summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/fixqt4headers23
-rwxr-xr-xconfigure4
-rw-r--r--demos/affine/affine.pro2
-rw-r--r--demos/books/bookdelegate.cpp2
-rw-r--r--demos/books/books.pro2
-rw-r--r--demos/books/bookwindow.h2
-rw-r--r--demos/books/main.cpp2
-rw-r--r--demos/boxes/boxes.pro2
-rw-r--r--demos/boxes/glbuffers.h2
-rw-r--r--demos/boxes/gltrianglemesh.h2
-rw-r--r--demos/boxes/main.cpp2
-rw-r--r--demos/boxes/qtbox.h2
-rw-r--r--demos/boxes/roundedbox.h2
-rw-r--r--demos/boxes/scene.h2
-rw-r--r--demos/boxes/trackball.h2
-rw-r--r--demos/chip/chip.cpp2
-rw-r--r--demos/chip/chip.h2
-rw-r--r--demos/chip/chip.pro2
-rw-r--r--demos/chip/mainwindow.cpp2
-rw-r--r--demos/chip/mainwindow.h2
-rw-r--r--demos/chip/view.cpp2
-rw-r--r--demos/composition/composition.pro2
-rw-r--r--demos/deform/deform.pro2
-rw-r--r--demos/demos.pro1
-rw-r--r--demos/embedded/digiflip/digiflip.cpp2
-rw-r--r--demos/embedded/digiflip/digiflip.pro1
-rw-r--r--demos/embedded/embedded.pro1
-rw-r--r--demos/embedded/flickable/flickable.cpp2
-rw-r--r--demos/embedded/flickable/flickable.pro1
-rw-r--r--demos/embedded/flickable/main.cpp2
-rw-r--r--demos/embedded/flightinfo/flightinfo.cpp2
-rw-r--r--demos/embedded/flightinfo/flightinfo.pro2
-rw-r--r--demos/embedded/lightmaps/lightmaps.cpp2
-rw-r--r--demos/embedded/lightmaps/lightmaps.pro2
-rw-r--r--demos/embedded/lightmaps/mapzoom.cpp2
-rw-r--r--demos/embedded/lightmaps/slippymap.cpp2
-rw-r--r--demos/embedded/raycasting/raycasting.cpp2
-rw-r--r--demos/embedded/raycasting/raycasting.pro1
-rw-r--r--demos/embedded/styledemo/styledemo.pro1
-rw-r--r--demos/embeddeddialogs/customproxy.cpp2
-rw-r--r--demos/embeddeddialogs/customproxy.h2
-rw-r--r--demos/embeddeddialogs/embeddeddialog.cpp2
-rw-r--r--demos/embeddeddialogs/embeddeddialog.h2
-rw-r--r--demos/embeddeddialogs/embeddeddialogs.pro1
-rw-r--r--demos/embeddeddialogs/main.cpp2
-rw-r--r--demos/gradients/gradients.h2
-rw-r--r--demos/gradients/gradients.pro2
-rw-r--r--demos/interview/interview.pro1
-rw-r--r--demos/macmainwindow/macmainwindow.h2
-rw-r--r--demos/macmainwindow/macmainwindow.pro1
-rw-r--r--demos/macmainwindow/main.cpp2
-rw-r--r--demos/mainwindow/mainwindow.pro1
-rw-r--r--demos/pathstroke/pathstroke.h2
-rw-r--r--demos/pathstroke/pathstroke.pro2
-rw-r--r--demos/shared/hoverpoints.h2
-rw-r--r--demos/shared/shared.pro4
-rw-r--r--demos/spreadsheet/main.cpp2
-rw-r--r--demos/spreadsheet/spreadsheet.cpp2
-rw-r--r--demos/spreadsheet/spreadsheet.pro3
-rw-r--r--demos/spreadsheet/spreadsheetdelegate.cpp2
-rw-r--r--demos/spreadsheet/spreadsheetitem.h2
-rw-r--r--demos/sqlbrowser/browser.cpp2
-rw-r--r--demos/sqlbrowser/connectionwidget.cpp2
-rw-r--r--demos/sqlbrowser/main.cpp2
-rw-r--r--demos/sqlbrowser/sqlbrowser.pro2
-rw-r--r--demos/sub-attaq/boat_p.h2
-rw-r--r--demos/sub-attaq/graphicsscene.cpp10
-rw-r--r--demos/sub-attaq/graphicsscene.h2
-rw-r--r--demos/sub-attaq/main.cpp2
-rw-r--r--demos/sub-attaq/mainwindow.h2
-rw-r--r--demos/sub-attaq/pixmapitem.h2
-rw-r--r--demos/sub-attaq/progressitem.h2
-rw-r--r--demos/sub-attaq/states.cpp6
-rw-r--r--demos/sub-attaq/states.h2
-rw-r--r--demos/sub-attaq/sub-attaq.pro2
-rw-r--r--demos/sub-attaq/submarine.h2
-rw-r--r--demos/sub-attaq/submarine_p.h2
-rw-r--r--demos/sub-attaq/textinformationitem.h2
-rw-r--r--demos/textedit/textedit.pro1
-rw-r--r--demos/undo/undo.pro1
-rw-r--r--examples/animation/animatedtiles/animatedtiles.pro1
-rw-r--r--examples/animation/animatedtiles/main.cpp2
-rw-r--r--examples/animation/animation.pro1
-rw-r--r--examples/animation/appchooser/appchooser.pro1
-rw-r--r--examples/animation/appchooser/main.cpp2
-rw-r--r--examples/animation/easing/animation.h2
-rw-r--r--examples/animation/easing/easing.pro1
-rw-r--r--examples/animation/easing/main.cpp2
-rw-r--r--examples/animation/easing/window.h2
-rw-r--r--examples/animation/moveblocks/main.cpp2
-rw-r--r--examples/animation/moveblocks/moveblocks.pro1
-rw-r--r--examples/animation/states/main.cpp2
-rw-r--r--examples/animation/states/states.pro1
-rw-r--r--examples/animation/stickman/graphicsview.cpp4
-rw-r--r--examples/animation/stickman/graphicsview.h2
-rw-r--r--examples/animation/stickman/lifecycle.cpp2
-rw-r--r--examples/animation/stickman/main.cpp2
-rw-r--r--examples/animation/stickman/stickman.pro1
-rw-r--r--examples/dbus/complexpingpong/complexpingpong.pro1
-rw-r--r--examples/dbus/dbus-chat/chat.cpp4
-rw-r--r--examples/dbus/dbus-chat/dbus-chat.pro1
-rw-r--r--examples/dbus/dbus.pro1
-rw-r--r--examples/dbus/pingpong/pingpong.pro1
-rw-r--r--examples/dbus/remotecontrolledcar/car/car.cpp2
-rw-r--r--examples/dbus/remotecontrolledcar/car/car.pro1
-rw-r--r--examples/dbus/remotecontrolledcar/car/main.cpp6
-rw-r--r--examples/dbus/remotecontrolledcar/controller/controller.cpp2
-rw-r--r--examples/dbus/remotecontrolledcar/controller/controller.pro1
-rw-r--r--examples/dbus/remotecontrolledcar/controller/main.cpp2
-rw-r--r--examples/dbus/remotecontrolledcar/remotecontrolledcar.pro1
-rw-r--r--examples/desktop/desktop.pro1
-rw-r--r--examples/desktop/screenshot/screenshot.cpp2
-rw-r--r--examples/desktop/screenshot/screenshot.pro1
-rw-r--r--examples/dialogs/classwizard/classwizard.cpp2
-rw-r--r--examples/dialogs/classwizard/classwizard.pro1
-rw-r--r--examples/dialogs/configdialog/configdialog.cpp2
-rw-r--r--examples/dialogs/configdialog/configdialog.pro1
-rw-r--r--examples/dialogs/configdialog/pages.cpp2
-rw-r--r--examples/dialogs/dialogs.pro1
-rw-r--r--examples/dialogs/extension/extension.pro1
-rw-r--r--examples/dialogs/extension/finddialog.cpp2
-rw-r--r--examples/dialogs/findfiles/findfiles.pro1
-rw-r--r--examples/dialogs/findfiles/window.cpp2
-rw-r--r--examples/dialogs/licensewizard/licensewizard.cpp2
-rw-r--r--examples/dialogs/licensewizard/licensewizard.pro1
-rw-r--r--examples/dialogs/sipdialog/dialog.cpp2
-rw-r--r--examples/dialogs/sipdialog/main.cpp2
-rw-r--r--examples/dialogs/sipdialog/sipdialog.pro1
-rw-r--r--examples/dialogs/standarddialogs/dialog.cpp2
-rw-r--r--examples/dialogs/standarddialogs/standarddialogs.pro1
-rw-r--r--examples/dialogs/tabdialog/tabdialog.cpp2
-rw-r--r--examples/dialogs/tabdialog/tabdialog.pro1
-rw-r--r--examples/dialogs/trivialwizard/trivialwizard.cpp2
-rw-r--r--examples/dialogs/trivialwizard/trivialwizard.pro1
-rw-r--r--examples/draganddrop/draganddrop.pro1
-rw-r--r--examples/draganddrop/draggableicons/draggableicons.pro1
-rw-r--r--examples/draganddrop/draggableicons/dragwidget.cpp2
-rw-r--r--examples/draganddrop/draggabletext/draggabletext.pro1
-rw-r--r--examples/draganddrop/draggabletext/draglabel.cpp2
-rw-r--r--examples/draganddrop/draggabletext/dragwidget.cpp2
-rw-r--r--examples/draganddrop/dropsite/droparea.cpp2
-rw-r--r--examples/draganddrop/dropsite/dropsite.pro1
-rw-r--r--examples/draganddrop/dropsite/dropsitewindow.cpp2
-rw-r--r--examples/draganddrop/fridgemagnets/draglabel.cpp2
-rw-r--r--examples/draganddrop/fridgemagnets/dragwidget.cpp2
-rw-r--r--examples/draganddrop/fridgemagnets/fridgemagnets.pro1
-rw-r--r--examples/draganddrop/puzzle/mainwindow.cpp2
-rw-r--r--examples/draganddrop/puzzle/pieceslist.cpp2
-rw-r--r--examples/draganddrop/puzzle/puzzle.pro1
-rw-r--r--examples/draganddrop/puzzle/puzzlewidget.cpp2
-rw-r--r--examples/effects/blurpicker/blurpicker.cpp2
-rw-r--r--examples/effects/blurpicker/blurpicker.pro1
-rw-r--r--examples/effects/effects.pro1
-rw-r--r--examples/effects/fademessage/fademessage.cpp2
-rw-r--r--examples/effects/fademessage/fademessage.pro1
-rw-r--r--examples/effects/lighting/lighting.cpp2
-rw-r--r--examples/effects/lighting/lighting.pro1
-rw-r--r--examples/examples.pro4
-rw-r--r--examples/gestures/gestures.pro1
-rw-r--r--examples/gestures/imagegestures/imagegestures.pro1
-rw-r--r--examples/gestures/imagegestures/imagewidget.cpp2
-rw-r--r--examples/gestures/imagegestures/imagewidget.h2
-rw-r--r--examples/gestures/imagegestures/main.cpp2
-rw-r--r--examples/graphicsview/anchorlayout/anchorlayout.pro1
-rw-r--r--examples/graphicsview/anchorlayout/main.cpp2
-rw-r--r--examples/graphicsview/basicgraphicslayouts/basicgraphicslayouts.pro1
-rw-r--r--examples/graphicsview/basicgraphicslayouts/layoutitem.h2
-rw-r--r--examples/graphicsview/basicgraphicslayouts/main.cpp2
-rw-r--r--examples/graphicsview/basicgraphicslayouts/window.h2
-rw-r--r--examples/graphicsview/collidingmice/collidingmice.pro1
-rw-r--r--examples/graphicsview/collidingmice/main.cpp2
-rw-r--r--examples/graphicsview/diagramscene/arrow.cpp2
-rw-r--r--examples/graphicsview/diagramscene/diagramitem.cpp2
-rw-r--r--examples/graphicsview/diagramscene/diagramscene.cpp2
-rw-r--r--examples/graphicsview/diagramscene/diagramscene.pro1
-rw-r--r--examples/graphicsview/diagramscene/diagramtextitem.cpp2
-rw-r--r--examples/graphicsview/diagramscene/main.cpp2
-rw-r--r--examples/graphicsview/diagramscene/mainwindow.cpp2
-rw-r--r--examples/graphicsview/dragdroprobot/coloritem.cpp2
-rw-r--r--examples/graphicsview/dragdroprobot/dragdroprobot.pro1
-rw-r--r--examples/graphicsview/dragdroprobot/main.cpp2
-rw-r--r--examples/graphicsview/dragdroprobot/robot.cpp2
-rw-r--r--examples/graphicsview/elasticnodes/elasticnodes.pro1
-rw-r--r--examples/graphicsview/elasticnodes/graphwidget.cpp2
-rw-r--r--examples/graphicsview/elasticnodes/graphwidget.h2
-rw-r--r--examples/graphicsview/elasticnodes/main.cpp2
-rw-r--r--examples/graphicsview/flowlayout/flowlayout.cpp2
-rw-r--r--examples/graphicsview/flowlayout/flowlayout.h2
-rw-r--r--examples/graphicsview/flowlayout/flowlayout.pro1
-rw-r--r--examples/graphicsview/flowlayout/main.cpp2
-rw-r--r--examples/graphicsview/flowlayout/window.cpp4
-rw-r--r--examples/graphicsview/flowlayout/window.h2
-rw-r--r--examples/graphicsview/graphicsview.pro1
-rw-r--r--examples/graphicsview/padnavigator/flippablepad.cpp2
-rw-r--r--examples/graphicsview/padnavigator/main.cpp2
-rw-r--r--examples/graphicsview/padnavigator/padnavigator.cpp2
-rw-r--r--examples/graphicsview/padnavigator/padnavigator.pro2
-rw-r--r--examples/graphicsview/padnavigator/roundrectitem.cpp2
-rw-r--r--examples/graphicsview/padnavigator/splashitem.cpp2
-rw-r--r--examples/graphicsview/simpleanchorlayout/main.cpp2
-rw-r--r--examples/graphicsview/simpleanchorlayout/simpleanchorlayout.pro1
-rw-r--r--examples/graphicsview/weatheranchorlayout/weatheranchorlayout.pro1
-rw-r--r--examples/ipc/ipc.pro1
-rw-r--r--examples/ipc/localfortuneclient/client.cpp2
-rw-r--r--examples/ipc/localfortuneclient/localfortuneclient.pro2
-rw-r--r--examples/ipc/localfortuneserver/localfortuneserver.pro2
-rw-r--r--examples/ipc/localfortuneserver/server.cpp2
-rw-r--r--examples/ipc/sharedmemory/sharedmemory.pro1
-rw-r--r--examples/itemviews/addressbook/adddialog.cpp2
-rw-r--r--examples/itemviews/addressbook/addressbook.pro1
-rw-r--r--examples/itemviews/addressbook/addresswidget.cpp2
-rw-r--r--examples/itemviews/addressbook/main.cpp2
-rw-r--r--examples/itemviews/addressbook/mainwindow.cpp2
-rw-r--r--examples/itemviews/addressbook/mainwindow.h2
-rw-r--r--examples/itemviews/addressbook/newaddresstab.cpp2
-rw-r--r--examples/itemviews/basicsortfiltermodel/basicsortfiltermodel.pro1
-rw-r--r--examples/itemviews/basicsortfiltermodel/main.cpp2
-rw-r--r--examples/itemviews/basicsortfiltermodel/window.cpp2
-rw-r--r--examples/itemviews/chart/chart.pro1
-rw-r--r--examples/itemviews/chart/mainwindow.cpp2
-rw-r--r--examples/itemviews/chart/pieview.cpp2
-rw-r--r--examples/itemviews/coloreditorfactory/coloreditorfactory.pro1
-rw-r--r--examples/itemviews/coloreditorfactory/colorlisteditor.cpp2
-rw-r--r--examples/itemviews/coloreditorfactory/main.cpp2
-rw-r--r--examples/itemviews/coloreditorfactory/window.cpp2
-rw-r--r--examples/itemviews/combowidgetmapper/combowidgetmapper.pro1
-rw-r--r--examples/itemviews/combowidgetmapper/window.cpp2
-rw-r--r--examples/itemviews/customsortfiltermodel/customsortfiltermodel.pro1
-rw-r--r--examples/itemviews/customsortfiltermodel/main.cpp2
-rw-r--r--examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp2
-rw-r--r--examples/itemviews/customsortfiltermodel/window.cpp2
-rw-r--r--examples/itemviews/dirview/dirview.pro1
-rw-r--r--examples/itemviews/dirview/main.cpp2
-rw-r--r--examples/itemviews/editabletreemodel/editabletreemodel.pro1
-rw-r--r--examples/itemviews/editabletreemodel/main.cpp2
-rw-r--r--examples/itemviews/editabletreemodel/mainwindow.cpp2
-rw-r--r--examples/itemviews/editabletreemodel/treemodel.cpp2
-rw-r--r--examples/itemviews/fetchmore/fetchmore.pro1
-rw-r--r--examples/itemviews/fetchmore/window.cpp2
-rw-r--r--examples/itemviews/frozencolumn/freezetablewidget.cpp2
-rw-r--r--examples/itemviews/frozencolumn/frozencolumn.pro1
-rw-r--r--examples/itemviews/itemviews.pro1
-rw-r--r--examples/itemviews/pixelator/imagemodel.cpp2
-rw-r--r--examples/itemviews/pixelator/mainwindow.cpp2
-rw-r--r--examples/itemviews/pixelator/pixelator.pro1
-rw-r--r--examples/itemviews/pixelator/pixeldelegate.cpp2
-rw-r--r--examples/itemviews/puzzle/mainwindow.cpp2
-rw-r--r--examples/itemviews/puzzle/piecesmodel.cpp2
-rw-r--r--examples/itemviews/puzzle/puzzle.pro1
-rw-r--r--examples/itemviews/puzzle/puzzlewidget.cpp2
-rw-r--r--examples/itemviews/simpledommodel/dommodel.cpp2
-rw-r--r--examples/itemviews/simpledommodel/mainwindow.cpp2
-rw-r--r--examples/itemviews/simpledommodel/simpledommodel.pro2
-rw-r--r--examples/itemviews/simpletreemodel/main.cpp2
-rw-r--r--examples/itemviews/simpletreemodel/simpletreemodel.pro1
-rw-r--r--examples/itemviews/simpletreemodel/treemodel.cpp2
-rw-r--r--examples/itemviews/simplewidgetmapper/simplewidgetmapper.pro1
-rw-r--r--examples/itemviews/simplewidgetmapper/window.cpp2
-rw-r--r--examples/itemviews/spinboxdelegate/delegate.cpp2
-rw-r--r--examples/itemviews/spinboxdelegate/spinboxdelegate.pro1
-rw-r--r--examples/itemviews/stardelegate/main.cpp2
-rw-r--r--examples/itemviews/stardelegate/stardelegate.cpp2
-rw-r--r--examples/itemviews/stardelegate/stardelegate.pro1
-rw-r--r--examples/itemviews/stardelegate/stareditor.cpp2
-rw-r--r--examples/itemviews/stardelegate/starrating.cpp2
-rw-r--r--examples/ja_JP/linguist/hellotr/hellotr.pro1
-rw-r--r--examples/layouts/basiclayouts/basiclayouts.pro1
-rw-r--r--examples/layouts/basiclayouts/dialog.cpp2
-rw-r--r--examples/layouts/borderlayout/borderlayout.cpp2
-rw-r--r--examples/layouts/borderlayout/borderlayout.pro1
-rw-r--r--examples/layouts/borderlayout/window.cpp2
-rw-r--r--examples/layouts/dynamiclayouts/dialog.cpp2
-rw-r--r--examples/layouts/dynamiclayouts/dynamiclayouts.pro1
-rw-r--r--examples/layouts/flowlayout/flowlayout.cpp2
-rw-r--r--examples/layouts/flowlayout/flowlayout.pro1
-rw-r--r--examples/layouts/flowlayout/window.cpp2
-rw-r--r--examples/layouts/layouts.pro1
-rw-r--r--examples/linguist/arrowpad/arrowpad.cpp2
-rw-r--r--examples/linguist/arrowpad/arrowpad.pro1
-rw-r--r--examples/linguist/arrowpad/main.cpp2
-rw-r--r--examples/linguist/arrowpad/mainwindow.cpp2
-rw-r--r--examples/linguist/hellotr/hellotr.pro1
-rw-r--r--examples/linguist/linguist.pro1
-rw-r--r--examples/linguist/trollprint/main.cpp2
-rw-r--r--examples/linguist/trollprint/mainwindow.cpp2
-rw-r--r--examples/linguist/trollprint/printpanel.cpp2
-rw-r--r--examples/linguist/trollprint/trollprint.pro1
-rw-r--r--examples/mainwindows/application/application.pro1
-rw-r--r--examples/mainwindows/application/mainwindow.cpp2
-rw-r--r--examples/mainwindows/dockwidgets/dockwidgets.pro1
-rw-r--r--examples/mainwindows/dockwidgets/mainwindow.cpp2
-rw-r--r--examples/mainwindows/mainwindows.pro1
-rw-r--r--examples/mainwindows/mdi/mainwindow.cpp2
-rw-r--r--examples/mainwindows/mdi/mdi.pro1
-rw-r--r--examples/mainwindows/mdi/mdichild.cpp2
-rw-r--r--examples/mainwindows/menus/mainwindow.cpp2
-rw-r--r--examples/mainwindows/menus/menus.pro1
-rw-r--r--examples/mainwindows/recentfiles/mainwindow.cpp2
-rw-r--r--examples/mainwindows/recentfiles/recentfiles.pro1
-rw-r--r--examples/mainwindows/sdi/mainwindow.cpp2
-rw-r--r--examples/mainwindows/sdi/sdi.pro1
-rw-r--r--examples/network/bearermonitor/bearermonitor.pro2
-rw-r--r--examples/network/bearermonitor/main.cpp4
-rw-r--r--examples/network/blockingfortuneclient/blockingclient.cpp2
-rw-r--r--examples/network/blockingfortuneclient/blockingfortuneclient.pro2
-rw-r--r--examples/network/broadcastreceiver/broadcastreceiver.pro2
-rw-r--r--examples/network/broadcastreceiver/receiver.cpp2
-rw-r--r--examples/network/broadcastsender/broadcastsender.pro2
-rw-r--r--examples/network/broadcastsender/sender.cpp2
-rw-r--r--examples/network/fortuneclient/client.cpp2
-rw-r--r--examples/network/fortuneclient/fortuneclient.pro2
-rw-r--r--examples/network/fortuneserver/fortuneserver.pro2
-rw-r--r--examples/network/fortuneserver/server.cpp2
-rw-r--r--examples/network/googlesuggest/googlesuggest.h2
-rw-r--r--examples/network/googlesuggest/googlesuggest.pro2
-rw-r--r--examples/network/http/http.pro2
-rw-r--r--examples/network/http/httpwindow.cpp2
-rw-r--r--examples/network/loopback/dialog.cpp2
-rw-r--r--examples/network/loopback/loopback.pro2
-rw-r--r--examples/network/multicastreceiver/multicastreceiver.pro2
-rw-r--r--examples/network/multicastreceiver/receiver.cpp2
-rw-r--r--examples/network/multicastsender/multicastsender.pro2
-rw-r--r--examples/network/multicastsender/sender.cpp2
-rw-r--r--examples/network/network-chat/chatdialog.cpp2
-rw-r--r--examples/network/network-chat/network-chat.pro2
-rw-r--r--examples/network/network.pro1
-rw-r--r--examples/network/qftp/ftpwindow.cpp2
-rw-r--r--examples/network/qftp/qftp.pro2
-rw-r--r--examples/network/securesocketclient/certificateinfo.h2
-rw-r--r--examples/network/securesocketclient/securesocketclient.pro2
-rw-r--r--examples/network/securesocketclient/sslclient.cpp6
-rw-r--r--examples/network/securesocketclient/sslclient.h2
-rw-r--r--examples/network/threadedfortuneserver/dialog.cpp2
-rw-r--r--examples/network/threadedfortuneserver/threadedfortuneserver.pro2
-rw-r--r--examples/network/torrent/mainwindow.cpp2
-rw-r--r--examples/network/torrent/torrent.pro2
-rw-r--r--examples/opengl/2dpainting/2dpainting.pro2
-rw-r--r--examples/opengl/2dpainting/glwidget.cpp2
-rw-r--r--examples/opengl/2dpainting/helper.cpp2
-rw-r--r--examples/opengl/2dpainting/widget.cpp2
-rw-r--r--examples/opengl/2dpainting/window.cpp2
-rw-r--r--examples/opengl/framebufferobject2/framebufferobject2.pro2
-rw-r--r--examples/opengl/framebufferobject2/main.cpp4
-rw-r--r--examples/opengl/grabber/glwidget.cpp2
-rw-r--r--examples/opengl/grabber/grabber.pro2
-rw-r--r--examples/opengl/grabber/mainwindow.cpp2
-rw-r--r--examples/opengl/hellogl/glwidget.cpp2
-rw-r--r--examples/opengl/hellogl/hellogl.pro2
-rw-r--r--examples/opengl/hellogl/window.cpp2
-rw-r--r--examples/opengl/hellogl_es/bubble.cpp2
-rw-r--r--examples/opengl/hellogl_es/hellogl_es.pro2
-rw-r--r--examples/opengl/hellogl_es2/bubble.cpp2
-rw-r--r--examples/opengl/hellogl_es2/hellogl_es2.pro2
-rw-r--r--examples/opengl/hellowindow/hellowindow.cpp268
-rw-r--r--examples/opengl/hellowindow/hellowindow.h40
-rw-r--r--examples/opengl/hellowindow/hellowindow.pro14
-rw-r--r--examples/opengl/hellowindow/main.cpp13
-rw-r--r--examples/opengl/opengl.pro5
-rw-r--r--examples/opengl/overpainting/bubble.cpp2
-rw-r--r--examples/opengl/overpainting/glwidget.cpp2
-rw-r--r--examples/opengl/overpainting/overpainting.pro2
-rw-r--r--examples/opengl/pbuffers/main.cpp4
-rw-r--r--examples/opengl/pbuffers/pbuffers.pro2
-rw-r--r--examples/opengl/pbuffers2/main.cpp4
-rw-r--r--examples/opengl/pbuffers2/pbuffers2.pro2
-rw-r--r--examples/opengl/samplebuffers/main.cpp4
-rw-r--r--examples/opengl/samplebuffers/samplebuffers.pro2
-rw-r--r--examples/opengl/textures/glwidget.cpp2
-rw-r--r--examples/opengl/textures/glwidget.h2
-rw-r--r--examples/opengl/textures/textures.pro2
-rw-r--r--examples/opengl/textures/window.cpp2
-rw-r--r--examples/openvg/openvg.pro1
-rw-r--r--examples/openvg/star/star.pro2
-rw-r--r--examples/painting/basicdrawing/basicdrawing.pro1
-rw-r--r--examples/painting/basicdrawing/renderarea.cpp2
-rw-r--r--examples/painting/basicdrawing/window.cpp2
-rw-r--r--examples/painting/concentriccircles/circlewidget.cpp2
-rw-r--r--examples/painting/concentriccircles/concentriccircles.pro1
-rw-r--r--examples/painting/concentriccircles/window.cpp2
-rw-r--r--examples/painting/fontsampler/fontsampler.pro1
-rw-r--r--examples/painting/fontsampler/mainwindow.cpp2
-rw-r--r--examples/painting/imagecomposition/imagecomposer.cpp2
-rw-r--r--examples/painting/imagecomposition/imagecomposition.pro1
-rw-r--r--examples/painting/painterpaths/painterpaths.pro1
-rw-r--r--examples/painting/painterpaths/renderarea.cpp2
-rw-r--r--examples/painting/painterpaths/window.cpp2
-rw-r--r--examples/painting/painting.pro1
-rw-r--r--examples/painting/transformations/renderarea.cpp2
-rw-r--r--examples/painting/transformations/transformations.pro1
-rw-r--r--examples/painting/transformations/window.cpp2
-rw-r--r--examples/qmake/precompile/precompile.pro1
-rw-r--r--examples/qpa/qpa.pro9
-rw-r--r--examples/qpa/windows/main.cpp19
-rw-r--r--examples/qpa/windows/window.cpp126
-rw-r--r--examples/qpa/windows/window.h25
-rw-r--r--examples/qpa/windows/windows.pro15
-rw-r--r--examples/qtconcurrent/imagescaling/imagescaling.h2
-rw-r--r--examples/qtconcurrent/imagescaling/imagescaling.pro1
-rw-r--r--examples/qtconcurrent/imagescaling/main.cpp2
-rw-r--r--examples/qtconcurrent/map/map.pro1
-rw-r--r--examples/qtconcurrent/progressdialog/main.cpp2
-rw-r--r--examples/qtconcurrent/progressdialog/progressdialog.pro1
-rw-r--r--examples/qtconcurrent/qtconcurrent.pro1
-rw-r--r--examples/qtconcurrent/runfunction/runfunction.pro1
-rw-r--r--examples/qtconcurrent/wordcount/wordcount.pro1
-rw-r--r--examples/qtestlib/qtestlib.pro1
-rw-r--r--examples/qtestlib/tutorial1/tutorial1.pro1
-rw-r--r--examples/qtestlib/tutorial2/tutorial2.pro1
-rw-r--r--examples/qtestlib/tutorial3/testgui.cpp2
-rw-r--r--examples/qtestlib/tutorial3/tutorial3.pro1
-rw-r--r--examples/qtestlib/tutorial4/testgui.cpp2
-rw-r--r--examples/qtestlib/tutorial4/tutorial4.pro1
-rw-r--r--examples/qtestlib/tutorial5/benchmarking.cpp2
-rw-r--r--examples/qtestlib/tutorial5/tutorial5.pro1
-rw-r--r--examples/qws/dbscreen/dbscreen.pro1
-rw-r--r--examples/qws/framebuffer/framebuffer.pro1
-rw-r--r--examples/qws/mousecalibration/mousecalibration.pro1
-rw-r--r--examples/qws/qws.pro1
-rw-r--r--examples/qws/simpledecoration/analogclock.cpp2
-rw-r--r--examples/qws/simpledecoration/mydecoration.cpp2
-rw-r--r--examples/qws/simpledecoration/simpledecoration.pro1
-rw-r--r--examples/qws/svgalib/svgalib.pro1
-rw-r--r--examples/richtext/calendar/calendar.pro1
-rw-r--r--examples/richtext/calendar/main.cpp2
-rw-r--r--examples/richtext/calendar/mainwindow.cpp2
-rw-r--r--examples/richtext/orderform/detailsdialog.cpp2
-rw-r--r--examples/richtext/orderform/main.cpp2
-rw-r--r--examples/richtext/orderform/mainwindow.cpp2
-rw-r--r--examples/richtext/orderform/orderform.pro1
-rw-r--r--examples/richtext/richtext.pro1
-rw-r--r--examples/richtext/syntaxhighlighter/highlighter.cpp2
-rw-r--r--examples/richtext/syntaxhighlighter/mainwindow.cpp2
-rw-r--r--examples/richtext/syntaxhighlighter/syntaxhighlighter.pro1
-rw-r--r--examples/scroller/graphicsview/graphicsview.pro1
-rw-r--r--examples/scroller/graphicsview/main.cpp2
-rw-r--r--examples/scroller/scroller.pro1
-rw-r--r--examples/sql/cachedtable/cachedtable.pro2
-rw-r--r--examples/sql/cachedtable/tableeditor.cpp2
-rw-r--r--examples/sql/drilldown/drilldown.pro2
-rw-r--r--examples/sql/drilldown/imageitem.h2
-rw-r--r--examples/sql/drilldown/informationwindow.h2
-rw-r--r--examples/sql/drilldown/main.cpp2
-rw-r--r--examples/sql/drilldown/view.h2
-rw-r--r--examples/sql/masterdetail/dialog.h2
-rw-r--r--examples/sql/masterdetail/main.cpp2
-rw-r--r--examples/sql/masterdetail/mainwindow.cpp2
-rw-r--r--examples/sql/masterdetail/masterdetail.pro4
-rw-r--r--examples/sql/querymodel/customsqlmodel.cpp2
-rw-r--r--examples/sql/querymodel/main.cpp2
-rw-r--r--examples/sql/querymodel/querymodel.pro2
-rw-r--r--examples/sql/relationaltablemodel/relationaltablemodel.cpp2
-rw-r--r--examples/sql/relationaltablemodel/relationaltablemodel.pro2
-rw-r--r--examples/sql/sql.pro1
-rw-r--r--examples/sql/sqlwidgetmapper/sqlwidgetmapper.pro2
-rw-r--r--examples/sql/sqlwidgetmapper/window.cpp2
-rw-r--r--examples/sql/tablemodel/tablemodel.cpp2
-rw-r--r--examples/sql/tablemodel/tablemodel.pro2
-rw-r--r--examples/statemachine/eventtransitions/eventtransitions.pro1
-rw-r--r--examples/statemachine/eventtransitions/main.cpp2
-rw-r--r--examples/statemachine/rogue/main.cpp2
-rw-r--r--examples/statemachine/rogue/movementtransition.h2
-rw-r--r--examples/statemachine/rogue/rogue.pro1
-rw-r--r--examples/statemachine/rogue/window.cpp2
-rw-r--r--examples/statemachine/statemachine.pro1
-rw-r--r--examples/statemachine/trafficlight/main.cpp2
-rw-r--r--examples/statemachine/trafficlight/trafficlight.pro1
-rw-r--r--examples/statemachine/twowaybutton/main.cpp2
-rw-r--r--examples/statemachine/twowaybutton/twowaybutton.pro1
-rw-r--r--examples/threads/mandelbrot/mandelbrot.pro1
-rw-r--r--examples/threads/mandelbrot/mandelbrotwidget.cpp2
-rw-r--r--examples/threads/mandelbrot/renderthread.cpp2
-rw-r--r--examples/threads/queuedcustomtype/queuedcustomtype.pro1
-rw-r--r--examples/threads/queuedcustomtype/window.cpp2
-rw-r--r--examples/threads/threads.pro1
-rw-r--r--examples/tools/codecs/codecs.pro1
-rw-r--r--examples/tools/codecs/mainwindow.cpp2
-rw-r--r--examples/tools/codecs/previewform.cpp2
-rw-r--r--examples/tools/completer/completer.pro1
-rw-r--r--examples/tools/completer/mainwindow.cpp2
-rw-r--r--examples/tools/contiguouscache/contiguouscache.pro1
-rw-r--r--examples/tools/customcompleter/customcompleter.pro1
-rw-r--r--examples/tools/customcompleter/mainwindow.cpp2
-rw-r--r--examples/tools/customtype/customtype.pro1
-rw-r--r--examples/tools/customtypesending/customtypesending.pro1
-rw-r--r--examples/tools/customtypesending/window.cpp2
-rw-r--r--examples/tools/echoplugin/echoplugin.pro1
-rw-r--r--examples/tools/echoplugin/echowindow/echowindow.cpp2
-rw-r--r--examples/tools/echoplugin/echowindow/echowindow.pro1
-rw-r--r--examples/tools/echoplugin/echowindow/main.cpp2
-rw-r--r--examples/tools/echoplugin/plugin/echoplugin.cpp2
-rw-r--r--examples/tools/echoplugin/plugin/plugin.pro1
-rw-r--r--examples/tools/i18n/i18n.pro1
-rw-r--r--examples/tools/i18n/languagechooser.cpp2
-rw-r--r--examples/tools/i18n/mainwindow.cpp2
-rw-r--r--examples/tools/inputpanel/inputpanel.pro1
-rw-r--r--examples/tools/inputpanel/main.cpp4
-rw-r--r--examples/tools/inputpanel/myinputpanel.h2
-rw-r--r--examples/tools/inputpanel/myinputpanelcontext.h2
-rw-r--r--examples/tools/plugandpaint/plugandpaint.pro1
-rw-r--r--examples/tools/plugandpaintplugins/basictools/basictools.pro1
-rw-r--r--examples/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp2
-rw-r--r--examples/tools/plugandpaintplugins/extrafilters/extrafilters.pro1
-rw-r--r--examples/tools/plugandpaintplugins/extrafilters/extrafiltersplugin.cpp2
-rw-r--r--examples/tools/plugandpaintplugins/plugandpaintplugins.pro1
-rw-r--r--examples/tools/regexp/regexp.pro1
-rw-r--r--examples/tools/regexp/regexpdialog.cpp2
-rw-r--r--examples/tools/settingseditor/locationdialog.cpp2
-rw-r--r--examples/tools/settingseditor/mainwindow.cpp2
-rw-r--r--examples/tools/settingseditor/settingseditor.pro1
-rw-r--r--examples/tools/settingseditor/settingstree.cpp2
-rw-r--r--examples/tools/settingseditor/variantdelegate.cpp2
-rw-r--r--examples/tools/styleplugin/plugin/plugin.pro1
-rw-r--r--examples/tools/styleplugin/plugin/simplestyle.cpp2
-rw-r--r--examples/tools/styleplugin/plugin/simplestyleplugin.cpp2
-rw-r--r--examples/tools/styleplugin/styleplugin.pro1
-rw-r--r--examples/tools/styleplugin/stylewindow/main.cpp2
-rw-r--r--examples/tools/styleplugin/stylewindow/stylewindow.cpp2
-rw-r--r--examples/tools/styleplugin/stylewindow/stylewindow.pro1
-rw-r--r--examples/tools/tools.pro1
-rw-r--r--examples/tools/treemodelcompleter/mainwindow.cpp2
-rw-r--r--examples/tools/treemodelcompleter/treemodelcompleter.pro1
-rw-r--r--examples/tools/undoframework/commands.cpp2
-rw-r--r--examples/tools/undoframework/diagramitem.cpp2
-rw-r--r--examples/tools/undoframework/diagramscene.cpp2
-rw-r--r--examples/tools/undoframework/main.cpp2
-rw-r--r--examples/tools/undoframework/mainwindow.cpp2
-rw-r--r--examples/tools/undoframework/undoframework.pro1
-rw-r--r--examples/touch/dials/dials.pro1
-rw-r--r--examples/touch/fingerpaint/fingerpaint.pro1
-rw-r--r--examples/touch/fingerpaint/mainwindow.cpp2
-rw-r--r--examples/touch/fingerpaint/scribblearea.cpp2
-rw-r--r--examples/touch/knobs/knobs.pro1
-rw-r--r--examples/touch/pinchzoom/main.cpp2
-rw-r--r--examples/touch/pinchzoom/pinchzoom.pro1
-rw-r--r--examples/touch/touch.pro1
-rw-r--r--examples/tutorials/addressbook-fr/addressbook-fr.pro1
-rw-r--r--examples/tutorials/addressbook-fr/part1/addressbook.cpp2
-rw-r--r--examples/tutorials/addressbook-fr/part1/main.cpp2
-rw-r--r--examples/tutorials/addressbook-fr/part1/part1.pro1
-rw-r--r--examples/tutorials/addressbook-fr/part2/addressbook.cpp2
-rw-r--r--examples/tutorials/addressbook-fr/part2/main.cpp2
-rw-r--r--examples/tutorials/addressbook-fr/part2/part2.pro1
-rw-r--r--examples/tutorials/addressbook-fr/part3/addressbook.cpp2
-rw-r--r--examples/tutorials/addressbook-fr/part3/main.cpp2
-rw-r--r--examples/tutorials/addressbook-fr/part3/part3.pro1
-rw-r--r--examples/tutorials/addressbook-fr/part4/addressbook.cpp2
-rw-r--r--examples/tutorials/addressbook-fr/part4/main.cpp2
-rw-r--r--examples/tutorials/addressbook-fr/part4/part4.pro1
-rw-r--r--examples/tutorials/addressbook-fr/part5/addressbook.cpp2
-rw-r--r--examples/tutorials/addressbook-fr/part5/finddialog.cpp2
-rw-r--r--examples/tutorials/addressbook-fr/part5/main.cpp2
-rw-r--r--examples/tutorials/addressbook-fr/part5/part5.pro1
-rw-r--r--examples/tutorials/addressbook-fr/part6/addressbook.cpp2
-rw-r--r--examples/tutorials/addressbook-fr/part6/finddialog.cpp2
-rw-r--r--examples/tutorials/addressbook-fr/part6/main.cpp2
-rw-r--r--examples/tutorials/addressbook-fr/part6/part6.pro1
-rw-r--r--examples/tutorials/addressbook-fr/part7/addressbook.cpp2
-rw-r--r--examples/tutorials/addressbook-fr/part7/finddialog.cpp2
-rw-r--r--examples/tutorials/addressbook-fr/part7/main.cpp2
-rw-r--r--examples/tutorials/addressbook-fr/part7/part7.pro1
-rw-r--r--examples/tutorials/addressbook/addressbook.pro1
-rw-r--r--examples/tutorials/addressbook/part1/addressbook.cpp2
-rw-r--r--examples/tutorials/addressbook/part1/main.cpp2
-rw-r--r--examples/tutorials/addressbook/part1/part1.pro1
-rw-r--r--examples/tutorials/addressbook/part2/addressbook.cpp2
-rw-r--r--examples/tutorials/addressbook/part2/main.cpp2
-rw-r--r--examples/tutorials/addressbook/part2/part2.pro1
-rw-r--r--examples/tutorials/addressbook/part3/addressbook.cpp2
-rw-r--r--examples/tutorials/addressbook/part3/main.cpp2
-rw-r--r--examples/tutorials/addressbook/part3/part3.pro1
-rw-r--r--examples/tutorials/addressbook/part4/addressbook.cpp2
-rw-r--r--examples/tutorials/addressbook/part4/main.cpp2
-rw-r--r--examples/tutorials/addressbook/part4/part4.pro1
-rw-r--r--examples/tutorials/addressbook/part5/addressbook.cpp2
-rw-r--r--examples/tutorials/addressbook/part5/finddialog.cpp2
-rw-r--r--examples/tutorials/addressbook/part5/main.cpp2
-rw-r--r--examples/tutorials/addressbook/part5/part5.pro1
-rw-r--r--examples/tutorials/addressbook/part6/addressbook.cpp2
-rw-r--r--examples/tutorials/addressbook/part6/finddialog.cpp2
-rw-r--r--examples/tutorials/addressbook/part6/main.cpp2
-rw-r--r--examples/tutorials/addressbook/part6/part6.pro1
-rw-r--r--examples/tutorials/addressbook/part7/addressbook.cpp2
-rw-r--r--examples/tutorials/addressbook/part7/finddialog.cpp2
-rw-r--r--examples/tutorials/addressbook/part7/main.cpp2
-rw-r--r--examples/tutorials/addressbook/part7/part7.pro1
-rw-r--r--examples/tutorials/gettingStarted/gettingStarted.pro1
-rwxr-xr-xexamples/tutorials/gettingStarted/gsQt/gsqt.pro1
-rwxr-xr-xexamples/tutorials/gettingStarted/gsQt/part1/main.cpp2
-rwxr-xr-xexamples/tutorials/gettingStarted/gsQt/part2/main.cpp2
-rwxr-xr-xexamples/tutorials/gettingStarted/gsQt/part3/main.cpp2
-rwxr-xr-xexamples/tutorials/gettingStarted/gsQt/part4/main.cpp2
-rwxr-xr-xexamples/tutorials/gettingStarted/gsQt/part5/main.cpp2
-rwxr-xr-xexamples/tutorials/modelview/1_readonly/1_readonly.pro1
-rwxr-xr-xexamples/tutorials/modelview/1_readonly/main.cpp4
-rwxr-xr-xexamples/tutorials/modelview/2_formatting/2_formatting.pro1
-rwxr-xr-xexamples/tutorials/modelview/2_formatting/main.cpp4
-rwxr-xr-xexamples/tutorials/modelview/3_changingmodel/3_changingmodel.pro1
-rwxr-xr-xexamples/tutorials/modelview/3_changingmodel/main.cpp4
-rwxr-xr-xexamples/tutorials/modelview/4_headers/4_headers.pro1
-rwxr-xr-xexamples/tutorials/modelview/4_headers/main.cpp4
-rwxr-xr-xexamples/tutorials/modelview/5_edit/5_edit.pro1
-rwxr-xr-xexamples/tutorials/modelview/5_edit/main.cpp2
-rwxr-xr-xexamples/tutorials/modelview/5_edit/mainwindow.h2
-rwxr-xr-xexamples/tutorials/modelview/6_treeview/6_treeview.pro1
-rwxr-xr-xexamples/tutorials/modelview/6_treeview/main.cpp2
-rwxr-xr-xexamples/tutorials/modelview/6_treeview/mainwindow.h2
-rwxr-xr-xexamples/tutorials/modelview/7_selections/7_selections.pro1
-rwxr-xr-xexamples/tutorials/modelview/7_selections/main.cpp2
-rwxr-xr-xexamples/tutorials/modelview/7_selections/mainwindow.h2
-rwxr-xr-xexamples/tutorials/modelview/modelview.pro1
-rwxr-xr-xexamples/tutorials/threads/clock/clock.pro1
-rw-r--r--examples/tutorials/threads/clock/clockthread.cpp2
-rwxr-xr-xexamples/tutorials/threads/clock/main.cpp2
-rwxr-xr-xexamples/tutorials/threads/movedobject/movedobject.pro1
-rw-r--r--examples/tutorials/threads/threads.pro1
-rw-r--r--examples/tutorials/tutorials.pro1
-rw-r--r--examples/tutorials/widgets/childwidget/childwidget.pro1
-rw-r--r--examples/tutorials/widgets/childwidget/main.cpp2
-rw-r--r--examples/tutorials/widgets/nestedlayouts/main.cpp2
-rw-r--r--examples/tutorials/widgets/nestedlayouts/nestedlayouts.pro1
-rw-r--r--examples/tutorials/widgets/toplevel/main.cpp2
-rw-r--r--examples/tutorials/widgets/toplevel/toplevel.pro1
-rw-r--r--examples/tutorials/widgets/widgets.pro1
-rw-r--r--examples/tutorials/widgets/windowlayout/main.cpp2
-rw-r--r--examples/tutorials/widgets/windowlayout/windowlayout.pro1
-rw-r--r--examples/uitools/multipleinheritance/calculatorform.cpp2
-rw-r--r--examples/uitools/multipleinheritance/multipleinheritance.pro1
-rw-r--r--examples/uitools/textfinder/textfinder.cpp2
-rw-r--r--examples/uitools/textfinder/textfinder.pro1
-rw-r--r--examples/uitools/uitools.pro1
-rw-r--r--examples/webkit/webkit-guide/webkit-guide.pro1
-rw-r--r--examples/widgets/analogclock/analogclock.cpp2
-rw-r--r--examples/widgets/analogclock/analogclock.pro1
-rw-r--r--examples/widgets/calculator/button.cpp2
-rw-r--r--examples/widgets/calculator/calculator.cpp2
-rw-r--r--examples/widgets/calculator/calculator.pro1
-rw-r--r--examples/widgets/calendarwidget/calendarwidget.pro1
-rw-r--r--examples/widgets/calendarwidget/main.cpp2
-rw-r--r--examples/widgets/calendarwidget/window.cpp2
-rw-r--r--examples/widgets/charactermap/charactermap.pro1
-rw-r--r--examples/widgets/charactermap/characterwidget.cpp2
-rw-r--r--examples/widgets/charactermap/mainwindow.cpp2
-rw-r--r--examples/widgets/codeeditor/codeeditor.cpp2
-rw-r--r--examples/widgets/codeeditor/codeeditor.pro1
-rw-r--r--examples/widgets/codeeditor/main.cpp2
-rw-r--r--examples/widgets/digitalclock/digitalclock.cpp2
-rw-r--r--examples/widgets/digitalclock/digitalclock.pro1
-rw-r--r--examples/widgets/groupbox/groupbox.pro1
-rw-r--r--examples/widgets/groupbox/window.cpp2
-rw-r--r--examples/widgets/icons/iconpreviewarea.cpp2
-rw-r--r--examples/widgets/icons/icons.pro1
-rw-r--r--examples/widgets/icons/iconsizespinbox.cpp2
-rw-r--r--examples/widgets/icons/imagedelegate.cpp2
-rw-r--r--examples/widgets/icons/mainwindow.cpp2
-rw-r--r--examples/widgets/imageviewer/imageviewer.cpp2
-rw-r--r--examples/widgets/imageviewer/imageviewer.pro1
-rw-r--r--examples/widgets/lineedits/lineedits.pro1
-rw-r--r--examples/widgets/lineedits/window.cpp2
-rw-r--r--examples/widgets/movie/movie.pro1
-rw-r--r--examples/widgets/movie/movieplayer.cpp2
-rw-r--r--examples/widgets/scribble/mainwindow.cpp2
-rw-r--r--examples/widgets/scribble/scribble.pro1
-rw-r--r--examples/widgets/scribble/scribblearea.cpp2
-rw-r--r--examples/widgets/shapedclock/shapedclock.cpp2
-rw-r--r--examples/widgets/shapedclock/shapedclock.pro1
-rw-r--r--examples/widgets/sliders/sliders.pro1
-rw-r--r--examples/widgets/sliders/slidersgroup.cpp2
-rw-r--r--examples/widgets/sliders/window.cpp2
-rw-r--r--examples/widgets/softkeys/main.cpp2
-rw-r--r--examples/widgets/softkeys/softkeys.h2
-rw-r--r--examples/widgets/softkeys/softkeys.pro1
-rw-r--r--examples/widgets/spinboxes/spinboxes.pro1
-rw-r--r--examples/widgets/spinboxes/window.cpp2
-rw-r--r--examples/widgets/styles/norwegianwoodstyle.cpp2
-rw-r--r--examples/widgets/styles/styles.pro1
-rw-r--r--examples/widgets/styles/widgetgallery.cpp2
-rw-r--r--examples/widgets/stylesheet/main.cpp2
-rw-r--r--examples/widgets/stylesheet/mainwindow.cpp2
-rw-r--r--examples/widgets/stylesheet/mainwindow.h2
-rw-r--r--examples/widgets/stylesheet/stylesheet.pro1
-rw-r--r--examples/widgets/stylesheet/stylesheeteditor.cpp2
-rw-r--r--examples/widgets/tablet/main.cpp2
-rw-r--r--examples/widgets/tablet/mainwindow.cpp2
-rw-r--r--examples/widgets/tablet/tablet.pro1
-rw-r--r--examples/widgets/tablet/tabletapplication.cpp2
-rw-r--r--examples/widgets/tablet/tabletcanvas.cpp2
-rw-r--r--examples/widgets/tetrix/main.cpp2
-rw-r--r--examples/widgets/tetrix/tetrix.pro1
-rw-r--r--examples/widgets/tetrix/tetrixboard.cpp2
-rw-r--r--examples/widgets/tetrix/tetrixwindow.cpp2
-rw-r--r--examples/widgets/tooltips/main.cpp2
-rw-r--r--examples/widgets/tooltips/shapeitem.cpp2
-rw-r--r--examples/widgets/tooltips/sortingbox.cpp2
-rw-r--r--examples/widgets/tooltips/tooltips.pro1
-rw-r--r--examples/widgets/validators/validators.pro1
-rw-r--r--examples/widgets/widgets.pro1
-rw-r--r--examples/widgets/wiggly/dialog.cpp3
-rw-r--r--examples/widgets/wiggly/wiggly.pro2
-rw-r--r--examples/widgets/wiggly/wigglywidget.cpp2
-rw-r--r--examples/widgets/windowflags/controllerwindow.cpp2
-rw-r--r--examples/widgets/windowflags/previewwindow.cpp2
-rw-r--r--examples/widgets/windowflags/windowflags.pro1
-rw-r--r--examples/xml/dombookmarks/dombookmarks.pro2
-rw-r--r--examples/xml/dombookmarks/mainwindow.cpp2
-rw-r--r--examples/xml/dombookmarks/xbeltree.cpp2
-rw-r--r--examples/xml/rsslisting/main.cpp2
-rw-r--r--examples/xml/rsslisting/rsslisting.cpp2
-rw-r--r--examples/xml/rsslisting/rsslisting.pro2
-rw-r--r--examples/xml/saxbookmarks/mainwindow.cpp2
-rw-r--r--examples/xml/saxbookmarks/saxbookmarks.pro2
-rw-r--r--examples/xml/saxbookmarks/xbelgenerator.cpp2
-rw-r--r--examples/xml/saxbookmarks/xbelhandler.cpp2
-rw-r--r--examples/xml/streambookmarks/mainwindow.cpp2
-rw-r--r--examples/xml/streambookmarks/streambookmarks.pro2
-rw-r--r--examples/xml/streambookmarks/xbelreader.cpp2
-rw-r--r--examples/xml/streambookmarks/xbelwriter.cpp2
-rw-r--r--examples/xml/xml.pro1
-rw-r--r--examples/xml/xmlstreamlint/xmlstreamlint.pro2
-rw-r--r--mkspecs/qws/freebsd-generic-g++/qmake.conf85
-rw-r--r--mkspecs/qws/freebsd-generic-g++/qplatformdefs.h42
-rw-r--r--mkspecs/qws/linux-arm-g++/qmake.conf21
-rw-r--r--mkspecs/qws/linux-arm-g++/qplatformdefs.h42
-rw-r--r--mkspecs/qws/linux-arm-gnueabi-g++/qmake.conf21
-rw-r--r--mkspecs/qws/linux-arm-gnueabi-g++/qplatformdefs.h42
-rw-r--r--mkspecs/qws/linux-armv6-g++/qmake.conf23
-rw-r--r--mkspecs/qws/linux-armv6-g++/qplatformdefs.h42
-rw-r--r--mkspecs/qws/linux-avr32-g++/qmake.conf21
-rw-r--r--mkspecs/qws/linux-avr32-g++/qplatformdefs.h42
-rw-r--r--mkspecs/qws/linux-cellon-g++/qmake.conf30
-rw-r--r--mkspecs/qws/linux-cellon-g++/qplatformdefs.h42
-rw-r--r--mkspecs/qws/linux-dm7000-g++/qmake.conf27
-rw-r--r--mkspecs/qws/linux-dm7000-g++/qplatformdefs.h42
-rw-r--r--mkspecs/qws/linux-dm800-g++/qmake.conf25
-rw-r--r--mkspecs/qws/linux-dm800-g++/qplatformdefs.h42
-rw-r--r--mkspecs/qws/linux-generic-g++-32/qmake.conf15
-rw-r--r--mkspecs/qws/linux-generic-g++-32/qplatformdefs.h42
-rw-r--r--mkspecs/qws/linux-generic-g++/qmake.conf10
-rw-r--r--mkspecs/qws/linux-generic-g++/qplatformdefs.h42
-rw-r--r--mkspecs/qws/linux-ipaq-g++/qmake.conf22
-rw-r--r--mkspecs/qws/linux-ipaq-g++/qplatformdefs.h42
-rw-r--r--mkspecs/qws/linux-lsb-g++/qmake.conf24
-rw-r--r--mkspecs/qws/linux-lsb-g++/qplatformdefs.h42
-rw-r--r--mkspecs/qws/linux-mips-g++/qmake.conf23
-rw-r--r--mkspecs/qws/linux-mips-g++/qplatformdefs.h42
-rw-r--r--mkspecs/qws/linux-nacl-g++/qmake.conf29
-rw-r--r--mkspecs/qws/linux-nacl-g++/qplatformdefs.h69
-rw-r--r--mkspecs/qws/linux-powerpc-g++/qmake.conf21
-rw-r--r--mkspecs/qws/linux-powerpc-g++/qplatformdefs.h42
-rw-r--r--mkspecs/qws/linux-sh-g++/qmake.conf21
-rw-r--r--mkspecs/qws/linux-sh-g++/qplatformdefs.h42
-rw-r--r--mkspecs/qws/linux-sh4al-g++/qmake.conf24
-rw-r--r--mkspecs/qws/linux-sh4al-g++/qplatformdefs.h42
-rw-r--r--mkspecs/qws/linux-sharp-g++/qmake.conf24
-rw-r--r--mkspecs/qws/linux-sharp-g++/qplatformdefs.h42
-rw-r--r--mkspecs/qws/linux-x86-g++/qmake.conf10
-rw-r--r--mkspecs/qws/linux-x86-g++/qplatformdefs.h42
-rw-r--r--mkspecs/qws/linux-x86_64-g++/qmake.conf15
-rw-r--r--mkspecs/qws/linux-x86_64-g++/qplatformdefs.h42
-rw-r--r--mkspecs/qws/linux-zylonite-g++/qmake.conf26
-rw-r--r--mkspecs/qws/linux-zylonite-g++/qplatformdefs.h42
-rw-r--r--mkspecs/qws/macx-generic-g++/qmake.conf90
-rw-r--r--mkspecs/qws/macx-generic-g++/qplatformdefs.h42
-rw-r--r--mkspecs/qws/macx-iphonedevice-g++/Info.plist.lib18
-rw-r--r--mkspecs/qws/macx-iphonedevice-g++/qmake.conf48
-rw-r--r--mkspecs/qws/macx-iphonedevice-g++/qplatformdefs.h99
-rw-r--r--mkspecs/qws/macx-iphonesimulator-g++/Info.plist.lib18
-rw-r--r--mkspecs/qws/macx-iphonesimulator-g++/qmake.conf49
-rw-r--r--mkspecs/qws/macx-iphonesimulator-g++/qplatformdefs.h99
-rw-r--r--mkspecs/qws/macx-nacl-g++/qmake.conf29
-rw-r--r--mkspecs/qws/macx-nacl-g++/qplatformdefs.h68
-rw-r--r--mkspecs/qws/solaris-generic-g++/qmake.conf89
-rw-r--r--mkspecs/qws/solaris-generic-g++/qplatformdefs.h42
-rw-r--r--src/corelib/global/qnamespace.h68
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp18
-rw-r--r--src/corelib/kernel/qcoreapplication.h14
-rw-r--r--src/corelib/kernel/qmetatype.cpp41
-rw-r--r--src/corelib/kernel/qmetatype.h19
-rw-r--r--src/corelib/kernel/qobject.cpp1
-rw-r--r--src/corelib/kernel/qobject.h4
-rw-r--r--src/corelib/kernel/qvariant.h45
-rw-r--r--src/gui/accessible/accessible.pri25
-rw-r--r--src/gui/accessible/qaccessible.h464
-rw-r--r--src/gui/accessible/qaccessible2.h246
-rw-r--r--src/gui/accessible/qaccessibleobject.h140
-rw-r--r--src/gui/accessible/qaccessibleplugin.h87
-rw-r--r--src/gui/accessible/qaccessiblewidget.cpp1031
-rw-r--r--src/gui/accessible/qaccessiblewidget.h141
-rw-r--r--src/gui/dialogs/dialogs.pri122
-rw-r--r--src/gui/dialogs/qabstractpagesetupdialog.h82
-rw-r--r--src/gui/dialogs/qabstractprintdialog.cpp497
-rw-r--r--src/gui/dialogs/qabstractprintdialog.h129
-rw-r--r--src/gui/dialogs/qabstractprintdialog_p.h95
-rw-r--r--src/gui/dialogs/qcolordialog.cpp2114
-rw-r--r--src/gui/dialogs/qcolordialog.h150
-rw-r--r--src/gui/dialogs/qdialog.h140
-rw-r--r--src/gui/dialogs/qdialog_p.h113
-rw-r--r--src/gui/dialogs/qerrormessage.h88
-rw-r--r--src/gui/dialogs/qfiledialog.h331
-rw-r--r--src/gui/dialogs/qfilesystemmodel.h180
-rw-r--r--src/gui/dialogs/qfontdialog.cpp1077
-rw-r--r--src/gui/dialogs/qfontdialog.h147
-rw-r--r--src/gui/dialogs/qfscompleter_p.h82
-rw-r--r--src/gui/dialogs/qinputdialog.h256
-rw-r--r--src/gui/dialogs/qmessagebox.cpp2751
-rw-r--r--src/gui/dialogs/qmessagebox.h365
-rw-r--r--src/gui/dialogs/qpagesetupdialog.h112
-rw-r--r--src/gui/dialogs/qprintdialog.h174
-rw-r--r--src/gui/dialogs/qprintdialog_qws.cpp567
-rw-r--r--src/gui/dialogs/qprintdialog_unix.cpp1309
-rw-r--r--src/gui/dialogs/qprintpreviewdialog.cpp802
-rw-r--r--src/gui/dialogs/qprintpreviewdialog.h107
-rw-r--r--src/gui/dialogs/qprogressdialog.cpp907
-rw-r--r--src/gui/dialogs/qprogressdialog.h145
-rw-r--r--src/gui/dialogs/qwizard.h268
-rw-r--r--src/gui/dialogs/qwizard_win.cpp759
-rw-r--r--src/gui/effects/effects.pri4
-rw-r--r--src/gui/effects/qgraphicseffect.cpp1235
-rw-r--r--src/gui/egl/egl.pri22
-rw-r--r--src/gui/egl/qegl_qpa.cpp3
-rw-r--r--src/gui/egl/qegl_qws.cpp114
-rw-r--r--src/gui/embedded/directfb.pri40
-rw-r--r--src/gui/embedded/embedded.pri226
-rw-r--r--src/gui/embedded/qcopchannel_qws.cpp608
-rw-r--r--src/gui/embedded/qcopchannel_qws.h108
-rw-r--r--src/gui/embedded/qdecoration_qws.cpp404
-rw-r--r--src/gui/embedded/qdecoration_qws.h124
-rw-r--r--src/gui/embedded/qdecorationdefault_qws.cpp803
-rw-r--r--src/gui/embedded/qdecorationdefault_qws.h101
-rw-r--r--src/gui/embedded/qdecorationfactory_qws.cpp156
-rw-r--r--src/gui/embedded/qdecorationfactory_qws.h66
-rw-r--r--src/gui/embedded/qdecorationplugin_qws.cpp116
-rw-r--r--src/gui/embedded/qdecorationplugin_qws.h80
-rw-r--r--src/gui/embedded/qdecorationstyled_qws.cpp313
-rw-r--r--src/gui/embedded/qdecorationstyled_qws.h73
-rw-r--r--src/gui/embedded/qdecorationwindows_qws.cpp407
-rw-r--r--src/gui/embedded/qdecorationwindows_qws.h77
-rw-r--r--src/gui/embedded/qdirectpainter_qws.cpp682
-rw-r--r--src/gui/embedded/qdirectpainter_qws.h112
-rw-r--r--src/gui/embedded/qkbd_defaultmap_qws_p.h806
-rw-r--r--src/gui/embedded/qkbd_qws.cpp693
-rw-r--r--src/gui/embedded/qkbd_qws.h103
-rw-r--r--src/gui/embedded/qkbd_qws_p.h134
-rw-r--r--src/gui/embedded/qkbddriverfactory_qws.cpp187
-rw-r--r--src/gui/embedded/qkbddriverfactory_qws.h70
-rw-r--r--src/gui/embedded/qkbddriverplugin_qws.cpp124
-rw-r--r--src/gui/embedded/qkbddriverplugin_qws.h84
-rw-r--r--src/gui/embedded/qkbdintegrity_qws.cpp197
-rw-r--r--src/gui/embedded/qkbdintegrity_qws.h81
-rw-r--r--src/gui/embedded/qkbdlinuxinput_qws.cpp245
-rw-r--r--src/gui/embedded/qkbdlinuxinput_qws.h79
-rw-r--r--src/gui/embedded/qkbdqnx_qws.cpp236
-rw-r--r--src/gui/embedded/qkbdqnx_qws.h76
-rw-r--r--src/gui/embedded/qkbdtty_qws.cpp353
-rw-r--r--src/gui/embedded/qkbdtty_qws.h79
-rw-r--r--src/gui/embedded/qkbdum_qws.cpp144
-rw-r--r--src/gui/embedded/qkbdum_qws.h77
-rw-r--r--src/gui/embedded/qkbdvfb_qws.cpp124
-rw-r--r--src/gui/embedded/qkbdvfb_qws.h86
-rw-r--r--src/gui/embedded/qlock.cpp325
-rw-r--r--src/gui/embedded/qlock_p.h100
-rw-r--r--src/gui/embedded/qmouse_qws.cpp653
-rw-r--r--src/gui/embedded/qmouse_qws.h123
-rw-r--r--src/gui/embedded/qmousedriverfactory_qws.cpp197
-rw-r--r--src/gui/embedded/qmousedriverfactory_qws.h67
-rw-r--r--src/gui/embedded/qmousedriverplugin_qws.cpp124
-rw-r--r--src/gui/embedded/qmousedriverplugin_qws.h84
-rw-r--r--src/gui/embedded/qmouseintegrity_qws.cpp271
-rw-r--r--src/gui/embedded/qmouseintegrity_qws.h82
-rw-r--r--src/gui/embedded/qmouselinuxinput_qws.cpp205
-rw-r--r--src/gui/embedded/qmouselinuxinput_qws.h78
-rw-r--r--src/gui/embedded/qmouselinuxtp_qws.cpp335
-rw-r--r--src/gui/embedded/qmouselinuxtp_qws.h77
-rw-r--r--src/gui/embedded/qmousepc_qws.cpp794
-rw-r--r--src/gui/embedded/qmousepc_qws.h76
-rw-r--r--src/gui/embedded/qmouseqnx_qws.cpp190
-rw-r--r--src/gui/embedded/qmouseqnx_qws.h79
-rw-r--r--src/gui/embedded/qmousetslib_qws.cpp371
-rw-r--r--src/gui/embedded/qmousetslib_qws.h80
-rw-r--r--src/gui/embedded/qmousevfb_qws.cpp133
-rw-r--r--src/gui/embedded/qmousevfb_qws.h83
-rw-r--r--src/gui/embedded/qscreen_qws.cpp3347
-rw-r--r--src/gui/embedded/qscreen_qws.h391
-rw-r--r--src/gui/embedded/qscreendriverfactory_qws.cpp204
-rw-r--r--src/gui/embedded/qscreendriverfactory_qws.h67
-rw-r--r--src/gui/embedded/qscreendriverplugin_qws.cpp123
-rw-r--r--src/gui/embedded/qscreendriverplugin_qws.h84
-rw-r--r--src/gui/embedded/qscreenintegrityfb_qws.cpp405
-rw-r--r--src/gui/embedded/qscreenintegrityfb_qws.h83
-rw-r--r--src/gui/embedded/qscreenlinuxfb_qws.cpp1386
-rw-r--r--src/gui/embedded/qscreenlinuxfb_qws.h135
-rw-r--r--src/gui/embedded/qscreenmulti_qws.cpp486
-rw-r--r--src/gui/embedded/qscreenmulti_qws_p.h114
-rw-r--r--src/gui/embedded/qscreenproxy_qws.cpp635
-rw-r--r--src/gui/embedded/qscreenproxy_qws.h153
-rw-r--r--src/gui/embedded/qscreenqnx_qws.cpp450
-rw-r--r--src/gui/embedded/qscreenqnx_qws.h82
-rw-r--r--src/gui/embedded/qscreentransformed_qws.cpp748
-rw-r--r--src/gui/embedded/qscreentransformed_qws.h103
-rw-r--r--src/gui/embedded/qscreenvfb_qws.cpp445
-rw-r--r--src/gui/embedded/qscreenvfb_qws.h86
-rw-r--r--src/gui/embedded/qsoundqss_qws.cpp1530
-rw-r--r--src/gui/embedded/qsoundqss_qws.h177
-rw-r--r--src/gui/embedded/qtransportauth_qws.cpp1563
-rw-r--r--src/gui/embedded/qtransportauth_qws.h281
-rw-r--r--src/gui/embedded/qtransportauth_qws_p.h189
-rw-r--r--src/gui/embedded/qtransportauthdefs_qws.h174
-rw-r--r--src/gui/embedded/qunixsocket.cpp1800
-rw-r--r--src/gui/embedded/qunixsocket_p.h202
-rw-r--r--src/gui/embedded/qunixsocketserver.cpp376
-rw-r--r--src/gui/embedded/qunixsocketserver_p.h98
-rw-r--r--src/gui/embedded/qvfbhdr.h119
-rw-r--r--src/gui/embedded/qwindowsystem_p.h315
-rw-r--r--src/gui/embedded/qwindowsystem_qws.cpp4960
-rw-r--r--src/gui/embedded/qwindowsystem_qws.h508
-rw-r--r--src/gui/embedded/qwscommand_qws.cpp609
-rw-r--r--src/gui/embedded/qwscommand_qws_p.h851
-rw-r--r--src/gui/embedded/qwscursor_qws.cpp654
-rw-r--r--src/gui/embedded/qwscursor_qws.h83
-rw-r--r--src/gui/embedded/qwsdisplay_qws.h185
-rw-r--r--src/gui/embedded/qwsdisplay_qws_p.h161
-rw-r--r--src/gui/embedded/qwsembedwidget.cpp227
-rw-r--r--src/gui/embedded/qwsembedwidget.h82
-rw-r--r--src/gui/embedded/qwsevent_qws.cpp216
-rw-r--r--src/gui/embedded/qwsevent_qws.h459
-rw-r--r--src/gui/embedded/qwslock.cpp236
-rw-r--r--src/gui/embedded/qwslock_p.h85
-rw-r--r--src/gui/embedded/qwsmanager_p.h122
-rw-r--r--src/gui/embedded/qwsmanager_qws.cpp537
-rw-r--r--src/gui/embedded/qwsmanager_qws.h122
-rw-r--r--src/gui/embedded/qwsproperty_qws.cpp145
-rw-r--r--src/gui/embedded/qwsproperty_qws.h96
-rw-r--r--src/gui/embedded/qwsprotocolitem_qws.h100
-rw-r--r--src/gui/embedded/qwssharedmemory.cpp185
-rw-r--r--src/gui/embedded/qwssharedmemory_p.h105
-rw-r--r--src/gui/embedded/qwssignalhandler.cpp128
-rw-r--r--src/gui/embedded/qwssignalhandler_p.h99
-rw-r--r--src/gui/embedded/qwssocket_qws.cpp280
-rw-r--r--src/gui/embedded/qwssocket_qws.h120
-rw-r--r--src/gui/embedded/qwsutils_qws.h98
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout.h128
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.cpp3015
-rw-r--r--src/gui/graphicsview/qgraphicsgridlayout.h144
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp11601
-rw-r--r--src/gui/graphicsview/qgraphicslayout.h98
-rw-r--r--src/gui/graphicsview/qgraphicslayout_p.h154
-rw-r--r--src/gui/graphicsview/qgraphicslayoutitem.h155
-rw-r--r--src/gui/graphicsview/qgraphicslayoutitem_p.h103
-rw-r--r--src/gui/graphicsview/qgraphicslinearlayout.h119
-rw-r--r--src/gui/graphicsview/qgraphicsproxywidget.cpp1570
-rw-r--r--src/gui/graphicsview/qgraphicsproxywidget.h147
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp6503
-rw-r--r--src/gui/graphicsview/qgraphicsscene_p.h359
-rw-r--r--src/gui/graphicsview/qgraphicssceneevent.cpp1674
-rw-r--r--src/gui/graphicsview/qgraphicsscenelinearindex_p.h109
-rw-r--r--src/gui/graphicsview/qgraphicsview.cpp3880
-rw-r--r--src/gui/graphicsview/qgraphicsview.h316
-rw-r--r--src/gui/graphicsview/qgraphicsview_p.h233
-rw-r--r--src/gui/graphicsview/qgraphicswidget.cpp2388
-rw-r--r--src/gui/graphicsview/qgraphicswidget.h257
-rw-r--r--src/gui/graphicsview/qgraphicswidget_p.cpp906
-rw-r--r--src/gui/graphicsview/qgraphicswidget_p.h226
-rw-r--r--src/gui/gui.pro47
-rw-r--r--src/gui/guikernel/guikernel.pri88
-rw-r--r--src/gui/guikernel/qclipboard.cpp665
-rw-r--r--src/gui/guikernel/qclipboard.h132
-rw-r--r--src/gui/guikernel/qclipboard_p.h (renamed from src/gui/kernel/qclipboard_p.h)0
-rw-r--r--src/gui/guikernel/qclipboard_qpa.cpp105
-rw-r--r--src/gui/guikernel/qcursor.cpp573
-rw-r--r--src/gui/guikernel/qcursor.h168
-rw-r--r--src/gui/guikernel/qcursor_p.h (renamed from src/gui/kernel/qcursor_p.h)0
-rw-r--r--src/gui/guikernel/qcursor_qpa.cpp (renamed from src/gui/kernel/qcursor_qpa.cpp)0
-rw-r--r--src/gui/guikernel/qevent.cpp4305
-rw-r--r--src/gui/guikernel/qevent.h812
-rw-r--r--src/gui/guikernel/qevent_p.h172
-rw-r--r--src/gui/guikernel/qeventdispatcher_glib_qpa.cpp146
-rw-r--r--src/gui/guikernel/qeventdispatcher_glib_qpa_p.h (renamed from src/gui/kernel/qeventdispatcher_glib_qpa_p.h)0
-rw-r--r--src/gui/guikernel/qeventdispatcher_qpa.cpp334
-rw-r--r--src/gui/guikernel/qeventdispatcher_qpa_p.h (renamed from src/gui/kernel/qeventdispatcher_qpa_p.h)0
-rw-r--r--src/gui/guikernel/qgenericplugin_qpa.cpp (renamed from src/gui/kernel/qgenericplugin_qpa.cpp)0
-rw-r--r--src/gui/guikernel/qgenericplugin_qpa.h (renamed from src/gui/kernel/qgenericplugin_qpa.h)0
-rw-r--r--src/gui/guikernel/qgenericpluginfactory_qpa.cpp115
-rw-r--r--src/gui/guikernel/qgenericpluginfactory_qpa.h (renamed from src/gui/kernel/qgenericpluginfactory_qpa.h)0
-rw-r--r--src/gui/guikernel/qguiapplication.cpp1059
-rw-r--r--src/gui/guikernel/qguiapplication.h146
-rw-r--r--src/gui/guikernel/qguiapplication_p.h169
-rw-r--r--src/gui/guikernel/qguivariant.cpp789
-rw-r--r--src/gui/guikernel/qkeymapper.cpp120
-rw-r--r--src/gui/guikernel/qkeymapper_p.h226
-rw-r--r--src/gui/guikernel/qkeymapper_qpa.cpp (renamed from src/gui/kernel/qkeymapper_qws.cpp)0
-rw-r--r--src/gui/guikernel/qkeysequence.cpp1725
-rw-r--r--src/gui/guikernel/qkeysequence.h237
-rw-r--r--src/gui/guikernel/qkeysequence_p.h (renamed from src/gui/kernel/qkeysequence_p.h)0
-rw-r--r--src/gui/guikernel/qmime.cpp (renamed from src/gui/kernel/qmime.cpp)0
-rw-r--r--src/gui/guikernel/qmime.h (renamed from src/gui/kernel/qmime.h)0
-rw-r--r--src/gui/guikernel/qpalette.cpp1091
-rw-r--r--src/gui/guikernel/qpalette.h197
-rw-r--r--src/gui/guikernel/qplatformclipboard_qpa.cpp (renamed from src/gui/kernel/qplatformclipboard_qpa.cpp)0
-rw-r--r--src/gui/guikernel/qplatformclipboard_qpa.h (renamed from src/gui/kernel/qplatformclipboard_qpa.h)0
-rw-r--r--src/gui/guikernel/qplatformcursor_qpa.cpp659
-rw-r--r--src/gui/guikernel/qplatformcursor_qpa.h103
-rw-r--r--src/gui/guikernel/qplatformeventloopintegration_qpa.cpp (renamed from src/gui/kernel/qplatformeventloopintegration_qpa.cpp)0
-rw-r--r--src/gui/guikernel/qplatformeventloopintegration_qpa.h (renamed from src/gui/kernel/qplatformeventloopintegration_qpa.h)0
-rw-r--r--src/gui/guikernel/qplatformglcontext_qpa.cpp81
-rw-r--r--src/gui/guikernel/qplatformglcontext_qpa.h72
-rw-r--r--src/gui/guikernel/qplatformintegration_qpa.cpp225
-rw-r--r--src/gui/guikernel/qplatformintegration_qpa.h107
-rw-r--r--src/gui/guikernel/qplatformintegrationfactory_qpa.cpp109
-rw-r--r--src/gui/guikernel/qplatformintegrationfactory_qpa_p.h (renamed from src/gui/kernel/qplatformintegrationfactory_qpa_p.h)0
-rw-r--r--src/gui/guikernel/qplatformintegrationplugin_qpa.cpp (renamed from src/gui/kernel/qplatformintegrationplugin_qpa.cpp)0
-rw-r--r--src/gui/guikernel/qplatformintegrationplugin_qpa.h (renamed from src/gui/kernel/qplatformintegrationplugin_qpa.h)0
-rw-r--r--src/gui/guikernel/qplatformnativeinterface_qpa.cpp53
-rw-r--r--src/gui/guikernel/qplatformnativeinterface_qpa.h65
-rw-r--r--src/gui/guikernel/qplatformscreen_qpa.cpp120
-rw-r--r--src/gui/guikernel/qplatformscreen_qpa.h86
-rw-r--r--src/gui/guikernel/qplatformwindow_qpa.cpp216
-rw-r--r--src/gui/guikernel/qplatformwindow_qpa.h94
-rw-r--r--src/gui/guikernel/qsessionmanager.h111
-rw-r--r--src/gui/guikernel/qsessionmanager_qpa.cpp173
-rw-r--r--src/gui/guikernel/qt_gui_pch.h81
-rw-r--r--src/gui/guikernel/qwindow.cpp457
-rw-r--r--src/gui/guikernel/qwindow.h186
-rw-r--r--src/gui/guikernel/qwindow_p.h92
-rw-r--r--src/gui/guikernel/qwindowcontext_qpa.cpp201
-rw-r--r--src/gui/guikernel/qwindowcontext_qpa.h90
-rw-r--r--src/gui/guikernel/qwindowdefs.h162
-rw-r--r--src/gui/guikernel/qwindowformat_qpa.cpp406
-rw-r--r--src/gui/guikernel/qwindowformat_qpa.h155
-rw-r--r--src/gui/guikernel/qwindowsysteminterface_qpa.cpp254
-rw-r--r--src/gui/guikernel/qwindowsysteminterface_qpa.h107
-rw-r--r--src/gui/guikernel/qwindowsysteminterface_qpa_p.h208
-rw-r--r--src/gui/guiutil/guiutil.pri10
-rw-r--r--src/gui/guiutil/qdesktopservices.cpp309
-rw-r--r--src/gui/guiutil/qdesktopservices.h (renamed from src/gui/util/qdesktopservices.h)0
-rw-r--r--src/gui/guiutil/qdesktopservices_mac.cpp (renamed from src/gui/util/qdesktopservices_mac.cpp)0
-rw-r--r--src/gui/guiutil/qdesktopservices_qpa.cpp (renamed from src/gui/util/qdesktopservices_qws.cpp)0
-rw-r--r--src/gui/guiutil/qdesktopservices_s60.cpp (renamed from src/gui/util/qdesktopservices_s60.cpp)0
-rw-r--r--src/gui/guiutil/qdesktopservices_win.cpp (renamed from src/gui/util/qdesktopservices_win.cpp)0
-rw-r--r--src/gui/guiutil/qdesktopservices_x11.cpp (renamed from src/gui/util/qdesktopservices_x11.cpp)0
-rw-r--r--src/gui/guiutil/qhexstring_p.h98
-rw-r--r--src/gui/guiutil/qvalidator.cpp (renamed from src/gui/widgets/qvalidator.cpp)0
-rw-r--r--src/gui/guiutil/qvalidator.h (renamed from src/gui/widgets/qvalidator.h)0
-rw-r--r--src/gui/image/image.pri14
-rw-r--r--src/gui/image/qbitmap.cpp94
-rw-r--r--src/gui/image/qbitmap.h23
-rw-r--r--src/gui/image/qicon.cpp1258
-rw-r--r--src/gui/image/qicon.h162
-rw-r--r--src/gui/image/qicon_p.h139
-rw-r--r--src/gui/image/qiconengine.h104
-rw-r--r--src/gui/image/qiconloader.cpp570
-rw-r--r--src/gui/image/qiconloader_p.h192
-rw-r--r--src/gui/image/qimage.cpp553
-rw-r--r--src/gui/image/qimage.h52
-rw-r--r--src/gui/image/qimage_p.h3
-rw-r--r--src/gui/image/qmovie.h20
-rw-r--r--src/gui/image/qnativeimage.cpp111
-rw-r--r--src/gui/image/qnativeimage_p.h12
-rw-r--r--src/gui/image/qpicture.cpp2
-rw-r--r--src/gui/image/qpicture.h3
-rw-r--r--src/gui/image/qpixmap.cpp254
-rw-r--r--src/gui/image/qpixmap.h36
-rw-r--r--src/gui/image/qpixmap_blitter.cpp5
-rw-r--r--src/gui/image/qpixmap_qpa.cpp5
-rw-r--r--src/gui/image/qpixmap_qws.cpp160
-rw-r--r--src/gui/image/qpixmap_raster.cpp1
-rw-r--r--src/gui/image/qpixmapdata.cpp17
-rw-r--r--src/gui/image/qpixmapdatafactory.cpp21
-rw-r--r--src/gui/image/qpixmapfilter.cpp1382
-rw-r--r--src/gui/image/qpixmapfilter_p.h196
-rw-r--r--src/gui/inputmethod/inputmethod.pri31
-rw-r--r--src/gui/inputmethod/qinputcontext.h139
-rw-r--r--src/gui/inputmethod/qmacinputcontext_p.h97
-rw-r--r--src/gui/inputmethod/qwininputcontext_p.h111
-rw-r--r--src/gui/inputmethod/qwsinputcontext_p.h97
-rw-r--r--src/gui/inputmethod/qwsinputcontext_qws.cpp246
-rw-r--r--src/gui/inputmethod/qximinputcontext_p.h142
-rw-r--r--src/gui/itemviews/qabstractitemdelegate.h134
-rw-r--r--src/gui/itemviews/qabstractitemview.h380
-rw-r--r--src/gui/itemviews/qabstractitemview_p.h457
-rw-r--r--src/gui/itemviews/qcolumnview.h123
-rw-r--r--src/gui/itemviews/qcolumnview_p.h189
-rw-r--r--src/gui/itemviews/qdirmodel.h160
-rw-r--r--src/gui/itemviews/qfileiconprovider.h82
-rw-r--r--src/gui/itemviews/qheaderview.h250
-rw-r--r--src/gui/itemviews/qheaderview_p.h366
-rw-r--r--src/gui/itemviews/qitemdelegate.h141
-rw-r--r--src/gui/itemviews/qlistview.cpp3212
-rw-r--r--src/gui/itemviews/qlistview.h203
-rw-r--r--src/gui/itemviews/qlistwidget.h335
-rw-r--r--src/gui/itemviews/qlistwidget_p.h175
-rw-r--r--src/gui/itemviews/qsortfilterproxymodel.h201
-rw-r--r--src/gui/itemviews/qstandarditemmodel.h456
-rw-r--r--src/gui/itemviews/qstringlistmodel.h91
-rw-r--r--src/gui/itemviews/qstyleditemdelegate.h116
-rw-r--r--src/gui/itemviews/qtableview.h198
-rw-r--r--src/gui/itemviews/qtablewidget.h377
-rw-r--r--src/gui/itemviews/qtreeview.h239
-rw-r--r--src/gui/itemviews/qtreewidget.h432
-rw-r--r--src/gui/itemviews/qtreewidget_p.h248
-rw-r--r--src/gui/kernel/kernel.pri329
-rw-r--r--src/gui/kernel/mac.pri4
-rw-r--r--src/gui/kernel/qaction.h264
-rw-r--r--src/gui/kernel/qaction_p.h144
-rw-r--r--src/gui/kernel/qactiongroup.h112
-rw-r--r--src/gui/kernel/qapplication.cpp6139
-rw-r--r--src/gui/kernel/qapplication.h430
-rw-r--r--src/gui/kernel/qapplication_p.h683
-rw-r--r--src/gui/kernel/qapplication_qpa.cpp965
-rw-r--r--src/gui/kernel/qapplication_qws.cpp3797
-rw-r--r--src/gui/kernel/qboxlayout.h173
-rw-r--r--src/gui/kernel/qclipboard.cpp667
-rw-r--r--src/gui/kernel/qclipboard.h131
-rw-r--r--src/gui/kernel/qclipboard_qpa.cpp105
-rw-r--r--src/gui/kernel/qclipboard_qws.cpp304
-rw-r--r--src/gui/kernel/qcursor.cpp573
-rw-r--r--src/gui/kernel/qcursor.h180
-rw-r--r--src/gui/kernel/qcursor_qws.cpp138
-rw-r--r--src/gui/kernel/qdesktopwidget.h110
-rw-r--r--src/gui/kernel/qdesktopwidget_qpa.cpp176
-rw-r--r--src/gui/kernel/qdesktopwidget_qws.cpp159
-rw-r--r--src/gui/kernel/qdnd.cpp491
-rw-r--r--src/gui/kernel/qdnd_p.h336
-rw-r--r--src/gui/kernel/qdnd_qws.cpp426
-rw-r--r--src/gui/kernel/qdnd_x11.cpp2076
-rw-r--r--src/gui/kernel/qevent.cpp4851
-rw-r--r--src/gui/kernel/qevent.h942
-rw-r--r--src/gui/kernel/qevent_p.h219
-rw-r--r--src/gui/kernel/qeventdispatcher_glib_qpa.cpp147
-rw-r--r--src/gui/kernel/qeventdispatcher_glib_qws.cpp195
-rw-r--r--src/gui/kernel/qeventdispatcher_glib_qws_p.h78
-rw-r--r--src/gui/kernel/qeventdispatcher_qpa.cpp334
-rw-r--r--src/gui/kernel/qeventdispatcher_qws.cpp168
-rw-r--r--src/gui/kernel/qeventdispatcher_qws_p.h86
-rw-r--r--src/gui/kernel/qformlayout.h163
-rw-r--r--src/gui/kernel/qgenericpluginfactory_qpa.cpp115
-rw-r--r--src/gui/kernel/qgesture.cpp807
-rw-r--r--src/gui/kernel/qgesture.h275
-rw-r--r--src/gui/kernel/qgesture_p.h197
-rw-r--r--src/gui/kernel/qgridlayout.h176
-rw-r--r--src/gui/kernel/qguiplatformplugin_p.h126
-rw-r--r--src/gui/kernel/qguivariant.cpp828
-rw-r--r--src/gui/kernel/qkde_p.h81
-rw-r--r--src/gui/kernel/qkeymapper.cpp118
-rw-r--r--src/gui/kernel/qkeymapper_p.h224
-rw-r--r--src/gui/kernel/qkeysequence.cpp1726
-rw-r--r--src/gui/kernel/qkeysequence.h240
-rw-r--r--src/gui/kernel/qlayout.h245
-rw-r--r--src/gui/kernel/qlayoutengine_p.h140
-rw-r--r--src/gui/kernel/qlayoutitem.h182
-rw-r--r--src/gui/kernel/qpalette.cpp1406
-rw-r--r--src/gui/kernel/qpalette.h270
-rw-r--r--src/gui/kernel/qplatformcursor_qpa.cpp660
-rw-r--r--src/gui/kernel/qplatformcursor_qpa.h103
-rw-r--r--src/gui/kernel/qplatformglcontext_qpa.cpp209
-rw-r--r--src/gui/kernel/qplatformglcontext_qpa.h91
-rw-r--r--src/gui/kernel/qplatformintegration_qpa.cpp225
-rw-r--r--src/gui/kernel/qplatformintegration_qpa.h107
-rw-r--r--src/gui/kernel/qplatformintegrationfactory_qpa.cpp109
-rw-r--r--src/gui/kernel/qplatformnativeinterface_qpa.cpp53
-rw-r--r--src/gui/kernel/qplatformnativeinterface_qpa.h65
-rw-r--r--src/gui/kernel/qplatformscreen_qpa.cpp129
-rw-r--r--src/gui/kernel/qplatformscreen_qpa.h86
-rw-r--r--src/gui/kernel/qplatformwindow_qpa.cpp229
-rw-r--r--src/gui/kernel/qplatformwindow_qpa.h95
-rw-r--r--src/gui/kernel/qplatformwindowformat_qpa.cpp1008
-rw-r--r--src/gui/kernel/qplatformwindowformat_qpa.h234
-rw-r--r--src/gui/kernel/qsessionmanager.h111
-rw-r--r--src/gui/kernel/qsessionmanager_qpa.cpp174
-rw-r--r--src/gui/kernel/qsessionmanager_qws.cpp171
-rw-r--r--src/gui/kernel/qshortcut.h107
-rw-r--r--src/gui/kernel/qshortcutmap.cpp897
-rw-r--r--src/gui/kernel/qsoftkeymanager_p.h115
-rw-r--r--src/gui/kernel/qsound.cpp390
-rw-r--r--src/gui/kernel/qsound.h95
-rw-r--r--src/gui/kernel/qsound_qws.cpp350
-rw-r--r--src/gui/kernel/qstackedlayout.h115
-rw-r--r--src/gui/kernel/qtooltip.h84
-rw-r--r--src/gui/kernel/qwhatsthis.cpp777
-rw-r--r--src/gui/kernel/qwidget.cpp12684
-rw-r--r--src/gui/kernel/qwidget.h1090
-rw-r--r--src/gui/kernel/qwidget_p.h1035
-rw-r--r--src/gui/kernel/qwidget_qpa.cpp875
-rw-r--r--src/gui/kernel/qwidget_qws.cpp1221
-rw-r--r--src/gui/kernel/qwidgetaction.h91
-rw-r--r--src/gui/kernel/qwindowdefs.h163
-rw-r--r--src/gui/kernel/qwindowsysteminterface_qpa.cpp291
-rw-r--r--src/gui/kernel/qwindowsysteminterface_qpa.h107
-rw-r--r--src/gui/kernel/qwindowsysteminterface_qpa_p.h208
-rw-r--r--src/gui/kernel/qx11embed_x11.h132
-rw-r--r--src/gui/painting/painting.pri78
-rw-r--r--src/gui/painting/qbackingstore.cpp1668
-rw-r--r--src/gui/painting/qbackingstore_p.h278
-rw-r--r--src/gui/painting/qbrush.cpp32
-rw-r--r--src/gui/painting/qbrush.h10
-rw-r--r--src/gui/painting/qcolor.cpp24
-rw-r--r--src/gui/painting/qcolor.h21
-rw-r--r--src/gui/painting/qcolormap_qpa.cpp5
-rw-r--r--src/gui/painting/qcolormap_qws.cpp185
-rw-r--r--src/gui/painting/qcssutil_p.h4
-rw-r--r--src/gui/painting/qcups_p.h2
-rw-r--r--src/gui/painting/qdrawhelper.cpp744
-rw-r--r--src/gui/painting/qdrawhelper_p.h145
-rw-r--r--src/gui/painting/qdrawutil.cpp1360
-rw-r--r--src/gui/painting/qdrawutil.h195
-rw-r--r--src/gui/painting/qgraphicssystem.cpp97
-rw-r--r--src/gui/painting/qgraphicssystem_mac.cpp59
-rw-r--r--src/gui/painting/qgraphicssystem_mac_p.h69
-rw-r--r--src/gui/painting/qgraphicssystem_p.h85
-rw-r--r--src/gui/painting/qgraphicssystem_qws.cpp62
-rw-r--r--src/gui/painting/qgraphicssystem_qws_p.h79
-rw-r--r--src/gui/painting/qgraphicssystem_raster.cpp72
-rw-r--r--src/gui/painting/qgraphicssystem_raster_p.h69
-rw-r--r--src/gui/painting/qgraphicssystem_runtime.cpp426
-rw-r--r--src/gui/painting/qgraphicssystem_runtime_p.h187
-rw-r--r--src/gui/painting/qgraphicssystemfactory.cpp123
-rw-r--r--src/gui/painting/qgraphicssystemfactory_p.h78
-rw-r--r--src/gui/painting/qgraphicssystemplugin.cpp56
-rw-r--r--src/gui/painting/qgraphicssystemplugin_p.h92
-rw-r--r--src/gui/painting/qmatrix.cpp36
-rw-r--r--src/gui/painting/qmatrix.h12
-rw-r--r--src/gui/painting/qmemrotate.cpp12
-rw-r--r--src/gui/painting/qpaintdevice.cpp17
-rw-r--r--src/gui/painting/qpaintdevice.h47
-rw-r--r--src/gui/painting/qpaintdevice_qpa.cpp5
-rw-r--r--src/gui/painting/qpaintdevice_qws.cpp56
-rw-r--r--src/gui/painting/qpaintdevice_x11.cpp198
-rw-r--r--src/gui/painting/qpaintengine.cpp3
-rw-r--r--src/gui/painting/qpaintengine_blitter.cpp1
-rw-r--r--src/gui/painting/qpaintengine_p.h4
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp231
-rw-r--r--src/gui/painting/qpaintengine_raster_p.h65
-rw-r--r--src/gui/painting/qpaintengine_x11.cpp2504
-rw-r--r--src/gui/painting/qpaintengineex_p.h2
-rw-r--r--src/gui/painting/qpainter.cpp645
-rw-r--r--src/gui/painting/qpainter.h77
-rw-r--r--src/gui/painting/qpdf_p.h4
-rw-r--r--src/gui/painting/qprintengine_ps.cpp972
-rw-r--r--src/gui/painting/qprintengine_ps_p.h137
-rw-r--r--src/gui/painting/qprintengine_qws.cpp886
-rw-r--r--src/gui/painting/qprintengine_qws_p.h213
-rw-r--r--src/gui/painting/qprinter.cpp225
-rw-r--r--src/gui/painting/qprinter.h58
-rw-r--r--src/gui/painting/qprinter_p.h10
-rw-r--r--src/gui/painting/qprinterinfo_unix.cpp26
-rw-r--r--src/gui/painting/qregion.cpp11
-rw-r--r--src/gui/painting/qregion.h6
-rw-r--r--src/gui/painting/qregion_qws.cpp3183
-rw-r--r--src/gui/painting/qstylepainter.h112
-rw-r--r--src/gui/painting/qunifiedtoolbarsurface_mac.cpp265
-rw-r--r--src/gui/painting/qunifiedtoolbarsurface_mac_p.h140
-rw-r--r--src/gui/painting/qwindowsurface.cpp101
-rw-r--r--src/gui/painting/qwindowsurface_mac.cpp139
-rw-r--r--src/gui/painting/qwindowsurface_mac_p.h84
-rw-r--r--src/gui/painting/qwindowsurface_p.h25
-rw-r--r--src/gui/painting/qwindowsurface_qws.cpp1433
-rw-r--r--src/gui/painting/qwindowsurface_qws_p.h355
-rw-r--r--src/gui/painting/qwindowsurface_raster.cpp487
-rw-r--r--src/gui/painting/qwindowsurface_raster_p.h132
-rw-r--r--src/gui/painting/qwindowsurface_s60.cpp254
-rw-r--r--src/gui/painting/qwindowsurface_s60_p.h93
-rw-r--r--src/gui/painting/qwindowsurface_x11.cpp265
-rw-r--r--src/gui/painting/qwindowsurface_x11_p.h92
-rw-r--r--src/gui/painting/qwmatrix.h61
-rw-r--r--src/gui/s60framework/qs60mainappui.cpp430
-rw-r--r--src/gui/statemachine/qguistatemachine.cpp523
-rw-r--r--src/gui/styles/qcdestyle.h82
-rw-r--r--src/gui/styles/qcleanlooksstyle.h114
-rw-r--r--src/gui/styles/qcommonstyle.h109
-rw-r--r--src/gui/styles/qgtkpainter.cpp716
-rw-r--r--src/gui/styles/qgtkpainter_p.h129
-rw-r--r--src/gui/styles/qgtkstyle.cpp3560
-rw-r--r--src/gui/styles/qgtkstyle.h128
-rw-r--r--src/gui/styles/qgtkstyle_p.cpp1146
-rw-r--r--src/gui/styles/qgtkstyle_p.h531
-rw-r--r--src/gui/styles/qmacstyle_mac.h148
-rw-r--r--src/gui/styles/qmacstyle_mac_p.h241
-rw-r--r--src/gui/styles/qmotifstyle.cpp2721
-rw-r--r--src/gui/styles/qmotifstyle.h128
-rw-r--r--src/gui/styles/qplastiquestyle.h119
-rw-r--r--src/gui/styles/qproxystyle.h114
-rw-r--r--src/gui/styles/qs60style.h118
-rw-r--r--src/gui/styles/qstyle.cpp2493
-rw-r--r--src/gui/styles/qstyle.h889
-rw-r--r--src/gui/styles/qstyle_p.h108
-rw-r--r--src/gui/styles/qstylehelper_p.h118
-rw-r--r--src/gui/styles/qstyleoption.h970
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp5898
-rw-r--r--src/gui/styles/qstylesheetstyle_p.h204
-rw-r--r--src/gui/styles/qwindowscestyle.h103
-rw-r--r--src/gui/styles/qwindowsmobilestyle.h116
-rw-r--r--src/gui/styles/qwindowsstyle.h111
-rw-r--r--src/gui/styles/qwindowsvistastyle.h108
-rw-r--r--src/gui/styles/qwindowsxpstyle.h107
-rw-r--r--src/gui/styles/styles.pri190
-rw-r--r--src/gui/text/qabstractfontengine_qws.cpp776
-rw-r--r--src/gui/text/qabstractfontengine_qws.h221
-rw-r--r--src/gui/text/qcssparser.cpp6
-rw-r--r--src/gui/text/qcssparser_p.h6
-rw-r--r--src/gui/text/qfont.cpp94
-rw-r--r--src/gui/text/qfont.h8
-rw-r--r--src/gui/text/qfont_qpa.cpp6
-rw-r--r--src/gui/text/qfont_qws.cpp135
-rw-r--r--src/gui/text/qfontdatabase.cpp48
-rw-r--r--src/gui/text/qfontdatabase.h4
-rw-r--r--src/gui/text/qfontdatabase_qpa.cpp29
-rw-r--r--src/gui/text/qfontdatabase_qws.cpp975
-rw-r--r--src/gui/text/qfontengine_qpa.cpp1
-rw-r--r--src/gui/text/qfontengine_qws.cpp665
-rw-r--r--src/gui/text/qfontmetrics.h9
-rw-r--r--src/gui/text/qrawfont_qpa.cpp4
-rw-r--r--src/gui/text/qstatictext.cpp2
-rw-r--r--src/gui/text/qsyntaxhighlighter.cpp21
-rw-r--r--src/gui/text/qsyntaxhighlighter.h2
-rw-r--r--src/gui/text/qtextcontrol.cpp3148
-rw-r--r--src/gui/text/qtextcontrol_p.h312
-rw-r--r--src/gui/text/qtextcontrol_p_p.h238
-rw-r--r--src/gui/text/qtextcursor_p.h2
-rw-r--r--src/gui/text/qtextdocument.cpp7
-rw-r--r--src/gui/text/qtextdocumentlayout.cpp4
-rw-r--r--src/gui/text/qtextengine.cpp4
-rw-r--r--src/gui/text/qtextengine_p.h2
-rw-r--r--src/gui/text/qtexthtmlparser.cpp5
-rw-r--r--src/gui/text/qtextimagehandler.cpp14
-rw-r--r--src/gui/text/qtextlayout.cpp2
-rw-r--r--src/gui/text/qtextoption.cpp4
-rw-r--r--src/gui/text/text.pri27
-rw-r--r--src/gui/util/qcompleter.cpp1833
-rw-r--r--src/gui/util/qcompleter_p.h264
-rw-r--r--src/gui/util/qdesktopservices.cpp309
-rw-r--r--src/gui/util/qscroller.h155
-rw-r--r--src/gui/util/qsystemtrayicon.h132
-rw-r--r--src/gui/util/qsystemtrayicon_p.h186
-rw-r--r--src/gui/util/qundostack_p.h114
-rw-r--r--src/gui/util/qundoview.cpp476
-rw-r--r--src/gui/util/qundoview.h102
-rw-r--r--src/gui/util/util.pri71
-rw-r--r--src/gui/widgets/qabstractbutton.h180
-rw-r--r--src/gui/widgets/qabstractscrollarea.h144
-rw-r--r--src/gui/widgets/qabstractslider.h184
-rw-r--r--src/gui/widgets/qabstractspinbox.h181
-rw-r--r--src/gui/widgets/qabstractspinbox_p.h170
-rw-r--r--src/gui/widgets/qcalendarwidget.h204
-rw-r--r--src/gui/widgets/qcheckbox.h114
-rw-r--r--src/gui/widgets/qcombobox.h339
-rw-r--r--src/gui/widgets/qcombobox_p.h421
-rw-r--r--src/gui/widgets/qcommandlinkbutton.h85
-rw-r--r--src/gui/widgets/qdatetimeedit.h230
-rw-r--r--src/gui/widgets/qdatetimeedit_p.h185
-rw-r--r--src/gui/widgets/qdial.h122
-rw-r--r--src/gui/widgets/qdialogbuttonbox.cpp1285
-rw-r--r--src/gui/widgets/qdialogbuttonbox.h168
-rw-r--r--src/gui/widgets/qdockarealayout.cpp3329
-rw-r--r--src/gui/widgets/qdockarealayout_p.h308
-rw-r--r--src/gui/widgets/qdockwidget.h146
-rw-r--r--src/gui/widgets/qdockwidget_p.h207
-rw-r--r--src/gui/widgets/qfocusframe.h82
-rw-r--r--src/gui/widgets/qfontcombobox.h112
-rw-r--r--src/gui/widgets/qframe.h148
-rw-r--r--src/gui/widgets/qgroupbox.h122
-rw-r--r--src/gui/widgets/qlabel.h182
-rw-r--r--src/gui/widgets/qlcdnumber.h144
-rw-r--r--src/gui/widgets/qlinecontrol_p.h456
-rw-r--r--src/gui/widgets/qlineedit.h299
-rw-r--r--src/gui/widgets/qlineedit_p.cpp291
-rw-r--r--src/gui/widgets/qlineedit_p.h156
-rw-r--r--src/gui/widgets/qmaccocoaviewcontainer_mac.h73
-rw-r--r--src/gui/widgets/qmacnativewidget_mac.h74
-rw-r--r--src/gui/widgets/qmainwindow.h219
-rw-r--r--src/gui/widgets/qmainwindowlayout_p.h357
-rw-r--r--src/gui/widgets/qmdiarea.h179
-rw-r--r--src/gui/widgets/qmdiarea_p.h285
-rw-r--r--src/gui/widgets/qmdisubwindow.h159
-rw-r--r--src/gui/widgets/qmenu.h434
-rw-r--r--src/gui/widgets/qmenu_p.h395
-rw-r--r--src/gui/widgets/qmenubar.h367
-rw-r--r--src/gui/widgets/qmenubar_p.h283
-rw-r--r--src/gui/widgets/qmenudata.h80
-rw-r--r--src/gui/widgets/qplaintextedit.h329
-rw-r--r--src/gui/widgets/qplaintextedit_p.h187
-rw-r--r--src/gui/widgets/qprintpreviewwidget.cpp844
-rw-r--r--src/gui/widgets/qprintpreviewwidget.h127
-rw-r--r--src/gui/widgets/qprogressbar.h132
-rw-r--r--src/gui/widgets/qpushbutton.h127
-rw-r--r--src/gui/widgets/qradiobutton.h89
-rw-r--r--src/gui/widgets/qrubberband.h104
-rw-r--r--src/gui/widgets/qscrollarea.h101
-rw-r--r--src/gui/widgets/qscrollarea_p.h81
-rw-r--r--src/gui/widgets/qscrollbar.h104
-rw-r--r--src/gui/widgets/qsizegrip.cpp570
-rw-r--r--src/gui/widgets/qsizegrip.h95
-rw-r--r--src/gui/widgets/qslider.h134
-rw-r--r--src/gui/widgets/qspinbox.h188
-rw-r--r--src/gui/widgets/qsplashscreen.h99
-rw-r--r--src/gui/widgets/qsplitter.h192
-rw-r--r--src/gui/widgets/qstackedwidget.h100
-rw-r--r--src/gui/widgets/qstatusbar.h116
-rw-r--r--src/gui/widgets/qtabbar.h226
-rw-r--r--src/gui/widgets/qtabwidget.h253
-rw-r--r--src/gui/widgets/qtextbrowser.h140
-rw-r--r--src/gui/widgets/qtextedit.h430
-rw-r--r--src/gui/widgets/qtextedit_p.h141
-rw-r--r--src/gui/widgets/qtoolbar.h188
-rw-r--r--src/gui/widgets/qtoolbar_p.h135
-rw-r--r--src/gui/widgets/qtoolbarextension_p.h80
-rw-r--r--src/gui/widgets/qtoolbarlayout_p.h134
-rw-r--r--src/gui/widgets/qtoolbarseparator_p.h88
-rw-r--r--src/gui/widgets/qtoolbox.h148
-rw-r--r--src/gui/widgets/qtoolbutton.h199
-rw-r--r--src/gui/widgets/qwidgetanimator.cpp117
-rw-r--r--src/gui/widgets/qworkspace.h137
-rw-r--r--src/gui/widgets/widgets.pri169
-rw-r--r--src/modules/qt_opengl.pri2
-rw-r--r--src/modules/qt_openvg.pri16
-rw-r--r--src/modules/qt_widgets.pri14
-rw-r--r--src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp4
-rw-r--r--src/opengl/gl2paintengineex/qtriangulator.cpp2
-rw-r--r--src/opengl/opengl.pro25
-rw-r--r--src/opengl/qgl.cpp8
-rw-r--r--src/opengl/qgl.h12
-rw-r--r--src/opengl/qgl_p.h6
-rw-r--r--src/opengl/qgl_qpa.cpp140
-rw-r--r--src/opengl/qgl_qws.cpp318
-rw-r--r--src/opengl/qglpixmapfilter.cpp1
-rw-r--r--src/opengl/qglscreen_qws.cpp242
-rw-r--r--src/opengl/qglscreen_qws.h127
-rw-r--r--src/opengl/qglwindowsurface_qws.cpp133
-rw-r--r--src/opengl/qglwindowsurface_qws_p.h90
-rw-r--r--src/opengl/qgraphicsshadereffect.cpp4
-rw-r--r--src/opengl/qgraphicsshadereffect_p.h2
-rw-r--r--src/opengl/qgraphicssystem_gl.cpp114
-rw-r--r--src/opengl/qgraphicssystem_gl_p.h80
-rw-r--r--src/opengl/qpaintengine_opengl.cpp4
-rw-r--r--src/opengl/qwindowsurface_gl.cpp165
-rw-r--r--src/opengl/qwindowsurface_gl_p.h10
-rw-r--r--src/openvg/openvg.pro74
-rw-r--r--src/openvg/qpaintengine_vg.cpp4269
-rw-r--r--src/openvg/qpaintengine_vg_p.h178
-rw-r--r--src/openvg/qpixmapdata_vg.cpp575
-rw-r--r--src/openvg/qpixmapdata_vg_p.h202
-rw-r--r--src/openvg/qpixmapfilter_vg.cpp356
-rw-r--r--src/openvg/qpixmapfilter_vg_p.h108
-rw-r--r--src/openvg/qvg.h65
-rw-r--r--src/openvg/qvg_p.h112
-rw-r--r--src/openvg/qvg_symbian.cpp366
-rw-r--r--src/openvg/qvgcompositionhelper_p.h90
-rw-r--r--src/openvg/qvgfontglyphcache_p.h101
-rw-r--r--src/openvg/qvgimagepool.cpp233
-rw-r--r--src/openvg/qvgimagepool_p.h157
-rw-r--r--src/openvg/qwindowsurface_vg.cpp148
-rw-r--r--src/openvg/qwindowsurface_vg_p.h94
-rw-r--r--src/openvg/qwindowsurface_vgegl.cpp783
-rw-r--r--src/openvg/qwindowsurface_vgegl_p.h148
-rw-r--r--src/plugins/accessible/widgets/complexwidgets.h6
-rw-r--r--src/plugins/accessible/widgets/qaccessiblemenu.cpp2
-rw-r--r--src/plugins/accessible/widgets/qaccessiblemenu.h2
-rw-r--r--src/plugins/accessible/widgets/qaccessiblewidgets.cpp2
-rw-r--r--src/plugins/accessible/widgets/qaccessiblewidgets.h4
-rw-r--r--src/plugins/accessible/widgets/rangecontrols.h4
-rw-r--r--src/plugins/accessible/widgets/simplewidgets.h4
-rw-r--r--src/plugins/accessible/widgets/widgets.pro2
-rw-r--r--src/plugins/decorations/decorations.pro4
-rw-r--r--src/plugins/decorations/default/default.pro10
-rw-r--r--src/plugins/decorations/default/main.cpp76
-rw-r--r--src/plugins/decorations/styled/main.cpp77
-rw-r--r--src/plugins/decorations/styled/styled.pro13
-rw-r--r--src/plugins/decorations/windows/main.cpp76
-rw-r--r--src/plugins/decorations/windows/windows.pro10
-rw-r--r--src/plugins/gfxdrivers/ahi/ahi.pro14
-rw-r--r--src/plugins/gfxdrivers/ahi/qscreenahi_qws.cpp598
-rw-r--r--src/plugins/gfxdrivers/ahi/qscreenahi_qws.h84
-rw-r--r--src/plugins/gfxdrivers/ahi/qscreenahiplugin.cpp74
-rw-r--r--src/plugins/gfxdrivers/directfb/directfb.pro15
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp436
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h74
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp294
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbmouse.h75
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp221
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h108
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp1430
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h123
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp588
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h105
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp1819
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreen.h303
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbscreenplugin.cpp78
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp506
-rw-r--r--src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h129
-rw-r--r--src/plugins/gfxdrivers/eglnullws/README48
-rw-r--r--src/plugins/gfxdrivers/eglnullws/eglnullws.pro18
-rw-r--r--src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp181
-rw-r--r--src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.h69
-rw-r--r--src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.cpp66
-rw-r--r--src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.h47
-rw-r--r--src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.cpp84
-rw-r--r--src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.h63
-rw-r--r--src/plugins/gfxdrivers/gfxdrivers.pro10
-rw-r--r--src/plugins/gfxdrivers/linuxfb/linuxfb.pro14
-rw-r--r--src/plugins/gfxdrivers/linuxfb/main.cpp79
-rw-r--r--src/plugins/gfxdrivers/powervr/QWSWSEGL/QWSWSEGL.pro26
-rw-r--r--src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c830
-rw-r--r--src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.h169
-rw-r--r--src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable_p.h132
-rw-r--r--src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwswsegl.c402
-rw-r--r--src/plugins/gfxdrivers/powervr/README66
-rw-r--r--src/plugins/gfxdrivers/powervr/powervr.pri2
-rw-r--r--src/plugins/gfxdrivers/powervr/powervr.pro3
-rw-r--r--src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp351
-rw-r--r--src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.h99
-rw-r--r--src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.pro27
-rw-r--r--src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreenplugin.cpp74
-rw-r--r--src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp273
-rw-r--r--src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.h85
-rw-r--r--src/plugins/gfxdrivers/qvfb/main.cpp82
-rw-r--r--src/plugins/gfxdrivers/qvfb/qvfb.pro19
-rw-r--r--src/plugins/gfxdrivers/transformed/main.cpp84
-rw-r--r--src/plugins/gfxdrivers/transformed/transformed.pro13
-rw-r--r--src/plugins/gfxdrivers/vnc/main.cpp86
-rw-r--r--src/plugins/gfxdrivers/vnc/qscreenvnc_p.h524
-rw-r--r--src/plugins/gfxdrivers/vnc/qscreenvnc_qws.cpp2338
-rw-r--r--src/plugins/gfxdrivers/vnc/qscreenvnc_qws.h88
-rw-r--r--src/plugins/gfxdrivers/vnc/vnc.pro16
-rw-r--r--src/plugins/graphicssystems/graphicssystems.pro15
-rw-r--r--src/plugins/graphicssystems/meego/dithering.cpp266
-rw-r--r--src/plugins/graphicssystems/meego/meego.pro13
-rw-r--r--src/plugins/graphicssystems/meego/qmeegoextensions.cpp213
-rw-r--r--src/plugins/graphicssystems/meego/qmeegoextensions.h125
-rw-r--r--src/plugins/graphicssystems/meego/qmeegographicssystem.cpp534
-rw-r--r--src/plugins/graphicssystems/meego/qmeegographicssystem.h127
-rw-r--r--src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp58
-rw-r--r--src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h54
-rw-r--r--src/plugins/graphicssystems/meego/qmeegolivepixmapdata.cpp323
-rw-r--r--src/plugins/graphicssystems/meego/qmeegolivepixmapdata.h78
-rw-r--r--src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp224
-rw-r--r--src/plugins/graphicssystems/meego/qmeegopixmapdata.h74
-rw-r--r--src/plugins/graphicssystems/meego/qmeegorasterpixmapdata.cpp60
-rw-r--r--src/plugins/graphicssystems/meego/qmeegorasterpixmapdata.h55
-rw-r--r--src/plugins/graphicssystems/opengl/main.cpp95
-rw-r--r--src/plugins/graphicssystems/opengl/opengl.pro13
-rw-r--r--src/plugins/graphicssystems/openvg/main.cpp71
-rw-r--r--src/plugins/graphicssystems/openvg/openvg.pro14
-rw-r--r--src/plugins/graphicssystems/openvg/qgraphicssystem_vg.cpp88
-rw-r--r--src/plugins/graphicssystems/openvg/qgraphicssystem_vg_p.h73
-rw-r--r--src/plugins/graphicssystems/shivavg/README8
-rw-r--r--src/plugins/graphicssystems/shivavg/main.cpp71
-rw-r--r--src/plugins/graphicssystems/shivavg/shivavg.pro12
-rw-r--r--src/plugins/graphicssystems/shivavg/shivavggraphicssystem.cpp62
-rw-r--r--src/plugins/graphicssystems/shivavg/shivavggraphicssystem.h60
-rw-r--r--src/plugins/graphicssystems/shivavg/shivavgwindowsurface.cpp358
-rw-r--r--src/plugins/graphicssystems/shivavg/shivavgwindowsurface.h76
-rw-r--r--src/plugins/graphicssystems/trace/main.cpp69
-rw-r--r--src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp153
-rw-r--r--src/plugins/graphicssystems/trace/qgraphicssystem_trace_p.h71
-rw-r--r--src/plugins/graphicssystems/trace/trace.pro13
-rw-r--r--src/plugins/inputmethods/imsw-multi/imsw-multi.pro1
-rw-r--r--src/plugins/inputmethods/imsw-multi/qmultiinputcontext.h4
-rw-r--r--src/plugins/inputmethods/imsw-multi/qmultiinputcontextplugin.h2
-rw-r--r--src/plugins/kbddrivers/kbddrivers.pro2
-rw-r--r--src/plugins/kbddrivers/linuxinput/linuxinput.pro14
-rw-r--r--src/plugins/kbddrivers/linuxinput/main.cpp77
-rw-r--r--src/plugins/mousedrivers/linuxtp/linuxtp.pro14
-rw-r--r--src/plugins/mousedrivers/linuxtp/main.cpp76
-rw-r--r--src/plugins/mousedrivers/mousedrivers.pro5
-rw-r--r--src/plugins/mousedrivers/pc/main.cpp81
-rw-r--r--src/plugins/mousedrivers/pc/pc.pro14
-rw-r--r--src/plugins/mousedrivers/tslib/main.cpp77
-rw-r--r--src/plugins/mousedrivers/tslib/tslib.pro16
-rw-r--r--src/plugins/platforms/eglconvenience/qeglconvenience.cpp46
-rw-r--r--src/plugins/platforms/eglconvenience/qeglconvenience.h8
-rw-r--r--src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp6
-rw-r--r--src/plugins/platforms/eglconvenience/qeglplatformcontext.h4
-rw-r--r--src/plugins/platforms/eglfs/qeglfswindow.h2
-rw-r--r--src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp2
-rw-r--r--src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp1
-rw-r--r--src/plugins/platforms/glxconvenience/qglxconvenience.cpp99
-rw-r--r--src/plugins/platforms/glxconvenience/qglxconvenience.h12
-rw-r--r--src/plugins/platforms/minimal/minimal.pro1
-rw-r--r--src/plugins/platforms/minimal/qminimalintegration.cpp10
-rw-r--r--src/plugins/platforms/minimal/qminimalintegration.h4
-rw-r--r--src/plugins/platforms/minimal/qminimalwindowsurface.cpp10
-rw-r--r--src/plugins/platforms/minimal/qminimalwindowsurface.h5
-rw-r--r--src/plugins/platforms/openkode/qopenkodewindow.cpp2
-rw-r--r--src/plugins/platforms/vnc/qvncserver.cpp2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h4
-rw-r--r--src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp18
-rw-r--r--src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h4
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp6
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h1
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h3
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp4
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp4
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h4
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h4
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp3
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp4
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp4
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h4
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp6
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp4
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h4
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h2
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp1
-rw-r--r--src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h4
-rw-r--r--src/plugins/platforms/wayland/qwaylandcursor.cpp4
-rw-r--r--src/plugins/platforms/wayland/qwaylandcursor.h2
-rw-r--r--src/plugins/platforms/wayland/qwaylanddisplay.cpp5
-rw-r--r--src/plugins/platforms/wayland/qwaylandinputdevice.cpp12
-rw-r--r--src/plugins/platforms/wayland/qwaylandintegration.cpp20
-rw-r--r--src/plugins/platforms/wayland/qwaylandintegration.h4
-rw-r--r--src/plugins/platforms/wayland/qwaylandnativeinterface.cpp16
-rw-r--r--src/plugins/platforms/wayland/qwaylandnativeinterface.h6
-rw-r--r--src/plugins/platforms/wayland/qwaylandscreen.cpp4
-rw-r--r--src/plugins/platforms/wayland/qwaylandscreen.h2
-rw-r--r--src/plugins/platforms/wayland/qwaylandshmsurface.cpp17
-rw-r--r--src/plugins/platforms/wayland/qwaylandshmsurface.h6
-rw-r--r--src/plugins/platforms/wayland/qwaylandshmwindow.cpp4
-rw-r--r--src/plugins/platforms/wayland/qwaylandshmwindow.h2
-rw-r--r--src/plugins/platforms/wayland/qwaylandwindow.cpp8
-rw-r--r--src/plugins/platforms/wayland/qwaylandwindow.h2
-rw-r--r--src/plugins/platforms/wayland/wayland.pro5
-rw-r--r--src/plugins/platforms/xcb/qdri2context.cpp4
-rw-r--r--src/plugins/platforms/xcb/qglxintegration.cpp15
-rw-r--r--src/plugins/platforms/xcb/qglxintegration.h8
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.cpp30
-rw-r--r--src/plugins/platforms/xcb/qxcbconnection.h10
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.cpp9
-rw-r--r--src/plugins/platforms/xcb/qxcbintegration.h4
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.cpp12
-rw-r--r--src/plugins/platforms/xcb/qxcbkeyboard.h8
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.cpp65
-rw-r--r--src/plugins/platforms/xcb/qxcbnativeinterface.h16
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp78
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.h6
-rw-r--r--src/plugins/platforms/xcb/qxcbwindowsurface.cpp19
-rw-r--r--src/plugins/platforms/xcb/qxcbwindowsurface.h4
-rw-r--r--src/plugins/platforms/xcb/xcb.pro2
-rw-r--r--src/plugins/plugins.pro2
-rw-r--r--src/sql/models/qsqlrelationaldelegate.h6
-rw-r--r--src/src.pro9
-rw-r--r--src/tools/uic/qclass_lib_map.h683
-rw-r--r--src/uitools/quiloader.cpp24
-rw-r--r--src/widgets/QtGui.dynlist (renamed from src/gui/QtGui.dynlist)0
-rw-r--r--src/widgets/accessible/accessible.pri25
-rw-r--r--src/widgets/accessible/qaccessible.cpp (renamed from src/gui/accessible/qaccessible.cpp)0
-rw-r--r--src/widgets/accessible/qaccessible.h461
-rw-r--r--src/widgets/accessible/qaccessible2.cpp (renamed from src/gui/accessible/qaccessible2.cpp)0
-rw-r--r--src/widgets/accessible/qaccessible2.h246
-rw-r--r--src/widgets/accessible/qaccessible_mac.mm (renamed from src/gui/accessible/qaccessible_mac.mm)0
-rw-r--r--src/widgets/accessible/qaccessible_mac_carbon.cpp (renamed from src/gui/accessible/qaccessible_mac_carbon.cpp)0
-rw-r--r--src/widgets/accessible/qaccessible_mac_cocoa.mm (renamed from src/gui/accessible/qaccessible_mac_cocoa.mm)0
-rw-r--r--src/widgets/accessible/qaccessible_mac_p.h (renamed from src/gui/accessible/qaccessible_mac_p.h)0
-rw-r--r--src/widgets/accessible/qaccessible_unix.cpp (renamed from src/gui/accessible/qaccessible_unix.cpp)0
-rw-r--r--src/widgets/accessible/qaccessible_win.cpp (renamed from src/gui/accessible/qaccessible_win.cpp)0
-rw-r--r--src/widgets/accessible/qaccessiblebridge.cpp (renamed from src/gui/accessible/qaccessiblebridge.cpp)0
-rw-r--r--src/widgets/accessible/qaccessiblebridge.h (renamed from src/gui/accessible/qaccessiblebridge.h)0
-rw-r--r--src/widgets/accessible/qaccessibleobject.cpp (renamed from src/gui/accessible/qaccessibleobject.cpp)0
-rw-r--r--src/widgets/accessible/qaccessibleobject.h140
-rw-r--r--src/widgets/accessible/qaccessibleplugin.cpp (renamed from src/gui/accessible/qaccessibleplugin.cpp)0
-rw-r--r--src/widgets/accessible/qaccessibleplugin.h87
-rw-r--r--src/widgets/accessible/qaccessiblewidget.cpp1031
-rw-r--r--src/widgets/accessible/qaccessiblewidget.h141
-rw-r--r--src/widgets/animation/animation.pri (renamed from src/gui/animation/animation.pri)0
-rw-r--r--src/widgets/animation/qguivariantanimation.cpp (renamed from src/gui/animation/qguivariantanimation.cpp)0
-rw-r--r--src/widgets/dialogs/dialogs.pri106
-rw-r--r--src/widgets/dialogs/images/fit-page-24.png (renamed from src/gui/dialogs/images/fit-page-24.png)bin985 -> 985 bytes
-rw-r--r--src/widgets/dialogs/images/fit-page-32.png (renamed from src/gui/dialogs/images/fit-page-32.png)bin1330 -> 1330 bytes
-rw-r--r--src/widgets/dialogs/images/fit-width-24.png (renamed from src/gui/dialogs/images/fit-width-24.png)bin706 -> 706 bytes
-rw-r--r--src/widgets/dialogs/images/fit-width-32.png (renamed from src/gui/dialogs/images/fit-width-32.png)bin1004 -> 1004 bytes
-rw-r--r--src/widgets/dialogs/images/go-first-24.png (renamed from src/gui/dialogs/images/go-first-24.png)bin796 -> 796 bytes
-rw-r--r--src/widgets/dialogs/images/go-first-32.png (renamed from src/gui/dialogs/images/go-first-32.png)bin985 -> 985 bytes
-rw-r--r--src/widgets/dialogs/images/go-last-24.png (renamed from src/gui/dialogs/images/go-last-24.png)bin792 -> 792 bytes
-rw-r--r--src/widgets/dialogs/images/go-last-32.png (renamed from src/gui/dialogs/images/go-last-32.png)bin984 -> 984 bytes
-rw-r--r--src/widgets/dialogs/images/go-next-24.png (renamed from src/gui/dialogs/images/go-next-24.png)bin782 -> 782 bytes
-rw-r--r--src/widgets/dialogs/images/go-next-32.png (renamed from src/gui/dialogs/images/go-next-32.png)bin948 -> 948 bytes
-rw-r--r--src/widgets/dialogs/images/go-previous-24.png (renamed from src/gui/dialogs/images/go-previous-24.png)bin797 -> 797 bytes
-rw-r--r--src/widgets/dialogs/images/go-previous-32.png (renamed from src/gui/dialogs/images/go-previous-32.png)bin945 -> 945 bytes
-rw-r--r--src/widgets/dialogs/images/layout-landscape-24.png (renamed from src/gui/dialogs/images/layout-landscape-24.png)bin820 -> 820 bytes
-rw-r--r--src/widgets/dialogs/images/layout-landscape-32.png (renamed from src/gui/dialogs/images/layout-landscape-32.png)bin1353 -> 1353 bytes
-rw-r--r--src/widgets/dialogs/images/layout-portrait-24.png (renamed from src/gui/dialogs/images/layout-portrait-24.png)bin817 -> 817 bytes
-rw-r--r--src/widgets/dialogs/images/layout-portrait-32.png (renamed from src/gui/dialogs/images/layout-portrait-32.png)bin1330 -> 1330 bytes
-rw-r--r--src/widgets/dialogs/images/page-setup-24.png (renamed from src/gui/dialogs/images/page-setup-24.png)bin620 -> 620 bytes
-rw-r--r--src/widgets/dialogs/images/page-setup-32.png (renamed from src/gui/dialogs/images/page-setup-32.png)bin1154 -> 1154 bytes
-rw-r--r--src/widgets/dialogs/images/print-24.png (renamed from src/gui/dialogs/images/print-24.png)bin914 -> 914 bytes
-rw-r--r--src/widgets/dialogs/images/print-32.png (renamed from src/gui/dialogs/images/print-32.png)bin1202 -> 1202 bytes
-rw-r--r--src/widgets/dialogs/images/qtlogo-64.png (renamed from src/gui/dialogs/images/qtlogo-64.png)bin2991 -> 2991 bytes
-rw-r--r--src/widgets/dialogs/images/status-color.png (renamed from src/gui/dialogs/images/status-color.png)bin1475 -> 1475 bytes
-rw-r--r--src/widgets/dialogs/images/status-gray-scale.png (renamed from src/gui/dialogs/images/status-gray-scale.png)bin1254 -> 1254 bytes
-rw-r--r--src/widgets/dialogs/images/view-page-multi-24.png (renamed from src/gui/dialogs/images/view-page-multi-24.png)bin390 -> 390 bytes
-rw-r--r--src/widgets/dialogs/images/view-page-multi-32.png (renamed from src/gui/dialogs/images/view-page-multi-32.png)bin556 -> 556 bytes
-rw-r--r--src/widgets/dialogs/images/view-page-one-24.png (renamed from src/gui/dialogs/images/view-page-one-24.png)bin662 -> 662 bytes
-rw-r--r--src/widgets/dialogs/images/view-page-one-32.png (renamed from src/gui/dialogs/images/view-page-one-32.png)bin810 -> 810 bytes
-rw-r--r--src/widgets/dialogs/images/view-page-sided-24.png (renamed from src/gui/dialogs/images/view-page-sided-24.png)bin700 -> 700 bytes
-rw-r--r--src/widgets/dialogs/images/view-page-sided-32.png (renamed from src/gui/dialogs/images/view-page-sided-32.png)bin908 -> 908 bytes
-rw-r--r--src/widgets/dialogs/images/zoom-in-24.png (renamed from src/gui/dialogs/images/zoom-in-24.png)bin1302 -> 1302 bytes
-rw-r--r--src/widgets/dialogs/images/zoom-in-32.png (renamed from src/gui/dialogs/images/zoom-in-32.png)bin1873 -> 1873 bytes
-rw-r--r--src/widgets/dialogs/images/zoom-out-24.png (renamed from src/gui/dialogs/images/zoom-out-24.png)bin1247 -> 1247 bytes
-rw-r--r--src/widgets/dialogs/images/zoom-out-32.png (renamed from src/gui/dialogs/images/zoom-out-32.png)bin1749 -> 1749 bytes
-rw-r--r--src/widgets/dialogs/qabstractpagesetupdialog.cpp (renamed from src/gui/dialogs/qabstractpagesetupdialog.cpp)0
-rw-r--r--src/widgets/dialogs/qabstractpagesetupdialog.h82
-rw-r--r--src/widgets/dialogs/qabstractpagesetupdialog_p.h (renamed from src/gui/dialogs/qabstractpagesetupdialog_p.h)0
-rw-r--r--src/widgets/dialogs/qabstractprintdialog.cpp499
-rw-r--r--src/widgets/dialogs/qabstractprintdialog.h130
-rw-r--r--src/widgets/dialogs/qabstractprintdialog_p.h99
-rw-r--r--src/widgets/dialogs/qcolordialog.cpp2115
-rw-r--r--src/widgets/dialogs/qcolordialog.h150
-rw-r--r--src/widgets/dialogs/qcolordialog_mac.mm (renamed from src/gui/dialogs/qcolordialog_mac.mm)0
-rw-r--r--src/widgets/dialogs/qcolordialog_p.h (renamed from src/gui/dialogs/qcolordialog_p.h)0
-rw-r--r--src/widgets/dialogs/qcolordialog_symbian.cpp (renamed from src/gui/dialogs/qcolordialog_symbian.cpp)0
-rw-r--r--src/widgets/dialogs/qdialog.cpp (renamed from src/gui/dialogs/qdialog.cpp)0
-rw-r--r--src/widgets/dialogs/qdialog.h140
-rw-r--r--src/widgets/dialogs/qdialog_p.h113
-rw-r--r--src/widgets/dialogs/qdialogsbinarycompat_win.cpp (renamed from src/gui/dialogs/qdialogsbinarycompat_win.cpp)0
-rw-r--r--src/widgets/dialogs/qerrormessage.cpp (renamed from src/gui/dialogs/qerrormessage.cpp)0
-rw-r--r--src/widgets/dialogs/qerrormessage.h88
-rw-r--r--src/widgets/dialogs/qfiledialog.cpp (renamed from src/gui/dialogs/qfiledialog.cpp)0
-rw-r--r--src/widgets/dialogs/qfiledialog.h331
-rw-r--r--src/widgets/dialogs/qfiledialog.ui (renamed from src/gui/dialogs/qfiledialog.ui)0
-rw-r--r--src/widgets/dialogs/qfiledialog_embedded.ui (renamed from src/gui/dialogs/qfiledialog_embedded.ui)0
-rw-r--r--src/widgets/dialogs/qfiledialog_mac.mm (renamed from src/gui/dialogs/qfiledialog_mac.mm)0
-rw-r--r--src/widgets/dialogs/qfiledialog_p.h (renamed from src/gui/dialogs/qfiledialog_p.h)0
-rw-r--r--src/widgets/dialogs/qfiledialog_symbian.cpp (renamed from src/gui/dialogs/qfiledialog_symbian.cpp)0
-rw-r--r--src/widgets/dialogs/qfiledialog_win.cpp (renamed from src/gui/dialogs/qfiledialog_win.cpp)0
-rw-r--r--src/widgets/dialogs/qfiledialog_win_p.h (renamed from src/gui/dialogs/qfiledialog_win_p.h)0
-rw-r--r--src/widgets/dialogs/qfileinfogatherer.cpp (renamed from src/gui/dialogs/qfileinfogatherer.cpp)0
-rw-r--r--src/widgets/dialogs/qfileinfogatherer_p.h (renamed from src/gui/dialogs/qfileinfogatherer_p.h)0
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.cpp (renamed from src/gui/dialogs/qfilesystemmodel.cpp)0
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.h180
-rw-r--r--src/widgets/dialogs/qfilesystemmodel_p.h (renamed from src/gui/dialogs/qfilesystemmodel_p.h)0
-rw-r--r--src/widgets/dialogs/qfontdialog.cpp1077
-rw-r--r--src/widgets/dialogs/qfontdialog.h147
-rw-r--r--src/widgets/dialogs/qfontdialog_mac.mm (renamed from src/gui/dialogs/qfontdialog_mac.mm)0
-rw-r--r--src/widgets/dialogs/qfontdialog_p.h (renamed from src/gui/dialogs/qfontdialog_p.h)0
-rw-r--r--src/widgets/dialogs/qfscompleter_p.h82
-rw-r--r--src/widgets/dialogs/qinputdialog.cpp (renamed from src/gui/dialogs/qinputdialog.cpp)0
-rw-r--r--src/widgets/dialogs/qinputdialog.h256
-rw-r--r--src/widgets/dialogs/qmessagebox.cpp2751
-rw-r--r--src/widgets/dialogs/qmessagebox.h365
-rw-r--r--src/widgets/dialogs/qmessagebox.qrc (renamed from src/gui/dialogs/qmessagebox.qrc)0
-rw-r--r--src/widgets/dialogs/qnspanelproxy_mac.mm (renamed from src/gui/dialogs/qnspanelproxy_mac.mm)0
-rw-r--r--src/widgets/dialogs/qpagesetupdialog.cpp (renamed from src/gui/dialogs/qpagesetupdialog.cpp)0
-rw-r--r--src/widgets/dialogs/qpagesetupdialog.h112
-rw-r--r--src/widgets/dialogs/qpagesetupdialog_mac.mm (renamed from src/gui/dialogs/qpagesetupdialog_mac.mm)0
-rw-r--r--src/widgets/dialogs/qpagesetupdialog_unix.cpp (renamed from src/gui/dialogs/qpagesetupdialog_unix.cpp)0
-rw-r--r--src/widgets/dialogs/qpagesetupdialog_unix_p.h (renamed from src/gui/dialogs/qpagesetupdialog_unix_p.h)0
-rw-r--r--src/widgets/dialogs/qpagesetupdialog_win.cpp (renamed from src/gui/dialogs/qpagesetupdialog_win.cpp)0
-rw-r--r--src/widgets/dialogs/qpagesetupwidget.ui (renamed from src/gui/dialogs/qpagesetupwidget.ui)0
-rw-r--r--src/widgets/dialogs/qprintdialog.h174
-rw-r--r--src/widgets/dialogs/qprintdialog.qdoc (renamed from src/gui/dialogs/qprintdialog.qdoc)0
-rw-r--r--src/widgets/dialogs/qprintdialog.qrc (renamed from src/gui/dialogs/qprintdialog.qrc)0
-rw-r--r--src/widgets/dialogs/qprintdialog_mac.mm (renamed from src/gui/dialogs/qprintdialog_mac.mm)0
-rw-r--r--src/widgets/dialogs/qprintdialog_unix.cpp1286
-rw-r--r--src/widgets/dialogs/qprintdialog_win.cpp (renamed from src/gui/dialogs/qprintdialog_win.cpp)0
-rw-r--r--src/widgets/dialogs/qprintpreviewdialog.cpp803
-rw-r--r--src/widgets/dialogs/qprintpreviewdialog.h107
-rw-r--r--src/widgets/dialogs/qprintpropertieswidget.ui (renamed from src/gui/dialogs/qprintpropertieswidget.ui)0
-rw-r--r--src/widgets/dialogs/qprintsettingsoutput.ui (renamed from src/gui/dialogs/qprintsettingsoutput.ui)0
-rw-r--r--src/widgets/dialogs/qprintwidget.ui (renamed from src/gui/dialogs/qprintwidget.ui)0
-rw-r--r--src/widgets/dialogs/qprogressdialog.cpp907
-rw-r--r--src/widgets/dialogs/qprogressdialog.h145
-rw-r--r--src/widgets/dialogs/qsidebar.cpp (renamed from src/gui/dialogs/qsidebar.cpp)0
-rw-r--r--src/widgets/dialogs/qsidebar_p.h (renamed from src/gui/dialogs/qsidebar_p.h)0
-rw-r--r--src/widgets/dialogs/qwizard.cpp (renamed from src/gui/dialogs/qwizard.cpp)0
-rw-r--r--src/widgets/dialogs/qwizard.h268
-rw-r--r--src/widgets/dialogs/qwizard_win.cpp759
-rw-r--r--src/widgets/dialogs/qwizard_win_p.h (renamed from src/gui/dialogs/qwizard_win_p.h)0
-rw-r--r--src/widgets/effects/effects.pri6
-rw-r--r--src/widgets/effects/qgraphicseffect.cpp1235
-rw-r--r--src/widgets/effects/qgraphicseffect.h (renamed from src/gui/effects/qgraphicseffect.h)0
-rw-r--r--src/widgets/effects/qgraphicseffect_p.h (renamed from src/gui/effects/qgraphicseffect_p.h)0
-rw-r--r--src/widgets/effects/qpixmapfilter.cpp1381
-rw-r--r--src/widgets/effects/qpixmapfilter_p.h196
-rw-r--r--src/widgets/graphicsview/graphicsview.pri (renamed from src/gui/graphicsview/graphicsview.pri)0
-rw-r--r--src/widgets/graphicsview/qgraph_p.h (renamed from src/gui/graphicsview/qgraph_p.h)0
-rw-r--r--src/widgets/graphicsview/qgraphicsanchorlayout.cpp (renamed from src/gui/graphicsview/qgraphicsanchorlayout.cpp)0
-rw-r--r--src/widgets/graphicsview/qgraphicsanchorlayout.h128
-rw-r--r--src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp3015
-rw-r--r--src/widgets/graphicsview/qgraphicsanchorlayout_p.h (renamed from src/gui/graphicsview/qgraphicsanchorlayout_p.h)0
-rw-r--r--src/widgets/graphicsview/qgraphicsgridlayout.cpp (renamed from src/gui/graphicsview/qgraphicsgridlayout.cpp)0
-rw-r--r--src/widgets/graphicsview/qgraphicsgridlayout.h144
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp11601
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.h (renamed from src/gui/graphicsview/qgraphicsitem.h)0
-rw-r--r--src/widgets/graphicsview/qgraphicsitem_p.h (renamed from src/gui/graphicsview/qgraphicsitem_p.h)0
-rw-r--r--src/widgets/graphicsview/qgraphicsitemanimation.cpp (renamed from src/gui/graphicsview/qgraphicsitemanimation.cpp)0
-rw-r--r--src/widgets/graphicsview/qgraphicsitemanimation.h (renamed from src/gui/graphicsview/qgraphicsitemanimation.h)0
-rw-r--r--src/widgets/graphicsview/qgraphicslayout.cpp (renamed from src/gui/graphicsview/qgraphicslayout.cpp)0
-rw-r--r--src/widgets/graphicsview/qgraphicslayout.h98
-rw-r--r--src/widgets/graphicsview/qgraphicslayout_p.cpp (renamed from src/gui/graphicsview/qgraphicslayout_p.cpp)0
-rw-r--r--src/widgets/graphicsview/qgraphicslayout_p.h154
-rw-r--r--src/widgets/graphicsview/qgraphicslayoutitem.cpp (renamed from src/gui/graphicsview/qgraphicslayoutitem.cpp)0
-rw-r--r--src/widgets/graphicsview/qgraphicslayoutitem.h155
-rw-r--r--src/widgets/graphicsview/qgraphicslayoutitem_p.h103
-rw-r--r--src/widgets/graphicsview/qgraphicslinearlayout.cpp (renamed from src/gui/graphicsview/qgraphicslinearlayout.cpp)0
-rw-r--r--src/widgets/graphicsview/qgraphicslinearlayout.h119
-rw-r--r--src/widgets/graphicsview/qgraphicsproxywidget.cpp1570
-rw-r--r--src/widgets/graphicsview/qgraphicsproxywidget.h147
-rw-r--r--src/widgets/graphicsview/qgraphicsproxywidget_p.h (renamed from src/gui/graphicsview/qgraphicsproxywidget_p.h)0
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.cpp6502
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.h (renamed from src/gui/graphicsview/qgraphicsscene.h)0
-rw-r--r--src/widgets/graphicsview/qgraphicsscene_bsp.cpp (renamed from src/gui/graphicsview/qgraphicsscene_bsp.cpp)0
-rw-r--r--src/widgets/graphicsview/qgraphicsscene_bsp_p.h (renamed from src/gui/graphicsview/qgraphicsscene_bsp_p.h)0
-rw-r--r--src/widgets/graphicsview/qgraphicsscene_p.h359
-rw-r--r--src/widgets/graphicsview/qgraphicsscenebsptreeindex.cpp (renamed from src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp)0
-rw-r--r--src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h (renamed from src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h)0
-rw-r--r--src/widgets/graphicsview/qgraphicssceneevent.cpp1674
-rw-r--r--src/widgets/graphicsview/qgraphicssceneevent.h (renamed from src/gui/graphicsview/qgraphicssceneevent.h)0
-rw-r--r--src/widgets/graphicsview/qgraphicssceneindex.cpp (renamed from src/gui/graphicsview/qgraphicssceneindex.cpp)0
-rw-r--r--src/widgets/graphicsview/qgraphicssceneindex_p.h (renamed from src/gui/graphicsview/qgraphicssceneindex_p.h)0
-rw-r--r--src/widgets/graphicsview/qgraphicsscenelinearindex.cpp (renamed from src/gui/graphicsview/qgraphicsscenelinearindex.cpp)0
-rw-r--r--src/widgets/graphicsview/qgraphicsscenelinearindex_p.h109
-rw-r--r--src/widgets/graphicsview/qgraphicstransform.cpp (renamed from src/gui/graphicsview/qgraphicstransform.cpp)0
-rw-r--r--src/widgets/graphicsview/qgraphicstransform.h (renamed from src/gui/graphicsview/qgraphicstransform.h)0
-rw-r--r--src/widgets/graphicsview/qgraphicstransform_p.h (renamed from src/gui/graphicsview/qgraphicstransform_p.h)0
-rw-r--r--src/widgets/graphicsview/qgraphicsview.cpp3880
-rw-r--r--src/widgets/graphicsview/qgraphicsview.h316
-rw-r--r--src/widgets/graphicsview/qgraphicsview_p.h233
-rw-r--r--src/widgets/graphicsview/qgraphicswidget.cpp2388
-rw-r--r--src/widgets/graphicsview/qgraphicswidget.h257
-rw-r--r--src/widgets/graphicsview/qgraphicswidget_p.cpp906
-rw-r--r--src/widgets/graphicsview/qgraphicswidget_p.h226
-rw-r--r--src/widgets/graphicsview/qgridlayoutengine.cpp (renamed from src/gui/graphicsview/qgridlayoutengine.cpp)0
-rw-r--r--src/widgets/graphicsview/qgridlayoutengine_p.h (renamed from src/gui/graphicsview/qgridlayoutengine_p.h)0
-rw-r--r--src/widgets/graphicsview/qsimplex_p.cpp (renamed from src/gui/graphicsview/qsimplex_p.cpp)0
-rw-r--r--src/widgets/graphicsview/qsimplex_p.h (renamed from src/gui/graphicsview/qsimplex_p.h)0
-rw-r--r--src/widgets/inputmethod/inputmethod.pri27
-rw-r--r--src/widgets/inputmethod/qcoefepinputcontext_p.h (renamed from src/gui/inputmethod/qcoefepinputcontext_p.h)0
-rw-r--r--src/widgets/inputmethod/qcoefepinputcontext_s60.cpp (renamed from src/gui/inputmethod/qcoefepinputcontext_s60.cpp)0
-rw-r--r--src/widgets/inputmethod/qinputcontext.cpp (renamed from src/gui/inputmethod/qinputcontext.cpp)0
-rw-r--r--src/widgets/inputmethod/qinputcontext.h139
-rw-r--r--src/widgets/inputmethod/qinputcontext_p.h (renamed from src/gui/inputmethod/qinputcontext_p.h)0
-rw-r--r--src/widgets/inputmethod/qinputcontextfactory.cpp (renamed from src/gui/inputmethod/qinputcontextfactory.cpp)0
-rw-r--r--src/widgets/inputmethod/qinputcontextfactory.h (renamed from src/gui/inputmethod/qinputcontextfactory.h)0
-rw-r--r--src/widgets/inputmethod/qinputcontextplugin.cpp (renamed from src/gui/inputmethod/qinputcontextplugin.cpp)0
-rw-r--r--src/widgets/inputmethod/qinputcontextplugin.h (renamed from src/gui/inputmethod/qinputcontextplugin.h)0
-rw-r--r--src/widgets/inputmethod/qmacinputcontext_mac.cpp (renamed from src/gui/inputmethod/qmacinputcontext_mac.cpp)0
-rw-r--r--src/widgets/inputmethod/qmacinputcontext_p.h97
-rw-r--r--src/widgets/inputmethod/qwininputcontext_p.h111
-rw-r--r--src/widgets/inputmethod/qwininputcontext_win.cpp (renamed from src/gui/inputmethod/qwininputcontext_win.cpp)0
-rw-r--r--src/widgets/inputmethod/qximinputcontext_p.h142
-rw-r--r--src/widgets/inputmethod/qximinputcontext_x11.cpp (renamed from src/gui/inputmethod/qximinputcontext_x11.cpp)0
-rw-r--r--src/widgets/itemviews/itemviews.pri (renamed from src/gui/itemviews/itemviews.pri)0
-rw-r--r--src/widgets/itemviews/qabstractitemdelegate.cpp (renamed from src/gui/itemviews/qabstractitemdelegate.cpp)0
-rw-r--r--src/widgets/itemviews/qabstractitemdelegate.h134
-rw-r--r--src/widgets/itemviews/qabstractitemview.cpp (renamed from src/gui/itemviews/qabstractitemview.cpp)0
-rw-r--r--src/widgets/itemviews/qabstractitemview.h380
-rw-r--r--src/widgets/itemviews/qabstractitemview_p.h457
-rw-r--r--src/widgets/itemviews/qabstractproxymodel.cpp (renamed from src/gui/itemviews/qabstractproxymodel.cpp)0
-rw-r--r--src/widgets/itemviews/qabstractproxymodel.h (renamed from src/gui/itemviews/qabstractproxymodel.h)0
-rw-r--r--src/widgets/itemviews/qabstractproxymodel_p.h (renamed from src/gui/itemviews/qabstractproxymodel_p.h)0
-rw-r--r--src/widgets/itemviews/qbsptree.cpp (renamed from src/gui/itemviews/qbsptree.cpp)0
-rw-r--r--src/widgets/itemviews/qbsptree_p.h (renamed from src/gui/itemviews/qbsptree_p.h)0
-rw-r--r--src/widgets/itemviews/qcolumnview.cpp (renamed from src/gui/itemviews/qcolumnview.cpp)0
-rw-r--r--src/widgets/itemviews/qcolumnview.h123
-rw-r--r--src/widgets/itemviews/qcolumnview_p.h189
-rw-r--r--src/widgets/itemviews/qcolumnviewgrip.cpp (renamed from src/gui/itemviews/qcolumnviewgrip.cpp)0
-rw-r--r--src/widgets/itemviews/qcolumnviewgrip_p.h (renamed from src/gui/itemviews/qcolumnviewgrip_p.h)0
-rw-r--r--src/widgets/itemviews/qdatawidgetmapper.cpp (renamed from src/gui/itemviews/qdatawidgetmapper.cpp)0
-rw-r--r--src/widgets/itemviews/qdatawidgetmapper.h (renamed from src/gui/itemviews/qdatawidgetmapper.h)0
-rw-r--r--src/widgets/itemviews/qdirmodel.cpp (renamed from src/gui/itemviews/qdirmodel.cpp)0
-rw-r--r--src/widgets/itemviews/qdirmodel.h160
-rw-r--r--src/widgets/itemviews/qfileiconprovider.cpp (renamed from src/gui/itemviews/qfileiconprovider.cpp)0
-rw-r--r--src/widgets/itemviews/qfileiconprovider.h82
-rw-r--r--src/widgets/itemviews/qheaderview.cpp (renamed from src/gui/itemviews/qheaderview.cpp)0
-rw-r--r--src/widgets/itemviews/qheaderview.h250
-rw-r--r--src/widgets/itemviews/qheaderview_p.h366
-rw-r--r--src/widgets/itemviews/qitemdelegate.cpp (renamed from src/gui/itemviews/qitemdelegate.cpp)0
-rw-r--r--src/widgets/itemviews/qitemdelegate.h141
-rw-r--r--src/widgets/itemviews/qitemeditorfactory.cpp (renamed from src/gui/itemviews/qitemeditorfactory.cpp)0
-rw-r--r--src/widgets/itemviews/qitemeditorfactory.h (renamed from src/gui/itemviews/qitemeditorfactory.h)0
-rw-r--r--src/widgets/itemviews/qitemeditorfactory_p.h (renamed from src/gui/itemviews/qitemeditorfactory_p.h)0
-rw-r--r--src/widgets/itemviews/qitemselectionmodel.cpp (renamed from src/gui/itemviews/qitemselectionmodel.cpp)0
-rw-r--r--src/widgets/itemviews/qitemselectionmodel.h (renamed from src/gui/itemviews/qitemselectionmodel.h)0
-rw-r--r--src/widgets/itemviews/qitemselectionmodel_p.h (renamed from src/gui/itemviews/qitemselectionmodel_p.h)0
-rw-r--r--src/widgets/itemviews/qlistview.cpp3213
-rw-r--r--src/widgets/itemviews/qlistview.h203
-rw-r--r--src/widgets/itemviews/qlistview_p.h (renamed from src/gui/itemviews/qlistview_p.h)0
-rw-r--r--src/widgets/itemviews/qlistwidget.cpp (renamed from src/gui/itemviews/qlistwidget.cpp)0
-rw-r--r--src/widgets/itemviews/qlistwidget.h335
-rw-r--r--src/widgets/itemviews/qlistwidget_p.h175
-rw-r--r--src/widgets/itemviews/qproxymodel.cpp (renamed from src/gui/itemviews/qproxymodel.cpp)0
-rw-r--r--src/widgets/itemviews/qproxymodel.h (renamed from src/gui/itemviews/qproxymodel.h)0
-rw-r--r--src/widgets/itemviews/qproxymodel_p.h (renamed from src/gui/itemviews/qproxymodel_p.h)0
-rw-r--r--src/widgets/itemviews/qsortfilterproxymodel.cpp (renamed from src/gui/itemviews/qsortfilterproxymodel.cpp)0
-rw-r--r--src/widgets/itemviews/qsortfilterproxymodel.h201
-rw-r--r--src/widgets/itemviews/qstandarditemmodel.cpp (renamed from src/gui/itemviews/qstandarditemmodel.cpp)0
-rw-r--r--src/widgets/itemviews/qstandarditemmodel.h456
-rw-r--r--src/widgets/itemviews/qstandarditemmodel_p.h (renamed from src/gui/itemviews/qstandarditemmodel_p.h)0
-rw-r--r--src/widgets/itemviews/qstringlistmodel.cpp (renamed from src/gui/itemviews/qstringlistmodel.cpp)0
-rw-r--r--src/widgets/itemviews/qstringlistmodel.h91
-rw-r--r--src/widgets/itemviews/qstyleditemdelegate.cpp (renamed from src/gui/itemviews/qstyleditemdelegate.cpp)0
-rw-r--r--src/widgets/itemviews/qstyleditemdelegate.h116
-rw-r--r--src/widgets/itemviews/qtableview.cpp (renamed from src/gui/itemviews/qtableview.cpp)0
-rw-r--r--src/widgets/itemviews/qtableview.h198
-rw-r--r--src/widgets/itemviews/qtableview_p.h (renamed from src/gui/itemviews/qtableview_p.h)0
-rw-r--r--src/widgets/itemviews/qtablewidget.cpp (renamed from src/gui/itemviews/qtablewidget.cpp)0
-rw-r--r--src/widgets/itemviews/qtablewidget.h377
-rw-r--r--src/widgets/itemviews/qtablewidget_p.h (renamed from src/gui/itemviews/qtablewidget_p.h)0
-rw-r--r--src/widgets/itemviews/qtreeview.cpp (renamed from src/gui/itemviews/qtreeview.cpp)0
-rw-r--r--src/widgets/itemviews/qtreeview.h239
-rw-r--r--src/widgets/itemviews/qtreeview_p.h (renamed from src/gui/itemviews/qtreeview_p.h)0
-rw-r--r--src/widgets/itemviews/qtreewidget.cpp (renamed from src/gui/itemviews/qtreewidget.cpp)0
-rw-r--r--src/widgets/itemviews/qtreewidget.h432
-rw-r--r--src/widgets/itemviews/qtreewidget_p.h248
-rw-r--r--src/widgets/itemviews/qtreewidgetitemiterator.cpp (renamed from src/gui/itemviews/qtreewidgetitemiterator.cpp)0
-rw-r--r--src/widgets/itemviews/qtreewidgetitemiterator.h (renamed from src/gui/itemviews/qtreewidgetitemiterator.h)0
-rw-r--r--src/widgets/itemviews/qtreewidgetitemiterator_p.h (renamed from src/gui/itemviews/qtreewidgetitemiterator_p.h)0
-rw-r--r--src/widgets/itemviews/qwidgetitemdata_p.h (renamed from src/gui/itemviews/qwidgetitemdata_p.h)0
-rw-r--r--src/widgets/kernel/kernel.pri246
-rw-r--r--src/widgets/kernel/mac.pri4
-rw-r--r--src/widgets/kernel/qaction.cpp (renamed from src/gui/kernel/qaction.cpp)0
-rw-r--r--src/widgets/kernel/qaction.h264
-rw-r--r--src/widgets/kernel/qaction_p.h144
-rw-r--r--src/widgets/kernel/qactiongroup.cpp (renamed from src/gui/kernel/qactiongroup.cpp)0
-rw-r--r--src/widgets/kernel/qactiongroup.h112
-rw-r--r--src/widgets/kernel/qapplication.cpp5674
-rw-r--r--src/widgets/kernel/qapplication.h422
-rw-r--r--src/widgets/kernel/qapplication_p.h626
-rw-r--r--src/widgets/kernel/qapplication_qpa.cpp425
-rw-r--r--src/widgets/kernel/qbackingstore.cpp1665
-rw-r--r--src/widgets/kernel/qbackingstore_p.h278
-rw-r--r--src/widgets/kernel/qboxlayout.cpp (renamed from src/gui/kernel/qboxlayout.cpp)0
-rw-r--r--src/widgets/kernel/qboxlayout.h173
-rw-r--r--src/widgets/kernel/qdesktopwidget.cpp (renamed from src/gui/kernel/qdesktopwidget.cpp)0
-rw-r--r--src/widgets/kernel/qdesktopwidget.h110
-rw-r--r--src/widgets/kernel/qdesktopwidget.qdoc (renamed from src/gui/kernel/qdesktopwidget.qdoc)0
-rw-r--r--src/widgets/kernel/qdesktopwidget_qpa.cpp174
-rw-r--r--src/widgets/kernel/qdesktopwidget_qpa_p.h (renamed from src/gui/kernel/qdesktopwidget_qpa_p.h)0
-rw-r--r--src/widgets/kernel/qformlayout.cpp (renamed from src/gui/kernel/qformlayout.cpp)0
-rw-r--r--src/widgets/kernel/qformlayout.h163
-rw-r--r--src/widgets/kernel/qgesture.cpp1118
-rw-r--r--src/widgets/kernel/qgesture.h328
-rw-r--r--src/widgets/kernel/qgesture_p.h245
-rw-r--r--src/widgets/kernel/qgesturemanager.cpp (renamed from src/gui/kernel/qgesturemanager.cpp)0
-rw-r--r--src/widgets/kernel/qgesturemanager_p.h (renamed from src/gui/kernel/qgesturemanager_p.h)0
-rw-r--r--src/widgets/kernel/qgesturerecognizer.cpp (renamed from src/gui/kernel/qgesturerecognizer.cpp)0
-rw-r--r--src/widgets/kernel/qgesturerecognizer.h (renamed from src/gui/kernel/qgesturerecognizer.h)0
-rw-r--r--src/widgets/kernel/qgridlayout.cpp (renamed from src/gui/kernel/qgridlayout.cpp)0
-rw-r--r--src/widgets/kernel/qgridlayout.h176
-rw-r--r--src/widgets/kernel/qguieventdispatcher_glib.cpp (renamed from src/gui/kernel/qguieventdispatcher_glib.cpp)0
-rw-r--r--src/widgets/kernel/qguieventdispatcher_glib_p.h (renamed from src/gui/kernel/qguieventdispatcher_glib_p.h)0
-rw-r--r--src/widgets/kernel/qguiplatformplugin.cpp (renamed from src/gui/kernel/qguiplatformplugin.cpp)0
-rw-r--r--src/widgets/kernel/qguiplatformplugin_p.h126
-rw-r--r--src/widgets/kernel/qicon.cpp1165
-rw-r--r--src/widgets/kernel/qicon.h143
-rw-r--r--src/widgets/kernel/qicon_p.h139
-rw-r--r--src/widgets/kernel/qiconengine.cpp (renamed from src/gui/image/qiconengine.cpp)0
-rw-r--r--src/widgets/kernel/qiconengine.h104
-rw-r--r--src/widgets/kernel/qiconengineplugin.cpp (renamed from src/gui/image/qiconengineplugin.cpp)0
-rw-r--r--src/widgets/kernel/qiconengineplugin.h (renamed from src/gui/image/qiconengineplugin.h)0
-rw-r--r--src/widgets/kernel/qiconloader.cpp573
-rw-r--r--src/widgets/kernel/qiconloader_p.h192
-rw-r--r--src/widgets/kernel/qlayout.cpp (renamed from src/gui/kernel/qlayout.cpp)0
-rw-r--r--src/widgets/kernel/qlayout.h245
-rw-r--r--src/widgets/kernel/qlayout_p.h (renamed from src/gui/kernel/qlayout_p.h)0
-rw-r--r--src/widgets/kernel/qlayoutengine.cpp (renamed from src/gui/kernel/qlayoutengine.cpp)0
-rw-r--r--src/widgets/kernel/qlayoutengine_p.h140
-rw-r--r--src/widgets/kernel/qlayoutitem.cpp (renamed from src/gui/kernel/qlayoutitem.cpp)0
-rw-r--r--src/widgets/kernel/qlayoutitem.h182
-rw-r--r--src/widgets/kernel/qsizepolicy.h (renamed from src/gui/kernel/qsizepolicy.h)0
-rw-r--r--src/widgets/kernel/qsizepolicy.qdoc (renamed from src/gui/kernel/qsizepolicy.qdoc)0
-rw-r--r--src/widgets/kernel/qsoftkeymanager.cpp (renamed from src/gui/kernel/qsoftkeymanager.cpp)0
-rw-r--r--src/widgets/kernel/qsoftkeymanager_common_p.h (renamed from src/gui/kernel/qsoftkeymanager_common_p.h)0
-rw-r--r--src/widgets/kernel/qsoftkeymanager_p.h115
-rw-r--r--src/widgets/kernel/qsound.cpp367
-rw-r--r--src/widgets/kernel/qsound.h90
-rw-r--r--src/widgets/kernel/qsound_p.h (renamed from src/gui/kernel/qsound_p.h)0
-rw-r--r--src/widgets/kernel/qstackedlayout.cpp (renamed from src/gui/kernel/qstackedlayout.cpp)0
-rw-r--r--src/widgets/kernel/qstackedlayout.h115
-rw-r--r--src/widgets/kernel/qstandardgestures.cpp (renamed from src/gui/kernel/qstandardgestures.cpp)0
-rw-r--r--src/widgets/kernel/qstandardgestures_p.h (renamed from src/gui/kernel/qstandardgestures_p.h)0
-rw-r--r--src/widgets/kernel/qt_gui_pch.h (renamed from src/gui/kernel/qt_gui_pch.h)0
-rw-r--r--src/widgets/kernel/qtooltip.cpp (renamed from src/gui/kernel/qtooltip.cpp)0
-rw-r--r--src/widgets/kernel/qtooltip.h84
-rw-r--r--src/widgets/kernel/qwhatsthis.cpp777
-rw-r--r--src/widgets/kernel/qwhatsthis.h (renamed from src/gui/kernel/qwhatsthis.h)0
-rw-r--r--src/widgets/kernel/qwidget.cpp12682
-rw-r--r--src/widgets/kernel/qwidget.h1091
-rw-r--r--src/widgets/kernel/qwidget_p.h1034
-rw-r--r--src/widgets/kernel/qwidget_qpa.cpp824
-rw-r--r--src/widgets/kernel/qwidgetaction.cpp (renamed from src/gui/kernel/qwidgetaction.cpp)0
-rw-r--r--src/widgets/kernel/qwidgetaction.h91
-rw-r--r--src/widgets/kernel/qwidgetaction_p.h (renamed from src/gui/kernel/qwidgetaction_p.h)0
-rw-r--r--src/widgets/kernel/qwidgetsvariant.cpp213
-rw-r--r--src/widgets/kernel/qwidgetwindow_qpa.cpp195
-rw-r--r--src/widgets/kernel/qwidgetwindow_qpa_p.h83
-rw-r--r--src/widgets/kernel/symbian.pri (renamed from src/gui/kernel/symbian.pri)0
-rw-r--r--src/widgets/kernel/win.pri (renamed from src/gui/kernel/win.pri)0
-rw-r--r--src/widgets/kernel/x11.pri (renamed from src/gui/kernel/x11.pri)0
-rw-r--r--src/widgets/mac/images/copyarrowcursor.png (renamed from src/gui/mac/images/copyarrowcursor.png)bin1976 -> 1976 bytes
-rw-r--r--src/widgets/mac/images/forbiddencursor.png (renamed from src/gui/mac/images/forbiddencursor.png)bin1745 -> 1745 bytes
-rw-r--r--src/widgets/mac/images/leopard-unified-toolbar-on.png (renamed from src/gui/mac/images/leopard-unified-toolbar-on.png)bin356 -> 356 bytes
-rw-r--r--src/widgets/mac/images/pluscursor.png (renamed from src/gui/mac/images/pluscursor.png)bin688 -> 688 bytes
-rw-r--r--src/widgets/mac/images/spincursor.png (renamed from src/gui/mac/images/spincursor.png)bin748 -> 748 bytes
-rw-r--r--src/widgets/mac/images/waitcursor.png (renamed from src/gui/mac/images/waitcursor.png)bin724 -> 724 bytes
-rw-r--r--src/widgets/mac/macresources.qrc (renamed from src/gui/mac/macresources.qrc)0
-rw-r--r--src/widgets/mac/qt_menu.nib/classes.nib (renamed from src/gui/mac/qt_menu.nib/classes.nib)0
-rw-r--r--src/widgets/mac/qt_menu.nib/info.nib (renamed from src/gui/mac/qt_menu.nib/info.nib)0
-rw-r--r--src/widgets/mac/qt_menu.nib/keyedobjects.nib (renamed from src/gui/mac/qt_menu.nib/keyedobjects.nib)bin5560 -> 5560 bytes
-rw-r--r--src/widgets/platforms/mac/qapplication_mac.mm (renamed from src/gui/kernel/qapplication_mac.mm)0
-rw-r--r--src/widgets/platforms/mac/qclipboard_mac.cpp (renamed from src/gui/kernel/qclipboard_mac.cpp)0
-rw-r--r--src/widgets/platforms/mac/qcocoaapplication_mac.mm (renamed from src/gui/kernel/qcocoaapplication_mac.mm)0
-rw-r--r--src/widgets/platforms/mac/qcocoaapplication_mac_p.h (renamed from src/gui/kernel/qcocoaapplication_mac_p.h)0
-rw-r--r--src/widgets/platforms/mac/qcocoaapplicationdelegate_mac.mm (renamed from src/gui/kernel/qcocoaapplicationdelegate_mac.mm)0
-rw-r--r--src/widgets/platforms/mac/qcocoaapplicationdelegate_mac_p.h (renamed from src/gui/kernel/qcocoaapplicationdelegate_mac_p.h)0
-rw-r--r--src/widgets/platforms/mac/qcocoaintrospection_mac.mm (renamed from src/gui/kernel/qcocoaintrospection_mac.mm)0
-rw-r--r--src/widgets/platforms/mac/qcocoaintrospection_p.h (renamed from src/gui/kernel/qcocoaintrospection_p.h)0
-rw-r--r--src/widgets/platforms/mac/qcocoamenuloader_mac.mm (renamed from src/gui/kernel/qcocoamenuloader_mac.mm)0
-rw-r--r--src/widgets/platforms/mac/qcocoamenuloader_mac_p.h (renamed from src/gui/kernel/qcocoamenuloader_mac_p.h)0
-rw-r--r--src/widgets/platforms/mac/qcocoapanel_mac.mm (renamed from src/gui/kernel/qcocoapanel_mac.mm)0
-rw-r--r--src/widgets/platforms/mac/qcocoapanel_mac_p.h (renamed from src/gui/kernel/qcocoapanel_mac_p.h)0
-rw-r--r--src/widgets/platforms/mac/qcocoasharedwindowmethods_mac_p.h (renamed from src/gui/kernel/qcocoasharedwindowmethods_mac_p.h)0
-rw-r--r--src/widgets/platforms/mac/qcocoaview_mac.mm (renamed from src/gui/kernel/qcocoaview_mac.mm)0
-rw-r--r--src/widgets/platforms/mac/qcocoaview_mac_p.h (renamed from src/gui/kernel/qcocoaview_mac_p.h)0
-rw-r--r--src/widgets/platforms/mac/qcocoawindow_mac.mm (renamed from src/gui/kernel/qcocoawindow_mac.mm)0
-rw-r--r--src/widgets/platforms/mac/qcocoawindow_mac_p.h (renamed from src/gui/kernel/qcocoawindow_mac_p.h)0
-rw-r--r--src/widgets/platforms/mac/qcocoawindowcustomthemeframe_mac.mm (renamed from src/gui/kernel/qcocoawindowcustomthemeframe_mac.mm)0
-rw-r--r--src/widgets/platforms/mac/qcocoawindowcustomthemeframe_mac_p.h (renamed from src/gui/kernel/qcocoawindowcustomthemeframe_mac_p.h)0
-rw-r--r--src/widgets/platforms/mac/qcocoawindowdelegate_mac.mm (renamed from src/gui/kernel/qcocoawindowdelegate_mac.mm)0
-rw-r--r--src/widgets/platforms/mac/qcocoawindowdelegate_mac_p.h (renamed from src/gui/kernel/qcocoawindowdelegate_mac_p.h)0
-rw-r--r--src/widgets/platforms/mac/qcolormap_mac.cpp (renamed from src/gui/painting/qcolormap_mac.cpp)0
-rw-r--r--src/widgets/platforms/mac/qcursor_mac.mm (renamed from src/gui/kernel/qcursor_mac.mm)0
-rw-r--r--src/widgets/platforms/mac/qdesktopwidget_mac.mm (renamed from src/gui/kernel/qdesktopwidget_mac.mm)0
-rw-r--r--src/widgets/platforms/mac/qdesktopwidget_mac_p.h (renamed from src/gui/kernel/qdesktopwidget_mac_p.h)0
-rw-r--r--src/widgets/platforms/mac/qdnd_mac.mm (renamed from src/gui/kernel/qdnd_mac.mm)0
-rw-r--r--src/widgets/platforms/mac/qeventdispatcher_mac.mm (renamed from src/gui/kernel/qeventdispatcher_mac.mm)0
-rw-r--r--src/widgets/platforms/mac/qeventdispatcher_mac_p.h (renamed from src/gui/kernel/qeventdispatcher_mac_p.h)0
-rw-r--r--src/widgets/platforms/mac/qfont_mac.cpp (renamed from src/gui/text/qfont_mac.cpp)0
-rw-r--r--src/widgets/platforms/mac/qfontdatabase_mac.cpp (renamed from src/gui/text/qfontdatabase_mac.cpp)0
-rw-r--r--src/widgets/platforms/mac/qfontengine_coretext.mm (renamed from src/gui/text/qfontengine_coretext.mm)0
-rw-r--r--src/widgets/platforms/mac/qfontengine_coretext_p.h (renamed from src/gui/text/qfontengine_coretext_p.h)0
-rw-r--r--src/widgets/platforms/mac/qfontengine_mac.mm (renamed from src/gui/text/qfontengine_mac.mm)0
-rw-r--r--src/widgets/platforms/mac/qfontengine_mac_p.h (renamed from src/gui/text/qfontengine_mac_p.h)0
-rw-r--r--src/widgets/platforms/mac/qkeymapper_mac.cpp (renamed from src/gui/kernel/qkeymapper_mac.cpp)0
-rw-r--r--src/widgets/platforms/mac/qmacdefines_mac.h (renamed from src/gui/kernel/qmacdefines_mac.h)0
-rw-r--r--src/widgets/platforms/mac/qmacgesturerecognizer_mac.mm (renamed from src/gui/kernel/qmacgesturerecognizer_mac.mm)0
-rw-r--r--src/widgets/platforms/mac/qmacgesturerecognizer_mac_p.h (renamed from src/gui/kernel/qmacgesturerecognizer_mac_p.h)0
-rw-r--r--src/widgets/platforms/mac/qmime_mac.cpp (renamed from src/gui/kernel/qmime_mac.cpp)0
-rw-r--r--src/widgets/platforms/mac/qmultitouch_mac.mm (renamed from src/gui/kernel/qmultitouch_mac.mm)0
-rw-r--r--src/widgets/platforms/mac/qmultitouch_mac_p.h (renamed from src/gui/kernel/qmultitouch_mac_p.h)0
-rw-r--r--src/widgets/platforms/mac/qnsframeview_mac_p.h (renamed from src/gui/kernel/qnsframeview_mac_p.h)0
-rw-r--r--src/widgets/platforms/mac/qnsthemeframe_mac_p.h (renamed from src/gui/kernel/qnsthemeframe_mac_p.h)0
-rw-r--r--src/widgets/platforms/mac/qnstitledframe_mac_p.h (renamed from src/gui/kernel/qnstitledframe_mac_p.h)0
-rw-r--r--src/widgets/platforms/mac/qpaintdevice_mac.cpp (renamed from src/gui/painting/qpaintdevice_mac.cpp)0
-rw-r--r--src/widgets/platforms/mac/qpaintengine_mac.cpp (renamed from src/gui/painting/qpaintengine_mac.cpp)0
-rw-r--r--src/widgets/platforms/mac/qpaintengine_mac_p.h (renamed from src/gui/painting/qpaintengine_mac_p.h)0
-rw-r--r--src/widgets/platforms/mac/qpixmap_mac.cpp (renamed from src/gui/image/qpixmap_mac.cpp)0
-rw-r--r--src/widgets/platforms/mac/qpixmap_mac_p.h (renamed from src/gui/image/qpixmap_mac_p.h)0
-rw-r--r--src/widgets/platforms/mac/qprintengine_mac.mm (renamed from src/gui/painting/qprintengine_mac.mm)0
-rw-r--r--src/widgets/platforms/mac/qprintengine_mac_p.h (renamed from src/gui/painting/qprintengine_mac_p.h)0
-rw-r--r--src/widgets/platforms/mac/qprinterinfo_mac.cpp (renamed from src/gui/painting/qprinterinfo_mac.cpp)0
-rw-r--r--src/widgets/platforms/mac/qrawfont_mac.cpp (renamed from src/gui/text/qrawfont_mac.cpp)0
-rw-r--r--src/widgets/platforms/mac/qregion_mac.cpp (renamed from src/gui/painting/qregion_mac.cpp)0
-rw-r--r--src/widgets/platforms/mac/qsound_mac.mm (renamed from src/gui/kernel/qsound_mac.mm)0
-rw-r--r--src/widgets/platforms/mac/qt_cocoa_helpers_mac.mm (renamed from src/gui/kernel/qt_cocoa_helpers_mac.mm)0
-rw-r--r--src/widgets/platforms/mac/qt_cocoa_helpers_mac_p.h (renamed from src/gui/kernel/qt_cocoa_helpers_mac_p.h)0
-rw-r--r--src/widgets/platforms/mac/qt_mac.cpp (renamed from src/gui/kernel/qt_mac.cpp)0
-rw-r--r--src/widgets/platforms/mac/qt_mac_p.h (renamed from src/gui/kernel/qt_mac_p.h)0
-rw-r--r--src/widgets/platforms/mac/qtextengine_mac.cpp (renamed from src/gui/text/qtextengine_mac.cpp)0
-rw-r--r--src/widgets/platforms/mac/qwidget_mac.mm (renamed from src/gui/kernel/qwidget_mac.mm)0
-rw-r--r--src/widgets/platforms/s60/qapplication_s60.cpp (renamed from src/gui/kernel/qapplication_s60.cpp)0
-rw-r--r--src/widgets/platforms/s60/qclipboard_s60.cpp (renamed from src/gui/kernel/qclipboard_s60.cpp)0
-rw-r--r--src/widgets/platforms/s60/qcolormap_s60.cpp (renamed from src/gui/painting/qcolormap_s60.cpp)0
-rw-r--r--src/widgets/platforms/s60/qcursor_s60.cpp (renamed from src/gui/kernel/qcursor_s60.cpp)0
-rw-r--r--src/widgets/platforms/s60/qdesktopwidget_s60.cpp (renamed from src/gui/kernel/qdesktopwidget_s60.cpp)0
-rw-r--r--src/widgets/platforms/s60/qdnd_s60.cpp (renamed from src/gui/kernel/qdnd_s60.cpp)0
-rw-r--r--src/widgets/platforms/s60/qeventdispatcher_s60.cpp (renamed from src/gui/kernel/qeventdispatcher_s60.cpp)0
-rw-r--r--src/widgets/platforms/s60/qeventdispatcher_s60_p.h (renamed from src/gui/kernel/qeventdispatcher_s60_p.h)0
-rw-r--r--src/widgets/platforms/s60/qfont_s60.cpp (renamed from src/gui/text/qfont_s60.cpp)0
-rw-r--r--src/widgets/platforms/s60/qfontdatabase_s60.cpp (renamed from src/gui/text/qfontdatabase_s60.cpp)0
-rw-r--r--src/widgets/platforms/s60/qfontengine_s60.cpp (renamed from src/gui/text/qfontengine_s60.cpp)0
-rw-r--r--src/widgets/platforms/s60/qfontengine_s60_p.h (renamed from src/gui/text/qfontengine_s60_p.h)0
-rw-r--r--src/widgets/platforms/s60/qkeymapper_s60.cpp (renamed from src/gui/kernel/qkeymapper_s60.cpp)0
-rw-r--r--src/widgets/platforms/s60/qpaintengine_s60.cpp (renamed from src/gui/painting/qpaintengine_s60.cpp)0
-rw-r--r--src/widgets/platforms/s60/qpaintengine_s60_p.h (renamed from src/gui/painting/qpaintengine_s60_p.h)0
-rw-r--r--src/widgets/platforms/s60/qpixmap_s60.cpp (renamed from src/gui/image/qpixmap_s60.cpp)0
-rw-r--r--src/widgets/platforms/s60/qpixmap_s60_p.h (renamed from src/gui/image/qpixmap_s60_p.h)0
-rw-r--r--src/widgets/platforms/s60/qregion_s60.cpp (renamed from src/gui/painting/qregion_s60.cpp)0
-rw-r--r--src/widgets/platforms/s60/qsoftkeymanager_s60.cpp (renamed from src/gui/kernel/qsoftkeymanager_s60.cpp)0
-rw-r--r--src/widgets/platforms/s60/qsoftkeymanager_s60_p.h (renamed from src/gui/kernel/qsoftkeymanager_s60_p.h)0
-rw-r--r--src/widgets/platforms/s60/qsound_s60.cpp (renamed from src/gui/kernel/qsound_s60.cpp)0
-rw-r--r--src/widgets/platforms/s60/qt_s60_p.h (renamed from src/gui/kernel/qt_s60_p.h)0
-rw-r--r--src/widgets/platforms/s60/qwidget_s60.cpp (renamed from src/gui/kernel/qwidget_s60.cpp)0
-rw-r--r--src/widgets/platforms/win/qapplication_win.cpp (renamed from src/gui/kernel/qapplication_win.cpp)0
-rw-r--r--src/widgets/platforms/win/qclipboard_win.cpp (renamed from src/gui/kernel/qclipboard_win.cpp)0
-rw-r--r--src/widgets/platforms/win/qcolormap_win.cpp (renamed from src/gui/painting/qcolormap_win.cpp)0
-rw-r--r--src/widgets/platforms/win/qcursor_win.cpp (renamed from src/gui/kernel/qcursor_win.cpp)0
-rw-r--r--src/widgets/platforms/win/qdesktopwidget_win.cpp (renamed from src/gui/kernel/qdesktopwidget_win.cpp)0
-rw-r--r--src/widgets/platforms/win/qdnd_win.cpp (renamed from src/gui/kernel/qdnd_win.cpp)0
-rw-r--r--src/widgets/platforms/win/qfont_win.cpp (renamed from src/gui/text/qfont_win.cpp)0
-rw-r--r--src/widgets/platforms/win/qfontdatabase_win.cpp (renamed from src/gui/text/qfontdatabase_win.cpp)0
-rw-r--r--src/widgets/platforms/win/qfontengine_win.cpp (renamed from src/gui/text/qfontengine_win.cpp)0
-rw-r--r--src/widgets/platforms/win/qfontengine_win_p.h (renamed from src/gui/text/qfontengine_win_p.h)0
-rw-r--r--src/widgets/platforms/win/qguifunctions_wince.cpp (renamed from src/gui/kernel/qguifunctions_wince.cpp)0
-rw-r--r--src/widgets/platforms/win/qguifunctions_wince.h (renamed from src/gui/kernel/qguifunctions_wince.h)0
-rw-r--r--src/widgets/platforms/win/qkeymapper_win.cpp (renamed from src/gui/kernel/qkeymapper_win.cpp)0
-rw-r--r--src/widgets/platforms/win/qmime_win.cpp (renamed from src/gui/kernel/qmime_win.cpp)0
-rw-r--r--src/widgets/platforms/win/qole_win.cpp (renamed from src/gui/kernel/qole_win.cpp)0
-rw-r--r--src/widgets/platforms/win/qpaintdevice_win.cpp (renamed from src/gui/painting/qpaintdevice_win.cpp)0
-rw-r--r--src/widgets/platforms/win/qpixmap_win.cpp (renamed from src/gui/image/qpixmap_win.cpp)0
-rw-r--r--src/widgets/platforms/win/qprintengine_win.cpp (renamed from src/gui/painting/qprintengine_win.cpp)0
-rw-r--r--src/widgets/platforms/win/qprintengine_win_p.h (renamed from src/gui/painting/qprintengine_win_p.h)0
-rw-r--r--src/widgets/platforms/win/qprinterinfo_win.cpp (renamed from src/gui/painting/qprinterinfo_win.cpp)0
-rw-r--r--src/widgets/platforms/win/qrawfont_win.cpp (renamed from src/gui/text/qrawfont_win.cpp)0
-rw-r--r--src/widgets/platforms/win/qregion_win.cpp (renamed from src/gui/painting/qregion_win.cpp)0
-rw-r--r--src/widgets/platforms/win/qsound_win.cpp (renamed from src/gui/kernel/qsound_win.cpp)0
-rw-r--r--src/widgets/platforms/win/qwidget_win.cpp (renamed from src/gui/kernel/qwidget_win.cpp)0
-rw-r--r--src/widgets/platforms/win/qwidget_wince.cpp (renamed from src/gui/kernel/qwidget_wince.cpp)0
-rw-r--r--src/widgets/platforms/win/qwindowdefs_win.h (renamed from src/gui/kernel/qwindowdefs_win.h)0
-rw-r--r--src/widgets/platforms/win/qwinnativepangesturerecognizer_win.cpp (renamed from src/gui/kernel/qwinnativepangesturerecognizer_win.cpp)0
-rw-r--r--src/widgets/platforms/win/qwinnativepangesturerecognizer_win_p.h (renamed from src/gui/kernel/qwinnativepangesturerecognizer_win_p.h)0
-rw-r--r--src/widgets/platforms/x11/qapplication_x11.cpp (renamed from src/gui/kernel/qapplication_x11.cpp)0
-rw-r--r--src/widgets/platforms/x11/qclipboard_x11.cpp (renamed from src/gui/kernel/qclipboard_x11.cpp)0
-rw-r--r--src/widgets/platforms/x11/qcolormap_x11.cpp (renamed from src/gui/painting/qcolormap_x11.cpp)0
-rw-r--r--src/widgets/platforms/x11/qcursor_x11.cpp (renamed from src/gui/kernel/qcursor_x11.cpp)0
-rw-r--r--src/widgets/platforms/x11/qdesktopwidget_x11.cpp (renamed from src/gui/kernel/qdesktopwidget_x11.cpp)0
-rw-r--r--src/widgets/platforms/x11/qdnd_x11.cpp2072
-rw-r--r--src/widgets/platforms/x11/qeventdispatcher_x11.cpp (renamed from src/gui/kernel/qeventdispatcher_x11.cpp)0
-rw-r--r--src/widgets/platforms/x11/qeventdispatcher_x11_p.h (renamed from src/gui/kernel/qeventdispatcher_x11_p.h)0
-rw-r--r--src/widgets/platforms/x11/qfont_x11.cpp (renamed from src/gui/text/qfont_x11.cpp)0
-rw-r--r--src/widgets/platforms/x11/qfontdatabase_x11.cpp (renamed from src/gui/text/qfontdatabase_x11.cpp)0
-rw-r--r--src/widgets/platforms/x11/qfontengine_x11.cpp (renamed from src/gui/text/qfontengine_x11.cpp)0
-rw-r--r--src/widgets/platforms/x11/qfontengine_x11_p.h (renamed from src/gui/text/qfontengine_x11_p.h)0
-rw-r--r--src/widgets/platforms/x11/qkde.cpp (renamed from src/gui/kernel/qkde.cpp)0
-rw-r--r--src/widgets/platforms/x11/qkde_p.h81
-rw-r--r--src/widgets/platforms/x11/qkeymapper_x11.cpp (renamed from src/gui/kernel/qkeymapper_x11.cpp)0
-rw-r--r--src/widgets/platforms/x11/qkeymapper_x11_p.cpp (renamed from src/gui/kernel/qkeymapper_x11_p.cpp)0
-rw-r--r--src/widgets/platforms/x11/qmotifdnd_x11.cpp (renamed from src/gui/kernel/qmotifdnd_x11.cpp)0
-rw-r--r--src/widgets/platforms/x11/qpaintdevice_x11.cpp84
-rw-r--r--src/widgets/platforms/x11/qpaintengine_x11.cpp2504
-rw-r--r--src/widgets/platforms/x11/qpaintengine_x11_p.h (renamed from src/gui/painting/qpaintengine_x11_p.h)0
-rw-r--r--src/widgets/platforms/x11/qpixmap_x11.cpp (renamed from src/gui/image/qpixmap_x11.cpp)0
-rw-r--r--src/widgets/platforms/x11/qpixmap_x11_p.h (renamed from src/gui/image/qpixmap_x11_p.h)0
-rw-r--r--src/widgets/platforms/x11/qregion_x11.cpp (renamed from src/gui/painting/qregion_x11.cpp)0
-rw-r--r--src/widgets/platforms/x11/qsound_x11.cpp (renamed from src/gui/kernel/qsound_x11.cpp)0
-rw-r--r--src/widgets/platforms/x11/qt_x11_p.h (renamed from src/gui/kernel/qt_x11_p.h)0
-rw-r--r--src/widgets/platforms/x11/qwidget_x11.cpp (renamed from src/gui/kernel/qwidget_x11.cpp)0
-rw-r--r--src/widgets/platforms/x11/qwidgetcreate_x11.cpp (renamed from src/gui/kernel/qwidgetcreate_x11.cpp)0
-rw-r--r--src/widgets/platforms/x11/qx11embed_x11.cpp (renamed from src/gui/kernel/qx11embed_x11.cpp)0
-rw-r--r--src/widgets/platforms/x11/qx11embed_x11.h132
-rw-r--r--src/widgets/platforms/x11/qx11info_x11.cpp (renamed from src/gui/kernel/qx11info_x11.cpp)0
-rw-r--r--src/widgets/platforms/x11/qx11info_x11.h (renamed from src/gui/kernel/qx11info_x11.h)0
-rw-r--r--src/widgets/s60framework/qs60mainapplication.cpp (renamed from src/gui/s60framework/qs60mainapplication.cpp)0
-rw-r--r--src/widgets/s60framework/qs60mainapplication.h (renamed from src/gui/s60framework/qs60mainapplication.h)0
-rw-r--r--src/widgets/s60framework/qs60mainapplication_p.h (renamed from src/gui/s60framework/qs60mainapplication_p.h)0
-rw-r--r--src/widgets/s60framework/qs60mainappui.cpp430
-rw-r--r--src/widgets/s60framework/qs60mainappui.h (renamed from src/gui/s60framework/qs60mainappui.h)0
-rw-r--r--src/widgets/s60framework/qs60maindocument.cpp (renamed from src/gui/s60framework/qs60maindocument.cpp)0
-rw-r--r--src/widgets/s60framework/qs60maindocument.h (renamed from src/gui/s60framework/qs60maindocument.h)0
-rw-r--r--src/widgets/s60framework/s60framework.pri (renamed from src/gui/s60framework/s60framework.pri)0
-rw-r--r--src/widgets/s60framework/s60main.rss (renamed from src/gui/s60framework/s60main.rss)0
-rw-r--r--src/widgets/statemachine/qbasickeyeventtransition.cpp (renamed from src/gui/statemachine/qbasickeyeventtransition.cpp)0
-rw-r--r--src/widgets/statemachine/qbasickeyeventtransition_p.h (renamed from src/gui/statemachine/qbasickeyeventtransition_p.h)0
-rw-r--r--src/widgets/statemachine/qbasicmouseeventtransition.cpp (renamed from src/gui/statemachine/qbasicmouseeventtransition.cpp)0
-rw-r--r--src/widgets/statemachine/qbasicmouseeventtransition_p.h (renamed from src/gui/statemachine/qbasicmouseeventtransition_p.h)0
-rw-r--r--src/widgets/statemachine/qguistatemachine.cpp500
-rw-r--r--src/widgets/statemachine/qkeyeventtransition.cpp (renamed from src/gui/statemachine/qkeyeventtransition.cpp)0
-rw-r--r--src/widgets/statemachine/qkeyeventtransition.h (renamed from src/gui/statemachine/qkeyeventtransition.h)0
-rw-r--r--src/widgets/statemachine/qmouseeventtransition.cpp (renamed from src/gui/statemachine/qmouseeventtransition.cpp)0
-rw-r--r--src/widgets/statemachine/qmouseeventtransition.h (renamed from src/gui/statemachine/qmouseeventtransition.h)0
-rw-r--r--src/widgets/statemachine/statemachine.pri (renamed from src/gui/statemachine/statemachine.pri)0
-rw-r--r--src/widgets/styles/images/cdr-128.png (renamed from src/gui/styles/images/cdr-128.png)bin16418 -> 16418 bytes
-rw-r--r--src/widgets/styles/images/cdr-16.png (renamed from src/gui/styles/images/cdr-16.png)bin845 -> 845 bytes
-rw-r--r--src/widgets/styles/images/cdr-32.png (renamed from src/gui/styles/images/cdr-32.png)bin2016 -> 2016 bytes
-rw-r--r--src/widgets/styles/images/closedock-16.png (renamed from src/gui/styles/images/closedock-16.png)bin516 -> 516 bytes
-rw-r--r--src/widgets/styles/images/closedock-down-16.png (renamed from src/gui/styles/images/closedock-down-16.png)bin578 -> 578 bytes
-rw-r--r--src/widgets/styles/images/computer-16.png (renamed from src/gui/styles/images/computer-16.png)bin782 -> 782 bytes
-rw-r--r--src/widgets/styles/images/computer-32.png (renamed from src/gui/styles/images/computer-32.png)bin1807 -> 1807 bytes
-rw-r--r--src/widgets/styles/images/defaults60theme.blob (renamed from src/gui/styles/images/defaults60theme.blob)bin74127 -> 74127 bytes
-rw-r--r--src/widgets/styles/images/desktop-16.png (renamed from src/gui/styles/images/desktop-16.png)bin773 -> 773 bytes
-rw-r--r--src/widgets/styles/images/desktop-32.png (renamed from src/gui/styles/images/desktop-32.png)bin1103 -> 1103 bytes
-rw-r--r--src/widgets/styles/images/dirclosed-128.png (renamed from src/gui/styles/images/dirclosed-128.png)bin1386 -> 1386 bytes
-rw-r--r--src/widgets/styles/images/dirclosed-16.png (renamed from src/gui/styles/images/dirclosed-16.png)bin231 -> 231 bytes
-rw-r--r--src/widgets/styles/images/dirclosed-32.png (renamed from src/gui/styles/images/dirclosed-32.png)bin474 -> 474 bytes
-rw-r--r--src/widgets/styles/images/dirlink-128.png (renamed from src/gui/styles/images/dirlink-128.png)bin5155 -> 5155 bytes
-rw-r--r--src/widgets/styles/images/dirlink-16.png (renamed from src/gui/styles/images/dirlink-16.png)bin416 -> 416 bytes
-rw-r--r--src/widgets/styles/images/dirlink-32.png (renamed from src/gui/styles/images/dirlink-32.png)bin1046 -> 1046 bytes
-rw-r--r--src/widgets/styles/images/diropen-128.png (renamed from src/gui/styles/images/diropen-128.png)bin2075 -> 2075 bytes
-rw-r--r--src/widgets/styles/images/diropen-16.png (renamed from src/gui/styles/images/diropen-16.png)bin248 -> 248 bytes
-rw-r--r--src/widgets/styles/images/diropen-32.png (renamed from src/gui/styles/images/diropen-32.png)bin633 -> 633 bytes
-rw-r--r--src/widgets/styles/images/dockdock-16.png (renamed from src/gui/styles/images/dockdock-16.png)bin438 -> 438 bytes
-rw-r--r--src/widgets/styles/images/dockdock-down-16.png (renamed from src/gui/styles/images/dockdock-down-16.png)bin406 -> 406 bytes
-rw-r--r--src/widgets/styles/images/down-128.png (renamed from src/gui/styles/images/down-128.png)bin9550 -> 9550 bytes
-rw-r--r--src/widgets/styles/images/down-16.png (renamed from src/gui/styles/images/down-16.png)bin817 -> 817 bytes
-rw-r--r--src/widgets/styles/images/down-32.png (renamed from src/gui/styles/images/down-32.png)bin1820 -> 1820 bytes
-rw-r--r--src/widgets/styles/images/dvd-128.png (renamed from src/gui/styles/images/dvd-128.png)bin14941 -> 14941 bytes
-rw-r--r--src/widgets/styles/images/dvd-16.png (renamed from src/gui/styles/images/dvd-16.png)bin892 -> 892 bytes
-rw-r--r--src/widgets/styles/images/dvd-32.png (renamed from src/gui/styles/images/dvd-32.png)bin2205 -> 2205 bytes
-rw-r--r--src/widgets/styles/images/file-128.png (renamed from src/gui/styles/images/file-128.png)bin3997 -> 3997 bytes
-rw-r--r--src/widgets/styles/images/file-16.png (renamed from src/gui/styles/images/file-16.png)bin423 -> 423 bytes
-rw-r--r--src/widgets/styles/images/file-32.png (renamed from src/gui/styles/images/file-32.png)bin713 -> 713 bytes
-rw-r--r--src/widgets/styles/images/filecontents-128.png (renamed from src/gui/styles/images/filecontents-128.png)bin8109 -> 8109 bytes
-rw-r--r--src/widgets/styles/images/filecontents-16.png (renamed from src/gui/styles/images/filecontents-16.png)bin766 -> 766 bytes
-rw-r--r--src/widgets/styles/images/filecontents-32.png (renamed from src/gui/styles/images/filecontents-32.png)bin1712 -> 1712 bytes
-rw-r--r--src/widgets/styles/images/fileinfo-128.png (renamed from src/gui/styles/images/fileinfo-128.png)bin12002 -> 12002 bytes
-rw-r--r--src/widgets/styles/images/fileinfo-16.png (renamed from src/gui/styles/images/fileinfo-16.png)bin849 -> 849 bytes
-rw-r--r--src/widgets/styles/images/fileinfo-32.png (renamed from src/gui/styles/images/fileinfo-32.png)bin2010 -> 2010 bytes
-rw-r--r--src/widgets/styles/images/filelink-128.png (renamed from src/gui/styles/images/filelink-128.png)bin5601 -> 5601 bytes
-rw-r--r--src/widgets/styles/images/filelink-16.png (renamed from src/gui/styles/images/filelink-16.png)bin566 -> 566 bytes
-rw-r--r--src/widgets/styles/images/filelink-32.png (renamed from src/gui/styles/images/filelink-32.png)bin1192 -> 1192 bytes
-rw-r--r--src/widgets/styles/images/floppy-128.png (renamed from src/gui/styles/images/floppy-128.png)bin5074 -> 5074 bytes
-rw-r--r--src/widgets/styles/images/floppy-16.png (renamed from src/gui/styles/images/floppy-16.png)bin602 -> 602 bytes
-rw-r--r--src/widgets/styles/images/floppy-32.png (renamed from src/gui/styles/images/floppy-32.png)bin1019 -> 1019 bytes
-rw-r--r--src/widgets/styles/images/fontbitmap-16.png (renamed from src/gui/styles/images/fontbitmap-16.png)bin537 -> 537 bytes
-rw-r--r--src/widgets/styles/images/fonttruetype-16.png (renamed from src/gui/styles/images/fonttruetype-16.png)bin442 -> 442 bytes
-rw-r--r--src/widgets/styles/images/harddrive-128.png (renamed from src/gui/styles/images/harddrive-128.png)bin11250 -> 11250 bytes
-rw-r--r--src/widgets/styles/images/harddrive-16.png (renamed from src/gui/styles/images/harddrive-16.png)bin802 -> 802 bytes
-rw-r--r--src/widgets/styles/images/harddrive-32.png (renamed from src/gui/styles/images/harddrive-32.png)bin1751 -> 1751 bytes
-rw-r--r--src/widgets/styles/images/left-128.png (renamed from src/gui/styles/images/left-128.png)bin9432 -> 9432 bytes
-rw-r--r--src/widgets/styles/images/left-16.png (renamed from src/gui/styles/images/left-16.png)bin826 -> 826 bytes
-rw-r--r--src/widgets/styles/images/left-32.png (renamed from src/gui/styles/images/left-32.png)bin1799 -> 1799 bytes
-rw-r--r--src/widgets/styles/images/media-pause-16.png (renamed from src/gui/styles/images/media-pause-16.png)bin229 -> 229 bytes
-rw-r--r--src/widgets/styles/images/media-pause-32.png (renamed from src/gui/styles/images/media-pause-32.png)bin185 -> 185 bytes
-rw-r--r--src/widgets/styles/images/media-play-16.png (renamed from src/gui/styles/images/media-play-16.png)bin262 -> 262 bytes
-rw-r--r--src/widgets/styles/images/media-play-32.png (renamed from src/gui/styles/images/media-play-32.png)bin413 -> 413 bytes
-rw-r--r--src/widgets/styles/images/media-seek-backward-16.png (renamed from src/gui/styles/images/media-seek-backward-16.png)bin384 -> 384 bytes
-rw-r--r--src/widgets/styles/images/media-seek-backward-32.png (renamed from src/gui/styles/images/media-seek-backward-32.png)bin548 -> 548 bytes
-rw-r--r--src/widgets/styles/images/media-seek-forward-16.png (renamed from src/gui/styles/images/media-seek-forward-16.png)bin370 -> 370 bytes
-rw-r--r--src/widgets/styles/images/media-seek-forward-32.png (renamed from src/gui/styles/images/media-seek-forward-32.png)bin524 -> 524 bytes
-rw-r--r--src/widgets/styles/images/media-skip-backward-16.png (renamed from src/gui/styles/images/media-skip-backward-16.png)bin396 -> 396 bytes
-rw-r--r--src/widgets/styles/images/media-skip-backward-32.png (renamed from src/gui/styles/images/media-skip-backward-32.png)bin570 -> 570 bytes
-rw-r--r--src/widgets/styles/images/media-skip-forward-16.png (renamed from src/gui/styles/images/media-skip-forward-16.png)bin384 -> 384 bytes
-rw-r--r--src/widgets/styles/images/media-skip-forward-32.png (renamed from src/gui/styles/images/media-skip-forward-32.png)bin549 -> 549 bytes
-rw-r--r--src/widgets/styles/images/media-stop-16.png (renamed from src/gui/styles/images/media-stop-16.png)bin166 -> 166 bytes
-rw-r--r--src/widgets/styles/images/media-stop-32.png (renamed from src/gui/styles/images/media-stop-32.png)bin176 -> 176 bytes
-rw-r--r--src/widgets/styles/images/media-volume-16.png (renamed from src/gui/styles/images/media-volume-16.png)bin799 -> 799 bytes
-rw-r--r--src/widgets/styles/images/media-volume-muted-16.png (renamed from src/gui/styles/images/media-volume-muted-16.png)bin668 -> 668 bytes
-rw-r--r--src/widgets/styles/images/networkdrive-128.png (renamed from src/gui/styles/images/networkdrive-128.png)bin18075 -> 18075 bytes
-rw-r--r--src/widgets/styles/images/networkdrive-16.png (renamed from src/gui/styles/images/networkdrive-16.png)bin885 -> 885 bytes
-rw-r--r--src/widgets/styles/images/networkdrive-32.png (renamed from src/gui/styles/images/networkdrive-32.png)bin2245 -> 2245 bytes
-rw-r--r--src/widgets/styles/images/newdirectory-128.png (renamed from src/gui/styles/images/newdirectory-128.png)bin7503 -> 7503 bytes
-rw-r--r--src/widgets/styles/images/newdirectory-16.png (renamed from src/gui/styles/images/newdirectory-16.png)bin870 -> 870 bytes
-rw-r--r--src/widgets/styles/images/newdirectory-32.png (renamed from src/gui/styles/images/newdirectory-32.png)bin1590 -> 1590 bytes
-rw-r--r--src/widgets/styles/images/parentdir-128.png (renamed from src/gui/styles/images/parentdir-128.png)bin8093 -> 8093 bytes
-rw-r--r--src/widgets/styles/images/parentdir-16.png (renamed from src/gui/styles/images/parentdir-16.png)bin938 -> 938 bytes
-rw-r--r--src/widgets/styles/images/parentdir-32.png (renamed from src/gui/styles/images/parentdir-32.png)bin1603 -> 1603 bytes
-rw-r--r--src/widgets/styles/images/refresh-24.png (renamed from src/gui/styles/images/refresh-24.png)bin1654 -> 1654 bytes
-rw-r--r--src/widgets/styles/images/refresh-32.png (renamed from src/gui/styles/images/refresh-32.png)bin2431 -> 2431 bytes
-rw-r--r--src/widgets/styles/images/right-128.png (renamed from src/gui/styles/images/right-128.png)bin9367 -> 9367 bytes
-rw-r--r--src/widgets/styles/images/right-16.png (renamed from src/gui/styles/images/right-16.png)bin811 -> 811 bytes
-rw-r--r--src/widgets/styles/images/right-32.png (renamed from src/gui/styles/images/right-32.png)bin1804 -> 1804 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-apply-128.png (renamed from src/gui/styles/images/standardbutton-apply-128.png)bin5395 -> 5395 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-apply-16.png (renamed from src/gui/styles/images/standardbutton-apply-16.png)bin611 -> 611 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-apply-32.png (renamed from src/gui/styles/images/standardbutton-apply-32.png)bin1279 -> 1279 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-cancel-128.png (renamed from src/gui/styles/images/standardbutton-cancel-128.png)bin7039 -> 7039 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-cancel-16.png (renamed from src/gui/styles/images/standardbutton-cancel-16.png)bin689 -> 689 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-cancel-32.png (renamed from src/gui/styles/images/standardbutton-cancel-32.png)bin1573 -> 1573 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-clear-128.png (renamed from src/gui/styles/images/standardbutton-clear-128.png)bin3094 -> 3094 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-clear-16.png (renamed from src/gui/styles/images/standardbutton-clear-16.png)bin456 -> 456 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-clear-32.png (renamed from src/gui/styles/images/standardbutton-clear-32.png)bin866 -> 866 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-close-128.png (renamed from src/gui/styles/images/standardbutton-close-128.png)bin4512 -> 4512 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-close-16.png (renamed from src/gui/styles/images/standardbutton-close-16.png)bin366 -> 366 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-close-32.png (renamed from src/gui/styles/images/standardbutton-close-32.png)bin780 -> 780 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-closetab-16.png (renamed from src/gui/styles/images/standardbutton-closetab-16.png)bin406 -> 406 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-closetab-down-16.png (renamed from src/gui/styles/images/standardbutton-closetab-down-16.png)bin481 -> 481 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-closetab-hover-16.png (renamed from src/gui/styles/images/standardbutton-closetab-hover-16.png)bin570 -> 570 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-delete-128.png (renamed from src/gui/styles/images/standardbutton-delete-128.png)bin5414 -> 5414 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-delete-16.png (renamed from src/gui/styles/images/standardbutton-delete-16.png)bin722 -> 722 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-delete-32.png (renamed from src/gui/styles/images/standardbutton-delete-32.png)bin1541 -> 1541 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-help-128.png (renamed from src/gui/styles/images/standardbutton-help-128.png)bin10765 -> 10765 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-help-16.png (renamed from src/gui/styles/images/standardbutton-help-16.png)bin840 -> 840 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-help-32.png (renamed from src/gui/styles/images/standardbutton-help-32.png)bin2066 -> 2066 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-no-128.png (renamed from src/gui/styles/images/standardbutton-no-128.png)bin6520 -> 6520 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-no-16.png (renamed from src/gui/styles/images/standardbutton-no-16.png)bin701 -> 701 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-no-32.png (renamed from src/gui/styles/images/standardbutton-no-32.png)bin1445 -> 1445 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-ok-128.png (renamed from src/gui/styles/images/standardbutton-ok-128.png)bin4232 -> 4232 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-ok-16.png (renamed from src/gui/styles/images/standardbutton-ok-16.png)bin584 -> 584 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-ok-32.png (renamed from src/gui/styles/images/standardbutton-ok-32.png)bin1246 -> 1246 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-open-128.png (renamed from src/gui/styles/images/standardbutton-open-128.png)bin5415 -> 5415 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-open-16.png (renamed from src/gui/styles/images/standardbutton-open-16.png)bin629 -> 629 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-open-32.png (renamed from src/gui/styles/images/standardbutton-open-32.png)bin1154 -> 1154 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-save-128.png (renamed from src/gui/styles/images/standardbutton-save-128.png)bin4398 -> 4398 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-save-16.png (renamed from src/gui/styles/images/standardbutton-save-16.png)bin583 -> 583 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-save-32.png (renamed from src/gui/styles/images/standardbutton-save-32.png)bin1092 -> 1092 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-yes-128.png (renamed from src/gui/styles/images/standardbutton-yes-128.png)bin6554 -> 6554 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-yes-16.png (renamed from src/gui/styles/images/standardbutton-yes-16.png)bin687 -> 687 bytes
-rw-r--r--src/widgets/styles/images/standardbutton-yes-32.png (renamed from src/gui/styles/images/standardbutton-yes-32.png)bin1504 -> 1504 bytes
-rw-r--r--src/widgets/styles/images/stop-24.png (renamed from src/gui/styles/images/stop-24.png)bin1267 -> 1267 bytes
-rw-r--r--src/widgets/styles/images/stop-32.png (renamed from src/gui/styles/images/stop-32.png)bin1878 -> 1878 bytes
-rw-r--r--src/widgets/styles/images/trash-128.png (renamed from src/gui/styles/images/trash-128.png)bin3296 -> 3296 bytes
-rw-r--r--src/widgets/styles/images/trash-16.png (renamed from src/gui/styles/images/trash-16.png)bin419 -> 419 bytes
-rw-r--r--src/widgets/styles/images/trash-32.png (renamed from src/gui/styles/images/trash-32.png)bin883 -> 883 bytes
-rw-r--r--src/widgets/styles/images/up-128.png (renamed from src/gui/styles/images/up-128.png)bin9363 -> 9363 bytes
-rw-r--r--src/widgets/styles/images/up-16.png (renamed from src/gui/styles/images/up-16.png)bin814 -> 814 bytes
-rw-r--r--src/widgets/styles/images/up-32.png (renamed from src/gui/styles/images/up-32.png)bin1798 -> 1798 bytes
-rw-r--r--src/widgets/styles/images/viewdetailed-128.png (renamed from src/gui/styles/images/viewdetailed-128.png)bin4743 -> 4743 bytes
-rw-r--r--src/widgets/styles/images/viewdetailed-16.png (renamed from src/gui/styles/images/viewdetailed-16.png)bin499 -> 499 bytes
-rw-r--r--src/widgets/styles/images/viewdetailed-32.png (renamed from src/gui/styles/images/viewdetailed-32.png)bin1092 -> 1092 bytes
-rw-r--r--src/widgets/styles/images/viewlist-128.png (renamed from src/gui/styles/images/viewlist-128.png)bin4069 -> 4069 bytes
-rw-r--r--src/widgets/styles/images/viewlist-16.png (renamed from src/gui/styles/images/viewlist-16.png)bin490 -> 490 bytes
-rw-r--r--src/widgets/styles/images/viewlist-32.png (renamed from src/gui/styles/images/viewlist-32.png)bin1006 -> 1006 bytes
-rw-r--r--src/widgets/styles/qcdestyle.cpp (renamed from src/gui/styles/qcdestyle.cpp)0
-rw-r--r--src/widgets/styles/qcdestyle.h82
-rw-r--r--src/widgets/styles/qcleanlooksstyle.cpp (renamed from src/gui/styles/qcleanlooksstyle.cpp)0
-rw-r--r--src/widgets/styles/qcleanlooksstyle.h114
-rw-r--r--src/widgets/styles/qcleanlooksstyle_p.h (renamed from src/gui/styles/qcleanlooksstyle_p.h)0
-rw-r--r--src/widgets/styles/qcommonstyle.cpp (renamed from src/gui/styles/qcommonstyle.cpp)0
-rw-r--r--src/widgets/styles/qcommonstyle.h109
-rw-r--r--src/widgets/styles/qcommonstyle_p.h (renamed from src/gui/styles/qcommonstyle_p.h)0
-rw-r--r--src/widgets/styles/qcommonstylepixmaps_p.h (renamed from src/gui/styles/qcommonstylepixmaps_p.h)0
-rw-r--r--src/widgets/styles/qdrawutil.cpp1053
-rw-r--r--src/widgets/styles/qdrawutil.h175
-rw-r--r--src/widgets/styles/qgtkpainter.cpp716
-rw-r--r--src/widgets/styles/qgtkpainter_p.h129
-rw-r--r--src/widgets/styles/qgtkstyle.cpp3560
-rw-r--r--src/widgets/styles/qgtkstyle.h128
-rw-r--r--src/widgets/styles/qgtkstyle_p.cpp1146
-rw-r--r--src/widgets/styles/qgtkstyle_p.h531
-rw-r--r--src/widgets/styles/qmacstyle.qdoc (renamed from src/gui/styles/qmacstyle.qdoc)0
-rw-r--r--src/widgets/styles/qmacstyle_mac.h148
-rw-r--r--src/widgets/styles/qmacstyle_mac.mm (renamed from src/gui/styles/qmacstyle_mac.mm)0
-rw-r--r--src/widgets/styles/qmacstyle_mac_p.h241
-rw-r--r--src/widgets/styles/qmacstylepixmaps_mac_p.h (renamed from src/gui/styles/qmacstylepixmaps_mac_p.h)0
-rw-r--r--src/widgets/styles/qmotifstyle.cpp2721
-rw-r--r--src/widgets/styles/qmotifstyle.h128
-rw-r--r--src/widgets/styles/qmotifstyle_p.h (renamed from src/gui/styles/qmotifstyle_p.h)0
-rw-r--r--src/widgets/styles/qplastiquestyle.cpp (renamed from src/gui/styles/qplastiquestyle.cpp)0
-rw-r--r--src/widgets/styles/qplastiquestyle.h119
-rw-r--r--src/widgets/styles/qproxystyle.cpp (renamed from src/gui/styles/qproxystyle.cpp)0
-rw-r--r--src/widgets/styles/qproxystyle.h114
-rw-r--r--src/widgets/styles/qproxystyle_p.h (renamed from src/gui/styles/qproxystyle_p.h)0
-rw-r--r--src/widgets/styles/qs60style.cpp (renamed from src/gui/styles/qs60style.cpp)0
-rw-r--r--src/widgets/styles/qs60style.h118
-rw-r--r--src/widgets/styles/qs60style_p.h (renamed from src/gui/styles/qs60style_p.h)0
-rw-r--r--src/widgets/styles/qs60style_s60.cpp (renamed from src/gui/styles/qs60style_s60.cpp)0
-rw-r--r--src/widgets/styles/qs60style_simulated.cpp (renamed from src/gui/styles/qs60style_simulated.cpp)0
-rw-r--r--src/widgets/styles/qs60style_stub.cpp (renamed from src/gui/styles/qs60style_stub.cpp)0
-rw-r--r--src/widgets/styles/qstyle.cpp2459
-rw-r--r--src/widgets/styles/qstyle.h889
-rw-r--r--src/widgets/styles/qstyle.qrc (renamed from src/gui/styles/qstyle.qrc)0
-rw-r--r--src/widgets/styles/qstyle_p.h108
-rw-r--r--src/widgets/styles/qstyle_s60.qrc (renamed from src/gui/styles/qstyle_s60.qrc)0
-rw-r--r--src/widgets/styles/qstyle_s60_simulated.qrc (renamed from src/gui/styles/qstyle_s60_simulated.qrc)0
-rw-r--r--src/widgets/styles/qstyle_wince.qrc (renamed from src/gui/styles/qstyle_wince.qrc)0
-rw-r--r--src/widgets/styles/qstylefactory.cpp (renamed from src/gui/styles/qstylefactory.cpp)0
-rw-r--r--src/widgets/styles/qstylefactory.h (renamed from src/gui/styles/qstylefactory.h)0
-rw-r--r--src/widgets/styles/qstylehelper.cpp (renamed from src/gui/styles/qstylehelper.cpp)0
-rw-r--r--src/widgets/styles/qstylehelper_p.h89
-rw-r--r--src/widgets/styles/qstyleoption.cpp (renamed from src/gui/styles/qstyleoption.cpp)0
-rw-r--r--src/widgets/styles/qstyleoption.h970
-rw-r--r--src/widgets/styles/qstylepainter.cpp (renamed from src/gui/painting/qstylepainter.cpp)0
-rw-r--r--src/widgets/styles/qstylepainter.h112
-rw-r--r--src/widgets/styles/qstyleplugin.cpp (renamed from src/gui/styles/qstyleplugin.cpp)0
-rw-r--r--src/widgets/styles/qstyleplugin.h (renamed from src/gui/styles/qstyleplugin.h)0
-rw-r--r--src/widgets/styles/qstylesheetstyle.cpp5900
-rw-r--r--src/widgets/styles/qstylesheetstyle_default.cpp (renamed from src/gui/styles/qstylesheetstyle_default.cpp)0
-rw-r--r--src/widgets/styles/qstylesheetstyle_p.h204
-rw-r--r--src/widgets/styles/qwindowscestyle.cpp (renamed from src/gui/styles/qwindowscestyle.cpp)0
-rw-r--r--src/widgets/styles/qwindowscestyle.h103
-rw-r--r--src/widgets/styles/qwindowscestyle_p.h (renamed from src/gui/styles/qwindowscestyle_p.h)0
-rw-r--r--src/widgets/styles/qwindowsmobilestyle.cpp (renamed from src/gui/styles/qwindowsmobilestyle.cpp)0
-rw-r--r--src/widgets/styles/qwindowsmobilestyle.h116
-rw-r--r--src/widgets/styles/qwindowsmobilestyle_p.h (renamed from src/gui/styles/qwindowsmobilestyle_p.h)0
-rw-r--r--src/widgets/styles/qwindowsstyle.cpp (renamed from src/gui/styles/qwindowsstyle.cpp)0
-rw-r--r--src/widgets/styles/qwindowsstyle.h111
-rw-r--r--src/widgets/styles/qwindowsstyle_p.h (renamed from src/gui/styles/qwindowsstyle_p.h)0
-rw-r--r--src/widgets/styles/qwindowsvistastyle.cpp (renamed from src/gui/styles/qwindowsvistastyle.cpp)0
-rw-r--r--src/widgets/styles/qwindowsvistastyle.h108
-rw-r--r--src/widgets/styles/qwindowsvistastyle_p.h (renamed from src/gui/styles/qwindowsvistastyle_p.h)0
-rw-r--r--src/widgets/styles/qwindowsxpstyle.cpp (renamed from src/gui/styles/qwindowsxpstyle.cpp)0
-rw-r--r--src/widgets/styles/qwindowsxpstyle.h107
-rw-r--r--src/widgets/styles/qwindowsxpstyle_p.h (renamed from src/gui/styles/qwindowsxpstyle_p.h)0
-rw-r--r--src/widgets/styles/styles.pri194
-rw-r--r--src/widgets/symbian/images/blank.png (renamed from src/gui/symbian/images/blank.png)bin91 -> 91 bytes
-rw-r--r--src/widgets/symbian/images/busy12.png (renamed from src/gui/symbian/images/busy12.png)bin253 -> 253 bytes
-rw-r--r--src/widgets/symbian/images/busy3.png (renamed from src/gui/symbian/images/busy3.png)bin251 -> 251 bytes
-rw-r--r--src/widgets/symbian/images/busy6.png (renamed from src/gui/symbian/images/busy6.png)bin253 -> 253 bytes
-rw-r--r--src/widgets/symbian/images/busy9.png (renamed from src/gui/symbian/images/busy9.png)bin255 -> 255 bytes
-rw-r--r--src/widgets/symbian/images/closehand.png (renamed from src/gui/symbian/images/closehand.png)bin190 -> 190 bytes
-rw-r--r--src/widgets/symbian/images/cross.png (renamed from src/gui/symbian/images/cross.png)bin145 -> 145 bytes
-rw-r--r--src/widgets/symbian/images/forbidden.png (renamed from src/gui/symbian/images/forbidden.png)bin256 -> 256 bytes
-rw-r--r--src/widgets/symbian/images/handpoint.png (renamed from src/gui/symbian/images/handpoint.png)bin230 -> 230 bytes
-rw-r--r--src/widgets/symbian/images/ibeam.png (renamed from src/gui/symbian/images/ibeam.png)bin176 -> 176 bytes
-rw-r--r--src/widgets/symbian/images/openhand.png (renamed from src/gui/symbian/images/openhand.png)bin201 -> 201 bytes
-rw-r--r--src/widgets/symbian/images/pointer.png (renamed from src/gui/symbian/images/pointer.png)bin222 -> 222 bytes
-rw-r--r--src/widgets/symbian/images/sizeall.png (renamed from src/gui/symbian/images/sizeall.png)bin188 -> 188 bytes
-rw-r--r--src/widgets/symbian/images/sizebdiag.png (renamed from src/gui/symbian/images/sizebdiag.png)bin192 -> 192 bytes
-rw-r--r--src/widgets/symbian/images/sizefdiag.png (renamed from src/gui/symbian/images/sizefdiag.png)bin197 -> 197 bytes
-rw-r--r--src/widgets/symbian/images/sizehor.png (renamed from src/gui/symbian/images/sizehor.png)bin175 -> 175 bytes
-rw-r--r--src/widgets/symbian/images/sizever.png (renamed from src/gui/symbian/images/sizever.png)bin171 -> 171 bytes
-rw-r--r--src/widgets/symbian/images/splith.png (renamed from src/gui/symbian/images/splith.png)bin206 -> 206 bytes
-rw-r--r--src/widgets/symbian/images/splitv.png (renamed from src/gui/symbian/images/splitv.png)bin205 -> 205 bytes
-rw-r--r--src/widgets/symbian/images/uparrow.png (renamed from src/gui/symbian/images/uparrow.png)bin157 -> 157 bytes
-rw-r--r--src/widgets/symbian/images/wait1.png (renamed from src/gui/symbian/images/wait1.png)bin219 -> 219 bytes
-rw-r--r--src/widgets/symbian/images/wait10.png (renamed from src/gui/symbian/images/wait10.png)bin220 -> 220 bytes
-rw-r--r--src/widgets/symbian/images/wait11.png (renamed from src/gui/symbian/images/wait11.png)bin220 -> 220 bytes
-rw-r--r--src/widgets/symbian/images/wait12.png (renamed from src/gui/symbian/images/wait12.png)bin213 -> 213 bytes
-rw-r--r--src/widgets/symbian/images/wait2.png (renamed from src/gui/symbian/images/wait2.png)bin219 -> 219 bytes
-rw-r--r--src/widgets/symbian/images/wait3.png (renamed from src/gui/symbian/images/wait3.png)bin210 -> 210 bytes
-rw-r--r--src/widgets/symbian/images/wait4.png (renamed from src/gui/symbian/images/wait4.png)bin215 -> 215 bytes
-rw-r--r--src/widgets/symbian/images/wait5.png (renamed from src/gui/symbian/images/wait5.png)bin217 -> 217 bytes
-rw-r--r--src/widgets/symbian/images/wait6.png (renamed from src/gui/symbian/images/wait6.png)bin213 -> 213 bytes
-rw-r--r--src/widgets/symbian/images/wait7.png (renamed from src/gui/symbian/images/wait7.png)bin215 -> 215 bytes
-rw-r--r--src/widgets/symbian/images/wait8.png (renamed from src/gui/symbian/images/wait8.png)bin217 -> 217 bytes
-rw-r--r--src/widgets/symbian/images/wait9.png (renamed from src/gui/symbian/images/wait9.png)bin209 -> 209 bytes
-rw-r--r--src/widgets/symbian/images/whatsthis.png (renamed from src/gui/symbian/images/whatsthis.png)bin254 -> 254 bytes
-rw-r--r--src/widgets/symbian/qsymbianevent.cpp (renamed from src/gui/symbian/qsymbianevent.cpp)0
-rw-r--r--src/widgets/symbian/qsymbianevent.h (renamed from src/gui/symbian/qsymbianevent.h)0
-rw-r--r--src/widgets/symbian/symbianresources.qrc (renamed from src/gui/symbian/symbianresources.qrc)0
-rw-r--r--src/widgets/to_be_moved/qdnd.cpp491
-rw-r--r--src/widgets/to_be_moved/qdnd_p.h336
-rw-r--r--src/widgets/to_be_moved/qdnd_qpa.cpp426
-rw-r--r--src/widgets/to_be_moved/qdrag.cpp (renamed from src/gui/kernel/qdrag.cpp)0
-rw-r--r--src/widgets/to_be_moved/qdrag.h (renamed from src/gui/kernel/qdrag.h)0
-rw-r--r--src/widgets/to_be_moved/qlinecontrol.cpp (renamed from src/gui/widgets/qlinecontrol.cpp)0
-rw-r--r--src/widgets/to_be_moved/qlinecontrol_p.h456
-rw-r--r--src/widgets/to_be_moved/qshortcut.cpp (renamed from src/gui/kernel/qshortcut.cpp)0
-rw-r--r--src/widgets/to_be_moved/qshortcut.h107
-rw-r--r--src/widgets/to_be_moved/qshortcutmap.cpp897
-rw-r--r--src/widgets/to_be_moved/qshortcutmap_p.h (renamed from src/gui/kernel/qshortcutmap_p.h)0
-rw-r--r--src/widgets/to_be_moved/qtextcontrol.cpp3148
-rw-r--r--src/widgets/to_be_moved/qtextcontrol_p.h307
-rw-r--r--src/widgets/to_be_moved/qtextcontrol_p_p.h238
-rw-r--r--src/widgets/to_be_moved/to_be_moved.pri17
-rw-r--r--src/widgets/util/qcompleter.cpp1833
-rw-r--r--src/widgets/util/qcompleter.h (renamed from src/gui/util/qcompleter.h)0
-rw-r--r--src/widgets/util/qcompleter_p.h264
-rw-r--r--src/widgets/util/qflickgesture.cpp (renamed from src/gui/util/qflickgesture.cpp)0
-rw-r--r--src/widgets/util/qflickgesture_p.h (renamed from src/gui/util/qflickgesture_p.h)0
-rw-r--r--src/widgets/util/qscroller.cpp (renamed from src/gui/util/qscroller.cpp)0
-rw-r--r--src/widgets/util/qscroller.h155
-rw-r--r--src/widgets/util/qscroller_mac.mm (renamed from src/gui/util/qscroller_mac.mm)0
-rw-r--r--src/widgets/util/qscroller_p.h (renamed from src/gui/util/qscroller_p.h)0
-rw-r--r--src/widgets/util/qscrollerproperties.cpp (renamed from src/gui/util/qscrollerproperties.cpp)0
-rw-r--r--src/widgets/util/qscrollerproperties.h (renamed from src/gui/util/qscrollerproperties.h)0
-rw-r--r--src/widgets/util/qscrollerproperties_p.h (renamed from src/gui/util/qscrollerproperties_p.h)0
-rw-r--r--src/widgets/util/qsystemtrayicon.cpp (renamed from src/gui/util/qsystemtrayicon.cpp)0
-rw-r--r--src/widgets/util/qsystemtrayicon.h132
-rw-r--r--src/widgets/util/qsystemtrayicon_mac.mm (renamed from src/gui/util/qsystemtrayicon_mac.mm)0
-rw-r--r--src/widgets/util/qsystemtrayicon_p.h186
-rw-r--r--src/widgets/util/qsystemtrayicon_qpa.cpp (renamed from src/gui/util/qsystemtrayicon_qws.cpp)0
-rw-r--r--src/widgets/util/qsystemtrayicon_win.cpp (renamed from src/gui/util/qsystemtrayicon_win.cpp)0
-rw-r--r--src/widgets/util/qsystemtrayicon_wince.cpp (renamed from src/gui/util/qsystemtrayicon_wince.cpp)0
-rw-r--r--src/widgets/util/qsystemtrayicon_x11.cpp (renamed from src/gui/util/qsystemtrayicon_x11.cpp)0
-rw-r--r--src/widgets/util/qundogroup.cpp (renamed from src/gui/util/qundogroup.cpp)0
-rw-r--r--src/widgets/util/qundogroup.h (renamed from src/gui/util/qundogroup.h)0
-rw-r--r--src/widgets/util/qundostack.cpp (renamed from src/gui/util/qundostack.cpp)0
-rw-r--r--src/widgets/util/qundostack.h (renamed from src/gui/util/qundostack.h)0
-rw-r--r--src/widgets/util/qundostack_p.h114
-rw-r--r--src/widgets/util/qundoview.cpp476
-rw-r--r--src/widgets/util/qundoview.h102
-rw-r--r--src/widgets/util/util.pri69
-rw-r--r--src/widgets/widgets.pro224
-rw-r--r--src/widgets/widgets/qabstractbutton.cpp (renamed from src/gui/widgets/qabstractbutton.cpp)0
-rw-r--r--src/widgets/widgets/qabstractbutton.h180
-rw-r--r--src/widgets/widgets/qabstractbutton_p.h (renamed from src/gui/widgets/qabstractbutton_p.h)0
-rw-r--r--src/widgets/widgets/qabstractscrollarea.cpp (renamed from src/gui/widgets/qabstractscrollarea.cpp)0
-rw-r--r--src/widgets/widgets/qabstractscrollarea.h144
-rw-r--r--src/widgets/widgets/qabstractscrollarea_p.h (renamed from src/gui/widgets/qabstractscrollarea_p.h)0
-rw-r--r--src/widgets/widgets/qabstractslider.cpp (renamed from src/gui/widgets/qabstractslider.cpp)0
-rw-r--r--src/widgets/widgets/qabstractslider.h184
-rw-r--r--src/widgets/widgets/qabstractslider_p.h (renamed from src/gui/widgets/qabstractslider_p.h)0
-rw-r--r--src/widgets/widgets/qabstractspinbox.cpp (renamed from src/gui/widgets/qabstractspinbox.cpp)0
-rw-r--r--src/widgets/widgets/qabstractspinbox.h181
-rw-r--r--src/widgets/widgets/qabstractspinbox_p.h170
-rw-r--r--src/widgets/widgets/qbuttongroup.cpp (renamed from src/gui/widgets/qbuttongroup.cpp)0
-rw-r--r--src/widgets/widgets/qbuttongroup.h (renamed from src/gui/widgets/qbuttongroup.h)0
-rw-r--r--src/widgets/widgets/qcalendartextnavigator_p.h (renamed from src/gui/widgets/qcalendartextnavigator_p.h)0
-rw-r--r--src/widgets/widgets/qcalendarwidget.cpp (renamed from src/gui/widgets/qcalendarwidget.cpp)0
-rw-r--r--src/widgets/widgets/qcalendarwidget.h204
-rw-r--r--src/widgets/widgets/qcheckbox.cpp (renamed from src/gui/widgets/qcheckbox.cpp)0
-rw-r--r--src/widgets/widgets/qcheckbox.h114
-rw-r--r--src/widgets/widgets/qcocoamenu_mac.mm (renamed from src/gui/widgets/qcocoamenu_mac.mm)0
-rw-r--r--src/widgets/widgets/qcocoamenu_mac_p.h (renamed from src/gui/widgets/qcocoamenu_mac_p.h)0
-rw-r--r--src/widgets/widgets/qcocoatoolbardelegate_mac.mm (renamed from src/gui/widgets/qcocoatoolbardelegate_mac.mm)0
-rw-r--r--src/widgets/widgets/qcocoatoolbardelegate_mac_p.h (renamed from src/gui/widgets/qcocoatoolbardelegate_mac_p.h)0
-rw-r--r--src/widgets/widgets/qcombobox.cpp (renamed from src/gui/widgets/qcombobox.cpp)0
-rw-r--r--src/widgets/widgets/qcombobox.h339
-rw-r--r--src/widgets/widgets/qcombobox_p.h421
-rw-r--r--src/widgets/widgets/qcommandlinkbutton.cpp (renamed from src/gui/widgets/qcommandlinkbutton.cpp)0
-rw-r--r--src/widgets/widgets/qcommandlinkbutton.h85
-rw-r--r--src/widgets/widgets/qdatetimeedit.cpp (renamed from src/gui/widgets/qdatetimeedit.cpp)0
-rw-r--r--src/widgets/widgets/qdatetimeedit.h230
-rw-r--r--src/widgets/widgets/qdatetimeedit_p.h185
-rw-r--r--src/widgets/widgets/qdial.cpp (renamed from src/gui/widgets/qdial.cpp)0
-rw-r--r--src/widgets/widgets/qdial.h122
-rw-r--r--src/widgets/widgets/qdialogbuttonbox.cpp1285
-rw-r--r--src/widgets/widgets/qdialogbuttonbox.h168
-rw-r--r--src/widgets/widgets/qdockarealayout.cpp3329
-rw-r--r--src/widgets/widgets/qdockarealayout_p.h308
-rw-r--r--src/widgets/widgets/qdockwidget.cpp (renamed from src/gui/widgets/qdockwidget.cpp)0
-rw-r--r--src/widgets/widgets/qdockwidget.h146
-rw-r--r--src/widgets/widgets/qdockwidget_p.h207
-rw-r--r--src/widgets/widgets/qeffects.cpp (renamed from src/gui/widgets/qeffects.cpp)0
-rw-r--r--src/widgets/widgets/qeffects_p.h (renamed from src/gui/widgets/qeffects_p.h)0
-rw-r--r--src/widgets/widgets/qfocusframe.cpp (renamed from src/gui/widgets/qfocusframe.cpp)0
-rw-r--r--src/widgets/widgets/qfocusframe.h82
-rw-r--r--src/widgets/widgets/qfontcombobox.cpp (renamed from src/gui/widgets/qfontcombobox.cpp)0
-rw-r--r--src/widgets/widgets/qfontcombobox.h112
-rw-r--r--src/widgets/widgets/qframe.cpp (renamed from src/gui/widgets/qframe.cpp)0
-rw-r--r--src/widgets/widgets/qframe.h148
-rw-r--r--src/widgets/widgets/qframe_p.h (renamed from src/gui/widgets/qframe_p.h)0
-rw-r--r--src/widgets/widgets/qgroupbox.cpp (renamed from src/gui/widgets/qgroupbox.cpp)0
-rw-r--r--src/widgets/widgets/qgroupbox.h122
-rw-r--r--src/widgets/widgets/qlabel.cpp (renamed from src/gui/widgets/qlabel.cpp)0
-rw-r--r--src/widgets/widgets/qlabel.h182
-rw-r--r--src/widgets/widgets/qlabel_p.h (renamed from src/gui/widgets/qlabel_p.h)0
-rw-r--r--src/widgets/widgets/qlcdnumber.cpp (renamed from src/gui/widgets/qlcdnumber.cpp)0
-rw-r--r--src/widgets/widgets/qlcdnumber.h144
-rw-r--r--src/widgets/widgets/qlineedit.cpp (renamed from src/gui/widgets/qlineedit.cpp)0
-rw-r--r--src/widgets/widgets/qlineedit.h299
-rw-r--r--src/widgets/widgets/qlineedit_p.cpp292
-rw-r--r--src/widgets/widgets/qlineedit_p.h156
-rw-r--r--src/widgets/widgets/qmaccocoaviewcontainer_mac.h73
-rw-r--r--src/widgets/widgets/qmaccocoaviewcontainer_mac.mm (renamed from src/gui/widgets/qmaccocoaviewcontainer_mac.mm)0
-rw-r--r--src/widgets/widgets/qmacnativewidget_mac.h74
-rw-r--r--src/widgets/widgets/qmacnativewidget_mac.mm (renamed from src/gui/widgets/qmacnativewidget_mac.mm)0
-rw-r--r--src/widgets/widgets/qmainwindow.cpp (renamed from src/gui/widgets/qmainwindow.cpp)0
-rw-r--r--src/widgets/widgets/qmainwindow.h219
-rw-r--r--src/widgets/widgets/qmainwindowlayout.cpp (renamed from src/gui/widgets/qmainwindowlayout.cpp)0
-rw-r--r--src/widgets/widgets/qmainwindowlayout_mac.mm (renamed from src/gui/widgets/qmainwindowlayout_mac.mm)0
-rw-r--r--src/widgets/widgets/qmainwindowlayout_p.h357
-rw-r--r--src/widgets/widgets/qmdiarea.cpp (renamed from src/gui/widgets/qmdiarea.cpp)0
-rw-r--r--src/widgets/widgets/qmdiarea.h179
-rw-r--r--src/widgets/widgets/qmdiarea_p.h285
-rw-r--r--src/widgets/widgets/qmdisubwindow.cpp (renamed from src/gui/widgets/qmdisubwindow.cpp)0
-rw-r--r--src/widgets/widgets/qmdisubwindow.h159
-rw-r--r--src/widgets/widgets/qmdisubwindow_p.h (renamed from src/gui/widgets/qmdisubwindow_p.h)0
-rw-r--r--src/widgets/widgets/qmenu.cpp (renamed from src/gui/widgets/qmenu.cpp)0
-rw-r--r--src/widgets/widgets/qmenu.h434
-rw-r--r--src/widgets/widgets/qmenu_mac.mm (renamed from src/gui/widgets/qmenu_mac.mm)0
-rw-r--r--src/widgets/widgets/qmenu_p.h395
-rw-r--r--src/widgets/widgets/qmenu_symbian.cpp (renamed from src/gui/widgets/qmenu_symbian.cpp)0
-rw-r--r--src/widgets/widgets/qmenu_wince.cpp (renamed from src/gui/widgets/qmenu_wince.cpp)0
-rw-r--r--src/widgets/widgets/qmenu_wince.rc (renamed from src/gui/widgets/qmenu_wince.rc)0
-rw-r--r--src/widgets/widgets/qmenu_wince_resource_p.h (renamed from src/gui/widgets/qmenu_wince_resource_p.h)0
-rw-r--r--src/widgets/widgets/qmenubar.cpp (renamed from src/gui/widgets/qmenubar.cpp)0
-rw-r--r--src/widgets/widgets/qmenubar.h367
-rw-r--r--src/widgets/widgets/qmenubar_p.h283
-rw-r--r--src/widgets/widgets/qmenudata.cpp (renamed from src/gui/widgets/qmenudata.cpp)0
-rw-r--r--src/widgets/widgets/qmenudata.h80
-rw-r--r--src/widgets/widgets/qplaintextedit.cpp (renamed from src/gui/widgets/qplaintextedit.cpp)0
-rw-r--r--src/widgets/widgets/qplaintextedit.h329
-rw-r--r--src/widgets/widgets/qplaintextedit_p.h187
-rw-r--r--src/widgets/widgets/qprintpreviewwidget.cpp844
-rw-r--r--src/widgets/widgets/qprintpreviewwidget.h127
-rw-r--r--src/widgets/widgets/qprogressbar.cpp (renamed from src/gui/widgets/qprogressbar.cpp)0
-rw-r--r--src/widgets/widgets/qprogressbar.h132
-rw-r--r--src/widgets/widgets/qpushbutton.cpp (renamed from src/gui/widgets/qpushbutton.cpp)0
-rw-r--r--src/widgets/widgets/qpushbutton.h127
-rw-r--r--src/widgets/widgets/qpushbutton_p.h (renamed from src/gui/widgets/qpushbutton_p.h)0
-rw-r--r--src/widgets/widgets/qradiobutton.cpp (renamed from src/gui/widgets/qradiobutton.cpp)0
-rw-r--r--src/widgets/widgets/qradiobutton.h89
-rw-r--r--src/widgets/widgets/qrubberband.cpp (renamed from src/gui/widgets/qrubberband.cpp)0
-rw-r--r--src/widgets/widgets/qrubberband.h104
-rw-r--r--src/widgets/widgets/qscrollarea.cpp (renamed from src/gui/widgets/qscrollarea.cpp)0
-rw-r--r--src/widgets/widgets/qscrollarea.h101
-rw-r--r--src/widgets/widgets/qscrollarea_p.h81
-rw-r--r--src/widgets/widgets/qscrollbar.cpp (renamed from src/gui/widgets/qscrollbar.cpp)0
-rw-r--r--src/widgets/widgets/qscrollbar.h104
-rw-r--r--src/widgets/widgets/qsizegrip.cpp570
-rw-r--r--src/widgets/widgets/qsizegrip.h95
-rw-r--r--src/widgets/widgets/qslider.cpp (renamed from src/gui/widgets/qslider.cpp)0
-rw-r--r--src/widgets/widgets/qslider.h134
-rw-r--r--src/widgets/widgets/qspinbox.cpp (renamed from src/gui/widgets/qspinbox.cpp)0
-rw-r--r--src/widgets/widgets/qspinbox.h188
-rw-r--r--src/widgets/widgets/qsplashscreen.cpp (renamed from src/gui/widgets/qsplashscreen.cpp)0
-rw-r--r--src/widgets/widgets/qsplashscreen.h99
-rw-r--r--src/widgets/widgets/qsplitter.cpp (renamed from src/gui/widgets/qsplitter.cpp)0
-rw-r--r--src/widgets/widgets/qsplitter.h192
-rw-r--r--src/widgets/widgets/qsplitter_p.h (renamed from src/gui/widgets/qsplitter_p.h)0
-rw-r--r--src/widgets/widgets/qstackedwidget.cpp (renamed from src/gui/widgets/qstackedwidget.cpp)0
-rw-r--r--src/widgets/widgets/qstackedwidget.h100
-rw-r--r--src/widgets/widgets/qstatusbar.cpp (renamed from src/gui/widgets/qstatusbar.cpp)0
-rw-r--r--src/widgets/widgets/qstatusbar.h116
-rw-r--r--src/widgets/widgets/qtabbar.cpp (renamed from src/gui/widgets/qtabbar.cpp)0
-rw-r--r--src/widgets/widgets/qtabbar.h226
-rw-r--r--src/widgets/widgets/qtabbar_p.h (renamed from src/gui/widgets/qtabbar_p.h)0
-rw-r--r--src/widgets/widgets/qtabwidget.cpp (renamed from src/gui/widgets/qtabwidget.cpp)0
-rw-r--r--src/widgets/widgets/qtabwidget.h253
-rw-r--r--src/widgets/widgets/qtextbrowser.cpp (renamed from src/gui/widgets/qtextbrowser.cpp)0
-rw-r--r--src/widgets/widgets/qtextbrowser.h140
-rw-r--r--src/widgets/widgets/qtextedit.cpp (renamed from src/gui/widgets/qtextedit.cpp)0
-rw-r--r--src/widgets/widgets/qtextedit.h431
-rw-r--r--src/widgets/widgets/qtextedit_p.h141
-rw-r--r--src/widgets/widgets/qtoolbar.cpp (renamed from src/gui/widgets/qtoolbar.cpp)0
-rw-r--r--src/widgets/widgets/qtoolbar.h188
-rw-r--r--src/widgets/widgets/qtoolbar_p.h135
-rw-r--r--src/widgets/widgets/qtoolbararealayout.cpp (renamed from src/gui/widgets/qtoolbararealayout.cpp)0
-rw-r--r--src/widgets/widgets/qtoolbararealayout_p.h (renamed from src/gui/widgets/qtoolbararealayout_p.h)0
-rw-r--r--src/widgets/widgets/qtoolbarextension.cpp (renamed from src/gui/widgets/qtoolbarextension.cpp)0
-rw-r--r--src/widgets/widgets/qtoolbarextension_p.h80
-rw-r--r--src/widgets/widgets/qtoolbarlayout.cpp (renamed from src/gui/widgets/qtoolbarlayout.cpp)0
-rw-r--r--src/widgets/widgets/qtoolbarlayout_p.h134
-rw-r--r--src/widgets/widgets/qtoolbarseparator.cpp (renamed from src/gui/widgets/qtoolbarseparator.cpp)0
-rw-r--r--src/widgets/widgets/qtoolbarseparator_p.h88
-rw-r--r--src/widgets/widgets/qtoolbox.cpp (renamed from src/gui/widgets/qtoolbox.cpp)0
-rw-r--r--src/widgets/widgets/qtoolbox.h148
-rw-r--r--src/widgets/widgets/qtoolbutton.cpp (renamed from src/gui/widgets/qtoolbutton.cpp)0
-rw-r--r--src/widgets/widgets/qtoolbutton.h199
-rw-r--r--src/widgets/widgets/qwidgetanimator.cpp117
-rw-r--r--src/widgets/widgets/qwidgetanimator_p.h (renamed from src/gui/widgets/qwidgetanimator_p.h)0
-rw-r--r--src/widgets/widgets/qwidgetresizehandler.cpp (renamed from src/gui/widgets/qwidgetresizehandler.cpp)0
-rw-r--r--src/widgets/widgets/qwidgetresizehandler_p.h (renamed from src/gui/widgets/qwidgetresizehandler_p.h)0
-rw-r--r--src/widgets/widgets/qworkspace.cpp (renamed from src/gui/widgets/qworkspace.cpp)0
-rw-r--r--src/widgets/widgets/qworkspace.h137
-rw-r--r--src/widgets/widgets/widgets.pri165
-rw-r--r--sync.profile16
-rw-r--r--tests/auto/qmetatype/tst_qmetatype.cpp1
-rw-r--r--tests/auto/qvariant/tst_qvariant.cpp4
-rw-r--r--tools/uilib/abstractformbuilder.cpp38
-rw-r--r--tools/uilib/abstractformbuilder.h2
-rw-r--r--tools/uilib/customwidget.h2
-rw-r--r--tools/uilib/formbuilder.cpp1
-rw-r--r--tools/uilib/formbuilderextra.cpp6
-rw-r--r--tools/uilib/formscriptrunner.cpp2
-rw-r--r--tools/uilib/properties.cpp6
-rw-r--r--tools/uilib/properties_p.h2
-rw-r--r--tools/uilib/resourcebuilder.cpp2
2617 files changed, 172894 insertions, 267546 deletions
diff --git a/bin/fixqt4headers b/bin/fixqt4headers
new file mode 100755
index 0000000000..0bb6add8f8
--- /dev/null
+++ b/bin/fixqt4headers
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+modules=`ls $QTDIR/include`
+
+files=`find * -name '*.h' -or -name '*.cpp' -or -name '*.C'`
+
+echo $files
+
+for module in $modules; do
+# once we change other things, change the line from == "QtWidgets" to != "Qt" to get everything fixed
+ if [ $module == "QtWidgets" ]; then
+ echo $module ":"
+ includes=`ls $QTDIR/include/$module`
+ for i in $includes; do
+# echo " fixing " $i
+ perl -pi -e "s,^#include +<.+/$i>,#include <$module/$i>," $files;
+# perl -pi -e 's,^#include +".+/$i",#include "$module/$i",' $files;
+ done;
+ fi;
+done;
+
+perl -pi -e 's,<QtGui>,<QtWidgets>,' $files
+perl -pi -e 's,<QtGui/QtGui>,<QtWidgets/QtWidgets>,' $files
diff --git a/configure b/configure
index baa94cc1ba..0be1497d1c 100755
--- a/configure
+++ b/configure
@@ -185,8 +185,8 @@ fi
#-------------------------------------------------------------------------------
PLATFORM_X11=no
-PLATFORM_QWS=maybe
-PLATFORM_QPA=maybe
+PLATFORM_QWS=no
+PLATFORM_QPA=yes
BUILD_ON_MAC=no
if [ -d /System/Library/Frameworks/Carbon.framework ]; then
PLATFORM_MAC=maybe
diff --git a/demos/affine/affine.pro b/demos/affine/affine.pro
index a3d6e30ad1..4e4eee8882 100644
--- a/demos/affine/affine.pro
+++ b/demos/affine/affine.pro
@@ -3,7 +3,7 @@ HEADERS += xform.h
contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2) {
DEFINES += QT_OPENGL_SUPPORT
- QT += opengl
+ QT += opengl widgets
}
SHARED_FOLDER = ../shared
diff --git a/demos/books/bookdelegate.cpp b/demos/books/bookdelegate.cpp
index eb5d95b7b5..0965120d85 100644
--- a/demos/books/bookdelegate.cpp
+++ b/demos/books/bookdelegate.cpp
@@ -41,7 +41,7 @@
#include "bookdelegate.h"
-#include <QtGui>
+#include <QtWidgets>
BookDelegate::BookDelegate(QObject *parent)
: QSqlRelationalDelegate(parent), star(QPixmap(":images/star.png"))
diff --git a/demos/books/books.pro b/demos/books/books.pro
index 1588288f3e..39c5e1e257 100644
--- a/demos/books/books.pro
+++ b/demos/books/books.pro
@@ -6,7 +6,7 @@ RESOURCES = books.qrc
SOURCES = bookdelegate.cpp main.cpp bookwindow.cpp
FORMS = bookwindow.ui
-QT += sql
+QT += sql widgets widgets
target.path = $$[QT_INSTALL_DEMOS]/qtbase/books
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro images
diff --git a/demos/books/bookwindow.h b/demos/books/bookwindow.h
index 96545d7e8b..21a8d3995b 100644
--- a/demos/books/bookwindow.h
+++ b/demos/books/bookwindow.h
@@ -42,7 +42,7 @@
#ifndef BOOKWINDOW_H
#define BOOKWINDOW_H
-#include <QtGui>
+#include <QtWidgets>
#include <QtSql>
#include "ui_bookwindow.h"
diff --git a/demos/books/main.cpp b/demos/books/main.cpp
index 3481c9a2a8..6f72efc938 100644
--- a/demos/books/main.cpp
+++ b/demos/books/main.cpp
@@ -41,7 +41,7 @@
#include "bookwindow.h"
-#include <QtGui>
+#include <QtWidgets>
int main(int argc, char * argv[])
{
diff --git a/demos/boxes/boxes.pro b/demos/boxes/boxes.pro
index d599a3a0ac..930e5aa51d 100644
--- a/demos/boxes/boxes.pro
+++ b/demos/boxes/boxes.pro
@@ -27,7 +27,7 @@ SOURCES += 3rdparty/fbm.c \
RESOURCES += boxes.qrc
-QT += opengl
+QT += opengl widgets
# install
target.path = $$[QT_INSTALL_DEMOS]/qtbase/boxes
diff --git a/demos/boxes/glbuffers.h b/demos/boxes/glbuffers.h
index fb6455b28c..1b4823dcf5 100644
--- a/demos/boxes/glbuffers.h
+++ b/demos/boxes/glbuffers.h
@@ -45,7 +45,7 @@
//#include <GL/glew.h>
#include "glextensions.h"
-#include <QtGui>
+#include <QtWidgets>
#include <QtOpenGL>
#define BUFFER_OFFSET(i) ((char*)0 + (i))
diff --git a/demos/boxes/gltrianglemesh.h b/demos/boxes/gltrianglemesh.h
index d0afa35295..68897c849b 100644
--- a/demos/boxes/gltrianglemesh.h
+++ b/demos/boxes/gltrianglemesh.h
@@ -45,7 +45,7 @@
//#include <GL/glew.h>
#include "glextensions.h"
-#include <QtGui>
+#include <QtWidgets>
#include <QtOpenGL>
#include "glbuffers.h"
diff --git a/demos/boxes/main.cpp b/demos/boxes/main.cpp
index 568031ed41..67d112ce6f 100644
--- a/demos/boxes/main.cpp
+++ b/demos/boxes/main.cpp
@@ -44,7 +44,7 @@
#include "scene.h"
-#include <QtGui>
+#include <QtWidgets>
#include <QGLWidget>
class GraphicsView : public QGraphicsView
diff --git a/demos/boxes/qtbox.h b/demos/boxes/qtbox.h
index 71c1304a60..dd44902190 100644
--- a/demos/boxes/qtbox.h
+++ b/demos/boxes/qtbox.h
@@ -42,7 +42,7 @@
#ifndef QTBOX_H
#define QTBOX_H
-#include <QtGui>
+#include <QtWidgets>
#include <QtGui/qvector3d.h>
#include "glbuffers.h"
diff --git a/demos/boxes/roundedbox.h b/demos/boxes/roundedbox.h
index a19f1a3acc..81227342e3 100644
--- a/demos/boxes/roundedbox.h
+++ b/demos/boxes/roundedbox.h
@@ -45,7 +45,7 @@
//#include <GL/glew.h>
#include "glextensions.h"
-#include <QtGui>
+#include <QtWidgets>
#include <QtOpenGL>
#include "gltrianglemesh.h"
diff --git a/demos/boxes/scene.h b/demos/boxes/scene.h
index d1c65268fb..9e105fa052 100644
--- a/demos/boxes/scene.h
+++ b/demos/boxes/scene.h
@@ -45,7 +45,7 @@
//#include <GL/glew.h>
#include "glextensions.h"
-#include <QtGui>
+#include <QtWidgets>
#include <QtOpenGL>
#include "roundedbox.h"
diff --git a/demos/boxes/trackball.h b/demos/boxes/trackball.h
index e43b00d7b3..7eb51b1050 100644
--- a/demos/boxes/trackball.h
+++ b/demos/boxes/trackball.h
@@ -42,7 +42,7 @@
#ifndef TRACKBALL_H
#define TRACKBALL_H
-#include <QtGui>
+#include <QtWidgets>
#include <QtGui/qvector3d.h>
#include <QtGui/qquaternion.h>
diff --git a/demos/chip/chip.cpp b/demos/chip/chip.cpp
index 6f3b529f16..ae716b6904 100644
--- a/demos/chip/chip.cpp
+++ b/demos/chip/chip.cpp
@@ -41,7 +41,7 @@
#include "chip.h"
-#include <QtGui>
+#include <QtWidgets>
Chip::Chip(const QColor &color, int x, int y)
{
diff --git a/demos/chip/chip.h b/demos/chip/chip.h
index dca63b71fc..08dfc585f0 100644
--- a/demos/chip/chip.h
+++ b/demos/chip/chip.h
@@ -43,7 +43,7 @@
#define CHIP_H
#include <QtGui/QColor>
-#include <QtGui/QGraphicsItem>
+#include <QtWidgets/QGraphicsItem>
class Chip : public QGraphicsItem
{
diff --git a/demos/chip/chip.pro b/demos/chip/chip.pro
index 1e1a7de735..9b186b74a8 100644
--- a/demos/chip/chip.pro
+++ b/demos/chip/chip.pro
@@ -4,7 +4,7 @@ HEADERS += mainwindow.h view.h chip.h
SOURCES += main.cpp
SOURCES += mainwindow.cpp view.cpp chip.cpp
-contains(QT_CONFIG, opengl):QT += opengl
+contains(QT_CONFIG, opengl):QT += opengl widgets
build_all:!build_pass {
CONFIG -= build_all
diff --git a/demos/chip/mainwindow.cpp b/demos/chip/mainwindow.cpp
index 825c38823a..8a7e46af06 100644
--- a/demos/chip/mainwindow.cpp
+++ b/demos/chip/mainwindow.cpp
@@ -43,7 +43,7 @@
#include "view.h"
#include "chip.h"
-#include <QtGui>
+#include <QtWidgets>
MainWindow::MainWindow(QWidget *parent)
: QWidget(parent)
diff --git a/demos/chip/mainwindow.h b/demos/chip/mainwindow.h
index 9c8ac03638..c365ad30a3 100644
--- a/demos/chip/mainwindow.h
+++ b/demos/chip/mainwindow.h
@@ -42,7 +42,7 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
-#include <QtGui/qwidget.h>
+#include <QtWidgets/qwidget.h>
QT_FORWARD_DECLARE_CLASS(QGraphicsScene)
QT_FORWARD_DECLARE_CLASS(QGraphicsView)
diff --git a/demos/chip/view.cpp b/demos/chip/view.cpp
index 49d02ecb52..415ab1ecc8 100644
--- a/demos/chip/view.cpp
+++ b/demos/chip/view.cpp
@@ -41,7 +41,7 @@
#include "view.h"
-#include <QtGui>
+#include <QtWidgets>
#ifndef QT_NO_OPENGL
#include <QtOpenGL>
#endif
diff --git a/demos/composition/composition.pro b/demos/composition/composition.pro
index 59b91126b9..00c500ea3b 100644
--- a/demos/composition/composition.pro
+++ b/demos/composition/composition.pro
@@ -8,7 +8,7 @@ include($$SHARED_FOLDER/shared.pri)
RESOURCES += composition.qrc
contains(QT_CONFIG, opengl) {
DEFINES += QT_OPENGL_SUPPORT
- QT += opengl
+ QT += opengl widgets
}
# install
diff --git a/demos/deform/deform.pro b/demos/deform/deform.pro
index 3393b8e83c..d1c8938ad0 100644
--- a/demos/deform/deform.pro
+++ b/demos/deform/deform.pro
@@ -9,7 +9,7 @@ RESOURCES += deform.qrc
contains(QT_CONFIG, opengl) {
DEFINES += QT_OPENGL_SUPPORT
- QT += opengl
+ QT += opengl widgets
}
# install
diff --git a/demos/demos.pro b/demos/demos.pro
index 81968fd61d..69ecca80f4 100644
--- a/demos/demos.pro
+++ b/demos/demos.pro
@@ -96,3 +96,4 @@ demos_sub-attaq.subdir = sub-attaq
demos_pathstroke.depends = demos_shared
}
}
+QT += widgets widgets
diff --git a/demos/embedded/digiflip/digiflip.cpp b/demos/embedded/digiflip/digiflip.cpp
index d756f21776..1a450e8e97 100644
--- a/demos/embedded/digiflip/digiflip.cpp
+++ b/demos/embedded/digiflip/digiflip.cpp
@@ -40,7 +40,7 @@
****************************************************************************/
#include <QtCore>
-#include <QtGui>
+#include <QtWidgets>
class Digits: public QWidget
{
diff --git a/demos/embedded/digiflip/digiflip.pro b/demos/embedded/digiflip/digiflip.pro
index 7fa06fa90a..acc1d56ce3 100644
--- a/demos/embedded/digiflip/digiflip.pro
+++ b/demos/embedded/digiflip/digiflip.pro
@@ -9,3 +9,4 @@ target.path = $$[QT_INSTALL_DEMOS]/qtbase/embedded/digiflip
sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro
sources.path = $$[QT_INSTALL_DEMOS]/qtbase/embedded/digiflip
INSTALLS += target sources
+QT += widgets widgets
diff --git a/demos/embedded/embedded.pro b/demos/embedded/embedded.pro
index e9a448b1e3..becdfe245f 100644
--- a/demos/embedded/embedded.pro
+++ b/demos/embedded/embedded.pro
@@ -10,3 +10,4 @@ sources.path = $$[QT_INSTALL_DEMOS]/qtbase/embedded
INSTALLS += sources
symbian: CONFIG += qt_demo
+QT += widgets widgets
diff --git a/demos/embedded/flickable/flickable.cpp b/demos/embedded/flickable/flickable.cpp
index e2d240d64f..ec7e05b5f9 100644
--- a/demos/embedded/flickable/flickable.cpp
+++ b/demos/embedded/flickable/flickable.cpp
@@ -42,7 +42,7 @@
#include "flickable.h"
#include <QtCore>
-#include <QtGui>
+#include <QtWidgets>
class FlickableTicker: QObject
{
diff --git a/demos/embedded/flickable/flickable.pro b/demos/embedded/flickable/flickable.pro
index 6ee744bc63..32b8213e11 100644
--- a/demos/embedded/flickable/flickable.pro
+++ b/demos/embedded/flickable/flickable.pro
@@ -10,3 +10,4 @@ target.path = $$[QT_INSTALL_DEMOS]/qtbase/embedded/flickable
sources.files = $$SOURCES $$HEADERS $$RESOURCES *.pro
sources.path = $$[QT_INSTALL_DEMOS]/qtbase/embedded/flickable
INSTALLS += target sources
+QT += widgets widgets
diff --git a/demos/embedded/flickable/main.cpp b/demos/embedded/flickable/main.cpp
index 431a99bfa1..f914fb84cc 100644
--- a/demos/embedded/flickable/main.cpp
+++ b/demos/embedded/flickable/main.cpp
@@ -40,7 +40,7 @@
****************************************************************************/
#include <QtCore>
-#include <QtGui>
+#include <QtWidgets>
#include "flickable.h"
diff --git a/demos/embedded/flightinfo/flightinfo.cpp b/demos/embedded/flightinfo/flightinfo.cpp
index 6f7c039973..76ca154019 100644
--- a/demos/embedded/flightinfo/flightinfo.cpp
+++ b/demos/embedded/flightinfo/flightinfo.cpp
@@ -40,7 +40,7 @@
****************************************************************************/
#include <QtCore>
-#include <QtGui>
+#include <QtWidgets>
#include <QtNetwork>
#include "ui_form.h"
diff --git a/demos/embedded/flightinfo/flightinfo.pro b/demos/embedded/flightinfo/flightinfo.pro
index a33423f543..dfa4ae355f 100644
--- a/demos/embedded/flightinfo/flightinfo.pro
+++ b/demos/embedded/flightinfo/flightinfo.pro
@@ -3,7 +3,7 @@ TARGET = flightinfo
SOURCES = flightinfo.cpp
FORMS += form.ui
RESOURCES = flightinfo.qrc
-QT += network
+QT += network widgets
symbian {
TARGET.UID3 = 0xA000CF74
diff --git a/demos/embedded/lightmaps/lightmaps.cpp b/demos/embedded/lightmaps/lightmaps.cpp
index 8e64e7370c..62d38a81c8 100644
--- a/demos/embedded/lightmaps/lightmaps.cpp
+++ b/demos/embedded/lightmaps/lightmaps.cpp
@@ -40,7 +40,7 @@
****************************************************************************/
#include <QtCore>
-#include <QtGui>
+#include <QtWidgets>
#include <QtNetwork>
#include <math.h>
diff --git a/demos/embedded/lightmaps/lightmaps.pro b/demos/embedded/lightmaps/lightmaps.pro
index 2751c3a647..b7fa2d660f 100644
--- a/demos/embedded/lightmaps/lightmaps.pro
+++ b/demos/embedded/lightmaps/lightmaps.pro
@@ -6,7 +6,7 @@ SOURCES = lightmaps.cpp \
main.cpp \
mapzoom.cpp \
slippymap.cpp
-QT += network
+QT += network widgets
symbian {
TARGET.UID3 = 0xA000CF75
diff --git a/demos/embedded/lightmaps/mapzoom.cpp b/demos/embedded/lightmaps/mapzoom.cpp
index 6cafc59b1d..61da74d629 100644
--- a/demos/embedded/lightmaps/mapzoom.cpp
+++ b/demos/embedded/lightmaps/mapzoom.cpp
@@ -39,7 +39,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QtNetwork>
#include "lightmaps.h"
#include "mapzoom.h"
diff --git a/demos/embedded/lightmaps/slippymap.cpp b/demos/embedded/lightmaps/slippymap.cpp
index 2c76f748bc..de58732c54 100644
--- a/demos/embedded/lightmaps/slippymap.cpp
+++ b/demos/embedded/lightmaps/slippymap.cpp
@@ -41,7 +41,7 @@
#include <math.h>
-#include <QtGui>
+#include <QtWidgets>
#include <QtNetwork>
#include "slippymap.h"
diff --git a/demos/embedded/raycasting/raycasting.cpp b/demos/embedded/raycasting/raycasting.cpp
index 8ca4f8bf74..220bcf9341 100644
--- a/demos/embedded/raycasting/raycasting.cpp
+++ b/demos/embedded/raycasting/raycasting.cpp
@@ -40,7 +40,7 @@
****************************************************************************/
#include <QtCore>
-#include <QtGui>
+#include <QtWidgets>
#include <math.h>
diff --git a/demos/embedded/raycasting/raycasting.pro b/demos/embedded/raycasting/raycasting.pro
index a4bb1826b9..552ebecf4c 100644
--- a/demos/embedded/raycasting/raycasting.pro
+++ b/demos/embedded/raycasting/raycasting.pro
@@ -11,3 +11,4 @@ target.path = $$[QT_INSTALL_DEMOS]/qtbase/embedded/raycasting
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro
sources.path = $$[QT_INSTALL_DEMOS]/qtbase/embedded/raycasting
INSTALLS += target sources
+QT += widgets widgets
diff --git a/demos/embedded/styledemo/styledemo.pro b/demos/embedded/styledemo/styledemo.pro
index 60700dd1df..e8a428106c 100644
--- a/demos/embedded/styledemo/styledemo.pro
+++ b/demos/embedded/styledemo/styledemo.pro
@@ -15,3 +15,4 @@ symbian {
TARGET.UID3 = 0xA000A63F
CONFIG += qt_demo
}
+QT += widgets widgets
diff --git a/demos/embeddeddialogs/customproxy.cpp b/demos/embeddeddialogs/customproxy.cpp
index e56823dfbd..a93112b7b0 100644
--- a/demos/embeddeddialogs/customproxy.cpp
+++ b/demos/embeddeddialogs/customproxy.cpp
@@ -41,7 +41,7 @@
#include "customproxy.h"
-#include <QtGui>
+#include <QtWidgets>
CustomProxy::CustomProxy(QGraphicsItem *parent, Qt::WindowFlags wFlags)
: QGraphicsProxyWidget(parent, wFlags), popupShown(false), currentPopup(0)
diff --git a/demos/embeddeddialogs/customproxy.h b/demos/embeddeddialogs/customproxy.h
index 67d2152f98..723f0a0a21 100644
--- a/demos/embeddeddialogs/customproxy.h
+++ b/demos/embeddeddialogs/customproxy.h
@@ -43,7 +43,7 @@
#define CUSTOMPROXY_H
#include <QtCore/qtimeline.h>
-#include <QtGui/qgraphicsproxywidget.h>
+#include <QtWidgets/qgraphicsproxywidget.h>
class CustomProxy : public QGraphicsProxyWidget
{
diff --git a/demos/embeddeddialogs/embeddeddialog.cpp b/demos/embeddeddialogs/embeddeddialog.cpp
index e359afe555..f38fbf0eb5 100644
--- a/demos/embeddeddialogs/embeddeddialog.cpp
+++ b/demos/embeddeddialogs/embeddeddialog.cpp
@@ -42,7 +42,7 @@
#include "embeddeddialog.h"
#include "ui_embeddeddialog.h"
-#include <QtGui>
+#include <QtWidgets>
EmbeddedDialog::EmbeddedDialog(QWidget *parent)
: QDialog(parent)
diff --git a/demos/embeddeddialogs/embeddeddialog.h b/demos/embeddeddialogs/embeddeddialog.h
index 54263f64e3..1c81575760 100644
--- a/demos/embeddeddialogs/embeddeddialog.h
+++ b/demos/embeddeddialogs/embeddeddialog.h
@@ -42,7 +42,7 @@
#ifndef EMBEDDEDDIALOG_H
#define EMBEDDEDDIALOG_H
-#include <QtGui/qdialog.h>
+#include <QtWidgets/qdialog.h>
QT_FORWARD_DECLARE_CLASS(Ui_embeddedDialog);
diff --git a/demos/embeddeddialogs/embeddeddialogs.pro b/demos/embeddeddialogs/embeddeddialogs.pro
index 675a9889a2..30cde78751 100644
--- a/demos/embeddeddialogs/embeddeddialogs.pro
+++ b/demos/embeddeddialogs/embeddeddialogs.pro
@@ -17,3 +17,4 @@ sources.path = $$[QT_INSTALL_DEMOS]/qtbase/embeddeddialogs
INSTALLS += target sources
symbian: CONFIG += qt_demo
+QT += widgets widgets
diff --git a/demos/embeddeddialogs/main.cpp b/demos/embeddeddialogs/main.cpp
index 01f1ca9c0e..970672e29c 100644
--- a/demos/embeddeddialogs/main.cpp
+++ b/demos/embeddeddialogs/main.cpp
@@ -42,7 +42,7 @@
#include "customproxy.h"
#include "embeddeddialog.h"
-#include <QtGui>
+#include <QtWidgets>
int main(int argc, char *argv[])
{
diff --git a/demos/gradients/gradients.h b/demos/gradients/gradients.h
index bdd5c713ec..d400eea70b 100644
--- a/demos/gradients/gradients.h
+++ b/demos/gradients/gradients.h
@@ -44,7 +44,7 @@
#include "arthurwidgets.h"
-#include <QtGui>
+#include <QtWidgets>
class HoverPoints;
diff --git a/demos/gradients/gradients.pro b/demos/gradients/gradients.pro
index ed4120e01c..ff292efba1 100644
--- a/demos/gradients/gradients.pro
+++ b/demos/gradients/gradients.pro
@@ -8,7 +8,7 @@ include($$SHARED_FOLDER/shared.pri)
RESOURCES += gradients.qrc
contains(QT_CONFIG, opengl) {
DEFINES += QT_OPENGL_SUPPORT
- QT += opengl
+ QT += opengl widgets
}
# install
diff --git a/demos/interview/interview.pro b/demos/interview/interview.pro
index a497fbc407..bf39328e99 100644
--- a/demos/interview/interview.pro
+++ b/demos/interview/interview.pro
@@ -17,3 +17,4 @@ sources.path = $$[QT_INSTALL_DEMOS]/qtbase/interview
INSTALLS += target sources
symbian: CONFIG += qt_demo
+QT += widgets widgets
diff --git a/demos/macmainwindow/macmainwindow.h b/demos/macmainwindow/macmainwindow.h
index 4c2c638a20..1070981a89 100644
--- a/demos/macmainwindow/macmainwindow.h
+++ b/demos/macmainwindow/macmainwindow.h
@@ -41,7 +41,7 @@
#ifndef MACMAINWINDOW_H
#define MACMAINWINDOW_H
-#include <QtGui>
+#include <QtWidgets>
#ifdef Q_WS_MAC
diff --git a/demos/macmainwindow/macmainwindow.pro b/demos/macmainwindow/macmainwindow.pro
index 435905612a..6773a669d0 100644
--- a/demos/macmainwindow/macmainwindow.pro
+++ b/demos/macmainwindow/macmainwindow.pro
@@ -21,3 +21,4 @@ sources.files = $$SOURCES *.pro *.html
sources.path = $$[QT_INSTALL_DEMOS]/qtbase/macmainwindow
INSTALLS += target sources
}
+QT += widgets widgets
diff --git a/demos/macmainwindow/main.cpp b/demos/macmainwindow/main.cpp
index 0b513f8951..56c26b4645 100644
--- a/demos/macmainwindow/main.cpp
+++ b/demos/macmainwindow/main.cpp
@@ -39,7 +39,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "macmainwindow.h"
#ifdef Q_WS_MAC
diff --git a/demos/mainwindow/mainwindow.pro b/demos/mainwindow/mainwindow.pro
index 6da113d722..bbb7c80a21 100644
--- a/demos/mainwindow/mainwindow.pro
+++ b/demos/mainwindow/mainwindow.pro
@@ -15,3 +15,4 @@ sources.path = $$[QT_INSTALL_DEMOS]/qtbase/mainwindow
INSTALLS += target sources
symbian: CONFIG += qt_demo
+QT += widgets widgets
diff --git a/demos/pathstroke/pathstroke.h b/demos/pathstroke/pathstroke.h
index c35c9e8d2b..687ed07fcb 100644
--- a/demos/pathstroke/pathstroke.h
+++ b/demos/pathstroke/pathstroke.h
@@ -43,7 +43,7 @@
#define PATHSTROKE_H
#include "arthurwidgets.h"
-#include <QtGui>
+#include <QtWidgets>
class PathStrokeRenderer : public ArthurFrame
{
diff --git a/demos/pathstroke/pathstroke.pro b/demos/pathstroke/pathstroke.pro
index 9bbf8a6f77..af6482fb48 100644
--- a/demos/pathstroke/pathstroke.pro
+++ b/demos/pathstroke/pathstroke.pro
@@ -9,7 +9,7 @@ RESOURCES += pathstroke.qrc
contains(QT_CONFIG, opengl) {
DEFINES += QT_OPENGL_SUPPORT
- QT += opengl
+ QT += opengl widgets
}
# install
diff --git a/demos/shared/hoverpoints.h b/demos/shared/hoverpoints.h
index 9c10632d8d..4b126990a4 100644
--- a/demos/shared/hoverpoints.h
+++ b/demos/shared/hoverpoints.h
@@ -42,7 +42,7 @@
#ifndef HOVERPOINTS_H
#define HOVERPOINTS_H
-#include <QtGui>
+#include <QtWidgets>
QT_FORWARD_DECLARE_CLASS(QBypassWidget)
diff --git a/demos/shared/shared.pro b/demos/shared/shared.pro
index 88d7fbedab..78aaaefe48 100644
--- a/demos/shared/shared.pro
+++ b/demos/shared/shared.pro
@@ -3,7 +3,7 @@ CONFIG += static
contains(QT_CONFIG, opengl)|contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2) {
DEFINES += QT_OPENGL_SUPPORT
- QT += opengl
+ QT += opengl widgets
}
build_all:!build_pass {
@@ -11,7 +11,7 @@ build_all:!build_pass {
CONFIG += release
}
TARGET = demo_shared
-QT += gui-private
+QT += gui-private widgets
SOURCES += \
arthurstyle.cpp\
diff --git a/demos/spreadsheet/main.cpp b/demos/spreadsheet/main.cpp
index e197e75c44..73500c8801 100644
--- a/demos/spreadsheet/main.cpp
+++ b/demos/spreadsheet/main.cpp
@@ -39,7 +39,7 @@
**
****************************************************************************/
-#include <QtGui/QApplication>
+#include <QtWidgets/QApplication>
#include "spreadsheet.h"
int main(int argc, char** argv) {
diff --git a/demos/spreadsheet/spreadsheet.cpp b/demos/spreadsheet/spreadsheet.cpp
index 000c7898bc..2651cdd106 100644
--- a/demos/spreadsheet/spreadsheet.cpp
+++ b/demos/spreadsheet/spreadsheet.cpp
@@ -39,7 +39,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "spreadsheet.h"
#include "spreadsheetdelegate.h"
#include "spreadsheetitem.h"
diff --git a/demos/spreadsheet/spreadsheet.pro b/demos/spreadsheet/spreadsheet.pro
index 7179d98eba..dc079866a3 100644
--- a/demos/spreadsheet/spreadsheet.pro
+++ b/demos/spreadsheet/spreadsheet.pro
@@ -7,8 +7,9 @@ TARGET =
DEPENDPATH += .
INCLUDEPATH += .
+QT += widgets
CONFIG += qt warn_on
-#unix:contains(QT_CONFIG, dbus):QT += dbus
+#unix:contains(QT_CONFIG, dbus):QT += dbus widgets
# Input
HEADERS += printview.h spreadsheet.h spreadsheetdelegate.h spreadsheetitem.h
diff --git a/demos/spreadsheet/spreadsheetdelegate.cpp b/demos/spreadsheet/spreadsheetdelegate.cpp
index f4aedaa5fc..9628234804 100644
--- a/demos/spreadsheet/spreadsheetdelegate.cpp
+++ b/demos/spreadsheet/spreadsheetdelegate.cpp
@@ -40,7 +40,7 @@
****************************************************************************/
#include "spreadsheetdelegate.h"
-#include <QtGui>
+#include <QtWidgets>
SpreadSheetDelegate::SpreadSheetDelegate(QObject *parent)
: QItemDelegate(parent) {}
diff --git a/demos/spreadsheet/spreadsheetitem.h b/demos/spreadsheet/spreadsheetitem.h
index 13566a7600..831b970481 100644
--- a/demos/spreadsheet/spreadsheetitem.h
+++ b/demos/spreadsheet/spreadsheetitem.h
@@ -43,7 +43,7 @@
#define SPREADSHEETITEM_H
#include <QTableWidgetItem>
-#include <QtGui>
+#include <QtWidgets>
#include "spreadsheet.h"
class SpreadSheetItem : public QTableWidgetItem
diff --git a/demos/sqlbrowser/browser.cpp b/demos/sqlbrowser/browser.cpp
index 479eaaaaa9..b84e3b980f 100644
--- a/demos/sqlbrowser/browser.cpp
+++ b/demos/sqlbrowser/browser.cpp
@@ -42,7 +42,7 @@
#include "browser.h"
#include "qsqlconnectiondialog.h"
-#include <QtGui>
+#include <QtWidgets>
#include <QtSql>
Browser::Browser(QWidget *parent)
diff --git a/demos/sqlbrowser/connectionwidget.cpp b/demos/sqlbrowser/connectionwidget.cpp
index 6d213f3036..9e6b19bced 100644
--- a/demos/sqlbrowser/connectionwidget.cpp
+++ b/demos/sqlbrowser/connectionwidget.cpp
@@ -41,7 +41,7 @@
#include "connectionwidget.h"
-#include <QtGui>
+#include <QtWidgets>
#include <QtSql>
ConnectionWidget::ConnectionWidget(QWidget *parent)
diff --git a/demos/sqlbrowser/main.cpp b/demos/sqlbrowser/main.cpp
index 875dd4815a..e9f93798ca 100644
--- a/demos/sqlbrowser/main.cpp
+++ b/demos/sqlbrowser/main.cpp
@@ -42,7 +42,7 @@
#include "browser.h"
#include <QtCore>
-#include <QtGui>
+#include <QtWidgets>
#include <QtSql>
void addConnectionsFromCommandline(const QStringList &args, Browser *browser)
diff --git a/demos/sqlbrowser/sqlbrowser.pro b/demos/sqlbrowser/sqlbrowser.pro
index dc6214622c..b2530b07fc 100644
--- a/demos/sqlbrowser/sqlbrowser.pro
+++ b/demos/sqlbrowser/sqlbrowser.pro
@@ -1,7 +1,7 @@
TEMPLATE = app
TARGET = sqlbrowser
-QT += sql
+QT += sql widgets
HEADERS = browser.h connectionwidget.h qsqlconnectiondialog.h
SOURCES = main.cpp browser.cpp connectionwidget.cpp qsqlconnectiondialog.cpp
diff --git a/demos/sub-attaq/boat_p.h b/demos/sub-attaq/boat_p.h
index 010dd0a6df..d64ad109a7 100644
--- a/demos/sub-attaq/boat_p.h
+++ b/demos/sub-attaq/boat_p.h
@@ -58,7 +58,7 @@
#include "graphicsscene.h"
// Qt
-#include <QtGui/QKeyEventTransition>
+#include <QtWidgets/QKeyEventTransition>
static const int MAX_BOMB = 5;
diff --git a/demos/sub-attaq/graphicsscene.cpp b/demos/sub-attaq/graphicsscene.cpp
index d01c94f8eb..2b7455c03a 100644
--- a/demos/sub-attaq/graphicsscene.cpp
+++ b/demos/sub-attaq/graphicsscene.cpp
@@ -59,12 +59,12 @@
#include <QtCore/QStateMachine>
#include <QtCore/QFinalState>
#include <QtCore/QPauseAnimation>
-#include <QtGui/QAction>
+#include <QtWidgets/QAction>
#include <QtCore/QDir>
-#include <QtGui/QApplication>
-#include <QtGui/QMessageBox>
-#include <QtGui/QGraphicsView>
-#include <QtGui/QGraphicsSceneMouseEvent>
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QMessageBox>
+#include <QtWidgets/QGraphicsView>
+#include <QtWidgets/QGraphicsSceneMouseEvent>
#include <QtCore/QXmlStreamReader>
GraphicsScene::GraphicsScene(int x, int y, int width, int height, Mode mode)
diff --git a/demos/sub-attaq/graphicsscene.h b/demos/sub-attaq/graphicsscene.h
index 215ee71262..002de29bab 100644
--- a/demos/sub-attaq/graphicsscene.h
+++ b/demos/sub-attaq/graphicsscene.h
@@ -43,7 +43,7 @@
#define __GRAPHICSSCENE__H__
//Qt
-#include <QtGui/QGraphicsScene>
+#include <QtWidgets/QGraphicsScene>
#include <QtCore/QSet>
#include <QtCore/QState>
diff --git a/demos/sub-attaq/main.cpp b/demos/sub-attaq/main.cpp
index 54f11e6a5f..4da920445b 100644
--- a/demos/sub-attaq/main.cpp
+++ b/demos/sub-attaq/main.cpp
@@ -39,7 +39,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
diff --git a/demos/sub-attaq/mainwindow.h b/demos/sub-attaq/mainwindow.h
index 532a39a265..56311dd94e 100644
--- a/demos/sub-attaq/mainwindow.h
+++ b/demos/sub-attaq/mainwindow.h
@@ -43,7 +43,7 @@
#define __MAINWINDOW__H__
//Qt
-#include <QtGui/QMainWindow>
+#include <QtWidgets/QMainWindow>
class GraphicsScene;
QT_BEGIN_NAMESPACE
class QGraphicsView;
diff --git a/demos/sub-attaq/pixmapitem.h b/demos/sub-attaq/pixmapitem.h
index 8b615e7f79..1bab23e6e9 100644
--- a/demos/sub-attaq/pixmapitem.h
+++ b/demos/sub-attaq/pixmapitem.h
@@ -46,7 +46,7 @@
#include "graphicsscene.h"
//Qt
-#include <QtGui/QGraphicsObject>
+#include <QtWidgets/QGraphicsObject>
class PixmapItem : public QGraphicsObject
{
diff --git a/demos/sub-attaq/progressitem.h b/demos/sub-attaq/progressitem.h
index d4778cbdc1..e1bb1d4db9 100644
--- a/demos/sub-attaq/progressitem.h
+++ b/demos/sub-attaq/progressitem.h
@@ -43,7 +43,7 @@
#define PROGRESSITEM_H
//Qt
-#include <QtGui/QGraphicsTextItem>
+#include <QtWidgets/QGraphicsTextItem>
class ProgressItem : public QGraphicsTextItem
{
diff --git a/demos/sub-attaq/states.cpp b/demos/sub-attaq/states.cpp
index e939641524..a54b232a0f 100644
--- a/demos/sub-attaq/states.cpp
+++ b/demos/sub-attaq/states.cpp
@@ -50,10 +50,10 @@
#include "textinformationitem.h"
//Qt
-#include <QtGui/QMessageBox>
-#include <QtGui/QGraphicsView>
+#include <QtWidgets/QMessageBox>
+#include <QtWidgets/QGraphicsView>
#include <QtCore/QStateMachine>
-#include <QtGui/QKeyEventTransition>
+#include <QtWidgets/QKeyEventTransition>
#include <QtCore/QFinalState>
PlayState::PlayState(GraphicsScene *scene, QState *parent)
diff --git a/demos/sub-attaq/states.h b/demos/sub-attaq/states.h
index 3a3c516871..f85a481b71 100644
--- a/demos/sub-attaq/states.h
+++ b/demos/sub-attaq/states.h
@@ -46,7 +46,7 @@
#include <QtCore/QState>
#include <QtCore/QSignalTransition>
#include <QtCore/QPropertyAnimation>
-#include <QtGui/QKeyEventTransition>
+#include <QtWidgets/QKeyEventTransition>
#include <QtCore/QSet>
class GraphicsScene;
diff --git a/demos/sub-attaq/sub-attaq.pro b/demos/sub-attaq/sub-attaq.pro
index 5575f5e65f..7b57baf19b 100644
--- a/demos/sub-attaq/sub-attaq.pro
+++ b/demos/sub-attaq/sub-attaq.pro
@@ -1,4 +1,4 @@
-contains(QT_CONFIG, opengl):QT += opengl
+contains(QT_CONFIG, opengl):QT += opengl widgets
HEADERS += boat.h \
bomb.h \
mainwindow.h \
diff --git a/demos/sub-attaq/submarine.h b/demos/sub-attaq/submarine.h
index 8bdd320e21..d1b5a5ed80 100644
--- a/demos/sub-attaq/submarine.h
+++ b/demos/sub-attaq/submarine.h
@@ -43,7 +43,7 @@
#define __SUBMARINE__H__
//Qt
-#include <QtGui/QGraphicsTransform>
+#include <QtWidgets/QGraphicsTransform>
#include "pixmapitem.h"
diff --git a/demos/sub-attaq/submarine_p.h b/demos/sub-attaq/submarine_p.h
index 59b7c1db7b..a7bacd1fcf 100644
--- a/demos/sub-attaq/submarine_p.h
+++ b/demos/sub-attaq/submarine_p.h
@@ -60,7 +60,7 @@
//Qt
#include <QtCore/QPropertyAnimation>
-#include <QtGui/QGraphicsScene>
+#include <QtWidgets/QGraphicsScene>
//This state is describing when the boat is moving right
class MovementState : public QAnimationState
diff --git a/demos/sub-attaq/textinformationitem.h b/demos/sub-attaq/textinformationitem.h
index 5a9b52cf1d..db557fdd9d 100644
--- a/demos/sub-attaq/textinformationitem.h
+++ b/demos/sub-attaq/textinformationitem.h
@@ -43,7 +43,7 @@
#define TEXTINFORMATIONITEM_H
//Qt
-#include <QtGui/QGraphicsTextItem>
+#include <QtWidgets/QGraphicsTextItem>
class TextInformationItem : public QGraphicsTextItem
{
diff --git a/demos/textedit/textedit.pro b/demos/textedit/textedit.pro
index b37ac3036a..02561f82ba 100644
--- a/demos/textedit/textedit.pro
+++ b/demos/textedit/textedit.pro
@@ -20,3 +20,4 @@ sources.path = $$[QT_INSTALL_DEMOS]/qtbase/textedit
INSTALLS += target sources
symbian: CONFIG += qt_demo
+QT += widgets widgets
diff --git a/demos/undo/undo.pro b/demos/undo/undo.pro
index 84f1d7b326..89f06bdfc7 100644
--- a/demos/undo/undo.pro
+++ b/demos/undo/undo.pro
@@ -16,3 +16,4 @@ sources.path = $$[QT_INSTALL_DEMOS]/qtbase/undo
INSTALLS += target sources
symbian: CONFIG += qt_demo
+QT += widgets
diff --git a/examples/animation/animatedtiles/animatedtiles.pro b/examples/animation/animatedtiles/animatedtiles.pro
index 763357f8ec..ba0482e71b 100644
--- a/examples/animation/animatedtiles/animatedtiles.pro
+++ b/examples/animation/animatedtiles/animatedtiles.pro
@@ -11,3 +11,4 @@ symbian {
TARGET.UID3 = 0xA000D7D1
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/animation/animatedtiles/main.cpp b/examples/animation/animatedtiles/main.cpp
index 1badb4f3ef..55dbd39ec1 100644
--- a/examples/animation/animatedtiles/main.cpp
+++ b/examples/animation/animatedtiles/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QtCore/qstate.h>
class Pixmap : public QObject, public QGraphicsPixmapItem
diff --git a/examples/animation/animation.pro b/examples/animation/animation.pro
index 4a9064d97e..27baed1a25 100644
--- a/examples/animation/animation.pro
+++ b/examples/animation/animation.pro
@@ -13,3 +13,4 @@ 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/appchooser.pro b/examples/animation/appchooser/appchooser.pro
index 65e2345165..557c764331 100644
--- a/examples/animation/appchooser/appchooser.pro
+++ b/examples/animation/appchooser/appchooser.pro
@@ -11,3 +11,4 @@ symbian {
TARGET.UID3 = 0xA000E3F5
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/animation/appchooser/main.cpp b/examples/animation/appchooser/main.cpp
index 86ec073f6e..ac801dde78 100644
--- a/examples/animation/appchooser/main.cpp
+++ b/examples/animation/appchooser/main.cpp
@@ -39,7 +39,7 @@
****************************************************************************/
#include <QtCore>
-#include <QtGui>
+#include <QtWidgets>
class Pixmap : public QGraphicsWidget
diff --git a/examples/animation/easing/animation.h b/examples/animation/easing/animation.h
index f0aef6560b..5f6c425827 100644
--- a/examples/animation/easing/animation.h
+++ b/examples/animation/easing/animation.h
@@ -41,7 +41,7 @@
#ifndef ANIMATION_H
#define ANIMATION_H
-#include <QtGui>
+#include <QtWidgets>
#include <QtCore/qpropertyanimation.h>
diff --git a/examples/animation/easing/easing.pro b/examples/animation/easing/easing.pro
index 3a10004022..402e61e714 100644
--- a/examples/animation/easing/easing.pro
+++ b/examples/animation/easing/easing.pro
@@ -17,3 +17,4 @@ symbian {
TARGET.UID3 = 0xA000E3F6
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/animation/easing/main.cpp b/examples/animation/easing/main.cpp
index def1db27de..72fa2d0a8d 100644
--- a/examples/animation/easing/main.cpp
+++ b/examples/animation/easing/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "window.h"
int main(int argc, char **argv)
diff --git a/examples/animation/easing/window.h b/examples/animation/easing/window.h
index bbdf14e0dc..1630b5d39f 100644
--- a/examples/animation/easing/window.h
+++ b/examples/animation/easing/window.h
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "ui_form.h"
#include "animation.h"
diff --git a/examples/animation/moveblocks/main.cpp b/examples/animation/moveblocks/main.cpp
index 3194c1b623..4e4bd554fe 100644
--- a/examples/animation/moveblocks/main.cpp
+++ b/examples/animation/moveblocks/main.cpp
@@ -39,7 +39,7 @@
****************************************************************************/
#include <QtCore>
-#include <QtGui>
+#include <QtWidgets>
//![15]
class StateSwitchEvent: public QEvent
diff --git a/examples/animation/moveblocks/moveblocks.pro b/examples/animation/moveblocks/moveblocks.pro
index b9c8542f4f..4c807e9d9c 100644
--- a/examples/animation/moveblocks/moveblocks.pro
+++ b/examples/animation/moveblocks/moveblocks.pro
@@ -10,3 +10,4 @@ symbian {
TARGET.UID3 = 0xA000E3F7
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/animation/states/main.cpp b/examples/animation/states/main.cpp
index 1565489069..eabbf7d4a7 100644
--- a/examples/animation/states/main.cpp
+++ b/examples/animation/states/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
class Pixmap : public QGraphicsObject
{
diff --git a/examples/animation/states/states.pro b/examples/animation/states/states.pro
index 00963fe8c0..27de30d63a 100644
--- a/examples/animation/states/states.pro
+++ b/examples/animation/states/states.pro
@@ -11,3 +11,4 @@ symbian {
TARGET.UID3 = 0xA000E3F8
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/animation/stickman/graphicsview.cpp b/examples/animation/stickman/graphicsview.cpp
index 23036efe92..e83a6e10f2 100644
--- a/examples/animation/stickman/graphicsview.cpp
+++ b/examples/animation/stickman/graphicsview.cpp
@@ -42,8 +42,8 @@
#include "stickman.h"
#include <QtGui/QKeyEvent>
-#include <QtGui/QGraphicsScene>
-#include <QtGui/QGraphicsView>
+#include <QtWidgets/QGraphicsScene>
+#include <QtWidgets/QGraphicsView>
GraphicsView::GraphicsView(QWidget *parent) : QGraphicsView(parent), m_editor(0) {}
diff --git a/examples/animation/stickman/graphicsview.h b/examples/animation/stickman/graphicsview.h
index 9cf87b63e6..5c93792f7b 100644
--- a/examples/animation/stickman/graphicsview.h
+++ b/examples/animation/stickman/graphicsview.h
@@ -41,7 +41,7 @@
#ifndef GRAPHICSVIEW_H
#define GRAPHICSVIEW
-#include <QtGui/QGraphicsView>
+#include <QtWidgets/QGraphicsView>
class MainWindow;
class GraphicsView: public QGraphicsView
diff --git a/examples/animation/stickman/lifecycle.cpp b/examples/animation/stickman/lifecycle.cpp
index 4abcdc22e5..3b18038fee 100644
--- a/examples/animation/stickman/lifecycle.cpp
+++ b/examples/animation/stickman/lifecycle.cpp
@@ -45,7 +45,7 @@
#include "graphicsview.h"
#include <QtCore>
-#include <QtGui>
+#include <QtWidgets>
class KeyPressTransition: public QSignalTransition
{
diff --git a/examples/animation/stickman/main.cpp b/examples/animation/stickman/main.cpp
index 08df766509..9ad7caa050 100644
--- a/examples/animation/stickman/main.cpp
+++ b/examples/animation/stickman/main.cpp
@@ -45,7 +45,7 @@
#include "graphicsview.h"
#include <QtCore>
-#include <QtGui>
+#include <QtWidgets>
int main(int argc, char **argv)
{
diff --git a/examples/animation/stickman/stickman.pro b/examples/animation/stickman/stickman.pro
index 2fefe72c4f..2d899cd2ff 100644
--- a/examples/animation/stickman/stickman.pro
+++ b/examples/animation/stickman/stickman.pro
@@ -22,3 +22,4 @@ symbian {
TARGET.UID3 = 0xA000E3F9
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/dbus/complexpingpong/complexpingpong.pro b/examples/dbus/complexpingpong/complexpingpong.pro
index cd618d549d..1dfeff92ac 100644
--- a/examples/dbus/complexpingpong/complexpingpong.pro
+++ b/examples/dbus/complexpingpong/complexpingpong.pro
@@ -2,3 +2,4 @@ TEMPLATE = subdirs
CONFIG += ordered
win32:CONFIG += console
SUBDIRS = complexping.pro complexpong.pro
+QT += widgets
diff --git a/examples/dbus/dbus-chat/chat.cpp b/examples/dbus/dbus-chat/chat.cpp
index 5cc12caafa..33ba0f7a3a 100644
--- a/examples/dbus/dbus-chat/chat.cpp
+++ b/examples/dbus/dbus-chat/chat.cpp
@@ -39,8 +39,8 @@
****************************************************************************/
#include "chat.h"
-#include <QtGui/QApplication>
-#include <QtGui/QMessageBox>
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QMessageBox>
#include "chat_adaptor.h"
#include "chat_interface.h"
diff --git a/examples/dbus/dbus-chat/dbus-chat.pro b/examples/dbus/dbus-chat/dbus-chat.pro
index 8de055afdb..34a1c4dc94 100644
--- a/examples/dbus/dbus-chat/dbus-chat.pro
+++ b/examples/dbus/dbus-chat/dbus-chat.pro
@@ -19,3 +19,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/chat
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/dbus/dbus.pro b/examples/dbus/dbus.pro
index 7a83e8864e..e79765b82b 100644
--- a/examples/dbus/dbus.pro
+++ b/examples/dbus/dbus.pro
@@ -15,3 +15,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus
INSTALLS += sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/dbus/pingpong/pingpong.pro b/examples/dbus/pingpong/pingpong.pro
index 07fca74c9a..701e778676 100644
--- a/examples/dbus/pingpong/pingpong.pro
+++ b/examples/dbus/pingpong/pingpong.pro
@@ -2,3 +2,4 @@ TEMPLATE = subdirs
CONFIG += ordered
win32:CONFIG += console
SUBDIRS = ping.pro pong.pro
+QT += widgets
diff --git a/examples/dbus/remotecontrolledcar/car/car.cpp b/examples/dbus/remotecontrolledcar/car/car.cpp
index 50f8f24d3e..d42db25d10 100644
--- a/examples/dbus/remotecontrolledcar/car/car.cpp
+++ b/examples/dbus/remotecontrolledcar/car/car.cpp
@@ -39,7 +39,7 @@
****************************************************************************/
#include "car.h"
-#include <QtGui/QtGui>
+#include <QtWidgets/QtWidgets>
#include <math.h>
static const double Pi = 3.14159265358979323846264338327950288419717;
diff --git a/examples/dbus/remotecontrolledcar/car/car.pro b/examples/dbus/remotecontrolledcar/car/car.pro
index 8bca29c6a3..11b8498b0a 100644
--- a/examples/dbus/remotecontrolledcar/car/car.pro
+++ b/examples/dbus/remotecontrolledcar/car/car.pro
@@ -20,3 +20,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/remotecontrolledcar/car
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/dbus/remotecontrolledcar/car/main.cpp b/examples/dbus/remotecontrolledcar/car/main.cpp
index 342a2b0c5d..df68f6125b 100644
--- a/examples/dbus/remotecontrolledcar/car/main.cpp
+++ b/examples/dbus/remotecontrolledcar/car/main.cpp
@@ -40,9 +40,9 @@
#include "car.h"
#include "car_adaptor.h"
-#include <QtGui/QApplication>
-#include <QtGui/QGraphicsView>
-#include <QtGui/QGraphicsScene>
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QGraphicsView>
+#include <QtWidgets/QGraphicsScene>
#include <QtDBus/QDBusConnection>
int main(int argc, char *argv[])
diff --git a/examples/dbus/remotecontrolledcar/controller/controller.cpp b/examples/dbus/remotecontrolledcar/controller/controller.cpp
index 8691aafa92..1303d9e218 100644
--- a/examples/dbus/remotecontrolledcar/controller/controller.cpp
+++ b/examples/dbus/remotecontrolledcar/controller/controller.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "controller.h"
#include "car_interface.h"
diff --git a/examples/dbus/remotecontrolledcar/controller/controller.pro b/examples/dbus/remotecontrolledcar/controller/controller.pro
index 00a5a2a317..a82ab0f470 100644
--- a/examples/dbus/remotecontrolledcar/controller/controller.pro
+++ b/examples/dbus/remotecontrolledcar/controller/controller.pro
@@ -21,3 +21,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/remotecontrolledcar/controlle
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/dbus/remotecontrolledcar/controller/main.cpp b/examples/dbus/remotecontrolledcar/controller/main.cpp
index 5b536117c8..c91edd3056 100644
--- a/examples/dbus/remotecontrolledcar/controller/main.cpp
+++ b/examples/dbus/remotecontrolledcar/controller/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QtDBus>
#include "controller.h"
diff --git a/examples/dbus/remotecontrolledcar/remotecontrolledcar.pro b/examples/dbus/remotecontrolledcar/remotecontrolledcar.pro
index 41a7476b11..f9c853fc2d 100644
--- a/examples/dbus/remotecontrolledcar/remotecontrolledcar.pro
+++ b/examples/dbus/remotecontrolledcar/remotecontrolledcar.pro
@@ -8,3 +8,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dbus/remotecontrolledcar
INSTALLS += sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/desktop/desktop.pro b/examples/desktop/desktop.pro
index 58c7b977fb..e99d4599fc 100644
--- a/examples/desktop/desktop.pro
+++ b/examples/desktop/desktop.pro
@@ -9,3 +9,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/desktop
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/desktop/screenshot/screenshot.cpp b/examples/desktop/screenshot/screenshot.cpp
index 0d7a18842a..683682ae52 100644
--- a/examples/desktop/screenshot/screenshot.cpp
+++ b/examples/desktop/screenshot/screenshot.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "screenshot.h"
diff --git a/examples/desktop/screenshot/screenshot.pro b/examples/desktop/screenshot/screenshot.pro
index c2c6ead8cc..426b77dd95 100644
--- a/examples/desktop/screenshot/screenshot.pro
+++ b/examples/desktop/screenshot/screenshot.pro
@@ -9,3 +9,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/desktop/screenshot
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/dialogs/classwizard/classwizard.cpp b/examples/dialogs/classwizard/classwizard.cpp
index 5247d7e2ae..64039ae44f 100644
--- a/examples/dialogs/classwizard/classwizard.cpp
+++ b/examples/dialogs/classwizard/classwizard.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "classwizard.h"
diff --git a/examples/dialogs/classwizard/classwizard.pro b/examples/dialogs/classwizard/classwizard.pro
index 0952e8f724..b233b44dc7 100644
--- a/examples/dialogs/classwizard/classwizard.pro
+++ b/examples/dialogs/classwizard/classwizard.pro
@@ -10,3 +10,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/classwizard
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/dialogs/configdialog/configdialog.cpp b/examples/dialogs/configdialog/configdialog.cpp
index 0e1de0c61c..d0f071440d 100644
--- a/examples/dialogs/configdialog/configdialog.cpp
+++ b/examples/dialogs/configdialog/configdialog.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "configdialog.h"
#include "pages.h"
diff --git a/examples/dialogs/configdialog/configdialog.pro b/examples/dialogs/configdialog/configdialog.pro
index c6e47485bb..9eee58d568 100644
--- a/examples/dialogs/configdialog/configdialog.pro
+++ b/examples/dialogs/configdialog/configdialog.pro
@@ -14,3 +14,4 @@ INSTALLS += target sources
symbian: CONFIG += qt_example
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/configdialog/pages.cpp b/examples/dialogs/configdialog/pages.cpp
index f69ec53f83..84949dd075 100644
--- a/examples/dialogs/configdialog/pages.cpp
+++ b/examples/dialogs/configdialog/pages.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "pages.h"
diff --git a/examples/dialogs/dialogs.pro b/examples/dialogs/dialogs.pro
index f4ea5713df..f5f3c114ec 100644
--- a/examples/dialogs/dialogs.pro
+++ b/examples/dialogs/dialogs.pro
@@ -17,3 +17,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs
INSTALLS += sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/dialogs/extension/extension.pro b/examples/dialogs/extension/extension.pro
index 108906f483..492b18b4d9 100644
--- a/examples/dialogs/extension/extension.pro
+++ b/examples/dialogs/extension/extension.pro
@@ -9,3 +9,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/extension
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/dialogs/extension/finddialog.cpp b/examples/dialogs/extension/finddialog.cpp
index 313e8e4201..0b41a8a1e5 100644
--- a/examples/dialogs/extension/finddialog.cpp
+++ b/examples/dialogs/extension/finddialog.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "finddialog.h"
diff --git a/examples/dialogs/findfiles/findfiles.pro b/examples/dialogs/findfiles/findfiles.pro
index ffae120bda..352daef509 100644
--- a/examples/dialogs/findfiles/findfiles.pro
+++ b/examples/dialogs/findfiles/findfiles.pro
@@ -9,3 +9,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/findfiles
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/dialogs/findfiles/window.cpp b/examples/dialogs/findfiles/window.cpp
index 3d6c0fd398..42d6fc13ea 100644
--- a/examples/dialogs/findfiles/window.cpp
+++ b/examples/dialogs/findfiles/window.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "window.h"
diff --git a/examples/dialogs/licensewizard/licensewizard.cpp b/examples/dialogs/licensewizard/licensewizard.cpp
index 19a0c069e4..49f9a27d7f 100644
--- a/examples/dialogs/licensewizard/licensewizard.cpp
+++ b/examples/dialogs/licensewizard/licensewizard.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "licensewizard.h"
diff --git a/examples/dialogs/licensewizard/licensewizard.pro b/examples/dialogs/licensewizard/licensewizard.pro
index cdf6aa7fdc..82cdf73d7d 100644
--- a/examples/dialogs/licensewizard/licensewizard.pro
+++ b/examples/dialogs/licensewizard/licensewizard.pro
@@ -10,3 +10,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/licensewizard
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/dialogs/sipdialog/dialog.cpp b/examples/dialogs/sipdialog/dialog.cpp
index c6d5a1767f..3dd37e368b 100644
--- a/examples/dialogs/sipdialog/dialog.cpp
+++ b/examples/dialogs/sipdialog/dialog.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "dialog.h"
diff --git a/examples/dialogs/sipdialog/main.cpp b/examples/dialogs/sipdialog/main.cpp
index bd37e33960..aa1151c0a9 100644
--- a/examples/dialogs/sipdialog/main.cpp
+++ b/examples/dialogs/sipdialog/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "dialog.h"
diff --git a/examples/dialogs/sipdialog/sipdialog.pro b/examples/dialogs/sipdialog/sipdialog.pro
index ffc9693604..5d2fd6169c 100644
--- a/examples/dialogs/sipdialog/sipdialog.pro
+++ b/examples/dialogs/sipdialog/sipdialog.pro
@@ -12,3 +12,4 @@ symbian: CONFIG += qt_example
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/standarddialogs/dialog.cpp b/examples/dialogs/standarddialogs/dialog.cpp
index 0b7728ece4..20639e5f0e 100644
--- a/examples/dialogs/standarddialogs/dialog.cpp
+++ b/examples/dialogs/standarddialogs/dialog.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "dialog.h"
diff --git a/examples/dialogs/standarddialogs/standarddialogs.pro b/examples/dialogs/standarddialogs/standarddialogs.pro
index f7b3cef905..816cb0a0ed 100644
--- a/examples/dialogs/standarddialogs/standarddialogs.pro
+++ b/examples/dialogs/standarddialogs/standarddialogs.pro
@@ -11,3 +11,4 @@ INSTALLS += target sources
symbian: CONFIG += qt_example
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/tabdialog.cpp b/examples/dialogs/tabdialog/tabdialog.cpp
index 62c921c84b..829d82e8c8 100644
--- a/examples/dialogs/tabdialog/tabdialog.cpp
+++ b/examples/dialogs/tabdialog/tabdialog.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "tabdialog.h"
diff --git a/examples/dialogs/tabdialog/tabdialog.pro b/examples/dialogs/tabdialog/tabdialog.pro
index c67fcbd157..d011f04cc0 100644
--- a/examples/dialogs/tabdialog/tabdialog.pro
+++ b/examples/dialogs/tabdialog/tabdialog.pro
@@ -10,3 +10,4 @@ INSTALLS += target sources
symbian: CONFIG += qt_example
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
index 2a5c0ae5db..5e3ef97694 100644
--- a/examples/dialogs/trivialwizard/trivialwizard.cpp
+++ b/examples/dialogs/trivialwizard/trivialwizard.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QTranslator>
#include <QLocale>
#include <QLibraryInfo>
diff --git a/examples/dialogs/trivialwizard/trivialwizard.pro b/examples/dialogs/trivialwizard/trivialwizard.pro
index 31422de763..ec5c4f8605 100644
--- a/examples/dialogs/trivialwizard/trivialwizard.pro
+++ b/examples/dialogs/trivialwizard/trivialwizard.pro
@@ -7,3 +7,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/dialogs/trivialwizard
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/draganddrop/draganddrop.pro b/examples/draganddrop/draganddrop.pro
index 8f737f1918..6759520ddc 100644
--- a/examples/draganddrop/draganddrop.pro
+++ b/examples/draganddrop/draganddrop.pro
@@ -11,3 +11,4 @@ symbian: SUBDIRS -= dropsite
sources.files = README *.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/draganddrop
INSTALLS += sources
+QT += widgets
diff --git a/examples/draganddrop/draggableicons/draggableicons.pro b/examples/draganddrop/draggableicons/draggableicons.pro
index db56b7cc95..8285600c75 100644
--- a/examples/draganddrop/draggableicons/draggableicons.pro
+++ b/examples/draganddrop/draggableicons/draggableicons.pro
@@ -13,3 +13,4 @@ symbian {
TARGET.UID3 = 0xA000C615
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/draganddrop/draggableicons/dragwidget.cpp b/examples/draganddrop/draggableicons/dragwidget.cpp
index c8c3b134fc..9e69bd5df8 100644
--- a/examples/draganddrop/draggableicons/dragwidget.cpp
+++ b/examples/draganddrop/draggableicons/dragwidget.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "dragwidget.h"
diff --git a/examples/draganddrop/draggabletext/draggabletext.pro b/examples/draganddrop/draggabletext/draggabletext.pro
index ffe219be14..2d473500b0 100644
--- a/examples/draganddrop/draggabletext/draggabletext.pro
+++ b/examples/draganddrop/draggabletext/draggabletext.pro
@@ -15,3 +15,4 @@ symbian {
TARGET.UID3 = 0xA000CF64
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/draganddrop/draggabletext/draglabel.cpp b/examples/draganddrop/draggabletext/draglabel.cpp
index dff09da14f..9eb5dfac0b 100644
--- a/examples/draganddrop/draggabletext/draglabel.cpp
+++ b/examples/draganddrop/draggabletext/draglabel.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "draglabel.h"
diff --git a/examples/draganddrop/draggabletext/dragwidget.cpp b/examples/draganddrop/draggabletext/dragwidget.cpp
index df61c39476..2ba4a1ac0f 100644
--- a/examples/draganddrop/draggabletext/dragwidget.cpp
+++ b/examples/draganddrop/draggabletext/dragwidget.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "draglabel.h"
#include "dragwidget.h"
diff --git a/examples/draganddrop/dropsite/droparea.cpp b/examples/draganddrop/dropsite/droparea.cpp
index 2a83de888e..c3cac7bf45 100644
--- a/examples/draganddrop/dropsite/droparea.cpp
+++ b/examples/draganddrop/dropsite/droparea.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "droparea.h"
diff --git a/examples/draganddrop/dropsite/dropsite.pro b/examples/draganddrop/dropsite/dropsite.pro
index 0ee9f600d1..7f42258221 100644
--- a/examples/draganddrop/dropsite/dropsite.pro
+++ b/examples/draganddrop/dropsite/dropsite.pro
@@ -11,3 +11,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/draganddrop/dropsite
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/draganddrop/dropsite/dropsitewindow.cpp b/examples/draganddrop/dropsite/dropsitewindow.cpp
index db7d6e3566..191470207e 100644
--- a/examples/draganddrop/dropsite/dropsitewindow.cpp
+++ b/examples/draganddrop/dropsite/dropsitewindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "droparea.h"
#include "dropsitewindow.h"
diff --git a/examples/draganddrop/fridgemagnets/draglabel.cpp b/examples/draganddrop/fridgemagnets/draglabel.cpp
index 986f0b28c8..dd5ddb57d9 100644
--- a/examples/draganddrop/fridgemagnets/draglabel.cpp
+++ b/examples/draganddrop/fridgemagnets/draglabel.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "draglabel.h"
diff --git a/examples/draganddrop/fridgemagnets/dragwidget.cpp b/examples/draganddrop/fridgemagnets/dragwidget.cpp
index aeab3ade12..a2593a9b35 100644
--- a/examples/draganddrop/fridgemagnets/dragwidget.cpp
+++ b/examples/draganddrop/fridgemagnets/dragwidget.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "draglabel.h"
#include "dragwidget.h"
diff --git a/examples/draganddrop/fridgemagnets/fridgemagnets.pro b/examples/draganddrop/fridgemagnets/fridgemagnets.pro
index fe1377fb74..8ecbc016dd 100644
--- a/examples/draganddrop/fridgemagnets/fridgemagnets.pro
+++ b/examples/draganddrop/fridgemagnets/fridgemagnets.pro
@@ -17,3 +17,4 @@ symbian {
}
+QT += widgets
diff --git a/examples/draganddrop/puzzle/mainwindow.cpp b/examples/draganddrop/puzzle/mainwindow.cpp
index ea7cff12ce..856df7004f 100644
--- a/examples/draganddrop/puzzle/mainwindow.cpp
+++ b/examples/draganddrop/puzzle/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <stdlib.h>
#include "mainwindow.h"
diff --git a/examples/draganddrop/puzzle/pieceslist.cpp b/examples/draganddrop/puzzle/pieceslist.cpp
index db27e7ad13..f1a1e43e97 100644
--- a/examples/draganddrop/puzzle/pieceslist.cpp
+++ b/examples/draganddrop/puzzle/pieceslist.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "pieceslist.h"
diff --git a/examples/draganddrop/puzzle/puzzle.pro b/examples/draganddrop/puzzle/puzzle.pro
index 0d3a5dab2e..20b6bbcb78 100644
--- a/examples/draganddrop/puzzle/puzzle.pro
+++ b/examples/draganddrop/puzzle/puzzle.pro
@@ -27,3 +27,4 @@ wince*: {
addFile.path = .
DEPLOYMENT += addFile
}
+QT += widgets
diff --git a/examples/draganddrop/puzzle/puzzlewidget.cpp b/examples/draganddrop/puzzle/puzzlewidget.cpp
index 355c6d55cd..25a5fa5fb2 100644
--- a/examples/draganddrop/puzzle/puzzlewidget.cpp
+++ b/examples/draganddrop/puzzle/puzzlewidget.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "puzzlewidget.h"
diff --git a/examples/effects/blurpicker/blurpicker.cpp b/examples/effects/blurpicker/blurpicker.cpp
index 26e53aafae..8739301a59 100644
--- a/examples/effects/blurpicker/blurpicker.cpp
+++ b/examples/effects/blurpicker/blurpicker.cpp
@@ -40,7 +40,7 @@
#include "blurpicker.h"
-#include <QtGui>
+#include <QtWidgets>
#include "blureffect.h"
diff --git a/examples/effects/blurpicker/blurpicker.pro b/examples/effects/blurpicker/blurpicker.pro
index ba65da8a5c..bb0b9b9273 100644
--- a/examples/effects/blurpicker/blurpicker.pro
+++ b/examples/effects/blurpicker/blurpicker.pro
@@ -7,3 +7,4 @@ 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/effects.pro b/examples/effects/effects.pro
index 4b13387902..db7b8a723e 100644
--- a/examples/effects/effects.pro
+++ b/examples/effects/effects.pro
@@ -11,3 +11,4 @@ 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/fademessage.cpp b/examples/effects/fademessage/fademessage.cpp
index 88f9f89f1b..6113c7978e 100644
--- a/examples/effects/fademessage/fademessage.cpp
+++ b/examples/effects/fademessage/fademessage.cpp
@@ -40,7 +40,7 @@
#include "fademessage.h"
-#include <QtGui>
+#include <QtWidgets>
FadeMessage::FadeMessage(QWidget *parent): QGraphicsView(parent)
{
diff --git a/examples/effects/fademessage/fademessage.pro b/examples/effects/fademessage/fademessage.pro
index 9cff9a1dfa..8a9de817dc 100644
--- a/examples/effects/fademessage/fademessage.pro
+++ b/examples/effects/fademessage/fademessage.pro
@@ -14,3 +14,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/effects/fademessage
DEPLOYMENT_PLUGIN += qjpeg
+QT += widgets
diff --git a/examples/effects/lighting/lighting.cpp b/examples/effects/lighting/lighting.cpp
index a988ffbcb3..6b0185737c 100644
--- a/examples/effects/lighting/lighting.cpp
+++ b/examples/effects/lighting/lighting.cpp
@@ -40,7 +40,7 @@
#include "lighting.h"
-#include <QtGui>
+#include <QtWidgets>
#ifndef M_PI
#define M_PI 3.14159265358979323846
diff --git a/examples/effects/lighting/lighting.pro b/examples/effects/lighting/lighting.pro
index fd2288640d..2d0462867b 100644
--- a/examples/effects/lighting/lighting.pro
+++ b/examples/effects/lighting/lighting.pro
@@ -6,3 +6,4 @@ 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/examples.pro b/examples/examples.pro
index 0680ff45f6..1cce476806 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -1,3 +1,5 @@
+Qt += widgets
+
TEMPLATE = subdirs
SUBDIRS = \
network \
@@ -48,6 +50,7 @@ symbian: SUBDIRS = \
SUBDIRS += multimedia
}
+qpa:SUBDIRS += qpa
embedded:SUBDIRS += qws
contains(QT_BUILD_PARTS, tools):!contains(QT_CONFIG, no-gui):SUBDIRS += qtestlib
contains(QT_CONFIG, opengl): SUBDIRS += opengl
@@ -62,3 +65,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]
INSTALLS += sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/gestures/gestures.pro b/examples/gestures/gestures.pro
index 1e9e2270f3..b354ec4645 100644
--- a/examples/gestures/gestures.pro
+++ b/examples/gestures/gestures.pro
@@ -8,3 +8,4 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/gestures
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS gestures.pro README
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/gestures
INSTALLS += target sources
+QT += widgets
diff --git a/examples/gestures/imagegestures/imagegestures.pro b/examples/gestures/imagegestures/imagegestures.pro
index 2e75f06355..cd1f177718 100644
--- a/examples/gestures/imagegestures/imagegestures.pro
+++ b/examples/gestures/imagegestures/imagegestures.pro
@@ -19,3 +19,4 @@ symbian {
TARGET.UID3 = 0xA000D7D0
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/gestures/imagegestures/imagewidget.cpp b/examples/gestures/imagegestures/imagewidget.cpp
index 8bbb96563e..e12cb41363 100644
--- a/examples/gestures/imagegestures/imagewidget.cpp
+++ b/examples/gestures/imagegestures/imagewidget.cpp
@@ -41,7 +41,7 @@
#include "imagewidget.h"
-#include <QtGui>
+#include <QtWidgets>
//! [constructor]
ImageWidget::ImageWidget(QWidget *parent)
diff --git a/examples/gestures/imagegestures/imagewidget.h b/examples/gestures/imagegestures/imagewidget.h
index fff24fbcdf..1ee7d02224 100644
--- a/examples/gestures/imagegestures/imagewidget.h
+++ b/examples/gestures/imagegestures/imagewidget.h
@@ -43,7 +43,7 @@
#include <QWidget>
#include <QImage>
-#include <QtGui>
+#include <QtWidgets>
QT_BEGIN_NAMESPACE
class QGestureEvent;
diff --git a/examples/gestures/imagegestures/main.cpp b/examples/gestures/imagegestures/main.cpp
index ca37a733f7..4097a2fb31 100644
--- a/examples/gestures/imagegestures/main.cpp
+++ b/examples/gestures/imagegestures/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwidget.h"
diff --git a/examples/graphicsview/anchorlayout/anchorlayout.pro b/examples/graphicsview/anchorlayout/anchorlayout.pro
index 52cb13b241..8791a16abc 100644
--- a/examples/graphicsview/anchorlayout/anchorlayout.pro
+++ b/examples/graphicsview/anchorlayout/anchorlayout.pro
@@ -7,3 +7,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/anchorlayout
INSTALLS += target sources
TARGET = anchorlayout
+QT += widgets
diff --git a/examples/graphicsview/anchorlayout/main.cpp b/examples/graphicsview/anchorlayout/main.cpp
index c31afd214d..e8cf1adf4e 100644
--- a/examples/graphicsview/anchorlayout/main.cpp
+++ b/examples/graphicsview/anchorlayout/main.cpp
@@ -41,7 +41,7 @@
#include <QGraphicsWidget>
#include <QGraphicsProxyWidget>
#include <QGraphicsAnchorLayout>
-#include <QtGui>
+#include <QtWidgets>
static QGraphicsProxyWidget *createItem(const QSizeF &minimum = QSizeF(100.0, 100.0),
const QSizeF &preferred = QSize(150.0, 100.0),
diff --git a/examples/graphicsview/basicgraphicslayouts/basicgraphicslayouts.pro b/examples/graphicsview/basicgraphicslayouts/basicgraphicslayouts.pro
index 8b667387a0..524623e840 100644
--- a/examples/graphicsview/basicgraphicslayouts/basicgraphicslayouts.pro
+++ b/examples/graphicsview/basicgraphicslayouts/basicgraphicslayouts.pro
@@ -15,3 +15,4 @@ symbian {
TARGET.UID3 = 0xA000A645
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/graphicsview/basicgraphicslayouts/layoutitem.h b/examples/graphicsview/basicgraphicslayouts/layoutitem.h
index 448e9bac3f..3d83d4cd88 100644
--- a/examples/graphicsview/basicgraphicslayouts/layoutitem.h
+++ b/examples/graphicsview/basicgraphicslayouts/layoutitem.h
@@ -40,7 +40,7 @@
#ifndef LAYOUTITEM_H
#define LAYOUTITEM_H
-#include <QtGui>
+#include <QtWidgets>
//! [0]
class LayoutItem : public QGraphicsLayoutItem, public QGraphicsItem
diff --git a/examples/graphicsview/basicgraphicslayouts/main.cpp b/examples/graphicsview/basicgraphicslayouts/main.cpp
index 57448a58d7..5edd130403 100644
--- a/examples/graphicsview/basicgraphicslayouts/main.cpp
+++ b/examples/graphicsview/basicgraphicslayouts/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "window.h"
diff --git a/examples/graphicsview/basicgraphicslayouts/window.h b/examples/graphicsview/basicgraphicslayouts/window.h
index b2166f0552..4efa1ecd3a 100644
--- a/examples/graphicsview/basicgraphicslayouts/window.h
+++ b/examples/graphicsview/basicgraphicslayouts/window.h
@@ -41,7 +41,7 @@
#ifndef WINDOW_H
#define WINDOW_H
-#include <QtGui/QGraphicsWidget>
+#include <QtWidgets/QGraphicsWidget>
//! [0]
class Window : public QGraphicsWidget {
diff --git a/examples/graphicsview/collidingmice/collidingmice.pro b/examples/graphicsview/collidingmice/collidingmice.pro
index b49f44be4c..1b94671226 100644
--- a/examples/graphicsview/collidingmice/collidingmice.pro
+++ b/examples/graphicsview/collidingmice/collidingmice.pro
@@ -17,3 +17,4 @@ symbian {
TARGET.UID3 = 0xA000A643
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/graphicsview/collidingmice/main.cpp b/examples/graphicsview/collidingmice/main.cpp
index 2970a0079f..5bba2756ce 100644
--- a/examples/graphicsview/collidingmice/main.cpp
+++ b/examples/graphicsview/collidingmice/main.cpp
@@ -40,7 +40,7 @@
#include "mouse.h"
-#include <QtGui>
+#include <QtWidgets>
#include <math.h>
diff --git a/examples/graphicsview/diagramscene/arrow.cpp b/examples/graphicsview/diagramscene/arrow.cpp
index 188928d1d8..34142ff71b 100644
--- a/examples/graphicsview/diagramscene/arrow.cpp
+++ b/examples/graphicsview/diagramscene/arrow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "arrow.h"
#include <math.h>
diff --git a/examples/graphicsview/diagramscene/diagramitem.cpp b/examples/graphicsview/diagramscene/diagramitem.cpp
index cd7ce0c6e1..31c9627f9a 100644
--- a/examples/graphicsview/diagramscene/diagramitem.cpp
+++ b/examples/graphicsview/diagramscene/diagramitem.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "diagramitem.h"
#include "arrow.h"
diff --git a/examples/graphicsview/diagramscene/diagramscene.cpp b/examples/graphicsview/diagramscene/diagramscene.cpp
index 7592224db7..4ce5c68841 100644
--- a/examples/graphicsview/diagramscene/diagramscene.cpp
+++ b/examples/graphicsview/diagramscene/diagramscene.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "diagramscene.h"
#include "arrow.h"
diff --git a/examples/graphicsview/diagramscene/diagramscene.pro b/examples/graphicsview/diagramscene/diagramscene.pro
index 6af1160015..c2b971abb9 100644
--- a/examples/graphicsview/diagramscene/diagramscene.pro
+++ b/examples/graphicsview/diagramscene/diagramscene.pro
@@ -20,3 +20,4 @@ INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/graphicsview/diagramscene/diagramtextitem.cpp b/examples/graphicsview/diagramscene/diagramtextitem.cpp
index 588603eda5..f8858f1f51 100644
--- a/examples/graphicsview/diagramscene/diagramtextitem.cpp
+++ b/examples/graphicsview/diagramscene/diagramtextitem.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "diagramtextitem.h"
#include "diagramscene.h"
diff --git a/examples/graphicsview/diagramscene/main.cpp b/examples/graphicsview/diagramscene/main.cpp
index fcd027cb44..bab04ef1aa 100644
--- a/examples/graphicsview/diagramscene/main.cpp
+++ b/examples/graphicsview/diagramscene/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
diff --git a/examples/graphicsview/diagramscene/mainwindow.cpp b/examples/graphicsview/diagramscene/mainwindow.cpp
index 87eb33e7ee..edf7d3c3f3 100644
--- a/examples/graphicsview/diagramscene/mainwindow.cpp
+++ b/examples/graphicsview/diagramscene/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QLabel>
#include "mainwindow.h"
diff --git a/examples/graphicsview/dragdroprobot/coloritem.cpp b/examples/graphicsview/dragdroprobot/coloritem.cpp
index 81e8f5607b..24b8491a6b 100644
--- a/examples/graphicsview/dragdroprobot/coloritem.cpp
+++ b/examples/graphicsview/dragdroprobot/coloritem.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "coloritem.h"
diff --git a/examples/graphicsview/dragdroprobot/dragdroprobot.pro b/examples/graphicsview/dragdroprobot/dragdroprobot.pro
index 5240b4208f..579e45d26d 100644
--- a/examples/graphicsview/dragdroprobot/dragdroprobot.pro
+++ b/examples/graphicsview/dragdroprobot/dragdroprobot.pro
@@ -18,3 +18,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/dragdroprobot
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/graphicsview/dragdroprobot/main.cpp b/examples/graphicsview/dragdroprobot/main.cpp
index 315d2b6917..8c2acc499a 100644
--- a/examples/graphicsview/dragdroprobot/main.cpp
+++ b/examples/graphicsview/dragdroprobot/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "coloritem.h"
#include "robot.h"
diff --git a/examples/graphicsview/dragdroprobot/robot.cpp b/examples/graphicsview/dragdroprobot/robot.cpp
index 9494e7af7f..df585a948f 100644
--- a/examples/graphicsview/dragdroprobot/robot.cpp
+++ b/examples/graphicsview/dragdroprobot/robot.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "robot.h"
diff --git a/examples/graphicsview/elasticnodes/elasticnodes.pro b/examples/graphicsview/elasticnodes/elasticnodes.pro
index 208c849d13..be7ebe460b 100644
--- a/examples/graphicsview/elasticnodes/elasticnodes.pro
+++ b/examples/graphicsview/elasticnodes/elasticnodes.pro
@@ -21,3 +21,4 @@ symbian {
TARGET.UID3 = 0xA000A642
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/graphicsview/elasticnodes/graphwidget.cpp b/examples/graphicsview/elasticnodes/graphwidget.cpp
index c875b6551d..ce73a68b47 100644
--- a/examples/graphicsview/elasticnodes/graphwidget.cpp
+++ b/examples/graphicsview/elasticnodes/graphwidget.cpp
@@ -42,7 +42,7 @@
#include "edge.h"
#include "node.h"
-#include <QtGui>
+#include <QtWidgets>
#include <math.h>
diff --git a/examples/graphicsview/elasticnodes/graphwidget.h b/examples/graphicsview/elasticnodes/graphwidget.h
index 764bb3f0b9..f64f59e691 100644
--- a/examples/graphicsview/elasticnodes/graphwidget.h
+++ b/examples/graphicsview/elasticnodes/graphwidget.h
@@ -41,7 +41,7 @@
#ifndef GRAPHWIDGET_H
#define GRAPHWIDGET_H
-#include <QtGui/QGraphicsView>
+#include <QtWidgets/QGraphicsView>
class Node;
diff --git a/examples/graphicsview/elasticnodes/main.cpp b/examples/graphicsview/elasticnodes/main.cpp
index ab7e7cf7c7..2cd3d2641f 100644
--- a/examples/graphicsview/elasticnodes/main.cpp
+++ b/examples/graphicsview/elasticnodes/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "graphwidget.h"
diff --git a/examples/graphicsview/flowlayout/flowlayout.cpp b/examples/graphicsview/flowlayout/flowlayout.cpp
index 0531e4cce5..cb0ca1b2de 100644
--- a/examples/graphicsview/flowlayout/flowlayout.cpp
+++ b/examples/graphicsview/flowlayout/flowlayout.cpp
@@ -39,7 +39,7 @@
****************************************************************************/
#include "flowlayout.h"
-#include <QtGui/qwidget.h>
+#include <QtWidgets/qwidget.h>
#include <QtCore/qmath.h>
FlowLayout::FlowLayout()
diff --git a/examples/graphicsview/flowlayout/flowlayout.h b/examples/graphicsview/flowlayout/flowlayout.h
index aff3382c01..67c3315736 100644
--- a/examples/graphicsview/flowlayout/flowlayout.h
+++ b/examples/graphicsview/flowlayout/flowlayout.h
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui/qgraphicslayout.h>
+#include <QtWidgets/qgraphicslayout.h>
class FlowLayout : public QGraphicsLayout
{
diff --git a/examples/graphicsview/flowlayout/flowlayout.pro b/examples/graphicsview/flowlayout/flowlayout.pro
index ce3536774b..22ac005715 100644
--- a/examples/graphicsview/flowlayout/flowlayout.pro
+++ b/examples/graphicsview/flowlayout/flowlayout.pro
@@ -8,3 +8,4 @@ QMAKE_PROJECT_NAME = flowlayout_graphicsview
# Input
HEADERS += flowlayout.h window.h
SOURCES += flowlayout.cpp main.cpp window.cpp
+QT += widgets
diff --git a/examples/graphicsview/flowlayout/main.cpp b/examples/graphicsview/flowlayout/main.cpp
index cee08d76ac..e8b72b179f 100644
--- a/examples/graphicsview/flowlayout/main.cpp
+++ b/examples/graphicsview/flowlayout/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "window.h"
int main(int argc, char **argv)
diff --git a/examples/graphicsview/flowlayout/window.cpp b/examples/graphicsview/flowlayout/window.cpp
index 4abe2a55c2..35bd931d39 100644
--- a/examples/graphicsview/flowlayout/window.cpp
+++ b/examples/graphicsview/flowlayout/window.cpp
@@ -38,8 +38,8 @@
**
****************************************************************************/
-#include <QtGui/qgraphicsproxywidget.h>
-#include <QtGui/qlabel.h>
+#include <QtWidgets/qgraphicsproxywidget.h>
+#include <QtWidgets/qlabel.h>
#include "flowlayout.h"
#include "window.h"
diff --git a/examples/graphicsview/flowlayout/window.h b/examples/graphicsview/flowlayout/window.h
index c338a14236..7697d70842 100644
--- a/examples/graphicsview/flowlayout/window.h
+++ b/examples/graphicsview/flowlayout/window.h
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui/qgraphicswidget.h>
+#include <QtWidgets/qgraphicswidget.h>
class Window : public QGraphicsWidget {
Q_OBJECT
diff --git a/examples/graphicsview/graphicsview.pro b/examples/graphicsview/graphicsview.pro
index a1458ded91..53ad3d67a2 100644
--- a/examples/graphicsview/graphicsview.pro
+++ b/examples/graphicsview/graphicsview.pro
@@ -22,3 +22,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/graphicsview/padnavigator/flippablepad.cpp b/examples/graphicsview/padnavigator/flippablepad.cpp
index ada44dad8f..78f8281afd 100644
--- a/examples/graphicsview/padnavigator/flippablepad.cpp
+++ b/examples/graphicsview/padnavigator/flippablepad.cpp
@@ -40,7 +40,7 @@
#include "flippablepad.h"
-#include <QtGui/QtGui>
+#include <QtWidgets/QtWidgets>
//! [0]
static QRectF boundsFromSize(const QSize &size)
diff --git a/examples/graphicsview/padnavigator/main.cpp b/examples/graphicsview/padnavigator/main.cpp
index 8f4a681743..5552ba511b 100644
--- a/examples/graphicsview/padnavigator/main.cpp
+++ b/examples/graphicsview/padnavigator/main.cpp
@@ -40,7 +40,7 @@
#include "padnavigator.h"
-#include <QtGui/QtGui>
+#include <QtWidgets/QtWidgets>
//! [0]
int main(int argc, char *argv[])
diff --git a/examples/graphicsview/padnavigator/padnavigator.cpp b/examples/graphicsview/padnavigator/padnavigator.cpp
index 3e57dcfbe6..b714ebfb71 100644
--- a/examples/graphicsview/padnavigator/padnavigator.cpp
+++ b/examples/graphicsview/padnavigator/padnavigator.cpp
@@ -42,7 +42,7 @@
#include "padnavigator.h"
#include "splashitem.h"
-#include <QtGui/QtGui>
+#include <QtWidgets/QtWidgets>
#ifndef QT_NO_OPENGL
#include <QtOpenGL/QtOpenGL>
#endif
diff --git a/examples/graphicsview/padnavigator/padnavigator.pro b/examples/graphicsview/padnavigator/padnavigator.pro
index 45ebfdcf2a..28c636fc74 100644
--- a/examples/graphicsview/padnavigator/padnavigator.pro
+++ b/examples/graphicsview/padnavigator/padnavigator.pro
@@ -16,7 +16,7 @@ RESOURCES += \
FORMS += \
form.ui
-contains(QT_CONFIG, opengl):QT += opengl
+contains(QT_CONFIG, opengl):QT += opengl widgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/padnavigator
diff --git a/examples/graphicsview/padnavigator/roundrectitem.cpp b/examples/graphicsview/padnavigator/roundrectitem.cpp
index 643770f4c6..0103de47fe 100644
--- a/examples/graphicsview/padnavigator/roundrectitem.cpp
+++ b/examples/graphicsview/padnavigator/roundrectitem.cpp
@@ -40,7 +40,7 @@
#include "roundrectitem.h"
-#include <QtGui/QtGui>
+#include <QtWidgets/QtWidgets>
//! [0]
RoundRectItem::RoundRectItem(const QRectF &bounds, const QColor &color,
diff --git a/examples/graphicsview/padnavigator/splashitem.cpp b/examples/graphicsview/padnavigator/splashitem.cpp
index 8cedcd6e60..ee3b38c1a9 100644
--- a/examples/graphicsview/padnavigator/splashitem.cpp
+++ b/examples/graphicsview/padnavigator/splashitem.cpp
@@ -40,7 +40,7 @@
#include "splashitem.h"
-#include <QtGui/QtGui>
+#include <QtWidgets/QtWidgets>
//! [0]
SplashItem::SplashItem(QGraphicsItem *parent)
diff --git a/examples/graphicsview/simpleanchorlayout/main.cpp b/examples/graphicsview/simpleanchorlayout/main.cpp
index 4fa837f540..fe5786fa7a 100644
--- a/examples/graphicsview/simpleanchorlayout/main.cpp
+++ b/examples/graphicsview/simpleanchorlayout/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
class Widget : public QGraphicsWidget
{
diff --git a/examples/graphicsview/simpleanchorlayout/simpleanchorlayout.pro b/examples/graphicsview/simpleanchorlayout/simpleanchorlayout.pro
index f85ad8f3a7..adb4c02b42 100644
--- a/examples/graphicsview/simpleanchorlayout/simpleanchorlayout.pro
+++ b/examples/graphicsview/simpleanchorlayout/simpleanchorlayout.pro
@@ -7,3 +7,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/simpleanchorlayout
INSTALLS += target sources
TARGET = simpleanchorlayout
+QT += widgets
diff --git a/examples/graphicsview/weatheranchorlayout/weatheranchorlayout.pro b/examples/graphicsview/weatheranchorlayout/weatheranchorlayout.pro
index 57e154e27a..444346d310 100644
--- a/examples/graphicsview/weatheranchorlayout/weatheranchorlayout.pro
+++ b/examples/graphicsview/weatheranchorlayout/weatheranchorlayout.pro
@@ -12,3 +12,4 @@ sources.files = $$SOURCES $$HEADERS $$RESOURCES weatheranchorlayout.pro images
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/graphicsview/weatheranchorlayout
INSTALLS += target sources
+QT += widgets
diff --git a/examples/ipc/ipc.pro b/examples/ipc/ipc.pro
index ed20b2627c..ba004bb03a 100644
--- a/examples/ipc/ipc.pro
+++ b/examples/ipc/ipc.pro
@@ -9,3 +9,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/ipc
INSTALLS += sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/ipc/localfortuneclient/client.cpp b/examples/ipc/localfortuneclient/client.cpp
index c8c3fe4f35..d6249849d8 100644
--- a/examples/ipc/localfortuneclient/client.cpp
+++ b/examples/ipc/localfortuneclient/client.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QtNetwork>
#include "client.h"
diff --git a/examples/ipc/localfortuneclient/localfortuneclient.pro b/examples/ipc/localfortuneclient/localfortuneclient.pro
index a66d4b2eca..73fac17569 100644
--- a/examples/ipc/localfortuneclient/localfortuneclient.pro
+++ b/examples/ipc/localfortuneclient/localfortuneclient.pro
@@ -1,7 +1,7 @@
HEADERS = client.h
SOURCES = client.cpp \
main.cpp
-QT += network
+QT += network widgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/ipc/localfortuneclient
diff --git a/examples/ipc/localfortuneserver/localfortuneserver.pro b/examples/ipc/localfortuneserver/localfortuneserver.pro
index ae09d8007c..eb51371ae5 100644
--- a/examples/ipc/localfortuneserver/localfortuneserver.pro
+++ b/examples/ipc/localfortuneserver/localfortuneserver.pro
@@ -1,7 +1,7 @@
HEADERS = server.h
SOURCES = server.cpp \
main.cpp
-QT += network
+QT += network widgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/ipc/localfortuneserver
diff --git a/examples/ipc/localfortuneserver/server.cpp b/examples/ipc/localfortuneserver/server.cpp
index 88784d440e..493f4d269b 100644
--- a/examples/ipc/localfortuneserver/server.cpp
+++ b/examples/ipc/localfortuneserver/server.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QtNetwork>
#include <stdlib.h>
diff --git a/examples/ipc/sharedmemory/sharedmemory.pro b/examples/ipc/sharedmemory/sharedmemory.pro
index 252fb29ca1..f448d98a21 100644
--- a/examples/ipc/sharedmemory/sharedmemory.pro
+++ b/examples/ipc/sharedmemory/sharedmemory.pro
@@ -13,3 +13,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/ipc/sharedmemory
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/itemviews/addressbook/adddialog.cpp b/examples/itemviews/addressbook/adddialog.cpp
index 551e729f9b..c5baddd1ea 100644
--- a/examples/itemviews/addressbook/adddialog.cpp
+++ b/examples/itemviews/addressbook/adddialog.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "adddialog.h"
//! [0]
diff --git a/examples/itemviews/addressbook/addressbook.pro b/examples/itemviews/addressbook/addressbook.pro
index 21a9f329b9..5754c47d30 100644
--- a/examples/itemviews/addressbook/addressbook.pro
+++ b/examples/itemviews/addressbook/addressbook.pro
@@ -20,3 +20,4 @@ symbian {
TARGET.UID3 = 0xA000A646
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/itemviews/addressbook/addresswidget.cpp b/examples/itemviews/addressbook/addresswidget.cpp
index 40b71f13fd..d9d3f46fed 100644
--- a/examples/itemviews/addressbook/addresswidget.cpp
+++ b/examples/itemviews/addressbook/addresswidget.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addresswidget.h"
#include "adddialog.h"
diff --git a/examples/itemviews/addressbook/main.cpp b/examples/itemviews/addressbook/main.cpp
index 455b275dfb..0a0ccb7ac8 100644
--- a/examples/itemviews/addressbook/main.cpp
+++ b/examples/itemviews/addressbook/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
//! [0]
diff --git a/examples/itemviews/addressbook/mainwindow.cpp b/examples/itemviews/addressbook/mainwindow.cpp
index 336da30d30..0a08b726bb 100644
--- a/examples/itemviews/addressbook/mainwindow.cpp
+++ b/examples/itemviews/addressbook/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
//! [0]
diff --git a/examples/itemviews/addressbook/mainwindow.h b/examples/itemviews/addressbook/mainwindow.h
index 0134c032bd..4f925dd1e4 100644
--- a/examples/itemviews/addressbook/mainwindow.h
+++ b/examples/itemviews/addressbook/mainwindow.h
@@ -41,7 +41,7 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
-#include <QtGui>
+#include <QtWidgets>
#include "addresswidget.h"
//! [0]
diff --git a/examples/itemviews/addressbook/newaddresstab.cpp b/examples/itemviews/addressbook/newaddresstab.cpp
index f3622604ab..3a720f6cb4 100644
--- a/examples/itemviews/addressbook/newaddresstab.cpp
+++ b/examples/itemviews/addressbook/newaddresstab.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "newaddresstab.h"
#include "adddialog.h"
diff --git a/examples/itemviews/basicsortfiltermodel/basicsortfiltermodel.pro b/examples/itemviews/basicsortfiltermodel/basicsortfiltermodel.pro
index da06113587..e4f0481e0e 100644
--- a/examples/itemviews/basicsortfiltermodel/basicsortfiltermodel.pro
+++ b/examples/itemviews/basicsortfiltermodel/basicsortfiltermodel.pro
@@ -10,3 +10,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/basicsortfiltermodel
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/itemviews/basicsortfiltermodel/main.cpp b/examples/itemviews/basicsortfiltermodel/main.cpp
index 84cfd05478..8f8a2a7205 100644
--- a/examples/itemviews/basicsortfiltermodel/main.cpp
+++ b/examples/itemviews/basicsortfiltermodel/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "window.h"
diff --git a/examples/itemviews/basicsortfiltermodel/window.cpp b/examples/itemviews/basicsortfiltermodel/window.cpp
index f35c1e18f6..da3da56829 100644
--- a/examples/itemviews/basicsortfiltermodel/window.cpp
+++ b/examples/itemviews/basicsortfiltermodel/window.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "window.h"
diff --git a/examples/itemviews/chart/chart.pro b/examples/itemviews/chart/chart.pro
index 3da23d4038..81f1f5509a 100644
--- a/examples/itemviews/chart/chart.pro
+++ b/examples/itemviews/chart/chart.pro
@@ -18,3 +18,4 @@ symbian {
TARGET.UID3 = 0xA000A647
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/itemviews/chart/mainwindow.cpp b/examples/itemviews/chart/mainwindow.cpp
index df6f01abc2..b98057e2e3 100644
--- a/examples/itemviews/chart/mainwindow.cpp
+++ b/examples/itemviews/chart/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "pieview.h"
#include "mainwindow.h"
diff --git a/examples/itemviews/chart/pieview.cpp b/examples/itemviews/chart/pieview.cpp
index 75c47ac5e9..ff6306e9ea 100644
--- a/examples/itemviews/chart/pieview.cpp
+++ b/examples/itemviews/chart/pieview.cpp
@@ -39,7 +39,7 @@
****************************************************************************/
#include <math.h>
-#include <QtGui>
+#include <QtWidgets>
#ifndef M_PI
#define M_PI 3.1415927
diff --git a/examples/itemviews/coloreditorfactory/coloreditorfactory.pro b/examples/itemviews/coloreditorfactory/coloreditorfactory.pro
index 3147375a45..ab4503bbad 100644
--- a/examples/itemviews/coloreditorfactory/coloreditorfactory.pro
+++ b/examples/itemviews/coloreditorfactory/coloreditorfactory.pro
@@ -11,3 +11,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/coloreditorfactory
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/itemviews/coloreditorfactory/colorlisteditor.cpp b/examples/itemviews/coloreditorfactory/colorlisteditor.cpp
index d8ce45b5ab..ee540c603c 100644
--- a/examples/itemviews/coloreditorfactory/colorlisteditor.cpp
+++ b/examples/itemviews/coloreditorfactory/colorlisteditor.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "colorlisteditor.h"
diff --git a/examples/itemviews/coloreditorfactory/main.cpp b/examples/itemviews/coloreditorfactory/main.cpp
index aa46cc5c53..bbb1d25933 100644
--- a/examples/itemviews/coloreditorfactory/main.cpp
+++ b/examples/itemviews/coloreditorfactory/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "window.h"
diff --git a/examples/itemviews/coloreditorfactory/window.cpp b/examples/itemviews/coloreditorfactory/window.cpp
index f234af1367..aa7e9377b5 100644
--- a/examples/itemviews/coloreditorfactory/window.cpp
+++ b/examples/itemviews/coloreditorfactory/window.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "window.h"
#include "colorlisteditor.h"
diff --git a/examples/itemviews/combowidgetmapper/combowidgetmapper.pro b/examples/itemviews/combowidgetmapper/combowidgetmapper.pro
index 5a0d562003..a3ecc3d691 100644
--- a/examples/itemviews/combowidgetmapper/combowidgetmapper.pro
+++ b/examples/itemviews/combowidgetmapper/combowidgetmapper.pro
@@ -7,3 +7,4 @@ 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/window.cpp b/examples/itemviews/combowidgetmapper/window.cpp
index 667fc4b8d2..8721a6a8e6 100644
--- a/examples/itemviews/combowidgetmapper/window.cpp
+++ b/examples/itemviews/combowidgetmapper/window.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "window.h"
//! [Set up widgets]
diff --git a/examples/itemviews/customsortfiltermodel/customsortfiltermodel.pro b/examples/itemviews/customsortfiltermodel/customsortfiltermodel.pro
index e04c5dfaae..cfa1af1801 100644
--- a/examples/itemviews/customsortfiltermodel/customsortfiltermodel.pro
+++ b/examples/itemviews/customsortfiltermodel/customsortfiltermodel.pro
@@ -12,3 +12,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/customsortfiltermodel
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/itemviews/customsortfiltermodel/main.cpp b/examples/itemviews/customsortfiltermodel/main.cpp
index b35b847663..34be2f682b 100644
--- a/examples/itemviews/customsortfiltermodel/main.cpp
+++ b/examples/itemviews/customsortfiltermodel/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "window.h"
diff --git a/examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp b/examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp
index 7e91444997..358546350c 100644
--- a/examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp
+++ b/examples/itemviews/customsortfiltermodel/mysortfilterproxymodel.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mysortfilterproxymodel.h"
diff --git a/examples/itemviews/customsortfiltermodel/window.cpp b/examples/itemviews/customsortfiltermodel/window.cpp
index 555e854044..1228d7565d 100644
--- a/examples/itemviews/customsortfiltermodel/window.cpp
+++ b/examples/itemviews/customsortfiltermodel/window.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mysortfilterproxymodel.h"
#include "window.h"
diff --git a/examples/itemviews/dirview/dirview.pro b/examples/itemviews/dirview/dirview.pro
index 28be5d782d..cd5ea0afb9 100644
--- a/examples/itemviews/dirview/dirview.pro
+++ b/examples/itemviews/dirview/dirview.pro
@@ -7,3 +7,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/dirview
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/itemviews/dirview/main.cpp b/examples/itemviews/dirview/main.cpp
index ffa287b321..dbb5b7ae8c 100644
--- a/examples/itemviews/dirview/main.cpp
+++ b/examples/itemviews/dirview/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
int main(int argc, char *argv[])
{
diff --git a/examples/itemviews/editabletreemodel/editabletreemodel.pro b/examples/itemviews/editabletreemodel/editabletreemodel.pro
index 6ed901c4a4..4797f19c6e 100644
--- a/examples/itemviews/editabletreemodel/editabletreemodel.pro
+++ b/examples/itemviews/editabletreemodel/editabletreemodel.pro
@@ -16,3 +16,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/editabletreemodel
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/itemviews/editabletreemodel/main.cpp b/examples/itemviews/editabletreemodel/main.cpp
index b6e6b0277d..5a2cc77465 100644
--- a/examples/itemviews/editabletreemodel/main.cpp
+++ b/examples/itemviews/editabletreemodel/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
diff --git a/examples/itemviews/editabletreemodel/mainwindow.cpp b/examples/itemviews/editabletreemodel/mainwindow.cpp
index 6f08ced0e9..380796d96a 100644
--- a/examples/itemviews/editabletreemodel/mainwindow.cpp
+++ b/examples/itemviews/editabletreemodel/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
#include "treemodel.h"
diff --git a/examples/itemviews/editabletreemodel/treemodel.cpp b/examples/itemviews/editabletreemodel/treemodel.cpp
index 8b44438623..34168137fa 100644
--- a/examples/itemviews/editabletreemodel/treemodel.cpp
+++ b/examples/itemviews/editabletreemodel/treemodel.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "treeitem.h"
#include "treemodel.h"
diff --git a/examples/itemviews/fetchmore/fetchmore.pro b/examples/itemviews/fetchmore/fetchmore.pro
index 2951d93faf..28af7e9ac0 100644
--- a/examples/itemviews/fetchmore/fetchmore.pro
+++ b/examples/itemviews/fetchmore/fetchmore.pro
@@ -10,3 +10,4 @@ sources.files = $$SOURCES $$HEADERS *.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/fetchmore
INSTALLS += target sources
+QT += widgets
diff --git a/examples/itemviews/fetchmore/window.cpp b/examples/itemviews/fetchmore/window.cpp
index 29dbf12b21..676a4ae1a8 100644
--- a/examples/itemviews/fetchmore/window.cpp
+++ b/examples/itemviews/fetchmore/window.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "filelistmodel.h"
#include "window.h"
diff --git a/examples/itemviews/frozencolumn/freezetablewidget.cpp b/examples/itemviews/frozencolumn/freezetablewidget.cpp
index 357d387321..f76575a86d 100644
--- a/examples/itemviews/frozencolumn/freezetablewidget.cpp
+++ b/examples/itemviews/frozencolumn/freezetablewidget.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "freezetablewidget.h"
diff --git a/examples/itemviews/frozencolumn/frozencolumn.pro b/examples/itemviews/frozencolumn/frozencolumn.pro
index a055fd93c0..19b2880a83 100644
--- a/examples/itemviews/frozencolumn/frozencolumn.pro
+++ b/examples/itemviews/frozencolumn/frozencolumn.pro
@@ -7,3 +7,4 @@ 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/itemviews.pro b/examples/itemviews/itemviews.pro
index 68fbc91c8c..1db97e2c02 100644
--- a/examples/itemviews/itemviews.pro
+++ b/examples/itemviews/itemviews.pro
@@ -27,3 +27,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews
INSTALLS += sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/itemviews/pixelator/imagemodel.cpp b/examples/itemviews/pixelator/imagemodel.cpp
index abf92ddef5..d0e315978b 100644
--- a/examples/itemviews/pixelator/imagemodel.cpp
+++ b/examples/itemviews/pixelator/imagemodel.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "imagemodel.h"
diff --git a/examples/itemviews/pixelator/mainwindow.cpp b/examples/itemviews/pixelator/mainwindow.cpp
index 62c6830313..7df4c0b126 100644
--- a/examples/itemviews/pixelator/mainwindow.cpp
+++ b/examples/itemviews/pixelator/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "imagemodel.h"
#include "mainwindow.h"
diff --git a/examples/itemviews/pixelator/pixelator.pro b/examples/itemviews/pixelator/pixelator.pro
index 2f71d34158..6704374e57 100644
--- a/examples/itemviews/pixelator/pixelator.pro
+++ b/examples/itemviews/pixelator/pixelator.pro
@@ -14,3 +14,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/pixelator
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/itemviews/pixelator/pixeldelegate.cpp b/examples/itemviews/pixelator/pixeldelegate.cpp
index 9ec88e614c..2ba4722ff4 100644
--- a/examples/itemviews/pixelator/pixeldelegate.cpp
+++ b/examples/itemviews/pixelator/pixeldelegate.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "pixeldelegate.h"
diff --git a/examples/itemviews/puzzle/mainwindow.cpp b/examples/itemviews/puzzle/mainwindow.cpp
index 4d6da116bf..c72fe2b08b 100644
--- a/examples/itemviews/puzzle/mainwindow.cpp
+++ b/examples/itemviews/puzzle/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <stdlib.h>
#include "mainwindow.h"
diff --git a/examples/itemviews/puzzle/piecesmodel.cpp b/examples/itemviews/puzzle/piecesmodel.cpp
index 4235050d9d..6c95a86c56 100644
--- a/examples/itemviews/puzzle/piecesmodel.cpp
+++ b/examples/itemviews/puzzle/piecesmodel.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "piecesmodel.h"
diff --git a/examples/itemviews/puzzle/puzzle.pro b/examples/itemviews/puzzle/puzzle.pro
index 16cbc5e72c..f45bbb70d3 100644
--- a/examples/itemviews/puzzle/puzzle.pro
+++ b/examples/itemviews/puzzle/puzzle.pro
@@ -19,3 +19,4 @@ wince* {
DEPLOYMENT_PLUGIN += qjpeg qgif qtiff
}
+QT += widgets
diff --git a/examples/itemviews/puzzle/puzzlewidget.cpp b/examples/itemviews/puzzle/puzzlewidget.cpp
index a0d769d20a..1b78a1ba63 100644
--- a/examples/itemviews/puzzle/puzzlewidget.cpp
+++ b/examples/itemviews/puzzle/puzzlewidget.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "puzzlewidget.h"
diff --git a/examples/itemviews/simpledommodel/dommodel.cpp b/examples/itemviews/simpledommodel/dommodel.cpp
index 7a5e9ca5c0..2a04f7a840 100644
--- a/examples/itemviews/simpledommodel/dommodel.cpp
+++ b/examples/itemviews/simpledommodel/dommodel.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QtXml>
#include "domitem.h"
diff --git a/examples/itemviews/simpledommodel/mainwindow.cpp b/examples/itemviews/simpledommodel/mainwindow.cpp
index 9803726d9f..11517c124b 100644
--- a/examples/itemviews/simpledommodel/mainwindow.cpp
+++ b/examples/itemviews/simpledommodel/mainwindow.cpp
@@ -40,7 +40,7 @@
#include <QDomDocument>
#include <QFile>
-#include <QtGui>
+#include <QtWidgets>
#include "dommodel.h"
#include "mainwindow.h"
diff --git a/examples/itemviews/simpledommodel/simpledommodel.pro b/examples/itemviews/simpledommodel/simpledommodel.pro
index a0b8f06794..ece9ef9505 100644
--- a/examples/itemviews/simpledommodel/simpledommodel.pro
+++ b/examples/itemviews/simpledommodel/simpledommodel.pro
@@ -6,7 +6,7 @@ SOURCES = domitem.cpp \
main.cpp \
mainwindow.cpp
CONFIG += qt
-QT += xml
+QT += xml widgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/simpledommodel
diff --git a/examples/itemviews/simpletreemodel/main.cpp b/examples/itemviews/simpletreemodel/main.cpp
index b14b52498b..1cca36328f 100644
--- a/examples/itemviews/simpletreemodel/main.cpp
+++ b/examples/itemviews/simpletreemodel/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "treemodel.h"
diff --git a/examples/itemviews/simpletreemodel/simpletreemodel.pro b/examples/itemviews/simpletreemodel/simpletreemodel.pro
index 3ff238ba03..50053b1f65 100644
--- a/examples/itemviews/simpletreemodel/simpletreemodel.pro
+++ b/examples/itemviews/simpletreemodel/simpletreemodel.pro
@@ -13,3 +13,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/simpletreemodel
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/itemviews/simpletreemodel/treemodel.cpp b/examples/itemviews/simpletreemodel/treemodel.cpp
index 3041d3b1ef..de5b6f8d6e 100644
--- a/examples/itemviews/simpletreemodel/treemodel.cpp
+++ b/examples/itemviews/simpletreemodel/treemodel.cpp
@@ -45,7 +45,7 @@
models.
*/
-#include <QtGui>
+#include <QtWidgets>
#include "treeitem.h"
#include "treemodel.h"
diff --git a/examples/itemviews/simplewidgetmapper/simplewidgetmapper.pro b/examples/itemviews/simplewidgetmapper/simplewidgetmapper.pro
index 0be57ba7e3..4f6008cacd 100644
--- a/examples/itemviews/simplewidgetmapper/simplewidgetmapper.pro
+++ b/examples/itemviews/simplewidgetmapper/simplewidgetmapper.pro
@@ -9,3 +9,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/simplewidgetmapper
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/itemviews/simplewidgetmapper/window.cpp b/examples/itemviews/simplewidgetmapper/window.cpp
index a6ed1bc984..c3331b689d 100644
--- a/examples/itemviews/simplewidgetmapper/window.cpp
+++ b/examples/itemviews/simplewidgetmapper/window.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "window.h"
diff --git a/examples/itemviews/spinboxdelegate/delegate.cpp b/examples/itemviews/spinboxdelegate/delegate.cpp
index 7837cbf670..ecc4f3eb3b 100644
--- a/examples/itemviews/spinboxdelegate/delegate.cpp
+++ b/examples/itemviews/spinboxdelegate/delegate.cpp
@@ -45,7 +45,7 @@
using a spin box widget.
*/
-#include <QtGui>
+#include <QtWidgets>
#include "delegate.h"
diff --git a/examples/itemviews/spinboxdelegate/spinboxdelegate.pro b/examples/itemviews/spinboxdelegate/spinboxdelegate.pro
index 561ee29538..42b852eb7a 100644
--- a/examples/itemviews/spinboxdelegate/spinboxdelegate.pro
+++ b/examples/itemviews/spinboxdelegate/spinboxdelegate.pro
@@ -9,3 +9,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/itemviews/spinboxdelegate
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/itemviews/stardelegate/main.cpp b/examples/itemviews/stardelegate/main.cpp
index 1af54d0d84..78245d005b 100644
--- a/examples/itemviews/stardelegate/main.cpp
+++ b/examples/itemviews/stardelegate/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "stardelegate.h"
#include "stareditor.h"
diff --git a/examples/itemviews/stardelegate/stardelegate.cpp b/examples/itemviews/stardelegate/stardelegate.cpp
index c784da2ffd..687ae0da2d 100644
--- a/examples/itemviews/stardelegate/stardelegate.cpp
+++ b/examples/itemviews/stardelegate/stardelegate.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "stardelegate.h"
#include "stareditor.h"
diff --git a/examples/itemviews/stardelegate/stardelegate.pro b/examples/itemviews/stardelegate/stardelegate.pro
index 9e710f0bad..c4dd65dd00 100644
--- a/examples/itemviews/stardelegate/stardelegate.pro
+++ b/examples/itemviews/stardelegate/stardelegate.pro
@@ -14,3 +14,4 @@ INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/itemviews/stardelegate/stareditor.cpp b/examples/itemviews/stardelegate/stareditor.cpp
index 453c75dbb7..6a9092c058 100644
--- a/examples/itemviews/stardelegate/stareditor.cpp
+++ b/examples/itemviews/stardelegate/stareditor.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "stareditor.h"
#include "starrating.h"
diff --git a/examples/itemviews/stardelegate/starrating.cpp b/examples/itemviews/stardelegate/starrating.cpp
index 121d4a2ca1..c77a40b323 100644
--- a/examples/itemviews/stardelegate/starrating.cpp
+++ b/examples/itemviews/stardelegate/starrating.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <math.h>
#include "starrating.h"
diff --git a/examples/ja_JP/linguist/hellotr/hellotr.pro b/examples/ja_JP/linguist/hellotr/hellotr.pro
index 40d37e2472..1be6f4c141 100644
--- a/examples/ja_JP/linguist/hellotr/hellotr.pro
+++ b/examples/ja_JP/linguist/hellotr/hellotr.pro
@@ -11,3 +11,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/linguist/hellotr
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/layouts/basiclayouts/basiclayouts.pro b/examples/layouts/basiclayouts/basiclayouts.pro
index cd0552f9ff..2bbb3be0e8 100644
--- a/examples/layouts/basiclayouts/basiclayouts.pro
+++ b/examples/layouts/basiclayouts/basiclayouts.pro
@@ -9,3 +9,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/layouts/basiclayouts
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/layouts/basiclayouts/dialog.cpp b/examples/layouts/basiclayouts/dialog.cpp
index e3cbc08948..91ae01cb0d 100644
--- a/examples/layouts/basiclayouts/dialog.cpp
+++ b/examples/layouts/basiclayouts/dialog.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "dialog.h"
diff --git a/examples/layouts/borderlayout/borderlayout.cpp b/examples/layouts/borderlayout/borderlayout.cpp
index e6c2bbc79e..c83ce0e476 100644
--- a/examples/layouts/borderlayout/borderlayout.cpp
+++ b/examples/layouts/borderlayout/borderlayout.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "borderlayout.h"
diff --git a/examples/layouts/borderlayout/borderlayout.pro b/examples/layouts/borderlayout/borderlayout.pro
index 6ddbb94f92..3880d876d2 100644
--- a/examples/layouts/borderlayout/borderlayout.pro
+++ b/examples/layouts/borderlayout/borderlayout.pro
@@ -11,3 +11,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/layouts/borderlayout
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/layouts/borderlayout/window.cpp b/examples/layouts/borderlayout/window.cpp
index da32600114..7501a7296c 100644
--- a/examples/layouts/borderlayout/window.cpp
+++ b/examples/layouts/borderlayout/window.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "borderlayout.h"
#include "window.h"
diff --git a/examples/layouts/dynamiclayouts/dialog.cpp b/examples/layouts/dynamiclayouts/dialog.cpp
index 58711bee7f..6e4f1efebc 100644
--- a/examples/layouts/dynamiclayouts/dialog.cpp
+++ b/examples/layouts/dynamiclayouts/dialog.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "dialog.h"
diff --git a/examples/layouts/dynamiclayouts/dynamiclayouts.pro b/examples/layouts/dynamiclayouts/dynamiclayouts.pro
index e0fbecceca..2ebe42a8dd 100644
--- a/examples/layouts/dynamiclayouts/dynamiclayouts.pro
+++ b/examples/layouts/dynamiclayouts/dynamiclayouts.pro
@@ -9,3 +9,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/layouts/dynamiclayouts
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/layouts/flowlayout/flowlayout.cpp b/examples/layouts/flowlayout/flowlayout.cpp
index b570af8e78..ddca09b71b 100644
--- a/examples/layouts/flowlayout/flowlayout.cpp
+++ b/examples/layouts/flowlayout/flowlayout.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "flowlayout.h"
//! [1]
diff --git a/examples/layouts/flowlayout/flowlayout.pro b/examples/layouts/flowlayout/flowlayout.pro
index 6d1a160cf6..ccc8481a68 100644
--- a/examples/layouts/flowlayout/flowlayout.pro
+++ b/examples/layouts/flowlayout/flowlayout.pro
@@ -11,3 +11,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/layouts/flowlayout
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/layouts/flowlayout/window.cpp b/examples/layouts/flowlayout/window.cpp
index 51f09a8b83..f5f6e293b2 100644
--- a/examples/layouts/flowlayout/window.cpp
+++ b/examples/layouts/flowlayout/window.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "flowlayout.h"
#include "window.h"
diff --git a/examples/layouts/layouts.pro b/examples/layouts/layouts.pro
index 65bf7f235a..58bde873a4 100644
--- a/examples/layouts/layouts.pro
+++ b/examples/layouts/layouts.pro
@@ -10,3 +10,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/layouts
INSTALLS += sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/linguist/arrowpad/arrowpad.cpp b/examples/linguist/arrowpad/arrowpad.cpp
index 1a5357a3ca..12e41474bf 100644
--- a/examples/linguist/arrowpad/arrowpad.cpp
+++ b/examples/linguist/arrowpad/arrowpad.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "arrowpad.h"
diff --git a/examples/linguist/arrowpad/arrowpad.pro b/examples/linguist/arrowpad/arrowpad.pro
index e1ff6f648d..77ee6ac70e 100644
--- a/examples/linguist/arrowpad/arrowpad.pro
+++ b/examples/linguist/arrowpad/arrowpad.pro
@@ -16,3 +16,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/linguist/arrowpad
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/linguist/arrowpad/main.cpp b/examples/linguist/arrowpad/main.cpp
index dc8cae8251..23f62b2ebf 100644
--- a/examples/linguist/arrowpad/main.cpp
+++ b/examples/linguist/arrowpad/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
diff --git a/examples/linguist/arrowpad/mainwindow.cpp b/examples/linguist/arrowpad/mainwindow.cpp
index 8c3ccf2fd3..9e141904cd 100644
--- a/examples/linguist/arrowpad/mainwindow.cpp
+++ b/examples/linguist/arrowpad/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "arrowpad.h"
#include "mainwindow.h"
diff --git a/examples/linguist/hellotr/hellotr.pro b/examples/linguist/hellotr/hellotr.pro
index 9c03bdc3e0..2c258a2d5b 100644
--- a/examples/linguist/hellotr/hellotr.pro
+++ b/examples/linguist/hellotr/hellotr.pro
@@ -11,3 +11,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/linguist/hellotr
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/linguist/linguist.pro b/examples/linguist/linguist.pro
index 7de32ef2ec..d335e6ac27 100644
--- a/examples/linguist/linguist.pro
+++ b/examples/linguist/linguist.pro
@@ -9,3 +9,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/linguist
INSTALLS += sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/linguist/trollprint/main.cpp b/examples/linguist/trollprint/main.cpp
index 92f163002c..b2f2131927 100644
--- a/examples/linguist/trollprint/main.cpp
+++ b/examples/linguist/trollprint/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
diff --git a/examples/linguist/trollprint/mainwindow.cpp b/examples/linguist/trollprint/mainwindow.cpp
index 4ea0db1733..337b7aa8c4 100644
--- a/examples/linguist/trollprint/mainwindow.cpp
+++ b/examples/linguist/trollprint/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
#include "printpanel.h"
diff --git a/examples/linguist/trollprint/printpanel.cpp b/examples/linguist/trollprint/printpanel.cpp
index af1ff53193..74ddc18b59 100644
--- a/examples/linguist/trollprint/printpanel.cpp
+++ b/examples/linguist/trollprint/printpanel.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "printpanel.h"
diff --git a/examples/linguist/trollprint/trollprint.pro b/examples/linguist/trollprint/trollprint.pro
index fe3dc20e59..50524c29ed 100644
--- a/examples/linguist/trollprint/trollprint.pro
+++ b/examples/linguist/trollprint/trollprint.pro
@@ -12,3 +12,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/linguist/trollprint
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/mainwindows/application/application.pro b/examples/mainwindows/application/application.pro
index 10b2b84219..f98d3afd3c 100644
--- a/examples/mainwindows/application/application.pro
+++ b/examples/mainwindows/application/application.pro
@@ -12,3 +12,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/application
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/mainwindows/application/mainwindow.cpp b/examples/mainwindows/application/mainwindow.cpp
index 4ebc5c169e..fd8fa97e68 100644
--- a/examples/mainwindows/application/mainwindow.cpp
+++ b/examples/mainwindows/application/mainwindow.cpp
@@ -39,7 +39,7 @@
****************************************************************************/
//! [0]
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
//! [0]
diff --git a/examples/mainwindows/dockwidgets/dockwidgets.pro b/examples/mainwindows/dockwidgets/dockwidgets.pro
index daba00c99c..48aad1a620 100644
--- a/examples/mainwindows/dockwidgets/dockwidgets.pro
+++ b/examples/mainwindows/dockwidgets/dockwidgets.pro
@@ -10,3 +10,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/dockwidgets
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/mainwindows/dockwidgets/mainwindow.cpp b/examples/mainwindows/dockwidgets/mainwindow.cpp
index 296eec2242..5a0c1f6ad9 100644
--- a/examples/mainwindows/dockwidgets/mainwindow.cpp
+++ b/examples/mainwindows/dockwidgets/mainwindow.cpp
@@ -39,7 +39,7 @@
****************************************************************************/
//! [0]
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
//! [0]
diff --git a/examples/mainwindows/mainwindows.pro b/examples/mainwindows/mainwindows.pro
index 6471c1406a..347fedac62 100644
--- a/examples/mainwindows/mainwindows.pro
+++ b/examples/mainwindows/mainwindows.pro
@@ -17,3 +17,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/mainwindows/mdi/mainwindow.cpp b/examples/mainwindows/mdi/mainwindow.cpp
index 956eabb230..816c8094da 100644
--- a/examples/mainwindows/mdi/mainwindow.cpp
+++ b/examples/mainwindows/mdi/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
#include "mdichild.h"
diff --git a/examples/mainwindows/mdi/mdi.pro b/examples/mainwindows/mdi/mdi.pro
index 74c418b52f..45f3bfb4a8 100644
--- a/examples/mainwindows/mdi/mdi.pro
+++ b/examples/mainwindows/mdi/mdi.pro
@@ -12,3 +12,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/mdi
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/mainwindows/mdi/mdichild.cpp b/examples/mainwindows/mdi/mdichild.cpp
index 0382b27e23..0b55ee5223 100644
--- a/examples/mainwindows/mdi/mdichild.cpp
+++ b/examples/mainwindows/mdi/mdichild.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mdichild.h"
diff --git a/examples/mainwindows/menus/mainwindow.cpp b/examples/mainwindows/menus/mainwindow.cpp
index cae81f6b71..2a1c3da71d 100644
--- a/examples/mainwindows/menus/mainwindow.cpp
+++ b/examples/mainwindows/menus/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
diff --git a/examples/mainwindows/menus/menus.pro b/examples/mainwindows/menus/menus.pro
index c437f160bb..f440f35423 100644
--- a/examples/mainwindows/menus/menus.pro
+++ b/examples/mainwindows/menus/menus.pro
@@ -12,3 +12,4 @@ symbian {
TARGET.UID3 = 0xA000CF66
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/mainwindows/recentfiles/mainwindow.cpp b/examples/mainwindows/recentfiles/mainwindow.cpp
index 623c4a375c..4a8011d64a 100644
--- a/examples/mainwindows/recentfiles/mainwindow.cpp
+++ b/examples/mainwindows/recentfiles/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
diff --git a/examples/mainwindows/recentfiles/recentfiles.pro b/examples/mainwindows/recentfiles/recentfiles.pro
index a8e83ffa20..05da6f2972 100644
--- a/examples/mainwindows/recentfiles/recentfiles.pro
+++ b/examples/mainwindows/recentfiles/recentfiles.pro
@@ -9,3 +9,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/recentfiles
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/mainwindows/sdi/mainwindow.cpp b/examples/mainwindows/sdi/mainwindow.cpp
index f881118899..7ae426d68c 100644
--- a/examples/mainwindows/sdi/mainwindow.cpp
+++ b/examples/mainwindows/sdi/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
diff --git a/examples/mainwindows/sdi/sdi.pro b/examples/mainwindows/sdi/sdi.pro
index 70bbf6543c..964b791936 100644
--- a/examples/mainwindows/sdi/sdi.pro
+++ b/examples/mainwindows/sdi/sdi.pro
@@ -10,3 +10,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/mainwindows/sdi
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/network/bearermonitor/bearermonitor.pro b/examples/network/bearermonitor/bearermonitor.pro
index bd9bd68e5c..e9dbf25b98 100644
--- a/examples/network/bearermonitor/bearermonitor.pro
+++ b/examples/network/bearermonitor/bearermonitor.pro
@@ -1,5 +1,5 @@
TARGET = bearermonitor
-QT = core gui network
+QT = core gui network widgets
HEADERS = sessionwidget.h \
bearermonitor.h
diff --git a/examples/network/bearermonitor/main.cpp b/examples/network/bearermonitor/main.cpp
index 1358033fc2..cc6d918ee7 100644
--- a/examples/network/bearermonitor/main.cpp
+++ b/examples/network/bearermonitor/main.cpp
@@ -38,8 +38,8 @@
**
****************************************************************************/
-#include <QtGui/QApplication>
-#include <QtGui/QMainWindow>
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QMainWindow>
#include "bearermonitor.h"
diff --git a/examples/network/blockingfortuneclient/blockingclient.cpp b/examples/network/blockingfortuneclient/blockingclient.cpp
index f5def3d927..e4ca17a6fd 100644
--- a/examples/network/blockingfortuneclient/blockingclient.cpp
+++ b/examples/network/blockingfortuneclient/blockingclient.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QtNetwork>
#include "blockingclient.h"
diff --git a/examples/network/blockingfortuneclient/blockingfortuneclient.pro b/examples/network/blockingfortuneclient/blockingfortuneclient.pro
index 2faedaa810..29abbeb43e 100644
--- a/examples/network/blockingfortuneclient/blockingfortuneclient.pro
+++ b/examples/network/blockingfortuneclient/blockingfortuneclient.pro
@@ -1,3 +1,5 @@
+QT += widgets
+
HEADERS = blockingclient.h \
fortunethread.h
SOURCES = blockingclient.cpp \
diff --git a/examples/network/broadcastreceiver/broadcastreceiver.pro b/examples/network/broadcastreceiver/broadcastreceiver.pro
index 458585def3..d7924b870a 100644
--- a/examples/network/broadcastreceiver/broadcastreceiver.pro
+++ b/examples/network/broadcastreceiver/broadcastreceiver.pro
@@ -1,3 +1,5 @@
+QT += widgets
+
HEADERS = receiver.h
SOURCES = receiver.cpp \
main.cpp
diff --git a/examples/network/broadcastreceiver/receiver.cpp b/examples/network/broadcastreceiver/receiver.cpp
index bd45a3cb35..72a5d7023d 100644
--- a/examples/network/broadcastreceiver/receiver.cpp
+++ b/examples/network/broadcastreceiver/receiver.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QtNetwork>
#include "receiver.h"
diff --git a/examples/network/broadcastsender/broadcastsender.pro b/examples/network/broadcastsender/broadcastsender.pro
index eb76c38071..a5751d2f71 100644
--- a/examples/network/broadcastsender/broadcastsender.pro
+++ b/examples/network/broadcastsender/broadcastsender.pro
@@ -1,3 +1,5 @@
+QT += widgets
+
HEADERS = sender.h
SOURCES = sender.cpp \
main.cpp
diff --git a/examples/network/broadcastsender/sender.cpp b/examples/network/broadcastsender/sender.cpp
index d753094637..55d91d2d20 100644
--- a/examples/network/broadcastsender/sender.cpp
+++ b/examples/network/broadcastsender/sender.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QtNetwork>
#include "sender.h"
diff --git a/examples/network/fortuneclient/client.cpp b/examples/network/fortuneclient/client.cpp
index 9eab1c2371..27443659df 100644
--- a/examples/network/fortuneclient/client.cpp
+++ b/examples/network/fortuneclient/client.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QtNetwork>
#include "client.h"
diff --git a/examples/network/fortuneclient/fortuneclient.pro b/examples/network/fortuneclient/fortuneclient.pro
index 2e3ec01abb..25f2e6745e 100644
--- a/examples/network/fortuneclient/fortuneclient.pro
+++ b/examples/network/fortuneclient/fortuneclient.pro
@@ -1,3 +1,5 @@
+QT += widgets
+
HEADERS = client.h
SOURCES = client.cpp \
main.cpp
diff --git a/examples/network/fortuneserver/fortuneserver.pro b/examples/network/fortuneserver/fortuneserver.pro
index c34c565a0f..056673ae7a 100644
--- a/examples/network/fortuneserver/fortuneserver.pro
+++ b/examples/network/fortuneserver/fortuneserver.pro
@@ -1,3 +1,5 @@
+QT += widgets
+
HEADERS = server.h
SOURCES = server.cpp \
main.cpp
diff --git a/examples/network/fortuneserver/server.cpp b/examples/network/fortuneserver/server.cpp
index edb8c9398c..9ce6b650e0 100644
--- a/examples/network/fortuneserver/server.cpp
+++ b/examples/network/fortuneserver/server.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QtNetwork>
#include <stdlib.h>
diff --git a/examples/network/googlesuggest/googlesuggest.h b/examples/network/googlesuggest/googlesuggest.h
index a5d268a126..6b4abff5d9 100644
--- a/examples/network/googlesuggest/googlesuggest.h
+++ b/examples/network/googlesuggest/googlesuggest.h
@@ -41,7 +41,7 @@
#ifndef GOOGLESUGGEST_H
#define GOOGLESUGGEST_H
-#include <QtGui>
+#include <QtWidgets>
#include <QtNetwork>
#include <QObject>
diff --git a/examples/network/googlesuggest/googlesuggest.pro b/examples/network/googlesuggest/googlesuggest.pro
index e118dc9c26..58343d473a 100644
--- a/examples/network/googlesuggest/googlesuggest.pro
+++ b/examples/network/googlesuggest/googlesuggest.pro
@@ -1,4 +1,4 @@
-QT += network
+QT += network widgets
SOURCES = main.cpp searchbox.cpp googlesuggest.cpp
HEADERS = searchbox.h googlesuggest.h
diff --git a/examples/network/http/http.pro b/examples/network/http/http.pro
index 74a8e49d90..57618b3137 100644
--- a/examples/network/http/http.pro
+++ b/examples/network/http/http.pro
@@ -1,3 +1,5 @@
+QT += widgets
+
HEADERS += httpwindow.h
SOURCES += httpwindow.cpp \
main.cpp
diff --git a/examples/network/http/httpwindow.cpp b/examples/network/http/httpwindow.cpp
index 874994ab92..1eceb4927e 100644
--- a/examples/network/http/httpwindow.cpp
+++ b/examples/network/http/httpwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QtNetwork>
#include "httpwindow.h"
diff --git a/examples/network/loopback/dialog.cpp b/examples/network/loopback/dialog.cpp
index 50a191e9ee..0dc1e1f8e4 100644
--- a/examples/network/loopback/dialog.cpp
+++ b/examples/network/loopback/dialog.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QtNetwork>
#include "dialog.h"
diff --git a/examples/network/loopback/loopback.pro b/examples/network/loopback/loopback.pro
index ea175b3e3c..e8220aea40 100644
--- a/examples/network/loopback/loopback.pro
+++ b/examples/network/loopback/loopback.pro
@@ -1,3 +1,5 @@
+QT += widgets
+
HEADERS = dialog.h
SOURCES = dialog.cpp \
main.cpp
diff --git a/examples/network/multicastreceiver/multicastreceiver.pro b/examples/network/multicastreceiver/multicastreceiver.pro
index 958a13f11d..caeca7ff46 100644
--- a/examples/network/multicastreceiver/multicastreceiver.pro
+++ b/examples/network/multicastreceiver/multicastreceiver.pro
@@ -1,3 +1,5 @@
+QT += widgets
+
HEADERS = receiver.h
SOURCES = receiver.cpp \
main.cpp
diff --git a/examples/network/multicastreceiver/receiver.cpp b/examples/network/multicastreceiver/receiver.cpp
index 77446b93ff..8db3042a4e 100644
--- a/examples/network/multicastreceiver/receiver.cpp
+++ b/examples/network/multicastreceiver/receiver.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QtNetwork>
#include "receiver.h"
diff --git a/examples/network/multicastsender/multicastsender.pro b/examples/network/multicastsender/multicastsender.pro
index 479251ca0b..a0cdc61eab 100644
--- a/examples/network/multicastsender/multicastsender.pro
+++ b/examples/network/multicastsender/multicastsender.pro
@@ -1,7 +1,7 @@
HEADERS = sender.h
SOURCES = sender.cpp \
main.cpp
-QT += network
+QT += network widgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/network/multicastsender
diff --git a/examples/network/multicastsender/sender.cpp b/examples/network/multicastsender/sender.cpp
index aab94aa42a..6172f07063 100644
--- a/examples/network/multicastsender/sender.cpp
+++ b/examples/network/multicastsender/sender.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QtNetwork>
#include "sender.h"
diff --git a/examples/network/network-chat/chatdialog.cpp b/examples/network/network-chat/chatdialog.cpp
index cdb29ea518..9ad042e05f 100644
--- a/examples/network/network-chat/chatdialog.cpp
+++ b/examples/network/network-chat/chatdialog.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "chatdialog.h"
diff --git a/examples/network/network-chat/network-chat.pro b/examples/network/network-chat/network-chat.pro
index 7c1514f727..91c832d149 100644
--- a/examples/network/network-chat/network-chat.pro
+++ b/examples/network/network-chat/network-chat.pro
@@ -10,7 +10,7 @@ SOURCES = chatdialog.cpp \
peermanager.cpp \
server.cpp
FORMS = chatdialog.ui
-QT += network
+QT += network widgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/network/network-chat
diff --git a/examples/network/network.pro b/examples/network/network.pro
index 09765a622a..c705b9eb32 100644
--- a/examples/network/network.pro
+++ b/examples/network/network.pro
@@ -35,3 +35,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/network
INSTALLS += sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/network/qftp/ftpwindow.cpp b/examples/network/qftp/ftpwindow.cpp
index c3e629f4f2..562b9fe4aa 100644
--- a/examples/network/qftp/ftpwindow.cpp
+++ b/examples/network/qftp/ftpwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QtNetwork>
#include "ftpwindow.h"
diff --git a/examples/network/qftp/qftp.pro b/examples/network/qftp/qftp.pro
index 0e62d153d9..5a64e35c47 100644
--- a/examples/network/qftp/qftp.pro
+++ b/examples/network/qftp/qftp.pro
@@ -1,3 +1,5 @@
+QT += widgets
+
HEADERS = ftpwindow.h
SOURCES = ftpwindow.cpp \
main.cpp
diff --git a/examples/network/securesocketclient/certificateinfo.h b/examples/network/securesocketclient/certificateinfo.h
index 6e60ade4f0..cc5cc34e8a 100644
--- a/examples/network/securesocketclient/certificateinfo.h
+++ b/examples/network/securesocketclient/certificateinfo.h
@@ -41,7 +41,7 @@
#ifndef CERTIFICATEINFO_H
#define CERTIFICATEINFO_H
-#include <QtGui/QDialog>
+#include <QtWidgets/QDialog>
#include <QtNetwork/QSslCertificate>
QT_BEGIN_NAMESPACE
diff --git a/examples/network/securesocketclient/securesocketclient.pro b/examples/network/securesocketclient/securesocketclient.pro
index f6276dd0bf..76720b8cf3 100644
--- a/examples/network/securesocketclient/securesocketclient.pro
+++ b/examples/network/securesocketclient/securesocketclient.pro
@@ -7,7 +7,7 @@ RESOURCES += securesocketclient.qrc
FORMS += certificateinfo.ui \
sslclient.ui \
sslerrors.ui
-QT += network
+QT += network widgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/network/securesocketclient
diff --git a/examples/network/securesocketclient/sslclient.cpp b/examples/network/securesocketclient/sslclient.cpp
index 43b81cd984..7aac7b1038 100644
--- a/examples/network/securesocketclient/sslclient.cpp
+++ b/examples/network/securesocketclient/sslclient.cpp
@@ -43,9 +43,9 @@
#include "ui_sslclient.h"
#include "ui_sslerrors.h"
-#include <QtGui/QScrollBar>
-#include <QtGui/QStyle>
-#include <QtGui/QToolButton>
+#include <QtWidgets/QScrollBar>
+#include <QtWidgets/QStyle>
+#include <QtWidgets/QToolButton>
#include <QtNetwork/QSslCipher>
SslClient::SslClient(QWidget *parent)
diff --git a/examples/network/securesocketclient/sslclient.h b/examples/network/securesocketclient/sslclient.h
index 33a9a882b6..4e0bc1891f 100644
--- a/examples/network/securesocketclient/sslclient.h
+++ b/examples/network/securesocketclient/sslclient.h
@@ -41,7 +41,7 @@
#ifndef SSLCLIENT_H
#define SSLCLIENT_H
-#include <QtGui/QWidget>
+#include <QtWidgets/QWidget>
#include <QtNetwork/QAbstractSocket>
#include <QtNetwork/QSslSocket>
diff --git a/examples/network/threadedfortuneserver/dialog.cpp b/examples/network/threadedfortuneserver/dialog.cpp
index b69f42cc85..b46beadd07 100644
--- a/examples/network/threadedfortuneserver/dialog.cpp
+++ b/examples/network/threadedfortuneserver/dialog.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QtNetwork>
#include <stdlib.h>
diff --git a/examples/network/threadedfortuneserver/threadedfortuneserver.pro b/examples/network/threadedfortuneserver/threadedfortuneserver.pro
index a76974a57e..21beac7529 100644
--- a/examples/network/threadedfortuneserver/threadedfortuneserver.pro
+++ b/examples/network/threadedfortuneserver/threadedfortuneserver.pro
@@ -1,3 +1,5 @@
+QT += widgets
+
HEADERS = dialog.h \
fortuneserver.h \
fortunethread.h
diff --git a/examples/network/torrent/mainwindow.cpp b/examples/network/torrent/mainwindow.cpp
index 06dfca1ba2..3d264eb272 100644
--- a/examples/network/torrent/mainwindow.cpp
+++ b/examples/network/torrent/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addtorrentdialog.h"
#include "mainwindow.h"
diff --git a/examples/network/torrent/torrent.pro b/examples/network/torrent/torrent.pro
index 0dc3aa7950..4e2aaa68ef 100644
--- a/examples/network/torrent/torrent.pro
+++ b/examples/network/torrent/torrent.pro
@@ -1,3 +1,5 @@
+QT += widgets
+
HEADERS += addtorrentdialog.h \
bencodeparser.h \
connectionmanager.h \
diff --git a/examples/opengl/2dpainting/2dpainting.pro b/examples/opengl/2dpainting/2dpainting.pro
index 3998cf55a5..7014ce6949 100644
--- a/examples/opengl/2dpainting/2dpainting.pro
+++ b/examples/opengl/2dpainting/2dpainting.pro
@@ -1,4 +1,4 @@
-QT += opengl
+QT += opengl widgets
HEADERS = glwidget.h \
helper.h \
diff --git a/examples/opengl/2dpainting/glwidget.cpp b/examples/opengl/2dpainting/glwidget.cpp
index 8b28a6e6a3..800e947385 100644
--- a/examples/opengl/2dpainting/glwidget.cpp
+++ b/examples/opengl/2dpainting/glwidget.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "glwidget.h"
#include "helper.h"
diff --git a/examples/opengl/2dpainting/helper.cpp b/examples/opengl/2dpainting/helper.cpp
index 662a4264a7..dc18c60a4b 100644
--- a/examples/opengl/2dpainting/helper.cpp
+++ b/examples/opengl/2dpainting/helper.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "helper.h"
//! [0]
diff --git a/examples/opengl/2dpainting/widget.cpp b/examples/opengl/2dpainting/widget.cpp
index 16398147c7..35eedae240 100644
--- a/examples/opengl/2dpainting/widget.cpp
+++ b/examples/opengl/2dpainting/widget.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "widget.h"
#include "helper.h"
diff --git a/examples/opengl/2dpainting/window.cpp b/examples/opengl/2dpainting/window.cpp
index d2c8ef706c..0186670f38 100644
--- a/examples/opengl/2dpainting/window.cpp
+++ b/examples/opengl/2dpainting/window.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "glwidget.h"
#include "widget.h"
#include "window.h"
diff --git a/examples/opengl/framebufferobject2/framebufferobject2.pro b/examples/opengl/framebufferobject2/framebufferobject2.pro
index 8a26573c84..2ae20ca4b0 100644
--- a/examples/opengl/framebufferobject2/framebufferobject2.pro
+++ b/examples/opengl/framebufferobject2/framebufferobject2.pro
@@ -2,7 +2,7 @@ HEADERS += glwidget.h
SOURCES += glwidget.cpp main.cpp
RESOURCES += framebufferobject2.qrc
-QT += opengl
+QT += opengl widgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/framebufferobject2
diff --git a/examples/opengl/framebufferobject2/main.cpp b/examples/opengl/framebufferobject2/main.cpp
index 12e5a62cdd..313e683da5 100644
--- a/examples/opengl/framebufferobject2/main.cpp
+++ b/examples/opengl/framebufferobject2/main.cpp
@@ -38,8 +38,8 @@
**
****************************************************************************/
-#include <QtGui/QApplication>
-#include <QtGui/QMessageBox>
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QMessageBox>
#include "glwidget.h"
int main(int argc, char **argv)
diff --git a/examples/opengl/grabber/glwidget.cpp b/examples/opengl/grabber/glwidget.cpp
index 72039a7b66..52d0b2662a 100644
--- a/examples/opengl/grabber/glwidget.cpp
+++ b/examples/opengl/grabber/glwidget.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QtOpenGL>
#include <math.h>
diff --git a/examples/opengl/grabber/grabber.pro b/examples/opengl/grabber/grabber.pro
index 7f5c3d63c9..7c46cebf52 100644
--- a/examples/opengl/grabber/grabber.pro
+++ b/examples/opengl/grabber/grabber.pro
@@ -3,7 +3,7 @@ HEADERS = glwidget.h \
SOURCES = glwidget.cpp \
main.cpp \
mainwindow.cpp
-QT += opengl
+QT += opengl widgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/grabber
diff --git a/examples/opengl/grabber/mainwindow.cpp b/examples/opengl/grabber/mainwindow.cpp
index d2f3a98dce..965c49ab1a 100644
--- a/examples/opengl/grabber/mainwindow.cpp
+++ b/examples/opengl/grabber/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QtOpenGL>
#include "glwidget.h"
diff --git a/examples/opengl/hellogl/glwidget.cpp b/examples/opengl/hellogl/glwidget.cpp
index 59efb12368..38333d8560 100644
--- a/examples/opengl/hellogl/glwidget.cpp
+++ b/examples/opengl/hellogl/glwidget.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QtOpenGL>
#include <math.h>
diff --git a/examples/opengl/hellogl/hellogl.pro b/examples/opengl/hellogl/hellogl.pro
index 1c67fe01bd..067d330d95 100644
--- a/examples/opengl/hellogl/hellogl.pro
+++ b/examples/opengl/hellogl/hellogl.pro
@@ -8,7 +8,7 @@ SOURCES = glwidget.cpp \
main.cpp \
window.cpp \
qtlogo.cpp
-QT += opengl
+QT += opengl widgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/hellogl
diff --git a/examples/opengl/hellogl/window.cpp b/examples/opengl/hellogl/window.cpp
index ef7cc2ad09..9f7d6be68b 100644
--- a/examples/opengl/hellogl/window.cpp
+++ b/examples/opengl/hellogl/window.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "glwidget.h"
#include "window.h"
diff --git a/examples/opengl/hellogl_es/bubble.cpp b/examples/opengl/hellogl_es/bubble.cpp
index 167d9abd92..6db14e32bd 100644
--- a/examples/opengl/hellogl_es/bubble.cpp
+++ b/examples/opengl/hellogl_es/bubble.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "bubble.h"
diff --git a/examples/opengl/hellogl_es/hellogl_es.pro b/examples/opengl/hellogl_es/hellogl_es.pro
index 774bfef265..181a90409a 100644
--- a/examples/opengl/hellogl_es/hellogl_es.pro
+++ b/examples/opengl/hellogl_es/hellogl_es.pro
@@ -18,7 +18,7 @@ HEADERS += mainwindow.h
HEADERS += bubble.h
RESOURCES += texture.qrc
-QT += opengl
+QT += opengl widgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/hellogl_es
diff --git a/examples/opengl/hellogl_es2/bubble.cpp b/examples/opengl/hellogl_es2/bubble.cpp
index 167d9abd92..6db14e32bd 100644
--- a/examples/opengl/hellogl_es2/bubble.cpp
+++ b/examples/opengl/hellogl_es2/bubble.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "bubble.h"
diff --git a/examples/opengl/hellogl_es2/hellogl_es2.pro b/examples/opengl/hellogl_es2/hellogl_es2.pro
index 8016aa37b0..0f48f66233 100644
--- a/examples/opengl/hellogl_es2/hellogl_es2.pro
+++ b/examples/opengl/hellogl_es2/hellogl_es2.pro
@@ -18,7 +18,7 @@ HEADERS += mainwindow.h
HEADERS += bubble.h
RESOURCES += texture.qrc
-QT += opengl
+QT += opengl widgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/hellogl_es2
diff --git a/examples/opengl/hellowindow/hellowindow.cpp b/examples/opengl/hellowindow/hellowindow.cpp
new file mode 100644
index 0000000000..32732f72b6
--- /dev/null
+++ b/examples/opengl/hellowindow/hellowindow.cpp
@@ -0,0 +1,268 @@
+#include "hellowindow.h"
+
+#include <QWindowContext>
+
+#include <QTimer>
+
+#include <qmath.h>
+
+HelloWindow::HelloWindow()
+ : colorIndex(0)
+{
+ setSurfaceType(OpenGLSurface);
+ setWindowTitle(QLatin1String("Hello Window"));
+
+ QWindowFormat format;
+ format.setDepthBufferSize(16);
+ format.setSamples(4);
+
+ setWindowFormat(format);
+
+ setGeometry(QRect(10, 10, 640, 480));
+
+ create();
+
+ initialize();
+
+ QTimer *timer = new QTimer(this);
+ timer->start(10);
+
+ connect(timer, SIGNAL(timeout()), this, SLOT(render()));
+}
+
+void HelloWindow::mousePressEvent(QMouseEvent *)
+{
+ updateColor();
+}
+
+void HelloWindow::resizeEvent(QResizeEvent *)
+{
+ glContext()->makeCurrent();
+
+ glViewport(0, 0, geometry().width(), geometry().height());
+}
+
+void HelloWindow::updateColor()
+{
+ float colors[][4] =
+ {
+ { 0.4, 1.0, 0.0, 0.0 },
+ { 0.0, 0.4, 1.0, 0.0 }
+ };
+
+ glContext()->makeCurrent();
+
+ program.bind();
+ program.setUniformValue(colorUniform, colors[colorIndex][0], colors[colorIndex][1], colors[colorIndex][2], colors[colorIndex][3]);
+ program.release();
+
+ colorIndex++;
+ if (colorIndex >= sizeof(colors) / sizeof(colors[0]))
+ colorIndex = 0;
+}
+
+void HelloWindow::render()
+{
+ if (!glContext())
+ return;
+
+ glContext()->makeCurrent();
+
+ glClearColor(0.1f, 0.1f, 0.2f, 1.0f);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+ glFrontFace(GL_CW);
+ glCullFace(GL_FRONT);
+ glEnable(GL_CULL_FACE);
+ glEnable(GL_DEPTH_TEST);
+
+ QMatrix4x4 modelview;
+ modelview.rotate(m_fAngle, 0.0f, 1.0f, 0.0f);
+ modelview.rotate(m_fAngle, 1.0f, 0.0f, 0.0f);
+ modelview.rotate(m_fAngle, 0.0f, 0.0f, 1.0f);
+ modelview.translate(0.0f, -0.2f, 0.0f);
+
+ program.bind();
+ program.setUniformValue(matrixUniform, modelview);
+ paintQtLogo();
+ program.release();
+
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_CULL_FACE);
+
+ glContext()->swapBuffers();
+
+ m_fAngle += 1.0f;
+}
+
+void HelloWindow::paintQtLogo()
+{
+ program.enableAttributeArray(normalAttr);
+ program.enableAttributeArray(vertexAttr);
+ program.setAttributeArray(vertexAttr, vertices.constData());
+ program.setAttributeArray(normalAttr, normals.constData());
+ glDrawArrays(GL_TRIANGLES, 0, vertices.size());
+ program.disableAttributeArray(normalAttr);
+ program.disableAttributeArray(vertexAttr);
+}
+
+void HelloWindow::initialize()
+{
+ glContext()->makeCurrent();
+
+ glClearColor(0.1f, 0.1f, 0.2f, 1.0f);
+
+ QGLShader *vshader = new QGLShader(QGLShader::Vertex, this);
+ const char *vsrc =
+ "attribute highp vec4 vertex;\n"
+ "attribute mediump vec3 normal;\n"
+ "uniform mediump mat4 matrix;\n"
+ "uniform lowp vec4 sourceColor;\n"
+ "varying mediump vec4 color;\n"
+ "void main(void)\n"
+ "{\n"
+ " vec3 toLight = normalize(vec3(0.0, 0.3, 1.0));\n"
+ " float angle = max(dot(normal, toLight), 0.0);\n"
+ " vec3 col = sourceColor.rgb;\n"
+ " color = vec4(col * 0.2 + col * 0.8 * angle, 1.0);\n"
+ " color = clamp(color, 0.0, 1.0);\n"
+ " gl_Position = matrix * vertex;\n"
+ "}\n";
+ vshader->compileSourceCode(vsrc);
+
+ QGLShader *fshader = new QGLShader(QGLShader::Fragment, this);
+ const char *fsrc =
+ "varying mediump vec4 color;\n"
+ "void main(void)\n"
+ "{\n"
+ " gl_FragColor = color;\n"
+ "}\n";
+ fshader->compileSourceCode(fsrc);
+
+ program.addShader(vshader);
+ program.addShader(fshader);
+ program.link();
+
+ vertexAttr = program.attributeLocation("vertex");
+ normalAttr = program.attributeLocation("normal");
+ matrixUniform = program.uniformLocation("matrix");
+ colorUniform = program.uniformLocation("sourceColor");
+
+ m_fAngle = 0;
+ createGeometry();
+ updateColor();
+}
+
+void HelloWindow::createGeometry()
+{
+ vertices.clear();
+ normals.clear();
+
+ qreal x1 = +0.06f;
+ qreal y1 = -0.14f;
+ qreal x2 = +0.14f;
+ qreal y2 = -0.06f;
+ qreal x3 = +0.08f;
+ qreal y3 = +0.00f;
+ qreal x4 = +0.30f;
+ qreal y4 = +0.22f;
+
+ quad(x1, y1, x2, y2, y2, x2, y1, x1);
+ quad(x3, y3, x4, y4, y4, x4, y3, x3);
+
+ extrude(x1, y1, x2, y2);
+ extrude(x2, y2, y2, x2);
+ extrude(y2, x2, y1, x1);
+ extrude(y1, x1, x1, y1);
+ extrude(x3, y3, x4, y4);
+ extrude(x4, y4, y4, x4);
+ extrude(y4, x4, y3, x3);
+
+ const qreal Pi = 3.14159f;
+ const int NumSectors = 100;
+
+ for (int i = 0; i < NumSectors; ++i) {
+ qreal angle1 = (i * 2 * Pi) / NumSectors;
+ qreal x5 = 0.30 * qSin(angle1);
+ qreal y5 = 0.30 * qCos(angle1);
+ qreal x6 = 0.20 * qSin(angle1);
+ qreal y6 = 0.20 * qCos(angle1);
+
+ qreal angle2 = ((i + 1) * 2 * Pi) / NumSectors;
+ qreal x7 = 0.20 * qSin(angle2);
+ qreal y7 = 0.20 * qCos(angle2);
+ qreal x8 = 0.30 * qSin(angle2);
+ qreal y8 = 0.30 * qCos(angle2);
+
+ quad(x5, y5, x6, y6, x7, y7, x8, y8);
+
+ extrude(x6, y6, x7, y7);
+ extrude(x8, y8, x5, y5);
+ }
+
+ for (int i = 0;i < vertices.size();i++)
+ vertices[i] *= 2.0f;
+}
+
+void HelloWindow::quad(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4)
+{
+ vertices << QVector3D(x1, y1, -0.05f);
+ vertices << QVector3D(x2, y2, -0.05f);
+ vertices << QVector3D(x4, y4, -0.05f);
+
+ vertices << QVector3D(x3, y3, -0.05f);
+ vertices << QVector3D(x4, y4, -0.05f);
+ vertices << QVector3D(x2, y2, -0.05f);
+
+ QVector3D n = QVector3D::normal
+ (QVector3D(x2 - x1, y2 - y1, 0.0f), QVector3D(x4 - x1, y4 - y1, 0.0f));
+
+ normals << n;
+ normals << n;
+ normals << n;
+
+ normals << n;
+ normals << n;
+ normals << n;
+
+ vertices << QVector3D(x4, y4, 0.05f);
+ vertices << QVector3D(x2, y2, 0.05f);
+ vertices << QVector3D(x1, y1, 0.05f);
+
+ vertices << QVector3D(x2, y2, 0.05f);
+ vertices << QVector3D(x4, y4, 0.05f);
+ vertices << QVector3D(x3, y3, 0.05f);
+
+ n = QVector3D::normal
+ (QVector3D(x2 - x4, y2 - y4, 0.0f), QVector3D(x1 - x4, y1 - y4, 0.0f));
+
+ normals << n;
+ normals << n;
+ normals << n;
+
+ normals << n;
+ normals << n;
+ normals << n;
+}
+
+void HelloWindow::extrude(qreal x1, qreal y1, qreal x2, qreal y2)
+{
+ vertices << QVector3D(x1, y1, +0.05f);
+ vertices << QVector3D(x2, y2, +0.05f);
+ vertices << QVector3D(x1, y1, -0.05f);
+
+ vertices << QVector3D(x2, y2, -0.05f);
+ vertices << QVector3D(x1, y1, -0.05f);
+ vertices << QVector3D(x2, y2, +0.05f);
+
+ QVector3D n = QVector3D::normal
+ (QVector3D(x2 - x1, y2 - y1, 0.0f), QVector3D(0.0f, 0.0f, -0.1f));
+
+ normals << n;
+ normals << n;
+ normals << n;
+
+ normals << n;
+ normals << n;
+ normals << n;
+}
diff --git a/examples/opengl/hellowindow/hellowindow.h b/examples/opengl/hellowindow/hellowindow.h
new file mode 100644
index 0000000000..f0b8ee8b45
--- /dev/null
+++ b/examples/opengl/hellowindow/hellowindow.h
@@ -0,0 +1,40 @@
+#include <QWindow>
+
+#include <QtOpenGL/qgl.h>
+#include <QtOpenGL/qglshaderprogram.h>
+
+#include <QTime>
+
+class HelloWindow : public QWindow
+{
+ Q_OBJECT
+public:
+ HelloWindow();
+
+protected:
+ void mousePressEvent(QMouseEvent *);
+ void resizeEvent(QResizeEvent *);
+
+private slots:
+ void render();
+
+private:
+ void initialize();
+ void updateColor();
+
+ qreal m_fAngle;
+ bool m_showBubbles;
+ void paintQtLogo();
+ void createGeometry();
+ void createBubbles(int number);
+ void quad(qreal x1, qreal y1, qreal x2, qreal y2, qreal x3, qreal y3, qreal x4, qreal y4);
+ void extrude(qreal x1, qreal y1, qreal x2, qreal y2);
+ QVector<QVector3D> vertices;
+ QVector<QVector3D> normals;
+ QGLShaderProgram program;
+ int vertexAttr;
+ int normalAttr;
+ int matrixUniform;
+ int colorUniform;
+ uint colorIndex;
+};
diff --git a/examples/opengl/hellowindow/hellowindow.pro b/examples/opengl/hellowindow/hellowindow.pro
new file mode 100644
index 0000000000..6492975d3b
--- /dev/null
+++ b/examples/opengl/hellowindow/hellowindow.pro
@@ -0,0 +1,14 @@
+######################################################################
+# Automatically generated by qmake (2.01a) Wed Apr 27 16:40:46 2011
+######################################################################
+
+TEMPLATE = app
+TARGET =
+DEPENDPATH += .
+INCLUDEPATH += .
+
+QT += opengl widgets
+
+# Input
+HEADERS += hellowindow.h
+SOURCES += hellowindow.cpp main.cpp
diff --git a/examples/opengl/hellowindow/main.cpp b/examples/opengl/hellowindow/main.cpp
new file mode 100644
index 0000000000..1b80dc7523
--- /dev/null
+++ b/examples/opengl/hellowindow/main.cpp
@@ -0,0 +1,13 @@
+#include <QGuiApplication>
+
+#include "hellowindow.h"
+
+int main(int argc, char **argv)
+{
+ QGuiApplication app(argc, argv);
+
+ HelloWindow window;
+ window.setVisible(true);
+
+ return app.exec();
+}
diff --git a/examples/opengl/opengl.pro b/examples/opengl/opengl.pro
index f9ca0bdaf4..ae381054a2 100644
--- a/examples/opengl/opengl.pro
+++ b/examples/opengl/opengl.pro
@@ -21,6 +21,10 @@ contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles2){
textures
}
+qpa {
+ SUBDIRS += hellowindow
+}
+
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS opengl.pro README
@@ -28,3 +32,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/opengl/overpainting/bubble.cpp b/examples/opengl/overpainting/bubble.cpp
index eb315057fa..bb6d2b8070 100644
--- a/examples/opengl/overpainting/bubble.cpp
+++ b/examples/opengl/overpainting/bubble.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "bubble.h"
diff --git a/examples/opengl/overpainting/glwidget.cpp b/examples/opengl/overpainting/glwidget.cpp
index ded7bf1cf5..4572e69644 100644
--- a/examples/opengl/overpainting/glwidget.cpp
+++ b/examples/opengl/overpainting/glwidget.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QtOpenGL>
#include <stdlib.h>
diff --git a/examples/opengl/overpainting/overpainting.pro b/examples/opengl/overpainting/overpainting.pro
index 31adf0fb34..8da2a163c5 100644
--- a/examples/opengl/overpainting/overpainting.pro
+++ b/examples/opengl/overpainting/overpainting.pro
@@ -1,7 +1,7 @@
VPATH += ../shared
INCLUDEPATH += ../shared
-QT += opengl
+QT += opengl widgets
HEADERS = bubble.h \
glwidget.h \
qtlogo.h
diff --git a/examples/opengl/pbuffers/main.cpp b/examples/opengl/pbuffers/main.cpp
index b4f1512cfe..aac6d1939c 100644
--- a/examples/opengl/pbuffers/main.cpp
+++ b/examples/opengl/pbuffers/main.cpp
@@ -38,8 +38,8 @@
**
****************************************************************************/
-#include <QtGui/QApplication>
-#include <QtGui/QMessageBox>
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QMessageBox>
#include <QtOpenGL/QGLPixelBuffer>
#include "glwidget.h"
diff --git a/examples/opengl/pbuffers/pbuffers.pro b/examples/opengl/pbuffers/pbuffers.pro
index 79d5a6d96c..b1ed04acc7 100644
--- a/examples/opengl/pbuffers/pbuffers.pro
+++ b/examples/opengl/pbuffers/pbuffers.pro
@@ -4,7 +4,7 @@ SOURCES += glwidget.cpp \
main.cpp \
cube.cpp
RESOURCES += pbuffers.qrc
-QT += opengl
+QT += opengl widgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/pbuffers
diff --git a/examples/opengl/pbuffers2/main.cpp b/examples/opengl/pbuffers2/main.cpp
index 0abe0b9faa..573b7f2cda 100644
--- a/examples/opengl/pbuffers2/main.cpp
+++ b/examples/opengl/pbuffers2/main.cpp
@@ -38,8 +38,8 @@
**
****************************************************************************/
-#include <QtGui/QApplication>
-#include <QtGui/QMessageBox>
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QMessageBox>
#include "glwidget.h"
int main(int argc, char **argv)
diff --git a/examples/opengl/pbuffers2/pbuffers2.pro b/examples/opengl/pbuffers2/pbuffers2.pro
index 0fb75c1f00..2e71887c00 100644
--- a/examples/opengl/pbuffers2/pbuffers2.pro
+++ b/examples/opengl/pbuffers2/pbuffers2.pro
@@ -7,7 +7,7 @@ TARGET =
DEPENDPATH += .
INCLUDEPATH += .
-QT += opengl svg
+QT += opengl svg widgets
# Input
HEADERS += glwidget.h
diff --git a/examples/opengl/samplebuffers/main.cpp b/examples/opengl/samplebuffers/main.cpp
index 8d4df924dd..c940541327 100644
--- a/examples/opengl/samplebuffers/main.cpp
+++ b/examples/opengl/samplebuffers/main.cpp
@@ -38,8 +38,8 @@
**
****************************************************************************/
-#include <QtGui/QApplication>
-#include <QtGui/QMessageBox>
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QMessageBox>
#include "glwidget.h"
int main(int argc, char **argv)
diff --git a/examples/opengl/samplebuffers/samplebuffers.pro b/examples/opengl/samplebuffers/samplebuffers.pro
index 34720736df..8420d431e4 100644
--- a/examples/opengl/samplebuffers/samplebuffers.pro
+++ b/examples/opengl/samplebuffers/samplebuffers.pro
@@ -1,7 +1,7 @@
HEADERS += glwidget.h
SOURCES += glwidget.cpp main.cpp
-QT += opengl
+QT += opengl widgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/samplebuffers
diff --git a/examples/opengl/textures/glwidget.cpp b/examples/opengl/textures/glwidget.cpp
index b5374c0200..4e74cf9d1d 100644
--- a/examples/opengl/textures/glwidget.cpp
+++ b/examples/opengl/textures/glwidget.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QtOpenGL>
#include "glwidget.h"
diff --git a/examples/opengl/textures/glwidget.h b/examples/opengl/textures/glwidget.h
index fd9246bef2..86dc889107 100644
--- a/examples/opengl/textures/glwidget.h
+++ b/examples/opengl/textures/glwidget.h
@@ -41,7 +41,7 @@
#ifndef GLWIDGET_H
#define GLWIDGET_H
-#include <QtGui>
+#include <QtWidgets>
#include <QGLWidget>
class QGLShaderProgram;
diff --git a/examples/opengl/textures/textures.pro b/examples/opengl/textures/textures.pro
index 78555d58cb..e67539a476 100644
--- a/examples/opengl/textures/textures.pro
+++ b/examples/opengl/textures/textures.pro
@@ -4,7 +4,7 @@ SOURCES = glwidget.cpp \
main.cpp \
window.cpp
RESOURCES = textures.qrc
-QT += opengl
+QT += opengl widgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/opengl/textures
diff --git a/examples/opengl/textures/window.cpp b/examples/opengl/textures/window.cpp
index 50f3afecce..16f402efab 100644
--- a/examples/opengl/textures/window.cpp
+++ b/examples/opengl/textures/window.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "glwidget.h"
#include "window.h"
diff --git a/examples/openvg/openvg.pro b/examples/openvg/openvg.pro
index ffbe81c312..91e74353ac 100644
--- a/examples/openvg/openvg.pro
+++ b/examples/openvg/openvg.pro
@@ -6,3 +6,4 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/openvg
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS openvg.pro README
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/openvg
INSTALLS += target sources
+QT += widgets
diff --git a/examples/openvg/star/star.pro b/examples/openvg/star/star.pro
index 6ae1238536..ee10c6c6ce 100644
--- a/examples/openvg/star/star.pro
+++ b/examples/openvg/star/star.pro
@@ -1,7 +1,7 @@
TEMPLATE = app
TARGET = star
CONFIG += qt debug warn_on
-QT += openvg
+QT += openvg widgets
SOURCES = starwidget.cpp main.cpp
HEADERS = starwidget.h
LIBS += $$QMAKE_LIBS_OPENVG \ No newline at end of file
diff --git a/examples/painting/basicdrawing/basicdrawing.pro b/examples/painting/basicdrawing/basicdrawing.pro
index e607721ffb..27eb0b3f55 100644
--- a/examples/painting/basicdrawing/basicdrawing.pro
+++ b/examples/painting/basicdrawing/basicdrawing.pro
@@ -15,3 +15,4 @@ symbian {
TARGET.UID3 = 0xA000A649
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/painting/basicdrawing/renderarea.cpp b/examples/painting/basicdrawing/renderarea.cpp
index 0906159e0e..87e6c187d3 100644
--- a/examples/painting/basicdrawing/renderarea.cpp
+++ b/examples/painting/basicdrawing/renderarea.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "renderarea.h"
diff --git a/examples/painting/basicdrawing/window.cpp b/examples/painting/basicdrawing/window.cpp
index 54422a0104..2bb7c63493 100644
--- a/examples/painting/basicdrawing/window.cpp
+++ b/examples/painting/basicdrawing/window.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "renderarea.h"
#include "window.h"
diff --git a/examples/painting/concentriccircles/circlewidget.cpp b/examples/painting/concentriccircles/circlewidget.cpp
index d801710b99..1ffab63944 100644
--- a/examples/painting/concentriccircles/circlewidget.cpp
+++ b/examples/painting/concentriccircles/circlewidget.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "circlewidget.h"
diff --git a/examples/painting/concentriccircles/concentriccircles.pro b/examples/painting/concentriccircles/concentriccircles.pro
index f7e050ba21..cc141d0706 100644
--- a/examples/painting/concentriccircles/concentriccircles.pro
+++ b/examples/painting/concentriccircles/concentriccircles.pro
@@ -14,3 +14,4 @@ symbian {
TARGET.UID3 = 0xA000A64A
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/painting/concentriccircles/window.cpp b/examples/painting/concentriccircles/window.cpp
index a01333be62..c4c5ed8e08 100644
--- a/examples/painting/concentriccircles/window.cpp
+++ b/examples/painting/concentriccircles/window.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "circlewidget.h"
#include "window.h"
diff --git a/examples/painting/fontsampler/fontsampler.pro b/examples/painting/fontsampler/fontsampler.pro
index b9328a6439..a7c8b02853 100644
--- a/examples/painting/fontsampler/fontsampler.pro
+++ b/examples/painting/fontsampler/fontsampler.pro
@@ -10,3 +10,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting/fontsampler
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/painting/fontsampler/mainwindow.cpp b/examples/painting/fontsampler/mainwindow.cpp
index 0976d1f971..27e8169f61 100644
--- a/examples/painting/fontsampler/mainwindow.cpp
+++ b/examples/painting/fontsampler/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
diff --git a/examples/painting/imagecomposition/imagecomposer.cpp b/examples/painting/imagecomposition/imagecomposer.cpp
index a41f405fd0..6410b30062 100644
--- a/examples/painting/imagecomposition/imagecomposer.cpp
+++ b/examples/painting/imagecomposition/imagecomposer.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "imagecomposer.h"
diff --git a/examples/painting/imagecomposition/imagecomposition.pro b/examples/painting/imagecomposition/imagecomposition.pro
index e8be8fa2b5..dcb8b22f48 100644
--- a/examples/painting/imagecomposition/imagecomposition.pro
+++ b/examples/painting/imagecomposition/imagecomposition.pro
@@ -13,3 +13,4 @@ symbian {
TARGET.UID3 = 0xA000A64B
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/painting/painterpaths/painterpaths.pro b/examples/painting/painterpaths/painterpaths.pro
index 84bbecaa83..e8fd7accd6 100644
--- a/examples/painting/painterpaths/painterpaths.pro
+++ b/examples/painting/painterpaths/painterpaths.pro
@@ -15,3 +15,4 @@ symbian {
TARGET.UID3 = 0xA000A64C
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/painting/painterpaths/renderarea.cpp b/examples/painting/painterpaths/renderarea.cpp
index 977fe30ed0..9bff70bb41 100644
--- a/examples/painting/painterpaths/renderarea.cpp
+++ b/examples/painting/painterpaths/renderarea.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "renderarea.h"
diff --git a/examples/painting/painterpaths/window.cpp b/examples/painting/painterpaths/window.cpp
index 429f470b26..2c3c0225c7 100644
--- a/examples/painting/painterpaths/window.cpp
+++ b/examples/painting/painterpaths/window.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <math.h>
diff --git a/examples/painting/painting.pro b/examples/painting/painting.pro
index 4108a64edd..72ea1c36ae 100644
--- a/examples/painting/painting.pro
+++ b/examples/painting/painting.pro
@@ -14,3 +14,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/painting
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/painting/transformations/renderarea.cpp b/examples/painting/transformations/renderarea.cpp
index 568cfde287..04a6eb511f 100644
--- a/examples/painting/transformations/renderarea.cpp
+++ b/examples/painting/transformations/renderarea.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "renderarea.h"
diff --git a/examples/painting/transformations/transformations.pro b/examples/painting/transformations/transformations.pro
index 8fe8be932e..10515e0df6 100644
--- a/examples/painting/transformations/transformations.pro
+++ b/examples/painting/transformations/transformations.pro
@@ -14,3 +14,4 @@ symbian {
TARGET.UID3 = 0xA000A64D
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/painting/transformations/window.cpp b/examples/painting/transformations/window.cpp
index fc3bcb856d..24d0a6f5ce 100644
--- a/examples/painting/transformations/window.cpp
+++ b/examples/painting/transformations/window.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "window.h"
diff --git a/examples/qmake/precompile/precompile.pro b/examples/qmake/precompile/precompile.pro
index 6360f06f07..828e912aec 100644
--- a/examples/qmake/precompile/precompile.pro
+++ b/examples/qmake/precompile/precompile.pro
@@ -20,3 +20,4 @@ SOURCES = main.cpp \
util.cpp
FORMS = mydialog.ui
#! [0]
+QT += widgets
diff --git a/examples/qpa/qpa.pro b/examples/qpa/qpa.pro
new file mode 100644
index 0000000000..c0e26072a0
--- /dev/null
+++ b/examples/qpa/qpa.pro
@@ -0,0 +1,9 @@
+TEMPLATE = subdirs
+SUBDIRS = windows
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qpa
+sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS qpa.pro
+sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qpa
+INSTALLS += target sources
+QT += widgets
diff --git a/examples/qpa/windows/main.cpp b/examples/qpa/windows/main.cpp
new file mode 100644
index 0000000000..99c24fa017
--- /dev/null
+++ b/examples/qpa/windows/main.cpp
@@ -0,0 +1,19 @@
+#include <QGuiApplication>
+
+#include "window.h"
+
+int main(int argc, char **argv)
+{
+ QGuiApplication app(argc, argv);
+
+ Window a;
+ a.setVisible(true);
+
+ Window b;
+ b.setVisible(true);
+
+ Window child(&b);
+ child.setVisible(true);
+
+ return app.exec();
+}
diff --git a/examples/qpa/windows/window.cpp b/examples/qpa/windows/window.cpp
new file mode 100644
index 0000000000..d08db5714b
--- /dev/null
+++ b/examples/qpa/windows/window.cpp
@@ -0,0 +1,126 @@
+#include "window.h"
+
+#include <private/qguiapplication_p.h>
+#include <private/qwindowsurface_p.h>
+
+#include <QPainter>
+
+static int colorIndexId = 0;
+
+QColor colorTable[] =
+{
+ QColor("#f09f8f"),
+ QColor("#a2bff2"),
+ QColor("#c0ef8f")
+};
+
+Window::Window(QWindow *parent)
+ : QWindow(parent)
+ , m_backgroundColorIndex(colorIndexId++)
+{
+ setSurfaceType(RasterSurface);
+ setWindowTitle(QLatin1String("Window"));
+
+ if (parent)
+ setGeometry(QRect(160, 120, 320, 240));
+ else
+ setGeometry(QRect(10, 10, 640, 480));
+
+ create();
+ QGuiApplicationPrivate::platformIntegration()->createWindowSurface(this, winId());
+
+ m_image = QImage(geometry().size(), QImage::Format_RGB32);
+ m_image.fill(colorTable[m_backgroundColorIndex % (sizeof(colorTable) / sizeof(colorTable[0]))].rgba());
+
+ m_lastPos = QPoint(-1, -1);
+
+ render();
+}
+
+void Window::mousePressEvent(QMouseEvent *event)
+{
+ m_lastPos = event->pos();
+}
+
+void Window::mouseMoveEvent(QMouseEvent *event)
+{
+ if (m_lastPos != QPoint(-1, -1)) {
+ QPainter p(&m_image);
+ p.setRenderHint(QPainter::Antialiasing);
+ p.drawLine(m_lastPos, event->pos());
+ m_lastPos = event->pos();
+ }
+
+ render();
+}
+
+void Window::mouseReleaseEvent(QMouseEvent *event)
+{
+ if (m_lastPos != QPoint(-1, -1)) {
+ QPainter p(&m_image);
+ p.setRenderHint(QPainter::Antialiasing);
+ p.drawLine(m_lastPos, event->pos());
+ m_lastPos = QPoint(-1, -1);
+ }
+
+ render();
+}
+
+void Window::resizeEvent(QResizeEvent *)
+{
+ QImage old = m_image;
+
+ int width = qMax(geometry().width(), old.width());
+ int height = qMax(geometry().height(), old.height());
+
+ if (width > old.width() || height > old.height()) {
+ m_image = QImage(width, height, QImage::Format_RGB32);
+ m_image.fill(colorTable[(m_backgroundColorIndex) % (sizeof(colorTable) / sizeof(colorTable[0]))].rgba());
+
+ QPainter p(&m_image);
+ p.drawImage(0, 0, old);
+ }
+
+ render();
+}
+
+void Window::keyPressEvent(QKeyEvent *event)
+{
+ switch (event->key()) {
+ case Qt::Key_Backspace:
+ m_text.chop(1);
+ break;
+ case Qt::Key_Enter:
+ case Qt::Key_Return:
+ m_text.append('\n');
+ break;
+ default:
+ m_text.append(event->text());
+ break;
+ }
+ render();
+}
+
+void Window::render()
+{
+ QRect rect(QPoint(), geometry().size());
+ surface()->resize(rect.size());
+
+ surface()->beginPaint(rect);
+
+ QPaintDevice *device = surface()->paintDevice();
+
+ QPainter p(device);
+ p.drawImage(0, 0, m_image);
+
+ QFont font;
+ font.setPixelSize(32);
+
+ p.setFont(font);
+ p.drawText(rect, 0, m_text);
+
+ surface()->endPaint(rect);
+ surface()->flush(this, rect, QPoint());
+}
+
+
diff --git a/examples/qpa/windows/window.h b/examples/qpa/windows/window.h
new file mode 100644
index 0000000000..f0b7d80531
--- /dev/null
+++ b/examples/qpa/windows/window.h
@@ -0,0 +1,25 @@
+#include <QWindow>
+#include <QImage>
+
+class Window : public QWindow
+{
+public:
+ Window(QWindow *parent = 0);
+
+protected:
+ void mousePressEvent(QMouseEvent *);
+ void mouseMoveEvent(QMouseEvent *);
+ void mouseReleaseEvent(QMouseEvent *);
+
+ void keyPressEvent(QKeyEvent *);
+
+ void resizeEvent(QResizeEvent *);
+
+private:
+ void render();
+
+ QString m_text;
+ QImage m_image;
+ QPoint m_lastPos;
+ int m_backgroundColorIndex;
+};
diff --git a/examples/qpa/windows/windows.pro b/examples/qpa/windows/windows.pro
new file mode 100644
index 0000000000..f898f5130f
--- /dev/null
+++ b/examples/qpa/windows/windows.pro
@@ -0,0 +1,15 @@
+######################################################################
+# Automatically generated by qmake (2.01a) Wed Apr 27 16:40:46 2011
+######################################################################
+
+TEMPLATE = app
+TARGET =
+DEPENDPATH += .
+INCLUDEPATH += .
+
+QT += gui-private widgets
+QT += core-private widgets
+
+# Input
+HEADERS += window.h
+SOURCES += window.cpp main.cpp
diff --git a/examples/qtconcurrent/imagescaling/imagescaling.h b/examples/qtconcurrent/imagescaling/imagescaling.h
index 096e880b1b..5bc9187dea 100644
--- a/examples/qtconcurrent/imagescaling/imagescaling.h
+++ b/examples/qtconcurrent/imagescaling/imagescaling.h
@@ -40,7 +40,7 @@
#ifndef IMAGESCALING_H
#define IMAGESCALING_H
-#include <QtGui>
+#include <QtWidgets>
#ifndef QT_NO_CONCURRENT
diff --git a/examples/qtconcurrent/imagescaling/imagescaling.pro b/examples/qtconcurrent/imagescaling/imagescaling.pro
index f6c029b678..2f3f1e6ceb 100644
--- a/examples/qtconcurrent/imagescaling/imagescaling.pro
+++ b/examples/qtconcurrent/imagescaling/imagescaling.pro
@@ -15,3 +15,4 @@ INSTALLS += target sources
symbian: CONFIG += qt_example
wince*: DEPLOYMENT_PLUGIN += qgif qjpeg qtiff
+QT += widgets
diff --git a/examples/qtconcurrent/imagescaling/main.cpp b/examples/qtconcurrent/imagescaling/main.cpp
index de64116f1c..08d66a0f4f 100644
--- a/examples/qtconcurrent/imagescaling/main.cpp
+++ b/examples/qtconcurrent/imagescaling/main.cpp
@@ -37,7 +37,7 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#ifndef QT_NO_CONCURRENT
diff --git a/examples/qtconcurrent/map/map.pro b/examples/qtconcurrent/map/map.pro
index da8b5cb664..ab41b67008 100644
--- a/examples/qtconcurrent/map/map.pro
+++ b/examples/qtconcurrent/map/map.pro
@@ -14,3 +14,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qtconcurrent/map
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/qtconcurrent/progressdialog/main.cpp b/examples/qtconcurrent/progressdialog/main.cpp
index 307baed45b..1167c45d6b 100644
--- a/examples/qtconcurrent/progressdialog/main.cpp
+++ b/examples/qtconcurrent/progressdialog/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#ifndef QT_NO_CONCURRENT
diff --git a/examples/qtconcurrent/progressdialog/progressdialog.pro b/examples/qtconcurrent/progressdialog/progressdialog.pro
index be3e62ceeb..9fa84fcbff 100644
--- a/examples/qtconcurrent/progressdialog/progressdialog.pro
+++ b/examples/qtconcurrent/progressdialog/progressdialog.pro
@@ -14,3 +14,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qtconcurrent/progressdialog
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/qtconcurrent/qtconcurrent.pro b/examples/qtconcurrent/qtconcurrent.pro
index a224b4a633..5be088e86d 100644
--- a/examples/qtconcurrent/qtconcurrent.pro
+++ b/examples/qtconcurrent/qtconcurrent.pro
@@ -15,3 +15,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qtconcurrent
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/qtconcurrent/runfunction/runfunction.pro b/examples/qtconcurrent/runfunction/runfunction.pro
index f5b359c5ef..d100aa86a9 100644
--- a/examples/qtconcurrent/runfunction/runfunction.pro
+++ b/examples/qtconcurrent/runfunction/runfunction.pro
@@ -14,3 +14,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qtconcurrent/runfunction
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/qtconcurrent/wordcount/wordcount.pro b/examples/qtconcurrent/wordcount/wordcount.pro
index c6e4d852f5..2866e807a1 100644
--- a/examples/qtconcurrent/wordcount/wordcount.pro
+++ b/examples/qtconcurrent/wordcount/wordcount.pro
@@ -14,3 +14,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qtconcurrent/wordcount
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/qtestlib/qtestlib.pro b/examples/qtestlib/qtestlib.pro
index 7fce5967c7..3118e391ce 100644
--- a/examples/qtestlib/qtestlib.pro
+++ b/examples/qtestlib/qtestlib.pro
@@ -8,3 +8,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qtestlib
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/qtestlib/tutorial1/tutorial1.pro b/examples/qtestlib/tutorial1/tutorial1.pro
index 439e8403ef..dd5820f49c 100644
--- a/examples/qtestlib/tutorial1/tutorial1.pro
+++ b/examples/qtestlib/tutorial1/tutorial1.pro
@@ -11,3 +11,4 @@ symbian {
TARGET.UID3 = 0xA000C60B
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/qtestlib/tutorial2/tutorial2.pro b/examples/qtestlib/tutorial2/tutorial2.pro
index 2c44466d47..a1798c56ae 100644
--- a/examples/qtestlib/tutorial2/tutorial2.pro
+++ b/examples/qtestlib/tutorial2/tutorial2.pro
@@ -11,3 +11,4 @@ symbian {
TARGET.UID3 = 0xA000C60C
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/qtestlib/tutorial3/testgui.cpp b/examples/qtestlib/tutorial3/testgui.cpp
index 74b25a8e02..6618d86c14 100644
--- a/examples/qtestlib/tutorial3/testgui.cpp
+++ b/examples/qtestlib/tutorial3/testgui.cpp
@@ -39,7 +39,7 @@
****************************************************************************/
//! [0]
-#include <QtGui>
+#include <QtWidgets>
#include <QtTest/QtTest>
class TestGui: public QObject
diff --git a/examples/qtestlib/tutorial3/tutorial3.pro b/examples/qtestlib/tutorial3/tutorial3.pro
index ec24447347..6dbfed961c 100644
--- a/examples/qtestlib/tutorial3/tutorial3.pro
+++ b/examples/qtestlib/tutorial3/tutorial3.pro
@@ -11,3 +11,4 @@ symbian {
TARGET.UID3 = 0xA000C60D
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/qtestlib/tutorial4/testgui.cpp b/examples/qtestlib/tutorial4/testgui.cpp
index a1fbbb7d71..66a6cbe7c5 100644
--- a/examples/qtestlib/tutorial4/testgui.cpp
+++ b/examples/qtestlib/tutorial4/testgui.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QtTest/QtTest>
//! [0]
diff --git a/examples/qtestlib/tutorial4/tutorial4.pro b/examples/qtestlib/tutorial4/tutorial4.pro
index ca3985ea21..e0a8895b19 100644
--- a/examples/qtestlib/tutorial4/tutorial4.pro
+++ b/examples/qtestlib/tutorial4/tutorial4.pro
@@ -11,3 +11,4 @@ symbian {
TARGET.UID3 = 0xA000C60E
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/qtestlib/tutorial5/benchmarking.cpp b/examples/qtestlib/tutorial5/benchmarking.cpp
index 604eb20a50..f844c2e66c 100644
--- a/examples/qtestlib/tutorial5/benchmarking.cpp
+++ b/examples/qtestlib/tutorial5/benchmarking.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <qtest.h>
class TestBenchmark : public QObject
diff --git a/examples/qtestlib/tutorial5/tutorial5.pro b/examples/qtestlib/tutorial5/tutorial5.pro
index c263a74278..2399df2919 100644
--- a/examples/qtestlib/tutorial5/tutorial5.pro
+++ b/examples/qtestlib/tutorial5/tutorial5.pro
@@ -11,3 +11,4 @@ symbian {
TARGET.UID3 = 0xA000C60F
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/qws/dbscreen/dbscreen.pro b/examples/qws/dbscreen/dbscreen.pro
index 172a02a5e7..3b8471943e 100644
--- a/examples/qws/dbscreen/dbscreen.pro
+++ b/examples/qws/dbscreen/dbscreen.pro
@@ -9,3 +9,4 @@ HEADERS = dbscreen.h
SOURCES = dbscreendriverplugin.cpp \
dbscreen.cpp
+QT += widgets
diff --git a/examples/qws/framebuffer/framebuffer.pro b/examples/qws/framebuffer/framebuffer.pro
index 098a97ed14..5f703ade9d 100644
--- a/examples/qws/framebuffer/framebuffer.pro
+++ b/examples/qws/framebuffer/framebuffer.pro
@@ -9,3 +9,4 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qws/framebuffer
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS framebuffer.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qws/framebuffer
INSTALLS += target sources
+QT += widgets
diff --git a/examples/qws/mousecalibration/mousecalibration.pro b/examples/qws/mousecalibration/mousecalibration.pro
index 878aff23bc..66e7881e63 100644
--- a/examples/qws/mousecalibration/mousecalibration.pro
+++ b/examples/qws/mousecalibration/mousecalibration.pro
@@ -9,3 +9,4 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qws/mousecalibration
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qws/mousecalibration
INSTALLS += target sources
+QT += widgets
diff --git a/examples/qws/qws.pro b/examples/qws/qws.pro
index 7736625cbe..06e3aa8eba 100644
--- a/examples/qws/qws.pro
+++ b/examples/qws/qws.pro
@@ -7,3 +7,4 @@ SUBDIRS += mousecalibration simpledecoration
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS README *.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qws
INSTALLS += sources
+QT += widgets
diff --git a/examples/qws/simpledecoration/analogclock.cpp b/examples/qws/simpledecoration/analogclock.cpp
index 4a91e0dc0a..c922c9fe18 100644
--- a/examples/qws/simpledecoration/analogclock.cpp
+++ b/examples/qws/simpledecoration/analogclock.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "analogclock.h"
diff --git a/examples/qws/simpledecoration/mydecoration.cpp b/examples/qws/simpledecoration/mydecoration.cpp
index 32db90596e..907fd6d8c2 100644
--- a/examples/qws/simpledecoration/mydecoration.cpp
+++ b/examples/qws/simpledecoration/mydecoration.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mydecoration.h"
/* XPM */
diff --git a/examples/qws/simpledecoration/simpledecoration.pro b/examples/qws/simpledecoration/simpledecoration.pro
index 2a4e0be51c..0f24844497 100644
--- a/examples/qws/simpledecoration/simpledecoration.pro
+++ b/examples/qws/simpledecoration/simpledecoration.pro
@@ -10,3 +10,4 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qws/simpledecoration
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS *.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/qws/simpledecoration
INSTALLS += target sources
+QT += widgets
diff --git a/examples/qws/svgalib/svgalib.pro b/examples/qws/svgalib/svgalib.pro
index 8a47c1d1d0..f3aff9d0da 100644
--- a/examples/qws/svgalib/svgalib.pro
+++ b/examples/qws/svgalib/svgalib.pro
@@ -17,3 +17,4 @@ SOURCES = svgalibscreen.cpp \
svgalibpaintdevice.cpp \
svgalibplugin.cpp
+QT += widgets
diff --git a/examples/richtext/calendar/calendar.pro b/examples/richtext/calendar/calendar.pro
index 7ecc8ab6b9..17ac2bb158 100644
--- a/examples/richtext/calendar/calendar.pro
+++ b/examples/richtext/calendar/calendar.pro
@@ -9,3 +9,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/richtext/calendar
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/richtext/calendar/main.cpp b/examples/richtext/calendar/main.cpp
index b23e883e24..808f72480b 100644
--- a/examples/richtext/calendar/main.cpp
+++ b/examples/richtext/calendar/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
diff --git a/examples/richtext/calendar/mainwindow.cpp b/examples/richtext/calendar/mainwindow.cpp
index 5117c03ae4..58d9b55c79 100644
--- a/examples/richtext/calendar/mainwindow.cpp
+++ b/examples/richtext/calendar/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
diff --git a/examples/richtext/orderform/detailsdialog.cpp b/examples/richtext/orderform/detailsdialog.cpp
index 9aa8535c5b..ba395ec2bb 100644
--- a/examples/richtext/orderform/detailsdialog.cpp
+++ b/examples/richtext/orderform/detailsdialog.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "detailsdialog.h"
diff --git a/examples/richtext/orderform/main.cpp b/examples/richtext/orderform/main.cpp
index 3ad32b8e4e..eb8155fd9a 100644
--- a/examples/richtext/orderform/main.cpp
+++ b/examples/richtext/orderform/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
diff --git a/examples/richtext/orderform/mainwindow.cpp b/examples/richtext/orderform/mainwindow.cpp
index e08f3ba9d3..30ea7a70be 100644
--- a/examples/richtext/orderform/mainwindow.cpp
+++ b/examples/richtext/orderform/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "detailsdialog.h"
#include "mainwindow.h"
diff --git a/examples/richtext/orderform/orderform.pro b/examples/richtext/orderform/orderform.pro
index 6760dad7aa..99697e5815 100644
--- a/examples/richtext/orderform/orderform.pro
+++ b/examples/richtext/orderform/orderform.pro
@@ -11,3 +11,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/richtext/orderform
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/richtext/richtext.pro b/examples/richtext/richtext.pro
index 102181ec26..4b82baf956 100644
--- a/examples/richtext/richtext.pro
+++ b/examples/richtext/richtext.pro
@@ -10,3 +10,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/richtext
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/richtext/syntaxhighlighter/highlighter.cpp b/examples/richtext/syntaxhighlighter/highlighter.cpp
index b51aa873a6..d14d0241fe 100644
--- a/examples/richtext/syntaxhighlighter/highlighter.cpp
+++ b/examples/richtext/syntaxhighlighter/highlighter.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "highlighter.h"
diff --git a/examples/richtext/syntaxhighlighter/mainwindow.cpp b/examples/richtext/syntaxhighlighter/mainwindow.cpp
index 0d64489993..298ba3c472 100644
--- a/examples/richtext/syntaxhighlighter/mainwindow.cpp
+++ b/examples/richtext/syntaxhighlighter/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
diff --git a/examples/richtext/syntaxhighlighter/syntaxhighlighter.pro b/examples/richtext/syntaxhighlighter/syntaxhighlighter.pro
index e981a912ad..4f44782318 100644
--- a/examples/richtext/syntaxhighlighter/syntaxhighlighter.pro
+++ b/examples/richtext/syntaxhighlighter/syntaxhighlighter.pro
@@ -17,3 +17,4 @@ wince*: {
addFiles.path = .
DEPLOYMENT += addFiles
}
+QT += widgets
diff --git a/examples/scroller/graphicsview/graphicsview.pro b/examples/scroller/graphicsview/graphicsview.pro
index b0b8405293..ccfb82d0ca 100644
--- a/examples/scroller/graphicsview/graphicsview.pro
+++ b/examples/scroller/graphicsview/graphicsview.pro
@@ -6,3 +6,4 @@ 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
index 738a824269..8f0019a82e 100644
--- a/examples/scroller/graphicsview/main.cpp
+++ b/examples/scroller/graphicsview/main.cpp
@@ -39,7 +39,7 @@
****************************************************************************/
#include <QtCore>
-#include <QtGui>
+#include <QtWidgets>
#define NUM_ITEMS 100
#define NUM_LISTS 10
diff --git a/examples/scroller/scroller.pro b/examples/scroller/scroller.pro
index bac3f26554..993977d538 100644
--- a/examples/scroller/scroller.pro
+++ b/examples/scroller/scroller.pro
@@ -1,2 +1,3 @@
TEMPLATE = subdirs
SUBDIRS += graphicsview
+QT += widgets
diff --git a/examples/sql/cachedtable/cachedtable.pro b/examples/sql/cachedtable/cachedtable.pro
index 0b015fd0fc..8df9313761 100644
--- a/examples/sql/cachedtable/cachedtable.pro
+++ b/examples/sql/cachedtable/cachedtable.pro
@@ -2,7 +2,7 @@ HEADERS = ../connection.h \
tableeditor.h
SOURCES = main.cpp \
tableeditor.cpp
-QT += sql
+QT += sql widgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/sql/cachedtable
diff --git a/examples/sql/cachedtable/tableeditor.cpp b/examples/sql/cachedtable/tableeditor.cpp
index 216f729d6f..02de4beb7a 100644
--- a/examples/sql/cachedtable/tableeditor.cpp
+++ b/examples/sql/cachedtable/tableeditor.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QtSql>
#include "tableeditor.h"
diff --git a/examples/sql/drilldown/drilldown.pro b/examples/sql/drilldown/drilldown.pro
index 6448e43d82..67eb8bef95 100644
--- a/examples/sql/drilldown/drilldown.pro
+++ b/examples/sql/drilldown/drilldown.pro
@@ -7,7 +7,7 @@ SOURCES = imageitem.cpp \
informationwindow.cpp \
main.cpp \
view.cpp
-QT += sql
+QT += sql widgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/sql/drilldown
diff --git a/examples/sql/drilldown/imageitem.h b/examples/sql/drilldown/imageitem.h
index 13d99c3846..f2bd27bc9e 100644
--- a/examples/sql/drilldown/imageitem.h
+++ b/examples/sql/drilldown/imageitem.h
@@ -42,7 +42,7 @@
#define IMAGEITEM_H
#include <QtCore>
-#include <QtGui/QGraphicsPixmapItem>
+#include <QtWidgets/QGraphicsPixmapItem>
//! [0]
class ImageItem : public QObject, public QGraphicsPixmapItem
diff --git a/examples/sql/drilldown/informationwindow.h b/examples/sql/drilldown/informationwindow.h
index 354823f152..b5cf25a8e0 100644
--- a/examples/sql/drilldown/informationwindow.h
+++ b/examples/sql/drilldown/informationwindow.h
@@ -41,7 +41,7 @@
#ifndef INFORMATIONWINDOW_H
#define INFORMATIONWINDOW_H
-#include <QtGui>
+#include <QtWidgets>
#include <QtSql>
//! [0]
diff --git a/examples/sql/drilldown/main.cpp b/examples/sql/drilldown/main.cpp
index e3c8fa7cce..d139089dc3 100644
--- a/examples/sql/drilldown/main.cpp
+++ b/examples/sql/drilldown/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "../connection.h"
#include "view.h"
diff --git a/examples/sql/drilldown/view.h b/examples/sql/drilldown/view.h
index 3efe6bb8ce..98855350bd 100644
--- a/examples/sql/drilldown/view.h
+++ b/examples/sql/drilldown/view.h
@@ -41,7 +41,7 @@
#ifndef VIEW_H
#define VIEW_H
-#include <QtGui>
+#include <QtWidgets>
#include <QtSql>
class ImageItem;
diff --git a/examples/sql/masterdetail/dialog.h b/examples/sql/masterdetail/dialog.h
index 5495a115b3..e311554597 100644
--- a/examples/sql/masterdetail/dialog.h
+++ b/examples/sql/masterdetail/dialog.h
@@ -41,7 +41,7 @@
#ifndef DIALOG_H
#define DIALOG_H
-#include <QtGui>
+#include <QtWidgets>
#include <QtSql>
#include <QtXml>
diff --git a/examples/sql/masterdetail/main.cpp b/examples/sql/masterdetail/main.cpp
index fe3dd9db50..0e2aca5d2e 100644
--- a/examples/sql/masterdetail/main.cpp
+++ b/examples/sql/masterdetail/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "database.h"
#include "mainwindow.h"
diff --git a/examples/sql/masterdetail/mainwindow.cpp b/examples/sql/masterdetail/mainwindow.cpp
index 24771bad09..d00946cb39 100644
--- a/examples/sql/masterdetail/mainwindow.cpp
+++ b/examples/sql/masterdetail/mainwindow.cpp
@@ -41,7 +41,7 @@
#include "mainwindow.h"
#include "dialog.h"
-#include <QtGui>
+#include <QtWidgets>
#include <QtSql>
#include <QtXml>
diff --git a/examples/sql/masterdetail/masterdetail.pro b/examples/sql/masterdetail/masterdetail.pro
index 98bfac4352..d320e85f87 100644
--- a/examples/sql/masterdetail/masterdetail.pro
+++ b/examples/sql/masterdetail/masterdetail.pro
@@ -6,8 +6,8 @@ SOURCES = dialog.cpp \
main.cpp \
mainwindow.cpp
-QT += sql
-QT += xml
+QT += sql widgets
+QT += xml widgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/sql/masterdetail
diff --git a/examples/sql/querymodel/customsqlmodel.cpp b/examples/sql/querymodel/customsqlmodel.cpp
index 5b09dd634b..534707e8e1 100644
--- a/examples/sql/querymodel/customsqlmodel.cpp
+++ b/examples/sql/querymodel/customsqlmodel.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "customsqlmodel.h"
diff --git a/examples/sql/querymodel/main.cpp b/examples/sql/querymodel/main.cpp
index b6507e92c4..be2a4156ac 100644
--- a/examples/sql/querymodel/main.cpp
+++ b/examples/sql/querymodel/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "../connection.h"
#include "customsqlmodel.h"
diff --git a/examples/sql/querymodel/querymodel.pro b/examples/sql/querymodel/querymodel.pro
index f376e126df..32fb8c091b 100644
--- a/examples/sql/querymodel/querymodel.pro
+++ b/examples/sql/querymodel/querymodel.pro
@@ -4,7 +4,7 @@ HEADERS = ../connection.h \
SOURCES = customsqlmodel.cpp \
editablesqlmodel.cpp \
main.cpp
-QT += sql
+QT += sql widgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/sql/querymodel
diff --git a/examples/sql/relationaltablemodel/relationaltablemodel.cpp b/examples/sql/relationaltablemodel/relationaltablemodel.cpp
index ecb985e6b5..41dbdd2890 100644
--- a/examples/sql/relationaltablemodel/relationaltablemodel.cpp
+++ b/examples/sql/relationaltablemodel/relationaltablemodel.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QtSql>
#include "../connection.h"
diff --git a/examples/sql/relationaltablemodel/relationaltablemodel.pro b/examples/sql/relationaltablemodel/relationaltablemodel.pro
index 41c1c170c4..ce8bb00152 100644
--- a/examples/sql/relationaltablemodel/relationaltablemodel.pro
+++ b/examples/sql/relationaltablemodel/relationaltablemodel.pro
@@ -1,6 +1,6 @@
HEADERS = ../connection.h
SOURCES = relationaltablemodel.cpp
-QT += sql
+QT += sql widgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/sql/relationaltablemodel
diff --git a/examples/sql/sql.pro b/examples/sql/sql.pro
index 36738fbeed..047f733fac 100644
--- a/examples/sql/sql.pro
+++ b/examples/sql/sql.pro
@@ -18,3 +18,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/sql
INSTALLS += sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/sql/sqlwidgetmapper/sqlwidgetmapper.pro b/examples/sql/sqlwidgetmapper/sqlwidgetmapper.pro
index 600531881e..26bf70ad97 100644
--- a/examples/sql/sqlwidgetmapper/sqlwidgetmapper.pro
+++ b/examples/sql/sqlwidgetmapper/sqlwidgetmapper.pro
@@ -1,7 +1,7 @@
HEADERS = window.h
SOURCES = main.cpp \
window.cpp
-QT += sql
+QT += sql widgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/sql/sqlwidgetmapper
diff --git a/examples/sql/sqlwidgetmapper/window.cpp b/examples/sql/sqlwidgetmapper/window.cpp
index 23954c95c7..4370f50869 100644
--- a/examples/sql/sqlwidgetmapper/window.cpp
+++ b/examples/sql/sqlwidgetmapper/window.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QtSql>
#include "window.h"
diff --git a/examples/sql/tablemodel/tablemodel.cpp b/examples/sql/tablemodel/tablemodel.cpp
index 41a42bc31e..23cf00bb97 100644
--- a/examples/sql/tablemodel/tablemodel.cpp
+++ b/examples/sql/tablemodel/tablemodel.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <QtSql>
#include "../connection.h"
diff --git a/examples/sql/tablemodel/tablemodel.pro b/examples/sql/tablemodel/tablemodel.pro
index 41280eec52..56567235db 100644
--- a/examples/sql/tablemodel/tablemodel.pro
+++ b/examples/sql/tablemodel/tablemodel.pro
@@ -1,6 +1,6 @@
HEADERS = ../connection.h
SOURCES = tablemodel.cpp
-QT += sql
+QT += sql widgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/sql/tablemodel
diff --git a/examples/statemachine/eventtransitions/eventtransitions.pro b/examples/statemachine/eventtransitions/eventtransitions.pro
index 646c90a07d..1cd958ae97 100644
--- a/examples/statemachine/eventtransitions/eventtransitions.pro
+++ b/examples/statemachine/eventtransitions/eventtransitions.pro
@@ -5,3 +5,4 @@ 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
diff --git a/examples/statemachine/eventtransitions/main.cpp b/examples/statemachine/eventtransitions/main.cpp
index 5391057992..1b84ae020c 100644
--- a/examples/statemachine/eventtransitions/main.cpp
+++ b/examples/statemachine/eventtransitions/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
//! [0]
class Window : public QWidget
diff --git a/examples/statemachine/rogue/main.cpp b/examples/statemachine/rogue/main.cpp
index 71c2c69470..b52b55fccf 100644
--- a/examples/statemachine/rogue/main.cpp
+++ b/examples/statemachine/rogue/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "window.h"
diff --git a/examples/statemachine/rogue/movementtransition.h b/examples/statemachine/rogue/movementtransition.h
index 1153b7508d..d125a862b6 100644
--- a/examples/statemachine/rogue/movementtransition.h
+++ b/examples/statemachine/rogue/movementtransition.h
@@ -41,7 +41,7 @@
#ifndef MOVEMENTTRANSITION_H
#define MOVEMENTTRANSITION_H
-#include <QtGui>
+#include <QtWidgets>
#include "window.h"
diff --git a/examples/statemachine/rogue/rogue.pro b/examples/statemachine/rogue/rogue.pro
index 6ab613bea9..d653beb2d0 100644
--- a/examples/statemachine/rogue/rogue.pro
+++ b/examples/statemachine/rogue/rogue.pro
@@ -9,3 +9,4 @@ 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
index 39f5aa65d9..2700a87754 100644
--- a/examples/statemachine/rogue/window.cpp
+++ b/examples/statemachine/rogue/window.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "window.h"
#include "movementtransition.h"
diff --git a/examples/statemachine/statemachine.pro b/examples/statemachine/statemachine.pro
index e5b8b75705..a049316e08 100644
--- a/examples/statemachine/statemachine.pro
+++ b/examples/statemachine/statemachine.pro
@@ -16,3 +16,4 @@ 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
+QT += widgets
diff --git a/examples/statemachine/trafficlight/main.cpp b/examples/statemachine/trafficlight/main.cpp
index 23cd34833a..9b10360ae2 100644
--- a/examples/statemachine/trafficlight/main.cpp
+++ b/examples/statemachine/trafficlight/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
//! [0]
class LightWidget : public QWidget
diff --git a/examples/statemachine/trafficlight/trafficlight.pro b/examples/statemachine/trafficlight/trafficlight.pro
index f6aab8d6e5..78367b0b03 100644
--- a/examples/statemachine/trafficlight/trafficlight.pro
+++ b/examples/statemachine/trafficlight/trafficlight.pro
@@ -5,3 +5,4 @@ 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
index 6b9ce1fe55..a6c7000446 100644
--- a/examples/statemachine/twowaybutton/main.cpp
+++ b/examples/statemachine/twowaybutton/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
//! [0]
int main(int argc, char **argv)
diff --git a/examples/statemachine/twowaybutton/twowaybutton.pro b/examples/statemachine/twowaybutton/twowaybutton.pro
index 212ba501d7..717f0b5498 100644
--- a/examples/statemachine/twowaybutton/twowaybutton.pro
+++ b/examples/statemachine/twowaybutton/twowaybutton.pro
@@ -5,3 +5,4 @@ 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/threads/mandelbrot/mandelbrot.pro b/examples/threads/mandelbrot/mandelbrot.pro
index fe72cd58a7..c19a9bd1aa 100644
--- a/examples/threads/mandelbrot/mandelbrot.pro
+++ b/examples/threads/mandelbrot/mandelbrot.pro
@@ -13,3 +13,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/threads/mandelbrot
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/threads/mandelbrot/mandelbrotwidget.cpp b/examples/threads/mandelbrot/mandelbrotwidget.cpp
index 8dc1f5d811..b4233538d9 100644
--- a/examples/threads/mandelbrot/mandelbrotwidget.cpp
+++ b/examples/threads/mandelbrot/mandelbrotwidget.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <math.h>
diff --git a/examples/threads/mandelbrot/renderthread.cpp b/examples/threads/mandelbrot/renderthread.cpp
index da89f99e5c..d4f3b8ad50 100644
--- a/examples/threads/mandelbrot/renderthread.cpp
+++ b/examples/threads/mandelbrot/renderthread.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <math.h>
diff --git a/examples/threads/queuedcustomtype/queuedcustomtype.pro b/examples/threads/queuedcustomtype/queuedcustomtype.pro
index 6f39121df7..f26ab6cde5 100644
--- a/examples/threads/queuedcustomtype/queuedcustomtype.pro
+++ b/examples/threads/queuedcustomtype/queuedcustomtype.pro
@@ -5,3 +5,4 @@ SOURCES = main.cpp \
block.cpp \
renderthread.cpp \
window.cpp
+QT += widgets
diff --git a/examples/threads/queuedcustomtype/window.cpp b/examples/threads/queuedcustomtype/window.cpp
index 367b75818f..26a78af969 100644
--- a/examples/threads/queuedcustomtype/window.cpp
+++ b/examples/threads/queuedcustomtype/window.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "window.h"
//! [Window constructor start]
diff --git a/examples/threads/threads.pro b/examples/threads/threads.pro
index fd62ccec11..33a9d95770 100644
--- a/examples/threads/threads.pro
+++ b/examples/threads/threads.pro
@@ -11,3 +11,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/threads
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tools/codecs/codecs.pro b/examples/tools/codecs/codecs.pro
index 2403fc8506..5f92b94a00 100644
--- a/examples/tools/codecs/codecs.pro
+++ b/examples/tools/codecs/codecs.pro
@@ -11,3 +11,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tools/codecs
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tools/codecs/mainwindow.cpp b/examples/tools/codecs/mainwindow.cpp
index 25eda1d2ba..bad23e9531 100644
--- a/examples/tools/codecs/mainwindow.cpp
+++ b/examples/tools/codecs/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
#include "previewform.h"
diff --git a/examples/tools/codecs/previewform.cpp b/examples/tools/codecs/previewform.cpp
index 523be6cb0f..1fc87c978d 100644
--- a/examples/tools/codecs/previewform.cpp
+++ b/examples/tools/codecs/previewform.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "previewform.h"
diff --git a/examples/tools/completer/completer.pro b/examples/tools/completer/completer.pro
index 3db4484662..016b7547f9 100644
--- a/examples/tools/completer/completer.pro
+++ b/examples/tools/completer/completer.pro
@@ -12,3 +12,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tools/completer
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tools/completer/mainwindow.cpp b/examples/tools/completer/mainwindow.cpp
index 8c848615dc..d56ed01108 100644
--- a/examples/tools/completer/mainwindow.cpp
+++ b/examples/tools/completer/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "fsmodel.h"
#include "mainwindow.h"
diff --git a/examples/tools/contiguouscache/contiguouscache.pro b/examples/tools/contiguouscache/contiguouscache.pro
index 45166d380e..1bdd5b9573 100644
--- a/examples/tools/contiguouscache/contiguouscache.pro
+++ b/examples/tools/contiguouscache/contiguouscache.pro
@@ -7,3 +7,4 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tools/contiguouscache
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS contiguouscache.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tools/contiguouscache
INSTALLS += target sources
+QT += widgets
diff --git a/examples/tools/customcompleter/customcompleter.pro b/examples/tools/customcompleter/customcompleter.pro
index 3b0874cbdc..b4bbace109 100644
--- a/examples/tools/customcompleter/customcompleter.pro
+++ b/examples/tools/customcompleter/customcompleter.pro
@@ -12,3 +12,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tools/customcompleter
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tools/customcompleter/mainwindow.cpp b/examples/tools/customcompleter/mainwindow.cpp
index c4a7c76e3b..ecb246f15b 100644
--- a/examples/tools/customcompleter/mainwindow.cpp
+++ b/examples/tools/customcompleter/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
#include "textedit.h"
diff --git a/examples/tools/customtype/customtype.pro b/examples/tools/customtype/customtype.pro
index 3079964946..893c9132ab 100644
--- a/examples/tools/customtype/customtype.pro
+++ b/examples/tools/customtype/customtype.pro
@@ -1,3 +1,4 @@
HEADERS = message.h
SOURCES = main.cpp \
message.cpp
+QT += widgets
diff --git a/examples/tools/customtypesending/customtypesending.pro b/examples/tools/customtypesending/customtypesending.pro
index b8b2aaf5fe..0c13eaca19 100644
--- a/examples/tools/customtypesending/customtypesending.pro
+++ b/examples/tools/customtypesending/customtypesending.pro
@@ -3,3 +3,4 @@ HEADERS = message.h \
SOURCES = main.cpp \
message.cpp \
window.cpp
+QT += widgets
diff --git a/examples/tools/customtypesending/window.cpp b/examples/tools/customtypesending/window.cpp
index 24845a4279..813fea9b1d 100644
--- a/examples/tools/customtypesending/window.cpp
+++ b/examples/tools/customtypesending/window.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "window.h"
//! [Window constructor]
diff --git a/examples/tools/echoplugin/echoplugin.pro b/examples/tools/echoplugin/echoplugin.pro
index 164dcadcf5..94dc8baca1 100644
--- a/examples/tools/echoplugin/echoplugin.pro
+++ b/examples/tools/echoplugin/echoplugin.pro
@@ -11,3 +11,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tools/echoplugin
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tools/echoplugin/echowindow/echowindow.cpp b/examples/tools/echoplugin/echowindow/echowindow.cpp
index 9e6460a3f7..75e9f161b1 100644
--- a/examples/tools/echoplugin/echowindow/echowindow.cpp
+++ b/examples/tools/echoplugin/echowindow/echowindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "echowindow.h"
diff --git a/examples/tools/echoplugin/echowindow/echowindow.pro b/examples/tools/echoplugin/echowindow/echowindow.pro
index c1b65bfec7..59347da188 100644
--- a/examples/tools/echoplugin/echowindow/echowindow.pro
+++ b/examples/tools/echoplugin/echowindow/echowindow.pro
@@ -19,3 +19,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tools/echoplugin/echowindow
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tools/echoplugin/echowindow/main.cpp b/examples/tools/echoplugin/echowindow/main.cpp
index 585c8da6e7..c4659d8813 100644
--- a/examples/tools/echoplugin/echowindow/main.cpp
+++ b/examples/tools/echoplugin/echowindow/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "echowindow.h"
#include "echointerface.h"
diff --git a/examples/tools/echoplugin/plugin/echoplugin.cpp b/examples/tools/echoplugin/plugin/echoplugin.cpp
index 099ab81cb1..daa95aa63c 100644
--- a/examples/tools/echoplugin/plugin/echoplugin.cpp
+++ b/examples/tools/echoplugin/plugin/echoplugin.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "echoplugin.h"
diff --git a/examples/tools/echoplugin/plugin/plugin.pro b/examples/tools/echoplugin/plugin/plugin.pro
index 617c1dd58f..c591850597 100644
--- a/examples/tools/echoplugin/plugin/plugin.pro
+++ b/examples/tools/echoplugin/plugin/plugin.pro
@@ -17,3 +17,4 @@ INSTALLS += target sources
symbian: CONFIG += qt_example
symbian:TARGET.EPOCALLOWDLLDATA = 1
+QT += widgets
diff --git a/examples/tools/i18n/i18n.pro b/examples/tools/i18n/i18n.pro
index c68620a989..b470587228 100644
--- a/examples/tools/i18n/i18n.pro
+++ b/examples/tools/i18n/i18n.pro
@@ -26,3 +26,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tools/i18n
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tools/i18n/languagechooser.cpp b/examples/tools/i18n/languagechooser.cpp
index 888e6aca83..1c03453793 100644
--- a/examples/tools/i18n/languagechooser.cpp
+++ b/examples/tools/i18n/languagechooser.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "languagechooser.h"
#include "mainwindow.h"
diff --git a/examples/tools/i18n/mainwindow.cpp b/examples/tools/i18n/mainwindow.cpp
index 8e1b14160f..34fd99d868 100644
--- a/examples/tools/i18n/mainwindow.cpp
+++ b/examples/tools/i18n/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
diff --git a/examples/tools/inputpanel/inputpanel.pro b/examples/tools/inputpanel/inputpanel.pro
index e8582a9ea0..2d493217a7 100644
--- a/examples/tools/inputpanel/inputpanel.pro
+++ b/examples/tools/inputpanel/inputpanel.pro
@@ -15,3 +15,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tools/inputpanel
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tools/inputpanel/main.cpp b/examples/tools/inputpanel/main.cpp
index 2760e98d79..9d0c350faa 100644
--- a/examples/tools/inputpanel/main.cpp
+++ b/examples/tools/inputpanel/main.cpp
@@ -38,8 +38,8 @@
**
****************************************************************************/
-#include <QtGui/QApplication>
-#include <QtGui/QWidget>
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QWidget>
//! [main]
#include "myinputpanelcontext.h"
diff --git a/examples/tools/inputpanel/myinputpanel.h b/examples/tools/inputpanel/myinputpanel.h
index c1d5d1ff25..0d11e9c038 100644
--- a/examples/tools/inputpanel/myinputpanel.h
+++ b/examples/tools/inputpanel/myinputpanel.h
@@ -41,7 +41,7 @@
#ifndef MYINPUTPANEL_H
#define MYINPUTPANEL_H
-#include <QtGui>
+#include <QtWidgets>
#include <QtCore>
#include "ui_myinputpanelform.h"
diff --git a/examples/tools/inputpanel/myinputpanelcontext.h b/examples/tools/inputpanel/myinputpanelcontext.h
index bb40e211a7..e69a496040 100644
--- a/examples/tools/inputpanel/myinputpanelcontext.h
+++ b/examples/tools/inputpanel/myinputpanelcontext.h
@@ -41,7 +41,7 @@
#ifndef MYINPUTPANELCONTEXT_H
#define MYINPUTPANELCONTEXT_H
-#include <QtGui/QInputContext>
+#include <QtWidgets/QInputContext>
#include "myinputpanel.h"
diff --git a/examples/tools/plugandpaint/plugandpaint.pro b/examples/tools/plugandpaint/plugandpaint.pro
index 8b91053230..88535483f2 100644
--- a/examples/tools/plugandpaint/plugandpaint.pro
+++ b/examples/tools/plugandpaint/plugandpaint.pro
@@ -26,3 +26,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tools/plugandpaint
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tools/plugandpaintplugins/basictools/basictools.pro b/examples/tools/plugandpaintplugins/basictools/basictools.pro
index 26a3f98bce..a614d507d2 100644
--- a/examples/tools/plugandpaintplugins/basictools/basictools.pro
+++ b/examples/tools/plugandpaintplugins/basictools/basictools.pro
@@ -15,3 +15,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tools/plugandpaintplugins/basictoo
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp b/examples/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp
index a35dae7ab9..3e0af26efa 100644
--- a/examples/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp
+++ b/examples/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <math.h>
#include <stdlib.h>
diff --git a/examples/tools/plugandpaintplugins/extrafilters/extrafilters.pro b/examples/tools/plugandpaintplugins/extrafilters/extrafilters.pro
index a9dc116bc5..5c3805d8af 100644
--- a/examples/tools/plugandpaintplugins/extrafilters/extrafilters.pro
+++ b/examples/tools/plugandpaintplugins/extrafilters/extrafilters.pro
@@ -17,3 +17,4 @@ INSTALLS += target sources
symbian: CONFIG += qt_example
symbian:TARGET.EPOCALLOWDLLDATA = 1
+QT += widgets
diff --git a/examples/tools/plugandpaintplugins/extrafilters/extrafiltersplugin.cpp b/examples/tools/plugandpaintplugins/extrafilters/extrafiltersplugin.cpp
index 9f8ca48650..e58fde2205 100644
--- a/examples/tools/plugandpaintplugins/extrafilters/extrafiltersplugin.cpp
+++ b/examples/tools/plugandpaintplugins/extrafilters/extrafiltersplugin.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <math.h>
#include <stdlib.h>
diff --git a/examples/tools/plugandpaintplugins/plugandpaintplugins.pro b/examples/tools/plugandpaintplugins/plugandpaintplugins.pro
index 857b62e88e..ef85148559 100644
--- a/examples/tools/plugandpaintplugins/plugandpaintplugins.pro
+++ b/examples/tools/plugandpaintplugins/plugandpaintplugins.pro
@@ -9,3 +9,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tools/plugandpaintplugins
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tools/regexp/regexp.pro b/examples/tools/regexp/regexp.pro
index 66904809f9..c6f4846e94 100644
--- a/examples/tools/regexp/regexp.pro
+++ b/examples/tools/regexp/regexp.pro
@@ -9,3 +9,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tools/regexp
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tools/regexp/regexpdialog.cpp b/examples/tools/regexp/regexpdialog.cpp
index 583c384bdd..b9468bd49f 100644
--- a/examples/tools/regexp/regexpdialog.cpp
+++ b/examples/tools/regexp/regexpdialog.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "regexpdialog.h"
diff --git a/examples/tools/settingseditor/locationdialog.cpp b/examples/tools/settingseditor/locationdialog.cpp
index 911392630b..de7e5bcada 100644
--- a/examples/tools/settingseditor/locationdialog.cpp
+++ b/examples/tools/settingseditor/locationdialog.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "locationdialog.h"
diff --git a/examples/tools/settingseditor/mainwindow.cpp b/examples/tools/settingseditor/mainwindow.cpp
index 4b8bc4e2b8..6b875f3a24 100644
--- a/examples/tools/settingseditor/mainwindow.cpp
+++ b/examples/tools/settingseditor/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "locationdialog.h"
#include "mainwindow.h"
diff --git a/examples/tools/settingseditor/settingseditor.pro b/examples/tools/settingseditor/settingseditor.pro
index 140e59f6ac..ebf9a9240a 100644
--- a/examples/tools/settingseditor/settingseditor.pro
+++ b/examples/tools/settingseditor/settingseditor.pro
@@ -15,3 +15,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tools/settingseditor
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tools/settingseditor/settingstree.cpp b/examples/tools/settingseditor/settingstree.cpp
index 1fd80d756b..892cb30590 100644
--- a/examples/tools/settingseditor/settingstree.cpp
+++ b/examples/tools/settingseditor/settingstree.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "settingstree.h"
#include "variantdelegate.h"
diff --git a/examples/tools/settingseditor/variantdelegate.cpp b/examples/tools/settingseditor/variantdelegate.cpp
index 5827b8447f..e4b532f9fe 100644
--- a/examples/tools/settingseditor/variantdelegate.cpp
+++ b/examples/tools/settingseditor/variantdelegate.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "variantdelegate.h"
diff --git a/examples/tools/styleplugin/plugin/plugin.pro b/examples/tools/styleplugin/plugin/plugin.pro
index 319a2be15b..795da2cb9f 100644
--- a/examples/tools/styleplugin/plugin/plugin.pro
+++ b/examples/tools/styleplugin/plugin/plugin.pro
@@ -23,3 +23,4 @@ INSTALLS += target sources
symbian: CONFIG += qt_example
symbian:TARGET.EPOCALLOWDLLDATA = 1
+QT += widgets
diff --git a/examples/tools/styleplugin/plugin/simplestyle.cpp b/examples/tools/styleplugin/plugin/simplestyle.cpp
index ea672166e2..d897f3a39b 100644
--- a/examples/tools/styleplugin/plugin/simplestyle.cpp
+++ b/examples/tools/styleplugin/plugin/simplestyle.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "simplestyle.h"
diff --git a/examples/tools/styleplugin/plugin/simplestyleplugin.cpp b/examples/tools/styleplugin/plugin/simplestyleplugin.cpp
index 28dbe5c857..d5acd08206 100644
--- a/examples/tools/styleplugin/plugin/simplestyleplugin.cpp
+++ b/examples/tools/styleplugin/plugin/simplestyleplugin.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "simplestyleplugin.h"
#include "simplestyle.h"
diff --git a/examples/tools/styleplugin/styleplugin.pro b/examples/tools/styleplugin/styleplugin.pro
index 69935f666e..fd03f0075f 100644
--- a/examples/tools/styleplugin/styleplugin.pro
+++ b/examples/tools/styleplugin/styleplugin.pro
@@ -9,3 +9,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tools/styleplugin
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tools/styleplugin/stylewindow/main.cpp b/examples/tools/styleplugin/stylewindow/main.cpp
index 1cf42aa86d..da6e218000 100644
--- a/examples/tools/styleplugin/stylewindow/main.cpp
+++ b/examples/tools/styleplugin/stylewindow/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "stylewindow.h"
diff --git a/examples/tools/styleplugin/stylewindow/stylewindow.cpp b/examples/tools/styleplugin/stylewindow/stylewindow.cpp
index eb2e3c3007..3a4da98494 100644
--- a/examples/tools/styleplugin/stylewindow/stylewindow.cpp
+++ b/examples/tools/styleplugin/stylewindow/stylewindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "stylewindow.h"
diff --git a/examples/tools/styleplugin/stylewindow/stylewindow.pro b/examples/tools/styleplugin/stylewindow/stylewindow.pro
index 6d6d9f5049..35e0a65dd1 100644
--- a/examples/tools/styleplugin/stylewindow/stylewindow.pro
+++ b/examples/tools/styleplugin/stylewindow/stylewindow.pro
@@ -17,3 +17,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tools/styleplugin/stylewindow
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tools/tools.pro b/examples/tools/tools.pro
index 4b8c896484..6d0d722995 100644
--- a/examples/tools/tools.pro
+++ b/examples/tools/tools.pro
@@ -24,3 +24,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tools
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tools/treemodelcompleter/mainwindow.cpp b/examples/tools/treemodelcompleter/mainwindow.cpp
index 3f832fa6ec..6d8c7aec80 100644
--- a/examples/tools/treemodelcompleter/mainwindow.cpp
+++ b/examples/tools/treemodelcompleter/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "treemodelcompleter.h"
#include "mainwindow.h"
diff --git a/examples/tools/treemodelcompleter/treemodelcompleter.pro b/examples/tools/treemodelcompleter/treemodelcompleter.pro
index 11f59085e3..220cdb9091 100644
--- a/examples/tools/treemodelcompleter/treemodelcompleter.pro
+++ b/examples/tools/treemodelcompleter/treemodelcompleter.pro
@@ -12,3 +12,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tools/treemodelcompleter
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tools/undoframework/commands.cpp b/examples/tools/undoframework/commands.cpp
index ff7b0b7f1d..03f8b98d74 100644
--- a/examples/tools/undoframework/commands.cpp
+++ b/examples/tools/undoframework/commands.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "commands.h"
#include "diagramitem.h"
diff --git a/examples/tools/undoframework/diagramitem.cpp b/examples/tools/undoframework/diagramitem.cpp
index 3e896f3926..815c8dd69e 100644
--- a/examples/tools/undoframework/diagramitem.cpp
+++ b/examples/tools/undoframework/diagramitem.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "diagramitem.h"
diff --git a/examples/tools/undoframework/diagramscene.cpp b/examples/tools/undoframework/diagramscene.cpp
index 7ffd2db3ac..c60ccc915b 100644
--- a/examples/tools/undoframework/diagramscene.cpp
+++ b/examples/tools/undoframework/diagramscene.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "diagramscene.h"
#include "diagramitem.h"
diff --git a/examples/tools/undoframework/main.cpp b/examples/tools/undoframework/main.cpp
index abfa0aa462..385311cb1d 100644
--- a/examples/tools/undoframework/main.cpp
+++ b/examples/tools/undoframework/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
diff --git a/examples/tools/undoframework/mainwindow.cpp b/examples/tools/undoframework/mainwindow.cpp
index 72c9cc14f4..52a2cffac3 100644
--- a/examples/tools/undoframework/mainwindow.cpp
+++ b/examples/tools/undoframework/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
#include "diagramscene.h"
diff --git a/examples/tools/undoframework/undoframework.pro b/examples/tools/undoframework/undoframework.pro
index ce11d353ad..cac35b01d9 100644
--- a/examples/tools/undoframework/undoframework.pro
+++ b/examples/tools/undoframework/undoframework.pro
@@ -16,3 +16,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tools/undoframework
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/touch/dials/dials.pro b/examples/touch/dials/dials.pro
index 7f8ec9b616..e7d40b6409 100644
--- a/examples/touch/dials/dials.pro
+++ b/examples/touch/dials/dials.pro
@@ -6,3 +6,4 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/touch/dials
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS dials.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/touch/dials
INSTALLS += target sources
+QT += widgets
diff --git a/examples/touch/fingerpaint/fingerpaint.pro b/examples/touch/fingerpaint/fingerpaint.pro
index 21e4294cf8..3572674e3a 100644
--- a/examples/touch/fingerpaint/fingerpaint.pro
+++ b/examples/touch/fingerpaint/fingerpaint.pro
@@ -9,3 +9,4 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/touch/fingerpaint
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS fingerpaint.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/touch/fingerpaint
INSTALLS += target sources
+QT += widgets
diff --git a/examples/touch/fingerpaint/mainwindow.cpp b/examples/touch/fingerpaint/mainwindow.cpp
index 37b7ed73f4..8388522432 100644
--- a/examples/touch/fingerpaint/mainwindow.cpp
+++ b/examples/touch/fingerpaint/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
#include "scribblearea.h"
diff --git a/examples/touch/fingerpaint/scribblearea.cpp b/examples/touch/fingerpaint/scribblearea.cpp
index f66e61cfd3..3b3b2ce33f 100644
--- a/examples/touch/fingerpaint/scribblearea.cpp
+++ b/examples/touch/fingerpaint/scribblearea.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "scribblearea.h"
diff --git a/examples/touch/knobs/knobs.pro b/examples/touch/knobs/knobs.pro
index c1caa98dfd..89793f5dde 100644
--- a/examples/touch/knobs/knobs.pro
+++ b/examples/touch/knobs/knobs.pro
@@ -6,3 +6,4 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/touch/knobs
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS knobs.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/touch/knobs
INSTALLS += target sources
+QT += widgets
diff --git a/examples/touch/pinchzoom/main.cpp b/examples/touch/pinchzoom/main.cpp
index defe0028af..bf8528c1e4 100644
--- a/examples/touch/pinchzoom/main.cpp
+++ b/examples/touch/pinchzoom/main.cpp
@@ -41,7 +41,7 @@
#include "graphicsview.h"
#include "mouse.h"
-#include <QtGui>
+#include <QtWidgets>
#include <math.h>
diff --git a/examples/touch/pinchzoom/pinchzoom.pro b/examples/touch/pinchzoom/pinchzoom.pro
index e6864237e3..660fbc5563 100644
--- a/examples/touch/pinchzoom/pinchzoom.pro
+++ b/examples/touch/pinchzoom/pinchzoom.pro
@@ -14,3 +14,4 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/touch/pinchzoom
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS pinchzoom.pro images
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/touch/pinchzoom
INSTALLS += target sources
+QT += widgets
diff --git a/examples/touch/touch.pro b/examples/touch/touch.pro
index d5983eb581..515b480f86 100644
--- a/examples/touch/touch.pro
+++ b/examples/touch/touch.pro
@@ -1,2 +1,3 @@
TEMPLATE = subdirs
SUBDIRS = pinchzoom fingerpaint knobs dials
+QT += widgets
diff --git a/examples/tutorials/addressbook-fr/addressbook-fr.pro b/examples/tutorials/addressbook-fr/addressbook-fr.pro
index ba945e24d6..0b76e41169 100644
--- a/examples/tutorials/addressbook-fr/addressbook-fr.pro
+++ b/examples/tutorials/addressbook-fr/addressbook-fr.pro
@@ -6,3 +6,4 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/addressbook-fr
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS addressbook-fr.pro README
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/addressbook-fr
INSTALLS += target sources
+QT += widgets
diff --git a/examples/tutorials/addressbook-fr/part1/addressbook.cpp b/examples/tutorials/addressbook-fr/part1/addressbook.cpp
index 7ff4c9ea79..372aa43ed0 100644
--- a/examples/tutorials/addressbook-fr/part1/addressbook.cpp
+++ b/examples/tutorials/addressbook-fr/part1/addressbook.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
//! [constructor and input fields]
diff --git a/examples/tutorials/addressbook-fr/part1/main.cpp b/examples/tutorials/addressbook-fr/part1/main.cpp
index 970921d537..a17c894a4b 100644
--- a/examples/tutorials/addressbook-fr/part1/main.cpp
+++ b/examples/tutorials/addressbook-fr/part1/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
//! [main function]
diff --git a/examples/tutorials/addressbook-fr/part1/part1.pro b/examples/tutorials/addressbook-fr/part1/part1.pro
index c22df740f4..a11c0889ee 100644
--- a/examples/tutorials/addressbook-fr/part1/part1.pro
+++ b/examples/tutorials/addressbook-fr/part1/part1.pro
@@ -7,3 +7,4 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/addressbook/part1
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS part1.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/addressbook/part1
INSTALLS += target sources
+QT += widgets
diff --git a/examples/tutorials/addressbook-fr/part2/addressbook.cpp b/examples/tutorials/addressbook-fr/part2/addressbook.cpp
index 36023c850a..04d4b2c693 100644
--- a/examples/tutorials/addressbook-fr/part2/addressbook.cpp
+++ b/examples/tutorials/addressbook-fr/part2/addressbook.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
AddressBook::AddressBook(QWidget *parent)
diff --git a/examples/tutorials/addressbook-fr/part2/main.cpp b/examples/tutorials/addressbook-fr/part2/main.cpp
index 970921d537..a17c894a4b 100644
--- a/examples/tutorials/addressbook-fr/part2/main.cpp
+++ b/examples/tutorials/addressbook-fr/part2/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
//! [main function]
diff --git a/examples/tutorials/addressbook-fr/part2/part2.pro b/examples/tutorials/addressbook-fr/part2/part2.pro
index a0a53e6e6c..9d90065f2d 100644
--- a/examples/tutorials/addressbook-fr/part2/part2.pro
+++ b/examples/tutorials/addressbook-fr/part2/part2.pro
@@ -7,3 +7,4 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/addressbook/part2
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS part2.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/addressbook/part2
INSTALLS += target sources
+QT += widgets
diff --git a/examples/tutorials/addressbook-fr/part3/addressbook.cpp b/examples/tutorials/addressbook-fr/part3/addressbook.cpp
index 47d312e7ac..ee57b19b08 100644
--- a/examples/tutorials/addressbook-fr/part3/addressbook.cpp
+++ b/examples/tutorials/addressbook-fr/part3/addressbook.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
AddressBook::AddressBook(QWidget *parent)
diff --git a/examples/tutorials/addressbook-fr/part3/main.cpp b/examples/tutorials/addressbook-fr/part3/main.cpp
index 2c92e255b8..15991677c2 100644
--- a/examples/tutorials/addressbook-fr/part3/main.cpp
+++ b/examples/tutorials/addressbook-fr/part3/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
int main(int argc, char *argv[])
diff --git a/examples/tutorials/addressbook-fr/part3/part3.pro b/examples/tutorials/addressbook-fr/part3/part3.pro
index 0e28296c5d..ac076242f7 100644
--- a/examples/tutorials/addressbook-fr/part3/part3.pro
+++ b/examples/tutorials/addressbook-fr/part3/part3.pro
@@ -7,3 +7,4 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/addressbook/part3
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS part3.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/addressbook/part3
INSTALLS += target sources
+QT += widgets
diff --git a/examples/tutorials/addressbook-fr/part4/addressbook.cpp b/examples/tutorials/addressbook-fr/part4/addressbook.cpp
index e88ab6a8e2..047bc6e05c 100644
--- a/examples/tutorials/addressbook-fr/part4/addressbook.cpp
+++ b/examples/tutorials/addressbook-fr/part4/addressbook.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
AddressBook::AddressBook(QWidget *parent)
diff --git a/examples/tutorials/addressbook-fr/part4/main.cpp b/examples/tutorials/addressbook-fr/part4/main.cpp
index 2c92e255b8..15991677c2 100644
--- a/examples/tutorials/addressbook-fr/part4/main.cpp
+++ b/examples/tutorials/addressbook-fr/part4/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
int main(int argc, char *argv[])
diff --git a/examples/tutorials/addressbook-fr/part4/part4.pro b/examples/tutorials/addressbook-fr/part4/part4.pro
index 31458a79b9..70dc8f2bc4 100644
--- a/examples/tutorials/addressbook-fr/part4/part4.pro
+++ b/examples/tutorials/addressbook-fr/part4/part4.pro
@@ -7,3 +7,4 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/addressbook/part4
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS part4.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/addressbook/part4
INSTALLS += target sources
+QT += widgets
diff --git a/examples/tutorials/addressbook-fr/part5/addressbook.cpp b/examples/tutorials/addressbook-fr/part5/addressbook.cpp
index 471ffa3663..3f381766c6 100644
--- a/examples/tutorials/addressbook-fr/part5/addressbook.cpp
+++ b/examples/tutorials/addressbook-fr/part5/addressbook.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
AddressBook::AddressBook(QWidget *parent)
diff --git a/examples/tutorials/addressbook-fr/part5/finddialog.cpp b/examples/tutorials/addressbook-fr/part5/finddialog.cpp
index 03d4abf1ac..5bba3afd94 100644
--- a/examples/tutorials/addressbook-fr/part5/finddialog.cpp
+++ b/examples/tutorials/addressbook-fr/part5/finddialog.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "finddialog.h"
//! [constructor]
diff --git a/examples/tutorials/addressbook-fr/part5/main.cpp b/examples/tutorials/addressbook-fr/part5/main.cpp
index 2c92e255b8..15991677c2 100644
--- a/examples/tutorials/addressbook-fr/part5/main.cpp
+++ b/examples/tutorials/addressbook-fr/part5/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
int main(int argc, char *argv[])
diff --git a/examples/tutorials/addressbook-fr/part5/part5.pro b/examples/tutorials/addressbook-fr/part5/part5.pro
index 0899fdd90a..99d0a54c53 100644
--- a/examples/tutorials/addressbook-fr/part5/part5.pro
+++ b/examples/tutorials/addressbook-fr/part5/part5.pro
@@ -9,3 +9,4 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/addressbook/part5
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS part5.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/addressbook/part5
INSTALLS += target sources
+QT += widgets
diff --git a/examples/tutorials/addressbook-fr/part6/addressbook.cpp b/examples/tutorials/addressbook-fr/part6/addressbook.cpp
index a085ab3bed..354b482742 100644
--- a/examples/tutorials/addressbook-fr/part6/addressbook.cpp
+++ b/examples/tutorials/addressbook-fr/part6/addressbook.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
AddressBook::AddressBook(QWidget *parent)
diff --git a/examples/tutorials/addressbook-fr/part6/finddialog.cpp b/examples/tutorials/addressbook-fr/part6/finddialog.cpp
index 9e4342a590..86d4df9227 100644
--- a/examples/tutorials/addressbook-fr/part6/finddialog.cpp
+++ b/examples/tutorials/addressbook-fr/part6/finddialog.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "finddialog.h"
FindDialog::FindDialog(QWidget *parent)
diff --git a/examples/tutorials/addressbook-fr/part6/main.cpp b/examples/tutorials/addressbook-fr/part6/main.cpp
index 2c92e255b8..15991677c2 100644
--- a/examples/tutorials/addressbook-fr/part6/main.cpp
+++ b/examples/tutorials/addressbook-fr/part6/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
int main(int argc, char *argv[])
diff --git a/examples/tutorials/addressbook-fr/part6/part6.pro b/examples/tutorials/addressbook-fr/part6/part6.pro
index df161f44fa..9b9fc52dd9 100644
--- a/examples/tutorials/addressbook-fr/part6/part6.pro
+++ b/examples/tutorials/addressbook-fr/part6/part6.pro
@@ -9,3 +9,4 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/addressbook/part6
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS part6.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/addressbook/part6
INSTALLS += target sources
+QT += widgets
diff --git a/examples/tutorials/addressbook-fr/part7/addressbook.cpp b/examples/tutorials/addressbook-fr/part7/addressbook.cpp
index 68a4b4cc85..73ec3dcf23 100644
--- a/examples/tutorials/addressbook-fr/part7/addressbook.cpp
+++ b/examples/tutorials/addressbook-fr/part7/addressbook.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
AddressBook::AddressBook(QWidget *parent)
diff --git a/examples/tutorials/addressbook-fr/part7/finddialog.cpp b/examples/tutorials/addressbook-fr/part7/finddialog.cpp
index 9e4342a590..86d4df9227 100644
--- a/examples/tutorials/addressbook-fr/part7/finddialog.cpp
+++ b/examples/tutorials/addressbook-fr/part7/finddialog.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "finddialog.h"
FindDialog::FindDialog(QWidget *parent)
diff --git a/examples/tutorials/addressbook-fr/part7/main.cpp b/examples/tutorials/addressbook-fr/part7/main.cpp
index 2c92e255b8..15991677c2 100644
--- a/examples/tutorials/addressbook-fr/part7/main.cpp
+++ b/examples/tutorials/addressbook-fr/part7/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
int main(int argc, char *argv[])
diff --git a/examples/tutorials/addressbook-fr/part7/part7.pro b/examples/tutorials/addressbook-fr/part7/part7.pro
index 22f4435559..bf70213d93 100644
--- a/examples/tutorials/addressbook-fr/part7/part7.pro
+++ b/examples/tutorials/addressbook-fr/part7/part7.pro
@@ -9,3 +9,4 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/addressbook/part7
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS part7.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/addressbook/part7
INSTALLS += target sources
+QT += widgets
diff --git a/examples/tutorials/addressbook/addressbook.pro b/examples/tutorials/addressbook/addressbook.pro
index 575f5cb518..ee13040220 100644
--- a/examples/tutorials/addressbook/addressbook.pro
+++ b/examples/tutorials/addressbook/addressbook.pro
@@ -8,3 +8,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/addressbook
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tutorials/addressbook/part1/addressbook.cpp b/examples/tutorials/addressbook/part1/addressbook.cpp
index 7ff4c9ea79..372aa43ed0 100644
--- a/examples/tutorials/addressbook/part1/addressbook.cpp
+++ b/examples/tutorials/addressbook/part1/addressbook.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
//! [constructor and input fields]
diff --git a/examples/tutorials/addressbook/part1/main.cpp b/examples/tutorials/addressbook/part1/main.cpp
index 970921d537..a17c894a4b 100644
--- a/examples/tutorials/addressbook/part1/main.cpp
+++ b/examples/tutorials/addressbook/part1/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
//! [main function]
diff --git a/examples/tutorials/addressbook/part1/part1.pro b/examples/tutorials/addressbook/part1/part1.pro
index b392ee06c9..272024a652 100644
--- a/examples/tutorials/addressbook/part1/part1.pro
+++ b/examples/tutorials/addressbook/part1/part1.pro
@@ -9,3 +9,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/addressbook/part1
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tutorials/addressbook/part2/addressbook.cpp b/examples/tutorials/addressbook/part2/addressbook.cpp
index 5fccd12b8e..a7d50017c6 100644
--- a/examples/tutorials/addressbook/part2/addressbook.cpp
+++ b/examples/tutorials/addressbook/part2/addressbook.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
AddressBook::AddressBook(QWidget *parent)
diff --git a/examples/tutorials/addressbook/part2/main.cpp b/examples/tutorials/addressbook/part2/main.cpp
index 970921d537..a17c894a4b 100644
--- a/examples/tutorials/addressbook/part2/main.cpp
+++ b/examples/tutorials/addressbook/part2/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
//! [main function]
diff --git a/examples/tutorials/addressbook/part2/part2.pro b/examples/tutorials/addressbook/part2/part2.pro
index 8dbf7f21f5..57c547563d 100644
--- a/examples/tutorials/addressbook/part2/part2.pro
+++ b/examples/tutorials/addressbook/part2/part2.pro
@@ -9,3 +9,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/addressbook/part2
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tutorials/addressbook/part3/addressbook.cpp b/examples/tutorials/addressbook/part3/addressbook.cpp
index 72ca52b199..b539c01776 100644
--- a/examples/tutorials/addressbook/part3/addressbook.cpp
+++ b/examples/tutorials/addressbook/part3/addressbook.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
AddressBook::AddressBook(QWidget *parent)
diff --git a/examples/tutorials/addressbook/part3/main.cpp b/examples/tutorials/addressbook/part3/main.cpp
index 2c92e255b8..15991677c2 100644
--- a/examples/tutorials/addressbook/part3/main.cpp
+++ b/examples/tutorials/addressbook/part3/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
int main(int argc, char *argv[])
diff --git a/examples/tutorials/addressbook/part3/part3.pro b/examples/tutorials/addressbook/part3/part3.pro
index 7ab6731a0a..c352115602 100644
--- a/examples/tutorials/addressbook/part3/part3.pro
+++ b/examples/tutorials/addressbook/part3/part3.pro
@@ -9,3 +9,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/addressbook/part3
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tutorials/addressbook/part4/addressbook.cpp b/examples/tutorials/addressbook/part4/addressbook.cpp
index bbb5e03987..d82dda74c4 100644
--- a/examples/tutorials/addressbook/part4/addressbook.cpp
+++ b/examples/tutorials/addressbook/part4/addressbook.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
AddressBook::AddressBook(QWidget *parent)
diff --git a/examples/tutorials/addressbook/part4/main.cpp b/examples/tutorials/addressbook/part4/main.cpp
index 2c92e255b8..15991677c2 100644
--- a/examples/tutorials/addressbook/part4/main.cpp
+++ b/examples/tutorials/addressbook/part4/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
int main(int argc, char *argv[])
diff --git a/examples/tutorials/addressbook/part4/part4.pro b/examples/tutorials/addressbook/part4/part4.pro
index 8dbba2e982..b288857339 100644
--- a/examples/tutorials/addressbook/part4/part4.pro
+++ b/examples/tutorials/addressbook/part4/part4.pro
@@ -9,3 +9,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/addressbook/part4
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tutorials/addressbook/part5/addressbook.cpp b/examples/tutorials/addressbook/part5/addressbook.cpp
index 7489e7c9db..6342db3f8d 100644
--- a/examples/tutorials/addressbook/part5/addressbook.cpp
+++ b/examples/tutorials/addressbook/part5/addressbook.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
AddressBook::AddressBook(QWidget *parent)
diff --git a/examples/tutorials/addressbook/part5/finddialog.cpp b/examples/tutorials/addressbook/part5/finddialog.cpp
index 03d4abf1ac..5bba3afd94 100644
--- a/examples/tutorials/addressbook/part5/finddialog.cpp
+++ b/examples/tutorials/addressbook/part5/finddialog.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "finddialog.h"
//! [constructor]
diff --git a/examples/tutorials/addressbook/part5/main.cpp b/examples/tutorials/addressbook/part5/main.cpp
index 2c92e255b8..15991677c2 100644
--- a/examples/tutorials/addressbook/part5/main.cpp
+++ b/examples/tutorials/addressbook/part5/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
int main(int argc, char *argv[])
diff --git a/examples/tutorials/addressbook/part5/part5.pro b/examples/tutorials/addressbook/part5/part5.pro
index 134a7e0461..6932373ed7 100644
--- a/examples/tutorials/addressbook/part5/part5.pro
+++ b/examples/tutorials/addressbook/part5/part5.pro
@@ -11,3 +11,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/addressbook/part5
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tutorials/addressbook/part6/addressbook.cpp b/examples/tutorials/addressbook/part6/addressbook.cpp
index c7dc8e219b..20425d15c2 100644
--- a/examples/tutorials/addressbook/part6/addressbook.cpp
+++ b/examples/tutorials/addressbook/part6/addressbook.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
AddressBook::AddressBook(QWidget *parent)
diff --git a/examples/tutorials/addressbook/part6/finddialog.cpp b/examples/tutorials/addressbook/part6/finddialog.cpp
index 9e4342a590..86d4df9227 100644
--- a/examples/tutorials/addressbook/part6/finddialog.cpp
+++ b/examples/tutorials/addressbook/part6/finddialog.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "finddialog.h"
FindDialog::FindDialog(QWidget *parent)
diff --git a/examples/tutorials/addressbook/part6/main.cpp b/examples/tutorials/addressbook/part6/main.cpp
index 2c92e255b8..15991677c2 100644
--- a/examples/tutorials/addressbook/part6/main.cpp
+++ b/examples/tutorials/addressbook/part6/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
int main(int argc, char *argv[])
diff --git a/examples/tutorials/addressbook/part6/part6.pro b/examples/tutorials/addressbook/part6/part6.pro
index 42401bd515..b797debc42 100644
--- a/examples/tutorials/addressbook/part6/part6.pro
+++ b/examples/tutorials/addressbook/part6/part6.pro
@@ -11,3 +11,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/addressbook/part6
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tutorials/addressbook/part7/addressbook.cpp b/examples/tutorials/addressbook/part7/addressbook.cpp
index 501ad31c5c..88847f2ea0 100644
--- a/examples/tutorials/addressbook/part7/addressbook.cpp
+++ b/examples/tutorials/addressbook/part7/addressbook.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
AddressBook::AddressBook(QWidget *parent)
diff --git a/examples/tutorials/addressbook/part7/finddialog.cpp b/examples/tutorials/addressbook/part7/finddialog.cpp
index 9e4342a590..86d4df9227 100644
--- a/examples/tutorials/addressbook/part7/finddialog.cpp
+++ b/examples/tutorials/addressbook/part7/finddialog.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "finddialog.h"
FindDialog::FindDialog(QWidget *parent)
diff --git a/examples/tutorials/addressbook/part7/main.cpp b/examples/tutorials/addressbook/part7/main.cpp
index 2c92e255b8..15991677c2 100644
--- a/examples/tutorials/addressbook/part7/main.cpp
+++ b/examples/tutorials/addressbook/part7/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "addressbook.h"
int main(int argc, char *argv[])
diff --git a/examples/tutorials/addressbook/part7/part7.pro b/examples/tutorials/addressbook/part7/part7.pro
index ffa94448ee..49313f1dfa 100644
--- a/examples/tutorials/addressbook/part7/part7.pro
+++ b/examples/tutorials/addressbook/part7/part7.pro
@@ -11,3 +11,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/addressbook/part7
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tutorials/gettingStarted/gettingStarted.pro b/examples/tutorials/gettingStarted/gettingStarted.pro
index 9d10f0f67a..4ab5f4e6dd 100644
--- a/examples/tutorials/gettingStarted/gettingStarted.pro
+++ b/examples/tutorials/gettingStarted/gettingStarted.pro
@@ -1,2 +1,3 @@
TEMPLATE = subdirs
SUBDIRS +=
+QT += widgets
diff --git a/examples/tutorials/gettingStarted/gsQt/gsqt.pro b/examples/tutorials/gettingStarted/gsQt/gsqt.pro
index ee632f96ff..3dac79afce 100755
--- a/examples/tutorials/gettingStarted/gsQt/gsqt.pro
+++ b/examples/tutorials/gettingStarted/gsQt/gsqt.pro
@@ -11,3 +11,4 @@ sources.files = *.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/gettingStarted/gsQt
INSTALLS += sources
+QT += widgets
diff --git a/examples/tutorials/gettingStarted/gsQt/part1/main.cpp b/examples/tutorials/gettingStarted/gsQt/part1/main.cpp
index eaf04256d9..5f5ac7384b 100755
--- a/examples/tutorials/gettingStarted/gsQt/part1/main.cpp
+++ b/examples/tutorials/gettingStarted/gsQt/part1/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
int main(int argv, char **args)
diff --git a/examples/tutorials/gettingStarted/gsQt/part2/main.cpp b/examples/tutorials/gettingStarted/gsQt/part2/main.cpp
index 24b4d77abc..c2b94a3d0c 100755
--- a/examples/tutorials/gettingStarted/gsQt/part2/main.cpp
+++ b/examples/tutorials/gettingStarted/gsQt/part2/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
int main(int argv, char **args)
{
diff --git a/examples/tutorials/gettingStarted/gsQt/part3/main.cpp b/examples/tutorials/gettingStarted/gsQt/part3/main.cpp
index 59ff9c40ea..00fb70a4ab 100755
--- a/examples/tutorials/gettingStarted/gsQt/part3/main.cpp
+++ b/examples/tutorials/gettingStarted/gsQt/part3/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
class Notepad : public QWidget
{
diff --git a/examples/tutorials/gettingStarted/gsQt/part4/main.cpp b/examples/tutorials/gettingStarted/gsQt/part4/main.cpp
index ba18afb749..a8cefe5347 100755
--- a/examples/tutorials/gettingStarted/gsQt/part4/main.cpp
+++ b/examples/tutorials/gettingStarted/gsQt/part4/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
class Notepad : public QMainWindow
{
diff --git a/examples/tutorials/gettingStarted/gsQt/part5/main.cpp b/examples/tutorials/gettingStarted/gsQt/part5/main.cpp
index 4a6257d10e..f25bbd02c1 100755
--- a/examples/tutorials/gettingStarted/gsQt/part5/main.cpp
+++ b/examples/tutorials/gettingStarted/gsQt/part5/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
class Notepad : public QMainWindow
{
diff --git a/examples/tutorials/modelview/1_readonly/1_readonly.pro b/examples/tutorials/modelview/1_readonly/1_readonly.pro
index 102bad59e6..82c763615f 100755
--- a/examples/tutorials/modelview/1_readonly/1_readonly.pro
+++ b/examples/tutorials/modelview/1_readonly/1_readonly.pro
@@ -15,3 +15,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/modelview/1_readonly
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tutorials/modelview/1_readonly/main.cpp b/examples/tutorials/modelview/1_readonly/main.cpp
index fdde141b4c..fb1b670896 100755
--- a/examples/tutorials/modelview/1_readonly/main.cpp
+++ b/examples/tutorials/modelview/1_readonly/main.cpp
@@ -40,8 +40,8 @@
//! [Quoting ModelView Tutorial]
// main.cpp
-#include <QtGui/QApplication>
-#include <QtGui/QTableView>
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QTableView>
#include "mymodel.h"
int main(int argc, char *argv[])
diff --git a/examples/tutorials/modelview/2_formatting/2_formatting.pro b/examples/tutorials/modelview/2_formatting/2_formatting.pro
index f7a950a4fd..3e5a18ca49 100755
--- a/examples/tutorials/modelview/2_formatting/2_formatting.pro
+++ b/examples/tutorials/modelview/2_formatting/2_formatting.pro
@@ -14,3 +14,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/modelview/2_formatting
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tutorials/modelview/2_formatting/main.cpp b/examples/tutorials/modelview/2_formatting/main.cpp
index fdde141b4c..fb1b670896 100755
--- a/examples/tutorials/modelview/2_formatting/main.cpp
+++ b/examples/tutorials/modelview/2_formatting/main.cpp
@@ -40,8 +40,8 @@
//! [Quoting ModelView Tutorial]
// main.cpp
-#include <QtGui/QApplication>
-#include <QtGui/QTableView>
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QTableView>
#include "mymodel.h"
int main(int argc, char *argv[])
diff --git a/examples/tutorials/modelview/3_changingmodel/3_changingmodel.pro b/examples/tutorials/modelview/3_changingmodel/3_changingmodel.pro
index d1f8971aaa..f19cf9c98f 100755
--- a/examples/tutorials/modelview/3_changingmodel/3_changingmodel.pro
+++ b/examples/tutorials/modelview/3_changingmodel/3_changingmodel.pro
@@ -14,3 +14,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/modelview/3_changingmode
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tutorials/modelview/3_changingmodel/main.cpp b/examples/tutorials/modelview/3_changingmodel/main.cpp
index 8a4ab8f6ab..424c1dc438 100755
--- a/examples/tutorials/modelview/3_changingmodel/main.cpp
+++ b/examples/tutorials/modelview/3_changingmodel/main.cpp
@@ -38,8 +38,8 @@
**
****************************************************************************/
-#include <QtGui/QApplication>
-#include <QtGui/QTableView>
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QTableView>
#include "mymodel.h"
int main(int argc, char *argv[])
diff --git a/examples/tutorials/modelview/4_headers/4_headers.pro b/examples/tutorials/modelview/4_headers/4_headers.pro
index 2a8b2dbbfa..d3e8670685 100755
--- a/examples/tutorials/modelview/4_headers/4_headers.pro
+++ b/examples/tutorials/modelview/4_headers/4_headers.pro
@@ -14,3 +14,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/modelview/4_headers
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tutorials/modelview/4_headers/main.cpp b/examples/tutorials/modelview/4_headers/main.cpp
index c89829ab42..9dadb071a7 100755
--- a/examples/tutorials/modelview/4_headers/main.cpp
+++ b/examples/tutorials/modelview/4_headers/main.cpp
@@ -38,8 +38,8 @@
**
****************************************************************************/
-#include <QtGui/QApplication>
-#include <QtGui/QTableView>
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QTableView>
#include "mymodel.h"
int main(int argc, char *argv[])
diff --git a/examples/tutorials/modelview/5_edit/5_edit.pro b/examples/tutorials/modelview/5_edit/5_edit.pro
index f8d725d5c0..7736cb94cf 100755
--- a/examples/tutorials/modelview/5_edit/5_edit.pro
+++ b/examples/tutorials/modelview/5_edit/5_edit.pro
@@ -16,3 +16,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/modelview/5_edit
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tutorials/modelview/5_edit/main.cpp b/examples/tutorials/modelview/5_edit/main.cpp
index 75246f7dc7..2a78dd09e9 100755
--- a/examples/tutorials/modelview/5_edit/main.cpp
+++ b/examples/tutorials/modelview/5_edit/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui/QApplication>
+#include <QtWidgets/QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
diff --git a/examples/tutorials/modelview/5_edit/mainwindow.h b/examples/tutorials/modelview/5_edit/mainwindow.h
index 37303f8293..7db37919e3 100755
--- a/examples/tutorials/modelview/5_edit/mainwindow.h
+++ b/examples/tutorials/modelview/5_edit/mainwindow.h
@@ -41,7 +41,7 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
-#include <QtGui/QMainWindow>
+#include <QtWidgets/QMainWindow>
QT_BEGIN_NAMESPACE // QT_BEGIN_NAMESPACE / QT_END_NAMESPACE are not needed in Qt user code
class QTableView; //forward declaration
diff --git a/examples/tutorials/modelview/6_treeview/6_treeview.pro b/examples/tutorials/modelview/6_treeview/6_treeview.pro
index 56b00aa81b..449d0b146f 100755
--- a/examples/tutorials/modelview/6_treeview/6_treeview.pro
+++ b/examples/tutorials/modelview/6_treeview/6_treeview.pro
@@ -11,3 +11,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/modelview/6_treeview
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tutorials/modelview/6_treeview/main.cpp b/examples/tutorials/modelview/6_treeview/main.cpp
index 75246f7dc7..2a78dd09e9 100755
--- a/examples/tutorials/modelview/6_treeview/main.cpp
+++ b/examples/tutorials/modelview/6_treeview/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui/QApplication>
+#include <QtWidgets/QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
diff --git a/examples/tutorials/modelview/6_treeview/mainwindow.h b/examples/tutorials/modelview/6_treeview/mainwindow.h
index 6398485cda..4e35a3ffc4 100755
--- a/examples/tutorials/modelview/6_treeview/mainwindow.h
+++ b/examples/tutorials/modelview/6_treeview/mainwindow.h
@@ -41,7 +41,7 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
-#include <QtGui/QMainWindow>
+#include <QtWidgets/QMainWindow>
QT_BEGIN_NAMESPACE // QT_BEGIN_NAMESPACE / QT_END_NAMESPACE are not needed in Qt user code
class QTreeView; //forward declarations
diff --git a/examples/tutorials/modelview/7_selections/7_selections.pro b/examples/tutorials/modelview/7_selections/7_selections.pro
index 5dd65ad6e5..bc09371aff 100755
--- a/examples/tutorials/modelview/7_selections/7_selections.pro
+++ b/examples/tutorials/modelview/7_selections/7_selections.pro
@@ -11,3 +11,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/modelview/7_selections
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tutorials/modelview/7_selections/main.cpp b/examples/tutorials/modelview/7_selections/main.cpp
index 75246f7dc7..2a78dd09e9 100755
--- a/examples/tutorials/modelview/7_selections/main.cpp
+++ b/examples/tutorials/modelview/7_selections/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui/QApplication>
+#include <QtWidgets/QApplication>
#include "mainwindow.h"
int main(int argc, char *argv[])
diff --git a/examples/tutorials/modelview/7_selections/mainwindow.h b/examples/tutorials/modelview/7_selections/mainwindow.h
index 0a30dab085..e78befbbc0 100755
--- a/examples/tutorials/modelview/7_selections/mainwindow.h
+++ b/examples/tutorials/modelview/7_selections/mainwindow.h
@@ -41,7 +41,7 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
-#include <QtGui/QMainWindow>
+#include <QtWidgets/QMainWindow>
QT_BEGIN_NAMESPACE // QT_BEGIN_NAMESPACE / QT_END_NAMESPACE are not needed in Qt user code
class QTreeView; //forward declarations
diff --git a/examples/tutorials/modelview/modelview.pro b/examples/tutorials/modelview/modelview.pro
index 853edfba6e..5c55ccb9d1 100755
--- a/examples/tutorials/modelview/modelview.pro
+++ b/examples/tutorials/modelview/modelview.pro
@@ -14,3 +14,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/modelview
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tutorials/threads/clock/clock.pro b/examples/tutorials/threads/clock/clock.pro
index 5c817b1473..f59413346d 100755
--- a/examples/tutorials/threads/clock/clock.pro
+++ b/examples/tutorials/threads/clock/clock.pro
@@ -12,3 +12,4 @@ INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tutorials/threads/clock/clockthread.cpp b/examples/tutorials/threads/clock/clockthread.cpp
index 01d3f1f697..f4721d8ed4 100644
--- a/examples/tutorials/threads/clock/clockthread.cpp
+++ b/examples/tutorials/threads/clock/clockthread.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "clockthread.h"
//This class starts another thread where it emits a signal for every new second.
diff --git a/examples/tutorials/threads/clock/main.cpp b/examples/tutorials/threads/clock/main.cpp
index a0f86d6bc7..99cbd4e693 100755
--- a/examples/tutorials/threads/clock/main.cpp
+++ b/examples/tutorials/threads/clock/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "clockthread.h"
//A clock that does time formatting in another thread
diff --git a/examples/tutorials/threads/movedobject/movedobject.pro b/examples/tutorials/threads/movedobject/movedobject.pro
index e2aa2d1dbb..f40ab0c012 100755
--- a/examples/tutorials/threads/movedobject/movedobject.pro
+++ b/examples/tutorials/threads/movedobject/movedobject.pro
@@ -16,3 +16,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/threads/movedobject
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/tutorials/threads/threads.pro b/examples/tutorials/threads/threads.pro
index d737513567..64392f8088 100644
--- a/examples/tutorials/threads/threads.pro
+++ b/examples/tutorials/threads/threads.pro
@@ -6,3 +6,4 @@ SUBDIRS = hellothread \
clock \
movedobject
+QT += widgets
diff --git a/examples/tutorials/tutorials.pro b/examples/tutorials/tutorials.pro
index cb57002082..e9a5bdd1fa 100644
--- a/examples/tutorials/tutorials.pro
+++ b/examples/tutorials/tutorials.pro
@@ -1,2 +1,3 @@
TEMPLATE = subdirs
SUBDIRS += addressbook-fr threads addressbook widgets modelview gettingStarted
+QT += widgets
diff --git a/examples/tutorials/widgets/childwidget/childwidget.pro b/examples/tutorials/widgets/childwidget/childwidget.pro
index ea319ad282..f23193fa29 100644
--- a/examples/tutorials/widgets/childwidget/childwidget.pro
+++ b/examples/tutorials/widgets/childwidget/childwidget.pro
@@ -5,3 +5,4 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/widgets/childwidget
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS childwidget.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/widgets/childwidget
INSTALLS += target sources
+QT += widgets
diff --git a/examples/tutorials/widgets/childwidget/main.cpp b/examples/tutorials/widgets/childwidget/main.cpp
index 15eda9f121..01e8b3f5d6 100644
--- a/examples/tutorials/widgets/childwidget/main.cpp
+++ b/examples/tutorials/widgets/childwidget/main.cpp
@@ -39,7 +39,7 @@
****************************************************************************/
//! [main program]
-#include <QtGui>
+#include <QtWidgets>
int main(int argc, char *argv[])
{
diff --git a/examples/tutorials/widgets/nestedlayouts/main.cpp b/examples/tutorials/widgets/nestedlayouts/main.cpp
index 40c63ab1fd..6783b718a7 100644
--- a/examples/tutorials/widgets/nestedlayouts/main.cpp
+++ b/examples/tutorials/widgets/nestedlayouts/main.cpp
@@ -40,7 +40,7 @@
//! [main program]
//! [first part]
-#include <QtGui>
+#include <QtWidgets>
int main(int argc, char *argv[])
{
diff --git a/examples/tutorials/widgets/nestedlayouts/nestedlayouts.pro b/examples/tutorials/widgets/nestedlayouts/nestedlayouts.pro
index cb27f9ecc4..28b935d3b4 100644
--- a/examples/tutorials/widgets/nestedlayouts/nestedlayouts.pro
+++ b/examples/tutorials/widgets/nestedlayouts/nestedlayouts.pro
@@ -5,3 +5,4 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/widgets/nestedlayouts
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS nestedlayouts.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/widgets/nestedlayouts
INSTALLS += target sources
+QT += widgets
diff --git a/examples/tutorials/widgets/toplevel/main.cpp b/examples/tutorials/widgets/toplevel/main.cpp
index f7baf0610e..6b84037ab2 100644
--- a/examples/tutorials/widgets/toplevel/main.cpp
+++ b/examples/tutorials/widgets/toplevel/main.cpp
@@ -39,7 +39,7 @@
****************************************************************************/
//! [main program]
-#include <QtGui>
+#include <QtWidgets>
int main(int argc, char *argv[])
{
diff --git a/examples/tutorials/widgets/toplevel/toplevel.pro b/examples/tutorials/widgets/toplevel/toplevel.pro
index b83ccfaf70..3c3351a1f5 100644
--- a/examples/tutorials/widgets/toplevel/toplevel.pro
+++ b/examples/tutorials/widgets/toplevel/toplevel.pro
@@ -5,3 +5,4 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/widgets/toplevel
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS toplevel.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/widgets/toplevel
INSTALLS += target sources
+QT += widgets
diff --git a/examples/tutorials/widgets/widgets.pro b/examples/tutorials/widgets/widgets.pro
index c03d43d7c2..3a6e065ffc 100644
--- a/examples/tutorials/widgets/widgets.pro
+++ b/examples/tutorials/widgets/widgets.pro
@@ -6,3 +6,4 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/widgets
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS widgets.pro README
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/widgets
INSTALLS += target sources
+QT += widgets
diff --git a/examples/tutorials/widgets/windowlayout/main.cpp b/examples/tutorials/widgets/windowlayout/main.cpp
index ada9ae7380..bb5ed125b5 100644
--- a/examples/tutorials/widgets/windowlayout/main.cpp
+++ b/examples/tutorials/widgets/windowlayout/main.cpp
@@ -39,7 +39,7 @@
****************************************************************************/
//! [main program]
-#include <QtGui>
+#include <QtWidgets>
int main(int argc, char *argv[])
{
diff --git a/examples/tutorials/widgets/windowlayout/windowlayout.pro b/examples/tutorials/widgets/windowlayout/windowlayout.pro
index f8b55ba214..1517845aa1 100644
--- a/examples/tutorials/widgets/windowlayout/windowlayout.pro
+++ b/examples/tutorials/widgets/windowlayout/windowlayout.pro
@@ -5,3 +5,4 @@ target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/widgets/windowlayout
sources.files = $$SOURCES $$HEADERS $$RESOURCES $$FORMS windowlayout.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/tutorials/widgets/windowlayout
INSTALLS += target sources
+QT += widgets
diff --git a/examples/uitools/multipleinheritance/calculatorform.cpp b/examples/uitools/multipleinheritance/calculatorform.cpp
index 2963db356a..ae1312f558 100644
--- a/examples/uitools/multipleinheritance/calculatorform.cpp
+++ b/examples/uitools/multipleinheritance/calculatorform.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "calculatorform.h"
diff --git a/examples/uitools/multipleinheritance/multipleinheritance.pro b/examples/uitools/multipleinheritance/multipleinheritance.pro
index 83b4a1331e..141df564a3 100644
--- a/examples/uitools/multipleinheritance/multipleinheritance.pro
+++ b/examples/uitools/multipleinheritance/multipleinheritance.pro
@@ -14,3 +14,4 @@ symbian {
TARGET.UID3 = 0xA000D7C1
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/uitools/textfinder/textfinder.cpp b/examples/uitools/textfinder/textfinder.cpp
index 0a69d5e2dd..041c36f218 100644
--- a/examples/uitools/textfinder/textfinder.cpp
+++ b/examples/uitools/textfinder/textfinder.cpp
@@ -39,7 +39,7 @@
****************************************************************************/
#include <QtUiTools>
-#include <QtGui>
+#include <QtWidgets>
#include "textfinder.h"
//! [0]
diff --git a/examples/uitools/textfinder/textfinder.pro b/examples/uitools/textfinder/textfinder.pro
index 9604ceac9e..93105c6412 100644
--- a/examples/uitools/textfinder/textfinder.pro
+++ b/examples/uitools/textfinder/textfinder.pro
@@ -10,3 +10,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/uitools/textfinder
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/uitools/uitools.pro b/examples/uitools/uitools.pro
index 7b11c98e7f..c44c1666bf 100644
--- a/examples/uitools/uitools.pro
+++ b/examples/uitools/uitools.pro
@@ -10,3 +10,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/uitools
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/webkit/webkit-guide/webkit-guide.pro b/examples/webkit/webkit-guide/webkit-guide.pro
index b4291a5e01..6614b6d52c 100644
--- a/examples/webkit/webkit-guide/webkit-guide.pro
+++ b/examples/webkit/webkit-guide/webkit-guide.pro
@@ -255,3 +255,4 @@ js/mob_condjs.js \
js/mobile.js \
js/storage.js \
+QT += widgets
diff --git a/examples/widgets/analogclock/analogclock.cpp b/examples/widgets/analogclock/analogclock.cpp
index 5368a2cbe1..606b962d4c 100644
--- a/examples/widgets/analogclock/analogclock.cpp
+++ b/examples/widgets/analogclock/analogclock.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "analogclock.h"
diff --git a/examples/widgets/analogclock/analogclock.pro b/examples/widgets/analogclock/analogclock.pro
index 77f4b7fd83..2c8737bd68 100644
--- a/examples/widgets/analogclock/analogclock.pro
+++ b/examples/widgets/analogclock/analogclock.pro
@@ -12,3 +12,4 @@ symbian {
TARGET.UID3 = 0xA000A64F
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/widgets/calculator/button.cpp b/examples/widgets/calculator/button.cpp
index 7bd1783801..eaf6000893 100644
--- a/examples/widgets/calculator/button.cpp
+++ b/examples/widgets/calculator/button.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "button.h"
diff --git a/examples/widgets/calculator/calculator.cpp b/examples/widgets/calculator/calculator.cpp
index 991ffc3efc..d938845a86 100644
--- a/examples/widgets/calculator/calculator.cpp
+++ b/examples/widgets/calculator/calculator.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <math.h>
diff --git a/examples/widgets/calculator/calculator.pro b/examples/widgets/calculator/calculator.pro
index d6bda73629..5e57372c58 100644
--- a/examples/widgets/calculator/calculator.pro
+++ b/examples/widgets/calculator/calculator.pro
@@ -14,3 +14,4 @@ symbian {
TARGET.UID3 = 0xA000C602
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/widgets/calendarwidget/calendarwidget.pro b/examples/widgets/calendarwidget/calendarwidget.pro
index cce3fb5161..ed311e2d08 100644
--- a/examples/widgets/calendarwidget/calendarwidget.pro
+++ b/examples/widgets/calendarwidget/calendarwidget.pro
@@ -12,3 +12,4 @@ symbian {
TARGET.UID3 = 0xA000C603
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/widgets/calendarwidget/main.cpp b/examples/widgets/calendarwidget/main.cpp
index b14a44f7c6..76565357ce 100644
--- a/examples/widgets/calendarwidget/main.cpp
+++ b/examples/widgets/calendarwidget/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "window.h"
diff --git a/examples/widgets/calendarwidget/window.cpp b/examples/widgets/calendarwidget/window.cpp
index ad8e63c3ec..4df7242efa 100644
--- a/examples/widgets/calendarwidget/window.cpp
+++ b/examples/widgets/calendarwidget/window.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "window.h"
diff --git a/examples/widgets/charactermap/charactermap.pro b/examples/widgets/charactermap/charactermap.pro
index 8356321413..54e9e6f63a 100644
--- a/examples/widgets/charactermap/charactermap.pro
+++ b/examples/widgets/charactermap/charactermap.pro
@@ -11,3 +11,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/widgets/charactermap
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/widgets/charactermap/characterwidget.cpp b/examples/widgets/charactermap/characterwidget.cpp
index d9a59b68b2..21d690f69b 100644
--- a/examples/widgets/charactermap/characterwidget.cpp
+++ b/examples/widgets/charactermap/characterwidget.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "characterwidget.h"
diff --git a/examples/widgets/charactermap/mainwindow.cpp b/examples/widgets/charactermap/mainwindow.cpp
index bdff127423..20c3bf407e 100644
--- a/examples/widgets/charactermap/mainwindow.cpp
+++ b/examples/widgets/charactermap/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "characterwidget.h"
#include "mainwindow.h"
diff --git a/examples/widgets/codeeditor/codeeditor.cpp b/examples/widgets/codeeditor/codeeditor.cpp
index c7d1405a0e..8676e48359 100644
--- a/examples/widgets/codeeditor/codeeditor.cpp
+++ b/examples/widgets/codeeditor/codeeditor.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "codeeditor.h"
diff --git a/examples/widgets/codeeditor/codeeditor.pro b/examples/widgets/codeeditor/codeeditor.pro
index 2e15d86a8d..c32914c4d1 100644
--- a/examples/widgets/codeeditor/codeeditor.pro
+++ b/examples/widgets/codeeditor/codeeditor.pro
@@ -7,3 +7,4 @@ sources.files = $$SOURCES $$HEADERS *.pro
sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/widgets/codeeditor
INSTALLS += target sources
+QT += widgets
diff --git a/examples/widgets/codeeditor/main.cpp b/examples/widgets/codeeditor/main.cpp
index a2a81a1a85..1bce70e03f 100644
--- a/examples/widgets/codeeditor/main.cpp
+++ b/examples/widgets/codeeditor/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "codeeditor.h"
diff --git a/examples/widgets/digitalclock/digitalclock.cpp b/examples/widgets/digitalclock/digitalclock.cpp
index 7d38ccd15f..bbedf0f858 100644
--- a/examples/widgets/digitalclock/digitalclock.cpp
+++ b/examples/widgets/digitalclock/digitalclock.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "digitalclock.h"
diff --git a/examples/widgets/digitalclock/digitalclock.pro b/examples/widgets/digitalclock/digitalclock.pro
index ae90686529..30a5fed019 100644
--- a/examples/widgets/digitalclock/digitalclock.pro
+++ b/examples/widgets/digitalclock/digitalclock.pro
@@ -9,3 +9,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/widgets/digitalclock
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/widgets/groupbox/groupbox.pro b/examples/widgets/groupbox/groupbox.pro
index 48056a3f3b..06afd2ac28 100644
--- a/examples/widgets/groupbox/groupbox.pro
+++ b/examples/widgets/groupbox/groupbox.pro
@@ -9,3 +9,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/widgets/groupbox
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/widgets/groupbox/window.cpp b/examples/widgets/groupbox/window.cpp
index 89531df9fd..82c042e40e 100644
--- a/examples/widgets/groupbox/window.cpp
+++ b/examples/widgets/groupbox/window.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "window.h"
diff --git a/examples/widgets/icons/iconpreviewarea.cpp b/examples/widgets/icons/iconpreviewarea.cpp
index 3f3de3d135..8ff82fcbfb 100644
--- a/examples/widgets/icons/iconpreviewarea.cpp
+++ b/examples/widgets/icons/iconpreviewarea.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "iconpreviewarea.h"
diff --git a/examples/widgets/icons/icons.pro b/examples/widgets/icons/icons.pro
index b355dc75d0..4cc3243dae 100644
--- a/examples/widgets/icons/icons.pro
+++ b/examples/widgets/icons/icons.pro
@@ -25,3 +25,4 @@ wince*: {
}
DEPLOYMENT += imageFiles
}
+QT += widgets
diff --git a/examples/widgets/icons/iconsizespinbox.cpp b/examples/widgets/icons/iconsizespinbox.cpp
index fd3722af8f..3c6061a1f4 100644
--- a/examples/widgets/icons/iconsizespinbox.cpp
+++ b/examples/widgets/icons/iconsizespinbox.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "iconsizespinbox.h"
diff --git a/examples/widgets/icons/imagedelegate.cpp b/examples/widgets/icons/imagedelegate.cpp
index 93018eb49b..20747eac1e 100644
--- a/examples/widgets/icons/imagedelegate.cpp
+++ b/examples/widgets/icons/imagedelegate.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "imagedelegate.h"
diff --git a/examples/widgets/icons/mainwindow.cpp b/examples/widgets/icons/mainwindow.cpp
index 6dda3c16db..91ce27646d 100644
--- a/examples/widgets/icons/mainwindow.cpp
+++ b/examples/widgets/icons/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "iconpreviewarea.h"
#include "iconsizespinbox.h"
diff --git a/examples/widgets/imageviewer/imageviewer.cpp b/examples/widgets/imageviewer/imageviewer.cpp
index 8a8aaf9e96..40bef145e5 100644
--- a/examples/widgets/imageviewer/imageviewer.cpp
+++ b/examples/widgets/imageviewer/imageviewer.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "imageviewer.h"
diff --git a/examples/widgets/imageviewer/imageviewer.pro b/examples/widgets/imageviewer/imageviewer.pro
index 1c0ac78115..1f144e4013 100644
--- a/examples/widgets/imageviewer/imageviewer.pro
+++ b/examples/widgets/imageviewer/imageviewer.pro
@@ -13,3 +13,4 @@ symbian: CONFIG += qt_example
wince*: {
DEPLOYMENT_PLUGIN += qjpeg qmng qgif
}
+QT += widgets
diff --git a/examples/widgets/lineedits/lineedits.pro b/examples/widgets/lineedits/lineedits.pro
index b568aac164..84c166e565 100644
--- a/examples/widgets/lineedits/lineedits.pro
+++ b/examples/widgets/lineedits/lineedits.pro
@@ -12,3 +12,4 @@ symbian {
TARGET.UID3 = 0xA000C604
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/widgets/lineedits/window.cpp b/examples/widgets/lineedits/window.cpp
index 427b6f5f5d..ff6c0a3d8e 100644
--- a/examples/widgets/lineedits/window.cpp
+++ b/examples/widgets/lineedits/window.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "window.h"
diff --git a/examples/widgets/movie/movie.pro b/examples/widgets/movie/movie.pro
index f41bbbbe03..0ec37f7825 100644
--- a/examples/widgets/movie/movie.pro
+++ b/examples/widgets/movie/movie.pro
@@ -17,3 +17,4 @@ wince*: {
DEPLOYMENT_PLUGIN += qmng
}
+QT += widgets
diff --git a/examples/widgets/movie/movieplayer.cpp b/examples/widgets/movie/movieplayer.cpp
index f4d2279729..e12d49763d 100644
--- a/examples/widgets/movie/movieplayer.cpp
+++ b/examples/widgets/movie/movieplayer.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "movieplayer.h"
diff --git a/examples/widgets/scribble/mainwindow.cpp b/examples/widgets/scribble/mainwindow.cpp
index a45bf07928..fb9d42ab31 100644
--- a/examples/widgets/scribble/mainwindow.cpp
+++ b/examples/widgets/scribble/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
#include "scribblearea.h"
diff --git a/examples/widgets/scribble/scribble.pro b/examples/widgets/scribble/scribble.pro
index 09c6882f60..0ad1311491 100644
--- a/examples/widgets/scribble/scribble.pro
+++ b/examples/widgets/scribble/scribble.pro
@@ -11,3 +11,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/widgets/scribble
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/widgets/scribble/scribblearea.cpp b/examples/widgets/scribble/scribblearea.cpp
index 5854e34f42..984629fb44 100644
--- a/examples/widgets/scribble/scribblearea.cpp
+++ b/examples/widgets/scribble/scribblearea.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "scribblearea.h"
diff --git a/examples/widgets/shapedclock/shapedclock.cpp b/examples/widgets/shapedclock/shapedclock.cpp
index 71c27bff14..77cf685259 100644
--- a/examples/widgets/shapedclock/shapedclock.cpp
+++ b/examples/widgets/shapedclock/shapedclock.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "shapedclock.h"
diff --git a/examples/widgets/shapedclock/shapedclock.pro b/examples/widgets/shapedclock/shapedclock.pro
index 5563d34258..f0c80b25bd 100644
--- a/examples/widgets/shapedclock/shapedclock.pro
+++ b/examples/widgets/shapedclock/shapedclock.pro
@@ -12,3 +12,4 @@ symbian {
TARGET.UID3 = 0xA000C605
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/widgets/sliders/sliders.pro b/examples/widgets/sliders/sliders.pro
index 74ca76426d..adc70cfec7 100644
--- a/examples/widgets/sliders/sliders.pro
+++ b/examples/widgets/sliders/sliders.pro
@@ -11,3 +11,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/widgets/sliders
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/widgets/sliders/slidersgroup.cpp b/examples/widgets/sliders/slidersgroup.cpp
index 4ead1cc226..bf05cc1d87 100644
--- a/examples/widgets/sliders/slidersgroup.cpp
+++ b/examples/widgets/sliders/slidersgroup.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "slidersgroup.h"
diff --git a/examples/widgets/sliders/window.cpp b/examples/widgets/sliders/window.cpp
index 9286910a19..541279a84d 100644
--- a/examples/widgets/sliders/window.cpp
+++ b/examples/widgets/sliders/window.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "slidersgroup.h"
#include "window.h"
diff --git a/examples/widgets/softkeys/main.cpp b/examples/widgets/softkeys/main.cpp
index 5678eb37ed..c23a3685d9 100644
--- a/examples/widgets/softkeys/main.cpp
+++ b/examples/widgets/softkeys/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "softkeys.h"
int main(int argc, char *argv[])
diff --git a/examples/widgets/softkeys/softkeys.h b/examples/widgets/softkeys/softkeys.h
index 5427e1020f..6e2b2665ea 100644
--- a/examples/widgets/softkeys/softkeys.h
+++ b/examples/widgets/softkeys/softkeys.h
@@ -41,7 +41,7 @@
#ifndef SOFTKEYS_H
#define SOFTKEYS_H
-#include <QtGui>
+#include <QtWidgets>
class MainWindow : public QMainWindow
{
diff --git a/examples/widgets/softkeys/softkeys.pro b/examples/widgets/softkeys/softkeys.pro
index b4be01fd5f..4073a29d8e 100644
--- a/examples/widgets/softkeys/softkeys.pro
+++ b/examples/widgets/softkeys/softkeys.pro
@@ -13,3 +13,4 @@ symbian {
TARGET.UID3 = 0xA000CF6B
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/widgets/spinboxes/spinboxes.pro b/examples/widgets/spinboxes/spinboxes.pro
index 11c471bc9e..9c9a001e7c 100644
--- a/examples/widgets/spinboxes/spinboxes.pro
+++ b/examples/widgets/spinboxes/spinboxes.pro
@@ -9,3 +9,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/widgets/spinboxes
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/widgets/spinboxes/window.cpp b/examples/widgets/spinboxes/window.cpp
index 095ff5cf79..9a3eb02e95 100644
--- a/examples/widgets/spinboxes/window.cpp
+++ b/examples/widgets/spinboxes/window.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "window.h"
diff --git a/examples/widgets/styles/norwegianwoodstyle.cpp b/examples/widgets/styles/norwegianwoodstyle.cpp
index 9fd0fed041..637b9a3705 100644
--- a/examples/widgets/styles/norwegianwoodstyle.cpp
+++ b/examples/widgets/styles/norwegianwoodstyle.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "norwegianwoodstyle.h"
diff --git a/examples/widgets/styles/styles.pro b/examples/widgets/styles/styles.pro
index 4806a1d78f..8c0eb25629 100644
--- a/examples/widgets/styles/styles.pro
+++ b/examples/widgets/styles/styles.pro
@@ -14,3 +14,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/widgets/styles
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/widgets/styles/widgetgallery.cpp b/examples/widgets/styles/widgetgallery.cpp
index 2867159895..82b7e37296 100644
--- a/examples/widgets/styles/widgetgallery.cpp
+++ b/examples/widgets/styles/widgetgallery.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "norwegianwoodstyle.h"
#include "widgetgallery.h"
diff --git a/examples/widgets/stylesheet/main.cpp b/examples/widgets/stylesheet/main.cpp
index fd417a0c18..2c05ee950d 100644
--- a/examples/widgets/stylesheet/main.cpp
+++ b/examples/widgets/stylesheet/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
diff --git a/examples/widgets/stylesheet/mainwindow.cpp b/examples/widgets/stylesheet/mainwindow.cpp
index b7491e2642..221fbcc765 100644
--- a/examples/widgets/stylesheet/mainwindow.cpp
+++ b/examples/widgets/stylesheet/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
#include "stylesheeteditor.h"
diff --git a/examples/widgets/stylesheet/mainwindow.h b/examples/widgets/stylesheet/mainwindow.h
index ca590ace4a..7430039594 100644
--- a/examples/widgets/stylesheet/mainwindow.h
+++ b/examples/widgets/stylesheet/mainwindow.h
@@ -41,7 +41,7 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
-#include <QtGui>
+#include <QtWidgets>
#include "ui_mainwindow.h"
diff --git a/examples/widgets/stylesheet/stylesheet.pro b/examples/widgets/stylesheet/stylesheet.pro
index 42df886e53..6ab994598c 100644
--- a/examples/widgets/stylesheet/stylesheet.pro
+++ b/examples/widgets/stylesheet/stylesheet.pro
@@ -14,3 +14,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/widgets/stylesheet
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/widgets/stylesheet/stylesheeteditor.cpp b/examples/widgets/stylesheet/stylesheeteditor.cpp
index c1d43ea99b..36d217cbb4 100644
--- a/examples/widgets/stylesheet/stylesheeteditor.cpp
+++ b/examples/widgets/stylesheet/stylesheeteditor.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "stylesheeteditor.h"
diff --git a/examples/widgets/tablet/main.cpp b/examples/widgets/tablet/main.cpp
index 27aab50901..f7524b2f48 100644
--- a/examples/widgets/tablet/main.cpp
+++ b/examples/widgets/tablet/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
#include "tabletapplication.h"
diff --git a/examples/widgets/tablet/mainwindow.cpp b/examples/widgets/tablet/mainwindow.cpp
index 8ae3431354..ac2825bcd2 100644
--- a/examples/widgets/tablet/mainwindow.cpp
+++ b/examples/widgets/tablet/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
#include "tabletcanvas.h"
diff --git a/examples/widgets/tablet/tablet.pro b/examples/widgets/tablet/tablet.pro
index 8519997045..a724703a81 100644
--- a/examples/widgets/tablet/tablet.pro
+++ b/examples/widgets/tablet/tablet.pro
@@ -13,3 +13,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/widgets/tablet
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/widgets/tablet/tabletapplication.cpp b/examples/widgets/tablet/tabletapplication.cpp
index 7f60136b12..2830ef80ab 100644
--- a/examples/widgets/tablet/tabletapplication.cpp
+++ b/examples/widgets/tablet/tabletapplication.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "tabletapplication.h"
diff --git a/examples/widgets/tablet/tabletcanvas.cpp b/examples/widgets/tablet/tabletcanvas.cpp
index 88a582de23..72f13b42ba 100644
--- a/examples/widgets/tablet/tabletcanvas.cpp
+++ b/examples/widgets/tablet/tabletcanvas.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <math.h>
#include "tabletcanvas.h"
diff --git a/examples/widgets/tetrix/main.cpp b/examples/widgets/tetrix/main.cpp
index 9a7dcf35e5..6c30ae5cae 100644
--- a/examples/widgets/tetrix/main.cpp
+++ b/examples/widgets/tetrix/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <stdlib.h>
diff --git a/examples/widgets/tetrix/tetrix.pro b/examples/widgets/tetrix/tetrix.pro
index 1c777f6021..fea2951dc8 100644
--- a/examples/widgets/tetrix/tetrix.pro
+++ b/examples/widgets/tetrix/tetrix.pro
@@ -16,3 +16,4 @@ symbian {
TARGET.UID3 = 0xA000C606
CONFIG += qt_example
}
+QT += widgets
diff --git a/examples/widgets/tetrix/tetrixboard.cpp b/examples/widgets/tetrix/tetrixboard.cpp
index 1bb91ee3d7..efdd11f5d8 100644
--- a/examples/widgets/tetrix/tetrixboard.cpp
+++ b/examples/widgets/tetrix/tetrixboard.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "tetrixboard.h"
diff --git a/examples/widgets/tetrix/tetrixwindow.cpp b/examples/widgets/tetrix/tetrixwindow.cpp
index fccb4beff1..e637392521 100644
--- a/examples/widgets/tetrix/tetrixwindow.cpp
+++ b/examples/widgets/tetrix/tetrixwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "tetrixboard.h"
#include "tetrixwindow.h"
diff --git a/examples/widgets/tooltips/main.cpp b/examples/widgets/tooltips/main.cpp
index c31d90a1cd..893b65da86 100644
--- a/examples/widgets/tooltips/main.cpp
+++ b/examples/widgets/tooltips/main.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "sortingbox.h"
diff --git a/examples/widgets/tooltips/shapeitem.cpp b/examples/widgets/tooltips/shapeitem.cpp
index 03b49be0ed..65dbfd16eb 100644
--- a/examples/widgets/tooltips/shapeitem.cpp
+++ b/examples/widgets/tooltips/shapeitem.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "shapeitem.h"
diff --git a/examples/widgets/tooltips/sortingbox.cpp b/examples/widgets/tooltips/sortingbox.cpp
index 083990c165..f5b45f1d7d 100644
--- a/examples/widgets/tooltips/sortingbox.cpp
+++ b/examples/widgets/tooltips/sortingbox.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include <stdlib.h>
diff --git a/examples/widgets/tooltips/tooltips.pro b/examples/widgets/tooltips/tooltips.pro
index d0725371de..467478ce0d 100644
--- a/examples/widgets/tooltips/tooltips.pro
+++ b/examples/widgets/tooltips/tooltips.pro
@@ -12,3 +12,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/widgets/tooltips
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/widgets/validators/validators.pro b/examples/widgets/validators/validators.pro
index 5f36bb8fdb..36d069b7c3 100644
--- a/examples/widgets/validators/validators.pro
+++ b/examples/widgets/validators/validators.pro
@@ -21,3 +21,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/widgets/validators
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/widgets/widgets.pro b/examples/widgets/widgets.pro
index 8811f8b0cd..552e6267d4 100644
--- a/examples/widgets/widgets.pro
+++ b/examples/widgets/widgets.pro
@@ -41,3 +41,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/widgets
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/widgets/wiggly/dialog.cpp b/examples/widgets/wiggly/dialog.cpp
index a5b376143c..d2053d84ac 100644
--- a/examples/widgets/wiggly/dialog.cpp
+++ b/examples/widgets/wiggly/dialog.cpp
@@ -38,7 +38,8 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
+#include <QtWidgets>
#include "dialog.h"
#include "wigglywidget.h"
diff --git a/examples/widgets/wiggly/wiggly.pro b/examples/widgets/wiggly/wiggly.pro
index e3a8fbc452..d0d8dc7b9d 100644
--- a/examples/widgets/wiggly/wiggly.pro
+++ b/examples/widgets/wiggly/wiggly.pro
@@ -1,3 +1,5 @@
+QT += widgets widgets
+
HEADERS = wigglywidget.h \
dialog.h
SOURCES = wigglywidget.cpp \
diff --git a/examples/widgets/wiggly/wigglywidget.cpp b/examples/widgets/wiggly/wigglywidget.cpp
index 56a026ade7..b55efaa1fa 100644
--- a/examples/widgets/wiggly/wigglywidget.cpp
+++ b/examples/widgets/wiggly/wigglywidget.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "wigglywidget.h"
diff --git a/examples/widgets/windowflags/controllerwindow.cpp b/examples/widgets/windowflags/controllerwindow.cpp
index c52e2b27c3..b2b929842f 100644
--- a/examples/widgets/windowflags/controllerwindow.cpp
+++ b/examples/widgets/windowflags/controllerwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "controllerwindow.h"
diff --git a/examples/widgets/windowflags/previewwindow.cpp b/examples/widgets/windowflags/previewwindow.cpp
index 5847af1c63..1cd74619e7 100644
--- a/examples/widgets/windowflags/previewwindow.cpp
+++ b/examples/widgets/windowflags/previewwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "previewwindow.h"
diff --git a/examples/widgets/windowflags/windowflags.pro b/examples/widgets/windowflags/windowflags.pro
index 23599d0ac8..19d01f3556 100644
--- a/examples/widgets/windowflags/windowflags.pro
+++ b/examples/widgets/windowflags/windowflags.pro
@@ -11,3 +11,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/widgets/windowflags
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/xml/dombookmarks/dombookmarks.pro b/examples/xml/dombookmarks/dombookmarks.pro
index aa815457f5..c2536eded8 100644
--- a/examples/xml/dombookmarks/dombookmarks.pro
+++ b/examples/xml/dombookmarks/dombookmarks.pro
@@ -3,7 +3,7 @@ HEADERS = mainwindow.h \
SOURCES = main.cpp \
mainwindow.cpp \
xbeltree.cpp
-QT += xml
+QT += xml widgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/xml/dombookmarks
diff --git a/examples/xml/dombookmarks/mainwindow.cpp b/examples/xml/dombookmarks/mainwindow.cpp
index b3bfe64e17..0c3ceafc88 100644
--- a/examples/xml/dombookmarks/mainwindow.cpp
+++ b/examples/xml/dombookmarks/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
#include "xbeltree.h"
diff --git a/examples/xml/dombookmarks/xbeltree.cpp b/examples/xml/dombookmarks/xbeltree.cpp
index 2a072b2d54..67c85aca40 100644
--- a/examples/xml/dombookmarks/xbeltree.cpp
+++ b/examples/xml/dombookmarks/xbeltree.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "xbeltree.h"
diff --git a/examples/xml/rsslisting/main.cpp b/examples/xml/rsslisting/main.cpp
index 011569f2b6..a646c602db 100644
--- a/examples/xml/rsslisting/main.cpp
+++ b/examples/xml/rsslisting/main.cpp
@@ -44,7 +44,7 @@ main.cpp
Provides the main function for the RSS news reader example.
*/
-#include <QtGui>
+#include <QtWidgets>
#include "rsslisting.h"
diff --git a/examples/xml/rsslisting/rsslisting.cpp b/examples/xml/rsslisting/rsslisting.cpp
index 5840f08d09..15fd51caf8 100644
--- a/examples/xml/rsslisting/rsslisting.cpp
+++ b/examples/xml/rsslisting/rsslisting.cpp
@@ -55,7 +55,7 @@ its operation, and also allows very large data sources to be read.
#include <QtCore>
-#include <QtGui>
+#include <QtWidgets>
#include <QtNetwork>
#include "rsslisting.h"
diff --git a/examples/xml/rsslisting/rsslisting.pro b/examples/xml/rsslisting/rsslisting.pro
index c883b77ada..e12c023c34 100644
--- a/examples/xml/rsslisting/rsslisting.pro
+++ b/examples/xml/rsslisting/rsslisting.pro
@@ -1,6 +1,6 @@
HEADERS += rsslisting.h
SOURCES += main.cpp rsslisting.cpp
-QT += network xml
+QT += network xml widgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/xml/rsslisting
diff --git a/examples/xml/saxbookmarks/mainwindow.cpp b/examples/xml/saxbookmarks/mainwindow.cpp
index e5300121e5..93aae7f906 100644
--- a/examples/xml/saxbookmarks/mainwindow.cpp
+++ b/examples/xml/saxbookmarks/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
#include "xbelgenerator.h"
diff --git a/examples/xml/saxbookmarks/saxbookmarks.pro b/examples/xml/saxbookmarks/saxbookmarks.pro
index bb1e0961e7..b846fec885 100644
--- a/examples/xml/saxbookmarks/saxbookmarks.pro
+++ b/examples/xml/saxbookmarks/saxbookmarks.pro
@@ -5,7 +5,7 @@ SOURCES = main.cpp \
mainwindow.cpp \
xbelgenerator.cpp \
xbelhandler.cpp
-QT += xml
+QT += xml widgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/xml/saxbookmarks
diff --git a/examples/xml/saxbookmarks/xbelgenerator.cpp b/examples/xml/saxbookmarks/xbelgenerator.cpp
index a0bfe67f69..7712d83d10 100644
--- a/examples/xml/saxbookmarks/xbelgenerator.cpp
+++ b/examples/xml/saxbookmarks/xbelgenerator.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "xbelgenerator.h"
diff --git a/examples/xml/saxbookmarks/xbelhandler.cpp b/examples/xml/saxbookmarks/xbelhandler.cpp
index 09874c9edc..da65c2bf88 100644
--- a/examples/xml/saxbookmarks/xbelhandler.cpp
+++ b/examples/xml/saxbookmarks/xbelhandler.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "xbelhandler.h"
diff --git a/examples/xml/streambookmarks/mainwindow.cpp b/examples/xml/streambookmarks/mainwindow.cpp
index e9236e93e6..ed765995e7 100644
--- a/examples/xml/streambookmarks/mainwindow.cpp
+++ b/examples/xml/streambookmarks/mainwindow.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "mainwindow.h"
#include "xbelreader.h"
diff --git a/examples/xml/streambookmarks/streambookmarks.pro b/examples/xml/streambookmarks/streambookmarks.pro
index 91abf97ec2..7811775597 100644
--- a/examples/xml/streambookmarks/streambookmarks.pro
+++ b/examples/xml/streambookmarks/streambookmarks.pro
@@ -5,7 +5,7 @@ SOURCES = main.cpp \
mainwindow.cpp \
xbelreader.cpp \
xbelwriter.cpp
-QT += xml
+QT += xml widgets
# install
target.path = $$[QT_INSTALL_EXAMPLES]/qtbase/xml/streambookmarks
diff --git a/examples/xml/streambookmarks/xbelreader.cpp b/examples/xml/streambookmarks/xbelreader.cpp
index e6d1c64e64..063243528b 100644
--- a/examples/xml/streambookmarks/xbelreader.cpp
+++ b/examples/xml/streambookmarks/xbelreader.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "xbelreader.h"
diff --git a/examples/xml/streambookmarks/xbelwriter.cpp b/examples/xml/streambookmarks/xbelwriter.cpp
index bd5454c941..aa100d401e 100644
--- a/examples/xml/streambookmarks/xbelwriter.cpp
+++ b/examples/xml/streambookmarks/xbelwriter.cpp
@@ -38,7 +38,7 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
#include "xbelwriter.h"
diff --git a/examples/xml/xml.pro b/examples/xml/xml.pro
index 7ef5eadbaa..62bb89723d 100644
--- a/examples/xml/xml.pro
+++ b/examples/xml/xml.pro
@@ -18,3 +18,4 @@ sources.path = $$[QT_INSTALL_EXAMPLES]/qtbase/xml
INSTALLS += target sources
symbian: CONFIG += qt_example
+QT += widgets
diff --git a/examples/xml/xmlstreamlint/xmlstreamlint.pro b/examples/xml/xmlstreamlint/xmlstreamlint.pro
index 9eb5b2a49e..e57e0ab3ab 100644
--- a/examples/xml/xmlstreamlint/xmlstreamlint.pro
+++ b/examples/xml/xmlstreamlint/xmlstreamlint.pro
@@ -1,6 +1,6 @@
CONFIG += console
QT -= gui
-QT += xml
+QT += xml widgets
SOURCES += main.cpp
# install
diff --git a/mkspecs/qws/freebsd-generic-g++/qmake.conf b/mkspecs/qws/freebsd-generic-g++/qmake.conf
deleted file mode 100644
index d50ce6b7b6..0000000000
--- a/mkspecs/qws/freebsd-generic-g++/qmake.conf
+++ /dev/null
@@ -1,85 +0,0 @@
-#
-# qmake configuration for freebsd-g++ with Qtopia Core
-#
-
-MAKEFILE_GENERATOR = UNIX
-TARGET_PLATFORM = unix
-TEMPLATE = app
-CONFIG += qt warn_on release
-QT += core gui network
-QMAKE_INCREMENTAL_STYLE = sublib
-
-QMAKE_CC = gcc
-QMAKE_LEX = flex
-QMAKE_LEXFLAGS =
-QMAKE_YACC = yacc
-QMAKE_YACCFLAGS = -d
-QMAKE_CFLAGS = -pipe
-QMAKE_CFLAGS_DEPS = -M
-QMAKE_CFLAGS_WARN_ON = -Wall -W
-QMAKE_CFLAGS_WARN_OFF = -w
-QMAKE_CFLAGS_RELEASE = -O2 -fno-default-inline
-QMAKE_CFLAGS_DEBUG = -g
-QMAKE_CFLAGS_SHLIB = -fPIC
-QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses
-QMAKE_CFLAGS_THREAD = -pthread -D_THREAD_SAFE
-QMAKE_CFLAGS_HIDESYMS = -fvisibility=hidden
-
-QMAKE_CXX = g++
-QMAKE_CXXFLAGS_DEPS = $$QMAKE_CFLAGS_DEPS
-QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -DQT_NO_QWS_LINUXFB -DQT_NO_QWS_TRANSFORMED
-QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON
-QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF
-QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE
-QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG
-QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB
-QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC
-QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD
-QMAKE_CXXFLAGS_HIDESYMS = $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden
-
-# Addon software goes into /usr/local on the BSDs, by default we will look there
-QMAKE_INCDIR = /usr/local/include
-QMAKE_LIBDIR = /usr/local/lib
-QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS]
-QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS]
-QMAKE_INCDIR_QTOPIA = $(QPEDIR)/include
-QMAKE_LIBDIR_QTOPIA = $(QPEDIR)/lib
-
-QMAKE_LINK = g++
-QMAKE_LINK_SHLIB = g++
-QMAKE_LINK_C = gcc
-QMAKE_LINK_C_SHLIB = gcc
-QMAKE_LFLAGS =
-QMAKE_LFLAGS_RELEASE =
-QMAKE_LFLAGS_DEBUG =
-QMAKE_LFLAGS_SHLIB = -shared
-QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB
-QMAKE_LFLAGS_SONAME = -Wl,-soname,
-QMAKE_LFLAGS_THREAD = -pthread
-QMAKE_LFLAGS_RPATH = -Wl,-rpath,
-
-QMAKE_LIBS =
-QMAKE_LIBS_QT = -lqte
-QMAKE_LIBS_QT_THREAD = -lqte-mt
-QMAKE_LIBS_THREAD =
-QMAKE_LIBS_OPENGL =
-QMAKE_LIBS_QTOPIA = -lqpe -lqtopia
-
-QMAKE_MOC = $$[QT_INSTALL_BINS]/moc
-QMAKE_UIC = $$[QT_INSTALL_BINS]/uic
-
-QMAKE_AR = ar cqs
-QMAKE_OBJCOPY = objcopy
-QMAKE_RANLIB =
-
-QMAKE_TAR = tar -cf
-QMAKE_GZIP = gzip -9f
-
-QMAKE_COPY = cp -f
-QMAKE_MOVE = mv -f
-QMAKE_DEL_FILE = rm -f
-QMAKE_DEL_DIR = rmdir
-QMAKE_CHK_DIR_EXISTS = test -d
-QMAKE_MKDIR = mkdir -p
-include(../../common/unix.conf)
-load(qt_config)
diff --git a/mkspecs/qws/freebsd-generic-g++/qplatformdefs.h b/mkspecs/qws/freebsd-generic-g++/qplatformdefs.h
deleted file mode 100644
index b5e2897e23..0000000000
--- a/mkspecs/qws/freebsd-generic-g++/qplatformdefs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the qmake spec of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "../../freebsd-g++/qplatformdefs.h"
diff --git a/mkspecs/qws/linux-arm-g++/qmake.conf b/mkspecs/qws/linux-arm-g++/qmake.conf
deleted file mode 100644
index 7b378133ac..0000000000
--- a/mkspecs/qws/linux-arm-g++/qmake.conf
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# qmake configuration for building with arm-linux-g++
-#
-
-include(../../common/linux.conf)
-include(../../common/gcc-base-unix.conf)
-include(../../common/g++-unix.conf)
-include(../../common/qws.conf)
-
-# modifications to g++.conf
-QMAKE_CC = arm-linux-gcc
-QMAKE_CXX = arm-linux-g++
-QMAKE_LINK = arm-linux-g++
-QMAKE_LINK_SHLIB = arm-linux-g++
-
-# modifications to linux.conf
-QMAKE_AR = arm-linux-ar cqs
-QMAKE_OBJCOPY = arm-linux-objcopy
-QMAKE_STRIP = arm-linux-strip
-
-load(qt_config)
diff --git a/mkspecs/qws/linux-arm-g++/qplatformdefs.h b/mkspecs/qws/linux-arm-g++/qplatformdefs.h
deleted file mode 100644
index afffb5a837..0000000000
--- a/mkspecs/qws/linux-arm-g++/qplatformdefs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the qmake spec of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "../../linux-g++/qplatformdefs.h"
diff --git a/mkspecs/qws/linux-arm-gnueabi-g++/qmake.conf b/mkspecs/qws/linux-arm-gnueabi-g++/qmake.conf
deleted file mode 100644
index e1ad837361..0000000000
--- a/mkspecs/qws/linux-arm-gnueabi-g++/qmake.conf
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# qmake configuration for building with arm-none-linux-gnueabi-g++
-#
-
-include(../../common/linux.conf)
-include(../../common/gcc-base-unix.conf)
-include(../../common/g++-unix.conf)
-include(../../common/qws.conf)
-
-# modifications to g++.conf
-QMAKE_CC = arm-none-linux-gnueabi-gcc
-QMAKE_CXX = arm-none-linux-gnueabi-g++
-QMAKE_LINK = arm-none-linux-gnueabi-g++
-QMAKE_LINK_SHLIB = arm-none-linux-gnueabi-g++
-
-# modifications to linux.conf
-QMAKE_AR = arm-none-linux-gnueabi-ar cqs
-QMAKE_OBJCOPY = arm-none-linux-gnueabi-objcopy
-QMAKE_STRIP = arm-none-linux-gnueabi-strip
-
-load(qt_config)
diff --git a/mkspecs/qws/linux-arm-gnueabi-g++/qplatformdefs.h b/mkspecs/qws/linux-arm-gnueabi-g++/qplatformdefs.h
deleted file mode 100644
index afffb5a837..0000000000
--- a/mkspecs/qws/linux-arm-gnueabi-g++/qplatformdefs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the qmake spec of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "../../linux-g++/qplatformdefs.h"
diff --git a/mkspecs/qws/linux-armv6-g++/qmake.conf b/mkspecs/qws/linux-armv6-g++/qmake.conf
deleted file mode 100644
index 0e2473c26c..0000000000
--- a/mkspecs/qws/linux-armv6-g++/qmake.conf
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# qmake configuration for building for ARMv6 devices with arm-linux-g++
-#
-
-include(../../common/linux.conf)
-include(../../common/gcc-base-unix.conf)
-include(../../common/g++-unix.conf)
-include(../../common/qws.conf)
-
-# modifications to g++.conf
-QMAKE_CC = arm-linux-gcc
-QMAKE_CXX = arm-linux-g++
-QMAKE_LINK = arm-linux-g++
-QMAKE_LINK_SHLIB = arm-linux-g++
-QMAKE_CFLAGS += -march=armv6
-QMAKE_CXXFLAGS += -march=armv6
-
-# modifications to linux.conf
-QMAKE_AR = arm-linux-ar cqs
-QMAKE_OBJCOPY = arm-linux-objcopy
-QMAKE_STRIP = arm-linux-strip
-
-load(qt_config)
diff --git a/mkspecs/qws/linux-armv6-g++/qplatformdefs.h b/mkspecs/qws/linux-armv6-g++/qplatformdefs.h
deleted file mode 100644
index afffb5a837..0000000000
--- a/mkspecs/qws/linux-armv6-g++/qplatformdefs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the qmake spec of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "../../linux-g++/qplatformdefs.h"
diff --git a/mkspecs/qws/linux-avr32-g++/qmake.conf b/mkspecs/qws/linux-avr32-g++/qmake.conf
deleted file mode 100644
index 32c0444de8..0000000000
--- a/mkspecs/qws/linux-avr32-g++/qmake.conf
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# qmake configuration for building with avr32-linux-g++
-#
-
-include(../../common/linux.conf)
-include(../../common/gcc-base-unix.conf)
-include(../../common/g++-unix.conf)
-include(../../common/qws.conf)
-
-# modifications to g++.conf
-QMAKE_CC = avr32-linux-gcc
-QMAKE_CXX = avr32-linux-g++
-QMAKE_LINK = avr32-linux-g++
-QMAKE_LINK_SHLIB = avr32-linux-g++
-
-# modifications to linux.conf
-QMAKE_AR = avr32-linux-ar cqs
-QMAKE_OBJCOPY = avr32-linux-objcopy
-QMAKE_STRIP = avr32-linux-strip
-
-load(qt_config)
diff --git a/mkspecs/qws/linux-avr32-g++/qplatformdefs.h b/mkspecs/qws/linux-avr32-g++/qplatformdefs.h
deleted file mode 100644
index afffb5a837..0000000000
--- a/mkspecs/qws/linux-avr32-g++/qplatformdefs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the qmake spec of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "../../linux-g++/qplatformdefs.h"
diff --git a/mkspecs/qws/linux-cellon-g++/qmake.conf b/mkspecs/qws/linux-cellon-g++/qmake.conf
deleted file mode 100644
index ad66c3c342..0000000000
--- a/mkspecs/qws/linux-cellon-g++/qmake.conf
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# qmake configuration for linux-g++ using the arm-linux-g++ crosscompiler
-#
-
-#
-# qmake configuration for building with arm-linux-g++
-#
-
-include(../../common/linux.conf)
-include(../../common/gcc-base-unix.conf)
-include(../../common/g++-unix.conf)
-include(../../common/qws.conf)
-
-# modifications to g++.conf
-QMAKE_CC = arm-linux-gcc
-QMAKE_CXX = arm-linux-g++
-QMAKE_LINK = arm-linux-g++
-QMAKE_LINK_SHLIB = arm-linux-g++
-QMAKE_CFLAGS = $$QMAKE_CFLAGS -DQT_QWS_CELLON -DQWS
-QMAKE_CXXFLAGS = $$QMAKE_CXXFLAGS -DQT_QWS_CELLON -DQWS
-QMAKE_CFLAGS_RELEASE ~= s/-O2/-Os/
-QMAKE_CXXFLAGS_RELEASE ~= s/-O2/-Os/
-
-# modifications to linux.conf
-QMAKE_AR = arm-linux-ar cqs
-QMAKE_OBJCOPY = arm-linux-objcopy
-QMAKE_STRIP = arm-linux-strip
-
-load(qt_config)
-
diff --git a/mkspecs/qws/linux-cellon-g++/qplatformdefs.h b/mkspecs/qws/linux-cellon-g++/qplatformdefs.h
deleted file mode 100644
index afffb5a837..0000000000
--- a/mkspecs/qws/linux-cellon-g++/qplatformdefs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the qmake spec of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "../../linux-g++/qplatformdefs.h"
diff --git a/mkspecs/qws/linux-dm7000-g++/qmake.conf b/mkspecs/qws/linux-dm7000-g++/qmake.conf
deleted file mode 100644
index c897091466..0000000000
--- a/mkspecs/qws/linux-dm7000-g++/qmake.conf
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# qmake configuration for linux-dm7000-g++, for Dream Multimedia's DM7000S
-#
-
-include(../../common/linux.conf)
-include(../../common/gcc-base-unix.conf)
-include(../../common/g++-unix.conf)
-include(../../common/qws.conf)
-
-# modifications to g++.conf
-QMAKE_CC = powerpc-tuxbox-linux-gnu-gcc
-QMAKE_CFLAGS = -pipe -msoft-float -meabi
-QMAKE_CFLAGS_RELEASE = -O2 -mcpu=405 -mmultiple -mstring
-QMAKE_CFLAGS_DEBUG = -ggdb3
-QMAKE_CXXFLAGS = $$QMAKE_CFLAGS
-QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE
-QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG
-QMAKE_CXX = powerpc-tuxbox-linux-gnu-g++
-QMAKE_LINK = powerpc-tuxbox-linux-gnu-g++
-QMAKE_LINK_SHLIB = powerpc-tuxbox-linux-gnu-g++
-
-# modifications to linux.conf
-QMAKE_AR = powerpc-tuxbox-linux-gnu-ar cqs
-QMAKE_OBJCOPY = powerpc-tuxbox-linux-gnu-objcopy
-QMAKE_STRIP = powerpc-tuxbox-linux-gnu-strip
-
-load(qt_config)
diff --git a/mkspecs/qws/linux-dm7000-g++/qplatformdefs.h b/mkspecs/qws/linux-dm7000-g++/qplatformdefs.h
deleted file mode 100644
index afffb5a837..0000000000
--- a/mkspecs/qws/linux-dm7000-g++/qplatformdefs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the qmake spec of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "../../linux-g++/qplatformdefs.h"
diff --git a/mkspecs/qws/linux-dm800-g++/qmake.conf b/mkspecs/qws/linux-dm800-g++/qmake.conf
deleted file mode 100644
index 002e4c7d56..0000000000
--- a/mkspecs/qws/linux-dm800-g++/qmake.conf
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# qmake configuration for linux-dm800-g++, for Dream Multimedia's DM800
-#
-
-include(../../common/linux.conf)
-include(../../common/gcc-base-unix.conf)
-include(../../common/g++-unix.conf)
-include(../../common/qws.conf)
-
-# modifications to g++.conf
-QMAKE_CC = mipsel-linux-gcc
-QMAKE_CXX = mipsel-linux-g++
-QMAKE_LINK = mipsel-linux-g++
-QMAKE_LINK_SHLIB = mipsel-linux-g++
-QMAKE_CFLAGS += -mabi=32 -mips32
-QMAKE_CFLAGS_RELEASE += -fexpensive-optimizations -frename-registers -O2
-QMAKE_CXXFLAGS = $$QMAKE_CFLAGS
-QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE
-
-# modifications to linux.conf
-QMAKE_AR = mipsel-linux-ar cqs
-QMAKE_OBJCOPY = mipsel-linux-objcopy
-QMAKE_STRIP = mipsel-linux-strip
-
-load(qt_config)
diff --git a/mkspecs/qws/linux-dm800-g++/qplatformdefs.h b/mkspecs/qws/linux-dm800-g++/qplatformdefs.h
deleted file mode 100644
index afffb5a837..0000000000
--- a/mkspecs/qws/linux-dm800-g++/qplatformdefs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the qmake spec of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "../../linux-g++/qplatformdefs.h"
diff --git a/mkspecs/qws/linux-generic-g++-32/qmake.conf b/mkspecs/qws/linux-generic-g++-32/qmake.conf
deleted file mode 100644
index 249c10aae9..0000000000
--- a/mkspecs/qws/linux-generic-g++-32/qmake.conf
+++ /dev/null
@@ -1,15 +0,0 @@
-#
-# qmake configuration for building with arm-linux-g++
-#
-
-include(../../common/linux.conf)
-include(../../common/gcc-base-unix.conf)
-include(../../common/g++-unix.conf)
-include(../../common/qws.conf)
-
-# modifications to g++.conf
-QMAKE_CFLAGS += -m32
-QMAKE_CXXFLAGS += -m32
-QMAKE_LFLAGS += -m32
-
-load(qt_config)
diff --git a/mkspecs/qws/linux-generic-g++-32/qplatformdefs.h b/mkspecs/qws/linux-generic-g++-32/qplatformdefs.h
deleted file mode 100644
index afffb5a837..0000000000
--- a/mkspecs/qws/linux-generic-g++-32/qplatformdefs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the qmake spec of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "../../linux-g++/qplatformdefs.h"
diff --git a/mkspecs/qws/linux-generic-g++/qmake.conf b/mkspecs/qws/linux-generic-g++/qmake.conf
deleted file mode 100644
index e803d0d402..0000000000
--- a/mkspecs/qws/linux-generic-g++/qmake.conf
+++ /dev/null
@@ -1,10 +0,0 @@
-#
-# qmake configuration for building with g++
-#
-
-include(../../common/linux.conf)
-include(../../common/gcc-base-unix.conf)
-include(../../common/g++-unix.conf)
-include(../../common/qws.conf)
-
-load(qt_config)
diff --git a/mkspecs/qws/linux-generic-g++/qplatformdefs.h b/mkspecs/qws/linux-generic-g++/qplatformdefs.h
deleted file mode 100644
index afffb5a837..0000000000
--- a/mkspecs/qws/linux-generic-g++/qplatformdefs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the qmake spec of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "../../linux-g++/qplatformdefs.h"
diff --git a/mkspecs/qws/linux-ipaq-g++/qmake.conf b/mkspecs/qws/linux-ipaq-g++/qmake.conf
deleted file mode 100644
index f9d33b3628..0000000000
--- a/mkspecs/qws/linux-ipaq-g++/qmake.conf
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-# qmake configuration for building with arm-linux-g++
-#
-
-include(../../common/linux.conf)
-include(../../common/gcc-base-unix.conf)
-include(../../common/g++-unix.conf)
-include(../../common/qws.conf)
-
-# modifications to g++.conf
-QMAKE_CC = arm-linux-gcc -DQT_QWS_IPAQ
-QMAKE_CXX = arm-linux-g++ -DQT_QWS_IPAQ
-QMAKE_LINK = arm-linux-g++
-QMAKE_LINK_SHLIB = arm-linux-g++
-
-# modifications to linux.conf
-QMAKE_AR = arm-linux-ar cqs
-QMAKE_OBJCOPY = arm-linux-objcopy
-QMAKE_STRIP = arm-linux-strip
-
-load(qt_config)
-
diff --git a/mkspecs/qws/linux-ipaq-g++/qplatformdefs.h b/mkspecs/qws/linux-ipaq-g++/qplatformdefs.h
deleted file mode 100644
index afffb5a837..0000000000
--- a/mkspecs/qws/linux-ipaq-g++/qplatformdefs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the qmake spec of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "../../linux-g++/qplatformdefs.h"
diff --git a/mkspecs/qws/linux-lsb-g++/qmake.conf b/mkspecs/qws/linux-lsb-g++/qmake.conf
deleted file mode 100644
index 4b359258fb..0000000000
--- a/mkspecs/qws/linux-lsb-g++/qmake.conf
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# qmake configuration for linux-g++
-#
-
-
-include(../../common/linux.conf)
-include(../../common/gcc-base-unix.conf)
-include(../../common/g++-unix.conf)
-include(../../common/qws.conf)
-
-
-QMAKE_LSB = 1
-
-# modifications to g++.conf
-QMAKE_CC = lsbcc
-QMAKE_CXX = lsbc++
-QMAKE_CFLAGS = -pipe -DQT_LINUXBASE -fno-stack-protector
-QMAKE_CXXFLAGS = $$QMAKE_CFLAGS
-QMAKE_LINK = lsbc++
-QMAKE_LINK_SHLIB = lsbc++
-QMAKE_LFLAGS += -fno-stack-protector
-
-load(qt_config)
-
diff --git a/mkspecs/qws/linux-lsb-g++/qplatformdefs.h b/mkspecs/qws/linux-lsb-g++/qplatformdefs.h
deleted file mode 100644
index afffb5a837..0000000000
--- a/mkspecs/qws/linux-lsb-g++/qplatformdefs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the qmake spec of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "../../linux-g++/qplatformdefs.h"
diff --git a/mkspecs/qws/linux-mips-g++/qmake.conf b/mkspecs/qws/linux-mips-g++/qmake.conf
deleted file mode 100644
index 1a8607869f..0000000000
--- a/mkspecs/qws/linux-mips-g++/qmake.conf
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# qmake configuration for building with mipsel-linux-g++
-#
-
-include(../../common/linux.conf)
-include(../../common/gcc-base-unix.conf)
-include(../../common/g++-unix.conf)
-include(../../common/qws.conf)
-
-# modifications to g++.conf
-QMAKE_CC = mips-linux-gcc
-QMAKE_CXX = mips-linux-g++
-QMAKE_CFLAGS += -mips32
-QMAKE_CXXFLAGS += -mips32
-QMAKE_LINK = mips-linux-g++
-QMAKE_LINK_SHLIB = mips-linux-g++
-
-# modifications to linux.conf
-QMAKE_AR = mips-linux-ar cqs
-QMAKE_OBJCOPY = mips-linux-objcopy
-QMAKE_STRIP = mips-linux-strip
-
-load(qt_config)
diff --git a/mkspecs/qws/linux-mips-g++/qplatformdefs.h b/mkspecs/qws/linux-mips-g++/qplatformdefs.h
deleted file mode 100644
index afffb5a837..0000000000
--- a/mkspecs/qws/linux-mips-g++/qplatformdefs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the qmake spec of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "../../linux-g++/qplatformdefs.h"
diff --git a/mkspecs/qws/linux-nacl-g++/qmake.conf b/mkspecs/qws/linux-nacl-g++/qmake.conf
deleted file mode 100644
index 7293a1acfd..0000000000
--- a/mkspecs/qws/linux-nacl-g++/qmake.conf
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# qmake configuration for building with nacl-g++
-#
-
-include(../../common/linux.conf)
-include(../../common/qws.conf)
-include(../../common/gcc-base-unix.conf)
-include(../../common/g++-unix.conf)
-
-QT = core gui
-
-QMAKE_CC = nacl-gcc
-QMAKE_CXX = nacl-g++
-QMAKE_LINK = nacl-g++
-QMAKE_LINK_SHLIB = nacl-g++
-QMAKE_AR = nacl-ar q
-QMAKE_OBJCOPY = nacl-objcopy
-QMAKE_STRIP = nacl-strip
-
-# work around linker crash when using PIC
-QMAKE_CFLAGS_STATIC_LIB -= -fPIC
-QMAKE_CFLAGS_SHLIB -= -fPIC
-QMAKE_CXXFLAGS_STATIC_LIB -= -fPIC
-QMAKE_CXXFLAGS_SHLIB -= -fPIC
-
-#QMAKE_CFLAGS += -pipe -DXP_UNIX -DNACL_STANDALONE=1
-QMAKE_LIBS_DYNLOAD -= -ldl
-
-load(qt_config)
diff --git a/mkspecs/qws/linux-nacl-g++/qplatformdefs.h b/mkspecs/qws/linux-nacl-g++/qplatformdefs.h
deleted file mode 100644
index 8d25281ab6..0000000000
--- a/mkspecs/qws/linux-nacl-g++/qplatformdefs.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the qmake spec of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPLATFORMDEFS_H
-#define QPLATFORMDEFS_H
-
-// Get Qt defines/settings
-
-#define _POSIX_TIMERS
-
-#include "qglobal.h"
-
-// extra disabling.
-#ifdef __native_client__
-#define QT_NO_FSFILEENGINE
-#endif
-
-#define QT_NO_SOCKET_H
-
-#define DIR void *
-#define PATH_MAX 256
-
-#include "../../common/posix/qplatformdefs.h"
-#include "qfunctions_nacl.h"
-#include <pthread.h>
-
-#undef QT_LSTAT
-#define QT_LSTAT QT_STAT
-
-
-#endif // QPLATFORMDEFS_H
diff --git a/mkspecs/qws/linux-powerpc-g++/qmake.conf b/mkspecs/qws/linux-powerpc-g++/qmake.conf
deleted file mode 100644
index 6a6310aa02..0000000000
--- a/mkspecs/qws/linux-powerpc-g++/qmake.conf
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# qmake configuration for building with g++
-#
-
-include(../../common/linux.conf)
-include(../../common/gcc-base-unix.conf)
-include(../../common/g++-unix.conf)
-include(../../common/qws.conf)
-
-# modifications to g++.conf
-QMAKE_CC = powerpc-linux-gcc
-QMAKE_CXX = powerpc-linux-g++
-QMAKE_LINK = powerpc-linux-g++
-QMAKE_LINK_SHLIB = powerpc-linux-g++
-
-# modifications to linux.conf
-QMAKE_AR = powerpc-linux-ar cqs
-QMAKE_OBJCOPY = powerpc-linux-objcopy
-QMAKE_STRIP = powerpc-linux-strip
-
-load(qt_config)
diff --git a/mkspecs/qws/linux-powerpc-g++/qplatformdefs.h b/mkspecs/qws/linux-powerpc-g++/qplatformdefs.h
deleted file mode 100644
index afffb5a837..0000000000
--- a/mkspecs/qws/linux-powerpc-g++/qplatformdefs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the qmake spec of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "../../linux-g++/qplatformdefs.h"
diff --git a/mkspecs/qws/linux-sh-g++/qmake.conf b/mkspecs/qws/linux-sh-g++/qmake.conf
deleted file mode 100644
index 004780a559..0000000000
--- a/mkspecs/qws/linux-sh-g++/qmake.conf
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# qmake configuration for building for SH devices with sh3-linux-g++
-#
-
-include(../../common/linux.conf)
-include(../../common/gcc-base-unix.conf)
-include(../../common/g++-unix.conf)
-include(../../common/qws.conf)
-
-# modifications to g++.conf
-QMAKE_CC = sh3-linux-gcc
-QMAKE_CXX = sh3-linux-g++
-QMAKE_LINK = sh3-linux-g++
-QMAKE_LINK_SHLIB = sh3-linux-g++
-
-# modifications to linux.conf
-QMAKE_AR = sh3-linux-ar cqs
-QMAKE_OBJCOPY = sh3-linux-objcopy
-QMAKE_STRIP = sh3-linux-strip
-
-load(qt_config)
diff --git a/mkspecs/qws/linux-sh-g++/qplatformdefs.h b/mkspecs/qws/linux-sh-g++/qplatformdefs.h
deleted file mode 100644
index afffb5a837..0000000000
--- a/mkspecs/qws/linux-sh-g++/qplatformdefs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the qmake spec of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "../../linux-g++/qplatformdefs.h"
diff --git a/mkspecs/qws/linux-sh4al-g++/qmake.conf b/mkspecs/qws/linux-sh4al-g++/qmake.conf
deleted file mode 100644
index 71f6b3df56..0000000000
--- a/mkspecs/qws/linux-sh4al-g++/qmake.conf
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# qmake configuration for building for SH4AL-DSP devices with sh3-linux-g++
-#
-
-include(../../common/linux.conf)
-include(../../common/gcc-base-unix.conf)
-include(../../common/g++-unix.conf)
-include(../../common/qws.conf)
-
-# modifications to g++.conf
-QMAKE_CC = sh3-linux-gcc
-QMAKE_CXX = sh3-linux-g++
-QMAKE_LINK = sh3-linux-g++
-QMAKE_LINK_SHLIB = sh3-linux-g++
-QMAKE_CFLAGS += -m4al
-QMAKE_CXXFLAGS += -m4al
-
-
-# modifications to linux.conf
-QMAKE_AR = sh3-linux-ar cqs
-QMAKE_OBJCOPY = sh3-linux-objcopy
-QMAKE_STRIP = sh3-linux-strip
-
-load(qt_config)
diff --git a/mkspecs/qws/linux-sh4al-g++/qplatformdefs.h b/mkspecs/qws/linux-sh4al-g++/qplatformdefs.h
deleted file mode 100644
index afffb5a837..0000000000
--- a/mkspecs/qws/linux-sh4al-g++/qplatformdefs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the qmake spec of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "../../linux-g++/qplatformdefs.h"
diff --git a/mkspecs/qws/linux-sharp-g++/qmake.conf b/mkspecs/qws/linux-sharp-g++/qmake.conf
deleted file mode 100644
index 6a000b9c64..0000000000
--- a/mkspecs/qws/linux-sharp-g++/qmake.conf
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# qmake configuration for building with arm-linux-g++
-#
-
-include(../../common/linux.conf)
-include(../../common/gcc-base-unix.conf)
-include(../../common/g++-unix.conf)
-include(../../common/qws.conf)
-
-# modifications to g++.conf
-QMAKE_CC = arm-linux-gcc
-QMAKE_CXX = arm-linux-g++
-QMAKE_LINK = arm-linux-g++
-QMAKE_LINK_SHLIB = arm-linux-g++
-QMAKE_CFLAGS += -DQT_QWS_SHARP -DQT_QWS_EBX
-QMAKE_CXXFLAGS += -DQT_QWS_SHARP -DQT_QWS_EBX
-
-# modifications to linux.conf
-QMAKE_AR = arm-linux-ar cqs
-QMAKE_OBJCOPY = arm-linux-objcopy
-QMAKE_STRIP = arm-linux-strip
-
-load(qt_config)
-
diff --git a/mkspecs/qws/linux-sharp-g++/qplatformdefs.h b/mkspecs/qws/linux-sharp-g++/qplatformdefs.h
deleted file mode 100644
index afffb5a837..0000000000
--- a/mkspecs/qws/linux-sharp-g++/qplatformdefs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the qmake spec of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "../../linux-g++/qplatformdefs.h"
diff --git a/mkspecs/qws/linux-x86-g++/qmake.conf b/mkspecs/qws/linux-x86-g++/qmake.conf
deleted file mode 100644
index 55011ec52b..0000000000
--- a/mkspecs/qws/linux-x86-g++/qmake.conf
+++ /dev/null
@@ -1,10 +0,0 @@
-#
-# qmake configuration for building with linux-g++
-#
-
-include(../../common/linux.conf)
-include(../../common/gcc-base-unix.conf)
-include(../../common/g++-unix.conf)
-include(../../common/qws.conf)
-
-load(qt_config)
diff --git a/mkspecs/qws/linux-x86-g++/qplatformdefs.h b/mkspecs/qws/linux-x86-g++/qplatformdefs.h
deleted file mode 100644
index afffb5a837..0000000000
--- a/mkspecs/qws/linux-x86-g++/qplatformdefs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the qmake spec of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "../../linux-g++/qplatformdefs.h"
diff --git a/mkspecs/qws/linux-x86_64-g++/qmake.conf b/mkspecs/qws/linux-x86_64-g++/qmake.conf
deleted file mode 100644
index e18d055790..0000000000
--- a/mkspecs/qws/linux-x86_64-g++/qmake.conf
+++ /dev/null
@@ -1,15 +0,0 @@
-#
-# qmake configuration for building with linux-g++
-#
-
-include(../../common/linux.conf)
-include(../../common/gcc-base-unix.conf)
-include(../../common/g++-unix.conf)
-include(../../common/qws.conf)
-
-# modifications to g++.conf
-QMAKE_CFLAGS += -m64
-QMAKE_CXXFLAGS += -m64
-
-load(qt_config)
-
diff --git a/mkspecs/qws/linux-x86_64-g++/qplatformdefs.h b/mkspecs/qws/linux-x86_64-g++/qplatformdefs.h
deleted file mode 100644
index afffb5a837..0000000000
--- a/mkspecs/qws/linux-x86_64-g++/qplatformdefs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the qmake spec of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "../../linux-g++/qplatformdefs.h"
diff --git a/mkspecs/qws/linux-zylonite-g++/qmake.conf b/mkspecs/qws/linux-zylonite-g++/qmake.conf
deleted file mode 100644
index f50b70f945..0000000000
--- a/mkspecs/qws/linux-zylonite-g++/qmake.conf
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# qmake configuration for building with arm-linux-g++
-#
-
-include(../../common/linux.conf)
-include(../../common/gcc-base-unix.conf)
-include(../../common/g++-unix.conf)
-include(../../common/qws.conf)
-
-# modifications to g++.conf
-QMAKE_CC = arm-linux-gcc
-QMAKE_CXX = arm-linux-g++
-QMAKE_CFLAGS += -DQT_QWS_ZYLONITE -DQWS -fno-rtti
-QMAKE_CXXFLAGS += -DQT_QWS_ZYLONITE -DQWS -fno-rtti
-QMAKE_LINK = arm-linux-g++
-QMAKE_LINK_SHLIB = arm-linux-g++
-QMAKE_CFLAGS_RELEASE ~= s/-O2/-Os/
-QMAKE_CXXFLAGS_RELEASE ~= s/-O2/-Os/
-
-# modifications to linux.conf
-QMAKE_AR = arm-linux-ar cqs
-QMAKE_OBJCOPY = arm-linux-objcopy
-QMAKE_STRIP = arm-linux-strip
-
-load(qt_config)
-
diff --git a/mkspecs/qws/linux-zylonite-g++/qplatformdefs.h b/mkspecs/qws/linux-zylonite-g++/qplatformdefs.h
deleted file mode 100644
index afffb5a837..0000000000
--- a/mkspecs/qws/linux-zylonite-g++/qplatformdefs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the qmake spec of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "../../linux-g++/qplatformdefs.h"
diff --git a/mkspecs/qws/macx-generic-g++/qmake.conf b/mkspecs/qws/macx-generic-g++/qmake.conf
deleted file mode 100644
index 8dcbb39316..0000000000
--- a/mkspecs/qws/macx-generic-g++/qmake.conf
+++ /dev/null
@@ -1,90 +0,0 @@
-#
-# qmake configuration for macx-g++ with Qtopia Core
-#
-
-include(../../common/unix.conf)
-
-MAKEFILE_GENERATOR = UNIX
-TARGET_PLATFORM = macx
-TEMPLATE = app
-CONFIG += qt warn_on release link_prl
-QT += core gui network
-QMAKE_INCREMENTAL_STYLE = sublib
-QMAKE_EXTENSION_SHLIB = dylib
-
-QMAKE_CC = $(TB)cc
-QMAKE_LEX = flex
-QMAKE_LEXFLAGS =
-QMAKE_YACC = yacc
-QMAKE_YACCFLAGS = -d
-QMAKE_CFLAGS = -pipe
-QMAKE_CFLAGS_WARN_ON = -Wall -W
-QMAKE_CFLAGS_WARN_OFF =
-QMAKE_CFLAGS_RELEASE = -O2
-QMAKE_CFLAGS_DEBUG = -g
-QMAKE_CFLAGS_SHLIB = -fPIC
-QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses
-QMAKE_CFLAGS_THREAD = -D_REENTRANT
-QMAKE_CFLAGS_HIDESYMS = -fvisibility=hidden
-
-QMAKE_CXX = c++
-QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -DQT_NO_QWS_TRANSFORMED
-QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON
-QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF
-QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -fno-default-inline
-QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG
-QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB
-QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC
-QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD
-QMAKE_CXXFLAGS_HIDESYMS = $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden
-
-QMAKE_INCDIR =
-QMAKE_LIBDIR =
-QMAKE_INCDIR_X11 =
-QMAKE_LIBDIR_X11 =
-QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS]
-QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS]
-QMAKE_INCDIR_OPENGL =
-QMAKE_LIBDIR_OPENGL =
-QMAKE_INCDIR_QTOPIA = $(QPEDIR)/include
-QMAKE_LIBDIR_QTOPIA = $(QPEDIR)/lib
-
-QMAKE_LINK = $$QMAKE_CXX
-QMAKE_LINK_SHLIB = $$QMAKE_CXX
-QMAKE_LFLAGS =
-QMAKE_LFLAGS_RELEASE =
-QMAKE_LFLAGS_DEBUG =
-QMAKE_LFLAGS_SHLIB = -dynamiclib
-QMAKE_LFLAGS_INCREMENTAL = -undefined suppress -flat_namespace
-QMAKE_LFLAGS_PLUGIN = -bundle
-QMAKE_LFLAGS_SONAME =
-QMAKE_LFLAGS_THREAD =
-QMAKE_LFLAGS_RPATH =
-
-QMAKE_LIBS =
-QMAKE_LIBS_X11 =
-QMAKE_LIBS_X11SM =
-QMAKE_LIBS_QT = -lqte
-QMAKE_LIBS_QT_THREAD = -lqte-mt
-QMAKE_LIBS_QT_OPENGL = -lqgl
-QMAKE_LIBS_QTOPIA = -lqpe -lqtopia
-QMAKE_LIBS_THREAD =
-QMAKE_LIBS_OPENGL =
-
-QMAKE_MOC = $$[QT_INSTALL_BINS]/moc
-QMAKE_UIC = $$[QT_INSTALL_BINS]/uic
-
-QMAKE_AR = ar cqs
-QMAKE_OBJCOPY = objcopy
-QMAKE_RANLIB =
-
-QMAKE_TAR = tar -cf
-QMAKE_GZIP = gzip -9f
-
-QMAKE_COPY = cp -f
-QMAKE_MOVE = mv -f
-QMAKE_DEL_FILE = rm -f
-QMAKE_DEL_DIR = rmdir
-QMAKE_CHK_DIR_EXISTS = test -d
-QMAKE_MKDIR = mkdir -p
-load(qt_config)
diff --git a/mkspecs/qws/macx-generic-g++/qplatformdefs.h b/mkspecs/qws/macx-generic-g++/qplatformdefs.h
deleted file mode 100644
index 7328c5049a..0000000000
--- a/mkspecs/qws/macx-generic-g++/qplatformdefs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the qmake spec of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "../../macx-g++/qplatformdefs.h"
diff --git a/mkspecs/qws/macx-iphonedevice-g++/Info.plist.lib b/mkspecs/qws/macx-iphonedevice-g++/Info.plist.lib
deleted file mode 100644
index 97609ed0ce..0000000000
--- a/mkspecs/qws/macx-iphonedevice-g++/Info.plist.lib
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
-<plist version="0.9">
-<dict>
- <key>CFBundlePackageType</key>
- <string>FMWK</string>
- <key>CFBundleShortVersionString</key>
- <string>@SHORT_VERSION@</string>
- <key>CFBundleGetInfoString</key>
- <string>Created by Qt/QMake</string>
- <key>CFBundleSignature</key>
- <string>@TYPEINFO@</string>
- <key>CFBundleExecutable</key>
- <string>@LIBRARY@</string>
- <key>NOTE</key>
- <string>Please, do NOT change this file -- It was generated by Qt/QMake.</string>
-</dict>
-</plist>
diff --git a/mkspecs/qws/macx-iphonedevice-g++/qmake.conf b/mkspecs/qws/macx-iphonedevice-g++/qmake.conf
deleted file mode 100644
index 227d24e838..0000000000
--- a/mkspecs/qws/macx-iphonedevice-g++/qmake.conf
+++ /dev/null
@@ -1,48 +0,0 @@
-#
-# qmake configuration for iphone-device-g++
-#
-include(../../common/mac.conf)
-include(../../common/gcc-base-macx.conf)
-include(../../common/g++-macx.conf)
-
-MAKEFILE_GENERATOR = UNIX
-TEMPLATE = app
-CONFIG += qt warn_on release app_bundle incremental global_init_link_order lib_version_first plugin_no_soname link_prl
-QT += core gui
-QMAKE_INCREMENTAL_STYLE = sublib
-
-# Do not compile a few things
-DEFINES += QT_NO_AUDIO_BACKEND QT_NO_NETWORKPROXY QT_NO_FILESYSTEMWATCHER
-
-# You may need to change this to point to the iOS SDK you want to use.
-QMAKE_IOS_DEV_PATH = /Developer/Platforms/iPhoneOS.platform/Developer
-QMAKE_IOS_SDK = $$QMAKE_IOS_DEV_PATH/SDKs/iPhoneOS4.3.sdk
-DEFINES += __IPHONE_OS_VERSION_MIN_REQUIRED=40200
-
-#clear
-QMAKE_MACOSX_DEPLOYMENT_TARGET =
-
-QMAKE_LIBS_OPENGL_ES1 += -framework OpenGLES
-QMAKE_LIBS_OPENGL_ES2 += -framework OpenGLES
-
-# TARGET_PLATFORM = ios
-QMAKE_CC = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2
-QMAKE_CXX = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/g++-4.2
-QMAKE_LINK = $$QMAKE_CXX
-QMAKE_LINK_SHLIB = $$QMAKE_CXX
-
-QMAKE_CFLAGS += -arch armv7 -marm -isysroot $$QMAKE_IOS_SDK -fmessage-length=0 -fexceptions -miphoneos-version-min=4.2
-QMAKE_CXXFLAGS += $$QMAKE_CFLAGS
-QMAKE_OBJECTIVE_CFLAGS += -arch armv7 -marm -isysroot $$QMAKE_IOS_SDK -fmessage-length=0 -fexceptions -miphoneos-version-min=4.2 -fobjc-abi-version=2 -fobjc-legacy-dispatch
-QMAKE_LFLAGS += -arch armv7 -marm -miphoneos-version-min=4.2 -Wl,-syslibroot,$$QMAKE_IOS_SDK
-
-QMAKE_INCDIR_OPENGL =
-QMAKE_LIBS_OPENGL =
-QMAKE_LIBS_OPENGL_QT =
-
-#QMAKE_RESOURCE =
-QMAKE_FIX_RPATH = $$QMAKE_IOS_DEV_PATH/usr/bin/install_name_tool -id
-QMAKE_AR = $$QMAKE_IOS_DEV_PATH/usr/bin/ar cq
-QMAKE_RANLIB = $$QMAKE_IOS_DEV_PATH/usr/bin/ranlib -s
-
-load(qt_config)
diff --git a/mkspecs/qws/macx-iphonedevice-g++/qplatformdefs.h b/mkspecs/qws/macx-iphonedevice-g++/qplatformdefs.h
deleted file mode 100644
index 0468935ea6..0000000000
--- a/mkspecs/qws/macx-iphonedevice-g++/qplatformdefs.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the qmake spec of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPLATFORMDEFS_H
-#define QPLATFORMDEFS_H
-
-// Get Qt defines/settings
-
-#include "qglobal.h"
-
-// Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs
-
-#include <unistd.h>
-
-
-// We are hot - unistd.h should have turned on the specific APIs we requested
-
-
-#include <pthread.h>
-#include <dirent.h>
-#include <fcntl.h>
-#include <grp.h>
-#include <pwd.h>
-#include <signal.h>
-#define QT_NO_LIBRARY_UNLOAD
-
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/ipc.h>
-#include <sys/time.h>
-#include <sys/shm.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <netinet/in.h>
-#ifndef QT_NO_IPV6IFNAME
-#include <net/if.h>
-#endif
-
-#include "../../common/posix/qplatformdefs.h"
-
-#undef QT_OPEN_LARGEFILE
-#undef QT_SOCKLEN_T
-#undef QT_SIGNAL_IGNORE
-
-#define QT_OPEN_LARGEFILE 0
-
-#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
-#define QT_SOCKLEN_T socklen_t
-#else
-#define QT_SOCKLEN_T int
-#endif
-
-#define QT_SIGNAL_IGNORE (void (*)(int))1
-
-#define QT_SNPRINTF ::snprintf
-#define QT_VSNPRINTF ::vsnprintf
-
-#define QT_QPA_DEFAULT_PLATFORM_NAME "uikit"
-
-#endif // QPLATFORMDEFS_H
diff --git a/mkspecs/qws/macx-iphonesimulator-g++/Info.plist.lib b/mkspecs/qws/macx-iphonesimulator-g++/Info.plist.lib
deleted file mode 100644
index 97609ed0ce..0000000000
--- a/mkspecs/qws/macx-iphonesimulator-g++/Info.plist.lib
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
-<plist version="0.9">
-<dict>
- <key>CFBundlePackageType</key>
- <string>FMWK</string>
- <key>CFBundleShortVersionString</key>
- <string>@SHORT_VERSION@</string>
- <key>CFBundleGetInfoString</key>
- <string>Created by Qt/QMake</string>
- <key>CFBundleSignature</key>
- <string>@TYPEINFO@</string>
- <key>CFBundleExecutable</key>
- <string>@LIBRARY@</string>
- <key>NOTE</key>
- <string>Please, do NOT change this file -- It was generated by Qt/QMake.</string>
-</dict>
-</plist>
diff --git a/mkspecs/qws/macx-iphonesimulator-g++/qmake.conf b/mkspecs/qws/macx-iphonesimulator-g++/qmake.conf
deleted file mode 100644
index 93c47862a0..0000000000
--- a/mkspecs/qws/macx-iphonesimulator-g++/qmake.conf
+++ /dev/null
@@ -1,49 +0,0 @@
-#
-# qmake configuration for macx-g++
-#
-include(../../common/mac.conf)
-include(../../common/gcc-base-macx.conf)
-include(../../common/g++-macx.conf)
-
-MAKEFILE_GENERATOR = UNIX
-TEMPLATE = app
-CONFIG += qt warn_on release app_bundle incremental global_init_link_order lib_version_first plugin_no_soname link_prl
-QT += core gui
-QMAKE_INCREMENTAL_STYLE = sublib
-
-# Do not compile a few things
-DEFINES += QT_NO_AUDIO_BACKEND QT_NO_NETWORKPROXY QT_NO_FILESYSTEMWATCHER
-
-# You may need to change this to point to the iOS SDK you want to use.
-QMAKE_IOS_DEV_PATH = /Developer/Platforms/iPhoneSimulator.platform/Developer
-QMAKE_IOS_SDK = $$QMAKE_IOS_DEV_PATH/SDKs/iPhoneSimulator4.2.sdk
-DEFINES += __IPHONE_OS_VERSION_MIN_REQUIRED=40200
-#clear
-QMAKE_MACOSX_DEPLOYMENT_TARGET =
-
-QMAKE_LIBS_OPENGL_ES1 += -framework OpenGLES
-QMAKE_LIBS_OPENGL_ES2 += -framework OpenGLES
-
-# TARGET_PLATFORM = ios
-QMAKE_CC = /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2
-QMAKE_CXX = /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g++-4.2
-QMAKE_LINK = $$QMAKE_CXX
-QMAKE_LINK_SHLIB = $$QMAKE_CXX
-
-QMAKE_CFLAGS += -arch i386 -isysroot $$QMAKE_IOS_SDK
-QMAKE_CXXFLAGS += $$QMAKE_CFLAGS
-QMAKE_OBJECTIVE_CFLAGS += -arch i386 -isysroot $$QMAKE_IOS_SDK -fobjc-abi-version=2 -fobjc-legacy-dispatch
-QMAKE_LFLAGS += -arch i386 -Wl,-syslibroot,$$QMAKE_IOS_SDK
-
-QMAKE_INCDIR_OPENGL =
-QMAKE_LIBS_OPENGL =
-QMAKE_LIBS_OPENGL_QT =
-
-#QMAKE_RESOURCE =
-QMAKE_FIX_RPATH = $$QMAKE_IOS_DEV_PATH/usr/bin/install_name_tool -id
-QMAKE_AR = $$QMAKE_IOS_DEV_PATH/usr/bin/ar cq
-QMAKE_RANLIB = $$QMAKE_IOS_DEV_PATH/usr/bin/ranlib -s
-
-load(qt_config)
-
-QMAKE_OBJECTIVE_CFLAGS_X86 += -arch i386 -isysroot $$QMAKE_IOS_SDK -fobjc-abi-version=2 -fobjc-legacy-dispatch
diff --git a/mkspecs/qws/macx-iphonesimulator-g++/qplatformdefs.h b/mkspecs/qws/macx-iphonesimulator-g++/qplatformdefs.h
deleted file mode 100644
index 0468935ea6..0000000000
--- a/mkspecs/qws/macx-iphonesimulator-g++/qplatformdefs.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the qmake spec of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPLATFORMDEFS_H
-#define QPLATFORMDEFS_H
-
-// Get Qt defines/settings
-
-#include "qglobal.h"
-
-// Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs
-
-#include <unistd.h>
-
-
-// We are hot - unistd.h should have turned on the specific APIs we requested
-
-
-#include <pthread.h>
-#include <dirent.h>
-#include <fcntl.h>
-#include <grp.h>
-#include <pwd.h>
-#include <signal.h>
-#define QT_NO_LIBRARY_UNLOAD
-
-#include <sys/types.h>
-#include <sys/ioctl.h>
-#include <sys/ipc.h>
-#include <sys/time.h>
-#include <sys/shm.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <netinet/in.h>
-#ifndef QT_NO_IPV6IFNAME
-#include <net/if.h>
-#endif
-
-#include "../../common/posix/qplatformdefs.h"
-
-#undef QT_OPEN_LARGEFILE
-#undef QT_SOCKLEN_T
-#undef QT_SIGNAL_IGNORE
-
-#define QT_OPEN_LARGEFILE 0
-
-#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_4)
-#define QT_SOCKLEN_T socklen_t
-#else
-#define QT_SOCKLEN_T int
-#endif
-
-#define QT_SIGNAL_IGNORE (void (*)(int))1
-
-#define QT_SNPRINTF ::snprintf
-#define QT_VSNPRINTF ::vsnprintf
-
-#define QT_QPA_DEFAULT_PLATFORM_NAME "uikit"
-
-#endif // QPLATFORMDEFS_H
diff --git a/mkspecs/qws/macx-nacl-g++/qmake.conf b/mkspecs/qws/macx-nacl-g++/qmake.conf
deleted file mode 100644
index 7293a1acfd..0000000000
--- a/mkspecs/qws/macx-nacl-g++/qmake.conf
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# qmake configuration for building with nacl-g++
-#
-
-include(../../common/linux.conf)
-include(../../common/qws.conf)
-include(../../common/gcc-base-unix.conf)
-include(../../common/g++-unix.conf)
-
-QT = core gui
-
-QMAKE_CC = nacl-gcc
-QMAKE_CXX = nacl-g++
-QMAKE_LINK = nacl-g++
-QMAKE_LINK_SHLIB = nacl-g++
-QMAKE_AR = nacl-ar q
-QMAKE_OBJCOPY = nacl-objcopy
-QMAKE_STRIP = nacl-strip
-
-# work around linker crash when using PIC
-QMAKE_CFLAGS_STATIC_LIB -= -fPIC
-QMAKE_CFLAGS_SHLIB -= -fPIC
-QMAKE_CXXFLAGS_STATIC_LIB -= -fPIC
-QMAKE_CXXFLAGS_SHLIB -= -fPIC
-
-#QMAKE_CFLAGS += -pipe -DXP_UNIX -DNACL_STANDALONE=1
-QMAKE_LIBS_DYNLOAD -= -ldl
-
-load(qt_config)
diff --git a/mkspecs/qws/macx-nacl-g++/qplatformdefs.h b/mkspecs/qws/macx-nacl-g++/qplatformdefs.h
deleted file mode 100644
index 2a806a3fa3..0000000000
--- a/mkspecs/qws/macx-nacl-g++/qplatformdefs.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the qmake spec of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPLATFORMDEFS_H
-#define QPLATFORMDEFS_H
-
-
-#define _POSIX_TIMERS
-
-#include "qglobal.h"
-
-// extra disabling.
-#ifdef __native_client__
-#define QT_NO_FSFILEENGINE
-#endif
-
-#define QT_NO_SOCKET_H
-
-#define DIR void *
-#define PATH_MAX 256
-
-#include "../../common/posix/qplatformdefs.h"
-#include "qfunctions_nacl.h"
-#include <pthread.h>
-
-#undef QT_LSTAT
-#define QT_LSTAT QT_STAT
-
-
-#endif // QPLATFORMDEFS_H
diff --git a/mkspecs/qws/solaris-generic-g++/qmake.conf b/mkspecs/qws/solaris-generic-g++/qmake.conf
deleted file mode 100644
index 3bf7e56447..0000000000
--- a/mkspecs/qws/solaris-generic-g++/qmake.conf
+++ /dev/null
@@ -1,89 +0,0 @@
-#
-# qmake configuration for solaris-g++ with Qtopia Core
-#
-
-MAKEFILE_GENERATOR = UNIX
-TARGET_PLATFORM = unix
-TEMPLATE = app
-CONFIG += qt warn_on release link_prl
-QT += core gui network
-QMAKE_INCREMENTAL_STYLE = sublib
-
-QMAKE_CC = gcc
-QMAKE_LEX = flex
-QMAKE_LEXFLAGS =
-QMAKE_YACC = yacc
-QMAKE_YACCFLAGS = -d
-QMAKE_CFLAGS = -pipe
-QMAKE_CFLAGS_WARN_ON = -Wall -W
-QMAKE_CFLAGS_WARN_OFF =
-QMAKE_CFLAGS_RELEASE = -O2 -fno-default-inline
-QMAKE_CFLAGS_DEBUG = -g
-QMAKE_CFLAGS_SHLIB = -fPIC
-QMAKE_CFLAGS_YACC = -Wno-unused -Wno-parentheses
-QMAKE_CFLAGS_THREAD = -D_REENTRANT
-QMAKE_CFLAGS_HIDESYMS = -fvisibility=hidden
-
-QMAKE_CXX = g++
-QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -DQT_NO_SOUND -DQT_NO_QWS_LINUXFB -DQT_NO_QWS_TRANSFORMED
-QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON
-QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF
-QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE
-QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG
-QMAKE_CXXFLAGS_SHLIB = $$QMAKE_CFLAGS_SHLIB
-QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC
-QMAKE_CXXFLAGS_THREAD = $$QMAKE_CFLAGS_THREAD
-QMAKE_CXXFLAGS_HIDESYMS = $$QMAKE_CFLAGS_HIDESYMS -fvisibility-inlines-hidden
-
-QMAKE_INCDIR =
-QMAKE_LIBDIR =
-QMAKE_INCDIR_X11 =
-QMAKE_LIBDIR_X11 =
-QMAKE_INCDIR_QT = $$[QT_INSTALL_HEADERS]
-QMAKE_LIBDIR_QT = $$[QT_INSTALL_LIBS]
-QMAKE_INCDIR_OPENGL =
-QMAKE_LIBDIR_OPENGL =
-QMAKE_INCDIR_QTOPIA = $(QPEDIR)/include
-QMAKE_LIBDIR_QTOPIA = $(QPEDIR)/lib
-
-QMAKE_LINK = g++
-QMAKE_LINK_SHLIB = g++
-QMAKE_LINK_C = gcc
-QMAKE_LINK_C_SHLIB = gcc
-QMAKE_LFLAGS =
-QMAKE_LFLAGS_RELEASE =
-QMAKE_LFLAGS_DEBUG =
-QMAKE_LFLAGS_SHLIB = -shared
-QMAKE_LFLAGS_PLUGIN = $$QMAKE_LFLAGS_SHLIB
-QMAKE_LFLAGS_SONAME = -Wl,-soname,
-QMAKE_LFLAGS_THREAD =
-QMAKE_LFLAGS_RPATH = -Wl,-rpath,
-
-QMAKE_LIBS = -lsocket -lnsl -lresolv
-QMAKE_LIBS_DYNLOAD = -ldl
-QMAKE_LIBS_X11 =
-QMAKE_LIBS_X11SM =
-QMAKE_LIBS_QT = -lqte
-QMAKE_LIBS_QT_THREAD = -lqte-mt
-QMAKE_LIBS_QT_OPENGL = -lqgl
-QMAKE_LIBS_QTOPIA = -lqpe -lqtopia
-QMAKE_LIBS_THREAD = -lthread -lrt
-QMAKE_LIBS_OPENGL =
-
-QMAKE_MOC = $$[QT_INSTALL_BINS]/moc
-QMAKE_UIC = $$[QT_INSTALL_BINS]/uic
-
-QMAKE_AR = ar cq
-QMAKE_OBJCOPY = objcopy
-QMAKE_RANLIB =
-
-QMAKE_TAR = tar -cf
-QMAKE_GZIP = gzip -9f
-
-QMAKE_COPY = cp -f
-QMAKE_MOVE = mv -f
-QMAKE_DEL_FILE = rm -f
-QMAKE_DEL_DIR = rmdir
-QMAKE_CHK_DIR_EXISTS = test -d
-QMAKE_MKDIR = mkdir -p
-load(qt_config)
diff --git a/mkspecs/qws/solaris-generic-g++/qplatformdefs.h b/mkspecs/qws/solaris-generic-g++/qplatformdefs.h
deleted file mode 100644
index d0525cbcba..0000000000
--- a/mkspecs/qws/solaris-generic-g++/qplatformdefs.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the qmake spec of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "../../solaris-g++/qplatformdefs.h"
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 75ce68afbf..252af2caf6 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -271,13 +271,13 @@ public:
Window = 0x00000001,
Dialog = 0x00000002 | Window,
Sheet = 0x00000004 | Window,
- Drawer = 0x00000006 | Window,
+ Drawer = Sheet | Dialog,
Popup = 0x00000008 | Window,
- Tool = 0x0000000a | Window,
- ToolTip = 0x0000000c | Window,
- SplashScreen = 0x0000000e | Window,
+ Tool = Popup | Dialog,
+ ToolTip = Popup | Sheet,
+ SplashScreen = ToolTip | Dialog,
Desktop = 0x00000010 | Window,
- SubWindow = 0x00000012,
+ SubWindow = Desktop | Dialog,
WindowType_Mask = 0x000000ff,
MSWindowsFixedSizeDialogHint = 0x00000100,
@@ -292,13 +292,7 @@ public:
WindowContextHelpButtonHint = 0x00010000,
WindowShadeButtonHint = 0x00020000,
WindowStaysOnTopHint = 0x00040000,
- // reserved for Qt3Support:
- // WMouseNoMask = 0x00080000,
- // WDestructiveClose = 0x00100000,
- // WStaticContents = 0x00200000,
- // WGroupLeader = 0x00400000,
- // WShowModal = 0x00800000,
- // WNoMousePropagation = 0x01000000,
+
CustomizeWindowHint = 0x02000000,
WindowStaysOnBottomHint = 0x04000000,
WindowCloseButtonHint = 0x08000000,
@@ -308,56 +302,6 @@ public:
WindowCancelButtonHint = 0x00100000,
WindowSoftkeysVisibleHint = 0x40000000,
WindowSoftkeysRespondHint = 0x80000000
-
-#ifdef QT3_SUPPORT
- ,
- WMouseNoMask = 0x00080000,
- WDestructiveClose = 0x00100000,
- WStaticContents = 0x00200000,
- WGroupLeader = 0x00400000,
- WShowModal = 0x00800000,
- WNoMousePropagation = 0x01000000,
-
- WType_TopLevel = Window,
- WType_Dialog = Dialog,
- WType_Popup = Popup,
- WType_Desktop = Desktop,
- WType_Mask = WindowType_Mask,
-
- WStyle_Customize = 0,
- WStyle_NormalBorder = 0,
- WStyle_DialogBorder = MSWindowsFixedSizeDialogHint,
- WStyle_NoBorder = FramelessWindowHint,
- WStyle_Title = WindowTitleHint,
- WStyle_SysMenu = WindowSystemMenuHint,
- WStyle_Minimize = WindowMinimizeButtonHint,
- WStyle_Maximize = WindowMaximizeButtonHint,
- WStyle_MinMax = WStyle_Minimize | WStyle_Maximize,
- WStyle_Tool = Tool,
- WStyle_StaysOnTop = WindowStaysOnTopHint,
- WStyle_ContextHelp = WindowContextHelpButtonHint,
-
- // misc flags
- WPaintDesktop = 0,
- WPaintClever = 0,
-
- WX11BypassWM = X11BypassWindowManagerHint,
- WWinOwnDC = MSWindowsOwnDC,
- WMacSheet = Sheet,
- WMacDrawer = Drawer,
-
- WStyle_Splash = SplashScreen,
-
- WNoAutoErase = 0,
- WRepaintNoErase = 0,
- WNorthWestGravity = WStaticContents,
- WType_Modal = Dialog | WShowModal,
- WStyle_Dialog = Dialog,
- WStyle_NoBorderEx = FramelessWindowHint,
- WResizeNoErase = 0,
- WMacNoSheet = 0
-#endif
-
};
Q_DECLARE_FLAGS(WindowFlags, WindowType)
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 902902f087..c323d44de7 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -596,23 +596,6 @@ void QCoreApplication::flush()
\a argc must be greater than zero and \a argv must contain at least
one valid character string.
*/
-QCoreApplication::QCoreApplication(int &argc, char **argv)
- : QObject(*new QCoreApplicationPrivate(argc, argv, 0x040000))
-{
- init();
- QCoreApplicationPrivate::eventDispatcher->startingUp();
-#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_LIBRARY)
- // Refresh factoryloader, as text codecs are requested during lib path
- // resolving process and won't be therefore properly loaded.
- // Unknown if this is symbian specific issue.
- QFactoryLoader::refreshAll();
-#endif
-
-#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE)
- d_func()->symbianInit();
-#endif
-}
-
QCoreApplication::QCoreApplication(int &argc, char **argv, int _internal)
: QObject(*new QCoreApplicationPrivate(argc, argv, _internal))
{
@@ -2203,7 +2186,6 @@ QStringList QCoreApplication::arguments()
;
else if (l1arg == "-style" ||
l1arg == "-session" ||
- l1arg == "-graphicssystem" ||
l1arg == "-testability")
++a;
else
diff --git a/src/corelib/kernel/qcoreapplication.h b/src/corelib/kernel/qcoreapplication.h
index 024c5096c9..929e4a9836 100644
--- a/src/corelib/kernel/qcoreapplication.h
+++ b/src/corelib/kernel/qcoreapplication.h
@@ -84,16 +84,7 @@ public:
#endif
};
-#if defined(QT_BUILD_CORE_LIB) || defined(qdoc)
- QCoreApplication(int &argc, char **argv); // ### Qt5 remove
-#endif
-#if !defined(qdoc)
- QCoreApplication(int &argc, char **argv, int
-#if !defined(QT_BUILD_CORE_LIB)
- = ApplicationFlags
-#endif
- );
-#endif
+ QCoreApplication(int &argc, char **argv, int = ApplicationFlags);
~QCoreApplication();
@@ -218,10 +209,13 @@ private:
friend class QEventDispatcherUNIXPrivate;
friend class QApplication;
friend class QApplicationPrivate;
+ friend class QGuiApplication;
+ friend class QGuiApplicationPrivate;
friend class QETWidget;
friend class Q3AccelManager;
friend class QShortcutMap;
friend class QWidget;
+ friend class QWidgetWindow;
friend class QWidgetPrivate;
friend bool qt_sendSpontaneousEvent(QObject*, QEvent*);
friend Q_CORE_EXPORT QString qAppName();
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index bdc96c638b..97afe5965a 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -265,19 +265,16 @@ static const struct { const char * typeName; int typeNameLength; int type; } typ
QT_ADD_STATIC_METATYPE("QEasingCurve", QMetaType::QEasingCurve),
/* All GUI types */
- QT_ADD_STATIC_METATYPE("QColorGroup", 63),
QT_ADD_STATIC_METATYPE("QFont", QMetaType::QFont),
QT_ADD_STATIC_METATYPE("QPixmap", QMetaType::QPixmap),
QT_ADD_STATIC_METATYPE("QBrush", QMetaType::QBrush),
QT_ADD_STATIC_METATYPE("QColor", QMetaType::QColor),
QT_ADD_STATIC_METATYPE("QPalette", QMetaType::QPalette),
- QT_ADD_STATIC_METATYPE("QIcon", QMetaType::QIcon),
QT_ADD_STATIC_METATYPE("QImage", QMetaType::QImage),
QT_ADD_STATIC_METATYPE("QPolygon", QMetaType::QPolygon),
QT_ADD_STATIC_METATYPE("QRegion", QMetaType::QRegion),
QT_ADD_STATIC_METATYPE("QBitmap", QMetaType::QBitmap),
QT_ADD_STATIC_METATYPE("QCursor", QMetaType::QCursor),
- QT_ADD_STATIC_METATYPE("QSizePolicy", QMetaType::QSizePolicy),
QT_ADD_STATIC_METATYPE("QKeySequence", QMetaType::QKeySequence),
QT_ADD_STATIC_METATYPE("QPen", QMetaType::QPen),
QT_ADD_STATIC_METATYPE("QTextLength", QMetaType::QTextLength),
@@ -290,6 +287,10 @@ static const struct { const char * typeName; int typeNameLength; int type; } typ
QT_ADD_STATIC_METATYPE("QVector4D", QMetaType::QVector4D),
QT_ADD_STATIC_METATYPE("QQuaternion", QMetaType::QQuaternion),
+ /* All Widgets types */
+ QT_ADD_STATIC_METATYPE("QIcon", QMetaType::QIcon),
+ QT_ADD_STATIC_METATYPE("QSizePolicy", QMetaType::QSizePolicy),
+
/* All Metatype builtins */
QT_ADD_STATIC_METATYPE("void*", QMetaType::VoidStar),
QT_ADD_STATIC_METATYPE("long", QMetaType::Long),
@@ -338,6 +339,7 @@ struct QMetaTypeGuiHelper
#endif
};
Q_CORE_EXPORT const QMetaTypeGuiHelper *qMetaTypeGuiHelper = 0;
+Q_CORE_EXPORT const QMetaTypeGuiHelper *qMetaTypeWidgetsHelper = 0;
class QCustomTypeInfo
{
@@ -399,14 +401,17 @@ void QMetaType::registerStreamOperators(int idx, SaveOperator saveOp,
*/
const char *QMetaType::typeName(int type)
{
- enum { GuiTypeCount = LastGuiType - FirstGuiType };
+ enum { GuiTypeCount = LastGuiType - FirstGuiType,
+ WidgetsTypeCount = LastWidgetsType - FirstWidgetsType };
if (type >= 0 && type <= LastCoreType) {
return types[type].typeName;
} else if (type >= FirstGuiType && type <= LastGuiType) {
return types[type - FirstGuiType + LastCoreType + 1].typeName;
+ } else if (type >= FirstWidgetsType && type <= LastWidgetsType) {
+ return types[type - FirstWidgetsType + GuiTypeCount + LastCoreType + 2].typeName;
} else if (type >= FirstCoreExtType && type <= LastCoreExtType) {
- return types[type - FirstCoreExtType + GuiTypeCount + LastCoreType + 2].typeName;
+ return types[type - FirstCoreExtType + GuiTypeCount + WidgetsTypeCount + LastCoreType + 3].typeName;
} else if (type >= User) {
const QVector<QCustomTypeInfo> * const ct = customTypes();
QReadLocker locker(customTypesLock());
@@ -768,13 +773,11 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data)
case QMetaType::QBrush:
case QMetaType::QColor:
case QMetaType::QPalette:
- case QMetaType::QIcon:
case QMetaType::QImage:
case QMetaType::QPolygon:
case QMetaType::QRegion:
case QMetaType::QBitmap:
case QMetaType::QCursor:
- case QMetaType::QSizePolicy:
case QMetaType::QKeySequence:
case QMetaType::QPen:
case QMetaType::QTextLength:
@@ -790,6 +793,12 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data)
return false;
qMetaTypeGuiHelper[type - FirstGuiType].saveOp(stream, data);
break;
+ case QMetaType::QIcon:
+ case QMetaType::QSizePolicy:
+ if (!qMetaTypeWidgetsHelper)
+ return false;
+ qMetaTypeWidgetsHelper[type - FirstWidgetsType].saveOp(stream, data);
+ break;
default: {
const QVector<QCustomTypeInfo> * const ct = customTypes();
if (!ct)
@@ -973,13 +982,11 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
case QMetaType::QBrush:
case QMetaType::QColor:
case QMetaType::QPalette:
- case QMetaType::QIcon:
case QMetaType::QImage:
case QMetaType::QPolygon:
case QMetaType::QRegion:
case QMetaType::QBitmap:
case QMetaType::QCursor:
- case QMetaType::QSizePolicy:
case QMetaType::QKeySequence:
case QMetaType::QPen:
case QMetaType::QTextLength:
@@ -995,6 +1002,12 @@ bool QMetaType::load(QDataStream &stream, int type, void *data)
return false;
qMetaTypeGuiHelper[type - FirstGuiType].loadOp(stream, data);
break;
+ case QMetaType::QIcon:
+ case QMetaType::QSizePolicy:
+ if (!qMetaTypeWidgetsHelper)
+ return false;
+ qMetaTypeWidgetsHelper[type - FirstWidgetsType].loadOp(stream, data);
+ break;
default: {
const QVector<QCustomTypeInfo> * const ct = customTypes();
if (!ct)
@@ -1224,6 +1237,10 @@ void *QMetaType::construct(int type, const void *copy)
if (!qMetaTypeGuiHelper)
return 0;
constr = qMetaTypeGuiHelper[type - FirstGuiType].constr;
+ } else if (type >= FirstWidgetsType && type <= LastWidgetsType) {
+ if (!qMetaTypeWidgetsHelper)
+ return 0;
+ constr = qMetaTypeWidgetsHelper[type - FirstWidgetsType].constr;
} else {
const QVector<QCustomTypeInfo> * const ct = customTypes();
QReadLocker locker(customTypesLock());
@@ -1386,6 +1403,12 @@ void QMetaType::destroy(int type, void *data)
if (!qMetaTypeGuiHelper)
return;
destr = qMetaTypeGuiHelper[type - FirstGuiType].destr;
+ } else if (type >= FirstWidgetsType && type <= LastWidgetsType) {
+ Q_ASSERT(qMetaTypeWidgetsHelper);
+
+ if (!qMetaTypeWidgetsHelper)
+ return;
+ destr = qMetaTypeWidgetsHelper[type - FirstWidgetsType].destr;
} else {
QReadLocker locker(customTypesLock());
if (type < User || !ct || ct->count() <= type - User)
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index a2bb7d1597..8e7848aef0 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -71,18 +71,19 @@ public:
QLine = 23, QLineF = 24, QPoint = 25, QPointF = 26, QRegExp = 27,
QVariantHash = 28, QEasingCurve = 29, LastCoreType = QEasingCurve,
- FirstGuiType = 63 /* QColorGroup */,
-#ifdef QT3_SUPPORT
- QColorGroup = 63,
-#endif
+ FirstGuiType = 64 /* QFont */,
QFont = 64, QPixmap = 65, QBrush = 66, QColor = 67, QPalette = 68,
- QIcon = 69, QImage = 70, QPolygon = 71, QRegion = 72, QBitmap = 73,
- QCursor = 74, QSizePolicy = 75, QKeySequence = 76, QPen = 77,
- QTextLength = 78, QTextFormat = 79, QMatrix = 80, QTransform = 81,
- QMatrix4x4 = 82, QVector2D = 83, QVector3D = 84, QVector4D = 85,
- QQuaternion = 86,
+ QImage = 69, QPolygon = 70, QRegion = 71, QBitmap = 72,
+ QCursor = 73, QKeySequence = 74, QPen = 75,
+ QTextLength = 76, QTextFormat = 77, QMatrix = 78, QTransform = 79,
+ QMatrix4x4 = 80, QVector2D = 81, QVector3D = 82, QVector4D = 83,
+ QQuaternion = 84,
LastGuiType = QQuaternion,
+ FirstWidgetsType = 120, /* QIcon */
+ QIcon = 120, QSizePolicy = 121,
+ LastWidgetsType = QSizePolicy,
+
FirstCoreExtType = 128 /* VoidStar */,
VoidStar = 128, Long = 129, Short = 130, Char = 131, ULong = 132,
UShort = 133, UChar = 134, Float = 135, QObjectStar = 136, QWidgetStar = 137,
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 357cfd3f33..9f3c63c588 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -157,6 +157,7 @@ QObjectPrivate::QObjectPrivate(int version)
#endif
metaObject = 0;
hasGuards = false;
+ isWindow = false;
}
QObjectPrivate::~QObjectPrivate()
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index 0ad73f5fe9..be2f5cbf6e 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -102,7 +102,8 @@ public:
uint inEventHandler : 1; //only used if QT_JAMBI_BUILD
uint inThreadChangeEvent : 1;
uint hasGuards : 1; //true iff there is one or more QPointer attached to this object
- uint unused : 22;
+ uint isWindow : 1; //for QWindow
+ uint unused : 21;
int postedEvents;
QMetaObject *metaObject; // assert dynamic
};
@@ -144,6 +145,7 @@ public:
void setObjectName(const QString &name);
inline bool isWidgetType() const { return d_ptr->isWidget; }
+ inline bool isWindowType() const { return d_ptr->isWindow; }
inline bool signalsBlocked() const { return d_ptr->blockSig; }
bool blockSignals(bool b);
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index 1b8cb7fd0b..345272ee36 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -127,40 +127,33 @@ class Q_CORE_EXPORT QVariant
LastCoreType = EasingCurve,
// value 62 is internally reserved
-#ifdef QT3_SUPPORT
- ColorGroup = 63,
-#endif
Font = 64,
Pixmap = 65,
Brush = 66,
Color = 67,
Palette = 68,
- Icon = 69,
- Image = 70,
- Polygon = 71,
- Region = 72,
- Bitmap = 73,
- Cursor = 74,
- SizePolicy = 75,
- KeySequence = 76,
- Pen = 77,
- TextLength = 78,
- TextFormat = 79,
- Matrix = 80,
- Transform = 81,
- Matrix4x4 = 82,
- Vector2D = 83,
- Vector3D = 84,
- Vector4D = 85,
- Quaternion = 86,
+ Image = 69,
+ Polygon = 70,
+ Region = 71,
+ Bitmap = 72,
+ Cursor = 73,
+ KeySequence = 74,
+ Pen = 75,
+ TextLength = 76,
+ TextFormat = 77,
+ Matrix = 78,
+ Transform = 79,
+ Matrix4x4 = 80,
+ Vector2D = 81,
+ Vector3D = 82,
+ Vector4D = 83,
+ Quaternion = 84,
LastGuiType = Quaternion,
+ Icon = 120,
+ SizePolicy = 121,
+
UserType = 127,
-#ifdef QT3_SUPPORT
- IconSet = Icon,
- CString = ByteArray,
- PointArray = Polygon,
-#endif
LastType = 0xffffffff // need this so that gcc >= 3.4 allocates 32 bits for Type
};
diff --git a/src/gui/accessible/accessible.pri b/src/gui/accessible/accessible.pri
deleted file mode 100644
index 31362ffded..0000000000
--- a/src/gui/accessible/accessible.pri
+++ /dev/null
@@ -1,25 +0,0 @@
-# Qt accessibility module
-
-contains(QT_CONFIG, accessibility) {
- HEADERS += accessible/qaccessible.h \
- accessible/qaccessible2.h \
- accessible/qaccessibleobject.h \
- accessible/qaccessiblewidget.h \
- accessible/qaccessibleplugin.h
- SOURCES += accessible/qaccessible.cpp \
- accessible/qaccessible2.cpp \
- accessible/qaccessibleobject.cpp \
- accessible/qaccessiblewidget.cpp \
- accessible/qaccessibleplugin.cpp
-
- mac:!embedded:!qpa {
- HEADERS += accessible/qaccessible_mac_p.h
- OBJECTIVE_SOURCES += accessible/qaccessible_mac.mm \
- accessible/qaccessible_mac_cocoa.mm
- } else:win32 {
- SOURCES += accessible/qaccessible_win.cpp
- } else {
- HEADERS += accessible/qaccessiblebridge.h
- SOURCES += accessible/qaccessible_unix.cpp accessible/qaccessiblebridge.cpp
- }
-}
diff --git a/src/gui/accessible/qaccessible.h b/src/gui/accessible/qaccessible.h
deleted file mode 100644
index 871ca58995..0000000000
--- a/src/gui/accessible/qaccessible.h
+++ /dev/null
@@ -1,464 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QACCESSIBLE_H
-#define QACCESSIBLE_H
-
-#include <QtCore/qglobal.h>
-#include <QtCore/qobject.h>
-#include <QtCore/qrect.h>
-#include <QtCore/qset.h>
-#include <QtCore/qvector.h>
-#include <QtCore/qvariant.h>
-#include <QtGui/qcolor.h>
-#include <QtGui/qevent.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_ACCESSIBILITY
-
-class QAccessibleInterface;
-
-class Q_GUI_EXPORT QAccessible
-{
-public:
- enum Event {
- SoundPlayed = 0x0001,
- Alert = 0x0002,
- ForegroundChanged = 0x0003,
- MenuStart = 0x0004,
- MenuEnd = 0x0005,
- PopupMenuStart = 0x0006,
- PopupMenuEnd = 0x0007,
- ContextHelpStart = 0x000C,
- ContextHelpEnd = 0x000D,
- DragDropStart = 0x000E,
- DragDropEnd = 0x000F,
- DialogStart = 0x0010,
- DialogEnd = 0x0011,
- ScrollingStart = 0x0012,
- ScrollingEnd = 0x0013,
-
- MenuCommand = 0x0018,
-
- // Values from IAccessible2
- ActionChanged = 0x0101,
- ActiveDescendantChanged,
- AttributeChanged,
- DocumentContentChanged,
- DocumentLoadComplete,
- DocumentLoadStopped,
- DocumentReload,
- HyperlinkEndIndexChanged,
- HyperlinkNumberOfAnchorsChanged,
- HyperlinkSelectedLinkChanged,
- HypertextLinkActivated,
- HypertextLinkSelected,
- HyperlinkStartIndexChanged,
- HypertextChanged,
- HypertextNLinksChanged,
- ObjectAttributeChanged,
- PageChanged,
- SectionChanged,
- TableCaptionChanged,
- TableColumnDescriptionChanged,
- TableColumnHeaderChanged,
- TableModelChanged,
- TableRowDescriptionChanged,
- TableRowHeaderChanged,
- TableSummaryChanged,
- TextAttributeChanged,
- TextCaretMoved,
- TextChanged,
- TextColumnChanged,
- TextInserted,
- TextRemoved,
- TextUpdated,
- TextSelectionChanged,
- VisibleDataChanged,
-
- ObjectCreated = 0x8000,
- ObjectDestroyed = 0x8001,
- ObjectShow = 0x8002,
- ObjectHide = 0x8003,
- ObjectReorder = 0x8004,
- Focus = 0x8005,
- Selection = 0x8006,
- SelectionAdd = 0x8007,
- SelectionRemove = 0x8008,
- SelectionWithin = 0x8009,
- StateChanged = 0x800A,
- LocationChanged = 0x800B,
- NameChanged = 0x800C,
- DescriptionChanged = 0x800D,
- ValueChanged = 0x800E,
- ParentChanged = 0x800F,
- HelpChanged = 0x80A0,
- DefaultActionChanged = 0x80B0,
- AcceleratorChanged = 0x80C0
- };
-
- enum StateFlag {
- Normal = 0x00000000,
- Unavailable = 0x00000001,
- Selected = 0x00000002,
- Focused = 0x00000004,
- Pressed = 0x00000008,
- Checked = 0x00000010,
- Mixed = 0x00000020,
- ReadOnly = 0x00000040,
- HotTracked = 0x00000080,
- DefaultButton = 0x00000100,
- Expanded = 0x00000200,
- Collapsed = 0x00000400,
- Busy = 0x00000800,
- // Floating = 0x00001000,
- Marqueed = 0x00002000,
- Animated = 0x00004000,
- Invisible = 0x00008000,
- Offscreen = 0x00010000,
- Sizeable = 0x00020000,
- Movable = 0x00040000,
-#ifdef QT3_SUPPORT
- Moveable = Movable,
-#endif
- SelfVoicing = 0x00080000,
- Focusable = 0x00100000,
- Selectable = 0x00200000,
- Linked = 0x00400000,
- Traversed = 0x00800000,
- MultiSelectable = 0x01000000,
- ExtSelectable = 0x02000000,
- //AlertLow = 0x04000000,
- //AlertMedium = 0x08000000,
- //AlertHigh = 0x10000000, /* reused for HasInvokeExtension */
- Protected = 0x20000000,
- HasPopup = 0x40000000,
- Modal = 0x80000000,
-
- HasInvokeExtension = 0x10000000 // internal
- };
- Q_DECLARE_FLAGS(State, StateFlag)
-
- enum Role {
- NoRole = 0x00000000,
- TitleBar = 0x00000001,
- MenuBar = 0x00000002,
- ScrollBar = 0x00000003,
- Grip = 0x00000004,
- Sound = 0x00000005,
- Cursor = 0x00000006,
- Caret = 0x00000007,
- AlertMessage = 0x00000008,
- Window = 0x00000009,
- Client = 0x0000000A,
- PopupMenu = 0x0000000B,
- MenuItem = 0x0000000C,
- ToolTip = 0x0000000D,
- Application = 0x0000000E,
- Document = 0x0000000F,
- Pane = 0x00000010,
- Chart = 0x00000011,
- Dialog = 0x00000012,
- Border = 0x00000013,
- Grouping = 0x00000014,
- Separator = 0x00000015,
- ToolBar = 0x00000016,
- StatusBar = 0x00000017,
- Table = 0x00000018,
- ColumnHeader = 0x00000019,
- RowHeader = 0x0000001A,
- Column = 0x0000001B,
- Row = 0x0000001C,
- Cell = 0x0000001D,
- Link = 0x0000001E,
- HelpBalloon = 0x0000001F,
- Assistant = 0x00000020,
- List = 0x00000021,
- ListItem = 0x00000022,
- Tree = 0x00000023,
- TreeItem = 0x00000024,
- PageTab = 0x00000025,
- PropertyPage = 0x00000026,
- Indicator = 0x00000027,
- Graphic = 0x00000028,
- StaticText = 0x00000029,
- EditableText = 0x0000002A, // Editable, selectable, etc.
- PushButton = 0x0000002B,
- CheckBox = 0x0000002C,
- RadioButton = 0x0000002D,
- ComboBox = 0x0000002E,
- // DropList = 0x0000002F,
- ProgressBar = 0x00000030,
- Dial = 0x00000031,
- HotkeyField = 0x00000032,
- Slider = 0x00000033,
- SpinBox = 0x00000034,
- Canvas = 0x00000035,
- Animation = 0x00000036,
- Equation = 0x00000037,
- ButtonDropDown = 0x00000038,
- ButtonMenu = 0x00000039,
- ButtonDropGrid = 0x0000003A,
- Whitespace = 0x0000003B,
- PageTabList = 0x0000003C,
- Clock = 0x0000003D,
- Splitter = 0x0000003E,
- // Additional Qt roles where enum value does not map directly to MSAA:
- LayeredPane = 0x0000003F,
- UserRole = 0x0000ffff
- };
-
- enum Text {
- Name = 0,
- Description,
- Value,
- Help,
- Accelerator,
- UserText = 0x0000ffff
- };
-
- enum RelationFlag {
- Unrelated = 0x00000000,
- Self = 0x00000001,
- Ancestor = 0x00000002,
- Child = 0x00000004,
- Descendent = 0x00000008,
- Sibling = 0x00000010,
- HierarchyMask = 0x000000ff,
-
- Up = 0x00000100,
- Down = 0x00000200,
- Left = 0x00000400,
- Right = 0x00000800,
- Covers = 0x00001000,
- Covered = 0x00002000,
- GeometryMask = 0x0000ff00,
-
- FocusChild = 0x00010000,
- Label = 0x00020000,
- Labelled = 0x00040000,
- Controller = 0x00080000,
- Controlled = 0x00100000,
- LogicalMask = 0x00ff0000
- };
- Q_DECLARE_FLAGS(Relation, RelationFlag)
-
- enum Action {
- DefaultAction = 0,
- Press = -1,
- FirstStandardAction = Press,
- SetFocus = -2,
- Increase = -3,
- Decrease = -4,
- Accept = -5,
- Cancel = -6,
- Select = -7,
- ClearSelection = -8,
- RemoveSelection = -9,
- ExtendSelection = -10,
- AddToSelection = -11,
- LastStandardAction = AddToSelection
- };
-
- enum Method {
- ListSupportedMethods = 0,
- SetCursorPosition = 1,
- GetCursorPosition = 2,
- ForegroundColor = 3,
- BackgroundColor = 4
- };
-
- typedef QAccessibleInterface*(*InterfaceFactory)(const QString &key, QObject*);
- typedef void(*UpdateHandler)(QObject*, int who, Event reason);
- typedef void(*RootObjectHandler)(QObject*);
-
- static void installFactory(InterfaceFactory);
- static void removeFactory(InterfaceFactory);
- static UpdateHandler installUpdateHandler(UpdateHandler);
- static RootObjectHandler installRootObjectHandler(RootObjectHandler);
-
- static QAccessibleInterface *queryAccessibleInterface(QObject *);
- static void updateAccessibility(QObject *, int who, Event reason);
- static bool isActive();
- static void setRootObject(QObject*);
-
- static void initialize();
- static void cleanup();
-
-private:
- static UpdateHandler updateHandler;
- static RootObjectHandler rootObjectHandler;
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QAccessible::State)
-Q_DECLARE_OPERATORS_FOR_FLAGS(QAccessible::Relation)
-QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QSet<QAccessible::Method>)
-QT_BEGIN_NAMESPACE
-
-namespace QAccessible2
-{
- enum InterfaceType
- {
- TextInterface,
- EditableTextInterface,
- ValueInterface,
- TableInterface,
- ActionInterface,
- ImageInterface
- };
-}
-
-class QAccessible2Interface;
-class QAccessibleTextInterface;
-class QAccessibleEditableTextInterface;
-class QAccessibleValueInterface;
-class QAccessibleTableInterface;
-class QAccessibleActionInterface;
-class QAccessibleImageInterface;
-
-class Q_GUI_EXPORT QAccessibleInterface : public QAccessible
-{
-public:
- virtual ~QAccessibleInterface() {}
- // check for valid pointers
- virtual bool isValid() const = 0;
- virtual QObject *object() const = 0;
-
- // hierarchy
- virtual int childCount() const = 0;
- virtual int indexOfChild(const QAccessibleInterface *) const = 0;
-
- // relations
- virtual Relation relationTo(int child, const QAccessibleInterface *other,
- int otherChild) const = 0;
- virtual int childAt(int x, int y) const = 0;
-
- // navigation
- virtual int navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const = 0;
-
- // properties and state
- virtual QString text(Text t, int child) const = 0;
- virtual void setText(Text t, int child, const QString &text) = 0;
- virtual QRect rect(int child) const = 0;
- virtual Role role(int child) const = 0;
- virtual State state(int child) const = 0;
-
- // action
- virtual int userActionCount(int child) const = 0;
- virtual QString actionText(int action, Text t, int child) const = 0;
- virtual bool doAction(int action, int child, const QVariantList &params = QVariantList()) = 0;
-
- QVariant invokeMethod(Method method, int child = 0,
- const QVariantList &params = QVariantList());
-
- inline QSet<Method> supportedMethods()
- { return qvariant_cast<QSet<Method> >(invokeMethod(ListSupportedMethods)); }
-
- inline QColor foregroundColor()
- { return qvariant_cast<QColor>(invokeMethod(ForegroundColor)); }
-
- inline QColor backgroundColor()
- { return qvariant_cast<QColor>(invokeMethod(BackgroundColor)); }
-
- inline QAccessibleTextInterface *textInterface()
- { return reinterpret_cast<QAccessibleTextInterface *>(cast_helper(QAccessible2::TextInterface)); }
-
- inline QAccessibleEditableTextInterface *editableTextInterface()
- { return reinterpret_cast<QAccessibleEditableTextInterface *>(cast_helper(QAccessible2::EditableTextInterface)); }
-
- inline QAccessibleValueInterface *valueInterface()
- { return reinterpret_cast<QAccessibleValueInterface *>(cast_helper(QAccessible2::ValueInterface)); }
-
- inline QAccessibleTableInterface *tableInterface()
- { return reinterpret_cast<QAccessibleTableInterface *>(cast_helper(QAccessible2::TableInterface)); }
-
- inline QAccessibleActionInterface *actionInterface()
- { return reinterpret_cast<QAccessibleActionInterface *>(cast_helper(QAccessible2::ActionInterface)); }
-
- inline QAccessibleImageInterface *imageInterface()
- { return reinterpret_cast<QAccessibleImageInterface *>(cast_helper(QAccessible2::ImageInterface)); }
-
-private:
- QAccessible2Interface *cast_helper(QAccessible2::InterfaceType);
-};
-
-class Q_GUI_EXPORT QAccessibleInterfaceEx: public QAccessibleInterface
-{
-public:
- virtual QVariant invokeMethodEx(Method method, int child, const QVariantList &params) = 0;
- virtual QVariant virtual_hook(const QVariant &data);
- virtual QAccessible2Interface *interface_cast(QAccessible2::InterfaceType)
- { return 0; }
-};
-
-
-class Q_GUI_EXPORT QAccessibleEvent : public QEvent
-{
-public:
- inline QAccessibleEvent(Type type, int child);
- inline int child() const { return c; }
- inline QString value() const { return val; }
- inline void setValue(const QString &aText) { val = aText; }
-
-private:
- int c;
- QString val;
-};
-
-inline QAccessibleEvent::QAccessibleEvent(Type atype, int achild)
- : QEvent(atype), c(achild) {}
-
-#define QAccessibleInterface_iid "com.trolltech.Qt.QAccessibleInterface"
-Q_DECLARE_INTERFACE(QAccessibleInterface, QAccessibleInterface_iid)
-
-#endif // QT_NO_ACCESSIBILITY
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QACCESSIBLE_H
diff --git a/src/gui/accessible/qaccessible2.h b/src/gui/accessible/qaccessible2.h
deleted file mode 100644
index 65ab7166c6..0000000000
--- a/src/gui/accessible/qaccessible2.h
+++ /dev/null
@@ -1,246 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QACCESSIBLE2_H
-#define QACCESSIBLE2_H
-
-#include <QtGui/qaccessible.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_ACCESSIBILITY
-
-namespace QAccessible2
-{
- enum CoordinateType
- {
- RelativeToScreen = 0,
- RelativeToParent = 1
- };
-
- enum BoundaryType {
- CharBoundary,
- WordBoundary,
- SentenceBoundary,
- ParagraphBoundary,
- LineBoundary,
- NoBoundary
- };
-}
-
-class Q_GUI_EXPORT QAccessible2Interface
-{
-public:
- virtual ~QAccessible2Interface() {}
-};
-
-// catch-all functions. If an accessible class doesn't implement interface T, return 0
-inline QAccessible2Interface *qAccessibleValueCastHelper() { return 0; }
-inline QAccessible2Interface *qAccessibleTextCastHelper() { return 0; }
-inline QAccessible2Interface *qAccessibleEditableTextCastHelper() { return 0; }
-inline QAccessible2Interface *qAccessibleTableCastHelper() { return 0; }
-inline QAccessible2Interface *qAccessibleActionCastHelper() { return 0; }
-inline QAccessible2Interface *qAccessibleImageCastHelper() { return 0; }
-
-#define Q_ACCESSIBLE_OBJECT \
- public: \
- QAccessible2Interface *interface_cast(QAccessible2::InterfaceType t) \
- { \
- switch (t) { \
- case QAccessible2::TextInterface: \
- return qAccessibleTextCastHelper(); \
- case QAccessible2::EditableTextInterface: \
- return qAccessibleEditableTextCastHelper(); \
- case QAccessible2::ValueInterface: \
- return qAccessibleValueCastHelper(); \
- case QAccessible2::TableInterface: \
- return qAccessibleTableCastHelper(); \
- case QAccessible2::ActionInterface: \
- return qAccessibleActionCastHelper(); \
- case QAccessible2::ImageInterface: \
- return qAccessibleImageCastHelper(); \
- } \
- return 0; \
- } \
- private:
-
-class Q_GUI_EXPORT QAccessibleTextInterface: public QAccessible2Interface
-{
-public:
- inline QAccessible2Interface *qAccessibleTextCastHelper() { return this; }
-
- virtual ~QAccessibleTextInterface() {}
-
- virtual void addSelection(int startOffset, int endOffset) = 0;
- virtual QString attributes(int offset, int *startOffset, int *endOffset) = 0;
- virtual int cursorPosition() = 0;
- virtual QRect characterRect(int offset, QAccessible2::CoordinateType coordType) = 0;
- virtual int selectionCount() = 0;
- virtual int offsetAtPoint(const QPoint &point, QAccessible2::CoordinateType coordType) = 0;
- virtual void selection(int selectionIndex, int *startOffset, int *endOffset) = 0;
- virtual QString text(int startOffset, int endOffset) = 0;
- virtual QString textBeforeOffset (int offset, QAccessible2::BoundaryType boundaryType,
- int *startOffset, int *endOffset) = 0;
- virtual QString textAfterOffset(int offset, QAccessible2::BoundaryType boundaryType,
- int *startOffset, int *endOffset) = 0;
- virtual QString textAtOffset(int offset, QAccessible2::BoundaryType boundaryType,
- int *startOffset, int *endOffset) = 0;
- virtual void removeSelection(int selectionIndex) = 0;
- virtual void setCursorPosition(int position) = 0;
- virtual void setSelection(int selectionIndex, int startOffset, int endOffset) = 0;
- virtual int characterCount() = 0;
- virtual void scrollToSubstring(int startIndex, int endIndex) = 0;
-};
-
-class Q_GUI_EXPORT QAccessibleEditableTextInterface: public QAccessible2Interface
-{
-public:
- inline QAccessible2Interface *qAccessibleEditableTextCastHelper() { return this; }
-
- virtual ~QAccessibleEditableTextInterface() {}
-
- virtual void copyText(int startOffset, int endOffset) = 0;
- virtual void deleteText(int startOffset, int endOffset) = 0;
- virtual void insertText(int offset, const QString &text) = 0;
- virtual void cutText(int startOffset, int endOffset) = 0;
- virtual void pasteText(int offset) = 0;
- virtual void replaceText(int startOffset, int endOffset, const QString &text) = 0;
- virtual void setAttributes(int startOffset, int endOffset, const QString &attributes) = 0;
-};
-
-class Q_GUI_EXPORT QAccessibleSimpleEditableTextInterface: public QAccessibleEditableTextInterface
-{
-public:
- QAccessibleSimpleEditableTextInterface(QAccessibleInterface *accessibleInterface);
-
- void copyText(int startOffset, int endOffset);
- void deleteText(int startOffset, int endOffset);
- void insertText(int offset, const QString &text);
- void cutText(int startOffset, int endOffset);
- void pasteText(int offset);
- void replaceText(int startOffset, int endOffset, const QString &text);
- inline void setAttributes(int, int, const QString &) {}
-
-private:
- QAccessibleInterface *iface;
-};
-
-class Q_GUI_EXPORT QAccessibleValueInterface: public QAccessible2Interface
-{
-public:
- inline QAccessible2Interface *qAccessibleValueCastHelper() { return this; }
-
- virtual ~QAccessibleValueInterface() {}
-
- virtual QVariant currentValue() = 0;
- virtual void setCurrentValue(const QVariant &value) = 0;
- virtual QVariant maximumValue() = 0;
- virtual QVariant minimumValue() = 0;
-};
-
-class Q_GUI_EXPORT QAccessibleTableInterface: public QAccessible2Interface
-{
-public:
- inline QAccessible2Interface *qAccessibleTableCastHelper() { return this; }
-
- virtual QAccessibleInterface *accessibleAt(int row, int column) = 0;
- virtual QAccessibleInterface *caption() = 0;
- virtual int childIndex(int rowIndex, int columnIndex) = 0;
- virtual QString columnDescription(int column) = 0;
- virtual int columnSpan(int row, int column) = 0;
- virtual QAccessibleInterface *columnHeader() = 0;
- virtual int columnIndex(int childIndex) = 0;
- virtual int columnCount() = 0;
- virtual int rowCount() = 0;
- virtual int selectedColumnCount() = 0;
- virtual int selectedRowCount() = 0;
- virtual QString rowDescription(int row) = 0;
- virtual int rowSpan(int row, int column) = 0;
- virtual QAccessibleInterface *rowHeader() = 0;
- virtual int rowIndex(int childIndex) = 0;
- virtual int selectedRows(int maxRows, QList<int> *rows) = 0;
- virtual int selectedColumns(int maxColumns, QList<int> *columns) = 0;
- virtual QAccessibleInterface *summary() = 0;
- virtual bool isColumnSelected(int column) = 0;
- virtual bool isRowSelected(int row) = 0;
- virtual bool isSelected(int row, int column) = 0;
- virtual void selectRow(int row) = 0;
- virtual void selectColumn(int column) = 0;
- virtual void unselectRow(int row) = 0;
- virtual void unselectColumn(int column) = 0;
- virtual void cellAtIndex(int index, int *row, int *column, int *rowSpan,
- int *columnSpan, bool *isSelected) = 0;
-};
-
-class Q_GUI_EXPORT QAccessibleActionInterface : public QAccessible2Interface
-{
-public:
- inline QAccessible2Interface *qAccessibleActionCastHelper() { return this; }
-
- virtual int actionCount() = 0;
- virtual void doAction(int actionIndex) = 0;
- virtual QString description(int actionIndex) = 0;
- virtual QString name(int actionIndex) = 0;
- virtual QString localizedName(int actionIndex) = 0;
- virtual QStringList keyBindings(int actionIndex) = 0;
-};
-
-class Q_GUI_EXPORT QAccessibleImageInterface : public QAccessible2Interface
-{
-public:
- inline QAccessible2Interface *qAccessibleImageCastHelper() { return this; }
-
- virtual QString imageDescription() = 0;
- virtual QSize imageSize() = 0;
- virtual QRect imagePosition(QAccessible2::CoordinateType coordType) = 0;
-};
-
-#endif // QT_NO_ACCESSIBILITY
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/gui/accessible/qaccessibleobject.h b/src/gui/accessible/qaccessibleobject.h
deleted file mode 100644
index 0eb9399028..0000000000
--- a/src/gui/accessible/qaccessibleobject.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QACCESSIBLEOBJECT_H
-#define QACCESSIBLEOBJECT_H
-
-#include <QtGui/qaccessible.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_ACCESSIBILITY
-
-class QAccessibleObjectPrivate;
-class QObject;
-
-class Q_GUI_EXPORT QAccessibleObject : public QAccessibleInterface
-{
-public:
- explicit QAccessibleObject(QObject *object);
-
- bool isValid() const;
- QObject *object() const;
-
- // properties
- QRect rect(int child) const;
- void setText(Text t, int child, const QString &text);
-
- // actions
- int userActionCount(int child) const;
- bool doAction(int action, int child, const QVariantList &params);
- QString actionText(int action, Text t, int child) const;
-
-protected:
- virtual ~QAccessibleObject();
-
-private:
- friend class QAccessibleObjectEx;
- QAccessibleObjectPrivate *d;
- Q_DISABLE_COPY(QAccessibleObject)
-};
-
-class Q_GUI_EXPORT QAccessibleObjectEx : public QAccessibleInterfaceEx
-{
-public:
- explicit QAccessibleObjectEx(QObject *object);
-
- bool isValid() const;
- QObject *object() const;
-
- // properties
- QRect rect(int child) const;
- void setText(Text t, int child, const QString &text);
-
- // actions
- int userActionCount(int child) const;
- bool doAction(int action, int child, const QVariantList &params);
- QString actionText(int action, Text t, int child) const;
-
-protected:
- virtual ~QAccessibleObjectEx();
-
-private:
- QAccessibleObjectPrivate *d;
- Q_DISABLE_COPY(QAccessibleObjectEx)
-};
-
-class Q_GUI_EXPORT QAccessibleApplication : public QAccessibleObject
-{
-public:
- QAccessibleApplication();
-
- // relations
- int childCount() const;
- int indexOfChild(const QAccessibleInterface*) const;
- Relation relationTo(int, const QAccessibleInterface *, int) const;
-
- // navigation
- int childAt(int x, int y) const;
- int navigate(RelationFlag, int, QAccessibleInterface **) const;
-
- // properties and state
- QString text(Text t, int child) const;
- Role role(int child) const;
- State state(int child) const;
-
- // actions
- int userActionCount(int child) const;
- bool doAction(int action, int child, const QVariantList &params);
- QString actionText(int action, Text t, int child) const;
-};
-
-#endif // QT_NO_ACCESSIBILITY
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QACCESSIBLEOBJECT_H
diff --git a/src/gui/accessible/qaccessibleplugin.h b/src/gui/accessible/qaccessibleplugin.h
deleted file mode 100644
index dcf794e752..0000000000
--- a/src/gui/accessible/qaccessibleplugin.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QACCESSIBLEPLUGIN_H
-#define QACCESSIBLEPLUGIN_H
-
-#include <QtGui/qaccessible.h>
-#include <QtCore/qfactoryinterface.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_ACCESSIBILITY
-
-class QStringList;
-class QAccessibleInterface;
-
-struct Q_GUI_EXPORT QAccessibleFactoryInterface : public QAccessible, public QFactoryInterface
-{
- virtual QAccessibleInterface* create(const QString &key, QObject *object) = 0;
-};
-
-#define QAccessibleFactoryInterface_iid "com.trolltech.Qt.QAccessibleFactoryInterface"
-Q_DECLARE_INTERFACE(QAccessibleFactoryInterface, QAccessibleFactoryInterface_iid)
-
-class QAccessiblePluginPrivate;
-
-class Q_GUI_EXPORT QAccessiblePlugin : public QObject, public QAccessibleFactoryInterface
-{
- Q_OBJECT
- Q_INTERFACES(QAccessibleFactoryInterface:QFactoryInterface)
-public:
- explicit QAccessiblePlugin(QObject *parent = 0);
- ~QAccessiblePlugin();
-
- virtual QStringList keys() const = 0;
- virtual QAccessibleInterface *create(const QString &key, QObject *object) = 0;
-};
-
-#endif // QT_NO_ACCESSIBILITY
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QACCESSIBLEPLUGIN_H
diff --git a/src/gui/accessible/qaccessiblewidget.cpp b/src/gui/accessible/qaccessiblewidget.cpp
deleted file mode 100644
index 2b2cec0f02..0000000000
--- a/src/gui/accessible/qaccessiblewidget.cpp
+++ /dev/null
@@ -1,1031 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qaccessiblewidget.h"
-
-#ifndef QT_NO_ACCESSIBILITY
-
-#include "qaction.h"
-#include "qapplication.h"
-#include "qgroupbox.h"
-#include "qlabel.h"
-#include "qtooltip.h"
-#include "qwhatsthis.h"
-#include "qwidget.h"
-#include "qdebug.h"
-#include <qmath.h>
-#include <QRubberBand>
-#include <QtGui/QFocusFrame>
-#include <QtGui/QMenu>
-
-QT_BEGIN_NAMESPACE
-
-static QList<QWidget*> childWidgets(const QWidget *widget)
-{
- QList<QObject*> list = widget->children();
- QList<QWidget*> widgets;
- for (int i = 0; i < list.size(); ++i) {
- QWidget *w = qobject_cast<QWidget *>(list.at(i));
- if (w && !w->isWindow()
- && !qobject_cast<QFocusFrame*>(w)
-#if !defined(QT_NO_MENU)
- && !qobject_cast<QMenu*>(w)
-#endif
- && w->objectName() != QLatin1String("qt_rubberband"))
- widgets.append(w);
- }
- return widgets;
-}
-
-static QString buddyString(const QWidget *widget)
-{
- if (!widget)
- return QString();
- QWidget *parent = widget->parentWidget();
- if (!parent)
- return QString();
-#ifndef QT_NO_SHORTCUT
- QObjectList ol = parent->children();
- for (int i = 0; i < ol.size(); ++i) {
- QLabel *label = qobject_cast<QLabel*>(ol.at(i));
- if (label && label->buddy() == widget)
- return label->text();
- }
-#endif
-
-#ifndef QT_NO_GROUPBOX
- QGroupBox *groupbox = qobject_cast<QGroupBox*>(parent);
- if (groupbox)
- return groupbox->title();
-#endif
-
- return QString();
-}
-
-QString Q_GUI_EXPORT qt_accStripAmp(const QString &text)
-{
- return QString(text).remove(QLatin1Char('&'));
-}
-
-QString Q_GUI_EXPORT qt_accHotKey(const QString &text)
-{
-#ifndef QT_NO_SHORTCUT
- if (text.isEmpty())
- return text;
-
- int fa = 0;
- QChar ac;
- while ((fa = text.indexOf(QLatin1Char('&'), fa)) != -1) {
- ++fa;
- if (fa < text.length()) {
- // ignore "&&"
- if (text.at(fa) == QLatin1Char('&')) {
- ++fa;
- continue;
- } else {
- ac = text.at(fa);
- break;
- }
- }
- }
- if (ac.isNull())
- return QString();
- return (QString)QKeySequence(Qt::ALT) + ac.toUpper();
-#else
- Q_UNUSED(text);
- return QString();
-#endif
-}
-
-class QAccessibleWidgetPrivate : public QAccessible
-{
-public:
- QAccessibleWidgetPrivate()
- :role(Client)
- {}
-
- Role role;
- QString name;
- QString description;
- QString value;
- QString help;
- QString accelerator;
- QStringList primarySignals;
- const QAccessibleInterface *asking;
-};
-
-/*!
- \class QAccessibleWidget
- \brief The QAccessibleWidget class implements the QAccessibleInterface for QWidgets.
-
- \ingroup accessibility
-
- This class is convenient to use as a base class for custom
- implementations of QAccessibleInterfaces that provide information
- about widget objects.
-
- The class provides functions to retrieve the parentObject() (the
- widget's parent widget), and the associated widget(). Controlling
- signals can be added with addControllingSignal(), and setters are
- provided for various aspects of the interface implementation, for
- example setValue(), setDescription(), setAccelerator(), and
- setHelp().
-
- \sa QAccessible, QAccessibleObject
-*/
-
-/*!
- Creates a QAccessibleWidget object for widget \a w.
- \a role and \a name are optional parameters that set the object's
- role and name properties.
-*/
-QAccessibleWidget::QAccessibleWidget(QWidget *w, Role role, const QString &name)
-: QAccessibleObject(w)
-{
- Q_ASSERT(widget());
- d = new QAccessibleWidgetPrivate();
- d->role = role;
- d->name = name;
- d->asking = 0;
-}
-
-/*!
- Destroys this object.
-*/
-QAccessibleWidget::~QAccessibleWidget()
-{
- delete d;
-}
-
-/*!
- Returns the associated widget.
-*/
-QWidget *QAccessibleWidget::widget() const
-{
- return qobject_cast<QWidget*>(object());
-}
-
-/*!
- Returns the associated widget's parent object, which is either the
- parent widget, or qApp for top-level widgets.
-*/
-QObject *QAccessibleWidget::parentObject() const
-{
- QObject *parent = object()->parent();
- if (!parent)
- parent = qApp;
- return parent;
-}
-
-/*! \reimp */
-int QAccessibleWidget::childAt(int x, int y) const
-{
- QWidget *w = widget();
- if (!w->isVisible())
- return -1;
- QPoint gp = w->mapToGlobal(QPoint(0, 0));
- if (!QRect(gp.x(), gp.y(), w->width(), w->height()).contains(x, y))
- return -1;
-
- QWidgetList list = childWidgets(w);
- int ccount = childCount();
-
- // a complex child
- if (list.size() < ccount) {
- for (int i = 1; i <= ccount; ++i) {
- if (rect(i).contains(x, y))
- return i;
- }
- return 0;
- }
-
- QPoint rp = w->mapFromGlobal(QPoint(x, y));
- for (int i = 0; i<list.size(); ++i) {
- QWidget *child = list.at(i);
- if (!child->isWindow() && !child->isHidden() && child->geometry().contains(rp)) {
- return i + 1;
- }
- }
- return 0;
-}
-
-/*! \reimp */
-QRect QAccessibleWidget::rect(int child) const
-{
- if (child) {
- qWarning("QAccessibleWidget::rect: This implementation does not support subelements! "
- "(ID %d unknown for %s)", child, widget()->metaObject()->className());
- }
-
- QWidget *w = widget();
- if (!w->isVisible())
- return QRect();
- QPoint wpos = w->mapToGlobal(QPoint(0, 0));
-
- return QRect(wpos.x(), wpos.y(), w->width(), w->height());
-}
-
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <private/qobject_p.h>
-QT_END_INCLUDE_NAMESPACE
-
-class QACConnectionObject : public QObject
-{
- Q_DECLARE_PRIVATE(QObject)
-public:
- inline bool isSender(const QObject *receiver, const char *signal) const
- { return d_func()->isSender(receiver, signal); }
- inline QObjectList receiverList(const char *signal) const
- { return d_func()->receiverList(signal); }
- inline QObjectList senderList() const
- { return d_func()->senderList(); }
-};
-
-/*!
- Registers \a signal as a controlling signal.
-
- An object is a Controller to any other object connected to a
- controlling signal.
-*/
-void QAccessibleWidget::addControllingSignal(const QString &signal)
-{
- QByteArray s = QMetaObject::normalizedSignature(signal.toAscii());
- if (object()->metaObject()->indexOfSignal(s) < 0)
- qWarning("Signal %s unknown in %s", s.constData(), object()->metaObject()->className());
- d->primarySignals << QLatin1String(s);
-}
-
-/*!
- Sets the value of this interface implementation to \a value.
-
- The default implementation of text() returns the set value for
- the Value text.
-
- Note that the object wrapped by this interface is not modified.
-*/
-void QAccessibleWidget::setValue(const QString &value)
-{
- d->value = value;
-}
-
-/*!
- Sets the description of this interface implementation to \a desc.
-
- The default implementation of text() returns the set value for
- the Description text.
-
- Note that the object wrapped by this interface is not modified.
-*/
-void QAccessibleWidget::setDescription(const QString &desc)
-{
- d->description = desc;
-}
-
-/*!
- Sets the help of this interface implementation to \a help.
-
- The default implementation of text() returns the set value for
- the Help text.
-
- Note that the object wrapped by this interface is not modified.
-*/
-void QAccessibleWidget::setHelp(const QString &help)
-{
- d->help = help;
-}
-
-/*!
- Sets the accelerator of this interface implementation to \a accel.
-
- The default implementation of text() returns the set value for
- the Accelerator text.
-
- Note that the object wrapped by this interface is not modified.
-*/
-void QAccessibleWidget::setAccelerator(const QString &accel)
-{
- d->accelerator = accel;
-}
-
-static inline bool isAncestor(const QObject *obj, const QObject *child)
-{
- while (child) {
- if (child == obj)
- return true;
- child = child->parent();
- }
- return false;
-}
-
-
-/*! \reimp */
-QAccessible::Relation QAccessibleWidget::relationTo(int child,
- const QAccessibleInterface *other, int otherChild) const
-{
- Relation relation = Unrelated;
- if (d->asking == this) // recursive call
- return relation;
-
- QObject *o = other ? other->object() : 0;
- if (!o)
- return relation;
-
- QWidget *focus = widget()->focusWidget();
- if (object() == focus && isAncestor(o, focus))
- relation |= FocusChild;
-
- QACConnectionObject *connectionObject = (QACConnectionObject*)object();
- for (int sig = 0; sig < d->primarySignals.count(); ++sig) {
- if (connectionObject->isSender(o, d->primarySignals.at(sig).toAscii())) {
- relation |= Controller;
- break;
- }
- }
- // test for passive relationships.
- // d->asking protects from endless recursion.
- d->asking = this;
- int inverse = other->relationTo(otherChild, this, child);
- d->asking = 0;
-
- if (inverse & Controller)
- relation |= Controlled;
- if (inverse & Label)
- relation |= Labelled;
-
- if(o == object()) {
- if (child && !otherChild)
- return relation | Child;
- if (!child && otherChild)
- return relation | Ancestor;
- if (!child && !otherChild)
- return relation | Self;
- }
-
- QObject *parent = object()->parent();
- if (o == parent)
- return relation | Child;
-
- if (o->parent() == parent) {
- relation |= Sibling;
- QAccessibleInterface *sibIface = QAccessible::queryAccessibleInterface(o);
- Q_ASSERT(sibIface);
- QRect wg = rect(0);
- QRect sg = sibIface->rect(0);
- if (wg.intersects(sg)) {
- QAccessibleInterface *pIface = 0;
- sibIface->navigate(Ancestor, 1, &pIface);
- if (pIface && !((sibIface->state(0) | state(0)) & Invisible)) {
- int wi = pIface->indexOfChild(this);
- int si = pIface->indexOfChild(sibIface);
-
- if (wi > si)
- relation |= QAccessible::Covers;
- else
- relation |= QAccessible::Covered;
- }
- delete pIface;
- } else {
- QPoint wc = wg.center();
- QPoint sc = sg.center();
- if (wc.x() < sc.x())
- relation |= QAccessible::Left;
- else if(wc.x() > sc.x())
- relation |= QAccessible::Right;
- if (wc.y() < sc.y())
- relation |= QAccessible::Up;
- else if (wc.y() > sc.y())
- relation |= QAccessible::Down;
- }
- delete sibIface;
-
- return relation;
- }
-
- if (isAncestor(o, object()))
- return relation | Descendent;
- if (isAncestor(object(), o))
- return relation | Ancestor;
-
- return relation;
-}
-
-/*! \reimp */
-int QAccessibleWidget::navigate(RelationFlag relation, int entry,
- QAccessibleInterface **target) const
-{
- if (!target)
- return -1;
-
- *target = 0;
- QObject *targetObject = 0;
-
- QWidgetList childList = childWidgets(widget());
- bool complexWidget = childList.size() < childCount();
-
- switch (relation) {
- // Hierarchical
- case Self:
- targetObject = object();
- break;
- case Child:
- if (complexWidget) {
- if (entry > 0 && entry <= childCount())
- return entry;
- return -1;
- }else {
- if (entry > 0 && childList.size() >= entry)
- targetObject = childList.at(entry - 1);
- }
- break;
- case Ancestor:
- {
- if (entry <= 0)
- return -1;
- targetObject = widget()->parentWidget();
- int i;
- for (i = entry; i > 1 && targetObject; --i)
- targetObject = targetObject->parent();
- if (!targetObject && i == 1)
- targetObject = qApp;
- }
- break;
- case Sibling:
- {
- QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(parentObject());
- if (!iface)
- return -1;
-
- iface->navigate(Child, entry, target);
- delete iface;
- if (*target)
- return 0;
- }
- break;
-
- // Geometrical
- case QAccessible::Left:
- if (complexWidget && entry) {
- if (entry < 2 || widget()->height() > widget()->width() + 20) // looks vertical
- return -1;
- return entry - 1;
- }
- // fall through
- case QAccessible::Right:
- if (complexWidget && entry) {
- if (entry >= childCount() || widget()->height() > widget()->width() + 20) // looks vertical
- return -1;
- return entry + 1;
- }
- // fall through
- case QAccessible::Up:
- if (complexWidget && entry) {
- if (entry < 2 || widget()->width() > widget()->height() + 20) // looks horizontal
- return - 1;
- return entry - 1;
- }
- // fall through
- case QAccessible::Down:
- if (complexWidget && entry) {
- if (entry >= childCount() || widget()->width() > widget()->height() + 20) // looks horizontal
- return - 1;
- return entry + 1;
- } else {
- QAccessibleInterface *pIface = QAccessible::queryAccessibleInterface(parentObject());
- if (!pIface)
- return -1;
-
- QRect startg = rect(0);
- QPoint startc = startg.center();
- QAccessibleInterface *candidate = 0;
- int mindist = 100000;
- int sibCount = pIface->childCount();
- for (int i = 0; i < sibCount; ++i) {
- QAccessibleInterface *sibling = 0;
- pIface->navigate(Child, i+1, &sibling);
- Q_ASSERT(sibling);
- if ((relationTo(0, sibling, 0) & Self) || (sibling->state(0) & QAccessible::Invisible)) {
- //ignore ourself and invisible siblings
- delete sibling;
- continue;
- }
-
- QRect sibg = sibling->rect(0);
- QPoint sibc = sibg.center();
- QPoint sibp;
- QPoint startp;
- QPoint distp;
- switch (relation) {
- case QAccessible::Left:
- startp = QPoint(startg.left(), startg.top() + startg.height() / 2);
- sibp = QPoint(sibg.right(), sibg.top() + sibg.height() / 2);
- if (QPoint(sibc - startc).x() >= 0) {
- delete sibling;
- continue;
- }
- distp = sibp - startp;
- break;
- case QAccessible::Right:
- startp = QPoint(startg.right(), startg.top() + startg.height() / 2);
- sibp = QPoint(sibg.left(), sibg.top() + sibg.height() / 2);
- if (QPoint(sibc - startc).x() <= 0) {
- delete sibling;
- continue;
- }
- distp = sibp - startp;
- break;
- case QAccessible::Up:
- startp = QPoint(startg.left() + startg.width() / 2, startg.top());
- sibp = QPoint(sibg.left() + sibg.width() / 2, sibg.bottom());
- if (QPoint(sibc - startc).y() >= 0) {
- delete sibling;
- continue;
- }
- distp = sibp - startp;
- break;
- case QAccessible::Down:
- startp = QPoint(startg.left() + startg.width() / 2, startg.bottom());
- sibp = QPoint(sibg.left() + sibg.width() / 2, sibg.top());
- if (QPoint(sibc - startc).y() <= 0) {
- delete sibling;
- continue;
- }
- distp = sibp - startp;
- break;
- default:
- break;
- }
-
- int dist = (int)qSqrt((qreal)distp.x() * distp.x() + distp.y() * distp.y());
- if (dist < mindist) {
- delete candidate;
- candidate = sibling;
- mindist = dist;
- } else {
- delete sibling;
- }
- }
- delete pIface;
- *target = candidate;
- if (*target)
- return 0;
- }
- break;
- case Covers:
- if (entry > 0) {
- QAccessibleInterface *pIface = QAccessible::queryAccessibleInterface(parentObject());
- if (!pIface)
- return -1;
-
- QRect r = rect(0);
- int sibCount = pIface->childCount();
- QAccessibleInterface *sibling = 0;
- for (int i = pIface->indexOfChild(this) + 1; i <= sibCount && entry; ++i) {
- pIface->navigate(Child, i, &sibling);
- if (!sibling || (sibling->state(0) & Invisible)) {
- delete sibling;
- sibling = 0;
- continue;
- }
- if (sibling->rect(0).intersects(r))
- --entry;
- if (!entry)
- break;
- delete sibling;
- sibling = 0;
- }
- delete pIface;
- *target = sibling;
- if (*target)
- return 0;
- }
- break;
- case Covered:
- if (entry > 0) {
- QAccessibleInterface *pIface = QAccessible::queryAccessibleInterface(parentObject());
- if (!pIface)
- return -1;
-
- QRect r = rect(0);
- int index = pIface->indexOfChild(this);
- QAccessibleInterface *sibling = 0;
- for (int i = 1; i < index && entry; ++i) {
- pIface->navigate(Child, i, &sibling);
- Q_ASSERT(sibling);
- if (!sibling || (sibling->state(0) & Invisible)) {
- delete sibling;
- sibling = 0;
- continue;
- }
- if (sibling->rect(0).intersects(r))
- --entry;
- if (!entry)
- break;
- delete sibling;
- sibling = 0;
- }
- delete pIface;
- *target = sibling;
- if (*target)
- return 0;
- }
- break;
-
- // Logical
- case FocusChild:
- {
- if (widget()->hasFocus()) {
- targetObject = object();
- break;
- }
-
- QWidget *fw = widget()->focusWidget();
- if (!fw)
- return -1;
-
- if (isAncestor(widget(), fw) || fw == widget())
- targetObject = fw;
- /* ###
- QWidget *parent = fw;
- while (parent && !targetObject) {
- parent = parent->parentWidget();
- if (parent == widget())
- targetObject = fw;
- }
- */
- }
- break;
- case Label:
- if (entry > 0) {
- QAccessibleInterface *pIface = QAccessible::queryAccessibleInterface(parentObject());
- if (!pIface)
- return -1;
-
- // first check for all siblings that are labels to us
- // ideally we would go through all objects and check, but that
- // will be too expensive
- int sibCount = pIface->childCount();
- QAccessibleInterface *candidate = 0;
- for (int i = 0; i < sibCount && entry; ++i) {
- pIface->navigate(Child, i+1, &candidate);
- Q_ASSERT(candidate);
- if (candidate->relationTo(0, this, 0) & Label)
- --entry;
- if (!entry)
- break;
- delete candidate;
- candidate = 0;
- }
- if (!candidate) {
- if (pIface->relationTo(0, this, 0) & Label)
- --entry;
- if (!entry)
- candidate = pIface;
- }
- if (pIface != candidate)
- delete pIface;
-
- *target = candidate;
- if (*target)
- return 0;
- }
- break;
- case Labelled: // only implemented in subclasses
- break;
- case Controller:
- if (entry > 0) {
- // check all senders we are connected to,
- // and figure out which one are controllers to us
- QACConnectionObject *connectionObject = (QACConnectionObject*)object();
- QObjectList allSenders = connectionObject->senderList();
- QObjectList senders;
- for (int s = 0; s < allSenders.size(); ++s) {
- QObject *sender = allSenders.at(s);
- QAccessibleInterface *candidate = QAccessible::queryAccessibleInterface(sender);
- if (!candidate)
- continue;
- if (candidate->relationTo(0, this, 0)&Controller)
- senders << sender;
- delete candidate;
- }
- if (entry <= senders.size())
- targetObject = senders.at(entry-1);
- }
- break;
- case Controlled:
- if (entry > 0) {
- QObjectList allReceivers;
- QACConnectionObject *connectionObject = (QACConnectionObject*)object();
- for (int sig = 0; sig < d->primarySignals.count(); ++sig) {
- QObjectList receivers = connectionObject->receiverList(d->primarySignals.at(sig).toAscii());
- allReceivers += receivers;
- }
- if (entry <= allReceivers.size())
- targetObject = allReceivers.at(entry-1);
- }
- break;
- default:
- break;
- }
-
- *target = QAccessible::queryAccessibleInterface(targetObject);
- return *target ? 0 : -1;
-}
-
-/*! \reimp */
-int QAccessibleWidget::childCount() const
-{
- QWidgetList cl = childWidgets(widget());
- return cl.size();
-}
-
-/*! \reimp */
-int QAccessibleWidget::indexOfChild(const QAccessibleInterface *child) const
-{
- QWidgetList cl = childWidgets(widget());
- int index = cl.indexOf(qobject_cast<QWidget *>(child->object()));
- if (index != -1)
- ++index;
- return index;
-}
-
-// from qwidget.cpp
-extern QString qt_setWindowTitle_helperHelper(const QString &, const QWidget*);
-
-/*! \reimp */
-QString QAccessibleWidget::text(Text t, int child) const
-{
- QString str;
-
- switch (t) {
- case Name:
- if (!d->name.isEmpty()) {
- str = d->name;
- } else if (!widget()->accessibleName().isEmpty()) {
- str = widget()->accessibleName();
- } else if (!child && widget()->isWindow()) {
- if (widget()->isMinimized())
- str = qt_setWindowTitle_helperHelper(widget()->windowIconText(), widget());
- else
- str = qt_setWindowTitle_helperHelper(widget()->windowTitle(), widget());
- } else {
- str = qt_accStripAmp(buddyString(widget()));
- }
- break;
- case Description:
- if (!d->description.isEmpty())
- str = d->description;
- else if (!widget()->accessibleDescription().isEmpty())
- str = widget()->accessibleDescription();
-#ifndef QT_NO_TOOLTIP
- else
- str = widget()->toolTip();
-#endif
- break;
- case Help:
- if (!d->help.isEmpty())
- str = d->help;
-#ifndef QT_NO_WHATSTHIS
- else
- str = widget()->whatsThis();
-#endif
- break;
- case Accelerator:
- if (!d->accelerator.isEmpty())
- str = d->accelerator;
- else
- str = qt_accHotKey(buddyString(widget()));
- break;
- case Value:
- str = d->value;
- break;
- default:
- break;
- }
- return str;
-}
-
-#ifndef QT_NO_ACTION
-
-/*! \reimp */
-int QAccessibleWidget::userActionCount(int child) const
-{
- if (child)
- return 0;
- return widget()->actions().count();
-}
-
-/*! \reimp */
-QString QAccessibleWidget::actionText(int action, Text t, int child) const
-{
- if (action == DefaultAction)
- action = SetFocus;
-
- if (action > 0 && !child) {
- QAction *act = widget()->actions().value(action - 1);
- if (act) {
- switch (t) {
- case Name:
- return act->text();
- case Description:
- return act->toolTip();
-#ifndef QT_NO_SHORTCUT
- case Accelerator:
- return act->shortcut().toString();
-#endif
- default:
- break;
- }
- }
- }
-
- return QAccessibleObject::actionText(action, t, child);
-}
-
-/*! \reimp */
-bool QAccessibleWidget::doAction(int action, int child, const QVariantList &params)
-{
- if (action == SetFocus || action == DefaultAction) {
- if (child || !widget()->isEnabled())
- return false;
- if (widget()->focusPolicy() != Qt::NoFocus)
- widget()->setFocus();
- else if (widget()->isWindow())
- widget()->activateWindow();
- else
- return false;
- return true;
- } else if (action > 0) {
- if (QAction *act = widget()->actions().value(action - 1)) {
- act->trigger();
- return true;
- }
- }
- return QAccessibleObject::doAction(action, child, params);
-}
-
-#endif // QT_NO_ACTION
-
-/*! \reimp */
-QAccessible::Role QAccessibleWidget::role(int child) const
-{
- if (!child)
- return d->role;
-
- QWidgetList childList = childWidgets(widget());
- if (childList.count() > 0 && child <= childList.count()) {
- QWidget *targetWidget = childList.at(child - 1);
- QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(targetWidget);
- if (iface) {
- QAccessible::Role role = iface->role(0);
- delete iface;
- return role;
- }
- }
-
- return NoRole;
-}
-
-/*! \reimp */
-QAccessible::State QAccessibleWidget::state(int child) const
-{
- if (child)
- return Normal;
-
- QAccessible::State state = Normal;
-
- QWidget *w = widget();
- if (w->testAttribute(Qt::WA_WState_Visible) == false)
- state |= Invisible;
- if (w->focusPolicy() != Qt::NoFocus && w->isActiveWindow())
- state |= Focusable;
- if (w->hasFocus())
- state |= Focused;
- if (!w->isEnabled())
- state |= Unavailable;
- if (w->isWindow()) {
- if (w->windowFlags() & Qt::WindowSystemMenuHint)
- state |= Movable;
- if (w->minimumSize() != w->maximumSize())
- state |= Sizeable;
- }
-
- return state;
-}
-
-// ### Qt 5: remove me - binary compatibility hack
-QAccessibleWidgetEx::QAccessibleWidgetEx(QWidget *o, Role role, const QString& name)
- : QAccessibleObjectEx(o)
-{
- Q_ASSERT(widget());
- d = new QAccessibleWidgetPrivate();
- d->role = role;
- d->name = name;
- d->asking = 0;
-}
-
-int QAccessibleWidgetEx::childCount() const
-{ return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::childCount(); }
-int QAccessibleWidgetEx::indexOfChild(const QAccessibleInterface *child) const
-{ return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::indexOfChild(child); }
-QAccessible::Relation QAccessibleWidgetEx::relationTo(int child, const QAccessibleInterface *other, int otherChild) const
-{ return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::relationTo(child, other, otherChild); }
-
-int QAccessibleWidgetEx::childAt(int x, int y) const
-{ return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::childAt(x, y); }
-QRect QAccessibleWidgetEx::rect(int child) const
-{ return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::rect(child); }
-int QAccessibleWidgetEx::navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const
-{ return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::navigate(rel, entry, target); }
-
-QString QAccessibleWidgetEx::text(Text t, int child) const
-{ return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::text(t, child); }
-QAccessible::Role QAccessibleWidgetEx::role(int child) const
-{ return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::role(child); }
-QAccessible::State QAccessibleWidgetEx::state(int child) const
-{ return (reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::state(child))
- | HasInvokeExtension; }
-
-QString QAccessibleWidgetEx::actionText(int action, Text t, int child) const
-{ return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::actionText(action, t, child); }
-bool QAccessibleWidgetEx::doAction(int action, int child, const QVariantList &params)
-{ return reinterpret_cast<QAccessibleWidget *>(this)->QAccessibleWidget::doAction(action, child, params); }
-
-QAccessibleWidgetEx::~QAccessibleWidgetEx()
-{ delete d; }
-QWidget *QAccessibleWidgetEx::widget() const
-{ return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::widget(); }
-QObject *QAccessibleWidgetEx::parentObject() const
-{ return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::parentObject(); }
-
-void QAccessibleWidgetEx::addControllingSignal(const QString &signal)
-{ reinterpret_cast<QAccessibleWidget *>(this)->QAccessibleWidget::addControllingSignal(signal); }
-void QAccessibleWidgetEx::setValue(const QString &value)
-{ reinterpret_cast<QAccessibleWidget *>(this)->QAccessibleWidget::setValue(value); }
-void QAccessibleWidgetEx::setDescription(const QString &desc)
-{ reinterpret_cast<QAccessibleWidget *>(this)->QAccessibleWidget::setDescription(desc); }
-void QAccessibleWidgetEx::setHelp(const QString &help)
-{ reinterpret_cast<QAccessibleWidget *>(this)->QAccessibleWidget::setHelp(help); }
-void QAccessibleWidgetEx::setAccelerator(const QString &accel)
-{ reinterpret_cast<QAccessibleWidget *>(this)->QAccessibleWidget::setAccelerator(accel); }
-
-QVariant QAccessibleWidgetEx::invokeMethodEx(Method method, int child, const QVariantList & /*params*/)
-{
- if (child)
- return QVariant();
-
- switch (method) {
- case ListSupportedMethods: {
- QSet<QAccessible::Method> set;
- set << ListSupportedMethods << ForegroundColor << BackgroundColor;
- return QVariant::fromValue(set);
- }
- case ForegroundColor:
- return widget()->palette().color(widget()->foregroundRole());
- case BackgroundColor:
- return widget()->palette().color(widget()->backgroundRole());
- default:
- return QVariant();
- }
-}
-
-QT_END_NAMESPACE
-
-#endif //QT_NO_ACCESSIBILITY
diff --git a/src/gui/accessible/qaccessiblewidget.h b/src/gui/accessible/qaccessiblewidget.h
deleted file mode 100644
index ef22e05c60..0000000000
--- a/src/gui/accessible/qaccessiblewidget.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QACCESSIBLEWIDGET_H
-#define QACCESSIBLEWIDGET_H
-
-#include <QtGui/qaccessibleobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_ACCESSIBILITY
-
-class QAccessibleWidgetPrivate;
-
-class Q_GUI_EXPORT QAccessibleWidget : public QAccessibleObject
-{
-public:
- explicit QAccessibleWidget(QWidget *o, Role r = Client, const QString& name = QString());
-
- int childCount() const;
- int indexOfChild(const QAccessibleInterface *child) const;
- Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const;
-
- int childAt(int x, int y) const;
- QRect rect(int child) const;
- int navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const;
-
- QString text(Text t, int child) const;
- Role role(int child) const;
- State state(int child) const;
-
-#ifndef QT_NO_ACTION
- int userActionCount(int child) const;
- QString actionText(int action, Text t, int child) const;
- bool doAction(int action, int child, const QVariantList &params);
-#endif
-
-protected:
- ~QAccessibleWidget();
- QWidget *widget() const;
- QObject *parentObject() const;
-
- void addControllingSignal(const QString &signal);
- void setValue(const QString &value);
- void setDescription(const QString &desc);
- void setHelp(const QString &help);
- void setAccelerator(const QString &accel);
-
-private:
- friend class QAccessibleWidgetEx;
- QAccessibleWidgetPrivate *d;
- Q_DISABLE_COPY(QAccessibleWidget)
-};
-
-class Q_GUI_EXPORT QAccessibleWidgetEx : public QAccessibleObjectEx
-{
-public:
- explicit QAccessibleWidgetEx(QWidget *o, Role r = Client, const QString& name = QString());
-
- int childCount() const;
- int indexOfChild(const QAccessibleInterface *child) const;
- Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const;
-
- int childAt(int x, int y) const;
- QRect rect(int child) const;
- int navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const;
-
- QString text(Text t, int child) const;
- Role role(int child) const;
- State state(int child) const;
-
- QString actionText(int action, Text t, int child) const;
- bool doAction(int action, int child, const QVariantList &params);
-
- QVariant invokeMethodEx(Method method, int child, const QVariantList &params);
-
-protected:
- ~QAccessibleWidgetEx();
- QWidget *widget() const;
- QObject *parentObject() const;
-
- void addControllingSignal(const QString &signal);
- void setValue(const QString &value);
- void setDescription(const QString &desc);
- void setHelp(const QString &help);
- void setAccelerator(const QString &accel);
-
-private:
- QAccessibleWidgetPrivate *d;
- Q_DISABLE_COPY(QAccessibleWidgetEx)
-};
-
-#endif // QT_NO_ACCESSIBILITY
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QACCESSIBLEWIDGET_H
diff --git a/src/gui/dialogs/dialogs.pri b/src/gui/dialogs/dialogs.pri
deleted file mode 100644
index 6ba707c9d3..0000000000
--- a/src/gui/dialogs/dialogs.pri
+++ /dev/null
@@ -1,122 +0,0 @@
-# Qt dialogs module
-
-HEADERS += \
- dialogs/qabstractprintdialog.h \
- dialogs/qabstractprintdialog_p.h \
- dialogs/qabstractpagesetupdialog.h \
- dialogs/qabstractpagesetupdialog_p.h \
- dialogs/qcolordialog.h \
- dialogs/qcolordialog_p.h \
- dialogs/qfscompleter_p.h \
- dialogs/qdialog.h \
- dialogs/qdialog_p.h \
- dialogs/qerrormessage.h \
- dialogs/qfiledialog.h \
- dialogs/qfiledialog_p.h \
- dialogs/qfontdialog.h \
- dialogs/qfontdialog_p.h \
- dialogs/qinputdialog.h \
- dialogs/qmessagebox.h \
- dialogs/qpagesetupdialog.h \
- dialogs/qprintdialog.h \
- dialogs/qprogressdialog.h \
- dialogs/qsidebar_p.h \
- dialogs/qfilesystemmodel.h \
- dialogs/qfilesystemmodel_p.h \
- dialogs/qfileinfogatherer_p.h \
- dialogs/qwizard.h \
- dialogs/qprintpreviewdialog.h
-
-!embedded:!qpa:mac {
- OBJECTIVE_SOURCES += dialogs/qfiledialog_mac.mm \
- dialogs/qfontdialog_mac.mm \
- dialogs/qnspanelproxy_mac.mm \
- dialogs/qpagesetupdialog_mac.mm \
- dialogs/qprintdialog_mac.mm
-
-# Compile qcolordialog_mac.mm with exception support, disregarding the -no-exceptions
-# configure option. (qcolordialog_mac needs to catch exceptions thrown by cocoa)
- EXCEPTION_SOURCES = dialogs/qcolordialog_mac.mm
- exceptions_compiler.commands = $$QMAKE_CXX -c
- exceptions_compiler.commands += $(CXXFLAGS) $(INCPATH) ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
- exceptions_compiler.commands += -fexceptions
- exceptions_compiler.dependency_type = TYPE_C
- exceptions_compiler.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)}
- exceptions_compiler.input = EXCEPTION_SOURCES
- exceptions_compiler.variable_out = OBJECTS
- exceptions_compiler.name = compiling[exceptopns] ${QMAKE_FILE_IN}
- silent:exceptions_compiler.commands = @echo compiling[exceptopns] ${QMAKE_FILE_IN} && $$exceptions_compiler.commands
- QMAKE_EXTRA_COMPILERS += exceptions_compiler
-}
-
-win32 {
- HEADERS += dialogs/qwizard_win_p.h \
- dialogs/qfiledialog_win_p.h
- SOURCES += dialogs/qdialogsbinarycompat_win.cpp \
- dialogs/qfiledialog_win.cpp \
- dialogs/qpagesetupdialog_win.cpp \
- dialogs/qprintdialog_win.cpp \
- dialogs/qwizard_win.cpp
-
- !win32-borland:!wince*: LIBS += -lshell32 # the filedialog needs this library
-}
-
-!mac:!embedded:!symbian:unix|qpa {
- HEADERS += dialogs/qpagesetupdialog_unix_p.h
- SOURCES += dialogs/qprintdialog_unix.cpp \
- dialogs/qpagesetupdialog_unix.cpp
- FORMS += dialogs/qprintsettingsoutput.ui \
- dialogs/qprintwidget.ui \
- dialogs/qprintpropertieswidget.ui
-}
-
-embedded {
- contains(QT_CONFIG,qtopia) {
- HEADERS += dialogs/qpagesetupdialog_unix_p.h
- DEFINES += QTOPIA_PRINTDIALOG
- SOURCES += dialogs/qprintdialog_qws.cpp \
- dialogs/qpagesetupdialog_unix.cpp
- } else {
- HEADERS += dialogs/qpagesetupdialog_unix_p.h
- SOURCES += dialogs/qprintdialog_unix.cpp \
- dialogs/qpagesetupdialog_unix.cpp
- FORMS += dialogs/qprintsettingsoutput.ui \
- dialogs/qprintwidget.ui \
- dialogs/qprintpropertieswidget.ui
- }
-}
-
-wince*|symbian: FORMS += dialogs/qfiledialog_embedded.ui
-else: FORMS += dialogs/qfiledialog.ui
-
-INCLUDEPATH += $$PWD
-SOURCES += \
- dialogs/qabstractprintdialog.cpp \
- dialogs/qabstractpagesetupdialog.cpp \
- dialogs/qcolordialog.cpp \
- dialogs/qdialog.cpp \
- dialogs/qerrormessage.cpp \
- dialogs/qfiledialog.cpp \
- dialogs/qfontdialog.cpp \
- dialogs/qinputdialog.cpp \
- dialogs/qmessagebox.cpp \
- dialogs/qprogressdialog.cpp \
- dialogs/qsidebar.cpp \
- dialogs/qfilesystemmodel.cpp \
- dialogs/qfileinfogatherer.cpp \
- dialogs/qpagesetupdialog.cpp \
- dialogs/qwizard.cpp \
- dialogs/qprintpreviewdialog.cpp
-
-symbian:contains(QT_CONFIG, s60) {
- LIBS += -lCommonDialogs
- SOURCES += dialogs/qfiledialog_symbian.cpp \
- dialogs/qcolordialog_symbian.cpp
-}
-
-FORMS += dialogs/qpagesetupwidget.ui
-RESOURCES += dialogs/qprintdialog.qrc
-RESOURCES += dialogs/qmessagebox.qrc
-
-# Compensate for lack of platform defines in Symbian3
-symbian: DEFINES += SYMBIAN_VERSION_$$upper($$replace(SYMBIAN_VERSION,\\.,_))
diff --git a/src/gui/dialogs/qabstractpagesetupdialog.h b/src/gui/dialogs/qabstractpagesetupdialog.h
deleted file mode 100644
index ac3ffa5451..0000000000
--- a/src/gui/dialogs/qabstractpagesetupdialog.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QABSTRACTPAGESETUPDIALOG_H
-#define QABSTRACTPAGESETUPDIALOG_H
-
-#include <QtGui/qdialog.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_PRINTDIALOG
-
-class QAbstractPageSetupDialogPrivate;
-class QPrinter;
-
-// ### Qt 5: Remove this class
-class Q_GUI_EXPORT QAbstractPageSetupDialog : public QDialog
-{
- Q_DECLARE_PRIVATE(QAbstractPageSetupDialog)
- Q_OBJECT
-
-public:
- explicit QAbstractPageSetupDialog(QPrinter *printer, QWidget *parent = 0);
- QAbstractPageSetupDialog(QAbstractPageSetupDialogPrivate &ptr,
- QPrinter *printer, QWidget *parent = 0);
- ~QAbstractPageSetupDialog();
-
- virtual int exec() = 0;
- void done(int result);
-
- QPrinter *printer();
-};
-
-#endif // QT_NO_PRINTDIALOG
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QABSTRACTPAGESETUPDIALOG_H
diff --git a/src/gui/dialogs/qabstractprintdialog.cpp b/src/gui/dialogs/qabstractprintdialog.cpp
deleted file mode 100644
index ef46697c2c..0000000000
--- a/src/gui/dialogs/qabstractprintdialog.cpp
+++ /dev/null
@@ -1,497 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qabstractprintdialog_p.h"
-#include "qcoreapplication.h"
-#include "qprintdialog.h"
-#include "qprinter.h"
-#include "private/qprinter_p.h"
-
-#ifndef QT_NO_PRINTDIALOG
-
-QT_BEGIN_NAMESPACE
-
-// hack
-class QPrintDialogPrivate : public QAbstractPrintDialogPrivate
-{
-};
-
-/*!
- \class QAbstractPrintDialog
- \brief The QAbstractPrintDialog class provides a base implementation for
- print dialogs used to configure printers.
-
- \ingroup printing
-
- This class implements getter and setter functions that are used to
- customize settings shown in print dialogs, but it is not used directly.
- Use QPrintDialog to display a print dialog in your application.
-
- In Symbian, there is no support for printing. Hence, this dialog should not
- be used in Symbian.
-
- \sa QPrintDialog, QPrinter, {Printing with Qt}
-*/
-
-/*!
- \enum QAbstractPrintDialog::PrintRange
-
- Used to specify the print range selection option.
-
- \value AllPages All pages should be printed.
- \value Selection Only the selection should be printed.
- \value PageRange The specified page range should be printed.
- \value CurrentPage Only the currently visible page should be printed.
-
- \sa QPrinter::PrintRange
-*/
-
-/*!
- \enum QAbstractPrintDialog::PrintDialogOption
-
- Used to specify which parts of the print dialog should be visible.
-
- \value None None of the options are enabled.
- \value PrintToFile The print to file option is enabled.
- \value PrintSelection The print selection option is enabled.
- \value PrintPageRange The page range selection option is enabled.
- \value PrintShowPageSize Show the page size + margins page only if this is enabled.
- \value PrintCollateCopies The collate copies option is enabled
- \value PrintCurrentPage The print current page option is enabled
-
- This value is obsolete and does nothing since Qt 4.5:
-
- \value DontUseSheet In previous versions of Qt, exec() the print dialog
- would create a sheet by default the dialog was given a parent.
- This is no longer supported in Qt 4.5. If you want to use sheets, use
- QPrintDialog::open() instead.
-*/
-
-/*!
- Constructs an abstract print dialog for \a printer with \a parent
- as parent widget.
-*/
-QAbstractPrintDialog::QAbstractPrintDialog(QPrinter *printer, QWidget *parent)
- : QDialog(*(new QAbstractPrintDialogPrivate), parent)
-{
- Q_D(QAbstractPrintDialog);
- setWindowTitle(QCoreApplication::translate("QPrintDialog", "Print"));
- d->setPrinter(printer);
-}
-
-/*!
- \internal
-*/
-QAbstractPrintDialog::QAbstractPrintDialog(QAbstractPrintDialogPrivate &ptr,
- QPrinter *printer,
- QWidget *parent)
- : QDialog(ptr, parent)
-{
- Q_D(QAbstractPrintDialog);
- setWindowTitle(QCoreApplication::translate("QPrintDialog", "Print"));
- d->setPrinter(printer);
-}
-
-/*!
- \internal
-*/
-QAbstractPrintDialog::~QAbstractPrintDialog()
-{
- Q_D(QAbstractPrintDialog);
- if (d->ownsPrinter)
- delete d->printer;
-}
-
-/*!
- Sets the given \a option to be enabled if \a on is true;
- otherwise, clears the given \a option.
-
- \sa options, testOption()
-*/
-void QPrintDialog::setOption(PrintDialogOption option, bool on)
-{
- Q_D(QPrintDialog);
- if (!(d->pd->options & option) != !on)
- setOptions(d->pd->options ^ option);
-}
-
-/*!
- Returns true if the given \a option is enabled; otherwise, returns
- false.
-
- \sa options, setOption()
-*/
-bool QPrintDialog::testOption(PrintDialogOption option) const
-{
- Q_D(const QPrintDialog);
- return (d->pd->options & option) != 0;
-}
-
-/*!
- \property QPrintDialog::options
- \brief the various options that affect the look and feel of the dialog
- \since 4.5
-
- By default, all options are disabled.
-
- Options should be set before showing the dialog. Setting them while the
- dialog is visible is not guaranteed to have an immediate effect on the
- dialog (depending on the option and on the platform).
-
- \sa setOption(), testOption()
-*/
-void QPrintDialog::setOptions(PrintDialogOptions options)
-{
- Q_D(QPrintDialog);
-
- PrintDialogOptions changed = (options ^ d->pd->options);
- if (!changed)
- return;
-
- d->pd->options = options;
-}
-
-QPrintDialog::PrintDialogOptions QPrintDialog::options() const
-{
- Q_D(const QPrintDialog);
- return d->pd->options;
-}
-
-/*!
- \obsolete
-
- Use QPrintDialog::setOptions() instead.
-*/
-void QAbstractPrintDialog::setEnabledOptions(PrintDialogOptions options)
-{
- Q_D(QAbstractPrintDialog);
- d->pd->options = options;
-}
-
-/*!
- \obsolete
-
- Use QPrintDialog::setOption(\a option, true) instead.
-*/
-void QAbstractPrintDialog::addEnabledOption(PrintDialogOption option)
-{
- Q_D(QAbstractPrintDialog);
- d->pd->options |= option;
-}
-
-/*!
- \obsolete
-
- Use QPrintDialog::options() instead.
-*/
-QAbstractPrintDialog::PrintDialogOptions QAbstractPrintDialog::enabledOptions() const
-{
- Q_D(const QAbstractPrintDialog);
- return d->pd->options;
-}
-
-/*!
- \obsolete
-
- Use QPrintDialog::testOption(\a option) instead.
-*/
-bool QAbstractPrintDialog::isOptionEnabled(PrintDialogOption option) const
-{
- Q_D(const QAbstractPrintDialog);
- return d->pd->options & option;
-}
-
-/*!
- Sets the print range option in to be \a range.
- */
-void QAbstractPrintDialog::setPrintRange(PrintRange range)
-{
- Q_D(QAbstractPrintDialog);
- d->pd->printRange = range;
-}
-
-/*!
- Returns the print range.
-*/
-QAbstractPrintDialog::PrintRange QAbstractPrintDialog::printRange() const
-{
- Q_D(const QAbstractPrintDialog);
- return d->pd->printRange;
-}
-
-/*!
- Sets the page range in this dialog to be from \a min to \a max. This also
- enables the PrintPageRange option.
-*/
-void QAbstractPrintDialog::setMinMax(int min, int max)
-{
- Q_D(QAbstractPrintDialog);
- Q_ASSERT_X(min <= max, "QAbstractPrintDialog::setMinMax",
- "'min' must be less than or equal to 'max'");
- d->pd->minPage = min;
- d->pd->maxPage = max;
- d->pd->options |= PrintPageRange;
-}
-
-/*!
- Returns the minimum page in the page range.
- By default, this value is set to 1.
-*/
-int QAbstractPrintDialog::minPage() const
-{
- Q_D(const QAbstractPrintDialog);
- return d->pd->minPage;
-}
-
-/*!
- Returns the maximum page in the page range. As of Qt 4.4, this
- function returns INT_MAX by default. Previous versions returned 1
- by default.
-*/
-int QAbstractPrintDialog::maxPage() const
-{
- Q_D(const QAbstractPrintDialog);
- return d->pd->maxPage;
-}
-
-/*!
- Sets the range in the print dialog to be from \a from to \a to.
-*/
-void QAbstractPrintDialog::setFromTo(int from, int to)
-{
- Q_D(QAbstractPrintDialog);
- Q_ASSERT_X(from <= to, "QAbstractPrintDialog::setFromTo",
- "'from' must be less than or equal to 'to'");
- d->pd->fromPage = from;
- d->pd->toPage = to;
-
- if (d->pd->minPage == 0 && d->pd->maxPage == 0)
- setMinMax(1, to);
-}
-
-/*!
- Returns the first page to be printed
- By default, this value is set to 0.
-*/
-int QAbstractPrintDialog::fromPage() const
-{
- Q_D(const QAbstractPrintDialog);
- return d->pd->fromPage;
-}
-
-/*!
- Returns the last page to be printed.
- By default, this value is set to 0.
-*/
-int QAbstractPrintDialog::toPage() const
-{
- Q_D(const QAbstractPrintDialog);
- return d->pd->toPage;
-}
-
-
-/*!
- Returns the printer that this printer dialog operates
- on.
-*/
-QPrinter *QAbstractPrintDialog::printer() const
-{
- Q_D(const QAbstractPrintDialog);
- return d->printer;
-}
-
-void QAbstractPrintDialogPrivate::setPrinter(QPrinter *newPrinter)
-{
- if (newPrinter) {
- printer = newPrinter;
- ownsPrinter = false;
- } else {
- printer = new QPrinter;
- ownsPrinter = true;
- }
- pd = printer->d_func();
-}
-
-/*!
- \fn int QAbstractPrintDialog::exec()
-
- This virtual function is called to pop up the dialog. It must be
- reimplemented in subclasses.
-*/
-
-/*!
- \class QPrintDialog
-
- \brief The QPrintDialog class provides a dialog for specifying
- the printer's configuration.
-
- \ingroup standard-dialogs
- \ingroup printing
-
- The dialog allows users to change document-related settings, such
- as the paper size and orientation, type of print (color or
- grayscale), range of pages, and number of copies to print.
-
- Controls are also provided to enable users to choose from the
- printers available, including any configured network printers.
-
- Typically, QPrintDialog objects are constructed with a QPrinter
- object, and executed using the exec() function.
-
- \snippet doc/src/snippets/code/src_gui_dialogs_qabstractprintdialog.cpp 0
-
- If the dialog is accepted by the user, the QPrinter object is
- correctly configured for printing.
-
- \table
- \row
- \o \inlineimage plastique-printdialog.png
- \o \inlineimage plastique-printdialog-properties.png
- \endtable
-
- The printer dialog (shown above in Plastique style) enables access to common
- printing properties. On X11 platforms that use the CUPS printing system, the
- settings for each available printer can be modified via the dialog's
- \gui{Properties} push button.
-
- On Windows and Mac OS X, the native print dialog is used, which means that
- some QWidget and QDialog properties set on the dialog won't be respected.
- The native print dialog on Mac OS X does not support setting printer options,
- i.e. setOptions() and setOption() have no effect.
-
- In Qt 4.4, it was possible to use the static functions to show a sheet on
- Mac OS X. This is no longer supported in Qt 4.5. If you want this
- functionality, use QPrintDialog::open().
-
- \sa QPageSetupDialog, QPrinter, {Pixelator Example}, {Order Form Example},
- {Image Viewer Example}, {Scribble Example}
-*/
-
-/*!
- \fn QPrintDialog::QPrintDialog(QPrinter *printer, QWidget *parent)
-
- Constructs a new modal printer dialog for the given \a printer
- with the given \a parent.
-*/
-
-/*!
- \fn QPrintDialog::~QPrintDialog()
-
- Destroys the print dialog.
-*/
-
-/*!
- \fn int QPrintDialog::exec()
- \reimp
-*/
-
-/*!
- \since 4.4
-
- Set a list of widgets as \a tabs to be shown on the print dialog, if supported.
-
- Currently this option is only supported on X11.
-
- Setting the option tabs will transfer their ownership to the print dialog.
-*/
-void QAbstractPrintDialog::setOptionTabs(const QList<QWidget*> &tabs)
-{
- Q_D(QAbstractPrintDialog);
- d->setTabs(tabs);
-}
-
-/*!
-
- \fn void QPrintDialog::accepted(QPrinter *printer)
-
- This signal is emitted when the user accepts the values set in the print dialog.
- The \a printer parameter includes the printer that the settings were applied to.
-*/
-
-/*!
- \fn QPrinter *QPrintDialog::printer()
-
- Returns the printer that this printer dialog operates
- on. This can be useful when using the QPrintDialog::open() method.
-*/
-
-/*!
- Closes the dialog and sets its result code to \a result. If this dialog
- is shown with exec(), done() causes the local event loop to finish,
- and exec() to return \a result.
-
- \sa QDialog::done()
-*/
-void QPrintDialog::done(int result)
-{
- Q_D(QPrintDialog);
- QDialog::done(result);
- if (result == Accepted)
- emit accepted(printer());
- if (d->receiverToDisconnectOnClose) {
- disconnect(this, SIGNAL(accepted(QPrinter*)),
- d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
- d->receiverToDisconnectOnClose = 0;
- }
- d->memberToDisconnectOnClose.clear();
-}
-
-/*!
- \since 4.5
- \overload
-
- Opens the dialog and connects its accepted() signal to the slot specified
- by \a receiver and \a member.
-
- The signal will be disconnected from the slot when the dialog is closed.
-*/
-void QPrintDialog::open(QObject *receiver, const char *member)
-{
- Q_D(QPrintDialog);
- connect(this, SIGNAL(accepted(QPrinter*)), receiver, member);
- d->receiverToDisconnectOnClose = receiver;
- d->memberToDisconnectOnClose = member;
- QDialog::open();
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_PRINTDIALOG
diff --git a/src/gui/dialogs/qabstractprintdialog.h b/src/gui/dialogs/qabstractprintdialog.h
deleted file mode 100644
index 02e7b0ea32..0000000000
--- a/src/gui/dialogs/qabstractprintdialog.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QABSTRACTPRINTDIALOG_H
-#define QABSTRACTPRINTDIALOG_H
-
-#include <QtGui/qdialog.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_PRINTER
-
-class QAbstractPrintDialogPrivate;
-class QPrinter;
-
-// ### Qt 5: remove this class
-class Q_GUI_EXPORT QAbstractPrintDialog : public QDialog
-{
- Q_DECLARE_PRIVATE(QAbstractPrintDialog)
- Q_OBJECT
-
-public:
- enum PrintRange {
- AllPages,
- Selection,
- PageRange,
- CurrentPage
- };
-
- enum PrintDialogOption {
- None = 0x0000, // obsolete
- PrintToFile = 0x0001,
- PrintSelection = 0x0002,
- PrintPageRange = 0x0004,
- PrintShowPageSize = 0x0008,
- PrintCollateCopies = 0x0010,
- DontUseSheet = 0x0020,
- PrintCurrentPage = 0x0040
- };
-
- Q_DECLARE_FLAGS(PrintDialogOptions, PrintDialogOption)
-
-#ifndef QT_NO_PRINTDIALOG
- explicit QAbstractPrintDialog(QPrinter *printer, QWidget *parent = 0);
- ~QAbstractPrintDialog();
-
- virtual int exec() = 0;
-
- // obsolete
- void addEnabledOption(PrintDialogOption option);
- void setEnabledOptions(PrintDialogOptions options);
- PrintDialogOptions enabledOptions() const;
- bool isOptionEnabled(PrintDialogOption option) const;
-
- void setOptionTabs(const QList<QWidget*> &tabs);
-
- void setPrintRange(PrintRange range);
- PrintRange printRange() const;
-
- void setMinMax(int min, int max);
- int minPage() const;
- int maxPage() const;
-
- void setFromTo(int fromPage, int toPage);
- int fromPage() const;
- int toPage() const;
-
- QPrinter *printer() const;
-
-protected:
- QAbstractPrintDialog(QAbstractPrintDialogPrivate &ptr, QPrinter *printer, QWidget *parent = 0);
-
-private:
- Q_DISABLE_COPY(QAbstractPrintDialog)
-
-#endif // QT_NO_PRINTDIALOG
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractPrintDialog::PrintDialogOptions)
-
-#endif // QT_NO_PRINTER
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QABSTRACTPRINTDIALOG_H
diff --git a/src/gui/dialogs/qabstractprintdialog_p.h b/src/gui/dialogs/qabstractprintdialog_p.h
deleted file mode 100644
index 4de34a2ec3..0000000000
--- a/src/gui/dialogs/qabstractprintdialog_p.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QABSTRACTPRINTDIALOG_P_H
-#define QABSTRACTPRINTDIALOG_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "private/qdialog_p.h"
-
-#ifndef QT_NO_PRINTDIALOG
-
-#include "QtGui/qabstractprintdialog.h"
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_PRINTER
-
-class QPrinter;
-class QPrinterPrivate;
-
-class QAbstractPrintDialogPrivate : public QDialogPrivate
-{
- Q_DECLARE_PUBLIC(QAbstractPrintDialog)
-
-public:
- QAbstractPrintDialogPrivate()
- : printer(0), pd(0), ownsPrinter(false)
- {
- }
-
- QPrinter *printer;
- QPrinterPrivate *pd;
- bool ownsPrinter;
- QPointer<QObject> receiverToDisconnectOnClose;
- QByteArray memberToDisconnectOnClose;
-
- virtual void setTabs(const QList<QWidget *> &) {}
- void setPrinter(QPrinter *newPrinter);
-};
-
-#endif //QT_NO_PRINTER
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_PRINTDIALOG
-
-#endif // QABSTRACTPRINTDIALOG_P_H
diff --git a/src/gui/dialogs/qcolordialog.cpp b/src/gui/dialogs/qcolordialog.cpp
deleted file mode 100644
index 94a54fe26c..0000000000
--- a/src/gui/dialogs/qcolordialog.cpp
+++ /dev/null
@@ -1,2114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qcolordialog_p.h"
-
-#ifndef QT_NO_COLORDIALOG
-
-#include "qapplication.h"
-#include "qdesktopwidget.h"
-#include "qdrawutil.h"
-#include "qevent.h"
-#include "qimage.h"
-#include "qlabel.h"
-#include "qlayout.h"
-#include "qlineedit.h"
-#include "qmenu.h"
-#include "qpainter.h"
-#include "qpixmap.h"
-#include "qpushbutton.h"
-#include "qsettings.h"
-#include "qstyle.h"
-#include "qstyleoption.h"
-#include "qvalidator.h"
-#include "qmime.h"
-#include "qspinbox.h"
-#include "qdialogbuttonbox.h"
-#include "private/qguiplatformplugin_p.h"
-
-#ifdef Q_WS_S60
-#include "private/qt_s60_p.h"
-#endif
-
-#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5)
-# define QT_SMALL_COLORDIALOG
-#endif
-
-QT_BEGIN_NAMESPACE
-
-//////////// QWellArray BEGIN
-
-struct QWellArrayData;
-
-class QWellArray : public QWidget
-{
- Q_OBJECT
- Q_PROPERTY(int selectedColumn READ selectedColumn)
- Q_PROPERTY(int selectedRow READ selectedRow)
-
-public:
- QWellArray(int rows, int cols, QWidget* parent=0);
- ~QWellArray() {}
- QString cellContent(int row, int col) const;
-
- int selectedColumn() const { return selCol; }
- int selectedRow() const { return selRow; }
-
- virtual void setCurrent(int row, int col);
- virtual void setSelected(int row, int col);
-
- QSize sizeHint() const;
-
- virtual void setCellBrush(int row, int col, const QBrush &);
- QBrush cellBrush(int row, int col);
-
- inline int cellWidth() const
- { return cellw; }
-
- inline int cellHeight() const
- { return cellh; }
-
- inline int rowAt(int y) const
- { return y / cellh; }
-
- inline int columnAt(int x) const
- { if (isRightToLeft()) return ncols - (x / cellw) - 1; return x / cellw; }
-
- inline int rowY(int row) const
- { return cellh * row; }
-
- inline int columnX(int column) const
- { if (isRightToLeft()) return cellw * (ncols - column - 1); return cellw * column; }
-
- inline int numRows() const
- { return nrows; }
-
- inline int numCols() const
- {return ncols; }
-
- inline QRect cellRect() const
- { return QRect(0, 0, cellw, cellh); }
-
- inline QSize gridSize() const
- { return QSize(ncols * cellw, nrows * cellh); }
-
- QRect cellGeometry(int row, int column)
- {
- QRect r;
- if (row >= 0 && row < nrows && column >= 0 && column < ncols)
- r.setRect(columnX(column), rowY(row), cellw, cellh);
- return r;
- }
-
- inline void updateCell(int row, int column) { update(cellGeometry(row, column)); }
-
-signals:
- void selected(int row, int col);
-
-protected:
- virtual void paintCell(QPainter *, int row, int col, const QRect&);
- virtual void paintCellContents(QPainter *, int row, int col, const QRect&);
-
- void mousePressEvent(QMouseEvent*);
- void mouseReleaseEvent(QMouseEvent*);
- void keyPressEvent(QKeyEvent*);
- void focusInEvent(QFocusEvent*);
- void focusOutEvent(QFocusEvent*);
- void paintEvent(QPaintEvent *);
-
-private:
- Q_DISABLE_COPY(QWellArray)
-
- int nrows;
- int ncols;
- int cellw;
- int cellh;
- int curRow;
- int curCol;
- int selRow;
- int selCol;
- QWellArrayData *d;
-};
-
-void QWellArray::paintEvent(QPaintEvent *e)
-{
- QRect r = e->rect();
- int cx = r.x();
- int cy = r.y();
- int ch = r.height();
- int cw = r.width();
- int colfirst = columnAt(cx);
- int collast = columnAt(cx + cw);
- int rowfirst = rowAt(cy);
- int rowlast = rowAt(cy + ch);
-
- if (isRightToLeft()) {
- int t = colfirst;
- colfirst = collast;
- collast = t;
- }
-
- QPainter painter(this);
- QPainter *p = &painter;
- QRect rect(0, 0, cellWidth(), cellHeight());
-
-
- if (collast < 0 || collast >= ncols)
- collast = ncols-1;
- if (rowlast < 0 || rowlast >= nrows)
- rowlast = nrows-1;
-
- // Go through the rows
- for (int r = rowfirst; r <= rowlast; ++r) {
- // get row position and height
- int rowp = rowY(r);
-
- // Go through the columns in the row r
- // if we know from where to where, go through [colfirst, collast],
- // else go through all of them
- for (int c = colfirst; c <= collast; ++c) {
- // get position and width of column c
- int colp = columnX(c);
- // Translate painter and draw the cell
- rect.translate(colp, rowp);
- paintCell(p, r, c, rect);
- rect.translate(-colp, -rowp);
- }
- }
-}
-
-struct QWellArrayData {
- QBrush *brush;
-};
-
-QWellArray::QWellArray(int rows, int cols, QWidget *parent)
- : QWidget(parent)
- ,nrows(rows), ncols(cols)
-{
- d = 0;
- setFocusPolicy(Qt::StrongFocus);
- cellw = 28;
- cellh = 24;
- curCol = 0;
- curRow = 0;
- selCol = -1;
- selRow = -1;
-}
-
-QSize QWellArray::sizeHint() const
-{
- ensurePolished();
- return gridSize().boundedTo(QSize(640, 480));
-}
-
-
-void QWellArray::paintCell(QPainter* p, int row, int col, const QRect &rect)
-{
- int b = 3; //margin
-
- const QPalette & g = palette();
- QStyleOptionFrame opt;
- int dfw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
- opt.lineWidth = dfw;
- opt.midLineWidth = 1;
- opt.rect = rect.adjusted(b, b, -b, -b);
- opt.palette = g;
- opt.state = QStyle::State_Enabled | QStyle::State_Sunken;
- style()->drawPrimitive(QStyle::PE_Frame, &opt, p, this);
- b += dfw;
-
- if ((row == curRow) && (col == curCol)) {
- if (hasFocus()) {
- QStyleOptionFocusRect opt;
- opt.palette = g;
- opt.rect = rect;
- opt.state = QStyle::State_None | QStyle::State_KeyboardFocusChange;
- style()->drawPrimitive(QStyle::PE_FrameFocusRect, &opt, p, this);
- }
- }
- paintCellContents(p, row, col, opt.rect.adjusted(dfw, dfw, -dfw, -dfw));
-}
-
-/*!
- Reimplement this function to change the contents of the well array.
- */
-void QWellArray::paintCellContents(QPainter *p, int row, int col, const QRect &r)
-{
- if (d) {
- p->fillRect(r, d->brush[row*numCols()+col]);
- } else {
- p->fillRect(r, Qt::white);
- p->setPen(Qt::black);
- p->drawLine(r.topLeft(), r.bottomRight());
- p->drawLine(r.topRight(), r.bottomLeft());
- }
-}
-
-void QWellArray::mousePressEvent(QMouseEvent *e)
-{
- // The current cell marker is set to the cell the mouse is pressed in
- QPoint pos = e->pos();
- setCurrent(rowAt(pos.y()), columnAt(pos.x()));
-}
-
-void QWellArray::mouseReleaseEvent(QMouseEvent * /* event */)
-{
- // The current cell marker is set to the cell the mouse is clicked in
- setSelected(curRow, curCol);
-}
-
-
-/*
- Sets the cell currently having the focus. This is not necessarily
- the same as the currently selected cell.
-*/
-
-void QWellArray::setCurrent(int row, int col)
-{
- if ((curRow == row) && (curCol == col))
- return;
-
- if (row < 0 || col < 0)
- row = col = -1;
-
- int oldRow = curRow;
- int oldCol = curCol;
-
- curRow = row;
- curCol = col;
-
- updateCell(oldRow, oldCol);
- updateCell(curRow, curCol);
-}
-
-/*
- Sets the currently selected cell to \a row, \a column. If \a row or
- \a column are less than zero, the current cell is unselected.
-
- Does not set the position of the focus indicator.
-*/
-void QWellArray::setSelected(int row, int col)
-{
- int oldRow = selRow;
- int oldCol = selCol;
-
- if (row < 0 || col < 0)
- row = col = -1;
-
- selCol = col;
- selRow = row;
-
- updateCell(oldRow, oldCol);
- updateCell(selRow, selCol);
- if (row >= 0)
- emit selected(row, col);
-
-#ifndef QT_NO_MENU
- if (isVisible() && qobject_cast<QMenu*>(parentWidget()))
- parentWidget()->close();
-#endif
-}
-
-void QWellArray::focusInEvent(QFocusEvent*)
-{
- updateCell(curRow, curCol);
-}
-
-void QWellArray::setCellBrush(int row, int col, const QBrush &b)
-{
- if (!d) {
- d = new QWellArrayData;
- int i = numRows()*numCols();
- d->brush = new QBrush[i];
- }
- if (row >= 0 && row < numRows() && col >= 0 && col < numCols())
- d->brush[row*numCols()+col] = b;
-}
-
-/*
- Returns the brush set for the cell at \a row, \a column. If no brush is
- set, Qt::NoBrush is returned.
-*/
-
-QBrush QWellArray::cellBrush(int row, int col)
-{
- if (d && row >= 0 && row < numRows() && col >= 0 && col < numCols())
- return d->brush[row*numCols()+col];
- return Qt::NoBrush;
-}
-
-
-
-/*!\reimp
-*/
-
-void QWellArray::focusOutEvent(QFocusEvent*)
-{
- updateCell(curRow, curCol);
-}
-
-/*\reimp
-*/
-void QWellArray::keyPressEvent(QKeyEvent* e)
-{
- switch(e->key()) { // Look at the key code
- case Qt::Key_Left: // If 'left arrow'-key,
- if(curCol > 0) // and cr't not in leftmost col
- setCurrent(curRow, curCol - 1); // set cr't to next left column
- break;
- case Qt::Key_Right: // Correspondingly...
- if(curCol < numCols()-1)
- setCurrent(curRow, curCol + 1);
- break;
- case Qt::Key_Up:
- if(curRow > 0)
- setCurrent(curRow - 1, curCol);
- break;
- case Qt::Key_Down:
- if(curRow < numRows()-1)
- setCurrent(curRow + 1, curCol);
- break;
-#if 0
- // bad idea that shouldn't have been implemented; very counterintuitive
- case Qt::Key_Return:
- case Qt::Key_Enter:
- /*
- ignore the key, so that the dialog get it, but still select
- the current row/col
- */
- e->ignore();
- // fallthrough intended
-#endif
- case Qt::Key_Space:
- setSelected(curRow, curCol);
- break;
- default: // If not an interesting key,
- e->ignore(); // we don't accept the event
- return;
- }
-
-}
-
-//////////// QWellArray END
-
-static bool initrgb = false;
-static QRgb stdrgb[6*8];
-static QRgb cusrgb[2*8];
-static bool customSet = false;
-
-
-static void initRGB()
-{
- if (initrgb)
- return;
- initrgb = true;
- int i = 0;
- for (int g = 0; g < 4; g++)
- for (int r = 0; r < 4; r++)
- for (int b = 0; b < 3; b++)
- stdrgb[i++] = qRgb(r * 255 / 3, g * 255 / 3, b * 255 / 2);
-
- for (i = 0; i < 2*8; i++)
- cusrgb[i] = 0xffffffff;
-}
-
-/*!
- Returns the number of custom colors supported by QColorDialog. All
- color dialogs share the same custom colors.
-*/
-int QColorDialog::customCount()
-{
- return 2 * 8;
-}
-
-/*!
- \since 4.5
-
- Returns the custom color at the given \a index as a QRgb value.
-*/
-QRgb QColorDialog::customColor(int index)
-{
- if (uint(index) >= uint(customCount()))
- return qRgb(255, 255, 255);
- initRGB();
- return cusrgb[index];
-}
-
-/*!
- Sets the custom color at \a index to the QRgb \a color value.
-
- \note This function does not apply to the Native Color Dialog on the Mac
- OS X platform. If you still require this function, use the
- QColorDialog::DontUseNativeDialog option.
-*/
-void QColorDialog::setCustomColor(int index, QRgb color)
-{
- if (uint(index) >= uint(customCount()))
- return;
- initRGB();
- customSet = true;
- cusrgb[index] = color;
-}
-
-/*!
- Sets the standard color at \a index to the QRgb \a color value.
-
- \note This function does not apply to the Native Color Dialog on the Mac
- OS X platform. If you still require this function, use the
- QColorDialog::DontUseNativeDialog option.
-*/
-
-void QColorDialog::setStandardColor(int index, QRgb color)
-{
- if (uint(index) >= uint(6 * 8))
- return;
- initRGB();
- stdrgb[index] = color;
-}
-
-static inline void rgb2hsv(QRgb rgb, int &h, int &s, int &v)
-{
- QColor c;
- c.setRgb(rgb);
- c.getHsv(&h, &s, &v);
-}
-
-class QColorWell : public QWellArray
-{
-public:
- QColorWell(QWidget *parent, int r, int c, QRgb *vals)
- :QWellArray(r, c, parent), values(vals), mousePressed(false), oldCurrent(-1, -1)
- { setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); }
-
-protected:
- void paintCellContents(QPainter *, int row, int col, const QRect&);
- void mousePressEvent(QMouseEvent *e);
- void mouseMoveEvent(QMouseEvent *e);
- void mouseReleaseEvent(QMouseEvent *e);
-#ifndef QT_NO_DRAGANDDROP
- void dragEnterEvent(QDragEnterEvent *e);
- void dragLeaveEvent(QDragLeaveEvent *e);
- void dragMoveEvent(QDragMoveEvent *e);
- void dropEvent(QDropEvent *e);
-#endif
-
-private:
- QRgb *values;
- bool mousePressed;
- QPoint pressPos;
- QPoint oldCurrent;
-
-};
-
-void QColorWell::paintCellContents(QPainter *p, int row, int col, const QRect &r)
-{
- int i = row + col*numRows();
- p->fillRect(r, QColor(values[i]));
-}
-
-void QColorWell::mousePressEvent(QMouseEvent *e)
-{
- oldCurrent = QPoint(selectedRow(), selectedColumn());
- QWellArray::mousePressEvent(e);
- mousePressed = true;
- pressPos = e->pos();
-}
-
-void QColorWell::mouseMoveEvent(QMouseEvent *e)
-{
- QWellArray::mouseMoveEvent(e);
-#ifndef QT_NO_DRAGANDDROP
- if (!mousePressed)
- return;
- if ((pressPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) {
- setCurrent(oldCurrent.x(), oldCurrent.y());
- int i = rowAt(pressPos.y()) + columnAt(pressPos.x()) * numRows();
- QColor col(values[i]);
- QMimeData *mime = new QMimeData;
- mime->setColorData(col);
- QPixmap pix(cellWidth(), cellHeight());
- pix.fill(col);
- QPainter p(&pix);
- p.drawRect(0, 0, pix.width() - 1, pix.height() - 1);
- p.end();
- QDrag *drg = new QDrag(this);
- drg->setMimeData(mime);
- drg->setPixmap(pix);
- mousePressed = false;
- drg->start();
- }
-#endif
-}
-
-#ifndef QT_NO_DRAGANDDROP
-void QColorWell::dragEnterEvent(QDragEnterEvent *e)
-{
- if (qvariant_cast<QColor>(e->mimeData()->colorData()).isValid())
- e->accept();
- else
- e->ignore();
-}
-
-void QColorWell::dragLeaveEvent(QDragLeaveEvent *)
-{
- if (hasFocus())
- parentWidget()->setFocus();
-}
-
-void QColorWell::dragMoveEvent(QDragMoveEvent *e)
-{
- if (qvariant_cast<QColor>(e->mimeData()->colorData()).isValid()) {
- setCurrent(rowAt(e->pos().y()), columnAt(e->pos().x()));
- e->accept();
- } else {
- e->ignore();
- }
-}
-
-void QColorWell::dropEvent(QDropEvent *e)
-{
- QColor col = qvariant_cast<QColor>(e->mimeData()->colorData());
- if (col.isValid()) {
- int i = rowAt(e->pos().y()) + columnAt(e->pos().x()) * numRows();
- values[i] = col.rgb();
- update();
- e->accept();
- } else {
- e->ignore();
- }
-}
-
-#endif // QT_NO_DRAGANDDROP
-
-void QColorWell::mouseReleaseEvent(QMouseEvent *e)
-{
- if (!mousePressed)
- return;
- QWellArray::mouseReleaseEvent(e);
- mousePressed = false;
-}
-
-class QColorPicker : public QFrame
-{
- Q_OBJECT
-public:
- QColorPicker(QWidget* parent);
- ~QColorPicker();
-
-public slots:
- void setCol(int h, int s);
-
-signals:
- void newCol(int h, int s);
-
-protected:
- QSize sizeHint() const;
- void paintEvent(QPaintEvent*);
- void mouseMoveEvent(QMouseEvent *);
- void mousePressEvent(QMouseEvent *);
- void resizeEvent(QResizeEvent *);
-
-private:
- int hue;
- int sat;
-
- QPoint colPt();
- int huePt(const QPoint &pt);
- int satPt(const QPoint &pt);
- void setCol(const QPoint &pt);
-
- QPixmap pix;
-};
-
-static int pWidth = 220;
-static int pHeight = 200;
-
-class QColorLuminancePicker : public QWidget
-{
- Q_OBJECT
-public:
- QColorLuminancePicker(QWidget* parent=0);
- ~QColorLuminancePicker();
-
-public slots:
- void setCol(int h, int s, int v);
- void setCol(int h, int s);
-
-signals:
- void newHsv(int h, int s, int v);
-
-protected:
- void paintEvent(QPaintEvent*);
- void mouseMoveEvent(QMouseEvent *);
- void mousePressEvent(QMouseEvent *);
-
-private:
- enum { foff = 3, coff = 4 }; //frame and contents offset
- int val;
- int hue;
- int sat;
-
- int y2val(int y);
- int val2y(int val);
- void setVal(int v);
-
- QPixmap *pix;
-};
-
-
-int QColorLuminancePicker::y2val(int y)
-{
- int d = height() - 2*coff - 1;
- return 255 - (y - coff)*255/d;
-}
-
-int QColorLuminancePicker::val2y(int v)
-{
- int d = height() - 2*coff - 1;
- return coff + (255-v)*d/255;
-}
-
-QColorLuminancePicker::QColorLuminancePicker(QWidget* parent)
- :QWidget(parent)
-{
- hue = 100; val = 100; sat = 100;
- pix = 0;
- // setAttribute(WA_NoErase, true);
-}
-
-QColorLuminancePicker::~QColorLuminancePicker()
-{
- delete pix;
-}
-
-void QColorLuminancePicker::mouseMoveEvent(QMouseEvent *m)
-{
- setVal(y2val(m->y()));
-}
-void QColorLuminancePicker::mousePressEvent(QMouseEvent *m)
-{
- setVal(y2val(m->y()));
-}
-
-void QColorLuminancePicker::setVal(int v)
-{
- if (val == v)
- return;
- val = qMax(0, qMin(v,255));
- delete pix; pix=0;
- repaint();
- emit newHsv(hue, sat, val);
-}
-
-//receives from a hue,sat chooser and relays.
-void QColorLuminancePicker::setCol(int h, int s)
-{
- setCol(h, s, val);
- emit newHsv(h, s, val);
-}
-
-void QColorLuminancePicker::paintEvent(QPaintEvent *)
-{
- int w = width() - 5;
-
- QRect r(0, foff, w, height() - 2*foff);
- int wi = r.width() - 2;
- int hi = r.height() - 2;
- if (!pix || pix->height() != hi || pix->width() != wi) {
- delete pix;
- QImage img(wi, hi, QImage::Format_RGB32);
- int y;
- uint *pixel = (uint *) img.scanLine(0);
- for (y = 0; y < hi; y++) {
- const uint *end = pixel + wi;
- while (pixel < end) {
- QColor c;
- c.setHsv(hue, sat, y2val(y+coff));
- *pixel = c.rgb();
- ++pixel;
- }
- }
- pix = new QPixmap(QPixmap::fromImage(img));
- }
- QPainter p(this);
- p.drawPixmap(1, coff, *pix);
- const QPalette &g = palette();
- qDrawShadePanel(&p, r, g, true);
- p.setPen(g.foreground().color());
- p.setBrush(g.foreground());
- QPolygon a;
- int y = val2y(val);
- a.setPoints(3, w, y, w+5, y+5, w+5, y-5);
- p.eraseRect(w, 0, 5, height());
- p.drawPolygon(a);
-}
-
-void QColorLuminancePicker::setCol(int h, int s , int v)
-{
- val = v;
- hue = h;
- sat = s;
- delete pix; pix=0;
- repaint();
-}
-
-QPoint QColorPicker::colPt()
-{
- QRect r = contentsRect();
- return QPoint((360 - hue) * (r.width() - 1) / 360, (255 - sat) * (r.height() - 1) / 255);
-}
-
-int QColorPicker::huePt(const QPoint &pt)
-{
- QRect r = contentsRect();
- return 360 - pt.x() * 360 / (r.width() - 1);
-}
-
-int QColorPicker::satPt(const QPoint &pt)
-{
- QRect r = contentsRect();
- return 255 - pt.y() * 255 / (r.height() - 1);
-}
-
-void QColorPicker::setCol(const QPoint &pt)
-{
- setCol(huePt(pt), satPt(pt));
-}
-
-QColorPicker::QColorPicker(QWidget* parent)
- : QFrame(parent)
-{
- hue = 0; sat = 0;
- setCol(150, 255);
-
- setAttribute(Qt::WA_NoSystemBackground);
- setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed) );
-}
-
-QColorPicker::~QColorPicker()
-{
-}
-
-QSize QColorPicker::sizeHint() const
-{
- return QSize(pWidth + 2*frameWidth(), pHeight + 2*frameWidth());
-}
-
-void QColorPicker::setCol(int h, int s)
-{
- int nhue = qMin(qMax(0,h), 359);
- int nsat = qMin(qMax(0,s), 255);
- if (nhue == hue && nsat == sat)
- return;
-
- QRect r(colPt(), QSize(20,20));
- hue = nhue; sat = nsat;
- r = r.united(QRect(colPt(), QSize(20,20)));
- r.translate(contentsRect().x()-9, contentsRect().y()-9);
- // update(r);
- repaint(r);
-}
-
-void QColorPicker::mouseMoveEvent(QMouseEvent *m)
-{
- QPoint p = m->pos() - contentsRect().topLeft();
- setCol(p);
- emit newCol(hue, sat);
-}
-
-void QColorPicker::mousePressEvent(QMouseEvent *m)
-{
- QPoint p = m->pos() - contentsRect().topLeft();
- setCol(p);
- emit newCol(hue, sat);
-}
-
-void QColorPicker::paintEvent(QPaintEvent* )
-{
- QPainter p(this);
- drawFrame(&p);
- QRect r = contentsRect();
-
- p.drawPixmap(r.topLeft(), pix);
- QPoint pt = colPt() + r.topLeft();
- p.setPen(Qt::black);
-
- p.fillRect(pt.x()-9, pt.y(), 20, 2, Qt::black);
- p.fillRect(pt.x(), pt.y()-9, 2, 20, Qt::black);
-
-}
-
-void QColorPicker::resizeEvent(QResizeEvent *ev)
-{
- QFrame::resizeEvent(ev);
-
- int w = width() - frameWidth() * 2;
- int h = height() - frameWidth() * 2;
- QImage img(w, h, QImage::Format_RGB32);
- int x, y;
- uint *pixel = (uint *) img.scanLine(0);
- for (y = 0; y < h; y++) {
- const uint *end = pixel + w;
- x = 0;
- while (pixel < end) {
- QPoint p(x, y);
- QColor c;
- c.setHsv(huePt(p), satPt(p), 200);
- *pixel = c.rgb();
- ++pixel;
- ++x;
- }
- }
- pix = QPixmap::fromImage(img);
-}
-
-
-class QColSpinBox : public QSpinBox
-{
-public:
- QColSpinBox(QWidget *parent)
- : QSpinBox(parent) { setRange(0, 255); }
- void setValue(int i) {
- bool block = signalsBlocked();
- blockSignals(true);
- QSpinBox::setValue(i);
- blockSignals(block);
- }
-};
-
-class QColorShowLabel;
-
-class QColorShower : public QWidget
-{
- Q_OBJECT
-public:
- QColorShower(QColorDialog *parent);
-
- //things that don't emit signals
- void setHsv(int h, int s, int v);
-
- int currentAlpha() const
- { return (colorDialog->options() & QColorDialog::ShowAlphaChannel) ? alphaEd->value() : 255; }
- void setCurrentAlpha(int a) { alphaEd->setValue(a); rgbEd(); }
- void showAlpha(bool b);
- bool isAlphaVisible() const;
-
- QRgb currentColor() const { return curCol; }
- QColor currentQColor() const { return curQColor; }
- void retranslateStrings();
- void updateQColor();
-
-public slots:
- void setRgb(QRgb rgb);
-
-signals:
- void newCol(QRgb rgb);
- void currentColorChanged(const QColor &color);
-
-private slots:
- void rgbEd();
- void hsvEd();
-private:
- void showCurrentColor();
- int hue, sat, val;
- QRgb curCol;
- QColor curQColor;
- QLabel *lblHue;
- QLabel *lblSat;
- QLabel *lblVal;
- QLabel *lblRed;
- QLabel *lblGreen;
- QLabel *lblBlue;
- QColSpinBox *hEd;
- QColSpinBox *sEd;
- QColSpinBox *vEd;
- QColSpinBox *rEd;
- QColSpinBox *gEd;
- QColSpinBox *bEd;
- QColSpinBox *alphaEd;
- QLabel *alphaLab;
- QColorShowLabel *lab;
- bool rgbOriginal;
- QColorDialog *colorDialog;
-
- friend class QColorDialog;
- friend class QColorDialogPrivate;
-};
-
-class QColorShowLabel : public QFrame
-{
- Q_OBJECT
-
-public:
- QColorShowLabel(QWidget *parent) : QFrame(parent) {
- setFrameStyle(QFrame::Panel|QFrame::Sunken);
- setAcceptDrops(true);
- mousePressed = false;
- }
- void setColor(QColor c) { col = c; }
-
-signals:
- void colorDropped(QRgb);
-
-protected:
- void paintEvent(QPaintEvent *);
- void mousePressEvent(QMouseEvent *e);
- void mouseMoveEvent(QMouseEvent *e);
- void mouseReleaseEvent(QMouseEvent *e);
-#ifndef QT_NO_DRAGANDDROP
- void dragEnterEvent(QDragEnterEvent *e);
- void dragLeaveEvent(QDragLeaveEvent *e);
- void dropEvent(QDropEvent *e);
-#endif
-
-private:
- QColor col;
- bool mousePressed;
- QPoint pressPos;
-};
-
-void QColorShowLabel::paintEvent(QPaintEvent *e)
-{
- QPainter p(this);
- drawFrame(&p);
- p.fillRect(contentsRect()&e->rect(), col);
-}
-
-void QColorShower::showAlpha(bool b)
-{
- alphaLab->setVisible(b);
- alphaEd->setVisible(b);
-}
-
-inline bool QColorShower::isAlphaVisible() const
-{
- return alphaLab->isVisible();
-}
-
-void QColorShowLabel::mousePressEvent(QMouseEvent *e)
-{
- mousePressed = true;
- pressPos = e->pos();
-}
-
-void QColorShowLabel::mouseMoveEvent(QMouseEvent *e)
-{
-#ifdef QT_NO_DRAGANDDROP
- Q_UNUSED(e);
-#else
- if (!mousePressed)
- return;
- if ((pressPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) {
- QMimeData *mime = new QMimeData;
- mime->setColorData(col);
- QPixmap pix(30, 20);
- pix.fill(col);
- QPainter p(&pix);
- p.drawRect(0, 0, pix.width() - 1, pix.height() - 1);
- p.end();
- QDrag *drg = new QDrag(this);
- drg->setMimeData(mime);
- drg->setPixmap(pix);
- mousePressed = false;
- drg->start();
- }
-#endif
-}
-
-#ifndef QT_NO_DRAGANDDROP
-void QColorShowLabel::dragEnterEvent(QDragEnterEvent *e)
-{
- if (qvariant_cast<QColor>(e->mimeData()->colorData()).isValid())
- e->accept();
- else
- e->ignore();
-}
-
-void QColorShowLabel::dragLeaveEvent(QDragLeaveEvent *)
-{
-}
-
-void QColorShowLabel::dropEvent(QDropEvent *e)
-{
- QColor color = qvariant_cast<QColor>(e->mimeData()->colorData());
- if (color.isValid()) {
- col = color;
- repaint();
- emit colorDropped(col.rgb());
- e->accept();
- } else {
- e->ignore();
- }
-}
-#endif // QT_NO_DRAGANDDROP
-
-void QColorShowLabel::mouseReleaseEvent(QMouseEvent *)
-{
- if (!mousePressed)
- return;
- mousePressed = false;
-}
-
-QColorShower::QColorShower(QColorDialog *parent)
- : QWidget(parent)
-{
- colorDialog = parent;
-
- curCol = qRgb(255, 255, 255);
- curQColor = Qt::white;
-
- QGridLayout *gl = new QGridLayout(this);
- gl->setMargin(gl->spacing());
- lab = new QColorShowLabel(this);
-
-#ifdef QT_SMALL_COLORDIALOG
-# ifdef Q_WS_S60
- const bool nonTouchUI = !S60->hasTouchscreen;
-# elif defined Q_WS_MAEMO_5
- const bool nonTouchUI = false;
-# endif
-#endif
-
-#ifndef Q_WS_WINCE
-#ifdef QT_SMALL_COLORDIALOG
- lab->setMinimumHeight(60);
-#endif
- lab->setMinimumWidth(60);
-#else
- lab->setMinimumWidth(20);
-#endif
-
-// In S60, due to small screen and different screen layouts need to re-arrange the widgets.
-// For QVGA screens only the comboboxes and color label are visible.
-// For nHD screens only color and luminence pickers and color label are visible.
-#if !defined(QT_SMALL_COLORDIALOG)
- gl->addWidget(lab, 0, 0, -1, 1);
-#else
- if (nonTouchUI)
- gl->addWidget(lab, 0, 0, 1, -1);
- else
- gl->addWidget(lab, 0, 0, -1, 1);
-#endif
- connect(lab, SIGNAL(colorDropped(QRgb)), this, SIGNAL(newCol(QRgb)));
- connect(lab, SIGNAL(colorDropped(QRgb)), this, SLOT(setRgb(QRgb)));
-
- hEd = new QColSpinBox(this);
- hEd->setRange(0, 359);
- lblHue = new QLabel(this);
-#ifndef QT_NO_SHORTCUT
- lblHue->setBuddy(hEd);
-#endif
- lblHue->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
-#if !defined(QT_SMALL_COLORDIALOG)
- gl->addWidget(lblHue, 0, 1);
- gl->addWidget(hEd, 0, 2);
-#else
- if (nonTouchUI) {
- gl->addWidget(lblHue, 1, 0);
- gl->addWidget(hEd, 2, 0);
- } else {
- lblHue->hide();
- hEd->hide();
- }
-#endif
-
- sEd = new QColSpinBox(this);
- lblSat = new QLabel(this);
-#ifndef QT_NO_SHORTCUT
- lblSat->setBuddy(sEd);
-#endif
- lblSat->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
-#if !defined(QT_SMALL_COLORDIALOG)
- gl->addWidget(lblSat, 1, 1);
- gl->addWidget(sEd, 1, 2);
-#else
- if (nonTouchUI) {
- gl->addWidget(lblSat, 1, 1);
- gl->addWidget(sEd, 2, 1);
- } else {
- lblSat->hide();
- sEd->hide();
- }
-#endif
-
- vEd = new QColSpinBox(this);
- lblVal = new QLabel(this);
-#ifndef QT_NO_SHORTCUT
- lblVal->setBuddy(vEd);
-#endif
- lblVal->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
-#if !defined(QT_SMALL_COLORDIALOG)
- gl->addWidget(lblVal, 2, 1);
- gl->addWidget(vEd, 2, 2);
-#else
- if (nonTouchUI) {
- gl->addWidget(lblVal, 1, 2);
- gl->addWidget(vEd, 2, 2);
- } else {
- lblVal->hide();
- vEd->hide();
- }
-#endif
-
- rEd = new QColSpinBox(this);
- lblRed = new QLabel(this);
-#ifndef QT_NO_SHORTCUT
- lblRed->setBuddy(rEd);
-#endif
- lblRed->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
-#if !defined(QT_SMALL_COLORDIALOG)
- gl->addWidget(lblRed, 0, 3);
- gl->addWidget(rEd, 0, 4);
-#else
- if (nonTouchUI) {
- gl->addWidget(lblRed, 3, 0);
- gl->addWidget(rEd, 4, 0);
- } else {
- lblRed->hide();
- rEd->hide();
- }
-#endif
-
- gEd = new QColSpinBox(this);
- lblGreen = new QLabel(this);
-#ifndef QT_NO_SHORTCUT
- lblGreen->setBuddy(gEd);
-#endif
- lblGreen->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
-#if !defined(QT_SMALL_COLORDIALOG)
- gl->addWidget(lblGreen, 1, 3);
- gl->addWidget(gEd, 1, 4);
-#else
- if (nonTouchUI) {
- gl->addWidget(lblGreen, 3, 1);
- gl->addWidget(gEd, 4, 1);
- } else {
- lblGreen->hide();
- gEd->hide();
- }
-#endif
-
- bEd = new QColSpinBox(this);
- lblBlue = new QLabel(this);
-#ifndef QT_NO_SHORTCUT
- lblBlue->setBuddy(bEd);
-#endif
- lblBlue->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
-#if !defined(QT_SMALL_COLORDIALOG)
- gl->addWidget(lblBlue, 2, 3);
- gl->addWidget(bEd, 2, 4);
-#else
- if (nonTouchUI) {
- gl->addWidget(lblBlue, 3, 2);
- gl->addWidget(bEd, 4, 2);
- } else {
- lblBlue->hide();
- bEd->hide();
- }
-#endif
-
- alphaEd = new QColSpinBox(this);
- alphaLab = new QLabel(this);
-#ifndef QT_NO_SHORTCUT
- alphaLab->setBuddy(alphaEd);
-#endif
- alphaLab->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
-#if !defined(QT_SMALL_COLORDIALOG)
- gl->addWidget(alphaLab, 3, 1, 1, 3);
- gl->addWidget(alphaEd, 3, 4);
-#else
- if (nonTouchUI) {
- gl->addWidget(alphaLab, 1, 3, 3, 1);
- gl->addWidget(alphaEd, 4, 3);
- } else {
- alphaLab->hide();
- alphaEd->hide();
- }
-#endif
- alphaEd->hide();
- alphaLab->hide();
-
- connect(hEd, SIGNAL(valueChanged(int)), this, SLOT(hsvEd()));
- connect(sEd, SIGNAL(valueChanged(int)), this, SLOT(hsvEd()));
- connect(vEd, SIGNAL(valueChanged(int)), this, SLOT(hsvEd()));
-
- connect(rEd, SIGNAL(valueChanged(int)), this, SLOT(rgbEd()));
- connect(gEd, SIGNAL(valueChanged(int)), this, SLOT(rgbEd()));
- connect(bEd, SIGNAL(valueChanged(int)), this, SLOT(rgbEd()));
- connect(alphaEd, SIGNAL(valueChanged(int)), this, SLOT(rgbEd()));
-
- retranslateStrings();
-}
-
-inline QRgb QColorDialogPrivate::currentColor() const { return cs->currentColor(); }
-inline int QColorDialogPrivate::currentAlpha() const { return cs->currentAlpha(); }
-inline void QColorDialogPrivate::setCurrentAlpha(int a) { cs->setCurrentAlpha(a); }
-inline void QColorDialogPrivate::showAlpha(bool b) { cs->showAlpha(b); }
-inline bool QColorDialogPrivate::isAlphaVisible() const { return cs->isAlphaVisible(); }
-
-QColor QColorDialogPrivate::currentQColor() const
-{
- return cs->currentQColor();
-}
-
-void QColorShower::showCurrentColor()
-{
- lab->setColor(currentColor());
- lab->repaint();
-}
-
-void QColorShower::rgbEd()
-{
- rgbOriginal = true;
- curCol = qRgba(rEd->value(), gEd->value(), bEd->value(), currentAlpha());
-
- rgb2hsv(currentColor(), hue, sat, val);
-
- hEd->setValue(hue);
- sEd->setValue(sat);
- vEd->setValue(val);
-
- showCurrentColor();
- emit newCol(currentColor());
- updateQColor();
-}
-
-void QColorShower::hsvEd()
-{
- rgbOriginal = false;
- hue = hEd->value();
- sat = sEd->value();
- val = vEd->value();
-
- QColor c;
- c.setHsv(hue, sat, val);
- curCol = c.rgb();
-
- rEd->setValue(qRed(currentColor()));
- gEd->setValue(qGreen(currentColor()));
- bEd->setValue(qBlue(currentColor()));
-
- showCurrentColor();
- emit newCol(currentColor());
- updateQColor();
-}
-
-void QColorShower::setRgb(QRgb rgb)
-{
- rgbOriginal = true;
- curCol = rgb;
-
- rgb2hsv(currentColor(), hue, sat, val);
-
- hEd->setValue(hue);
- sEd->setValue(sat);
- vEd->setValue(val);
-
- rEd->setValue(qRed(currentColor()));
- gEd->setValue(qGreen(currentColor()));
- bEd->setValue(qBlue(currentColor()));
-
- showCurrentColor();
- updateQColor();
-}
-
-void QColorShower::setHsv(int h, int s, int v)
-{
- if (h < -1 || (uint)s > 255 || (uint)v > 255)
- return;
-
- rgbOriginal = false;
- hue = h; val = v; sat = s;
- QColor c;
- c.setHsv(hue, sat, val);
- curCol = c.rgb();
-
- hEd->setValue(hue);
- sEd->setValue(sat);
- vEd->setValue(val);
-
- rEd->setValue(qRed(currentColor()));
- gEd->setValue(qGreen(currentColor()));
- bEd->setValue(qBlue(currentColor()));
-
- showCurrentColor();
- updateQColor();
-}
-
-void QColorShower::retranslateStrings()
-{
- lblHue->setText(QColorDialog::tr("Hu&e:"));
- lblSat->setText(QColorDialog::tr("&Sat:"));
- lblVal->setText(QColorDialog::tr("&Val:"));
- lblRed->setText(QColorDialog::tr("&Red:"));
- lblGreen->setText(QColorDialog::tr("&Green:"));
- lblBlue->setText(QColorDialog::tr("Bl&ue:"));
- alphaLab->setText(QColorDialog::tr("A&lpha channel:"));
-}
-
-void QColorShower::updateQColor()
-{
- QColor oldQColor(curQColor);
- curQColor.setRgba(qRgba(qRed(curCol), qGreen(curCol), qBlue(curCol), currentAlpha()));
- if (curQColor != oldQColor)
- emit currentColorChanged(curQColor);
-}
-
-//sets all widgets to display h,s,v
-void QColorDialogPrivate::_q_newHsv(int h, int s, int v)
-{
- cs->setHsv(h, s, v);
- cp->setCol(h, s);
- lp->setCol(h, s, v);
-}
-
-//sets all widgets to display rgb
-void QColorDialogPrivate::setCurrentColor(QRgb rgb)
-{
- cs->setRgb(rgb);
- _q_newColorTypedIn(rgb);
-}
-
-// hack; doesn't keep curCol in sync, so use with care
-void QColorDialogPrivate::setCurrentQColor(const QColor &color)
-{
- Q_Q(QColorDialog);
- if (cs->curQColor != color) {
- cs->curQColor = color;
- emit q->currentColorChanged(color);
- }
-}
-
-bool QColorDialogPrivate::selectColor(const QColor &col)
-{
- QRgb color = col.rgb();
- int i = 0, j = 0;
- // Check standard colors
- if (standard) {
- for (i = 0; i < 6; i++) {
- for (j = 0; j < 8; j++) {
- if (color == stdrgb[i + j*6]) {
- _q_newStandard(i, j);
- standard->setCurrent(i, j);
- standard->setSelected(i, j);
- standard->setFocus();
- return true;
- }
- }
- }
- }
- // Check custom colors
- if (custom) {
- for (i = 0; i < 2; i++) {
- for (j = 0; j < 8; j++) {
- if (color == cusrgb[i + j*2]) {
- _q_newCustom(i, j);
- custom->setCurrent(i, j);
- custom->setSelected(i, j);
- custom->setFocus();
- return true;
- }
- }
- }
- }
- return false;
-}
-
-//sets all widgets except cs to display rgb
-void QColorDialogPrivate::_q_newColorTypedIn(QRgb rgb)
-{
- int h, s, v;
- rgb2hsv(rgb, h, s, v);
- cp->setCol(h, s);
- lp->setCol(h, s, v);
-}
-
-void QColorDialogPrivate::_q_newCustom(int r, int c)
-{
- int i = r+2*c;
- setCurrentColor(cusrgb[i]);
- nextCust = i;
- if (standard)
- standard->setSelected(-1,-1);
-}
-
-void QColorDialogPrivate::_q_newStandard(int r, int c)
-{
- setCurrentColor(stdrgb[r+c*6]);
- if (custom)
- custom->setSelected(-1,-1);
-}
-
-void QColorDialogPrivate::init(const QColor &initial)
-{
- Q_Q(QColorDialog);
-
- q->setSizeGripEnabled(false);
- q->setWindowTitle(QColorDialog::tr("Select Color"));
-
- nativeDialogInUse = false;
-
- nextCust = 0;
- QVBoxLayout *mainLay = new QVBoxLayout(q);
- // there's nothing in this dialog that benefits from sizing up
- mainLay->setSizeConstraint(QLayout::SetFixedSize);
-
- QHBoxLayout *topLay = new QHBoxLayout();
- mainLay->addLayout(topLay);
-
- leftLay = 0;
-
-#if defined(Q_WS_WINCE) || defined(QT_SMALL_COLORDIALOG)
- smallDisplay = true;
- const int lumSpace = 20;
-#else
- // small displays (e.g. PDAs) cannot fit the full color dialog,
- // so just use the color picker.
- smallDisplay = (QApplication::desktop()->width() < 480 || QApplication::desktop()->height() < 350);
- const int lumSpace = topLay->spacing() / 2;
-#endif
-
- if (!smallDisplay) {
- leftLay = new QVBoxLayout;
- topLay->addLayout(leftLay);
- }
-
- initRGB();
-
-#ifndef QT_NO_SETTINGS
- if (!customSet) {
- QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
- for (int i = 0; i < 2*8; ++i) {
- QVariant v = settings.value(QLatin1String("Qt/customColors/") + QString::number(i));
- if (v.isValid()) {
- QRgb rgb = v.toUInt();
- cusrgb[i] = rgb;
- }
- }
- }
-#endif
-
-#if defined(QT_SMALL_COLORDIALOG)
-# if defined(Q_WS_S60)
- const bool nonTouchUI = !S60->hasTouchscreen;
-# elif defined(Q_WS_MAEMO_5)
- const bool nonTouchUI = false;
-# endif
-#endif
-
- if (!smallDisplay) {
- standard = new QColorWell(q, 6, 8, stdrgb);
- lblBasicColors = new QLabel(q);
-#ifndef QT_NO_SHORTCUT
- lblBasicColors->setBuddy(standard);
-#endif
- q->connect(standard, SIGNAL(selected(int,int)), SLOT(_q_newStandard(int,int)));
- leftLay->addWidget(lblBasicColors);
- leftLay->addWidget(standard);
-
-#if !defined(Q_WS_WINCE)
- leftLay->addStretch();
-#endif
-
- custom = new QColorWell(q, 2, 8, cusrgb);
- custom->setAcceptDrops(true);
-
- q->connect(custom, SIGNAL(selected(int,int)), SLOT(_q_newCustom(int,int)));
- lblCustomColors = new QLabel(q);
-#ifndef QT_NO_SHORTCUT
- lblCustomColors->setBuddy(custom);
-#endif
- leftLay->addWidget(lblCustomColors);
- leftLay->addWidget(custom);
-
- addCusBt = new QPushButton(q);
- QObject::connect(addCusBt, SIGNAL(clicked()), q, SLOT(_q_addCustom()));
- leftLay->addWidget(addCusBt);
- } else {
- // better color picker size for small displays
-#if defined(QT_SMALL_COLORDIALOG)
- QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size();
- pWidth = pHeight = qMin(screenSize.width(), screenSize.height());
- pHeight -= 20;
- if(screenSize.height() > screenSize.width())
- pWidth -= 20;
-#else
- pWidth = 150;
- pHeight = 100;
-#endif
- custom = 0;
- standard = 0;
- }
-
- QVBoxLayout *rightLay = new QVBoxLayout;
- topLay->addLayout(rightLay);
-
- QHBoxLayout *pickLay = new QHBoxLayout;
- rightLay->addLayout(pickLay);
-
- QVBoxLayout *cLay = new QVBoxLayout;
- pickLay->addLayout(cLay);
- cp = new QColorPicker(q);
-
- cp->setFrameStyle(QFrame::Panel + QFrame::Sunken);
-
-#if defined(QT_SMALL_COLORDIALOG)
- if (!nonTouchUI) {
- pickLay->addWidget(cp);
- cLay->addSpacing(lumSpace);
- } else {
- cp->hide();
- }
-#else
- cLay->addSpacing(lumSpace);
- cLay->addWidget(cp);
-#endif
- cLay->addSpacing(lumSpace);
-
- lp = new QColorLuminancePicker(q);
-#if defined(QT_SMALL_COLORDIALOG)
- QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size();
- const int minDimension = qMin(screenSize.height(), screenSize.width());
- //set picker to be finger-usable
- int pickerWidth = !nonTouchUI ? minDimension/9 : minDimension/12;
- lp->setFixedWidth(pickerWidth);
- if (!nonTouchUI)
- pickLay->addWidget(lp);
- else
- lp->hide();
-#else
- lp->setFixedWidth(20);
- pickLay->addWidget(lp);
-#endif
-
- QObject::connect(cp, SIGNAL(newCol(int,int)), lp, SLOT(setCol(int,int)));
- QObject::connect(lp, SIGNAL(newHsv(int,int,int)), q, SLOT(_q_newHsv(int,int,int)));
-
- rightLay->addStretch();
-
- cs = new QColorShower(q);
- QObject::connect(cs, SIGNAL(newCol(QRgb)), q, SLOT(_q_newColorTypedIn(QRgb)));
- QObject::connect(cs, SIGNAL(currentColorChanged(QColor)),
- q, SIGNAL(currentColorChanged(QColor)));
-#if defined(QT_SMALL_COLORDIALOG)
- if (!nonTouchUI)
- pWidth -= cp->size().width();
- topLay->addWidget(cs);
-#else
- rightLay->addWidget(cs);
-#endif
-
- buttons = new QDialogButtonBox(q);
- mainLay->addWidget(buttons);
-
- ok = buttons->addButton(QDialogButtonBox::Ok);
- QObject::connect(ok, SIGNAL(clicked()), q, SLOT(accept()));
- ok->setDefault(true);
- cancel = buttons->addButton(QDialogButtonBox::Cancel);
- QObject::connect(cancel, SIGNAL(clicked()), q, SLOT(reject()));
-
- retranslateStrings();
-
-#ifdef Q_WS_MAC
- delegate = 0;
-#endif
-
- q->setCurrentColor(initial);
-}
-
-void QColorDialogPrivate::_q_addCustom()
-{
- cusrgb[nextCust] = cs->currentColor();
- if (custom)
- custom->update();
- nextCust = (nextCust+1) % 16;
-}
-
-void QColorDialogPrivate::retranslateStrings()
-{
- if (!smallDisplay) {
- lblBasicColors->setText(QColorDialog::tr("&Basic colors"));
- lblCustomColors->setText(QColorDialog::tr("&Custom colors"));
- addCusBt->setText(QColorDialog::tr("&Add to Custom Colors"));
- }
-
- cs->retranslateStrings();
-}
-
-static const Qt::WindowFlags DefaultWindowFlags =
- Qt::Dialog | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint
- | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint;
-
-/*!
- \class QColorDialog
- \brief The QColorDialog class provides a dialog widget for specifying colors.
-
- \ingroup standard-dialogs
-
- The color dialog's function is to allow users to choose colors.
- For example, you might use this in a drawing program to allow the
- user to set the brush color.
-
- The static functions provide modal color dialogs.
- \omit
- If you require a modeless dialog, use the QColorDialog constructor.
- \endomit
-
- The static getColor() function shows the dialog, and allows the user to
- specify a color. This function can also be used to let users choose a
- color with a level of transparency: pass the ShowAlphaChannel option as
- an additional argument.
-
- The user can store customCount() different custom colors. The
- custom colors are shared by all color dialogs, and remembered
- during the execution of the program. Use setCustomColor() to set
- the custom colors, and use customColor() to get them.
-
- Additional widgets that allow users to pick colors are available
- as \l{Qt Solutions}.
-
- The \l{dialogs/standarddialogs}{Standard Dialogs} example shows
- how to use QColorDialog as well as other built-in Qt dialogs.
-
- \image plastique-colordialog.png A color dialog in the Plastique widget style.
-
- \sa QColor, QFileDialog, QPrintDialog, QFontDialog, {Standard Dialogs Example}
-*/
-
-/*!
- \since 4.5
-
- Constructs a color dialog with the given \a parent.
-*/
-QColorDialog::QColorDialog(QWidget *parent)
- : QDialog(*new QColorDialogPrivate, parent, DefaultWindowFlags)
-{
- Q_D(QColorDialog);
- d->init(Qt::white);
-}
-
-/*!
- \since 4.5
-
- Constructs a color dialog with the given \a parent and specified
- \a initial color.
-*/
-QColorDialog::QColorDialog(const QColor &initial, QWidget *parent)
- : QDialog(*new QColorDialogPrivate, parent, DefaultWindowFlags)
-{
- Q_D(QColorDialog);
- d->init(initial);
-}
-
-/*!
- \property QColorDialog::currentColor
- \brief the currently selected color in the dialog
-*/
-
-void QColorDialog::setCurrentColor(const QColor &color)
-{
- Q_D(QColorDialog);
- d->setCurrentColor(color.rgb());
- d->selectColor(color);
- d->setCurrentAlpha(color.alpha());
-
-#ifdef Q_WS_MAC
- d->setCurrentQColor(color);
- d->setCocoaPanelColor(color);
-#endif
- if (d->nativeDialogInUse)
- qt_guiPlatformPlugin()->colorDialogSetCurrentColor(this, color);
-}
-
-QColor QColorDialog::currentColor() const
-{
- Q_D(const QColorDialog);
- return d->currentQColor();
-}
-
-
-/*!
- Returns the color that the user selected by clicking the \gui{OK}
- or equivalent button.
-
- \note This color is not always the same as the color held by the
- \l currentColor property since the user can choose different colors
- before finally selecting the one to use.
-*/
-QColor QColorDialog::selectedColor() const
-{
- Q_D(const QColorDialog);
- return d->selectedQColor;
-}
-
-/*!
- Sets the given \a option to be enabled if \a on is true;
- otherwise, clears the given \a option.
-
- \sa options, testOption()
-*/
-void QColorDialog::setOption(ColorDialogOption option, bool on)
-{
- Q_D(QColorDialog);
- if (!(d->opts & option) != !on)
- setOptions(d->opts ^ option);
-}
-
-/*!
- \since 4.5
-
- Returns true if the given \a option is enabled; otherwise, returns
- false.
-
- \sa options, setOption()
-*/
-bool QColorDialog::testOption(ColorDialogOption option) const
-{
- Q_D(const QColorDialog);
- return (d->opts & option) != 0;
-}
-
-/*!
- \property QColorDialog::options
- \brief the various options that affect the look and feel of the dialog
-
- By default, all options are disabled.
-
- Options should be set before showing the dialog. Setting them while the
- dialog is visible is not guaranteed to have an immediate effect on the
- dialog (depending on the option and on the platform).
-
- \sa setOption(), testOption()
-*/
-void QColorDialog::setOptions(ColorDialogOptions options)
-{
- Q_D(QColorDialog);
-
- ColorDialogOptions changed = (options ^ d->opts);
- if (!changed)
- return;
-
- d->opts = options;
- d->buttons->setVisible(!(options & NoButtons));
- d->showAlpha(options & ShowAlphaChannel);
-}
-
-QColorDialog::ColorDialogOptions QColorDialog::options() const
-{
- Q_D(const QColorDialog);
- return d->opts;
-}
-
-/*!
- \enum QColorDialog::ColorDialogOption
-
- \since 4.5
-
- This enum specifies various options that affect the look and feel
- of a color dialog.
-
- \value ShowAlphaChannel Allow the user to select the alpha component of a color.
- \value NoButtons Don't display \gui{OK} and \gui{Cancel} buttons. (Useful for "live dialogs".)
- \value DontUseNativeDialog Use Qt's standard color dialog on the Mac instead of Apple's
- native color panel.
-
- \sa options, setOption(), testOption(), windowModality()
-*/
-
-/*!
- \fn void QColorDialog::currentColorChanged(const QColor &color)
-
- This signal is emitted whenever the current color changes in the dialog.
- The current color is specified by \a color.
-
- \sa color, colorSelected()
-*/
-
-#ifdef Q_WS_MAC
-// can only have one Cocoa color panel active
-bool QColorDialogPrivate::sharedColorPanelAvailable = true;
-#endif
-
-/*!
- \fn void QColorDialog::colorSelected(const QColor &color);
-
- This signal is emitted just after the user has clicked \gui{OK} to
- select a color to use. The chosen color is specified by \a color.
-
- \sa color, currentColorChanged()
-*/
-
-/*!
- Changes the visibility of the dialog. If \a visible is true, the dialog
- is shown; otherwise, it is hidden.
-*/
-void QColorDialog::setVisible(bool visible)
-{
- Q_D(QColorDialog);
-
- if (visible){
- if (testAttribute(Qt::WA_WState_ExplicitShowHide) && !testAttribute(Qt::WA_WState_Hidden))
- return;
- } else if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden))
- return;
-
- if (visible)
- d->selectedQColor = QColor();
-
-#if defined(Q_WS_MAC)
- if (visible) {
- if (d->delegate || (QColorDialogPrivate::sharedColorPanelAvailable &&
- !(testAttribute(Qt::WA_DontShowOnScreen) || (d->opts & DontUseNativeDialog)))){
- d->openCocoaColorPanel(currentColor(), parentWidget(), windowTitle(), options());
- QColorDialogPrivate::sharedColorPanelAvailable = false;
- setAttribute(Qt::WA_DontShowOnScreen);
- }
- setWindowFlags(windowModality() == Qt::WindowModal ? Qt::Sheet : DefaultWindowFlags);
- } else {
- if (d->delegate) {
- d->closeCocoaColorPanel();
- setAttribute(Qt::WA_DontShowOnScreen, false);
- }
- }
-#else
-
- if (!(d->opts & DontUseNativeDialog) && qt_guiPlatformPlugin()->colorDialogSetVisible(this, visible)) {
- d->nativeDialogInUse = true;
- // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below
- // updates the state correctly, but skips showing the non-native version:
- setAttribute(Qt::WA_DontShowOnScreen);
- } else {
- d->nativeDialogInUse = false;
- setAttribute(Qt::WA_DontShowOnScreen, false);
- }
-#endif
-
- QDialog::setVisible(visible);
-}
-
-/*!
- \overload
- \since 4.5
-
- Opens the dialog and connects its colorSelected() signal to the slot specified
- by \a receiver and \a member.
-
- The signal will be disconnected from the slot when the dialog is closed.
-*/
-void QColorDialog::open(QObject *receiver, const char *member)
-{
- Q_D(QColorDialog);
- connect(this, SIGNAL(colorSelected(QColor)), receiver, member);
- d->receiverToDisconnectOnClose = receiver;
- d->memberToDisconnectOnClose = member;
- QDialog::open();
-}
-
-/*!
- \fn QColorDialog::open()
-
- \since 4.5
- Shows the dialog as a \l{QDialog#Modal Dialogs}{window modal dialog},
- returning immediately.
-
- \sa QDialog::open()
-*/
-
-/*
- For Symbian color dialogs
-*/
-#ifdef Q_WS_S60
-extern QColor qtSymbianGetColor(const QColor &initial);
-#endif
-/*!
- \since 4.5
-
- Pops up a modal color dialog with the given window \a title (or "Select Color" if none is
- specified), lets the user choose a color, and returns that color. The color is initially set
- to \a initial. The dialog is a child of \a parent. It returns an invalid (see
- QColor::isValid()) color if the user cancels the dialog.
-
- The \a options argument allows you to customize the dialog.
-
- On Symbian, this static function will use the native color dialog and not a QColorDialog.
- On Symbian the parameters \a title and \a parent has no relevance and the
- \a options parameter is only used to define if the native color dialog is
- used or not.
-*/
-QColor QColorDialog::getColor(const QColor &initial, QWidget *parent, const QString &title,
- ColorDialogOptions options)
-{
-#ifdef Q_WS_S60
- if (!(options & DontUseNativeDialog))
- return qtSymbianGetColor(initial);
-#endif
- QColorDialog dlg(parent);
- if (!title.isEmpty())
- dlg.setWindowTitle(title);
- dlg.setOptions(options);
- dlg.setCurrentColor(initial);
- dlg.exec();
- return dlg.selectedColor();
-}
-
-/*!
- Pops up a modal color dialog, lets the user choose a color, and
- returns that color. The color is initially set to \a initial. The
- dialog is a child of \a parent. It returns an invalid (see
- QColor::isValid()) color if the user cancels the dialog.
-
- On Symbian, this static function will use the native
- color dialog and not a QColorDialog.
-*/
-
-QColor QColorDialog::getColor(const QColor &initial, QWidget *parent)
-{
-#ifdef Q_WS_S60
- return qtSymbianGetColor(initial);
-#endif
- return getColor(initial, parent, QString(), ColorDialogOptions(0));
-}
-
-
-/*!
- \obsolete
-
- Pops up a modal color dialog to allow the user to choose a color
- and an alpha channel (transparency) value. The color+alpha is
- initially set to \a initial. The dialog is a child of \a parent.
-
- If \a ok is non-null, \e *\a ok is set to true if the user clicked
- \gui{OK}, and to false if the user clicked Cancel.
-
- If the user clicks Cancel, the \a initial value is returned.
-
- Use QColorDialog::getColor() instead, passing the
- QColorDialog::ShowAlphaChannel option.
-*/
-
-QRgb QColorDialog::getRgba(QRgb initial, bool *ok, QWidget *parent)
-{
- QColor color(getColor(QColor(initial), parent, QString(), ShowAlphaChannel));
- QRgb result = color.isValid() ? color.rgba() : initial;
- if (ok)
- *ok = color.isValid();
- return result;
-}
-
-/*!
- Destroys the color dialog.
-*/
-
-QColorDialog::~QColorDialog()
-{
- Q_D(QColorDialog);
-#if defined(Q_WS_MAC)
- if (d->delegate) {
- d->releaseCocoaColorPanelDelegate();
- QColorDialogPrivate::sharedColorPanelAvailable = true;
- }
-#endif
-
-#ifndef QT_NO_SETTINGS
- if (!customSet) {
- QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
- for (int i = 0; i < 2*8; ++i)
- settings.setValue(QLatin1String("Qt/customColors/") + QString::number(i), cusrgb[i]);
- }
-#endif
- if (d->nativeDialogInUse)
- qt_guiPlatformPlugin()->colorDialogDelete(this);
-
-}
-
-
-/*!
- \reimp
-*/
-void QColorDialog::changeEvent(QEvent *e)
-{
- Q_D(QColorDialog);
- if (e->type() == QEvent::LanguageChange)
- d->retranslateStrings();
- QDialog::changeEvent(e);
-}
-
-/*!
- Closes the dialog and sets its result code to \a result. If this dialog
- is shown with exec(), done() causes the local event loop to finish,
- and exec() to return \a result.
-
- \sa QDialog::done()
-*/
-void QColorDialog::done(int result)
-{
- Q_D(QColorDialog);
- QDialog::done(result);
- if (result == Accepted) {
- d->selectedQColor = d->currentQColor();
- emit colorSelected(d->selectedQColor);
- } else {
- d->selectedQColor = QColor();
- }
- if (d->receiverToDisconnectOnClose) {
- disconnect(this, SIGNAL(colorSelected(QColor)),
- d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
- d->receiverToDisconnectOnClose = 0;
- }
- d->memberToDisconnectOnClose.clear();
-}
-
-QT_END_NAMESPACE
-
-#include "qcolordialog.moc"
-#include "moc_qcolordialog.cpp"
-
-#endif // QT_NO_COLORDIALOG
-
-/*!
- \fn QColor QColorDialog::getColor(const QColor &init, QWidget *parent, const char *name)
- \compat
-*/
-
-/*!
- \fn QRgb QColorDialog::getRgba(QRgb rgba, bool *ok, QWidget *parent, const char *name)
- \compat
-*/
diff --git a/src/gui/dialogs/qcolordialog.h b/src/gui/dialogs/qcolordialog.h
deleted file mode 100644
index 80a893d568..0000000000
--- a/src/gui/dialogs/qcolordialog.h
+++ /dev/null
@@ -1,150 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QCOLORDIALOG_H
-#define QCOLORDIALOG_H
-
-#include <QtGui/qdialog.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_COLORDIALOG
-
-class QColorDialogPrivate;
-
-class Q_GUI_EXPORT QColorDialog : public QDialog
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QColorDialog)
- Q_ENUMS(ColorDialogOption)
- Q_PROPERTY(QColor currentColor READ currentColor WRITE setCurrentColor
- NOTIFY currentColorChanged)
- Q_PROPERTY(ColorDialogOptions options READ options WRITE setOptions)
-
-public:
- enum ColorDialogOption {
- ShowAlphaChannel = 0x00000001,
- NoButtons = 0x00000002,
- DontUseNativeDialog = 0x00000004
- };
-
- Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)
-
- explicit QColorDialog(QWidget *parent = 0);
- explicit QColorDialog(const QColor &initial, QWidget *parent = 0);
- ~QColorDialog();
-
- void setCurrentColor(const QColor &color);
- QColor currentColor() const;
-
- QColor selectedColor() const;
-
- void setOption(ColorDialogOption option, bool on = true);
- bool testOption(ColorDialogOption option) const;
- void setOptions(ColorDialogOptions options);
- ColorDialogOptions options() const;
-
-#ifdef Q_NO_USING_KEYWORD
- void open() { QDialog::open(); }
-#else
- using QDialog::open;
-#endif
- void open(QObject *receiver, const char *member);
-
- void setVisible(bool visible);
-
- // ### Qt 5: merge overloads with title = QString()
- static QColor getColor(const QColor &initial, QWidget *parent, const QString &title,
- ColorDialogOptions options = 0);
- static QColor getColor(const QColor &initial = Qt::white, QWidget *parent = 0);
-
- // obsolete
- static QRgb getRgba(QRgb rgba = 0xffffffff, bool *ok = 0, QWidget *parent = 0);
-
- // ### Qt 5: use QColor in signatures
- static int customCount();
- static QRgb customColor(int index);
- static void setCustomColor(int index, QRgb color);
- static void setStandardColor(int index, QRgb color);
-
-#ifdef QT3_SUPPORT
- static QColor getColor(const QColor &init, QWidget *parent, const char *name)
- { Q_UNUSED(name); return getColor(init, parent); }
- static QRgb getRgba(QRgb rgba, bool *ok, QWidget *parent, const char *name)
- { Q_UNUSED(name); return getRgba(rgba, ok, parent); }
-#endif
-
-Q_SIGNALS:
- void currentColorChanged(const QColor &color);
- void colorSelected(const QColor &color);
-
-protected:
- void changeEvent(QEvent *event);
- void done(int result);
-
-private:
- Q_DISABLE_COPY(QColorDialog)
-
- Q_PRIVATE_SLOT(d_func(), void _q_addCustom())
- Q_PRIVATE_SLOT(d_func(), void _q_newHsv(int h, int s, int v))
- Q_PRIVATE_SLOT(d_func(), void _q_newColorTypedIn(QRgb rgb))
- Q_PRIVATE_SLOT(d_func(), void _q_newCustom(int, int))
- Q_PRIVATE_SLOT(d_func(), void _q_newStandard(int, int))
-#if defined(Q_WS_MAC)
- Q_PRIVATE_SLOT(d_func(), void _q_macRunNativeAppModalPanel())
-#endif
-
- friend class QColorShower;
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QColorDialog::ColorDialogOptions)
-
-#endif // QT_NO_COLORDIALOG
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QCOLORDIALOG_H
diff --git a/src/gui/dialogs/qdialog.h b/src/gui/dialogs/qdialog.h
deleted file mode 100644
index ee23b7bf87..0000000000
--- a/src/gui/dialogs/qdialog.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDIALOG_H
-#define QDIALOG_H
-
-#include <QtGui/qwidget.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QPushButton;
-class QDialogPrivate;
-
-class Q_GUI_EXPORT QDialog : public QWidget
-{
- Q_OBJECT
- friend class QPushButton;
-
- Q_PROPERTY(bool sizeGripEnabled READ isSizeGripEnabled WRITE setSizeGripEnabled)
- Q_PROPERTY(bool modal READ isModal WRITE setModal)
-
-public:
- explicit QDialog(QWidget *parent = 0, Qt::WindowFlags f = 0);
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QDialog(QWidget *parent, const char *name, bool modal = false,
- Qt::WindowFlags f = 0);
-#endif
- ~QDialog();
-
- enum DialogCode { Rejected, Accepted };
-
- int result() const;
-
- void setVisible(bool visible);
-
- void setOrientation(Qt::Orientation orientation);
- Qt::Orientation orientation() const;
-
- void setExtension(QWidget* extension);
- QWidget* extension() const;
-
- QSize sizeHint() const;
- QSize minimumSizeHint() const;
-
- void setSizeGripEnabled(bool);
- bool isSizeGripEnabled() const;
-
- void setModal(bool modal);
- void setResult(int r);
-
-Q_SIGNALS:
- void finished(int result);
- void accepted();
- void rejected();
-
-public Q_SLOTS:
- void open();
- int exec();
- virtual void done(int);
- virtual void accept();
- virtual void reject();
-
- void showExtension(bool);
-
-protected:
- QDialog(QDialogPrivate &, QWidget *parent, Qt::WindowFlags f = 0);
-
-#if defined(Q_WS_WINCE) || defined(Q_OS_SYMBIAN)
- bool event(QEvent *e);
-#endif
- void keyPressEvent(QKeyEvent *);
- void closeEvent(QCloseEvent *);
- void showEvent(QShowEvent *);
- void resizeEvent(QResizeEvent *);
-#ifndef QT_NO_CONTEXTMENU
- void contextMenuEvent(QContextMenuEvent *);
-#endif
- bool eventFilter(QObject *, QEvent *);
- void adjustPosition(QWidget*);
-private:
- Q_DECLARE_PRIVATE(QDialog)
- Q_DISABLE_COPY(QDialog)
-
-#if defined(Q_OS_SYMBIAN)
- bool symbianAdjustedPosition();
-#endif
-
-
-#ifdef Q_WS_WINCE_WM
- Q_PRIVATE_SLOT(d_func(), void _q_doneAction())
-#endif
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDIALOG_H
diff --git a/src/gui/dialogs/qdialog_p.h b/src/gui/dialogs/qdialog_p.h
deleted file mode 100644
index a2a948e951..0000000000
--- a/src/gui/dialogs/qdialog_p.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDIALOG_P_H
-#define QDIALOG_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "private/qwidget_p.h"
-#include "QtCore/qeventloop.h"
-#include "QtCore/qpointer.h"
-#include "QtGui/qdialog.h"
-#include "QtGui/qpushbutton.h"
-
-QT_BEGIN_NAMESPACE
-
-class QSizeGrip;
-
-class QDialogPrivate : public QWidgetPrivate
-{
- Q_DECLARE_PUBLIC(QDialog)
-public:
-
- QDialogPrivate()
- : mainDef(0), orientation(Qt::Horizontal),extension(0), doShowExtension(false),
-#ifndef QT_NO_SIZEGRIP
- resizer(0),
- sizeGripEnabled(false),
-#endif
- rescode(0), resetModalityTo(-1), wasModalitySet(true), eventLoop(0)
- {}
-
- QPointer<QPushButton> mainDef;
- Qt::Orientation orientation;
- QWidget *extension;
- bool doShowExtension;
- QSize size, min, max;
-#ifndef QT_NO_SIZEGRIP
- QSizeGrip *resizer;
- bool sizeGripEnabled;
-#endif
- QPoint lastRMBPress;
-
- void setDefault(QPushButton *);
- void setMainDefault(QPushButton *);
- void hideDefault();
- void resetModalitySetByOpen();
-
-#ifdef Q_WS_WINCE_WM
- void _q_doneAction();
-#endif
-
-#ifdef Q_WS_MAC
- virtual void mac_nativeDialogModalHelp() {}
-#endif
-
- int rescode;
- int resetModalityTo;
- bool wasModalitySet;
-
- QPointer<QEventLoop> eventLoop;
-};
-
-QT_END_NAMESPACE
-
-#endif // QDIALOG_P_H
diff --git a/src/gui/dialogs/qerrormessage.h b/src/gui/dialogs/qerrormessage.h
deleted file mode 100644
index 500482c722..0000000000
--- a/src/gui/dialogs/qerrormessage.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QERRORMESSAGE_H
-#define QERRORMESSAGE_H
-
-#include <QtGui/qdialog.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_ERRORMESSAGE
-
-class QErrorMessagePrivate;
-
-class Q_GUI_EXPORT QErrorMessage: public QDialog
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QErrorMessage)
-public:
- explicit QErrorMessage(QWidget* parent = 0);
- ~QErrorMessage();
-
- static QErrorMessage * qtHandler();
-
-public Q_SLOTS:
- void showMessage(const QString &message);
- void showMessage(const QString &message, const QString &type);
-#ifdef QT3_SUPPORT
- inline QT_MOC_COMPAT void message(const QString &text) { showMessage(text); }
-#endif
-
-protected:
- void done(int);
- void changeEvent(QEvent *e);
-
-private:
- Q_DISABLE_COPY(QErrorMessage)
-};
-
-#endif // QT_NO_ERRORMESSAGE
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QERRORMESSAGE_H
diff --git a/src/gui/dialogs/qfiledialog.h b/src/gui/dialogs/qfiledialog.h
deleted file mode 100644
index fabb575a5a..0000000000
--- a/src/gui/dialogs/qfiledialog.h
+++ /dev/null
@@ -1,331 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFILEDIALOG_H
-#define QFILEDIALOG_H
-
-#include <QtCore/qdir.h>
-#include <QtCore/qstring.h>
-#include <QtGui/qdialog.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_FILEDIALOG
-
-class QModelIndex;
-class QItemSelection;
-struct QFileDialogArgs;
-class QFileIconProvider;
-class QFileDialogPrivate;
-class QAbstractItemDelegate;
-class QAbstractProxyModel;
-class QUrl;
-
-class Q_GUI_EXPORT QFileDialog : public QDialog
-{
- Q_OBJECT
- Q_ENUMS(ViewMode FileMode AcceptMode Option)
- Q_FLAGS(Options)
- Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode)
- Q_PROPERTY(FileMode fileMode READ fileMode WRITE setFileMode)
- Q_PROPERTY(AcceptMode acceptMode READ acceptMode WRITE setAcceptMode)
- Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly DESIGNABLE false)
- Q_PROPERTY(bool resolveSymlinks READ resolveSymlinks WRITE setResolveSymlinks DESIGNABLE false)
- Q_PROPERTY(bool confirmOverwrite READ confirmOverwrite WRITE setConfirmOverwrite DESIGNABLE false)
- Q_PROPERTY(QString defaultSuffix READ defaultSuffix WRITE setDefaultSuffix)
- Q_PROPERTY(bool nameFilterDetailsVisible READ isNameFilterDetailsVisible
- WRITE setNameFilterDetailsVisible DESIGNABLE false)
- Q_PROPERTY(Options options READ options WRITE setOptions)
-
-public:
- enum ViewMode { Detail, List };
- enum FileMode { AnyFile, ExistingFile, Directory, ExistingFiles, DirectoryOnly };
- enum AcceptMode { AcceptOpen, AcceptSave };
- enum DialogLabel { LookIn, FileName, FileType, Accept, Reject };
-
- // ### Rename to FileDialogOption and FileDialogOptions for Qt 5.0
- enum Option
- {
- ShowDirsOnly = 0x00000001,
- DontResolveSymlinks = 0x00000002,
- DontConfirmOverwrite = 0x00000004,
- DontUseSheet = 0x00000008,
- DontUseNativeDialog = 0x00000010,
- ReadOnly = 0x00000020,
- HideNameFilterDetails = 0x00000040
- };
- Q_DECLARE_FLAGS(Options, Option)
-
- QFileDialog(QWidget *parent, Qt::WindowFlags f);
- explicit QFileDialog(QWidget *parent = 0,
- const QString &caption = QString(),
- const QString &directory = QString(),
- const QString &filter = QString());
- ~QFileDialog();
-
- void setDirectory(const QString &directory);
- inline void setDirectory(const QDir &directory);
- QDir directory() const;
-
- void selectFile(const QString &filename);
- QStringList selectedFiles() const;
-
-#ifdef QT_DEPRECATED
- QT_DEPRECATED void setFilter(const QString &filter);
- QT_DEPRECATED void setFilters(const QStringList &filters);
- QT_DEPRECATED QStringList filters() const;
- QT_DEPRECATED void selectFilter(const QString &filter);
- QT_DEPRECATED QString selectedFilter() const;
-#endif
- void setNameFilterDetailsVisible(bool enabled);
- bool isNameFilterDetailsVisible() const;
-
- void setNameFilter(const QString &filter);
- void setNameFilters(const QStringList &filters);
- QStringList nameFilters() const;
- void selectNameFilter(const QString &filter);
- QString selectedNameFilter() const;
-
- QDir::Filters filter() const;
- void setFilter(QDir::Filters filters);
-
- void setViewMode(ViewMode mode);
- ViewMode viewMode() const;
-
- void setFileMode(FileMode mode);
- FileMode fileMode() const;
-
- void setAcceptMode(AcceptMode mode);
- AcceptMode acceptMode() const;
-
- void setReadOnly(bool enabled);
- bool isReadOnly() const;
-
- void setResolveSymlinks(bool enabled);
- bool resolveSymlinks() const;
-
- void setSidebarUrls(const QList<QUrl> &urls);
- QList<QUrl> sidebarUrls() const;
-
- QByteArray saveState() const;
- bool restoreState(const QByteArray &state);
-
- void setConfirmOverwrite(bool enabled);
- bool confirmOverwrite() const;
-
- void setDefaultSuffix(const QString &suffix);
- QString defaultSuffix() const;
-
- void setHistory(const QStringList &paths);
- QStringList history() const;
-
- void setItemDelegate(QAbstractItemDelegate *delegate);
- QAbstractItemDelegate *itemDelegate() const;
-
- void setIconProvider(QFileIconProvider *provider);
- QFileIconProvider *iconProvider() const;
-
- void setLabelText(DialogLabel label, const QString &text);
- QString labelText(DialogLabel label) const;
-
-#ifndef QT_NO_PROXYMODEL
- void setProxyModel(QAbstractProxyModel *model);
- QAbstractProxyModel *proxyModel() const;
-#endif
-
- void setOption(Option option, bool on = true);
- bool testOption(Option option) const;
- void setOptions(Options options);
- Options options() const;
-
-#ifdef Q_NO_USING_KEYWORD
-#ifndef Q_QDOC
- void open() { QDialog::open(); }
-#endif
-#else
- using QDialog::open;
-#endif
- void open(QObject *receiver, const char *member);
- void setVisible(bool visible);
-
-Q_SIGNALS:
- void fileSelected(const QString &file);
- void filesSelected(const QStringList &files);
- void currentChanged(const QString &path);
- void directoryEntered(const QString &directory);
- void filterSelected(const QString &filter);
-
-public:
-#ifdef QT3_SUPPORT
- typedef FileMode Mode;
- inline QT3_SUPPORT void setMode(FileMode m) { setFileMode(m); }
- inline QT3_SUPPORT FileMode mode() const { return fileMode(); }
- inline QT3_SUPPORT void setDir(const QString &directory) { setDirectory(directory); }
- inline QT3_SUPPORT void setDir( const QDir &directory ) { setDirectory(directory); }
- QT3_SUPPORT QString selectedFile() const;
-#endif
-
- static QString getOpenFileName(QWidget *parent = 0,
- const QString &caption = QString(),
- const QString &dir = QString(),
- const QString &filter = QString(),
- QString *selectedFilter = 0,
- Options options = 0);
-
- static QString getSaveFileName(QWidget *parent = 0,
- const QString &caption = QString(),
- const QString &dir = QString(),
- const QString &filter = QString(),
- QString *selectedFilter = 0,
- Options options = 0);
-
- static QString getExistingDirectory(QWidget *parent = 0,
- const QString &caption = QString(),
- const QString &dir = QString(),
- Options options = ShowDirsOnly);
-
- static QStringList getOpenFileNames(QWidget *parent = 0,
- const QString &caption = QString(),
- const QString &dir = QString(),
- const QString &filter = QString(),
- QString *selectedFilter = 0,
- Options options = 0);
-
-#ifdef QT3_SUPPORT
- inline static QString QT3_SUPPORT getOpenFileName(const QString &dir,
- const QString &filter = QString(),
- QWidget *parent = 0, const char* name = 0,
- const QString &caption = QString(),
- QString *selectedFilter = 0,
- bool resolveSymlinks = true)
- { Q_UNUSED(name);
- return getOpenFileName(parent, caption, dir, filter, selectedFilter,
- resolveSymlinks ? Option(0) : DontResolveSymlinks); }
-
- inline static QString QT3_SUPPORT getSaveFileName(const QString &dir,
- const QString &filter = QString(),
- QWidget *parent = 0, const char* name = 0,
- const QString &caption = QString(),
- QString *selectedFilter = 0,
- bool resolveSymlinks = true)
- { Q_UNUSED(name);
- return getSaveFileName(parent, caption, dir, filter, selectedFilter,
- resolveSymlinks ? Option(0) : DontResolveSymlinks); }
-
- inline static QString QT3_SUPPORT getExistingDirectory(const QString &dir,
- QWidget *parent = 0,
- const char* name = 0,
- const QString &caption = QString(),
- bool dirOnly = true,
- bool resolveSymlinks = true)
- { Q_UNUSED(name);
- return getExistingDirectory(parent, caption, dir,
- Options((resolveSymlinks ? Option(0) : DontResolveSymlinks)
- | (dirOnly ? ShowDirsOnly : Option(0)))); }
-
- inline static QStringList QT3_SUPPORT getOpenFileNames(const QString &filter,
- const QString &dir = QString(),
- QWidget *parent = 0,
- const char* name = 0,
- const QString &caption = QString(),
- QString *selectedFilter = 0,
- bool resolveSymlinks = true)
- { Q_UNUSED(name);
- return getOpenFileNames(parent, caption, dir, filter, selectedFilter,
- resolveSymlinks ? Option(0) : DontResolveSymlinks); }
-#endif // QT3_SUPPORT
-
-protected:
- QFileDialog(const QFileDialogArgs &args);
- void done(int result);
- void accept();
- void changeEvent(QEvent *e);
-
-private:
- Q_DECLARE_PRIVATE(QFileDialog)
- Q_DISABLE_COPY(QFileDialog)
-
- Q_PRIVATE_SLOT(d_func(), void _q_pathChanged(const QString &))
-
- Q_PRIVATE_SLOT(d_func(), void _q_navigateBackward())
- Q_PRIVATE_SLOT(d_func(), void _q_navigateForward())
- Q_PRIVATE_SLOT(d_func(), void _q_navigateToParent())
- Q_PRIVATE_SLOT(d_func(), void _q_createDirectory())
- Q_PRIVATE_SLOT(d_func(), void _q_showListView())
- Q_PRIVATE_SLOT(d_func(), void _q_showDetailsView())
- Q_PRIVATE_SLOT(d_func(), void _q_showContextMenu(const QPoint &))
- Q_PRIVATE_SLOT(d_func(), void _q_renameCurrent())
- Q_PRIVATE_SLOT(d_func(), void _q_deleteCurrent())
- Q_PRIVATE_SLOT(d_func(), void _q_showHidden())
- Q_PRIVATE_SLOT(d_func(), void _q_updateOkButton())
- Q_PRIVATE_SLOT(d_func(), void _q_currentChanged(const QModelIndex &index))
- Q_PRIVATE_SLOT(d_func(), void _q_enterDirectory(const QModelIndex &index))
- Q_PRIVATE_SLOT(d_func(), void _q_goToDirectory(const QString &path))
- Q_PRIVATE_SLOT(d_func(), void _q_useNameFilter(int index))
- Q_PRIVATE_SLOT(d_func(), void _q_selectionChanged())
- Q_PRIVATE_SLOT(d_func(), void _q_goToUrl(const QUrl &url))
- Q_PRIVATE_SLOT(d_func(), void _q_goHome())
- Q_PRIVATE_SLOT(d_func(), void _q_showHeader(QAction *))
- Q_PRIVATE_SLOT(d_func(), void _q_autoCompleteFileName(const QString &text))
- Q_PRIVATE_SLOT(d_func(), void _q_rowsInserted(const QModelIndex & parent))
- Q_PRIVATE_SLOT(d_func(), void _q_fileRenamed(const QString &path,
- const QString oldName, const QString newName))
-#if defined(Q_WS_MAC)
- Q_PRIVATE_SLOT(d_func(), void _q_macRunNativeAppModalPanel())
-#endif
-};
-
-inline void QFileDialog::setDirectory(const QDir &adirectory)
-{ setDirectory(adirectory.absolutePath()); }
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QFileDialog::Options)
-
-#endif // QT_NO_FILEDIALOG
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QFILEDIALOG_H
diff --git a/src/gui/dialogs/qfilesystemmodel.h b/src/gui/dialogs/qfilesystemmodel.h
deleted file mode 100644
index 8aa9875d13..0000000000
--- a/src/gui/dialogs/qfilesystemmodel.h
+++ /dev/null
@@ -1,180 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFILESYSTEMMODEL_H
-#define QFILESYSTEMMODEL_H
-
-#include <QtCore/qabstractitemmodel.h>
-#include <QtCore/qpair.h>
-#include <QtCore/qdir.h>
-#include <QtGui/qicon.h>
-#include <QtCore/qdiriterator.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_FILESYSTEMMODEL
-
-class ExtendedInformation;
-class QFileSystemModelPrivate;
-class QFileIconProvider;
-
-class Q_GUI_EXPORT QFileSystemModel : public QAbstractItemModel
-{
- Q_OBJECT
- Q_PROPERTY(bool resolveSymlinks READ resolveSymlinks WRITE setResolveSymlinks)
- Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
- Q_PROPERTY(bool nameFilterDisables READ nameFilterDisables WRITE setNameFilterDisables)
-
-Q_SIGNALS:
- void rootPathChanged(const QString &newPath);
- void fileRenamed(const QString &path, const QString &oldName, const QString &newName);
- void directoryLoaded(const QString &path);
-
-public:
- enum Roles {
- FileIconRole = Qt::DecorationRole,
- FilePathRole = Qt::UserRole + 1,
- FileNameRole = Qt::UserRole + 2,
- FilePermissions = Qt::UserRole + 3
- };
-
- explicit QFileSystemModel(QObject *parent = 0);
- ~QFileSystemModel();
-
- QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
- QModelIndex index(const QString &path, int column = 0) const;
- QModelIndex parent(const QModelIndex &child) const;
- bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
- bool canFetchMore(const QModelIndex &parent) const;
- void fetchMore(const QModelIndex &parent);
-
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- int columnCount(const QModelIndex &parent = QModelIndex()) const;
-
- QVariant myComputer(int role = Qt::DisplayRole) const;
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
-
- QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
-
- Qt::ItemFlags flags(const QModelIndex &index) const;
-
- void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
-
- QStringList mimeTypes() const;
- QMimeData *mimeData(const QModelIndexList &indexes) const;
- bool dropMimeData(const QMimeData *data, Qt::DropAction action,
- int row, int column, const QModelIndex &parent);
- Qt::DropActions supportedDropActions() const;
-
- // QFileSystemModel specific API
- QModelIndex setRootPath(const QString &path);
- QString rootPath() const;
- QDir rootDirectory() const;
-
- void setIconProvider(QFileIconProvider *provider);
- QFileIconProvider *iconProvider() const;
-
- void setFilter(QDir::Filters filters);
- QDir::Filters filter() const;
-
- void setResolveSymlinks(bool enable);
- bool resolveSymlinks() const;
-
- void setReadOnly(bool enable);
- bool isReadOnly() const;
-
- void setNameFilterDisables(bool enable);
- bool nameFilterDisables() const;
-
- void setNameFilters(const QStringList &filters);
- QStringList nameFilters() const;
-
- QString filePath(const QModelIndex &index) const;
- bool isDir(const QModelIndex &index) const;
- qint64 size(const QModelIndex &index) const;
- QString type(const QModelIndex &index) const;
- QDateTime lastModified(const QModelIndex &index) const;
-
- QModelIndex mkdir(const QModelIndex &parent, const QString &name);
- bool rmdir(const QModelIndex &index) const; // ### Qt5: should not be const
- inline QString fileName(const QModelIndex &index) const;
- inline QIcon fileIcon(const QModelIndex &index) const;
- QFile::Permissions permissions(const QModelIndex &index) const;
- inline QFileInfo fileInfo(const QModelIndex &index) const;
- bool remove(const QModelIndex &index) const;
-
-protected:
- QFileSystemModel(QFileSystemModelPrivate &, QObject *parent = 0);
- void timerEvent(QTimerEvent *event);
- bool event(QEvent *event);
-
-private:
- Q_DECLARE_PRIVATE(QFileSystemModel)
- Q_DISABLE_COPY(QFileSystemModel)
-
- Q_PRIVATE_SLOT(d_func(), void _q_directoryChanged(const QString &directory, const QStringList &list))
- Q_PRIVATE_SLOT(d_func(), void _q_performDelayedSort())
- Q_PRIVATE_SLOT(d_func(), void _q_fileSystemChanged(const QString &path, const QList<QPair<QString, QFileInfo> > &))
- Q_PRIVATE_SLOT(d_func(), void _q_resolvedName(const QString &fileName, const QString &resolvedName))
-
- friend class QFileDialogPrivate;
-};
-
-inline QString QFileSystemModel::fileName(const QModelIndex &aindex) const
-{ return aindex.data(Qt::DisplayRole).toString(); }
-inline QIcon QFileSystemModel::fileIcon(const QModelIndex &aindex) const
-{ return qvariant_cast<QIcon>(aindex.data(Qt::DecorationRole)); }
-inline QFileInfo QFileSystemModel::fileInfo(const QModelIndex &aindex) const
-{ return QFileInfo(filePath(aindex)); }
-
-#endif // QT_NO_FILESYSTEMMODEL
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QFILESYSTEMMODEL_H
-
diff --git a/src/gui/dialogs/qfontdialog.cpp b/src/gui/dialogs/qfontdialog.cpp
deleted file mode 100644
index b58021d877..0000000000
--- a/src/gui/dialogs/qfontdialog.cpp
+++ /dev/null
@@ -1,1077 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwindowdefs.h"
-
-#ifndef QT_NO_FONTDIALOG
-
-#include "qfontdialog.h"
-#include "qfontdialog_p.h"
-
-#include <qapplication.h>
-#include <qcheckbox.h>
-#include <qcombobox.h>
-#include <qevent.h>
-#include <qfontdatabase.h>
-#include <qgroupbox.h>
-#include <qlabel.h>
-#include <qlayout.h>
-#include <qlineedit.h>
-#include <qpushbutton.h>
-#include <qstyle.h>
-#include <qdialogbuttonbox.h>
-#include <qheaderview.h>
-#include <qlistview.h>
-#include <qstringlistmodel.h>
-#include <qvalidator.h>
-#include <private/qdialog_p.h>
-#include <private/qfont_p.h>
-
-#if defined(Q_WS_S60)
-#include <QtGui/qdesktopwidget.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class QFontListView : public QListView
-{
- Q_OBJECT
-public:
- QFontListView(QWidget *parent);
- inline QStringListModel *model() const {
- return static_cast<QStringListModel *>(QListView::model());
- }
- inline void setCurrentItem(int item) {
- QListView::setCurrentIndex(static_cast<QAbstractListModel*>(model())->index(item));
- }
- inline int currentItem() const {
- return QListView::currentIndex().row();
- }
- inline int count() const {
- return model()->rowCount();
- }
- inline QString currentText() const {
- int row = QListView::currentIndex().row();
- return row < 0 ? QString() : model()->stringList().at(row);
- }
- void currentChanged(const QModelIndex &current, const QModelIndex &previous) {
- QListView::currentChanged(current, previous);
- if (current.isValid())
- emit highlighted(current.row());
- }
- QString text(int i) const {
- return model()->stringList().at(i);
- }
-signals:
- void highlighted(int);
-};
-
-QFontListView::QFontListView(QWidget *parent)
- : QListView(parent)
-{
- setModel(new QStringListModel(parent));
- setEditTriggers(NoEditTriggers);
-}
-
-static const Qt::WindowFlags DefaultWindowFlags =
- Qt::Dialog | Qt::WindowSystemMenuHint;
-
-/*!
- \class QFontDialog
- \ingroup standard-dialogs
-
- \brief The QFontDialog class provides a dialog widget for selecting a font.
-
- A font dialog is created through one of the static getFont()
- functions.
-
- Examples:
-
- \snippet doc/src/snippets/code/src_gui_dialogs_qfontdialog.cpp 0
-
- The dialog can also be used to set a widget's font directly:
- \snippet doc/src/snippets/code/src_gui_dialogs_qfontdialog.cpp 1
- If the user clicks OK the font they chose will be used for myWidget,
- and if they click Cancel the original font is used.
-
- \image plastique-fontdialog.png A font dialog in the Plastique widget style.
-
- \sa QFont, QFontInfo, QFontMetrics, QColorDialog, QFileDialog, QPrintDialog,
- {Standard Dialogs Example}
-*/
-
-/*!
- \since 4.5
-
- Constructs a standard font dialog.
-
- Use setCurrentFont() to set the initial font attributes.
-
- The \a parent parameter is passed to the QDialog constructor.
-
- \sa getFont()
-*/
-QFontDialog::QFontDialog(QWidget *parent)
- : QDialog(*new QFontDialogPrivate, parent, DefaultWindowFlags)
-{
- Q_D(QFontDialog);
- d->init();
-}
-
-/*!
- \since 4.5
-
- Constructs a standard font dialog with the given \a parent and specified
- \a initial color.
-*/
-QFontDialog::QFontDialog(const QFont &initial, QWidget *parent)
- : QDialog(*new QFontDialogPrivate, parent, DefaultWindowFlags)
-{
- Q_D(QFontDialog);
- d->init();
- setCurrentFont(initial);
-}
-
-void QFontDialogPrivate::init()
-{
- Q_Q(QFontDialog);
-
-#ifdef Q_WS_MAC
- nativeDialogInUse = false;
- delegate = 0;
-#endif
-
- q->setSizeGripEnabled(true);
- q->setWindowTitle(QFontDialog::tr("Select Font"));
-
- // grid
- familyEdit = new QLineEdit(q);
- familyEdit->setReadOnly(true);
- familyList = new QFontListView(q);
- familyEdit->setFocusProxy(familyList);
-
- familyAccel = new QLabel(q);
-#ifndef QT_NO_SHORTCUT
- familyAccel->setBuddy(familyList);
-#endif
- familyAccel->setIndent(2);
-
- styleEdit = new QLineEdit(q);
- styleEdit->setReadOnly(true);
- styleList = new QFontListView(q);
- styleEdit->setFocusProxy(styleList);
-
- styleAccel = new QLabel(q);
-#ifndef QT_NO_SHORTCUT
- styleAccel->setBuddy(styleList);
-#endif
- styleAccel->setIndent(2);
-
- sizeEdit = new QLineEdit(q);
- sizeEdit->setFocusPolicy(Qt::ClickFocus);
- QIntValidator *validator = new QIntValidator(1, 512, q);
- sizeEdit->setValidator(validator);
- sizeList = new QFontListView(q);
-
- sizeAccel = new QLabel(q);
-#ifndef QT_NO_SHORTCUT
- sizeAccel->setBuddy(sizeEdit);
-#endif
- sizeAccel->setIndent(2);
-
- // effects box
- effects = new QGroupBox(q);
- QVBoxLayout *vbox = new QVBoxLayout(effects);
- strikeout = new QCheckBox(effects);
- vbox->addWidget(strikeout);
- underline = new QCheckBox(effects);
- vbox->addWidget(underline);
-
- sample = new QGroupBox(q);
- QHBoxLayout *hbox = new QHBoxLayout(sample);
- sampleEdit = new QLineEdit(sample);
- sampleEdit->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
- sampleEdit->setAlignment(Qt::AlignCenter);
- // Note that the sample text is *not* translated with tr(), as the
- // characters used depend on the charset encoding.
- sampleEdit->setText(QLatin1String("AaBbYyZz"));
- hbox->addWidget(sampleEdit);
-
- writingSystemCombo = new QComboBox(q);
-
- writingSystemAccel = new QLabel(q);
-#ifndef QT_NO_SHORTCUT
- writingSystemAccel->setBuddy(writingSystemCombo);
-#endif
- writingSystemAccel->setIndent(2);
-
- size = 0;
- smoothScalable = false;
-
- QObject::connect(writingSystemCombo, SIGNAL(activated(int)), q, SLOT(_q_writingSystemHighlighted(int)));
- QObject::connect(familyList, SIGNAL(highlighted(int)), q, SLOT(_q_familyHighlighted(int)));
- QObject::connect(styleList, SIGNAL(highlighted(int)), q, SLOT(_q_styleHighlighted(int)));
- QObject::connect(sizeList, SIGNAL(highlighted(int)), q, SLOT(_q_sizeHighlighted(int)));
- QObject::connect(sizeEdit, SIGNAL(textChanged(QString)), q, SLOT(_q_sizeChanged(QString)));
-
- QObject::connect(strikeout, SIGNAL(clicked()), q, SLOT(_q_updateSample()));
- QObject::connect(underline, SIGNAL(clicked()), q, SLOT(_q_updateSample()));
-
- for (int i = 0; i < QFontDatabase::WritingSystemsCount; ++i) {
- QFontDatabase::WritingSystem ws = QFontDatabase::WritingSystem(i);
- QString writingSystemName = QFontDatabase::writingSystemName(ws);
- if (writingSystemName.isEmpty())
- break;
- writingSystemCombo->addItem(writingSystemName);
- }
-
- updateFamilies();
- if (familyList->count() != 0)
- familyList->setCurrentItem(0);
-
- // grid layout
- QGridLayout *mainGrid = new QGridLayout(q);
-
- int spacing = mainGrid->spacing();
- if (spacing >= 0) { // uniform spacing
- mainGrid->setSpacing(0);
-
- mainGrid->setColumnMinimumWidth(1, spacing);
- mainGrid->setColumnMinimumWidth(3, spacing);
-
- int margin = 0;
- mainGrid->getContentsMargins(0, 0, 0, &margin);
-
- mainGrid->setRowMinimumHeight(3, margin);
- mainGrid->setRowMinimumHeight(6, 2);
- mainGrid->setRowMinimumHeight(8, margin);
- }
-
- mainGrid->addWidget(familyAccel, 0, 0);
- mainGrid->addWidget(familyEdit, 1, 0);
- mainGrid->addWidget(familyList, 2, 0);
-
- mainGrid->addWidget(styleAccel, 0, 2);
- mainGrid->addWidget(styleEdit, 1, 2);
- mainGrid->addWidget(styleList, 2, 2);
-
- mainGrid->addWidget(sizeAccel, 0, 4);
- mainGrid->addWidget(sizeEdit, 1, 4);
- mainGrid->addWidget(sizeList, 2, 4);
-
- mainGrid->setColumnStretch(0, 38);
- mainGrid->setColumnStretch(2, 24);
- mainGrid->setColumnStretch(4, 10);
-
- mainGrid->addWidget(effects, 4, 0);
-
- mainGrid->addWidget(sample, 4, 2, 4, 3);
-
- mainGrid->addWidget(writingSystemAccel, 5, 0);
- mainGrid->addWidget(writingSystemCombo, 7, 0);
-
- buttonBox = new QDialogButtonBox(q);
- mainGrid->addWidget(buttonBox, 9, 0, 1, 5);
-
- QPushButton *button
- = static_cast<QPushButton *>(buttonBox->addButton(QDialogButtonBox::Ok));
- QObject::connect(buttonBox, SIGNAL(accepted()), q, SLOT(accept()));
- button->setDefault(true);
-
- buttonBox->addButton(QDialogButtonBox::Cancel);
- QObject::connect(buttonBox, SIGNAL(rejected()), q, SLOT(reject()));
-
-#if defined(Q_WS_WINCE)
- q->resize(180, 120);
-#elif defined(Q_WS_S60)
- q->resize(QApplication::desktop()->availableGeometry(QCursor::pos()).size());
-#else
- q->resize(500, 360);
-#endif // Q_WS_WINCE
-
- sizeEdit->installEventFilter(q);
- familyList->installEventFilter(q);
- styleList->installEventFilter(q);
- sizeList->installEventFilter(q);
-
- familyList->setFocus();
- retranslateStrings();
-}
-
-/*!
- \internal
- Destroys the font dialog and frees up its storage.
-*/
-
-QFontDialog::~QFontDialog()
-{
-#ifdef Q_WS_MAC
- Q_D(QFontDialog);
- if (d->delegate) {
- d->closeCocoaFontPanel();
- return;
- }
-#endif
-}
-
-/*!
- Executes a modal font dialog and returns a font.
-
- If the user clicks \gui OK, the selected font is returned. If the user
- clicks \gui Cancel, the \a initial font is returned.
-
- The dialog is constructed with the given \a parent and the options specified
- in \a options. \a title is shown as the window title of the dialog and \a
- initial is the initially selected font. If the \a ok parameter is not-null,
- the value it refers to is set to true if the user clicks \gui OK, and set to
- false if the user clicks \gui Cancel.
-
- Examples:
- \snippet doc/src/snippets/code/src_gui_dialogs_qfontdialog.cpp 2
-
- The dialog can also be used to set a widget's font directly:
- \snippet doc/src/snippets/code/src_gui_dialogs_qfontdialog.cpp 3
- In this example, if the user clicks OK the font they chose will be
- used, and if they click Cancel the original font is used.
-
- \warning Do not delete \a parent during the execution of the dialog.
- If you want to do this, you should create the dialog
- yourself using one of the QFontDialog constructors.
-*/
-QFont QFontDialog::getFont(bool *ok, const QFont &initial, QWidget *parent, const QString &title,
- FontDialogOptions options)
-{
- return QFontDialogPrivate::getFont(ok, initial, parent, title, options);
-}
-
-/*!
- \overload
- \since 4.5
-*/
-QFont QFontDialog::getFont(bool *ok, const QFont &initial, QWidget *parent, const QString &title)
-{
- return QFontDialogPrivate::getFont(ok, initial, parent, title, 0);
-}
-
-/*!
- \overload
-*/
-QFont QFontDialog::getFont(bool *ok, const QFont &initial, QWidget *parent)
-{
- return QFontDialogPrivate::getFont(ok, initial, parent, QString(), 0);
-}
-
-/*!
- \overload
-
- Executes a modal font dialog and returns a font.
-
- If the user clicks \gui OK, the selected font is returned. If the user
- clicks \gui Cancel, the Qt default font is returned.
-
- The dialog is constructed with the given \a parent.
- If the \a ok parameter is not-null, the value it refers to is set
- to true if the user clicks \gui OK, and false if the user clicks
- \gui Cancel.
-
- Example:
- \snippet doc/src/snippets/code/src_gui_dialogs_qfontdialog.cpp 4
-
- \warning Do not delete \a parent during the execution of the dialog.
- If you want to do this, you should create the dialog
- yourself using one of the QFontDialog constructors.
-*/
-QFont QFontDialog::getFont(bool *ok, QWidget *parent)
-{
- QFont initial;
- return QFontDialogPrivate::getFont(ok, initial, parent, QString(), 0);
-}
-
-QFont QFontDialogPrivate::getFont(bool *ok, const QFont &initial, QWidget *parent,
- const QString &title, QFontDialog::FontDialogOptions options)
-{
- QFontDialog dlg(parent);
- dlg.setOptions(options);
- dlg.setCurrentFont(initial);
- if (!title.isEmpty())
- dlg.setWindowTitle(title);
-
- int ret = (dlg.exec() || (options & QFontDialog::NoButtons));
- if (ok)
- *ok = !!ret;
- if (ret) {
- return dlg.selectedFont();
- } else {
- return initial;
- }
-}
-
-/*!
- \internal
- An event filter to make the Up, Down, PageUp and PageDown keys work
- correctly in the line edits. The source of the event is the object
- \a o and the event is \a e.
-*/
-
-bool QFontDialog::eventFilter(QObject *o , QEvent *e)
-{
- Q_D(QFontDialog);
- if (e->type() == QEvent::KeyPress) {
- QKeyEvent *k = (QKeyEvent *)e;
- if (o == d->sizeEdit &&
- (k->key() == Qt::Key_Up ||
- k->key() == Qt::Key_Down ||
- k->key() == Qt::Key_PageUp ||
- k->key() == Qt::Key_PageDown)) {
-
- int ci = d->sizeList->currentItem();
- (void)QApplication::sendEvent(d->sizeList, k);
-
- if (ci != d->sizeList->currentItem()
- && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, this))
- d->sizeEdit->selectAll();
- return true;
- } else if ((o == d->familyList || o == d->styleList) &&
- (k->key() == Qt::Key_Return || k->key() == Qt::Key_Enter)) {
- k->accept();
- accept();
- return true;
- }
- } else if (e->type() == QEvent::FocusIn
- && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, this)) {
- if (o == d->familyList)
- d->familyEdit->selectAll();
- else if (o == d->styleList)
- d->styleEdit->selectAll();
- else if (o == d->sizeList)
- d->sizeEdit->selectAll();
- } else if (e->type() == QEvent::MouseButtonPress && o == d->sizeList) {
- d->sizeEdit->setFocus();
- }
- return QDialog::eventFilter(o, e);
-}
-
-/*
- Updates the contents of the "font family" list box. This
- function can be reimplemented if you have special requirements.
-*/
-
-void QFontDialogPrivate::updateFamilies()
-{
- Q_Q(QFontDialog);
-
- enum match_t { MATCH_NONE = 0, MATCH_LAST_RESORT = 1, MATCH_APP = 2, MATCH_FAMILY = 3 };
-
- QStringList familyNames = fdb.families(writingSystem);
-
- familyList->model()->setStringList(familyNames);
-
- QString foundryName1, familyName1, foundryName2, familyName2;
- int bestFamilyMatch = -1;
- match_t bestFamilyType = MATCH_NONE;
-
- QFont f;
-
- // ##### do the right thing for a list of family names in the font.
- QFontDatabase::parseFontName(family, foundryName1, familyName1);
-
- QStringList::const_iterator it = familyNames.constBegin();
- int i = 0;
- for(; it != familyNames.constEnd(); ++it, ++i) {
- QFontDatabase::parseFontName(*it, foundryName2, familyName2);
-
- //try to match...
- if (familyName1 == familyName2) {
- bestFamilyType = MATCH_FAMILY;
- if (foundryName1 == foundryName2) {
- bestFamilyMatch = i;
- break;
- }
- if (bestFamilyMatch < MATCH_FAMILY)
- bestFamilyMatch = i;
- }
-
- //and try some fall backs
- match_t type = MATCH_NONE;
- if (bestFamilyType <= MATCH_NONE && familyName2 == f.lastResortFamily())
- type = MATCH_LAST_RESORT;
- if (bestFamilyType <= MATCH_LAST_RESORT && familyName2 == f.family())
- type = MATCH_APP;
- // ### add fallback for writingSystem
- if (type != MATCH_NONE) {
- bestFamilyType = type;
- bestFamilyMatch = i;
- }
- }
-
- if (i != -1 && bestFamilyType != MATCH_NONE)
- familyList->setCurrentItem(bestFamilyMatch);
- else
- familyList->setCurrentItem(0);
- familyEdit->setText(familyList->currentText());
- if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
- && familyList->hasFocus())
- familyEdit->selectAll();
-
- updateStyles();
-}
-
-/*
- Updates the contents of the "font style" list box. This
- function can be reimplemented if you have special requirements.
-*/
-void QFontDialogPrivate::updateStyles()
-{
- Q_Q(QFontDialog);
- QStringList styles = fdb.styles(familyList->currentText());
- styleList->model()->setStringList(styles);
-
- if (styles.isEmpty()) {
- styleEdit->clear();
- smoothScalable = false;
- } else {
- if (!style.isEmpty()) {
- bool found = false;
- bool first = true;
- QString cstyle = style;
-
- redo:
- for (int i = 0; i < (int)styleList->count(); i++) {
- if (cstyle == styleList->text(i)) {
- styleList->setCurrentItem(i);
- found = true;
- break;
- }
- }
- if (!found && first) {
- if (cstyle.contains(QLatin1String("Italic"))) {
- cstyle.replace(QLatin1String("Italic"), QLatin1String("Oblique"));
- first = false;
- goto redo;
- } else if (cstyle.contains(QLatin1String("Oblique"))) {
- cstyle.replace(QLatin1String("Oblique"), QLatin1String("Italic"));
- first = false;
- goto redo;
- }
- }
- if (!found)
- styleList->setCurrentItem(0);
- } else {
- styleList->setCurrentItem(0);
- }
-
- styleEdit->setText(styleList->currentText());
- if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
- && styleList->hasFocus())
- styleEdit->selectAll();
-
- smoothScalable = fdb.isSmoothlyScalable(familyList->currentText(), styleList->currentText());
- }
-
- updateSizes();
-}
-
-/*!
- \internal
- Updates the contents of the "font size" list box. This
- function can be reimplemented if you have special requirements.
-*/
-
-void QFontDialogPrivate::updateSizes()
-{
- Q_Q(QFontDialog);
-
- if (!familyList->currentText().isEmpty()) {
- QList<int> sizes = fdb.pointSizes(familyList->currentText(), styleList->currentText());
-
- int i = 0;
- int current = -1;
- QStringList str_sizes;
- for(QList<int>::const_iterator it = sizes.constBegin(); it != sizes.constEnd(); ++it) {
- str_sizes.append(QString::number(*it));
- if (current == -1 && *it >= size)
- current = i;
- ++i;
- }
- sizeList->model()->setStringList(str_sizes);
- if (current == -1) {
- // we request a size bigger than the ones in the list, select the biggest one
- current = sizeList->count() - 1;
- }
- sizeList->setCurrentItem(current);
-
- sizeEdit->blockSignals(true);
- sizeEdit->setText((smoothScalable ? QString::number(size) : sizeList->currentText()));
- if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
- && sizeList->hasFocus())
- sizeEdit->selectAll();
- sizeEdit->blockSignals(false);
- } else {
- sizeEdit->clear();
- }
-
- _q_updateSample();
-}
-
-void QFontDialogPrivate::_q_updateSample()
-{
- // compute new font
- int pSize = sizeEdit->text().toInt();
- QFont newFont(fdb.font(familyList->currentText(), style, pSize));
- newFont.setStrikeOut(strikeout->isChecked());
- newFont.setUnderline(underline->isChecked());
-
- if (familyList->currentText().isEmpty())
- sampleEdit->clear();
-
- updateSampleFont(newFont);
-}
-
-void QFontDialogPrivate::updateSampleFont(const QFont &newFont)
-{
- Q_Q(QFontDialog);
- if (newFont != sampleEdit->font()) {
- sampleEdit->setFont(newFont);
- emit q->currentFontChanged(newFont);
- }
-}
-
-/*!
- \internal
-*/
-void QFontDialogPrivate::_q_writingSystemHighlighted(int index)
-{
- writingSystem = QFontDatabase::WritingSystem(index);
- sampleEdit->setText(fdb.writingSystemSample(writingSystem));
- updateFamilies();
-}
-
-/*!
- \internal
-*/
-void QFontDialogPrivate::_q_familyHighlighted(int i)
-{
- Q_Q(QFontDialog);
- family = familyList->text(i);
- familyEdit->setText(family);
- if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
- && familyList->hasFocus())
- familyEdit->selectAll();
-
- updateStyles();
-}
-
-
-/*!
- \internal
-*/
-
-void QFontDialogPrivate::_q_styleHighlighted(int index)
-{
- Q_Q(QFontDialog);
- QString s = styleList->text(index);
- styleEdit->setText(s);
- if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
- && styleList->hasFocus())
- styleEdit->selectAll();
-
- style = s;
-
- updateSizes();
-}
-
-
-/*!
- \internal
-*/
-
-void QFontDialogPrivate::_q_sizeHighlighted(int index)
-{
- Q_Q(QFontDialog);
- QString s = sizeList->text(index);
- sizeEdit->setText(s);
- if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
- && sizeEdit->hasFocus())
- sizeEdit->selectAll();
-
- size = s.toInt();
- _q_updateSample();
-}
-
-/*!
- \internal
- This slot is called if the user changes the font size.
- The size is passed in the \a s argument as a \e string.
-*/
-
-void QFontDialogPrivate::_q_sizeChanged(const QString &s)
-{
- // no need to check if the conversion is valid, since we have an QIntValidator in the size edit
- int size = s.toInt();
- if (this->size == size)
- return;
-
- this->size = size;
- if (sizeList->count() != 0) {
- int i;
- for (i = 0; i < sizeList->count() - 1; i++) {
- if (sizeList->text(i).toInt() >= this->size)
- break;
- }
- sizeList->blockSignals(true);
- sizeList->setCurrentItem(i);
- sizeList->blockSignals(false);
- }
- _q_updateSample();
-}
-
-void QFontDialogPrivate::retranslateStrings()
-{
- familyAccel->setText(QFontDialog::tr("&Font"));
- styleAccel->setText(QFontDialog::tr("Font st&yle"));
- sizeAccel->setText(QFontDialog::tr("&Size"));
-#ifndef Q_WS_S60
- // Removed the title due to lack of screen estate in small S60 screen.
- // The effects are descriptive without a title (strikeout, underline).
- effects->setTitle(QFontDialog::tr("Effects"));
-#endif
- strikeout->setText(QFontDialog::tr("Stri&keout"));
- underline->setText(QFontDialog::tr("&Underline"));
- sample->setTitle(QFontDialog::tr("Sample"));
- writingSystemAccel->setText(QFontDialog::tr("Wr&iting System"));
-}
-
-/*!
- \reimp
-*/
-void QFontDialog::changeEvent(QEvent *e)
-{
- Q_D(QFontDialog);
- if (e->type() == QEvent::LanguageChange) {
- d->retranslateStrings();
- }
- QDialog::changeEvent(e);
-}
-
-/*!
- \since 4.5
-
- \property QFontDialog::currentFont
- \brief the current font of the dialog.
-*/
-
-/*!
- \since 4.5
-
- Sets the font highlighted in the QFontDialog to the given \a font.
-
- \sa selectedFont()
-*/
-void QFontDialog::setCurrentFont(const QFont &font)
-{
- Q_D(QFontDialog);
- d->family = font.family();
- d->style = d->fdb.styleString(font);
- d->size = font.pointSize();
- if (d->size == -1) {
- QFontInfo fi(font);
- d->size = fi.pointSize();
- }
- d->strikeout->setChecked(font.strikeOut());
- d->underline->setChecked(font.underline());
- d->updateFamilies();
-
-#ifdef Q_WS_MAC
- if (d->delegate)
- QFontDialogPrivate::setFont(d->delegate, font);
-#endif
-}
-
-/*!
- \since 4.5
-
- Returns the current font.
-
- \sa selectedFont()
-*/
-QFont QFontDialog::currentFont() const
-{
- Q_D(const QFontDialog);
- return d->sampleEdit->font();
-}
-
-/*!
- Returns the font that the user selected by clicking the \gui{OK}
- or equivalent button.
-
- \note This font is not always the same as the font held by the
- \l currentFont property since the user can choose different fonts
- before finally selecting the one to use.
-*/
-QFont QFontDialog::selectedFont() const
-{
- Q_D(const QFontDialog);
- return d->selectedFont;
-}
-
-/*!
- \enum QFontDialog::FontDialogOption
- \since 4.5
-
- This enum specifies various options that affect the look and feel
- of a font dialog.
-
- \value NoButtons Don't display \gui{OK} and \gui{Cancel} buttons. (Useful for "live dialogs".)
- \value DontUseNativeDialog Use Qt's standard font dialog on the Mac instead of Apple's
- native font panel. (Currently, the native dialog is never used,
- but this is likely to change in future Qt releases.)
-
- \sa options, setOption(), testOption()
-*/
-
-/*!
- Sets the given \a option to be enabled if \a on is true;
- otherwise, clears the given \a option.
-
- \sa options, testOption()
-*/
-void QFontDialog::setOption(FontDialogOption option, bool on)
-{
- Q_D(QFontDialog);
- if (!(d->opts & option) != !on)
- setOptions(d->opts ^ option);
-}
-
-/*!
- Returns true if the given \a option is enabled; otherwise, returns
- false.
-
- \sa options, setOption()
-*/
-bool QFontDialog::testOption(FontDialogOption option) const
-{
- Q_D(const QFontDialog);
- return (d->opts & option) != 0;
-}
-
-/*!
- \property QFontDialog::options
- \brief the various options that affect the look and feel of the dialog
- \since 4.5
-
- By default, all options are disabled.
-
- Options should be set before showing the dialog. Setting them while the
- dialog is visible is not guaranteed to have an immediate effect on the
- dialog (depending on the option and on the platform).
-
- \sa setOption(), testOption()
-*/
-void QFontDialog::setOptions(FontDialogOptions options)
-{
- Q_D(QFontDialog);
-
- FontDialogOptions changed = (options ^ d->opts);
- if (!changed)
- return;
-
- d->opts = options;
- d->buttonBox->setVisible(!(options & NoButtons));
-}
-
-QFontDialog::FontDialogOptions QFontDialog::options() const
-{
- Q_D(const QFontDialog);
- return d->opts;
-}
-
-#ifdef Q_WS_MAC
-// can only have one Cocoa font panel active
-bool QFontDialogPrivate::sharedFontPanelAvailable = true;
-#endif
-
-/*!
- \since 4.5
- \overload
-
- Opens the dialog and connects its fontSelected() signal to the slot specified
- by \a receiver and \a member.
-
- The signal will be disconnected from the slot when the dialog is closed.
-*/
-void QFontDialog::open(QObject *receiver, const char *member)
-{
- Q_D(QFontDialog);
- connect(this, SIGNAL(fontSelected(QFont)), receiver, member);
- d->receiverToDisconnectOnClose = receiver;
- d->memberToDisconnectOnClose = member;
- QDialog::open();
-}
-
-/*!
- \since 4.5
-
- \fn void QFontDialog::currentFontChanged(const QFont &font)
-
- This signal is emitted when the current font is changed. The new font is
- specified in \a font.
-
- The signal is emitted while a user is selecting a font. Ultimately, the
- chosen font may differ from the font currently selected.
-
- \sa currentFont, fontSelected(), selectedFont()
-*/
-
-/*!
- \since 4.5
-
- \fn void QFontDialog::fontSelected(const QFont &font)
-
- This signal is emitted when a font has been selected. The selected font is
- specified in \a font.
-
- The signal is only emitted when a user has chosen the final font to be
- used. It is not emitted while the user is changing the current font in the
- font dialog.
-
- \sa selectedFont(), currentFontChanged(), currentFont
-*/
-
-/*!
- \reimp
-*/
-void QFontDialog::setVisible(bool visible)
-{
- if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden) != visible)
- return;
-#ifdef Q_WS_MAC
- Q_D(QFontDialog);
- if (d->canBeNativeDialog()){
- if (d->setVisible_sys(visible)){
- d->nativeDialogInUse = true;
- // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below
- // updates the state correctly, but skips showing the non-native version:
- setAttribute(Qt::WA_DontShowOnScreen, true);
- } else {
- d->nativeDialogInUse = false;
- setAttribute(Qt::WA_DontShowOnScreen, false);
- }
- }
-#endif // Q_WS_MAC
- QDialog::setVisible(visible);
-}
-
-/*!
- Closes the dialog and sets its result code to \a result. If this dialog
- is shown with exec(), done() causes the local event loop to finish,
- and exec() to return \a result.
-
- \sa QDialog::done()
-*/
-void QFontDialog::done(int result)
-{
- Q_D(QFontDialog);
- QDialog::done(result);
- if (result == Accepted) {
- // We check if this is the same font we had before, if so we emit currentFontChanged
- QFont selectedFont = currentFont();
- if(selectedFont != d->selectedFont)
- emit(currentFontChanged(selectedFont));
- d->selectedFont = selectedFont;
- emit fontSelected(d->selectedFont);
- } else
- d->selectedFont = QFont();
- if (d->receiverToDisconnectOnClose) {
- disconnect(this, SIGNAL(fontSelected(QFont)),
- d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
- d->receiverToDisconnectOnClose = 0;
- }
- d->memberToDisconnectOnClose.clear();
-}
-
-#ifdef Q_WS_MAC
-bool QFontDialogPrivate::canBeNativeDialog()
-{
- Q_Q(QFontDialog);
- if (nativeDialogInUse)
- return true;
- if (q->testAttribute(Qt::WA_DontShowOnScreen))
- return false;
- if (opts & QFontDialog::DontUseNativeDialog)
- return false;
-
- QLatin1String staticName(QFontDialog::staticMetaObject.className());
- QLatin1String dynamicName(q->metaObject()->className());
- return (staticName == dynamicName);
-}
-#endif // Q_WS_MAC
-
-/*!
- \fn QFont QFontDialog::getFont(bool *ok, const QFont &initial, QWidget* parent, const char* name)
- \since 4.5
-
- Call getFont(\a ok, \a initial, \a parent) instead.
-
- \warning Do not delete \a parent during the execution of the dialog.
- If you want to do this, you should create the dialog
- yourself using one of the QFontDialog constructors.
-
- The \a name parameter is ignored.
-*/
-
-/*!
- \fn QFont QFontDialog::getFont(bool *ok, QWidget* parent, const char* name)
-
- Call getFont(\a ok, \a parent) instead.
-
- \warning Do not delete \a parent during the execution of the dialog.
- If you want to do this, you should create the dialog
- yourself using one of the QFontDialog constructors.
-
- The \a name parameter is ignored.
-*/
-
-QT_END_NAMESPACE
-
-#include "qfontdialog.moc"
-#include "moc_qfontdialog.cpp"
-
-#endif // QT_NO_FONTDIALOG
diff --git a/src/gui/dialogs/qfontdialog.h b/src/gui/dialogs/qfontdialog.h
deleted file mode 100644
index a09f16d0a0..0000000000
--- a/src/gui/dialogs/qfontdialog.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFONTDIALOG_H
-#define QFONTDIALOG_H
-
-#include <QtGui/qwindowdefs.h>
-#include <QtGui/qdialog.h>
-#include <QtGui/qfont.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_FONTDIALOG
-
-class QFontDialogPrivate;
-
-class Q_GUI_EXPORT QFontDialog : public QDialog
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QFontDialog)
- Q_ENUMS(FontDialogOption)
- Q_PROPERTY(QFont currentFont READ currentFont WRITE setCurrentFont NOTIFY currentFontChanged)
- Q_PROPERTY(FontDialogOptions options READ options WRITE setOptions)
-
-public:
- enum FontDialogOption {
- NoButtons = 0x00000001,
- DontUseNativeDialog = 0x00000002
- };
-
- Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)
-
- explicit QFontDialog(QWidget *parent = 0);
- explicit QFontDialog(const QFont &initial, QWidget *parent = 0);
- ~QFontDialog();
-
- void setCurrentFont(const QFont &font);
- QFont currentFont() const;
-
- QFont selectedFont() const;
-
- void setOption(FontDialogOption option, bool on = true);
- bool testOption(FontDialogOption option) const;
- void setOptions(FontDialogOptions options);
- FontDialogOptions options() const;
-
-#ifdef Q_NO_USING_KEYWORD
-#ifndef Q_QDOC
- void open() { QDialog::open(); }
-#endif
-#else
- using QDialog::open;
-#endif
- void open(QObject *receiver, const char *member);
-
- void setVisible(bool visible);
-
- // ### Qt 5: merge overloads
- static QFont getFont(bool *ok, const QFont &initial, QWidget *parent, const QString &title,
- FontDialogOptions options);
- static QFont getFont(bool *ok, const QFont &initial, QWidget *parent, const QString &title);
- static QFont getFont(bool *ok, const QFont &initial, QWidget *parent = 0);
- static QFont getFont(bool *ok, QWidget *parent = 0);
-
-#ifdef QT3_SUPPORT
- static QFont getFont(bool *ok, const QFont &initial, QWidget *parent, const char *name)
- { Q_UNUSED(name); return getFont(ok, initial, parent); }
- static QFont getFont(bool *ok, QWidget *parent, const char *name)
- { Q_UNUSED(name); return getFont(ok, parent); }
-#endif
-
-Q_SIGNALS:
- void currentFontChanged(const QFont &font);
- void fontSelected(const QFont &font);
-
-protected:
- void changeEvent(QEvent *event);
- void done(int result);
-
-private:
- // ### Qt 5: make protected
- bool eventFilter(QObject *object, QEvent *event);
-
- Q_DISABLE_COPY(QFontDialog)
-
- Q_PRIVATE_SLOT(d_func(), void _q_sizeChanged(const QString &))
- Q_PRIVATE_SLOT(d_func(), void _q_familyHighlighted(int))
- Q_PRIVATE_SLOT(d_func(), void _q_writingSystemHighlighted(int))
- Q_PRIVATE_SLOT(d_func(), void _q_styleHighlighted(int))
- Q_PRIVATE_SLOT(d_func(), void _q_sizeHighlighted(int))
- Q_PRIVATE_SLOT(d_func(), void _q_updateSample())
-#if defined(Q_WS_MAC)
- Q_PRIVATE_SLOT(d_func(), void _q_macRunNativeAppModalPanel())
-#endif
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QFontDialog::FontDialogOptions)
-
-#endif // QT_NO_FONTDIALOG
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QFONTDIALOG_H
diff --git a/src/gui/dialogs/qfscompleter_p.h b/src/gui/dialogs/qfscompleter_p.h
deleted file mode 100644
index 26a6698a6c..0000000000
--- a/src/gui/dialogs/qfscompleter_p.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFSCOMPLETOR_P_H
-#define QFSCOMPLETOR_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qcompleter.h"
-#include <QtGui/qfilesystemmodel.h>
-QT_BEGIN_NAMESPACE
-#ifndef QT_NO_FSCOMPLETER
-
-/*!
- QCompleter that can deal with QFileSystemModel
- */
-class QFSCompleter : public QCompleter {
-public:
- QFSCompleter(QFileSystemModel *model, QObject *parent = 0)
- : QCompleter(model, parent), proxyModel(0), sourceModel(model)
- {
-#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
- setCaseSensitivity(Qt::CaseInsensitive);
-#endif
- }
- QString pathFromIndex(const QModelIndex &index) const;
- QStringList splitPath(const QString& path) const;
-
- QAbstractProxyModel *proxyModel;
- QFileSystemModel *sourceModel;
-};
-#endif // QT_NO_FSCOMPLETER
-QT_END_NAMESPACE
-#endif // QFSCOMPLETOR_P_H
-
diff --git a/src/gui/dialogs/qinputdialog.h b/src/gui/dialogs/qinputdialog.h
deleted file mode 100644
index b0e6fbb216..0000000000
--- a/src/gui/dialogs/qinputdialog.h
+++ /dev/null
@@ -1,256 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QINPUTDIALOG_H
-#define QINPUTDIALOG_H
-
-#include <QtGui/qdialog.h>
-#include <QtCore/qstring.h>
-#include <QtGui/qlineedit.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_INPUTDIALOG
-
-class QInputDialogPrivate;
-
-class Q_GUI_EXPORT QInputDialog : public QDialog
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QInputDialog)
-// Q_ENUMS(InputMode InputDialogOption)
- QDOC_PROPERTY(InputMode inputMode READ inputMode WRITE setInputMode)
- QDOC_PROPERTY(QString labelText READ labelText WRITE setLabelText)
- QDOC_PROPERTY(InputDialogOptions options READ options WRITE setOptions)
- QDOC_PROPERTY(QString textValue READ textValue WRITE setTextValue NOTIFY textValueChanged)
- QDOC_PROPERTY(int intValue READ intValue WRITE setIntValue NOTIFY intValueChanged)
- QDOC_PROPERTY(int doubleValue READ doubleValue WRITE setDoubleValue NOTIFY doubleValueChanged)
- QDOC_PROPERTY(QLineEdit::EchoMode textEchoMode READ textEchoMode WRITE setTextEchoMode)
- QDOC_PROPERTY(bool comboBoxEditable READ isComboBoxEditable WRITE setComboBoxEditable)
- QDOC_PROPERTY(QStringList comboBoxItems READ comboBoxItems WRITE setComboBoxItems)
- QDOC_PROPERTY(int intMinimum READ intMinimum WRITE setIntMinimum)
- QDOC_PROPERTY(int intMaximum READ intMaximum WRITE setIntMaximum)
- QDOC_PROPERTY(int intStep READ intStep WRITE setIntStep)
- QDOC_PROPERTY(double doubleMinimum READ doubleMinimum WRITE setDoubleMinimum)
- QDOC_PROPERTY(double doubleMaximum READ doubleMaximum WRITE setDoubleMaximum)
- QDOC_PROPERTY(int doubleDecimals READ doubleDecimals WRITE setDoubleDecimals)
- QDOC_PROPERTY(QString okButtonText READ okButtonText WRITE setOkButtonText)
- QDOC_PROPERTY(QString cancelButtonText READ cancelButtonText WRITE setCancelButtonText)
-
-public:
- enum InputDialogOption {
- NoButtons = 0x00000001,
- UseListViewForComboBoxItems = 0x00000002
- };
-
- Q_DECLARE_FLAGS(InputDialogOptions, InputDialogOption)
-
- enum InputMode {
- TextInput,
- IntInput,
- DoubleInput
- };
-
- QInputDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0);
- ~QInputDialog();
-
- void setInputMode(InputMode mode);
- InputMode inputMode() const;
-
- void setLabelText(const QString &text);
- QString labelText() const;
-
- void setOption(InputDialogOption option, bool on = true);
- bool testOption(InputDialogOption option) const;
- void setOptions(InputDialogOptions options);
- InputDialogOptions options() const;
-
- void setTextValue(const QString &text);
- QString textValue() const;
-
- void setTextEchoMode(QLineEdit::EchoMode mode);
- QLineEdit::EchoMode textEchoMode() const;
-
- void setComboBoxEditable(bool editable);
- bool isComboBoxEditable() const;
-
- void setComboBoxItems(const QStringList &items);
- QStringList comboBoxItems() const;
-
- void setIntValue(int value);
- int intValue() const;
-
- void setIntMinimum(int min);
- int intMinimum() const;
-
- void setIntMaximum(int max);
- int intMaximum() const;
-
- void setIntRange(int min, int max);
-
- void setIntStep(int step);
- int intStep() const;
-
- void setDoubleValue(double value);
- double doubleValue() const;
-
- void setDoubleMinimum(double min);
- double doubleMinimum() const;
-
- void setDoubleMaximum(double max);
- double doubleMaximum() const;
-
- void setDoubleRange(double min, double max);
-
- void setDoubleDecimals(int decimals);
- int doubleDecimals() const;
-
- void setOkButtonText(const QString &text);
- QString okButtonText() const;
-
- void setCancelButtonText(const QString &text);
- QString cancelButtonText() const;
-
-#ifdef Q_NO_USING_KEYWORD
-#ifndef Q_QDOC
- void open() { QDialog::open(); }
-#endif
-#else
- using QDialog::open;
-#endif
- void open(QObject *receiver, const char *member);
-
- QSize minimumSizeHint() const;
- QSize sizeHint() const;
-
- void setVisible(bool visible);
-
-#ifdef Q_QDOC
- static QString getText(QWidget *parent, const QString &title, const QString &label,
- QLineEdit::EchoMode echo = QLineEdit::Normal,
- const QString &text = QString(), bool *ok = 0, Qt::WindowFlags flags = 0,
- Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
- static QString getItem(QWidget *parent, const QString &title, const QString &label,
- const QStringList &items, int current = 0, bool editable = true,
- bool *ok = 0, Qt::WindowFlags flags = 0,
- Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
-#else
- static QString getText(QWidget *parent, const QString &title, const QString &label,
- QLineEdit::EchoMode echo = QLineEdit::Normal,
- const QString &text = QString(), bool *ok = 0, Qt::WindowFlags flags = 0);
- static QString getItem(QWidget *parent, const QString &title, const QString &label,
- const QStringList &items, int current = 0, bool editable = true,
- bool *ok = 0, Qt::WindowFlags flags = 0);
- static QString getText(QWidget *parent, const QString &title, const QString &label,
- QLineEdit::EchoMode echo,
- const QString &text, bool *ok, Qt::WindowFlags flags,
- Qt::InputMethodHints inputMethodHints);
- static QString getItem(QWidget *parent, const QString &title, const QString &label,
- const QStringList &items, int current, bool editable,
- bool *ok, Qt::WindowFlags flags,
- Qt::InputMethodHints inputMethodHints);
-#endif
- static int getInt(QWidget *parent, const QString &title, const QString &label, int value = 0,
- int minValue = -2147483647, int maxValue = 2147483647,
- int step = 1, bool *ok = 0, Qt::WindowFlags flags = 0);
- static double getDouble(QWidget *parent, const QString &title, const QString &label, double value = 0,
- double minValue = -2147483647, double maxValue = 2147483647,
- int decimals = 1, bool *ok = 0, Qt::WindowFlags flags = 0);
-
- // obsolete
- static int getInteger(QWidget *parent, const QString &title, const QString &label, int value = 0,
- int minValue = -2147483647, int maxValue = 2147483647,
- int step = 1, bool *ok = 0, Qt::WindowFlags flags = 0);
-
-#ifdef QT3_SUPPORT
- inline static QT3_SUPPORT QString getText(const QString &title, const QString &label,
- QLineEdit::EchoMode echo = QLineEdit::Normal,
- const QString &text = QString(), bool *ok = 0,
- QWidget *parent = 0, const char * = 0, Qt::WindowFlags flags = 0)
- { return getText(parent, title, label, echo, text, ok, flags); }
- inline static QT3_SUPPORT int getInteger(const QString &title, const QString &label, int value = 0,
- int minValue = -2147483647, int maxValue = 2147483647,
- int step = 1, bool *ok = 0,
- QWidget *parent = 0, const char * = 0, Qt::WindowFlags flags = 0)
- { return getInteger(parent, title, label, value, minValue, maxValue, step, ok, flags); }
- inline static QT3_SUPPORT double getDouble(const QString &title, const QString &label, double value = 0,
- double minValue = -2147483647, double maxValue = 2147483647,
- int decimals = 1, bool *ok = 0,
- QWidget *parent = 0, const char * = 0, Qt::WindowFlags flags = 0)
- { return getDouble(parent, title, label, value, minValue, maxValue, decimals, ok, flags); }
- inline static QT3_SUPPORT QString getItem(const QString &title, const QString &label, const QStringList &list,
- int current = 0, bool editable = true, bool *ok = 0,
- QWidget *parent = 0, const char * = 0, Qt::WindowFlags flags = 0)
- { return getItem(parent, title, label, list, current, editable, ok, flags); }
-#endif
-
-Q_SIGNALS:
- // ### emit signals!
- void textValueChanged(const QString &text);
- void textValueSelected(const QString &text);
- void intValueChanged(int value);
- void intValueSelected(int value);
- void doubleValueChanged(double value);
- void doubleValueSelected(double value);
-
-
-public:
- void done(int result); // ### Qt 5: Make protected.
-
-private:
- Q_DISABLE_COPY(QInputDialog)
- Q_PRIVATE_SLOT(d_func(), void _q_textChanged(const QString&))
- Q_PRIVATE_SLOT(d_func(), void _q_currentRowChanged(const QModelIndex&, const QModelIndex&))
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QInputDialog::InputDialogOptions)
-
-#endif // QT_NO_INPUTDIALOG
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QINPUTDIALOG_H
diff --git a/src/gui/dialogs/qmessagebox.cpp b/src/gui/dialogs/qmessagebox.cpp
deleted file mode 100644
index d6dbcf6e78..0000000000
--- a/src/gui/dialogs/qmessagebox.cpp
+++ /dev/null
@@ -1,2751 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtGui/qmessagebox.h>
-
-#ifndef QT_NO_MESSAGEBOX
-
-#include <QtGui/qdialogbuttonbox.h>
-#include "private/qlabel_p.h"
-#include "private/qapplication_p.h"
-#include <QtCore/qlist.h>
-#include <QtCore/qdebug.h>
-#include <QtGui/qstyle.h>
-#include <QtGui/qstyleoption.h>
-#include <QtGui/qgridlayout.h>
-#include <QtGui/qdesktopwidget.h>
-#include <QtGui/qpushbutton.h>
-#include <QtGui/qaccessible.h>
-#include <QtGui/qicon.h>
-#include <QtGui/qtextdocument.h>
-#include <QtGui/qapplication.h>
-#include <QtGui/qtextedit.h>
-#include <QtGui/qtextbrowser.h>
-#include <QtGui/qmenu.h>
-#include "qdialog_p.h"
-#include <QtGui/qfont.h>
-#include <QtGui/qfontmetrics.h>
-#include <QtGui/qclipboard.h>
-
-#ifndef QT_NO_STYLE_S60
-#include <qs60style.h>
-#endif
-
-#ifdef Q_WS_WINCE
-extern bool qt_wince_is_mobile(); //defined in qguifunctions_wince.cpp
-extern bool qt_wince_is_smartphone();//defined in qguifunctions_wince.cpp
-extern bool qt_wince_is_pocket_pc(); //defined in qguifunctions_wince.cpp
-
-#include "qguifunctions_wince.h"
-#endif
-
-QT_BEGIN_NAMESPACE
-
-enum Button { Old_Ok = 1, Old_Cancel = 2, Old_Yes = 3, Old_No = 4, Old_Abort = 5, Old_Retry = 6,
- Old_Ignore = 7, Old_YesAll = 8, Old_NoAll = 9, Old_ButtonMask = 0xFF,
- NewButtonMask = 0xFFFFFC00 };
-
-enum DetailButtonLabel { ShowLabel = 0, HideLabel = 1 };
-#ifndef QT_NO_TEXTEDIT
-class QMessageBoxDetailsText : public QWidget
-{
-public:
- class TextEdit : public QTextEdit
- {
- public:
- TextEdit(QWidget *parent=0) : QTextEdit(parent) { }
- void contextMenuEvent(QContextMenuEvent * e)
- {
-#ifndef QT_NO_CONTEXTMENU
- QMenu *menu = createStandardContextMenu();
- menu->setAttribute(Qt::WA_DeleteOnClose);
- menu->popup(e->globalPos());
-#else
- Q_UNUSED(e);
-#endif
- }
- };
-
- QMessageBoxDetailsText(QWidget *parent=0)
- : QWidget(parent)
- {
- QVBoxLayout *layout = new QVBoxLayout;
- layout->setMargin(0);
- QFrame *line = new QFrame(this);
- line->setFrameShape(QFrame::HLine);
- line->setFrameShadow(QFrame::Sunken);
- layout->addWidget(line);
- textEdit = new TextEdit();
- textEdit->setFixedHeight(100);
- textEdit->setFocusPolicy(Qt::NoFocus);
- textEdit->setReadOnly(true);
- layout->addWidget(textEdit);
- setLayout(layout);
- }
- void setText(const QString &text) { textEdit->setPlainText(text); }
- QString text() const { return textEdit->toPlainText(); }
-private:
- TextEdit *textEdit;
-};
-#endif // QT_NO_TEXTEDIT
-
-class DetailButton : public QPushButton
-{
-public:
- DetailButton(QWidget *parent) : QPushButton(label(ShowLabel), parent)
- {
- setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
- }
-
- QString label(DetailButtonLabel label) const
- { return label == ShowLabel ? QMessageBox::tr("Show Details...") : QMessageBox::tr("Hide Details..."); }
-
- void setLabel(DetailButtonLabel lbl)
- { setText(label(lbl)); }
-
- QSize sizeHint() const
- {
- ensurePolished();
- QStyleOptionButton opt;
- initStyleOption(&opt);
- const QFontMetrics fm = fontMetrics();
- opt.text = label(ShowLabel);
- QSize sz = fm.size(Qt::TextShowMnemonic, opt.text);
- QSize ret = style()->sizeFromContents(QStyle::CT_PushButton, &opt, sz, this).
- expandedTo(QApplication::globalStrut());
- opt.text = label(HideLabel);
- sz = fm.size(Qt::TextShowMnemonic, opt.text);
- ret.expandedTo(style()->sizeFromContents(QStyle::CT_PushButton, &opt, sz, this).
- expandedTo(QApplication::globalStrut()));
- return ret;
- }
-};
-
-
-class QMessageBoxPrivate : public QDialogPrivate
-{
- Q_DECLARE_PUBLIC(QMessageBox)
-
-public:
- QMessageBoxPrivate() : escapeButton(0), defaultButton(0), clickedButton(0), detailsButton(0),
-#ifndef QT_NO_TEXTEDIT
- detailsText(0),
-#endif
- compatMode(false), autoAddOkButton(true),
- detectedEscapeButton(0), informativeLabel(0) { }
-
- void init(const QString &title = QString(), const QString &text = QString());
- void _q_buttonClicked(QAbstractButton *);
-
- QAbstractButton *findButton(int button0, int button1, int button2, int flags);
- void addOldButtons(int button0, int button1, int button2);
-
- QAbstractButton *abstractButtonForId(int id) const;
- int execReturnCode(QAbstractButton *button);
-
- void detectEscapeButton();
- void updateSize();
- int layoutMinimumWidth();
- void retranslateStrings();
-
-#ifdef Q_WS_WINCE
- void hideSpecial();
-#endif
-
- static int showOldMessageBox(QWidget *parent, QMessageBox::Icon icon,
- const QString &title, const QString &text,
- int button0, int button1, int button2);
- static int showOldMessageBox(QWidget *parent, QMessageBox::Icon icon,
- const QString &title, const QString &text,
- const QString &button0Text,
- const QString &button1Text,
- const QString &button2Text,
- int defaultButtonNumber,
- int escapeButtonNumber);
-
- static QMessageBox::StandardButton showNewMessageBox(QWidget *parent,
- QMessageBox::Icon icon, const QString& title, const QString& text,
- QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton);
-
- static QPixmap standardIcon(QMessageBox::Icon icon, QMessageBox *mb);
-
- QLabel *label;
- QMessageBox::Icon icon;
- QLabel *iconLabel;
- QDialogButtonBox *buttonBox;
- QList<QAbstractButton *> customButtonList;
- QAbstractButton *escapeButton;
- QPushButton *defaultButton;
- QAbstractButton *clickedButton;
- DetailButton *detailsButton;
-#ifndef QT_NO_TEXTEDIT
- QMessageBoxDetailsText *detailsText;
-#endif
- bool compatMode;
- bool autoAddOkButton;
- QAbstractButton *detectedEscapeButton;
- QLabel *informativeLabel;
-#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5)
- QTextBrowser *textBrowser;
-#endif
- QPointer<QObject> receiverToDisconnectOnClose;
- QByteArray memberToDisconnectOnClose;
- QByteArray signalToDisconnectOnClose;
-};
-
-void QMessageBoxPrivate::init(const QString &title, const QString &text)
-{
- Q_Q(QMessageBox);
-
- label = new QLabel;
- label->setObjectName(QLatin1String("qt_msgbox_label"));
- label->setTextInteractionFlags(Qt::TextInteractionFlags(q->style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, 0, q)));
- label->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
- label->setOpenExternalLinks(true);
-#if defined(Q_WS_MAC)
- label->setContentsMargins(16, 0, 0, 0);
-#elif !defined(Q_WS_QWS)
- label->setContentsMargins(2, 0, 0, 0);
- label->setIndent(9);
-#endif
- icon = QMessageBox::NoIcon;
- iconLabel = new QLabel;
- iconLabel->setObjectName(QLatin1String("qt_msgboxex_icon_label"));
- iconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
-
- buttonBox = new QDialogButtonBox;
- buttonBox->setObjectName(QLatin1String("qt_msgbox_buttonbox"));
- buttonBox->setCenterButtons(q->style()->styleHint(QStyle::SH_MessageBox_CenterButtons, 0, q));
- QObject::connect(buttonBox, SIGNAL(clicked(QAbstractButton*)),
- q, SLOT(_q_buttonClicked(QAbstractButton*)));
-
- QGridLayout *grid = new QGridLayout;
-#ifndef Q_WS_MAC
- grid->addWidget(iconLabel, 0, 0, 2, 1, Qt::AlignTop);
- grid->addWidget(label, 0, 1, 1, 1);
- // -- leave space for information label --
- grid->addWidget(buttonBox, 2, 0, 1, 2);
-#else
- grid->setMargin(0);
- grid->setVerticalSpacing(8);
- grid->setHorizontalSpacing(0);
- q->setContentsMargins(24, 15, 24, 20);
- grid->addWidget(iconLabel, 0, 0, 2, 1, Qt::AlignTop | Qt::AlignLeft);
- grid->addWidget(label, 0, 1, 1, 1);
- // -- leave space for information label --
- grid->setRowStretch(1, 100);
- grid->setRowMinimumHeight(2, 6);
- grid->addWidget(buttonBox, 3, 1, 1, 1);
-#endif
-
- grid->setSizeConstraint(QLayout::SetNoConstraint);
- q->setLayout(grid);
-
- if (!title.isEmpty() || !text.isEmpty()) {
- q->setWindowTitle(title);
- q->setText(text);
- }
- q->setModal(true);
-
-#ifdef Q_WS_MAC
- QFont f = q->font();
- f.setBold(true);
- label->setFont(f);
-#endif
- retranslateStrings();
-}
-
-int QMessageBoxPrivate::layoutMinimumWidth()
-{
- layout->activate();
- return layout->totalMinimumSize().width();
-}
-
-void QMessageBoxPrivate::updateSize()
-{
- Q_Q(QMessageBox);
-
- if (!q->isVisible())
- return;
-
- QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size();
-#if defined(Q_WS_QWS) || defined(Q_WS_WINCE) || defined(Q_OS_SYMBIAN)
- // the width of the screen, less the window border.
- int hardLimit = screenSize.width() - (q->frameGeometry().width() - q->geometry().width());
-#else
- int hardLimit = qMin(screenSize.width() - 480, 1000); // can never get bigger than this
- // on small screens allows the messagebox be the same size as the screen
- if (screenSize.width() <= 1024)
- hardLimit = screenSize.width();
-#endif
-#ifdef Q_WS_MAC
- int softLimit = qMin(screenSize.width()/2, 420);
-#elif defined(Q_WS_QWS)
- int softLimit = qMin(hardLimit, 500);
-#else
- // note: ideally on windows, hard and soft limits but it breaks compat
-#ifndef Q_WS_WINCE
- int softLimit = qMin(screenSize.width()/2, 500);
-#else
- int softLimit = qMin(screenSize.width() * 3 / 4, 500);
-#endif //Q_WS_WINCE
-#endif
-
- if (informativeLabel)
- informativeLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
-
- label->setWordWrap(false); // makes the label return min size
- int width = layoutMinimumWidth();
-
- if (width > softLimit) {
- label->setWordWrap(true);
- width = qMax(softLimit, layoutMinimumWidth());
-
- if (width > hardLimit) {
- label->d_func()->ensureTextControl();
- if (QTextControl *control = label->d_func()->control) {
- QTextOption opt = control->document()->defaultTextOption();
- opt.setWrapMode(QTextOption::WrapAnywhere);
- control->document()->setDefaultTextOption(opt);
- }
- width = hardLimit;
- }
- }
-#ifdef Q_WS_S60
- // in S60 portait messageBoxes should always occupy maximum width
- if (QApplication::desktop()->size().height() > QApplication::desktop()->size().width()){
- width = hardLimit;
- } else {
- // in landscape the messageBoxes should be of same width as in portrait
- width = qMin(QApplication::desktop()->size().height(), hardLimit);
- }
-#endif
-
- if (informativeLabel) {
- label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
- QSizePolicy policy(QSizePolicy::Minimum, QSizePolicy::Preferred);
- policy.setHeightForWidth(true);
- informativeLabel->setSizePolicy(policy);
- width = qMax(width, layoutMinimumWidth());
- if (width > hardLimit) { // longest word is really big, so wrap anywhere
- informativeLabel->d_func()->ensureTextControl();
- if (QTextControl *control = informativeLabel->d_func()->control) {
- QTextOption opt = control->document()->defaultTextOption();
- opt.setWrapMode(QTextOption::WrapAnywhere);
- control->document()->setDefaultTextOption(opt);
- }
- width = hardLimit;
- }
- policy.setHeightForWidth(label->wordWrap());
- label->setSizePolicy(policy);
- }
-
- QFontMetrics fm(QApplication::font("QWorkspaceTitleBar"));
- int windowTitleWidth = qMin(fm.width(q->windowTitle()) + 50, hardLimit);
- if (windowTitleWidth > width)
- width = windowTitleWidth;
-
- layout->activate();
- int height = (layout->hasHeightForWidth())
- ? layout->totalHeightForWidth(width)
- : layout->totalMinimumSize().height();
-
-#ifndef QT_NO_STYLE_S60
- QS60Style *s60Style = 0;
- s60Style = qobject_cast<QS60Style *>(QApplication::style());
-
- //use custom pixel metric to deduce the minimum height of the messagebox
- if (s60Style)
- height = qMax(height, s60Style->pixelMetric((QStyle::PixelMetric)PM_MessageBoxHeight));
-#endif
-
- q->setFixedSize(width, height);
- QCoreApplication::removePostedEvents(q, QEvent::LayoutRequest);
-}
-
-
-#ifdef Q_WS_WINCE
-/*!
- \internal
- Hides special buttons which are rather shown in the title bar
- on WinCE, to conserve screen space.
-*/
-
-void QMessageBoxPrivate::hideSpecial()
-{
- Q_Q(QMessageBox);
- QList<QPushButton*> list = q->findChildren<QPushButton*>();
- for (int i=0; i<list.size(); ++i) {
- QPushButton *pb = list.at(i);
- QString text = pb->text();
- text.remove(QChar::fromLatin1('&'));
- if (text == QApplication::translate("QMessageBox", "OK" ))
- pb->setFixedSize(0,0);
- }
-}
-#endif
-
-static int oldButton(int button)
-{
- switch (button & QMessageBox::ButtonMask) {
- case QMessageBox::Ok:
- return Old_Ok;
- case QMessageBox::Cancel:
- return Old_Cancel;
- case QMessageBox::Yes:
- return Old_Yes;
- case QMessageBox::No:
- return Old_No;
- case QMessageBox::Abort:
- return Old_Abort;
- case QMessageBox::Retry:
- return Old_Retry;
- case QMessageBox::Ignore:
- return Old_Ignore;
- case QMessageBox::YesToAll:
- return Old_YesAll;
- case QMessageBox::NoToAll:
- return Old_NoAll;
- default:
- return 0;
- }
-}
-
-int QMessageBoxPrivate::execReturnCode(QAbstractButton *button)
-{
- int ret = buttonBox->standardButton(button);
- if (ret == QMessageBox::NoButton) {
- ret = customButtonList.indexOf(button); // if button == 0, correctly sets ret = -1
- } else if (compatMode) {
- ret = oldButton(ret);
- }
- return ret;
-}
-
-void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button)
-{
- Q_Q(QMessageBox);
-#ifndef QT_NO_TEXTEDIT
- if (detailsButton && detailsText && button == detailsButton) {
- detailsButton->setLabel(detailsText->isHidden() ? HideLabel : ShowLabel);
- detailsText->setHidden(!detailsText->isHidden());
- updateSize();
- } else
-#endif
- {
- clickedButton = button;
- q->done(execReturnCode(button)); // does not trigger closeEvent
- emit q->buttonClicked(button);
-
- if (receiverToDisconnectOnClose) {
- QObject::disconnect(q, signalToDisconnectOnClose, receiverToDisconnectOnClose,
- memberToDisconnectOnClose);
- receiverToDisconnectOnClose = 0;
- }
- signalToDisconnectOnClose.clear();
- memberToDisconnectOnClose.clear();
- }
-}
-
-/*!
- \class QMessageBox
-
- \brief The QMessageBox class provides a modal dialog for informing
- the user or for asking the user a question and receiving an answer.
-
- \ingroup standard-dialogs
-
-
- A message box displays a primary \l{QMessageBox::text}{text} to
- alert the user to a situation, an \l{QMessageBox::informativeText}
- {informative text} to further explain the alert or to ask the user
- a question, and an optional \l{QMessageBox::detailedText}
- {detailed text} to provide even more data if the user requests
- it. A message box can also display an \l{QMessageBox::icon} {icon}
- and \l{QMessageBox::standardButtons} {standard buttons} for
- accepting a user response.
-
- Two APIs for using QMessageBox are provided, the property-based
- API, and the static functions. Calling one of the static functions
- is the simpler approach, but it is less flexible than using the
- property-based API, and the result is less informative. Using the
- property-based API is recommended.
-
- \section1 The Property-based API
-
- To use the property-based API, construct an instance of
- QMessageBox, set the desired properties, and call exec() to show
- the message. The simplest configuration is to set only the
- \l{QMessageBox::text} {message text} property.
-
- \snippet doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp 5
-
- The user must click the \gui{OK} button to dismiss the message
- box. The rest of the GUI is blocked until the message box is
- dismissed.
-
- \image msgbox1.png
-
- A better approach than just alerting the user to an event is to
- also ask the user what to do about it. Store the question in the
- \l{QMessageBox::informativeText} {informative text} property, and
- set the \l{QMessageBox::standardButtons} {standard buttons}
- property to the set of buttons you want as the set of user
- responses. The buttons are specified by combining values from
- StandardButtons using the bitwise OR operator. The display order
- for the buttons is platform-dependent. For example, on Windows,
- \gui{Save} is displayed to the left of \gui{Cancel}, whereas on
- Mac OS, the order is reversed.
-
- Mark one of your standard buttons to be your
- \l{QMessageBox::defaultButton()} {default button}.
-
- \snippet doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp 6
-
- This is the approach recommended in the
- \l{http://developer.apple.com/documentation/UserExperience/Conceptual/AppleHIGuidelines/XHIGWindows/chapter_18_section_7.html}
- {Mac OS X Guidlines}. Similar guidlines apply for the other
- platforms, but note the different ways the
- \l{QMessageBox::informativeText} {informative text} is handled for
- different platforms.
-
- \image msgbox2.png
-
- The exec() slot returns the StandardButtons value of the button
- that was clicked.
-
- \snippet doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp 7
-
- To give the user more information to help him answer the question,
- set the \l{QMessageBox::detailedText} {detailed text} property. If
- the \l{QMessageBox::detailedText} {detailed text} property is set,
- the \gui{Show Details...} button will be shown.
-
- \image msgbox3.png
-
- Clicking the \gui{Show Details...} button displays the detailed text.
-
- \image msgbox4.png
-
- \section2 Rich Text and the Text Format Property
-
- The \l{QMessageBox::detailedText} {detailed text} property is
- always interpreted as plain text. The \l{QMessageBox::text} {main
- text} and \l{QMessageBox::informativeText} {informative text}
- properties can be either plain text or rich text. These strings
- are interpreted according to the setting of the
- \l{QMessageBox::textFormat} {text format} property. The default
- setting is \l{Qt::AutoText} {auto-text}.
-
- Note that for some plain text strings containing XML
- meta-characters, the auto-text \l{Qt::mightBeRichText()} {rich
- text detection test} may fail causing your plain text string to be
- interpreted incorrectly as rich text. In these rare cases, use
- Qt::convertFromPlainText() to convert your plain text string to a
- visually equivalent rich text string, or set the
- \l{QMessageBox::textFormat} {text format} property explicitly with
- setTextFormat().
-
- \section2 Severity Levels and the Icon and Pixmap Properties
-
- QMessageBox supports four predefined message severity levels, or message
- types, which really only differ in the predefined icon they each show.
- Specify one of the four predefined message types by setting the
- \l{QMessageBox::icon}{icon} property to one of the
- \l{QMessageBox::Icon}{predefined icons}. The following rules are
- guidelines:
-
- \table
- \row
- \o \img qmessagebox-quest.png
- \o \l Question
- \o For asking a question during normal operations.
- \row
- \o \img qmessagebox-info.png
- \o \l Information
- \o For reporting information about normal operations.
- \row
- \o \img qmessagebox-warn.png
- \o \l Warning
- \o For reporting non-critical errors.
- \row
- \o \img qmessagebox-crit.png
- \o \l Critical
- \o For reporting critical errors.
- \endtable
-
- \l{QMessageBox::Icon}{Predefined icons} are not defined by QMessageBox, but
- provided by the style. The default value is \l{QMessageBox::NoIcon}
- {No Icon}. The message boxes are otherwise the same for all cases. When
- using a standard icon, use the one recommended in the table, or use the
- one recommended by the style guidelines for your platform. If none of the
- standard icons is right for your message box, you can use a custom icon by
- setting the \l{QMessageBox::iconPixmap}{icon pixmap} property instead of
- setting the \l{QMessageBox::icon}{icon} property.
-
- In summary, to set an icon, use \e{either} setIcon() for one of the
- standard icons, \e{or} setIconPixmap() for a custom icon.
-
- \section1 The Static Functions API
-
- Building message boxes with the static functions API, although
- convenient, is less flexible than using the property-based API,
- because the static function signatures lack parameters for setting
- the \l{QMessageBox::informativeText} {informative text} and
- \l{QMessageBox::detailedText} {detailed text} properties. One
- work-around for this has been to use the \c{title} parameter as
- the message box main text and the \c{text} parameter as the
- message box informative text. Because this has the obvious
- drawback of making a less readable message box, platform
- guidelines do not recommend it. The \e{Microsoft Windows User
- Interface Guidelines} recommend using the
- \l{QCoreApplication::applicationName} {application name} as the
- \l{QMessageBox::setWindowTitle()} {window's title}, which means
- that if you have an informative text in addition to your main
- text, you must concatenate it to the \c{text} parameter.
-
- Note that the static function signatures have changed with respect
- to their button parameters, which are now used to set the
- \l{QMessageBox::standardButtons} {standard buttons} and the
- \l{QMessageBox::defaultButton()} {default button}.
-
- Static functions are available for creating information(),
- question(), warning(), and critical() message boxes.
-
- \snippet doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp 0
-
- The \l{dialogs/standarddialogs}{Standard Dialogs} example shows
- how to use QMessageBox and the other built-in Qt dialogs.
-
- \section1 Advanced Usage
-
- If the \l{QMessageBox::StandardButtons} {standard buttons} are not
- flexible enough for your message box, you can use the addButton()
- overload that takes a text and a ButtonRoleto to add custom
- buttons. The ButtonRole is used by QMessageBox to determine the
- ordering of the buttons on screen (which varies according to the
- platform). You can test the value of clickedButton() after calling
- exec(). For example,
-
- \snippet doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp 2
-
- \section1 Default and Escape Keys
-
- The default button (i.e., the button activated when \key Enter is
- pressed) can be specified using setDefaultButton(). If a default
- button is not specified, QMessageBox tries to find one based on
- the \l{ButtonRole} {button roles} of the buttons used in the
- message box.
-
- The escape button (the button activated when \key Esc is pressed)
- can be specified using setEscapeButton(). If an escape button is
- not specified, QMessageBox tries to find one using these rules:
-
- \list 1
-
- \o If there is only one button, it is the button activated when
- \key Esc is pressed.
-
- \o If there is a \l Cancel button, it is the button activated when
- \key Esc is pressed.
-
- \o If there is exactly one button having either
- \l{QMessageBox::RejectRole} {the Reject role} or the
- \l{QMessageBox::NoRole} {the No role}, it is the button
- activated when \key Esc is pressed.
-
- \endlist
-
- When an escape button can't be determined using these rules,
- pressing \key Esc has no effect.
-
- \sa QDialogButtonBox, {fowler}{GUI Design Handbook: Message Box}, {Standard Dialogs Example}, {Application Example}
-*/
-
-/*!
- \enum QMessageBox::StandardButton
- \since 4.2
-
- These enums describe flags for standard buttons. Each button has a
- defined \l ButtonRole.
-
- \value Ok An "OK" button defined with the \l AcceptRole.
- \value Open A "Open" button defined with the \l AcceptRole.
- \value Save A "Save" button defined with the \l AcceptRole.
- \value Cancel A "Cancel" button defined with the \l RejectRole.
- \value Close A "Close" button defined with the \l RejectRole.
- \value Discard A "Discard" or "Don't Save" button, depending on the platform,
- defined with the \l DestructiveRole.
- \value Apply An "Apply" button defined with the \l ApplyRole.
- \value Reset A "Reset" button defined with the \l ResetRole.
- \value RestoreDefaults A "Restore Defaults" button defined with the \l ResetRole.
- \value Help A "Help" button defined with the \l HelpRole.
- \value SaveAll A "Save All" button defined with the \l AcceptRole.
- \value Yes A "Yes" button defined with the \l YesRole.
- \value YesToAll A "Yes to All" button defined with the \l YesRole.
- \value No A "No" button defined with the \l NoRole.
- \value NoToAll A "No to All" button defined with the \l NoRole.
- \value Abort An "Abort" button defined with the \l RejectRole.
- \value Retry A "Retry" button defined with the \l AcceptRole.
- \value Ignore An "Ignore" button defined with the \l AcceptRole.
-
- \value NoButton An invalid button.
-
- \omitvalue FirstButton
- \omitvalue LastButton
-
- The following values are obsolete:
-
- \value YesAll Use YesToAll instead.
- \value NoAll Use NoToAll instead.
- \value Default Use the \c defaultButton argument of
- information(), warning(), etc. instead, or call
- setDefaultButton().
- \value Escape Call setEscapeButton() instead.
- \value FlagMask
- \value ButtonMask
-
- \sa ButtonRole, standardButtons
-*/
-
-/*!
- \fn void QMessageBox::buttonClicked(QAbstractButton *button)
-
- This signal is emitted whenever a button is clicked inside the QMessageBox.
- The button that was clicked in returned in \a button.
-*/
-
-/*!
- Constructs a message box with no text and no buttons. \a parent is
- passed to the QDialog constructor.
-
- On Mac OS X, if you want your message box to appear
- as a Qt::Sheet of its \a parent, set the message box's
- \l{setWindowModality()} {window modality} to Qt::WindowModal or use open().
- Otherwise, the message box will be a standard dialog.
-
-*/
-QMessageBox::QMessageBox(QWidget *parent)
- : QDialog(*new QMessageBoxPrivate, parent, Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint)
-{
- Q_D(QMessageBox);
- d->init();
-}
-
-/*!
- Constructs a message box with the given \a icon, \a title, \a
- text, and standard \a buttons. Standard or custom buttons can be
- added at any time using addButton(). The \a parent and \a f
- arguments are passed to the QDialog constructor.
-
- The message box is an \l{Qt::ApplicationModal} {application modal}
- dialog box.
-
- On Mac OS X, if \a parent is not 0 and you want your message box
- to appear as a Qt::Sheet of that parent, set the message box's
- \l{setWindowModality()} {window modality} to Qt::WindowModal
- (default). Otherwise, the message box will be a standard dialog.
-
- \sa setWindowTitle(), setText(), setIcon(), setStandardButtons()
-*/
-QMessageBox::QMessageBox(Icon icon, const QString &title, const QString &text,
- StandardButtons buttons, QWidget *parent,
- Qt::WindowFlags f)
-: QDialog(*new QMessageBoxPrivate, parent, f | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint)
-{
- Q_D(QMessageBox);
- d->init(title, text);
- setIcon(icon);
- if (buttons != NoButton)
- setStandardButtons(buttons);
-}
-
-/*!
- Destroys the message box.
-*/
-QMessageBox::~QMessageBox()
-{
-}
-
-/*!
- \since 4.2
-
- Adds the given \a button to the message box with the specified \a
- role.
-
- \sa removeButton(), button(), setStandardButtons()
-*/
-void QMessageBox::addButton(QAbstractButton *button, ButtonRole role)
-{
- Q_D(QMessageBox);
- if (!button)
- return;
- removeButton(button);
- d->buttonBox->addButton(button, (QDialogButtonBox::ButtonRole)role);
- d->customButtonList.append(button);
- d->autoAddOkButton = false;
-}
-
-/*!
- \since 4.2
- \overload
-
- Creates a button with the given \a text, adds it to the message box for the
- specified \a role, and returns it.
-*/
-QPushButton *QMessageBox::addButton(const QString& text, ButtonRole role)
-{
- Q_D(QMessageBox);
- QPushButton *pushButton = new QPushButton(text);
- addButton(pushButton, role);
- d->updateSize();
- return pushButton;
-}
-
-/*!
- \since 4.2
- \overload
-
- Adds a standard \a button to the message box if it is valid to do so, and
- returns the push button.
-
- \sa setStandardButtons()
-*/
-QPushButton *QMessageBox::addButton(StandardButton button)
-{
- Q_D(QMessageBox);
- QPushButton *pushButton = d->buttonBox->addButton((QDialogButtonBox::StandardButton)button);
- if (pushButton)
- d->autoAddOkButton = false;
- return pushButton;
-}
-
-/*!
- \since 4.2
-
- Removes \a button from the button box without deleting it.
-
- \sa addButton(), setStandardButtons()
-*/
-void QMessageBox::removeButton(QAbstractButton *button)
-{
- Q_D(QMessageBox);
- d->customButtonList.removeAll(button);
- if (d->escapeButton == button)
- d->escapeButton = 0;
- if (d->defaultButton == button)
- d->defaultButton = 0;
- d->buttonBox->removeButton(button);
- d->updateSize();
-}
-
-/*!
- \property QMessageBox::standardButtons
- \brief collection of standard buttons in the message box
- \since 4.2
-
- This property controls which standard buttons are used by the message box.
-
- By default, this property contains no standard buttons.
-
- \sa addButton()
-*/
-void QMessageBox::setStandardButtons(StandardButtons buttons)
-{
- Q_D(QMessageBox);
- d->buttonBox->setStandardButtons(QDialogButtonBox::StandardButtons(int(buttons)));
-
- QList<QAbstractButton *> buttonList = d->buttonBox->buttons();
- if (!buttonList.contains(d->escapeButton))
- d->escapeButton = 0;
- if (!buttonList.contains(d->defaultButton))
- d->defaultButton = 0;
- d->autoAddOkButton = false;
- d->updateSize();
-}
-
-QMessageBox::StandardButtons QMessageBox::standardButtons() const
-{
- Q_D(const QMessageBox);
- return QMessageBox::StandardButtons(int(d->buttonBox->standardButtons()));
-}
-
-/*!
- \since 4.2
-
- Returns the standard button enum value corresponding to the given \a button,
- or NoButton if the given \a button isn't a standard button.
-
- \sa button(), standardButtons()
-*/
-QMessageBox::StandardButton QMessageBox::standardButton(QAbstractButton *button) const
-{
- Q_D(const QMessageBox);
- return (QMessageBox::StandardButton)d->buttonBox->standardButton(button);
-}
-
-/*!
- \since 4.2
-
- Returns a pointer corresponding to the standard button \a which,
- or 0 if the standard button doesn't exist in this message box.
-
- \sa standardButtons, standardButton()
-*/
-QAbstractButton *QMessageBox::button(StandardButton which) const
-{
- Q_D(const QMessageBox);
- return d->buttonBox->button(QDialogButtonBox::StandardButton(which));
-}
-
-/*!
- \since 4.2
-
- Returns the button that is activated when escape is pressed.
-
- By default, QMessageBox attempts to automatically detect an
- escape button as follows:
-
- \list 1
- \o If there is only one button, it is made the escape button.
- \o If there is a \l Cancel button, it is made the escape button.
- \o On Mac OS X only, if there is exactly one button with the role
- QMessageBox::RejectRole, it is made the escape button.
- \endlist
-
- When an escape button could not be automatically detected, pressing
- \key Esc has no effect.
-
- \sa addButton()
-*/
-QAbstractButton *QMessageBox::escapeButton() const
-{
- Q_D(const QMessageBox);
- return d->escapeButton;
-}
-
-/*!
- \since 4.2
-
- Sets the button that gets activated when the \key Escape key is
- pressed to \a button.
-
- \sa addButton(), clickedButton()
-*/
-void QMessageBox::setEscapeButton(QAbstractButton *button)
-{
- Q_D(QMessageBox);
- if (d->buttonBox->buttons().contains(button))
- d->escapeButton = button;
-}
-
-/*!
- \since 4.3
-
- Sets the buttons that gets activated when the \key Escape key is
- pressed to \a button.
-
- \sa addButton(), clickedButton()
-*/
-void QMessageBox::setEscapeButton(QMessageBox::StandardButton button)
-{
- Q_D(QMessageBox);
- setEscapeButton(d->buttonBox->button(QDialogButtonBox::StandardButton(button)));
-}
-
-void QMessageBoxPrivate::detectEscapeButton()
-{
- if (escapeButton) { // escape button explicitly set
- detectedEscapeButton = escapeButton;
- return;
- }
-
- // Cancel button automatically becomes escape button
- detectedEscapeButton = buttonBox->button(QDialogButtonBox::Cancel);
- if (detectedEscapeButton)
- return;
-
- // If there is only one button, make it the escape button
- const QList<QAbstractButton *> buttons = buttonBox->buttons();
- if (buttons.count() == 1) {
- detectedEscapeButton = buttons.first();
- return;
- }
-
- // if the message box has one RejectRole button, make it the escape button
- for (int i = 0; i < buttons.count(); i++) {
- if (buttonBox->buttonRole(buttons.at(i)) == QDialogButtonBox::RejectRole) {
- if (detectedEscapeButton) { // already detected!
- detectedEscapeButton = 0;
- break;
- }
- detectedEscapeButton = buttons.at(i);
- }
- }
- if (detectedEscapeButton)
- return;
-
- // if the message box has one NoRole button, make it the escape button
- for (int i = 0; i < buttons.count(); i++) {
- if (buttonBox->buttonRole(buttons.at(i)) == QDialogButtonBox::NoRole) {
- if (detectedEscapeButton) { // already detected!
- detectedEscapeButton = 0;
- break;
- }
- detectedEscapeButton = buttons.at(i);
- }
- }
-}
-
-/*!
- \since 4.2
-
- Returns the button that was clicked by the user,
- or 0 if the user hit the \key Esc key and
- no \l{setEscapeButton()}{escape button} was set.
-
- If exec() hasn't been called yet, returns 0.
-
- Example:
-
- \snippet doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp 3
-
- \sa standardButton(), button()
-*/
-QAbstractButton *QMessageBox::clickedButton() const
-{
- Q_D(const QMessageBox);
- return d->clickedButton;
-}
-
-/*!
- \since 4.2
-
- Returns the button that should be the message box's
- \l{QPushButton::setDefault()}{default button}. Returns 0
- if no default button was set.
-
- \sa addButton(), QPushButton::setDefault()
-*/
-QPushButton *QMessageBox::defaultButton() const
-{
- Q_D(const QMessageBox);
- return d->defaultButton;
-}
-
-/*!
- \since 4.2
-
- Sets the message box's \l{QPushButton::setDefault()}{default button}
- to \a button.
-
- \sa addButton(), QPushButton::setDefault()
-*/
-void QMessageBox::setDefaultButton(QPushButton *button)
-{
- Q_D(QMessageBox);
- if (!d->buttonBox->buttons().contains(button))
- return;
- d->defaultButton = button;
- button->setDefault(true);
- button->setFocus();
-}
-
-/*!
- \since 4.3
-
- Sets the message box's \l{QPushButton::setDefault()}{default button}
- to \a button.
-
- \sa addButton(), QPushButton::setDefault()
-*/
-void QMessageBox::setDefaultButton(QMessageBox::StandardButton button)
-{
- Q_D(QMessageBox);
- setDefaultButton(d->buttonBox->button(QDialogButtonBox::StandardButton(button)));
-}
-
-/*!
- \property QMessageBox::text
- \brief the message box text to be displayed.
-
- The text will be interpreted either as a plain text or as rich text,
- depending on the text format setting (\l QMessageBox::textFormat).
- The default setting is Qt::AutoText, i.e., the message box will try
- to auto-detect the format of the text.
-
- The default value of this property is an empty string.
-
- \sa textFormat, QMessageBox::informativeText, QMessageBox::detailedText
-*/
-QString QMessageBox::text() const
-{
- Q_D(const QMessageBox);
- return d->label->text();
-}
-
-void QMessageBox::setText(const QString &text)
-{
- Q_D(QMessageBox);
- d->label->setText(text);
- d->label->setWordWrap(d->label->textFormat() == Qt::RichText
- || (d->label->textFormat() == Qt::AutoText && Qt::mightBeRichText(text)));
- d->updateSize();
-}
-
-/*!
- \enum QMessageBox::Icon
-
- This enum has the following values:
-
- \value NoIcon the message box does not have any icon.
-
- \value Question an icon indicating that
- the message is asking a question.
-
- \value Information an icon indicating that
- the message is nothing out of the ordinary.
-
- \value Warning an icon indicating that the
- message is a warning, but can be dealt with.
-
- \value Critical an icon indicating that
- the message represents a critical problem.
-
-*/
-
-/*!
- \property QMessageBox::icon
- \brief the message box's icon
-
- The icon of the message box can be specified with one of the
- values:
-
- \list
- \o QMessageBox::NoIcon
- \o QMessageBox::Question
- \o QMessageBox::Information
- \o QMessageBox::Warning
- \o QMessageBox::Critical
- \endlist
-
- The default is QMessageBox::NoIcon.
-
- The pixmap used to display the actual icon depends on the current
- \l{QWidget::style()} {GUI style}. You can also set a custom pixmap
- for the icon by setting the \l{QMessageBox::iconPixmap} {icon
- pixmap} property.
-
- \sa iconPixmap
-*/
-QMessageBox::Icon QMessageBox::icon() const
-{
- Q_D(const QMessageBox);
- return d->icon;
-}
-
-void QMessageBox::setIcon(Icon icon)
-{
- Q_D(QMessageBox);
- setIconPixmap(QMessageBoxPrivate::standardIcon((QMessageBox::Icon)icon,
- this));
- d->icon = icon;
-}
-
-/*!
- \property QMessageBox::iconPixmap
- \brief the current icon
-
- The icon currently used by the message box. Note that it's often
- hard to draw one pixmap that looks appropriate in all GUI styles;
- you may want to supply a different pixmap for each platform.
-
- By default, this property is undefined.
-
- \sa icon
-*/
-QPixmap QMessageBox::iconPixmap() const
-{
- Q_D(const QMessageBox);
- if (d->iconLabel && d->iconLabel->pixmap())
- return *d->iconLabel->pixmap();
- return QPixmap();
-}
-
-void QMessageBox::setIconPixmap(const QPixmap &pixmap)
-{
- Q_D(QMessageBox);
- d->iconLabel->setPixmap(pixmap);
- d->updateSize();
- d->icon = NoIcon;
-}
-
-/*!
- \property QMessageBox::textFormat
- \brief the format of the text displayed by the message box
-
- The current text format used by the message box. See the \l
- Qt::TextFormat enum for an explanation of the possible options.
-
- The default format is Qt::AutoText.
-
- \sa setText()
-*/
-Qt::TextFormat QMessageBox::textFormat() const
-{
- Q_D(const QMessageBox);
- return d->label->textFormat();
-}
-
-void QMessageBox::setTextFormat(Qt::TextFormat format)
-{
- Q_D(QMessageBox);
- d->label->setTextFormat(format);
- d->label->setWordWrap(format == Qt::RichText
- || (format == Qt::AutoText && Qt::mightBeRichText(d->label->text())));
- d->updateSize();
-}
-
-/*!
- \reimp
-*/
-bool QMessageBox::event(QEvent *e)
-{
- bool result =QDialog::event(e);
- switch (e->type()) {
- case QEvent::LayoutRequest:
- d_func()->updateSize();
- break;
- case QEvent::LanguageChange:
- d_func()->retranslateStrings();
- break;
-#ifdef Q_WS_WINCE
- case QEvent::OkRequest:
- case QEvent::HelpRequest: {
- QString bName =
- (e->type() == QEvent::OkRequest)
- ? QApplication::translate("QMessageBox", "OK")
- : QApplication::translate("QMessageBox", "Help");
- QList<QPushButton*> list = findChildren<QPushButton*>();
- for (int i=0; i<list.size(); ++i) {
- QPushButton *pb = list.at(i);
- if (pb->text() == bName) {
- if (pb->isEnabled())
- pb->click();
- return pb->isEnabled();
- }
- }
- }
-#endif
- default:
- break;
- }
- return result;
-}
-
-/*!
- \reimp
-*/
-void QMessageBox::resizeEvent(QResizeEvent *event)
-{
- QDialog::resizeEvent(event);
-}
-
-/*!
- \reimp
-*/
-void QMessageBox::closeEvent(QCloseEvent *e)
-{
- Q_D(QMessageBox);
- if (!d->detectedEscapeButton) {
- e->ignore();
- return;
- }
- QDialog::closeEvent(e);
- d->clickedButton = d->detectedEscapeButton;
- setResult(d->execReturnCode(d->detectedEscapeButton));
-}
-
-/*!
- \reimp
-*/
-void QMessageBox::changeEvent(QEvent *ev)
-{
- Q_D(QMessageBox);
- switch (ev->type()) {
- case QEvent::StyleChange:
- {
- if (d->icon != NoIcon)
- setIcon(d->icon);
- Qt::TextInteractionFlags flags(style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, 0, this));
- d->label->setTextInteractionFlags(flags);
- d->buttonBox->setCenterButtons(style()->styleHint(QStyle::SH_MessageBox_CenterButtons, 0, this));
- if (d->informativeLabel)
- d->informativeLabel->setTextInteractionFlags(flags);
- // intentional fall through
- }
- case QEvent::FontChange:
- case QEvent::ApplicationFontChange:
-#ifdef Q_WS_MAC
- {
- QFont f = font();
- f.setBold(true);
- d->label->setFont(f);
- }
-#endif
- default:
- break;
- }
- QDialog::changeEvent(ev);
-}
-
-/*!
- \reimp
-*/
-void QMessageBox::keyPressEvent(QKeyEvent *e)
-{
- Q_D(QMessageBox);
- if (e->key() == Qt::Key_Escape
-#ifdef Q_WS_MAC
- || (e->modifiers() == Qt::ControlModifier && e->key() == Qt::Key_Period)
-#endif
- ) {
- if (d->detectedEscapeButton) {
-#ifdef Q_WS_MAC
- d->detectedEscapeButton->animateClick();
-#else
- d->detectedEscapeButton->click();
-#endif
- }
- return;
- }
-
-#if defined (Q_OS_WIN) && !defined(QT_NO_CLIPBOARD) && !defined(QT_NO_SHORTCUT)
- if (e == QKeySequence::Copy) {
- QString separator = QString::fromLatin1("---------------------------\n");
- QString textToCopy = separator;
- separator.prepend(QLatin1Char('\n'));
- textToCopy += windowTitle() + separator; // title
- textToCopy += d->label->text() + separator; // text
-
- if (d->informativeLabel)
- textToCopy += d->informativeLabel->text() + separator;
-
- QString buttonTexts;
- QList<QAbstractButton *> buttons = d->buttonBox->buttons();
- for (int i = 0; i < buttons.count(); i++) {
- buttonTexts += buttons[i]->text() + QLatin1String(" ");
- }
- textToCopy += buttonTexts + separator;
-
- QApplication::clipboard()->setText(textToCopy);
- return;
- }
-#endif //QT_NO_SHORTCUT QT_NO_CLIPBOARD Q_OS_WIN
-
-#ifndef QT_NO_SHORTCUT
- if (!(e->modifiers() & Qt::AltModifier)) {
- int key = e->key() & ~((int)Qt::MODIFIER_MASK|(int)Qt::UNICODE_ACCEL);
- if (key) {
- const QList<QAbstractButton *> buttons = d->buttonBox->buttons();
- for (int i = 0; i < buttons.count(); ++i) {
- QAbstractButton *pb = buttons.at(i);
- int acc = pb->shortcut() & ~((int)Qt::MODIFIER_MASK|(int)Qt::UNICODE_ACCEL);
- if (acc == key) {
- pb->animateClick();
- return;
- }
- }
- }
- }
-#endif
- QDialog::keyPressEvent(e);
-}
-
-#ifdef Q_WS_WINCE
-/*!
- \reimp
-*/
-void QMessageBox::setVisible(bool visible)
-{
- Q_D(QMessageBox);
- if (visible)
- d->hideSpecial();
- QDialog::setVisible(visible);
-}
-#endif
-
-
-/*!
- \overload
-
- Opens the dialog and connects its finished() or buttonClicked() signal to
- the slot specified by \a receiver and \a member. If the slot in \a member
- has a pointer for its first parameter the connection is to buttonClicked(),
- otherwise the connection is to finished().
-
- The signal will be disconnected from the slot when the dialog is closed.
-*/
-void QMessageBox::open(QObject *receiver, const char *member)
-{
- Q_D(QMessageBox);
- const char *signal = member && strchr(member, '*') ? SIGNAL(buttonClicked(QAbstractButton*))
- : SIGNAL(finished(int));
- connect(this, signal, receiver, member);
- d->signalToDisconnectOnClose = signal;
- d->receiverToDisconnectOnClose = receiver;
- d->memberToDisconnectOnClose = member;
- QDialog::open();
-}
-
-/*!
- \since 4.5
-
- Returns a list of all the buttons that have been added to the message box.
-
- \sa buttonRole(), addButton(), removeButton()
-*/
-QList<QAbstractButton *> QMessageBox::buttons() const
-{
- Q_D(const QMessageBox);
- return d->buttonBox->buttons();
-}
-
-/*!
- \since 4.5
-
- Returns the button role for the specified \a button. This function returns
- \l InvalidRole if \a button is 0 or has not been added to the message box.
-
- \sa buttons(), addButton()
-*/
-QMessageBox::ButtonRole QMessageBox::buttonRole(QAbstractButton *button) const
-{
- Q_D(const QMessageBox);
- return QMessageBox::ButtonRole(d->buttonBox->buttonRole(button));
-}
-
-/*!
- \reimp
-*/
-void QMessageBox::showEvent(QShowEvent *e)
-{
- Q_D(QMessageBox);
- if (d->autoAddOkButton) {
- addButton(Ok);
-#if defined(Q_WS_WINCE)
- d->hideSpecial();
-#endif
- }
- if (d->detailsButton)
- addButton(d->detailsButton, QMessageBox::ActionRole);
- d->detectEscapeButton();
- d->updateSize();
-
-#ifndef QT_NO_ACCESSIBILITY
- QAccessible::updateAccessibility(this, 0, QAccessible::Alert);
-#endif
-#ifdef Q_WS_WIN
- HMENU systemMenu = GetSystemMenu((HWND)winId(), FALSE);
- if (!d->detectedEscapeButton) {
- EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_GRAYED);
- }
- else {
- EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_ENABLED);
- }
-#endif
- QDialog::showEvent(e);
-}
-
-
-static QMessageBox::StandardButton showNewMessageBox(QWidget *parent,
- QMessageBox::Icon icon,
- const QString& title, const QString& text,
- QMessageBox::StandardButtons buttons,
- QMessageBox::StandardButton defaultButton)
-{
- // necessary for source compatibility with Qt 4.0 and 4.1
- // handles (Yes, No) and (Yes|Default, No)
- if (defaultButton && !(buttons & defaultButton))
- return (QMessageBox::StandardButton)
- QMessageBoxPrivate::showOldMessageBox(parent, icon, title,
- text, int(buttons),
- int(defaultButton), 0);
-
- QMessageBox msgBox(icon, title, text, QMessageBox::NoButton, parent);
- QDialogButtonBox *buttonBox = msgBox.findChild<QDialogButtonBox*>();
- Q_ASSERT(buttonBox != 0);
-
- uint mask = QMessageBox::FirstButton;
- while (mask <= QMessageBox::LastButton) {
- uint sb = buttons & mask;
- mask <<= 1;
- if (!sb)
- continue;
- QPushButton *button = msgBox.addButton((QMessageBox::StandardButton)sb);
- // Choose the first accept role as the default
- if (msgBox.defaultButton())
- continue;
- if ((defaultButton == QMessageBox::NoButton && buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole)
- || (defaultButton != QMessageBox::NoButton && sb == uint(defaultButton)))
- msgBox.setDefaultButton(button);
- }
- if (msgBox.exec() == -1)
- return QMessageBox::Cancel;
- return msgBox.standardButton(msgBox.clickedButton());
-}
-
-/*!
- \since 4.2
-
- Opens an information message box with the given \a title and
- \a text in front of the specified \a parent widget.
-
- The standard \a buttons are added to the message box.
- \a defaultButton specifies the button used when \key Enter is pressed.
- \a defaultButton must refer to a button that was given in \a buttons.
- If \a defaultButton is QMessageBox::NoButton, QMessageBox
- chooses a suitable default automatically.
-
- Returns the identity of the standard button that was clicked. If
- \key Esc was pressed instead, the \l{Default and Escape Keys}
- {escape button} is returned.
-
- The message box is an \l{Qt::ApplicationModal}{application modal}
- dialog box.
-
- \warning Do not delete \a parent during the execution of the dialog.
- If you want to do this, you should create the dialog
- yourself using one of the QMessageBox constructors.
-
- \sa question(), warning(), critical()
-*/
-QMessageBox::StandardButton QMessageBox::information(QWidget *parent, const QString &title,
- const QString& text, StandardButtons buttons,
- StandardButton defaultButton)
-{
- return showNewMessageBox(parent, Information, title, text, buttons,
- defaultButton);
-}
-
-
-/*!
- \since 4.2
-
- Opens a question message box with the given \a title and \a
- text in front of the specified \a parent widget.
-
- The standard \a buttons are added to the message box. \a
- defaultButton specifies the button used when \key Enter is
- pressed. \a defaultButton must refer to a button that was given in \a buttons.
- If \a defaultButton is QMessageBox::NoButton, QMessageBox
- chooses a suitable default automatically.
-
- Returns the identity of the standard button that was clicked. If
- \key Esc was pressed instead, the \l{Default and Escape Keys}
- {escape button} is returned.
-
- The message box is an \l{Qt::ApplicationModal} {application modal}
- dialog box.
-
- \warning Do not delete \a parent during the execution of the dialog.
- If you want to do this, you should create the dialog
- yourself using one of the QMessageBox constructors.
-
- \sa information(), warning(), critical()
-*/
-QMessageBox::StandardButton QMessageBox::question(QWidget *parent, const QString &title,
- const QString& text, StandardButtons buttons,
- StandardButton defaultButton)
-{
- return showNewMessageBox(parent, Question, title, text, buttons, defaultButton);
-}
-
-/*!
- \since 4.2
-
- Opens a warning message box with the given \a title and \a
- text in front of the specified \a parent widget.
-
- The standard \a buttons are added to the message box. \a
- defaultButton specifies the button used when \key Enter is
- pressed. \a defaultButton must refer to a button that was given in \a buttons.
- If \a defaultButton is QMessageBox::NoButton, QMessageBox
- chooses a suitable default automatically.
-
- Returns the identity of the standard button that was clicked. If
- \key Esc was pressed instead, the \l{Default and Escape Keys}
- {escape button} is returned.
-
- The message box is an \l{Qt::ApplicationModal} {application modal}
- dialog box.
-
- \warning Do not delete \a parent during the execution of the dialog.
- If you want to do this, you should create the dialog
- yourself using one of the QMessageBox constructors.
-
- \sa question(), information(), critical()
-*/
-QMessageBox::StandardButton QMessageBox::warning(QWidget *parent, const QString &title,
- const QString& text, StandardButtons buttons,
- StandardButton defaultButton)
-{
- return showNewMessageBox(parent, Warning, title, text, buttons, defaultButton);
-}
-
-/*!
- \since 4.2
-
- Opens a critical message box with the given \a title and \a
- text in front of the specified \a parent widget.
-
- The standard \a buttons are added to the message box. \a
- defaultButton specifies the button used when \key Enter is
- pressed. \a defaultButton must refer to a button that was given in \a buttons.
- If \a defaultButton is QMessageBox::NoButton, QMessageBox
- chooses a suitable default automatically.
-
- Returns the identity of the standard button that was clicked. If
- \key Esc was pressed instead, the \l{Default and Escape Keys}
- {escape button} is returned.
-
- The message box is an \l{Qt::ApplicationModal} {application modal}
- dialog box.
-
- \warning Do not delete \a parent during the execution of the dialog.
- If you want to do this, you should create the dialog
- yourself using one of the QMessageBox constructors.
-
- \sa question(), warning(), information()
-*/
-QMessageBox::StandardButton QMessageBox::critical(QWidget *parent, const QString &title,
- const QString& text, StandardButtons buttons,
- StandardButton defaultButton)
-{
- return showNewMessageBox(parent, Critical, title, text, buttons, defaultButton);
-}
-
-/*!
- Displays a simple about box with title \a title and text \a
- text. The about box's parent is \a parent.
-
- about() looks for a suitable icon in four locations:
-
- \list 1
- \o It prefers \link QWidget::windowIcon() parent->icon() \endlink
- if that exists.
- \o If not, it tries the top-level widget containing \a parent.
- \o If that fails, it tries the \link
- QApplication::activeWindow() active window. \endlink
- \o As a last resort it uses the Information icon.
- \endlist
-
- The about box has a single button labelled "OK". On Mac OS X, the
- about box is popped up as a modeless window; on other platforms,
- it is currently application modal.
-
- \sa QWidget::windowIcon(), QApplication::activeWindow()
-*/
-void QMessageBox::about(QWidget *parent, const QString &title, const QString &text)
-{
-#ifdef Q_WS_MAC
- static QPointer<QMessageBox> oldMsgBox;
-
- if (oldMsgBox && oldMsgBox->text() == text) {
- oldMsgBox->show();
- oldMsgBox->raise();
- oldMsgBox->activateWindow();
- return;
- }
-#endif
-
- QMessageBox *msgBox = new QMessageBox(title, text, Information, 0, 0, 0, parent
-#ifdef Q_WS_MAC
- , Qt::WindowTitleHint | Qt::WindowSystemMenuHint
-#endif
- );
- msgBox->setAttribute(Qt::WA_DeleteOnClose);
- QIcon icon = msgBox->windowIcon();
- QSize size = icon.actualSize(QSize(64, 64));
- msgBox->setIconPixmap(icon.pixmap(size));
-
- // should perhaps be a style hint
-#ifdef Q_WS_MAC
- oldMsgBox = msgBox;
-#if 0
- // ### doesn't work until close button is enabled in title bar
- msgBox->d_func()->autoAddOkButton = false;
-#else
- msgBox->d_func()->buttonBox->setCenterButtons(true);
-#endif
- msgBox->show();
-#else
- msgBox->exec();
-#endif
-}
-
-/*!
- Displays a simple message box about Qt, with the given \a title
- and centered over \a parent (if \a parent is not 0). The message
- includes the version number of Qt being used by the application.
-
- This is useful for inclusion in the \gui Help menu of an application,
- as shown in the \l{mainwindows/menus}{Menus} example.
-
- QApplication provides this functionality as a slot.
-
- On Mac OS X, the about box is popped up as a modeless window; on
- other platforms, it is currently application modal.
-
- \sa QApplication::aboutQt()
-*/
-void QMessageBox::aboutQt(QWidget *parent, const QString &title)
-{
-#ifdef Q_WS_MAC
- static QPointer<QMessageBox> oldMsgBox;
-
- if (oldMsgBox) {
- oldMsgBox->show();
- oldMsgBox->raise();
- oldMsgBox->activateWindow();
- return;
- }
-#endif
-
- QString translatedTextAboutQtCaption;
- translatedTextAboutQtCaption = QMessageBox::tr(
- "<h3>About Qt</h3>"
- "<p>This program uses Qt version %1.</p>"
- ).arg(QLatin1String(QT_VERSION_STR));
- QString translatedTextAboutQtText;
- translatedTextAboutQtText = QMessageBox::tr(
- "<p>Qt is a C++ toolkit for cross-platform application "
- "development.</p>"
- "<p>Qt provides single-source portability across MS&nbsp;Windows, "
- "Mac&nbsp;OS&nbsp;X, Linux, and all major commercial Unix variants. "
- "Qt is also available for embedded devices as Qt for Embedded Linux "
- "and Qt for Windows CE.</p>"
- "<p>Qt is available under three different licensing options designed "
- "to accommodate the needs of our various users.</p>"
- "<p>Qt licensed under our commercial license agreement is appropriate "
- "for development of proprietary/commercial software where you do not "
- "want to share any source code with third parties or otherwise cannot "
- "comply with the terms of the GNU LGPL version 2.1 or GNU GPL version "
- "3.0.</p>"
- "<p>Qt licensed under the GNU LGPL version 2.1 is appropriate for the "
- "development of Qt applications (proprietary or open source) provided "
- "you can comply with the terms and conditions of the GNU LGPL version "
- "2.1.</p>"
- "<p>Qt licensed under the GNU General Public License version 3.0 is "
- "appropriate for the development of Qt applications where you wish to "
- "use such applications in combination with software subject to the "
- "terms of the GNU GPL version 3.0 or where you are otherwise willing "
- "to comply with the terms of the GNU GPL version 3.0.</p>"
- "<p>Please see <a href=\"http://qt.nokia.com/products/licensing\">qt.nokia.com/products/licensing</a> "
- "for an overview of Qt licensing.</p>"
- "<p>Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).</p>"
- "<p>Qt is a Nokia product. See <a href=\"http://qt.nokia.com/\">qt.nokia.com</a> "
- "for more information.</p>"
- );
- QMessageBox *msgBox = new QMessageBox(parent);
- msgBox->setAttribute(Qt::WA_DeleteOnClose);
- msgBox->setWindowTitle(title.isEmpty() ? tr("About Qt") : title);
- msgBox->setText(translatedTextAboutQtCaption);
- msgBox->setInformativeText(translatedTextAboutQtText);
-
- QPixmap pm(QLatin1String(":/trolltech/qmessagebox/images/qtlogo-64.png"));
- if (!pm.isNull())
- msgBox->setIconPixmap(pm);
-#if defined(Q_WS_WINCE)
- msgBox->setDefaultButton(msgBox->addButton(QMessageBox::Ok));
-#endif
-
- // should perhaps be a style hint
-#ifdef Q_WS_MAC
- oldMsgBox = msgBox;
-#if 0
- // ### doesn't work until close button is enabled in title bar
- msgBox->d_func()->autoAddOkButton = false;
-#else
- msgBox->d_func()->buttonBox->setCenterButtons(true);
-#endif
- msgBox->show();
-#else
- msgBox->exec();
-#endif
-}
-
-/*!
- \internal
-*/
-QSize QMessageBox::sizeHint() const
-{
- // ### Qt 5: remove
- return QDialog::sizeHint();
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Source and binary compatibility routines for 4.0 and 4.1
-
-static QMessageBox::StandardButton newButton(int button)
-{
- // this is needed for source compatibility with Qt 4.0 and 4.1
- if (button == QMessageBox::NoButton || (button & NewButtonMask))
- return QMessageBox::StandardButton(button & QMessageBox::ButtonMask);
-
-#if QT_VERSION < 0x050000
- // this is needed for binary compatibility with Qt 4.0 and 4.1
- switch (button & Old_ButtonMask) {
- case Old_Ok:
- return QMessageBox::Ok;
- case Old_Cancel:
- return QMessageBox::Cancel;
- case Old_Yes:
- return QMessageBox::Yes;
- case Old_No:
- return QMessageBox::No;
- case Old_Abort:
- return QMessageBox::Abort;
- case Old_Retry:
- return QMessageBox::Retry;
- case Old_Ignore:
- return QMessageBox::Ignore;
- case Old_YesAll:
- return QMessageBox::YesToAll;
- case Old_NoAll:
- return QMessageBox::NoToAll;
- default:
- return QMessageBox::NoButton;
- }
-#endif
-}
-
-static bool detectedCompat(int button0, int button1, int button2)
-{
- if (button0 != 0 && !(button0 & NewButtonMask))
- return true;
- if (button1 != 0 && !(button1 & NewButtonMask))
- return true;
- if (button2 != 0 && !(button2 & NewButtonMask))
- return true;
- return false;
-}
-
-QAbstractButton *QMessageBoxPrivate::findButton(int button0, int button1, int button2, int flags)
-{
- Q_Q(QMessageBox);
- int button = 0;
-
- if (button0 & flags) {
- button = button0;
- } else if (button1 & flags) {
- button = button1;
- } else if (button2 & flags) {
- button = button2;
- }
- return q->button(newButton(button));
-}
-
-void QMessageBoxPrivate::addOldButtons(int button0, int button1, int button2)
-{
- Q_Q(QMessageBox);
- q->addButton(newButton(button0));
- q->addButton(newButton(button1));
- q->addButton(newButton(button2));
- q->setDefaultButton(
- static_cast<QPushButton *>(findButton(button0, button1, button2, QMessageBox::Default)));
- q->setEscapeButton(findButton(button0, button1, button2, QMessageBox::Escape));
- compatMode = detectedCompat(button0, button1, button2);
-}
-
-QAbstractButton *QMessageBoxPrivate::abstractButtonForId(int id) const
-{
- Q_Q(const QMessageBox);
- QAbstractButton *result = customButtonList.value(id);
- if (result)
- return result;
- if (id & QMessageBox::FlagMask) // for compatibility with Qt 4.0/4.1 (even if it is silly)
- return 0;
- return q->button(newButton(id));
-}
-
-int QMessageBoxPrivate::showOldMessageBox(QWidget *parent, QMessageBox::Icon icon,
- const QString &title, const QString &text,
- int button0, int button1, int button2)
-{
- QMessageBox messageBox(icon, title, text, QMessageBox::NoButton, parent);
- messageBox.d_func()->addOldButtons(button0, button1, button2);
- return messageBox.exec();
-}
-
-int QMessageBoxPrivate::showOldMessageBox(QWidget *parent, QMessageBox::Icon icon,
- const QString &title, const QString &text,
- const QString &button0Text,
- const QString &button1Text,
- const QString &button2Text,
- int defaultButtonNumber,
- int escapeButtonNumber)
-{
- QMessageBox messageBox(icon, title, text, QMessageBox::NoButton, parent);
- QString myButton0Text = button0Text;
- if (myButton0Text.isEmpty())
- myButton0Text = QDialogButtonBox::tr("OK");
- messageBox.addButton(myButton0Text, QMessageBox::ActionRole);
- if (!button1Text.isEmpty())
- messageBox.addButton(button1Text, QMessageBox::ActionRole);
- if (!button2Text.isEmpty())
- messageBox.addButton(button2Text, QMessageBox::ActionRole);
-
- const QList<QAbstractButton *> &buttonList = messageBox.d_func()->customButtonList;
- messageBox.setDefaultButton(static_cast<QPushButton *>(buttonList.value(defaultButtonNumber)));
- messageBox.setEscapeButton(buttonList.value(escapeButtonNumber));
-
- return messageBox.exec();
-}
-
-void QMessageBoxPrivate::retranslateStrings()
-{
-#ifndef QT_NO_TEXTEDIT
- if (detailsButton)
- detailsButton->setLabel(detailsText->isHidden() ? ShowLabel : HideLabel);
-#endif
-}
-
-/*!
- \obsolete
-
- Constructs a message box with a \a title, a \a text, an \a icon,
- and up to three buttons.
-
- The \a icon must be one of the following:
- \list
- \o QMessageBox::NoIcon
- \o QMessageBox::Question
- \o QMessageBox::Information
- \o QMessageBox::Warning
- \o QMessageBox::Critical
- \endlist
-
- Each button, \a button0, \a button1 and \a button2, can have one
- of the following values:
- \list
- \o QMessageBox::NoButton
- \o QMessageBox::Ok
- \o QMessageBox::Cancel
- \o QMessageBox::Yes
- \o QMessageBox::No
- \o QMessageBox::Abort
- \o QMessageBox::Retry
- \o QMessageBox::Ignore
- \o QMessageBox::YesAll
- \o QMessageBox::NoAll
- \endlist
-
- Use QMessageBox::NoButton for the later parameters to have fewer
- than three buttons in your message box. If you don't specify any
- buttons at all, QMessageBox will provide an Ok button.
-
- One of the buttons can be OR-ed with the QMessageBox::Default
- flag to make it the default button (clicked when Enter is
- pressed).
-
- One of the buttons can be OR-ed with the QMessageBox::Escape flag
- to make it the cancel or close button (clicked when \key Esc is
- pressed).
-
- \snippet doc/src/snippets/dialogs/dialogs.cpp 2
-
- The message box is an \l{Qt::ApplicationModal} {application modal}
- dialog box.
-
- The \a parent and \a f arguments are passed to
- the QDialog constructor.
-
- \sa setWindowTitle(), setText(), setIcon()
-*/
-QMessageBox::QMessageBox(const QString &title, const QString &text, Icon icon,
- int button0, int button1, int button2, QWidget *parent,
- Qt::WindowFlags f)
- : QDialog(*new QMessageBoxPrivate, parent,
- f /*| Qt::MSWindowsFixedSizeDialogHint #### */| Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint)
-{
- Q_D(QMessageBox);
- d->init(title, text);
- setIcon(icon);
- d->addOldButtons(button0, button1, button2);
-}
-
-/*!
- \obsolete
-
- Opens an information message box with the given \a title and the
- \a text. The dialog may have up to three buttons. Each of the
- buttons, \a button0, \a button1 and \a button2 may be set to one
- of the following values:
-
- \list
- \o QMessageBox::NoButton
- \o QMessageBox::Ok
- \o QMessageBox::Cancel
- \o QMessageBox::Yes
- \o QMessageBox::No
- \o QMessageBox::Abort
- \o QMessageBox::Retry
- \o QMessageBox::Ignore
- \o QMessageBox::YesAll
- \o QMessageBox::NoAll
- \endlist
-
- If you don't want all three buttons, set the last button, or last
- two buttons to QMessageBox::NoButton.
-
- One button can be OR-ed with QMessageBox::Default, and one
- button can be OR-ed with QMessageBox::Escape.
-
- Returns the identity (QMessageBox::Ok, or QMessageBox::No, etc.)
- of the button that was clicked.
-
- The message box is an \l{Qt::ApplicationModal} {application modal}
- dialog box.
-
- \warning Do not delete \a parent during the execution of the dialog.
- If you want to do this, you should create the dialog
- yourself using one of the QMessageBox constructors.
-
- \sa question(), warning(), critical()
-*/
-int QMessageBox::information(QWidget *parent, const QString &title, const QString& text,
- int button0, int button1, int button2)
-{
- return QMessageBoxPrivate::showOldMessageBox(parent, Information, title, text,
- button0, button1, button2);
-}
-
-/*!
- \obsolete
- \overload
-
- Displays an information message box with the given \a title and
- \a text, as well as one, two or three buttons. Returns the index
- of the button that was clicked (0, 1 or 2).
-
- \a button0Text is the text of the first button, and is optional.
- If \a button0Text is not supplied, "OK" (translated) will be
- used. \a button1Text is the text of the second button, and is
- optional. \a button2Text is the text of the third button, and is
- optional. \a defaultButtonNumber (0, 1 or 2) is the index of the
- default button; pressing Return or Enter is the same as clicking
- the default button. It defaults to 0 (the first button). \a
- escapeButtonNumber is the index of the escape button; pressing
- \key Esc is the same as clicking this button. It defaults to -1;
- supply 0, 1 or 2 to make pressing \key Esc equivalent to clicking
- the relevant button.
-
- The message box is an \l{Qt::ApplicationModal} {application modal}
- dialog box.
-
- \warning Do not delete \a parent during the execution of the dialog.
- If you want to do this, you should create the dialog
- yourself using one of the QMessageBox constructors.
-
- \sa question(), warning(), critical()
-*/
-
-int QMessageBox::information(QWidget *parent, const QString &title, const QString& text,
- const QString& button0Text, const QString& button1Text,
- const QString& button2Text, int defaultButtonNumber,
- int escapeButtonNumber)
-{
- return QMessageBoxPrivate::showOldMessageBox(parent, Information, title, text,
- button0Text, button1Text, button2Text,
- defaultButtonNumber, escapeButtonNumber);
-}
-
-/*!
- \obsolete
-
- Opens a question message box with the given \a title and \a text.
- The dialog may have up to three buttons. Each of the buttons, \a
- button0, \a button1 and \a button2 may be set to one of the
- following values:
-
- \list
- \o QMessageBox::NoButton
- \o QMessageBox::Ok
- \o QMessageBox::Cancel
- \o QMessageBox::Yes
- \o QMessageBox::No
- \o QMessageBox::Abort
- \o QMessageBox::Retry
- \o QMessageBox::Ignore
- \o QMessageBox::YesAll
- \o QMessageBox::NoAll
- \endlist
-
- If you don't want all three buttons, set the last button, or last
- two buttons to QMessageBox::NoButton.
-
- One button can be OR-ed with QMessageBox::Default, and one
- button can be OR-ed with QMessageBox::Escape.
-
- Returns the identity (QMessageBox::Yes, or QMessageBox::No, etc.)
- of the button that was clicked.
-
- The message box is an \l{Qt::ApplicationModal} {application modal}
- dialog box.
-
- \warning Do not delete \a parent during the execution of the dialog.
- If you want to do this, you should create the dialog
- yourself using one of the QMessageBox constructors.
-
- \sa information(), warning(), critical()
-*/
-int QMessageBox::question(QWidget *parent, const QString &title, const QString& text,
- int button0, int button1, int button2)
-{
- return QMessageBoxPrivate::showOldMessageBox(parent, Question, title, text,
- button0, button1, button2);
-}
-
-/*!
- \obsolete
- \overload
-
- Displays a question message box with the given \a title and \a
- text, as well as one, two or three buttons. Returns the index of
- the button that was clicked (0, 1 or 2).
-
- \a button0Text is the text of the first button, and is optional.
- If \a button0Text is not supplied, "OK" (translated) will be used.
- \a button1Text is the text of the second button, and is optional.
- \a button2Text is the text of the third button, and is optional.
- \a defaultButtonNumber (0, 1 or 2) is the index of the default
- button; pressing Return or Enter is the same as clicking the
- default button. It defaults to 0 (the first button). \a
- escapeButtonNumber is the index of the Escape button; pressing
- Escape is the same as clicking this button. It defaults to -1;
- supply 0, 1 or 2 to make pressing Escape equivalent to clicking
- the relevant button.
-
- The message box is an \l{Qt::ApplicationModal} {application modal}
- dialog box.
-
- \warning Do not delete \a parent during the execution of the dialog.
- If you want to do this, you should create the dialog
- yourself using one of the QMessageBox constructors.
-
- \sa information(), warning(), critical()
-*/
-int QMessageBox::question(QWidget *parent, const QString &title, const QString& text,
- const QString& button0Text, const QString& button1Text,
- const QString& button2Text, int defaultButtonNumber,
- int escapeButtonNumber)
-{
- return QMessageBoxPrivate::showOldMessageBox(parent, Question, title, text,
- button0Text, button1Text, button2Text,
- defaultButtonNumber, escapeButtonNumber);
-}
-
-
-/*!
- \obsolete
-
- Opens a warning message box with the given \a title and \a text.
- The dialog may have up to three buttons. Each of the button
- parameters, \a button0, \a button1 and \a button2 may be set to
- one of the following values:
-
- \list
- \o QMessageBox::NoButton
- \o QMessageBox::Ok
- \o QMessageBox::Cancel
- \o QMessageBox::Yes
- \o QMessageBox::No
- \o QMessageBox::Abort
- \o QMessageBox::Retry
- \o QMessageBox::Ignore
- \o QMessageBox::YesAll
- \o QMessageBox::NoAll
- \endlist
-
- If you don't want all three buttons, set the last button, or last
- two buttons to QMessageBox::NoButton.
-
- One button can be OR-ed with QMessageBox::Default, and one
- button can be OR-ed with QMessageBox::Escape.
-
- Returns the identity (QMessageBox::Ok or QMessageBox::No or ...)
- of the button that was clicked.
-
- The message box is an \l{Qt::ApplicationModal} {application modal}
- dialog box.
-
- \warning Do not delete \a parent during the execution of the dialog.
- If you want to do this, you should create the dialog
- yourself using one of the QMessageBox constructors.
-
- \sa information(), question(), critical()
-*/
-int QMessageBox::warning(QWidget *parent, const QString &title, const QString& text,
- int button0, int button1, int button2)
-{
- return QMessageBoxPrivate::showOldMessageBox(parent, Warning, title, text,
- button0, button1, button2);
-}
-
-/*!
- \obsolete
- \overload
-
- Displays a warning message box with the given \a title and \a
- text, as well as one, two, or three buttons. Returns the number
- of the button that was clicked (0, 1, or 2).
-
- \a button0Text is the text of the first button, and is optional.
- If \a button0Text is not supplied, "OK" (translated) will be used.
- \a button1Text is the text of the second button, and is optional,
- and \a button2Text is the text of the third button, and is
- optional. \a defaultButtonNumber (0, 1 or 2) is the index of the
- default button; pressing Return or Enter is the same as clicking
- the default button. It defaults to 0 (the first button). \a
- escapeButtonNumber is the index of the Escape button; pressing
- Escape is the same as clicking this button. It defaults to -1;
- supply 0, 1, or 2 to make pressing Escape equivalent to clicking
- the relevant button.
-
- The message box is an \l{Qt::ApplicationModal} {application modal}
- dialog box.
-
- \warning Do not delete \a parent during the execution of the dialog.
- If you want to do this, you should create the dialog
- yourself using one of the QMessageBox constructors.
-
- \sa information(), question(), critical()
-*/
-int QMessageBox::warning(QWidget *parent, const QString &title, const QString& text,
- const QString& button0Text, const QString& button1Text,
- const QString& button2Text, int defaultButtonNumber,
- int escapeButtonNumber)
-{
- return QMessageBoxPrivate::showOldMessageBox(parent, Warning, title, text,
- button0Text, button1Text, button2Text,
- defaultButtonNumber, escapeButtonNumber);
-}
-
-/*!
- \obsolete
-
- Opens a critical message box with the given \a title and \a text.
- The dialog may have up to three buttons. Each of the button
- parameters, \a button0, \a button1 and \a button2 may be set to
- one of the following values:
-
- \list
- \o QMessageBox::NoButton
- \o QMessageBox::Ok
- \o QMessageBox::Cancel
- \o QMessageBox::Yes
- \o QMessageBox::No
- \o QMessageBox::Abort
- \o QMessageBox::Retry
- \o QMessageBox::Ignore
- \o QMessageBox::YesAll
- \o QMessageBox::NoAll
- \endlist
-
- If you don't want all three buttons, set the last button, or last
- two buttons to QMessageBox::NoButton.
-
- One button can be OR-ed with QMessageBox::Default, and one
- button can be OR-ed with QMessageBox::Escape.
-
- Returns the identity (QMessageBox::Ok, or QMessageBox::No, etc.)
- of the button that was clicked.
-
- The message box is an \l{Qt::ApplicationModal} {application modal}
- dialog box.
-
- \warning Do not delete \a parent during the execution of the dialog.
- If you want to do this, you should create the dialog
- yourself using one of the QMessageBox constructors.
-
- \sa information(), question(), warning()
-*/
-
-int QMessageBox::critical(QWidget *parent, const QString &title, const QString& text,
- int button0, int button1, int button2)
-{
- return QMessageBoxPrivate::showOldMessageBox(parent, Critical, title, text,
- button0, button1, button2);
-}
-
-/*!
- \obsolete
- \overload
-
- Displays a critical error message box with the given \a title and
- \a text, as well as one, two, or three buttons. Returns the
- number of the button that was clicked (0, 1 or 2).
-
- \a button0Text is the text of the first button, and is optional.
- If \a button0Text is not supplied, "OK" (translated) will be used.
- \a button1Text is the text of the second button, and is optional,
- and \a button2Text is the text of the third button, and is
- optional. \a defaultButtonNumber (0, 1 or 2) is the index of the
- default button; pressing Return or Enter is the same as clicking
- the default button. It defaults to 0 (the first button). \a
- escapeButtonNumber is the index of the Escape button; pressing
- Escape is the same as clicking this button. It defaults to -1;
- supply 0, 1, or 2 to make pressing Escape equivalent to clicking
- the relevant button.
-
- The message box is an \l{Qt::ApplicationModal} {application modal}
- dialog box.
-
- \warning Do not delete \a parent during the execution of the dialog.
- If you want to do this, you should create the dialog
- yourself using one of the QMessageBox constructors.
-
- \sa information(), question(), warning()
-*/
-int QMessageBox::critical(QWidget *parent, const QString &title, const QString& text,
- const QString& button0Text, const QString& button1Text,
- const QString& button2Text, int defaultButtonNumber,
- int escapeButtonNumber)
-{
- return QMessageBoxPrivate::showOldMessageBox(parent, Critical, title, text,
- button0Text, button1Text, button2Text,
- defaultButtonNumber, escapeButtonNumber);
-}
-
-
-/*!
- \obsolete
-
- Returns the text of the message box button \a button, or
- an empty string if the message box does not contain the button.
-
- Use button() and QPushButton::text() instead.
-*/
-QString QMessageBox::buttonText(int button) const
-{
- Q_D(const QMessageBox);
-
- if (QAbstractButton *abstractButton = d->abstractButtonForId(button)) {
- return abstractButton->text();
- } else if (d->buttonBox->buttons().isEmpty() && (button == Ok || button == Old_Ok)) {
- // for compatibility with Qt 4.0/4.1
- return QDialogButtonBox::tr("OK");
- }
- return QString();
-}
-
-/*!
- \obsolete
-
- Sets the text of the message box button \a button to \a text.
- Setting the text of a button that is not in the message box is
- silently ignored.
-
- Use addButton() instead.
-*/
-void QMessageBox::setButtonText(int button, const QString &text)
-{
- Q_D(QMessageBox);
- if (QAbstractButton *abstractButton = d->abstractButtonForId(button)) {
- abstractButton->setText(text);
- } else if (d->buttonBox->buttons().isEmpty() && (button == Ok || button == Old_Ok)) {
- // for compatibility with Qt 4.0/4.1
- addButton(QMessageBox::Ok)->setText(text);
- }
-}
-
-#ifndef QT_NO_TEXTEDIT
-/*!
- \property QMessageBox::detailedText
- \brief the text to be displayed in the details area.
- \since 4.2
-
- The text will be interpreted as a plain text.
-
- By default, this property contains an empty string.
-
- \sa QMessageBox::text, QMessageBox::informativeText
-*/
-QString QMessageBox::detailedText() const
-{
- Q_D(const QMessageBox);
- return d->detailsText ? d->detailsText->text() : QString();
-}
-
-void QMessageBox::setDetailedText(const QString &text)
-{
- Q_D(QMessageBox);
- if (text.isEmpty()) {
- delete d->detailsText;
- d->detailsText = 0;
- removeButton(d->detailsButton);
- delete d->detailsButton;
- d->detailsButton = 0;
- return;
- }
-
- if (!d->detailsText) {
- d->detailsText = new QMessageBoxDetailsText(this);
- QGridLayout* grid = qobject_cast<QGridLayout*>(layout());
- if (grid)
- grid->addWidget(d->detailsText, grid->rowCount(), 0, 1, grid->columnCount());
- d->detailsText->hide();
- }
- if (!d->detailsButton)
- d->detailsButton = new DetailButton(this);
- d->detailsText->setText(text);
-}
-#endif // QT_NO_TEXTEDIT
-
-/*!
- \property QMessageBox::informativeText
-
- \brief the informative text that provides a fuller description for
- the message
-
- \since 4.2
-
- Infromative text can be used to expand upon the text() to give more
- information to the user. On the Mac, this text appears in small
- system font below the text(). On other platforms, it is simply
- appended to the existing text.
-
- By default, this property contains an empty string.
-
- \sa QMessageBox::text, QMessageBox::detailedText
-*/
-QString QMessageBox::informativeText() const
-{
- Q_D(const QMessageBox);
- return d->informativeLabel ? d->informativeLabel->text() : QString();
-}
-
-void QMessageBox::setInformativeText(const QString &text)
-{
- Q_D(QMessageBox);
- if (text.isEmpty()) {
- layout()->removeWidget(d->informativeLabel);
- delete d->informativeLabel;
- d->informativeLabel = 0;
-#ifndef Q_WS_MAC
- d->label->setContentsMargins(2, 0, 0, 0);
-#endif
- d->updateSize();
- return;
- }
-
- if (!d->informativeLabel) {
- QLabel *label = new QLabel;
- label->setObjectName(QLatin1String("qt_msgbox_informativelabel"));
- label->setTextInteractionFlags(Qt::TextInteractionFlags(style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, 0, this)));
- label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
- label->setOpenExternalLinks(true);
- label->setWordWrap(true);
-#ifndef Q_WS_MAC
- d->label->setContentsMargins(2, 0, 0, 0);
- label->setContentsMargins(2, 0, 0, 6);
- label->setIndent(9);
-#else
- label->setContentsMargins(16, 0, 0, 0);
- // apply a smaller font the information label on the mac
- label->setFont(qt_app_fonts_hash()->value("QTipLabel"));
-#endif
- label->setWordWrap(true);
- QGridLayout *grid = static_cast<QGridLayout *>(layout());
-#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5)
- label->hide();
- QTextBrowser *textBrowser = new QTextBrowser(this);
- textBrowser->setOpenExternalLinks(true);
- grid->addWidget(textBrowser, 1, 1, 1, 1);
- d->textBrowser = textBrowser;
-#else
- grid->addWidget(label, 1, 1, 1, 1);
-#endif
- d->informativeLabel = label;
- }
- d->informativeLabel->setText(text);
-
-#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5)
- //We need to put the informative label inside textBrowser to enable scrolling of long texts.
- d->textBrowser->setText(d->informativeLabel->text());
-#endif
-
- d->updateSize();
-}
-
-/*!
- \since 4.2
-
- This function shadows QWidget::setWindowTitle().
-
- Sets the title of the message box to \a title. On Mac OS X,
- the window title is ignored (as required by the Mac OS X
- Guidelines).
-*/
-void QMessageBox::setWindowTitle(const QString &title)
-{
- // Message boxes on the mac do not have a title
-#ifndef Q_WS_MAC
- QDialog::setWindowTitle(title);
-#else
- Q_UNUSED(title);
-#endif
-}
-
-
-/*!
- \since 4.2
-
- This function shadows QWidget::setWindowModality().
-
- Sets the modality of the message box to \a windowModality.
-
- On Mac OS X, if the modality is set to Qt::WindowModal and the message box
- has a parent, then the message box will be a Qt::Sheet, otherwise the
- message box will be a standard dialog.
-*/
-void QMessageBox::setWindowModality(Qt::WindowModality windowModality)
-{
- QDialog::setWindowModality(windowModality);
-
- if (parentWidget() && windowModality == Qt::WindowModal)
- setParent(parentWidget(), Qt::Sheet);
- else
- setParent(parentWidget(), Qt::Dialog);
- setDefaultButton(d_func()->defaultButton);
-}
-
-#ifdef QT3_SUPPORT
-/*!
- \compat
-
- Constructs a message box with the given \a parent, \a name, and
- window flags, \a f.
- The window title is specified by \a title, and the message box
- displays message text and an icon specified by \a text and \a icon.
-
- The buttons that the user can access to respond to the message are
- defined by \a button0, \a button1, and \a button2.
-*/
-QMessageBox::QMessageBox(const QString& title,
- const QString &text, Icon icon,
- int button0, int button1, int button2,
- QWidget *parent, const char *name,
- bool modal, Qt::WindowFlags f)
- : QDialog(*new QMessageBoxPrivate, parent,
- f | Qt::WStyle_Customize | Qt::WStyle_DialogBorder | Qt::WStyle_Title | Qt::WStyle_SysMenu | Qt::WindowCloseButtonHint)
-{
- Q_D(QMessageBox);
- setObjectName(QString::fromAscii(name));
- d->init(title, text);
- d->addOldButtons(button0, button1, button2);
- setModal(modal);
- setIcon(icon);
-}
-
-/*!
- \compat
- Constructs a message box with the given \a parent and \a name.
-*/
-QMessageBox::QMessageBox(QWidget *parent, const char *name)
- : QDialog(*new QMessageBoxPrivate, parent,
- Qt::WStyle_Customize | Qt::WStyle_DialogBorder | Qt::WStyle_Title | Qt::WStyle_SysMenu | Qt::WindowCloseButtonHint)
-{
- Q_D(QMessageBox);
- setObjectName(QString::fromAscii(name));
- d->init();
-}
-
-/*!
- Returns the pixmap used for a standard icon. This
- allows the pixmaps to be used in more complex message boxes.
- \a icon specifies the required icon, e.g. QMessageBox::Information,
- QMessageBox::Warning or QMessageBox::Critical.
-
- \a style is unused.
-*/
-
-QPixmap QMessageBox::standardIcon(Icon icon, Qt::GUIStyle style)
-{
- Q_UNUSED(style);
- return QMessageBox::standardIcon(icon);
-}
-
-/*!
- \fn int QMessageBox::message(const QString &title, const QString &text,
- const QString &buttonText, QWidget *parent = 0,
- const char *name = 0)
-
- Opens a modal message box with the given \a title and showing the
- given \a text. The message box has a single button which has the
- given \a buttonText (or tr("OK")). The message box is centred over
- its \a parent and is called \a name.
-
- Use information(), warning(), question(), or critical() instead.
-
- \oldcode
- QMessageBox::message(tr("My App"), tr("All occurrences replaced."),
- tr("Close"), this);
- \newcode
- QMessageBox::information(this, tr("My App"),
- tr("All occurrences replaced."),
- QMessageBox::Close);
- \endcode
-*/
-
-/*!
- \fn bool QMessageBox::query(const QString &caption,
- const QString& text,
- const QString& yesButtonText,
- const QString& noButtonText,
- QWidget *parent, const char *name)
-
- \obsolete
-
- Queries the user using a modal message box with up to two buttons.
- The message box has the given \a caption (although some window
- managers don't show it), and shows the given \a text. The left
- button has the \a yesButtonText (or tr("OK")), and the right button
- has the \a noButtonText (or isn't shown). The message box is centred
- over its \a parent and is called \a name.
-
- Use information(), question(), warning(), or critical() instead.
-*/
-
-#endif
-
-QPixmap QMessageBoxPrivate::standardIcon(QMessageBox::Icon icon, QMessageBox *mb)
-{
- QStyle *style = mb ? mb->style() : QApplication::style();
- int iconSize = style->pixelMetric(QStyle::PM_MessageBoxIconSize, 0, mb);
- QIcon tmpIcon;
- switch (icon) {
- case QMessageBox::Information:
- tmpIcon = style->standardIcon(QStyle::SP_MessageBoxInformation, 0, mb);
- break;
- case QMessageBox::Warning:
- tmpIcon = style->standardIcon(QStyle::SP_MessageBoxWarning, 0, mb);
- break;
- case QMessageBox::Critical:
- tmpIcon = style->standardIcon(QStyle::SP_MessageBoxCritical, 0, mb);
- break;
- case QMessageBox::Question:
- tmpIcon = style->standardIcon(QStyle::SP_MessageBoxQuestion, 0, mb);
- default:
- break;
- }
- if (!tmpIcon.isNull())
- return tmpIcon.pixmap(iconSize, iconSize);
- return QPixmap();
-}
-
-/*!
- \obsolete
-
- Returns the pixmap used for a standard icon. This allows the
- pixmaps to be used in more complex message boxes. \a icon
- specifies the required icon, e.g. QMessageBox::Question,
- QMessageBox::Information, QMessageBox::Warning or
- QMessageBox::Critical.
-
- Call QStyle::standardIcon() with QStyle::SP_MessageBoxInformation etc.
- instead.
-*/
-
-QPixmap QMessageBox::standardIcon(Icon icon)
-{
- return QMessageBoxPrivate::standardIcon(icon, 0);
-}
-
-/*!
- \typedef QMessageBox::Button
- \obsolete
-
- Use QMessageBox::StandardButton instead.
-*/
-
-/*!
- \fn int QMessageBox::information(QWidget *parent, const QString &title,
- const QString& text, StandardButton button0,
- StandardButton button1)
- \fn int QMessageBox::warning(QWidget *parent, const QString &title,
- const QString& text, StandardButton button0,
- StandardButton button1)
- \fn int QMessageBox::critical(QWidget *parent, const QString &title,
- const QString& text, StandardButton button0,
- StandardButton button1)
- \fn int QMessageBox::question(QWidget *parent, const QString &title,
- const QString& text, StandardButton button0,
- StandardButton button1)
- \internal
-
- ### Needed for Qt 4 source compatibility
-*/
-
-/*!
- \fn int QMessageBox::exec()
-
- Shows the message box as a \l{QDialog#Modal Dialogs}{modal dialog},
- blocking until the user closes it.
-
- When using a QMessageBox with standard buttons, this functions returns a
- \l StandardButton value indicating the standard button that was clicked.
- When using QMessageBox with custom buttons, this function returns an
- opaque value; use clickedButton() to determine which button was clicked.
-
- Users cannot interact with any other window in the same
- application until they close the dialog, either by clicking a
- button or by using a mechanism provided by the window system.
-
- \sa show(), result()
-*/
-
-QT_END_NAMESPACE
-
-#include "moc_qmessagebox.cpp"
-
-#endif // QT_NO_MESSAGEBOX
diff --git a/src/gui/dialogs/qmessagebox.h b/src/gui/dialogs/qmessagebox.h
deleted file mode 100644
index 37ddb38e2d..0000000000
--- a/src/gui/dialogs/qmessagebox.h
+++ /dev/null
@@ -1,365 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMESSAGEBOX_H
-#define QMESSAGEBOX_H
-
-#include <QtGui/qdialog.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_MESSAGEBOX
-
-class QLabel;
-class QMessageBoxPrivate;
-class QAbstractButton;
-
-class Q_GUI_EXPORT QMessageBox : public QDialog
-{
- Q_OBJECT
- Q_ENUMS(Icon)
- Q_FLAGS(StandardButtons)
- Q_PROPERTY(QString text READ text WRITE setText)
- // ### Qt 5: Rename 'icon' 'standardIcon' and 'iconPixmap' 'icon' (and use QIcon?)
- Q_PROPERTY(Icon icon READ icon WRITE setIcon)
- Q_PROPERTY(QPixmap iconPixmap READ iconPixmap WRITE setIconPixmap)
- Q_PROPERTY(Qt::TextFormat textFormat READ textFormat WRITE setTextFormat)
- Q_PROPERTY(StandardButtons standardButtons READ standardButtons WRITE setStandardButtons)
-#ifndef QT_NO_TEXTEDIT
- Q_PROPERTY(QString detailedText READ detailedText WRITE setDetailedText)
-#endif
- Q_PROPERTY(QString informativeText READ informativeText WRITE setInformativeText)
-
-public:
- enum Icon {
- NoIcon = 0,
- Information = 1,
- Warning = 2,
- Critical = 3,
- Question = 4
- };
-
- enum ButtonRole {
- // keep this in sync with QDialogButtonBox::ButtonRole
- InvalidRole = -1,
- AcceptRole,
- RejectRole,
- DestructiveRole,
- ActionRole,
- HelpRole,
- YesRole,
- NoRole,
- ResetRole,
- ApplyRole,
-
- NRoles
- };
-
- enum StandardButton {
- // keep this in sync with QDialogButtonBox::StandardButton
- NoButton = 0x00000000,
- Ok = 0x00000400,
- Save = 0x00000800,
- SaveAll = 0x00001000,
- Open = 0x00002000,
- Yes = 0x00004000,
- YesToAll = 0x00008000,
- No = 0x00010000,
- NoToAll = 0x00020000,
- Abort = 0x00040000,
- Retry = 0x00080000,
- Ignore = 0x00100000,
- Close = 0x00200000,
- Cancel = 0x00400000,
- Discard = 0x00800000,
- Help = 0x01000000,
- Apply = 0x02000000,
- Reset = 0x04000000,
- RestoreDefaults = 0x08000000,
-
- FirstButton = Ok, // internal
- LastButton = RestoreDefaults, // internal
-
- YesAll = YesToAll, // obsolete
- NoAll = NoToAll, // obsolete
-
- Default = 0x00000100, // obsolete
- Escape = 0x00000200, // obsolete
- FlagMask = 0x00000300, // obsolete
- ButtonMask = ~FlagMask // obsolete
- };
- typedef StandardButton Button; // obsolete
-
- Q_DECLARE_FLAGS(StandardButtons, StandardButton)
-
- explicit QMessageBox(QWidget *parent = 0);
- QMessageBox(Icon icon, const QString &title, const QString &text,
- StandardButtons buttons = NoButton, QWidget *parent = 0,
- Qt::WindowFlags flags = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
- ~QMessageBox();
-
- void addButton(QAbstractButton *button, ButtonRole role);
- QPushButton *addButton(const QString &text, ButtonRole role);
- QPushButton *addButton(StandardButton button);
- void removeButton(QAbstractButton *button);
-
-#ifdef Q_WS_WINCE
- void setVisible(bool visible);
-#endif
-
-#ifdef Q_NO_USING_KEYWORD
-#ifndef Q_QDOC
- void open() { QDialog::open(); }
-#endif
-#else
- using QDialog::open;
-#endif
- void open(QObject *receiver, const char *member);
-
- QList<QAbstractButton *> buttons() const;
- ButtonRole buttonRole(QAbstractButton *button) const;
-
- void setStandardButtons(StandardButtons buttons);
- StandardButtons standardButtons() const;
- StandardButton standardButton(QAbstractButton *button) const;
- QAbstractButton *button(StandardButton which) const;
-
- QPushButton *defaultButton() const;
- void setDefaultButton(QPushButton *button);
- void setDefaultButton(StandardButton button);
-
- QAbstractButton *escapeButton() const;
- void setEscapeButton(QAbstractButton *button);
- void setEscapeButton(StandardButton button);
-
- QAbstractButton *clickedButton() const;
-
- QString text() const;
- void setText(const QString &text);
-
- Icon icon() const;
- void setIcon(Icon);
-
- QPixmap iconPixmap() const;
- void setIconPixmap(const QPixmap &pixmap);
-
- Qt::TextFormat textFormat() const;
- void setTextFormat(Qt::TextFormat format);
-
- static StandardButton information(QWidget *parent, const QString &title,
- const QString &text, StandardButtons buttons = Ok,
- StandardButton defaultButton = NoButton);
- // ### Qt 5: Replace Ok with Yes|No in question() function.
- // Also consider if Ok == Yes and Cancel == No.
- static StandardButton question(QWidget *parent, const QString &title,
- const QString &text, StandardButtons buttons = Ok,
- StandardButton defaultButton = NoButton);
- static StandardButton warning(QWidget *parent, const QString &title,
- const QString &text, StandardButtons buttons = Ok,
- StandardButton defaultButton = NoButton);
- static StandardButton critical(QWidget *parent, const QString &title,
- const QString &text, StandardButtons buttons = Ok,
- StandardButton defaultButton = NoButton);
- static void about(QWidget *parent, const QString &title, const QString &text);
- static void aboutQt(QWidget *parent, const QString &title = QString());
-
- QSize sizeHint() const;
-
- // the following functions are obsolete:
-
- QMessageBox(const QString &title, const QString &text, Icon icon,
- int button0, int button1, int button2,
- QWidget *parent = 0,
- Qt::WindowFlags f = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
-
- static int information(QWidget *parent, const QString &title,
- const QString& text,
- int button0, int button1 = 0, int button2 = 0);
- static int information(QWidget *parent, const QString &title,
- const QString& text,
- const QString& button0Text,
- const QString& button1Text = QString(),
- const QString& button2Text = QString(),
- int defaultButtonNumber = 0,
- int escapeButtonNumber = -1);
- inline static StandardButton information(QWidget *parent, const QString &title,
- const QString& text,
- StandardButton button0, StandardButton button1 = NoButton)
- { return information(parent, title, text, StandardButtons(button0), button1); }
-
- static int question(QWidget *parent, const QString &title,
- const QString& text,
- int button0, int button1 = 0, int button2 = 0);
- static int question(QWidget *parent, const QString &title,
- const QString& text,
- const QString& button0Text,
- const QString& button1Text = QString(),
- const QString& button2Text = QString(),
- int defaultButtonNumber = 0,
- int escapeButtonNumber = -1);
- inline static int question(QWidget *parent, const QString &title,
- const QString& text,
- StandardButton button0, StandardButton button1)
- { return question(parent, title, text, StandardButtons(button0), button1); }
-
- static int warning(QWidget *parent, const QString &title,
- const QString& text,
- int button0, int button1, int button2 = 0);
- static int warning(QWidget *parent, const QString &title,
- const QString& text,
- const QString& button0Text,
- const QString& button1Text = QString(),
- const QString& button2Text = QString(),
- int defaultButtonNumber = 0,
- int escapeButtonNumber = -1);
- inline static int warning(QWidget *parent, const QString &title,
- const QString& text,
- StandardButton button0, StandardButton button1)
- { return warning(parent, title, text, StandardButtons(button0), button1); }
-
- static int critical(QWidget *parent, const QString &title,
- const QString& text,
- int button0, int button1, int button2 = 0);
- static int critical(QWidget *parent, const QString &title,
- const QString& text,
- const QString& button0Text,
- const QString& button1Text = QString(),
- const QString& button2Text = QString(),
- int defaultButtonNumber = 0,
- int escapeButtonNumber = -1);
- inline static int critical(QWidget *parent, const QString &title,
- const QString& text,
- StandardButton button0, StandardButton button1)
- { return critical(parent, title, text, StandardButtons(button0), button1); }
-
- QString buttonText(int button) const;
- void setButtonText(int button, const QString &text);
-
- QString informativeText() const;
- void setInformativeText(const QString &text);
-
-#ifndef QT_NO_TEXTEDIT
- QString detailedText() const;
- void setDetailedText(const QString &text);
-#endif
-
- void setWindowTitle(const QString &title);
- void setWindowModality(Qt::WindowModality windowModality);
-
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QMessageBox(const QString &title, const QString &text, Icon icon,
- int button0, int button1, int button2,
- QWidget *parent, const char *name, bool modal,
- Qt::WindowFlags f = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
- QT3_SUPPORT_CONSTRUCTOR QMessageBox(QWidget *parent, const char *name);
-
- static QT3_SUPPORT QPixmap standardIcon(Icon icon, Qt::GUIStyle);
- static QT3_SUPPORT int message(const QString &title,
- const QString& text,
- const QString& buttonText=QString(),
- QWidget *parent = 0, const char * = 0) {
- return QMessageBox::information(parent, title, text,
- buttonText.isEmpty() ? tr("OK") : buttonText) == 0;
- }
- static QT3_SUPPORT bool query(const QString &title,
- const QString& text,
- const QString& yesButtonText = QString(),
- const QString& noButtonText = QString(),
- QWidget *parent = 0, const char * = 0) {
- return QMessageBox::information(parent, title, text,
- yesButtonText.isEmpty() ? tr("OK") : yesButtonText,
- noButtonText) == 0;
- }
-#endif
-
- static QPixmap standardIcon(Icon icon);
-
-Q_SIGNALS:
- void buttonClicked(QAbstractButton *button);
-
-#ifdef qdoc
-public Q_SLOTS:
- int exec();
-#endif
-
-protected:
- bool event(QEvent *e);
- void resizeEvent(QResizeEvent *event);
- void showEvent(QShowEvent *event);
- void closeEvent(QCloseEvent *event);
- void keyPressEvent(QKeyEvent *event);
- void changeEvent(QEvent *event);
-
-private:
- Q_PRIVATE_SLOT(d_func(), void _q_buttonClicked(QAbstractButton *))
-
- Q_DISABLE_COPY(QMessageBox)
- Q_DECLARE_PRIVATE(QMessageBox)
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QMessageBox::StandardButtons)
-
-#define QT_REQUIRE_VERSION(argc, argv, str) { QString s = QString::fromLatin1(str);\
-QString sq = QString::fromLatin1(qVersion()); \
-if ((sq.section(QChar::fromLatin1('.'),0,0).toInt()<<16)+\
-(sq.section(QChar::fromLatin1('.'),1,1).toInt()<<8)+\
-sq.section(QChar::fromLatin1('.'),2,2).toInt()<(s.section(QChar::fromLatin1('.'),0,0).toInt()<<16)+\
-(s.section(QChar::fromLatin1('.'),1,1).toInt()<<8)+\
-s.section(QChar::fromLatin1('.'),2,2).toInt()) { \
-if (!qApp){ \
- new QApplication(argc,argv); \
-} \
-QString s = QApplication::tr("Executable '%1' requires Qt "\
- "%2, found Qt %3.").arg(qAppName()).arg(QString::fromLatin1(\
-str)).arg(QString::fromLatin1(qVersion())); QMessageBox::critical(0, QApplication::tr(\
-"Incompatible Qt Library Error"), s, QMessageBox::Abort, 0); qFatal("%s", s.toLatin1().data()); }}
-
-#endif // QT_NO_MESSAGEBOX
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMESSAGEBOX_H
diff --git a/src/gui/dialogs/qpagesetupdialog.h b/src/gui/dialogs/qpagesetupdialog.h
deleted file mode 100644
index 184af251da..0000000000
--- a/src/gui/dialogs/qpagesetupdialog.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPAGESETUPDIALOG_H
-#define QPAGESETUPDIALOG_H
-
-#include <QtGui/qabstractpagesetupdialog.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_PRINTDIALOG
-
-class QPageSetupDialogPrivate;
-
-class Q_GUI_EXPORT QPageSetupDialog : public QAbstractPageSetupDialog
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QPageSetupDialog)
- Q_ENUMS(PageSetupDialogOption)
- Q_PROPERTY(PageSetupDialogOptions options READ options WRITE setOptions)
-
-public:
- enum PageSetupDialogOption {
- None = 0x00000000, // internal
- DontUseSheet = 0x00000001,
- OwnsPrinter = 0x80000000 // internal
- };
-
- Q_DECLARE_FLAGS(PageSetupDialogOptions, PageSetupDialogOption)
-
- explicit QPageSetupDialog(QPrinter *printer, QWidget *parent = 0);
- explicit QPageSetupDialog(QWidget *parent = 0);
-
- // obsolete
- void addEnabledOption(PageSetupDialogOption option);
- void setEnabledOptions(PageSetupDialogOptions options);
- PageSetupDialogOptions enabledOptions() const;
- bool isOptionEnabled(PageSetupDialogOption option) const;
-
- void setOption(PageSetupDialogOption option, bool on = true);
- bool testOption(PageSetupDialogOption option) const;
- void setOptions(PageSetupDialogOptions options);
- PageSetupDialogOptions options() const;
-
-#if defined(Q_WS_MAC) || defined(Q_OS_WIN)
- virtual void setVisible(bool visible);
-#endif
- virtual int exec();
-
-#ifdef Q_NO_USING_KEYWORD
-#ifndef Q_QDOC
- void open() { QDialog::open(); }
-#endif
-#else
- using QDialog::open;
-#endif
- void open(QObject *receiver, const char *member);
-
-#ifdef qdoc
- QPrinter *printer();
-#endif
-};
-
-#endif // QT_NO_PRINTDIALOG
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QPAGESETUPDIALOG_H
diff --git a/src/gui/dialogs/qprintdialog.h b/src/gui/dialogs/qprintdialog.h
deleted file mode 100644
index 05431608c4..0000000000
--- a/src/gui/dialogs/qprintdialog.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPRINTDIALOG_H
-#define QPRINTDIALOG_H
-
-#include <QtGui/qabstractprintdialog.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_PRINTDIALOG
-
-class QPrintDialogPrivate;
-class QPushButton;
-class QPrinter;
-
-#if defined (Q_OS_UNIX) && !defined(QTOPIA_PRINTDIALOG) && !defined(Q_WS_MAC) && !defined(Q_OS_SYMBIAN)
-class QUnixPrintWidgetPrivate;
-
-class Q_GUI_EXPORT QUnixPrintWidget : public QWidget
-{
- Q_OBJECT
-
-public:
- QUnixPrintWidget(QPrinter *printer, QWidget *parent = 0);
- ~QUnixPrintWidget();
- void updatePrinter();
-
-private:
- friend class QPrintDialogPrivate;
- friend class QUnixPrintWidgetPrivate;
- QUnixPrintWidgetPrivate *d;
- Q_PRIVATE_SLOT(d, void _q_printerChanged(int))
- Q_PRIVATE_SLOT(d, void _q_btnBrowseClicked())
- Q_PRIVATE_SLOT(d, void _q_btnPropertiesClicked())
-};
-#endif
-
-class Q_GUI_EXPORT QPrintDialog : public QAbstractPrintDialog
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QPrintDialog)
- Q_ENUMS(PrintDialogOption)
- Q_PROPERTY(PrintDialogOptions options READ options WRITE setOptions)
-
-public:
- explicit QPrintDialog(QPrinter *printer, QWidget *parent = 0);
- explicit QPrintDialog(QWidget *parent = 0);
- ~QPrintDialog();
-
- int exec();
-#if defined (Q_OS_UNIX) && !defined(QTOPIA_PRINTDIALOG) && !defined(Q_WS_MAC)
- virtual void accept();
-#endif
- void done(int result);
-
-#if defined (Q_OS_UNIX) && defined (QT3_SUPPORT)
- QT3_SUPPORT void setPrinter(QPrinter *, bool = false);
- QT3_SUPPORT QPrinter *printer() const;
- QT3_SUPPORT void addButton(QPushButton *button);
-#endif
-
- void setOption(PrintDialogOption option, bool on = true);
- bool testOption(PrintDialogOption option) const;
- void setOptions(PrintDialogOptions options);
- PrintDialogOptions options() const;
-
-#if defined(Q_OS_UNIX) || defined(Q_WS_MAC) || defined(Q_OS_WIN)
- void setVisible(bool visible);
-#endif
-
-#ifdef Q_NO_USING_KEYWORD
-#ifndef Q_QDOC
- void open() { QDialog::open(); }
-#endif
-#else
- using QDialog::open;
-#endif
- void open(QObject *receiver, const char *member);
-
-#ifdef qdoc
- QPrinter *printer();
-#endif
-
-#ifdef QTOPIA_PRINTDIALOG
-public:
- bool eventFilter(QObject *, QEvent *);
-#endif
-
-#ifdef Q_NO_USING_KEYWORD
-#ifndef Q_QDOC
- void accepted() { QDialog::accepted(); }
-#endif
-#else
- using QDialog::accepted;
-#endif
-
-Q_SIGNALS:
- void accepted(QPrinter *printer);
-
-private:
-#ifndef QTOPIA_PRINTDIALOG
- Q_PRIVATE_SLOT(d_func(), void _q_chbPrintLastFirstToggled(bool))
-#if defined (Q_OS_UNIX) && !defined (Q_OS_MAC)
- Q_PRIVATE_SLOT(d_func(), void _q_collapseOrExpandDialog())
-#endif
-# if defined(Q_OS_UNIX) && !defined (Q_OS_MAC) && !defined(QT_NO_MESSAGEBOX)
- Q_PRIVATE_SLOT(d_func(), void _q_checkFields())
-# endif
-#else // QTOPIA_PRINTDIALOG
- Q_PRIVATE_SLOT(d_func(), void _q_okClicked())
- Q_PRIVATE_SLOT(d_func(),void _q_printerOrFileSelected(QAbstractButton *b))
- Q_PRIVATE_SLOT(d_func(),void _q_paperSizeSelected(int))
- Q_PRIVATE_SLOT(d_func(), void _q_orientSelected(int))
- Q_PRIVATE_SLOT(d_func(), void _q_pageOrderSelected(int))
- Q_PRIVATE_SLOT(d_func(), void _q_colorModeSelected(QAbstractButton *))
- Q_PRIVATE_SLOT(d_func(), void _q_setNumCopies(int))
- Q_PRIVATE_SLOT(d_func(), void _q_printRangeSelected(int))
- Q_PRIVATE_SLOT(d_func(), void _q_setFirstPage(int))
- Q_PRIVATE_SLOT(d_func(), void _q_setLastPage(int))
- Q_PRIVATE_SLOT(d_func(), void _q_fileNameEditChanged(const QString &text))
-#endif // QTOPIA_PRINTDIALOG
- friend class QUnixPrintWidget;
-};
-
-#endif // QT_NO_PRINTDIALOG
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QPRINTDIALOG_H
diff --git a/src/gui/dialogs/qprintdialog_qws.cpp b/src/gui/dialogs/qprintdialog_qws.cpp
deleted file mode 100644
index 373b986f0b..0000000000
--- a/src/gui/dialogs/qprintdialog_qws.cpp
+++ /dev/null
@@ -1,567 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qplatformdefs.h"
-
-#include <private/qabstractprintdialog_p.h>
-#include "qprintdialog.h"
-
-#ifndef QT_NO_PRINTDIALOG
-
-#include "qapplication.h"
-#include "qbuttongroup.h"
-#include "qradiobutton.h"
-#include "qcombobox.h"
-#include "qspinbox.h"
-#include "qprinter.h"
-#include "qlineedit.h"
-#include "qdir.h"
-#include "qmessagebox.h"
-#include "qinputdialog.h"
-#include "qlayout.h"
-#include "qlabel.h"
-
-#include "qlibrary.h"
-
-#ifndef QT_NO_NIS
-
-#ifndef BOOL_DEFINED
-#define BOOL_DEFINED
-#endif
-
-#include <rpcsvc/ypclnt.h>
-#include <rpcsvc/yp_prot.h>
-
-#endif //QT_NO_NIS
-
-#include <ctype.h>
-#include <stdlib.h>
-
-#include <qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-typedef void (*QPrintDialogCreator)(QPrintDialog *parent);
-Q_GUI_EXPORT QPrintDialogCreator _qt_print_dialog_creator;
-
-class QPrintDialogPrivate : public QAbstractPrintDialogPrivate
-{
- Q_DECLARE_PUBLIC(QPrintDialog)
-public:
- QButtonGroup *printerOrFile;
- bool outputToFile;
- QRadioButton *printToPrinterButton;
- QRadioButton *printToFileButton;
- QLineEdit *fileName;
-
- QButtonGroup *colorMode;
- QRadioButton *printColor;
- QRadioButton *printGray;
- QPrinter::ColorMode colorMode2;
-
- QComboBox *orientationCombo, *sizeCombo;
- QPrinter::PaperSize pageSize;
- QPrinter::Orientation orientation;
-
- QSpinBox *copies;
- int numCopies;
- QPrinter::PaperSize indexToPaperSize[QPrinter::NPaperSize];
-
- QComboBox *rangeCombo;
- QSpinBox *firstPage;
- QSpinBox *lastPage;
-
- QComboBox *pageOrderCombo;
- QPrinter::PageOrder pageOrder2;
-
- QString faxNum;
-
- void init();
-
- void _q_okClicked();
- void _q_printerOrFileSelected(QAbstractButton *b);
- void _q_paperSizeSelected(int);
- void _q_orientSelected(int);
- void _q_pageOrderSelected(int);
- void _q_colorModeSelected(QAbstractButton *);
- void _q_setNumCopies(int);
- void _q_printRangeSelected(int);
- void _q_setFirstPage(int);
- void _q_setLastPage(int);
- void _q_fileNameEditChanged(const QString &text);
-
- void setupDestination();
- void setupPrinterSettings();
- void setupPaper();
- void setupOptions();
-
- void setPrinter(QPrinter *p, bool pickUpSettings);
-};
-
-static void isc(QPrintDialogPrivate *d, const QString & text,
- QPrinter::PaperSize ps);
-
-void QPrintDialogPrivate::_q_okClicked()
-{
- Q_Q(QPrintDialog);
-#ifndef QT_NO_MESSAGEBOX
- if (outputToFile && fileName->isModified() && QFileInfo(fileName->text()).exists()) {
- int confirm = QMessageBox::warning(
- q, QPrintDialog::tr("File exists"),
- QPrintDialog::tr("<qt>Do you want to overwrite it?</qt>"),
- QMessageBox::Yes, QMessageBox::No);
- if (confirm == QMessageBox::No)
- return;
- }
-#endif // QT_NO_MESSAGEBOX
-
- lastPage->interpretText();
- firstPage->interpretText();
- copies->interpretText();
- if (outputToFile) {
- printer->setOutputFileName(fileName->text());
- }
- printer->setOrientation(orientation);
- printer->setPaperSize(pageSize);
- printer->setPageOrder(pageOrder2);
- printer->setColorMode(colorMode2);
- printer->setCopyCount(numCopies);
-
- switch ((rangeCombo->itemData(rangeCombo->currentIndex())).toInt()){
- case (int)QPrintDialog::AllPages:
- q->setPrintRange(QPrintDialog::AllPages);
- q->setFromTo(0, 0);
- break;
- case (int)QPrintDialog::Selection:
- q->setPrintRange(QPrintDialog::Selection);
- q->setFromTo(0, 0);
- break;
- case (int)QPrintDialog::PageRange:
- q->setPrintRange(QPrintDialog::PageRange);
- q->setFromTo(firstPage->value(), lastPage->value());
- break;
- case (int)QPrintDialog::CurrentPage:
- q->setPrintRange(QPrintDialog::CurrentPage);
- q->setFromTo(0, 0);
- break;
- }
- q->accept();
-}
-
-void QPrintDialogPrivate::_q_printerOrFileSelected(QAbstractButton *b)
-{
- outputToFile = (b == printToFileButton);
- if (outputToFile) {
- _q_fileNameEditChanged(fileName->text());
- if (!fileName->isModified() && fileName->text().isEmpty()) {
- QString file = "print.tiff";
- fileName->setText(file);
- fileName->setCursorPosition(file.length());
- fileName->selectAll();
- fileName->setModified(true); // confirm overwrite when OK clicked
-
- }
- fileName->setEnabled(true);
- fileName->setFocus();
- } else {
- fileName->setText(QString());
- if (fileName->isEnabled())
- fileName->setEnabled(false);
- }
-}
-
-void QPrintDialogPrivate::_q_paperSizeSelected(int id)
-{
- if (id < QPrinter::NPaperSize)
- pageSize = QPrinter::PaperSize(indexToPaperSize[id]);
-}
-
-void QPrintDialogPrivate::_q_orientSelected(int id)
-{
- orientation = (QPrinter::Orientation)id;
-}
-
-void QPrintDialogPrivate::_q_pageOrderSelected(int id)
-{
- pageOrder2 = (QPrinter::PageOrder)id;
-}
-
-void QPrintDialogPrivate::_q_colorModeSelected(QAbstractButton *b)
-{
- colorMode2 = (b == printColor) ? QPrinter::Color : QPrinter::GrayScale;
-}
-
-void QPrintDialogPrivate::_q_setNumCopies(int copies)
-{
- numCopies = copies;
-}
-
-void QPrintDialogPrivate::_q_printRangeSelected(int id)
-{
- bool enable = (rangeCombo->itemData(id).toInt() == (int)QPrintDialog::PageRange);
- firstPage->setEnabled(enable);
- lastPage->setEnabled(enable);
-}
-
-void QPrintDialogPrivate::_q_setFirstPage(int fp)
-{
- Q_Q(QPrintDialog);
- if (printer) {
- lastPage->setMinimum(fp);
- lastPage->setMaximum(qMax(fp, q->maxPage()));
- }
-}
-
-void QPrintDialogPrivate::_q_setLastPage(int lp)
-{
- Q_Q(QPrintDialog);
- if (printer) {
- firstPage->setMinimum(qMin(lp, q->minPage()));
- firstPage->setMaximum(lp);
- }
-}
-
-void QPrintDialogPrivate::_q_fileNameEditChanged(const QString &text)
-{
- Q_UNUSED(text);
-}
-
-void QPrintDialogPrivate::setupDestination()
-{
- Q_Q(QPrintDialog);
-
- // print destinations
- printerOrFile = new QButtonGroup(q);
- QObject::connect(printerOrFile, SIGNAL(buttonClicked(QAbstractButton*)),
- q, SLOT(_q_printerOrFileSelected(QAbstractButton*)));
-
- printToPrinterButton = q->findChild<QRadioButton *>("printToPrinterButton");
- printerOrFile->addButton(printToPrinterButton);
- printToFileButton = q->findChild<QRadioButton *>("printToFileButton");
- printerOrFile->addButton(printToFileButton);
-
- // file name
- fileName = q->findChild<QLineEdit *>("fileName");
- QObject::connect(fileName, SIGNAL(textChanged(QString)),
- q, SLOT(_q_fileNameEditChanged(QString)));
-
- outputToFile = false;
-}
-
-void QPrintDialogPrivate::setupPrinterSettings()
-{
- Q_Q(QPrintDialog);
-
- // color mode
- colorMode = new QButtonGroup(q);
- QObject::connect(colorMode, SIGNAL(buttonClicked(QAbstractButton*)),
- q, SLOT(_q_colorModeSelected(QAbstractButton*)));
-
- printColor = q->findChild<QRadioButton *>("printColor");
- colorMode->addButton(printColor);
- printGray = q->findChild<QRadioButton *>("printGray");
- colorMode->addButton(printGray);
-}
-
-void isc(QPrintDialogPrivate *ptr, const QString & text, QPrinter::PaperSize ps)
-{
- if (ptr && !text.isEmpty() && ps < QPrinter::NPaperSize) {
- ptr->sizeCombo->addItem(text);
- int index = ptr->sizeCombo->count()-1;
- if (index >= 0 && index < QPrinter::NPaperSize)
- ptr->indexToPaperSize[index] = ps;
- }
-}
-
-void QPrintDialogPrivate::setupPaper()
-{
- Q_Q(QPrintDialog);
-
- pageSize = QPrinter::A4;
-
- // paper orientation
- orientationCombo = q->findChild<QComboBox *>("orientationCombo");
- orientation = QPrinter::Portrait;
- QObject::connect(orientationCombo, SIGNAL(activated(int)),
- q, SLOT(_q_orientSelected(int)));
-
- // paper size
- sizeCombo = q->findChild<QComboBox *>("sizeCombo");
-
- int n;
- for(n=0; n<QPrinter::NPaperSize; n++)
- indexToPaperSize[n] = QPrinter::A4;
-
- isc(this, QPrintDialog::tr("A0 (841 x 1189 mm)"), QPrinter::A0);
- isc(this, QPrintDialog::tr("A1 (594 x 841 mm)"), QPrinter::A1);
- isc(this, QPrintDialog::tr("A2 (420 x 594 mm)"), QPrinter::A2);
- isc(this, QPrintDialog::tr("A3 (297 x 420 mm)"), QPrinter::A3);
- isc(this, QPrintDialog::tr("A4 (210 x 297 mm, 8.26 x 11.7 inches)"), QPrinter::A4);
- isc(this, QPrintDialog::tr("A5 (148 x 210 mm)"), QPrinter::A5);
- isc(this, QPrintDialog::tr("A6 (105 x 148 mm)"), QPrinter::A6);
- isc(this, QPrintDialog::tr("A7 (74 x 105 mm)"), QPrinter::A7);
- isc(this, QPrintDialog::tr("A8 (52 x 74 mm)"), QPrinter::A8);
- isc(this, QPrintDialog::tr("A9 (37 x 52 mm)"), QPrinter::A9);
- isc(this, QPrintDialog::tr("B0 (1000 x 1414 mm)"), QPrinter::B0);
- isc(this, QPrintDialog::tr("B1 (707 x 1000 mm)"), QPrinter::B1);
- isc(this, QPrintDialog::tr("B2 (500 x 707 mm)"), QPrinter::B2);
- isc(this, QPrintDialog::tr("B3 (353 x 500 mm)"), QPrinter::B3);
- isc(this, QPrintDialog::tr("B4 (250 x 353 mm)"), QPrinter::B4);
- isc(this, QPrintDialog::tr("B5 (176 x 250 mm, 6.93 x 9.84 inches)"), QPrinter::B5);
- isc(this, QPrintDialog::tr("B6 (125 x 176 mm)"), QPrinter::B6);
- isc(this, QPrintDialog::tr("B7 (88 x 125 mm)"), QPrinter::B7);
- isc(this, QPrintDialog::tr("B8 (62 x 88 mm)"), QPrinter::B8);
- isc(this, QPrintDialog::tr("B9 (44 x 62 mm)"), QPrinter::B9);
- isc(this, QPrintDialog::tr("B10 (31 x 44 mm)"), QPrinter::B10);
- isc(this, QPrintDialog::tr("C5E (163 x 229 mm)"), QPrinter::C5E);
- isc(this, QPrintDialog::tr("DLE (110 x 220 mm)"), QPrinter::DLE);
- isc(this, QPrintDialog::tr("Executive (7.5 x 10 inches, 191 x 254 mm)"), QPrinter::Executive);
- isc(this, QPrintDialog::tr("Folio (210 x 330 mm)"), QPrinter::Folio);
- isc(this, QPrintDialog::tr("Ledger (432 x 279 mm)"), QPrinter::Ledger);
- isc(this, QPrintDialog::tr("Legal (8.5 x 14 inches, 216 x 356 mm)"), QPrinter::Legal);
- isc(this, QPrintDialog::tr("Letter (8.5 x 11 inches, 216 x 279 mm)"), QPrinter::Letter);
- isc(this, QPrintDialog::tr("Tabloid (279 x 432 mm)"), QPrinter::Tabloid);
- isc(this, QPrintDialog::tr("US Common #10 Envelope (105 x 241 mm)"), QPrinter::Comm10E);
-
- QObject::connect(sizeCombo, SIGNAL(activated(int)),
- q, SLOT(_q_paperSizeSelected(int)));
-}
-
-void QPrintDialogPrivate::setupOptions()
-{
- Q_Q(QPrintDialog);
-
- // no. of copies
- copies = q->findChild<QSpinBox *>("copies");
- QObject::connect(copies, SIGNAL(valueChanged(int)),
- q, SLOT(_q_setNumCopies(int)));
-
- // print range
- rangeCombo = q->findChild<QComboBox *>("rangeCombo");
- rangeCombo->addItem(QPrintDialog::tr("Print all"), QPrintDialog::AllPages);
- rangeCombo->addItem(QPrintDialog::tr("Print selection"), QPrintDialog::Selection);
- rangeCombo->addItem(QPrintDialog::tr("Print range"), QPrintDialog::PageRange);
- rangeCombo->addItem(QPrintDialog::tr("Print current page"), QPrintDialog::CurrentPage);
- QObject::connect(rangeCombo, SIGNAL(activated(int)),
- q, SLOT(_q_printRangeSelected(int)));
-
- // page range
- firstPage = q->findChild<QSpinBox *>("firstPage");
- firstPage->setRange(1, 9999);
- firstPage->setValue(1);
- QObject::connect(firstPage, SIGNAL(valueChanged(int)),
- q, SLOT(_q_setFirstPage(int)));
-
- lastPage = q->findChild<QSpinBox *>("lastPage");
- lastPage->setRange(1, 9999);
- lastPage->setValue(1);
- QObject::connect(lastPage, SIGNAL(valueChanged(int)),
- q, SLOT(_q_setLastPage(int)));
-
- // print order
- pageOrderCombo = q->findChild<QComboBox *>("pageOrderCombo");
- QObject::connect(pageOrderCombo, SIGNAL(activated(int)),
- q, SLOT(_q_pageOrderSelected(int)));
-}
-
-bool QPrintDialog::eventFilter(QObject *o, QEvent *e)
-{
- Q_UNUSED(o);
-
- Q_D(QPrintDialog);
- switch (e->type()){
- case QEvent::KeyPress:
- switch (static_cast<QKeyEvent*>(e)->key()) {
- case Qt::Key_Back:
- d->_q_okClicked();
- return true;
- }
- break;
- default:
- break;
- }
- return false;
-}
-
-QPrintDialog::QPrintDialog(QPrinter *printer, QWidget *parent)
- : QAbstractPrintDialog(*(new QPrintDialogPrivate), printer, parent)
-{
- d_func()->init();
-}
-
-QPrintDialog::QPrintDialog(QWidget *parent)
- : QAbstractPrintDialog(*(new QPrintDialogPrivate), 0, parent)
-{
- d_func()->init();
-}
-
-QPrintDialog::~QPrintDialog()
-{
-}
-
-void QPrintDialogPrivate::setPrinter(QPrinter *p, bool pickUpSettings)
-{
- Q_Q(QPrintDialog);
- printer = p;
-
- if (p && pickUpSettings) {
- // top to bottom in the old dialog.
- // printer or file
- outputToFile = !p->outputFileName().isEmpty() && q->isOptionEnabled(QPrintDialog::PrintToFile);
- if (outputToFile)
- printToFileButton->setChecked(true);
- else
- printToPrinterButton->setChecked(true);
- fileName->setEnabled(outputToFile);
-
- // file name
- if (q->isOptionEnabled(QPrintDialog::PrintToFile)) {
- fileName->setText(p->outputFileName());
- fileName->setModified(!fileName->text().isEmpty());
- } else {
- printToFileButton->setEnabled(false);
- }
-
- // orientation
- orientationCombo->setCurrentIndex((int)p->orientation());
- _q_orientSelected(p->orientation());
-
- // page size
- int n = 0;
- while (n < QPrinter::NPaperSize &&
- indexToPaperSize[n] != p->pageSize())
- n++;
- sizeCombo->setCurrentIndex(n);
- _q_paperSizeSelected(n);
-
- // page order
- pageOrder2 = p->pageOrder();
- pageOrderCombo->setCurrentIndex((int)pageOrder2);
-
- // color mode
- colorMode2 = p->colorMode();
- if (colorMode2 == QPrinter::Color)
- printColor->setChecked(true);
- else
- printGray->setChecked(true);
-
- // number of copies
- copies->setValue(p->copyCount());
- _q_setNumCopies(p->copyCount());
- }
-
- if (p) {
- if (!q->isOptionEnabled(QPrintDialog::PrintSelection)
- && rangeCombo->findData(QPrintDialog::Selection) > 0)
- rangeCombo->removeItem(rangeCombo->findData(QPrintDialog::Selection));
- if (!q->isOptionEnabled(QPrintDialog::PrintPageRange)
- && rangeCombo->findData(QPrintDialog::PageRange) > 0)
- rangeCombo->removeItem(rangeCombo->findData(QPrintDialog::PageRange));
- if (!q->isOptionEnabled(QPrintDialog::PrintCurrentPage)
- && rangeCombo->findData(QPrintDialog::CurrentPage) > 0)
- rangeCombo->removeItem(rangeCombo->findData(QPrintDialog::CurrentPage));
-
- switch (q->printRange()) {
- case QPrintDialog::AllPages:
- rangeCombo->setCurrentIndex((int)(QPrintDialog::AllPages));
- break;
- case QPrintDialog::Selection:
- rangeCombo->setCurrentIndex((int)(QPrintDialog::Selection));
- break;
- case QPrintDialog::PageRange:
- rangeCombo->setCurrentIndex((int)(QPrintDialog::PageRange));
- break;
- case QPrintDialog::CurrentPage:
- rangeCombo->setCurrentIndex((int)(QPrintDialog::CurrentPage));
- break;
- }
- }
-
- if (p && q->maxPage()) {
- int from = q->minPage();
- int to = q->maxPage();
- if (q->printRange() == QPrintDialog::PageRange) {
- from = q->fromPage();
- to = q->toPage();
- }
- firstPage->setRange(q->minPage(), to);
- lastPage->setRange(from, q->maxPage());
- firstPage->setValue(from);
- lastPage->setValue(to);
- }
-}
-
-int QPrintDialog::exec()
-{
- Q_D(QPrintDialog);
- d->setPrinter(d->printer, true);
- return QDialog::exec();
-}
-
-void QPrintDialogPrivate::init()
-{
- Q_Q(QPrintDialog);
- numCopies = 1;
-
- if (_qt_print_dialog_creator)
- (*_qt_print_dialog_creator)(q);
-
- setupDestination();
- setupPrinterSettings();
- setupPaper();
- setupOptions();
-
- setPrinter(printer, true);
-
- q->installEventFilter(q);
-}
-
-void QPrintDialog::setVisible(bool visible)
-{
- QAbstractPrintDialog::setVisible(visible);
-}
-
-QT_END_NAMESPACE
-
-#include "moc_qprintdialog.cpp"
-#include "qrc_qprintdialog.cpp"
-
-#endif // QT_NO_PRINTDIALOG
diff --git a/src/gui/dialogs/qprintdialog_unix.cpp b/src/gui/dialogs/qprintdialog_unix.cpp
deleted file mode 100644
index 5b5c49d158..0000000000
--- a/src/gui/dialogs/qprintdialog_unix.cpp
+++ /dev/null
@@ -1,1309 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qplatformdefs.h"
-
-#ifndef QT_NO_PRINTDIALOG
-
-#include "private/qabstractprintdialog_p.h"
-#include <QtGui/qmessagebox.h>
-#include "qprintdialog.h"
-#include "qfiledialog.h"
-#include <QtCore/qdir.h>
-#include <QtGui/qevent.h>
-#include <QtGui/qfilesystemmodel.h>
-#include <QtGui/qstyleditemdelegate.h>
-#include <QtGui/qprinter.h>
-
-#include <QtGui/qdialogbuttonbox.h>
-
-#include "qfscompleter_p.h"
-#include "ui_qprintpropertieswidget.h"
-#include "ui_qprintsettingsoutput.h"
-#include "ui_qprintwidget.h"
-
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
-# include <private/qcups_p.h>
-# include <cups/cups.h>
-# include <private/qpdf_p.h>
-#else
-# include <QtCore/qlibrary.h>
-#endif
-
-#include <private/qprinterinfo_unix_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QOptionTreeItem;
-class QPPDOptionsModel;
-
-class QPrintPropertiesDialog : public QDialog
-{
- Q_OBJECT
-public:
- QPrintPropertiesDialog(QAbstractPrintDialog *parent = 0);
- ~QPrintPropertiesDialog();
-
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- void setCups(QCUPSSupport *cups) { m_cups = cups; }
- void addItemToOptions(QOptionTreeItem *parent, QList<const ppd_option_t*>& options, QList<const char*>& markedOptions) const;
-#endif
-
- void selectPrinter();
- void selectPdfPsPrinter(const QPrinter *p);
-
- /// copy printer properties to the widget
- void applyPrinterProperties(QPrinter *p);
- void setupPrinter() const;
-
-protected:
- void showEvent(QShowEvent* event);
-
-private:
- Ui::QPrintPropertiesWidget widget;
- QDialogButtonBox *m_buttons;
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- QCUPSSupport *m_cups;
- QPPDOptionsModel *m_cupsOptionsModel;
-#endif
-};
-
-class QPrintDialogPrivate : public QAbstractPrintDialogPrivate
-{
- Q_DECLARE_PUBLIC(QPrintDialog)
- Q_DECLARE_TR_FUNCTIONS(QPrintDialog)
-public:
- QPrintDialogPrivate();
- ~QPrintDialogPrivate();
-
- void init();
- /// copy printer properties to the widget
- void applyPrinterProperties(QPrinter *p);
-
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- void selectPrinter(QCUPSSupport *cups);
-#endif
-
- void _q_chbPrintLastFirstToggled(bool);
-#ifndef QT_NO_MESSAGEBOX
- void _q_checkFields();
-#endif
- void _q_collapseOrExpandDialog();
-
- void setupPrinter();
- void updateWidgets();
-
- virtual void setTabs(const QList<QWidget*> &tabs);
-
- Ui::QPrintSettingsOutput options;
- QUnixPrintWidget *top;
- QWidget *bottom;
- QDialogButtonBox *buttons;
- QPushButton *collapseButton;
-};
-
-#if defined (Q_OS_UNIX)
-class QUnixPrintWidgetPrivate
-{
-public:
- QUnixPrintWidgetPrivate(QUnixPrintWidget *q);
- ~QUnixPrintWidgetPrivate();
-
- /// copy printer properties to the widget
- void applyPrinterProperties(QPrinter *p);
- bool checkFields();
- void setupPrinter();
- void setOptionsPane(QPrintDialogPrivate *pane);
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- void setCupsProperties();
-#endif
-
-// slots
- void _q_printerChanged(int index);
- void _q_btnPropertiesClicked();
- void _q_btnBrowseClicked();
-
- QUnixPrintWidget * const parent;
- QPrintPropertiesDialog *propertiesDialog;
- Ui::QPrintWidget widget;
- QAbstractPrintDialog * q;
- QPrinter *printer;
- QList<QPrinterDescription> lprPrinters;
- void updateWidget();
-
-private:
- QPrintDialogPrivate *optionsPane;
- bool filePrintersAdded;
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- QCUPSSupport* cups;
- int cupsPrinterCount;
- const cups_dest_t* cupsPrinters;
- const ppd_file_t* cupsPPD;
-#endif
-};
-#endif
-
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
-class QOptionTreeItem
-{
-public:
- enum ItemType { Root, Group, Option, Choice };
-
- QOptionTreeItem(ItemType t, int i, const void* p, const char* desc, QOptionTreeItem* pi)
- : type(t),
- index(i),
- ptr(p),
- description(desc),
- selected(-1),
- selDescription(0),
- parentItem(pi) {}
-
- ~QOptionTreeItem() {
- while (!childItems.isEmpty())
- delete childItems.takeFirst();
- }
-
- ItemType type;
- int index;
- const void* ptr;
- const char* description;
- int selected;
- const char* selDescription;
- QOptionTreeItem* parentItem;
- QList<QOptionTreeItem*> childItems;
-};
-
-class QPPDOptionsModel : public QAbstractItemModel
-{
- friend class QPPDOptionsEditor;
-public:
- QPPDOptionsModel(QCUPSSupport *cups, QObject *parent = 0);
- ~QPPDOptionsModel();
-
- int columnCount(const QModelIndex& parent = QModelIndex()) const;
- int rowCount(const QModelIndex& parent = QModelIndex()) const;
- QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
- QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const;
- QModelIndex parent(const QModelIndex& index) const;
- Qt::ItemFlags flags(const QModelIndex& index) const;
- QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
-
- QOptionTreeItem* rootItem;
- QCUPSSupport *cups;
- const ppd_file_t* ppd;
- void parseItems();
- void parseGroups(QOptionTreeItem* parent);
- void parseOptions(QOptionTreeItem* parent);
- void parseChoices(QOptionTreeItem* parent);
-};
-
-class QPPDOptionsEditor : public QStyledItemDelegate
-{
- Q_OBJECT
-public:
- QPPDOptionsEditor(QObject* parent = 0) : QStyledItemDelegate(parent) {}
- ~QPPDOptionsEditor() {}
-
- 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 cbChanged(int index);
-
-};
-
-#endif
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-QPrintPropertiesDialog::QPrintPropertiesDialog(QAbstractPrintDialog *parent)
- : QDialog(parent)
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- , m_cups(0), m_cupsOptionsModel(0)
-#endif
-{
- QVBoxLayout *lay = new QVBoxLayout(this);
- this->setLayout(lay);
- QWidget *content = new QWidget(this);
- widget.setupUi(content);
- m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
- lay->addWidget(content);
- lay->addWidget(m_buttons);
-
- connect(m_buttons->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(accept()));
- connect(m_buttons->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject()));
-}
-
-QPrintPropertiesDialog::~QPrintPropertiesDialog()
-{
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- delete m_cupsOptionsModel;
-#else
- delete widget.cupsPropertiesPage;
-#endif
-}
-
-void QPrintPropertiesDialog::applyPrinterProperties(QPrinter *p)
-{
- widget.pageSetup->setPrinter(p);
-}
-
-void QPrintPropertiesDialog::setupPrinter() const
-{
- widget.pageSetup->setupPrinter();
-
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- QPPDOptionsModel* model = static_cast<QPPDOptionsModel*>(widget.treeView->model());
- if (model) {
- QOptionTreeItem* rootItem = model->rootItem;
- QList<const ppd_option_t*> options;
- QList<const char*> markedOptions;
-
- addItemToOptions(rootItem, options, markedOptions);
- model->cups->saveOptions(options, markedOptions);
- }
-#endif
-}
-
-void QPrintPropertiesDialog::selectPrinter()
-{
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- widget.pageSetup->selectPrinter(m_cups);
- widget.treeView->setModel(0);
- if (m_cups && QCUPSSupport::isAvailable()) {
-
- if (m_cupsOptionsModel == 0) {
- m_cupsOptionsModel = new QPPDOptionsModel(m_cups);
-
- widget.treeView->setItemDelegate(new QPPDOptionsEditor(this));
- } else {
- // update the model
- m_cupsOptionsModel->parseItems();
- }
-
- if (m_cupsOptionsModel->rowCount() > 0) {
- widget.treeView->setModel(m_cupsOptionsModel);
-
- for (int i = 0; i < m_cupsOptionsModel->rowCount(); ++i)
- widget.treeView->expand(m_cupsOptionsModel->index(i,0));
-
- widget.tabs->setTabEnabled(1, true); // enable the advanced tab
- } else {
- widget.tabs->setTabEnabled(1, false);
- }
-
- } else
-#endif
- {
- widget.cupsPropertiesPage->setEnabled(false);
- widget.pageSetup->selectPrinter(0);
- }
-}
-
-void QPrintPropertiesDialog::selectPdfPsPrinter(const QPrinter *p)
-{
- widget.treeView->setModel(0);
- widget.pageSetup->selectPdfPsPrinter(p);
- widget.tabs->setTabEnabled(1, false); // disable the advanced tab
-}
-
-void QPrintPropertiesDialog::showEvent(QShowEvent* event)
-{
- widget.treeView->resizeColumnToContents(0);
- event->accept();
-}
-
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
-void QPrintPropertiesDialog::addItemToOptions(QOptionTreeItem *parent, QList<const ppd_option_t*>& options, QList<const char*>& markedOptions) const
-{
- for (int i = 0; i < parent->childItems.count(); ++i) {
- QOptionTreeItem *itm = parent->childItems.at(i);
- if (itm->type == QOptionTreeItem::Option) {
- const ppd_option_t* opt = reinterpret_cast<const ppd_option_t*>(itm->ptr);
- options << opt;
- if (qstrcmp(opt->defchoice, opt->choices[itm->selected].choice) != 0) {
- markedOptions << opt->keyword << opt->choices[itm->selected].choice;
- }
- } else {
- addItemToOptions(itm, options, markedOptions);
- }
- }
-}
-#endif
-
-QPrintDialogPrivate::QPrintDialogPrivate()
- : top(0), bottom(0), buttons(0), collapseButton(0)
-{
-}
-
-QPrintDialogPrivate::~QPrintDialogPrivate()
-{
-}
-
-void QPrintDialogPrivate::init()
-{
- Q_Q(QPrintDialog);
-
- top = new QUnixPrintWidget(0, q);
- bottom = new QWidget(q);
- options.setupUi(bottom);
- options.color->setIconSize(QSize(32, 32));
- options.color->setIcon(QIcon(QLatin1String(":/trolltech/dialogs/qprintdialog/images/status-color.png")));
- options.grayscale->setIconSize(QSize(32, 32));
- options.grayscale->setIcon(QIcon(QLatin1String(":/trolltech/dialogs/qprintdialog/images/status-gray-scale.png")));
- top->d->setOptionsPane(this);
-
- buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, q);
- collapseButton = new QPushButton(QPrintDialog::tr("&Options >>"), buttons);
- buttons->addButton(collapseButton, QDialogButtonBox::ResetRole);
- bottom->setVisible(false);
-
- QPushButton *printButton = buttons->button(QDialogButtonBox::Ok);
- printButton->setText(QPrintDialog::tr("&Print"));
- printButton->setDefault(true);
-
- QVBoxLayout *lay = new QVBoxLayout(q);
- q->setLayout(lay);
- lay->addWidget(top);
- lay->addWidget(bottom);
- lay->addWidget(buttons);
-
- QPrinter* p = q->printer();
-
- applyPrinterProperties(p);
-
-#ifdef QT_NO_MESSAGEBOX
- QObject::connect(buttons, SIGNAL(accepted()), q, SLOT(accept()));
-#else
- QObject::connect(buttons, SIGNAL(accepted()), q, SLOT(_q_checkFields()));
-#endif
- QObject::connect(buttons, SIGNAL(rejected()), q, SLOT(reject()));
-
- QObject::connect(options.reverse, SIGNAL(toggled(bool)),
- q, SLOT(_q_chbPrintLastFirstToggled(bool)));
-
- QObject::connect(collapseButton, SIGNAL(released()), q, SLOT(_q_collapseOrExpandDialog()));
-}
-
-void QPrintDialogPrivate::applyPrinterProperties(QPrinter *p)
-{
- if (p->colorMode() == QPrinter::Color)
- options.color->setChecked(true);
- else
- options.grayscale->setChecked(true);
-
- switch(p->duplex()) {
- case QPrinter::DuplexNone:
- options.noDuplex->setChecked(true); break;
- case QPrinter::DuplexLongSide:
- case QPrinter::DuplexAuto:
- options.duplexLong->setChecked(true); break;
- case QPrinter::DuplexShortSide:
- options.duplexShort->setChecked(true); break;
- }
- options.copies->setValue(p->copyCount());
- options.collate->setChecked(p->collateCopies());
- options.reverse->setChecked(p->pageOrder() == QPrinter::LastPageFirst);
- top->d->applyPrinterProperties(p);
-}
-
-void QPrintDialogPrivate::_q_chbPrintLastFirstToggled(bool checked)
-{
- Q_Q(QPrintDialog);
- if (checked)
- q->printer()->setPageOrder(QPrinter::LastPageFirst);
- else
- q->printer()->setPageOrder(QPrinter::FirstPageFirst);
-}
-
-void QPrintDialogPrivate::_q_collapseOrExpandDialog()
-{
- int collapseHeight = 0;
- Q_Q(QPrintDialog);
- QWidget *widgetToHide = bottom;
- if (widgetToHide->isVisible()) {
- collapseButton->setText(QPrintDialog::tr("&Options >>"));
- collapseHeight = widgetToHide->y() + widgetToHide->height() - (top->y() + top->height());
- }
- else
- collapseButton->setText(QPrintDialog::tr("&Options <<"));
- widgetToHide->setVisible(! widgetToHide->isVisible());
- if (! widgetToHide->isVisible()) { // make it shrink
- q->layout()->activate();
- q->resize( QSize(q->width(), q->height() - collapseHeight) );
- }
-}
-
-#ifndef QT_NO_MESSAGEBOX
-void QPrintDialogPrivate::_q_checkFields()
-{
- Q_Q(QPrintDialog);
- if (top->d->checkFields())
- q->accept();
-}
-#endif // QT_NO_MESSAGEBOX
-
-void QPrintDialogPrivate::setupPrinter()
-{
- Q_Q(QPrintDialog);
- QPrinter* p = q->printer();
-
- if (options.duplex->isEnabled()) {
- if (options.noDuplex->isChecked())
- p->setDuplex(QPrinter::DuplexNone);
- else if (options.duplexLong->isChecked())
- p->setDuplex(QPrinter::DuplexLongSide);
- else
- p->setDuplex(QPrinter::DuplexShortSide);
- }
-
- p->setColorMode( options.color->isChecked() ? QPrinter::Color : QPrinter::GrayScale );
-
- // print range
- if (options.printAll->isChecked()) {
- p->setPrintRange(QPrinter::AllPages);
- p->setFromTo(0,0);
- } else if (options.printSelection->isChecked()) {
- p->setPrintRange(QPrinter::Selection);
- p->setFromTo(0,0);
- } else if (options.printCurrentPage->isChecked()) {
- p->setPrintRange(QPrinter::CurrentPage);
- p->setFromTo(0,0);
- } else if (options.printRange->isChecked()) {
- p->setPrintRange(QPrinter::PageRange);
- p->setFromTo(options.from->value(), qMax(options.from->value(), options.to->value()));
- }
-
- // copies
- p->setCopyCount(options.copies->value());
- p->setCollateCopies(options.collate->isChecked());
-
- top->d->setupPrinter();
-}
-
-void QPrintDialogPrivate::updateWidgets()
-{
- Q_Q(QPrintDialog);
- options.gbPrintRange->setVisible(q->isOptionEnabled(QPrintDialog::PrintPageRange) ||
- q->isOptionEnabled(QPrintDialog::PrintSelection) ||
- q->isOptionEnabled(QPrintDialog::PrintCurrentPage));
-
- options.printRange->setEnabled(q->isOptionEnabled(QPrintDialog::PrintPageRange));
- options.printSelection->setVisible(q->isOptionEnabled(QPrintDialog::PrintSelection));
- options.printCurrentPage->setVisible(q->isOptionEnabled(QPrintDialog::PrintCurrentPage));
- options.collate->setVisible(q->isOptionEnabled(QPrintDialog::PrintCollateCopies));
-
- switch (q->printRange()) {
- case QPrintDialog::AllPages:
- options.printAll->setChecked(true);
- break;
- case QPrintDialog::Selection:
- options.printSelection->setChecked(true);
- break;
- case QPrintDialog::PageRange:
- options.printRange->setChecked(true);
- break;
- case QPrintDialog::CurrentPage:
- if (q->isOptionEnabled(QPrintDialog::PrintCurrentPage))
- options.printCurrentPage->setChecked(true);
- break;
- default:
- break;
- }
- const int minPage = qMax(1, qMin(q->minPage() , q->maxPage()));
- const int maxPage = qMax(1, q->maxPage() == INT_MAX ? 9999 : q->maxPage());
-
- options.from->setMinimum(minPage);
- options.to->setMinimum(minPage);
- options.from->setMaximum(maxPage);
- options.to->setMaximum(maxPage);
-
- options.from->setValue(q->fromPage());
- options.to->setValue(q->toPage());
- top->d->updateWidget();
-}
-
-void QPrintDialogPrivate::setTabs(const QList<QWidget*> &tabWidgets)
-{
- while(options.tabs->count() > 2)
- delete options.tabs->widget(2);
-
- QList<QWidget*>::ConstIterator iter = tabWidgets.begin();
- while(iter != tabWidgets.constEnd()) {
- QWidget *tab = *iter;
- options.tabs->addTab(tab, tab->windowTitle());
- ++iter;
- }
-}
-
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
-void QPrintDialogPrivate::selectPrinter(QCUPSSupport *cups)
-{
- options.duplex->setEnabled(cups && cups->ppdOption("Duplex"));
-}
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-
-QPrintDialog::QPrintDialog(QPrinter *printer, QWidget *parent)
- : QAbstractPrintDialog(*(new QPrintDialogPrivate), printer, parent)
-{
- Q_D(QPrintDialog);
- d->init();
-}
-
-/*!
- Constructs a print dialog with the given \a parent.
-*/
-QPrintDialog::QPrintDialog(QWidget *parent)
- : QAbstractPrintDialog(*(new QPrintDialogPrivate), 0, parent)
-{
- Q_D(QPrintDialog);
- d->init();
-}
-
-QPrintDialog::~QPrintDialog()
-{
-}
-
-void QPrintDialog::setVisible(bool visible)
-{
- Q_D(QPrintDialog);
-
- if (visible)
- d->updateWidgets();
-
- QAbstractPrintDialog::setVisible(visible);
-}
-
-int QPrintDialog::exec()
-{
- return QDialog::exec();
-}
-
-void QPrintDialog::accept()
-{
- Q_D(QPrintDialog);
- d->setupPrinter();
- QDialog::accept();
-}
-
-#ifdef QT3_SUPPORT
-QPrinter *QPrintDialog::printer() const
-{
- Q_D(const QPrintDialog);
- return d->printer;
-}
-
-void QPrintDialog::setPrinter(QPrinter *printer, bool pickupSettings)
-{
- if (!printer)
- return;
-
- Q_D(QPrintDialog);
- d->printer = printer;
-
- if (pickupSettings)
- d->applyPrinterProperties(printer);
-}
-
-void QPrintDialog::addButton(QPushButton *button)
-{
- Q_D(QPrintDialog);
- d->buttons->addButton(button, QDialogButtonBox::HelpRole);
-}
-#endif // QT3_SUPPORT
-
-#if defined (Q_OS_UNIX)
-
-/*! \internal
-*/
-QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p)
- : parent(p), propertiesDialog(0), printer(0), optionsPane(0), filePrintersAdded(false)
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- , cups(0), cupsPrinterCount(0), cupsPrinters(0), cupsPPD(0)
-#endif
-{
- q = 0;
- if (parent)
- q = qobject_cast<QAbstractPrintDialog*> (parent->parent());
-
- widget.setupUi(parent);
-
- int currentPrinterIndex = 0;
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- cups = new QCUPSSupport;
- if (QCUPSSupport::isAvailable()) {
- cupsPPD = cups->currentPPD();
- cupsPrinterCount = cups->availablePrintersCount();
- cupsPrinters = cups->availablePrinters();
-
- for (int i = 0; i < cupsPrinterCount; ++i) {
- QString printerName(QString::fromLocal8Bit(cupsPrinters[i].name));
- if (cupsPrinters[i].instance)
- printerName += QLatin1Char('/') + QString::fromLocal8Bit(cupsPrinters[i].instance);
-
- widget.printers->addItem(printerName);
- if (cupsPrinters[i].is_default)
- widget.printers->setCurrentIndex(i);
- }
- // the model depends on valid ppd. so before enabling the
- // properties button we make sure the ppd is in fact valid.
- if (cupsPrinterCount && cups->currentPPD()) {
- widget.properties->setEnabled(true);
- }
- currentPrinterIndex = cups->currentPrinterIndex();
- } else {
-#endif
- currentPrinterIndex = qt_getLprPrinters(lprPrinters);
- // populating printer combo
- QList<QPrinterDescription>::const_iterator i = lprPrinters.constBegin();
- for(; i != lprPrinters.constEnd(); ++i)
- widget.printers->addItem((*i).name);
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- }
-#endif
-
-#if !defined(QT_NO_FILESYSTEMMODEL) && !defined(QT_NO_COMPLETER)
- QFileSystemModel *fsm = new QFileSystemModel(widget.filename);
- fsm->setRootPath(QDir::homePath());
- widget.filename->setCompleter(new QCompleter(fsm, widget.filename));
-#endif
- _q_printerChanged(currentPrinterIndex);
-
- QObject::connect(widget.printers, SIGNAL(currentIndexChanged(int)),
- parent, SLOT(_q_printerChanged(int)));
- QObject::connect(widget.fileBrowser, SIGNAL(clicked()), parent, SLOT(_q_btnBrowseClicked()));
- QObject::connect(widget.properties, SIGNAL(clicked()), parent, SLOT(_q_btnPropertiesClicked()));
-
- // disable features that QPrinter does not yet support.
- widget.preview->setVisible(false);
-}
-
-void QUnixPrintWidgetPrivate::updateWidget()
-{
- const bool printToFile = q == 0 || q->isOptionEnabled(QPrintDialog::PrintToFile);
- if (printToFile && !filePrintersAdded) {
- if (widget.printers->count())
- widget.printers->insertSeparator(widget.printers->count());
- widget.printers->addItem(QPrintDialog::tr("Print to File (PDF)"));
- widget.printers->addItem(QPrintDialog::tr("Print to File (Postscript)"));
- filePrintersAdded = true;
- }
- if (!printToFile && filePrintersAdded) {
- widget.printers->removeItem(widget.printers->count()-1);
- widget.printers->removeItem(widget.printers->count()-1);
- if (widget.printers->count())
- widget.printers->removeItem(widget.printers->count()-1); // remove separator
- filePrintersAdded = false;
- }
- if (printer && filePrintersAdded && (printer->outputFormat() != QPrinter::NativeFormat
- || printer->printerName().isEmpty()))
- {
- if (printer->outputFormat() == QPrinter::PdfFormat)
- widget.printers->setCurrentIndex(widget.printers->count() - 2);
- else if (printer->outputFormat() == QPrinter::PostScriptFormat)
- widget.printers->setCurrentIndex(widget.printers->count() - 1);
- widget.filename->setEnabled(true);
- widget.lOutput->setEnabled(true);
- }
-
- widget.filename->setVisible(printToFile);
- widget.lOutput->setVisible(printToFile);
- widget.fileBrowser->setVisible(printToFile);
-
- widget.properties->setVisible(q->isOptionEnabled(QAbstractPrintDialog::PrintShowPageSize));
-}
-
-QUnixPrintWidgetPrivate::~QUnixPrintWidgetPrivate()
-{
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- delete cups;
-#endif
-}
-
-void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
-{
- if (index < 0)
- return;
- const int printerCount = widget.printers->count();
- widget.filename->setEnabled(false);
- widget.lOutput->setEnabled(false);
-
- if (filePrintersAdded) {
- Q_ASSERT(index != printerCount - 3); // separator
- if (index > printerCount - 3) { // PDF or postscript
- bool pdfPrinter = (index == printerCount - 2);
- widget.location->setText(QPrintDialog::tr("Local file"));
- widget.type->setText(QPrintDialog::tr("Write %1 file").arg(pdfPrinter ? QString::fromLatin1("PDF")
- : QString::fromLatin1("PostScript")));
- widget.properties->setEnabled(true);
- widget.filename->setEnabled(true);
- QString filename = widget.filename->text();
- QString suffix = QFileInfo(filename).suffix();
- if (pdfPrinter && suffix == QLatin1String("ps"))
- filename = filename.replace(QLatin1String(".ps"), QLatin1String(".pdf"));
- if (!pdfPrinter && suffix == QLatin1String("pdf"))
- filename = filename.replace(QLatin1String(".pdf"), QLatin1String(".ps"));
- widget.filename->setText(filename);
- widget.lOutput->setEnabled(true);
- if (propertiesDialog)
- propertiesDialog->selectPdfPsPrinter(printer);
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- if (optionsPane)
- optionsPane->selectPrinter(0);
-#endif
- return;
- }
- }
-
- widget.location->setText(QString());
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- if (QCUPSSupport::isAvailable()) {
- cups->setCurrentPrinter(index);
-
- const cups_option_t *opt = cups->printerOption(QString::fromLatin1("printer-location"));
- QString location;
- if (opt)
- location = QString::fromLocal8Bit(opt->value);
- widget.location->setText(location);
-
- cupsPPD = cups->currentPPD();
- // set printer type line
- QString type;
- if (cupsPPD)
- type = QString::fromLocal8Bit(cupsPPD->manufacturer) + QLatin1String(" - ") + QString::fromLocal8Bit(cupsPPD->modelname);
- widget.type->setText(type);
- if (propertiesDialog)
- propertiesDialog->selectPrinter();
- if (optionsPane)
- optionsPane->selectPrinter(cups);
- } else {
- if (optionsPane)
- optionsPane->selectPrinter(0);
-#endif
- if (lprPrinters.count() > 0) {
- QString type = lprPrinters.at(index).name + QLatin1Char('@') + lprPrinters.at(index).host;
- if (!lprPrinters.at(index).comment.isEmpty())
- type += QLatin1String(", ") + lprPrinters.at(index).comment;
- widget.type->setText(type);
- if (propertiesDialog)
- propertiesDialog->selectPrinter();
- }
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- }
-#endif
-}
-
-void QUnixPrintWidgetPrivate::setOptionsPane(QPrintDialogPrivate *pane)
-{
- optionsPane = pane;
- if (optionsPane)
- _q_printerChanged(widget.printers->currentIndex());
-}
-
-void QUnixPrintWidgetPrivate::_q_btnBrowseClicked()
-{
- QString filename = widget.filename->text();
-#ifndef QT_NO_FILEDIALOG
- filename = QFileDialog::getSaveFileName(parent, QPrintDialog::tr("Print To File ..."), filename,
- QString(), 0, QFileDialog::DontConfirmOverwrite);
-#else
- filename.clear();
-#endif
- if (!filename.isEmpty()) {
- widget.filename->setText(filename);
- if (filename.endsWith(QString::fromLatin1(".ps"), Qt::CaseInsensitive))
- widget.printers->setCurrentIndex(widget.printers->count() - 1); // the postscript one
- else if (filename.endsWith(QString::fromLatin1(".pdf"), Qt::CaseInsensitive))
- widget.printers->setCurrentIndex(widget.printers->count() - 2); // the pdf one
- else if (widget.printers->currentIndex() != widget.printers->count() - 1) // if ps is not selected, pdf is default
- widget.printers->setCurrentIndex(widget.printers->count() - 2); // the pdf one
- }
-}
-
-void QUnixPrintWidgetPrivate::applyPrinterProperties(QPrinter *p)
-{
- if (p == 0)
- return;
- printer = p;
- if (p->outputFileName().isEmpty()) {
- QString home = QString::fromLocal8Bit(qgetenv("HOME").constData());
- QString cur = QDir::currentPath();
- if (home.at(home.length()-1) != QLatin1Char('/'))
- home += QLatin1Char('/');
- if (cur.at(cur.length()-1) != QLatin1Char('/'))
- cur += QLatin1Char('/');
- if (cur.left(home.length()) != home)
- cur = home;
-#ifdef Q_WS_X11
- if (p->docName().isEmpty()) {
- if (p->outputFormat() == QPrinter::PostScriptFormat)
- cur += QLatin1String("print.ps");
- else
- cur += QLatin1String("print.pdf");
- } else {
- QRegExp re(QString::fromLatin1("(.*)\\.\\S+"));
- if (re.exactMatch(p->docName()))
- cur += re.cap(1);
- else
- cur += p->docName();
- if (p->outputFormat() == QPrinter::PostScriptFormat)
- cur += QLatin1String(".ps");
- else
- cur += QLatin1String(".pdf");
- }
-#endif
- widget.filename->setText(cur);
- }
- else
- widget.filename->setText( p->outputFileName() );
- QString printer = p->printerName();
- if (!printer.isEmpty()) {
- for (int i = 0; i < widget.printers->count(); ++i) {
- if (widget.printers->itemText(i) == printer) {
- widget.printers->setCurrentIndex(i);
- break;
- }
- }
- }
- // PDF and PS printers are not added to the dialog yet, we'll handle those cases in QUnixPrintWidgetPrivate::updateWidget
-
- if (propertiesDialog)
- propertiesDialog->applyPrinterProperties(p);
-}
-
-#ifndef QT_NO_MESSAGEBOX
-bool QUnixPrintWidgetPrivate::checkFields()
-{
- if (widget.filename->isEnabled()) {
- QString file = widget.filename->text();
- QFile f(file);
- QFileInfo fi(f);
- bool exists = fi.exists();
- bool opened = false;
- if (exists && fi.isDir()) {
- QMessageBox::warning(q, q->windowTitle(),
- QPrintDialog::tr("%1 is a directory.\nPlease choose a different file name.").arg(file));
- return false;
- } else if ((exists && !fi.isWritable()) || !(opened = f.open(QFile::Append))) {
- QMessageBox::warning(q, q->windowTitle(),
- QPrintDialog::tr("File %1 is not writable.\nPlease choose a different file name.").arg(file));
- return false;
- } else if (exists) {
- int ret = QMessageBox::question(q, q->windowTitle(),
- QPrintDialog::tr("%1 already exists.\nDo you want to overwrite it?").arg(file),
- QMessageBox::Yes|QMessageBox::No, QMessageBox::No);
- if (ret == QMessageBox::No)
- return false;
- }
- if (opened) {
- f.close();
- if (!exists)
- f.remove();
- }
- }
-
- // Every test passed. Accept the dialog.
- return true;
-}
-#endif // QT_NO_MESSAGEBOX
-
-void QUnixPrintWidgetPrivate::_q_btnPropertiesClicked()
-{
- if (!propertiesDialog) {
- propertiesDialog = new QPrintPropertiesDialog(q);
- propertiesDialog->setResult(QDialog::Rejected);
- }
-
- if (propertiesDialog->result() == QDialog::Rejected) {
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- propertiesDialog->setCups(cups);
-#endif
- propertiesDialog->applyPrinterProperties(q->printer());
-
- if (q->isOptionEnabled(QPrintDialog::PrintToFile)
- && (widget.printers->currentIndex() > widget.printers->count() - 3)) // PDF or postscript
- propertiesDialog->selectPdfPsPrinter(q->printer());
- else
- propertiesDialog->selectPrinter();
- }
- propertiesDialog->exec();
-}
-
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
-void QUnixPrintWidgetPrivate::setCupsProperties()
-{
- if (cups && QCUPSSupport::isAvailable() && cups->pageSizes()) {
- QPrintEngine *engine = printer->printEngine();
- const ppd_option_t* pageSizes = cups->pageSizes();
- QByteArray cupsPageSize;
- for (int i = 0; i < pageSizes->num_choices; ++i) {
- if (static_cast<int>(pageSizes->choices[i].marked) == 1)
- cupsPageSize = pageSizes->choices[i].choice;
- }
- engine->setProperty(PPK_CupsStringPageSize, QString::fromLatin1(cupsPageSize));
- engine->setProperty(PPK_CupsOptions, cups->options());
-
- QRect pageRect = cups->pageRect(cupsPageSize);
- engine->setProperty(PPK_CupsPageRect, pageRect);
-
- QRect paperRect = cups->paperRect(cupsPageSize);
- engine->setProperty(PPK_CupsPaperRect, paperRect);
-
- for (int ps = 0; ps < QPrinter::NPaperSize; ++ps) {
- QPdf::PaperSize size = QPdf::paperSize(QPrinter::PaperSize(ps));
- if (size.width == paperRect.width() && size.height == paperRect.height())
- printer->setPaperSize(static_cast<QPrinter::PaperSize>(ps));
- }
- }
-}
-#endif
-
-void QUnixPrintWidgetPrivate::setupPrinter()
-{
- const int printerCount = widget.printers->count();
- const int index = widget.printers->currentIndex();
-
- if (filePrintersAdded && index > printerCount - 3) { // PDF or postscript
- printer->setPrinterName(QString());
- Q_ASSERT(index != printerCount - 3); // separator
- if (index == printerCount - 2)
- printer->setOutputFormat(QPrinter::PdfFormat);
- else
- printer->setOutputFormat(QPrinter::PostScriptFormat);
- QString path = widget.filename->text();
- if (QDir::isRelativePath(path))
- path = QDir::homePath() + QDir::separator() + path;
- printer->setOutputFileName(path);
- }
- else {
- printer->setPrinterName(widget.printers->currentText());
- printer->setOutputFileName(QString());
- }
-
- if (propertiesDialog && propertiesDialog->result() == QDialog::Accepted)
- propertiesDialog->setupPrinter();
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
- if (!propertiesDialog)
- setCupsProperties();
-#endif
-}
-
-
-/*! \internal
-*/
-QUnixPrintWidget::QUnixPrintWidget(QPrinter *printer, QWidget *parent)
- : QWidget(parent), d(new QUnixPrintWidgetPrivate(this))
-{
- d->applyPrinterProperties(printer);
-}
-
-/*! \internal
-*/
-QUnixPrintWidget::~QUnixPrintWidget()
-{
- delete d;
-}
-
-/*! \internal
-
- Updates the printer with the states held in the QUnixPrintWidget.
-*/
-void QUnixPrintWidget::updatePrinter()
-{
- d->setupPrinter();
-}
-
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
-
-QPPDOptionsModel::QPPDOptionsModel(QCUPSSupport *c, QObject *parent)
- : QAbstractItemModel(parent), rootItem(0), cups(c), ppd(c->currentPPD())
-{
- parseItems();
-}
-
-QPPDOptionsModel::~QPPDOptionsModel()
-{
-}
-
-int QPPDOptionsModel::columnCount(const QModelIndex&) const
-{
- return 2;
-}
-
-int QPPDOptionsModel::rowCount(const QModelIndex& parent) const
-{
- QOptionTreeItem* itm;
- if (!parent.isValid())
- itm = rootItem;
- else
- itm = reinterpret_cast<QOptionTreeItem*>(parent.internalPointer());
-
- if (itm->type == QOptionTreeItem::Option)
- return 0;
-
- return itm->childItems.count();
-}
-
-QVariant QPPDOptionsModel::data(const QModelIndex& index, int role) const
-{
- switch(role) {
- case Qt::FontRole: {
- QOptionTreeItem* itm = reinterpret_cast<QOptionTreeItem*>(index.internalPointer());
- if (itm && itm->type == QOptionTreeItem::Group){
- QFont font = QApplication::font();
- font.setBold(true);
- return QVariant(font);
- }
- return QVariant();
- }
- break;
-
- case Qt::DisplayRole: {
- QOptionTreeItem* itm;
- if (!index.isValid())
- itm = rootItem;
- else
- itm = reinterpret_cast<QOptionTreeItem*>(index.internalPointer());
-
- if (index.column() == 0)
- return cups->unicodeString(itm->description);
- else if (itm->type == QOptionTreeItem::Option && itm->selected > -1)
- return cups->unicodeString(itm->selDescription);
- else
- return QVariant();
- }
- break;
-
- default:
- return QVariant();
- }
- if (role != Qt::DisplayRole)
- return QVariant();
-}
-
-QModelIndex QPPDOptionsModel::index(int row, int column, const QModelIndex& parent) const
-{
- QOptionTreeItem* itm;
- if (!parent.isValid())
- itm = rootItem;
- else
- itm = reinterpret_cast<QOptionTreeItem*>(parent.internalPointer());
-
- return createIndex(row, column, itm->childItems.at(row));
-}
-
-
-QModelIndex QPPDOptionsModel::parent(const QModelIndex& index) const
-{
- if (!index.isValid())
- return QModelIndex();
-
- QOptionTreeItem* itm = reinterpret_cast<QOptionTreeItem*>(index.internalPointer());
-
- if (itm->parentItem && itm->parentItem != rootItem)
- return createIndex(itm->parentItem->index, 0, itm->parentItem);
- else
- return QModelIndex();
-}
-
-Qt::ItemFlags QPPDOptionsModel::flags(const QModelIndex& index) const
-{
- if (!index.isValid() || reinterpret_cast<QOptionTreeItem*>(index.internalPointer())->type == QOptionTreeItem::Group)
- return Qt::ItemIsEnabled;
-
- if (index.column() == 1)
- return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
-
- return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
-}
-
-void QPPDOptionsModel::parseItems()
-{
- emit layoutAboutToBeChanged();
- ppd = cups->currentPPD();
- delete rootItem;
- rootItem = new QOptionTreeItem(QOptionTreeItem::Root, 0, ppd, "Root Item", 0);
- parseGroups(rootItem);
- emit layoutChanged();
-}
-
-void QPPDOptionsModel::parseGroups(QOptionTreeItem* parent)
-{
- if (parent->type == QOptionTreeItem::Root) {
-
- const ppd_file_t* ppdFile = reinterpret_cast<const ppd_file_t*>(parent->ptr);
-
- if (ppdFile) {
- for (int i = 0; i < ppdFile->num_groups; ++i) {
- QOptionTreeItem* group = new QOptionTreeItem(QOptionTreeItem::Group, i, &ppdFile->groups[i], ppdFile->groups[i].text, parent);
- parent->childItems.append(group);
- parseGroups(group); // parse possible subgroups
- parseOptions(group); // parse options
- }
- }
- } else if (parent->type == QOptionTreeItem::Group) {
-
- const ppd_group_t* group = reinterpret_cast<const ppd_group_t*>(parent->ptr);
-
- if (group) {
- for (int i = 0; i < group->num_subgroups; ++i) {
- QOptionTreeItem* subgroup = new QOptionTreeItem(QOptionTreeItem::Group, i, &group->subgroups[i], group->subgroups[i].text, parent);
- parent->childItems.append(subgroup);
- parseGroups(subgroup); // parse possible subgroups
- parseOptions(subgroup); // parse options
- }
- }
- }
-}
-
-void QPPDOptionsModel::parseOptions(QOptionTreeItem* parent)
-{
- const ppd_group_t* group = reinterpret_cast<const ppd_group_t*>(parent->ptr);
- for (int i = 0; i < group->num_options; ++i) {
- QOptionTreeItem* opt = new QOptionTreeItem(QOptionTreeItem::Option, i, &group->options[i], group->options[i].text, parent);
- parent->childItems.append(opt);
- parseChoices(opt);
- }
-}
-
-void QPPDOptionsModel::parseChoices(QOptionTreeItem* parent)
-{
- const ppd_option_t* option = reinterpret_cast<const ppd_option_t*>(parent->ptr);
- bool marked = false;
- for (int i = 0; i < option->num_choices; ++i) {
- QOptionTreeItem* choice = new QOptionTreeItem(QOptionTreeItem::Choice, i, &option->choices[i], option->choices[i].text, parent);
- if (static_cast<int>(option->choices[i].marked) == 1) {
- parent->selected = i;
- parent->selDescription = option->choices[i].text;
- marked = true;
- } else if (!marked && qstrcmp(option->choices[i].choice, option->defchoice) == 0) {
- parent->selected = i;
- parent->selDescription = option->choices[i].text;
- }
- parent->childItems.append(choice);
- }
-}
-
-QVariant QPPDOptionsModel::headerData(int section, Qt::Orientation, int role) const
-{
- if (role != Qt::DisplayRole)
- return QVariant();
-
- switch(section){
- case 0:
- return QVariant(QApplication::translate("QPPDOptionsModel", "Name"));
- case 1:
- return QVariant(QApplication::translate("QPPDOptionsModel", "Value"));
- default:
- return QVariant();
- }
-}
-
-////////////////////////////////////////////////////////////////////////////////
-
-QWidget* QPPDOptionsEditor::createEditor(QWidget* parent, const QStyleOptionViewItem&, const QModelIndex& index) const
-{
- if (index.column() == 1 && reinterpret_cast<QOptionTreeItem*>(index.internalPointer())->type == QOptionTreeItem::Option)
- return new QComboBox(parent);
- else
- return 0;
-}
-
-void QPPDOptionsEditor::setEditorData(QWidget* editor, const QModelIndex& index) const
-{
- if (index.column() != 1)
- return;
-
- QComboBox* cb = static_cast<QComboBox*>(editor);
- QOptionTreeItem* itm = reinterpret_cast<QOptionTreeItem*>(index.internalPointer());
-
- if (itm->selected == -1)
- cb->addItem(QString());
-
- for (int i = 0; i < itm->childItems.count(); ++i)
- cb->addItem(QString::fromLocal8Bit(itm->childItems.at(i)->description));
-
- if (itm->selected > -1)
- cb->setCurrentIndex(itm->selected);
-
- connect(cb, SIGNAL(currentIndexChanged(int)), this, SLOT(cbChanged(int)));
-}
-
-void QPPDOptionsEditor::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
-{
- QComboBox* cb = static_cast<QComboBox*>(editor);
- QOptionTreeItem* itm = reinterpret_cast<QOptionTreeItem*>(index.internalPointer());
-
- if (itm->selected == cb->currentIndex())
- return;
-
- const ppd_option_t* opt = reinterpret_cast<const ppd_option_t*>(itm->ptr);
- QPPDOptionsModel* m = static_cast<QPPDOptionsModel*>(model);
-
- if (m->cups->markOption(opt->keyword, opt->choices[cb->currentIndex()].choice) == 0) {
- itm->selected = cb->currentIndex();
- itm->selDescription = reinterpret_cast<const ppd_option_t*>(itm->ptr)->choices[itm->selected].text;
- }
-}
-
-void QPPDOptionsEditor::cbChanged(int)
-{
-/*
- emit commitData(static_cast<QWidget*>(sender()));
-*/
-}
-
-#endif
-
-QT_END_NAMESPACE
-
-#include "moc_qprintdialog.cpp"
-#include "qprintdialog_unix.moc"
-#include "qrc_qprintdialog.cpp"
-
-#endif // QT_NO_PRINTDIALOG
-
diff --git a/src/gui/dialogs/qprintpreviewdialog.cpp b/src/gui/dialogs/qprintpreviewdialog.cpp
deleted file mode 100644
index eb597fb384..0000000000
--- a/src/gui/dialogs/qprintpreviewdialog.cpp
+++ /dev/null
@@ -1,802 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qprintpreviewdialog.h"
-#include "qprintpreviewwidget.h"
-#include <private/qprinter_p.h>
-#include "private/qdialog_p.h"
-
-#include <QtGui/qaction.h>
-#include <QtGui/qboxlayout.h>
-#include <QtGui/qcombobox.h>
-#include <QtGui/qlabel.h>
-#include <QtGui/qlineedit.h>
-#include <QtGui/qpagesetupdialog.h>
-#include <QtGui/qprinter.h>
-#include <QtGui/qstyle.h>
-#include <QtGui/qtoolbutton.h>
-#include <QtGui/qvalidator.h>
-#include <QtGui/qfiledialog.h>
-#include <QtGui/qmainwindow.h>
-#include <QtGui/qtoolbar.h>
-#include <QtGui/qformlayout.h>
-#include <QtCore/QCoreApplication>
-
-#include <math.h>
-
-#ifndef QT_NO_PRINTPREVIEWDIALOG
-
-QT_BEGIN_NAMESPACE
-
-namespace {
-class QPrintPreviewMainWindow : public QMainWindow
-{
-public:
- QPrintPreviewMainWindow(QWidget *parent) : QMainWindow(parent) {}
- QMenu *createPopupMenu() { return 0; }
-};
-
-class ZoomFactorValidator : public QDoubleValidator
-{
-public:
- ZoomFactorValidator(QObject* parent)
- : QDoubleValidator(parent) {}
- ZoomFactorValidator(qreal bottom, qreal top, int decimals, QObject *parent)
- : QDoubleValidator(bottom, top, decimals, parent) {}
-
- State validate(QString &input, int &pos) const
- {
- bool replacePercent = false;
- if (input.endsWith(QLatin1Char('%'))) {
- input = input.left(input.length() - 1);
- replacePercent = true;
- }
- State state = QDoubleValidator::validate(input, pos);
- if (replacePercent)
- input += QLatin1Char('%');
- const int num_size = 4;
- if (state == Intermediate) {
- int i = input.indexOf(QLocale::system().decimalPoint());
- if ((i == -1 && input.size() > num_size)
- || (i != -1 && i > num_size))
- return Invalid;
- }
- return state;
- }
-};
-
-class LineEdit : public QLineEdit
-{
- Q_OBJECT
-public:
- LineEdit(QWidget* parent = 0)
- : QLineEdit(parent)
- {
- setContextMenuPolicy(Qt::NoContextMenu);
- connect(this, SIGNAL(returnPressed()), SLOT(handleReturnPressed()));
- }
-
-protected:
- void focusInEvent(QFocusEvent *e)
- {
- origText = text();
- QLineEdit::focusInEvent(e);
- }
-
- void focusOutEvent(QFocusEvent *e)
- {
- if (isModified() && !hasAcceptableInput())
- setText(origText);
- QLineEdit::focusOutEvent(e);
- }
-
-private slots:
- void handleReturnPressed()
- {
- origText = text();
- }
-
-private:
- QString origText;
-};
-} // anonymous namespace
-
-class QPrintPreviewDialogPrivate : public QDialogPrivate
-{
- Q_DECLARE_PUBLIC(QPrintPreviewDialog)
-public:
- QPrintPreviewDialogPrivate()
- : printDialog(0), ownPrinter(false),
- initialized(false) {}
-
- // private slots
- void _q_fit(QAction *action);
- void _q_zoomIn();
- void _q_zoomOut();
- void _q_navigate(QAction *action);
- void _q_setMode(QAction *action);
- void _q_pageNumEdited();
- void _q_print();
- void _q_pageSetup();
- void _q_previewChanged();
- void _q_zoomFactorChanged();
-
- void init(QPrinter *printer = 0);
- void populateScene();
- void layoutPages();
- void setupActions();
- void updateNavActions();
- void setFitting(bool on);
- bool isFitting();
- void updatePageNumLabel();
- void updateZoomFactor();
-
- QPrintDialog *printDialog;
- QPrintPreviewWidget *preview;
- QPrinter *printer;
- bool ownPrinter;
- bool initialized;
-
- // widgets:
- QLineEdit *pageNumEdit;
- QLabel *pageNumLabel;
- QComboBox *zoomFactor;
-
- // actions:
- QActionGroup* navGroup;
- QAction *nextPageAction;
- QAction *prevPageAction;
- QAction *firstPageAction;
- QAction *lastPageAction;
-
- QActionGroup* fitGroup;
- QAction *fitWidthAction;
- QAction *fitPageAction;
-
- QActionGroup* zoomGroup;
- QAction *zoomInAction;
- QAction *zoomOutAction;
-
- QActionGroup* orientationGroup;
- QAction *portraitAction;
- QAction *landscapeAction;
-
- QActionGroup* modeGroup;
- QAction *singleModeAction;
- QAction *facingModeAction;
- QAction *overviewModeAction;
-
- QActionGroup *printerGroup;
- QAction *printAction;
- QAction *pageSetupAction;
-#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
- QAction *closeAction;
-#endif
-
- QPointer<QObject> receiverToDisconnectOnClose;
- QByteArray memberToDisconnectOnClose;
-};
-
-void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
-{
- Q_Q(QPrintPreviewDialog);
-
- if (_printer) {
- preview = new QPrintPreviewWidget(_printer, q);
- printer = _printer;
- } else {
- ownPrinter = true;
- printer = new QPrinter;
- preview = new QPrintPreviewWidget(printer, q);
- }
- QObject::connect(preview, SIGNAL(paintRequested(QPrinter*)), q, SIGNAL(paintRequested(QPrinter*)));
- QObject::connect(preview, SIGNAL(previewChanged()), q, SLOT(_q_previewChanged()));
- setupActions();
-
- pageNumEdit = new LineEdit;
- pageNumEdit->setAlignment(Qt::AlignRight);
- pageNumEdit->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
- pageNumLabel = new QLabel;
- QObject::connect(pageNumEdit, SIGNAL(editingFinished()), q, SLOT(_q_pageNumEdited()));
-
- zoomFactor = new QComboBox;
- zoomFactor->setEditable(true);
- zoomFactor->setMinimumContentsLength(7);
- zoomFactor->setInsertPolicy(QComboBox::NoInsert);
- LineEdit *zoomEditor = new LineEdit;
- zoomEditor->setValidator(new ZoomFactorValidator(1, 1000, 1, zoomEditor));
- zoomFactor->setLineEdit(zoomEditor);
- static const short factorsX2[] = { 25, 50, 100, 200, 250, 300, 400, 800, 1600 };
- for (int i = 0; i < int(sizeof(factorsX2) / sizeof(factorsX2[0])); ++i)
- zoomFactor->addItem(QPrintPreviewDialog::tr("%1%").arg(factorsX2[i] / 2.0));
- QObject::connect(zoomFactor->lineEdit(), SIGNAL(editingFinished()),
- q, SLOT(_q_zoomFactorChanged()));
- QObject::connect(zoomFactor, SIGNAL(currentIndexChanged(int)),
- q, SLOT(_q_zoomFactorChanged()));
-
- QPrintPreviewMainWindow *mw = new QPrintPreviewMainWindow(q);
- QToolBar *toolbar = new QToolBar(mw);
- toolbar->addAction(fitWidthAction);
- toolbar->addAction(fitPageAction);
- toolbar->addSeparator();
- toolbar->addWidget(zoomFactor);
- toolbar->addAction(zoomOutAction);
- toolbar->addAction(zoomInAction);
- toolbar->addSeparator();
- toolbar->addAction(portraitAction);
- toolbar->addAction(landscapeAction);
- toolbar->addSeparator();
- toolbar->addAction(firstPageAction);
- toolbar->addAction(prevPageAction);
-
- // this is to ensure the label text and the editor text are
- // aligned in all styles - the extra QVBoxLayout is a workaround
- // for bug in QFormLayout
- QWidget *pageEdit = new QWidget(toolbar);
- QVBoxLayout *vboxLayout = new QVBoxLayout;
- vboxLayout->setContentsMargins(0, 0, 0, 0);
-#ifdef Q_WS_MAC
- // We query the widgets about their size and then we fix the size.
- // This should do the trick for the laying out part...
- QSize pageNumEditSize, pageNumLabelSize;
- pageNumEditSize = pageNumEdit->minimumSizeHint();
- pageNumLabelSize = pageNumLabel->minimumSizeHint();
- pageNumEdit->resize(pageNumEditSize);
- pageNumLabel->resize(pageNumLabelSize);
-#endif
- QFormLayout *formLayout = new QFormLayout;
-#ifdef Q_WS_MAC
- // We have to change the growth policy in Mac.
- formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
-#endif
- formLayout->setWidget(0, QFormLayout::LabelRole, pageNumEdit);
- formLayout->setWidget(0, QFormLayout::FieldRole, pageNumLabel);
- vboxLayout->addLayout(formLayout);
- vboxLayout->setAlignment(Qt::AlignVCenter);
- pageEdit->setLayout(vboxLayout);
- toolbar->addWidget(pageEdit);
-
- toolbar->addAction(nextPageAction);
- toolbar->addAction(lastPageAction);
- toolbar->addSeparator();
- toolbar->addAction(singleModeAction);
- toolbar->addAction(facingModeAction);
- toolbar->addAction(overviewModeAction);
- toolbar->addSeparator();
- toolbar->addAction(pageSetupAction);
- toolbar->addAction(printAction);
-#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
- toolbar->addAction(closeAction);
-#endif
-
- // Cannot use the actions' triggered signal here, since it doesn't autorepeat
- QToolButton *zoomInButton = static_cast<QToolButton *>(toolbar->widgetForAction(zoomInAction));
- QToolButton *zoomOutButton = static_cast<QToolButton *>(toolbar->widgetForAction(zoomOutAction));
- zoomInButton->setAutoRepeat(true);
- zoomInButton->setAutoRepeatInterval(200);
- zoomInButton->setAutoRepeatDelay(200);
- zoomOutButton->setAutoRepeat(true);
- zoomOutButton->setAutoRepeatInterval(200);
- zoomOutButton->setAutoRepeatDelay(200);
- QObject::connect(zoomInButton, SIGNAL(clicked()), q, SLOT(_q_zoomIn()));
- QObject::connect(zoomOutButton, SIGNAL(clicked()), q, SLOT(_q_zoomOut()));
-
- mw->addToolBar(toolbar);
- mw->setCentralWidget(preview);
- // QMainWindows are always created as top levels, force it to be a
- // plain widget
- mw->setParent(q, Qt::Widget);
-
- QVBoxLayout *topLayout = new QVBoxLayout;
- topLayout->addWidget(mw);
- topLayout->setMargin(0);
- q->setLayout(topLayout);
-
- QString caption = QCoreApplication::translate("QPrintPreviewDialog", "Print Preview");
- if (!printer->docName().isEmpty())
- caption += QString::fromLatin1(": ") + printer->docName();
- q->setWindowTitle(caption);
-
- if (!printer->isValid()
-#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
- || printer->outputFormat() != QPrinter::NativeFormat
-#endif
- )
- pageSetupAction->setEnabled(false);
- preview->setFocus();
-}
-
-static inline void qt_setupActionIcon(QAction *action, const QLatin1String &name)
-{
- QLatin1String imagePrefix(":/trolltech/dialogs/qprintpreviewdialog/images/");
- QIcon icon;
- icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
- icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
- action->setIcon(icon);
-}
-
-void QPrintPreviewDialogPrivate::setupActions()
-{
- Q_Q(QPrintPreviewDialog);
-
- // Navigation
- navGroup = new QActionGroup(q);
- navGroup->setExclusive(false);
- nextPageAction = navGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Next page"));
- prevPageAction = navGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Previous page"));
- firstPageAction = navGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "First page"));
- lastPageAction = navGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Last page"));
- qt_setupActionIcon(nextPageAction, QLatin1String("go-next"));
- qt_setupActionIcon(prevPageAction, QLatin1String("go-previous"));
- qt_setupActionIcon(firstPageAction, QLatin1String("go-first"));
- qt_setupActionIcon(lastPageAction, QLatin1String("go-last"));
- QObject::connect(navGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_navigate(QAction*)));
-
-
- fitGroup = new QActionGroup(q);
- fitWidthAction = fitGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Fit width"));
- fitPageAction = fitGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Fit page"));
- fitWidthAction->setObjectName(QLatin1String("fitWidthAction"));
- fitPageAction->setObjectName(QLatin1String("fitPageAction"));
- fitWidthAction->setCheckable(true);
- fitPageAction->setCheckable(true);
- qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
- qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
- QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
-
- // Zoom
- zoomGroup = new QActionGroup(q);
- zoomInAction = zoomGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Zoom in"));
- zoomOutAction = zoomGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Zoom out"));
- qt_setupActionIcon(zoomInAction, QLatin1String("zoom-in"));
- qt_setupActionIcon(zoomOutAction, QLatin1String("zoom-out"));
-
- // Portrait/Landscape
- orientationGroup = new QActionGroup(q);
- portraitAction = orientationGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Portrait"));
- landscapeAction = orientationGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Landscape"));
- portraitAction->setCheckable(true);
- landscapeAction->setCheckable(true);
- qt_setupActionIcon(portraitAction, QLatin1String("layout-portrait"));
- qt_setupActionIcon(landscapeAction, QLatin1String("layout-landscape"));
- QObject::connect(portraitAction, SIGNAL(triggered(bool)), preview, SLOT(setPortraitOrientation()));
- QObject::connect(landscapeAction, SIGNAL(triggered(bool)), preview, SLOT(setLandscapeOrientation()));
-
- // Display mode
- modeGroup = new QActionGroup(q);
- singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
- facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
- overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
- qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
- qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
- qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
- singleModeAction->setObjectName(QLatin1String("singleModeAction"));
- facingModeAction->setObjectName(QLatin1String("facingModeAction"));
- overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
-
- singleModeAction->setCheckable(true);
- facingModeAction->setCheckable(true);
- overviewModeAction->setCheckable(true);
- QObject::connect(modeGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_setMode(QAction*)));
-
- // Print
- printerGroup = new QActionGroup(q);
- printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
- pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
- qt_setupActionIcon(printAction, QLatin1String("print"));
- qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
- QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
- QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
-#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
- closeAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Close"));
- QObject::connect(closeAction, SIGNAL(triggered(bool)), q, SLOT(reject()));
-#endif
-
- // Initial state:
- fitPageAction->setChecked(true);
- singleModeAction->setChecked(true);
- if (preview->orientation() == QPrinter::Portrait)
- portraitAction->setChecked(true);
- else
- landscapeAction->setChecked(true);
-}
-
-
-bool QPrintPreviewDialogPrivate::isFitting()
-{
- return (fitGroup->isExclusive()
- && (fitWidthAction->isChecked() || fitPageAction->isChecked()));
-}
-
-
-void QPrintPreviewDialogPrivate::setFitting(bool on)
-{
- if (isFitting() == on)
- return;
- fitGroup->setExclusive(on);
- if (on) {
- QAction* action = fitWidthAction->isChecked() ? fitWidthAction : fitPageAction;
- action->setChecked(true);
- if (fitGroup->checkedAction() != action) {
- // work around exclusitivity problem
- fitGroup->removeAction(action);
- fitGroup->addAction(action);
- }
- } else {
- fitWidthAction->setChecked(false);
- fitPageAction->setChecked(false);
- }
-}
-
-void QPrintPreviewDialogPrivate::updateNavActions()
-{
- int curPage = preview->currentPage();
- int numPages = preview->pageCount();
- nextPageAction->setEnabled(curPage < numPages);
- prevPageAction->setEnabled(curPage > 1);
- firstPageAction->setEnabled(curPage > 1);
- lastPageAction->setEnabled(curPage < numPages);
- pageNumEdit->setText(QString::number(curPage));
-}
-
-void QPrintPreviewDialogPrivate::updatePageNumLabel()
-{
- Q_Q(QPrintPreviewDialog);
-
- int numPages = preview->pageCount();
- int maxChars = QString::number(numPages).length();
- pageNumLabel->setText(QString::fromLatin1("/ %1").arg(numPages));
- int cyphersWidth = q->fontMetrics().width(QString().fill(QLatin1Char('8'), maxChars));
- int maxWidth = pageNumEdit->minimumSizeHint().width() + cyphersWidth;
- pageNumEdit->setMinimumWidth(maxWidth);
- pageNumEdit->setMaximumWidth(maxWidth);
- pageNumEdit->setValidator(new QIntValidator(1, numPages, pageNumEdit));
- // any old one will be deleted later along with its parent pageNumEdit
-}
-
-void QPrintPreviewDialogPrivate::updateZoomFactor()
-{
- zoomFactor->lineEdit()->setText(QString().sprintf("%.1f%%", preview->zoomFactor()*100));
-}
-
-void QPrintPreviewDialogPrivate::_q_fit(QAction* action)
-{
- setFitting(true);
- if (action == fitPageAction)
- preview->fitInView();
- else
- preview->fitToWidth();
-}
-
-void QPrintPreviewDialogPrivate::_q_zoomIn()
-{
- setFitting(false);
- preview->zoomIn();
- updateZoomFactor();
-}
-
-void QPrintPreviewDialogPrivate::_q_zoomOut()
-{
- setFitting(false);
- preview->zoomOut();
- updateZoomFactor();
-}
-
-void QPrintPreviewDialogPrivate::_q_pageNumEdited()
-{
- bool ok = false;
- int res = pageNumEdit->text().toInt(&ok);
- if (ok)
- preview->setCurrentPage(res);
-}
-
-void QPrintPreviewDialogPrivate::_q_navigate(QAction* action)
-{
- int curPage = preview->currentPage();
- if (action == prevPageAction)
- preview->setCurrentPage(curPage - 1);
- else if (action == nextPageAction)
- preview->setCurrentPage(curPage + 1);
- else if (action == firstPageAction)
- preview->setCurrentPage(1);
- else if (action == lastPageAction)
- preview->setCurrentPage(preview->pageCount());
- updateNavActions();
-}
-
-void QPrintPreviewDialogPrivate::_q_setMode(QAction* action)
-{
- if (action == overviewModeAction) {
- preview->setViewMode(QPrintPreviewWidget::AllPagesView);
- setFitting(false);
- fitGroup->setEnabled(false);
- navGroup->setEnabled(false);
- pageNumEdit->setEnabled(false);
- pageNumLabel->setEnabled(false);
- } else if (action == facingModeAction) {
- preview->setViewMode(QPrintPreviewWidget::FacingPagesView);
- } else {
- preview->setViewMode(QPrintPreviewWidget::SinglePageView);
- }
- if (action == facingModeAction || action == singleModeAction) {
- fitGroup->setEnabled(true);
- navGroup->setEnabled(true);
- pageNumEdit->setEnabled(true);
- pageNumLabel->setEnabled(true);
- setFitting(true);
- }
-}
-
-void QPrintPreviewDialogPrivate::_q_print()
-{
- Q_Q(QPrintPreviewDialog);
-
-#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
- if (printer->outputFormat() != QPrinter::NativeFormat) {
- QString title;
- QString suffix;
- if (printer->outputFormat() == QPrinter::PdfFormat) {
- title = QCoreApplication::translate("QPrintPreviewDialog", "Export to PDF");
- suffix = QLatin1String(".pdf");
- } else {
- title = QCoreApplication::translate("QPrintPreviewDialog", "Export to PostScript");
- suffix = QLatin1String(".ps");
- }
- QString fileName = QFileDialog::getSaveFileName(q, title, printer->outputFileName(),
- QLatin1Char('*') + suffix);
- if (!fileName.isEmpty()) {
- if (QFileInfo(fileName).suffix().isEmpty())
- fileName.append(suffix);
- printer->setOutputFileName(fileName);
- }
- if (!printer->outputFileName().isEmpty())
- preview->print();
- q->accept();
- return;
- }
-#endif
-
- if (!printDialog)
- printDialog = new QPrintDialog(printer, q);
- if (printDialog->exec() == QDialog::Accepted) {
- preview->print();
- q->accept();
- }
-}
-
-void QPrintPreviewDialogPrivate::_q_pageSetup()
-{
- Q_Q(QPrintPreviewDialog);
-
- QPageSetupDialog pageSetup(printer, q);
- if (pageSetup.exec() == QDialog::Accepted) {
- // update possible orientation changes
- if (preview->orientation() == QPrinter::Portrait) {
- portraitAction->setChecked(true);
- preview->setPortraitOrientation();
- }else {
- landscapeAction->setChecked(true);
- preview->setLandscapeOrientation();
- }
- }
-}
-
-void QPrintPreviewDialogPrivate::_q_previewChanged()
-{
- updateNavActions();
- updatePageNumLabel();
- updateZoomFactor();
-}
-
-void QPrintPreviewDialogPrivate::_q_zoomFactorChanged()
-{
- QString text = zoomFactor->lineEdit()->text();
- bool ok;
- qreal factor = text.remove(QLatin1Char('%')).toFloat(&ok);
- factor = qMax(qreal(1.0), qMin(qreal(1000.0), factor));
- if (ok) {
- preview->setZoomFactor(factor/100.0);
- zoomFactor->setEditText(QString::fromLatin1("%1%").arg(factor));
- setFitting(false);
- }
-}
-
-///////////////////////////////////////////////////////////////////////////
-
-/*!
- \class QPrintPreviewDialog
- \since 4.4
-
- \brief The QPrintPreviewDialog class provides a dialog for
- previewing and configuring page layouts for printer output.
-
- \ingroup standard-dialogs
- \ingroup printing
-
- Using QPrintPreviewDialog in your existing application is
- straightforward:
-
- \list 1
- \o Create the QPrintPreviewDialog.
-
- You can construct a QPrintPreviewDialog with an existing QPrinter
- object, or you can have QPrintPreviewDialog create one for you,
- which will be the system default printer.
-
- \o Connect the paintRequested() signal to a slot.
-
- When the dialog needs to generate a set of preview pages, the
- paintRequested() signal will be emitted. You can use the exact
- same code for the actual printing as for having the preview
- generated, including calling QPrinter::newPage() to start a new
- page in the preview. Connect a slot to the paintRequested()
- signal, where you draw onto the QPrinter object that is passed
- into the slot.
-
- \o Call exec().
-
- Call QPrintPreviewDialog::exec() to show the preview dialog.
- \endlist
-
- In Symbian, there is no support for printing. Hence, this dialog should not
- be used in Symbian.
-
- \sa QPrinter, QPrintDialog, QPageSetupDialog, QPrintPreviewWidget
-*/
-
-/*!
- Constructs a QPrintPreviewDialog based on \a printer and with \a
- parent as the parent widget. The widget flags \a flags are passed on
- to the QWidget constructor.
-
- \sa QWidget::setWindowFlags()
-*/
-QPrintPreviewDialog::QPrintPreviewDialog(QPrinter* printer, QWidget *parent, Qt::WindowFlags flags)
- : QDialog(*new QPrintPreviewDialogPrivate, parent, flags)
-{
- Q_D(QPrintPreviewDialog);
- d->init(printer);
-}
-
-/*!
- \overload
- \fn QPrintPreviewDialog::QPrintPreviewDialog(QWidget *parent, Qt::WindowFlags flags)
-
- This will create an internal QPrinter object, which will use the
- system default printer.
-*/
-QPrintPreviewDialog::QPrintPreviewDialog(QWidget *parent, Qt::WindowFlags f)
- : QDialog(*new QPrintPreviewDialogPrivate, parent, f)
-{
- Q_D(QPrintPreviewDialog);
- d->init();
-}
-
-/*!
- Destroys the QPrintPreviewDialog.
-*/
-QPrintPreviewDialog::~QPrintPreviewDialog()
-{
- Q_D(QPrintPreviewDialog);
- if (d->ownPrinter)
- delete d->printer;
- delete d->printDialog;
-}
-
-/*!
- \reimp
-*/
-void QPrintPreviewDialog::setVisible(bool visible)
-{
- Q_D(QPrintPreviewDialog);
- // this will make the dialog get a decent default size
- if (visible && !d->initialized) {
- d->preview->updatePreview();
- d->initialized = true;
- }
- QDialog::setVisible(visible);
-}
-
-/*!
- \reimp
-*/
-void QPrintPreviewDialog::done(int result)
-{
- Q_D(QPrintPreviewDialog);
- QDialog::done(result);
- if (d->receiverToDisconnectOnClose) {
- disconnect(this, SIGNAL(finished(int)),
- d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
- d->receiverToDisconnectOnClose = 0;
- }
- d->memberToDisconnectOnClose.clear();
-}
-
-/*!
- \overload
- \since 4.5
-
- Opens the dialog and connects its finished(int) signal to the slot specified
- by \a receiver and \a member.
-
- The signal will be disconnected from the slot when the dialog is closed.
-*/
-void QPrintPreviewDialog::open(QObject *receiver, const char *member)
-{
- Q_D(QPrintPreviewDialog);
- // the int parameter isn't very useful here; we could just as well connect
- // to reject(), but this feels less robust somehow
- connect(this, SIGNAL(finished(int)), receiver, member);
- d->receiverToDisconnectOnClose = receiver;
- d->memberToDisconnectOnClose = member;
- QDialog::open();
-}
-
-/*!
- Returns a pointer to the QPrinter object this dialog is currently
- operating on.
-*/
-QPrinter *QPrintPreviewDialog::printer()
-{
- Q_D(QPrintPreviewDialog);
- return d->printer;
-}
-
-/*!
- \fn void QPrintPreviewDialog::paintRequested(QPrinter *printer)
-
- This signal is emitted when the QPrintPreviewDialog needs to generate
- a set of preview pages.
-
- The \a printer instance supplied is the paint device onto which you should
- paint the contents of each page, using the QPrinter instance in the same way
- as you would when printing directly.
-*/
-
-
-QT_END_NAMESPACE
-
-#include "moc_qprintpreviewdialog.cpp"
-#include "qprintpreviewdialog.moc"
-
-#endif // QT_NO_PRINTPREVIEWDIALOG
-
-
diff --git a/src/gui/dialogs/qprintpreviewdialog.h b/src/gui/dialogs/qprintpreviewdialog.h
deleted file mode 100644
index a49455b520..0000000000
--- a/src/gui/dialogs/qprintpreviewdialog.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPRINTPREVIEWDIALOG_H
-#define QPRINTPREVIEWDIALOG_H
-
-#include <QtGui/qdialog.h>
-
-#ifndef QT_NO_PRINTPREVIEWDIALOG
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QGraphicsView;
-class QPrintPreviewDialogPrivate;
-
-class Q_GUI_EXPORT QPrintPreviewDialog : public QDialog
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QPrintPreviewDialog)
-
-public:
- explicit QPrintPreviewDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0);
- explicit QPrintPreviewDialog(QPrinter *printer, QWidget *parent = 0, Qt::WindowFlags flags = 0);
- ~QPrintPreviewDialog();
-
-#ifdef Q_NO_USING_KEYWORD
-#ifndef Q_QDOC
- void open() { QDialog::open(); }
-#endif
-#else
- using QDialog::open;
-#endif
- void open(QObject *receiver, const char *member);
-
- QPrinter *printer();
-
- void setVisible(bool visible);
- void done(int result);
-
-Q_SIGNALS:
- void paintRequested(QPrinter *printer);
-
-private:
- Q_PRIVATE_SLOT(d_func(), void _q_fit(QAction *action))
- Q_PRIVATE_SLOT(d_func(), void _q_zoomIn())
- Q_PRIVATE_SLOT(d_func(), void _q_zoomOut())
- Q_PRIVATE_SLOT(d_func(), void _q_navigate(QAction *action))
- Q_PRIVATE_SLOT(d_func(), void _q_setMode(QAction *action))
- Q_PRIVATE_SLOT(d_func(), void _q_pageNumEdited())
- Q_PRIVATE_SLOT(d_func(), void _q_print())
- Q_PRIVATE_SLOT(d_func(), void _q_pageSetup())
- Q_PRIVATE_SLOT(d_func(), void _q_previewChanged())
- Q_PRIVATE_SLOT(d_func(), void _q_zoomFactorChanged())
-
- void *dummy; // ### Qt 5 - remove me
-};
-
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_PRINTPREVIEWDIALOG
-
-#endif // QPRINTPREVIEWDIALOG_H
diff --git a/src/gui/dialogs/qprogressdialog.cpp b/src/gui/dialogs/qprogressdialog.cpp
deleted file mode 100644
index a3fff9b617..0000000000
--- a/src/gui/dialogs/qprogressdialog.cpp
+++ /dev/null
@@ -1,907 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qprogressdialog.h"
-
-#ifndef QT_NO_PROGRESSDIALOG
-
-#include "qshortcut.h"
-#include "qpainter.h"
-#include "qdrawutil.h"
-#include "qlabel.h"
-#include "qprogressbar.h"
-#include "qapplication.h"
-#include "qstyle.h"
-#include "qpushbutton.h"
-#include "qcursor.h"
-#include "qtimer.h"
-#include "qelapsedtimer.h"
-#include <private/qdialog_p.h>
-#include <limits.h>
-
-#if defined(QT_SOFTKEYS_ENABLED)
-#include <qaction.h>
-#endif
-#ifdef Q_WS_S60
-#include <QtGui/qdesktopwidget.h>
-#endif
-
-
-QT_BEGIN_NAMESPACE
-
-// If the operation is expected to take this long (as predicted by
-// progress time), show the progress dialog.
-static const int defaultShowTime = 4000;
-// Wait at least this long before attempting to make a prediction.
-static const int minWaitTime = 50;
-
-class QProgressDialogPrivate : public QDialogPrivate
-{
- Q_DECLARE_PUBLIC(QProgressDialog)
-
-public:
- QProgressDialogPrivate() : label(0), cancel(0), bar(0),
- shown_once(false),
- cancellation_flag(false),
- showTime(defaultShowTime),
-#ifndef QT_NO_SHORTCUT
- escapeShortcut(0),
-#endif
-#ifdef QT_SOFTKEYS_ENABLED
- cancelAction(0),
-#endif
- useDefaultCancelText(false)
- {
- }
-
- void init(const QString &labelText, const QString &cancelText, int min, int max);
- void layout();
- void retranslateStrings();
- void _q_disconnectOnClose();
-
- QLabel *label;
- QPushButton *cancel;
- QProgressBar *bar;
- QTimer *forceTimer;
- bool shown_once;
- bool cancellation_flag;
- QElapsedTimer starttime;
-#ifndef QT_NO_CURSOR
- QCursor parentCursor;
-#endif
- int showTime;
- bool autoClose;
- bool autoReset;
- bool forceHide;
-#ifndef QT_NO_SHORTCUT
- QShortcut *escapeShortcut;
-#endif
-#ifdef QT_SOFTKEYS_ENABLED
- QAction *cancelAction;
-#endif
- bool useDefaultCancelText;
- QPointer<QObject> receiverToDisconnectOnClose;
- QByteArray memberToDisconnectOnClose;
-};
-
-void QProgressDialogPrivate::init(const QString &labelText, const QString &cancelText,
- int min, int max)
-{
- Q_Q(QProgressDialog);
- label = new QLabel(labelText, q);
- int align = q->style()->styleHint(QStyle::SH_ProgressDialog_TextLabelAlignment, 0, q);
- label->setAlignment(Qt::Alignment(align));
- bar = new QProgressBar(q);
- bar->setRange(min, max);
- autoClose = true;
- autoReset = true;
- forceHide = false;
- QObject::connect(q, SIGNAL(canceled()), q, SLOT(cancel()));
- forceTimer = new QTimer(q);
- QObject::connect(forceTimer, SIGNAL(timeout()), q, SLOT(forceShow()));
- if (useDefaultCancelText) {
- retranslateStrings();
- } else {
- q->setCancelButtonText(cancelText);
- }
-}
-
-void QProgressDialogPrivate::layout()
-{
- Q_Q(QProgressDialog);
- int sp = q->style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing);
- int mtb = q->style()->pixelMetric(QStyle::PM_DefaultTopLevelMargin);
- int mlr = qMin(q->width() / 10, mtb);
- const bool centered =
- bool(q->style()->styleHint(QStyle::SH_ProgressDialog_CenterCancelButton, 0, q));
-
- int additionalSpacing = 0;
-#ifdef Q_OS_SYMBIAN
- //In Symbian, we need to have wider margins for dialog borders, as the actual border is some pixels
- //inside the dialog area (to enable transparent borders)
- additionalSpacing = mlr;
-#endif
-
- QSize cs = cancel ? cancel->sizeHint() : QSize(0,0);
- QSize bh = bar->sizeHint();
- int cspc;
- int lh = 0;
-
- // Find spacing and sizes that fit. It is important that a progress
- // dialog can be made very small if the user demands it so.
- for (int attempt=5; attempt--;) {
- cspc = cancel ? cs.height() + sp : 0;
- lh = qMax(0, q->height() - mtb - bh.height() - sp - cspc);
-
- if (lh < q->height()/4) {
- // Getting cramped
- sp /= 2;
- mtb /= 2;
- if (cancel) {
- cs.setHeight(qMax(4,cs.height()-sp-2));
- }
- bh.setHeight(qMax(4,bh.height()-sp-1));
- } else {
- break;
- }
- }
-
- if (cancel) {
- cancel->setGeometry(
- centered ? q->width()/2 - cs.width()/2 : q->width() - mlr - cs.width(),
- q->height() - mtb - cs.height(),
- cs.width(), cs.height());
- }
-
- if (label)
- label->setGeometry(mlr, additionalSpacing, q->width() - mlr * 2, lh);
- bar->setGeometry(mlr, lh + sp + additionalSpacing, q->width() - mlr * 2, bh.height());
-}
-
-void QProgressDialogPrivate::retranslateStrings()
-{
- Q_Q(QProgressDialog);
- if (useDefaultCancelText)
- q->setCancelButtonText(QProgressDialog::tr("Cancel"));
-}
-
-void QProgressDialogPrivate::_q_disconnectOnClose()
-{
- Q_Q(QProgressDialog);
- if (receiverToDisconnectOnClose) {
- QObject::disconnect(q, SIGNAL(canceled()), receiverToDisconnectOnClose,
- memberToDisconnectOnClose);
- receiverToDisconnectOnClose = 0;
- }
- memberToDisconnectOnClose.clear();
-}
-
-/*!
- \class QProgressDialog
- \brief The QProgressDialog class provides feedback on the progress of a slow operation.
- \ingroup standard-dialogs
-
-
- A progress dialog is used to give the user an indication of how long
- an operation is going to take, and to demonstrate that the
- application has not frozen. It can also give the user an opportunity
- to abort the operation.
-
- A common problem with progress dialogs is that it is difficult to know
- when to use them; operations take different amounts of time on different
- hardware. QProgressDialog offers a solution to this problem:
- it estimates the time the operation will take (based on time for
- steps), and only shows itself if that estimate is beyond minimumDuration()
- (4 seconds by default).
-
- Use setMinimum() and setMaximum() or the constructor to set the number of
- "steps" in the operation and call setValue() as the operation
- progresses. The number of steps can be chosen arbitrarily. It can be the
- number of files copied, the number of bytes received, the number of
- iterations through the main loop of your algorithm, or some other
- suitable unit. Progress starts at the value set by setMinimum(),
- and the progress dialog shows that the operation has finished when
- you call setValue() with the value set by setMaximum() as its argument.
-
- The dialog automatically resets and hides itself at the end of the
- operation. Use setAutoReset() and setAutoClose() to change this
- behavior. Note that if you set a new maximum (using setMaximum() or
- setRange()) that equals your current value(), the dialog will not
- close regardless.
-
- There are two ways of using QProgressDialog: modal and modeless.
-
- Compared to a modeless QProgressDialog, a modal QProgressDialog is simpler
- to use for the programmer. Do the operation in a loop, call \l setValue() at
- intervals, and check for cancellation with wasCanceled(). For example:
-
- \snippet doc/src/snippets/dialogs/dialogs.cpp 3
-
- A modeless progress dialog is suitable for operations that take
- place in the background, where the user is able to interact with the
- application. Such operations are typically based on QTimer (or
- QObject::timerEvent()), QSocketNotifier, or QUrlOperator; or performed
- in a separate thread. A QProgressBar in the status bar of your main window
- is often an alternative to a modeless progress dialog.
-
- You need to have an event loop to be running, connect the
- canceled() signal to a slot that stops the operation, and call \l
- setValue() at intervals. For example:
-
- \snippet doc/src/snippets/dialogs/dialogs.cpp 4
- \codeline
- \snippet doc/src/snippets/dialogs/dialogs.cpp 5
- \codeline
- \snippet doc/src/snippets/dialogs/dialogs.cpp 6
-
- In both modes the progress dialog may be customized by
- replacing the child widgets with custom widgets by using setLabel(),
- setBar(), and setCancelButton().
- The functions setLabelText() and setCancelButtonText()
- set the texts shown.
-
- \image plastique-progressdialog.png A progress dialog shown in the Plastique widget style.
-
- \sa QDialog, QProgressBar, {fowler}{GUI Design Handbook: Progress Indicator},
- {Find Files Example}, {Pixelator Example}
-*/
-
-
-/*!
- Constructs a progress dialog.
-
- Default settings:
- \list
- \i The label text is empty.
- \i The cancel button text is (translated) "Cancel".
- \i minimum is 0;
- \i maximum is 100
- \endlist
-
- The \a parent argument is dialog's parent widget. The widget flags, \a f, are
- passed to the QDialog::QDialog() constructor.
-
- \sa setLabelText(), setCancelButtonText(), setCancelButton(),
- setMinimum(), setMaximum()
-*/
-
-QProgressDialog::QProgressDialog(QWidget *parent, Qt::WindowFlags f)
- : QDialog(*(new QProgressDialogPrivate), parent, f)
-{
- Q_D(QProgressDialog);
- d->useDefaultCancelText = true;
- d->init(QString::fromLatin1(""), QString(), 0, 100);
-}
-
-/*!
- Constructs a progress dialog.
-
- The \a labelText is the text used to remind the user what is progressing.
-
- The \a cancelButtonText is the text to display on the cancel button. If
- QString() is passed then no cancel button is shown.
-
- The \a minimum and \a maximum is the number of steps in the operation for
- which this progress dialog shows progress. For example, if the
- operation is to examine 50 files, this value minimum value would be 0,
- and the maximum would be 50. Before examining the first file, call
- setValue(0). As each file is processed call setValue(1), setValue(2),
- etc., finally calling setValue(50) after examining the last file.
-
- The \a parent argument is the dialog's parent widget. The parent, \a parent, and
- widget flags, \a f, are passed to the QDialog::QDialog() constructor.
-
- \sa setLabelText(), setLabel(), setCancelButtonText(), setCancelButton(),
- setMinimum(), setMaximum()
-*/
-
-QProgressDialog::QProgressDialog(const QString &labelText,
- const QString &cancelButtonText,
- int minimum, int maximum,
- QWidget *parent, Qt::WindowFlags f)
- : QDialog(*(new QProgressDialogPrivate), parent, f)
-{
- Q_D(QProgressDialog);
- d->init(labelText, cancelButtonText, minimum, maximum);
-}
-
-
-/*!
- Destroys the progress dialog.
-*/
-
-QProgressDialog::~QProgressDialog()
-{
-}
-
-/*!
- \fn void QProgressDialog::canceled()
-
- This signal is emitted when the cancel button is clicked.
- It is connected to the cancel() slot by default.
-
- \sa wasCanceled()
-*/
-
-
-/*!
- Sets the label to \a label. The progress dialog resizes to fit. The
- label becomes owned by the progress dialog and will be deleted when
- necessary, so do not pass the address of an object on the stack.
-
- \sa setLabelText()
-*/
-
-void QProgressDialog::setLabel(QLabel *label)
-{
- Q_D(QProgressDialog);
- delete d->label;
- d->label = label;
- if (label) {
- if (label->parentWidget() == this) {
- label->hide(); // until we resize
- } else {
- label->setParent(this, 0);
- }
- }
- int w = qMax(isVisible() ? width() : 0, sizeHint().width());
- int h = qMax(isVisible() ? height() : 0, sizeHint().height());
- resize(w, h);
- if (label)
- label->show();
-}
-
-
-/*!
- \property QProgressDialog::labelText
- \brief the label's text
-
- The default text is an empty string.
-*/
-
-QString QProgressDialog::labelText() const
-{
- Q_D(const QProgressDialog);
- if (d->label)
- return d->label->text();
- return QString();
-}
-
-void QProgressDialog::setLabelText(const QString &text)
-{
- Q_D(QProgressDialog);
- if (d->label) {
- d->label->setText(text);
- int w = qMax(isVisible() ? width() : 0, sizeHint().width());
- int h = qMax(isVisible() ? height() : 0, sizeHint().height());
- resize(w, h);
- }
-}
-
-
-/*!
- Sets the cancel button to the push button, \a cancelButton. The
- progress dialog takes ownership of this button which will be deleted
- when necessary, so do not pass the address of an object that is on
- the stack, i.e. use new() to create the button. If 0 is passed then
- no cancel button will be shown.
-
- \sa setCancelButtonText()
-*/
-
-void QProgressDialog::setCancelButton(QPushButton *cancelButton)
-{
- Q_D(QProgressDialog);
- delete d->cancel;
- d->cancel = cancelButton;
- if (cancelButton) {
- if (cancelButton->parentWidget() == this) {
- cancelButton->hide(); // until we resize
- } else {
- cancelButton->setParent(this, 0);
- }
- connect(d->cancel, SIGNAL(clicked()), this, SIGNAL(canceled()));
-#ifndef QT_NO_SHORTCUT
- d->escapeShortcut = new QShortcut(Qt::Key_Escape, this, SIGNAL(canceled()));
-#endif
- } else {
-#ifndef QT_NO_SHORTCUT
- delete d->escapeShortcut;
- d->escapeShortcut = 0;
-#endif
- }
- int w = qMax(isVisible() ? width() : 0, sizeHint().width());
- int h = qMax(isVisible() ? height() : 0, sizeHint().height());
- resize(w, h);
- if (cancelButton)
-#if !defined(QT_SOFTKEYS_ENABLED)
- cancelButton->show();
-#else
- {
- d->cancelAction = new QAction(cancelButton->text(), cancelButton);
- d->cancelAction->setSoftKeyRole(QAction::NegativeSoftKey);
- connect(d->cancelAction, SIGNAL(triggered()), this, SIGNAL(canceled()));
- addAction(d->cancelAction);
- }
-#endif
-}
-
-/*!
- Sets the cancel button's text to \a cancelButtonText. If the text
- is set to QString() then it will cause the cancel button to be
- hidden and deleted.
-
- \sa setCancelButton()
-*/
-
-void QProgressDialog::setCancelButtonText(const QString &cancelButtonText)
-{
- Q_D(QProgressDialog);
- d->useDefaultCancelText = false;
-
- if (!cancelButtonText.isNull()) {
- if (d->cancel) {
- d->cancel->setText(cancelButtonText);
-#ifdef QT_SOFTKEYS_ENABLED
- d->cancelAction->setText(cancelButtonText);
-#endif
- } else {
- setCancelButton(new QPushButton(cancelButtonText, this));
- }
- } else {
- setCancelButton(0);
- }
- int w = qMax(isVisible() ? width() : 0, sizeHint().width());
- int h = qMax(isVisible() ? height() : 0, sizeHint().height());
- resize(w, h);
-}
-
-
-/*!
- Sets the progress bar widget to \a bar. The progress dialog resizes to
- fit. The progress dialog takes ownership of the progress \a bar which
- will be deleted when necessary, so do not use a progress bar
- allocated on the stack.
-*/
-
-void QProgressDialog::setBar(QProgressBar *bar)
-{
- Q_D(QProgressDialog);
- if (!bar) {
- qWarning("QProgressDialog::setBar: Cannot set a null progress bar");
- return;
- }
-#ifndef QT_NO_DEBUG
- if (value() > 0)
- qWarning("QProgressDialog::setBar: Cannot set a new progress bar "
- "while the old one is active");
-#endif
- delete d->bar;
- d->bar = bar;
- int w = qMax(isVisible() ? width() : 0, sizeHint().width());
- int h = qMax(isVisible() ? height() : 0, sizeHint().height());
- resize(w, h);
-}
-
-
-/*!
- \property QProgressDialog::wasCanceled
- \brief whether the dialog was canceled
-*/
-
-bool QProgressDialog::wasCanceled() const
-{
- Q_D(const QProgressDialog);
- return d->cancellation_flag;
-}
-
-
-/*!
- \property QProgressDialog::maximum
- \brief the highest value represented by the progress bar
-
- The default is 0.
-
- \sa minimum, setRange()
-*/
-
-int QProgressDialog::maximum() const
-{
- Q_D(const QProgressDialog);
- return d->bar->maximum();
-}
-
-void QProgressDialog::setMaximum(int maximum)
-{
- Q_D(QProgressDialog);
- d->bar->setMaximum(maximum);
-}
-
-/*!
- \property QProgressDialog::minimum
- \brief the lowest value represented by the progress bar
-
- The default is 0.
-
- \sa maximum, setRange()
-*/
-
-int QProgressDialog::minimum() const
-{
- Q_D(const QProgressDialog);
- return d->bar->minimum();
-}
-
-void QProgressDialog::setMinimum(int minimum)
-{
- Q_D(QProgressDialog);
- d->bar->setMinimum(minimum);
-}
-
-/*!
- Sets the progress dialog's minimum and maximum values
- to \a minimum and \a maximum, respectively.
-
- If \a maximum is smaller than \a minimum, \a minimum becomes the only
- legal value.
-
- If the current value falls outside the new range, the progress
- dialog is reset with reset().
-
- \sa minimum, maximum
-*/
-void QProgressDialog::setRange(int minimum, int maximum)
-{
- Q_D(QProgressDialog);
- d->bar->setRange(minimum, maximum);
-}
-
-
-/*!
- Resets the progress dialog.
- The progress dialog becomes hidden if autoClose() is true.
-
- \sa setAutoClose(), setAutoReset()
-*/
-
-void QProgressDialog::reset()
-{
- Q_D(QProgressDialog);
-#ifndef QT_NO_CURSOR
- if (value() >= 0) {
- if (parentWidget())
- parentWidget()->setCursor(d->parentCursor);
- }
-#endif
- if (d->autoClose || d->forceHide)
- hide();
- d->bar->reset();
- d->cancellation_flag = false;
- d->shown_once = false;
- d->forceTimer->stop();
-
- /*
- I wish we could disconnect the user slot provided to open() here but
- unfortunately reset() is usually called before the slot has been invoked.
- (reset() is itself invoked when canceled() is emitted.)
- */
- if (d->receiverToDisconnectOnClose)
- QMetaObject::invokeMethod(this, "_q_disconnectOnClose", Qt::QueuedConnection);
-}
-
-/*!
- Resets the progress dialog. wasCanceled() becomes true until
- the progress dialog is reset.
- The progress dialog becomes hidden.
-*/
-
-void QProgressDialog::cancel()
-{
- Q_D(QProgressDialog);
- d->forceHide = true;
- reset();
- d->forceHide = false;
- d->cancellation_flag = true;
-}
-
-
-int QProgressDialog::value() const
-{
- Q_D(const QProgressDialog);
- return d->bar->value();
-}
-
-/*!
- \property QProgressDialog::value
- \brief the current amount of progress made.
-
- For the progress dialog to work as expected, you should initially set
- this property to 0 and finally set it to
- QProgressDialog::maximum(); you can call setValue() any number of times
- in-between.
-
- \warning If the progress dialog is modal
- (see QProgressDialog::QProgressDialog()),
- setValue() calls QApplication::processEvents(), so take care that
- this does not cause undesirable re-entrancy in your code. For example,
- don't use a QProgressDialog inside a paintEvent()!
-
- \sa minimum, maximum
-*/
-void QProgressDialog::setValue(int progress)
-{
- Q_D(QProgressDialog);
- if (progress == d->bar->value()
- || (d->bar->value() == -1 && progress == d->bar->maximum()))
- return;
-
- d->bar->setValue(progress);
-
- if (d->shown_once) {
- if (isModal())
- QApplication::processEvents();
- } else {
- if (progress == 0) {
- d->starttime.start();
- d->forceTimer->start(d->showTime);
- return;
- } else {
- bool need_show;
- int elapsed = d->starttime.elapsed();
- if (elapsed >= d->showTime) {
- need_show = true;
- } else {
- if (elapsed > minWaitTime) {
- int estimate;
- int totalSteps = maximum() - minimum();
- int myprogress = progress - minimum();
- if ((totalSteps - myprogress) >= INT_MAX / elapsed)
- estimate = (totalSteps - myprogress) / myprogress * elapsed;
- else
- estimate = elapsed * (totalSteps - myprogress) / myprogress;
- need_show = estimate >= d->showTime;
- } else {
- need_show = false;
- }
- }
- if (need_show) {
- int w = qMax(isVisible() ? width() : 0, sizeHint().width());
- int h = qMax(isVisible() ? height() : 0, sizeHint().height());
- resize(w, h);
- show();
- d->shown_once = true;
- }
- }
-#ifdef Q_WS_MAC
- QApplication::flush();
-#endif
- }
-
- if (progress == d->bar->maximum() && d->autoReset)
- reset();
-}
-
-/*!
- Returns a size that fits the contents of the progress dialog.
- The progress dialog resizes itself as required, so you should not
- need to call this yourself.
-*/
-
-QSize QProgressDialog::sizeHint() const
-{
- Q_D(const QProgressDialog);
- QSize sh = d->label ? d->label->sizeHint() : QSize(0, 0);
- QSize bh = d->bar->sizeHint();
- int margin = style()->pixelMetric(QStyle::PM_DefaultTopLevelMargin);
- int spacing = style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing);
- int h = margin * 2 + bh.height() + sh.height() + spacing;
- if (d->cancel)
- h += d->cancel->sizeHint().height() + spacing;
-#ifdef Q_WS_S60
- if (QApplication::desktop()->size().height() > QApplication::desktop()->size().width())
- return QSize(qMax(QApplication::desktop()->size().width(), sh.width() + 2 * margin), h);
- else
- return QSize(qMax(QApplication::desktop()->size().height(), sh.width() + 2 * margin), h);
-#else
- return QSize(qMax(200, sh.width() + 2 * margin), h);
-#endif
-}
-
-/*!\reimp
-*/
-void QProgressDialog::resizeEvent(QResizeEvent *)
-{
- Q_D(QProgressDialog);
- d->layout();
-}
-
-/*!
- \reimp
-*/
-void QProgressDialog::changeEvent(QEvent *ev)
-{
- Q_D(QProgressDialog);
- if (ev->type() == QEvent::StyleChange) {
- d->layout();
- } else if (ev->type() == QEvent::LanguageChange) {
- d->retranslateStrings();
- }
- QDialog::changeEvent(ev);
-}
-
-/*!
- \property QProgressDialog::minimumDuration
- \brief the time that must pass before the dialog appears
-
- If the expected duration of the task is less than the
- minimumDuration, the dialog will not appear at all. This prevents
- the dialog popping up for tasks that are quickly over. For tasks
- that are expected to exceed the minimumDuration, the dialog will
- pop up after the minimumDuration time or as soon as any progress
- is set.
-
- If set to 0, the dialog is always shown as soon as any progress is
- set. The default is 4000 milliseconds.
-*/
-void QProgressDialog::setMinimumDuration(int ms)
-{
- Q_D(QProgressDialog);
- d->showTime = ms;
- if (d->bar->value() == 0) {
- d->forceTimer->stop();
- d->forceTimer->start(ms);
- }
-}
-
-int QProgressDialog::minimumDuration() const
-{
- Q_D(const QProgressDialog);
- return d->showTime;
-}
-
-
-/*!
- \reimp
-*/
-
-void QProgressDialog::closeEvent(QCloseEvent *e)
-{
- emit canceled();
- QDialog::closeEvent(e);
-}
-
-/*!
- \property QProgressDialog::autoReset
- \brief whether the progress dialog calls reset() as soon as value() equals maximum()
-
- The default is true.
-
- \sa setAutoClose()
-*/
-
-void QProgressDialog::setAutoReset(bool b)
-{
- Q_D(QProgressDialog);
- d->autoReset = b;
-}
-
-bool QProgressDialog::autoReset() const
-{
- Q_D(const QProgressDialog);
- return d->autoReset;
-}
-
-/*!
- \property QProgressDialog::autoClose
- \brief whether the dialog gets hidden by reset()
-
- The default is true.
-
- \sa setAutoReset()
-*/
-
-void QProgressDialog::setAutoClose(bool close)
-{
- Q_D(QProgressDialog);
- d->autoClose = close;
-}
-
-bool QProgressDialog::autoClose() const
-{
- Q_D(const QProgressDialog);
- return d->autoClose;
-}
-
-/*!
- \reimp
-*/
-
-void QProgressDialog::showEvent(QShowEvent *e)
-{
- Q_D(QProgressDialog);
- QDialog::showEvent(e);
- int w = qMax(isVisible() ? width() : 0, sizeHint().width());
- int h = qMax(isVisible() ? height() : 0, sizeHint().height());
- resize(w, h);
- d->forceTimer->stop();
-}
-
-/*!
- Shows the dialog if it is still hidden after the algorithm has been started
- and minimumDuration milliseconds have passed.
-
- \sa setMinimumDuration()
-*/
-
-void QProgressDialog::forceShow()
-{
- Q_D(QProgressDialog);
- d->forceTimer->stop();
- if (d->shown_once || d->cancellation_flag)
- return;
-
- show();
- d->shown_once = true;
-}
-
-/*!
- \since 4.5
- \overload
-
- Opens the dialog and connects its accepted() signal to the slot specified
- by \a receiver and \a member.
-
- The signal will be disconnected from the slot when the dialog is closed.
-*/
-void QProgressDialog::open(QObject *receiver, const char *member)
-{
- Q_D(QProgressDialog);
- connect(this, SIGNAL(canceled()), receiver, member);
- d->receiverToDisconnectOnClose = receiver;
- d->memberToDisconnectOnClose = member;
- QDialog::open();
-}
-
-QT_END_NAMESPACE
-
-#include "moc_qprogressdialog.cpp"
-
-#endif // QT_NO_PROGRESSDIALOG
diff --git a/src/gui/dialogs/qprogressdialog.h b/src/gui/dialogs/qprogressdialog.h
deleted file mode 100644
index 21a40c152f..0000000000
--- a/src/gui/dialogs/qprogressdialog.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPROGRESSDIALOG_H
-#define QPROGRESSDIALOG_H
-
-#include <QtGui/qdialog.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_PROGRESSDIALOG
-
-class QPushButton;
-class QLabel;
-class QProgressBar;
-class QTimer;
-class QProgressDialogPrivate;
-
-class Q_GUI_EXPORT QProgressDialog : public QDialog
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QProgressDialog)
- Q_PROPERTY(bool wasCanceled READ wasCanceled)
- Q_PROPERTY(int minimum READ minimum WRITE setMinimum)
- Q_PROPERTY(int maximum READ maximum WRITE setMaximum)
- Q_PROPERTY(int value READ value WRITE setValue)
- Q_PROPERTY(bool autoReset READ autoReset WRITE setAutoReset)
- Q_PROPERTY(bool autoClose READ autoClose WRITE setAutoClose)
- Q_PROPERTY(int minimumDuration READ minimumDuration WRITE setMinimumDuration)
- Q_PROPERTY(QString labelText READ labelText WRITE setLabelText)
-
-public:
- explicit QProgressDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0);
- QProgressDialog(const QString &labelText, const QString &cancelButtonText,
- int minimum, int maximum, QWidget *parent = 0, Qt::WindowFlags flags = 0);
- ~QProgressDialog();
-
- void setLabel(QLabel *label);
- void setCancelButton(QPushButton *button);
- void setBar(QProgressBar *bar);
-
- bool wasCanceled() const;
-
- int minimum() const;
- int maximum() const;
-
- int value() const;
-
- QSize sizeHint() const;
-
- QString labelText() const;
- int minimumDuration() const;
-
- void setAutoReset(bool reset);
- bool autoReset() const;
- void setAutoClose(bool close);
- bool autoClose() const;
-
-#ifdef Q_NO_USING_KEYWORD
-#ifndef Q_QDOC
- void open() { QDialog::open(); }
-#endif
-#else
- using QDialog::open;
-#endif
- void open(QObject *receiver, const char *member);
-
-public Q_SLOTS:
- void cancel();
- void reset();
- void setMaximum(int maximum);
- void setMinimum(int minimum);
- void setRange(int minimum, int maximum);
- void setValue(int progress);
- void setLabelText(const QString &text);
- void setCancelButtonText(const QString &text);
- void setMinimumDuration(int ms);
-
-Q_SIGNALS:
- void canceled();
-
-protected:
- void resizeEvent(QResizeEvent *event);
- void closeEvent(QCloseEvent *event);
- void changeEvent(QEvent *event);
- void showEvent(QShowEvent *event);
-
-protected Q_SLOTS:
- void forceShow();
-
-private:
- Q_DISABLE_COPY(QProgressDialog)
-
- Q_PRIVATE_SLOT(d_func(), void _q_disconnectOnClose())
-};
-
-#endif // QT_NO_PROGRESSDIALOG
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QPROGRESSDIALOG_H
diff --git a/src/gui/dialogs/qwizard.h b/src/gui/dialogs/qwizard.h
deleted file mode 100644
index 148a5924b9..0000000000
--- a/src/gui/dialogs/qwizard.h
+++ /dev/null
@@ -1,268 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWIZARD_H
-#define QWIZARD_H
-
-#include <QtGui/qdialog.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_WIZARD
-
-class QAbstractButton;
-class QWizardPage;
-class QWizardPrivate;
-
-class Q_GUI_EXPORT QWizard : public QDialog
-{
- Q_OBJECT
- Q_ENUMS(WizardStyle WizardOption)
- Q_FLAGS(WizardOptions)
- Q_PROPERTY(WizardStyle wizardStyle READ wizardStyle WRITE setWizardStyle)
- Q_PROPERTY(WizardOptions options READ options WRITE setOptions)
- Q_PROPERTY(Qt::TextFormat titleFormat READ titleFormat WRITE setTitleFormat)
- Q_PROPERTY(Qt::TextFormat subTitleFormat READ subTitleFormat WRITE setSubTitleFormat)
- Q_PROPERTY(int startId READ startId WRITE setStartId)
- Q_PROPERTY(int currentId READ currentId NOTIFY currentIdChanged)
-
-public:
- enum WizardButton {
- BackButton,
- NextButton,
- CommitButton,
- FinishButton,
- CancelButton,
- HelpButton,
- CustomButton1,
- CustomButton2,
- CustomButton3,
- Stretch,
-
- NoButton = -1,
- NStandardButtons = 6,
- NButtons = 9
- };
-
- enum WizardPixmap {
- WatermarkPixmap,
- LogoPixmap,
- BannerPixmap,
- BackgroundPixmap,
- NPixmaps
- };
-
- enum WizardStyle {
- ClassicStyle,
- ModernStyle,
- MacStyle,
- AeroStyle,
- NStyles
- };
-
- enum WizardOption {
- IndependentPages = 0x00000001,
- IgnoreSubTitles = 0x00000002,
- ExtendedWatermarkPixmap = 0x00000004,
- NoDefaultButton = 0x00000008,
- NoBackButtonOnStartPage = 0x00000010,
- NoBackButtonOnLastPage = 0x00000020,
- DisabledBackButtonOnLastPage = 0x00000040,
- HaveNextButtonOnLastPage = 0x00000080,
- HaveFinishButtonOnEarlyPages = 0x00000100,
- NoCancelButton = 0x00000200,
- CancelButtonOnLeft = 0x00000400,
- HaveHelpButton = 0x00000800,
- HelpButtonOnRight = 0x00001000,
- HaveCustomButton1 = 0x00002000,
- HaveCustomButton2 = 0x00004000,
- HaveCustomButton3 = 0x00008000
- };
-
- Q_DECLARE_FLAGS(WizardOptions, WizardOption)
-
- explicit QWizard(QWidget *parent = 0, Qt::WindowFlags flags = 0);
- ~QWizard();
-
- int addPage(QWizardPage *page);
- void setPage(int id, QWizardPage *page);
- void removePage(int id);
- QWizardPage *page(int id) const;
- bool hasVisitedPage(int id) const;
- QList<int> visitedPages() const; // ### visitedIds()?
- QList<int> pageIds() const;
- void setStartId(int id);
- int startId() const;
- QWizardPage *currentPage() const;
- int currentId() const;
-
- virtual bool validateCurrentPage();
- virtual int nextId() const;
-
- void setField(const QString &name, const QVariant &value);
- QVariant field(const QString &name) const;
-
- void setWizardStyle(WizardStyle style);
- WizardStyle wizardStyle() const;
-
- void setOption(WizardOption option, bool on = true);
- bool testOption(WizardOption option) const;
- void setOptions(WizardOptions options);
- WizardOptions options() const;
-
- void setButtonText(WizardButton which, const QString &text);
- QString buttonText(WizardButton which) const;
- void setButtonLayout(const QList<WizardButton> &layout);
- void setButton(WizardButton which, QAbstractButton *button);
- QAbstractButton *button(WizardButton which) const;
-
- void setTitleFormat(Qt::TextFormat format);
- Qt::TextFormat titleFormat() const;
- void setSubTitleFormat(Qt::TextFormat format);
- Qt::TextFormat subTitleFormat() const;
- void setPixmap(WizardPixmap which, const QPixmap &pixmap);
- QPixmap pixmap(WizardPixmap which) const;
-
- void setSideWidget(QWidget *widget);
- QWidget *sideWidget() const;
-
- void setDefaultProperty(const char *className, const char *property,
- const char *changedSignal);
-
- void setVisible(bool visible);
- QSize sizeHint() const;
-
-Q_SIGNALS:
- void currentIdChanged(int id);
- void helpRequested();
- void customButtonClicked(int which);
- void pageAdded(int id);
- void pageRemoved(int id);
-
-public Q_SLOTS:
- void back();
- void next();
- void restart();
-
-protected:
- bool event(QEvent *event);
- void resizeEvent(QResizeEvent *event);
- void paintEvent(QPaintEvent *event);
-#if defined(Q_WS_WIN)
- bool winEvent(MSG * message, long * result);
-#endif
- void done(int result);
- virtual void initializePage(int id);
- virtual void cleanupPage(int id);
-
-private:
- Q_DISABLE_COPY(QWizard)
- Q_DECLARE_PRIVATE(QWizard)
- Q_PRIVATE_SLOT(d_func(), void _q_emitCustomButtonClicked())
- Q_PRIVATE_SLOT(d_func(), void _q_updateButtonStates())
- Q_PRIVATE_SLOT(d_func(), void _q_handleFieldObjectDestroyed(QObject *))
-
- friend class QWizardPage;
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QWizard::WizardOptions)
-
-class QWizardPagePrivate;
-
-class Q_GUI_EXPORT QWizardPage : public QWidget
-{
- Q_OBJECT
- Q_PROPERTY(QString title READ title WRITE setTitle)
- Q_PROPERTY(QString subTitle READ subTitle WRITE setSubTitle)
-
-public:
- QWizardPage(QWidget *parent = 0);
-
- void setTitle(const QString &title);
- QString title() const;
- void setSubTitle(const QString &subTitle);
- QString subTitle() const;
- void setPixmap(QWizard::WizardPixmap which, const QPixmap &pixmap);
- QPixmap pixmap(QWizard::WizardPixmap which) const;
- void setFinalPage(bool finalPage);
- bool isFinalPage() const;
- void setCommitPage(bool commitPage);
- bool isCommitPage() const;
- void setButtonText(QWizard::WizardButton which, const QString &text);
- QString buttonText(QWizard::WizardButton which) const;
-
- virtual void initializePage();
- virtual void cleanupPage();
- virtual bool validatePage();
- virtual bool isComplete() const;
- virtual int nextId() const;
-
-Q_SIGNALS:
- void completeChanged();
-
-protected:
- void setField(const QString &name, const QVariant &value);
- QVariant field(const QString &name) const;
- void registerField(const QString &name, QWidget *widget, const char *property = 0,
- const char *changedSignal = 0);
- QWizard *wizard() const;
-
-private:
- Q_DISABLE_COPY(QWizardPage)
- Q_DECLARE_PRIVATE(QWizardPage)
- Q_PRIVATE_SLOT(d_func(), void _q_maybeEmitCompleteChanged())
- Q_PRIVATE_SLOT(d_func(), void _q_updateCachedCompleteState())
-
- friend class QWizard;
- friend class QWizardPrivate;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_WIZARD
-
-#endif // QWIZARD_H
diff --git a/src/gui/dialogs/qwizard_win.cpp b/src/gui/dialogs/qwizard_win.cpp
deleted file mode 100644
index 3480c6853c..0000000000
--- a/src/gui/dialogs/qwizard_win.cpp
+++ /dev/null
@@ -1,759 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QT_NO_WIZARD
-#ifndef QT_NO_STYLE_WINDOWSVISTA
-
-#include "qwizard_win_p.h"
-#include <private/qsystemlibrary_p.h>
-#include "qwizard.h"
-#include "qpaintengine.h"
-#include "qapplication.h"
-#include <QtGui/QMouseEvent>
-#include <QtGui/QDesktopWidget>
-
-// Note, these tests are duplicates in qwindowsxpstyle_p.h.
-#ifdef Q_CC_GNU
-# include <w32api.h>
-# if (__W32API_MAJOR_VERSION >= 3 || (__W32API_MAJOR_VERSION == 2 && __W32API_MINOR_VERSION >= 5))
-# ifdef _WIN32_WINNT
-# undef _WIN32_WINNT
-# endif
-# define _WIN32_WINNT 0x0501
-# include <commctrl.h>
-# endif
-#endif
-
-#include <uxtheme.h>
-
-QT_BEGIN_NAMESPACE
-
-//DWM related
-typedef struct { //MARGINS
- int cxLeftWidth; // width of left border that retains its size
- int cxRightWidth; // width of right border that retains its size
- int cyTopHeight; // height of top border that retains its size
- int cyBottomHeight; // height of bottom border that retains its size
-} WIZ_MARGINS;
-typedef struct { //DTTOPTS
- DWORD dwSize;
- DWORD dwFlags;
- COLORREF crText;
- COLORREF crBorder;
- COLORREF crShadow;
- int eTextShadowType;
- POINT ptShadowOffset;
- int iBorderSize;
- int iFontPropId;
- int iColorPropId;
- int iStateId;
- BOOL fApplyOverlay;
- int iGlowSize;
-} WIZ_DTTOPTS;
-
-typedef struct {
- DWORD dwFlags;
- DWORD dwMask;
-} WIZ_WTA_OPTIONS;
-
-#define WIZ_WM_THEMECHANGED 0x031A
-#define WIZ_WM_DWMCOMPOSITIONCHANGED 0x031E
-
-enum WIZ_WINDOWTHEMEATTRIBUTETYPE {
- WIZ_WTA_NONCLIENT = 1
-};
-
-#define WIZ_WTNCA_NODRAWCAPTION 0x00000001
-#define WIZ_WTNCA_NODRAWICON 0x00000002
-
-#define WIZ_DT_CENTER 0x00000001 //DT_CENTER
-#define WIZ_DT_VCENTER 0x00000004
-#define WIZ_DT_SINGLELINE 0x00000020
-#define WIZ_DT_NOPREFIX 0x00000800
-
-enum WIZ_NAVIGATIONPARTS { //NAVIGATIONPARTS
- WIZ_NAV_BACKBUTTON = 1,
- WIZ_NAV_FORWARDBUTTON = 2,
- WIZ_NAV_MENUBUTTON = 3,
-};
-
-enum WIZ_NAV_BACKBUTTONSTATES { //NAV_BACKBUTTONSTATES
- WIZ_NAV_BB_NORMAL = 1,
- WIZ_NAV_BB_HOT = 2,
- WIZ_NAV_BB_PRESSED = 3,
- WIZ_NAV_BB_DISABLED = 4,
-};
-
-#define WIZ_TMT_CAPTIONFONT (801) //TMT_CAPTIONFONT
-#define WIZ_DTT_COMPOSITED (1UL << 13) //DTT_COMPOSITED
-#define WIZ_DTT_GLOWSIZE (1UL << 11) //DTT_GLOWSIZE
-
-#define WIZ_WM_NCMOUSELEAVE 674 //WM_NCMOUSELEAVE
-
-#define WIZ_WP_CAPTION 1 //WP_CAPTION
-#define WIZ_CS_ACTIVE 1 //CS_ACTIVE
-#define WIZ_TMT_FILLCOLORHINT 3821 //TMT_FILLCOLORHINT
-#define WIZ_TMT_BORDERCOLORHINT 3822 //TMT_BORDERCOLORHINT
-
-typedef BOOL (WINAPI *PtrDwmDefWindowProc)(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *plResult);
-typedef HRESULT (WINAPI *PtrDwmIsCompositionEnabled)(BOOL* pfEnabled);
-typedef HRESULT (WINAPI *PtrDwmExtendFrameIntoClientArea)(HWND hWnd, const WIZ_MARGINS* pMarInset);
-typedef HRESULT (WINAPI *PtrSetWindowThemeAttribute)(HWND hwnd, enum WIZ_WINDOWTHEMEATTRIBUTETYPE eAttribute, PVOID pvAttribute, DWORD cbAttribute);
-
-static PtrDwmDefWindowProc pDwmDefWindowProc = 0;
-static PtrDwmIsCompositionEnabled pDwmIsCompositionEnabled = 0;
-static PtrDwmExtendFrameIntoClientArea pDwmExtendFrameIntoClientArea = 0;
-static PtrSetWindowThemeAttribute pSetWindowThemeAttribute = 0;
-
-//Theme related
-typedef bool (WINAPI *PtrIsAppThemed)();
-typedef bool (WINAPI *PtrIsThemeActive)();
-typedef HANDLE (WINAPI *PtrOpenThemeData)(HWND hwnd, LPCWSTR pszClassList);
-typedef HRESULT (WINAPI *PtrCloseThemeData)(HANDLE hTheme);
-typedef HRESULT (WINAPI *PtrGetThemeSysFont)(HANDLE hTheme, int iFontId, LOGFONTW *plf);
-typedef HRESULT (WINAPI *PtrDrawThemeTextEx)(HANDLE hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int cchText, DWORD dwTextFlags, LPRECT pRect, const WIZ_DTTOPTS *pOptions);
-typedef HRESULT (WINAPI *PtrDrawThemeBackground)(HANDLE hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, OPTIONAL const RECT *pClipRect);
-typedef HRESULT (WINAPI *PtrGetThemePartSize)(HANDLE hTheme, HDC hdc, int iPartId, int iStateId, OPTIONAL RECT *prc, enum THEMESIZE eSize, OUT SIZE *psz);
-typedef HRESULT (WINAPI *PtrGetThemeColor)(HANDLE hTheme, int iPartId, int iStateId, int iPropId, OUT COLORREF *pColor);
-
-static PtrIsAppThemed pIsAppThemed = 0;
-static PtrIsThemeActive pIsThemeActive = 0;
-static PtrOpenThemeData pOpenThemeData = 0;
-static PtrCloseThemeData pCloseThemeData = 0;
-static PtrGetThemeSysFont pGetThemeSysFont = 0;
-static PtrDrawThemeTextEx pDrawThemeTextEx = 0;
-static PtrDrawThemeBackground pDrawThemeBackground = 0;
-static PtrGetThemePartSize pGetThemePartSize = 0;
-static PtrGetThemeColor pGetThemeColor = 0;
-
-bool QVistaHelper::is_vista = false;
-QVistaHelper::VistaState QVistaHelper::cachedVistaState = QVistaHelper::Dirty;
-
-/******************************************************************************
-** QVistaBackButton
-*/
-
-QVistaBackButton::QVistaBackButton(QWidget *widget)
- : QAbstractButton(widget)
-{
- setFocusPolicy(Qt::NoFocus);
-}
-
-QSize QVistaBackButton::sizeHint() const
-{
- ensurePolished();
- int size = int(QStyleHelper::dpiScaled(32));
- int width = size, height = size;
-/*
- HANDLE theme = pOpenThemeData(0, L"Navigation");
- SIZE size;
- if (pGetThemePartSize(theme, 0, WIZ_NAV_BACKBUTTON, WIZ_NAV_BB_NORMAL, 0, TS_TRUE, &size) == S_OK) {
- width = size.cx;
- height = size.cy;
- }
-*/
- return QSize(width, height);
-}
-
-void QVistaBackButton::enterEvent(QEvent *event)
-{
- if (isEnabled())
- update();
- QAbstractButton::enterEvent(event);
-}
-
-void QVistaBackButton::leaveEvent(QEvent *event)
-{
- if (isEnabled())
- update();
- QAbstractButton::leaveEvent(event);
-}
-
-void QVistaBackButton::paintEvent(QPaintEvent *)
-{
- QPainter p(this);
- QRect r = rect();
- HANDLE theme = pOpenThemeData(0, L"Navigation");
- //RECT rect;
- RECT clipRect;
- int xoffset = QWidget::mapToParent(r.topLeft()).x() - 1;
- int yoffset = QWidget::mapToParent(r.topLeft()).y() - 1;
-
- clipRect.top = r.top() + yoffset;
- clipRect.bottom = r.bottom() + yoffset;
- clipRect.left = r.left() + xoffset;
- clipRect.right = r.right() + xoffset;
-
- int state = WIZ_NAV_BB_NORMAL;
- if (!isEnabled())
- state = WIZ_NAV_BB_DISABLED;
- else if (isDown())
- state = WIZ_NAV_BB_PRESSED;
- else if (underMouse())
- state = WIZ_NAV_BB_HOT;
-
- pDrawThemeBackground(theme, p.paintEngine()->getDC(), WIZ_NAV_BACKBUTTON, state, &clipRect, &clipRect);
-}
-
-/******************************************************************************
-** QVistaHelper
-*/
-
-QVistaHelper::QVistaHelper(QWizard *wizard)
- : QObject(wizard)
- , pressed(false)
- , wizard(wizard)
- , backButton_(0)
-{
- is_vista = resolveSymbols();
- if (is_vista)
- backButton_ = new QVistaBackButton(wizard);
-
- // Handle diff between Windows 7 and Vista
- iconSpacing = QStyleHelper::dpiScaled(7);
- textSpacing = QSysInfo::WindowsVersion >= QSysInfo::WV_WINDOWS7 ?
- iconSpacing : QStyleHelper::dpiScaled(20);
-}
-
-QVistaHelper::~QVistaHelper()
-{
-}
-
-bool QVistaHelper::isCompositionEnabled()
-{
- bool value = is_vista;
- if (is_vista) {
- HRESULT hr;
- BOOL bEnabled;
-
- hr = pDwmIsCompositionEnabled(&bEnabled);
- value = (SUCCEEDED(hr) && bEnabled);
- }
- return value;
-}
-
-bool QVistaHelper::isThemeActive()
-{
- return is_vista && pIsThemeActive();
-}
-
-QVistaHelper::VistaState QVistaHelper::vistaState()
-{
- if (cachedVistaState == Dirty)
- cachedVistaState =
- isCompositionEnabled() ? VistaAero : isThemeActive() ? VistaBasic : Classic;
- return cachedVistaState;
-}
-
-QColor QVistaHelper::basicWindowFrameColor()
-{
- DWORD rgb;
- HANDLE hTheme = pOpenThemeData(QApplication::desktop()->winId(), L"WINDOW");
- pGetThemeColor(
- hTheme, WIZ_WP_CAPTION, WIZ_CS_ACTIVE,
- wizard->isActiveWindow() ? WIZ_TMT_FILLCOLORHINT : WIZ_TMT_BORDERCOLORHINT,
- &rgb);
- BYTE r = GetRValue(rgb);
- BYTE g = GetGValue(rgb);
- BYTE b = GetBValue(rgb);
- return QColor(r, g, b);
-}
-
-bool QVistaHelper::setDWMTitleBar(TitleBarChangeType type)
-{
- bool value = false;
- if (vistaState() == VistaAero) {
- WIZ_MARGINS mar = {0};
- if (type == NormalTitleBar)
- mar.cyTopHeight = 0;
- else
- mar.cyTopHeight = titleBarSize() + topOffset();
- HRESULT hr = pDwmExtendFrameIntoClientArea(wizard->winId(), &mar);
- value = SUCCEEDED(hr);
- }
- return value;
-}
-
-void QVistaHelper::drawTitleBar(QPainter *painter)
-{
- HDC hdc = painter->paintEngine()->getDC();
-
- if (vistaState() == VistaAero)
- drawBlackRect(QRect(0, 0, wizard->width(),
- titleBarSize() + topOffset()), hdc);
- Q_ASSERT(backButton_);
- const int btnTop = backButton_->mapToParent(QPoint()).y();
- const int btnHeight = backButton_->size().height();
- const int verticalCenter = (btnTop + btnHeight / 2) - 1;
-
- const QString text = wizard->window()->windowTitle();
- const QFont font = QApplication::font("QWorkspaceTitleBar");
- const QFontMetrics fontMetrics(font);
- const QRect brect = fontMetrics.boundingRect(text);
- int textHeight = brect.height();
- int textWidth = brect.width();
- int glowOffset = 0;
-
- if (vistaState() == VistaAero) {
- textHeight += 2 * glowSize();
- textWidth += 2 * glowSize();
- glowOffset = glowSize();
- }
-
- drawTitleText(
- painter, text,
- QRect(titleOffset() - glowOffset, verticalCenter - textHeight / 2, textWidth, textHeight),
- hdc);
-
- if (!wizard->windowIcon().isNull()) {
- QRect rect(leftMargin(), verticalCenter - iconSize() / 2, iconSize(), iconSize());
- HICON hIcon = wizard->windowIcon().pixmap(iconSize()).toWinHICON();
- DrawIconEx(hdc, rect.left(), rect.top(), hIcon, 0, 0, 0, NULL, DI_NORMAL | DI_COMPAT);
- DestroyIcon(hIcon);
- }
-}
-
-void QVistaHelper::setTitleBarIconAndCaptionVisible(bool visible)
-{
- if (is_vista) {
- WIZ_WTA_OPTIONS opt;
- opt.dwFlags = WIZ_WTNCA_NODRAWICON | WIZ_WTNCA_NODRAWCAPTION;
- if (visible)
- opt.dwMask = 0;
- else
- opt.dwMask = WIZ_WTNCA_NODRAWICON | WIZ_WTNCA_NODRAWCAPTION;
- pSetWindowThemeAttribute(wizard->winId(), WIZ_WTA_NONCLIENT, &opt, sizeof(WIZ_WTA_OPTIONS));
- }
-}
-
-bool QVistaHelper::winEvent(MSG* msg, long* result)
-{
- bool retval = true;
-
- switch (msg->message) {
- case WM_NCHITTEST: {
- LRESULT lResult;
- pDwmDefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam, &lResult);
- if (lResult == HTCLOSE || lResult == HTMAXBUTTON || lResult == HTMINBUTTON || lResult == HTHELP)
- *result = lResult;
- else
- *result = DefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam);
- break;
- }
- case WM_NCMOUSEMOVE:
- case WM_NCLBUTTONDOWN:
- case WM_NCLBUTTONUP:
- case WIZ_WM_NCMOUSELEAVE: {
- LRESULT lResult;
- pDwmDefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam, &lResult);
- *result = DefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam);
- break;
- }
- case WM_NCCALCSIZE: {
- NCCALCSIZE_PARAMS* lpncsp = (NCCALCSIZE_PARAMS*)msg->lParam;
- *result = DefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam);
- lpncsp->rgrc[0].top -= (vistaState() == VistaAero ? titleBarSize() : 0);
- break;
- }
- default:
- retval = false;
- }
-
- return retval;
-}
-
-void QVistaHelper::setMouseCursor(QPoint pos)
-{
-#ifndef QT_NO_CURSOR
- if (rtTop.contains(pos))
- wizard->setCursor(Qt::SizeVerCursor);
- else
- wizard->setCursor(Qt::ArrowCursor);
-#endif
-}
-
-void QVistaHelper::mouseEvent(QEvent *event)
-{
- switch (event->type()) {
- case QEvent::MouseMove:
- mouseMoveEvent(static_cast<QMouseEvent *>(event));
- break;
- case QEvent::MouseButtonPress:
- mousePressEvent(static_cast<QMouseEvent *>(event));
- break;
- case QEvent::MouseButtonRelease:
- mouseReleaseEvent(static_cast<QMouseEvent *>(event));
- break;
- default:
- break;
- }
-}
-
-// The following hack ensures that the titlebar is updated correctly
-// when the wizard style changes to and from AeroStyle. Specifically,
-// this function causes a Windows message of type WM_NCCALCSIZE to
-// be triggered.
-void QVistaHelper::setWindowPosHack()
-{
- const int x = wizard->geometry().x(); // ignored by SWP_NOMOVE
- const int y = wizard->geometry().y(); // ignored by SWP_NOMOVE
- const int w = wizard->width();
- const int h = wizard->height();
- SetWindowPos(wizard->winId(), 0, x, y, w, h, SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED);
-}
-
-// The following hack allows any QWidget subclass to access
-// QWidgetPrivate::topData() without being declared as a
-// friend by QWidget.
-class QHackWidget : public QWidget
-{
-public:
- Q_DECLARE_PRIVATE(QWidget)
- QTLWExtra* topData() { return d_func()->topData(); }
-};
-
-void QVistaHelper::collapseTopFrameStrut()
-{
- QTLWExtra *top = ((QHackWidget *)wizard)->d_func()->topData();
- int x1, y1, x2, y2;
- top->frameStrut.getCoords(&x1, &y1, &x2, &y2);
- top->frameStrut.setCoords(x1, 0, x2, y2);
-}
-
-bool QVistaHelper::handleWinEvent(MSG *message, long *result)
-{
- if (message->message == WIZ_WM_THEMECHANGED || message->message == WIZ_WM_DWMCOMPOSITIONCHANGED)
- cachedVistaState = Dirty;
-
- bool status = false;
- if (wizard->wizardStyle() == QWizard::AeroStyle && vistaState() == VistaAero) {
- status = winEvent(message, result);
- if (message->message == WM_NCCALCSIZE) {
- if (status)
- collapseTopFrameStrut();
- } else if (message->message == WM_NCPAINT) {
- wizard->update();
- }
- }
- return status;
-}
-
-void QVistaHelper::resizeEvent(QResizeEvent * event)
-{
- Q_UNUSED(event);
- rtTop = QRect (0, 0, wizard->width(), frameSize());
- int height = captionSize() + topOffset();
- if (vistaState() == VistaBasic)
- height -= titleBarSize();
- rtTitle = QRect (0, frameSize(), wizard->width(), height);
-}
-
-void QVistaHelper::paintEvent(QPaintEvent *event)
-{
- Q_UNUSED(event);
- QPainter painter(wizard);
- drawTitleBar(&painter);
-}
-
-void QVistaHelper::mouseMoveEvent(QMouseEvent *event)
-{
- if (wizard->windowState() & Qt::WindowMaximized) {
- event->ignore();
- return;
- }
-
- QRect rect = wizard->geometry();
- if (pressed) {
- switch (change) {
- case resizeTop:
- {
- const int dy = event->pos().y() - pressedPos.y();
- if ((dy > 0 && rect.height() > wizard->minimumHeight())
- || (dy < 0 && rect.height() < wizard->maximumHeight()))
- rect.setTop(rect.top() + dy);
- }
- break;
- case movePosition: {
- QPoint newPos = event->pos() - pressedPos;
- rect.moveLeft(rect.left() + newPos.x());
- rect.moveTop(rect.top() + newPos.y());
- break; }
- default:
- break;
- }
- wizard->setGeometry(rect);
-
- } else if (vistaState() == VistaAero) {
- setMouseCursor(event->pos());
- }
- event->ignore();
-}
-
-void QVistaHelper::mousePressEvent(QMouseEvent *event)
-{
- change = noChange;
-
- if (wizard->windowState() & Qt::WindowMaximized) {
- event->ignore();
- return;
- }
-
- if (rtTitle.contains(event->pos())) {
- change = movePosition;
- } else if (rtTop.contains(event->pos()))
- change = (vistaState() == VistaAero) ? resizeTop : movePosition;
-
- if (change != noChange) {
- if (vistaState() == VistaAero)
- setMouseCursor(event->pos());
- pressed = true;
- pressedPos = event->pos();
- } else {
- event->ignore();
- }
-}
-
-void QVistaHelper::mouseReleaseEvent(QMouseEvent *event)
-{
- change = noChange;
- if (pressed) {
- pressed = false;
- wizard->releaseMouse();
- if (vistaState() == VistaAero)
- setMouseCursor(event->pos());
- }
- event->ignore();
-}
-
-bool QVistaHelper::eventFilter(QObject *obj, QEvent *event)
-{
- if (obj != wizard)
- return QObject::eventFilter(obj, event);
-
- if (event->type() == QEvent::MouseMove) {
- QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
- long result;
- MSG msg;
- msg.message = WM_NCHITTEST;
- msg.wParam = 0;
- msg.lParam = MAKELPARAM(mouseEvent->globalX(), mouseEvent->globalY());
- msg.hwnd = wizard->winId();
- winEvent(&msg, &result);
- msg.wParam = result;
- msg.message = WM_NCMOUSEMOVE;
- winEvent(&msg, &result);
- } else if (event->type() == QEvent::MouseButtonPress) {
- QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
- long result;
- MSG msg;
- msg.message = WM_NCHITTEST;
- msg.wParam = 0;
- msg.lParam = MAKELPARAM(mouseEvent->globalX(), mouseEvent->globalY());
- msg.hwnd = wizard->winId();
- winEvent(&msg, &result);
- msg.wParam = result;
- msg.message = WM_NCLBUTTONDOWN;
- winEvent(&msg, &result);
- } else if (event->type() == QEvent::MouseButtonRelease) {
- QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
- long result;
- MSG msg;
- msg.message = WM_NCHITTEST;
- msg.wParam = 0;
- msg.lParam = MAKELPARAM(mouseEvent->globalX(), mouseEvent->globalY());
- msg.hwnd = wizard->winId();
- winEvent(&msg, &result);
- msg.wParam = result;
- msg.message = WM_NCLBUTTONUP;
- winEvent(&msg, &result);
- }
-
- return false;
-}
-
-HFONT QVistaHelper::getCaptionFont(HANDLE hTheme)
-{
- LOGFONT lf = {0};
-
- if (!hTheme)
- pGetThemeSysFont(hTheme, WIZ_TMT_CAPTIONFONT, &lf);
- else
- {
- NONCLIENTMETRICS ncm = {sizeof(NONCLIENTMETRICS)};
- SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, false);
- lf = ncm.lfMessageFont;
- }
- return CreateFontIndirect(&lf);
-}
-
-bool QVistaHelper::drawTitleText(QPainter *painter, const QString &text, const QRect &rect, HDC hdc)
-{
- bool value = false;
- if (vistaState() == VistaAero) {
- HANDLE hTheme = pOpenThemeData(QApplication::desktop()->winId(), L"WINDOW");
- if (!hTheme) return false;
- // Set up a memory DC and bitmap that we'll draw into
- HDC dcMem;
- HBITMAP bmp;
- BITMAPINFO dib = {{0}};
- dcMem = CreateCompatibleDC(hdc);
-
- dib.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- dib.bmiHeader.biWidth = rect.width();
- dib.bmiHeader.biHeight = -rect.height();
- dib.bmiHeader.biPlanes = 1;
- dib.bmiHeader.biBitCount = 32;
- dib.bmiHeader.biCompression = BI_RGB;
-
- bmp = CreateDIBSection(hdc, &dib, DIB_RGB_COLORS, NULL, NULL, 0);
-
- // Set up the DC
- HFONT hCaptionFont = getCaptionFont(hTheme);
- HBITMAP hOldBmp = (HBITMAP)SelectObject(dcMem, (HGDIOBJ) bmp);
- HFONT hOldFont = (HFONT)SelectObject(dcMem, (HGDIOBJ) hCaptionFont);
-
- // Draw the text!
- WIZ_DTTOPTS dto = { sizeof(WIZ_DTTOPTS) };
- const UINT uFormat = WIZ_DT_SINGLELINE|WIZ_DT_CENTER|WIZ_DT_VCENTER|WIZ_DT_NOPREFIX;
- RECT rctext ={0,0, rect.width(), rect.height()};
-
- dto.dwFlags = WIZ_DTT_COMPOSITED|WIZ_DTT_GLOWSIZE;
- dto.iGlowSize = glowSize();
-
- pDrawThemeTextEx(hTheme, dcMem, 0, 0, (LPCWSTR)text.utf16(), -1, uFormat, &rctext, &dto );
- BitBlt(hdc, rect.left(), rect.top(), rect.width(), rect.height(), dcMem, 0, 0, SRCCOPY);
- SelectObject(dcMem, (HGDIOBJ) hOldBmp);
- SelectObject(dcMem, (HGDIOBJ) hOldFont);
- DeleteObject(bmp);
- DeleteObject(hCaptionFont);
- DeleteDC(dcMem);
- //ReleaseDC(hwnd, hdc);
- } else if (vistaState() == VistaBasic) {
- painter->drawText(rect, text);
- }
- return value;
-}
-
-bool QVistaHelper::drawBlackRect(const QRect &rect, HDC hdc)
-{
- bool value = false;
- if (vistaState() == VistaAero) {
- // Set up a memory DC and bitmap that we'll draw into
- HDC dcMem;
- HBITMAP bmp;
- BITMAPINFO dib = {{0}};
- dcMem = CreateCompatibleDC(hdc);
-
- dib.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
- dib.bmiHeader.biWidth = rect.width();
- dib.bmiHeader.biHeight = -rect.height();
- dib.bmiHeader.biPlanes = 1;
- dib.bmiHeader.biBitCount = 32;
- dib.bmiHeader.biCompression = BI_RGB;
-
- bmp = CreateDIBSection(hdc, &dib, DIB_RGB_COLORS, NULL, NULL, 0);
- HBITMAP hOldBmp = (HBITMAP)SelectObject(dcMem, (HGDIOBJ) bmp);
-
- BitBlt(hdc, rect.left(), rect.top(), rect.width(), rect.height(), dcMem, 0, 0, SRCCOPY);
- SelectObject(dcMem, (HGDIOBJ) hOldBmp);
-
- DeleteObject(bmp);
- DeleteDC(dcMem);
- }
- return value;
-}
-
-bool QVistaHelper::resolveSymbols()
-{
- static bool tried = false;
- if (!tried) {
- tried = true;
- QSystemLibrary dwmLib(L"dwmapi");
- pDwmIsCompositionEnabled =
- (PtrDwmIsCompositionEnabled)dwmLib.resolve("DwmIsCompositionEnabled");
- if (pDwmIsCompositionEnabled) {
- pDwmDefWindowProc = (PtrDwmDefWindowProc)dwmLib.resolve("DwmDefWindowProc");
- pDwmExtendFrameIntoClientArea =
- (PtrDwmExtendFrameIntoClientArea)dwmLib.resolve("DwmExtendFrameIntoClientArea");
- }
- QSystemLibrary themeLib(L"uxtheme");
- pIsAppThemed = (PtrIsAppThemed)themeLib.resolve("IsAppThemed");
- if (pIsAppThemed) {
- pDrawThemeBackground = (PtrDrawThemeBackground)themeLib.resolve("DrawThemeBackground");
- pGetThemePartSize = (PtrGetThemePartSize)themeLib.resolve("GetThemePartSize");
- pGetThemeColor = (PtrGetThemeColor)themeLib.resolve("GetThemeColor");
- pIsThemeActive = (PtrIsThemeActive)themeLib.resolve("IsThemeActive");
- pOpenThemeData = (PtrOpenThemeData)themeLib.resolve("OpenThemeData");
- pCloseThemeData = (PtrCloseThemeData)themeLib.resolve("CloseThemeData");
- pGetThemeSysFont = (PtrGetThemeSysFont)themeLib.resolve("GetThemeSysFont");
- pDrawThemeTextEx = (PtrDrawThemeTextEx)themeLib.resolve("DrawThemeTextEx");
- pSetWindowThemeAttribute = (PtrSetWindowThemeAttribute)themeLib.resolve("SetWindowThemeAttribute");
- }
- }
-
- return (
- pDwmIsCompositionEnabled != 0
- && pDwmDefWindowProc != 0
- && pDwmExtendFrameIntoClientArea != 0
- && pIsAppThemed != 0
- && pDrawThemeBackground != 0
- && pGetThemePartSize != 0
- && pGetThemeColor != 0
- && pIsThemeActive != 0
- && pOpenThemeData != 0
- && pCloseThemeData != 0
- && pGetThemeSysFont != 0
- && pDrawThemeTextEx != 0
- && pSetWindowThemeAttribute != 0
- );
-}
-
-int QVistaHelper::titleOffset()
-{
- int iconOffset = wizard ->windowIcon().isNull() ? 0 : iconSize() + textSpacing;
- return leftMargin() + iconOffset;
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_STYLE_WINDOWSVISTA
-
-#endif // QT_NO_WIZARD
diff --git a/src/gui/effects/effects.pri b/src/gui/effects/effects.pri
deleted file mode 100644
index 0ebf96fccb..0000000000
--- a/src/gui/effects/effects.pri
+++ /dev/null
@@ -1,4 +0,0 @@
-HEADERS += effects/qgraphicseffect.h \
- effects/qgraphicseffect_p.h
-
-SOURCES += effects/qgraphicseffect.cpp
diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp
deleted file mode 100644
index 7ba38f6d3a..0000000000
--- a/src/gui/effects/qgraphicseffect.cpp
+++ /dev/null
@@ -1,1235 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \class QGraphicsEffect
- \brief The QGraphicsEffect class is the base class for all graphics
- effects.
- \since 4.6
- \ingroup multimedia
- \ingroup graphicsview-api
-
- Effects alter the appearance of elements by hooking into the rendering
- pipeline and operating between the source (e.g., a QGraphicsPixmapItem)
- and the destination device (e.g., QGraphicsView's viewport). Effects can be
- disabled by calling setEnabled(false). If effects are disabled, the source
- is rendered directly.
-
- To add a visual effect to a QGraphicsItem, for example, you can use one of
- the standard effects, or alternately, create your own effect by creating a
- subclass of QGraphicsEffect. The effect can then be installed on the item
- using QGraphicsItem::setGraphicsEffect().
-
- Qt provides the following standard effects:
-
- \list
- \o QGraphicsBlurEffect - blurs the item by a given radius
- \o QGraphicsDropShadowEffect - renders a dropshadow behind the item
- \o QGraphicsColorizeEffect - renders the item in shades of any given color
- \o QGraphicsOpacityEffect - renders the item with an opacity
- \endlist
-
- \table
- \row
- \o{2,1} \img graphicseffect-plain.png
- \row
- \o \img graphicseffect-blur.png
- \o \img graphicseffect-colorize.png
- \row
- \o \img graphicseffect-opacity.png
- \o \img graphicseffect-drop-shadow.png
- \endtable
-
- \img graphicseffect-widget.png
-
- For more information on how to use each effect, refer to the specific
- effect's documentation.
-
- To create your own custom effect, create a subclass of QGraphicsEffect (or
- any other existing effects) and reimplement the virtual function draw().
- This function is called whenever the effect needs to redraw. The draw()
- function takes the painter with which to draw as an argument. For more
- information, refer to the documenation for draw(). In the draw() function
- you can call sourcePixmap() to get a pixmap of the graphics effect source
- which you can then process.
-
- If your effect changes, use update() to request for a redraw. If your
- custom effect changes the bounding rectangle of the source, e.g., a radial
- glow effect may need to apply an extra margin, you can reimplement the
- virtual boundingRectFor() function, and call updateBoundingRect()
- to notify the framework whenever this rectangle changes. The virtual
- sourceChanged() function is called to notify the effects that
- the source has changed in some way - e.g., if the source is a
- QGraphicsRectItem and its rectangle parameters have changed.
-
- \sa QGraphicsItem::setGraphicsEffect(), QWidget::setGraphicsEffect()
-*/
-
-#include "qgraphicseffect_p.h"
-#include "private/qgraphicsitem_p.h"
-
-#include <QtGui/qgraphicsitem.h>
-
-#include <QtGui/qimage.h>
-#include <QtGui/qpainter.h>
-#include <QtGui/qpaintengine.h>
-#include <QtCore/qrect.h>
-#include <QtCore/qdebug.h>
-#include <private/qdrawhelper_p.h>
-
-#ifndef QT_NO_GRAPHICSEFFECT
-QT_BEGIN_NAMESPACE
-
-/*!
- \internal
- \class QGraphicsEffectSource
- \brief The QGraphicsEffectSource class represents the source on which a
- QGraphicsEffect is installed on.
-
- When a QGraphicsEffect is installed on a QGraphicsItem, for example, this
- class will act as a wrapper around QGraphicsItem. Then, calling update() is
- effectively the same as calling QGraphicsItem::update().
-
- QGraphicsEffectSource also provides a pixmap() function which creates a
- pixmap with the source painted into it.
-
- \sa QGraphicsItem::setGraphicsEffect(), QWidget::setGraphicsEffect().
-*/
-
-/*!
- \internal
-*/
-QGraphicsEffectSource::QGraphicsEffectSource(QGraphicsEffectSourcePrivate &dd, QObject *parent)
- : QObject(dd, parent)
-{}
-
-/*!
- Destroys the effect source.
-*/
-QGraphicsEffectSource::~QGraphicsEffectSource()
-{}
-
-/*!
- Returns the bounding rectangle of the source mapped to the given \a system.
-
- \sa draw()
-*/
-QRectF QGraphicsEffectSource::boundingRect(Qt::CoordinateSystem system) const
-{
- return d_func()->boundingRect(system);
-}
-
-/*!
- Returns the bounding rectangle of the source mapped to the given \a system.
-
- Calling this function with Qt::DeviceCoordinates outside of
- QGraphicsEffect::draw() will give undefined results, as there is no device
- context available.
-
- \sa draw()
-*/
-QRectF QGraphicsEffect::sourceBoundingRect(Qt::CoordinateSystem system) const
-{
- Q_D(const QGraphicsEffect);
- if (d->source)
- return d->source->boundingRect(system);
- return QRectF();
-}
-
-/*!
- Returns a pointer to the item if this source is a QGraphicsItem; otherwise
- returns 0.
-
- \sa widget()
-*/
-const QGraphicsItem *QGraphicsEffectSource::graphicsItem() const
-{
- return d_func()->graphicsItem();
-}
-
-/*!
- Returns a pointer to the widget if this source is a QWidget; otherwise
- returns 0.
-
- \sa graphicsItem()
-*/
-const QWidget *QGraphicsEffectSource::widget() const
-{
- return d_func()->widget();
-}
-
-/*!
- Returns a pointer to the style options (used when drawing the source) if
- available; otherwise returns 0.
-
- \sa graphicsItem(), widget()
-*/
-const QStyleOption *QGraphicsEffectSource::styleOption() const
-{
- return d_func()->styleOption();
-}
-
-/*!
- Draws the source using the given \a painter.
-
- This function should only be called from QGraphicsEffect::draw().
-
- \sa QGraphicsEffect::draw()
-*/
-void QGraphicsEffectSource::draw(QPainter *painter)
-{
- Q_D(const QGraphicsEffectSource);
-
- QPixmap pm;
- if (QPixmapCache::find(d->m_cacheKey, &pm)) {
- QTransform restoreTransform;
- if (d->m_cachedSystem == Qt::DeviceCoordinates) {
- restoreTransform = painter->worldTransform();
- painter->setWorldTransform(QTransform());
- }
-
- painter->drawPixmap(d->m_cachedOffset, pm);
-
- if (d->m_cachedSystem == Qt::DeviceCoordinates)
- painter->setWorldTransform(restoreTransform);
- } else {
- d_func()->draw(painter);
- }
-}
-
-/*!
- Draws the source directly using the given \a painter.
-
- This function should only be called from QGraphicsEffect::draw().
-
- For example:
-
- \snippet doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp 0
-
- \sa QGraphicsEffect::draw()
-*/
-void QGraphicsEffect::drawSource(QPainter *painter)
-{
- Q_D(const QGraphicsEffect);
- if (d->source)
- d->source->draw(painter);
-}
-
-/*!
- Schedules a redraw of the source. Call this function whenever the source
- needs to be redrawn.
-
- \sa QGraphicsEffect::updateBoundingRect(), QWidget::update(),
- QGraphicsItem::update(),
-*/
-void QGraphicsEffectSource::update()
-{
- d_func()->update();
-}
-
-/*!
- Returns true if the source effectively is a pixmap, e.g., a
- QGraphicsPixmapItem.
-
- This function is useful for optimization purposes. For instance, there's no
- point in drawing the source in device coordinates to avoid pixmap scaling
- if this function returns true - the source pixmap will be scaled anyways.
-*/
-bool QGraphicsEffectSource::isPixmap() const
-{
- return d_func()->isPixmap();
-}
-
-/*!
- Returns true if the source effectively is a pixmap, e.g., a
- QGraphicsPixmapItem.
-
- This function is useful for optimization purposes. For instance, there's no
- point in drawing the source in device coordinates to avoid pixmap scaling
- if this function returns true - the source pixmap will be scaled anyways.
-*/
-bool QGraphicsEffect::sourceIsPixmap() const
-{
- return source() ? source()->isPixmap() : false;
-}
-
-/*!
- Returns a pixmap with the source painted into it.
-
- The \a system specifies which coordinate system to be used for the source.
- The optional \a offset parameter returns the offset where the pixmap should
- be painted at using the current painter.
-
- The \a mode determines how much of the effect the pixmap will contain.
- By default, the pixmap will contain the whole effect.
-
- The returned pixmap is bound to the current painter's device rectangle when
- \a system is Qt::DeviceCoordinates.
-
- \sa QGraphicsEffect::draw(), boundingRect()
-*/
-QPixmap QGraphicsEffectSource::pixmap(Qt::CoordinateSystem system, QPoint *offset, QGraphicsEffect::PixmapPadMode mode) const
-{
- Q_D(const QGraphicsEffectSource);
-
- // Shortcut, no cache for childless pixmap items...
- const QGraphicsItem *item = graphicsItem();
- if (system == Qt::LogicalCoordinates && mode == QGraphicsEffect::NoPad && item && isPixmap()) {
- const QGraphicsPixmapItem *pixmapItem = static_cast<const QGraphicsPixmapItem *>(item);
- if (offset)
- *offset = pixmapItem->offset().toPoint();
- return pixmapItem->pixmap();
- }
-
- if (system == Qt::DeviceCoordinates && item
- && !static_cast<const QGraphicsItemEffectSourcePrivate *>(d_func())->info) {
- qWarning("QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context");
- return QPixmap();
- }
-
- QPixmap pm;
- if (item && d->m_cachedSystem == system && d->m_cachedMode == mode)
- QPixmapCache::find(d->m_cacheKey, &pm);
-
- if (pm.isNull()) {
- pm = d->pixmap(system, &d->m_cachedOffset, mode);
- d->m_cachedSystem = system;
- d->m_cachedMode = mode;
-
- d->invalidateCache();
- d->m_cacheKey = QPixmapCache::insert(pm);
- }
-
- if (offset)
- *offset = d->m_cachedOffset;
-
- return pm;
-}
-
-/*!
- Returns a pixmap with the source painted into it.
-
- The \a system specifies which coordinate system to be used for the source.
- The optional \a offset parameter returns the offset where the pixmap should
- be painted at using the current painter. For control on how the pixmap is
- padded use the \a mode parameter.
-
- The returned pixmap is clipped to the current painter's device rectangle when
- \a system is Qt::DeviceCoordinates.
-
- Calling this function with Qt::DeviceCoordinates outside of
- QGraphicsEffect::draw() will give undefined results, as there is no device
- context available.
-
- \sa draw(), boundingRect()
-*/
-QPixmap QGraphicsEffect::sourcePixmap(Qt::CoordinateSystem system, QPoint *offset, QGraphicsEffect::PixmapPadMode mode) const
-{
- Q_D(const QGraphicsEffect);
- if (d->source)
- return d->source->pixmap(system, offset, mode);
- return QPixmap();
-}
-
-QGraphicsEffectSourcePrivate::~QGraphicsEffectSourcePrivate()
-{
- invalidateCache();
-}
-
-void QGraphicsEffectSourcePrivate::setCachedOffset(const QPoint &offset)
-{
- m_cachedOffset = offset;
-}
-
-void QGraphicsEffectSourcePrivate::invalidateCache(InvalidateReason reason) const
-{
- if (m_cachedMode != QGraphicsEffect::PadToEffectiveBoundingRect
- && (reason == EffectRectChanged
- || (reason == TransformChanged && m_cachedSystem == Qt::LogicalCoordinates))) {
- return;
- }
-
- QPixmapCache::remove(m_cacheKey);
-}
-
-/*!
- Constructs a new QGraphicsEffect instance having the
- specified \a parent.
-*/
-QGraphicsEffect::QGraphicsEffect(QObject *parent)
- : QObject(*new QGraphicsEffectPrivate, parent)
-{
-}
-
-/*!
- \internal
-*/
-QGraphicsEffect::QGraphicsEffect(QGraphicsEffectPrivate &dd, QObject *parent)
- : QObject(dd, parent)
-{
-}
-
-/*!
- Removes the effect from the source, and destroys the graphics effect.
-*/
-QGraphicsEffect::~QGraphicsEffect()
-{
- Q_D(QGraphicsEffect);
- d->setGraphicsEffectSource(0);
-}
-
-/*!
- Returns the effective bounding rectangle for this effect, i.e., the
- bounding rectangle of the source in device coordinates, adjusted by
- any margins applied by the effect itself.
-
- \sa boundingRectFor(), updateBoundingRect()
-*/
-QRectF QGraphicsEffect::boundingRect() const
-{
- Q_D(const QGraphicsEffect);
- if (d->source)
- return boundingRectFor(d->source->boundingRect());
- return QRectF();
-}
-
-/*!
- Returns the effective bounding rectangle for this effect, given the
- provided \a rect in the device coordinates. When writing
- you own custom effect, you must call updateBoundingRect() whenever any
- parameters are changed that may cause this this function to return a
- different value.
-
- \sa sourceBoundingRect()
-*/
-QRectF QGraphicsEffect::boundingRectFor(const QRectF &rect) const
-{
- return rect;
-}
-
-/*!
- \property QGraphicsEffect::enabled
- \brief whether the effect is enabled or not.
-
- If an effect is disabled, the source will be rendered with as normal, with
- no interference from the effect. If the effect is enabled, the source will
- be rendered with the effect applied.
-
- This property is enabled by default.
-
- Using this property, you can disable certain effects on slow platforms, in
- order to ensure that the user interface is responsive.
-*/
-bool QGraphicsEffect::isEnabled() const
-{
- Q_D(const QGraphicsEffect);
- return d->isEnabled;
-}
-
-void QGraphicsEffect::setEnabled(bool enable)
-{
- Q_D(QGraphicsEffect);
- if (d->isEnabled == enable)
- return;
-
- d->isEnabled = enable;
- if (d->source) {
- d->source->d_func()->effectBoundingRectChanged();
- d->source->d_func()->invalidateCache();
- }
- emit enabledChanged(enable);
-}
-
-/*!
- \fn void QGraphicsEffect::enabledChanged(bool enabled)
-
- This signal is emitted whenever the effect is enabled or disabled.
- The \a enabled parameter holds the effects's new enabled state.
-
- \sa isEnabled()
-*/
-
-/*!
- Schedules a redraw of the effect. Call this function whenever the effect
- needs to be redrawn. This function does not trigger a redraw of the source.
-
- \sa updateBoundingRect()
-*/
-void QGraphicsEffect::update()
-{
- Q_D(QGraphicsEffect);
- if (d->source)
- d->source->update();
-}
-
-/*!
- \internal
-
- Returns a pointer to the source, which provides extra context information
- that can be useful for the effect.
-
- \sa draw()
-*/
-QGraphicsEffectSource *QGraphicsEffect::source() const
-{
- Q_D(const QGraphicsEffect);
- return d->source;
-}
-
-/*!
- This function notifies the effect framework when the effect's bounding
- rectangle has changed. As a custom effect author, you must call this
- function whenever you change any parameters that will cause the virtual
- boundingRectFor() function to return a different value.
-
- This function will call update() if this is necessary.
-
- \sa boundingRectFor(), boundingRect(), sourceBoundingRect()
-*/
-void QGraphicsEffect::updateBoundingRect()
-{
- Q_D(QGraphicsEffect);
- if (d->source) {
- d->source->d_func()->effectBoundingRectChanged();
- d->source->d_func()->invalidateCache(QGraphicsEffectSourcePrivate::EffectRectChanged);
- }
-}
-
-/*!
- \fn virtual void QGraphicsEffect::draw(QPainter *painter) = 0
-
- This pure virtual function draws the effect and is called whenever the
- source needs to be drawn.
-
- Reimplement this function in a QGraphicsEffect subclass to provide the
- effect's drawing implementation, using \a painter.
-
- For example:
-
- \snippet doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp 1
-
- This function should not be called explicitly by the user, since it is
- meant for reimplementation purposes only.
-*/
-
-/*!
- \enum QGraphicsEffect::ChangeFlag
-
- This enum describes what has changed in QGraphicsEffectSource.
-
- \value SourceAttached The effect is installed on a source.
- \value SourceDetached The effect is uninstalled on a source.
- \value SourceBoundingRectChanged The bounding rect of the source has
- changed.
- \value SourceInvalidated The visual appearance of the source has changed.
-*/
-
-/*!
- \enum QGraphicsEffect::PixmapPadMode
-
- This enum describes how the pixmap returned from sourcePixmap should be
- padded.
-
- \value NoPad The pixmap should not receive any additional
- padding.
- \value PadToTransparentBorder The pixmap should be padded
- to ensure it has a completely transparent border.
- \value PadToEffectiveBoundingRect The pixmap should be padded to
- match the effective bounding rectangle of the effect.
-*/
-
-/*!
- This virtual function is called by QGraphicsEffect to notify the effect
- that the source has changed. If the effect applies any cache, then this
- cache must be purged in order to reflect the new appearance of the source.
-
- The \a flags describes what has changed.
-*/
-void QGraphicsEffect::sourceChanged(ChangeFlags flags)
-{
- Q_UNUSED(flags);
-}
-
-/*!
- \class QGraphicsColorizeEffect
- \brief The QGraphicsColorizeEffect class provides a colorize effect.
- \since 4.6
-
- A colorize effect renders the source with a tint of its color(). The color
- can be modified using the setColor() function.
-
- By default, the color is light blue (QColor(0, 0, 192)).
-
- \img graphicseffect-colorize.png
-
- \sa QGraphicsDropShadowEffect, QGraphicsBlurEffect, QGraphicsOpacityEffect
-*/
-
-/*!
- Constructs a new QGraphicsColorizeEffect instance.
- The \a parent parameter is passed to QGraphicsEffect's constructor.
-*/
-QGraphicsColorizeEffect::QGraphicsColorizeEffect(QObject *parent)
- : QGraphicsEffect(*new QGraphicsColorizeEffectPrivate, parent)
-{
-}
-
-/*!
- Destroys the effect.
-*/
-QGraphicsColorizeEffect::~QGraphicsColorizeEffect()
-{
-}
-
-/*!
- \property QGraphicsColorizeEffect::color
- \brief the color of the effect.
-
- By default, the color is light blue (QColor(0, 0, 192)).
-*/
-QColor QGraphicsColorizeEffect::color() const
-{
- Q_D(const QGraphicsColorizeEffect);
- return d->filter->color();
-}
-
-void QGraphicsColorizeEffect::setColor(const QColor &color)
-{
- Q_D(QGraphicsColorizeEffect);
- if (d->filter->color() == color)
- return;
-
- d->filter->setColor(color);
- update();
- emit colorChanged(color);
-}
-
-/*!
- \property QGraphicsColorizeEffect::strength
- \brief the strength of the effect.
-
- By default, the strength is 1.0.
- A strength 0.0 equals to no effect, while 1.0 means full colorization.
-*/
-qreal QGraphicsColorizeEffect::strength() const
-{
- Q_D(const QGraphicsColorizeEffect);
- return d->filter->strength();
-}
-
-void QGraphicsColorizeEffect::setStrength(qreal strength)
-{
- Q_D(QGraphicsColorizeEffect);
- if (qFuzzyCompare(d->filter->strength(), strength))
- return;
-
- d->filter->setStrength(strength);
- d->opaque = !qFuzzyIsNull(strength);
- update();
- emit strengthChanged(strength);
-}
-
-/*! \fn void QGraphicsColorizeEffect::strengthChanged(qreal strength)
- This signal is emitted whenever setStrength() changes the colorize
- strength property. \a strength contains the new strength value of
- the colorize effect.
- */
-
-/*!
- \fn void QGraphicsColorizeEffect::colorChanged(const QColor &color)
-
- This signal is emitted whenever the effect's color changes.
- The \a color parameter holds the effect's new color.
-*/
-
-/*!
- \reimp
-*/
-void QGraphicsColorizeEffect::draw(QPainter *painter)
-{
- Q_D(QGraphicsColorizeEffect);
-
- if (!d->opaque) {
- drawSource(painter);
- return;
- }
-
- QPoint offset;
- if (sourceIsPixmap()) {
- // No point in drawing in device coordinates (pixmap will be scaled anyways).
- const QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset, NoPad);
- if (!pixmap.isNull())
- d->filter->draw(painter, offset, pixmap);
-
- return;
- }
-
- // Draw pixmap in deviceCoordinates to avoid pixmap scaling.
- const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset);
- if (pixmap.isNull())
- return;
-
- QTransform restoreTransform = painter->worldTransform();
- painter->setWorldTransform(QTransform());
- d->filter->draw(painter, offset, pixmap);
- painter->setWorldTransform(restoreTransform);
-}
-
-/*!
- \class QGraphicsBlurEffect
- \brief The QGraphicsBlurEffect class provides a blur effect.
- \since 4.6
-
- A blur effect blurs the source. This effect is useful for reducing details,
- such as when the source loses focus and you want to draw attention to other
- elements. The level of detail can be modified using the setBlurRadius()
- function. Use setBlurHints() to choose the blur hints.
-
- By default, the blur radius is 5 pixels. The blur radius is specified in
- device coordinates.
-
- \img graphicseffect-blur.png
-
- \sa QGraphicsDropShadowEffect, QGraphicsColorizeEffect, QGraphicsOpacityEffect
-*/
-
-/*!
- \enum QGraphicsBlurEffect::BlurHint
- \since 4.6
-
- This enum describes the possible hints that can be used to control how
- blur effects are applied. The hints might not have an effect in all the
- paint engines.
-
- \value PerformanceHint Indicates that rendering performance is the most important factor,
- at the potential cost of lower quality.
-
- \value QualityHint Indicates that rendering quality is the most important factor,
- at the potential cost of lower performance.
-
- \value AnimationHint Indicates that the blur radius is going to be animated, hinting
- that the implementation can keep a cache of blurred verisons of the source.
- Do not use this hint if the source is going to be dynamically changing.
-
- \sa blurHints(), setBlurHints()
-*/
-
-
-/*!
- Constructs a new QGraphicsBlurEffect instance.
- The \a parent parameter is passed to QGraphicsEffect's constructor.
-*/
-QGraphicsBlurEffect::QGraphicsBlurEffect(QObject *parent)
- : QGraphicsEffect(*new QGraphicsBlurEffectPrivate, parent)
-{
- Q_D(QGraphicsBlurEffect);
- d->filter->setBlurHints(QGraphicsBlurEffect::PerformanceHint);
-}
-
-/*!
- Destroys the effect.
-*/
-QGraphicsBlurEffect::~QGraphicsBlurEffect()
-{
-}
-
-/*!
- \property QGraphicsBlurEffect::blurRadius
- \brief the blur radius of the effect.
-
- Using a smaller radius results in a sharper appearance, whereas a bigger
- radius results in a more blurred appearance.
-
- By default, the blur radius is 5 pixels.
-
- The radius is given in device coordinates, meaning it is
- unaffected by scale.
-*/
-qreal QGraphicsBlurEffect::blurRadius() const
-{
- Q_D(const QGraphicsBlurEffect);
- return d->filter->radius();
-}
-
-void QGraphicsBlurEffect::setBlurRadius(qreal radius)
-{
- Q_D(QGraphicsBlurEffect);
- if (qFuzzyCompare(d->filter->radius(), radius))
- return;
-
- d->filter->setRadius(radius);
- updateBoundingRect();
- emit blurRadiusChanged(radius);
-}
-
-/*!
- \fn void QGraphicsBlurEffect::blurRadiusChanged(qreal radius)
-
- This signal is emitted whenever the effect's blur radius changes.
- The \a radius parameter holds the effect's new blur radius.
-*/
-
-/*!
- \property QGraphicsBlurEffect::blurHints
- \brief the blur hint of the effect.
-
- Use the PerformanceHint hint to say that you want a faster blur,
- the QualityHint hint to say that you prefer a higher quality blur,
- or the AnimationHint when you want to animate the blur radius.
-
- By default, the blur hint is PerformanceHint.
-*/
-QGraphicsBlurEffect::BlurHints QGraphicsBlurEffect::blurHints() const
-{
- Q_D(const QGraphicsBlurEffect);
- return d->filter->blurHints();
-}
-
-void QGraphicsBlurEffect::setBlurHints(QGraphicsBlurEffect::BlurHints hints)
-{
- Q_D(QGraphicsBlurEffect);
- if (d->filter->blurHints() == hints)
- return;
-
- d->filter->setBlurHints(hints);
- emit blurHintsChanged(hints);
-}
-
-/*!
- \fn void QGraphicsBlurEffect::blurHintsChanged(QGraphicsBlurEffect::BlurHints hints)
-
- This signal is emitted whenever the effect's blur hints changes.
- The \a hints parameter holds the effect's new blur hints.
-*/
-
-/*!
- \reimp
-*/
-QRectF QGraphicsBlurEffect::boundingRectFor(const QRectF &rect) const
-{
- Q_D(const QGraphicsBlurEffect);
- return d->filter->boundingRectFor(rect);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsBlurEffect::draw(QPainter *painter)
-{
- Q_D(QGraphicsBlurEffect);
- if (d->filter->radius() < 1) {
- drawSource(painter);
- return;
- }
-
- PixmapPadMode mode = PadToEffectiveBoundingRect;
- if (painter->paintEngine()->type() == QPaintEngine::OpenGL2)
- mode = NoPad;
-
- QPoint offset;
- QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset, mode);
- if (pixmap.isNull())
- return;
-
- d->filter->draw(painter, offset, pixmap);
-}
-
-/*!
- \class QGraphicsDropShadowEffect
- \brief The QGraphicsDropShadowEffect class provides a drop shadow effect.
- \since 4.6
-
- A drop shadow effect renders the source with a drop shadow. The color of
- the drop shadow can be modified using the setColor() function. The drop
- shadow offset can be modified using the setOffset() function and the blur
- radius of the drop shadow can be changed with the setBlurRadius()
- function.
-
- By default, the drop shadow is a semi-transparent dark gray
- (QColor(63, 63, 63, 180)) shadow, blurred with a radius of 1 at an offset
- of 8 pixels towards the lower right. The drop shadow offset is specified
- in device coordinates.
-
- \img graphicseffect-drop-shadow.png
-
- \sa QGraphicsBlurEffect, QGraphicsColorizeEffect, QGraphicsOpacityEffect
-*/
-
-/*!
- Constructs a new QGraphicsDropShadowEffect instance.
- The \a parent parameter is passed to QGraphicsEffect's constructor.
-*/
-QGraphicsDropShadowEffect::QGraphicsDropShadowEffect(QObject *parent)
- : QGraphicsEffect(*new QGraphicsDropShadowEffectPrivate, parent)
-{
-}
-
-/*!
- Destroys the effect.
-*/
-QGraphicsDropShadowEffect::~QGraphicsDropShadowEffect()
-{
-}
-
-/*!
- \property QGraphicsDropShadowEffect::offset
- \brief the shadow offset in pixels.
-
- By default, the offset is 8 pixels towards the lower right.
-
- The offset is given in device coordinates, which means it is
- unaffected by scale.
-
- \sa xOffset(), yOffset(), blurRadius(), color()
-*/
-QPointF QGraphicsDropShadowEffect::offset() const
-{
- Q_D(const QGraphicsDropShadowEffect);
- return d->filter->offset();
-}
-
-void QGraphicsDropShadowEffect::setOffset(const QPointF &offset)
-{
- Q_D(QGraphicsDropShadowEffect);
- if (d->filter->offset() == offset)
- return;
-
- d->filter->setOffset(offset);
- updateBoundingRect();
- emit offsetChanged(offset);
-}
-
-/*!
- \property QGraphicsDropShadowEffect::xOffset
- \brief the horizontal shadow offset in pixels.
-
- By default, the horizontal shadow offset is 8 pixels.
-
-
-
- \sa yOffset(), offset()
-*/
-
-/*!
- \property QGraphicsDropShadowEffect::yOffset
- \brief the vertical shadow offset in pixels.
-
- By default, the vertical shadow offset is 8 pixels.
-
- \sa xOffset(), offset()
-*/
-
-/*!
- \fn void QGraphicsDropShadowEffect::offsetChanged(const QPointF &offset)
-
- This signal is emitted whenever the effect's shadow offset changes.
- The \a offset parameter holds the effect's new shadow offset.
-*/
-
-/*!
- \property QGraphicsDropShadowEffect::blurRadius
- \brief the blur radius in pixels of the drop shadow.
-
- Using a smaller radius results in a sharper shadow, whereas using a bigger
- radius results in a more blurred shadow.
-
- By default, the blur radius is 1 pixel.
-
- \sa color(), offset().
-*/
-qreal QGraphicsDropShadowEffect::blurRadius() const
-{
- Q_D(const QGraphicsDropShadowEffect);
- return d->filter->blurRadius();
-}
-
-void QGraphicsDropShadowEffect::setBlurRadius(qreal blurRadius)
-{
- Q_D(QGraphicsDropShadowEffect);
- if (qFuzzyCompare(d->filter->blurRadius(), blurRadius))
- return;
-
- d->filter->setBlurRadius(blurRadius);
- updateBoundingRect();
- emit blurRadiusChanged(blurRadius);
-}
-
-/*!
- \fn void QGraphicsDropShadowEffect::blurRadiusChanged(qreal blurRadius)
-
- This signal is emitted whenever the effect's blur radius changes.
- The \a blurRadius parameter holds the effect's new blur radius.
-*/
-
-/*!
- \property QGraphicsDropShadowEffect::color
- \brief the color of the drop shadow.
-
- By default, the drop color is a semi-transparent dark gray
- (QColor(63, 63, 63, 180)).
-
- \sa offset(), blurRadius()
-*/
-QColor QGraphicsDropShadowEffect::color() const
-{
- Q_D(const QGraphicsDropShadowEffect);
- return d->filter->color();
-}
-
-void QGraphicsDropShadowEffect::setColor(const QColor &color)
-{
- Q_D(QGraphicsDropShadowEffect);
- if (d->filter->color() == color)
- return;
-
- d->filter->setColor(color);
- update();
- emit colorChanged(color);
-}
-
-/*!
- \fn void QGraphicsDropShadowEffect::colorChanged(const QColor &color)
-
- This signal is emitted whenever the effect's color changes.
- The \a color parameter holds the effect's new color.
-*/
-
-/*!
- \reimp
-*/
-QRectF QGraphicsDropShadowEffect::boundingRectFor(const QRectF &rect) const
-{
- Q_D(const QGraphicsDropShadowEffect);
- return d->filter->boundingRectFor(rect);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsDropShadowEffect::draw(QPainter *painter)
-{
- Q_D(QGraphicsDropShadowEffect);
- if (d->filter->blurRadius() <= 0 && d->filter->offset().isNull()) {
- drawSource(painter);
- return;
- }
-
- PixmapPadMode mode = PadToEffectiveBoundingRect;
- if (painter->paintEngine()->type() == QPaintEngine::OpenGL2)
- mode = NoPad;
-
- // Draw pixmap in device coordinates to avoid pixmap scaling.
- QPoint offset;
- const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset, mode);
- if (pixmap.isNull())
- return;
-
- QTransform restoreTransform = painter->worldTransform();
- painter->setWorldTransform(QTransform());
- d->filter->draw(painter, offset, pixmap);
- painter->setWorldTransform(restoreTransform);
-}
-
-/*!
- \class QGraphicsOpacityEffect
- \brief The QGraphicsOpacityEffect class provides an opacity effect.
- \since 4.6
-
- An opacity effect renders the source with an opacity. This effect is useful
- for making the source semi-transparent, similar to a fade-in/fade-out
- sequence. The opacity can be modified using the setOpacity() function.
-
- By default, the opacity is 0.7.
-
- \img graphicseffect-opacity.png
-
- \sa QGraphicsDropShadowEffect, QGraphicsBlurEffect, QGraphicsColorizeEffect
-*/
-
-/*!
- Constructs a new QGraphicsOpacityEffect instance.
- The \a parent parameter is passed to QGraphicsEffect's constructor.
-*/
-QGraphicsOpacityEffect::QGraphicsOpacityEffect(QObject *parent)
- : QGraphicsEffect(*new QGraphicsOpacityEffectPrivate, parent)
-{
-}
-
-/*!
- Destroys the effect.
-*/
-QGraphicsOpacityEffect::~QGraphicsOpacityEffect()
-{
-}
-
-/*!
- \property QGraphicsOpacityEffect::opacity
- \brief the opacity of the effect.
-
- The value should be in the range of 0.0 to 1.0, where 0.0 is
- fully transparent and 1.0 is fully opaque.
-
- By default, the opacity is 0.7.
-
- \sa setOpacityMask()
-*/
-qreal QGraphicsOpacityEffect::opacity() const
-{
- Q_D(const QGraphicsOpacityEffect);
- return d->opacity;
-}
-
-void QGraphicsOpacityEffect::setOpacity(qreal opacity)
-{
- Q_D(QGraphicsOpacityEffect);
- opacity = qBound(qreal(0.0), opacity, qreal(1.0));
-
- if (qFuzzyCompare(d->opacity, opacity))
- return;
-
- d->opacity = opacity;
- if ((d->isFullyTransparent = qFuzzyIsNull(d->opacity)))
- d->isFullyOpaque = 0;
- else
- d->isFullyOpaque = qFuzzyIsNull(d->opacity - 1);
- update();
- emit opacityChanged(opacity);
-}
-
-/*!
- \fn void QGraphicsOpacityEffect::opacityChanged(qreal opacity)
-
- This signal is emitted whenever the effect's opacity changes.
- The \a opacity parameter holds the effect's new opacity.
-*/
-
-/*!
- \property QGraphicsOpacityEffect::opacityMask
- \brief the opacity mask of the effect.
-
- An opacity mask allows you apply opacity to portions of an element.
-
- For example:
-
- \snippet doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp 2
-
- There is no opacity mask by default.
-
- \sa setOpacity()
-*/
-QBrush QGraphicsOpacityEffect::opacityMask() const
-{
- Q_D(const QGraphicsOpacityEffect);
- return d->opacityMask;
-}
-
-void QGraphicsOpacityEffect::setOpacityMask(const QBrush &mask)
-{
- Q_D(QGraphicsOpacityEffect);
- if (d->opacityMask == mask)
- return;
-
- d->opacityMask = mask;
- d->hasOpacityMask = (mask.style() != Qt::NoBrush);
- update();
-
- emit opacityMaskChanged(mask);
-}
-
-/*!
- \fn void QGraphicsOpacityEffect::opacityMaskChanged(const QBrush &mask)
-
- This signal is emitted whenever the effect's opacity mask changes.
- The \a mask parameter holds the effect's new opacity mask.
-*/
-
-/*!
- \reimp
-*/
-void QGraphicsOpacityEffect::draw(QPainter *painter)
-{
- Q_D(QGraphicsOpacityEffect);
-
- // Transparent; nothing to draw.
- if (d->isFullyTransparent)
- return;
-
- // Opaque; draw directly without going through a pixmap.
- if (d->isFullyOpaque && !d->hasOpacityMask) {
- drawSource(painter);
- return;
- }
-
- QPoint offset;
- Qt::CoordinateSystem system = sourceIsPixmap() ? Qt::LogicalCoordinates : Qt::DeviceCoordinates;
- QPixmap pixmap = sourcePixmap(system, &offset, QGraphicsEffect::NoPad);
- if (pixmap.isNull())
- return;
-
- painter->save();
- painter->setOpacity(d->opacity);
-
- if (d->hasOpacityMask) {
- QPainter pixmapPainter(&pixmap);
- pixmapPainter.setRenderHints(painter->renderHints());
- pixmapPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
- if (system == Qt::DeviceCoordinates) {
- QTransform worldTransform = painter->worldTransform();
- worldTransform *= QTransform::fromTranslate(-offset.x(), -offset.y());
- pixmapPainter.setWorldTransform(worldTransform);
- pixmapPainter.fillRect(sourceBoundingRect(), d->opacityMask);
- } else {
- pixmapPainter.translate(-offset);
- pixmapPainter.fillRect(pixmap.rect(), d->opacityMask);
- }
- }
-
- if (system == Qt::DeviceCoordinates)
- painter->setWorldTransform(QTransform());
-
- painter->drawPixmap(offset, pixmap);
- painter->restore();
-}
-
-
-QT_END_NAMESPACE
-
-#endif //QT_NO_GRAPHICSEFFECT
diff --git a/src/gui/egl/egl.pri b/src/gui/egl/egl.pri
index 8e8664c679..ec23da3312 100644
--- a/src/gui/egl/egl.pri
+++ b/src/gui/egl/egl.pri
@@ -25,19 +25,15 @@ contains(QT_CONFIG, egl): {
wince*: SOURCES += egl/qegl_wince.cpp
unix {
- embedded {
- SOURCES += egl/qegl_qws.cpp
- } else {
- qpa {
- SOURCES += egl/qegl_qpa.cpp
- } else {
- symbian {
- SOURCES += egl/qegl_symbian.cpp
- } else {
- SOURCES += egl/qegl_x11.cpp
- }
- }
- }
+ qpa {
+ SOURCES += egl/qegl_qpa.cpp
+ } else {
+ symbian {
+ SOURCES += egl/qegl_symbian.cpp
+ } else {
+ SOURCES += egl/qegl_x11.cpp
+ }
+ }
}
} else:symbian {
DEFINES += QT_NO_EGL
diff --git a/src/gui/egl/qegl_qpa.cpp b/src/gui/egl/qegl_qpa.cpp
index 10caf46d56..7785c03084 100644
--- a/src/gui/egl/qegl_qpa.cpp
+++ b/src/gui/egl/qegl_qpa.cpp
@@ -46,7 +46,6 @@
#if !defined(QT_NO_EGL)
-#include <QtGui/private/qgraphicssystem_p.h>
#include <QtGui/private/qapplication_p.h>
#include <QtGui/qdesktopwidget.h>
@@ -75,7 +74,7 @@ EGLNativePixmapType QEgl::nativePixmap(QPixmap* pixmap)
static QPlatformScreen *screenForDevice(QPaintDevice *device)
{
- QPlatformIntegration *pi = QApplicationPrivate::platformIntegration();
+ QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration();
QList<QPlatformScreen *> screens = pi->screens();
diff --git a/src/gui/egl/qegl_qws.cpp b/src/gui/egl/qegl_qws.cpp
deleted file mode 100644
index 181a9f2c63..0000000000
--- a/src/gui/egl/qegl_qws.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtGui/qpaintdevice.h>
-#include <QtGui/qpixmap.h>
-#include <QtGui/qwidget.h>
-
-#include "qegl_p.h"
-#include "qeglcontext_p.h"
-
-#if !defined(QT_NO_EGL)
-
-#include <qscreen_qws.h>
-#include <qscreenproxy_qws.h>
-#include <qapplication.h>
-#include <qdesktopwidget.h>
-
-QT_BEGIN_NAMESPACE
-
-static QScreen *screenForDevice(QPaintDevice *device)
-{
- QScreen *screen = qt_screen;
- if (!screen)
- return 0;
- if (screen->classId() == QScreen::MultiClass) {
- int screenNumber;
- if (device && device->devType() == QInternal::Widget)
- screenNumber = qApp->desktop()->screenNumber(static_cast<QWidget *>(device));
- else
- screenNumber = 0;
- screen = screen->subScreens()[screenNumber];
- }
- while (screen->classId() == QScreen::ProxyClass ||
- screen->classId() == QScreen::TransformedClass) {
- screen = static_cast<QProxyScreen *>(screen)->screen();
- }
- return screen;
-}
-
-// Set pixel format and other properties based on a paint device.
-void QEglProperties::setPaintDeviceFormat(QPaintDevice *dev)
-{
- if (!dev)
- return;
-
- // Find the QGLScreen for this paint device.
- QScreen *screen = screenForDevice(dev);
- if (!screen)
- return;
- int devType = dev->devType();
- if (devType == QInternal::Image)
- setPixelFormat(static_cast<QImage *>(dev)->format());
- else
- setPixelFormat(screen->pixelFormat());
-}
-
-EGLNativeDisplayType QEgl::nativeDisplay()
-{
- return EGLNativeDisplayType(EGL_DEFAULT_DISPLAY);
-}
-
-EGLNativeWindowType QEgl::nativeWindow(QWidget* widget)
-{
- return (EGLNativeWindowType)(widget->winId()); // Might work
-}
-
-EGLNativePixmapType QEgl::nativePixmap(QPixmap*)
-{
- qWarning("QEgl: EGL pixmap surfaces not supported on QWS");
- return (EGLNativePixmapType)0;
-}
-
-
-QT_END_NAMESPACE
-
-#endif // !QT_NO_EGL
diff --git a/src/gui/embedded/directfb.pri b/src/gui/embedded/directfb.pri
deleted file mode 100644
index 75d693e0b4..0000000000
--- a/src/gui/embedded/directfb.pri
+++ /dev/null
@@ -1,40 +0,0 @@
-# These defines might be necessary if your DirectFB driver doesn't
-# support all of the DirectFB API.
-#
-#DEFINES += QT_DIRECTFB_SUBSURFACE
-#DEFINES += QT_DIRECTFB_WINDOW_AS_CURSOR
-#DEFINES += QT_NO_DIRECTFB_IMAGEPROVIDER
-#DEFINES += QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE
-#DEFINES += QT_DIRECTFB_IMAGECACHE
-#DEFINES += QT_NO_DIRECTFB_WM
-#DEFINES += QT_NO_DIRECTFB_LAYER
-#DEFINES += QT_DIRECTFB_PALETTE
-#DEFINES += QT_NO_DIRECTFB_PREALLOCATED
-#DEFINES += QT_NO_DIRECTFB_MOUSE
-#DEFINES += QT_NO_DIRECTFB_KEYBOARD
-#DEFINES += QT_DIRECTFB_TIMING
-#DEFINES += QT_NO_DIRECTFB_OPAQUE_DETECTION
-#DEFINES += QT_NO_DIRECTFB_STRETCHBLIT
-DIRECTFB_DRAWINGOPERATIONS=DRAW_RECTS|DRAW_LINES|DRAW_IMAGE|DRAW_PIXMAP|DRAW_TILED_PIXMAP|STROKE_PATH|DRAW_PATH|DRAW_POINTS|DRAW_ELLIPSE|DRAW_POLYGON|DRAW_TEXT|FILL_PATH|FILL_RECT|DRAW_COLORSPANS|DRAW_ROUNDED_RECT|DRAW_STATICTEXT
-#DEFINES += \"QT_DIRECTFB_WARN_ON_RASTERFALLBACKS=$$DIRECTFB_DRAWINGOPERATIONS\"
-#DEFINES += \"QT_DIRECTFB_DISABLE_RASTERFALLBACKS=$$DIRECTFB_DRAWINGOPERATIONS\"
-
-HEADERS += $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h \
- $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h \
- $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h \
- $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h \
- $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h \
- $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h \
- $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h
-
-SOURCES += $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp \
- $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp \
- $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp \
- $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp \
- $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp \
- $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp \
- $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp
-
-
-QMAKE_CXXFLAGS += $$QT_CFLAGS_DIRECTFB
-LIBS += $$QT_LIBS_DIRECTFB
diff --git a/src/gui/embedded/embedded.pri b/src/gui/embedded/embedded.pri
deleted file mode 100644
index 31f0bc6d50..0000000000
--- a/src/gui/embedded/embedded.pri
+++ /dev/null
@@ -1,226 +0,0 @@
-# Qt for Embedded Linux
-
-embedded {
- CONFIG -= opengl x11
- LIBS -= -dl
- KERNEL_P = kernel
-
- !mac:HEADERS += embedded/qsoundqss_qws.h
- HEADERS += \
- embedded/qcopchannel_qws.h \
- embedded/qdecoration_qws.h \
- embedded/qdecorationfactory_qws.h \
- embedded/qdecorationplugin_qws.h \
- embedded/qdirectpainter_qws.h \
- embedded/qlock_p.h \
- embedded/qscreen_qws.h \
- embedded/qscreenmulti_qws_p.h \
- embedded/qscreenproxy_qws.h \
- embedded/qwindowsystem_qws.h \
- embedded/qwindowsystem_p.h \
- embedded/qwscommand_qws_p.h \
- embedded/qwscursor_qws.h \
- embedded/qwsdisplay_qws.h \
- embedded/qwsdisplay_qws_p.h \
- embedded/qwsevent_qws.h \
- embedded/qwsmanager_qws.h \
- embedded/qwsmanager_p.h \
- embedded/qwsproperty_qws.h \
- embedded/qwsprotocolitem_qws.h \
- embedded/qtransportauth_qws.h \
- embedded/qtransportauth_qws_p.h \
- embedded/qtransportauthdefs_qws.h \
- embedded/qwssocket_qws.h \
- embedded/qwslock_p.h \
- embedded/qwsutils_qws.h \
- embedded/qwssharedmemory_p.h \
- embedded/qwssignalhandler_p.h \
- embedded/qwsembedwidget.h
-
- !mac:SOURCES += embedded/qsoundqss_qws.cpp
- SOURCES += \
- embedded/qcopchannel_qws.cpp \
- embedded/qdecoration_qws.cpp \
- embedded/qdecorationfactory_qws.cpp \
- embedded/qdecorationplugin_qws.cpp \
- embedded/qdirectpainter_qws.cpp \
- embedded/qlock.cpp \
- embedded/qscreen_qws.cpp \
- embedded/qscreenmulti_qws.cpp \
- embedded/qscreenproxy_qws.cpp \
- embedded/qwindowsystem_qws.cpp \
- embedded/qwscommand_qws.cpp \
- embedded/qwscursor_qws.cpp \
- embedded/qwsevent_qws.cpp \
- embedded/qwsmanager_qws.cpp \
- embedded/qwsproperty_qws.cpp \
- embedded/qtransportauth_qws.cpp \
- embedded/qwslock.cpp \
- embedded/qwssharedmemory.cpp \
- embedded/qwssocket_qws.cpp \
- embedded/qwssignalhandler.cpp \
- embedded/qwsembedwidget.cpp
-
- contains(QT_CONFIG,sxe)|contains(QT_CONFIG,qtopia) {
- SOURCES += embedded/qunixsocket.cpp embedded/qunixsocketserver.cpp
- HEADERS += embedded/qunixsocket_p.h embedded/qunixsocketserver_p.h
- }
-
-#
-# Decorations
-#
- contains( decorations, default ) {
- HEADERS += embedded/qdecorationdefault_qws.h
- SOURCES += embedded/qdecorationdefault_qws.cpp
- }
- contains( decorations, styled ) {
- HEADERS += embedded/qdecorationstyled_qws.h
- SOURCES += embedded/qdecorationstyled_qws.cpp
- }
-
- contains( decorations, windows ) {
- HEADERS += embedded/qdecorationwindows_qws.h
- SOURCES += embedded/qdecorationwindows_qws.cpp
- }
-
-#
-# Qt for Embedded Linux Drivers
-#
- HEADERS += embedded/qscreendriverplugin_qws.h \
- embedded/qscreendriverfactory_qws.h \
- embedded/qkbd_qws.h \
- embedded/qkbd_qws_p.h \
- embedded/qkbd_defaultmap_qws_p.h \
- embedded/qkbddriverplugin_qws.h \
- embedded/qkbddriverfactory_qws.h \
- embedded/qmouse_qws.h \
- embedded/qmousedriverplugin_qws.h \
- embedded/qmousedriverfactory_qws.h
-
- SOURCES += embedded/qscreendriverplugin_qws.cpp \
- embedded/qscreendriverfactory_qws.cpp \
- embedded/qkbd_qws.cpp \
- embedded/qkbddriverplugin_qws.cpp \
- embedded/qkbddriverfactory_qws.cpp \
- embedded/qmouse_qws.cpp \
- embedded/qmousedriverplugin_qws.cpp \
- embedded/qmousedriverfactory_qws.cpp
-
-#
-# Graphics drivers
-#
- contains( gfx-drivers, linuxfb ) {
- HEADERS += embedded/qscreenlinuxfb_qws.h
- SOURCES += embedded/qscreenlinuxfb_qws.cpp
- }
-
- contains( gfx-drivers, qnx ) {
- HEADERS += embedded/qscreenqnx_qws.h
- SOURCES += embedded/qscreenqnx_qws.cpp
- LIBS += -lgf
- }
-
- contains( gfx-drivers, integrityfb ) {
- HEADERS += embedded/qscreenintegrityfb_qws.h
- SOURCES += embedded/qscreenintegrityfb_qws.cpp
- LIBS += -lfbdev
- }
-
- contains( gfx-drivers, qvfb ) {
- HEADERS += embedded/qscreenvfb_qws.h
- SOURCES += embedded/qscreenvfb_qws.cpp
- }
-
-
- contains( gfx-drivers, vnc ) {
- VNCDIR = $$QT_SOURCE_TREE/src/plugins/gfxdrivers/vnc
- INCLUDEPATH += $$VNCDIR
- HEADERS += $$VNCDIR/qscreenvnc_qws.h \
- $$VNCDIR/qscreenvnc_p.h
- SOURCES += $$VNCDIR/qscreenvnc_qws.cpp
- }
-
- contains( gfx-drivers, transformed ) {
- HEADERS += embedded/qscreentransformed_qws.h
- SOURCES += embedded/qscreentransformed_qws.cpp
- }
-
- contains( gfx-drivers, directfb ) {
- INCLUDEPATH += $$QT_SOURCE_TREE/src/plugins/gfxdrivers/directfb
- include($$PWD/directfb.pri)
- }
-#
-# Keyboard drivers
-#
- contains( kbd-drivers, qvfb ) {
- HEADERS +=embedded/qkbdvfb_qws.h
- SOURCES +=embedded/qkbdvfb_qws.cpp
- !contains( kbd-drivers, qvfb ) {
- kbd-drivers += qvfb
- }
- }
-
- contains( kbd-drivers, tty ) {
- HEADERS +=embedded/qkbdtty_qws.h
- SOURCES +=embedded/qkbdtty_qws.cpp
- }
-
- contains( kbd-drivers, linuxinput ) {
- HEADERS +=embedded/qkbdlinuxinput_qws.h
- SOURCES +=embedded/qkbdlinuxinput_qws.cpp
- }
-
- contains( kbd-drivers, um ) {
- HEADERS +=embedded/qkbdum_qws.h
- SOURCES +=embedded/qkbdum_qws.cpp
- }
-
- contains( kbd-drivers, qnx ) {
- HEADERS += embedded/qkbdqnx_qws.h
- SOURCES += embedded/qkbdqnx_qws.cpp
- }
-
- contains( kbd-drivers, integrity ) {
- HEADERS += embedded/qkbdintegrity_qws.h
- SOURCES += embedded/qkbdintegrity_qws.cpp
- }
-
-#
-# Mouse drivers
-#
- contains( mouse-drivers, qvfb ) {
- HEADERS +=embedded/qmousevfb_qws.h
- SOURCES +=embedded/qmousevfb_qws.cpp
- }
-
- contains( mouse-drivers, pc ) {
- HEADERS +=embedded/qmousepc_qws.h
- SOURCES +=embedded/qmousepc_qws.cpp
- }
-
- contains( mouse-drivers, linuxtp ) {
- HEADERS +=embedded/qmouselinuxtp_qws.h
- SOURCES +=embedded/qmouselinuxtp_qws.cpp
- }
-
- contains( mouse-drivers, tslib ) {
- LIBS_PRIVATE += -lts
- HEADERS +=embedded/qmousetslib_qws.h
- SOURCES +=embedded/qmousetslib_qws.cpp
- }
-
- contains( mouse-drivers, linuxinput ) {
- HEADERS +=embedded/qmouselinuxinput_qws.h
- SOURCES +=embedded/qmouselinuxinput_qws.cpp
- }
-
- contains( mouse-drivers, qnx ) {
- HEADERS += embedded/qmouseqnx_qws.h
- SOURCES += embedded/qmouseqnx_qws.cpp
- }
-
- contains( mouse-drivers, integrity ) {
- HEADERS += embedded/qmouseintegrity_qws.h
- SOURCES += embedded/qmouseintegrity_qws.cpp
- }
-}
diff --git a/src/gui/embedded/qcopchannel_qws.cpp b/src/gui/embedded/qcopchannel_qws.cpp
deleted file mode 100644
index 703debc69c..0000000000
--- a/src/gui/embedded/qcopchannel_qws.cpp
+++ /dev/null
@@ -1,608 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qcopchannel_qws.h"
-
-#ifndef QT_NO_COP
-
-#include "qwsdisplay_qws.h"
-#include "qwscommand_qws_p.h"
-#include "qwindowsystem_qws.h"
-#include "qwindowsystem_p.h"
-#include "qlist.h"
-#include "qmap.h"
-#include "qdatastream.h"
-#include "qpointer.h"
-#include "qmutex.h"
-
-#include "qdebug.h"
-
-QT_BEGIN_NAMESPACE
-
-typedef QMap<QString, QList<QWSClient*> > QCopServerMap;
-static QCopServerMap *qcopServerMap = 0;
-
-class QCopServerRegexp
-{
-public:
- QCopServerRegexp( const QString& channel, QWSClient *client );
- QCopServerRegexp( const QCopServerRegexp& other );
-
- QString channel;
- QWSClient *client;
- QRegExp regexp;
-};
-
-QCopServerRegexp::QCopServerRegexp( const QString& channel, QWSClient *client )
-{
- this->channel = channel;
- this->client = client;
- this->regexp = QRegExp( channel, Qt::CaseSensitive, QRegExp::Wildcard );
-}
-
-QCopServerRegexp::QCopServerRegexp( const QCopServerRegexp& other )
-{
- channel = other.channel;
- client = other.client;
- regexp = other.regexp;
-}
-
-typedef QList<QCopServerRegexp> QCopServerRegexpList;
-static QCopServerRegexpList *qcopServerRegexpList = 0;
-
-typedef QMap<QString, QList< QPointer<QCopChannel> > > QCopClientMap;
-static QCopClientMap *qcopClientMap = 0;
-
-Q_GLOBAL_STATIC(QMutex, qcopClientMapMutex)
-
-// Determine if a channel name contains wildcard characters.
-static bool containsWildcards( const QString& channel )
-{
- return channel.contains(QLatin1Char('*'));
-}
-
-class QCopChannelPrivate
-{
-public:
- QString channel;
-};
-
-/*!
- \class QCopChannel
- \ingroup qws
-
- \brief The QCopChannel class provides communication capabilities
- between clients in \l{Qt for Embedded Linux}.
-
- Note that this class is only available in \l{Qt for Embedded Linux}.
-
- The Qt COmmunication Protocol (QCOP) is a many-to-many protocol
- for transferring messages across registered channels. A channel is
- registered by name, and anyone who wants to can listen to the
- channel as well as send messages through it. The QCOP protocol
- allows clients to communicate both within the same address space
- and between different processes.
-
- To send messages to a given channel, QCopChannel provides the
- static send() function. Using this function alone, the messages
- are queued until Qt re-enters the event loop. To immediately flush
- all queued messages to the registered listeners, call the static
- flush() function.
-
- To listen to the traffic on a given channel, you typically
- instantiate a QCopChannel object for the given channel and connect
- to its received() signal that is emitted whenever there is
- incoming data. Use the static isRegistered() function to query
- the server for the existence of a given channel. QCopChannel
- provides the channel() function returning the name of this
- QCopChannel object's channel.
-
- In additon, QCopChannel provides the virtual receive() function
- that can be reimplemented to filter the incoming messages and
- data. The default implementation simply emits the received()
- signal.
-
- \sa QWSServer, QWSClient, {Qt for Embedded Linux Architecture}
-*/
-
-/*!
- Constructs a QCopChannel object for the specified \a channel, with
- the given \a parent. Once created, the channel is registered by
- the server.
-
- \sa isRegistered(), channel()
-*/
-
-QCopChannel::QCopChannel(const QString& channel, QObject *parent) :
- QObject(parent)
-{
- init(channel);
-}
-
-#ifdef QT3_SUPPORT
-/*!
- Use the two argument overload instead, and call the
- QObject::setObjectName() function to \a name the instance.
-*/
-QCopChannel::QCopChannel(const QString& channel, QObject *parent, const char *name) :
- QObject(parent)
-{
- setObjectName(QString::fromAscii(name));
- init(channel);
-}
-#endif
-
-void QCopChannel::init(const QString& channel)
-{
- d = new QCopChannelPrivate;
- d->channel = channel;
-
- if (!qt_fbdpy) {
- qFatal("QCopChannel: Must construct a QApplication "
- "before QCopChannel");
- return;
- }
-
- {
- QMutexLocker locker(qcopClientMapMutex());
-
- if (!qcopClientMap)
- qcopClientMap = new QCopClientMap;
-
- // do we need a new channel list ?
- QCopClientMap::Iterator it = qcopClientMap->find(channel);
- if (it != qcopClientMap->end()) {
- it.value().append(this);
- return;
- }
-
- it = qcopClientMap->insert(channel, QList< QPointer<QCopChannel> >());
- it.value().append(QPointer<QCopChannel>(this));
- }
-
- // inform server about this channel
- qt_fbdpy->registerChannel(channel);
-}
-
-/*!
- \internal
-
- Resend all channel registrations
- */
-void QCopChannel::reregisterAll()
-{
- if(qcopClientMap)
- for(QCopClientMap::Iterator iter = qcopClientMap->begin();
- iter != qcopClientMap->end();
- ++iter)
- qt_fbdpy->registerChannel(iter.key());
-}
-
-/*!
- Destroys this QCopChannel object.
-
- The server is notified that this particular listener has closed
- its connection. The server will keep the channel open until the
- last registered listener detaches.
-
- \sa isRegistered(), channel()
-*/
-
-QCopChannel::~QCopChannel()
-{
- QMutexLocker locker(qcopClientMapMutex());
- QCopClientMap::Iterator it = qcopClientMap->find(d->channel);
- Q_ASSERT(it != qcopClientMap->end());
- it.value().removeAll(this);
- // still any clients connected locally ?
- if (it.value().isEmpty()) {
- QByteArray data;
- QDataStream s(&data, QIODevice::WriteOnly);
- s << d->channel;
- if (qt_fbdpy)
- send(QLatin1String(""), QLatin1String("detach()"), data);
- qcopClientMap->remove(d->channel);
- }
-
- delete d;
-}
-
-/*!
- Returns the name of this object's channel.
-
- \sa isRegistered()
-*/
-
-QString QCopChannel::channel() const
-{
- return d->channel;
-}
-
-/*!
- \fn void QCopChannel::receive(const QString& message, const QByteArray &data)
-
- Processes the incoming \a message and \a data.
-
- This function is called by the server when this object's channel
- receives new messages. Note that the default implementation simply
- emits the received() signal; reimplement this function to process
- the incoming \a message and \a data.
-
- Note that the format of the given \a data has to be well defined
- in order to extract the information it contains. In addition, it
- is recommended to use the DCOP convention. This is not a
- requirement, but you must ensure that the sender and receiver
- agree on the argument types. For example:
-
- \snippet doc/src/snippets/code/src_gui_embedded_qcopchannel_qws.cpp 0
-
- The above code assumes that the \c message is a DCOP-style
- function signature and the \c data contains the function's
- arguments.
-
- \sa send(), channel(), received()
- */
-void QCopChannel::receive(const QString& msg, const QByteArray &data)
-{
- emit received(msg, data);
-}
-
-/*!
- \fn void QCopChannel::received(const QString& message, const QByteArray &data)
-
- This signal is emitted whenever this object's channel receives new
- messages (i.e., it is emitted by the receive() function), passing
- the incoming \a message and \a data as parameters.
-
- \sa receive(), channel()
-*/
-
-/*!
- Queries the server for the existence of the given \a channel. Returns true
- if the channel is registered; otherwise returns false.
-
- \sa channel(), send()
-*/
-
-bool QCopChannel::isRegistered(const QString& channel)
-{
- QByteArray data;
- QDataStream s(&data, QIODevice::WriteOnly);
- s << channel;
- if (!send(QLatin1String(""), QLatin1String("isRegistered()"), data))
- return false;
-
- QWSQCopMessageEvent *e = qt_fbdpy->waitForQCopResponse();
- bool known = e->message == "known";
- delete e;
- return known;
-}
-
-/*!
- \fn bool QCopChannel::send(const QString& channel, const QString& message)
- \overload
-*/
-
-bool QCopChannel::send(const QString& channel, const QString& msg)
-{
- QByteArray data;
- return send(channel, msg, data);
-}
-
-/*!
- \fn bool QCopChannel::send(const QString& channel, const QString& message,
- const QByteArray &data)
-
- Sends the given \a message on the specified \a channel with the
- given \a data. The message will be distributed to all clients
- subscribed to the channel. Returns true if the message is sent
- successfully; otherwise returns false.
-
- It is recommended to use the DCOP convention. This is not a
- requirement, but you must ensure that the sender and receiver
- agree on the argument types.
-
- Note that QDataStream provides a convenient way to fill the byte
- array with auxiliary data. For example:
-
- \snippet doc/src/snippets/code/src_gui_embedded_qcopchannel_qws.cpp 1
-
- In the code above the channel is \c "System/Shell". The \c message
- is an arbitrary string, but in the example we've used the DCOP
- convention of passing a function signature. Such a signature is
- formatted as \c "functionname(types)" where \c types is a list of
- zero or more comma-separated type names, with no whitespace, no
- consts and no pointer or reference marks, i.e. no "*" or "&".
-
- \sa receive(), isRegistered()
-*/
-
-bool QCopChannel::send(const QString& channel, const QString& msg,
- const QByteArray &data)
-{
- if (!qt_fbdpy) {
- qFatal("QCopChannel::send: Must construct a QApplication "
- "before using QCopChannel");
- return false;
- }
-
- qt_fbdpy->sendMessage(channel, msg, data);
-
- return true;
-}
-
-/*!
- \since 4.2
-
- Flushes all queued messages to the registered listeners.
-
- Note that this function returns false if no QApplication has been
- constructed, otherwise it returns true.
-
- \sa send()
-
-*/
-bool QCopChannel::flush()
-{
- if (!qt_fbdpy) {
- qFatal("QCopChannel::flush: Must construct a QApplication "
- "before using QCopChannel");
- return false;
- }
-
- qt_fbdpy->flushCommands();
-
- return true;
-}
-
-class QWSServerSignalBridge : public QObject {
- Q_OBJECT
-
-public:
- void emitNewChannel(const QString& channel);
- void emitRemovedChannel(const QString& channel);
-
- signals:
- void newChannel(const QString& channel);
- void removedChannel(const QString& channel);
-};
-
-void QWSServerSignalBridge::emitNewChannel(const QString& channel){
- emit newChannel(channel);
-}
-
-void QWSServerSignalBridge::emitRemovedChannel(const QString& channel) {
- emit removedChannel(channel);
-}
-
-/*!
- \internal
- Server side: subscribe client \a cl on channel \a ch.
-*/
-
-void QCopChannel::registerChannel(const QString& ch, QWSClient *cl)
-{
- if (!qcopServerMap)
- qcopServerMap = new QCopServerMap;
-
- // do we need a new channel list ?
- QCopServerMap::Iterator it = qcopServerMap->find(ch);
- if (it == qcopServerMap->end())
- it = qcopServerMap->insert(ch, QList<QWSClient*>());
-
- // If the channel name contains wildcard characters, then we also
- // register it on the server regexp matching list.
- if (containsWildcards( ch )) {
- QCopServerRegexp item(ch, cl);
- if (!qcopServerRegexpList)
- qcopServerRegexpList = new QCopServerRegexpList;
- qcopServerRegexpList->append( item );
- }
-
- // If this is the first client in the channel, announce the channel as being created.
- if (it.value().count() == 0) {
- QWSServerSignalBridge* qwsBridge = new QWSServerSignalBridge();
- connect(qwsBridge, SIGNAL(newChannel(QString)), qwsServer, SIGNAL(newChannel(QString)));
- qwsBridge->emitNewChannel(ch);
- delete qwsBridge;
- }
-
- it.value().append(cl);
-}
-
-/*!
- \internal
- Server side: unsubscribe \a cl from all channels.
-*/
-
-void QCopChannel::detach(QWSClient *cl)
-{
- if (!qcopServerMap)
- return;
-
- QCopServerMap::Iterator it = qcopServerMap->begin();
- for (; it != qcopServerMap->end(); ++it) {
- if (it.value().contains(cl)) {
- it.value().removeAll(cl);
- // If this was the last client in the channel, announce the channel as dead.
- if (it.value().count() == 0) {
- QWSServerSignalBridge* qwsBridge = new QWSServerSignalBridge();
- connect(qwsBridge, SIGNAL(removedChannel(QString)), qwsServer, SIGNAL(removedChannel(QString)));
- qwsBridge->emitRemovedChannel(it.key());
- delete qwsBridge;
- }
- }
- }
-
- if (!qcopServerRegexpList)
- return;
-
- QCopServerRegexpList::Iterator it2 = qcopServerRegexpList->begin();
- while(it2 != qcopServerRegexpList->end()) {
- if ((*it2).client == cl)
- it2 = qcopServerRegexpList->erase(it2);
- else
- ++it2;
- }
-}
-
-/*!
- \internal
- Server side: transmit the message to all clients registered to the
- specified channel.
-*/
-
-void QCopChannel::answer(QWSClient *cl, const QString& ch,
- const QString& msg, const QByteArray &data)
-{
- // internal commands
- if (ch.isEmpty()) {
- if (msg == QLatin1String("isRegistered()")) {
- QString c;
- QDataStream s(data);
- s >> c;
- bool known = qcopServerMap && qcopServerMap->contains(c)
- && !((*qcopServerMap)[c]).isEmpty();
- // Yes, it's a typo, it's not user-visible, and we choose not to fix it for compatibility
- QLatin1String ans = QLatin1String(known ? "known" : "unknown");
- QWSServerPrivate::sendQCopEvent(cl, QLatin1String(""),
- ans, data, true);
- return;
- } else if (msg == QLatin1String("detach()")) {
- QString c;
- QDataStream s(data);
- s >> c;
- Q_ASSERT(qcopServerMap);
- QCopServerMap::Iterator it = qcopServerMap->find(c);
- if (it != qcopServerMap->end()) {
- //Q_ASSERT(it.value().contains(cl));
- it.value().removeAll(cl);
- if (it.value().isEmpty()) {
- // If this was the last client in the channel, announce the channel as dead
- QWSServerSignalBridge* qwsBridge = new QWSServerSignalBridge();
- connect(qwsBridge, SIGNAL(removedChannel(QString)), qwsServer, SIGNAL(removedChannel(QString)));
- qwsBridge->emitRemovedChannel(it.key());
- delete qwsBridge;
- qcopServerMap->erase(it);
- }
- }
- if (qcopServerRegexpList && containsWildcards(c)) {
- // Remove references to a wildcarded channel.
- QCopServerRegexpList::Iterator it
- = qcopServerRegexpList->begin();
- while(it != qcopServerRegexpList->end()) {
- if ((*it).client == cl && (*it).channel == c)
- it = qcopServerRegexpList->erase(it);
- else
- ++it;
- }
- }
- return;
- }
- qWarning("QCopChannel: unknown internal command %s", qPrintable(msg));
- QWSServerPrivate::sendQCopEvent(cl, QLatin1String(""),
- QLatin1String("bad"), data);
- return;
- }
-
- if (qcopServerMap) {
- QList<QWSClient*> clist = qcopServerMap->value(ch);
- for (int i=0; i < clist.size(); ++i) {
- QWSClient *c = clist.at(i);
- QWSServerPrivate::sendQCopEvent(c, ch, msg, data);
- }
- }
-
- if(qcopServerRegexpList && !containsWildcards(ch)) {
- // Search for wildcard matches and forward the message on.
- QCopServerRegexpList::ConstIterator it = qcopServerRegexpList->constBegin();
- for (; it != qcopServerRegexpList->constEnd(); ++it) {
- if ((*it).regexp.exactMatch(ch)) {
- QByteArray newData;
- {
- QDataStream stream
- (&newData, QIODevice::WriteOnly | QIODevice::Append);
- stream << ch;
- stream << msg;
- stream << data;
- // Stream is flushed and closed at this point.
- }
- QWSServerPrivate::sendQCopEvent
- ((*it).client, (*it).channel,
- QLatin1String("forwardedMessage(QString,QString,QByteArray)"),
- newData);
- }
- }
- }
-}
-
-/*!
- \internal
- Client side: distribute received event to the QCop instance managing the
- channel.
-*/
-void QCopChannel::sendLocally(const QString& ch, const QString& msg,
- const QByteArray &data)
-{
- Q_ASSERT(qcopClientMap);
-
- // filter out internal events
- if (ch.isEmpty())
- return;
-
- // feed local clients with received data
- QList< QPointer<QCopChannel> > clients;
- {
- QMutexLocker locker(qcopClientMapMutex());
- clients = (*qcopClientMap)[ch];
- }
- for (int i = 0; i < clients.size(); ++i) {
- QCopChannel *channel = (QCopChannel *)clients.at(i);
- if ( channel )
- channel->receive(msg, data);
- }
-}
-
-QT_END_NAMESPACE
-
-#include "qcopchannel_qws.moc"
-
-#endif
diff --git a/src/gui/embedded/qcopchannel_qws.h b/src/gui/embedded/qcopchannel_qws.h
deleted file mode 100644
index 5f018662c7..0000000000
--- a/src/gui/embedded/qcopchannel_qws.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QCOPCHANNEL_QWS_H
-#define QCOPCHANNEL_QWS_H
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_COP
-
-class QWSClient;
-class QCopChannelPrivate;
-
-class Q_GUI_EXPORT QCopChannel : public QObject
-{
- Q_OBJECT
-public:
- explicit QCopChannel(const QString& channel, QObject *parent=0);
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QCopChannel(const QString& channel, QObject *parent, const char *name);
-#endif
- virtual ~QCopChannel();
-
- QString channel() const;
-
- static bool isRegistered(const QString& channel);
- static bool send(const QString& channel, const QString& msg);
- static bool send(const QString& channel, const QString& msg,
- const QByteArray &data);
-
- static bool flush();
-
- static void sendLocally( const QString& ch, const QString& msg,
- const QByteArray &data);
- static void reregisterAll();
-
- virtual void receive(const QString& msg, const QByteArray &data);
-
-Q_SIGNALS:
- void received(const QString& msg, const QByteArray &data);
-
-private:
- void init(const QString& channel);
-
- // server side
- static void registerChannel(const QString& ch, QWSClient *cl);
- static void detach(QWSClient *cl);
- static void answer(QWSClient *cl, const QString& ch,
- const QString& msg, const QByteArray &data);
- // client side
- QCopChannelPrivate* d;
-
- friend class QWSServer;
- friend class QWSServerPrivate;
- friend class QApplication;
-};
-
-#endif // QT_NO_COP
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QCOPCHANNEL_QWS_H
diff --git a/src/gui/embedded/qdecoration_qws.cpp b/src/gui/embedded/qdecoration_qws.cpp
deleted file mode 100644
index 7e93407c08..0000000000
--- a/src/gui/embedded/qdecoration_qws.cpp
+++ /dev/null
@@ -1,404 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdecoration_qws.h"
-
-#include "qapplication.h"
-#include "qdrawutil.h"
-#include "qpainter.h"
-#include "qregion.h"
-#include "qwhatsthis.h"
-
-#include "qmenu.h"
-#include "private/qwidget_p.h"
-#include "qwsmanager_qws.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QDecoration
- \ingroup qws
-
- \brief The QDecoration class is a base class for window
- decorations in Qt for Embedded Linux
-
- Note that this class is non-portable and only available in
- \l{Qt for Embedded Linux}.
-
- \l{Qt for Embedded Linux} provides window management of top level windows
- and several ready made decorations (i.e., \c Default, \c Styled
- and \c Windows). Custom decorations can be implemented by
- subclassing the QDecoration class and creating a decoration plugin
- (derived from QDecorationPlugin). The default
- implementation of the QDecorationFactory class will automatically
- detect the plugin, and load the decoration into the application at
- run-time using Qt's \l {How to Create Qt Plugins}{plugin
- system}. To actually apply a decoration, use the
- QApplication::qwsSetDecoration() function.
-
- When creating a custom decoration, implement the paint() function
- to paint the border and title decoration, and the region()
- function to return the regions the decoration
- occupies. Reimplement the regionClicked() and
- regionDoubleClicked() functions to respond to mouse clicks (the
- default implementations responds to (single) clicks on items in a
- widget's system menu and double clicks on a widget's title).
-
- QDecoration provides the DecorationRegion enum that describes the
- various regions of the window decoration, and the regionAt()
- function to determine the region containing a given point. The
- QDecoration class also provides the DecorationState enum
- describing the state of a given region, e.g. whether it is active
- or not.
-
- In addition, it is possible to build the system menu for a given
- top level widget using the buildSysMenu() function; whenever an
- action in this menu is triggered, the menuTriggered() function is
- called automatically.
-
- Finally, the QDecoration class provides a couple of static
- functions, startMove() and startResize(), which start a move or
- resize action by making the appropriate decoration region active
- and grabbing the mouse input.
-
- \sa QDecorationFactory, QDecorationPlugin, {Qt for Embedded Linux
- Architecture}
-*/
-
-/*!
- \fn QDecoration::QDecoration()
-
- Constructs a decoration object.
-*/
-
-/*!
- \fn QDecoration::~QDecoration()
-
- Destroys this decoration object.
-*/
-
-/*!
- \enum QDecoration::DecorationRegion
-
- This enum describes the various regions of the window decoration.
-
- \value All The entire region used by the window decoration.
-
- \value Top The top border used to vertically resize the window.
- \value Bottom The bottom border used to vertically resize the window.
- \value Left The left border used to horizontally resize the window.
- \value Right The right border used to horizontally resize the window.
- \value TopLeft The top-left corner of the window used to resize the
- window both horizontally and vertically.
- \value TopRight The top-right corner of the window used to resize the
- window both horizontally and vertically.
- \value BottomLeft The bottom-left corner of the window used to resize the
- window both horizontally and vertically.
- \value BottomRight The bottom-right corner of the window used to resize the
- window both horizontally and vertically.
- \value Borders All the regions used to describe the window's borders.
-
- \value Title The region containing the window title, used
- to move the window by dragging with the mouse cursor.
- \value Close The region occupied by the close button. Clicking in this
- region closes the window.
- \value Minimize The region occupied by the minimize button. Clicking in
- this region minimizes the window.
- \value Maximize The region occupied by the maximize button. Clicking in
- this region maximizes the window.
- \value Normalize The region occupied by a button used to restore a window's
- normal size. Clicking in this region restores a maximized
- window to its previous size. The region used for this
- button is often also the Maximize region.
- \value Menu The region occupied by the window's menu button. Clicking
- in this region opens the window operations (system) menu.
- \value Help The region occupied by the window's help button. Clicking
- in this region causes the context-sensitive help function
- to be enabled.
- \value Resize The region used to resize the window.
- \value Move The region used to move the window.
- \value None No region.
-
- \sa region(), regionAt(), DecorationState
-*/
-
-/*!
- \enum QDecoration::DecorationState
-
- This enum describes the various states of a decoration region.
-
- \value Normal The region is active
- \value Disabled The region is inactive.
- \value Hover The cursor is hovering over the region.
- \value Pressed The region is pressed.
-
- \sa paint(), DecorationRegion
-*/
-
-/*!
- \fn QRegion QDecoration::region(const QWidget *widget, const QRect & rectangle, int decorationRegion)
-
- Implement this function to return the region specified by \a
- decorationRegion for the given top level \a widget.
-
- The \a rectangle parameter specifies the rectangle the decoration
- is wrapped around. The \a decorationRegion is a bitmask of the
- values described by the DecorationRegion enum.
-
- \sa regionAt(), paint()
-*/
-
-/*!
- \fn QRegion QDecoration::region(const QWidget *widget, int decorationRegion)
- \overload
-*/
-
-/*!
- \fn bool QDecoration::paint(QPainter *painter, const QWidget *widget, int decorationRegion,
- DecorationState state)
-
- Implement this function to paint the border and title decoration
- for the specified top level \a widget using the given \a painter
- and decoration \a state. The specified \a decorationRegion is a
- bitmask of the values described by the DecorationRegion enum.
-
- Note that \l{Qt for Embedded Linux} expects this function to return true if
- any of the widget's decorations are repainted; otherwise it should
- return false.
-
- \sa region()
-*/
-
-/*!
- \fn int QDecoration::regionAt(const QWidget *widget, const QPoint &point)
-
- Returns the type of the first region of the specified top level \a
- widget containing the given \a point.
-
- The return value is one of the DecorationRegion enum's values. Use
- the region() function to retrieve the actual region. If none of
- the widget's regions contain the point, this function returns \l
- None.
-
- \sa region()
-*/
-int QDecoration::regionAt(const QWidget *w, const QPoint &point)
-{
- int regions[] = {
- TopLeft, Top, TopRight, Left, Right, BottomLeft, Bottom, BottomRight, // Borders first
- Menu, Title, Help, Minimize, Normalize, Maximize, Close, // then buttons
- None
- };
-
-// char *regions_str[] = {
-// "TopLeft", "Top", "TopRight", "Left", "Right", "BottomLeft", "Bottom", "BottomRight",
-// "Menu", "Title", "Help", "Minimize", "Normalize", "Maximize", "Close",
-// "None"
-// };
-
- // First check to see if within all regions at all
- QRegion reg = region(w, w->geometry(), All);
- if (!reg.contains(point)) {
- return None;
- }
-
- int i = 0;
- while (regions[i]) {
- reg = region(w, w->geometry(), regions[i]);
- if (reg.contains(point)) {
-// qDebug("In region %s", regions_str[i]);
- return regions[i];
- }
- ++i;
- }
- return None;
-}
-
-#ifndef QT_NO_MENU
-/*!
- Builds the system menu for the given top level \a widget, adding
- \gui Restore, \gui Move, \gui Size, \gui Minimize, \gui Maximize
- and \gui Close actions to the given \a menu.
-
- \sa menuTriggered()
-*/
-void QDecoration::buildSysMenu(QWidget *widget, QMenu *menu)
-{
- QDecorationAction *act = new QDecorationAction(QLatin1String("Restore"),
- menu, Maximize);
- act->setEnabled(widget->windowState() & Qt::WindowMaximized);
- menu->addAction(act);
- act = new QDecorationAction(QLatin1String("Move"), menu, Move);
- act->setEnabled(!(widget->windowState() & Qt::WindowMaximized));
- menu->addAction(act);
- menu->addAction(new QDecorationAction(QLatin1String("Size"), menu, Resize));
- act = new QDecorationAction(QLatin1String("Minimize"), menu, Minimize);
- menu->addAction(act);
- act = new QDecorationAction(QLatin1String("Maximize"), menu, Maximize);
- act->setDisabled(widget->windowState() & Qt::WindowMaximized);
- menu->addAction(act);
- menu->addSeparator();
- menu->addAction(new QDecorationAction(QLatin1String("Close"), menu, Close));
-}
-
-/*!
- This function is called whenever an action in a top level widget's
- menu is triggered, and simply calls the regionClicked() function
- passing the \a widget and \a action parameters as arguments.
-
- \sa buildSysMenu()
-*/
-void QDecoration::menuTriggered(QWidget *widget, QAction *action)
-{
- QDecorationAction *decAction = static_cast<QDecorationAction *>(action);
- regionClicked(widget, decAction->reg);
-}
-#endif // QT_NO_MENU
-
-/*!
- \fn void QDecoration::regionClicked(QWidget *widget, int region)
-
- Handles the event that the specified \a region in the given top
- level \a widget is activated by a single click (the \a region
- parameter is described using the DecorationRegion enum).
-
- This function is called whenever a region in a top level widget is
- clicked; the default implementation responds to clicks on items in
- the system menu, performing the requested actions.
-
- \sa regionDoubleClicked(), region()
-*/
-void QDecoration::regionClicked(QWidget *widget, int reg)
-{
- switch(reg) {
- case Move:
- startMove(widget);
- break;
- case Resize:
- startResize(widget);
- break;
- case Help:
-#ifndef QT_NO_WHATSTHIS
- if (QWhatsThis::inWhatsThisMode())
- QWhatsThis::leaveWhatsThisMode();
- else
- QWhatsThis::enterWhatsThisMode();
-#endif
- break;
- case Close:
- widget->close();
- break;
- case Normalize:
- widget->showNormal();
- break;
- case Maximize:
- if (widget->windowState() & Qt::WindowMaximized)
- widget->showNormal();
- else
- widget->showMaximized();
- break;
- }
-}
-
-/*!
- \fn void QDecoration::regionDoubleClicked(QWidget *widget, int region)
-
- Handles the event that the specified \a region in the given top
- level \a widget is activated by a double click (the region
- parameter is described using the DecorationRegion enum).
-
- This function is called whenever a region in a top level widget is
- double clicked; the default implementation responds to a double
- click on the widget's title, toggling its size between the maximum
- and its normal size.
-
- \sa regionClicked(), region()
-*/
-void QDecoration::regionDoubleClicked(QWidget *widget, int reg)
-{
- switch(reg)
- {
- case Title: {
- if (widget->windowState() & Qt::WindowMaximized)
- widget->showNormal();
- else
- widget->showMaximized();
- break;
- }
- }
-}
-
-/*!
- Starts to move the given top level \a widget by making its \l
- Title region active and grabbing the mouse input.
-
- \sa startResize()
-*/
-void QDecoration::startMove(QWidget *widget)
-{
-#ifdef QT_NO_QWS_MANAGER
- Q_UNUSED(widget);
-#else
- QWSManager *manager = widget->d_func()->topData()->qwsManager;
- if (manager)
- manager->startMove();
-#endif
-}
-
-/*!
- Starts to resize the given top level \a widget by making its \l
- BottomRight region active and grabbing the mouse input.
-
- \sa startMove()
-*/
-void QDecoration::startResize(QWidget *widget)
-{
-#ifdef QT_NO_QWS_MANAGER
- Q_UNUSED(widget);
-#else
- QWSManager *manager = widget->d_func()->topData()->qwsManager;
- if (manager)
- manager->startResize();
-#endif
-}
-
-
-QT_END_NAMESPACE
diff --git a/src/gui/embedded/qdecoration_qws.h b/src/gui/embedded/qdecoration_qws.h
deleted file mode 100644
index 979e15f07d..0000000000
--- a/src/gui/embedded/qdecoration_qws.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECORATION_QWS_H
-#define QDECORATION_QWS_H
-
-#include <QtGui/qregion.h>
-#include <QtGui/qwidget.h>
-#include <QtGui/qaction.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QPopupMenu;
-class QMenu;
-
-#ifndef QT_NO_ACTION
-class QDecorationAction : public QAction
-{
-public:
- QDecorationAction(const QString &text, QObject* parent, int region)
- : QAction(text, parent), reg(region) {}
- int reg;
-};
-#endif // QT_NO_ACTION
-
-/*
- Implements decoration styles
-*/
-class Q_GUI_EXPORT QDecoration
-{
-public:
- QDecoration() {}
- virtual ~QDecoration() {}
-
- /* AABBBBBBBBBBCC Items in DecorationRegion:
- AijjjjjjjklmnC
- A C A = TopLeft B = Top C = TopRight
- D E D = Left E = Right
- D E F = BottomLeft H = Bottom G = BottomRight
- F G i = Menu j = Title k = Help
- FFHHHHHHHHHHGG l = Minimize m = Maximize n = Close
-
- */
-
- enum DecorationRegion {
- None = 0x0000000000, All = 0x7fffffff,
- TopLeft = 0x0000000001, Top = 0x0000000002, TopRight = 0x0000000004,
- Left = 0x0000000008, Right = 0x0000000010,
- BottomLeft = 0x0000000020, Bottom = 0x0000000040, BottomRight = 0x0000000080,
- Borders = 0x00000000ff,
- Menu = 0x0000000100, Title = 0x0000000200, Help = 0x0000000400,
- Minimize = 0x0000000800, Maximize = 0x0000001000, Normalize = 0x0000002000,
- Close = 0x0000004000, Move = 0x0000008000, Resize = 0x0000010000
- };
-
- enum DecorationState { Normal = 0x04, Disabled = 0x08, Hover = 0x01, Pressed = 0x02 };
-
- virtual QRegion region(const QWidget *w, const QRect &rect, int decorationRegion = All ) = 0;
- QRegion region(const QWidget *w, int decorationRegion = All )
- { return region(w, w->rect(), decorationRegion); }
- virtual int regionAt(const QWidget *w, const QPoint &point);
-
- virtual void regionClicked(QWidget *widget, int region);
- virtual void regionDoubleClicked(QWidget *widget, int region);
-#ifndef QT_NO_MENU
- virtual void buildSysMenu(QWidget *widget, QMenu *menu);
- void menuTriggered(QWidget *widget, QAction *action);
-#endif
-
- static void startMove(QWidget *widget);
- static void startResize(QWidget *widget);
-
- virtual bool paint(QPainter *p, const QWidget *w, int decorationRegion = All,
- DecorationState state = Normal) = 0;
-
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECORATION_QWS_H
diff --git a/src/gui/embedded/qdecorationdefault_qws.cpp b/src/gui/embedded/qdecorationdefault_qws.cpp
deleted file mode 100644
index b87ac3223d..0000000000
--- a/src/gui/embedded/qdecorationdefault_qws.cpp
+++ /dev/null
@@ -1,803 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qapplication.h>
-#include <qwidget.h>
-#include <qpainter.h>
-#include <qpaintengine.h>
-#include <qdrawutil.h>
-#include "qdecorationdefault_qws.h"
-
-QT_BEGIN_NAMESPACE
-
-#if !defined(QT_NO_QWS_DECORATION_DEFAULT) || defined(QT_PLUGIN)
-
-QPixmap *QDecorationDefault::staticHelpPixmap = 0;
-QPixmap *QDecorationDefault::staticMenuPixmap = 0;
-QPixmap *QDecorationDefault::staticClosePixmap = 0;
-QPixmap *QDecorationDefault::staticMinimizePixmap = 0;
-QPixmap *QDecorationDefault::staticMaximizePixmap = 0;
-QPixmap *QDecorationDefault::staticNormalizePixmap = 0;
-
-#ifndef QT_NO_IMAGEFORMAT_XPM
-
-/* XPM */
-static const char * const default_menu_xpm[] = {
-/* width height ncolors chars_per_pixel */
-"16 16 11 1",
-/* colors */
-" c #000000",
-". c #336600",
-"X c #666600",
-"o c #99CC00",
-"O c #999933",
-"+ c #333300",
-"@ c #669900",
-"# c #999900",
-"$ c #336633",
-"% c #666633",
-"& c #99CC33",
-/* pixels */
-"oooooooooooooooo",
-"oooooooooooooooo",
-"ooooo#.++X#ooooo",
-"ooooX Xoooo",
-"oooX XO#% X&oo",
-"oo# Ooo&@O Ooo",
-"oo. Xoo#+ @X Xoo",
-"oo+ OoO+ +O# +oo",
-"oo+ #O+ +## +oo",
-"oo. %@ ++ +. Xoo",
-"oo# O@OO+ #oo",
-"oooX X##$ Ooo",
-"ooooX Xoo",
-"oooo&OX++X#OXooo",
-"oooooooooooooooo",
-"oooooooooooooooo"
-};
-
-static const char * const default_help_xpm[] = {
-"16 16 3 1",
-" s None c None",
-". c #ffffff",
-"X c #707070",
-" ",
-" ",
-" ...... ",
-" ..XXXXXX ",
-" .XX .XX ",
-" .XX .XX ",
-" ..XX ",
-" ..XX ",
-" ..XX ",
-" .XX ",
-" .XX ",
-" .. ",
-" .XX ",
-" .XX ",
-" ",
-" "};
-
-static const char * const default_close_xpm[] = {
-"16 16 3 1",
-" s None c None",
-". c #ffffff",
-"X c #707070",
-" ",
-" ",
-" .X .X ",
-" .XX .XX ",
-" .XX .XX ",
-" .XX .XX ",
-" .XX.XX ",
-" .XXX ",
-" .XXX ",
-" .XX.XX ",
-" .XX .XX ",
-" .XX .XX ",
-" .XX .XX ",
-" .X .X ",
-" ",
-" "};
-
-static const char * const default_maximize_xpm[] = {
-"16 16 3 1",
-" s None c None",
-". c #ffffff",
-"X c #707070",
-" ",
-" ",
-" ........... ",
-" .XXXXXXXXXX ",
-" .X .X ",
-" .X .X ",
-" .X .X ",
-" .X .X ",
-" .X .X ",
-" .X .X ",
-" .X .X ",
-" .X........X ",
-" .XXXXXXXXXX ",
-" ",
-" ",
-" "};
-
-static const char * const default_minimize_xpm[] = {
-"16 16 3 1",
-" s None c None",
-". c #ffffff",
-"X c #707070",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ... ",
-" . X ",
-" .XX ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" "};
-
-static const char * const default_normalize_xpm[] = {
-"16 16 3 1",
-" s None c None",
-". c #ffffff",
-"X c #707070",
-" ",
-" ",
-" ........ ",
-" .XXXXXXXX ",
-" .X .X ",
-" .X .X ",
-" ....X... .X ",
-" .XXXXXXXX .X ",
-" .X .XXXX ",
-" .X .X ",
-" .X .X ",
-" .X......X ",
-" .XXXXXXXX ",
-" ",
-" ",
-" "};
-
-#endif // QT_NO_IMAGEFORMAT_XPM
-
-/*!
- \class QDecorationDefault
- \since 4.4
- \ingroup qws
- \brief The QDecorationDefault class is a base class providing default window decorations.
-
- See the documentation for class QDecoration for a detailed
- description. This subclass of QDecoration provides standard
- icons for the decoration regions.
-
- Note that this class is non-portable and only available in
- \l{Qt for Embedded Linux}.
- */
-
-/*!
- Default constructor.
- */
-QDecorationDefault::QDecorationDefault()
- : QDecoration()
-{
- menu_width = 20;
- help_width = 20;
- close_width = 20;
- minimize_width = 20;
- maximize_width = 20;
- normalize_width = 20;
-}
-
-/*!
- The constructor deletes the static pixmaps.
- */
-QDecorationDefault::~QDecorationDefault()
-{
- delete staticMenuPixmap;
- delete staticClosePixmap;
- delete staticMinimizePixmap;
- delete staticMaximizePixmap;
- delete staticNormalizePixmap;
-
- // This makes it safe to delete and then create a QDecorationDefault
- staticMenuPixmap = 0;
- staticClosePixmap = 0;
- staticMinimizePixmap = 0;
- staticMaximizePixmap = 0;
- staticNormalizePixmap = 0;
-}
-
-/*!
- \fn const char **QDecorationDefault::xpmForRegion(int region)
-
- Returns a pointer to the X pixmap for the icon specified by
- \a region. An X pixmap is an ASCII-text-based image. The value
- of \a region must be one of a subset of the values of enum
- DecorationRegion. The supported values are \e Help, \e Menu,
- \e Close, \e Minimize, \e Maximize, and \e Normalize. Other
- values of \a region cause zero to be returned.
-
- \sa QDecoration::DecorationRegion
- */
-const char **QDecorationDefault::xpmForRegion(int reg)
-{
-#ifdef QT_NO_IMAGEFORMAT_XPM
- Q_UNUSED(reg);
-#else
- switch(reg)
- {
- case Help:
- return (const char **)default_help_xpm;
- case Menu:
- return (const char **)default_menu_xpm;
- case Close:
- return (const char **)default_close_xpm;
- case Minimize:
- return (const char **)default_minimize_xpm;
- case Maximize:
- return (const char **)default_maximize_xpm;
- case Normalize:
- return (const char **)default_normalize_xpm;
- }
-#endif
- return 0;
-}
-
-/*!
- \fn QPixmap QDecorationDefault::pixmapFor(const QWidget *widget,
- int decorationRegion, int &xoff, int &yoff)
-
- Returns a pointer to the QPixmap for the widget specified by \a widget and
- \a decorationRegion. The returned QPixmap is constructed from the default
- X pixmap obtained from xpmForRegion().
-
- \a xoff and \a yoff specify the offset for the pixmap.
-
- The value of \a decorationRegion must be one of a subset of the values
- of enum DecorationRegion. The supported values are \e Help,
- \e Menu, \e Close, \e Minimize, \e Maximize, and \e Normalize.
- Other values of \a decorationRegion return 0.
-
- \sa QDecoration::DecorationRegion
-*/
-QPixmap QDecorationDefault::pixmapFor(const QWidget *widget,
- int decorationRegion,
- int &xoff,
- int &/*yoff*/)
-{
-#ifdef QT_NO_IMAGEFORMAT_XPM
- Q_UNUSED(widget);
- Q_UNUSED(decorationRegion);
- Q_UNUSED(xoff);
- return QPixmap();
-#else
- static const char **staticHelpPixmapXPM = 0;
- static const char **staticMenuPixmapXPM = 0;
- static const char **staticClosePixmapXPM = 0;
- static const char **staticMinimizePixmapXPM = 0;
- static const char **staticMaximizePixmapXPM = 0;
- static const char **staticNormalizePixmapXPM = 0;
- const char **xpm;
-
- // Why don't we just use/extend the enum type...
-
- if (staticHelpPixmapXPM != (xpm = xpmForRegion(Help)) || !staticHelpPixmap) {
- staticHelpPixmapXPM = xpm;
- staticHelpPixmap = new QPixmap(xpm);
- }
- if (staticMenuPixmapXPM != (xpm = xpmForRegion(Menu)) || !staticMenuPixmap) {
- staticMenuPixmapXPM = xpm;
- staticMenuPixmap = new QPixmap(xpm);
- }
- if (staticClosePixmapXPM != (xpm = xpmForRegion(Close)) || !staticClosePixmap) {
- staticClosePixmapXPM = xpm;
- staticClosePixmap = new QPixmap(xpm);
- }
- if (staticMinimizePixmapXPM != (xpm = xpmForRegion(Minimize)) || !staticMinimizePixmap) {
- staticMinimizePixmapXPM = xpm;
- staticMinimizePixmap = new QPixmap(xpm);
- }
- if (staticMaximizePixmapXPM != (xpm = xpmForRegion(Maximize)) || !staticMaximizePixmap) {
- staticMaximizePixmapXPM = xpm;
- staticMaximizePixmap = new QPixmap(xpm);
- }
- if (staticNormalizePixmapXPM != (xpm = xpmForRegion(Normalize)) || !staticNormalizePixmap) {
- staticNormalizePixmapXPM = xpm;
- staticNormalizePixmap = new QPixmap(xpm);
- }
-
- const QPixmap *pm = 0;
-
- switch (decorationRegion) {
- case Help:
- pm = staticHelpPixmap;
- break;
- case Menu:
- if (!widget->windowIcon().isNull())
- return widget->windowIcon().pixmap(16,16); //##### QIcon::pixmap() needs a size !!!!!!"
- if (!pm) {
- xoff = 1;
- pm = staticMenuPixmap;
- }
- break;
- case Close:
- pm = staticClosePixmap;
- break;
- case Maximize:
- pm = staticMaximizePixmap;
- break;
- case Normalize:
- pm = staticNormalizePixmap;
- break;
- case Minimize:
- pm = staticMinimizePixmap;
- break;
- default:
- break;
- }
- return *pm;
-#endif
-}
-
-/*!
- \fn int QDecorationDefault::titleBarHeight(const QWidget *widget)
-
- Returns the title bar height in pixels for the given \a widget. It is the
- greater of 20, or the sum of the application font's line spacing value
- plus a border width fudge factor.
-*/
-int QDecorationDefault::titleBarHeight(const QWidget *)
-{
- return qMax(20, QApplication::fontMetrics().height() + BORDER_WIDTH);
-}
-
-/*!
- Returns the region specified by \a decorationRegion for the
- top-level \a widget. \a rect specifies the rectangle the decoration
- wraps. The value of \a decorationRegion is a combination of the
- bitmask values of enum DecorationRegion.
- */
-QRegion QDecorationDefault::region(const QWidget *widget,
- const QRect &rect,
- int decorationRegion)
-{
- Qt::WindowFlags flags = widget->windowFlags();
- bool hasBorder = !widget->isMaximized();
- bool hasTitle = flags & Qt::WindowTitleHint;
- bool hasSysMenu = flags & Qt::WindowSystemMenuHint;
- bool hasContextHelp = flags & Qt::WindowContextHelpButtonHint;
- bool hasMinimize = flags & Qt::WindowMinimizeButtonHint;
- bool hasMaximize = flags & Qt::WindowMaximizeButtonHint;
- int state = widget->windowState();
- bool isMinimized = state & Qt::WindowMinimized;
- bool isMaximized = state & Qt::WindowMaximized;
-
- int titleHeight = hasTitle ? titleBarHeight(widget) : 0;
- int bw = hasBorder ? BORDER_WIDTH : 0;
- int bbw = hasBorder ? BOTTOM_BORDER_WIDTH : 0;
-
- QRegion region;
- switch (decorationRegion) {
- case All: {
- QRect r(rect.left() - bw,
- rect.top() - titleHeight - bw,
- rect.width() + 2 * bw,
- rect.height() + titleHeight + bw + bbw);
- region = r;
- region -= rect;
- }
- break;
-
- case Title: {
- QRect r(rect.left()
- + (hasSysMenu ? menu_width : 0),
- rect.top() - titleHeight,
- rect.width()
- - (hasSysMenu ? menu_width : 0)
- - close_width
- - (hasMaximize ? maximize_width : 0)
- - (hasMinimize ? minimize_width : 0)
- - (hasContextHelp ? help_width : 0),
-
- titleHeight);
- if (r.width() > 0)
- region = r;
- }
- break;
-
- case Top: {
- QRect r(rect.left() + CORNER_GRAB,
- rect.top() - titleHeight - bw,
- rect.width() - 2 * CORNER_GRAB,
- bw);
- region = r;
- }
- break;
-
- case Left: {
- QRect r(rect.left() - bw,
- rect.top() - titleHeight + CORNER_GRAB,
- bw,
- rect.height() + titleHeight - 2 * CORNER_GRAB);
- region = r;
- }
- break;
-
- case Right: {
- QRect r(rect.right() + 1,
- rect.top() - titleHeight + CORNER_GRAB,
- bw,
- rect.height() + titleHeight - 2 * CORNER_GRAB);
- region = r;
- }
- break;
-
- case Bottom: {
- QRect r(rect.left() + CORNER_GRAB,
- rect.bottom() + 1,
- rect.width() - 2 * CORNER_GRAB,
- bw);
- region = r;
- }
- break;
-
- case TopLeft: {
- QRect r1(rect.left() - bw,
- rect.top() - bw - titleHeight,
- CORNER_GRAB + bw,
- bw);
-
- QRect r2(rect.left() - bw,
- rect.top() - bw - titleHeight,
- bw,
- CORNER_GRAB + bw);
-
- region = QRegion(r1) + r2;
- }
- break;
-
- case TopRight: {
- QRect r1(rect.right() - CORNER_GRAB,
- rect.top() - bw - titleHeight,
- CORNER_GRAB + bw,
- bw);
-
- QRect r2(rect.right() + 1,
- rect.top() - bw - titleHeight,
- bw,
- CORNER_GRAB + bw);
-
- region = QRegion(r1) + r2;
- }
- break;
-
- case BottomLeft: {
- QRect r1(rect.left() - bw,
- rect.bottom() + 1,
- CORNER_GRAB + bw,
- bw);
-
- QRect r2(rect.left() - bw,
- rect.bottom() - CORNER_GRAB,
- bw,
- CORNER_GRAB + bw);
- region = QRegion(r1) + r2;
- }
- break;
-
- case BottomRight: {
- QRect r1(rect.right() - CORNER_GRAB,
- rect.bottom() + 1,
- CORNER_GRAB + bw,
- bw);
-
- QRect r2(rect.right() + 1,
- rect.bottom() - CORNER_GRAB,
- bw,
- CORNER_GRAB + bw);
- region = QRegion(r1) + r2;
- }
- break;
-
- case Menu: {
- if (hasSysMenu) {
- region = QRect(rect.left(), rect.top() - titleHeight,
- menu_width, titleHeight);
- }
- }
- break;
-
- case Help: {
- if (hasContextHelp) {
- QRect r(rect.right()
- - close_width
- - (hasMaximize ? maximize_width : 0)
- - (hasMinimize ? minimize_width : 0)
- - help_width + 1, rect.top() - titleHeight,
- help_width, titleHeight);
- if (r.left() > rect.left() + titleHeight)
- region = r;
- }
- }
- break;
-
-
- case Minimize: {
- if (hasMinimize && !isMinimized) {
- QRect r(rect.right() - close_width
- - (hasMaximize ? maximize_width : 0)
- - minimize_width + 1, rect.top() - titleHeight,
- minimize_width, titleHeight);
- if (r.left() > rect.left() + titleHeight)
- region = r;
- }
- }
- break;
-
- case Maximize: {
- if (hasMaximize && !isMaximized) {
- QRect r(rect.right() - close_width - maximize_width + 1,
- rect.top() - titleHeight, maximize_width, titleHeight);
- if (r.left() > rect.left() + titleHeight)
- region = r;
- }
- }
- break;
-
- case Normalize: {
- if (hasMinimize && isMinimized) {
- QRect r(rect.right() - close_width
- - (hasMaximize ? maximize_width : 0)
- - minimize_width + 1, rect.top() - titleHeight,
- minimize_width, titleHeight);
- if (r.left() > rect.left() + titleHeight)
- region = r;
- } else if (hasMaximize && isMaximized) {
- QRect r(rect.right() - close_width - maximize_width + 1,
- rect.top() - titleHeight, maximize_width, titleHeight);
- if (r.left() > rect.left() + titleHeight)
- region = r;
- }
- }
- break;
-
- case Close: {
- QRect r(rect.right() - close_width + 1, rect.top() - titleHeight,
- close_width, titleHeight);
- if (r.left() > rect.left() + titleHeight)
- region = r;
- }
- break;
-
- default: {
- int i = 1;
- while (i) {
- if (i & decorationRegion)
- region += this->region(widget, rect, i);
- i <<= 1;
- }
- }
- break;
- }
-
- return region;
-}
-
-/*!
- Paints the border and title decoration for the top-level \a widget
- using the \a painter provided and the decoration \a state. The value
- of \a decorationRegion is a combination of the bitmask values of
- enum DecorationRegion.
-
- Note that Qt for Embedded Linux expects this function to return true if any of
- the widget's decorations are repainted; otherwise it returns false.
- */
-bool QDecorationDefault::paint(QPainter *painter,
- const QWidget *widget,
- int decorationRegion,
- DecorationState state)
-{
- if (decorationRegion == None)
- return false;
-
- const QRect titleRect = QDecoration::region(widget, Title).boundingRect();
- const QPalette pal = QApplication::palette();
- int titleHeight = titleRect.height();
- int titleWidth = titleRect.width();
- QRegion oldClipRegion = painter->clipRegion();
-
-
- Qt::WindowFlags flags = widget->windowFlags();
- bool hasBorder = !widget->isMaximized();
- bool hasTitle = flags & Qt::WindowTitleHint;
- bool hasSysMenu = flags & Qt::WindowSystemMenuHint;
- bool hasContextHelp = flags & Qt::WindowContextHelpButtonHint;
- bool hasMinimize = flags & Qt::WindowMinimizeButtonHint;
- bool hasMaximize = flags & Qt::WindowMaximizeButtonHint;
-
- bool paintAll = (decorationRegion == int(All));
- bool handled = false;
-
- bool porterDuff = painter->paintEngine()->hasFeature(QPaintEngine::PorterDuff);
-
- if ((paintAll || decorationRegion & Borders) && state == Normal && hasBorder) {
- if (hasTitle) { // reduce flicker
- QRect rect(widget->rect());
- QRect r(rect.left(), rect.top() - titleHeight,
- rect.width(), titleHeight);
- painter->setClipRegion(oldClipRegion - r);
- }
- QRect br = QDecoration::region(widget).boundingRect();
- if (porterDuff)
- painter->setCompositionMode(QPainter::CompositionMode_Source);
- qDrawWinPanel(painter, br.x(), br.y(), br.width(),
- br.height(), pal, false,
- &pal.brush(QPalette::Window));
- if (porterDuff)
- painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
- handled |= true;
- }
-
- if ((paintAll || decorationRegion & Title && titleWidth > 0) && state == Normal && hasTitle) {
- painter->setClipRegion(oldClipRegion);
- QBrush titleBrush;
- QPen titlePen;
-
- if (widget == qApp->activeWindow()) {
- titleBrush = pal.brush(QPalette::Highlight);
- titlePen = pal.color(QPalette::HighlightedText);
- } else {
- titleBrush = pal.brush(QPalette::Window);
- titlePen = pal.color(QPalette::Text);
- }
-
- if (porterDuff)
- painter->setCompositionMode(QPainter::CompositionMode_Source);
- qDrawShadePanel(painter,
- titleRect.x(), titleRect.y(), titleRect.width(), titleRect.height(),
- pal, true, 1, &titleBrush);
- if (porterDuff)
- painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
-
- painter->setPen(titlePen);
- painter->drawText(titleRect.x() + 4, titleRect.y(),
- titleRect.width() - 8, titleRect.height(),
- Qt::AlignVCenter, windowTitleFor(widget));
- handled |= true;
- }
-
- if (state != Hover) {
- painter->setClipRegion(oldClipRegion);
- if ((paintAll || decorationRegion & Menu) && hasSysMenu) {
- paintButton(painter, widget, Menu, state, pal);
- handled |= true;
- }
-
- if ((paintAll || decorationRegion & Help) && hasContextHelp) {
- paintButton(painter, widget, Help, state, pal);
- handled |= true;
- }
-
- if ((paintAll || decorationRegion & Minimize) && hasMinimize) {
- paintButton(painter, widget, Minimize, state, pal);
- handled |= true;
- }
-
- if ((paintAll || decorationRegion & Maximize) && hasMaximize) {
- paintButton(painter, widget,
- ((widget->windowState() & Qt::WindowMaximized)? Normalize : Maximize),
- state, pal);
- handled |= true;
- }
-
- if (paintAll || decorationRegion & Close) {
- paintButton(painter, widget, Close, state, pal);
- handled |= true;
- }
- }
- return handled;
-}
-
-/*!
- \fn void QDecorationDefault::paintButton(QPainter *painter, const
- QWidget *widget, int buttonRegion, DecorationState state,
- const QPalette &palette)
-
- Paints a region of the top-level \a widget. The region is
- painted in the specified decoration \a state using the
- \a painter and \a palette provided. The region to be painted is specified
- by \a buttonRegion, which is a combination of the bitmask values of
- DecorationRegion. If the value of \a buttonRegion is one of \e Help,
- \e Menu, \e Close, \e Minimize, \e Maximize, and \e Normalize, the
- button pixmap for that region is painted.
-
- \sa pixmapFor()
- */
-void QDecorationDefault::paintButton(QPainter *painter,
- const QWidget *widget,
- int buttonRegion,
- DecorationState state,
- const QPalette &pal)
-{
- int xoff = 2;
- int yoff = 2;
-
- const QPixmap pm = pixmapFor(widget, buttonRegion, xoff, yoff);
- QRect brect(QDecoration::region(widget, buttonRegion).boundingRect());
- bool porterDuff = painter->paintEngine()->hasFeature(QPaintEngine::PorterDuff);
-
- if (state & QDecoration::Pressed) {
- if (porterDuff)
- painter->setCompositionMode(QPainter::CompositionMode_Source);
- qDrawWinPanel(painter, brect, pal, true, &pal.brush(QPalette::Window));
- if (porterDuff)
- painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
- ++xoff;
- ++yoff;
- } else {
- painter->fillRect(brect, pal.brush(QPalette::Window));
- }
-
- if (!pm.isNull())
- painter->drawPixmap(brect.x() + xoff, brect.y() + yoff, pm);
-}
-
-extern QString qt_setWindowTitle_helperHelper(const QString&, const QWidget*);
-
-/*!
- \internal
- */
-QString QDecorationDefault::windowTitleFor(const QWidget *widget) const
-{
- return qt_setWindowTitle_helperHelper(widget->windowTitle(), widget);
-}
-
-#endif // QT_NO_QWS_DECORATION_DEFAULT
-
-QT_END_NAMESPACE
diff --git a/src/gui/embedded/qdecorationdefault_qws.h b/src/gui/embedded/qdecorationdefault_qws.h
deleted file mode 100644
index a166220913..0000000000
--- a/src/gui/embedded/qdecorationdefault_qws.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECORATIONDEFAULT_QWS_H
-#define QDECORATIONDEFAULT_QWS_H
-
-#include <QtGui/qdecoration_qws.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if !defined(QT_NO_QWS_DECORATION_DEFAULT) || defined(QT_PLUGIN)
-
-#define CORNER_GRAB 16
-#define BORDER_WIDTH 4
-#define BOTTOM_BORDER_WIDTH BORDER_WIDTH
-
-class Q_GUI_EXPORT QDecorationDefault : public QDecoration
-{
-public:
- QDecorationDefault();
- virtual ~QDecorationDefault();
-
- virtual QRegion region(const QWidget *widget, const QRect &rect, int decorationRegion = All);
- virtual bool paint(QPainter *painter, const QWidget *widget, int decorationRegion = All,
- DecorationState state = Normal);
-
-protected:
- virtual int titleBarHeight(const QWidget *widget);
-
- virtual void paintButton(QPainter *painter, const QWidget *widget, int buttonRegion,
- DecorationState state, const QPalette &pal);
- virtual QPixmap pixmapFor(const QWidget *widget, int decorationRegion, int &xoff, int &yoff);
- virtual const char **xpmForRegion(int region);
-
- QString windowTitleFor(const QWidget *widget) const;
-
- int menu_width;
- int help_width;
- int close_width;
- int minimize_width;
- int maximize_width;
- int normalize_width;
-
-private:
- static QPixmap *staticHelpPixmap;
- static QPixmap *staticMenuPixmap;
- static QPixmap *staticClosePixmap;
- static QPixmap *staticMinimizePixmap;
- static QPixmap *staticMaximizePixmap;
- static QPixmap *staticNormalizePixmap;
-
-};
-
-
-QT_END_NAMESPACE
-#endif // QT_NO_QWS_DECORATION_DEFAULT
-QT_END_HEADER
-
-#endif // QDECORATIONDEFAULT_QWS_H
diff --git a/src/gui/embedded/qdecorationfactory_qws.cpp b/src/gui/embedded/qdecorationfactory_qws.cpp
deleted file mode 100644
index 2cae140ac0..0000000000
--- a/src/gui/embedded/qdecorationfactory_qws.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdecorationfactory_qws.h"
-#include "qdecorationplugin_qws.h"
-#include "private/qfactoryloader_p.h"
-#include "qmutex.h"
-
-#include "qapplication.h"
-#include "qdecorationdefault_qws.h"
-#include "qdecorationwindows_qws.h"
-#include "qdecorationstyled_qws.h"
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_LIBRARY
-Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
- (QDecorationFactoryInterface_iid,
- QLatin1String("/decorations"), Qt::CaseInsensitive))
-#endif
-
-
-
-/*!
- \class QDecorationFactory
- \ingroup qws
- \ingroup appearance
-
- \brief The QDecorationFactory class creates window decorations in
- Qt for Embedded Linux.
-
- Note that this class is only available in \l{Qt for Embedded Linux}.
-
- QDecorationFactory is used to detect and instantiate the available
- decorations, allowing \l{Qt for Embedded Linux} to load the preferred
- decoration into the application at runtime. The create() function
- returns a QDecoration object representing the decoration
- identified by a given key. The valid keys (i.e. the supported
- decorations) can be retrieved using the keys() function.
-
- \l{Qt for Embedded Linux} provides three built-in decorations: \c Default,
- \c Styled and \c Windows. In addition, custom decorations can be
- added using Qt's \l {How to Create Qt Plugins}{plugin mechanism},
- i.e. by subclassing the QDecoration class and creating a mouse
- driver plugin (QDecorationPlugin).
-
- \sa QDecoration, QDecorationPlugin
-*/
-
-/*!
- Creates the decoration specified by the given \a key. Note that
- the keys are case-insensitive.
-
- \sa keys()
-*/
-
-QDecoration *QDecorationFactory::create(const QString& key)
-{
- QDecoration *ret = 0;
- QString decoration = key.toLower();
-#ifndef QT_NO_QWS_DECORATION_DEFAULT
- if (decoration == QLatin1String("default"))
- ret = new QDecorationDefault;
- else
-#endif
-#ifndef QT_NO_QWS_DECORATION_WINDOWS
- if (decoration == QLatin1String("windows"))
- ret = new QDecorationWindows;
- else
-#endif
-#ifndef QT_NO_QWS_DECORATION_STYLED
- if (decoration == QLatin1String("styled"))
- ret = new QDecorationStyled;
- else
-#endif
- { } // Keep these here - they make the #ifdefery above work
-#ifndef QT_NO_LIBRARY
- if (!ret) {
- if (QDecorationFactoryInterface *factory = qobject_cast<QDecorationFactoryInterface*>(loader()->instance(decoration))) {
- ret = factory->create(decoration);
- }
- }
-#endif
- return ret;
-}
-
-/*!
- Returns the list of valid keys, i.e., the available decorations.
-
- \sa create()
-*/
-QStringList QDecorationFactory::keys()
-{
- QStringList list;
-#ifndef QT_NO_QWS_DECORATION_STYLED
- list << QLatin1String("Styled");
-#endif
-#ifndef QT_NO_QWS_DECORATION_DEFAULT
- list << QLatin1String("Default");
-#endif
-#ifndef QT_NO_QWS_DECORATION_WINDOWS
- list << QLatin1String("Windows");
-#endif
-
-#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
-#ifndef QT_NO_LIBRARY
- QStringList plugins = loader()->keys();
- for (int i = 0; i < plugins.size(); ++i) {
- if (!list.contains(plugins.at(i)))
- list += plugins.at(i);
- }
-#endif //QT_NO_LIBRARY
-#endif //QT_MAKEDLL
-
- return list;
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/embedded/qdecorationfactory_qws.h b/src/gui/embedded/qdecorationfactory_qws.h
deleted file mode 100644
index c5995eeb02..0000000000
--- a/src/gui/embedded/qdecorationfactory_qws.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECORATIONFACTORY_QWS_H
-#define QDECORATIONFACTORY_QWS_H
-
-#include <QtCore/qstringlist.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QDecoration;
-
-class Q_GUI_EXPORT QDecorationFactory
-{
-public:
- static QStringList keys();
- static QDecoration *create(const QString&);
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECORATIONFACTORY_QWS_H
diff --git a/src/gui/embedded/qdecorationplugin_qws.cpp b/src/gui/embedded/qdecorationplugin_qws.cpp
deleted file mode 100644
index 869243151f..0000000000
--- a/src/gui/embedded/qdecorationplugin_qws.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdecorationplugin_qws.h"
-#include "qdecoration_qws.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QDecorationPlugin
- \ingroup qws
- \ingroup plugins
-
- \brief The QDecorationPlugin class is an abstract base class for
- window decoration plugins in Qt for Embedded Linux.
-
- Note that this class is only available in \l{Qt for Embedded Linux}.
-
- \l{Qt for Embedded Linux} provides three ready-made decoration styles: \c
- Default, \c Styled and \c Windows. Custom decorations can be
- implemented by subclassing the QDecoration class and creating a
- decoration plugin.
-
- A decoration plugin can be created by subclassing
- QDecorationPlugin and implementing the pure virtual keys() and
- create() functions. By exporting the derived class using the
- Q_EXPORT_PLUGIN2() macro, the default implementation of the
- QDecorationFactory class will automatically detect the plugin and
- load the driver into the application at run-time. See \l{How to
- Create Qt Plugins} for details.
-
- To actually apply a decoration, use the
- QApplication::qwsSetDecoration() function.
-
- \sa QDecoration, QDecorationFactory
-*/
-
-/*!
- \fn QStringList QDecorationPlugin::keys() const
-
- Returns the list of valid keys, i.e., the decorations supported by
- this plugin.
-
- \sa create()
-*/
-
-/*!
- \fn QDecoration *QDecorationPlugin::create(const QString &key)
-
- Creates a decoration matching the given \a key. Note that keys are
- case-insensitive.
-
- \sa keys()
-*/
-
-/*!
- Constructs a decoration plugin with the given \a parent.
-
- Note that this constructor is invoked automatically by the
- Q_EXPORT_PLUGIN2() macro, so there is no need for calling it
- explicitly.
-*/
-QDecorationPlugin::QDecorationPlugin(QObject *parent)
- : QObject(parent)
-{
-}
-
-/*!
- Destroys the decoration plugin.
-
- Note that Qt destroys a plugin automatically when it is no longer
- used, so there is no need for calling the destructor explicitly.
-*/
-QDecorationPlugin::~QDecorationPlugin()
-{
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/embedded/qdecorationplugin_qws.h b/src/gui/embedded/qdecorationplugin_qws.h
deleted file mode 100644
index 4fa97f36f1..0000000000
--- a/src/gui/embedded/qdecorationplugin_qws.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECORATIONPLUGIN_QWS_H
-#define QDECORATIONPLUGIN_QWS_H
-
-#include <QtCore/qplugin.h>
-#include <QtCore/qfactoryinterface.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QDecoration;
-
-struct Q_GUI_EXPORT QDecorationFactoryInterface : public QFactoryInterface
-{
- virtual QDecoration *create(const QString &key) = 0;
-};
-
-#define QDecorationFactoryInterface_iid "com.trolltech.Qt.QDecorationFactoryInterface"
-Q_DECLARE_INTERFACE(QDecorationFactoryInterface, QDecorationFactoryInterface_iid)
-
-class Q_GUI_EXPORT QDecorationPlugin : public QObject, public QDecorationFactoryInterface
-{
- Q_OBJECT
- Q_INTERFACES(QDecorationFactoryInterface:QFactoryInterface)
- public:
- explicit QDecorationPlugin(QObject *parent = 0);
- ~QDecorationPlugin();
-
- virtual QStringList keys() const = 0;
- virtual QDecoration *create(const QString &key) = 0;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECORATIONPLUGIN_QWS_H
diff --git a/src/gui/embedded/qdecorationstyled_qws.cpp b/src/gui/embedded/qdecorationstyled_qws.cpp
deleted file mode 100644
index 40da4c2583..0000000000
--- a/src/gui/embedded/qdecorationstyled_qws.cpp
+++ /dev/null
@@ -1,313 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qapplication.h>
-#include <qwidget.h>
-#include <qpainter.h>
-#include <qdrawutil.h>
-#include "qdecorationstyled_qws.h"
-#include "qstyle.h"
-#include "qstyleoption.h"
-#include "qpaintengine.h"
-
-QT_BEGIN_NAMESPACE
-
-#if !defined(QT_NO_QWS_DECORATION_STYLED) || defined(QT_PLUGIN)
-
-QDecorationStyled::QDecorationStyled()
- : QDecorationDefault()
-{
-}
-
-QDecorationStyled::~QDecorationStyled()
-{
-}
-
-int QDecorationStyled::titleBarHeight(const QWidget *widget)
-{
- QStyleOptionTitleBar opt;
- opt.subControls = QStyle::SC_TitleBarLabel
- | QStyle::SC_TitleBarSysMenu
- | QStyle::SC_TitleBarNormalButton
- | QStyle::SC_TitleBarContextHelpButton
- | QStyle::SC_TitleBarMinButton
- | QStyle::SC_TitleBarMaxButton
- | QStyle::SC_TitleBarCloseButton;
- opt.titleBarFlags = widget->windowFlags();
- opt.direction = QApplication::layoutDirection();
- opt.text = windowTitleFor(widget);
- opt.icon = widget->windowIcon();
- opt.rect = widget->rect();
-
- QStyle *style = QApplication::style();
- if (!style)
- return 18;
-
- return style->pixelMetric(QStyle::PM_TitleBarHeight, &opt, 0);
-}
-
-bool QDecorationStyled::paint(QPainter *painter, const QWidget *widget, int decorationRegion,
- DecorationState state)
-{
- if (decorationRegion == None)
- return false;
-
- bool isActive = (widget == qApp->activeWindow());
- QPalette pal = qApp->palette();
- //ideally, the difference between Active and Inactive should be enough, so we shouldn't need to test this
- if (!isActive) {
- //pal.setCurrentColorGroup(QPalette::Disabled); //Can't do this either, because of palette limitations
- //copied from Q3TitleBar:
- pal.setColor(QPalette::Inactive, QPalette::Highlight,
- pal.color(QPalette::Inactive, QPalette::Dark));
- pal.setColor(QPalette::Inactive, QPalette::Base,
- pal.color(QPalette::Inactive, QPalette::Dark));
- pal.setColor(QPalette::Inactive, QPalette::HighlightedText,
- pal.color(QPalette::Inactive, QPalette::Window));
- }
-
- Qt::WindowFlags flags = widget->windowFlags();
- bool hasBorder = !widget->isMaximized();
- bool hasTitle = flags & Qt::WindowTitleHint;
- bool hasSysMenu = flags & Qt::WindowSystemMenuHint;
- bool hasContextHelp = flags & Qt::WindowContextHelpButtonHint;
- bool hasMinimize = flags & Qt::WindowMinimizeButtonHint;
- bool hasMaximize = flags & Qt::WindowMaximizeButtonHint;
-
- bool paintAll = (DecorationRegion(decorationRegion) == All);
- bool handled = false;
-
- QStyle *style = QApplication::style();
-
- // In the case of a borderless title bar, the title bar must be expanded one
- // borderWidth to the left, right and up.
- bool noTitleBorder = style->styleHint(QStyle::SH_TitleBar_NoBorder, 0, widget);
- int borderWidth = style->pixelMetric(QStyle::PM_MDIFrameWidth, 0, 0);
- int titleHeight = titleBarHeight(widget) + (noTitleBorder ? borderWidth : 0);
- int titleExtra = noTitleBorder ? borderWidth : 0;
-
- if ((paintAll || decorationRegion & Borders) && state == Normal && hasBorder) {
- QRegion newClip = painter->clipRegion();
- if (hasTitle) { // reduce flicker
- QRect rect(widget->rect());
- QRect r(rect.left() - titleExtra, rect.top() - titleHeight,
- rect.width() + 2 * titleExtra, titleHeight);
- newClip -= r;
- }
- if (!newClip.isEmpty()) {
- QRect br = QDecoration::region(widget).boundingRect();
- painter->save();
- painter->setClipRegion(newClip);
-
- QStyleOptionFrame opt;
- opt.palette = pal;
- opt.rect = br;
- opt.lineWidth = borderWidth;
-
- if (isActive)
- opt.state |= QStyle::State_Active;
- bool porterDuff = painter->paintEngine()->hasFeature(QPaintEngine::PorterDuff);
- if (porterDuff)
- painter->setCompositionMode(QPainter::CompositionMode_Source);
- painter->fillRect(br, pal.window());
- if (porterDuff)
- painter->setCompositionMode(QPainter::CompositionMode_SourceOver);
- style->drawPrimitive(QStyle::PE_FrameWindow, &opt, painter, 0);
- painter->restore();
-
- decorationRegion &= (~Borders);
- handled |= true;
- }
- }
-
- if (hasTitle) {
- painter->save();
-
- QStyleOptionTitleBar opt;
- opt.subControls = (decorationRegion & Title
- ? QStyle::SC_TitleBarLabel : QStyle::SubControl(0))
- | (decorationRegion & Menu
- ? QStyle::SC_TitleBarSysMenu : QStyle::SubControl(0))
- | (decorationRegion & Help
- ? QStyle::SC_TitleBarContextHelpButton : QStyle::SubControl(0))
- | (decorationRegion & Minimize
- ? QStyle::SC_TitleBarMinButton : QStyle::SubControl(0))
- | (decorationRegion & Maximize
- ? QStyle::SC_TitleBarMaxButton : QStyle::SubControl(0))
- | (decorationRegion & (Minimize | Maximize)
- ? QStyle::SC_TitleBarNormalButton : QStyle::SubControl(0))
- | (decorationRegion & Close
- ? QStyle::SC_TitleBarCloseButton : QStyle::SubControl(0));
- opt.titleBarFlags = widget->windowFlags();
- opt.titleBarState = widget->windowState();
- if (isActive)
- opt.titleBarState |= QStyle::State_Active;
- opt.text = windowTitleFor(widget);
- opt.icon = widget->windowIcon();
- opt.palette = pal;
- opt.rect = QRect(widget->rect().x() - titleExtra, -titleHeight,
- widget->rect().width() + 2 * titleExtra, titleHeight);
-
- if (paintAll) {
- painter->setClipRegion(opt.rect);
- } else {
- const QRect widgetRect = widget->rect();
- QRegion newClip = opt.rect;
- if (!(decorationRegion & Menu) && hasSysMenu)
- newClip -= region(widget, widgetRect, Menu);
- if (!(decorationRegion & Title) && hasTitle)
- newClip -= region(widget, widgetRect, Title);
- if (!(decorationRegion & Help) && hasContextHelp)
- newClip -= region(widget, widgetRect, Help);
- if (!(decorationRegion & Minimize) && hasMinimize)
- newClip -= region(widget, widgetRect, Minimize);
- if (!(decorationRegion & Maximize) && hasMaximize)
- newClip -= region(widget, widgetRect, Maximize);
- if (!(decorationRegion & (Minimize | Maximize)) && (hasMaximize | hasMinimize))
- newClip -= region(widget, widgetRect, Normal);
- if (!(decorationRegion & Close))
- newClip -= region(widget, widgetRect, Close);
- painter->setClipRegion(newClip);
- }
-
- if (state == Pressed)
- opt.activeSubControls = opt.subControls;
-
- style->drawComplexControl(QStyle::CC_TitleBar, &opt, painter, 0);
- painter->restore();
-
- decorationRegion &= ~(Title | Menu | Help | Normalize | Minimize | Maximize | Close);
- handled |= true;
- }
-
- return handled;
-}
-
-QRegion QDecorationStyled::region(const QWidget *widget, const QRect &rect, int decorationRegion)
-{
- QStyle *style = QApplication::style();
-
- // In the case of a borderless title bar, the title bar must be expanded one
- // borderWidth to the left, right and up.
- bool noTitleBorder = style->styleHint(QStyle::SH_TitleBar_NoBorder, 0, widget);
- int borderWidth = style->pixelMetric(QStyle::PM_MDIFrameWidth, 0, 0);
- int titleHeight = titleBarHeight(widget) + (noTitleBorder ? borderWidth : 0);
- int titleExtra = noTitleBorder ? borderWidth : 0;
-
- QRect inside = QRect(rect.x() - titleExtra, rect.top() - titleHeight,
- rect.width() + 2 * titleExtra, titleHeight);
-
- Qt::WindowFlags flags = widget->windowFlags();
- bool hasSysMenu = flags & Qt::WindowSystemMenuHint;
- bool hasContextHelp = flags & Qt::WindowContextHelpButtonHint;
- bool hasMinimize = flags & Qt::WindowMinimizeButtonHint;
- bool hasMaximize = flags & Qt::WindowMaximizeButtonHint;
-
- QStyleOptionTitleBar opt;
- opt.subControls = QStyle::SC_TitleBarLabel
- | QStyle::SC_TitleBarSysMenu
- | QStyle::SC_TitleBarNormalButton
- | QStyle::SC_TitleBarMinButton
- | QStyle::SC_TitleBarMaxButton
- | QStyle::SC_TitleBarCloseButton;
- opt.titleBarFlags = widget->windowFlags();
- opt.direction = QApplication::layoutDirection();
- opt.text = windowTitleFor(widget);
- opt.icon = widget->windowIcon();
- opt.rect = inside;
-
- QRegion region;
- switch (decorationRegion) {
- case Title:
- region = style->subControlRect(QStyle::CC_TitleBar, &opt,
- QStyle::SC_TitleBarLabel, 0);
- break;
- case Menu:
- if (hasSysMenu)
- region = style->subControlRect(QStyle::CC_TitleBar, &opt,
- QStyle::SC_TitleBarSysMenu, 0);
- break;
- case Help:
- if (hasContextHelp)
- region = style->subControlRect(QStyle::CC_TitleBar, &opt,
- QStyle::SC_TitleBarContextHelpButton,
- 0);
- break;
- case Normalize:
- if (hasMaximize | hasMinimize)
- region = style->subControlRect(QStyle::CC_TitleBar, &opt,
- QStyle::SC_TitleBarNormalButton,
- 0);
- break;
- case Minimize:
- if (hasMinimize)
- region = style->subControlRect(QStyle::CC_TitleBar, &opt,
- QStyle::SC_TitleBarMinButton,
- 0);
- break;
- case Maximize:
- if (hasMaximize)
- region = style->subControlRect(QStyle::CC_TitleBar, &opt,
- QStyle::SC_TitleBarMaxButton,
- 0);
- break;
- case Close:
- region = style->subControlRect(QStyle::CC_TitleBar, &opt,
- QStyle::SC_TitleBarCloseButton, 0);
- break;
-
- default:
- region = QDecorationDefault::region(widget, rect, decorationRegion);
- }
-
- opt.rect = QRect(rect.x() - titleExtra, rect.top() - titleHeight,
- rect.width() + 2 * titleExtra,
- rect.height() + titleHeight + titleExtra);
-
- QStyleHintReturnMask mask;
- style->styleHint(QStyle::SH_WindowFrame_Mask, &opt, 0, &mask);
-
- return (mask.region.isEmpty() ? region : (region & mask.region));
-}
-
-#endif // QT_NO_QWS_DECORATION_STYLED
-
-QT_END_NAMESPACE
diff --git a/src/gui/embedded/qdecorationstyled_qws.h b/src/gui/embedded/qdecorationstyled_qws.h
deleted file mode 100644
index ed697c0cd2..0000000000
--- a/src/gui/embedded/qdecorationstyled_qws.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECORATIONSTYLED_QWS_H
-#define QDECORATIONSTYLED_QWS_H
-
-#include <QtGui/qdecorationdefault_qws.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if !defined(QT_NO_QWS_DECORATION_STYLED) || defined(QT_PLUGIN)
-
-class Q_GUI_EXPORT QDecorationStyled : public QDecorationDefault
-{
-public:
- QDecorationStyled();
- virtual ~QDecorationStyled();
-
- QRegion region(const QWidget *widget, const QRect &rect, int decorationRegion = All);
- bool paint(QPainter *painter, const QWidget *widget, int decorationRegion = All,
- DecorationState state = Normal);
- int titleBarHeight(const QWidget *widget);
-};
-
-#endif // QT_NO_QWS_DECORATION_STYLED
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECORATIONSTYLED_QWS_H
diff --git a/src/gui/embedded/qdecorationwindows_qws.cpp b/src/gui/embedded/qdecorationwindows_qws.cpp
deleted file mode 100644
index 51d57d7203..0000000000
--- a/src/gui/embedded/qdecorationwindows_qws.cpp
+++ /dev/null
@@ -1,407 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qapplication.h>
-#include <qwidget.h>
-#include <qpainter.h>
-#include <qdrawutil.h>
-#include "qdecorationwindows_qws.h"
-
-QT_BEGIN_NAMESPACE
-
-#if !defined(QT_NO_QWS_DECORATION_WINDOWS) || defined(QT_PLUGIN)
-
-#ifndef QT_NO_IMAGEFORMAT_XPM
-
-/* XPM */
-static const char * const win_close_xpm[] = {
-"16 16 4 1",
-" s None c None",
-". c #000000",
-"X c #FFFFFF",
-"Y c #707070",
-" ",
-" ",
-" ",
-" Y. .Y ",
-" .. .. ",
-" .. .. ",
-" .YY. ",
-" Y..Y ",
-" .YY. ",
-" .. .. ",
-" .. .. ",
-" Y. .Y ",
-" ",
-" ",
-" ",
-" "};
-
-static const char * const win_help_xpm[] = {
-"16 16 3 1",
-" s None c None",
-". c #ffffff",
-"X c #000000",
-" ",
-" ",
-" ",
-" XXXXXX ",
-" XX XX ",
-" XX XX ",
-" XX ",
-" XX ",
-" XX ",
-" XX ",
-" ",
-" XX ",
-" XX ",
-" ",
-" ",
-" "};
-
-static const char * const win_maximize_xpm[] = {
-"16 16 4 1",
-" s None c None",
-". c #000000",
-"X c #FFFFFF",
-"Y c #707070",
-" ",
-" ",
-" ",
-" .......... ",
-" .......... ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" . . ",
-" .......... ",
-" ",
-" ",
-" ",
-" "};
-
-static const char * const win_minimize_xpm[] = {
-"16 16 4 1",
-" s None c None",
-". c #000000",
-"X c #FFFFFF",
-"Y c #707070",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ",
-" ........ ",
-" ........ ",
-" ",
-" ",
-" ",
-" "};
-
-static const char * const win_normalize_xpm[] = {
-"16 16 4 1",
-" s None c None",
-". c #000000",
-"X c #FFFFFF",
-"Y c #707070",
-" ",
-" ",
-" ......... ",
-" ......... ",
-" . . ",
-" . . ",
-" ......... . ",
-" ......... . ",
-" . . . ",
-" . .... ",
-" . . ",
-" . . ",
-" ......... ",
-" ",
-" ",
-" "};
-
-#endif // QT_NO_IMAGEFORMAT_XPM
-
-
-QDecorationWindows::QDecorationWindows()
- : QDecorationDefault()
-{
- menu_width = 16;
- help_width = 18;
- minimize_width = 18;
- maximize_width = 18;
- close_width = 18;
-}
-
-QDecorationWindows::~QDecorationWindows()
-{
-}
-
-const char **QDecorationWindows::xpmForRegion(int reg)
-{
-#ifdef QT_NO_IMAGEFORMAT_XPM
- Q_UNUSED(reg);
-#else
- switch(reg)
- {
- case Close:
- return (const char **)win_close_xpm;
- case Help:
- return (const char **)win_help_xpm;
- case Minimize:
- return (const char **)win_minimize_xpm;
- case Maximize:
- return (const char **)win_maximize_xpm;
- case Normalize:
- return (const char **)win_normalize_xpm;
- default:
- return QDecorationDefault::xpmForRegion(reg);
- }
-#endif
- return 0;
-}
-
-QRegion QDecorationWindows::region(const QWidget *widget, const QRect &rect, int type)
-{
- Qt::WindowFlags flags = widget->windowFlags();
- bool hasTitle = flags & Qt::WindowTitleHint;
- bool hasSysMenu = flags & Qt::WindowSystemMenuHint;
- bool hasContextHelp = flags & Qt::WindowContextHelpButtonHint;
- bool hasMinimize = flags & Qt::WindowMinimizeButtonHint;
- bool hasMaximize = flags & Qt::WindowMaximizeButtonHint;
- const QFontMetrics fontMetrics = QApplication::fontMetrics();
- int titleHeight = hasTitle ? qMax(20, fontMetrics.height()) : 0;
- int state = widget->windowState();
- bool isMinimized = state & Qt::WindowMinimized;
- bool isMaximized = state & Qt::WindowMaximized;
-
- QRegion region;
- switch (type) {
- case Menu: {
- if (hasSysMenu) {
- region = QRect(rect.left() + 2, rect.top() - titleHeight,
- menu_width, titleHeight);
- }
- }
- break;
-
- case Title: {
- QRect r(rect.left()
- + (hasSysMenu ? menu_width + 4: 0),
- rect.top() - titleHeight,
- rect.width()
- - (hasSysMenu ? menu_width : 0)
- - close_width
- - (hasMaximize ? maximize_width : 0)
- - (hasMinimize ? minimize_width : 0)
- - (hasContextHelp ? help_width : 0)
- - 3,
- titleHeight);
- if (r.width() > 0)
- region = r;
- }
- break;
- case Help: {
- if (hasContextHelp) {
- QRect r(rect.right()
- - close_width
- - (hasMaximize ? maximize_width : 0)
- - (hasMinimize ? minimize_width : 0)
- - help_width - 3, rect.top() - titleHeight,
- help_width, titleHeight);
- if (r.left() > rect.left() + titleHeight)
- region = r;
- }
- }
- break;
-
- case Minimize: {
- if (hasMinimize && !isMinimized) {
- QRect r(rect.right() - close_width
- - (hasMaximize ? maximize_width : 0)
- - minimize_width - 3, rect.top() - titleHeight,
- minimize_width, titleHeight);
- if (r.left() > rect.left() + titleHeight)
- region = r;
- }
- }
- break;
-
- case Maximize: {
- if (hasMaximize && !isMaximized) {
- QRect r(rect.right() - close_width - maximize_width - 3,
- rect.top() - titleHeight, maximize_width, titleHeight);
- if (r.left() > rect.left() + titleHeight)
- region = r;
- }
- }
- break;
-
- case Normalize: {
- if (hasMinimize && isMinimized) {
- QRect r(rect.right() - close_width
- - (hasMaximize ? maximize_width : 0)
- - minimize_width - 3, rect.top() - titleHeight,
- minimize_width, titleHeight);
- if (r.left() > rect.left() + titleHeight)
- region = r;
- } else if (hasMaximize && isMaximized) {
- QRect r(rect.right() - close_width - maximize_width - 3,
- rect.top() - titleHeight, maximize_width, titleHeight);
- if (r.left() > rect.left() + titleHeight)
- region = r;
- }
- }
- break;
-
- case Close: {
- QRect r(rect.right() - close_width - 1, rect.top() - titleHeight,
- close_width, titleHeight);
- if (r.left() > rect.left() + titleHeight)
- region = r;
- }
- break;
-
- default:
- region = QDecorationDefault::region(widget, rect, type);
- break;
- }
-
- return region;
-}
-
-bool QDecorationWindows::paint(QPainter *painter, const QWidget *widget, int decorationRegion,
- DecorationState state)
-{
- if (decorationRegion == None)
- return false;
-
- const QRect titleRect = QDecoration::region(widget, Title).boundingRect();
- const QPalette pal = QApplication::palette();
- QRegion oldClipRegion = painter->clipRegion();
-
- bool paintAll = (decorationRegion == int(All));
- if ((paintAll || decorationRegion & Title && titleRect.width() > 0) && state == Normal
- && (widget->windowFlags() & Qt::WindowTitleHint) ) {
- painter->setClipRegion(oldClipRegion);
- QColor fromBrush, toBrush;
- QPen titlePen;
-
- if (widget == qApp->activeWindow() || qApp->activeWindow() == qApp->activePopupWidget()) {
- fromBrush = pal.color(QPalette::Highlight);
- titlePen = pal.color(QPalette::HighlightedText);
- } else {
- fromBrush = pal.color(QPalette::Window);
- titlePen = pal.color(QPalette::Text);
- }
- toBrush = fromBrush.lighter(300);
-
- painter->setPen(Qt::NoPen);
- QPoint p1(titleRect.x(), titleRect.y() + titleRect.height()/2);
- QPoint p2(titleRect.right(), titleRect.y() + titleRect.height()/2);
- QLinearGradient lg(p1, p2);
- lg.setColorAt(0, fromBrush);
- lg.setColorAt(1, toBrush);
- painter->fillRect(titleRect, lg);
-
- painter->setPen(titlePen);
- painter->drawText(titleRect, Qt::AlignVCenter, windowTitleFor(widget));
- decorationRegion ^= Title;
- }
-
- return QDecorationDefault::paint(painter, widget, decorationRegion, state);
-}
-
-void QDecorationWindows::paintButton(QPainter *painter, const QWidget *widget, int buttonRegion,
- DecorationState state, const QPalette &pal)
-{
- QBrush fromBrush, toBrush;
- QPen titlePen;
-
- if (widget == qApp->activeWindow() || qApp->activeWindow() == qApp->activePopupWidget()) {
- fromBrush = pal.brush(QPalette::Highlight);
- titlePen = pal.color(QPalette::HighlightedText);
- } else {
- fromBrush = pal.brush(QPalette::Window);
- titlePen = pal.color(QPalette::Text);
- }
- toBrush = fromBrush.color().lighter(300);
-
- QRect brect(QDecoration::region(widget, buttonRegion).boundingRect());
- if (buttonRegion != Close && buttonRegion != Menu)
- painter->fillRect(brect, toBrush);
- else
- painter->fillRect(brect.x() - 2, brect.y(), brect.width() + 4, brect.height(),
- buttonRegion == Menu ? fromBrush : toBrush);
-
- int xoff = 1;
- int yoff = 2;
- const QPixmap pm = pixmapFor(widget, buttonRegion, xoff, yoff);
- if (buttonRegion != Menu) {
- if (state & Normal) {
- qDrawWinPanel(painter, brect.x(), brect.y() + 2, brect.width(),
- brect.height() - 4, pal, false, &pal.brush(QPalette::Window));
- } else if (state & Pressed) {
- qDrawWinPanel(painter, brect.x(), brect.y() + 2, brect.width(),
- brect.height() - 4, pal, true, &pal.brush(QPalette::Window));
- ++xoff;
- ++yoff;
- }
- } else {
- xoff = 0;
- yoff = 2;
- }
-
- if (!pm.isNull())
- painter->drawPixmap(brect.x() + xoff, brect.y() + yoff, pm);
-}
-
-#endif // QT_NO_QWS_DECORATION_WINDOWS || QT_PLUGIN
-
-QT_END_NAMESPACE
diff --git a/src/gui/embedded/qdecorationwindows_qws.h b/src/gui/embedded/qdecorationwindows_qws.h
deleted file mode 100644
index 44213e6680..0000000000
--- a/src/gui/embedded/qdecorationwindows_qws.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDECORATIONWINDOWS_QWS_H
-#define QDECORATIONWINDOWS_QWS_H
-
-#include <QtGui/qdecorationdefault_qws.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if !defined(QT_NO_QWS_DECORATION_WINDOWS) || defined(QT_PLUGIN)
-
-class Q_GUI_EXPORT QDecorationWindows : public QDecorationDefault
-{
-public:
- QDecorationWindows();
- virtual ~QDecorationWindows();
-
- QRegion region(const QWidget *widget, const QRect &rect, int decorationRegion = All);
- bool paint(QPainter *painter, const QWidget *widget, int decorationRegion = All,
- DecorationState state = Normal);
-
-protected:
- void paintButton(QPainter *painter, const QWidget *widget, int buttonRegion,
- DecorationState state, const QPalette &pal);
- const char **xpmForRegion(int reg);
-};
-
-#endif // QT_NO_QWS_DECORATION_WINDOWS
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDECORATIONWINDOWS_QWS_H
diff --git a/src/gui/embedded/qdirectpainter_qws.cpp b/src/gui/embedded/qdirectpainter_qws.cpp
deleted file mode 100644
index 47369947da..0000000000
--- a/src/gui/embedded/qdirectpainter_qws.cpp
+++ /dev/null
@@ -1,682 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdirectpainter_qws.h"
-
-#include "qscreen_qws.h"
-#include "private/qobject_p.h"
-#include "private/qapplication_p.h"
-#include "qwsdisplay_qws.h"
-#include "qwidget.h"
-#include "qimage.h"
-#include <qwsevent_qws.h>
-#include <private/qwindowsurface_qws_p.h>
-#include <private/qwsdisplay_qws_p.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifdef Q_WS_QWS
-#ifndef QT_NO_DIRECTPAINTER
-
-/*!
- \class QDirectPainter
- \ingroup painting
- \ingroup qws
-
- \brief The QDirectPainter class provides direct access to the
- underlying hardware in Qt for Embedded Linux.
-
- Note that this class is only available in \l{Qt for Embedded Linux}.
-
- QDirectPainter allows a client application to reserve a region of
- the framebuffer and render directly onto the screen. There are two
- ways of using the QDirectPainter class: You can either reserve a
- region using the provided static functions, or you can instantiate
- an object and make use of its more dynamic API.
-
- \tableofcontents
-
- \section1 Dynamic Allocation
-
- By instantiating a QDirectPainter object using the default
- QDirectPainter::NonReserved surface flag, the client application
- only gets some control over the reserved region, i.e., it can
- still render directly onto the screen but the allocated region may
- change (for example, if a window with a higher focus requests
- parts of the same region). The currently allocated region can be
- retrieved using the allocatedRegion() function, while the
- requestedRegion() function returns the originally reserved
- region.
-
-
- \section1 Static Allocation
-
-
- Using the static approach, the client application gets complete
- control over the reserved region, i.e., the affected region will
- never be modified by the screen driver.
-
- To create a static region, pass the QDirectPainter::Reserved
- surface flag to the constructor. After the reserved region is
- reported through regionChanged(), the allocated region will not
- change, unless setRegion() is called.
-
- If QDirectPainter::ReservedSynchronous is passed to the
- constructor, calls to setRegion() will block until the region is
- reserved, meaning that allocatedRegion() will be available immediately.
- Note that in the current version setRegion() will cause the application
- event loop to be entered, potentially causing reentrancy issues.
-
- \section1 Rendering
-
- To draw on a given region, the application must first get hold of
- a pointer to the framebuffer. In most cases, this pointer can be
- retrieved using the QDirectPainter::frameBuffer() function. But
- note that if the current screen has subscreens, you must query the
- screen driver instead to identify the correct subscreen. A pointer
- to the current screen driver can always be retrieved using the
- static QScreen::instance() function. Then use QScreen's \l
- {QScreen::}{subScreenIndexAt()} and \l {QScreen::}{subScreens()}
- functions to access the correct subscreen, and the subscreen's \l
- {QScreen::}{base()} function to retrieve a pointer to the
- framebuffer.
-
- Depending on the hardware, it might be necessary to lock the
- framebuffer for exclusive use while writing to it. This is
- possible using the lock() and unlock() functions. Note that
- calling lock() will prevent all other applications from working
- until unlock() is called.
-
- In addition, QDirectPainter provides several functions returning
- information about the framebuffer: the linestep() function returns
- the length (in bytes) of each scanline of the framebuffer while
- the screenDepth(), screenWidth() and screenHeight() function
- return the screen metrics.
-
- \sa QScreen, QWSEmbedWidget, {Qt for Embedded Linux Architecture}
-*/
-
-/*!
- \enum QDirectPainter::SurfaceFlag
-
- This enum describes the behavior of the region reserved by this
- QDirectPainter object.
-
- \value NonReserved The allocated region may change, e.g., if a
- window with a higher focus requests parts of the same region. See
- also \l {Dynamic Allocation}.
-
- \value Reserved The allocated region will never change. See also
- \l {Static Allocation}.
-
- \value ReservedSynchronous The allocated region will never change and
- each function that changes the allocated region will be blocking.
-
- \sa allocatedRegion()
-*/
-
-/*!
- \fn QRegion QDirectPainter::region()
- \obsolete
-
- Use QDirectPainter::allocatedRegion() instead.
-*/
-
-static inline QScreen *getPrimaryScreen()
-{
- QScreen *screen = QScreen::instance();
- if (!screen->base()) {
- QList<QScreen*> subScreens = screen->subScreens();
- if (subScreens.size() < 1)
- return 0;
- screen = subScreens.at(0);
- }
- return screen;
-}
-
-static inline QSize screenS()
-{
- QScreen *screen = getPrimaryScreen();
- if (!screen)
- return QSize();
- return QSize(screen->width(), screen->height());
-}
-
-static inline QSize devS()
-{
- QScreen *screen = getPrimaryScreen();
- if (!screen)
- return QSize();
- return QSize(screen->deviceWidth(), screen->deviceHeight());
-}
-
-
-class QDirectPainterPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QDirectPainter);
-public:
-
- QDirectPainterPrivate() : surface(0), seenRegion(false) {}
-
- ~QDirectPainterPrivate() {
- if (QPaintDevice::qwsDisplay()) { // make sure not in QApplication destructor
- qApp->d_func()->directPainters->remove(surface->windowId());
- surface->setGeometry(QRect());
- }
- delete surface;
- }
-
- QWSDirectPainterSurface *surface;
- QRegion requested_region;
-
- static QDirectPainter *staticPainter;
- bool seenRegion;
-};
-
-QDirectPainter *QDirectPainterPrivate::staticPainter = 0;
-
-void qt_directpainter_region(QDirectPainter *dp, const QRegion &alloc, int type)
-{
- QDirectPainterPrivate *d = dp->d_func();
-
- QRegion r = alloc;
- QScreen *screen = d->surface->screen();
- if (screen->isTransformed()) {
- const QSize screenSize(screen->width(), screen->height());
- r = screen->mapToDevice(r, screenSize);
- }
- if (type == QWSRegionEvent::Allocation) {
- d->surface->setClipRegion(alloc);
- d->seenRegion = true;
- if (dp != QDirectPainterPrivate::staticPainter) {
- if (!d->surface->flushingRegionEvents) // recursion guard
- dp->regionChanged(r);
- }
- }
-}
-
-#ifndef QT_NO_QWSEMBEDWIDGET
-void qt_directpainter_embedevent(QDirectPainter *dp, const QWSEmbedEvent *event)
-{
- if (event->type | QWSEmbedEvent::Region) {
- QScreen *screen = dp->d_func()->surface->screen();
- QRegion r = event->region;
- if (screen->isTransformed()) {
- const QSize screenSize(screen->width(), screen->height());
- r = screen->mapToDevice(r, screenSize);
- }
- dp->setRegion(r);
- }
-}
-#endif
-
-/*!
- Constructs a QDirectPainter object with the given \a parent and
- surface \a flag.
-*/
-QDirectPainter::QDirectPainter(QObject *parent, SurfaceFlag flag)
- :QObject(*new QDirectPainterPrivate, parent)
-{
- Q_D(QDirectPainter);
- d->surface = new QWSDirectPainterSurface(true, flag);
-
- if (flag != NonReserved)
- d->surface->setReserved();
-
- QApplicationPrivate *ad = qApp->d_func();
- if (!ad->directPainters)
- ad->directPainters = new QMap<WId, QDirectPainter*>;
- ad->directPainters->insert(d->surface->windowId(), this);
-}
-
-/*!
- Destroys this QDirectPainter object, releasing the reserved region.
-
- \sa allocatedRegion()
-*/
-QDirectPainter::~QDirectPainter()
-{
- /* should not be necessary
- if (this == QDirectPainterPrivate::staticPainter)
- QDirectPainterPrivate::staticPainter = 0;
- */
-}
-
-/*!
- \fn void QDirectPainter::setGeometry(const QRect &rectangle)
- \since 4.2
-
- Request to reserve the given \a rectangle of the framebuffer.
-
- Note that the actually allocated region might differ from the
- requested one, e.g., if the given region overlaps with the
- region of another QDirectPainter object.
-
- \sa geometry(), allocatedRegion(), setRegion()
-*/
-void QDirectPainter::setGeometry(const QRect &rect)
-{
- setRegion(rect);
-}
-
-/*!
- \since 4.2
-
- Returns the bounding rectangle of the requested region.
-
- \sa setGeometry(), requestedRegion()
-*/
-QRect QDirectPainter::geometry() const
-{
- Q_D(const QDirectPainter);
- return d->requested_region.boundingRect();
-}
-
-/*!
- \since 4.2
-
- Requests to reserve the given \a region of the framebuffer.
-
- Note that the actually allocated region might differ from the
- requested one, e.g., if the given region overlaps with the region
- of another QDirectPainter object.
-
- \sa requestedRegion(), allocatedRegion(), {Dynamic Allocation}
-*/
-void QDirectPainter::setRegion(const QRegion &region)
-{
- Q_D(QDirectPainter);
- d->requested_region = region;
-
- const QScreen *screen = d->surface->screen();
- if (screen->isTransformed()) {
- const QSize devSize(screen->deviceWidth(), screen->deviceHeight());
- const QRegion r = screen->mapFromDevice(region, devSize);
- d->surface->setRegion(r);
- } else {
- d->surface->setRegion(region);
- }
-}
-
-/*!
- \since 4.2
-
- Returns the region requested by this QDirectPainter.
-
- Note that if the QDirectPainter::Reserved flag is set, the region
- returned by this function will always be equivalent to the region
- returned by the allocatedRegion() function. Otherwise they might
- differ (see \l {Dynamic Allocation} for details).
-
- \sa geometry(), setRegion(), allocatedRegion()
-*/
-QRegion QDirectPainter::requestedRegion() const
-{
- Q_D(const QDirectPainter);
- return d->requested_region;
-}
-
-/*!
- \since 4.2
-
- Returns the currently reserved region.
-
- Note that if the QDirectPainter::Reserved flag is set, the region
- returned by this function will always be equivalent to the region
- returned by the requestedRegion() function. Otherwise they might
- differ (see \l {Dynamic Allocation} for details).
-
- \sa requestedRegion(), geometry()
-*/
-QRegion QDirectPainter::allocatedRegion() const
-{
- Q_D(const QDirectPainter);
- const QScreen *screen = d->surface->screen();
- if (screen->isTransformed()) {
- const QSize screenSize(screen->width(), screen->height());
- return screen->mapToDevice(d->surface->region(), screenSize);
- } else {
- return d->surface->region();
- }
-}
-
-/*!
- \since 4.2
-
- Returns the window system identifier of the widget.
-*/
-WId QDirectPainter::winId() const
-{
- Q_D(const QDirectPainter);
- return d->surface->windowId();
-}
-
-/*!
- \fn void QDirectPainter::regionChanged(const QRegion &newRegion)
- \since 4.2
-
- This function is called when the allocated region changes.
-
- This function is not called for region changes that happen while the
- startPainting() function is executing.
-
- Note that the given region, \a newRegion, is not guaranteed to be correct at the
- time you access the display. To prevent reentrancy problems you should
- always call startPainting() before updating the display and then use
- allocatedRegion() to retrieve the correct region.
-
- \sa allocatedRegion(), startPainting(), {Dynamic Allocation}
-*/
-void QDirectPainter::regionChanged(const QRegion &region)
-{
- Q_UNUSED(region);
-}
-
-/*!
- \since 4.2
-
- Call this function before you start updating the pixels in the
- allocated region. The hardware will be notified, if necessary,
- that you are about to start painting operations.
-
- Set \a lockDisplay if you want startPainting() and endPainting()
- to lock() and unlock() the display automatically.
-
- Note that for a NonReserved direct painter, you must call
- allocatedRegion() after calling this function, since the allocated
- region is only guaranteed to be correct after this function has
- returned.
-
- The regionChanged() function will not be called between startPainting()
- and endPainting().
-
- \sa endPainting(), flush()
-*/
-void QDirectPainter::startPainting(bool lockDisplay)
-{
- Q_D(QDirectPainter);
- d->surface->setLocking(lockDisplay);
-
- const QScreen *screen = d->surface->screen();
- if (screen->isTransformed()) {
- const QSize devSize(screen->deviceWidth(), screen->deviceHeight());
- const QRegion r = screen->mapFromDevice(d->surface->region(), devSize);
- d->surface->beginPaint(r);
- } else {
- d->surface->beginPaint(d->surface->region());
- }
-}
-
-/*!
- \since 4.2
-
- Call this function when you are done updating the screen. It will
- notify the hardware, if necessary, that your painting operations
- have ended.
-*/
-void QDirectPainter::endPainting()
-{
- Q_D(QDirectPainter);
-
- const QScreen *screen = d->surface->screen();
- if (screen->isTransformed()) {
- const QSize devSize(screen->deviceWidth(), screen->deviceHeight());
- const QRegion r = screen->mapFromDevice(d->surface->region(), devSize);
- d->surface->endPaint(r);
- } else {
- d->surface->endPaint(d->surface->region());
- }
-}
-
-/*!
- \since 4.3
- \overload
-
- This function will automatically call flush() to flush the
- \a region to the display before notifying the hardware, if
- necessary, that painting operations have ended.
-*/
-void QDirectPainter::endPainting(const QRegion &region)
-{
- endPainting();
- flush(region);
-}
-
-/*!
- \since 4.3
-
- Flushes the \a region onto the screen.
-*/
-void QDirectPainter::flush(const QRegion &region)
-{
- Q_D(QDirectPainter);
-
- const QScreen *screen = d->surface->screen();
- if (screen->isTransformed()) {
- const QSize devSize(screen->deviceWidth(), screen->deviceHeight());
- const QRegion r = screen->mapFromDevice(region, devSize);
- d->surface->flush(0, r, QPoint());
- } else {
- d->surface->flush(0, region, QPoint());
- }
-}
-
-/*!
- \since 4.2
-
- Raises the reserved region to the top of the widget stack.
-
- After this call the reserved region will be visually in front of
- any overlapping widgets.
-
- \sa lower(), requestedRegion()
-*/
-void QDirectPainter::raise()
-{
- QWidget::qwsDisplay()->setAltitude(winId(),QWSChangeAltitudeCommand::Raise);
-}
-
-/*!
- \since 4.2
-
- Lowers the reserved region to the bottom of the widget stack.
-
- After this call the reserved region will be visually behind (and
- therefore obscured by) any overlapping widgets.
-
- \sa raise(), requestedRegion()
-*/
-void QDirectPainter::lower()
-{
- QWidget::qwsDisplay()->setAltitude(winId(),QWSChangeAltitudeCommand::Lower);
-}
-
-
-/*!
- \fn QRegion QDirectPainter::reserveRegion(const QRegion &region)
-
- Attempts to reserve the \a region and returns the region that is
- actually reserved.
-
- This function also releases the previously reserved region if
- any. If not released explicitly, the region will be released on
- application exit.
-
- \sa allocatedRegion(), {Static Allocation}
-
- \obsolete
-
- Construct a QDirectPainter using QDirectPainter::ReservedSynchronous instead.
-*/
-QRegion QDirectPainter::reserveRegion(const QRegion &reg)
-{
- if (!QDirectPainterPrivate::staticPainter)
- QDirectPainterPrivate::staticPainter = new QDirectPainter(qApp, ReservedSynchronous);
-
- QDirectPainter *dp = QDirectPainterPrivate::staticPainter;
- dp->setRegion(reg);
-
- return dp->allocatedRegion();
-}
-
-/*!
- Returns a pointer to the beginning of the display memory.
-
- Note that it is the application's responsibility to limit itself
- to modifying only the reserved region.
-
- Do not use this pointer if the current screen has subscreens,
- query the screen driver instead: A pointer to the current screen
- driver can always be retrieved using the static
- QScreen::instance() function. Then use QScreen's \l
- {QScreen::}{subScreenIndexAt()} and \l {QScreen::}{subScreens()}
- functions to access the correct subscreen, and the subscreen's \l
- {QScreen::}{base()} function to retrieve a pointer to the
- framebuffer.
-
- \sa requestedRegion(), allocatedRegion(), linestep()
-*/
-uchar* QDirectPainter::frameBuffer()
-{
- QScreen *screen = getPrimaryScreen();
- if (!screen)
- return 0;
- return screen->base();
-}
-
-/*!
- \since 4.2
-
- Returns the reserved region.
-
- \sa reserveRegion(), frameBuffer()
-
- \obsolete
-
- Use allocatedRegion() instead.
-*/
-QRegion QDirectPainter::reservedRegion()
-{
- return QDirectPainterPrivate::staticPainter
- ? QDirectPainterPrivate::staticPainter->allocatedRegion() : QRegion();
-}
-
-/*!
- Returns the bit depth of the display.
-
- \sa screenHeight(), screenWidth()
-*/
-int QDirectPainter::screenDepth()
-{
- QScreen *screen = getPrimaryScreen();
- if (!screen)
- return 0;
- return screen->depth();
-}
-
-/*!
- Returns the width of the display in pixels.
-
- \sa screenHeight(), screenDepth()
-*/
-int QDirectPainter::screenWidth()
-{
- QScreen *screen = getPrimaryScreen();
- if (!screen)
- return 0;
- return screen->deviceWidth();
-}
-
-/*!
- Returns the height of the display in pixels.
-
- \sa screenWidth(), screenDepth()
-*/
-int QDirectPainter::screenHeight()
-{
- QScreen *screen = getPrimaryScreen();
- if (!screen)
- return 0;
- return screen->deviceHeight();
-}
-
-/*!
- Returns the length (in bytes) of each scanline of the framebuffer.
-
- \sa frameBuffer()
-*/
-int QDirectPainter::linestep()
-{
- QScreen *screen = getPrimaryScreen();
- if (!screen)
- return 0;
- return screen->linestep();
-}
-
-
-/*!
- Locks access to the framebuffer.
-
- Note that calling this function will prevent all other
- applications from updating the display until unlock() is called.
-
- \sa unlock()
-*/
-void QDirectPainter::lock()
-{
- QWSDisplay::grab(true);
-}
-/*!
- Unlocks the lock on the framebuffer (set using the lock()
- function), allowing other applications to access the screen.
-
- \sa lock()
- */
-void QDirectPainter::unlock()
-{
- QWSDisplay::ungrab();
-}
-
-#endif //QT_NO_DIRECTPAINTER
-
-#endif
-
-QT_END_NAMESPACE
diff --git a/src/gui/embedded/qdirectpainter_qws.h b/src/gui/embedded/qdirectpainter_qws.h
deleted file mode 100644
index 47cc721d49..0000000000
--- a/src/gui/embedded/qdirectpainter_qws.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDIRECTPAINTER_QWS_H
-#define QDIRECTPAINTER_QWS_H
-
-#include <QtCore/qobject.h>
-#include <QtGui/qregion.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_DIRECTPAINTER
-class QDirectPainterPrivate;
-class QWSEmbedEvent;
-
-class Q_GUI_EXPORT QDirectPainter : public QObject {
- Q_OBJECT
- Q_DECLARE_PRIVATE(QDirectPainter)
-public:
-
- enum SurfaceFlag { NonReserved = 0,
- Reserved = 1,
- ReservedSynchronous = 3 };
-
- explicit QDirectPainter(QObject *parentObject = 0, SurfaceFlag flag = NonReserved);
- ~QDirectPainter();
-
- void setRegion(const QRegion&);
- QRegion requestedRegion() const;
- QRegion allocatedRegion() const;
-
- void setGeometry(const QRect&);
- QRect geometry() const;
-
- WId winId() const;
- virtual void regionChanged(const QRegion &exposedRegion);
-
- void startPainting(bool lockDisplay = true);
- void endPainting();
- void endPainting(const QRegion &region);
- void flush(const QRegion &region);
-
- void raise();
- void lower();
-
-
- static QRegion reserveRegion(const QRegion&);
- static QRegion reservedRegion();
- static QRegion region() { return reservedRegion(); }
-
- static uchar* frameBuffer();
- static int screenDepth();
- static int screenWidth();
- static int screenHeight();
- static int linestep();
-
- static void lock();
- static void unlock();
-private:
- friend void qt_directpainter_region(QDirectPainter *dp, const QRegion &alloc, int type);
- friend void qt_directpainter_embedevent(QDirectPainter*, const QWSEmbedEvent*);
-};
-
-#endif
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDIRECTPAINTER_QWS_H
diff --git a/src/gui/embedded/qkbd_defaultmap_qws_p.h b/src/gui/embedded/qkbd_defaultmap_qws_p.h
deleted file mode 100644
index 017f56deb6..0000000000
--- a/src/gui/embedded/qkbd_defaultmap_qws_p.h
+++ /dev/null
@@ -1,806 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWSKEYBOARDHANDLER_DEFAULTMAP_H
-#define QWSKEYBOARDHANDLER_DEFAULTMAP_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.
-//
-
-// no QT_BEGIN_NAMESPACE, since we include it internally...
-
-const QWSKeyboard::Mapping QWSKbPrivate::s_keymap_default[] = {
- { 1, 0xffff, 0x01000000, 0x00, 0x00, 0x0000 },
- { 2, 0x0031, 0x00000031, 0x00, 0x00, 0x0000 },
- { 2, 0x0021, 0x00000021, 0x01, 0x00, 0x0000 },
- { 3, 0x0032, 0x00000032, 0x00, 0x00, 0x0000 },
- { 3, 0x0040, 0x00000040, 0x01, 0x00, 0x0000 },
- { 3, 0x0040, 0x00000040, 0x02, 0x00, 0x0000 },
- { 4, 0x0033, 0x00000033, 0x00, 0x00, 0x0000 },
- { 4, 0x0023, 0x00000023, 0x01, 0x00, 0x0000 },
- { 4, 0xffff, 0x01000000, 0x04, 0x00, 0x0000 },
- { 5, 0x0034, 0x00000034, 0x00, 0x00, 0x0000 },
- { 5, 0x0024, 0x00000024, 0x01, 0x00, 0x0000 },
- { 5, 0x0024, 0x00000024, 0x02, 0x00, 0x0000 },
- { 5, 0x005c, 0x0400005c, 0x04, 0x00, 0x0000 },
- { 6, 0x0035, 0x00000035, 0x00, 0x00, 0x0000 },
- { 6, 0x0025, 0x00000025, 0x01, 0x00, 0x0000 },
- { 6, 0x005d, 0x0400005d, 0x04, 0x00, 0x0000 },
- { 7, 0x0036, 0x00000036, 0x00, 0x00, 0x0000 },
- { 7, 0x005e, 0x0000005e, 0x01, 0x00, 0x0000 },
- { 7, 0x005e, 0x01001252, 0x02, 0x01, 0x0000 },
- { 7, 0x005e, 0x0400005e, 0x04, 0x00, 0x0000 },
- { 8, 0x0037, 0x00000037, 0x00, 0x00, 0x0000 },
- { 8, 0x0026, 0x00000026, 0x01, 0x00, 0x0000 },
- { 8, 0x007b, 0x0000007b, 0x02, 0x00, 0x0000 },
- { 8, 0x005f, 0x0400005f, 0x04, 0x00, 0x0000 },
- { 9, 0x0038, 0x00000038, 0x00, 0x00, 0x0000 },
- { 9, 0x002a, 0x0000002a, 0x01, 0x00, 0x0000 },
- { 9, 0x005b, 0x0000005b, 0x02, 0x00, 0x0000 },
- { 9, 0xffff, 0x01000003, 0x04, 0x00, 0x0000 },
- { 10, 0x0039, 0x00000039, 0x00, 0x00, 0x0000 },
- { 10, 0x0028, 0x00000028, 0x01, 0x00, 0x0000 },
- { 10, 0x005d, 0x0000005d, 0x02, 0x00, 0x0000 },
- { 11, 0x0030, 0x00000030, 0x00, 0x00, 0x0000 },
- { 11, 0x0029, 0x00000029, 0x01, 0x00, 0x0000 },
- { 11, 0x007d, 0x0000007d, 0x02, 0x00, 0x0000 },
- { 12, 0x002d, 0x0000002d, 0x00, 0x00, 0x0000 },
- { 12, 0x005f, 0x0000005f, 0x01, 0x00, 0x0000 },
- { 12, 0x005c, 0x0000005c, 0x02, 0x00, 0x0000 },
- { 12, 0x005f, 0x0400005f, 0x04, 0x00, 0x0000 },
- { 12, 0x005f, 0x0400005f, 0x05, 0x00, 0x0000 },
- { 13, 0x003d, 0x0000003d, 0x00, 0x00, 0x0000 },
- { 13, 0x002b, 0x0000002b, 0x01, 0x00, 0x0000 },
- { 14, 0xffff, 0x01000003, 0x00, 0x00, 0x0000 },
- { 14, 0xffff, 0x01000000, 0x0c, 0x08, 0x0300 },
- { 15, 0xffff, 0x01000001, 0x00, 0x00, 0x0000 },
- { 16, 0x0071, 0x00000051, 0x00, 0x00, 0x0000 },
- { 16, 0x0051, 0x00000051, 0x01, 0x00, 0x0000 },
- { 16, 0x0071, 0x00000051, 0x02, 0x00, 0x0000 },
- { 16, 0x0051, 0x00000051, 0x03, 0x00, 0x0000 },
- { 16, 0x0071, 0x04000051, 0x04, 0x00, 0x0000 },
- { 16, 0x0071, 0x04000051, 0x05, 0x00, 0x0000 },
- { 16, 0x0071, 0x04000051, 0x06, 0x00, 0x0000 },
- { 16, 0x0071, 0x04000051, 0x07, 0x00, 0x0000 },
- { 16, 0x0071, 0x08000051, 0x08, 0x00, 0x0000 },
- { 16, 0x0071, 0x08000051, 0x09, 0x00, 0x0000 },
- { 16, 0x0071, 0x08000051, 0x0a, 0x00, 0x0000 },
- { 16, 0x0071, 0x08000051, 0x0b, 0x00, 0x0000 },
- { 16, 0x0071, 0x0c000051, 0x0c, 0x00, 0x0000 },
- { 16, 0x0071, 0x0c000051, 0x0d, 0x00, 0x0000 },
- { 16, 0x0071, 0x0c000051, 0x0e, 0x00, 0x0000 },
- { 16, 0x0071, 0x0c000051, 0x0f, 0x00, 0x0000 },
- { 17, 0x0077, 0x00000057, 0x00, 0x00, 0x0000 },
- { 17, 0x0057, 0x00000057, 0x01, 0x00, 0x0000 },
- { 17, 0x0077, 0x00000057, 0x02, 0x00, 0x0000 },
- { 17, 0x0057, 0x00000057, 0x03, 0x00, 0x0000 },
- { 17, 0x0077, 0x04000057, 0x04, 0x00, 0x0000 },
- { 17, 0x0077, 0x04000057, 0x05, 0x00, 0x0000 },
- { 17, 0x0077, 0x04000057, 0x06, 0x00, 0x0000 },
- { 17, 0x0077, 0x04000057, 0x07, 0x00, 0x0000 },
- { 17, 0x0077, 0x08000057, 0x08, 0x00, 0x0000 },
- { 17, 0x0077, 0x08000057, 0x09, 0x00, 0x0000 },
- { 17, 0x0077, 0x08000057, 0x0a, 0x00, 0x0000 },
- { 17, 0x0077, 0x08000057, 0x0b, 0x00, 0x0000 },
- { 17, 0x0077, 0x0c000057, 0x0c, 0x00, 0x0000 },
- { 17, 0x0077, 0x0c000057, 0x0d, 0x00, 0x0000 },
- { 17, 0x0077, 0x0c000057, 0x0e, 0x00, 0x0000 },
- { 17, 0x0077, 0x0c000057, 0x0f, 0x00, 0x0000 },
- { 18, 0x0065, 0x00000045, 0x00, 0x00, 0x0000 },
- { 18, 0x0045, 0x00000045, 0x01, 0x00, 0x0000 },
- { 18, 0x0065, 0x00000045, 0x02, 0x00, 0x0000 },
- { 18, 0x0045, 0x00000045, 0x03, 0x00, 0x0000 },
- { 18, 0x0065, 0x04000045, 0x04, 0x00, 0x0000 },
- { 18, 0x0065, 0x04000045, 0x05, 0x00, 0x0000 },
- { 18, 0x0065, 0x04000045, 0x06, 0x00, 0x0000 },
- { 18, 0x0065, 0x04000045, 0x07, 0x00, 0x0000 },
- { 18, 0x0065, 0x08000045, 0x08, 0x00, 0x0000 },
- { 18, 0x0065, 0x08000045, 0x09, 0x00, 0x0000 },
- { 18, 0x0065, 0x08000045, 0x0a, 0x00, 0x0000 },
- { 18, 0x0065, 0x08000045, 0x0b, 0x00, 0x0000 },
- { 18, 0x0065, 0x0c000045, 0x0c, 0x00, 0x0000 },
- { 18, 0x0065, 0x0c000045, 0x0d, 0x00, 0x0000 },
- { 18, 0x0065, 0x0c000045, 0x0e, 0x00, 0x0000 },
- { 18, 0x0065, 0x0c000045, 0x0f, 0x00, 0x0000 },
- { 19, 0x0072, 0x00000052, 0x00, 0x00, 0x0000 },
- { 19, 0x0052, 0x00000052, 0x01, 0x00, 0x0000 },
- { 19, 0x0072, 0x00000052, 0x02, 0x00, 0x0000 },
- { 19, 0x0052, 0x00000052, 0x03, 0x00, 0x0000 },
- { 19, 0x0072, 0x04000052, 0x04, 0x00, 0x0000 },
- { 19, 0x0072, 0x04000052, 0x05, 0x00, 0x0000 },
- { 19, 0x0072, 0x04000052, 0x06, 0x00, 0x0000 },
- { 19, 0x0072, 0x04000052, 0x07, 0x00, 0x0000 },
- { 19, 0x0072, 0x08000052, 0x08, 0x00, 0x0000 },
- { 19, 0x0072, 0x08000052, 0x09, 0x00, 0x0000 },
- { 19, 0x0072, 0x08000052, 0x0a, 0x00, 0x0000 },
- { 19, 0x0072, 0x08000052, 0x0b, 0x00, 0x0000 },
- { 19, 0x0072, 0x0c000052, 0x0c, 0x00, 0x0000 },
- { 19, 0x0072, 0x0c000052, 0x0d, 0x00, 0x0000 },
- { 19, 0x0072, 0x0c000052, 0x0e, 0x00, 0x0000 },
- { 19, 0x0072, 0x0c000052, 0x0f, 0x00, 0x0000 },
- { 20, 0x0074, 0x00000054, 0x00, 0x00, 0x0000 },
- { 20, 0x0054, 0x00000054, 0x01, 0x00, 0x0000 },
- { 20, 0x0074, 0x00000054, 0x02, 0x00, 0x0000 },
- { 20, 0x0054, 0x00000054, 0x03, 0x00, 0x0000 },
- { 20, 0x0074, 0x04000054, 0x04, 0x00, 0x0000 },
- { 20, 0x0074, 0x04000054, 0x05, 0x00, 0x0000 },
- { 20, 0x0074, 0x04000054, 0x06, 0x00, 0x0000 },
- { 20, 0x0074, 0x04000054, 0x07, 0x00, 0x0000 },
- { 20, 0x0074, 0x08000054, 0x08, 0x00, 0x0000 },
- { 20, 0x0074, 0x08000054, 0x09, 0x00, 0x0000 },
- { 20, 0x0074, 0x08000054, 0x0a, 0x00, 0x0000 },
- { 20, 0x0074, 0x08000054, 0x0b, 0x00, 0x0000 },
- { 20, 0x0074, 0x0c000054, 0x0c, 0x00, 0x0000 },
- { 20, 0x0074, 0x0c000054, 0x0d, 0x00, 0x0000 },
- { 20, 0x0074, 0x0c000054, 0x0e, 0x00, 0x0000 },
- { 20, 0x0074, 0x0c000054, 0x0f, 0x00, 0x0000 },
- { 21, 0x0079, 0x00000059, 0x00, 0x00, 0x0000 },
- { 21, 0x0059, 0x00000059, 0x01, 0x00, 0x0000 },
- { 21, 0x0079, 0x00000059, 0x02, 0x00, 0x0000 },
- { 21, 0x0059, 0x00000059, 0x03, 0x00, 0x0000 },
- { 21, 0x0079, 0x04000059, 0x04, 0x00, 0x0000 },
- { 21, 0x0079, 0x04000059, 0x05, 0x00, 0x0000 },
- { 21, 0x0079, 0x04000059, 0x06, 0x00, 0x0000 },
- { 21, 0x0079, 0x04000059, 0x07, 0x00, 0x0000 },
- { 21, 0x0079, 0x08000059, 0x08, 0x00, 0x0000 },
- { 21, 0x0079, 0x08000059, 0x09, 0x00, 0x0000 },
- { 21, 0x0079, 0x08000059, 0x0a, 0x00, 0x0000 },
- { 21, 0x0079, 0x08000059, 0x0b, 0x00, 0x0000 },
- { 21, 0x0079, 0x0c000059, 0x0c, 0x00, 0x0000 },
- { 21, 0x0079, 0x0c000059, 0x0d, 0x00, 0x0000 },
- { 21, 0x0079, 0x0c000059, 0x0e, 0x00, 0x0000 },
- { 21, 0x0079, 0x0c000059, 0x0f, 0x00, 0x0000 },
- { 22, 0x0075, 0x00000055, 0x00, 0x00, 0x0000 },
- { 22, 0x0055, 0x00000055, 0x01, 0x00, 0x0000 },
- { 22, 0x0075, 0x00000055, 0x02, 0x00, 0x0000 },
- { 22, 0x0055, 0x00000055, 0x03, 0x00, 0x0000 },
- { 22, 0x0075, 0x04000055, 0x04, 0x00, 0x0000 },
- { 22, 0x0075, 0x04000055, 0x05, 0x00, 0x0000 },
- { 22, 0x0075, 0x04000055, 0x06, 0x00, 0x0000 },
- { 22, 0x0075, 0x04000055, 0x07, 0x00, 0x0000 },
- { 22, 0x0075, 0x08000055, 0x08, 0x00, 0x0000 },
- { 22, 0x0075, 0x08000055, 0x09, 0x00, 0x0000 },
- { 22, 0x0075, 0x08000055, 0x0a, 0x00, 0x0000 },
- { 22, 0x0075, 0x08000055, 0x0b, 0x00, 0x0000 },
- { 22, 0x0075, 0x0c000055, 0x0c, 0x00, 0x0000 },
- { 22, 0x0075, 0x0c000055, 0x0d, 0x00, 0x0000 },
- { 22, 0x0075, 0x0c000055, 0x0e, 0x00, 0x0000 },
- { 22, 0x0075, 0x0c000055, 0x0f, 0x00, 0x0000 },
- { 23, 0x0069, 0x00000049, 0x00, 0x00, 0x0000 },
- { 23, 0x0049, 0x00000049, 0x01, 0x00, 0x0000 },
- { 23, 0x0069, 0x00000049, 0x02, 0x00, 0x0000 },
- { 23, 0x0049, 0x00000049, 0x03, 0x00, 0x0000 },
- { 23, 0x0069, 0x04000049, 0x04, 0x00, 0x0000 },
- { 23, 0x0069, 0x04000049, 0x05, 0x00, 0x0000 },
- { 23, 0x0069, 0x04000049, 0x06, 0x00, 0x0000 },
- { 23, 0x0069, 0x04000049, 0x07, 0x00, 0x0000 },
- { 23, 0x0069, 0x08000049, 0x08, 0x00, 0x0000 },
- { 23, 0x0069, 0x08000049, 0x09, 0x00, 0x0000 },
- { 23, 0x0069, 0x08000049, 0x0a, 0x00, 0x0000 },
- { 23, 0x0069, 0x08000049, 0x0b, 0x00, 0x0000 },
- { 23, 0x0069, 0x0c000049, 0x0c, 0x00, 0x0000 },
- { 23, 0x0069, 0x0c000049, 0x0d, 0x00, 0x0000 },
- { 23, 0x0069, 0x0c000049, 0x0e, 0x00, 0x0000 },
- { 23, 0x0069, 0x0c000049, 0x0f, 0x00, 0x0000 },
- { 24, 0x006f, 0x0000004f, 0x00, 0x00, 0x0000 },
- { 24, 0x004f, 0x0000004f, 0x01, 0x00, 0x0000 },
- { 24, 0x006f, 0x0000004f, 0x02, 0x00, 0x0000 },
- { 24, 0x004f, 0x0000004f, 0x03, 0x00, 0x0000 },
- { 24, 0x006f, 0x0400004f, 0x04, 0x00, 0x0000 },
- { 24, 0x006f, 0x0400004f, 0x05, 0x00, 0x0000 },
- { 24, 0x006f, 0x0400004f, 0x06, 0x00, 0x0000 },
- { 24, 0x006f, 0x0400004f, 0x07, 0x00, 0x0000 },
- { 24, 0x006f, 0x0800004f, 0x08, 0x00, 0x0000 },
- { 24, 0x006f, 0x0800004f, 0x09, 0x00, 0x0000 },
- { 24, 0x006f, 0x0800004f, 0x0a, 0x00, 0x0000 },
- { 24, 0x006f, 0x0800004f, 0x0b, 0x00, 0x0000 },
- { 24, 0x006f, 0x0c00004f, 0x0c, 0x00, 0x0000 },
- { 24, 0x006f, 0x0c00004f, 0x0d, 0x00, 0x0000 },
- { 24, 0x006f, 0x0c00004f, 0x0e, 0x00, 0x0000 },
- { 24, 0x006f, 0x0c00004f, 0x0f, 0x00, 0x0000 },
- { 25, 0x0070, 0x00000050, 0x00, 0x00, 0x0000 },
- { 25, 0x0050, 0x00000050, 0x01, 0x00, 0x0000 },
- { 25, 0x0070, 0x00000050, 0x02, 0x00, 0x0000 },
- { 25, 0x0050, 0x00000050, 0x03, 0x00, 0x0000 },
- { 25, 0x0070, 0x04000050, 0x04, 0x00, 0x0000 },
- { 25, 0x0070, 0x04000050, 0x05, 0x00, 0x0000 },
- { 25, 0x0070, 0x04000050, 0x06, 0x00, 0x0000 },
- { 25, 0x0070, 0x04000050, 0x07, 0x00, 0x0000 },
- { 25, 0x0070, 0x08000050, 0x08, 0x00, 0x0000 },
- { 25, 0x0070, 0x08000050, 0x09, 0x00, 0x0000 },
- { 25, 0x0070, 0x08000050, 0x0a, 0x00, 0x0000 },
- { 25, 0x0070, 0x08000050, 0x0b, 0x00, 0x0000 },
- { 25, 0x0070, 0x0c000050, 0x0c, 0x00, 0x0000 },
- { 25, 0x0070, 0x0c000050, 0x0d, 0x00, 0x0000 },
- { 25, 0x0070, 0x0c000050, 0x0e, 0x00, 0x0000 },
- { 25, 0x0070, 0x0c000050, 0x0f, 0x00, 0x0000 },
- { 26, 0x005b, 0x0000005b, 0x00, 0x00, 0x0000 },
- { 26, 0x007b, 0x0000007b, 0x01, 0x00, 0x0000 },
- { 26, 0xffff, 0x01000000, 0x04, 0x00, 0x0000 },
- { 27, 0x005d, 0x0000005d, 0x00, 0x00, 0x0000 },
- { 27, 0x007d, 0x0000007d, 0x01, 0x00, 0x0000 },
- { 27, 0x007e, 0x0000007e, 0x02, 0x00, 0x0000 },
- { 27, 0x005d, 0x0400005d, 0x04, 0x00, 0x0000 },
- { 28, 0xffff, 0x01000004, 0x00, 0x00, 0x0000 },
- { 28, 0x006d, 0x0c00004d, 0x08, 0x00, 0x0000 },
- { 29, 0xffff, 0x01000021, 0x00, 0x04, 0x0004 },
- { 30, 0x0061, 0x00000041, 0x00, 0x00, 0x0000 },
- { 30, 0x0041, 0x00000041, 0x01, 0x00, 0x0000 },
- { 30, 0x0061, 0x00000041, 0x02, 0x00, 0x0000 },
- { 30, 0x0041, 0x00000041, 0x03, 0x00, 0x0000 },
- { 30, 0x0061, 0x04000041, 0x04, 0x00, 0x0000 },
- { 30, 0x0061, 0x04000041, 0x05, 0x00, 0x0000 },
- { 30, 0x0061, 0x04000041, 0x06, 0x00, 0x0000 },
- { 30, 0x0061, 0x04000041, 0x07, 0x00, 0x0000 },
- { 30, 0x0061, 0x08000041, 0x08, 0x00, 0x0000 },
- { 30, 0x0061, 0x08000041, 0x09, 0x00, 0x0000 },
- { 30, 0x0061, 0x08000041, 0x0a, 0x00, 0x0000 },
- { 30, 0x0061, 0x08000041, 0x0b, 0x00, 0x0000 },
- { 30, 0x0061, 0x0c000041, 0x0c, 0x00, 0x0000 },
- { 30, 0x0061, 0x0c000041, 0x0d, 0x00, 0x0000 },
- { 30, 0x0061, 0x0c000041, 0x0e, 0x00, 0x0000 },
- { 30, 0x0061, 0x0c000041, 0x0f, 0x00, 0x0000 },
- { 31, 0x0073, 0x00000053, 0x00, 0x00, 0x0000 },
- { 31, 0x0053, 0x00000053, 0x01, 0x00, 0x0000 },
- { 31, 0x0073, 0x00000053, 0x02, 0x00, 0x0000 },
- { 31, 0x0053, 0x00000053, 0x03, 0x00, 0x0000 },
- { 31, 0x0073, 0x04000053, 0x04, 0x00, 0x0000 },
- { 31, 0x0073, 0x04000053, 0x05, 0x00, 0x0000 },
- { 31, 0x0073, 0x04000053, 0x06, 0x00, 0x0000 },
- { 31, 0x0073, 0x04000053, 0x07, 0x00, 0x0000 },
- { 31, 0x0073, 0x08000053, 0x08, 0x00, 0x0000 },
- { 31, 0x0073, 0x08000053, 0x09, 0x00, 0x0000 },
- { 31, 0x0073, 0x08000053, 0x0a, 0x00, 0x0000 },
- { 31, 0x0073, 0x08000053, 0x0b, 0x00, 0x0000 },
- { 31, 0x0073, 0x0c000053, 0x0c, 0x00, 0x0000 },
- { 31, 0x0073, 0x0c000053, 0x0d, 0x00, 0x0000 },
- { 31, 0x0073, 0x0c000053, 0x0e, 0x00, 0x0000 },
- { 31, 0x0073, 0x0c000053, 0x0f, 0x00, 0x0000 },
- { 32, 0x0064, 0x00000044, 0x00, 0x00, 0x0000 },
- { 32, 0x0044, 0x00000044, 0x01, 0x00, 0x0000 },
- { 32, 0x0064, 0x00000044, 0x02, 0x00, 0x0000 },
- { 32, 0x0044, 0x00000044, 0x03, 0x00, 0x0000 },
- { 32, 0x0064, 0x04000044, 0x04, 0x00, 0x0000 },
- { 32, 0x0064, 0x04000044, 0x05, 0x00, 0x0000 },
- { 32, 0x0064, 0x04000044, 0x06, 0x00, 0x0000 },
- { 32, 0x0064, 0x04000044, 0x07, 0x00, 0x0000 },
- { 32, 0x0064, 0x08000044, 0x08, 0x00, 0x0000 },
- { 32, 0x0064, 0x08000044, 0x09, 0x00, 0x0000 },
- { 32, 0x0064, 0x08000044, 0x0a, 0x00, 0x0000 },
- { 32, 0x0064, 0x08000044, 0x0b, 0x00, 0x0000 },
- { 32, 0x0064, 0x0c000044, 0x0c, 0x00, 0x0000 },
- { 32, 0x0064, 0x0c000044, 0x0d, 0x00, 0x0000 },
- { 32, 0x0064, 0x0c000044, 0x0e, 0x00, 0x0000 },
- { 32, 0x0064, 0x0c000044, 0x0f, 0x00, 0x0000 },
- { 33, 0x0066, 0x00000046, 0x00, 0x00, 0x0000 },
- { 33, 0x0046, 0x00000046, 0x01, 0x00, 0x0000 },
- { 33, 0x0066, 0x00000046, 0x02, 0x00, 0x0000 },
- { 33, 0x0046, 0x00000046, 0x03, 0x00, 0x0000 },
- { 33, 0x0066, 0x04000046, 0x04, 0x00, 0x0000 },
- { 33, 0x0066, 0x04000046, 0x05, 0x00, 0x0000 },
- { 33, 0x0066, 0x04000046, 0x06, 0x00, 0x0000 },
- { 33, 0x0066, 0x04000046, 0x07, 0x00, 0x0000 },
- { 33, 0x0066, 0x08000046, 0x08, 0x00, 0x0000 },
- { 33, 0x0066, 0x08000046, 0x09, 0x00, 0x0000 },
- { 33, 0x0066, 0x08000046, 0x0a, 0x00, 0x0000 },
- { 33, 0x0066, 0x08000046, 0x0b, 0x00, 0x0000 },
- { 33, 0x0066, 0x0c000046, 0x0c, 0x00, 0x0000 },
- { 33, 0x0066, 0x0c000046, 0x0d, 0x00, 0x0000 },
- { 33, 0x0066, 0x0c000046, 0x0e, 0x00, 0x0000 },
- { 33, 0x0066, 0x0c000046, 0x0f, 0x00, 0x0000 },
- { 34, 0x0067, 0x00000047, 0x00, 0x00, 0x0000 },
- { 34, 0x0047, 0x00000047, 0x01, 0x00, 0x0000 },
- { 34, 0x0067, 0x00000047, 0x02, 0x00, 0x0000 },
- { 34, 0x0047, 0x00000047, 0x03, 0x00, 0x0000 },
- { 34, 0x0067, 0x04000047, 0x04, 0x00, 0x0000 },
- { 34, 0x0067, 0x04000047, 0x05, 0x00, 0x0000 },
- { 34, 0x0067, 0x04000047, 0x06, 0x00, 0x0000 },
- { 34, 0x0067, 0x04000047, 0x07, 0x00, 0x0000 },
- { 34, 0x0067, 0x08000047, 0x08, 0x00, 0x0000 },
- { 34, 0x0067, 0x08000047, 0x09, 0x00, 0x0000 },
- { 34, 0x0067, 0x08000047, 0x0a, 0x00, 0x0000 },
- { 34, 0x0067, 0x08000047, 0x0b, 0x00, 0x0000 },
- { 34, 0x0067, 0x0c000047, 0x0c, 0x00, 0x0000 },
- { 34, 0x0067, 0x0c000047, 0x0d, 0x00, 0x0000 },
- { 34, 0x0067, 0x0c000047, 0x0e, 0x00, 0x0000 },
- { 34, 0x0067, 0x0c000047, 0x0f, 0x00, 0x0000 },
- { 35, 0x0068, 0x00000048, 0x00, 0x00, 0x0000 },
- { 35, 0x0048, 0x00000048, 0x01, 0x00, 0x0000 },
- { 35, 0x0068, 0x00000048, 0x02, 0x00, 0x0000 },
- { 35, 0x0048, 0x00000048, 0x03, 0x00, 0x0000 },
- { 35, 0x0068, 0x04000048, 0x04, 0x00, 0x0000 },
- { 35, 0x0068, 0x04000048, 0x05, 0x00, 0x0000 },
- { 35, 0x0068, 0x04000048, 0x06, 0x00, 0x0000 },
- { 35, 0x0068, 0x04000048, 0x07, 0x00, 0x0000 },
- { 35, 0x0068, 0x08000048, 0x08, 0x00, 0x0000 },
- { 35, 0x0068, 0x08000048, 0x09, 0x00, 0x0000 },
- { 35, 0x0068, 0x08000048, 0x0a, 0x00, 0x0000 },
- { 35, 0x0068, 0x08000048, 0x0b, 0x00, 0x0000 },
- { 35, 0x0068, 0x0c000048, 0x0c, 0x00, 0x0000 },
- { 35, 0x0068, 0x0c000048, 0x0d, 0x00, 0x0000 },
- { 35, 0x0068, 0x0c000048, 0x0e, 0x00, 0x0000 },
- { 35, 0x0068, 0x0c000048, 0x0f, 0x00, 0x0000 },
- { 36, 0x006a, 0x0000004a, 0x00, 0x00, 0x0000 },
- { 36, 0x004a, 0x0000004a, 0x01, 0x00, 0x0000 },
- { 36, 0x006a, 0x0000004a, 0x02, 0x00, 0x0000 },
- { 36, 0x004a, 0x0000004a, 0x03, 0x00, 0x0000 },
- { 36, 0x006a, 0x0400004a, 0x04, 0x00, 0x0000 },
- { 36, 0x006a, 0x0400004a, 0x05, 0x00, 0x0000 },
- { 36, 0x006a, 0x0400004a, 0x06, 0x00, 0x0000 },
- { 36, 0x006a, 0x0400004a, 0x07, 0x00, 0x0000 },
- { 36, 0x006a, 0x0800004a, 0x08, 0x00, 0x0000 },
- { 36, 0x006a, 0x0800004a, 0x09, 0x00, 0x0000 },
- { 36, 0x006a, 0x0800004a, 0x0a, 0x00, 0x0000 },
- { 36, 0x006a, 0x0800004a, 0x0b, 0x00, 0x0000 },
- { 36, 0x006a, 0x0c00004a, 0x0c, 0x00, 0x0000 },
- { 36, 0x006a, 0x0c00004a, 0x0d, 0x00, 0x0000 },
- { 36, 0x006a, 0x0c00004a, 0x0e, 0x00, 0x0000 },
- { 36, 0x006a, 0x0c00004a, 0x0f, 0x00, 0x0000 },
- { 37, 0x006b, 0x0000004b, 0x00, 0x00, 0x0000 },
- { 37, 0x004b, 0x0000004b, 0x01, 0x00, 0x0000 },
- { 37, 0x006b, 0x0000004b, 0x02, 0x00, 0x0000 },
- { 37, 0x004b, 0x0000004b, 0x03, 0x00, 0x0000 },
- { 37, 0x006b, 0x0400004b, 0x04, 0x00, 0x0000 },
- { 37, 0x006b, 0x0400004b, 0x05, 0x00, 0x0000 },
- { 37, 0x006b, 0x0400004b, 0x06, 0x00, 0x0000 },
- { 37, 0x006b, 0x0400004b, 0x07, 0x00, 0x0000 },
- { 37, 0x006b, 0x0800004b, 0x08, 0x00, 0x0000 },
- { 37, 0x006b, 0x0800004b, 0x09, 0x00, 0x0000 },
- { 37, 0x006b, 0x0800004b, 0x0a, 0x00, 0x0000 },
- { 37, 0x006b, 0x0800004b, 0x0b, 0x00, 0x0000 },
- { 37, 0x006b, 0x0c00004b, 0x0c, 0x00, 0x0000 },
- { 37, 0x006b, 0x0c00004b, 0x0d, 0x00, 0x0000 },
- { 37, 0x006b, 0x0c00004b, 0x0e, 0x00, 0x0000 },
- { 37, 0x006b, 0x0c00004b, 0x0f, 0x00, 0x0000 },
- { 38, 0x006c, 0x0000004c, 0x00, 0x00, 0x0000 },
- { 38, 0x004c, 0x0000004c, 0x01, 0x00, 0x0000 },
- { 38, 0x006c, 0x0000004c, 0x02, 0x00, 0x0000 },
- { 38, 0x004c, 0x0000004c, 0x03, 0x00, 0x0000 },
- { 38, 0x006c, 0x0400004c, 0x04, 0x00, 0x0000 },
- { 38, 0x006c, 0x0400004c, 0x05, 0x00, 0x0000 },
- { 38, 0x006c, 0x0400004c, 0x06, 0x00, 0x0000 },
- { 38, 0x006c, 0x0400004c, 0x07, 0x00, 0x0000 },
- { 38, 0x006c, 0x0800004c, 0x08, 0x00, 0x0000 },
- { 38, 0x006c, 0x0800004c, 0x09, 0x00, 0x0000 },
- { 38, 0x006c, 0x0800004c, 0x0a, 0x00, 0x0000 },
- { 38, 0x006c, 0x0800004c, 0x0b, 0x00, 0x0000 },
- { 38, 0x006c, 0x0c00004c, 0x0c, 0x00, 0x0000 },
- { 38, 0x006c, 0x0c00004c, 0x0d, 0x00, 0x0000 },
- { 38, 0x006c, 0x0c00004c, 0x0e, 0x00, 0x0000 },
- { 38, 0x006c, 0x0c00004c, 0x0f, 0x00, 0x0000 },
- { 39, 0x003b, 0x0000003b, 0x00, 0x00, 0x0000 },
- { 39, 0x003a, 0x0000003a, 0x01, 0x00, 0x0000 },
- { 40, 0x0027, 0x00000027, 0x00, 0x00, 0x0000 },
- { 40, 0x0022, 0x00000022, 0x01, 0x00, 0x0000 },
- { 40, 0x0027, 0x01001251, 0x02, 0x01, 0x0000 },
- { 40, 0x0022, 0x01001257, 0x03, 0x01, 0x0000 },
- { 40, 0x0067, 0x04000047, 0x04, 0x00, 0x0000 },
- { 41, 0x0060, 0x00000060, 0x00, 0x00, 0x0000 },
- { 41, 0x007e, 0x0000007e, 0x01, 0x00, 0x0000 },
- { 41, 0x0060, 0x01001250, 0x02, 0x01, 0x0000 },
- { 41, 0x007e, 0x01001253, 0x03, 0x01, 0x0000 },
- { 42, 0xffff, 0x01000020, 0x00, 0x04, 0x0001 },
- { 43, 0x005c, 0x0000005c, 0x00, 0x00, 0x0000 },
- { 43, 0x007c, 0x0000007c, 0x01, 0x00, 0x0000 },
- { 43, 0x005c, 0x0400005c, 0x04, 0x00, 0x0000 },
- { 44, 0x007a, 0x0000005a, 0x00, 0x00, 0x0000 },
- { 44, 0x005a, 0x0000005a, 0x01, 0x00, 0x0000 },
- { 44, 0x007a, 0x0000005a, 0x02, 0x00, 0x0000 },
- { 44, 0x005a, 0x0000005a, 0x03, 0x00, 0x0000 },
- { 44, 0x007a, 0x0400005a, 0x04, 0x00, 0x0000 },
- { 44, 0x007a, 0x0400005a, 0x05, 0x00, 0x0000 },
- { 44, 0x007a, 0x0400005a, 0x06, 0x00, 0x0000 },
- { 44, 0x007a, 0x0400005a, 0x07, 0x00, 0x0000 },
- { 44, 0x007a, 0x0800005a, 0x08, 0x00, 0x0000 },
- { 44, 0x007a, 0x0800005a, 0x09, 0x00, 0x0000 },
- { 44, 0x007a, 0x0800005a, 0x0a, 0x00, 0x0000 },
- { 44, 0x007a, 0x0800005a, 0x0b, 0x00, 0x0000 },
- { 44, 0x007a, 0x0c00005a, 0x0c, 0x00, 0x0000 },
- { 44, 0x007a, 0x0c00005a, 0x0d, 0x00, 0x0000 },
- { 44, 0x007a, 0x0c00005a, 0x0e, 0x00, 0x0000 },
- { 44, 0x007a, 0x0c00005a, 0x0f, 0x00, 0x0000 },
- { 45, 0x0078, 0x00000058, 0x00, 0x00, 0x0000 },
- { 45, 0x0058, 0x00000058, 0x01, 0x00, 0x0000 },
- { 45, 0x0078, 0x00000058, 0x02, 0x00, 0x0000 },
- { 45, 0x0058, 0x00000058, 0x03, 0x00, 0x0000 },
- { 45, 0x0078, 0x04000058, 0x04, 0x00, 0x0000 },
- { 45, 0x0078, 0x04000058, 0x05, 0x00, 0x0000 },
- { 45, 0x0078, 0x04000058, 0x06, 0x00, 0x0000 },
- { 45, 0x0078, 0x04000058, 0x07, 0x00, 0x0000 },
- { 45, 0x0078, 0x08000058, 0x08, 0x00, 0x0000 },
- { 45, 0x0078, 0x08000058, 0x09, 0x00, 0x0000 },
- { 45, 0x0078, 0x08000058, 0x0a, 0x00, 0x0000 },
- { 45, 0x0078, 0x08000058, 0x0b, 0x00, 0x0000 },
- { 45, 0x0078, 0x0c000058, 0x0c, 0x00, 0x0000 },
- { 45, 0x0078, 0x0c000058, 0x0d, 0x00, 0x0000 },
- { 45, 0x0078, 0x0c000058, 0x0e, 0x00, 0x0000 },
- { 45, 0x0078, 0x0c000058, 0x0f, 0x00, 0x0000 },
- { 46, 0x0063, 0x00000043, 0x00, 0x00, 0x0000 },
- { 46, 0x0043, 0x00000043, 0x01, 0x00, 0x0000 },
- { 46, 0x0063, 0x00000043, 0x02, 0x00, 0x0000 },
- { 46, 0x0043, 0x00000043, 0x03, 0x00, 0x0000 },
- { 46, 0x0063, 0x04000043, 0x04, 0x00, 0x0000 },
- { 46, 0x0063, 0x04000043, 0x05, 0x00, 0x0000 },
- { 46, 0x0063, 0x04000043, 0x06, 0x00, 0x0000 },
- { 46, 0x0063, 0x04000043, 0x07, 0x00, 0x0000 },
- { 46, 0x0063, 0x08000043, 0x08, 0x00, 0x0000 },
- { 46, 0x0063, 0x08000043, 0x09, 0x00, 0x0000 },
- { 46, 0x0063, 0x08000043, 0x0a, 0x00, 0x0000 },
- { 46, 0x0063, 0x08000043, 0x0b, 0x00, 0x0000 },
- { 46, 0x0063, 0x0c000043, 0x0c, 0x00, 0x0000 },
- { 46, 0x0063, 0x0c000043, 0x0d, 0x00, 0x0000 },
- { 46, 0x0063, 0x0c000043, 0x0e, 0x00, 0x0000 },
- { 46, 0x0063, 0x0c000043, 0x0f, 0x00, 0x0000 },
- { 47, 0x0076, 0x00000056, 0x00, 0x00, 0x0000 },
- { 47, 0x0056, 0x00000056, 0x01, 0x00, 0x0000 },
- { 47, 0x0076, 0x00000056, 0x02, 0x00, 0x0000 },
- { 47, 0x0056, 0x00000056, 0x03, 0x00, 0x0000 },
- { 47, 0x0076, 0x04000056, 0x04, 0x00, 0x0000 },
- { 47, 0x0076, 0x04000056, 0x05, 0x00, 0x0000 },
- { 47, 0x0076, 0x04000056, 0x06, 0x00, 0x0000 },
- { 47, 0x0076, 0x04000056, 0x07, 0x00, 0x0000 },
- { 47, 0x0076, 0x08000056, 0x08, 0x00, 0x0000 },
- { 47, 0x0076, 0x08000056, 0x09, 0x00, 0x0000 },
- { 47, 0x0076, 0x08000056, 0x0a, 0x00, 0x0000 },
- { 47, 0x0076, 0x08000056, 0x0b, 0x00, 0x0000 },
- { 47, 0x0076, 0x0c000056, 0x0c, 0x00, 0x0000 },
- { 47, 0x0076, 0x0c000056, 0x0d, 0x00, 0x0000 },
- { 47, 0x0076, 0x0c000056, 0x0e, 0x00, 0x0000 },
- { 47, 0x0076, 0x0c000056, 0x0f, 0x00, 0x0000 },
- { 48, 0x0062, 0x00000042, 0x00, 0x00, 0x0000 },
- { 48, 0x0042, 0x00000042, 0x01, 0x00, 0x0000 },
- { 48, 0x0062, 0x00000042, 0x02, 0x00, 0x0000 },
- { 48, 0x0042, 0x00000042, 0x03, 0x00, 0x0000 },
- { 48, 0x0062, 0x04000042, 0x04, 0x00, 0x0000 },
- { 48, 0x0062, 0x04000042, 0x05, 0x00, 0x0000 },
- { 48, 0x0062, 0x04000042, 0x06, 0x00, 0x0000 },
- { 48, 0x0062, 0x04000042, 0x07, 0x00, 0x0000 },
- { 48, 0x0062, 0x08000042, 0x08, 0x00, 0x0000 },
- { 48, 0x0062, 0x08000042, 0x09, 0x00, 0x0000 },
- { 48, 0x0062, 0x08000042, 0x0a, 0x00, 0x0000 },
- { 48, 0x0062, 0x08000042, 0x0b, 0x00, 0x0000 },
- { 48, 0x0062, 0x0c000042, 0x0c, 0x00, 0x0000 },
- { 48, 0x0062, 0x0c000042, 0x0d, 0x00, 0x0000 },
- { 48, 0x0062, 0x0c000042, 0x0e, 0x00, 0x0000 },
- { 48, 0x0062, 0x0c000042, 0x0f, 0x00, 0x0000 },
- { 49, 0x006e, 0x0000004e, 0x00, 0x00, 0x0000 },
- { 49, 0x004e, 0x0000004e, 0x01, 0x00, 0x0000 },
- { 49, 0x006e, 0x0000004e, 0x02, 0x00, 0x0000 },
- { 49, 0x004e, 0x0000004e, 0x03, 0x00, 0x0000 },
- { 49, 0x006e, 0x0400004e, 0x04, 0x00, 0x0000 },
- { 49, 0x006e, 0x0400004e, 0x05, 0x00, 0x0000 },
- { 49, 0x006e, 0x0400004e, 0x06, 0x00, 0x0000 },
- { 49, 0x006e, 0x0400004e, 0x07, 0x00, 0x0000 },
- { 49, 0x006e, 0x0800004e, 0x08, 0x00, 0x0000 },
- { 49, 0x006e, 0x0800004e, 0x09, 0x00, 0x0000 },
- { 49, 0x006e, 0x0800004e, 0x0a, 0x00, 0x0000 },
- { 49, 0x006e, 0x0800004e, 0x0b, 0x00, 0x0000 },
- { 49, 0x006e, 0x0c00004e, 0x0c, 0x00, 0x0000 },
- { 49, 0x006e, 0x0c00004e, 0x0d, 0x00, 0x0000 },
- { 49, 0x006e, 0x0c00004e, 0x0e, 0x00, 0x0000 },
- { 49, 0x006e, 0x0c00004e, 0x0f, 0x00, 0x0000 },
- { 50, 0x006d, 0x0000004d, 0x00, 0x00, 0x0000 },
- { 50, 0x004d, 0x0000004d, 0x01, 0x00, 0x0000 },
- { 50, 0x006d, 0x0000004d, 0x02, 0x00, 0x0000 },
- { 50, 0x004d, 0x0000004d, 0x03, 0x00, 0x0000 },
- { 50, 0x006d, 0x0400004d, 0x04, 0x00, 0x0000 },
- { 50, 0x006d, 0x0400004d, 0x05, 0x00, 0x0000 },
- { 50, 0x006d, 0x0400004d, 0x06, 0x00, 0x0000 },
- { 50, 0x006d, 0x0400004d, 0x07, 0x00, 0x0000 },
- { 50, 0x006d, 0x0800004d, 0x08, 0x00, 0x0000 },
- { 50, 0x006d, 0x0800004d, 0x09, 0x00, 0x0000 },
- { 50, 0x006d, 0x0800004d, 0x0a, 0x00, 0x0000 },
- { 50, 0x006d, 0x0800004d, 0x0b, 0x00, 0x0000 },
- { 50, 0x006d, 0x0c00004d, 0x0c, 0x00, 0x0000 },
- { 50, 0x006d, 0x0c00004d, 0x0d, 0x00, 0x0000 },
- { 50, 0x006d, 0x0c00004d, 0x0e, 0x00, 0x0000 },
- { 50, 0x006d, 0x0c00004d, 0x0f, 0x00, 0x0000 },
- { 51, 0x002c, 0x0000002c, 0x00, 0x00, 0x0000 },
- { 51, 0x003c, 0x0000003c, 0x01, 0x00, 0x0000 },
- { 51, 0x002c, 0x0100125b, 0x02, 0x01, 0x0000 },
- { 52, 0x002e, 0x0000002e, 0x00, 0x00, 0x0000 },
- { 52, 0x003e, 0x0000003e, 0x01, 0x00, 0x0000 },
- { 52, 0xffff, 0x01001120, 0x02, 0x00, 0x0000 },
- { 53, 0x002f, 0x0000002f, 0x00, 0x00, 0x0000 },
- { 53, 0x003f, 0x0000003f, 0x01, 0x00, 0x0000 },
- { 53, 0xffff, 0x01000003, 0x04, 0x00, 0x0000 },
- { 54, 0xffff, 0x01000020, 0x00, 0x04, 0x0001 },
- { 55, 0x002a, 0x2000002a, 0x00, 0x00, 0x0000 },
- { 56, 0xffff, 0x01000023, 0x00, 0x04, 0x0008 },
- { 57, 0x0020, 0x00000020, 0x00, 0x00, 0x0000 },
- { 58, 0xffff, 0x01000024, 0x00, 0x00, 0x0000 },
- { 59, 0xffff, 0x01000030, 0x00, 0x00, 0x0000 },
- { 59, 0xffff, 0x0100003c, 0x01, 0x00, 0x0000 },
- { 59, 0xffff, 0x01000048, 0x04, 0x00, 0x0000 },
- { 59, 0xffff, 0x01000000, 0x0c, 0x08, 0x0100 },
- { 60, 0xffff, 0x01000031, 0x00, 0x00, 0x0000 },
- { 60, 0xffff, 0x0100003d, 0x01, 0x00, 0x0000 },
- { 60, 0xffff, 0x01000049, 0x04, 0x00, 0x0000 },
- { 60, 0xffff, 0x01000000, 0x0c, 0x08, 0x0101 },
- { 61, 0xffff, 0x01000032, 0x00, 0x00, 0x0000 },
- { 61, 0xffff, 0x0100003e, 0x01, 0x00, 0x0000 },
- { 61, 0xffff, 0x0100004a, 0x04, 0x00, 0x0000 },
- { 61, 0xffff, 0x01000000, 0x0c, 0x08, 0x0102 },
- { 62, 0xffff, 0x01000033, 0x00, 0x00, 0x0000 },
- { 62, 0xffff, 0x0100003f, 0x01, 0x00, 0x0000 },
- { 62, 0xffff, 0x0100004b, 0x04, 0x00, 0x0000 },
- { 62, 0xffff, 0x01000000, 0x0c, 0x08, 0x0103 },
- { 63, 0xffff, 0x01000034, 0x00, 0x00, 0x0000 },
- { 63, 0xffff, 0x01000040, 0x01, 0x00, 0x0000 },
- { 63, 0xffff, 0x0100004c, 0x04, 0x00, 0x0000 },
- { 63, 0xffff, 0x01000000, 0x0c, 0x08, 0x0104 },
- { 64, 0xffff, 0x01000035, 0x00, 0x00, 0x0000 },
- { 64, 0xffff, 0x01000041, 0x01, 0x00, 0x0000 },
- { 64, 0xffff, 0x0100004d, 0x04, 0x00, 0x0000 },
- { 64, 0xffff, 0x01000000, 0x0c, 0x08, 0x0105 },
- { 65, 0xffff, 0x01000036, 0x00, 0x00, 0x0000 },
- { 65, 0xffff, 0x01000042, 0x01, 0x00, 0x0000 },
- { 65, 0xffff, 0x0100004e, 0x04, 0x00, 0x0000 },
- { 65, 0xffff, 0x01000000, 0x0c, 0x08, 0x0106 },
- { 66, 0xffff, 0x01000037, 0x00, 0x00, 0x0000 },
- { 66, 0xffff, 0x01000043, 0x01, 0x00, 0x0000 },
- { 66, 0xffff, 0x0100004f, 0x04, 0x00, 0x0000 },
- { 66, 0xffff, 0x01000000, 0x0c, 0x08, 0x0107 },
- { 67, 0xffff, 0x01000038, 0x00, 0x00, 0x0000 },
- { 67, 0xffff, 0x01000044, 0x01, 0x00, 0x0000 },
- { 67, 0xffff, 0x01000050, 0x04, 0x00, 0x0000 },
- { 67, 0xffff, 0x01000000, 0x0c, 0x08, 0x0108 },
- { 68, 0xffff, 0x01000039, 0x00, 0x00, 0x0000 },
- { 68, 0xffff, 0x01000045, 0x01, 0x00, 0x0000 },
- { 68, 0xffff, 0x01000051, 0x04, 0x00, 0x0000 },
- { 68, 0xffff, 0x01000000, 0x0c, 0x08, 0x0109 },
- { 69, 0xffff, 0x01000025, 0x00, 0x00, 0x0000 },
- { 70, 0xffff, 0x01000026, 0x00, 0x00, 0x0000 },
- { 70, 0xffff, 0x01000026, 0x08, 0x00, 0x0000 },
- { 71, 0x0037, 0x20000037, 0x00, 0x00, 0x0000 },
- { 72, 0x0038, 0x20000038, 0x00, 0x00, 0x0000 },
- { 73, 0x0039, 0x20000039, 0x00, 0x00, 0x0000 },
- { 74, 0x002d, 0x2000002d, 0x00, 0x00, 0x0000 },
- { 75, 0x0034, 0x20000034, 0x00, 0x00, 0x0000 },
- { 76, 0x0035, 0x20000035, 0x00, 0x00, 0x0000 },
- { 77, 0x0036, 0x20000036, 0x00, 0x00, 0x0000 },
- { 78, 0x002b, 0x2000002b, 0x00, 0x00, 0x0000 },
- { 79, 0x0031, 0x20000031, 0x00, 0x00, 0x0000 },
- { 80, 0x0032, 0x20000032, 0x00, 0x00, 0x0000 },
- { 81, 0x0033, 0x20000033, 0x00, 0x00, 0x0000 },
- { 82, 0x0030, 0x20000030, 0x00, 0x00, 0x0000 },
- { 83, 0x002e, 0x2000002e, 0x00, 0x00, 0x0000 },
- { 83, 0xffff, 0x01000000, 0x06, 0x08, 0x0200 },
- { 83, 0xffff, 0x01000000, 0x0c, 0x08, 0x0200 },
- { 86, 0x003c, 0x0000003c, 0x00, 0x00, 0x0000 },
- { 86, 0x003e, 0x0000003e, 0x01, 0x00, 0x0000 },
- { 86, 0x007c, 0x0000007c, 0x02, 0x00, 0x0000 },
- { 87, 0xffff, 0x0100003a, 0x00, 0x00, 0x0000 },
- { 87, 0xffff, 0x01000046, 0x01, 0x00, 0x0000 },
- { 87, 0xffff, 0x01000052, 0x04, 0x00, 0x0000 },
- { 87, 0xffff, 0x01000000, 0x0c, 0x08, 0x010a },
- { 88, 0xffff, 0x0100003b, 0x00, 0x00, 0x0000 },
- { 88, 0xffff, 0x01000047, 0x01, 0x00, 0x0000 },
- { 88, 0xffff, 0x01000000, 0x0c, 0x08, 0x010b },
- { 96, 0xffff, 0x21000005, 0x00, 0x00, 0x0000 },
- { 97, 0xffff, 0x01000021, 0x00, 0x04, 0x0004 },
- { 98, 0x002f, 0x2000002f, 0x00, 0x00, 0x0000 },
- { 99, 0x005c, 0x0400005c, 0x00, 0x00, 0x0000 },
- { 100, 0xffff, 0x01001103, 0x00, 0x04, 0x0002 },
- { 102, 0xffff, 0x01000010, 0x00, 0x00, 0x0000 },
- { 103, 0xffff, 0x01000013, 0x00, 0x00, 0x0000 },
- { 104, 0xffff, 0x01000016, 0x00, 0x00, 0x0000 },
- { 105, 0xffff, 0x01000012, 0x00, 0x00, 0x0000 },
- { 105, 0xffff, 0x01000000, 0x0c, 0x08, 0x0180 },
- { 106, 0xffff, 0x01000014, 0x00, 0x00, 0x0000 },
- { 106, 0xffff, 0x01000000, 0x0c, 0x08, 0x0181 },
- { 107, 0xffff, 0x01000011, 0x00, 0x00, 0x0000 },
- { 108, 0xffff, 0x01000015, 0x00, 0x00, 0x0000 },
- { 109, 0xffff, 0x01000017, 0x00, 0x00, 0x0000 },
- { 110, 0xffff, 0x01000006, 0x00, 0x00, 0x0000 },
- { 111, 0xffff, 0x01000007, 0x00, 0x00, 0x0000 },
- { 111, 0xffff, 0x01000000, 0x06, 0x08, 0x0200 },
- { 111, 0xffff, 0x01000000, 0x0c, 0x08, 0x0200 },
- { 113, 0xffff, 0x01000071, 0x00, 0x00, 0x0000 },
- { 114, 0xffff, 0x01000070, 0x00, 0x00, 0x0000 },
- { 115, 0xffff, 0x01000072, 0x00, 0x00, 0x0000 },
- { 116, 0xffff, 0x0100010b, 0x00, 0x00, 0x0000 },
- { 119, 0xffff, 0x01000008, 0x00, 0x00, 0x0000 },
- { 138, 0xffff, 0x01000058, 0x00, 0x00, 0x0000 },
- { 139, 0xffff, 0x01000055, 0x00, 0x00, 0x0000 },
- { 152, 0xffff, 0x010000ba, 0x00, 0x00, 0x0000 },
-
-};
-
-const QWSKeyboard::Composing QWSKbPrivate::s_keycompose_default[] = {
- { 0x0060, 0x0041, 0x00c0 },
- { 0x0060, 0x0061, 0x00e0 },
- { 0x0027, 0x0041, 0x00c1 },
- { 0x0027, 0x0061, 0x00e1 },
- { 0x005e, 0x0041, 0x00c2 },
- { 0x005e, 0x0061, 0x00e2 },
- { 0x007e, 0x0041, 0x00c3 },
- { 0x007e, 0x0061, 0x00e3 },
- { 0x0022, 0x0041, 0x00c4 },
- { 0x0022, 0x0061, 0x00e4 },
- { 0x002d, 0x0061, 0x00aa },
- { 0x002d, 0x0041, 0x00aa },
- { 0x004f, 0x0041, 0x00c5 },
- { 0x006f, 0x0061, 0x00e5 },
- { 0x0030, 0x0041, 0x00c5 },
- { 0x0030, 0x0061, 0x00e5 },
- { 0x0041, 0x0041, 0x00c5 },
- { 0x0061, 0x0061, 0x00e5 },
- { 0x00b0, 0x0041, 0x00c5 },
- { 0x00b0, 0x0061, 0x00e5 },
- { 0x0041, 0x0045, 0x00c6 },
- { 0x0061, 0x0065, 0x00e6 },
- { 0x002c, 0x0043, 0x00c7 },
- { 0x002c, 0x0063, 0x00e7 },
- { 0x005e, 0x0043, 0x00c7 },
- { 0x005e, 0x0063, 0x00e7 },
- { 0x0060, 0x0045, 0x00c8 },
- { 0x0060, 0x0065, 0x00e8 },
- { 0x0027, 0x0045, 0x00c9 },
- { 0x0027, 0x0065, 0x00e9 },
- { 0x005e, 0x0045, 0x00ca },
- { 0x005e, 0x0065, 0x00ea },
- { 0x0022, 0x0045, 0x00cb },
- { 0x0022, 0x0065, 0x00eb },
- { 0x0060, 0x0049, 0x00cc },
- { 0x0060, 0x0069, 0x00ec },
- { 0x0027, 0x0049, 0x00cd },
- { 0x0027, 0x0069, 0x00ed },
- { 0x005e, 0x0049, 0x00ce },
- { 0x005e, 0x0069, 0x00ee },
- { 0x0022, 0x0049, 0x00cf },
- { 0x0022, 0x0069, 0x00ef },
- { 0x002d, 0x0044, 0x00d0 },
- { 0x002d, 0x0064, 0x00f0 },
- { 0x005e, 0x0044, 0x00d0 },
- { 0x005e, 0x0064, 0x00f0 },
- { 0x007e, 0x004e, 0x00d1 },
- { 0x007e, 0x006e, 0x00f1 },
- { 0x005e, 0x004e, 0x00d1 },
- { 0x005e, 0x006e, 0x00f1 },
- { 0x0060, 0x004f, 0x00d2 },
- { 0x0060, 0x006f, 0x00f2 },
- { 0x0027, 0x004f, 0x00d3 },
- { 0x0027, 0x006f, 0x00f3 },
- { 0x005e, 0x004f, 0x00d4 },
- { 0x005e, 0x006f, 0x00f4 },
- { 0x007e, 0x004f, 0x00d5 },
- { 0x007e, 0x006f, 0x00f5 },
- { 0x0022, 0x004f, 0x00d6 },
- { 0x0022, 0x006f, 0x00f6 },
- { 0x002f, 0x004f, 0x00d8 },
- { 0x002f, 0x006f, 0x00f8 },
- { 0x002d, 0x006f, 0x00ba },
- { 0x002d, 0x004f, 0x00ba },
- { 0x0060, 0x0055, 0x00d9 },
- { 0x0060, 0x0075, 0x00f9 },
- { 0x0027, 0x0055, 0x00da },
- { 0x0027, 0x0075, 0x00fa },
- { 0x005e, 0x0055, 0x00db },
- { 0x005e, 0x0075, 0x00fb },
- { 0x0022, 0x0055, 0x00dc },
- { 0x0022, 0x0075, 0x00fc },
- { 0x0027, 0x0059, 0x00dd },
- { 0x0027, 0x0079, 0x00fd },
- { 0x0054, 0x0048, 0x00de },
- { 0x0074, 0x0068, 0x00fe },
- { 0x0073, 0x0073, 0x00df },
- { 0x0022, 0x0079, 0x00ff },
- { 0x0073, 0x007a, 0x00df },
- { 0x006e, 0x006e, 0x00f1 },
- { 0x006e, 0x0068, 0x00f1 },
- { 0x004e, 0x0059, 0x00d1 },
- { 0x004e, 0x004e, 0x00d1 },
- { 0x004e, 0x0048, 0x00d1 },
- { 0x004e, 0x0079, 0x00d1 },
- { 0x004e, 0x006e, 0x00d1 },
- { 0x004e, 0x0068, 0x00d1 },
- { 0x002d, 0x004c, 0x00a3 },
- { 0x003c, 0x003c, 0x00ab },
- { 0x003e, 0x003e, 0x00bb },
- { 0x003f, 0x003f, 0x00bf },
- { 0x005e, 0x003f, 0x00bf },
- { 0x0021, 0x0021, 0x00a1 },
- { 0x005e, 0x0021, 0x00a1 },
- { 0x005e, 0x0031, 0x00b9 },
- { 0x005e, 0x0032, 0x00b2 },
- { 0x005e, 0x0033, 0x00b3 },
- { 0x002b, 0x002d, 0x00b1 },
- { 0x0063, 0x003d, 0x00a2 },
- { 0x0063, 0x002f, 0x00a2 },
- { 0x002f, 0x0063, 0x00a2 },
- { 0x002d, 0x0063, 0x00a2 },
- { 0x002d, 0x0043, 0x00a2 },
- { 0x004c, 0x003d, 0x00a3 },
- { 0x002d, 0x004c, 0x00a3 },
- { 0x002d, 0x006c, 0x00a3 },
- { 0x005e, 0x002a, 0x00d7 },
- { 0x005e, 0x0078, 0x00d7 },
- { 0x0078, 0x0078, 0x00d7 },
- { 0x005e, 0x002e, 0x00b7 },
- { 0x002e, 0x002e, 0x00b7 },
- { 0x005e, 0x002f, 0x00f7 },
- { 0x005e, 0x003a, 0x00f7 },
- { 0x002d, 0x003a, 0x00f7 },
- { 0x003a, 0x002d, 0x00f7 },
- { 0x0059, 0x003d, 0x00a5 },
- { 0x002d, 0x0059, 0x00a5 },
- { 0x002d, 0x006c, 0x00a5 },
- { 0x0028, 0x0063, 0x00a9 },
- { 0x0022, 0x0063, 0x00a9 },
- { 0x002d, 0x0061, 0x00aa },
- { 0x002d, 0x0041, 0x00aa },
- { 0x002d, 0x006f, 0x00ba },
- { 0x002d, 0x004f, 0x00ba },
- { 0x0028, 0x0072, 0x00ae },
- { 0x0022, 0x0072, 0x00ae },
- { 0x006d, 0x0075, 0x00b5 },
- { 0x0031, 0x0034, 0x0152 },
- { 0x0031, 0x0032, 0x0153 },
- { 0x0033, 0x0034, 0x0178 },
- { 0x0065, 0x003d, 0x20ac },
- { 0x002d, 0x0065, 0x20ac },
- { 0x002d, 0x0045, 0x20ac },
- { 0x0076, 0x0053, 0x0160 },
- { 0x005e, 0x0053, 0x0160 },
- { 0x0076, 0x0073, 0x0161 },
- { 0x005e, 0x0073, 0x0161 },
- { 0x0076, 0x005a, 0x017d },
- { 0x005e, 0x005a, 0x017d },
- { 0x0076, 0x007a, 0x017e },
- { 0x005e, 0x007a, 0x017e },
- { 0x004f, 0x0045, 0x0152 },
- { 0x004f, 0x0065, 0x0152 },
- { 0x006f, 0x0065, 0x0153 },
- { 0x0022, 0x0059, 0x0178 },
- { 0x0069, 0x006a, 0x00ff },
- { 0x0049, 0x004a, 0x0178 },
-};
-
-#endif
diff --git a/src/gui/embedded/qkbd_qws.cpp b/src/gui/embedded/qkbd_qws.cpp
deleted file mode 100644
index 9d2c6e86d8..0000000000
--- a/src/gui/embedded/qkbd_qws.cpp
+++ /dev/null
@@ -1,693 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qkbd_qws.h"
-#include "qkbd_qws_p.h"
-
-#ifndef QT_NO_QWS_KEYBOARD
-
-#include <QFile>
-#include <QDataStream>
-#include <QStringList>
-
-#ifdef Q_WS_QWS
-#include "qwindowsystem_qws.h"
-#include "qscreen_qws.h"
-#endif
-
-#ifdef Q_WS_QPA
-#include <QWindowSystemInterface>
-#include <QKeyEvent>
-#endif
-
-#include "qtimer.h"
-#include <stdlib.h>
-
-//#define QT_DEBUG_KEYMAP
-
-
-QT_BEGIN_NAMESPACE
-
-class QWSKbPrivate : public QObject
-{
- Q_OBJECT
-public:
- QWSKbPrivate(QWSKeyboardHandler *h, const QString &device)
- : m_handler(h), m_modifiers(0), m_composing(0), m_dead_unicode(0xffff),
- m_no_zap(false), m_do_compose(false),
- m_keymap(0), m_keymap_size(0), m_keycompose(0), m_keycompose_size(0)
- {
- m_ar_timer = new QTimer(this);
- m_ar_timer->setSingleShot(true);
- connect(m_ar_timer, SIGNAL(timeout()), SLOT(autoRepeat()));
- m_ar_delay = 400;
- m_ar_period = 80;
-
- memset(m_locks, 0, sizeof(m_locks));
-
- QString keymap;
- QStringList args = device.split(QLatin1Char(':'));
- foreach (const QString &arg, args) {
- if (arg.startsWith(QLatin1String("keymap=")))
- keymap = arg.mid(7);
- else if (arg == QLatin1String("disable-zap"))
- m_no_zap = true;
- else if (arg == QLatin1String("enable-compose"))
- m_do_compose = true;
- else if (arg.startsWith(QLatin1String("repeat-delay=")))
- m_ar_delay = arg.mid(13).toInt();
- else if (arg.startsWith(QLatin1String("repeat-rate=")))
- m_ar_period = arg.mid(12).toInt();
- }
-
- if (keymap.isEmpty() || !loadKeymap(keymap))
- unloadKeymap();
- }
-
- ~QWSKbPrivate()
- {
- unloadKeymap();
- }
-
- void beginAutoRepeat(int uni, int code, Qt::KeyboardModifiers mod)
- {
- m_ar_unicode = uni;
- m_ar_keycode = code;
- m_ar_modifier = mod;
- m_ar_timer->start(m_ar_delay);
- }
-
- void endAutoRepeat()
- {
- m_ar_timer->stop();
- }
-
- static Qt::KeyboardModifiers toQtModifiers(quint8 mod)
- {
- Qt::KeyboardModifiers qtmod = Qt::NoModifier;
-
- if (mod & (QWSKeyboard::ModShift | QWSKeyboard::ModShiftL | QWSKeyboard::ModShiftR))
- qtmod |= Qt::ShiftModifier;
- if (mod & (QWSKeyboard::ModControl | QWSKeyboard::ModCtrlL | QWSKeyboard::ModCtrlR))
- qtmod |= Qt::ControlModifier;
- if (mod & QWSKeyboard::ModAlt)
- qtmod |= Qt::AltModifier;
-
- return qtmod;
- }
-
- void unloadKeymap();
- bool loadKeymap(const QString &file);
-
-private slots:
- void autoRepeat()
- {
- m_handler->processKeyEvent(m_ar_unicode, m_ar_keycode, m_ar_modifier, false, true);
- m_handler->processKeyEvent(m_ar_unicode, m_ar_keycode, m_ar_modifier, true, true);
- m_ar_timer->start(m_ar_period);
- }
-
-private:
- QWSKeyboardHandler *m_handler;
-
- // auto repeat simulation
- int m_ar_unicode;
- int m_ar_keycode;
- Qt::KeyboardModifiers m_ar_modifier;
- int m_ar_delay;
- int m_ar_period;
- QTimer *m_ar_timer;
-
- // keymap handling
- quint8 m_modifiers;
- quint8 m_locks[3];
- int m_composing;
- quint16 m_dead_unicode;
-
- bool m_no_zap;
- bool m_do_compose;
-
- const QWSKeyboard::Mapping *m_keymap;
- int m_keymap_size;
- const QWSKeyboard::Composing *m_keycompose;
- int m_keycompose_size;
-
- static const QWSKeyboard::Mapping s_keymap_default[];
- static const QWSKeyboard::Composing s_keycompose_default[];
-
- friend class QWSKeyboardHandler;
-};
-
-// simple builtin US keymap
-#include "qkbd_defaultmap_qws_p.h"
-
-// the unloadKeymap() function needs to be AFTER the defaultmap include,
-// since the sizeof(s_keymap_default) wouldn't work otherwise.
-
-void QWSKbPrivate::unloadKeymap()
-{
- if (m_keymap && m_keymap != s_keymap_default)
- delete [] m_keymap;
- if (m_keycompose && m_keycompose != s_keycompose_default)
- delete [] m_keycompose;
-
- m_keymap = s_keymap_default;
- m_keymap_size = sizeof(s_keymap_default) / sizeof(s_keymap_default[0]);
- m_keycompose = s_keycompose_default;
- m_keycompose_size = sizeof(s_keycompose_default) / sizeof(s_keycompose_default[0]);
-
- // reset state, so we could switch keymaps at runtime
- m_modifiers = 0;
- memset(m_locks, 0, sizeof(m_locks));
- m_composing = 0;
- m_dead_unicode = 0xffff;
-}
-
-bool QWSKbPrivate::loadKeymap(const QString &file)
-{
- QFile f(file);
-
- if (!f.open(QIODevice::ReadOnly)) {
- qWarning("Could not open keymap file '%s'", qPrintable(file));
- return false;
- }
-
- // .qmap files have a very simple structure:
- // quint32 magic (QWSKeyboard::FileMagic)
- // quint32 version (1)
- // quint32 keymap_size (# of struct QWSKeyboard::Mappings)
- // quint32 keycompose_size (# of struct QWSKeyboard::Composings)
- // all QWSKeyboard::Mappings via QDataStream::operator(<<|>>)
- // all QWSKeyboard::Composings via QDataStream::operator(<<|>>)
-
- quint32 qmap_magic, qmap_version, qmap_keymap_size, qmap_keycompose_size;
-
- QDataStream ds(&f);
-
- ds >> qmap_magic >> qmap_version >> qmap_keymap_size >> qmap_keycompose_size;
-
- if (ds.status() != QDataStream::Ok || qmap_magic != QWSKeyboard::FileMagic || qmap_version != 1 || qmap_keymap_size == 0) {
- qWarning("'%s' is ot a valid.qmap keymap file.", qPrintable(file));
- return false;
- }
-
- QWSKeyboard::Mapping *qmap_keymap = new QWSKeyboard::Mapping[qmap_keymap_size];
- QWSKeyboard::Composing *qmap_keycompose = qmap_keycompose_size ? new QWSKeyboard::Composing[qmap_keycompose_size] : 0;
-
- for (quint32 i = 0; i < qmap_keymap_size; ++i)
- ds >> qmap_keymap[i];
- for (quint32 i = 0; i < qmap_keycompose_size; ++i)
- ds >> qmap_keycompose[i];
-
- if (ds.status() != QDataStream::Ok) {
- delete [] qmap_keymap;
- delete [] qmap_keycompose;
-
- qWarning("Keymap file '%s' can not be loaded.", qPrintable(file));
- return false;
- }
-
- // unload currently active and clear state
- unloadKeymap();
-
- m_keymap = qmap_keymap;
- m_keymap_size = qmap_keymap_size;
- m_keycompose = qmap_keycompose;
- m_keycompose_size = qmap_keycompose_size;
-
- m_do_compose = true;
-
- return true;
-}
-
-
-/*!
- \class QWSKeyboardHandler
- \ingroup qws
-
- \brief The QWSKeyboardHandler class is a base class for keyboard
- drivers in Qt for Embedded Linux.
-
- Note that this class is only available in \l{Qt for Embedded Linux}.
-
- \l{Qt for Embedded Linux} provides ready-made drivers for several keyboard
- protocols, see the \l{Qt for Embedded Linux Character Input}{character
- input} documentation for details. Custom keyboard drivers can be
- implemented by subclassing the QWSKeyboardHandler class and
- creating a keyboard driver plugin (derived from
- QKbdDriverPlugin). The default implementation of the
- QKbdDriverFactory class will automatically detect the plugin, and
- load the driver into the server application at run-time using Qt's
- \l{How to Create Qt Plugins}{plugin system}.
-
- The keyboard driver receives keyboard events from the system
- device and encapsulates each event with an instance of the
- QWSEvent class which it then passes to the server application (the
- server is responsible for propagating the event to the appropriate
- client). To receive keyboard events, a QWSKeyboardHandler object
- will usually create a QSocketNotifier object for the given
- device. The QSocketNotifier class provides support for monitoring
- activity on a file descriptor. When the socket notifier receives
- data, it will call the keyboard driver's processKeyEvent()
- function to send the event to the \l{Qt for Embedded Linux} server
- application for relaying to clients.
-
-
- QWSKeyboardHandler also provides functions to control
- auto-repetion of key sequences, beginAutoRepeat() and
- endAutoRepeat(), and the transformDirKey() function enabling
- transformation of arrow keys according to the display orientation.
-
- \sa QKbdDriverPlugin, QKbdDriverFactory, {Qt for Embedded Linux Character Input}
-*/
-
-
-/*!
- Constructs a keyboard driver. The \a device argument is passed by the
- QWS_KEYBOARD environment variable.
-
- Call the QWSServer::setKeyboardHandler() function to make the
- newly created keyboard driver, the primary driver. Note that the
- primary driver is controlled by the system, i.e., the system will
- delete it upon exit.
-*/
-QWSKeyboardHandler::QWSKeyboardHandler(const QString &device)
-{
- d = new QWSKbPrivate(this, device);
-}
-
-/*!
- \overload
-*/
-QWSKeyboardHandler::QWSKeyboardHandler()
-{
- d = new QWSKbPrivate(this, QString());
-}
-
-
-
-/*!
- Destroys this keyboard driver.
-
- Do not call this function if this driver is the primary keyboard
- handler, i.e., if QWSServer::setKeyboardHandler() function has
- been called passing this driver as argument. The primary keyboard
- driver is deleted by the system.
-*/
-QWSKeyboardHandler::~QWSKeyboardHandler()
-{
- delete d;
-}
-
-
-/*!
- Sends a key event to the \l{Qt for Embedded Linux} server application.
-
- The key event is identified by its \a unicode value and the \a
- keycode, \a modifiers, \a isPress and \a autoRepeat parameters.
-
- The \a keycode parameter is the Qt keycode value as defined by the
- Qt::Key enum. The \a modifiers is an OR combination of
- Qt::KeyboardModifier values, indicating whether \gui
- Shift/Alt/Ctrl keys are pressed. The \a isPress parameter is true
- if the event is a key press event and \a autoRepeat is true if the
- event is caused by an auto-repeat mechanism and not an actual key
- press.
-
- Note that this function does not handle key mapping. Please use
- processKeycode() if you need that functionality.
-
- \sa processKeycode(), beginAutoRepeat(), endAutoRepeat(), transformDirKey()
-*/
-void QWSKeyboardHandler::processKeyEvent(int unicode, int keycode, Qt::KeyboardModifiers modifiers,
- bool isPress, bool autoRepeat)
-{
-#if defined(Q_WS_QWS)
- qwsServer->processKeyEvent(unicode, keycode, modifiers, isPress, autoRepeat);
-#elif defined(Q_WS_QPA)
- QEvent::Type type = isPress ? QEvent::KeyPress : QEvent::KeyRelease;
- QString str;
- if (unicode != 0xffff)
- str = QString(unicode);
- QWindowSystemInterface::handleKeyEvent(0, type, keycode, modifiers, str);
-#endif
-}
-
-/*!
- \fn int QWSKeyboardHandler::transformDirKey(int keycode)
-
- Transforms the arrow key specified by the given \a keycode, to the
- orientation of the display and returns the transformed keycode.
-
- The \a keycode is a Qt::Key value. The values identifying arrow
- keys are:
-
- \list
- \o Qt::Key_Left
- \o Qt::Key_Up
- \o Qt::Key_Right
- \o Qt::Key_Down
- \endlist
-
- \sa processKeyEvent()
- */
-int QWSKeyboardHandler::transformDirKey(int key)
-{
-#ifdef Q_WS_QWS
- static int dir_keyrot = -1;
- if (dir_keyrot < 0) {
- // get the rotation
- switch (qgetenv("QWS_CURSOR_ROTATION").toInt()) {
- case 90: dir_keyrot = 1; break;
- case 180: dir_keyrot = 2; break;
- case 270: dir_keyrot = 3; break;
- default: dir_keyrot = 0; break;
- }
- }
- int xf = qt_screen->transformOrientation() + dir_keyrot;
- return (key-Qt::Key_Left+xf)%4+Qt::Key_Left;
-#else
- return 0;
-#endif
-}
-
-/*!
- \fn void QWSKeyboardHandler::beginAutoRepeat(int unicode, int keycode, Qt::KeyboardModifiers modifier)
-
- Begins auto-repeating the specified key press; after a short delay
- the key press is sent periodically until the endAutoRepeat()
- function is called.
-
- The key press is specified by its \a unicode, \a keycode and \a
- modifier state.
-
- \sa endAutoRepeat(), processKeyEvent()
-*/
-void QWSKeyboardHandler::beginAutoRepeat(int uni, int code, Qt::KeyboardModifiers mod)
-{
- d->beginAutoRepeat(uni, code, mod);
-}
-
-/*!
- Stops auto-repeating a key press.
-
- \sa beginAutoRepeat(), processKeyEvent()
-*/
-void QWSKeyboardHandler::endAutoRepeat()
-{
- d->endAutoRepeat();
-}
-
-/*!
- \enum QWSKeyboardHandler::KeycodeAction
-
- This enum describes the various special actions that actual
- QWSKeyboardHandler implementations have to take care of.
-
- \value None No further action required.
-
- \value CapsLockOn Set the state of the Caps lock LED to on.
- \value CapsLockOff Set the state of the Caps lock LED to off.
- \value NumLockOn Set the state of the Num lock LED to on.
- \value NumLockOff Set the state of the Num lock LED to off.
- \value ScrollLockOn Set the state of the Scroll lock LED to on.
- \value ScrollLockOff Set the state of the Scroll lock LED to off.
-
- \value PreviousConsole Switch to the previous virtual console (by
- default Ctrl+Alt+Left on Linux).
- \value NextConsole Switch to the next virtual console (by default
- Ctrl+Alt+Right on Linux).
- \value SwitchConsoleFirst Switch to the first virtual console (0).
- \value SwitchConsoleLast Switch to the last virtual console (255).
- \value SwitchConsoleMask If the KeyAction value is between SwitchConsoleFirst
- and SwitchConsoleLast, you can use this mask to get
- the specific virtual console number to switch to.
-
- \value Reboot Reboot the machine - this is ignored in both the TTY and
- LinuxInput handlers though (by default Ctrl+Alt+Del on Linux).
-
- \sa processKeycode()
-*/
-
-/*!
- \fn QWSKeyboardHandler::KeycodeAction QWSKeyboardHandler::processKeycode(quint16 keycode, bool isPress, bool autoRepeat)
-
- \since 4.6
-
- Maps \a keycode according to a keymap and sends that key event to the
- \l{Qt for Embedded Linux} server application.
-
- Please see the \l{Qt for Embedded Linux Character Input} and the \l
- {kmap2qmap} documentations for a description on how to create and use
- keymap files.
-
- The key event is identified by its \a keycode value and the \a isPress
- and \a autoRepeat parameters.
-
- The \a keycode parameter is \bold NOT the Qt keycode value as defined by
- the Qt::Key enum. This functions expects a standard Linux 16 bit kernel
- keycode as it is used in the Linux Input Event sub-system. This
- \a keycode is transformed to a Qt::Key code by using either a
- compiled-in US keyboard layout or by dynamically loading a keymap at
- startup which can be specified via the QWS_KEYBOARD environment
- variable.
-
- The \a isPress parameter is true if the event is a key press event and
- \a autoRepeat is true if the event is caused by an auto-repeat mechanism
- and not an actual key press.
-
- The return value indicates if the actual QWSKeyboardHandler
- implementation needs to take care of a special action, like console
- switching or LED handling.
-
- If standard Linux console keymaps are used, \a keycode must be one of the
- standardized values defined in \c /usr/include/linux/input.h
-
- \sa processKeyEvent(), KeycodeAction
-*/
-
-QWSKeyboardHandler::KeycodeAction QWSKeyboardHandler::processKeycode(quint16 keycode, bool pressed, bool autorepeat)
-{
- KeycodeAction result = None;
- bool first_press = pressed && !autorepeat;
-
- const QWSKeyboard::Mapping *map_plain = 0;
- const QWSKeyboard::Mapping *map_withmod = 0;
-
- // get a specific and plain mapping for the keycode and the current modifiers
- for (int i = 0; i < d->m_keymap_size && !(map_plain && map_withmod); ++i) {
- const QWSKeyboard::Mapping *m = d->m_keymap + i;
- if (m->keycode == keycode) {
- if (m->modifiers == 0)
- map_plain = m;
-
- quint8 testmods = d->m_modifiers;
- if (d->m_locks[0] /*CapsLock*/ && (m->flags & QWSKeyboard::IsLetter))
- testmods ^= QWSKeyboard::ModShift;
- if (m->modifiers == testmods)
- map_withmod = m;
- }
- }
-
-#ifdef QT_DEBUG_KEYMAP
- qWarning("Processing key event: keycode=%3d, modifiers=%02x pressed=%d, autorepeat=%d | plain=%d, withmod=%d, size=%d", \
- keycode, d->m_modifiers, pressed ? 1 : 0, autorepeat ? 1 : 0, \
- map_plain ? map_plain - d->m_keymap : -1, \
- map_withmod ? map_withmod - d->m_keymap : -1, \
- d->m_keymap_size);
-#endif
-
- const QWSKeyboard::Mapping *it = map_withmod ? map_withmod : map_plain;
-
- if (!it) {
-#ifdef QT_DEBUG_KEYMAP
- // we couldn't even find a plain mapping
- qWarning("Could not find a suitable mapping for keycode: %3d, modifiers: %02x", keycode, d->m_modifiers);
-#endif
- return result;
- }
-
- bool skip = false;
- quint16 unicode = it->unicode;
- quint32 qtcode = it->qtcode;
-
- if ((it->flags & QWSKeyboard::IsModifier) && it->special) {
- // this is a modifier, i.e. Shift, Alt, ...
- if (pressed)
- d->m_modifiers |= quint8(it->special);
- else
- d->m_modifiers &= ~quint8(it->special);
- } else if (qtcode >= Qt::Key_CapsLock && qtcode <= Qt::Key_ScrollLock) {
- // (Caps|Num|Scroll)Lock
- if (first_press) {
- quint8 &lock = d->m_locks[qtcode - Qt::Key_CapsLock];
- lock ^= 1;
-
- switch (qtcode) {
- case Qt::Key_CapsLock : result = lock ? CapsLockOn : CapsLockOff; break;
- case Qt::Key_NumLock : result = lock ? NumLockOn : NumLockOff; break;
- case Qt::Key_ScrollLock: result = lock ? ScrollLockOn : ScrollLockOff; break;
- default : break;
- }
- }
- } else if ((it->flags & QWSKeyboard::IsSystem) && it->special && first_press) {
- switch (it->special) {
- case QWSKeyboard::SystemReboot:
- result = Reboot;
- break;
-
- case QWSKeyboard::SystemZap:
- if (!d->m_no_zap)
- qApp->quit();
- break;
-
- case QWSKeyboard::SystemConsolePrevious:
- result = PreviousConsole;
- break;
-
- case QWSKeyboard::SystemConsoleNext:
- result = NextConsole;
- break;
-
- default:
- if (it->special >= QWSKeyboard::SystemConsoleFirst &&
- it->special <= QWSKeyboard::SystemConsoleLast) {
- result = KeycodeAction(SwitchConsoleFirst + ((it->special & QWSKeyboard::SystemConsoleMask) & SwitchConsoleMask));
- }
- break;
- }
-
- skip = true; // no need to tell QWS about it
- } else if ((qtcode == Qt::Key_Multi_key) && d->m_do_compose) {
- // the Compose key was pressed
- if (first_press)
- d->m_composing = 2;
- skip = true;
- } else if ((it->flags & QWSKeyboard::IsDead) && d->m_do_compose) {
- // a Dead key was pressed
- if (first_press && d->m_composing == 1 && d->m_dead_unicode == unicode) { // twice
- d->m_composing = 0;
- qtcode = Qt::Key_unknown; // otherwise it would be Qt::Key_Dead...
- } else if (first_press && unicode != 0xffff) {
- d->m_dead_unicode = unicode;
- d->m_composing = 1;
- skip = true;
- } else {
- skip = true;
- }
- }
-
- if (!skip) {
- // a normal key was pressed
- const int modmask = Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier | Qt::KeypadModifier;
-
- // we couldn't find a specific mapping for the current modifiers,
- // or that mapping didn't have special modifiers:
- // so just report the plain mapping with additional modifiers.
- if ((it == map_plain && it != map_withmod) ||
- (map_withmod && !(map_withmod->qtcode & modmask))) {
- qtcode |= QWSKbPrivate::toQtModifiers(d->m_modifiers);
- }
-
- if (d->m_composing == 2 && first_press && !(it->flags & QWSKeyboard::IsModifier)) {
- // the last key press was the Compose key
- if (unicode != 0xffff) {
- int idx = 0;
- // check if this code is in the compose table at all
- for ( ; idx < d->m_keycompose_size; ++idx) {
- if (d->m_keycompose[idx].first == unicode)
- break;
- }
- if (idx < d->m_keycompose_size) {
- // found it -> simulate a Dead key press
- d->m_dead_unicode = unicode;
- unicode = 0xffff;
- d->m_composing = 1;
- skip = true;
- } else {
- d->m_composing = 0;
- }
- } else {
- d->m_composing = 0;
- }
- } else if (d->m_composing == 1 && first_press && !(it->flags & QWSKeyboard::IsModifier)) {
- // the last key press was a Dead key
- bool valid = false;
- if (unicode != 0xffff) {
- int idx = 0;
- // check if this code is in the compose table at all
- for ( ; idx < d->m_keycompose_size; ++idx) {
- if (d->m_keycompose[idx].first == d->m_dead_unicode && d->m_keycompose[idx].second == unicode)
- break;
- }
- if (idx < d->m_keycompose_size) {
- quint16 composed = d->m_keycompose[idx].result;
- if (composed != 0xffff) {
- unicode = composed;
- qtcode = Qt::Key_unknown;
- valid = true;
- }
- }
- }
- if (!valid) {
- unicode = d->m_dead_unicode;
- qtcode = Qt::Key_unknown;
- }
- d->m_composing = 0;
- }
-
- if (!skip) {
-#ifdef QT_DEBUG_KEYMAP
- qWarning("Processing: uni=%04x, qt=%08x, qtmod=%08x", unicode, qtcode & ~modmask, (qtcode & modmask));
-#endif
-
- // send the result to the QWS server
- processKeyEvent(unicode, qtcode & ~modmask, Qt::KeyboardModifiers(qtcode & modmask), pressed, autorepeat);
- }
- }
- return result;
-}
-
-QT_END_NAMESPACE
-
-#include "qkbd_qws.moc"
-
-#endif // QT_NO_QWS_KEYBOARD
diff --git a/src/gui/embedded/qkbd_qws.h b/src/gui/embedded/qkbd_qws.h
deleted file mode 100644
index 712b9007c7..0000000000
--- a/src/gui/embedded/qkbd_qws.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QKBD_QWS_H
-#define QKBD_QWS_H
-
-#include <QtGui/qapplication.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_QWS_KEYBOARD
-
-class QWSKbPrivate;
-
-class Q_GUI_EXPORT QWSKeyboardHandler
-{
-public:
- QWSKeyboardHandler();
- QWSKeyboardHandler(const QString &device);
- virtual ~QWSKeyboardHandler();
-
- virtual void processKeyEvent(int unicode, int keycode, Qt::KeyboardModifiers modifiers,
- bool isPress, bool autoRepeat);
-
- enum KeycodeAction {
- None = 0,
-
- CapsLockOff = 0x01000000,
- CapsLockOn = 0x01000001,
- NumLockOff = 0x02000000,
- NumLockOn = 0x02000001,
- ScrollLockOff = 0x03000000,
- ScrollLockOn = 0x03000001,
-
- Reboot = 0x04000000,
-
- PreviousConsole = 0x05000000,
- NextConsole = 0x05000001,
- SwitchConsoleFirst = 0x06000000,
- SwitchConsoleLast = 0x0600007f,
- SwitchConsoleMask = 0x0000007f,
- };
-
- KeycodeAction processKeycode(quint16 keycode, bool pressed, bool autorepeat);
-
-protected:
- int transformDirKey(int key);
- void beginAutoRepeat(int uni, int code, Qt::KeyboardModifiers mod);
- void endAutoRepeat();
-
-private:
- QWSKbPrivate *d;
-};
-
-#endif // QT_NO_QWS_KEYBOARD
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QKBD_QWS_H
diff --git a/src/gui/embedded/qkbd_qws_p.h b/src/gui/embedded/qkbd_qws_p.h
deleted file mode 100644
index be260e3273..0000000000
--- a/src/gui/embedded/qkbd_qws_p.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWSKEYBOARD_P_H
-#define QWSKEYBOARD_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QDataStream>
-
-QT_BEGIN_NAMESPACE
-
-namespace QWSKeyboard {
- const quint32 FileMagic = 0x514d4150; // 'QMAP'
-
- struct Mapping {
- quint16 keycode;
- quint16 unicode;
- quint32 qtcode;
- quint8 modifiers;
- quint8 flags;
- quint16 special;
-
- };
-
- enum Flags {
- IsDead = 0x01,
- IsLetter = 0x02,
- IsModifier = 0x04,
- IsSystem = 0x08,
- };
-
- enum System {
- SystemConsoleFirst = 0x0100,
- SystemConsoleMask = 0x007f,
- SystemConsoleLast = 0x017f,
- SystemConsolePrevious = 0x0180,
- SystemConsoleNext = 0x0181,
- SystemReboot = 0x0200,
- SystemZap = 0x0300,
- };
-
- struct Composing {
- quint16 first;
- quint16 second;
- quint16 result;
- };
-
- enum Modifiers {
- ModPlain = 0x00,
- ModShift = 0x01,
- ModAltGr = 0x02,
- ModControl = 0x04,
- ModAlt = 0x08,
- ModShiftL = 0x10,
- ModShiftR = 0x20,
- ModCtrlL = 0x40,
- ModCtrlR = 0x80,
- // ModCapsShift = 0x100, // not supported!
- };
-};
-
-#ifndef QT_NO_DATASTREAM
-inline QDataStream &operator>>(QDataStream &ds, QWSKeyboard::Mapping &m)
-{
- return ds >> m.keycode >> m.unicode >> m.qtcode >> m.modifiers >> m.flags >> m.special;
-}
-
-inline QDataStream &operator<<(QDataStream &ds, const QWSKeyboard::Mapping &m)
-{
- return ds << m.keycode << m.unicode << m.qtcode << m.modifiers << m.flags << m.special;
-}
-
-inline QDataStream &operator>>(QDataStream &ds, QWSKeyboard::Composing &c)
-{
- return ds >> c.first >> c.second >> c.result;
-}
-
-inline QDataStream &operator<<(QDataStream &ds, const QWSKeyboard::Composing &c)
-{
- return ds << c.first << c.second << c.result;
-}
-#endif // QT_NO_DATASTREAM
-
-QT_END_NAMESPACE
-
-#endif // QWSKEYBOARD_H
diff --git a/src/gui/embedded/qkbddriverfactory_qws.cpp b/src/gui/embedded/qkbddriverfactory_qws.cpp
deleted file mode 100644
index 45825e52ea..0000000000
--- a/src/gui/embedded/qkbddriverfactory_qws.cpp
+++ /dev/null
@@ -1,187 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qkbddriverfactory_qws.h"
-
-#ifndef QT_NO_QWS_KEYBOARD
-
-#include "qapplication.h"
-#include "qkbdtty_qws.h"
-#include "qkbdlinuxinput_qws.h"
-#include "qkbdum_qws.h"
-#include "qkbdvfb_qws.h"
-#include "qkbdqnx_qws.h"
-#include "qkbdintegrity_qws.h"
-#include <stdlib.h>
-#include "private/qfactoryloader_p.h"
-#include "qkbddriverplugin_qws.h"
-
-QT_BEGIN_NAMESPACE
-
-#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
-#ifndef QT_NO_LIBRARY
-Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
- (QWSKeyboardHandlerFactoryInterface_iid,
- QLatin1String("/kbddrivers"), Qt::CaseInsensitive))
-
-#endif //QT_NO_LIBRARY
-#endif //QT_MAKEDLL
-
-/*!
- \class QKbdDriverFactory
- \ingroup qws
-
- \brief The QKbdDriverFactory class creates keyboard drivers in
- Qt for Embedded Linux.
-
- Note that this class is only available in \l{Qt for Embedded Linux}.
-
- QKbdDriverFactory is used to detect and instantiate the available
- keyboard drivers, allowing \l{Qt for Embedded Linux} to load the preferred
- driver into the server application at runtime. The create()
- function returns a QWSKeyboardHandler object representing the
- keyboard driver identified by a given key. The valid keys
- (i.e. the supported drivers) can be retrieved using the keys()
- function.
-
- \l{Qt for Embedded Linux} provides several built-in keyboard drivers. In
- addition, custom keyboard drivers can be added using Qt's plugin
- mechanism, i.e. by subclassing the QWSKeyboardHandler class and
- creating a keyboard driver plugin (QKbdDriverPlugin). See the
- \l{Qt for Embedded Linux Character Input}{character input} documentation
- for details.
-
- \sa QWSKeyboardHandler, QKbdDriverPlugin
-*/
-
-/*!
- Creates the keyboard driver specified by the given \a key, using
- the display specified by the given \a device.
-
- Note that the keys are case-insensitive.
-
- \sa keys()
-*/
-QWSKeyboardHandler *QKbdDriverFactory::create(const QString& key, const QString& device)
-{
- QString driver = key.toLower();
-#if defined(Q_OS_QNX) && !defined(QT_NO_QWS_KBD_QNX)
- if (driver == QLatin1String("qnx") || driver.isEmpty())
- return new QWSQnxKeyboardHandler(device);
-#endif
-#if defined(Q_OS_INTEGRITY)
- if (driver == QLatin1String("integrity") || driver.isEmpty())
- return new QWSIntKeyboardHandler(device);
-#endif
-#ifndef QT_NO_QWS_KEYBOARD
-# ifndef QT_NO_QWS_KBD_TTY
- if (driver == QLatin1String("tty") || driver.isEmpty())
- return new QWSTtyKeyboardHandler(device);
-# endif
-# ifndef QT_NO_QWS_KBD_LINUXINPUT
- if (driver == QLatin1String("linuxinput") || \
- driver == QLatin1String("usb") || \
- driver == QLatin1String("linuxis"))
- return new QWSLinuxInputKeyboardHandler(device);
-# endif
-# ifndef QT_NO_QWS_KBD_UM
- if (driver == QLatin1String("um") || driver == QLatin1String("qvfbkeyboard"))
- return new QWSUmKeyboardHandler(device);
-# endif
-# ifndef QT_NO_QWS_KBD_QVFB
- if (driver == QLatin1String("qvfbkbd")
- || driver == QLatin1String("qvfbkeyboard")
- || driver == QLatin1String("qvfb"))
- return new QVFbKeyboardHandler(device);
-# endif
-#endif
-
-#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
-#ifndef QT_NO_LIBRARY
- if (QWSKeyboardHandlerFactoryInterface *factory = qobject_cast<QWSKeyboardHandlerFactoryInterface*>(loader()->instance(driver)))
- return factory->create(driver, device);
-#endif
-#endif
- return 0;
-}
-
-/*!
- Returns the list of valid keys, i.e. the available keyboard
- drivers.
-
- \sa create()
-*/
-QStringList QKbdDriverFactory::keys()
-{
- QStringList list;
-
-#if defined(Q_OS_QNX) && !defined(QT_NO_QWS_KBD_QNX)
- list << QLatin1String("QNX");
-#endif
-#if defined(Q_OS_INTEGRITY) && !defined(QT_NO_QWS_KBD_INTEGRITY)
- list << QLatin1String("INTEGRITY");
-#endif
-#ifndef QT_NO_QWS_KBD_TTY
- list << QLatin1String("TTY");
-#endif
-#ifndef QT_NO_QWS_KBD_LINUXINPUT
- list << QLatin1String("LinuxInput");
-#endif
-#ifndef QT_NO_QWS_KBD_UM
- list << QLatin1String("UM");
-#endif
-
-#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
-#ifndef QT_NO_LIBRARY
- QStringList plugins = loader()->keys();
- for (int i = 0; i < plugins.size(); ++i) {
- if (!list.contains(plugins.at(i)))
- list += plugins.at(i);
- }
-#endif //QT_NO_LIBRARY
-#endif //QT_MAKEDLL
-
- return list;
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_KEYBOARD
diff --git a/src/gui/embedded/qkbddriverfactory_qws.h b/src/gui/embedded/qkbddriverfactory_qws.h
deleted file mode 100644
index ffb768b01f..0000000000
--- a/src/gui/embedded/qkbddriverfactory_qws.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QKBDDRIVERFACTORY_QWS_H
-#define QKBDDRIVERFACTORY_QWS_H
-
-#include <QtCore/qstringlist.h>
-
-#ifndef QT_NO_QWS_KEYBOARD
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QString;
-class QWSKeyboardHandler;
-
-class Q_GUI_EXPORT QKbdDriverFactory
-{
-public:
- static QStringList keys();
- static QWSKeyboardHandler *create(const QString&, const QString&);
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_QWS_KEYBOARD
-#endif // QKBDDRIVERFACTORY_QWS_H
diff --git a/src/gui/embedded/qkbddriverplugin_qws.cpp b/src/gui/embedded/qkbddriverplugin_qws.cpp
deleted file mode 100644
index 569cb425c9..0000000000
--- a/src/gui/embedded/qkbddriverplugin_qws.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qkbddriverplugin_qws.h"
-
-#ifndef QT_NO_LIBRARY
-
-#include "qkbd_qws.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QKbdDriverPlugin
- \ingroup plugins
- \ingroup qws
-
- \brief The QKbdDriverPlugin class is an abstract base class for
- keyboard driver plugins in Qt for Embedded Linux.
-
- Note that this class is only available in \l{Qt for Embedded Linux}.
-
- \l{Qt for Embedded Linux} provides ready-made drivers for several keyboard
- protocols, see the \l{Qt for Embedded Linux Character Input}{character
- input} documentation for details. Custom keyboard drivers can be
- implemented by subclassing the QWSKeyboardHandler class and
- creating a keyboard driver plugin.
-
- A keyboard driver plugin can be created by subclassing
- QKbdDriverPlugin and reimplementing the pure virtual keys() and
- create() functions. By exporting the derived class using the
- Q_EXPORT_PLUGIN2() macro, the default implementation of the
- QKbdDriverFactory class will automatically detect the plugin and
- load the driver into the server application at run-time. See
- \l{How to Create Qt Plugins} for details.
-
- \sa QKbdDriverFactory, QWSKeyboardHandler
-*/
-
-/*!
- \fn QStringList QKbdDriverPlugin::keys() const
-
- Implement this function to return the list of valid keys, i.e. the
- keyboard drivers supported by this plugin.
-
- \l{Qt for Embedded Linux} provides ready-made drivers for several keyboard
- protocols, see the \l{Qt for Embedded Linux Character Input}{character
- input} documentation for details.
-
- \sa create()
-*/
-
-/*!
- Constructs a keyboard driver plugin with the given \a parent.
-
- Note that this constructor is invoked automatically by the
- Q_EXPORT_PLUGIN2() macro, so there is no need for calling it
- explicitly.
-*/
-QKbdDriverPlugin::QKbdDriverPlugin(QObject *parent)
- : QObject(parent)
-{
-}
-
-/*!
- Destroys the keyboard driver plugin.
-
- Note that Qt destroys a plugin automatically when it is no longer
- used, so there is no need for calling the destructor explicitly.
-*/
-QKbdDriverPlugin::~QKbdDriverPlugin()
-{
-}
-
-/*!
- \fn QScreen *QKbdDriverPlugin::create(const QString &key, const QString &device)
-
- Implement this function to create a driver matching the type
- specified by the given \a key and \a device parameters. Note that
- keys are case-insensitive.
-
- \sa keys()
-*/
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_LIBRARY
diff --git a/src/gui/embedded/qkbddriverplugin_qws.h b/src/gui/embedded/qkbddriverplugin_qws.h
deleted file mode 100644
index 2bb111cbea..0000000000
--- a/src/gui/embedded/qkbddriverplugin_qws.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QKBDDRIVERPLUGIN_QWS_H
-#define QKBDDRIVERPLUGIN_QWS_H
-
-#include <QtCore/qplugin.h>
-#include <QtCore/qfactoryinterface.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_LIBRARY
-
-class QWSKeyboardHandler;
-
-struct Q_GUI_EXPORT QWSKeyboardHandlerFactoryInterface : public QFactoryInterface
-{
- virtual QWSKeyboardHandler* create(const QString &name, const QString &device) = 0;
-};
-
-#define QWSKeyboardHandlerFactoryInterface_iid "com.trolltech.Qt.QWSKeyboardHandlerFactoryInterface"
-Q_DECLARE_INTERFACE(QWSKeyboardHandlerFactoryInterface, QWSKeyboardHandlerFactoryInterface_iid)
-
-class Q_GUI_EXPORT QKbdDriverPlugin : public QObject, public QWSKeyboardHandlerFactoryInterface
-{
- Q_OBJECT
- Q_INTERFACES(QWSKeyboardHandlerFactoryInterface:QFactoryInterface)
-public:
- explicit QKbdDriverPlugin(QObject *parent = 0);
- ~QKbdDriverPlugin();
-
- virtual QStringList keys() const = 0;
- virtual QWSKeyboardHandler* create(const QString& driver, const QString &device) = 0;
-};
-
-#endif // QT_NO_LIBRARY
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QKBDDRIVERPLUGIN_QWS_H
diff --git a/src/gui/embedded/qkbdintegrity_qws.cpp b/src/gui/embedded/qkbdintegrity_qws.cpp
deleted file mode 100644
index b2df4226a8..0000000000
--- a/src/gui/embedded/qkbdintegrity_qws.cpp
+++ /dev/null
@@ -1,197 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#if !defined(QT_NO_QWS_KEYBOARD) && !defined(QT_NO_QWS_KBD_INTEGRITY)
-
-#include "qkbdintegrity_qws.h"
-#include <qwindowsystem_qws.h>
-#include <qapplication.h>
-#include <qtimer.h>
-#include <qthread.h>
-
-#include <INTEGRITY.h>
-
-
-//===========================================================================
-
-QT_BEGIN_NAMESPACE
-
-//
-// INTEGRITY keyboard
-//
-
-class QIntKeyboardListenThread;
-
-class QWSIntKbPrivate : public QObject
-{
- Q_OBJECT
- friend class QIntKeyboardListenThread;
-public:
- QWSIntKbPrivate(QWSKeyboardHandler *, const QString &device);
- ~QWSIntKbPrivate();
- void dataReady(int amount) { emit kbdDataAvailable(amount); }
- uint8_t scancodebuf[32 /* USB_SCANCODE_BUF_LEN */ ];
- uint8_t rxpost;
- uint8_t rxack;
-
-Q_SIGNALS:
- void kbdDataAvailable(int amount);
-
-private Q_SLOTS:
- void readKeyboardData(int amount);
-
-private:
- QWSKeyboardHandler *handler;
- QIntKeyboardListenThread *kbdthread;
-};
-class QIntKeyboardListenThread : public QThread
-{
-protected:
- QWSIntKbPrivate *imp;
- bool loop;
-public:
- QIntKeyboardListenThread(QWSIntKbPrivate *im) : QThread(), imp(im) {};
- ~QIntKeyboardListenThread() {};
- void run();
- void stoploop() { loop = false; };
-};
-
-
-QWSIntKeyboardHandler::QWSIntKeyboardHandler(const QString &device)
- : QWSKeyboardHandler(device)
-{
- d = new QWSIntKbPrivate(this, device);
-}
-
-QWSIntKeyboardHandler::~QWSIntKeyboardHandler()
-{
- delete d;
-}
-
-//void QWSIntKeyboardHandler::processKeyEvent(int keycode, bool isPress,
-// bool autoRepeat)
-//{
-// QWSKeyboardHandler::processKeyEvent(keycode, isPress, autoRepeat);
-//}
-
-void QIntKeyboardListenThread::run(void)
-{
- Error E;
- Buffer b;
- Connection kbdc;
- bool waitforresource = true;
- do {
- E = RequestResource((Object*)&kbdc,
- "USBKeyboardClient", "!systempassword");
- if (E == Success) {
- loop = false;
- } else {
- E = RequestResource((Object*)&kbdc,
- "KeyboardClient", "!systempassword");
- if (E == Success) {
- waitforresource = false;
- }
- }
- if (waitforresource)
- ::sleep(1);
- } while (loop && waitforresource);
- if (!loop)
- return;
- b.BufferType = DataBuffer | LastBuffer;
- b.Length = sizeof(imp->scancodebuf);
- b.TheAddress = (Address)imp->scancodebuf;
- do {
- b.Transferred = 0;
- b.TheAddress = (Address)imp->scancodebuf + imp->rxpost;
- CheckSuccess(SynchronousReceive(kbdc, &b));
- imp->rxpost += b.Transferred;
- if (imp->rxpost >= 32 /* USB_SCANCODE_BUF_LEN */)
- imp->rxpost = 0;
- if (imp->rxpost == (imp->rxack + b.Transferred) % 32 /* USB_SCANCODE_BUF_LEN */) {
- imp->kbdDataAvailable(b.Transferred);
- }
- } while (loop);
-}
-
-void QWSIntKbPrivate::readKeyboardData(int amount)
-{
- uint16_t keycode;
- do {
- if (scancodebuf[rxack] == 0xe0) {
- keycode = scancodebuf[rxack] << 8;
- rxack++;
- if (rxack >= 32 /* USB_SCANCODE_BUF_LEN */)
- rxack = 0;
- } else {
- keycode = 0;
- }
-
- handler->processKeycode(keycode + (scancodebuf[rxack] & 0x7f),
- (scancodebuf[rxack] & 0x80) == 0,
- scancodebuf[rxack] == 2);
- rxack++;
- if (rxack >= 32 /* USB_SCANCODE_BUF_LEN */)
- rxack = 0;
- } while (rxack != rxpost);
-}
-
-QWSIntKbPrivate::QWSIntKbPrivate(QWSKeyboardHandler *h, const QString &device) : handler(h)
-{
- connect(this, SIGNAL(kbdDataAvailable(int)), this, SLOT(readKeyboardData(int)));
- this->handler = handler;
- rxack = rxpost = 0;
- kbdthread = new QIntKeyboardListenThread(this);
- kbdthread->start();
-}
-
-QWSIntKbPrivate::~QWSIntKbPrivate()
-{
- kbdthread->stoploop();
- kbdthread->wait();
- delete kbdthread;
-}
-
-
-QT_END_NAMESPACE
-
-#include "qkbdintegrity_qws.moc"
-
-#endif // QT_NO_QWS_KEYBOARD || QT_NO_QWS_KBD_TTY
diff --git a/src/gui/embedded/qkbdintegrity_qws.h b/src/gui/embedded/qkbdintegrity_qws.h
deleted file mode 100644
index f9ae4e3250..0000000000
--- a/src/gui/embedded/qkbdintegrity_qws.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QKBDINTEGRITY_QWS_H
-#define QKBDINTEGRITY_QWS_H
-
-#include <QtGui/qkbd_qws.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_QWS_KEYBOARD
-
-#ifndef QT_NO_QWS_KBD_INTEGRITY
-
-class QSocketNotifier;
-class QWSIntKbPrivate;
-
-class QWSIntKeyboardHandler : public QWSKeyboardHandler
-{
-public:
- explicit QWSIntKeyboardHandler(const QString&);
- virtual ~QWSIntKeyboardHandler();
-
-//protected:
-// virtual void processKeyEvent(int keycode, bool isPress, bool autoRepeat);
-
-private:
- QWSIntKbPrivate *d;
-};
-
-#endif // QT_NO_QWS_KBD_INTEGRITY
-
-#endif // QT_NO_QWS_KEYBOARD
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QKBDINTEGRITY_QWS_H
diff --git a/src/gui/embedded/qkbdlinuxinput_qws.cpp b/src/gui/embedded/qkbdlinuxinput_qws.cpp
deleted file mode 100644
index 71910b41e7..0000000000
--- a/src/gui/embedded/qkbdlinuxinput_qws.cpp
+++ /dev/null
@@ -1,245 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qkbdlinuxinput_qws.h"
-
-#ifndef QT_NO_QWS_KEYBOARD
-
-#include <QSocketNotifier>
-#include <QStringList>
-
-#include <qplatformdefs.h>
-#include <private/qcore_unix_p.h> // overrides QT_OPEN
-
-#include <errno.h>
-#include <termios.h>
-
-#include <linux/kd.h>
-#include <linux/input.h>
-
-QT_BEGIN_NAMESPACE
-
-
-class QWSLinuxInputKbPrivate : public QObject
-{
- Q_OBJECT
-public:
- QWSLinuxInputKbPrivate(QWSLinuxInputKeyboardHandler *, const QString &);
- ~QWSLinuxInputKbPrivate();
-
-private:
- void switchLed(int, bool);
-
-private Q_SLOTS:
- void readKeycode();
-
-private:
- QWSLinuxInputKeyboardHandler *m_handler;
- int m_fd;
- int m_tty_fd;
- struct termios m_tty_attr;
- int m_orig_kbmode;
-};
-
-QWSLinuxInputKeyboardHandler::QWSLinuxInputKeyboardHandler(const QString &device)
- : QWSKeyboardHandler(device)
-{
- d = new QWSLinuxInputKbPrivate(this, device);
-}
-
-QWSLinuxInputKeyboardHandler::~QWSLinuxInputKeyboardHandler()
-{
- delete d;
-}
-
-bool QWSLinuxInputKeyboardHandler::filterInputEvent(quint16 &, qint32 &)
-{
- return false;
-}
-
-QWSLinuxInputKbPrivate::QWSLinuxInputKbPrivate(QWSLinuxInputKeyboardHandler *h, const QString &device)
- : m_handler(h), m_fd(-1), m_tty_fd(-1), m_orig_kbmode(K_XLATE)
-{
- setObjectName(QLatin1String("LinuxInputSubsystem Keyboard Handler"));
-
- QString dev = QLatin1String("/dev/input/event1");
- int repeat_delay = -1;
- int repeat_rate = -1;
-
- QStringList args = device.split(QLatin1Char(':'));
- foreach (const QString &arg, args) {
- if (arg.startsWith(QLatin1String("repeat-delay=")))
- repeat_delay = arg.mid(13).toInt();
- else if (arg.startsWith(QLatin1String("repeat-rate=")))
- repeat_rate = arg.mid(12).toInt();
- else if (arg.startsWith(QLatin1String("/dev/")))
- dev = arg;
- }
-
- m_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDWR, 0);
- if (m_fd >= 0) {
- if (repeat_delay > 0 && repeat_rate > 0) {
- int kbdrep[2] = { repeat_delay, repeat_rate };
- ::ioctl(m_fd, EVIOCSREP, kbdrep);
- }
-
- QSocketNotifier *notifier;
- notifier = new QSocketNotifier(m_fd, QSocketNotifier::Read, this);
- connect(notifier, SIGNAL(activated(int)), this, SLOT(readKeycode()));
-
- // play nice in case we are started from a shell (e.g. for debugging)
- m_tty_fd = isatty(0) ? 0 : -1;
-
- if (m_tty_fd >= 0) {
- // save tty config for restore.
- tcgetattr(m_tty_fd, &m_tty_attr);
-
- struct ::termios termdata;
- tcgetattr(m_tty_fd, &termdata);
-
- // record the original mode so we can restore it again in the destructor.
- ::ioctl(m_tty_fd, KDGKBMODE, &m_orig_kbmode);
-
- // setting this translation mode is even needed in INPUT mode to prevent
- // the shell from also interpreting codes, if the process has a tty
- // attached: e.g. Ctrl+C wouldn't copy, but kill the application.
- ::ioctl(m_tty_fd, KDSKBMODE, K_MEDIUMRAW);
-
- // set the tty layer to pass-through
- termdata.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
- termdata.c_oflag = 0;
- termdata.c_cflag = CREAD | CS8;
- termdata.c_lflag = 0;
- termdata.c_cc[VTIME]=0;
- termdata.c_cc[VMIN]=1;
- cfsetispeed(&termdata, 9600);
- cfsetospeed(&termdata, 9600);
- tcsetattr(m_tty_fd, TCSANOW, &termdata);
- }
- } else {
- qWarning("Cannot open keyboard input device '%s': %s", qPrintable(dev), strerror(errno));
- return;
- }
-}
-
-QWSLinuxInputKbPrivate::~QWSLinuxInputKbPrivate()
-{
- if (m_tty_fd >= 0) {
- ::ioctl(m_tty_fd, KDSKBMODE, m_orig_kbmode);
- tcsetattr(m_tty_fd, TCSANOW, &m_tty_attr);
- }
- if (m_fd >= 0)
- QT_CLOSE(m_fd);
-}
-
-void QWSLinuxInputKbPrivate::switchLed(int led, bool state)
-{
- struct ::input_event led_ie;
- ::gettimeofday(&led_ie.time, 0);
- led_ie.type = EV_LED;
- led_ie.code = led;
- led_ie.value = state;
-
- QT_WRITE(m_fd, &led_ie, sizeof(led_ie));
-}
-
-void QWSLinuxInputKbPrivate::readKeycode()
-{
- struct ::input_event buffer[32];
- int n = 0;
-
- forever {
- n = QT_READ(m_fd, reinterpret_cast<char *>(buffer) + n, sizeof(buffer) - n);
-
- if (n == 0) {
- qWarning("Got EOF from the input device.");
- return;
- } else if (n < 0 && (errno != EINTR && errno != EAGAIN)) {
- qWarning("Could not read from input device: %s", strerror(errno));
- return;
- } else if (n % sizeof(buffer[0]) == 0) {
- break;
- }
- }
-
- n /= sizeof(buffer[0]);
-
- for (int i = 0; i < n; ++i) {
- if (buffer[i].type != EV_KEY)
- continue;
-
- quint16 code = buffer[i].code;
- qint32 value = buffer[i].value;
-
- if (m_handler->filterInputEvent(code, value))
- continue;
-
- QWSKeyboardHandler::KeycodeAction ka;
- ka = m_handler->processKeycode(code, value != 0, value == 2);
-
- switch (ka) {
- case QWSKeyboardHandler::CapsLockOn:
- case QWSKeyboardHandler::CapsLockOff:
- switchLed(LED_CAPSL, ka == QWSKeyboardHandler::CapsLockOn);
- break;
-
- case QWSKeyboardHandler::NumLockOn:
- case QWSKeyboardHandler::NumLockOff:
- switchLed(LED_NUML, ka == QWSKeyboardHandler::NumLockOn);
- break;
-
- case QWSKeyboardHandler::ScrollLockOn:
- case QWSKeyboardHandler::ScrollLockOff:
- switchLed(LED_SCROLLL, ka == QWSKeyboardHandler::ScrollLockOn);
- break;
-
- default:
- // ignore console switching and reboot
- break;
- }
- }
-}
-
-QT_END_NAMESPACE
-
-#include "qkbdlinuxinput_qws.moc"
-
-#endif // QT_NO_QWS_KEYBOARD
diff --git a/src/gui/embedded/qkbdlinuxinput_qws.h b/src/gui/embedded/qkbdlinuxinput_qws.h
deleted file mode 100644
index 4cd45de854..0000000000
--- a/src/gui/embedded/qkbdlinuxinput_qws.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QKBDLINUXINPUT_QWS_H
-#define QKBDLINUXINPUT_QWS_H
-
-#include <QtGui/qkbd_qws.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_QWS_KEYBOARD
-
-#ifndef QT_NO_QWS_KBD_LINUXINPUT
-
-class QWSLinuxInputKbPrivate;
-
-class QWSLinuxInputKeyboardHandler : public QWSKeyboardHandler
-{
-public:
- QWSLinuxInputKeyboardHandler(const QString&);
- virtual ~QWSLinuxInputKeyboardHandler();
-
- virtual bool filterInputEvent(quint16 &input_code, qint32 &input_value);
-
-private:
- QWSLinuxInputKbPrivate *d;
-};
-
-#endif // QT_NO_QWS_KBD_LINUXINPUT
-
-#endif // QT_NO_QWS_KEYBOARD
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QKBDLINUXINPUT_QWS_H
diff --git a/src/gui/embedded/qkbdqnx_qws.cpp b/src/gui/embedded/qkbdqnx_qws.cpp
deleted file mode 100644
index 87e658d35a..0000000000
--- a/src/gui/embedded/qkbdqnx_qws.cpp
+++ /dev/null
@@ -1,236 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qkbdqnx_qws.h"
-#include "QtCore/qsocketnotifier.h"
-#include "QtCore/qdebug.h"
-
-#include <sys/dcmd_input.h>
-#include <photon/keycodes.h>
-
-#include "qplatformdefs.h"
-#include <errno.h>
-
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QWSQnxKeyboardHandler
- \preliminary
- \ingroup qws
- \since 4.6
- \internal
-
- \brief The QWSQnxKeyboardHandler class implements a keyboard driver
- for the QNX \c{devi-hid} input manager.
-
- To be able to compile this mouse handler, \l{Qt for Embedded Linux}
- must be configured with the \c -qt-kbd-qnx option, see the
- \l{Qt for Embedded Linux Character Input} documentation for details.
-
- In order to use this keyboard handler, the \c{devi-hid} input manager
- must be set up and run with the resource manager interface (option \c{-r}).
- Also, Photon must not be running.
-
- Example invocation from command line: \c{/usr/photon/bin/devi-hid -Pr kbd mouse}
- Note that after running \c{devi-hid}, you will not be able to use the local
- shell anymore. It is suggested to run the command in a shell scrip, that launches
- a Qt application after invocation of \c{devi-hid}.
-
- To make \l{Qt for Embedded Linux} explicitly choose the qnx keyboard
- handler, set the QWS_KEYBOARD environment variable to \c{qnx}. By default,
- the first keyboard device (\c{/dev/devi/keyboard0}) is used. To override, pass a device
- name as the first and only parameter, for example
- \c{QWS_KEYBOARD=qnx:/dev/devi/keyboard1; export QWS_KEYBOARD}.
-
- \sa {Qt for Embedded Linux Character Input}, {Qt for Embedded Linux}
-*/
-
-/*!
- Constructs a keyboard handler for the specified \a device, defaulting to
- \c{/dev/devi/keyboard0}.
-
- Note that you should never instanciate this class, instead let QKbdDriverFactory
- handle the keyboard handlers.
-
- \sa QKbdDriverFactory
- */
-QWSQnxKeyboardHandler::QWSQnxKeyboardHandler(const QString &device)
-{
- // open the keyboard device
- keyboardFD = QT_OPEN(device.isEmpty() ? "/dev/devi/keyboard0" : device.toLatin1().constData(),
- QT_OPEN_RDONLY);
- if (keyboardFD == -1) {
- qErrnoWarning(errno, "QWSQnxKeyboardHandler: Unable to open device");
- return;
- }
-
- // create a socket notifier so we'll wake up whenever keyboard input is detected.
- QSocketNotifier *notifier = new QSocketNotifier(keyboardFD, QSocketNotifier::Read, this);
- connect(notifier, SIGNAL(activated(int)), SLOT(socketActivated()));
-
- qDebug() << "QWSQnxKeyboardHandler: connected.";
-
-}
-
-/*!
- Destroys this keyboard handler and closes the connection to the keyboard device.
- */
-QWSQnxKeyboardHandler::~QWSQnxKeyboardHandler()
-{
- QT_CLOSE(keyboardFD);
-}
-
-/*! \internal
- Translates the QNX keyboard events to Qt keyboard events
- */
-void QWSQnxKeyboardHandler::socketActivated()
-{
- _keyboard_packet packet;
-
- // read one keyboard event
- int bytesRead = QT_READ(keyboardFD, &packet, sizeof(_keyboard_packet));
- if (bytesRead == -1) {
- qErrnoWarning(errno, "QWSQnxKeyboardHandler::socketActivated(): Unable to read data.");
- return;
- }
-
- // the bytes read must be the size of a keyboard packet
- Q_ASSERT(bytesRead == sizeof(_keyboard_packet));
-
-#if 0
- qDebug() << "keyboard got scancode"
- << hex << packet.data.modifiers
- << packet.data.flags
- << packet.data.key_cap
- << packet.data.key_sym
- << packet.data.key_scan;
-#endif
-
- // QNX is nice enough to translate the raw keyboard data into a QNX data structure
- // Now we just have to translate it into a format Qt understands.
-
- // figure out whether it's a press
- bool isPress = packet.data.key_cap & KEY_DOWN;
- // figure out whether the key is still pressed and the key event is repeated
- bool isRepeat = packet.data.key_cap & KEY_REPEAT;
-
- Qt::Key key = Qt::Key_unknown;
- int unicode = 0xffff;
-
- // TODO - this switch is not complete!
- switch (packet.data.key_scan) {
- case KEYCODE_SPACE: key = Qt::Key_Space; unicode = 0x20; break;
- case KEYCODE_F1: key = Qt::Key_F1; break;
- case KEYCODE_F2: key = Qt::Key_F2; break;
- case KEYCODE_F3: key = Qt::Key_F3; break;
- case KEYCODE_F4: key = Qt::Key_F4; break;
- case KEYCODE_F5: key = Qt::Key_F5; break;
- case KEYCODE_F6: key = Qt::Key_F6; break;
- case KEYCODE_F7: key = Qt::Key_F7; break;
- case KEYCODE_F8: key = Qt::Key_F8; break;
- case KEYCODE_F9: key = Qt::Key_F9; break;
- case KEYCODE_F10: key = Qt::Key_F10; break;
- case KEYCODE_F11: key = Qt::Key_F11; break;
- case KEYCODE_F12: key = Qt::Key_F12; break;
- case KEYCODE_BACKSPACE: key = Qt::Key_Backspace; break;
- case KEYCODE_TAB: key = Qt::Key_Tab; break;
- case KEYCODE_RETURN: key = Qt::Key_Return; break;
- case KEYCODE_KP_ENTER: key = Qt::Key_Enter; break;
- case KEYCODE_UP:
- case KEYCODE_KP_UP:
- key = Qt::Key_Up; break;
- case KEYCODE_DOWN:
- case KEYCODE_KP_DOWN:
- key = Qt::Key_Down; break;
- case KEYCODE_LEFT:
- case KEYCODE_KP_LEFT:
- key = Qt::Key_Left; break;
- case KEYCODE_RIGHT:
- case KEYCODE_KP_RIGHT:
- key = Qt::Key_Right; break;
- case KEYCODE_HOME:
- case KEYCODE_KP_HOME:
- key = Qt::Key_Home; break;
- case KEYCODE_END:
- case KEYCODE_KP_END:
- key = Qt::Key_End; break;
- case KEYCODE_PG_UP:
- case KEYCODE_KP_PG_UP:
- key = Qt::Key_PageUp; break;
- case KEYCODE_PG_DOWN:
- case KEYCODE_KP_PG_DOWN:
- key = Qt::Key_PageDown; break;
- case KEYCODE_INSERT:
- case KEYCODE_KP_INSERT:
- key = Qt::Key_Insert; break;
- case KEYCODE_DELETE:
- case KEYCODE_KP_DELETE:
- key = Qt::Key_Delete; break;
- case KEYCODE_ESCAPE:
- key = Qt::Key_Escape; break;
- default: // none of the above, try the key_scan directly
- unicode = packet.data.key_scan;
- break;
- }
-
- // figure out the modifiers that are currently pressed
- Qt::KeyboardModifiers modifiers = Qt::NoModifier;
- if (packet.data.flags & KEYMOD_SHIFT)
- modifiers |= Qt::ShiftModifier;
- if (packet.data.flags & KEYMOD_CTRL)
- modifiers |= Qt::ControlModifier;
- if (packet.data.flags & KEYMOD_ALT)
- modifiers |= Qt::AltModifier;
-
- // if the unicode value is not ascii, we ignore it.
- // TODO - do a complete mapping between all QNX scan codes and Qt codes
- if (unicode != 0xffff && !isascii(unicode))
- return; // unprintable character
-
- // call processKeyEvent. This is where all the magic happens to insert a
- // key event into Qt's event loop.
- // Note that for repeated key events, isPress must be true
- // (on QNX, isPress is not set when the key event is repeated).
- processKeyEvent(unicode, key, modifiers, isPress || isRepeat, isRepeat);
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/embedded/qkbdqnx_qws.h b/src/gui/embedded/qkbdqnx_qws.h
deleted file mode 100644
index 1615a42fd7..0000000000
--- a/src/gui/embedded/qkbdqnx_qws.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QKBDQNX_QWS_H
-#define QKBDQNX_QWS_H
-
-#include <QtGui/qapplication.h>
-#include <QtGui/qkbd_qws.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if !defined(QT_NO_QWS_KEYBOARD) && !defined(QT_NO_QWS_KBD_QNX)
-
-class Q_GUI_EXPORT QWSQnxKeyboardHandler : public QObject, public QWSKeyboardHandler
-{
- Q_OBJECT
-public:
- QWSQnxKeyboardHandler(const QString &device);
- ~QWSQnxKeyboardHandler();
-
-private Q_SLOTS:
- void socketActivated();
-
-private:
- int keyboardFD;
-};
-
-#endif // QT_NO_QWS_KEYBOARD
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QKBDQNX_QWS_H
diff --git a/src/gui/embedded/qkbdtty_qws.cpp b/src/gui/embedded/qkbdtty_qws.cpp
deleted file mode 100644
index c4b7df2d9b..0000000000
--- a/src/gui/embedded/qkbdtty_qws.cpp
+++ /dev/null
@@ -1,353 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qkbdtty_qws.h"
-
-#if !defined(QT_NO_QWS_KEYBOARD) && !defined(QT_NO_QWS_KBD_TTY)
-
-#include <QSocketNotifier>
-#include <QStringList>
-
-#include <qplatformdefs.h>
-#include <private/qcore_unix_p.h> // overrides QT_OPEN
-
-#include <errno.h>
-#include <termios.h>
-
-#if defined Q_OS_LINUX
-# include <linux/kd.h>
-# include <linux/vt.h> //TODO: move vt handling somewhere else (QLinuxFbScreen?)
-
-# include "qscreen_qws.h"
-# include "qwindowsystem_qws.h"
-# include "qapplication.h"
-# include "private/qwindowsurface_qws_p.h"
-# include "private/qwssignalhandler_p.h"
-
-# define VTACQSIG SIGUSR1
-# define VTRELSIG SIGUSR2
-#endif
-
-
-QT_BEGIN_NAMESPACE
-
-class QWSTtyKbPrivate : public QObject
-{
- Q_OBJECT
-public:
- QWSTtyKbPrivate(QWSTtyKeyboardHandler *handler, const QString &device);
- ~QWSTtyKbPrivate();
-
-private:
- void switchLed(char, bool);
- void switchConsole(int vt);
-
-private Q_SLOTS:
- void readKeycode();
- void handleConsoleSwitch(int sig);
-
-private:
- QWSTtyKeyboardHandler *m_handler;
- int m_tty_fd;
- struct termios m_tty_attr;
- char m_last_keycode;
- int m_vt_qws;
- int m_orig_kbmode;
-};
-
-
-QWSTtyKeyboardHandler::QWSTtyKeyboardHandler(const QString &device)
- : QWSKeyboardHandler(device)
-{
- d = new QWSTtyKbPrivate(this, device);
-}
-
-QWSTtyKeyboardHandler::~QWSTtyKeyboardHandler()
-{
- delete d;
-}
-
-bool QWSTtyKeyboardHandler::filterKeycode(char &)
-{
- return false;
-}
-
-QWSTtyKbPrivate::QWSTtyKbPrivate(QWSTtyKeyboardHandler *h, const QString &device)
- : m_handler(h), m_tty_fd(-1), m_last_keycode(0), m_vt_qws(0), m_orig_kbmode(K_XLATE)
-{
- setObjectName(QLatin1String("TTY Keyboard Handler"));
-#ifndef QT_NO_QWS_SIGNALHANDLER
- QWSSignalHandler::instance()->addObject(this);
-#endif
-
- QString dev = QLatin1String("/dev/tty0");
- int repeat_delay = -1;
- int repeat_rate = -1;
-
- QStringList args = device.split(QLatin1Char(':'));
- foreach (const QString &arg, args) {
- if (arg.startsWith(QLatin1String("repeat-delay=")))
- repeat_delay = arg.mid(13).toInt();
- else if (arg.startsWith(QLatin1String("repeat-rate=")))
- repeat_rate = arg.mid(12).toInt();
- else if (arg.startsWith(QLatin1String("/dev/")))
- dev = arg;
- }
-
- m_tty_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDWR, 0);
- if (m_tty_fd >= 0) {
- if (repeat_delay > 0 && repeat_rate > 0) {
-#if defined(Q_OS_LINUX)
- struct ::kbd_repeat kbdrep = { repeat_delay, repeat_rate };
- ::ioctl(m_tty_fd, KDKBDREP, &kbdrep);
-#endif
- }
-
- QSocketNotifier *notifier;
- notifier = new QSocketNotifier(m_tty_fd, QSocketNotifier::Read, this);
- connect(notifier, SIGNAL(activated(int)), this, SLOT(readKeycode()));
-
- // save tty config for restore.
- tcgetattr(m_tty_fd, &m_tty_attr);
-
- struct ::termios termdata;
- tcgetattr(m_tty_fd, &termdata);
-
-#if defined(Q_OS_LINUX)
- // record the original mode so we can restore it again in the destructor.
- ::ioctl(m_tty_fd, KDGKBMODE, &m_orig_kbmode);
-
- // PLEASE NOTE:
- // the tty keycode interface can only report keycodes 0x01 .. 0x7f
- // KEY_MAX is however defined to 0x1ff. In practice this is sufficient
- // for a PC style keyboard though.
- // we don't support K_RAW anymore - if you need that, you have to add
- // a scan- to keycode converter yourself.
- ::ioctl(m_tty_fd, KDSKBMODE, K_MEDIUMRAW);
-#endif
-
- // set the tty layer to pass-through
- termdata.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
- termdata.c_oflag = 0;
- termdata.c_cflag = CREAD | CS8;
- termdata.c_lflag = 0;
- termdata.c_cc[VTIME]=0;
- termdata.c_cc[VMIN]=1;
- cfsetispeed(&termdata, 9600);
- cfsetospeed(&termdata, 9600);
- tcsetattr(m_tty_fd, TCSANOW, &termdata);
-
-#if defined(Q_OS_LINUX)
- // VT switching is handled via unix signals
- connect(QApplication::instance(), SIGNAL(unixSignal(int)), this, SLOT(handleConsoleSwitch(int)));
- QApplication::instance()->watchUnixSignal(VTACQSIG, true);
- QApplication::instance()->watchUnixSignal(VTRELSIG, true);
-
- struct ::vt_mode vtMode;
- if (::ioctl(m_tty_fd, VT_GETMODE, &vtMode) == 0) {
- vtMode.mode = VT_PROCESS;
- vtMode.relsig = VTRELSIG;
- vtMode.acqsig = VTACQSIG;
-
- if (::ioctl(m_tty_fd, VT_SETMODE, &vtMode) == 0) {
- struct ::vt_stat vtStat;
- ::memset(&vtStat, 0, sizeof(vtStat));
-
- if (::ioctl(m_tty_fd, VT_GETSTATE, &vtStat) == 0 ) {
- m_vt_qws = vtStat.v_active;
- }
- }
- }
-
- if (!m_vt_qws)
- qWarning("Could not initialize virtual console switching");
-#endif
- } else {
- qWarning("Cannot open input device '%s': %s", qPrintable(dev), strerror(errno));
- return;
- }
-
-}
-
-QWSTtyKbPrivate::~QWSTtyKbPrivate()
-{
- if (m_tty_fd >= 0) {
-#if defined(Q_OS_LINUX)
- ::ioctl(m_tty_fd, KDSKBMODE, m_orig_kbmode);
-#endif
- tcsetattr(m_tty_fd, TCSANOW, &m_tty_attr);
- QT_CLOSE(m_tty_fd);
- }
-}
-
-
-
-void QWSTtyKbPrivate::switchLed(char led, bool state)
-{
-#if defined(Q_OS_LINUX)
- char ledstate;
-
- ::ioctl(m_tty_fd, KDGETLED, &ledstate);
- if (state)
- ledstate |= led;
- else
- ledstate &= ~led;
- ::ioctl(m_tty_fd, KDSETLED, ledstate);
-#endif
-}
-
-void QWSTtyKbPrivate::readKeycode()
-{
- char buffer[32];
- int n = 0;
-
- forever {
- n = QT_READ(m_tty_fd, buffer + n, 32 - n);
-
- if (n == 0) {
- qWarning("Got EOF from the input device.");
- return;
- } else if (n < 0 && (errno != EINTR && errno != EAGAIN)) {
- qWarning("Could not read from input device: %s", strerror(errno));
- return;
- } else {
- break;
- }
- }
-
- for (int i = 0; i < n; ++i) {
- if (m_handler->filterKeycode(buffer[i]))
- continue;
-
- QWSKeyboardHandler::KeycodeAction ka;
- ka = m_handler->processKeycode(buffer[i] & 0x7f, (buffer[i] & 0x80) == 0x00, buffer[i] == m_last_keycode);
- m_last_keycode = buffer[i];
-
- switch (ka) {
- case QWSKeyboardHandler::CapsLockOn:
- case QWSKeyboardHandler::CapsLockOff:
- switchLed(LED_CAP, ka == QWSKeyboardHandler::CapsLockOn);
- break;
-
- case QWSKeyboardHandler::NumLockOn:
- case QWSKeyboardHandler::NumLockOff:
- switchLed(LED_NUM, ka == QWSKeyboardHandler::NumLockOn);
- break;
-
- case QWSKeyboardHandler::ScrollLockOn:
- case QWSKeyboardHandler::ScrollLockOff:
- switchLed(LED_SCR, ka == QWSKeyboardHandler::ScrollLockOn);
- break;
-
- case QWSKeyboardHandler::PreviousConsole:
- switchConsole(qBound(1, m_vt_qws - 1, 10));
- break;
-
- case QWSKeyboardHandler::NextConsole:
- switchConsole(qBound(1, m_vt_qws + 1, 10));
- break;
-
- default:
- if (ka >= QWSKeyboardHandler::SwitchConsoleFirst &&
- ka <= QWSKeyboardHandler::SwitchConsoleLast) {
- switchConsole(1 + (ka & QWSKeyboardHandler::SwitchConsoleMask));
- }
- //ignore reboot
- break;
- }
- }
-}
-
-
-void QWSTtyKbPrivate::switchConsole(int vt)
-{
-#if defined(Q_OS_LINUX)
- if (m_vt_qws && vt && (m_tty_fd >= 0 ))
- ::ioctl(m_tty_fd, VT_ACTIVATE, vt);
-#endif
-}
-
-void QWSTtyKbPrivate::handleConsoleSwitch(int sig)
-{
-#if defined(Q_OS_LINUX)
- // received a notification from the kernel that the current VT is
- // changing: either enable or disable QWS painting accordingly.
-
- if (sig == VTACQSIG) {
- if (::ioctl(m_tty_fd, VT_RELDISP, VT_ACKACQ) == 0) {
- qwsServer->enablePainting(true);
- qt_screen->restore();
- qwsServer->resumeMouse();
- qwsServer->refresh();
- }
- } else if (sig == VTRELSIG) {
- qwsServer->enablePainting(false);
-
- // Check for reserved surfaces which might still do painting
- bool allWindowsHidden = true;
- const QList<QWSWindow*> windows = QWSServer::instance()->clientWindows();
- for (int i = 0; i < windows.size(); ++i) {
- const QWSWindow *w = windows.at(i);
- QWSWindowSurface *s = w->windowSurface();
- if (s && s->isRegionReserved() && !w->allocatedRegion().isEmpty()) {
- allWindowsHidden = false;
- break;
- }
- }
-
- if (!allWindowsHidden) {
- ::ioctl(m_tty_fd, VT_RELDISP, 0); // abort console switch
- qwsServer->enablePainting(true);
- } else if (::ioctl(m_tty_fd, VT_RELDISP, 1) == 0) {
- qt_screen->save();
- qwsServer->suspendMouse();
- } else {
- qwsServer->enablePainting(true);
- }
- }
-#endif
-}
-
-QT_END_NAMESPACE
-
-#include "qkbdtty_qws.moc"
-
-#endif // QT_NO_QWS_KEYBOARD || QT_NO_QWS_KBD_TTY
diff --git a/src/gui/embedded/qkbdtty_qws.h b/src/gui/embedded/qkbdtty_qws.h
deleted file mode 100644
index 373342b87b..0000000000
--- a/src/gui/embedded/qkbdtty_qws.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QKBDTTY_QWS_H
-#define QKBDTTY_QWS_H
-
-#include <QtGui/qkbd_qws.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_QWS_KEYBOARD
-
-#ifndef QT_NO_QWS_KBD_TTY
-
-class QWSTtyKbPrivate;
-
-class QWSTtyKeyboardHandler : public QWSKeyboardHandler
-{
-public:
- explicit QWSTtyKeyboardHandler(const QString&);
- virtual ~QWSTtyKeyboardHandler();
-
- virtual bool filterKeycode(char &code);
-
-private:
- QWSTtyKbPrivate *d;
-};
-
-#endif // QT_NO_QWS_KBD_TTY
-
-#endif // QT_NO_QWS_KEYBOARD
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QKBDTTY_QWS_H
diff --git a/src/gui/embedded/qkbdum_qws.cpp b/src/gui/embedded/qkbdum_qws.cpp
deleted file mode 100644
index cfdaa2eed1..0000000000
--- a/src/gui/embedded/qkbdum_qws.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qkbdum_qws.h"
-#include "qvfbhdr.h"
-
-#if !defined(QT_NO_QWS_KEYBOARD) && !defined(QT_NO_QWS_KBD_UM)
-
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#include <qstring.h>
-#include <qwindowsystem_qws.h>
-#include <qsocketnotifier.h>
-#include "qplatformdefs.h"
-
-QT_BEGIN_NAMESPACE
-
-class QWSUmKeyboardHandlerPrivate : public QObject
-{
- Q_OBJECT
-
-public:
- QWSUmKeyboardHandlerPrivate(const QString&);
- ~QWSUmKeyboardHandlerPrivate();
-
-private slots:
- void readKeyboardData();
-
-private:
- int kbdFD;
- int kbdIdx;
- const int kbdBufferLen;
- unsigned char *kbdBuffer;
- QSocketNotifier *notifier;
-};
-
-QWSUmKeyboardHandlerPrivate::QWSUmKeyboardHandlerPrivate(const QString &device)
- : kbdFD(-1), kbdIdx(0), kbdBufferLen(sizeof(QVFbKeyData)*5)
-{
- kbdBuffer = new unsigned char [kbdBufferLen];
-
- if ((kbdFD = QT_OPEN((const char *)device.toLocal8Bit(), O_RDONLY | O_NDELAY, 0)) < 0) {
- qDebug("Cannot open %s (%s)", (const char *)device.toLocal8Bit(),
- strerror(errno));
- } else {
- // Clear pending input
- char buf[2];
- while (QT_READ(kbdFD, buf, 1) > 0) { }
-
- notifier = new QSocketNotifier(kbdFD, QSocketNotifier::Read, this);
- connect(notifier, SIGNAL(activated(int)),this, SLOT(readKeyboardData()));
- }
-}
-
-QWSUmKeyboardHandlerPrivate::~QWSUmKeyboardHandlerPrivate()
-{
- if (kbdFD >= 0)
- QT_CLOSE(kbdFD);
- delete [] kbdBuffer;
-}
-
-
-void QWSUmKeyboardHandlerPrivate::readKeyboardData()
-{
- int n;
- do {
- n = QT_READ(kbdFD, kbdBuffer+kbdIdx, kbdBufferLen - kbdIdx);
- if (n > 0)
- kbdIdx += n;
- } while (n > 0);
-
- int idx = 0;
- while (kbdIdx - idx >= (int)sizeof(QVFbKeyData)) {
- QVFbKeyData *kd = (QVFbKeyData *)(kbdBuffer + idx);
- // Qtopia Key filters must still work.
- QWSServer::processKeyEvent(kd->unicode, kd->keycode, kd->modifiers, kd->press, kd->repeat);
- idx += sizeof(QVFbKeyData);
- }
-
- int surplus = kbdIdx - idx;
- for (int i = 0; i < surplus; i++)
- kbdBuffer[i] = kbdBuffer[idx+i];
- kbdIdx = surplus;
-}
-
-QWSUmKeyboardHandler::QWSUmKeyboardHandler(const QString &device)
- : QWSKeyboardHandler()
-{
- d = new QWSUmKeyboardHandlerPrivate(device);
-}
-
-QWSUmKeyboardHandler::~QWSUmKeyboardHandler()
-{
- delete d;
-}
-
-QT_END_NAMESPACE
-
-#include "qkbdum_qws.moc"
-
-#endif // QT_NO_QWS_KEYBOARD && QT_NO_QWS_KBD_UM
diff --git a/src/gui/embedded/qkbdum_qws.h b/src/gui/embedded/qkbdum_qws.h
deleted file mode 100644
index fd21c4875a..0000000000
--- a/src/gui/embedded/qkbdum_qws.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QKBDUM_QWS_H
-#define QKBDUM_QWS_H
-
-#include <QtGui/qkbd_qws.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_QWS_KEYBOARD
-
-#ifndef QT_NO_QWS_KBD_UM
-
-class QWSUmKeyboardHandlerPrivate;
-
-class QWSUmKeyboardHandler : public QWSKeyboardHandler
-{
-public:
- QWSUmKeyboardHandler(const QString &);
- virtual ~QWSUmKeyboardHandler();
-
-private:
-
- QWSUmKeyboardHandlerPrivate *d;
-};
-#endif // QT_NO_QWS_KBD_UM
-
-#endif // QT_NO_QWS_KEYBOARD
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QKBDUM_QWS_H
diff --git a/src/gui/embedded/qkbdvfb_qws.cpp b/src/gui/embedded/qkbdvfb_qws.cpp
deleted file mode 100644
index a626ef5e13..0000000000
--- a/src/gui/embedded/qkbdvfb_qws.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#include <qvfbhdr.h>
-#include <qkbdvfb_qws.h>
-
-#ifndef QT_NO_QWS_KEYBOARD
-#ifndef QT_NO_QWS_KBD_QVFB
-
-#include <qwindowsystem_qws.h>
-#include <qsocketnotifier.h>
-#include <qapplication.h>
-#include <private/qcore_unix_p.h> // overrides QT_OPEN
-
-QT_BEGIN_NAMESPACE
-
-QVFbKeyboardHandler::QVFbKeyboardHandler(const QString &device)
- : QObject()
-{
- terminalName = device;
- if (terminalName.isEmpty())
- terminalName = QLatin1String("/dev/vkdb");
- kbdFD = -1;
- kbdIdx = 0;
- kbdBufferLen = sizeof(QVFbKeyData) * 5;
- kbdBuffer = new unsigned char [kbdBufferLen];
-
- if ((kbdFD = QT_OPEN(terminalName.toLatin1().constData(), O_RDONLY | O_NDELAY)) < 0) {
- qWarning("Cannot open %s (%s)", terminalName.toLatin1().constData(),
- strerror(errno));
- } else {
- // Clear pending input
- char buf[2];
- while (QT_READ(kbdFD, buf, 1) > 0) { }
-
- notifier = new QSocketNotifier(kbdFD, QSocketNotifier::Read, this);
- connect(notifier, SIGNAL(activated(int)),this, SLOT(readKeyboardData()));
- }
-}
-
-QVFbKeyboardHandler::~QVFbKeyboardHandler()
-{
- if (kbdFD >= 0)
- QT_CLOSE(kbdFD);
- delete [] kbdBuffer;
-}
-
-
-void QVFbKeyboardHandler::readKeyboardData()
-{
- int n;
- do {
- n = QT_READ(kbdFD, kbdBuffer+kbdIdx, kbdBufferLen - kbdIdx);
- if (n > 0)
- kbdIdx += n;
- } while (n > 0);
-
- int idx = 0;
- while (kbdIdx - idx >= (int)sizeof(QVFbKeyData)) {
- QVFbKeyData *kd = (QVFbKeyData *)(kbdBuffer + idx);
- if (kd->unicode == 0 && kd->keycode == 0 && kd->modifiers == 0 && kd->press) {
- // magic exit key
- qWarning("Instructed to quit by Virtual Keyboard");
- qApp->quit();
- }
- QWSServer::processKeyEvent(kd->unicode ? kd->unicode : 0xffff, kd->keycode, kd->modifiers, kd->press, kd->repeat);
- idx += sizeof(QVFbKeyData);
- }
-
- int surplus = kbdIdx - idx;
- for (int i = 0; i < surplus; i++)
- kbdBuffer[i] = kbdBuffer[idx+i];
- kbdIdx = surplus;
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_KBD_QVFB
-#endif // QT_NO_QWS_KEYBOARD
diff --git a/src/gui/embedded/qkbdvfb_qws.h b/src/gui/embedded/qkbdvfb_qws.h
deleted file mode 100644
index c99a6df006..0000000000
--- a/src/gui/embedded/qkbdvfb_qws.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QKBDVFB_QWS_H
-#define QKBDVFB_QWS_H
-
-#include <QtGui/qkbd_qws.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_QWS_KEYBOARD
-
-#ifndef QT_NO_QWS_KBD_QVFB
-
-class QSocketNotifier;
-
-class QVFbKeyboardHandler : public QObject, public QWSKeyboardHandler
-{
- Q_OBJECT
-public:
- QVFbKeyboardHandler(const QString &device);
- virtual ~QVFbKeyboardHandler();
-
-private Q_SLOTS:
- void readKeyboardData();
-
-private:
- QString terminalName;
- int kbdFD;
- int kbdIdx;
- int kbdBufferLen;
- unsigned char *kbdBuffer;
- QSocketNotifier *notifier;
-};
-
-#endif // QT_NO_QWS_KBD_QVFB
-
-#endif // QT_NO_QWS_KEYBOARD
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QKBDVFB_QWS_H
diff --git a/src/gui/embedded/qlock.cpp b/src/gui/embedded/qlock.cpp
deleted file mode 100644
index d429b93f26..0000000000
--- a/src/gui/embedded/qlock.cpp
+++ /dev/null
@@ -1,325 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qlock_p.h"
-
-
-#ifdef QT_NO_QWS_MULTIPROCESS
-
-QT_BEGIN_NAMESPACE
-
-/* no multiprocess - use a dummy */
-
-QLock::QLock(const QString & /*filename*/, char /*id*/, bool /*create*/)
- : type(Read), data(0)
-{
-}
-
-QLock::~QLock()
-{
-}
-
-bool QLock::isValid() const
-{
- return true;
-}
-
-void QLock::lock(Type t)
-{
- data = (QLockData *)-1;
- type = t;
-}
-
-void QLock::unlock()
-{
- data = 0;
-}
-
-bool QLock::locked() const
-{
- return data;
-}
-
-QT_END_NAMESPACE
-
-#else // QT_NO_QWS_MULTIPROCESS
-
-#if defined(Q_OS_DARWIN)
-# define Q_NO_SEMAPHORE
-#endif
-
-#include "qwssignalhandler_p.h"
-
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/ipc.h>
-#if defined(Q_NO_SEMAPHORE)
-# include <sys/stat.h>
-# include <sys/file.h>
-#else
-# include <sys/sem.h>
-#endif
-#include <string.h>
-#include <errno.h>
-#include <qdebug.h>
-
-#include <private/qcore_unix_p.h> // overrides QT_OPEN
-
-QT_BEGIN_NAMESPACE
-
-#define MAX_LOCKS 200 // maximum simultaneous read locks
-
-class QLockData
-{
-public:
-#ifdef Q_NO_SEMAPHORE
- QByteArray file;
-#endif // Q_NO_SEMAPHORE
- int id;
- int count;
- bool owned;
-};
-
-/*!
- \class QLock
- \brief The QLock class is a wrapper for a System V shared semaphore.
-
- \ingroup qws
-
- \internal
-
- It is used by \l{Qt for Embedded Linux} for synchronizing access to the graphics
- card and shared memory region between processes.
-*/
-
-/*!
- \enum QLock::Type
-
- \value Read
- \value Write
-*/
-
-/*!
- \fn QLock::QLock(const QString &filename, char id, bool create)
-
- Creates a lock. \a filename is the file path of the Unix-domain
- socket the \l{Qt for Embedded Linux} client is using. \a id is the name of the
- particular lock to be created on that socket. If \a create is true
- the lock is to be created (as the Qt for Embedded Linux server does); if \a
- create is false the lock should exist already (as the Qt for Embedded Linux
- client expects).
-*/
-
-QLock::QLock(const QString &filename, char id, bool create)
-{
- data = new QLockData;
- data->count = 0;
-#ifdef Q_NO_SEMAPHORE
- data->file = QString(filename+id).toLocal8Bit().constData();
- for(int x = 0; x < 2; x++) {
- data->id = QT_OPEN(data->file, O_RDWR | (x ? O_CREAT : 0), S_IRWXU);
- if(data->id != -1 || !create) {
- data->owned = x;
- break;
- }
- }
-#else
- key_t semkey = ftok(filename.toLocal8Bit().constData(), id);
- data->id = semget(semkey,0,0);
- data->owned = create;
- if (create) {
- qt_semun arg; arg.val = 0;
- if (data->id != -1)
- semctl(data->id,0,IPC_RMID,arg);
- data->id = semget(semkey,1,IPC_CREAT|0600);
- arg.val = MAX_LOCKS;
- semctl(data->id,0,SETVAL,arg);
-
- QWSSignalHandler::instance()->addSemaphore(data->id);
- }
-#endif
- if (data->id == -1) {
- int eno = errno;
- qWarning("Cannot %s semaphore %s '%c'", (create ? "create" : "get"),
- qPrintable(filename), id);
- qDebug() << "Error" << eno << strerror(eno);
- }
-}
-
-/*!
- \fn QLock::~QLock()
-
- Destroys a lock
-*/
-
-QLock::~QLock()
-{
- if (locked())
- unlock();
-#ifdef Q_NO_SEMAPHORE
- if(isValid()) {
- QT_CLOSE(data->id);
- if(data->owned)
- unlink(data->file);
- }
-#else
- if(data->owned)
- QWSSignalHandler::instance()->removeSemaphore(data->id);
-#endif
- delete data;
-}
-
-/*!
- \fn bool QLock::isValid() const
-
- Returns true if the lock constructor was successful; returns false if
- the lock could not be created or was not available to connect to.
-*/
-
-bool QLock::isValid() const
-{
- return (data->id != -1);
-}
-
-/*!
- Locks the semaphore with a lock of type \a t. Locks can either be
- \c Read or \c Write. If a lock is \c Read, attempts by other
- processes to obtain \c Read locks will succeed, and \c Write
- attempts will block until the lock is unlocked. If locked as \c
- Write, all attempts to lock by other processes will block until
- the lock is unlocked. Locks are stacked: i.e. a given QLock can be
- locked multiple times by the same process without blocking, and
- will only be unlocked after a corresponding number of unlock()
- calls.
-*/
-
-void QLock::lock(Type t)
-{
- if (!data->count) {
-#ifdef Q_NO_SEMAPHORE
- int op = LOCK_SH;
- if(t == Write)
- op = LOCK_EX;
- for(int rv=1; rv;) {
- rv = flock(data->id, op);
- if (rv == -1 && errno != EINTR)
- qDebug("Semop lock failure %s",strerror(errno));
- }
-#else
- sembuf sops;
- sops.sem_num = 0;
- sops.sem_flg = SEM_UNDO;
-
- if (t == Write) {
- sops.sem_op = -MAX_LOCKS;
- type = Write;
- } else {
- sops.sem_op = -1;
- type = Read;
- }
-
- int rv;
- do {
- rv = semop(data->id,&sops,1);
- if (rv == -1 && errno != EINTR)
- qDebug("Semop lock failure %s",strerror(errno));
- } while (rv == -1 && errno == EINTR);
-#endif
- }
- data->count++;
-}
-
-/*!
- \fn void QLock::unlock()
-
- Unlocks the semaphore. If other processes were blocking waiting to
- lock() the semaphore, one of them will wake up and succeed in
- lock()ing.
-*/
-
-void QLock::unlock()
-{
- if(data->count) {
- data->count--;
- if(!data->count) {
-#ifdef Q_NO_SEMAPHORE
- for(int rv=1; rv;) {
- rv = flock(data->id, LOCK_UN);
- if (rv == -1 && errno != EINTR)
- qDebug("Semop lock failure %s",strerror(errno));
- }
-#else
- sembuf sops;
- sops.sem_num = 0;
- sops.sem_op = 1;
- sops.sem_flg = SEM_UNDO;
- if (type == Write)
- sops.sem_op = MAX_LOCKS;
-
- int rv;
- do {
- rv = semop(data->id,&sops,1);
- if (rv == -1 && errno != EINTR)
- qDebug("Semop unlock failure %s",strerror(errno));
- } while (rv == -1 && errno == EINTR);
-#endif
- }
- } else {
- qDebug("Unlock without corresponding lock");
- }
-}
-
-/*!
- \fn bool QLock::locked() const
-
- Returns true if the lock is currently held by the current process;
- otherwise returns false.
-*/
-
-bool QLock::locked() const
-{
- return (data->count > 0);
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_MULTIPROCESS
-
diff --git a/src/gui/embedded/qlock_p.h b/src/gui/embedded/qlock_p.h
deleted file mode 100644
index 34560a012e..0000000000
--- a/src/gui/embedded/qlock_p.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QLOCK_P_H
-#define QLOCK_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. This header file may
-// change from version to version without notice, or even be
-// removed.
-//
-// We mean it.
-//
-
-#include "QtCore/qstring.h"
-
-QT_BEGIN_NAMESPACE
-
-class QLockData;
-
-class Q_GUI_EXPORT QLock
-{
-public:
- QLock(const QString &filename, char id, bool create = false);
- ~QLock();
-
- enum Type { Read, Write };
-
- bool isValid() const;
- void lock(Type type);
- void unlock();
- bool locked() const;
-
-private:
- Type type;
- QLockData *data;
-};
-
-
-// Nice class for ensuring the lock is released.
-// Just create one on the stack and the lock is automatically released
-// when QLockHandle is destructed.
-class Q_GUI_EXPORT QLockHandle
-{
-public:
- QLockHandle(QLock *l, QLock::Type type) : qlock(l) { qlock->lock(type); }
- ~QLockHandle() { if (locked()) qlock->unlock(); }
-
- void lock(QLock::Type type) { qlock->lock(type); }
- void unlock() { qlock->unlock(); }
- bool locked() const { return qlock->locked(); }
-
-private:
- QLock *qlock;
-};
-
-QT_END_NAMESPACE
-
-#endif // QLOCK_P_H
diff --git a/src/gui/embedded/qmouse_qws.cpp b/src/gui/embedded/qmouse_qws.cpp
deleted file mode 100644
index c373b916ca..0000000000
--- a/src/gui/embedded/qmouse_qws.cpp
+++ /dev/null
@@ -1,653 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmouse_qws.h"
-#include "qwindowsystem_qws.h"
-#include "qscreen_qws.h"
-#include "qapplication.h"
-#include "qtextstream.h"
-#include "qfile.h"
-#include "qdebug.h"
-#include "qscreen_qws.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QWSPointerCalibrationData
- \ingroup qws
-
- \brief The QWSPointerCalibrationData class is a container for
- mouse calibration data in Qt for Embedded Linux.
-
- Note that this class is only available in \l{Qt for Embedded Linux}.
-
- QWSPointerCalibrationData stores device and screen coordinates in
- the devPoints and screenPoints variables, respectively.
-
- A calibration program should create a QWSPointerCalibrationData
- object, fill the devPoints and screenPoints variables with its
- device and screen coordinates, and pass the object to the mouse
- driver using the QWSMouseHandler::calibrate() function.
-
- \sa QWSCalibratedMouseHandler, {Mouse Calibration Example}
-*/
-
-/*!
- \variable QWSPointerCalibrationData::devPoints
- \brief the raw device coordinates for each value of the Location enum.
-*/
-
-/*!
- \variable QWSPointerCalibrationData::screenPoints
- \brief the logical screen coordinates for each value of the Location enum.
-*/
-
-/*!
- \enum QWSPointerCalibrationData::Location
-
- This enum describes the various logical positions that can be
- specified by the devPoints and screenPoints variables.
-
- \value TopLeft Index of the top left corner of the screen.
- \value BottomLeft Index of the bottom left corner of the screen.
- \value BottomRight Index of the bottom right corner of the screen.
- \value TopRight Index of the top right corner of the screen.
- \value Center Index of the center of the screen.
- \value LastLocation Last index in the pointer arrays.
-*/
-
-class QWSMouseHandlerPrivate
-{
-public:
- QWSMouseHandlerPrivate() : screen(qt_screen) {}
-
- const QScreen *screen;
-};
-
-/*!
- \class QWSMouseHandler
- \ingroup qws
-
- \brief The QWSMouseHandler class is a base class for mouse drivers in
- Qt for Embedded Linux.
-
- Note that this class is only available in \l{Qt for Embedded Linux}.
-
- \l{Qt for Embedded Linux} provides ready-made drivers for several mouse
- protocols, see the \l{Qt for Embedded Linux Pointer Handling}{pointer
- handling} documentation for details. Custom mouse drivers can be
- implemented by subclassing the QWSMouseHandler class and creating
- a mouse driver plugin (derived from QMouseDriverPlugin).
- The default implementation of the QMouseDriverFactory class
- will automatically detect the plugin, and load the driver into the
- server application at run-time using Qt's \l {How to Create Qt
- Plugins}{plugin system}.
-
- The mouse driver receives mouse events from the system device and
- encapsulates each event with an instance of the QWSEvent class
- which it then passes to the server application (the server is
- responsible for propagating the event to the appropriate
- client). To receive mouse events, a QWSMouseHandler object will
- usually create a QSocketNotifier object for the given device. The
- QSocketNotifier class provides support for monitoring activity on
- a file descriptor. When the socket notifier receives data, it will
- call the mouse driver's mouseChanged() function to send the event
- to the \l{Qt for Embedded Linux} server application for relaying to
- clients.
-
- If you are creating a driver for a device that needs calibration
- or noise reduction, such as a touchscreen, use the
- QWSCalibratedMouseHandler subclass instead to take advantage of
- the calibrate() and clearCalibration() functions. The \l
- {qws/mousecalibration}{Mouse Calibration}
- demonstrates how to write a simple program using the mechanisms
- provided by the QWSMouseHandler class to calibrate a mouse driver.
-
- Note that when deriving from the QWSMouseHandler class, the
- resume() and suspend() functions must be reimplemented to control
- the flow of mouse input, i.e., the default implementation does
- nothing. Reimplementations of these functions typically call the
- QSocketNotifier::setEnabled() function to enable or disable the
- socket notifier, respectively.
-
- In addition, QWSMouseHandler provides the setScreen() function
- that allows you to specify a screen for your mouse driver and the
- limitToScreen() function that ensures that a given position is
- within this screen's boundaries (changing the position if
- necessary). Finally, QWSMouseHandler provides the pos() function
- returning the current mouse position.
-
- \sa QMouseDriverPlugin, QMouseDriverFactory, {Qt for Embedded Linux Pointer
- Handling}
-*/
-
-
-/*!
- \fn void QWSMouseHandler::suspend()
-
- Implement this function to suspend reading and handling of mouse
- events, e.g., call the QSocketNotifier::setEnabled() function to
- disable the socket notifier.
-
- \sa resume()
-*/
-
-/*!
- \fn void QWSMouseHandler::resume()
-
- Implement this function to resume reading and handling mouse
- events, e.g., call the QSocketNotifier::setEnabled() function to
- enable the socket notifier.
-
- \sa suspend()
-*/
-
-/*!
- \fn const QPoint &QWSMouseHandler::pos() const
-
- Returns the current mouse position.
-
- \sa mouseChanged(), limitToScreen()
-*/
-
-/*!
- Constructs a mouse driver. The \a driver and \a device arguments
- are passed by the QWS_MOUSE_PROTO environment variable.
-
- Call the QWSServer::setMouseHandler() function to make the newly
- created mouse driver, the primary driver. Note that the primary
- driver is controlled by the system, i.e., the system will delete
- it upon exit.
-*/
-QWSMouseHandler::QWSMouseHandler(const QString &, const QString &)
- : mousePos(QWSServer::mousePosition), d_ptr(new QWSMouseHandlerPrivate)
-{
-}
-
-/*!
- Destroys this mouse driver.
-
- Do not call this function if this driver is the primary mouse
- driver, i.e., if QWSServer::setMouseHandler() function has been
- called passing this driver as argument. The primary mouse
- driver is deleted by the system.
-*/
-QWSMouseHandler::~QWSMouseHandler()
-{
- delete d_ptr;
-}
-
-/*!
- Ensures that the given \a position is within the screen's
- boundaries, changing the \a position if necessary.
-
- \sa pos(), setScreen()
-*/
-
-void QWSMouseHandler::limitToScreen(QPoint &position)
-{
- position.setX(qMin(d_ptr->screen->deviceWidth() - 1, qMax(0, position.x())));
- position.setY(qMin(d_ptr->screen->deviceHeight() - 1, qMax(0, position.y())));
-}
-
-/*!
- \since 4.2
-
- Sets the screen for this mouse driver to be the given \a screen.
-
- \sa limitToScreen()
-*/
-void QWSMouseHandler::setScreen(const QScreen *screen)
-{
- d_ptr->screen = (screen ? screen : qt_screen);
-}
-
-/*!
- Notifies the system of a new mouse event.
-
- This function updates the current mouse position and sends the
- event to the \l{Qt for Embedded Linux} server application for
- delivery to the correct widget. Note that a custom mouse driver must call
- this function whenever it wants to deliver a new mouse event.
-
- The given \a position is the global position of the mouse cursor.
- The \a state parameter is a bitmask of the Qt::MouseButton enum's
- values, indicating which mouse buttons are pressed. The \a wheel
- parameter is the delta value of the mouse wheel as returned by
- QWheelEvent::delta().
-
- \sa pos()
-*/
-void QWSMouseHandler::mouseChanged(const QPoint &position, int state, int wheel)
-{
- mousePos = position + d_ptr->screen->offset();
- QWSServer::sendMouseEvent(mousePos, state, wheel);
-}
-
-/*!
- \fn QWSMouseHandler::clearCalibration()
-
- This virtual function allows subclasses of QWSMouseHandler to
- clear the calibration information. Note that the default
- implementation does nothing.
-
- \sa QWSCalibratedMouseHandler::clearCalibration(), calibrate()
-*/
-
-/*!
- \fn QWSMouseHandler::calibrate(const QWSPointerCalibrationData *data)
-
- This virtual function allows subclasses of QWSMouseHandler to set
- the calibration information passed in the given \a data. Note that
- the default implementation does nothing.
-
- \sa QWSCalibratedMouseHandler::calibrate(), clearCalibration()
-*/
-
-/*! \fn QWSMouseHandler::getCalibration(QWSPointerCalibrationData *data) const
- This virtual function allows subclasses of QWSMouseHandler
- to fill in the device coordinates in \a data with values
- that correspond to screen coordinates that are already in
- \a data. Note that the default implementation does nothing.
- */
-
-/*!
- \class QWSCalibratedMouseHandler
- \ingroup qws
-
- \brief The QWSCalibratedMouseHandler class provides mouse
- calibration and noise reduction in Qt for Embedded Linux.
-
- Note that this class is only available in \l{Qt for Embedded Linux}.
-
- \l{Qt for Embedded Linux} provides ready-made drivers for several mouse
- protocols, see the \l{Qt for Embedded Linux Pointer Handling}{pointer
- handling} documentation for details. In general, custom mouse
- drivers can be implemented by subclassing the QWSMouseHandler
- class. But when the system device does not have a fixed mapping
- between device and screen coordinates and/or produces noisy events
- (e.g., a touchscreen), you should derive from the
- QWSCalibratedMouseHandler class instead to take advantage of its
- calibration functionality. As always, you must also create a mouse
- driver plugin (derived from QMouseDriverPlugin);
- the implementation of the QMouseDriverFactory class will then
- automatically detect the plugin, and load the driver into the
- server application at run-time using Qt's
- \l{How to Create Qt Plugins}{plugin system}.
-
- QWSCalibratedMouseHandler provides an implementation of the
- calibrate() function to update the calibration parameters based on
- coordinate mapping of the given calibration data. The calibration
- data is represented by an QWSPointerCalibrationData object. The
- linear transformation between device coordinates and screen
- coordinates is performed by calling the transform() function
- explicitly on the points passed to the
- QWSMouseHandler::mouseChanged() function. Use the
- clearCalibration() function to make the mouse driver return mouse
- events in raw device coordinates and not in screen coordinates.
-
- The calibration parameters are recalculated whenever calibrate()
- is called, and they can be stored using the writeCalibration()
- function. Previously written parameters can be retrieved at any
- time using the readCalibration() function (calibration parameters
- are always read when the class is instantiated). Note that the
- calibration parameters is written to and read from the file
- currently specified by the POINTERCAL_FILE environment variable;
- the default file is \c /etc/pointercal.
-
- To achieve noise reduction, QWSCalibratedMouseHandler provides the
- sendFiltered() function. Use this function instead of
- mouseChanged() whenever a mouse event occurs. The filter's size
- can be manipulated using the setFilterSize() function.
-
- \sa QWSMouseHandler, QWSPointerCalibrationData,
- {Mouse Calibration Example}
-*/
-
-
-/*!
- \internal
- */
-
-QWSCalibratedMouseHandler::QWSCalibratedMouseHandler(const QString &, const QString &)
- : samples(5), currSample(0), numSamples(0)
-{
- clearCalibration();
- readCalibration();
-}
-
-/*!
- Fills \a cd with the device coordinates corresponding to the given
- screen coordinates.
-
- \internal
-*/
-void QWSCalibratedMouseHandler::getCalibration(QWSPointerCalibrationData *cd) const
-{
- const qint64 scale = qint64(a) * qint64(e) - qint64(b) * qint64(d);
- const qint64 xOff = qint64(b) * qint64(f) - qint64(c) * qint64(e);
- const qint64 yOff = qint64(c) * qint64(d) - qint64(a) * qint64(f);
- for (int i = 0; i <= QWSPointerCalibrationData::LastLocation; ++i) {
- const qint64 sX = cd->screenPoints[i].x();
- const qint64 sY = cd->screenPoints[i].y();
- const qint64 dX = (s*(e*sX - b*sY) + xOff) / scale;
- const qint64 dY = (s*(a*sY - d*sX) + yOff) / scale;
- cd->devPoints[i] = QPoint(dX, dY);
- }
-}
-
-/*!
- Clears the current calibration, i.e., makes the mouse
- driver return mouse events in raw device coordinates instead of
- screen coordinates.
-
- \sa calibrate()
-*/
-void QWSCalibratedMouseHandler::clearCalibration()
-{
- a = 1;
- b = 0;
- c = 0;
- d = 0;
- e = 1;
- f = 0;
- s = 1;
-}
-
-
-/*!
- Saves the current calibration parameters in \c /etc/pointercal
- (separated by whitespace and in alphabetical order).
-
- You can override the default \c /etc/pointercal by specifying
- another file using the POINTERCAL_FILE environment variable.
-
- \sa readCalibration()
-*/
-void QWSCalibratedMouseHandler::writeCalibration()
-{
- QString calFile;
- calFile = QString::fromLocal8Bit(qgetenv("POINTERCAL_FILE"));
- if (calFile.isEmpty())
- calFile = QLatin1String("/etc/pointercal");
-
-#ifndef QT_NO_TEXTSTREAM
- QFile file(calFile);
- if (file.open(QIODevice::WriteOnly)) {
- QTextStream t(&file);
- t << a << ' ' << b << ' ' << c << ' ';
- t << d << ' ' << e << ' ' << f << ' ' << s << endl;
- } else
-#endif
- {
- qCritical("QWSCalibratedMouseHandler::writeCalibration: "
- "Could not save calibration into %s", qPrintable(calFile));
- }
-}
-
-/*!
- Reads previously written calibration parameters which are stored
- in \c /etc/pointercal (separated by whitespace and in alphabetical
- order).
-
- You can override the default \c /etc/pointercal by specifying
- another file using the POINTERCAL_FILE environment variable.
-
-
- \sa writeCalibration()
-*/
-void QWSCalibratedMouseHandler::readCalibration()
-{
- QString calFile = QString::fromLocal8Bit(qgetenv("POINTERCAL_FILE"));
- if (calFile.isEmpty())
- calFile = QLatin1String("/etc/pointercal");
-
-#ifndef QT_NO_TEXTSTREAM
- QFile file(calFile);
- if (file.open(QIODevice::ReadOnly)) {
- QTextStream t(&file);
- t >> a >> b >> c >> d >> e >> f >> s;
- if (s == 0 || t.status() != QTextStream::Ok) {
- qCritical("Corrupt calibration data");
- clearCalibration();
- }
- } else
-#endif
- {
- qDebug() << "Could not read calibration:" <<calFile;
- }
-}
-
-static int ilog2(quint32 n)
-{
- int result = 0;
-
- if (n & 0xffff0000) {
- n >>= 16;
- result += 16;
- }
- if (n & 0xff00) {
- n >>= 8;
- result += 8;}
- if (n & 0xf0) {
- n >>= 4;
- result += 4;
- }
- if (n & 0xc) {
- n >>= 2;
- result += 2;
- }
- if (n & 0x2)
- result += 1;
-
- return result;
-}
-
-/*!
- Updates the calibration parameters based on coordinate mapping of
- the given \a data.
-
- Create an instance of the QWSPointerCalibrationData class, fill in
- the device and screen coordinates and pass that object to the mouse
- driver using this function.
-
- \sa clearCalibration(), transform()
-*/
-void QWSCalibratedMouseHandler::calibrate(const QWSPointerCalibrationData *data)
-{
- // Algorithm derived from
- // "How To Calibrate Touch Screens" by Carlos E. Vidales,
- // printed in Embedded Systems Programming, Vol. 15 no 6, June 2002
- // URL: http://www.embedded.com/showArticle.jhtml?articleID=9900629
-
- const QPoint pd0 = data->devPoints[QWSPointerCalibrationData::TopLeft];
- const QPoint pd1 = data->devPoints[QWSPointerCalibrationData::TopRight];
- const QPoint pd2 = data->devPoints[QWSPointerCalibrationData::BottomRight];
- const QPoint p0 = data->screenPoints[QWSPointerCalibrationData::TopLeft];
- const QPoint p1 = data->screenPoints[QWSPointerCalibrationData::TopRight];
- const QPoint p2 = data->screenPoints[QWSPointerCalibrationData::BottomRight];
-
- const qint64 xd0 = pd0.x();
- const qint64 xd1 = pd1.x();
- const qint64 xd2 = pd2.x();
- const qint64 yd0 = pd0.y();
- const qint64 yd1 = pd1.y();
- const qint64 yd2 = pd2.y();
- const qint64 x0 = p0.x();
- const qint64 x1 = p1.x();
- const qint64 x2 = p2.x();
- const qint64 y0 = p0.y();
- const qint64 y1 = p1.y();
- const qint64 y2 = p2.y();
-
- qint64 scale = ((xd0 - xd2)*(yd1 - yd2) - (xd1 - xd2)*(yd0 - yd2));
- int shift = 0;
- qint64 absScale = qAbs(scale);
- // use maximum 16 bit precision to reduce risk of integer overflow
- if (absScale > (1 << 16)) {
- shift = ilog2(absScale >> 16) + 1;
- scale >>= shift;
- }
-
- s = scale;
- a = ((x0 - x2)*(yd1 - yd2) - (x1 - x2)*(yd0 - yd2)) >> shift;
- b = ((xd0 - xd2)*(x1 - x2) - (x0 - x2)*(xd1 - xd2)) >> shift;
- c = (yd0*(xd2*x1 - xd1*x2) + yd1*(xd0*x2 - xd2*x0) + yd2*(xd1*x0 - xd0*x1)) >> shift;
- d = ((y0 - y2)*(yd1 - yd2) - (y1 - y2)*(yd0 - yd2)) >> shift;
- e = ((xd0 - xd2)*(y1 - y2) - (y0 - y2)*(xd1 - xd2)) >> shift;
- f = (yd0*(xd2*y1 - xd1*y2) + yd1*(xd0*y2 - xd2*y0) + yd2*(xd1*y0 - xd0*y1)) >> shift;
-
- writeCalibration();
-}
-
-/*!
- Transforms the given \a position from device coordinates to screen
- coordinates, and returns the transformed position.
-
- This function is typically called explicitly on the points passed
- to the QWSMouseHandler::mouseChanged() function.
-
- This implementation is a linear transformation using 7 parameters
- (\c a, \c b, \c c, \c d, \c e, \c f and \c s) to transform the
- device coordinates (\c Xd, \c Yd) into screen coordinates (\c Xs,
- \c Ys) using the following equations:
-
- \snippet doc/src/snippets/code/src_gui_embedded_qmouse_qws.cpp 0
-
- \sa mouseChanged()
-*/
-QPoint QWSCalibratedMouseHandler::transform(const QPoint &position)
-{
- QPoint tp;
-
- tp.setX((a * position.x() + b * position.y() + c) / s);
- tp.setY((d * position.x() + e * position.y() + f) / s);
-
- return tp;
-}
-
-/*!
- Sets the size of the filter used in noise reduction to the given
- \a size.
-
- The sendFiltered() function reduces noice by calculating an
- average position from a collection of mouse event positions. The
- filter size determines the number of positions that forms the
- basis for these calculations.
-
- \sa sendFiltered()
-*/
-void QWSCalibratedMouseHandler::setFilterSize(int size)
-{
- samples.resize(qMax(1, size));
- numSamples = 0;
- currSample = 0;
-}
-
-/*!
- \fn bool QWSCalibratedMouseHandler::sendFiltered(const QPoint &position, int state)
-
- Notifies the system of a new mouse event \e after applying a noise
- reduction filter. Returns true if the filtering process is
- successful; otherwise returns false. Note that if the filtering
- process failes, the system is not notified about the event.
-
- The given \a position is the global position of the mouse. The \a
- state parameter is a bitmask of the Qt::MouseButton enum's values
- indicating which mouse buttons are pressed.
-
- The noice is reduced by calculating an average position from a
- collection of mouse event positions and then calling the
- mouseChanged() function with the new position. The number of
- positions that is used is determined by the filter size.
-
- \sa mouseChanged(), setFilterSize()
-*/
-bool QWSCalibratedMouseHandler::sendFiltered(const QPoint &position, int button)
-{
- if (!button) {
- if (numSamples >= samples.count())
- mouseChanged(transform(position), 0);
- currSample = 0;
- numSamples = 0;
- return true;
- }
-
- bool sent = false;
- samples[currSample] = position;
- numSamples++;
- if (numSamples >= samples.count()) {
-
- int ignore = -1;
- if (samples.count() > 2) { // throw away the "worst" sample
- int maxd = 0;
- for (int i = 0; i < samples.count(); i++) {
- int d = (mousePos - samples[i]).manhattanLength();
- if (d > maxd) {
- maxd = d;
- ignore = i;
- }
- }
- }
-
- // average the rest
- QPoint pos(0, 0);
- int numAveraged = 0;
- for (int i = 0; i < samples.count(); i++) {
- if (ignore == i)
- continue;
- pos += samples[i];
- ++numAveraged;
- }
- if (numAveraged)
- pos /= numAveraged;
-
- mouseChanged(transform(pos), button);
- sent = true;
- }
- currSample++;
- if (currSample >= samples.count())
- currSample = 0;
-
- return sent;
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/embedded/qmouse_qws.h b/src/gui/embedded/qmouse_qws.h
deleted file mode 100644
index 8f2cbe5fc2..0000000000
--- a/src/gui/embedded/qmouse_qws.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMOUSE_QWS_H
-#define QMOUSE_QWS_H
-
-#include <QtCore/qobject.h>
-#include <QtGui/qpolygon.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QWSMouseHandlerPrivate;
-class QScreen;
-
-class Q_GUI_EXPORT QWSPointerCalibrationData
-{
-public:
- enum Location { TopLeft = 0, BottomLeft = 1, BottomRight = 2, TopRight = 3,
- Center = 4, LastLocation = Center };
- QPoint devPoints[5];
- QPoint screenPoints[5];
-};
-
-class Q_GUI_EXPORT QWSMouseHandler
-{
-public:
- explicit QWSMouseHandler(const QString &driver = QString(),
- const QString &device = QString());
- virtual ~QWSMouseHandler();
-
- virtual void clearCalibration() {}
- virtual void calibrate(const QWSPointerCalibrationData *) {}
- virtual void getCalibration(QWSPointerCalibrationData *) const {}
-
- virtual void resume() = 0;
- virtual void suspend() = 0;
-
- void limitToScreen(QPoint &pt);
- void mouseChanged(const QPoint& pos, int bstate, int wheel = 0);
- const QPoint &pos() const { return mousePos; }
-
- void setScreen(const QScreen *screen);
-
-protected:
- QPoint &mousePos;
- QWSMouseHandlerPrivate *d_ptr;
-};
-
-
-class Q_GUI_EXPORT QWSCalibratedMouseHandler : public QWSMouseHandler
-{
-public:
- explicit QWSCalibratedMouseHandler(const QString &driver = QString(),
- const QString &device = QString());
-
- virtual void clearCalibration();
- virtual void calibrate(const QWSPointerCalibrationData *);
- virtual void getCalibration(QWSPointerCalibrationData *) const;
-
-protected:
- bool sendFiltered(const QPoint &, int button);
- QPoint transform(const QPoint &);
-
- void readCalibration();
- void writeCalibration();
- void setFilterSize(int);
-
-private:
- int a, b, c;
- int d, e, f;
- int s;
- QPolygon samples;
- int currSample;
- int numSamples;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMOUSE_QWS_H
diff --git a/src/gui/embedded/qmousedriverfactory_qws.cpp b/src/gui/embedded/qmousedriverfactory_qws.cpp
deleted file mode 100644
index f67284d6d5..0000000000
--- a/src/gui/embedded/qmousedriverfactory_qws.cpp
+++ /dev/null
@@ -1,197 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmousedriverfactory_qws.h"
-
-#include "qapplication.h"
-#include "qmousepc_qws.h"
-#include "qmouselinuxtp_qws.h"
-#include "qmouselinuxinput_qws.h"
-#include "qmousevfb_qws.h"
-#include "qmousetslib_qws.h"
-#include "qmouseqnx_qws.h"
-#include "qmouseintegrity_qws.h"
-#include <stdlib.h>
-#include "private/qfactoryloader_p.h"
-#include "qmousedriverplugin_qws.h"
-#include "qdebug.h"
-
-QT_BEGIN_NAMESPACE
-
-#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
-#ifndef QT_NO_LIBRARY
-
-Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
- (QWSMouseHandlerFactoryInterface_iid,
- QLatin1String("/mousedrivers"), Qt::CaseInsensitive))
-
-#endif //QT_NO_LIBRARY
-#endif //QT_MAKEDLL
-
-/*!
- \class QMouseDriverFactory
- \ingroup qws
-
- \brief The QMouseDriverFactory class creates mouse drivers in
- Qt for Embedded Linux.
-
- Note that this class is only available in \l{Qt for Embedded Linux}.
-
- QMouseDriverFactory is used to detect and instantiate the
- available mouse drivers, allowing \l{Qt for Embedded Linux} to load the
- preferred driver into the server application at runtime. The
- create() function returns a QWSMouseHandler object representing
- the mouse driver identified by a given key. The valid keys
- (i.e. the supported drivers) can be retrieved using the keys()
- function.
-
- \l{Qt for Embedded Linux} provides several built-in mouse drivers. In
- addition, custom mouse drivers can be added using Qt's plugin
- mechanism, i.e. by subclassing the QWSMouseHandler class and
- creating a mouse driver plugin (QMouseDriverPlugin). See the
- \l{Qt for Embedded Linux Pointer Handling}{pointer handling}
- documentation for details.
-
- \sa QWSMouseHandler, QMouseDriverPlugin
-*/
-
-/*!
- Creates the mouse driver specified by the given \a key, using the
- display specified by the given \a device.
-
- Note that the keys are case-insensitive.
-
- \sa keys()
-*/
-QWSMouseHandler *QMouseDriverFactory::create(const QString& key, const QString &device)
-{
- QString driver = key.toLower();
-#if defined(Q_OS_QNX) && !defined(QT_NO_QWS_MOUSE_QNX)
- if (driver == QLatin1String("qnx") || driver.isEmpty())
- return new QQnxMouseHandler(key, device);
-#endif
-#if defined(Q_OS_INTEGRITY) && !defined(QT_NO_MOUSE_INTEGRITY)
- if (driver == QLatin1String("integrity") || driver.isEmpty())
- return new QIntMouseHandler(key, device);
-#endif
-#ifndef QT_NO_QWS_MOUSE_LINUXTP
- if (driver == QLatin1String("linuxtp") || driver.isEmpty())
- return new QWSLinuxTPMouseHandler(key, device);
-#endif
-#ifndef QT_NO_QWS_MOUSE_PC
- if (driver == QLatin1String("auto")
- || driver == QLatin1String("intellimouse")
- || driver == QLatin1String("microsoft")
- || driver == QLatin1String("mousesystems")
- || driver == QLatin1String("mouseman")
- || driver.isEmpty()) {
- return new QWSPcMouseHandler(key, device);
- }
-#endif
-#ifndef QT_NO_QWS_MOUSE_TSLIB
- if (driver == QLatin1String("tslib") || driver.isEmpty())
- return new QWSTslibMouseHandler(key, device);
-#endif
-# ifndef QT_NO_QWS_MOUSE_LINUXINPUT
- if (driver == QLatin1String("linuxinput") || \
- driver == QLatin1String("usb") || \
- driver == QLatin1String("linuxis"))
- return new QWSLinuxInputMouseHandler(device);
-# endif
-#ifndef QT_NO_QWS_MOUSE_QVFB
- if (driver == QLatin1String("qvfbmouse") || driver == QLatin1String("qvfb"))
- return new QVFbMouseHandler(key, device);
-#endif
-
-#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
-#ifndef QT_NO_LIBRARY
- if (QWSMouseHandlerFactoryInterface *factory = qobject_cast<QWSMouseHandlerFactoryInterface*>(loader()->instance(driver)))
- return factory->create(driver, device);
-#endif
-#endif
- return 0;
-}
-
-/*!
- Returns the list of valid keys, i.e. the available mouse drivers.
-
- \sa create()
-*/
-QStringList QMouseDriverFactory::keys()
-{
- QStringList list;
-
-#if defined(Q_OS_QNX) && !defined(QT_NO_QWS_MOUSE_QNX)
- list << QLatin1String("QNX");
-#endif
-#if defined(Q_OS_INTEGRITY) && !defined(QT_NO_QWS_MOUSE_INTEGRITY)
- list << QLatin1String("INTEGRITY");
-#endif
-#ifndef QT_NO_QWS_MOUSE_LINUXTP
- list << QLatin1String("LinuxTP");
-#endif
-#ifndef QT_NO_QWS_MOUSE_PC
- list << QLatin1String("Auto")
- << QLatin1String("IntelliMouse")
- << QLatin1String("Microsoft")
- << QLatin1String("MouseSystems")
- << QLatin1String("MouseMan");
-#endif
-#ifndef QT_NO_QWS_MOUSE_TSLIB
- list << QLatin1String("Tslib");
-#endif
-#ifndef QT_NO_QWS_MOUSE_LINUXINPUT
- list << QLatin1String("LinuxInput");
-#endif
-
-#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
-#ifndef QT_NO_LIBRARY
- QStringList plugins = loader()->keys();
- for (int i = 0; i < plugins.size(); ++i) {
- if (!list.contains(plugins.at(i)))
- list += plugins.at(i);
- }
-#endif //QT_NO_LIBRARY
-#endif //QT_MAKEDLL
- return list;
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/embedded/qmousedriverfactory_qws.h b/src/gui/embedded/qmousedriverfactory_qws.h
deleted file mode 100644
index 0eac39a758..0000000000
--- a/src/gui/embedded/qmousedriverfactory_qws.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMOUSEDRIVERFACTORY_QWS_H
-#define QMOUSEDRIVERFACTORY_QWS_H
-
-#include <QtCore/qstringlist.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QString;
-class QWSMouseHandler;
-
-class Q_GUI_EXPORT QMouseDriverFactory
-{
-public:
- static QStringList keys();
- static QWSMouseHandler *create(const QString&, const QString &);
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMOUSEDRIVERFACTORY_QWS_H
diff --git a/src/gui/embedded/qmousedriverplugin_qws.cpp b/src/gui/embedded/qmousedriverplugin_qws.cpp
deleted file mode 100644
index 4fae54b6b7..0000000000
--- a/src/gui/embedded/qmousedriverplugin_qws.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmousedriverplugin_qws.h"
-
-#ifndef QT_NO_LIBRARY
-
-#include "qmouse_qws.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QMouseDriverPlugin
- \ingroup plugins
- \ingroup qws
-
- \brief The QMouseDriverPlugin class is an abstract base class for
- mouse driver plugins in Qt for Embedded Linux.
-
- Note that this class is only available in \l{Qt for Embedded Linux}.
-
- \l{Qt for Embedded Linux} provides ready-made drivers for several mouse
- protocols, see the \l{Qt for Embedded Linux Pointer Handling}{pointer
- handling} documentation for details. Custom mouse drivers can be
- implemented by subclassing the QWSMouseHandler class and creating
- a mouse driver plugin.
-
- A mouse driver plugin can be created by subclassing
- QMouseDriverPlugin and reimplementing the pure virtual keys() and
- create() functions. By exporting the derived class using the
- Q_EXPORT_PLUGIN2() macro, The default implementation of the
- QMouseDriverFactory class will automatically detect the plugin and
- load the driver into the server application at run-time. See \l
- {How to Create Qt Plugins} for details.
-
- \sa QWSMouseHandler, QMouseDriverFactory
-*/
-
-/*!
- \fn QStringList QMouseDriverPlugin::keys() const
-
- Implement this function to return the list of valid keys, i.e. the
- mouse drivers supported by this plugin.
-
- \l{Qt for Embedded Linux} provides ready-made drivers for several mouse
- protocols, see the \l {Qt for Embedded Linux Pointer Handling}{pointer
- handling} documentation for details.
-
- \sa create()
-*/
-
-/*!
- Constructs a mouse driver plugin with the given \a parent.
-
- Note that this constructor is invoked automatically by the
- Q_EXPORT_PLUGIN2() macro, so there is no need for calling it
- explicitly.
-*/
-QMouseDriverPlugin::QMouseDriverPlugin(QObject *parent)
- : QObject(parent)
-{
-}
-
-/*!
- Destroys the mouse driver plugin.
-
- Note that Qt destroys a plugin automatically when it is no longer
- used, so there is no need for calling the destructor explicitly.
-*/
-QMouseDriverPlugin::~QMouseDriverPlugin()
-{
-}
-
-/*!
- \fn QScreen* QMouseDriverPlugin::create(const QString &key, const QString& device)
-
- Implement this function to create a driver matching the type
- specified by the given \a key and \a device parameters. Note that
- keys are case-insensitive.
-
- \sa keys()
-*/
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_LIBRARY
diff --git a/src/gui/embedded/qmousedriverplugin_qws.h b/src/gui/embedded/qmousedriverplugin_qws.h
deleted file mode 100644
index 275bbd1514..0000000000
--- a/src/gui/embedded/qmousedriverplugin_qws.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMOUSEDRIVERPLUGIN_QWS_H
-#define QMOUSEDRIVERPLUGIN_QWS_H
-
-#include <QtCore/qplugin.h>
-#include <QtCore/qfactoryinterface.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_LIBRARY
-
-class QWSMouseHandler;
-
-struct Q_GUI_EXPORT QWSMouseHandlerFactoryInterface : public QFactoryInterface
-{
- virtual QWSMouseHandler* create(const QString &name, const QString &device) = 0;
-};
-
-#define QWSMouseHandlerFactoryInterface_iid "com.trolltech.Qt.QWSMouseHandlerFactoryInterface"
-Q_DECLARE_INTERFACE(QWSMouseHandlerFactoryInterface, QWSMouseHandlerFactoryInterface_iid)
-
-class Q_GUI_EXPORT QMouseDriverPlugin : public QObject, public QWSMouseHandlerFactoryInterface
-{
- Q_OBJECT
- Q_INTERFACES(QWSMouseHandlerFactoryInterface:QFactoryInterface)
-public:
- explicit QMouseDriverPlugin(QObject *parent = 0);
- ~QMouseDriverPlugin();
-
- virtual QStringList keys() const = 0;
- virtual QWSMouseHandler* create(const QString& driver, const QString &device) = 0;
-};
-
-#endif // QT_NO_LIBRARY
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMOUSEDRIVERPLUGIN_QWS_H
diff --git a/src/gui/embedded/qmouseintegrity_qws.cpp b/src/gui/embedded/qmouseintegrity_qws.cpp
deleted file mode 100644
index 78a8c1b509..0000000000
--- a/src/gui/embedded/qmouseintegrity_qws.cpp
+++ /dev/null
@@ -1,271 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QT_NO_QWS_MOUSE_INTEGRITY
-
-#include "qmouseintegrity_qws.h"
-#include <qwindowsystem_qws.h>
-#include <qapplication.h>
-#include <qtimer.h>
-#include <qthread.h>
-
-#include <INTEGRITY.h>
-
-
-typedef Address MOUSEHandler;
-typedef struct MOUSEMessageStruct
-{
- Value x;
- Value y;
- Value z;
- Value buttons;
-} MOUSEMessage;
-
-static Error MOUSE_Init(MOUSEHandler *handler, Boolean *isabsolute);
-static Error MOUSE_SynchronousGetPosition(MOUSEHandler handler, MOUSEMessage *msg,
- Boolean absolute);
-static Error MOUSE_ShouldFilter(MOUSEHandler handler, Boolean *filter);
-
-QT_BEGIN_NAMESPACE
-
-class QIntMouseListenThread;
-
-class QIntMousePrivate : public QObject
-{
- Q_OBJECT
- friend class QIntMouseListenTaskThread;
-Q_SIGNALS:
- void mouseDataAvailable(int x, int y, int buttons);
-public:
- QIntMousePrivate(QIntMouseHandler *handler);
- ~QIntMousePrivate();
- void dataReady(int x, int y, int buttons) { emit mouseDataAvailable(x, y, buttons); }
- bool calibrated;
- bool waitforread;
- bool suspended;
- QIntMouseListenThread *mousethread;
-
-private:
- QIntMouseHandler *handler;
-};
-
-class QIntMouseListenThread : public QThread
-{
-protected:
- QIntMousePrivate *imp;
- bool loop;
-public:
- QIntMouseListenThread(QIntMousePrivate *im) : QThread(), imp(im) {};
- ~QIntMouseListenThread() {};
- void run();
- void stoploop() { loop = false; };
-};
-
-
-QIntMouseHandler::QIntMouseHandler(const QString &driver, const QString &device)
- : QObject(), QWSCalibratedMouseHandler(driver, device)
-{
- QPoint test(1,1);
- d = new QIntMousePrivate(this);
- connect(d, SIGNAL(mouseDataAvailable(int, int, int)), this, SLOT(readMouseData(int, int, int)));
-
- d->calibrated = (test != transform(test));
-
- d->mousethread->start();
-}
-
-QIntMouseHandler::~QIntMouseHandler()
-{
- disconnect(d, SIGNAL(mouseDataAvailable(int, int, int)), this, SLOT(readMouseData(int, int, int)));
- delete d;
-}
-
-void QIntMouseHandler::resume()
-{
- d->suspended = true;
-}
-
-void QIntMouseHandler::suspend()
-{
- d->suspended = false;
-}
-
-void QIntMouseHandler::readMouseData(int x, int y, int buttons)
-{
- d->waitforread = false;
- if (d->suspended)
- return;
- if (d->calibrated) {
- sendFiltered(QPoint(x, y), buttons);
- } else {
- QPoint pos;
- pos = transform(QPoint(x, y));
- limitToScreen(pos);
- mouseChanged(pos, buttons, 0);
- }
-}
-
-void QIntMouseHandler::clearCalibration()
-{
- QWSCalibratedMouseHandler::clearCalibration();
-}
-
-void QIntMouseHandler::calibrate(const QWSPointerCalibrationData *data)
-{
- QWSCalibratedMouseHandler::calibrate(data);
-}
-
-void QIntMouseListenThread::run(void)
-{
- MOUSEHandler handler;
- MOUSEMessage msg;
- Boolean filter;
- Boolean isabsolute;
- loop = true;
- CheckSuccess(MOUSE_Init(&handler, &isabsolute));
- CheckSuccess(MOUSE_ShouldFilter(handler, &filter));
- if (!filter)
- imp->calibrated = false;
- imp->waitforread = false;
- do {
- MOUSE_SynchronousGetPosition(handler, &msg, isabsolute);
- imp->dataReady(msg.x, msg.y, msg.buttons);
- } while (loop);
- QThread::exit(0);
-}
-
-QIntMousePrivate::QIntMousePrivate(QIntMouseHandler *handler)
- : QObject()
-{
- this->handler = handler;
- suspended = false;
- mousethread = new QIntMouseListenThread(this);
-}
-
-QIntMousePrivate::~QIntMousePrivate()
-{
- mousethread->stoploop();
- mousethread->wait();
- delete mousethread;
-}
-
-QT_END_NAMESPACE
-
-#include "qmouseintegrity_qws.moc"
-
-typedef struct USBMouseStruct
-{
- Connection mouseconn;
- Buffer mousemsg[2];
- Value x;
- Value y;
-} USBMouse;
-
-USBMouse mousedev;
-
-Error MOUSE_Init(MOUSEHandler *handler, Boolean *isabsolute)
-{
- Error E;
- bool loop = true;
- memset((void*)&mousedev, 0, sizeof(USBMouse));
- mousedev.mousemsg[0].BufferType = DataImmediate;
- mousedev.mousemsg[1].BufferType = DataImmediate | LastBuffer;
- do {
- E = RequestResource((Object*)&mousedev.mouseconn,
- "MouseClient", "!systempassword");
- if (E == Success) {
- *isabsolute = true;
- loop = false;
- } else {
- E = RequestResource((Object*)&mousedev.mouseconn,
- "USBMouseClient", "!systempassword");
- if (E == Success) {
- *isabsolute = false;
- loop = false;
- }
- }
- if (loop)
- sleep(1);
- } while (loop);
- *handler = (MOUSEHandler)&mousedev;
- return Success;
-}
-
-Error MOUSE_SynchronousGetPosition(MOUSEHandler handler, MOUSEMessage *msg,
- Boolean isabsolute)
-{
- signed long x;
- signed long y;
- USBMouse *mdev = (USBMouse *)handler;
- mdev->mousemsg[0].Transferred = 0;
- mdev->mousemsg[1].Transferred = 0;
- SynchronousReceive(mdev->mouseconn, mdev->mousemsg);
- if (isabsolute) {
- x = (signed long)mdev->mousemsg[0].Length;
- y = (signed long)mdev->mousemsg[1].TheAddress;
- } else {
- x = mdev->x + (signed long)mdev->mousemsg[0].Length;
- y = mdev->y + (signed long)mdev->mousemsg[1].TheAddress;
- }
- if (x < 0)
- mdev->x = 0;
- else
- mdev->x = x;
- if (y < 0)
- mdev->y = 0;
- else
- mdev->y = y;
- msg->x = mdev->x;
- msg->y = mdev->y;
- msg->buttons = mdev->mousemsg[0].TheAddress;
- return Success;
-}
-
-Error MOUSE_ShouldFilter(MOUSEHandler handler, Boolean *filter)
-{
- if (filter == NULL)
- return Failure;
- *filter = false;
- return Success;
-}
-
-#endif // QT_NO_QWS_MOUSE_INTEGRITY
-
diff --git a/src/gui/embedded/qmouseintegrity_qws.h b/src/gui/embedded/qmouseintegrity_qws.h
deleted file mode 100644
index 46d27a3d2e..0000000000
--- a/src/gui/embedded/qmouseintegrity_qws.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMOUSEINTEGRITY_QWS_H
-#define QMOUSEINTEGRITY_QWS_H
-
-#include <QtGui/qmouse_qws.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_QWS_MOUSE_INTEGRITY
-
-class QSocketNotifier;
-class QIntMousePrivate;
-
-class QIntMouseHandler : public QObject, public QWSCalibratedMouseHandler {
- Q_OBJECT
-public:
- QIntMouseHandler(const QString &driver = QString(),
- const QString &device = QString());
- ~QIntMouseHandler();
-
- void resume();
- void suspend();
-
- void calibrate(const QWSPointerCalibrationData *data);
- void clearCalibration();
-
-private:
- QIntMousePrivate *d;
-private Q_SLOTS:
- void readMouseData(int x, int y, int buttons);
-};
-#endif // QT_NO_QWS_MOUSE_INTEGRITY
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMOUSEINTEGRITY_QWS_H
diff --git a/src/gui/embedded/qmouselinuxinput_qws.cpp b/src/gui/embedded/qmouselinuxinput_qws.cpp
deleted file mode 100644
index 534e9f16f7..0000000000
--- a/src/gui/embedded/qmouselinuxinput_qws.cpp
+++ /dev/null
@@ -1,205 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmouselinuxinput_qws.h"
-
-#include <QScreen>
-#include <QSocketNotifier>
-
-#include <qplatformdefs.h>
-#include <private/qcore_unix_p.h> // overrides QT_OPEN
-
-#include <errno.h>
-
-#include <linux/input.h>
-
-QT_BEGIN_NAMESPACE
-
-
-class QWSLinuxInputMousePrivate : public QObject
-{
- Q_OBJECT
-public:
- QWSLinuxInputMousePrivate(QWSLinuxInputMouseHandler *, const QString &);
- ~QWSLinuxInputMousePrivate();
-
- void enable(bool on);
-
-private Q_SLOTS:
- void readMouseData();
-
-private:
- QWSLinuxInputMouseHandler *m_handler;
- QSocketNotifier * m_notify;
- int m_fd;
- int m_x, m_y;
- int m_buttons;
-};
-
-QWSLinuxInputMouseHandler::QWSLinuxInputMouseHandler(const QString &device)
- : QWSCalibratedMouseHandler(device)
-{
- d = new QWSLinuxInputMousePrivate(this, device);
-}
-
-QWSLinuxInputMouseHandler::~QWSLinuxInputMouseHandler()
-{
- delete d;
-}
-
-void QWSLinuxInputMouseHandler::suspend()
-{
- d->enable(false);
-}
-
-void QWSLinuxInputMouseHandler::resume()
-{
- d->enable(true);
-}
-
-QWSLinuxInputMousePrivate::QWSLinuxInputMousePrivate(QWSLinuxInputMouseHandler *h, const QString &device)
- : m_handler(h), m_notify(0), m_x(0), m_y(0), m_buttons(0)
-{
- setObjectName(QLatin1String("LinuxInputSubsystem Mouse Handler"));
-
- QString dev = QLatin1String("/dev/input/event0");
- if (device.startsWith(QLatin1String("/dev/")))
- dev = device;
-
- m_fd = QT_OPEN(dev.toLocal8Bit().constData(), O_RDONLY | O_NDELAY, 0);
- if (m_fd >= 0) {
- m_notify = new QSocketNotifier(m_fd, QSocketNotifier::Read, this);
- connect(m_notify, SIGNAL(activated(int)), this, SLOT(readMouseData()));
- } else {
- qWarning("Cannot open mouse input device '%s': %s", qPrintable(dev), strerror(errno));
- return;
- }
-}
-
-QWSLinuxInputMousePrivate::~QWSLinuxInputMousePrivate()
-{
- if (m_fd >= 0)
- QT_CLOSE(m_fd);
-}
-
-void QWSLinuxInputMousePrivate::enable(bool on)
-{
- if (m_notify)
- m_notify->setEnabled(on);
-}
-
-void QWSLinuxInputMousePrivate::readMouseData()
-{
- if (!qt_screen)
- return;
-
- struct ::input_event buffer[32];
- int n = 0;
-
- forever {
- n = QT_READ(m_fd, reinterpret_cast<char *>(buffer) + n, sizeof(buffer) - n);
-
- if (n == 0) {
- qWarning("Got EOF from the input device.");
- return;
- } else if (n < 0 && (errno != EINTR && errno != EAGAIN)) {
- qWarning("Could not read from input device: %s", strerror(errno));
- return;
- } else if (n % sizeof(buffer[0]) == 0) {
- break;
- }
- }
-
- n /= sizeof(buffer[0]);
-
- for (int i = 0; i < n; ++i) {
- struct ::input_event *data = &buffer[i];
-
- bool unknown = false;
- if (data->type == EV_ABS) {
- if (data->code == ABS_X) {
- m_x = data->value;
- } else if (data->code == ABS_Y) {
- m_y = data->value;
- } else {
- unknown = true;
- }
- } else if (data->type == EV_REL) {
- if (data->code == REL_X) {
- m_x += data->value;
- } else if (data->code == REL_Y) {
- m_y += data->value;
- } else {
- unknown = true;
- }
- } else if (data->type == EV_KEY && data->code == BTN_TOUCH) {
- m_buttons = data->value ? Qt::LeftButton : 0;
- } else if (data->type == EV_KEY) {
- int button = 0;
- switch (data->code) {
- case BTN_LEFT: button = Qt::LeftButton; break;
- case BTN_MIDDLE: button = Qt::MidButton; break;
- case BTN_RIGHT: button = Qt::RightButton; break;
- }
- if (data->value)
- m_buttons |= button;
- else
- m_buttons &= ~button;
- } else if (data->type == EV_SYN && data->code == SYN_REPORT) {
- QPoint pos(m_x, m_y);
- pos = m_handler->transform(pos);
- m_handler->limitToScreen(pos);
- m_handler->mouseChanged(pos, m_buttons);
- } else if (data->type == EV_MSC && data->code == MSC_SCAN) {
- // kernel encountered an unmapped key - just ignore it
- continue;
- } else {
- unknown = true;
- }
- if (unknown) {
- qWarning("unknown mouse event type=%x, code=%x, value=%x", data->type, data->code, data->value);
- }
- }
-}
-
-QT_END_NAMESPACE
-
-#include "qmouselinuxinput_qws.moc"
diff --git a/src/gui/embedded/qmouselinuxinput_qws.h b/src/gui/embedded/qmouselinuxinput_qws.h
deleted file mode 100644
index 2a9ddb3826..0000000000
--- a/src/gui/embedded/qmouselinuxinput_qws.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMOUSELINUXINPUT_QWS_H
-#define QMOUSELINUXINPUT_QWS_H
-
-#include <QtGui/QWSCalibratedMouseHandler>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_QWS_MOUSE_LINUXINPUT
-
-class QWSLinuxInputMousePrivate;
-
-class QWSLinuxInputMouseHandler : public QWSCalibratedMouseHandler
-{
-public:
- QWSLinuxInputMouseHandler(const QString &);
- ~QWSLinuxInputMouseHandler();
-
- void suspend();
- void resume();
-
-private:
- QWSLinuxInputMousePrivate *d;
-
- friend class QWSLinuxInputMousePrivate;
-};
-
-#endif // QT_NO_QWS_MOUSE_LINUXINPUT
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMOUSELINUXINPUT_QWS_H
diff --git a/src/gui/embedded/qmouselinuxtp_qws.cpp b/src/gui/embedded/qmouselinuxtp_qws.cpp
deleted file mode 100644
index 21fff97418..0000000000
--- a/src/gui/embedded/qmouselinuxtp_qws.cpp
+++ /dev/null
@@ -1,335 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmouselinuxtp_qws.h"
-
-#ifndef QT_NO_QWS_MOUSE_LINUXTP
-#include "qwindowsystem_qws.h"
-#include "qsocketnotifier.h"
-#include "qtimer.h"
-#include "qapplication.h"
-#include "qscreen_qws.h"
-#include <private/qcore_unix_p.h> // overrides QT_OPEN
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <termios.h>
-
-QT_BEGIN_NAMESPACE
-
-#if defined(QT_QWS_IPAQ)
- #define QT_QWS_IPAQ_RAW
- #define QT_QWS_SCREEN_COORDINATES
- typedef struct {
- unsigned short pressure;
- unsigned short x;
- unsigned short y;
- unsigned short pad;
- } TS_EVENT;
-#elif defined(QT_QWS_EBX)
- #define QT_QWS_EBX_RAW
- #define QT_QWS_SCREEN_COORDINATES
-#ifndef QT_QWS_SHARP
- typedef struct {
- unsigned short pressure;
- unsigned short x;
- unsigned short y;
- unsigned short pad;
- } TS_EVENT;
- #else
- typedef struct {
- long y;
- long x;
- long pressure;
- long long millisecs;
- } TS_EVENT;
- #define QT_QWS_TP_SAMPLE_SIZE 10
- #define QT_QWS_TP_MINIMUM_SAMPLES 4
- #define QT_QWS_TP_PRESSURE_THRESHOLD 500
- #define QT_QWS_TP_MOVE_LIMIT 50
- #define QT_QWS_TP_JITTER_LIMIT 2
- #endif
-#else // not IPAQ, not SHARP
- typedef struct {
- unsigned short pressure;
- unsigned short x;
- unsigned short y;
- unsigned short pad;
- } TS_EVENT;
-#endif
-
-#ifndef QT_QWS_TP_SAMPLE_SIZE
-#define QT_QWS_TP_SAMPLE_SIZE 5
-#endif
-
-#ifndef QT_QWS_TP_MINIMUM_SAMPLES
-#define QT_QWS_TP_MINIMUM_SAMPLES 5
-#endif
-
-#ifndef QT_QWS_TP_PRESSURE_THRESHOLD
-#define QT_QWS_TP_PRESSURE_THRESHOLD 1
-#endif
-
-#ifndef QT_QWS_TP_MOVE_LIMIT
-#define QT_QWS_TP_MOVE_LIMIT 100
-#endif
-
-#ifndef QT_QWS_TP_JITTER_LIMIT
-#define QT_QWS_TP_JITTER_LIMIT 2
-#endif
-
-class QWSLinuxTPMouseHandlerPrivate : public QObject
-{
- Q_OBJECT
-public:
- QWSLinuxTPMouseHandlerPrivate(QWSLinuxTPMouseHandler *h, const QString &);
- ~QWSLinuxTPMouseHandlerPrivate();
-
- void suspend();
- void resume();
-private:
- static const int mouseBufSize = 2048;
- int mouseFD;
- QPoint oldmouse;
- QPoint oldTotalMousePos;
- bool waspressed;
- QPolygon samples;
- int currSample;
- int lastSample;
- int numSamples;
- int skipCount;
- int mouseIdx;
- uchar mouseBuf[mouseBufSize];
- QWSLinuxTPMouseHandler *handler;
- QSocketNotifier *mouseNotifier;
-
-private slots:
- void readMouseData();
-};
-
-QWSLinuxTPMouseHandler::QWSLinuxTPMouseHandler(const QString &driver, const QString &device)
- : QWSCalibratedMouseHandler(driver, device)
-{
- d = new QWSLinuxTPMouseHandlerPrivate(this, device);
-}
-
-QWSLinuxTPMouseHandler::~QWSLinuxTPMouseHandler()
-{
- delete d;
-}
-
-void QWSLinuxTPMouseHandler::suspend()
-{
- d->suspend();
-}
-
-void QWSLinuxTPMouseHandler::resume()
-{
- d->resume();
-}
-
-QWSLinuxTPMouseHandlerPrivate::QWSLinuxTPMouseHandlerPrivate(QWSLinuxTPMouseHandler *h,
- const QString &device)
- : samples(QT_QWS_TP_SAMPLE_SIZE), currSample(0), lastSample(0),
- numSamples(0), skipCount(0), handler(h)
-{
- QString mousedev;
- if (device.isEmpty()) {
-#if defined(QT_QWS_IPAQ)
-# ifdef QT_QWS_IPAQ_RAW
- mousedev = QLatin1String("/dev/h3600_tsraw");
-# else
- mousedev = QLatin1String("/dev/h3600_ts");
-# endif
-#else
- mousedev = QLatin1String("/dev/ts");
-#endif
- } else {
- mousedev = device;
- }
- if ((mouseFD = QT_OPEN(mousedev.toLatin1().constData(), O_RDONLY | O_NDELAY)) < 0) {
- qWarning("Cannot open %s (%s)", qPrintable(mousedev), strerror(errno));
- return;
- }
-
- mouseNotifier = new QSocketNotifier(mouseFD, QSocketNotifier::Read,
- this);
- connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData()));
- waspressed=false;
- mouseIdx = 0;
-}
-
-QWSLinuxTPMouseHandlerPrivate::~QWSLinuxTPMouseHandlerPrivate()
-{
- if (mouseFD >= 0)
- QT_CLOSE(mouseFD);
-}
-
-void QWSLinuxTPMouseHandlerPrivate::suspend()
-{
- if (mouseNotifier)
- mouseNotifier->setEnabled(false);
-}
-
-void QWSLinuxTPMouseHandlerPrivate::resume()
-{
- mouseIdx=0;
- currSample=0;
- lastSample=0;
- numSamples=0;
- skipCount=0;
- if (mouseNotifier)
- mouseNotifier->setEnabled(true);
-}
-
-
-void QWSLinuxTPMouseHandlerPrivate::readMouseData()
-{
- if(!qt_screen)
- return;
-
- int n;
- do {
- n = QT_READ(mouseFD, mouseBuf+mouseIdx, mouseBufSize-mouseIdx);
- if (n > 0)
- mouseIdx += n;
- } while (n > 0 && mouseIdx < mouseBufSize);
-
- //qDebug("readMouseData()");
-
- TS_EVENT *data;
- int idx = 0;
-
- // perhaps we shouldn't be reading EVERY SAMPLE.
- while (mouseIdx-idx >= (int)sizeof(TS_EVENT)) {
- uchar *mb = mouseBuf+idx;
- data = (TS_EVENT *) mb;
-
- if(data->pressure >= QT_QWS_TP_PRESSURE_THRESHOLD) {
-#ifdef QT_QWS_SHARP
- samples[currSample] = QPoint(1000 - data->x, data->y);
-#else
- samples[currSample] = QPoint(data->x, data->y);
-#endif
- numSamples++;
- if (numSamples >= QT_QWS_TP_MINIMUM_SAMPLES) {
- int sampleCount = qMin(numSamples + 1,samples.count());
-
- // average the rest
- QPoint mousePos = QPoint(0, 0);
- QPoint totalMousePos = oldTotalMousePos;
- totalMousePos += samples[currSample];
- if(numSamples >= samples.count())
- totalMousePos -= samples[lastSample];
-
- mousePos = totalMousePos / (sampleCount - 1);
-#if defined(QT_QWS_SCREEN_COORDINATES)
- mousePos = handler->transform(mousePos);
-#endif
- if(!waspressed)
- oldmouse = mousePos;
- QPoint dp = mousePos - oldmouse;
- int dxSqr = dp.x() * dp.x();
- int dySqr = dp.y() * dp.y();
- if (dxSqr + dySqr < (QT_QWS_TP_MOVE_LIMIT * QT_QWS_TP_MOVE_LIMIT)) {
- if (waspressed) {
- if ((dxSqr + dySqr > (QT_QWS_TP_JITTER_LIMIT * QT_QWS_TP_JITTER_LIMIT)) || skipCount > 2) {
- handler->mouseChanged(mousePos,Qt::LeftButton);
- oldmouse = mousePos;
- skipCount = 0;
- } else {
- skipCount++;
- }
- } else {
- handler->mouseChanged(mousePos,Qt::LeftButton);
- oldmouse=mousePos;
- waspressed=true;
- }
-
- // save recuring information
- currSample++;
- if (numSamples >= samples.count())
- lastSample++;
- oldTotalMousePos = totalMousePos;
- } else {
- numSamples--; // don't use this sample, it was bad.
- }
- } else {
- // build up the average
- oldTotalMousePos += samples[currSample];
- currSample++;
- }
- if (currSample >= samples.count())
- currSample = 0;
- if (lastSample >= samples.count())
- lastSample = 0;
- } else {
- currSample = 0;
- lastSample = 0;
- numSamples = 0;
- skipCount = 0;
- oldTotalMousePos = QPoint(0,0);
- if (waspressed) {
- handler->mouseChanged(oldmouse,0);
- oldmouse = QPoint(-100, -100);
- waspressed=false;
- }
- }
- idx += sizeof(TS_EVENT);
- }
-
- int surplus = mouseIdx - idx;
- for (int i = 0; i < surplus; i++)
- mouseBuf[i] = mouseBuf[idx+i];
- mouseIdx = surplus;
-}
-
-QT_END_NAMESPACE
-
-#include "qmouselinuxtp_qws.moc"
-
-#endif //QT_NO_QWS_MOUSE_LINUXTP
diff --git a/src/gui/embedded/qmouselinuxtp_qws.h b/src/gui/embedded/qmouselinuxtp_qws.h
deleted file mode 100644
index 1974ad0e89..0000000000
--- a/src/gui/embedded/qmouselinuxtp_qws.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMOUSELINUXTP_QWS_H
-#define QMOUSELINUXTP_QWS_H
-
-#include <QtGui/qmouse_qws.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_QWS_MOUSE_LINUXTP
-
-class QWSLinuxTPMouseHandlerPrivate;
-
-class QWSLinuxTPMouseHandler : public QWSCalibratedMouseHandler
-{
- friend class QWSLinuxTPMouseHandlerPrivate;
-public:
- explicit QWSLinuxTPMouseHandler(const QString & = QString(),
- const QString & = QString());
- ~QWSLinuxTPMouseHandler();
-
- void suspend();
- void resume();
-protected:
- QWSLinuxTPMouseHandlerPrivate *d;
-};
-
-#endif // QT_NO_QWS_MOUSE_LINUXTP
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMOUSELINUXTP_QWS_H
diff --git a/src/gui/embedded/qmousepc_qws.cpp b/src/gui/embedded/qmousepc_qws.cpp
deleted file mode 100644
index e3f85cbc77..0000000000
--- a/src/gui/embedded/qmousepc_qws.cpp
+++ /dev/null
@@ -1,794 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmousepc_qws.h"
-
-#ifndef QT_NO_QWS_MOUSE_PC
-
-#include "qwindowsystem_qws.h"
-#include "qsocketnotifier.h"
-#include "qwsevent_qws.h"
-#include "qwscommand_qws_p.h"
-#include "qwsutils_qws.h"
-
-#include "qapplication.h"
-#include "qpolygon.h"
-#include "qtimer.h"
-#include "qfile.h"
-#include "qtextstream.h"
-#include "qstringlist.h"
-#include <private/qcore_unix_p.h> // overrides QT_OPEN
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <termios.h>
-
-#include <qscreen_qws.h>
-
-QT_BEGIN_NAMESPACE
-
-//#define QWS_MOUSE_DEBUG
-
-/*
- * Automatic-detection mouse driver
- */
-
-class QWSPcMouseSubHandler {
-protected:
- enum { max_buf=32 };
-
- int fd;
-
- uchar buffer[max_buf];
- int nbuf;
-
- QPoint motion;
- int bstate;
- int wheel;
-
- int goodness;
- int badness;
-
- virtual int tryData()=0;
-
-public:
- QWSPcMouseSubHandler(int f) : fd(f)
- {
- initState();
- }
- virtual ~QWSPcMouseSubHandler() {}
-
- int file() const { return fd; }
-
- void closeIfNot(int& f)
- {
- if (fd != f) {
- f = fd;
- QT_CLOSE(fd);
- }
- }
-
- void initState() { nbuf = bstate = goodness = badness = 0; }
-
- void worse(int by=1) { badness+=by; }
- bool reliable() const { return goodness >= 5 && badness < 50; }
- int buttonState() const { return bstate; }
- bool motionPending() const { return motion!=QPoint(0,0); }
- QPoint takeMotion() { QPoint r=motion; motion=QPoint(0,0); return r; }
- int takeWheel() { int result = wheel; wheel = 0; return result; }
-
- void appendData(uchar* data, int length)
- {
- memcpy(buffer+nbuf, data, length);
- nbuf += length;
- }
-
- enum UsageResult { Insufficient, Motion, Button };
-
- UsageResult useData()
- {
- int pbstate = bstate;
- int n = tryData();
-#ifdef QWS_MOUSE_DEBUG
- if (n) {
- fprintf(stderr, "QWSPcMouseSubHandler tryData read %d bytes:", n);
- for (int i=0; i<n; ++i)
- fprintf(stderr, " %02x", buffer[i]);
- fprintf(stderr, "\n");
- }
-#endif
- if (n > 0) {
- if (n<nbuf)
- memmove(buffer, buffer+n, nbuf-n);
- nbuf -= n;
- return (wheel || pbstate != bstate) ? Button : Motion;
- }
- return Insufficient;
- }
-};
-
-class QWSPcMouseSubHandler_intellimouse : public QWSPcMouseSubHandler {
- int packetsize;
-public:
- QWSPcMouseSubHandler_intellimouse(int f) : QWSPcMouseSubHandler(f)
- {
- init();
- }
-
- void init()
- {
- int n;
- uchar reply[20];
-
- if (tcflush(fd,TCIOFLUSH) == -1) {
-#ifdef QWS_MOUSE_DEBUG
- perror("QWSPcMouseSubHandler_intellimouse: pre-init tcflush");
-#endif
- }
- static const uchar initseq[] = { 243, 200, 243, 100, 243, 80 };
- static const uchar query[] = { 0xf2 };
- if (QT_WRITE(fd, initseq, sizeof(initseq))!=sizeof(initseq)) {
- badness = 100;
- return;
- }
- usleep(10000);
- if (tcflush(fd,TCIOFLUSH) == -1) {
-#ifdef QWS_MOUSE_DEBUG
- perror("QWSPcMouseSubHandler_intellimouse: post-init tcflush");
-#endif
- }
- if (QT_WRITE(fd, query, sizeof(query))!=sizeof(query)) {
- badness = 100;
- return;
- }
- usleep(10000);
- n = QT_READ(fd, reply, 20);
- if (n > 0) {
- goodness = 10;
- switch (reply[n-1]) {
- case 3:
- case 4:
- packetsize = 4;
- break;
- default:
- packetsize = 3;
- }
- } else {
- badness = 100;
- }
- }
-
- int tryData()
- {
- if (nbuf >= packetsize) {
- //int overflow = (buffer[0]>>6)& 0x03;
-
- if (/*overflow ||*/ !(buffer[0] & 8)) {
-#ifdef QWS_MOUSE_DEBUG
- qDebug("Intellimouse: skipping (overflow)");
-#endif
- badness++;
- return 1;
- } else {
- QPoint delta((buffer[0] & 0x10) ? buffer[1]-256 : buffer[1],
- (buffer[0] & 0x20) ? 256-buffer[2] : -buffer[2]);
- motion += delta;
- int nbstate = buffer[0] & 0x7;
-#ifdef QWS_MOUSE_DEBUG
- int debugwheel =
-#endif
- wheel = packetsize > 3 ? -(signed char)buffer[3] : 0;
- if (wheel < -2 || wheel > 2)
- wheel = 0;
- wheel *= 120; // WHEEL_DELTA?
-#ifdef QWS_MOUSE_DEBUG
- qDebug("Intellimouse: motion %d,%d, state %d, raw wheel %d, wheel %d", motion.x(), motion.y(), nbstate, debugwheel, wheel);
-#endif
- if (motion.x() || motion.y() || bstate != nbstate || wheel) {
- bstate = nbstate;
- goodness++;
- } else {
- badness++;
- return 1;
- }
- }
- return packetsize;
- }
- return 0;
- }
-};
-
-class QWSPcMouseSubHandler_mouseman : public QWSPcMouseSubHandler {
- int packetsize;
-public:
- QWSPcMouseSubHandler_mouseman(int f) : QWSPcMouseSubHandler(f)
- {
- init();
- }
-
- void init()
- {
- if (tcflush(fd,TCIOFLUSH) == -1) {
-#ifdef QWS_MOUSE_DEBUG
- perror("QWSPcMouseSubHandler_mouseman: initial tcflush");
-#endif
- }
- QT_WRITE(fd,"",1);
- usleep(50000);
- QT_WRITE(fd,"@EeI!",5);
- usleep(10000);
- static const char ibuf[] = { 246, 244 };
- QT_WRITE(fd,ibuf,1);
- QT_WRITE(fd,ibuf+1,1);
- if (tcflush(fd,TCIOFLUSH) == -1) {
-#ifdef QWS_MOUSE_DEBUG
- perror("QWSPcMouseSubHandler_mouseman: tcflush");
-#endif
- }
- usleep(10000);
-
- char buf[100];
- while (QT_READ(fd, buf, 100) > 0) { } // eat unwanted replies
- }
-
- int tryData()
- {
- if (nbuf >= 3) {
- int nbstate = 0;
- if (buffer[0] & 0x01)
- nbstate |= Qt::LeftButton;
- if (buffer[0] & 0x02)
- nbstate |= Qt::RightButton;
- if (buffer[0] & 0x04)
- nbstate |= Qt::MidButton;
-
- int overflow = (buffer[0]>>6)& 0x03;
- if (overflow) {
- //### wheel events signalled with overflow bit, ignore for now
- badness++;
- return 1;
- } else {
- bool xs = buffer[0] & 0x10;
- bool ys = buffer[0] & 0x20;
- int dx = xs ? buffer[1]-256 : buffer[1];
- int dy = ys ? buffer[2]-256 : buffer[2];
-
- motion += QPoint(dx, -dy);
- if (motion.x() || motion.y() || bstate != nbstate) {
- bstate = nbstate;
- goodness++;
- } else {
- badness++;
- return 1;
- }
- }
- return 3;
- }
- return 0;
- }
-};
-
-class QWSPcMouseSubHandler_serial : public QWSPcMouseSubHandler {
-public:
- QWSPcMouseSubHandler_serial(int f) : QWSPcMouseSubHandler(f)
- {
- initSerial();
- }
-
-protected:
- void setflags(int f)
- {
- termios tty;
- if (tcgetattr(fd, &tty) == -1) {
-#ifdef QWS_MOUSE_DEBUG
- perror("QWSPcMouseSubHandler_serial: tcgetattr");
-#endif
- }
- tty.c_iflag = IGNBRK | IGNPAR;
- tty.c_oflag = 0;
- tty.c_lflag = 0;
- tty.c_cflag = f | CREAD | CLOCAL | HUPCL;
-#ifdef Q_OS_LINUX
- tty.c_line = 0;
-#endif
- tty.c_cc[VTIME] = 0;
- tty.c_cc[VMIN] = 1;
- if (tcsetattr(fd, TCSANOW, &tty) == -1) {
-#ifdef QWS_MOUSE_DEBUG
- perror("QWSPcMouseSubHandler_serial: tcgetattr");
-#endif
- }
- }
-
-private:
- void initSerial()
- {
- int speed[4] = { B9600, B4800, B2400, B1200 };
-
- for (int n = 0; n < 4; n++) {
- setflags(CSTOPB | speed[n]);
- QT_WRITE(fd, "*q", 2);
- usleep(10000);
- }
- }
-};
-
-class QWSPcMouseSubHandler_mousesystems : public QWSPcMouseSubHandler_serial {
-public:
- // ##### This driver has not been tested
-
- QWSPcMouseSubHandler_mousesystems(int f) : QWSPcMouseSubHandler_serial(f)
- {
- init();
- }
-
- void init()
- {
- setflags(B1200|CS8|CSTOPB);
- // 60Hz
- if (QT_WRITE(fd, "R", 1)!=1) {
- badness = 100;
- return;
- }
- if (tcflush(fd,TCIOFLUSH) == -1) {
-#ifdef QT_QWS_VNC_DEBUG
- perror("QWSPcMouseSubHandler_mousesystems: tcflush");
-#endif
- }
- }
-
- int tryData()
- {
- if (nbuf >= 5) {
- if ((buffer[0] & 0xf8) != 0x80) {
- badness++;
- return 1;
- }
- motion +=
- QPoint((signed char)buffer[1] + (signed char)buffer[3],
- -(signed char)buffer[2] + (signed char)buffer[4]);
- int t = ~buffer[0];
- int nbstate = ((t&3) << 1) | ((t&4) >> 2);
- if (motion.x() || motion.y() || bstate != nbstate) {
- bstate = nbstate;
- goodness++;
- } else {
- badness++;
- return 1;
- }
- return 5;
- }
- return 0;
- }
-};
-
-class QWSPcMouseSubHandler_ms : public QWSPcMouseSubHandler_serial {
- int mman;
-public:
- QWSPcMouseSubHandler_ms(int f) : QWSPcMouseSubHandler_serial(f)
- {
- mman=0;
- init();
- }
-
- void init()
- {
- setflags(B1200|CS7);
- // 60Hz
- if (QT_WRITE(fd, "R", 1)!=1) {
- badness = 100;
- return;
- }
- if (tcflush(fd,TCIOFLUSH) == -1) {
-#ifdef QWS_MOUSE_DEBUG
- perror("QWSPcMouseSubHandler_ms: tcflush");
-#endif
- }
- }
-
- int tryData()
- {
- if (!(buffer[0] & 0x40)) {
- if (buffer[0] == 0x20 && (bstate & Qt::MidButton)) {
- mman=1; // mouseman extension
- }
- return 1;
- }
- int extra = mman&&(bstate & Qt::MidButton);
- if (nbuf >= 3+extra) {
- int nbstate = 0;
- if (buffer[0] == 0x40 && !bstate && !buffer[1] && !buffer[2]) {
- nbstate = Qt::MidButton;
- } else {
- nbstate = ((buffer[0] & 0x20) >> 5)
- | ((buffer[0] & 0x10) >> 3);
- if (extra && buffer[3] == 0x20)
- nbstate = Qt::MidButton;
- }
-
- if (buffer[1] & 0x40) {
- badness++;
- return 1;
- } else {
- motion +=
- QPoint((signed char)((buffer[0]&0x3)<<6)
- |(signed char)(buffer[1]&0x3f),
- (signed char)((buffer[0]&0xc)<<4)
- |(signed char)(buffer[2]&0x3f));
- if (motion.x() || motion.y() || bstate != nbstate) {
- bstate = nbstate;
- goodness++;
- } else {
- badness++;
- return 1;
- }
- return 3+extra;
- }
- }
- return 0;
- }
-};
-
-//===========================================================================
-
-class QWSPcMouseHandlerPrivate : public QObject
-{
- Q_OBJECT
-public:
- QWSPcMouseHandlerPrivate(QWSPcMouseHandler *h, const QString &, const QString &);
- ~QWSPcMouseHandlerPrivate();
-
- void suspend();
- void resume();
-
-private:
- enum { max_dev=32 };
- QWSPcMouseSubHandler *sub[max_dev];
- QList<QSocketNotifier*> notifiers;
- int nsub;
- int retries;
-
-private slots:
- void readMouseData(int);
-
-private:
- void openDevices();
- void closeDevices();
- void notify(int fd);
- bool sendEvent(QWSPcMouseSubHandler& h);
-
-private:
- QWSPcMouseHandler *handler;
- QString driver;
- QString device;
- qreal accel;
- int accel_limit;
-};
-
-QWSPcMouseHandler::QWSPcMouseHandler(const QString &driver, const QString &device)
- : QWSMouseHandler(driver, device)
-{
- d = new QWSPcMouseHandlerPrivate(this, driver, device);
-}
-
-QWSPcMouseHandler::~QWSPcMouseHandler()
-{
- delete d;
-}
-
-void QWSPcMouseHandler::suspend()
-{
- d->suspend();
-}
-
-void QWSPcMouseHandler::resume()
-{
- d->resume();
-}
-
-
-QWSPcMouseHandlerPrivate::QWSPcMouseHandlerPrivate(QWSPcMouseHandler *h,
- const QString &drv, const QString &arg)
- : handler(h), driver(drv)
-{
- QStringList args = arg.split(QLatin1Char(':'), QString::SkipEmptyParts);
-
- int index;
-
- accel = qreal(2.0);
- QRegExp accelRegex(QLatin1String("^accel=(\\d+\\.?\\d*)$"));
- index = args.indexOf(accelRegex);
- if (index >= 0) {
- accel = qreal(accelRegex.cap(1).toDouble());
- args.removeAt(index);
- }
-
- accel_limit = 5;
- QRegExp accelLimitRegex(QLatin1String("^accel_limit=(\\d+)$"));
- index = args.indexOf(accelLimitRegex);
- if (index >= 0) {
- accel_limit = accelLimitRegex.cap(1).toInt();
- args.removeAt(index);
- }
-
- device = args.join(QString());
-
- retries = 0;
- openDevices();
-}
-
-QWSPcMouseHandlerPrivate::~QWSPcMouseHandlerPrivate()
-{
- closeDevices();
-}
-
-/*
-QWSPcMouseHandler::UsageResult QWSPcMouseHandler::useDev(Dev& d)
-{
- if (d.nbuf >= mouseData[d.protocol].bytesPerPacket) {
- uchar *mb = d.buf;
- int bstate = 0;
- int dx = 0;
- int dy = 0;
-
- switch (mouseProtocol) {
- case MouseMan:
- case IntelliMouse:
- {
- bstate = mb[0] & 0x7; // assuming Qt::*Button order
-
- int overflow = (mb[0]>>6)& 0x03;
- if (mouseProtocol == MouseMan && overflow) {
- //### wheel events signalled with overflow bit, ignore for now
- }
- else {
- bool xs = mb[0] & 0x10;
- bool ys = mb[0] & 0x20;
- dx = xs ? mb[1]-256 : mb[1];
- dy = ys ? mb[2]-256 : mb[2];
- }
- break;
- }
- case Microsoft:
- if (((mb[0] & 0x20) >> 3)) {
- bstate |= Qt::LeftButton;
- }
- if (((mb[0] & 0x10) >> 4)) {
- bstate |= Qt::RightButton;
- }
-
- dx=(signed char)(((mb[0] & 0x03) << 6) | (mb[1] & 0x3f));
- dy=-(signed char)(((mb[0] & 0x0c) << 4) | (mb[2] & 0x3f));
-
- break;
- }
- }
- }
-*/
-
-
-bool QWSPcMouseHandlerPrivate::sendEvent(QWSPcMouseSubHandler& h)
-{
- if (h.reliable()) {
- QPoint motion = h.takeMotion();
- if (qAbs(motion.x()) > accel_limit || qAbs(motion.y()) > accel_limit)
- motion *= accel;
- QPoint newPos = handler->pos() + motion;
- if (qt_screen->isTransformed()) {
- QSize s = QSize(qt_screen->width(), qt_screen->height());
- newPos = qt_screen->mapToDevice(newPos, s);
- }
- handler->limitToScreen(newPos);
-
- handler->mouseChanged(newPos, h.buttonState(), h.takeWheel());
- return true;
- } else {
- h.takeMotion();
- if (h.buttonState() & (Qt::RightButton|Qt::MidButton)) {
- // Strange for the user to press right or middle without
- // a moving mouse!
- h.worse();
- }
- return false;
- }
-}
-
-void QWSPcMouseHandlerPrivate::openDevices()
-{
- nsub=0;
- int fd = -1;
-
- QString drv = driver.toLower();
- if (!drv.isEmpty() && drv != QLatin1String("auto")) {
- // Manually specified mouse
- QByteArray dev = device.toLatin1();
- if (drv == QLatin1String("intellimouse")) {
- if (dev.isEmpty())
- dev = "/dev/psaux";
- fd = QT_OPEN(dev, O_RDWR | O_NDELAY);
- if (fd >= 0)
- sub[nsub++] = new QWSPcMouseSubHandler_intellimouse(fd);
- } else if (drv == QLatin1String("microsoft")) {
- if (dev.isEmpty())
- dev = "/dev/ttyS0";
- fd = QT_OPEN(dev, O_RDWR | O_NDELAY);
- if (fd >= 0)
- sub[nsub++] = new QWSPcMouseSubHandler_ms(fd);
- } else if (drv == QLatin1String("mousesystems")) {
- if (dev.isEmpty())
- dev = "/dev/ttyS0";
- fd = QT_OPEN(dev, O_RDWR | O_NDELAY);
- if (fd >= 0)
- sub[nsub++] = new QWSPcMouseSubHandler_mousesystems(fd);
- } else if (drv == QLatin1String("mouseman")) {
- if (dev.isEmpty())
- dev = "/dev/psaux";
- fd = QT_OPEN(dev, O_RDWR | O_NDELAY);
- if (fd >= 0)
- sub[nsub++] = new QWSPcMouseSubHandler_mouseman(fd);
- }
- if (fd >= 0)
- notify(fd);
- else
- qCritical("Error opening mouse device '%s': %s",
- dev.constData(), strerror(errno));
- } else {
- // Try automatically
- fd = QT_OPEN("/dev/psaux", O_RDWR | O_NDELAY);
- if (fd >= 0) {
- sub[nsub++] = new QWSPcMouseSubHandler_intellimouse(fd);
- notify(fd);
- }
- fd = QT_OPEN("/dev/input/mice", O_RDWR | O_NDELAY);
- if (fd >= 0) {
- sub[nsub++] = new QWSPcMouseSubHandler_intellimouse(fd);
- notify(fd);
- //qDebug("/dev/input/mice fd %d #%d", fd, nsub-1);
- }
-
-// include the code below to auto-detect serial mice, and to mess up
-// any sort of serial communication
-#if 0
- const char fn[4][11] = { "/dev/ttyS0", "/dev/ttyS1", "/dev/ttyS2", "/dev/ttyS3" };
- for (int ch = 0; ch < 4; ++ch) {
- fd = QT_OPEN(fn[ch], O_RDWR | O_NDELAY);
- if (fd >= 0) {
- //sub[nsub++] = new QWSPcMouseSubHandler_intellimouse(fd);
- sub[nsub++] = new QWSPcMouseSubHandler_mousesystems(fd);
- sub[nsub++] = new QWSPcMouseSubHandler_ms(fd);
- notify(fd);
- }
- }
-#endif
- }
-}
-
-void QWSPcMouseHandlerPrivate::closeDevices()
-{
- int pfd=-1;
- for (int i=0; i<nsub; i++) {
- sub[i]->closeIfNot(pfd);
- delete sub[i];
- }
- qDeleteAll(notifiers);
- notifiers.clear();
-}
-
-void QWSPcMouseHandlerPrivate::suspend()
-{
- for (int i=0; i<notifiers.size(); ++i)
- notifiers.at(i)->setEnabled(false);
-}
-
-void QWSPcMouseHandlerPrivate::resume()
-{
- for (int i=0; i<nsub; i++)
- sub[i]->initState();
-
- for (int i=0; i<notifiers.size(); ++i)
- notifiers.at(i)->setEnabled(true);
-}
-
-
-
-void QWSPcMouseHandlerPrivate::notify(int fd)
-{
- QSocketNotifier *mouseNotifier
- = new QSocketNotifier(fd, QSocketNotifier::Read, this);
- connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData(int)));
- notifiers.append(mouseNotifier);
-}
-
-void QWSPcMouseHandlerPrivate::readMouseData(int fd)
-{
- for (;;) {
- uchar buf[8];
- int n = read(fd, buf, 8);
- if (n<=0)
- break;
- for (int i=0; i<nsub; i++) {
- QWSPcMouseSubHandler& h = *sub[i];
- if (h.file() == fd) {
- h.appendData(buf,n);
- for (;;) {
- switch (h.useData()) {
- case QWSPcMouseSubHandler::Button:
- sendEvent(h);
- break;
- case QWSPcMouseSubHandler::Insufficient:
- goto breakbreak;
- case QWSPcMouseSubHandler::Motion:
- break;
- }
- }
- breakbreak:
- ;
- }
- }
- }
- bool any_reliable=false;
- for (int i=0; i<nsub; i++) {
- QWSPcMouseSubHandler& h = *sub[i];
- if (h.motionPending())
- sendEvent(h);
- any_reliable = any_reliable || h.reliable();
- }
- if (any_reliable) {
- // ... get rid of all unreliable ones? All bad ones?
- } else if (retries < 2) {
- // Try again - maybe the mouse was being moved when we tried to init.
- closeDevices();
- openDevices();
- retries++;
- }
-}
-
-QT_END_NAMESPACE
-
-#include "qmousepc_qws.moc"
-
-#endif // QT_NO_MOUSE_PC
diff --git a/src/gui/embedded/qmousepc_qws.h b/src/gui/embedded/qmousepc_qws.h
deleted file mode 100644
index 339418cdb8..0000000000
--- a/src/gui/embedded/qmousepc_qws.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMOUSEPC_QWS_H
-#define QMOUSEPC_QWS_H
-
-#include <QtGui/qmouse_qws.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_QWS_MOUSE_PC
-
-class QWSPcMouseHandlerPrivate;
-
-class QWSPcMouseHandler : public QWSMouseHandler
-{
-public:
- explicit QWSPcMouseHandler(const QString & = QString(),
- const QString & = QString());
- ~QWSPcMouseHandler();
-
- void suspend();
- void resume();
-protected:
- QWSPcMouseHandlerPrivate *d;
-};
-
-#endif // QT_NO_QWS_MOUSE_PC
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMOUSEPC_QWS_H
diff --git a/src/gui/embedded/qmouseqnx_qws.cpp b/src/gui/embedded/qmouseqnx_qws.cpp
deleted file mode 100644
index cea3673d70..0000000000
--- a/src/gui/embedded/qmouseqnx_qws.cpp
+++ /dev/null
@@ -1,190 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qplatformdefs.h"
-#include "qmouseqnx_qws.h"
-
-#include "qsocketnotifier.h"
-#include "qdebug.h"
-
-#include <sys/dcmd_input.h>
-
-#include <errno.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QQnxMouseHandler
- \preliminary
- \ingroup qws
- \internal
- \since 4.6
-
- \brief The QQnxMouseHandler class implements a mouse driver
- for the QNX \c{devi-hid} input manager.
-
- To be able to compile this mouse handler, \l{Qt for Embedded Linux}
- must be configured with the \c -qt-mouse-qnx option, see the
- \l{Qt for Embedded Linux Pointer Handling}{Pointer Handling} documentation for details.
-
- In order to use this mouse handler, the \c{devi-hid} input manager
- must be set up and run with the resource manager interface (option \c{-r}).
- Also, Photon must not be running.
-
- Example invocation from command line: \c{/usr/photon/bin/devi-hid -Pr kbd mouse}
- Note that after running \c{devi-hid}, you will not be able to use the local
- shell anymore. It is suggested to run the command in a shell scrip, that launches
- a Qt application after invocation of \c{devi-hid}.
-
- To make \l{Qt for Embedded Linux} explicitly choose the qnx mouse
- handler, set the QWS_MOUSE_PROTO environment variable to \c{qnx}. By default,
- the first mouse device (\c{/dev/devi/mouse0}) is used. To override, pass a device
- name as the first and only parameter, for example
- \c{QWS_MOUSE_PROTO=qnx:/dev/devi/mouse1; export QWS_MOUSE_PROTO}.
-
- \sa {Qt for Embedded Linux Pointer Handling}{Pointer Handling}, {Qt for Embedded Linux}
-*/
-
-/*!
- Constructs a mouse handler for the specified \a device, defaulting to \c{/dev/devi/mouse0}.
- The \a driver parameter must be \c{"qnx"}.
-
- Note that you should never instanciate this class, instead let QMouseDriverFactory
- handle the mouse handlers.
-
- \sa QMouseDriverFactory
- */
-QQnxMouseHandler::QQnxMouseHandler(const QString & /*driver*/, const QString &device)
-{
- // open the mouse device with O_NONBLOCK so reading won't block when there's no data
- mouseFD = QT_OPEN(device.isEmpty() ? "/dev/devi/mouse0" : device.toLatin1().constData(),
- QT_OPEN_RDONLY | O_NONBLOCK);
- if (mouseFD == -1) {
- qErrnoWarning(errno, "QQnxMouseHandler: Unable to open mouse device");
- return;
- }
-
- // register a socket notifier on the file descriptor so we'll wake up whenever
- // there's a mouse move waiting for us.
- mouseNotifier = new QSocketNotifier(mouseFD, QSocketNotifier::Read, this);
- connect(mouseNotifier, SIGNAL(activated(int)), SLOT(socketActivated()));
-
- qDebug() << "QQnxMouseHandler: connected.";
-}
-
-/*!
- Destroys this mouse handler and closes the connection to the mouse device.
- */
-QQnxMouseHandler::~QQnxMouseHandler()
-{
- QT_CLOSE(mouseFD);
-}
-
-/*! \reimp */
-void QQnxMouseHandler::resume()
-{
- if (mouseNotifier)
- mouseNotifier->setEnabled(true);
-}
-
-/*! \reimp */
-void QQnxMouseHandler::suspend()
-{
- if (mouseNotifier)
- mouseNotifier->setEnabled(false);
-}
-
-/*! \internal
-
- This function is called whenever there is activity on the mouse device.
- By default, it reads up to 10 mouse move packets and calls mouseChanged()
- for each of them.
-*/
-void QQnxMouseHandler::socketActivated()
-{
- // _mouse_packet is a QNX structure. devi-hid is nice enough to translate
- // the raw byte data from mouse devices into generic format for us.
- _mouse_packet packet;
-
- int iteration = 0;
-
- // read mouse events in batches of 10. Since we're getting quite a lot
- // of mouse events, it's better to do them in batches than to return to the
- // event loop every time.
- do {
- int bytesRead = QT_READ(mouseFD, &packet, sizeof(packet));
- if (bytesRead == -1) {
- // EAGAIN means that there are no more mouse events to read
- if (errno != EAGAIN)
- qErrnoWarning(errno, "QQnxMouseHandler: Unable to read from socket");
- return;
- }
-
- // bytes read should always be equal to the size of a packet.
- Q_ASSERT(bytesRead == sizeof(packet));
-
- // translate the coordinates from the QNX data structure to Qt coordinates
- // note the swapped y axis
- QPoint pos = mousePos;
- pos += QPoint(packet.dx, -packet.dy);
-
- // QNX only tells us relative mouse movements, not absolute ones, so limit the
- // cursor position manually to the screen
- limitToScreen(pos);
-
- // translate the QNX mouse button bitmask to Qt buttons
- int buttons = Qt::NoButton;
-
- if (packet.hdr.buttons & _POINTER_BUTTON_LEFT)
- buttons |= Qt::LeftButton;
- if (packet.hdr.buttons & _POINTER_BUTTON_MIDDLE)
- buttons |= Qt::MidButton;
- if (packet.hdr.buttons & _POINTER_BUTTON_RIGHT)
- buttons |= Qt::RightButton;
-
- // call mouseChanged() - this does all the magic to actually move the on-screen
- // mouse cursor.
- mouseChanged(pos, buttons, 0);
- } while (++iteration < 11);
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/gui/embedded/qmouseqnx_qws.h b/src/gui/embedded/qmouseqnx_qws.h
deleted file mode 100644
index 0779367600..0000000000
--- a/src/gui/embedded/qmouseqnx_qws.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMOUSE_QNX_H
-#define QMOUSE_QNX_H
-
-#include <QtCore/qobject.h>
-#include <QtGui/qmouse_qws.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QSocketNotifier;
-
-class Q_GUI_EXPORT QQnxMouseHandler : public QObject, public QWSMouseHandler
-{
- Q_OBJECT
-public:
- explicit QQnxMouseHandler(const QString &driver = QString(),
- const QString &device = QString());
- ~QQnxMouseHandler();
-
- void resume();
- void suspend();
-
-private Q_SLOTS:
- void socketActivated();
-
-private:
- QSocketNotifier *mouseNotifier;
- int mouseFD;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMOUSE_QWS_H
diff --git a/src/gui/embedded/qmousetslib_qws.cpp b/src/gui/embedded/qmousetslib_qws.cpp
deleted file mode 100644
index 8794eed2f2..0000000000
--- a/src/gui/embedded/qmousetslib_qws.cpp
+++ /dev/null
@@ -1,371 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmousetslib_qws.h"
-
-#if !defined(QT_NO_QWS_MOUSE_TSLIB) || defined(QT_PLUGIN)
-
-#include <QtCore/qregexp.h>
-#include <QtCore/qstringlist.h>
-#include "qsocketnotifier.h"
-#include "qscreen_qws.h"
-
-#include <tslib.h>
-#include <errno.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifdef TSLIBMOUSEHANDLER_DEBUG
-# include <QtCore/QDebug>
-#endif
-
-/*!
- \internal
-
- \class QWSTslibMouseHandler
- \ingroup qws
-
- \brief The QWSTslibMouseHandler class implements a mouse driver
- for the Universal Touch Screen Library, tslib.
-
- QWSTslibMouseHandler inherits the QWSCalibratedMouseHandler class,
- providing calibration and noise reduction functionality in
- addition to generating mouse events, for devices using the
- Universal Touch Screen Library.
-
- To be able to compile this mouse handler, \l{Qt for Embedded Linux}
- must be configured with the \c -qt-mouse-tslib option, see the
- \l{Pointer Handling} documentation for details. In addition, the tslib
- headers and library must be present in the build environment. The
- tslib sources can be downloaded from \l
- {http://tslib.berlios.de/}. Use the \c -L and \c -I options
- with \c configure to explicitly specify the location of the
- library and its headers:
-
- \snippet doc/src/snippets/code/src_gui_embedded_qmousetslib_qws.cpp 0
-
- In order to use this mouse handler, tslib must also be correctly
- installed on the target machine. This includes providing a \c
- ts.conf configuration file and setting the necessary environment
- variables, see the README file provided with tslib for details.
-
- The ts.conf file will usually contain the following two lines
-
- \snippet doc/src/snippets/code/src_gui_embedded_qmousetslib_qws.cpp 1
-
- To make \l{Qt for Embedded Linux} explicitly choose the tslib mouse
- handler, set the QWS_MOUSE_PROTO environment variable.
-
- \sa {Pointer Handling}, {Qt for Embedded Linux}
-*/
-
-class QWSTslibMouseHandlerPrivate : public QObject
-{
- Q_OBJECT
-public:
- QWSTslibMouseHandlerPrivate(QWSTslibMouseHandler *h,
- const QString &device);
- ~QWSTslibMouseHandlerPrivate();
-
- void suspend();
- void resume();
-
- void calibrate(const QWSPointerCalibrationData *data);
- void clearCalibration();
-
-private:
- QWSTslibMouseHandler *handler;
- struct tsdev *dev;
- QSocketNotifier *mouseNotifier;
- int jitter_limit;
-
- struct ts_sample lastSample;
- bool wasPressed;
- int lastdx;
- int lastdy;
-
- bool calibrated;
- QString devName;
-
- bool open();
- void close();
- inline bool get_sample(struct ts_sample *sample);
-
-private slots:
- void readMouseData();
-};
-
-QWSTslibMouseHandlerPrivate::QWSTslibMouseHandlerPrivate(QWSTslibMouseHandler *h,
- const QString &device)
- : handler(h), dev(0), mouseNotifier(0), jitter_limit(3)
-{
- QStringList args = device.split(QLatin1Char(':'), QString::SkipEmptyParts);
- QRegExp jitterRegex(QLatin1String("^jitter_limit=(\\d+)$"));
- int index = args.indexOf(jitterRegex);
- if (index >= 0) {
- jitter_limit = jitterRegex.cap(1).toInt();
- args.removeAt(index);
- }
-
- devName = args.join(QString());
-
- if (devName.isNull()) {
- const char *str = getenv("TSLIB_TSDEVICE");
- if (str)
- devName = QString::fromLocal8Bit(str);
- }
-
- if (devName.isNull())
- devName = QLatin1String("/dev/ts");
-
- if (!open())
- return;
-
- calibrated = true;
-
- int fd = ts_fd(dev);
- mouseNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this);
- connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData()));
- resume();
-}
-
-QWSTslibMouseHandlerPrivate::~QWSTslibMouseHandlerPrivate()
-{
- close();
-}
-
-bool QWSTslibMouseHandlerPrivate::open()
-{
- dev = ts_open(devName.toLocal8Bit().constData(), 1);
- if (!dev) {
- qCritical("QWSTslibMouseHandlerPrivate: ts_open() failed"
- " with error: '%s'", strerror(errno));
- qCritical("Please check your tslib installation!");
- return false;
- }
-
- if (ts_config(dev)) {
- qCritical("QWSTslibMouseHandlerPrivate: ts_config() failed"
- " with error: '%s'", strerror(errno));
- qCritical("Please check your tslib installation!");
- close();
- return false;
- }
-
- return true;
-}
-
-void QWSTslibMouseHandlerPrivate::close()
-{
- if (dev)
- ts_close(dev);
-}
-
-void QWSTslibMouseHandlerPrivate::suspend()
-{
- if (mouseNotifier)
- mouseNotifier->setEnabled(false);
-}
-
-void QWSTslibMouseHandlerPrivate::resume()
-{
- memset(&lastSample, 0, sizeof(lastSample));
- wasPressed = false;
- lastdx = 0;
- lastdy = 0;
- if (mouseNotifier)
- mouseNotifier->setEnabled(true);
-}
-
-bool QWSTslibMouseHandlerPrivate::get_sample(struct ts_sample *sample)
-{
- if (!calibrated)
- return (ts_read_raw(dev, sample, 1) == 1);
-
- return (ts_read(dev, sample, 1) == 1);
-}
-
-void QWSTslibMouseHandlerPrivate::readMouseData()
-{
- if (!qt_screen)
- return;
-
- for(;;) {
- struct ts_sample sample = lastSample;
- bool pressed = wasPressed;
-
- // Fast return if there's no events.
- if (!get_sample(&sample))
- return;
- pressed = (sample.pressure > 0);
-
- // Only return last sample unless there's a press/release event.
- while (pressed == wasPressed) {
- if (!get_sample(&sample))
- break;
- pressed = (sample.pressure > 0);
- }
-
- // work around missing coordinates on mouse release in raw mode
- if (!calibrated && !pressed && sample.x == 0 && sample.y == 0) {
- sample.x = lastSample.x;
- sample.y = lastSample.y;
- }
-
- int dx = sample.x - lastSample.x;
- int dy = sample.y - lastSample.y;
-
- // Remove small movements in oppsite direction
- if (dx * lastdx < 0 && qAbs(dx) < jitter_limit) {
- sample.x = lastSample.x;
- dx = 0;
- }
- if (dy * lastdy < 0 && qAbs(dy) < jitter_limit) {
- sample.y = lastSample.y;
- dy = 0;
- }
-
- if (wasPressed == pressed && dx == 0 && dy == 0)
- return;
-
-#ifdef TSLIBMOUSEHANDLER_DEBUG
- qDebug() << "last" << QPoint(lastSample.x, lastSample.y)
- << "curr" << QPoint(sample.x, sample.y)
- << "dx,dy" << QPoint(dx, dy)
- << "ddx,ddy" << QPoint(dx*lastdx, dy*lastdy)
- << "pressed" << wasPressed << pressed;
-#endif
-
- lastSample = sample;
- wasPressed = pressed;
- if (dx != 0)
- lastdx = dx;
- if (dy != 0)
- lastdy = dy;
-
- const QPoint p(sample.x, sample.y);
- if (calibrated) {
- // tslib should do all the translation and filtering, so we send a
- // "raw" mouse event
- handler->QWSMouseHandler::mouseChanged(p, pressed);
- } else {
- handler->sendFiltered(p, pressed);
- }
- }
-}
-
-void QWSTslibMouseHandlerPrivate::clearCalibration()
-{
- suspend();
- close();
- handler->QWSCalibratedMouseHandler::clearCalibration();
- calibrated = false;
- open();
- resume();
-}
-
-void QWSTslibMouseHandlerPrivate::calibrate(const QWSPointerCalibrationData *data)
-{
- suspend();
- close();
- // default implementation writes to /etc/pointercal
- // using the same format as the tslib linear module.
- handler->QWSCalibratedMouseHandler::calibrate(data);
- calibrated = true;
- open();
- resume();
-}
-
-/*!
- \internal
-*/
-QWSTslibMouseHandler::QWSTslibMouseHandler(const QString &driver,
- const QString &device)
- : QWSCalibratedMouseHandler(driver, device)
-{
- d = new QWSTslibMouseHandlerPrivate(this, device);
-}
-
-/*!
- \internal
-*/
-QWSTslibMouseHandler::~QWSTslibMouseHandler()
-{
- delete d;
-}
-
-/*!
- \reimp
-*/
-void QWSTslibMouseHandler::suspend()
-{
- d->suspend();
-}
-
-/*!
- \reimp
-*/
-void QWSTslibMouseHandler::resume()
-{
- d->resume();
-}
-
-/*!
- \reimp
-*/
-void QWSTslibMouseHandler::clearCalibration()
-{
- d->clearCalibration();
-}
-
-/*!
- \reimp
-*/
-void QWSTslibMouseHandler::calibrate(const QWSPointerCalibrationData *data)
-{
- d->calibrate(data);
-}
-
-QT_END_NAMESPACE
-
-#include "qmousetslib_qws.moc"
-
-#endif //QT_NO_QWS_MOUSE_TSLIB
diff --git a/src/gui/embedded/qmousetslib_qws.h b/src/gui/embedded/qmousetslib_qws.h
deleted file mode 100644
index fc6206c03f..0000000000
--- a/src/gui/embedded/qmousetslib_qws.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMOUSETSLIB_QWS_H
-#define QMOUSETSLIB_QWS_H
-
-#include <QtGui/qmouse_qws.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if !defined(QT_NO_QWS_MOUSE_TSLIB) || defined(QT_PLUGIN)
-
-class QWSTslibMouseHandlerPrivate;
-
-class QWSTslibMouseHandler : public QWSCalibratedMouseHandler
-{
-public:
- explicit QWSTslibMouseHandler(const QString &driver = QString(),
- const QString &device = QString());
- ~QWSTslibMouseHandler();
-
- void suspend();
- void resume();
-
- void calibrate(const QWSPointerCalibrationData *data);
- void clearCalibration();
-
-protected:
- friend class QWSTslibMouseHandlerPrivate;
- QWSTslibMouseHandlerPrivate *d;
-};
-
-
-#endif // QT_NO_QWS_MOUSE_TSLIB
-QT_END_NAMESPACE
-QT_END_HEADER
-
-#endif // QMOUSETSLIB_QWS_H
diff --git a/src/gui/embedded/qmousevfb_qws.cpp b/src/gui/embedded/qmousevfb_qws.cpp
deleted file mode 100644
index 76eff3efe1..0000000000
--- a/src/gui/embedded/qmousevfb_qws.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QT_NO_QWS_MOUSE_QVFB
-
-#include <stdlib.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <stdio.h>
-
-#include <qvfbhdr.h>
-#include <qmousevfb_qws.h>
-#include <qwindowsystem_qws.h>
-#include <qsocketnotifier.h>
-#include <qapplication.h>
-#include <qtimer.h>
-#include <private/qcore_unix_p.h> // overrides QT_OPEN
-
-QT_BEGIN_NAMESPACE
-
-QVFbMouseHandler::QVFbMouseHandler(const QString &driver, const QString &device)
- : QObject(), QWSMouseHandler(driver, device)
-{
- QString mouseDev = device;
- if (device.isEmpty())
- mouseDev = QLatin1String("/dev/vmouse");
-
- mouseFD = QT_OPEN(mouseDev.toLatin1().constData(), O_RDWR | O_NDELAY);
- if (mouseFD == -1) {
- perror("QVFbMouseHandler::QVFbMouseHandler");
- qWarning("QVFbMouseHander: Unable to open device %s",
- qPrintable(mouseDev));
- return;
- }
-
- // Clear pending input
- char buf[2];
- while (QT_READ(mouseFD, buf, 1) > 0) { }
-
- mouseIdx = 0;
-
- mouseNotifier = new QSocketNotifier(mouseFD, QSocketNotifier::Read, this);
- connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData()));
-}
-
-QVFbMouseHandler::~QVFbMouseHandler()
-{
- if (mouseFD >= 0)
- QT_CLOSE(mouseFD);
-}
-
-void QVFbMouseHandler::resume()
-{
- mouseNotifier->setEnabled(true);
-}
-
-void QVFbMouseHandler::suspend()
-{
- mouseNotifier->setEnabled(false);
-}
-
-void QVFbMouseHandler::readMouseData()
-{
- int n;
- do {
- n = QT_READ(mouseFD, mouseBuf+mouseIdx, mouseBufSize-mouseIdx);
- if (n > 0)
- mouseIdx += n;
- } while (n > 0);
-
- int idx = 0;
- static const int packetsize = sizeof(QPoint) + 2*sizeof(int);
- while (mouseIdx-idx >= packetsize) {
- uchar *mb = mouseBuf+idx;
- QPoint mousePos = *reinterpret_cast<QPoint *>(mb);
- mb += sizeof(QPoint);
- int bstate = *reinterpret_cast<int *>(mb);
- mb += sizeof(int);
- int wheel = *reinterpret_cast<int *>(mb);
-// limitToScreen(mousePos);
- mouseChanged(mousePos, bstate, wheel);
- idx += packetsize;
- }
-
- int surplus = mouseIdx - idx;
- for (int i = 0; i < surplus; i++)
- mouseBuf[i] = mouseBuf[idx+i];
- mouseIdx = surplus;
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_MOUSE_QVFB
diff --git a/src/gui/embedded/qmousevfb_qws.h b/src/gui/embedded/qmousevfb_qws.h
deleted file mode 100644
index f2e7bd14fc..0000000000
--- a/src/gui/embedded/qmousevfb_qws.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMOUSEVFB_QWS_H
-#define QMOUSEVFB_QWS_H
-
-#include <QtGui/qmouse_qws.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_QWS_MOUSE_QVFB
-
-class QSocketNotifier;
-
-class QVFbMouseHandler : public QObject, public QWSMouseHandler {
- Q_OBJECT
-public:
- QVFbMouseHandler(const QString &driver = QString(),
- const QString &device = QString());
- ~QVFbMouseHandler();
-
- void resume();
- void suspend();
-
-private:
- int mouseFD;
- int mouseIdx;
- enum {mouseBufSize = 128};
- uchar mouseBuf[mouseBufSize];
- QSocketNotifier *mouseNotifier;
-
-private Q_SLOTS:
- void readMouseData();
-};
-#endif // QT_NO_QWS_MOUSE_QVFB
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMOUSEVFB_QWS_H
diff --git a/src/gui/embedded/qscreen_qws.cpp b/src/gui/embedded/qscreen_qws.cpp
deleted file mode 100644
index 90561fd06d..0000000000
--- a/src/gui/embedded/qscreen_qws.cpp
+++ /dev/null
@@ -1,3347 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qplatformdefs.h"
-#include "qscreen_qws.h"
-
-#include "qcolormap.h"
-#include "qscreendriverfactory_qws.h"
-#include "qwindowsystem_qws.h"
-#include "qwidget.h"
-#include "qcolor.h"
-#include "qpixmap.h"
-#include "qvarlengtharray.h"
-#include "qwsdisplay_qws.h"
-#include "qpainter.h"
-#include <private/qdrawhelper_p.h>
-#include <private/qpaintengine_raster_p.h>
-#include <private/qpixmap_raster_p.h>
-#include <private/qwindowsurface_qws_p.h>
-#include <private/qpainter_p.h>
-#include <private/qwidget_p.h>
-#include <private/qgraphicssystem_qws_p.h>
-
-QT_BEGIN_NAMESPACE
-
-// #define QT_USE_MEMCPY_DUFF
-
-#ifndef QT_NO_QWS_CURSOR
-Q_GUI_EXPORT QScreenCursor * qt_screencursor = 0;
-#endif
-Q_GUI_EXPORT QScreen * qt_screen = 0;
-
-ClearCacheFunc QScreen::clearCacheFunc = 0;
-
-#ifndef QT_NO_QWS_CURSOR
-/*!
- \class QScreenCursor
- \ingroup qws
-
- \brief The QScreenCursor class is a base class for screen cursors
- in Qt for Embedded Linux.
-
- Note that this class is non-portable, and that it is only
- available in \l{Qt for Embedded Linux}.
-
- QScreenCursor implements a software cursor, but can be subclassed
- to support hardware cursors as well. When deriving from the
- QScreenCursor class it is important to maintain the cursor's
- image, position, hot spot (the point within the cursor's image
- that will be the position of the associated mouse events) and
- visibility as well as informing whether it is hardware accelerated
- or not.
-
- Note that there may only be one screen cursor at a time. Use the
- static instance() function to retrieve a pointer to the current
- screen cursor. Typically, the cursor is constructed by the QScreen
- class or one of its descendants when it is initializing the
- device; the QScreenCursor class should never be instantiated
- explicitly.
-
- Use the move() function to change the position of the cursor, and
- the set() function to alter its image or its hot spot. In
- addition, you can find out whether the cursor is accelerated or
- not, using the isAccelerated() function, and the boundingRect()
- function returns the cursor's bounding rectangle.
-
- The cursor's appearance can be controlled using the isVisible(),
- hide() and show() functions; alternatively the QWSServer class
- provides some means of controlling the cursor's appearance using
- the QWSServer::isCursorVisible() and QWSServer::setCursorVisible()
- functions.
-
- \sa QScreen, QWSServer
-*/
-
-/*!
- \fn static QScreenCursor* QScreenCursor::instance()
- \since 4.2
-
- Returns a pointer to the application's unique screen cursor.
-*/
-
-/*!
- Constructs a screen cursor
-*/
-QScreenCursor::QScreenCursor()
-{
- pos = QPoint(qt_screen->deviceWidth()/2, qt_screen->deviceHeight()/2);
- size = QSize(0,0);
- enable = true;
- hwaccel = false;
- supportsAlpha = true;
-}
-
-/*!
- Destroys the screen cursor.
-*/
-QScreenCursor::~QScreenCursor()
-{
-}
-
-/*!
- Hides the cursor from the screen.
-
- \sa show()
-*/
-void QScreenCursor::hide()
-{
- if (enable) {
- enable = false;
- if (!hwaccel)
- qt_screen->exposeRegion(boundingRect(), 0);
- }
-}
-
-/*!
- Shows the mouse cursor.
-
- \sa hide()
-*/
-void QScreenCursor::show()
-{
- if (!enable) {
- enable = true;
- if (!hwaccel)
- qt_screen->exposeRegion(boundingRect(), 0);
- }
-}
-
-/*!
- Sets the cursor's image to be the given \a image.
-
- The \a hotx and \a hoty parameters define the cursor's hot spot,
- i.e., the point within the cursor's image that will be the
- position of the associated mouse events.
-
- \sa move()
-*/
-void QScreenCursor::set(const QImage &image, int hotx, int hoty)
-{
- const QRect r = boundingRect();
-
- hotspot = QPoint(hotx, hoty);
- // These are in almost all cases the fastest formats to blend
- QImage::Format f;
- switch (qt_screen->depth()) {
- case 12:
- f = QImage::Format_ARGB4444_Premultiplied;
- break;
- case 15:
- f = QImage::Format_ARGB8555_Premultiplied;
- break;
- case 16:
- f = QImage::Format_ARGB8565_Premultiplied;
- break;
- case 18:
- f = QImage::Format_ARGB6666_Premultiplied;
- break;
- default:
- f = QImage::Format_ARGB32_Premultiplied;
- }
-
- cursor = image.convertToFormat(f);
-
- size = image.size();
-
- if (enable && !hwaccel)
- qt_screen->exposeRegion(r | boundingRect(), 0);
-}
-
-/*!
- Moves the mouse cursor to the given position, i.e., (\a x, \a y).
-
- Note that the given position defines the top-left corner of the
- cursor's image, i.e., not the cursor's hot spot (the position of
- the associated mouse events).
-
- \sa set()
-*/
-void QScreenCursor::move(int x, int y)
-{
- QRegion r = boundingRect();
- pos = QPoint(x,y);
- if (enable && !hwaccel) {
- r |= boundingRect();
- qt_screen->exposeRegion(r, 0);
- }
-}
-
-
-/*!
- \fn void QScreenCursor::initSoftwareCursor ()
-
- Initializes the screen cursor.
-
- This function is typically called from the screen driver when
- initializing the device. Alternatively, the cursor can be set
- directly using the pointer returned by the static instance()
- function.
-
- \sa QScreen::initDevice()
-*/
-void QScreenCursor::initSoftwareCursor()
-{
- qt_screencursor = new QScreenCursor;
-}
-
-
-#endif // QT_NO_QWS_CURSOR
-
-
-/*!
- \fn QRect QScreenCursor::boundingRect () const
-
- Returns the cursor's bounding rectangle.
-*/
-
-/*!
- \internal
- \fn bool QScreenCursor::enabled ()
-*/
-
-/*!
- \fn QImage QScreenCursor::image () const
-
- Returns the cursor's image.
-*/
-
-
-/*!
- \fn bool QScreenCursor::isAccelerated () const
-
- Returns true if the cursor is accelerated; otherwise false.
-*/
-
-/*!
- \fn bool QScreenCursor::isVisible () const
-
- Returns true if the cursor is visible; otherwise false.
-*/
-
-/*!
- \internal
- \fn bool QScreenCursor::supportsAlphaCursor () const
-*/
-
-/*
- \variable QScreenCursor::cursor
-
- \brief the cursor's image.
-
- \sa image()
-*/
-
-/*
- \variable QScreenCursor::size
-
- \brief the cursor's size
-*/
-
-/*
- \variable QScreenCursor::pos
-
- \brief the cursor's position, i.e., the position of the top-left
- corner of the crsor's image
-
- \sa set(), move()
-*/
-
-/*
- \variable QScreenCursor::hotspot
-
- \brief the cursor's hotspot, i.e., the point within the cursor's
- image that will be the position of the associated mouse events.
-
- \sa set(), move()
-*/
-
-/*
- \variable QScreenCursor::enable
-
- \brief whether the cursor is visible or not
-
- \sa isVisible()
-*/
-
-/*
- \variable QScreenCursor::hwaccel
-
- \brief holds whether the cursor is accelerated or not
-
- If the cursor is not accelerated, its image will be included by
- the screen when it composites the window surfaces.
-
- \sa isAccelerated()
-
-*/
-
-/*
- \variable QScreenCursor::supportsAlpha
-*/
-
-/*!
- \internal
- \macro qt_screencursor
- \relates QScreenCursor
-
- A global pointer referring to the unique screen cursor. It is
- equivalent to the pointer returned by the
- QScreenCursor::instance() function.
-*/
-
-
-
-class QScreenPrivate
-{
-public:
- QScreenPrivate(QScreen *parent, QScreen::ClassId id = QScreen::CustomClass);
- ~QScreenPrivate();
-
- inline QImage::Format preferredImageFormat() const;
-
- typedef void (*SolidFillFunc)(QScreen*, const QColor&, const QRegion&);
- typedef void (*BlitFunc)(QScreen*, const QImage&, const QPoint&, const QRegion&);
-
- SolidFillFunc solidFill;
- BlitFunc blit;
-
- QPoint offset;
- QList<QScreen*> subScreens;
- QPixmapDataFactory* pixmapFactory;
- QGraphicsSystem* graphicsSystem;
- QWSGraphicsSystem defaultGraphicsSystem; //###
- QImage::Format pixelFormat;
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- bool fb_is_littleEndian;
-#endif
-#ifdef QT_QWS_CLIENTBLIT
- bool supportsBlitInClients;
-#endif
- int classId;
- QScreen *q_ptr;
-};
-
-template <typename T>
-static void solidFill_template(QScreen *screen, const QColor &color,
- const QRegion &region)
-{
- T *dest = reinterpret_cast<T*>(screen->base());
- const T c = qt_colorConvert<T, quint32>(color.rgba(), 0);
- const int stride = screen->linestep();
- const QVector<QRect> rects = region.rects();
-
- for (int i = 0; i < rects.size(); ++i) {
- const QRect r = rects.at(i);
- qt_rectfill(dest, c, r.x(), r.y(), r.width(), r.height(), stride);
- }
-}
-
-#ifdef QT_QWS_DEPTH_GENERIC
-static void solidFill_rgb_32bpp(QScreen *screen, const QColor &color,
- const QRegion &region)
-{
- quint32 *dest = reinterpret_cast<quint32*>(screen->base());
- const quint32 c = qt_convertToRgb<quint32>(color.rgba());
-
- const int stride = screen->linestep();
- const QVector<QRect> rects = region.rects();
-
- for (int i = 0; i < rects.size(); ++i) {
- const QRect r = rects.at(i);
- qt_rectfill(dest, c, r.x(), r.y(), r.width(), r.height(), stride);
- }
-}
-
-static void solidFill_rgb_16bpp(QScreen *screen, const QColor &color,
- const QRegion &region)
-{
- quint16 *dest = reinterpret_cast<quint16*>(screen->base());
- const quint16 c = qt_convertToRgb<quint32>(color.rgba());
-
- const int stride = screen->linestep();
- const QVector<QRect> rects = region.rects();
-
- for (int i = 0; i < rects.size(); ++i) {
- const QRect r = rects.at(i);
- qt_rectfill(dest, c, r.x(), r.y(), r.width(), r.height(), stride);
- }
-}
-#endif // QT_QWS_DEPTH_GENERIC
-
-#ifdef QT_QWS_DEPTH_4
-static inline void qt_rectfill_gray4(quint8 *dest, quint8 value,
- int x, int y, int width, int height,
- int stride)
-{
- const int pixelsPerByte = 2;
- dest += y * stride + x / pixelsPerByte;
- const int doAlign = x & 1;
- const int doTail = (width - doAlign) & 1;
- const int width8 = (width - doAlign) / pixelsPerByte;
-
- for (int j = 0; j < height; ++j) {
- if (doAlign)
- *dest = (*dest & 0xf0) | (value & 0x0f);
- if (width8)
- qt_memfill<quint8>(dest + doAlign, value, width8);
- if (doTail) {
- quint8 *d = dest + doAlign + width8;
- *d = (*d & 0x0f) | (value & 0xf0);
- }
- dest += stride;
- }
-}
-
-static void solidFill_gray4(QScreen *screen, const QColor &color,
- const QRegion &region)
-{
- quint8 *dest = reinterpret_cast<quint8*>(screen->base());
- const quint8 c = qGray(color.rgba()) >> 4;
- const quint8 c8 = (c << 4) | c;
-
- const int stride = screen->linestep();
- const QVector<QRect> rects = region.rects();
-
- for (int i = 0; i < rects.size(); ++i) {
- const QRect r = rects.at(i);
- qt_rectfill_gray4(dest, c8, r.x(), r.y(), r.width(), r.height(),
- stride);
- }
-}
-#endif // QT_QWS_DEPTH_4
-
-#ifdef QT_QWS_DEPTH_1
-static inline void qt_rectfill_mono(quint8 *dest, quint8 value,
- int x, int y, int width, int height,
- int stride)
-{
- const int pixelsPerByte = 8;
- const int alignWidth = qMin(width, (8 - (x & 7)) & 7);
- const int doAlign = (alignWidth > 0 ? 1 : 0);
- const int alignStart = pixelsPerByte - 1 - (x & 7);
- const int alignStop = alignStart - (alignWidth - 1);
- const quint8 alignMask = ((1 << alignWidth) - 1) << alignStop;
- const int tailWidth = (width - alignWidth) & 7;
- const int doTail = (tailWidth > 0 ? 1 : 0);
- const quint8 tailMask = (1 << (pixelsPerByte - tailWidth)) - 1;
- const int width8 = (width - alignWidth) / pixelsPerByte;
-
- dest += y * stride + x / pixelsPerByte;
- stride -= (doAlign + width8);
-
- for (int j = 0; j < height; ++j) {
- if (doAlign) {
- *dest = (*dest & ~alignMask) | (value & alignMask);
- ++dest;
- }
- if (width8) {
- qt_memfill<quint8>(dest, value, width8);
- dest += width8;
- }
- if (doTail)
- *dest = (*dest & tailMask) | (value & ~tailMask);
- dest += stride;
- }
-}
-
-static void solidFill_mono(QScreen *screen, const QColor &color,
- const QRegion &region)
-{
- quint8 *dest = reinterpret_cast<quint8*>(screen->base());
- const quint8 c8 = (qGray(color.rgba()) >> 7) * 0xff;
-
- const int stride = screen->linestep();
- const QVector<QRect> rects = region.rects();
-
- for (int i = 0; i < rects.size(); ++i) {
- const QRect r = rects.at(i);
- qt_rectfill_mono(dest, c8, r.x(), r.y(), r.width(), r.height(),
- stride);
- }
-}
-#endif // QT_QWS_DEPTH_1
-
-void qt_solidFill_setup(QScreen *screen, const QColor &color,
- const QRegion &region)
-{
- switch (screen->depth()) {
-#ifdef QT_QWS_DEPTH_32
- case 32:
- if (screen->pixelType() == QScreen::NormalPixel)
- screen->d_ptr->solidFill = solidFill_template<quint32>;
- else
- screen->d_ptr->solidFill = solidFill_template<qabgr8888>;
- break;
-#endif
-#ifdef QT_QWS_DEPTH_24
- case 24:
- if (screen->pixelType() == QScreen::NormalPixel)
- screen->d_ptr->solidFill = solidFill_template<qrgb888>;
- else
- screen->d_ptr->solidFill = solidFill_template<quint24>;
- break;
-#endif
-#ifdef QT_QWS_DEPTH_18
- case 18:
- screen->d_ptr->solidFill = solidFill_template<quint18>;
- break;
-#endif
-#ifdef QT_QWS_DEPTH_16
- case 16:
- if (screen->pixelType() == QScreen::NormalPixel)
- screen->d_ptr->solidFill = solidFill_template<quint16>;
- else
- screen->d_ptr->solidFill = solidFill_template<qbgr565>;
- break;
-#endif
-#ifdef QT_QWS_DEPTH_15
- case 15:
- if (screen->pixelType() == QScreen::NormalPixel)
- screen->d_ptr->solidFill = solidFill_template<qrgb555>;
- else
- screen->d_ptr->solidFill = solidFill_template<qbgr555>;
- break;
-#endif
-#ifdef QT_QWS_DEPTH_12
- case 12:
- screen->d_ptr->solidFill = solidFill_template<qrgb444>;
- break;
-#endif
-#ifdef QT_QWS_DEPTH_8
- case 8:
- screen->d_ptr->solidFill = solidFill_template<quint8>;
- break;
-#endif
-#ifdef QT_QWS_DEPTH_4
- case 4:
- screen->d_ptr->solidFill = solidFill_gray4;
- break;
-#endif
-#ifdef QT_QWS_DEPTH_1
- case 1:
- screen->d_ptr->solidFill = solidFill_mono;
- break;
-#endif
- default:
- qFatal("solidFill_setup(): Screen depth %d not supported!",
- screen->depth());
- screen->d_ptr->solidFill = 0;
- break;
- }
- screen->d_ptr->solidFill(screen, color, region);
-}
-
-template <typename DST, typename SRC>
-static void blit_template(QScreen *screen, const QImage &image,
- const QPoint &topLeft, const QRegion &region)
-{
- DST *dest = reinterpret_cast<DST*>(screen->base());
- const int screenStride = screen->linestep();
- const int imageStride = image.bytesPerLine();
-
- if (region.rectCount() == 1) {
- const QRect r = region.boundingRect();
- const SRC *src = reinterpret_cast<const SRC*>(image.scanLine(r.y()))
- + r.x();
- qt_rectconvert<DST, SRC>(dest, src,
- r.x() + topLeft.x(), r.y() + topLeft.y(),
- r.width(), r.height(),
- screenStride, imageStride);
- } else {
- const QVector<QRect> rects = region.rects();
-
- for (int i = 0; i < rects.size(); ++i) {
- const QRect r = rects.at(i);
- const SRC *src = reinterpret_cast<const SRC*>(image.scanLine(r.y()))
- + r.x();
- qt_rectconvert<DST, SRC>(dest, src,
- r.x() + topLeft.x(), r.y() + topLeft.y(),
- r.width(), r.height(),
- screenStride, imageStride);
- }
- }
-}
-
-#ifdef QT_QWS_DEPTH_32
-static void blit_32(QScreen *screen, const QImage &image,
- const QPoint &topLeft, const QRegion &region)
-{
- switch (image.format()) {
- case QImage::Format_RGB32:
- case QImage::Format_ARGB32:
- case QImage::Format_ARGB32_Premultiplied:
- blit_template<quint32, quint32>(screen, image, topLeft, region);
- return;
-#ifdef QT_QWS_DEPTH_16
- case QImage::Format_RGB16:
- blit_template<quint32, quint16>(screen, image, topLeft, region);
- return;
-#endif
- default:
- qCritical("blit_32(): Image format %d not supported!", image.format());
- }
-}
-#endif // QT_QWS_DEPTH_32
-
-#ifdef QT_QWS_DEPTH_24
-static void blit_24(QScreen *screen, const QImage &image,
- const QPoint &topLeft, const QRegion &region)
-{
- switch (image.format()) {
- case QImage::Format_RGB32:
- case QImage::Format_ARGB32:
- case QImage::Format_ARGB32_Premultiplied:
- blit_template<quint24, quint32>(screen, image, topLeft, region);
- return;
- case QImage::Format_RGB888:
- blit_template<quint24, qrgb888>(screen, image, topLeft, region);
- return;
-#ifdef QT_QWS_DEPTH_16
- case QImage::Format_RGB16:
- blit_template<quint24, quint16>(screen, image, topLeft, region);
- return;
-#endif
- default:
- qCritical("blit_24(): Image format %d not supported!", image.format());
- }
-}
-
-static void blit_qrgb888(QScreen *screen, const QImage &image,
- const QPoint &topLeft, const QRegion &region)
-{
- switch (image.format()) {
- case QImage::Format_RGB32:
- case QImage::Format_ARGB32:
- case QImage::Format_ARGB32_Premultiplied:
- blit_template<qrgb888, quint32>(screen, image, topLeft, region);
- return;
- case QImage::Format_RGB888:
- blit_template<qrgb888, qrgb888>(screen, image, topLeft, region);
- return;
-#ifdef QT_QWS_DEPTH_16
- case QImage::Format_RGB16:
- blit_template<qrgb888, quint16>(screen, image, topLeft, region);
- return;
-#endif
- default:
- qCritical("blit_24(): Image format %d not supported!", image.format());
- break;
- }
-}
-#endif // QT_QWS_DEPTH_24
-
-#ifdef QT_QWS_DEPTH_18
-static void blit_18(QScreen *screen, const QImage &image,
- const QPoint &topLeft, const QRegion &region)
-{
- switch (image.format()) {
- case QImage::Format_RGB32:
- case QImage::Format_ARGB32:
- case QImage::Format_ARGB32_Premultiplied:
- blit_template<qrgb666, quint32>(screen, image, topLeft, region);
- return;
- case QImage::Format_RGB666:
- blit_template<qrgb666, qrgb666>(screen, image, topLeft, region);
- return;
-#ifdef QT_QWS_DEPTH_16
- case QImage::Format_RGB16:
- blit_template<qrgb666, quint16>(screen, image, topLeft, region);
- return;
-#endif
- default:
- qCritical("blit_18(): Image format %d not supported!", image.format());
- }
-}
-#endif // QT_QWS_DEPTH_18
-
-#if (Q_BYTE_ORDER == Q_BIG_ENDIAN) && (defined(QT_QWS_DEPTH_16) || defined(QT_QWS_DEPTH_15))
-class quint16LE
-{
-public:
- inline quint16LE(quint32 v) {
- data = ((v & 0xff00) >> 8) | ((v & 0x00ff) << 8);
- }
-
- inline quint16LE(int v) {
- data = ((v & 0xff00) >> 8) | ((v & 0x00ff) << 8);
- }
-
- inline quint16LE(quint16 v) {
- data = ((v & 0xff00) >> 8) | ((v & 0x00ff) << 8);
- }
-
- inline quint16LE(qrgb555 v) {
- data = (( (quint16)v & 0xff00) >> 8) |
- (( (quint16)v & 0x00ff) << 8);
- }
-
- inline bool operator==(const quint16LE &v) const
- {
- return data == v.data;
- }
-
-private:
- quint16 data;
-};
-#endif
-
-#ifdef QT_QWS_DEPTH_16
-static void blit_16(QScreen *screen, const QImage &image,
- const QPoint &topLeft, const QRegion &region)
-{
- switch (image.format()) {
- case QImage::Format_RGB32:
- case QImage::Format_ARGB32:
- case QImage::Format_ARGB32_Premultiplied:
- // ### This probably doesn't work but it's a case which should never happen
- blit_template<quint16, quint32>(screen, image, topLeft, region);
- return;
- case QImage::Format_RGB16:
- blit_template<quint16, quint16>(screen, image, topLeft, region);
- return;
- default:
- qCritical("blit_16(): Image format %d not supported!", image.format());
- }
-}
-
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
-static void blit_16_bigToLittleEndian(QScreen *screen, const QImage &image,
- const QPoint &topLeft,
- const QRegion &region)
-{
- switch (image.format()) {
- case QImage::Format_RGB32:
- case QImage::Format_ARGB32:
- case QImage::Format_ARGB32_Premultiplied:
- blit_template<quint16LE, quint32>(screen, image, topLeft, region);
- return;
- case QImage::Format_RGB16:
- blit_template<quint16LE, quint16>(screen, image, topLeft, region);
- return;
- default:
- qCritical("blit_16_bigToLittleEndian(): Image format %d not supported!", image.format());
- }
-}
-
-#endif // Q_BIG_ENDIAN
-#endif // QT_QWS_DEPTH_16
-
-#ifdef QT_QWS_DEPTH_15
-static void blit_15(QScreen *screen, const QImage &image,
- const QPoint &topLeft, const QRegion &region)
-{
- switch (image.format()) {
- case QImage::Format_RGB32:
- case QImage::Format_ARGB32:
- case QImage::Format_ARGB32_Premultiplied:
- blit_template<qrgb555, quint32>(screen, image, topLeft, region);
- return;
- case QImage::Format_RGB555:
- blit_template<qrgb555, qrgb555>(screen, image, topLeft, region);
- return;
- case QImage::Format_RGB16:
- blit_template<qrgb555, quint16>(screen, image, topLeft, region);
- return;
- default:
- qCritical("blit_15(): Image format %d not supported!", image.format());
- }
-}
-
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
-static void blit_15_bigToLittleEndian(QScreen *screen, const QImage &image,
- const QPoint &topLeft,
- const QRegion &region)
-{
- switch (image.format()) {
- case QImage::Format_RGB555:
- blit_template<quint16LE, qrgb555>(screen, image, topLeft, region);
- return;
- default:
- qCritical("blit_15_bigToLittleEndian(): Image format %d not supported!", image.format());
- }
-}
-#endif // Q_BIG_ENDIAN
-#endif // QT_QWS_DEPTH_15
-
-
-#ifdef QT_QWS_DEPTH_12
-static void blit_12(QScreen *screen, const QImage &image,
- const QPoint &topLeft, const QRegion &region)
-{
- switch (image.format()) {
- case QImage::Format_ARGB4444_Premultiplied:
- blit_template<qrgb444, qargb4444>(screen, image, topLeft, region);
- return;
- case QImage::Format_RGB444:
- blit_template<qrgb444, qrgb444>(screen, image, topLeft, region);
- return;
- default:
- qCritical("blit_12(): Image format %d not supported!", image.format());
- }
-}
-#endif // QT_QWS_DEPTH_12
-
-#ifdef QT_QWS_DEPTH_8
-static void blit_8(QScreen *screen, const QImage &image,
- const QPoint &topLeft, const QRegion &region)
-{
- switch (image.format()) {
- case QImage::Format_RGB32:
- case QImage::Format_ARGB32:
- case QImage::Format_ARGB32_Premultiplied:
- blit_template<quint8, quint32>(screen, image, topLeft, region);
- return;
- case QImage::Format_RGB16:
- blit_template<quint8, quint16>(screen, image, topLeft, region);
- return;
- case QImage::Format_ARGB4444_Premultiplied:
- blit_template<quint8, qargb4444>(screen, image, topLeft, region);
- return;
- case QImage::Format_RGB444:
- blit_template<quint8, qrgb444>(screen, image, topLeft, region);
- return;
- default:
- qCritical("blit_8(): Image format %d not supported!", image.format());
- }
-}
-#endif // QT_QWS_DEPTH_8
-
-#ifdef QT_QWS_DEPTH_4
-
-struct qgray4 { quint8 dummy; } Q_PACKED;
-
-template <typename SRC>
-Q_STATIC_TEMPLATE_FUNCTION inline quint8 qt_convertToGray4(SRC color);
-
-template <>
-inline quint8 qt_convertToGray4(quint32 color)
-{
- return qGray(color) >> 4;
-}
-
-template <>
-inline quint8 qt_convertToGray4(quint16 color)
-{
- const int r = (color & 0xf800) >> 11;
- const int g = (color & 0x07e0) >> 6; // only keep 5 bit
- const int b = (color & 0x001f);
- return (r * 11 + g * 16 + b * 5) >> 6;
-}
-
-template <>
-inline quint8 qt_convertToGray4(qrgb444 color)
-{
- return qt_convertToGray4(quint32(color));
-}
-
-template <>
-inline quint8 qt_convertToGray4(qargb4444 color)
-{
- return qt_convertToGray4(quint32(color));
-}
-
-template <typename SRC>
-Q_STATIC_TEMPLATE_FUNCTION inline void qt_rectconvert_gray4(qgray4 *dest4, const SRC *src,
- int x, int y, int width, int height,
- int dstStride, int srcStride)
-{
- const int pixelsPerByte = 2;
- quint8 *dest8 = reinterpret_cast<quint8*>(dest4)
- + y * dstStride + x / pixelsPerByte;
- const int doAlign = x & 1;
- const int doTail = (width - doAlign) & 1;
- const int width8 = (width - doAlign) / pixelsPerByte;
- const int count8 = (width8 + 3) / 4;
-
- srcStride = srcStride / sizeof(SRC) - width;
- dstStride -= (width8 + doAlign);
-
- for (int i = 0; i < height; ++i) {
- if (doAlign) {
- *dest8 = (*dest8 & 0xf0) | qt_convertToGray4<SRC>(*src++);
- ++dest8;
- }
- if (count8) {
- int n = count8;
- switch (width8 & 0x03) // duff's device
- {
- case 0: do { *dest8++ = qt_convertToGray4<SRC>(src[0]) << 4
- | qt_convertToGray4<SRC>(src[1]);
- src += 2;
- case 3: *dest8++ = qt_convertToGray4<SRC>(src[0]) << 4
- | qt_convertToGray4<SRC>(src[1]);
- src += 2;
- case 2: *dest8++ = qt_convertToGray4<SRC>(src[0]) << 4
- | qt_convertToGray4<SRC>(src[1]);
- src += 2;
- case 1: *dest8++ = qt_convertToGray4<SRC>(src[0]) << 4
- | qt_convertToGray4<SRC>(src[1]);
- src += 2;
- } while (--n > 0);
- }
- }
-
- if (doTail)
- *dest8 = qt_convertToGray4<SRC>(*src++) << 4 | (*dest8 & 0x0f);
-
- dest8 += dstStride;
- src += srcStride;
- }
-}
-
-template <>
-void qt_rectconvert(qgray4 *dest, const quint32 *src,
- int x, int y, int width, int height,
- int dstStride, int srcStride)
-{
- qt_rectconvert_gray4<quint32>(dest, src, x, y, width, height,
- dstStride, srcStride);
-}
-
-template <>
-void qt_rectconvert(qgray4 *dest, const quint16 *src,
- int x, int y, int width, int height,
- int dstStride, int srcStride)
-{
- qt_rectconvert_gray4<quint16>(dest, src, x, y, width, height,
- dstStride, srcStride);
-}
-
-template <>
-void qt_rectconvert(qgray4 *dest, const qrgb444 *src,
- int x, int y, int width, int height,
- int dstStride, int srcStride)
-{
- qt_rectconvert_gray4<qrgb444>(dest, src, x, y, width, height,
- dstStride, srcStride);
-}
-
-template <>
-void qt_rectconvert(qgray4 *dest, const qargb4444 *src,
- int x, int y, int width, int height,
- int dstStride, int srcStride)
-{
- qt_rectconvert_gray4<qargb4444>(dest, src, x, y, width, height,
- dstStride, srcStride);
-}
-
-static void blit_4(QScreen *screen, const QImage &image,
- const QPoint &topLeft, const QRegion &region)
-{
- switch (image.format()) {
- case QImage::Format_ARGB32_Premultiplied:
- blit_template<qgray4, quint32>(screen, image, topLeft, region);
- return;
- case QImage::Format_RGB16:
- blit_template<qgray4, quint16>(screen, image, topLeft, region);
- return;
- case QImage::Format_RGB444:
- blit_template<qgray4, qrgb444>(screen, image, topLeft, region);
- return;
- case QImage::Format_ARGB4444_Premultiplied:
- blit_template<qgray4, qargb4444>(screen, image, topLeft, region);
- return;
- default:
- qCritical("blit_4(): Image format %d not supported!", image.format());
- }
-}
-#endif // QT_QWS_DEPTH_4
-
-#ifdef QT_QWS_DEPTH_1
-
-struct qmono { quint8 dummy; } Q_PACKED;
-
-template <typename SRC>
-Q_STATIC_TEMPLATE_FUNCTION inline quint8 qt_convertToMono(SRC color);
-
-template <>
-inline quint8 qt_convertToMono(quint32 color)
-{
- return qGray(color) >> 7;
-}
-
-template <>
-inline quint8 qt_convertToMono(quint16 color)
-{
- return (qGray(qt_colorConvert<quint32, quint16>(color, 0)) >> 7);
-}
-
-template <>
-inline quint8 qt_convertToMono(qargb4444 color)
-{
- return (qGray(quint32(color)) >> 7);
-}
-
-template <>
-inline quint8 qt_convertToMono(qrgb444 color)
-{
- return (qGray(quint32(color)) >> 7);
-}
-
-template <typename SRC>
-inline void qt_rectconvert_mono(qmono *dest, const SRC *src,
- int x, int y, int width, int height,
- int dstStride, int srcStride)
-{
- const int pixelsPerByte = 8;
- quint8 *dest8 = reinterpret_cast<quint8*>(dest)
- + y * dstStride + x / pixelsPerByte;
- const int alignWidth = qMin(width, (8 - (x & 7)) & 7);
- const int doAlign = (alignWidth > 0 ? 1 : 0);
- const int alignStart = pixelsPerByte - 1 - (x & 7);
- const int alignStop = alignStart - (alignWidth - 1);
- const quint8 alignMask = ((1 << alignWidth) - 1) << alignStop;
- const int tailWidth = (width - alignWidth) & 7;
- const int doTail = (tailWidth > 0 ? 1 : 0);
- const quint8 tailMask = (1 << (pixelsPerByte - tailWidth)) - 1;
- const int width8 = (width - alignWidth) / pixelsPerByte;
-
- srcStride = srcStride / sizeof(SRC) - (width8 * 8 + alignWidth);
- dstStride -= (width8 + doAlign);
-
- for (int j = 0; j < height; ++j) {
- if (doAlign) {
- quint8 d = *dest8 & ~alignMask;
- for (int i = alignStart; i >= alignStop; --i)
- d |= qt_convertToMono<SRC>(*src++) << i;
- *dest8++ = d;
- }
- for (int i = 0; i < width8; ++i) {
- *dest8 = (qt_convertToMono<SRC>(src[0]) << 7)
- | (qt_convertToMono<SRC>(src[1]) << 6)
- | (qt_convertToMono<SRC>(src[2]) << 5)
- | (qt_convertToMono<SRC>(src[3]) << 4)
- | (qt_convertToMono<SRC>(src[4]) << 3)
- | (qt_convertToMono<SRC>(src[5]) << 2)
- | (qt_convertToMono<SRC>(src[6]) << 1)
- | (qt_convertToMono<SRC>(src[7]));
- src += 8;
- ++dest8;
- }
- if (doTail) {
- quint8 d = *dest8 & tailMask;
- switch (tailWidth) {
- case 7: d |= qt_convertToMono<SRC>(src[6]) << 1;
- case 6: d |= qt_convertToMono<SRC>(src[5]) << 2;
- case 5: d |= qt_convertToMono<SRC>(src[4]) << 3;
- case 4: d |= qt_convertToMono<SRC>(src[3]) << 4;
- case 3: d |= qt_convertToMono<SRC>(src[2]) << 5;
- case 2: d |= qt_convertToMono<SRC>(src[1]) << 6;
- case 1: d |= qt_convertToMono<SRC>(src[0]) << 7;
- }
- *dest8 = d;
- }
-
- dest8 += dstStride;
- src += srcStride;
- }
-}
-
-template <>
-void qt_rectconvert(qmono *dest, const quint32 *src,
- int x, int y, int width, int height,
- int dstStride, int srcStride)
-{
- qt_rectconvert_mono<quint32>(dest, src, x, y, width, height,
- dstStride, srcStride);
-}
-
-template <>
-void qt_rectconvert(qmono *dest, const quint16 *src,
- int x, int y, int width, int height,
- int dstStride, int srcStride)
-{
- qt_rectconvert_mono<quint16>(dest, src, x, y, width, height,
- dstStride, srcStride);
-}
-
-template <>
-void qt_rectconvert(qmono *dest, const qrgb444 *src,
- int x, int y, int width, int height,
- int dstStride, int srcStride)
-{
- qt_rectconvert_mono<qrgb444>(dest, src, x, y, width, height,
- dstStride, srcStride);
-}
-
-template <>
-void qt_rectconvert(qmono *dest, const qargb4444 *src,
- int x, int y, int width, int height,
- int dstStride, int srcStride)
-{
- qt_rectconvert_mono<qargb4444>(dest, src, x, y, width, height,
- dstStride, srcStride);
-}
-
-static void blit_1(QScreen *screen, const QImage &image,
- const QPoint &topLeft, const QRegion &region)
-{
- switch (image.format()) {
- case QImage::Format_ARGB32_Premultiplied:
- blit_template<qmono, quint32>(screen, image, topLeft, region);
- return;
- case QImage::Format_RGB16:
- blit_template<qmono, quint16>(screen, image, topLeft, region);
- return;
- case QImage::Format_RGB444:
- blit_template<qmono, qrgb444>(screen, image, topLeft, region);
- return;
- case QImage::Format_ARGB4444_Premultiplied:
- blit_template<qmono, qargb4444>(screen, image, topLeft, region);
- return;
- default:
- qCritical("blit_1(): Image format %d not supported!", image.format());
- }
-}
-#endif // QT_QWS_DEPTH_1
-
-#ifdef QT_QWS_DEPTH_GENERIC
-
-static void blit_rgb(QScreen *screen, const QImage &image,
- const QPoint &topLeft, const QRegion &region)
-{
- switch (image.format()) {
- case QImage::Format_ARGB32_Premultiplied:
- blit_template<qrgb, quint32>(screen, image, topLeft, region);
- return;
- case QImage::Format_RGB16:
- blit_template<qrgb, quint16>(screen, image, topLeft, region);
- return;
- default:
- qCritical("blit_rgb(): Image format %d not supported!", image.format());
- }
-}
-
-void qt_set_generic_blit(QScreen *screen, int bpp,
- int len_red, int len_green, int len_blue, int len_alpha,
- int off_red, int off_green, int off_blue, int off_alpha)
-{
- qrgb::bpp = bpp / 8;
- qrgb::len_red = len_red;
- qrgb::len_green = len_green;
- qrgb::len_blue = len_blue;
- qrgb::len_alpha = len_alpha;
- qrgb::off_red = off_red;
- qrgb::off_green = off_green;
- qrgb::off_blue = off_blue;
- qrgb::off_alpha = off_alpha;
- screen->d_ptr->blit = blit_rgb;
- if (bpp == 16)
- screen->d_ptr->solidFill = solidFill_rgb_16bpp;
- else if (bpp == 32)
- screen->d_ptr->solidFill = solidFill_rgb_32bpp;
-}
-
-#endif // QT_QWS_DEPTH_GENERIC
-
-void qt_blit_setup(QScreen *screen, const QImage &image,
- const QPoint &topLeft, const QRegion &region)
-{
- switch (screen->depth()) {
-#ifdef QT_QWS_DEPTH_32
- case 32:
- if (screen->pixelType() == QScreen::NormalPixel)
- screen->d_ptr->blit = blit_32;
- else
- screen->d_ptr->blit = blit_template<qabgr8888, quint32>;
- break;
-#endif
-#ifdef QT_QWS_DEPTH_24
- case 24:
- if (screen->pixelType() == QScreen::NormalPixel)
- screen->d_ptr->blit = blit_qrgb888;
- else
- screen->d_ptr->blit = blit_24;
- break;
-#endif
-#ifdef QT_QWS_DEPTH_18
- case 18:
- screen->d_ptr->blit = blit_18;
- break;
-#endif
-#ifdef QT_QWS_DEPTH_16
- case 16:
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- if (screen->d_ptr->fb_is_littleEndian)
- screen->d_ptr->blit = blit_16_bigToLittleEndian;
- else
-#endif
- if (screen->pixelType() == QScreen::NormalPixel)
- screen->d_ptr->blit = blit_16;
- else
- screen->d_ptr->blit = blit_template<qbgr565, quint16>;
- break;
-#endif
-#ifdef QT_QWS_DEPTH_15
- case 15:
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- if (screen->d_ptr->fb_is_littleEndian)
- screen->d_ptr->blit = blit_15_bigToLittleEndian;
- else
-#endif // Q_BIG_ENDIAN
- if (screen->pixelType() == QScreen::NormalPixel)
- screen->d_ptr->blit = blit_15;
- else
- screen->d_ptr->blit = blit_template<qbgr555, qrgb555>;
- break;
-#endif
-#ifdef QT_QWS_DEPTH_12
- case 12:
- screen->d_ptr->blit = blit_12;
- break;
-#endif
-#ifdef QT_QWS_DEPTH_8
- case 8:
- screen->d_ptr->blit = blit_8;
- break;
-#endif
-#ifdef QT_QWS_DEPTH_4
- case 4:
- screen->d_ptr->blit = blit_4;
- break;
-#endif
-#ifdef QT_QWS_DEPTH_1
- case 1:
- screen->d_ptr->blit = blit_1;
- break;
-#endif
- default:
- qFatal("blit_setup(): Screen depth %d not supported!",
- screen->depth());
- screen->d_ptr->blit = 0;
- break;
- }
- screen->d_ptr->blit(screen, image, topLeft, region);
-}
-
-QScreenPrivate::QScreenPrivate(QScreen *parent, QScreen::ClassId id)
- : defaultGraphicsSystem(QWSGraphicsSystem(parent)),
- pixelFormat(QImage::Format_Invalid),
-#ifdef QT_QWS_CLIENTBLIT
- supportsBlitInClients(false),
-#endif
- classId(id), q_ptr(parent)
-{
- solidFill = qt_solidFill_setup;
- blit = qt_blit_setup;
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- fb_is_littleEndian = false;
-#endif
- pixmapFactory = 0;
- graphicsSystem = &defaultGraphicsSystem;
-}
-
-QScreenPrivate::~QScreenPrivate()
-{
-}
-
-QImage::Format QScreenPrivate::preferredImageFormat() const
-{
- if (pixelFormat > QImage::Format_Indexed8)
- return pixelFormat;
-
- if (q_ptr->depth() <= 16)
- return QImage::Format_RGB16;
- else
- return QImage::Format_ARGB32_Premultiplied;
-}
-
-/*!
- \class QScreen
- \ingroup qws
-
- \brief The QScreen class is a base class for screen drivers in
- Qt for Embedded Linux.
-
- Note that this class is only available in \l{Qt for Embedded Linux}.
-
- \l{Qt for Embedded Linux} provides ready-made drivers for several screen
- protocols, see the \l{Qt for Embedded Linux Display Management}{display
- management} documentation for details. Custom screen drivers can
- be implemented by subclassing the QScreen class and creating a
- screen driver plugin (derived from QScreenDriverPlugin). The
- default implementation of the QScreenDriverFactory class
- will automatically detect the plugin, and load the driver into the
- server application at run-time using Qt's \l {How to Create Qt
- Plugins}{plugin system}.
-
- When rendering, the default behavior is for each
- client to render its widgets as well as its decorations into
- memory, while the server copies the memory content to the device's
- framebuffer using the screen driver. See the \l{Qt for Embedded Linux
- Architecture} overview for details (note that it is possible for
- the clients to manipulate and control the underlying hardware
- directly as well).
-
- Starting with Qt 4.2, it is also possible to add an
- accelerated graphics driver to take advantage of available
- hardware resources. See the \l{Adding an Accelerated Graphics
- Driver to Qt for Embedded Linux} documentation for details.
-
- \tableofcontents
-
- \section1 Framebuffer Management
-
- When a \l{Qt for Embedded Linux} application starts running, it
- calls the screen driver's connect() function to map the
- framebuffer and the accelerated drivers that the graphics card
- control registers. The connect() function should then read out the
- parameters of the framebuffer and use them as required to set this
- class's protected variables.
-
- The initDevice() function can be reimplemented to initialize the
- graphics card. Note, however, that connect() is called \e before
- the initDevice() function, so, for some hardware configurations,
- some of the initialization that would normally be done in the
- initDevice() function might have to be done in the connect()
- function.
-
- Likewise, just before a \l{Qt for Embedded Linux} application
- exits, it calls the screen driver's disconnect() function. The
- server application will in addition call the shutdownDevice()
- function before it calls disconnect(). Note that the default
- implementation of the shutdownDevice() function only hides the
- mouse cursor.
-
- QScreen also provides the save() and restore() functions, making
- it possible to save and restore the state of the graphics
- card. Note that the default implementations do nothing. Hardware
- screen drivers should reimplement these functions to save (and
- restore) its registers, enabling switching between virtual
- consoles.
-
- In addition, you can use the base() function to retrieve a pointer
- to the beginning of the framebuffer, and the region() function to
- retrieve the framebuffer's region. Use the onCard() function to
- determine whether the framebuffer is within the graphics card's
- memory, and the totalSize() function to determine the size of the
- available graphics card memory (including the screen). Finally,
- you can use the offset() function to retrieve the offset between
- the framebuffer's coordinates and the application's coordinate
- system.
-
- \section1 Palette Management
-
- QScreen provides several functions to retrieve information about
- the color palette: The clut() function returns a pointer to the
- color lookup table (i.e. its color palette). Use the colorCount()
- function to determine the number of entries in this table, and the
- alloc() function to retrieve the palette index of the color that
- is the closest match to a given RGB value.
-
- To determine if the screen driver supports a given color depth,
- use the supportsDepth() function that returns true of the
- specified depth is supported.
-
- \section1 Drawing on Screen
-
- When a screen update is required, the \l{Qt for Embedded Linux} server runs
- through all the top-level windows that intersect with the region
- that is about to be updated, and ensures that the associated
- clients have updated their memory buffer. Then the server calls
- the exposeRegion() function that composes the window surfaces and
- copies the content of memory to screen by calling the blit() and
- solidFill() functions.
-
- The blit() function copies a given region in a given image to a
- specified point using device coordinates, while the solidFill()
- function fills the given region of the screen with the specified
- color. Note that normally there is no need to call either of these
- functions explicitly.
-
- In addition, QScreen provides the blank() function that can be
- reimplemented to prevent any contents from being displayed on the
- screen, and the setDirty() function that can be reimplemented to
- indicate that a given rectangle of the screen has been
- altered. Note that the default implementations of these functions
- do nothing.
-
- Reimplement the mapFromDevice() and mapToDevice() functions to
- map objects from the framebuffer coordinate system to the
- coordinate space used by the application, and vice versa. Be aware
- that the default implementations simply return the given objects
- as they are.
-
- \section1 Properties
-
- \table
- \header \o Property \o Functions
- \row
- \o Size
- \o
-
- The size of the screen can be retrieved using the screenSize()
- function. The size is returned in bytes.
-
- The framebuffer's logical width and height can be retrieved using
- width() and height(), respectively. These functions return values
- are given in pixels. Alternatively, the physicalWidth() and
- physicalHeight() function returns the same metrics in
- millimeters. QScreen also provides the deviceWidth() and
- deviceHeight() functions returning the physical width and height
- of the device in pixels. Note that the latter metrics can differ
- from the ones used if the display is centered within the
- framebuffer.
-
- \row
- \o Resolution
- \o
-
- Reimplement the setMode() function to be able to set the
- framebuffer to a new resolution (width and height) and bit depth.
-
- The current depth of the framebuffer can be always be retrieved
- using the depth() function. Use the pixmapDepth() function to
- obtain the preferred depth for pixmaps.
-
- \row
- \o Pixmap Alignment
- \o
-
- Use the pixmapOffsetAlignment() function to retrieve the value to
- which the start address of pixmaps held in the graphics card's
- memory, should be aligned.
-
- Use the pixmapLinestepAlignment() to retrieve the value to which
- the \e {individual scanlines} of pixmaps should be aligned.
-
- \row
- \o Image Display
- \o
-
- The isInterlaced() function tells whether the screen is displaying
- images progressively, and the isTransformed() function whether it
- is rotated. The transformOrientation() function can be
- reimplemented to return the current rotation.
-
- \row
- \o Scanlines
- \o
-
- Use the linestep() function to retrieve the length of each
- scanline of the framebuffer.
-
- \row
- \o Pixel Type
- \o
-
- The pixelType() function returns the screen's pixel storage format as
- described by the PixelType enum.
-
- \endtable
-
- \section1 Subclassing and Initial Values
-
- You need to set the following members when implementing a subclass of QScreen:
-
- \table
- \header \o Member \o Initial Value
- \row \o \l{QScreen::}{data} \o A pointer to the framebuffer if possible;
- 0 otherwise.
- \row \o \l{QScreen::}{lstep} \o The number of bytes between each scanline
- in the framebuffer.
- \row \o \l{QScreen::}{w} \o The logical screen width in pixels.
- \row \o \l{QScreen::}{h} \o The logical screen height in pixels.
- \row \o \l{QScreen::}{dw} \o The real screen width in pixels.
- \row \o \l{QScreen::}{dh} \o The real screen height in pixels.
- \row \o \l{QScreen::}{d} \o The number of bits per pixel.
- \row \o \l{QScreen::}{physWidth} \o The screen width in millimeters.
- \row \o \l{QScreen::}{physHeight} \o The screen height in millimeters.
- \endtable
-
- The logical screen values are the same as the real screen values unless the
- screen is transformed in some way; e.g., rotated.
-
- See also the \l{Accelerated Graphics Driver Example} for an example that
- shows how to initialize these values.
-
- \sa QScreenDriverPlugin, QScreenDriverFactory, {Qt for Embedded Linux Display
- Management}
-*/
-
-/*!
- \enum QScreen::PixelType
-
- This enum describes the pixel storage format of the screen,
- i.e. the order of the red (R), green (G) and blue (B) components
- of a pixel.
-
- \value NormalPixel Red-green-blue (RGB)
- \value BGRPixel Blue-green-red (BGR)
-
- \sa pixelType()
-*/
-
-/*!
- \enum QScreen::ClassId
-
- This enum defines the class identifiers for the known screen subclasses.
-
- \value LinuxFBClass QLinuxFBScreen
- \value TransformedClass QTransformedScreen
- \value VNCClass QVNCScreen
- \value MultiClass QMultiScreen
- \value VFbClass QVFbScreen
- \value DirectFBClass QDirectFBScreen
- \value SvgalibClass QSvgalibScreen
- \value ProxyClass QProxyScreen
- \value GLClass QGLScreen
- \value CustomClass Unknown QScreen subclass
-
- \sa classId()
-*/
-
-/*!
- \variable QScreen::screenclut
- \brief the color table
-
- Initialize this variable in a subclass using a paletted screen mode,
- and initialize its partner, QScreen::screencols.
-
- \sa screencols
-*/
-
-/*!
- \variable QScreen::screencols
- \brief the number of entries in the color table
-
- Initialize this variable in a subclass using a paletted screen mode,
- and initialize its partner, QScreen::screenclut.
-
- \sa screenclut
-*/
-
-/*!
- \variable QScreen::data
- \brief points to the first visible pixel in the frame buffer.
-
- You must initialize this variable if you are using the default
- implementation of non-buffered painting Qt::WA_PaintOnScreen,
- QPixmap::grabWindow() or QDirectPainter::frameBuffer(). If you
- initialize this variable, you must also initialize QScreen::size and
- QScreen::mapsize.
-
- \sa QScreen::size, QScreen::mapsize
-*/
-
-/*!
- \variable QScreen::w
- \brief the logical width of the screen.
-
- This variable \e{must} be initialized by a subclass.
-*/
-
-/*!
- \variable QScreen::lstep
- \brief the number of bytes representing a line in the frame buffer.
-
- i.e., \e{line step}. \c {data[lstep * 2]} is the address of the
- first visible pixel in the third line of the frame buffer.
-
- \sa data
-*/
-
-/*!
- \variable QScreen::h
- \brief the logical height of the screen.
-
- This variable \e{must} be initialized by a subclass.
-*/
-
-/*!
- \variable QScreen::d
- \brief the pixel depth
-
- This is the number of significant bits used to set a pixel
- color. This variable \e{must} be initialized by a subclass.
-*/
-
-/*!
- \variable QScreen::pixeltype
- \brief set to BGRPixel
-
- Set this variable to BGRPixel in a subclass, if the screen pixel
- format is a BGR type and you have used setPixelFormat() to set the
- pixel format to the corresponding RGB format. e.g., you have set the
- pixel format to QImage::Format_RGB555, but your screen really uses
- BGR, not RGB.
-*/
-
-/*!
- \variable QScreen::grayscale
- \brief the gray scale screen mode flag
-
- Set this variable to true in a subclass, if you are using a
- grayscale screen mode. e.g., in an 8-bit mode where you don't want
- to use the palette, but you want to use the grayscales.
-*/
-
-/*!
- \variable QScreen::dw
- \brief the device width
-
- This is the number of pixels in a row of the physical screen. It
- \e{must} be initialized by a subclass. Normally, it should be set to
- the logical width QScreen::w, but it might be different, e.g., if
- you are doing rotations in software.
-
- \sa QScreen::w
-*/
-
-/*!
- \variable QScreen::dh
- \brief the device height
-
- This is the number of pixels in a column of the physical screen. It
- \e{must} be initialized by a subclass. Normally, it should be set to
- the logical height QScreen::h, but it might be different, e.g., if
- you are doing rotations in software.
-
- \sa QScreen::h
-*/
-
-/*!
- \variable QScreen::size
- \brief the number of bytes in the visible region of the frame buffer
-
- This is the number of bytes in the visible part of the block pointed
- to by the QScreen::data pointer. You must initialize this variable
- if you initialize the QScreen::data pointer.
-
- \sa QScreen::data, QScreen::mapsize
-*/
-
-/*!
- \variable QScreen::mapsize
- \brief the total number of bytes in the frame buffer
-
- This is the total number of bytes in the block pointed to by the
- QScreen::data pointer. You must initialize this variable if you
- initialize the QScreen::data pointer.
-
- \sa QScreen::data, QScreen::size
-*/
-
-/*!
- \variable QScreen::physWidth
- \brief the physical width of the screen in millimeters.
-
- Currently, this variable is used when calculating the screen DPI,
- which in turn is used when deciding the actual font size Qt is
- using.
-*/
-
-/*!
- \variable QScreen::physHeight
- \brief the physical height of the screen in millimeters.
-
- Currently, this variable is used when calculating the screen DPI,
- which in turn is used when deciding the actual font size Qt is
- using.
-*/
-
-/*!
- \fn static QScreen* QScreen::instance()
-
- Returns a pointer to the application's QScreen instance.
-
- If this screen consists of several subscreens, operations to the
- returned instance will affect all its subscreens. Use the
- subscreens() function to retrieve access to a particular
- subscreen.
-
- \sa subScreens(), subScreenIndexAt()
-*/
-
-/*!
- \fn QList<QScreen*> QScreen::subScreens() const
- \since 4.2
-
- Returns a list of this screen's subscreens. Use the
- subScreenIndexAt() function to retrieve the index of a screen at a
- given position.
-
- Note that if \e this screen consists of several subscreens,
- operations to \e this instance will affect all subscreens by
- default.
-
- \sa instance(), subScreenIndexAt()
-*/
-
-/*!
- \fn int QScreen::physicalWidth() const
- \since 4.2
-
- Returns the physical width of the screen in millimeters.
-
- \sa width(), deviceWidth(), physicalHeight()
-*/
-
-/*!
- \fn int QScreen::physicalHeight() const
- \since 4.2
-
- Returns the physical height of the screen in millimeters.
-
- \sa height(), deviceHeight(), physicalWidth()
-*/
-
-/*!
- \fn virtual bool QScreen::initDevice() = 0
-
- This function is called by the \l{Qt for Embedded Linux} server to
- initialize the framebuffer. Note that a server application will call the
- connect() function prior to this function.
-
- Implement this function to make accelerated drivers set up the
- graphics card. Return true to indicate success and false to indicate
- failure.
-
- \sa shutdownDevice(), connect()
-*/
-
-/*!
- \fn virtual bool QScreen::connect(const QString &displaySpec) = 0
-
- This function is called by every \l{Qt for Embedded Linux}
- application on startup, and must be implemented to map in the
- framebuffer and the accelerated drivers that the graphics card
- control registers. Note that connect must be called \e before
- the initDevice() function.
-
- Ensure that true is returned if a connection to the screen device
- is made. Otherwise, return false. Upon making the connection, the
- function should read out the parameters of the framebuffer and use
- them as required to set this class's protected variables.
-
- The \a displaySpec argument is passed by the QWS_DISPLAY
- environment variable or the -display command line parameter, and
- has the following syntax:
-
- \snippet doc/src/snippets/code/src_gui_embedded_qscreen_qws.cpp 0
-
- For example, to use the mach64 driver on fb1 as display 2:
-
- \snippet doc/src/snippets/code/src_gui_embedded_qscreen_qws.cpp 1
-
- See \l{Qt for Embedded Linux Display Management} for more details.
-
- \sa disconnect(), initDevice(), {Running Qt for Embedded Linux Applications}
-*/
-
-/*!
- \fn QScreen::disconnect()
-
- This function is called by every \l{Qt for Embedded Linux} application
- before exiting, and must be implemented to unmap the
- framebuffer. Note that a server application will call the
- shutdownDevice() function prior to this function.
-
- \sa connect(), shutdownDevice(), {Running Qt for Embedded Linux
- Applications}
-*/
-
-/*!
- \fn QScreen::setMode(int width, int height, int depth)
-
- Implement this function to reset the framebuffer's resolution (\a
- width and \a height) and bit \a depth.
-
- After the resolution has been set, existing paint engines will be
- invalid and the framebuffer should be completely redrawn. In a
- multiple-process situation, all other applications must be
- notified to reset their mode and update themselves accordingly.
-*/
-
-/*!
- \fn QScreen::blank(bool on)
-
- Prevents the screen driver form displaying any content on the
- screen.
-
- Note that the default implementation does nothing.
-
- Reimplement this function to prevent the screen driver from
- displaying any contents on the screen if \a on is true; otherwise
- the contents is expected to be shown.
-
- \sa blit()
-*/
-
-/*!
- \fn int QScreen::pixmapOffsetAlignment()
-
- Returns the value (in bits) to which the start address of pixmaps
- held in the graphics card's memory, should be aligned.
-
- Note that the default implementation returns 64; reimplement this
- function to override the return value, e.g., when implementing an
- accelerated driver (see the \l {Adding an Accelerated Graphics
- Driver to Qt for Embedded Linux}{Adding an Accelerated Graphics Driver}
- documentation for details).
-
- \sa pixmapLinestepAlignment()
-*/
-
-/*!
- \fn int QScreen::pixmapLinestepAlignment()
-
- Returns the value (in bits) to which individual scanlines of
- pixmaps held in the graphics card's memory, should be
- aligned.
-
- Note that the default implementation returns 64; reimplement this
- function to override the return value, e.g., when implementing an
- accelerated driver (see the \l {Adding an Accelerated Graphics
- Driver to Qt for Embedded Linux}{Adding an Accelerated Graphics Driver}
- documentation for details).
-
- \sa pixmapOffsetAlignment()
-*/
-
-/*!
- \fn QScreen::width() const
-
- Returns the logical width of the framebuffer in pixels.
-
- \sa deviceWidth(), physicalWidth(), height()
-*/
-
-/*!
- \fn int QScreen::height() const
-
- Returns the logical height of the framebuffer in pixels.
-
- \sa deviceHeight(), physicalHeight(), width()
-*/
-
-/*!
- \fn QScreen::depth() const
-
- Returns the depth of the framebuffer, in bits per pixel.
-
- Note that the returned depth is the number of bits each pixel
- fills rather than the number of significant bits, so 24bpp and
- 32bpp express the same range of colors (8 bits of red, green and
- blue).
-
- \sa clut(), pixmapDepth()
-*/
-
-/*!
- \fn int QScreen::pixmapDepth() const
-
- Returns the preferred depth for pixmaps, in bits per pixel.
-
- \sa depth()
-*/
-
-/*!
- \fn QScreen::linestep() const
-
- Returns the length of each scanline of the framebuffer in bytes.
-
- \sa isInterlaced()
-*/
-
-/*!
- \fn QScreen::deviceWidth() const
-
- Returns the physical width of the framebuffer device in pixels.
-
- Note that the returned width can differ from the width which
- \l{Qt for Embedded Linux} will actually use, that is if the display is
- centered within the framebuffer.
-
- \sa width(), physicalWidth(), deviceHeight()
-*/
-
-/*!
- \fn QScreen::deviceHeight() const
-
- Returns the full height of the framebuffer device in pixels.
-
- Note that the returned height can differ from the height which
- \l{Qt for Embedded Linux} will actually use, that is if the display is
- centered within the framebuffer.
-
- \sa height(), physicalHeight(), deviceWidth()
-*/
-
-/*!
- \fn uchar *QScreen::base() const
-
- Returns a pointer to the beginning of the framebuffer.
-
- \sa onCard(), region(), totalSize()
-*/
-
-/*!
- \fn uchar *QScreen::cache(int)
-
- \internal
-
- This function is used to store pixmaps in graphics memory for the
- use of the accelerated drivers. See QLinuxFbScreen (where the
- caching is implemented) for more information.
-*/
-
-/*!
- \fn QScreen::uncache(uchar *)
-
- \internal
-
- This function is called on pixmap destruction to remove them from
- graphics card memory.
-*/
-
-/*!
- \fn QScreen::screenSize() const
-
- Returns the size of the screen in bytes.
-
- The screen size is always located at the beginning of framebuffer
- memory, i.e. it can also be retrieved using the base() function.
-
- \sa base(), region()
-*/
-
-/*!
- \fn QScreen::totalSize() const
-
- Returns the size of the available graphics card memory (including
- the screen) in bytes.
-
- \sa onCard()
-*/
-
-// Unaccelerated screen/driver setup. Can be overridden by accelerated
-// drivers
-
-/*!
- \fn QScreen::QScreen(int displayId)
-
- Constructs a new screen driver.
-
- The \a displayId identifies the \l{Qt for Embedded Linux} server to connect
- to.
-*/
-
-/*!
- \fn QScreen::clut()
-
- Returns a pointer to the screen's color lookup table (i.e. its
- color palette).
-
- Note that this function only apply in paletted modes like 8-bit,
- i.e. in modes where only the palette indexes (and not the actual
- color values) are stored in memory.
-
- \sa alloc(), depth(), colorCount()
-*/
-
-/*!
- \obsolete
- \fn int QScreen::numCols()
-
- \sa colorCount()
-*/
-
-/*!
- \since 4.6
- \fn int QScreen::colorCount()
-
- Returns the number of entries in the screen's color lookup table
- (i.e. its color palette). A pointer to the color table can be
- retrieved using the clut() function.
-
- \sa clut(), alloc()
-*/
-
-/*!
- \since 4.4
-
- Constructs a new screen driver.
-
- The \a display_id identifies the \l{Qt for Embedded Linux}
- server to connect to. The \a classId specifies the class
- identifier.
-*/
-QScreen::QScreen(int display_id, ClassId classId)
- : screencols(0), data(0), entries(0), entryp(0), lowest(0),
- w(0), lstep(0), h(0), d(1), pixeltype(NormalPixel), grayscale(false),
- dw(0), dh(0), size(0), mapsize(0), displayId(display_id),
- physWidth(0), physHeight(0), d_ptr(new QScreenPrivate(this, classId))
-{
- clearCacheFunc = 0;
-}
-
-QScreen::QScreen(int display_id)
- : screencols(0), data(0), entries(0), entryp(0), lowest(0),
- w(0), lstep(0), h(0), d(1), pixeltype(NormalPixel), grayscale(false),
- dw(0), dh(0), size(0), mapsize(0), displayId(display_id),
- physWidth(0), physHeight(0), d_ptr(new QScreenPrivate(this))
-{
- clearCacheFunc = 0;
-}
-
-/*!
- Destroys this screen driver.
-*/
-
-QScreen::~QScreen()
-{
- delete d_ptr;
-}
-
-/*!
- This function is called by the \l{Qt for Embedded Linux} server before it
- calls the disconnect() function when exiting.
-
- Note that the default implementation only hides the mouse cursor;
- reimplement this function to do the necessary graphics card
- specific cleanup.
-
- \sa initDevice(), disconnect()
-*/
-
-void QScreen::shutdownDevice()
-{
-#ifndef QT_NO_QWS_CURSOR
- if (qt_screencursor)
- qt_screencursor->hide();
-#endif
-}
-
-extern bool qws_accel; //in qapplication_qws.cpp
-
-/*!
- \fn PixelType QScreen::pixelType() const
-
- Returns the pixel storage format of the screen.
-*/
-
-/*!
- Returns the pixel format of the screen, or \c QImage::Format_Invalid
- if the pixel format is not a supported image format.
-
-*/
-QImage::Format QScreen::pixelFormat() const
-{
- return d_ptr->pixelFormat;
-}
-
-/*!
- Sets the screen's pixel format to \a format.
- */
-void QScreen::setPixelFormat(QImage::Format format)
-{
- d_ptr->pixelFormat = format;
-}
-
-
-/*!
- \fn int QScreen::alloc(unsigned int red, unsigned int green, unsigned int blue)
-
- Returns the index in the screen's palette which is the closest
- match to the given RGB value (\a red, \a green, \a blue).
-
- Note that this function only apply in paletted modes like 8-bit,
- i.e. in modes where only the palette indexes (and not the actual
- color values) are stored in memory.
-
- \sa clut(), colorCount()
-*/
-
-int QScreen::alloc(unsigned int r,unsigned int g,unsigned int b)
-{
- int ret = 0;
- if (d == 8) {
- if (grayscale)
- return qGray(r, g, b);
-
- // First we look to see if we match a default color
- const int pos = (r + 25) / 51 * 36 + (g + 25) / 51 * 6 + (b + 25) / 51;
- if (pos < screencols && screenclut[pos] == qRgb(r, g, b)) {
- return pos;
- }
-
- // search for nearest color
- unsigned int mindiff = 0xffffffff;
- unsigned int diff;
- int dr,dg,db;
-
- for (int loopc = 0; loopc < screencols; ++loopc) {
- dr = qRed(screenclut[loopc]) - r;
- dg = qGreen(screenclut[loopc]) - g;
- db = qBlue(screenclut[loopc]) - b;
- diff = dr*dr + dg*dg + db*db;
-
- if (diff < mindiff) {
- ret = loopc;
- if (!diff)
- break;
- mindiff = diff;
- }
- }
- } else if (d == 4) {
- ret = qGray(r, g, b) >> 4;
- } else if (d == 1) {
- ret = qGray(r, g, b) >= 128;
- } else {
- qFatal("cannot alloc %dbpp color", d);
- }
-
- return ret;
-}
-
-/*!
- Saves the current state of the graphics card.
-
- For example, hardware screen drivers should reimplement the save()
- and restore() functions to save and restore its registers,
- enabling swintching between virtual consoles.
-
- Note that the default implementation does nothing.
-
- \sa restore()
-*/
-
-void QScreen::save()
-{
-}
-
-/*!
- Restores the previously saved state of the graphics card.
-
- For example, hardware screen drivers should reimplement the save()
- and restore() functions to save and restore its registers,
- enabling swintching between virtual consoles.
-
- Note that the default implementation does nothing.
-
- \sa save()
-*/
-
-void QScreen::restore()
-{
-}
-
-void QScreen::blank(bool)
-{
-}
-
-/*!
- \internal
-*/
-
-void QScreen::set(unsigned int, unsigned int, unsigned int, unsigned int)
-{
-}
-
-/*!
- \fn bool QScreen::supportsDepth(int depth) const
-
- Returns true if the screen supports the specified color \a depth;
- otherwise returns false.
-
- \sa clut()
-*/
-
-bool QScreen::supportsDepth(int d) const
-{
- if (false) {
- //Just to simplify the ifdeffery
-#ifdef QT_QWS_DEPTH_1
- } else if(d==1) {
- return true;
-#endif
-#ifdef QT_QWS_DEPTH_4
- } else if(d==4) {
- return true;
-#endif
-#ifdef QT_QWS_DEPTH_8
- } else if(d==8) {
- return true;
-#endif
-#ifdef QT_QWS_DEPTH_16
- } else if(d==16) {
- return true;
-#endif
-#ifdef QT_QWS_DEPTH_15
- } else if (d == 15) {
- return true;
-#endif
-#ifdef QT_QWS_DEPTH_18
- } else if(d==18 || d==19) {
- return true;
-#endif
-#ifdef QT_QWS_DEPTH_24
- } else if(d==24) {
- return true;
-#endif
-#ifdef QT_QWS_DEPTH_32
- } else if(d==32) {
- return true;
-#endif
- }
- return false;
-}
-
-/*!
- \fn bool QScreen::onCard(const unsigned char *buffer) const
-
- Returns true if the specified \a buffer is within the graphics
- card's memory; otherwise returns false (i.e. if it's in main RAM).
-
- \sa base(), totalSize()
-*/
-
-bool QScreen::onCard(const unsigned char * p) const
-{
- long t=(unsigned long)p;
- long bmin=(unsigned long)data;
- if (t < bmin)
- return false;
- if(t >= bmin+mapsize)
- return false;
- return true;
-}
-
-/*!
- \fn bool QScreen::onCard(const unsigned char * buffer, ulong& offset) const
- \overload
-
- If the specified \a buffer is within the graphics card's memory,
- this function stores the offset from the start of graphics card
- memory (in bytes), in the location specified by the \a offset
- parameter.
-*/
-
-bool QScreen::onCard(const unsigned char * p, ulong& offset) const
-{
- long t=(unsigned long)p;
- long bmin=(unsigned long)data;
- if (t < bmin)
- return false;
- long o = t - bmin;
- if (o >= mapsize)
- return false;
- offset = o;
- return true;
-}
-
-/*
-#if !defined(QT_NO_QWS_REPEATER)
- { "Repeater", qt_get_screen_repeater, 0 },
-#endif
-#if defined(QT_QWS_EE)
- { "EE", qt_get_screen_ee, 0 },
-#endif
-
-*/
-
-/*
-Given a display_id (number of the \l{Qt for Embedded Linux} server to connect to)
-and a spec (e.g. Mach64:/dev/fb0) return a QScreen-descendant.
-The QScreenDriverFactory is queried for a suitable driver and, if found,
-asked to create a driver.
-People writing new graphics drivers should either hook their own
-QScreen-descendant into QScreenDriverFactory or use the QScreenDriverPlugin
-to make a dynamically loadable driver.
-*/
-
-Q_GUI_EXPORT QScreen* qt_get_screen(int display_id, const char *spec)
-{
- QString displaySpec = QString::fromAscii(spec);
- QString driver = displaySpec;
- int colon = displaySpec.indexOf(QLatin1Char(':'));
- if (colon >= 0)
- driver.truncate(colon);
- driver = driver.trimmed();
-
- bool foundDriver = false;
- QString driverName = driver;
-
- QStringList driverList;
- if (!driver.isEmpty())
- driverList << driver;
- else
- driverList = QScreenDriverFactory::keys();
-
- for (int i = 0; i < driverList.size(); ++i) {
- const QString driverName = driverList.at(i);
- qt_screen = QScreenDriverFactory::create(driverName, display_id);
- if (qt_screen) {
- foundDriver = true;
- if (qt_screen->connect(displaySpec)) {
- return qt_screen;
- } else {
- delete qt_screen;
- qt_screen = 0;
- }
- }
- }
-
- if (driver.isNull())
- qFatal("No suitable driver found");
- else if (foundDriver)
- qFatal("%s: driver cannot connect", driver.toLatin1().constData());
- else
- qFatal("%s: driver not found", driver.toLatin1().constData());
-
- return 0;
-}
-
-#ifndef QT_NO_QWS_CURSOR
-static void blendCursor(QImage *dest, const QImage &cursor, const QPoint &offset)
-{
- QRasterBuffer rb;
- rb.prepare(dest);
-
- QSpanData spanData;
- spanData.init(&rb, 0);
- spanData.type = QSpanData::Texture;
- spanData.initTexture(&cursor, 256);
- spanData.dx = -offset.x();
- spanData.dy = -offset.y();
- if (!spanData.blend)
- return;
-
- const QRect rect = QRect(offset, cursor.size())
- & QRect(QPoint(0, 0), dest->size());
- const int w = rect.width();
- const int h = rect.height();
-
- QVarLengthArray<QT_FT_Span, 32> spans(h);
- for (int i = 0; i < h; ++i) {
- spans[i].x = rect.x();
- spans[i].len = w;
- spans[i].y = rect.y() + i;
- spans[i].coverage = 255;
- }
- spanData.blend(h, spans.constData(), &spanData);
-}
-#endif // QT_NO_QWS_CURSOR
-
-/*!
- \fn void QScreen::exposeRegion(QRegion region, int windowIndex)
-
- This function is called by the \l{Qt for Embedded Linux} server whenever a
- screen update is required. \a region is the area on the screen
- that must be updated, and \a windowIndex is the index into
- QWSServer::clientWindows() of the window that required the
- update. QWSWindow::state() gives more information about the cause.
-
- The default implementation composes the
- affected windows and paints the given \a region on screen by
- calling the blit() and solidFill() functions
-
- This function can be reimplemented to perform composition in
- hardware, or to perform transition effects.
- For simpler hardware acceleration, or to interface with
- this is typically done by reimplementing the blit() and
- solidFill() functions instead.
-
- Note that there is no need to call this function explicitly.
-
- \sa blit(), solidFill(), blank()
-*/
-void QScreen::exposeRegion(QRegion r, int windowIndex)
-{
- r &= region();
- if (r.isEmpty())
- return;
-
- int changing = windowIndex;
- // when we have just lowered a window, we have to expose all the windows below where the
- // window used to be.
- if (changing && qwsServer->clientWindows().at(changing)->state() == QWSWindow::Lowering)
- changing = 0;
-#ifdef QTOPIA_PERFTEST
- static enum { PerfTestUnknown, PerfTestOn, PerfTestOff } perfTestState = PerfTestUnknown;
- if(PerfTestUnknown == perfTestState) {
- if(::getenv("QTOPIA_PERFTEST"))
- perfTestState = PerfTestOn;
- else
- perfTestState = PerfTestOff;
- }
- if(PerfTestOn == perfTestState) {
- QWSWindow *changed = qwsServer->clientWindows().at(changing);
- if(!changed->client()->identity().isEmpty())
- qDebug() << "Performance : expose_region :"
- << changed->client()->identity()
- << r.boundingRect() << ": "
- << qPrintable( QTime::currentTime().toString( "h:mm:ss.zzz" ) );
- }
-#endif
-
- const QRect bounds = r.boundingRect();
- QRegion blendRegion;
- QImage *blendBuffer = 0;
-
-#ifndef QT_NO_QWS_CURSOR
- if (qt_screencursor && !qt_screencursor->isAccelerated()) {
- blendRegion = r & qt_screencursor->boundingRect();
- }
-#endif
- compose(0, r, blendRegion, &blendBuffer, changing);
-
- if (blendBuffer && !blendBuffer->isNull()) {
- const QPoint offset = blendRegion.boundingRect().topLeft();
-#ifndef QT_NO_QWS_CURSOR
- if (qt_screencursor && !qt_screencursor->isAccelerated()) {
- const QRect cursorRect = qt_screencursor->boundingRect();
- if (blendRegion.intersects(cursorRect)) {
- blendCursor(blendBuffer, qt_screencursor->image(),
- cursorRect.topLeft() - offset);
- }
- }
-#endif // QT_NO_QWS_CURSOR
- blit(*blendBuffer, offset, blendRegion);
- delete blendBuffer;
- }
-
- if (r.rectCount() == 1) {
- setDirty(r.boundingRect());
- } else {
- const QVector<QRect> rects = r.rects();
- for (int i = 0; i < rects.size(); ++i)
- setDirty(rects.at(i));
- }
-}
-
-/*!
- \fn void QScreen::blit(const QImage &image, const QPoint &topLeft, const QRegion &region)
-
- Copies the given \a region in the given \a image to the point
- specified by \a topLeft using device coordinates.
-
- This function is called from the exposeRegion() function; it is
- not intended to be called explicitly.
-
- Reimplement this function to make use of \l{Adding an Accelerated
- Graphics Driver to Qt for Embedded Linux}{accelerated hardware}. Note that
- this function must be reimplemented if the framebuffer format is
- not supported by \l{Qt for Embedded Linux} (See the
- \l{Qt for Embedded Linux Display Management}{Display Management}
- documentation for more details).
-
- \sa exposeRegion(), solidFill(), blank()
-*/
-void QScreen::blit(const QImage &img, const QPoint &topLeft, const QRegion &reg)
-{
- const QRect bound = (region() & QRect(topLeft, img.size())).boundingRect();
- QWSDisplay::grab();
- d_ptr->blit(this, img, topLeft - offset(),
- (reg & bound).translated(-topLeft));
- QWSDisplay::ungrab();
-}
-
-#ifdef QT_QWS_CLIENTBLIT
-/*!
- Returns true if this screen driver supports calling QScreen::blit() and
- QScreen::setDirty() directly from non-server applications, otherwise returns
- false.
-
- If available, this is used to optimize the performance of non-occluded, opaque
- client windows by removing the server round trip when they are updated.
-
- \sa setSupportsBlitInClients()
- */
-bool QScreen::supportsBlitInClients() const
-{
- return d_ptr->supportsBlitInClients;
-}
-
-/*!
- If \a supported, the screen driver is marked as supporting blitting directly
- from non-server applications.
-
- \sa supportsBlitInClients()
- */
-void QScreen::setSupportsBlitInClients(bool supported)
-{
- d_ptr->supportsBlitInClients = supported;
-}
-#endif
-
-/*!
- \internal
-*/
-
-void QScreen::blit(QWSWindow *win, const QRegion &clip)
-{
- QWSWindowSurface *surface = win->windowSurface();
- if (!surface)
- return;
-
- const QImage &img = surface->image();
- if (img.isNull())
- return;
-
- const QRegion rgn = clip & win->paintedRegion();
- if (rgn.isEmpty())
- return;
-
- surface->lock();
- blit(img, win->requestedRegion().boundingRect().topLeft(), rgn);
- surface->unlock();
-}
-
-struct fill_data {
- quint32 color;
- uchar *data;
- int lineStep;
- int x;
- int y;
- int w;
- int h;
-};
-
-/*!
- Fills the given \a region of the screen with the specified \a
- color.
-
- This function is called from the exposeRegion() function; it is
- not intended to be called explicitly.
-
- Reimplement this function to make use of \l{Adding an Accelerated
- Graphics Driver to Qt for Embedded Linux}{accelerated hardware}. Note that
- this function must be reimplemented if the framebuffer format is
- not supported by \l{Qt for Embedded Linux} (See the
- \l{Qt for Embedded Linux Display Management}{Display Management}
- documentation for more details).
-
- \sa exposeRegion(), blit(), blank()
-*/
-// the base class implementation works in device coordinates, so that transformed drivers can use it
-void QScreen::solidFill(const QColor &color, const QRegion &region)
-{
- QWSDisplay::grab();
- d_ptr->solidFill(this, color,
- region.translated(-offset()) & QRect(0, 0, dw, dh));
- QWSDisplay::ungrab();
-}
-
-/*!
- \since 4.2
-
- Creates and returns a new window surface matching the given \a
- key.
-
- The server application will call this function whenever it needs
- to create a server side representation of a window, e.g. when
- copying the content of memory to the screen using the screen
- driver.
-
- Note that this function must be reimplemented when adding an
- accelerated graphics driver. See the
- \l{Adding an Accelerated Graphics Driver to Qt for Embedded Linux}
- {Adding an Accelerated Graphics Driver} documentation for details.
-
- \sa {Qt for Embedded Linux Architecture}
-*/
-QWSWindowSurface* QScreen::createSurface(const QString &key) const
-{
-#ifndef QT_NO_PAINTONSCREEN
- if (key == QLatin1String("OnScreen"))
- return new QWSOnScreenSurface;
- else
-#endif
- if (key == QLatin1String("mem"))
- return new QWSLocalMemSurface;
-#ifndef QT_NO_QWS_MULTIPROCESS
- else if (key == QLatin1String("shm"))
- return new QWSSharedMemSurface;
-#endif
-#ifndef QT_NO_PAINT_DEBUG
- else if (key == QLatin1String("Yellow"))
- return new QWSYellowSurface;
-#endif
-#ifndef QT_NO_DIRECTPAINTER
- else if (key == QLatin1String("DirectPainter"))
- return new QWSDirectPainterSurface;
-#endif
-
- return 0;
-}
-
-#ifndef QT_NO_PAINTONSCREEN
-bool QScreen::isWidgetPaintOnScreen(const QWidget *w)
-{
- static int doOnScreen = -1;
- if (doOnScreen == -1) {
- const QByteArray env = qgetenv("QT_ONSCREEN_PAINT");
- if (env == "force")
- doOnScreen = 2;
- else
- doOnScreen = (env.toInt() > 0 ? 1 : 0);
- }
-
- if (doOnScreen == 2) // force
- return true;
-
- if (doOnScreen == 0 && !w->testAttribute(Qt::WA_PaintOnScreen))
- return false;
-
- return w->d_func()->isOpaque;
-}
-#endif
-
-/*!
- \overload
-
- Creates and returns a new window surface for the given \a widget.
-*/
-QWSWindowSurface* QScreen::createSurface(QWidget *widget) const
-{
-#ifndef QT_NO_PAINTONSCREEN
- if (isWidgetPaintOnScreen(widget) && base())
- return new QWSOnScreenSurface(widget);
- else
-#endif
- if (QApplication::type() == QApplication::GuiServer)
- return new QWSLocalMemSurface(widget);
-#ifndef QT_NO_QWS_MULTIPROCESS
- else
- return new QWSSharedMemSurface(widget);
-#endif
-
- return 0;
-}
-
-void QScreen::compose(int level, const QRegion &exposed, QRegion &blend,
- QImage **blendbuffer, int changing_level)
-{
- QRect exposed_bounds = exposed.boundingRect();
- QWSWindow *win = 0;
- do {
- win = qwsServer->clientWindows().value(level); // null is background
- ++level;
- } while (win && !win->paintedRegion().boundingRect().intersects(exposed_bounds));
-
- QWSWindowSurface *surface = (win ? win->windowSurface() : 0);
- bool above_changing = level <= changing_level; // 0 is topmost
-
- QRegion exposedBelow = exposed;
- bool opaque = true;
-
- if (win) {
- opaque = win->isOpaque() || !surface->isBuffered();
- if (opaque) {
- exposedBelow -= win->paintedRegion();
- if (above_changing || !surface->isBuffered())
- blend -= exposed & win->paintedRegion();
- } else {
- blend += exposed & win->paintedRegion();
- }
- }
- if (win && !exposedBelow.isEmpty()) {
- compose(level, exposedBelow, blend, blendbuffer, changing_level);
- } else {
- QSize blendSize = blend.boundingRect().size();
- if (!blendSize.isNull()) {
- *blendbuffer = new QImage(blendSize, d_ptr->preferredImageFormat());
- }
- }
-
- const QRegion blitRegion = exposed - blend;
- if (!win)
- paintBackground(blitRegion);
- else if (!above_changing && surface->isBuffered())
- blit(win, blitRegion);
-
- QRegion blendRegion = exposed & blend;
-
- if (win)
- blendRegion &= win->paintedRegion();
- if (!blendRegion.isEmpty()) {
-
- QPoint off = blend.boundingRect().topLeft();
-
- QRasterBuffer rb;
- rb.prepare(*blendbuffer);
- QSpanData spanData;
- spanData.init(&rb, 0);
- if (!win) {
- const QImage::Format format = (*blendbuffer)->format();
- switch (format) {
- case QImage::Format_ARGB32_Premultiplied:
- case QImage::Format_ARGB32:
- case QImage::Format_ARGB8565_Premultiplied:
- case QImage::Format_ARGB8555_Premultiplied:
- case QImage::Format_ARGB6666_Premultiplied:
- case QImage::Format_ARGB4444_Premultiplied:
- spanData.rasterBuffer->compositionMode = QPainter::CompositionMode_Source;
- break;
- default:
- break;
- }
- spanData.setup(qwsServer->backgroundBrush(), 256, QPainter::CompositionMode_Source);
- spanData.dx = off.x();
- spanData.dy = off.y();
- } else if (!surface->isBuffered()) {
- return;
- } else {
- const QImage &img = surface->image();
- QPoint winoff = off - win->requestedRegion().boundingRect().topLeft();
- // convert win->opacity() from scale [0..255] to [0..256]
- int const_alpha = win->opacity();
- const_alpha += (const_alpha >> 7);
- spanData.type = QSpanData::Texture;
- spanData.initTexture(&img, const_alpha);
- spanData.dx = winoff.x();
- spanData.dy = winoff.y();
- }
- if (!spanData.blend)
- return;
-
- if (surface)
- surface->lock();
- const QVector<QRect> rects = blendRegion.rects();
- const int nspans = 256;
- QT_FT_Span spans[nspans];
- for (int i = 0; i < rects.size(); ++i) {
- int y = rects.at(i).y() - off.y();
- int ye = y + rects.at(i).height();
- int x = rects.at(i).x() - off.x();
- int len = rects.at(i).width();
- while (y < ye) {
- int n = qMin(nspans, ye - y);
- int i = 0;
- while (i < n) {
- spans[i].x = x;
- spans[i].len = len;
- spans[i].y = y + i;
- spans[i].coverage = 255;
- ++i;
- }
- spanData.blend(n, spans, &spanData);
- y += n;
- }
- }
- if (surface)
- surface->unlock();
- }
-}
-
-void QScreen::paintBackground(const QRegion &r)
-{
- const QBrush &bg = qwsServer->backgroundBrush();
- Qt::BrushStyle bs = bg.style();
- if (bs == Qt::NoBrush || r.isEmpty())
- return;
-
- if (bs == Qt::SolidPattern) {
- solidFill(bg.color(), r);
- } else {
- const QRect br = r.boundingRect();
- QImage img(br.size(), d_ptr->preferredImageFormat());
- QPoint off = br.topLeft();
- QRasterBuffer rb;
- rb.prepare(&img);
- QSpanData spanData;
- spanData.init(&rb, 0);
- spanData.setup(bg, 256, QPainter::CompositionMode_Source);
- spanData.dx = off.x();
- spanData.dy = off.y();
- Q_ASSERT(spanData.blend);
-
- const QVector<QRect> rects = r.rects();
- const int nspans = 256;
- QT_FT_Span spans[nspans];
- for (int i = 0; i < rects.size(); ++i) {
- int y = rects.at(i).y() - off.y();
- int ye = y + rects.at(i).height();
- int x = rects.at(i).x() - off.x();
- int len = rects.at(i).width();
- while (y < ye) {
- int n = qMin(nspans, ye - y);
- int i = 0;
- while (i < n) {
- spans[i].x = x;
- spans[i].len = len;
- spans[i].y = y + i;
- spans[i].coverage = 255;
- ++i;
- }
- spanData.blend(n, spans, &spanData);
- y += n;
- }
- }
- blit(img, br.topLeft(), r);
- }
-}
-
-/*!
- \fn virtual int QScreen::sharedRamSize(void *)
-
- \internal
-*/
-
-/*!
- \fn QScreen::setDirty(const QRect& rectangle)
-
- Marks the given \a rectangle as dirty.
-
- Note that the default implementation does nothing; reimplement
- this function to indicate that the given \a rectangle has been
- altered.
-*/
-
-void QScreen::setDirty(const QRect&)
-{
-}
-
-/*!
- \fn QScreen::isTransformed() const
-
- Returns true if the screen is transformed (for instance, rotated
- 90 degrees); otherwise returns false.
-
- \sa transformOrientation(), isInterlaced()
-*/
-
-bool QScreen::isTransformed() const
-{
- return false;
-}
-
-/*!
- \fn QScreen::isInterlaced() const
-
- Returns true if the display is interlaced (i.e. is displaying
- images progressively like a television screen); otherwise returns
- false.
-
- If the display is interlaced, the drawing is altered to look
- better.
-
- \sa isTransformed(), linestep()
-*/
-
-bool QScreen::isInterlaced() const
-{
- return false;//qws_screen_is_interlaced;;
-}
-
-/*!
- \fn QScreen::mapToDevice(const QSize &size) const
-
- Maps the given \a size from the coordinate space used by the
- application to the framebuffer coordinate system. Note that the
- default implementation simply returns the given \a size as it is.
-
- Reimplement this function to use the given device's coordinate
- system when mapping.
-
- \sa mapFromDevice()
-*/
-
-QSize QScreen::mapToDevice(const QSize &s) const
-{
- return s;
-}
-
-/*!
- \fn QScreen::mapFromDevice(const QSize &size) const
-
- Maps the given \a size from the framebuffer coordinate system to
- the coordinate space used by the application. Note that the
- default implementation simply returns the given \a size as it is.
-
- Reimplement this function to use the given device's coordinate
- system when mapping.
-
- \sa mapToDevice()
-*/
-
-QSize QScreen::mapFromDevice(const QSize &s) const
-{
- return s;
-}
-
-/*!
- \fn QScreen::mapToDevice(const QPoint &point, const QSize &screenSize) const
- \overload
-
- Maps the given \a point from the coordinate space used by the
- application to the framebuffer coordinate system, passing the
- device's \a screenSize as argument. Note that the default
- implementation returns the given \a point as it is.
-*/
-
-QPoint QScreen::mapToDevice(const QPoint &p, const QSize &) const
-{
- return p;
-}
-
-/*!
- \fn QScreen::mapFromDevice(const QPoint &point, const QSize &screenSize) const
- \overload
-
- Maps the given \a point from the framebuffer coordinate system to
- the coordinate space used by the application, passing the device's
- \a screenSize as argument. Note that the default implementation
- simply returns the given \a point as it is.
-*/
-
-QPoint QScreen::mapFromDevice(const QPoint &p, const QSize &) const
-{
- return p;
-}
-
-/*!
- \fn QScreen::mapToDevice(const QRect &rectangle, const QSize &screenSize) const
- \overload
-
- Maps the given \a rectangle from the coordinate space used by the
- application to the framebuffer coordinate system, passing the
- device's \a screenSize as argument. Note that the default
- implementation returns the given \a rectangle as it is.
-*/
-
-QRect QScreen::mapToDevice(const QRect &r, const QSize &) const
-{
- return r;
-}
-
-/*!
- \fn QScreen::mapFromDevice(const QRect &rectangle, const QSize &screenSize) const
- \overload
-
- Maps the given \a rectangle from the framebuffer coordinate system to
- the coordinate space used by the application, passing the device's
- \a screenSize as argument. Note that the default implementation
- simply returns the given \a rectangle as it is.
-*/
-
-QRect QScreen::mapFromDevice(const QRect &r, const QSize &) const
-{
- return r;
-}
-
-/*!
- \fn QScreen::mapToDevice(const QImage &image) const
- \overload
-
- Maps the given \a image from the coordinate space used by the
- application to the framebuffer coordinate system. Note that the
- default implementation returns the given \a image as it is.
-*/
-
-QImage QScreen::mapToDevice(const QImage &i) const
-{
- return i;
-}
-
-/*!
- \fn QScreen::mapFromDevice(const QImage &image) const
- \overload
-
- Maps the given \a image from the framebuffer coordinate system to
- the coordinate space used by the application. Note that the
- default implementation simply returns the given \a image as it is.
-*/
-
-QImage QScreen::mapFromDevice(const QImage &i) const
-{
- return i;
-}
-
-/*!
- \fn QScreen::mapToDevice(const QRegion &region, const QSize &screenSize) const
- \overload
-
- Maps the given \a region from the coordinate space used by the
- application to the framebuffer coordinate system, passing the
- device's \a screenSize as argument. Note that the default
- implementation returns the given \a region as it is.
-*/
-
-QRegion QScreen::mapToDevice(const QRegion &r, const QSize &) const
-{
- return r;
-}
-
-/*!
- \fn QScreen::mapFromDevice(const QRegion &region, const QSize &screenSize) const
- \overload
-
- Maps the given \a region from the framebuffer coordinate system to
- the coordinate space used by the application, passing the device's
- \a screenSize as argument. Note that the default implementation
- simply returns the given \a region as it is.
-*/
-
-QRegion QScreen::mapFromDevice(const QRegion &r, const QSize &) const
-{
- return r;
-}
-
-/*!
- \fn QScreen::transformOrientation() const
-
- Returns the current rotation as an integer value.
-
- Note that the default implementation returns 0; reimplement this
- function to override this value.
-
- \sa isTransformed()
-*/
-
-int QScreen::transformOrientation() const
-{
- return 0;
-}
-
-int QScreen::pixmapDepth() const
-{
- return depth();
-}
-
-/*!
- \internal
-*/
-int QScreen::memoryNeeded(const QString&)
-{
- return 0;
-}
-
-/*!
- \internal
-*/
-void QScreen::haltUpdates()
-{
-}
-
-/*!
- \internal
-*/
-void QScreen::resumeUpdates()
-{
-}
-
-/*!
- \fn QRegion QScreen::region() const
- \since 4.2
-
- Returns the region covered by this screen driver.
-
- \sa base(), screenSize()
-*/
-
-/*!
- \internal
-*/
-void QScreen::setOffset(const QPoint &p)
-{
- d_ptr->offset = p;
-}
-
-/*!
- \since 4.2
-
- Returns the logical offset of the screen, i.e., the offset between
- (0,0) in screen coordinates and the application coordinate system.
-*/
-QPoint QScreen::offset() const
-{
- return d_ptr->offset;
-}
-
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
-void QScreen::setFrameBufferLittleEndian(bool littleEndian)
-{
- d_ptr->fb_is_littleEndian = littleEndian;
-}
-
-bool QScreen::frameBufferLittleEndian() const
-{
- return d_ptr->fb_is_littleEndian;
-}
-#endif
-
-/*!
- \fn int QScreen::subScreenIndexAt(const QPoint &position) const
- \since 4.2
-
- Returns the index of the subscreen at the given \a position;
- returns -1 if no screen is found.
-
- The index identifies the subscreen in the list of pointers
- returned by the subScreens() function.
-
- \sa instance(), subScreens()
-*/
-int QScreen::subScreenIndexAt(const QPoint &p) const
-{
- const QList<QScreen*> screens = subScreens();
- const int n = screens.count();
- for (int i = 0; i < n; ++i) {
- if (screens.at(i)->region().contains(p))
- return i;
- }
-
- return -1;
-}
-
-#if 0
-#ifdef QT_LOADABLE_MODULES
-#include <dlfcn.h>
-
-// ### needs update after driver init changes
-
-static QScreen * qt_dodriver(char * driver,char * a,unsigned char * b)
-
-{
- char buf[200];
- strcpy(buf,"/etc/qws/drivers/");
- qstrcpy(buf+17,driver);
- qDebug("Attempting driver %s",driver);
-
- void * handle;
- handle=dlopen(buf,RTLD_LAZY);
- if(handle==0) {
- qFatal("Module load error");
- }
- QScreen *(*qt_get_screen_func)(char *,unsigned char *);
- qt_get_screen_func=dlsym(handle,"qt_get_screen");
- if(qt_get_screen_func==0) {
- qFatal("Couldn't get symbol");
- }
- QScreen * ret=qt_get_screen_func(a,b);
- return ret;
-}
-
-static QScreen * qt_do_entry(char * entry)
-{
- unsigned char config[256];
-
- FILE * f=fopen(entry,"r");
- if(!f) {
- return 0;
- }
-
- int r=fread(config,256,1,f);
- if(r<1)
- return 0;
-
- fclose(f);
-
- unsigned short vendorid=*((unsigned short int *)config);
- unsigned short deviceid=*(((unsigned short int *)config)+1);
- if(config[0xb]!=3)
- return 0;
-
- if(vendorid==0x1002) {
- if(deviceid==0x4c4d) {
- qDebug("Compaq Armada/IBM Thinkpad's Mach64 card");
- return qt_dodriver("mach64.so",entry,config);
- } else if(deviceid==0x4742) {
- qDebug("Desktop Rage Pro Mach64 card");
- return qt_dodriver("mach64.so",entry,config);
- } else {
- qDebug("Unrecognised ATI card id %x",deviceid);
- return 0;
- }
- } else {
- qDebug("Unrecognised vendor");
- }
- return 0;
-}
-
-extern bool qws_accel;
-
-/// ** NOT SUPPPORTED **
-
-QScreen * qt_probe_bus()
-{
- if(!qws_accel) {
- return qt_dodriver("unaccel.so",0,0);
- }
-
- QT_DIR *dirptr = QT_OPENDIR("/proc/bus/pci");
- if(!dirptr)
- return qt_dodriver("unaccel.so",0,0);
- QT_DIR * dirptr2;
- QT_DIRENT *cards;
-
- QT_DIRENT *busses = QT_READDIR(dirptr);
-
- while(busses) {
- if(busses->d_name[0]!='.') {
- char buf[100];
- strcpy(buf,"/proc/bus/pci/");
- qstrcpy(buf+14,busses->d_name);
- int p=strlen(buf);
- dirptr2 = QT_OPENDIR(buf);
- if(dirptr2) {
- cards = QT_READDIR(dirptr2);
- while(cards) {
- if(cards->d_name[0]!='.') {
- buf[p]='/';
- qstrcpy(buf+p+1,cards->d_name);
- QScreen * ret=qt_do_entry(buf);
- if(ret)
- return ret;
- }
- cards = QT_READDIR(dirptr2);
- }
- QT_CLOSEDIR(dirptr2);
- }
- }
- busses = QT_READDIR(dirptr);
- }
- QT_CLOSEDIR(dirptr);
-
- return qt_dodriver("unaccel.so",0,0);
-}
-
-#else
-
-char *qt_qws_hardcoded_slot = "/proc/bus/pci/01/00.0";
-
-const unsigned char* qt_probe_bus()
-{
- const char * slot;
- slot=::getenv("QWS_CARD_SLOT");
- if(!slot)
- slot=qt_qws_hardcoded_slot;
- if (slot) {
- static unsigned char config[256];
- FILE * f=fopen(slot,"r");
- if(!f) {
- qDebug("Open failure for %s",slot);
- slot=0;
- } else {
- int r=fread((char*)config,256,1,f);
- fclose(f);
- if(r<1) {
- qDebug("Read failure");
- return 0;
- } else {
- return config;
- }
- }
- }
- return 0;
-}
-
-#endif
-
-#endif // 0
-
-/*!
- \internal
- \since 4.4
-*/
-void QScreen::setPixmapDataFactory(QPixmapDataFactory *factory)
-{
- static bool shownWarning = false;
- if (!shownWarning) {
- qWarning("QScreen::setPixmapDataFactory() is deprecated - use setGraphicsSystem() instead");
- shownWarning = true;
- }
-
- d_ptr->pixmapFactory = factory;
-}
-
-/*!
- \internal
- \since 4.4
-*/
-QPixmapDataFactory* QScreen::pixmapDataFactory() const
-{
- return d_ptr->pixmapFactory;
-}
-
-/*!
- \internal
- \since 4.5
-*/
-void QScreen::setGraphicsSystem(QGraphicsSystem* system)
-{
- d_ptr->graphicsSystem = system;
-}
-
-/*!
- \internal
- \since 4.5
-*/
-QGraphicsSystem* QScreen::graphicsSystem() const
-{
- return d_ptr->graphicsSystem;
-}
-
-/*!
- \since 4.4
-
- Returns the class identifier for the screen object.
-*/
-QScreen::ClassId QScreen::classId() const
-{
- return static_cast<ClassId>(d_ptr->classId);
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/embedded/qscreen_qws.h b/src/gui/embedded/qscreen_qws.h
deleted file mode 100644
index 85c775e377..0000000000
--- a/src/gui/embedded/qscreen_qws.h
+++ /dev/null
@@ -1,391 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSCREEN_QWS_H
-#define QSCREEN_QWS_H
-
-#include <QtCore/qnamespace.h>
-#include <QtCore/qpoint.h>
-#include <QtCore/qlist.h>
-#include <QtGui/qrgb.h>
-#include <QtCore/qrect.h>
-#include <QtGui/qimage.h>
-#include <QtGui/qregion.h>
-
-struct fb_cmap;
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QScreenCursor;
-class QBrush;
-class QWSWindow;
-class QWSWindowSurface;
-class QGraphicsSystem;
-class QPixmapData;
-
-#ifndef QT_QWS_DEPTH16_RGB
-#define QT_QWS_DEPTH16_RGB 565
-#endif
-static const int qt_rbits = (QT_QWS_DEPTH16_RGB/100);
-static const int qt_gbits = (QT_QWS_DEPTH16_RGB/10%10);
-static const int qt_bbits = (QT_QWS_DEPTH16_RGB%10);
-static const int qt_red_shift = qt_bbits+qt_gbits-(8-qt_rbits);
-static const int qt_green_shift = qt_bbits-(8-qt_gbits);
-static const int qt_neg_blue_shift = 8-qt_bbits;
-static const int qt_blue_mask = (1<<qt_bbits)-1;
-static const int qt_green_mask = (1<<(qt_gbits+qt_bbits))-(1<<qt_bbits);
-static const int qt_red_mask = (1<<(qt_rbits+qt_gbits+qt_bbits))-(1<<(qt_gbits+qt_bbits));
-
-static const int qt_red_rounding_shift = qt_red_shift + qt_rbits;
-static const int qt_green_rounding_shift = qt_green_shift + qt_gbits;
-static const int qt_blue_rounding_shift = qt_bbits - qt_neg_blue_shift;
-
-
-inline ushort qt_convRgbTo16(const int r, const int g, const int b)
-{
- const int tr = r << qt_red_shift;
- const int tg = g << qt_green_shift;
- const int tb = b >> qt_neg_blue_shift;
-
- return (tb & qt_blue_mask) | (tg & qt_green_mask) | (tr & qt_red_mask);
-}
-
-inline ushort qt_convRgbTo16(QRgb c)
-{
- const int tr = qRed(c) << qt_red_shift;
- const int tg = qGreen(c) << qt_green_shift;
- const int tb = qBlue(c) >> qt_neg_blue_shift;
-
- return (tb & qt_blue_mask) | (tg & qt_green_mask) | (tr & qt_red_mask);
-}
-
-inline QRgb qt_conv16ToRgb(ushort c)
-{
- const int r=(c & qt_red_mask);
- const int g=(c & qt_green_mask);
- const int b=(c & qt_blue_mask);
- const int tr = r >> qt_red_shift | r >> qt_red_rounding_shift;
- const int tg = g >> qt_green_shift | g >> qt_green_rounding_shift;
- const int tb = b << qt_neg_blue_shift | b >> qt_blue_rounding_shift;
-
- return qRgb(tr,tg,tb);
-}
-
-inline void qt_conv16ToRgb(ushort c, int& r, int& g, int& b)
-{
- const int tr=(c & qt_red_mask);
- const int tg=(c & qt_green_mask);
- const int tb=(c & qt_blue_mask);
- r = tr >> qt_red_shift | tr >> qt_red_rounding_shift;
- g = tg >> qt_green_shift | tg >> qt_green_rounding_shift;
- b = tb << qt_neg_blue_shift | tb >> qt_blue_rounding_shift;
-}
-
-const int SourceSolid=0;
-const int SourcePixmap=1;
-
-#ifndef QT_NO_QWS_CURSOR
-
-class QScreenCursor;
-extern QScreenCursor *qt_screencursor;
-extern bool qws_sw_cursor;
-
-class Q_GUI_EXPORT QScreenCursor
-{
-public:
- QScreenCursor();
- virtual ~QScreenCursor();
-
- virtual void set(const QImage &image, int hotx, int hoty);
- virtual void move(int x, int y);
- virtual void show();
- virtual void hide();
-
- bool supportsAlphaCursor() const { return supportsAlpha; }
-
- static bool enabled() { return qws_sw_cursor; }
-
- QRect boundingRect() const { return QRect(pos - hotspot, size); }
- QImage image() const { return cursor; }
- bool isVisible() const { return enable; }
- bool isAccelerated() const { return hwaccel; }
-
- static void initSoftwareCursor();
- static QScreenCursor* instance() { return qt_screencursor; }
-
-protected:
- QImage cursor;
-
- QSize size;
- QPoint pos;
- QPoint hotspot;
- uint enable : 1;
- uint hwaccel : 1;
- uint supportsAlpha : 1;
-
-private:
- friend class QProxyScreenCursor;
-};
-
-#endif // QT_NO_QWS_CURSOR
-
-// A (used) chunk of offscreen memory
-
-class QPoolEntry
-{
-public:
- unsigned int start;
- unsigned int end;
- int clientId;
-};
-
-class QScreen;
-class QScreenPrivate;
-class QPixmapDataFactory;
-
-extern Q_GUI_EXPORT QScreen *qt_screen;
-typedef void(*ClearCacheFunc)(QScreen *obj, int);
-
-class Q_GUI_EXPORT QScreen {
-
-public:
- enum ClassId { LinuxFBClass, TransformedClass, VNCClass, MultiClass,
- VFbClass, DirectFBClass, SvgalibClass, ProxyClass,
- GLClass, IntfbClass, CustomClass = 1024 };
-
- QScreen(int display_id, ClassId classId);
- explicit QScreen(int display_id);
- virtual ~QScreen();
- static QScreen* instance() { return qt_screen; }
- virtual bool initDevice() = 0;
- virtual bool connect(const QString &displaySpec) = 0;
- virtual void disconnect() = 0;
- virtual void shutdownDevice();
- virtual void setMode(int,int,int) = 0;
- virtual bool supportsDepth(int) const;
-
- virtual void save();
- virtual void restore();
- virtual void blank(bool on);
-
- virtual int pixmapOffsetAlignment() { return 64; }
- virtual int pixmapLinestepAlignment() { return 64; }
- virtual int sharedRamSize(void *) { return 0; }
-
- virtual bool onCard(const unsigned char *) const;
- virtual bool onCard(const unsigned char *, ulong& out_offset) const;
-
- enum PixelType { NormalPixel, BGRPixel };
-
- // sets a single color in the colormap
- virtual void set(unsigned int,unsigned int,unsigned int,unsigned int);
- // allocates a color
- virtual int alloc(unsigned int,unsigned int,unsigned int);
-
- int width() const { return w; }
- int height() const { return h; }
- int depth() const { return d; }
- virtual int pixmapDepth() const;
- PixelType pixelType() const { return pixeltype; }
- int linestep() const { return lstep; }
- int deviceWidth() const { return dw; }
- int deviceHeight() const { return dh; }
- uchar * base() const { return data; }
- // Ask for memory from card cache with alignment
- virtual uchar * cache(int) { return 0; }
- virtual void uncache(uchar *) {}
-
- QImage::Format pixelFormat() const;
-
- int screenSize() const { return size; }
- int totalSize() const { return mapsize; }
-
- QRgb * clut() { return screenclut; }
-#ifdef QT_DEPRECATED
- QT_DEPRECATED int numCols() { return screencols; }
-#endif
- int colorCount() { return screencols; }
-
- virtual QSize mapToDevice(const QSize &) const;
- virtual QSize mapFromDevice(const QSize &) const;
- virtual QPoint mapToDevice(const QPoint &, const QSize &) const;
- virtual QPoint mapFromDevice(const QPoint &, const QSize &) const;
- virtual QRect mapToDevice(const QRect &, const QSize &) const;
- virtual QRect mapFromDevice(const QRect &, const QSize &) const;
- virtual QImage mapToDevice(const QImage &) const;
- virtual QImage mapFromDevice(const QImage &) const;
- virtual QRegion mapToDevice(const QRegion &, const QSize &) const;
- virtual QRegion mapFromDevice(const QRegion &, const QSize &) const;
- virtual int transformOrientation() const;
- virtual bool isTransformed() const;
- virtual bool isInterlaced() const;
-
- virtual void setDirty(const QRect&);
-
- virtual int memoryNeeded(const QString&);
-
- virtual void haltUpdates();
- virtual void resumeUpdates();
-
- // composition manager methods
- virtual void exposeRegion(QRegion r, int changing);
-
- // these work directly on the screen
- virtual void blit(const QImage &img, const QPoint &topLeft, const QRegion &region);
- virtual void solidFill(const QColor &color, const QRegion &region);
- void blit(QWSWindow *bs, const QRegion &clip);
-
- virtual QWSWindowSurface* createSurface(QWidget *widget) const;
- virtual QWSWindowSurface* createSurface(const QString &key) const;
-
- virtual QList<QScreen*> subScreens() const { return QList<QScreen*>(); }
- virtual QRegion region() const { return QRect(offset(), QSize(w, h)); }
- int subScreenIndexAt(const QPoint &p) const;
-
- void setOffset(const QPoint &p);
- QPoint offset() const;
-
- int physicalWidth() const { return physWidth; } // physical display size in mm
- int physicalHeight() const { return physHeight; } // physical display size in mm
-
- QPixmapDataFactory* pixmapDataFactory() const; // Deprecated, will be removed in 4.6
- QGraphicsSystem* graphicsSystem() const;
-
-#ifdef QT_QWS_CLIENTBLIT
- bool supportsBlitInClients() const;
- void setSupportsBlitInClients(bool);
-#endif
-
- ClassId classId() const;
-
-protected:
- void setPixelFormat(QImage::Format format);
- void setPixmapDataFactory(QPixmapDataFactory *factory); // Deprecated, will be removed in 4.6
- void setGraphicsSystem(QGraphicsSystem* system);
-
- QRgb screenclut[256];
- int screencols;
-
- uchar * data;
-
- // Table of allocated lumps, kept in sorted highest-to-lowest order
- // The table itself is allocated at the bottom of offscreen memory
- // i.e. it's similar to having a stack (the table) and a heap
- // (the allocated blocks). Freed space is implicitly described
- // by the gaps between the allocated lumps (this saves entries and
- // means we don't need to worry about coalescing freed lumps)
-
- QPoolEntry * entries;
- int * entryp;
- unsigned int * lowest;
-
- int w;
- int lstep;
- int h;
- int d;
- PixelType pixeltype;
- bool grayscale;
-
- int dw;
- int dh;
-
- int size; // Screen size
- int mapsize; // Total mapped memory
-
- int displayId;
-
- int physWidth;
- int physHeight;
-
- friend class QWSServer;
- friend class QWSServerPrivate;
- static ClearCacheFunc clearCacheFunc;
-
-private:
- void compose(int level, const QRegion &exposed, QRegion &blend,
- QImage **blendbuffer, int changing_level);
- void paintBackground(const QRegion &);
-
- friend class QWSOnScreenSurface;
- static bool isWidgetPaintOnScreen(const QWidget *w);
-
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- void setFrameBufferLittleEndian(bool littleEndian);
- bool frameBufferLittleEndian() const;
- friend class QVNCScreen;
- friend class QLinuxFbScreen;
- friend class QVFbScreen;
- friend class QProxyScreen;
- friend class QIntfbScreen;
-#endif
- friend void qt_solidFill_setup(QScreen*, const QColor&, const QRegion&);
- friend void qt_blit_setup(QScreen *screen, const QImage &image,
- const QPoint &topLeft, const QRegion &region);
-#ifdef QT_QWS_DEPTH_GENERIC
- friend void qt_set_generic_blit(QScreen *screen, int bpp,
- int len_red, int len_green, int len_blue,
- int len_alpha, int off_red, int off_green,
- int off_blue, int off_alpha);
-#endif
-
- QScreenPrivate *d_ptr;
-};
-
-// This lives in loadable modules
-
-#ifndef QT_LOADABLE_MODULES
-extern "C" QScreen * qt_get_screen(int display_id, const char* spec);
-#endif
-
-// This is in main lib, loads the right module, calls qt_get_screen
-// In non-loadable cases just aliases to qt_get_screen
-
-const unsigned char * qt_probe_bus();
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSCREEN_QWS_H
diff --git a/src/gui/embedded/qscreendriverfactory_qws.cpp b/src/gui/embedded/qscreendriverfactory_qws.cpp
deleted file mode 100644
index ea194e56c5..0000000000
--- a/src/gui/embedded/qscreendriverfactory_qws.cpp
+++ /dev/null
@@ -1,204 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qscreendriverfactory_qws.h"
-
-#include "qscreen_qws.h"
-#include "qapplication.h"
-#include "qscreenlinuxfb_qws.h"
-#include "qscreentransformed_qws.h"
-#include "qscreenvfb_qws.h"
-#include "qscreenmulti_qws_p.h"
-#include "qscreenqnx_qws.h"
-#include "qscreenintegrityfb_qws.h"
-#include <stdlib.h>
-#include "private/qfactoryloader_p.h"
-#include "qscreendriverplugin_qws.h"
-#ifndef QT_NO_QWS_DIRECTFB
-#include "qdirectfbscreen.h"
-#endif
-#ifndef QT_NO_QWS_VNC
-#include "qscreenvnc_qws.h"
-#endif
-
-QT_BEGIN_NAMESPACE
-
-#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
-#ifndef QT_NO_LIBRARY
-
-Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
- (QScreenDriverFactoryInterface_iid,
- QLatin1String("/gfxdrivers"), Qt::CaseInsensitive))
-
-#endif //QT_NO_LIBRARY
-#endif //QT_MAKEDLL
-
-/*!
- \class QScreenDriverFactory
- \ingroup qws
-
- \brief The QScreenDriverFactory class creates screen drivers in
- Qt for Embedded Linux.
-
- Note that this class is only available in \l{Qt for Embedded Linux}.
-
- QScreenDriverFactory is used to detect and instantiate the
- available screen drivers, allowing \l{Qt for Embedded Linux} to load the
- preferred driver into the server application at runtime. The
- create() function returns a QScreen object representing the screen
- driver identified by a given key. The valid keys (i.e. the
- supported drivers) can be retrieved using the keys() function.
-
-
- \l{Qt for Embedded Linux} provides several built-in screen drivers. In
- addition, custom screen drivers can be added using Qt's plugin
- mechanism, i.e. by subclassing the QScreen class and creating a
- screen driver plugin (QScreenDriverPlugin). See the
- \l{Qt for Embedded Linux Display Management}{display management}
- documentation for details.
-
- \sa QScreen, QScreenDriverPlugin
-*/
-
-/*!
- Creates the screen driver specified by the given \a key, using the
- display specified by the given \a displayId.
-
- Note that the keys are case-insensitive.
-
- \sa keys()
-*/
-QScreen *QScreenDriverFactory::create(const QString& key, int displayId)
-{
- QString driver = key.toLower();
-#if defined(Q_OS_QNX) && !defined(QT_NO_QWS_QNX)
- if (driver == QLatin1String("qnx") || driver.isEmpty())
- return new QQnxScreen(displayId);
-#endif
-#if defined(Q_OS_INTEGRITY) && !defined(QT_NO_QWS_INTEGRITY)
- if (driver == QLatin1String("integrityfb") || driver.isEmpty())
- return new QIntfbScreen(displayId);
-#endif
-#ifndef QT_NO_QWS_QVFB
- if (driver == QLatin1String("qvfb") || driver.isEmpty())
- return new QVFbScreen(displayId);
-#endif
-#ifndef QT_NO_QWS_LINUXFB
- if (driver == QLatin1String("linuxfb") || driver.isEmpty())
- return new QLinuxFbScreen(displayId);
-#endif
-#ifndef QT_NO_QWS_DIRECTFB
- if (driver == QLatin1String("directfb") || driver.isEmpty())
- return new QDirectFBScreen(displayId);
-#endif
-#ifndef QT_NO_QWS_TRANSFORMED
- if (driver == QLatin1String("transformed"))
- return new QTransformedScreen(displayId);
-#endif
-#ifndef QT_NO_QWS_VNC
- if (driver == QLatin1String("vnc"))
- return new QVNCScreen(displayId);
-#endif
-#ifndef QT_NO_QWS_MULTISCREEN
- if (driver == QLatin1String("multi"))
- return new QMultiScreen(displayId);
-#endif
-#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
-#ifndef QT_NO_LIBRARY
-
- if (QScreenDriverFactoryInterface *factory = qobject_cast<QScreenDriverFactoryInterface*>(loader()->instance(key)))
- return factory->create(driver, displayId);
-
-#endif
-#endif
- return 0;
-}
-
-/*!
- Returns the list of valid keys, i.e. the available screen drivers.
-
- \sa create()
-*/
-QStringList QScreenDriverFactory::keys()
-{
- QStringList list;
-
-#if defined(Q_OS_QNX) && !defined(QT_NO_QWS_QNX)
- list << QLatin1String("QNX");
-#endif
-#if defined(Q_OS_INTEGRITY) && !defined(QT_NO_QWS_INTEGRITY)
- list << QLatin1String("INTEGRITYFB");
-#endif
-#ifndef QT_NO_QWS_QVFB
- list << QLatin1String("QVFb");
-#endif
-#ifndef QT_NO_QWS_LINUXFB
- list << QLatin1String("LinuxFb");
-#endif
-#ifndef QT_NO_QWS_TRANSFORMED
- list << QLatin1String("Transformed");
-#endif
-#ifndef QT_NO_QWS_VNC
- list << QLatin1String("VNC");
-#endif
-#ifndef QT_NO_QWS_MULTISCREEN
- list << QLatin1String("Multi");
-#endif
-
-#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
-#ifndef QT_NO_LIBRARY
- QStringList plugins = loader()->keys();
- for (int i = 0; i < plugins.size(); ++i) {
-# ifdef QT_NO_QWS_QVFB
- // give QVFb top priority for autodetection
- if (plugins.at(i) == QLatin1String("QVFb"))
- list.prepend(plugins.at(i));
- else
-# endif
- if (!list.contains(plugins.at(i)))
- list += plugins.at(i);
- }
-#endif //QT_NO_LIBRARY
-#endif //QT_MAKEDLL
- return list;
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/embedded/qscreendriverfactory_qws.h b/src/gui/embedded/qscreendriverfactory_qws.h
deleted file mode 100644
index 072ae9bad8..0000000000
--- a/src/gui/embedded/qscreendriverfactory_qws.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSCREENDRIVERFACTORY_QWS_H
-#define QSCREENDRIVERFACTORY_QWS_H
-
-#include <QtCore/qstringlist.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QString;
-class QScreen;
-
-class Q_GUI_EXPORT QScreenDriverFactory
-{
-public:
- static QStringList keys();
- static QScreen *create(const QString&, int);
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSCREENDRIVERFACTORY_QWS_H
diff --git a/src/gui/embedded/qscreendriverplugin_qws.cpp b/src/gui/embedded/qscreendriverplugin_qws.cpp
deleted file mode 100644
index d7822c8ffc..0000000000
--- a/src/gui/embedded/qscreendriverplugin_qws.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qscreendriverplugin_qws.h"
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_LIBRARY
-
-/*!
- \class QScreenDriverPlugin
- \ingroup plugins
- \ingroup qws
-
- \brief The QScreenDriverPlugin class is an abstract base class for
- screen driver plugins in Qt for Embedded Linux.
-
- Note that this class is only available in \l{Qt for Embedded Linux}.
-
- \l{Qt for Embedded Linux} provides ready-made drivers for several screen
- protocols, see the \l{Qt for Embedded Linux Display Management}{display
- management} documentation for details. Custom screen drivers can be
- implemented by subclassing the QScreen class and creating a screen
- driver plugin.
-
- A screen driver plugin can be created by subclassing
- QScreenDriverPlugin and reimplementing the pure virtual keys() and
- create() functions. By exporting the derived class using the
- Q_EXPORT_PLUGIN2() macro, The default implementation of the
- QScreenDriverFactory class will automatically detect the plugin
- and load the driver into the server application at run-time. See
- \l{How to Create Qt Plugins} for details.
-
- \sa QScreen, QScreenDriverFactory
-*/
-
-/*!
- \fn QStringList QScreenDriverPlugin::keys() const
-
- Implement this function to return the list of valid keys, i.e. the
- screen drivers supported by this plugin.
-
- \l{Qt for Embedded Linux} provides ready-made drivers for several screen
- protocols, see the \l{Qt for Embedded Linux Display Management}{display
- management} documentation for details.
-
- \sa create()
-*/
-
-/*!
- Constructs a screen driver plugin with the given \a parent.
-
- Note that this constructor is invoked automatically by the
- Q_EXPORT_PLUGIN2() macro, so there is no need for calling it
- explicitly.
-*/
-QScreenDriverPlugin::QScreenDriverPlugin(QObject *parent)
- : QObject(parent)
-{
-}
-
-/*!
- Destroys this screen driver plugin.
-
- Note that Qt destroys a plugin automatically when it is no longer
- used, so there is no need for calling the destructor explicitly.
-*/
-QScreenDriverPlugin::~QScreenDriverPlugin()
-{
-}
-
-
-/*!
- \fn QScreen* QScreenDriverPlugin::create(const QString &key, int displayId)
-
- Implement this function to create a driver matching the type
- specified by the given \a key and \a displayId parameters. Note
- that keys are case-insensitive.
-
- \sa keys()
-*/
-
-#endif // QT_NO_LIBRARY
-
-QT_END_NAMESPACE
diff --git a/src/gui/embedded/qscreendriverplugin_qws.h b/src/gui/embedded/qscreendriverplugin_qws.h
deleted file mode 100644
index 039a8aabf1..0000000000
--- a/src/gui/embedded/qscreendriverplugin_qws.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSCREENDRIVERPLUGIN_QWS_H
-#define QSCREENDRIVERPLUGIN_QWS_H
-
-#include <QtCore/qplugin.h>
-#include <QtCore/qfactoryinterface.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_LIBRARY
-
-class QScreen;
-
-struct Q_GUI_EXPORT QScreenDriverFactoryInterface : public QFactoryInterface
-{
- virtual QScreen* create(const QString& driver, int displayId) = 0;
-};
-
-#define QScreenDriverFactoryInterface_iid "com.trolltech.Qt.QScreenDriverFactoryInterface"
-Q_DECLARE_INTERFACE(QScreenDriverFactoryInterface, QScreenDriverFactoryInterface_iid)
-
-class Q_GUI_EXPORT QScreenDriverPlugin : public QObject, public QScreenDriverFactoryInterface
-{
- Q_OBJECT
- Q_INTERFACES(QScreenDriverFactoryInterface:QFactoryInterface)
-public:
- explicit QScreenDriverPlugin(QObject *parent = 0);
- ~QScreenDriverPlugin();
-
- virtual QStringList keys() const = 0;
- virtual QScreen *create(const QString& driver, int displayId) = 0;
-};
-
-#endif // QT_NO_LIBRARY
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSCREENDRIVERPLUGIN_QWS_H
diff --git a/src/gui/embedded/qscreenintegrityfb_qws.cpp b/src/gui/embedded/qscreenintegrityfb_qws.cpp
deleted file mode 100644
index 7b24490353..0000000000
--- a/src/gui/embedded/qscreenintegrityfb_qws.cpp
+++ /dev/null
@@ -1,405 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QT_NO_QWS_INTEGRITYFB
-
-#include <qscreenintegrityfb_qws.h>
-#include <qwindowsystem_qws.h>
-#include <qsocketnotifier.h>
-#include <qapplication.h>
-#include <qscreen_qws.h>
-#include "qmouseintegrity_qws.h"
-#include "qkbdintegrity_qws.h"
-#include <qmousedriverfactory_qws.h>
-#include <qkbddriverfactory_qws.h>
-#include <qdebug.h>
-
-#include <INTEGRITY.h>
-#include <device/fbdriver.h>
-
-QT_BEGIN_NAMESPACE
-
-class QIntfbScreenPrivate
-{
-public:
- QIntfbScreenPrivate();
- ~QIntfbScreenPrivate();
-
- FBHandle handle;
- struct FBInfoStruct fbinfo;
-
- QWSMouseHandler *mouse;
-#ifndef QT_NO_QWS_KEYBOARD
- QWSKeyboardHandler *keyboard;
-#endif
-};
-
-QIntfbScreenPrivate::QIntfbScreenPrivate()
- : mouse(0)
-
-{
-#ifndef QT_NO_QWS_KEYBOARD
- keyboard = 0;
-#endif
-}
-
-QIntfbScreenPrivate::~QIntfbScreenPrivate()
-{
- delete mouse;
-#ifndef QT_NO_QWS_KEYBOARD
- delete keyboard;
-#endif
-}
-
-/*!
- \internal
-
- \class QIntfbScreen
- \ingroup qws
-
- \brief The QIntfbScreen class implements a screen driver for the
- INTEGRITY framebuffer drivers.
-
- Note that this class is only available in \l{Qt for INTEGRITY}.
- Custom screen drivers can be added by subclassing the
- QScreenDriverPlugin class, using the QScreenDriverFactory class to
- dynamically load the driver into the application, but there should
- only be one screen object per application.
-
- \sa QScreen, QScreenDriverPlugin, {Running Applications}
-*/
-
-/*!
- \fn bool QIntfbScreen::connect(const QString & displaySpec)
- \reimp
-*/
-
-/*!
- \fn void QIntfbScreen::disconnect()
- \reimp
-*/
-
-/*!
- \fn bool QIntfbScreen::initDevice()
- \reimp
-*/
-
-/*!
- \fn void QIntfbScreen::restore()
- \reimp
-*/
-
-/*!
- \fn void QIntfbScreen::save()
- \reimp
-*/
-
-/*!
- \fn void QIntfbScreen::setDirty(const QRect & r)
- \reimp
-*/
-
-/*!
- \fn void QIntfbScreen::setMode(int nw, int nh, int nd)
- \reimp
-*/
-
-/*!
- \fn void QIntfbScreen::shutdownDevice()
- \reimp
-*/
-
-/*!
- \fn QIntfbScreen::QIntfbScreen(int displayId)
-
- Constructs a QVNCScreen object. The \a displayId argument
- identifies the Qt for Embedded Linux server to connect to.
-*/
-QIntfbScreen::QIntfbScreen(int display_id)
- : QScreen(display_id, IntfbClass), d_ptr(new QIntfbScreenPrivate)
-{
- d_ptr->handle = 0;
- data = 0;
-}
-
-/*!
- Destroys this QIntfbScreen object.
-*/
-QIntfbScreen::~QIntfbScreen()
-{
- delete d_ptr;
-}
-
-static QIntfbScreen *connected = 0;
-
-bool QIntfbScreen::connect(const QString &displaySpec)
-{
- FBDriver *fbdev;
-
- CheckSuccess(gh_FB_get_driver(0, &fbdev));
- CheckSuccess(gh_FB_init_device(fbdev, 0, &d_ptr->handle));
- CheckSuccess(gh_FB_get_info(d_ptr->handle, &d_ptr->fbinfo));
-
- data = (uchar *)d_ptr->fbinfo.start;
-
- d = d_ptr->fbinfo.bitsperpixel;
- switch (d) {
- case 1:
- setPixelFormat(QImage::Format_Mono);
- break;
- case 8:
- setPixelFormat(QImage::Format_Indexed8);
- break;
- case 12:
- setPixelFormat(QImage::Format_RGB444);
- break;
- case 15:
- setPixelFormat(QImage::Format_RGB555);
- break;
- case 16:
- setPixelFormat(QImage::Format_RGB16);
- break;
- case 18:
- setPixelFormat(QImage::Format_RGB666);
- break;
- case 24:
- setPixelFormat(QImage::Format_RGB888);
-#ifdef QT_QWS_DEPTH_GENERIC
-#if Q_BYTE_ORDER != Q_BIG_ENDIAN
- qt_set_generic_blit(this, 24,
- d_ptr->fbinfo.redbits,
- d_ptr->fbinfo.greenbits,
- d_ptr->fbinfo.bluebits,
- d_ptr->fbinfo.alphabits,
- d_ptr->fbinfo.redoffset,
- d_ptr->fbinfo.greenoffset,
- d_ptr->fbinfo.blueoffset,
- d_ptr->fbinfo.alphaoffset);
-#else
- qt_set_generic_blit(this, 24,
- d_ptr->fbinfo.redbits,
- d_ptr->fbinfo.greenbits,
- d_ptr->fbinfo.bluebits,
- d_ptr->fbinfo.alphabits,
- 16 - d_ptr->fbinfo.redoffset,
- 16 - d_ptr->fbinfo.greenoffset,
- 16 - d_ptr->fbinfo.blueoffset,
- d_ptr->fbinfo.alphaoffset);
-#endif
-#endif
- break;
- case 32:
- setPixelFormat(QImage::Format_ARGB32_Premultiplied);
-#ifdef QT_QWS_DEPTH_GENERIC
-#if Q_BYTE_ORDER != Q_BIG_ENDIAN
- qt_set_generic_blit(this, 32,
- d_ptr->fbinfo.redbits,
- d_ptr->fbinfo.greenbits,
- d_ptr->fbinfo.bluebits,
- d_ptr->fbinfo.alphabits,
- d_ptr->fbinfo.redoffset,
- d_ptr->fbinfo.greenoffset,
- d_ptr->fbinfo.blueoffset,
- d_ptr->fbinfo.alphaoffset);
-#else
- qt_set_generic_blit(this, 32,
- d_ptr->fbinfo.redbits,
- d_ptr->fbinfo.greenbits,
- d_ptr->fbinfo.bluebits,
- d_ptr->fbinfo.alphabits,
- 24 - d_ptr->fbinfo.redoffset,
- 24 - d_ptr->fbinfo.greenoffset,
- 24 - d_ptr->fbinfo.blueoffset,
- d_ptr->fbinfo.alphaoffset ? 24 - d_ptr->fbinfo.alphaoffset : 0);
-#endif
-#endif
- break;
- }
-
- dw = w = d_ptr->fbinfo.width;
- dh = h = d_ptr->fbinfo.height;
-
- /* assumes no padding */
- lstep = w * ((d + 7) >> 3);
-
- mapsize = size = h * lstep;
-
- /* default values */
- int dpi = 72;
- physWidth = qRound(dw * 25.4 / dpi);
- physHeight = qRound(dh * 25.4 / dpi);
-
- qDebug("Connected to INTEGRITYfb server: %d x %d x %d %dx%dmm (%dx%ddpi)",
- w, h, d, physWidth, physHeight, qRound(dw*25.4/physWidth), qRound(dh*25.4/physHeight) );
-
-
- QWSServer::setDefaultMouse("integrity");
- QWSServer::setDefaultKeyboard("integrity");
-
- connected = this;
-
- return true;
-}
-
-void QIntfbScreen::disconnect()
-{
- connected = 0;
-}
-
-bool QIntfbScreen::initDevice()
-{
-
- CheckSuccess(gh_FB_set_info(d_ptr->handle, &d_ptr->fbinfo, false));
- CheckSuccess(gh_FB_get_info(d_ptr->handle, &d_ptr->fbinfo));
- data = (uchar *)d_ptr->fbinfo.start;
- d = d_ptr->fbinfo.bitsperpixel;
- dw = w = d_ptr->fbinfo.width;
- dh = h = d_ptr->fbinfo.height;
- mapsize = d_ptr->fbinfo.length;
- /* assumes no padding */
- lstep = w * ((d + 7) >> 3);
-
- mapsize = size = h * lstep;
-
- data = (uchar *)d_ptr->fbinfo.start;
-
- d = d_ptr->fbinfo.bitsperpixel;
- switch (d) {
- case 1:
- setPixelFormat(QImage::Format_Mono);
- break;
- case 8:
- setPixelFormat(QImage::Format_Indexed8);
- break;
- case 12:
- setPixelFormat(QImage::Format_RGB444);
- break;
- case 15:
- setPixelFormat(QImage::Format_RGB555);
- break;
- case 16:
- setPixelFormat(QImage::Format_RGB16);
- break;
- case 18:
- setPixelFormat(QImage::Format_RGB666);
- break;
- case 24:
- setPixelFormat(QImage::Format_RGB888);
- break;
- case 32:
- setPixelFormat(QImage::Format_ARGB32_Premultiplied);
- break;
- }
-#ifdef QT_QWS_DEPTH_GENERIC
-#if defined(__BIG_ENDIAN__)
- qt_set_generic_blit(this, d,
- d_ptr->fbinfo.redbits,
- d_ptr->fbinfo.greenbits,
- d_ptr->fbinfo.bluebits,
- d_ptr->fbinfo.alphabits,
- 24 - d_ptr->fbinfo.redoffset,
- 24 - d_ptr->fbinfo.greenoffset,
- 24 - d_ptr->fbinfo.blueoffset,
- d_ptr->fbinfo.alphaoffset ? 24 - d_ptr->fbinfo.alphaoffset : 0);
-#else
- qt_set_generic_blit(this, d,
- d_ptr->fbinfo.redbits,
- d_ptr->fbinfo.greenbits,
- d_ptr->fbinfo.bluebits,
- d_ptr->fbinfo.alphabits,
- d_ptr->fbinfo.redoffset,
- d_ptr->fbinfo.greenoffset,
- d_ptr->fbinfo.blueoffset,
- d_ptr->fbinfo.alphaoffset);
-#endif
-#endif
-
-#ifndef QT_NO_QWS_CURSOR
- QScreenCursor::initSoftwareCursor();
-#endif
- return true;
-}
-
-void QIntfbScreen::shutdownDevice()
-{
- gh_FB_close(d_ptr->handle);
-}
-
-void QIntfbScreen::setMode(int ,int ,int)
-{
-}
-
-// save the state of the graphics card
-// This is needed so that e.g. we can restore the palette when switching
-// between linux virtual consoles.
-void QIntfbScreen::save()
-{
- // nothing to do.
-}
-
-// restore the state of the graphics card.
-void QIntfbScreen::restore()
-{
-}
-void QIntfbScreen::setDirty(const QRect& rect)
-{
- FBRect fbrect;
- fbrect.dx = rect.x();
- fbrect.dy = rect.y();
- fbrect.width = rect.width();
- fbrect.height = rect.height();
- gh_FB_expose(d_ptr->handle, &fbrect);
-}
-
-void QIntfbScreen::setBrightness(int b)
-{
- if (connected) {
- }
-}
-
-void QIntfbScreen::blank(bool on)
-{
-}
-
-#endif // QT_NO_QWS_INTEGRITYFB
-
-QT_END_NAMESPACE
-
diff --git a/src/gui/embedded/qscreenintegrityfb_qws.h b/src/gui/embedded/qscreenintegrityfb_qws.h
deleted file mode 100644
index 06b39671f4..0000000000
--- a/src/gui/embedded/qscreenintegrityfb_qws.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSCREENINTEGRITYFB_QWS_H
-#define QSCREENINTEGRITYFB_QWS_H
-
-#include <QtGui/qscreen_qws.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_QWS_INTEGRITYFB
-
-class QIntfbScreenPrivate;
-
-class Q_GUI_EXPORT QIntfbScreen : public QScreen
-{
-public:
- explicit QIntfbScreen(int display_id);
- virtual ~QIntfbScreen();
- virtual bool initDevice();
- virtual bool connect(const QString &displaySpec);
- virtual void disconnect();
- virtual void shutdownDevice();
- virtual void save();
- virtual void restore();
- virtual void setMode(int nw,int nh,int nd);
- virtual void setDirty(const QRect& r);
- virtual void blank(bool);
- static void setBrightness(int b);
-
-private:
- QIntfbScreenPrivate *d_ptr;
-};
-
-#endif // QT_NO_QWS_INTEGRITYFB
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSCREENINTEGRITYFB_QWS_H
diff --git a/src/gui/embedded/qscreenlinuxfb_qws.cpp b/src/gui/embedded/qscreenlinuxfb_qws.cpp
deleted file mode 100644
index a566f5294c..0000000000
--- a/src/gui/embedded/qscreenlinuxfb_qws.cpp
+++ /dev/null
@@ -1,1386 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qscreenlinuxfb_qws.h"
-
-#ifndef QT_NO_QWS_LINUXFB
-//#include "qmemorymanager_qws.h"
-#include "qwsdisplay_qws.h"
-#include "qpixmap.h"
-#include <private/qwssignalhandler_p.h>
-#include <private/qcore_unix_p.h> // overrides QT_OPEN
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <sys/kd.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <stdio.h>
-#include <limits.h>
-#include <signal.h>
-
-#include "qwindowsystem_qws.h"
-
-#if !defined(Q_OS_DARWIN) && !defined(Q_OS_FREEBSD)
-#include <linux/fb.h>
-
-#ifdef __i386__
-#include <asm/mtrr.h>
-#endif
-#endif
-
-QT_BEGIN_NAMESPACE
-
-extern int qws_client_id;
-
-//#define DEBUG_CACHE
-
-class QLinuxFbScreenPrivate : public QObject
-{
-public:
- QLinuxFbScreenPrivate();
- ~QLinuxFbScreenPrivate();
-
- void openTty();
- void closeTty();
-
- int fd;
- int startupw;
- int startuph;
- int startupd;
- bool blank;
- QLinuxFbScreen::DriverTypes driverType;
-
- bool doGraphicsMode;
-#ifdef QT_QWS_DEPTH_GENERIC
- bool doGenericColors;
-#endif
- int ttyfd;
- long oldKdMode;
- QString ttyDevice;
- QString displaySpec;
-};
-
-QLinuxFbScreenPrivate::QLinuxFbScreenPrivate()
- : fd(-1), blank(true), doGraphicsMode(true),
-#ifdef QT_QWS_DEPTH_GENERIC
- doGenericColors(false),
-#endif
- ttyfd(-1), oldKdMode(KD_TEXT)
-{
- QWSSignalHandler::instance()->addObject(this);
-}
-
-QLinuxFbScreenPrivate::~QLinuxFbScreenPrivate()
-{
- closeTty();
-}
-
-void QLinuxFbScreenPrivate::openTty()
-{
- const char *const devs[] = {"/dev/tty0", "/dev/tty", "/dev/console", 0};
-
- if (ttyDevice.isEmpty()) {
- for (const char * const *dev = devs; *dev; ++dev) {
- ttyfd = QT_OPEN(*dev, O_RDWR);
- if (ttyfd != -1)
- break;
- }
- } else {
- ttyfd = QT_OPEN(ttyDevice.toAscii().constData(), O_RDWR);
- }
-
- if (ttyfd == -1)
- return;
-
- if (doGraphicsMode) {
- ioctl(ttyfd, KDGETMODE, &oldKdMode);
- if (oldKdMode != KD_GRAPHICS) {
- int ret = ioctl(ttyfd, KDSETMODE, KD_GRAPHICS);
- if (ret == -1)
- doGraphicsMode = false;
- }
- }
-
- // No blankin' screen, no blinkin' cursor!, no cursor!
- const char termctl[] = "\033[9;0]\033[?33l\033[?25l\033[?1c";
- QT_WRITE(ttyfd, termctl, sizeof(termctl));
-}
-
-void QLinuxFbScreenPrivate::closeTty()
-{
- if (ttyfd == -1)
- return;
-
- if (doGraphicsMode)
- ioctl(ttyfd, KDSETMODE, oldKdMode);
-
- // Blankin' screen, blinkin' cursor!
- const char termctl[] = "\033[9;15]\033[?33h\033[?25h\033[?0c";
- QT_WRITE(ttyfd, termctl, sizeof(termctl));
-
- QT_CLOSE(ttyfd);
- ttyfd = -1;
-}
-
-/*!
- \enum QLinuxFbScreen::DriverTypes
-
- This enum describes the driver type.
-
- \value GenericDriver Generic Linux framebuffer driver
- \value EInk8Track e-Ink framebuffer driver using the 8Track chipset
- */
-
-/*!
- \fn QLinuxFbScreen::fixupScreenInfo(fb_fix_screeninfo &finfo, fb_var_screeninfo &vinfo)
-
- Adjust the values returned by the framebuffer driver, to work
- around driver bugs or nonstandard behavior in certain drivers.
- \a finfo and \a vinfo specify the fixed and variable screen info
- returned by the driver.
- */
-void QLinuxFbScreen::fixupScreenInfo(fb_fix_screeninfo &finfo, fb_var_screeninfo &vinfo)
-{
- // 8Track e-ink devices (as found in Sony PRS-505) lie
- // about their bit depth -- they claim they're 1 bit per
- // pixel while the only supported mode is 8 bit per pixel
- // grayscale.
- // Caused by this, they also miscalculate their line length.
- if(!strcmp(finfo.id, "8TRACKFB") && vinfo.bits_per_pixel == 1) {
- vinfo.bits_per_pixel = 8;
- finfo.line_length = vinfo.xres;
- }
-}
-
-/*!
- \internal
-
- \class QLinuxFbScreen
- \ingroup qws
-
- \brief The QLinuxFbScreen class implements a screen driver for the
- Linux framebuffer.
-
- Note that this class is only available in \l{Qt for Embedded Linux}.
- Custom screen drivers can be added by subclassing the
- QScreenDriverPlugin class, using the QScreenDriverFactory class to
- dynamically load the driver into the application, but there should
- only be one screen object per application.
-
- The QLinuxFbScreen class provides the cache() function allocating
- off-screen graphics memory, and the complementary uncache()
- function releasing the allocated memory. The latter function will
- first sync the graphics card to ensure the memory isn't still
- being used by a command in the graphics card FIFO queue. The
- deleteEntry() function deletes the given memory block without such
- synchronization. Given the screen instance and client id, the
- memory can also be released using the clearCache() function, but
- this should only be necessary if a client exits abnormally.
-
- In addition, when in paletted graphics modes, the set() function
- provides the possibility of setting a specified color index to a
- given RGB value.
-
- The QLinuxFbScreen class also acts as a factory for the
- unaccelerated screen cursor and the unaccelerated raster-based
- implementation of QPaintEngine (\c QRasterPaintEngine);
- accelerated drivers for Linux should derive from this class.
-
- \sa QScreen, QScreenDriverPlugin, {Running Applications}
-*/
-
-/*!
- \fn bool QLinuxFbScreen::useOffscreen()
- \internal
-*/
-
-// Unaccelerated screen/driver setup. Can be overridden by accelerated
-// drivers
-
-/*!
- \fn QLinuxFbScreen::QLinuxFbScreen(int displayId)
-
- Constructs a QLinuxFbScreen object. The \a displayId argument
- identifies the Qt for Embedded Linux server to connect to.
-*/
-
-QLinuxFbScreen::QLinuxFbScreen(int display_id)
- : QScreen(display_id, LinuxFBClass), d_ptr(new QLinuxFbScreenPrivate)
-{
- canaccel=false;
- clearCacheFunc = &clearCache;
-#ifdef QT_QWS_CLIENTBLIT
- setSupportsBlitInClients(true);
-#endif
-}
-
-/*!
- Destroys this QLinuxFbScreen object.
-*/
-
-QLinuxFbScreen::~QLinuxFbScreen()
-{
-}
-
-/*!
- \reimp
-
- This is called by \l{Qt for Embedded Linux} clients to map in the framebuffer.
- It should be reimplemented by accelerated drivers to map in
- graphics card registers; those drivers should then call this
- function in order to set up offscreen memory management. The
- device is specified in \a displaySpec; e.g. "/dev/fb".
-
- \sa disconnect()
-*/
-
-bool QLinuxFbScreen::connect(const QString &displaySpec)
-{
- d_ptr->displaySpec = displaySpec;
-
- const QStringList args = displaySpec.split(QLatin1Char(':'));
-
- if (args.contains(QLatin1String("nographicsmodeswitch")))
- d_ptr->doGraphicsMode = false;
-
-#ifdef QT_QWS_DEPTH_GENERIC
- if (args.contains(QLatin1String("genericcolors")))
- d_ptr->doGenericColors = true;
-#endif
-
- QRegExp ttyRegExp(QLatin1String("tty=(.*)"));
- if (args.indexOf(ttyRegExp) != -1)
- d_ptr->ttyDevice = ttyRegExp.cap(1);
-
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
-#ifndef QT_QWS_FRAMEBUFFER_LITTLE_ENDIAN
- if (args.contains(QLatin1String("littleendian")))
-#endif
- QScreen::setFrameBufferLittleEndian(true);
-#endif
-
- QString dev = QLatin1String("/dev/fb0");
- foreach(QString d, args) {
- if (d.startsWith(QLatin1Char('/'))) {
- dev = d;
- break;
- }
- }
-
- if (access(dev.toLatin1().constData(), R_OK|W_OK) == 0)
- d_ptr->fd = QT_OPEN(dev.toLatin1().constData(), O_RDWR);
- if (d_ptr->fd == -1) {
- if (QApplication::type() == QApplication::GuiServer) {
- perror("QScreenLinuxFb::connect");
- qCritical("Error opening framebuffer device %s", qPrintable(dev));
- return false;
- }
- if (access(dev.toLatin1().constData(), R_OK) == 0)
- d_ptr->fd = QT_OPEN(dev.toLatin1().constData(), O_RDONLY);
- }
-
- ::fb_fix_screeninfo finfo;
- ::fb_var_screeninfo vinfo;
- //#######################
- // Shut up Valgrind
- memset(&vinfo, 0, sizeof(vinfo));
- memset(&finfo, 0, sizeof(finfo));
- //#######################
-
- /* Get fixed screen information */
- if (d_ptr->fd != -1 && ioctl(d_ptr->fd, FBIOGET_FSCREENINFO, &finfo)) {
- perror("QLinuxFbScreen::connect");
- qWarning("Error reading fixed information");
- return false;
- }
-
- d_ptr->driverType = strcmp(finfo.id, "8TRACKFB") ? GenericDriver : EInk8Track;
-
- if (finfo.type == FB_TYPE_VGA_PLANES) {
- qWarning("VGA16 video mode not supported");
- return false;
- }
-
- /* Get variable screen information */
- if (d_ptr->fd != -1 && ioctl(d_ptr->fd, FBIOGET_VSCREENINFO, &vinfo)) {
- perror("QLinuxFbScreen::connect");
- qWarning("Error reading variable information");
- return false;
- }
-
- fixupScreenInfo(finfo, vinfo);
-
- grayscale = vinfo.grayscale;
- d = vinfo.bits_per_pixel;
- if (d == 24) {
- d = vinfo.red.length + vinfo.green.length + vinfo.blue.length;
- if (d <= 0)
- d = 24; // reset if color component lengths are not reported
- } else if (d == 16) {
- d = vinfo.red.length + vinfo.green.length + vinfo.blue.length;
- if (d <= 0)
- d = 16;
- }
- lstep = finfo.line_length;
-
- int xoff = vinfo.xoffset;
- int yoff = vinfo.yoffset;
- const char* qwssize;
- if((qwssize=::getenv("QWS_SIZE")) && sscanf(qwssize,"%dx%d",&w,&h)==2) {
- if (d_ptr->fd != -1) {
- if ((uint)w > vinfo.xres) w = vinfo.xres;
- if ((uint)h > vinfo.yres) h = vinfo.yres;
- }
- dw=w;
- dh=h;
- int xxoff, yyoff;
- if (sscanf(qwssize, "%*dx%*d+%d+%d", &xxoff, &yyoff) == 2) {
- if (xxoff < 0 || xxoff + w > vinfo.xres)
- xxoff = vinfo.xres - w;
- if (yyoff < 0 || yyoff + h > vinfo.yres)
- yyoff = vinfo.yres - h;
- xoff += xxoff;
- yoff += yyoff;
- } else {
- xoff += (vinfo.xres - w)/2;
- yoff += (vinfo.yres - h)/2;
- }
- } else {
- dw=w=vinfo.xres;
- dh=h=vinfo.yres;
- }
-
- if (w == 0 || h == 0) {
- qWarning("QScreenLinuxFb::connect(): Unable to find screen geometry, "
- "will use 320x240.");
- dw = w = 320;
- dh = h = 240;
- }
-
- setPixelFormat(vinfo);
-
- // Handle display physical size spec.
- QStringList displayArgs = displaySpec.split(QLatin1Char(':'));
- QRegExp mmWidthRx(QLatin1String("mmWidth=?(\\d+)"));
- int dimIdxW = displayArgs.indexOf(mmWidthRx);
- QRegExp mmHeightRx(QLatin1String("mmHeight=?(\\d+)"));
- int dimIdxH = displayArgs.indexOf(mmHeightRx);
- if (dimIdxW >= 0) {
- mmWidthRx.exactMatch(displayArgs.at(dimIdxW));
- physWidth = mmWidthRx.cap(1).toInt();
- if (dimIdxH < 0)
- physHeight = dh*physWidth/dw;
- }
- if (dimIdxH >= 0) {
- mmHeightRx.exactMatch(displayArgs.at(dimIdxH));
- physHeight = mmHeightRx.cap(1).toInt();
- if (dimIdxW < 0)
- physWidth = dw*physHeight/dh;
- }
- if (dimIdxW < 0 && dimIdxH < 0) {
- if (vinfo.width != 0 && vinfo.height != 0
- && vinfo.width != UINT_MAX && vinfo.height != UINT_MAX) {
- physWidth = vinfo.width;
- physHeight = vinfo.height;
- } else {
- const int dpi = 72;
- physWidth = qRound(dw * 25.4 / dpi);
- physHeight = qRound(dh * 25.4 / dpi);
- }
- }
-
- dataoffset = yoff * lstep + xoff * d / 8;
- //qDebug("Using %dx%dx%d screen",w,h,d);
-
- /* Figure out the size of the screen in bytes */
- size = h * lstep;
-
- mapsize = finfo.smem_len;
-
- data = (unsigned char *)-1;
- if (d_ptr->fd != -1)
- data = (unsigned char *)mmap(0, mapsize, PROT_READ | PROT_WRITE,
- MAP_SHARED, d_ptr->fd, 0);
-
- if ((long)data == -1) {
- if (QApplication::type() == QApplication::GuiServer) {
- perror("QLinuxFbScreen::connect");
- qWarning("Error: failed to map framebuffer device to memory.");
- return false;
- }
- data = 0;
- } else {
- data += dataoffset;
- }
-
- canaccel = useOffscreen();
- if(canaccel)
- setupOffScreen();
-
- // Now read in palette
- if((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4)) {
- screencols= (vinfo.bits_per_pixel==8) ? 256 : 16;
- int loopc;
- ::fb_cmap startcmap;
- startcmap.start=0;
- startcmap.len=screencols;
- startcmap.red=(unsigned short int *)
- malloc(sizeof(unsigned short int)*screencols);
- startcmap.green=(unsigned short int *)
- malloc(sizeof(unsigned short int)*screencols);
- startcmap.blue=(unsigned short int *)
- malloc(sizeof(unsigned short int)*screencols);
- startcmap.transp=(unsigned short int *)
- malloc(sizeof(unsigned short int)*screencols);
- if (d_ptr->fd == -1 || ioctl(d_ptr->fd, FBIOGETCMAP, &startcmap)) {
- perror("QLinuxFbScreen::connect");
- qWarning("Error reading palette from framebuffer, using default palette");
- createPalette(startcmap, vinfo, finfo);
- }
- int bits_used = 0;
- for(loopc=0;loopc<screencols;loopc++) {
- screenclut[loopc]=qRgb(startcmap.red[loopc] >> 8,
- startcmap.green[loopc] >> 8,
- startcmap.blue[loopc] >> 8);
- bits_used |= startcmap.red[loopc]
- | startcmap.green[loopc]
- | startcmap.blue[loopc];
- }
- // WORKAROUND: Some framebuffer drivers only return 8 bit
- // color values, so we need to not bit shift them..
- if ((bits_used & 0x00ff) && !(bits_used & 0xff00)) {
- for(loopc=0;loopc<screencols;loopc++) {
- screenclut[loopc] = qRgb(startcmap.red[loopc],
- startcmap.green[loopc],
- startcmap.blue[loopc]);
- }
- qWarning("8 bits cmap returned due to faulty FB driver, colors corrected");
- }
- free(startcmap.red);
- free(startcmap.green);
- free(startcmap.blue);
- free(startcmap.transp);
- } else {
- screencols=0;
- }
-
- return true;
-}
-
-/*!
- \reimp
-
- This unmaps the framebuffer.
-
- \sa connect()
-*/
-
-void QLinuxFbScreen::disconnect()
-{
- data -= dataoffset;
- if (data)
- munmap((char*)data,mapsize);
- close(d_ptr->fd);
-}
-
-// #define DEBUG_VINFO
-
-void QLinuxFbScreen::createPalette(fb_cmap &cmap, fb_var_screeninfo &vinfo, fb_fix_screeninfo &finfo)
-{
- if((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4)) {
- screencols= (vinfo.bits_per_pixel==8) ? 256 : 16;
- cmap.start=0;
- cmap.len=screencols;
- cmap.red=(unsigned short int *)
- malloc(sizeof(unsigned short int)*screencols);
- cmap.green=(unsigned short int *)
- malloc(sizeof(unsigned short int)*screencols);
- cmap.blue=(unsigned short int *)
- malloc(sizeof(unsigned short int)*screencols);
- cmap.transp=(unsigned short int *)
- malloc(sizeof(unsigned short int)*screencols);
-
- if (screencols==16) {
- if (finfo.type == FB_TYPE_PACKED_PIXELS) {
- // We'll setup a grayscale cmap for 4bpp linear
- int val = 0;
- for (int idx = 0; idx < 16; ++idx, val += 17) {
- cmap.red[idx] = (val<<8)|val;
- cmap.green[idx] = (val<<8)|val;
- cmap.blue[idx] = (val<<8)|val;
- screenclut[idx]=qRgb(val, val, val);
- }
- } else {
- // Default 16 colour palette
- // Green is now trolltech green so certain images look nicer
- // black d_gray l_gray white red green blue cyan magenta yellow
- unsigned char reds[16] = { 0x00, 0x7F, 0xBF, 0xFF, 0xFF, 0xA2, 0x00, 0xFF, 0xFF, 0x00, 0x7F, 0x7F, 0x00, 0x00, 0x00, 0x82 };
- unsigned char greens[16] = { 0x00, 0x7F, 0xBF, 0xFF, 0x00, 0xC5, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x7F, 0x7F, 0x7F };
- unsigned char blues[16] = { 0x00, 0x7F, 0xBF, 0xFF, 0x00, 0x11, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0x7F, 0x7F, 0x7F, 0x00, 0x00 };
-
- for (int idx = 0; idx < 16; ++idx) {
- cmap.red[idx] = ((reds[idx]) << 8)|reds[idx];
- cmap.green[idx] = ((greens[idx]) << 8)|greens[idx];
- cmap.blue[idx] = ((blues[idx]) << 8)|blues[idx];
- cmap.transp[idx] = 0;
- screenclut[idx]=qRgb(reds[idx], greens[idx], blues[idx]);
- }
- }
- } else {
- if (grayscale) {
- // Build grayscale palette
- int i;
- for(i=0;i<screencols;++i) {
- int bval = screencols == 256 ? i : (i << 4);
- ushort val = (bval << 8) | bval;
- cmap.red[i] = val;
- cmap.green[i] = val;
- cmap.blue[i] = val;
- cmap.transp[i] = 0;
- screenclut[i] = qRgb(bval,bval,bval);
- }
- } else {
- // 6x6x6 216 color cube
- int idx = 0;
- for(int ir = 0x0; ir <= 0xff; ir+=0x33) {
- for(int ig = 0x0; ig <= 0xff; ig+=0x33) {
- for(int ib = 0x0; ib <= 0xff; ib+=0x33) {
- cmap.red[idx] = (ir << 8)|ir;
- cmap.green[idx] = (ig << 8)|ig;
- cmap.blue[idx] = (ib << 8)|ib;
- cmap.transp[idx] = 0;
- screenclut[idx]=qRgb(ir, ig, ib);
- ++idx;
- }
- }
- }
- // Fill in rest with 0
- for (int loopc=0; loopc<40; ++loopc) {
- screenclut[idx]=0;
- ++idx;
- }
- screencols=idx;
- }
- }
- } else if(finfo.visual==FB_VISUAL_DIRECTCOLOR) {
- cmap.start=0;
- int rbits=0,gbits=0,bbits=0;
- switch (vinfo.bits_per_pixel) {
- case 8:
- rbits=vinfo.red.length;
- gbits=vinfo.green.length;
- bbits=vinfo.blue.length;
- if(rbits==0 && gbits==0 && bbits==0) {
- // cyber2000 driver bug hack
- rbits=3;
- gbits=3;
- bbits=2;
- }
- break;
- case 15:
- rbits=5;
- gbits=5;
- bbits=5;
- break;
- case 16:
- rbits=5;
- gbits=6;
- bbits=5;
- break;
- case 18:
- case 19:
- rbits=6;
- gbits=6;
- bbits=6;
- break;
- case 24: case 32:
- rbits=gbits=bbits=8;
- break;
- }
- screencols=cmap.len=1<<qMax(rbits,qMax(gbits,bbits));
- cmap.red=(unsigned short int *)
- malloc(sizeof(unsigned short int)*256);
- cmap.green=(unsigned short int *)
- malloc(sizeof(unsigned short int)*256);
- cmap.blue=(unsigned short int *)
- malloc(sizeof(unsigned short int)*256);
- cmap.transp=(unsigned short int *)
- malloc(sizeof(unsigned short int)*256);
- for(unsigned int i = 0x0; i < cmap.len; i++) {
- cmap.red[i] = i*65535/((1<<rbits)-1);
- cmap.green[i] = i*65535/((1<<gbits)-1);
- cmap.blue[i] = i*65535/((1<<bbits)-1);
- cmap.transp[i] = 0;
- }
- }
-}
-
-/*!
- \reimp
-
- This is called by the \l{Qt for Embedded Linux} server at startup time.
- It turns off console blinking, sets up the color palette, enables write
- combining on the framebuffer and initialises the off-screen memory
- manager.
-*/
-
-bool QLinuxFbScreen::initDevice()
-{
- d_ptr->openTty();
-
- // Grab current mode so we can reset it
- fb_var_screeninfo vinfo;
- fb_fix_screeninfo finfo;
- //#######################
- // Shut up Valgrind
- memset(&vinfo, 0, sizeof(vinfo));
- memset(&finfo, 0, sizeof(finfo));
- //#######################
-
- if (ioctl(d_ptr->fd, FBIOGET_VSCREENINFO, &vinfo)) {
- perror("QLinuxFbScreen::initDevice");
- qFatal("Error reading variable information in card init");
- return false;
- }
-
-#ifdef DEBUG_VINFO
- qDebug("Greyscale %d",vinfo.grayscale);
- qDebug("Nonstd %d",vinfo.nonstd);
- qDebug("Red %d %d %d",vinfo.red.offset,vinfo.red.length,
- vinfo.red.msb_right);
- qDebug("Green %d %d %d",vinfo.green.offset,vinfo.green.length,
- vinfo.green.msb_right);
- qDebug("Blue %d %d %d",vinfo.blue.offset,vinfo.blue.length,
- vinfo.blue.msb_right);
- qDebug("Transparent %d %d %d",vinfo.transp.offset,vinfo.transp.length,
- vinfo.transp.msb_right);
-#endif
-
- if (ioctl(d_ptr->fd, FBIOGET_FSCREENINFO, &finfo)) {
- perror("QLinuxFbScreen::initDevice");
- qCritical("Error reading fixed information in card init");
- // It's not an /error/ as such, though definitely a bad sign
- // so we return true
- return true;
- }
-
- fixupScreenInfo(finfo, vinfo);
-
- d_ptr->startupw=vinfo.xres;
- d_ptr->startuph=vinfo.yres;
- d_ptr->startupd=vinfo.bits_per_pixel;
- grayscale = vinfo.grayscale;
-
-#ifdef __i386__
- // Now init mtrr
- if(!::getenv("QWS_NOMTRR")) {
- int mfd=QT_OPEN("/proc/mtrr",O_WRONLY,0);
- // MTRR entry goes away when file is closed - i.e.
- // hopefully when QWS is killed
- if(mfd != -1) {
- mtrr_sentry sentry;
- sentry.base=(unsigned long int)finfo.smem_start;
- //qDebug("Physical framebuffer address %p",(void*)finfo.smem_start);
- // Size needs to be in 4k chunks, but that's not always
- // what we get thanks to graphics card registers. Write combining
- // these is Not Good, so we write combine what we can
- // (which is not much - 4 megs on an 8 meg card, it seems)
- unsigned int size=finfo.smem_len;
- size=size >> 22;
- size=size << 22;
- sentry.size=size;
- sentry.type=MTRR_TYPE_WRCOMB;
- if(ioctl(mfd,MTRRIOC_ADD_ENTRY,&sentry)==-1) {
- //printf("Couldn't add mtrr entry for %lx %lx, %s\n",
- //sentry.base,sentry.size,strerror(errno));
- }
- }
-
- // Should we close mfd here?
- //QT_CLOSE(mfd);
- }
-#endif
- if ((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4) || (finfo.visual==FB_VISUAL_DIRECTCOLOR))
- {
- fb_cmap cmap;
- createPalette(cmap, vinfo, finfo);
- if (ioctl(d_ptr->fd, FBIOPUTCMAP, &cmap)) {
- perror("QLinuxFbScreen::initDevice");
- qWarning("Error writing palette to framebuffer");
- }
- free(cmap.red);
- free(cmap.green);
- free(cmap.blue);
- free(cmap.transp);
- }
-
- if (canaccel) {
- *entryp=0;
- *lowest = mapsize;
- insert_entry(*entryp, *lowest, *lowest); // dummy entry to mark start
- }
-
- shared->fifocount = 0;
- shared->buffer_offset = 0xffffffff; // 0 would be a sensible offset (screen)
- shared->linestep = 0;
- shared->cliptop = 0xffffffff;
- shared->clipleft = 0xffffffff;
- shared->clipright = 0xffffffff;
- shared->clipbottom = 0xffffffff;
- shared->rop = 0xffffffff;
-
-#ifdef QT_QWS_DEPTH_GENERIC
- if (pixelFormat() == QImage::Format_Invalid && screencols == 0
- && d_ptr->doGenericColors)
- {
- qt_set_generic_blit(this, vinfo.bits_per_pixel,
- vinfo.red.length, vinfo.green.length,
- vinfo.blue.length, vinfo.transp.length,
- vinfo.red.offset, vinfo.green.offset,
- vinfo.blue.offset, vinfo.transp.offset);
- }
-#endif
-
-#ifndef QT_NO_QWS_CURSOR
- QScreenCursor::initSoftwareCursor();
-#endif
- blank(false);
-
- return true;
-}
-
-/*
- The offscreen memory manager's list of entries is stored at the bottom
- of the offscreen memory area and consistes of a series of QPoolEntry's,
- each of which keep track of a block of allocated memory. Unallocated memory
- is implicitly indicated by the gap between blocks indicated by QPoolEntry's.
- The memory manager looks through any unallocated memory before the end
- of currently-allocated memory to see if a new block will fit in the gap;
- if it doesn't it allocated it from the end of currently-allocated memory.
- Memory is allocated from the top of the framebuffer downwards; if it hits
- the list of entries then offscreen memory is full and further allocations
- are made from main RAM (and hence unaccelerated). Allocated memory can
- be seen as a sort of upside-down stack; lowest keeps track of the
- bottom of the stack.
-*/
-
-void QLinuxFbScreen::delete_entry(int pos)
-{
- if (pos > *entryp || pos < 0) {
- qWarning("Attempt to delete odd pos! %d %d", pos, *entryp);
- return;
- }
-
-#ifdef DEBUG_CACHE
- qDebug("Remove entry: %d", pos);
-#endif
-
- QPoolEntry *qpe = &entries[pos];
- if (qpe->start <= *lowest) {
- // Lowest goes up again
- *lowest = entries[pos-1].start;
-#ifdef DEBUG_CACHE
- qDebug(" moved lowest to %d", *lowest);
-#endif
- }
-
- (*entryp)--;
- if (pos == *entryp)
- return;
-
- int size = (*entryp)-pos;
- memmove(&entries[pos], &entries[pos+1], size*sizeof(QPoolEntry));
-}
-
-void QLinuxFbScreen::insert_entry(int pos, int start, int end)
-{
- if (pos > *entryp) {
- qWarning("Attempt to insert odd pos! %d %d",pos,*entryp);
- return;
- }
-
-#ifdef DEBUG_CACHE
- qDebug("Insert entry: %d, %d -> %d", pos, start, end);
-#endif
-
- if (start < (int)*lowest) {
- *lowest = start;
-#ifdef DEBUG_CACHE
- qDebug(" moved lowest to %d", *lowest);
-#endif
- }
-
- if (pos == *entryp) {
- entries[pos].start = start;
- entries[pos].end = end;
- entries[pos].clientId = qws_client_id;
- (*entryp)++;
- return;
- }
-
- int size=(*entryp)-pos;
- memmove(&entries[pos+1],&entries[pos],size*sizeof(QPoolEntry));
- entries[pos].start=start;
- entries[pos].end=end;
- entries[pos].clientId=qws_client_id;
- (*entryp)++;
-}
-
-/*!
- \fn uchar * QLinuxFbScreen::cache(int amount)
-
- Requests the specified \a amount of offscreen graphics card memory
- from the memory manager, and returns a pointer to the data within
- the framebuffer (or 0 if there is no free memory).
-
- Note that the display is locked while memory is allocated in order to
- preserve the memory pool's integrity.
-
- Use the QScreen::onCard() function to retrieve an offset (in
- bytes) from the start of graphics card memory for the returned
- pointer.
-
- \sa uncache(), clearCache(), deleteEntry()
-*/
-
-uchar * QLinuxFbScreen::cache(int amount)
-{
- if (!canaccel || entryp == 0)
- return 0;
-
- qt_fbdpy->grab();
-
- int startp = cacheStart + (*entryp+1) * sizeof(QPoolEntry);
- if (startp >= (int)*lowest) {
- // We don't have room for another cache QPoolEntry.
-#ifdef DEBUG_CACHE
- qDebug("No room for pool entry in VRAM");
-#endif
- qt_fbdpy->ungrab();
- return 0;
- }
-
- int align = pixmapOffsetAlignment();
-
- if (*entryp > 1) {
- // Try to find a gap in the allocated blocks.
- for (int loopc = 0; loopc < *entryp-1; loopc++) {
- int freestart = entries[loopc+1].end;
- int freeend = entries[loopc].start;
- if (freestart != freeend) {
- while (freestart % align) {
- freestart++;
- }
- int len=freeend-freestart;
- if (len >= amount) {
- insert_entry(loopc+1, freestart, freestart+amount);
- qt_fbdpy->ungrab();
- return data+freestart;
- }
- }
- }
- }
-
- // No free blocks in already-taken memory; get some more
- // if we can
- int newlowest = (*lowest)-amount;
- if (newlowest % align) {
- newlowest -= align;
- while (newlowest % align) {
- newlowest++;
- }
- }
- if (startp >= newlowest) {
- qt_fbdpy->ungrab();
-#ifdef DEBUG_CACHE
- qDebug("No VRAM available for %d bytes", amount);
-#endif
- return 0;
- }
- insert_entry(*entryp, newlowest, *lowest);
- qt_fbdpy->ungrab();
-
- return data + newlowest;
-}
-
-/*!
- \fn void QLinuxFbScreen::uncache(uchar * memoryBlock)
-
- Deletes the specified \a memoryBlock allocated from the graphics
- card memory.
-
- Note that the display is locked while memory is unallocated in
- order to preserve the memory pool's integrity.
-
- This function will first sync the graphics card to ensure the
- memory isn't still being used by a command in the graphics card
- FIFO queue. It is possible to speed up a driver by overriding this
- function to avoid syncing. For example, the driver might delay
- deleting the memory until it detects that all commands dealing
- with the memory are no longer in the queue. Note that it will then
- be up to the driver to ensure that the specified \a memoryBlock no
- longer is being used.
-
- \sa cache(), deleteEntry(), clearCache()
- */
-void QLinuxFbScreen::uncache(uchar * c)
-{
- // need to sync graphics card
-
- deleteEntry(c);
-}
-
-/*!
- \fn void QLinuxFbScreen::deleteEntry(uchar * memoryBlock)
-
- Deletes the specified \a memoryBlock allocated from the graphics
- card memory.
-
- \sa uncache(), cache(), clearCache()
-*/
-void QLinuxFbScreen::deleteEntry(uchar * c)
-{
- qt_fbdpy->grab();
- unsigned long pos=(unsigned long)c;
- pos-=((unsigned long)data);
- unsigned int hold=(*entryp);
- for(unsigned int loopc=1;loopc<hold;loopc++) {
- if (entries[loopc].start==pos) {
- if (entries[loopc].clientId == qws_client_id)
- delete_entry(loopc);
- else
- qWarning("Attempt to delete client id %d cache entry",
- entries[loopc].clientId);
- qt_fbdpy->ungrab();
- return;
- }
- }
- qt_fbdpy->ungrab();
- qWarning("Attempt to delete unknown offset %ld",pos);
-}
-
-/*!
- Removes all entries from the cache for the specified screen \a
- instance and client identified by the given \a clientId.
-
- Calling this function should only be necessary if a client exits
- abnormally.
-
- \sa cache(), uncache(), deleteEntry()
-*/
-void QLinuxFbScreen::clearCache(QScreen *instance, int clientId)
-{
- QLinuxFbScreen *screen = (QLinuxFbScreen *)instance;
- if (!screen->canaccel || !screen->entryp)
- return;
- qt_fbdpy->grab();
- for (int loopc = 0; loopc < *(screen->entryp); loopc++) {
- if (screen->entries[loopc].clientId == clientId) {
- screen->delete_entry(loopc);
- loopc--;
- }
- }
- qt_fbdpy->ungrab();
-}
-
-
-void QLinuxFbScreen::setupOffScreen()
-{
- // Figure out position of offscreen memory
- // Set up pool entries pointer table and 64-bit align it
- int psize = size;
-
- // hw: this causes the limitation of cursors to 64x64
- // the cursor should rather use the normal pixmap mechanism
- psize += 4096; // cursor data
- psize += 8; // for alignment
- psize &= ~0x7; // align
-
- unsigned long pos = (unsigned long)data;
- pos += psize;
- entryp = ((int *)pos);
- lowest = ((unsigned int *)pos)+1;
- pos += (sizeof(int))*4;
- entries = (QPoolEntry *)pos;
-
- // beginning of offscreen memory available for pixmaps.
- cacheStart = psize + 4*sizeof(int) + sizeof(QPoolEntry);
-}
-
-/*!
- \reimp
-
- This is called by the \l{Qt for Embedded Linux} server when it shuts
- down, and should be inherited if you need to do any card-specific cleanup.
- The default version hides the screen cursor and reenables the blinking
- cursor and screen blanking.
-*/
-
-void QLinuxFbScreen::shutdownDevice()
-{
- // Causing crashes. Not needed.
- //setMode(startupw,startuph,startupd);
-/*
- if (startupd == 8) {
- ioctl(fd,FBIOPUTCMAP,startcmap);
- free(startcmap->red);
- free(startcmap->green);
- free(startcmap->blue);
- free(startcmap->transp);
- delete startcmap;
- startcmap = 0;
- }
-*/
- d_ptr->closeTty();
-}
-
-/*!
- \fn void QLinuxFbScreen::set(unsigned int index,unsigned int red,unsigned int green,unsigned int blue)
-
- Sets the specified color \a index to the specified RGB value, (\a
- red, \a green, \a blue), when in paletted graphics modes.
-*/
-
-void QLinuxFbScreen::set(unsigned int i,unsigned int r,unsigned int g,unsigned int b)
-{
- if (d_ptr->fd != -1) {
- fb_cmap cmap;
- cmap.start=i;
- cmap.len=1;
- cmap.red=(unsigned short int *)
- malloc(sizeof(unsigned short int)*256);
- cmap.green=(unsigned short int *)
- malloc(sizeof(unsigned short int)*256);
- cmap.blue=(unsigned short int *)
- malloc(sizeof(unsigned short int)*256);
- cmap.transp=(unsigned short int *)
- malloc(sizeof(unsigned short int)*256);
- cmap.red[0]=r << 8;
- cmap.green[0]=g << 8;
- cmap.blue[0]=b << 8;
- cmap.transp[0]=0;
- ioctl(d_ptr->fd, FBIOPUTCMAP, &cmap);
- free(cmap.red);
- free(cmap.green);
- free(cmap.blue);
- free(cmap.transp);
- }
- screenclut[i] = qRgb(r, g, b);
-}
-
-/*!
- \reimp
-
- Sets the framebuffer to a new resolution and bit depth. The width is
- in \a nw, the height is in \a nh, and the depth is in \a nd. After
- doing this any currently-existing paint engines will be invalid and the
- screen should be completely redrawn. In a multiple-process
- Embedded Qt situation you must signal all other applications to
- call setMode() to the same mode and redraw.
-*/
-
-void QLinuxFbScreen::setMode(int nw,int nh,int nd)
-{
- if (d_ptr->fd == -1)
- return;
-
- fb_fix_screeninfo finfo;
- fb_var_screeninfo vinfo;
- //#######################
- // Shut up Valgrind
- memset(&vinfo, 0, sizeof(vinfo));
- memset(&finfo, 0, sizeof(finfo));
- //#######################
-
- if (ioctl(d_ptr->fd, FBIOGET_VSCREENINFO, &vinfo)) {
- perror("QLinuxFbScreen::setMode");
- qFatal("Error reading variable information in mode change");
- }
-
- vinfo.xres=nw;
- vinfo.yres=nh;
- vinfo.bits_per_pixel=nd;
-
- if (ioctl(d_ptr->fd, FBIOPUT_VSCREENINFO, &vinfo)) {
- perror("QLinuxFbScreen::setMode");
- qCritical("Error writing variable information in mode change");
- }
-
- if (ioctl(d_ptr->fd, FBIOGET_VSCREENINFO, &vinfo)) {
- perror("QLinuxFbScreen::setMode");
- qFatal("Error reading changed variable information in mode change");
- }
-
- if (ioctl(d_ptr->fd, FBIOGET_FSCREENINFO, &finfo)) {
- perror("QLinuxFbScreen::setMode");
- qFatal("Error reading fixed information");
- }
-
- fixupScreenInfo(finfo, vinfo);
- disconnect();
- connect(d_ptr->displaySpec);
- exposeRegion(region(), 0);
-}
-
-// save the state of the graphics card
-// This is needed so that e.g. we can restore the palette when switching
-// between linux virtual consoles.
-
-/*!
- \reimp
-
- This doesn't do anything; accelerated drivers may wish to reimplement
- it to save graphics cards registers. It's called by the
- \l{Qt for Embedded Linux} server when the virtual console is switched.
-*/
-
-void QLinuxFbScreen::save()
-{
- // nothing to do.
-}
-
-
-// restore the state of the graphics card.
-/*!
- \reimp
-
- This is called when the virtual console is switched back to
- \l{Qt for Embedded Linux} and restores the palette.
-*/
-void QLinuxFbScreen::restore()
-{
- if (d_ptr->fd == -1)
- return;
-
- if ((d == 8) || (d == 4)) {
- fb_cmap cmap;
- cmap.start=0;
- cmap.len=screencols;
- cmap.red=(unsigned short int *)
- malloc(sizeof(unsigned short int)*256);
- cmap.green=(unsigned short int *)
- malloc(sizeof(unsigned short int)*256);
- cmap.blue=(unsigned short int *)
- malloc(sizeof(unsigned short int)*256);
- cmap.transp=(unsigned short int *)
- malloc(sizeof(unsigned short int)*256);
- for (int loopc = 0; loopc < screencols; loopc++) {
- cmap.red[loopc] = qRed(screenclut[loopc]) << 8;
- cmap.green[loopc] = qGreen(screenclut[loopc]) << 8;
- cmap.blue[loopc] = qBlue(screenclut[loopc]) << 8;
- cmap.transp[loopc] = 0;
- }
- ioctl(d_ptr->fd, FBIOPUTCMAP, &cmap);
- free(cmap.red);
- free(cmap.green);
- free(cmap.blue);
- free(cmap.transp);
- }
-}
-
-/*!
- \fn int QLinuxFbScreen::sharedRamSize(void * end)
- \internal
-*/
-
-// This works like the QScreenCursor code. end points to the end
-// of our shared structure, we return the amount of memory we reserved
-int QLinuxFbScreen::sharedRamSize(void * end)
-{
- shared=(QLinuxFb_Shared *)end;
- shared--;
- return sizeof(QLinuxFb_Shared);
-}
-
-/*!
- \reimp
-*/
-void QLinuxFbScreen::setDirty(const QRect &r)
-{
- if(d_ptr->driverType == EInk8Track) {
- // e-Ink displays need a trigger to actually show what is
- // in their framebuffer memory. The 8-Track driver does this
- // by adding custom IOCTLs - FBIO_EINK_DISP_PIC (0x46a2) takes
- // an argument specifying whether or not to flash the screen
- // while updating.
- // There doesn't seem to be a way to tell it to just update
- // a subset of the screen.
- if(r.left() == 0 && r.top() == 0 && r.width() == dw && r.height() == dh)
- ioctl(d_ptr->fd, 0x46a2, 1);
- else
- ioctl(d_ptr->fd, 0x46a2, 0);
- }
-}
-
-/*!
- \reimp
-*/
-void QLinuxFbScreen::blank(bool on)
-{
- if (d_ptr->blank == on)
- return;
-
-#if defined(QT_QWS_IPAQ)
- if (on)
- system("apm -suspend");
-#else
- if (d_ptr->fd == -1)
- return;
-// Some old kernel versions don't have this. These defines should go
-// away eventually
-#if defined(FBIOBLANK)
-#if defined(VESA_POWERDOWN) && defined(VESA_NO_BLANKING)
- ioctl(d_ptr->fd, FBIOBLANK, on ? VESA_POWERDOWN : VESA_NO_BLANKING);
-#else
- ioctl(d_ptr->fd, FBIOBLANK, on ? 1 : 0);
-#endif
-#endif
-#endif
-
- d_ptr->blank = on;
-}
-
-void QLinuxFbScreen::setPixelFormat(struct fb_var_screeninfo info)
-{
- const fb_bitfield rgba[4] = { info.red, info.green,
- info.blue, info.transp };
-
- QImage::Format format = QImage::Format_Invalid;
-
- switch (d) {
- case 32: {
- const fb_bitfield argb8888[4] = {{16, 8, 0}, {8, 8, 0},
- {0, 8, 0}, {24, 8, 0}};
- const fb_bitfield abgr8888[4] = {{0, 8, 0}, {8, 8, 0},
- {16, 8, 0}, {24, 8, 0}};
- if (memcmp(rgba, argb8888, 4 * sizeof(fb_bitfield)) == 0) {
- format = QImage::Format_ARGB32;
- } else if (memcmp(rgba, argb8888, 3 * sizeof(fb_bitfield)) == 0) {
- format = QImage::Format_RGB32;
- } else if (memcmp(rgba, abgr8888, 3 * sizeof(fb_bitfield)) == 0) {
- format = QImage::Format_RGB32;
- pixeltype = QScreen::BGRPixel;
- }
- break;
- }
- case 24: {
- const fb_bitfield rgb888[4] = {{16, 8, 0}, {8, 8, 0},
- {0, 8, 0}, {0, 0, 0}};
- const fb_bitfield bgr888[4] = {{0, 8, 0}, {8, 8, 0},
- {16, 8, 0}, {0, 0, 0}};
- if (memcmp(rgba, rgb888, 3 * sizeof(fb_bitfield)) == 0) {
- format = QImage::Format_RGB888;
- } else if (memcmp(rgba, bgr888, 3 * sizeof(fb_bitfield)) == 0) {
- format = QImage::Format_RGB888;
- pixeltype = QScreen::BGRPixel;
- }
- break;
- }
- case 18: {
- const fb_bitfield rgb666[4] = {{12, 6, 0}, {6, 6, 0},
- {0, 6, 0}, {0, 0, 0}};
- if (memcmp(rgba, rgb666, 3 * sizeof(fb_bitfield)) == 0)
- format = QImage::Format_RGB666;
- break;
- }
- case 16: {
- const fb_bitfield rgb565[4] = {{11, 5, 0}, {5, 6, 0},
- {0, 5, 0}, {0, 0, 0}};
- const fb_bitfield bgr565[4] = {{0, 5, 0}, {5, 6, 0},
- {11, 5, 0}, {0, 0, 0}};
- if (memcmp(rgba, rgb565, 3 * sizeof(fb_bitfield)) == 0) {
- format = QImage::Format_RGB16;
- } else if (memcmp(rgba, bgr565, 3 * sizeof(fb_bitfield)) == 0) {
- format = QImage::Format_RGB16;
- pixeltype = QScreen::BGRPixel;
- }
- break;
- }
- case 15: {
- const fb_bitfield rgb1555[4] = {{10, 5, 0}, {5, 5, 0},
- {0, 5, 0}, {15, 1, 0}};
- const fb_bitfield bgr1555[4] = {{0, 5, 0}, {5, 5, 0},
- {10, 5, 0}, {15, 1, 0}};
- if (memcmp(rgba, rgb1555, 3 * sizeof(fb_bitfield)) == 0) {
- format = QImage::Format_RGB555;
- } else if (memcmp(rgba, bgr1555, 3 * sizeof(fb_bitfield)) == 0) {
- format = QImage::Format_RGB555;
- pixeltype = QScreen::BGRPixel;
- }
- break;
- }
- case 12: {
- const fb_bitfield rgb444[4] = {{8, 4, 0}, {4, 4, 0},
- {0, 4, 0}, {0, 0, 0}};
- if (memcmp(rgba, rgb444, 3 * sizeof(fb_bitfield)) == 0)
- format = QImage::Format_RGB444;
- break;
- }
- case 8:
- break;
- case 1:
- format = QImage::Format_Mono; //###: LSB???
- break;
- default:
- break;
- }
-
- QScreen::setPixelFormat(format);
-}
-
-bool QLinuxFbScreen::useOffscreen()
-{
- // Not done for 8Track because on e-Ink displays,
- // everything is offscreen anyway
- if (d_ptr->driverType == EInk8Track || ((mapsize - size) < 16*1024))
- return false;
-
- return true;
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_LINUXFB
diff --git a/src/gui/embedded/qscreenlinuxfb_qws.h b/src/gui/embedded/qscreenlinuxfb_qws.h
deleted file mode 100644
index 4142bb5dd4..0000000000
--- a/src/gui/embedded/qscreenlinuxfb_qws.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSCREENLINUXFB_QWS_H
-#define QSCREENLINUXFB_QWS_H
-
-#include <QtGui/qscreen_qws.h>
-
-struct fb_cmap;
-struct fb_var_screeninfo;
-struct fb_fix_screeninfo;
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_QWS_LINUXFB
-
-class QLinuxFb_Shared
-{
-public:
- volatile int lastop;
- volatile int optype;
- volatile int fifocount; // Accel drivers only
- volatile int fifomax;
- volatile int forecol; // Foreground colour caching
- volatile unsigned int buffer_offset; // Destination
- volatile int linestep;
- volatile int cliptop; // Clip rectangle
- volatile int clipleft;
- volatile int clipright;
- volatile int clipbottom;
- volatile unsigned int rop;
-
-};
-
-class QLinuxFbScreenPrivate;
-
-class Q_GUI_EXPORT QLinuxFbScreen : public QScreen
-{
-public:
- explicit QLinuxFbScreen(int display_id);
- virtual ~QLinuxFbScreen();
-
- virtual bool initDevice();
- virtual bool connect(const QString &displaySpec);
-
- virtual bool useOffscreen();
-
- enum DriverTypes { GenericDriver, EInk8Track };
-
- virtual void disconnect();
- virtual void shutdownDevice();
- virtual void setMode(int,int,int);
- virtual void save();
- virtual void restore();
- virtual void blank(bool on);
- virtual void set(unsigned int,unsigned int,unsigned int,unsigned int);
- virtual uchar * cache(int);
- virtual void uncache(uchar *);
- virtual int sharedRamSize(void *);
- virtual void setDirty(const QRect&);
-
- QLinuxFb_Shared * shared;
-
-protected:
-
- void deleteEntry(uchar *);
-
- bool canaccel;
- int dataoffset;
- int cacheStart;
-
- virtual void fixupScreenInfo(fb_fix_screeninfo &finfo, fb_var_screeninfo &vinfo);
- static void clearCache(QScreen *instance, int);
-
-private:
-
- void delete_entry(int);
- void insert_entry(int,int,int);
- void setupOffScreen();
- void createPalette(fb_cmap &cmap, fb_var_screeninfo &vinfo, fb_fix_screeninfo &finfo);
- void setPixelFormat(struct fb_var_screeninfo);
-
- QLinuxFbScreenPrivate *d_ptr;
-};
-
-#endif // QT_NO_QWS_LINUXFB
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSCREENLINUXFB_QWS_H
diff --git a/src/gui/embedded/qscreenmulti_qws.cpp b/src/gui/embedded/qscreenmulti_qws.cpp
deleted file mode 100644
index 8a27a7cb82..0000000000
--- a/src/gui/embedded/qscreenmulti_qws.cpp
+++ /dev/null
@@ -1,486 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qscreenmulti_qws_p.h"
-
-#ifndef QT_NO_QWS_MULTISCREEN
-
-#include <qlist.h>
-#include <qstringlist.h>
-#include <qwidget.h>
-#include <qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_QWS_CURSOR
-
-class QMultiScreenCursor : public QScreenCursor
-{
-public:
- QMultiScreenCursor() : currentCursor(qt_screencursor) { enable = false; }
- ~QMultiScreenCursor() { qt_screencursor = 0; }
-
- void set(const QImage &image, int hotx, int hoty);
- void move(int x, int y);
- void show();
- void hide();
-
- void addCursor(QScreenCursor *cursor);
-
-private:
- void setCurrentCursor(QScreenCursor *newCursor);
-
- QScreenCursor *currentCursor;
- QList<QScreenCursor*> cursors;
-};
-
-void QMultiScreenCursor::set(const QImage &image, int hotx, int hoty)
-{
- QScreenCursor::set(image, hotx, hoty);
- if (currentCursor)
- currentCursor->set(image, hotx, hoty);
-}
-
-void QMultiScreenCursor::setCurrentCursor(QScreenCursor *newCursor)
-{
- *((QScreenCursor*)this) = *newCursor;
- currentCursor = newCursor;
-}
-
-// XXX: this is a mess!
-void QMultiScreenCursor::move(int x, int y)
-{
- const int oldIndex = qt_screen->subScreenIndexAt(pos);
- QScreenCursor::move(x, y); // updates pos
- const int newIndex = qt_screen->subScreenIndexAt(pos);
-
- if (!currentCursor && oldIndex != -1)
- setCurrentCursor(cursors.at(oldIndex));
- QScreenCursor *oldCursor = currentCursor;
-
- if (oldIndex != -1) {
- const QScreen *oldScreen = qt_screen->subScreens().at(oldIndex);
- if (newIndex == -1 || oldScreen->region().contains(pos)) {
- oldCursor->move(x, y);
- return;
- }
- }
-
- if (newIndex != -1) {
- QScreenCursor *newCursor = cursors.at(newIndex);
- newCursor->set(cursor, hotspot.x(), hotspot.y());
-
- if (oldCursor) {
- if (oldCursor->isVisible())
- newCursor->show();
- oldCursor->hide();
- }
-
- newCursor->move(x, y);
-
- setCurrentCursor(newCursor);
- }
-}
-
-void QMultiScreenCursor::show()
-{
- if (currentCursor)
- currentCursor->show();
-}
-
-void QMultiScreenCursor::hide()
-{
- if (currentCursor)
- currentCursor->hide();
-}
-
-void QMultiScreenCursor::addCursor(QScreenCursor *cursor)
-{
- cursors.append(cursor);
-}
-
-#endif
-
-class QMultiScreenPrivate
-{
-public:
- QMultiScreenPrivate()
-#ifndef QT_NO_QWS_CURSOR
- : cursor(0)
-#endif
- {}
- ~QMultiScreenPrivate()
- {
-#ifndef QT_NO_QWS_CURSOR
- delete cursor;
-#endif
- }
-
- QList<QScreen*> screens;
- QRegion region;
-#ifndef QT_NO_QWS_CURSOR
- QMultiScreenCursor *cursor;
-#endif
-};
-
-QMultiScreen::QMultiScreen(int displayId)
- : QScreen(displayId, MultiClass), d_ptr(new QMultiScreenPrivate)
-{
-}
-
-QMultiScreen::~QMultiScreen()
-{
- delete d_ptr;
-}
-
-bool QMultiScreen::initDevice()
-{
- bool ok = true;
-
-#ifndef QT_NO_QWS_CURSOR
- d_ptr->cursor = new QMultiScreenCursor;
-#endif
-
- const int n = d_ptr->screens.count();
- for (int i = 0; i < n; ++i) {
- QScreen *s = d_ptr->screens.at(i);
- ok = s->initDevice() && ok;
-#ifndef QT_NO_QWS_CURSOR
- d_ptr->cursor->addCursor(qt_screencursor); // XXX
-#endif
- }
-
-#ifndef QT_NO_QWS_CURSOR
- // XXX
- qt_screencursor = d_ptr->cursor;
-#endif
-
- return ok;
-}
-
-static int getDisplayId(const QString &spec)
-{
- QRegExp regexp(QLatin1String(":(\\d+)\\b"));
- if (regexp.lastIndexIn(spec) != -1) {
- const QString capture = regexp.cap(1);
- return capture.toInt();
- }
- return 0;
-}
-
-static QPoint filterDisplayOffset(QString &spec)
-{
- QRegExp regexp(QLatin1String(":offset=(\\d+),(\\d+)\\b"));
- if (regexp.indexIn(spec) == -1)
- return QPoint();
-
- const int x = regexp.cap(1).toInt();
- const int y = regexp.cap(2).toInt();
- spec.remove(regexp.pos(0), regexp.matchedLength());
- return QPoint(x, y);
-}
-
-bool QMultiScreen::connect(const QString &displaySpec)
-{
- QString dSpec = displaySpec;
- if (dSpec.startsWith(QLatin1String("Multi:"), Qt::CaseInsensitive))
- dSpec = dSpec.mid(QString::fromLatin1("Multi:").size());
-
- const QString displayIdSpec = QString::fromLatin1(" :%1").arg(displayId);
- if (dSpec.endsWith(displayIdSpec))
- dSpec = dSpec.left(dSpec.size() - displayIdSpec.size());
-
- QStringList specs = dSpec.split(QLatin1Char(' '), QString::SkipEmptyParts);
- foreach (QString spec, specs) {
- const int id = getDisplayId(spec);
- if (spec.startsWith("vnc:", Qt::CaseInsensitive)) {
- spec.append(":noDisablePainting");
- }
- const QPoint offset = filterDisplayOffset(spec);
- QScreen *s = qt_get_screen(id, spec.toLatin1().constData());
- s->setOffset(offset);
- addSubScreen(s);
- }
-
- QScreen *firstScreen = d_ptr->screens.at(0);
- Q_ASSERT(firstScreen);
-
- // XXX
- QScreen::d = firstScreen->depth();
-
- QScreen::lstep = 0;
- QScreen::data = 0;
- QScreen::size = 0;
-
- QScreen::w = d_ptr->region.boundingRect().width();
- QScreen::h = d_ptr->region.boundingRect().height();
-
- QScreen::dw = QScreen::w;
- QScreen::dh = QScreen::h;
-
- // XXX - Extend the physical size based on the first screen
- // to encompass all screens, so that code that uses the multi
- // screen to calculate dpi values will get the right numbers.
- QScreen::physWidth = firstScreen->physicalWidth() * w / firstScreen->width();
- QScreen::physHeight = firstScreen->physicalHeight() * h / firstScreen->height();
-
- // XXXXX
- qt_screen = this;
-
- return true;
-}
-
-void QMultiScreen::disconnect()
-{
- const int n = d_ptr->screens.size();
- for (int i = 0; i < n; ++i)
- d_ptr->screens.at(i)->disconnect();
-}
-
-void QMultiScreen::shutdownDevice()
-{
- const int n = d_ptr->screens.size();
- for (int i = 0; i < n; ++i)
- d_ptr->screens.at(i)->shutdownDevice();
-}
-
-void QMultiScreen::setMode(int, int, int)
-{
- return;
-}
-
-bool QMultiScreen::supportsDepth(int) const
-{
- return false;
-}
-
-void QMultiScreen::save()
-{
- const int n = d_ptr->screens.size();
- for (int i = 0; i < n; ++i)
- d_ptr->screens.at(i)->save();
-}
-
-void QMultiScreen::restore()
-{
- const int n = d_ptr->screens.size();
- for (int i = 0; i < n; ++i)
- d_ptr->screens.at(i)->restore();
-}
-
-void QMultiScreen::blank(bool on)
-{
- const int n = d_ptr->screens.size();
- for (int i = 0; i < n; ++i)
- d_ptr->screens.at(i)->blank(on);
-}
-
-bool QMultiScreen::onCard(const unsigned char *ptr) const
-{
- const int n = d_ptr->screens.size();
- for (int i = 0; i < n; ++i)
- if (d_ptr->screens.at(i)->onCard(ptr))
- return true;
- return false;
-}
-
-bool QMultiScreen::onCard(const unsigned char *ptr, ulong &offset) const
-{
- const int n = d_ptr->screens.size();
- for (int i = 0; i < n; ++i)
- if (d_ptr->screens.at(i)->onCard(ptr, offset))
- return true;
- return false;
-}
-
-bool QMultiScreen::isInterlaced() const
-{
- const int n = d_ptr->screens.size();
- for (int i = 0; i < n; ++i)
- if (d_ptr->screens.at(i)->isInterlaced())
- return true;
-
- return false;
-}
-
-int QMultiScreen::memoryNeeded(const QString &string)
-{
- int total = 0;
- const int n = d_ptr->screens.size();
- for (int i = 0; i < n; ++i)
- total += d_ptr->screens.at(i)->memoryNeeded(string);
- return total;
-}
-
-int QMultiScreen::sharedRamSize(void *arg)
-{
- int total = 0;
- const int n = d_ptr->screens.size();
- for (int i = 0; i < n; ++i)
- total += d_ptr->screens.at(i)->sharedRamSize(arg);
- return total;
-}
-
-void QMultiScreen::haltUpdates()
-{
- const int n = d_ptr->screens.size();
- for (int i = 0; i < n; ++i)
- d_ptr->screens.at(i)->haltUpdates();
-}
-
-void QMultiScreen::resumeUpdates()
-{
- const int n = d_ptr->screens.size();
- for (int i = 0; i < n; ++i)
- d_ptr->screens.at(i)->resumeUpdates();
-}
-
-void QMultiScreen::exposeRegion(QRegion region, int changing)
-{
- const int n = d_ptr->screens.size();
- for (int i = 0; i < n; ++i) {
- QScreen *screen = d_ptr->screens.at(i);
- const QRegion r = region & screen->region();
- if (r.isEmpty())
- continue;
- screen->exposeRegion(r, changing);
- }
-}
-
-void QMultiScreen::solidFill(const QColor &color, const QRegion &region)
-{
- const int n = d_ptr->screens.size();
- for (int i = 0; i < n; ++i) {
- QScreen *screen = d_ptr->screens.at(i);
- const QRegion r = region & screen->region();
- if (r.isEmpty())
- continue;
- screen->solidFill(color, r);
- }
-}
-
-void QMultiScreen::blit(const QImage &img, const QPoint &topLeft,
- const QRegion &region)
-{
- const int n = d_ptr->screens.size();
- for (int i = 0; i < n; ++i) {
- QScreen *screen = d_ptr->screens.at(i);
- const QRegion r = region & screen->region();
- if (r.isEmpty())
- continue;
- screen->blit(img, topLeft, r);
- }
-}
-
-void QMultiScreen::blit(QWSWindow *bs, const QRegion &clip)
-{
- const int n = d_ptr->screens.size();
- for (int i = 0; i < n; ++i) {
- QScreen *screen = d_ptr->screens.at(i);
- const QRegion r = clip & screen->region();
- if (r.isEmpty())
- continue;
- screen->blit(bs, r);
- }
-}
-
-void QMultiScreen::setDirty(const QRect &rect)
-{
- const int n = d_ptr->screens.size();
- for (int i = 0; i < n; ++i) {
- QScreen *screen = d_ptr->screens.at(i);
- const QRegion r = screen->region() & rect;
- if (r.isEmpty())
- continue;
- screen->setDirty(r.boundingRect());
- }
-}
-
-
-QWSWindowSurface* QMultiScreen::createSurface(const QString &key) const
-{
- QWSWindowSurface* surf = 0;
- const int n = d_ptr->screens.size();
- for (int i = 0; i < n; ++i) {
- QScreen *screen = d_ptr->screens.at(i);
- surf = screen->createSurface(key);
- if (surf)
- break;
- }
- return surf;
-}
-
-
-QWSWindowSurface* QMultiScreen::createSurface(QWidget *widget) const
-{
- const QPoint midpoint = (widget->frameGeometry().topLeft()
- + widget->frameGeometry().bottomRight()) / 2;
- int index = subScreenIndexAt(midpoint);
- if (index == -1)
- index = 0; // XXX
- return d_ptr->screens.at(index)->createSurface(widget);
-}
-
-QList<QScreen*> QMultiScreen::subScreens() const
-{
- return d_ptr->screens;
-}
-
-QRegion QMultiScreen::region() const
-{
- return d_ptr->region;
-}
-
-void QMultiScreen::addSubScreen(QScreen *screen)
-{
- d_ptr->screens.append(screen);
- d_ptr->region += screen->region();
-}
-
-void QMultiScreen::removeSubScreen(QScreen *screen)
-{
- d_ptr->screens.removeAll(screen);
- d_ptr->region -= screen->region();
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_MULTISCREEN
diff --git a/src/gui/embedded/qscreenmulti_qws_p.h b/src/gui/embedded/qscreenmulti_qws_p.h
deleted file mode 100644
index b7eba7e374..0000000000
--- a/src/gui/embedded/qscreenmulti_qws_p.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMULTISCREEN_QWS_P_H
-#define QMULTISCREEN_QWS_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QLibrary class. This header file may change from
-// version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <qscreen_qws.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_QWS_MULTISCREEN
-
-class QMultiScreenPrivate;
-
-class QMultiScreen : public QScreen
-{
-public:
- QMultiScreen(int displayId);
- ~QMultiScreen();
- bool initDevice();
- bool connect(const QString &displaySpec);
- void disconnect();
- void shutdownDevice();
- void setMode(int,int,int);
- bool supportsDepth(int) const;
-
- void save();
- void restore();
- void blank(bool on);
-
- bool onCard(const unsigned char *) const;
- bool onCard(const unsigned char *, ulong& out_offset) const;
-
- bool isInterlaced() const;
-
- int memoryNeeded(const QString&);
- int sharedRamSize(void *);
-
- void haltUpdates();
- void resumeUpdates();
-
- void exposeRegion(QRegion r, int changing);
-
- void blit(const QImage &img, const QPoint &topLeft, const QRegion &region);
- void solidFill(const QColor &color, const QRegion &region);
- void blit(QWSWindow *bs, const QRegion &clip);
- void setDirty(const QRect&);
-
- QWSWindowSurface* createSurface(QWidget *widget) const;
- QWSWindowSurface* createSurface(const QString &key) const;
-
- QList<QScreen*> subScreens() const;
- QRegion region() const;
-
-private:
- void addSubScreen(QScreen *screen);
- void removeSubScreen(QScreen *screen);
-
- QMultiScreenPrivate *d_ptr;
-};
-
-
-QT_END_NAMESPACE
-#endif // QT_NO_QWS_MULTISCREEN
-#endif // QMULTISCREEN_QWS_P_H
diff --git a/src/gui/embedded/qscreenproxy_qws.cpp b/src/gui/embedded/qscreenproxy_qws.cpp
deleted file mode 100644
index 706524ad19..0000000000
--- a/src/gui/embedded/qscreenproxy_qws.cpp
+++ /dev/null
@@ -1,635 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qscreenproxy_qws.h>
-
-#ifndef QT_NO_QWS_PROXYSCREEN
-
-#include <qregexp.h>
-
-QT_BEGIN_NAMESPACE
-#ifndef QT_NO_QWS_CURSOR
-
-/*!
- \class QProxyScreenCursor
- \since 4.5
- \ingroup qws
- \brief The QProxyScreenCursor class provides a generic interface to
- QScreenCursor implementations.
-*/
-
-/*!
- Constructs a proxy screen cursor.
-*/
-QProxyScreenCursor::QProxyScreenCursor()
- : QScreenCursor(), realCursor(0), d_ptr(0)
-{
-}
-
-/*!
- Destroys the proxy screen cursor.
-*/
-QProxyScreenCursor::~QProxyScreenCursor()
-{
-}
-
-/*!
- Sets the real screen cursor to be used for the proxy screen cursor to
- the \a cursor specified.
-
- \sa screenCursor()
-*/
-void QProxyScreenCursor::setScreenCursor(QScreenCursor *cursor)
-{
- realCursor = cursor;
- configure();
-}
-
-/*!
- Returns the real screen cursor used by the proxy screen cursor.
-
- \sa setScreenCursor()
-*/
-QScreenCursor* QProxyScreenCursor::screenCursor() const
-{
- return realCursor;
-}
-
-/*!
- \reimp
-*/
-void QProxyScreenCursor::set(const QImage &image, int hotx, int hoty)
-{
- if (realCursor) {
- hotspot = QPoint(hotx, hoty);
- cursor = image;
- size = image.size();
- realCursor->set(image, hotx, hoty);
- } else {
- QScreenCursor::set(image, hotx, hoty);
- }
-}
-
-/*!
- \reimp
-*/
-void QProxyScreenCursor::move(int x, int y)
-{
- if (realCursor) {
- pos = QPoint(x, y);
- realCursor->move(x, y);
- } else {
- QScreenCursor::move(x, y);
- }
-}
-
-/*!
- \reimp
-*/
-void QProxyScreenCursor::show()
-{
- if (realCursor) {
- realCursor->show();
- enable = true;
- } else {
- QScreenCursor::show();
- }
-}
-
-/*!
- \reimp
-*/
-void QProxyScreenCursor::hide()
-{
- if (realCursor) {
- realCursor->hide();
- enable = false;
- } else {
- QScreenCursor::hide();
- }
-}
-
-/*!
- \internal
-*/
-void QProxyScreenCursor::configure()
-{
- if (!realCursor)
- return;
-
- cursor = realCursor->cursor;
- size = realCursor->size;
- pos = realCursor->pos;
- hotspot = realCursor->hotspot;
- enable = realCursor->enable;
- hwaccel = realCursor->hwaccel;
- supportsAlpha = realCursor->supportsAlpha;
-}
-
-#endif // QT_NO_QWS_CURSOR
-
-/*!
- \class QProxyScreen
- \ingroup qws
- \brief The QProxyScreen class provides a generic interface to QScreen implementations.
-*/
-
-/*!
- \fn QProxyScreen::QProxyScreen(int displayId, ClassId classId)
-
- Constructs a proxy screen with the given \a displayId and \a classId.
-*/
-QProxyScreen::QProxyScreen(int displayId, QScreen::ClassId classId)
- : QScreen(displayId, classId), realScreen(0), d_ptr(0)
-{
-}
-
-/*!
- Destroys the proxy screen.
-*/
-QProxyScreen::~QProxyScreen()
-{
-}
-
-/*!
- Sets the real \a screen to be used by the proxy screen.
-
- \sa screen()
-*/
-void QProxyScreen::setScreen(QScreen *screen)
-{
- realScreen = screen;
- configure();
-}
-
-/*!
- Returns the real screen used by the proxy screen.
-
- \sa setScreen()
-*/
-QScreen* QProxyScreen::screen() const
-{
- return realScreen;
-}
-
-
-/*!
- \internal
-*/
-void QProxyScreen::configure()
-{
- if (!realScreen)
- return;
-
- d = realScreen->depth();
- w = realScreen->width();
- h = realScreen->height();
- dw = realScreen->deviceWidth();
- dh = realScreen->deviceHeight();
- lstep = realScreen->linestep();
- data = realScreen->base();
- lstep = realScreen->linestep();
- size = realScreen->screenSize();
- physWidth = realScreen->physicalWidth();
- physHeight = realScreen->physicalHeight();
- pixeltype = realScreen->pixelType();
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- setFrameBufferLittleEndian(realScreen->frameBufferLittleEndian());
-#endif
-
- setOffset(realScreen->offset());
- setPixelFormat(realScreen->pixelFormat());
-
-#ifdef QT_QWS_CLIENTBLIT
- setSupportsBlitInClients(realScreen->supportsBlitInClients());
-#endif
-}
-
-/*!
- \internal
- Returns the display ID that corresponds to the given \a spec.
-*/
-static int getDisplayId(const QString &spec)
-{
- QRegExp regexp(QLatin1String(":(\\d+)\\b"));
- if (regexp.lastIndexIn(spec) != -1) {
- const QString capture = regexp.cap(1);
- return capture.toInt();
- }
- return 0;
-}
-
-/*!
- \reimp
-*/
-bool QProxyScreen::connect(const QString &displaySpec)
-{
- const int id = getDisplayId(displaySpec);
- realScreen = qt_get_screen(id, displaySpec.toLatin1().constData());
- configure();
-
- return true;
-}
-
-/*!
- \reimp
-*/
-void QProxyScreen::exposeRegion(QRegion r, int changing)
-{
- if (!realScreen) {
- QScreen::exposeRegion(r, changing);
- return;
- }
-
- realScreen->exposeRegion(r, changing);
- r &= realScreen->region();
-
- const QVector<QRect> rects = r.rects();
- for (int i = 0; i < rects.size(); ++i)
- setDirty(rects.at(i));
-}
-
-/*!
- \reimp
-*/
-void QProxyScreen::blit(const QImage &image, const QPoint &topLeft,
- const QRegion &region)
-{
- if (!realScreen) {
- QScreen::blit(image, topLeft, region);
- return;
- }
-
- realScreen->blit(image, topLeft, region);
-}
-
-/*!
- \reimp
-*/
-void QProxyScreen::solidFill(const QColor &color, const QRegion &region)
-{
- if (!realScreen) {
- QScreen::solidFill(color, region);
- return;
- }
- realScreen->solidFill(color, region);
-}
-
-/*!
- \reimp
-*/
-QSize QProxyScreen::mapToDevice(const QSize &s) const
-{
- if (!realScreen)
- return QScreen::mapToDevice(s);
-
- return realScreen->mapToDevice(s);
-}
-
-/*!
- \reimp
-*/
-QSize QProxyScreen::mapFromDevice(const QSize &s) const
-{
- if (!realScreen)
- return QScreen::mapFromDevice(s);
-
- return realScreen->mapFromDevice(s);
-}
-
-/*!
- \reimp
-*/
-QPoint QProxyScreen::mapToDevice(const QPoint &p, const QSize &s) const
-{
- if (!realScreen)
- return QScreen::mapToDevice(p, s);
-
- return realScreen->mapToDevice(p, s);
-}
-
-/*!
- \reimp
-*/
-QPoint QProxyScreen::mapFromDevice(const QPoint &p, const QSize &s) const
-{
- if (!realScreen)
- return QScreen::mapFromDevice(p, s);
-
- return realScreen->mapFromDevice(p, s);
-}
-
-/*!
- \reimp
-*/
-QRect QProxyScreen::mapToDevice(const QRect &r, const QSize &s) const
-{
- if (!realScreen)
- return QScreen::mapToDevice(r, s);
-
- return realScreen->mapToDevice(r, s);
-}
-
-/*!
- \reimp
-*/
-QRect QProxyScreen::mapFromDevice(const QRect &r, const QSize &s) const
-{
- if (!realScreen)
- return QScreen::mapFromDevice(r, s);
-
- return realScreen->mapFromDevice(r, s);
-}
-
-/*!
- \reimp
-*/
-QRegion QProxyScreen::mapToDevice(const QRegion &r, const QSize &s) const
-{
- if (!realScreen)
- return QScreen::mapToDevice(r, s);
-
- return realScreen->mapToDevice(r, s);
-}
-
-/*!
- \reimp
-*/
-QRegion QProxyScreen::mapFromDevice(const QRegion &r, const QSize &s) const
-{
- if (!realScreen)
- return QScreen::mapFromDevice(r, s);
-
- return realScreen->mapFromDevice(r, s);
-}
-
-/*!
- \reimp
-*/
-void QProxyScreen::disconnect()
-{
- if (realScreen) {
- realScreen->disconnect();
- delete realScreen;
- realScreen = 0;
- }
-}
-
-/*!
-*/
-bool QProxyScreen::initDevice()
-{
- if (realScreen)
- return realScreen->initDevice();
-
- return false;
-}
-
-/*!
- \reimp
-*/
-void QProxyScreen::shutdownDevice()
-{
- if (realScreen)
- realScreen->shutdownDevice();
-}
-
-/*!
- \reimp
-*/
-void QProxyScreen::setMode(int w,int h, int d)
-{
- if (realScreen) {
- realScreen->setMode(w, h, d);
- } else {
- QScreen::dw = QScreen::w = w;
- QScreen::dh = QScreen::h = h;
- QScreen::d = d;
- }
- configure();
- exposeRegion(region(), 0);
-}
-
-/*!
- \reimp
-*/
-bool QProxyScreen::supportsDepth(int depth) const
-{
- if (realScreen)
- return realScreen->supportsDepth(depth);
- return false;
-}
-
-/*!
- \reimp
-*/
-void QProxyScreen::save()
-{
- if (realScreen)
- realScreen->save();
- QScreen::save();
-}
-
-/*!
- \reimp
-*/
-void QProxyScreen::restore()
-{
- if (realScreen)
- realScreen->restore();
- QScreen::restore();
-}
-
-/*!
- \reimp
-*/
-void QProxyScreen::blank(bool on)
-{
- if (realScreen)
- realScreen->blank(on);
-}
-
-/*!
- \reimp
-*/
-bool QProxyScreen::onCard(const unsigned char *ptr) const
-{
- if (realScreen)
- return realScreen->onCard(ptr);
- return false;
-}
-
-/*!
- \reimp
-*/
-bool QProxyScreen::onCard(const unsigned char *ptr, ulong &offset) const
-{
- if (realScreen)
- return realScreen->onCard(ptr, offset);
- return false;
-}
-
-/*!
- \reimp
-*/
-bool QProxyScreen::isInterlaced() const
-{
- if (realScreen)
- return realScreen->isInterlaced();
- return false;
-}
-
-/*!
- \reimp
-*/
-bool QProxyScreen::isTransformed() const
-{
- if (realScreen)
- return realScreen->isTransformed();
- return QScreen::isTransformed();
-}
-
-/*!
- \reimp
-*/
-int QProxyScreen::transformOrientation() const
-{
- if (realScreen)
- return realScreen->transformOrientation();
- return QScreen::transformOrientation();
-}
-
-/*!
-\internal
-*/
-int QProxyScreen::memoryNeeded(const QString &str)
-{
- if (realScreen)
- return realScreen->memoryNeeded(str);
- else
- return QScreen::memoryNeeded(str);
-}
-
-/*!
-\internal
-*/
-int QProxyScreen::sharedRamSize(void *ptr)
-{
- if (realScreen)
- return realScreen->sharedRamSize(ptr);
- else
- return QScreen::sharedRamSize(ptr);
-}
-
-/*!
-\internal
-*/
-void QProxyScreen::haltUpdates()
-{
- if (realScreen)
- realScreen->haltUpdates();
-}
-
-/*!
-\internal
-*/
-void QProxyScreen::resumeUpdates()
-{
- if (realScreen)
- realScreen->resumeUpdates();
-}
-
-/*!
- \reimp
-*/
-void QProxyScreen::setDirty(const QRect &rect)
-{
- if (realScreen)
- realScreen->setDirty(rect);
-}
-
-/*!
- \reimp
-*/
-QWSWindowSurface* QProxyScreen::createSurface(QWidget *widget) const
-{
- if (realScreen)
- return realScreen->createSurface(widget);
-
- return QScreen::createSurface(widget);
-}
-
-/*!
- \reimp
-*/
-QWSWindowSurface* QProxyScreen::createSurface(const QString &key) const
-{
- if (realScreen)
- return realScreen->createSurface(key);
-
- return QScreen::createSurface(key);
-}
-
-/*!
- \reimp
-*/
-QList<QScreen*> QProxyScreen::subScreens() const
-{
- if (realScreen)
- return realScreen->subScreens();
-
- return QScreen::subScreens();
-}
-
-/*!
- \reimp
-*/
-QRegion QProxyScreen::region() const
-{
- if (realScreen)
- return realScreen->region();
- else
- return QScreen::region();
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_PROXYSCREEN
diff --git a/src/gui/embedded/qscreenproxy_qws.h b/src/gui/embedded/qscreenproxy_qws.h
deleted file mode 100644
index bde36aa6bd..0000000000
--- a/src/gui/embedded/qscreenproxy_qws.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPROXYSCREEN_QWS_H
-#define QPROXYSCREEN_QWS_H
-
-#include <QtGui/qscreen_qws.h>
-
-#ifndef QT_NO_QWS_PROXYSCREEN
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QProxyScreenPrivate;
-
-#ifndef QT_NO_QWS_CURSOR
-
-class QProxyScreenCursorPrivate;
-
-class Q_GUI_EXPORT QProxyScreenCursor : public QScreenCursor
-{
-public:
- QProxyScreenCursor();
- ~QProxyScreenCursor();
-
- void setScreenCursor(QScreenCursor *cursor);
- QScreenCursor* screenCursor() const;
-
- void set(const QImage &image, int hotx, int hoty);
- void move(int x, int y);
- void show();
- void hide();
-
-private:
- void configure();
-
- QScreenCursor *realCursor;
- QProxyScreenCursorPrivate *d_ptr;
-};
-
-#endif // QT_NO_QWS_CURSOR
-
-class Q_GUI_EXPORT QProxyScreen : public QScreen
-{
-public:
- QProxyScreen(int display_id, ClassId = ProxyClass);
- ~QProxyScreen();
-
- void setScreen(QScreen *screen);
- QScreen *screen() const;
-
- QSize mapToDevice(const QSize &s) const;
- QSize mapFromDevice(const QSize &s) const;
-
- QPoint mapToDevice(const QPoint &, const QSize &) const;
- QPoint mapFromDevice(const QPoint &, const QSize &) const;
-
- QRect mapToDevice(const QRect &, const QSize &) const;
- QRect mapFromDevice(const QRect &, const QSize &) const;
-
- QRegion mapToDevice(const QRegion &, const QSize &) const;
- QRegion mapFromDevice(const QRegion &, const QSize &) const;
-
- bool connect(const QString &displaySpec);
- bool initDevice();
- void shutdownDevice();
- void disconnect();
-
- void setMode(int width, int height, int depth);
- bool supportsDepth(int) const;
-
- void save();
- void restore();
- void blank(bool on);
-
- bool onCard(const unsigned char *) const;
- bool onCard(const unsigned char *, ulong& out_offset) const;
-
- bool isInterlaced() const;
- bool isTransformed() const;
- int transformOrientation() const;
-
- int memoryNeeded(const QString&);
- int sharedRamSize(void *);
-
- void haltUpdates();
- void resumeUpdates();
-
- void exposeRegion(QRegion r, int changing);
- void blit(const QImage &img, const QPoint &topLeft, const QRegion &region);
- void solidFill(const QColor &color, const QRegion &region);
- void setDirty(const QRect&);
-
- QWSWindowSurface* createSurface(QWidget *widget) const;
- QWSWindowSurface* createSurface(const QString &key) const;
-
- QList<QScreen*> subScreens() const;
- QRegion region() const;
-
-private:
- void configure();
-
- QScreen *realScreen;
- QProxyScreenPrivate *d_ptr;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_QWS_PROXYSCREEN
-#endif // QPROXYSCREEN_QWS_H
diff --git a/src/gui/embedded/qscreenqnx_qws.cpp b/src/gui/embedded/qscreenqnx_qws.cpp
deleted file mode 100644
index 7101a71d83..0000000000
--- a/src/gui/embedded/qscreenqnx_qws.cpp
+++ /dev/null
@@ -1,450 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qscreenqnx_qws.h"
-#include "qdebug.h"
-
-#include <gf/gf.h>
-
-QT_BEGIN_NAMESPACE
-
-// This struct holds all the pointers to QNX's internals
-struct QQnxScreenContext
-{
- inline QQnxScreenContext()
- : device(0), display(0), layer(0), hwSurface(0), memSurface(0), context(0)
- {}
-
- gf_dev_t device;
- gf_dev_info_t deviceInfo;
- gf_display_t display;
- gf_display_info_t displayInfo;
- gf_layer_t layer;
- gf_surface_t hwSurface;
- gf_surface_t memSurface;
- gf_surface_info_t memSurfaceInfo;
- gf_context_t context;
-};
-
-/*!
- \class QQnxScreen
- \preliminary
- \ingroup qws
- \since 4.6
- \internal
-
- \brief The QQnxScreen class implements a screen driver
- for QNX io-display based devices.
-
- Note - you never have to instanciate this class, the QScreenDriverFactory
- does that for us based on the \c{QWS_DISPLAY} environment variable.
-
- To activate this driver, set \c{QWS_DISPLAY} to \c{qnx}.
-
- Example:
- \c{QWS_DISPLAY=qnx; export QWS_DISPLAY}
-
- By default, the main layer of the first display of the first device is used.
- If you have multiple graphic cards, multiple displays or multiple layers and
- don't want to connect to the default, you can override that with setting
- the corresponding options \c{device}, \c{display} or \c{layer} in the \c{QWS_DISPLAY} variable:
-
- \c{QWS_DISPLAY=qnx:device=3:display=4:layer=5}
-
- In addition, it is suggested to set the physical width and height of the display.
- QQnxScreen will use that information to compute the dots per inch (DPI) in order to render
- fonts correctly. If this informaiton is omitted, QQnxScreen defaults to 72 dpi.
-
- \c{QWS_DISPLAY=qnx:mmWidth=120:mmHeight=80}
-
- \c{mmWidth} and \c{mmHeight} are the physical width/height of the screen in millimeters.
-
- \sa QScreen, QScreenDriverPlugin, {Running Qt for Embedded Linux Applications}{Running Applications}
-*/
-
-/*!
- Constructs a QQnxScreen object. The \a display_id argument
- identifies the Qt for Embedded Linux server to connect to.
-*/
-QQnxScreen::QQnxScreen(int display_id)
- : QScreen(display_id), d(new QQnxScreenContext)
-{
-}
-
-/*!
- Destroys this QQnxScreen object.
-*/
-QQnxScreen::~QQnxScreen()
-{
- delete d;
-}
-
-/*! \reimp
-*/
-bool QQnxScreen::initDevice()
-{
- // implement this if you have multiple processes that want to access the display
- // (not required if QT_NO_QWS_MULTIPROCESS is set)
- return true;
-}
-
-/*! \internal
- Attaches to the named device \a name.
-*/
-static bool attachDevice(QQnxScreenContext * const d, const char *name)
-{
- int ret = gf_dev_attach(&d->device, name, &d->deviceInfo);
- if (ret != GF_ERR_OK) {
- qWarning("QQnxScreen: gf_dev_attach(%s) failed with error code %d", name, ret);
- return false;
- }
- return true;
-}
-
-/*! \internal
- Attaches to the display at index \a displayIndex.
- */
-static bool attachDisplay(QQnxScreenContext * const d, int displayIndex)
-{
- int ret = gf_display_attach(&d->display, d->device, displayIndex, &d->displayInfo);
- if (ret != GF_ERR_OK) {
- qWarning("QQnxScreen: gf_display_attach(%d) failed with error code %d",
- displayIndex, ret);
- return false;
- }
- return true;
-}
-
-/*! \internal
- Attaches to the layer \a layerIndex.
- */
-static bool attachLayer(QQnxScreenContext * const d, int layerIndex)
-{
- int ret = gf_layer_attach(&d->layer, d->display, layerIndex, 0);
- if (ret != GF_ERR_OK) {
- qWarning("QQnxScreen: gf_layer_attach(%d) failed with error code %d", layerIndex,
- ret);
- return false;
- }
- gf_layer_enable(d->layer);
-
- return true;
-}
-
-/*! \internal
- Creates a new hardware surface (usually on the Gfx card memory) with the dimensions \a w * \a h.
- */
-static bool createHwSurface(QQnxScreenContext * const d, int w, int h)
-{
- int ret = gf_surface_create_layer(&d->hwSurface, &d->layer, 1, 0,
- w, h, GF_FORMAT_ARGB8888, 0, 0);
- if (ret != GF_ERR_OK) {
- qWarning("QQnxScreen: gf_surface_create_layer(%dx%d) failed with error code %d",
- w, h, ret);
- return false;
- }
-
- gf_layer_set_surfaces(d->layer, &d->hwSurface, 1);
-
- ret = gf_layer_update(d->layer, 0);
- if (ret != GF_ERR_OK) {
- qWarning("QQnxScreen: gf_layer_update() failed with error code %d\n", ret);
- return false;
- }
-
- return true;
-}
-
-/*! \internal
- Creates an in-memory, linear accessible surface of dimensions \a w * \a h.
- This is the main surface that QWS blits to.
- */
-static bool createMemSurface(QQnxScreenContext * const d, int w, int h)
-{
- // Note: gf_surface_attach() could also be used, so we'll create the buffer
- // and let the surface point to it. Here, we use surface_create instead.
-
- int ret = gf_surface_create(&d->memSurface, d->device, w, h,
- GF_FORMAT_ARGB8888, 0,
- GF_SURFACE_CREATE_CPU_FAST_ACCESS | GF_SURFACE_CREATE_CPU_LINEAR_ACCESSIBLE
- | GF_SURFACE_PHYS_CONTIG | GF_SURFACE_CREATE_SHAREABLE);
- if (ret != GF_ERR_OK) {
- qWarning("QQnxScreen: gf_surface_create(%dx%d) failed with error code %d",
- w, h, ret);
- return false;
- }
-
- gf_surface_get_info(d->memSurface, &d->memSurfaceInfo);
-
- if (d->memSurfaceInfo.sid == unsigned(GF_SID_INVALID)) {
- qWarning("QQnxScreen: gf_surface_get_info() failed.");
- return false;
- }
-
- return true;
-}
-
-/* \internal
- Creates a QNX gf context and sets our memory surface on it.
- */
-static bool createContext(QQnxScreenContext * const d)
-{
- int ret = gf_context_create(&d->context);
- if (ret != GF_ERR_OK) {
- qWarning("QQnxScreen: gf_context_create() failed with error code %d", ret);
- return false;
- }
-
- ret = gf_context_set_surface(d->context, d->memSurface);
- if (ret != GF_ERR_OK) {
- qWarning("QQnxScreen: gf_context_set_surface() failed with error code %d", ret);
- return false;
- }
-
- return true;
-}
-
-/*! \reimp
- Connects to QNX's io-display based device based on the \a displaySpec parameters
- from the \c{QWS_DISPLAY} environment variable. See the QQnxScreen class documentation
- for possible parameters.
-
- \sa QQnxScreen
- */
-bool QQnxScreen::connect(const QString &displaySpec)
-{
- const QStringList params = displaySpec.split(QLatin1Char(':'), QString::SkipEmptyParts);
-
- bool isOk = false;
- QRegExp deviceRegExp(QLatin1String("^device=(.+)$"));
- if (params.indexOf(deviceRegExp) != -1) {
- isOk = attachDevice(d, deviceRegExp.cap(1).toLocal8Bit().constData());
- } else {
- // no device specified - attach to device 0 (the default)
- isOk = attachDevice(d, GF_DEVICE_INDEX(0));
- }
-
- if (!isOk)
- return false;
-
- qDebug("QQnxScreen: Attached to Device, number of displays: %d", d->deviceInfo.ndisplays);
-
- // default to display 0
- int displayIndex = 0;
- QRegExp displayRegexp(QLatin1String("^display=(\\d+)$"));
- if (params.indexOf(displayRegexp) != -1) {
- displayIndex = displayRegexp.cap(1).toInt();
- }
-
- if (!attachDisplay(d, displayIndex))
- return false;
-
- qDebug("QQnxScreen: Attached to Display %d, resolution %dx%d, refresh %d Hz",
- displayIndex, d->displayInfo.xres, d->displayInfo.yres,
- d->displayInfo.refresh);
-
-
- // default to main_layer_index from the displayInfo struct
- int layerIndex = 0;
- QRegExp layerRegexp(QLatin1String("^layer=(\\d+)$"));
- if (params.indexOf(layerRegexp) != -1) {
- layerIndex = layerRegexp.cap(1).toInt();
- } else {
- layerIndex = d->displayInfo.main_layer_index;
- }
-
- if (!attachLayer(d, layerIndex))
- return false;
-
- // tell QWSDisplay the width and height of the display
- w = dw = d->displayInfo.xres;
- h = dh = d->displayInfo.yres;
-
- // we only support 32 bit displays for now.
- QScreen::d = 32;
-
- // assume 72 dpi as default, to calculate the physical dimensions if not specified
- const int defaultDpi = 72;
-
- // Handle display physical size spec.
- QRegExp mmWidthRegexp(QLatin1String("^mmWidth=(\\d+)$"));
- if (params.indexOf(mmWidthRegexp) == -1) {
- physWidth = qRound(dw * 25.4 / defaultDpi);
- } else {
- physWidth = mmWidthRegexp.cap(1).toInt();
- }
-
- QRegExp mmHeightRegexp(QLatin1String("^mmHeight=(\\d+)$"));
- if (params.indexOf(mmHeightRegexp) == -1) {
- physHeight = qRound(dh * 25.4 / defaultDpi);
- } else {
- physHeight = mmHeightRegexp.cap(1).toInt();
- }
-
- // create a hardware surface with our dimensions. In the old days, it was possible
- // to get a pointer directly to the hw surface, so we could blit directly. Now, we
- // have to use one indirection more, because it's not guaranteed that the hw surface
- // is mappable into our process.
- if (!createHwSurface(d, w, h))
- return false;
-
- // create an in-memory linear surface that is used by QWS. QWS will blit directly in here.
- if (!createMemSurface(d, w, h))
- return false;
-
- // set the address of the in-memory buffer that QWS is blitting to
- data = d->memSurfaceInfo.vaddr;
- // set the line stepping
- lstep = d->memSurfaceInfo.stride;
-
- // the overall size of the in-memory buffer is linestep * height
- size = mapsize = lstep * h;
-
- // create a QNX drawing context
- if (!createContext(d))
- return false;
-
- // we're always using a software cursor for now. Initialize it here.
- QScreenCursor::initSoftwareCursor();
-
- // done, the driver should be connected to the display now.
- return true;
-}
-
-/*! \reimp
- */
-void QQnxScreen::disconnect()
-{
- if (d->context)
- gf_context_free(d->context);
-
- if (d->memSurface)
- gf_surface_free(d->memSurface);
-
- if (d->hwSurface)
- gf_surface_free(d->hwSurface);
-
- if (d->layer)
- gf_layer_detach(d->layer);
-
- if (d->display)
- gf_display_detach(d->display);
-
- if (d->device)
- gf_dev_detach(d->device);
-
- d->memSurface = 0;
- d->hwSurface = 0;
- d->context = 0;
- d->layer = 0;
- d->display = 0;
- d->device = 0;
-}
-
-/*! \reimp
- */
-void QQnxScreen::shutdownDevice()
-{
-}
-
-
-/*! \reimp
- QQnxScreen doesn't support setting the mode, use io-display instead.
- */
-void QQnxScreen::setMode(int,int,int)
-{
- qWarning("QQnxScreen: Unable to change mode, use io-display instead.");
-}
-
-/*! \reimp
- */
-bool QQnxScreen::supportsDepth(int depth) const
-{
- // only 32-bit for the moment
- return depth == 32;
-}
-
-/*! \reimp
- */
-void QQnxScreen::exposeRegion(QRegion r, int changing)
-{
- // here is where the actual magic happens. QWS will call exposeRegion whenever
- // a region on the screen is dirty and needs to be updated on the actual screen.
-
- // first, call the parent implementation. The parent implementation will update
- // the region on our in-memory surface
- QScreen::exposeRegion(r, changing);
-
- // now our in-memory surface should be up to date with the latest changes.
- // the code below copies the region from the in-memory surface to the hardware.
-
- // just get the bounding rectangle of the region. Most screen updates are rectangular
- // anyways. Code could be optimized to blit each and every member of the region
- // individually, but in real life, the speed-up is neglectable
- const QRect br = r.boundingRect();
- if (br.isEmpty())
- return; // ignore empty regions because gf_draw_blit2 doesn't like 0x0 dimensions
-
- // start drawing.
- int ret = gf_draw_begin(d->context);
- if (ret != GF_ERR_OK) {
- qWarning("QQnxScreen: gf_draw_begin() failed with error code %d", ret);
- return;
- }
-
- // blit the changed region from the memory surface to the hardware surface
- ret = gf_draw_blit2(d->context, d->memSurface, d->hwSurface,
- br.x(), br.y(), br.right(), br.bottom(), br.x(), br.y());
- if (ret != GF_ERR_OK) {
- qWarning("QQnxScreen: gf_draw_blit2() failed with error code %d", ret);
- }
-
- // flush all drawing commands (in our case, a single blit)
- ret = gf_draw_flush(d->context);
- if (ret != GF_ERR_OK) {
- qWarning("QQnxScreen: gf_draw_flush() failed with error code %d", ret);
- }
-
- // tell QNX that we're done drawing.
- gf_draw_end(d->context);
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/embedded/qscreenqnx_qws.h b/src/gui/embedded/qscreenqnx_qws.h
deleted file mode 100644
index 35915ae794..0000000000
--- a/src/gui/embedded/qscreenqnx_qws.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSCREENQNX_QWS_H
-#define QSCREENQNX_QWS_H
-
-#include <QtGui/qscreen_qws.h>
-
-#ifndef QT_NO_QWS_QNX
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-struct QQnxScreenContext;
-
-class QQnxScreen : public QScreen
-{
-public:
- explicit QQnxScreen(int display_id);
- ~QQnxScreen();
-
- bool initDevice();
- bool connect(const QString &displaySpec);
- void disconnect();
- void shutdownDevice();
- void setMode(int,int,int);
- bool supportsDepth(int) const;
-
- void exposeRegion(QRegion r, int changing);
-
-private:
- QQnxScreenContext * const d;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_QWS_QNX
-
-#endif
diff --git a/src/gui/embedded/qscreentransformed_qws.cpp b/src/gui/embedded/qscreentransformed_qws.cpp
deleted file mode 100644
index f37ab8084b..0000000000
--- a/src/gui/embedded/qscreentransformed_qws.cpp
+++ /dev/null
@@ -1,748 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qscreentransformed_qws.h"
-
-#ifndef QT_NO_QWS_TRANSFORMED
-#include <qscreendriverfactory_qws.h>
-#include <qvector.h>
-#include <private/qpainter_p.h>
-#include <private/qmemrotate_p.h>
-#include <qmatrix.h>
-
-#include <unistd.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#include <qwindowsystem_qws.h>
-#include <qwsdisplay_qws.h>
-
-QT_BEGIN_NAMESPACE
-
-//#define QT_REGION_DEBUG
-
-#ifdef QT_REGION_DEBUG
-#include <QDebug>
-#endif
-
-class QTransformedScreenPrivate
-{
-public:
- QTransformedScreenPrivate(QTransformedScreen *parent);
-
- void configure();
-
- QTransformedScreen::Transformation transformation;
-#ifdef QT_QWS_DEPTH_GENERIC
- bool doGenericColors;
-#endif
- QTransformedScreen *q;
-};
-
-QTransformedScreenPrivate::QTransformedScreenPrivate(QTransformedScreen *parent)
- : transformation(QTransformedScreen::None),
-#ifdef QT_QWS_DEPTH_GENERIC
- doGenericColors(false),
-#endif
- q(parent)
-{
-}
-
-extern "C"
-#ifndef QT_BUILD_GUI_LIB
-Q_DECL_EXPORT
-#endif
-void qws_setScreenTransformation(QScreen *that, int t)
-{
- QTransformedScreen *tscreen = static_cast<QTransformedScreen*>(that);
- tscreen->setTransformation((QTransformedScreen::Transformation)t);
-}
-
-// ---------------------------------------------------------------------------
-// Transformed Screen
-// ---------------------------------------------------------------------------
-
-/*!
- \internal
-
- \class QTransformedScreen
- \ingroup qws
-
- \brief The QTransformedScreen class implements a screen driver for
- a transformed screen.
-
- Note that this class is only available in \l{Qt for Embedded Linux}.
- Custom screen drivers can be added by subclassing the
- QScreenDriverPlugin class, using the QScreenDriverFactory class to
- dynamically load the driver into the application, but there should
- only be one screen object per application.
-
- Use the QScreen::isTransformed() function to determine if a screen
- is transformed. The QTransformedScreen class itself provides means
- of rotating the screen with its setTransformation() function; the
- transformation() function returns the currently set rotation in
- terms of the \l Transformation enum (which describes the various
- available rotation settings). Alternatively, QTransformedScreen
- provides an implementation of the QScreen::transformOrientation()
- function, returning the current rotation as an integer value.
-
- \sa QScreen, QScreenDriverPlugin, {Running Applications}
-*/
-
-/*!
- \enum QTransformedScreen::Transformation
-
- This enum describes the various rotations a transformed screen can
- have.
-
- \value None No rotation
- \value Rot90 90 degrees rotation
- \value Rot180 180 degrees rotation
- \value Rot270 270 degrees rotation
-*/
-
-/*!
- \fn bool QTransformedScreen::isTransformed() const
- \reimp
-*/
-
-/*!
- Constructs a QTransformedScreen object. The \a displayId argument
- identifies the Qt for Embedded Linux server to connect to.
-*/
-QTransformedScreen::QTransformedScreen(int displayId)
- : QProxyScreen(displayId, QScreen::TransformedClass)
-{
- d_ptr = new QTransformedScreenPrivate(this);
- d_ptr->transformation = None;
-
-#ifdef QT_REGION_DEBUG
- qDebug() << "QTransformedScreen::QTransformedScreen";
-#endif
-}
-
-void QTransformedScreenPrivate::configure()
-{
- // ###: works because setTransformation recalculates unconditionally
- q->setTransformation(transformation);
-}
-
-/*!
- Destroys the QTransformedScreen object.
-*/
-QTransformedScreen::~QTransformedScreen()
-{
- delete d_ptr;
-}
-
-static int getDisplayId(const QString &spec)
-{
- QRegExp regexp(QLatin1String(":(\\d+)\\b"));
- if (regexp.lastIndexIn(spec) != -1) {
- const QString capture = regexp.cap(1);
- return capture.toInt();
- }
- return 0;
-}
-
-static QTransformedScreen::Transformation filterTransformation(QString &spec)
-{
- QRegExp regexp(QLatin1String("\\bRot(\\d+):?\\b"), Qt::CaseInsensitive);
- if (regexp.indexIn(spec) == -1)
- return QTransformedScreen::None;
-
- const int degrees = regexp.cap(1).toInt();
- spec.remove(regexp.pos(0), regexp.matchedLength());
-
- return static_cast<QTransformedScreen::Transformation>(degrees / 90);
-}
-
-/*!
- \reimp
-*/
-bool QTransformedScreen::connect(const QString &displaySpec)
-{
- QString dspec = displaySpec.trimmed();
- if (dspec.startsWith(QLatin1String("Transformed:"), Qt::CaseInsensitive))
- dspec = dspec.mid(QString::fromLatin1("Transformed:").size());
- else if (!dspec.compare(QLatin1String("Transformed"), Qt::CaseInsensitive))
- dspec = QString();
-
- const QString displayIdSpec = QString::fromLatin1(" :%1").arg(displayId);
- if (dspec.endsWith(displayIdSpec))
- dspec = dspec.left(dspec.size() - displayIdSpec.size());
-
- d_ptr->transformation = filterTransformation(dspec);
-
- QString driver = dspec;
- int colon = driver.indexOf(QLatin1Char(':'));
- if (colon >= 0)
- driver.truncate(colon);
-
- if (!QScreenDriverFactory::keys().contains(driver, Qt::CaseInsensitive))
- if (!dspec.isEmpty())
- dspec.prepend(QLatin1Char(':'));
-
- const int id = getDisplayId(dspec);
- QScreen *s = qt_get_screen(id, dspec.toLatin1().constData());
- setScreen(s);
-
-#ifdef QT_QWS_DEPTH_GENERIC
- d_ptr->doGenericColors = dspec.contains(QLatin1String("genericcolors"));
-#endif
-
- d_ptr->configure();
-
- // XXX
- qt_screen = this;
-
- return true;
-}
-
-/*!
- Returns the currently set rotation.
-
- \sa setTransformation(), QScreen::transformOrientation()
-*/
-QTransformedScreen::Transformation QTransformedScreen::transformation() const
-{
- return d_ptr->transformation;
-}
-
-/*!
- \reimp
-*/
-int QTransformedScreen::transformOrientation() const
-{
- return (int)d_ptr->transformation;
-}
-
-/*!
- \reimp
-*/
-void QTransformedScreen::exposeRegion(QRegion region, int changing)
-{
- if (!data || d_ptr->transformation == None) {
- QProxyScreen::exposeRegion(region, changing);
- return;
- }
- QScreen::exposeRegion(region, changing);
-}
-
-/*!
- Rotates this screen object according to the specified \a transformation.
-
- \sa transformation()
-*/
-void QTransformedScreen::setTransformation(Transformation transformation)
-{
- d_ptr->transformation = transformation;
- QSize size = mapFromDevice(QSize(dw, dh));
- w = size.width();
- h = size.height();
-
- const QScreen *s = screen();
- size = mapFromDevice(QSize(s->physicalWidth(), s->physicalHeight()));
- physWidth = size.width();
- physHeight = size.height();
-
-#ifdef QT_REGION_DEBUG
- qDebug() << "QTransformedScreen::setTransformation" << transformation
- << "size" << w << h << "dev size" << dw << dh;
-#endif
-
-}
-
-static inline QRect correctNormalized(const QRect &r) {
- const int x1 = qMin(r.left(), r.right());
- const int x2 = qMax(r.left(), r.right());
- const int y1 = qMin(r.top(), r.bottom());
- const int y2 = qMax(r.top(), r.bottom());
-
- return QRect( QPoint(x1,y1), QPoint(x2,y2) );
-}
-
-template <class DST, class SRC>
-static inline void blit90(QScreen *screen, const QImage &image,
- const QRect &rect, const QPoint &topLeft)
-{
- const SRC *src = (const SRC*)(image.scanLine(rect.top())) + rect.left();
- DST *dest = (DST*)(screen->base() + topLeft.y() * screen->linestep())
- + topLeft.x();
- qt_memrotate90(src, rect.width(), rect.height(), image.bytesPerLine(),
- dest, screen->linestep());
-}
-
-template <class DST, class SRC>
-static inline void blit180(QScreen *screen, const QImage &image,
- const QRect &rect, const QPoint &topLeft)
-{
- const SRC *src = (const SRC*)(image.scanLine(rect.top())) + rect.left();
- DST *dest = (DST*)(screen->base() + topLeft.y() * screen->linestep())
- + topLeft.x();
- qt_memrotate180(src, rect.width(), rect.height(), image.bytesPerLine(),
- dest, screen->linestep());
-}
-
-template <class DST, class SRC>
-static inline void blit270(QScreen *screen, const QImage &image,
- const QRect &rect, const QPoint &topLeft)
-{
- const SRC *src = (const SRC *)(image.scanLine(rect.top())) + rect.left();
- DST *dest = (DST*)(screen->base() + topLeft.y() * screen->linestep())
- + topLeft.x();
- qt_memrotate270(src, rect.width(), rect.height(), image.bytesPerLine(),
- dest, screen->linestep());
-}
-
-typedef void (*BlitFunc)(QScreen *, const QImage &, const QRect &, const QPoint &);
-
-#define SET_BLIT_FUNC(dst, src, rotation, func) \
-do { \
- switch (rotation) { \
- case Rot90: \
- func = blit90<dst, src>; \
- break; \
- case Rot180: \
- func = blit180<dst, src>; \
- break; \
- case Rot270: \
- func = blit270<dst, src>; \
- break; \
- default: \
- break; \
- } \
-} while (0)
-
-/*!
- \reimp
-*/
-void QTransformedScreen::blit(const QImage &image, const QPoint &topLeft,
- const QRegion &region)
-{
- const Transformation trans = d_ptr->transformation;
- if (trans == None) {
- QProxyScreen::blit(image, topLeft, region);
- return;
- }
-
- const QVector<QRect> rects = region.rects();
- const QRect bound = QRect(0, 0, QScreen::w, QScreen::h)
- & QRect(topLeft, image.size());
-
- BlitFunc func = 0;
-#ifdef QT_QWS_DEPTH_GENERIC
- if (d_ptr->doGenericColors && depth() == 16) {
- if (image.depth() == 16)
- SET_BLIT_FUNC(qrgb_generic16, quint16, trans, func);
- else
- SET_BLIT_FUNC(qrgb_generic16, quint32, trans, func);
- } else
-#endif
- switch (depth()) {
-#ifdef QT_QWS_DEPTH_32
- case 32:
-#ifdef QT_QWS_DEPTH_16
- if (image.depth() == 16)
- SET_BLIT_FUNC(quint32, quint16, trans, func);
- else
-#endif
- SET_BLIT_FUNC(quint32, quint32, trans, func);
- break;
-#endif
-#if defined(QT_QWS_DEPTH_24) || defined(QT_QWS_DEPTH18)
- case 24:
- case 18:
- SET_BLIT_FUNC(quint24, quint24, trans, func);
- break;
-#endif
-#if defined(QT_QWS_DEPTH_16) || defined(QT_QWS_DEPTH_15) || defined(QT_QWS_DEPTH_12)
- case 16:
-#if defined QT_QWS_ROTATE_BGR
- if (pixelType() == BGRPixel && image.depth() == 16) {
- SET_BLIT_FUNC(qbgr565, quint16, trans, func);
- break;
- } //fall-through here!!!
-#endif
- case 15:
-#if defined QT_QWS_ROTATE_BGR
- if (pixelType() == BGRPixel && image.format() == QImage::Format_RGB555) {
- SET_BLIT_FUNC(qbgr555, qrgb555, trans, func);
- break;
- } //fall-through here!!!
-#endif
- case 12:
- if (image.depth() == 16)
- SET_BLIT_FUNC(quint16, quint16, trans, func);
- else
- SET_BLIT_FUNC(quint16, quint32, trans, func);
- break;
-#endif
-#ifdef QT_QWS_DEPTH_8
- case 8:
- if (image.format() == QImage::Format_RGB444)
- SET_BLIT_FUNC(quint8, qrgb444, trans, func);
- else if (image.depth() == 16)
- SET_BLIT_FUNC(quint8, quint16, trans, func);
- else
- SET_BLIT_FUNC(quint8, quint32, trans, func);
- break;
-#endif
- default:
- return;
- }
- if (!func)
- return;
-
- QWSDisplay::grab();
- for (int i = 0; i < rects.size(); ++i) {
- const QRect r = rects.at(i) & bound;
-
- QPoint dst;
- switch (trans) {
- case Rot90:
- dst = mapToDevice(r.topRight(), QSize(w, h));
- break;
- case Rot180:
- dst = mapToDevice(r.bottomRight(), QSize(w, h));
- break;
- case Rot270:
- dst = mapToDevice(r.bottomLeft(), QSize(w, h));
- break;
- default:
- break;
- }
- func(this, image, r.translated(-topLeft), dst);
- }
- QWSDisplay::ungrab();
-
-}
-
-/*!
- \reimp
-*/
-void QTransformedScreen::solidFill(const QColor &color, const QRegion &region)
-{
- const QRegion tr = mapToDevice(region, QSize(w,h));
-
- Q_ASSERT(tr.boundingRect() == mapToDevice(region.boundingRect(), QSize(w,h)));
-
-#ifdef QT_REGION_DEBUG
- qDebug() << "QTransformedScreen::solidFill region" << region << "transformed" << tr;
-#endif
- QProxyScreen::solidFill(color, tr);
-}
-
-/*!
- \reimp
-*/
-QSize QTransformedScreen::mapToDevice(const QSize &s) const
-{
- switch (d_ptr->transformation) {
- case None:
- case Rot180:
- break;
- case Rot90:
- case Rot270:
- return QSize(s.height(), s.width());
- break;
- }
- return s;
-}
-
-/*!
- \reimp
-*/
-QSize QTransformedScreen::mapFromDevice(const QSize &s) const
-{
- switch (d_ptr->transformation) {
- case None:
- case Rot180:
- break;
- case Rot90:
- case Rot270:
- return QSize(s.height(), s.width());
- break;
- }
- return s;
-}
-
-/*!
- \reimp
-*/
-QPoint QTransformedScreen::mapToDevice(const QPoint &p, const QSize &s) const
-{
- QPoint rp(p);
-
- switch (d_ptr->transformation) {
- case None:
- break;
- case Rot90:
- rp.setX(p.y());
- rp.setY(s.width() - p.x() - 1);
- break;
- case Rot180:
- rp.setX(s.width() - p.x() - 1);
- rp.setY(s.height() - p.y() - 1);
- break;
- case Rot270:
- rp.setX(s.height() - p.y() - 1);
- rp.setY(p.x());
- break;
- }
-
- return rp;
-}
-
-/*!
- \reimp
-*/
-QPoint QTransformedScreen::mapFromDevice(const QPoint &p, const QSize &s) const
-{
- QPoint rp(p);
-
- switch (d_ptr->transformation) {
- case None:
- break;
- case Rot90:
- rp.setX(s.height() - p.y() - 1);
- rp.setY(p.x());
- break;
- case Rot180:
- rp.setX(s.width() - p.x() - 1);
- rp.setY(s.height() - p.y() - 1);
- break;
- case Rot270:
- rp.setX(p.y());
- rp.setY(s.width() - p.x() - 1);
- break;
- }
-
- return rp;
-}
-
-/*!
- \reimp
-*/
-QRect QTransformedScreen::mapToDevice(const QRect &r, const QSize &s) const
-{
- if (r.isNull())
- return QRect();
-
- QRect tr;
- switch (d_ptr->transformation) {
- case None:
- tr = r;
- break;
- case Rot90:
- tr.setCoords(r.y(), s.width() - r.x() - 1,
- r.bottom(), s.width() - r.right() - 1);
- break;
- case Rot180:
- tr.setCoords(s.width() - r.x() - 1, s.height() - r.y() - 1,
- s.width() - r.right() - 1, s.height() - r.bottom() - 1);
- break;
- case Rot270:
- tr.setCoords(s.height() - r.y() - 1, r.x(),
- s.height() - r.bottom() - 1, r.right());
- break;
- }
-
- return correctNormalized(tr);
-}
-
-/*!
- \reimp
-*/
-QRect QTransformedScreen::mapFromDevice(const QRect &r, const QSize &s) const
-{
- if (r.isNull())
- return QRect();
-
- QRect tr;
- switch (d_ptr->transformation) {
- case None:
- tr = r;
- break;
- case Rot90:
- tr.setCoords(s.height() - r.y() - 1, r.x(),
- s.height() - r.bottom() - 1, r.right());
- break;
- case Rot180:
- tr.setCoords(s.width() - r.x() - 1, s.height() - r.y() - 1,
- s.width() - r.right() - 1, s.height() - r.bottom() - 1);
- break;
- case Rot270:
- tr.setCoords(r.y(), s.width() - r.x() - 1,
- r.bottom(), s.width() - r.right() - 1);
- break;
- }
-
- return correctNormalized(tr);
-}
-
-/*!
- \reimp
-*/
-QRegion QTransformedScreen::mapToDevice(const QRegion &rgn, const QSize &s) const
-{
- if (d_ptr->transformation == None)
- return QProxyScreen::mapToDevice(rgn, s);
-
-#ifdef QT_REGION_DEBUG
- qDebug() << "mapToDevice size" << s << "rgn: " << rgn;
-#endif
- QRect tr;
- QRegion trgn;
- QVector<QRect> a = rgn.rects();
- const QRect *r = a.data();
-
- int w = s.width();
- int h = s.height();
- int size = a.size();
-
- switch (d_ptr->transformation) {
- case None:
- break;
- case Rot90:
- for (int i = 0; i < size; i++, r++) {
- tr.setCoords(r->y(), w - r->x() - 1,
- r->bottom(), w - r->right() - 1);
- trgn |= correctNormalized(tr);
- }
- break;
- case Rot180:
- for (int i = 0; i < size; i++, r++) {
- tr.setCoords(w - r->x() - 1, h - r->y() - 1,
- w - r->right() - 1, h - r->bottom() - 1);
- trgn |= correctNormalized(tr);
- }
- break;
- case Rot270:
- for (int i = 0; i < size; i++, r++) {
- tr.setCoords(h - r->y() - 1, r->x(),
- h - r->bottom() - 1, r->right());
- trgn |= correctNormalized(tr);
- }
- break;
- }
-#ifdef QT_REGION_DEBUG
- qDebug() << "mapToDevice trgn: " << trgn;
-#endif
- return trgn;
-}
-
-/*!
- \reimp
-*/
-QRegion QTransformedScreen::mapFromDevice(const QRegion &rgn, const QSize &s) const
-{
- if (d_ptr->transformation == None)
- return QProxyScreen::mapFromDevice(rgn, s);
-
-#ifdef QT_REGION_DEBUG
- qDebug() << "fromDevice: realRegion count: " << rgn.rects().size() << " isEmpty? " << rgn.isEmpty() << " bounds:" << rgn.boundingRect();
-#endif
- QRect tr;
- QRegion trgn;
- QVector<QRect> a = rgn.rects();
- const QRect *r = a.data();
-
- int w = s.width();
- int h = s.height();
- int size = a.size();
-
- switch (d_ptr->transformation) {
- case None:
- break;
- case Rot90:
- for (int i = 0; i < size; i++, r++) {
- tr.setCoords(h - r->y() - 1, r->x(),
- h - r->bottom() - 1, r->right());
- trgn |= correctNormalized(tr);
- }
- break;
- case Rot180:
- for (int i = 0; i < size; i++, r++) {
- tr.setCoords(w - r->x() - 1, h - r->y() - 1,
- w - r->right() - 1, h - r->bottom() - 1);
- trgn |= correctNormalized(tr);
- }
- break;
- case Rot270:
- for (int i = 0; i < size; i++, r++) {
- tr.setCoords(r->y(), w - r->x() - 1,
- r->bottom(), w - r->right() - 1);
- trgn |= correctNormalized(tr);
- }
- break;
- }
-#ifdef QT_REGION_DEBUG
- qDebug() << "fromDevice: transRegion count: " << trgn.rects().size() << " isEmpty? " << trgn.isEmpty() << " bounds:" << trgn.boundingRect();
-#endif
- return trgn;
-}
-
-/*!
- \reimp
-*/
-void QTransformedScreen::setDirty(const QRect& rect)
-{
- const QRect r = mapToDevice(rect, QSize(width(), height()));
- QProxyScreen::setDirty(r);
-}
-
-/*!
- \reimp
-*/
-QRegion QTransformedScreen::region() const
-{
- QRegion deviceRegion = QProxyScreen::region();
- return mapFromDevice(deviceRegion, QSize(deviceWidth(), deviceHeight()));
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_TRANSFORMED
diff --git a/src/gui/embedded/qscreentransformed_qws.h b/src/gui/embedded/qscreentransformed_qws.h
deleted file mode 100644
index 70f5063387..0000000000
--- a/src/gui/embedded/qscreentransformed_qws.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSCREENTRANSFORMED_QWS_H
-#define QSCREENTRANSFORMED_QWS_H
-
-#include <QtGui/qscreenproxy_qws.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_QWS_TRANSFORMED
-
-class QTransformedScreenPrivate;
-
-class Q_AUTOTEST_EXPORT QTransformedScreen : public QProxyScreen
-{
-public:
- explicit QTransformedScreen(int display_id);
- ~QTransformedScreen();
-
- enum Transformation { None, Rot90, Rot180, Rot270 };
-
- void setTransformation(Transformation t);
- Transformation transformation() const;
- int transformOrientation() const;
-
- QSize mapToDevice(const QSize &s) const;
- QSize mapFromDevice(const QSize &s) const;
-
- QPoint mapToDevice(const QPoint &, const QSize &) const;
- QPoint mapFromDevice(const QPoint &, const QSize &) const;
-
- QRect mapToDevice(const QRect &, const QSize &) const;
- QRect mapFromDevice(const QRect &, const QSize &) const;
-
- QRegion mapToDevice(const QRegion &, const QSize &) const;
- QRegion mapFromDevice(const QRegion &, const QSize &) const;
-
- bool connect(const QString &displaySpec);
-
- bool isTransformed() const { return transformation() != None; }
-
- void exposeRegion(QRegion region, int changing);
- void blit(const QImage &img, const QPoint &topLeft, const QRegion &region);
- void solidFill(const QColor &color, const QRegion &region);
- void setDirty(const QRect&);
-
- QRegion region() const;
-
-private:
- friend class QTransformedScreenPrivate;
- QTransformedScreenPrivate *d_ptr;
-};
-
-#endif // QT_NO_QWS_TRANSFORMED
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSCREENTRANSFORMED_QWS_H
diff --git a/src/gui/embedded/qscreenvfb_qws.cpp b/src/gui/embedded/qscreenvfb_qws.cpp
deleted file mode 100644
index 1c8829d500..0000000000
--- a/src/gui/embedded/qscreenvfb_qws.cpp
+++ /dev/null
@@ -1,445 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QT_NO_QWS_QVFB
-
-#define QTOPIA_QVFB_BRIGHTNESS
-
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#include <qvfbhdr.h>
-#include <qscreenvfb_qws.h>
-#include <qkbdvfb_qws.h>
-#include <qmousevfb_qws.h>
-#include <qwindowsystem_qws.h>
-#include <qsocketnotifier.h>
-#include <qapplication.h>
-#include <qscreen_qws.h>
-#include <qmousedriverfactory_qws.h>
-#include <qkbddriverfactory_qws.h>
-#include <qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-class QVFbScreenPrivate
-{
-public:
- QVFbScreenPrivate();
- ~QVFbScreenPrivate();
-
- bool success;
- unsigned char *shmrgn;
- int brightness;
- bool blank;
- QVFbHeader *hdr;
- QWSMouseHandler *mouse;
-#ifndef QT_NO_QWS_KEYBOARD
- QWSKeyboardHandler *keyboard;
-#endif
-};
-
-QVFbScreenPrivate::QVFbScreenPrivate()
- : mouse(0)
-
-{
-#ifndef QT_NO_QWS_KEYBOARD
- keyboard = 0;
-#endif
- brightness = 255;
- blank = false;
-}
-
-QVFbScreenPrivate::~QVFbScreenPrivate()
-{
- delete mouse;
-#ifndef QT_NO_QWS_KEYBOARD
- delete keyboard;
-#endif
-}
-
-/*!
- \internal
-
- \class QVFbScreen
- \ingroup qws
-
- \brief The QVFbScreen class implements a screen driver for the
- virtual framebuffer.
-
- Note that this class is only available in \l{Qt for Embedded Linux}.
- Custom screen drivers can be added by subclassing the
- QScreenDriverPlugin class, using the QScreenDriverFactory class to
- dynamically load the driver into the application, but there should
- only be one screen object per application.
-
- The Qt for Embedded Linux platform provides a \l{The Virtual
- Framebuffer}{virtual framebuffer} for development and debugging;
- the virtual framebuffer allows Qt for Embedded Linux applications to be
- developed on a desktop machine, without switching between consoles
- and X11.
-
- \sa QScreen, QScreenDriverPlugin, {Running Applications}
-*/
-
-/*!
- \fn bool QVFbScreen::connect(const QString & displaySpec)
- \reimp
-*/
-
-/*!
- \fn void QVFbScreen::disconnect()
- \reimp
-*/
-
-/*!
- \fn bool QVFbScreen::initDevice()
- \reimp
-*/
-
-/*!
- \fn void QVFbScreen::restore()
- \reimp
-*/
-
-/*!
- \fn void QVFbScreen::save()
- \reimp
-*/
-
-/*!
- \fn void QVFbScreen::setDirty(const QRect & r)
- \reimp
-*/
-
-/*!
- \fn void QVFbScreen::setMode(int nw, int nh, int nd)
- \reimp
-*/
-
-/*!
- \fn void QVFbScreen::shutdownDevice()
- \reimp
-*/
-
-/*!
- \fn QVFbScreen::QVFbScreen(int displayId)
-
- Constructs a QVNCScreen object. The \a displayId argument
- identifies the Qt for Embedded Linux server to connect to.
-*/
-QVFbScreen::QVFbScreen(int display_id)
- : QScreen(display_id, VFbClass), d_ptr(new QVFbScreenPrivate)
-{
- d_ptr->shmrgn = 0;
- d_ptr->hdr = 0;
- data = 0;
-}
-
-/*!
- Destroys this QVFbScreen object.
-*/
-QVFbScreen::~QVFbScreen()
-{
- delete d_ptr;
-}
-
-static QVFbScreen *connected = 0;
-
-bool QVFbScreen::connect(const QString &displaySpec)
-{
- QStringList displayArgs = displaySpec.split(QLatin1Char(':'));
- if (displayArgs.contains(QLatin1String("Gray")))
- grayscale = true;
-
- key_t key = ftok(QT_VFB_MOUSE_PIPE(displayId).toLocal8Bit(), 'b');
-
- if (key == -1)
- return false;
-
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
-#ifndef QT_QWS_FRAMEBUFFER_LITTLE_ENDIAN
- if (displayArgs.contains(QLatin1String("littleendian")))
-#endif
- QScreen::setFrameBufferLittleEndian(true);
-#endif
-
- int shmId = shmget(key, 0, 0);
- if (shmId != -1)
- d_ptr->shmrgn = (unsigned char *)shmat(shmId, 0, 0);
- else
- return false;
-
- if ((long)d_ptr->shmrgn == -1 || d_ptr->shmrgn == 0) {
- qDebug("No shmrgn %ld", (long)d_ptr->shmrgn);
- return false;
- }
-
- d_ptr->hdr = (QVFbHeader *)d_ptr->shmrgn;
- data = d_ptr->shmrgn + d_ptr->hdr->dataoffset;
-
- dw = w = d_ptr->hdr->width;
- dh = h = d_ptr->hdr->height;
- d = d_ptr->hdr->depth;
-
- switch (d) {
- case 1:
- setPixelFormat(QImage::Format_Mono);
- break;
- case 8:
- setPixelFormat(QImage::Format_Indexed8);
- break;
- case 12:
- setPixelFormat(QImage::Format_RGB444);
- break;
- case 15:
- setPixelFormat(QImage::Format_RGB555);
- break;
- case 16:
- setPixelFormat(QImage::Format_RGB16);
- break;
- case 18:
- setPixelFormat(QImage::Format_RGB666);
- break;
- case 24:
- setPixelFormat(QImage::Format_RGB888);
- break;
- case 32:
- setPixelFormat(QImage::Format_ARGB32_Premultiplied);
- break;
- }
-
- lstep = d_ptr->hdr->linestep;
-
- // Handle display physical size spec.
- int dimIdxW = -1;
- int dimIdxH = -1;
- for (int i = 0; i < displayArgs.size(); ++i) {
- if (displayArgs.at(i).startsWith(QLatin1String("mmWidth"))) {
- dimIdxW = i;
- break;
- }
- }
- for (int i = 0; i < displayArgs.size(); ++i) {
- if (displayArgs.at(i).startsWith(QLatin1String("mmHeight"))) {
- dimIdxH = i;
- break;
- }
- }
- if (dimIdxW >= 0) {
- bool ok;
- int pos = 7;
- if (displayArgs.at(dimIdxW).at(pos) == QLatin1Char('='))
- ++pos;
- int pw = displayArgs.at(dimIdxW).mid(pos).toInt(&ok);
- if (ok) {
- physWidth = pw;
- if (dimIdxH < 0)
- physHeight = dh*physWidth/dw;
- }
- }
- if (dimIdxH >= 0) {
- bool ok;
- int pos = 8;
- if (displayArgs.at(dimIdxH).at(pos) == QLatin1Char('='))
- ++pos;
- int ph = displayArgs.at(dimIdxH).mid(pos).toInt(&ok);
- if (ok) {
- physHeight = ph;
- if (dimIdxW < 0)
- physWidth = dw*physHeight/dh;
- }
- }
- if (dimIdxW < 0 && dimIdxH < 0) {
- const int dpi = 72;
- physWidth = qRound(dw * 25.4 / dpi);
- physHeight = qRound(dh * 25.4 / dpi);
- }
-
- qDebug("Connected to VFB server %s: %d x %d x %d %dx%dmm (%dx%ddpi)", displaySpec.toLatin1().data(),
- w, h, d, physWidth, physHeight, qRound(dw*25.4/physWidth), qRound(dh*25.4/physHeight) );
-
- size = lstep * h;
- mapsize = size;
- screencols = d_ptr->hdr->numcols;
- memcpy(screenclut, d_ptr->hdr->clut, sizeof(QRgb) * screencols);
-
- connected = this;
-
- if (qgetenv("QT_QVFB_BGR").toInt())
- pixeltype = BGRPixel;
-
- return true;
-}
-
-void QVFbScreen::disconnect()
-{
- connected = 0;
- if ((long)d_ptr->shmrgn != -1 && d_ptr->shmrgn) {
- if (qApp->type() == QApplication::GuiServer && d_ptr->hdr->dataoffset >= (int)sizeof(QVFbHeader)) {
- d_ptr->hdr->serverVersion = 0;
- }
- shmdt((char*)d_ptr->shmrgn);
- }
-}
-
-bool QVFbScreen::initDevice()
-{
-#ifndef QT_NO_QWS_MOUSE_QVFB
- const QString mouseDev = QT_VFB_MOUSE_PIPE(displayId);
- d_ptr->mouse = new QVFbMouseHandler(QLatin1String("QVFbMouse"), mouseDev);
- qwsServer->setDefaultMouse("None");
- if (d_ptr->mouse)
- d_ptr->mouse->setScreen(this);
-#endif
-
-#if !defined(QT_NO_QWS_KBD_QVFB) && !defined(QT_NO_QWS_KEYBOARD)
- const QString keyboardDev = QT_VFB_KEYBOARD_PIPE(displayId);
- d_ptr->keyboard = new QVFbKeyboardHandler(keyboardDev);
- qwsServer->setDefaultKeyboard("None");
-#endif
-
- if (d_ptr->hdr->dataoffset >= (int)sizeof(QVFbHeader))
- d_ptr->hdr->serverVersion = QT_VERSION;
-
- if(d==8) {
- screencols=256;
- if (grayscale) {
- // Build grayscale palette
- for(int loopc=0;loopc<256;loopc++) {
- screenclut[loopc]=qRgb(loopc,loopc,loopc);
- }
- } else {
- // 6x6x6 216 color cube
- int idx = 0;
- for(int ir = 0x0; ir <= 0xff; ir+=0x33) {
- for(int ig = 0x0; ig <= 0xff; ig+=0x33) {
- for(int ib = 0x0; ib <= 0xff; ib+=0x33) {
- screenclut[idx]=qRgb(ir, ig, ib);
- idx++;
- }
- }
- }
- screencols=idx;
- }
- memcpy(d_ptr->hdr->clut, screenclut, sizeof(QRgb) * screencols);
- d_ptr->hdr->numcols = screencols;
- } else if (d == 4) {
- int val = 0;
- for (int idx = 0; idx < 16; idx++, val += 17) {
- screenclut[idx] = qRgb(val, val, val);
- }
- screencols = 16;
- memcpy(d_ptr->hdr->clut, screenclut, sizeof(QRgb) * screencols);
- d_ptr->hdr->numcols = screencols;
- } else if (d == 1) {
- screencols = 2;
- screenclut[1] = qRgb(0xff, 0xff, 0xff);
- screenclut[0] = qRgb(0, 0, 0);
- memcpy(d_ptr->hdr->clut, screenclut, sizeof(QRgb) * screencols);
- d_ptr->hdr->numcols = screencols;
- }
-
-#ifndef QT_NO_QWS_CURSOR
- QScreenCursor::initSoftwareCursor();
-#endif
- return true;
-}
-
-void QVFbScreen::shutdownDevice()
-{
-}
-
-void QVFbScreen::setMode(int ,int ,int)
-{
-}
-
-// save the state of the graphics card
-// This is needed so that e.g. we can restore the palette when switching
-// between linux virtual consoles.
-void QVFbScreen::save()
-{
- // nothing to do.
-}
-
-// restore the state of the graphics card.
-void QVFbScreen::restore()
-{
-}
-void QVFbScreen::setDirty(const QRect& rect)
-{
- const QRect r = rect.translated(-offset());
- d_ptr->hdr->dirty = true;
- d_ptr->hdr->update = d_ptr->hdr->update.united(r);
-}
-
-void QVFbScreen::setBrightness(int b)
-{
- if (connected) {
- connected->d_ptr->brightness = b;
-
- QVFbHeader *hdr = connected->d_ptr->hdr;
- if (hdr->viewerVersion < 0x040400) // brightness not supported
- return;
-
- const int br = connected->d_ptr->blank ? 0 : b;
- if (hdr->brightness != br) {
- hdr->brightness = br;
- connected->setDirty(connected->region().boundingRect());
- }
- }
-}
-
-void QVFbScreen::blank(bool on)
-{
- d_ptr->blank = on;
- setBrightness(connected->d_ptr->brightness);
-}
-
-#endif // QT_NO_QWS_QVFB
-
-QT_END_NAMESPACE
diff --git a/src/gui/embedded/qscreenvfb_qws.h b/src/gui/embedded/qscreenvfb_qws.h
deleted file mode 100644
index dc5ff54a1b..0000000000
--- a/src/gui/embedded/qscreenvfb_qws.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSCREENVFB_QWS_H
-#define QSCREENVFB_QWS_H
-
-#include <QtGui/qscreen_qws.h>
-#include <QtGui/qvfbhdr.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_QWS_QVFB
-
-class QVFbScreenPrivate;
-
-class Q_GUI_EXPORT QVFbScreen : public QScreen
-{
-public:
- explicit QVFbScreen(int display_id);
- virtual ~QVFbScreen();
- virtual bool initDevice();
- virtual bool connect(const QString &displaySpec);
- virtual void disconnect();
- virtual void shutdownDevice();
- virtual void save();
- virtual void restore();
- virtual void setMode(int nw,int nh,int nd);
- virtual void setDirty(const QRect& r);
- virtual void blank(bool);
-#ifdef QTOPIA_QVFB_BRIGHTNESS
- static void setBrightness(int b);
-#endif
-
-private:
- QVFbScreenPrivate *d_ptr;
-};
-
-#endif // QT_NO_QWS_QVFB
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSCREENVFB_QWS_H
diff --git a/src/gui/embedded/qsoundqss_qws.cpp b/src/gui/embedded/qsoundqss_qws.cpp
deleted file mode 100644
index bd6da77d4c..0000000000
--- a/src/gui/embedded/qsoundqss_qws.cpp
+++ /dev/null
@@ -1,1530 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qsoundqss_qws.h"
-
-#ifndef QT_NO_SOUND
-#include <qbytearray.h>
-#include <qlist.h>
-#include <qsocketnotifier.h>
-#include <qfile.h>
-#include <qfileinfo.h>
-#include <qstringlist.h>
-#include <qevent.h>
-#include <qalgorithms.h>
-#include <qtimer.h>
-#include <qpointer.h>
-#include <qendian.h>
-#include <private/qcore_unix_p.h> // overrides QT_OPEN
-
-#include <unistd.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <sys/soundcard.h>
-
-#include <qdebug.h>
-
-#include <qvfbhdr.h>
-
-extern int errno;
-
-QT_BEGIN_NAMESPACE
-
-#define QT_QWS_SOUND_16BIT 1 // or 0, or undefined for always 0
-#define QT_QWS_SOUND_STEREO 1 // or 0, or undefined for always 0
-
-// Zaurus SL5000D doesn't seem to return any error if setting to 44000 and it fails,
-// however 44100 works, 44100 is more common that 44000.
-static int sound_speed = 44100;
-#ifndef QT_NO_QWS_SOUNDSERVER
-extern int qws_display_id;
-#endif
-
-static char *zeroMem = 0;
-
-struct QRiffChunk {
- char id[4];
- quint32 size;
- char data[4/*size*/];
-};
-
-#if defined(QT_QWS_IPAQ)
-static const int sound_fragment_size = 12;
-#else
-static const int sound_fragment_size = 12;
-#endif
-static const int sound_buffer_size = 1 << sound_fragment_size;
-// nb. there will be an sound startup delay of
-// 2^sound_fragment_size / sound_speed seconds.
-// (eg. sound_fragment_size==12, sound_speed==44000 means 0.093s delay)
-
-#ifdef QT_QWS_SOUND_STEREO
-static int sound_stereo=QT_QWS_SOUND_STEREO;
-#else
-static const int sound_stereo=0;
-#endif
-#ifdef QT_QWS_SOUND_16BIT
-static bool sound_16bit=QT_QWS_SOUND_16BIT;
-#else
-static const bool sound_16bit=false;
-#endif
-
-#ifndef QT_NO_QWS_SOUNDSERVER
-class QWSSoundServerClient : public QObject {
- Q_OBJECT
-
-public:
- QWSSoundServerClient(QWS_SOCK_BASE *s, QObject* parent);
- ~QWSSoundServerClient();
-
-public slots:
- void sendSoundCompleted(int, int);
- void sendDeviceReady(int, int);
- void sendDeviceError(int, int, int);
-
-signals:
- void play(int, int, const QString&);
- void play(int, int, const QString&, int, int);
- void playRaw(int, int, const QString&, int, int, int, int);
-
- void pause(int, int);
- void stop(int, int);
- void resume(int, int);
- void setVolume(int, int, int, int);
- void setMute(int, int, bool);
-
- void stopAll(int);
-
- void playPriorityOnly(bool);
-
- void setSilent( bool );
-
-private slots:
- void tryReadCommand();
-
-private:
- void sendClientMessage(QString msg);
- int mCurrentID;
- int left, right;
- bool priExist;
- static int lastId;
- static int nextId() { return ++lastId; }
- QPointer<QWS_SOCK_BASE> socket;
-};
-
-int QWSSoundServerClient::lastId = 0;
-
-QWSSoundServerClient::QWSSoundServerClient(QWS_SOCK_BASE *s, QObject* parent) :
- QObject( parent )
-{
- socket = s;
- priExist = false;
- mCurrentID = nextId();
- connect(socket,SIGNAL(readyRead()),
- this,SLOT(tryReadCommand()));
- connect(socket, SIGNAL(disconnected()), this, SLOT(deleteLater()));
-}
-
-QWSSoundServerClient::~QWSSoundServerClient()
-{
- if (priExist)
- playPriorityOnly(false);
- emit stopAll(mCurrentID);
- if (socket)
- socket->deleteLater();
-}
-
-static QString getStringTok(QString &in)
-{
- int pos = in.indexOf(QLatin1Char(' '));
- QString ret;
- if (pos > 0) {
- ret = in.left(pos);
- in = in.mid(pos+1);
- } else {
- ret = in;
- in = QString::null;
- }
- return ret;
-}
-
-static int getNumTok(QString &in)
-{
- return getStringTok(in).toInt();
-}
-
-void QWSSoundServerClient::tryReadCommand()
-{
- while ( socket->canReadLine() ) {
- QString l = QString::fromAscii(socket->readLine());
- l.truncate(l.length()-1); // chomp
- QString functionName = getStringTok(l);
- int soundid = getNumTok(l);
- if (functionName == QLatin1String("PLAY")) {
- emit play(mCurrentID, soundid, l);
- } else if (functionName == QLatin1String("PLAYEXTEND")) {
- int volume = getNumTok(l);
- int flags = getNumTok(l);
- emit play(mCurrentID, soundid, l, volume, flags);
- } else if (functionName == QLatin1String("PLAYRAW")) {
- int chs = getNumTok(l);
- int freq = getNumTok(l);
- int bitspersample = getNumTok(l);
- int flags = getNumTok(l);
- emit playRaw(mCurrentID, soundid, l, freq, chs, bitspersample, flags);
- } else if (functionName == QLatin1String("PAUSE")) {
- emit pause(mCurrentID, soundid);
- } else if (functionName == QLatin1String("STOP")) {
- emit stop(mCurrentID, soundid);
- } else if (functionName == QLatin1String("RESUME")) {
- emit resume(mCurrentID, soundid);
- } else if (functionName == QLatin1String("SETVOLUME")) {
- int left = getNumTok(l);
- int right = getNumTok(l);
- emit setVolume(mCurrentID, soundid, left, right);
- } else if (functionName == QLatin1String("MUTE")) {
- emit setMute(mCurrentID, soundid, true);
- } else if (functionName == QLatin1String("UNMUTE")) {
- emit setMute(mCurrentID, soundid, false);
- } else if (functionName == QLatin1String("PRIORITYONLY")) {
- bool sPri = soundid != 0;
- if (sPri != priExist) {
- priExist = sPri;
- emit playPriorityOnly(sPri);
- }
- } else if(functionName == QLatin1String("SILENT")) {
- emit setSilent( soundid != 0 );
- }
- }
-}
-
-void QWSSoundServerClient::sendClientMessage(QString msg)
-{
-#ifndef QT_NO_TEXTCODEC
- QByteArray u = msg.toUtf8();
-#else
- QByteArray u = msg.toLatin1();
-#endif
- socket->write(u.data(), u.length());
- socket->flush();
-}
-
-void QWSSoundServerClient::sendSoundCompleted(int gid, int sid)
-{
- if (gid == mCurrentID)
- sendClientMessage(QLatin1String("SOUNDCOMPLETED ")
- + QString::number(sid) + QLatin1Char('\n'));
-}
-
-void QWSSoundServerClient::sendDeviceReady(int gid, int sid)
-{
- if (gid == mCurrentID)
- sendClientMessage(QLatin1String("DEVICEREADY ")
- + QString::number(sid) + QLatin1Char('\n'));
-}
-
-void QWSSoundServerClient::sendDeviceError(int gid, int sid, int err)
-{
- if (gid == mCurrentID)
- sendClientMessage(QLatin1String("DEVICEERROR ")
- + QString::number(sid) + QLatin1Char(' ')
- + QString::number(err) + QLatin1Char('\n'));
-}
-#endif
-
-static const int maxVolume = 100;
-static const int runinLength = 2*sound_buffer_size;
-class QWSSoundServerProvider {
-public:
- QWSSoundServerProvider(int w, int s)
- : mWid(w), mSid(s), mMuted(false)
- {
- leftVolume = maxVolume>>1;
- rightVolume = maxVolume>>1;
- isPriority = false;
- samples_due = 0;
- max1 = max2 = out = 0;// = sound_buffer_size;
- data = data1;
- max = &max1;
- sampleRunin = 0;
- dev = -1;
- }
-
- virtual ~QWSSoundServerProvider() {
- }
-
- int groupId() const { return mWid; }
- int soundId() const { return mSid; }
-
- void startSampleRunin() {
- // inteded to provide even audio return from mute/pause/dead samples.
- //sampleRunin = runinLength; // or more?
- }
-
-
- void setVolume(int lv, int rv) {
- leftVolume = qMin(maxVolume, qMax(0, lv));
- rightVolume = qMin(maxVolume, qMax(0, rv));
- }
-
- void setMute(bool m) { mMuted = m; }
- bool muted() { return mMuted; }
-
- void setPriority(bool p) {
- if (p != isPriority) {
- isPriority = p; // currently meaningless.
- }
- }
-
-
- static void setPlayPriorityOnly(bool p)
- {
- if (p)
- priorityExists++;
- else
- priorityExists--;
-
- if (priorityExists < 0)
- qDebug("QSS: got more priority offs than ons");
- }
-
- // return -1 for file broken, give up.
- // else return sampels ready for playing.
- // argument is max samples server is looking for,
- // in terms of current device status.
- virtual int readySamples(int) = 0;
-
- int getSample(int off, int bps) {
-
- //
- // 16-bit audio data is converted to native endian so that it can be scaled
- // Yes, this is ugly on a BigEndian machine
- // Perhaps it shouldn't be scaled at all
- //
- return (bps == 1) ? (data[out+off] - 128) * 128 : qToLittleEndian(((short*)data)[(out/2)+off]);
- }
-
- int add(int* mixl, int* mixr, int count)
- {
- int bytesPerSample = chunkdata.wBitsPerSample >> 3;
-
- if ( mMuted ) {
- sampleRunin -= qMin(sampleRunin,count);
- while (count && (dev != -1)) {
- if (out >= *max) {
- // switch buffers
- out = 0;
- if (data == data1 && max2 != 0) {
- data = data2;
- max = &max2;
- max1 = 0;
- } else if (data == data2 && max1 != 0) {
- data = data1;
- max = &max1;
- max2 = 0;
- } else {
- qDebug("QSS Read Error: both buffers empty");
- return 0;
- }
- }
- samples_due += sound_speed;
- while (count && samples_due >= chunkdata.samplesPerSec) {
- samples_due -= chunkdata.samplesPerSec;
- count--;
- }
- out += bytesPerSample * chunkdata.channels;
- }
- return count;
- }
-
- // This shouldn't be the case
- if ( !mixl || !mixr )
- return 0;
-
- int lVolNum = leftVolume, lVolDen = maxVolume;
- int rVolNum = rightVolume, rVolDen = maxVolume;
- if (priorityExists > 0 && !isPriority) {
- lVolNum = 0; // later, make this gradually fade in and out.
- lVolDen = 5;
- rVolNum = 0;
- rVolDen = 5;
- }
-
- while (count && (dev != -1)) {
- if (out >= *max) {
- // switch buffers
- out = 0;
- if (data == data1 && max2 != 0) {
- data = data2;
- max = &max2;
- max1 = 0;
- } else if (data == data2 && max1 != 0) {
- data = data1;
- max = &max1;
- max2 = 0;
- } else {
- qDebug("QSS Read Error: both buffers empty");
- return 0;
- }
- }
- samples_due += sound_speed;
- if (count && samples_due >= chunkdata.samplesPerSec) {
- int l = getSample(0,bytesPerSample)*lVolNum/lVolDen;
- int r = (chunkdata.channels == 2) ? getSample(1,bytesPerSample)*rVolNum/rVolDen : l;
- if (!sound_stereo && chunkdata.channels == 2)
- l += r;
- if (sampleRunin) {
- while (sampleRunin && count && samples_due >= chunkdata.samplesPerSec) {
- mixl++;
- if (sound_stereo)
- mixr++;
- samples_due -= chunkdata.samplesPerSec;
- sampleRunin--;
- count--;
- }
- }
- while (count && samples_due >= chunkdata.samplesPerSec) {
- *mixl++ += l;
- if (sound_stereo)
- *mixr++ += r;
- samples_due -= chunkdata.samplesPerSec;
- count--;
- }
- }
-
- // optimize out manipulation of sample if downsampling and we skip it
- out += bytesPerSample * chunkdata.channels;
- }
-
- return count;
- }
-
- virtual bool finished() const = 0;
-
- bool equal(int wid, int sid)
- {
- return (wid == mWid && sid == mSid);
- }
-
-protected:
-
- char * prepareBuffer( int &size)
- {
- // keep reading as long as there is 50 % or more room in off buffer.
- if (data == data1 && (max2<<1 < sound_buffer_size)) {
- size=sound_buffer_size - max2;
- return (char *)data2;
- } else if (data == data2 && (max1<<1 < sound_buffer_size)) {
- size=sound_buffer_size - max1;
- return (char *)data1;
- } else {
- size = 0;
- return 0;
- }
- }
-
- void updateBuffer(int read)
- {
- // always reads to off buffer.
- if (read >= 0) {
- if (data == data2) {
- max1 = read;
- } else {
- max2 = read;
- }
- }
- }
-
- int devSamples()
- {
- int possible = (((max1+max2-out) / ((chunkdata.wBitsPerSample>>3)*chunkdata.channels))
- *sound_speed)/chunkdata.samplesPerSec;
-
- return possible;
- }
-
-
- struct {
- qint16 formatTag;
- qint16 channels;
- qint32 samplesPerSec;
- qint32 avgBytesPerSec;
- qint16 blockAlign;
- qint16 wBitsPerSample;
- } chunkdata;
- int dev;
- int samples_due;
-private:
- int mWid;
- int mSid;
- int leftVolume;
- int rightVolume;
- bool isPriority;
- static int priorityExists;
- int *max;
- uchar *data;
- uchar data1[sound_buffer_size+4]; // +4 to handle badly aligned input data
- uchar data2[sound_buffer_size+4]; // +4 to handle badly aligned input data
- int out, max1, max2;
- int sampleRunin;
- bool mMuted;
-};
-
-int QWSSoundServerProvider::priorityExists = 0;
-
-class QWSSoundServerBucket : public QWSSoundServerProvider {
-public:
- QWSSoundServerBucket(int d, int wid, int sid)
- : QWSSoundServerProvider(wid, sid)
- {
- dev = d;
- wavedata_remaining = -1;
- mFinishedRead = false;
- mInsufficientSamples = false;
- }
- ~QWSSoundServerBucket()
- {
- //dev->close();
- ::close(dev);
- }
- bool finished() const
- {
- //return !max;
- return mInsufficientSamples && mFinishedRead ;
- }
- int readySamples(int)
- {
- int size;
- char *dest = prepareBuffer(size);
- // may want to change this to something like
- // if (data == data1 && max2<<1 < sound_buffer_size
- // ||
- // data == data2 && max1<<1 < sound_buffer_size)
- // so will keep filling off buffer while there is +50% space left
- if (size > 0 && dest != 0) {
- while ( wavedata_remaining < 0 ) {
- //max = 0;
- wavedata_remaining = -1;
- // Keep reading chunks...
- const int n = sizeof(chunk)-sizeof(chunk.data);
- int nr = ::read(dev, (void*)&chunk,n);
- if ( nr != n ) {
- // XXX check error? or don't we care?
- wavedata_remaining = 0;
- mFinishedRead = true;
- } else if ( qstrncmp(chunk.id,"data",4) == 0 ) {
- wavedata_remaining = qToLittleEndian( chunk.size );
-
- //out = max = sound_buffer_size;
-
- } else if ( qstrncmp(chunk.id,"RIFF",4) == 0 ) {
- char d[4];
- if ( read(dev, d, 4) != 4 ) {
- // XXX check error? or don't we care?
- //qDebug("couldn't read riff");
- mInsufficientSamples = true;
- mFinishedRead = true;
- return 0;
- } else if ( qstrncmp(d,"WAVE",4) != 0 ) {
- // skip
- if ( chunk.size > 1000000000 || lseek(dev,chunk.size-4, SEEK_CUR) == -1 ) {
- //qDebug("oversized wav chunk");
- mFinishedRead = true;
- }
- }
- } else if ( qstrncmp(chunk.id,"fmt ",4) == 0 ) {
- if ( ::read(dev,(char*)&chunkdata,sizeof(chunkdata)) != sizeof(chunkdata) ) {
- // XXX check error? or don't we care?
- //qDebug("couldn't ready chunkdata");
- mFinishedRead = true;
- }
-
-#define WAVE_FORMAT_PCM 1
- else
- {
- /*
- ** Endian Fix the chuck data
- */
- chunkdata.formatTag = qToLittleEndian( chunkdata.formatTag );
- chunkdata.channels = qToLittleEndian( chunkdata.channels );
- chunkdata.samplesPerSec = qToLittleEndian( chunkdata.samplesPerSec );
- chunkdata.avgBytesPerSec = qToLittleEndian( chunkdata.avgBytesPerSec );
- chunkdata.blockAlign = qToLittleEndian( chunkdata.blockAlign );
- chunkdata.wBitsPerSample = qToLittleEndian( chunkdata.wBitsPerSample );
- if ( chunkdata.formatTag != WAVE_FORMAT_PCM ) {
- qWarning("WAV file: UNSUPPORTED FORMAT %d",chunkdata.formatTag);
- mFinishedRead = true;
- }
- }
- } else {
- // ignored chunk
- if ( chunk.size > 1000000000 || lseek(dev, chunk.size, SEEK_CUR) == -1) {
- //qDebug("chunk size too big");
- mFinishedRead = true;
- }
- }
- }
- // this looks wrong.
- if (wavedata_remaining <= 0) {
- mFinishedRead = true;
- }
-
- }
- // may want to change this to something like
- // if (data == data1 && max2<<1 < sound_buffer_size
- // ||
- // data == data2 && max1<<1 < sound_buffer_size)
- // so will keep filling off buffer while there is +50% space left
-
- if (wavedata_remaining) {
- if (size > 0 && dest != 0) {
- int read = ::read(dev, dest, qMin(size, wavedata_remaining));
- // XXX check error? or don't we care?
- wavedata_remaining -= read;
- updateBuffer(read);
- if (read <= 0) // data unexpectidly ended
- mFinishedRead = true;
- }
- }
- int possible = devSamples();
- if (possible == 0)
- mInsufficientSamples = true;
- return possible;
- }
-
-protected:
- QRiffChunk chunk;
- int wavedata_remaining;
- bool mFinishedRead;
- bool mInsufficientSamples;
-};
-
-class QWSSoundServerStream : public QWSSoundServerProvider {
-public:
- QWSSoundServerStream(int d,int c, int f, int b,
- int wid, int sid)
- : QWSSoundServerProvider(wid, sid)
- {
- chunkdata.channels = c;
- chunkdata.samplesPerSec = f;
- chunkdata.wBitsPerSample = b;
- dev = d;
- //fcntl( dev, F_SETFL, O_NONBLOCK );
- lasttime = 0;
- }
-
- ~QWSSoundServerStream()
- {
- if (dev != -1) {
- ::close(dev);
- dev = -1;
- }
- }
-
- bool finished() const
- {
- return (dev == -1);
- }
-
-
- int readySamples(int)
- {
- int size;
- char *dest = prepareBuffer(size);
- if (size > 0 && dest != 0 && dev != -1) {
-
- int read = ::read(dev, dest, size);
- if (read < 0) {
- switch(errno) {
- case EAGAIN:
- case EINTR:
- // means read may yet succeed on the next attempt
- break;
- default:
- // unexpected error, fail.
- ::close(dev);
- dev = -1;
- }
- } else if (read == 0) {
- // 0 means writer has closed dev and/or
- // file is at end.
- ::close(dev);
- dev = -1;
- } else {
- updateBuffer(read);
- }
- }
- int possible = devSamples();
- if (possible == 0)
- startSampleRunin();
- return possible;
- }
-
-protected:
- time_t lasttime;
-};
-
-#ifndef QT_NO_QWS_SOUNDSERVER
-QWSSoundServerSocket::QWSSoundServerSocket(QObject *parent) :
- QWSServerSocket(QT_VFB_SOUND_PIPE(qws_display_id), parent)
-{
- connect(this, SIGNAL(newConnection()), this, SLOT(newConnection()));
-}
-
-
-#ifdef QT3_SUPPORT
-QWSSoundServerSocket::QWSSoundServerSocket(QObject *parent, const char *name) :
- QWSServerSocket(QT_VFB_SOUND_PIPE(qws_display_id), parent)
-{
- if (name)
- setObjectName(QString::fromAscii(name));
- connect(this, SIGNAL(newConnection()), this, SLOT(newConnection()));
-}
-#endif
-
-void QWSSoundServerSocket::newConnection()
-{
- while (QWS_SOCK_BASE *sock = nextPendingConnection()) {
- QWSSoundServerClient* client = new QWSSoundServerClient(sock,this);
-
- connect(client, SIGNAL(play(int,int,QString)),
- this, SIGNAL(playFile(int,int,QString)));
- connect(client, SIGNAL(play(int,int,QString,int,int)),
- this, SIGNAL(playFile(int,int,QString,int,int)));
- connect(client, SIGNAL(playRaw(int,int,QString,int,int,int,int)),
- this, SIGNAL(playRawFile(int,int,QString,int,int,int,int)));
-
- connect(client, SIGNAL(pause(int,int)),
- this, SIGNAL(pauseFile(int,int)));
- connect(client, SIGNAL(stop(int,int)),
- this, SIGNAL(stopFile(int,int)));
- connect(client, SIGNAL(playPriorityOnly(bool)),
- this, SIGNAL(playPriorityOnly(bool)));
- connect(client, SIGNAL(stopAll(int)),
- this, SIGNAL(stopAll(int)));
- connect(client, SIGNAL(resume(int,int)),
- this, SIGNAL(resumeFile(int,int)));
-
- connect(client, SIGNAL(setSilent(bool)),
- this, SIGNAL(setSilent(bool)));
-
- connect(client, SIGNAL(setMute(int,int,bool)),
- this, SIGNAL(setMute(int,int,bool)));
- connect(client, SIGNAL(setVolume(int,int,int,int)),
- this, SIGNAL(setVolume(int,int,int,int)));
-
- connect(this, SIGNAL(soundFileCompleted(int,int)),
- client, SLOT(sendSoundCompleted(int,int)));
- connect(this, SIGNAL(deviceReady(int,int)),
- client, SLOT(sendDeviceReady(int,int)));
- connect(this, SIGNAL(deviceError(int,int,int)),
- client, SLOT(sendDeviceError(int,int,int)));
- }
-}
-
-#endif
-
-class QWSSoundServerPrivate : public QObject {
- Q_OBJECT
-
-public:
- QWSSoundServerPrivate(QObject* parent=0, const char* name=0) :
- QObject(parent)
- {
- timerId = 0;
- if (name)
- setObjectName(QString::fromAscii(name));
-#ifndef QT_NO_QWS_SOUNDSERVER
- server = new QWSSoundServerSocket(this);
-
- connect(server, SIGNAL(playFile(int,int,QString)),
- this, SLOT(playFile(int,int,QString)));
- connect(server, SIGNAL(playFile(int,int,QString,int,int)),
- this, SLOT(playFile(int,int,QString,int,int)));
- connect(server, SIGNAL(playRawFile(int,int,QString,int,int,int,int)),
- this, SLOT(playRawFile(int,int,QString,int,int,int,int)));
-
- connect(server, SIGNAL(pauseFile(int,int)),
- this, SLOT(pauseFile(int,int)));
- connect(server, SIGNAL(stopFile(int,int)),
- this, SLOT(stopFile(int,int)));
- connect(server, SIGNAL(stopAll(int)),
- this, SLOT(stopAll(int)));
- connect(server, SIGNAL(playPriorityOnly(bool)),
- this, SLOT(playPriorityOnly(bool)));
- connect(server, SIGNAL(resumeFile(int,int)),
- this, SLOT(resumeFile(int,int)));
-
- connect( server, SIGNAL(setSilent(bool)),
- this, SLOT(setSilent(bool)));
-
- connect(server, SIGNAL(setMute(int,int,bool)),
- this, SLOT(setMute(int,int,bool)));
- connect(server, SIGNAL(setVolume(int,int,int,int)),
- this, SLOT(setVolume(int,int,int,int)));
-
- connect(this, SIGNAL(soundFileCompleted(int,int)),
- server, SIGNAL(soundFileCompleted(int,int)));
- connect(this, SIGNAL(deviceReady(int,int)),
- server, SIGNAL(deviceReady(int,int)));
- connect(this, SIGNAL(deviceError(int,int,int)),
- server, SIGNAL(deviceError(int,int,int)));
-
-#endif
- silent = false;
- fd = -1;
- unwritten = 0;
- can_GETOSPACE = true;
- }
-
- ~QWSSoundServerPrivate()
- {
- qDeleteAll(active);
- qDeleteAll(inactive);
- }
-
-signals:
- void soundFileCompleted(int, int);
- void deviceReady(int, int);
- void deviceError(int, int, int);
-
-public slots:
- void playRawFile(int wid, int sid, const QString &filename, int freq, int channels, int bitspersample, int flags);
- void playFile(int wid, int sid, const QString& filename);
- void playFile(int wid, int sid, const QString& filename, int v, int flags);
- void checkPresetVolumes(int wid, int sid, QWSSoundServerProvider *p);
- void pauseFile(int wid, int sid);
- void resumeFile(int wid, int sid);
- void stopFile(int wid, int sid);
- void stopAll(int wid);
- void setVolume(int wid, int sid, int lv, int rv);
- void setMute(int wid, int sid, bool m);
- void playPriorityOnly(bool p);
- void sendCompletedSignals();
- void feedDevice(int fd);
- void setSilent( bool enabled );
-
-protected:
- void timerEvent(QTimerEvent* event);
-
-private:
- int openFile(int wid, int sid, const QString& filename);
- bool openDevice();
- void closeDevice()
- {
- if (fd >= 0) {
- ::close(fd);
- fd = -1;
- }
- }
-
- QList<QWSSoundServerProvider*> active;
- QList<QWSSoundServerProvider*> inactive;
- struct PresetVolume {
- int wid;
- int sid;
- int left;
- int right;
- bool mute;
- };
- QList<PresetVolume> volumes;
- struct CompletedInfo {
- CompletedInfo( ) : groupId( 0 ), soundId( 0 ) { }
- CompletedInfo( int _groupId, int _soundId ) : groupId( _groupId ), soundId( _soundId ) { }
- int groupId;
- int soundId;
- };
- QList<CompletedInfo> completed;
-
- bool silent;
-
- int fd;
- int unwritten;
- int timerId;
- char* cursor;
- short data[sound_buffer_size*2];
- bool can_GETOSPACE;
-#ifndef QT_NO_QWS_SOUNDSERVER
- QWSSoundServerSocket *server;
-#endif
-};
-
-void QWSSoundServerPrivate::setSilent( bool enabled )
-{
- // Close output device
- closeDevice();
- if( !unwritten && !active.count() ) {
- sendCompletedSignals();
- }
- // Stop processing audio
- killTimer( timerId );
- silent = enabled;
- // If audio remaining, open output device and continue processing
- if( unwritten || active.count() ) {
- openDevice();
- }
-}
-
-void QWSSoundServerPrivate::timerEvent(QTimerEvent* event)
-{
- // qDebug("QSS timer event");
- if( event->timerId() == timerId ) {
- if (fd >= 0)
- feedDevice(fd);
- if (fd < 0) {
- killTimer(timerId);
- timerId = 0;
- }
- }
-}
-
-void QWSSoundServerPrivate::playRawFile(int wid, int sid, const QString &filename,
- int freq, int channels, int bitspersample, int flags)
-{
-#ifdef QT_NO_QWS_SOUNDSERVER
- Q_UNUSED(flags);
-#endif
- int f = openFile(wid, sid, filename);
- if ( f ) {
- QWSSoundServerStream *b = new QWSSoundServerStream(f, channels, freq, bitspersample, wid, sid);
- // check preset volumes.
- checkPresetVolumes(wid, sid, b);
-#ifndef QT_NO_QWS_SOUNDSERVER
- b->setPriority((flags & QWSSoundClient::Priority) == QWSSoundClient::Priority);
-#endif
- active.append(b);
- emit deviceReady(wid, sid);
- }
-}
-
-void QWSSoundServerPrivate::playFile(int wid, int sid, const QString& filename)
-{
- int f = openFile(wid, sid, filename);
- if ( f ) {
- QWSSoundServerProvider *b = new QWSSoundServerBucket(f, wid, sid);
- checkPresetVolumes(wid, sid, b);
- active.append( b );
- emit deviceReady(wid, sid);
- }
-}
-
-void QWSSoundServerPrivate::playFile(int wid, int sid, const QString& filename,
- int v, int flags)
-{
-#ifdef QT_NO_QWS_SOUNDSERVER
- Q_UNUSED(flags);
-#endif
- int f = openFile(wid, sid, filename);
- if ( f ) {
- QWSSoundServerProvider *b = new QWSSoundServerBucket(f, wid, sid);
- checkPresetVolumes(wid, sid, b);
- b->setVolume(v, v);
-#ifndef QT_NO_QWS_SOUNDSERVER
- b->setPriority((flags & QWSSoundClient::Priority) == QWSSoundClient::Priority);
-#endif
- active.append(b);
- emit deviceReady(wid, sid);
- }
-}
-
-void QWSSoundServerPrivate::checkPresetVolumes(int wid, int sid, QWSSoundServerProvider *p)
-{
- QList<PresetVolume>::Iterator it = volumes.begin();
- while (it != volumes.end()) {
- PresetVolume v = *it;
- if (v.wid == wid && v.sid == sid) {
- p->setVolume(v.left, v.right);
- p->setMute(v.mute);
- it = volumes.erase(it);
- return;
- } else {
- ++it;
- }
- }
-}
-
-void QWSSoundServerPrivate::pauseFile(int wid, int sid)
-{
- QWSSoundServerProvider *bucket;
- for (int i = 0; i < active.size(); ++i ) {
- bucket = active.at(i);
- if (bucket->equal(wid, sid)) {
- // found bucket....
- active.removeAt(i);
- inactive.append(bucket);
- return;
- }
- }
-}
-
-void QWSSoundServerPrivate::resumeFile(int wid, int sid)
-{
- QWSSoundServerProvider *bucket;
- for (int i = 0; i < inactive.size(); ++i ) {
- bucket = inactive.at(i);
- if (bucket->equal(wid, sid)) {
- // found bucket....
- inactive.removeAt(i);
- active.append(bucket);
- return;
- }
- }
-}
-
-void QWSSoundServerPrivate::stopFile(int wid, int sid)
-{
- QWSSoundServerProvider *bucket;
- for (int i = 0; i < active.size(); ++i ) {
- bucket = active.at(i);
- if (bucket->equal(wid, sid)) {
- active.removeAt(i);
- delete bucket;
- return;
- }
- }
- for (int i = 0; i < inactive.size(); ++i ) {
- bucket = inactive.at(i);
- if (bucket->equal(wid, sid)) {
- inactive.removeAt(i);
- delete bucket;
- return;
- }
- }
-}
-
-void QWSSoundServerPrivate::stopAll(int wid)
-{
- QWSSoundServerProvider *bucket;
- if (!active.isEmpty()) {
- QList<QWSSoundServerProvider*>::Iterator it = active.begin();
- while (it != active.end()) {
- bucket = *it;
- if (bucket->groupId() == wid) {
- it = active.erase(it);
- delete bucket;
- } else {
- ++it;
- }
- }
- }
- if (!inactive.isEmpty()) {
- QList<QWSSoundServerProvider*>::Iterator it = inactive.begin();
- while (it != inactive.end()) {
- bucket = *it;
- if (bucket->groupId() == wid) {
- it = inactive.erase(it);
- delete bucket;
- } else {
- ++it;
- }
- }
- }
-}
-
-void QWSSoundServerPrivate::setVolume(int wid, int sid, int lv, int rv)
-{
- QWSSoundServerProvider *bucket;
- for( int i = 0; i < active.size(); ++i ) {
- bucket = active.at(i);
- if (bucket->equal(wid, sid)) {
- bucket->setVolume(lv,rv);
- return;
- }
- }
- // If gotten here, then it means wid/sid wasn't set up yet.
- // first find and remove current preset volumes, then add this one.
- QList<PresetVolume>::Iterator it = volumes.begin();
- while (it != volumes.end()) {
- PresetVolume v = *it;
- if (v.wid == wid && v.sid == sid)
- it = volumes.erase(it);
- else
- ++it;
- }
- // and then add this volume
- PresetVolume nv;
- nv.wid = wid;
- nv.sid = sid;
- nv.left = lv;
- nv.right = rv;
- nv.mute = false;
- volumes.append(nv);
-}
-
-void QWSSoundServerPrivate::setMute(int wid, int sid, bool m)
-{
- QWSSoundServerProvider *bucket;
- for( int i = 0; i < active.size(); ++i ) {
- bucket = active.at(i);
- if (bucket->equal(wid, sid)) {
- bucket->setMute(m);
- return;
- }
- }
- // if gotten here then setting is being applied before item
- // is created.
- QList<PresetVolume>::Iterator it = volumes.begin();
- while (it != volumes.end()) {
- PresetVolume v = *it;
- if (v.wid == wid && v.sid == sid) {
- (*it).mute = m;
- return;
- }
- }
- if (m) {
- PresetVolume nv;
- nv.wid = wid;
- nv.sid = sid;
- nv.left = maxVolume>>1;
- nv.right = maxVolume>>1;
- nv.mute = true;
- volumes.append(nv);
- }
-}
-
-void QWSSoundServerPrivate::playPriorityOnly(bool p)
-{
- QWSSoundServerProvider::setPlayPriorityOnly(p);
-}
-
-void QWSSoundServerPrivate::sendCompletedSignals()
-{
- while( !completed.isEmpty() ) {
- emit soundFileCompleted( (*completed.begin()).groupId,
- (*completed.begin()).soundId );
- completed.erase( completed.begin() );
- }
-}
-
-
-int QWSSoundServerPrivate::openFile(int wid, int sid, const QString& filename)
-{
- stopFile(wid, sid); // close and re-open.
- int f = QT_OPEN(QFile::encodeName(filename), O_RDONLY|O_NONBLOCK);
- if (f == -1) {
- // XXX check ferror, check reason.
- qDebug("Failed opening \"%s\"",filename.toLatin1().data());
-#ifndef QT_NO_QWS_SOUNDSERVER
- emit deviceError(wid, sid, (int)QWSSoundClient::ErrOpeningFile );
-#endif
- } else if ( openDevice() ) {
- return f;
- }
-#ifndef QT_NO_QWS_SOUNDSERVER
- emit deviceError(wid, sid, (int)QWSSoundClient::ErrOpeningAudioDevice );
-#endif
- return 0;
-}
-
-bool QWSSoundServerPrivate::openDevice()
-{
- if (fd < 0) {
- if( silent ) {
- fd = QT_OPEN( "/dev/null", O_WRONLY );
- // Emulate write to audio device
- int delay = 1000*(sound_buffer_size>>(sound_stereo+sound_16bit))/sound_speed/2;
- timerId = startTimer(delay);
-
- return true;
- }
- //
- // Don't block open right away.
- //
- bool openOkay = false;
- if ((fd = QT_OPEN("/dev/dsp", O_WRONLY|O_NONBLOCK)) != -1) {
- int flags = fcntl(fd, F_GETFL);
- flags &= ~O_NONBLOCK;
- openOkay = (fcntl(fd, F_SETFL, flags) == 0);
- }
- if (!openOkay) {
- qDebug("Failed opening audio device");
- return false;
- }
-
- // Setup soundcard at 16 bit mono
- int v;
- //v=0x00010000+sound_fragment_size;
- // um the media player did this instead.
- v=0x10000 * 4 + sound_fragment_size;
- if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &v))
- qWarning("Could not set fragments to %08x",v);
-#ifdef QT_QWS_SOUND_16BIT
- //
- // Use native endian
- // Since we have manipulated the data volume the data
- // is now in native format, even though its stored
- // as little endian in the WAV file
- //
- v=AFMT_S16_NE; if (ioctl(fd, SNDCTL_DSP_SETFMT, &v))
- qWarning("Could not set format %d",v);
- if (AFMT_S16_NE != v)
- qDebug("Want format %d got %d", AFMT_S16_LE, v);
-#else
- v=AFMT_U8; if (ioctl(fd, SNDCTL_DSP_SETFMT, &v))
- qWarning("Could not set format %d",v);
- if (AFMT_U8 != v)
- qDebug("Want format %d got %d", AFMT_U8, v);
-#endif
- v=sound_stereo; if (ioctl(fd, SNDCTL_DSP_STEREO, &v))
- qWarning("Could not set stereo %d",v);
- if (sound_stereo != v)
- qDebug("Want stereo %d got %d", sound_stereo, v);
-#ifdef QT_QWS_SOUND_STEREO
- sound_stereo=v;
-#endif
- v=sound_speed; if (ioctl(fd, SNDCTL_DSP_SPEED, &sound_speed))
- qWarning("Could not set speed %d",v);
- if (v != sound_speed)
- qDebug("Want speed %d got %d", v, sound_speed);
-
- int delay = 1000*(sound_buffer_size>>(sound_stereo+sound_16bit))
- /sound_speed/2;
- // qDebug("QSS delay: %d", delay);
- timerId = startTimer(delay);
-
- //
- // Check system volume
- //
- int mixerHandle = QT_OPEN( "/dev/mixer", O_RDWR|O_NONBLOCK );
- if ( mixerHandle >= 0 ) {
- int volume;
- ioctl( mixerHandle, MIXER_READ(0), &volume );
- close( mixerHandle );
- if ( volume < 1<<(sound_stereo+sound_16bit) )
- qDebug("Want sound at %d got %d",
- 1<<(sound_stereo+sound_16bit), volume);
- } else
- qDebug( "get volume of audio device failed" );
-
- }
- return true;
-}
-
-void QWSSoundServerPrivate::feedDevice(int fd)
-{
- if ( !unwritten && active.size() == 0 ) {
- closeDevice();
- sendCompletedSignals();
- return;
- } else {
- sendCompletedSignals();
- }
-
- QWSSoundServerProvider* bucket;
-
- // find out how much audio is possible
- int available = sound_buffer_size;
- QList<QWSSoundServerProvider*> running;
- for (int i = 0; i < active.size(); ++i) {
- bucket = active.at(i);
- int ready = bucket->readySamples(available);
- if (ready > 0) {
- available = qMin(available, ready);
- running.append(bucket);
- }
- }
-
- audio_buf_info info;
- if (can_GETOSPACE && ioctl(fd,SNDCTL_DSP_GETOSPACE,&info)) {
- can_GETOSPACE = false;
- fcntl(fd, F_SETFL, O_NONBLOCK);
- }
- if (!can_GETOSPACE)
- info.fragments = 4; // #### configurable?
- if (info.fragments > 0) {
- if (!unwritten) {
- int left[sound_buffer_size];
- memset(left,0,available*sizeof(int));
- int right[sound_buffer_size];
- if ( sound_stereo )
- memset(right,0,available*sizeof(int));
-
- if (running.size() > 0) {
- // should do volume mod here in regards to each bucket to avoid flattened/bad peaks.
- for (int i = 0; i < running.size(); ++i ) {
- bucket = running.at(i);
- int unused = bucket->add(left,right,available);
- if (unused > 0) {
- // this error is quite serious, as
- // it will really screw up mixing.
- qDebug("provider lied about samples ready");
- }
- }
- if ( sound_16bit ) {
- short *d = (short*)data;
- for (int i=0; i<available; i++) {
- *d++ = (short)qMax(qMin(left[i],32767),-32768);
- if ( sound_stereo )
- *d++ = (short)qMax(qMin(right[i],32767),-32768);
- }
- } else {
- signed char *d = (signed char *)data;
- for (int i=0; i<available; i++) {
- *d++ = (signed char)qMax(qMin(left[i]/256,127),-128)+128;
- if ( sound_stereo )
- *d++ = (signed char)qMax(qMin(right[i]/256,127),-128)+128;
- }
- }
- unwritten = available*(sound_16bit+1)*(sound_stereo+1);
- cursor = (char*)data;
- }
- }
- // sound open, but nothing written. Should clear the buffer.
-
- int w;
- if (unwritten) {
- w = ::write(fd,cursor,unwritten);
-
- if (w < 0) {
- if (can_GETOSPACE)
- return;
- w = 0;
- }
-
- cursor += w;
- unwritten -= w;
- } else {
- // write some zeros to clear the buffer?
- if (!zeroMem)
- zeroMem = (char *)calloc(sound_buffer_size, sizeof(char));
- w = ::write(fd, zeroMem, sound_buffer_size);
- if (w < 0)
- w = 0;
- }
- }
-
- QList<QWSSoundServerProvider*>::Iterator it = active.begin();
- while (it != active.end()) {
- bucket = *it;
- if (bucket->finished()) {
- completed.append(CompletedInfo(bucket->groupId(), bucket->soundId()));
- it = active.erase(it);
- delete bucket;
- } else {
- ++it;
- }
- }
-}
-
-
-QWSSoundServer::QWSSoundServer(QObject* parent) :
- QObject(parent)
-{
- d = new QWSSoundServerPrivate(this);
-
- connect( d, SIGNAL(soundFileCompleted(int,int)),
- this, SLOT(translateSoundCompleted(int,int)) );
-}
-
-void QWSSoundServer::playFile( int sid, const QString& filename )
-{
- //wid == 0, as it is the server initiating rather than a client
- // if wid was passable, would accidently collide with server
- // sockect's wids.
- d->playFile(0, sid, filename);
-}
-
-void QWSSoundServer::pauseFile( int sid )
-{
- d->pauseFile(0, sid);
-}
-
-void QWSSoundServer::stopFile( int sid )
-{
- d->stopFile(0, sid);
-}
-
-void QWSSoundServer::resumeFile( int sid )
-{
- d->resumeFile(0, sid);
-}
-
-QWSSoundServer::~QWSSoundServer()
-{
- d->stopAll(0);
-}
-
-void QWSSoundServer::translateSoundCompleted( int, int sid )
-{
- emit soundCompleted( sid );
-}
-
-#ifndef QT_NO_QWS_SOUNDSERVER
-QWSSoundClient::QWSSoundClient(QObject* parent) :
- QWSSocket(parent)
-{
- connectToLocalFile(QT_VFB_SOUND_PIPE(qws_display_id));
- QObject::connect(this,SIGNAL(readyRead()),
- this,SLOT(tryReadCommand()));
- if( state() == QWS_SOCK_BASE::ConnectedState ) QTimer::singleShot(1, this, SIGNAL(connected()));
- else QTimer::singleShot(1, this, SLOT(emitConnectionRefused()));
-}
-
-QWSSoundClient::~QWSSoundClient( )
-{
- flush();
-}
-
-void QWSSoundClient::reconnect()
-{
- connectToLocalFile(QT_VFB_SOUND_PIPE(qws_display_id));
- if( state() == QWS_SOCK_BASE::ConnectedState ) emit connected();
- else emit error( QTcpSocket::ConnectionRefusedError );
-}
-
-void QWSSoundClient::sendServerMessage(QString msg)
-{
-#ifndef QT_NO_TEXTCODEC
- QByteArray u = msg.toUtf8();
-#else
- QByteArray u = msg.toLatin1();
-#endif
- write(u.data(), u.length());
- flush();
-}
-
-void QWSSoundClient::play( int id, const QString& filename )
-{
- QFileInfo fi(filename);
- sendServerMessage(QLatin1String("PLAY ")
- + QString::number(id) + QLatin1Char(' ')
- + fi.absoluteFilePath() + QLatin1Char('\n'));
-}
-
-void QWSSoundClient::play( int id, const QString& filename, int volume, int flags)
-{
- QFileInfo fi(filename);
- sendServerMessage(QLatin1String("PLAYEXTEND ")
- + QString::number(id) + QLatin1Char(' ')
- + QString::number(volume) + QLatin1Char(' ')
- + QString::number(flags) + QLatin1Char(' ')
- + fi.absoluteFilePath() + QLatin1Char('\n'));
-}
-
-void QWSSoundClient::pause( int id )
-{
- sendServerMessage(QLatin1String("PAUSE ")
- + QString::number(id) + QLatin1Char('\n'));
-}
-
-void QWSSoundClient::stop( int id )
-{
- sendServerMessage(QLatin1String("STOP ")
- + QString::number(id) + QLatin1Char('\n'));
-}
-
-void QWSSoundClient::resume( int id )
-{
- sendServerMessage(QLatin1String("RESUME ")
- + QString::number(id) + QLatin1Char('\n'));
-}
-
-void QWSSoundClient::playRaw( int id, const QString& filename,
- int freq, int chs, int bitspersample, int flags)
-{
- QFileInfo fi(filename);
- sendServerMessage(QLatin1String("PLAYRAW ")
- + QString::number(id) + QLatin1Char(' ')
- + QString::number(chs) + QLatin1Char(' ')
- + QString::number(freq) + QLatin1Char(' ')
- + QString::number(bitspersample) + QLatin1Char(' ')
- + QString::number(flags) + QLatin1Char(' ')
- + fi.absoluteFilePath() + QLatin1Char('\n'));
-}
-
-void QWSSoundClient::setMute( int id, bool m )
-{
- sendServerMessage(QLatin1String(m ? "MUTE " : "UNMUTE ")
- + QString::number(id) + QLatin1Char('\n'));
-}
-
-void QWSSoundClient::setVolume( int id, int leftVol, int rightVol )
-{
- sendServerMessage(QLatin1String("SETVOLUME ")
- + QString::number(id) + QLatin1Char(' ')
- + QString::number(leftVol) + QLatin1Char(' ')
- + QString::number(rightVol) + QLatin1Char('\n'));
-}
-
-void QWSSoundClient::playPriorityOnly( bool pri )
-{
- sendServerMessage(QLatin1String("PRIORITYONLY ")
- + QString::number(pri ? 1 : 0) + QLatin1Char('\n'));
-}
-
-void QWSSoundClient::setSilent( bool enable )
-{
- sendServerMessage(QLatin1String("SILENT ")
- + QString::number( enable ? 1 : 0 ) + QLatin1Char('\n'));
-}
-
-void QWSSoundClient::tryReadCommand()
-{
- while ( canReadLine() ) {
- QString l = QString::fromAscii(readLine());
- l.truncate(l.length()-1); // chomp
- QStringList token = l.split(QLatin1Char(' '));
- if (token[0] == QLatin1String("SOUNDCOMPLETED")) {
- emit soundCompleted(token[1].toInt());
- } else if (token[0] == QLatin1String("DEVICEREADY")) {
- emit deviceReady(token[1].toInt());
- } else if (token[0] == QLatin1String("DEVICEERROR")) {
- emit deviceError(token[1].toInt(),(DeviceErrors)token[2].toInt());
- }
- }
-}
-
-void QWSSoundClient::emitConnectionRefused()
-{
- emit error( QTcpSocket::ConnectionRefusedError );
-}
-#endif
-
-QT_END_NAMESPACE
-
-#include "qsoundqss_qws.moc"
-
-#endif // QT_NO_SOUND
diff --git a/src/gui/embedded/qsoundqss_qws.h b/src/gui/embedded/qsoundqss_qws.h
deleted file mode 100644
index c802a72384..0000000000
--- a/src/gui/embedded/qsoundqss_qws.h
+++ /dev/null
@@ -1,177 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSOUNDQSS_QWS_H
-#define QSOUNDQSS_QWS_H
-
-#include <QtCore/qglobal.h>
-
-#ifndef QT_NO_SOUND
-
-#include <QtNetwork/qtcpserver.h>
-#include <QtNetwork/qtcpsocket.h>
-#include <QtGui/qwssocket_qws.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if defined(QT_NO_NETWORK) || defined(QT_NO_DNS)
-#define QT_NO_QWS_SOUNDSERVER
-#endif
-
-#ifndef Q_OS_MAC
-
-class QWSSoundServerPrivate;
-
-class Q_GUI_EXPORT QWSSoundServer : public QObject {
- Q_OBJECT
-public:
- explicit QWSSoundServer(QObject *parent=0);
- ~QWSSoundServer();
- void playFile( int id, const QString& filename );
- void stopFile( int id );
- void pauseFile( int id );
- void resumeFile( int id );
-
-Q_SIGNALS:
- void soundCompleted( int );
-
-private Q_SLOTS:
- void translateSoundCompleted( int, int );
-
-private:
- QWSSoundServerPrivate* d;
-};
-
-#ifndef QT_NO_QWS_SOUNDSERVER
-class Q_GUI_EXPORT QWSSoundClient : public QWSSocket {
- Q_OBJECT
-public:
-
- enum SoundFlags {
- Priority = 0x01,
- Streaming = 0x02 // currently ignored, but but could set up so both Raw and non raw can be done streaming or not.
- };
- enum DeviceErrors {
- ErrOpeningAudioDevice = 0x01,
- ErrOpeningFile = 0x02,
- ErrReadingFile = 0x04
- };
- explicit QWSSoundClient(QObject* parent=0);
- ~QWSSoundClient( );
- void reconnect();
- void play( int id, const QString& filename );
- void play( int id, const QString& filename, int volume, int flags = 0 );
- void playRaw( int id, const QString&, int, int, int, int flags = 0 );
-
- void pause( int id );
- void stop( int id );
- void resume( int id );
- void setVolume( int id, int left, int right );
- void setMute( int id, bool m );
-
- // to be used by server only, to protect phone conversation/rings.
- void playPriorityOnly(bool);
-
- // If silent, tell sound server to release audio device
- // Otherwise, allow sound server to regain audio device
- void setSilent(bool);
-
-Q_SIGNALS:
- void soundCompleted(int);
- void deviceReady(int id);
- void deviceError(int id, QWSSoundClient::DeviceErrors);
-
-private Q_SLOTS:
- void tryReadCommand();
- void emitConnectionRefused();
-
-private:
- void sendServerMessage(QString msg);
-};
-
-class QWSSoundServerSocket : public QWSServerSocket {
- Q_OBJECT
-
-public:
- explicit QWSSoundServerSocket(QObject *parent=0);
-public Q_SLOTS:
- void newConnection();
-
-#ifdef QT3_SUPPORT
-public:
- QT3_SUPPORT_CONSTRUCTOR QWSSoundServerSocket(QObject *parent, const char *name);
-#endif
-
-Q_SIGNALS:
- void playFile(int, int, const QString&);
- void playFile(int, int, const QString&, int, int);
- void playRawFile(int, int, const QString&, int, int, int, int);
- void pauseFile(int, int);
- void stopFile(int, int);
- void resumeFile(int, int);
- void setVolume(int, int, int, int);
- void setMute(int, int, bool);
-
- void stopAll(int);
-
- void playPriorityOnly(bool);
-
- void setSilent(bool);
-
- void soundFileCompleted(int, int);
- void deviceReady(int, int);
- void deviceError(int, int, int);
-};
-#endif
-
-#endif // Q_OS_MAC
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_SOUND
-
-#endif // QSOUNDQSS_QWS_H
diff --git a/src/gui/embedded/qtransportauth_qws.cpp b/src/gui/embedded/qtransportauth_qws.cpp
deleted file mode 100644
index 81e67a9e90..0000000000
--- a/src/gui/embedded/qtransportauth_qws.cpp
+++ /dev/null
@@ -1,1563 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qtransportauth_qws.h"
-#include "qtransportauth_qws_p.h"
-
-#ifndef QT_NO_SXE
-
-#include "../../3rdparty/md5/md5.h"
-#include "../../3rdparty/md5/md5.cpp"
-#include "qwsutils_qws.h"
-#include "qwssocket_qws.h"
-#include "qwscommand_qws_p.h"
-#include "qwindowsystem_qws.h"
-#include "qbuffer.h"
-#include "qthread.h"
-#include "qabstractsocket.h"
-#include "qlibraryinfo.h"
-#include "qfile.h"
-#include "qdebug.h"
-#include <private/qcore_unix_p.h> // overrides QT_OPEN
-
-#include <syslog.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/file.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <time.h>
-
-#include <QtCore/qcache.h>
-
-#define BUF_SIZE 512
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \internal
- memset for security purposes, guaranteed not to be optimized away
- http://www.faqs.org/docs/Linux-HOWTO/Secure-Programs-HOWTO.html
-*/
-Q_GUI_EXPORT void *guaranteed_memset(void *v,int c,size_t n)
-{
- volatile char *p = (char *)v; while (n--) *p++=c; return v;
-}
-
-/*!
- \class QTransportAuth
- \internal
-
- \brief Authenticate a message transport.
-
- For performance reasons, message authentication is tied to an individual
- message transport instance. For example in connection oriented transports
- the authentication cookie can be cached against the connection avoiding
- the overhead of authentication on every message.
-
- For each process there is one instance of the QTransportAuth object.
- For server processes it can determine the \link secure-exe-environ.html SXE
- Program Identity \endlink and provide access to policy data to determine if
- the message should be forwarded for action. If not actioned, the message
- may be treated as being from a flawed or malicious process.
-
- Retrieve the instance with the getInstance() method. The constructor is
- disabled and instances of QTransportAuth should never be constructed by
- calling classes.
-
- To make the Authentication easier to use a proxied QIODevice is provided
- which uses an internal QBuffer.
-
- In the server code first get a pointer to a QTransportAuth::Data object
- using the connectTransport() method:
-
- \snippet doc/src/snippets/code/src_gui_embedded_qtransportauth_qws.cpp 0
-
- Here it is asserted that the transport is trusted. See the assumptions
- listed in the \link secure-exe-environ.html SXE documentation \endlink
-
- Then proxy in the authentication device:
-
- \snippet doc/src/snippets/code/src_gui_embedded_qtransportauth_qws.cpp 1
-
- In the client code it is similar. Use the connectTransport() method
- just the same then proxy in the authentication device instead of the
- socket in write calls:
-
- \snippet doc/src/snippets/code/src_gui_embedded_qtransportauth_qws.cpp 2
-*/
-
-static int hmac_md5(
- unsigned char* text, /* pointer to data stream */
- int text_length, /* length of data stream */
- const unsigned char* key, /* pointer to authentication key */
- int key_length, /* length of authentication key */
- unsigned char * digest /* caller digest to be filled in */
- );
-
-
-
-#define KEY_CACHE_SIZE 30
-
-const char * const errorStrings[] = {
- "pending identity verification",
- "message too small to carry auth data",
- "cache miss on connection oriented transport",
- "no magic bytes on message",
- "key not found for prog id",
- "authorization key match failed",
- "key out of date"
-};
-
-const char *QTransportAuth::errorString( const Data &d )
-{
- if (( d.status & ErrMask ) == Success )
- return "success";
- int e = d.status & ErrMask;
- if ( e > OutOfDate )
- return "unknown";
- return errorStrings[e];
-}
-
-SxeRegistryLocker::SxeRegistryLocker( QObject *reg )
- : m_success( false )
- , m_reg( 0 )
-{
- if ( reg )
- if ( !QMetaObject::invokeMethod( reg, "lockManifest", Q_RETURN_ARG(bool, m_success) ))
- m_success = false;
- m_reg = reg;
-}
-
-SxeRegistryLocker::~SxeRegistryLocker()
-{
- if ( m_success )
- QMetaObject::invokeMethod( m_reg, "unlockManifest" );
-}
-
-
-QTransportAuthPrivate::QTransportAuthPrivate()
- : keyInitialised(false)
- , m_packageRegistry( 0 )
-{
-}
-
-QTransportAuthPrivate::~QTransportAuthPrivate()
-{
-}
-
-/*!
- \internal
- Construct a new QTransportAuth
-*/
-QTransportAuth::QTransportAuth() : QObject(*new QTransportAuthPrivate)
-{
- // qDebug( "creating transport auth" );
-}
-
-/*!
- \internal
- Destructor
-*/
-QTransportAuth::~QTransportAuth()
-{
- // qDebug( "deleting transport auth" );
-}
-
-/*!
- Set the process key for this currently running Qt Extended process to
- the \a authdata. \a authdata should be sizeof(struct AuthCookie)
- in length and contain the key and program id. Use this method
- when setting or changing the SXE identity of the current program.
-*/
-void QTransportAuth::setProcessKey( const char *authdata )
-{
- Q_D(QTransportAuth);
- ::memcpy(&d->authKey, authdata, sizeof(struct AuthCookie));
- QFile proc_key( QLatin1String("/proc/self/lids_key") );
- // where proc key exists use that instead
- if ( proc_key.open( QIODevice::ReadOnly ))
- {
- qint64 kb = proc_key.read( (char*)&d->authKey.key, QSXE_KEY_LEN );
-#ifdef QTRANSPORTAUTH_DEBUG
- qDebug( "Using %li bytes of /proc/%i/lids_key\n", (long int)kb, getpid() );
-#else
- Q_UNUSED( kb );
-#endif
- }
- d->keyInitialised = true;
-}
-
-
-/*!
- Apply \a key as the process key for the currently running application.
-
- \a prog is current ignored
-
- Deprecated function
-*/
-void QTransportAuth::setProcessKey( const char *key, const char *prog )
-{
- Q_UNUSED(prog);
- setProcessKey( key );
-#ifdef QTRANSPORTAUTH_DEBUG
- char displaybuf[QSXE_KEY_LEN*2+1];
- hexstring( displaybuf, (const unsigned char *)key, QSXE_KEY_LEN );
- qDebug() << "key" << displaybuf << "set";
-#endif
-}
-
-/*!
- Register \a pr as a policy handler object. The object pointed to
- by \a pr should have a slot as follows
- \snippet doc/src/snippets/code/src_gui_embedded_qtransportauth_qws.cpp 3
- All requests received by this server will then generate a call to
- this slot, and may be processed for policy compliance.
-*/
-void QTransportAuth::registerPolicyReceiver( QObject *pr )
-{
- // not every policy receiver needs setup - no error if this fails
- QMetaObject::invokeMethod( pr, "setupPolicyCheck" );
-
- connect( this, SIGNAL(policyCheck(QTransportAuth::Data&,QString)),
- pr, SLOT(policyCheck(QTransportAuth::Data&,QString)), Qt::DirectConnection );
-}
-
-/*!
- Unregister the \a pr from being a policy handler. No more policyCheck signals
- are received by this object.
-*/
-void QTransportAuth::unregisterPolicyReceiver( QObject *pr )
-{
- disconnect( pr );
- // not every policy receiver needs tear down - no error if this fails
- QMetaObject::invokeMethod( pr, "teardownPolicyCheck" );
-}
-
-/*!
- Record a new transport connection with \a properties and \a descriptor.
-
- The calling code is responsible for destroying the returned data when the
- tranport connection is closed.
-*/
-QTransportAuth::Data *QTransportAuth::connectTransport( unsigned char properties, int descriptor )
-{
- Data *data = new Data(properties, descriptor);
- data->status = Pending;
- return data;
-}
-
-/*!
- Is the transport trusted. This is true iff data written into the
- transport medium cannot be intercepted or modified by another process.
- This is for example true for Unix Domain Sockets, but not for shared
- memory or UDP sockets.
-
- There is of course an underlying assumption that the kernel implementing
- the transport is sound, ie it cannot be compromised by writing to
- /dev/kmem or loading untrusted modules
-*/
-inline bool QTransportAuth::Data::trusted() const
-{
- return (bool)(properties & Trusted);
-}
-
-/*!
- Assert that the transport is trusted.
-
- For example with respect to shared memory, if it is ensured that no untrusted
- root processes are running, and that unix permissions have been set such that
- any untrusted non-root processes do not have access rights, then a shared
- memory transport could be asserted to be trusted.
-
- \sa trusted()
-*/
-inline void QTransportAuth::Data::setTrusted( bool t )
-{
- properties = t ? properties | Trusted : properties & ~Trusted;
-}
-
-/*!
- Is the transport connection oriented. This is true iff once a connection
- has been accepted, and state established, then further messages over the
- transport are guaranteed to have come from the original connecting entity.
- This is for example true for Unix Domain Sockets, but not
- for shared memory or UDP sockets.
-
- By extension if the transport is not trusted() then it should not be
- assumed to be connection oriented, since spoofed connection information
- could be created. For example if we assume the TCP/IP transport is
- trusted, it can be treated as connection oriented; but this is only the
- case if intervening routers are trusted.
-
- Connection oriented transports have authorization cached against the
- connection, and thus authorization is only done at connect time.
-*/
-inline bool QTransportAuth::Data::connection() const
-{
- return (bool)(properties & Connection);
-}
-
-/*!
- Assert that the transport is connection oriented.
-
- \sa connection()
-*/
-inline void QTransportAuth::Data::setConnection( bool t )
-{
- properties = t ? properties | Connection : properties & ~Connection;
-}
-
-/*!
- Return a pointer to the instance of this process's QTransportAuth object
-*/
-QTransportAuth *QTransportAuth::getInstance()
-{
- static QTransportAuth theInstance;
-
- return &theInstance;
-}
-
-/*!
- Set the full path to the key file
-
- Since this is normally relative to Qtopia::qpeDir() this needs to be
- set within the Qt Extended framework.
-
- The keyfile should be protected by file permissions or by MAC rules
- such that it can only be read/written by the "qpe" server process
-*/
-void QTransportAuth::setKeyFilePath( const QString &path )
-{
- Q_D(QTransportAuth);
- d->m_keyFilePath = path;
-}
-
-QString QTransportAuth::keyFilePath() const
-{
- Q_D(const QTransportAuth);
- return d->m_keyFilePath;
-}
-
-void QTransportAuth::setLogFilePath( const QString &path )
-{
- Q_D(QTransportAuth);
- d->m_logFilePath = path;
-}
-
-QString QTransportAuth::logFilePath() const
-{
- Q_D(const QTransportAuth);
- return d->m_logFilePath;
-}
-
-void QTransportAuth::setPackageRegistry( QObject *registry )
-{
- Q_D(QTransportAuth);
- d->m_packageRegistry = registry;
-}
-
-bool QTransportAuth::isDiscoveryMode() const
-{
-#if defined(SXE_DISCOVERY)
- static bool checked = false;
- static bool yesItIs = false;
-
- if ( checked ) return yesItIs;
-
- yesItIs = ( getenv( "SXE_DISCOVERY_MODE" ) != 0 );
- if ( yesItIs )
- {
- qWarning("SXE Discovery mode on, ALLOWING ALL requests and logging to %s",
- qPrintable(logFilePath()));
- QFile::remove( logFilePath() );
- }
- checked = true;
- return yesItIs;
-#else
- return false;
-#endif
-}
-
-/*!
- \internal
- Return the authorizer device mapped to this client. Note that this
- could probably all be void* instead of QWSClient* for generality.
- Until the need for that rears its head its QWSClient* to save the casts.
-
- #### OK the need has arrived, but the public API is frozen.
-*/
-QIODevice *QTransportAuth::passThroughByClient( QWSClient *client ) const
-{
- Q_D(const QTransportAuth);
-
- if ( client == 0 ) return 0;
- if ( d->buffersByClient.contains( client ))
- {
- return d->buffersByClient[client];
- }
- // qWarning( "buffer not found for client %p", client );
- return 0;
-}
-
-/*!
- \internal
- Return a QIODevice pointer (to an internal QBuffer) which can be used
- to receive data after authorization on transport \a d.
-
- The return QIODevice will act as a pass-through.
-
- The data will be consumed from \a iod and forwarded on to the returned
- QIODevice which can be connected to readyRead() signal handlers in
- place of the original QIODevice \a iod.
-
- This will be called in the server process to handle incoming
- authenticated requests.
-
- The returned QIODevice will take ownership of \a data which will be deleted
- when the QIODevice is delected.
-
- \sa setTargetDevice()
-*/
-QAuthDevice *QTransportAuth::recvBuf( QTransportAuth::Data *data, QIODevice *iod )
-{
- return new QAuthDevice( iod, data, QAuthDevice::Receive );
-}
-
-/*!
- Return a QIODevice pointer (to an internal QBuffer) which can be used
- to write data onto, for authorization on transport \a d.
-
- The return QIODevice will act as a pass-through.
-
- The data written to the return QIODevice will be forwarded on to the
- returned QIODevice. In the case of a QTcpSocket, this will cause it
- to send out the data with the authentication information on it.
-
- This will be called in the client process to generate outgoing
- authenticated requests.
-
- The returned QIODevice will take ownership of \a data which will be deleted
- when the QIODevice is delected.
-
- \sa setTargetDevice()
-*/
-QAuthDevice *QTransportAuth::authBuf( QTransportAuth::Data *data, QIODevice *iod )
-{
- return new QAuthDevice( iod, data, QAuthDevice::Send );
-}
-
-const unsigned char *QTransportAuth::getClientKey( unsigned char progId )
-{
- Q_D(QTransportAuth);
- return d->getClientKey( progId );
-}
-
-void QTransportAuth::invalidateClientKeyCache()
-{
- Q_D(QTransportAuth);
- d->invalidateClientKeyCache();
-}
-
-QMutex *QTransportAuth::getKeyFileMutex()
-{
- Q_D(QTransportAuth);
- return &d->keyfileMutex;
-}
-
-/*
- \internal
- Respond to the destroyed(QObject*) signal of the QAuthDevice's
- client object and remove it from the buffersByClient lookup hash.
-*/
-void QTransportAuth::bufferDestroyed( QObject *cli )
-{
- Q_D(QTransportAuth);
- if ( cli == NULL ) return;
-
- if ( d->buffersByClient.contains( cli ))
- {
- d->buffersByClient.remove( cli );
- // qDebug( "@@@@@@@ client %p removed @@@@@@@@@", cli );
- }
- // qDebug( " client count %d", d->buffersByClient.count() );
-}
-
-bool QTransportAuth::authorizeRequest( QTransportAuth::Data &d, const QString &request )
-{
- bool isAuthorized = true;
-
- if ( !request.isEmpty() && request != QLatin1String("Unknown") )
- {
- d.status &= QTransportAuth::ErrMask; // clear the status
- emit policyCheck( d, request );
- isAuthorized = (( d.status & QTransportAuth::StatusMask ) == QTransportAuth::Allow );
- }
-#if defined(SXE_DISCOVERY)
- if (isDiscoveryMode()) {
-#ifndef QT_NO_TEXTSTREAM
- if (!logFilePath().isEmpty()) {
- QFile log( logFilePath() );
- if (!log.open(QIODevice::WriteOnly | QIODevice::Append)) {
- qWarning("Could not write to log in discovery mode: %s",
- qPrintable(logFilePath()));
- } else {
- QTextStream ts( &log );
- ts << d.progId << '\t' << ( isAuthorized ? "Allow" : "Deny" ) << '\t' << request << endl;
- }
- }
-#endif
- isAuthorized = true;
- }
-#endif
- if ( !isAuthorized )
- {
- qWarning( "%s - denied: for Program Id %u [PID %d]"
- , qPrintable(request), d.progId, d.processId );
-
- char linkTarget[BUF_SIZE]="";
- char exeLink[BUF_SIZE]="";
- char cmdlinePath[BUF_SIZE]="";
- char cmdline[BUF_SIZE]="";
-
- //get executable from /proc/pid/exe
- snprintf( exeLink, BUF_SIZE, "/proc/%d/exe", d.processId );
- if ( -1 == ::readlink( exeLink, linkTarget, BUF_SIZE - 1 ) )
- {
- qWarning( "SXE:- Error encountered in retrieving executable link target from /proc/%u/exe : %s",
- d.processId, strerror(errno) );
- snprintf( linkTarget, BUF_SIZE, "%s", linkTarget );
- }
-
- //get cmdline from proc/pid/cmdline
- snprintf( cmdlinePath, BUF_SIZE, "/proc/%d/cmdline", d.processId );
- int cmdlineFd = QT_OPEN( cmdlinePath, O_RDONLY );
- if ( cmdlineFd == -1 )
- {
- qWarning( "SXE:- Error encountered in opening /proc/%u/cmdline: %s",
- d.processId, strerror(errno) );
- snprintf( cmdline, BUF_SIZE, "%s", "Unknown" );
- }
- else
- {
- if ( -1 == QT_READ(cmdlineFd, cmdline, BUF_SIZE - 1 ) )
- {
- qWarning( "SXE:- Error encountered in reading /proc/%u/cmdline : %s",
- d.processId, strerror(errno) );
- snprintf( cmdline, BUF_SIZE, "%s", "Unknown" );
- }
- QT_CLOSE( cmdlineFd );
- }
-
- syslog( LOG_ERR | LOG_LOCAL6, "%s // PID:%u // ProgId:%u // Exe:%s // Request:%s // Cmdline:%s",
- "<SXE Breach>", d.processId, d.progId, linkTarget, qPrintable(request), cmdline);
- }
-
- return isAuthorized;
-}
-
-inline bool __fileOpen( QFile *f )
-{
-#ifdef QTRANSPORTAUTH_DEBUG
- if ( f->open( QIODevice::ReadOnly ))
- {
- qDebug( "Opened file: %s\n", qPrintable( f->fileName() ));
- return true;
- }
- else
- {
- qWarning( "Could not open file: %s\n", qPrintable( f->fileName() ));
- return false;
- }
-#else
- return ( f->open( QIODevice::ReadOnly ));
-#endif
-}
-
-/*!
- \internal
- Find client keys for the \a progId. If it is cached should be very
- fast, otherwise requires a read of the secret key file
-
- In the success case a pointer to the keys is returned. The pointer is
- to storage allocated for the internal cache and must be used asap.
-
- The list returned is a sequence of one or more keys which match the
- progId. There is no separator, each 16 byte sequence represents a key.
- The sequence is followed by two iterations of the SXE magic
- bytes,eg 0xBA, 0xD4, 0xD4, 0xBA, 0xBA, 0xD4, 0xD4, 0xBA
-
- NULL is returned in the following cases:
- \list
- \o the keyfiles could not be accessed - error condition
- \o there was no key for the supplied program id - key auth failed
- \endlist
-
- Note that for the keyfiles, there is multi-thread and multi-process
- concurrency issues: they can be read by the qpe process when
- QTransportAuth calls getClientKey to verify a request, and they can be
- read or written by the packagemanager when updating package data.
-
- To protect against this, the keyfileMutex & SxeRegistryLocker is used.
-
- The sxe_installer tool can also update inode and device numbers in
- the manifest file, but this only occurs outside of normal operation,
- so qpe and packagemanager are never running when this occurs.
-*/
-const unsigned char *QTransportAuthPrivate::getClientKey(unsigned char progId)
-{
- int manifestMatchCount = 0;
- struct IdBlock mr;
- int total_size = 0;
- char *result = 0;
- char *result_ptr;
- int keysFound = 0;
- bool foundKey;
- int keysRead = 0;
- struct usr_key_entry keys_list[128];
-
- if ( keyCache.contains( progId ))
- return (const unsigned char *)keyCache[progId];
-
- SxeRegistryLocker rlock( m_packageRegistry );
-
- // ### Qt 4.3: this is hacky - see documentation for setKeyFilePath
- QString manifestPath = m_keyFilePath + QLatin1String("/manifest");
- QString actualKeyPath = QLatin1String("/proc/lids/keys");
- bool noFailOnKeyMissing = true;
- if ( !QFile::exists( actualKeyPath )) {
- actualKeyPath = m_keyFilePath + QLatin1String( "/" QSXE_KEYFILE );
- }
- QFile kf( actualKeyPath );
- QFile mn( manifestPath );
- if ( !__fileOpen( &mn ))
- goto key_not_found;
- // first find how much storage is needed
- while ( mn.read( (char*)&mr, sizeof(struct IdBlock)) > 0 )
- if ( mr.progId == progId )
- manifestMatchCount++;
- if ( manifestMatchCount == 0 )
- goto key_not_found;
- if ( !__fileOpen( &kf ))
- {
- noFailOnKeyMissing = false;
- goto key_not_found;
- }
- total_size = 2 * QSXE_MAGIC_BYTES + manifestMatchCount * QSXE_KEY_LEN;
- result = (char*)malloc( total_size );
- Q_CHECK_PTR( result );
- mn.seek( 0 );
- result_ptr = result;
- /* reading whole key array in is much more efficient, 99% case is this loop only
- executes once, should not have more than 128 keyed items */
- while (( keysRead = kf.read( (char*)keys_list, sizeof(struct usr_key_entry)*128 )) > 0 )
- {
- /* qDebug("PID %d: getClientKey() - read %d bytes = %d keys from %s", getpid(), keysRead,
- keysRead/sizeof(struct usr_key_entry), qPrintable(actualKeyPath)); */
- keysRead /= sizeof(struct usr_key_entry);
- while ( mn.read( (char*)&mr, sizeof(struct IdBlock)) > 0 )
- {
- if ( mr.progId == progId )
- {
- foundKey = false;
- for ( int i = 0; i < keysRead; ++i )
- {
- /* if ( i == 0 )
- qDebug() << " pid" << getpid() << "looking for device" << (dev_t)mr.device << "inode" << (ino_t)mr.inode;
- qDebug() << " pid" << getpid() << "trying device" << keys_list[i].dev << "inode" << keys_list[i].ino; */
- if ( keys_list[i].ino == (ino_t)mr.inode && keys_list[i].dev == (dev_t)mr.device )
- {
- memcpy( result_ptr, keys_list[i].key, QSXE_KEY_LEN );
- result_ptr += QSXE_KEY_LEN;
- foundKey = true;
- break;
- }
- }
- if ( foundKey )
- {
- keysFound++;
- if ( keysFound == manifestMatchCount )
- break;
- }
- }
- }
- }
- if ( result_ptr == result ) // nothing found!
- goto key_not_found;
- // 2 x magic bytes sentinel at end of sequence
- for ( int i = 0; i < 2; ++i )
- for ( int j = 0; j < QSXE_MAGIC_BYTES; ++j )
- *result_ptr++ = magic[j];
- keyCache.insert( progId, result, total_size / 10 );
- /* qDebug( "PID %d : Found %d client keys for prog %u", getpid(), keysFound, progId ); */
- goto success_out;
-
-key_not_found:
- if ( noFailOnKeyMissing ) // return an "empty" set of keys in this case
- {
- if ( result == 0 )
- {
- result = (char*)malloc( 2 * QSXE_MAGIC_BYTES );
- Q_CHECK_PTR( result );
- }
- result_ptr = result;
- for ( int i = 0; i < 2; ++i )
- for ( int j = 0; j < QSXE_MAGIC_BYTES; ++j )
- *result_ptr++ = magic[j];
- return (unsigned char *)result;
- }
- qWarning( "PID %d : Not found client key for prog %u", getpid(), progId );
- if ( result )
- {
- free( result );
- result = 0;
- }
-success_out:
- if ( mn.isOpen() )
- mn.close();
- if ( kf.isOpen() )
- kf.close();
- return (unsigned char *)result;
-}
-
-void QTransportAuthPrivate::invalidateClientKeyCache()
-{
- keyfileMutex.lock();
- keyCache.clear();
- keyfileMutex.unlock();
-}
-
-////////////////////////////////////////////////////////////////////////
-////
-//// RequestAnalyzer definition
-////
-
-
-RequestAnalyzer::RequestAnalyzer()
- : moreData( false )
- , dataSize( 0 )
-{
-}
-
-RequestAnalyzer::~RequestAnalyzer()
-{
-}
-
-/*!
- Analzye the data in the\a msgQueue according to some protocol
- and produce a request string for policy analysis.
-
- If enough data is in the queue for analysis of a complete message,
- return a non-null string, and set a flag so requireMoreData() will
- return false; otherwise return a null string and requireMoreData()
- return true.
-
- The amount of bytes analyzed is then available via bytesAnalyzed().
-
- A null string is also returned in the case where the message was
- corrupt and could not be analyzed. In this case requireMoreData()
- returns false.
-
-Note: this method will modify the msgQueue and pull off the data
- deemed to be corrupt, in the case of corrupt data.
-
- In all other cases the msgQueue is left alone. The calling code
- should then pull off the analyzed data. Use bytesAnalzyed() to
- find how much data to pull off the queue.
-*/
-QString RequestAnalyzer::analyze( QByteArray *msgQueue )
-{
-#ifdef Q_WS_QWS
- dataSize = 0;
- moreData = false;
- QBuffer cmdBuf( msgQueue );
- cmdBuf.open( QIODevice::ReadOnly | QIODevice::Unbuffered );
- QWSCommand::Type command_type = (QWSCommand::Type)(qws_read_uint( &cmdBuf ));
- QWSCommand *command = QWSCommand::factory(command_type);
- // if NULL, factory will have already printed warning for bogus
- // command_type just purge the bad stuff and attempt to recover
- if ( command == NULL )
- {
- *msgQueue = msgQueue->mid( sizeof(int) );
- return QString();
- }
- QString request = QLatin1String(qws_getCommandTypeString(command_type));
-#ifndef QT_NO_COP
- if ( !command->read( &cmdBuf ))
- {
- // not all command arrived yet - come back later
- delete command;
- moreData = true;
- return QString();
- }
- if ( command_type == QWSCommand::QCopSend )
- {
- QWSQCopSendCommand *sendCommand = static_cast<QWSQCopSendCommand*>(command);
- request += QString::fromLatin1("/QCop/%1/%2").arg( sendCommand->channel ).arg( sendCommand->message );
- }
- if ( command_type == QWSCommand::QCopRegisterChannel )
- {
- QWSQCopRegisterChannelCommand *registerCommand = static_cast<QWSQCopRegisterChannelCommand*>(command);
- request += QString::fromLatin1("/QCop/RegisterChannel/%1").arg( registerCommand->channel );
- }
-#endif
- dataSize = QWS_PROTOCOL_ITEM_SIZE( *command );
- delete command;
- return request;
-#else
- Q_UNUSED(msgQueue);
- return QString();
-#endif
-}
-
-////////////////////////////////////////////////////////////////////////
-////
-//// AuthDevice definition
-////
-
-/*!
- Constructs a new auth device for the transport \a data and I/O device \a parent.
-
- Incoming or outgoing data will be authenticated according to the auth direction \a dir.
-
- The auth device will take ownership of the transport \a data and delete it when the device
- is destroyed.
-*/
-QAuthDevice::QAuthDevice( QIODevice *parent, QTransportAuth::Data *data, AuthDirection dir )
- : QIODevice( parent )
- , d( data )
- , way( dir )
- , m_target( parent )
- , m_client( 0 )
- , m_bytesAvailable( 0 )
- , m_skipWritten( 0 )
- , analyzer( 0 )
-{
- if ( dir == Receive ) // server side
- {
- connect( m_target, SIGNAL(readyRead()),
- this, SLOT(recvReadyRead()));
- } else {
- connect( m_target, SIGNAL(readyRead()),
- this, SIGNAL(readyRead()));
- }
- connect( m_target, SIGNAL(bytesWritten(qint64)),
- this, SLOT(targetBytesWritten(qint64)) );
- open( QIODevice::ReadWrite | QIODevice::Unbuffered );
-}
-
-QAuthDevice::~QAuthDevice()
-{
- if ( analyzer )
- delete analyzer;
- delete d;
-}
-
-/*!
- \internal
- Store a pointer to the related device or instance which this
- authorizer is proxying for
-*/
-void QAuthDevice::setClient( QObject *cli )
-{
- m_client = cli;
- QTransportAuth::getInstance()->d_func()->buffersByClient[cli] = this;
- QObject::connect( cli, SIGNAL(destroyed(QObject*)),
- QTransportAuth::getInstance(), SLOT(bufferDestroyed(QObject*)) );
- // qDebug( "@@@@@@@@@@@@ client set %p @@@@@@@@@", cli );
- // qDebug( " client count %d", QTransportAuth::getInstance()->d_func()->buffersByClient.count() );
-}
-
-QObject *QAuthDevice::client() const
-{
- return m_client;
-}
-
-/*
- \fn void QAuthDevice::authViolation(QTransportAuth::Data &)
-
- This signal is emitted if an authorization failure is generated, as
- described in checkAuth();
-
- \sa checkAuth()
-*/
-
-
-/*
- \fn void QAuthDevice::policyCheck(QTransportAuth::Data &transport, const QString &request )
-
- This signal is emitted when a transport successfully delivers a request
- and gives the opportunity to either deny or accept the request.
-
- This signal must be connected in the same thread, ie it cannot be queued.
-
- As soon as all handlers connected to this signal are processed the Allow or
- Deny state on the \a transport is checked, and the request is allowed or denied
- accordingly.
-
- \sa checkAuth()
-*/
-
-/*!
- \internal
- Reimplement QIODevice writeData method.
-
- For client end, when the device is written to the incoming data is
- processed and an authentication header calculated. This is pushed
- into the target device, followed by the actual incoming data (the
- payload).
-
- For server end, it is a fatal error to write to the device.
-*/
-qint64 QAuthDevice::writeData(const char *data, qint64 len)
-{
- if ( way == Receive ) // server
- return m_target->write( data, len );
- // client
-#ifdef QTRANSPORTAUTH_DEBUG
- char displaybuf[1024];
-#endif
- char header[QSXE_HEADER_LEN];
- ::memset( header, 0, QSXE_HEADER_LEN );
- qint64 bytes = 0;
- if ( QTransportAuth::getInstance()->authToMessage( *d, header, data, len ))
- {
- m_target->write( header, QSXE_HEADER_LEN );
-#ifdef QTRANSPORTAUTH_DEBUG
- hexstring( displaybuf, (const unsigned char *)header, QSXE_HEADER_LEN );
- qDebug( "%d QAuthDevice::writeData - CLIENT: Header written: %s", getpid(), displaybuf );
-#endif
- m_skipWritten += QSXE_HEADER_LEN;
- }
- m_target->write( data, len );
- bytes += len;
-#ifdef QTRANSPORTAUTH_DEBUG
- int bytesToDisplay = bytes;
- const unsigned char *dataptr = (const unsigned char *)data;
- while ( bytesToDisplay > 0 )
- {
- int amt = bytes < 500 ? bytes : 500;
- hexstring( displaybuf, dataptr, amt );
- qDebug( "%d QAuthDevice::writeData - CLIENT: %s", getpid(), bytes > 0 ? displaybuf : "(null)" );
- dataptr += 500;
- bytesToDisplay -= 500;
- }
-#endif
- if ( m_target->inherits( "QAbstractSocket" ))
- static_cast<QAbstractSocket*>(m_target)->flush();
- return bytes;
-}
-
-/*!
- Reimplement from QIODevice
-
- Read data out of the internal message queue, reduce the queue by the amount
- read. Note that the amount available is only ever the size of a command
- (although a command can be very big) since we need to check at command
- boundaries for new authentication headers.
-*/
-qint64 QAuthDevice::readData( char *data, qint64 maxSize )
-{
- if ( way == Send ) // client
- return m_target->read( data, maxSize );
- if ( msgQueue.size() == 0 )
- return 0;
-#ifdef QTRANSPORTAUTH_DEBUG
- char displaybuf[1024];
- hexstring( displaybuf, reinterpret_cast<const unsigned char *>(msgQueue.constData()),
- msgQueue.size() > 500 ? 500 : msgQueue.size() );
- qDebug() << getpid() << "QAuthDevice::readData() buffered/requested/avail"
- << msgQueue.size() << maxSize << m_bytesAvailable << displaybuf;
-#endif
- Q_ASSERT( m_bytesAvailable <= msgQueue.size() );
- qint64 bytes = ( maxSize > m_bytesAvailable ) ? m_bytesAvailable : maxSize;
- ::memcpy( data, msgQueue.constData(), bytes );
- msgQueue = msgQueue.mid( bytes );
- m_bytesAvailable -= bytes;
- return bytes;
-}
-
-/*!
- \internal
- Receive readyRead signal from the target recv device. In response
- authorize the data, and write results out to the recvBuf() device
- for processing by the application. Trigger the readyRead signal.
-
- Authorizing involves first checking the transport is valid, ie the
- handshake has either already been done and is cached on a trusted
- transport, or was valid with this message; then second passing the
- string representation of the service request up to any policyReceivers
-
- If either of these fail, the message is denied. In discovery mode
- denied messages are allowed, but the message is logged.
-*/
-void QAuthDevice::recvReadyRead()
-{
- qint64 bytes = m_target->bytesAvailable();
- if ( bytes <= 0 ) return;
- open( QIODevice::ReadWrite | QIODevice::Unbuffered );
- QUnixSocket *usock = static_cast<QUnixSocket*>(m_target);
- QUnixSocketMessage msg = usock->read();
- msgQueue.append( msg.bytes() );
- d->processId = msg.processId();
- // if "fragmented" packet 1/2 way through start of a command, ie
- // in the QWS msg type, cant do anything, come back later when
- // there's more of the packet
- if ( msgQueue.size() < (int)sizeof(int) )
- {
- // qDebug() << "returning: msg size too small" << msgQueue.size();
- return;
- }
-#ifdef QTRANSPORTAUTH_DEBUG
- char displaybuf[1024];
- hexstring( displaybuf, reinterpret_cast<const unsigned char *>(msgQueue.constData()),
- msgQueue.size() > 500 ? 500 : msgQueue.size() );
- qDebug( "%d ***** SERVER read %lli bytes - msg %s", getpid(), bytes, displaybuf );
-#endif
-
- bool bufHasMessages = msgQueue.size() >= (int)sizeof(int);
- while ( bufHasMessages )
- {
- unsigned char saveStatus = d->status;
- if (( d->status & QTransportAuth::ErrMask ) == QTransportAuth::NoSuchKey )
- {
- QTransportAuth::getInstance()->authorizeRequest( *d, QLatin1String("NoSuchKey") );
- break;
- }
- if ( !QTransportAuth::getInstance()->authFromMessage( *d, msgQueue, msgQueue.size() ))
- {
- // not all arrived yet? come back later
- if (( d->status & QTransportAuth::ErrMask ) == QTransportAuth::TooSmall )
- {
- d->status = saveStatus;
- return;
- }
- }
- if (( d->status & QTransportAuth::ErrMask ) == QTransportAuth::NoMagic )
- {
- // no msg auth header, don't change the success status for connections
- if ( d->connection() )
- d->status = saveStatus;
- }
- else
- {
- // msg auth header detected and auth determined, remove hdr
- msgQueue = msgQueue.mid( QSXE_HEADER_LEN );
- }
- if ( !authorizeMessage() )
- break;
- bufHasMessages = msgQueue.size() >= (int)sizeof(int);
- }
-}
-
-/**
- \internal
- Handle bytesWritten signals from the underlying target device.
- We adjust the target's value for bytes that are part of auth packets.
-*/
-void QAuthDevice::targetBytesWritten( qint64 bytes )
-{
- if ( m_skipWritten >= bytes ) {
- m_skipWritten -= bytes;
- bytes = 0;
- } else if ( m_skipWritten > 0 ) {
- bytes -= m_skipWritten;
- m_skipWritten = 0;
- }
- if ( bytes > 0 ) {
- emit bytesWritten( bytes );
- }
-}
-
-/**
- \internal
- Pre-process the message to determine what QWS command it is. This
- information is used as the "request" for the purposes of authorization.
-
- The request and other data on the connection (id, PID, etc.) are forwarded
- to all policy listeners by emitting a signal.
-
- The signal must be processed synchronously because on return the allow/deny
- status is used immediately to either drop or continue processing the message.
-*/
-bool QAuthDevice::authorizeMessage()
-{
- if ( analyzer == NULL )
- analyzer = new RequestAnalyzer();
- QString request = (*analyzer)( &msgQueue );
- if ( analyzer->requireMoreData() )
- return false;
- bool isAuthorized = true;
-
- if ( !request.isEmpty() && request != QLatin1String("Unknown") )
- {
- isAuthorized = QTransportAuth::getInstance()->authorizeRequest( *d, request );
- }
-
- bool moreToProcess = ( msgQueue.size() - analyzer->bytesAnalyzed() ) > (int)sizeof(int);
- if ( isAuthorized )
- {
-#ifdef QTRANSPORTAUTH_DEBUG
- qDebug() << getpid() << "SERVER authorized: releasing" << analyzer->bytesAnalyzed() << "byte command" << request;
-#endif
- m_bytesAvailable = analyzer->bytesAnalyzed();
- emit QIODevice::readyRead();
- return moreToProcess;
- }
- else
- {
- msgQueue = msgQueue.mid( analyzer->bytesAnalyzed() );
- }
-
- return true;
-}
-
-void QAuthDevice::setRequestAnalyzer( RequestAnalyzer *ra )
-{
- Q_ASSERT( ra );
- if ( analyzer )
- delete analyzer;
- analyzer = ra;
-}
-
-/*!
- \internal
- Add authentication header to the beginning of a message
-
- Note that the per-process auth cookie is used. This key should be rewritten in
- the binary image of the executable at install time to make it unique.
-
- For this to be secure some mechanism (eg MAC kernel or other
- permissions) must prevent other processes from reading the key.
-
- The buffer must have AUTH_SPACE(0) bytes spare at the beginning for the
- authentication header to be added.
-
- Returns true if header successfully added. Will fail if the
- per-process key has not yet been set with setProcessKey()
-*/
-bool QTransportAuth::authToMessage( QTransportAuth::Data &d, char *hdr, const char *msg, int msgLen )
-{
- // qDebug( "authToMessage(): prog id %u", d.progId );
- // only authorize connection oriented transports once, unless key has changed
- if ( d.connection() && ((d.status & QTransportAuth::ErrMask) != QTransportAuth::Pending) &&
- d_func()->authKey.progId == d.progId )
- return false;
- d.progId = d_func()->authKey.progId;
- // If Unix socket credentials are being used the key wont be set
- if ( !d_func()->keyInitialised )
- return false;
- unsigned char digest[QSXE_KEY_LEN];
- char *msgPtr = hdr;
- // magic always goes on the beginning
- for ( int m = 0; m < QSXE_MAGIC_BYTES; ++m )
- *msgPtr++ = magic[m];
- hdr[ QSXE_LEN_IDX ] = (unsigned char)msgLen;
- if ( !d.trusted())
- {
- // Use HMAC
- int rc = hmac_md5( (unsigned char *)msg, msgLen, d_func()->authKey.key, QSXE_KEY_LEN, digest );
- if ( rc == -1 )
- return false;
- memcpy( hdr + QSXE_KEY_IDX, digest, QSXE_KEY_LEN );
- }
- else
- {
- memcpy( hdr + QSXE_KEY_IDX, d_func()->authKey.key, QSXE_KEY_LEN );
- }
-
- hdr[ QSXE_PROG_IDX ] = d_func()->authKey.progId;
-
-#ifdef QTRANSPORTAUTH_DEBUG
- char keydisplay[QSXE_KEY_LEN*2+1];
- hexstring( keydisplay, d_func()->authKey.key, QSXE_KEY_LEN );
-
- qDebug( "%d CLIENT Auth to message %s against prog id %u and key %s\n",
- getpid(), msg, d_func()->authKey.progId, keydisplay );
-#endif
-
- // TODO implement sequence to prevent replay attack, not required
- // for trusted transports
- hdr[ QSXE_SEQ_IDX ] = 1; // dummy sequence
-
- d.status = ( d.status & QTransportAuth::StatusMask ) | QTransportAuth::Success;
- return true;
-}
-
-
-/*!
- Check authorization on the \a msg, which must be of size \a msgLen,
- for the transport \a d.
-
- If able to determine authorization, return the program identity of
- the message source in the reference \a progId, and return true.
-
- Otherwise return false.
-
- If data is being received on a socket, it may be that more data is yet
- needed before authentication can proceed.
-
- Also the message may not be an authenticated at all.
-
- In these cases the method returns false to indicate authorization could
- not be determined:
- \list
- \i The message is too small to carry the authentication data
- (status TooSmall is set on the \a d transport )
- \i The 4 magic bytes are missing from the message start
- (status NoMagic is set on the \a d transport )
- \i The message is too small to carry the auth + claimed payload
- (status TooSmall is set on the \a d transport )
- \endlist
-
- If however the authentication header (preceded by the magic bytes) and
- any authenticated payload is received the method will determine the
- authentication status, and return true.
-
- In the following cases as well as returning true it will also emit
- an authViolation():
- \list
- \i If the program id claimed by the message is not found in the key file
- (status NoSuchKey is set on the \a d transport )
- \i The authentication token failed against the claimed program id:
- \list
- \i in the case of trusted transports, the secret did not match
- \i in the case of untrusted transports the HMAC code did not match
- \endlist
- (status FailMatch is set on the \a d transport )
- \endlist
-
- In these cases the authViolation( QTransportAuth::Data d ) signal is emitted
- and the error string can be obtained from the status like this:
- \snippet doc/src/snippets/code/src_gui_embedded_qtransportauth_qws.cpp 4
-*/
-bool QTransportAuth::authFromMessage( QTransportAuth::Data &d, const char *msg, int msgLen )
-{
- if ( msgLen < QSXE_MAGIC_BYTES )
- {
- d.status = ( d.status & QTransportAuth::StatusMask ) | QTransportAuth::TooSmall;
- return false;
- }
- // if no magic bytes, exit straight away
- int m;
- const unsigned char *mptr = reinterpret_cast<const unsigned char *>(msg);
- for ( m = 0; m < QSXE_MAGIC_BYTES; ++m )
- {
- if ( *mptr++ != magic[m] )
- {
- d.status = ( d.status & QTransportAuth::StatusMask ) | QTransportAuth::NoMagic;
- return false;
- }
- }
-
- if ( msgLen < AUTH_SPACE(1) )
- {
- d.status = ( d.status & QTransportAuth::StatusMask ) | QTransportAuth::TooSmall;
- return false;
- }
-
- // At this point we know the header is at least long enough to contain valid auth
- // data, however the data may be spoofed. If it is not verified then the status will
- // be set to uncertified so the spoofed data will not be relied on. However we want to
- // know the program id which is being reported (even if it might be spoofed) for
- // policy debugging purposes. So set it here, rather than after verification.
- d.progId = msg[QSXE_PROG_IDX];
-
-#ifdef QTRANSPORTAUTH_DEBUG
- char authhdr[QSXE_HEADER_LEN*2+1];
- hexstring( authhdr, reinterpret_cast<const unsigned char *>(msg), QSXE_HEADER_LEN );
- qDebug( "%d SERVER authFromMessage(): message header is %s",
- getpid(), authhdr );
-#endif
-
- unsigned char authLen = (unsigned char)(msg[ QSXE_LEN_IDX ]);
-
- if ( msgLen < AUTH_SPACE(authLen) )
- {
- d.status = ( d.status & QTransportAuth::StatusMask ) | QTransportAuth::TooSmall;
- return false;
- }
-
- bool isCached = d_func()->keyCache.contains( d.progId );
- const unsigned char *clientKey = d_func()->getClientKey( d.progId );
- if ( clientKey == NULL )
- {
- d.status = ( d.status & QTransportAuth::StatusMask ) | QTransportAuth::NoSuchKey;
- return false;
- }
-
-#ifdef QTRANSPORTAUTH_DEBUG
- char keydisplay[QSXE_KEY_LEN*2+1];
- hexstring( keydisplay, clientKey, QSXE_KEY_LEN );
- qDebug( "\t\tauthFromMessage(): message %s against prog id %u and key %s\n",
- AUTH_DATA(msg), ((unsigned int)d.progId), keydisplay );
-#endif
-
- const unsigned char *auth_tok;
- unsigned char digest[QSXE_KEY_LEN];
- bool multi_tok = false;
-
- bool need_to_recheck=false;
- do
- {
- if ( !d.trusted())
- {
- hmac_md5( AUTH_DATA(msg), authLen, clientKey, QSXE_KEY_LEN, digest );
- auth_tok = digest;
- }
- else
- {
- auth_tok = clientKey;
- multi_tok = true; // 1 or more keys are in the clientKey
- }
- while( true )
- {
- if ( memcmp( auth_tok, magic, QSXE_MAGIC_BYTES ) == 0
- && memcmp( auth_tok + QSXE_MAGIC_BYTES, magic, QSXE_MAGIC_BYTES ) == 0 )
- break;
- if ( memcmp( msg + QSXE_KEY_IDX, auth_tok, QSXE_KEY_LEN ) == 0 )
- {
- d.status = ( d.status & QTransportAuth::StatusMask ) | QTransportAuth::Success;
- return true;
- }
- if ( !multi_tok )
- break;
- auth_tok += QSXE_KEY_LEN;
- }
- //the keys cached on d.progId may not contain the binary key because the cache entry was made
- //before the binary had first started, must search for client key again.
- if ( isCached )
- {
- d_func()->keyCache.remove(d.progId);
- isCached = false;
-
-#ifdef QTRANSPORTAUTH_DEBUG
- qDebug() << "QTransportAuth::authFromMessage(): key not found in set of keys cached"
- << "against prog Id =" << d.progId << ". Re-obtaining client key. ";
-#endif
- clientKey = d_func()->getClientKey( d.progId );
- if ( clientKey == NULL )
- {
- d.status = ( d.status & QTransportAuth::StatusMask ) | QTransportAuth::NoSuchKey;
- return false;
- }
- need_to_recheck = true;
- }
- else
- {
- need_to_recheck = false;
- }
- } while( need_to_recheck );
-
- d.status = ( d.status & QTransportAuth::StatusMask ) | QTransportAuth::FailMatch;
- qWarning() << "QTransportAuth::authFromMessage():failed authentication";
- FAREnforcer::getInstance()->logAuthAttempt( QDateTime::currentDateTime() );
- emit authViolation( d );
- return false;
-}
-
-
-#ifdef QTRANSPORTAUTH_DEBUG
-/*!
- sprintf into hex - dest \a buf, src \a key, \a key_len is length of key.
-
- The target buf should be [ key_len * 2 + 1 ] in size
-*/
-void hexstring( char *buf, const unsigned char* key, size_t key_len )
-{
- unsigned int i, p;
- for ( i = 0, p = 0; i < key_len; i++, p+=2 )
- {
- unsigned char lo_nibble = key[i] & 0x0f;
- unsigned char hi_nibble = key[i] >> 4;
- buf[p] = (int)hi_nibble > 9 ? hi_nibble-10 + 'A' : hi_nibble + '0';
- buf[p+1] = (int)lo_nibble > 9 ? lo_nibble-10 + 'A' : lo_nibble + '0';
- }
- buf[p] = '\0';
-}
-#endif
-
-/*
- HMAC MD5 as listed in RFC 2104
-
- This code is taken from:
-
- http://www.faqs.org/rfcs/rfc2104.html
-
- with the allowance for keys other than length 16 removed, but otherwise
- a straight cut-and-paste.
-
- The HMAC_MD5 transform looks like:
-
- \snippet doc/src/snippets/code/src.gui.embedded.qtransportauth_qws.cpp 5
-
- \list
- \i where K is an n byte key
- \i ipad is the byte 0x36 repeated 64 times
- \i opad is the byte 0x5c repeated 64 times
- \i and text is the data being protected
- \endlist
-
- Hardware is available with accelerated implementations of HMAC-MD5 and
- HMAC-SHA1. Where this hardware is available, this routine should be
- replaced with a call into the accelerated version.
-*/
-
-static int hmac_md5(
- unsigned char* text, /* pointer to data stream */
- int text_length, /* length of data stream */
- const unsigned char* key, /* pointer to authentication key */
- int key_length, /* length of authentication key */
- unsigned char * digest /* caller digest to be filled in */
- )
-{
- MD5Context context;
- unsigned char k_ipad[65]; /* inner padding - * key XORd with ipad */
- unsigned char k_opad[65]; /* outer padding - * key XORd with opad */
- int i;
-
- /* in this implementation key_length == 16 */
- if ( key_length != 16 )
- {
- fprintf( stderr, "Key length was %d - must be 16 bytes", key_length );
- return 0;
- }
-
- /* start out by storing key in pads */
- memset( k_ipad, 0, sizeof k_ipad );
- memset( k_opad, 0, sizeof k_opad );
- memcpy( k_ipad, key, key_length );
- memcpy( k_opad, key, key_length );
-
- /* XOR key with ipad and opad values */
- for (i=0; i<64; i++) {
- k_ipad[i] ^= 0x36;
- k_opad[i] ^= 0x5c;
- }
-
- /* perform inner MD5 */
- MD5Init(&context); /* init context for 1st pass */
- MD5Update(&context, k_ipad, 64); /* start with inner pad */
- MD5Update(&context, text, text_length); /* then text of datagram */
- MD5Final(&context, digest); /* finish up 1st pass */
-
- /* perform outer MD5 */
- MD5Init(&context); /* init context for 2nd pass */
- MD5Update(&context, k_opad, 64); /* start with outer pad */
- MD5Update(&context, digest, 16); /* then results of 1st * hash */
- MD5Final(&context, digest); /* finish up 2nd pass */
- return 1;
-}
-
-
-const int FAREnforcer::minutelyRate = 4; //allowed number of false authentication attempts per minute
-const QString FAREnforcer::FARMessage = QLatin1String("FAR_Exceeded");
-const QString FAREnforcer::SxeTag = QLatin1String("<SXE Breach>");
-const int FAREnforcer::minute = 60;
-
-FAREnforcer::FAREnforcer():authAttempts()
-{
- QDateTime nullDateTime = QDateTime();
- for (int i = 0; i < minutelyRate; i++ )
- authAttempts << nullDateTime;
-}
-
-
-FAREnforcer *FAREnforcer::getInstance()
-{
- static FAREnforcer theInstance;
- return &theInstance;
-}
-
-void FAREnforcer::logAuthAttempt( QDateTime time )
-{
- QDateTime dt = authAttempts.takeFirst();
-
- authAttempts.append( time );
- if ( dt.secsTo( authAttempts.last() ) <= minute )
- {
-#if defined(SXE_DISCOVERY)
- if ( QTransportAuth::getInstance()->isDiscoveryMode() ) {
- static QBasicAtomicInt reported = Q_BASIC_ATOMIC_INITIALIZER(0);
- if ( reported.testAndSetRelaxed(0,1) ) {
-#ifndef QT_NO_TEXTSTREAM
- QString logFilePath = QTransportAuth::getInstance()->logFilePath();
- if ( !logFilePath.isEmpty() ) {
- QFile log( logFilePath );
- if ( !log.open(QIODevice::WriteOnly | QIODevice::Append) ) {
- qWarning("Could not write to log in discovery mode: %s",
- qPrintable(logFilePath) );
- } else {
- QTextStream ts( &log );
- ts << "\t\tWarning: False Authentication Rate of " << minutelyRate << "\n"
- << "\t\tserver connections/authentications per minute has been exceeded,\n"
- << "\t\tno further warnings will be issued\n";
- }
- }
- }
-#endif
- reset();
- return;
- }
-#endif
- syslog( LOG_ERR | LOG_LOCAL6, "%s %s",
- qPrintable( FAREnforcer::SxeTag ),
- qPrintable( FAREnforcer::FARMessage ) );
- reset();
- }
-}
-
-void FAREnforcer::reset()
-{
- QDateTime nullDateTime = QDateTime();
- for (int i = 0; i < minutelyRate; i++ )
- authAttempts[i] = nullDateTime;
-}
-
-QT_END_NAMESPACE
-
-#include "moc_qtransportauth_qws_p.cpp"
-
-#endif // QT_NO_SXE
diff --git a/src/gui/embedded/qtransportauth_qws.h b/src/gui/embedded/qtransportauth_qws.h
deleted file mode 100644
index cd89e0f3aa..0000000000
--- a/src/gui/embedded/qtransportauth_qws.h
+++ /dev/null
@@ -1,281 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTRANSPORTAUTH_QWS_H
-#define QTRANSPORTAUTH_QWS_H
-
-#include <QtCore/qglobal.h>
-
-#if !defined(QT_NO_SXE) || defined(SXE_INSTALLER)
-
-#include <QtCore/qobject.h>
-#include <QtCore/qhash.h>
-#include <QtCore/qstring.h>
-#include <QtCore/qbuffer.h>
-#include <QtCore/qpointer.h>
-
-#include <sys/types.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QAuthDevice;
-class QWSClient;
-class QIODevice;
-class QTransportAuthPrivate;
-class QMutex;
-
-class Q_GUI_EXPORT QTransportAuth : public QObject
-{
- Q_OBJECT
-public:
- static QTransportAuth *getInstance();
-
- enum Result {
- // Error codes
- Pending = 0x00,
- TooSmall = 0x01,
- CacheMiss = 0x02,
- NoMagic = 0x03,
- NoSuchKey = 0x04,
- FailMatch = 0x05,
- OutOfDate = 0x06,
- // reserved for expansion
- Success = 0x1e,
- ErrMask = 0x1f,
-
- // Verification codes
- Allow = 0x20,
- Deny = 0x40,
- Ask = 0x60,
- // reserved
- StatusMask = 0xe0
- };
-
- enum Properties {
- Trusted = 0x01,
- Connection = 0x02,
- UnixStreamSock = 0x04,
- SharedMemory = 0x08,
- MessageQueue = 0x10,
- UDP = 0x20,
- TCP = 0x40,
- UserDefined = 0x80,
- TransportType = 0xfc
- };
-
- struct Data
- {
- Data() { processId = -1; }
- Data( unsigned char p, int d )
- : properties( p )
- , descriptor( d )
- , processId( -1 )
- {
- if (( properties & TransportType ) == TCP ||
- ( properties & TransportType ) == UnixStreamSock )
- properties |= Connection;
- }
-
- unsigned char properties;
- unsigned char progId;
- unsigned char status;
- unsigned int descriptor; // socket fd or shmget key
- pid_t processId;
-
- bool trusted() const;
- void setTrusted( bool );
- bool connection() const;
- void setConnection( bool );
- };
-
- static const char *errorString( const QTransportAuth::Data & );
-
- QTransportAuth::Data *connectTransport( unsigned char, int );
-
- QAuthDevice *authBuf( QTransportAuth::Data *, QIODevice * );
- QAuthDevice *recvBuf( QTransportAuth::Data *, QIODevice * );
- QIODevice *passThroughByClient( QWSClient * ) const;
-
- void setKeyFilePath( const QString & );
- QString keyFilePath() const;
- const unsigned char *getClientKey( unsigned char progId );
- void invalidateClientKeyCache();
- QMutex *getKeyFileMutex();
- void setLogFilePath( const QString & );
- QString logFilePath() const;
- void setPackageRegistry( QObject *registry );
- bool isDiscoveryMode() const;
- void setProcessKey( const char * );
- void setProcessKey( const char *, const char * );
- void registerPolicyReceiver( QObject * );
- void unregisterPolicyReceiver( QObject * );
-
- bool authToMessage( QTransportAuth::Data &d, char *hdr, const char *msg, int msgLen );
- bool authFromMessage( QTransportAuth::Data &d, const char *msg, int msgLen );
-
- bool authorizeRequest( QTransportAuth::Data &d, const QString &request );
-
-Q_SIGNALS:
- void policyCheck( QTransportAuth::Data &, const QString & );
- void authViolation( QTransportAuth::Data & );
-private Q_SLOTS:
- void bufferDestroyed( QObject * );
-
-private:
- // users should never construct their own
- QTransportAuth();
- ~QTransportAuth();
-
- friend class QAuthDevice;
- Q_DECLARE_PRIVATE(QTransportAuth)
-};
-
-class Q_GUI_EXPORT RequestAnalyzer
-{
-public:
- RequestAnalyzer();
- virtual ~RequestAnalyzer();
- QString operator()( QByteArray *data ) { return analyze( data ); }
- bool requireMoreData() const { return moreData; }
- qint64 bytesAnalyzed() const { return dataSize; }
-protected:
- virtual QString analyze( QByteArray * );
- bool moreData;
- qint64 dataSize;
-};
-
-/*!
- \internal
- \class QAuthDevice
-
- \brief Pass-through QIODevice sub-class for authentication.
-
- Use this class to forward on or receive forwarded data over a real
- device for authentication.
-*/
-class Q_GUI_EXPORT QAuthDevice : public QIODevice
-{
- Q_OBJECT
-public:
- enum AuthDirection {
- Receive,
- Send
- };
- QAuthDevice( QIODevice *, QTransportAuth::Data *, AuthDirection );
- ~QAuthDevice();
- void setTarget( QIODevice *t ) { m_target = t; }
- QIODevice *target() const { return m_target; }
- void setClient( QObject* );
- QObject *client() const;
- void setRequestAnalyzer( RequestAnalyzer * );
- bool isSequential() const;
- bool atEnd() const;
- qint64 bytesAvailable() const;
- qint64 bytesToWrite() const;
- bool seek( qint64 );
- QByteArray & buffer();
-
-protected:
- qint64 readData( char *, qint64 );
- qint64 writeData(const char *, qint64 );
-private Q_SLOTS:
- void recvReadyRead();
- void targetBytesWritten( qint64 );
-private:
- bool authorizeMessage();
-
- QTransportAuth::Data *d;
- AuthDirection way;
- QIODevice *m_target;
- QObject *m_client;
- QByteArray msgQueue;
- qint64 m_bytesAvailable;
- qint64 m_skipWritten;
-
- RequestAnalyzer *analyzer;
-};
-
-inline bool QAuthDevice::isSequential() const
-{
- return true;
-}
-
-inline bool QAuthDevice::seek( qint64 )
-{
- return false;
-}
-
-inline bool QAuthDevice::atEnd() const
-{
- return msgQueue.isEmpty();
-}
-
-inline qint64 QAuthDevice::bytesAvailable() const
-{
- if ( way == Receive )
- return m_bytesAvailable;
- else
- return ( m_target ? m_target->bytesAvailable() : 0 );
-}
-
-inline qint64 QAuthDevice::bytesToWrite() const
-{
- return msgQueue.size();
-}
-
-inline QByteArray &QAuthDevice::buffer()
-{
- return msgQueue;
-}
-
-
-
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_SXE
-#endif // QTRANSPORTAUTH_QWS_H
diff --git a/src/gui/embedded/qtransportauth_qws_p.h b/src/gui/embedded/qtransportauth_qws_p.h
deleted file mode 100644
index 9cdbaaf26a..0000000000
--- a/src/gui/embedded/qtransportauth_qws_p.h
+++ /dev/null
@@ -1,189 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTRANSPORTAUTH_QWS_P_H
-#define QTRANSPORTAUTH_QWS_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qglobal.h>
-
-#ifndef QT_NO_SXE
-
-#include "qtransportauth_qws.h"
-#include "qtransportauthdefs_qws.h"
-#include "qbuffer.h"
-
-#include <qmutex.h>
-#include <qdatetime.h>
-#include "private/qobject_p.h"
-
-#include <QtCore/qcache.h>
-
-QT_BEGIN_NAMESPACE
-
-// Uncomment to generate debug output
-// #define QTRANSPORTAUTH_DEBUG 1
-
-#ifdef QTRANSPORTAUTH_DEBUG
-void hexstring( char *buf, const unsigned char* key, size_t sz );
-#endif
-
-// proj id for ftok usage in sxe
-#define SXE_PROJ 10022
-
-/*!
- \internal
- memset for security purposes, guaranteed not to be optimized away
- http://www.faqs.org/docs/Linux-HOWTO/Secure-Programs-HOWTO.html
-*/
-void *guaranteed_memset(void *v,int c,size_t n);
-
-class QUnixSocketMessage;
-
-/*!
- \internal
- \class AuthCookie
- Struct to carry process authentication key and id
-*/
-#define QSXE_HEADER_LEN 24
-
-/*!
- \macro AUTH_ID
- Macro to manage authentication header. Format of header is:
- \table
- \header \i BYTES \i CONTENT
- \row \i 0-3 \i magic numbers
- \row \i 4 \i length of authenticated data (max 255 bytes)
- \row i\ 5 \i reserved
- \row \i 6-21 \i MAC digest, or shared secret in case of simple auth
- \row \i 22 \i program id
- \row \i 23 \i sequence number
- \endtable
- Total length of the header is 24 bytes
-
- However this may change. Instead of coding these numbers use the AUTH_ID,
- AUTH_KEY, AUTH_DATA and AUTH_SPACE macros.
-*/
-
-#define AUTH_ID(k) ((unsigned char)(k[QSXE_KEY_LEN]))
-#define AUTH_KEY(k) ((unsigned char *)(k))
-
-#define AUTH_DATA(x) (unsigned char *)((x) + QSXE_HEADER_LEN)
-#define AUTH_SPACE(x) ((x) + QSXE_HEADER_LEN)
-#define QSXE_LEN_IDX 4
-#define QSXE_KEY_IDX 6
-#define QSXE_PROG_IDX 22
-#define QSXE_SEQ_IDX 23
-
-class SxeRegistryLocker : public QObject
-{
- Q_OBJECT
-public:
- SxeRegistryLocker( QObject * );
- ~SxeRegistryLocker();
- bool success() const { return m_success; }
-private:
- bool m_success;
- QObject *m_reg;
-};
-
-class QTransportAuthPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QTransportAuth)
-public:
- QTransportAuthPrivate();
- ~QTransportAuthPrivate();
-
- const unsigned char *getClientKey( unsigned char progId );
- void invalidateClientKeyCache();
-
- bool keyInitialised;
- QString m_logFilePath;
- QString m_keyFilePath;
- QObject *m_packageRegistry;
- AuthCookie authKey;
- QCache<unsigned char, char> keyCache;
- QHash< QObject*, QIODevice*> buffersByClient;
- QMutex keyfileMutex;
-};
-
-/*!
- \internal
- Enforces the False Authentication Rate. If more than 4 authentications
- are received per minute the sxemonitor is notified that the FAR has been exceeded
-*/
-class FAREnforcer
-{
- public:
- static FAREnforcer *getInstance();
- void logAuthAttempt( QDateTime time = QDateTime::currentDateTime() );
- void reset();
-
-#ifndef TEST_FAR_ENFORCER
- private:
-#endif
- FAREnforcer();
- FAREnforcer( const FAREnforcer & );
- FAREnforcer &operator=(FAREnforcer const & );
-
- static const QString FARMessage;
- static const int minutelyRate;
- static const QString SxeTag;
- static const int minute;
-
- QList<QDateTime> authAttempts;
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_SXE
-#endif // QTRANSPORTAUTH_QWS_P_H
-
diff --git a/src/gui/embedded/qtransportauthdefs_qws.h b/src/gui/embedded/qtransportauthdefs_qws.h
deleted file mode 100644
index a6d39fb425..0000000000
--- a/src/gui/embedded/qtransportauthdefs_qws.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTRANSPORTAUTHDEFS_QWS_H
-#define QTRANSPORTAUTHDEFS_QWS_H
-
-#include <sys/types.h>
-#include <string.h>
-
-#include <QtCore/qglobal.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#define QSXE_KEY_LEN 16
-#define QSXE_MAGIC_BYTES 4
-
-// Number of bytes of each message to authenticate. Just need to ensure
-// that the command at the beginning hasn't been tampered with. This value
-// does not matter for trusted transports.
-#define AMOUNT_TO_AUTHENTICATE 200
-
-#define AUTH_ID(k) ((unsigned char)(k[QSXE_KEY_LEN]))
-#define AUTH_KEY(k) ((unsigned char *)(k))
-
-// must be a largish -ve number under any endianess when cast as an int
-const unsigned char magic[QSXE_MAGIC_BYTES] = { 0xBA, 0xD4, 0xD4, 0xBA };
-const int magicInt = 0xBAD4D4BA;
-
-#define QSXE_KEYFILE "keyfile"
-
-/*
- Header in above format, less the magic bytes.
- Useful for reading off the socket
-*/
-struct AuthHeader
-{
- unsigned char len;
- unsigned char pad;
- unsigned char digest[QSXE_KEY_LEN];
- unsigned char id;
- unsigned char seq;
-};
-
-/*
- Header in a form suitable for authentication routines
-*/
-struct AuthMessage
-{
- AuthMessage()
- {
- ::memset( authData, 0, sizeof(authData) );
- ::memcpy( pad_magic, magic, QSXE_MAGIC_BYTES );
- }
- unsigned char pad_magic[QSXE_MAGIC_BYTES];
- union {
- AuthHeader hdr;
- char authData[sizeof(AuthHeader)];
- };
- char payLoad[AMOUNT_TO_AUTHENTICATE];
-};
-
-/**
- Auth data as stored in _key
-*/
-struct AuthCookie
-{
- unsigned char key[QSXE_KEY_LEN];
- unsigned char pad;
- unsigned char progId;
-};
-
-/*
- Auth data as written to the key file - SUPERSEDED by usr_key_entry
-
- This is still used internally for some functions, ie the socket
- related calls.
-*/
-struct AuthRecord
-{
- union {
- AuthCookie auth;
- char data[sizeof(struct AuthCookie)];
- };
- time_t change_time;
-};
-
-/*!
- \class usr_key_entry
- This comes from the SXE kernel patch file include/linux/lidsif.h
-
- This is the (new) data record for the key file (version 2).
-
- The key file is (now) either /proc/lids/keys (and the per-process
- keys in /proc/<pid>/lids_key) OR for desktop/development ONLY (not
- for production) it is $QPEDIR/etc/keyfile
-
- The key file maps keys to files.
-
- File are identified by inode and device numbers, not paths.
-
- (See the "installs" file for path to inode/device mapping)
-*/
-struct usr_key_entry
-{
- char key[QSXE_KEY_LEN];
- ino_t ino;
- dev_t dev;
-};
-
-
-/*!
- \class IdBlock
- \brief Data record for the manifest file.
- The manifest file maps program id's to files
-*/
-struct IdBlock
-{
- quint64 inode;
- quint64 device;
- unsigned char pad;
- unsigned char progId;
- unsigned short installId;
- unsigned int keyOffset;
- qint64 install_time;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QTRANSPORTAUTHDEFS_QWS_H
-
diff --git a/src/gui/embedded/qunixsocket.cpp b/src/gui/embedded/qunixsocket.cpp
deleted file mode 100644
index 03319cbb0a..0000000000
--- a/src/gui/embedded/qunixsocket.cpp
+++ /dev/null
@@ -1,1800 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qunixsocket_p.h"
-
-// #define QUNIXSOCKET_DEBUG 1
-
-#include <QtCore/qsocketnotifier.h>
-#include <QtCore/qqueue.h>
-#include <QtCore/qdatetime.h>
-#include "private/qcore_unix_p.h" // overrides QT_OPEN
-
-#ifdef QUNIXSOCKET_DEBUG
-#include <QtCore/qdebug.h>
-#endif
-
-extern "C" {
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-};
-
-#define UNIX_PATH_MAX 108 // From unix(7)
-
-#ifdef QT_LINUXBASE
-// LSB doesn't declare ucred
-struct ucred
-{
- pid_t pid; /* PID of sending process. */
- uid_t uid; /* UID of sending process. */
- gid_t gid; /* GID of sending process. */
-};
-
-// LSB doesn't define the ones below
-#ifndef SO_PASSCRED
-# define SO_PASSCRED 16
-#endif
-#ifndef SCM_CREDENTIALS
-# define SCM_CREDENTIALS 0x02
-#endif
-#ifndef MSG_DONTWAIT
-# define MSG_DONTWAIT 0x40
-#endif
-#ifndef MSG_NOSIGNAL
-# define MSG_NOSIGNAL 0x4000
-#endif
-
-#endif // QT_LINUXBASE
-
-QT_BEGIN_NAMESPACE
-
-///////////////////////////////////////////////////////////////////////////////
-// class QUnixSocketRights
-///////////////////////////////////////////////////////////////////////////////
-/*!
- \class QUnixSocketRights
- \internal
-
- \brief The QUnixSocketRights class encapsulates QUnixSocket rights data.
- \omit
- \ingroup Platform::DeviceSpecific
- \ingroup Platform::OS
- \ingroup Platform::Communications
- \endomit
- \ingroup qws
-
- \l QUnixSocket allows you to transfer Unix file descriptors between processes.
- A file descriptor is referred to as "rights data" as it allows one process to
- transfer its right to access a resource to another.
-
- The Unix system verifies resource permissions only when the resource is first
- opened. For example, consider a file on disk readable only by the user "qt".
- A process running as user "qt" will be able to open this file for reading.
- If, while the process was still reading from the file, the ownership was
- changed from user "qt" to user "root", the process would be allowed to
- continue reading from the file, even though attempting to reopen the file
- would be denied. Permissions are associated with special descriptors called
- file descriptors which are returned to a process after it initially opens a
- resource.
-
- File descriptors can be duplicated within a process through the dup(2) system
- call. File descriptors can be passed between processes using the
- \l QUnixSocket class in the same way. Even though the receiving process never
- opened the resource directly, it has the same permissions to access it as the
- process that did.
-
- \sa QUnixSocket
- */
-struct QUnixSocketRightsPrivate : public QSharedData
-{
- virtual ~QUnixSocketRightsPrivate() {
-#ifdef QUNIXSOCKET_DEBUG
- int closerv =
-#endif
- QT_CLOSE(fd);
-#ifdef QUNIXSOCKET_DEBUG
- if(0 != closerv) {
- qDebug() << "QUnixSocketRightsPrivate: Unable to close managed"
- " file descriptor (" << ::strerror(errno) << ')';
- }
-#endif
- }
-
- int fd;
-};
-
-/*!
- Create a new QUnixSocketRights instance containing the file descriptor \a fd.
- \a fd will be dup(2)'d internally, so the application is free to close \a fd
- following this call.
-
- If the dup(2) fails, or you pass an invalid \a fd, an
- \l {QUnixSocketRights::isValid()}{invalid } object will be
- constructed.
-
- QUnixSocketRights instances are immutable and the internal file descriptor
- will be shared between any copies made of this object. The system will
- close(2) the file descriptor once it is no longer needed.
- */
-QUnixSocketRights::QUnixSocketRights(int fd)
-{
- d = new QUnixSocketRightsPrivate();
- if(-1 == fd) {
- d->fd = -1;
- } else {
- d->fd = qt_safe_dup(fd);
-#ifdef QUNIXSOCKET_DEBUG
- if(-1 == d->fd) {
- qDebug() << "QUnixSocketRights: Unable to duplicate fd "
- << fd << " (" << ::strerror(errno) << ')';
- }
-#endif
- }
-}
-
-/*!
- \internal
-
- Construct a QUnixSocketRights instance on \a fd without dup(2)'ing the file
- descriptor.
- */
-QUnixSocketRights::QUnixSocketRights(int fd,int)
-{
- Q_ASSERT(-1 != fd);
- d = new QUnixSocketRightsPrivate();
- d->fd = fd;
-}
-
-/*!
- Destroys the QUnixSocketRights instance.
- */
-QUnixSocketRights::~QUnixSocketRights()
-{
-}
-
-/*!
- Create a copy of \a other.
- */
-QUnixSocketRights &
-QUnixSocketRights::operator=(const QUnixSocketRights & other)
-{
- d = other.d;
- return *this;
-}
-
-/*!
- Create a copy of \a other.
- */
-QUnixSocketRights::QUnixSocketRights(const QUnixSocketRights & other)
-: d(other.d)
-{
-}
-
-/*!
- Returns true if this QUnixSocketRights instance is managing a valid file
- descriptor. This method is equivalent to (-1 != peekFd()).
-
- \sa QUnixSocketRights::peekFd()
- */
-bool QUnixSocketRights::isValid() const
-{
- return d->fd != -1;
-}
-
-/*!
- Return a duplicate of the file descriptor contained in this object. If this
- is an \l {QUnixSocketRights::isValid()}{invalid } object, or the
- dup(2) call fails, an invalid file descriptor (-1) will be returned.
-
- \sa QUnixSocketRights::peekFd()
- */
-int QUnixSocketRights::dupFd() const
-{
- if(-1 == d->fd) return -1;
-
- int rv = qt_safe_dup(d->fd);
-
-#ifdef QUNIXSOCKET_DEBUG
- if(-1 == rv)
- qDebug() << "QUnixSocketRights: Unable to duplicate managed file "
- "descriptor (" << ::strerror(errno) << ')';
-#endif
-
- return rv;
-}
-
-/*!
- Returns the file descriptor contained in this object. If this
- is an \l {QUnixSocketRights::isValid()}{invalid } object an invalid
- file descriptor (-1) will be returned.
-
- The lifetime of this file descriptor is tied to the lifetime of the
- QUnixSocketRights instance. The file descriptor returned by this method
- \e may be close(2)'d when the QUnixSocketRights instance is destroyed. If
- you want to continue to use the file descriptor use
- \l QUnixSocketRights::dupFd() instead.
-
- \sa QUnixSocketRights::dupFd()
- */
-int QUnixSocketRights::peekFd() const
-{
- return d->fd;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// class QUnixSocketMessage
-///////////////////////////////////////////////////////////////////////////////
-struct QUnixSocketMessagePrivate : public QSharedData
-{
- QUnixSocketMessagePrivate()
- : state(Default), vec(0), iovecLen(0), dataSize(0) {}
- QUnixSocketMessagePrivate(const QByteArray & b)
- : bytes(b), state(Default), vec(0), iovecLen(0), dataSize(0) {}
- QUnixSocketMessagePrivate(const QByteArray & b,
- const QList<QUnixSocketRights> & r)
- : bytes(b), rights(r), state(Default), vec(0), iovecLen(0), dataSize(0) {}
-
- int size() const { return vec ? dataSize : bytes.size(); }
- void removeBytes( unsigned int );
-
- QByteArray bytes;
- QList<QUnixSocketRights> rights;
-
- enum AncillaryDataState {
- Default = 0x00,
- Truncated = 0x01,
- Credential = 0x02
- };
- AncillaryDataState state;
-
- pid_t pid;
- gid_t gid;
- uid_t uid;
-
- ::iovec *vec;
- int iovecLen; // number of vectors in array
- int dataSize; // total size of vectors = payload
-};
-
-/*!
- \internal
- Remove \a bytesToDequeue bytes from the front of this message
-*/
-void QUnixSocketMessagePrivate::removeBytes( unsigned int bytesToDequeue )
-{
- if ( vec )
- {
- ::iovec *vecPtr = vec;
- if ( bytesToDequeue > (unsigned int)dataSize ) bytesToDequeue = dataSize;
- while ( bytesToDequeue > 0 && iovecLen > 0 )
- {
- if ( vecPtr->iov_len > bytesToDequeue )
- {
- // dequeue the bytes by taking them off the front of the
- // current vector. since we don't own the iovec, its okay
- // to "leak" this away by pointing past it
- char **base = reinterpret_cast<char**>(&(vecPtr->iov_base));
- *base += bytesToDequeue;
- vecPtr->iov_len -= bytesToDequeue;
- bytesToDequeue = 0;
- }
- else
- {
- // dequeue bytes by skipping a whole vector. again, its ok
- // to lose the pointers to this data
- bytesToDequeue -= vecPtr->iov_len;
- iovecLen--;
- vecPtr++;
- }
- }
- dataSize -= bytesToDequeue;
- if ( iovecLen == 0 ) vec = 0;
- }
- else
- {
- bytes.remove(0, bytesToDequeue );
- }
-}
-
-
-/*!
- \class QUnixSocketMessage
- \internal
-
- \brief The QUnixSocketMessage class encapsulates a message sent or received
- through the QUnixSocket class.
- \omit
- \ingroup Platform::DeviceSpecific
- \ingroup Platform::OS
- \ingroup Platform::Communications
- \endomit
- \ingroup qws
-
- In addition to transmitting regular byte stream data, messages sent over Unix
- domain sockets may have special ancillary properties. QUnixSocketMessage
- instances allow programmers to retrieve and control these properties.
-
- Every QUnixSocketMessage sent has an associated set of credentials. A
- message's credentials consist of the process id, the user id and the group id
- of the sending process. Normally these credentials are set automatically for
- you by the QUnixSocketMessage class and can be queried by the receiving
- process using the \l QUnixSocketMessage::processId(),
- \l QUnixSocketMessage::userId() and \l QUnixSocketMessage::groupId() methods
- respectively.
-
- Advanced applications may wish to change the credentials that their message
- is sent with, and may do so though the \l QUnixSocketMessage::setProcessId(),
- \l QUnixSocketMessage::setUserId() and \l QUnixSocketMessage::setGroupId()
- methods. The validity of these credentials is verified by the system kernel.
- Only the root user can send messages with credentials that are not his own.
- Sending of the message will fail for any non-root user who attempts to
- fabricate credentials. Note that this failure is enforced by the system
- kernel - receivers can trust the accuracy of credential data!
-
- Unix domain socket messages may also be used to transmit Unix file descriptors
- between processes. In this context, file descriptors are known as rights data
- and are encapsulated by the \l QUnixSocketRights class. Senders can set the
- file descriptors to transmit using the \l QUnixSocketMessage::setRights() and
- receivers can retrieve this data through a call to
- \l QUnixSocketMessage::rights(). \l QUnixSocket and \l QUnixSocketRights
- discuss the specific copy and ordering semantic associated with rights data.
-
- QUnixSocketMessage messages are sent by the \l QUnixSocket::write() method.
- Like any normal network message, attempting to transmit an empty
- QUnixSocketMessage will succeed, but result in a no-op. Limitations in the
- Unix domain protocol semantic will cause a transmission of a
- QUnixSocketMessage with rights data, but no byte data portion, to fail.
-
- \sa QUnixSocket QUnixSocketRights
- */
-
-/*!
- Construct an empty QUnixSocketMessage. This instance will have not data and
- no rights information. The message's credentials will be set to the
- application's default credentials.
- */
-QUnixSocketMessage::QUnixSocketMessage()
-: d(new QUnixSocketMessagePrivate())
-{
-}
-
-/*!
- Construct a QUnixSocketMessage with an initial data payload of \a bytes. The
- message's credentials will be set to the application's default credentials.
- */
-QUnixSocketMessage::QUnixSocketMessage(const QByteArray & bytes)
-: d(new QUnixSocketMessagePrivate(bytes))
-{
-}
-
-/*!
- Construct a QUnixSocketMessage with an initial data payload of \a bytes and
- an initial rights payload of \a rights. The message's credentials will be set
- to the application's default credentials.
-
- A message with rights data but an empty data payload cannot be transmitted
- by the system.
- */
-QUnixSocketMessage::QUnixSocketMessage(const QByteArray & bytes,
- const QList<QUnixSocketRights> & rights)
-: d(new QUnixSocketMessagePrivate(bytes, rights))
-{
-}
-
-/*!
- Create a copy of \a other.
- */
-QUnixSocketMessage::QUnixSocketMessage(const QUnixSocketMessage & other)
-: d(other.d)
-{
-}
-
-/*!
- \fn QUnixSocketMessage::QUnixSocketMessage(const iovec* data, int vecLen)
-
- Construct a QUnixSocketMessage with an initial data payload of \a
- data which points to an array of \a vecLen iovec structures. The
- message's credentials will be set to the application's default
- credentials.
-
- This method can be used to avoid the overhead of copying buffers of data
- and will directly send the data pointed to by \a data on the socket. It also
- avoids the syscall overhead of making a number of small socket write calls,
- if a number of data items can be delivered with one write.
-
- Caller must ensure the iovec * \a data remains valid until the message
- is flushed. Caller retains ownership of the iovec structs.
- */
-QUnixSocketMessage::QUnixSocketMessage(const ::iovec* data, int vecLen )
-: d(new QUnixSocketMessagePrivate())
-{
- for ( int v = 0; v < vecLen; v++ )
- d->dataSize += data[v].iov_len;
- d->vec = const_cast<iovec*>(data);
- d->iovecLen = vecLen;
-}
-
-/*!
- Assign the contents of \a other to this object.
- */
-QUnixSocketMessage & QUnixSocketMessage::operator=(const QUnixSocketMessage & other)
-{
- d = other.d;
- return *this;
-}
-
-/*!
- Destroy this instance.
- */
-QUnixSocketMessage::~QUnixSocketMessage()
-{
-}
-
-/*!
- Set the data portion of the message to \a bytes.
-
- \sa QUnixSocketMessage::bytes()
- */
-void QUnixSocketMessage::setBytes(const QByteArray & bytes)
-{
- d.detach();
- d->bytes = bytes;
-}
-
-/*!
- Set the rights portion of the message to \a rights.
-
- A message with rights data but an empty byte data payload cannot be
- transmitted by the system.
-
- \sa QUnixSocketMessage::rights()
- */
-void QUnixSocketMessage::setRights(const QList<QUnixSocketRights> & rights)
-{
- d.detach();
- d->rights = rights;
-}
-
-/*!
- Return the rights portion of the message.
-
- \sa QUnixSocketMessage::setRights()
- */
-const QList<QUnixSocketRights> & QUnixSocketMessage::rights() const
-{
- return d->rights;
-}
-
-/*!
- Returns true if the rights portion of the message was truncated on reception
- due to insufficient buffer size. The rights buffer size can be adjusted
- through calls to the \l QUnixSocket::setRightsBufferSize() method.
- \l QUnixSocket contains a discussion of the buffering and truncation
- characteristics of the Unix domain protocol.
-
- \sa QUnixSocket QUnixSocket::setRightsBufferSize()
- */
-bool QUnixSocketMessage::rightsWereTruncated() const
-{
- return d->state & QUnixSocketMessagePrivate::Truncated;
-}
-
-/*!
- Return the data portion of the message.
-
- \sa QUnixSocketMessage::setBytes()
- */
-const QByteArray & QUnixSocketMessage::bytes() const
-{
- return d->bytes;
-}
-
-/*!
- Returns the process id credential associated with this message.
-
- \sa QUnixSocketMessage::setProcessId()
- */
-pid_t QUnixSocketMessage::processId() const
-{
- if(QUnixSocketMessagePrivate::Credential & d->state)
- return d->pid;
- else
- return ::getpid();
-}
-
-/*!
- Returns the user id credential associated with this message.
-
- \sa QUnixSocketMessage::setUserId()
- */
-uid_t QUnixSocketMessage::userId() const
-{
- if(QUnixSocketMessagePrivate::Credential & d->state)
- return d->uid;
- else
- return ::geteuid();
-}
-
-/*!
- Returns the group id credential associated with this message.
-
- \sa QUnixSocketMessage::setGroupId()
- */
-gid_t QUnixSocketMessage::groupId() const
-{
- if(QUnixSocketMessagePrivate::Credential & d->state)
- return d->gid;
- else
- return ::getegid();
-}
-
-/*!
- Set the process id credential associated with this message to \a pid. Unless
- you are the root user, setting a fraudulant credential will cause this message
- to fail.
-
- \sa QUnixSocketMessage::processId()
- */
-void QUnixSocketMessage::setProcessId(pid_t pid)
-{
- if(!(d->state & QUnixSocketMessagePrivate::Credential)) {
- d->state = (QUnixSocketMessagePrivate::AncillaryDataState)( d->state | QUnixSocketMessagePrivate::Credential );
- d->uid = ::geteuid();
- d->gid = ::getegid();
- }
- d->pid = pid;
-}
-
-/*!
- Set the user id credential associated with this message to \a uid. Unless
- you are the root user, setting a fraudulant credential will cause this message
- to fail.
-
- \sa QUnixSocketMessage::userId()
- */
-void QUnixSocketMessage::setUserId(uid_t uid)
-{
- if(!(d->state & QUnixSocketMessagePrivate::Credential)) {
- d->state = (QUnixSocketMessagePrivate::AncillaryDataState)( d->state | QUnixSocketMessagePrivate::Credential );
- d->pid = ::getpid();
- d->gid = ::getegid();
- }
- d->uid = uid;
-}
-
-/*!
- Set the group id credential associated with this message to \a gid. Unless
- you are the root user, setting a fraudulant credential will cause this message
- to fail.
-
- \sa QUnixSocketMessage::groupId()
- */
-void QUnixSocketMessage::setGroupId(gid_t gid)
-{
- if(!(d->state & QUnixSocketMessagePrivate::Credential)) {
- d->state = (QUnixSocketMessagePrivate::AncillaryDataState)( d->state | QUnixSocketMessagePrivate::Credential );
- d->pid = ::getpid();
- d->uid = ::geteuid();
- }
- d->gid = gid;
-}
-
-/*!
- Return true if this message is valid. A message with rights data but an empty
- byte data payload cannot be transmitted by the system and is marked as
- invalid.
- */
-bool QUnixSocketMessage::isValid() const
-{
- return d->rights.isEmpty() || !d->bytes.isEmpty();
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// class QUnixSocket
-///////////////////////////////////////////////////////////////////////////////
-#define QUNIXSOCKET_DEFAULT_READBUFFER 1024
-#define QUNIXSOCKET_DEFAULT_ANCILLARYBUFFER 0
-
-/*!
- \class QUnixSocket
- \internal
-
- \brief The QUnixSocket class provides a Unix domain socket.
-
- \omit
- \ingroup Platform::DeviceSpecific
- \ingroup Platform::OS
- \ingroup Platform::Communications
- \endomit
- \ingroup qws
-
- Unix domain sockets provide an efficient mechanism for communications between
- Unix processes on the same machine. Unix domain sockets support a reliable,
- stream-oriented, connection-oriented transport protocol, much like TCP
- sockets. Unlike IP based sockets, the connection endpoint of a Unix domain
- socket is a file on disk of type socket.
-
- In addition to transporting raw data bytes, Unix domain sockets are able to
- transmit special ancillary data. The two types of ancillary data supported
- by the QUnixSocket class are:
-
- \list
- \o Credential Data - Allows a receiver
- to reliably identify the process sending each message.
- \o \l {QUnixSocketRights}{Rights Data } - Allows Unix file descriptors
- to be transmitted between processes.
- \endlist
-
- Because of the need to support ancillary data, QUnixSocket is not a QIODevice,
- like QTcpSocket and QUdpSocket. Instead, QUnixSocket contains a number of
- read and write methods that clients must invoke directly. Rather than
- returning raw data bytes, \l QUnixSocket::read() returns \l QUnixSocketMessage
- instances that encapsulate the message's byte data and any other ancillary
- data.
-
- Ancillary data is transmitted "out of band". Every \l QUnixSocketMessage
- received will have credential data associated with it that the client can
- access through calls to \l QUnixSocketMessage::processId(),
- \l QUnixSocketMessage::groupId() and \l QUnixSocketMessage::userId().
- Likewise, message creators can set the credential data to send through calls
- to \l QUnixSocketMessage::setProcessId(), \l QUnixSocketMessage::setGroupId()
- and \l QUnixSocketMessage::setUserId() respectively. The authenticity of the
- credential values is verified by the system kernel and cannot be fabricated
- by unprivileged processes. Only processes running as the root user can
- specify credential data that does not match the sending process.
-
- Unix file descriptors, known as "rights data", transmitted between processes
- appear as though they had been dup(2)'d between the two. As Unix
- domain sockets present a continuous stream of bytes to the receiver, the
- rights data - which is transmitted out of band - must be "slotted" in at some
- point. The rights data is logically associated with the first byte - called
- the anchor byte - of the \l QUnixSocketMessage to which they are attached.
- Received rights data will be available from the
- \l QUnixSocketMessage::rights() method for the \l QUnixSocketMessage
- instance that contains the anchor byte.
-
- In addition to a \l QUnixSocket::write() that takes a \l QUnixSocketMessage
- instance - allowing a client to transmit both byte and rights data - a
- number of convenience overloads are provided for use when only transmitting
- simple byte data. Unix requires that at least one byte of raw data be
- transmitted in order to send rights data. A \l QUnixSocketMessage instance
- with rights data, but no byte data, cannot be transmitted.
-
- Unix sockets present a stream interface, such that, for example, a single
- six byte transmission might be received as two three byte messages. Rights
- data, on the other hand, is conceptually transmitted as unfragmentable
- datagrams. If the receiving buffer is not large enough to contain all the
- transmitted rights information, the data is truncated and irretreivably lost.
- Users should use the \l QUnixSocket::setRightsBufferSize() method to control
- the buffer size used for this data, and develop protocols that avoid the
- problem. If the buffer size is too small and rights data is truncated,
- the \l QUnixSocketMessage::rightsWereTruncated() flag will be set.
-
- \sa QUnixSocketMessage QUnixSocketRights
-*/
-
-/*!
- \enum QUnixSocket::SocketError
-
- The SocketError enumeration represents the various errors that can occur on
- a Unix domain socket. The most recent error for the socket is available
- through the \l QUnixSocket::error() method.
-
- \value NoError No error has occurred.
- \value InvalidPath An invalid path endpoint was passed to
- \l QUnixSocket::connect(). As defined by unix(7), invalid paths
- include an empty path, or what more than 107 characters long.
- \value ResourceError An error acquiring or manipulating the system's socket
- resources occurred. For example, if the process runs out of available
- socket descriptors, a ResourceError will occur.
- \value NonexistentPath The endpoing passed to \l QUnixSocket::connect() does
- not refer to a Unix domain socket entity on disk.
- \value ConnectionRefused The connection to the specified endpoint was refused.
- Generally this means that there is no server listening on that
- endpoint.
- \value UnknownError An unknown error has occurred.
- \value ReadFailure An error occurred while reading bytes from the connection.
- \value WriteFailure An error occurred while writing bytes into the connection.
- */
-
-/*!
- \enum QUnixSocket::SocketState
-
- The SocketState enumeration represents the connection state of a QUnixSocket
- instance.
-
- \value UnconnectedState The connection is not established.
- \value ConnectedState The connection is established.
- \value ClosingState The connection is being closed, following a call to
- \l QUnixSocket::close(). While closing, any pending data will be
- transmitted, but further writes by the application will be refused.
- */
-
-/*
- \fn QUnixSocket::bytesWritten(qint64 bytes)
-
- This signal is emitted every time a payload of data has been written to the
- connection. The \a bytes argument is set to the number of bytes that were
- written in this payload.
-
- \sa QUnixSocket::readyRead()
-*/
-
-/*
- \fn QUnixSocket::readyRead()
-
- This signal is emitted once every time new data is available for reading from
- the connection. It will only be emitted again once new data is available.
-
- \sa QUnixSocket::bytesWritten()
-*/
-
-/*!
- \fn QUnixSocket::stateChanged(SocketState socketState)
-
- This signal is emitted each time the socket changes connection state.
- \a socketState will be set to the socket's new state.
-*/
-
-class QUnixSocketPrivate : public QObject {
-Q_OBJECT
-public:
- QUnixSocketPrivate(QUnixSocket * _me)
- : me(_me), fd(-1), readNotifier(0), writeNotifier(0),
- state(QUnixSocket::UnconnectedState), error(QUnixSocket::NoError),
- writeQueueBytes(0), messageValid(false), dataBuffer(0),
- dataBufferLength(0), dataBufferCapacity(0), ancillaryBuffer(0),
- ancillaryBufferCount(0), closingTimer(0) {
- QObject::connect(this, SIGNAL(readyRead()), me, SIGNAL(readyRead()));
- QObject::connect(this, SIGNAL(bytesWritten(qint64)),
- me, SIGNAL(bytesWritten(qint64)));
- }
- ~QUnixSocketPrivate()
- {
- if(dataBuffer)
- delete [] dataBuffer;
- if(ancillaryBuffer)
- delete [] ancillaryBuffer;
- }
-
- enum { CausedAbort = 0x70000000 };
-
- QUnixSocket * me;
-
- int fd;
-
- QSocketNotifier * readNotifier;
- QSocketNotifier * writeNotifier;
-
- QUnixSocket::SocketState state;
- QUnixSocket::SocketError error;
-
- QQueue<QUnixSocketMessage> writeQueue;
- unsigned int writeQueueBytes;
-
- bool messageValid;
- ::msghdr message;
- inline void flushAncillary()
- {
- if(!messageValid) return;
- ::cmsghdr * h = (::cmsghdr *)CMSG_FIRSTHDR(&(message));
- while(h) {
-
- if(SCM_RIGHTS == h->cmsg_type) {
- int * fds = (int *)CMSG_DATA(h);
- int numFds = (h->cmsg_len - CMSG_LEN(0)) / sizeof(int);
-
- for(int ii = 0; ii < numFds; ++ii)
- QT_CLOSE(fds[ii]);
- }
-
- h = (::cmsghdr *)CMSG_NXTHDR(&(message), h);
- }
-
- messageValid = false;
- }
-
-
- char * dataBuffer;
- unsigned int dataBufferLength;
- unsigned int dataBufferCapacity;
-
- char * ancillaryBuffer;
- inline unsigned int ancillaryBufferCapacity()
- {
- return CMSG_SPACE(sizeof(::ucred)) + CMSG_SPACE(sizeof(int) * ancillaryBufferCount);
- }
- unsigned int ancillaryBufferCount;
-
- QByteArray address;
-
- int closingTimer;
-
- virtual void timerEvent(QTimerEvent *)
- {
- me->abort();
- killTimer(closingTimer);
- closingTimer = 0;
- }
-signals:
- void readyRead();
- void bytesWritten(qint64);
-
-public slots:
- void readActivated();
- qint64 writeActivated();
-};
-
-/*!
- Construct a QUnixSocket instance, with \a parent.
-
- The read buffer is initially set to 1024 bytes, and the rights buffer to 0
- entries.
-
- \sa QUnixSocket::readBufferSize() QUnixSocket::rightsBufferSize()
- */
-QUnixSocket::QUnixSocket(QObject * parent)
-: QIODevice(parent), d(new QUnixSocketPrivate(this))
-{
- setOpenMode(QIODevice::NotOpen);
- setReadBufferSize(QUNIXSOCKET_DEFAULT_READBUFFER);
- setRightsBufferSize(QUNIXSOCKET_DEFAULT_ANCILLARYBUFFER);
-}
-
-/*!
- Construct a QUnixSocket instance, with \a parent.
-
- The read buffer is initially set to \a readBufferSize bytes, and the rights
- buffer to \a rightsBufferSize entries.
-
- \sa QUnixSocket::readBufferSize() QUnixSocket::rightsBufferSize()
- */
-QUnixSocket::QUnixSocket(qint64 readBufferSize, qint64 rightsBufferSize,
- QObject * parent)
-: QIODevice(parent), d(new QUnixSocketPrivate(this))
-{
- Q_ASSERT(readBufferSize > 0 && rightsBufferSize >= 0);
-
- setOpenMode(QIODevice::NotOpen);
- setReadBufferSize(readBufferSize);
- setRightsBufferSize(rightsBufferSize);
-}
-
-/*!
- Destroys the QUnixSocket instance. Any unsent data is discarded.
- */
-QUnixSocket::~QUnixSocket()
-{
- abort();
- delete d;
-}
-
-/*!
- Attempt to connect to \a path.
-
- This method is synchronous and will return true if the connection succeeds and
- false otherwise. In the case of failure, \l QUnixSocket::error() will be set
- accordingly.
-
- Any existing connection will be aborted, and all pending data will be
- discarded.
-
- \sa QUnixSocket::close() QUnixSocket::abort() QUnixSocket::error()
- */
-bool QUnixSocket::connect(const QByteArray & path)
-{
- int _true;
- int crv;
-#ifdef QUNIXSOCKET_DEBUG
- qDebug() << "QUnixSocket: Connect requested to '"
- << path << '\'';
-#endif
-
- abort(); // Reset any existing connection
-
- if(UnconnectedState != d->state) // abort() caused a signal and someone messed
- // with us. We'll assume they know what
- // they're doing and bail. Alternative is to
- // have a special "Connecting" state
- return false;
-
-
- if(path.isEmpty() || path.size() > UNIX_PATH_MAX) {
- d->error = InvalidPath;
- return false;
- }
-
- // Create the socket
- d->fd = ::socket(PF_UNIX, SOCK_STREAM, 0);
- if(-1 == d->fd) {
-#ifdef QUNIXSOCKET_DEBUG
- qDebug() << "QUnixSocket: Unable to create socket ("
- << strerror(errno) << ')';
-#endif
- d->error = ResourceError;
- goto connect_error;
- }
-
- // Set socket options
- _true = 1;
- crv = ::setsockopt(d->fd, SOL_SOCKET, SO_PASSCRED, (void *)&_true,
- sizeof(int));
- if(-1 == crv) {
-#ifdef QUNIXSOCKET_DEBUG
- qDebug() << "QUnixSocket: Unable to configure socket ("
- << ::strerror(errno) << ')';
-#endif
- d->error = ResourceError;
-
- goto connect_error;
- }
-
- // Construct our unix address
- struct ::sockaddr_un addr;
- addr.sun_family = AF_UNIX;
- ::memcpy(addr.sun_path, path.data(), path.size());
- if(path.size() < UNIX_PATH_MAX)
- addr.sun_path[path.size()] = '\0';
-
- // Attempt the connect
- crv = ::connect(d->fd, (sockaddr *)&addr, sizeof(sockaddr_un));
- if(-1 == crv) {
-#ifdef QUNIXSOCKET_DEBUG
- qDebug() << "QUnixSocket: Unable to connect ("
- << ::strerror(errno) << ')';
-#endif
- if(ECONNREFUSED == errno)
- d->error = ConnectionRefused;
- else if(ENOENT == errno)
- d->error = NonexistentPath;
- else
- d->error = UnknownError;
-
- goto connect_error;
- }
-
- // We're connected!
- d->address = path;
- d->state = ConnectedState;
- d->readNotifier = new QSocketNotifier(d->fd, QSocketNotifier::Read, d);
- d->writeNotifier = new QSocketNotifier(d->fd, QSocketNotifier::Write, d);
- QObject::connect(d->readNotifier, SIGNAL(activated(int)),
- d, SLOT(readActivated()));
- QObject::connect(d->writeNotifier, SIGNAL(activated(int)),
- d, SLOT(writeActivated()));
- d->readNotifier->setEnabled(true);
- d->writeNotifier->setEnabled(false);
- setOpenMode(QIODevice::ReadWrite);
- emit stateChanged(ConnectedState);
-
-#ifdef QUNIXSOCKET_DEBUG
- qDebug() << "QUnixSocket: Connected to " << path;
-#endif
- return true;
-
-connect_error: // Cleanup failed connection
- if(-1 != d->fd) {
-#ifdef QUNIXSOCKET_DEBUG
- int closerv =
-#endif
- QT_CLOSE(d->fd);
-#ifdef QUNIXSOCKET_DEBUG
- if(0 != closerv) {
- qDebug() << "QUnixSocket: Unable to close file descriptor after "
- "failed connect (" << ::strerror(errno) << ')';
- }
-#endif
- }
- d->fd = -1;
- return false;
-}
-
-/*!
- Sets the socket descriptor to use to \a socketDescriptor, bypassing
- QUnixSocket's connection infrastructure, and return true on success and false
- on failure. \a socketDescriptor must be in the connected state, and must be
- a Unix domain socket descriptor. Following a successful call to this method,
- the QUnixSocket instance will be in the Connected state and will have assumed
- ownership of \a socketDescriptor.
-
- Any existing connection will be aborted, and all pending data will be
- discarded.
-
- \sa QUnixSocket::connect()
-*/
-bool QUnixSocket::setSocketDescriptor(int socketDescriptor)
-{
- abort();
-
- if(UnconnectedState != state()) // See QUnixSocket::connect()
- return false;
-
- // Attempt to set the socket options
- if(-1 == socketDescriptor) {
-#ifdef QUNIXSOCKET_DEBUG
- qDebug() << "QUnixSocket: User provided socket is invalid";
-#endif
- d->error = ResourceError;
- return false;
- }
-
- // Set socket options
- int _true = 1;
- int crv = ::setsockopt(socketDescriptor, SOL_SOCKET,
- SO_PASSCRED, (void *)&_true, sizeof(int));
- if(-1 == crv) {
-#ifdef QUNIXSOCKET_DEBUG
- qDebug() << "QUnixSocket: Unable to configure client provided socket ("
- << ::strerror(errno) << ')';
-#endif
- d->error = ResourceError;
-
- return false;
- }
-
- d->fd = socketDescriptor;
- d->state = ConnectedState;
- d->address = QByteArray();
- setOpenMode(QIODevice::ReadWrite);
- d->readNotifier = new QSocketNotifier(d->fd, QSocketNotifier::Read, d);
- d->writeNotifier = new QSocketNotifier(d->fd, QSocketNotifier::Write, d);
- QObject::connect(d->readNotifier, SIGNAL(activated(int)),
- d, SLOT(readActivated()));
- QObject::connect(d->writeNotifier, SIGNAL(activated(int)),
- d, SLOT(writeActivated()));
- d->readNotifier->setEnabled(true);
- d->writeNotifier->setEnabled(false);
- emit stateChanged(d->state);
-
- return true;
-}
-
-/*!
- Returns the socket descriptor currently in use. This method will return -1
- if the QUnixSocket instance is in the UnconnectedState \l {QUnixSocket::state()}{state. }
-
- \sa QUnixSocket::setSocketDescriptor()
- */
-int QUnixSocket::socketDescriptor() const
-{
- return d->fd;
-}
-
-/*!
- Abort the connection. This will immediately disconnect (if connected) and
- discard any pending data. Following a call to QUnixSocket::abort() the
- object will always be in the disconnected \link QUnixSocket::state() state.
- \endlink
-
- \sa QUnixSocket::close()
-*/
-void QUnixSocket::abort()
-{
- setOpenMode(QIODevice::NotOpen);
-
- // We want to be able to use QUnixSocket::abort() to cleanup our state but
- // also preserve the error message that caused the abort. It is not
- // possible to reorder code to do this:
- // abort();
- // d->error = SomeError
- // as QUnixSocket::abort() might emit a signal and we need the error to be
- // set within that signal. So, if we want an error message to be preserved
- // across a *single* call to abort(), we set the
- // QUnixSocketPrivate::CausedAbort flag in the error.
- if(d->error & QUnixSocketPrivate::CausedAbort)
- d->error = (QUnixSocket::SocketError)(d->error &
- ~QUnixSocketPrivate::CausedAbort);
- else
- d->error = NoError;
-
- if( UnconnectedState == d->state) return;
-
-#ifdef QUNIXSOCKET_DEBUG
- int closerv =
-#endif
- ::close(d->fd);
-#ifdef QUNIXSOCKET_DEBUG
- if(0 != closerv) {
- qDebug() << "QUnixSocket: Unable to close socket during abort ("
- << strerror(errno) << ')';
- }
-#endif
-
- // Reset variables
- d->fd = -1;
- d->state = UnconnectedState;
- d->dataBufferLength = 0;
- d->flushAncillary();
- d->address = QByteArray();
- if(d->readNotifier) {
- d->readNotifier->setEnabled(false);
- d->readNotifier->deleteLater();
- }
- if(d->writeNotifier) {
- d->writeNotifier->setEnabled(false);
- d->writeNotifier->deleteLater();
- }
- d->readNotifier = 0;
- d->writeNotifier = 0;
- d->writeQueue.clear();
- d->writeQueueBytes = 0;
- if(d->closingTimer) {
- d->killTimer(d->closingTimer);
- }
- d->closingTimer = 0;
- emit stateChanged(d->state);
-}
-
-/*!
- Close the connection. The instance will enter the Closing
- \l {QUnixSocket::state()}{state } until all pending data has been
- transmitted, at which point it will enter the Unconnected state.
-
- Even if there is no pending data for transmission, the object will never
- jump directly to Disconnect without first passing through the
- Closing state.
-
- \sa QUnixSocket::abort()
- */
-void QUnixSocket::close()
-{
- if(ConnectedState != state()) return;
-
- d->state = ClosingState;
- if(d->writeQueue.isEmpty()) {
- d->closingTimer = d->startTimer(0); // Start a timer to "fake"
- // completing writes
- }
- emit stateChanged(d->state);
-}
-
-/*!
- This function writes as much as possible from the internal write buffer to
- the underlying socket, without blocking. If any data was written, this
- function returns true; otherwise false is returned.
-*/
-// Note! docs partially copied from QAbstractSocket::flush()
-bool QUnixSocket::flush()
-{
- // This needs to have the same semantics as QAbstractSocket, if it is to
- // be used interchangeably with that class.
- if (d->writeQueue.isEmpty())
- return false;
-
- d->writeActivated();
- return true;
-}
-
-/*!
- Returns the last error to have occurred on this object. This method is not
- destructive, so multiple calls to QUnixSocket::error() will return the same
- value. The error is only reset by a call to \l QUnixSocket::connect() or
- \l QUnixSocket::abort()
- */
-QUnixSocket::SocketError QUnixSocket::error() const
-{
- return (QUnixSocket::SocketError)
- (d->error & ~QUnixSocketPrivate::CausedAbort);
-}
-
-/*!
- Returns the connection state of this instance.
- */
-QUnixSocket::SocketState QUnixSocket::state() const
-{
- return d->state;
-}
-
-/*!
- Returns the Unix path address passed to \l QUnixSocket::connect(). This
- method will return an empty path if the object is in the Unconnected
- \l {QUnixSocket::state()}{state } or was connected through a call
- to \l QUnixSocket::setSocketDescriptor()
-
- \sa QUnixSocket::connect() QUnixSocket::setSocketDescriptor()
- */
-QByteArray QUnixSocket::address() const
-{
- return d->address;
-}
-
-/*!
- Returns the number of bytes available for immediate retrieval through a call
- to \l QUnixSocket::read().
- */
-qint64 QUnixSocket::bytesAvailable() const
-{
- return QIODevice::bytesAvailable() + d->dataBufferLength;
-}
-
-/*!
- Returns the number of enqueued bytes still to be written to the socket.
- */
-qint64 QUnixSocket::bytesToWrite() const
-{
- return d->writeQueueBytes;
-}
-
-/*!
- Returns the size of the read buffer in bytes. The read buffer size
- determines the amount of byte data that can be read from the socket in one go.
- The read buffer size caps the maximum value that can be returned by
- \l QUnixSocket::bytesAvailable() and will always be greater than zero. By
- default, the read buffer size is 1024 bytes.
-
- The size of the read buffer is independent of the rights buffer, which can be
- queried by \l QUnixSocket::rightsBufferSize().
-
- \sa QUnixSocket::setReadBufferSize()
- */
-qint64 QUnixSocket::readBufferSize() const
-{
- return d->dataBufferCapacity;
-}
-
-/*!
- Sets the \a size of the socket's read buffer in bytes.
-
- The size of the read buffer is independent of the rights buffer, which can be
- set by \l QUnixSocket::setRightsBufferSize().
-
- Attempting to reduce the buffer size while bytes are available for reading
- (ie. while the buffer is in use) will fail.
-
- \sa QUnixSocket::readBufferSize()
- */
-void QUnixSocket::setReadBufferSize(qint64 size)
-{
- Q_ASSERT(size > 0);
- if(size == d->dataBufferCapacity || d->dataBufferLength) return;
- if(d->dataBuffer) delete [] d->dataBuffer;
- d->dataBuffer = new char[size];
- d->dataBufferCapacity = size;
-}
-
-/*!
- Returns the size of the rights buffer in rights entries. The rights buffer
- size determines the number of rights transferences that can be received in
- any message. Unlike byte stream data which can be fragmented into many
- smaller messages if the \link QUnixSocket::readBufferSize() read buffer
- \endlink is not large enough to contain all the available data, rights data
- is transmitted as unfragmentable datagrams. If the rights buffer is not
- large enough to contain this unfragmentable datagram, the datagram will be
- truncated and rights data irretrievably lost. If truncation occurs, the
- \l QUnixSocketMessage::rightsWereTruncated() flag will be set. By default
- the rights buffer size is 0 entries - rights data cannot be received.
-
- The size of the rights buffer is independent of the read buffer, which can be
- queried by \l QUnixSocket::readBufferSize().
-
- \sa QUnixSocket::setRightsBufferSize()
- */
-qint64 QUnixSocket::rightsBufferSize() const
-{
- return d->ancillaryBufferCount;
-}
-
-/*!
- Sets the \a size of the socket's rights buffer in rights entries.
-
- The size of the rights buffer is independent of the read buffer, which can be
- set by \l QUnixSocket::setReadBufferSize().
-
- Attempting to reduce the buffer size while bytes are available for reading
- (ie. while the buffer is in use) will fail.
-
- \sa QUnixSocket::rightsBufferSize()
- */
-void QUnixSocket::setRightsBufferSize(qint64 size)
-{
- Q_ASSERT(size >= 0);
-
- if((size == d->ancillaryBufferCount || d->dataBufferLength) &&
- d->ancillaryBuffer)
- return;
-
- qint64 byteSize = CMSG_SPACE(sizeof(::ucred)) +
- CMSG_SPACE(size * sizeof(int));
-
- if(d->ancillaryBuffer) delete [] d->ancillaryBuffer;
- d->ancillaryBuffer = new char[byteSize];
- d->ancillaryBufferCount = size;
-}
-
-/*!
- \overload
-
- Writes \a socketdata to the socket. In addition to failing if the socket
- is not in the Connected state, writing will fail if \a socketdata is
- \l {QUnixSocketMessage::isValid()}{invalid. }
-
- Writes through the QUnixSocket class are asynchronous. Rather than being
- written immediately, data is enqueued and written once the application
- reenters the Qt event loop and the socket becomes available for writing.
- Thus, this method will only fail if the socket is not in the Connected state
- - it is illegal to attempt a write on a Unconnected or Closing socket.
-
- Applications can monitor the progress of data writes through the
- \l QUnixSocket::bytesWritten() signal and \l QUnixSocket::bytesToWrite()
- method.
-
- \sa QUnixSocketMessage
- */
-qint64 QUnixSocket::write(const QUnixSocketMessage & socketdata)
-{
- if(ConnectedState != state() || !socketdata.isValid()) return -1;
- if(socketdata.d->size() == 0) return 0;
-
- d->writeQueue.enqueue(socketdata);
- d->writeQueueBytes += socketdata.d->size();
- d->writeNotifier->setEnabled(true);
-
- return socketdata.d->size();
-}
-
-/*!
- Return the next available message, or an empty message if none is available.
-
- To avoid retrieving empty messages, applications should connect to the
- \l QUnixSocket::readyRead() signal to be notified when new messages are
- available or periodically poll the \l QUnixSocket::bytesAvailable() method.
-
- \sa QUnixSocket::readyRead() QUnixSocket::bytesAvailable()
- */
-QUnixSocketMessage QUnixSocket::read()
-{
- QUnixSocketMessage data;
- if(!d->dataBufferLength)
- return data;
-
- data.d->state = QUnixSocketMessagePrivate::Credential;
-
- // Bytes are easy
- data.setBytes(QByteArray(d->dataBuffer, d->dataBufferLength));
-
- // Extract ancillary data
- QList<QUnixSocketRights> a;
-
- ::cmsghdr * h = (::cmsghdr *)CMSG_FIRSTHDR(&(d->message));
- while(h) {
-
- if(SCM_CREDENTIALS == h->cmsg_type) {
- ::ucred * cred = (::ucred *)CMSG_DATA(h);
-#ifdef QUNIXSOCKET_DEBUG
- qDebug( "Credentials recd: pid %lu - gid %lu - uid %lu",
- cred->pid, cred->gid, cred->uid );
-#endif
- data.d->pid = cred->pid;
- data.d->gid = cred->gid;
- data.d->uid = cred->uid;
-
- } else if(SCM_RIGHTS == h->cmsg_type) {
-
- int * fds = (int *)CMSG_DATA(h);
- int numFds = (h->cmsg_len - CMSG_LEN(0)) / sizeof(int);
-
- for(int ii = 0; ii < numFds; ++ii) {
- QUnixSocketRights qusr(fds[ii], 0);
- a.append(qusr);
- }
-
- } else {
-
-#ifdef QUNIXSOCKET_DEBUG
- qFatal("QUnixSocket: Unknown ancillary data type (%d) received.",
- h->cmsg_type);
-#endif
-
- }
-
- h = (::cmsghdr *)CMSG_NXTHDR(&(d->message), h);
- }
-
- if(d->message.msg_flags & MSG_CTRUNC) {
- data.d->state = (QUnixSocketMessagePrivate::AncillaryDataState)(QUnixSocketMessagePrivate::Truncated |
- QUnixSocketMessagePrivate::Credential );
- }
-
- if(!a.isEmpty())
- data.d->rights = a;
-
- d->dataBufferLength = 0;
- d->messageValid = false;
- d->readNotifier->setEnabled(true);
-
- return data;
-}
-
-/*! \internal */
-bool QUnixSocket::isSequential() const
-{
- return true;
-}
-
-/*! \internal */
-bool QUnixSocket::waitForReadyRead(int msecs)
-{
- if(UnconnectedState == d->state)
- return false;
-
- if(d->messageValid) {
- return true;
- }
-
- Q_ASSERT(-1 != d->fd);
-
- int timeout = msecs;
- struct timeval tv;
- struct timeval *ptrTv = 0;
- QTime stopWatch;
-
- stopWatch.start();
-
- do
- {
- fd_set readset;
-
- FD_ZERO(&readset);
- FD_SET(d->fd, &readset);
-
- if(-1 != msecs) {
- tv.tv_sec = timeout / 1000;
- tv.tv_usec = (timeout % 1000) * 1000;
- ptrTv = &tv;
- }
-
- int rv = ::select(d->fd + 1, &readset, 0, 0, ptrTv);
- switch(rv) {
- case 0:
- // timeout
- return false;
- case 1:
- // ok
- d->readActivated();
- return true;
- default:
- if (errno != EINTR)
- abort(); // error
- break;
- }
-
- timeout = msecs - stopWatch.elapsed();
- }
- while (timeout > 0);
-
- return false;
-}
-
-bool QUnixSocket::waitForBytesWritten(int msecs)
-{
- if(UnconnectedState == d->state)
- return false;
-
- Q_ASSERT(-1 != d->fd);
-
- if ( d->writeQueue.isEmpty() )
- return true;
-
- QTime stopWatch;
- stopWatch.start();
-
- while ( true )
- {
- fd_set fdwrite;
- FD_ZERO(&fdwrite);
- FD_SET(d->fd, &fdwrite);
- int timeout = msecs < 0 ? 0 : msecs - stopWatch.elapsed();
- struct timeval tv;
- struct timeval *ptrTv = 0;
- if ( -1 != msecs )
- {
- tv.tv_sec = timeout / 1000;
- tv.tv_usec = (timeout % 1000) * 1000;
- ptrTv = &tv;
- }
-
- int rv = ::select(d->fd + 1, 0, &fdwrite, 0, ptrTv);
- switch ( rv )
- {
- case 0:
- // timeout
- return false;
- case 1:
- {
- // ok to write
- qint64 bytesWritten = d->writeActivated();
- if (bytesWritten == 0) {
- // We need to retry
- int delay = 1;
- do {
- if (-1 != msecs) {
- timeout = msecs - stopWatch.elapsed();
- if (timeout <= 0) {
- // We have exceeded our allotted time
- return false;
- } else {
- if (delay > timeout)
- delay = timeout;
- }
- }
-
- // Pause before we make another attempt to send
- ::usleep(delay * 1000);
- if (delay < 1024)
- delay *= 2;
-
- bytesWritten = d->writeActivated();
- } while (bytesWritten == 0);
- }
- return (bytesWritten != -1);
- }
- default:
- // error - or an uncaught signal!!!!!!!!!
- if ( rv == EINTR )
- continue;
- abort();
- return false;
- }
- }
- return false; // fix warnings
-}
-
-/*! \internal */
-bool QUnixSocket::canReadLine() const
-{
- for(unsigned int ii = 0; ii < d->dataBufferLength; ++ii)
- if(d->dataBuffer[ii] == '\n') return true;
- return false;
-}
-
-/*! \internal */
-qint64 QUnixSocket::readData(char * data, qint64 maxSize)
-{
- Q_ASSERT(data);
- if(0 >= maxSize) return 0;
- if(!d->dataBufferLength) return 0;
-
- // Read data
- unsigned int size = d->dataBufferLength>maxSize?maxSize:d->dataBufferLength;
- memcpy(data, d->dataBuffer, size);
- if(size == d->dataBufferLength) {
- d->dataBufferLength = 0;
- } else {
- memmove(d->dataBuffer, d->dataBuffer + size, d->dataBufferLength - size);
- d->dataBufferLength -= size;
- }
-
-
- // Flush ancillary
- d->flushAncillary();
-
- if(0 == d->dataBufferLength)
- d->readNotifier->setEnabled(true);
-
- return size;
-}
-
-/*! \internal */
-qint64 QUnixSocket::writeData (const char * data, qint64 maxSize)
-{
- return write(QUnixSocketMessage(QByteArray(data, maxSize)));
-}
-
-qint64 QUnixSocketPrivate::writeActivated()
-{
- writeNotifier->setEnabled(false);
-
- QUnixSocketMessage & m = writeQueue.head();
- const QList<QUnixSocketRights> & a = m.rights();
-
- //
- // Construct the message
- //
- ::iovec vec;
- if ( !m.d->vec ) // message does not already have an iovec
- {
- vec.iov_base = (void *)m.bytes().constData();
- vec.iov_len = m.bytes().size();
- }
-
- // Allocate the control buffer
- ::msghdr sendmessage;
- ::bzero(&sendmessage, sizeof(::msghdr));
- if ( m.d->vec )
- {
- sendmessage.msg_iov = m.d->vec;
- sendmessage.msg_iovlen = m.d->iovecLen;
- }
- else
- {
- sendmessage.msg_iov = &vec;
- sendmessage.msg_iovlen = 1;
- }
- unsigned int required = CMSG_SPACE(sizeof(::ucred)) +
- a.size() * CMSG_SPACE(sizeof(int));
- sendmessage.msg_control = new char[required];
- ::bzero(sendmessage.msg_control, required);
- sendmessage.msg_controllen = required;
-
- // Create ancillary buffer
- ::cmsghdr * h = CMSG_FIRSTHDR(&sendmessage);
-
- if(m.d->state & QUnixSocketMessagePrivate::Credential) {
- h->cmsg_len = CMSG_LEN(sizeof(::ucred));
- h->cmsg_level = SOL_SOCKET;
- h->cmsg_type = SCM_CREDENTIALS;
- ((::ucred *)CMSG_DATA(h))->pid = m.d->pid;
- ((::ucred *)CMSG_DATA(h))->gid = m.d->gid;
- ((::ucred *)CMSG_DATA(h))->uid = m.d->uid;
- h = CMSG_NXTHDR(&sendmessage, h);
- } else {
- sendmessage.msg_controllen -= CMSG_SPACE(sizeof(::ucred));
- }
-
- for(int ii = 0; ii < a.count(); ++ii) {
- const QUnixSocketRights & r = a.at(ii);
-
- if(r.isValid()) {
- h->cmsg_len = CMSG_LEN(sizeof(int));
- h->cmsg_level = SOL_SOCKET;
- h->cmsg_type = SCM_RIGHTS;
- *((int *)CMSG_DATA(h)) = r.peekFd();
- h = CMSG_NXTHDR(&sendmessage, h);
- } else {
- sendmessage.msg_controllen -= CMSG_SPACE(sizeof(int));
- }
- }
-
-#ifdef QUNIXSOCKET_DEBUG
- qDebug() << "QUnixSocket: Transmitting message (length" << m.d->size() << ')';
-#endif
- ::ssize_t s = ::sendmsg(fd, &sendmessage, MSG_DONTWAIT | MSG_NOSIGNAL);
-#ifdef QUNIXSOCKET_DEBUG
- qDebug() << "QUnixSocket: Transmitted message (" << s << ')';
-#endif
-
- if(-1 == s) {
- if(EAGAIN == errno || EWOULDBLOCK == errno || EINTR == errno) {
- writeNotifier->setEnabled(true);
- } else if(EPIPE == errno) {
-#ifdef QUNIXSOCKET_DEBUG
- qDebug() << "QUnixSocket: Remote side disconnected during transmit "
- "(" << ::strerror(errno) << ')';
-#endif
- me->abort();
- } else {
-#ifdef QUNIXSOCKET_DEBUG
- qDebug() << "QUnixSocket: Unable to transmit data ("
- << ::strerror(errno) << ')';
-#endif
- error = (QUnixSocket::SocketError)(QUnixSocket::WriteFailure |
- CausedAbort);
- me->abort();
- }
- } else if(s != m.d->size()) {
-
- // A partial transmission
- writeNotifier->setEnabled(true);
- delete [] (char *)sendmessage.msg_control;
- m.d->rights = QList<QUnixSocketRights>();
- m.d->removeBytes( s );
- writeQueueBytes -= s;
- emit bytesWritten(s);
- return s;
-
- } else {
-
- // Success!
- writeQueue.dequeue();
- Q_ASSERT(writeQueueBytes >= (unsigned)s);
- writeQueueBytes -= s;
- emit bytesWritten(s);
-
- }
-
- delete [] (char *)sendmessage.msg_control;
- if(-1 != s && !writeQueue.isEmpty())
- return writeActivated();
- else if(QUnixSocket::ClosingState == me->state() && writeQueue.isEmpty())
- me->abort();
-
- if((-1 == s) && (EAGAIN == errno || EWOULDBLOCK == errno || EINTR == errno))
- // Return zero bytes written to indicate retry may be required
- return 0;
- else
- return s;
-}
-
-void QUnixSocketPrivate::readActivated()
-{
-#ifdef QUNIXSOCKET_DEBUG
- qDebug() << "QUnixSocket: readActivated";
-#endif
- readNotifier->setEnabled(false);
-
- ::iovec vec;
- vec.iov_base = dataBuffer;
- vec.iov_len = dataBufferCapacity;
-
- bzero(&message, sizeof(::msghdr));
- message.msg_iov = &vec;
- message.msg_iovlen = 1;
- message.msg_controllen = ancillaryBufferCapacity();
- message.msg_control = ancillaryBuffer;
-
- int flags = 0;
-#ifdef MSG_CMSG_CLOEXEC
- flags = MSG_CMSG_CLOEXEC;
-#endif
-
- int recvrv = ::recvmsg(fd, &message, flags);
-#ifdef QUNIXSOCKET_DEBUG
- qDebug() << "QUnixSocket: Received message (" << recvrv << ')';
-#endif
- if(-1 == recvrv) {
-#ifdef QUNIXSOCKET_DEBUG
- qDebug() << "QUnixSocket: Unable to receive data ("
- << ::strerror(errno) << ')';
-#endif
- error = (QUnixSocket::SocketError)(QUnixSocket::ReadFailure |
- CausedAbort);
- me->abort();
- } else if(0 == recvrv) {
- me->abort();
- } else {
- Q_ASSERT(recvrv);
- Q_ASSERT((unsigned)recvrv <= dataBufferCapacity);
- dataBufferLength = recvrv;
- messageValid = true;
-
-#ifdef QUNIXSOCKET_DEBUG
- qDebug() << "QUnixSocket: readyRead() " << dataBufferLength;
-#endif
- emit readyRead();
- }
-}
-
-QT_END_NAMESPACE
-
-#include "qunixsocket.moc"
diff --git a/src/gui/embedded/qunixsocket_p.h b/src/gui/embedded/qunixsocket_p.h
deleted file mode 100644
index cfa463001f..0000000000
--- a/src/gui/embedded/qunixsocket_p.h
+++ /dev/null
@@ -1,202 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QUNIXSOCKET_P_H
-#define QUNIXSOCKET_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtNetwork/qabstractsocket.h>
-#include <QtCore/qiodevice.h>
-#include <QtCore/qlist.h>
-#include <QtCore/qshareddata.h>
-
-extern "C" {
-#include <sys/types.h>
-};
-
-QT_BEGIN_NAMESPACE
-
-class QUnixSocketRights;
-class QUnixSocketRightsPrivate;
-class QUnixSocketPrivate;
-class QUnixSocketMessagePrivate;
-struct iovec;
-
-class Q_GUI_EXPORT QUnixSocketRights {
-public:
- QUnixSocketRights(int);
- ~QUnixSocketRights();
-
- QUnixSocketRights(const QUnixSocketRights &);
- QUnixSocketRights & operator=(const QUnixSocketRights &);
-
- bool isValid() const;
-
- int dupFd() const;
- int peekFd() const;
-
-private:
- friend class QUnixSocket;
- QUnixSocketRights(int,int);
- QSharedDataPointer<QUnixSocketRightsPrivate> d;
-};
-
-class Q_GUI_EXPORT QUnixSocketMessage {
-public:
- QUnixSocketMessage();
- QUnixSocketMessage(const QByteArray &);
- QUnixSocketMessage(const QByteArray &, const QList<QUnixSocketRights> &);
- QUnixSocketMessage(const QUnixSocketMessage &);
- QUnixSocketMessage(const iovec*, int);
- QUnixSocketMessage & operator=(const QUnixSocketMessage &);
- ~QUnixSocketMessage();
-
- void setBytes(const QByteArray &);
- void setRights(const QList<QUnixSocketRights> &);
-
- const QList<QUnixSocketRights> & rights() const;
- bool rightsWereTruncated() const;
-
- const QByteArray & bytes() const;
-
- pid_t processId() const;
- uid_t userId() const;
- gid_t groupId() const;
-
- void setProcessId(pid_t);
- void setUserId(uid_t);
- void setGroupId(gid_t);
-
- bool isValid() const;
-private:
- friend class QUnixSocket;
- friend class QUnixSocketPrivate;
- QSharedDataPointer<QUnixSocketMessagePrivate> d;
-};
-
-class Q_GUI_EXPORT QUnixSocket : public QIODevice
-{
- Q_OBJECT
-public:
- QUnixSocket(QObject * = 0);
- QUnixSocket(qint64, qint64, QObject * = 0);
- virtual ~QUnixSocket();
-
- enum SocketState {
- UnconnectedState = QAbstractSocket::UnconnectedState,
- HostLookupState = QAbstractSocket::HostLookupState,
- ConnectingState = QAbstractSocket::ConnectingState,
- ConnectedState = QAbstractSocket::ConnectedState,
- BoundState = QAbstractSocket::BoundState,
- ClosingState = QAbstractSocket::ClosingState,
- ListeningState = QAbstractSocket::ListeningState,
- };
-
- enum SocketError { NoError, InvalidPath, ResourceError,
- NonexistentPath, ConnectionRefused, UnknownError,
- ReadFailure, WriteFailure };
-
- bool connect(const QByteArray & path);
- bool setSocketDescriptor(int socketDescriptor);
- int socketDescriptor() const;
- void abort();
- void close();
-
- bool flush();
-
- SocketError error() const;
-
- SocketState state() const;
- QByteArray address() const;
-
- qint64 bytesAvailable() const;
- qint64 bytesToWrite() const;
-
- qint64 readBufferSize() const;
- void setReadBufferSize(qint64 size);
- qint64 rightsBufferSize() const;
- void setRightsBufferSize(qint64 size);
-
- bool canReadLine() const;
-
- qint64 write(const char * data, qint64 maxSize)
- { return QIODevice::write(data, maxSize); }
- qint64 write(const QByteArray & byteArray)
- { return QIODevice::write(byteArray); }
- qint64 read(char * data, qint64 maxSize)
- { return QIODevice::read(data, maxSize); }
- QByteArray read(qint64 maxSize)
- { return QIODevice::read(maxSize); }
-
- qint64 write(const QUnixSocketMessage &);
- QUnixSocketMessage read();
-
- virtual bool isSequential() const;
- virtual bool waitForReadyRead(int msec = 300);
- virtual bool waitForBytesWritten(int msec = 300);
-
-Q_SIGNALS:
- void stateChanged(SocketState socketState);
-
-protected:
- virtual qint64 readData(char * data, qint64 maxSize);
- virtual qint64 writeData (const char * data, qint64 maxSize);
-
-private:
- QUnixSocket(const QUnixSocket &);
- QUnixSocket & operator=(const QUnixSocket &);
-
- QUnixSocketPrivate * d;
-};
-
-QT_END_NAMESPACE
-
-#endif // QUNIXSOCKET_P_H
diff --git a/src/gui/embedded/qunixsocketserver.cpp b/src/gui/embedded/qunixsocketserver.cpp
deleted file mode 100644
index 36060fdd29..0000000000
--- a/src/gui/embedded/qunixsocketserver.cpp
+++ /dev/null
@@ -1,376 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qunixsocketserver_p.h"
-
-// #define QUNIXSOCKETSERVER_DEBUG
-
-#ifdef QUNIXSOCKETSERVER_DEBUG
-#include <QDebug>
-#endif
-
-#include <QtCore/qsocketnotifier.h>
-
-extern "C" {
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <unistd.h>
-#include <errno.h>
-};
-
-#define UNIX_PATH_MAX 108 // From unix(7)
-
-QT_BEGIN_NAMESPACE
-
-class QUnixSocketServerPrivate : public QObject
-{
-Q_OBJECT
-public:
- QUnixSocketServerPrivate(QUnixSocketServer * parent)
- : QObject(), me(parent), fd(-1), maxConns(30),
- error(QUnixSocketServer::NoError), acceptNotifier(0)
- {}
-
- QUnixSocketServer * me;
- int fd;
- int maxConns;
- QByteArray address;
- QUnixSocketServer::ServerError error;
- QSocketNotifier * acceptNotifier;
-public slots:
- void acceptActivated();
-};
-
-/*!
- \class QUnixSocketServer
- \internal
-
- \brief The QUnixSocketServer class provides a Unix domain socket based server.
- \omit
- \ingroup Platform::DeviceSpecific
- \ingroup Platform::OS
- \ingroup Platform::Communications
- \endomit
- \ingroup qws
-
- This class makes it possible to accept incoming Unix domain socket
- connections. Call \l QUnixSocketServer::listen() to have the server listen
- for incoming connections on a specified path. The pure virtual
- \l QUnixSocketServer::incomingConnection() is called each time a new
- connection is established. Users must inherit from QUnixSocketServer and
- implement this method.
-
- If an error occurs, \l QUnixSocketServer::serverError() returns the type of
- error. Errors can only occur during server establishment - that is, during a
- call to \l QUnixSocketServer::listen(). Calling \l QUnixSocketServer::close()
- causes QUnixSocketServer to stop listening for connections and reset its
- state.
-
- QUnixSocketServer is often used in conjunction with the \l QUnixSocket class.
-
- \sa QUnixSocket
-*/
-
-/*!
- \enum QUnixSocketServer::ServerError
-
- The ServerError enumeration represents the errors that can occur during server
- establishment. The most recent error can be retrieved through a call to
- \l QUnixSocketServer::serverError().
-
- \value NoError No error has occurred.
- \value InvalidPath An invalid path endpoint was passed to
- \l QUnixSocketServer::listen(). As defined by unix(7), invalid paths
- include an empty path, or what more than 107 characters long.
- \value ResourceError An error acquiring or manipulating the system's socket
- resources occurred. For example, if the process runs out of available
- socket descriptors, a ResourceError will occur.
- \value BindError The server was unable to bind to the specified path.
- \value ListenError The server was unable to listen on the specified path for
- incoming connections.
- */
-
-/*!
- Create a new Unix socket server with the given \a parent.
- */
-QUnixSocketServer::QUnixSocketServer(QObject *parent)
-: QObject(parent), d(0)
-{
-}
-
-/*!
- Stops listening for incoming connection and destroys the Unix socket server.
- */
-QUnixSocketServer::~QUnixSocketServer()
-{
- close();
- if(d)
- delete d;
-}
-
-/*!
- Stop listening for incoming connections and resets the Unix socket server's
- state. Calling this method while \l {QUnixSocketServer::isListening()}{not listening } for incoming connections is a no-op.
-
- \sa QUnixSocketServer::listen()
- */
-void QUnixSocketServer::close()
-{
- if(!d)
- return;
-
- if(d->acceptNotifier) {
- d->acceptNotifier->setEnabled(false);
- delete d->acceptNotifier;
- }
- d->acceptNotifier = 0;
-
- if(-1 != d->fd) {
-#ifdef QUNIXSOCKET_DEBUG
- int closerv =
-#endif
- ::close(d->fd);
-#ifdef QUNIXSOCKET_DEBUG
- if(0 != closerv) {
- qDebug() << "QUnixSocketServer: Unable to close socket ("
- << strerror(errno) << ')';
- }
-#endif
- }
- d->fd = -1;
- d->address = QByteArray();
- d->error = NoError;
-}
-
-/*!
- Returns the last server error. Errors may only occur within a call to
- \l QUnixSocketServer::listen(), and only when such a call fails.
-
- This method is not destructive, so multiple calls to
- QUnixSocketServer::serverError() will return the same value. The error is
- only reset by an explicit call to \l QUnixSocketServer::close() or
- by further calls to \l QUnixSocketServer::listen().
- */
-QUnixSocketServer::ServerError QUnixSocketServer::serverError() const
-{
- if(!d)
- return NoError;
-
- return d->error;
-}
-
-/*!
- Returns true if this server is listening for incoming connections, false
- otherwise.
-
- \sa QUnixSocketServer::listen()
- */
-bool QUnixSocketServer::isListening() const
-{
- if(!d)
- return false;
-
- return (-1 != d->fd);
-}
-
-/*!
- Tells the server to listen for incoming connections on \a path. Returns true
- if it successfully initializes, false otherwise. In the case of failure, the
- \l QUnixSocketServer::serverError() error status is set accordingly.
-
- Calling this method while the server is already running will result in the
- server begin reset, and then attempting to listen on \a path. This will not
- affect connections established prior to the server being reset, but further
- incoming connections on the previous path will be refused.
-
- The server can be explicitly reset by a call to \l QUnixSocketServer::close().
-
- \sa QUnixSocketServer::close()
- */
-bool QUnixSocketServer::listen(const QByteArray & path)
-{
- if(d) {
- close(); // Any existing server is destroyed
- } else {
- d = new QUnixSocketServerPrivate(this);
- }
-
- if(path.isEmpty() || path.size() > UNIX_PATH_MAX) {
- d->error = InvalidPath;
- return false;
- }
- unlink( path ); // ok if this fails
-
- // Create the socket
- d->fd = ::socket(PF_UNIX, SOCK_STREAM, 0);
- if(-1 == d->fd) {
-#ifdef QUNIXSOCKETSERVER_DEBUG
- qDebug() << "QUnixSocketServer: Unable to create socket ("
- << strerror(errno) << ')';
-#endif
- close();
- d->error = ResourceError;
- return false;
- }
-
- // Construct our unix address
- struct ::sockaddr_un addr;
- addr.sun_family = AF_UNIX;
- ::memcpy(addr.sun_path, path.data(), path.size());
- if(path.size() < UNIX_PATH_MAX)
- addr.sun_path[path.size()] = '\0';
-
- // Attempt to bind
- if(-1 == ::bind(d->fd, (sockaddr *)&addr, sizeof(sockaddr_un))) {
-#ifdef QUNIXSOCKETSERVER_DEBUG
- qDebug() << "QUnixSocketServer: Unable to bind socket ("
- << strerror(errno) << ')';
-#endif
- close();
- d->error = BindError;
- return false;
- }
-
- // Listen to socket
- if(-1 == ::listen(d->fd, d->maxConns)) {
-#ifdef QUNIXSOCKETSERVER_DEBUG
- qDebug() << "QUnixSocketServer: Unable to listen socket ("
- << strerror(errno) << ')';
-#endif
- close();
- d->error = ListenError;
- return false;
- }
-
- // Success!
- d->address = path;
- d->acceptNotifier = new QSocketNotifier(d->fd, QSocketNotifier::Read, d);
- d->acceptNotifier->setEnabled(true);
- QObject::connect(d->acceptNotifier, SIGNAL(activated(int)),
- d, SLOT(acceptActivated()));
-
- return true;
-}
-
-/*!
- Returns the Unix path on which this server is listening. If this server is
- not listening, and empty address will be returned.
- */
-QByteArray QUnixSocketServer::serverAddress() const
-{
- if(!d)
- return QByteArray();
- return d->address;
-}
-
-int QUnixSocketServer::socketDescriptor() const
-{
- if (!d)
- return -1;
- return d->fd;
-}
-
-
-/*!
- Returns the maximum length the queue of pending connections may grow to. That
- is, the maximum number of clients attempting to connect for which the Unix
- socket server has not yet accepted and passed to
- \l QUnixSocketServer::incomingConnection(). If a connection request arrives
- with the queue full, the client may receive a connection refused notification.
-
- By default a queue length of 30 is used.
-
- \sa QUnixSocketServer::setMaxPendingConnections()
- */
-int QUnixSocketServer::maxPendingConnections() const
-{
- if(!d)
- return 30;
-
- return d->maxConns;
-}
-
-/*!
- Sets the maximum length the queue of pending connections may grow to
- \a numConnections. This value will only apply to
- \l QUnixSocketServer::listen() calls made following the value change - it will
- not be retroactively applied.
-
- \sa QUnixSocketServer::maxPendingConnections()
- */
-void QUnixSocketServer::setMaxPendingConnections(int numConnections)
-{
- Q_ASSERT(numConnections >= 1);
- if(!d)
- d = new QUnixSocketServerPrivate(this);
-
- d->maxConns = numConnections;
-}
-
-/*!
- \fn void QUnixSocketServer::incomingConnection(int socketDescriptor)
-
- This method is invoked each time a new incoming connection is established with
- the server. Clients must reimplement this function in their QUnixSocketServer
- derived class to handle the connection.
-
- A common approach to handling the connection is to pass \a socketDescriptor to
- a QUnixSocket instance.
-
- \sa QUnixSocket
- */
-
-void QUnixSocketServerPrivate::acceptActivated()
-{
- ::sockaddr_un r;
- socklen_t len = sizeof(sockaddr_un);
- int connsock = ::accept(fd, (sockaddr *)&r, &len);
-#ifdef QUNIXSOCKETSERVER_DEBUG
- qDebug() << "QUnixSocketServer: Accept connection " << connsock;
-#endif
- if(-1 != connsock)
- me->incomingConnection(connsock);
-}
-
-QT_END_NAMESPACE
-
-#include "qunixsocketserver.moc"
diff --git a/src/gui/embedded/qunixsocketserver_p.h b/src/gui/embedded/qunixsocketserver_p.h
deleted file mode 100644
index d7b0a45782..0000000000
--- a/src/gui/embedded/qunixsocketserver_p.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QUNIXSOCKETSERVER_P_H
-#define QUNIXSOCKETSERVER_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_NAMESPACE
-
-class QUnixSocketServerPrivate;
-class Q_GUI_EXPORT QUnixSocketServer : public QObject
-{
- Q_OBJECT
-public:
- enum ServerError { NoError, InvalidPath, ResourceError, BindError,
- ListenError };
-
- QUnixSocketServer(QObject *parent=0);
- virtual ~QUnixSocketServer();
-
- void close();
-
- ServerError serverError() const;
-
- bool isListening() const;
- bool listen(const QByteArray & path);
-
- int socketDescriptor() const;
- QByteArray serverAddress() const;
-
- int maxPendingConnections() const;
- void setMaxPendingConnections(int numConnections);
-
-protected:
- virtual void incomingConnection(int socketDescriptor) = 0;
-
-private:
- QUnixSocketServer(const QUnixSocketServer &);
- QUnixSocketServer & operator=(const QUnixSocketServer &);
-
- friend class QUnixSocketServerPrivate;
- QUnixSocketServerPrivate * d;
-};
-
-
-QT_END_NAMESPACE
-#endif // QUNIXSOCKETSERVER_P_H
-
diff --git a/src/gui/embedded/qvfbhdr.h b/src/gui/embedded/qvfbhdr.h
deleted file mode 100644
index 84f82acd69..0000000000
--- a/src/gui/embedded/qvfbhdr.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QVFBHDR_H
-#define QVFBHDR_H
-
-#include <QtGui/qcolor.h>
-#include <QtGui/qwindowdefs.h>
-#include <QtCore/qrect.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_QWS_TEMP_DIR
-# define QT_QWS_TEMP_DIR QLatin1String("/tmp")
-#endif
-
-#ifdef QT_PRIVATE_QWS
-#define QT_VFB_DATADIR(DISPLAY) QString::fromLatin1("%1/qtembedded-%2-%3") \
- .arg(QT_QWS_TEMP_DIR).arg(getuid()).arg(DISPLAY)
-#define QT_VFB_MOUSE_PIPE(DISPLAY) QT_VFB_DATADIR(DISPLAY) \
- .append(QLatin1String("/qtvfb_mouse"))
-#define QT_VFB_KEYBOARD_PIPE(DISPLAY) QT_VFB_DATADIR(DISPLAY) \
- .append(QLatin1String("/qtvfb_keyboard"))
-#define QT_VFB_MAP(DISPLAY) QT_VFB_DATADIR(DISPLAY) \
- .append(QLatin1String("/qtvfb_map"))
-#define QT_VFB_SOUND_PIPE(DISPLAY) QT_VFB_DATADIR(DISPLAY) \
- .append(QLatin1String("/qt_soundserver"))
-#define QTE_PIPE(DISPLAY) QT_VFB_DATADIR(DISPLAY) \
- .append(QLatin1String("/QtEmbedded"))
-#define QTE_PIPE_QVFB(DISPLAY) QTE_PIPE(DISPLAY)
-#else
-#define QT_VFB_DATADIR(DISPLAY) QString::fromLatin1("%1/qtembedded-%2") \
- .arg(QT_QWS_TEMP_DIR).arg(DISPLAY)
-#define QT_VFB_MOUSE_PIPE(DISPLAY) QString::fromLatin1("%1/.qtvfb_mouse-%2") \
- .arg(QT_QWS_TEMP_DIR).arg(DISPLAY)
-#define QT_VFB_KEYBOARD_PIPE(DISPLAY) QString::fromLatin1("%1/.qtvfb_keyboard-%2") \
- .arg(QT_QWS_TEMP_DIR).arg(DISPLAY)
-#define QT_VFB_MAP(DISPLAY) QString::fromLatin1("%1/.qtvfb_map-%2") \
- .arg(QT_QWS_TEMP_DIR).arg(DISPLAY)
-#define QT_VFB_SOUND_PIPE(DISPLAY) QString::fromLatin1("%1/.qt_soundserver-%2") \
- .arg(QT_QWS_TEMP_DIR).arg(DISPLAY)
-#define QTE_PIPE(DISPLAY) QT_VFB_DATADIR(DISPLAY) \
- .append(QLatin1String("/QtEmbedded-%1")).arg(DISPLAY)
-#define QTE_PIPE_QVFB(DISPLAY) QTE_PIPE(DISPLAY)
-#endif
-
-struct QVFbHeader
-{
- int width;
- int height;
- int depth;
- int linestep;
- int dataoffset;
- QRect update;
- bool dirty;
- int numcols;
- QRgb clut[256];
- int viewerVersion;
- int serverVersion;
- int brightness; // since 4.4.0
- WId windowId; // since 4.5.0
-};
-
-struct QVFbKeyData
-{
- unsigned int keycode;
- Qt::KeyboardModifiers modifiers;
- unsigned short int unicode;
- bool press;
- bool repeat;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QVFBHDR_H
diff --git a/src/gui/embedded/qwindowsystem_p.h b/src/gui/embedded/qwindowsystem_p.h
deleted file mode 100644
index 31190033f2..0000000000
--- a/src/gui/embedded/qwindowsystem_p.h
+++ /dev/null
@@ -1,315 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSYSTEM_QWS_P_H
-#define QWINDOWSYSTEM_QWS_P_H
-
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QWSServer class. This header file may change from
-// version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "private/qobject_p.h"
-#include "qwindowsystem_qws.h"
-#include "qbrush.h"
-#include "qwsproperty_qws.h"
-#include "qwscommand_qws_p.h"
-#include "QtCore/qbasictimer.h"
-
-QT_BEGIN_NAMESPACE
-
-class QWSServerPrivate : public QObjectPrivate {
- friend class QCopChannel;
- friend class QWSMouseHandler;
- friend class QWSWindow;
- friend class QWSDisplay;
- friend class QWSInputMethod;
- Q_DECLARE_PUBLIC(QWSServer)
-
-public:
- QWSServerPrivate()
- : screensaverintervals(0)
- , screensavereventblocklevel(-1), screensaverblockevents(false)
- , saver(0), cursorClient(0), mouseState(0), nReserved(0)
- , doClientIsActive(false)
- {
- }
- ~QWSServerPrivate()
- {
- closeDisplay();
-
- qDeleteAll(deletedWindows);
- delete [] screensaverintervals;
- delete saver;
-
- qDeleteAll(windows);
- windows.clear();
-
- delete bgBrush;
- bgBrush = 0;
- }
- QTime screensavertime;
- QTimer* screensavertimer;
- int* screensaverintervals;
- int screensavereventblocklevel;
- bool screensaverblockevents;
- bool screensaverblockevent( int index, int *screensaverinterval, bool isDown );
- QWSScreenSaver* saver;
- QWSClient *cursorClient;
- int mouseState;
-// bool prevWin;
- QList<QWSWindow*> deletedWindows;
- QList<int> crashedClientIds;
-
- void update_regions();
-//private functions moved from class
-
-private:
- void initServer(int flags);
-#ifndef QT_NO_COP
- static void sendQCopEvent(QWSClient *c, const QString &ch,
- const QString &msg, const QByteArray &data,
- bool response = false);
-#endif
- void move_region(const QWSRegionMoveCommand *);
- void set_altitude(const QWSChangeAltitudeCommand *);
- void set_opacity(const QWSSetOpacityCommand *);
- void request_focus(const QWSRequestFocusCommand *);
- QRegion reserve_region(QWSWindow *window, const QRegion &region);
- void request_region(int winId, const QString &surfaceKey,
- const QByteArray &surfaceData,
- const QRegion &region);
- void repaint_region(int winId, int windowFlags, bool opaque, const QRegion &);
- void destroy_region(const QWSRegionDestroyCommand *);
- void name_region(const QWSRegionNameCommand *);
- void set_identity(const QWSIdentifyCommand *);
-#ifndef QT_NO_QWS_PROPERTIES
- bool get_property(int winId, int property, const char *&data, int &len);
-#endif
-#ifndef QT_NO_QWS_INPUTMETHODS
- void im_response(const QWSIMResponseCommand *);
-
- void im_update(const QWSIMUpdateCommand *);
-
- void send_im_mouse(const QWSIMMouseCommand *);
-#endif
- // not in ifndef as this results in more readable functions.
- static void sendKeyEventUnfiltered(int unicode, int keycode, Qt::KeyboardModifiers modifiers,
- bool isPress, bool autoRepeat);
- static void sendMouseEventUnfiltered(const QPoint &pos, int state, int wheel = 0);
- static void emergency_cleanup();
-
- static QBrush *bgBrush;
-
- void sendMaxWindowRectEvents(const QRect &rect);
-
- void invokeIdentify(const QWSIdentifyCommand *cmd, QWSClient *client);
- void invokeCreate(QWSCreateCommand *cmd, QWSClient *client);
- void invokeRegionName(const QWSRegionNameCommand *cmd, QWSClient *client);
- void invokeRegion(QWSRegionCommand *cmd, QWSClient *client);
- void invokeRegionMove(const QWSRegionMoveCommand *cmd, QWSClient *client);
- void invokeRegionDestroy(const QWSRegionDestroyCommand *cmd, QWSClient *client);
- void invokeSetAltitude(const QWSChangeAltitudeCommand *cmd, QWSClient *client);
- void invokeSetOpacity(const QWSSetOpacityCommand *cmd, QWSClient *client);
-#ifndef QT_NO_QWS_PROPERTIES
- void invokeAddProperty(QWSAddPropertyCommand *cmd);
- void invokeSetProperty(QWSSetPropertyCommand *cmd);
- void invokeRemoveProperty(QWSRemovePropertyCommand *cmd);
- void invokeGetProperty(QWSGetPropertyCommand *cmd, QWSClient *client);
-#endif //QT_NO_QWS_PROPERTIES
- void invokeSetSelectionOwner(QWSSetSelectionOwnerCommand *cmd);
- void invokeConvertSelection(QWSConvertSelectionCommand *cmd);
- void invokeSetFocus(const QWSRequestFocusCommand *cmd, QWSClient *client);
-
- void initIO();
- void setFocus(QWSWindow*, bool gain);
-#ifndef QT_NO_QWS_CURSOR
- void invokeDefineCursor(QWSDefineCursorCommand *cmd, QWSClient *client);
- void invokeSelectCursor(QWSSelectCursorCommand *cmd, QWSClient *client);
- void invokePositionCursor(QWSPositionCursorCommand *cmd, QWSClient *client);
-#endif
- void invokeGrabMouse(QWSGrabMouseCommand *cmd, QWSClient *client);
- void invokeGrabKeyboard(QWSGrabKeyboardCommand *cmd, QWSClient *client);
-#ifndef QT_NO_SOUND
- void invokePlaySound(QWSPlaySoundCommand *cmd, QWSClient *client);
-#endif
-#ifndef QT_NO_COP
- void invokeRegisterChannel(QWSQCopRegisterChannelCommand *cmd,
- QWSClient *client);
- void invokeQCopSend(QWSQCopSendCommand *cmd, QWSClient *client);
-#endif
- void invokeRepaintRegion(QWSRepaintRegionCommand *cmd,
- QWSClient *client);
-#ifndef QT_NO_QWSEMBEDWIDGET
- void invokeEmbed(QWSEmbedCommand *cmd, QWSClient *client);
-#endif
-#ifndef QT_NO_QWS_INPUTMETHODS
- void invokeIMResponse(const QWSIMResponseCommand *cmd,
- QWSClient *client);
- void invokeIMUpdate(const QWSIMUpdateCommand *cmd,
- QWSClient *client);
-#endif
- void invokeFont(const QWSFontCommand *cmd, QWSClient *client);
- void invokeScreenTransform(const QWSScreenTransformCommand *cmd,
- QWSClient *client);
-
- QWSMouseHandler* newMouseHandler(const QString& spec);
- void openDisplay();
- void closeDisplay();
-
- void showCursor();
- void hideCursor();
- void initializeCursor();
-
- void resetEngine();
-
-//private Q_SLOTS:
-
-#ifndef QT_NO_QWS_MULTIPROCESS
- void _q_clientClosed();
- void _q_doClient();
- void _q_deleteWindowsLater();
-#endif
-
- void _q_screenSaverWake();
- void _q_screenSaverSleep();
- void _q_screenSaverTimeout();
-#ifndef QT_NO_QWS_MULTIPROCESS
- void _q_newConnection();
-#endif
-
-//other private moved from class
-
- void disconnectClient(QWSClient *);
- void screenSave(int level);
- void doClient(QWSClient *);
- typedef QMap<int,QWSClient*>::Iterator ClientIterator;
- typedef QMap<int,QWSClient*> ClientMap;
- void handleWindowClose(QWSWindow *w);
- void releaseMouse(QWSWindow* w);
- void releaseKeyboard(QWSWindow* w);
- void updateClientCursorPos();
-
- uchar* sharedram;
- int ramlen;
-
- ClientMap clientMap;
-#ifndef QT_NO_QWS_PROPERTIES
- QWSPropertyManager propertyManager;
-#endif
- struct SelectionOwner {
- int windowid;
- struct Time {
- void set(int h, int m, int s, int s2) {
- hour = h; minute = m; sec = s; ms = s2;
- }
- int hour, minute, sec, ms;
- } time;
- } selectionOwner;
- QTime timer;
- int* screensaverinterval;
-
- QWSWindow *focusw;
- QWSWindow *mouseGrabber;
- bool mouseGrabbing;
- bool inputMethodMouseGrabbed;
- int swidth, sheight, sdepth;
-#ifndef QT_NO_QWS_CURSOR
- bool haveviscurs;
- QWSCursor *cursor; // cursor currently shown
- QWSCursor *nextCursor; // cursor to show once grabbing is off
-#endif
-
- bool disablePainting;
- QList<QWSMouseHandler*> mousehandlers;
-#ifndef QT_NO_QWS_KEYBOARD
- QList<QWSKeyboardHandler*> keyboardhandlers;
-#endif
-
- QList<QWSCommandStruct*> commandQueue;
-
- // Window management
- QList<QWSWindow*> windows; // first=topmost
- int nReserved;
- QWSWindow* newWindow(int id, QWSClient* client);
- QWSWindow* findWindow(int windowid, QWSClient* client = 0);
- void moveWindowRegion(QWSWindow*, int dx, int dy);
- void setWindowRegion(QWSWindow*, const QRegion &r);
- void raiseWindow(QWSWindow *, int = 0);
- void lowerWindow(QWSWindow *, int = -1);
- void exposeRegion(const QRegion &, int index = 0);
-
- void setCursor(QWSCursor *curs);
-
- // multimedia
-#ifndef QT_NO_SOUND
- QWSSoundServer *soundserver;
-#endif
-#ifndef QT_NO_COP
- QMap<QString, QList<QWSClient*> > channels;
-#endif
-
-#ifndef QT_NO_QWS_MULTIPROCESS
- QWSServerSocket *ssocket;
-#endif
-
- // filename -> refcount
- QMap<QByteArray, int> fontReferenceCount;
- QBasicTimer fontCleanupTimer;
- void referenceFont(QWSClientPrivate *client, const QByteArray &font);
- void dereferenceFont(QWSClientPrivate *client, const QByteArray &font);
- void cleanupFonts(bool force = false);
- void sendFontRemovedEvent(const QByteArray &font);
-
- bool doClientIsActive;
- QList<QWSClient*> pendingDoClients;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/gui/embedded/qwindowsystem_qws.cpp b/src/gui/embedded/qwindowsystem_qws.cpp
deleted file mode 100644
index 0d1ae0d2d2..0000000000
--- a/src/gui/embedded/qwindowsystem_qws.cpp
+++ /dev/null
@@ -1,4960 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qplatformdefs.h"
-
-#include "qwindowsystem_qws.h"
-#include "qwsevent_qws.h"
-#include "qwscommand_qws_p.h"
-#include "qtransportauth_qws_p.h"
-#include "qwsutils_qws.h"
-#include "qwscursor_qws.h"
-#include "qwsdisplay_qws.h"
-#include "qmouse_qws.h"
-#include "qcopchannel_qws.h"
-#include "qwssocket_qws.h"
-
-#include "qapplication.h"
-#include "private/qapplication_p.h"
-#include "qsocketnotifier.h"
-#include "qpolygon.h"
-#include "qimage.h"
-#include "qcursor.h"
-#include <private/qpaintengine_raster_p.h>
-#include "qscreen_qws.h"
-#include "qwindowdefs.h"
-#include "private/qlock_p.h"
-#include "qwslock_p.h"
-#include "qfile.h"
-#include "qtimer.h"
-#include "qpen.h"
-#include "qdesktopwidget.h"
-#include "qevent.h"
-#include "qinputcontext.h"
-#include "qpainter.h"
-
-#include <qdebug.h>
-
-#include "qkbddriverfactory_qws.h"
-#include "qmousedriverfactory_qws.h"
-
-#include <qbuffer.h>
-#include <qdir.h>
-
-#include <private/qwindowsurface_qws_p.h>
-#include <private/qfontengine_qpf_p.h>
-
-#include "qwindowsystem_p.h"
-
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <errno.h>
-
-#ifndef QT_NO_QWS_MULTIPROCESS
-#include <sys/param.h>
-#include <sys/mount.h>
-#endif
-
-#if !defined(QT_NO_SOUND) && !defined(Q_OS_DARWIN)
-#ifdef QT_USE_OLD_QWS_SOUND
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <sys/soundcard.h>
-#else
-#include "qsoundqss_qws.h"
-#endif
-#endif
-
-//#define QWS_DEBUG_FONTCLEANUP
-
-QT_BEGIN_NAMESPACE
-
-QWSServer Q_GUI_EXPORT *qwsServer=0;
-static QWSServerPrivate *qwsServerPrivate=0;
-
-#define MOUSE 0
-#define KEY 1
-//#define EVENT_BLOCK_DEBUG
-
-QWSScreenSaver::~QWSScreenSaver()
-{
-}
-
-extern QByteArray qws_display_spec;
-extern void qt_init_display(); //qapplication_qws.cpp
-extern QString qws_qtePipeFilename();
-
-extern void qt_client_enqueue(const QWSEvent *); //qapplication_qws.cpp
-extern QList<QWSCommand*> *qt_get_server_queue();
-
-Q_GLOBAL_STATIC_WITH_ARGS(QString, defaultMouse, (QLatin1String("Auto")))
-Q_GLOBAL_STATIC_WITH_ARGS(QString, defaultKeyboard, (QLatin1String("TTY")))
-static const int FontCleanupInterval = 60 * 1000;
-
-static int qws_keyModifiers = 0;
-
-static QWSWindow *keyboardGrabber;
-static bool keyboardGrabbing;
-
-static int get_object_id(int count = 1)
-{
- static int next=1000;
- int n = next;
- next += count;
- return n;
-}
-#ifndef QT_NO_QWS_INPUTMETHODS
-static QWSInputMethod *current_IM = 0;
-
-static QWSWindow *current_IM_composing_win = 0;
-static int current_IM_winId = -1;
-static bool force_reject_strokeIM = false;
-#endif
-
-static void cleanupFontsDir();
-
-//#define QWS_REGION_DEBUG
-
-/*!
- \class QWSScreenSaver
- \ingroup qws
-
- \brief The QWSScreenSaver class is a base class for screensavers
- in Qt for Embedded Linux.
-
- When running \l{Qt for Embedded Linux} applications, it is the server
- application that installs and controls the screensaver.
- \l{Qt for Embedded Linux} supports multilevel screen saving; i.e., it is possible to
- specify several different levels of screen responsiveness. For
- example, you can choose to first turn off the light before you
- fully activate the screensaver.
-
- Note that there exists no default screensaver implementation.
-
- To create a custom screensaver, derive from this class and
- reimplement the restore() and save() functions. These functions
- are called whenever the screensaver is activated or deactivated,
- respectively. Once an instance of your custom screensaver is
- created, you can use the QWSServer::setScreenSaver() function to
- install it.
-
- \sa QWSServer, QScreen, {Qt for Embedded Linux}
-*/
-
-/*!
- \fn QWSScreenSaver::~QWSScreenSaver()
-
- Reimplement this function to destroy the screensaver.
-*/
-
-/*!
- \fn QWSScreenSaver::restore()
-
- Implement this function to deactivate the screensaver, restoring
- the previously saved screen.
-
- \sa save(), QWSServer::screenSaverActivate()
-*/
-
-/*!
- \fn QWSScreenSaver::save(int level)
-
- Implement this function to activate the screensaver, saving the
- current screen.
-
- \l{Qt for Embedded Linux} supports multilevel screen saving; i.e., it is
- possible to specify several different levels of screen
- responsiveness. For example, you can choose to first turn off the
- light before you fully activate the screensaver. Use the
- QWSServer::setScreenSaverIntervals() to specify the time intervals
- between the different levels.
-
- This function should return true if the screensaver successfully
- enters the given \a level; otherwise it should return false.
-
- \sa restore(), QWSServer::screenSaverActivate()
-*/
-
-class QWSWindowPrivate
-{
-public:
- QWSWindowPrivate();
-
-#ifdef QT_QWS_CLIENTBLIT
- QRegion directPaintRegion;
-#endif
- QRegion allocatedRegion;
-#ifndef QT_NO_QWSEMBEDWIDGET
- QList<QWSWindow*> embedded;
- QWSWindow *embedder;
-#endif
- QWSWindow::State state;
- Qt::WindowFlags windowFlags;
- QRegion dirtyOnScreen;
- bool painted;
-};
-
-QWSWindowPrivate::QWSWindowPrivate()
- :
-#ifndef QT_NO_QWSEMBEDWIDGET
- embedder(0), state(QWSWindow::NoState),
-#endif
- painted(false)
-{
-}
-
-/*!
- \class QWSWindow
- \ingroup qws
-
- \brief The QWSWindow class encapsulates a top-level window in
- Qt for Embedded Linux.
-
- When you run a \l{Qt for Embedded Linux} application, it either runs as a
- server or connects to an existing server. As applications add and
- remove windows, the server process maintains information about
- each window. In \l{Qt for Embedded Linux}, top-level windows are
- encapsulated as QWSWindow objects. Note that you should never
- construct the QWSWindow class yourself; the current top-level
- windows can be retrieved using the QWSServer::clientWindows()
- function.
-
- With a window at hand, you can retrieve its caption, name, opacity
- and ID using the caption(), name(), opacity() and winId()
- functions, respectively. Use the client() function to retrieve a
- pointer to the client that owns the window.
-
- Use the isVisible() function to find out if the window is
- visible. You can find out if the window is completely obscured by
- another window or by the bounds of the screen, using the
- isFullyObscured() function. The isOpaque() function returns true
- if the window has an alpha channel equal to 255. Finally, the
- requestedRegion() function returns the region of the display the
- window wants to draw on.
-
- \sa QWSServer, QWSClient, {Qt for Embedded Linux Architecture}
-*/
-
-/*!
- \fn int QWSWindow::winId() const
-
- Returns the window's ID.
-
- \sa name(), caption()
-*/
-
-/*!
- \fn const QString &QWSWindow::name() const
-
- Returns the window's name, which is taken from the \l {QWidget::}{objectName()}
- at the time of \l {QWidget::}{show()}.
-
- \sa caption(), winId()
-*/
-
-/*!
- \fn const QString &QWSWindow::caption() const
-
- Returns the window's caption.
-
- \sa name(), winId()
-*/
-
-/*!
- \fn QWSClient* QWSWindow::client() const
-
- Returns a reference to the QWSClient object that owns this window.
-
- \sa requestedRegion()
-*/
-
-/*!
- \fn QRegion QWSWindow::requestedRegion() const
-
- Returns the region that the window has requested to draw onto,
- including any window decorations.
-
- \sa client()
-*/
-
-/*!
- \fn bool QWSWindow::isVisible() const
-
- Returns true if the window is visible; otherwise returns false.
-
- \sa isFullyObscured()
-*/
-
-/*!
- \fn bool QWSWindow::isOpaque() const
-
- Returns true if the window is opaque, i.e., if its alpha channel
- equals 255; otherwise returns false.
-
- \sa opacity()
-*/
-
-/*!
- \fn uint QWSWindow::opacity () const
-
- Returns the window's alpha channel value.
-
- \sa isOpaque()
-*/
-
-/*!
- \fn bool QWSWindow::isPartiallyObscured() const
- \internal
-
- Returns true if the window is partially obsured by another window
- or by the bounds of the screen; otherwise returns false.
-*/
-
-/*!
- \fn bool QWSWindow::isFullyObscured() const
-
- Returns true if the window is completely obsured by another window
- or by the bounds of the screen; otherwise returns false.
-
- \sa isVisible()
-*/
-
-/*!
- \fn QWSWindowSurface* QWSWindow::windowSurface() const
- \internal
-*/
-
-QWSWindow::QWSWindow(int i, QWSClient* client)
- : id(i), modified(false),
- onTop(false), c(client), last_focus_time(0), _opacity(255),
- opaque(true), d(new QWSWindowPrivate)
-{
- surface = 0;
-}
-
-
-/*!
- \enum QWSWindow::State
-
- This enum describes the state of a window. Most of the
- transitional states are set just before a call to
- QScreen::exposeRegion() and reset immediately afterwards.
-
- \value NoState Initial state before the window is properly initialized.
- \value Hidden The window is not visible.
- \value Showing The window is being shown.
- \value Visible The window is visible, and not in a transition.
- \value Hiding The window is being hidden.
- \value Raising The windoe is being raised.
- \value Lowering The window is being raised.
- \value Moving The window is being moved.
- \value ChangingGeometry The window's geometry is being changed.
- \value Destroyed The window is destroyed.
-
- \sa state(), QScreen::exposeRegion()
-*/
-
-/*!
- Returns the current state of the window.
-
- \since 4.3
-*/
-QWSWindow::State QWSWindow::state() const
-{
- return d->state;
-}
-
-/*!
- Returns the window flags of the window. This value is only available
- after the first paint event.
-
- \since 4.3
-*/
-Qt::WindowFlags QWSWindow::windowFlags() const
-{
- return d->windowFlags;
-}
-
-/*!
- Returns the region that has been repainted since the previous
- QScreen::exposeRegion(), and needs to be copied to the screen.
- \since 4.3
-*/
-QRegion QWSWindow::dirtyOnScreen() const
-{
- return d->dirtyOnScreen;
-}
-
-void QWSWindow::createSurface(const QString &key, const QByteArray &data)
-{
-#ifndef QT_NO_QWS_MULTIPROCESS
- if (surface && !surface->isBuffered())
- c->removeUnbufferedSurface();
-#endif
-
- delete surface;
- surface = qt_screen->createSurface(key);
- surface->setPermanentState(data);
-
-#ifndef QT_NO_QWS_MULTIPROCESS
- if (!surface->isBuffered())
- c->addUnbufferedSurface();
-#endif
-}
-
-/*!
- \internal
- Raises the window above all other windows except "Stay on top" windows.
-*/
-void QWSWindow::raise()
-{
- qwsServerPrivate->raiseWindow(this);
-#ifndef QT_NO_QWSEMBEDWIDGET
- const int n = d->embedded.size();
- for (int i = 0; i < n; ++i)
- d->embedded.at(i)->raise();
-#endif
-}
-
-/*!
- \internal
- Lowers the window below other windows.
-*/
-void QWSWindow::lower()
-{
- qwsServerPrivate->lowerWindow(this);
-#ifndef QT_NO_QWSEMBEDWIDGET
- const int n = d->embedded.size();
- for (int i = 0; i < n; ++i)
- d->embedded.at(i)->lower();
-#endif
-}
-
-/*!
- \internal
- Shows the window.
-*/
-void QWSWindow::show()
-{
- operation(QWSWindowOperationEvent::Show);
-#ifndef QT_NO_QWSEMBEDWIDGET
- const int n = d->embedded.size();
- for (int i = 0; i < n; ++i)
- d->embedded.at(i)->show();
-#endif
-}
-
-/*!
- \internal
- Hides the window.
-*/
-void QWSWindow::hide()
-{
- operation(QWSWindowOperationEvent::Hide);
-#ifndef QT_NO_QWSEMBEDWIDGET
- const int n = d->embedded.size();
- for (int i = 0; i < n; ++i)
- d->embedded.at(i)->hide();
-#endif
-}
-
-/*!
- \internal
- Make this the active window (i.e., sets the keyboard focus to this
- window).
-*/
-void QWSWindow::setActiveWindow()
-{
- qwsServerPrivate->setFocus(this, true);
-#ifndef QT_NO_QWSEMBEDWIDGET
- const int n = d->embedded.size();
- for (int i = 0; i < n; ++i)
- d->embedded.at(i)->setActiveWindow();
-#endif
-}
-
-void QWSWindow::setName(const QString &n)
-{
- rgnName = n;
-}
-
-/*!
- \internal
- Sets the window's caption to \a c.
-*/
-void QWSWindow::setCaption(const QString &c)
-{
- rgnCaption = c;
-}
-
-
-static int global_focus_time_counter=100;
-
-void QWSWindow::focus(bool get)
-{
- if (get)
- last_focus_time = global_focus_time_counter++;
- if (c) {
- QWSFocusEvent event;
- event.simpleData.window = id;
- event.simpleData.get_focus = get;
- c->sendEvent(&event);
- }
-}
-
-void QWSWindow::operation(QWSWindowOperationEvent::Operation o)
-{
- if (!c)
- return;
- QWSWindowOperationEvent event;
- event.simpleData.window = id;
- event.simpleData.op = o;
- c->sendEvent(&event);
-}
-
-/*!
- \internal
- Destructor.
-*/
-QWSWindow::~QWSWindow()
-{
-#ifndef QT_NO_QWS_INPUTMETHODS
- if (current_IM_composing_win == this)
- current_IM_composing_win = 0;
-#endif
-#ifndef QT_NO_QWSEMBEDWIDGET
- QWSWindow *embedder = d->embedder;
- if (embedder) {
- embedder->d->embedded.removeAll(this);
- d->embedder = 0;
- }
- while (!d->embedded.isEmpty())
- stopEmbed(d->embedded.first());
-#endif
-
-#ifndef QT_NO_QWS_MULTIPROCESS
- if (surface && !surface->isBuffered()) {
- if (c && c->d_func()) // d_func() will be 0 if client is deleted
- c->removeUnbufferedSurface();
- }
-#endif
-
- delete surface;
- delete d;
-}
-
-/*!
- \internal
-
- Returns the region that the window is allowed to draw onto,
- including any window decorations but excluding regions covered by
- other windows.
-
- \sa paintedRegion(), requestedRegion()
-*/
-QRegion QWSWindow::allocatedRegion() const
-{
- return d->allocatedRegion;
-}
-
-#ifdef QT_QWS_CLIENTBLIT
-QRegion QWSWindow::directPaintRegion() const
-{
- return d->directPaintRegion;
-}
-
-inline void QWSWindow::setDirectPaintRegion(const QRegion &r)
-{
- d->directPaintRegion = r;
-}
-#endif
-
-/*!
- \internal
-
- Returns the region that the window is known to have drawn into.
-
- \sa allocatedRegion(), requestedRegion()
-*/
-QRegion QWSWindow::paintedRegion() const
-{
- return (d->painted ? d->allocatedRegion : QRegion());
-}
-
-inline void QWSWindow::setAllocatedRegion(const QRegion &region)
-{
- d->allocatedRegion = region;
-}
-
-#ifndef QT_NO_QWSEMBEDWIDGET
-inline void QWSWindow::startEmbed(QWSWindow *w)
-{
- d->embedded.append(w);
- w->d->embedder = this;
-}
-
-inline void QWSWindow::stopEmbed(QWSWindow *w)
-{
- w->d->embedder = 0;
- w->client()->sendEmbedEvent(w->winId(), QWSEmbedEvent::Region, QRegion());
- d->embedded.removeAll(w);
-}
-#endif // QT_NO_QWSEMBEDWIDGET
-
-/*********************************************************************
- *
- * Class: QWSClient
- *
- *********************************************************************/
-
-class QWSClientPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QWSClient)
-
-public:
- QWSClientPrivate();
- ~QWSClientPrivate();
-
- void setLockId(int id);
- void unlockCommunication();
-
-private:
-#ifndef QT_NO_QWS_MULTIPROCESS
- QWSLock *clientLock;
- bool shutdown;
- int numUnbufferedSurfaces;
-#endif
- QSet<QByteArray> usedFonts;
- friend class QWSServerPrivate;
-};
-
-QWSClientPrivate::QWSClientPrivate()
-{
-#ifndef QT_NO_QWS_MULTIPROCESS
- clientLock = 0;
- shutdown = false;
- numUnbufferedSurfaces = 0;
-#endif
-}
-
-QWSClientPrivate::~QWSClientPrivate()
-{
-#ifndef QT_NO_QWS_MULTIPROCESS
- delete clientLock;
-#endif
-}
-
-void QWSClientPrivate::setLockId(int id)
-{
-#ifdef QT_NO_QWS_MULTIPROCESS
- Q_UNUSED(id);
-#else
- clientLock = new QWSLock(id);
-#endif
-}
-
-void QWSClientPrivate::unlockCommunication()
-{
-#ifndef QT_NO_QWS_MULTIPROCESS
- if (clientLock)
- clientLock->unlock(QWSLock::Communication);
-#endif
-}
-
-/*!
- \class QWSClient
- \ingroup qws
-
- \brief The QWSClient class encapsulates a client process in Qt for Embedded Linux.
-
- When you run a \l{Qt for Embedded Linux} application, it either runs as a
- server or connects to an existing server. The server and client
- processes have different responsibilities: The client process
- performs all application specific operations. The server process
- is responsible for managing the clients as well as taking care of
- the pointer handling, character input, and screen output. In
- addition, the server provides functionality to handle input
- methods.
-
- As applications add and remove windows, the server process
- maintains information about each window. In \l{Qt for Embedded Linux},
- top-level windows are encapsulated as QWSWindow objects. A list of
- the current windows can be retrieved using the
- QWSServer::clientWindows() function, and each window can tell
- which client that owns it through its QWSWindow::client()
- function.
-
- A QWSClient object has an unique ID that can be retrieved using
- its clientId() function. QWSClient also provides the identity()
- function which typically returns the name of this client's running
- application.
-
- \sa QWSServer, QWSWindow, {Qt for Embedded Linux Architecture}
-*/
-
-/*!
- \internal
-*/
-//always use frame buffer
-QWSClient::QWSClient(QObject* parent, QWS_SOCK_BASE* sock, int id)
- : QObject(*new QWSClientPrivate, parent), command(0), cid(id)
-{
-#ifdef QT_NO_QWS_MULTIPROCESS
- Q_UNUSED(sock);
- isClosed = false;
-#else
- csocket = 0;
- if (!sock) {
- socketDescriptor = -1;
- isClosed = false;
- } else {
- csocket = static_cast<QWSSocket*>(sock); //###
- isClosed = false;
-
- csocket->flush();
- socketDescriptor = csocket->socketDescriptor();
- connect(csocket, SIGNAL(readyRead()), this, SIGNAL(readyRead()));
- connect(csocket, SIGNAL(disconnected()), this, SLOT(closeHandler()));
- connect(csocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(errorHandler()));
- }
-#endif //QT_NO_QWS_MULTIPROCESS
-}
-
-/*!
- \internal
-*/
-QWSClient::~QWSClient()
-{
- qDeleteAll(cursors);
- delete command;
-#ifndef QT_NO_QWS_MULTIPROCESS
- delete csocket;
-#endif
-}
-
-#ifndef QT_NO_QWS_MULTIPROCESS
-void QWSClient::removeUnbufferedSurface()
-{
- Q_D(QWSClient);
- --d->numUnbufferedSurfaces;
-}
-
-void QWSClient::addUnbufferedSurface()
-{
- Q_D(QWSClient);
- ++d->numUnbufferedSurfaces;
-}
-#endif // QT_NO_QWS_MULTIPROCESS
-
-/*!
- \internal
-*/
-void QWSClient::setIdentity(const QString& i)
-{
- id = i;
-}
-
-void QWSClient::closeHandler()
-{
- isClosed = true;
- emit connectionClosed();
-}
-
-void QWSClient::errorHandler()
-{
-#if defined(QWS_SOCKET_DEBUG)
- qDebug("Client %p error %s", this, csocket ? csocket->errorString().toLatin1().constData() : "(no socket)");
-#endif
- isClosed = true;
-//####Do we need to clean out the pipes?
-
- emit connectionClosed();
-}
-
-/*!
- \internal
-*/
-int QWSClient::socket() const
-{
- return socketDescriptor;
-}
-
-/*!
- \internal
-*/
-void QWSClient::sendEvent(QWSEvent* event)
-{
-#ifndef QT_NO_QWS_MULTIPROCESS
- if (csocket) {
- // qDebug() << "QWSClient::sendEvent type " << event->type << " socket state " << csocket->state();
- if ((QAbstractSocket::SocketState)(csocket->state()) == QAbstractSocket::ConnectedState) {
- event->write(csocket);
- }
- }
- else
-#endif
- {
- qt_client_enqueue(event);
- }
-}
-
-/*!
- \internal
-*/
-void QWSClient::sendRegionEvent(int winid, QRegion rgn, int type
-#ifdef QT_QWS_CLIENTBLIT
- , int id
-#endif
- )
-{
-#ifndef QT_NO_QWS_MULTIPROCESS
- Q_D(QWSClient);
- if (d->clientLock)
- d->clientLock->lock(QWSLock::RegionEvent);
-#endif
-
- QWSRegionEvent event;
- event.setData(winid, rgn, type);
-#ifdef QT_QWS_CLIENTBLIT
- event.simpleData.id = id;
-#endif
-
-// qDebug() << "Sending Region event to" << winid << "rgn" << rgn << "type" << type;
-
- sendEvent(&event);
-}
-
-extern int qt_servershmid;
-
-/*!
- \internal
-*/
-void QWSClient::sendConnectedEvent(const char *display_spec)
-{
- QWSConnectedEvent event;
- event.simpleData.window = 0;
- event.simpleData.len = strlen(display_spec) + 1;
- event.simpleData.clientId = cid;
- event.simpleData.servershmid = qt_servershmid;
- char * tmp=(char *)display_spec;
- event.setData(tmp, event.simpleData.len);
- sendEvent(&event);
-}
-
-/*!
- \internal
-*/
-void QWSClient::sendMaxWindowRectEvent(const QRect &rect)
-{
- QWSMaxWindowRectEvent event;
- event.simpleData.window = 0;
- event.simpleData.rect = rect;
- sendEvent(&event);
-}
-
-/*!
- \internal
-*/
-#ifndef QT_NO_QWS_PROPERTIES
-void QWSClient::sendPropertyNotifyEvent(int property, int state)
-{
- QWSPropertyNotifyEvent event;
- event.simpleData.window = 0; // not used yet
- event.simpleData.property = property;
- event.simpleData.state = state;
- sendEvent(&event);
-}
-
-/*!
- \internal
-*/
-void QWSClient::sendPropertyReplyEvent(int property, int len, const char *data)
-{
- QWSPropertyReplyEvent event;
- event.simpleData.window = 0; // not used yet
- event.simpleData.property = property;
- event.simpleData.len = len;
- event.setData(data, len);
- sendEvent(&event);
-}
-#endif //QT_NO_QWS_PROPERTIES
-
-/*!
- \internal
-*/
-void QWSClient::sendSelectionClearEvent(int windowid)
-{
- QWSSelectionClearEvent event;
- event.simpleData.window = windowid;
- sendEvent(&event);
-}
-
-/*!
- \internal
-*/
-void QWSClient::sendSelectionRequestEvent(QWSConvertSelectionCommand *cmd, int windowid)
-{
- QWSSelectionRequestEvent event;
- event.simpleData.window = windowid;
- event.simpleData.requestor = cmd->simpleData.requestor;
- event.simpleData.property = cmd->simpleData.selection;
- event.simpleData.mimeTypes = cmd->simpleData.mimeTypes;
- sendEvent(&event);
-}
-
-#ifndef QT_NO_QWSEMBEDWIDGET
-/*!
- \internal
-*/
-void QWSClient::sendEmbedEvent(int windowid, QWSEmbedEvent::Type type,
- const QRegion &region)
-{
- QWSEmbedEvent event;
- event.setData(windowid, type, region);
- sendEvent(&event);
-}
-#endif // QT_NO_QWSEMBEDWIDGET
-
-/*!
- \fn void QWSClient::connectionClosed()
- \internal
-*/
-
-/*!
- \fn void QWSClient::readyRead();
- \internal
-*/
-
-/*!
- \fn int QWSClient::clientId () const
-
- Returns an integer uniquely identfying this client.
-*/
-
-/*!
- \fn QString QWSClient::identity () const
-
- Returns the name of this client's running application.
-*/
-/*********************************************************************
- *
- * Class: QWSServer
- *
- *********************************************************************/
-
-/*!
- \class QWSServer
- \brief The QWSServer class encapsulates a server process in Qt for Embedded Linux.
-
- \ingroup qws
-
- When you run a \l{Qt for Embedded Linux} application, it either runs as a
- server or connects to an existing server. The server and client
- processes have different responsibilities: The client process
- performs all application specific operations. The server process
- is responsible for managing the clients as well as taking care of
- the pointer handling, character input, and screen output. In
- addition, the server provides functionality to handle input
- methods.
-
- In \l{Qt for Embedded Linux}, all system generated events are passed to the
- server application which then propagates the event to the
- appropriate client. See the \l{Qt for Embedded Linux Architecture}
- documentation for details.
-
- Note that this class is instantiated by QApplication for
- \l{Qt for Embedded Linux} server processes; you should never construct this
- class yourself. Use the instance() function to retrieve a pointer
- to the server object.
-
- Note that the static functions of the QWSServer class can only be
- used in the server process.
-
- \tableofcontents
-
- \section1 Client Administration
-
- As applications add and remove windows, the server process
- maintains information about each window. In \l{Qt for Embedded Linux},
- top-level windows are encapsulated as QWSWindow objects. Each
- window can tell which client that owns it through its
- QWSWindow::client() function. Use the clientWindows() function to
- retrieve a list of the current top-level windows. Given a
- particular position on the display, the window containing it can
- be retrieved using the windowAt() function.
-
- QWSServer also provides the windowEvent() signal which is emitted
- whenever something happens to a top level window; the WindowEvent
- enum describes the various types of events that the signal
- recognizes. In addition, the server class provides the
- markedText() signal which is emitted whenever some text has been
- selected in any of the windows, passing the selection as
- parameter.
-
- The QCopChannel class and the QCOP communication protocol enable
- transfer of messages between clients. QWSServer provides the
- newChannel() and removedChannel() signals that is emitted whenever
- a new QCopChannel object is created or destroyed, respectively.
-
- See also: QWSWindow, QWSClient and QCopChannel.
-
-
- \section1 Mouse Handling
-
- The mouse driver (represented by an instance of the
- QWSMouseHandler class) is loaded by the server application when it
- starts running, using Qt's \l {How to Create Qt Plugins}{plugin
- system}. A mouse driver receives mouse events from the device and
- encapsulates each event with an instance of the QWSEvent class
- which it then passes to the server.
-
- The openMouse() function opens the mouse devices specified by the
- QWS_MOUSE_PROTO environment variable, and the setMouseHandler()
- functions sets the primary mouse driver. Alternatively, the static
- setDefaultMouse() function provides means of specifying the mouse
- driver to use if the QWS_MOUSE_PROTO variable is not defined (note
- that the default is otherwise platform dependent). The primary
- mouse driver can be retrieved using the static mouseHandler()
- function. Use the closeMouse() function to delete the mouse
- drivers.
-
- In addition, the QWSServer class can control the flow of mouse
- input using the suspendMouse() and resumeMouse() functions.
-
- See also: QWSMouseHandler and \l{Qt for Embedded Linux Pointer Handling}.
-
- \section1 Keyboard Handling
-
- The keyboard driver (represented by an instance of the
- QWSKeyboardHandler class) is loaded by the server application when
- it starts running, using Qt's \l {How to Create Qt Plugins}{plugin
- system}. A keyboard driver receives keyboard events from the
- device and encapsulates each event with an instance of the
- QWSEvent class which it then passes to the server.
-
- The openKeyboard() function opens the keyboard devices specified
- by the QWS_KEYBOARD environment variable, and the
- setKeyboardHandler() functions sets the primary keyboard
- driver. Alternatively, the static setDefaultKeyboard() function
- provides means of specifying the keyboard driver to use if the
- QWS_KEYBOARD variable is not defined (note again that the default
- is otherwise platform dependent). The primary keyboard driver can
- be retrieved using the static keyboardHandler() function. Use the
- closeKeyboard() function to delete the keyboard drivers.
-
- In addition, the QWSServer class can handle key events from both
- physical and virtual keyboards using the processKeyEvent() and
- sendKeyEvent() functions, respectively. Use the
- addKeyboardFilter() function to filter the key events from
- physical keyboard drivers, the most recently added filter can be
- removed and deleted using the removeKeyboardFilter() function.
-
- See also: QWSKeyboardHandler and \l{Qt for Embedded Linux Character Input}.
-
- \section1 Display Handling
-
- When a screen update is required, the server runs through all the
- top-level windows that intersect with the region that is about to
- be updated, and ensures that the associated clients have updated
- their memory buffer. Then the server uses the screen driver
- (represented by an instance of the QScreen class) to copy the
- content of the memory to the screen.
-
- In addition, the QWSServer class provides some means of managing
- the screen output: Use the refresh() function to refresh the
- entire display, or alternatively a specified region of it. The
- enablePainting() function can be used to disable (and enable)
- painting onto the screen. QWSServer also provide the
- setMaxWindowRect() function restricting the area of the screen
- which \l{Qt for Embedded Linux} applications will consider to be the
- maximum area to use for windows. To set the brush used as the
- background in the absence of obscuring windows, QWSServer provides
- the static setBackground() function. The corresponding
- backgroundBrush() function returns the currently set brush.
-
- QWSServer also controls the screen saver: Use the setScreenSaver()
- to install a custom screen saver derived from the QWSScreenSaver
- class. Once installed, the screensaver can be activated using the
- screenSaverActivate() function, and the screenSaverActive()
- function returns its current status. Use the
- setScreenSaverInterval() function to specify the timeout interval.
- \l{Qt for Embedded Linux} also supports multilevel screen saving, use the
- setScreenSaverIntervals() function to specify the various levels
- and their timeout intervals.
-
- Finally, the QWSServer class controls the cursor's appearance,
- i.e., use the setCursorVisible() function to hide or show the
- cursor, and the isCursorVisible() function to determine whether
- the cursor is visible on the display or not.
-
- See also: QScreen and \l{Qt for Embedded Linux Display Management}.
-
- \section1 Input Method Handling
-
- Whenever the server receives an event, it queries its stack of
- top-level windows to find the window containing the event's
- position (each window can identify the client application that
- created it). Then the server forwards the event to the appropriate
- client. If an input method is installed, it is used as a filter
- between the server and the client application.
-
- Derive from the QWSInputMethod class to create custom input
- methods, and use the server's setCurrentInputMethod() function to
- install it. Use the sendIMEvent() and sendIMQuery() functions to
- send input method events and queries.
-
- QWSServer provides the IMMouse enum describing the various mouse
- events recognized by the QWSInputMethod::mouseHandler()
- function. The latter function allows subclasses of QWSInputMethod
- to handle mouse events within the preedit text.
-
- \sa QWSInputMethod
-*/
-
-/*!
- \enum QWSServer::IMState
- \obsolete
-
- This enum describes the various states of an input method.
-
- \value IMCompose Composing.
- \value IMStart Equivalent to IMCompose.
- \value IMEnd Finished composing.
-
- \sa QWSInputMethod::sendIMEvent()
-*/
-
-/*!
- \enum QWSServer::IMMouse
-
- This enum describes the various types of mouse events recognized
- by the QWSInputMethod::mouseHandler() function.
-
- \value MousePress An event generated by pressing a mouse button.
- \value MouseRelease An event generated by relasing a mouse button.
- \value MouseMove An event generated by moving the mouse cursor.
- \value MouseOutside This value is only reserved, i.e., it is not used in
- current implementations.
-
- \sa QWSInputMethod, setCurrentInputMethod()
-*/
-
-/*!
- \enum QWSServer::ServerFlags
- \internal
-
- This enum is used to pass various options to the window system
- server.
-
- \value DisableKeyboard Ignore all keyboard input.
- \value DisableMouse Ignore all mouse input.
-*/
-
-/*!
- \enum QWSServer::WindowEvent
-
- This enum specifies the various events that can occur in a
- top-level window.
-
- \value Create A new window has been created (by the QWidget constructor).
- \value Destroy The window has been closed and deleted (by the QWidget destructor).
- \value Hide The window has been hidden using the QWidget::hide() function.
- \value Show The window has been shown using the QWidget::show() function or similar.
- \value Raise The window has been raised to the top of the desktop.
- \value Lower The window has been lowered.
- \value Geometry The window has changed size or position.
- \value Active The window has become the active window (i.e., it has keyboard focus).
- \value Name The window has been named.
-
- \sa windowEvent()
-*/
-
-/*!
- \fn void QWSServer::markedText(const QString &selection)
-
- This signal is emitted whenever some text is selected in any of
- the running applications, passing the selected text in the \a
- selection parameter.
-
- \sa windowEvent()
-*/
-
-/*!
- \fn const QList<QWSWindow*> &QWSServer::clientWindows()
-
- Returns the list of current top-level windows.
-
- Note that the collection of top-level windows changes as
- applications add and remove widgets so it should not be stored for
- future use. The windows are sorted in stacking order from top-most
- to bottom-most.
-
- Use the QWSWindow::client() function to retrieve the client
- application that owns a given window.
-
- \sa windowAt(), instance()
-*/
-
-/*!
- \fn void QWSServer::newChannel(const QString& channel)
-
- This signal is emitted whenever a new QCopChannel object is
- created, passing the channel's name in the \a channel parameter.
-
- \sa removedChannel()
-*/
-
-/*!
- \fn void QWSServer::removedChannel(const QString& channel)
-
- This signal is emitted immediately after the given the QCopChannel
- object specified by \a channel, is destroyed.
-
- Note that a channel is not destroyed until all its listeners have
- been unregistered.
-
- \sa newChannel()
-*/
-
-/*!
- \fn QWSServer::QWSServer(int flags, QObject *parent)
- \internal
-
- Construct a QWSServer object with the given \a parent. The \a
- flags are used for keyboard and mouse settings.
-
- \warning This class is instantiated by QApplication for
- \l{Qt for Embedded Linux} server processes. You should never construct
- this class yourself.
-
- \sa {Running Applications}
-*/
-
-/*!
- \fn static QWSServer* QWSServer::instance()
- \since 4.2
-
- Returns a pointer to the server instance.
-
- Note that the pointer will be 0 if the application is not the
- server, i.e., if the QApplication::type() function doesn't return
- QApplication::GuiServer.
-
- \sa clientWindows(), windowAt()
-*/
-
-struct QWSCommandStruct
-{
- QWSCommandStruct(QWSCommand *c, QWSClient *cl) :command(c),client(cl){}
- ~QWSCommandStruct() { delete command; }
-
- QWSCommand *command;
- QWSClient *client;
-
-};
-
-QWSServer::QWSServer(int flags, QObject *parent) :
- QObject(*new QWSServerPrivate, parent)
-{
- Q_D(QWSServer);
- QT_TRY {
- d->initServer(flags);
- } QT_CATCH(...) {
- qwsServer = 0;
- qwsServerPrivate = 0;
- QT_RETHROW;
- }
-}
-
-#ifdef QT3_SUPPORT
-/*!
- Use the two-argument overload and call the
- QObject::setObjectName() function instead.
-*/
-QWSServer::QWSServer(int flags, QObject *parent, const char *name) :
- QObject(*new QWSServerPrivate, parent)
-{
- Q_D(QWSServer);
- setObjectName(QString::fromAscii(name));
- d->initServer(flags);
-}
-#endif
-
-
-#ifndef QT_NO_QWS_MULTIPROCESS
-static void ignoreSignal(int) {} // Used to eat SIGPIPE signals below
-#endif
-
-bool QWSServerPrivate::screensaverblockevent( int index, int *screensaverinterval, bool isDown )
-{
- static bool ignoreEvents[2] = { false, false };
- if ( isDown ) {
- if ( !ignoreEvents[index] ) {
- bool wake = false;
- if ( screensaverintervals ) {
- if ( screensaverinterval != screensaverintervals ) {
- wake = true;
- }
- }
- if ( screensaverblockevents && wake ) {
-#ifdef EVENT_BLOCK_DEBUG
- qDebug( "waking the screen" );
-#endif
- ignoreEvents[index] = true;
- } else if ( !screensaverblockevents ) {
-#ifdef EVENT_BLOCK_DEBUG
- qDebug( "the screen was already awake" );
-#endif
- ignoreEvents[index] = false;
- }
- }
- } else {
- if ( ignoreEvents[index] ) {
-#ifdef EVENT_BLOCK_DEBUG
- qDebug( "mouseup?" );
-#endif
- ignoreEvents[index] = false;
- return true;
- }
- }
- return ignoreEvents[index];
-}
-
-void QWSServerPrivate::initServer(int flags)
-{
- Q_Q(QWSServer);
- Q_ASSERT(!qwsServer);
- qwsServer = q;
- qwsServerPrivate = this;
- disablePainting = false;
-#ifndef QT_NO_QWS_MULTIPROCESS
- ssocket = new QWSServerSocket(qws_qtePipeFilename(), q);
- QObject::connect(ssocket, SIGNAL(newConnection()), q, SLOT(_q_newConnection()));
-
- if ( !ssocket->isListening()) {
- perror("QWSServerPrivate::initServer: server socket not listening");
- qFatal("Failed to bind to %s", qws_qtePipeFilename().toLatin1().constData());
- }
-
- struct linger tmp;
- tmp.l_onoff=1;
- tmp.l_linger=0;
- setsockopt(ssocket->socketDescriptor(),SOL_SOCKET,SO_LINGER,(char *)&tmp,sizeof(tmp));
-
-
- signal(SIGPIPE, ignoreSignal); //we get it when we read
-#endif
- focusw = 0;
- mouseGrabber = 0;
- mouseGrabbing = false;
- inputMethodMouseGrabbed = false;
- keyboardGrabber = 0;
- keyboardGrabbing = false;
-#ifndef QT_NO_QWS_CURSOR
- haveviscurs = false;
- cursor = 0;
- nextCursor = 0;
-#endif
-
-#ifndef QT_NO_QWS_MULTIPROCESS
-
- if (!geteuid()) {
-#if defined(Q_OS_LINUX) && !defined(QT_LINUXBASE)
- if(mount(0,"/var/shm", "shm", 0, 0)) {
- /* This just confuses people with 2.2 kernels
- if (errno != EBUSY)
- qDebug("Failed mounting shm fs on /var/shm: %s",strerror(errno));
- */
- }
-#endif
- }
-#endif
-
- // no selection yet
- selectionOwner.windowid = -1;
- selectionOwner.time.set(-1, -1, -1, -1);
-
- cleanupFontsDir();
-
- // initialize the font database
- // from qfontdatabase_qws.cpp
- extern void qt_qws_init_fontdb();
- qt_qws_init_fontdb();
-
- openDisplay();
-
- screensavertimer = new QTimer(q);
- screensavertimer->setSingleShot(true);
- QObject::connect(screensavertimer, SIGNAL(timeout()), q, SLOT(_q_screenSaverTimeout()));
- _q_screenSaverWake();
-
- clientMap[-1] = new QWSClient(q, 0, 0);
-
- if (!bgBrush)
- bgBrush = new QBrush(QColor(0x20, 0xb0, 0x50));
-
- initializeCursor();
-
- // input devices
- if (!(flags&QWSServer::DisableMouse)) {
- q->openMouse();
- }
-#ifndef QT_NO_QWS_KEYBOARD
- if (!(flags&QWSServer::DisableKeyboard)) {
- q->openKeyboard();
- }
-#endif
-
-#if !defined(QT_NO_SOUND) && !defined(QT_EXTERNAL_SOUND_SERVER) && !defined(Q_OS_DARWIN)
- soundserver = new QWSSoundServer(q);
-#endif
-}
-
-/*!
- \internal
- Destructs this server.
-*/
-QWSServer::~QWSServer()
-{
- closeMouse();
-#ifndef QT_NO_QWS_KEYBOARD
- closeKeyboard();
-#endif
- d_func()->cleanupFonts(/*force =*/true);
-}
-
-/*!
- \internal
- */
-void QWSServer::timerEvent(QTimerEvent *e)
-{
- Q_D(QWSServer);
- if (e->timerId() == d->fontCleanupTimer.timerId()) {
- d->cleanupFonts();
- d->fontCleanupTimer.stop();
- } else {
- QObject::timerEvent(e);
- }
-}
-
-const QList<QWSWindow*> &QWSServer::clientWindows()
-{
- Q_D(QWSServer);
- return d->windows;
-}
-
-/*!
- \internal
-*/
-void QWSServerPrivate::releaseMouse(QWSWindow* w)
-{
- if (w && mouseGrabber == w) {
- mouseGrabber = 0;
- mouseGrabbing = false;
-#ifndef QT_NO_QWS_CURSOR
- if (nextCursor) {
- // Not grabbing -> set the correct cursor
- setCursor(nextCursor);
- nextCursor = 0;
- }
-#endif
- }
-}
-
-/*!
- \internal
-*/
-void QWSServerPrivate::releaseKeyboard(QWSWindow* w)
-{
- if (keyboardGrabber == w) {
- keyboardGrabber = 0;
- keyboardGrabbing = false;
- }
-}
-
-void QWSServerPrivate::handleWindowClose(QWSWindow *w)
-{
- w->shuttingDown();
- if (focusw == w)
- setFocus(w,false);
- if (mouseGrabber == w)
- releaseMouse(w);
- if (keyboardGrabber == w)
- releaseKeyboard(w);
-}
-
-
-#ifndef QT_NO_QWS_MULTIPROCESS
-/*!
- \internal
-*/
-void QWSServerPrivate::_q_newConnection()
-{
- Q_Q(QWSServer);
- while (QWS_SOCK_BASE *sock = ssocket->nextPendingConnection()) {
- int socket = sock->socketDescriptor();
- sock->setParent(0);
-
- QWSClient *client = new QWSClient(q,sock, get_object_id());
- clientMap[socket] = client;
-
-#ifndef QT_NO_SXE
-#ifdef QTRANSPORTAUTH_DEBUG
- qDebug( "Transport auth connected: unix stream socket %d", socket );
-#endif
- // get a handle to the per-process authentication service
- QTransportAuth *a = QTransportAuth::getInstance();
-
- // assert that this transport is trusted
- QTransportAuth::Data *d = a->connectTransport(
- QTransportAuth::UnixStreamSock |
- QTransportAuth::Trusted, socket );
-
- QAuthDevice *ad = a->recvBuf( d, sock );
- ad->setClient(client);
-
- QObject::connect(ad, SIGNAL(readyRead()),
- q, SLOT(_q_doClient()));
-
- QObject::connect(client, SIGNAL(connectionClosed()),
- q, SLOT(_q_clientClosed()));
-#else
- QObject::connect(client, SIGNAL(readyRead()),
- q, SLOT(_q_doClient()));
- QObject::connect(client, SIGNAL(connectionClosed()),
- q, SLOT(_q_clientClosed()));
-#endif // QT_NO_SXE
-
- client->sendConnectedEvent(qws_display_spec.constData());
-
- if (clientMap.contains(socket)) {
- QList<QScreen*> screens = qt_screen->subScreens();
- if (screens.isEmpty())
- screens.append(qt_screen);
- for (int i = 0; i < screens.size(); ++i) {
- const QApplicationPrivate *ap = QApplicationPrivate::instance();
- QScreen *screen = screens.at(i);
- const QRect rect = ap->maxWindowRect(screen);
- if (!rect.isEmpty())
- client->sendMaxWindowRectEvent(rect);
- if (screen->isTransformed()) {
- QWSScreenTransformationEvent event;
- event.simpleData.screen = i;
- event.simpleData.transformation = screen->transformOrientation();
- client->sendEvent(&event);
- }
- }
- }
-
- // pre-provide some object id's
- QWSCreateCommand cmd(30);
- invokeCreate(&cmd, client);
- }
-}
-/*!
- \internal
-*/
-void QWSServerPrivate::_q_clientClosed()
-{
- Q_Q(QWSServer);
- QWSClient* cl = (QWSClient*)q->sender();
-
- // Remove any queued commands for this client
- int i = 0;
- while (i < commandQueue.size()) {
- QWSCommandStruct *cs = commandQueue.at(i);
- if (cs->client == cl) {
- commandQueue.removeAt(i);
- delete cs;
- } else {
- ++i;
- }
- }
-
-#ifndef QT_NO_COP
- // Enfore unsubscription from all channels.
- QCopChannel::detach(cl);
-#endif
-
- // Shut down all windows for this client
- for (int i = 0; i < windows.size(); ++i) {
- QWSWindow* w = windows.at(i);
- if (w->forClient(cl))
- w->shuttingDown();
- }
-
- // Delete all windows for this client
- QRegion exposed;
- i = 0;
- while (i < windows.size()) {
- QWSWindow* w = windows.at(i);
- if (w->forClient(cl)) {
- windows.takeAt(i);
- w->c = 0; //so we don't send events to it anymore
- releaseMouse(w);
- releaseKeyboard(w);
- exposed += w->allocatedRegion();
-// rgnMan->remove(w->allocationIndex());
- if (focusw == w)
- setFocus(focusw,0);
- if (mouseGrabber == w)
- releaseMouse(w);
- if (i < nReserved)
- --nReserved;
-#ifndef QT_NO_QWS_PROPERTIES
- propertyManager.removeProperties(w->winId());
-#endif
- emit q->windowEvent(w, QWSServer::Destroy);
- w->d->state = QWSWindow::Destroyed; //???
- deletedWindows.append(w);
- } else {
- ++i;
- }
- }
- if (deletedWindows.count())
- QTimer::singleShot(0, q, SLOT(_q_deleteWindowsLater()));
-
- QWSClientPrivate *clientPrivate = cl->d_func();
- if (!clientPrivate->shutdown) {
-#if defined(QWS_DEBUG_FONTCLEANUP)
- qDebug() << "client" << cl->clientId() << "crashed";
-#endif
- // this would be the place to emit a signal to notify about the
- // crash of a client
- crashedClientIds.append(cl->clientId());
- fontCleanupTimer.start(10, q_func());
- }
- clientPrivate->shutdown = true;
-
- while (!clientPrivate->usedFonts.isEmpty()) {
- const QByteArray font = *clientPrivate->usedFonts.begin();
-#if defined(QWS_DEBUG_FONTCLEANUP)
- qDebug() << "dereferencing font" << font << "from disconnected client";
-#endif
- dereferenceFont(clientPrivate, font);
- }
- clientPrivate->usedFonts.clear();
-
- //qDebug("removing client %d with socket %d", cl->clientId(), cl->socket());
- clientMap.remove(cl->socket());
- if (cl == cursorClient)
- cursorClient = 0;
- if (qt_screen->clearCacheFunc)
- (qt_screen->clearCacheFunc)(qt_screen, cl->clientId()); // remove any remaining cache entries.
- cl->deleteLater();
-
- update_regions();
- exposeRegion(exposed);
-}
-
-void QWSServerPrivate::_q_deleteWindowsLater()
-{
- qDeleteAll(deletedWindows);
- deletedWindows.clear();
-}
-
-#endif //QT_NO_QWS_MULTIPROCESS
-
-void QWSServerPrivate::referenceFont(QWSClientPrivate *client, const QByteArray &font)
-{
- if (!client->usedFonts.contains(font)) {
- client->usedFonts.insert(font);
-
- ++fontReferenceCount[font];
-#if defined(QWS_DEBUG_FONTCLEANUP)
- qDebug() << "Client" << client->q_func()->clientId() << "added font" << font;
- qDebug() << "Refcount is" << fontReferenceCount[font];
-#endif
- }
-}
-
-void QWSServerPrivate::dereferenceFont(QWSClientPrivate *client, const QByteArray &font)
-{
- if (client->usedFonts.contains(font)) {
- client->usedFonts.remove(font);
-
- Q_ASSERT(fontReferenceCount[font]);
- if (!--fontReferenceCount[font] && !fontCleanupTimer.isActive())
- fontCleanupTimer.start(FontCleanupInterval, q_func());
-
-#if defined(QWS_DEBUG_FONTCLEANUP)
- qDebug() << "Client" << client->q_func()->clientId() << "removed font" << font;
- qDebug() << "Refcount is" << fontReferenceCount[font];
-#endif
- }
-}
-
-static void cleanupFontsDir()
-{
- static bool dontDelete = !qgetenv("QWS_KEEP_FONTS").isEmpty();
- if (dontDelete)
- return;
-
- extern QString qws_fontCacheDir();
- QDir dir(qws_fontCacheDir(), QLatin1String("*.qsf"));
- for (uint i = 0; i < dir.count(); ++i) {
-#if defined(QWS_DEBUG_FONTCLEANUP)
- qDebug() << "removing stale font file" << dir[i];
-#endif
- dir.remove(dir[i]);
- }
-}
-
-void QWSServerPrivate::cleanupFonts(bool force)
-{
- static bool dontDelete = !qgetenv("QWS_KEEP_FONTS").isEmpty();
- if (dontDelete)
- return;
-
-#if defined(QWS_DEBUG_FONTCLEANUP)
- qDebug() << "cleanupFonts()";
-#endif
- if (!fontReferenceCount.isEmpty()) {
- QMap<QByteArray, int>::Iterator it = fontReferenceCount.begin();
- while (it != fontReferenceCount.end()) {
- if (it.value() && !force) {
- ++it;
- continue;
- }
-
- const QByteArray &fontName = it.key();
-#if defined(QWS_DEBUG_FONTCLEANUP)
- qDebug() << "removing unused font file" << fontName;
-#endif
- QT_TRY {
- QFile::remove(QFile::decodeName(fontName));
- sendFontRemovedEvent(fontName);
-
- it = fontReferenceCount.erase(it);
- } QT_CATCH(...) {
- // so we were not able to remove the font.
- // don't be angry and just continue with the next ones.
- ++it;
- }
- }
- }
-
- if (crashedClientIds.isEmpty())
- return;
-
- QList<QByteArray> removedFonts;
-#if !defined(QT_NO_QWS_QPF2) && !defined(QT_FONTS_ARE_RESOURCES)
- removedFonts = QFontEngineQPF::cleanUpAfterClientCrash(crashedClientIds);
-#endif
- crashedClientIds.clear();
-
- for (int i = 0; i < removedFonts.count(); ++i)
- sendFontRemovedEvent(removedFonts.at(i));
-}
-
-void QWSServerPrivate::sendFontRemovedEvent(const QByteArray &font)
-{
- QWSFontEvent event;
- event.simpleData.type = QWSFontEvent::FontRemoved;
- event.setData(font.constData(), font.length(), false);
-
- QMap<int,QWSClient*>::const_iterator it = clientMap.constBegin();
- for (; it != clientMap.constEnd(); ++it)
- (*it)->sendEvent(&event);
-}
-
-/*!
- \internal
-*/
-QWSCommand* QWSClient::readMoreCommand()
-{
-#ifndef QT_NO_QWS_MULTIPROCESS
- QIODevice *socket = 0;
-#endif
-#ifndef QT_NO_SXE
- if (socketDescriptor != -1) // not server socket
- socket = QTransportAuth::getInstance()->passThroughByClient( this );
-#if QTRANSPORTAUTH_DEBUG
- if (socket) {
- char displaybuf[1024];
- qint64 bytes = socket->bytesAvailable();
- if ( bytes > 511 ) bytes = 511;
- hexstring( displaybuf, ((unsigned char *)(reinterpret_cast<QAuthDevice*>(socket)->buffer().constData())), bytes );
- qDebug( "readMoreCommand: %lli bytes - %s", socket->bytesAvailable(), displaybuf );
- }
-#endif
-#endif // QT_NO_SXE
-
-#ifndef QT_NO_QWS_MULTIPROCESS
- if (!socket)
- socket = csocket; // server socket
- if (socket) {
- // read next command
- if (!command) {
- int command_type = qws_read_uint(socket);
-
- if (command_type >= 0)
- command = QWSCommand::factory(command_type);
- }
- if (command) {
- if (command->read(socket)) {
- // Finished reading a whole command.
- QWSCommand* result = command;
- command = 0;
- return result;
- }
- }
-
- // Not finished reading a whole command.
- return 0;
- } else
-#endif // QT_NO_QWS_MULTIPROCESS
- {
- QList<QWSCommand*> *serverQueue = qt_get_server_queue();
- return serverQueue->isEmpty() ? 0 : serverQueue->takeFirst();
- }
-}
-
-
-/*!
- \internal
-*/
-void QWSServer::processEventQueue()
-{
- if (qwsServerPrivate)
- qwsServerPrivate->doClient(qwsServerPrivate->clientMap.value(-1));
-}
-
-
-#ifndef QT_NO_QWS_MULTIPROCESS
-void QWSServerPrivate::_q_doClient()
-{
- Q_Q(QWSServer);
-
- QWSClient* client;
-#ifndef QT_NO_SXE
- QAuthDevice *ad = qobject_cast<QAuthDevice*>(q->sender());
- if (ad)
- client = (QWSClient*)ad->client();
- else
-#endif
- client = (QWSClient*)q->sender();
-
- if (doClientIsActive) {
- pendingDoClients.append(client);
- return;
- }
- doClientIsActive = true;
-
- doClient(client);
-
- while (!pendingDoClients.isEmpty()) {
- doClient(pendingDoClients.takeFirst());
- }
-
- doClientIsActive = false;
-}
-#endif // QT_NO_QWS_MULTIPROCESS
-
-void QWSServerPrivate::doClient(QWSClient *client)
-{
- QWSCommand* command=client->readMoreCommand();
-
- while (command) {
- QWSCommandStruct *cs = new QWSCommandStruct(command, client);
- commandQueue.append(cs);
- // Try for some more...
- command=client->readMoreCommand();
- }
-
- while (!commandQueue.isEmpty()) {
- QWSCommandStruct *cs = commandQueue.takeAt(0);
- switch (cs->command->type) {
- case QWSCommand::Identify:
- invokeIdentify((QWSIdentifyCommand*)cs->command, cs->client);
- break;
- case QWSCommand::Create:
- invokeCreate((QWSCreateCommand*)cs->command, cs->client);
- break;
-#ifndef QT_NO_QWS_MULTIPROCESS
- case QWSCommand::Shutdown:
- cs->client->d_func()->shutdown = true;
- break;
-#endif
- case QWSCommand::RegionName:
- invokeRegionName((QWSRegionNameCommand*)cs->command, cs->client);
- break;
- case QWSCommand::Region:
- invokeRegion((QWSRegionCommand*)cs->command, cs->client);
- cs->client->d_func()->unlockCommunication();
- break;
- case QWSCommand::RegionMove:
- invokeRegionMove((QWSRegionMoveCommand*)cs->command, cs->client);
- cs->client->d_func()->unlockCommunication();
- break;
- case QWSCommand::RegionDestroy:
- invokeRegionDestroy((QWSRegionDestroyCommand*)cs->command, cs->client);
- break;
-#ifndef QT_NO_QWS_PROPERTIES
- case QWSCommand::AddProperty:
- invokeAddProperty((QWSAddPropertyCommand*)cs->command);
- break;
- case QWSCommand::SetProperty:
- invokeSetProperty((QWSSetPropertyCommand*)cs->command);
- break;
- case QWSCommand::RemoveProperty:
- invokeRemoveProperty((QWSRemovePropertyCommand*)cs->command);
- break;
- case QWSCommand::GetProperty:
- invokeGetProperty((QWSGetPropertyCommand*)cs->command, cs->client);
- break;
-#endif
- case QWSCommand::SetSelectionOwner:
- invokeSetSelectionOwner((QWSSetSelectionOwnerCommand*)cs->command);
- break;
- case QWSCommand::RequestFocus:
- invokeSetFocus((QWSRequestFocusCommand*)cs->command, cs->client);
- break;
- case QWSCommand::ChangeAltitude:
- invokeSetAltitude((QWSChangeAltitudeCommand*)cs->command,
- cs->client);
- cs->client->d_func()->unlockCommunication();
- break;
- case QWSCommand::SetOpacity:
- invokeSetOpacity((QWSSetOpacityCommand*)cs->command,
- cs->client);
- break;
-
-#ifndef QT_NO_QWS_CURSOR
- case QWSCommand::DefineCursor:
- invokeDefineCursor((QWSDefineCursorCommand*)cs->command, cs->client);
- break;
- case QWSCommand::SelectCursor:
- invokeSelectCursor((QWSSelectCursorCommand*)cs->command, cs->client);
- break;
- case QWSCommand::PositionCursor:
- invokePositionCursor((QWSPositionCursorCommand*)cs->command, cs->client);
- break;
-#endif
- case QWSCommand::GrabMouse:
- invokeGrabMouse((QWSGrabMouseCommand*)cs->command, cs->client);
- break;
- case QWSCommand::GrabKeyboard:
- invokeGrabKeyboard((QWSGrabKeyboardCommand*)cs->command, cs->client);
- break;
-#if !defined(QT_NO_SOUND) && !defined(Q_OS_DARWIN)
- case QWSCommand::PlaySound:
- invokePlaySound((QWSPlaySoundCommand*)cs->command, cs->client);
- break;
-#endif
-#ifndef QT_NO_COP
- case QWSCommand::QCopRegisterChannel:
- invokeRegisterChannel((QWSQCopRegisterChannelCommand*)cs->command,
- cs->client);
- break;
- case QWSCommand::QCopSend:
- invokeQCopSend((QWSQCopSendCommand*)cs->command, cs->client);
- break;
-#endif
-#ifndef QT_NO_QWS_INPUTMETHODS
- case QWSCommand::IMUpdate:
- invokeIMUpdate((QWSIMUpdateCommand*)cs->command, cs->client);
- break;
- case QWSCommand::IMResponse:
- invokeIMResponse((QWSIMResponseCommand*)cs->command, cs->client);
- break;
- case QWSCommand::IMMouse:
- {
- if (current_IM) {
- QWSIMMouseCommand *cmd = (QWSIMMouseCommand *) cs->command;
- current_IM->mouseHandler(cmd->simpleData.index,
- cmd->simpleData.state);
- }
- }
- break;
-#endif
- case QWSCommand::Font:
- invokeFont((QWSFontCommand *)cs->command, cs->client);
- break;
- case QWSCommand::RepaintRegion:
- invokeRepaintRegion((QWSRepaintRegionCommand*)cs->command,
- cs->client);
- cs->client->d_func()->unlockCommunication();
- break;
-#ifndef QT_NO_QWSEMBEDWIDGET
- case QWSCommand::Embed:
- invokeEmbed(static_cast<QWSEmbedCommand*>(cs->command),
- cs->client);
- break;
-#endif
- case QWSCommand::ScreenTransform:
- invokeScreenTransform(static_cast<QWSScreenTransformCommand*>(cs->command),
- cs->client);
- break;
- }
- delete cs;
- }
-}
-
-
-void QWSServerPrivate::showCursor()
-{
-#ifndef QT_NO_QWS_CURSOR
- if (qt_screencursor)
- qt_screencursor->show();
-#endif
-}
-
-void QWSServerPrivate::hideCursor()
-{
-#ifndef QT_NO_QWS_CURSOR
- if (qt_screencursor)
- qt_screencursor->hide();
-#endif
-}
-
-/*!
- \fn void QWSServer::enablePainting(bool enable)
-
- Enables painting onto the screen if \a enable is true; otherwise
- painting is disabled.
-
- \sa {Qt for Embedded Linux Architecture#Drawing on Screen}{Qt for Embedded Linux
- Architecture}
-*/
-void QWSServer::enablePainting(bool enable)
-{
- Q_D(QWSServer);
-
- if (d->disablePainting == !enable)
- return;
-
- d->disablePainting = !enable;
-
- if (enable) {
- // Reset the server side allocated regions to ensure update_regions()
- // will send out region events.
- for (int i = 0; i < d->windows.size(); ++i) {
- QWSWindow *w = d->windows.at(i);
- w->setAllocatedRegion(QRegion());
-#ifdef QT_QWS_CLIENTBLIT
- w->setDirectPaintRegion(QRegion());
-#endif
- }
- d->update_regions();
- d->showCursor();
- } else {
- // Disable painting by clients by taking away their allocated region.
- // To ensure mouse events are still delivered to the correct windows,
- // the allocated regions are not modified on the server.
- for (int i = 0; i < d->windows.size(); ++i) {
- QWSWindow *w = d->windows.at(i);
- w->client()->sendRegionEvent(w->winId(), QRegion(),
- QWSRegionEvent::Allocation);
-#ifdef QT_QWS_CLIENTBLIT
- w->client()->sendRegionEvent(w->winId(), QRegion(),
- QWSRegionEvent::DirectPaint);
-#endif
- }
- d->hideCursor();
- }
-}
-
-/*!
- Refreshes the display by making the screen driver update the
- entire display.
-
- \sa QScreen::exposeRegion()
-*/
-void QWSServer::refresh()
-{
- Q_D(QWSServer);
- d->exposeRegion(QScreen::instance()->region());
-//### send repaint to non-buffered windows
-}
-
-/*!
- \fn void QWSServer::refresh(QRegion & region)
- \overload
-
- Refreshes the given \a region of the display.
-*/
-void QWSServer::refresh(QRegion & r)
-{
- Q_D(QWSServer);
- d->exposeRegion(r);
-//### send repaint to non-buffered windows
-}
-
-/*!
- \fn void QWSServer::setMaxWindowRect(const QRect& rectangle)
-
- Sets the maximum area of the screen that \l{Qt for Embedded Linux}
- applications can use, to be the given \a rectangle.
-
- Note that this function can only be used in the server process.
-
- \sa QWidget::showMaximized()
-*/
-void QWSServer::setMaxWindowRect(const QRect &rect)
-{
- QList<QScreen*> subScreens = qt_screen->subScreens();
- if (subScreens.isEmpty() && qt_screen != 0)
- subScreens.append(qt_screen);
-
- for (int i = 0; i < subScreens.size(); ++i) {
- const QScreen *screen = subScreens.at(i);
- const QRect r = (screen->region() & rect).boundingRect();
- if (r.isEmpty())
- continue;
-
- QApplicationPrivate *ap = QApplicationPrivate::instance();
- if (ap->maxWindowRect(screen) != r) {
- ap->setMaxWindowRect(screen, i, r);
- qwsServerPrivate->sendMaxWindowRectEvents(r);
- }
- }
-}
-
-/*!
- \internal
-*/
-void QWSServerPrivate::sendMaxWindowRectEvents(const QRect &rect)
-{
- QMap<int,QWSClient*>::const_iterator it = clientMap.constBegin();
- for (; it != clientMap.constEnd(); ++it)
- (*it)->sendMaxWindowRectEvent(rect);
-}
-
-/*!
- \fn void QWSServer::setDefaultMouse(const char *mouseDriver)
-
- Sets the mouse driver that will be used if the QWS_MOUSE_PROTO
- environment variable is not defined, to be the given \a
- mouseDriver.
-
- Note that the default is platform-dependent. This function can
- only be used in the server process.
-
-
- \sa setMouseHandler(), {Qt for Embedded Linux Pointer Handling}
-*/
-void QWSServer::setDefaultMouse(const char *m)
-{
- *defaultMouse() = QString::fromAscii(m);
-}
-
-/*!
- \fn void QWSServer::setDefaultKeyboard(const char *keyboardDriver)
-
- Sets the keyboard driver that will be used if the QWS_KEYBOARD
- environment variable is not defined, to be the given \a
- keyboardDriver.
-
- Note that the default is platform-dependent. This function can
- only be used in the server process.
-
- \sa setKeyboardHandler(), {Qt for Embedded Linux Character Input}
-*/
-void QWSServer::setDefaultKeyboard(const char *k)
-{
- *defaultKeyboard() = QString::fromAscii(k);
-}
-
-#ifndef QT_NO_QWS_CURSOR
-static bool prevWin;
-#endif
-
-
-extern int *qt_last_x,*qt_last_y;
-
-
-/*!
- \internal
-
- Send a mouse event. \a pos is the screen position where the mouse
- event occurred and \a state is a mask indicating which buttons are
- pressed.
-
- \a pos is in device coordinates
-*/
-void QWSServer::sendMouseEvent(const QPoint& pos, int state, int wheel)
-{
- bool block = qwsServerPrivate->screensaverblockevent(MOUSE, qwsServerPrivate->screensaverinterval, state);
-#ifdef EVENT_BLOCK_DEBUG
- qDebug() << "sendMouseEvent" << pos.x() << pos.y() << state << (block ? "block" : "pass");
-#endif
-
- if (state || wheel)
- qwsServerPrivate->_q_screenSaverWake();
-
- if ( block )
- return;
-
- QPoint tpos;
- // transformations
- if (qt_screen->isTransformed()) {
- QSize s = QSize(qt_screen->deviceWidth(), qt_screen->deviceHeight());
- tpos = qt_screen->mapFromDevice(pos, s);
- } else {
- tpos = pos;
- }
-
- if (qt_last_x) {
- *qt_last_x = tpos.x();
- *qt_last_y = tpos.y();
- }
- QWSServer::mousePosition = tpos;
- qwsServerPrivate->mouseState = state;
-
-#ifndef QT_NO_QWS_INPUTMETHODS
- const int btnMask = Qt::LeftButton | Qt::RightButton | Qt::MidButton;
- int stroke_count; // number of strokes to keep shown.
- if (force_reject_strokeIM || !current_IM)
- {
- stroke_count = 0;
- } else {
- stroke_count = current_IM->filter(tpos, state, wheel);
- }
-
- if (stroke_count == 0) {
- if (state&btnMask)
- force_reject_strokeIM = true;
- QWSServerPrivate::sendMouseEventUnfiltered(tpos, state, wheel);
- }
- // stop force reject after stroke ends.
- if (state&btnMask && force_reject_strokeIM)
- force_reject_strokeIM = false;
- // on end of stroke, force_rejct
- // and once a stroke is rejected, do not try again till pen is lifted
-#else
- QWSServerPrivate::sendMouseEventUnfiltered(tpos, state, wheel);
-#endif // end QT_NO_QWS_FSIM
-}
-
-void QWSServerPrivate::sendMouseEventUnfiltered(const QPoint &pos, int state, int wheel)
-{
- const int btnMask = Qt::LeftButton | Qt::RightButton | Qt::MidButton;
- QWSMouseEvent event;
-
- QWSWindow *win = qwsServer->windowAt(pos);
-
- QWSClient *serverClient = qwsServerPrivate->clientMap.value(-1);
- QWSClient *winClient = win ? win->client() : 0;
-
-
- bool imMouse = false;
-#ifndef QT_NO_QWS_INPUTMETHODS
- // check for input method window
- if (current_IM && current_IM_winId != -1) {
- QWSWindow *kbw = keyboardGrabber ? keyboardGrabber :
- qwsServerPrivate->focusw;
-
- imMouse = kbw == win;
- if ( !imMouse ) {
- QWidget *target = winClient == serverClient ?
- QApplication::widgetAt(pos) : 0;
- imMouse = target && (target->testAttribute(Qt::WA_InputMethodTransparent));
- }
- }
-#endif
-
- //If grabbing window disappears, grab is still active until
- //after mouse release.
- if ( qwsServerPrivate->mouseGrabber && (!imMouse || qwsServerPrivate->inputMethodMouseGrabbed)) {
- win = qwsServerPrivate->mouseGrabber;
- winClient = win ? win->client() : 0;
- }
- event.simpleData.window = win ? win->id : 0;
-
-#ifndef QT_NO_QWS_CURSOR
- if (qt_screencursor)
- qt_screencursor->move(pos.x(),pos.y());
-
- // Arrow cursor over desktop
- // prevWin remembers if the last event was over a window
- if (!win && prevWin) {
- if (!qwsServerPrivate->mouseGrabber)
- qwsServerPrivate->setCursor(QWSCursor::systemCursor(Qt::ArrowCursor));
- else
- qwsServerPrivate->nextCursor = QWSCursor::systemCursor(Qt::ArrowCursor);
- prevWin = false;
- }
- // reset prevWin
- if (win && !prevWin)
- prevWin = true;
-#endif
-
- if ((state&btnMask) && !qwsServerPrivate->mouseGrabbing) {
- qwsServerPrivate->mouseGrabber = win;
- if (imMouse)
- qwsServerPrivate->inputMethodMouseGrabbed = true;
- }
- if (!(state&btnMask))
- qwsServerPrivate->inputMethodMouseGrabbed = false;
-
- event.simpleData.x_root=pos.x();
- event.simpleData.y_root=pos.y();
- event.simpleData.state=state | qws_keyModifiers;
- event.simpleData.delta = wheel;
- event.simpleData.time=qwsServerPrivate->timer.elapsed();
-
- static int oldstate = 0;
-
-#ifndef QT_NO_QWS_INPUTMETHODS
- //tell the input method if we click on a different window that is not IM transparent
- bool isPress = state > oldstate;
- if (isPress && !imMouse && current_IM && current_IM_winId != -1)
- current_IM->mouseHandler(-1, QWSServer::MouseOutside);
-#endif
-
- if (serverClient)
- serverClient->sendEvent(&event);
- if (winClient && winClient != serverClient)
- winClient->sendEvent(&event);
-
- if ( !imMouse ) {
- // Make sure that if we leave a window, that window gets one last mouse
- // event so that it knows the mouse has left.
- QWSClient *oldClient = qwsServer->d_func()->cursorClient;
- if (oldClient && oldClient != winClient && oldClient != serverClient) {
- event.simpleData.state = oldstate | qws_keyModifiers;
- oldClient->sendEvent(&event);
- }
- }
-
- oldstate = state;
- if ( !imMouse )
- qwsServer->d_func()->cursorClient = winClient;
-
- if (!(state&btnMask) && !qwsServerPrivate->mouseGrabbing)
- qwsServerPrivate->releaseMouse(qwsServerPrivate->mouseGrabber);
-}
-
-/*!
- Returns the primary mouse driver.
-
- Note that this function can only be used in the server process.
-
- \sa setMouseHandler(), openMouse(), closeMouse()
-*/
-QWSMouseHandler *QWSServer::mouseHandler()
-{
- if (qwsServerPrivate->mousehandlers.empty())
- return 0;
- return qwsServerPrivate->mousehandlers.first();
-}
-
-/*!
- \since 4.5
-
- Returns list of all mouse handlers
-
- Note that this function can only be used in the server process.
-
- \sa mouseHandler(), setMouseHandler(), openMouse(), closeMouse()
-*/
-const QList<QWSMouseHandler*>& QWSServer::mouseHandlers()
-{
- return qwsServerPrivate->mousehandlers;
-}
-
-
-// called by QWSMouseHandler constructor, not user code.
-/*!
- \fn void QWSServer::setMouseHandler(QWSMouseHandler* driver)
-
- Sets the primary mouse driver to be the given \a driver.
-
- \l{Qt for Embedded Linux} provides several ready-made mouse drivers, and
- custom drivers are typically added using Qt's plugin
- mechanism. See the \l{Qt for Embedded Linux Pointer Handling} documentation
- for details.
-
- Note that this function can only be used in the server process.
-
- \sa mouseHandler(), setDefaultMouse()
-*/
-void QWSServer::setMouseHandler(QWSMouseHandler* mh)
-{
- if (!mh)
- return;
- qwsServerPrivate->mousehandlers.removeAll(mh);
- qwsServerPrivate->mousehandlers.prepend(mh);
-}
-
-/*!
- \internal
- \obsolete
- Caller owns data in list, and must delete contents
-*/
-QList<QWSInternalWindowInfo*> * QWSServer::windowList()
-{
- QList<QWSInternalWindowInfo*> * ret=new QList<QWSInternalWindowInfo*>;
- for (int i=0; i < qwsServerPrivate->windows.size(); ++i) {
- QWSWindow *window = qwsServerPrivate->windows.at(i);
- QWSInternalWindowInfo * qwi=new QWSInternalWindowInfo();
- qwi->winid=window->winId();
- qwi->clientid=window->client()->clientId();
- ret->append(qwi);
- }
- return ret;
-}
-
-#ifndef QT_NO_COP
-/*!
- \internal
-*/
-void QWSServerPrivate::sendQCopEvent(QWSClient *c, const QString &ch,
- const QString &msg, const QByteArray &data,
- bool response)
-{
- Q_ASSERT(c);
-
- QWSQCopMessageEvent event;
- event.channel = ch.toLatin1();
- event.message = msg.toLatin1();
- event.data = data;
- event.simpleData.is_response = response;
- event.simpleData.lchannel = ch.length();
- event.simpleData.lmessage = msg.length();
- event.simpleData.ldata = data.size();
- int l = event.simpleData.lchannel + event.simpleData.lmessage +
- event.simpleData.ldata;
-
- // combine channel, message and data into one block of raw bytes
- char *tmp = new char [l];
- char *d = tmp;
- memcpy(d, event.channel.constData(), event.simpleData.lchannel);
- d += event.simpleData.lchannel;
- memcpy(d, event.message.constData(), event.simpleData.lmessage);
- d += event.simpleData.lmessage;
- memcpy(d, data.constData(), event.simpleData.ldata);
-
- event.setDataDirect(tmp, l);
-
- c->sendEvent(&event);
-}
-#endif
-
-/*!
- \fn QWSWindow *QWSServer::windowAt(const QPoint& position)
-
- Returns the window containing the given \a position.
-
- Note that if there is no window under the specified point this
- function returns 0.
-
- \sa clientWindows(), instance()
-*/
-QWSWindow *QWSServer::windowAt(const QPoint& pos)
-{
- Q_D(QWSServer);
- for (int i=0; i<d->windows.size(); ++i) {
- QWSWindow* w = d->windows.at(i);
- if (w->allocatedRegion().contains(pos))
- return w;
- }
- return 0;
-}
-
-#ifndef QT_NO_QWS_KEYBOARD
-static int keyUnicode(int keycode)
-{
- int code = 0xffff;
-
- if (keycode >= Qt::Key_A && keycode <= Qt::Key_Z)
- code = keycode - Qt::Key_A + 'a';
- else if (keycode >= Qt::Key_0 && keycode <= Qt::Key_9)
- code = keycode - Qt::Key_0 + '0';
-
- return code;
-}
-#endif
-
-/*!
- Sends the given key event. The key is identified by its \a unicode
- value and the given \a keycode, \a modifiers, \a isPress and \a
- autoRepeat parameters.
-
- Use this function to send key events generated by "virtual
- keyboards" (note that the processKeyEvent() function is
- impelemented using this function).
-
- The \a keycode parameter is the Qt keycode value as defined by the
- Qt::Key enum. The \a modifiers is an OR combination of
- Qt::KeyboardModifier values, indicating whether \gui
- Shift/Alt/Ctrl keys are pressed. The \a isPress parameter is true
- if the event is a key press event and \a autoRepeat is true if the
- event is caused by an auto-repeat mechanism and not an actual key
- press.
-
- Note that this function can only be used in the server process.
-
- \sa processKeyEvent(), {Qt for Embedded Linux Character Input}
-*/
-void QWSServer::sendKeyEvent(int unicode, int keycode, Qt::KeyboardModifiers modifiers,
- bool isPress, bool autoRepeat)
-{
- qws_keyModifiers = modifiers;
-
- if (isPress) {
- if (keycode != Qt::Key_F34 && keycode != Qt::Key_F35)
- qwsServerPrivate->_q_screenSaverWake();
- }
-
-#ifndef QT_NO_QWS_INPUTMETHODS
-
- if (!current_IM || !current_IM->filter(unicode, keycode, modifiers, isPress, autoRepeat))
- QWSServerPrivate::sendKeyEventUnfiltered(unicode, keycode, modifiers, isPress, autoRepeat);
-#else
- QWSServerPrivate::sendKeyEventUnfiltered(unicode, keycode, modifiers, isPress, autoRepeat);
-#endif
-}
-
-void QWSServerPrivate::sendKeyEventUnfiltered(int unicode, int keycode, Qt::KeyboardModifiers modifiers,
- bool isPress, bool autoRepeat)
-{
-
- QWSKeyEvent event;
- QWSWindow *win = keyboardGrabber ? keyboardGrabber :
- qwsServerPrivate->focusw;
-
- event.simpleData.window = win ? win->winId() : 0;
-
- event.simpleData.unicode =
-#ifndef QT_NO_QWS_KEYBOARD
- unicode < 0 ? keyUnicode(keycode) :
-#endif
- unicode;
- event.simpleData.keycode = keycode;
- event.simpleData.modifiers = modifiers;
- event.simpleData.is_press = isPress;
- event.simpleData.is_auto_repeat = autoRepeat;
-
- QWSClient *serverClient = qwsServerPrivate->clientMap.value(-1);
- QWSClient *winClient = win ? win->client() : 0;
- if (serverClient)
- serverClient->sendEvent(&event);
- if (winClient && winClient != serverClient)
- winClient->sendEvent(&event);
-}
-
-/*!
- \internal
-*/
-void QWSServer::beginDisplayReconfigure()
-{
- qwsServer->enablePainting(false);
-#ifndef QT_NO_QWS_CURSOR
- if (qt_screencursor)
- qt_screencursor->hide();
-#endif
- QWSDisplay::grab(true);
- qt_screen->disconnect();
-}
-
-/*!
- \internal
-*/
-void QWSServer::endDisplayReconfigure()
-{
- qt_screen->connect(QString());
- qwsServerPrivate->swidth = qt_screen->deviceWidth();
- qwsServerPrivate->sheight = qt_screen->deviceHeight();
-
- QWSDisplay::ungrab();
-#ifndef QT_NO_QWS_CURSOR
- if (qt_screencursor)
- qt_screencursor->show();
-#endif
- QApplicationPrivate *ap = QApplicationPrivate::instance();
- ap->setMaxWindowRect(qt_screen, 0,
- QRect(0, 0, qt_screen->width(), qt_screen->height()));
- QSize olds = qApp->desktop()->size();
- qApp->desktop()->resize(qt_screen->width(), qt_screen->height());
- qApp->postEvent(qApp->desktop(), new QResizeEvent(qApp->desktop()->size(), olds));
- qwsServer->enablePainting(true);
- qwsServer->refresh();
- qDebug("Desktop size: %dx%d", qApp->desktop()->width(), qApp->desktop()->height());
-}
-
-void QWSServerPrivate::resetEngine()
-{
-#ifndef QT_NO_QWS_CURSOR
- if (!qt_screencursor)
- return;
- qt_screencursor->hide();
- qt_screencursor->show();
-#endif
-}
-
-
-#ifndef QT_NO_QWS_CURSOR
-/*!
- \fn void QWSServer::setCursorVisible(bool visible)
-
- Shows the cursor if \a visible is true: otherwise the cursor is
- hidden.
-
- Note that this function can only be used in the server process.
-
- \sa isCursorVisible()
-*/
-void QWSServer::setCursorVisible(bool vis)
-{
- if (qwsServerPrivate && qwsServerPrivate->haveviscurs != vis) {
- QWSCursor* c = qwsServerPrivate->cursor;
- qwsServerPrivate->setCursor(QWSCursor::systemCursor(Qt::BlankCursor));
- qwsServerPrivate->haveviscurs = vis;
- qwsServerPrivate->setCursor(c);
- }
-}
-
-/*!
- Returns true if the cursor is visible; otherwise returns false.
-
- Note that this function can only be used in the server process.
-
- \sa setCursorVisible()
-*/
-bool QWSServer::isCursorVisible()
-{
- return qwsServerPrivate ? qwsServerPrivate->haveviscurs : true;
-}
-#endif
-
-#ifndef QT_NO_QWS_INPUTMETHODS
-
-
-/*!
- \fn void QWSServer::sendIMEvent(const QInputMethodEvent *event)
-
- Sends the given input method \a event.
-
- The \c QInputMethodEvent class is derived from QWSEvent, i.e., it
- is a QWSEvent object of the QWSEvent::IMEvent type.
-
- If there is a window actively composing the preedit string, the
- event is sent to that window. Otherwise, the event is sent to the
- window currently in focus.
-
- \sa sendIMQuery(), QWSInputMethod::sendEvent()
-*/
-void QWSServer::sendIMEvent(const QInputMethodEvent *ime)
-{
- QWSIMEvent event;
-
- QWSWindow *win = keyboardGrabber ? keyboardGrabber :
- qwsServerPrivate->focusw;
-
- //if currently composing then event must go to the composing window
-
- if (current_IM_composing_win)
- win = current_IM_composing_win;
-
- event.simpleData.window = win ? win->winId() : 0;
- event.simpleData.replaceFrom = ime->replacementStart();;
- event.simpleData.replaceLength = ime->replacementLength();
-
- QBuffer buffer;
- buffer.open(QIODevice::WriteOnly);
- QDataStream out(&buffer);
-
- out << ime->preeditString();
- out << ime->commitString();
-
- const QList<QInputMethodEvent::Attribute> &attributes = ime->attributes();
- for (int i = 0; i < attributes.count(); ++i) {
- const QInputMethodEvent::Attribute &a = attributes.at(i);
- out << a.type << a.start << a.length << a.value;
- }
- event.setData(buffer.data(), buffer.size());
- QWSClient *serverClient = qwsServerPrivate->clientMap.value(-1);
- if (serverClient)
- serverClient->sendEvent(&event);
- if (win && win->client() && win->client() != serverClient)
- win->client()->sendEvent(&event);
-
- current_IM_composing_win = ime->preeditString().isEmpty() ? 0 : win;
- current_IM_winId = win ? win->winId() : 0;
-}
-
-
-/*!
- Sends an input method query for the given \a property.
-
- To receive responses to input method queries, the virtual
- QWSInputMethod::queryResponse() function must be reimplemented in
- a QWSInputMethod subclass that is activated using the
- setCurrentInputMethod() function.
-
- \sa sendIMEvent(), setCurrentInputMethod()
-*/
-void QWSServer::sendIMQuery(int property)
-{
- QWSIMQueryEvent event;
-
- QWSWindow *win = keyboardGrabber ? keyboardGrabber :
- qwsServerPrivate->focusw;
- if (current_IM_composing_win)
- win = current_IM_composing_win;
-
- event.simpleData.window = win ? win->winId() : 0;
- event.simpleData.property = property;
- if (win && win->client())
- win->client()->sendEvent(&event);
-}
-
-
-
-/*!
- \fn void QWSServer::setCurrentInputMethod(QWSInputMethod *method)
-
- Sets the current input method to be the given \a method.
-
- Note that this function can only be used in the server process.
-
- \sa sendIMQuery(), sendIMEvent()
-*/
-void QWSServer::setCurrentInputMethod(QWSInputMethod *im)
-{
- if (current_IM)
- current_IM->reset(); //??? send an update event instead ?
- current_IM = im;
-}
-
-/*!
- \fn static void QWSServer::resetInputMethod()
-
- \internal
-*/
-
-#endif //QT_NO_QWS_INPUTMETHODS
-
-#ifndef QT_NO_QWS_PROPERTIES
-/*!
- \internal
-*/
-void QWSServer::sendPropertyNotifyEvent(int property, int state)
-{
- Q_D(QWSServer);
- QWSServerPrivate::ClientIterator it = d->clientMap.begin();
- while (it != d->clientMap.end()) {
- QWSClient *cl = *it;
- ++it;
- cl->sendPropertyNotifyEvent(property, state);
- }
-}
-#endif
-
-void QWSServerPrivate::invokeIdentify(const QWSIdentifyCommand *cmd, QWSClient *client)
-{
- client->setIdentity(cmd->id);
-#ifndef QT_NO_QWS_MULTIPROCESS
- if (client->clientId() > 0)
- client->d_func()->setLockId(cmd->simpleData.idLock);
-#endif
-}
-
-void QWSServerPrivate::invokeCreate(QWSCreateCommand *cmd, QWSClient *client)
-{
- QWSCreationEvent event;
- event.simpleData.objectid = get_object_id(cmd->count);
- event.simpleData.count = cmd->count;
- client->sendEvent(&event);
-}
-
-void QWSServerPrivate::invokeRegionName(const QWSRegionNameCommand *cmd, QWSClient *client)
-{
- Q_Q(QWSServer);
- QWSWindow* changingw = findWindow(cmd->simpleData.windowid, client);
- if (changingw && (changingw->name() != cmd->name || changingw->caption() !=cmd->caption)) {
- changingw->setName(cmd->name);
- changingw->setCaption(cmd->caption);
- emit q->windowEvent(changingw, QWSServer::Name);
- }
-}
-
-void QWSServerPrivate::invokeRegion(QWSRegionCommand *cmd, QWSClient *client)
-{
-#ifdef QWS_REGION_DEBUG
- qDebug("QWSServer::invokeRegion %d rects (%d)",
- cmd->simpleData.nrectangles, cmd->simpleData.windowid);
-#endif
-
- QWSWindow* changingw = findWindow(cmd->simpleData.windowid, 0);
- if (!changingw) {
- qWarning("Invalid window handle %08x",cmd->simpleData.windowid);
- return;
- }
- if (!changingw->forClient(client)) {
- qWarning("Disabled: clients changing other client's window region");
- return;
- }
-
- request_region(cmd->simpleData.windowid, cmd->surfaceKey, cmd->surfaceData,
- cmd->region);
-}
-
-void QWSServerPrivate::invokeRegionMove(const QWSRegionMoveCommand *cmd, QWSClient *client)
-{
- Q_Q(QWSServer);
- QWSWindow* changingw = findWindow(cmd->simpleData.windowid, 0);
- if (!changingw) {
- qWarning("invokeRegionMove: Invalid window handle %d",cmd->simpleData.windowid);
- return;
- }
- if (!changingw->forClient(client)) {
- qWarning("Disabled: clients changing other client's window region");
- return;
- }
-
-// changingw->setNeedAck(true);
- moveWindowRegion(changingw, cmd->simpleData.dx, cmd->simpleData.dy);
- emit q->windowEvent(changingw, QWSServer::Geometry);
-}
-
-void QWSServerPrivate::invokeRegionDestroy(const QWSRegionDestroyCommand *cmd, QWSClient *client)
-{
- Q_Q(QWSServer);
- QWSWindow* changingw = findWindow(cmd->simpleData.windowid, 0);
- if (!changingw) {
- qWarning("invokeRegionDestroy: Invalid window handle %d",cmd->simpleData.windowid);
- return;
- }
- if (!changingw->forClient(client)) {
- qWarning("Disabled: clients changing other client's window region");
- return;
- }
-
- setWindowRegion(changingw, QRegion());
-// rgnMan->remove(changingw->allocationIndex());
- for (int i = 0; i < windows.size(); ++i) {
- if (windows.at(i) == changingw) {
- windows.takeAt(i);
- if (i < nReserved)
- --nReserved;
- break;
- }
- }
-
- handleWindowClose(changingw);
-#ifndef QT_NO_QWS_PROPERTIES
- propertyManager.removeProperties(changingw->winId());
-#endif
- emit q->windowEvent(changingw, QWSServer::Destroy);
- delete changingw;
-}
-
-void QWSServerPrivate::invokeSetFocus(const QWSRequestFocusCommand *cmd, QWSClient *client)
-{
- int winId = cmd->simpleData.windowid;
- int gain = cmd->simpleData.flag;
-
- if (gain != 0 && gain != 1) {
- qWarning("Only 0(lose) and 1(gain) supported");
- return;
- }
-
- QWSWindow* changingw = findWindow(winId, 0);
- if (!changingw)
- return;
-
- if (!changingw->forClient(client)) {
- qWarning("Disabled: clients changing other client's focus");
- return;
- }
-
- setFocus(changingw, gain);
-}
-
-void QWSServerPrivate::setFocus(QWSWindow* changingw, bool gain)
-{
- Q_Q(QWSServer);
-#ifndef QT_NO_QWS_INPUTMETHODS
- /*
- This is the logic:
- QWSWindow *loser = 0;
- if (gain && focusw != changingw)
- loser = focusw;
- else if (!gain && focusw == changingw)
- loser = focusw;
- But these five lines can be reduced to one:
- */
- if (current_IM) {
- QWSWindow *loser = (!gain == (focusw==changingw)) ? focusw : 0;
- if (loser && loser->winId() == current_IM_winId)
- current_IM->updateHandler(QWSInputMethod::FocusOut);
- }
-#endif
- if (gain) {
- if (focusw != changingw) {
- if (focusw) focusw->focus(0);
- focusw = changingw;
- focusw->focus(1);
- emit q->windowEvent(focusw, QWSServer::Active);
- }
- } else if (focusw == changingw) {
- if (changingw->client())
- changingw->focus(0);
- focusw = 0;
- // pass focus to window which most recently got it...
- QWSWindow* bestw=0;
- for (int i=0; i<windows.size(); ++i) {
- QWSWindow* w = windows.at(i);
- if (w != changingw && !w->hidden() &&
- (!bestw || bestw->focusPriority() < w->focusPriority()))
- bestw = w;
- }
- if (!bestw && changingw->focusPriority()) { // accept focus back?
- bestw = changingw; // must be the only one
- }
- focusw = bestw;
- if (focusw) {
- focusw->focus(1);
- emit q->windowEvent(focusw, QWSServer::Active);
- }
- }
-}
-
-
-
-void QWSServerPrivate::invokeSetOpacity(const QWSSetOpacityCommand *cmd, QWSClient *client)
-{
- Q_UNUSED( client );
- int winId = cmd->simpleData.windowid;
- int opacity = cmd->simpleData.opacity;
-
- QWSWindow* changingw = findWindow(winId, 0);
-
- if (!changingw) {
- qWarning("invokeSetOpacity: Invalid window handle %d", winId);
- return;
- }
-
- int altitude = windows.indexOf(changingw);
- const bool wasOpaque = changingw->isOpaque();
- changingw->_opacity = opacity;
- if (wasOpaque != changingw->isOpaque())
- update_regions();
- exposeRegion(changingw->allocatedRegion(), altitude);
-}
-
-void QWSServerPrivate::invokeSetAltitude(const QWSChangeAltitudeCommand *cmd,
- QWSClient *client)
-{
- Q_UNUSED(client);
-
- int winId = cmd->simpleData.windowid;
- int alt = cmd->simpleData.altitude;
- bool fixed = cmd->simpleData.fixed;
-#if 0
- qDebug("QWSServer::invokeSetAltitude winId %d alt %d)", winId, alt);
-#endif
-
- if (alt < -1 || alt > 1) {
- qWarning("QWSServer::invokeSetAltitude Only lower, raise and stays-on-top supported");
- return;
- }
-
- QWSWindow* changingw = findWindow(winId, 0);
- if (!changingw) {
- qWarning("invokeSetAltitude: Invalid window handle %d", winId);
- return;
- }
-
- if (fixed && alt >= 1) {
- changingw->onTop = true;
- }
- if (alt == QWSChangeAltitudeCommand::Lower)
- changingw->lower();
- else
- changingw->raise();
-
-// if (!changingw->forClient(client)) {
-// refresh();
-// }
-}
-
-#ifndef QT_NO_QWS_PROPERTIES
-void QWSServerPrivate::invokeAddProperty(QWSAddPropertyCommand *cmd)
-{
- propertyManager.addProperty(cmd->simpleData.windowid, cmd->simpleData.property);
-}
-
-void QWSServerPrivate::invokeSetProperty(QWSSetPropertyCommand *cmd)
-{
- Q_Q(QWSServer);
- if (propertyManager.setProperty(cmd->simpleData.windowid,
- cmd->simpleData.property,
- cmd->simpleData.mode,
- cmd->data,
- cmd->rawLen)) {
- q->sendPropertyNotifyEvent(cmd->simpleData.property,
- QWSPropertyNotifyEvent::PropertyNewValue);
-#ifndef QT_NO_QWS_INPUTMETHODS
- if (cmd->simpleData.property == QT_QWS_PROPERTY_MARKEDTEXT) {
- QString s((const QChar*)cmd->data, cmd->rawLen/2);
- emit q->markedText(s);
- }
-#endif
- }
-}
-
-void QWSServerPrivate::invokeRemoveProperty(QWSRemovePropertyCommand *cmd)
-{
- Q_Q(QWSServer);
- if (propertyManager.removeProperty(cmd->simpleData.windowid,
- cmd->simpleData.property)) {
- q->sendPropertyNotifyEvent(cmd->simpleData.property,
- QWSPropertyNotifyEvent::PropertyDeleted);
- }
-}
-
-
-bool QWSServerPrivate:: get_property(int winId, int property, const char *&data, int &len)
-{
- return propertyManager.getProperty(winId, property, data, len);
-}
-
-
-void QWSServerPrivate::invokeGetProperty(QWSGetPropertyCommand *cmd, QWSClient *client)
-{
- const char *data;
- int len;
-
- if (propertyManager.getProperty(cmd->simpleData.windowid,
- cmd->simpleData.property,
- data, len)) {
- client->sendPropertyReplyEvent(cmd->simpleData.property, len, data);
- } else {
- client->sendPropertyReplyEvent(cmd->simpleData.property, -1, 0);
- }
-}
-#endif //QT_NO_QWS_PROPERTIES
-
-void QWSServerPrivate::invokeSetSelectionOwner(QWSSetSelectionOwnerCommand *cmd)
-{
- qDebug("QWSServer::invokeSetSelectionOwner");
-
- SelectionOwner so;
- so.windowid = cmd->simpleData.windowid;
- so.time.set(cmd->simpleData.hour, cmd->simpleData.minute,
- cmd->simpleData.sec, cmd->simpleData.ms);
-
- if (selectionOwner.windowid != -1) {
- QWSWindow *win = findWindow(selectionOwner.windowid, 0);
- if (win)
- win->client()->sendSelectionClearEvent(selectionOwner.windowid);
- else
- qDebug("couldn't find window %d", selectionOwner.windowid);
- }
-
- selectionOwner = so;
-}
-
-void QWSServerPrivate::invokeConvertSelection(QWSConvertSelectionCommand *cmd)
-{
- qDebug("QWSServer::invokeConvertSelection");
-
- if (selectionOwner.windowid != -1) {
- QWSWindow *win = findWindow(selectionOwner.windowid, 0);
- if (win)
- win->client()->sendSelectionRequestEvent(cmd, selectionOwner.windowid);
- else
- qDebug("couldn't find window %d", selectionOwner.windowid);
- }
-}
-
-#ifndef QT_NO_QWS_CURSOR
-void QWSServerPrivate::invokeDefineCursor(QWSDefineCursorCommand *cmd, QWSClient *client)
-{
- if (cmd->simpleData.height > 64 || cmd->simpleData.width > 64) {
- qDebug("Cannot define cursor size > 64x64");
- return;
- }
-
- delete client->cursors.take(cmd->simpleData.id);
-
- int dataLen = cmd->simpleData.height * ((cmd->simpleData.width+7) / 8);
-
- if (dataLen > 0 && cmd->data) {
- QWSCursor *curs = new QWSCursor(cmd->data, cmd->data + dataLen,
- cmd->simpleData.width, cmd->simpleData.height,
- cmd->simpleData.hotX, cmd->simpleData.hotY);
- client->cursors.insert(cmd->simpleData.id, curs);
- }
-}
-
-void QWSServerPrivate::invokeSelectCursor(QWSSelectCursorCommand *cmd, QWSClient *client)
-{
- int id = cmd->simpleData.id;
- QWSCursor *curs = 0;
- if (id <= Qt::LastCursor) {
- curs = QWSCursor::systemCursor(id);
- }
- else {
- QWSCursorMap cursMap = client->cursors;
- QWSCursorMap::Iterator it = cursMap.find(id);
- if (it != cursMap.end()) {
- curs = it.value();
- }
- }
- if (curs == 0) {
- curs = QWSCursor::systemCursor(Qt::ArrowCursor);
- }
-
- QWSWindow* win = findWindow(cmd->simpleData.windowid, 0);
- if (mouseGrabber) {
- // If the mouse is being grabbed, we don't want just anyone to
- // be able to change the cursor. We do want the cursor to be set
- // correctly once mouse grabbing is stopped though.
- if (win != mouseGrabber)
- nextCursor = curs;
- else
- setCursor(curs);
- } else if (win && win->allocatedRegion().contains(QWSServer::mousePosition)) { //##################### cursor
- // A non-grabbing window can only set the cursor shape if the
- // cursor is within its allocated region.
- setCursor(curs);
- }
-}
-
-void QWSServerPrivate::invokePositionCursor(QWSPositionCursorCommand *cmd, QWSClient *)
-{
- Q_Q(QWSServer);
- QPoint newPos(cmd->simpleData.newX, cmd->simpleData.newY);
- if (newPos != QWSServer::mousePosition)
- q->sendMouseEvent(newPos, qwsServer->d_func()->mouseState);
-}
-#endif
-
-void QWSServerPrivate::invokeGrabMouse(QWSGrabMouseCommand *cmd, QWSClient *client)
-{
- QWSWindow* win = findWindow(cmd->simpleData.windowid, 0);
- if (!win)
- return;
-
- if (cmd->simpleData.grab) {
- if (!mouseGrabber || mouseGrabber->client() == client) {
- mouseGrabbing = true;
- mouseGrabber = win;
- }
- } else {
- releaseMouse(mouseGrabber);
- }
-}
-
-void QWSServerPrivate::invokeGrabKeyboard(QWSGrabKeyboardCommand *cmd, QWSClient *client)
-{
- QWSWindow* win = findWindow(cmd->simpleData.windowid, 0);
- if (!win)
- return;
-
- if (cmd->simpleData.grab) {
- if (!keyboardGrabber || (keyboardGrabber->client() == client)) {
- keyboardGrabbing = true;
- keyboardGrabber = win;
- }
- } else {
- releaseKeyboard(keyboardGrabber);
- }
-}
-
-#if !defined(QT_NO_SOUND)
-void QWSServerPrivate::invokePlaySound(QWSPlaySoundCommand *cmd, QWSClient *)
-{
-#if !defined(QT_EXTERNAL_SOUND_SERVER) && !defined(Q_OS_DARWIN)
- soundserver->playFile( 1, cmd->filename );
-#else
- Q_UNUSED(cmd);
-#endif
-}
-#endif
-
-#ifndef QT_NO_COP
-void QWSServerPrivate::invokeRegisterChannel(QWSQCopRegisterChannelCommand *cmd,
- QWSClient *client)
-{
- // QCopChannel will force us to emit the newChannel signal if this channel
- // didn't already exist.
- QCopChannel::registerChannel(cmd->channel, client);
-}
-
-void QWSServerPrivate::invokeQCopSend(QWSQCopSendCommand *cmd, QWSClient *client)
-{
- QCopChannel::answer(client, cmd->channel, cmd->message, cmd->data);
-}
-
-#endif
-
-#ifndef QT_NO_QWS_INPUTMETHODS
-void QWSServer::resetInputMethod()
-{
- if (current_IM && qwsServer) {
- current_IM->reset();
- }
-}
-
-void QWSServerPrivate::invokeIMResponse(const QWSIMResponseCommand *cmd,
- QWSClient *)
-{
- if (current_IM)
- current_IM->queryResponse(cmd->simpleData.property, cmd->result);
-}
-
-void QWSServerPrivate::invokeIMUpdate(const QWSIMUpdateCommand *cmd,
- QWSClient *)
-{
- if (cmd->simpleData.type == QWSInputMethod::FocusIn)
- current_IM_winId = cmd->simpleData.windowid;
-
- if (current_IM && (current_IM_winId == cmd->simpleData.windowid || cmd->simpleData.windowid == -1))
- current_IM->updateHandler(cmd->simpleData.type);
-}
-
-#endif
-
-void QWSServerPrivate::invokeFont(const QWSFontCommand *cmd, QWSClient *client)
-{
- QWSClientPrivate *priv = client->d_func();
- if (cmd->simpleData.type == QWSFontCommand::StartedUsingFont) {
- referenceFont(priv, cmd->fontName);
- } else if (cmd->simpleData.type == QWSFontCommand::StoppedUsingFont) {
- dereferenceFont(priv, cmd->fontName);
- }
-}
-
-void QWSServerPrivate::invokeRepaintRegion(QWSRepaintRegionCommand * cmd,
- QWSClient *)
-{
- QRegion r;
- r.setRects(cmd->rectangles,cmd->simpleData.nrectangles);
- repaint_region(cmd->simpleData.windowid, cmd->simpleData.windowFlags, cmd->simpleData.opaque, r);
-}
-
-#ifndef QT_NO_QWSEMBEDWIDGET
-void QWSServerPrivate::invokeEmbed(QWSEmbedCommand *cmd, QWSClient *client)
-{
- // Should find these two windows in a single loop
- QWSWindow *embedder = findWindow(cmd->simpleData.embedder, client);
- QWSWindow *embedded = findWindow(cmd->simpleData.embedded);
-
- if (!embedder) {
- qWarning("QWSServer: Embed command from window %i failed: No such id.",
- static_cast<int>(cmd->simpleData.embedder));
- return;
- }
-
- if (!embedded) {
- qWarning("QWSServer: Embed command on window %i failed: No such id.",
- static_cast<int>(cmd->simpleData.embedded));
- return;
- }
-
- switch (cmd->simpleData.type) {
- case QWSEmbedEvent::StartEmbed:
- embedder->startEmbed(embedded);
- windows.removeAll(embedded);
- windows.insert(windows.indexOf(embedder), embedded);
- break;
- case QWSEmbedEvent::StopEmbed:
- embedder->stopEmbed(embedded);
- break;
- case QWSEmbedEvent::Region:
- break;
- }
-
- embedded->client()->sendEmbedEvent(embedded->winId(),
- cmd->simpleData.type, cmd->region);
- const QRegion oldAllocated = embedded->allocatedRegion();
- update_regions();
- exposeRegion(oldAllocated - embedded->allocatedRegion(),
- windows.indexOf(embedded));
-}
-#endif // QT_NO_QWSEMBEDWIDGET
-
-void QWSServerPrivate::invokeScreenTransform(const QWSScreenTransformCommand *cmd,
- QWSClient *client)
-{
- Q_UNUSED(client);
-
- QWSScreenTransformationEvent event;
- event.simpleData.screen = cmd->simpleData.screen;
- event.simpleData.transformation = cmd->simpleData.transformation;
-
- QMap<int, QWSClient*>::const_iterator it = clientMap.constBegin();
- for (; it != clientMap.constEnd(); ++it)
- (*it)->sendEvent(&event);
-}
-
-QWSWindow* QWSServerPrivate::newWindow(int id, QWSClient* client)
-{
- Q_Q(QWSServer);
- // Make a new window, put it on top.
- QWSWindow* w = new QWSWindow(id,client);
-
- // insert after "stays on top" windows
- bool added = false;
- for (int i = nReserved; i < windows.size(); ++i) {
- QWSWindow *win = windows.at(i);
- if (!win->onTop) {
- windows.insert(i, w);
- added = true;
- break;
- }
- }
- if (!added)
- windows.append(w);
- emit q->windowEvent(w, QWSServer::Create);
- return w;
-}
-
-QWSWindow* QWSServerPrivate::findWindow(int windowid, QWSClient* client)
-{
- for (int i=0; i<windows.size(); ++i) {
- QWSWindow* w = windows.at(i);
- if (w->winId() == windowid)
- return w;
- }
- if (client)
- return newWindow(windowid,client);
- else
- return 0;
-}
-
-void QWSServerPrivate::raiseWindow(QWSWindow *changingw, int /*alt*/)
-{
- Q_Q(QWSServer);
- if (changingw == windows.first())
- return;
- QWSWindow::State oldstate = changingw->d->state;
- changingw->d->state = QWSWindow::Raising;
- // Expose regions previously overlapped by transparent windows
- const QRegion bound = changingw->allocatedRegion();
- QRegion expose;
- int windowPos = 0;
-
- //change position in list:
- for (int i = 0; i < windows.size(); ++i) {
- QWSWindow *w = windows.at(i);
- if (w == changingw) {
- windowPos = i;
- windows.takeAt(i);
- break;
- }
- if (!w->isOpaque())
- expose += (w->allocatedRegion() & bound);
- }
-
- bool onTop = changingw->onTop;
-
-#ifndef QT_NO_QWSEMBEDWIDGET
- // an embedded window is on top if the embedder is on top
- QWSWindow *embedder = changingw->d->embedder;
- while (!onTop && embedder) {
- onTop = embedder->onTop;
- embedder = embedder->d->embedder;
- }
-#endif
-
- int newPos = -1;
- if (onTop) {
- windows.insert(nReserved, changingw);
- newPos = nReserved;
- } else {
- // insert after "stays on top" windows
- bool in = false;
- for (int i = nReserved; i < windows.size(); ++i) {
- QWSWindow *w = windows.at(i);
- if (!w->onTop) {
- windows.insert(i, changingw);
- in = true;
- newPos = i;
- break;
- }
- }
- if (!in) {
- windows.append(changingw);
- newPos = windows.size()-1;
- }
- }
-
- if (windowPos != newPos) {
- update_regions();
- if (!expose.isEmpty())
- exposeRegion(expose, newPos);
- }
- changingw->d->state = oldstate;
- emit q->windowEvent(changingw, QWSServer::Raise);
-}
-
-void QWSServerPrivate::lowerWindow(QWSWindow *changingw, int /*alt*/)
-{
- Q_Q(QWSServer);
- if (changingw == windows.last())
- return;
- QWSWindow::State oldstate = changingw->d->state;
- changingw->d->state = QWSWindow::Lowering;
-
- int i = windows.indexOf(changingw);
- int newIdx = windows.size()-1;
- windows.move(i, newIdx);
-
- const QRegion bound = changingw->allocatedRegion();
-
- update_regions();
-
- // Expose regions previously overlapped by transparent window
- if (!changingw->isOpaque()) {
- QRegion expose;
- for (int j = i; j < windows.size() - 1; ++j)
- expose += (windows.at(j)->allocatedRegion() & bound);
- if (!expose.isEmpty())
- exposeRegion(expose, newIdx);
- }
-
- changingw->d->state = oldstate;
- emit q->windowEvent(changingw, QWSServer::Lower);
-}
-
-void QWSServerPrivate::update_regions()
-{
- if (disablePainting)
- return;
-
- QRegion available = QRect(0, 0, qt_screen->width(), qt_screen->height());
- QRegion transparentRegion;
-
- // only really needed if there are unbuffered surfaces...
- const bool doLock = (clientMap.size() > 1);
- if (doLock)
- QWSDisplay::grab(true);
-
- for (int i = 0; i < windows.count(); ++i) {
- QWSWindow *w = windows.at(i);
- QRegion r = (w->requested_region & available);
-
-#ifndef QT_NO_QWSEMBEDWIDGET
- // Subtract regions needed for embedded windows
- const int n = w->d->embedded.size();
- for (int i = 0; i < n; ++i)
- r -= w->d->embedded.at(i)->allocatedRegion();
-
- // Limited to the embedder region
- if (w->d->embedder)
- r &= w->d->embedder->requested_region;
-#endif // QT_NO_QWSEMBEDWIDGET
-
- QWSWindowSurface *surface = w->windowSurface();
- const bool opaque = w->isOpaque()
- && (w->d->painted || !surface || !surface->isBuffered());
-
- if (!opaque) {
- transparentRegion += r;
- } else {
- if (surface && (surface->isRegionReserved() || !surface->isBuffered()))
- r -= transparentRegion;
- available -= r;
- }
-
- if (r != w->allocatedRegion()) {
- w->setAllocatedRegion(r);
- w->client()->sendRegionEvent(w->winId(), r,
- QWSRegionEvent::Allocation);
- }
-
-#ifdef QT_QWS_CLIENTBLIT
-#ifdef QT_NO_QWS_CURSOR
- // This optimization only really works when there isn't a crazy cursor
- // wizzing around.
- QRegion directPaint = (r - transparentRegion); // in gloal coords
- if(directPaint != w->directPaintRegion()) {
- w->setDirectPaintRegion(directPaint);
- static int id = 0;
- surface->setDirectRegion(directPaint, ++id);
- w->client()->sendRegionEvent(w->winId(), directPaint,
- QWSRegionEvent::DirectPaint, id);
- }
-#endif
-#endif
- }
-
- if (doLock)
- QWSDisplay::ungrab();
-}
-
-void QWSServerPrivate::moveWindowRegion(QWSWindow *changingw, int dx, int dy)
-{
- if (!changingw)
- return;
-
- QWSWindow::State oldState = changingw->d->state;
- changingw->d->state = QWSWindow::Moving;
- const QRegion oldRegion(changingw->allocatedRegion());
- changingw->requested_region.translate(dx, dy);
-
- // hw: Even if the allocated region doesn't change, the requested region
- // region has changed and we need to send region events.
- // Resetting the allocated region to force update_regions to send events.
- changingw->setAllocatedRegion(QRegion());
- update_regions();
- const QRegion newRegion(changingw->allocatedRegion());
-
- QWSWindowSurface *surface = changingw->windowSurface();
- QRegion expose;
- if (surface)
- expose = surface->move(QPoint(dx, dy), changingw->allocatedRegion());
- else
- expose = oldRegion + newRegion;
-
- if (!changingw->d->painted && !expose.isEmpty())
- expose = oldRegion - newRegion;
-
- int idx = windows.indexOf(changingw);
- exposeRegion(expose, idx);
- changingw->d->state = oldState;
-}
-
-/*!
- Changes the requested region of window \a changingw to \a r
- If \a changingw is 0, the server's reserved region is changed.
-*/
-void QWSServerPrivate::setWindowRegion(QWSWindow* changingw, const QRegion &r)
-{
- if (!changingw) {
- qWarning("Not implemented in this release");
- return;
- }
-
- if (changingw->requested_region == r)
- return;
-
- const QRegion oldRegion(changingw->allocatedRegion());
- changingw->requested_region = r;
- update_regions();
- const QRegion newRegion(changingw->allocatedRegion());
-
- int idx = windows.indexOf(changingw);
- exposeRegion(oldRegion - newRegion, idx);
-}
-
-
-void QWSServerPrivate::exposeRegion(const QRegion &r, int changing)
-{
- if (disablePainting)
- return;
-
- if (r.isEmpty())
- return;
-
- static bool initial = true;
- if (initial) {
- changing = 0;
- initial = false;
- qt_screen->exposeRegion(qt_screen->region(), changing);
- } else {
- qt_screen->exposeRegion(r, changing);
- }
-}
-
-/*!
- Closes all pointer devices (specified by the QWS_MOUSE_PROTO
- environment variable) by deleting the associated mouse drivers.
-
- \sa openMouse(), mouseHandler()
-*/
-void QWSServer::closeMouse()
-{
- Q_D(QWSServer);
- qDeleteAll(d->mousehandlers);
- d->mousehandlers.clear();
-}
-
-/*!
- Opens the mouse devices specified by the QWS_MOUSE_PROTO
- environment variable. Be advised that closeMouse() is called first
- to delete all the existing mouse handlers. This behaviour could be
- the cause of problems if you were not expecting it.
-
- \sa closeMouse(), mouseHandler()
-*/
-void QWSServer::openMouse()
-{
- Q_D(QWSServer);
- QString mice = QString::fromLatin1(qgetenv("QWS_MOUSE_PROTO"));
-#if defined(QT_QWS_CASSIOPEIA)
- if (mice.isEmpty())
- mice = QLatin1String("TPanel:/dev/tpanel");
-#endif
- if (mice.isEmpty())
- mice = *defaultMouse();
- closeMouse();
- bool needviscurs = true;
- if (mice != QLatin1String("None")) {
- const QStringList mouse = mice.split(QLatin1Char(' '));
- for (int i = mouse.size() - 1; i >= 0; --i) {
- QWSMouseHandler *handler = d->newMouseHandler(mouse.at(i));
- setMouseHandler(handler);
- /* XXX handle mouse cursor visibility sensibly
- if (!h->inherits("QCalibratedMouseHandler"))
- needviscurs = true;
- */
- }
- }
-#ifndef QT_NO_QWS_CURSOR
- setCursorVisible(needviscurs);
-#else
- Q_UNUSED(needviscurs)
-#endif
-}
-
-/*!
- Suspends pointer handling by deactivating all the mouse drivers
- registered by the QWS_MOUSE_PROTO environment variable.
-
-
- \sa resumeMouse(), QWSMouseHandler::suspend()
-*/
-void QWSServer::suspendMouse()
-{
- Q_D(QWSServer);
- for (int i=0; i < d->mousehandlers.size(); ++i)
- d->mousehandlers.at(i)->suspend();
-}
-
-/*!
- Resumes pointer handling by reactivating all the mouse drivers
- registered by the QWS_MOUSE_PROTO environment variable.
-
- \sa suspendMouse(), QWSMouseHandler::resume()
-*/
-void QWSServer::resumeMouse()
-{
- Q_D(QWSServer);
- for (int i=0; i < d->mousehandlers.size(); ++i)
- d->mousehandlers.at(i)->resume();
-}
-
-
-
-QWSMouseHandler* QWSServerPrivate::newMouseHandler(const QString& spec)
-{
- int c = spec.indexOf(QLatin1Char(':'));
- QString mouseProto;
- QString mouseDev;
- if (c >= 0) {
- mouseProto = spec.left(c);
- mouseDev = spec.mid(c+1);
- } else {
- mouseProto = spec;
- }
-
- int screen = -1;
- const QList<QRegExp> regexps = QList<QRegExp>()
- << QRegExp(QLatin1String(":screen=(\\d+)\\b"))
- << QRegExp(QLatin1String("\\bscreen=(\\d+):"));
- for (int i = 0; i < regexps.size(); ++i) {
- QRegExp regexp = regexps.at(i);
- if (regexp.indexIn(mouseDev) == -1)
- continue;
- screen = regexp.cap(1).toInt();
- mouseDev.remove(regexp.pos(0), regexp.matchedLength());
- break;
- }
-
- QWSMouseHandler *handler = 0;
- handler = QMouseDriverFactory::create(mouseProto, mouseDev);
- if (screen != -1)
- handler->setScreen(qt_screen->subScreens().at(screen));
-
- return handler;
-}
-
-#ifndef QT_NO_QWS_KEYBOARD
-
-/*!
- Closes all the keyboard devices (specified by the QWS_KEYBOARD
- environment variable) by deleting the associated keyboard
- drivers.
-
- \sa openKeyboard(), keyboardHandler()
-*/
-void QWSServer::closeKeyboard()
-{
- Q_D(QWSServer);
- qDeleteAll(d->keyboardhandlers);
- d->keyboardhandlers.clear();
-}
-
-/*!
- Returns the primary keyboard driver.
-
- Note that this function can only be used in the server process.
-
- \sa setKeyboardHandler(), openKeyboard(), closeKeyboard()
-*/
-QWSKeyboardHandler* QWSServer::keyboardHandler()
-{
- return qwsServerPrivate->keyboardhandlers.first();
-}
-
-/*!
- \fn void QWSServer::setKeyboardHandler(QWSKeyboardHandler* driver)
-
- Sets the primary keyboard driver to be the given \a driver.
-
- \l{Qt for Embedded Linux} provides several ready-made keyboard drivers, and
- custom drivers are typically added using Qt's plugin
- mechanism. See the \l{Qt for Embedded Linux Character Input} documentation
- for details.
-
- Note that this function can only be used in the server process.
-
- \sa keyboardHandler(), setDefaultKeyboard()
-*/
-void QWSServer::setKeyboardHandler(QWSKeyboardHandler* kh)
-{
- if (!kh)
- return;
- qwsServerPrivate->keyboardhandlers.removeAll(kh);
- qwsServerPrivate->keyboardhandlers.prepend(kh);
-}
-
-/*!
- Opens the keyboard devices specified by the QWS_KEYBOARD
- environment variable.
-
- \sa closeKeyboard(), keyboardHandler()
-*/
-void QWSServer::openKeyboard()
-{
- QString keyboards = QString::fromLatin1(qgetenv("QWS_KEYBOARD"));
-#if defined(QT_QWS_CASSIOPEIA)
- if (keyboards.isEmpty())
- keyboards = QLatin1String("Buttons");
-#endif
- if (keyboards.isEmpty())
- keyboards = *defaultKeyboard();
-
- closeKeyboard();
- if (keyboards == QLatin1String("None"))
- return;
-
- QString device;
- QString type;
- QStringList keyboard = keyboards.split(QLatin1Char(' '));
- for (int i = keyboard.size() - 1; i >= 0; --i) {
- const QString spec = keyboard.at(i);
- int colon=spec.indexOf(QLatin1Char(':'));
- if (colon>=0) {
- type = spec.left(colon);
- device = spec.mid(colon+1);
- } else {
- type = spec;
- device = QString();
- }
- QWSKeyboardHandler *handler = QKbdDriverFactory::create(type, device);
- setKeyboardHandler(handler);
- }
-}
-
-#endif //QT_NO_QWS_KEYBOARD
-
-QPoint QWSServer::mousePosition;
-QBrush *QWSServerPrivate::bgBrush = 0;
-
-void QWSServerPrivate::move_region(const QWSRegionMoveCommand *cmd)
-{
- QWSClient *serverClient = clientMap.value(-1);
- invokeRegionMove(cmd, serverClient);
-}
-
-void QWSServerPrivate::set_altitude(const QWSChangeAltitudeCommand *cmd)
-{
- QWSClient *serverClient = clientMap.value(-1);
- invokeSetAltitude(cmd, serverClient);
-}
-
-void QWSServerPrivate::set_opacity(const QWSSetOpacityCommand *cmd)
-{
- QWSClient *serverClient = clientMap.value(-1);
- invokeSetOpacity(cmd, serverClient);
-}
-
-
-void QWSServerPrivate::request_focus(const QWSRequestFocusCommand *cmd)
-{
- invokeSetFocus(cmd, clientMap.value(-1));
-}
-
-void QWSServerPrivate::set_identity(const QWSIdentifyCommand *cmd)
-{
- invokeIdentify(cmd, clientMap.value(-1));
-}
-
-void QWSServerPrivate::repaint_region(int wid, int windowFlags, bool opaque,
- const QRegion &region)
-{
- QWSWindow* changingw = findWindow(wid, 0);
- if (!changingw) {
- return;
- }
-
- const bool isOpaque = changingw->opaque;
- const bool wasPainted = changingw->d->painted;
- changingw->opaque = opaque;
- changingw->d->windowFlags = QFlag(windowFlags);
- changingw->d->dirtyOnScreen |= region;
- changingw->d->painted = true;
- if (isOpaque != opaque || !wasPainted)
- update_regions();
-
- int level = windows.indexOf(changingw);
- exposeRegion(region, level);
- changingw->d->dirtyOnScreen = QRegion();
-}
-
-QRegion QWSServerPrivate::reserve_region(QWSWindow *win, const QRegion &region)
-{
- QRegion r = region;
-
- int oldPos = windows.indexOf(win);
- int newPos = oldPos < nReserved ? nReserved - 1 : nReserved;
- for (int i = 0; i < nReserved; ++i) {
- if (i != oldPos) {
- QWSWindow *w = windows.at(i);
- r -= w->requested_region;
- }
- }
- windows.move(oldPos, newPos);
- nReserved = newPos + 1;
-
- return r;
-}
-
-void QWSServerPrivate::request_region(int wid, const QString &surfaceKey,
- const QByteArray &surfaceData,
- const QRegion &region)
-{
- QWSWindow *changingw = findWindow(wid, 0);
- if (!changingw)
- return;
-
- Q_Q(QWSServer);
- QWSWindow::State windowState = QWSWindow::NoState;
-
- if (region.isEmpty()) {
- windowState = QWSWindow::Hiding;
- emit q->windowEvent(changingw, QWSServer::Hide);
- }
-
- const bool wasOpaque = changingw->opaque;
-
- changingw->createSurface(surfaceKey, surfaceData);
- QWSWindowSurface *surface = changingw->windowSurface();
-
- changingw->opaque = surface->isOpaque();
-
- QRegion r;
- if (surface->isRegionReserved())
- r = reserve_region(changingw, region);
- else
- r = region;
-
- if (!region.isEmpty()) {
- if (changingw->isVisible())
- windowState = QWSWindow::ChangingGeometry;
- else
- windowState = QWSWindow::Showing;
- }
- changingw->d->state = windowState;
-
- if (!r.isEmpty() && wasOpaque != changingw->opaque && surface->isBuffered())
- changingw->requested_region = QRegion(); // XXX: force update_regions
-
- const QRegion oldAllocated = changingw->allocatedRegion();
- setWindowRegion(changingw, r);
- if (oldAllocated == changingw->allocatedRegion()) {
- // Always send region event to the requesting window even if the
- // region didn't change. This is necessary as the client will reset
- // the clip region until an event is received.
- changingw->client()->sendRegionEvent(wid, changingw->allocatedRegion(),
- QWSRegionEvent::Allocation);
- }
-
- surface->QWindowSurface::setGeometry(r.boundingRect());
-
- if (windowState == QWSWindow::Showing)
- emit q->windowEvent(changingw, QWSServer::Show);
- else if (windowState == QWSWindow::ChangingGeometry)
- emit q->windowEvent(changingw, QWSServer::Geometry);
- if (windowState == QWSWindow::Hiding) {
- handleWindowClose(changingw);
- changingw->d->state = QWSWindow::Hidden;
- changingw->d->painted = false;
- } else {
- changingw->d->state = QWSWindow::Visible;
- }
-}
-
-void QWSServerPrivate::destroy_region(const QWSRegionDestroyCommand *cmd)
-{
- invokeRegionDestroy(cmd, clientMap.value(-1));
-}
-
-void QWSServerPrivate::name_region(const QWSRegionNameCommand *cmd)
-{
- invokeRegionName(cmd, clientMap.value(-1));
-}
-
-#ifndef QT_NO_QWS_INPUTMETHODS
-void QWSServerPrivate::im_response(const QWSIMResponseCommand *cmd)
- {
- invokeIMResponse(cmd, clientMap.value(-1));
-}
-
-void QWSServerPrivate::im_update(const QWSIMUpdateCommand *cmd)
-{
- invokeIMUpdate(cmd, clientMap.value(-1));
-}
-
-void QWSServerPrivate::send_im_mouse(const QWSIMMouseCommand *cmd)
-{
- if (current_IM)
- current_IM->mouseHandler(cmd->simpleData.index, cmd->simpleData.state);
-}
-#endif
-
-void QWSServerPrivate::openDisplay()
-{
- qt_init_display();
-
-// rgnMan = qt_fbdpy->regionManager();
- swidth = qt_screen->deviceWidth();
- sheight = qt_screen->deviceHeight();
-}
-
-void QWSServerPrivate::closeDisplay()
-{
- if (qt_screen)
- qt_screen->shutdownDevice();
-}
-
-/*!
- Returns the brush used as background in the absence of obscuring
- windows.
-
- \sa setBackground()
-*/
-const QBrush &QWSServer::backgroundBrush() const
-{
- return *QWSServerPrivate::bgBrush;
-}
-
-/*!
- Sets the brush used as background in the absence of obscuring
- windows, to be the given \a brush.
-
- Note that this function can only be used in the server process.
-
- \sa backgroundBrush()
-*/
-void QWSServer::setBackground(const QBrush &brush)
-{
- if (!QWSServerPrivate::bgBrush)
- QWSServerPrivate::bgBrush = new QBrush(brush);
- else
- *QWSServerPrivate::bgBrush = brush;
- if (!qwsServer)
- return;
- qt_screen->exposeRegion(QRect(0,0,qt_screen->width(), qt_screen->height()), 0);
-}
-
-
-#ifdef QT3_SUPPORT
-/*!
- \fn void QWSServer::setDesktopBackground(const QImage &image)
-
- Sets the image used as background in the absence of obscuring
- windows, to be the given \a image.
-
- Use the setBackground() function instead.
-
- \oldcode
- QImage image;
- setDesktopBackground(image);
- \newcode
- QImage image;
- setBackground(QBrush(image));
- \endcode
-*/
-void QWSServer::setDesktopBackground(const QImage &img)
-{
- if (img.isNull())
- setBackground(Qt::NoBrush);
- else
- setBackground(QBrush(QPixmap::fromImage(img)));
-}
-
-/*!
- \fn void QWSServer::setDesktopBackground(const QColor &color)
- \overload
-
- Sets the color used as background in the absence of obscuring
- windows, to be the given \a color.
-
- Use the setBackground() function instead.
-
- \oldcode
- QColor color;
- setDesktopBackground(color);
- \newcode
- QColor color;
- setBackground(QBrush(color));
- \endcode
-*/
-void QWSServer::setDesktopBackground(const QColor &c)
-{
- setBackground(QBrush(c));
-}
-#endif //QT3_SUPPORT
-
-/*!
- \internal
- */
-void QWSServer::startup(int flags)
-{
- if (qwsServer)
- return;
- unlink(qws_qtePipeFilename().toLatin1().constData());
- (void)new QWSServer(flags);
-}
-
-/*!
- \internal
-*/
-
-void QWSServer::closedown()
-{
- QScopedPointer<QWSServer> server(qwsServer);
- qwsServer = 0;
- QT_TRY {
- unlink(qws_qtePipeFilename().toLatin1().constData());
- } QT_CATCH(const std::bad_alloc &) {
- // ### TODO - what to do when we run out of memory
- // when calling toLatin1?
- }
-}
-
-void QWSServerPrivate::emergency_cleanup()
-{
-#ifndef QT_NO_QWS_KEYBOARD
- if (qwsServer)
- qwsServer->closeKeyboard();
-#endif
-}
-
-#ifndef QT_NO_QWS_KEYBOARD
-static QList<QWSServer::KeyboardFilter*> *keyFilters = 0;
-
-/*!
- Processes the given key event. The key is identified by its \a
- unicode value and the given \a keycode, \a modifiers, \a isPress
- and \a autoRepeat parameters.
-
- The \a keycode parameter is the Qt keycode value as defined by the
- Qt::Key enum. The \a modifiers is an OR combination of
- Qt::KeyboardModifier values, indicating whether \gui
- Shift/Alt/Ctrl keys are pressed. The \a isPress parameter is true
- if the event is a key press event and \a autoRepeat is true if the
- event is caused by an auto-repeat mechanism and not an actual key
- press.
-
- This function is typically called internally by keyboard drivers.
- Note that this function can only be used in the server process.
-
- \sa sendKeyEvent(), {Qt for Embedded Linux Character Input}
-*/
-void QWSServer::processKeyEvent(int unicode, int keycode, Qt::KeyboardModifiers modifiers,
- bool isPress, bool autoRepeat)
-{
- bool block;
- // Don't block the POWER or LIGHT keys
- if ( keycode == Qt::Key_F34 || keycode == Qt::Key_F35 )
- block = false;
- else
- block = qwsServerPrivate->screensaverblockevent(KEY, qwsServerPrivate->screensaverinterval, isPress);
-
-#ifdef EVENT_BLOCK_DEBUG
- qDebug() << "processKeyEvent" << unicode << keycode << modifiers << isPress << autoRepeat << (block ? "block" : "pass");
-#endif
-
- // If we press a key and it's going to be blocked, wake up the screen
- if ( block && isPress )
- qwsServerPrivate->_q_screenSaverWake();
-
- if ( block )
- return;
-
- if (keyFilters) {
- for (int i = 0; i < keyFilters->size(); ++i) {
- QWSServer::KeyboardFilter *keyFilter = keyFilters->at(i);
- if (keyFilter->filter(unicode, keycode, modifiers, isPress, autoRepeat))
- return;
- }
- }
- sendKeyEvent(unicode, keycode, modifiers, isPress, autoRepeat);
-}
-
-/*!
- \fn void QWSServer::addKeyboardFilter(KeyboardFilter *filter)
-
- Activates the given keyboard \a filter all key events generated by
- physical keyboard drivers (i.e., events sent using the
- processKeyEvent() function).
-
- Note that the filter is not invoked for keys generated by \e
- virtual keyboard drivers (i.e., events sent using the
- sendKeyEvent() function).
-
- Note that this function can only be used in the server process.
-
- \sa removeKeyboardFilter()
-*/
-void QWSServer::addKeyboardFilter(KeyboardFilter *f)
-{
- if (!keyFilters)
- keyFilters = new QList<QWSServer::KeyboardFilter*>;
- if (f) {
- keyFilters->prepend(f);
- }
-}
-
-/*
-//#######
- We should probably obsolete the whole keyboard filter thing since
- it's not useful for input methods anyway
-
- We could do removeKeyboardFilter(KeyboardFilter *f), but
- the "remove and delete the filter" concept does not match "user
- remembers the pointer".
-*/
-
-/*!
- Removes and deletes the most recently added filter.
-
- Note that the programmer is responsible for removing each added
- keyboard filter.
-
- Note that this function can only be used in the server process.
-
- \sa addKeyboardFilter()
-*/
-void QWSServer::removeKeyboardFilter()
-{
- if (!keyFilters || keyFilters->isEmpty())
- return;
- delete keyFilters->takeAt(0);
-}
-#endif // QT_NO_QWS_KEYBOARD
-
-/*!
- \fn void QWSServer::setScreenSaverIntervals(int* intervals)
-
- Specifies the time \a intervals (in milliseconds) between the
- different levels of screen responsiveness.
-
- \l{Qt for Embedded Linux} supports multilevel screen saving, i.e., it is
- possible to specify several different levels of screen
- responsiveness by implementing the QWSScreenSaver::save()
- function. For example, you can choose to first turn off the light
- before you fully activate the screensaver. See the QWSScreenSaver
- documentation for details.
-
- Note that an interval of 0 milliseconds will turn off the
- screensaver, and that the \a intervals array must be 0-terminated.
- This function can only be used in the server process.
-
- \sa setScreenSaverInterval(), setScreenSaverBlockLevel()
-*/
-void QWSServer::setScreenSaverIntervals(int* ms)
-{
- if (!qwsServerPrivate)
- return;
-
- delete [] qwsServerPrivate->screensaverintervals;
- if (ms) {
- int* t=ms;
- int n=0;
- while (*t++) n++;
- if (n) {
- n++; // the 0
- qwsServerPrivate->screensaverintervals = new int[n];
- memcpy(qwsServerPrivate->screensaverintervals, ms, n*sizeof(int));
- } else {
- qwsServerPrivate->screensaverintervals = 0;
- }
- } else {
- qwsServerPrivate->screensaverintervals = 0;
- }
- qwsServerPrivate->screensaverinterval = 0;
-
- qwsServerPrivate->screensavertimer->stop();
- qt_screen->blank(false);
- qwsServerPrivate->_q_screenSaverWake();
-}
-
-/*!
- \fn void QWSServer::setScreenSaverInterval(int milliseconds)
-
- Sets the timeout interval for the screensaver to the specified \a
- milliseconds. To turn off the screensaver, set the timout interval
- to 0.
-
- Note that this function can only be used in the server process.
-
- \sa setScreenSaverIntervals(), setScreenSaverBlockLevel()
-*/
-void QWSServer::setScreenSaverInterval(int ms)
-{
- int v[2];
- v[0] = ms;
- v[1] = 0;
- setScreenSaverIntervals(v);
-}
-
-/*!
- Block the key or mouse event that wakes the system from level \a eventBlockLevel or higher.
- To completely disable event blocking (the default behavior), set \a eventBlockLevel to -1.
-
- The algorithm blocks the "down", "up" as well as any "repeat" events for the same key
- but will not block other key events after the initial "down" event. For mouse events, the
- algorithm blocks all mouse events until an event with no buttons pressed is received.
-
- There are 2 keys that are never blocked, Qt::Key_F34 (POWER) and Qt::Key_F35 (LIGHT).
-
- Example usage:
-
- \snippet doc/src/snippets/code/src_gui_embedded_qwindowsystem_qws.cpp 0
-
- Note that this function can only be used in the server process.
-
- \sa setScreenSaverIntervals(), setScreenSaverInterval()
-*/
-void QWSServer::setScreenSaverBlockLevel(int eventBlockLevel)
-{
- if (!qwsServerPrivate)
- return;
- qwsServerPrivate->screensavereventblocklevel = eventBlockLevel;
-#ifdef EVENT_BLOCK_DEBUG
- qDebug() << "QWSServer::setScreenSaverBlockLevel() " << eventBlockLevel;
-#endif
-}
-
-extern bool qt_disable_lowpriority_timers; //in qeventloop_unix.cpp
-
-void QWSServerPrivate::_q_screenSaverWake()
-{
- if (screensaverintervals) {
- if (screensaverinterval != screensaverintervals) {
- if (saver) saver->restore();
- screensaverinterval = screensaverintervals;
- screensaverblockevents = false;
- } else {
- if (!screensavertimer->isActive()) {
- qt_screen->blank(false);
- if (saver) saver->restore();
- }
- }
- screensavertimer->start(*screensaverinterval);
- screensavertime.start();
- }
- qt_disable_lowpriority_timers=false;
-}
-
-void QWSServerPrivate::_q_screenSaverSleep()
-{
- qt_screen->blank(true);
-#if !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX)
- screensavertimer->stop();
-#else
- if (screensaverinterval) {
- screensavertimer->start(*screensaverinterval);
- screensavertime.start();
- } else {
- screensavertimer->stop();
- }
-#endif
- qt_disable_lowpriority_timers=true;
-}
-
-/*!
- \fn void QWSServer::setScreenSaver(QWSScreenSaver* screenSaver)
-
- Installs the given \a screenSaver, deleting the current screen
- saver.
-
- Note that this function can only be used in the server process.
-
- \sa screenSaverActivate(), setScreenSaverInterval(), setScreenSaverIntervals(), setScreenSaverBlockLevel()
-*/
-void QWSServer::setScreenSaver(QWSScreenSaver* ss)
-{
- QWSServerPrivate *qd = qwsServer->d_func();
- delete qd->saver;
- qd->saver = ss;
-}
-
-void QWSServerPrivate::screenSave(int level)
-{
- if (saver) {
- // saver->save() may call QCoreApplication::processEvents,
- // block event before calling saver->save().
- bool oldScreensaverblockevents = screensaverblockevents;
- if (*screensaverinterval >= 1000) {
- screensaverblockevents = (screensavereventblocklevel >= 0 && screensavereventblocklevel <= level);
-#ifdef EVENT_BLOCK_DEBUG
- if (screensaverblockevents)
- qDebug("ready to block events");
-#endif
- }
- int *oldScreensaverinterval = screensaverinterval;
- if (saver->save(level)) {
- // only update screensaverinterval if it hasn't already changed
- if (oldScreensaverinterval == screensaverinterval) {
- if (screensaverinterval && screensaverinterval[1]) {
- screensavertimer->start(*++screensaverinterval);
- screensavertime.start();
- } else {
- screensaverinterval = 0;
- }
- }
- } else {
- // restore previous state
- screensaverblockevents = oldScreensaverblockevents;
-
- // for some reason, the saver don't want us to change to the
- // next level, so we'll stay at this level for another interval
- if (screensaverinterval && *screensaverinterval) {
- screensavertimer->start(*screensaverinterval);
- screensavertime.start();
- }
- }
- } else {
- screensaverinterval = 0;//screensaverintervals;
- screensaverblockevents = false;
- _q_screenSaverSleep();
- }
-}
-
-void QWSServerPrivate::_q_screenSaverTimeout()
-{
- if (screensaverinterval) {
- if (screensavertime.elapsed() > *screensaverinterval*2) {
- // bogus (eg. unsuspend, system time changed)
- _q_screenSaverWake(); // try again
- return;
- }
- screenSave(screensaverinterval - screensaverintervals);
- }
-}
-
-/*!
- Returns true if the screen saver is active; otherwise returns
- false.
-
- Note that this function can only be used in the server process.
-
- \sa screenSaverActivate()
-*/
-bool QWSServer::screenSaverActive()
-{
- return qwsServerPrivate->screensaverinterval
- && !qwsServerPrivate->screensavertimer->isActive();
-}
-
-/*!
- \internal
-*/
-void QWSServer::updateWindowRegions() const
-{
- qwsServerPrivate->update_regions();
-}
-
-/*!
- Activates the screen saver if \a activate is true; otherwise it is
- deactivated.
-
- Note that this function can only be used in the server process.
-
- \sa screenSaverActive(), setScreenSaver()
-*/
-void QWSServer::screenSaverActivate(bool activate)
-{
- if (activate)
- qwsServerPrivate->_q_screenSaverSleep();
- else
- qwsServerPrivate->_q_screenSaverWake();
-}
-
-void QWSServerPrivate::disconnectClient(QWSClient *c)
-{
- QTimer::singleShot(0, c, SLOT(closeHandler()));
-}
-
-void QWSServerPrivate::updateClientCursorPos()
-{
- Q_Q(QWSServer);
- QWSWindow *win = qwsServerPrivate->mouseGrabber ? qwsServerPrivate->mouseGrabber : qwsServer->windowAt(QWSServer::mousePosition);
- QWSClient *winClient = win ? win->client() : 0;
- if (winClient && winClient != cursorClient)
- q->sendMouseEvent(QWSServer::mousePosition, mouseState);
-}
-
-#ifndef QT_NO_QWS_INPUTMETHODS
-
-/*!
- \class QWSInputMethod
- \preliminary
- \ingroup qws
-
- \brief The QWSInputMethod class provides international input methods
- in Qt for Embedded Linux.
-
- Note that this class is only available in \l{Qt for Embedded Linux}.
-
- A \l{Qt for Embedded Linux} application requires a server application to be
- running, or to be the server application itself. All system
- generated events, including keyboard and mouse events, are passed
- to the server application which then propagates the event to the
- appropriate client.
-
- An input method consists of a filter and optionally a graphical
- interface, and is used to filter input events between the server
- and the client application.
-
- \tableofcontents
-
- \section1 Creating Custom Input Methods
-
- To implement a custom input method, derive from the QWSInputMethod
- class, and use the server's \l
- {QWSServer::}{setCurrentInputMethod()} function to install it.
-
- When subclassing QWSInputMethod, you can reimplement the filter()
- functions to handle input from both physical and virtual keyboards
- as well as mouse devices. Note that the default implementations do
- nothing. Use the setInputResolution() function to control the
- number of bits shifted when filtering mouse input, i.e., when
- going from pointer resolution to screen resolution (the current
- resolution can be retrieved using the inputResolutionShift()
- function).
-
- Reimplement the reset() function to restore the state of the input
- method. Note that the default implementation calls the sendEvent()
- function with empty preedit and commit strings if the input method
- is in compose mode (i.e., if the input method is actively
- composing a preedit string).
-
- To receive replies to an input method query (sent using the
- sendQuery() function), you must reimplement the queryResponse()
- function, while the mouseHandler() function must be reimplemented
- if you want to handle mouse events within the preedit
- text. Reimplement the updateHandler() function to handle update
- events including resets and focus changes. The UpdateType enum
- describes the various types of update events recognized by the
- input method.
-
- \section1 Using Input Methods
-
- In addition to the filter(), reset(), queryResponse(),
- mouseHandler() and updateHandler() function mentioned in the
- previous section, the QWSInputMethod provides several other
- functions helping the window system to manage the installed input
- methods.
-
- The sendEvent() function sends the given event to the focus
- widget, while the sendPreeditString() function sends the given
- preedit text (encapsulated by an event). QWSInputMethod also
- provides the sendCommitString() convenience function which sends
- an event encapsulating the given commit string to the current
- focus widget, and the sendMouseEvent() function which sends the
- given mouse event.
-
- Finally, the QWSInputMethod class provides the sendQuery()
- function for sending input method queries. This function
- encapsulates the event with a QWSEvent instance of the \l
- {QWSEvent::}{IMQuery} type.
-
- \sa QWSServer, {Qt for Embedded Linux Architecture}
-*/
-
-/*!
- Constructs a new input method.
-
- Use the QWSServer::setCurrentInputMethod() function to install it.
-*/
-
-QWSInputMethod::QWSInputMethod()
-{
-
-}
-
-/*!
- Destroys this input method, uninstalling it if it is installed.
-*/
-QWSInputMethod::~QWSInputMethod()
-{
- if (current_IM == this)
- current_IM = 0;
-}
-
-/*!
- Filters the key input identified by the given \a unicode, \a
- keycode, \a modifiers, \a isPress and \a autoRepeat parameters.
-
- Note that the default implementation does nothing; reimplement
- this function to handle input from both physical and virtual
- devices.
-
- The \a keycode is a Qt::Key value, and the \a modifiers is an OR
- combination of Qt::KeyboardModifiers. The \a isPress parameter is
- telling whether the input is a key press or key release, and the
- \a autoRepeat parameter determines whether the input is
- autorepeated ( i.e., in which case the
- QWSKeyboardHandler::beginAutoRepeat() function has been called).
-
- To block the event from further processing, return true when
- reimplementing this function; the default implementation returns
- false.
-
- \sa setInputResolution(), inputResolutionShift()
-*/
-bool QWSInputMethod::filter(int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat)
-{
- Q_UNUSED(unicode);
- Q_UNUSED(keycode);
- Q_UNUSED(modifiers);
- Q_UNUSED(isPress);
- Q_UNUSED(autoRepeat);
- return false;
-}
-
-/*!
- \overload
-
- Filters the mouse input identified by the given \a position, \a
- state, and \a wheel parameters.
-*/
-bool QWSInputMethod::filter(const QPoint &position, int state, int wheel)
-{
- Q_UNUSED(position);
- Q_UNUSED(state);
- Q_UNUSED(wheel);
- return false;
-}
-
-/*!
- Resets the state of the input method.
-
- If the input method is in compose mode, i.e., the input method is
- actively composing a preedit string, the default implementation
- calls sendEvent() with empty preedit and commit strings; otherwise
- it does nothing. Reimplement this function to alter this behavior.
-
- \sa sendEvent()
-*/
-void QWSInputMethod::reset()
-{
- if (current_IM_composing_win) {
- QInputMethodEvent ime;
- sendEvent(&ime);
- }
-}
-
-/*!
- \enum QWSInputMethod::UpdateType
-
- This enum describes the various types of update events recognized
- by the input method.
-
- \value Update The input widget is updated in some way; use sendQuery() with
- Qt::ImMicroFocus as an argument for more information.
- \value FocusIn A new input widget receives focus.
- \value FocusOut The input widget loses focus.
- \value Reset The input method should be reset.
- \value Destroyed The input widget is destroyed.
-
- \sa updateHandler()
-*/
-
-/*!
- Handles update events including resets and focus changes. The
- update events are specified by the given \a type which is one of
- the UpdateType enum values.
-
- Note that reimplementations of this function must call the base
- implementation for all cases that it does not handle itself.
-
- \sa UpdateType
-*/
-void QWSInputMethod::updateHandler(int type)
-{
- switch (type) {
- case FocusOut:
- case Reset:
- reset();
- break;
-
- default:
- break;
- }
-}
-
-
-/*!
- Receive replies to an input method query.
-
- Note that the default implementation does nothing; reimplement
- this function to receive such replies.
-
- Internally, an input method query is passed encapsulated by an \l
- {QWSEvent::IMQuery}{IMQuery} event generated by the sendQuery()
- function. The queried property and the result is passed in the \a
- property and \a result parameters.
-
- \sa sendQuery(), QWSServer::sendIMQuery()
-*/
-void QWSInputMethod::queryResponse(int property, const QVariant &result)
-{
- Q_UNUSED(property);
- Q_UNUSED(result);
-}
-
-
-
-/*!
- \fn void QWSInputMethod::mouseHandler(int offset, int state)
-
- Handles mouse events within the preedit text.
-
- Note that the default implementation resets the input method on
- all mouse presses; reimplement this function to alter this
- behavior.
-
- The \a offset parameter specifies the position of the mouse event
- within the string, and \a state specifies the type of the mouse
- event as described by the QWSServer::IMMouse enum. If \a state is
- less than 0, the mouse event is inside the associated widget, but
- outside the preedit text. When clicking in a different widget, the
- \a state is QWSServer::MouseOutside.
-
- \sa sendPreeditString(), reset()
-*/
-void QWSInputMethod::mouseHandler(int, int state)
-{
- if (state == QWSServer::MousePress || state == QWSServer::MouseOutside)
- reset();
-}
-
-
-/*!
- Sends an event encapsulating the given \a preeditString, to the
- focus widget.
-
- The specified \a selectionLength is the number of characters to be
- marked as selected (starting at the given \a cursorPosition). If
- \a selectionLength is negative, the text \e before \a
- cursorPosition is marked.
-
- The preedit string is marked with QInputContext::PreeditFormat,
- and the selected part is marked with
- QInputContext::SelectionFormat.
-
- Sending an input method event with a non-empty preedit string will
- cause the input method to enter compose mode. Sending an input
- method event with an empty preedit string will cause the input
- method to leave compose mode, i.e., the input method will no longer
- be actively composing the preedit string.
-
- Internally, the event is represented by a QWSEvent object of the
- \l {QWSEvent::IMEvent}{IMEvent} type.
-
- \sa sendEvent(), sendCommitString()
-*/
-
-void QWSInputMethod::sendPreeditString(const QString &preeditString, int cursorPosition, int selectionLength)
-{
- QList<QInputMethodEvent::Attribute> attributes;
-
- int selPos = cursorPosition;
- if (selectionLength == 0) {
- selPos = 0;
- } else if (selectionLength < 0) {
- selPos += selectionLength;
- selectionLength = -selectionLength;
- }
- if (selPos > 0)
- attributes += QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 0, selPos,
- QVariant(int(QInputContext::PreeditFormat)));
-
- if (selectionLength)
- attributes += QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, selPos, selectionLength,
- QVariant(int(QInputContext::SelectionFormat)));
-
- if (selPos + selectionLength < preeditString.length())
- attributes += QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat,
- selPos + selectionLength,
- preeditString.length() - selPos - selectionLength,
- QVariant(int(QInputContext::PreeditFormat)));
-
- attributes += QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, cursorPosition, 0, QVariant());
-
- QInputMethodEvent ime(preeditString, attributes);
- qwsServer->sendIMEvent(&ime);
-}
-
-/*!
- \fn void QWSInputMethod::sendCommitString(const QString &commitString, int replaceFromPosition, int replaceLength)
-
- Sends an event encapsulating the given \a commitString, to the
- focus widget.
-
- Note that this will cause the input method to leave compose mode,
- i.e., the input method will no longer be actively composing the
- preedit string.
-
- If the specified \a replaceLength is greater than 0, the commit
- string will replace the given number of characters of the
- receiving widget's previous text, starting at the given \a
- replaceFromPosition relative to the start of the current preedit
- string.
-
- Internally, the event is represented by a QWSEvent object of the
- \l {QWSEvent::IMEvent}{IMEvent} type.
-
- \sa sendEvent(), sendPreeditString()
-*/
-void QWSInputMethod::sendCommitString(const QString &commitString, int replaceFrom, int replaceLength)
-{
- QInputMethodEvent ime;
- ime.setCommitString(commitString, replaceFrom, replaceLength);
- qwsServer->sendIMEvent(&ime);
-}
-
-/*!
- \fn QWSInputMethod::sendIMEvent(QWSServer::IMState state, const QString &text, int cursorPosition, int selectionLength)
- \obsolete
-
- Sends a QInputMethodEvent object to the focus widget.
-
- If the specified \a state is QWSServer::IMCompose, \a text is a
- preedit string, \a cursorPosition is the cursor's position within
- the preedit string, and \a selectionLength is the number of
- characters (starting at \a cursorPosition) that should be marked
- as selected by the input widget receiving the event. If the
- specified \a state is QWSServer::IMEnd, \a text is a commit
- string.
-
- Use sendEvent(), sendPreeditString() or sendCommitString() instead.
-*/
-
-/*!
- \fn QWSInputMethod::sendEvent(const QInputMethodEvent *event)
-
- Sends the given \a event to the focus widget.
-
- The \c QInputMethodEvent class is derived from QWSEvent, i.e., the
- given \a event is a QWSEvent object of the \l
- {QWSEvent::IMEvent}{IMEvent} type.
-
- \sa sendPreeditString(), sendCommitString(), reset()
-*/
-
-
-/*!
- \fn void QWSInputMethod::sendQuery(int property)
-
- Sends an input method query (internally encapsulated by a QWSEvent
- of the \l {QWSEvent::IMQuery}{IMQuery} type) for the specified \a
- property.
-
- To receive responses to input method queries, the virtual
- queryResponse() function must be reimplemented.
-
- \sa queryResponse(), QWSServer::sendIMQuery()
-*/
-
-/*!
- Sets and returns the number of bits shifted to go from pointer
- resolution to screen resolution when filtering mouse input.
-
- If \a isHigh is true and the device has a pointer device
- resolution twice or more of the screen resolution, the positions
- passed to the filter() function will be presented at the higher
- resolution; otherwise the resolution will be equal to that of the
- screen resolution.
-
- \sa inputResolutionShift(), filter()
-*/
-uint QWSInputMethod::setInputResolution(bool isHigh)
-{
- mIResolution = isHigh;
- return inputResolutionShift();
-}
-
-/*!
- Returns the number of bits shifted to go from pointer resolution
- to screen resolution when filtering mouse input.
-
- \sa setInputResolution(), filter()
-*/
-uint QWSInputMethod::inputResolutionShift() const
-{
- return 0; // default for devices with single resolution.
-}
-
-/*!
- \fn void QWSInputMethod::sendMouseEvent( const QPoint &position, int state, int wheel )
-
- Sends a mouse event specified by the given \a position, \a state
- and \a wheel parameters.
-
- The given \a position will be transformed if the screen
- coordinates do not match the pointer device coordinates.
-
- Note that the event will be not be tested by the active input
- method, but calling the QWSServer::sendMouseEvent() function will
- make the current input method filter the event.
-
- \sa mouseHandler(), sendEvent()
-*/
-void QWSInputMethod::sendMouseEvent( const QPoint &pos, int state, int wheel )
-{
- if (qt_last_x) {
- *qt_last_x = pos.x();
- *qt_last_y = pos.y();
- }
- QWSServer::mousePosition = pos;
- qwsServerPrivate->mouseState = state;
- QWSServerPrivate::sendMouseEventUnfiltered(pos, state, wheel);
-}
-#endif // QT_NO_QWS_INPUTMETHODS
-
-/*!
- \fn QWSWindow::QWSWindow(int i, QWSClient * client)
- \internal
-
- Constructs a new top-level window, associated with the client \a
- client and giving it the id \a i.
-*/
-
-/*!
- \fn QWSServer::windowEvent(QWSWindow * window, QWSServer::WindowEvent eventType)
-
- This signal is emitted whenever something happens to a top-level
- window (e.g., it's created or destroyed), passing a pointer to the
- window and the event's type in the \a window and \a eventType
- parameters, respectively.
-
- \sa markedText()
-*/
-
-/*!
- \class QWSServer::KeyboardFilter
- \ingroup qws
-
- \brief The KeyboardFilter class is a base class for global
- keyboard event filters in Qt for Embedded Linux.
-
- Note that this class is only available in \l{Qt for Embedded Linux}.
-
- In \l{Qt for Embedded Linux}, all system generated events, including
- keyboard events, are passed to the server application which then
- propagates the event to the appropriate client. The KeyboardFilter
- class is used to implement a global, low-level filter on the
- server side. The server applies the filter to all keyboard events
- before passing them on to the clients:
-
- \image qwsserver_keyboardfilter.png
-
- This feature can, for example, be used to filter things like APM
- (advanced power management) suspended from a button without having
- to filter for it in all applications.
-
- To add a new keyboard filter you must first create the filter by
- deriving from this class, reimplementing the pure virtual filter()
- function. Then you can install the filter on the server using
- QWSServer's \l {QWSServer::}{addKeyboardFilter()}
- function. QWSServer also provides a \l
- {QWSServer::}{removeKeyboardFilter()} function.
-
- \sa {Qt for Embedded Linux Architecture}, QWSServer, QWSInputMethod
-*/
-
-/*!
- \fn QWSServer::KeyboardFilter::~KeyboardFilter()
-
- Destroys the keyboard filter.
-*/
-
-/*!
- \fn bool QWSServer::KeyboardFilter::filter(int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat)
-
- Implement this function to return true if a given key event should
- be stopped from being processed any further; otherwise it should
- return false.
-
- A key event can be identified by the given \a unicode value and
- the \a keycode, \a modifiers, \a isPress and \a autoRepeat
- parameters.
-
- The \a keycode parameter is the Qt keycode value as defined by the
- Qt::Key enum. The \a modifiers is an OR combination of
- Qt::KeyboardModifier values, indicating whether \gui
- Shift/Alt/Ctrl keys are pressed. The \a isPress parameter is true
- if the event is a key press event and \a autoRepeat is true if the
- event is caused by an auto-repeat mechanism and not an actual key
- press.
-*/
-
-QT_END_NAMESPACE
-
-#include "moc_qwindowsystem_qws.cpp"
diff --git a/src/gui/embedded/qwindowsystem_qws.h b/src/gui/embedded/qwindowsystem_qws.h
deleted file mode 100644
index 65e1683d38..0000000000
--- a/src/gui/embedded/qwindowsystem_qws.h
+++ /dev/null
@@ -1,508 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSYSTEM_QWS_H
-#define QWINDOWSYSTEM_QWS_H
-
-#include <QtCore/qbytearray.h>
-#include <QtCore/qmap.h>
-#include <QtCore/qdatetime.h>
-#include <QtCore/qlist.h>
-
-#include <QtGui/qwsevent_qws.h>
-#include <QtGui/qkbd_qws.h>
-#include <QtGui/qregion.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-struct QWSWindowPrivate;
-class QWSCursor;
-class QWSClient;
-class QWSRegionManager;
-class QBrush;
-class QVariant;
-class QInputMethodEvent;
-class QWSInputMethod;
-class QWSBackingStore;
-class QWSWindowSurface;
-
-#ifdef QT3_SUPPORT
-class QImage;
-class QColor;
-#endif
-
-class QWSInternalWindowInfo
-{
-public:
- int winid;
- unsigned int clientid;
- QString name; // Corresponds to QObject name of top-level widget
-};
-
-
-class Q_GUI_EXPORT QWSScreenSaver
-{
-public:
- virtual ~QWSScreenSaver();
- virtual void restore()=0;
- virtual bool save(int level)=0;
-};
-
-
-class Q_GUI_EXPORT QWSWindow
-{
- friend class QWSServer;
- friend class QWSServerPrivate;
-
-public:
- QWSWindow(int i, QWSClient* client);
- ~QWSWindow();
-
- int winId() const { return id; }
- const QString &name() const { return rgnName; }
- const QString &caption() const { return rgnCaption; }
- QWSClient* client() const { return c; }
- const QRegion &requestedRegion() const { return requested_region; }
- QRegion allocatedRegion() const;
- QRegion paintedRegion() const;
- bool isVisible() const { return !requested_region.isEmpty(); }
- bool isPartiallyObscured() const { return requested_region != allocatedRegion(); }
- bool isFullyObscured() const { return allocatedRegion().isEmpty(); }
-
- enum State { NoState, Hidden, Showing, Visible, Hiding, Raising, Lowering, Moving, ChangingGeometry, Destroyed };
- State state() const;
- Qt::WindowFlags windowFlags() const;
- QRegion dirtyOnScreen() const;
-
- void raise();
- void lower();
- void show();
- void hide();
- void setActiveWindow();
-
- bool isOpaque() const {return opaque && _opacity == 255;}
- uint opacity() const { return _opacity; }
-
- QWSWindowSurface* windowSurface() const { return surface; }
-
-private:
- bool hidden() const { return requested_region.isEmpty(); }
- bool forClient(const QWSClient* cl) const { return cl==c; }
-
- void setName(const QString &n);
- void setCaption(const QString &c);
-
- void focus(bool get);
- int focusPriority() const { return last_focus_time; }
- void operation(QWSWindowOperationEvent::Operation o);
- void shuttingDown() { last_focus_time=0; }
-
-#ifdef QT_QWS_CLIENTBLIT
- QRegion directPaintRegion() const;
- inline void setDirectPaintRegion(const QRegion &topmost);
-#endif
- inline void setAllocatedRegion(const QRegion &region);
-
- void createSurface(const QString &key, const QByteArray &data);
-
-#ifndef QT_NO_QWSEMBEDWIDGET
- void startEmbed(QWSWindow *window);
- void stopEmbed(QWSWindow *window);
-#endif
-
-private:
- int id;
- QString rgnName;
- QString rgnCaption;
- bool modified;
- bool onTop;
- QWSClient* c;
- QRegion requested_region;
- QRegion exposed;
- int last_focus_time;
- QWSWindowSurface *surface;
- uint _opacity;
- bool opaque;
- QWSWindowPrivate *d;
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT QRegion requested() const { return requested_region; }
-// inline QT3_SUPPORT QRegion allocation() const { return allocated_region; }
-#endif
-};
-
-
-#ifndef QT_NO_SOUND
-class QWSSoundServer;
-#ifdef QT_USE_OLD_QWS_SOUND
-class QWSSoundServerData;
-
-class Q_GUI_EXPORT QWSSoundServer : public QObject {
- Q_OBJECT
-public:
- QWSSoundServer(QObject* parent);
- ~QWSSoundServer();
- void playFile(const QString& filename);
-private Q_SLOTS:
- void feedDevice(int fd);
-private:
- QWSSoundServerData* d;
-};
-#endif
-#endif
-
-
-/*********************************************************************
- *
- * Class: QWSServer
- *
- *********************************************************************/
-
-class QWSMouseHandler;
-struct QWSCommandStruct;
-class QWSServerPrivate;
-class QWSServer;
-
-extern Q_GUI_EXPORT QWSServer *qwsServer;
-
-class Q_GUI_EXPORT QWSServer : public QObject
-{
- friend class QCopChannel;
- friend class QWSMouseHandler;
- friend class QWSWindow;
- friend class QWSDisplay;
- friend class QWSInputMethod;
- Q_OBJECT
- Q_DECLARE_PRIVATE(QWSServer)
-public:
- explicit QWSServer(int flags = 0, QObject *parent=0);
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QWSServer(int flags, QObject *parent, const char *name);
-#endif
- ~QWSServer();
- enum ServerFlags { DisableKeyboard = 0x01,
- DisableMouse = 0x02 };
-
- static void sendKeyEvent(int unicode, int keycode, Qt::KeyboardModifiers modifiers,
- bool isPress, bool autoRepeat);
-#ifndef QT_NO_QWS_KEYBOARD
- static void processKeyEvent(int unicode, int keycode, Qt::KeyboardModifiers modifiers,
- bool isPress, bool autoRepeat);
-#endif
-
- static QWSServer* instance() { return qwsServer; }
-
-#ifndef QT_NO_QWS_INPUTMETHODS
-#ifdef QT3_SUPPORT
- enum IMState { IMCompose, IMEnd, IMStart = IMCompose };
-#endif
- enum IMMouse { MousePress, MouseRelease, MouseMove, MouseOutside }; //MouseMove reserved but not used
- void sendIMEvent(const QInputMethodEvent*);
- void sendIMQuery(int property);
-#endif
-
-#ifndef QT_NO_QWS_KEYBOARD
- class KeyboardFilter
- {
- public:
- virtual ~KeyboardFilter() {}
- virtual bool filter(int unicode, int keycode, int modifiers,
- bool isPress, bool autoRepeat)=0;
- };
- static void addKeyboardFilter(KeyboardFilter *f);
- static void removeKeyboardFilter();
-#endif
-
-#ifndef QT_NO_QWS_INPUTMETHODS
- static void setCurrentInputMethod(QWSInputMethod *im);
- static void resetInputMethod();
-#endif
-
- static void setDefaultMouse(const char *);
- static void setDefaultKeyboard(const char *);
- static void setMaxWindowRect(const QRect&);
- static void sendMouseEvent(const QPoint& pos, int state, int wheel = 0);
-
- static void setBackground(const QBrush &);
-#ifdef QT3_SUPPORT
- static QT3_SUPPORT void setDesktopBackground(const QImage &img);
- static QT3_SUPPORT void setDesktopBackground(const QColor &);
-#endif
- static QWSMouseHandler *mouseHandler();
- static const QList<QWSMouseHandler*>& mouseHandlers();
- static void setMouseHandler(QWSMouseHandler*);
-#ifndef QT_NO_QWS_KEYBOARD
- static QWSKeyboardHandler* keyboardHandler();
- static void setKeyboardHandler(QWSKeyboardHandler* kh);
-#endif
- QWSWindow *windowAt(const QPoint& pos);
-
- const QList<QWSWindow*> &clientWindows();
-
- void openMouse();
- void closeMouse();
- void suspendMouse();
- void resumeMouse();
-#ifndef QT_NO_QWS_KEYBOARD
- void openKeyboard();
- void closeKeyboard();
-#endif
-
- static void setScreenSaver(QWSScreenSaver*);
- static void setScreenSaverIntervals(int* ms);
- static void setScreenSaverInterval(int);
- static void setScreenSaverBlockLevel(int);
- static bool screenSaverActive();
- static void screenSaverActivate(bool);
-
- // the following are internal.
- void refresh();
- void refresh(QRegion &);
-
- void enablePainting(bool);
- static void processEventQueue();
- static QList<QWSInternalWindowInfo*> * windowList();
-
- void sendPropertyNotifyEvent(int property, int state);
-
- static QPoint mousePosition;
-
- static void startup(int flags);
- static void closedown();
-
- static void beginDisplayReconfigure();
- static void endDisplayReconfigure();
-
-#ifndef QT_NO_QWS_CURSOR
- static void setCursorVisible(bool);
- static bool isCursorVisible();
-#endif
-
- const QBrush &backgroundBrush() const;
-
- enum WindowEvent { Create=0x0001, Destroy=0x0002, Hide=0x0004, Show=0x0008,
- Raise=0x0010, Lower=0x0020, Geometry=0x0040, Active = 0x0080,
- Name=0x0100 };
-
-Q_SIGNALS:
- void windowEvent(QWSWindow *w, QWSServer::WindowEvent e);
-
-#ifndef QT_NO_COP
- void newChannel(const QString& channel);
- void removedChannel(const QString& channel);
-
-#endif
-#ifndef QT_NO_QWS_INPUTMETHODS
- void markedText(const QString &);
-#endif
-
-protected:
- void timerEvent(QTimerEvent *e);
-
-private:
- friend class QApplicationPrivate;
- void updateWindowRegions() const;
-
-#ifdef QT3_SUPPORT
-#ifndef QT_NO_QWS_KEYBOARD
- static inline QT3_SUPPORT void setKeyboardFilter(QWSServer::KeyboardFilter *f)
- { if (f) addKeyboardFilter(f); else removeKeyboardFilter(); }
-#endif
-#endif
-
-private:
-#ifndef QT_NO_QWS_MULTIPROCESS
- Q_PRIVATE_SLOT(d_func(), void _q_clientClosed())
- Q_PRIVATE_SLOT(d_func(), void _q_doClient())
- Q_PRIVATE_SLOT(d_func(), void _q_deleteWindowsLater())
-#endif
-
- Q_PRIVATE_SLOT(d_func(), void _q_screenSaverWake())
- Q_PRIVATE_SLOT(d_func(), void _q_screenSaverSleep())
- Q_PRIVATE_SLOT(d_func(), void _q_screenSaverTimeout())
-
-#ifndef QT_NO_QWS_MULTIPROCESS
- Q_PRIVATE_SLOT(d_func(), void _q_newConnection())
-#endif
-};
-
-#ifndef QT_NO_QWS_INPUTMETHODS
-class Q_GUI_EXPORT QWSInputMethod : public QObject
-{
- Q_OBJECT
-public:
- QWSInputMethod();
- virtual ~QWSInputMethod();
-
- enum UpdateType {Update, FocusIn, FocusOut, Reset, Destroyed};
-
- virtual bool filter(int unicode, int keycode, int modifiers,
- bool isPress, bool autoRepeat);
-
- virtual bool filter(const QPoint &, int state, int wheel);
-
- virtual void reset();
- virtual void updateHandler(int type);
- virtual void mouseHandler(int pos, int state);
- virtual void queryResponse(int property, const QVariant&);
-
-protected:
- uint setInputResolution(bool isHigh);
- uint inputResolutionShift() const;
- // needed for required transform
- void sendMouseEvent(const QPoint &pos, int state, int wheel);
-
- void sendEvent(const QInputMethodEvent*);
- void sendPreeditString(const QString &preeditString, int cursorPosition, int selectionLength = 0);
- void sendCommitString(const QString &commitString, int replaceFrom = 0, int replaceLength = 0);
- void sendQuery(int property);
-
-#ifdef QT3_SUPPORT
- inline void sendIMEvent(QWSServer::IMState, const QString& txt, int cpos, int selLen = 0);
-#endif
-private:
- bool mIResolution;
-};
-
-inline void QWSInputMethod::sendEvent(const QInputMethodEvent *ime)
-{
- qwsServer->sendIMEvent(ime);
-}
-#ifdef QT3_SUPPORT
-inline void QWSInputMethod::sendIMEvent(QWSServer::IMState state, const QString& txt, int cpos, int selLen)
-{
- if (state == QWSServer::IMCompose) sendPreeditString(txt, cpos, selLen); else sendCommitString(txt);
-}
-#endif
-
-inline void QWSInputMethod::sendQuery(int property)
-{
- qwsServer->sendIMQuery(property);
-}
-
-// mouse events not inline as involve transformations.
-#endif // QT_NO_QWS_INPUTMETHODS
-
-
-
-/*********************************************************************
- *
- * Class: QWSClient
- *
- *********************************************************************/
-
-struct QWSMouseEvent;
-
-typedef QMap<int, QWSCursor*> QWSCursorMap;
-
-class QWSClientPrivate;
-class QWSCommand;
-class QWSConvertSelectionCommand;
-
-class Q_GUI_EXPORT QWSClient : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QWSClient)
-public:
- QWSClient(QObject* parent, QWS_SOCK_BASE *, int id);
- ~QWSClient();
-
- int socket() const;
-
- void setIdentity(const QString&);
- QString identity() const { return id; }
-
- void sendEvent(QWSEvent* event);
- void sendConnectedEvent(const char *display_spec);
- void sendMaxWindowRectEvent(const QRect &rect);
- void sendPropertyNotifyEvent(int property, int state);
- void sendPropertyReplyEvent(int property, int len, const char *data);
- void sendSelectionClearEvent(int windowid);
- void sendSelectionRequestEvent(QWSConvertSelectionCommand *cmd, int windowid);
-#ifndef QT_QWS_CLIENTBLIT
- void sendRegionEvent(int winid, QRegion rgn, int type);
-#else
- void sendRegionEvent(int winid, QRegion rgn, int type, int id = 0);
-#endif
-#ifndef QT_NO_QWSEMBEDWIDGET
- void sendEmbedEvent(int winid, QWSEmbedEvent::Type type,
- const QRegion &region = QRegion());
-#endif
- QWSCommand* readMoreCommand();
-
- int clientId() const { return cid; }
-
- QWSCursorMap cursors; // cursors defined by this client
-Q_SIGNALS:
- void connectionClosed();
- void readyRead();
-private Q_SLOTS:
- void closeHandler();
- void errorHandler();
-
-private:
-#ifndef QT_NO_QWS_MULTIPROCESS
- friend class QWSWindow;
- void removeUnbufferedSurface();
- void addUnbufferedSurface();
-#endif
-
-private:
- int socketDescriptor;
-#ifndef QT_NO_QWS_MULTIPROCESS
- QWSSocket *csocket;
-#endif
- QWSCommand* command;
- uint isClosed : 1;
- QString id;
- int cid;
-
- friend class QWSServerPrivate;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QWINDOWSYSTEM_QWS_H
diff --git a/src/gui/embedded/qwscommand_qws.cpp b/src/gui/embedded/qwscommand_qws.cpp
deleted file mode 100644
index 71d3a06dbe..0000000000
--- a/src/gui/embedded/qwscommand_qws.cpp
+++ /dev/null
@@ -1,609 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwscommand_qws_p.h"
-#include "qtransportauth_qws.h"
-#include "qtransportauth_qws_p.h"
-
-#include <unistd.h>
-
-// #define QWSCOMMAND_DEBUG 1 // Uncomment to debug client/server communication
-
-#ifdef QWSCOMMAND_DEBUG
-# include <qdebug.h>
-# include "qfile.h"
-# include <ctype.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-#ifdef QWSCOMMAND_DEBUG
-// QWSHexDump -[ start ]---------------------------------------------
-# define QWSHEXDUMP_MAX 32
-class QWSHexDump
-{
-public:
-
- QWSHexDump(const void *address, int len, int wrapAt = 16)
- : wrap(wrapAt), dataSize(len)
- {
- init();
- data = reinterpret_cast<const char*>(address);
- if (len < 0)
- dataSize = 0;
- }
-
- QWSHexDump(const char *str, int len = -1, int wrapAt = 16)
- : wrap(wrapAt), dataSize(len)
- {
- init();
- data = str;
- if (len == -1)
- dataSize = str ? strlen(str) : 0;
- }
-
- QWSHexDump(const QByteArray &array, int wrapAt = 16)
- : wrap(wrapAt)
- {
- init();
- data = array.data();
- dataSize = array.size();
- }
-
- // Sets a customized prefix for the hexdump
- void setPrefix(const char *str) { prefix = str; }
-
- // Sets number of bytes to cluster together
- void setClusterSize(uint num) { clustering = num; }
-
- // Output hexdump to a text stream
- void intoTextStream(QTextStream &strm) {
- outstrm = &strm;
- hexDump();
- }
-
- // Output hexdump to a QString
- QString toString();
-
-protected:
- void init();
- void hexDump();
- void sideviewDump(int at);
-
-private:
- uint wrap;
- uint clustering;
- uint dataSize;
- int dataWidth;
- const char *data;
- const char *prefix;
- bool dirty;
-
- char sideviewLayout[QWSHEXDUMP_MAX + 1];
- char sideview[15];
-
- QTextStream *outstrm;
-};
-
-void QWSHexDump::init()
-{
- prefix = "> "; // Standard line prefix
- clustering = 2; // Word-size clustering by default
- if (wrap > QWSHEXDUMP_MAX) // No wider than QWSHexDump_MAX bytes
- wrap = QWSHEXDUMP_MAX;
-}
-
-void QWSHexDump::hexDump()
-{
- *outstrm << '(' << dataSize << " bytes):\n" << prefix;
- sprintf(sideviewLayout, " [%%-%us]", wrap);
- dataWidth = (2 * wrap) + (wrap / clustering);
-
- dirty = false;
- uint wrapIndex = 0;
- for (uint i = 0; i < dataSize; i++) {
- uint c = static_cast<uchar>(data[i]);
- sideview[wrapIndex = i%wrap] = isprint(c) ? c : '.';
-
- if (wrapIndex && (wrapIndex % clustering == 0))
- *outstrm << ' ';
-
- outstrm->setFieldWidth(2);
- outstrm->setPadChar('0');
- outstrm->setNumberFlags( QTextStream::ShowBase );
- *outstrm << hex << c;
- dirty = true;
-
- if (wrapIndex == wrap-1) {
- sideviewDump(wrapIndex);
- wrapIndex = 0;
- if (i+1 < dataSize)
- *outstrm << endl << prefix;
- }
-
- }
- sideviewDump(wrapIndex);
-}
-
-void QWSHexDump::sideviewDump(int at)
-{
- if (dirty) {
- dirty = false;
- ++at;
- sideview[at] = '\0';
- int currentWidth = (2 * at) + (at / clustering) - (at%clustering?0:1);
- int missing = qMax(dataWidth - currentWidth, 0);
- while (missing--)
- *outstrm << ' ';
-
- *outstrm << " [";
- outstrm->setPadChar(' ');
- outstrm->setFieldWidth(wrap);
- outstrm->setFieldAlignment( QTextStream::AlignLeft );
- *outstrm << sideview;
- *outstrm << ']';
- }
-}
-
-// Output hexdump to a QString
-QString QWSHexDump::toString() {
- QString result;
- QTextStream strm(&result, QFile::WriteOnly);
- outstrm = &strm;
- hexDump();
- return result;
-}
-
-#ifndef QT_NO_DEBUG
-QDebug &operator<<(QDebug &dbg, QWSHexDump *hd) {
- if (!hd)
- return dbg << "QWSHexDump(0x0)";
- QString result = hd->toString();
- dbg.nospace() << result;
- return dbg.space();
-}
-
-// GCC & Intel wont handle references here
-QDebug operator<<(QDebug dbg, QWSHexDump hd) {
- return dbg << &hd;
-}
-#endif
-// QWSHexDump -[ end ]-----------------------------------------------
-
-
-QDebug &operator<<(QDebug &dbg, QWSCommand::Type tp)
-{
- dbg << qws_getCommandTypeString( tp );
- return dbg;
-}
-
-#define N_EVENTS 19
-const char * eventNames[N_EVENTS] = {
- "NoEvent",
- "Connected",
- "Mouse", "Focus", "Key",
- "Region",
- "Creation",
- "PropertyNotify",
- "PropertyReply",
- "SelectionClear",
- "SelectionRequest",
- "SelectionNotify",
- "MaxWindowRect",
- "QCopMessage",
- "WindowOperation",
- "IMEvent",
- "IMQuery",
- "IMInit",
- "Font"
- };
-
-class QWSServer;
-extern QWSServer *qwsServer;
-#endif
-
-const char *qws_getCommandTypeString( QWSCommand::Type tp )
-{
- const char *typeStr;
- switch(tp) {
- case QWSCommand::Create:
- typeStr = "Create";
- break;
- case QWSCommand::Shutdown:
- typeStr = "Shutdown";
- break;
- case QWSCommand::Region:
- typeStr = "Region";
- break;
- case QWSCommand::RegionMove:
- typeStr = "RegionMove";
- break;
- case QWSCommand::RegionDestroy:
- typeStr = "RegionDestroy";
- break;
- case QWSCommand::SetProperty:
- typeStr = "SetProperty";
- break;
- case QWSCommand::AddProperty:
- typeStr = "AddProperty";
- break;
- case QWSCommand::RemoveProperty:
- typeStr = "RemoveProperty";
- break;
- case QWSCommand::GetProperty:
- typeStr = "GetProperty";
- break;
- case QWSCommand::SetSelectionOwner:
- typeStr = "SetSelectionOwner";
- break;
- case QWSCommand::ConvertSelection:
- typeStr = "ConvertSelection";
- break;
- case QWSCommand::RequestFocus:
- typeStr = "RequestFocus";
- break;
- case QWSCommand::ChangeAltitude:
- typeStr = "ChangeAltitude";
- break;
- case QWSCommand::SetOpacity:
- typeStr = "SetOpacity";
- break;
- case QWSCommand::DefineCursor:
- typeStr = "DefineCursor";
- break;
- case QWSCommand::SelectCursor:
- typeStr = "SelectCursor";
- break;
- case QWSCommand::PositionCursor:
- typeStr = "PositionCursor";
- break;
- case QWSCommand::GrabMouse:
- typeStr = "GrabMouse";
- break;
- case QWSCommand::PlaySound:
- typeStr = "PlaySound";
- break;
- case QWSCommand::QCopRegisterChannel:
- typeStr = "QCopRegisterChannel";
- break;
- case QWSCommand::QCopSend:
- typeStr = "QCopSend";
- break;
- case QWSCommand::RegionName:
- typeStr = "RegionName";
- break;
- case QWSCommand::Identify:
- typeStr = "Identify";
- break;
- case QWSCommand::GrabKeyboard:
- typeStr = "GrabKeyboard";
- break;
- case QWSCommand::RepaintRegion:
- typeStr = "RepaintRegion";
- break;
- case QWSCommand::IMMouse:
- typeStr = "IMMouse";
- break;
- case QWSCommand::IMUpdate:
- typeStr = "IMUpdate";
- break;
- case QWSCommand::IMResponse:
- typeStr = "IMResponse";
- break;
- case QWSCommand::Font:
- typeStr = "Font";
- break;
- case QWSCommand::Unknown:
- default:
- typeStr = "Unknown";
- break;
- }
- return typeStr;
-}
-
-
-/*********************************************************************
- *
- * Functions to read/write commands on/from a socket
- *
- *********************************************************************/
-
-#ifndef QT_NO_QWS_MULTIPROCESS
-void qws_write_command(QIODevice *socket, int type, char *simpleData, int simpleLen,
- char *rawData, int rawLen)
-{
-#ifdef QWSCOMMAND_DEBUG
- if (simpleLen) qDebug() << "WRITE simpleData " << QWSHexDump(simpleData, simpleLen);
- if (rawLen > 0) qDebug() << "WRITE rawData " << QWSHexDump(rawData, rawLen);
-#endif
-
-#ifndef QT_NO_SXE
- QTransportAuth *a = QTransportAuth::getInstance();
- // ###### as soon as public API can be modified get rid of horrible casts
- QIODevice *ad = a->passThroughByClient(reinterpret_cast<QWSClient*>(socket));
- if (ad)
- socket = ad;
-#endif
-
- qws_write_uint(socket, type);
-
- if (rawLen > MAX_COMMAND_SIZE) {
- qWarning("qws_write_command: Message of size %d too big. "
- "Truncated to %d", rawLen, MAX_COMMAND_SIZE);
- rawLen = MAX_COMMAND_SIZE;
- }
-
- qws_write_uint(socket, rawLen == -1 ? 0 : rawLen);
-
- if (simpleData && simpleLen)
- socket->write(simpleData, simpleLen);
-
- if (rawLen && rawData)
- socket->write(rawData, rawLen);
-}
-
-/*
- command format: [type][rawLen][simpleData][rawData]
- type is already read when entering this function
-*/
-
-bool qws_read_command(QIODevice *socket, char *&simpleData, int &simpleLen,
- char *&rawData, int &rawLen, int &bytesRead)
-{
-
- // read rawLen
- if (rawLen == -1) {
- rawLen = qws_read_uint(socket);
- if (rawLen == -1)
- return false;
- }
-
- // read simpleData, assumes socket is capable of buffering all the data
- if (simpleLen && !rawData) {
- if (socket->bytesAvailable() < uint(simpleLen))
- return false;
- int tmp = socket->read(simpleData, simpleLen);
- Q_ASSERT(tmp == simpleLen);
- Q_UNUSED(tmp);
- }
-
- if (rawLen > MAX_COMMAND_SIZE) {
- socket->close();
- qWarning("qws_read_command: Won't read command of length %d, "
- "connection closed.", rawLen);
- return false;
- }
-
- // read rawData
- if (rawLen && !rawData) {
- rawData = new char[rawLen];
- bytesRead = 0;
- }
- if (bytesRead < rawLen && socket->bytesAvailable())
- bytesRead += socket->read(rawData + bytesRead, rawLen - bytesRead);
-
- return (bytesRead == rawLen);
-}
-#endif
-
-/*********************************************************************
- *
- * QWSCommand base class - only use derived classes from that
- *
- *********************************************************************/
-QWSProtocolItem::~QWSProtocolItem() {
- if (deleteRaw)
- delete []rawDataPtr;
-}
-
-#ifndef QT_NO_QWS_MULTIPROCESS
-void QWSProtocolItem::write(QIODevice *s) {
-#ifdef QWSCOMMAND_DEBUG
- if (!qwsServer)
- qDebug() << "QWSProtocolItem::write sending type " << static_cast<QWSCommand::Type>(type);
- else
- qDebug() << "QWSProtocolItem::write sending event " << (type < N_EVENTS ? eventNames[type] : "unknown");
-#endif
- qws_write_command(s, type, simpleDataPtr, simpleLen, rawDataPtr, rawLen);
-}
-
-bool QWSProtocolItem::read(QIODevice *s) {
-#ifdef QWSCOMMAND_DEBUG
- QLatin1String reread( (rawLen == -1) ? "" : "REREAD");
- if (qwsServer)
- qDebug() << "QWSProtocolItem::read reading type " << static_cast<QWSCommand::Type>(type) << reread;
- else
- qDebug() << "QWSProtocolItem::read reading event " << (type < N_EVENTS ? eventNames[type] : "unknown") << reread;
- //qDebug("QWSProtocolItem::read reading event %s", type < N_EVENTS ? eventNames[type] : "unknown");
-#endif
- bool b = qws_read_command(s, simpleDataPtr, simpleLen, rawDataPtr, rawLen, bytesRead);
- if (b) {
- setData(rawDataPtr, rawLen, false);
- deleteRaw = true;
- }
-#ifdef QWSCOMMAND_DEBUG
- else
- {
- qDebug() << "error in reading command " << static_cast<QWSCommand::Type>(type);
- }
-#endif
- return b;
-}
-#endif // QT_NO_QWS_MULTIPROCESS
-
-void QWSProtocolItem::copyFrom(const QWSProtocolItem *item) {
- if (this == item)
- return;
- simpleLen = item->simpleLen;
- memcpy(simpleDataPtr, item->simpleDataPtr, simpleLen);
- setData(item->rawDataPtr, item->rawLen);
-}
-
-void QWSProtocolItem::setData(const char *data, int len, bool allocateMem) {
- if (deleteRaw)
- delete [] rawDataPtr;
- if (!data || len <= 0) {
- rawDataPtr = 0;
- rawLen = 0;
- return;
- }
- if (allocateMem) {
- rawDataPtr = new char[len];
- memcpy(rawDataPtr, data, len);
- deleteRaw = true;
- } else {
- rawDataPtr = const_cast<char *>(data);
- deleteRaw = false;
- }
- rawLen = len;
-}
-
-QWSCommand *QWSCommand::factory(int type)
-{
- QWSCommand *command = 0;
- switch (type) {
- case QWSCommand::Create:
- command = new QWSCreateCommand;
- break;
- case QWSCommand::Shutdown:
- command = new QWSCommand(type, 0, 0);
- break;
- case QWSCommand::Region:
- command = new QWSRegionCommand;
- break;
- case QWSCommand::RegionMove:
- command = new QWSRegionMoveCommand;
- break;
- case QWSCommand::RegionDestroy:
- command = new QWSRegionDestroyCommand;
- break;
- case QWSCommand::AddProperty:
- command = new QWSAddPropertyCommand;
- break;
- case QWSCommand::SetProperty:
- command = new QWSSetPropertyCommand;
- break;
- case QWSCommand::RemoveProperty:
- command = new QWSRemovePropertyCommand;
- break;
- case QWSCommand::GetProperty:
- command = new QWSGetPropertyCommand;
- break;
- case QWSCommand::SetSelectionOwner:
- command = new QWSSetSelectionOwnerCommand;
- break;
- case QWSCommand::RequestFocus:
- command = new QWSRequestFocusCommand;
- break;
- case QWSCommand::ChangeAltitude:
- command = new QWSChangeAltitudeCommand;
- break;
- case QWSCommand::SetOpacity:
- command = new QWSSetOpacityCommand;
- break;
- case QWSCommand::DefineCursor:
- command = new QWSDefineCursorCommand;
- break;
- case QWSCommand::SelectCursor:
- command = new QWSSelectCursorCommand;
- break;
- case QWSCommand::GrabMouse:
- command = new QWSGrabMouseCommand;
- break;
- case QWSCommand::GrabKeyboard:
- command = new QWSGrabKeyboardCommand;
- break;
-#ifndef QT_NO_SOUND
- case QWSCommand::PlaySound:
- command = new QWSPlaySoundCommand;
- break;
-#endif
-#ifndef QT_NO_COP
- case QWSCommand::QCopRegisterChannel:
- command = new QWSQCopRegisterChannelCommand;
- break;
- case QWSCommand::QCopSend:
- command = new QWSQCopSendCommand;
- break;
-#endif
- case QWSCommand::RegionName:
- command = new QWSRegionNameCommand;
- break;
- case QWSCommand::Identify:
- command = new QWSIdentifyCommand;
- break;
- case QWSCommand::RepaintRegion:
- command = new QWSRepaintRegionCommand;
- break;
-#ifndef QT_NO_QWS_INPUTMETHODS
- case QWSCommand::IMUpdate:
- command = new QWSIMUpdateCommand;
- break;
-
- case QWSCommand::IMMouse:
- command = new QWSIMMouseCommand;
- break;
-
- case QWSCommand::IMResponse:
- command = new QWSIMResponseCommand;
- break;
-#endif
- case QWSCommand::PositionCursor:
- command = new QWSPositionCursorCommand;
- break;
-#ifndef QT_NO_QWSEMBEDWIDGET
- case QWSCommand::Embed:
- command = new QWSEmbedCommand;
- break;
-#endif
- case QWSCommand::Font:
- command = new QWSFontCommand;
- break;
- case QWSCommand::ScreenTransform:
- command = new QWSScreenTransformCommand;
- break;
- default:
- qWarning("QWSCommand::factory : Type error - got %08x!", type);
- }
- return command;
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/embedded/qwscommand_qws_p.h b/src/gui/embedded/qwscommand_qws_p.h
deleted file mode 100644
index 70ecc6be6d..0000000000
--- a/src/gui/embedded/qwscommand_qws_p.h
+++ /dev/null
@@ -1,851 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWSCOMMAND_QWS_P_H
-#define QWSCOMMAND_QWS_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.
-//
-
-// When reading commands "off the wire" in the server, the rawLen is read
-// and then that many bytes are allocated. If the rawLen is corrupted (or
-// the protocol is being attacked) too many bytes can be allocated. Set
-// a hard limit here for security.
-#define MAX_COMMAND_SIZE (16 * 1024)
-
-#include <QtCore/qbytearray.h>
-#include <QtGui/qwsutils_qws.h>
-#include <QtGui/qfont.h>
-#include <QtCore/qdatastream.h>
-#include <QtCore/qvariant.h>
-#include <QtCore/qrect.h>
-#include <QtGui/qregion.h>
-#include <QtCore/qvector.h>
-#include <QtCore/qvarlengtharray.h>
-#include <QtGui/qwsevent_qws.h>
-#include "qwsprotocolitem_qws.h"
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QRect;
-
-/*********************************************************************
- *
- * Functions to read/write commands on/from a socket
- *
- *********************************************************************/
-#ifndef QT_NO_QWS_MULTIPROCESS
-void qws_write_command(QIODevice *socket, int type, char *simpleData, int simpleLen, char *rawData, int rawLen);
-bool qws_read_command(QIODevice *socket, char *&simpleData, int &simpleLen, char *&rawData, int &rawLen, int &bytesRead);
-#endif
-
-struct QWSCommand : QWSProtocolItem
-{
- QWSCommand(int t, int len, char *ptr) : QWSProtocolItem(t,len,ptr) {}
-
- enum Type {
- Unknown = 0,
- Create,
- Shutdown,
- Region,
- RegionMove,
- RegionDestroy,
- SetProperty,
- AddProperty,
- RemoveProperty,
- GetProperty,
- SetSelectionOwner,
- ConvertSelection,
- RequestFocus,
- ChangeAltitude,
- SetOpacity,
- DefineCursor,
- SelectCursor,
- PositionCursor,
- GrabMouse,
- PlaySound,
- QCopRegisterChannel,
- QCopSend,
- RegionName,
- Identify,
- GrabKeyboard,
- RepaintRegion,
- IMMouse,
- IMUpdate,
- IMResponse,
- Embed,
- Font,
- ScreenTransform
- };
- static QWSCommand *factory(int type);
-};
-
-const char *qws_getCommandTypeString( QWSCommand::Type tp );
-
-#ifndef QT_NO_DEBUG
-class QDebug;
-QDebug &operator<<(QDebug &dbg, QWSCommand::Type tp);
-#endif // QT_NO_DEBUG
-
-/*********************************************************************
- *
- * Commands
- *
- *********************************************************************/
-
-struct QWSIdentifyCommand : public QWSCommand
-{
- QWSIdentifyCommand() :
- QWSCommand(QWSCommand::Identify,
- sizeof(simpleData), reinterpret_cast<char *>(&simpleData))
- {
- simpleData.idLen = 0;
- simpleData.idLock = -1;
- }
-
- void setData(const char *d, int len, bool allocateMem) {
- QWSCommand::setData(d, len, allocateMem);
- if ( simpleData.idLen > MAX_COMMAND_SIZE )
- {
- qWarning( "Identify command - name length %d - too big!", simpleData.idLen );
- simpleData.idLen = MAX_COMMAND_SIZE;
- }
- if ( simpleData.idLen * int(sizeof(QChar)) > len )
- {
- qWarning( "Identify command - name length %d - buffer size %d - buffer overrun!", simpleData.idLen, len );
- }
- else
- {
- id = QString(reinterpret_cast<const QChar*>(d), simpleData.idLen);
- }
- }
-
- void setId(const QString& i, int lock)
- {
- id = i;
- simpleData.idLen = id.length();
- simpleData.idLock = lock;
- setData(reinterpret_cast<const char*>(id.unicode()), simpleData.idLen*2, true);
- }
-
- struct SimpleData {
- int idLen;
- int idLock;
- } simpleData;
- QString id;
-};
-
-struct QWSCreateCommand : public QWSCommand
-{
- QWSCreateCommand(int n = 1) :
- QWSCommand(QWSCommand::Create, sizeof(count),
- reinterpret_cast<char *>(&count)), count(n) {}
- int count;
-};
-
-struct QWSRegionNameCommand : public QWSCommand
-{
- QWSRegionNameCommand() :
- QWSCommand(QWSCommand::RegionName,
- sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
-
- void setData(const char *d, int len, bool allocateMem) {
- QWSCommand::setData(d, len, allocateMem);
- if ( simpleData.nameLen > MAX_COMMAND_SIZE )
- {
- qWarning( "region name command - name length too big!" );
- simpleData.nameLen = MAX_COMMAND_SIZE;
- }
- if ( simpleData.captionLen > MAX_COMMAND_SIZE )
- {
- qWarning( "region name command - caption length too big!" );
- simpleData.captionLen = MAX_COMMAND_SIZE;
- }
- if ( simpleData.nameLen + simpleData.captionLen > len )
- {
- qWarning( "region name command - name length %d - caption length %d - buffer size %d - buffer overrun!",
- simpleData.nameLen, simpleData.captionLen, len );
-
- }
- else
- {
- name = QString(reinterpret_cast<const QChar*>(d), simpleData.nameLen/2);
- d += simpleData.nameLen;
- caption = QString(reinterpret_cast<const QChar*>(d), simpleData.captionLen/2);
- }
- }
-
- void setName(const QString& n, const QString &c)
- {
- name = n;
- caption = c;
- int l = simpleData.nameLen = name.length()*2;
- l += simpleData.captionLen = caption.length()*2;
- char *d = new char[l];
- memcpy(d, name.unicode(), simpleData.nameLen);
- memcpy(d+simpleData.nameLen, caption.unicode(), simpleData.captionLen);
- setData(d, l, true);
- delete[] d;
- }
-
- struct SimpleData {
- int windowid;
- int nameLen;
- int captionLen;
- } simpleData;
- QString name;
- QString caption;
-};
-
-struct QWSRegionCommand : public QWSCommand
-{
- QWSRegionCommand() :
- QWSCommand(QWSCommand::Region, sizeof(simpleData),
- reinterpret_cast<char*>(&simpleData)) {}
-
- void setData(const char *d, int len, bool allocateMem = true) {
- QWSCommand::setData(d, len, allocateMem);
-
- if( simpleData.nrectangles * int(sizeof(QRect)) + simpleData.surfacekeylength * int(sizeof(QChar)) + simpleData.surfacedatalength * int(sizeof(char)) > len )
- {
- qWarning( "region command - rectangle count %d - surface key length %d - region data size %d - buffer size %d - buffer overrun!",
- simpleData.nrectangles, simpleData.surfacekeylength, simpleData.surfacedatalength, len );
- }
- else
- {
- char *ptr = rawDataPtr;
-
- region.setRects(reinterpret_cast<QRect*>(ptr), simpleData.nrectangles);
- ptr += simpleData.nrectangles * sizeof(QRect);
-
- surfaceKey = QString(reinterpret_cast<QChar*>(ptr),
- simpleData.surfacekeylength);
- ptr += simpleData.surfacekeylength * sizeof(QChar);
-
- surfaceData = QByteArray(ptr, simpleData.surfacedatalength);
- }
- }
-
- void setData(int id, const QString &key, const QByteArray &data,
- const QRegion &reg)
- {
- surfaceKey = key;
- surfaceData = data;
- region = reg;
-
- const QVector<QRect> rects = reg.rects();
-
- simpleData.windowid = id;
- simpleData.surfacekeylength = key.size();
- simpleData.surfacedatalength = data.size();
- simpleData.nrectangles = rects.count();
-
- QVarLengthArray<char, 256> buffer;
- buffer.append(reinterpret_cast<const char*>(rects.constData()),
- rects.count() * sizeof(QRect));
- buffer.append(reinterpret_cast<const char*>(key.constData()),
- key.size() * sizeof(QChar));
- buffer.append(data, data.size());
-
- QWSCommand::setData(buffer.constData(), buffer.size(), true);
- }
-
- /* XXX this will pad out in a compiler dependent way,
- should move nrectangles to before windowtype, and
- add reserved bytes.
- Symptom will be valgrind reported uninitialized memory usage
- */
- struct SimpleData {
- int windowid;
- int surfacekeylength;
- int surfacedatalength;
- int nrectangles;
- } simpleData;
-
- QString surfaceKey;
- QByteArray surfaceData;
- QRegion region;
-};
-
-struct QWSSetOpacityCommand : public QWSCommand
-{
- QWSSetOpacityCommand() :
- QWSCommand(QWSCommand::SetOpacity, sizeof(simpleData),
- reinterpret_cast<char*>(&simpleData)) {}
-
- struct SimpleData {
- int windowid;
- uchar opacity;
- } simpleData;
-};
-
-struct QWSRegionMoveCommand : public QWSCommand
-{
- QWSRegionMoveCommand() :
- QWSCommand(QWSCommand::RegionMove, sizeof(simpleData),
- reinterpret_cast<char*>(&simpleData)) {}
-
- struct SimpleData {
- int windowid;
- int dx;
- int dy;
- } simpleData;
-
-};
-
-struct QWSRegionDestroyCommand : public QWSCommand
-{
- QWSRegionDestroyCommand() :
- QWSCommand(QWSCommand::RegionDestroy, sizeof(simpleData),
- reinterpret_cast<char*>(&simpleData)) {}
-
- struct SimpleData {
- int windowid;
- } simpleData;
-
-};
-
-struct QWSRequestFocusCommand : public QWSCommand
-{
- QWSRequestFocusCommand() :
- QWSCommand(QWSCommand::RequestFocus, sizeof(simpleData), reinterpret_cast<char*>(&simpleData)) {}
-
- struct SimpleData {
- int windowid;
- int flag;
- } simpleData;
-};
-
-struct QWSChangeAltitudeCommand : public QWSCommand
-{
- QWSChangeAltitudeCommand() :
- QWSCommand(QWSCommand::ChangeAltitude, sizeof(simpleData), reinterpret_cast<char*>(&simpleData)) {}
-
- enum Altitude {
- Lower = -1,
- Raise = 0,
- StaysOnTop = 1
- };
-
- struct SimpleData {
- int windowid;
- Altitude altitude;
- bool fixed;
- } simpleData;
-
-};
-
-
-struct QWSAddPropertyCommand : public QWSCommand
-{
- QWSAddPropertyCommand() :
- QWSCommand(QWSCommand::AddProperty, sizeof(simpleData), reinterpret_cast<char*>(&simpleData)) {}
-
- struct SimpleData {
- int windowid, property;
- } simpleData;
-
-};
-
-struct QWSSetPropertyCommand : public QWSCommand
-{
- QWSSetPropertyCommand() :
- QWSCommand(QWSCommand::SetProperty, sizeof(simpleData),
- reinterpret_cast<char*>(&simpleData)) { data = 0; }
-
- void setData(const char *d, int len, bool allocateMem = true) {
- QWSCommand::setData(d, len, allocateMem);
- data = rawDataPtr;
- }
-
- struct SimpleData {
- int windowid, property, mode;
- } simpleData;
-
- char *data;
-};
-
-struct QWSRepaintRegionCommand : public QWSCommand
-{
- QWSRepaintRegionCommand() :
- QWSCommand(QWSCommand::RepaintRegion, sizeof(simpleData),
- reinterpret_cast<char*>(&simpleData)) {}
-
- void setData(const char *d, int len, bool allocateMem = true) {
- QWSCommand::setData(d, len, allocateMem);
-
- if( simpleData.nrectangles * int(sizeof(QRect)) > len )
- {
- qWarning( "repaint region command - region rectangle count %d - buffer size %d - buffer overrun",
- simpleData.nrectangles, len );
-
- simpleData.nrectangles = len / sizeof(QRect);
- }
- rectangles = reinterpret_cast<QRect *>(rawDataPtr);
- }
-
- struct SimpleData {
- int windowid;
- int windowFlags;
- bool opaque;
- int nrectangles;
- } simpleData;
-
- QRect * rectangles;
-
-};
-
-struct QWSRemovePropertyCommand : public QWSCommand
-{
- QWSRemovePropertyCommand() :
- QWSCommand(QWSCommand::RemoveProperty, sizeof(simpleData), reinterpret_cast<char*>(&simpleData)) {}
-
- struct SimpleData {
- int windowid, property;
- } simpleData;
-
-};
-
-struct QWSGetPropertyCommand : public QWSCommand
-{
- QWSGetPropertyCommand() :
- QWSCommand(QWSCommand::GetProperty, sizeof(simpleData), reinterpret_cast<char*>(&simpleData)) {}
-
- struct SimpleData {
- int windowid, property;
- } simpleData;
-
-};
-
-struct QWSSetSelectionOwnerCommand : public QWSCommand
-{
- QWSSetSelectionOwnerCommand() :
- QWSCommand(QWSCommand::SetSelectionOwner,
- sizeof(simpleData), reinterpret_cast<char*>(&simpleData)) {}
-
- struct SimpleData {
- int windowid;
- int hour, minute, sec, ms; // time
- } simpleData;
-
-};
-
-struct QWSConvertSelectionCommand : public QWSCommand
-{
- QWSConvertSelectionCommand() :
- QWSCommand(QWSCommand::ConvertSelection,
- sizeof(simpleData), reinterpret_cast<char*>(&simpleData)) {}
-
- struct SimpleData {
- int requestor; // requestor window of the selection
- int selection; // property on requestor into which the selection should be stored
- int mimeTypes; // property ion requestor in which the mimetypes, in which the selection may be, are stored
- } simpleData;
-
-};
-
-struct QWSDefineCursorCommand : public QWSCommand
-{
- QWSDefineCursorCommand() :
- QWSCommand(QWSCommand::DefineCursor,
- sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
-
- void setData(const char *d, int len, bool allocateMem = true) {
- QWSCommand::setData(d, len, allocateMem);
- data = reinterpret_cast<unsigned char *>(rawDataPtr);
- if (simpleData.height * ((simpleData.width+7) / 8) > len) {
- qWarning("define cursor command - width %d height %d- buffer size %d - buffer overrun",
- simpleData.width, simpleData.height, len );
- simpleData.width = simpleData.height = 0;
- }
- }
-
- struct SimpleData {
- int width;
- int height;
- int hotX;
- int hotY;
- int id;
- } simpleData;
-
- unsigned char *data;
-};
-
-struct QWSSelectCursorCommand : public QWSCommand
-{
- QWSSelectCursorCommand() :
- QWSCommand(QWSCommand::SelectCursor,
- sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
-
- struct SimpleData {
- int windowid;
- int id;
- } simpleData;
-};
-
-struct QWSPositionCursorCommand : public QWSCommand
-{
- QWSPositionCursorCommand() :
- QWSCommand(QWSCommand::PositionCursor,
- sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
-
- struct SimpleData {
- int newX;
- int newY;
- } simpleData;
-};
-
-struct QWSGrabMouseCommand : public QWSCommand
-{
- QWSGrabMouseCommand() :
- QWSCommand(QWSCommand::GrabMouse,
- sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
-
- struct SimpleData {
- int windowid;
- bool grab; // grab or ungrab?
- } simpleData;
-};
-
-struct QWSGrabKeyboardCommand : public QWSCommand
-{
- QWSGrabKeyboardCommand() :
- QWSCommand(QWSCommand::GrabKeyboard,
- sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
-
- struct SimpleData {
- int windowid;
- bool grab; // grab or ungrab?
- } simpleData;
-};
-
-#ifndef QT_NO_SOUND
-struct QWSPlaySoundCommand : public QWSCommand
-{
- QWSPlaySoundCommand() :
- QWSCommand(QWSCommand::PlaySound,
- sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
-
- void setData(const char *d, int len, bool allocateMem) {
- QWSCommand::setData(d, len, allocateMem);
- filename = QString(reinterpret_cast<QChar*>(rawDataPtr),len/2);
- }
- void setFileName(const QString& n)
- {
- setData(reinterpret_cast<const char*>(n.unicode()), n.length()*2, true);
- }
-
- struct SimpleData {
- int windowid;
- } simpleData;
- QString filename;
-};
-#endif
-
-
-#ifndef QT_NO_COP
-struct QWSQCopRegisterChannelCommand : public QWSCommand
-{
- QWSQCopRegisterChannelCommand() :
- QWSCommand(QWSCommand::QCopRegisterChannel,
- sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
-
- void setData(const char *d, int len, bool allocateMem) {
- QWSCommand::setData(d, len, allocateMem);
- if ( simpleData.chLen > MAX_COMMAND_SIZE )
- {
- qWarning( "Command channel name too large!" );
- simpleData.chLen = MAX_COMMAND_SIZE;
- }
- if( simpleData.chLen * int(sizeof(QChar)) > len )
- {
- qWarning( "register qcop channel command - channel name length %d - buffer size %d - buffer overrun!", simpleData.chLen, len );
- }
- else
- {
- channel = QString(reinterpret_cast<const QChar*>(d), simpleData.chLen);
- }
- }
-
- void setChannel(const QString& n)
- {
- channel = n;
- simpleData.chLen = channel.length();
- setData(reinterpret_cast<const char*>(channel.unicode()), simpleData.chLen*2, true);
- }
-
- struct SimpleData {
- int chLen;
- } simpleData;
- QString channel;
-};
-
-struct QWSQCopSendCommand : public QWSCommand
-{
- QWSQCopSendCommand() :
- QWSCommand(QWSCommand::QCopSend,
- sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
-
- void setData(const char *d, int len, bool allocateMem) {
- QWSCommand::setData(d, len, allocateMem);
-
- if( simpleData.clen * int(sizeof(QChar)) + simpleData.mlen * int(sizeof(QChar)) + simpleData.dlen * int(sizeof(char)) > len )
- {
- qWarning( "qcop send command - channel name length %d - message name length %d - data size %d - buffer size %d - buffer overrun!",
- simpleData.clen, simpleData.mlen, simpleData.dlen, len );
- }
- else
- {
- const QChar *cd = reinterpret_cast<const QChar*>(d);
- channel = QString(cd,simpleData.clen); cd += simpleData.clen;
- message = QString(cd,simpleData.mlen);
- d += simpleData.clen*sizeof(QChar) + simpleData.mlen*sizeof(QChar);
- data = QByteArray(d, simpleData.dlen);
- }
- }
-
- void setMessage(const QString &c, const QString &m,
- const QByteArray &data)
- {
- this->channel = c;
- this->message = m;
- this->data = data;
- simpleData.clen = c.length();
- simpleData.mlen = m.length();
- simpleData.dlen = data.size();
- int l = simpleData.clen*sizeof(QChar);
- l += simpleData.mlen*sizeof(QChar);
- l += simpleData.dlen;
- char *tmp = new char[l];
- char *d = tmp;
- memcpy(d, c.unicode(), simpleData.clen*sizeof(QChar));
- d += simpleData.clen*sizeof(QChar);
- memcpy(d, m.unicode(), simpleData.mlen*sizeof(QChar));
- d += simpleData.mlen*sizeof(QChar);
- memcpy(d, data.data(), simpleData.dlen);
- QWSCommand::setData(tmp, l, false);
- deleteRaw = true;
- }
-
- struct SimpleData {
- int clen;
- int mlen;
- int dlen;
- } simpleData;
- QString channel;
- QString message;
- QByteArray data;
-};
-
-#endif
-
-
-#ifndef QT_NO_QWS_INPUTMETHODS
-
-struct QWSIMMouseCommand : public QWSCommand
-{
- QWSIMMouseCommand() :
- QWSCommand(QWSCommand::IMMouse,
- sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
-
- struct SimpleData {
- int windowid;
- int state;
- int index;
- } simpleData;
-};
-
-
-struct QWSIMResponseCommand : public QWSCommand
-{
- QWSIMResponseCommand() :
- QWSCommand(QWSCommand::IMResponse,
- sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
-
- void setData(const char *d, int len, bool allocateMem) {
- QWSCommand::setData(d, len, allocateMem);
-
- QByteArray tmp = QByteArray::fromRawData(d, len);
- QDataStream s(tmp);
- s >> result;
- }
-
- void setResult(const QVariant & v)
- {
- QByteArray tmp;
- QDataStream s(&tmp, QIODevice::WriteOnly);
- s << v;
- setData(tmp.data(), tmp.size(), true);
- }
-
- struct SimpleData {
- int windowid;
- int property;
- } simpleData;
-
- QVariant result;
-};
-
-struct QWSIMUpdateCommand: public QWSCommand
-{
- QWSIMUpdateCommand() :
- QWSCommand(QWSCommand::IMUpdate,
- sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
-
- struct SimpleData {
- int windowid;
- int type;
- int widgetid;
- } simpleData;
-};
-
-#endif
-
-#ifndef QT_NO_QWSEMBEDWIDGET
-struct QWSEmbedCommand : public QWSCommand
-{
- QWSEmbedCommand() : QWSCommand(QWSCommand::Embed,
- sizeof(simpleData),
- reinterpret_cast<char*>(&simpleData))
- {}
-
- void setData(const char *d, int len, bool allocateMem = true)
- {
- QWSCommand::setData(d, len, allocateMem);
-
- if( simpleData.rects * int(sizeof(QRect)) > len )
- {
- qWarning( "embed command - region rectangle count %d - buffer size %d - buffer overrun!",
- simpleData.rects, len );
- }
- else
- {
- region.setRects(reinterpret_cast<QRect*>(rawDataPtr),
- simpleData.rects);
- }
- }
-
- void setData(WId embedder, WId embedded, QWSEmbedEvent::Type type,
- const QRegion reg = QRegion())
- {
- simpleData.embedder = embedder;
- simpleData.embedded = embedded;
- simpleData.type = type;
-
- region = reg;
- const QVector<QRect> rects = reg.rects();
- simpleData.rects = rects.count();
-
- QWSCommand::setData(reinterpret_cast<const char*>(rects.constData()),
- rects.count() * sizeof(QRect));
- }
-
- struct {
- WId embedder;
- WId embedded;
- QWSEmbedEvent::Type type;
- int rects;
- } simpleData;
-
- QRegion region;
-};
-#endif // QT_NO_QWSEMBEDWIDGET
-
-struct QWSFontCommand : public QWSCommand
-{
- enum CommandType {
- StartedUsingFont,
- StoppedUsingFont
- };
-
- QWSFontCommand() :
- QWSCommand(QWSCommand::Font,
- sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
-
- void setData(const char *d, int len, bool allocateMem) {
- QWSCommand::setData(d, len, allocateMem);
-
- fontName = QByteArray(d, len);
- }
-
- void setFontName(const QByteArray &name)
- {
- setData(name.constData(), name.size(), true);
- }
-
- struct SimpleData {
- int type;
- } simpleData;
-
- QByteArray fontName;
-};
-
-struct QWSScreenTransformCommand : public QWSCommand
-{
- QWSScreenTransformCommand() :
- QWSCommand(QWSCommand::ScreenTransform,
- sizeof(simpleData), reinterpret_cast<char *>(&simpleData)) {}
-
- void setTransformation(int screen, int transformation)
- {
- simpleData.screen = screen;
- simpleData.transformation = transformation;
- }
-
- struct SimpleData {
- int screen;
- int transformation;
- } simpleData;
-};
-
-QT_END_NAMESPACE
-
-#endif // QWSCOMMAND_QWS_P_H
diff --git a/src/gui/embedded/qwscursor_qws.cpp b/src/gui/embedded/qwscursor_qws.cpp
deleted file mode 100644
index 0313e00391..0000000000
--- a/src/gui/embedded/qwscursor_qws.cpp
+++ /dev/null
@@ -1,654 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qcursor.h"
-#include "qbitmap.h"
-#include "qscreen_qws.h"
-#include "qapplication.h"
-#include "qwindowsystem_qws.h"
-#include "qwindowsystem_p.h"
-#include "qwscursor_qws.h"
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_QWS_CURSOR
-static QWSCursor *systemCursorTable[Qt::LastCursor+1];
-static bool systemCursorTableInit = false;
-
-// 16 x 16
-static const uchar cur_arrow_bits[] = {
- 0x07, 0x00, 0x39, 0x00, 0xc1, 0x01, 0x02, 0x0e, 0x02, 0x10, 0x02, 0x08,
- 0x04, 0x04, 0x04, 0x02, 0x04, 0x04, 0x88, 0x08, 0x48, 0x11, 0x28, 0x22,
- 0x10, 0x44, 0x00, 0x28, 0x00, 0x10, 0x00, 0x00 };
-static const uchar mcur_arrow_bits[] = {
- 0x07, 0x00, 0x3f, 0x00, 0xff, 0x01, 0xfe, 0x0f, 0xfe, 0x1f, 0xfe, 0x0f,
- 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x0f, 0x78, 0x1f, 0x38, 0x3e,
- 0x10, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00, 0x00 };
-
-static const unsigned char cur_up_arrow_bits[] = {
- 0x80, 0x00, 0x40, 0x01, 0x40, 0x01, 0x20, 0x02, 0x20, 0x02, 0x10, 0x04,
- 0x10, 0x04, 0x08, 0x08, 0x78, 0x0f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01,
- 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01};
-static const unsigned char mcur_up_arrow_bits[] = {
- 0x80, 0x00, 0xc0, 0x01, 0xc0, 0x01, 0xe0, 0x03, 0xe0, 0x03, 0xf0, 0x07,
- 0xf0, 0x07, 0xf8, 0x0f, 0xf8, 0x0f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
- 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01};
-
-static const unsigned char cur_cross_bits[] = {
- 0xc0, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01,
- 0x7f, 0x7f, 0x01, 0x40, 0x7f, 0x7f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01,
- 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01, 0x00, 0x00};
-static const unsigned char mcur_cross_bits[] = {
- 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
- 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
- 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00};
-
-static const uchar cur_ibeam_bits[] = {
- 0x00, 0x00, 0xe0, 0x03, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00,
- 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00,
- 0x80, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00 };
-static const uchar mcur_ibeam_bits[] = {
- 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
- 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
- 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0x00, 0x00 };
-
-static const uchar cur_ver_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f,
- 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f,
- 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 };
-static const uchar mcur_ver_bits[] = {
- 0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f,
- 0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f,
- 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 };
-
-static const uchar cur_hor_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18,
- 0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-static const uchar mcur_hor_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c,
- 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c,
- 0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 };
-static const uchar cur_bdiag_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e,
- 0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00,
- 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-static const uchar mcur_bdiag_bits[] = {
- 0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f,
- 0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01,
- 0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 };
-static const uchar cur_fdiag_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00,
- 0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c,
- 0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 };
-static const uchar mcur_fdiag_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00,
- 0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e,
- 0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 };
-static const uchar cur_blank_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-// 20 x 20
-static const uchar forbidden_bits[] = {
- 0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01,
- 0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06,
- 0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03,
- 0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 };
-
-static const uchar forbiddenm_bits[] = {
- 0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03,
- 0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f,
- 0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07,
- 0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00};
-
-// 32 x 32
-static const uchar wait_data_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00,
- 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x08, 0x20, 0x00,
- 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00,
- 0x00, 0x50, 0x15, 0x00, 0x00, 0xa0, 0x0a, 0x00, 0x00, 0x40, 0x05, 0x00,
- 0x00, 0x80, 0x02, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x20, 0x08, 0x00,
- 0x00, 0x10, 0x10, 0x00, 0x00, 0x08, 0x21, 0x00, 0x00, 0x88, 0x22, 0x00,
- 0x00, 0x48, 0x25, 0x00, 0x00, 0xa8, 0x2a, 0x00, 0x00, 0xfc, 0x7f, 0x00,
- 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-static const uchar wait_mask_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00,
- 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xf8, 0x3f, 0x00,
- 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00,
- 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xc0, 0x07, 0x00,
- 0x00, 0x80, 0x03, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xe0, 0x0f, 0x00,
- 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00,
- 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00,
- 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const uchar hsplit_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
- 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
- 0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03,
- 0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00,
- 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
- 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-static const uchar hsplitm_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
- 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00,
- 0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07,
- 0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00,
- 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
- 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-static const uchar vsplit_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00,
- 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-static const uchar vsplitm_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
- 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00,
- 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
- 0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
- 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
- 0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
- 0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00,
- 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-static const uchar phand_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00,
- 0x7e, 0x04, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x70, 0x08, 0x00, 0x00,
- 0x08, 0x08, 0x00, 0x00, 0x70, 0x14, 0x00, 0x00, 0x08, 0x22, 0x00, 0x00,
- 0x30, 0x41, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0x40, 0x12, 0x00, 0x00,
- 0x80, 0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-static const uchar phandm_bits[] = {
- 0xfe, 0x01, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0xff, 0x07, 0x00, 0x00,
- 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00,
- 0xfc, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00,
- 0xf8, 0xff, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00,
- 0xc0, 0x1f, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00,
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const uchar size_all_data_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x80, 0x81, 0xc0, 0x00,
- 0xc0, 0xff, 0xff, 0x01, 0x80, 0x81, 0xc0, 0x00, 0x00, 0x81, 0x40, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-static const uchar size_all_mask_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
- 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00,
- 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc2, 0x21, 0x00,
- 0x00, 0xc3, 0x61, 0x00, 0x80, 0xc3, 0xe1, 0x00, 0xc0, 0xff, 0xff, 0x01,
- 0xe0, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0x01, 0x80, 0xc3, 0xe1, 0x00,
- 0x00, 0xc3, 0x61, 0x00, 0x00, 0xc2, 0x21, 0x00, 0x00, 0xc0, 0x01, 0x00,
- 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0xe0, 0x03, 0x00,
- 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const uchar whatsthis_bits[] = {
- 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00,
- 0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00,
- 0x41, 0x1c, 0x0e, 0x00, 0x81, 0x1c, 0x0e, 0x00, 0x01, 0x01, 0x07, 0x00,
- 0x01, 0x82, 0x03, 0x00, 0xc1, 0xc7, 0x01, 0x00, 0x49, 0xc0, 0x01, 0x00,
- 0x95, 0xc0, 0x01, 0x00, 0x93, 0xc0, 0x01, 0x00, 0x21, 0x01, 0x00, 0x00,
- 0x20, 0xc1, 0x01, 0x00, 0x40, 0xc2, 0x01, 0x00, 0x40, 0x02, 0x00, 0x00,
- 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
-static const uchar whatsthism_bits[] = {
- 0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00,
- 0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00,
- 0x7f, 0x3e, 0x1f, 0x00, 0xff, 0x3e, 0x1f, 0x00, 0xff, 0x9d, 0x0f, 0x00,
- 0xff, 0xc3, 0x07, 0x00, 0xff, 0xe7, 0x03, 0x00, 0x7f, 0xe0, 0x03, 0x00,
- 0xf7, 0xe0, 0x03, 0x00, 0xf3, 0xe0, 0x03, 0x00, 0xe1, 0xe1, 0x03, 0x00,
- 0xe0, 0xe1, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00,
- 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
-
-static const uchar busy_bits[] = {
- 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
- 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00,
- 0x41, 0xe0, 0xff, 0x00, 0x81, 0x20, 0x80, 0x00, 0x01, 0xe1, 0xff, 0x00,
- 0x01, 0x42, 0x40, 0x00, 0xc1, 0x47, 0x40, 0x00, 0x49, 0x40, 0x55, 0x00,
- 0x95, 0x80, 0x2a, 0x00, 0x93, 0x00, 0x15, 0x00, 0x21, 0x01, 0x0a, 0x00,
- 0x20, 0x01, 0x11, 0x00, 0x40, 0x82, 0x20, 0x00, 0x40, 0x42, 0x44, 0x00,
- 0x80, 0x41, 0x4a, 0x00, 0x00, 0x40, 0x55, 0x00, 0x00, 0xe0, 0xff, 0x00,
- 0x00, 0x20, 0x80, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-static const uchar busym_bits[] = {
- 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
- 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00,
- 0x7f, 0xe0, 0xff, 0x00, 0xff, 0xe0, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00,
- 0xff, 0xc3, 0x7f, 0x00, 0xff, 0xc7, 0x7f, 0x00, 0x7f, 0xc0, 0x7f, 0x00,
- 0xf7, 0x80, 0x3f, 0x00, 0xf3, 0x00, 0x1f, 0x00, 0xe1, 0x01, 0x0e, 0x00,
- 0xe0, 0x01, 0x1f, 0x00, 0xc0, 0x83, 0x3f, 0x00, 0xc0, 0xc3, 0x7f, 0x00,
- 0x80, 0xc1, 0x7f, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0x00,
- 0x00, 0xe0, 0xff, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-
-// 16 x 16
-static const uchar openhand_bits[] = {
- 0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92,
- 0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20,
- 0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00};
-static const uchar openhandm_bits[] = {
- 0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff,
- 0xfe,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f,
- 0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00};
-static const uchar closedhand_bits[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50,
- 0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10,
- 0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00};
-static const uchar closedhandm_bits[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f,
- 0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f,
- 0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00};
-
-#endif
-
-void QWSServerPrivate::initializeCursor()
-{
- Q_Q(QWSServer);
- // setup system cursors
-#ifndef QT_NO_QWS_CURSOR
-// qt_screen->initCursor(sharedram + ramlen,true);
-
- // default cursor
- cursor = 0;
- setCursor(QWSCursor::systemCursor(Qt::ArrowCursor));
-#endif
- q->sendMouseEvent(QPoint(swidth/2, sheight/2), 0);
-}
-
-void QWSServerPrivate::setCursor(QWSCursor *curs)
-{
-#ifdef QT_NO_QWS_CURSOR
- Q_UNUSED(curs);
-#else
- if (cursor == curs)
- return;
-
- cursor = curs;
-
- if (!haveviscurs || !curs)
- curs = QWSCursor::systemCursor(Qt::BlankCursor);
-
- if (qt_screencursor) {
- qt_screencursor->set(curs->image(),
- curs->hotSpot().x(),
- curs->hotSpot().y());
- }
-#endif
-}
-
-#ifndef QT_NO_QWS_CURSOR
-static void cleanupSystemCursorTable()
-{
- for (int i = 0; i <= Qt::LastCursor; i++)
- if (systemCursorTable[i]) {
- delete systemCursorTable[i];
- systemCursorTable[i] = 0;
- }
-}
-#endif
-
-void QWSCursor::createSystemCursor(int id)
-{
-#ifdef QT_NO_QWS_CURSOR
- Q_UNUSED(id);
-#else
- if (!systemCursorTableInit) {
- for (int i = 0; i <= Qt::LastCursor; i++)
- systemCursorTable[i] = 0;
- qAddPostRoutine(cleanupSystemCursorTable);
- systemCursorTableInit = true;
- }
- switch (id) {
- // 16x16 cursors
- case Qt::ArrowCursor:
- systemCursorTable[Qt::ArrowCursor] =
- new QWSCursor(cur_arrow_bits, mcur_arrow_bits, 16, 16, 0, 0);
- break;
-
- case Qt::UpArrowCursor:
- systemCursorTable[Qt::UpArrowCursor] =
- new QWSCursor(cur_up_arrow_bits, mcur_up_arrow_bits, 16, 16, 7, 0);
- break;
-
- case Qt::CrossCursor:
- systemCursorTable[Qt::CrossCursor] =
- new QWSCursor(cur_cross_bits, mcur_cross_bits, 16, 16, 7, 7);
- break;
-
- case Qt::IBeamCursor:
- systemCursorTable[Qt::IBeamCursor] =
- new QWSCursor(cur_ibeam_bits, mcur_ibeam_bits, 16, 16, 7, 7);
- break;
-
- case Qt::SizeVerCursor:
- systemCursorTable[Qt::SizeVerCursor] =
- new QWSCursor(cur_ver_bits, mcur_ver_bits, 16, 16, 7, 7);
- break;
-
- case Qt::SizeHorCursor:
- systemCursorTable[Qt::SizeHorCursor] =
- new QWSCursor(cur_hor_bits, mcur_hor_bits, 16, 16, 7, 7);
- break;
-
- case Qt::SizeBDiagCursor:
- systemCursorTable[Qt::SizeBDiagCursor] =
- new QWSCursor(cur_bdiag_bits, mcur_bdiag_bits, 16, 16, 7, 7);
- break;
-
- case Qt::SizeFDiagCursor:
- systemCursorTable[Qt::SizeFDiagCursor] =
- new QWSCursor(cur_fdiag_bits, mcur_fdiag_bits, 16, 16, 7, 7);
- break;
-
- case Qt::BlankCursor:
- systemCursorTable[Qt::BlankCursor] =
- new QWSCursor(0, 0, 0, 0, 0, 0);
- break;
-
- // 20x20 cursors
- case Qt::ForbiddenCursor:
- systemCursorTable[Qt::ForbiddenCursor] =
- new QWSCursor(forbidden_bits, forbiddenm_bits, 20, 20, 10, 10);
- break;
-
- // 32x32 cursors
- case Qt::WaitCursor:
- systemCursorTable[Qt::WaitCursor] =
- new QWSCursor(wait_data_bits, wait_mask_bits, 32, 32, 15, 15);
- break;
-
- case Qt::SplitVCursor:
- systemCursorTable[Qt::SplitVCursor] =
- new QWSCursor(vsplit_bits, vsplitm_bits, 32, 32, 15, 15);
- break;
-
- case Qt::SplitHCursor:
- systemCursorTable[Qt::SplitHCursor] =
- new QWSCursor(hsplit_bits, hsplitm_bits, 32, 32, 15, 15);
- break;
-
- case Qt::SizeAllCursor:
- systemCursorTable[Qt::SizeAllCursor] =
- new QWSCursor(size_all_data_bits, size_all_mask_bits, 32, 32, 15, 15);
- break;
-
- case Qt::PointingHandCursor:
- systemCursorTable[Qt::PointingHandCursor] =
- new QWSCursor(phand_bits, phandm_bits, 32, 32, 0, 0);
- break;
-
- case Qt::WhatsThisCursor:
- systemCursorTable[Qt::WhatsThisCursor] =
- new QWSCursor(whatsthis_bits, whatsthism_bits, 32, 32, 0, 0);
- break;
- case Qt::BusyCursor:
- systemCursorTable[Qt::BusyCursor] =
- new QWSCursor(busy_bits, busym_bits, 32, 32, 0, 0);
- break;
-
- case Qt::OpenHandCursor:
- systemCursorTable[Qt::OpenHandCursor] =
- new QWSCursor(openhand_bits, openhandm_bits, 16, 16, 8, 8);
- break;
- case Qt::ClosedHandCursor:
- systemCursorTable[Qt::ClosedHandCursor] =
- new QWSCursor(closedhand_bits, closedhandm_bits, 16, 16, 8, 8);
- break;
- default:
- qWarning("Unknown system cursor %d", id);
- }
-#endif
-}
-
-QWSCursor *QWSCursor::systemCursor(int id)
-{
- QWSCursor *cursor = 0;
-#ifdef QT_NO_QWS_CURSOR
- Q_UNUSED(id);
-#else
- if (id >= 0 && id <= Qt::LastCursor) {
- if (!systemCursorTable[id])
- createSystemCursor(id);
- cursor = systemCursorTable[id];
- }
-
- if (cursor == 0) {
- if (!systemCursorTable[Qt::ArrowCursor])
- createSystemCursor(Qt::ArrowCursor);
- cursor = systemCursorTable[Qt::ArrowCursor];
- }
-#endif
- return cursor;
-}
-
-void QWSCursor::set(const uchar *data, const uchar *mask,
- int width, int height, int hx, int hy)
-{
-#ifdef QT_NO_QWS_CURSOR
- Q_UNUSED(data);
- Q_UNUSED(mask);
- Q_UNUSED(width);
- Q_UNUSED(height);
- Q_UNUSED(hx);
- Q_UNUSED(hy);
-#else
- hot.setX(hx);
- hot.setY(hy);
-
- cursor = QImage(width,height, QImage::Format_Indexed8);
-
- if (!width || !height || !data || !mask || cursor.isNull())
- return;
-
- cursor.setColorCount(3);
- cursor.setColor(0, 0xff000000);
- cursor.setColor(1, 0xffffffff);
- cursor.setColor(2, 0x00000000);
-
- int bytesPerLine = (width + 7) / 8;
- int p = 0;
- int d, m;
-
- int x = -1, w = 0;
-
- uchar *cursor_data = cursor.bits();
- int bpl = cursor.bytesPerLine();
- for (int i = 0; i < height; i++)
- {
- for (int j = 0; j < bytesPerLine; j++, data++, mask++)
- {
- for (int b = 0; b < 8 && j*8+b < width; b++)
- {
- d = *data & (1 << b);
- m = *mask & (1 << b);
- if (d && m) p = 0;
- else if (!d && m) p = 1;
- else p = 2;
- cursor_data[j*8+b] = p;
-
- // calc region
- if (x < 0 && m)
- x = j*8+b;
- else if (x >= 0 && !m) {
- x = -1;
- w = 0;
- }
- if (m)
- w++;
- }
- }
- if (x >= 0) {
- x = -1;
- w = 0;
- }
- cursor_data += bpl;
- }
-
- if (qt_screencursor && qt_screencursor->supportsAlphaCursor())
- createDropShadow(5, 2);
-#endif
-}
-
-// now we're really silly
-void QWSCursor::createDropShadow(int dropx, int dropy)
-{
- //####
-#if 1 || defined(QT_NO_QWS_CURSOR) || defined(QT_NO_QWS_ALHPA_CURSOR)
- Q_UNUSED(dropx);
- Q_UNUSED(dropy);
-#else
- if (cursor.width() + dropx > 64 || cursor.height() + dropy > 64)
- return;
-
- if (!cursor.hasAlphaBuffer()) {
- cursor.setAlphaBuffer(true);
-
- const int nblur=4;
- const int darkness=140;
-
- QImage drop(cursor.width()+dropx+nblur, cursor.height()+dropy+nblur, 8, 18);
- drop.setColor(0, 0xff000000); // bg (black)
- drop.setColor(1, 0xffffffff); // fg (white)
- for (int i=0; i<16; i++) {
- drop.setColor(2+i, (darkness*i/16)<<24);
- }
- drop.fill(2); // all trans
- QImage drop2 = drop.copy();
-
- int cp;
-
- // made solid shadow
- for (int row = 0; row < cursor.height(); row++) {
- for (int col = 0; col < cursor.width(); col++) {
- cp = cursor.pixelIndex(col, row);
- if (cp != 2)
- drop.setPixel(col+dropx, row+dropy, 17);
- }
- }
-
- // blur shadow
- for (int blur=0; blur<nblur; blur++) {
- QImage& to((blur&1)?drop:drop2);
- QImage& from((blur&1)?drop2:drop);
- for (int row = 1; row < drop.height()-1; row++) {
- for (int col = 1; col < drop.width()-1; col++) {
- int t=0;
- for (int dx=-1; dx<=1; dx++) {
- for (int dy=-1; dy<=1; dy++) {
- t += from.pixelIndex(col+dx,row+dy)-2;
- }
- }
- to.setPixel(col,row,2+t/9);
- }
- }
- }
-
- // copy cursor
- for (int row = 0; row < cursor.height(); row++) {
- for (int col = 0; col < cursor.width(); col++) {
- cp = cursor.pixelIndex(col, row);
- if (cp != 2)
- drop.setPixel(col, row, cp);
- }
- }
-
- cursor = drop;
- }
-#endif
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/embedded/qwscursor_qws.h b/src/gui/embedded/qwscursor_qws.h
deleted file mode 100644
index 39464173c1..0000000000
--- a/src/gui/embedded/qwscursor_qws.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWSCURSOR_QWS_H
-#define QWSCURSOR_QWS_H
-
-#include <QtGui/qimage.h>
-#include <QtGui/qregion.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QWSCursor
-{
-public:
- QWSCursor() {}
- QWSCursor(const uchar *data, const uchar *mask, int width, int height,
- int hotX, int hotY)
- { set(data, mask, width, height, hotX, hotY); }
-
- void set(const uchar *data, const uchar *mask,
- int width, int height, int hotX, int hotY);
-
- QPoint hotSpot() const { return hot; }
- QImage &image() { return cursor; }
-
- static QWSCursor *systemCursor(int id);
-
-private:
- static void createSystemCursor(int id);
- void createDropShadow(int dropx, int dropy);
-
-private:
- QPoint hot;
- QImage cursor;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QWSCURSOR_QWS_H
diff --git a/src/gui/embedded/qwsdisplay_qws.h b/src/gui/embedded/qwsdisplay_qws.h
deleted file mode 100644
index 81acb425c9..0000000000
--- a/src/gui/embedded/qwsdisplay_qws.h
+++ /dev/null
@@ -1,185 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWSDISPLAY_QWS_H
-#define QWSDISPLAY_QWS_H
-
-#include <QtCore/qobject.h>
-#include <QtCore/qbytearray.h>
-#include <QtGui/qregion.h>
-#include <QtGui/qimage.h>
-#include <QtGui/qwindowdefs.h>
-#include <QtCore/qlist.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QWSEvent;
-class QWSMouseEvent;
-class QWSQCopMessageEvent;
-class QVariant;
-class QLock;
-
-class QWSWindowInfo
-{
-
-public:
-
- int winid;
- unsigned int clientid;
- QString name;
-
-};
-
-#define QT_QWS_PROPERTY_CONVERTSELECTION 999
-#define QT_QWS_PROPERTY_WINDOWNAME 998
-#define QT_QWS_PROPERTY_MARKEDTEXT 997
-
-class QWSDisplay;
-extern Q_GUI_EXPORT QWSDisplay *qt_fbdpy;
-
-class Q_GUI_EXPORT QWSDisplay
-{
-public:
- QWSDisplay();
- ~QWSDisplay();
-
- static QWSDisplay* instance() { return qt_fbdpy; }
-
- bool eventPending() const;
- QWSEvent *getEvent();
-// QWSRegionManager *regionManager() const;
-
- uchar* frameBuffer() const;
- int width() const;
- int height() const;
- int depth() const;
- int pixmapDepth() const;
- bool supportsDepth(int) const;
-
- uchar *sharedRam() const;
- int sharedRamSize() const;
-
-#ifndef QT_NO_QWS_PROPERTIES
- void addProperty(int winId, int property);
- void setProperty(int winId, int property, int mode, const QByteArray &data);
- void setProperty(int winId, int property, int mode, const char * data);
- void removeProperty(int winId, int property);
- bool getProperty(int winId, int property, char *&data, int &len);
-#endif // QT_NO_QWS_PROPERTIES
-
- QList<QWSWindowInfo> windowList();
- int windowAt(const QPoint &);
-
- void setIdentity(const QString &appName);
- void nameRegion(int winId, const QString& n, const QString &c);
- void requestRegion(int winId, const QString &surfacekey,
- const QByteArray &surfaceData,
- const QRegion &region);
- void repaintRegion(int winId, int windowFlags, bool opaque, QRegion);
- void moveRegion(int winId, int dx, int dy);
- void destroyRegion(int winId);
- void requestFocus(int winId, bool get);
- void setAltitude(int winId, int altitude, bool fixed = false);
- void setOpacity(int winId, int opacity);
- int takeId();
- void setSelectionOwner(int winId, const QTime &time);
- void convertSelection(int winId, int selectionProperty, const QString &mimeTypes);
- void defineCursor(int id, const QBitmap &curs, const QBitmap &mask,
- int hotX, int hotY);
- void destroyCursor(int id);
- void selectCursor(QWidget *w, unsigned int id);
- void setCursorPosition(int x, int y);
- void grabMouse(QWidget *w, bool grab);
- void grabKeyboard(QWidget *w, bool grab);
- void playSoundFile(const QString&);
- void registerChannel(const QString &channel);
- void sendMessage(const QString &channel, const QString &msg,
- const QByteArray &data);
- void flushCommands();
-#ifndef QT_NO_QWS_INPUTMETHODS
- void sendIMUpdate(int type, int winId, int widgetid);
- void resetIM();
- void sendIMResponse(int winId, int property, const QVariant &result);
- void sendIMMouseEvent(int index, bool isPress);
-#endif
- QWSQCopMessageEvent* waitForQCopResponse();
- void sendFontCommand(int type, const QByteArray &fontName);
-
- void setWindowCaption(QWidget *w, const QString &);
-
- // Lock display for access only by this process
- static bool initLock(const QString &filename, bool create = false);
- static bool grabbed();
- static void grab();
- static void grab(bool write);
- static void ungrab();
-
- static void setTransformation(int transformation, int screenNo = -1);
- static void setRawMouseEventFilter(void (*filter)(QWSMouseEvent *));
-
-private:
- friend int qt_fork_qapplication();
- friend void qt_app_reinit( const QString& newAppName );
- friend class QApplication;
- friend class QCopChannel;
- friend class QWSEmbedWidget;
- friend class QWSEmbedWidgetPrivate;
- class Data;
- friend class Data;
- Data *d;
-
- friend class QWSMemorySurface;
- friend class QWSOnScreenSurface;
- friend class QWSDirectPainterSurface;
- int getPropertyLen;
- char *getPropertyData;
- static QLock *lock;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QWSDISPLAY_QWS_H
diff --git a/src/gui/embedded/qwsdisplay_qws_p.h b/src/gui/embedded/qwsdisplay_qws_p.h
deleted file mode 100644
index a217a2af7c..0000000000
--- a/src/gui/embedded/qwsdisplay_qws_p.h
+++ /dev/null
@@ -1,161 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWSDISPLAY_QWS_P_H
-#define QWSDISPLAY_QWS_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qwsdisplay_qws.h"
-#include "qwssocket_qws.h"
-#include "qwsevent_qws.h"
-#include <private/qwssharedmemory_p.h>
-#include "qwscommand_qws_p.h"
-#include "qwslock_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QWSDisplay::Data
-{
-public:
- Data(QObject* parent, bool singleProcess = false);
- ~Data();
-
- void flush();
-
- bool queueNotEmpty();
- QWSEvent *dequeue();
- QWSEvent *peek();
-
- bool directServerConnection();
- void fillQueue();
-#ifndef QT_NO_QWS_MULTIPROCESS
- void connectToPipe();
- void waitForConnection();
- void waitForPropertyReply();
- void waitForRegionAck(int winId);
- void waitForRegionEvents(int winId, bool ungrabDisplay);
- bool hasPendingRegionEvents() const;
-#endif
- void waitForCreation();
-#ifndef QT_NO_COP
- void waitForQCopResponse();
-#endif
- void init();
- void reinit( const QString& newAppName );
- void create(int n = 1);
-
- void flushCommands();
- void sendCommand(QWSCommand & cmd);
- void sendSynchronousCommand(QWSCommand & cmd);
-
- QWSEvent *readMore();
-
- int takeId();
-
- void setMouseFilter(void (*filter)(QWSMouseEvent*));
-
- //####public data members
-
-// QWSRegionManager *rgnMan;
- uchar *sharedRam;
-#ifndef QT_NO_QWS_MULTIPROCESS
- QWSSharedMemory shm;
-#endif
- int sharedRamSize;
-
-#ifndef QT_NO_QWS_MULTIPROCESS
- static QWSLock *clientLock;
-
- static bool lockClient(QWSLock::LockType, int timeout = -1);
- static void unlockClient(QWSLock::LockType);
- static bool waitClient(QWSLock::LockType, int timeout = -1);
- static QWSLock* getClientLock();
-#endif // QT_NO_QWS_MULTIPROCESS
-
-private:
-#ifndef QT_NO_QWS_MULTIPROCESS
- QWSSocket *csocket;
-#endif
- QList<QWSEvent*> queue;
-
-#if 0
- void debugQueue() {
- for (int i = 0; i < queue.size(); ++i) {
- QWSEvent *e = queue.at(i);
- qDebug( " ev %d type %d sl %d rl %d", i, e->type, e->simpleLen, e->rawLen);
- }
- }
-#endif
-
- QWSConnectedEvent* connected_event;
- QWSMouseEvent* mouse_event;
- int region_events_count;
- int mouse_state;
- int mouse_winid;
- QPoint region_offset;
- int region_offset_window;
-#ifndef QT_NO_COP
- QWSQCopMessageEvent *qcop_response;
-#endif
- QWSEvent* current_event;
- QList<int> unused_identifiers;
-#ifdef QAPPLICATION_EXTRA_DEBUG
- int mouse_event_count;
-#endif
- void (*mouseFilter)(QWSMouseEvent *);
-
- enum { VariableEvent=-1 };
-
-};
-
-QT_END_NAMESPACE
-
-#endif // QWSDISPLAY_QWS_P_H
diff --git a/src/gui/embedded/qwsembedwidget.cpp b/src/gui/embedded/qwsembedwidget.cpp
deleted file mode 100644
index 9005ea4400..0000000000
--- a/src/gui/embedded/qwsembedwidget.cpp
+++ /dev/null
@@ -1,227 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwsembedwidget.h"
-
-#ifndef QT_NO_QWSEMBEDWIDGET
-
-#include <qwsdisplay_qws.h>
-#include <private/qwidget_p.h>
-#include <private/qwsdisplay_qws_p.h>
-#include <private/qwscommand_qws_p.h>
-
-QT_BEGIN_NAMESPACE
-
-// TODO:
-// Must remove window decorations from the embedded window
-// Focus In/Out, Keyboard/Mouse...
-//
-// BUG: what if my parent change parent?
-
-class QWSEmbedWidgetPrivate : public QWidgetPrivate
-{
- Q_DECLARE_PUBLIC(QWSEmbedWidget);
-
-public:
- QWSEmbedWidgetPrivate(int winId);
- void updateWindow();
- void resize(const QSize &size);
-
- QWidget *window;
- WId windowId;
- WId embeddedId;
-};
-
-QWSEmbedWidgetPrivate::QWSEmbedWidgetPrivate(int winId)
- : window(0), windowId(0), embeddedId(winId)
-{
-}
-
-void QWSEmbedWidgetPrivate::updateWindow()
-{
- Q_Q(QWSEmbedWidget);
-
- QWidget *win = q->window();
- if (win == window)
- return;
-
- if (window) {
- window->removeEventFilter(q);
- QWSEmbedCommand command;
- command.setData(windowId, embeddedId, QWSEmbedEvent::StopEmbed);
- QWSDisplay::instance()->d->sendCommand(command);
- }
-
- window = win;
- if (!window)
- return;
- windowId = window->winId();
-
- QWSEmbedCommand command;
- command.setData(windowId, embeddedId, QWSEmbedEvent::StartEmbed);
- QWSDisplay::instance()->d->sendCommand(command);
- window->installEventFilter(q);
- q->installEventFilter(q);
-}
-
-void QWSEmbedWidgetPrivate::resize(const QSize &size)
-{
- if (!window)
- return;
-
- Q_Q(QWSEmbedWidget);
-
- QWSEmbedCommand command;
- command.setData(windowId, embeddedId, QWSEmbedEvent::Region,
- QRect(q->mapToGlobal(QPoint(0, 0)), size));
- QWSDisplay::instance()->d->sendCommand(command);
-}
-
-/*!
- \class QWSEmbedWidget
- \since 4.2
- \ingroup qws
- \ingroup advanced
-
- \brief The QWSEmbedWidget class enables embedded top-level widgets
- in Qt for Embedded Linux.
-
- Note that this class is only available in \l{Qt for Embedded Linux}.
-
- QWSEmbedWidget inherits QWidget and acts as any other widget, but
- in addition it is capable of embedding another top-level widget.
-
- An example of use is when painting directly onto the screen using
- the QDirectPainter class. Then the reserved region can be embedded
- into an instance of the QWSEmbedWidget class, providing for
- example event handling and size policies for the reserved region.
-
- All that is required to embed a top-level widget is its window ID.
-
- \sa {Qt for Embedded Linux Architecture}
-*/
-
-/*!
- Constructs a widget with the given \a parent, embedding the widget
- identified by the given window \a id.
-*/
-QWSEmbedWidget::QWSEmbedWidget(WId id, QWidget *parent)
- : QWidget(*new QWSEmbedWidgetPrivate(id), parent, 0)
-{
- Q_D(QWSEmbedWidget);
- d->updateWindow();
-}
-
-/*!
- Destroys this widget.
-*/
-QWSEmbedWidget::~QWSEmbedWidget()
-{
- Q_D(QWSEmbedWidget);
- if (!d->window)
- return;
-
- QWSEmbedCommand command;
- command.setData(d->windowId, d->embeddedId, QWSEmbedEvent::StopEmbed);
- QWSDisplay::instance()->d->sendCommand(command);
-}
-
-/*!
- \reimp
-*/
-bool QWSEmbedWidget::eventFilter(QObject *object, QEvent *event)
-{
- Q_D(QWSEmbedWidget);
- if (object == d->window && event->type() == QEvent::Move)
- resizeEvent(0);
- else if (object == this && event->type() == QEvent::Hide)
- d->resize(QSize());
- return QWidget::eventFilter(object, event);
-}
-
-/*!
- \reimp
-*/
-void QWSEmbedWidget::changeEvent(QEvent *event)
-{
- Q_D(QWSEmbedWidget);
- if (event->type() == QEvent::ParentChange)
- d->updateWindow();
-}
-
-/*!
- \reimp
-*/
-void QWSEmbedWidget::resizeEvent(QResizeEvent*)
-{
- Q_D(QWSEmbedWidget);
- d->resize(rect().size());
-}
-
-/*!
- \reimp
-*/
-void QWSEmbedWidget::moveEvent(QMoveEvent*)
-{
- resizeEvent(0);
-}
-
-/*!
- \reimp
-*/
-void QWSEmbedWidget::hideEvent(QHideEvent*)
-{
- Q_D(QWSEmbedWidget);
- d->resize(QSize());
-}
-
-/*!
- \reimp
-*/
-void QWSEmbedWidget::showEvent(QShowEvent*)
-{
- Q_D(QWSEmbedWidget);
- d->resize(rect().size());
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWSEMBEDWIDGET
diff --git a/src/gui/embedded/qwsembedwidget.h b/src/gui/embedded/qwsembedwidget.h
deleted file mode 100644
index 50237a6963..0000000000
--- a/src/gui/embedded/qwsembedwidget.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWSEMBEDWIDGET_H
-#define QWSEMBEDWIDGET_H
-
-#include <QtGui/qwidget.h>
-
-#ifndef QT_NO_QWSEMBEDWIDGET
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QWSEmbedWidgetPrivate;
-
-class Q_GUI_EXPORT QWSEmbedWidget : public QWidget
-{
- Q_OBJECT
-
-public:
- QWSEmbedWidget(WId winId, QWidget *parent = 0);
- ~QWSEmbedWidget();
-
-protected:
- bool eventFilter(QObject *object, QEvent *event);
- void changeEvent(QEvent *event);
- void resizeEvent(QResizeEvent *event);
- void moveEvent(QMoveEvent *event);
- void hideEvent(QHideEvent *event);
- void showEvent(QShowEvent *event);
-
-private:
- Q_DECLARE_PRIVATE(QWSEmbedWidget)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_QWSEMBEDWIDGET
-#endif // QWSEMBEDWIDGET_H
diff --git a/src/gui/embedded/qwsevent_qws.cpp b/src/gui/embedded/qwsevent_qws.cpp
deleted file mode 100644
index bcecafed40..0000000000
--- a/src/gui/embedded/qwsevent_qws.cpp
+++ /dev/null
@@ -1,216 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwsevent_qws.h"
-
-QT_BEGIN_NAMESPACE
-
-QWSEvent *QWSEvent::factory(int type)
-{
- QWSEvent *event = 0;
- switch (type) {
- case QWSEvent::Connected:
- event = new QWSConnectedEvent;
- break;
- case QWSEvent::MaxWindowRect:
- event = new QWSMaxWindowRectEvent;
- break;
- case QWSEvent::Mouse:
- event = new QWSMouseEvent;
- break;
- case QWSEvent::Focus:
- event = new QWSFocusEvent;
- break;
- case QWSEvent::Key:
- event = new QWSKeyEvent;
- break;
- case QWSEvent::Region:
- event = new QWSRegionEvent;
- break;
- case QWSEvent::Creation:
- event = new QWSCreationEvent;
- break;
-#ifndef QT_NO_QWS_PROPERTIES
- case QWSEvent::PropertyNotify:
- event = new QWSPropertyNotifyEvent;
- break;
- case QWSEvent::PropertyReply:
- event = new QWSPropertyReplyEvent;
- break;
-#endif // QT_NO_QWS_PROPERTIES
- case QWSEvent::SelectionClear:
- event = new QWSSelectionClearEvent;
- break;
- case QWSEvent::SelectionRequest:
- event = new QWSSelectionRequestEvent;
- break;
- case QWSEvent::SelectionNotify:
- event = new QWSSelectionNotifyEvent;
- break;
-#ifndef QT_NO_COP
- case QWSEvent::QCopMessage:
- event = new QWSQCopMessageEvent;
- break;
-#endif
- case QWSEvent::WindowOperation:
- event = new QWSWindowOperationEvent;
- break;
-
-#ifndef QT_NO_QWS_INPUTMETHODS
- case QWSEvent::IMEvent:
- event = new QWSIMEvent;
- break;
- case QWSEvent::IMQuery:
- event = new QWSIMQueryEvent;
- break;
- case QWSEvent::IMInit:
- event = new QWSIMInitEvent;
- break;
-#endif
-#ifndef QT_NO_QWSEMBEDWIDGET
- case QWSEvent::Embed:
- event = new QWSEmbedEvent;
- break;
-#endif
- case QWSEvent::Font:
- event = new QWSFontEvent;
- break;
- case QWSEvent::ScreenTransformation:
- event = new QWSScreenTransformationEvent;
- break;
- default:
- qCritical("QWSEvent::factory() : Unknown event type %08x!", type);
- }
- return event;
-}
-
-/*!
- \class QWSEvent
- \ingroup qws
-
- \brief The QWSEvent class encapsulates an event in Qt for Embedded Linux.
-
- When running a \l{Qt for Embedded Linux} application, it either runs as a
- server or connects to an existing server. All system generated
- events are passed to the server application which then propagates
- the event to the appropriate client.
-
- Whenever the server receives an event, it queries its stack of
- top-level windows to find the window containing the event's
- position. Each window can identify the client application that
- created it, and returns its ID to the server upon
- request. Finally, the server forwards the event, encapsulated by
- an instance of the QWSEvent class, to the appropriate client.
-
- \image qt-embedded-client.png
-
- The server communicates with the client applications over the UNIX
- domain socket. You can retrieve direct access to all the events a
- client receives from the server, by reimplementing QApplication's
- \l {QApplication::}{qwsEventFilter()} function.
-
- QWSEvent provides the \l Type enum specifying the origin of the
- event. Internally, each type is represented by a QWSEvent
- subclass, e.g., \c QWSKeyEvent.
-
- \sa QWSServer, QWSClient, {Qt for Embedded Linux Architecture}
-*/
-
-/*!
- \enum QWSEvent::Type
-
- This enum describes the origin of the event.
-
- \value NoEvent No event has occurred.
- \value Connected An application has connected to the server.
- \value Mouse A mouse button is pressed or released, or the mouse cursor is moved.
- See also \l{Qt for Embedded Linux Pointer Handling}.
- \value Focus A window has lost or received focus.
- \value Key A key is pressed or released. See also \l{Qt for Embedded Linux Character Input}.
- \value Region A region has changed.
- \value Creation The server has created an ID, typically for a window.
- \value PropertyNotify A property has changed.
- \value PropertyReply The server is responding to a request for a property's value.
- \value SelectionClear A selection is deleted.
- \value SelectionRequest The server has queried for a selection.
- \value SelectionNotify A new selection has been created.
- \value MaxWindowRect The server has changed the maximum window for an application.
- \value QCopMessage A new Qt Cop message has appeared. See also QCopChannel
- \value WindowOperation A window operation, e.g. resizing, has occurred.
- \value IMEvent An input method has been used to enter text for languages with
- non-Latin alphabets. See also QWSInputMethod.
- \value IMQuery An input method query for a specified property has occurred.
- See also QWSInputMethod.
- \value NEvent The number of events has changed.
- \value Embed An event used internally to implement embedded windows. See also
- QWSEmbedWidget.
- \value ScreenTransformation An event used internally to notify the client processes
- that the screen has changed for example, rotation, etc.
- \omitvalue Font
- \omitvalue IMInit
-*/
-
-/*!
- \fn QWSMouseEvent *QWSEvent::asMouse()
- \internal
-*/
-
-/*!
- \fn int QWSEvent::window()
- \internal
-*/
-
-/*!
- \fn int QWSEvent::window() const
- \internal
-*/
-
-/*!
- \fn QWSEvent *QWSEvent::factory(int type)
- \internal
-*/
-
-/*!
- \fn QWSEvent::QWSEvent( int t, int len, char * ptr)
- \internal
-*/
-
-QT_END_NAMESPACE
diff --git a/src/gui/embedded/qwsevent_qws.h b/src/gui/embedded/qwsevent_qws.h
deleted file mode 100644
index f439ee5843..0000000000
--- a/src/gui/embedded/qwsevent_qws.h
+++ /dev/null
@@ -1,459 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWSEVENT_QWS_H
-#define QWSEVENT_QWS_H
-
-#include <QtGui/qwsutils_qws.h>
-#include <QtGui/qwsprotocolitem_qws.h>
-#include <QtCore/qrect.h>
-#include <QtGui/qregion.h>
-#include <QtCore/qvector.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-struct QWSMouseEvent;
-
-struct QWSEvent : QWSProtocolItem {
-
- QWSEvent(int t, int len, char *ptr) : QWSProtocolItem(t,len,ptr) {}
-
-
-
- enum Type {
- NoEvent,
- Connected,
- Mouse,
- Focus,
- Key,
- Region,
- Creation,
- PropertyNotify,
- PropertyReply,
- SelectionClear,
- SelectionRequest,
- SelectionNotify,
- MaxWindowRect,
- QCopMessage,
- WindowOperation,
- IMEvent,
- IMQuery,
- IMInit,
- Embed,
- Font,
- ScreenTransformation,
- NEvent
- };
-
- QWSMouseEvent *asMouse()
- { return type == Mouse ? reinterpret_cast<QWSMouseEvent*>(this) : 0; }
- int window() { return *(reinterpret_cast<int*>(simpleDataPtr)); }
- int window() const { return *(reinterpret_cast<int*>(simpleDataPtr)); }
- static QWSEvent *factory(int type);
-};
-
-
-//All events must start with windowID
-
-struct QWSConnectedEvent : QWSEvent {
- QWSConnectedEvent()
- : QWSEvent(QWSEvent::Connected, sizeof(simpleData),
- reinterpret_cast<char*>(&simpleData)) {}
-
- void setData(const char *d, int len, bool allocateMem = true) {
- QWSEvent::setData(d, len, allocateMem);
- display = reinterpret_cast<char*>(rawDataPtr);
- }
-
- struct SimpleData {
- int window;
- int len;
- int clientId;
- int servershmid;
- } simpleData;
-
- char *display;
-};
-
-struct QWSMaxWindowRectEvent : QWSEvent {
- QWSMaxWindowRectEvent()
- : QWSEvent(MaxWindowRect, sizeof(simpleData), reinterpret_cast<char*>(&simpleData)) { }
- struct SimpleData {
- int window;
- QRect rect;
- } simpleData;
-};
-
-struct QWSMouseEvent : QWSEvent {
- QWSMouseEvent()
- : QWSEvent(QWSEvent::Mouse, sizeof(simpleData),
- reinterpret_cast<char*>(&simpleData)) {}
- struct SimpleData {
- int window;
- int x_root, y_root, state, delta;
- int time; // milliseconds
- } simpleData;
-};
-
-struct QWSFocusEvent : QWSEvent {
- QWSFocusEvent()
- : QWSEvent(QWSEvent::Focus, sizeof(simpleData), reinterpret_cast<char*>(&simpleData))
- { memset(reinterpret_cast<char*>(&simpleData),0,sizeof(simpleData)); }
- struct SimpleData {
- int window;
- uint get_focus:1;
- } simpleData;
-};
-
-struct QWSKeyEvent: QWSEvent {
- QWSKeyEvent()
- : QWSEvent(QWSEvent::Key, sizeof(simpleData),
- reinterpret_cast<char*>(&simpleData)) {}
- struct SimpleData {
- int window;
- uint keycode;
- Qt::KeyboardModifiers modifiers;
- ushort unicode;
- uint is_press:1;
- uint is_auto_repeat:1;
- } simpleData;
-};
-
-
-struct QWSCreationEvent : QWSEvent {
- QWSCreationEvent()
- : QWSEvent(QWSEvent::Creation, sizeof(simpleData),
- reinterpret_cast<char*>(&simpleData)) {}
- struct SimpleData {
- int objectid;
- int count;
- } simpleData;
-};
-
-#ifndef QT_NO_QWS_PROPERTIES
-struct QWSPropertyNotifyEvent : QWSEvent {
- QWSPropertyNotifyEvent()
- : QWSEvent(QWSEvent::PropertyNotify, sizeof(simpleData),
- reinterpret_cast<char*>(&simpleData)) {}
- enum State {
- PropertyNewValue,
- PropertyDeleted
- };
- struct SimpleData {
- int window;
- int property;
- int state;
- } simpleData;
-};
-#endif
-
-struct QWSSelectionClearEvent : QWSEvent {
- QWSSelectionClearEvent()
- : QWSEvent(QWSEvent::SelectionClear, sizeof(simpleData),
- reinterpret_cast<char*>(&simpleData)) {}
- struct SimpleData {
- int window;
- } simpleData;
-};
-
-struct QWSSelectionRequestEvent : QWSEvent {
- QWSSelectionRequestEvent()
- : QWSEvent(QWSEvent::SelectionRequest, sizeof(simpleData),
- reinterpret_cast<char*>(&simpleData)) {}
- struct SimpleData {
- int window;
- int requestor; // window which wants the selection
- int property; // property on requestor into which the selection should be stored, normally QWSProperty::PropSelection
- int mimeTypes; // Value is stored in the property mimeType on the requestor window. This value may contain
- // multiple mimeTypes separated by ;; where the order reflects the priority
- } simpleData;
-};
-
-struct QWSSelectionNotifyEvent : QWSEvent {
- QWSSelectionNotifyEvent()
- : QWSEvent(QWSEvent::SelectionNotify, sizeof(simpleData),
- reinterpret_cast<char*>(&simpleData)) {}
- struct SimpleData {
- int window;
- int requestor; // the window which wanted the selection and to which this event is sent
- int property; // property of requestor in which the data of the selection is stored
- int mimeType; // a property on the requestor in which the mime type in which the selection is, is stored
- } simpleData;
-};
-
-//complex events:
-
-struct QWSRegionEvent : QWSEvent {
- QWSRegionEvent()
- : QWSEvent(QWSEvent::Region, sizeof(simpleData),
- reinterpret_cast<char*>(&simpleData))
- { memset(reinterpret_cast<char*>(&simpleData),0,sizeof(simpleData)); }
-
- void setData(const char *d, int len, bool allocateMem = true) {
- QWSEvent::setData(d, len, allocateMem);
- rectangles = reinterpret_cast<QRect*>(rawDataPtr);
- }
-
- void setData(int winId, const QRegion &region, uint type) {
- const QVector<QRect> rects = region.rects();
- setData(reinterpret_cast<const char*>(rects.constData()),
- rects.size() * sizeof(QRect));
- simpleData.window = winId;
- simpleData.nrectangles = rects.size();
- simpleData.type = type;
-#ifdef QT_QWS_CLIENTBLIT
- simpleData.id = 0;
-#endif
- }
-
- enum Type {Allocation
-#ifdef QT_QWS_CLIENTBLIT
- , DirectPaint
-#endif
- };
- struct SimpleData {
- int window;
- int nrectangles;
-#ifdef QT_QWS_CLIENTBLIT
- int id;
-#endif
- uint type:8;
- } simpleData;
-
- QRect *rectangles;
-};
-
-#ifndef QT_NO_QWSEMBEDWIDGET
-struct QWSEmbedEvent : QWSEvent
-{
- QWSEmbedEvent() : QWSEvent(QWSEvent::Embed, sizeof(simpleData),
- reinterpret_cast<char*>(&simpleData))
- {}
-
- enum Type { StartEmbed = 1, StopEmbed = 2, Region = 4 };
-
- void setData(const char *d, int len, bool allocateMem = true) {
- QWSEvent::setData(d, len, allocateMem);
- region.setRects(reinterpret_cast<const QRect *>(rawDataPtr),
- simpleData.nrectangles);
- }
-
- void setData(int winId, Type type, const QRegion &reg = QRegion()) {
- simpleData.window = winId;
- simpleData.nrectangles = reg.rects().size();
- simpleData.type = type;
- region = reg;
- const QVector<QRect> rects = reg.rects();
- QWSEvent::setData(reinterpret_cast<const char*>(rects.data()),
- rects.size() * sizeof(QRect));
- }
-
- struct SimpleData {
- int window;
- int nrectangles;
- Type type;
- } simpleData;
-
- QRegion region;
-};
-#endif // QT_NO_QWSEMBEDWIDGET
-
-#ifndef QT_NO_QWS_PROPERTIES
-struct QWSPropertyReplyEvent : QWSEvent {
- QWSPropertyReplyEvent()
- : QWSEvent(QWSEvent::PropertyReply, sizeof(simpleData),
- reinterpret_cast<char*>(&simpleData)) {}
-
- void setData(const char *d, int len, bool allocateMem = true) {
- QWSEvent::setData(d, len, allocateMem);
- data = reinterpret_cast<char*>(rawDataPtr);
- }
-
- struct SimpleData {
- int window;
- int property;
- int len;
- } simpleData;
- char *data;
-};
-#endif //QT_NO_QWS_PROPERTIES
-
-#ifndef QT_NO_COP
-struct QWSQCopMessageEvent : QWSEvent {
- QWSQCopMessageEvent()
- : QWSEvent(QWSEvent::QCopMessage, sizeof(simpleData),
- reinterpret_cast<char*>(&simpleData))
- { memset(reinterpret_cast<char*>(&simpleData),0,sizeof(simpleData)); }
-
- void setData(const char *d, int len, bool allocateMem = true) {
- QWSEvent::setData(d, len, allocateMem);
- char* p = rawDataPtr;
- channel = QByteArray(p, simpleData.lchannel);
- p += simpleData.lchannel;
- message = QByteArray(p, simpleData.lmessage);
- p += simpleData.lmessage;
- data = QByteArray(p, simpleData.ldata);
- }
-
- void setDataDirect(const char *d, int len) {
- QWSEvent::setData(d, len, false);
- deleteRaw = true;
- }
-
- struct SimpleData {
- bool is_response;
- int lchannel;
- int lmessage;
- int ldata;
- } simpleData;
-
- QByteArray channel;
- QByteArray message;
- QByteArray data;
-};
-
-#endif
-
-struct QWSWindowOperationEvent : QWSEvent {
- QWSWindowOperationEvent()
- : QWSEvent(WindowOperation, sizeof(simpleData), reinterpret_cast<char*>(&simpleData)) { }
-
- enum Operation { Show, Hide, ShowMaximized, ShowNormal, ShowMinimized, Close };
- struct SimpleData {
- int window;
- Operation op;
- } simpleData;
-};
-
-#ifndef QT_NO_QWS_INPUTMETHODS
-
-
-struct QWSIMEvent : QWSEvent {
- QWSIMEvent()
- : QWSEvent(IMEvent, sizeof(simpleData), reinterpret_cast<char*>(&simpleData))
- { memset(reinterpret_cast<char*>(&simpleData),0,sizeof(simpleData)); }
-
- struct SimpleData {
- int window;
- int replaceFrom;
- int replaceLength;
- } simpleData;
-
- void setData(const char *d, int len, bool allocateMem = true) {
- QWSEvent::setData(d, len, allocateMem);
- streamingData = QByteArray::fromRawData(rawDataPtr, len);
- }
- QByteArray streamingData;
-};
-
-
-struct QWSIMInitEvent : QWSEvent {
- QWSIMInitEvent()
- : QWSEvent(IMInit, sizeof(simpleData), reinterpret_cast<char*>(&simpleData))
- { memset(reinterpret_cast<char*>(&simpleData),0,sizeof(simpleData)); }
-
- struct SimpleData {
- int window;
- int existence;
- } simpleData;
-
- void setData(const char *d, int len, bool allocateMem = true) {
- QWSEvent::setData(d, len, allocateMem);
- streamingData = QByteArray::fromRawData(rawDataPtr, len);
- }
- QByteArray streamingData;
-};
-
-
-struct QWSIMQueryEvent : QWSEvent {
- QWSIMQueryEvent()
- : QWSEvent(QWSEvent::IMQuery, sizeof(simpleData),
- reinterpret_cast<char*>(&simpleData)) {}
-
- struct SimpleData {
- int window;
- int property;
- } simpleData;
-
-};
-
-#endif
-
-struct QWSFontEvent : QWSEvent {
- QWSFontEvent()
- : QWSEvent(QWSEvent::Font, sizeof(simpleData),
- reinterpret_cast<char*>(&simpleData)) {}
-
- enum EventType {
- FontRemoved
- };
-
- void setData(const char *d, int len, bool allocateMem = true) {
- QWSEvent::setData(d, len, allocateMem);
- fontName = QByteArray::fromRawData(rawDataPtr, len);
- }
-
- struct SimpleData {
- uchar type;
- } simpleData;
- QByteArray fontName;
-};
-
-struct QWSScreenTransformationEvent : QWSEvent {
- QWSScreenTransformationEvent()
- : QWSEvent(QWSEvent::ScreenTransformation, sizeof(simpleData),
- reinterpret_cast<char*>(&simpleData)) {}
-
- struct SimpleData {
- int screen;
- int transformation;
- } simpleData;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QWSEVENT_QWS_H
diff --git a/src/gui/embedded/qwslock.cpp b/src/gui/embedded/qwslock.cpp
deleted file mode 100644
index 324d81362d..0000000000
--- a/src/gui/embedded/qwslock.cpp
+++ /dev/null
@@ -1,236 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwslock_p.h"
-
-#ifndef QT_NO_QWS_MULTIPROCESS
-
-#include "qwssignalhandler_p.h"
-
-#include <qglobal.h>
-#include <qdebug.h>
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/ipc.h>
-#include <sys/sem.h>
-#include <sys/time.h>
-#include <time.h>
-#ifdef Q_OS_LINUX
-#include <linux/version.h>
-#endif
-#include <unistd.h>
-
-#include <private/qcore_unix_p.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifdef QT_NO_SEMAPHORE
-#error QWSLock currently requires semaphores
-#endif
-
-QWSLock::QWSLock()
-{
- semId = semget(IPC_PRIVATE, 3, IPC_CREAT | 0666);
-
- if (semId == -1) {
- perror("QWSLock::QWSLock");
- qFatal("Unable to create semaphore");
- }
- QWSSignalHandler::instance()->addSemaphore(semId);
-
- qt_semun semval;
- semval.val = 1;
-
- if (semctl(semId, BackingStore, SETVAL, semval) == -1) {
- perror("QWSLock::QWSLock");
- qFatal("Unable to initialize backingstore semaphore");
- }
- lockCount[BackingStore] = 0;
-
- if (semctl(semId, Communication, SETVAL, semval) == -1) {
- perror("QWSLock::QWSLock");
- qFatal("Unable to initialize communication semaphore");
- }
- lockCount[Communication] = 0;
-
- semval.val = 0;
- if (semctl(semId, RegionEvent, SETVAL, semval) == -1) {
- perror("QWSLock::QWSLock");
- qFatal("Unable to initialize region event semaphore");
- }
-}
-
-QWSLock::QWSLock(int id)
-{
- semId = id;
- QWSSignalHandler::instance()->addSemaphore(semId);
- lockCount[0] = lockCount[1] = 0;
-}
-
-QWSLock::~QWSLock()
-{
- if (semId == -1)
- return;
- QWSSignalHandler::instance()->removeSemaphore(semId);
-}
-
-static bool forceLock(int semId, int semNum, int)
-{
- int ret;
- do {
- sembuf sops = { semNum, -1, 0 };
-
- // As the BackingStore lock is a mutex, and only one process may own
- // the lock, it's safe to use SEM_UNDO. On the other hand, the
- // Communication lock is locked by the client but unlocked by the
- // server and therefore can't use SEM_UNDO.
- if (semNum == QWSLock::BackingStore)
- sops.sem_flg |= SEM_UNDO;
-
- ret = semop(semId, &sops, 1);
- if (ret == -1 && errno != EINTR)
- qDebug("QWSLock::lock: %s", strerror(errno));
- } while (ret == -1 && errno == EINTR);
-
- return (ret != -1);
-}
-
-static bool up(int semId, int semNum)
-{
- int ret;
- do {
- sembuf sops = { semNum, 1, 0 };
- ret = semop(semId, &sops, 1);
- if (ret == -1 && errno != EINTR)
- qDebug("QWSLock::up: %s", strerror(errno));
- } while (ret == -1 && errno == EINTR);
-
- return (ret != -1);
-}
-
-static bool down(int semId, int semNum)
-{
- int ret;
- do {
- sembuf sops = { semNum, -1, 0 };
- ret = semop(semId, &sops, 1);
- if (ret == -1 && errno != EINTR)
- qDebug("QWSLock::down: %s", strerror(errno));
- } while (ret == -1 && errno == EINTR);
-
- return (ret != -1);
-}
-
-static int getValue(int semId, int semNum)
-{
- int ret;
- do {
- ret = semctl(semId, semNum, GETVAL, 0);
- if (ret == -1 && errno != EINTR)
- qDebug("QWSLock::getValue: %s", strerror(errno));
- } while (ret == -1 && errno == EINTR);
-
- return ret;
-}
-
-bool QWSLock::lock(LockType type, int timeout)
-{
- if (type == RegionEvent)
- return up(semId, RegionEvent);
-
- if (hasLock(type)) {
- ++lockCount[type];
- return true;
- }
-
- if (!forceLock(semId, type, timeout))
- return false;
- ++lockCount[type];
- return true;
-}
-
-bool QWSLock::hasLock(LockType type)
-{
- if (type == RegionEvent)
- return (getValue(semId, RegionEvent) == 0);
-
- return (lockCount[type] > 0);
-}
-
-void QWSLock::unlock(LockType type)
-{
- if (type == RegionEvent) {
- down(semId, RegionEvent);
- return;
- }
-
- if (hasLock(type)) {
- --lockCount[type];
- if (hasLock(type))
- return;
- }
-
- const int semNum = type;
- int ret;
- do {
- sembuf sops = {semNum, 1, 0};
- if (semNum == QWSLock::BackingStore)
- sops.sem_flg |= SEM_UNDO;
-
- ret = semop(semId, &sops, 1);
- if (ret == -1 && errno != EINTR)
- qDebug("QWSLock::unlock: %s", strerror(errno));
- } while (ret == -1 && errno == EINTR);
-}
-
-bool QWSLock::wait(LockType type, int timeout)
-{
- bool ok = forceLock(semId, type, timeout);
- if (ok)
- unlock(type);
- return ok;
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_MULTIPROCESS
diff --git a/src/gui/embedded/qwslock_p.h b/src/gui/embedded/qwslock_p.h
deleted file mode 100644
index 397053776a..0000000000
--- a/src/gui/embedded/qwslock_p.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWSLOCK_P_H
-#define QWSLOCK_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. This header file may
-// change from version to version without notice, or even be
-// removed.
-//
-// We mean it.
-//
-
-#include <qglobal.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_QWS_MULTIPROCESS
-
-class QWSLock
-{
-public:
- enum LockType { BackingStore, Communication, RegionEvent };
-
- QWSLock();
- QWSLock(int lockId);
- ~QWSLock();
-
- bool lock(LockType type, int timeout = -1);
- void unlock(LockType type);
- bool wait(LockType type, int timeout = -1);
- bool hasLock(LockType type);
- int id() const { return semId; }
-
-private:
- int semId;
- int lockCount[2];
-};
-
-
-QT_END_NAMESPACE
-#endif // QT_NO_QWS_MULTIPROCESS
-#endif // QWSLOCK_P_H
diff --git a/src/gui/embedded/qwsmanager_p.h b/src/gui/embedded/qwsmanager_p.h
deleted file mode 100644
index e5db3ef4b2..0000000000
--- a/src/gui/embedded/qwsmanager_p.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWSMANAGER_P_H
-#define QWSMANAGER_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QLibrary class. This header file may change from
-// version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "QtGui/qregion.h"
-#include "QtGui/qdecoration_qws.h"
-
-#ifndef QT_NO_QWS_MANAGER
-
-#include "QtCore/qhash.h"
-
-QT_BEGIN_NAMESPACE
-
-class QWidget;
-class QMenu;
-
-class QWSManagerPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QWSManager)
-public:
- QWSManagerPrivate();
-
- int activeRegion;
- QWidget *managed;
- QMenu *popup;
-
- enum MenuAction {
- NormalizeAction,
- TitleAction,
- BottomRightAction,
- MinimizeAction,
- MaximizeAction,
- CloseAction,
- LastMenuAction
- };
- QAction *menuActions[LastMenuAction];
-
- static QWidget *active;
- static QPoint mousePos;
-
- // Region caching to avoid getting a regiontype's
- // QRegion for each mouse move event
- int previousRegionType;
- bool previousRegionRepainted; // Hover/Press handled
- bool entireDecorationNeedsRepaint;
- struct RegionCaching {
- int regionType;
- QRegion region;
- Qt::WindowFlags windowFlags;
- QRect windowGeometry;
- } cached_region;
-
- bool newCachedRegion(const QPoint &pos);
- int cachedRegionAt()
- { return cached_region.regionType; }
-
- void dirtyRegion(int decorationRegion,
- QDecoration::DecorationState state,
- const QRegion &clip = QRegion());
- void clearDirtyRegions();
-
- QList<int> dirtyRegions;
- QList<QDecoration::DecorationState> dirtyStates;
- QRegion dirtyClip;
-};
-
-#endif // QT_NO_QWS_MANAGER
-
-QT_END_NAMESPACE
-
-#endif // QWSMANAGER_P_H
diff --git a/src/gui/embedded/qwsmanager_qws.cpp b/src/gui/embedded/qwsmanager_qws.cpp
deleted file mode 100644
index 5b5695264b..0000000000
--- a/src/gui/embedded/qwsmanager_qws.cpp
+++ /dev/null
@@ -1,537 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwsmanager_qws.h"
-
-#ifndef QT_NO_QWS_MANAGER
-
-#include "qdrawutil.h"
-#include "qapplication.h"
-#include "qstyle.h"
-#include "qwidget.h"
-#include "qmenu.h"
-#include "qpainter.h"
-#include "private/qpainter_p.h"
-#include "qregion.h"
-#include "qevent.h"
-#include "qcursor.h"
-#include "qwsdisplay_qws.h"
-#include "qdesktopwidget.h"
-
-#include <private/qapplication_p.h>
-#include <private/qwidget_p.h>
-#include <private/qbackingstore_p.h>
-#include <private/qwindowsurface_qws_p.h>
-#include "qdecorationfactory_qws.h"
-
-#include "qlayout.h"
-
-#include "qwsmanager_p.h"
-
-#include <qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-QWidget *QWSManagerPrivate::active = 0;
-QPoint QWSManagerPrivate::mousePos;
-
-
-QWSManagerPrivate::QWSManagerPrivate()
- : QObjectPrivate(), activeRegion(QDecoration::None), managed(0), popup(0),
- previousRegionType(0), previousRegionRepainted(false), entireDecorationNeedsRepaint(false)
-{
- cached_region.regionType = 0;
-}
-
-QRegion &QWSManager::cachedRegion()
-{
- return d_func()->cached_region.region;
-}
-
-/*!
- \class QWSManager
- \ingroup qws
- \internal
-*/
-
-/*!
-
-*/
-QWSManager::QWSManager(QWidget *w)
- : QObject(*new QWSManagerPrivate, (QObject*)0)
-{
- d_func()->managed = w;
-
-}
-
-QWSManager::~QWSManager()
-{
- Q_D(QWSManager);
-#ifndef QT_NO_MENU
- if (d->popup)
- delete d->popup;
-#endif
- if (d->managed == QWSManagerPrivate::active)
- QWSManagerPrivate::active = 0;
-}
-
-QWidget *QWSManager::widget()
-{
- Q_D(QWSManager);
- return d->managed;
-}
-
-QWidget *QWSManager::grabbedMouse()
-{
- return QWSManagerPrivate::active;
-}
-
-QRegion QWSManager::region()
-{
- Q_D(QWSManager);
- return QApplication::qwsDecoration().region(d->managed, d->managed->geometry());
-}
-
-bool QWSManager::event(QEvent *e)
-{
- if (QObject::event(e))
- return true;
-
- switch (e->type()) {
- case QEvent::MouseMove:
- mouseMoveEvent((QMouseEvent*)e);
- break;
-
- case QEvent::MouseButtonPress:
- mousePressEvent((QMouseEvent*)e);
- break;
-
- case QEvent::MouseButtonRelease:
- mouseReleaseEvent((QMouseEvent*)e);
- break;
-
- case QEvent::MouseButtonDblClick:
- mouseDoubleClickEvent((QMouseEvent*)e);
- break;
-
- case QEvent::Paint:
- paintEvent((QPaintEvent*)e);
- break;
-
- default:
- return false;
- break;
- }
-
- return true;
-}
-
-void QWSManager::mousePressEvent(QMouseEvent *e)
-{
- Q_D(QWSManager);
- d->mousePos = e->globalPos();
- d->activeRegion = QApplication::qwsDecoration().regionAt(d->managed, d->mousePos);
- if(d->cached_region.regionType)
- d->previousRegionRepainted |= repaintRegion(d->cached_region.regionType, QDecoration::Pressed);
-
- if (d->activeRegion == QDecoration::Menu) {
- QPoint pos = (QApplication::layoutDirection() == Qt::LeftToRight
- ? d->managed->geometry().topLeft()
- : d->managed->geometry().topRight());
- menu(pos);
- }
- if (d->activeRegion != QDecoration::None &&
- d->activeRegion != QDecoration::Menu) {
- d->active = d->managed;
- d->managed->grabMouse();
- }
- if (d->activeRegion != QDecoration::None &&
- d->activeRegion != QDecoration::Close &&
- d->activeRegion != QDecoration::Minimize &&
- d->activeRegion != QDecoration::Menu) {
- d->managed->raise();
- }
-
- if (e->button() == Qt::RightButton) {
- menu(e->globalPos());
- }
-}
-
-void QWSManager::mouseReleaseEvent(QMouseEvent *e)
-{
- Q_D(QWSManager);
- d->managed->releaseMouse();
- if (d->cached_region.regionType && d->previousRegionRepainted && QApplication::mouseButtons() == 0) {
- bool doesHover = repaintRegion(d->cached_region.regionType, QDecoration::Hover);
- if (!doesHover) {
- repaintRegion(d->cached_region.regionType, QDecoration::Normal);
- d->previousRegionRepainted = false;
- }
- }
-
- if (e->button() == Qt::LeftButton) {
- //handleMove();
- int itm = QApplication::qwsDecoration().regionAt(d->managed, e->globalPos());
- int activatedItem = d->activeRegion;
- d->activeRegion = QDecoration::None;
- d->active = 0;
- if (activatedItem == itm)
- QApplication::qwsDecoration().regionClicked(d->managed, itm);
- } else if (d->activeRegion == QDecoration::None) {
- d->active = 0;
- }
-}
-
-void QWSManager::mouseDoubleClickEvent(QMouseEvent *e)
-{
- Q_D(QWSManager);
- if (e->button() == Qt::LeftButton)
- QApplication::qwsDecoration().regionDoubleClicked(d->managed,
- QApplication::qwsDecoration().regionAt(d->managed, e->globalPos()));
-}
-
-static inline Qt::CursorShape regionToShape(int region)
-{
- if (region == QDecoration::None)
- return Qt::ArrowCursor;
-
- static const struct {
- int region;
- Qt::CursorShape shape;
- } r2s[] = {
- { QDecoration::TopLeft, Qt::SizeFDiagCursor },
- { QDecoration::Top, Qt::SizeVerCursor},
- { QDecoration::TopRight, Qt::SizeBDiagCursor},
- { QDecoration::Left, Qt::SizeHorCursor},
- { QDecoration::Right, Qt::SizeHorCursor},
- { QDecoration::BottomLeft, Qt::SizeBDiagCursor},
- { QDecoration::Bottom, Qt::SizeVerCursor},
- { QDecoration::BottomRight, Qt::SizeFDiagCursor},
- { QDecoration::None, Qt::ArrowCursor}
- };
-
- int i = 0;
- while (region != r2s[i].region && r2s[i].region)
- ++i;
- return r2s[i].shape;
-}
-
-void QWSManager::mouseMoveEvent(QMouseEvent *e)
-{
- Q_D(QWSManager);
- if (d->newCachedRegion(e->globalPos())) {
- if(d->previousRegionType && d->previousRegionRepainted)
- repaintRegion(d->previousRegionType, QDecoration::Normal);
- if(d->cached_region.regionType) {
- d->previousRegionRepainted = repaintRegion(d->cached_region.regionType, QDecoration::Hover);
- }
- }
-
-
-#ifndef QT_NO_CURSOR
- if (d->managed->minimumSize() != d->managed->maximumSize()) {
- QWSDisplay *qwsd = QApplication::desktop()->qwsDisplay();
- qwsd->selectCursor(d->managed, regionToShape(d->cachedRegionAt()));
- }
-#endif //QT_NO_CURSOR
-
- if (d->activeRegion)
- handleMove(e->globalPos());
-}
-
-void QWSManager::handleMove(QPoint g)
-{
- Q_D(QWSManager);
-
- // don't allow dragging to where the user probably cannot click!
- QApplicationPrivate *ap = QApplicationPrivate::instance();
- const QRect maxWindowRect = ap->maxWindowRect(qt_screen);
- if (maxWindowRect.isValid()) {
- if (g.x() < maxWindowRect.x())
- g.setX(maxWindowRect.x());
- if (g.y() < maxWindowRect.y())
- g.setY(maxWindowRect.y());
- if (g.x() > maxWindowRect.right())
- g.setX(maxWindowRect.right());
- if (g.y() > maxWindowRect.bottom())
- g.setY(maxWindowRect.bottom());
- }
-
- if (g == d->mousePos)
- return;
-
- if ( d->managed->isMaximized() )
- return;
-
- int x = d->managed->geometry().x();
- int y = d->managed->geometry().y();
- int w = d->managed->width();
- int h = d->managed->height();
-
- QRect geom(d->managed->geometry());
-
- QPoint delta = g - d->mousePos;
- d->mousePos = g;
-
- if (d->activeRegion == QDecoration::Title) {
- geom = QRect(x + delta.x(), y + delta.y(), w, h);
- } else {
- bool keepTop = true;
- bool keepLeft = true;
- switch (d->activeRegion) {
- case QDecoration::Top:
- geom.setTop(geom.top() + delta.y());
- keepTop = false;
- break;
- case QDecoration::Bottom:
- geom.setBottom(geom.bottom() + delta.y());
- keepTop = true;
- break;
- case QDecoration::Left:
- geom.setLeft(geom.left() + delta.x());
- keepLeft = false;
- break;
- case QDecoration::Right:
- geom.setRight(geom.right() + delta.x());
- keepLeft = true;
- break;
- case QDecoration::TopRight:
- geom.setTopRight(geom.topRight() + delta);
- keepLeft = true;
- keepTop = false;
- break;
- case QDecoration::TopLeft:
- geom.setTopLeft(geom.topLeft() + delta);
- keepLeft = false;
- keepTop = false;
- break;
- case QDecoration::BottomLeft:
- geom.setBottomLeft(geom.bottomLeft() + delta);
- keepLeft = false;
- keepTop = true;
- break;
- case QDecoration::BottomRight:
- geom.setBottomRight(geom.bottomRight() + delta);
- keepLeft = true;
- keepTop = true;
- break;
- default:
- return;
- }
-
- QSize newSize = QLayout::closestAcceptableSize(d->managed, geom.size());
-
- int dx = newSize.width() - geom.width();
- int dy = newSize.height() - geom.height();
-
- if (keepTop) {
- geom.setBottom(geom.bottom() + dy);
- d->mousePos.ry() += dy;
- } else {
- geom.setTop(geom.top() - dy);
- d->mousePos.ry() -= dy;
- }
- if (keepLeft) {
- geom.setRight(geom.right() + dx);
- d->mousePos.rx() += dx;
- } else {
- geom.setLeft(geom.left() - dx);
- d->mousePos.rx() -= dx;
- }
- }
- if (geom != d->managed->geometry()) {
- QApplication::sendPostedEvents();
- d->managed->setGeometry(geom);
- }
-}
-
-void QWSManager::paintEvent(QPaintEvent *)
-{
- Q_D(QWSManager);
- d->dirtyRegion(QDecoration::All, QDecoration::Normal);
-}
-
-void QWSManagerPrivate::dirtyRegion(int decorationRegion,
- QDecoration::DecorationState state,
- const QRegion &clip)
-{
- QTLWExtra *topextra = managed->d_func()->extra->topextra;
- QWidgetBackingStore *bs = topextra->backingStore.data();
- const bool pendingUpdateRequest = bs->isDirty();
-
- if (decorationRegion == QDecoration::All) {
- if (clip.isEmpty())
- entireDecorationNeedsRepaint = true;
- dirtyRegions.clear();
- dirtyStates.clear();
- }
- int i = dirtyRegions.indexOf(decorationRegion);
- if (i >= 0) {
- dirtyRegions.removeAt(i);
- dirtyStates.removeAt(i);
- }
-
- dirtyRegions.append(decorationRegion);
- dirtyStates.append(state);
- if (!entireDecorationNeedsRepaint)
- dirtyClip += clip;
-
- if (!pendingUpdateRequest)
- QApplication::postEvent(managed, new QEvent(QEvent::UpdateRequest), Qt::LowEventPriority);
-}
-
-void QWSManagerPrivate::clearDirtyRegions()
-{
- dirtyRegions.clear();
- dirtyStates.clear();
- dirtyClip = QRegion();
- entireDecorationNeedsRepaint = false;
-}
-
-bool QWSManager::repaintRegion(int decorationRegion, QDecoration::DecorationState state)
-{
- Q_D(QWSManager);
-
- d->dirtyRegion(decorationRegion, state);
- return true;
-}
-
-void QWSManager::menu(const QPoint &pos)
-{
-#ifdef QT_NO_MENU
- Q_UNUSED(pos);
-#else
- Q_D(QWSManager);
- if (d->popup)
- delete d->popup;
-
- // Basic window operation menu
- d->popup = new QMenu();
- QApplication::qwsDecoration().buildSysMenu(d->managed, d->popup);
- connect(d->popup, SIGNAL(triggered(QAction*)), SLOT(menuTriggered(QAction*)));
-
- d->popup->popup(pos);
- d->activeRegion = QDecoration::None;
-#endif // QT_NO_MENU
-}
-
-void QWSManager::menuTriggered(QAction *action)
-{
-#ifdef QT_NO_MENU
- Q_UNUSED(action);
-#else
- Q_D(QWSManager);
- QApplication::qwsDecoration().menuTriggered(d->managed, action);
- d->popup->deleteLater();
- d->popup = 0;
-#endif
-}
-
-void QWSManager::startMove()
-{
- Q_D(QWSManager);
- d->mousePos = QCursor::pos();
- d->activeRegion = QDecoration::Title;
- d->active = d->managed;
- d->managed->grabMouse();
-}
-
-void QWSManager::startResize()
-{
- Q_D(QWSManager);
- d->activeRegion = QDecoration::BottomRight;
- d->active = d->managed;
- d->managed->grabMouse();
-}
-
-void QWSManager::maximize()
-{
- Q_D(QWSManager);
- // find out how much space the decoration needs
- const int screen = QApplication::desktop()->screenNumber(d->managed);
- const QRect desk = QApplication::desktop()->availableGeometry(screen);
- QRect dummy(0, 0, 1, 1);
- QRect nr;
- QRegion r = QApplication::qwsDecoration().region(d->managed, dummy);
- if (r.isEmpty()) {
- nr = desk;
- } else {
- r += dummy; // make sure we get the full window region in case of 0 width borders
- QRect rect = r.boundingRect();
- nr = QRect(desk.x()-rect.x(), desk.y()-rect.y(),
- desk.width() - (rect.width()==1 ? 0 : rect.width()-1), // ==1 -> dummy
- desk.height() - (rect.height()==1 ? 0 : rect.height()-1));
- }
- d->managed->setGeometry(nr);
-}
-
-bool QWSManagerPrivate::newCachedRegion(const QPoint &pos)
-{
- // Check if anything has changed that would affect the region caching
- if (managed->windowFlags() == cached_region.windowFlags
- && managed->geometry() == cached_region.windowGeometry
- && cached_region.region.contains(pos))
- return false;
-
- // Update the cached region
- int reg = QApplication::qwsDecoration().regionAt(managed, pos);
- if (QWidget::mouseGrabber())
- reg = QDecoration::None;
-
- previousRegionType = cached_region.regionType;
- cached_region.regionType = reg;
- cached_region.region = QApplication::qwsDecoration().region(managed, managed->geometry(),
- reg);
- // Make room for borders around the widget, even if the decoration doesn't have a frame.
- if (reg && !(reg & int(QDecoration::Borders))) {
- cached_region.region -= QApplication::qwsDecoration().region(managed, managed->geometry(), QDecoration::Borders);
- }
- cached_region.windowFlags = managed->windowFlags();
- cached_region.windowGeometry = managed->geometry();
-// QRect rec = cached_region.region.boundingRect();
-// qDebug("Updated cached region: 0x%04x (%d, %d) (%d, %d, %d, %d)",
-// reg, pos.x(), pos.y(), rec.x(), rec.y(), rec.right(), rec.bottom());
- return true;
-}
-
-QT_END_NAMESPACE
-
-#endif //QT_NO_QWS_MANAGER
diff --git a/src/gui/embedded/qwsmanager_qws.h b/src/gui/embedded/qwsmanager_qws.h
deleted file mode 100644
index 5a33bfd038..0000000000
--- a/src/gui/embedded/qwsmanager_qws.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWSMANAGER_QWS_H
-#define QWSMANAGER_QWS_H
-
-#include <QtGui/qpixmap.h>
-#include <QtCore/qobject.h>
-#include <QtGui/qdecoration_qws.h>
-#include <QtGui/qevent.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_QWS_MANAGER
-
-class QAction;
-class QPixmap;
-class QWidget;
-class QPopupMenu;
-class QRegion;
-class QMouseEvent;
-class QWSManagerPrivate;
-
-class Q_GUI_EXPORT QWSManager : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QWSManager)
-public:
- explicit QWSManager(QWidget *);
- ~QWSManager();
-
- static QDecoration *newDefaultDecoration();
-
- QWidget *widget();
- static QWidget *grabbedMouse();
- void maximize();
- void startMove();
- void startResize();
-
- QRegion region();
- QRegion &cachedRegion();
-
-protected Q_SLOTS:
- void menuTriggered(QAction *action);
-
-protected:
- void handleMove(QPoint g);
-
- virtual bool event(QEvent *e);
- virtual void mouseMoveEvent(QMouseEvent *);
- virtual void mousePressEvent(QMouseEvent *);
- virtual void mouseReleaseEvent(QMouseEvent *);
- virtual void mouseDoubleClickEvent(QMouseEvent *);
- virtual void paintEvent(QPaintEvent *);
- bool repaintRegion(int region, QDecoration::DecorationState state);
-
- void menu(const QPoint &);
-
-private:
- friend class QWidget;
- friend class QETWidget;
- friend class QWidgetPrivate;
- friend class QApplication;
- friend class QApplicationPrivate;
- friend class QWidgetBackingStore;
- friend class QWSWindowSurface;
- friend class QGLDrawable;
-};
-
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <QtGui/qdecorationdefault_qws.h>
-QT_END_INCLUDE_NAMESPACE
-
-#endif // QT_NO_QWS_MANAGER
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QWSMANAGER_QWS_H
diff --git a/src/gui/embedded/qwsproperty_qws.cpp b/src/gui/embedded/qwsproperty_qws.cpp
deleted file mode 100644
index b5ce4c52be..0000000000
--- a/src/gui/embedded/qwsproperty_qws.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwsproperty_qws.h"
-
-#ifndef QT_NO_QWS_PROPERTIES
-#include "qwscommand_qws_p.h"
-#include "qwindowsystem_qws.h"
-#include "qhash.h"
-#include "qalgorithms.h"
-#include "qbytearray.h"
-
-#include <stdio.h>
-
-QT_BEGIN_NAMESPACE
-
-class QWSPropertyManager::Data {
-public:
- QByteArray find(int winId, int property)
- {
- return properties.value(winId).value(property);
- }
-
- typedef QHash<int, QHash<int, QByteArray> > PropertyHash;
- PropertyHash properties;
-};
-
-/*********************************************************************
- *
- * Class: QWSPropertyManager
- *
- *********************************************************************/
-
-QWSPropertyManager::QWSPropertyManager()
-{
- d = new Data;
-}
-
-QWSPropertyManager::~QWSPropertyManager()
-{
- delete d;
-}
-
-bool QWSPropertyManager::setProperty(int winId, int property, int mode, const char *data, int len)
-{
- QHash<int, QByteArray> props = d->properties.value(winId);
- QHash<int, QByteArray>::iterator it = props.find(property);
- if (it == props.end())
- return false;
-
- switch (mode) {
- case PropReplace:
- d->properties[winId][property] = QByteArray(data, len);
- break;
- case PropAppend:
- d->properties[winId][property].append(data);
- break;
- case PropPrepend:
- d->properties[winId][property].prepend(data);
- break;
- }
- return true;
-}
-
-bool QWSPropertyManager::hasProperty(int winId, int property)
-{
- return d->properties.value(winId).contains(property);
-}
-
-bool QWSPropertyManager::removeProperty(int winId, int property)
-{
- QWSPropertyManager::Data::PropertyHash::iterator it = d->properties.find(winId);
- if (it == d->properties.end())
- return false;
- return d->properties[winId].remove( property );
-}
-
-bool QWSPropertyManager::addProperty(int winId, int property)
-{
- if( !d->properties[winId].contains(property) )
- d->properties[winId][property] = QByteArray(); // only add if it doesn't exist
- return true;
-}
-
-bool QWSPropertyManager::getProperty(int winId, int property, const char *&data, int &len)
-{
- QHash<int, QByteArray> props = d->properties.value(winId);
- QHash<int, QByteArray>::iterator it = props.find(property);
- if (it == props.end()) {
- data = 0;
- len = -1;
- return false;
- }
- data = it.value().constData();
- len = it.value().length();
-
- return true;
-}
-
-bool QWSPropertyManager::removeProperties(int winId)
-{
- return d->properties.remove(winId);
-}
-
-QT_END_NAMESPACE
-
-#endif //QT_NO_QWS_PROPERTIES
diff --git a/src/gui/embedded/qwsproperty_qws.h b/src/gui/embedded/qwsproperty_qws.h
deleted file mode 100644
index 4a779e0905..0000000000
--- a/src/gui/embedded/qwsproperty_qws.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWSPROPERTY_QWS_H
-#define QWSPROPERTY_QWS_H
-
-#include <QtCore/qglobal.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-/*********************************************************************
- *
- * Class: QWSPropertyManager
- *
- *********************************************************************/
-
-#ifndef QT_NO_QWS_PROPERTIES
-
-class QWSPropertyManager
-{
-public:
- enum Mode {
- PropReplace = 0,
- PropPrepend,
- PropAppend
- };
-
- // pre-defined properties
- enum Atom {
- PropSelection = 0
- };
-
- QWSPropertyManager();
- ~QWSPropertyManager();
-
- bool setProperty(int winId, int property, int mode, const char *data, int len);
- bool hasProperty(int winId, int property);
- bool removeProperty(int winId, int property);
- bool addProperty(int winId, int property);
- bool getProperty(int winId, int property, const char *&data, int &len);
- bool removeProperties(int winId);
-
-private:
- class Data;
- Data* d;
-};
-
-#endif // QT_NO_QWS_PROPERTIES
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QWSPROPERTY_QWS_H
diff --git a/src/gui/embedded/qwsprotocolitem_qws.h b/src/gui/embedded/qwsprotocolitem_qws.h
deleted file mode 100644
index 0afd4c2a02..0000000000
--- a/src/gui/embedded/qwsprotocolitem_qws.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWSPROTOCOLITEM_QWS_H
-#define QWSPROTOCOLITEM_QWS_H
-
-/*********************************************************************
- *
- * QWSCommand base class - only use derived classes from that
- *
- *********************************************************************/
-
-#include <QtCore/qglobal.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QIODevice;
-
-struct QWSProtocolItem
-{
- // ctor - dtor
- QWSProtocolItem(int t, int len, char *ptr) : type(t),
- simpleLen(len), rawLen(-1), deleteRaw(false), simpleDataPtr(ptr),
- rawDataPtr(0), bytesRead(0) { }
- virtual ~QWSProtocolItem();
-
- // data
- int type;
- int simpleLen;
- int rawLen;
- bool deleteRaw;
-
- // functions
-#ifndef QT_NO_QWS_MULTIPROCESS
- void write(QIODevice *s);
- bool read(QIODevice *s);
-#endif
- void copyFrom(const QWSProtocolItem *item);
-
- virtual void setData(const char *data, int len, bool allocateMem = true);
-
- char *simpleDataPtr;
- char *rawDataPtr;
- // temp variables
- int bytesRead;
-};
-
-// This should probably be a method on QWSProtocolItem, but this way avoids
-// changing the API of this apparently public header
-// size = (int)type + (int)rawLenSize + simpleLen + rawLen
-#define QWS_PROTOCOL_ITEM_SIZE( item ) \
- (2 * sizeof(int)) + ((item).simpleDataPtr ? (item).simpleLen : 0) + ((item).rawDataPtr ? (item).rawLen : 0)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QWSPROTOCOLITEM_QWS_H
diff --git a/src/gui/embedded/qwssharedmemory.cpp b/src/gui/embedded/qwssharedmemory.cpp
deleted file mode 100644
index 07c46254bd..0000000000
--- a/src/gui/embedded/qwssharedmemory.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwssharedmemory_p.h"
-
-#if !defined(QT_NO_QWS_MULTIPROCESS)
-
-#include <sys/shm.h>
-
-QT_BEGIN_NAMESPACE
-
-QWSSharedMemory::QWSSharedMemory()
- : shmBase(0), shmSize(0), character(0), shmId(-1), key(-1)
-{
-}
-
-
-QWSSharedMemory::~QWSSharedMemory()
-{
- detach();
-}
-
-/*
- man page says:
- On Linux, it is possible to attach a shared memory segment even if it
- is already marked to be deleted. However, POSIX.1-2001 does not spec-
- ify this behaviour and many other implementations do not support it.
-*/
-
-bool QWSSharedMemory::create(int size)
-{
- if (shmId != -1)
- detach();
- shmId = shmget(IPC_PRIVATE, size, IPC_CREAT|0600);
-
- if (shmId == -1) {
-#ifdef QT_SHM_DEBUG
- perror("QWSSharedMemory::create allocating shared memory");
- qWarning("Error allocating shared memory of size %d", size);
-#endif
- return false;
- }
- shmBase = shmat(shmId,0,0);
- shmctl(shmId, IPC_RMID, 0);
- if (shmBase == (void*)-1) {
-#ifdef QT_SHM_DEBUG
- perror("QWSSharedMemory::create attaching to shared memory");
- qWarning("Error attaching to shared memory id %d", shmId);
-#endif
- shmBase = 0;
- return false;
- }
- return true;
-}
-
-bool QWSSharedMemory::attach(int id)
-{
- if (shmId == id)
- return id != -1;
- if (shmId != -1)
- detach();
-
- shmBase = shmat(id,0,0);
- if (shmBase == (void*)-1) {
-#ifdef QT_SHM_DEBUG
- perror("QWSSharedMemory::attach attaching to shared memory");
- qWarning("Error attaching to shared memory 0x%x of size %d",
- id, size());
-#endif
- shmBase = 0;
- return false;
- }
- shmId = id;
- return true;
-}
-
-
-void QWSSharedMemory::detach ()
-{
- if (!shmBase)
- return;
- shmdt (shmBase);
- shmBase = 0;
- shmSize = 0;
- shmId = -1;
-}
-
-void QWSSharedMemory::setPermissions (mode_t mode)
-{
- struct shmid_ds shm;
- shmctl (shmId, IPC_STAT, &shm);
- shm.shm_perm.mode = mode;
- shmctl (shmId, IPC_SET, &shm);
-}
-
-int QWSSharedMemory::size () const
-{
- struct shmid_ds shm;
- shmctl (shmId, IPC_STAT, &shm);
- return shm.shm_segsz;
-}
-
-
-// old API
-
-
-
-QWSSharedMemory::QWSSharedMemory (int size, const QString &filename, char c)
-{
- shmSize = size;
- shmFile = filename;
- shmBase = 0;
- shmId = -1;
- character = c;
- key = ftok (shmFile.toLatin1().constData(), c);
-}
-
-
-
-bool QWSSharedMemory::create ()
-{
- shmId = shmget (key, shmSize, IPC_CREAT | 0666);
- return (shmId != -1);
-}
-
-void QWSSharedMemory::destroy ()
-{
- if (shmId != -1)
- shmctl(shmId, IPC_RMID, 0);
-}
-
-bool QWSSharedMemory::attach ()
-{
- if (shmId == -1)
- shmId = shmget (key, shmSize, 0);
-
- shmBase = shmat (shmId, 0, 0);
- if ((long)shmBase == -1)
- shmBase = 0;
-
- return (long)shmBase != 0;
-}
-
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_MULTIPROCESS
diff --git a/src/gui/embedded/qwssharedmemory_p.h b/src/gui/embedded/qwssharedmemory_p.h
deleted file mode 100644
index 591d92a012..0000000000
--- a/src/gui/embedded/qwssharedmemory_p.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWSSHAREDMEMORY_P_H
-#define QWSSHAREDMEMORY_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qplatformdefs.h"
-#include "QtCore/qstring.h"
-
-QT_BEGIN_NAMESPACE
-
-#if !defined(QT_NO_QWS_MULTIPROCESS)
-
-class QWSSharedMemory {
-public:
-
- QWSSharedMemory();
- ~QWSSharedMemory();
-
- void setPermissions(mode_t mode);
- int size() const;
- void *address() { return shmBase; }
-
- int id() const { return shmId; }
-
- void detach();
-
- bool create(int size);
- bool attach(int id);
-
- //bool create(int size, const QString &filename, char c = 'Q');
- //bool attach(const QString &filename, char c = 'Q');
-// old API
-
- QWSSharedMemory(int, const QString &, char c = 'Q');
- void * base() { return address(); }
-
- bool create();
- void destroy();
-
- bool attach();
-
-private:
- void *shmBase;
- int shmSize;
- QString shmFile;
- char character;
- int shmId;
- key_t key;
-};
-
-#endif // QT_NO_QWS_MULTIPROCESS
-
-QT_END_NAMESPACE
-
-#endif // QWSSHAREDMEMORY_P_H
diff --git a/src/gui/embedded/qwssignalhandler.cpp b/src/gui/embedded/qwssignalhandler.cpp
deleted file mode 100644
index cc18bebdfb..0000000000
--- a/src/gui/embedded/qwssignalhandler.cpp
+++ /dev/null
@@ -1,128 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwssignalhandler_p.h"
-
-#ifndef QT_NO_QWS_SIGNALHANDLER
-
-#include <sys/types.h>
-#ifndef QT_NO_QWS_MULTIPROCESS
-# include <sys/ipc.h>
-# include <sys/sem.h>
-
-# include <private/qcore_unix_p.h>
-#endif
-#include <signal.h>
-
-QT_BEGIN_NAMESPACE
-
-class QWSSignalHandlerPrivate : public QWSSignalHandler
-{
-public:
- QWSSignalHandlerPrivate() : QWSSignalHandler() {}
-};
-
-
-Q_GLOBAL_STATIC(QWSSignalHandlerPrivate, signalHandlerInstance);
-
-
-QWSSignalHandler* QWSSignalHandler::instance()
-{
- return signalHandlerInstance();
-}
-
-QWSSignalHandler::QWSSignalHandler()
-{
- const int signums[] = { SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGABRT, SIGFPE,
- SIGSEGV, SIGTERM, SIGBUS };
- const int n = sizeof(signums)/sizeof(int);
-
- for (int i = 0; i < n; ++i) {
- const int signum = signums[i];
- qt_sighandler_t old = signal(signum, handleSignal);
- if (old == SIG_IGN) // don't remove shm and semaphores when ignored
- signal(signum, old);
- else
- oldHandlers[signum] = (old == SIG_ERR ? SIG_DFL : old);
- }
-}
-
-QWSSignalHandler::~QWSSignalHandler()
-{
-#ifndef QT_NO_QWS_MULTIPROCESS
- while (!semaphores.isEmpty())
- removeSemaphore(semaphores.last());
-#endif
-}
-
-#ifndef QT_NO_QWS_MULTIPROCESS
-void QWSSignalHandler::removeSemaphore(int semno)
-{
- const int index = semaphores.lastIndexOf(semno);
- if (index != -1) {
- qt_semun semval;
- semval.val = 0;
- semctl(semaphores.at(index), 0, IPC_RMID, semval);
- semaphores.remove(index);
- }
-}
-#endif // QT_NO_QWS_MULTIPROCESS
-
-void QWSSignalHandler::handleSignal(int signum)
-{
- QWSSignalHandler *h = instance();
-
- signal(signum, h->oldHandlers[signum]);
-
-#ifndef QT_NO_QWS_MULTIPROCESS
- qt_semun semval;
- semval.val = 0;
- for (int i = 0; i < h->semaphores.size(); ++i)
- semctl(h->semaphores.at(i), 0, IPC_RMID, semval);
-#endif
-
- h->objects.clear();
- raise(signum);
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_QWS_NO_SIGNALHANDLER
diff --git a/src/gui/embedded/qwssignalhandler_p.h b/src/gui/embedded/qwssignalhandler_p.h
deleted file mode 100644
index e933d06b6a..0000000000
--- a/src/gui/embedded/qwssignalhandler_p.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWSSIGNALHANDLER_P_H
-#define QWSSIGNALHANDLER_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QLibrary class. This header file may change from
-// version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qglobal.h>
-
-#ifndef QT_NO_QWS_SIGNALHANDLER
-
-#include <QtCore/qmap.h>
-#include <QtCore/qvector.h>
-#include <QtCore/qobjectcleanuphandler.h>
-
-QT_BEGIN_NAMESPACE
-
-typedef void (*qt_sighandler_t)(int);
-
-class QWSSignalHandlerPrivate;
-
-class Q_GUI_EXPORT QWSSignalHandler
-{
-public:
- static QWSSignalHandler* instance();
-
- ~QWSSignalHandler();
-
-#ifndef QT_NO_QWS_MULTIPROCESS
- inline void addSemaphore(int semno) { semaphores.append(semno); }
- void removeSemaphore(int semno);
-#endif
- inline void addObject(QObject *object) { (void)objects.add(object); }
-
-private:
- QWSSignalHandler();
- static void handleSignal(int signal);
- QMap<int, qt_sighandler_t> oldHandlers;
-#ifndef QT_NO_QWS_MULTIPROCESS
- QVector<int> semaphores;
-#endif
- QObjectCleanupHandler objects;
-
- friend class QWSSignalHandlerPrivate;
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_SIGNALHANDLER
-
-#endif // QWSSIGNALHANDLER_P_H
diff --git a/src/gui/embedded/qwssocket_qws.cpp b/src/gui/embedded/qwssocket_qws.cpp
deleted file mode 100644
index 463af6c336..0000000000
--- a/src/gui/embedded/qwssocket_qws.cpp
+++ /dev/null
@@ -1,280 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qplatformdefs.h"
-#include "qwssocket_qws.h"
-
-#ifndef QT_NO_QWS_MULTIPROCESS
-
-#include <fcntl.h>
-#include <netdb.h>
-#include <errno.h>
-#include <stdio.h>
-#include <sys/file.h>
-#include <sys/time.h>
-#include <sys/un.h>
-
-#ifdef __MIPSEL__
-# ifndef SOCK_DGRAM
-# define SOCK_DGRAM 1
-# endif
-# ifndef SOCK_STREAM
-# define SOCK_STREAM 2
-# endif
-#endif
-
-#if defined(Q_OS_SOLARIS) || defined (QT_LINUXBASE)
-// uff-da apparently Solaris doesn't have the SUN_LEN macro, here is
-// an implementation of it...
-# ifndef SUN_LEN
-# define SUN_LEN(su) \
- sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path)
-# endif
-
-// nor the POSIX names of UNIX domain sockets *sigh*
-# ifndef AF_LOCAL
-# define AF_LOCAL AF_UNIX
-# endif
-# ifndef PF_LOCAL
-# define PF_LOCAL PF_UNIX
-# endif
-#endif // Q_OS_SOLARIS || QT_LINUXBASE
-
-QT_BEGIN_NAMESPACE
-
-/***********************************************************************
- *
- * QWSSocket
- *
- **********************************************************************/
-QWSSocket::QWSSocket(QObject *parent)
- : QWS_SOCK_BASE(parent)
-{
-#ifndef QT_NO_SXE
- QObject::connect( this, SIGNAL(stateChanged(SocketState)),
- this, SLOT(forwardStateChange(SocketState)));
-#endif
-}
-
-QWSSocket::~QWSSocket()
-{
-}
-
-#ifndef QT_NO_SXE
-QString QWSSocket::errorString()
-{
- switch (QUnixSocket::error()) {
- case NoError:
- return QString();
- case InvalidPath:
- case NonexistentPath:
- return QLatin1String("Bad path"); // NO_TR
- default:
- return QLatin1String("Bad socket"); // NO TR
- }
-}
-
-void QWSSocket::forwardStateChange(QUnixSocket::SocketState st )
-{
- switch ( st )
- {
- case ConnectedState:
- emit connected();
- break;
- case ClosingState:
- break;
- case UnconnectedState:
- emit disconnected();
- break;
- default:
- // nothing
- break;
- }
- if ( QUnixSocket::error() != NoError )
- emit error((QAbstractSocket::SocketError)0);
-}
-#endif
-
-bool QWSSocket::connectToLocalFile(const QString &file)
-{
-#ifndef QT_NO_SXE
- bool result = QUnixSocket::connect( file.toLocal8Bit() );
- if ( !result )
- {
- perror( "QWSSocketAuth::connectToLocalFile could not connect:" );
- emit error(QAbstractSocket::ConnectionRefusedError);
- return false;
- }
- return true;
-#else
- // create socket
- int s = ::socket(PF_LOCAL, SOCK_STREAM, 0);
-
- // connect to socket
- struct sockaddr_un a;
- memset(&a, 0, sizeof(a));
- a.sun_family = PF_LOCAL;
- strncpy(a.sun_path, file.toLocal8Bit().constData(), sizeof(a.sun_path) - 1);
- int r = ::connect(s, (struct sockaddr*)&a, SUN_LEN(&a));
- if (r == 0) {
- setSocketDescriptor(s);
- } else {
- perror("QWSSocket::connectToLocalFile could not connect:");
- ::close(s);
- emit error(ConnectionRefusedError);
- return false;
- }
-#endif
- return true;
-}
-
-
-/***********************************************************************
- *
- * QWSServerSocket
- *
- **********************************************************************/
-QWSServerSocket::QWSServerSocket(const QString& file, QObject *parent)
-#ifndef QT_NO_SXE
- : QUnixSocketServer(parent)
-#else
- : QTcpServer(parent)
-#endif
-{
- init(file);
-}
-
-void QWSServerSocket::init(const QString &file)
-{
-#ifndef QT_NO_SXE
- QByteArray fn = file.toLocal8Bit();
- bool result = QUnixSocketServer::listen( fn );
- if ( !result )
- {
- QUnixSocketServer::ServerError err = serverError();
- switch ( err )
- {
- case InvalidPath:
- qWarning("QWSServerSocket:: invalid path %s", qPrintable(file));
- break;
- case ResourceError:
- case BindError:
- case ListenError:
- qWarning("QWSServerSocket:: could not listen on path %s", qPrintable(file));
- break;
- default:
- break;
- }
- }
-#else
- int backlog = 16; //#####
-
-// create socket
- int s = ::socket(PF_LOCAL, SOCK_STREAM, 0);
- if (s == -1) {
- perror("QWSServerSocket::init");
- qWarning("QWSServerSocket: unable to create socket.");
- return;
- }
-
- QByteArray fn = file.toLocal8Bit();
- unlink(fn.constData()); // doesn't have to succeed
-
- // bind socket
- struct sockaddr_un a;
- memset(&a, 0, sizeof(a));
- a.sun_family = PF_LOCAL;
- strncpy(a.sun_path, fn.constData(), sizeof(a.sun_path) - 1);
- int r = ::bind(s, (struct sockaddr*)&a, SUN_LEN(&a));
- if (r < 0) {
- perror("QWSServerSocket::init");
- qWarning("QWSServerSocket: could not bind to file %s", fn.constData());
- ::close(s);
- return;
- }
-
- if (chmod(fn.constData(), 0600) < 0) {
- perror("QWSServerSocket::init");
- qWarning("Could not set permissions of %s", fn.constData());
- ::close(s);
- return;
- }
-
- // listen
- if (::listen(s, backlog) == 0) {
- if (!setSocketDescriptor(s))
- qWarning( "QWSServerSocket could not set descriptor %d : %s", s, errorString().toLatin1().constData());
- } else {
- perror("QWSServerSocket::init");
- qWarning("QWSServerSocket: could not listen to file %s", fn.constData());
- ::close(s);
- }
-#endif
-}
-
-QWSServerSocket::~QWSServerSocket()
-{
-}
-
-#ifndef QT_NO_SXE
-
-void QWSServerSocket::incomingConnection(int socketDescriptor)
-{
- inboundConnections.append( socketDescriptor );
- emit newConnection();
-}
-
-
-QWSSocket *QWSServerSocket::nextPendingConnection()
-{
- QMutexLocker locker( &ssmx );
- if ( inboundConnections.count() == 0 )
- return 0;
- QWSSocket *s = new QWSSocket();
- s->setSocketDescriptor( inboundConnections.takeFirst() );
- return s;
-}
-
-#endif // QT_NO_SXE
-
-QT_END_NAMESPACE
-
-#endif //QT_NO_QWS_MULTIPROCESS
diff --git a/src/gui/embedded/qwssocket_qws.h b/src/gui/embedded/qwssocket_qws.h
deleted file mode 100644
index 4f90564bdb..0000000000
--- a/src/gui/embedded/qwssocket_qws.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWSSOCKET_QWS_H
-#define QWSSOCKET_QWS_H
-
-#include <QtCore/qconfig.h>
-#include <QtGui/qwsutils_qws.h>
-
-#ifndef QT_NO_QWS_MULTIPROCESS
-
-#ifndef QT_NO_SXE
-#include <QtCore/qmutex.h>
-#include <QtGui/private/qunixsocketserver_p.h>
-#include <QtGui/private/qunixsocket_p.h>
-#else
-#include <QtNetwork/qtcpsocket.h>
-#include <QtNetwork/qtcpserver.h>
-#endif
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-
-class QWSSocket : public QWS_SOCK_BASE
-{
- Q_OBJECT
-public:
- explicit QWSSocket(QObject *parent=0);
- ~QWSSocket();
-
- bool connectToLocalFile(const QString &file);
-
-#ifndef QT_NO_SXE
- QString errorString();
-Q_SIGNALS:
- void connected();
- void disconnected();
- void error(QAbstractSocket::SocketError);
-private Q_SLOTS:
- void forwardStateChange(SocketState);
-#endif
-
-private:
- Q_DISABLE_COPY(QWSSocket)
-};
-
-
-class QWSServerSocket : public QWS_SOCK_SERVER_BASE
-{
- Q_OBJECT
-public:
- QWSServerSocket(const QString& file, QObject *parent=0);
- ~QWSServerSocket();
-
-#ifndef QT_NO_SXE
- QWSSocket *nextPendingConnection();
-Q_SIGNALS:
- void newConnection();
-protected:
- void incomingConnection(int socketDescriptor);
-private:
- QMutex ssmx;
- QList<int> inboundConnections;
-#endif
-
-private:
- Q_DISABLE_COPY(QWSServerSocket)
-
- void init(const QString &file);
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_QWS_MULTIPROCESS
-
-#endif // QWSSOCKET_QWS_H
diff --git a/src/gui/embedded/qwsutils_qws.h b/src/gui/embedded/qwsutils_qws.h
deleted file mode 100644
index c1295082fd..0000000000
--- a/src/gui/embedded/qwsutils_qws.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWSUTILS_QWS_H
-#define QWSUTILS_QWS_H
-
-#include <QtCore/QIODevice>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_SXE
-#define QWS_SOCK_BASE QUnixSocket
-#define QWS_SOCK_SERVER_BASE QUnixSocketServer
-class QUnixSocket;
-class QUnixSocketServer;
-#else
-#define QWS_SOCK_BASE QTcpSocket
-#define QWS_SOCK_SERVER_BASE QTcpServer
-class QTcpSocket;
-class QTcpServer;
-#endif
-class QWSSocket;
-class QWSServerSocket;
-
-/********************************************************************
- *
- * Convenient socket functions
- *
- ********************************************************************/
-#ifndef QT_NO_QWS_MULTIPROCESS
-inline int qws_read_uint(QIODevice *socket)
-{
- if (!socket || socket->bytesAvailable() < (int)sizeof(int))
- return -1;
-
- int i;
- socket->read(reinterpret_cast<char*>(&i), sizeof(i));
-
- return i;
-}
-
-inline void qws_write_uint(QIODevice *socket, int i)
-{
- if (!socket)
- return;
-
- socket->write(reinterpret_cast<char*>(&i), sizeof(i));
-}
-
-#endif // QT_NO_QWS_MULTIPROCESS
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QWSUTILS_QWS_H
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.h b/src/gui/graphicsview/qgraphicsanchorlayout.h
deleted file mode 100644
index cdb14bc3ba..0000000000
--- a/src/gui/graphicsview/qgraphicsanchorlayout.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSANCHORLAYOUT_H
-#define QGRAPHICSANCHORLAYOUT_H
-
-#include <QtGui/qgraphicsitem.h>
-#include <QtGui/qgraphicslayout.h>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
-
-class QGraphicsAnchorPrivate;
-class QGraphicsAnchorLayout;
-class QGraphicsAnchorLayoutPrivate;
-
-class Q_GUI_EXPORT QGraphicsAnchor : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing RESET unsetSpacing)
- Q_PROPERTY(QSizePolicy::Policy sizePolicy READ sizePolicy WRITE setSizePolicy)
-public:
- void setSpacing(qreal spacing);
- void unsetSpacing();
- qreal spacing() const;
- void setSizePolicy(QSizePolicy::Policy policy);
- QSizePolicy::Policy sizePolicy() const;
- ~QGraphicsAnchor();
-private:
- QGraphicsAnchor(QGraphicsAnchorLayout *parent);
-
- Q_DECLARE_PRIVATE(QGraphicsAnchor)
-
- friend class QGraphicsAnchorLayoutPrivate;
- friend struct AnchorData;
-};
-
-class Q_GUI_EXPORT QGraphicsAnchorLayout : public QGraphicsLayout
-{
-public:
- QGraphicsAnchorLayout(QGraphicsLayoutItem *parent = 0);
- virtual ~QGraphicsAnchorLayout();
-
- QGraphicsAnchor *addAnchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,
- QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge);
- QGraphicsAnchor *anchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,
- QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge);
-
- void addCornerAnchors(QGraphicsLayoutItem *firstItem, Qt::Corner firstCorner,
- QGraphicsLayoutItem *secondItem, Qt::Corner secondCorner);
-
- void addAnchors(QGraphicsLayoutItem *firstItem,
- QGraphicsLayoutItem *secondItem,
- Qt::Orientations orientations = Qt::Horizontal | Qt::Vertical);
-
- void setHorizontalSpacing(qreal spacing);
- void setVerticalSpacing(qreal spacing);
- void setSpacing(qreal spacing);
- qreal horizontalSpacing() const;
- qreal verticalSpacing() const;
-
- void removeAt(int index);
- void setGeometry(const QRectF &rect);
- int count() const;
- QGraphicsLayoutItem *itemAt(int index) const;
-
- void invalidate();
-protected:
- QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
-
-private:
- Q_DISABLE_COPY(QGraphicsAnchorLayout)
- Q_DECLARE_PRIVATE(QGraphicsAnchorLayout)
-
- friend class QGraphicsAnchor;
-};
-
-#endif
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
deleted file mode 100644
index 78918cc086..0000000000
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
+++ /dev/null
@@ -1,3015 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtGui/qwidget.h>
-#include <QtGui/qapplication.h>
-#include <QtCore/qlinkedlist.h>
-#include <QtCore/qstack.h>
-
-#ifdef QT_DEBUG
-#include <QtCore/qfile.h>
-#endif
-
-#include "qgraphicsanchorlayout_p.h"
-
-#ifndef QT_NO_GRAPHICSVIEW
-QT_BEGIN_NAMESPACE
-
-// To ensure that all variables inside the simplex solver are non-negative,
-// we limit the size of anchors in the interval [-limit, limit]. Then before
-// sending them to the simplex solver we add "limit" as an offset, so that
-// they are actually calculated in the interval [0, 2 * limit]
-// To avoid numerical errors in platforms where we use single precision,
-// we use a tighter limit for the variables range.
-const qreal g_offset = (sizeof(qreal) == sizeof(double)) ? QWIDGETSIZE_MAX : QWIDGETSIZE_MAX / 32;
-
-QGraphicsAnchorPrivate::QGraphicsAnchorPrivate(int version)
- : QObjectPrivate(version), layoutPrivate(0), data(0),
- sizePolicy(QSizePolicy::Fixed), preferredSize(0),
- hasSize(true)
-{
-}
-
-QGraphicsAnchorPrivate::~QGraphicsAnchorPrivate()
-{
- if (data) {
- // The QGraphicsAnchor was already deleted at this moment. We must clean
- // the dangling pointer to avoid double deletion in the AnchorData dtor.
- data->graphicsAnchor = 0;
-
- layoutPrivate->removeAnchor(data->from, data->to);
- }
-}
-
-void QGraphicsAnchorPrivate::setSizePolicy(QSizePolicy::Policy policy)
-{
- if (sizePolicy != policy) {
- sizePolicy = policy;
- layoutPrivate->q_func()->invalidate();
- }
-}
-
-void QGraphicsAnchorPrivate::setSpacing(qreal value)
-{
- if (!data) {
- qWarning("QGraphicsAnchor::setSpacing: The anchor does not exist.");
- return;
- }
-
- if (hasSize && (preferredSize == value))
- return;
-
- // The anchor has an user-defined size
- hasSize = true;
- preferredSize = value;
-
- layoutPrivate->q_func()->invalidate();
-}
-
-void QGraphicsAnchorPrivate::unsetSpacing()
-{
- if (!data) {
- qWarning("QGraphicsAnchor::setSpacing: The anchor does not exist.");
- return;
- }
-
- // Return to standard direction
- hasSize = false;
-
- layoutPrivate->q_func()->invalidate();
-}
-
-qreal QGraphicsAnchorPrivate::spacing() const
-{
- if (!data) {
- qWarning("QGraphicsAnchor::setSpacing: The anchor does not exist.");
- return 0;
- }
-
- return preferredSize;
-}
-
-
-static void applySizePolicy(QSizePolicy::Policy policy,
- qreal minSizeHint, qreal prefSizeHint, qreal maxSizeHint,
- qreal *minSize, qreal *prefSize,
- qreal *maxSize)
-{
- // minSize, prefSize and maxSize are initialized
- // with item's preferred Size: this is QSizePolicy::Fixed.
- //
- // Then we check each flag to find the resultant QSizePolicy,
- // according to the following table:
- //
- // constant value
- // QSizePolicy::Fixed 0
- // QSizePolicy::Minimum GrowFlag
- // QSizePolicy::Maximum ShrinkFlag
- // QSizePolicy::Preferred GrowFlag | ShrinkFlag
- // QSizePolicy::Ignored GrowFlag | ShrinkFlag | IgnoreFlag
-
- if (policy & QSizePolicy::ShrinkFlag)
- *minSize = minSizeHint;
- else
- *minSize = prefSizeHint;
-
- if (policy & QSizePolicy::GrowFlag)
- *maxSize = maxSizeHint;
- else
- *maxSize = prefSizeHint;
-
- // Note that these two initializations are affected by the previous flags
- if (policy & QSizePolicy::IgnoreFlag)
- *prefSize = *minSize;
- else
- *prefSize = prefSizeHint;
-}
-
-AnchorData::~AnchorData()
-{
- if (graphicsAnchor) {
- // Remove reference to ourself to avoid double removal in
- // QGraphicsAnchorPrivate dtor.
- graphicsAnchor->d_func()->data = 0;
-
- delete graphicsAnchor;
- }
-}
-
-
-void AnchorData::refreshSizeHints(const QLayoutStyleInfo *styleInfo)
-{
- QSizePolicy::Policy policy;
- qreal minSizeHint;
- qreal prefSizeHint;
- qreal maxSizeHint;
-
- if (item) {
- // It is an internal anchor, fetch size information from the item
- if (isLayoutAnchor) {
- minSize = 0;
- prefSize = 0;
- maxSize = QWIDGETSIZE_MAX;
- if (isCenterAnchor)
- maxSize /= 2;
-
- minPrefSize = prefSize;
- maxPrefSize = maxSize;
- return;
- } else {
- if (orientation == QGraphicsAnchorLayoutPrivate::Horizontal) {
- policy = item->sizePolicy().horizontalPolicy();
- minSizeHint = item->effectiveSizeHint(Qt::MinimumSize).width();
- prefSizeHint = item->effectiveSizeHint(Qt::PreferredSize).width();
- maxSizeHint = item->effectiveSizeHint(Qt::MaximumSize).width();
- } else {
- policy = item->sizePolicy().verticalPolicy();
- minSizeHint = item->effectiveSizeHint(Qt::MinimumSize).height();
- prefSizeHint = item->effectiveSizeHint(Qt::PreferredSize).height();
- maxSizeHint = item->effectiveSizeHint(Qt::MaximumSize).height();
- }
-
- if (isCenterAnchor) {
- minSizeHint /= 2;
- prefSizeHint /= 2;
- maxSizeHint /= 2;
- }
- }
- } else {
- // It is a user-created anchor, fetch size information from the associated QGraphicsAnchor
- Q_ASSERT(graphicsAnchor);
- QGraphicsAnchorPrivate *anchorPrivate = graphicsAnchor->d_func();
-
- // Policy, min and max sizes are straightforward
- policy = anchorPrivate->sizePolicy;
- minSizeHint = 0;
- maxSizeHint = QWIDGETSIZE_MAX;
-
- // Preferred Size
- if (anchorPrivate->hasSize) {
- // Anchor has user-defined size
- prefSizeHint = anchorPrivate->preferredSize;
- } else {
- // Fetch size information from style
- const Qt::Orientation orient = Qt::Orientation(QGraphicsAnchorLayoutPrivate::edgeOrientation(from->m_edge) + 1);
- qreal s = styleInfo->defaultSpacing(orient);
- if (s < 0) {
- QSizePolicy::ControlType controlTypeFrom = from->m_item->sizePolicy().controlType();
- QSizePolicy::ControlType controlTypeTo = to->m_item->sizePolicy().controlType();
- s = styleInfo->perItemSpacing(controlTypeFrom, controlTypeTo, orient);
-
- // ### Currently we do not support negative anchors inside the graph.
- // To avoid those being created by a negative style spacing, we must
- // make this test.
- if (s < 0)
- s = 0;
- }
- prefSizeHint = s;
- }
- }
-
- // Fill minSize, prefSize and maxSize based on policy and sizeHints
- applySizePolicy(policy, minSizeHint, prefSizeHint, maxSizeHint,
- &minSize, &prefSize, &maxSize);
-
- minPrefSize = prefSize;
- maxPrefSize = maxSize;
-
- // Set the anchor effective sizes to preferred.
- //
- // Note: The idea here is that all items should remain at their
- // preferred size unless where that's impossible. In cases where
- // the item is subject to restrictions (anchored to the layout
- // edges, for instance), the simplex solver will be run to
- // recalculate and override the values we set here.
- sizeAtMinimum = prefSize;
- sizeAtPreferred = prefSize;
- sizeAtMaximum = prefSize;
-}
-
-void ParallelAnchorData::updateChildrenSizes()
-{
- firstEdge->sizeAtMinimum = sizeAtMinimum;
- firstEdge->sizeAtPreferred = sizeAtPreferred;
- firstEdge->sizeAtMaximum = sizeAtMaximum;
-
- if (secondForward()) {
- secondEdge->sizeAtMinimum = sizeAtMinimum;
- secondEdge->sizeAtPreferred = sizeAtPreferred;
- secondEdge->sizeAtMaximum = sizeAtMaximum;
- } else {
- secondEdge->sizeAtMinimum = -sizeAtMinimum;
- secondEdge->sizeAtPreferred = -sizeAtPreferred;
- secondEdge->sizeAtMaximum = -sizeAtMaximum;
- }
-
- firstEdge->updateChildrenSizes();
- secondEdge->updateChildrenSizes();
-}
-
-/*
- \internal
-
- Initialize the parallel anchor size hints using the sizeHint information from
- its children.
-
- Note that parallel groups can lead to unfeasibility, so during calculation, we can
- find out one unfeasibility. Because of that this method return boolean. This can't
- happen in sequential, so there the method is void.
- */
-bool ParallelAnchorData::calculateSizeHints()
-{
- // Normalize second child sizes.
- // A negative anchor of sizes min, minPref, pref, maxPref and max, is equivalent
- // to a forward anchor of sizes -max, -maxPref, -pref, -minPref, -min
- qreal secondMin;
- qreal secondMinPref;
- qreal secondPref;
- qreal secondMaxPref;
- qreal secondMax;
-
- if (secondForward()) {
- secondMin = secondEdge->minSize;
- secondMinPref = secondEdge->minPrefSize;
- secondPref = secondEdge->prefSize;
- secondMaxPref = secondEdge->maxPrefSize;
- secondMax = secondEdge->maxSize;
- } else {
- secondMin = -secondEdge->maxSize;
- secondMinPref = -secondEdge->maxPrefSize;
- secondPref = -secondEdge->prefSize;
- secondMaxPref = -secondEdge->minPrefSize;
- secondMax = -secondEdge->minSize;
- }
-
- minSize = qMax(firstEdge->minSize, secondMin);
- maxSize = qMin(firstEdge->maxSize, secondMax);
-
- // This condition means that the maximum size of one anchor being simplified is smaller than
- // the minimum size of the other anchor. The consequence is that there won't be a valid size
- // for this parallel setup.
- if (minSize > maxSize) {
- return false;
- }
-
- // Preferred size calculation
- // The calculation of preferred size is done as follows:
- //
- // 1) Check whether one of the child anchors is the layout structural anchor
- // If so, we can simply copy the preferred information from the other child,
- // after bounding it to our minimum and maximum sizes.
- // If not, then we proceed with the actual calculations.
- //
- // 2) The whole algorithm for preferred size calculation is based on the fact
- // that, if a given anchor cannot remain at its preferred size, it'd rather
- // grow than shrink.
- //
- // What happens though is that while this affirmative is true for simple
- // anchors, it may not be true for sequential anchors that have one or more
- // reversed anchors inside it. That happens because when a sequential anchor
- // grows, any reversed anchors inside it may be required to shrink, something
- // we try to avoid, as said above.
- //
- // To overcome this, besides their actual preferred size "prefSize", each anchor
- // exports what we call "minPrefSize" and "maxPrefSize". These two values define
- // a surrounding interval where, if required to move, the anchor would rather
- // remain inside.
- //
- // For standard anchors, this area simply represents the region between
- // prefSize and maxSize, which makes sense since our first affirmation.
- // For composed anchors, these values are calculated as to reduce the global
- // "damage", that is, to reduce the total deviation and the total amount of
- // anchors that had to shrink.
-
- if (firstEdge->isLayoutAnchor) {
- prefSize = qBound(minSize, secondPref, maxSize);
- minPrefSize = qBound(minSize, secondMinPref, maxSize);
- maxPrefSize = qBound(minSize, secondMaxPref, maxSize);
- } else if (secondEdge->isLayoutAnchor) {
- prefSize = qBound(minSize, firstEdge->prefSize, maxSize);
- minPrefSize = qBound(minSize, firstEdge->minPrefSize, maxSize);
- maxPrefSize = qBound(minSize, firstEdge->maxPrefSize, maxSize);
- } else {
- // Calculate the intersection between the "preferred" regions of each child
- const qreal lowerBoundary =
- qBound(minSize, qMax(firstEdge->minPrefSize, secondMinPref), maxSize);
- const qreal upperBoundary =
- qBound(minSize, qMin(firstEdge->maxPrefSize, secondMaxPref), maxSize);
- const qreal prefMean =
- qBound(minSize, (firstEdge->prefSize + secondPref) / 2, maxSize);
-
- if (lowerBoundary < upperBoundary) {
- // If there is an intersection between the two regions, this intersection
- // will be used as the preferred region of the parallel anchor itself.
- // The preferred size will be the bounded average between the two preferred
- // sizes.
- prefSize = qBound(lowerBoundary, prefMean, upperBoundary);
- minPrefSize = lowerBoundary;
- maxPrefSize = upperBoundary;
- } else {
- // If there is no intersection, we have to attribute "damage" to at least
- // one of the children. The minimum total damage is achieved in points
- // inside the region that extends from (1) the upper boundary of the lower
- // region to (2) the lower boundary of the upper region.
- // Then, we expose this region as _our_ preferred region and once again,
- // use the bounded average as our preferred size.
- prefSize = qBound(upperBoundary, prefMean, lowerBoundary);
- minPrefSize = upperBoundary;
- maxPrefSize = lowerBoundary;
- }
- }
-
- // See comment in AnchorData::refreshSizeHints() about sizeAt* values
- sizeAtMinimum = prefSize;
- sizeAtPreferred = prefSize;
- sizeAtMaximum = prefSize;
-
- return true;
-}
-
-/*!
- \internal
- returns the factor in the interval [-1, 1].
- -1 is at Minimum
- 0 is at Preferred
- 1 is at Maximum
-*/
-static QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> getFactor(qreal value, qreal min,
- qreal minPref, qreal pref,
- qreal maxPref, qreal max)
-{
- QGraphicsAnchorLayoutPrivate::Interval interval;
- qreal lower;
- qreal upper;
-
- if (value < minPref) {
- interval = QGraphicsAnchorLayoutPrivate::MinimumToMinPreferred;
- lower = min;
- upper = minPref;
- } else if (value < pref) {
- interval = QGraphicsAnchorLayoutPrivate::MinPreferredToPreferred;
- lower = minPref;
- upper = pref;
- } else if (value < maxPref) {
- interval = QGraphicsAnchorLayoutPrivate::PreferredToMaxPreferred;
- lower = pref;
- upper = maxPref;
- } else {
- interval = QGraphicsAnchorLayoutPrivate::MaxPreferredToMaximum;
- lower = maxPref;
- upper = max;
- }
-
- qreal progress;
- if (upper == lower) {
- progress = 0;
- } else {
- progress = (value - lower) / (upper - lower);
- }
-
- return qMakePair(interval, progress);
-}
-
-static qreal interpolate(const QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> &factor,
- qreal min, qreal minPref, qreal pref, qreal maxPref, qreal max)
-{
- qreal lower = 0;
- qreal upper = 0;
-
- switch (factor.first) {
- case QGraphicsAnchorLayoutPrivate::MinimumToMinPreferred:
- lower = min;
- upper = minPref;
- break;
- case QGraphicsAnchorLayoutPrivate::MinPreferredToPreferred:
- lower = minPref;
- upper = pref;
- break;
- case QGraphicsAnchorLayoutPrivate::PreferredToMaxPreferred:
- lower = pref;
- upper = maxPref;
- break;
- case QGraphicsAnchorLayoutPrivate::MaxPreferredToMaximum:
- lower = maxPref;
- upper = max;
- break;
- }
-
- return lower + factor.second * (upper - lower);
-}
-
-void SequentialAnchorData::updateChildrenSizes()
-{
- // Band here refers if the value is in the Minimum To Preferred
- // band (the lower band) or the Preferred To Maximum (the upper band).
-
- const QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> minFactor =
- getFactor(sizeAtMinimum, minSize, minPrefSize, prefSize, maxPrefSize, maxSize);
- const QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> prefFactor =
- getFactor(sizeAtPreferred, minSize, minPrefSize, prefSize, maxPrefSize, maxSize);
- const QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> maxFactor =
- getFactor(sizeAtMaximum, minSize, minPrefSize, prefSize, maxPrefSize, maxSize);
-
- // XXX This is not safe if Vertex simplification takes place after the sequential
- // anchor is created. In that case, "prev" will be a group-vertex, different from
- // "from" or "to", that _contains_ one of them.
- AnchorVertex *prev = from;
-
- for (int i = 0; i < m_edges.count(); ++i) {
- AnchorData *e = m_edges.at(i);
-
- const bool edgeIsForward = (e->from == prev);
- if (edgeIsForward) {
- e->sizeAtMinimum = interpolate(minFactor, e->minSize, e->minPrefSize,
- e->prefSize, e->maxPrefSize, e->maxSize);
- e->sizeAtPreferred = interpolate(prefFactor, e->minSize, e->minPrefSize,
- e->prefSize, e->maxPrefSize, e->maxSize);
- e->sizeAtMaximum = interpolate(maxFactor, e->minSize, e->minPrefSize,
- e->prefSize, e->maxPrefSize, e->maxSize);
- prev = e->to;
- } else {
- Q_ASSERT(prev == e->to);
- e->sizeAtMinimum = interpolate(minFactor, e->maxSize, e->maxPrefSize,
- e->prefSize, e->minPrefSize, e->minSize);
- e->sizeAtPreferred = interpolate(prefFactor, e->maxSize, e->maxPrefSize,
- e->prefSize, e->minPrefSize, e->minSize);
- e->sizeAtMaximum = interpolate(maxFactor, e->maxSize, e->maxPrefSize,
- e->prefSize, e->minPrefSize, e->minSize);
- prev = e->from;
- }
-
- e->updateChildrenSizes();
- }
-}
-
-void SequentialAnchorData::calculateSizeHints()
-{
- minSize = 0;
- prefSize = 0;
- maxSize = 0;
- minPrefSize = 0;
- maxPrefSize = 0;
-
- AnchorVertex *prev = from;
-
- for (int i = 0; i < m_edges.count(); ++i) {
- AnchorData *edge = m_edges.at(i);
-
- const bool edgeIsForward = (edge->from == prev);
- if (edgeIsForward) {
- minSize += edge->minSize;
- prefSize += edge->prefSize;
- maxSize += edge->maxSize;
- minPrefSize += edge->minPrefSize;
- maxPrefSize += edge->maxPrefSize;
- prev = edge->to;
- } else {
- Q_ASSERT(prev == edge->to);
- minSize -= edge->maxSize;
- prefSize -= edge->prefSize;
- maxSize -= edge->minSize;
- minPrefSize -= edge->maxPrefSize;
- maxPrefSize -= edge->minPrefSize;
- prev = edge->from;
- }
- }
-
- // See comment in AnchorData::refreshSizeHints() about sizeAt* values
- sizeAtMinimum = prefSize;
- sizeAtPreferred = prefSize;
- sizeAtMaximum = prefSize;
-}
-
-#ifdef QT_DEBUG
-void AnchorData::dump(int indent) {
- if (type == Parallel) {
- qDebug("%*s type: parallel:", indent, "");
- ParallelAnchorData *p = static_cast<ParallelAnchorData *>(this);
- p->firstEdge->dump(indent+2);
- p->secondEdge->dump(indent+2);
- } else if (type == Sequential) {
- SequentialAnchorData *s = static_cast<SequentialAnchorData *>(this);
- int kids = s->m_edges.count();
- qDebug("%*s type: sequential(%d):", indent, "", kids);
- for (int i = 0; i < kids; ++i) {
- s->m_edges.at(i)->dump(indent+2);
- }
- } else {
- qDebug("%*s type: Normal:", indent, "");
- }
-}
-
-#endif
-
-QSimplexConstraint *GraphPath::constraint(const GraphPath &path) const
-{
- // Calculate
- QSet<AnchorData *> cPositives;
- QSet<AnchorData *> cNegatives;
- QSet<AnchorData *> intersection;
-
- cPositives = positives + path.negatives;
- cNegatives = negatives + path.positives;
-
- intersection = cPositives & cNegatives;
-
- cPositives -= intersection;
- cNegatives -= intersection;
-
- // Fill
- QSimplexConstraint *c = new QSimplexConstraint;
- QSet<AnchorData *>::iterator i;
- for (i = cPositives.begin(); i != cPositives.end(); ++i)
- c->variables.insert(*i, 1.0);
-
- for (i = cNegatives.begin(); i != cNegatives.end(); ++i)
- c->variables.insert(*i, -1.0);
-
- return c;
-}
-
-#ifdef QT_DEBUG
-QString GraphPath::toString() const
-{
- QString string(QLatin1String("Path: "));
- foreach(AnchorData *edge, positives)
- string += QString::fromAscii(" (+++) %1").arg(edge->toString());
-
- foreach(AnchorData *edge, negatives)
- string += QString::fromAscii(" (---) %1").arg(edge->toString());
-
- return string;
-}
-#endif
-
-QGraphicsAnchorLayoutPrivate::QGraphicsAnchorLayoutPrivate()
- : calculateGraphCacheDirty(true), styleInfoDirty(true)
-{
- for (int i = 0; i < NOrientations; ++i) {
- for (int j = 0; j < 3; ++j) {
- sizeHints[i][j] = -1;
- }
- interpolationProgress[i] = -1;
-
- spacings[i] = -1;
- graphHasConflicts[i] = false;
-
- layoutFirstVertex[i] = 0;
- layoutCentralVertex[i] = 0;
- layoutLastVertex[i] = 0;
- }
-}
-
-Qt::AnchorPoint QGraphicsAnchorLayoutPrivate::oppositeEdge(Qt::AnchorPoint edge)
-{
- switch (edge) {
- case Qt::AnchorLeft:
- edge = Qt::AnchorRight;
- break;
- case Qt::AnchorRight:
- edge = Qt::AnchorLeft;
- break;
- case Qt::AnchorTop:
- edge = Qt::AnchorBottom;
- break;
- case Qt::AnchorBottom:
- edge = Qt::AnchorTop;
- break;
- default:
- break;
- }
- return edge;
-}
-
-
-/*!
- * \internal
- *
- * helper function in order to avoid overflowing anchor sizes
- * the returned size will never be larger than FLT_MAX
- *
- */
-inline static qreal checkAdd(qreal a, qreal b)
-{
- if (FLT_MAX - b < a)
- return FLT_MAX;
- return a + b;
-}
-
-/*!
- \internal
-
- Adds \a newAnchor to the graph.
-
- Returns the newAnchor itself if it could be added without further changes to the graph. If a
- new parallel anchor had to be created, then returns the new parallel anchor. If a parallel anchor
- had to be created and it results in an unfeasible setup, \a feasible is set to false, otherwise
- true.
-
- Note that in the case a new parallel anchor is created, it might also take over some constraints
- from its children anchors.
-*/
-AnchorData *QGraphicsAnchorLayoutPrivate::addAnchorMaybeParallel(AnchorData *newAnchor, bool *feasible)
-{
- Orientation orientation = Orientation(newAnchor->orientation);
- Graph<AnchorVertex, AnchorData> &g = graph[orientation];
- *feasible = true;
-
- // If already exists one anchor where newAnchor is supposed to be, we create a parallel
- // anchor.
- if (AnchorData *oldAnchor = g.takeEdge(newAnchor->from, newAnchor->to)) {
- ParallelAnchorData *parallel = new ParallelAnchorData(oldAnchor, newAnchor);
-
- // The parallel anchor will "replace" its children anchors in
- // every center constraint that they appear.
-
- // ### If the dependent (center) anchors had reference(s) to their constraints, we
- // could avoid traversing all the itemCenterConstraints.
- QList<QSimplexConstraint *> &constraints = itemCenterConstraints[orientation];
-
- AnchorData *children[2] = { oldAnchor, newAnchor };
- QList<QSimplexConstraint *> *childrenConstraints[2] = { &parallel->m_firstConstraints,
- &parallel->m_secondConstraints };
-
- for (int i = 0; i < 2; ++i) {
- AnchorData *child = children[i];
- QList<QSimplexConstraint *> *childConstraints = childrenConstraints[i];
-
- // We need to fix the second child constraints if the parallel group will have the
- // opposite direction of the second child anchor. For the point of view of external
- // entities, this anchor was reversed. So if at some point we say that the parallel
- // has a value of 20, this mean that the second child (when reversed) will be
- // assigned -20.
- const bool needsReverse = i == 1 && !parallel->secondForward();
-
- if (!child->isCenterAnchor)
- continue;
-
- parallel->isCenterAnchor = true;
-
- for (int j = 0; j < constraints.count(); ++j) {
- QSimplexConstraint *c = constraints[j];
- if (c->variables.contains(child)) {
- childConstraints->append(c);
- qreal v = c->variables.take(child);
- if (needsReverse)
- v *= -1;
- c->variables.insert(parallel, v);
- }
- }
- }
-
- // At this point we can identify that the parallel anchor is not feasible, e.g. one
- // anchor minimum size is bigger than the other anchor maximum size.
- *feasible = parallel->calculateSizeHints();
- newAnchor = parallel;
- }
-
- g.createEdge(newAnchor->from, newAnchor->to, newAnchor);
- return newAnchor;
-}
-
-/*!
- \internal
-
- Takes the sequence of vertices described by (\a before, \a vertices, \a after) and removes
- all anchors connected to the vertices in \a vertices, returning one simplified anchor between
- \a before and \a after.
-
- Note that this function doesn't add the created anchor to the graph. This should be done by
- the caller.
-*/
-static AnchorData *createSequence(Graph<AnchorVertex, AnchorData> *graph,
- AnchorVertex *before,
- const QVector<AnchorVertex*> &vertices,
- AnchorVertex *after)
-{
-#if defined(QT_DEBUG) && 0
- QString strVertices;
- for (int i = 0; i < vertices.count(); ++i) {
- strVertices += QString::fromAscii("%1 - ").arg(vertices.at(i)->toString());
- }
- QString strPath = QString::fromAscii("%1 - %2%3").arg(before->toString(), strVertices, after->toString());
- qDebug("simplifying [%s] to [%s - %s]", qPrintable(strPath), qPrintable(before->toString()), qPrintable(after->toString()));
-#endif
-
- AnchorVertex *prev = before;
- QVector<AnchorData *> edges;
-
- // Take from the graph, the edges that will be simplificated
- for (int i = 0; i < vertices.count(); ++i) {
- AnchorVertex *next = vertices.at(i);
- AnchorData *ad = graph->takeEdge(prev, next);
- Q_ASSERT(ad);
- edges.append(ad);
- prev = next;
- }
-
- // Take the last edge (not covered in the loop above)
- AnchorData *ad = graph->takeEdge(vertices.last(), after);
- Q_ASSERT(ad);
- edges.append(ad);
-
- // Create sequence
- SequentialAnchorData *sequence = new SequentialAnchorData(vertices, edges);
- sequence->from = before;
- sequence->to = after;
-
- sequence->calculateSizeHints();
-
- return sequence;
-}
-
-/*!
- \internal
-
- The purpose of this function is to simplify the graph.
- Simplification serves two purposes:
- 1. Reduce the number of edges in the graph, (thus the number of variables to the equation
- solver is reduced, and the solver performs better).
- 2. Be able to do distribution of sequences of edges more intelligently (esp. with sequential
- anchors)
-
- It is essential that it must be possible to restore simplified anchors back to their "original"
- form. This is done by restoreSimplifiedAnchor().
-
- There are two types of simplification that can be done:
- 1. Sequential simplification
- Sequential simplification means that all sequences of anchors will be merged into one single
- anchor. Only anhcors that points in the same direction will be merged.
- 2. Parallel simplification
- If a simplified sequential anchor is about to be inserted between two vertices in the graph
- and there already exist an anchor between those two vertices, a parallel anchor will be
- created that serves as a placeholder for the sequential anchor and the anchor that was
- already between the two vertices.
-
- The process of simplification can be described as:
-
- 1. Simplify all sequences of anchors into one anchor.
- If no further simplification was done, go to (3)
- - If there already exist an anchor where the sequential anchor is supposed to be inserted,
- take that anchor out of the graph
- - Then create a parallel anchor that holds the sequential anchor and the anchor just taken
- out of the graph.
- 2. Go to (1)
- 3. Done
-
- When creating the parallel anchors, the algorithm might identify unfeasible situations. In this
- case the simplification process stops and returns false. Otherwise returns true.
-*/
-bool QGraphicsAnchorLayoutPrivate::simplifyGraph(Orientation orientation)
-{
- if (items.isEmpty())
- return true;
-
-#if defined(QT_DEBUG) && 0
- qDebug("Simplifying Graph for %s",
- orientation == Horizontal ? "Horizontal" : "Vertical");
-
- static int count = 0;
- if (orientation == Horizontal) {
- count++;
- dumpGraph(QString::fromAscii("%1-full").arg(count));
- }
-#endif
-
- // Vertex simplification
- if (!simplifyVertices(orientation)) {
- restoreVertices(orientation);
- return false;
- }
-
- // Anchor simplification
- bool dirty;
- bool feasible = true;
- do {
- dirty = simplifyGraphIteration(orientation, &feasible);
- } while (dirty && feasible);
-
- // Note that if we are not feasible, we fallback and make sure that the graph is fully restored
- if (!feasible) {
- restoreSimplifiedGraph(orientation);
- restoreVertices(orientation);
- return false;
- }
-
-#if defined(QT_DEBUG) && 0
- dumpGraph(QString::fromAscii("%1-simplified-%2").arg(count).arg(
- QString::fromAscii(orientation == Horizontal ? "Horizontal" : "Vertical")));
-#endif
-
- return true;
-}
-
-static AnchorVertex *replaceVertex_helper(AnchorData *data, AnchorVertex *oldV, AnchorVertex *newV)
-{
- AnchorVertex *other;
- if (data->from == oldV) {
- data->from = newV;
- other = data->to;
- } else {
- data->to = newV;
- other = data->from;
- }
- return other;
-}
-
-bool QGraphicsAnchorLayoutPrivate::replaceVertex(Orientation orientation, AnchorVertex *oldV,
- AnchorVertex *newV, const QList<AnchorData *> &edges)
-{
- Graph<AnchorVertex, AnchorData> &g = graph[orientation];
- bool feasible = true;
-
- for (int i = 0; i < edges.count(); ++i) {
- AnchorData *ad = edges[i];
- AnchorVertex *otherV = replaceVertex_helper(ad, oldV, newV);
-
-#if defined(QT_DEBUG)
- ad->name = QString::fromAscii("%1 --to--> %2").arg(ad->from->toString()).arg(ad->to->toString());
-#endif
-
- bool newFeasible;
- AnchorData *newAnchor = addAnchorMaybeParallel(ad, &newFeasible);
- feasible &= newFeasible;
-
- if (newAnchor != ad) {
- // A parallel was created, we mark that in the list of anchors created by vertex
- // simplification. This is needed because we want to restore them in a separate step
- // from the restoration of anchor simplification.
- anchorsFromSimplifiedVertices[orientation].append(newAnchor);
- }
-
- g.takeEdge(oldV, otherV);
- }
-
- return feasible;
-}
-
-/*!
- \internal
-*/
-bool QGraphicsAnchorLayoutPrivate::simplifyVertices(Orientation orientation)
-{
- Q_Q(QGraphicsAnchorLayout);
- Graph<AnchorVertex, AnchorData> &g = graph[orientation];
-
- // We'll walk through vertices
- QStack<AnchorVertex *> stack;
- stack.push(layoutFirstVertex[orientation]);
- QSet<AnchorVertex *> visited;
-
- while (!stack.isEmpty()) {
- AnchorVertex *v = stack.pop();
- visited.insert(v);
-
- // Each adjacent of 'v' is a possible vertex to be merged. So we traverse all of
- // them. Since once a merge is made, we might add new adjacents, and we don't want to
- // pass two times through one adjacent. The 'index' is used to track our position.
- QList<AnchorVertex *> adjacents = g.adjacentVertices(v);
- int index = 0;
-
- while (index < adjacents.count()) {
- AnchorVertex *next = adjacents.at(index);
- index++;
-
- AnchorData *data = g.edgeData(v, next);
- const bool bothLayoutVertices = v->m_item == q && next->m_item == q;
- const bool zeroSized = !data->minSize && !data->maxSize;
-
- if (!bothLayoutVertices && zeroSized) {
-
- // Create a new vertex pair, note that we keep a list of those vertices so we can
- // easily process them when restoring the graph.
- AnchorVertexPair *newV = new AnchorVertexPair(v, next, data);
- simplifiedVertices[orientation].append(newV);
-
- // Collect the anchors of both vertices, the new vertex pair will take their place
- // in those anchors
- const QList<AnchorVertex *> &vAdjacents = g.adjacentVertices(v);
- const QList<AnchorVertex *> &nextAdjacents = g.adjacentVertices(next);
-
- for (int i = 0; i < vAdjacents.count(); ++i) {
- AnchorVertex *adjacent = vAdjacents.at(i);
- if (adjacent != next) {
- AnchorData *ad = g.edgeData(v, adjacent);
- newV->m_firstAnchors.append(ad);
- }
- }
-
- for (int i = 0; i < nextAdjacents.count(); ++i) {
- AnchorVertex *adjacent = nextAdjacents.at(i);
- if (adjacent != v) {
- AnchorData *ad = g.edgeData(next, adjacent);
- newV->m_secondAnchors.append(ad);
-
- // We'll also add new vertices to the adjacent list of the new 'v', to be
- // created as a vertex pair and replace the current one.
- if (!adjacents.contains(adjacent))
- adjacents.append(adjacent);
- }
- }
-
- // ### merge this loop into the ones that calculated m_firstAnchors/m_secondAnchors?
- // Make newV take the place of v and next
- bool feasible = replaceVertex(orientation, v, newV, newV->m_firstAnchors);
- feasible &= replaceVertex(orientation, next, newV, newV->m_secondAnchors);
-
- // Update the layout vertex information if one of the vertices is a layout vertex.
- AnchorVertex *layoutVertex = 0;
- if (v->m_item == q)
- layoutVertex = v;
- else if (next->m_item == q)
- layoutVertex = next;
-
- if (layoutVertex) {
- // Layout vertices always have m_item == q...
- newV->m_item = q;
- changeLayoutVertex(orientation, layoutVertex, newV);
- }
-
- g.takeEdge(v, next);
-
- // If a non-feasibility is found, we leave early and cancel the simplification
- if (!feasible)
- return false;
-
- v = newV;
- visited.insert(newV);
-
- } else if (!visited.contains(next) && !stack.contains(next)) {
- // If the adjacent is not fit for merge and it wasn't visited by the outermost
- // loop, we add it to the stack.
- stack.push(next);
- }
- }
- }
-
- return true;
-}
-
-/*!
- \internal
-
- One iteration of the simplification algorithm. Returns true if another iteration is needed.
-
- The algorithm walks the graph in depth-first order, and only collects vertices that has two
- edges connected to it. If the vertex does not have two edges or if it is a layout edge, it
- will take all the previously collected vertices and try to create a simplified sequential
- anchor representing all the previously collected vertices. Once the simplified anchor is
- inserted, the collected list is cleared in order to find the next sequence to simplify.
-
- Note that there are some catches to this that are not covered by the above explanation, see
- the function comments for more details.
-*/
-bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutPrivate::Orientation orientation,
- bool *feasible)
-{
- Q_Q(QGraphicsAnchorLayout);
- Graph<AnchorVertex, AnchorData> &g = graph[orientation];
-
- QSet<AnchorVertex *> visited;
- QStack<QPair<AnchorVertex *, AnchorVertex *> > stack;
- stack.push(qMakePair(static_cast<AnchorVertex *>(0), layoutFirstVertex[orientation]));
- QVector<AnchorVertex*> candidates;
-
- // Walk depth-first, in the stack we store start of the candidate sequence (beforeSequence)
- // and the vertex to be visited.
- while (!stack.isEmpty()) {
- QPair<AnchorVertex *, AnchorVertex *> pair = stack.pop();
- AnchorVertex *beforeSequence = pair.first;
- AnchorVertex *v = pair.second;
-
- // The basic idea is to determine whether we found an end of sequence,
- // if that's the case, we stop adding vertices to the candidate list
- // and do a simplification step.
- //
- // A vertex can trigger an end of sequence if
- // (a) it is a layout vertex, we don't simplify away the layout vertices;
- // (b) it does not have exactly 2 adjacents;
- // (c) its next adjacent is already visited (a cycle in the graph).
- // (d) the next anchor is a center anchor.
-
- const QList<AnchorVertex *> &adjacents = g.adjacentVertices(v);
- const bool isLayoutVertex = v->m_item == q;
- AnchorVertex *afterSequence = v;
- bool endOfSequence = false;
-
- //
- // Identify the end cases.
- //
-
- // Identifies cases (a) and (b)
- endOfSequence = isLayoutVertex || adjacents.count() != 2;
-
- if (!endOfSequence) {
- // This is a tricky part. We peek at the next vertex to find out whether
- //
- // - we already visited the next vertex (c);
- // - the next anchor is a center (d).
- //
- // Those are needed to identify the remaining end of sequence cases. Note that unlike
- // (a) and (b), we preempt the end of sequence by looking into the next vertex.
-
- // Peek at the next vertex
- AnchorVertex *after;
- if (candidates.isEmpty())
- after = (beforeSequence == adjacents.last() ? adjacents.first() : adjacents.last());
- else
- after = (candidates.last() == adjacents.last() ? adjacents.first() : adjacents.last());
-
- // ### At this point we assumed that candidates will not contain 'after', this may not hold
- // when simplifying FLOATing anchors.
- Q_ASSERT(!candidates.contains(after));
-
- const AnchorData *data = g.edgeData(v, after);
- Q_ASSERT(data);
- const bool cycleFound = visited.contains(after);
-
- // Now cases (c) and (d)...
- endOfSequence = cycleFound || data->isCenterAnchor;
-
- if (!endOfSequence) {
- // If it's not an end of sequence, then the vertex didn't trigger neither of the
- // previously three cases, so it can be added to the candidates list.
- candidates.append(v);
- } else if (cycleFound && (beforeSequence != after)) {
- afterSequence = after;
- candidates.append(v);
- }
- }
-
- //
- // Add next non-visited vertices to the stack.
- //
- for (int i = 0; i < adjacents.count(); ++i) {
- AnchorVertex *next = adjacents.at(i);
- if (visited.contains(next))
- continue;
-
- // If current vertex is an end of sequence, and it'll reset the candidates list. So
- // the next vertices will build candidates lists with the current vertex as 'before'
- // vertex. If it's not an end of sequence, we keep the original 'before' vertex,
- // since we are keeping the candidates list.
- if (endOfSequence)
- stack.push(qMakePair(v, next));
- else
- stack.push(qMakePair(beforeSequence, next));
- }
-
- visited.insert(v);
-
- if (!endOfSequence || candidates.isEmpty())
- continue;
-
- //
- // Create a sequence for (beforeSequence, candidates, afterSequence).
- //
-
- // One restriction we have is to not simplify half of an anchor and let the other half
- // unsimplified. So we remove center edges before and after the sequence.
- const AnchorData *firstAnchor = g.edgeData(beforeSequence, candidates.first());
- if (firstAnchor->isCenterAnchor) {
- beforeSequence = candidates.first();
- candidates.remove(0);
-
- // If there's not candidates to be simplified, leave.
- if (candidates.isEmpty())
- continue;
- }
-
- const AnchorData *lastAnchor = g.edgeData(candidates.last(), afterSequence);
- if (lastAnchor->isCenterAnchor) {
- afterSequence = candidates.last();
- candidates.remove(candidates.count() - 1);
-
- if (candidates.isEmpty())
- continue;
- }
-
- //
- // Add the sequence to the graph.
- //
-
- AnchorData *sequence = createSequence(&g, beforeSequence, candidates, afterSequence);
-
- // If 'beforeSequence' and 'afterSequence' already had an anchor between them, we'll
- // create a parallel anchor between the new sequence and the old anchor.
- bool newFeasible;
- AnchorData *newAnchor = addAnchorMaybeParallel(sequence, &newFeasible);
-
- if (!newFeasible) {
- *feasible = false;
- return false;
- }
-
- // When a new parallel anchor is create in the graph, we finish the iteration and return
- // true to indicate a new iteration is needed. This happens because a parallel anchor
- // changes the number of adjacents one vertex has, possibly opening up oportunities for
- // building candidate lists (when adjacents == 2).
- if (newAnchor != sequence)
- return true;
-
- // If there was no parallel simplification, we'll keep walking the graph. So we clear the
- // candidates list to start again.
- candidates.clear();
- }
-
- return false;
-}
-
-void QGraphicsAnchorLayoutPrivate::restoreSimplifiedAnchor(AnchorData *edge)
-{
-#if 0
- static const char *anchortypes[] = {"Normal",
- "Sequential",
- "Parallel"};
- qDebug("Restoring %s edge.", anchortypes[int(edge->type)]);
-#endif
-
- Graph<AnchorVertex, AnchorData> &g = graph[edge->orientation];
-
- if (edge->type == AnchorData::Normal) {
- g.createEdge(edge->from, edge->to, edge);
-
- } else if (edge->type == AnchorData::Sequential) {
- SequentialAnchorData *sequence = static_cast<SequentialAnchorData *>(edge);
-
- for (int i = 0; i < sequence->m_edges.count(); ++i) {
- AnchorData *data = sequence->m_edges.at(i);
- restoreSimplifiedAnchor(data);
- }
-
- delete sequence;
-
- } else if (edge->type == AnchorData::Parallel) {
-
- // Skip parallel anchors that were created by vertex simplification, they will be processed
- // later, when restoring vertex simplification.
- // ### we could improve this check bit having a bit inside 'edge'
- if (anchorsFromSimplifiedVertices[edge->orientation].contains(edge))
- return;
-
- ParallelAnchorData* parallel = static_cast<ParallelAnchorData*>(edge);
- restoreSimplifiedConstraints(parallel);
-
- // ### Because of the way parallel anchors are created in the anchor simplification
- // algorithm, we know that one of these will be a sequence, so it'll be safe if the other
- // anchor create an edge between the same vertices as the parallel.
- Q_ASSERT(parallel->firstEdge->type == AnchorData::Sequential
- || parallel->secondEdge->type == AnchorData::Sequential);
- restoreSimplifiedAnchor(parallel->firstEdge);
- restoreSimplifiedAnchor(parallel->secondEdge);
-
- delete parallel;
- }
-}
-
-void QGraphicsAnchorLayoutPrivate::restoreSimplifiedConstraints(ParallelAnchorData *parallel)
-{
- if (!parallel->isCenterAnchor)
- return;
-
- for (int i = 0; i < parallel->m_firstConstraints.count(); ++i) {
- QSimplexConstraint *c = parallel->m_firstConstraints.at(i);
- qreal v = c->variables[parallel];
- c->variables.remove(parallel);
- c->variables.insert(parallel->firstEdge, v);
- }
-
- // When restoring, we might have to revert constraints back. See comments on
- // addAnchorMaybeParallel().
- const bool needsReverse = !parallel->secondForward();
-
- for (int i = 0; i < parallel->m_secondConstraints.count(); ++i) {
- QSimplexConstraint *c = parallel->m_secondConstraints.at(i);
- qreal v = c->variables[parallel];
- if (needsReverse)
- v *= -1;
- c->variables.remove(parallel);
- c->variables.insert(parallel->secondEdge, v);
- }
-}
-
-void QGraphicsAnchorLayoutPrivate::restoreSimplifiedGraph(Orientation orientation)
-{
-#if 0
- qDebug("Restoring Simplified Graph for %s",
- orientation == Horizontal ? "Horizontal" : "Vertical");
-#endif
-
- // Restore anchor simplification
- Graph<AnchorVertex, AnchorData> &g = graph[orientation];
- QList<QPair<AnchorVertex*, AnchorVertex*> > connections = g.connections();
- for (int i = 0; i < connections.count(); ++i) {
- AnchorVertex *v1 = connections.at(i).first;
- AnchorVertex *v2 = connections.at(i).second;
- AnchorData *edge = g.edgeData(v1, v2);
-
- // We restore only sequential anchors and parallels that were not created by
- // vertex simplification.
- if (edge->type == AnchorData::Sequential
- || (edge->type == AnchorData::Parallel &&
- !anchorsFromSimplifiedVertices[orientation].contains(edge))) {
-
- g.takeEdge(v1, v2);
- restoreSimplifiedAnchor(edge);
- }
- }
-
- restoreVertices(orientation);
-}
-
-void QGraphicsAnchorLayoutPrivate::restoreVertices(Orientation orientation)
-{
- Q_Q(QGraphicsAnchorLayout);
-
- Graph<AnchorVertex, AnchorData> &g = graph[orientation];
- QList<AnchorVertexPair *> &toRestore = simplifiedVertices[orientation];
-
- // Since we keep a list of parallel anchors and vertices that were created during vertex
- // simplification, we can now iterate on those lists instead of traversing the graph
- // recursively.
-
- // First, restore the constraints changed when we created parallel anchors. Note that this
- // works at this point because the constraints doesn't depend on vertex information and at
- // this point it's always safe to identify whether the second child is forward or backwards.
- // In the next step, we'll change the anchors vertices so that would not be possible anymore.
- QList<AnchorData *> &parallelAnchors = anchorsFromSimplifiedVertices[orientation];
-
- for (int i = parallelAnchors.count() - 1; i >= 0; --i) {
- ParallelAnchorData *parallel = static_cast<ParallelAnchorData *>(parallelAnchors.at(i));
- restoreSimplifiedConstraints(parallel);
- }
-
- // Then, we will restore the vertices in the inverse order of creation, this way we ensure that
- // the vertex being restored was not wrapped by another simplification.
- for (int i = toRestore.count() - 1; i >= 0; --i) {
- AnchorVertexPair *pair = toRestore.at(i);
- QList<AnchorVertex *> adjacents = g.adjacentVertices(pair);
-
- // Restore the removed edge, this will also restore both vertices 'first' and 'second' to
- // the graph structure.
- AnchorVertex *first = pair->m_first;
- AnchorVertex *second = pair->m_second;
- g.createEdge(first, second, pair->m_removedAnchor);
-
- // Restore the anchors for the first child vertex
- for (int j = 0; j < pair->m_firstAnchors.count(); ++j) {
- AnchorData *ad = pair->m_firstAnchors.at(j);
- Q_ASSERT(ad->from == pair || ad->to == pair);
-
- replaceVertex_helper(ad, pair, first);
- g.createEdge(ad->from, ad->to, ad);
- }
-
- // Restore the anchors for the second child vertex
- for (int j = 0; j < pair->m_secondAnchors.count(); ++j) {
- AnchorData *ad = pair->m_secondAnchors.at(j);
- Q_ASSERT(ad->from == pair || ad->to == pair);
-
- replaceVertex_helper(ad, pair, second);
- g.createEdge(ad->from, ad->to, ad);
- }
-
- for (int j = 0; j < adjacents.count(); ++j) {
- g.takeEdge(pair, adjacents.at(j));
- }
-
- // The pair simplified a layout vertex, so place back the correct vertex in the variable
- // that track layout vertices
- if (pair->m_item == q) {
- AnchorVertex *layoutVertex = first->m_item == q ? first : second;
- Q_ASSERT(layoutVertex->m_item == q);
- changeLayoutVertex(orientation, pair, layoutVertex);
- }
-
- delete pair;
- }
- qDeleteAll(parallelAnchors);
- parallelAnchors.clear();
- toRestore.clear();
-}
-
-QGraphicsAnchorLayoutPrivate::Orientation
-QGraphicsAnchorLayoutPrivate::edgeOrientation(Qt::AnchorPoint edge)
-{
- return edge > Qt::AnchorRight ? Vertical : Horizontal;
-}
-
-/*!
- \internal
-
- Create internal anchors to connect the layout edges (Left to Right and
- Top to Bottom).
-
- These anchors doesn't have size restrictions, that will be enforced by
- other anchors and items in the layout.
-*/
-void QGraphicsAnchorLayoutPrivate::createLayoutEdges()
-{
- Q_Q(QGraphicsAnchorLayout);
- QGraphicsLayoutItem *layout = q;
-
- // Horizontal
- AnchorData *data = new AnchorData;
- addAnchor_helper(layout, Qt::AnchorLeft, layout,
- Qt::AnchorRight, data);
- data->maxSize = QWIDGETSIZE_MAX;
-
- // Save a reference to layout vertices
- layoutFirstVertex[Horizontal] = internalVertex(layout, Qt::AnchorLeft);
- layoutCentralVertex[Horizontal] = 0;
- layoutLastVertex[Horizontal] = internalVertex(layout, Qt::AnchorRight);
-
- // Vertical
- data = new AnchorData;
- addAnchor_helper(layout, Qt::AnchorTop, layout,
- Qt::AnchorBottom, data);
- data->maxSize = QWIDGETSIZE_MAX;
-
- // Save a reference to layout vertices
- layoutFirstVertex[Vertical] = internalVertex(layout, Qt::AnchorTop);
- layoutCentralVertex[Vertical] = 0;
- layoutLastVertex[Vertical] = internalVertex(layout, Qt::AnchorBottom);
-}
-
-void QGraphicsAnchorLayoutPrivate::deleteLayoutEdges()
-{
- Q_Q(QGraphicsAnchorLayout);
-
- Q_ASSERT(!internalVertex(q, Qt::AnchorHorizontalCenter));
- Q_ASSERT(!internalVertex(q, Qt::AnchorVerticalCenter));
-
- removeAnchor_helper(internalVertex(q, Qt::AnchorLeft),
- internalVertex(q, Qt::AnchorRight));
- removeAnchor_helper(internalVertex(q, Qt::AnchorTop),
- internalVertex(q, Qt::AnchorBottom));
-}
-
-void QGraphicsAnchorLayoutPrivate::createItemEdges(QGraphicsLayoutItem *item)
-{
- items.append(item);
-
- // Create horizontal and vertical internal anchors for the item and
- // refresh its size hint / policy values.
- AnchorData *data = new AnchorData;
- addAnchor_helper(item, Qt::AnchorLeft, item, Qt::AnchorRight, data);
- data->refreshSizeHints();
-
- data = new AnchorData;
- addAnchor_helper(item, Qt::AnchorTop, item, Qt::AnchorBottom, data);
- data->refreshSizeHints();
-}
-
-/*!
- \internal
-
- By default, each item in the layout is represented internally as
- a single anchor in each direction. For instance, from Left to Right.
-
- However, to support anchorage of items to the center of items, we
- must split this internal anchor into two half-anchors. From Left
- to Center and then from Center to Right, with the restriction that
- these anchors must have the same time at all times.
-*/
-void QGraphicsAnchorLayoutPrivate::createCenterAnchors(
- QGraphicsLayoutItem *item, Qt::AnchorPoint centerEdge)
-{
- Q_Q(QGraphicsAnchorLayout);
-
- Orientation orientation;
- switch (centerEdge) {
- case Qt::AnchorHorizontalCenter:
- orientation = Horizontal;
- break;
- case Qt::AnchorVerticalCenter:
- orientation = Vertical;
- break;
- default:
- // Don't create center edges unless needed
- return;
- }
-
- // Check if vertex already exists
- if (internalVertex(item, centerEdge))
- return;
-
- // Orientation code
- Qt::AnchorPoint firstEdge;
- Qt::AnchorPoint lastEdge;
-
- if (orientation == Horizontal) {
- firstEdge = Qt::AnchorLeft;
- lastEdge = Qt::AnchorRight;
- } else {
- firstEdge = Qt::AnchorTop;
- lastEdge = Qt::AnchorBottom;
- }
-
- AnchorVertex *first = internalVertex(item, firstEdge);
- AnchorVertex *last = internalVertex(item, lastEdge);
- Q_ASSERT(first && last);
-
- // Create new anchors
- QSimplexConstraint *c = new QSimplexConstraint;
-
- AnchorData *data = new AnchorData;
- c->variables.insert(data, 1.0);
- addAnchor_helper(item, firstEdge, item, centerEdge, data);
- data->isCenterAnchor = true;
- data->dependency = AnchorData::Master;
- data->refreshSizeHints();
-
- data = new AnchorData;
- c->variables.insert(data, -1.0);
- addAnchor_helper(item, centerEdge, item, lastEdge, data);
- data->isCenterAnchor = true;
- data->dependency = AnchorData::Slave;
- data->refreshSizeHints();
-
- itemCenterConstraints[orientation].append(c);
-
- // Remove old one
- removeAnchor_helper(first, last);
-
- if (item == q) {
- layoutCentralVertex[orientation] = internalVertex(q, centerEdge);
- }
-}
-
-void QGraphicsAnchorLayoutPrivate::removeCenterAnchors(
- QGraphicsLayoutItem *item, Qt::AnchorPoint centerEdge,
- bool substitute)
-{
- Q_Q(QGraphicsAnchorLayout);
-
- Orientation orientation;
- switch (centerEdge) {
- case Qt::AnchorHorizontalCenter:
- orientation = Horizontal;
- break;
- case Qt::AnchorVerticalCenter:
- orientation = Vertical;
- break;
- default:
- // Don't remove edges that not the center ones
- return;
- }
-
- // Orientation code
- Qt::AnchorPoint firstEdge;
- Qt::AnchorPoint lastEdge;
-
- if (orientation == Horizontal) {
- firstEdge = Qt::AnchorLeft;
- lastEdge = Qt::AnchorRight;
- } else {
- firstEdge = Qt::AnchorTop;
- lastEdge = Qt::AnchorBottom;
- }
-
- AnchorVertex *center = internalVertex(item, centerEdge);
- if (!center)
- return;
- AnchorVertex *first = internalVertex(item, firstEdge);
-
- Q_ASSERT(first);
- Q_ASSERT(center);
-
- Graph<AnchorVertex, AnchorData> &g = graph[orientation];
-
-
- AnchorData *oldData = g.edgeData(first, center);
- // Remove center constraint
- for (int i = itemCenterConstraints[orientation].count() - 1; i >= 0; --i) {
- if (itemCenterConstraints[orientation].at(i)->variables.contains(oldData)) {
- delete itemCenterConstraints[orientation].takeAt(i);
- break;
- }
- }
-
- if (substitute) {
- // Create the new anchor that should substitute the left-center-right anchors.
- AnchorData *data = new AnchorData;
- addAnchor_helper(item, firstEdge, item, lastEdge, data);
- data->refreshSizeHints();
-
- // Remove old anchors
- removeAnchor_helper(first, center);
- removeAnchor_helper(center, internalVertex(item, lastEdge));
-
- } else {
- // this is only called from removeAnchors()
- // first, remove all non-internal anchors
- QList<AnchorVertex*> adjacents = g.adjacentVertices(center);
- for (int i = 0; i < adjacents.count(); ++i) {
- AnchorVertex *v = adjacents.at(i);
- if (v->m_item != item) {
- removeAnchor_helper(center, internalVertex(v->m_item, v->m_edge));
- }
- }
- // when all non-internal anchors is removed it will automatically merge the
- // center anchor into a left-right (or top-bottom) anchor. We must also delete that.
- // by this time, the center vertex is deleted and merged into a non-centered internal anchor
- removeAnchor_helper(first, internalVertex(item, lastEdge));
- }
-
- if (item == q) {
- layoutCentralVertex[orientation] = 0;
- }
-}
-
-
-void QGraphicsAnchorLayoutPrivate::removeCenterConstraints(QGraphicsLayoutItem *item,
- Orientation orientation)
-{
- // Remove the item center constraints associated to this item
- // ### This is a temporary solution. We should probably use a better
- // data structure to hold items and/or their associated constraints
- // so that we can remove those easily
-
- AnchorVertex *first = internalVertex(item, orientation == Horizontal ?
- Qt::AnchorLeft :
- Qt::AnchorTop);
- AnchorVertex *center = internalVertex(item, orientation == Horizontal ?
- Qt::AnchorHorizontalCenter :
- Qt::AnchorVerticalCenter);
-
- // Skip if no center constraints exist
- if (!center)
- return;
-
- Q_ASSERT(first);
- AnchorData *internalAnchor = graph[orientation].edgeData(first, center);
-
- // Look for our anchor in all item center constraints, then remove it
- for (int i = 0; i < itemCenterConstraints[orientation].size(); ++i) {
- if (itemCenterConstraints[orientation].at(i)->variables.contains(internalAnchor)) {
- delete itemCenterConstraints[orientation].takeAt(i);
- break;
- }
- }
-}
-
-/*!
- * \internal
- * Implements the high level "addAnchor" feature. Called by the public API
- * addAnchor method.
- *
- * The optional \a spacing argument defines the size of the anchor. If not provided,
- * the anchor size is either 0 or not-set, depending on type of anchor created (see
- * matrix below).
- *
- * All anchors that remain with size not-set will assume the standard spacing,
- * set either by the layout style or through the "setSpacing" layout API.
- */
-QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::addAnchor(QGraphicsLayoutItem *firstItem,
- Qt::AnchorPoint firstEdge,
- QGraphicsLayoutItem *secondItem,
- Qt::AnchorPoint secondEdge,
- qreal *spacing)
-{
- Q_Q(QGraphicsAnchorLayout);
- if ((firstItem == 0) || (secondItem == 0)) {
- qWarning("QGraphicsAnchorLayout::addAnchor(): "
- "Cannot anchor NULL items");
- return 0;
- }
-
- if (firstItem == secondItem) {
- qWarning("QGraphicsAnchorLayout::addAnchor(): "
- "Cannot anchor the item to itself");
- return 0;
- }
-
- if (edgeOrientation(secondEdge) != edgeOrientation(firstEdge)) {
- qWarning("QGraphicsAnchorLayout::addAnchor(): "
- "Cannot anchor edges of different orientations");
- return 0;
- }
-
- const QGraphicsLayoutItem *parentWidget = q->parentLayoutItem();
- if (firstItem == parentWidget || secondItem == parentWidget) {
- qWarning("QGraphicsAnchorLayout::addAnchor(): "
- "You cannot add the parent of the layout to the layout.");
- return 0;
- }
-
- // In QGraphicsAnchorLayout, items are represented in its internal
- // graph as four anchors that connect:
- // - Left -> HCenter
- // - HCenter-> Right
- // - Top -> VCenter
- // - VCenter -> Bottom
-
- // Ensure that the internal anchors have been created for both items.
- if (firstItem != q && !items.contains(firstItem)) {
- createItemEdges(firstItem);
- addChildLayoutItem(firstItem);
- }
- if (secondItem != q && !items.contains(secondItem)) {
- createItemEdges(secondItem);
- addChildLayoutItem(secondItem);
- }
-
- // Create center edges if needed
- createCenterAnchors(firstItem, firstEdge);
- createCenterAnchors(secondItem, secondEdge);
-
- // Use heuristics to find out what the user meant with this anchor.
- correctEdgeDirection(firstItem, firstEdge, secondItem, secondEdge);
-
- AnchorData *data = new AnchorData;
- QGraphicsAnchor *graphicsAnchor = acquireGraphicsAnchor(data);
-
- addAnchor_helper(firstItem, firstEdge, secondItem, secondEdge, data);
-
- if (spacing) {
- graphicsAnchor->setSpacing(*spacing);
- } else {
- // If firstItem or secondItem is the layout itself, the spacing will default to 0.
- // Otherwise, the following matrix is used (questionmark means that the spacing
- // is queried from the style):
- // from
- // to Left HCenter Right
- // Left 0 0 ?
- // HCenter 0 0 0
- // Right ? 0 0
- if (firstItem == q
- || secondItem == q
- || pickEdge(firstEdge, Horizontal) == Qt::AnchorHorizontalCenter
- || oppositeEdge(firstEdge) != secondEdge) {
- graphicsAnchor->setSpacing(0);
- } else {
- graphicsAnchor->unsetSpacing();
- }
- }
-
- return graphicsAnchor;
-}
-
-/*
- \internal
-
- This method adds an AnchorData to the internal graph. It is responsible for doing
- the boilerplate part of such task.
-
- If another AnchorData exists between the mentioned vertices, it is deleted and
- the new one is inserted.
-*/
-void QGraphicsAnchorLayoutPrivate::addAnchor_helper(QGraphicsLayoutItem *firstItem,
- Qt::AnchorPoint firstEdge,
- QGraphicsLayoutItem *secondItem,
- Qt::AnchorPoint secondEdge,
- AnchorData *data)
-{
- Q_Q(QGraphicsAnchorLayout);
-
- const Orientation orientation = edgeOrientation(firstEdge);
-
- // Create or increase the reference count for the related vertices.
- AnchorVertex *v1 = addInternalVertex(firstItem, firstEdge);
- AnchorVertex *v2 = addInternalVertex(secondItem, secondEdge);
-
- // Remove previous anchor
- if (graph[orientation].edgeData(v1, v2)) {
- removeAnchor_helper(v1, v2);
- }
-
- // If its an internal anchor, set the associated item
- if (firstItem == secondItem)
- data->item = firstItem;
-
- data->orientation = orientation;
-
- // Create a bi-directional edge in the sense it can be transversed both
- // from v1 or v2. "data" however is shared between the two references
- // so we still know that the anchor direction is from 1 to 2.
- data->from = v1;
- data->to = v2;
-#ifdef QT_DEBUG
- data->name = QString::fromAscii("%1 --to--> %2").arg(v1->toString()).arg(v2->toString());
-#endif
- // ### bit to track internal anchors, since inside AnchorData methods
- // we don't have access to the 'q' pointer.
- data->isLayoutAnchor = (data->item == q);
-
- graph[orientation].createEdge(v1, v2, data);
-}
-
-QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::getAnchor(QGraphicsLayoutItem *firstItem,
- Qt::AnchorPoint firstEdge,
- QGraphicsLayoutItem *secondItem,
- Qt::AnchorPoint secondEdge)
-{
- // Do not expose internal anchors
- if (firstItem == secondItem)
- return 0;
-
- const Orientation orientation = edgeOrientation(firstEdge);
- AnchorVertex *v1 = internalVertex(firstItem, firstEdge);
- AnchorVertex *v2 = internalVertex(secondItem, secondEdge);
-
- QGraphicsAnchor *graphicsAnchor = 0;
-
- AnchorData *data = graph[orientation].edgeData(v1, v2);
- if (data) {
- // We could use "acquireGraphicsAnchor" here, but to avoid a regression where
- // an internal anchor was wrongly exposed, I want to ensure no new
- // QGraphicsAnchor instances are created by this call.
- // This assumption must hold because anchors are either user-created (and already
- // have their public object created), or they are internal (and must not reach
- // this point).
- Q_ASSERT(data->graphicsAnchor);
- graphicsAnchor = data->graphicsAnchor;
- }
- return graphicsAnchor;
-}
-
-/*!
- * \internal
- *
- * Implements the high level "removeAnchor" feature. Called by
- * the QAnchorData destructor.
- */
-void QGraphicsAnchorLayoutPrivate::removeAnchor(AnchorVertex *firstVertex,
- AnchorVertex *secondVertex)
-{
- Q_Q(QGraphicsAnchorLayout);
-
- // Save references to items while it's safe to assume the vertices exist
- QGraphicsLayoutItem *firstItem = firstVertex->m_item;
- QGraphicsLayoutItem *secondItem = secondVertex->m_item;
-
- // Delete the anchor (may trigger deletion of center vertices)
- removeAnchor_helper(firstVertex, secondVertex);
-
- // Ensure no dangling pointer is left behind
- firstVertex = secondVertex = 0;
-
- // Checking if the item stays in the layout or not
- bool keepFirstItem = false;
- bool keepSecondItem = false;
-
- QPair<AnchorVertex *, int> v;
- int refcount = -1;
-
- if (firstItem != q) {
- for (int i = Qt::AnchorLeft; i <= Qt::AnchorBottom; ++i) {
- v = m_vertexList.value(qMakePair(firstItem, static_cast<Qt::AnchorPoint>(i)));
- if (v.first) {
- if (i == Qt::AnchorHorizontalCenter || i == Qt::AnchorVerticalCenter)
- refcount = 2;
- else
- refcount = 1;
-
- if (v.second > refcount) {
- keepFirstItem = true;
- break;
- }
- }
- }
- } else
- keepFirstItem = true;
-
- if (secondItem != q) {
- for (int i = Qt::AnchorLeft; i <= Qt::AnchorBottom; ++i) {
- v = m_vertexList.value(qMakePair(secondItem, static_cast<Qt::AnchorPoint>(i)));
- if (v.first) {
- if (i == Qt::AnchorHorizontalCenter || i == Qt::AnchorVerticalCenter)
- refcount = 2;
- else
- refcount = 1;
-
- if (v.second > refcount) {
- keepSecondItem = true;
- break;
- }
- }
- }
- } else
- keepSecondItem = true;
-
- if (!keepFirstItem)
- q->removeAt(items.indexOf(firstItem));
-
- if (!keepSecondItem)
- q->removeAt(items.indexOf(secondItem));
-
- // Removing anchors invalidates the layout
- q->invalidate();
-}
-
-/*
- \internal
-
- Implements the low level "removeAnchor" feature. Called by
- private methods.
-*/
-void QGraphicsAnchorLayoutPrivate::removeAnchor_helper(AnchorVertex *v1, AnchorVertex *v2)
-{
- Q_ASSERT(v1 && v2);
-
- // Remove edge from graph
- const Orientation o = edgeOrientation(v1->m_edge);
- graph[o].removeEdge(v1, v2);
-
- // Decrease vertices reference count (may trigger a deletion)
- removeInternalVertex(v1->m_item, v1->m_edge);
- removeInternalVertex(v2->m_item, v2->m_edge);
-}
-
-AnchorVertex *QGraphicsAnchorLayoutPrivate::addInternalVertex(QGraphicsLayoutItem *item,
- Qt::AnchorPoint edge)
-{
- QPair<QGraphicsLayoutItem *, Qt::AnchorPoint> pair(item, edge);
- QPair<AnchorVertex *, int> v = m_vertexList.value(pair);
-
- if (!v.first) {
- Q_ASSERT(v.second == 0);
- v.first = new AnchorVertex(item, edge);
- }
- v.second++;
- m_vertexList.insert(pair, v);
- return v.first;
-}
-
-/**
- * \internal
- *
- * returns the AnchorVertex that was dereferenced, also when it was removed.
- * returns 0 if it did not exist.
- */
-void QGraphicsAnchorLayoutPrivate::removeInternalVertex(QGraphicsLayoutItem *item,
- Qt::AnchorPoint edge)
-{
- QPair<QGraphicsLayoutItem *, Qt::AnchorPoint> pair(item, edge);
- QPair<AnchorVertex *, int> v = m_vertexList.value(pair);
-
- if (!v.first) {
- qWarning("This item with this edge is not in the graph");
- return;
- }
-
- v.second--;
- if (v.second == 0) {
- // Remove reference and delete vertex
- m_vertexList.remove(pair);
- delete v.first;
- } else {
- // Update reference count
- m_vertexList.insert(pair, v);
-
- if ((v.second == 2) &&
- ((edge == Qt::AnchorHorizontalCenter) ||
- (edge == Qt::AnchorVerticalCenter))) {
- removeCenterAnchors(item, edge, true);
- }
- }
-}
-
-void QGraphicsAnchorLayoutPrivate::removeVertex(QGraphicsLayoutItem *item, Qt::AnchorPoint edge)
-{
- if (AnchorVertex *v = internalVertex(item, edge)) {
- Graph<AnchorVertex, AnchorData> &g = graph[edgeOrientation(edge)];
- const QList<AnchorVertex *> allVertices = graph[edgeOrientation(edge)].adjacentVertices(v);
- AnchorVertex *v2;
- foreach (v2, allVertices) {
- g.removeEdge(v, v2);
- removeInternalVertex(item, edge);
- removeInternalVertex(v2->m_item, v2->m_edge);
- }
- }
-}
-
-void QGraphicsAnchorLayoutPrivate::removeAnchors(QGraphicsLayoutItem *item)
-{
- // remove the center anchor first!!
- removeCenterAnchors(item, Qt::AnchorHorizontalCenter, false);
- removeVertex(item, Qt::AnchorLeft);
- removeVertex(item, Qt::AnchorRight);
-
- removeCenterAnchors(item, Qt::AnchorVerticalCenter, false);
- removeVertex(item, Qt::AnchorTop);
- removeVertex(item, Qt::AnchorBottom);
-}
-
-/*!
- \internal
-
- Use heuristics to determine the correct orientation of a given anchor.
-
- After API discussions, we decided we would like expressions like
- anchor(A, Left, B, Right) to mean the same as anchor(B, Right, A, Left).
- The problem with this is that anchors could become ambiguous, for
- instance, what does the anchor A, B of size X mean?
-
- "pos(B) = pos(A) + X" or "pos(A) = pos(B) + X" ?
-
- To keep the API user friendly and at the same time, keep our algorithm
- deterministic, we use an heuristic to determine a direction for each
- added anchor and then keep it. The heuristic is based on the fact
- that people usually avoid overlapping items, therefore:
-
- "A, RIGHT to B, LEFT" means that B is to the LEFT of A.
- "B, LEFT to A, RIGHT" is corrected to the above anchor.
-
- Special correction is also applied when one of the items is the
- layout. We handle Layout Left as if it was another items's Right
- and Layout Right as another item's Left.
-*/
-void QGraphicsAnchorLayoutPrivate::correctEdgeDirection(QGraphicsLayoutItem *&firstItem,
- Qt::AnchorPoint &firstEdge,
- QGraphicsLayoutItem *&secondItem,
- Qt::AnchorPoint &secondEdge)
-{
- Q_Q(QGraphicsAnchorLayout);
-
- if ((firstItem != q) && (secondItem != q)) {
- // If connection is between widgets (not the layout itself)
- // Ensure that "right-edges" sit to the left of "left-edges".
- if (firstEdge < secondEdge) {
- qSwap(firstItem, secondItem);
- qSwap(firstEdge, secondEdge);
- }
- } else if (firstItem == q) {
- // If connection involves the right or bottom of a layout, ensure
- // the layout is the second item.
- if ((firstEdge == Qt::AnchorRight) || (firstEdge == Qt::AnchorBottom)) {
- qSwap(firstItem, secondItem);
- qSwap(firstEdge, secondEdge);
- }
- } else if ((secondEdge != Qt::AnchorRight) && (secondEdge != Qt::AnchorBottom)) {
- // If connection involves the left, center or top of layout, ensure
- // the layout is the first item.
- qSwap(firstItem, secondItem);
- qSwap(firstEdge, secondEdge);
- }
-}
-
-QLayoutStyleInfo &QGraphicsAnchorLayoutPrivate::styleInfo() const
-{
- if (styleInfoDirty) {
- Q_Q(const QGraphicsAnchorLayout);
- //### Fix this if QGV ever gets support for Metal style or different Aqua sizes.
- QWidget *wid = 0;
-
- QGraphicsLayoutItem *parent = q->parentLayoutItem();
- while (parent && parent->isLayout()) {
- parent = parent->parentLayoutItem();
- }
- QGraphicsWidget *w = 0;
- if (parent) {
- QGraphicsItem *parentItem = parent->graphicsItem();
- if (parentItem && parentItem->isWidget())
- w = static_cast<QGraphicsWidget*>(parentItem);
- }
-
- QStyle *style = w ? w->style() : QApplication::style();
- cachedStyleInfo = QLayoutStyleInfo(style, wid);
- cachedStyleInfo.setDefaultSpacing(Qt::Horizontal, spacings[0]);
- cachedStyleInfo.setDefaultSpacing(Qt::Vertical, spacings[1]);
-
- styleInfoDirty = false;
- }
- return cachedStyleInfo;
-}
-
-/*!
- \internal
-
- Called on activation. Uses Linear Programming to define minimum, preferred
- and maximum sizes for the layout. Also calculates the sizes that each item
- should assume when the layout is in one of such situations.
-*/
-void QGraphicsAnchorLayoutPrivate::calculateGraphs()
-{
- if (!calculateGraphCacheDirty)
- return;
- calculateGraphs(Horizontal);
- calculateGraphs(Vertical);
- calculateGraphCacheDirty = false;
-}
-
-// ### Maybe getGraphParts could return the variables when traversing, at least
-// for trunk...
-QList<AnchorData *> getVariables(QList<QSimplexConstraint *> constraints)
-{
- QSet<AnchorData *> variableSet;
- for (int i = 0; i < constraints.count(); ++i) {
- const QSimplexConstraint *c = constraints.at(i);
- foreach (QSimplexVariable *var, c->variables.keys()) {
- variableSet += static_cast<AnchorData *>(var);
- }
- }
- return variableSet.toList();
-}
-
-/*!
- \internal
-
- Calculate graphs is the method that puts together all the helper routines
- so that the AnchorLayout can calculate the sizes of each item.
-
- In a nutshell it should do:
-
- 1) Refresh anchor nominal sizes, that is, the size that each anchor would
- have if no other restrictions applied. This is done by quering the
- layout style and the sizeHints of the items belonging to the layout.
-
- 2) Simplify the graph by grouping together parallel and sequential anchors
- into "group anchors". These have equivalent minimum, preferred and maximum
- sizeHints as the anchors they replace.
-
- 3) Check if we got to a trivial case. In some cases, the whole graph can be
- simplified into a single anchor. If so, use this information. If not,
- then call the Simplex solver to calculate the anchors sizes.
-
- 4) Once the root anchors had its sizes calculated, propagate that to the
- anchors they represent.
-*/
-void QGraphicsAnchorLayoutPrivate::calculateGraphs(
- QGraphicsAnchorLayoutPrivate::Orientation orientation)
-{
-#if defined(QT_DEBUG) || defined(Q_AUTOTEST_EXPORT)
- lastCalculationUsedSimplex[orientation] = false;
-#endif
-
- static bool simplificationEnabled = qgetenv("QT_ANCHORLAYOUT_NO_SIMPLIFICATION").isEmpty();
-
- // Reset the nominal sizes of each anchor based on the current item sizes
- refreshAllSizeHints(orientation);
-
- // Simplify the graph
- if (simplificationEnabled && !simplifyGraph(orientation)) {
- qWarning("QGraphicsAnchorLayout: anchor setup is not feasible.");
- graphHasConflicts[orientation] = true;
- return;
- }
-
- // Traverse all graph edges and store the possible paths to each vertex
- findPaths(orientation);
-
- // From the paths calculated above, extract the constraints that the current
- // anchor setup impose, to our Linear Programming problem.
- constraintsFromPaths(orientation);
-
- // Split the constraints and anchors into groups that should be fed to the
- // simplex solver independently. Currently we find two groups:
- //
- // 1) The "trunk", that is, the set of anchors (items) that are connected
- // to the two opposite sides of our layout, and thus need to stretch in
- // order to fit in the current layout size.
- //
- // 2) The floating or semi-floating anchors (items) that are those which
- // are connected to only one (or none) of the layout sides, thus are not
- // influenced by the layout size.
- QList<QList<QSimplexConstraint *> > parts = getGraphParts(orientation);
-
- // Now run the simplex solver to calculate Minimum, Preferred and Maximum sizes
- // of the "trunk" set of constraints and variables.
- // ### does trunk always exist? empty = trunk is the layout left->center->right
- QList<QSimplexConstraint *> trunkConstraints = parts.at(0);
- QList<AnchorData *> trunkVariables = getVariables(trunkConstraints);
-
- // For minimum and maximum, use the path between the two layout sides as the
- // objective function.
- AnchorVertex *v = layoutLastVertex[orientation];
- GraphPath trunkPath = graphPaths[orientation].value(v);
-
- bool feasible = calculateTrunk(orientation, trunkPath, trunkConstraints, trunkVariables);
-
- // For the other parts that not the trunk, solve only for the preferred size
- // that is the size they will remain at, since they are not stretched by the
- // layout.
-
- // Skipping the first (trunk)
- for (int i = 1; i < parts.count(); ++i) {
- if (!feasible)
- break;
-
- QList<QSimplexConstraint *> partConstraints = parts.at(i);
- QList<AnchorData *> partVariables = getVariables(partConstraints);
- Q_ASSERT(!partVariables.isEmpty());
- feasible &= calculateNonTrunk(partConstraints, partVariables);
- }
-
- // Propagate the new sizes down the simplified graph, ie. tell the
- // group anchors to set their children anchors sizes.
- updateAnchorSizes(orientation);
-
- graphHasConflicts[orientation] = !feasible;
-
- // Clean up our data structures. They are not needed anymore since
- // distribution uses just interpolation.
- qDeleteAll(constraints[orientation]);
- constraints[orientation].clear();
- graphPaths[orientation].clear(); // ###
-
- if (simplificationEnabled)
- restoreSimplifiedGraph(orientation);
-}
-
-/*!
- \internal
-
- Shift all the constraints by a certain amount. This allows us to deal with negative values in
- the linear program if they are bounded by a certain limit. Functions should be careful to
- call it again with a negative amount, to shift the constraints back.
-*/
-static void shiftConstraints(const QList<QSimplexConstraint *> &constraints, qreal amount)
-{
- for (int i = 0; i < constraints.count(); ++i) {
- QSimplexConstraint *c = constraints.at(i);
- qreal multiplier = 0;
- foreach (qreal v, c->variables.values()) {
- multiplier += v;
- }
- c->constant += multiplier * amount;
- }
-}
-
-/*!
- \internal
-
- Calculate the sizes for all anchors which are part of the trunk. This works
- on top of a (possibly) simplified graph.
-*/
-bool QGraphicsAnchorLayoutPrivate::calculateTrunk(Orientation orientation, const GraphPath &path,
- const QList<QSimplexConstraint *> &constraints,
- const QList<AnchorData *> &variables)
-{
- bool feasible = true;
- bool needsSimplex = !constraints.isEmpty();
-
-#if 0
- qDebug("Simplex %s for trunk of %s", needsSimplex ? "used" : "NOT used",
- orientation == Horizontal ? "Horizontal" : "Vertical");
-#endif
-
- if (needsSimplex) {
-
- QList<QSimplexConstraint *> sizeHintConstraints = constraintsFromSizeHints(variables);
- QList<QSimplexConstraint *> allConstraints = constraints + sizeHintConstraints;
-
- shiftConstraints(allConstraints, g_offset);
-
- // Solve min and max size hints
- qreal min, max;
- feasible = solveMinMax(allConstraints, path, &min, &max);
-
- if (feasible) {
- solvePreferred(constraints, variables);
-
- // Calculate and set the preferred size for the layout,
- // from the edge sizes that were calculated above.
- qreal pref(0.0);
- foreach (const AnchorData *ad, path.positives) {
- pref += ad->sizeAtPreferred;
- }
- foreach (const AnchorData *ad, path.negatives) {
- pref -= ad->sizeAtPreferred;
- }
-
- sizeHints[orientation][Qt::MinimumSize] = min;
- sizeHints[orientation][Qt::PreferredSize] = pref;
- sizeHints[orientation][Qt::MaximumSize] = max;
- }
-
- qDeleteAll(sizeHintConstraints);
- shiftConstraints(constraints, -g_offset);
-
- } else {
- // No Simplex is necessary because the path was simplified all the way to a single
- // anchor.
- Q_ASSERT(path.positives.count() == 1);
- Q_ASSERT(path.negatives.count() == 0);
-
- AnchorData *ad = path.positives.toList()[0];
- ad->sizeAtMinimum = ad->minSize;
- ad->sizeAtPreferred = ad->prefSize;
- ad->sizeAtMaximum = ad->maxSize;
-
- sizeHints[orientation][Qt::MinimumSize] = ad->sizeAtMinimum;
- sizeHints[orientation][Qt::PreferredSize] = ad->sizeAtPreferred;
- sizeHints[orientation][Qt::MaximumSize] = ad->sizeAtMaximum;
- }
-
-#if defined(QT_DEBUG) || defined(Q_AUTOTEST_EXPORT)
- lastCalculationUsedSimplex[orientation] = needsSimplex;
-#endif
-
- return feasible;
-}
-
-/*!
- \internal
-*/
-bool QGraphicsAnchorLayoutPrivate::calculateNonTrunk(const QList<QSimplexConstraint *> &constraints,
- const QList<AnchorData *> &variables)
-{
- shiftConstraints(constraints, g_offset);
- bool feasible = solvePreferred(constraints, variables);
-
- if (feasible) {
- // Propagate size at preferred to other sizes. Semi-floats always will be
- // in their sizeAtPreferred.
- for (int j = 0; j < variables.count(); ++j) {
- AnchorData *ad = variables.at(j);
- Q_ASSERT(ad);
- ad->sizeAtMinimum = ad->sizeAtPreferred;
- ad->sizeAtMaximum = ad->sizeAtPreferred;
- }
- }
-
- shiftConstraints(constraints, -g_offset);
- return feasible;
-}
-
-/*!
- \internal
-
- Traverse the graph refreshing the size hints. Edges will query their associated
- item or graphicsAnchor for their size hints.
-*/
-void QGraphicsAnchorLayoutPrivate::refreshAllSizeHints(Orientation orientation)
-{
- Graph<AnchorVertex, AnchorData> &g = graph[orientation];
- QList<QPair<AnchorVertex *, AnchorVertex *> > vertices = g.connections();
-
- QLayoutStyleInfo styleInf = styleInfo();
- for (int i = 0; i < vertices.count(); ++i) {
- AnchorData *data = g.edgeData(vertices.at(i).first, vertices.at(i).second);
- data->refreshSizeHints(&styleInf);
- }
-}
-
-/*!
- \internal
-
- This method walks the graph using a breadth-first search to find paths
- between the root vertex and each vertex on the graph. The edges
- directions in each path are considered and they are stored as a
- positive edge (left-to-right) or negative edge (right-to-left).
-
- The list of paths is used later to generate a list of constraints.
- */
-void QGraphicsAnchorLayoutPrivate::findPaths(Orientation orientation)
-{
- QQueue<QPair<AnchorVertex *, AnchorVertex *> > queue;
-
- QSet<AnchorData *> visited;
-
- AnchorVertex *root = layoutFirstVertex[orientation];
-
- graphPaths[orientation].insert(root, GraphPath());
-
- foreach (AnchorVertex *v, graph[orientation].adjacentVertices(root)) {
- queue.enqueue(qMakePair(root, v));
- }
-
- while(!queue.isEmpty()) {
- QPair<AnchorVertex *, AnchorVertex *> pair = queue.dequeue();
- AnchorData *edge = graph[orientation].edgeData(pair.first, pair.second);
-
- if (visited.contains(edge))
- continue;
-
- visited.insert(edge);
- GraphPath current = graphPaths[orientation].value(pair.first);
-
- if (edge->from == pair.first)
- current.positives.insert(edge);
- else
- current.negatives.insert(edge);
-
- graphPaths[orientation].insert(pair.second, current);
-
- foreach (AnchorVertex *v,
- graph[orientation].adjacentVertices(pair.second)) {
- queue.enqueue(qMakePair(pair.second, v));
- }
- }
-
- // We will walk through every reachable items (non-float) store them in a temporary set.
- // We them create a set of all items and subtract the non-floating items from the set in
- // order to get the floating items. The floating items is then stored in m_floatItems
- identifyFloatItems(visited, orientation);
-}
-
-/*!
- \internal
-
- Each vertex on the graph that has more than one path to it
- represents a contra int to the sizes of the items in these paths.
-
- This method walks the list of paths to each vertex, generate
- the constraints and store them in a list so they can be used later
- by the Simplex solver.
-*/
-void QGraphicsAnchorLayoutPrivate::constraintsFromPaths(Orientation orientation)
-{
- foreach (AnchorVertex *vertex, graphPaths[orientation].uniqueKeys())
- {
- int valueCount = graphPaths[orientation].count(vertex);
- if (valueCount == 1)
- continue;
-
- QList<GraphPath> pathsToVertex = graphPaths[orientation].values(vertex);
- for (int i = 1; i < valueCount; ++i) {
- constraints[orientation] += \
- pathsToVertex[0].constraint(pathsToVertex.at(i));
- }
- }
-}
-
-/*!
- \internal
-*/
-void QGraphicsAnchorLayoutPrivate::updateAnchorSizes(Orientation orientation)
-{
- Graph<AnchorVertex, AnchorData> &g = graph[orientation];
- const QList<QPair<AnchorVertex *, AnchorVertex *> > &vertices = g.connections();
-
- for (int i = 0; i < vertices.count(); ++i) {
- AnchorData *ad = g.edgeData(vertices.at(i).first, vertices.at(i).second);
- ad->updateChildrenSizes();
- }
-}
-
-/*!
- \internal
-
- Create LP constraints for each anchor based on its minimum and maximum
- sizes, as specified in its size hints
-*/
-QList<QSimplexConstraint *> QGraphicsAnchorLayoutPrivate::constraintsFromSizeHints(
- const QList<AnchorData *> &anchors)
-{
- if (anchors.isEmpty())
- return QList<QSimplexConstraint *>();
-
- // Look for the layout edge. That can be either the first half in case the
- // layout is split in two, or the whole layout anchor.
- Orientation orient = Orientation(anchors.first()->orientation);
- AnchorData *layoutEdge = 0;
- if (layoutCentralVertex[orient]) {
- layoutEdge = graph[orient].edgeData(layoutFirstVertex[orient], layoutCentralVertex[orient]);
- } else {
- layoutEdge = graph[orient].edgeData(layoutFirstVertex[orient], layoutLastVertex[orient]);
- }
-
- // If maxSize is less then "infinite", that means there are other anchors
- // grouped together with this one. We can't ignore its maximum value so we
- // set back the variable to NULL to prevent the continue condition from being
- // satisfied in the loop below.
- const qreal expectedMax = layoutCentralVertex[orient] ? QWIDGETSIZE_MAX / 2 : QWIDGETSIZE_MAX;
- qreal actualMax;
- if (layoutEdge->from == layoutFirstVertex[orient]) {
- actualMax = layoutEdge->maxSize;
- } else {
- actualMax = -layoutEdge->minSize;
- }
- if (actualMax != expectedMax) {
- layoutEdge = 0;
- }
-
- // For each variable, create constraints based on size hints
- QList<QSimplexConstraint *> anchorConstraints;
- bool unboundedProblem = true;
- for (int i = 0; i < anchors.size(); ++i) {
- AnchorData *ad = anchors.at(i);
-
- // Anchors that have their size directly linked to another one don't need constraints
- // For exammple, the second half of an item has exactly the same size as the first half
- // thus constraining the latter is enough.
- if (ad->dependency == AnchorData::Slave)
- continue;
-
- // To use negative variables inside simplex, we shift them so the minimum negative value is
- // mapped to zero before solving. To make sure that it works, we need to guarantee that the
- // variables are all inside a certain boundary.
- qreal boundedMin = qBound(-g_offset, ad->minSize, g_offset);
- qreal boundedMax = qBound(-g_offset, ad->maxSize, g_offset);
-
- if ((boundedMin == boundedMax) || qFuzzyCompare(boundedMin, boundedMax)) {
- QSimplexConstraint *c = new QSimplexConstraint;
- c->variables.insert(ad, 1.0);
- c->constant = boundedMin;
- c->ratio = QSimplexConstraint::Equal;
- anchorConstraints += c;
- unboundedProblem = false;
- } else {
- QSimplexConstraint *c = new QSimplexConstraint;
- c->variables.insert(ad, 1.0);
- c->constant = boundedMin;
- c->ratio = QSimplexConstraint::MoreOrEqual;
- anchorConstraints += c;
-
- // We avoid adding restrictions to the layout internal anchors. That's
- // to prevent unnecessary fair distribution from happening due to this
- // artificial restriction.
- if (ad == layoutEdge)
- continue;
-
- c = new QSimplexConstraint;
- c->variables.insert(ad, 1.0);
- c->constant = boundedMax;
- c->ratio = QSimplexConstraint::LessOrEqual;
- anchorConstraints += c;
- unboundedProblem = false;
- }
- }
-
- // If no upper boundary restriction was added, add one to avoid unbounded problem
- if (unboundedProblem) {
- QSimplexConstraint *c = new QSimplexConstraint;
- c->variables.insert(layoutEdge, 1.0);
- // The maximum size that the layout can take
- c->constant = g_offset;
- c->ratio = QSimplexConstraint::LessOrEqual;
- anchorConstraints += c;
- }
-
- return anchorConstraints;
-}
-
-/*!
- \internal
-*/
-QList< QList<QSimplexConstraint *> >
-QGraphicsAnchorLayoutPrivate::getGraphParts(Orientation orientation)
-{
- Q_ASSERT(layoutFirstVertex[orientation] && layoutLastVertex[orientation]);
-
- AnchorData *edgeL1 = 0;
- AnchorData *edgeL2 = 0;
-
- // The layout may have a single anchor between Left and Right or two half anchors
- // passing through the center
- if (layoutCentralVertex[orientation]) {
- edgeL1 = graph[orientation].edgeData(layoutFirstVertex[orientation], layoutCentralVertex[orientation]);
- edgeL2 = graph[orientation].edgeData(layoutCentralVertex[orientation], layoutLastVertex[orientation]);
- } else {
- edgeL1 = graph[orientation].edgeData(layoutFirstVertex[orientation], layoutLastVertex[orientation]);
- }
-
- QLinkedList<QSimplexConstraint *> remainingConstraints;
- for (int i = 0; i < constraints[orientation].count(); ++i) {
- remainingConstraints += constraints[orientation].at(i);
- }
- for (int i = 0; i < itemCenterConstraints[orientation].count(); ++i) {
- remainingConstraints += itemCenterConstraints[orientation].at(i);
- }
-
- QList<QSimplexConstraint *> trunkConstraints;
- QSet<QSimplexVariable *> trunkVariables;
-
- trunkVariables += edgeL1;
- if (edgeL2)
- trunkVariables += edgeL2;
-
- bool dirty;
- do {
- dirty = false;
-
- QLinkedList<QSimplexConstraint *>::iterator it = remainingConstraints.begin();
- while (it != remainingConstraints.end()) {
- QSimplexConstraint *c = *it;
- bool match = false;
-
- // Check if this constraint have some overlap with current
- // trunk variables...
- foreach (QSimplexVariable *ad, trunkVariables) {
- if (c->variables.contains(ad)) {
- match = true;
- break;
- }
- }
-
- // If so, we add it to trunk, and erase it from the
- // remaining constraints.
- if (match) {
- trunkConstraints += c;
- trunkVariables += QSet<QSimplexVariable *>::fromList(c->variables.keys());
- it = remainingConstraints.erase(it);
- dirty = true;
- } else {
- // Note that we don't erase the constraint if it's not
- // a match, since in a next iteration of a do-while we
- // can pass on it again and it will be a match.
- //
- // For example: if trunk share a variable with
- // remainingConstraints[1] and it shares with
- // remainingConstraints[0], we need a second iteration
- // of the do-while loop to match both.
- ++it;
- }
- }
- } while (dirty);
-
- QList< QList<QSimplexConstraint *> > result;
- result += trunkConstraints;
-
- if (!remainingConstraints.isEmpty()) {
- QList<QSimplexConstraint *> nonTrunkConstraints;
- QLinkedList<QSimplexConstraint *>::iterator it = remainingConstraints.begin();
- while (it != remainingConstraints.end()) {
- nonTrunkConstraints += *it;
- ++it;
- }
- result += nonTrunkConstraints;
- }
-
- return result;
-}
-
-/*!
- \internal
-
- Use all visited Anchors on findPaths() so we can identify non-float Items.
-*/
-void QGraphicsAnchorLayoutPrivate::identifyFloatItems(const QSet<AnchorData *> &visited, Orientation orientation)
-{
- QSet<QGraphicsLayoutItem *> nonFloating;
-
- foreach (const AnchorData *ad, visited)
- identifyNonFloatItems_helper(ad, &nonFloating);
-
- QSet<QGraphicsLayoutItem *> allItems;
- foreach (QGraphicsLayoutItem *item, items)
- allItems.insert(item);
- m_floatItems[orientation] = allItems - nonFloating;
-}
-
-
-/*!
- \internal
-
- Given an anchor, if it is an internal anchor and Normal we must mark it's item as non-float.
- If the anchor is Sequential or Parallel, we must iterate on its children recursively until we reach
- internal anchors (items).
-*/
-void QGraphicsAnchorLayoutPrivate::identifyNonFloatItems_helper(const AnchorData *ad, QSet<QGraphicsLayoutItem *> *nonFloatingItemsIdentifiedSoFar)
-{
- Q_Q(QGraphicsAnchorLayout);
-
- switch(ad->type) {
- case AnchorData::Normal:
- if (ad->item && ad->item != q)
- nonFloatingItemsIdentifiedSoFar->insert(ad->item);
- break;
- case AnchorData::Sequential:
- foreach (const AnchorData *d, static_cast<const SequentialAnchorData *>(ad)->m_edges)
- identifyNonFloatItems_helper(d, nonFloatingItemsIdentifiedSoFar);
- break;
- case AnchorData::Parallel:
- identifyNonFloatItems_helper(static_cast<const ParallelAnchorData *>(ad)->firstEdge, nonFloatingItemsIdentifiedSoFar);
- identifyNonFloatItems_helper(static_cast<const ParallelAnchorData *>(ad)->secondEdge, nonFloatingItemsIdentifiedSoFar);
- break;
- }
-}
-
-/*!
- \internal
-
- Use the current vertices distance to calculate and set the geometry of
- each item.
-*/
-void QGraphicsAnchorLayoutPrivate::setItemsGeometries(const QRectF &geom)
-{
- Q_Q(QGraphicsAnchorLayout);
- AnchorVertex *firstH, *secondH, *firstV, *secondV;
-
- qreal top;
- qreal left;
- qreal right;
-
- q->getContentsMargins(&left, &top, &right, 0);
- const Qt::LayoutDirection visualDir = visualDirection();
- if (visualDir == Qt::RightToLeft)
- qSwap(left, right);
-
- left += geom.left();
- top += geom.top();
- right = geom.right() - right;
-
- foreach (QGraphicsLayoutItem *item, items) {
- QRectF newGeom;
- QSizeF itemPreferredSize = item->effectiveSizeHint(Qt::PreferredSize);
- if (m_floatItems[Horizontal].contains(item)) {
- newGeom.setLeft(0);
- newGeom.setRight(itemPreferredSize.width());
- } else {
- firstH = internalVertex(item, Qt::AnchorLeft);
- secondH = internalVertex(item, Qt::AnchorRight);
-
- if (visualDir == Qt::LeftToRight) {
- newGeom.setLeft(left + firstH->distance);
- newGeom.setRight(left + secondH->distance);
- } else {
- newGeom.setLeft(right - secondH->distance);
- newGeom.setRight(right - firstH->distance);
- }
- }
-
- if (m_floatItems[Vertical].contains(item)) {
- newGeom.setTop(0);
- newGeom.setBottom(itemPreferredSize.height());
- } else {
- firstV = internalVertex(item, Qt::AnchorTop);
- secondV = internalVertex(item, Qt::AnchorBottom);
-
- newGeom.setTop(top + firstV->distance);
- newGeom.setBottom(top + secondV->distance);
- }
-
- item->setGeometry(newGeom);
- }
-}
-
-/*!
- \internal
-
- Calculate the position of each vertex based on the paths to each of
- them as well as the current edges sizes.
-*/
-void QGraphicsAnchorLayoutPrivate::calculateVertexPositions(
- QGraphicsAnchorLayoutPrivate::Orientation orientation)
-{
- QQueue<QPair<AnchorVertex *, AnchorVertex *> > queue;
- QSet<AnchorVertex *> visited;
-
- // Get root vertex
- AnchorVertex *root = layoutFirstVertex[orientation];
-
- root->distance = 0;
- visited.insert(root);
-
- // Add initial edges to the queue
- foreach (AnchorVertex *v, graph[orientation].adjacentVertices(root)) {
- queue.enqueue(qMakePair(root, v));
- }
-
- // Do initial calculation required by "interpolateEdge()"
- setupEdgesInterpolation(orientation);
-
- // Traverse the graph and calculate vertex positions
- while (!queue.isEmpty()) {
- QPair<AnchorVertex *, AnchorVertex *> pair = queue.dequeue();
- AnchorData *edge = graph[orientation].edgeData(pair.first, pair.second);
-
- if (visited.contains(pair.second))
- continue;
-
- visited.insert(pair.second);
- interpolateEdge(pair.first, edge);
-
- QList<AnchorVertex *> adjacents = graph[orientation].adjacentVertices(pair.second);
- for (int i = 0; i < adjacents.count(); ++i) {
- if (!visited.contains(adjacents.at(i)))
- queue.enqueue(qMakePair(pair.second, adjacents.at(i)));
- }
- }
-}
-
-/*!
- \internal
-
- Calculate interpolation parameters based on current Layout Size.
- Must be called once before calling "interpolateEdgeSize()" for
- the edges.
-*/
-void QGraphicsAnchorLayoutPrivate::setupEdgesInterpolation(
- Orientation orientation)
-{
- Q_Q(QGraphicsAnchorLayout);
-
- qreal current;
- current = (orientation == Horizontal) ? q->contentsRect().width() : q->contentsRect().height();
-
- QPair<Interval, qreal> result;
- result = getFactor(current,
- sizeHints[orientation][Qt::MinimumSize],
- sizeHints[orientation][Qt::PreferredSize],
- sizeHints[orientation][Qt::PreferredSize],
- sizeHints[orientation][Qt::PreferredSize],
- sizeHints[orientation][Qt::MaximumSize]);
-
- interpolationInterval[orientation] = result.first;
- interpolationProgress[orientation] = result.second;
-}
-
-/*!
- \internal
-
- Calculate the current Edge size based on the current Layout size and the
- size the edge is supposed to have when the layout is at its:
-
- - minimum size,
- - preferred size,
- - maximum size.
-
- These three key values are calculated in advance using linear
- programming (more expensive) or the simplification algorithm, then
- subsequential resizes of the parent layout require a simple
- interpolation.
-*/
-void QGraphicsAnchorLayoutPrivate::interpolateEdge(AnchorVertex *base, AnchorData *edge)
-{
- const Orientation orientation = Orientation(edge->orientation);
- const QPair<Interval, qreal> factor(interpolationInterval[orientation],
- interpolationProgress[orientation]);
-
- qreal edgeDistance = interpolate(factor, edge->sizeAtMinimum, edge->sizeAtPreferred,
- edge->sizeAtPreferred, edge->sizeAtPreferred,
- edge->sizeAtMaximum);
-
- Q_ASSERT(edge->from == base || edge->to == base);
-
- // Calculate the distance for the vertex opposite to the base
- if (edge->from == base) {
- edge->to->distance = base->distance + edgeDistance;
- } else {
- edge->from->distance = base->distance - edgeDistance;
- }
-}
-
-bool QGraphicsAnchorLayoutPrivate::solveMinMax(const QList<QSimplexConstraint *> &constraints,
- GraphPath path, qreal *min, qreal *max)
-{
- QSimplex simplex;
- bool feasible = simplex.setConstraints(constraints);
- if (feasible) {
- // Obtain the objective constraint
- QSimplexConstraint objective;
- QSet<AnchorData *>::const_iterator iter;
- for (iter = path.positives.constBegin(); iter != path.positives.constEnd(); ++iter)
- objective.variables.insert(*iter, 1.0);
-
- for (iter = path.negatives.constBegin(); iter != path.negatives.constEnd(); ++iter)
- objective.variables.insert(*iter, -1.0);
-
- const qreal objectiveOffset = (path.positives.count() - path.negatives.count()) * g_offset;
- simplex.setObjective(&objective);
-
- // Calculate minimum values
- *min = simplex.solveMin() - objectiveOffset;
-
- // Save sizeAtMinimum results
- QList<AnchorData *> variables = getVariables(constraints);
- for (int i = 0; i < variables.size(); ++i) {
- AnchorData *ad = static_cast<AnchorData *>(variables.at(i));
- ad->sizeAtMinimum = ad->result - g_offset;
- }
-
- // Calculate maximum values
- *max = simplex.solveMax() - objectiveOffset;
-
- // Save sizeAtMaximum results
- for (int i = 0; i < variables.size(); ++i) {
- AnchorData *ad = static_cast<AnchorData *>(variables.at(i));
- ad->sizeAtMaximum = ad->result - g_offset;
- }
- }
- return feasible;
-}
-
-enum slackType { Grower = -1, Shrinker = 1 };
-static QPair<QSimplexVariable *, QSimplexConstraint *> createSlack(QSimplexConstraint *sizeConstraint,
- qreal interval, slackType type)
-{
- QSimplexVariable *slack = new QSimplexVariable;
- sizeConstraint->variables.insert(slack, type);
-
- QSimplexConstraint *limit = new QSimplexConstraint;
- limit->variables.insert(slack, 1.0);
- limit->ratio = QSimplexConstraint::LessOrEqual;
- limit->constant = interval;
-
- return qMakePair(slack, limit);
-}
-
-bool QGraphicsAnchorLayoutPrivate::solvePreferred(const QList<QSimplexConstraint *> &constraints,
- const QList<AnchorData *> &variables)
-{
- QList<QSimplexConstraint *> preferredConstraints;
- QList<QSimplexVariable *> preferredVariables;
- QSimplexConstraint objective;
-
- // Fill the objective coefficients for this variable. In the
- // end the objective function will be
- //
- // z = n * (A_shrinker_hard + A_grower_hard + B_shrinker_hard + B_grower_hard + ...) +
- // (A_shrinker_soft + A_grower_soft + B_shrinker_soft + B_grower_soft + ...)
- //
- // where n is the number of variables that have
- // slacks. Note that here we use the number of variables
- // as coefficient, this is to mark the "shrinker slack
- // variable" less likely to get value than the "grower
- // slack variable".
-
- // This will fill the values for the structural constraints
- // and we now fill the values for the slack constraints (one per variable),
- // which have this form (the constant A_pref was set when creating the slacks):
- //
- // A + A_shrinker_hard + A_shrinker_soft - A_grower_hard - A_grower_soft = A_pref
- //
- for (int i = 0; i < variables.size(); ++i) {
- AnchorData *ad = variables.at(i);
-
- // The layout original structure anchors are not relevant in preferred size calculation
- if (ad->isLayoutAnchor)
- continue;
-
- // By default, all variables are equal to their preferred size. If they have room to
- // grow or shrink, such flexibility will be added by the additional variables below.
- QSimplexConstraint *sizeConstraint = new QSimplexConstraint;
- preferredConstraints += sizeConstraint;
- sizeConstraint->variables.insert(ad, 1.0);
- sizeConstraint->constant = ad->prefSize + g_offset;
-
- // Can easily shrink
- QPair<QSimplexVariable *, QSimplexConstraint *> slack;
- const qreal softShrinkInterval = ad->prefSize - ad->minPrefSize;
- if (softShrinkInterval) {
- slack = createSlack(sizeConstraint, softShrinkInterval, Shrinker);
- preferredVariables += slack.first;
- preferredConstraints += slack.second;
-
- // Add to objective with ratio == 1 (soft)
- objective.variables.insert(slack.first, 1.0);
- }
-
- // Can easily grow
- const qreal softGrowInterval = ad->maxPrefSize - ad->prefSize;
- if (softGrowInterval) {
- slack = createSlack(sizeConstraint, softGrowInterval, Grower);
- preferredVariables += slack.first;
- preferredConstraints += slack.second;
-
- // Add to objective with ratio == 1 (soft)
- objective.variables.insert(slack.first, 1.0);
- }
-
- // Can shrink if really necessary
- const qreal hardShrinkInterval = ad->minPrefSize - ad->minSize;
- if (hardShrinkInterval) {
- slack = createSlack(sizeConstraint, hardShrinkInterval, Shrinker);
- preferredVariables += slack.first;
- preferredConstraints += slack.second;
-
- // Add to objective with ratio == N (hard)
- objective.variables.insert(slack.first, variables.size());
- }
-
- // Can grow if really necessary
- const qreal hardGrowInterval = ad->maxSize - ad->maxPrefSize;
- if (hardGrowInterval) {
- slack = createSlack(sizeConstraint, hardGrowInterval, Grower);
- preferredVariables += slack.first;
- preferredConstraints += slack.second;
-
- // Add to objective with ratio == N (hard)
- objective.variables.insert(slack.first, variables.size());
- }
- }
-
- QSimplex *simplex = new QSimplex;
- bool feasible = simplex->setConstraints(constraints + preferredConstraints);
- if (feasible) {
- simplex->setObjective(&objective);
-
- // Calculate minimum values
- simplex->solveMin();
-
- // Save sizeAtPreferred results
- for (int i = 0; i < variables.size(); ++i) {
- AnchorData *ad = variables.at(i);
- ad->sizeAtPreferred = ad->result - g_offset;
- }
-
- // Make sure we delete the simplex solver -before- we delete the
- // constraints used by it.
- delete simplex;
- }
- // Delete constraints and variables we created.
- qDeleteAll(preferredConstraints);
- qDeleteAll(preferredVariables);
-
- return feasible;
-}
-
-/*!
- \internal
- Returns true if there are no arrangement that satisfies all constraints.
- Otherwise returns false.
-
- \sa addAnchor()
-*/
-bool QGraphicsAnchorLayoutPrivate::hasConflicts() const
-{
- QGraphicsAnchorLayoutPrivate *that = const_cast<QGraphicsAnchorLayoutPrivate*>(this);
- that->calculateGraphs();
-
- bool floatConflict = !m_floatItems[0].isEmpty() || !m_floatItems[1].isEmpty();
-
- return graphHasConflicts[0] || graphHasConflicts[1] || floatConflict;
-}
-
-#ifdef QT_DEBUG
-void QGraphicsAnchorLayoutPrivate::dumpGraph(const QString &name)
-{
- QFile file(QString::fromAscii("anchorlayout.%1.dot").arg(name));
- if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate))
- qWarning("Could not write to %s", file.fileName().toLocal8Bit().constData());
-
- QString str = QString::fromAscii("digraph anchorlayout {\nnode [shape=\"rect\"]\n%1}");
- QString dotContents = graph[0].serializeToDot();
- dotContents += graph[1].serializeToDot();
- file.write(str.arg(dotContents).toLocal8Bit());
-
- file.close();
-}
-#endif
-
-QT_END_NAMESPACE
-#endif //QT_NO_GRAPHICSVIEW
diff --git a/src/gui/graphicsview/qgraphicsgridlayout.h b/src/gui/graphicsview/qgraphicsgridlayout.h
deleted file mode 100644
index f493eb6153..0000000000
--- a/src/gui/graphicsview/qgraphicsgridlayout.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSGRIDLAYOUT_H
-#define QGRAPHICSGRIDLAYOUT_H
-
-#include <QtGui/qgraphicsitem.h>
-#include <QtGui/qgraphicslayout.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
-
-class QGraphicsGridLayoutPrivate;
-
-class Q_GUI_EXPORT QGraphicsGridLayout : public QGraphicsLayout
-{
-public:
- QGraphicsGridLayout(QGraphicsLayoutItem *parent = 0);
- virtual ~QGraphicsGridLayout();
-
- void addItem(QGraphicsLayoutItem *item, int row, int column, int rowSpan, int columnSpan,
- Qt::Alignment alignment = 0);
- inline void addItem(QGraphicsLayoutItem *item, int row, int column, Qt::Alignment alignment = 0);
-
- void setHorizontalSpacing(qreal spacing);
- qreal horizontalSpacing() const;
- void setVerticalSpacing(qreal spacing);
- qreal verticalSpacing() const;
- void setSpacing(qreal spacing);
-
- void setRowSpacing(int row, qreal spacing);
- qreal rowSpacing(int row) const;
- void setColumnSpacing(int column, qreal spacing);
- qreal columnSpacing(int column) const;
-
- void setRowStretchFactor(int row, int stretch);
- int rowStretchFactor(int row) const;
- void setColumnStretchFactor(int column, int stretch);
- int columnStretchFactor(int column) const;
-
- void setRowMinimumHeight(int row, qreal height);
- qreal rowMinimumHeight(int row) const;
- void setRowPreferredHeight(int row, qreal height);
- qreal rowPreferredHeight(int row) const;
- void setRowMaximumHeight(int row, qreal height);
- qreal rowMaximumHeight(int row) const;
- void setRowFixedHeight(int row, qreal height);
-
- void setColumnMinimumWidth(int column, qreal width);
- qreal columnMinimumWidth(int column) const;
- void setColumnPreferredWidth(int column, qreal width);
- qreal columnPreferredWidth(int column) const;
- void setColumnMaximumWidth(int column, qreal width);
- qreal columnMaximumWidth(int column) const;
- void setColumnFixedWidth(int column, qreal width);
-
- void setRowAlignment(int row, Qt::Alignment alignment);
- Qt::Alignment rowAlignment(int row) const;
- void setColumnAlignment(int column, Qt::Alignment alignment);
- Qt::Alignment columnAlignment(int column) const;
-
- void setAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment);
- Qt::Alignment alignment(QGraphicsLayoutItem *item) const;
-
- int rowCount() const;
- int columnCount() const;
-
- QGraphicsLayoutItem *itemAt(int row, int column) const;
-
- // inherited from QGraphicsLayout
- int count() const;
- QGraphicsLayoutItem *itemAt(int index) const;
- void removeAt(int index);
- void removeItem(QGraphicsLayoutItem *item);
-
- void invalidate();
-
- // inherited from QGraphicsLayoutItem
- void setGeometry(const QRectF &rect);
- QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
-
- // ####
- //QRect cellRect(int row, int column, int rowSpan = 1, int columnSpan = 1) const;
- //QSizePolicy::ControlTypes controlTypes(LayoutSide side) const;
-
-private:
- Q_DISABLE_COPY(QGraphicsGridLayout)
- Q_DECLARE_PRIVATE(QGraphicsGridLayout)
-};
-
-inline void QGraphicsGridLayout::addItem(QGraphicsLayoutItem *aitem, int arow, int acolumn, Qt::Alignment aalignment)
-{ addItem(aitem, arow, acolumn, 1, 1, aalignment); }
-
-#endif
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
-
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
deleted file mode 100644
index 41ff317676..0000000000
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ /dev/null
@@ -1,11601 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \class QGraphicsItem
- \brief The QGraphicsItem class is the base class for all graphical
- items in a QGraphicsScene.
- \since 4.2
-
- \ingroup graphicsview-api
-
- It provides a light-weight foundation for writing your own custom items.
- This includes defining the item's geometry, collision detection, its
- painting implementation and item interaction through its event handlers.
- QGraphicsItem is part of the \l{Graphics View Framework}
-
- \image graphicsview-items.png
-
- For convenience, Qt provides a set of standard graphics items for the most
- common shapes. These are:
-
- \list
- \o QGraphicsEllipseItem provides an ellipse item
- \o QGraphicsLineItem provides a line item
- \o QGraphicsPathItem provides an arbitrary path item
- \o QGraphicsPixmapItem provides a pixmap item
- \o QGraphicsPolygonItem provides a polygon item
- \o QGraphicsRectItem provides a rectangular item
- \o QGraphicsSimpleTextItem provides a simple text label item
- \o QGraphicsTextItem provides an advanced text browser item
- \endlist
-
- All of an item's geometric information is based on its local coordinate
- system. The item's position, pos(), is the only function that does not
- operate in local coordinates, as it returns a position in parent
- coordinates. \l {The Graphics View Coordinate System} describes the coordinate
- system in detail.
-
- You can set whether an item should be visible (i.e., drawn, and accepting
- events), by calling setVisible(). Hiding an item will also hide its
- children. Similarly, you can enable or disable an item by calling
- setEnabled(). If you disable an item, all its children will also be
- disabled. By default, items are both visible and enabled. To toggle
- whether an item is selected or not, first enable selection by setting
- the ItemIsSelectable flag, and then call setSelected(). Normally,
- selection is toggled by the scene, as a result of user interaction.
-
- To write your own graphics item, you first create a subclass of
- QGraphicsItem, and then start by implementing its two pure virtual public
- functions: boundingRect(), which returns an estimate of the area painted
- by the item, and paint(), which implements the actual painting. For
- example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 0
-
- The boundingRect() function has many different purposes.
- QGraphicsScene bases its item index on boundingRect(), and
- QGraphicsView uses it both for culling invisible items, and for
- determining the area that needs to be recomposed when drawing
- overlapping items. In addition, QGraphicsItem's collision
- detection mechanisms use boundingRect() to provide an efficient
- cut-off. The fine grained collision algorithm in
- collidesWithItem() is based on calling shape(), which returns an
- accurate outline of the item's shape as a QPainterPath.
-
- QGraphicsScene expects all items boundingRect() and shape() to
- remain unchanged unless it is notified. If you want to change an
- item's geometry in any way, you must first call
- prepareGeometryChange() to allow QGraphicsScene to update its
- bookkeeping.
-
- Collision detection can be done in two ways:
-
- \list 1
-
- \o Reimplement shape() to return an accurate shape for your item,
- and rely on the default implementation of collidesWithItem() to do
- shape-shape intersection. This can be rather expensive if the
- shapes are complex.
-
- \o Reimplement collidesWithItem() to provide your own custom item
- and shape collision algorithm.
-
- \endlist
-
- The contains() function can be called to determine whether the item \e
- contains a point or not. This function can also be reimplemented by the
- item. The default behavior of contains() is based on calling shape().
-
- Items can contain other items, and also be contained by other items. All
- items can have a parent item and a list of children. Unless the item has
- no parent, its position is in \e parent coordinates (i.e., the parent's
- local coordinates). Parent items propagate both their position and their
- transformation to all children.
-
- \img graphicsview-parentchild.png
-
- \target Transformations
- \section1 Transformations
-
- QGraphicsItem supports projective transformations in addition to its base
- position, pos(). There are several ways to change an item's transformation.
- For simple transformations, you can call either of the convenience
- functions setRotation() or setScale(), or you can pass any transformation
- matrix to setTransform(). For advanced transformation control you also have
- the option of setting several combined transformations by calling
- setTransformations().
-
- Item transformations accumulate from parent to child, so if both a parent
- and child item are rotated 90 degrees, the child's total transformation
- will be 180 degrees. Similarly, if the item's parent is scaled to 2x its
- original size, its children will also be twice as large. An item's
- transformation does not affect its own local geometry; all geometry
- functions (e.g., contains(), update(), and all the mapping functions) still
- operate in local coordinates. For convenience, QGraphicsItem provides the
- functions sceneTransform(), which returns the item's total transformation
- matrix (including its position and all parents' positions and
- transformations), and scenePos(), which returns its position in scene
- coordinates. To reset an item's matrix, call resetTransform().
-
- Certain transformation operations produce a different outcome depending on
- the order in which they are applied. For example, if you scale an
- transform, and then rotate it, you may get a different result than if the
- transform was rotated first. However, the order you set the transformation
- properties on QGraphicsItem does not affect the resulting transformation;
- QGraphicsItem always applies the properties in a fixed, defined order:
-
- \list
- \o The item's base transform is applied (transform())
- \o The item's transformations list is applied in order (transformations())
- \o The item is rotated relative to its transform origin point (rotation(), transformOriginPoint())
- \o The item is scaled relative to its transform origin point (scale(), transformOriginPoint())
- \endlist
-
- \section1 Painting
-
- The paint() function is called by QGraphicsView to paint the item's
- contents. The item has no background or default fill of its own; whatever
- is behind the item will shine through all areas that are not explicitly
- painted in this function. You can call update() to schedule a repaint,
- optionally passing the rectangle that needs a repaint. Depending on
- whether or not the item is visible in a view, the item may or may not be
- repainted; there is no equivalent to QWidget::repaint() in QGraphicsItem.
-
- Items are painted by the view, starting with the parent items and then
- drawing children, in ascending stacking order. You can set an item's
- stacking order by calling setZValue(), and test it by calling
- zValue(), where items with low z-values are painted before items with
- high z-values. Stacking order applies to sibling items; parents are always
- drawn before their children.
-
- \section1 Sorting
-
- All items are drawn in a defined, stable order, and this same order decides
- which items will receive mouse input first when you click on the scene.
- Normally you don't have to worry about sorting, as the items follow a
- "natural order", following the logical structure of the scene.
-
- An item's children are stacked on top of the parent, and sibling items are
- stacked by insertion order (i.e., in the same order that they were either
- added to the scene, or added to the same parent). If you add item A, and
- then B, then B will be on top of A. If you then add C, the items' stacking
- order will be A, then B, then C.
-
- \image graphicsview-zorder.png
-
- This example shows the stacking order of all limbs of the robot from the
- \l{graphicsview/dragdroprobot}{Drag and Drop Robot} example. The torso is
- the root item (all other items are children or descendants of the torso),
- so it is drawn first. Next, the head is drawn, as it is the first item in
- the torso's list of children. Then the upper left arm is drawn. As the
- lower arm is a child of the upper arm, the lower arm is then drawn,
- followed by the upper arm's next sibling, which is the upper right arm, and
- so on.
-
- For advanced users, there are ways to alter how your items are sorted:
-
- \list
- \o You can call setZValue() on an item to explicitly stack it on top of, or
- under, other sibling items. The default Z value for an item is 0. Items
- with the same Z value are stacked by insertion order.
-
- \o You can call stackBefore() to reorder the list of children. This will
- directly modify the insertion order.
-
- \o You can set the ItemStacksBehindParent flag to stack a child item behind
- its parent.
- \endlist
-
- The stacking order of two sibling items also counts for each item's
- children and descendant items. So if one item is on top of another, then
- all its children will also be on top of all the other item's children as
- well.
-
- \section1 Events
-
- QGraphicsItem receives events from QGraphicsScene through the virtual
- function sceneEvent(). This function distributes the most common events
- to a set of convenience event handlers:
-
- \list
- \o contextMenuEvent() handles context menu events
- \o focusInEvent() and focusOutEvent() handle focus in and out events
- \o hoverEnterEvent(), hoverMoveEvent(), and hoverLeaveEvent() handles
- hover enter, move and leave events
- \o inputMethodEvent() handles input events, for accessibility support
- \o keyPressEvent() and keyReleaseEvent() handle key press and release events
- \o mousePressEvent(), mouseMoveEvent(), mouseReleaseEvent(), and
- mouseDoubleClickEvent() handles mouse press, move, release, click and
- doubleclick events
- \endlist
-
- You can filter events for any other item by installing event filters. This
- functionality is separate from Qt's regular event filters (see
- QObject::installEventFilter()), which only work on subclasses of QObject. After
- installing your item as an event filter for another item by calling
- installSceneEventFilter(), the filtered events will be received by the virtual
- function sceneEventFilter(). You can remove item event filters by calling
- removeSceneEventFilter().
-
- \section1 Custom Data
-
- Sometimes it's useful to register custom data with an item, be it a custom
- item, or a standard item. You can call setData() on any item to store data
- in it using a key-value pair (the key being an integer, and the value is a
- QVariant). To get custom data from an item, call data(). This
- functionality is completely untouched by Qt itself; it is provided for the
- user's convenience.
-
- \sa QGraphicsScene, QGraphicsView, {Graphics View Framework}
-*/
-
-/*!
- \variable QGraphicsItem::Type
-
- The type value returned by the virtual type() function in standard
- graphics item classes in Qt. All such standard graphics item
- classes in Qt are associated with a unique value for Type,
- e.g. the value returned by QGraphicsPathItem::type() is 2.
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 18
-*/
-
-/*!
- \variable QGraphicsItem::UserType
-
- The lowest permitted type value for custom items (subclasses
- of QGraphicsItem or any of the standard items). This value is
- used in conjunction with a reimplementation of QGraphicsItem::type()
- and declaring a Type enum value. Example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 1
-
- \note UserType = 65536
-*/
-
-/*!
- \enum QGraphicsItem::GraphicsItemFlag
-
- This enum describes different flags that you can set on an item to
- toggle different features in the item's behavior.
-
- All flags are disabled by default.
-
- \value ItemIsMovable The item supports interactive movement using
- the mouse. By clicking on the item and then dragging, the item
- will move together with the mouse cursor. If the item has
- children, all children are also moved. If the item is part of a
- selection, all selected items are also moved. This feature is
- provided as a convenience through the base implementation of
- QGraphicsItem's mouse event handlers.
-
- \value ItemIsSelectable The item supports selection. Enabling this
- feature will enable setSelected() to toggle selection for the
- item. It will also let the item be selected automatically as a
- result of calling QGraphicsScene::setSelectionArea(), by clicking
- on an item, or by using rubber band selection in QGraphicsView.
-
- \value ItemIsFocusable The item supports keyboard input focus (i.e., it is
- an input item). Enabling this flag will allow the item to accept focus,
- which again allows the delivery of key events to
- QGraphicsItem::keyPressEvent() and QGraphicsItem::keyReleaseEvent().
-
- \value ItemClipsToShape The item clips to its own shape. The item cannot
- draw or receive mouse, tablet, drag and drop or hover events outside its
- shape. It is disabled by default. This behavior is enforced by
- QGraphicsView::drawItems() or QGraphicsScene::drawItems(). This flag was
- introduced in Qt 4.3.
-
- \value ItemClipsChildrenToShape The item clips the painting of all its
- descendants to its own shape. Items that are either direct or indirect
- children of this item cannot draw outside this item's shape. By default,
- this flag is disabled; children can draw anywhere. This behavior is
- enforced by QGraphicsView::drawItems() or
- QGraphicsScene::drawItems(). This flag was introduced in Qt 4.3.
-
- \value ItemIgnoresTransformations The item ignores inherited
- transformations (i.e., its position is still anchored to its parent, but
- the parent or view rotation, zoom or shear transformations are ignored).
- This flag is useful for keeping text label items horizontal and unscaled,
- so they will still be readable if the view is transformed. When set, the
- item's view geometry and scene geometry will be maintained separately. You
- must call deviceTransform() to map coordinates and detect collisions in
- the view. By default, this flag is disabled. This flag was introduced in
- Qt 4.3. \note With this flag set you can still scale the item itself, and
- that scale transformation will influence the item's children.
-
- \value ItemIgnoresParentOpacity The item ignores its parent's opacity. The
- item's effective opacity is the same as its own; it does not combine with
- the parent's opacity. This flags allows your item to keep its absolute
- opacity even if the parent is semitransparent. This flag was introduced in
- Qt 4.5.
-
- \value ItemDoesntPropagateOpacityToChildren The item doesn't propagate its
- opacity to its children. This flag allows you to create a semitransparent
- item that does not affect the opacity of its children. This flag was
- introduced in Qt 4.5.
-
- \value ItemStacksBehindParent The item is stacked behind its parent. By
- default, child items are stacked on top of the parent item. But setting
- this flag, the child will be stacked behind it. This flag is useful for
- drop shadow effects and for decoration objects that follow the parent
- item's geometry without drawing on top of it. This flag was introduced
- in Qt 4.5.
-
- \value ItemUsesExtendedStyleOption The item makes use of either
- \l{QStyleOptionGraphicsItem::} {exposedRect} or
- \l{QStyleOptionGraphicsItem::} {matrix} in
- QStyleOptionGraphicsItem. By default, the
- \l{QStyleOptionGraphicsItem::} {exposedRect} is initialized to the
- item's boundingRect() and the
- \l{QStyleOptionGraphicsItem::}{matrix} is untransformed. You can
- enable this flag for the style options to be set up with more
- fine-grained values. Note that
- QStyleOptionGraphicsItem::levelOfDetail is unaffected by this flag
- and always initialized to 1. Use
- QStyleOptionGraphicsItem::levelOfDetailFromTransform() if you need
- a higher value. This flag was introduced in Qt 4.6.
-
- \value ItemHasNoContents The item does not paint anything (i.e., calling
- paint() on the item has no effect). You should set this flag on items that
- do not need to be painted to ensure that Graphics View avoids unnecessary
- painting preparations. This flag was introduced in Qt 4.6.
-
- \value ItemSendsGeometryChanges The item enables itemChange()
- notifications for ItemPositionChange, ItemPositionHasChanged,
- ItemMatrixChange, ItemTransformChange, ItemTransformHasChanged,
- ItemRotationChange, ItemRotationHasChanged, ItemScaleChange, ItemScaleHasChanged,
- ItemTransformOriginPointChange, and ItemTransformOriginPointHasChanged. For
- performance reasons, these notifications are disabled by default. You must
- enable this flag to receive notifications for position and transform
- changes. This flag was introduced in Qt 4.6.
-
- \value ItemAcceptsInputMethod The item supports input methods typically
- used for Asian languages.
- This flag was introduced in Qt 4.6.
-
- \value ItemNegativeZStacksBehindParent The item automatically
- stacks behind it's parent if it's z-value is negative. This flag
- enables setZValue() to toggle ItemStacksBehindParent. This flag
- was introduced in Qt 4.6.
-
- \value ItemIsPanel The item is a panel. A panel provides activation and
- contained focus handling. Only one panel can be active at a time (see
- QGraphicsItem::isActive()). When no panel is active, QGraphicsScene
- activates all non-panel items. Window items (i.e.,
- QGraphicsItem::isWindow() returns true) are panels. This flag was
- introduced in Qt 4.6.
-
- \omitvalue ItemIsFocusScope \omit Internal only (for now). \endomit
-
- \value ItemSendsScenePositionChanges The item enables itemChange()
- notifications for ItemScenePositionHasChanged. For performance reasons,
- these notifications are disabled by default. You must enable this flag
- to receive notifications for scene position changes. This flag was
- introduced in Qt 4.6.
-
- \omitvalue ItemStopsClickFocusPropagation \omit The item stops propagating
- click focus to items underneath when being clicked on. This flag
- allows you create a non-focusable item that can be clicked on without
- changing the focus. \endomit
-
- \omitvalue ItemStopsFocusHandling \omit Same as
- ItemStopsClickFocusPropagation, but also suppresses focus-out. This flag
- allows you to completely take over focus handling.
- This flag was introduced in Qt 4.7. \endomit
-*/
-
-/*!
- \enum QGraphicsItem::GraphicsItemChange
-
- This enum describes the state changes that are notified by
- QGraphicsItem::itemChange(). The notifications are sent as the state
- changes, and in some cases, adjustments can be made (see the documentation
- for each change for details).
-
- Note: Be careful with calling functions on the QGraphicsItem itself inside
- itemChange(), as certain function calls can lead to unwanted
- recursion. For example, you cannot call setPos() in itemChange() on an
- ItemPositionChange notification, as the setPos() function will again call
- itemChange(ItemPositionChange). Instead, you can return the new, adjusted
- position from itemChange().
-
- \value ItemEnabledChange The item's enabled state changes. If the item is
- presently enabled, it will become disabled, and vice verca. The value
- argument is the new enabled state (i.e., true or false). Do not call
- setEnabled() in itemChange() as this notification is delivered. Instead,
- you can return the new state from itemChange().
-
- \value ItemEnabledHasChanged The item's enabled state has changed. The
- value argument is the new enabled state (i.e., true or false). Do not call
- setEnabled() in itemChange() as this notification is delivered. The return
- value is ignored.
-
- \value ItemMatrixChange The item's affine transformation matrix is
- changing. This value is obsolete; you can use ItemTransformChange instead.
-
- \value ItemPositionChange The item's position changes. This notification
- is sent if the ItemSendsGeometryChanges flag is enabled, and when the
- item's local position changes, relative to its parent (i.e., as a result
- of calling setPos() or moveBy()). The value argument is the new position
- (i.e., a QPointF). You can call pos() to get the original position. Do
- not call setPos() or moveBy() in itemChange() as this notification is
- delivered; instead, you can return the new, adjusted position from
- itemChange(). After this notification, QGraphicsItem immediately sends the
- ItemPositionHasChanged notification if the position changed.
-
- \value ItemPositionHasChanged The item's position has changed. This
- notification is sent if the ItemSendsGeometryChanges flag is enabled, and
- after the item's local position, relative to its parent, has changed. The
- value argument is the new position (the same as pos()), and QGraphicsItem
- ignores the return value for this notification (i.e., a read-only
- notification).
-
- \value ItemTransformChange The item's transformation matrix changes. This
- notification is send if the ItemSendsGeometryChanges flag is enabled, and
- when the item's local transformation matrix changes (i.e., as a result of
- calling setTransform(). The value argument is the new matrix (i.e., a
- QTransform); to get the old matrix, call transform(). Do not call
- setTransform() or set any of the transformation properties in itemChange()
- as this notification is delivered; instead, you can return the new matrix
- from itemChange(). This notification is not sent if you change the
- transformation properties.
-
- \value ItemTransformHasChanged The item's transformation matrix has
- changed either because setTransform is called, or one of the
- transformation properties is changed. This notification is sent if the
- ItemSendsGeometryChanges flag is enabled, and after the item's local
- transformation matrix has changed. The value argument is the new matrix
- (same as transform()), and QGraphicsItem ignores the return value for this
- notification (i.e., a read-only notification).
-
- \value ItemRotationChange The item's rotation property changes. This
- notification is sent if the ItemSendsGeometryChanges flag is enabled, and
- when the item's rotation property changes (i.e., as a result of calling
- setRotation()). The value argument is the new rotation (i.e., a double);
- to get the old rotation, call rotation(). Do not call setRotation() in
- itemChange() as this notification is delivered; instead, you can return
- the new rotation from itemChange().
-
- \value ItemRotationHasChanged The item's rotation property has changed.
- This notification is sent if the ItemSendsGeometryChanges flag is enabled,
- and after the item's rotation property has changed. The value argument is
- the new rotation (i.e., a double), and QGraphicsItem ignores the return
- value for this notification (i.e., a read-only notification). Do not call
- setRotation() in itemChange() as this notification is delivered.
-
- \value ItemScaleChange The item's scale property changes. This notification
- is sent if the ItemSendsGeometryChanges flag is enabled, and when the item's
- scale property changes (i.e., as a result of calling setScale()). The value
- argument is the new scale (i.e., a double); to get the old scale, call
- scale(). Do not call setScale() in itemChange() as this notification is
- delivered; instead, you can return the new scale from itemChange().
-
- \value ItemScaleHasChanged The item's scale property has changed. This
- notification is sent if the ItemSendsGeometryChanges flag is enabled, and
- after the item's scale property has changed. The value argument is the new
- scale (i.e., a double), and QGraphicsItem ignores the return value for this
- notification (i.e., a read-only notification). Do not call setScale() in
- itemChange() as this notification is delivered.
-
- \value ItemTransformOriginPointChange The item's transform origin point
- property changes. This notification is sent if the ItemSendsGeometryChanges
- flag is enabled, and when the item's transform origin point property changes
- (i.e., as a result of calling setTransformOriginPoint()). The value argument
- is the new origin point (i.e., a QPointF); to get the old origin point, call
- transformOriginPoint(). Do not call setTransformOriginPoint() in itemChange()
- as this notification is delivered; instead, you can return the new transform
- origin point from itemChange().
-
- \value ItemTransformOriginPointHasChanged The item's transform origin point
- property has changed. This notification is sent if the ItemSendsGeometryChanges
- flag is enabled, and after the item's transform origin point property has
- changed. The value argument is the new origin point (i.e., a QPointF), and
- QGraphicsItem ignores the return value for this notification (i.e., a read-only
- notification). Do not call setTransformOriginPoint() in itemChange() as this
- notification is delivered.
-
- \value ItemSelectedChange The item's selected state changes. If the item is
- presently selected, it will become unselected, and vice verca. The value
- argument is the new selected state (i.e., true or false). Do not call
- setSelected() in itemChange() as this notification is delivered; instead, you
- can return the new selected state from itemChange().
-
- \value ItemSelectedHasChanged The item's selected state has changed. The
- value argument is the new selected state (i.e., true or false). Do not
- call setSelected() in itemChange() as this notification is delivered. The
- return value is ignored.
-
- \value ItemVisibleChange The item's visible state changes. If the item is
- presently visible, it will become invisible, and vice verca. The value
- argument is the new visible state (i.e., true or false). Do not call
- setVisible() in itemChange() as this notification is delivered; instead,
- you can return the new visible state from itemChange().
-
- \value ItemVisibleHasChanged The item's visible state has changed. The
- value argument is the new visible state (i.e., true or false). Do not call
- setVisible() in itemChange() as this notification is delivered. The return
- value is ignored.
-
- \value ItemParentChange The item's parent changes. The value argument is
- the new parent item (i.e., a QGraphicsItem pointer). Do not call
- setParentItem() in itemChange() as this notification is delivered;
- instead, you can return the new parent from itemChange().
-
- \value ItemParentHasChanged The item's parent has changed. The value
- argument is the new parent (i.e., a pointer to a QGraphicsItem). Do not
- call setParentItem() in itemChange() as this notification is
- delivered. The return value is ignored.
-
- \value ItemChildAddedChange A child is added to this item. The value
- argument is the new child item (i.e., a QGraphicsItem pointer). Do not
- pass this item to any item's setParentItem() function as this notification
- is delivered. The return value is unused; you cannot adjust anything in
- this notification. Note that the new child might not be fully constructed
- when this notification is sent; calling pure virtual functions on
- the child can lead to a crash.
-
- \value ItemChildRemovedChange A child is removed from this item. The value
- argument is the child item that is about to be removed (i.e., a
- QGraphicsItem pointer). The return value is unused; you cannot adjust
- anything in this notification.
-
- \value ItemSceneChange The item is moved to a new scene. This notification is
- also sent when the item is added to its initial scene, and when it is removed.
- The item's scene() is the old scene (or 0 if the item has not been added to a
- scene yet). The value argument is the new scene (i.e., a QGraphicsScene
- pointer), or a null pointer if the item is removed from a scene. Do not
- override this change by passing this item to QGraphicsScene::addItem() as this
- notification is delivered; instead, you can return the new scene from
- itemChange(). Use this feature with caution; objecting to a scene change can
- quickly lead to unwanted recursion.
-
- \value ItemSceneHasChanged The item's scene has changed. The item's scene() is
- the new scene. This notification is also sent when the item is added to its
- initial scene, and when it is removed.The value argument is the new scene
- (i.e., a pointer to a QGraphicsScene). Do not call setScene() in itemChange()
- as this notification is delivered. The return value is ignored.
-
- \value ItemCursorChange The item's cursor changes. The value argument is
- the new cursor (i.e., a QCursor). Do not call setCursor() in itemChange()
- as this notification is delivered. Instead, you can return a new cursor
- from itemChange().
-
- \value ItemCursorHasChanged The item's cursor has changed. The value
- argument is the new cursor (i.e., a QCursor). Do not call setCursor() as
- this notification is delivered. The return value is ignored.
-
- \value ItemToolTipChange The item's tooltip changes. The value argument is
- the new tooltip (i.e., a QToolTip). Do not call setToolTip() in
- itemChange() as this notification is delivered. Instead, you can return a
- new tooltip from itemChange().
-
- \value ItemToolTipHasChanged The item's tooltip has changed. The value
- argument is the new tooltip (i.e., a QToolTip). Do not call setToolTip()
- as this notification is delivered. The return value is ignored.
-
- \value ItemFlagsChange The item's flags change. The value argument is the
- new flags (i.e., a quint32). Do not call setFlags() in itemChange() as
- this notification is delivered. Instead, you can return the new flags from
- itemChange().
-
- \value ItemFlagsHaveChanged The item's flags have changed. The value
- argument is the new flags (i.e., a quint32). Do not call setFlags() in
- itemChange() as this notification is delivered. The return value is
- ignored.
-
- \value ItemZValueChange The item's Z-value changes. The value argument is
- the new Z-value (i.e., a double). Do not call setZValue() in itemChange()
- as this notification is delivered. Instead, you can return a new Z-value
- from itemChange().
-
- \value ItemZValueHasChanged The item's Z-value has changed. The value
- argument is the new Z-value (i.e., a double). Do not call setZValue() as
- this notification is delivered. The return value is ignored.
-
- \value ItemOpacityChange The item's opacity changes. The value argument is
- the new opacity (i.e., a double). Do not call setOpacity() in itemChange()
- as this notification is delivered. Instead, you can return a new opacity
- from itemChange().
-
- \value ItemOpacityHasChanged The item's opacity has changed. The value
- argument is the new opacity (i.e., a double). Do not call setOpacity() as
- this notification is delivered. The return value is ignored.
-
- \value ItemScenePositionHasChanged The item's scene position has changed.
- This notification is sent if the ItemSendsScenePositionChanges flag is
- enabled, and after the item's scene position has changed (i.e., the
- position or transformation of the item itself or the position or
- transformation of any ancestor has changed). The value argument is the
- new scene position (the same as scenePos()), and QGraphicsItem ignores
- the return value for this notification (i.e., a read-only notification).
-*/
-
-/*!
- \enum QGraphicsItem::CacheMode
- \since 4.4
-
- This enum describes QGraphicsItem's cache modes. Caching is used to speed
- up rendering by allocating and rendering to an off-screen pixel buffer,
- which can be reused when the item requires redrawing. For some paint
- devices, the cache is stored directly in graphics memory, which makes
- rendering very quick.
-
- \value NoCache The default; all item caching is
- disabled. QGraphicsItem::paint() is called every time the item needs
- redrawing.
-
- \value ItemCoordinateCache Caching is enabled for the item's logical
- (local) coordinate system. QGraphicsItem creates an off-screen pixel
- buffer with a configurable size / resolution that you can pass to
- QGraphicsItem::setCacheMode(). Rendering quality will typically degrade,
- depending on the resolution of the cache and the item transformation. The
- first time the item is redrawn, it will render itself into the cache, and
- the cache is then reused for every subsequent expose. The cache is also
- reused as the item is transformed. To adjust the resolution of the cache,
- you can call setCacheMode() again.
-
- \value DeviceCoordinateCache Caching is enabled at the paint device level,
- in device coordinates. This mode is for items that can move, but are not
- rotated, scaled or sheared. If the item is transformed directly or
- indirectly, the cache will be regenerated automatically. Unlike
- ItemCoordinateCacheMode, DeviceCoordinateCache always renders at maximum
- quality.
-
- \sa QGraphicsItem::setCacheMode()
-*/
-
-/*!
- \enum QGraphicsItem::Extension
- \internal
-
- Note: This is provided as a hook to avoid future problems related
- to adding virtual functions. See also extension(),
- supportsExtension() and setExtension().
-*/
-
-/*!
- \enum QGraphicsItem::PanelModality
- \since 4.6
-
- This enum specifies the behavior of a modal panel. A modal panel
- is one that blocks input to other panels. Note that items that
- are children of a modal panel are not blocked.
-
- The values are:
-
- \value NonModal The panel is not modal and does not block input to
- other panels. This is the default value for panels.
-
- \value PanelModal The panel is modal to a single item hierarchy
- and blocks input to its parent pane, all grandparent panels, and
- all siblings of its parent and grandparent panels.
-
- \value SceneModal The window is modal to the entire scene and
- blocks input to all panels.
-
- \sa QGraphicsItem::setPanelModality(), QGraphicsItem::panelModality(), QGraphicsItem::ItemIsPanel
-*/
-
-#include "qgraphicsitem.h"
-
-#ifndef QT_NO_GRAPHICSVIEW
-
-#include "qgraphicsscene.h"
-#include "qgraphicsscene_p.h"
-#include "qgraphicssceneevent.h"
-#include "qgraphicsview.h"
-#include "qgraphicswidget.h"
-#include "qgraphicsproxywidget.h"
-#include "qgraphicsscenebsptreeindex_p.h"
-#include <QtCore/qbitarray.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/qpoint.h>
-#include <QtCore/qstack.h>
-#include <QtCore/qtimer.h>
-#include <QtCore/qvariant.h>
-#include <QtCore/qvarlengtharray.h>
-#include <QtCore/qnumeric.h>
-#include <QtGui/qapplication.h>
-#include <QtGui/qbitmap.h>
-#include <QtGui/qpainter.h>
-#include <QtGui/qpainterpath.h>
-#include <QtGui/qpixmapcache.h>
-#include <QtGui/qstyleoption.h>
-#include <QtGui/qevent.h>
-#include <QtGui/qinputcontext.h>
-#include <QtGui/qgraphicseffect.h>
-#ifndef QT_NO_ACCESSIBILITY
-# include "qaccessible.h"
-#endif
-
-#include <private/qgraphicsitem_p.h>
-#include <private/qgraphicswidget_p.h>
-#include <private/qtextcontrol_p.h>
-#include <private/qtextdocumentlayout_p.h>
-#include <private/qtextengine_p.h>
-#include <private/qwidget_p.h>
-#include <private/qapplication_p.h>
-
-#ifdef Q_WS_X11
-#include <private/qt_x11_p.h>
-#include <private/qpixmap_x11_p.h>
-#endif
-
-#include <private/qgesturemanager_p.h>
-
-#include <math.h>
-
-QT_BEGIN_NAMESPACE
-
-static inline void _q_adjustRect(QRect *rect)
-{
- Q_ASSERT(rect);
- if (!rect->width())
- rect->adjust(0, 0, 1, 0);
- if (!rect->height())
- rect->adjust(0, 0, 0, 1);
-}
-
-/*
- ### Move this into QGraphicsItemPrivate
- */
-class QGraphicsItemCustomDataStore
-{
-public:
- QMap<const QGraphicsItem *, QMap<int, QVariant> > data;
-};
-Q_GLOBAL_STATIC(QGraphicsItemCustomDataStore, qt_dataStore)
-
-/*!
- \internal
-
- Returns a QPainterPath of \a path when stroked with the \a pen.
- Ignoring dash pattern.
-*/
-static QPainterPath qt_graphicsItem_shapeFromPath(const QPainterPath &path, const QPen &pen)
-{
- // We unfortunately need this hack as QPainterPathStroker will set a width of 1.0
- // if we pass a value of 0.0 to QPainterPathStroker::setWidth()
- const qreal penWidthZero = qreal(0.00000001);
-
- if (path == QPainterPath())
- return path;
- QPainterPathStroker ps;
- ps.setCapStyle(pen.capStyle());
- if (pen.widthF() <= 0.0)
- ps.setWidth(penWidthZero);
- else
- ps.setWidth(pen.widthF());
- ps.setJoinStyle(pen.joinStyle());
- ps.setMiterLimit(pen.miterLimit());
- QPainterPath p = ps.createStroke(path);
- p.addPath(path);
- return p;
-}
-
-/*!
- \internal
-
- Propagates the ancestor flag \a flag with value \a enabled to all this
- item's children. If \a root is false, the flag is also set on this item
- (default is true).
-*/
-void QGraphicsItemPrivate::updateAncestorFlag(QGraphicsItem::GraphicsItemFlag childFlag,
- AncestorFlag flag, bool enabled, bool root)
-{
- Q_Q(QGraphicsItem);
- if (root) {
- // For root items only. This is the item that has either enabled or
- // disabled \a childFlag, or has been reparented.
- switch (int(childFlag)) {
- case -2:
- flag = AncestorFiltersChildEvents;
- enabled = q->filtersChildEvents();
- break;
- case -1:
- flag = AncestorHandlesChildEvents;
- enabled = q->handlesChildEvents();
- break;
- case QGraphicsItem::ItemClipsChildrenToShape:
- flag = AncestorClipsChildren;
- enabled = flags & QGraphicsItem::ItemClipsChildrenToShape;
- break;
- case QGraphicsItem::ItemIgnoresTransformations:
- flag = AncestorIgnoresTransformations;
- enabled = flags & QGraphicsItem::ItemIgnoresTransformations;
- break;
- default:
- return;
- }
-
- if (parent) {
- // Inherit the enabled-state from our parents.
- if ((parent->d_ptr->ancestorFlags & flag)
- || (int(parent->d_ptr->flags & childFlag) == childFlag)
- || (childFlag == -1 && parent->d_ptr->handlesChildEvents)
- || (childFlag == -2 && parent->d_ptr->filtersDescendantEvents)) {
- enabled = true;
- ancestorFlags |= flag;
- } else {
- ancestorFlags &= ~flag;
- }
- } else {
- // Top-level root items don't have any ancestors, so there are no
- // ancestor flags either.
- ancestorFlags = 0;
- }
- } else {
- // Don't set or propagate the ancestor flag if it's already correct.
- if (((ancestorFlags & flag) && enabled) || (!(ancestorFlags & flag) && !enabled))
- return;
-
- // Set the flag.
- if (enabled)
- ancestorFlags |= flag;
- else
- ancestorFlags &= ~flag;
-
- // Don't process children if the item has the main flag set on itself.
- if ((childFlag != -1 && int(flags & childFlag) == childFlag)
- || (int(childFlag) == -1 && handlesChildEvents)
- || (int(childFlag) == -2 && filtersDescendantEvents))
- return;
- }
-
- for (int i = 0; i < children.size(); ++i)
- children.at(i)->d_ptr->updateAncestorFlag(childFlag, flag, enabled, false);
-}
-
-void QGraphicsItemPrivate::updateAncestorFlags()
-{
- int flags = 0;
- if (parent) {
- // Inherit the parent's ancestor flags.
- QGraphicsItemPrivate *pd = parent->d_ptr.data();
- flags = pd->ancestorFlags;
-
- // Add in flags from the parent.
- if (pd->filtersDescendantEvents)
- flags |= AncestorFiltersChildEvents;
- if (pd->handlesChildEvents)
- flags |= AncestorHandlesChildEvents;
- if (pd->flags & QGraphicsItem::ItemClipsChildrenToShape)
- flags |= AncestorClipsChildren;
- if (pd->flags & QGraphicsItem::ItemIgnoresTransformations)
- flags |= AncestorIgnoresTransformations;
- }
-
- if (ancestorFlags == flags)
- return; // No change; stop propagation.
- ancestorFlags = flags;
-
- // Propagate to children recursively.
- for (int i = 0; i < children.size(); ++i)
- children.at(i)->d_ptr->updateAncestorFlags();
-}
-
-/*!
- \internal
-
- Propagates item group membership.
-*/
-void QGraphicsItemPrivate::setIsMemberOfGroup(bool enabled)
-{
- Q_Q(QGraphicsItem);
- isMemberOfGroup = enabled;
- if (!qgraphicsitem_cast<QGraphicsItemGroup *>(q)) {
- foreach (QGraphicsItem *child, children)
- child->d_func()->setIsMemberOfGroup(enabled);
- }
-}
-
-/*!
- \internal
-
- Maps any item pos properties of \a event to \a item's coordinate system.
-*/
-void QGraphicsItemPrivate::remapItemPos(QEvent *event, QGraphicsItem *item)
-{
- Q_Q(QGraphicsItem);
- switch (event->type()) {
- case QEvent::GraphicsSceneMouseMove:
- case QEvent::GraphicsSceneMousePress:
- case QEvent::GraphicsSceneMouseRelease:
- case QEvent::GraphicsSceneMouseDoubleClick: {
- QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);
- mouseEvent->setPos(item->mapFromItem(q, mouseEvent->pos()));
- mouseEvent->setLastPos(item->mapFromItem(q, mouseEvent->pos()));
- for (int i = 0x1; i <= 0x10; i <<= 1) {
- if (mouseEvent->buttons() & i) {
- Qt::MouseButton button = Qt::MouseButton(i);
- mouseEvent->setButtonDownPos(button, item->mapFromItem(q, mouseEvent->buttonDownPos(button)));
- }
- }
- break;
- }
- case QEvent::GraphicsSceneWheel: {
- QGraphicsSceneWheelEvent *wheelEvent = static_cast<QGraphicsSceneWheelEvent *>(event);
- wheelEvent->setPos(item->mapFromItem(q, wheelEvent->pos()));
- break;
- }
- case QEvent::GraphicsSceneContextMenu: {
- QGraphicsSceneContextMenuEvent *contextEvent = static_cast<QGraphicsSceneContextMenuEvent *>(event);
- contextEvent->setPos(item->mapFromItem(q, contextEvent->pos()));
- break;
- }
- case QEvent::GraphicsSceneHoverMove: {
- QGraphicsSceneHoverEvent *hoverEvent = static_cast<QGraphicsSceneHoverEvent *>(event);
- hoverEvent->setPos(item->mapFromItem(q, hoverEvent->pos()));
- break;
- }
- default:
- break;
- }
-}
-
-/*!
- \internal
-
- Maps the point \a pos from scene to item coordinates. If \a view is passed and the item
- is untransformable, this function will correctly map \a pos from the scene using the
- view's transformation.
-*/
-QPointF QGraphicsItemPrivate::genericMapFromScene(const QPointF &pos,
- const QWidget *viewport) const
-{
- Q_Q(const QGraphicsItem);
- if (!itemIsUntransformable())
- return q->mapFromScene(pos);
- QGraphicsView *view = 0;
- if (viewport)
- view = qobject_cast<QGraphicsView *>(viewport->parentWidget());
- if (!view)
- return q->mapFromScene(pos);
- // ### More ping pong than needed.
- return q->deviceTransform(view->viewportTransform()).inverted().map(view->mapFromScene(pos));
-}
-
-/*!
- \internal
-
- Combines this item's position and transform onto \a transform.
-
- If you need to change this function (e.g., adding more transformation
- modes / options), make sure to change all places marked with COMBINE.
-*/
-void QGraphicsItemPrivate::combineTransformToParent(QTransform *x, const QTransform *viewTransform) const
-{
- // COMBINE
- if (viewTransform && itemIsUntransformable()) {
- *x = q_ptr->deviceTransform(*viewTransform);
- } else {
- if (transformData)
- *x *= transformData->computedFullTransform();
- if (!pos.isNull())
- *x *= QTransform::fromTranslate(pos.x(), pos.y());
- }
-}
-
-/*!
- \internal
-
- Combines this item's position and transform onto \a transform.
-
- If you need to change this function (e.g., adding more transformation
- modes / options), make sure to change QGraphicsItem::deviceTransform() as
- well.
-*/
-void QGraphicsItemPrivate::combineTransformFromParent(QTransform *x, const QTransform *viewTransform) const
-{
- // COMBINE
- if (viewTransform && itemIsUntransformable()) {
- *x = q_ptr->deviceTransform(*viewTransform);
- } else {
- x->translate(pos.x(), pos.y());
- if (transformData)
- *x = transformData->computedFullTransform(x);
- }
-}
-
-void QGraphicsItemPrivate::updateSceneTransformFromParent()
-{
- if (parent) {
- Q_ASSERT(!parent->d_ptr->dirtySceneTransform);
- if (parent->d_ptr->sceneTransformTranslateOnly) {
- sceneTransform = QTransform::fromTranslate(parent->d_ptr->sceneTransform.dx() + pos.x(),
- parent->d_ptr->sceneTransform.dy() + pos.y());
- } else {
- sceneTransform = parent->d_ptr->sceneTransform;
- sceneTransform.translate(pos.x(), pos.y());
- }
- if (transformData) {
- sceneTransform = transformData->computedFullTransform(&sceneTransform);
- sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate);
- } else {
- sceneTransformTranslateOnly = parent->d_ptr->sceneTransformTranslateOnly;
- }
- } else if (!transformData) {
- sceneTransform = QTransform::fromTranslate(pos.x(), pos.y());
- sceneTransformTranslateOnly = 1;
- } else if (transformData->onlyTransform) {
- sceneTransform = transformData->transform;
- if (!pos.isNull())
- sceneTransform *= QTransform::fromTranslate(pos.x(), pos.y());
- sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate);
- } else if (pos.isNull()) {
- sceneTransform = transformData->computedFullTransform();
- sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate);
- } else {
- sceneTransform = QTransform::fromTranslate(pos.x(), pos.y());
- sceneTransform = transformData->computedFullTransform(&sceneTransform);
- sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate);
- }
- dirtySceneTransform = 0;
-}
-
-/*!
- \internal
-
- This helper function helped us add input method query support in
- Qt 4.4.1 without having to reimplement the inputMethodQuery()
- function in QGraphicsProxyWidget. ### Qt 5: Remove. We cannot
- remove it in 4.5+ even if we do reimplement the function properly,
- because apps compiled with 4.4 will not be able to call the
- reimplementation.
-*/
-QVariant QGraphicsItemPrivate::inputMethodQueryHelper(Qt::InputMethodQuery query) const
-{
- Q_UNUSED(query);
- return QVariant();
-}
-
-/*!
- \internal
-
- Make sure not to trigger any pure virtual function calls (e.g.,
- prepareGeometryChange) if the item is in its destructor, i.e.
- inDestructor is 1.
-*/
-void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const QVariant *newParentVariant,
- const QVariant *thisPointerVariant)
-{
- Q_Q(QGraphicsItem);
- if (newParent == parent)
- return;
-
- if (isWidget)
- static_cast<QGraphicsWidgetPrivate *>(this)->fixFocusChainBeforeReparenting((newParent &&
- newParent->isWidget()) ? static_cast<QGraphicsWidget *>(newParent) : 0,
- scene);
- if (scene) {
- // Deliver the change to the index
- if (scene->d_func()->indexMethod != QGraphicsScene::NoIndex)
- scene->d_func()->index->itemChange(q, QGraphicsItem::ItemParentChange, newParent);
-
- // Disable scene pos notifications for old ancestors
- if (scenePosDescendants || (flags & QGraphicsItem::ItemSendsScenePositionChanges))
- scene->d_func()->setScenePosItemEnabled(q, false);
- }
-
- if (subFocusItem && parent) {
- // Make sure none of the old parents point to this guy.
- subFocusItem->d_ptr->clearSubFocus(parent);
- }
-
- // We anticipate geometry changes. If the item is deleted, it will be
- // removed from the index at a later stage, and the whole scene will be
- // updated.
- if (!inDestructor)
- q_ptr->prepareGeometryChange();
-
- if (parent) {
- // Remove from current parent
- parent->d_ptr->removeChild(q);
- if (thisPointerVariant)
- parent->itemChange(QGraphicsItem::ItemChildRemovedChange, *thisPointerVariant);
- }
-
- // Update toplevelitem list. If this item is being deleted, its parent
- // will be 0 but we don't want to register/unregister it in the TLI list.
- if (scene && !inDestructor) {
- if (parent && !newParent) {
- scene->d_func()->registerTopLevelItem(q);
- } else if (!parent && newParent) {
- scene->d_func()->unregisterTopLevelItem(q);
- }
- }
-
- // Ensure any last parent focus scope does not point to this item or any of
- // its descendents.
- QGraphicsItem *p = parent;
- QGraphicsItem *parentFocusScopeItem = 0;
- while (p) {
- if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) {
- // If this item's focus scope's focus scope item points
- // to this item or a descendent, then clear it.
- QGraphicsItem *fsi = p->d_ptr->focusScopeItem;
- if (q_ptr == fsi || q_ptr->isAncestorOf(fsi)) {
- parentFocusScopeItem = fsi;
- p->d_ptr->focusScopeItem = 0;
- fsi->d_ptr->focusScopeItemChange(false);
- }
- break;
- }
- p = p->d_ptr->parent;
- }
-
- // Update graphics effect optimization flag
- if (newParent && (graphicsEffect || mayHaveChildWithGraphicsEffect))
- newParent->d_ptr->updateChildWithGraphicsEffectFlagRecursively();
-
- // Update focus scope item ptr in new scope.
- QGraphicsItem *newFocusScopeItem = subFocusItem ? subFocusItem : parentFocusScopeItem;
- if (newFocusScopeItem && newParent) {
- if (subFocusItem) {
- // Find the subFocusItem's topmost focus scope.
- QGraphicsItem *ancestorScope = 0;
- QGraphicsItem *p = subFocusItem->d_ptr->parent;
- while (p) {
- if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope)
- ancestorScope = p;
- if (p->d_ptr->flags & QGraphicsItem::ItemIsPanel)
- break;
- p = p->d_ptr->parent;
- }
- if (ancestorScope)
- newFocusScopeItem = ancestorScope;
- }
-
- QGraphicsItem *p = newParent;
- while (p) {
- if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) {
- p->d_ptr->focusScopeItem = newFocusScopeItem;
- newFocusScopeItem->d_ptr->focusScopeItemChange(true);
- // Ensure the new item is no longer the subFocusItem. The
- // only way to set focus on a child of a focus scope is
- // by setting focus on the scope itself.
- if (subFocusItem && !p->focusItem())
- subFocusItem->d_ptr->clearSubFocus();
- break;
- }
- p = p->d_ptr->parent;
- }
- }
-
- // Resolve depth.
- invalidateDepthRecursively();
-
- if ((parent = newParent)) {
- if (parent->d_func()->scene && parent->d_func()->scene != scene) {
- // Move this item to its new parent's scene
- parent->d_func()->scene->addItem(q);
- } else if (!parent->d_func()->scene && scene) {
- // Remove this item from its former scene
- scene->removeItem(q);
- }
-
- parent->d_ptr->addChild(q);
- if (thisPointerVariant)
- parent->itemChange(QGraphicsItem::ItemChildAddedChange, *thisPointerVariant);
- if (scene) {
- // Re-enable scene pos notifications for new ancestors
- if (scenePosDescendants || (flags & QGraphicsItem::ItemSendsScenePositionChanges))
- scene->d_func()->setScenePosItemEnabled(q, true);
- }
-
- // Propagate dirty flags to the new parent
- markParentDirty(/*updateBoundingRect=*/true);
-
- // Inherit ancestor flags from the new parent.
- updateAncestorFlags();
-
- // Update item visible / enabled.
- if (parent->d_ptr->visible != visible) {
- if (!parent->d_ptr->visible || !explicitlyHidden)
- setVisibleHelper(parent->d_ptr->visible, /* explicit = */ false, /* update = */ false);
- }
- if (parent->isEnabled() != enabled) {
- if (!parent->d_ptr->enabled || !explicitlyDisabled)
- setEnabledHelper(parent->d_ptr->enabled, /* explicit = */ false, /* update = */ false);
- }
-
- // Auto-activate if visible and the parent is active.
- if (visible && parent->isActive())
- q->setActive(true);
- } else {
- // Inherit ancestor flags from the new parent.
- updateAncestorFlags();
-
- if (!inDestructor) {
- // Update item visible / enabled.
- if (!visible && !explicitlyHidden)
- setVisibleHelper(true, /* explicit = */ false);
- if (!enabled && !explicitlyDisabled)
- setEnabledHelper(true, /* explicit = */ false);
- }
- }
-
- dirtySceneTransform = 1;
- if (!inDestructor && (transformData || (newParent && newParent->d_ptr->transformData)))
- transformChanged();
-
- // Restore the sub focus chain.
- if (subFocusItem) {
- subFocusItem->d_ptr->setSubFocus(newParent);
- if (parent && parent->isActive())
- subFocusItem->setFocus();
- }
-
- // Deliver post-change notification
- if (newParentVariant)
- q->itemChange(QGraphicsItem::ItemParentHasChanged, *newParentVariant);
-
- if (isObject)
- emit static_cast<QGraphicsObject *>(q)->parentChanged();
-}
-
-/*!
- \internal
-
- Returns the bounding rect of this item's children (excluding itself).
-*/
-void QGraphicsItemPrivate::childrenBoundingRectHelper(QTransform *x, QRectF *rect, QGraphicsItem *topMostEffectItem)
-{
- Q_Q(QGraphicsItem);
-
- QRectF childrenRect;
- QRectF *result = rect;
- rect = &childrenRect;
- const bool setTopMostEffectItem = !topMostEffectItem;
-
- for (int i = 0; i < children.size(); ++i) {
- QGraphicsItem *child = children.at(i);
- QGraphicsItemPrivate *childd = child->d_ptr.data();
- if (setTopMostEffectItem)
- topMostEffectItem = child;
- bool hasPos = !childd->pos.isNull();
- if (hasPos || childd->transformData) {
- // COMBINE
- QTransform matrix = childd->transformToParent();
- if (x)
- matrix *= *x;
- *rect |= matrix.mapRect(child->d_ptr->effectiveBoundingRect(topMostEffectItem));
- if (!childd->children.isEmpty())
- childd->childrenBoundingRectHelper(&matrix, rect, topMostEffectItem);
- } else {
- if (x)
- *rect |= x->mapRect(child->d_ptr->effectiveBoundingRect(topMostEffectItem));
- else
- *rect |= child->d_ptr->effectiveBoundingRect(topMostEffectItem);
- if (!childd->children.isEmpty())
- childd->childrenBoundingRectHelper(x, rect, topMostEffectItem);
- }
- }
-
- if (flags & QGraphicsItem::ItemClipsChildrenToShape){
- if (x)
- *rect &= x->mapRect(q->boundingRect());
- else
- *rect &= q->boundingRect();
- }
-
- *result |= *rect;
-}
-
-void QGraphicsItemPrivate::initStyleOption(QStyleOptionGraphicsItem *option, const QTransform &worldTransform,
- const QRegion &exposedRegion, bool allItems) const
-{
- Q_ASSERT(option);
- Q_Q(const QGraphicsItem);
-
- // Initialize standard QStyleOption values.
- const QRectF brect = q->boundingRect();
- option->state = QStyle::State_None;
- option->rect = brect.toRect();
- option->levelOfDetail = 1;
- option->exposedRect = brect;
- if (selected)
- option->state |= QStyle::State_Selected;
- if (enabled)
- option->state |= QStyle::State_Enabled;
- if (q->hasFocus())
- option->state |= QStyle::State_HasFocus;
- if (scene) {
- if (scene->d_func()->hoverItems.contains(q_ptr))
- option->state |= QStyle::State_MouseOver;
- if (q == scene->mouseGrabberItem())
- option->state |= QStyle::State_Sunken;
- }
-
- if (!(flags & QGraphicsItem::ItemUsesExtendedStyleOption))
- return;
-
- // Initialize QStyleOptionGraphicsItem specific values (matrix, exposedRect).
- option->matrix = worldTransform.toAffine(); //### discards perspective
-
- if (!allItems) {
- // Determine the item's exposed area
- option->exposedRect = QRectF();
- const QTransform reverseMap = worldTransform.inverted();
- const QVector<QRect> exposedRects(exposedRegion.rects());
- for (int i = 0; i < exposedRects.size(); ++i) {
- option->exposedRect |= reverseMap.mapRect(QRectF(exposedRects.at(i)));
- if (option->exposedRect.contains(brect))
- break;
- }
- option->exposedRect &= brect;
- }
-}
-
-/*!
- \internal
-
- Empty all cached pixmaps from the pixmap cache.
-*/
-void QGraphicsItemCache::purge()
-{
- QPixmapCache::remove(key);
- key = QPixmapCache::Key();
- QMutableMapIterator<QPaintDevice *, DeviceData> it(deviceData);
- while (it.hasNext()) {
- DeviceData &data = it.next().value();
- QPixmapCache::remove(data.key);
- data.cacheIndent = QPoint();
- }
- deviceData.clear();
- allExposed = true;
- exposed.clear();
-}
-
-/*!
- Constructs a QGraphicsItem with the given \a parent item.
- It does not modify the parent object returned by QObject::parent().
-
- If \a parent is 0, you can add the item to a scene by calling
- QGraphicsScene::addItem(). The item will then become a top-level item.
-
- \sa QGraphicsScene::addItem(), setParentItem()
-*/
-QGraphicsItem::QGraphicsItem(QGraphicsItem *parent
-#ifndef Q_QDOC
- // obsolete argument
- , QGraphicsScene *scene
-#endif
- )
- : d_ptr(new QGraphicsItemPrivate)
-{
- d_ptr->q_ptr = this;
- setParentItem(parent);
-
- if (scene && parent && parent->scene() != scene) {
- qWarning("QGraphicsItem::QGraphicsItem: ignoring scene (%p), which is"
- " different from parent's scene (%p)",
- scene, parent->scene());
- return;
- }
- if (scene && !parent)
- scene->addItem(this);
-}
-
-/*!
- \internal
-*/
-QGraphicsItem::QGraphicsItem(QGraphicsItemPrivate &dd, QGraphicsItem *parent,
- QGraphicsScene *scene)
- : d_ptr(&dd)
-{
- d_ptr->q_ptr = this;
- setParentItem(parent);
-
- if (scene && parent && parent->scene() != scene) {
- qWarning("QGraphicsItem::QGraphicsItem: ignoring scene (%p), which is"
- " different from parent's scene (%p)",
- scene, parent->scene());
- return;
- }
- if (scene && !parent)
- scene->addItem(this);
-}
-
-/*!
- Destroys the QGraphicsItem and all its children. If this item is currently
- associated with a scene, the item will be removed from the scene before it
- is deleted.
-
- \note It is more efficient to remove the item from the QGraphicsScene before
- destroying the item.
-*/
-QGraphicsItem::~QGraphicsItem()
-{
- if (d_ptr->isObject) {
- QGraphicsObject *o = static_cast<QGraphicsObject *>(this);
- QObjectPrivate *p = QObjectPrivate::get(o);
- p->wasDeleted = true;
- if (p->declarativeData) {
- QAbstractDeclarativeData::destroyed(p->declarativeData, o);
- p->declarativeData = 0;
- }
- }
-
- d_ptr->inDestructor = 1;
- d_ptr->removeExtraItemCache();
-
-#ifndef QT_NO_GESTURES
- if (d_ptr->isObject && !d_ptr->gestureContext.isEmpty()) {
- QGraphicsObject *o = static_cast<QGraphicsObject *>(this);
- if (QGestureManager *manager = QGestureManager::instance()) {
- foreach (Qt::GestureType type, d_ptr->gestureContext.keys())
- manager->cleanupCachedGestures(o, type);
- }
- }
-#endif
-
- clearFocus();
-
- // Update focus scope item ptr.
- QGraphicsItem *p = d_ptr->parent;
- while (p) {
- if (p->flags() & ItemIsFocusScope) {
- if (p->d_ptr->focusScopeItem == this)
- p->d_ptr->focusScopeItem = 0;
- break;
- }
- p = p->d_ptr->parent;
- }
-
- if (!d_ptr->children.isEmpty()) {
- while (!d_ptr->children.isEmpty())
- delete d_ptr->children.first();
- Q_ASSERT(d_ptr->children.isEmpty());
- }
-
- if (d_ptr->scene) {
- d_ptr->scene->d_func()->removeItemHelper(this);
- } else {
- d_ptr->resetFocusProxy();
- setParentItem(0);
- }
-
-#ifndef QT_NO_GRAPHICSEFFECT
- delete d_ptr->graphicsEffect;
-#endif //QT_NO_GRAPHICSEFFECT
- if (d_ptr->transformData) {
- for(int i = 0; i < d_ptr->transformData->graphicsTransforms.size(); ++i) {
- QGraphicsTransform *t = d_ptr->transformData->graphicsTransforms.at(i);
- static_cast<QGraphicsTransformPrivate *>(t->d_ptr.data())->item = 0;
- delete t;
- }
- }
- delete d_ptr->transformData;
-
- if (QGraphicsItemCustomDataStore *dataStore = qt_dataStore())
- dataStore->data.remove(this);
-}
-
-/*!
- Returns the current scene for the item, or 0 if the item is not stored in
- a scene.
-
- To add or move an item to a scene, call QGraphicsScene::addItem().
-*/
-QGraphicsScene *QGraphicsItem::scene() const
-{
- return d_ptr->scene;
-}
-
-/*!
- Returns a pointer to this item's item group, or 0 if this item is not
- member of a group.
-
- \sa QGraphicsItemGroup, QGraphicsScene::createItemGroup()
-*/
-QGraphicsItemGroup *QGraphicsItem::group() const
-{
- if (!d_ptr->isMemberOfGroup)
- return 0;
- QGraphicsItem *parent = const_cast<QGraphicsItem *>(this);
- while ((parent = parent->d_ptr->parent)) {
- if (QGraphicsItemGroup *group = qgraphicsitem_cast<QGraphicsItemGroup *>(parent))
- return group;
- }
- // Unreachable; if d_ptr->isMemberOfGroup is != 0, then one parent of this
- // item is a group item.
- return 0;
-}
-
-/*!
- Adds this item to the item group \a group. If \a group is 0, this item is
- removed from any current group and added as a child of the previous
- group's parent.
-
- \sa group(), QGraphicsScene::createItemGroup()
-*/
-void QGraphicsItem::setGroup(QGraphicsItemGroup *group)
-{
- if (!group) {
- if (QGraphicsItemGroup *group = this->group())
- group->removeFromGroup(this);
- } else {
- group->addToGroup(this);
- }
-}
-
-/*!
- Returns a pointer to this item's parent item. If this item does not have a
- parent, 0 is returned.
-
- \sa setParentItem(), childItems()
-*/
-QGraphicsItem *QGraphicsItem::parentItem() const
-{
- return d_ptr->parent;
-}
-
-/*!
- Returns this item's top-level item. The top-level item is the item's
- topmost ancestor item whose parent is 0. If an item has no parent, its own
- pointer is returned (i.e., a top-level item is its own top-level item).
-
- \sa parentItem()
-*/
-QGraphicsItem *QGraphicsItem::topLevelItem() const
-{
- QGraphicsItem *parent = const_cast<QGraphicsItem *>(this);
- while (QGraphicsItem *grandPa = parent->parentItem())
- parent = grandPa;
- return parent;
-}
-
-/*!
- \since 4.6
-
- Returns a pointer to the item's parent, cast to a QGraphicsObject. returns 0 if the parent item
- is not a QGraphicsObject.
-
- \sa parentItem(), childItems()
-*/
-QGraphicsObject *QGraphicsItem::parentObject() const
-{
- QGraphicsItem *p = d_ptr->parent;
- return (p && p->d_ptr->isObject) ? static_cast<QGraphicsObject *>(p) : 0;
-}
-
-/*!
- \since 4.4
-
- Returns a pointer to the item's parent widget. The item's parent widget is
- the closest parent item that is a widget.
-
- \sa parentItem(), childItems()
-*/
-QGraphicsWidget *QGraphicsItem::parentWidget() const
-{
- QGraphicsItem *p = parentItem();
- while (p && !p->isWidget())
- p = p->parentItem();
- return (p && p->isWidget()) ? static_cast<QGraphicsWidget *>(p) : 0;
-}
-
-/*!
- \since 4.4
-
- Returns a pointer to the item's top level widget (i.e., the item's
- ancestor whose parent is 0, or whose parent is not a widget), or 0 if this
- item does not have a top level widget. If the item is its own top level
- widget, this function returns a pointer to the item itself.
-*/
-QGraphicsWidget *QGraphicsItem::topLevelWidget() const
-{
- if (const QGraphicsWidget *p = parentWidget())
- return p->topLevelWidget();
- return isWidget() ? static_cast<QGraphicsWidget *>(const_cast<QGraphicsItem *>(this)) : 0;
-}
-
-/*!
- \since 4.4
-
- Returns the item's window, or 0 if this item does not have a window. If
- the item is a window, it will return itself. Otherwise it will return the
- closest ancestor that is a window.
-
- \sa QGraphicsWidget::isWindow()
-*/
-QGraphicsWidget *QGraphicsItem::window() const
-{
- QGraphicsItem *p = panel();
- if (p && p->isWindow())
- return static_cast<QGraphicsWidget *>(p);
- return 0;
-}
-
-/*!
- \since 4.6
-
- Returns the item's panel, or 0 if this item does not have a panel. If the
- item is a panel, it will return itself. Otherwise it will return the
- closest ancestor that is a panel.
-
- \sa isPanel(), ItemIsPanel
-*/
-QGraphicsItem *QGraphicsItem::panel() const
-{
- if (d_ptr->flags & ItemIsPanel)
- return const_cast<QGraphicsItem *>(this);
- return d_ptr->parent ? d_ptr->parent->panel() : 0;
-}
-
-/*!
- \since 4.6
-
- Return the graphics item cast to a QGraphicsObject, if the class is actually a
- graphics object, 0 otherwise.
-*/
-QGraphicsObject *QGraphicsItem::toGraphicsObject()
-{
- return d_ptr->isObject ? static_cast<QGraphicsObject *>(this) : 0;
-}
-
-/*!
- \since 4.6
-
- Return the graphics item cast to a QGraphicsObject, if the class is actually a
- graphics object, 0 otherwise.
-*/
-const QGraphicsObject *QGraphicsItem::toGraphicsObject() const
-{
- return d_ptr->isObject ? static_cast<const QGraphicsObject *>(this) : 0;
-}
-
-/*!
- Sets this item's parent item to \a newParent. If this item already
- has a parent, it is first removed from the previous parent. If \a
- newParent is 0, this item will become a top-level item.
-
- Note that this implicitly adds this graphics item to the scene of
- the parent. You should not \l{QGraphicsScene::addItem()}{add} the
- item to the scene yourself.
-
- Calling this function on an item that is an ancestor of \a newParent
- have undefined behaviour.
-
- \sa parentItem(), childItems()
-*/
-void QGraphicsItem::setParentItem(QGraphicsItem *newParent)
-{
- if (newParent == this) {
- qWarning("QGraphicsItem::setParentItem: cannot assign %p as a parent of itself", this);
- return;
- }
- if (newParent == d_ptr->parent)
- return;
-
- const QVariant newParentVariant(itemChange(QGraphicsItem::ItemParentChange,
- QVariant::fromValue<QGraphicsItem *>(newParent)));
- newParent = qvariant_cast<QGraphicsItem *>(newParentVariant);
- if (newParent == d_ptr->parent)
- return;
-
- const QVariant thisPointerVariant(QVariant::fromValue<QGraphicsItem *>(this));
- d_ptr->setParentItemHelper(newParent, &newParentVariant, &thisPointerVariant);
-}
-
-/*!
- \obsolete
-
- Use childItems() instead.
-
- \sa setParentItem()
-*/
-QList<QGraphicsItem *> QGraphicsItem::children() const
-{
- return childItems();
-}
-
-/*!
- \since 4.4
-
- Returns a list of this item's children.
-
- The items are sorted by stacking order. This takes into account both the
- items' insertion order and their Z-values.
-
- \sa setParentItem(), zValue(), {QGraphicsItem#Sorting}{Sorting}
-*/
-QList<QGraphicsItem *> QGraphicsItem::childItems() const
-{
- const_cast<QGraphicsItem *>(this)->d_ptr->ensureSortedChildren();
- return d_ptr->children;
-}
-
-/*!
- \since 4.4
- Returns true if this item is a widget (i.e., QGraphicsWidget); otherwise,
- returns false.
-*/
-bool QGraphicsItem::isWidget() const
-{
- return d_ptr->isWidget;
-}
-
-/*!
- \since 4.4
- Returns true if the item is a QGraphicsWidget window, otherwise returns
- false.
-
- \sa QGraphicsWidget::windowFlags()
-*/
-bool QGraphicsItem::isWindow() const
-{
- return d_ptr->isWidget && (static_cast<const QGraphicsWidget *>(this)->windowType() & Qt::Window);
-}
-
-/*!
- \since 4.6
- Returns true if the item is a panel; otherwise returns false.
-
- \sa QGraphicsItem::panel(), ItemIsPanel
-*/
-bool QGraphicsItem::isPanel() const
-{
- return d_ptr->flags & ItemIsPanel;
-}
-
-/*!
- Returns this item's flags. The flags describe what configurable features
- of the item are enabled and not. For example, if the flags include
- ItemIsFocusable, the item can accept input focus.
-
- By default, no flags are enabled.
-
- \sa setFlags(), setFlag()
-*/
-QGraphicsItem::GraphicsItemFlags QGraphicsItem::flags() const
-{
- return GraphicsItemFlags(d_ptr->flags);
-}
-
-/*!
- If \a enabled is true, the item flag \a flag is enabled; otherwise, it is
- disabled.
-
- \sa flags(), setFlags()
-*/
-void QGraphicsItem::setFlag(GraphicsItemFlag flag, bool enabled)
-{
- if (enabled)
- setFlags(GraphicsItemFlags(d_ptr->flags) | flag);
- else
- setFlags(GraphicsItemFlags(d_ptr->flags) & ~flag);
-}
-
-/*!
- \internal
-
- Sets the flag \a flag on \a item and all its children, to \a enabled.
-*/
-static void _q_qgraphicsItemSetFlag(QGraphicsItem *item, QGraphicsItem::GraphicsItemFlag flag,
- bool enabled)
-{
- if (item->flags() & flag) {
- // If this item already has the correct flag set, we don't have to
- // propagate it.
- return;
- }
- item->setFlag(flag, enabled);
- foreach (QGraphicsItem *child, item->children())
- _q_qgraphicsItemSetFlag(child, flag, enabled);
-}
-
-/*!
- Sets the item flags to \a flags. All flags in \a flags are enabled; all
- flags not in \a flags are disabled.
-
- If the item had focus and \a flags does not enable ItemIsFocusable, the
- item loses focus as a result of calling this function. Similarly, if the
- item was selected, and \a flags does not enabled ItemIsSelectable, the
- item is automatically unselected.
-
- By default, no flags are enabled. (QGraphicsWidget enables the
- ItemSendsGeometryChanges flag by default in order to track position
- changes.)
-
- \sa flags(), setFlag()
-*/
-void QGraphicsItem::setFlags(GraphicsItemFlags flags)
-{
- // Notify change and check for adjustment.
- if (quint32(d_ptr->flags) == quint32(flags))
- return;
- flags = GraphicsItemFlags(itemChange(ItemFlagsChange, quint32(flags)).toUInt());
- if (quint32(d_ptr->flags) == quint32(flags))
- return;
- if (d_ptr->scene && d_ptr->scene->d_func()->indexMethod != QGraphicsScene::NoIndex)
- d_ptr->scene->d_func()->index->itemChange(this, ItemFlagsChange, &flags);
-
- // Flags that alter the geometry of the item (or its children).
- const quint32 geomChangeFlagsMask = (ItemClipsChildrenToShape | ItemClipsToShape | ItemIgnoresTransformations | ItemIsSelectable);
- bool fullUpdate = (quint32(flags) & geomChangeFlagsMask) != (d_ptr->flags & geomChangeFlagsMask);
- if (fullUpdate)
- d_ptr->updatePaintedViewBoundingRects(/*children=*/true);
-
- // Keep the old flags to compare the diff.
- GraphicsItemFlags oldFlags = GraphicsItemFlags(d_ptr->flags);
-
- // Update flags.
- d_ptr->flags = flags;
-
- if (!(d_ptr->flags & ItemIsFocusable) && hasFocus()) {
- // Clear focus on the item if it has focus when the focusable flag
- // is unset.
- clearFocus();
- }
-
- if (!(d_ptr->flags & ItemIsSelectable) && isSelected()) {
- // Unselect the item if it is selected when the selectable flag is
- // unset.
- setSelected(false);
- }
-
- if ((flags & ItemClipsChildrenToShape) != (oldFlags & ItemClipsChildrenToShape)) {
- // Item children clipping changes. Propagate the ancestor flag to
- // all children.
- d_ptr->updateAncestorFlag(ItemClipsChildrenToShape);
- // The childrenBoundingRect is clipped to the boundingRect in case of ItemClipsChildrenToShape,
- // which means we have to invalidate the cached childrenBoundingRect whenever this flag changes.
- d_ptr->dirtyChildrenBoundingRect = 1;
- d_ptr->markParentDirty(true);
- }
-
- if ((flags & ItemIgnoresTransformations) != (oldFlags & ItemIgnoresTransformations)) {
- // Item children clipping changes. Propagate the ancestor flag to
- // all children.
- d_ptr->updateAncestorFlag(ItemIgnoresTransformations);
- }
-
- if ((flags & ItemNegativeZStacksBehindParent) != (oldFlags & ItemNegativeZStacksBehindParent)) {
- // NB! We change the flags directly here, so we must also update d_ptr->flags.
- // Note that this has do be done before the ItemStacksBehindParent check
- // below; otherwise we will loose the change.
-
- // Update stack-behind.
- if (d_ptr->z < qreal(0.0))
- flags |= ItemStacksBehindParent;
- else
- flags &= ~ItemStacksBehindParent;
- d_ptr->flags = flags;
- }
-
- if ((flags & ItemStacksBehindParent) != (oldFlags & ItemStacksBehindParent)) {
- // NB! This check has to come after the ItemNegativeZStacksBehindParent
- // check above. Be careful.
-
- // Ensure child item sorting is up to date when toggling this flag.
- if (d_ptr->parent)
- d_ptr->parent->d_ptr->needSortChildren = 1;
- else if (d_ptr->scene)
- d_ptr->scene->d_func()->needSortTopLevelItems = 1;
- }
-
- if ((flags & ItemAcceptsInputMethod) != (oldFlags & ItemAcceptsInputMethod)) {
- // Update input method sensitivity in any views.
- if (d_ptr->scene)
- d_ptr->scene->d_func()->updateInputMethodSensitivityInViews();
- }
-
-
- if ((d_ptr->panelModality != NonModal)
- && d_ptr->scene
- && (flags & ItemIsPanel) != (oldFlags & ItemIsPanel)) {
- // update the panel's modal state
- if (flags & ItemIsPanel)
- d_ptr->scene->d_func()->enterModal(this);
- else
- d_ptr->scene->d_func()->leaveModal(this);
- }
-
- if (d_ptr->scene) {
- if ((flags & ItemSendsScenePositionChanges) != (oldFlags & ItemSendsScenePositionChanges)) {
- if (flags & ItemSendsScenePositionChanges)
- d_ptr->scene->d_func()->registerScenePosItem(this);
- else
- d_ptr->scene->d_func()->unregisterScenePosItem(this);
- }
- d_ptr->scene->d_func()->markDirty(this, QRectF(), /*invalidateChildren=*/true);
- }
-
- // Notify change.
- itemChange(ItemFlagsHaveChanged, quint32(flags));
-}
-
-/*!
- \since 4.4
- Returns the cache mode for this item. The default mode is NoCache (i.e.,
- cache is disabled and all painting is immediate).
-
- \sa setCacheMode()
-*/
-QGraphicsItem::CacheMode QGraphicsItem::cacheMode() const
-{
- return QGraphicsItem::CacheMode(d_ptr->cacheMode);
-}
-
-/*!
- \since 4.4
- Sets the item's cache mode to \a mode.
-
- The optional \a logicalCacheSize argument is used only by
- ItemCoordinateCache mode, and describes the resolution of the cache
- buffer; if \a logicalCacheSize is (100, 100), QGraphicsItem will fit the
- item into 100x100 pixels in graphics memory, regardless of the logical
- size of the item itself. By default QGraphicsItem uses the size of
- boundingRect(). For all other cache modes than ItemCoordinateCache, \a
- logicalCacheSize is ignored.
-
- Caching can speed up rendering if your item spends a significant time
- redrawing itself. In some cases the cache can also slow down rendering, in
- particular when the item spends less time redrawing than QGraphicsItem
- spends redrawing from the cache. When enabled, the item's paint() function
- will be called only once for each call to update(); for any subsequent
- repaint requests, the Graphics View framework will redraw from the
- cache. This approach works particularly well with QGLWidget, which stores
- all the cache as OpenGL textures.
-
- Be aware that QPixmapCache's cache limit may need to be changed to obtain
- optimal performance.
-
- You can read more about the different cache modes in the CacheMode
- documentation.
-
- \sa CacheMode, QPixmapCache::setCacheLimit()
-*/
-void QGraphicsItem::setCacheMode(CacheMode mode, const QSize &logicalCacheSize)
-{
- CacheMode lastMode = CacheMode(d_ptr->cacheMode);
- d_ptr->cacheMode = mode;
- bool noVisualChange = (mode == NoCache && lastMode == NoCache)
- || (mode == NoCache && lastMode == DeviceCoordinateCache)
- || (mode == DeviceCoordinateCache && lastMode == NoCache)
- || (mode == DeviceCoordinateCache && lastMode == DeviceCoordinateCache);
- if (mode == NoCache) {
- d_ptr->removeExtraItemCache();
- } else {
- QGraphicsItemCache *cache = d_ptr->extraItemCache();
-
- // Reset old cache
- cache->purge();
-
- if (mode == ItemCoordinateCache) {
- if (lastMode == mode && cache->fixedSize == logicalCacheSize)
- noVisualChange = true;
- cache->fixedSize = logicalCacheSize;
- }
- }
- if (!noVisualChange)
- update();
-}
-
-/*!
- \since 4.6
-
- Returns the modality for this item.
-*/
-QGraphicsItem::PanelModality QGraphicsItem::panelModality() const
-{
- return d_ptr->panelModality;
-}
-
-/*!
- \since 4.6
-
- Sets the modality for this item to \a panelModality.
-
- Changing the modality of a visible item takes effect immediately.
-*/
-void QGraphicsItem::setPanelModality(PanelModality panelModality)
-{
- if (d_ptr->panelModality == panelModality)
- return;
-
- PanelModality previousModality = d_ptr->panelModality;
- bool enterLeaveModal = (isPanel() && d_ptr->scene && isVisible());
- if (enterLeaveModal && panelModality == NonModal)
- d_ptr->scene->d_func()->leaveModal(this);
- d_ptr->panelModality = panelModality;
- if (enterLeaveModal && d_ptr->panelModality != NonModal)
- d_ptr->scene->d_func()->enterModal(this, previousModality);
-}
-
-/*!
- \since 4.6
-
- Returns true if this item is blocked by a modal panel, false otherwise. If \a blockingPanel is
- non-zero, \a blockingPanel will be set to the modal panel that is blocking this item. If this
- item is not blocked, \a blockingPanel will not be set by this function.
-
- This function always returns false for items not in a scene.
-
- \sa panelModality() setPanelModality() PanelModality
-*/
-bool QGraphicsItem::isBlockedByModalPanel(QGraphicsItem **blockingPanel) const
-{
- if (!d_ptr->scene)
- return false;
-
-
- QGraphicsItem *dummy = 0;
- if (!blockingPanel)
- blockingPanel = &dummy;
-
- QGraphicsScenePrivate *scene_d = d_ptr->scene->d_func();
- if (scene_d->modalPanels.isEmpty())
- return false;
-
- // ###
- if (!scene_d->popupWidgets.isEmpty() && scene_d->popupWidgets.first() == this)
- return false;
-
- for (int i = 0; i < scene_d->modalPanels.count(); ++i) {
- QGraphicsItem *modalPanel = scene_d->modalPanels.at(i);
- if (modalPanel->panelModality() == QGraphicsItem::SceneModal) {
- // Scene modal panels block all non-descendents.
- if (modalPanel != this && !modalPanel->isAncestorOf(this)) {
- *blockingPanel = modalPanel;
- return true;
- }
- } else {
- // Window modal panels block ancestors and siblings/cousins.
- if (modalPanel != this
- && !modalPanel->isAncestorOf(this)
- && commonAncestorItem(modalPanel)) {
- *blockingPanel = modalPanel;
- return true;
- }
- }
- }
- return false;
-}
-
-#ifndef QT_NO_TOOLTIP
-/*!
- Returns the item's tool tip, or an empty QString if no tool tip has been
- set.
-
- \sa setToolTip(), QToolTip
-*/
-QString QGraphicsItem::toolTip() const
-{
- return d_ptr->extra(QGraphicsItemPrivate::ExtraToolTip).toString();
-}
-
-/*!
- Sets the item's tool tip to \a toolTip. If \a toolTip is empty, the item's
- tool tip is cleared.
-
- \sa toolTip(), QToolTip
-*/
-void QGraphicsItem::setToolTip(const QString &toolTip)
-{
- const QVariant toolTipVariant(itemChange(ItemToolTipChange, toolTip));
- d_ptr->setExtra(QGraphicsItemPrivate::ExtraToolTip, toolTipVariant.toString());
- itemChange(ItemToolTipHasChanged, toolTipVariant);
-}
-#endif // QT_NO_TOOLTIP
-
-#ifndef QT_NO_CURSOR
-/*!
- Returns the current cursor shape for the item. The mouse cursor
- will assume this shape when it's over this item. See the \link
- Qt::CursorShape list of predefined cursor objects\endlink for a
- range of useful shapes.
-
- An editor item might want to use an I-beam cursor:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 2
-
- If no cursor has been set, the cursor of the item beneath is used.
-
- \sa setCursor(), hasCursor(), unsetCursor(), QWidget::cursor,
- QApplication::overrideCursor()
-*/
-QCursor QGraphicsItem::cursor() const
-{
- return qvariant_cast<QCursor>(d_ptr->extra(QGraphicsItemPrivate::ExtraCursor));
-}
-
-/*!
- Sets the current cursor shape for the item to \a cursor. The mouse cursor
- will assume this shape when it's over this item. See the \link
- Qt::CursorShape list of predefined cursor objects\endlink for a range of
- useful shapes.
-
- An editor item might want to use an I-beam cursor:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 3
-
- If no cursor has been set, the cursor of the item beneath is used.
-
- \sa cursor(), hasCursor(), unsetCursor(), QWidget::cursor,
- QApplication::overrideCursor()
-*/
-void QGraphicsItem::setCursor(const QCursor &cursor)
-{
- const QVariant cursorVariant(itemChange(ItemCursorChange, QVariant::fromValue<QCursor>(cursor)));
- d_ptr->setExtra(QGraphicsItemPrivate::ExtraCursor, qvariant_cast<QCursor>(cursorVariant));
- d_ptr->hasCursor = 1;
- if (d_ptr->scene) {
- d_ptr->scene->d_func()->allItemsUseDefaultCursor = false;
- foreach (QGraphicsView *view, d_ptr->scene->views()) {
- view->viewport()->setMouseTracking(true);
- // Note: Some of this logic is duplicated in QGraphicsView's mouse events.
- if (view->underMouse()) {
- foreach (QGraphicsItem *itemUnderCursor, view->items(view->mapFromGlobal(QCursor::pos()))) {
- if (itemUnderCursor->hasCursor()) {
- QMetaObject::invokeMethod(view, "_q_setViewportCursor",
- Q_ARG(QCursor, itemUnderCursor->cursor()));
- break;
- }
- }
- break;
- }
- }
- }
- itemChange(ItemCursorHasChanged, cursorVariant);
-}
-
-/*!
- Returns true if this item has a cursor set; otherwise, false is returned.
-
- By default, items don't have any cursor set. cursor() will return a
- standard pointing arrow cursor.
-
- \sa unsetCursor()
-*/
-bool QGraphicsItem::hasCursor() const
-{
- return d_ptr->hasCursor;
-}
-
-/*!
- Clears the cursor from this item.
-
- \sa hasCursor(), setCursor()
-*/
-void QGraphicsItem::unsetCursor()
-{
- d_ptr->unsetExtra(QGraphicsItemPrivate::ExtraCursor);
- d_ptr->hasCursor = 0;
- if (d_ptr->scene) {
- foreach (QGraphicsView *view, d_ptr->scene->views()) {
- if (view->underMouse() && view->itemAt(view->mapFromGlobal(QCursor::pos())) == this) {
- QMetaObject::invokeMethod(view, "_q_unsetViewportCursor");
- break;
- }
- }
- }
-}
-
-#endif // QT_NO_CURSOR
-
-/*!
- Returns true if the item is visible; otherwise, false is returned.
-
- Note that the item's general visibility is unrelated to whether or not it
- is actually being visualized by a QGraphicsView.
-
- \sa setVisible()
-*/
-bool QGraphicsItem::isVisible() const
-{
- return d_ptr->visible;
-}
-
-/*!
- \since 4.4
- Returns true if the item is visible to \a parent; otherwise, false is
- returned. \a parent can be 0, in which case this function will return
- whether the item is visible to the scene or not.
-
- An item may not be visible to its ancestors even if isVisible() is true. If
- any ancestor is hidden, the item itself will be implicitly hidden, in which
- case this function will return false.
-
- \sa isVisible(), setVisible()
-*/
-bool QGraphicsItem::isVisibleTo(const QGraphicsItem *parent) const
-{
- if (!d_ptr->visible)
- return false;
- if (parent == this)
- return true;
- if (parentItem() && parentItem()->isVisibleTo(parent))
- return true;
- if (!parent && !parentItem())
- return true;
- return false;
-}
-
-/*!
- \internal
-
- Sets this item's visibility to \a newVisible. If \a explicitly is true,
- this item will be "explicitly" \a newVisible; otherwise, it.. will not be.
-*/
-void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bool update)
-{
- Q_Q(QGraphicsItem);
-
- // Update explicit bit.
- if (explicitly)
- explicitlyHidden = newVisible ? 0 : 1;
-
- // Check if there's nothing to do.
- if (visible == quint32(newVisible))
- return;
-
- // Don't show child if parent is not visible
- if (parent && newVisible && !parent->d_ptr->visible)
- return;
-
- // Modify the property.
- const QVariant newVisibleVariant(q_ptr->itemChange(QGraphicsItem::ItemVisibleChange,
- quint32(newVisible)));
- newVisible = newVisibleVariant.toBool();
- if (visible == quint32(newVisible))
- return;
- visible = newVisible;
-
- // Schedule redrawing
- if (update) {
- QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));
- if (c)
- c->purge();
- if (scene) {
-#ifndef QT_NO_GRAPHICSEFFECT
- invalidateParentGraphicsEffectsRecursively();
-#endif //QT_NO_GRAPHICSEFFECT
- scene->d_func()->markDirty(q_ptr, QRectF(), /*invalidateChildren=*/false, /*force=*/true);
- }
- }
-
- // Certain properties are dropped as an item becomes invisible.
- bool hasFocus = q_ptr->hasFocus();
- if (!newVisible) {
- if (scene) {
- if (scene->d_func()->mouseGrabberItems.contains(q))
- q->ungrabMouse();
- if (scene->d_func()->keyboardGrabberItems.contains(q))
- q->ungrabKeyboard();
- if (q->isPanel() && panelModality != QGraphicsItem::NonModal)
- scene->d_func()->leaveModal(q_ptr);
- }
- if (hasFocus && scene) {
- // Hiding the closest non-panel ancestor of the focus item
- QGraphicsItem *focusItem = scene->focusItem();
- bool clear = true;
- if (isWidget && !focusItem->isPanel()) {
- do {
- if (focusItem == q_ptr) {
- clear = !static_cast<QGraphicsWidget *>(q_ptr)->focusNextPrevChild(true);
- break;
- }
- } while ((focusItem = focusItem->parentWidget()) && !focusItem->isPanel());
- }
- if (clear)
- clearFocusHelper(/* giveFocusToParent = */ false);
- }
- if (q_ptr->isSelected())
- q_ptr->setSelected(false);
- } else {
- geometryChanged = 1;
- paintedViewBoundingRectsNeedRepaint = 1;
- if (scene) {
- if (isWidget) {
- QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(q_ptr);
- if (widget->windowType() == Qt::Popup)
- scene->d_func()->addPopup(widget);
- }
- if (q->isPanel() && panelModality != QGraphicsItem::NonModal) {
- scene->d_func()->enterModal(q_ptr);
- }
- }
- }
-
- // Update children with explicitly = false.
- const bool updateChildren = update && !(flags & QGraphicsItem::ItemClipsChildrenToShape);
- foreach (QGraphicsItem *child, children) {
- if (!newVisible || !child->d_ptr->explicitlyHidden)
- child->d_ptr->setVisibleHelper(newVisible, false, updateChildren);
- }
-
- // Update activation
- if (scene && q->isPanel()) {
- if (newVisible) {
- if (parent && parent->isActive())
- q->setActive(true);
- } else {
- if (q->isActive())
- scene->setActivePanel(parent);
- }
- }
-
- // Enable subfocus
- if (scene) {
- if (newVisible) {
- // Item is shown
- QGraphicsItem *p = parent;
- bool done = false;
- while (p) {
- if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
- QGraphicsItem *fsi = p->d_ptr->focusScopeItem;
- if (q_ptr == fsi || q_ptr->isAncestorOf(fsi)) {
- done = true;
- while (fsi->d_ptr->focusScopeItem && fsi->d_ptr->focusScopeItem->isVisible())
- fsi = fsi->d_ptr->focusScopeItem;
- fsi->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ true,
- /* focusFromHide = */ false);
- }
- break;
- }
- p = p->d_ptr->parent;
- }
- if (!done) {
- QGraphicsItem *fi = subFocusItem;
- if (fi && fi != scene->focusItem()) {
- scene->setFocusItem(fi);
- } else if (flags & QGraphicsItem::ItemIsFocusScope &&
- !scene->focusItem() &&
- q->isAncestorOf(scene->d_func()->lastFocusItem)) {
- q_ptr->setFocus();
- }
- }
- } else {
- // Item is hidden
- if (hasFocus) {
- QGraphicsItem *p = parent;
- while (p) {
- if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
- if (p->d_ptr->visible) {
- p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ true,
- /* focusFromHide = */ true);
- }
- break;
- }
- p = p->d_ptr->parent;
- }
- }
- }
- }
-
- // Deliver post-change notification.
- q_ptr->itemChange(QGraphicsItem::ItemVisibleHasChanged, newVisibleVariant);
-
- if (isObject)
- emit static_cast<QGraphicsObject *>(q_ptr)->visibleChanged();
-}
-
-/*!
- If \a visible is true, the item is made visible. Otherwise, the item is
- made invisible. Invisible items are not painted, nor do they receive any
- events. In particular, mouse events pass right through invisible items,
- and are delivered to any item that may be behind. Invisible items are also
- unselectable, they cannot take input focus, and are not detected by
- QGraphicsScene's item location functions.
-
- If an item becomes invisible while grabbing the mouse, (i.e., while it is
- receiving mouse events,) it will automatically lose the mouse grab, and
- the grab is not regained by making the item visible again; it must receive
- a new mouse press to regain the mouse grab.
-
- Similarly, an invisible item cannot have focus, so if the item has focus
- when it becomes invisible, it will lose focus, and the focus is not
- regained by simply making the item visible again.
-
- If you hide a parent item, all its children will also be hidden. If you
- show a parent item, all children will be shown, unless they have been
- explicitly hidden (i.e., if you call setVisible(false) on a child, it will
- not be reshown even if its parent is hidden, and then shown again).
-
- Items are visible by default; it is unnecessary to call
- setVisible() on a new item.
-
- \sa isVisible(), show(), hide()
-*/
-void QGraphicsItem::setVisible(bool visible)
-{
- d_ptr->setVisibleHelper(visible, /* explicit = */ true);
-}
-
-/*!
- \fn void QGraphicsItem::hide()
-
- Hides the item. (Items are visible by default.)
-
- This convenience function is equivalent to calling \c setVisible(false).
-
- \sa show(), setVisible()
-*/
-
-/*!
- \fn void QGraphicsItem::show()
-
- Shows the item. (Items are visible by default.)
-
- This convenience function is equivalent to calling \c setVisible(true).
-
- \sa hide(), setVisible()
-*/
-
-/*!
- Returns true if the item is enabled; otherwise, false is returned.
-
- \sa setEnabled()
-*/
-bool QGraphicsItem::isEnabled() const
-{
- return d_ptr->enabled;
-}
-
-/*!
- \internal
-
- Sets this item's visibility to \a newEnabled. If \a explicitly is true,
- this item will be "explicitly" \a newEnabled; otherwise, it.. will not be.
-*/
-void QGraphicsItemPrivate::setEnabledHelper(bool newEnabled, bool explicitly, bool update)
-{
- // Update explicit bit.
- if (explicitly)
- explicitlyDisabled = newEnabled ? 0 : 1;
-
- // Check if there's nothing to do.
- if (enabled == quint32(newEnabled))
- return;
-
- // Certain properties are dropped when an item is disabled.
- if (!newEnabled) {
- if (scene && scene->mouseGrabberItem() == q_ptr)
- q_ptr->ungrabMouse();
- if (q_ptr->hasFocus()) {
- // Disabling the closest non-panel ancestor of the focus item
- // causes focus to pop to the next item, otherwise it's cleared.
- QGraphicsItem *focusItem = scene->focusItem();
- bool clear = true;
- if (isWidget && !focusItem->isPanel() && q_ptr->isAncestorOf(focusItem)) {
- do {
- if (focusItem == q_ptr) {
- clear = !static_cast<QGraphicsWidget *>(q_ptr)->focusNextPrevChild(true);
- break;
- }
- } while ((focusItem = focusItem->parentWidget()) && !focusItem->isPanel());
- }
- if (clear)
- q_ptr->clearFocus();
- }
- if (q_ptr->isSelected())
- q_ptr->setSelected(false);
- }
-
- // Modify the property.
- const QVariant newEnabledVariant(q_ptr->itemChange(QGraphicsItem::ItemEnabledChange,
- quint32(newEnabled)));
- enabled = newEnabledVariant.toBool();
-
- // Schedule redraw.
- if (update)
- q_ptr->update();
-
- foreach (QGraphicsItem *child, children) {
- if (!newEnabled || !child->d_ptr->explicitlyDisabled)
- child->d_ptr->setEnabledHelper(newEnabled, /* explicitly = */ false);
- }
-
- // Deliver post-change notification.
- q_ptr->itemChange(QGraphicsItem::ItemEnabledHasChanged, newEnabledVariant);
-
- if (isObject)
- emit static_cast<QGraphicsObject *>(q_ptr)->enabledChanged();
-}
-
-/*!
- If \a enabled is true, the item is enabled; otherwise, it is disabled.
-
- Disabled items are visible, but they do not receive any events, and cannot
- take focus nor be selected. Mouse events are discarded; they are not
- propagated unless the item is also invisible, or if it does not accept
- mouse events (see acceptedMouseButtons()). A disabled item cannot become the
- mouse grabber, and as a result of this, an item loses the grab if it
- becomes disabled when grabbing the mouse, just like it loses focus if it
- had focus when it was disabled.
-
- Disabled items are traditionally drawn using grayed-out colors (see \l
- QPalette::Disabled).
-
- If you disable a parent item, all its children will also be disabled. If
- you enable a parent item, all children will be enabled, unless they have
- been explicitly disabled (i.e., if you call setEnabled(false) on a child,
- it will not be reenabled if its parent is disabled, and then enabled
- again).
-
- Items are enabled by default.
-
- \note If you install an event filter, you can still intercept events
- before they are delivered to items; this mechanism disregards the item's
- enabled state.
-
- \sa isEnabled()
-*/
-void QGraphicsItem::setEnabled(bool enabled)
-{
- d_ptr->setEnabledHelper(enabled, /* explicitly = */ true);
-}
-
-/*!
- Returns true if this item is selected; otherwise, false is returned.
-
- Items that are in a group inherit the group's selected state.
-
- Items are not selected by default.
-
- \sa setSelected(), QGraphicsScene::setSelectionArea()
-*/
-bool QGraphicsItem::isSelected() const
-{
- if (QGraphicsItemGroup *group = this->group())
- return group->isSelected();
- return d_ptr->selected;
-}
-
-/*!
- If \a selected is true and this item is selectable, this item is selected;
- otherwise, it is unselected.
-
- If the item is in a group, the whole group's selected state is toggled by
- this function. If the group is selected, all items in the group are also
- selected, and if the group is not selected, no item in the group is
- selected.
-
- Only visible, enabled, selectable items can be selected. If \a selected
- is true and this item is either invisible or disabled or unselectable,
- this function does nothing.
-
- By default, items cannot be selected. To enable selection, set the
- ItemIsSelectable flag.
-
- This function is provided for convenience, allowing individual toggling of
- the selected state of an item. However, a more common way of selecting
- items is to call QGraphicsScene::setSelectionArea(), which will call this
- function for all visible, enabled, and selectable items within a specified
- area on the scene.
-
- \sa isSelected(), QGraphicsScene::selectedItems()
-*/
-void QGraphicsItem::setSelected(bool selected)
-{
- if (QGraphicsItemGroup *group = this->group()) {
- group->setSelected(selected);
- return;
- }
-
- if (!(d_ptr->flags & ItemIsSelectable) || !d_ptr->enabled || !d_ptr->visible)
- selected = false;
- if (d_ptr->selected == selected)
- return;
- const QVariant newSelectedVariant(itemChange(ItemSelectedChange, quint32(selected)));
- bool newSelected = newSelectedVariant.toBool();
- if (d_ptr->selected == newSelected)
- return;
- d_ptr->selected = newSelected;
-
- update();
- if (d_ptr->scene) {
- QGraphicsScenePrivate *sceneD = d_ptr->scene->d_func();
- if (selected) {
- sceneD->selectedItems << this;
- } else {
- // QGraphicsScene::selectedItems() lazily pulls out all items that are
- // no longer selected.
- }
- if (!sceneD->selectionChanging)
- emit d_ptr->scene->selectionChanged();
- }
-
- // Deliver post-change notification.
- itemChange(QGraphicsItem::ItemSelectedHasChanged, newSelectedVariant);
-}
-
-/*!
- \since 4.5
-
- Returns this item's local opacity, which is between 0.0 (transparent) and
- 1.0 (opaque). This value is combined with parent and ancestor values into
- the effectiveOpacity(). The effective opacity decides how the item is
- rendered.
-
- The opacity property decides the state of the painter passed to the
- paint() function. If the item is cached, i.e., ItemCoordinateCache or
- DeviceCoordinateCache, the effective property will be applied to the item's
- cache as it is rendered.
-
- The default opacity is 1.0; fully opaque.
-
- \sa setOpacity(), paint(), ItemIgnoresParentOpacity,
- ItemDoesntPropagateOpacityToChildren
-*/
-qreal QGraphicsItem::opacity() const
-{
- return d_ptr->opacity;
-}
-
-/*!
- \since 4.5
-
- Returns this item's \e effective opacity, which is between 0.0
- (transparent) and 1.0 (opaque). This value is a combination of this item's
- local opacity, and its parent and ancestors' opacities. The effective
- opacity decides how the item is rendered.
-
- \sa opacity(), setOpacity(), paint(), ItemIgnoresParentOpacity,
- ItemDoesntPropagateOpacityToChildren
-*/
-qreal QGraphicsItem::effectiveOpacity() const
-{
- return d_ptr->effectiveOpacity();
-}
-
-/*!
- \since 4.5
-
- Sets this item's local \a opacity, between 0.0 (transparent) and 1.0
- (opaque). The item's local opacity is combined with parent and ancestor
- opacities into the effectiveOpacity().
-
- By default, opacity propagates from parent to child, so if a parent's
- opacity is 0.5 and the child is also 0.5, the child's effective opacity
- will be 0.25.
-
- The opacity property decides the state of the painter passed to the
- paint() function. If the item is cached, i.e., ItemCoordinateCache or
- DeviceCoordinateCache, the effective property will be applied to the
- item's cache as it is rendered.
-
- There are two item flags that affect how the item's opacity is combined
- with the parent: ItemIgnoresParentOpacity and
- ItemDoesntPropagateOpacityToChildren.
-
- \sa opacity(), effectiveOpacity()
-*/
-void QGraphicsItem::setOpacity(qreal opacity)
-{
- // Notify change.
- const QVariant newOpacityVariant(itemChange(ItemOpacityChange, opacity));
-
- // Normalized opacity
- qreal newOpacity = qBound(qreal(0), newOpacityVariant.toReal(), qreal(1));
-
- // No change? Done.
- if (newOpacity == d_ptr->opacity)
- return;
-
- bool wasFullyTransparent = d_ptr->isOpacityNull();
- d_ptr->opacity = newOpacity;
-
- // Notify change.
- itemChange(ItemOpacityHasChanged, newOpacityVariant);
-
- // Update.
- if (d_ptr->scene) {
-#ifndef QT_NO_GRAPHICSEFFECT
- d_ptr->invalidateParentGraphicsEffectsRecursively();
- if (!(d_ptr->flags & ItemDoesntPropagateOpacityToChildren))
- d_ptr->invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::OpacityChanged);
-#endif //QT_NO_GRAPHICSEFFECT
- d_ptr->scene->d_func()->markDirty(this, QRectF(),
- /*invalidateChildren=*/true,
- /*force=*/false,
- /*ignoreOpacity=*/d_ptr->isOpacityNull());
- if (wasFullyTransparent)
- d_ptr->paintedViewBoundingRectsNeedRepaint = 1;
- }
-
- if (d_ptr->isObject)
- emit static_cast<QGraphicsObject *>(this)->opacityChanged();
-}
-
-/*!
- Returns a pointer to this item's effect if it has one; otherwise 0.
-
- \since 4.6
-*/
-#ifndef QT_NO_GRAPHICSEFFECT
-QGraphicsEffect *QGraphicsItem::graphicsEffect() const
-{
- return d_ptr->graphicsEffect;
-}
-
-/*!
- Sets \a effect as the item's effect. If there already is an effect installed
- on this item, QGraphicsItem will delete the existing effect before installing
- the new \a effect.
-
- If \a effect is the installed on a different item, setGraphicsEffect() will remove
- the effect from the item and install it on this item.
-
- QGraphicsItem takes ownership of \a effect.
-
- \note This function will apply the effect on itself and all its children.
-
- \since 4.6
-*/
-void QGraphicsItem::setGraphicsEffect(QGraphicsEffect *effect)
-{
- if (d_ptr->graphicsEffect == effect)
- return;
-
- if (d_ptr->graphicsEffect) {
- delete d_ptr->graphicsEffect;
- d_ptr->graphicsEffect = 0;
- } else if (d_ptr->parent) {
- d_ptr->parent->d_ptr->updateChildWithGraphicsEffectFlagRecursively();
- }
-
- if (effect) {
- // Set new effect.
- QGraphicsEffectSourcePrivate *sourced = new QGraphicsItemEffectSourcePrivate(this);
- QGraphicsEffectSource *source = new QGraphicsEffectSource(*sourced);
- d_ptr->graphicsEffect = effect;
- effect->d_func()->setGraphicsEffectSource(source);
- prepareGeometryChange();
- }
-}
-#endif //QT_NO_GRAPHICSEFFECT
-
-void QGraphicsItemPrivate::updateChildWithGraphicsEffectFlagRecursively()
-{
-#ifndef QT_NO_GRAPHICSEFFECT
- QGraphicsItemPrivate *itemPrivate = this;
- do {
- // parent chain already notified?
- if (itemPrivate->mayHaveChildWithGraphicsEffect)
- return;
- itemPrivate->mayHaveChildWithGraphicsEffect = 1;
- } while ((itemPrivate = itemPrivate->parent ? itemPrivate->parent->d_ptr.data() : 0));
-#endif
-}
-
-/*!
- \internal
- \since 4.6
- Returns the effective bounding rect of the given item space rect.
- If the item has no effect, the rect is returned unmodified.
- If the item has an effect, the effective rect can be extend beyond the
- item's bounding rect, depending on the effect.
-
- \sa boundingRect()
-*/
-QRectF QGraphicsItemPrivate::effectiveBoundingRect(const QRectF &rect) const
-{
-#ifndef QT_NO_GRAPHICSEFFECT
- Q_Q(const QGraphicsItem);
- QGraphicsEffect *effect = graphicsEffect;
- if (scene && effect && effect->isEnabled()) {
- if (scene->d_func()->views.isEmpty())
- return effect->boundingRectFor(rect);
- QRectF sceneRect = q->mapRectToScene(rect);
- QRectF sceneEffectRect;
- foreach (QGraphicsView *view, scene->views()) {
- QRectF deviceRect = view->d_func()->mapRectFromScene(sceneRect);
- QRect deviceEffectRect = effect->boundingRectFor(deviceRect).toAlignedRect();
- sceneEffectRect |= view->d_func()->mapRectToScene(deviceEffectRect);
- }
- return q->mapRectFromScene(sceneEffectRect);
- }
-#endif //QT_NO_GRAPHICSEFFECT
- return rect;
-}
-
-/*!
- \internal
- \since 4.6
- Returns the effective bounding rect of the item.
- If the item has no effect, this is the same as the item's bounding rect.
- If the item has an effect, the effective rect can be larger than the item's
- bouding rect, depending on the effect.
-
- \sa boundingRect()
-*/
-QRectF QGraphicsItemPrivate::effectiveBoundingRect(QGraphicsItem *topMostEffectItem) const
-{
-#ifndef QT_NO_GRAPHICSEFFECT
- Q_Q(const QGraphicsItem);
- QRectF brect = effectiveBoundingRect(q_ptr->boundingRect());
- if (ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren || topMostEffectItem == q)
- return brect;
-
- const QGraphicsItem *effectParent = parent;
- while (effectParent) {
- QGraphicsEffect *effect = effectParent->d_ptr->graphicsEffect;
- if (scene && effect && effect->isEnabled()) {
- const QRectF brectInParentSpace = q->mapRectToItem(effectParent, brect);
- const QRectF effectRectInParentSpace = effectParent->d_ptr->effectiveBoundingRect(brectInParentSpace);
- brect = effectParent->mapRectToItem(q, effectRectInParentSpace);
- }
- if (effectParent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren
- || topMostEffectItem == effectParent) {
- return brect;
- }
- effectParent = effectParent->d_ptr->parent;
- }
-
- return brect;
-#else //QT_NO_GRAPHICSEFFECT
- return q_ptr->boundingRect();
-#endif //QT_NO_GRAPHICSEFFECT
-
-}
-
-/*!
- \internal
- \since 4.6
- Returns the effective bounding rect of this item in scene coordinates,
- by combining sceneTransform() with boundingRect(), taking into account
- the effect that the item might have.
-
- If the item has no effect, this is the same as sceneBoundingRect().
-
- \sa effectiveBoundingRect(), sceneBoundingRect()
-*/
-QRectF QGraphicsItemPrivate::sceneEffectiveBoundingRect() const
-{
- // Find translate-only offset
- // COMBINE
- QPointF offset;
- const QGraphicsItem *parentItem = q_ptr;
- const QGraphicsItemPrivate *itemd;
- do {
- itemd = parentItem->d_ptr.data();
- if (itemd->transformData)
- break;
- offset += itemd->pos;
- } while ((parentItem = itemd->parent));
-
- QRectF br = effectiveBoundingRect();
- br.translate(offset);
- return !parentItem ? br : parentItem->sceneTransform().mapRect(br);
-}
-
-/*!
- Returns true if this item can accept drag and drop events; otherwise,
- returns false. By default, items do not accept drag and drop events; items
- are transparent to drag and drop.
-
- \sa setAcceptDrops()
-*/
-bool QGraphicsItem::acceptDrops() const
-{
- return d_ptr->acceptDrops;
-}
-
-/*!
- If \a on is true, this item will accept drag and drop events; otherwise,
- it is transparent for drag and drop events. By default, items do not
- accept drag and drop events.
-
- \sa acceptDrops()
-*/
-void QGraphicsItem::setAcceptDrops(bool on)
-{
- d_ptr->acceptDrops = on;
-}
-
-/*!
- Returns the mouse buttons that this item accepts mouse events for. By
- default, all mouse buttons are accepted.
-
- If an item accepts a mouse button, it will become the mouse
- grabber item when a mouse press event is delivered for that mouse
- button. However, if the item does not accept the button,
- QGraphicsScene will forward the mouse events to the first item
- beneath it that does.
-
- \sa setAcceptedMouseButtons(), mousePressEvent()
-*/
-Qt::MouseButtons QGraphicsItem::acceptedMouseButtons() const
-{
- return Qt::MouseButtons(d_ptr->acceptedMouseButtons);
-}
-
-/*!
- Sets the mouse \a buttons that this item accepts mouse events for.
-
- By default, all mouse buttons are accepted. If an item accepts a
- mouse button, it will become the mouse grabber item when a mouse
- press event is delivered for that button. However, if the item
- does not accept the mouse button, QGraphicsScene will forward the
- mouse events to the first item beneath it that does.
-
- To disable mouse events for an item (i.e., make it transparent for mouse
- events), call setAcceptedMouseButtons(0).
-
- \sa acceptedMouseButtons(), mousePressEvent()
-*/
-void QGraphicsItem::setAcceptedMouseButtons(Qt::MouseButtons buttons)
-{
- if (Qt::MouseButtons(d_ptr->acceptedMouseButtons) != buttons) {
- if (buttons == 0 && d_ptr->scene && d_ptr->scene->mouseGrabberItem() == this
- && d_ptr->scene->d_func()->lastMouseGrabberItemHasImplicitMouseGrab) {
- ungrabMouse();
- }
- d_ptr->acceptedMouseButtons = quint32(buttons);
- }
-}
-
-/*!
- \since 4.4
-
- Returns true if an item accepts hover events
- (QGraphicsSceneHoverEvent); otherwise, returns false. By default,
- items do not accept hover events.
-
- \sa setAcceptedMouseButtons()
-*/
-bool QGraphicsItem::acceptHoverEvents() const
-{
- return d_ptr->acceptsHover;
-}
-
-/*!
- \obsolete
-
- Call acceptHoverEvents() instead.
-*/
-bool QGraphicsItem::acceptsHoverEvents() const
-{
- return d_ptr->acceptsHover;
-}
-
-/*!
- \since 4.4
-
- If \a enabled is true, this item will accept hover events;
- otherwise, it will ignore them. By default, items do not accept
- hover events.
-
- Hover events are delivered when there is no current mouse grabber
- item. They are sent when the mouse cursor enters an item, when it
- moves around inside the item, and when the cursor leaves an
- item. Hover events are commonly used to highlight an item when
- it's entered, and for tracking the mouse cursor as it hovers over
- the item (equivalent to QWidget::mouseTracking).
-
- Parent items receive hover enter events before their children, and
- leave events after their children. The parent does not receive a
- hover leave event if the cursor enters a child, though; the parent
- stays "hovered" until the cursor leaves its area, including its
- children's areas.
-
- If a parent item handles child events, it will receive hover move,
- drag move, and drop events as the cursor passes through its
- children, but it does not receive hover enter and hover leave, nor
- drag enter and drag leave events on behalf of its children.
-
- A QGraphicsWidget with window decorations will accept hover events
- regardless of the value of acceptHoverEvents().
-
- \sa acceptHoverEvents(), hoverEnterEvent(), hoverMoveEvent(),
- hoverLeaveEvent()
-*/
-void QGraphicsItem::setAcceptHoverEvents(bool enabled)
-{
- if (d_ptr->acceptsHover == quint32(enabled))
- return;
- d_ptr->acceptsHover = quint32(enabled);
- if (d_ptr->acceptsHover && d_ptr->scene && d_ptr->scene->d_func()->allItemsIgnoreHoverEvents) {
- d_ptr->scene->d_func()->allItemsIgnoreHoverEvents = false;
- d_ptr->scene->d_func()->enableMouseTrackingOnViews();
- }
-}
-
-/*!
- \obsolete
-
- Use setAcceptHoverEvents(\a enabled) instead.
-*/
-void QGraphicsItem::setAcceptsHoverEvents(bool enabled)
-{
- setAcceptHoverEvents(enabled);
-}
-
-/*! \since 4.6
-
- Returns true if an item accepts \l{QTouchEvent}{touch events};
- otherwise, returns false. By default, items do not accept touch events.
-
- \sa setAcceptTouchEvents()
-*/
-bool QGraphicsItem::acceptTouchEvents() const
-{
- return d_ptr->acceptTouchEvents;
-}
-
-/*!
- \since 4.6
-
- If \a enabled is true, this item will accept \l{QTouchEvent}{touch events};
- otherwise, it will ignore them. By default, items do not accept
- touch events.
-*/
-void QGraphicsItem::setAcceptTouchEvents(bool enabled)
-{
- if (d_ptr->acceptTouchEvents == quint32(enabled))
- return;
- d_ptr->acceptTouchEvents = quint32(enabled);
- if (d_ptr->acceptTouchEvents && d_ptr->scene && d_ptr->scene->d_func()->allItemsIgnoreTouchEvents) {
- d_ptr->scene->d_func()->allItemsIgnoreTouchEvents = false;
- d_ptr->scene->d_func()->enableTouchEventsOnViews();
- }
-}
-
-/*!
- \since 4.6
-
- Returns true if this item filters child events (i.e., all events
- intended for any of its children are instead sent to this item);
- otherwise, false is returned.
-
- The default value is false; child events are not filtered.
-
- \sa setFiltersChildEvents()
-*/
-bool QGraphicsItem::filtersChildEvents() const
-{
- return d_ptr->filtersDescendantEvents;
-}
-
-/*!
- \since 4.6
-
- If \a enabled is true, this item is set to filter all events for
- all its children (i.e., all events intented for any of its
- children are instead sent to this item); otherwise, if \a enabled
- is false, this item will only handle its own events. The default
- value is false.
-
- \sa filtersChildEvents()
-*/
-void QGraphicsItem::setFiltersChildEvents(bool enabled)
-{
- if (d_ptr->filtersDescendantEvents == enabled)
- return;
-
- d_ptr->filtersDescendantEvents = enabled;
- d_ptr->updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-2));
-}
-
-/*!
- \obsolete
-
- Returns true if this item handles child events (i.e., all events
- intended for any of its children are instead sent to this item);
- otherwise, false is returned.
-
- This property is useful for item groups; it allows one item to
- handle events on behalf of its children, as opposed to its
- children handling their events individually.
-
- The default is to return false; children handle their own events.
- The exception for this is if the item is a QGraphicsItemGroup, then
- it defaults to return true.
-
- \sa setHandlesChildEvents()
-*/
-bool QGraphicsItem::handlesChildEvents() const
-{
- return d_ptr->handlesChildEvents;
-}
-
-/*!
- \obsolete
-
- If \a enabled is true, this item is set to handle all events for
- all its children (i.e., all events intented for any of its
- children are instead sent to this item); otherwise, if \a enabled
- is false, this item will only handle its own events. The default
- value is false.
-
- This property is useful for item groups; it allows one item to
- handle events on behalf of its children, as opposed to its
- children handling their events individually.
-
- If a child item accepts hover events, its parent will receive
- hover move events as the cursor passes through the child, but it
- does not receive hover enter and hover leave events on behalf of
- its child.
-
- \sa handlesChildEvents()
-*/
-void QGraphicsItem::setHandlesChildEvents(bool enabled)
-{
- if (d_ptr->handlesChildEvents == enabled)
- return;
-
- d_ptr->handlesChildEvents = enabled;
- d_ptr->updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-1));
-}
-/*!
- \since 4.6
- Returns true if this item is active; otherwise returns false.
-
- An item can only be active if the scene is active. An item is active
- if it is, or is a descendent of, an active panel. Items in non-active
- panels are not active.
-
- Items that are not part of a panel follow scene activation when the
- scene has no active panel.
-
- Only active items can gain input focus.
-
- \sa QGraphicsScene::isActive(), QGraphicsScene::activePanel(), panel(), isPanel()
-*/
-bool QGraphicsItem::isActive() const
-{
- if (!d_ptr->scene || !d_ptr->scene->isActive())
- return false;
- return panel() == d_ptr->scene->activePanel();
-}
-
-/*!
- \since 4.6
-
- If \a active is true, and the scene is active, this item's panel will be
- activated. Otherwise, the panel is deactivated.
-
- If the item is not part of an active scene, \a active will decide what
- happens to the panel when the scene becomes active or the item is added to
- the scene. If true, the item's panel will be activated when the item is
- either added to the scene or the scene is activated. Otherwise, the item
- will stay inactive independent of the scene's activated state.
-
- \sa isPanel(), QGraphicsScene::setActivePanel(), QGraphicsScene::isActive()
-*/
-void QGraphicsItem::setActive(bool active)
-{
- d_ptr->explicitActivate = 1;
- d_ptr->wantsActive = active;
- if (d_ptr->scene) {
- if (active) {
- // Activate this item.
- d_ptr->scene->setActivePanel(this);
- } else {
- // Deactivate this item, and reactivate the last active item
- // (if any).
- QGraphicsItem *lastActive = d_ptr->scene->d_func()->lastActivePanel;
- d_ptr->scene->setActivePanel(lastActive != this ? lastActive : 0);
- }
- }
-}
-
-/*!
- Returns true if this item is active, and it or its \l{focusProxy()}{focus
- proxy} has keyboard input focus; otherwise, returns false.
-
- \sa focusItem(), setFocus(), QGraphicsScene::setFocusItem(), isActive()
-*/
-bool QGraphicsItem::hasFocus() const
-{
- if (!d_ptr->scene || !d_ptr->scene->isActive())
- return false;
-
- if (d_ptr->focusProxy)
- return d_ptr->focusProxy->hasFocus();
-
- if (d_ptr->scene->d_func()->focusItem != this)
- return false;
-
- return panel() == d_ptr->scene->d_func()->activePanel;
-}
-
-/*!
- Gives keyboard input focus to this item. The \a focusReason argument will
- be passed into any \l{QFocusEvent}{focus event} generated by this function;
- it is used to give an explanation of what caused the item to get focus.
-
- Only enabled items that set the ItemIsFocusable flag can accept keyboard
- focus.
-
- If this item is not visible, not active, or not associated with a scene,
- it will not gain immediate input focus. However, it will be registered as
- the preferred focus item for its subtree of items, should it later become
- visible.
-
- As a result of calling this function, this item will receive a
- \l{focusInEvent()}{focus in event} with \a focusReason. If another item
- already has focus, that item will first receive a \l{focusOutEvent()}
- {focus out event} indicating that it has lost input focus.
-
- \sa clearFocus(), hasFocus(), focusItem(), focusProxy()
-*/
-void QGraphicsItem::setFocus(Qt::FocusReason focusReason)
-{
- d_ptr->setFocusHelper(focusReason, /* climb = */ true, /* focusFromHide = */ false);
-}
-
-/*!
- \internal
-*/
-void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool climb, bool focusFromHide)
-{
- // Disabled / unfocusable items cannot accept focus.
- if (!q_ptr->isEnabled() || !(flags & QGraphicsItem::ItemIsFocusable))
- return;
-
- // Find focus proxy.
- QGraphicsItem *f = q_ptr;
- while (f->d_ptr->focusProxy)
- f = f->d_ptr->focusProxy;
-
- // Return if it already has focus.
- if (scene && scene->focusItem() == f)
- return;
-
- // Update focus scope item ptr.
- QGraphicsItem *p = parent;
- while (p) {
- if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
- QGraphicsItem *oldFocusScopeItem = p->d_ptr->focusScopeItem;
- p->d_ptr->focusScopeItem = q_ptr;
- if (!p->focusItem() && !focusFromHide) {
- if (oldFocusScopeItem)
- oldFocusScopeItem->d_ptr->focusScopeItemChange(false);
- focusScopeItemChange(true);
- // If you call setFocus on a child of a focus scope that
- // doesn't currently have a focus item, then stop.
- return;
- }
- break;
- }
- p = p->d_ptr->parent;
- }
-
- if (climb) {
- while (f->d_ptr->focusScopeItem && f->d_ptr->focusScopeItem->isVisible())
- f = f->d_ptr->focusScopeItem;
- }
-
- // Update the child focus chain.
- QGraphicsItem *commonAncestor = 0;
- if (scene && scene->focusItem()) {
- commonAncestor = scene->focusItem()->commonAncestorItem(f);
- scene->focusItem()->d_ptr->clearSubFocus(scene->focusItem(), commonAncestor);
- }
-
- f->d_ptr->setSubFocus(f, commonAncestor);
-
- // Update the scene's focus item.
- if (scene) {
- QGraphicsItem *p = q_ptr->panel();
- if ((!p && scene->isActive()) || (p && p->isActive())) {
- // Visible items immediately gain focus from scene.
- scene->d_func()->setFocusItemHelper(f, focusReason);
- }
- }
-}
-
-/*!
- Takes keyboard input focus from the item.
-
- If it has focus, a \l{focusOutEvent()}{focus out event} is sent to this
- item to tell it that it is about to lose the focus.
-
- Only items that set the ItemIsFocusable flag, or widgets that set an
- appropriate focus policy, can accept keyboard focus.
-
- \sa setFocus(), hasFocus(), QGraphicsWidget::focusPolicy
-*/
-void QGraphicsItem::clearFocus()
-{
- d_ptr->clearFocusHelper(/* giveFocusToParent = */ true);
-}
-
-/*!
- \internal
-*/
-void QGraphicsItemPrivate::clearFocusHelper(bool giveFocusToParent)
-{
- if (giveFocusToParent) {
- // Pass focus to the closest parent focus scope
- if (!inDestructor) {
- QGraphicsItem *p = parent;
- while (p) {
- if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
- if (p->d_ptr->focusScopeItem == q_ptr) {
- p->d_ptr->focusScopeItem = 0;
- if (!q_ptr->hasFocus()) //if it has focus, focusScopeItemChange is called elsewhere
- focusScopeItemChange(false);
- }
- if (q_ptr->hasFocus())
- p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ false,
- /* focusFromHide = */ false);
- return;
- }
- p = p->d_ptr->parent;
- }
- }
- }
-
- if (q_ptr->hasFocus()) {
- // Invisible items with focus must explicitly clear subfocus.
- clearSubFocus(q_ptr);
-
- // If this item has the scene's input focus, clear it.
- scene->setFocusItem(0);
- }
-}
-
-/*!
- \since 4.6
-
- Returns this item's focus proxy, or 0 if this item has no
- focus proxy.
-
- \sa setFocusProxy(), setFocus(), hasFocus()
-*/
-QGraphicsItem *QGraphicsItem::focusProxy() const
-{
- return d_ptr->focusProxy;
-}
-
-/*!
- \since 4.6
-
- Sets the item's focus proxy to \a item.
-
- If an item has a focus proxy, the focus proxy will receive
- input focus when the item gains input focus. The item itself
- will still have focus (i.e., hasFocus() will return true),
- but only the focus proxy will receive the keyboard input.
-
- A focus proxy can itself have a focus proxy, and so on. In
- such case, keyboard input will be handled by the outermost
- focus proxy.
-
- The focus proxy \a item must belong to the same scene as
- this item.
-
- \sa focusProxy(), setFocus(), hasFocus()
-*/
-void QGraphicsItem::setFocusProxy(QGraphicsItem *item)
-{
- if (item == d_ptr->focusProxy)
- return;
- if (item == this) {
- qWarning("QGraphicsItem::setFocusProxy: cannot assign self as focus proxy");
- return;
- }
- if (item) {
- if (item->d_ptr->scene != d_ptr->scene) {
- qWarning("QGraphicsItem::setFocusProxy: focus proxy must be in same scene");
- return;
- }
- for (QGraphicsItem *f = item->focusProxy(); f != 0; f = f->focusProxy()) {
- if (f == this) {
- qWarning("QGraphicsItem::setFocusProxy: %p is already in the focus proxy chain", item);
- return;
- }
- }
- }
-
- QGraphicsItem *lastFocusProxy = d_ptr->focusProxy;
- if (lastFocusProxy)
- lastFocusProxy->d_ptr->focusProxyRefs.removeOne(&d_ptr->focusProxy);
- d_ptr->focusProxy = item;
- if (item)
- item->d_ptr->focusProxyRefs << &d_ptr->focusProxy;
-}
-
-/*!
- \since 4.6
-
- If this item, a child or descendant of this item currently has input
- focus, this function will return a pointer to that item. If
- no descendant has input focus, 0 is returned.
-
- \sa hasFocus(), setFocus(), QWidget::focusWidget()
-*/
-QGraphicsItem *QGraphicsItem::focusItem() const
-{
- return d_ptr->subFocusItem;
-}
-
-/*!
- \internal
-
- Returns this item's focus scope item.
-*/
-QGraphicsItem *QGraphicsItem::focusScopeItem() const
-{
- return d_ptr->focusScopeItem;
-}
-
-/*!
- \since 4.4
- Grabs the mouse input.
-
- This item will receive all mouse events for the scene until any of the
- following events occurs:
-
- \list
- \o The item becomes invisible
- \o The item is removed from the scene
- \o The item is deleted
- \o The item call ungrabMouse()
- \o Another item calls grabMouse(); the item will regain the mouse grab
- when the other item calls ungrabMouse().
- \endlist
-
- When an item gains the mouse grab, it receives a QEvent::GrabMouse
- event. When it loses the mouse grab, it receives a QEvent::UngrabMouse
- event. These events can be used to detect when your item gains or loses
- the mouse grab through other means than receiving mouse button events.
-
- It is almost never necessary to explicitly grab the mouse in Qt, as Qt
- grabs and releases it sensibly. In particular, Qt grabs the mouse when you
- press a mouse button, and keeps the mouse grabbed until you release the
- last mouse button. Also, Qt::Popup widgets implicitly call grabMouse()
- when shown, and ungrabMouse() when hidden.
-
- Note that only visible items can grab mouse input. Calling grabMouse() on
- an invisible item has no effect.
-
- Keyboard events are not affected.
-
- \sa QGraphicsScene::mouseGrabberItem(), ungrabMouse(), grabKeyboard()
-*/
-void QGraphicsItem::grabMouse()
-{
- if (!d_ptr->scene) {
- qWarning("QGraphicsItem::grabMouse: cannot grab mouse without scene");
- return;
- }
- if (!d_ptr->visible) {
- qWarning("QGraphicsItem::grabMouse: cannot grab mouse while invisible");
- return;
- }
- d_ptr->scene->d_func()->grabMouse(this);
-}
-
-/*!
- \since 4.4
- Releases the mouse grab.
-
- \sa grabMouse(), ungrabKeyboard()
-*/
-void QGraphicsItem::ungrabMouse()
-{
- if (!d_ptr->scene) {
- qWarning("QGraphicsItem::ungrabMouse: cannot ungrab mouse without scene");
- return;
- }
- d_ptr->scene->d_func()->ungrabMouse(this);
-}
-
-/*!
- \since 4.4
- Grabs the keyboard input.
-
- The item will receive all keyboard input to the scene until one of the
- following events occur:
-
- \list
- \o The item becomes invisible
- \o The item is removed from the scene
- \o The item is deleted
- \o The item calls ungrabKeyboard()
- \o Another item calls grabKeyboard(); the item will regain the keyboard grab
- when the other item calls ungrabKeyboard().
- \endlist
-
- When an item gains the keyboard grab, it receives a QEvent::GrabKeyboard
- event. When it loses the keyboard grab, it receives a
- QEvent::UngrabKeyboard event. These events can be used to detect when your
- item gains or loses the keyboard grab through other means than gaining
- input focus.
-
- It is almost never necessary to explicitly grab the keyboard in Qt, as Qt
- grabs and releases it sensibly. In particular, Qt grabs the keyboard when
- your item gains input focus, and releases it when your item loses input
- focus, or when the item is hidden.
-
- Note that only visible items can grab keyboard input. Calling
- grabKeyboard() on an invisible item has no effect.
-
- Keyboard events are not affected.
-
- \sa ungrabKeyboard(), grabMouse(), setFocus()
-*/
-void QGraphicsItem::grabKeyboard()
-{
- if (!d_ptr->scene) {
- qWarning("QGraphicsItem::grabKeyboard: cannot grab keyboard without scene");
- return;
- }
- if (!d_ptr->visible) {
- qWarning("QGraphicsItem::grabKeyboard: cannot grab keyboard while invisible");
- return;
- }
- d_ptr->scene->d_func()->grabKeyboard(this);
-}
-
-/*!
- \since 4.4
- Releases the keyboard grab.
-
- \sa grabKeyboard(), ungrabMouse()
-*/
-void QGraphicsItem::ungrabKeyboard()
-{
- if (!d_ptr->scene) {
- qWarning("QGraphicsItem::ungrabKeyboard: cannot ungrab keyboard without scene");
- return;
- }
- d_ptr->scene->d_func()->ungrabKeyboard(this);
-}
-
-/*!
- Returns the position of the item in parent coordinates. If the item has no
- parent, its position is given in scene coordinates.
-
- The position of the item describes its origin (local coordinate
- (0, 0)) in parent coordinates; this function returns the same as
- mapToParent(0, 0).
-
- For convenience, you can also call scenePos() to determine the
- item's position in scene coordinates, regardless of its parent.
-
- \sa x(), y(), setPos(), transform(), {The Graphics View Coordinate System}
-*/
-QPointF QGraphicsItem::pos() const
-{
- return d_ptr->pos;
-}
-
-/*!
- \fn QGraphicsItem::x() const
-
- This convenience function is equivalent to calling pos().x().
-
- \sa y()
-*/
-
-/*!
- \since 4.6
-
- Set's the \a x coordinate of the item's position. Equivalent to
- calling setPos(x, y()).
-
- \sa x(), setPos()
-*/
-void QGraphicsItem::setX(qreal x)
-{
- if (d_ptr->inDestructor)
- return;
-
- if (qIsNaN(x))
- return;
-
- setPos(QPointF(x, d_ptr->pos.y()));
-}
-
-/*!
- \fn QGraphicsItem::y() const
-
- This convenience function is equivalent to calling pos().y().
-
- \sa x()
-*/
-
-/*!
- \since 4.6
-
- Set's the \a y coordinate of the item's position. Equivalent to
- calling setPos(x(), y).
-
- \sa x(), setPos()
-*/
-void QGraphicsItem::setY(qreal y)
-{
- if (d_ptr->inDestructor)
- return;
-
- if (qIsNaN(y))
- return;
-
- setPos(QPointF(d_ptr->pos.x(), y));
-}
-
-/*!
- Returns the item's position in scene coordinates. This is
- equivalent to calling \c mapToScene(0, 0).
-
- \sa pos(), sceneTransform(), {The Graphics View Coordinate System}
-*/
-QPointF QGraphicsItem::scenePos() const
-{
- return mapToScene(0, 0);
-}
-
-/*!
- \internal
-
- Sets the position \a pos.
-*/
-void QGraphicsItemPrivate::setPosHelper(const QPointF &pos)
-{
- Q_Q(QGraphicsItem);
- inSetPosHelper = 1;
- if (scene)
- q->prepareGeometryChange();
- QPointF oldPos = this->pos;
- this->pos = pos;
- dirtySceneTransform = 1;
- inSetPosHelper = 0;
- if (isObject) {
- if (pos.x() != oldPos.x())
- emit static_cast<QGraphicsObject *>(q_ptr)->xChanged();
- if (pos.y() != oldPos.y())
- emit static_cast<QGraphicsObject *>(q_ptr)->yChanged();
- }
-}
-
-/*!
- \internal
-
- Sets the transform \a transform.
-*/
-void QGraphicsItemPrivate::setTransformHelper(const QTransform &transform)
-{
- q_ptr->prepareGeometryChange();
- transformData->transform = transform;
- dirtySceneTransform = 1;
- transformChanged();
-}
-
-/*!
- Sets the position of the item to \a pos, which is in parent
- coordinates. For items with no parent, \a pos is in scene
- coordinates.
-
- The position of the item describes its origin (local coordinate
- (0, 0)) in parent coordinates.
-
- \sa pos(), scenePos(), {The Graphics View Coordinate System}
-*/
-void QGraphicsItem::setPos(const QPointF &pos)
-{
- if (d_ptr->pos == pos)
- return;
-
- if (d_ptr->inDestructor)
- return;
-
- // Update and repositition.
- if (!(d_ptr->flags & (ItemSendsGeometryChanges | ItemSendsScenePositionChanges))) {
- d_ptr->setPosHelper(pos);
- if (d_ptr->isWidget)
- static_cast<QGraphicsWidget *>(this)->d_func()->setGeometryFromSetPos();
- if (d_ptr->scenePosDescendants)
- d_ptr->sendScenePosChange();
- return;
- }
-
- // Notify the item that the position is changing.
- const QVariant newPosVariant(itemChange(ItemPositionChange, QVariant::fromValue<QPointF>(pos)));
- QPointF newPos = newPosVariant.toPointF();
- if (newPos == d_ptr->pos)
- return;
-
- // Update and repositition.
- d_ptr->setPosHelper(newPos);
-
- // Send post-notification.
- itemChange(QGraphicsItem::ItemPositionHasChanged, newPosVariant);
- d_ptr->sendScenePosChange();
-}
-
-/*!
- \fn void QGraphicsItem::setPos(qreal x, qreal y)
- \overload
-
- This convenience function is equivalent to calling setPos(QPointF(\a x, \a
- y)).
-*/
-
-/*!
- \fn void QGraphicsItem::moveBy(qreal dx, qreal dy)
-
- Moves the item by \a dx points horizontally, and \a dy point
- vertically. This function is equivalent to calling setPos(pos() +
- QPointF(\a dx, \a dy)).
-*/
-
-/*!
- If this item is part of a scene that is viewed by a QGraphicsView, this
- convenience function will attempt to scroll the view to ensure that \a
- rect is visible inside the view's viewport. If \a rect is a null rect (the
- default), QGraphicsItem will default to the item's bounding rect. \a xmargin
- and \a ymargin are the number of pixels the view should use for margins.
-
- If the specified rect cannot be reached, the contents are scrolled to the
- nearest valid position.
-
- If this item is not viewed by a QGraphicsView, this function does nothing.
-
- \sa QGraphicsView::ensureVisible()
-*/
-void QGraphicsItem::ensureVisible(const QRectF &rect, int xmargin, int ymargin)
-{
- if (d_ptr->scene) {
- QRectF sceneRect;
- if (!rect.isNull())
- sceneRect = sceneTransform().mapRect(rect);
- else
- sceneRect = sceneBoundingRect();
- foreach (QGraphicsView *view, d_ptr->scene->d_func()->views)
- view->ensureVisible(sceneRect, xmargin, ymargin);
- }
-}
-
-/*!
- \fn void QGraphicsItem::ensureVisible(qreal x, qreal y, qreal w, qreal h,
- int xmargin = 50, int ymargin = 50)
-
- This convenience function is equivalent to calling
- ensureVisible(QRectF(\a x, \a y, \a w, \a h), \a xmargin, \a ymargin):
-*/
-
-/*!
- \obsolete
-
- Returns the item's affine transformation matrix. This is a subset or the
- item's full transformation matrix, and might not represent the item's full
- transformation.
-
- Use transform() instead.
-
- \sa setTransform(), sceneTransform()
-*/
-QMatrix QGraphicsItem::matrix() const
-{
- return transform().toAffine();
-}
-
-/*!
- \since 4.3
-
- Returns this item's transformation matrix.
-
- The transformation matrix is combined with the item's rotation(), scale()
- and transformations() into a combined transformations for the item.
-
- The default transformation matrix is an identity matrix.
-
- \sa setTransform(), sceneTransform()
-*/
-QTransform QGraphicsItem::transform() const
-{
- if (!d_ptr->transformData)
- return QTransform();
- return d_ptr->transformData->transform;
-}
-
-/*!
- \since 4.6
-
- Returns the clockwise rotation, in degrees, around the Z axis. The default
- value is 0 (i.e., the item is not rotated).
-
- The rotation is combined with the item's scale(), transform() and
- transformations() to map the item's coordinate system to the parent item.
-
- \sa setRotation(), transformOriginPoint(), {Transformations}
-*/
-qreal QGraphicsItem::rotation() const
-{
- if (!d_ptr->transformData)
- return 0;
- return d_ptr->transformData->rotation;
-}
-
-/*!
- \since 4.6
-
- Sets the clockwise rotation \a angle, in degrees, around the Z axis. The
- default value is 0 (i.e., the item is not rotated). Assigning a negative
- value will rotate the item counter-clockwise. Normally the rotation angle
- is in the range (-360, 360), but it's also possible to assign values
- outside of this range (e.g., a rotation of 370 degrees is the same as a
- rotation of 10 degrees).
-
- The item is rotated around its transform origin point, which by default
- is (0, 0). You can select a different transformation origin by calling
- setTransformOriginPoint().
-
- The rotation is combined with the item's scale(), transform() and
- transformations() to map the item's coordinate system to the parent item.
-
- \sa rotation(), setTransformOriginPoint(), {Transformations}
-*/
-void QGraphicsItem::setRotation(qreal angle)
-{
- prepareGeometryChange();
- qreal newRotation = angle;
-
- if (d_ptr->flags & ItemSendsGeometryChanges) {
- // Notify the item that the rotation is changing.
- const QVariant newRotationVariant(itemChange(ItemRotationChange, angle));
- newRotation = newRotationVariant.toReal();
- }
-
- if (!d_ptr->transformData)
- d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
-
- if (d_ptr->transformData->rotation == newRotation)
- return;
-
- d_ptr->transformData->rotation = newRotation;
- d_ptr->transformData->onlyTransform = false;
- d_ptr->dirtySceneTransform = 1;
-
- // Send post-notification.
- if (d_ptr->flags & ItemSendsGeometryChanges)
- itemChange(ItemRotationHasChanged, newRotation);
-
- if (d_ptr->isObject)
- emit static_cast<QGraphicsObject *>(this)->rotationChanged();
-
- d_ptr->transformChanged();
-}
-
-/*!
- \since 4.6
-
- Returns the scale factor of the item. The default scale factor is 1.0
- (i.e., the item is not scaled).
-
- The scale is combined with the item's rotation(), transform() and
- transformations() to map the item's coordinate system to the parent item.
-
- \sa setScale(), rotation(), {Transformations}
-*/
-qreal QGraphicsItem::scale() const
-{
- if (!d_ptr->transformData)
- return 1.;
- return d_ptr->transformData->scale;
-}
-
-/*!
- \since 4.6
-
- Sets the scale \a factor of the item. The default scale factor is 1.0
- (i.e., the item is not scaled). A scale factor of 0.0 will collapse the
- item to a single point. If you provide a negative scale factor, the
- item will be flipped and mirrored (i.e., rotated 180 degrees).
-
- The item is scaled around its transform origin point, which by default
- is (0, 0). You can select a different transformation origin by calling
- setTransformOriginPoint().
-
- The scale is combined with the item's rotation(), transform() and
- transformations() to map the item's coordinate system to the parent item.
-
- \sa scale(), setTransformOriginPoint(), {Transformations Example}
-*/
-void QGraphicsItem::setScale(qreal factor)
-{
- prepareGeometryChange();
- qreal newScale = factor;
-
- if (d_ptr->flags & ItemSendsGeometryChanges) {
- // Notify the item that the scale is changing.
- const QVariant newScaleVariant(itemChange(ItemScaleChange, factor));
- newScale = newScaleVariant.toReal();
- }
-
- if (!d_ptr->transformData)
- d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
-
- if (d_ptr->transformData->scale == newScale)
- return;
-
- d_ptr->transformData->scale = newScale;
- d_ptr->transformData->onlyTransform = false;
- d_ptr->dirtySceneTransform = 1;
-
- // Send post-notification.
- if (d_ptr->flags & ItemSendsGeometryChanges)
- itemChange(ItemScaleHasChanged, newScale);
-
- if (d_ptr->isObject)
- emit static_cast<QGraphicsObject *>(this)->scaleChanged();
-
- d_ptr->transformChanged();
-}
-
-
-/*!
- \since 4.6
-
- Returns a list of graphics transforms that currently apply to this item.
-
- QGraphicsTransform is for applying and controlling a chain of individual
- transformation operations on an item. It's particularly useful in
- animations, where each transform operation needs to be interpolated
- independently, or differently.
-
- The transformations are combined with the item's rotation(), scale() and
- transform() to map the item's coordinate system to the parent item.
-
- \sa scale(), rotation(), transformOriginPoint(), {Transformations}
-*/
-QList<QGraphicsTransform *> QGraphicsItem::transformations() const
-{
- if (!d_ptr->transformData)
- return QList<QGraphicsTransform *>();
- return d_ptr->transformData->graphicsTransforms;
-}
-
-/*!
- \since 4.6
-
- Sets a list of graphics \a transformations (QGraphicsTransform) that
- currently apply to this item.
-
- If all you want is to rotate or scale an item, you should call setRotation()
- or setScale() instead. If you want to set an arbitrary transformation on
- an item, you can call setTransform().
-
- QGraphicsTransform is for applying and controlling a chain of individual
- transformation operations on an item. It's particularly useful in
- animations, where each transform operation needs to be interpolated
- independently, or differently.
-
- The transformations are combined with the item's rotation(), scale() and
- transform() to map the item's coordinate system to the parent item.
-
- \sa scale(), setTransformOriginPoint(), {Transformations}
-*/
-void QGraphicsItem::setTransformations(const QList<QGraphicsTransform *> &transformations)
-{
- prepareGeometryChange();
- if (!d_ptr->transformData)
- d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
- d_ptr->transformData->graphicsTransforms = transformations;
- for (int i = 0; i < transformations.size(); ++i)
- transformations.at(i)->d_func()->setItem(this);
- d_ptr->transformData->onlyTransform = false;
- d_ptr->dirtySceneTransform = 1;
- d_ptr->transformChanged();
-}
-
-/*!
- \internal
-*/
-void QGraphicsItemPrivate::prependGraphicsTransform(QGraphicsTransform *t)
-{
- if (!transformData)
- transformData = new QGraphicsItemPrivate::TransformData;
- if (!transformData->graphicsTransforms.contains(t))
- transformData->graphicsTransforms.prepend(t);
-
- Q_Q(QGraphicsItem);
- t->d_func()->setItem(q);
- transformData->onlyTransform = false;
- dirtySceneTransform = 1;
- transformChanged();
-}
-
-/*!
- \internal
-*/
-void QGraphicsItemPrivate::appendGraphicsTransform(QGraphicsTransform *t)
-{
- if (!transformData)
- transformData = new QGraphicsItemPrivate::TransformData;
- if (!transformData->graphicsTransforms.contains(t))
- transformData->graphicsTransforms.append(t);
-
- Q_Q(QGraphicsItem);
- t->d_func()->setItem(q);
- transformData->onlyTransform = false;
- dirtySceneTransform = 1;
- transformChanged();
-}
-
-/*!
- \since 4.6
-
- Returns the origin point for the transformation in item coordinates.
-
- The default is QPointF(0,0).
-
- \sa setTransformOriginPoint(), {Transformations}
-*/
-QPointF QGraphicsItem::transformOriginPoint() const
-{
- if (!d_ptr->transformData)
- return QPointF(0,0);
- return QPointF(d_ptr->transformData->xOrigin, d_ptr->transformData->yOrigin);
-}
-
-/*!
- \since 4.6
-
- Sets the \a origin point for the transformation in item coordinates.
-
- \sa transformOriginPoint(), {Transformations}
-*/
-void QGraphicsItem::setTransformOriginPoint(const QPointF &origin)
-{
- prepareGeometryChange();
- QPointF newOrigin = origin;
-
- if (d_ptr->flags & ItemSendsGeometryChanges) {
- // Notify the item that the origin point is changing.
- const QVariant newOriginVariant(itemChange(ItemTransformOriginPointChange,
- QVariant::fromValue<QPointF>(origin)));
- newOrigin = newOriginVariant.toPointF();
- }
-
- if (!d_ptr->transformData)
- d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
-
- if (d_ptr->transformData->xOrigin == newOrigin.x()
- && d_ptr->transformData->yOrigin == newOrigin.y()) {
- return;
- }
-
- d_ptr->transformData->xOrigin = newOrigin.x();
- d_ptr->transformData->yOrigin = newOrigin.y();
- d_ptr->transformData->onlyTransform = false;
- d_ptr->dirtySceneTransform = 1;
-
- // Send post-notification.
- if (d_ptr->flags & ItemSendsGeometryChanges)
- itemChange(ItemTransformOriginPointHasChanged, QVariant::fromValue<QPointF>(newOrigin));
-}
-
-/*!
- \fn void QGraphicsItem::setTransformOriginPoint(qreal x, qreal y)
-
- \since 4.6
- \overload
-
- Sets the origin point for the transformation in item coordinates.
- This is equivalent to calling setTransformOriginPoint(QPointF(\a x, \a y)).
-
- \sa setTransformOriginPoint(), {Transformations}
-*/
-
-
-/*!
- \obsolete
-
- Use sceneTransform() instead.
-
- \sa transform(), setTransform(), scenePos(), {The Graphics View Coordinate System}
-*/
-QMatrix QGraphicsItem::sceneMatrix() const
-{
- d_ptr->ensureSceneTransform();
- return d_ptr->sceneTransform.toAffine();
-}
-
-
-/*!
- \since 4.3
-
- Returns this item's scene transformation matrix. This matrix can be used
- to map coordinates and geometrical shapes from this item's local
- coordinate system to the scene's coordinate system. To map coordinates
- from the scene, you must first invert the returned matrix.
-
- Example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 4
-
- Unlike transform(), which returns only an item's local transformation, this
- function includes the item's (and any parents') position, and all the transfomation properties.
-
- \sa transform(), setTransform(), scenePos(), {The Graphics View Coordinate System}, {Transformations}
-*/
-QTransform QGraphicsItem::sceneTransform() const
-{
- d_ptr->ensureSceneTransform();
- return d_ptr->sceneTransform;
-}
-
-/*!
- \since 4.3
-
- Returns this item's device transformation matrix, using \a
- viewportTransform to map from scene to device coordinates. This matrix can
- be used to map coordinates and geometrical shapes from this item's local
- coordinate system to the viewport's (or any device's) coordinate
- system. To map coordinates from the viewport, you must first invert the
- returned matrix.
-
- Example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 5
-
- This function is the same as combining this item's scene transform with
- the view's viewport transform, but it also understands the
- ItemIgnoresTransformations flag. The device transform can be used to do
- accurate coordinate mapping (and collision detection) for untransformable
- items.
-
- \sa transform(), setTransform(), scenePos(), {The Graphics View Coordinate
- System}, itemTransform()
-*/
-QTransform QGraphicsItem::deviceTransform(const QTransform &viewportTransform) const
-{
- // Ensure we return the standard transform if we're not untransformable.
- if (!d_ptr->itemIsUntransformable()) {
- d_ptr->ensureSceneTransform();
- return d_ptr->sceneTransform * viewportTransform;
- }
-
- // Find the topmost item that ignores view transformations.
- const QGraphicsItem *untransformedAncestor = this;
- QList<const QGraphicsItem *> parents;
- while (untransformedAncestor && ((untransformedAncestor->d_ptr->ancestorFlags
- & QGraphicsItemPrivate::AncestorIgnoresTransformations))) {
- parents.prepend(untransformedAncestor);
- untransformedAncestor = untransformedAncestor->parentItem();
- }
-
- if (!untransformedAncestor) {
- // Assert in debug mode, continue in release.
- Q_ASSERT_X(untransformedAncestor, "QGraphicsItem::deviceTransform",
- "Invalid object structure!");
- return QTransform();
- }
-
- // First translate the base untransformable item.
- untransformedAncestor->d_ptr->ensureSceneTransform();
- QPointF mappedPoint = (untransformedAncestor->d_ptr->sceneTransform * viewportTransform).map(QPointF(0, 0));
-
- // COMBINE
- QTransform matrix = QTransform::fromTranslate(mappedPoint.x(), mappedPoint.y());
- if (untransformedAncestor->d_ptr->transformData)
- matrix = untransformedAncestor->d_ptr->transformData->computedFullTransform(&matrix);
-
- // Then transform and translate all children.
- for (int i = 0; i < parents.size(); ++i) {
- const QGraphicsItem *parent = parents.at(i);
- parent->d_ptr->combineTransformFromParent(&matrix);
- }
-
- return matrix;
-}
-
-/*!
- \since 4.5
-
- Returns a QTransform that maps coordinates from this item to \a other. If
- \a ok is not null, and if there is no such transform, the boolean pointed
- to by \a ok will be set to false; otherwise it will be set to true.
-
- This transform provides an alternative to the mapToItem() or mapFromItem()
- functions, by returning the appropriate transform so that you can map
- shapes and coordinates yourself. It also helps you write more efficient
- code when repeatedly mapping between the same two items.
-
- \note In rare circumstances, there is no transform that maps between two
- items.
-
- \sa mapToItem(), mapFromItem(), deviceTransform()
-*/
-QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) const
-{
- // Catch simple cases first.
- if (other == 0) {
- qWarning("QGraphicsItem::itemTransform: null pointer passed");
- return QTransform();
- }
- if (other == this) {
- if (ok)
- *ok = true;
- return QTransform();
- }
-
- QGraphicsItem *parent = d_ptr->parent;
- const QGraphicsItem *otherParent = other->d_ptr->parent;
-
- // This is other's child
- if (parent == other) {
- if (ok)
- *ok = true;
- QTransform x;
- d_ptr->combineTransformFromParent(&x);
- return x;
- }
-
- // This is other's parent
- if (otherParent == this) {
- const QPointF &otherPos = other->d_ptr->pos;
- if (other->d_ptr->transformData) {
- QTransform otherToParent;
- other->d_ptr->combineTransformFromParent(&otherToParent);
- return otherToParent.inverted(ok);
- }
- if (ok)
- *ok = true;
- return QTransform::fromTranslate(-otherPos.x(), -otherPos.y());
- }
-
- // Siblings
- if (parent == otherParent) {
- // COMBINE
- const QPointF &itemPos = d_ptr->pos;
- const QPointF &otherPos = other->d_ptr->pos;
- if (!d_ptr->transformData && !other->d_ptr->transformData) {
- QPointF delta = itemPos - otherPos;
- if (ok)
- *ok = true;
- return QTransform::fromTranslate(delta.x(), delta.y());
- }
-
- QTransform itemToParent;
- d_ptr->combineTransformFromParent(&itemToParent);
- QTransform otherToParent;
- other->d_ptr->combineTransformFromParent(&otherToParent);
- return itemToParent * otherToParent.inverted(ok);
- }
-
- // Find the closest common ancestor. If the two items don't share an
- // ancestor, then the only way is to combine their scene transforms.
- const QGraphicsItem *commonAncestor = commonAncestorItem(other);
- if (!commonAncestor) {
- d_ptr->ensureSceneTransform();
- other->d_ptr->ensureSceneTransform();
- return d_ptr->sceneTransform * other->d_ptr->sceneTransform.inverted(ok);
- }
-
- // If the two items are cousins (in sibling branches), map both to the
- // common ancestor, and combine the two transforms.
- bool cousins = other != commonAncestor && this != commonAncestor;
- if (cousins) {
- bool good = false;
- QTransform thisToScene = itemTransform(commonAncestor, &good);
- QTransform otherToScene(Qt::Uninitialized);
- if (good)
- otherToScene = other->itemTransform(commonAncestor, &good);
- if (!good) {
- if (ok)
- *ok = false;
- return QTransform();
- }
- return thisToScene * otherToScene.inverted(ok);
- }
-
- // One is an ancestor of the other; walk the chain.
- bool parentOfOther = isAncestorOf(other);
- const QGraphicsItem *child = parentOfOther ? other : this;
- const QGraphicsItem *root = parentOfOther ? this : other;
-
- QTransform x;
- const QGraphicsItem *p = child;
- do {
- p->d_ptr.data()->combineTransformToParent(&x);
- } while ((p = p->d_ptr->parent) && p != root);
- if (parentOfOther)
- return x.inverted(ok);
- if (ok)
- *ok = true;
- return x;
-}
-
-/*!
- \obsolete
-
- Sets the item's affine transformation matrix. This is a subset or the
- item's full transformation matrix, and might not represent the item's full
- transformation.
-
- Use setTransform() instead.
-
- \sa transform(), {The Graphics View Coordinate System}
-*/
-void QGraphicsItem::setMatrix(const QMatrix &matrix, bool combine)
-{
- if (!d_ptr->transformData)
- d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
-
- QTransform newTransform(combine ? QTransform(matrix) * d_ptr->transformData->transform : QTransform(matrix));
- if (d_ptr->transformData->transform == newTransform)
- return;
-
- // Update and set the new transformation.
- if (!(d_ptr->flags & ItemSendsGeometryChanges)) {
- d_ptr->setTransformHelper(newTransform);
- return;
- }
-
- // Notify the item that the transformation matrix is changing.
- const QVariant newMatrixVariant = QVariant::fromValue<QMatrix>(newTransform.toAffine());
- newTransform = QTransform(qvariant_cast<QMatrix>(itemChange(ItemMatrixChange, newMatrixVariant)));
- if (d_ptr->transformData->transform == newTransform)
- return;
-
- // Update and set the new transformation.
- d_ptr->setTransformHelper(newTransform);
-
- // Send post-notification.
- itemChange(ItemTransformHasChanged, QVariant::fromValue<QTransform>(newTransform));
-}
-
-/*!
- \since 4.3
-
- Sets the item's current transformation matrix to \a matrix.
-
- If \a combine is true, then \a matrix is combined with the current matrix;
- otherwise, \a matrix \e replaces the current matrix. \a combine is false
- by default.
-
- To simplify interation with items using a transformed view, QGraphicsItem
- provides mapTo... and mapFrom... functions that can translate between
- items' and the scene's coordinates. For example, you can call mapToScene()
- to map an item coordiate to a scene coordinate, or mapFromScene() to map
- from scene coordinates to item coordinates.
-
- The transformation matrix is combined with the item's rotation(), scale()
- and transformations() into a combined transformation that maps the item's
- coordinate system to its parent.
-
- \sa transform(), setRotation(), setScale(), setTransformOriginPoint(), {The Graphics View Coordinate System}, {Transformations}
-*/
-void QGraphicsItem::setTransform(const QTransform &matrix, bool combine)
-{
- if (!d_ptr->transformData)
- d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
-
- QTransform newTransform(combine ? matrix * d_ptr->transformData->transform : matrix);
- if (d_ptr->transformData->transform == newTransform)
- return;
-
- // Update and set the new transformation.
- if (!(d_ptr->flags & (ItemSendsGeometryChanges | ItemSendsScenePositionChanges))) {
- d_ptr->setTransformHelper(newTransform);
- if (d_ptr->scenePosDescendants)
- d_ptr->sendScenePosChange();
- return;
- }
-
- // Notify the item that the transformation matrix is changing.
- const QVariant newTransformVariant(itemChange(ItemTransformChange,
- QVariant::fromValue<QTransform>(newTransform)));
- newTransform = qvariant_cast<QTransform>(newTransformVariant);
- if (d_ptr->transformData->transform == newTransform)
- return;
-
- // Update and set the new transformation.
- d_ptr->setTransformHelper(newTransform);
-
- // Send post-notification.
- itemChange(ItemTransformHasChanged, newTransformVariant);
- d_ptr->sendScenePosChange();
-}
-
-/*!
- \obsolete
-
- Use resetTransform() instead.
-*/
-void QGraphicsItem::resetMatrix()
-{
- resetTransform();
-}
-
-/*!
- \since 4.3
-
- Resets this item's transformation matrix to the identity matrix or
- all the transformation properties to their default values.
- This is equivalent to calling \c setTransform(QTransform()).
-
- \sa setTransform(), transform()
-*/
-void QGraphicsItem::resetTransform()
-{
- setTransform(QTransform(), false);
-}
-
-/*!
- \obsolete
-
- Use
-
- \code
- setRotation(rotation() + angle);
- \endcode
-
- instead.
-
- Rotates the current item transformation \a angle degrees clockwise around
- its origin. To translate around an arbitrary point (x, y), you need to
- combine translation and rotation with setTransform().
-
- Example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 6
-
- \sa setTransform(), transform(), scale(), shear(), translate()
-*/
-void QGraphicsItem::rotate(qreal angle)
-{
- setTransform(QTransform().rotate(angle), true);
-}
-
-/*!
- \obsolete
-
- Use
-
- \code
- setTransform(QTransform::fromScale(sx, sy), true);
- \endcode
-
- instead.
-
- Scales the current item transformation by (\a sx, \a sy) around its
- origin. To scale from an arbitrary point (x, y), you need to combine
- translation and scaling with setTransform().
-
- Example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 7
-
- \sa setTransform(), transform()
-*/
-void QGraphicsItem::scale(qreal sx, qreal sy)
-{
- setTransform(QTransform::fromScale(sx, sy), true);
-}
-
-/*!
- \obsolete
-
- Use
-
- \code
- setTransform(QTransform().shear(sh, sv), true);
- \endcode
-
- instead.
-
- Shears the current item transformation by (\a sh, \a sv).
-
- \sa setTransform(), transform()
-*/
-void QGraphicsItem::shear(qreal sh, qreal sv)
-{
- setTransform(QTransform().shear(sh, sv), true);
-}
-
-/*!
- \obsolete
-
- Use setPos() or setTransformOriginPoint() instead. For identical
- behavior, use
-
- \code
- setTransform(QTransform::fromTranslate(dx, dy), true);
- \endcode
-
- Translates the current item transformation by (\a dx, \a dy).
-
- If all you want is to move an item, you should call moveBy() or
- setPos() instead; this function changes the item's translation,
- which is conceptually separate from its position.
-
- \sa setTransform(), transform()
-*/
-void QGraphicsItem::translate(qreal dx, qreal dy)
-{
- setTransform(QTransform::fromTranslate(dx, dy), true);
-}
-
-/*!
- This virtual function is called twice for all items by the
- QGraphicsScene::advance() slot. In the first phase, all items are called
- with \a phase == 0, indicating that items on the scene are about to
- advance, and then all items are called with \a phase == 1. Reimplement
- this function to update your item if you need simple scene-controlled
- animation.
-
- The default implementation does nothing.
-
- For individual item animation, an alternative to this function is to
- either use QGraphicsItemAnimation, or to multiple-inherit from QObject and
- QGraphicsItem, and animate your item using QObject::startTimer() and
- QObject::timerEvent().
-
- \sa QGraphicsItemAnimation, QTimeLine
-*/
-void QGraphicsItem::advance(int phase)
-{
- Q_UNUSED(phase);
-}
-
-/*!
- Returns the Z-value of the item. The Z-value affects the stacking order of
- sibling (neighboring) items.
-
- The default Z-value is 0.
-
- \sa setZValue(), {QGraphicsItem#Sorting}{Sorting}, stackBefore(), ItemStacksBehindParent
-*/
-qreal QGraphicsItem::zValue() const
-{
- return d_ptr->z;
-}
-
-/*!
- Sets the Z-value of the item to \a z. The Z value decides the stacking
- order of sibling (neighboring) items. A sibling item of high Z value will
- always be drawn on top of another sibling item with a lower Z value.
-
- If you restore the Z value, the item's insertion order will decide its
- stacking order.
-
- The Z-value does not affect the item's size in any way.
-
- The default Z-value is 0.
-
- \sa zValue(), {QGraphicsItem#Sorting}{Sorting}, stackBefore(), ItemStacksBehindParent
-*/
-void QGraphicsItem::setZValue(qreal z)
-{
- const QVariant newZVariant(itemChange(ItemZValueChange, z));
- qreal newZ = newZVariant.toReal();
- if (newZ == d_ptr->z)
- return;
-
- if (d_ptr->scene && d_ptr->scene->d_func()->indexMethod != QGraphicsScene::NoIndex) {
- // Z Value has changed, we have to notify the index.
- d_ptr->scene->d_func()->index->itemChange(this, ItemZValueChange, &newZ);
- }
-
- d_ptr->z = newZ;
- if (d_ptr->parent)
- d_ptr->parent->d_ptr->needSortChildren = 1;
- else if (d_ptr->scene)
- d_ptr->scene->d_func()->needSortTopLevelItems = 1;
-
- if (d_ptr->scene)
- d_ptr->scene->d_func()->markDirty(this, QRectF(), /*invalidateChildren=*/true);
-
- itemChange(ItemZValueHasChanged, newZVariant);
-
- if (d_ptr->flags & ItemNegativeZStacksBehindParent)
- setFlag(QGraphicsItem::ItemStacksBehindParent, z < qreal(0.0));
-
- if (d_ptr->isObject)
- emit static_cast<QGraphicsObject *>(this)->zChanged();
-}
-
-/*!
- \internal
-
- Ensures that the list of children is sorted by insertion order, and that
- the siblingIndexes are packed (no gaps), and start at 0.
-
- ### This function is almost identical to
- QGraphicsScenePrivate::ensureSequentialTopLevelSiblingIndexes().
-*/
-void QGraphicsItemPrivate::ensureSequentialSiblingIndex()
-{
- if (!sequentialOrdering) {
- qSort(children.begin(), children.end(), insertionOrder);
- sequentialOrdering = 1;
- needSortChildren = 1;
- }
- if (holesInSiblingIndex) {
- holesInSiblingIndex = 0;
- for (int i = 0; i < children.size(); ++i)
- children[i]->d_ptr->siblingIndex = i;
- }
-}
-
-/*!
- \internal
-*/
-inline void QGraphicsItemPrivate::sendScenePosChange()
-{
- Q_Q(QGraphicsItem);
- if (scene) {
- if (flags & QGraphicsItem::ItemSendsScenePositionChanges)
- q->itemChange(QGraphicsItem::ItemScenePositionHasChanged, q->scenePos());
- if (scenePosDescendants) {
- foreach (QGraphicsItem *item, scene->d_func()->scenePosItems) {
- if (q->isAncestorOf(item))
- item->itemChange(QGraphicsItem::ItemScenePositionHasChanged, item->scenePos());
- }
- }
- }
-}
-
-/*!
- \since 4.6
-
- Stacks this item before \a sibling, which must be a sibling item (i.e., the
- two items must share the same parent item, or must both be toplevel items).
- The \a sibling must have the same Z value as this item, otherwise calling
- this function will have no effect.
-
- By default, all sibling items are stacked by insertion order (i.e., the
- first item you add is drawn before the next item you add). If two items' Z
- values are different, then the item with the highest Z value is drawn on
- top. When the Z values are the same, the insertion order will decide the
- stacking order.
-
- \sa setZValue(), ItemStacksBehindParent, {QGraphicsItem#Sorting}{Sorting}
-*/
-void QGraphicsItem::stackBefore(const QGraphicsItem *sibling)
-{
- if (sibling == this)
- return;
- if (!sibling || d_ptr->parent != sibling->parentItem()) {
- qWarning("QGraphicsItem::stackUnder: cannot stack under %p, which must be a sibling", sibling);
- return;
- }
- QList<QGraphicsItem *> *siblings = d_ptr->parent
- ? &d_ptr->parent->d_ptr->children
- : (d_ptr->scene ? &d_ptr->scene->d_func()->topLevelItems : 0);
- if (!siblings) {
- qWarning("QGraphicsItem::stackUnder: cannot stack under %p, which must be a sibling", sibling);
- return;
- }
-
- // First, make sure that the sibling indexes have no holes. This also
- // marks the children list for sorting.
- if (d_ptr->parent)
- d_ptr->parent->d_ptr->ensureSequentialSiblingIndex();
- else
- d_ptr->scene->d_func()->ensureSequentialTopLevelSiblingIndexes();
-
- // Only move items with the same Z value, and that need moving.
- int siblingIndex = sibling->d_ptr->siblingIndex;
- int myIndex = d_ptr->siblingIndex;
- if (myIndex >= siblingIndex) {
- siblings->move(myIndex, siblingIndex);
- // Fixup the insertion ordering.
- for (int i = 0; i < siblings->size(); ++i) {
- int &index = siblings->at(i)->d_ptr->siblingIndex;
- if (i != siblingIndex && index >= siblingIndex && index <= myIndex)
- ++index;
- }
- d_ptr->siblingIndex = siblingIndex;
- for (int i = 0; i < siblings->size(); ++i) {
- int &index = siblings->at(i)->d_ptr->siblingIndex;
- if (i != siblingIndex && index >= siblingIndex && index <= myIndex)
- siblings->at(i)->d_ptr->siblingOrderChange();
- }
- d_ptr->siblingOrderChange();
- }
-}
-
-/*!
- Returns the bounding rect of this item's descendants (i.e., its
- children, their children, etc.) in local coordinates. The
- rectangle will contain all descendants after they have been mapped
- to local coordinates. If the item has no children, this function
- returns an empty QRectF.
-
- This does not include this item's own bounding rect; it only returns
- its descendants' accumulated bounding rect. If you need to include this
- item's bounding rect, you can add boundingRect() to childrenBoundingRect()
- using QRectF::operator|().
-
- This function is linear in complexity; it determines the size of the
- returned bounding rect by iterating through all descendants.
-
- \sa boundingRect(), sceneBoundingRect()
-*/
-QRectF QGraphicsItem::childrenBoundingRect() const
-{
- if (!d_ptr->dirtyChildrenBoundingRect)
- return d_ptr->childrenBoundingRect;
-
- d_ptr->childrenBoundingRect = QRectF();
- d_ptr->childrenBoundingRectHelper(0, &d_ptr->childrenBoundingRect, 0);
- d_ptr->dirtyChildrenBoundingRect = 0;
- return d_ptr->childrenBoundingRect;
-}
-
-/*!
- \fn virtual QRectF QGraphicsItem::boundingRect() const = 0
-
- This pure virtual function defines the outer bounds of the item as
- a rectangle; all painting must be restricted to inside an item's
- bounding rect. QGraphicsView uses this to determine whether the
- item requires redrawing.
-
- Although the item's shape can be arbitrary, the bounding rect is
- always rectangular, and it is unaffected by the items'
- transformation.
-
- If you want to change the item's bounding rectangle, you must first call
- prepareGeometryChange(). This notifies the scene of the imminent change,
- so that its can update its item geometry index; otherwise, the scene will
- be unaware of the item's new geometry, and the results are undefined
- (typically, rendering artifacts are left around in the view).
-
- Reimplement this function to let QGraphicsView determine what
- parts of the widget, if any, need to be redrawn.
-
- Note: For shapes that paint an outline / stroke, it is important
- to include half the pen width in the bounding rect. It is not
- necessary to compensate for antialiasing, though.
-
- Example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 8
-
- \sa boundingRegion(), shape(), contains(), {The Graphics View Coordinate
- System}, prepareGeometryChange()
-*/
-
-/*!
- Returns the bounding rect of this item in scene coordinates, by combining
- sceneTransform() with boundingRect().
-
- \sa boundingRect(), {The Graphics View Coordinate System}
-*/
-QRectF QGraphicsItem::sceneBoundingRect() const
-{
- // Find translate-only offset
- // COMBINE
- QPointF offset;
- const QGraphicsItem *parentItem = this;
- const QGraphicsItemPrivate *itemd;
- do {
- itemd = parentItem->d_ptr.data();
- if (itemd->transformData)
- break;
- offset += itemd->pos;
- } while ((parentItem = itemd->parent));
-
- QRectF br = boundingRect();
- br.translate(offset);
- if (!parentItem)
- return br;
- if (parentItem->d_ptr->hasTranslateOnlySceneTransform()) {
- br.translate(parentItem->d_ptr->sceneTransform.dx(), parentItem->d_ptr->sceneTransform.dy());
- return br;
- }
- return parentItem->d_ptr->sceneTransform.mapRect(br);
-}
-
-/*!
- Returns the shape of this item as a QPainterPath in local
- coordinates. The shape is used for many things, including collision
- detection, hit tests, and for the QGraphicsScene::items() functions.
-
- The default implementation calls boundingRect() to return a simple
- rectangular shape, but subclasses can reimplement this function to return
- a more accurate shape for non-rectangular items. For example, a round item
- may choose to return an elliptic shape for better collision detection. For
- example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 9
-
- The outline of a shape can vary depending on the width and style of the
- pen used when drawing. If you want to include this outline in the item's
- shape, you can create a shape from the stroke using QPainterPathStroker.
-
- This function is called by the default implementations of contains() and
- collidesWithPath().
-
- \sa boundingRect(), contains(), prepareGeometryChange(), QPainterPathStroker
-*/
-QPainterPath QGraphicsItem::shape() const
-{
- QPainterPath path;
- path.addRect(boundingRect());
- return path;
-}
-
-/*!
- Returns true if this item is clipped. An item is clipped if it has either
- set the \l ItemClipsToShape flag, or if it or any of its ancestors has set
- the \l ItemClipsChildrenToShape flag.
-
- Clipping affects the item's appearance (i.e., painting), as well as mouse
- and hover event delivery.
-
- \sa clipPath(), shape(), setFlags()
-*/
-bool QGraphicsItem::isClipped() const
-{
- Q_D(const QGraphicsItem);
- return (d->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren)
- || (d->flags & QGraphicsItem::ItemClipsToShape);
-}
-
-/*!
- \since 4.5
-
- Returns this item's clip path, or an empty QPainterPath if this item is
- not clipped. The clip path constrains the item's appearance and
- interaction (i.e., restricts the area the item can draw, and it also
- restricts the area that the item receives events).
-
- You can enable clipping by setting the ItemClipsToShape or
- ItemClipsChildrenToShape flags. The item's clip path is calculated by
- intersecting all clipping ancestors' shapes. If the item sets
- ItemClipsToShape, the final clip is intersected with the item's own shape.
-
- \note Clipping introduces a performance penalty for all items involved;
- you should generally avoid using clipping if you can (e.g., if your items
- always draw inside boundingRect() or shape() boundaries, clipping is not
- necessary).
-
- \sa isClipped(), shape(), setFlags()
-*/
-QPainterPath QGraphicsItem::clipPath() const
-{
- Q_D(const QGraphicsItem);
- if (!isClipped())
- return QPainterPath();
-
- const QRectF thisBoundingRect(boundingRect());
- if (thisBoundingRect.isEmpty())
- return QPainterPath();
-
- QPainterPath clip;
- // Start with the item's bounding rect.
- clip.addRect(thisBoundingRect);
-
- if (d->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) {
- const QGraphicsItem *parent = this;
- const QGraphicsItem *lastParent = this;
-
- // Intersect any in-between clips starting at the top and moving downwards.
- while ((parent = parent->d_ptr->parent)) {
- if (parent->d_ptr->flags & ItemClipsChildrenToShape) {
- // Map clip to the current parent and intersect with its shape/clipPath
- clip = lastParent->itemTransform(parent).map(clip);
- clip = clip.intersected(parent->shape());
- if (clip.isEmpty())
- return clip;
- lastParent = parent;
- }
-
- if (!(parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren))
- break;
- }
-
- if (lastParent != this) {
- // Map clip back to the item's transform.
- // ### what if itemtransform fails
- clip = lastParent->itemTransform(this).map(clip);
- }
- }
-
- if (d->flags & ItemClipsToShape)
- clip = clip.intersected(shape());
-
- return clip;
-}
-
-/*!
- Returns true if this item contains \a point, which is in local
- coordinates; otherwise, false is returned. It is most often called from
- QGraphicsView to determine what item is under the cursor, and for that
- reason, the implementation of this function should be as light-weight as
- possible.
-
- By default, this function calls shape(), but you can reimplement it in a
- subclass to provide a (perhaps more efficient) implementation.
-
- \sa shape(), boundingRect(), collidesWithPath()
-*/
-bool QGraphicsItem::contains(const QPointF &point) const
-{
- return isClipped() ? clipPath().contains(point) : shape().contains(point);
-}
-
-/*!
-
- Returns true if this item collides with \a other; otherwise
- returns false.
-
- The \a mode is applied to \a other, and the resulting shape or
- bounding rectangle is then compared to this item's shape. The
- default value for \a mode is Qt::IntersectsItemShape; \a other
- collides with this item if it either intersects, contains, or is
- contained by this item's shape (see Qt::ItemSelectionMode for
- details).
-
- The default implementation is based on shape intersection, and it calls
- shape() on both items. Because the complexity of arbitrary shape-shape
- intersection grows with an order of magnitude when the shapes are complex,
- this operation can be noticably time consuming. You have the option of
- reimplementing this function in a subclass of QGraphicsItem to provide a
- custom algorithm. This allows you to make use of natural constraints in
- the shapes of your own items, in order to improve the performance of the
- collision detection. For instance, two untransformed perfectly circular
- items' collision can be determined very efficiently by comparing their
- positions and radii.
-
- Keep in mind that when reimplementing this function and calling shape() or
- boundingRect() on \a other, the returned coordinates must be mapped to
- this item's coordinate system before any intersection can take place.
-
- \sa contains(), shape()
-*/
-bool QGraphicsItem::collidesWithItem(const QGraphicsItem *other, Qt::ItemSelectionMode mode) const
-{
- if (other == this)
- return true;
- if (!other)
- return false;
- // The items share the same clip if their closest clipper is the same, or
- // if one clips the other.
- bool clips = (d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren);
- bool otherClips = (other->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren);
- if (clips || otherClips) {
- const QGraphicsItem *closestClipper = isAncestorOf(other) ? this : parentItem();
- while (closestClipper && !(closestClipper->flags() & ItemClipsChildrenToShape))
- closestClipper = closestClipper->parentItem();
- const QGraphicsItem *otherClosestClipper = other->isAncestorOf(this) ? other : other->parentItem();
- while (otherClosestClipper && !(otherClosestClipper->flags() & ItemClipsChildrenToShape))
- otherClosestClipper = otherClosestClipper->parentItem();
- if (closestClipper == otherClosestClipper) {
- d_ptr->localCollisionHack = 1;
- bool res = collidesWithPath(mapFromItem(other, other->shape()), mode);
- d_ptr->localCollisionHack = 0;
- return res;
- }
- }
-
- QPainterPath otherShape = other->isClipped() ? other->clipPath() : other->shape();
- return collidesWithPath(mapFromItem(other, otherShape), mode);
-}
-
-/*!
- Returns true if this item collides with \a path.
-
- The collision is determined by \a mode. The default value for \a mode is
- Qt::IntersectsItemShape; \a path collides with this item if it either
- intersects, contains, or is contained by this item's shape.
-
- Note that this function checks whether the item's shape or
- bounding rectangle (depending on \a mode) is contained within \a
- path, and not whether \a path is contained within the items shape
- or bounding rectangle.
-
- \sa collidesWithItem(), contains(), shape()
-*/
-bool QGraphicsItem::collidesWithPath(const QPainterPath &path, Qt::ItemSelectionMode mode) const
-{
- if (path.isEmpty()) {
- // No collision with empty paths.
- return false;
- }
-
- QRectF rectA(boundingRect());
- _q_adjustRect(&rectA);
- QRectF rectB(path.controlPointRect());
- _q_adjustRect(&rectB);
- if (!rectA.intersects(rectB)) {
- // This we can determine efficiently. If the two rects neither
- // intersect nor contain eachother, then the two items do not collide.
- return false;
- }
-
- // For further testing, we need this item's shape or bounding rect.
- QPainterPath thisShape;
- if (mode == Qt::IntersectsItemShape || mode == Qt::ContainsItemShape)
- thisShape = (isClipped() && !d_ptr->localCollisionHack) ? clipPath() : shape();
- else
- thisShape.addRect(rectA);
-
- if (thisShape == QPainterPath()) {
- // Empty shape? No collision.
- return false;
- }
-
- // Use QPainterPath boolean operations to determine the collision, O(N*logN).
- if (mode == Qt::IntersectsItemShape || mode == Qt::IntersectsItemBoundingRect)
- return path.intersects(thisShape);
- return path.contains(thisShape);
-}
-
-/*!
- Returns a list of all items that collide with this item.
-
- The way collisions are detected is determined by applying \a mode
- to items that are compared to this item, i.e., each item's shape
- or bounding rectangle is checked against this item's shape. The
- default value for \a mode is Qt::IntersectsItemShape.
-
- \sa collidesWithItem()
-*/
-QList<QGraphicsItem *> QGraphicsItem::collidingItems(Qt::ItemSelectionMode mode) const
-{
- if (d_ptr->scene)
- return d_ptr->scene->collidingItems(this, mode);
- return QList<QGraphicsItem *>();
-}
-
-/*!
- Returns true if this item's bounding rect is completely obscured by the
- opaque shape of any of colliding items above it (i.e., with a higher Z
- value than this item).
-
- Its implementation is based on calling isObscuredBy(), which you can
- reimplement to provide a custom obscurity algorithm.
-
- \sa opaqueArea()
-*/
-bool QGraphicsItem::isObscured() const
-{
- return isObscured(QRectF());
-}
-
-/*!
- \internal
-
- Item obscurity helper function.
-
- Returns true if the subrect \a rect of \a item's bounding rect is obscured
- by \a other (i.e., \a other's opaque area covers \a item's \a rect
- completely. \a other is assumed to already be "on top of" \a item
- wrt. stacking order.
-*/
-static bool qt_QGraphicsItem_isObscured(const QGraphicsItem *item,
- const QGraphicsItem *other,
- const QRectF &rect)
-{
- return other->mapToItem(item, other->opaqueArea()).contains(rect);
-}
-
-/*!
- \overload
- \since 4.3
-
- Returns true if \a rect is completely obscured by the opaque shape of any
- of colliding items above it (i.e., with a higher Z value than this item).
-
- Unlike the default isObscured() function, this function does not call
- isObscuredBy().
-
- \sa opaqueArea()
-*/
-bool QGraphicsItem::isObscured(const QRectF &rect) const
-{
- Q_D(const QGraphicsItem);
- if (!d->scene)
- return false;
-
- QRectF br = boundingRect();
- QRectF testRect = rect.isNull() ? br : rect;
-
- foreach (QGraphicsItem *item, d->scene->items(mapToScene(br), Qt::IntersectsItemBoundingRect)) {
- if (item == this)
- break;
- if (qt_QGraphicsItem_isObscured(this, item, testRect))
- return true;
- }
- return false;
-}
-
-/*!
- \fn bool QGraphicsItem::isObscured(qreal x, qreal y, qreal w, qreal h) const
- \since 4.3
-
- This convenience function is equivalent to calling isObscured(QRectF(\a x, \a y, \a w, \a h)).
-*/
-
-/*!
- Returns true if this item's bounding rect is completely obscured by the
- opaque shape of \a item.
-
- The base implementation maps \a item's opaqueArea() to this item's
- coordinate system, and then checks if this item's boundingRect() is fully
- contained within the mapped shape.
-
- You can reimplement this function to provide a custom algorithm for
- determining whether this item is obscured by \a item.
-
- \sa opaqueArea(), isObscured()
-*/
-bool QGraphicsItem::isObscuredBy(const QGraphicsItem *item) const
-{
- if (!item)
- return false;
- return qt_closestItemFirst(item, this)
- && qt_QGraphicsItem_isObscured(this, item, boundingRect());
-}
-
-/*!
- This virtual function returns a shape representing the area where this
- item is opaque. An area is opaque if it is filled using an opaque brush or
- color (i.e., not transparent).
-
- This function is used by isObscuredBy(), which is called by underlying
- items to determine if they are obscured by this item.
-
- The default implementation returns an empty QPainterPath, indicating that
- this item is completely transparent and does not obscure any other items.
-
- \sa isObscuredBy(), isObscured(), shape()
-*/
-QPainterPath QGraphicsItem::opaqueArea() const
-{
- return QPainterPath();
-}
-
-/*!
- \since 4.4
-
- Returns the bounding region for this item. The coordinate space of the
- returned region depends on \a itemToDeviceTransform. If you pass an
- identity QTransform as a parameter, this function will return a local
- coordinate region.
-
- The bounding region describes a coarse outline of the item's visual
- contents. Although it's expensive to calculate, it's also more precise
- than boundingRect(), and it can help to avoid unnecessary repainting when
- an item is updated. This is particularly efficient for thin items (e.g.,
- lines or simple polygons). You can tune the granularity for the bounding
- region by calling setBoundingRegionGranularity(). The default granularity
- is 0; in which the item's bounding region is the same as its bounding
- rect.
-
- \a itemToDeviceTransform is the transformation from item coordinates to
- device coordinates. If you want this function to return a QRegion in scene
- coordinates, you can pass sceneTransform() as an argument.
-
- \sa boundingRegionGranularity()
-*/
-QRegion QGraphicsItem::boundingRegion(const QTransform &itemToDeviceTransform) const
-{
- // ### Ideally we would have a better way to generate this region,
- // preferably something in the lines of QPainterPath::toRegion(QTransform)
- // coupled with a way to generate a painter path from a set of painter
- // operations (e.g., QPicture::toPainterPath() or so). The current
- // approach generates a bitmap with the size of the item's bounding rect
- // in device coordinates, scaled by b.r.granularity, then paints the item
- // into the bitmap, converts the result to a QRegion and scales the region
- // back to device space with inverse granularity.
- qreal granularity = boundingRegionGranularity();
- QRect deviceRect = itemToDeviceTransform.mapRect(boundingRect()).toRect();
- _q_adjustRect(&deviceRect);
- if (granularity == 0.0)
- return QRegion(deviceRect);
-
- int pad = 1;
- QSize bitmapSize(qMax(1, int(deviceRect.width() * granularity) + pad * 2),
- qMax(1, int(deviceRect.height() * granularity) + pad * 2));
- QImage mask(bitmapSize, QImage::Format_ARGB32_Premultiplied);
- mask.fill(0);
- QPainter p(&mask);
- p.setRenderHints(QPainter::Antialiasing);
-
- // Transform painter (### this code is from QGraphicsScene::drawItemHelper
- // and doesn't work properly with perspective transformations).
- QPointF viewOrigo = itemToDeviceTransform.map(QPointF(0, 0));
- QPointF offset = viewOrigo - deviceRect.topLeft();
- p.scale(granularity, granularity);
- p.translate(offset);
- p.translate(pad, pad);
- p.setWorldTransform(itemToDeviceTransform, true);
- p.translate(itemToDeviceTransform.inverted().map(QPointF(0, 0)));
-
- // Render
- QStyleOptionGraphicsItem option;
- const_cast<QGraphicsItem *>(this)->paint(&p, &option, 0);
- p.end();
-
- // Transform QRegion back to device space
- QTransform unscale = QTransform::fromScale(1 / granularity, 1 / granularity);
- QRegion r;
- QBitmap colorMask = QBitmap::fromImage(mask.createMaskFromColor(0));
- foreach (const QRect &rect, QRegion( colorMask ).rects()) {
- QRect xrect = unscale.mapRect(rect).translated(deviceRect.topLeft() - QPoint(pad, pad));
- r += xrect.adjusted(-1, -1, 1, 1) & deviceRect;
- }
- return r;
-}
-
-/*!
- \since 4.4
-
- Returns the item's bounding region granularity; a value between and
- including 0 and 1. The default value is 0 (i.e., the lowest granularity,
- where the bounding region corresponds to the item's bounding rectangle).
-
-\omit
-### NOTE
-\endomit
-
- \sa setBoundingRegionGranularity()
-*/
-qreal QGraphicsItem::boundingRegionGranularity() const
-{
- return d_ptr->hasBoundingRegionGranularity
- ? qvariant_cast<qreal>(d_ptr->extra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity))
- : 0;
-}
-
-/*!
- \since 4.4
- Sets the bounding region granularity to \a granularity; a value between
- and including 0 and 1. The default value is 0 (i.e., the lowest
- granularity, where the bounding region corresponds to the item's bounding
- rectangle).
-
- The granularity is used by boundingRegion() to calculate how fine the
- bounding region of the item should be. The highest achievable granularity
- is 1, where boundingRegion() will return the finest outline possible for
- the respective device (e.g., for a QGraphicsView viewport, this gives you
- a pixel-perfect bounding region). The lowest possible granularity is
- 0. The value of \a granularity describes the ratio between device
- resolution and the resolution of the bounding region (e.g., a value of
- 0.25 will provide a region where each chunk corresponds to 4x4 device
- units / pixels).
-
- \sa boundingRegionGranularity()
-*/
-void QGraphicsItem::setBoundingRegionGranularity(qreal granularity)
-{
- if (granularity < 0.0 || granularity > 1.0) {
- qWarning("QGraphicsItem::setBoundingRegionGranularity: invalid granularity %g", granularity);
- return;
- }
- if (granularity == 0.0) {
- d_ptr->unsetExtra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity);
- d_ptr->hasBoundingRegionGranularity = 0;
- return;
- }
- d_ptr->hasBoundingRegionGranularity = 1;
- d_ptr->setExtra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity,
- QVariant::fromValue<qreal>(granularity));
-}
-
-/*!
- \fn virtual void QGraphicsItem::paint(QPainter *painter, const
- QStyleOptionGraphicsItem *option, QWidget *widget = 0) = 0
-
- This function, which is usually called by QGraphicsView, paints the
- contents of an item in local coordinates.
-
- Reimplement this function in a QGraphicsItem subclass to provide the
- item's painting implementation, using \a painter. The \a option parameter
- provides style options for the item, such as its state, exposed area and
- its level-of-detail hints. The \a widget argument is optional. If
- provided, it points to the widget that is being painted on; otherwise, it
- is 0. For cached painting, \a widget is always 0.
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 10
-
- The painter's pen is 0-width by default, and its pen is initialized to the
- QPalette::Text brush from the paint device's palette. The brush is
- initialized to QPalette::Window.
-
- Make sure to constrain all painting inside the boundaries of
- boundingRect() to avoid rendering artifacts (as QGraphicsView does not
- clip the painter for you). In particular, when QPainter renders the
- outline of a shape using an assigned QPen, half of the outline will be
- drawn outside, and half inside, the shape you're rendering (e.g., with a
- pen width of 2 units, you must draw outlines 1 unit inside
- boundingRect()). QGraphicsItem does not support use of cosmetic pens with
- a non-zero width.
-
- All painting is done in local coordinates.
-
- \sa setCacheMode(), QPen::width(), {Item Coordinates}, ItemUsesExtendedStyleOption
-*/
-
-/*!
- \internal
- Returns true if we can discard an update request; otherwise false.
-*/
-bool QGraphicsItemPrivate::discardUpdateRequest(bool ignoreVisibleBit, bool ignoreDirtyBit,
- bool ignoreOpacity) const
-{
- // No scene, or if the scene is updating everything, means we have nothing
- // to do. The only exception is if the scene tracks the growing scene rect.
- return !scene
- || (!visible && !ignoreVisibleBit && !this->ignoreVisible)
- || (!ignoreDirtyBit && fullUpdatePending)
- || (!ignoreOpacity && !this->ignoreOpacity && childrenCombineOpacity() && isFullyTransparent());
-}
-
-/*!
- \internal
-*/
-int QGraphicsItemPrivate::depth() const
-{
- if (itemDepth == -1)
- const_cast<QGraphicsItemPrivate *>(this)->resolveDepth();
-
- return itemDepth;
-}
-
-/*!
- \internal
-*/
-#ifndef QT_NO_GRAPHICSEFFECT
-void QGraphicsItemPrivate::invalidateParentGraphicsEffectsRecursively()
-{
- QGraphicsItemPrivate *itemPrivate = this;
- do {
- if (itemPrivate->graphicsEffect) {
- itemPrivate->notifyInvalidated = 1;
-
- if (!itemPrivate->updateDueToGraphicsEffect)
- static_cast<QGraphicsItemEffectSourcePrivate *>(itemPrivate->graphicsEffect->d_func()->source->d_func())->invalidateCache();
- }
- } while ((itemPrivate = itemPrivate->parent ? itemPrivate->parent->d_ptr.data() : 0));
-}
-
-void QGraphicsItemPrivate::invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::InvalidateReason reason)
-{
- if (!mayHaveChildWithGraphicsEffect)
- return;
-
- for (int i = 0; i < children.size(); ++i) {
- QGraphicsItemPrivate *childPrivate = children.at(i)->d_ptr.data();
- if (reason == OpacityChanged && (childPrivate->flags & QGraphicsItem::ItemIgnoresParentOpacity))
- continue;
- if (childPrivate->graphicsEffect) {
- childPrivate->notifyInvalidated = 1;
- static_cast<QGraphicsItemEffectSourcePrivate *>(childPrivate->graphicsEffect->d_func()->source->d_func())->invalidateCache();
- }
-
- childPrivate->invalidateChildGraphicsEffectsRecursively(reason);
- }
-}
-#endif //QT_NO_GRAPHICSEFFECT
-
-/*!
- \internal
-*/
-void QGraphicsItemPrivate::invalidateDepthRecursively()
-{
- if (itemDepth == -1)
- return;
-
- itemDepth = -1;
- for (int i = 0; i < children.size(); ++i)
- children.at(i)->d_ptr->invalidateDepthRecursively();
-}
-
-/*!
- \internal
-
- Resolves the stacking depth of this object and all its ancestors.
-*/
-void QGraphicsItemPrivate::resolveDepth()
-{
- if (!parent)
- itemDepth = 0;
- else {
- if (parent->d_ptr->itemDepth == -1)
- parent->d_ptr->resolveDepth();
- itemDepth = parent->d_ptr->itemDepth + 1;
- }
-}
-
-/*!
- \internal
-
- ### This function is almost identical to
- QGraphicsScenePrivate::registerTopLevelItem().
-*/
-void QGraphicsItemPrivate::addChild(QGraphicsItem *child)
-{
- // Remove all holes from the sibling index list. Now the max index
- // number is equal to the size of the children list.
- ensureSequentialSiblingIndex();
- needSortChildren = 1; // ### maybe 0
- child->d_ptr->siblingIndex = children.size();
- children.append(child);
- if (isObject)
- emit static_cast<QGraphicsObject *>(q_ptr)->childrenChanged();
-}
-
-/*!
- \internal
-
- ### This function is almost identical to
- QGraphicsScenePrivate::unregisterTopLevelItem().
-*/
-void QGraphicsItemPrivate::removeChild(QGraphicsItem *child)
-{
- // When removing elements in the middle of the children list,
- // there will be a "gap" in the list of sibling indexes (0,1,3,4).
- if (!holesInSiblingIndex)
- holesInSiblingIndex = child->d_ptr->siblingIndex != children.size() - 1;
- if (sequentialOrdering && !holesInSiblingIndex)
- children.removeAt(child->d_ptr->siblingIndex);
- else
- children.removeOne(child);
- // NB! Do not use children.removeAt(child->d_ptr->siblingIndex) because
- // the child is not guaranteed to be at the index after the list is sorted.
- // (see ensureSortedChildren()).
- child->d_ptr->siblingIndex = -1;
- if (isObject)
- emit static_cast<QGraphicsObject *>(q_ptr)->childrenChanged();
-}
-
-/*!
- \internal
-*/
-QGraphicsItemCache *QGraphicsItemPrivate::maybeExtraItemCache() const
-{
- return (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));
-}
-
-/*!
- \internal
-*/
-QGraphicsItemCache *QGraphicsItemPrivate::extraItemCache() const
-{
- QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));
- if (!c) {
- QGraphicsItemPrivate *that = const_cast<QGraphicsItemPrivate *>(this);
- c = new QGraphicsItemCache;
- that->setExtra(ExtraCacheData, QVariant::fromValue<void *>(c));
- }
- return c;
-}
-
-/*!
- \internal
-*/
-void QGraphicsItemPrivate::removeExtraItemCache()
-{
- QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));
- if (c) {
- c->purge();
- delete c;
- }
- unsetExtra(ExtraCacheData);
-}
-
-void QGraphicsItemPrivate::updatePaintedViewBoundingRects(bool updateChildren)
-{
- if (!scene)
- return;
-
- for (int i = 0; i < scene->d_func()->views.size(); ++i) {
- QGraphicsViewPrivate *viewPrivate = scene->d_func()->views.at(i)->d_func();
- QRect rect = paintedViewBoundingRects.value(viewPrivate->viewport);
- rect.translate(viewPrivate->dirtyScrollOffset);
- viewPrivate->updateRect(rect);
- }
-
- if (updateChildren) {
- for (int i = 0; i < children.size(); ++i)
- children.at(i)->d_ptr->updatePaintedViewBoundingRects(true);
- }
-}
-
-// Traverses all the ancestors up to the top-level and updates the pointer to
-// always point to the top-most item that has a dirty scene transform.
-// It then backtracks to the top-most dirty item and start calculating the
-// scene transform by combining the item's transform (+pos) with the parent's
-// cached scene transform (which we at this point know for sure is valid).
-void QGraphicsItemPrivate::ensureSceneTransformRecursive(QGraphicsItem **topMostDirtyItem)
-{
- Q_ASSERT(topMostDirtyItem);
-
- if (dirtySceneTransform)
- *topMostDirtyItem = q_ptr;
-
- if (parent)
- parent->d_ptr->ensureSceneTransformRecursive(topMostDirtyItem);
-
- if (*topMostDirtyItem == q_ptr) {
- if (!dirtySceneTransform)
- return; // OK, neither my ancestors nor I have dirty scene transforms.
- *topMostDirtyItem = 0;
- } else if (*topMostDirtyItem) {
- return; // Continue backtrack.
- }
-
- // This item and all its descendants have dirty scene transforms.
- // We're about to validate this item's scene transform, so we have to
- // invalidate all the children; otherwise there's no way for the descendants
- // to detect that the ancestor has changed.
- invalidateChildrenSceneTransform();
-
- // COMBINE my transform with the parent's scene transform.
- updateSceneTransformFromParent();
- Q_ASSERT(!dirtySceneTransform);
-}
-
-/*!
- \internal
-*/
-void QGraphicsItemPrivate::setSubFocus(QGraphicsItem *rootItem, QGraphicsItem *stopItem)
-{
- // Update focus child chain. Stop at panels, or if this item
- // is hidden, stop at the first item with a visible parent.
- QGraphicsItem *parent = rootItem ? rootItem : q_ptr;
- if (parent->panel() != q_ptr->panel())
- return;
-
- do {
- // Clear any existing ancestor's subFocusItem.
- if (parent != q_ptr && parent->d_ptr->subFocusItem) {
- if (parent->d_ptr->subFocusItem == q_ptr)
- break;
- parent->d_ptr->subFocusItem->d_ptr->clearSubFocus(0, stopItem);
- }
- parent->d_ptr->subFocusItem = q_ptr;
- parent->d_ptr->subFocusItemChange();
- } while (!parent->isPanel() && (parent = parent->d_ptr->parent) && (visible || !parent->d_ptr->visible));
-
- if (scene && !scene->isActive()) {
- scene->d_func()->passiveFocusItem = subFocusItem;
- scene->d_func()->lastFocusItem = subFocusItem;
- }
-}
-
-/*!
- \internal
-*/
-void QGraphicsItemPrivate::clearSubFocus(QGraphicsItem *rootItem, QGraphicsItem *stopItem)
-{
- // Reset sub focus chain.
- QGraphicsItem *parent = rootItem ? rootItem : q_ptr;
- do {
- if (parent->d_ptr->subFocusItem != q_ptr)
- break;
- parent->d_ptr->subFocusItem = 0;
- if (parent != stopItem && !parent->isAncestorOf(stopItem))
- parent->d_ptr->subFocusItemChange();
- } while (!parent->isPanel() && (parent = parent->d_ptr->parent));
-}
-
-/*!
- \internal
-
- Sets the focusProxy pointer to 0 for all items that have this item as their
- focusProxy. ### Qt 5: Use QPointer instead.
-*/
-void QGraphicsItemPrivate::resetFocusProxy()
-{
- for (int i = 0; i < focusProxyRefs.size(); ++i)
- *focusProxyRefs.at(i) = 0;
- focusProxyRefs.clear();
-}
-
-/*!
- \internal
-
- Subclasses can reimplement this function to be notified when subFocusItem
- changes.
-*/
-void QGraphicsItemPrivate::subFocusItemChange()
-{
-}
-
-/*!
- \internal
-
- Subclasses can reimplement this function to be notified when an item
- becomes a focusScopeItem (or is no longer a focusScopeItem).
-*/
-void QGraphicsItemPrivate::focusScopeItemChange(bool isSubFocusItem)
-{
- Q_UNUSED(isSubFocusItem);
-}
-
-/*!
- \internal
-
- Subclasses can reimplement this function to be notified when its
- siblingIndex order is changed.
-*/
-void QGraphicsItemPrivate::siblingOrderChange()
-{
-}
-
-/*!
- \internal
-
- Tells us if it is a proxy widget
-*/
-bool QGraphicsItemPrivate::isProxyWidget() const
-{
- return false;
-}
-
-/*!
- Schedules a redraw of the area covered by \a rect in this item. You can
- call this function whenever your item needs to be redrawn, such as if it
- changes appearance or size.
-
- This function does not cause an immediate paint; instead it schedules a
- paint request that is processed by QGraphicsView after control reaches the
- event loop. The item will only be redrawn if it is visible in any
- associated view.
-
- As a side effect of the item being repainted, other items that overlap the
- area \a rect may also be repainted.
-
- If the item is invisible (i.e., isVisible() returns false), this function
- does nothing.
-
- \sa paint(), boundingRect()
-*/
-void QGraphicsItem::update(const QRectF &rect)
-{
- if (rect.isEmpty() && !rect.isNull())
- return;
-
- // Make sure we notify effects about invalidated source.
-#ifndef QT_NO_GRAPHICSEFFECT
- d_ptr->invalidateParentGraphicsEffectsRecursively();
-#endif //QT_NO_GRAPHICSEFFECT
-
- if (CacheMode(d_ptr->cacheMode) != NoCache) {
- // Invalidate cache.
- QGraphicsItemCache *cache = d_ptr->extraItemCache();
- if (!cache->allExposed) {
- if (rect.isNull()) {
- cache->allExposed = true;
- cache->exposed.clear();
- } else {
- cache->exposed.append(rect);
- }
- }
- // Only invalidate cache; item is already dirty.
- if (d_ptr->fullUpdatePending)
- return;
- }
-
- if (d_ptr->scene)
- d_ptr->scene->d_func()->markDirty(this, rect);
-}
-
-/*!
- \since 4.4
- Scrolls the contents of \a rect by \a dx, \a dy. If \a rect is a null rect
- (the default), the item's bounding rect is scrolled.
-
- Scrolling provides a fast alternative to simply redrawing when the
- contents of the item (or parts of the item) are shifted vertically or
- horizontally. Depending on the current transformation and the capabilities
- of the paint device (i.e., the viewport), this operation may consist of
- simply moving pixels from one location to another using memmove(). In most
- cases this is faster than rerendering the entire area.
-
- After scrolling, the item will issue an update for the newly exposed
- areas. If scrolling is not supported (e.g., you are rendering to an OpenGL
- viewport, which does not benefit from scroll optimizations), this function
- is equivalent to calling update(\a rect).
-
- \bold{Note:} Scrolling is only supported when QGraphicsItem::ItemCoordinateCache
- is enabled; in all other cases calling this function is equivalent to calling
- update(\a rect). If you for sure know that the item is opaque and not overlapped
- by other items, you can map the \a rect to viewport coordinates and scroll the
- viewport.
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 19
-
- \sa boundingRect()
-*/
-void QGraphicsItem::scroll(qreal dx, qreal dy, const QRectF &rect)
-{
- Q_D(QGraphicsItem);
- if (dx == 0.0 && dy == 0.0)
- return;
- if (!d->scene)
- return;
-
- // Accelerated scrolling means moving pixels from one location to another
- // and only redraw the newly exposed area. The following requirements must
- // be fulfilled in order to do that:
- //
- // 1) Item is opaque.
- // 2) Item is not overlapped by other items.
- //
- // There's (yet) no way to detect whether an item is opaque or not, which means
- // we cannot do accelerated scrolling unless the cache is enabled. In case of using
- // DeviceCoordinate cache we also have to take the device transform into account in
- // order to determine whether we can do accelerated scrolling or not. That's left out
- // for simplicity here, but it is definitely something we can consider in the future
- // as a performance improvement.
- if (d->cacheMode != QGraphicsItem::ItemCoordinateCache
- || !qFuzzyIsNull(dx - int(dx)) || !qFuzzyIsNull(dy - int(dy))) {
- update(rect);
- return;
- }
-
- QGraphicsItemCache *cache = d->extraItemCache();
- if (cache->allExposed || cache->fixedSize.isValid()) {
- // Cache is either invalidated or item is scaled (see QGraphicsItem::setCacheMode).
- update(rect);
- return;
- }
-
- // Find pixmap in cache.
- QPixmap cachedPixmap;
- if (!QPixmapCache::find(cache->key, &cachedPixmap)) {
- update(rect);
- return;
- }
-
- QRect scrollRect = (rect.isNull() ? boundingRect() : rect).toAlignedRect();
- if (!scrollRect.intersects(cache->boundingRect))
- return; // Nothing to scroll.
-
- // Remove from cache to avoid deep copy when modifying.
- QPixmapCache::remove(cache->key);
-
- QRegion exposed;
- cachedPixmap.scroll(dx, dy, scrollRect.translated(-cache->boundingRect.topLeft()), &exposed);
-
- // Reinsert into cache.
- cache->key = QPixmapCache::insert(cachedPixmap);
-
- // Translate the existing expose.
- for (int i = 0; i < cache->exposed.size(); ++i) {
- QRectF &e = cache->exposed[i];
- if (!rect.isNull() && !e.intersects(rect))
- continue;
- e.translate(dx, dy);
- }
-
- // Append newly exposed areas. Note that the exposed region is currently
- // in pixmap coordinates, so we have to translate it to item coordinates.
- exposed.translate(cache->boundingRect.topLeft());
- const QVector<QRect> exposedRects = exposed.rects();
- for (int i = 0; i < exposedRects.size(); ++i)
- cache->exposed += exposedRects.at(i);
-
- // Trigger update. This will redraw the newly exposed area and make sure
- // the pixmap is re-blitted in case there are overlapping items.
- d->scene->d_func()->markDirty(this, rect);
-}
-
-/*!
- \fn void QGraphicsItem::update(qreal x, qreal y, qreal width, qreal height)
- \overload
-
- This convenience function is equivalent to calling update(QRectF(\a x, \a
- y, \a width, \a height)).
-*/
-
-/*!
- Maps the point \a point, which is in this item's coordinate system, to \a
- item's coordinate system, and returns the mapped coordinate.
-
- If \a item is 0, this function returns the same as mapToScene().
-
- \sa itemTransform(), mapToParent(), mapToScene(), transform(), mapFromItem(), {The Graphics
- View Coordinate System}
-*/
-QPointF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPointF &point) const
-{
- if (item)
- return itemTransform(item).map(point);
- return mapToScene(point);
-}
-
-/*!
- \fn QPointF QGraphicsItem::mapToItem(const QGraphicsItem *item, qreal x, qreal y) const
- \overload
-
- This convenience function is equivalent to calling mapToItem(\a item,
- QPointF(\a x, \a y)).
-*/
-
-/*!
- Maps the point \a point, which is in this item's coordinate system, to its
- parent's coordinate system, and returns the mapped coordinate. If the item
- has no parent, \a point will be mapped to the scene's coordinate system.
-
- \sa mapToItem(), mapToScene(), transform(), mapFromParent(), {The Graphics
- View Coordinate System}
-*/
-QPointF QGraphicsItem::mapToParent(const QPointF &point) const
-{
- // COMBINE
- if (!d_ptr->transformData)
- return point + d_ptr->pos;
- return d_ptr->transformToParent().map(point);
-}
-
-/*!
- \fn QPointF QGraphicsItem::mapToParent(qreal x, qreal y) const
- \overload
-
- This convenience function is equivalent to calling mapToParent(QPointF(\a
- x, \a y)).
-*/
-
-/*!
- Maps the point \a point, which is in this item's coordinate system, to the
- scene's coordinate system, and returns the mapped coordinate.
-
- \sa mapToItem(), mapToParent(), transform(), mapFromScene(), {The Graphics
- View Coordinate System}
-*/
-QPointF QGraphicsItem::mapToScene(const QPointF &point) const
-{
- if (d_ptr->hasTranslateOnlySceneTransform())
- return QPointF(point.x() + d_ptr->sceneTransform.dx(), point.y() + d_ptr->sceneTransform.dy());
- return d_ptr->sceneTransform.map(point);
-}
-
-/*!
- \fn QPointF QGraphicsItem::mapToScene(qreal x, qreal y) const
- \overload
-
- This convenience function is equivalent to calling mapToScene(QPointF(\a
- x, \a y)).
-*/
-
-/*!
- Maps the rectangle \a rect, which is in this item's coordinate system, to
- \a item's coordinate system, and returns the mapped rectangle as a polygon.
-
- If \a item is 0, this function returns the same as mapToScene().
-
- \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The
- Graphics View Coordinate System}
-*/
-QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QRectF &rect) const
-{
- if (item)
- return itemTransform(item).map(rect);
- return mapToScene(rect);
-}
-
-/*!
- \fn QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
- \since 4.3
-
- This convenience function is equivalent to calling mapToItem(item, QRectF(\a x, \a y, \a w, \a h)).
-*/
-
-/*!
- Maps the rectangle \a rect, which is in this item's coordinate system, to
- its parent's coordinate system, and returns the mapped rectangle as a
- polygon. If the item has no parent, \a rect will be mapped to the scene's
- coordinate system.
-
- \sa mapToScene(), mapToItem(), mapFromParent(), {The Graphics View
- Coordinate System}
-*/
-QPolygonF QGraphicsItem::mapToParent(const QRectF &rect) const
-{
- // COMBINE
- if (!d_ptr->transformData)
- return rect.translated(d_ptr->pos);
- return d_ptr->transformToParent().map(rect);
-}
-
-/*!
- \fn QPolygonF QGraphicsItem::mapToParent(qreal x, qreal y, qreal w, qreal h) const
- \since 4.3
-
- This convenience function is equivalent to calling mapToParent(QRectF(\a x, \a y, \a w, \a h)).
-*/
-
-/*!
- Maps the rectangle \a rect, which is in this item's coordinate system, to
- the scene's coordinate system, and returns the mapped rectangle as a polygon.
-
- \sa mapToParent(), mapToItem(), mapFromScene(), {The Graphics View
- Coordinate System}
-*/
-QPolygonF QGraphicsItem::mapToScene(const QRectF &rect) const
-{
- if (d_ptr->hasTranslateOnlySceneTransform())
- return rect.translated(d_ptr->sceneTransform.dx(), d_ptr->sceneTransform.dy());
- return d_ptr->sceneTransform.map(rect);
-}
-
-/*!
- \fn QPolygonF QGraphicsItem::mapToScene(qreal x, qreal y, qreal w, qreal h) const
- \since 4.3
-
- This convenience function is equivalent to calling mapToScene(QRectF(\a x, \a y, \a w, \a h)).
-*/
-
-/*!
- \since 4.5
-
- Maps the rectangle \a rect, which is in this item's coordinate system, to
- \a item's coordinate system, and returns the mapped rectangle as a new
- rectangle (i.e., the bounding rectangle of the resulting polygon).
-
- If \a item is 0, this function returns the same as mapRectToScene().
-
- \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The
- Graphics View Coordinate System}
-*/
-QRectF QGraphicsItem::mapRectToItem(const QGraphicsItem *item, const QRectF &rect) const
-{
- if (item)
- return itemTransform(item).mapRect(rect);
- return mapRectToScene(rect);
-}
-
-/*!
- \fn QRectF QGraphicsItem::mapRectToItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
- \since 4.5
-
- This convenience function is equivalent to calling mapRectToItem(item, QRectF(\a x, \a y, \a w, \a h)).
-*/
-
-/*!
- \since 4.5
-
- Maps the rectangle \a rect, which is in this item's coordinate system, to
- its parent's coordinate system, and returns the mapped rectangle as a new
- rectangle (i.e., the bounding rectangle of the resulting polygon).
-
- \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The
- Graphics View Coordinate System}
-*/
-QRectF QGraphicsItem::mapRectToParent(const QRectF &rect) const
-{
- // COMBINE
- if (!d_ptr->transformData)
- return rect.translated(d_ptr->pos);
- return d_ptr->transformToParent().mapRect(rect);
-}
-
-/*!
- \fn QRectF QGraphicsItem::mapRectToParent(qreal x, qreal y, qreal w, qreal h) const
- \since 4.5
-
- This convenience function is equivalent to calling mapRectToParent(QRectF(\a x, \a y, \a w, \a h)).
-*/
-
-/*!
- \since 4.5
-
- Maps the rectangle \a rect, which is in this item's coordinate system, to
- the scene coordinate system, and returns the mapped rectangle as a new
- rectangle (i.e., the bounding rectangle of the resulting polygon).
-
- \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The
- Graphics View Coordinate System}
-*/
-QRectF QGraphicsItem::mapRectToScene(const QRectF &rect) const
-{
- if (d_ptr->hasTranslateOnlySceneTransform())
- return rect.translated(d_ptr->sceneTransform.dx(), d_ptr->sceneTransform.dy());
- return d_ptr->sceneTransform.mapRect(rect);
-}
-
-/*!
- \fn QRectF QGraphicsItem::mapRectToScene(qreal x, qreal y, qreal w, qreal h) const
- \since 4.5
-
- This convenience function is equivalent to calling mapRectToScene(QRectF(\a x, \a y, \a w, \a h)).
-*/
-
-/*!
- \since 4.5
-
- Maps the rectangle \a rect, which is in \a item's coordinate system, to
- this item's coordinate system, and returns the mapped rectangle as a new
- rectangle (i.e., the bounding rectangle of the resulting polygon).
-
- If \a item is 0, this function returns the same as mapRectFromScene().
-
- \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The
- Graphics View Coordinate System}
-*/
-QRectF QGraphicsItem::mapRectFromItem(const QGraphicsItem *item, const QRectF &rect) const
-{
- if (item)
- return item->itemTransform(this).mapRect(rect);
- return mapRectFromScene(rect);
-}
-
-/*!
- \fn QRectF QGraphicsItem::mapRectFromItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
- \since 4.5
-
- This convenience function is equivalent to calling mapRectFromItem(item, QRectF(\a x, \a y, \a w, \a h)).
-*/
-
-/*!
- \since 4.5
-
- Maps the rectangle \a rect, which is in this item's parent's coordinate
- system, to this item's coordinate system, and returns the mapped rectangle
- as a new rectangle (i.e., the bounding rectangle of the resulting
- polygon).
-
- \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The
- Graphics View Coordinate System}
-*/
-QRectF QGraphicsItem::mapRectFromParent(const QRectF &rect) const
-{
- // COMBINE
- if (!d_ptr->transformData)
- return rect.translated(-d_ptr->pos);
- return d_ptr->transformToParent().inverted().mapRect(rect);
-}
-
-/*!
- \fn QRectF QGraphicsItem::mapRectFromParent(qreal x, qreal y, qreal w, qreal h) const
- \since 4.5
-
- This convenience function is equivalent to calling mapRectFromParent(QRectF(\a x, \a y, \a w, \a h)).
-*/
-
-/*!
- \since 4.5
-
- Maps the rectangle \a rect, which is in scene coordinates, to this item's
- coordinate system, and returns the mapped rectangle as a new rectangle
- (i.e., the bounding rectangle of the resulting polygon).
-
- \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The
- Graphics View Coordinate System}
-*/
-QRectF QGraphicsItem::mapRectFromScene(const QRectF &rect) const
-{
- if (d_ptr->hasTranslateOnlySceneTransform())
- return rect.translated(-d_ptr->sceneTransform.dx(), -d_ptr->sceneTransform.dy());
- return d_ptr->sceneTransform.inverted().mapRect(rect);
-}
-
-/*!
- \fn QRectF QGraphicsItem::mapRectFromScene(qreal x, qreal y, qreal w, qreal h) const
- \since 4.5
-
- This convenience function is equivalent to calling mapRectFromScene(QRectF(\a x, \a y, \a w, \a h)).
-*/
-
-/*!
- Maps the polygon \a polygon, which is in this item's coordinate system, to
- \a item's coordinate system, and returns the mapped polygon.
-
- If \a item is 0, this function returns the same as mapToScene().
-
- \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The
- Graphics View Coordinate System}
-*/
-QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPolygonF &polygon) const
-{
- if (item)
- return itemTransform(item).map(polygon);
- return mapToScene(polygon);
-}
-
-/*!
- Maps the polygon \a polygon, which is in this item's coordinate system, to
- its parent's coordinate system, and returns the mapped polygon. If the
- item has no parent, \a polygon will be mapped to the scene's coordinate
- system.
-
- \sa mapToScene(), mapToItem(), mapFromParent(), {The Graphics View
- Coordinate System}
-*/
-QPolygonF QGraphicsItem::mapToParent(const QPolygonF &polygon) const
-{
- // COMBINE
- if (!d_ptr->transformData)
- return polygon.translated(d_ptr->pos);
- return d_ptr->transformToParent().map(polygon);
-}
-
-/*!
- Maps the polygon \a polygon, which is in this item's coordinate system, to
- the scene's coordinate system, and returns the mapped polygon.
-
- \sa mapToParent(), mapToItem(), mapFromScene(), {The Graphics View
- Coordinate System}
-*/
-QPolygonF QGraphicsItem::mapToScene(const QPolygonF &polygon) const
-{
- if (d_ptr->hasTranslateOnlySceneTransform())
- return polygon.translated(d_ptr->sceneTransform.dx(), d_ptr->sceneTransform.dy());
- return d_ptr->sceneTransform.map(polygon);
-}
-
-/*!
- Maps the path \a path, which is in this item's coordinate system, to
- \a item's coordinate system, and returns the mapped path.
-
- If \a item is 0, this function returns the same as mapToScene().
-
- \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The
- Graphics View Coordinate System}
-*/
-QPainterPath QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPainterPath &path) const
-{
- if (item)
- return itemTransform(item).map(path);
- return mapToScene(path);
-}
-
-/*!
- Maps the path \a path, which is in this item's coordinate system, to
- its parent's coordinate system, and returns the mapped path. If the
- item has no parent, \a path will be mapped to the scene's coordinate
- system.
-
- \sa mapToScene(), mapToItem(), mapFromParent(), {The Graphics View
- Coordinate System}
-*/
-QPainterPath QGraphicsItem::mapToParent(const QPainterPath &path) const
-{
- // COMBINE
- if (!d_ptr->transformData)
- return path.translated(d_ptr->pos);
- return d_ptr->transformToParent().map(path);
-}
-
-/*!
- Maps the path \a path, which is in this item's coordinate system, to
- the scene's coordinate system, and returns the mapped path.
-
- \sa mapToParent(), mapToItem(), mapFromScene(), {The Graphics View
- Coordinate System}
-*/
-QPainterPath QGraphicsItem::mapToScene(const QPainterPath &path) const
-{
- if (d_ptr->hasTranslateOnlySceneTransform())
- return path.translated(d_ptr->sceneTransform.dx(), d_ptr->sceneTransform.dy());
- return d_ptr->sceneTransform.map(path);
-}
-
-/*!
- Maps the point \a point, which is in \a item's coordinate system, to this
- item's coordinate system, and returns the mapped coordinate.
-
- If \a item is 0, this function returns the same as mapFromScene().
-
- \sa itemTransform(), mapFromParent(), mapFromScene(), transform(), mapToItem(), {The Graphics
- View Coordinate System}
-*/
-QPointF QGraphicsItem::mapFromItem(const QGraphicsItem *item, const QPointF &point) const
-{
- if (item)
- return item->itemTransform(this).map(point);
- return mapFromScene(point);
-}
-
-/*!
- \fn QPointF QGraphicsItem::mapFromItem(const QGraphicsItem *item, qreal x, qreal y) const
- \overload
-
- This convenience function is equivalent to calling mapFromItem(\a item,
- QPointF(\a x, \a y)).
-*/
-
-/*!
- Maps the point \a point, which is in this item's parent's coordinate
- system, to this item's coordinate system, and returns the mapped
- coordinate.
-
- \sa mapFromItem(), mapFromScene(), transform(), mapToParent(), {The Graphics
- View Coordinate System}
-*/
-QPointF QGraphicsItem::mapFromParent(const QPointF &point) const
-{
- // COMBINE
- if (d_ptr->transformData)
- return d_ptr->transformToParent().inverted().map(point);
- return point - d_ptr->pos;
-}
-
-/*!
- \fn QPointF QGraphicsItem::mapFromParent(qreal x, qreal y) const
- \overload
-
- This convenience function is equivalent to calling
- mapFromParent(QPointF(\a x, \a y)).
-*/
-
-/*!
- Maps the point \a point, which is in this item's scene's coordinate
- system, to this item's coordinate system, and returns the mapped
- coordinate.
-
- \sa mapFromItem(), mapFromParent(), transform(), mapToScene(), {The Graphics
- View Coordinate System}
-*/
-QPointF QGraphicsItem::mapFromScene(const QPointF &point) const
-{
- if (d_ptr->hasTranslateOnlySceneTransform())
- return QPointF(point.x() - d_ptr->sceneTransform.dx(), point.y() - d_ptr->sceneTransform.dy());
- return d_ptr->sceneTransform.inverted().map(point);
-}
-
-/*!
- \fn QPointF QGraphicsItem::mapFromScene(qreal x, qreal y) const
- \overload
-
- This convenience function is equivalent to calling mapFromScene(QPointF(\a
- x, \a y)).
-*/
-
-/*!
- Maps the rectangle \a rect, which is in \a item's coordinate system, to
- this item's coordinate system, and returns the mapped rectangle as a
- polygon.
-
- If \a item is 0, this function returns the same as mapFromScene()
-
- \sa itemTransform(), mapToItem(), mapFromParent(), transform(), {The Graphics View Coordinate
- System}
-*/
-QPolygonF QGraphicsItem::mapFromItem(const QGraphicsItem *item, const QRectF &rect) const
-{
- if (item)
- return item->itemTransform(this).map(rect);
- return mapFromScene(rect);
-}
-
-/*!
- \fn QPolygonF QGraphicsItem::mapFromItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
- \since 4.3
-
- This convenience function is equivalent to calling mapFromItem(item, QRectF(\a x, \a y, \a w, \a h)).
-*/
-
-/*!
- Maps the rectangle \a rect, which is in this item's parent's coordinate
- system, to this item's coordinate system, and returns the mapped rectangle
- as a polygon.
-
- \sa mapToParent(), mapFromItem(), transform(), {The Graphics View Coordinate
- System}
-*/
-QPolygonF QGraphicsItem::mapFromParent(const QRectF &rect) const
-{
- // COMBINE
- if (!d_ptr->transformData)
- return rect.translated(-d_ptr->pos);
- return d_ptr->transformToParent().inverted().map(rect);
-}
-
-/*!
- \fn QPolygonF QGraphicsItem::mapFromParent(qreal x, qreal y, qreal w, qreal h) const
- \since 4.3
-
- This convenience function is equivalent to calling mapFromItem(QRectF(\a x, \a y, \a w, \a h)).
-*/
-
-/*!
- Maps the rectangle \a rect, which is in this item's scene's coordinate
- system, to this item's coordinate system, and returns the mapped rectangle
- as a polygon.
-
- \sa mapToScene(), mapFromItem(), transform(), {The Graphics View Coordinate
- System}
-*/
-QPolygonF QGraphicsItem::mapFromScene(const QRectF &rect) const
-{
- if (d_ptr->hasTranslateOnlySceneTransform())
- return rect.translated(-d_ptr->sceneTransform.dx(), -d_ptr->sceneTransform.dy());
- return d_ptr->sceneTransform.inverted().map(rect);
-}
-
-/*!
- \fn QPolygonF QGraphicsItem::mapFromScene(qreal x, qreal y, qreal w, qreal h) const
- \since 4.3
-
- This convenience function is equivalent to calling mapFromScene(QRectF(\a x, \a y, \a w, \a h)).
-*/
-
-/*!
- Maps the polygon \a polygon, which is in \a item's coordinate system, to
- this item's coordinate system, and returns the mapped polygon.
-
- If \a item is 0, this function returns the same as mapFromScene().
-
- \sa itemTransform(), mapToItem(), mapFromParent(), transform(), {The
- Graphics View Coordinate System}
-*/
-QPolygonF QGraphicsItem::mapFromItem(const QGraphicsItem *item, const QPolygonF &polygon) const
-{
- if (item)
- return item->itemTransform(this).map(polygon);
- return mapFromScene(polygon);
-}
-
-/*!
- Maps the polygon \a polygon, which is in this item's parent's coordinate
- system, to this item's coordinate system, and returns the mapped polygon.
-
- \sa mapToParent(), mapToItem(), transform(), {The Graphics View Coordinate
- System}
-*/
-QPolygonF QGraphicsItem::mapFromParent(const QPolygonF &polygon) const
-{
- // COMBINE
- if (!d_ptr->transformData)
- return polygon.translated(-d_ptr->pos);
- return d_ptr->transformToParent().inverted().map(polygon);
-}
-
-/*!
- Maps the polygon \a polygon, which is in this item's scene's coordinate
- system, to this item's coordinate system, and returns the mapped polygon.
-
- \sa mapToScene(), mapFromParent(), transform(), {The Graphics View Coordinate
- System}
-*/
-QPolygonF QGraphicsItem::mapFromScene(const QPolygonF &polygon) const
-{
- if (d_ptr->hasTranslateOnlySceneTransform())
- return polygon.translated(-d_ptr->sceneTransform.dx(), -d_ptr->sceneTransform.dy());
- return d_ptr->sceneTransform.inverted().map(polygon);
-}
-
-/*!
- Maps the path \a path, which is in \a item's coordinate system, to
- this item's coordinate system, and returns the mapped path.
-
- If \a item is 0, this function returns the same as mapFromScene().
-
- \sa itemTransform(), mapFromParent(), mapFromScene(), mapToItem(), {The
- Graphics View Coordinate System}
-*/
-QPainterPath QGraphicsItem::mapFromItem(const QGraphicsItem *item, const QPainterPath &path) const
-{
- if (item)
- return item->itemTransform(this).map(path);
- return mapFromScene(path);
-}
-
-/*!
- Maps the path \a path, which is in this item's parent's coordinate
- system, to this item's coordinate system, and returns the mapped path.
-
- \sa mapFromScene(), mapFromItem(), mapToParent(), {The Graphics View
- Coordinate System}
-*/
-QPainterPath QGraphicsItem::mapFromParent(const QPainterPath &path) const
-{
- // COMBINE
- if (!d_ptr->transformData)
- return path.translated(-d_ptr->pos);
- return d_ptr->transformToParent().inverted().map(path);
-}
-
-/*!
- Maps the path \a path, which is in this item's scene's coordinate
- system, to this item's coordinate system, and returns the mapped path.
-
- \sa mapFromParent(), mapFromItem(), mapToScene(), {The Graphics View
- Coordinate System}
-*/
-QPainterPath QGraphicsItem::mapFromScene(const QPainterPath &path) const
-{
- if (d_ptr->hasTranslateOnlySceneTransform())
- return path.translated(-d_ptr->sceneTransform.dx(), -d_ptr->sceneTransform.dy());
- return d_ptr->sceneTransform.inverted().map(path);
-}
-
-/*!
- Returns true if this item is an ancestor of \a child (i.e., if this item
- is \a child's parent, or one of \a child's parent's ancestors).
-
- \sa parentItem()
-*/
-bool QGraphicsItem::isAncestorOf(const QGraphicsItem *child) const
-{
- if (!child || child == this)
- return false;
- if (child->d_ptr->depth() < d_ptr->depth())
- return false;
- const QGraphicsItem *ancestor = child;
- while ((ancestor = ancestor->d_ptr->parent)) {
- if (ancestor == this)
- return true;
- }
- return false;
-}
-
-/*!
- \since 4.4
-
- Returns the closest common ancestor item of this item and \a other, or 0
- if either \a other is 0, or there is no common ancestor.
-
- \sa isAncestorOf()
-*/
-QGraphicsItem *QGraphicsItem::commonAncestorItem(const QGraphicsItem *other) const
-{
- if (!other)
- return 0;
- if (other == this)
- return const_cast<QGraphicsItem *>(this);
- const QGraphicsItem *thisw = this;
- const QGraphicsItem *otherw = other;
- int thisDepth = d_ptr->depth();
- int otherDepth = other->d_ptr->depth();
- while (thisDepth > otherDepth) {
- thisw = thisw->d_ptr->parent;
- --thisDepth;
- }
- while (otherDepth > thisDepth) {
- otherw = otherw->d_ptr->parent;
- --otherDepth;
- }
- while (thisw && thisw != otherw) {
- thisw = thisw->d_ptr->parent;
- otherw = otherw->d_ptr->parent;
- }
- return const_cast<QGraphicsItem *>(thisw);
-}
-
-/*!
- \since 4,4
- Returns true if this item is currently under the mouse cursor in one of
- the views; otherwise, false is returned.
-
- \sa QGraphicsScene::views(), QCursor::pos()
-*/
-bool QGraphicsItem::isUnderMouse() const
-{
- Q_D(const QGraphicsItem);
- if (!d->scene)
- return false;
-
- QPoint cursorPos = QCursor::pos();
- foreach (QGraphicsView *view, d->scene->views()) {
- if (contains(mapFromScene(view->mapToScene(view->mapFromGlobal(cursorPos)))))
- return true;
- }
- return false;
-}
-
-/*!
- Returns this item's custom data for the key \a key as a QVariant.
-
- Custom item data is useful for storing arbitrary properties in any
- item. Example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 11
-
- Qt does not use this feature for storing data; it is provided solely
- for the convenience of the user.
-
- \sa setData()
-*/
-QVariant QGraphicsItem::data(int key) const
-{
- QGraphicsItemCustomDataStore *store = qt_dataStore();
- if (!store->data.contains(this))
- return QVariant();
- return store->data.value(this).value(key);
-}
-
-/*!
- Sets this item's custom data for the key \a key to \a value.
-
- Custom item data is useful for storing arbitrary properties for any
- item. Qt does not use this feature for storing data; it is provided solely
- for the convenience of the user.
-
- \sa data()
-*/
-void QGraphicsItem::setData(int key, const QVariant &value)
-{
- qt_dataStore()->data[this][key] = value;
-}
-
-/*!
- \fn T qgraphicsitem_cast(QGraphicsItem *item)
- \relates QGraphicsItem
- \since 4.2
-
- Returns the given \a item cast to type T if \a item is of type T;
- otherwise, 0 is returned.
-
- \note To make this function work correctly with custom items, reimplement
- the \l{QGraphicsItem::}{type()} function for each custom QGraphicsItem
- subclass.
-
- \sa QGraphicsItem::type(), QGraphicsItem::UserType
-*/
-
-/*!
- Returns the type of an item as an int. All standard graphicsitem classes
- are associated with a unique value; see QGraphicsItem::Type. This type
- information is used by qgraphicsitem_cast() to distinguish between types.
-
- The default implementation (in QGraphicsItem) returns UserType.
-
- To enable use of qgraphicsitem_cast() with a custom item, reimplement this
- function and declare a Type enum value equal to your custom item's type.
- Custom items must return a value larger than or equal to UserType (65536).
-
- For example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp QGraphicsItem type
-
- \sa UserType
-*/
-int QGraphicsItem::type() const
-{
- return (int)UserType;
-}
-
-/*!
- Installs an event filter for this item on \a filterItem, causing
- all events for this item to first pass through \a filterItem's
- sceneEventFilter() function.
-
- To filter another item's events, install this item as an event filter
- for the other item. Example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 12
-
- An item can only filter events for other items in the same
- scene. Also, an item cannot filter its own events; instead, you
- can reimplement sceneEvent() directly.
-
- Items must belong to a scene for scene event filters to be installed and
- used.
-
- \sa removeSceneEventFilter(), sceneEventFilter(), sceneEvent()
-*/
-void QGraphicsItem::installSceneEventFilter(QGraphicsItem *filterItem)
-{
- if (!d_ptr->scene) {
- qWarning("QGraphicsItem::installSceneEventFilter: event filters can only be installed"
- " on items in a scene.");
- return;
- }
- if (d_ptr->scene != filterItem->scene()) {
- qWarning("QGraphicsItem::installSceneEventFilter: event filters can only be installed"
- " on items in the same scene.");
- return;
- }
- d_ptr->scene->d_func()->installSceneEventFilter(this, filterItem);
-}
-
-/*!
- Removes an event filter on this item from \a filterItem.
-
- \sa installSceneEventFilter()
-*/
-void QGraphicsItem::removeSceneEventFilter(QGraphicsItem *filterItem)
-{
- if (!d_ptr->scene || d_ptr->scene != filterItem->scene())
- return;
- d_ptr->scene->d_func()->removeSceneEventFilter(this, filterItem);
-}
-
-/*!
- Filters events for the item \a watched. \a event is the filtered
- event.
-
- Reimplementing this function in a subclass makes it possible
- for the item to be used as an event filter for other items,
- intercepting all the events send to those items before they are
- able to respond.
-
- Reimplementations must return true to prevent further processing of
- a given event, ensuring that it will not be delivered to the watched
- item, or return false to indicate that the event should be propagated
- further by the event system.
-
- \sa installSceneEventFilter()
-*/
-bool QGraphicsItem::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
-{
- Q_UNUSED(watched);
- Q_UNUSED(event);
- return false;
-}
-
-/*!
- This virtual function receives events to this item. Reimplement
- this function to intercept events before they are dispatched to
- the specialized event handlers contextMenuEvent(), focusInEvent(),
- focusOutEvent(), hoverEnterEvent(), hoverMoveEvent(),
- hoverLeaveEvent(), keyPressEvent(), keyReleaseEvent(),
- mousePressEvent(), mouseReleaseEvent(), mouseMoveEvent(), and
- mouseDoubleClickEvent().
-
- Returns true if the event was recognized and handled; otherwise, (e.g., if
- the event type was not recognized,) false is returned.
-
- \a event is the intercepted event.
-*/
-bool QGraphicsItem::sceneEvent(QEvent *event)
-{
- if (d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents) {
- if (event->type() == QEvent::HoverEnter || event->type() == QEvent::HoverLeave
- || event->type() == QEvent::DragEnter || event->type() == QEvent::DragLeave) {
- // Hover enter and hover leave events for children are ignored;
- // hover move events are forwarded.
- return true;
- }
-
- QGraphicsItem *handler = this;
- do {
- handler = handler->d_ptr->parent;
- Q_ASSERT(handler);
- } while (handler->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents);
- // Forward the event to the closest parent that handles child
- // events, mapping existing item-local coordinates to its
- // coordinate system.
- d_ptr->remapItemPos(event, handler);
- handler->sceneEvent(event);
- return true;
- }
-
- if (event->type() == QEvent::FocusOut) {
- focusOutEvent(static_cast<QFocusEvent *>(event));
- return true;
- }
-
- if (!d_ptr->visible) {
- // Eaten
- return true;
- }
-
- switch (event->type()) {
- case QEvent::FocusIn:
- focusInEvent(static_cast<QFocusEvent *>(event));
- break;
- case QEvent::GraphicsSceneContextMenu:
- contextMenuEvent(static_cast<QGraphicsSceneContextMenuEvent *>(event));
- break;
- case QEvent::GraphicsSceneDragEnter:
- dragEnterEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
- break;
- case QEvent::GraphicsSceneDragMove:
- dragMoveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
- break;
- case QEvent::GraphicsSceneDragLeave:
- dragLeaveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
- break;
- case QEvent::GraphicsSceneDrop:
- dropEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
- break;
- case QEvent::GraphicsSceneHoverEnter:
- hoverEnterEvent(static_cast<QGraphicsSceneHoverEvent *>(event));
- break;
- case QEvent::GraphicsSceneHoverMove:
- hoverMoveEvent(static_cast<QGraphicsSceneHoverEvent *>(event));
- break;
- case QEvent::GraphicsSceneHoverLeave:
- hoverLeaveEvent(static_cast<QGraphicsSceneHoverEvent *>(event));
- break;
- case QEvent::GraphicsSceneMouseMove:
- mouseMoveEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
- break;
- case QEvent::GraphicsSceneMousePress:
- mousePressEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
- break;
- case QEvent::GraphicsSceneMouseRelease:
- mouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
- break;
- case QEvent::GraphicsSceneMouseDoubleClick:
- mouseDoubleClickEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
- break;
- case QEvent::GraphicsSceneWheel:
- wheelEvent(static_cast<QGraphicsSceneWheelEvent *>(event));
- break;
- case QEvent::KeyPress: {
- QKeyEvent *k = static_cast<QKeyEvent *>(event);
- if (k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) {
- if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier?
- bool res = false;
- if (k->key() == Qt::Key_Backtab
- || (k->key() == Qt::Key_Tab && (k->modifiers() & Qt::ShiftModifier))) {
- if (d_ptr->isWidget) {
- res = static_cast<QGraphicsWidget *>(this)->focusNextPrevChild(false);
- } else if (d_ptr->scene) {
- res = d_ptr->scene->focusNextPrevChild(false);
- }
- } else if (k->key() == Qt::Key_Tab) {
- if (d_ptr->isWidget) {
- res = static_cast<QGraphicsWidget *>(this)->focusNextPrevChild(true);
- } else if (d_ptr->scene) {
- res = d_ptr->scene->focusNextPrevChild(true);
- }
- }
- if (!res)
- event->ignore();
- return true;
- }
- }
- keyPressEvent(static_cast<QKeyEvent *>(event));
- break;
- }
- case QEvent::KeyRelease:
- keyReleaseEvent(static_cast<QKeyEvent *>(event));
- break;
- case QEvent::InputMethod:
- inputMethodEvent(static_cast<QInputMethodEvent *>(event));
- break;
- case QEvent::WindowActivate:
- case QEvent::WindowDeactivate:
- // Propagate panel activation.
- if (d_ptr->scene) {
- for (int i = 0; i < d_ptr->children.size(); ++i) {
- QGraphicsItem *child = d_ptr->children.at(i);
- if (child->isVisible() && !child->isPanel()) {
- if (!(child->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents))
- d_ptr->scene->sendEvent(child, event);
- }
- }
- }
- break;
- default:
- return false;
- }
-
- return true;
-}
-
-/*!
- This event handler can be reimplemented in a subclass to process context
- menu events. The \a event parameter contains details about the event to
- be handled.
-
- If you ignore the event, (i.e., by calling QEvent::ignore(),) \a event
- will propagate to any item beneath this item. If no items accept the
- event, it will be ignored by the scene, and propagate to the view.
-
- It's common to open a QMenu in response to receiving a context menu
- event. Example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 13
-
- The default implementation ignores the event.
-
- \sa sceneEvent()
-*/
-void QGraphicsItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
-{
- event->ignore();
-}
-
-/*!
- This event handler, for event \a event, can be reimplemented to receive
- drag enter events for this item. Drag enter events are generated as the
- cursor enters the item's area.
-
- By accepting the event, (i.e., by calling QEvent::accept(),) the item will
- accept drop events, in addition to receiving drag move and drag
- leave. Otherwise, the event will be ignored and propagate to the item
- beneath. If the event is accepted, the item will receive a drag move event
- before control goes back to the event loop.
-
- A common implementation of dragEnterEvent accepts or ignores \a event
- depending on the associated mime data in \a event. Example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 14
-
- Items do not receive drag and drop events by default; to enable this
- feature, call \c setAcceptDrops(true).
-
- The default implementation does nothing.
-
- \sa dropEvent(), dragMoveEvent(), dragLeaveEvent()
-*/
-void QGraphicsItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
-{
- Q_D(QGraphicsItem);
- // binary compatibility workaround between 4.4 and 4.5
- if (d->isProxyWidget())
- static_cast<QGraphicsProxyWidget*>(this)->dragEnterEvent(event);
-}
-
-/*!
- This event handler, for event \a event, can be reimplemented to receive
- drag leave events for this item. Drag leave events are generated as the
- cursor leaves the item's area. Most often you will not need to reimplement
- this function, but it can be useful for resetting state in your item
- (e.g., highlighting).
-
- Calling QEvent::ignore() or QEvent::accept() on \a event has no effect.
-
- Items do not receive drag and drop events by default; to enable this
- feature, call \c setAcceptDrops(true).
-
- The default implementation does nothing.
-
- \sa dragEnterEvent(), dropEvent(), dragMoveEvent()
-*/
-void QGraphicsItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
-{
- Q_D(QGraphicsItem);
- // binary compatibility workaround between 4.4 and 4.5
- if (d->isProxyWidget())
- static_cast<QGraphicsProxyWidget*>(this)->dragLeaveEvent(event);
-}
-
-/*!
- This event handler, for event \a event, can be reimplemented to receive
- drag move events for this item. Drag move events are generated as the
- cursor moves around inside the item's area. Most often you will not need
- to reimplement this function; it is used to indicate that only parts of
- the item can accept drops.
-
- Calling QEvent::ignore() or QEvent::accept() on \a event toggles whether
- or not the item will accept drops at the position from the event. By
- default, \a event is accepted, indicating that the item allows drops at
- the specified position.
-
- Items do not receive drag and drop events by default; to enable this
- feature, call \c setAcceptDrops(true).
-
- The default implementation does nothing.
-
- \sa dropEvent(), dragEnterEvent(), dragLeaveEvent()
-*/
-void QGraphicsItem::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
-{
- Q_D(QGraphicsItem);
- // binary compatibility workaround between 4.4 and 4.5
- if (d->isProxyWidget())
- static_cast<QGraphicsProxyWidget*>(this)->dragMoveEvent(event);
-}
-
-/*!
- This event handler, for event \a event, can be reimplemented to receive
- drop events for this item. Items can only receive drop events if the last
- drag move event was accepted.
-
- Calling QEvent::ignore() or QEvent::accept() on \a event has no effect.
-
- Items do not receive drag and drop events by default; to enable this
- feature, call \c setAcceptDrops(true).
-
- The default implementation does nothing.
-
- \sa dragEnterEvent(), dragMoveEvent(), dragLeaveEvent()
-*/
-void QGraphicsItem::dropEvent(QGraphicsSceneDragDropEvent *event)
-{
- Q_D(QGraphicsItem);
- // binary compatibility workaround between 4.4 and 4.5
- if (d->isProxyWidget())
- static_cast<QGraphicsProxyWidget*>(this)->dropEvent(event);
-}
-
-/*!
- This event handler, for event \a event, can be reimplemented to receive
- focus in events for this item. The default implementation calls
- ensureVisible().
-
- \sa focusOutEvent(), sceneEvent(), setFocus()
-*/
-void QGraphicsItem::focusInEvent(QFocusEvent *event)
-{
- Q_UNUSED(event);
- update();
-}
-
-/*!
- This event handler, for event \a event, can be reimplemented to receive
- focus out events for this item. The default implementation does nothing.
-
- \sa focusInEvent(), sceneEvent(), setFocus()
-*/
-void QGraphicsItem::focusOutEvent(QFocusEvent *event)
-{
- Q_UNUSED(event);
- update();
-}
-
-/*!
- This event handler, for event \a event, can be reimplemented to receive
- hover enter events for this item. The default implementation calls
- update(); otherwise it does nothing.
-
- Calling QEvent::ignore() or QEvent::accept() on \a event has no effect.
-
- \sa hoverMoveEvent(), hoverLeaveEvent(), sceneEvent(), setAcceptHoverEvents()
-*/
-void QGraphicsItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
-{
- Q_UNUSED(event);
- update();
-}
-
-/*!
- This event handler, for event \a event, can be reimplemented to receive
- hover move events for this item. The default implementation does nothing.
-
- Calling QEvent::ignore() or QEvent::accept() on \a event has no effect.
-
- \sa hoverEnterEvent(), hoverLeaveEvent(), sceneEvent(), setAcceptHoverEvents()
-*/
-void QGraphicsItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
-{
- Q_UNUSED(event);
-}
-
-/*!
- This event handler, for event \a event, can be reimplemented to receive
- hover leave events for this item. The default implementation calls
- update(); otherwise it does nothing.
-
- Calling QEvent::ignore() or QEvent::accept() on \a event has no effect.
-
- \sa hoverEnterEvent(), hoverMoveEvent(), sceneEvent(), setAcceptHoverEvents()
-*/
-void QGraphicsItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
-{
- Q_UNUSED(event);
- update();
-}
-
-/*!
- This event handler, for event \a event, can be reimplemented to
- receive key press events for this item. The default implementation
- ignores the event. If you reimplement this handler, the event will by
- default be accepted.
-
- Note that key events are only received for items that set the
- ItemIsFocusable flag, and that have keyboard input focus.
-
- \sa keyReleaseEvent(), setFocus(), QGraphicsScene::setFocusItem(),
- sceneEvent()
-*/
-void QGraphicsItem::keyPressEvent(QKeyEvent *event)
-{
- event->ignore();
-}
-
-/*!
- This event handler, for event \a event, can be reimplemented to receive
- key release events for this item. The default implementation
- ignores the event. If you reimplement this handler, the event will by
- default be accepted.
-
- Note that key events are only received for items that set the
- ItemIsFocusable flag, and that have keyboard input focus.
-
- \sa keyPressEvent(), setFocus(), QGraphicsScene::setFocusItem(),
- sceneEvent()
-*/
-void QGraphicsItem::keyReleaseEvent(QKeyEvent *event)
-{
- event->ignore();
-}
-
-/*!
- This event handler, for event \a event, can be reimplemented to
- receive mouse press events for this item. Mouse press events are
- only delivered to items that accept the mouse button that is
- pressed. By default, an item accepts all mouse buttons, but you
- can change this by calling setAcceptedMouseButtons().
-
- The mouse press event decides which item should become the mouse
- grabber (see QGraphicsScene::mouseGrabberItem()). If you do not
- reimplement this function, the press event will propagate to any
- topmost item beneath this item, and no other mouse events will be
- delivered to this item.
-
- If you do reimplement this function, \a event will by default be
- accepted (see QEvent::accept()), and this item is then the mouse
- grabber. This allows the item to receive future move, release and
- doubleclick events. If you call QEvent::ignore() on \a event, this
- item will lose the mouse grab, and \a event will propagate to any
- topmost item beneath. No further mouse events will be delivered to
- this item unless a new mouse press event is received.
-
- The default implementation handles basic item interaction, such as
- selection and moving. If you want to keep the base implementation
- when reimplementing this function, call
- QGraphicsItem::mousePressEvent() in your reimplementation.
-
- The event is \l{QEvent::ignore()}d for items that are neither
- \l{QGraphicsItem::ItemIsMovable}{movable} nor
- \l{QGraphicsItem::ItemIsSelectable}{selectable}.
-
- \sa mouseMoveEvent(), mouseReleaseEvent(),
- mouseDoubleClickEvent(), sceneEvent()
-*/
-void QGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
-{
- if (event->button() == Qt::LeftButton && (flags() & ItemIsSelectable)) {
- bool multiSelect = (event->modifiers() & Qt::ControlModifier) != 0;
- if (!multiSelect) {
- if (!d_ptr->selected) {
- if (QGraphicsScene *scene = d_ptr->scene) {
- ++scene->d_func()->selectionChanging;
- scene->clearSelection();
- --scene->d_func()->selectionChanging;
- }
- setSelected(true);
- }
- }
- } else if (!(flags() & ItemIsMovable)) {
- event->ignore();
- }
- if (d_ptr->isWidget) {
- // Qt::Popup closes when you click outside.
- QGraphicsWidget *w = static_cast<QGraphicsWidget *>(this);
- if ((w->windowFlags() & Qt::Popup) == Qt::Popup) {
- event->accept();
- if (!w->rect().contains(event->pos()))
- w->close();
- }
- }
-}
-
-/*!
- obsolete
-*/
-bool _qt_movableAncestorIsSelected(const QGraphicsItem *item)
-{
- const QGraphicsItem *parent = item->parentItem();
- return parent && (((parent->flags() & QGraphicsItem::ItemIsMovable) && parent->isSelected()) || _qt_movableAncestorIsSelected(parent));
-}
-
-bool QGraphicsItemPrivate::movableAncestorIsSelected(const QGraphicsItem *item)
-{
- const QGraphicsItem *parent = item->d_ptr->parent;
- return parent && (((parent->flags() & QGraphicsItem::ItemIsMovable) && parent->isSelected()) || _qt_movableAncestorIsSelected(parent));
-}
-
-/*!
- This event handler, for event \a event, can be reimplemented to
- receive mouse move events for this item. If you do receive this
- event, you can be certain that this item also received a mouse
- press event, and that this item is the current mouse grabber.
-
- Calling QEvent::ignore() or QEvent::accept() on \a event has no
- effect.
-
- The default implementation handles basic item interaction, such as
- selection and moving. If you want to keep the base implementation
- when reimplementing this function, call
- QGraphicsItem::mouseMoveEvent() in your reimplementation.
-
- Please note that mousePressEvent() decides which graphics item it
- is that receives mouse events. See the mousePressEvent()
- description for details.
-
- \sa mousePressEvent(), mouseReleaseEvent(),
- mouseDoubleClickEvent(), sceneEvent()
-*/
-void QGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
-{
- if ((event->buttons() & Qt::LeftButton) && (flags() & ItemIsMovable)) {
- // Determine the list of items that need to be moved.
- QList<QGraphicsItem *> selectedItems;
- QMap<QGraphicsItem *, QPointF> initialPositions;
- if (d_ptr->scene) {
- selectedItems = d_ptr->scene->selectedItems();
- initialPositions = d_ptr->scene->d_func()->movingItemsInitialPositions;
- if (initialPositions.isEmpty()) {
- foreach (QGraphicsItem *item, selectedItems)
- initialPositions[item] = item->pos();
- initialPositions[this] = pos();
- }
- d_ptr->scene->d_func()->movingItemsInitialPositions = initialPositions;
- }
-
- // Find the active view.
- QGraphicsView *view = 0;
- if (event->widget())
- view = qobject_cast<QGraphicsView *>(event->widget()->parentWidget());
-
- // Move all selected items
- int i = 0;
- bool movedMe = false;
- while (i <= selectedItems.size()) {
- QGraphicsItem *item = 0;
- if (i < selectedItems.size())
- item = selectedItems.at(i);
- else
- item = this;
- if (item == this) {
- // Slightly clumsy-looking way to ensure that "this" is part
- // of the list of items to move, this is to avoid allocations
- // (appending this item to the list of selected items causes a
- // detach).
- if (movedMe)
- break;
- movedMe = true;
- }
-
- if ((item->flags() & ItemIsMovable) && !QGraphicsItemPrivate::movableAncestorIsSelected(item)) {
- QPointF currentParentPos;
- QPointF buttonDownParentPos;
- if (item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorIgnoresTransformations) {
- // Items whose ancestors ignore transformations need to
- // map screen coordinates to local coordinates, then map
- // those to the parent.
- QTransform viewToItemTransform = (item->deviceTransform(view->viewportTransform())).inverted();
- currentParentPos = mapToParent(viewToItemTransform.map(QPointF(view->mapFromGlobal(event->screenPos()))));
- buttonDownParentPos = mapToParent(viewToItemTransform.map(QPointF(view->mapFromGlobal(event->buttonDownScreenPos(Qt::LeftButton)))));
- } else if (item->flags() & ItemIgnoresTransformations) {
- // Root items that ignore transformations need to
- // calculate their diff by mapping viewport coordinates
- // directly to parent coordinates.
- // COMBINE
- QTransform itemTransform;
- if (item->d_ptr->transformData)
- itemTransform = item->d_ptr->transformData->computedFullTransform();
- itemTransform.translate(item->d_ptr->pos.x(), item->d_ptr->pos.y());
- QTransform viewToParentTransform = itemTransform
- * (item->sceneTransform() * view->viewportTransform()).inverted();
- currentParentPos = viewToParentTransform.map(QPointF(view->mapFromGlobal(event->screenPos())));
- buttonDownParentPos = viewToParentTransform.map(QPointF(view->mapFromGlobal(event->buttonDownScreenPos(Qt::LeftButton))));
- } else {
- // All other items simply map from the scene.
- currentParentPos = item->mapToParent(item->mapFromScene(event->scenePos()));
- buttonDownParentPos = item->mapToParent(item->mapFromScene(event->buttonDownScenePos(Qt::LeftButton)));
- }
-
- item->setPos(initialPositions.value(item) + currentParentPos - buttonDownParentPos);
-
- if (item->flags() & ItemIsSelectable)
- item->setSelected(true);
- }
- ++i;
- }
-
- } else {
- event->ignore();
- }
-}
-
-/*!
- This event handler, for event \a event, can be reimplemented to
- receive mouse release events for this item.
-
- Calling QEvent::ignore() or QEvent::accept() on \a event has no
- effect.
-
- The default implementation handles basic item interaction, such as
- selection and moving. If you want to keep the base implementation
- when reimplementing this function, call
- QGraphicsItem::mouseReleaseEvent() in your reimplementation.
-
- Please note that mousePressEvent() decides which graphics item it
- is that receives mouse events. See the mousePressEvent()
- description for details.
-
- \sa mousePressEvent(), mouseMoveEvent(), mouseDoubleClickEvent(),
- sceneEvent()
-*/
-void QGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-{
- if (flags() & ItemIsSelectable) {
- bool multiSelect = (event->modifiers() & Qt::ControlModifier) != 0;
- if (event->scenePos() == event->buttonDownScenePos(Qt::LeftButton)) {
- // The item didn't move
- if (multiSelect) {
- setSelected(!isSelected());
- } else {
- bool selectionChanged = false;
- if (QGraphicsScene *scene = d_ptr->scene) {
- ++scene->d_func()->selectionChanging;
- // Clear everything but this item. Bypass
- // QGraphicsScene::clearSelection()'s default behavior by
- // temporarily removing this item from the selection list.
- if (d_ptr->selected) {
- scene->d_func()->selectedItems.remove(this);
- foreach (QGraphicsItem *item, scene->d_func()->selectedItems) {
- if (item->isSelected()) {
- selectionChanged = true;
- break;
- }
- }
- }
- scene->clearSelection();
- if (d_ptr->selected)
- scene->d_func()->selectedItems.insert(this);
- --scene->d_func()->selectionChanging;
- if (selectionChanged)
- emit d_ptr->scene->selectionChanged();
- }
- setSelected(true);
- }
- }
- }
- if (d_ptr->scene && !event->buttons())
- d_ptr->scene->d_func()->movingItemsInitialPositions.clear();
-}
-
-/*!
- This event handler, for event \a event, can be reimplemented to
- receive mouse doubleclick events for this item.
-
- When doubleclicking an item, the item will first receive a mouse
- press event, followed by a release event (i.e., a click), then a
- doubleclick event, and finally a release event.
-
- Calling QEvent::ignore() or QEvent::accept() on \a event has no
- effect.
-
- The default implementation calls mousePressEvent(). If you want to
- keep the base implementation when reimplementing this function,
- call QGraphicsItem::mouseDoubleClickEvent() in your
- reimplementation.
-
- Note that an item will not receive double click events if it is
- neither \l {QGraphicsItem::ItemIsSelectable}{selectable} nor
- \l{QGraphicsItem::ItemIsMovable}{movable} (single mouse clicks are
- ignored in this case, and that stops the generation of double
- clicks).
-
- \sa mousePressEvent(), mouseMoveEvent(), mouseReleaseEvent(), sceneEvent()
-*/
-void QGraphicsItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
-{
- mousePressEvent(event);
-}
-
-/*!
- This event handler, for event \a event, can be reimplemented to receive
- wheel events for this item. If you reimplement this function, \a event
- will be accepted by default.
-
- If you ignore the event, (i.e., by calling QEvent::ignore(),) it will
- propagate to any item beneath this item. If no items accept the event, it
- will be ignored by the scene, and propagate to the view (e.g., the view's
- vertical scroll bar).
-
- The default implementation ignores the event.
-
- \sa sceneEvent()
-*/
-void QGraphicsItem::wheelEvent(QGraphicsSceneWheelEvent *event)
-{
- event->ignore();
-}
-
-/*!
- This event handler, for event \a event, can be reimplemented to receive
- input method events for this item. The default implementation ignores the
- event.
-
- \sa inputMethodQuery(), sceneEvent()
-*/
-void QGraphicsItem::inputMethodEvent(QInputMethodEvent *event)
-{
- event->ignore();
-}
-
-/*!
- This method is only relevant for input items. It is used by the
- input method to query a set of properties of the item to be able
- to support complex input method operations, such as support for
- surrounding text and reconversions. \a query specifies which
- property is queried.
-
- \sa inputMethodEvent(), QInputMethodEvent, QInputContext
-*/
-QVariant QGraphicsItem::inputMethodQuery(Qt::InputMethodQuery query) const
-{
- if (isWidget()) {
- // ### Qt 5: Remove. The reimplementation in
- // QGraphicsProxyWidget solves this problem (but requires a
- // recompile to take effect).
- return d_ptr->inputMethodQueryHelper(query);
- }
-
- Q_UNUSED(query);
- return QVariant();
-}
-
-/*!
- Returns the current input method hints of this item.
-
- Input method hints are only relevant for input items.
- The hints are used by the input method to indicate how it should operate.
- For example, if the Qt::ImhNumbersOnly flag is set, the input method may change
- its visual components to reflect that only numbers can be entered.
-
- The effect may vary between input method implementations.
-
- \since 4.6
-
- \sa setInputMethodHints(), inputMethodQuery(), QInputContext
-*/
-Qt::InputMethodHints QGraphicsItem::inputMethodHints() const
-{
- Q_D(const QGraphicsItem);
- return d->imHints;
-}
-
-/*!
- Sets the current input method hints of this item to \a hints.
-
- \since 4.6
-
- \sa inputMethodHints(), inputMethodQuery(), QInputContext
-*/
-void QGraphicsItem::setInputMethodHints(Qt::InputMethodHints hints)
-{
- Q_D(QGraphicsItem);
- d->imHints = hints;
- if (!hasFocus())
- return;
- d->scene->d_func()->updateInputMethodSensitivityInViews();
-#if !defined(QT_NO_IM) && (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN))
- QWidget *fw = QApplication::focusWidget();
- if (!fw)
- return;
- for (int i = 0 ; i < scene()->views().count() ; ++i)
- if (scene()->views().at(i) == fw)
- if (QInputContext *inputContext = fw->inputContext())
- inputContext->update();
-#endif
-}
-
-/*!
- Updates the item's micro focus.
-
- \since 4.7
-
- \sa QInputContext
-*/
-void QGraphicsItem::updateMicroFocus()
-{
-#if !defined(QT_NO_IM) && (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN))
- if (QWidget *fw = QApplication::focusWidget()) {
- if (scene()) {
- for (int i = 0 ; i < scene()->views().count() ; ++i) {
- if (scene()->views().at(i) == fw) {
- if (QInputContext *inputContext = fw->inputContext()) {
- inputContext->update();
-#ifndef QT_NO_ACCESSIBILITY
- // ##### is this correct
- if (toGraphicsObject())
- QAccessible::updateAccessibility(toGraphicsObject(), 0, QAccessible::StateChanged);
-#endif
- break;
- }
- }
- }
- }
- }
-#endif
-}
-
-/*!
- This virtual function is called by QGraphicsItem to notify custom items
- that some part of the item's state changes. By reimplementing this
- function, your can react to a change, and in some cases, (depending on \a
- change,) adjustments can be made.
-
- \a change is the parameter of the item that is changing. \a value is the
- new value; the type of the value depends on \a change.
-
- Example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 15
-
- The default implementation does nothing, and returns \a value.
-
- Note: Certain QGraphicsItem functions cannot be called in a
- reimplementation of this function; see the GraphicsItemChange
- documentation for details.
-
- \sa GraphicsItemChange
-*/
-QVariant QGraphicsItem::itemChange(GraphicsItemChange change, const QVariant &value)
-{
- Q_UNUSED(change);
- return value;
-}
-
-/*!
- \internal
-
- Note: This is provided as a hook to avoid future problems related
- to adding virtual functions.
-*/
-bool QGraphicsItem::supportsExtension(Extension extension) const
-{
- Q_UNUSED(extension);
- return false;
-}
-
-/*!
- \internal
-
- Note: This is provided as a hook to avoid future problems related
- to adding virtual functions.
-*/
-void QGraphicsItem::setExtension(Extension extension, const QVariant &variant)
-{
- Q_UNUSED(extension);
- Q_UNUSED(variant);
-}
-
-/*!
- \internal
-
- Note: This is provided as a hook to avoid future problems related
- to adding virtual functions.
-*/
-QVariant QGraphicsItem::extension(const QVariant &variant) const
-{
- Q_UNUSED(variant);
- return QVariant();
-}
-
-/*!
- \internal
-
- Adds this item to the scene's index. Called in conjunction with
- removeFromIndex() to ensure the index bookkeeping is correct when
- the item's position, transformation or shape changes.
-*/
-void QGraphicsItem::addToIndex()
-{
- if (d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) {
- // ### add to child index only if applicable
- return;
- }
- if (d_ptr->scene)
- d_ptr->scene->d_func()->index->addItem(this);
-}
-
-/*!
- \internal
-
- Removes this item from the scene's index. Called in conjunction
- with addToIndex() to ensure the index bookkeeping is correct when
- the item's position, transformation or shape changes.
-*/
-void QGraphicsItem::removeFromIndex()
-{
- if (d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) {
- // ### remove from child index only if applicable
- return;
- }
- if (d_ptr->scene)
- d_ptr->scene->d_func()->index->removeItem(this);
-}
-
-/*!
- Prepares the item for a geometry change. Call this function before
- changing the bounding rect of an item to keep QGraphicsScene's index up to
- date.
-
- prepareGeometryChange() will call update() if this is necessary.
-
- Example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 16
-
- \sa boundingRect()
-*/
-void QGraphicsItem::prepareGeometryChange()
-{
- if (d_ptr->inDestructor)
- return;
- if (d_ptr->scene) {
- d_ptr->scene->d_func()->dirtyGrowingItemsBoundingRect = true;
- d_ptr->geometryChanged = 1;
- d_ptr->paintedViewBoundingRectsNeedRepaint = 1;
- d_ptr->notifyBoundingRectChanged = !d_ptr->inSetPosHelper;
-
- QGraphicsScenePrivate *scenePrivate = d_ptr->scene->d_func();
- scenePrivate->index->prepareBoundingRectChange(this);
- scenePrivate->markDirty(this, QRectF(), /*invalidateChildren=*/true, /*force=*/false,
- /*ignoreOpacity=*/ false, /*removingItemFromScene=*/ false,
- /*updateBoundingRect=*/true);
-
- // For compatibility reasons, we have to update the item's old geometry
- // if someone is connected to the changed signal or the scene has no views.
- // Note that this has to be done *after* markDirty to ensure that
- // _q_processDirtyItems is called before _q_emitUpdated.
- if (scenePrivate->isSignalConnected(scenePrivate->changedSignalIndex)
- || scenePrivate->views.isEmpty()) {
- if (d_ptr->hasTranslateOnlySceneTransform()) {
- d_ptr->scene->update(boundingRect().translated(d_ptr->sceneTransform.dx(),
- d_ptr->sceneTransform.dy()));
- } else {
- d_ptr->scene->update(d_ptr->sceneTransform.mapRect(boundingRect()));
- }
- }
- }
-
- d_ptr->markParentDirty(/*updateBoundingRect=*/true);
-}
-
-/*!
- \internal
-
- Highlights \a item as selected.
-
- NOTE: This function is a duplicate of qt_graphicsItem_highlightSelected() in
- qgraphicssvgitem.cpp!
-*/
-static void qt_graphicsItem_highlightSelected(
- QGraphicsItem *item, QPainter *painter, const QStyleOptionGraphicsItem *option)
-{
- const QRectF murect = painter->transform().mapRect(QRectF(0, 0, 1, 1));
- if (qFuzzyIsNull(qMax(murect.width(), murect.height())))
- return;
-
- const QRectF mbrect = painter->transform().mapRect(item->boundingRect());
- if (qMin(mbrect.width(), mbrect.height()) < qreal(1.0))
- return;
-
- qreal itemPenWidth;
- switch (item->type()) {
- case QGraphicsEllipseItem::Type:
- itemPenWidth = static_cast<QGraphicsEllipseItem *>(item)->pen().widthF();
- break;
- case QGraphicsPathItem::Type:
- itemPenWidth = static_cast<QGraphicsPathItem *>(item)->pen().widthF();
- break;
- case QGraphicsPolygonItem::Type:
- itemPenWidth = static_cast<QGraphicsPolygonItem *>(item)->pen().widthF();
- break;
- case QGraphicsRectItem::Type:
- itemPenWidth = static_cast<QGraphicsRectItem *>(item)->pen().widthF();
- break;
- case QGraphicsSimpleTextItem::Type:
- itemPenWidth = static_cast<QGraphicsSimpleTextItem *>(item)->pen().widthF();
- break;
- case QGraphicsLineItem::Type:
- itemPenWidth = static_cast<QGraphicsLineItem *>(item)->pen().widthF();
- break;
- default:
- itemPenWidth = 1.0;
- }
- const qreal pad = itemPenWidth / 2;
-
- const qreal penWidth = 0; // cosmetic pen
-
- const QColor fgcolor = option->palette.windowText().color();
- const QColor bgcolor( // ensure good contrast against fgcolor
- fgcolor.red() > 127 ? 0 : 255,
- fgcolor.green() > 127 ? 0 : 255,
- fgcolor.blue() > 127 ? 0 : 255);
-
- painter->setPen(QPen(bgcolor, penWidth, Qt::SolidLine));
- painter->setBrush(Qt::NoBrush);
- painter->drawRect(item->boundingRect().adjusted(pad, pad, -pad, -pad));
-
- painter->setPen(QPen(option->palette.windowText(), 0, Qt::DashLine));
- painter->setBrush(Qt::NoBrush);
- painter->drawRect(item->boundingRect().adjusted(pad, pad, -pad, -pad));
-}
-
-/*!
- \class QGraphicsObject
- \brief The QGraphicsObject class provides a base class for all graphics items that
- require signals, slots and properties.
- \since 4.6
- \ingroup graphicsview-api
-
- The class extends a QGraphicsItem with QObject's signal/slot and property mechanisms.
- It maps many of QGraphicsItem's basic setters and getters to properties and adds notification
- signals for many of them.
-
- \section1 Parents and Children
-
- Each graphics object can be constructed with a parent item. This ensures that the
- item will be destroyed when its parent item is destroyed. Although QGraphicsObject
- inherits from both QObject and QGraphicsItem, you should use the functions provided
- by QGraphicsItem, \e not QObject, to manage the relationships between parent and
- child items.
-
- The relationships between items can be explored using the parentItem() and childItems()
- functions. In the hierarchy of items in a scene, the parentObject() and parentWidget()
- functions are the equivalent of the QWidget::parent() and QWidget::parentWidget()
- functions for QWidget subclasses.
-
- \sa QGraphicsWidget
-*/
-
-/*!
- Constructs a QGraphicsObject with \a parent.
-*/
-QGraphicsObject::QGraphicsObject(QGraphicsItem *parent)
- : QGraphicsItem(parent)
-{
- QGraphicsItem::d_ptr->isObject = true;
-}
-
-/*!
- \internal
-*/
-QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene)
- : QGraphicsItem(dd, parent, scene)
-{
- QGraphicsItem::d_ptr->isObject = true;
-}
-
-#ifndef QT_NO_GESTURES
-/*!
- Subscribes the graphics object to the given \a gesture with specific \a flags.
-
- \sa ungrabGesture(), QGestureEvent
-*/
-void QGraphicsObject::grabGesture(Qt::GestureType gesture, Qt::GestureFlags flags)
-{
- bool contains = QGraphicsItem::d_ptr->gestureContext.contains(gesture);
- QGraphicsItem::d_ptr->gestureContext.insert(gesture, flags);
- if (!contains && QGraphicsItem::d_ptr->scene)
- QGraphicsItem::d_ptr->scene->d_func()->grabGesture(this, gesture);
-}
-
-/*!
- Unsubscribes the graphics object from the given \a gesture.
-
- \sa grabGesture(), QGestureEvent
-*/
-void QGraphicsObject::ungrabGesture(Qt::GestureType gesture)
-{
- if (QGraphicsItem::d_ptr->gestureContext.remove(gesture) && QGraphicsItem::d_ptr->scene)
- QGraphicsItem::d_ptr->scene->d_func()->ungrabGesture(this, gesture);
-}
-#endif // QT_NO_GESTURES
-
-/*!
- Updates the item's micro focus. This is slot for convenience.
-
- \since 4.7
-
- \sa QInputContext
-*/
-void QGraphicsObject::updateMicroFocus()
-{
- QGraphicsItem::updateMicroFocus();
-}
-
-void QGraphicsItemPrivate::children_append(QDeclarativeListProperty<QGraphicsObject> *list, QGraphicsObject *item)
-{
- if (item) {
- QGraphicsObject *graphicsObject = static_cast<QGraphicsObject *>(list->object);
- if (QGraphicsItemPrivate::get(graphicsObject)->sendParentChangeNotification) {
- item->setParentItem(graphicsObject);
- } else {
- QGraphicsItemPrivate::get(item)->setParentItemHelper(graphicsObject, 0, 0);
- }
- }
-}
-
-int QGraphicsItemPrivate::children_count(QDeclarativeListProperty<QGraphicsObject> *list)
-{
- QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object));
- return d->children.count();
-}
-
-QGraphicsObject *QGraphicsItemPrivate::children_at(QDeclarativeListProperty<QGraphicsObject> *list, int index)
-{
- QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object));
- if (index >= 0 && index < d->children.count())
- return d->children.at(index)->toGraphicsObject();
- else
- return 0;
-}
-
-void QGraphicsItemPrivate::children_clear(QDeclarativeListProperty<QGraphicsObject> *list)
-{
- QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object));
- int childCount = d->children.count();
- if (d->sendParentChangeNotification) {
- for (int index = 0; index < childCount; index++)
- d->children.at(0)->setParentItem(0);
- } else {
- for (int index = 0; index < childCount; index++)
- QGraphicsItemPrivate::get(d->children.at(0))->setParentItemHelper(0, 0, 0);
- }
-}
-
-/*!
- Returns a list of this item's children.
-
- The items are sorted by stacking order. This takes into account both the
- items' insertion order and their Z-values.
-
-*/
-QDeclarativeListProperty<QGraphicsObject> QGraphicsItemPrivate::childrenList()
-{
- Q_Q(QGraphicsItem);
- if (isObject) {
- QGraphicsObject *that = static_cast<QGraphicsObject *>(q);
- return QDeclarativeListProperty<QGraphicsObject>(that, &children, children_append,
- children_count, children_at, children_clear);
- } else {
- //QGraphicsItem is not supported for this property
- return QDeclarativeListProperty<QGraphicsObject>();
- }
-}
-
-/*!
- \internal
- Returns the width of the item
- Reimplemented by QGraphicsWidget
-*/
-qreal QGraphicsItemPrivate::width() const
-{
- return 0;
-}
-
-/*!
- \internal
- Set the width of the item
- Reimplemented by QGraphicsWidget
-*/
-void QGraphicsItemPrivate::setWidth(qreal w)
-{
- Q_UNUSED(w);
-}
-
-/*!
- \internal
- Reset the width of the item
- Reimplemented by QGraphicsWidget
-*/
-void QGraphicsItemPrivate::resetWidth()
-{
-}
-
-/*!
- \internal
- Returns the height of the item
- Reimplemented by QGraphicsWidget
-*/
-qreal QGraphicsItemPrivate::height() const
-{
- return 0;
-}
-
-/*!
- \internal
- Set the height of the item
- Reimplemented by QGraphicsWidget
-*/
-void QGraphicsItemPrivate::setHeight(qreal h)
-{
- Q_UNUSED(h);
-}
-
-/*!
- \internal
- Reset the height of the item
- Reimplemented by QGraphicsWidget
-*/
-void QGraphicsItemPrivate::resetHeight()
-{
-}
-
-/*!
- \property QGraphicsObject::children
- \since 4.7
- \internal
-*/
-
-/*!
- \property QGraphicsObject::width
- \since 4.7
- \internal
-*/
-
-/*!
- \property QGraphicsObject::height
- \since 4.7
- \internal
-*/
-
-/*!
- \property QGraphicsObject::parent
- \brief the parent of the item
-
- \note The item's parent is set independently of the parent object returned
- by QObject::parent().
-
- \sa QGraphicsItem::setParentItem(), QGraphicsItem::parentObject()
-*/
-
-/*!
- \property QGraphicsObject::opacity
- \brief the opacity of the item
-
- \sa QGraphicsItem::setOpacity(), QGraphicsItem::opacity()
-*/
-
-/*!
- \fn QGraphicsObject::opacityChanged()
-
- This signal gets emitted whenever the opacity of the item changes
-
- \sa QGraphicsItem::opacity()
-*/
-
-/*!
- \fn QGraphicsObject::parentChanged()
-
- This signal gets emitted whenever the parent of the item changes
-*/
-
-/*!
- \property QGraphicsObject::pos
- \brief the position of the item
-
- Describes the items position.
-
- \sa QGraphicsItem::setPos(), QGraphicsItem::pos()
-*/
-
-/*!
- \property QGraphicsObject::x
- \brief the x position of the item
-
- Describes the items x position.
-
- \sa QGraphicsItem::setX(), setPos(), xChanged()
-*/
-
-/*!
- \fn QGraphicsObject::xChanged()
-
- This signal gets emitted whenever the x position of the item changes
-
- \sa pos()
-*/
-
-/*!
- \property QGraphicsObject::y
- \brief the y position of the item
-
- Describes the items y position.
-
- \sa QGraphicsItem::setY(), setPos(), yChanged()
-*/
-
-/*!
- \fn QGraphicsObject::yChanged()
-
- This signal gets emitted whenever the y position of the item changes.
-
- \sa pos()
-*/
-
-/*!
- \property QGraphicsObject::z
- \brief the z value of the item
-
- Describes the items z value.
-
- \sa QGraphicsItem::setZValue(), zValue(), zChanged()
-*/
-
-/*!
- \fn QGraphicsObject::zChanged()
-
- This signal gets emitted whenever the z value of the item changes.
-
- \sa pos()
-*/
-
-/*!
- \property QGraphicsObject::rotation
- This property holds the rotation of the item in degrees.
-
- This specifies how many degrees to rotate the item around its transformOrigin.
- The default rotation is 0 degrees (i.e. not rotated at all).
-*/
-
-/*!
- \fn QGraphicsObject::rotationChanged()
-
- This signal gets emitted whenever the roation of the item changes.
-*/
-
-/*!
- \property QGraphicsObject::scale
- This property holds the scale of the item.
-
- A scale of less than 1 means the item will be displayed smaller than
- normal, and a scale of greater than 1 means the item will be
- displayed larger than normal. A negative scale means the item will
- be mirrored.
-
- By default, items are displayed at a scale of 1 (i.e. at their
- normal size).
-
- Scaling is from the item's transformOrigin.
-*/
-
-/*!
- \fn void QGraphicsObject::scaleChanged()
-
- This signal is emitted when the scale of the item changes.
-*/
-
-
-/*!
- \property QGraphicsObject::enabled
- \brief whether the item is enabled or not
-
- This property is declared in QGraphicsItem.
-
- By default, this property is true.
-
- \sa QGraphicsItem::isEnabled(), QGraphicsItem::setEnabled()
- \sa QGraphicsObject::enabledChanged()
-*/
-
-/*!
- \fn void QGraphicsObject::enabledChanged()
-
- This signal gets emitted whenever the item get's enabled or disabled.
-
- \sa isEnabled()
-*/
-
-/*!
- \property QGraphicsObject::visible
- \brief whether the item is visible or not
-
- This property is declared in QGraphicsItem.
-
- By default, this property is true.
-
- \sa QGraphicsItem::isVisible(), QGraphicsItem::setVisible(), visibleChanged()
-*/
-
-/*!
- \fn QGraphicsObject::visibleChanged()
-
- This signal gets emitted whenever the visibility of the item changes
-
- \sa visible
-*/
-
-/*!
- \fn const QObjectList &QGraphicsObject::children() const
- \internal
-
- This function returns the same value as QObject::children(). It's
- provided to differentiate between the obsolete member
- QGraphicsItem::children() and QObject::children(). QGraphicsItem now
- provides childItems() instead.
-*/
-
-/*!
- \property QGraphicsObject::transformOriginPoint
- \brief the transformation origin
-
- This property sets a specific point in the items coordiante system as the
- origin for scale and rotation.
-
- \sa scale, rotation, QGraphicsItem::transformOriginPoint()
-*/
-
-/*!
- \fn void QGraphicsObject::widthChanged()
- \internal
-*/
-
-/*!
- \fn void QGraphicsObject::heightChanged()
- \internal
-*/
-
-/*!
-
- \fn QGraphicsObject::childrenChanged()
-
- This signal gets emitted whenever the children list changes
- \internal
-*/
-
-/*!
- \property QGraphicsObject::effect
- \since 4.7
- \brief the effect attached to this item
-
- \sa QGraphicsItem::setGraphicsEffect(), QGraphicsItem::graphicsEffect()
-*/
-
-/*!
- \class QAbstractGraphicsShapeItem
- \brief The QAbstractGraphicsShapeItem class provides a common base for
- all path items.
- \since 4.2
- \ingroup graphicsview-api
-
- This class does not fully implement an item by itself; in particular, it
- does not implement boundingRect() and paint(), which are inherited by
- QGraphicsItem.
-
- You can subclass this item to provide a simple base implementation of
- accessors for the item's pen and brush.
-
- \sa QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPathItem,
- QGraphicsPolygonItem, QGraphicsTextItem, QGraphicsLineItem,
- QGraphicsPixmapItem, {Graphics View Framework}
-*/
-
-class QAbstractGraphicsShapeItemPrivate : public QGraphicsItemPrivate
-{
- Q_DECLARE_PUBLIC(QAbstractGraphicsShapeItem)
-public:
-
- QBrush brush;
- QPen pen;
-
- // Cached bounding rectangle
- mutable QRectF boundingRect;
-};
-
-/*!
- Constructs a QAbstractGraphicsShapeItem. \a parent is passed to
- QGraphicsItem's constructor.
-*/
-QAbstractGraphicsShapeItem::QAbstractGraphicsShapeItem(QGraphicsItem *parent
-#ifndef Q_QDOC
- // obsolete argument
- , QGraphicsScene *scene
-#endif
- )
- : QGraphicsItem(*new QAbstractGraphicsShapeItemPrivate, parent, scene)
-{
-}
-
-/*!
- \internal
-*/
-QAbstractGraphicsShapeItem::QAbstractGraphicsShapeItem(QAbstractGraphicsShapeItemPrivate &dd,
- QGraphicsItem *parent,
- QGraphicsScene *scene)
- : QGraphicsItem(dd, parent, scene)
-{
-}
-
-/*!
- Destroys a QAbstractGraphicsShapeItem.
-*/
-QAbstractGraphicsShapeItem::~QAbstractGraphicsShapeItem()
-{
-}
-
-/*!
- Returns the item's pen. If no pen has been set, this function returns
- QPen(), a default black solid line pen with 0 width.
-*/
-QPen QAbstractGraphicsShapeItem::pen() const
-{
- Q_D(const QAbstractGraphicsShapeItem);
- return d->pen;
-}
-
-/*!
- Sets the pen for this item to \a pen.
-
- The pen is used to draw the item's outline.
-
- \sa pen()
-*/
-void QAbstractGraphicsShapeItem::setPen(const QPen &pen)
-{
- Q_D(QAbstractGraphicsShapeItem);
- if (d->pen == pen)
- return;
- prepareGeometryChange();
- d->pen = pen;
- d->boundingRect = QRectF();
- update();
-}
-
-/*!
- Returns the item's brush, or an empty brush if no brush has been set.
-
- \sa setBrush()
-*/
-QBrush QAbstractGraphicsShapeItem::brush() const
-{
- Q_D(const QAbstractGraphicsShapeItem);
- return d->brush;
-}
-
-/*!
- Sets the item's brush to \a brush.
-
- The item's brush is used to fill the item.
-
- If you use a brush with a QGradient, the gradient
- is relative to the item's coordinate system.
-
- \sa brush()
-*/
-void QAbstractGraphicsShapeItem::setBrush(const QBrush &brush)
-{
- Q_D(QAbstractGraphicsShapeItem);
- if (d->brush == brush)
- return;
- d->brush = brush;
- update();
-}
-
-/*!
- \reimp
-*/
-bool QAbstractGraphicsShapeItem::isObscuredBy(const QGraphicsItem *item) const
-{
- return QGraphicsItem::isObscuredBy(item);
-}
-
-/*!
- \reimp
-*/
-QPainterPath QAbstractGraphicsShapeItem::opaqueArea() const
-{
- Q_D(const QAbstractGraphicsShapeItem);
- if (d->brush.isOpaque())
- return isClipped() ? clipPath() : shape();
- return QGraphicsItem::opaqueArea();
-}
-
-/*!
- \class QGraphicsPathItem
- \brief The QGraphicsPathItem class provides a path item that you
- can add to a QGraphicsScene.
- \since 4.2
- \ingroup graphicsview-api
-
- To set the item's path, pass a QPainterPath to QGraphicsPathItem's
- constructor, or call the setPath() function. The path() function
- returns the current path.
-
- \image graphicsview-pathitem.png
-
- QGraphicsPathItem uses the path to provide a reasonable
- implementation of boundingRect(), shape(), and contains(). The
- paint() function draws the path using the item's associated pen
- and brush, which you can set by calling the setPen() and
- setBrush() functions.
-
- \sa QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPolygonItem,
- QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics
- View Framework}
-*/
-
-class QGraphicsPathItemPrivate : public QAbstractGraphicsShapeItemPrivate
-{
- Q_DECLARE_PUBLIC(QGraphicsPathItem)
-public:
- QPainterPath path;
-};
-
-/*!
- Constructs a QGraphicsPath item using \a path as the default path. \a
- parent is passed to QAbstractGraphicsShapeItem's constructor.
-
- \sa QGraphicsScene::addItem()
-*/
-QGraphicsPathItem::QGraphicsPathItem(const QPainterPath &path,
- QGraphicsItem *parent
-#ifndef Q_QDOC
- // obsolete argument
- , QGraphicsScene *scene
-#endif
- )
- : QAbstractGraphicsShapeItem(*new QGraphicsPathItemPrivate, parent, scene)
-{
- if (!path.isEmpty())
- setPath(path);
-}
-
-/*!
- Constructs a QGraphicsPath. \a parent is passed to
- QAbstractGraphicsShapeItem's constructor.
-
- \sa QGraphicsScene::addItem()
-*/
-QGraphicsPathItem::QGraphicsPathItem(QGraphicsItem *parent
-#ifndef Q_QDOC
- // obsolete argument
- , QGraphicsScene *scene
-#endif
- )
- : QAbstractGraphicsShapeItem(*new QGraphicsPathItemPrivate, parent, scene)
-{
-}
-
-/*!
- Destroys the QGraphicsPathItem.
-*/
-QGraphicsPathItem::~QGraphicsPathItem()
-{
-}
-
-/*!
- Returns the item's path as a QPainterPath. If no item has been set, an
- empty QPainterPath is returned.
-
- \sa setPath()
-*/
-QPainterPath QGraphicsPathItem::path() const
-{
- Q_D(const QGraphicsPathItem);
- return d->path;
-}
-
-/*!
- Sets the item's path to be the given \a path.
-
- \sa path()
-*/
-void QGraphicsPathItem::setPath(const QPainterPath &path)
-{
- Q_D(QGraphicsPathItem);
- if (d->path == path)
- return;
- prepareGeometryChange();
- d->path = path;
- d->boundingRect = QRectF();
- update();
-}
-
-/*!
- \reimp
-*/
-QRectF QGraphicsPathItem::boundingRect() const
-{
- Q_D(const QGraphicsPathItem);
- if (d->boundingRect.isNull()) {
- qreal pw = pen().widthF();
- if (pw == 0.0)
- d->boundingRect = d->path.controlPointRect();
- else {
- d->boundingRect = shape().controlPointRect();
- }
- }
- return d->boundingRect;
-}
-
-/*!
- \reimp
-*/
-QPainterPath QGraphicsPathItem::shape() const
-{
- Q_D(const QGraphicsPathItem);
- return qt_graphicsItem_shapeFromPath(d->path, d->pen);
-}
-
-/*!
- \reimp
-*/
-bool QGraphicsPathItem::contains(const QPointF &point) const
-{
- return QAbstractGraphicsShapeItem::contains(point);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsPathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
- QWidget *widget)
-{
- Q_D(QGraphicsPathItem);
- Q_UNUSED(widget);
- painter->setPen(d->pen);
- painter->setBrush(d->brush);
- painter->drawPath(d->path);
-
- if (option->state & QStyle::State_Selected)
- qt_graphicsItem_highlightSelected(this, painter, option);
-}
-
-/*!
- \reimp
-*/
-bool QGraphicsPathItem::isObscuredBy(const QGraphicsItem *item) const
-{
- return QAbstractGraphicsShapeItem::isObscuredBy(item);
-}
-
-/*!
- \reimp
-*/
-QPainterPath QGraphicsPathItem::opaqueArea() const
-{
- return QAbstractGraphicsShapeItem::opaqueArea();
-}
-
-/*!
- \reimp
-*/
-int QGraphicsPathItem::type() const
-{
- return Type;
-}
-
-/*!
- \internal
-*/
-bool QGraphicsPathItem::supportsExtension(Extension extension) const
-{
- Q_UNUSED(extension);
- return false;
-}
-
-/*!
- \internal
-*/
-void QGraphicsPathItem::setExtension(Extension extension, const QVariant &variant)
-{
- Q_UNUSED(extension);
- Q_UNUSED(variant);
-}
-
-/*!
- \internal
-*/
-QVariant QGraphicsPathItem::extension(const QVariant &variant) const
-{
- Q_UNUSED(variant);
- return QVariant();
-}
-
-/*!
- \class QGraphicsRectItem
- \brief The QGraphicsRectItem class provides a rectangle item that you
- can add to a QGraphicsScene.
- \since 4.2
- \ingroup graphicsview-api
-
- To set the item's rectangle, pass a QRectF to QGraphicsRectItem's
- constructor, or call the setRect() function. The rect() function
- returns the current rectangle.
-
- \image graphicsview-rectitem.png
-
- QGraphicsRectItem uses the rectangle and the pen width to provide
- a reasonable implementation of boundingRect(), shape(), and
- contains(). The paint() function draws the rectangle using the
- item's associated pen and brush, which you can set by calling the
- setPen() and setBrush() functions.
-
- \note The rendering of invalid rectangles, such as those with negative
- widths or heights, is undefined. If you cannot be sure that you are
- using valid rectangles (for example, if you are creating
- rectangles using data from an unreliable source) then you should
- use QRectF::normalized() to create normalized rectangles, and use
- those instead.
-
- \sa QGraphicsPathItem, QGraphicsEllipseItem, QGraphicsPolygonItem,
- QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics
- View Framework}
-*/
-
-class QGraphicsRectItemPrivate : public QAbstractGraphicsShapeItemPrivate
-{
- Q_DECLARE_PUBLIC(QGraphicsRectItem)
-public:
- QRectF rect;
-};
-
-/*!
- Constructs a QGraphicsRectItem, using \a rect as the default rectangle.
- \a parent is passed to QAbstractGraphicsShapeItem's constructor.
-
- \sa QGraphicsScene::addItem()
-*/
-QGraphicsRectItem::QGraphicsRectItem(const QRectF &rect, QGraphicsItem *parent
-#ifndef Q_QDOC
- // obsolete argument
- , QGraphicsScene *scene
-#endif
- )
- : QAbstractGraphicsShapeItem(*new QGraphicsRectItemPrivate, parent, scene)
-{
- setRect(rect);
-}
-
-/*!
- \fn QGraphicsRectItem::QGraphicsRectItem(qreal x, qreal y, qreal width, qreal height,
- QGraphicsItem *parent)
-
- Constructs a QGraphicsRectItem with a default rectangle defined
- by (\a x, \a y) and the given \a width and \a height.
-
- \a parent is passed to QAbstractGraphicsShapeItem's constructor.
-
- \sa QGraphicsScene::addItem()
-*/
-QGraphicsRectItem::QGraphicsRectItem(qreal x, qreal y, qreal w, qreal h,
- QGraphicsItem *parent
-#ifndef Q_QDOC
- // obsolete argument
- , QGraphicsScene *scene
-#endif
- )
- : QAbstractGraphicsShapeItem(*new QGraphicsRectItemPrivate, parent, scene)
-{
- setRect(QRectF(x, y, w, h));
-}
-
-/*!
- Constructs a QGraphicsRectItem. \a parent is passed to
- QAbstractGraphicsShapeItem's constructor.
-
- \sa QGraphicsScene::addItem()
-*/
-QGraphicsRectItem::QGraphicsRectItem(QGraphicsItem *parent
-#ifndef Q_QDOC
- // obsolete argument
- , QGraphicsScene *scene
-#endif
- )
- : QAbstractGraphicsShapeItem(*new QGraphicsRectItemPrivate, parent, scene)
-{
-}
-
-/*!
- Destroys the QGraphicsRectItem.
-*/
-QGraphicsRectItem::~QGraphicsRectItem()
-{
-}
-
-/*!
- Returns the item's rectangle.
-
- \sa setRect()
-*/
-QRectF QGraphicsRectItem::rect() const
-{
- Q_D(const QGraphicsRectItem);
- return d->rect;
-}
-
-/*!
- \fn void QGraphicsRectItem::setRect(const QRectF &rectangle)
-
- Sets the item's rectangle to be the given \a rectangle.
-
- \sa rect()
-*/
-void QGraphicsRectItem::setRect(const QRectF &rect)
-{
- Q_D(QGraphicsRectItem);
- if (d->rect == rect)
- return;
- prepareGeometryChange();
- d->rect = rect;
- d->boundingRect = QRectF();
- update();
-}
-
-/*!
- \fn void QGraphicsRectItem::setRect(qreal x, qreal y, qreal width, qreal height)
- \fn void QGraphicsEllipseItem::setRect(qreal x, qreal y, qreal width, qreal height)
-
- Sets the item's rectangle to the rectangle defined by (\a x, \a y)
- and the given \a width and \a height.
-
- This convenience function is equivalent to calling \c
- {setRect(QRectF(x, y, width, height))}
-
- \sa rect()
-*/
-
-/*!
- \reimp
-*/
-QRectF QGraphicsRectItem::boundingRect() const
-{
- Q_D(const QGraphicsRectItem);
- if (d->boundingRect.isNull()) {
- qreal halfpw = pen().widthF() / 2;
- d->boundingRect = d->rect;
- if (halfpw > 0.0)
- d->boundingRect.adjust(-halfpw, -halfpw, halfpw, halfpw);
- }
- return d->boundingRect;
-}
-
-/*!
- \reimp
-*/
-QPainterPath QGraphicsRectItem::shape() const
-{
- Q_D(const QGraphicsRectItem);
- QPainterPath path;
- path.addRect(d->rect);
- return qt_graphicsItem_shapeFromPath(path, d->pen);
-}
-
-/*!
- \reimp
-*/
-bool QGraphicsRectItem::contains(const QPointF &point) const
-{
- return QAbstractGraphicsShapeItem::contains(point);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsRectItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
- QWidget *widget)
-{
- Q_D(QGraphicsRectItem);
- Q_UNUSED(widget);
- painter->setPen(d->pen);
- painter->setBrush(d->brush);
- painter->drawRect(d->rect);
-
- if (option->state & QStyle::State_Selected)
- qt_graphicsItem_highlightSelected(this, painter, option);
-}
-
-/*!
- \reimp
-*/
-bool QGraphicsRectItem::isObscuredBy(const QGraphicsItem *item) const
-{
- return QAbstractGraphicsShapeItem::isObscuredBy(item);
-}
-
-/*!
- \reimp
-*/
-QPainterPath QGraphicsRectItem::opaqueArea() const
-{
- return QAbstractGraphicsShapeItem::opaqueArea();
-}
-
-/*!
- \reimp
-*/
-int QGraphicsRectItem::type() const
-{
- return Type;
-}
-
-/*!
- \internal
-*/
-bool QGraphicsRectItem::supportsExtension(Extension extension) const
-{
- Q_UNUSED(extension);
- return false;
-}
-
-/*!
- \internal
-*/
-void QGraphicsRectItem::setExtension(Extension extension, const QVariant &variant)
-{
- Q_UNUSED(extension);
- Q_UNUSED(variant);
-}
-
-/*!
- \internal
-*/
-QVariant QGraphicsRectItem::extension(const QVariant &variant) const
-{
- Q_UNUSED(variant);
- return QVariant();
-}
-
-/*!
- \class QGraphicsEllipseItem
- \brief The QGraphicsEllipseItem class provides an ellipse item that you
- can add to a QGraphicsScene.
- \since 4.2
- \ingroup graphicsview-api
-
- QGraphicsEllipseItem respresents an ellipse with a fill and an outline,
- and you can also use it for ellipse segments (see startAngle(),
- spanAngle()).
-
- \table
- \row
- \o \inlineimage graphicsview-ellipseitem.png
- \o \inlineimage graphicsview-ellipseitem-pie.png
- \endtable
-
- To set the item's ellipse, pass a QRectF to QGraphicsEllipseItem's
- constructor, or call setRect(). The rect() function returns the
- current ellipse geometry.
-
- QGraphicsEllipseItem uses the rect and the pen width to provide a
- reasonable implementation of boundingRect(), shape(), and contains(). The
- paint() function draws the ellipse using the item's associated pen and
- brush, which you can set by calling setPen() and setBrush().
-
- \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsPolygonItem,
- QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics
- View Framework}
-*/
-
-class QGraphicsEllipseItemPrivate : public QAbstractGraphicsShapeItemPrivate
-{
- Q_DECLARE_PUBLIC(QGraphicsEllipseItem)
-public:
- inline QGraphicsEllipseItemPrivate()
- : startAngle(0), spanAngle(360 * 16)
- { }
-
- QRectF rect;
- int startAngle;
- int spanAngle;
-};
-
-/*!
- Constructs a QGraphicsEllipseItem using \a rect as the default rectangle.
- \a parent is passed to QAbstractGraphicsShapeItem's constructor.
-
- \sa QGraphicsScene::addItem()
-*/
-QGraphicsEllipseItem::QGraphicsEllipseItem(const QRectF &rect, QGraphicsItem *parent
-#ifndef Q_QDOC
- // obsolete argument
- , QGraphicsScene *scene
-#endif
- )
- : QAbstractGraphicsShapeItem(*new QGraphicsEllipseItemPrivate, parent, scene)
-{
- setRect(rect);
-}
-
-/*!
- \fn QGraphicsEllipseItem::QGraphicsEllipseItem(qreal x, qreal y, qreal width, qreal height, QGraphicsItem *parent)
- \since 4.3
-
- Constructs a QGraphicsEllipseItem using the rectangle defined by (\a x, \a
- y) and the given \a width and \a height, as the default rectangle. \a
- parent is passed to QAbstractGraphicsShapeItem's constructor.
-
- \sa QGraphicsScene::addItem()
-*/
-QGraphicsEllipseItem::QGraphicsEllipseItem(qreal x, qreal y, qreal w, qreal h,
- QGraphicsItem *parent
-#ifndef Q_QDOC
- // obsolete argument
- , QGraphicsScene *scene
-#endif
- )
- : QAbstractGraphicsShapeItem(*new QGraphicsEllipseItemPrivate, parent, scene)
-{
- setRect(x,y,w,h);
-}
-
-
-
-/*!
- Constructs a QGraphicsEllipseItem. \a parent is passed to
- QAbstractGraphicsShapeItem's constructor.
-
- \sa QGraphicsScene::addItem()
-*/
-QGraphicsEllipseItem::QGraphicsEllipseItem(QGraphicsItem *parent
-#ifndef Q_QDOC
- // obsolete argument
- , QGraphicsScene *scene
-#endif
- )
- : QAbstractGraphicsShapeItem(*new QGraphicsEllipseItemPrivate, parent, scene)
-{
-}
-
-/*!
- Destroys the QGraphicsEllipseItem.
-*/
-QGraphicsEllipseItem::~QGraphicsEllipseItem()
-{
-}
-
-/*!
- Returns the item's ellipse geometry as a QRectF.
-
- \sa setRect(), QPainter::drawEllipse()
-*/
-QRectF QGraphicsEllipseItem::rect() const
-{
- Q_D(const QGraphicsEllipseItem);
- return d->rect;
-}
-
-/*!
- Sets the item's ellipse geometry to \a rect. The rectangle's left edge
- defines the left edge of the ellipse, and the rectangle's top edge
- describes the top of the ellipse. The height and width of the rectangle
- describe the height and width of the ellipse.
-
- \sa rect(), QPainter::drawEllipse()
-*/
-void QGraphicsEllipseItem::setRect(const QRectF &rect)
-{
- Q_D(QGraphicsEllipseItem);
- if (d->rect == rect)
- return;
- prepareGeometryChange();
- d->rect = rect;
- d->boundingRect = QRectF();
- update();
-}
-
-/*!
- Returns the start angle for an ellipse segment in 16ths of a degree. This
- angle is used together with spanAngle() for representing an ellipse
- segment (a pie). By default, the start angle is 0.
-
- \sa setStartAngle(), spanAngle()
-*/
-int QGraphicsEllipseItem::startAngle() const
-{
- Q_D(const QGraphicsEllipseItem);
- return d->startAngle;
-}
-
-/*!
- Sets the start angle for an ellipse segment to \a angle, which is in 16ths
- of a degree. This angle is used together with spanAngle() for representing
- an ellipse segment (a pie). By default, the start angle is 0.
-
- \sa startAngle(), setSpanAngle(), QPainter::drawPie()
-*/
-void QGraphicsEllipseItem::setStartAngle(int angle)
-{
- Q_D(QGraphicsEllipseItem);
- if (angle != d->startAngle) {
- prepareGeometryChange();
- d->boundingRect = QRectF();
- d->startAngle = angle;
- update();
- }
-}
-
-/*!
- Returns the span angle of an ellipse segment in 16ths of a degree. This
- angle is used together with startAngle() for representing an ellipse
- segment (a pie). By default, this function returns 5760 (360 * 16, a full
- ellipse).
-
- \sa setSpanAngle(), startAngle()
-*/
-int QGraphicsEllipseItem::spanAngle() const
-{
- Q_D(const QGraphicsEllipseItem);
- return d->spanAngle;
-}
-
-/*!
- Sets the span angle for an ellipse segment to \a angle, which is in 16ths
- of a degree. This angle is used together with startAngle() to represent an
- ellipse segment (a pie). By default, the span angle is 5760 (360 * 16, a
- full ellipse).
-
- \sa spanAngle(), setStartAngle(), QPainter::drawPie()
-*/
-void QGraphicsEllipseItem::setSpanAngle(int angle)
-{
- Q_D(QGraphicsEllipseItem);
- if (angle != d->spanAngle) {
- prepareGeometryChange();
- d->boundingRect = QRectF();
- d->spanAngle = angle;
- update();
- }
-}
-
-/*!
- \reimp
-*/
-QRectF QGraphicsEllipseItem::boundingRect() const
-{
- Q_D(const QGraphicsEllipseItem);
- if (d->boundingRect.isNull()) {
- qreal pw = pen().widthF();
- if (pw == 0.0 && d->spanAngle == 360 * 16)
- d->boundingRect = d->rect;
- else
- d->boundingRect = shape().controlPointRect();
- }
- return d->boundingRect;
-}
-
-/*!
- \reimp
-*/
-QPainterPath QGraphicsEllipseItem::shape() const
-{
- Q_D(const QGraphicsEllipseItem);
- QPainterPath path;
- if (d->rect.isNull())
- return path;
- if (d->spanAngle != 360 * 16) {
- path.moveTo(d->rect.center());
- path.arcTo(d->rect, d->startAngle / 16.0, d->spanAngle / 16.0);
- } else {
- path.addEllipse(d->rect);
- }
-
- return qt_graphicsItem_shapeFromPath(path, d->pen);
-}
-
-/*!
- \reimp
-*/
-bool QGraphicsEllipseItem::contains(const QPointF &point) const
-{
- return QAbstractGraphicsShapeItem::contains(point);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsEllipseItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
- QWidget *widget)
-{
- Q_D(QGraphicsEllipseItem);
- Q_UNUSED(widget);
- painter->setPen(d->pen);
- painter->setBrush(d->brush);
- if ((d->spanAngle != 0) && (qAbs(d->spanAngle) % (360 * 16) == 0))
- painter->drawEllipse(d->rect);
- else
- painter->drawPie(d->rect, d->startAngle, d->spanAngle);
-
- if (option->state & QStyle::State_Selected)
- qt_graphicsItem_highlightSelected(this, painter, option);
-}
-
-/*!
- \reimp
-*/
-bool QGraphicsEllipseItem::isObscuredBy(const QGraphicsItem *item) const
-{
- return QAbstractGraphicsShapeItem::isObscuredBy(item);
-}
-
-/*!
- \reimp
-*/
-QPainterPath QGraphicsEllipseItem::opaqueArea() const
-{
- return QAbstractGraphicsShapeItem::opaqueArea();
-}
-
-/*!
- \reimp
-*/
-int QGraphicsEllipseItem::type() const
-{
- return Type;
-}
-
-
-/*!
- \internal
-*/
-bool QGraphicsEllipseItem::supportsExtension(Extension extension) const
-{
- Q_UNUSED(extension);
- return false;
-}
-
-/*!
- \internal
-*/
-void QGraphicsEllipseItem::setExtension(Extension extension, const QVariant &variant)
-{
- Q_UNUSED(extension);
- Q_UNUSED(variant);
-}
-
-/*!
- \internal
-*/
-QVariant QGraphicsEllipseItem::extension(const QVariant &variant) const
-{
- Q_UNUSED(variant);
- return QVariant();
-}
-
-/*!
- \class QGraphicsPolygonItem
- \brief The QGraphicsPolygonItem class provides a polygon item that you
- can add to a QGraphicsScene.
- \since 4.2
- \ingroup graphicsview-api
-
- To set the item's polygon, pass a QPolygonF to
- QGraphicsPolygonItem's constructor, or call the setPolygon()
- function. The polygon() function returns the current polygon.
-
- \image graphicsview-polygonitem.png
-
- QGraphicsPolygonItem uses the polygon and the pen width to provide
- a reasonable implementation of boundingRect(), shape(), and
- contains(). The paint() function draws the polygon using the
- item's associated pen and brush, which you can set by calling the
- setPen() and setBrush() functions.
-
- \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem,
- QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics
- View Framework}
-*/
-
-class QGraphicsPolygonItemPrivate : public QAbstractGraphicsShapeItemPrivate
-{
- Q_DECLARE_PUBLIC(QGraphicsPolygonItem)
-public:
- inline QGraphicsPolygonItemPrivate()
- : fillRule(Qt::OddEvenFill)
- { }
-
- QPolygonF polygon;
- Qt::FillRule fillRule;
-};
-
-/*!
- Constructs a QGraphicsPolygonItem with \a polygon as the default
- polygon. \a parent is passed to QAbstractGraphicsShapeItem's constructor.
-
- \sa QGraphicsScene::addItem()
-*/
-QGraphicsPolygonItem::QGraphicsPolygonItem(const QPolygonF &polygon,
- QGraphicsItem *parent
-#ifndef Q_QDOC
- // obsolete argument
- , QGraphicsScene *scene
-#endif
- )
- : QAbstractGraphicsShapeItem(*new QGraphicsPolygonItemPrivate, parent, scene)
-{
- setPolygon(polygon);
-}
-
-/*!
- Constructs a QGraphicsPolygonItem. \a parent is passed to
- QAbstractGraphicsShapeItem's constructor.
-
- \sa QGraphicsScene::addItem()
-*/
-QGraphicsPolygonItem::QGraphicsPolygonItem(QGraphicsItem *parent
-#ifndef Q_QDOC
- // obsolete argument
- , QGraphicsScene *scene
-#endif
- )
- : QAbstractGraphicsShapeItem(*new QGraphicsPolygonItemPrivate, parent, scene)
-{
-}
-
-/*!
- Destroys the QGraphicsPolygonItem.
-*/
-QGraphicsPolygonItem::~QGraphicsPolygonItem()
-{
-}
-
-/*!
- Returns the item's polygon, or an empty polygon if no polygon
- has been set.
-
- \sa setPolygon()
-*/
-QPolygonF QGraphicsPolygonItem::polygon() const
-{
- Q_D(const QGraphicsPolygonItem);
- return d->polygon;
-}
-
-/*!
- Sets the item's polygon to be the given \a polygon.
-
- \sa polygon()
-*/
-void QGraphicsPolygonItem::setPolygon(const QPolygonF &polygon)
-{
- Q_D(QGraphicsPolygonItem);
- if (d->polygon == polygon)
- return;
- prepareGeometryChange();
- d->polygon = polygon;
- d->boundingRect = QRectF();
- update();
-}
-
-/*!
- Returns the fill rule of the polygon. The default fill rule is
- Qt::OddEvenFill.
-
- \sa setFillRule(), QPainterPath::fillRule(), QPainter::drawPolygon()
-*/
-Qt::FillRule QGraphicsPolygonItem::fillRule() const
-{
- Q_D(const QGraphicsPolygonItem);
- return d->fillRule;
-}
-
-/*!
- Sets the fill rule of the polygon to \a rule. The default fill rule is
- Qt::OddEvenFill.
-
- \sa fillRule(), QPainterPath::fillRule(), QPainter::drawPolygon()
-*/
-void QGraphicsPolygonItem::setFillRule(Qt::FillRule rule)
-{
- Q_D(QGraphicsPolygonItem);
- if (rule != d->fillRule) {
- d->fillRule = rule;
- update();
- }
-}
-
-/*!
- \reimp
-*/
-QRectF QGraphicsPolygonItem::boundingRect() const
-{
- Q_D(const QGraphicsPolygonItem);
- if (d->boundingRect.isNull()) {
- qreal pw = pen().widthF();
- if (pw == 0.0)
- d->boundingRect = d->polygon.boundingRect();
- else
- d->boundingRect = shape().controlPointRect();
- }
- return d->boundingRect;
-}
-
-/*!
- \reimp
-*/
-QPainterPath QGraphicsPolygonItem::shape() const
-{
- Q_D(const QGraphicsPolygonItem);
- QPainterPath path;
- path.addPolygon(d->polygon);
- return qt_graphicsItem_shapeFromPath(path, d->pen);
-}
-
-/*!
- \reimp
-*/
-bool QGraphicsPolygonItem::contains(const QPointF &point) const
-{
- return QAbstractGraphicsShapeItem::contains(point);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsPolygonItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
-{
- Q_D(QGraphicsPolygonItem);
- Q_UNUSED(widget);
- painter->setPen(d->pen);
- painter->setBrush(d->brush);
- painter->drawPolygon(d->polygon, d->fillRule);
-
- if (option->state & QStyle::State_Selected)
- qt_graphicsItem_highlightSelected(this, painter, option);
-}
-
-/*!
- \reimp
-*/
-bool QGraphicsPolygonItem::isObscuredBy(const QGraphicsItem *item) const
-{
- return QAbstractGraphicsShapeItem::isObscuredBy(item);
-}
-
-/*!
- \reimp
-*/
-QPainterPath QGraphicsPolygonItem::opaqueArea() const
-{
- return QAbstractGraphicsShapeItem::opaqueArea();
-}
-
-/*!
- \reimp
-*/
-int QGraphicsPolygonItem::type() const
-{
- return Type;
-}
-
-/*!
- \internal
-*/
-bool QGraphicsPolygonItem::supportsExtension(Extension extension) const
-{
- Q_UNUSED(extension);
- return false;
-}
-
-/*!
- \internal
-*/
-void QGraphicsPolygonItem::setExtension(Extension extension, const QVariant &variant)
-{
- Q_UNUSED(extension);
- Q_UNUSED(variant);
-}
-
-/*!
- \internal
-*/
-QVariant QGraphicsPolygonItem::extension(const QVariant &variant) const
-{
- Q_UNUSED(variant);
- return QVariant();
-}
-
-/*!
- \class QGraphicsLineItem
- \brief The QGraphicsLineItem class provides a line item that you can add to a
- QGraphicsScene.
- \since 4.2
- \ingroup graphicsview-api
-
- To set the item's line, pass a QLineF to QGraphicsLineItem's
- constructor, or call the setLine() function. The line() function
- returns the current line. By default the line is black with a
- width of 0, but you can change this by calling setPen().
-
- \img graphicsview-lineitem.png
-
- QGraphicsLineItem uses the line and the pen width to provide a reasonable
- implementation of boundingRect(), shape(), and contains(). The paint()
- function draws the line using the item's associated pen.
-
- \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem,
- QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsPixmapItem,
- {Graphics View Framework}
-*/
-
-class QGraphicsLineItemPrivate : public QGraphicsItemPrivate
-{
- Q_DECLARE_PUBLIC(QGraphicsLineItem)
-public:
- QLineF line;
- QPen pen;
-};
-
-/*!
- Constructs a QGraphicsLineItem, using \a line as the default line. \a
- parent is passed to QGraphicsItem's constructor.
-
- \sa QGraphicsScene::addItem()
-*/
-QGraphicsLineItem::QGraphicsLineItem(const QLineF &line, QGraphicsItem *parent
-#ifndef Q_QDOC
- // obsolete argument
- , QGraphicsScene *scene
-#endif
- )
- : QGraphicsItem(*new QGraphicsLineItemPrivate, parent, scene)
-{
- setLine(line);
-}
-
-/*!
- Constructs a QGraphicsLineItem, using the line between (\a x1, \a y1) and
- (\a x2, \a y2) as the default line. \a parent is passed to
- QGraphicsItem's constructor.
-
- \sa QGraphicsScene::addItem()
-*/
-QGraphicsLineItem::QGraphicsLineItem(qreal x1, qreal y1, qreal x2, qreal y2, QGraphicsItem *parent
-#ifndef Q_QDOC
- // obsolete argument
- , QGraphicsScene *scene
-#endif
- )
- : QGraphicsItem(*new QGraphicsLineItemPrivate, parent, scene)
-{
- setLine(x1, y1, x2, y2);
-}
-
-
-
-/*!
- Constructs a QGraphicsLineItem. \a parent is passed to QGraphicsItem's
- constructor.
-
- \sa QGraphicsScene::addItem()
-*/
-QGraphicsLineItem::QGraphicsLineItem(QGraphicsItem *parent
-#ifndef Q_QDOC
- // obsolete argument
- , QGraphicsScene *scene
-#endif
- )
- : QGraphicsItem(*new QGraphicsLineItemPrivate, parent, scene)
-{
-}
-
-/*!
- Destroys the QGraphicsLineItem.
-*/
-QGraphicsLineItem::~QGraphicsLineItem()
-{
-}
-
-/*!
- Returns the item's pen, or a black solid 0-width pen if no pen has
- been set.
-
- \sa setPen()
-*/
-QPen QGraphicsLineItem::pen() const
-{
- Q_D(const QGraphicsLineItem);
- return d->pen;
-}
-
-/*!
- Sets the item's pen to \a pen. If no pen is set, the line will be painted
- using a black solid 0-width pen.
-
- \sa pen()
-*/
-void QGraphicsLineItem::setPen(const QPen &pen)
-{
- Q_D(QGraphicsLineItem);
- if (d->pen == pen)
- return;
- prepareGeometryChange();
- d->pen = pen;
- update();
-}
-
-/*!
- Returns the item's line, or a null line if no line has been set.
-
- \sa setLine()
-*/
-QLineF QGraphicsLineItem::line() const
-{
- Q_D(const QGraphicsLineItem);
- return d->line;
-}
-
-/*!
- Sets the item's line to be the given \a line.
-
- \sa line()
-*/
-void QGraphicsLineItem::setLine(const QLineF &line)
-{
- Q_D(QGraphicsLineItem);
- if (d->line == line)
- return;
- prepareGeometryChange();
- d->line = line;
- update();
-}
-
-/*!
- \fn void QGraphicsLineItem::setLine(qreal x1, qreal y1, qreal x2, qreal y2)
- \overload
-
- Sets the item's line to be the line between (\a x1, \a y1) and (\a
- x2, \a y2).
-
- This is the same as calling \c {setLine(QLineF(x1, y1, x2, y2))}.
-*/
-
-/*!
- \reimp
-*/
-QRectF QGraphicsLineItem::boundingRect() const
-{
- Q_D(const QGraphicsLineItem);
- if (d->pen.widthF() == 0.0) {
- const qreal x1 = d->line.p1().x();
- const qreal x2 = d->line.p2().x();
- const qreal y1 = d->line.p1().y();
- const qreal y2 = d->line.p2().y();
- qreal lx = qMin(x1, x2);
- qreal rx = qMax(x1, x2);
- qreal ty = qMin(y1, y2);
- qreal by = qMax(y1, y2);
- return QRectF(lx, ty, rx - lx, by - ty);
- }
- return shape().controlPointRect();
-}
-
-/*!
- \reimp
-*/
-QPainterPath QGraphicsLineItem::shape() const
-{
- Q_D(const QGraphicsLineItem);
- QPainterPath path;
- if (d->line == QLineF())
- return path;
-
- path.moveTo(d->line.p1());
- path.lineTo(d->line.p2());
- return qt_graphicsItem_shapeFromPath(path, d->pen);
-}
-
-/*!
- \reimp
-*/
-bool QGraphicsLineItem::contains(const QPointF &point) const
-{
- return QGraphicsItem::contains(point);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsLineItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
-{
- Q_D(QGraphicsLineItem);
- Q_UNUSED(widget);
- painter->setPen(d->pen);
- painter->drawLine(d->line);
-
- if (option->state & QStyle::State_Selected)
- qt_graphicsItem_highlightSelected(this, painter, option);
-}
-
-/*!
- \reimp
-*/
-bool QGraphicsLineItem::isObscuredBy(const QGraphicsItem *item) const
-{
- return QGraphicsItem::isObscuredBy(item);
-}
-
-/*!
- \reimp
-*/
-QPainterPath QGraphicsLineItem::opaqueArea() const
-{
- return QGraphicsItem::opaqueArea();
-}
-
-/*!
- \reimp
-*/
-int QGraphicsLineItem::type() const
-{
- return Type;
-}
-
-/*!
- \internal
-*/
-bool QGraphicsLineItem::supportsExtension(Extension extension) const
-{
- Q_UNUSED(extension);
- return false;
-}
-
-/*!
- \internal
-*/
-void QGraphicsLineItem::setExtension(Extension extension, const QVariant &variant)
-{
- Q_UNUSED(extension);
- Q_UNUSED(variant);
-}
-
-/*!
- \internal
-*/
-QVariant QGraphicsLineItem::extension(const QVariant &variant) const
-{
- Q_UNUSED(variant);
- return QVariant();
-}
-
-/*!
- \class QGraphicsPixmapItem
- \brief The QGraphicsPixmapItem class provides a pixmap item that you can add to
- a QGraphicsScene.
- \since 4.2
- \ingroup graphicsview-api
-
- To set the item's pixmap, pass a QPixmap to QGraphicsPixmapItem's
- constructor, or call the setPixmap() function. The pixmap()
- function returns the current pixmap.
-
- QGraphicsPixmapItem uses pixmap's optional alpha mask to provide a
- reasonable implementation of boundingRect(), shape(), and contains().
-
- \image graphicsview-pixmapitem.png
-
- The pixmap is drawn at the item's (0, 0) coordinate, as returned by
- offset(). You can change the drawing offset by calling setOffset().
-
- You can set the pixmap's transformation mode by calling
- setTransformationMode(). By default, Qt::FastTransformation is used, which
- provides fast, non-smooth scaling. Qt::SmoothTransformation enables
- QPainter::SmoothPixmapTransform on the painter, and the quality depends on
- the platform and viewport. The result is usually not as good as calling
- QPixmap::scale() directly. Call transformationMode() to get the current
- transformation mode for the item.
-
- \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem,
- QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsLineItem,
- {Graphics View Framework}
-*/
-
-/*!
- \enum QGraphicsPixmapItem::ShapeMode
-
- This enum describes how QGraphicsPixmapItem calculates its shape and
- opaque area.
-
- The default value is MaskShape.
-
- \value MaskShape The shape is determined by calling QPixmap::mask().
- This shape includes only the opaque pixels of the pixmap.
- Because the shape is more complex, however, it can be slower than the other modes,
- and uses more memory.
-
- \value BoundingRectShape The shape is determined by tracing the outline of
- the pixmap. This is the fastest shape mode, but it does not take into account
- any transparent areas on the pixmap.
-
- \value HeuristicMaskShape The shape is determine by calling
- QPixmap::createHeuristicMask(). The performance and memory consumption
- is similar to MaskShape.
-*/
-extern QPainterPath qt_regionToPath(const QRegion &region);
-
-class QGraphicsPixmapItemPrivate : public QGraphicsItemPrivate
-{
- Q_DECLARE_PUBLIC(QGraphicsPixmapItem)
-public:
- QGraphicsPixmapItemPrivate()
- : transformationMode(Qt::FastTransformation),
- shapeMode(QGraphicsPixmapItem::MaskShape),
- hasShape(false)
- {}
-
- QPixmap pixmap;
- Qt::TransformationMode transformationMode;
- QPointF offset;
- QGraphicsPixmapItem::ShapeMode shapeMode;
- QPainterPath shape;
- bool hasShape;
-
- void updateShape()
- {
- shape = QPainterPath();
- switch (shapeMode) {
- case QGraphicsPixmapItem::MaskShape: {
- QBitmap mask = pixmap.mask();
- if (!mask.isNull()) {
- shape = qt_regionToPath(QRegion(mask).translated(offset.toPoint()));
- break;
- }
- // FALL THROUGH
- }
- case QGraphicsPixmapItem::BoundingRectShape:
- shape.addRect(QRectF(offset.x(), offset.y(), pixmap.width(), pixmap.height()));
- break;
- case QGraphicsPixmapItem::HeuristicMaskShape:
-#ifndef QT_NO_IMAGE_HEURISTIC_MASK
- shape = qt_regionToPath(QRegion(pixmap.createHeuristicMask()).translated(offset.toPoint()));
-#else
- shape.addRect(QRectF(offset.x(), offset.y(), pixmap.width(), pixmap.height()));
-#endif
- break;
- }
- }
-};
-
-/*!
- Constructs a QGraphicsPixmapItem, using \a pixmap as the default pixmap.
- \a parent is passed to QGraphicsItem's constructor.
-
- \sa QGraphicsScene::addItem()
-*/
-QGraphicsPixmapItem::QGraphicsPixmapItem(const QPixmap &pixmap,
- QGraphicsItem *parent
-#ifndef Q_QDOC
- // obsolete argument
- , QGraphicsScene *scene
-#endif
- )
- : QGraphicsItem(*new QGraphicsPixmapItemPrivate, parent, scene)
-{
- setPixmap(pixmap);
-}
-
-/*!
- Constructs a QGraphicsPixmapItem. \a parent is passed to QGraphicsItem's
- constructor.
-
- \sa QGraphicsScene::addItem()
-*/
-QGraphicsPixmapItem::QGraphicsPixmapItem(QGraphicsItem *parent
-#ifndef Q_QDOC
- // obsolete argument
- , QGraphicsScene *scene
-#endif
- )
- : QGraphicsItem(*new QGraphicsPixmapItemPrivate, parent, scene)
-{
-}
-
-/*!
- Destroys the QGraphicsPixmapItem.
-*/
-QGraphicsPixmapItem::~QGraphicsPixmapItem()
-{
-}
-
-/*!
- Sets the item's pixmap to \a pixmap.
-
- \sa pixmap()
-*/
-void QGraphicsPixmapItem::setPixmap(const QPixmap &pixmap)
-{
- Q_D(QGraphicsPixmapItem);
- prepareGeometryChange();
- d->pixmap = pixmap;
- d->hasShape = false;
- update();
-}
-
-/*!
- Returns the item's pixmap, or an invalid QPixmap if no pixmap has been
- set.
-
- \sa setPixmap()
-*/
-QPixmap QGraphicsPixmapItem::pixmap() const
-{
- Q_D(const QGraphicsPixmapItem);
- return d->pixmap;
-}
-
-/*!
- Returns the transformation mode of the pixmap. The default mode is
- Qt::FastTransformation, which provides quick transformation with no
- smoothing.
-
- \sa setTransformationMode()
-*/
-Qt::TransformationMode QGraphicsPixmapItem::transformationMode() const
-{
- Q_D(const QGraphicsPixmapItem);
- return d->transformationMode;
-}
-
-/*!
- Sets the pixmap item's transformation mode to \a mode, and toggles an
- update of the item. The default mode is Qt::FastTransformation, which
- provides quick transformation with no smoothing.
-
- Qt::SmoothTransformation enables QPainter::SmoothPixmapTransform on the
- painter, and the quality depends on the platform and viewport. The result
- is usually not as good as calling QPixmap::scale() directly.
-
- \sa transformationMode()
-*/
-void QGraphicsPixmapItem::setTransformationMode(Qt::TransformationMode mode)
-{
- Q_D(QGraphicsPixmapItem);
- if (mode != d->transformationMode) {
- d->transformationMode = mode;
- update();
- }
-}
-
-/*!
- Returns the pixmap item's \e offset, which defines the point of the
- top-left corner of the pixmap, in local coordinates.
-
- \sa setOffset()
-*/
-QPointF QGraphicsPixmapItem::offset() const
-{
- Q_D(const QGraphicsPixmapItem);
- return d->offset;
-}
-
-/*!
- Sets the pixmap item's offset to \a offset. QGraphicsPixmapItem will draw
- its pixmap using \a offset for its top-left corner.
-
- \sa offset()
-*/
-void QGraphicsPixmapItem::setOffset(const QPointF &offset)
-{
- Q_D(QGraphicsPixmapItem);
- if (d->offset == offset)
- return;
- prepareGeometryChange();
- d->offset = offset;
- d->hasShape = false;
- update();
-}
-
-/*!
- \fn void QGraphicsPixmapItem::setOffset(qreal x, qreal y)
- \since 4.3
-
- This convenience function is equivalent to calling setOffset(QPointF(\a x, \a y)).
-*/
-
-/*!
- \reimp
-*/
-QRectF QGraphicsPixmapItem::boundingRect() const
-{
- Q_D(const QGraphicsPixmapItem);
- if (d->pixmap.isNull())
- return QRectF();
- if (d->flags & ItemIsSelectable) {
- qreal pw = 1.0;
- return QRectF(d->offset, d->pixmap.size()).adjusted(-pw/2, -pw/2, pw/2, pw/2);
- } else {
- return QRectF(d->offset, d->pixmap.size());
- }
-}
-
-/*!
- \reimp
-*/
-QPainterPath QGraphicsPixmapItem::shape() const
-{
- Q_D(const QGraphicsPixmapItem);
- if (!d->hasShape) {
- QGraphicsPixmapItemPrivate *thatD = const_cast<QGraphicsPixmapItemPrivate *>(d);
- thatD->updateShape();
- thatD->hasShape = true;
- }
- return d_func()->shape;
-}
-
-/*!
- \reimp
-*/
-bool QGraphicsPixmapItem::contains(const QPointF &point) const
-{
- return QGraphicsItem::contains(point);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsPixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
- QWidget *widget)
-{
- Q_D(QGraphicsPixmapItem);
- Q_UNUSED(widget);
-
- painter->setRenderHint(QPainter::SmoothPixmapTransform,
- (d->transformationMode == Qt::SmoothTransformation));
-
- painter->drawPixmap(d->offset, d->pixmap);
-
- if (option->state & QStyle::State_Selected)
- qt_graphicsItem_highlightSelected(this, painter, option);
-}
-
-/*!
- \reimp
-*/
-bool QGraphicsPixmapItem::isObscuredBy(const QGraphicsItem *item) const
-{
- return QGraphicsItem::isObscuredBy(item);
-}
-
-/*!
- \reimp
-*/
-QPainterPath QGraphicsPixmapItem::opaqueArea() const
-{
- return shape();
-}
-
-/*!
- \reimp
-*/
-int QGraphicsPixmapItem::type() const
-{
- return Type;
-}
-
-/*!
- Returns the item's shape mode. The shape mode describes how
- QGraphicsPixmapItem calculates its shape. The default mode is MaskShape.
-
- \sa setShapeMode(), ShapeMode
-*/
-QGraphicsPixmapItem::ShapeMode QGraphicsPixmapItem::shapeMode() const
-{
- return d_func()->shapeMode;
-}
-
-/*!
- Sets the item's shape mode to \a mode. The shape mode describes how
- QGraphicsPixmapItem calculates its shape. The default mode is MaskShape.
-
- \sa shapeMode(), ShapeMode
-*/
-void QGraphicsPixmapItem::setShapeMode(ShapeMode mode)
-{
- Q_D(QGraphicsPixmapItem);
- if (d->shapeMode == mode)
- return;
- d->shapeMode = mode;
- d->hasShape = false;
-}
-
-/*!
- \internal
-*/
-bool QGraphicsPixmapItem::supportsExtension(Extension extension) const
-{
- Q_UNUSED(extension);
- return false;
-}
-
-/*!
- \internal
-*/
-void QGraphicsPixmapItem::setExtension(Extension extension, const QVariant &variant)
-{
- Q_UNUSED(extension);
- Q_UNUSED(variant);
-}
-
-/*!
- \internal
-*/
-QVariant QGraphicsPixmapItem::extension(const QVariant &variant) const
-{
- Q_UNUSED(variant);
- return QVariant();
-}
-
-/*!
- \class QGraphicsTextItem
- \brief The QGraphicsTextItem class provides a text item that you can add to
- a QGraphicsScene to display formatted text.
- \since 4.2
- \ingroup graphicsview-api
-
- If you only need to show plain text in an item, consider using QGraphicsSimpleTextItem
- instead.
-
- To set the item's text, pass a QString to QGraphicsTextItem's
- constructor, or call setHtml()/setPlainText().
-
- QGraphicsTextItem uses the text's formatted size and the associated font
- to provide a reasonable implementation of boundingRect(), shape(),
- and contains(). You can set the font by calling setFont().
-
- It is possible to make the item editable by setting the Qt::TextEditorInteraction flag
- using setTextInteractionFlags().
-
- The item's preferred text width can be set using setTextWidth() and obtained
- using textWidth().
-
- \note In order to align HTML text in the center, the item's text width must be set.
-
- \img graphicsview-textitem.png
-
- \note QGraphicsTextItem accepts \l{QGraphicsItem::acceptHoverEvents()}{hover events}
- by default. You can change this with \l{QGraphicsItem::}{setAcceptHoverEvents()}.
-
- \sa QGraphicsSimpleTextItem, QGraphicsPathItem, QGraphicsRectItem,
- QGraphicsEllipseItem, QGraphicsPixmapItem, QGraphicsPolygonItem,
- QGraphicsLineItem, {Graphics View Framework}
-*/
-
-class QGraphicsTextItemPrivate
-{
-public:
- QGraphicsTextItemPrivate()
- : control(0), pageNumber(0), useDefaultImpl(false), tabChangesFocus(false), clickCausedFocus(0)
- { }
-
- mutable QTextControl *control;
- QTextControl *textControl() const;
-
- inline QPointF controlOffset() const
- { return QPointF(0., pageNumber * control->document()->pageSize().height()); }
- inline void sendControlEvent(QEvent *e)
- { if (control) control->processEvent(e, controlOffset()); }
-
- void _q_updateBoundingRect(const QSizeF &);
- void _q_update(QRectF);
- void _q_ensureVisible(QRectF);
- bool _q_mouseOnEdge(QGraphicsSceneMouseEvent *);
-
- QRectF boundingRect;
- int pageNumber;
- bool useDefaultImpl;
- bool tabChangesFocus;
-
- uint clickCausedFocus : 1;
-
- QGraphicsTextItem *qq;
-};
-
-
-/*!
- Constructs a QGraphicsTextItem, using \a text as the default plain
- text. \a parent is passed to QGraphicsItem's constructor.
-
- \sa QGraphicsScene::addItem()
-*/
-QGraphicsTextItem::QGraphicsTextItem(const QString &text, QGraphicsItem *parent
-#ifndef Q_QDOC
- // obsolete argument
- , QGraphicsScene *scene
-#endif
- )
- : QGraphicsObject(*new QGraphicsItemPrivate, parent, scene), dd(new QGraphicsTextItemPrivate)
-{
- dd->qq = this;
- if (!text.isEmpty())
- setPlainText(text);
- setAcceptDrops(true);
- setAcceptHoverEvents(true);
- setFlags(ItemUsesExtendedStyleOption);
-}
-
-/*!
- Constructs a QGraphicsTextItem. \a parent is passed to QGraphicsItem's
- constructor.
-
- \sa QGraphicsScene::addItem()
-*/
-QGraphicsTextItem::QGraphicsTextItem(QGraphicsItem *parent
-#ifndef Q_QDOC
- // obsolete argument
- , QGraphicsScene *scene
-#endif
- )
- : QGraphicsObject(*new QGraphicsItemPrivate, parent, scene), dd(new QGraphicsTextItemPrivate)
-{
- dd->qq = this;
- setAcceptDrops(true);
- setAcceptHoverEvents(true);
- setFlag(ItemUsesExtendedStyleOption);
-}
-
-/*!
- Destroys the QGraphicsTextItem.
-*/
-QGraphicsTextItem::~QGraphicsTextItem()
-{
- delete dd;
-}
-
-/*!
- Returns the item's text converted to HTML, or an empty QString if no text has been set.
-
- \sa setHtml()
-*/
-QString QGraphicsTextItem::toHtml() const
-{
-#ifndef QT_NO_TEXTHTMLPARSER
- if (dd->control)
- return dd->control->toHtml();
-#endif
- return QString();
-}
-
-/*!
- Sets the item's text to \a text, assuming that text is HTML formatted. If
- the item has keyboard input focus, this function will also call
- ensureVisible() to ensure that the text is visible in all viewports.
-
- \sa toHtml(), hasFocus(), QGraphicsSimpleTextItem
-*/
-void QGraphicsTextItem::setHtml(const QString &text)
-{
- dd->textControl()->setHtml(text);
-}
-
-/*!
- Returns the item's text converted to plain text, or an empty QString if no text has been set.
-
- \sa setPlainText()
-*/
-QString QGraphicsTextItem::toPlainText() const
-{
- if (dd->control)
- return dd->control->toPlainText();
- return QString();
-}
-
-/*!
- Sets the item's text to \a text. If the item has keyboard input focus,
- this function will also call ensureVisible() to ensure that the text is
- visible in all viewports.
-
- \sa toHtml(), hasFocus()
-*/
-void QGraphicsTextItem::setPlainText(const QString &text)
-{
- dd->textControl()->setPlainText(text);
-}
-
-/*!
- Returns the item's font, which is used to render the text.
-
- \sa setFont()
-*/
-QFont QGraphicsTextItem::font() const
-{
- if (!dd->control)
- return QFont();
- return dd->control->document()->defaultFont();
-}
-
-/*!
- Sets the font used to render the text item to \a font.
-
- \sa font()
-*/
-void QGraphicsTextItem::setFont(const QFont &font)
-{
- dd->textControl()->document()->setDefaultFont(font);
-}
-
-/*!
- Sets the color for unformatted text to \a col.
-*/
-void QGraphicsTextItem::setDefaultTextColor(const QColor &col)
-{
- QTextControl *c = dd->textControl();
- QPalette pal = c->palette();
- QColor old = pal.color(QPalette::Text);
- pal.setColor(QPalette::Text, col);
- c->setPalette(pal);
- if (old != col)
- update();
-}
-
-/*!
- Returns the default text color that is used to for unformatted text.
-*/
-QColor QGraphicsTextItem::defaultTextColor() const
-{
- return dd->textControl()->palette().color(QPalette::Text);
-}
-
-/*!
- \reimp
-*/
-QRectF QGraphicsTextItem::boundingRect() const
-{
- return dd->boundingRect;
-}
-
-/*!
- \reimp
-*/
-QPainterPath QGraphicsTextItem::shape() const
-{
- if (!dd->control)
- return QPainterPath();
- QPainterPath path;
- path.addRect(dd->boundingRect);
- return path;
-}
-
-/*!
- \reimp
-*/
-bool QGraphicsTextItem::contains(const QPointF &point) const
-{
- return dd->boundingRect.contains(point);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
- QWidget *widget)
-{
- Q_UNUSED(widget);
- if (dd->control) {
- painter->save();
- QRectF r = option->exposedRect;
- painter->translate(-dd->controlOffset());
- r.translate(dd->controlOffset());
-
- QTextDocument *doc = dd->control->document();
- QTextDocumentLayout *layout = qobject_cast<QTextDocumentLayout *>(doc->documentLayout());
-
- // the layout might need to expand the root frame to
- // the viewport if NoWrap is set
- if (layout)
- layout->setViewport(dd->boundingRect);
-
- dd->control->drawContents(painter, r);
-
- if (layout)
- layout->setViewport(QRect());
-
- painter->restore();
- }
-
- if (option->state & (QStyle::State_Selected | QStyle::State_HasFocus))
- qt_graphicsItem_highlightSelected(this, painter, option);
-}
-
-/*!
- \reimp
-*/
-bool QGraphicsTextItem::isObscuredBy(const QGraphicsItem *item) const
-{
- return QGraphicsItem::isObscuredBy(item);
-}
-
-/*!
- \reimp
-*/
-QPainterPath QGraphicsTextItem::opaqueArea() const
-{
- return QGraphicsItem::opaqueArea();
-}
-
-/*!
- \reimp
-*/
-int QGraphicsTextItem::type() const
-{
- return Type;
-}
-
-/*!
- Sets the preferred width for the item's text. If the actual text
- is wider than the specified width then it will be broken into
- multiple lines.
-
- If \a width is set to -1 then the text will not be broken into
- multiple lines unless it is enforced through an explicit line
- break or a new paragraph.
-
- The default value is -1.
-
- Note that QGraphicsTextItem keeps a QTextDocument internally,
- which is used to calculate the text width.
-
- \sa textWidth(), QTextDocument::setTextWidth()
-*/
-void QGraphicsTextItem::setTextWidth(qreal width)
-{
- dd->textControl()->setTextWidth(width);
-}
-
-/*!
- Returns the text width.
-
- The width is calculated with the QTextDocument that
- QGraphicsTextItem keeps internally.
-
- \sa setTextWidth(), QTextDocument::textWidth()
-*/
-qreal QGraphicsTextItem::textWidth() const
-{
- if (!dd->control)
- return -1;
- return dd->control->textWidth();
-}
-
-/*!
- Adjusts the text item to a reasonable size.
-*/
-void QGraphicsTextItem::adjustSize()
-{
- if (dd->control)
- dd->control->adjustSize();
-}
-
-/*!
- Sets the text document \a document on the item.
-*/
-void QGraphicsTextItem::setDocument(QTextDocument *document)
-{
- dd->textControl()->setDocument(document);
- dd->_q_updateBoundingRect(dd->control->size());
-}
-
-/*!
- Returns the item's text document.
-*/
-QTextDocument *QGraphicsTextItem::document() const
-{
- return dd->textControl()->document();
-}
-
-/*!
- \reimp
-*/
-bool QGraphicsTextItem::sceneEvent(QEvent *event)
-{
- QEvent::Type t = event->type();
- if (!dd->tabChangesFocus && (t == QEvent::KeyPress || t == QEvent::KeyRelease)) {
- int k = ((QKeyEvent *)event)->key();
- if (k == Qt::Key_Tab || k == Qt::Key_Backtab) {
- dd->sendControlEvent(event);
- return true;
- }
- }
- bool result = QGraphicsItem::sceneEvent(event);
-
- // Ensure input context is updated.
- switch (event->type()) {
- case QEvent::ContextMenu:
- case QEvent::FocusIn:
- case QEvent::FocusOut:
- case QEvent::GraphicsSceneDragEnter:
- case QEvent::GraphicsSceneDragLeave:
- case QEvent::GraphicsSceneDragMove:
- case QEvent::GraphicsSceneDrop:
- case QEvent::GraphicsSceneHoverEnter:
- case QEvent::GraphicsSceneHoverLeave:
- case QEvent::GraphicsSceneHoverMove:
- case QEvent::GraphicsSceneMouseDoubleClick:
- case QEvent::GraphicsSceneMousePress:
- case QEvent::GraphicsSceneMouseMove:
- case QEvent::GraphicsSceneMouseRelease:
- case QEvent::KeyPress:
- case QEvent::KeyRelease:
- // Reset the focus widget's input context, regardless
- // of how this item gained or lost focus.
- if (QWidget *fw = qApp->focusWidget()) {
-#ifndef QT_NO_IM
- if (QInputContext *qic = fw->inputContext()) {
- if (event->type() == QEvent::FocusIn || event->type() == QEvent::FocusOut)
- qic->reset();
- else
- qic->update();
- }
-#endif //QT_NO_IM
- }
- break;
- case QEvent::ShortcutOverride:
- dd->sendControlEvent(event);
- return true;
- default:
- break;
- }
-
- return result;
-}
-
-/*!
- \reimp
-*/
-void QGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
-{
- if ((QGraphicsItem::d_ptr->flags & (ItemIsSelectable | ItemIsMovable))
- && (event->buttons() & Qt::LeftButton) && dd->_q_mouseOnEdge(event)) {
- // User left-pressed on edge of selectable/movable item, use
- // base impl.
- dd->useDefaultImpl = true;
- } else if (event->buttons() == event->button()
- && dd->control->textInteractionFlags() == Qt::NoTextInteraction) {
- // User pressed first button on non-interactive item.
- dd->useDefaultImpl = true;
- }
- if (dd->useDefaultImpl) {
- QGraphicsItem::mousePressEvent(event);
- if (!event->isAccepted())
- dd->useDefaultImpl = false;
- return;
- }
-
- dd->sendControlEvent(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
-{
- if (dd->useDefaultImpl) {
- QGraphicsItem::mouseMoveEvent(event);
- return;
- }
-
- dd->sendControlEvent(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-{
- if (dd->useDefaultImpl) {
- QGraphicsItem::mouseReleaseEvent(event);
- if (dd->control->textInteractionFlags() == Qt::NoTextInteraction
- && !event->buttons()) {
- // User released last button on non-interactive item.
- dd->useDefaultImpl = false;
- } else if ((event->buttons() & Qt::LeftButton) == 0) {
- // User released the left button on an interactive item.
- dd->useDefaultImpl = false;
- }
- return;
- }
-
- QWidget *widget = event->widget();
- if (widget && (dd->control->textInteractionFlags() & Qt::TextEditable) && boundingRect().contains(event->pos())) {
- qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), dd->clickCausedFocus);
- }
- dd->clickCausedFocus = 0;
- dd->sendControlEvent(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
-{
- if (dd->useDefaultImpl) {
- QGraphicsItem::mouseDoubleClickEvent(event);
- return;
- }
-
- if (!hasFocus()) {
- QGraphicsItem::mouseDoubleClickEvent(event);
- return;
- }
-
- dd->sendControlEvent(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsTextItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
-{
- dd->sendControlEvent(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsTextItem::keyPressEvent(QKeyEvent *event)
-{
- dd->sendControlEvent(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsTextItem::keyReleaseEvent(QKeyEvent *event)
-{
- dd->sendControlEvent(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsTextItem::focusInEvent(QFocusEvent *event)
-{
- dd->sendControlEvent(event);
- if (event->reason() == Qt::MouseFocusReason) {
- dd->clickCausedFocus = 1;
- }
- update();
-}
-
-/*!
- \reimp
-*/
-void QGraphicsTextItem::focusOutEvent(QFocusEvent *event)
-{
- dd->sendControlEvent(event);
- update();
-}
-
-/*!
- \reimp
-*/
-void QGraphicsTextItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
-{
- dd->sendControlEvent(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsTextItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
-{
- dd->sendControlEvent(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsTextItem::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
-{
- dd->sendControlEvent(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsTextItem::dropEvent(QGraphicsSceneDragDropEvent *event)
-{
- dd->sendControlEvent(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsTextItem::inputMethodEvent(QInputMethodEvent *event)
-{
- dd->sendControlEvent(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
-{
- dd->sendControlEvent(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
-{
- dd->sendControlEvent(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
-{
- dd->sendControlEvent(event);
-}
-
-/*!
- \reimp
-*/
-QVariant QGraphicsTextItem::inputMethodQuery(Qt::InputMethodQuery query) const
-{
- QVariant v;
- if (dd->control)
- v = dd->control->inputMethodQuery(query);
- if (v.type() == QVariant::RectF)
- v = v.toRectF().translated(-dd->controlOffset());
- else if (v.type() == QVariant::PointF)
- v = v.toPointF() - dd->controlOffset();
- else if (v.type() == QVariant::Rect)
- v = v.toRect().translated(-dd->controlOffset().toPoint());
- else if (v.type() == QVariant::Point)
- v = v.toPoint() - dd->controlOffset().toPoint();
- return v;
-}
-
-/*!
- \internal
-*/
-bool QGraphicsTextItem::supportsExtension(Extension extension) const
-{
- Q_UNUSED(extension);
- return false;
-}
-
-/*!
- \internal
-*/
-void QGraphicsTextItem::setExtension(Extension extension, const QVariant &variant)
-{
- Q_UNUSED(extension);
- Q_UNUSED(variant);
-}
-
-/*!
- \internal
-*/
-QVariant QGraphicsTextItem::extension(const QVariant &variant) const
-{
- Q_UNUSED(variant);
- return QVariant();
-}
-
-/*!
- \internal
-*/
-void QGraphicsTextItemPrivate::_q_update(QRectF rect)
-{
- if (rect.isValid()) {
- rect.translate(-controlOffset());
- } else {
- rect = boundingRect;
- }
- if (rect.intersects(boundingRect))
- qq->update(rect);
-}
-
-/*!
- \internal
-*/
-void QGraphicsTextItemPrivate::_q_updateBoundingRect(const QSizeF &size)
-{
- if (!control) return; // can't happen
- const QSizeF pageSize = control->document()->pageSize();
- // paged items have a constant (page) size
- if (size == boundingRect.size() || pageSize.height() != -1)
- return;
- qq->prepareGeometryChange();
- boundingRect.setSize(size);
- qq->update();
-}
-
-/*!
- \internal
-*/
-void QGraphicsTextItemPrivate::_q_ensureVisible(QRectF rect)
-{
- if (qq->hasFocus()) {
- rect.translate(-controlOffset());
- qq->ensureVisible(rect, /*xmargin=*/0, /*ymargin=*/0);
- }
-}
-
-QTextControl *QGraphicsTextItemPrivate::textControl() const
-{
- if (!control) {
- QGraphicsTextItem *that = const_cast<QGraphicsTextItem *>(qq);
- control = new QTextControl(that);
- control->setTextInteractionFlags(Qt::NoTextInteraction);
-
- QObject::connect(control, SIGNAL(updateRequest(QRectF)),
- qq, SLOT(_q_update(QRectF)));
- QObject::connect(control, SIGNAL(documentSizeChanged(QSizeF)),
- qq, SLOT(_q_updateBoundingRect(QSizeF)));
- QObject::connect(control, SIGNAL(visibilityRequest(QRectF)),
- qq, SLOT(_q_ensureVisible(QRectF)));
- QObject::connect(control, SIGNAL(linkActivated(QString)),
- qq, SIGNAL(linkActivated(QString)));
- QObject::connect(control, SIGNAL(linkHovered(QString)),
- qq, SIGNAL(linkHovered(QString)));
-
- const QSizeF pgSize = control->document()->pageSize();
- if (pgSize.height() != -1) {
- qq->prepareGeometryChange();
- that->dd->boundingRect.setSize(pgSize);
- qq->update();
- } else {
- that->dd->_q_updateBoundingRect(control->size());
- }
- }
- return control;
-}
-
-/*!
- \internal
-*/
-bool QGraphicsTextItemPrivate::_q_mouseOnEdge(QGraphicsSceneMouseEvent *event)
-{
- QPainterPath path;
- path.addRect(qq->boundingRect());
-
- QPainterPath docPath;
- const QTextFrameFormat format = control->document()->rootFrame()->frameFormat();
- docPath.addRect(
- qq->boundingRect().adjusted(
- format.leftMargin(),
- format.topMargin(),
- -format.rightMargin(),
- -format.bottomMargin()));
-
- return path.subtracted(docPath).contains(event->pos());
-}
-
-/*!
- \fn QGraphicsTextItem::linkActivated(const QString &link)
-
- This signal is emitted when the user clicks on a link on a text item
- that enables Qt::LinksAccessibleByMouse or Qt::LinksAccessibleByKeyboard.
- \a link is the link that was clicked.
-
- \sa setTextInteractionFlags()
-*/
-
-/*!
- \fn QGraphicsTextItem::linkHovered(const QString &link)
-
- This signal is emitted when the user hovers over a link on a text item
- that enables Qt::LinksAccessibleByMouse. \a link is
- the link that was hovered over.
-
- \sa setTextInteractionFlags()
-*/
-
-/*!
- Sets the flags \a flags to specify how the text item should react to user
- input.
-
- The default for a QGraphicsTextItem is Qt::NoTextInteraction. This function
- also affects the ItemIsFocusable QGraphicsItem flag by setting it if \a flags
- is different from Qt::NoTextInteraction and clearing it otherwise.
-
- By default, the text is read-only. To transform the item into an editor,
- set the Qt::TextEditable flag.
-*/
-void QGraphicsTextItem::setTextInteractionFlags(Qt::TextInteractionFlags flags)
-{
- if (flags == Qt::NoTextInteraction)
- setFlags(this->flags() & ~(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod));
- else
- setFlags(this->flags() | QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod);
-
- dd->textControl()->setTextInteractionFlags(flags);
-}
-
-/*!
- Returns the current text interaction flags.
-
- \sa setTextInteractionFlags()
-*/
-Qt::TextInteractionFlags QGraphicsTextItem::textInteractionFlags() const
-{
- if (!dd->control)
- return Qt::NoTextInteraction;
- return dd->control->textInteractionFlags();
-}
-
-/*!
- \since 4.5
-
- If \a b is true, the \gui Tab key will cause the widget to change focus;
- otherwise, the tab key will insert a tab into the document.
-
- In some occasions text edits should not allow the user to input tabulators
- or change indentation using the \gui Tab key, as this breaks the focus
- chain. The default is false.
-
- \sa tabChangesFocus(), ItemIsFocusable, textInteractionFlags()
-*/
-void QGraphicsTextItem::setTabChangesFocus(bool b)
-{
- dd->tabChangesFocus = b;
-}
-
-/*!
- \since 4.5
-
- Returns true if the \gui Tab key will cause the widget to change focus;
- otherwise, false is returned.
-
- By default, this behavior is disabled, and this function will return false.
-
- \sa setTabChangesFocus()
-*/
-bool QGraphicsTextItem::tabChangesFocus() const
-{
- return dd->tabChangesFocus;
-}
-
-/*!
- \property QGraphicsTextItem::openExternalLinks
-
- Specifies whether QGraphicsTextItem should automatically open links using
- QDesktopServices::openUrl() instead of emitting the
- linkActivated signal.
-
- The default value is false.
-*/
-void QGraphicsTextItem::setOpenExternalLinks(bool open)
-{
- dd->textControl()->setOpenExternalLinks(open);
-}
-
-bool QGraphicsTextItem::openExternalLinks() const
-{
- if (!dd->control)
- return false;
- return dd->control->openExternalLinks();
-}
-
-/*!
- \property QGraphicsTextItem::textCursor
-
- This property represents the visible text cursor in an editable
- text item.
-
- By default, if the item's text has not been set, this property
- contains a null text cursor; otherwise it contains a text cursor
- placed at the start of the item's document.
-*/
-void QGraphicsTextItem::setTextCursor(const QTextCursor &cursor)
-{
- dd->textControl()->setTextCursor(cursor);
-}
-
-QTextCursor QGraphicsTextItem::textCursor() const
-{
- if (!dd->control)
- return QTextCursor();
- return dd->control->textCursor();
-}
-
-class QGraphicsSimpleTextItemPrivate : public QAbstractGraphicsShapeItemPrivate
-{
- Q_DECLARE_PUBLIC(QGraphicsSimpleTextItem)
-public:
- inline QGraphicsSimpleTextItemPrivate() {
- pen.setStyle(Qt::NoPen);
- brush.setStyle(Qt::SolidPattern);
- }
- QString text;
- QFont font;
- QRectF boundingRect;
-
- void updateBoundingRect();
-};
-
-static QRectF setupTextLayout(QTextLayout *layout)
-{
- layout->setCacheEnabled(true);
- layout->beginLayout();
- while (layout->createLine().isValid())
- ;
- layout->endLayout();
- qreal maxWidth = 0;
- qreal y = 0;
- for (int i = 0; i < layout->lineCount(); ++i) {
- QTextLine line = layout->lineAt(i);
- maxWidth = qMax(maxWidth, line.naturalTextWidth());
- line.setPosition(QPointF(0, y));
- y += line.height();
- }
- return QRectF(0, 0, maxWidth, y);
-}
-
-void QGraphicsSimpleTextItemPrivate::updateBoundingRect()
-{
- Q_Q(QGraphicsSimpleTextItem);
- QRectF br;
- if (text.isEmpty()) {
- br = QRectF();
- } else {
- QString tmp = text;
- tmp.replace(QLatin1Char('\n'), QChar::LineSeparator);
- QStackTextEngine engine(tmp, font);
- QTextLayout layout(&engine);
- br = setupTextLayout(&layout);
- }
- if (br != boundingRect) {
- q->prepareGeometryChange();
- boundingRect = br;
- q->update();
- }
-}
-
-/*!
- \class QGraphicsSimpleTextItem
- \brief The QGraphicsSimpleTextItem class provides a simple text path item
- that you can add to a QGraphicsScene.
- \since 4.2
- \ingroup graphicsview-api
-
- To set the item's text, you can either pass a QString to
- QGraphicsSimpleTextItem's constructor, or call setText() to change the
- text later. To set the text fill color, call setBrush().
-
- The simple text item can have both a fill and an outline; setBrush() will
- set the text fill (i.e., text color), and setPen() sets the pen that will
- be used to draw the text outline. (The latter can be slow, especially for
- complex pens, and items with long text content.) If all you want is to
- draw a simple line of text, you should call setBrush() only, and leave the
- pen unset; QGraphicsSimpleTextItem's pen is by default Qt::NoPen.
-
- QGraphicsSimpleTextItem uses the text's formatted size and the associated
- font to provide a reasonable implementation of boundingRect(), shape(),
- and contains(). You can set the font by calling setFont().
-
- QGraphicsSimpleText does not display rich text; instead, you can use
- QGraphicsTextItem, which provides full text control capabilities.
-
- \img graphicsview-simpletextitem.png
-
- \sa QGraphicsTextItem, QGraphicsPathItem, QGraphicsRectItem,
- QGraphicsEllipseItem, QGraphicsPixmapItem, QGraphicsPolygonItem,
- QGraphicsLineItem, {Graphics View Framework}
-*/
-
-/*!
- Constructs a QGraphicsSimpleTextItem.
-
- \a parent is passed to QGraphicsItem's constructor.
-
- \sa QGraphicsScene::addItem()
-*/
-QGraphicsSimpleTextItem::QGraphicsSimpleTextItem(QGraphicsItem *parent
-#ifndef Q_QDOC
- // obsolete argument
- , QGraphicsScene *scene
-#endif
- )
- : QAbstractGraphicsShapeItem(*new QGraphicsSimpleTextItemPrivate, parent, scene)
-{
-}
-
-/*!
- Constructs a QGraphicsSimpleTextItem, using \a text as the default plain text.
-
- \a parent is passed to QGraphicsItem's constructor.
-
- \sa QGraphicsScene::addItem()
-*/
-QGraphicsSimpleTextItem::QGraphicsSimpleTextItem(const QString &text, QGraphicsItem *parent
-#ifndef Q_QDOC
- // obsolete argument
- , QGraphicsScene *scene
-#endif
- )
- : QAbstractGraphicsShapeItem(*new QGraphicsSimpleTextItemPrivate, parent, scene)
-{
- setText(text);
-}
-
-/*!
- Destroys the QGraphicsSimpleTextItem.
-*/
-QGraphicsSimpleTextItem::~QGraphicsSimpleTextItem()
-{
-}
-
-/*!
- Sets the item's text to \a text. The text will be displayed as
- plain text. Newline characters ('\n') as well as characters of
- type QChar::LineSeparator will cause item to break the text into
- multiple lines.
-*/
-void QGraphicsSimpleTextItem::setText(const QString &text)
-{
- Q_D(QGraphicsSimpleTextItem);
- if (d->text == text)
- return;
- d->text = text;
- d->updateBoundingRect();
- update();
-}
-
-/*!
- Returns the item's text.
-*/
-QString QGraphicsSimpleTextItem::text() const
-{
- Q_D(const QGraphicsSimpleTextItem);
- return d->text;
-}
-
-/*!
- Sets the font that is used to draw the item's text to \a font.
-*/
-void QGraphicsSimpleTextItem::setFont(const QFont &font)
-{
- Q_D(QGraphicsSimpleTextItem);
- d->font = font;
- d->updateBoundingRect();
-}
-
-/*!
- Returns the font that is used to draw the item's text.
-*/
-QFont QGraphicsSimpleTextItem::font() const
-{
- Q_D(const QGraphicsSimpleTextItem);
- return d->font;
-}
-
-/*!
- \reimp
-*/
-QRectF QGraphicsSimpleTextItem::boundingRect() const
-{
- Q_D(const QGraphicsSimpleTextItem);
- return d->boundingRect;
-}
-
-/*!
- \reimp
-*/
-QPainterPath QGraphicsSimpleTextItem::shape() const
-{
- Q_D(const QGraphicsSimpleTextItem);
- QPainterPath path;
- path.addRect(d->boundingRect);
- return path;
-}
-
-/*!
- \reimp
-*/
-bool QGraphicsSimpleTextItem::contains(const QPointF &point) const
-{
- Q_D(const QGraphicsSimpleTextItem);
- return d->boundingRect.contains(point);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
-{
- Q_UNUSED(widget);
- Q_D(QGraphicsSimpleTextItem);
-
- painter->setFont(d->font);
-
- QString tmp = d->text;
- tmp.replace(QLatin1Char('\n'), QChar::LineSeparator);
- QStackTextEngine engine(tmp, d->font);
- QTextLayout layout(&engine);
- setupTextLayout(&layout);
-
- QPen p;
- p.setBrush(d->brush);
- painter->setPen(p);
- if (d->pen.style() == Qt::NoPen && d->brush.style() == Qt::SolidPattern) {
- painter->setBrush(Qt::NoBrush);
- } else {
- QTextLayout::FormatRange range;
- range.start = 0;
- range.length = layout.text().length();
- range.format.setTextOutline(d->pen);
- QList<QTextLayout::FormatRange> formats;
- formats.append(range);
- layout.setAdditionalFormats(formats);
- }
-
- layout.draw(painter, QPointF(0, 0));
-
- if (option->state & (QStyle::State_Selected | QStyle::State_HasFocus))
- qt_graphicsItem_highlightSelected(this, painter, option);
-}
-
-/*!
- \reimp
-*/
-bool QGraphicsSimpleTextItem::isObscuredBy(const QGraphicsItem *item) const
-{
- return QAbstractGraphicsShapeItem::isObscuredBy(item);
-}
-
-/*!
- \reimp
-*/
-QPainterPath QGraphicsSimpleTextItem::opaqueArea() const
-{
- return QAbstractGraphicsShapeItem::opaqueArea();
-}
-
-/*!
- \reimp
-*/
-int QGraphicsSimpleTextItem::type() const
-{
- return Type;
-}
-
-/*!
- \internal
-*/
-bool QGraphicsSimpleTextItem::supportsExtension(Extension extension) const
-{
- Q_UNUSED(extension);
- return false;
-}
-
-/*!
- \internal
-*/
-void QGraphicsSimpleTextItem::setExtension(Extension extension, const QVariant &variant)
-{
- Q_UNUSED(extension);
- Q_UNUSED(variant);
-}
-
-/*!
- \internal
-*/
-QVariant QGraphicsSimpleTextItem::extension(const QVariant &variant) const
-{
- Q_UNUSED(variant);
- return QVariant();
-}
-
-/*!
- \class QGraphicsItemGroup
- \brief The QGraphicsItemGroup class provides a container that treats
- a group of items as a single item.
- \since 4.2
- \ingroup graphicsview-api
-
- A QGraphicsItemGroup is a special type of compound item that
- treats itself and all its children as one item (i.e., all events
- and geometries for all children are merged together). It's common
- to use item groups in presentation tools, when the user wants to
- group several smaller items into one big item in order to simplify
- moving and copying of items.
-
- If all you want is to store items inside other items, you can use
- any QGraphicsItem directly by passing a suitable parent to
- setParentItem().
-
- The boundingRect() function of QGraphicsItemGroup returns the
- bounding rectangle of all items in the item group.
- QGraphicsItemGroup ignores the ItemIgnoresTransformations flag on
- its children (i.e., with respect to the geometry of the group
- item, the children are treated as if they were transformable).
-
- There are two ways to construct an item group. The easiest and
- most common approach is to pass a list of items (e.g., all
- selected items) to QGraphicsScene::createItemGroup(), which
- returns a new QGraphicsItemGroup item. The other approach is to
- manually construct a QGraphicsItemGroup item, add it to the scene
- calling QGraphicsScene::addItem(), and then add items to the group
- manually, one at a time by calling addToGroup(). To dismantle
- ("ungroup") an item group, you can either call
- QGraphicsScene::destroyItemGroup(), or you can manually remove all
- items from the group by calling removeFromGroup().
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 17
-
- The operation of adding and removing items preserves the items'
- scene-relative position and transformation, as opposed to calling
- setParentItem(), where only the child item's parent-relative
- position and transformation are kept.
-
- The addtoGroup() function reparents the target item to this item
- group, keeping the item's position and transformation intact
- relative to the scene. Visually, this means that items added via
- addToGroup() will remain completely unchanged as a result of this
- operation, regardless of the item or the group's current position
- or transformation; although the item's position and matrix are
- likely to change.
-
- The removeFromGroup() function has similar semantics to
- setParentItem(); it reparents the item to the parent item of the
- item group. As with addToGroup(), the item's scene-relative
- position and transformation remain intact.
-
- \sa QGraphicsItem, {Graphics View Framework}
-*/
-
-class QGraphicsItemGroupPrivate : public QGraphicsItemPrivate
-{
-public:
- QRectF itemsBoundingRect;
-};
-
-/*!
- Constructs a QGraphicsItemGroup. \a parent is passed to QGraphicsItem's
- constructor.
-
- \sa QGraphicsScene::addItem()
-*/
-QGraphicsItemGroup::QGraphicsItemGroup(QGraphicsItem *parent
-#ifndef Q_QDOC
- // obsolete argument
- , QGraphicsScene *scene
-#endif
- )
- : QGraphicsItem(*new QGraphicsItemGroupPrivate, parent, scene)
-{
- setHandlesChildEvents(true);
-}
-
-/*!
- Destroys the QGraphicsItemGroup.
-*/
-QGraphicsItemGroup::~QGraphicsItemGroup()
-{
-}
-
-/*!
- Adds the given \a item to this item group. The item will be
- reparented to this group, but its position and transformation
- relative to the scene will stay intact.
-
- \sa removeFromGroup(), QGraphicsScene::createItemGroup()
-*/
-void QGraphicsItemGroup::addToGroup(QGraphicsItem *item)
-{
- Q_D(QGraphicsItemGroup);
- if (!item) {
- qWarning("QGraphicsItemGroup::addToGroup: cannot add null item");
- return;
- }
- if (item == this) {
- qWarning("QGraphicsItemGroup::addToGroup: cannot add a group to itself");
- return;
- }
-
- // COMBINE
- bool ok;
- QTransform itemTransform = item->itemTransform(this, &ok);
-
- if (!ok) {
- qWarning("QGraphicsItemGroup::addToGroup: could not find a valid transformation from item to group coordinates");
- return;
- }
-
- QTransform newItemTransform(itemTransform);
- item->setPos(mapFromItem(item, 0, 0));
- item->setParentItem(this);
-
- // removing position from translation component of the new transform
- if (!item->pos().isNull())
- newItemTransform *= QTransform::fromTranslate(-item->x(), -item->y());
-
- // removing additional transformations properties applied with itemTransform()
- QPointF origin = item->transformOriginPoint();
- QMatrix4x4 m;
- QList<QGraphicsTransform*> transformList = item->transformations();
- for (int i = 0; i < transformList.size(); ++i)
- transformList.at(i)->applyTo(&m);
- newItemTransform *= m.toTransform().inverted();
- newItemTransform.translate(origin.x(), origin.y());
- newItemTransform.rotate(-item->rotation());
- newItemTransform.scale(1/item->scale(), 1/item->scale());
- newItemTransform.translate(-origin.x(), -origin.y());
-
- // ### Expensive, we could maybe use dirtySceneTransform bit for optimization
-
- item->setTransform(newItemTransform);
- item->d_func()->setIsMemberOfGroup(true);
- prepareGeometryChange();
- d->itemsBoundingRect |= itemTransform.mapRect(item->boundingRect() | item->childrenBoundingRect());
- update();
-}
-
-/*!
- Removes the specified \a item from this group. The item will be
- reparented to this group's parent item, or to 0 if this group has
- no parent. Its position and transformation relative to the scene
- will stay intact.
-
- \sa addToGroup(), QGraphicsScene::destroyItemGroup()
-*/
-void QGraphicsItemGroup::removeFromGroup(QGraphicsItem *item)
-{
- Q_D(QGraphicsItemGroup);
- if (!item) {
- qWarning("QGraphicsItemGroup::removeFromGroup: cannot remove null item");
- return;
- }
-
- QGraphicsItem *newParent = d_ptr->parent;
-
- // COMBINE
- bool ok;
- QTransform itemTransform;
- if (newParent)
- itemTransform = item->itemTransform(newParent, &ok);
- else
- itemTransform = item->sceneTransform();
-
- QPointF oldPos = item->mapToItem(newParent, 0, 0);
- item->setParentItem(newParent);
- item->setPos(oldPos);
-
- // removing position from translation component of the new transform
- if (!item->pos().isNull())
- itemTransform *= QTransform::fromTranslate(-item->x(), -item->y());
-
- // removing additional transformations properties applied
- // with itemTransform() or sceneTransform()
- QPointF origin = item->transformOriginPoint();
- QMatrix4x4 m;
- QList<QGraphicsTransform*> transformList = item->transformations();
- for (int i = 0; i < transformList.size(); ++i)
- transformList.at(i)->applyTo(&m);
- itemTransform *= m.toTransform().inverted();
- itemTransform.translate(origin.x(), origin.y());
- itemTransform.rotate(-item->rotation());
- itemTransform.scale(1 / item->scale(), 1 / item->scale());
- itemTransform.translate(-origin.x(), -origin.y());
-
- // ### Expensive, we could maybe use dirtySceneTransform bit for optimization
-
- item->setTransform(itemTransform);
- item->d_func()->setIsMemberOfGroup(item->group() != 0);
-
- // ### Quite expensive. But removeFromGroup() isn't called very often.
- prepareGeometryChange();
- d->itemsBoundingRect = childrenBoundingRect();
-}
-
-/*!
- \reimp
-
- Returns the bounding rect of this group item, and all its children.
-*/
-QRectF QGraphicsItemGroup::boundingRect() const
-{
- Q_D(const QGraphicsItemGroup);
- return d->itemsBoundingRect;
-}
-
-/*!
- \reimp
-*/
-void QGraphicsItemGroup::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
- QWidget *widget)
-{
- Q_UNUSED(widget);
- if (option->state & QStyle::State_Selected) {
- Q_D(QGraphicsItemGroup);
- painter->setBrush(Qt::NoBrush);
- painter->drawRect(d->itemsBoundingRect);
- }
-}
-
-/*!
- \reimp
-*/
-bool QGraphicsItemGroup::isObscuredBy(const QGraphicsItem *item) const
-{
- return QGraphicsItem::isObscuredBy(item);
-}
-
-/*!
- \reimp
-*/
-QPainterPath QGraphicsItemGroup::opaqueArea() const
-{
- return QGraphicsItem::opaqueArea();
-}
-
-/*!
- \reimp
-*/
-int QGraphicsItemGroup::type() const
-{
- return Type;
-}
-
-#ifndef QT_NO_GRAPHICSEFFECT
-QRectF QGraphicsItemEffectSourcePrivate::boundingRect(Qt::CoordinateSystem system) const
-{
- const bool deviceCoordinates = (system == Qt::DeviceCoordinates);
- if (!info && deviceCoordinates) {
- // Device coordinates without info not yet supported.
- qWarning("QGraphicsEffectSource::boundingRect: Not yet implemented, lacking device context");
- return QRectF();
- }
-
- QRectF rect = item->boundingRect();
- if (!item->d_ptr->children.isEmpty())
- rect |= item->childrenBoundingRect();
-
- if (deviceCoordinates) {
- Q_ASSERT(info->painter);
- rect = info->painter->worldTransform().mapRect(rect);
- }
-
- return rect;
-}
-
-void QGraphicsItemEffectSourcePrivate::draw(QPainter *painter)
-{
- if (!info) {
- qWarning("QGraphicsEffectSource::draw: Can only begin as a result of QGraphicsEffect::draw");
- return;
- }
-
- Q_ASSERT(item->d_ptr->scene);
- QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func();
- if (painter == info->painter) {
- scened->draw(item, painter, info->viewTransform, info->transformPtr, info->exposedRegion,
- info->widget, info->opacity, info->effectTransform, info->wasDirtySceneTransform,
- info->drawItem);
- } else {
- QTransform effectTransform = info->painter->worldTransform().inverted();
- effectTransform *= painter->worldTransform();
- scened->draw(item, painter, info->viewTransform, info->transformPtr, info->exposedRegion,
- info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform,
- info->drawItem);
- }
-}
-
-// sourceRect must be in the given coordinate system
-QRect QGraphicsItemEffectSourcePrivate::paddedEffectRect(Qt::CoordinateSystem system, QGraphicsEffect::PixmapPadMode mode, const QRectF &sourceRect, bool *unpadded) const
-{
- QRectF effectRectF;
-
- if (unpadded)
- *unpadded = false;
-
- if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) {
- if (info) {
- QRectF deviceRect = system == Qt::DeviceCoordinates ? sourceRect : info->painter->worldTransform().mapRect(sourceRect);
- effectRectF = item->graphicsEffect()->boundingRectFor(deviceRect);
- if (unpadded)
- *unpadded = (effectRectF.size() == sourceRect.size());
- if (info && system == Qt::LogicalCoordinates)
- effectRectF = info->painter->worldTransform().inverted().mapRect(effectRectF);
- } else {
- // no choice but to send a logical coordinate bounding rect to boundingRectFor
- effectRectF = item->graphicsEffect()->boundingRectFor(sourceRect);
- }
- } else if (mode == QGraphicsEffect::PadToTransparentBorder) {
- // adjust by 1.5 to account for cosmetic pens
- effectRectF = sourceRect.adjusted(-1.5, -1.5, 1.5, 1.5);
- } else {
- effectRectF = sourceRect;
- if (unpadded)
- *unpadded = true;
- }
-
- return effectRectF.toAlignedRect();
-}
-
-QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset,
- QGraphicsEffect::PixmapPadMode mode) const
-{
- const bool deviceCoordinates = (system == Qt::DeviceCoordinates);
- if (!info && deviceCoordinates) {
- // Device coordinates without info not yet supported.
- qWarning("QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context");
- return QPixmap();
- }
- if (!item->d_ptr->scene)
- return QPixmap();
- QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func();
-
- bool unpadded;
- const QRectF sourceRect = boundingRect(system);
- QRect effectRect = paddedEffectRect(system, mode, sourceRect, &unpadded);
-
- if (offset)
- *offset = effectRect.topLeft();
-
- bool untransformed = !deviceCoordinates
- || info->painter->worldTransform().type() <= QTransform::TxTranslate;
- if (untransformed && unpadded && isPixmap()) {
- if (offset)
- *offset = boundingRect(system).topLeft().toPoint();
- return static_cast<QGraphicsPixmapItem *>(item)->pixmap();
- }
-
- if (effectRect.isEmpty())
- return QPixmap();
-
- QPixmap pixmap(effectRect.size());
- pixmap.fill(Qt::transparent);
- QPainter pixmapPainter(&pixmap);
- pixmapPainter.setRenderHints(info ? info->painter->renderHints() : QPainter::TextAntialiasing);
-
- QTransform effectTransform = QTransform::fromTranslate(-effectRect.x(), -effectRect.y());
- if (deviceCoordinates && info->effectTransform)
- effectTransform *= *info->effectTransform;
-
- if (!info) {
- // Logical coordinates without info.
- QTransform sceneTransform = item->sceneTransform();
- QTransform newEffectTransform = sceneTransform.inverted();
- newEffectTransform *= effectTransform;
- scened->draw(item, &pixmapPainter, 0, &sceneTransform, 0, 0, qreal(1.0),
- &newEffectTransform, false, true);
- } else if (deviceCoordinates) {
- // Device coordinates with info.
- scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, 0,
- info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform,
- info->drawItem);
- } else {
- // Item coordinates with info.
- QTransform newEffectTransform = info->transformPtr->inverted();
- newEffectTransform *= effectTransform;
- scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, 0,
- info->widget, info->opacity, &newEffectTransform, info->wasDirtySceneTransform,
- info->drawItem);
- }
-
- pixmapPainter.end();
-
- return pixmap;
-}
-#endif //QT_NO_GRAPHICSEFFECT
-
-#ifndef QT_NO_DEBUG_STREAM
-QDebug operator<<(QDebug debug, QGraphicsItem *item)
-{
- if (!item) {
- debug << "QGraphicsItem(0)";
- return debug;
- }
-
- if (QGraphicsObject *o = item->toGraphicsObject())
- debug << o->metaObject()->className();
- else
- debug << "QGraphicsItem";
- debug << "(this =" << (void*)item
- << ", parent =" << (void*)item->parentItem()
- << ", pos =" << item->pos()
- << ", z =" << item->zValue() << ", flags = "
- << item->flags() << ")";
- return debug;
-}
-
-QDebug operator<<(QDebug debug, QGraphicsObject *item)
-{
- if (!item) {
- debug << "QGraphicsObject(0)";
- return debug;
- }
-
- debug.nospace() << item->metaObject()->className() << '(' << (void*)item;
- if (!item->objectName().isEmpty())
- debug << ", name = " << item->objectName();
- debug.nospace() << ", parent = " << ((void*)item->parentItem())
- << ", pos = " << item->pos()
- << ", z = " << item->zValue() << ", flags = "
- << item->flags() << ')';
- return debug.space();
-}
-
-QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemChange change)
-{
- const char *str = "UnknownChange";
- switch (change) {
- case QGraphicsItem::ItemChildAddedChange:
- str = "ItemChildAddedChange";
- break;
- case QGraphicsItem::ItemChildRemovedChange:
- str = "ItemChildRemovedChange";
- break;
- case QGraphicsItem::ItemCursorChange:
- str = "ItemCursorChange";
- break;
- case QGraphicsItem::ItemCursorHasChanged:
- str = "ItemCursorHasChanged";
- break;
- case QGraphicsItem::ItemEnabledChange:
- str = "ItemEnabledChange";
- break;
- case QGraphicsItem::ItemEnabledHasChanged:
- str = "ItemEnabledHasChanged";
- break;
- case QGraphicsItem::ItemFlagsChange:
- str = "ItemFlagsChange";
- break;
- case QGraphicsItem::ItemFlagsHaveChanged:
- str = "ItemFlagsHaveChanged";
- break;
- case QGraphicsItem::ItemMatrixChange:
- str = "ItemMatrixChange";
- break;
- case QGraphicsItem::ItemParentChange:
- str = "ItemParentChange";
- break;
- case QGraphicsItem::ItemParentHasChanged:
- str = "ItemParentHasChanged";
- break;
- case QGraphicsItem::ItemPositionChange:
- str = "ItemPositionChange";
- break;
- case QGraphicsItem::ItemPositionHasChanged:
- str = "ItemPositionHasChanged";
- break;
- case QGraphicsItem::ItemSceneChange:
- str = "ItemSceneChange";
- break;
- case QGraphicsItem::ItemSceneHasChanged:
- str = "ItemSceneHasChanged";
- break;
- case QGraphicsItem::ItemSelectedChange:
- str = "ItemSelectedChange";
- break;
- case QGraphicsItem::ItemSelectedHasChanged:
- str = "ItemSelectedHasChanged";
- break;
- case QGraphicsItem::ItemToolTipChange:
- str = "ItemToolTipChange";
- break;
- case QGraphicsItem::ItemToolTipHasChanged:
- str = "ItemToolTipHasChanged";
- break;
- case QGraphicsItem::ItemTransformChange:
- str = "ItemTransformChange";
- break;
- case QGraphicsItem::ItemTransformHasChanged:
- str = "ItemTransformHasChanged";
- break;
- case QGraphicsItem::ItemVisibleChange:
- str = "ItemVisibleChange";
- break;
- case QGraphicsItem::ItemVisibleHasChanged:
- str = "ItemVisibleHasChanged";
- break;
- case QGraphicsItem::ItemZValueChange:
- str = "ItemZValueChange";
- break;
- case QGraphicsItem::ItemZValueHasChanged:
- str = "ItemZValueHasChanged";
- break;
- case QGraphicsItem::ItemOpacityChange:
- str = "ItemOpacityChange";
- break;
- case QGraphicsItem::ItemOpacityHasChanged:
- str = "ItemOpacityHasChanged";
- break;
- case QGraphicsItem::ItemScenePositionHasChanged:
- str = "ItemScenePositionHasChanged";
- break;
- case QGraphicsItem::ItemRotationChange:
- str = "ItemRotationChange";
- break;
- case QGraphicsItem::ItemRotationHasChanged:
- str = "ItemRotationHasChanged";
- break;
- case QGraphicsItem::ItemScaleChange:
- str = "ItemScaleChange";
- break;
- case QGraphicsItem::ItemScaleHasChanged:
- str = "ItemScaleHasChanged";
- break;
- case QGraphicsItem::ItemTransformOriginPointChange:
- str = "ItemTransformOriginPointChange";
- break;
- case QGraphicsItem::ItemTransformOriginPointHasChanged:
- str = "ItemTransformOriginPointHasChanged";
- break;
- }
- debug << str;
- return debug;
-}
-
-QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlag flag)
-{
- const char *str = "UnknownFlag";
- switch (flag) {
- case QGraphicsItem::ItemIsMovable:
- str = "ItemIsMovable";
- break;
- case QGraphicsItem::ItemIsSelectable:
- str = "ItemIsSelectable";
- break;
- case QGraphicsItem::ItemIsFocusable:
- str = "ItemIsFocusable";
- break;
- case QGraphicsItem::ItemClipsToShape:
- str = "ItemClipsToShape";
- break;
- case QGraphicsItem::ItemClipsChildrenToShape:
- str = "ItemClipsChildrenToShape";
- break;
- case QGraphicsItem::ItemIgnoresTransformations:
- str = "ItemIgnoresTransformations";
- break;
- case QGraphicsItem::ItemIgnoresParentOpacity:
- str = "ItemIgnoresParentOpacity";
- break;
- case QGraphicsItem::ItemDoesntPropagateOpacityToChildren:
- str = "ItemDoesntPropagateOpacityToChildren";
- break;
- case QGraphicsItem::ItemStacksBehindParent:
- str = "ItemStacksBehindParent";
- break;
- case QGraphicsItem::ItemUsesExtendedStyleOption:
- str = "ItemUsesExtendedStyleOption";
- break;
- case QGraphicsItem::ItemHasNoContents:
- str = "ItemHasNoContents";
- break;
- case QGraphicsItem::ItemSendsGeometryChanges:
- str = "ItemSendsGeometryChanges";
- break;
- case QGraphicsItem::ItemAcceptsInputMethod:
- str = "ItemAcceptsInputMethod";
- break;
- case QGraphicsItem::ItemNegativeZStacksBehindParent:
- str = "ItemNegativeZStacksBehindParent";
- break;
- case QGraphicsItem::ItemIsPanel:
- str = "ItemIsPanel";
- break;
- case QGraphicsItem::ItemIsFocusScope:
- str = "ItemIsFocusScope";
- break;
- case QGraphicsItem::ItemSendsScenePositionChanges:
- str = "ItemSendsScenePositionChanges";
- break;
- case QGraphicsItem::ItemStopsClickFocusPropagation:
- str = "ItemStopsClickFocusPropagation";
- break;
- case QGraphicsItem::ItemStopsFocusHandling:
- str = "ItemStopsFocusHandling";
- break;
- }
- debug << str;
- return debug;
-}
-
-QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlags flags)
-{
- debug << '(';
- bool f = false;
- for (int i = 0; i < 17; ++i) {
- if (flags & (1 << i)) {
- if (f)
- debug << '|';
- f = true;
- debug << QGraphicsItem::GraphicsItemFlag(int(flags & (1 << i)));
- }
- }
- debug << ')';
- return debug;
-}
-
-#endif
-
-QT_END_NAMESPACE
-
-#include "moc_qgraphicsitem.cpp"
-
-#endif // QT_NO_GRAPHICSVIEW
diff --git a/src/gui/graphicsview/qgraphicslayout.h b/src/gui/graphicsview/qgraphicslayout.h
deleted file mode 100644
index c622fb881e..0000000000
--- a/src/gui/graphicsview/qgraphicslayout.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSLAYOUT_H
-#define QGRAPHICSLAYOUT_H
-
-#include <QtGui/qgraphicslayoutitem.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
-
-class QGraphicsLayoutPrivate;
-class QGraphicsLayoutItem;
-class QGraphicsWidget;
-
-class Q_GUI_EXPORT QGraphicsLayout : public QGraphicsLayoutItem
-{
-public:
- QGraphicsLayout(QGraphicsLayoutItem *parent = 0);
- ~QGraphicsLayout();
-
- void setContentsMargins(qreal left, qreal top, qreal right, qreal bottom);
- void getContentsMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const;
-
- void activate();
- bool isActivated() const;
- virtual void invalidate();
- virtual void updateGeometry();
-
- virtual void widgetEvent(QEvent *e);
-
- virtual int count() const = 0;
- virtual QGraphicsLayoutItem *itemAt(int i) const = 0;
- virtual void removeAt(int index) = 0;
-
-protected:
- QGraphicsLayout(QGraphicsLayoutPrivate &, QGraphicsLayoutItem *);
- void addChildLayoutItem(QGraphicsLayoutItem *layoutItem);
-
-private:
- Q_DISABLE_COPY(QGraphicsLayout)
- Q_DECLARE_PRIVATE(QGraphicsLayout)
- friend class QGraphicsWidget;
-};
-
-Q_DECLARE_INTERFACE(QGraphicsLayout, "com.trolltech.Qt.QGraphicsLayout")
-
-#endif
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
-
diff --git a/src/gui/graphicsview/qgraphicslayout_p.h b/src/gui/graphicsview/qgraphicslayout_p.h
deleted file mode 100644
index 5358ec3cf4..0000000000
--- a/src/gui/graphicsview/qgraphicslayout_p.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSLAYOUT_P_H
-#define QGRAPHICSLAYOUT_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qglobal.h>
-
-#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
-
-#include "qgraphicslayout.h"
-#include "qgraphicslayoutitem_p.h"
-#include <QtGui/qstyle.h>
-#include <QtGui/qwidget.h>
-#include <QtGui/qstyleoption.h>
-
-QT_BEGIN_NAMESPACE
-
-class QGraphicsLayoutItem;
-class QGraphicsWidget;
-
-#ifdef QT_DEBUG
-inline bool qt_graphicsLayoutDebug()
-{
- static int checked_env = -1;
- if(checked_env == -1)
- checked_env = !!qgetenv("QT_GRAPHICSLAYOUT_DEBUG").toInt();
- return checked_env;
-}
-#endif
-
-
-class QLayoutStyleInfo
-{
-public:
- inline QLayoutStyleInfo() { invalidate(); }
- inline QLayoutStyleInfo(QStyle *style, QWidget *widget)
- : m_valid(true), m_style(style), m_widget(widget)
- {
- Q_ASSERT(style);
- if (widget) //###
- m_styleOption.initFrom(widget);
- m_defaultSpacing[0] = style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing);
- m_defaultSpacing[1] = style->pixelMetric(QStyle::PM_LayoutVerticalSpacing);
- }
-
- inline void invalidate() { m_valid = false; m_style = 0; m_widget = 0; }
-
- inline QStyle *style() const { return m_style; }
- inline QWidget *widget() const { return m_widget; }
-
- inline bool operator==(const QLayoutStyleInfo &other)
- { return m_style == other.m_style && m_widget == other.m_widget; }
- inline bool operator!=(const QLayoutStyleInfo &other)
- { return !(*this == other); }
-
- inline void setDefaultSpacing(Qt::Orientation o, qreal spacing){
- if (spacing >= 0)
- m_defaultSpacing[o - 1] = spacing;
- }
-
- inline qreal defaultSpacing(Qt::Orientation o) const {
- return m_defaultSpacing[o - 1];
- }
-
- inline qreal perItemSpacing(QSizePolicy::ControlType control1,
- QSizePolicy::ControlType control2,
- Qt::Orientation orientation) const
- {
- Q_ASSERT(style());
- return style()->layoutSpacing(control1, control2, orientation, &m_styleOption, widget());
- }
-private:
- bool m_valid;
- QStyle *m_style;
- QWidget *m_widget;
- QStyleOption m_styleOption;
- qreal m_defaultSpacing[2];
-};
-
-class Q_AUTOTEST_EXPORT QGraphicsLayoutPrivate : public QGraphicsLayoutItemPrivate
-{
- Q_DECLARE_PUBLIC(QGraphicsLayout)
-
-public:
- QGraphicsLayoutPrivate() : QGraphicsLayoutItemPrivate(0, true), left(-1.0), top(-1.0), right(-1.0), bottom(-1.0),
- activated(true) { }
-
- void reparentChildItems(QGraphicsItem *newParent);
- void getMargin(qreal *result, qreal userMargin, QStyle::PixelMetric pm) const;
- Qt::LayoutDirection visualDirection() const;
-
- void addChildLayoutItem(QGraphicsLayoutItem *item);
- void activateRecursive(QGraphicsLayoutItem *item);
-
- qreal left, top, right, bottom;
- bool activated;
-};
-
-
-QT_END_NAMESPACE
-
-#endif //QT_NO_GRAPHICSVIEW
-
-#endif
diff --git a/src/gui/graphicsview/qgraphicslayoutitem.h b/src/gui/graphicsview/qgraphicslayoutitem.h
deleted file mode 100644
index 7112dd06fc..0000000000
--- a/src/gui/graphicsview/qgraphicslayoutitem.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSLAYOUTITEM_H
-#define QGRAPHICSLAYOUTITEM_H
-
-#include <QtCore/qscopedpointer.h>
-#include <QtGui/qsizepolicy.h>
-#include <QtGui/qevent.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
-
-class QGraphicsLayoutItemPrivate;
-class QGraphicsItem;
-class Q_GUI_EXPORT QGraphicsLayoutItem
-{
-public:
- QGraphicsLayoutItem(QGraphicsLayoutItem *parent = 0, bool isLayout = false);
- virtual ~QGraphicsLayoutItem();
-
- void setSizePolicy(const QSizePolicy &policy);
- void setSizePolicy(QSizePolicy::Policy hPolicy, QSizePolicy::Policy vPolicy, QSizePolicy::ControlType controlType = QSizePolicy::DefaultType);
- QSizePolicy sizePolicy() const;
-
- void setMinimumSize(const QSizeF &size);
- inline void setMinimumSize(qreal w, qreal h);
- QSizeF minimumSize() const;
- void setMinimumWidth(qreal width);
- inline qreal minimumWidth() const;
- void setMinimumHeight(qreal height);
- inline qreal minimumHeight() const;
-
- void setPreferredSize(const QSizeF &size);
- inline void setPreferredSize(qreal w, qreal h);
- QSizeF preferredSize() const;
- void setPreferredWidth(qreal width);
- inline qreal preferredWidth() const;
- void setPreferredHeight(qreal height);
- inline qreal preferredHeight() const;
-
- void setMaximumSize(const QSizeF &size);
- inline void setMaximumSize(qreal w, qreal h);
- QSizeF maximumSize() const;
- void setMaximumWidth(qreal width);
- inline qreal maximumWidth() const;
- void setMaximumHeight(qreal height);
- inline qreal maximumHeight() const;
-
- virtual void setGeometry(const QRectF &rect);
- QRectF geometry() const;
- virtual void getContentsMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const;
- QRectF contentsRect() const;
-
- QSizeF effectiveSizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
-
- virtual void updateGeometry(); //### rename to sizeHintChanged()
-
- QGraphicsLayoutItem *parentLayoutItem() const;
- void setParentLayoutItem(QGraphicsLayoutItem *parent);
-
- bool isLayout() const;
- // ###Qt5: Make automatic reparenting work regardless of item/object/widget type.
- QGraphicsItem *graphicsItem() const;
- bool ownedByLayout() const;
-
-protected:
- void setGraphicsItem(QGraphicsItem *item);
- void setOwnedByLayout(bool ownedByLayout);
- QGraphicsLayoutItem(QGraphicsLayoutItemPrivate &dd);
-
- virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const = 0;
- QScopedPointer<QGraphicsLayoutItemPrivate> d_ptr;
-
-private:
- QSizeF *effectiveSizeHints(const QSizeF &constraint) const;
- Q_DECLARE_PRIVATE(QGraphicsLayoutItem)
-
- friend class QGraphicsLayout;
-};
-
-Q_DECLARE_INTERFACE(QGraphicsLayoutItem, "com.trolltech.Qt.QGraphicsLayoutItem")
-
-inline void QGraphicsLayoutItem::setMinimumSize(qreal aw, qreal ah)
-{ setMinimumSize(QSizeF(aw, ah)); }
-inline void QGraphicsLayoutItem::setPreferredSize(qreal aw, qreal ah)
-{ setPreferredSize(QSizeF(aw, ah)); }
-inline void QGraphicsLayoutItem::setMaximumSize(qreal aw, qreal ah)
-{ setMaximumSize(QSizeF(aw, ah)); }
-
-inline qreal QGraphicsLayoutItem::minimumWidth() const
-{ return effectiveSizeHint(Qt::MinimumSize).width(); }
-inline qreal QGraphicsLayoutItem::minimumHeight() const
-{ return effectiveSizeHint(Qt::MinimumSize).height(); }
-
-inline qreal QGraphicsLayoutItem::preferredWidth() const
-{ return effectiveSizeHint(Qt::PreferredSize).width(); }
-inline qreal QGraphicsLayoutItem::preferredHeight() const
-{ return effectiveSizeHint(Qt::PreferredSize).height(); }
-
-inline qreal QGraphicsLayoutItem::maximumWidth() const
-{ return effectiveSizeHint(Qt::MaximumSize).width(); }
-inline qreal QGraphicsLayoutItem::maximumHeight() const
-{ return effectiveSizeHint(Qt::MaximumSize).height(); }
-
-#endif
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/gui/graphicsview/qgraphicslayoutitem_p.h b/src/gui/graphicsview/qgraphicslayoutitem_p.h
deleted file mode 100644
index 85481b7a46..0000000000
--- a/src/gui/graphicsview/qgraphicslayoutitem_p.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSLAYOUTITEM_P_H
-#define QGRAPHICSLAYOUTITEM_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/QSizeF>
-#include <QtGui/QSizePolicy>
-
-QT_BEGIN_NAMESPACE
-
-class QGraphicsLayoutItem;
-class Q_AUTOTEST_EXPORT QGraphicsLayoutItemPrivate
-{
- Q_DECLARE_PUBLIC(QGraphicsLayoutItem)
-public:
- virtual ~QGraphicsLayoutItemPrivate();
- QGraphicsLayoutItemPrivate(QGraphicsLayoutItem *parent, bool isLayout);
- static QGraphicsLayoutItemPrivate *get(QGraphicsLayoutItem *q) { return q->d_func();}
- static const QGraphicsLayoutItemPrivate *get(const QGraphicsLayoutItem *q) { return q->d_func();}
-
- void init();
- QSizeF *effectiveSizeHints(const QSizeF &constraint) const;
- QGraphicsItem *parentItem() const;
- void ensureUserSizeHints();
- void setSize(Qt::SizeHint which, const QSizeF &size);
- enum SizeComponent { Width, Height };
- void setSizeComponent(Qt::SizeHint which, SizeComponent component, qreal value);
-
- bool hasHeightForWidth() const;
- bool hasWidthForHeight() const;
-
- QSizePolicy sizePolicy;
- QGraphicsLayoutItem *parent;
-
- QSizeF *userSizeHints;
- mutable QSizeF cachedSizeHints[Qt::NSizeHints];
- mutable QSizeF cachedConstraint;
- mutable QSizeF cachedSizeHintsWithConstraints[Qt::NSizeHints];
-
- mutable quint32 sizeHintCacheDirty : 1;
- mutable quint32 sizeHintWithConstraintCacheDirty : 1;
- quint32 isLayout : 1;
- quint32 ownedByLayout : 1;
-
- QGraphicsLayoutItem *q_ptr;
- QRectF geom;
- QGraphicsItem *graphicsItem;
-};
-
-QT_END_NAMESPACE
-
-#endif //QGRAPHICSLAYOUTITEM_P_H
-
diff --git a/src/gui/graphicsview/qgraphicslinearlayout.h b/src/gui/graphicsview/qgraphicslinearlayout.h
deleted file mode 100644
index 60749dbdaf..0000000000
--- a/src/gui/graphicsview/qgraphicslinearlayout.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSLINEARLAYOUT_H
-#define QGRAPHICSLINEARLAYOUT_H
-
-#include <QtGui/qgraphicsitem.h>
-#include <QtGui/qgraphicslayout.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
-
-class QGraphicsLinearLayoutPrivate;
-
-class Q_GUI_EXPORT QGraphicsLinearLayout : public QGraphicsLayout
-{
-public:
- QGraphicsLinearLayout(QGraphicsLayoutItem *parent = 0);
- QGraphicsLinearLayout(Qt::Orientation orientation, QGraphicsLayoutItem *parent = 0);
- virtual ~QGraphicsLinearLayout();
-
- void setOrientation(Qt::Orientation orientation);
- Qt::Orientation orientation() const;
-
- inline void addItem(QGraphicsLayoutItem *item) { insertItem(-1, item); }
- inline void addStretch(int stretch = 1) { insertStretch(-1, stretch); }
-
- void insertItem(int index, QGraphicsLayoutItem *item);
- void insertStretch(int index, int stretch = 1);
-
- void removeItem(QGraphicsLayoutItem *item);
- void removeAt(int index);
-
- void setSpacing(qreal spacing);
- qreal spacing() const;
- void setItemSpacing(int index, qreal spacing);
- qreal itemSpacing(int index) const;
-
- void setStretchFactor(QGraphicsLayoutItem *item, int stretch);
- int stretchFactor(QGraphicsLayoutItem *item) const;
-
- void setAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment);
- Qt::Alignment alignment(QGraphicsLayoutItem *item) const;
-
- void setGeometry(const QRectF &rect);
-
- int count() const;
- QGraphicsLayoutItem *itemAt(int index) const;
-
- void invalidate();
- QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
-
-#if 0 // ###
- Q5SizePolicy::ControlTypes controlTypes(LayoutSide side) const;
-#endif
-
- void dump(int indent = 0) const;
-
-protected:
-#if 0
- QSize contentsSizeHint(Qt::SizeHint which, const QSize &constraint = QSize()) const;
-#endif
-
-private:
- Q_DISABLE_COPY(QGraphicsLinearLayout)
- Q_DECLARE_PRIVATE(QGraphicsLinearLayout)
-};
-
-#endif
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
-
diff --git a/src/gui/graphicsview/qgraphicsproxywidget.cpp b/src/gui/graphicsview/qgraphicsproxywidget.cpp
deleted file mode 100644
index e6142e66ac..0000000000
--- a/src/gui/graphicsview/qgraphicsproxywidget.cpp
+++ /dev/null
@@ -1,1570 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qglobal.h"
-
-#ifndef QT_NO_GRAPHICSVIEW
-
-#include "qgraphicslayout.h"
-#include "qgraphicsproxywidget.h"
-#include "private/qgraphicsproxywidget_p.h"
-#include "private/qwidget_p.h"
-#include "private/qapplication_p.h"
-
-#include <QtCore/qdebug.h>
-#include <QtGui/qevent.h>
-#include <QtGui/qgraphicsscene.h>
-#include <QtGui/qgraphicssceneevent.h>
-#include <QtGui/qlayout.h>
-#include <QtGui/qpainter.h>
-#include <QtGui/qstyleoption.h>
-#include <QtGui/qgraphicsview.h>
-#include <QtGui/qlistview.h>
-#include <QtGui/qlineedit.h>
-#include <QtGui/qtextedit.h>
-
-QT_BEGIN_NAMESPACE
-
-//#define GRAPHICSPROXYWIDGET_DEBUG
-
-/*!
- \class QGraphicsProxyWidget
- \brief The QGraphicsProxyWidget class provides a proxy layer for embedding
- a QWidget in a QGraphicsScene.
- \since 4.4
- \ingroup graphicsview-api
-
- QGraphicsProxyWidget embeds QWidget-based widgets, for example, a
- QPushButton, QFontComboBox, or even QFileDialog, into
- QGraphicsScene. It forwards events between the two objects and
- translates between QWidget's integer-based geometry and
- QGraphicsWidget's qreal-based geometry. QGraphicsProxyWidget
- supports all core features of QWidget, including tab focus,
- keyboard input, Drag & Drop, and popups. You can also embed
- complex widgets, e.g., widgets with subwidgets.
-
- Example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp 0
-
- QGraphicsProxyWidget takes care of automatically embedding popup children
- of embedded widgets through creating a child proxy for each popup. This
- means that when an embedded QComboBox shows its popup list, a new
- QGraphicsProxyWidget is created automatically, embedding the popup, and
- positioning it correctly. This only works if the popup is child of the
- embedded widget (for example QToolButton::setMenu() requires the QMenu instance
- to be child of the QToolButton).
-
- \section1 Embedding a Widget with QGraphicsProxyWidget
-
- There are two ways to embed a widget using QGraphicsProxyWidget. The most
- common way is to pass a widget pointer to QGraphicsScene::addWidget()
- together with any relevant \l Qt::WindowFlags. This function returns a
- pointer to a QGraphicsProxyWidget. You can then choose to reparent or
- position either the proxy, or the embedded widget itself.
-
- For example, in the code snippet below, we embed a group box into the proxy:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp 1
-
- The image below is the output obtained with its contents margin and
- contents rect labeled.
-
- \image qgraphicsproxywidget-embed.png
-
- Alternatively, you can start by creating a new QGraphicsProxyWidget item,
- and then call setWidget() to embed a QWidget later. The widget() function
- returns a pointer to the embedded widget. QGraphicsProxyWidget shares
- ownership with QWidget, so if either of the two widgets are destroyed, the
- other widget will be automatically destroyed as well.
-
- \section1 Synchronizing Widget States
-
- QGraphicsProxyWidget keeps its state in sync with the embedded widget. For
- example, if the proxy is hidden or disabled, the embedded widget will be
- hidden or disabled as well, and vice versa. When the widget is embedded by
- calling addWidget(), QGraphicsProxyWidget copies the state from the widget
- into the proxy, and after that, the two will stay synchronized where
- possible. By default, when you embed a widget into a proxy, both the widget
- and the proxy will be visible because a QGraphicsWidget is visible when
- created (you do not have to call show()). If you explicitly hide the
- embedded widget, the proxy will also become invisible.
-
- Example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp 2
-
- QGraphicsProxyWidget maintains symmetry for the following states:
-
- \table
- \header \o QWidget state \o QGraphicsProxyWidget state \o Notes
- \row \o QWidget::enabled
- \o QGraphicsProxyWidget::enabled
- \o
- \row \o QWidget::visible
- \o QGraphicsProxyWidget::visible
- \o The explicit state is also symmetric.
- \row \o QWidget::geometry
- \o QGraphicsProxyWidget::geometry
- \o Geometry is only guaranteed to be symmetric while
- the embedded widget is visible.
- \row \o QWidget::layoutDirection
- \o QGraphicsProxyWidget::layoutDirection
- \o
- \row \o QWidget::style
- \o QGraphicsProxyWidget::style
- \o
- \row \o QWidget::palette
- \o QGraphicsProxyWidget::palette
- \o
- \row \o QWidget::font
- \o QGraphicsProxyWidget::font
- \o
- \row \o QWidget::cursor
- \o QGraphicsProxyWidget::cursor
- \o The embedded widget overrides the proxy widget
- cursor. The proxy cursor changes depending on
- which embedded subwidget is currently under the
- mouse.
- \row \o QWidget::sizeHint()
- \o QGraphicsProxyWidget::sizeHint()
- \o All size hint functionality from the embedded
- widget is forwarded by the proxy.
- \row \o QWidget::getContentsMargins()
- \o QGraphicsProxyWidget::getContentsMargins()
- \o Updated once by setWidget().
- \row \o QWidget::windowTitle
- \o QGraphicsProxyWidget::windowTitle
- \o Updated once by setWidget().
- \endtable
-
- \note QGraphicsScene keeps the embedded widget in a special state that
- prevents it from disturbing other widgets (both embedded and not embedded)
- while the widget is embedded. In this state, the widget may differ slightly
- in behavior from when it is not embedded.
-
- \warning This class is provided for convenience when bridging
- QWidgets and QGraphicsItems, it should not be used for
- high-performance scenarios.
-
- \sa QGraphicsScene::addWidget(), QGraphicsWidget
-*/
-
-extern bool qt_sendSpontaneousEvent(QObject *, QEvent *);
-Q_GUI_EXPORT extern bool qt_tab_all_widgets;
-
-/*!
- \internal
-*/
-void QGraphicsProxyWidgetPrivate::init()
-{
- Q_Q(QGraphicsProxyWidget);
- q->setFocusPolicy(Qt::WheelFocus);
- q->setAcceptDrops(true);
-}
-
-/*!
- \internal
-*/
-void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneHoverEvent *event)
-{
- QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseMove);
- mouseEvent.setPos(event->pos());
- mouseEvent.setScreenPos(event->screenPos());
- mouseEvent.setButton(Qt::NoButton);
- mouseEvent.setButtons(0);
- mouseEvent.setModifiers(event->modifiers());
- sendWidgetMouseEvent(&mouseEvent);
- event->setAccepted(mouseEvent.isAccepted());
-}
-
-/*!
- \internal
-*/
-void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneMouseEvent *event)
-{
- if (!event || !widget || !widget->isVisible())
- return;
- Q_Q(QGraphicsProxyWidget);
-
- // Find widget position and receiver.
- QPointF pos = event->pos();
- QPointer<QWidget> alienWidget = widget->childAt(pos.toPoint());
- QPointer<QWidget> receiver = alienWidget ? alienWidget : widget;
-
- if (QWidgetPrivate::nearestGraphicsProxyWidget(receiver) != q)
- return; //another proxywidget will handle the events
-
- // Translate QGraphicsSceneMouse events to QMouseEvents.
- QEvent::Type type = QEvent::None;
- switch (event->type()) {
- case QEvent::GraphicsSceneMousePress:
- type = QEvent::MouseButtonPress;
- if (!embeddedMouseGrabber)
- embeddedMouseGrabber = receiver;
- else
- receiver = embeddedMouseGrabber;
- break;
- case QEvent::GraphicsSceneMouseRelease:
- type = QEvent::MouseButtonRelease;
- if (embeddedMouseGrabber)
- receiver = embeddedMouseGrabber;
- break;
- case QEvent::GraphicsSceneMouseDoubleClick:
- type = QEvent::MouseButtonDblClick;
- if (!embeddedMouseGrabber)
- embeddedMouseGrabber = receiver;
- else
- receiver = embeddedMouseGrabber;
- break;
- case QEvent::GraphicsSceneMouseMove:
- type = QEvent::MouseMove;
- if (embeddedMouseGrabber)
- receiver = embeddedMouseGrabber;
- break;
- default:
- Q_ASSERT_X(false, "QGraphicsProxyWidget", "internal error");
- break;
- }
-
- if (!lastWidgetUnderMouse) {
- QApplicationPrivate::dispatchEnterLeave(embeddedMouseGrabber ? embeddedMouseGrabber : receiver, 0);
- lastWidgetUnderMouse = receiver;
- }
-
- // Map event position from us to the receiver
- pos = mapToReceiver(pos, receiver);
-
- // Send mouse event.
- QMouseEvent *mouseEvent = QMouseEvent::createExtendedMouseEvent(type, pos,
- receiver->mapToGlobal(pos.toPoint()), event->button(),
- event->buttons(), event->modifiers());
-
- QWidget *embeddedMouseGrabberPtr = (QWidget *)embeddedMouseGrabber;
- QApplicationPrivate::sendMouseEvent(receiver, mouseEvent, alienWidget, widget,
- &embeddedMouseGrabberPtr, lastWidgetUnderMouse, event->spontaneous());
- embeddedMouseGrabber = embeddedMouseGrabberPtr;
-
- // Handle enter/leave events when last button is released from mouse
- // grabber child widget.
- if (embeddedMouseGrabber && type == QEvent::MouseButtonRelease && !event->buttons()) {
- Q_Q(QGraphicsProxyWidget);
- if (q->rect().contains(event->pos()) && q->acceptsHoverEvents())
- lastWidgetUnderMouse = alienWidget ? alienWidget : widget;
- else // released on the frame our outside the item, or doesn't accept hover events.
- lastWidgetUnderMouse = 0;
-
- QApplicationPrivate::dispatchEnterLeave(lastWidgetUnderMouse, embeddedMouseGrabber);
- embeddedMouseGrabber = 0;
-
-#ifndef QT_NO_CURSOR
- // ### Restore the cursor, don't override it.
- if (!lastWidgetUnderMouse)
- q->unsetCursor();
-#endif
- }
-
- event->setAccepted(mouseEvent->isAccepted());
- delete mouseEvent;
-}
-
-void QGraphicsProxyWidgetPrivate::sendWidgetKeyEvent(QKeyEvent *event)
-{
- Q_Q(QGraphicsProxyWidget);
- if (!event || !widget || !widget->isVisible())
- return;
-
- QPointer<QWidget> receiver = widget->focusWidget();
- if (!receiver)
- receiver = widget;
- Q_ASSERT(receiver);
-
- do {
- bool res = QApplication::sendEvent(receiver, event);
- if ((res && event->isAccepted()) || (q->isWindow() && receiver == widget))
- break;
- receiver = receiver->parentWidget();
- } while (receiver);
-}
-
-/*!
- \internal
-*/
-void QGraphicsProxyWidgetPrivate::removeSubFocusHelper(QWidget *widget, Qt::FocusReason reason)
-{
- QFocusEvent event(QEvent::FocusOut, reason);
- QPointer<QWidget> widgetGuard = widget;
- QApplication::sendEvent(widget, &event);
- if (widgetGuard && event.isAccepted())
- QApplication::sendEvent(widget->style(), &event);
-}
-
-/*!
- \internal
-
- Reimplemented from QGraphicsItemPrivate. ### Qt 5: Move impl to
- reimplementation QGraphicsProxyWidget::inputMethodQuery().
-*/
-QVariant QGraphicsProxyWidgetPrivate::inputMethodQueryHelper(Qt::InputMethodQuery query) const
-{
- Q_Q(const QGraphicsProxyWidget);
- if (!widget || !q->hasFocus())
- return QVariant();
-
- QWidget *focusWidget = widget->focusWidget();
- if (!focusWidget)
- focusWidget = widget;
- QVariant v = focusWidget->inputMethodQuery(query);
- QPointF focusWidgetPos = q->subWidgetRect(focusWidget).topLeft();
- switch (v.type()) {
- case QVariant::RectF:
- v = v.toRectF().translated(focusWidgetPos);
- break;
- case QVariant::PointF:
- v = v.toPointF() + focusWidgetPos;
- break;
- case QVariant::Rect:
- v = v.toRect().translated(focusWidgetPos.toPoint());
- break;
- case QVariant::Point:
- v = v.toPoint() + focusWidgetPos.toPoint();
- break;
- default:
- break;
- }
- return v;
-}
-
-/*!
- \internal
- Some of the logic is shared with QApplicationPrivate::focusNextPrevChild_helper
-*/
-QWidget *QGraphicsProxyWidgetPrivate::findFocusChild(QWidget *child, bool next) const
-{
- if (!widget)
- return 0;
-
- // Run around the focus chain until we find a widget that can take tab focus.
- if (!child) {
- child = next ? (QWidget *)widget : widget->d_func()->focus_prev;
- } else {
- child = next ? child->d_func()->focus_next : child->d_func()->focus_prev;
- if ((next && child == widget) || (!next && child == widget->d_func()->focus_prev)) {
- return 0;
- }
- }
-
- QWidget *oldChild = child;
- uint focus_flag = qt_tab_all_widgets ? Qt::TabFocus : Qt::StrongFocus;
- do {
- if (child->isEnabled()
- && child->isVisibleTo(widget)
- && ((child->focusPolicy() & focus_flag) == focus_flag)
- && !(child->d_func()->extra && child->d_func()->extra->focus_proxy)) {
- return child;
- }
- child = next ? child->d_func()->focus_next : child->d_func()->focus_prev;
- } while (child != oldChild && !(next && child == widget) && !(!next && child == widget->d_func()->focus_prev));
- return 0;
-}
-
-/*!
- \internal
-*/
-void QGraphicsProxyWidgetPrivate::_q_removeWidgetSlot()
-{
- Q_Q(QGraphicsProxyWidget);
- widget = 0;
- delete q;
-}
-
-/*!
- \internal
-*/
-void QGraphicsProxyWidgetPrivate::updateWidgetGeometryFromProxy()
-{
-}
-
-/*!
- \internal
-*/
-void QGraphicsProxyWidgetPrivate::updateProxyGeometryFromWidget()
-{
- Q_Q(QGraphicsProxyWidget);
- if (!widget)
- return;
-
- QRectF widgetGeometry = widget->geometry();
- QWidget *parentWidget = widget->parentWidget();
- if (widget->isWindow()) {
- QGraphicsProxyWidget *proxyParent = 0;
- if (parentWidget && (proxyParent = qobject_cast<QGraphicsProxyWidget *>(q->parentWidget()))) {
- // Nested window proxy (e.g., combobox popup), map widget to the
- // parent widget's global coordinates, and map that to the parent
- // proxy's child coordinates.
- widgetGeometry.moveTo(proxyParent->subWidgetRect(parentWidget).topLeft()
- + parentWidget->mapFromGlobal(widget->pos()));
- }
- }
-
- // Adjust to size hint if the widget has never been resized.
- if (!widget->size().isValid())
- widgetGeometry.setSize(widget->sizeHint());
-
- // Assign new geometry.
- posChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
- sizeChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
- q->setGeometry(widgetGeometry);
- posChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
- sizeChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
-}
-
-/*!
- \internal
-*/
-void QGraphicsProxyWidgetPrivate::updateProxyInputMethodAcceptanceFromWidget()
-{
- Q_Q(QGraphicsProxyWidget);
- if (!widget)
- return;
-
- QWidget *focusWidget = widget->focusWidget();
- if (!focusWidget)
- focusWidget = widget;
- q->setFlag(QGraphicsItem::ItemAcceptsInputMethod,
- focusWidget->testAttribute(Qt::WA_InputMethodEnabled));
-}
-
-/*!
- \internal
-
- Embeds \a subWin as a subwindow of this proxy widget. \a subWin must be a top-level
- widget and a descendant of the widget managed by this proxy. A separate subproxy
- will be created as a child of this proxy widget to manage \a subWin.
-*/
-void QGraphicsProxyWidgetPrivate::embedSubWindow(QWidget *subWin)
-{
- QWExtra *extra;
- if (!((extra = subWin->d_func()->extra) && extra->proxyWidget)) {
- QGraphicsProxyWidget *subProxy = new QGraphicsProxyWidget(q_func(), subWin->windowFlags());
- subProxy->d_func()->setWidget_helper(subWin, false);
- }
-}
-
-/*!
- \internal
-
- Removes ("unembeds") \a subWin and deletes the proxy holder item. This can
- happen when QWidget::setParent() reparents the embedded window out of
- "embedded space".
-*/
-void QGraphicsProxyWidgetPrivate::unembedSubWindow(QWidget *subWin)
-{
- foreach (QGraphicsItem *child, children) {
- if (child->isWidget()) {
- if (QGraphicsProxyWidget *proxy = qobject_cast<QGraphicsProxyWidget *>(static_cast<QGraphicsWidget *>(child))) {
- if (proxy->widget() == subWin) {
- proxy->setWidget(0);
- scene->removeItem(proxy);
- delete proxy;
- return;
- }
- }
- }
- }
-}
-
-bool QGraphicsProxyWidgetPrivate::isProxyWidget() const
-{
- return true;
-}
-
-/*!
- \internal
-*/
-QPointF QGraphicsProxyWidgetPrivate::mapToReceiver(const QPointF &pos, const QWidget *receiver) const
-{
- QPointF p = pos;
- // Map event position from us to the receiver, preserving its
- // precision (don't use QWidget::mapFrom here).
- while (receiver && receiver != widget) {
- p -= QPointF(receiver->pos());
- receiver = receiver->parentWidget();
- }
- return p;
-}
-
-/*!
- Constructs a new QGraphicsProxy widget. \a parent and \a wFlags are passed
- to QGraphicsItem's constructor.
-*/
-QGraphicsProxyWidget::QGraphicsProxyWidget(QGraphicsItem *parent, Qt::WindowFlags wFlags)
- : QGraphicsWidget(*new QGraphicsProxyWidgetPrivate, parent, 0, wFlags)
-{
- Q_D(QGraphicsProxyWidget);
- d->init();
-}
-
-/*!
- Destroys the proxy widget and any embedded widget.
-*/
-QGraphicsProxyWidget::~QGraphicsProxyWidget()
-{
- Q_D(QGraphicsProxyWidget);
- if (d->widget) {
- QObject::disconnect(d->widget, SIGNAL(destroyed()), this, SLOT(_q_removeWidgetSlot()));
- delete d->widget;
- }
-}
-
-/*!
- Embeds \a widget into this proxy widget. The embedded widget must reside
- exclusively either inside or outside of Graphics View. You cannot embed a
- widget as long as it is is visible elsewhere in the UI, at the same time.
-
- \a widget must be a top-level widget whose parent is 0.
-
- When the widget is embedded, its state (e.g., visible, enabled, geometry,
- size hints) is copied into the proxy widget. If the embedded widget is
- explicitly hidden or disabled, the proxy widget will become explicitly
- hidden or disabled after embedding is complete. The class documentation
- has a full overview over the shared state.
-
- QGraphicsProxyWidget's window flags determine whether the widget, after
- embedding, will be given window decorations or not.
-
- After this function returns, QGraphicsProxyWidget will keep its state
- synchronized with that of \a widget whenever possible.
-
- If a widget is already embedded by this proxy when this function is
- called, that widget will first be automatically unembedded. Passing 0 for
- the \a widget argument will only unembed the widget, and the ownership of
- the currently embedded widget will be passed on to the caller.
- Every child widget that are embedded will also be embedded and their proxy
- widget destroyed.
-
- Note that widgets with the Qt::WA_PaintOnScreen widget attribute
- set and widgets that wrap an external application or controller
- cannot be embedded. Examples are QGLWidget and QAxWidget.
-
- \sa widget()
-*/
-void QGraphicsProxyWidget::setWidget(QWidget *widget)
-{
- Q_D(QGraphicsProxyWidget);
- d->setWidget_helper(widget, true);
-}
-
-void QGraphicsProxyWidgetPrivate::setWidget_helper(QWidget *newWidget, bool autoShow)
-{
- Q_Q(QGraphicsProxyWidget);
- if (newWidget == widget)
- return;
- if (widget) {
- QObject::disconnect(widget, SIGNAL(destroyed()), q, SLOT(_q_removeWidgetSlot()));
- widget->removeEventFilter(q);
- widget->setAttribute(Qt::WA_DontShowOnScreen, false);
- widget->d_func()->extra->proxyWidget = 0;
- resolveFont(inheritedFontResolveMask);
- resolvePalette(inheritedPaletteResolveMask);
- widget->update();
-
- foreach (QGraphicsItem *child, q->childItems()) {
- if (child->d_ptr->isProxyWidget()) {
- QGraphicsProxyWidget *childProxy = static_cast<QGraphicsProxyWidget *>(child);
- QWidget * parent = childProxy->widget();
- while (parent->parentWidget() != 0) {
- if (parent == widget)
- break;
- parent = parent->parentWidget();
- }
- if (!childProxy->widget() || parent != widget)
- continue;
- childProxy->setWidget(0);
- delete childProxy;
- }
- }
-
- widget = 0;
-#ifndef QT_NO_CURSOR
- q->unsetCursor();
-#endif
- q->setAcceptHoverEvents(false);
- if (!newWidget)
- q->update();
- }
- if (!newWidget)
- return;
- if (!newWidget->isWindow()) {
- QWExtra *extra = newWidget->parentWidget()->d_func()->extra;
- if (!extra || !extra->proxyWidget) {
- qWarning("QGraphicsProxyWidget::setWidget: cannot embed widget %p "
- "which is not a toplevel widget, and is not a child of an embedded widget", newWidget);
- return;
- }
- }
-
- // Register this proxy within the widget's private.
- // ### This is a bit backdoorish
- QWExtra *extra = newWidget->d_func()->extra;
- if (!extra) {
- newWidget->d_func()->createExtra();
- extra = newWidget->d_func()->extra;
- }
- QGraphicsProxyWidget **proxyWidget = &extra->proxyWidget;
- if (*proxyWidget) {
- if (*proxyWidget != q) {
- qWarning("QGraphicsProxyWidget::setWidget: cannot embed widget %p"
- "; already embedded", newWidget);
- }
- return;
- }
- *proxyWidget = q;
-
- newWidget->setAttribute(Qt::WA_DontShowOnScreen);
- newWidget->ensurePolished();
- // Do not wait for this widget to close before the app closes ###
- // shouldn't this widget inherit the attribute?
- newWidget->setAttribute(Qt::WA_QuitOnClose, false);
- q->setAcceptHoverEvents(true);
-
- if (newWidget->testAttribute(Qt::WA_NoSystemBackground))
- q->setAttribute(Qt::WA_NoSystemBackground);
- if (newWidget->testAttribute(Qt::WA_OpaquePaintEvent))
- q->setAttribute(Qt::WA_OpaquePaintEvent);
-
- widget = newWidget;
-
- // Changes only go from the widget to the proxy.
- enabledChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
- visibleChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
- posChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
- sizeChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
-
- if ((autoShow && !newWidget->testAttribute(Qt::WA_WState_ExplicitShowHide)) || !newWidget->testAttribute(Qt::WA_WState_Hidden)) {
- newWidget->show();
- }
-
- // Copy the state from the widget onto the proxy.
-#ifndef QT_NO_CURSOR
- if (newWidget->testAttribute(Qt::WA_SetCursor))
- q->setCursor(widget->cursor());
-#endif
- q->setEnabled(newWidget->isEnabled());
- q->setVisible(newWidget->isVisible());
- q->setLayoutDirection(newWidget->layoutDirection());
- if (newWidget->testAttribute(Qt::WA_SetStyle))
- q->setStyle(widget->style());
-
- resolveFont(inheritedFontResolveMask);
- resolvePalette(inheritedPaletteResolveMask);
-
- if (!newWidget->testAttribute(Qt::WA_Resized))
- newWidget->adjustSize();
-
- int left, top, right, bottom;
- newWidget->getContentsMargins(&left, &top, &right, &bottom);
- q->setContentsMargins(left, top, right, bottom);
- q->setWindowTitle(newWidget->windowTitle());
-
- // size policies and constraints..
- q->setSizePolicy(newWidget->sizePolicy());
- QSize sz = newWidget->minimumSize();
- q->setMinimumSize(sz.isNull() ? QSizeF() : QSizeF(sz));
- sz = newWidget->maximumSize();
- q->setMaximumSize(sz.isNull() ? QSizeF() : QSizeF(sz));
-
- updateProxyGeometryFromWidget();
-
- updateProxyInputMethodAcceptanceFromWidget();
-
- // Hook up the event filter to keep the state up to date.
- newWidget->installEventFilter(q);
- QObject::connect(newWidget, SIGNAL(destroyed()), q, SLOT(_q_removeWidgetSlot()));
-
- // Changes no longer go only from the widget to the proxy.
- enabledChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
- visibleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
- posChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
- sizeChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
-}
-
-/*!
- Returns a pointer to the embedded widget.
-
- \sa setWidget()
-*/
-QWidget *QGraphicsProxyWidget::widget() const
-{
- Q_D(const QGraphicsProxyWidget);
- return d->widget;
-}
-
-/*!
- Returns the rectangle for \a widget, which must be a descendant of
- widget(), or widget() itself, in this proxy item's local coordinates.
-
- If no widget is embedded, \a widget is 0, or \a widget is not a
- descendant of the embedded widget, this function returns an empty QRectF.
-
- \sa widget()
-*/
-QRectF QGraphicsProxyWidget::subWidgetRect(const QWidget *widget) const
-{
- Q_D(const QGraphicsProxyWidget);
- if (!widget || !d->widget)
- return QRectF();
- if (d->widget == widget || d->widget->isAncestorOf(widget))
- return QRectF(widget->mapTo(d->widget, QPoint(0, 0)), widget->size());
- return QRectF();
-}
-
-/*!
- \reimp
-*/
-void QGraphicsProxyWidget::setGeometry(const QRectF &rect)
-{
- Q_D(QGraphicsProxyWidget);
- bool proxyResizesWidget = !d->posChangeMode && !d->sizeChangeMode;
- if (proxyResizesWidget) {
- d->posChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
- d->sizeChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
- }
- QGraphicsWidget::setGeometry(rect);
- if (proxyResizesWidget) {
- d->posChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
- d->sizeChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
- }
-}
-
-/*!
- \reimp
-*/
-QVariant QGraphicsProxyWidget::itemChange(GraphicsItemChange change,
- const QVariant &value)
-{
- Q_D(QGraphicsProxyWidget);
-
- switch (change) {
- case ItemPositionChange:
- // The item's position is either changed directly on the proxy, in
- // which case the position change should propagate to the widget,
- // otherwise it happens as a side effect when filtering QEvent::Move.
- if (!d->posChangeMode)
- d->posChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
- break;
- case ItemPositionHasChanged:
- // Move the internal widget if we're in widget-to-proxy
- // mode. Otherwise the widget has already moved.
- if (d->widget && d->posChangeMode != QGraphicsProxyWidgetPrivate::WidgetToProxyMode)
- d->widget->move(value.toPoint());
- if (d->posChangeMode == QGraphicsProxyWidgetPrivate::ProxyToWidgetMode)
- d->posChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
- break;
- case ItemVisibleChange:
- if (!d->visibleChangeMode)
- d->visibleChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
- break;
- case ItemVisibleHasChanged:
- if (d->widget && d->visibleChangeMode != QGraphicsProxyWidgetPrivate::WidgetToProxyMode)
- d->widget->setVisible(isVisible());
- if (d->visibleChangeMode == QGraphicsProxyWidgetPrivate::ProxyToWidgetMode)
- d->visibleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
- break;
- case ItemEnabledChange:
- if (!d->enabledChangeMode)
- d->enabledChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
- break;
- case ItemEnabledHasChanged:
- if (d->widget && d->enabledChangeMode != QGraphicsProxyWidgetPrivate::WidgetToProxyMode)
- d->widget->setEnabled(isEnabled());
- if (d->enabledChangeMode == QGraphicsProxyWidgetPrivate::ProxyToWidgetMode)
- d->enabledChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
- break;
- default:
- break;
- }
- return QGraphicsWidget::itemChange(change, value);
-}
-
-/*!
- \reimp
-*/
-bool QGraphicsProxyWidget::event(QEvent *event)
-{
- Q_D(QGraphicsProxyWidget);
- if (!d->widget)
- return QGraphicsWidget::event(event);
-
- switch (event->type()) {
- case QEvent::StyleChange:
- // Propagate style changes to the embedded widget.
- if (!d->styleChangeMode) {
- d->styleChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
- d->widget->setStyle(style());
- d->styleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
- }
- break;
- case QEvent::FontChange: {
- // Propagate to widget.
- QWidgetPrivate *wd = d->widget->d_func();
- int mask = d->font.resolve() | d->inheritedFontResolveMask;
- wd->inheritedFontResolveMask = mask;
- wd->resolveFont();
- break;
- }
- case QEvent::PaletteChange: {
- // Propagate to widget.
- QWidgetPrivate *wd = d->widget->d_func();
- int mask = d->palette.resolve() | d->inheritedPaletteResolveMask;
- wd->inheritedPaletteResolveMask = mask;
- wd->resolvePalette();
- break;
- }
- case QEvent::InputMethod: {
- // Forward input method events if the focus widget enables
- // input methods.
- // ### Qt 4.5: this code must also go into a reimplementation
- // of inputMethodEvent().
- QWidget *focusWidget = d->widget->focusWidget();
- if (focusWidget && focusWidget->testAttribute(Qt::WA_InputMethodEnabled))
- QApplication::sendEvent(focusWidget, event);
- break;
- }
- case QEvent::ShortcutOverride: {
- QWidget *focusWidget = d->widget->focusWidget();
- while (focusWidget) {
- QApplication::sendEvent(focusWidget, event);
- if (event->isAccepted())
- return true;
- focusWidget = focusWidget->parentWidget();
- }
- return false;
- }
- case QEvent::KeyPress: {
- QKeyEvent *k = static_cast<QKeyEvent *>(event);
- if (k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) {
- if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier?
- QWidget *focusWidget = d->widget->focusWidget();
- while (focusWidget) {
- bool res = QApplication::sendEvent(focusWidget, event);
- if ((res && event->isAccepted()) || (isWindow() && focusWidget == d->widget)) {
- event->accept();
- break;
- }
- focusWidget = focusWidget->parentWidget();
- }
- return true;
- }
- }
- break;
- }
-#ifndef QT_NO_TOOLTIP
- case QEvent::GraphicsSceneHelp: {
- // Propagate the help event (for tooltip) to the widget under mouse
- if (d->lastWidgetUnderMouse) {
- QGraphicsSceneHelpEvent *he = static_cast<QGraphicsSceneHelpEvent *>(event);
- QPoint pos = d->mapToReceiver(mapFromScene(he->scenePos()), d->lastWidgetUnderMouse).toPoint();
- QHelpEvent e(QEvent::ToolTip, pos, he->screenPos());
- QApplication::sendEvent(d->lastWidgetUnderMouse, &e);
- event->setAccepted(e.isAccepted());
- return e.isAccepted();
- }
- break;
- }
- case QEvent::ToolTipChange: {
- // Propagate tooltip change to the widget
- if (!d->tooltipChangeMode) {
- d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
- d->widget->setToolTip(toolTip());
- d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
- }
- break;
- }
-#endif
- default:
- break;
- }
- return QGraphicsWidget::event(event);
-}
-
-/*!
- \reimp
-*/
-bool QGraphicsProxyWidget::eventFilter(QObject *object, QEvent *event)
-{
- Q_D(QGraphicsProxyWidget);
-
- if (object == d->widget) {
- switch (event->type()) {
- case QEvent::LayoutRequest:
- updateGeometry();
- break;
- case QEvent::Resize:
- // If the widget resizes itself, we resize the proxy too.
- // Prevent feed-back by checking the geometry change mode.
- if (!d->sizeChangeMode)
- d->updateProxyGeometryFromWidget();
- break;
- case QEvent::Move:
- // If the widget moves itself, we move the proxy too. Prevent
- // feed-back by checking the geometry change mode.
- if (!d->posChangeMode)
- d->updateProxyGeometryFromWidget();
- break;
- case QEvent::Hide:
- case QEvent::Show:
- // If the widget toggles its visible state, the proxy will follow.
- if (!d->visibleChangeMode) {
- d->visibleChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
- setVisible(event->type() == QEvent::Show);
- d->visibleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
- }
- break;
- case QEvent::EnabledChange:
- // If the widget toggles its enabled state, the proxy will follow.
- if (!d->enabledChangeMode) {
- d->enabledChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
- setEnabled(d->widget->isEnabled());
- d->enabledChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
- }
- break;
- case QEvent::StyleChange:
- // Propagate style changes to the proxy.
- if (!d->styleChangeMode) {
- d->styleChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
- setStyle(d->widget->style());
- d->styleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
- }
- break;
-#ifndef QT_NO_TOOLTIP
- case QEvent::ToolTipChange:
- // Propagate tooltip change to the proxy.
- if (!d->tooltipChangeMode) {
- d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
- setToolTip(d->widget->toolTip());
- d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
- }
- break;
-#endif
- default:
- break;
- }
- }
- return QGraphicsWidget::eventFilter(object, event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsProxyWidget::showEvent(QShowEvent *event)
-{
- Q_UNUSED(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsProxyWidget::hideEvent(QHideEvent *event)
-{
- Q_UNUSED(event);
-}
-
-#ifndef QT_NO_CONTEXTMENU
-/*!
- \reimp
-*/
-void QGraphicsProxyWidget::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
-{
- Q_D(QGraphicsProxyWidget);
- if (!event || !d->widget || !d->widget->isVisible() || !hasFocus())
- return;
-
- // Find widget position and receiver.
- QPointF pos = event->pos();
- QPointer<QWidget> alienWidget = d->widget->childAt(pos.toPoint());
- QPointer<QWidget> receiver = alienWidget ? alienWidget : d->widget;
-
- // Map event position from us to the receiver
- pos = d->mapToReceiver(pos, receiver);
-
- QPoint globalPos = receiver->mapToGlobal(pos.toPoint());
- //If the receiver by-pass the proxy its popups
- //will be top level QWidgets therefore they need
- //the screen position. mapToGlobal expect the widget to
- //have proper coordinates in regards of the windowing system
- //but it's not true because the widget is embedded.
- if (bypassGraphicsProxyWidget(receiver))
- globalPos = event->screenPos();
-
- // Send mouse event. ### Doesn't propagate the event.
- QContextMenuEvent contextMenuEvent(QContextMenuEvent::Reason(event->reason()),
- pos.toPoint(), globalPos, event->modifiers());
- QApplication::sendEvent(receiver, &contextMenuEvent);
-
- event->setAccepted(contextMenuEvent.isAccepted());
-}
-#endif // QT_NO_CONTEXTMENU
-
-#ifndef QT_NO_DRAGANDDROP
-/*!
- \reimp
-*/
-void QGraphicsProxyWidget::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
-{
-#ifdef QT_NO_DRAGANDDROP
- Q_UNUSED(event);
-#else
- Q_D(QGraphicsProxyWidget);
- if (!d->widget)
- return;
-
- QDragEnterEvent proxyDragEnter(event->pos().toPoint(), event->dropAction(), event->mimeData(), event->buttons(), event->modifiers());
- proxyDragEnter.setAccepted(event->isAccepted());
- QApplication::sendEvent(d->widget, &proxyDragEnter);
- event->setAccepted(proxyDragEnter.isAccepted());
- if (proxyDragEnter.isAccepted()) // we discard answerRect
- event->setDropAction(proxyDragEnter.dropAction());
-#endif
-}
-/*!
- \reimp
-*/
-void QGraphicsProxyWidget::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
-{
- Q_UNUSED(event);
-#ifndef QT_NO_DRAGANDDROP
- Q_D(QGraphicsProxyWidget);
- if (!d->widget || !d->dragDropWidget)
- return;
- QDragLeaveEvent proxyDragLeave;
- QApplication::sendEvent(d->dragDropWidget, &proxyDragLeave);
- d->dragDropWidget = 0;
-#endif
-}
-
-/*!
- \reimp
-*/
-void QGraphicsProxyWidget::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
-{
-#ifdef QT_NO_DRAGANDDROP
- Q_UNUSED(event);
-#else
- Q_D(QGraphicsProxyWidget);
- if (!d->widget)
- return;
- QPointF p = event->pos();
- event->ignore();
- QPointer<QWidget> subWidget = d->widget->childAt(p.toPoint());
- QPointer<QWidget> receiver = subWidget ? subWidget : d->widget;
- bool eventDelivered = false;
- for (; receiver; receiver = receiver->parentWidget()) {
- if (!receiver->isEnabled() || !receiver->acceptDrops())
- continue;
- // Map event position from us to the receiver
- QPoint receiverPos = d->mapToReceiver(p, receiver).toPoint();
- if (receiver != d->dragDropWidget) {
- // Try to enter before we leave
- QDragEnterEvent dragEnter(receiverPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers());
- dragEnter.setDropAction(event->proposedAction());
- QApplication::sendEvent(receiver, &dragEnter);
- event->setAccepted(dragEnter.isAccepted());
- event->setDropAction(dragEnter.dropAction());
- if (!event->isAccepted()) {
- // propagate to the parent widget
- continue;
- }
-
- d->lastDropAction = event->dropAction();
-
- if (d->dragDropWidget) {
- QDragLeaveEvent dragLeave;
- QApplication::sendEvent(d->dragDropWidget, &dragLeave);
- }
- d->dragDropWidget = receiver;
- }
-
- QDragMoveEvent dragMove(receiverPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers());
- event->setDropAction(d->lastDropAction);
- QApplication::sendEvent(receiver, &dragMove);
- event->setAccepted(dragMove.isAccepted());
- event->setDropAction(dragMove.dropAction());
- if (event->isAccepted())
- d->lastDropAction = event->dropAction();
- eventDelivered = true;
- break;
- }
-
- if (!eventDelivered) {
- if (d->dragDropWidget) {
- // Leave the last drag drop item
- QDragLeaveEvent dragLeave;
- QApplication::sendEvent(d->dragDropWidget, &dragLeave);
- d->dragDropWidget = 0;
- }
- // Propagate
- event->setDropAction(Qt::IgnoreAction);
- }
-#endif
-}
-
-/*!
- \reimp
-*/
-void QGraphicsProxyWidget::dropEvent(QGraphicsSceneDragDropEvent *event)
-{
-#ifdef QT_NO_DRAGANDDROP
- Q_UNUSED(event);
-#else
- Q_D(QGraphicsProxyWidget);
- if (d->widget && d->dragDropWidget) {
- QPoint widgetPos = d->mapToReceiver(event->pos(), d->dragDropWidget).toPoint();
- QDropEvent dropEvent(widgetPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers());
- QApplication::sendEvent(d->dragDropWidget, &dropEvent);
- event->setAccepted(dropEvent.isAccepted());
- d->dragDropWidget = 0;
- }
-#endif
-}
-#endif
-
-/*!
- \reimp
-*/
-void QGraphicsProxyWidget::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
-{
- Q_UNUSED(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsProxyWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
-{
- Q_UNUSED(event);
- Q_D(QGraphicsProxyWidget);
- // If hoverMove was compressed away, make sure we update properly here.
- if (d->lastWidgetUnderMouse) {
- QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse);
- d->lastWidgetUnderMouse = 0;
- }
-}
-
-/*!
- \reimp
-*/
-void QGraphicsProxyWidget::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
-{
- Q_D(QGraphicsProxyWidget);
-#ifdef GRAPHICSPROXYWIDGET_DEBUG
- qDebug() << "QGraphicsProxyWidget::hoverMoveEvent";
-#endif
- // Ignore events on the window frame.
- if (!d->widget || !rect().contains(event->pos())) {
- if (d->lastWidgetUnderMouse) {
- QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse);
- d->lastWidgetUnderMouse = 0;
- }
- return;
- }
-
- d->embeddedMouseGrabber = 0;
- d->sendWidgetMouseEvent(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsProxyWidget::grabMouseEvent(QEvent *event)
-{
- Q_UNUSED(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsProxyWidget::ungrabMouseEvent(QEvent *event)
-{
- Q_D(QGraphicsProxyWidget);
- Q_UNUSED(event);
- d->embeddedMouseGrabber = 0;
-}
-
-/*!
- \reimp
-*/
-void QGraphicsProxyWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QGraphicsProxyWidget);
-#ifdef GRAPHICSPROXYWIDGET_DEBUG
- qDebug() << "QGraphicsProxyWidget::mouseMoveEvent";
-#endif
- d->sendWidgetMouseEvent(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsProxyWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QGraphicsProxyWidget);
-#ifdef GRAPHICSPROXYWIDGET_DEBUG
- qDebug() << "QGraphicsProxyWidget::mousePressEvent";
-#endif
- d->sendWidgetMouseEvent(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsProxyWidget::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QGraphicsProxyWidget);
-#ifdef GRAPHICSPROXYWIDGET_DEBUG
- qDebug() << "QGraphicsProxyWidget::mouseDoubleClickEvent";
-#endif
- d->sendWidgetMouseEvent(event);
-}
-
-/*!
- \reimp
-*/
-#ifndef QT_NO_WHEELEVENT
-void QGraphicsProxyWidget::wheelEvent(QGraphicsSceneWheelEvent *event)
-{
- Q_D(QGraphicsProxyWidget);
-#ifdef GRAPHICSPROXYWIDGET_DEBUG
- qDebug() << "QGraphicsProxyWidget::wheelEvent";
-#endif
- if (!d->widget)
- return;
-
- QPointF pos = event->pos();
- QPointer<QWidget> receiver = d->widget->childAt(pos.toPoint());
- if (!receiver)
- receiver = d->widget;
-
- // Map event position from us to the receiver
- pos = d->mapToReceiver(pos, receiver);
-
- // Send mouse event.
- QWheelEvent wheelEvent(pos.toPoint(), event->screenPos(), event->delta(),
- event->buttons(), event->modifiers(), event->orientation());
- QPointer<QWidget> focusWidget = d->widget->focusWidget();
- extern bool qt_sendSpontaneousEvent(QObject *, QEvent *);
- qt_sendSpontaneousEvent(receiver, &wheelEvent);
- event->setAccepted(wheelEvent.isAccepted());
-
- // ### Remove, this should be done by proper focusIn/focusOut events.
- if (focusWidget && !focusWidget->hasFocus()) {
- focusWidget->update();
- focusWidget = d->widget->focusWidget();
- if (focusWidget && focusWidget->hasFocus())
- focusWidget->update();
- }
-}
-#endif
-
-/*!
- \reimp
-*/
-void QGraphicsProxyWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_D(QGraphicsProxyWidget);
-#ifdef GRAPHICSPROXYWIDGET_DEBUG
- qDebug() << "QGraphicsProxyWidget::mouseReleaseEvent";
-#endif
- d->sendWidgetMouseEvent(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsProxyWidget::keyPressEvent(QKeyEvent *event)
-{
- Q_D(QGraphicsProxyWidget);
-#ifdef GRAPHICSPROXYWIDGET_DEBUG
- qDebug() << "QGraphicsProxyWidget::keyPressEvent";
-#endif
- d->sendWidgetKeyEvent(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsProxyWidget::keyReleaseEvent(QKeyEvent *event)
-{
- Q_D(QGraphicsProxyWidget);
-#ifdef GRAPHICSPROXYWIDGET_DEBUG
- qDebug() << "QGraphicsProxyWidget::keyReleaseEvent";
-#endif
- d->sendWidgetKeyEvent(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsProxyWidget::focusInEvent(QFocusEvent *event)
-{
-#ifdef GRAPHICSPROXYWIDGET_DEBUG
- qDebug() << "QGraphicsProxyWidget::focusInEvent";
-#endif
- Q_D(QGraphicsProxyWidget);
-
- if (d->focusFromWidgetToProxy) {
- // Prevent recursion when the proxy autogains focus through the
- // embedded widget calling setFocus(). ### Could be done with event
- // filter on FocusIn instead?
- return;
- }
-
- d->proxyIsGivingFocus = true;
-
- switch (event->reason()) {
- case Qt::TabFocusReason: {
- if (QWidget *focusChild = d->findFocusChild(0, true))
- focusChild->setFocus(event->reason());
- break;
- }
- case Qt::BacktabFocusReason:
- if (QWidget *focusChild = d->findFocusChild(0, false))
- focusChild->setFocus(event->reason());
- break;
- default:
- if (d->widget && d->widget->focusWidget()) {
- d->widget->focusWidget()->setFocus(event->reason());
- }
- break;
- }
-
- d->proxyIsGivingFocus = false;
-}
-
-/*!
- \reimp
-*/
-void QGraphicsProxyWidget::focusOutEvent(QFocusEvent *event)
-{
-#ifdef GRAPHICSPROXYWIDGET_DEBUG
- qDebug() << "QGraphicsProxyWidget::focusOutEvent";
-#endif
- Q_D(QGraphicsProxyWidget);
- if (d->widget) {
- // We need to explicitly remove subfocus from the embedded widget's
- // focus widget.
- if (QWidget *focusWidget = d->widget->focusWidget())
- d->removeSubFocusHelper(focusWidget, event->reason());
- }
-}
-
-/*!
- \reimp
-*/
-bool QGraphicsProxyWidget::focusNextPrevChild(bool next)
-{
- Q_D(QGraphicsProxyWidget);
- if (!d->widget || !d->scene)
- return QGraphicsWidget::focusNextPrevChild(next);
-
- Qt::FocusReason reason = next ? Qt::TabFocusReason : Qt::BacktabFocusReason;
- QWidget *lastFocusChild = d->widget->focusWidget();
- if (QWidget *newFocusChild = d->findFocusChild(lastFocusChild, next)) {
- newFocusChild->setFocus(reason);
- return true;
- }
-
- return QGraphicsWidget::focusNextPrevChild(next);
-}
-
-/*!
- \reimp
-*/
-QSizeF QGraphicsProxyWidget::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
-{
- Q_D(const QGraphicsProxyWidget);
- if (!d->widget)
- return QGraphicsWidget::sizeHint(which, constraint);
-
- QSizeF sh;
- switch (which) {
- case Qt::PreferredSize:
- if (QLayout *l = d->widget->layout())
- sh = l->sizeHint();
- else
- sh = d->widget->sizeHint();
- break;
- case Qt::MinimumSize:
- if (QLayout *l = d->widget->layout())
- sh = l->minimumSize();
- else
- sh = d->widget->minimumSizeHint();
- break;
- case Qt::MaximumSize:
- if (QLayout *l = d->widget->layout())
- sh = l->maximumSize();
- else
- sh = QSizeF(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
- break;
- case Qt::MinimumDescent:
- sh = constraint;
- break;
- default:
- break;
- }
- return sh;
-}
-
-/*!
- \reimp
-*/
-void QGraphicsProxyWidget::resizeEvent(QGraphicsSceneResizeEvent *event)
-{
- Q_D(QGraphicsProxyWidget);
- if (d->widget) {
- if (d->sizeChangeMode != QGraphicsProxyWidgetPrivate::WidgetToProxyMode)
- d->widget->resize(event->newSize().toSize());
- }
- QGraphicsWidget::resizeEvent(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsProxyWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
-{
- Q_D(QGraphicsProxyWidget);
- Q_UNUSED(widget);
- if (!d->widget || !d->widget->isVisible())
- return;
-
- // Filter out repaints on the window frame.
- const QRect exposedWidgetRect = (option->exposedRect & rect()).toAlignedRect();
- if (exposedWidgetRect.isEmpty())
- return;
-
- // Disable QPainter's default pen being cosmetic. This allows widgets and
- // styles to follow Qt's existing defaults without getting ugly cosmetic
- // lines when scaled.
- bool restore = !(painter->renderHints() & QPainter::NonCosmeticDefaultPen);
- painter->setRenderHints(QPainter::NonCosmeticDefaultPen, true);
-
- d->widget->render(painter, exposedWidgetRect.topLeft(), exposedWidgetRect);
-
- // Restore the render hints if necessary.
- if (restore)
- painter->setRenderHints(QPainter::NonCosmeticDefaultPen, false);
-}
-
-/*!
- \reimp
-*/
-int QGraphicsProxyWidget::type() const
-{
- return Type;
-}
-
-/*!
- \since 4.5
-
- Creates a proxy widget for the given \a child of the widget
- contained in this proxy.
-
- This function makes it possible to acquire proxies for
- non top-level widgets. For instance, you can embed a dialog,
- and then transform only one of its widgets.
-
- If the widget is already embedded, return the existing proxy widget.
-
- \sa newProxyWidget(), QGraphicsScene::addWidget()
-*/
-QGraphicsProxyWidget *QGraphicsProxyWidget::createProxyForChildWidget(QWidget *child)
-{
- QGraphicsProxyWidget *proxy = child->graphicsProxyWidget();
- if (proxy)
- return proxy;
- if (!child->parentWidget()) {
- qWarning("QGraphicsProxyWidget::createProxyForChildWidget: top-level widget not in a QGraphicsScene");
- return 0;
- }
-
- QGraphicsProxyWidget *parentProxy = createProxyForChildWidget(child->parentWidget());
- if (!parentProxy)
- return 0;
-
- if (!QMetaObject::invokeMethod(parentProxy, "newProxyWidget", Qt::DirectConnection,
- Q_RETURN_ARG(QGraphicsProxyWidget*, proxy), Q_ARG(const QWidget*, child)))
- return 0;
- proxy->setParent(parentProxy);
- proxy->setWidget(child);
- return proxy;
-}
-
-/*!
- \fn QGraphicsProxyWidget *QGraphicsProxyWidget::newProxyWidget(const QWidget *child)
- \since 4.5
-
- Creates a proxy widget for the given \a child of the widget contained in this
- proxy.
-
- You should not call this function directly; use
- QGraphicsProxyWidget::createProxyForChildWidget() instead.
-
- This function is a fake virtual slot that you can reimplement in
- your subclass in order to control how new proxy widgets are
- created. The default implementation returns a proxy created with
- the QGraphicsProxyWidget() constructor with this proxy widget as
- the parent.
-
- \sa createProxyForChildWidget()
-*/
-QGraphicsProxyWidget *QGraphicsProxyWidget::newProxyWidget(const QWidget *)
-{
- return new QGraphicsProxyWidget(this);
-}
-
-
-
-QT_END_NAMESPACE
-
-#include "moc_qgraphicsproxywidget.cpp"
-
-#endif //QT_NO_GRAPHICSVIEW
diff --git a/src/gui/graphicsview/qgraphicsproxywidget.h b/src/gui/graphicsview/qgraphicsproxywidget.h
deleted file mode 100644
index b2ffe2f7d1..0000000000
--- a/src/gui/graphicsview/qgraphicsproxywidget.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSPROXYWIDGET_H
-#define QGRAPHICSPROXYWIDGET_H
-
-#include <QtGui/qgraphicswidget.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
-
-class QGraphicsProxyWidgetPrivate;
-
-class Q_GUI_EXPORT QGraphicsProxyWidget : public QGraphicsWidget
-{
- Q_OBJECT
-public:
- QGraphicsProxyWidget(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
- ~QGraphicsProxyWidget();
-
- void setWidget(QWidget *widget);
- QWidget *widget() const;
-
- QRectF subWidgetRect(const QWidget *widget) const;
-
- void setGeometry(const QRectF &rect);
-
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
-
- enum {
- Type = 12
- };
- int type() const;
-
- QGraphicsProxyWidget *createProxyForChildWidget(QWidget *child);
-
-protected:
- QVariant itemChange(GraphicsItemChange change, const QVariant &value);
-
- bool event(QEvent *event);
- bool eventFilter(QObject *object, QEvent *event);
-
- void showEvent(QShowEvent *event);
- void hideEvent(QHideEvent *event);
-
-#ifndef QT_NO_CONTEXTMENU
- void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
-#endif
-
-#ifndef QT_NO_DRAGANDDROP
- void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
- void dragLeaveEvent(QGraphicsSceneDragDropEvent *event);
- void dragMoveEvent(QGraphicsSceneDragDropEvent *event);
- void dropEvent(QGraphicsSceneDragDropEvent *event);
-#endif
-
- void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
- void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
- void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
- void grabMouseEvent(QEvent *event);
- void ungrabMouseEvent(QEvent *event);
-
- void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
- void mousePressEvent(QGraphicsSceneMouseEvent *event);
- void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
- void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
-#ifndef QT_NO_WHEELEVENT
- void wheelEvent(QGraphicsSceneWheelEvent *event);
-#endif
-
- void keyPressEvent(QKeyEvent *event);
- void keyReleaseEvent(QKeyEvent *event);
-
- void focusInEvent(QFocusEvent *event);
- void focusOutEvent(QFocusEvent *event);
- bool focusNextPrevChild(bool next);
- // ### Qt 4.5:
- // QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
- // void inputMethodEvent(QInputMethodEvent *event);
-
- QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
- void resizeEvent(QGraphicsSceneResizeEvent *event);
-
-protected Q_SLOTS:
- QGraphicsProxyWidget *newProxyWidget(const QWidget *);
-
-private:
- Q_DISABLE_COPY(QGraphicsProxyWidget)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QGraphicsProxyWidget)
- Q_PRIVATE_SLOT(d_func(), void _q_removeWidgetSlot())
-
- friend class QWidget;
- friend class QWidgetPrivate;
- friend class QGraphicsItem;
-};
-
-#endif
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
-
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
deleted file mode 100644
index ba4c9148a0..0000000000
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ /dev/null
@@ -1,6503 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \class QGraphicsScene
- \brief The QGraphicsScene class provides a surface for managing a large
- number of 2D graphical items.
- \since 4.2
- \ingroup graphicsview-api
-
-
- The class serves as a container for QGraphicsItems. It is used together
- with QGraphicsView for visualizing graphical items, such as lines,
- rectangles, text, or even custom items, on a 2D surface. QGraphicsScene is
- part of the \l{Graphics View Framework}.
-
- QGraphicsScene also provides functionality that lets you efficiently
- determine both the location of items, and for determining what items are
- visible within an arbitrary area on the scene. With the QGraphicsView
- widget, you can either visualize the whole scene, or zoom in and view only
- parts of the scene.
-
- Example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp 0
-
- Note that QGraphicsScene has no visual appearance of its own; it only
- manages the items. You need to create a QGraphicsView widget to visualize
- the scene.
-
- To add items to a scene, you start off by constructing a QGraphicsScene
- object. Then, you have two options: either add your existing QGraphicsItem
- objects by calling addItem(), or you can call one of the convenience
- functions addEllipse(), addLine(), addPath(), addPixmap(), addPolygon(),
- addRect(), or addText(), which all return a pointer to the newly added item.
- The dimensions of the items added with these functions are relative to the
- item's coordinate system, and the items position is initialized to (0,
- 0) in the scene.
-
- You can then visualize the scene using QGraphicsView. When the scene
- changes, (e.g., when an item moves or is transformed) QGraphicsScene
- emits the changed() signal. To remove an item, call removeItem().
-
- QGraphicsScene uses an indexing algorithm to manage the location of items
- efficiently. By default, a BSP (Binary Space Partitioning) tree is used; an
- algorithm suitable for large scenes where most items remain static (i.e.,
- do not move around). You can choose to disable this index by calling
- setItemIndexMethod(). For more information about the available indexing
- algorithms, see the itemIndexMethod property.
-
- The scene's bounding rect is set by calling setSceneRect(). Items can be
- placed at any position on the scene, and the size of the scene is by
- default unlimited. The scene rect is used only for internal bookkeeping,
- maintaining the scene's item index. If the scene rect is unset,
- QGraphicsScene will use the bounding area of all items, as returned by
- itemsBoundingRect(), as the scene rect. However, itemsBoundingRect() is a
- relatively time consuming function, as it operates by collecting
- positional information for every item on the scene. Because of this, you
- should always set the scene rect when operating on large scenes.
-
- One of QGraphicsScene's greatest strengths is its ability to efficiently
- determine the location of items. Even with millions of items on the scene,
- the items() functions can determine the location of an item within few
- milliseconds. There are several overloads to items(): one that finds items
- at a certain position, one that finds items inside or intersecting with a
- polygon or a rectangle, and more. The list of returned items is sorted by
- stacking order, with the topmost item being the first item in the list.
- For convenience, there is also an itemAt() function that returns the
- topmost item at a given position.
-
- QGraphicsScene maintains selection information for the scene. To select
- items, call setSelectionArea(), and to clear the current selection, call
- clearSelection(). Call selectedItems() to get the list of all selected
- items.
-
- \section1 Event Handling and Propagation
-
- Another responsibility that QGraphicsScene has, is to propagate events
- from QGraphicsView. To send an event to a scene, you construct an event
- that inherits QEvent, and then send it using, for example,
- QApplication::sendEvent(). event() is responsible for dispatching
- the event to the individual items. Some common events are handled by
- convenience event handlers. For example, key press events are handled by
- keyPressEvent(), and mouse press events are handled by mousePressEvent().
-
- Key events are delivered to the \e {focus item}. To set the focus item,
- you can either call setFocusItem(), passing an item that accepts focus, or
- the item itself can call QGraphicsItem::setFocus(). Call focusItem() to
- get the current focus item. For compatibility with widgets, the scene also
- maintains its own focus information. By default, the scene does not have
- focus, and all key events are discarded. If setFocus() is called, or if an
- item on the scene gains focus, the scene automatically gains focus. If the
- scene has focus, hasFocus() will return true, and key events will be
- forwarded to the focus item, if any. If the scene loses focus, (i.e.,
- someone calls clearFocus()) while an item has focus, the scene will
- maintain its item focus information, and once the scene regains focus, it
- will make sure the last focus item regains focus.
-
- For mouse-over effects, QGraphicsScene dispatches \e {hover
- events}. If an item accepts hover events (see
- QGraphicsItem::acceptHoverEvents()), it will receive a \l
- {QEvent::}{GraphicsSceneHoverEnter} event when the mouse enters
- its area. As the mouse continues moving inside the item's area,
- QGraphicsScene will send it \l {QEvent::}{GraphicsSceneHoverMove}
- events. When the mouse leaves the item's area, the item will
- receive a \l {QEvent::}{GraphicsSceneHoverLeave} event.
-
- All mouse events are delivered to the current \e {mouse grabber}
- item. An item becomes the scene's mouse grabber if it accepts
- mouse events (see QGraphicsItem::acceptedMouseButtons()) and it
- receives a mouse press. It stays the mouse grabber until it
- receives a mouse release when no other mouse buttons are
- pressed. You can call mouseGrabberItem() to determine what item is
- currently grabbing the mouse.
-
- \sa QGraphicsItem, QGraphicsView
-*/
-
-/*!
- \enum QGraphicsScene::SceneLayer
- \since 4.3
-
- This enum describes the rendering layers in a QGraphicsScene. When
- QGraphicsScene draws the scene contents, it renders each of these layers
- separately, in order.
-
- Each layer represents a flag that can be OR'ed together when calling
- functions such as invalidate() or QGraphicsView::invalidateScene().
-
- \value ItemLayer The item layer. QGraphicsScene renders all items are in
- this layer by calling the virtual function drawItems(). The item layer is
- drawn after the background layer, but before the foreground layer.
-
- \value BackgroundLayer The background layer. QGraphicsScene renders the
- scene's background in this layer by calling the virtual function
- drawBackground(). The background layer is drawn first of all layers.
-
- \value ForegroundLayer The foreground layer. QGraphicsScene renders the
- scene's foreground in this layer by calling the virtual function
- drawForeground(). The foreground layer is drawn last of all layers.
-
- \value AllLayers All layers; this value represents a combination of all
- three layers.
-
- \sa invalidate(), QGraphicsView::invalidateScene()
-*/
-
-/*!
- \enum QGraphicsScene::ItemIndexMethod
-
- This enum describes the indexing algorithms QGraphicsScene provides for
- managing positional information about items on the scene.
-
- \value BspTreeIndex A Binary Space Partitioning tree is applied. All
- QGraphicsScene's item location algorithms are of an order close to
- logarithmic complexity, by making use of binary search. Adding, moving and
- removing items is logarithmic. This approach is best for static scenes
- (i.e., scenes where most items do not move).
-
- \value NoIndex No index is applied. Item location is of linear complexity,
- as all items on the scene are searched. Adding, moving and removing items,
- however, is done in constant time. This approach is ideal for dynamic
- scenes, where many items are added, moved or removed continuously.
-
- \sa setItemIndexMethod(), bspTreeDepth
-*/
-
-#include "qgraphicsscene.h"
-
-#ifndef QT_NO_GRAPHICSVIEW
-
-#include "qgraphicsitem.h"
-#include "qgraphicsitem_p.h"
-#include "qgraphicslayout.h"
-#include "qgraphicsscene_p.h"
-#include "qgraphicssceneevent.h"
-#include "qgraphicsview.h"
-#include "qgraphicsview_p.h"
-#include "qgraphicswidget.h"
-#include "qgraphicswidget_p.h"
-#include "qgraphicssceneindex_p.h"
-#include "qgraphicsscenebsptreeindex_p.h"
-#include "qgraphicsscenelinearindex_p.h"
-
-#include <QtCore/qdebug.h>
-#include <QtCore/qlist.h>
-#include <QtCore/qmath.h>
-#include <QtCore/qrect.h>
-#include <QtCore/qset.h>
-#include <QtCore/qstack.h>
-#include <QtCore/qtimer.h>
-#include <QtCore/qvarlengtharray.h>
-#include <QtCore/QMetaMethod>
-#include <QtGui/qapplication.h>
-#include <QtGui/qdesktopwidget.h>
-#include <QtGui/qevent.h>
-#include <QtGui/qgraphicslayout.h>
-#include <QtGui/qgraphicsproxywidget.h>
-#include <QtGui/qgraphicswidget.h>
-#include <QtGui/qmatrix.h>
-#include <QtGui/qpaintengine.h>
-#include <QtGui/qpainter.h>
-#include <QtGui/qpixmapcache.h>
-#include <QtGui/qpolygon.h>
-#include <QtGui/qstyleoption.h>
-#include <QtGui/qtooltip.h>
-#include <QtGui/qtransform.h>
-#include <QtGui/qinputcontext.h>
-#include <QtGui/qgraphicseffect.h>
-#ifndef QT_NO_ACCESSIBILITY
-# include <QtGui/qaccessible.h>
-#endif
-
-#include <private/qapplication_p.h>
-#include <private/qobject_p.h>
-#ifdef Q_WS_X11
-#include <private/qt_x11_p.h>
-#endif
-#include <private/qgraphicseffect_p.h>
-#include <private/qgesturemanager_p.h>
-#include <private/qpathclipper_p.h>
-
-// #define GESTURE_DEBUG
-#ifndef GESTURE_DEBUG
-# define DEBUG if (0) qDebug
-#else
-# define DEBUG qDebug
-#endif
-
-QT_BEGIN_NAMESPACE
-
-bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event);
-
-static void _q_hoverFromMouseEvent(QGraphicsSceneHoverEvent *hover, const QGraphicsSceneMouseEvent *mouseEvent)
-{
- hover->setWidget(mouseEvent->widget());
- hover->setPos(mouseEvent->pos());
- hover->setScenePos(mouseEvent->scenePos());
- hover->setScreenPos(mouseEvent->screenPos());
- hover->setLastPos(mouseEvent->lastPos());
- hover->setLastScenePos(mouseEvent->lastScenePos());
- hover->setLastScreenPos(mouseEvent->lastScreenPos());
- hover->setModifiers(mouseEvent->modifiers());
- hover->setAccepted(mouseEvent->isAccepted());
-}
-
-/*!
- \internal
-*/
-QGraphicsScenePrivate::QGraphicsScenePrivate()
- : indexMethod(QGraphicsScene::BspTreeIndex),
- index(0),
- lastItemCount(0),
- hasSceneRect(false),
- dirtyGrowingItemsBoundingRect(true),
- updateAll(false),
- calledEmitUpdated(false),
- processDirtyItemsEmitted(false),
- needSortTopLevelItems(true),
- holesInTopLevelSiblingIndex(false),
- topLevelSequentialOrdering(true),
- scenePosDescendantsUpdatePending(false),
- stickyFocus(false),
- hasFocus(false),
- lastMouseGrabberItemHasImplicitMouseGrab(false),
- allItemsIgnoreHoverEvents(true),
- allItemsUseDefaultCursor(true),
- painterStateProtection(true),
- sortCacheEnabled(false),
- allItemsIgnoreTouchEvents(true),
- selectionChanging(0),
- rectAdjust(2),
- focusItem(0),
- lastFocusItem(0),
- passiveFocusItem(0),
- tabFocusFirst(0),
- activePanel(0),
- lastActivePanel(0),
- activationRefCount(0),
- childExplicitActivation(0),
- lastMouseGrabberItem(0),
- dragDropItem(0),
- enterWidget(0),
- lastDropAction(Qt::IgnoreAction),
- style(0)
-{
-}
-
-/*!
- \internal
-*/
-void QGraphicsScenePrivate::init()
-{
- Q_Q(QGraphicsScene);
-
- index = new QGraphicsSceneBspTreeIndex(q);
-
- // Keep this index so we can check for connected slots later on.
- changedSignalIndex = signalIndex("changed(QList<QRectF>)");
- processDirtyItemsIndex = q->metaObject()->indexOfSlot("_q_processDirtyItems()");
- polishItemsIndex = q->metaObject()->indexOfSlot("_q_polishItems()");
-
- qApp->d_func()->scene_list.append(q);
- q->update();
-}
-
-/*!
- \internal
-*/
-QGraphicsScenePrivate *QGraphicsScenePrivate::get(QGraphicsScene *q)
-{
- return q->d_func();
-}
-
-void QGraphicsScenePrivate::_q_emitUpdated()
-{
- Q_Q(QGraphicsScene);
- calledEmitUpdated = false;
-
- if (dirtyGrowingItemsBoundingRect) {
- if (!hasSceneRect) {
- const QRectF oldGrowingItemsBoundingRect = growingItemsBoundingRect;
- growingItemsBoundingRect |= q->itemsBoundingRect();
- if (oldGrowingItemsBoundingRect != growingItemsBoundingRect)
- emit q->sceneRectChanged(growingItemsBoundingRect);
- }
- dirtyGrowingItemsBoundingRect = false;
- }
-
- // Ensure all views are connected if anything is connected. This disables
- // the optimization that items send updates directly to the views, but it
- // needs to happen in order to keep compatibility with the behavior from
- // Qt 4.4 and backward.
- if (isSignalConnected(changedSignalIndex)) {
- for (int i = 0; i < views.size(); ++i) {
- QGraphicsView *view = views.at(i);
- if (!view->d_func()->connectedToScene) {
- view->d_func()->connectedToScene = true;
- q->connect(q, SIGNAL(changed(QList<QRectF>)),
- views.at(i), SLOT(updateScene(QList<QRectF>)));
- }
- }
- } else {
- if (views.isEmpty()) {
- updateAll = false;
- return;
- }
- for (int i = 0; i < views.size(); ++i)
- views.at(i)->d_func()->processPendingUpdates();
- // It's important that we update all views before we dispatch, hence two for-loops.
- for (int i = 0; i < views.size(); ++i)
- views.at(i)->d_func()->dispatchPendingUpdateRequests();
- return;
- }
-
- // Notify the changes to anybody interested.
- QList<QRectF> oldUpdatedRects;
- oldUpdatedRects = updateAll ? (QList<QRectF>() << q->sceneRect()) : updatedRects;
- updateAll = false;
- updatedRects.clear();
- emit q->changed(oldUpdatedRects);
-}
-
-/*!
- \internal
-
- ### This function is almost identical to QGraphicsItemPrivate::addChild().
-*/
-void QGraphicsScenePrivate::registerTopLevelItem(QGraphicsItem *item)
-{
- item->d_ptr->ensureSequentialSiblingIndex();
- needSortTopLevelItems = true; // ### maybe false
- item->d_ptr->siblingIndex = topLevelItems.size();
- topLevelItems.append(item);
-}
-
-/*!
- \internal
-
- ### This function is almost identical to QGraphicsItemPrivate::removeChild().
-*/
-void QGraphicsScenePrivate::unregisterTopLevelItem(QGraphicsItem *item)
-{
- if (!holesInTopLevelSiblingIndex)
- holesInTopLevelSiblingIndex = item->d_ptr->siblingIndex != topLevelItems.size() - 1;
- if (topLevelSequentialOrdering && !holesInTopLevelSiblingIndex)
- topLevelItems.removeAt(item->d_ptr->siblingIndex);
- else
- topLevelItems.removeOne(item);
- // NB! Do not use topLevelItems.removeAt(item->d_ptr->siblingIndex) because
- // the item is not guaranteed to be at the index after the list is sorted
- // (see ensureSortedTopLevelItems()).
- item->d_ptr->siblingIndex = -1;
- if (topLevelSequentialOrdering)
- topLevelSequentialOrdering = !holesInTopLevelSiblingIndex;
-}
-
-/*!
- \internal
-*/
-void QGraphicsScenePrivate::_q_polishItems()
-{
- if (unpolishedItems.isEmpty())
- return;
-
- const QVariant booleanTrueVariant(true);
- QGraphicsItem *item = 0;
- QGraphicsItemPrivate *itemd = 0;
- const int oldUnpolishedCount = unpolishedItems.count();
-
- for (int i = 0; i < oldUnpolishedCount; ++i) {
- item = unpolishedItems.at(i);
- if (!item)
- continue;
- itemd = item->d_ptr.data();
- itemd->pendingPolish = false;
- if (!itemd->explicitlyHidden) {
- item->itemChange(QGraphicsItem::ItemVisibleChange, booleanTrueVariant);
- item->itemChange(QGraphicsItem::ItemVisibleHasChanged, booleanTrueVariant);
- }
- if (itemd->isWidget) {
- QEvent event(QEvent::Polish);
- QApplication::sendEvent((QGraphicsWidget *)item, &event);
- }
- }
-
- if (unpolishedItems.count() == oldUnpolishedCount) {
- // No new items were added to the vector.
- unpolishedItems.clear();
- } else {
- // New items were appended; keep them and remove the old ones.
- unpolishedItems.remove(0, oldUnpolishedCount);
- unpolishedItems.squeeze();
- QMetaObject::invokeMethod(q_ptr, "_q_polishItems", Qt::QueuedConnection);
- }
-}
-
-void QGraphicsScenePrivate::_q_processDirtyItems()
-{
- processDirtyItemsEmitted = false;
-
- if (updateAll) {
- Q_ASSERT(calledEmitUpdated);
- // No need for further processing (except resetting the dirty states).
- // The growingItemsBoundingRect is updated in _q_emitUpdated.
- for (int i = 0; i < topLevelItems.size(); ++i)
- resetDirtyItem(topLevelItems.at(i), /*recursive=*/true);
- return;
- }
-
- const bool wasPendingSceneUpdate = calledEmitUpdated;
- const QRectF oldGrowingItemsBoundingRect = growingItemsBoundingRect;
-
- // Process items recursively.
- for (int i = 0; i < topLevelItems.size(); ++i)
- processDirtyItemsRecursive(topLevelItems.at(i));
-
- dirtyGrowingItemsBoundingRect = false;
- if (!hasSceneRect && oldGrowingItemsBoundingRect != growingItemsBoundingRect)
- emit q_func()->sceneRectChanged(growingItemsBoundingRect);
-
- if (wasPendingSceneUpdate)
- return;
-
- for (int i = 0; i < views.size(); ++i)
- views.at(i)->d_func()->processPendingUpdates();
-
- if (calledEmitUpdated) {
- // We did a compatibility QGraphicsScene::update in processDirtyItemsRecursive
- // and we cannot wait for the control to reach the eventloop before the
- // changed signal is emitted, so we emit it now.
- _q_emitUpdated();
- }
-
- // Immediately dispatch all pending update requests on the views.
- for (int i = 0; i < views.size(); ++i)
- views.at(i)->d_func()->dispatchPendingUpdateRequests();
-}
-
-/*!
- \internal
-*/
-void QGraphicsScenePrivate::setScenePosItemEnabled(QGraphicsItem *item, bool enabled)
-{
- QGraphicsItem *p = item->d_ptr->parent;
- while (p) {
- p->d_ptr->scenePosDescendants = enabled;
- p = p->d_ptr->parent;
- }
- if (!enabled && !scenePosDescendantsUpdatePending) {
- scenePosDescendantsUpdatePending = true;
- QMetaObject::invokeMethod(q_func(), "_q_updateScenePosDescendants", Qt::QueuedConnection);
- }
-}
-
-/*!
- \internal
-*/
-void QGraphicsScenePrivate::registerScenePosItem(QGraphicsItem *item)
-{
- scenePosItems.insert(item);
- setScenePosItemEnabled(item, true);
-}
-
-/*!
- \internal
-*/
-void QGraphicsScenePrivate::unregisterScenePosItem(QGraphicsItem *item)
-{
- scenePosItems.remove(item);
- setScenePosItemEnabled(item, false);
-}
-
-/*!
- \internal
-*/
-void QGraphicsScenePrivate::_q_updateScenePosDescendants()
-{
- foreach (QGraphicsItem *item, scenePosItems) {
- QGraphicsItem *p = item->d_ptr->parent;
- while (p) {
- p->d_ptr->scenePosDescendants = 1;
- p = p->d_ptr->parent;
- }
- }
- scenePosDescendantsUpdatePending = false;
-}
-
-/*!
- \internal
-
- Schedules an item for removal. This function leaves some stale indexes
- around in the BSP tree if called from the item's destructor; these will
- be cleaned up the next time someone triggers purgeRemovedItems().
-
- Note: This function might get called from QGraphicsItem's destructor. \a item is
- being destroyed, so we cannot call any pure virtual functions on it (such
- as boundingRect()). Also, it is unnecessary to update the item's own state
- in any way.
-*/
-void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item)
-{
- Q_Q(QGraphicsScene);
-
- // Clear focus on the item to remove any reference in the focusWidget chain.
- item->clearFocus();
-
- markDirty(item, QRectF(), /*invalidateChildren=*/false, /*force=*/false,
- /*ignoreOpacity=*/false, /*removingItemFromScene=*/true);
-
- if (item->d_ptr->inDestructor) {
- // The item is actually in its destructor, we call the special method in the index.
- index->deleteItem(item);
- } else {
- // Can potentially call item->boundingRect() (virtual function), that's why
- // we only can call this function if the item is not in its destructor.
- index->removeItem(item);
- }
-
- item->d_ptr->clearSubFocus();
-
- if (item->flags() & QGraphicsItem::ItemSendsScenePositionChanges)
- unregisterScenePosItem(item);
-
- QGraphicsScene *oldScene = item->d_func()->scene;
- item->d_func()->scene = 0;
-
- //We need to remove all children first because they might use their parent
- //attributes (e.g. sceneTransform).
- if (!item->d_ptr->inDestructor) {
- // Remove all children recursively
- for (int i = 0; i < item->d_ptr->children.size(); ++i)
- q->removeItem(item->d_ptr->children.at(i));
- }
-
- if (!item->d_ptr->inDestructor && item == tabFocusFirst) {
- QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
- widget->d_func()->fixFocusChainBeforeReparenting(0, oldScene, 0);
- }
-
- // Unregister focus proxy.
- item->d_ptr->resetFocusProxy();
-
- // Remove from parent, or unregister from toplevels.
- if (QGraphicsItem *parentItem = item->parentItem()) {
- if (parentItem->scene()) {
- Q_ASSERT_X(parentItem->scene() == q, "QGraphicsScene::removeItem",
- "Parent item's scene is different from this item's scene");
- item->setParentItem(0);
- }
- } else {
- unregisterTopLevelItem(item);
- }
-
- // Reset the mouse grabber and focus item data.
- if (item == focusItem)
- focusItem = 0;
- if (item == lastFocusItem)
- lastFocusItem = 0;
- if (item == passiveFocusItem)
- passiveFocusItem = 0;
- if (item == activePanel) {
- // ### deactivate...
- activePanel = 0;
- }
- if (item == lastActivePanel)
- lastActivePanel = 0;
-
- // Cancel active touches
- {
- QMap<int, QGraphicsItem *>::iterator it = itemForTouchPointId.begin();
- while (it != itemForTouchPointId.end()) {
- if (it.value() == item) {
- sceneCurrentTouchPoints.remove(it.key());
- it = itemForTouchPointId.erase(it);
- } else {
- ++it;
- }
- }
- }
-
- // Disable selectionChanged() for individual items
- ++selectionChanging;
- int oldSelectedItemsSize = selectedItems.size();
-
- // Update selected & hovered item bookkeeping
- selectedItems.remove(item);
- hoverItems.removeAll(item);
- cachedItemsUnderMouse.removeAll(item);
- if (item->d_ptr->pendingPolish) {
- const int unpolishedIndex = unpolishedItems.indexOf(item);
- if (unpolishedIndex != -1)
- unpolishedItems[unpolishedIndex] = 0;
- item->d_ptr->pendingPolish = false;
- }
- resetDirtyItem(item);
-
- //We remove all references of item from the sceneEventFilter arrays
- QMultiMap<QGraphicsItem*, QGraphicsItem*>::iterator iterator = sceneEventFilters.begin();
- while (iterator != sceneEventFilters.end()) {
- if (iterator.value() == item || iterator.key() == item)
- iterator = sceneEventFilters.erase(iterator);
- else
- ++iterator;
- }
-
- if (item->isPanel() && item->isVisible() && item->panelModality() != QGraphicsItem::NonModal)
- leaveModal(item);
-
- // Reset the mouse grabber and focus item data.
- if (mouseGrabberItems.contains(item))
- ungrabMouse(item, /* item is dying */ item->d_ptr->inDestructor);
-
- // Reset the keyboard grabber
- if (keyboardGrabberItems.contains(item))
- ungrabKeyboard(item, /* item is dying */ item->d_ptr->inDestructor);
-
- // Reset the last mouse grabber item
- if (item == lastMouseGrabberItem)
- lastMouseGrabberItem = 0;
-
- // Reset the current drop item
- if (item == dragDropItem)
- dragDropItem = 0;
-
- // Reenable selectionChanged() for individual items
- --selectionChanging;
- if (!selectionChanging && selectedItems.size() != oldSelectedItemsSize)
- emit q->selectionChanged();
-
-#ifndef QT_NO_GESTURES
- QHash<QGesture *, QGraphicsObject *>::iterator it;
- for (it = gestureTargets.begin(); it != gestureTargets.end();) {
- if (it.value() == item)
- it = gestureTargets.erase(it);
- else
- ++it;
- }
-
- QGraphicsObject *dummy = static_cast<QGraphicsObject *>(item);
- cachedTargetItems.removeOne(dummy);
- cachedItemGestures.remove(dummy);
- cachedAlreadyDeliveredGestures.remove(dummy);
-
- foreach (Qt::GestureType gesture, item->d_ptr->gestureContext.keys())
- ungrabGesture(item, gesture);
-#endif // QT_NO_GESTURES
-}
-
-/*!
- \internal
-*/
-void QGraphicsScenePrivate::setActivePanelHelper(QGraphicsItem *item, bool duringActivationEvent)
-{
- Q_Q(QGraphicsScene);
- if (item && item->scene() != q) {
- qWarning("QGraphicsScene::setActivePanel: item %p must be part of this scene",
- item);
- return;
- }
-
- // Ensure the scene has focus when we change panel activation.
- q->setFocus(Qt::ActiveWindowFocusReason);
-
- // Find the item's panel.
- QGraphicsItem *panel = item ? item->panel() : 0;
- lastActivePanel = panel ? activePanel : 0;
- if (panel == activePanel || (!q->isActive() && !duringActivationEvent))
- return;
-
- // Deactivate the last active panel.
- if (activePanel) {
- if (QGraphicsItem *fi = activePanel->focusItem()) {
- // Remove focus from the current focus item.
- if (fi == q->focusItem())
- q->setFocusItem(0, Qt::ActiveWindowFocusReason);
- }
-
- QEvent event(QEvent::WindowDeactivate);
- q->sendEvent(activePanel, &event);
- } else if (panel && !duringActivationEvent) {
- // Deactivate the scene if changing activation to a panel.
- QEvent event(QEvent::WindowDeactivate);
- foreach (QGraphicsItem *item, q->items()) {
- if (item->isVisible() && !item->isPanel() && !item->parentItem())
- q->sendEvent(item, &event);
- }
- }
-
- // Update activate state.
- activePanel = panel;
- QEvent event(QEvent::ActivationChange);
- QApplication::sendEvent(q, &event);
-
- // Activate
- if (panel) {
- QEvent event(QEvent::WindowActivate);
- q->sendEvent(panel, &event);
-
- // Set focus on the panel's focus item.
- if (QGraphicsItem *focusItem = panel->focusItem())
- focusItem->setFocus(Qt::ActiveWindowFocusReason);
- } else if (q->isActive()) {
- // Activate the scene
- QEvent event(QEvent::WindowActivate);
- foreach (QGraphicsItem *item, q->items()) {
- if (item->isVisible() && !item->isPanel() && !item->parentItem())
- q->sendEvent(item, &event);
- }
- }
-}
-
-/*!
- \internal
-*/
-void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item,
- Qt::FocusReason focusReason)
-{
- Q_Q(QGraphicsScene);
- if (item == focusItem)
- return;
-
- // Clear focus if asked to set focus on something that can't
- // accept input focus.
- if (item && (!(item->flags() & QGraphicsItem::ItemIsFocusable)
- || !item->isVisible() || !item->isEnabled())) {
- item = 0;
- }
-
- // Set focus on the scene if an item requests focus.
- if (item) {
- q->setFocus(focusReason);
- if (item == focusItem)
- return;
- }
-
- if (focusItem) {
- lastFocusItem = focusItem;
-
-#ifndef QT_NO_IM
- if (lastFocusItem
- && (lastFocusItem->flags() & QGraphicsItem::ItemAcceptsInputMethod)) {
- // Close any external input method panel. This happens
- // automatically by removing WA_InputMethodEnabled on
- // the views, but if we are changing focus, we have to
- // do it ourselves.
- for (int i = 0; i < views.size(); ++i)
- if (views.at(i)->inputContext())
- views.at(i)->inputContext()->reset();
- }
-
- focusItem = 0;
- QFocusEvent event(QEvent::FocusOut, focusReason);
- sendEvent(lastFocusItem, &event);
-#endif //QT_NO_IM
- }
-
- // This handles the case that the item has been removed from the
- // scene in response to the FocusOut event.
- if (item && item->scene() != q)
- item = 0;
-
- if (item)
- focusItem = item;
- updateInputMethodSensitivityInViews();
-
-#ifndef QT_NO_ACCESSIBILITY
- if (focusItem) {
- if (QGraphicsObject *focusObj = focusItem->toGraphicsObject()) {
- QAccessible::updateAccessibility(focusObj, 0, QAccessible::Focus);
- }
- }
-#endif
- if (item) {
- QFocusEvent event(QEvent::FocusIn, focusReason);
- sendEvent(item, &event);
- }
-}
-
-/*!
- \internal
-*/
-void QGraphicsScenePrivate::addPopup(QGraphicsWidget *widget)
-{
- Q_ASSERT(widget);
- Q_ASSERT(!popupWidgets.contains(widget));
- popupWidgets << widget;
- if (QGraphicsWidget *focusWidget = widget->focusWidget()) {
- focusWidget->setFocus(Qt::PopupFocusReason);
- } else {
- grabKeyboard((QGraphicsItem *)widget);
- if (focusItem && popupWidgets.size() == 1) {
- QFocusEvent event(QEvent::FocusOut, Qt::PopupFocusReason);
- sendEvent(focusItem, &event);
- }
- }
- grabMouse((QGraphicsItem *)widget);
-}
-
-/*!
- \internal
-
- Remove \a widget from the popup list. Important notes:
-
- \a widget is guaranteed to be in the list of popups, but it might not be
- the last entry; you can hide any item in the pop list before the others,
- and this must cause all later mouse grabbers to lose the grab.
-*/
-void QGraphicsScenePrivate::removePopup(QGraphicsWidget *widget, bool itemIsDying)
-{
- Q_ASSERT(widget);
- int index = popupWidgets.indexOf(widget);
- Q_ASSERT(index != -1);
-
- for (int i = popupWidgets.size() - 1; i >= index; --i) {
- QGraphicsWidget *widget = popupWidgets.takeLast();
- ungrabMouse(widget, itemIsDying);
- if (focusItem && popupWidgets.isEmpty()) {
- QFocusEvent event(QEvent::FocusIn, Qt::PopupFocusReason);
- sendEvent(focusItem, &event);
- } else if (keyboardGrabberItems.contains(static_cast<QGraphicsItem *>(widget))) {
- ungrabKeyboard(static_cast<QGraphicsItem *>(widget), itemIsDying);
- }
- if (!itemIsDying && widget->isVisible()) {
- widget->QGraphicsItem::d_ptr->setVisibleHelper(false, /* explicit = */ false);
- }
- }
-}
-
-/*!
- \internal
-*/
-void QGraphicsScenePrivate::grabMouse(QGraphicsItem *item, bool implicit)
-{
- // Append to list of mouse grabber items, and send a mouse grab event.
- if (mouseGrabberItems.contains(item)) {
- if (mouseGrabberItems.last() == item) {
- Q_ASSERT(!implicit);
- if (!lastMouseGrabberItemHasImplicitMouseGrab) {
- qWarning("QGraphicsItem::grabMouse: already a mouse grabber");
- } else {
- // Upgrade to an explicit mouse grab
- lastMouseGrabberItemHasImplicitMouseGrab = false;
- }
- } else {
- qWarning("QGraphicsItem::grabMouse: already blocked by mouse grabber: %p",
- mouseGrabberItems.last());
- }
- return;
- }
-
- // Send ungrab event to the last grabber.
- if (!mouseGrabberItems.isEmpty()) {
- QGraphicsItem *last = mouseGrabberItems.last();
- if (lastMouseGrabberItemHasImplicitMouseGrab) {
- // Implicit mouse grab is immediately lost.
- last->ungrabMouse();
- } else {
- // Just send ungrab event to current grabber.
- QEvent ungrabEvent(QEvent::UngrabMouse);
- sendEvent(last, &ungrabEvent);
- }
- }
-
- mouseGrabberItems << item;
- lastMouseGrabberItemHasImplicitMouseGrab = implicit;
-
- // Send grab event to current grabber.
- QEvent grabEvent(QEvent::GrabMouse);
- sendEvent(item, &grabEvent);
-}
-
-/*!
- \internal
-*/
-void QGraphicsScenePrivate::ungrabMouse(QGraphicsItem *item, bool itemIsDying)
-{
- int index = mouseGrabberItems.indexOf(item);
- if (index == -1) {
- qWarning("QGraphicsItem::ungrabMouse: not a mouse grabber");
- return;
- }
-
- if (item != mouseGrabberItems.last()) {
- // Recursively ungrab the next mouse grabber until we reach this item
- // to ensure state consistency.
- ungrabMouse(mouseGrabberItems.at(index + 1), itemIsDying);
- }
- if (!popupWidgets.isEmpty() && item == popupWidgets.last()) {
- // If the item is a popup, go via removePopup to ensure state
- // consistency and that it gets hidden correctly - beware that
- // removePopup() reenters this function to continue removing the grab.
- removePopup((QGraphicsWidget *)item, itemIsDying);
- return;
- }
-
- // Send notification about mouse ungrab.
- if (!itemIsDying) {
- QEvent event(QEvent::UngrabMouse);
- sendEvent(item, &event);
- }
-
- // Remove the item from the list of grabbers. Whenever this happens, we
- // reset the implicitGrab (there can be only ever be one implicit grabber
- // in a scene, and it is always the latest grabber; if the implicit grab
- // is lost, it is not automatically regained.
- mouseGrabberItems.takeLast();
- lastMouseGrabberItemHasImplicitMouseGrab = false;
-
- // Send notification about mouse regrab. ### It's unfortunate that all the
- // items get a GrabMouse event, but this is a rare case with a simple
- // implementation and it does ensure a consistent state.
- if (!itemIsDying && !mouseGrabberItems.isEmpty()) {
- QGraphicsItem *last = mouseGrabberItems.last();
- QEvent event(QEvent::GrabMouse);
- sendEvent(last, &event);
- }
-}
-
-/*!
- \internal
-*/
-void QGraphicsScenePrivate::clearMouseGrabber()
-{
- if (!mouseGrabberItems.isEmpty())
- mouseGrabberItems.first()->ungrabMouse();
- lastMouseGrabberItem = 0;
-}
-
-/*!
- \internal
-*/
-void QGraphicsScenePrivate::grabKeyboard(QGraphicsItem *item)
-{
- if (keyboardGrabberItems.contains(item)) {
- if (keyboardGrabberItems.last() == item)
- qWarning("QGraphicsItem::grabKeyboard: already a keyboard grabber");
- else
- qWarning("QGraphicsItem::grabKeyboard: already blocked by keyboard grabber: %p",
- keyboardGrabberItems.last());
- return;
- }
-
- // Send ungrab event to the last grabber.
- if (!keyboardGrabberItems.isEmpty()) {
- // Just send ungrab event to current grabber.
- QEvent ungrabEvent(QEvent::UngrabKeyboard);
- sendEvent(keyboardGrabberItems.last(), &ungrabEvent);
- }
-
- keyboardGrabberItems << item;
-
- // Send grab event to current grabber.
- QEvent grabEvent(QEvent::GrabKeyboard);
- sendEvent(item, &grabEvent);
-}
-
-/*!
- \internal
-*/
-void QGraphicsScenePrivate::ungrabKeyboard(QGraphicsItem *item, bool itemIsDying)
-{
- int index = keyboardGrabberItems.lastIndexOf(item);
- if (index == -1) {
- qWarning("QGraphicsItem::ungrabKeyboard: not a keyboard grabber");
- return;
- }
- if (item != keyboardGrabberItems.last()) {
- // Recursively ungrab the topmost keyboard grabber until we reach this
- // item to ensure state consistency.
- ungrabKeyboard(keyboardGrabberItems.at(index + 1), itemIsDying);
- }
-
- // Send notification about keyboard ungrab.
- if (!itemIsDying) {
- QEvent event(QEvent::UngrabKeyboard);
- sendEvent(item, &event);
- }
-
- // Remove the item from the list of grabbers.
- keyboardGrabberItems.takeLast();
-
- // Send notification about mouse regrab.
- if (!itemIsDying && !keyboardGrabberItems.isEmpty()) {
- QGraphicsItem *last = keyboardGrabberItems.last();
- QEvent event(QEvent::GrabKeyboard);
- sendEvent(last, &event);
- }
-}
-
-/*!
- \internal
-*/
-void QGraphicsScenePrivate::clearKeyboardGrabber()
-{
- if (!keyboardGrabberItems.isEmpty())
- ungrabKeyboard(keyboardGrabberItems.first());
-}
-
-void QGraphicsScenePrivate::enableMouseTrackingOnViews()
-{
- foreach (QGraphicsView *view, views)
- view->viewport()->setMouseTracking(true);
-}
-
-/*!
- Returns all items for the screen position in \a event.
-*/
-QList<QGraphicsItem *> QGraphicsScenePrivate::itemsAtPosition(const QPoint &/*screenPos*/,
- const QPointF &scenePos,
- QWidget *widget) const
-{
- Q_Q(const QGraphicsScene);
- QGraphicsView *view = widget ? qobject_cast<QGraphicsView *>(widget->parentWidget()) : 0;
- if (!view)
- return q->items(scenePos, Qt::IntersectsItemShape, Qt::DescendingOrder, QTransform());
-
- const QRectF pointRect(scenePos, QSizeF(1, 1));
- if (!view->isTransformed())
- return q->items(pointRect, Qt::IntersectsItemShape, Qt::DescendingOrder);
-
- const QTransform viewTransform = view->viewportTransform();
- return q->items(pointRect, Qt::IntersectsItemShape,
- Qt::DescendingOrder, viewTransform);
-}
-
-/*!
- \internal
-*/
-void QGraphicsScenePrivate::storeMouseButtonsForMouseGrabber(QGraphicsSceneMouseEvent *event)
-{
- for (int i = 0x1; i <= 0x10; i <<= 1) {
- if (event->buttons() & i) {
- mouseGrabberButtonDownPos.insert(Qt::MouseButton(i),
- mouseGrabberItems.last()->d_ptr->genericMapFromScene(event->scenePos(),
- event->widget()));
- mouseGrabberButtonDownScenePos.insert(Qt::MouseButton(i), event->scenePos());
- mouseGrabberButtonDownScreenPos.insert(Qt::MouseButton(i), event->screenPos());
- }
- }
-}
-
-/*!
- \internal
-*/
-void QGraphicsScenePrivate::installSceneEventFilter(QGraphicsItem *watched, QGraphicsItem *filter)
-{
- sceneEventFilters.insert(watched, filter);
-}
-
-/*!
- \internal
-*/
-void QGraphicsScenePrivate::removeSceneEventFilter(QGraphicsItem *watched, QGraphicsItem *filter)
-{
- if (!sceneEventFilters.contains(watched))
- return;
-
- QMultiMap<QGraphicsItem *, QGraphicsItem *>::Iterator it = sceneEventFilters.lowerBound(watched);
- QMultiMap<QGraphicsItem *, QGraphicsItem *>::Iterator end = sceneEventFilters.upperBound(watched);
- do {
- if (it.value() == filter)
- it = sceneEventFilters.erase(it);
- else
- ++it;
- } while (it != end);
-}
-
-/*!
- \internal
-*/
-bool QGraphicsScenePrivate::filterDescendantEvent(QGraphicsItem *item, QEvent *event)
-{
- if (item && (item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorFiltersChildEvents)) {
- QGraphicsItem *parent = item->parentItem();
- while (parent) {
- if (parent->d_ptr->filtersDescendantEvents && parent->sceneEventFilter(item, event))
- return true;
- if (!(parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorFiltersChildEvents))
- return false;
- parent = parent->parentItem();
- }
- }
- return false;
-}
-
-/*!
- \internal
-*/
-bool QGraphicsScenePrivate::filterEvent(QGraphicsItem *item, QEvent *event)
-{
- if (item && !sceneEventFilters.contains(item))
- return false;
-
- QMultiMap<QGraphicsItem *, QGraphicsItem *>::Iterator it = sceneEventFilters.lowerBound(item);
- QMultiMap<QGraphicsItem *, QGraphicsItem *>::Iterator end = sceneEventFilters.upperBound(item);
- while (it != end) {
- // ### The filterer and filteree might both be deleted.
- if (it.value()->sceneEventFilter(it.key(), event))
- return true;
- ++it;
- }
- return false;
-}
-
-/*!
- \internal
-
- This is the final dispatch point for any events from the scene to the
- item. It filters the event first - if the filter returns true, the event
- is considered to have been eaten by the filter, and is therefore stopped
- (the default filter returns false). Then/otherwise, if the item is
- enabled, the event is sent; otherwise it is stopped.
-*/
-bool QGraphicsScenePrivate::sendEvent(QGraphicsItem *item, QEvent *event)
-{
- if (QGraphicsObject *object = item->toGraphicsObject()) {
-#ifndef QT_NO_GESTURES
- QGestureManager *gestureManager = QApplicationPrivate::instance()->gestureManager;
- if (gestureManager) {
- if (gestureManager->filterEvent(object, event))
- return true;
- }
-#endif // QT_NO_GESTURES
- }
-
- if (filterEvent(item, event))
- return false;
- if (filterDescendantEvent(item, event))
- return false;
- if (!item || !item->isEnabled())
- return false;
- if (QGraphicsObject *o = item->toGraphicsObject()) {
- bool spont = event->spontaneous();
- if (spont ? qt_sendSpontaneousEvent(o, event) : QApplication::sendEvent(o, event))
- return true;
- event->spont = spont;
- }
- return item->sceneEvent(event);
-}
-
-/*!
- \internal
-*/
-void QGraphicsScenePrivate::cloneDragDropEvent(QGraphicsSceneDragDropEvent *dest,
- QGraphicsSceneDragDropEvent *source)
-{
- dest->setWidget(source->widget());
- dest->setPos(source->pos());
- dest->setScenePos(source->scenePos());
- dest->setScreenPos(source->screenPos());
- dest->setButtons(source->buttons());
- dest->setModifiers(source->modifiers());
- dest->setPossibleActions(source->possibleActions());
- dest->setProposedAction(source->proposedAction());
- dest->setDropAction(source->dropAction());
- dest->setSource(source->source());
- dest->setMimeData(source->mimeData());
-}
-
-/*!
- \internal
-*/
-void QGraphicsScenePrivate::sendDragDropEvent(QGraphicsItem *item,
- QGraphicsSceneDragDropEvent *dragDropEvent)
-{
- dragDropEvent->setPos(item->d_ptr->genericMapFromScene(dragDropEvent->scenePos(), dragDropEvent->widget()));
- sendEvent(item, dragDropEvent);
-}
-
-/*!
- \internal
-*/
-void QGraphicsScenePrivate::sendHoverEvent(QEvent::Type type, QGraphicsItem *item,
- QGraphicsSceneHoverEvent *hoverEvent)
-{
- QGraphicsSceneHoverEvent event(type);
- event.setWidget(hoverEvent->widget());
- event.setPos(item->d_ptr->genericMapFromScene(hoverEvent->scenePos(), hoverEvent->widget()));
- event.setScenePos(hoverEvent->scenePos());
- event.setScreenPos(hoverEvent->screenPos());
- event.setLastPos(item->d_ptr->genericMapFromScene(hoverEvent->lastScenePos(), hoverEvent->widget()));
- event.setLastScenePos(hoverEvent->lastScenePos());
- event.setLastScreenPos(hoverEvent->lastScreenPos());
- event.setModifiers(hoverEvent->modifiers());
- sendEvent(item, &event);
-}
-
-/*!
- \internal
-*/
-void QGraphicsScenePrivate::sendMouseEvent(QGraphicsSceneMouseEvent *mouseEvent)
-{
- if (mouseEvent->button() == 0 && mouseEvent->buttons() == 0 && lastMouseGrabberItemHasImplicitMouseGrab) {
- // ### This is a temporary fix for until we get proper mouse
- // grab events.
- clearMouseGrabber();
- return;
- }
-
- QGraphicsItem *item = mouseGrabberItems.last();
- if (item->isBlockedByModalPanel())
- return;
-
- for (int i = 0x1; i <= 0x10; i <<= 1) {
- Qt::MouseButton button = Qt::MouseButton(i);
- mouseEvent->setButtonDownPos(button, mouseGrabberButtonDownPos.value(button, item->d_ptr->genericMapFromScene(mouseEvent->scenePos(), mouseEvent->widget())));
- mouseEvent->setButtonDownScenePos(button, mouseGrabberButtonDownScenePos.value(button, mouseEvent->scenePos()));
- mouseEvent->setButtonDownScreenPos(button, mouseGrabberButtonDownScreenPos.value(button, mouseEvent->screenPos()));
- }
- mouseEvent->setPos(item->d_ptr->genericMapFromScene(mouseEvent->scenePos(), mouseEvent->widget()));
- mouseEvent->setLastPos(item->d_ptr->genericMapFromScene(mouseEvent->lastScenePos(), mouseEvent->widget()));
- sendEvent(item, mouseEvent);
-}
-
-/*!
- \internal
-*/
-void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mouseEvent)
-{
- Q_Q(QGraphicsScene);
-
- // Ignore by default, unless we find a mouse grabber that accepts it.
- mouseEvent->ignore();
-
- // Deliver to any existing mouse grabber.
- if (!mouseGrabberItems.isEmpty()) {
- if (mouseGrabberItems.last()->isBlockedByModalPanel())
- return;
- // The event is ignored by default, but we disregard the event's
- // accepted state after delivery; the mouse is grabbed, after all.
- sendMouseEvent(mouseEvent);
- return;
- }
-
- // Start by determining the number of items at the current position.
- // Reuse value from earlier calculations if possible.
- if (cachedItemsUnderMouse.isEmpty()) {
- cachedItemsUnderMouse = itemsAtPosition(mouseEvent->screenPos(),
- mouseEvent->scenePos(),
- mouseEvent->widget());
- }
-
- // Update window activation.
- QGraphicsItem *topItem = cachedItemsUnderMouse.value(0);
- QGraphicsWidget *newActiveWindow = topItem ? topItem->window() : 0;
- if (newActiveWindow && newActiveWindow->isBlockedByModalPanel(&topItem)) {
- // pass activation to the blocking modal window
- newActiveWindow = topItem ? topItem->window() : 0;
- }
-
- if (newActiveWindow != q->activeWindow())
- q->setActiveWindow(newActiveWindow);
-
- // Set focus on the topmost enabled item that can take focus.
- bool setFocus = false;
-
- foreach (QGraphicsItem *item, cachedItemsUnderMouse) {
- if (item->isBlockedByModalPanel()
- || (item->d_ptr->flags & QGraphicsItem::ItemStopsFocusHandling)) {
- // Make sure we don't clear focus.
- setFocus = true;
- break;
- }
- if (item->isEnabled() && ((item->flags() & QGraphicsItem::ItemIsFocusable))) {
- if (!item->isWidget() || ((QGraphicsWidget *)item)->focusPolicy() & Qt::ClickFocus) {
- setFocus = true;
- if (item != q->focusItem() && item->d_ptr->mouseSetsFocus)
- q->setFocusItem(item, Qt::MouseFocusReason);
- break;
- }
- }
- if (item->isPanel())
- break;
- if (item->d_ptr->flags & QGraphicsItem::ItemStopsClickFocusPropagation)
- break;
- }
-
- // Check for scene modality.
- bool sceneModality = false;
- for (int i = 0; i < modalPanels.size(); ++i) {
- if (modalPanels.at(i)->panelModality() == QGraphicsItem::SceneModal) {
- sceneModality = true;
- break;
- }
- }
-
- // If nobody could take focus, clear it.
- if (!stickyFocus && !setFocus && !sceneModality)
- q->setFocusItem(0, Qt::MouseFocusReason);
-
- // Any item will do.
- if (sceneModality && cachedItemsUnderMouse.isEmpty())
- cachedItemsUnderMouse << modalPanels.first();
-
- // Find a mouse grabber by sending mouse press events to all mouse grabber
- // candidates one at a time, until the event is accepted. It's accepted by
- // default, so the receiver has to explicitly ignore it for it to pass
- // through.
- foreach (QGraphicsItem *item, cachedItemsUnderMouse) {
- if (!(item->acceptedMouseButtons() & mouseEvent->button())) {
- // Skip items that don't accept the event's mouse button.
- continue;
- }
-
- // Check if this item is blocked by a modal panel and deliver the mouse event to the
- // blocking panel instead of this item if blocked.
- (void) item->isBlockedByModalPanel(&item);
-
- grabMouse(item, /* implicit = */ true);
- mouseEvent->accept();
-
- // check if the item we are sending to are disabled (before we send the event)
- bool disabled = !item->isEnabled();
- bool isPanel = item->isPanel();
- if (mouseEvent->type() == QEvent::GraphicsSceneMouseDoubleClick
- && item != lastMouseGrabberItem && lastMouseGrabberItem) {
- // If this item is different from the item that received the last
- // mouse event, and mouseEvent is a doubleclick event, then the
- // event is converted to a press. Known limitation:
- // Triple-clicking will not generate a doubleclick, though.
- QGraphicsSceneMouseEvent mousePress(QEvent::GraphicsSceneMousePress);
- mousePress.spont = mouseEvent->spont;
- mousePress.accept();
- mousePress.setButton(mouseEvent->button());
- mousePress.setButtons(mouseEvent->buttons());
- mousePress.setScreenPos(mouseEvent->screenPos());
- mousePress.setScenePos(mouseEvent->scenePos());
- mousePress.setModifiers(mouseEvent->modifiers());
- mousePress.setWidget(mouseEvent->widget());
- mousePress.setButtonDownPos(mouseEvent->button(),
- mouseEvent->buttonDownPos(mouseEvent->button()));
- mousePress.setButtonDownScenePos(mouseEvent->button(),
- mouseEvent->buttonDownScenePos(mouseEvent->button()));
- mousePress.setButtonDownScreenPos(mouseEvent->button(),
- mouseEvent->buttonDownScreenPos(mouseEvent->button()));
- sendMouseEvent(&mousePress);
- mouseEvent->setAccepted(mousePress.isAccepted());
- } else {
- sendMouseEvent(mouseEvent);
- }
-
- bool dontSendUngrabEvents = mouseGrabberItems.isEmpty() || mouseGrabberItems.last() != item;
- if (disabled) {
- ungrabMouse(item, /* itemIsDying = */ dontSendUngrabEvents);
- break;
- }
- if (mouseEvent->isAccepted()) {
- if (!mouseGrabberItems.isEmpty())
- storeMouseButtonsForMouseGrabber(mouseEvent);
- lastMouseGrabberItem = item;
- return;
- }
- ungrabMouse(item, /* itemIsDying = */ dontSendUngrabEvents);
-
- // Don't propagate through panels.
- if (isPanel)
- break;
- }
-
- // Is the event still ignored? Then the mouse press goes to the scene.
- // Reset the mouse grabber, clear the selection, clear focus, and leave
- // the event ignored so that it can propagate through the originating
- // view.
- if (!mouseEvent->isAccepted()) {
- clearMouseGrabber();
-
- QGraphicsView *view = mouseEvent->widget() ? qobject_cast<QGraphicsView *>(mouseEvent->widget()->parentWidget()) : 0;
- bool dontClearSelection = view && view->dragMode() == QGraphicsView::ScrollHandDrag;
- if (!dontClearSelection) {
- // Clear the selection if the originating view isn't in scroll
- // hand drag mode. The view will clear the selection if no drag
- // happened.
- q->clearSelection();
- }
- }
-}
-
-/*!
- \internal
-
- Ensures that the list of toplevels is sorted by insertion order, and that
- the siblingIndexes are packed (no gaps), and start at 0.
-
- ### This function is almost identical to
- QGraphicsItemPrivate::ensureSequentialSiblingIndex().
-*/
-void QGraphicsScenePrivate::ensureSequentialTopLevelSiblingIndexes()
-{
- if (!topLevelSequentialOrdering) {
- qSort(topLevelItems.begin(), topLevelItems.end(), QGraphicsItemPrivate::insertionOrder);
- topLevelSequentialOrdering = true;
- needSortTopLevelItems = 1;
- }
- if (holesInTopLevelSiblingIndex) {
- holesInTopLevelSiblingIndex = 0;
- for (int i = 0; i < topLevelItems.size(); ++i)
- topLevelItems[i]->d_ptr->siblingIndex = i;
- }
-}
-
-/*!
- \internal
-
- Set the font and propagate the changes if the font is different from the
- current font.
-*/
-void QGraphicsScenePrivate::setFont_helper(const QFont &font)
-{
- if (this->font == font && this->font.resolve() == font.resolve())
- return;
- updateFont(font);
-}
-
-/*!
- \internal
-
- Resolve the scene's font against the application font, and propagate the
- changes too all items in the scene.
-*/
-void QGraphicsScenePrivate::resolveFont()
-{
- QFont naturalFont = QApplication::font();
- naturalFont.resolve(0);
- QFont resolvedFont = font.resolve(naturalFont);
- updateFont(resolvedFont);
-}
-
-/*!
- \internal
-
- Update the font, and whether or not it has changed, reresolve all fonts in
- the scene.
-*/
-void QGraphicsScenePrivate::updateFont(const QFont &font)
-{
- Q_Q(QGraphicsScene);
-
- // Update local font setting.
- this->font = font;
-
- // Resolve the fonts of all top-level widget items, or widget items
- // whose parent is not a widget.
- foreach (QGraphicsItem *item, q->items()) {
- if (!item->parentItem()) {
- // Resolvefont for an item is a noop operation, but
- // every item can be a widget, or can have a widget
- // childre.
- item->d_ptr->resolveFont(font.resolve());
- }
- }
-
- // Send the scene a FontChange event.
- QEvent event(QEvent::FontChange);
- QApplication::sendEvent(q, &event);
-}
-
-/*!
- \internal
-
- Set the palette and propagate the changes if the palette is different from
- the current palette.
-*/
-void QGraphicsScenePrivate::setPalette_helper(const QPalette &palette)
-{
- if (this->palette == palette && this->palette.resolve() == palette.resolve())
- return;
- updatePalette(palette);
-}
-
-/*!
- \internal
-
- Resolve the scene's palette against the application palette, and propagate
- the changes too all items in the scene.
-*/
-void QGraphicsScenePrivate::resolvePalette()
-{
- QPalette naturalPalette = QApplication::palette();
- naturalPalette.resolve(0);
- QPalette resolvedPalette = palette.resolve(naturalPalette);
- updatePalette(resolvedPalette);
-}
-
-/*!
- \internal
-
- Update the palette, and whether or not it has changed, reresolve all
- palettes in the scene.
-*/
-void QGraphicsScenePrivate::updatePalette(const QPalette &palette)
-{
- Q_Q(QGraphicsScene);
-
- // Update local palette setting.
- this->palette = palette;
-
- // Resolve the palettes of all top-level widget items, or widget items
- // whose parent is not a widget.
- foreach (QGraphicsItem *item, q->items()) {
- if (!item->parentItem()) {
- // Resolvefont for an item is a noop operation, but
- // every item can be a widget, or can have a widget
- // childre.
- item->d_ptr->resolvePalette(palette.resolve());
- }
- }
-
- // Send the scene a PaletteChange event.
- QEvent event(QEvent::PaletteChange);
- QApplication::sendEvent(q, &event);
-}
-
-/*!
- Constructs a QGraphicsScene object. The \a parent parameter is
- passed to QObject's constructor.
-*/
-QGraphicsScene::QGraphicsScene(QObject *parent)
- : QObject(*new QGraphicsScenePrivate, parent)
-{
- d_func()->init();
-}
-
-/*!
- Constructs a QGraphicsScene object, using \a sceneRect for its
- scene rectangle. The \a parent parameter is passed to QObject's
- constructor.
-
- \sa sceneRect
-*/
-QGraphicsScene::QGraphicsScene(const QRectF &sceneRect, QObject *parent)
- : QObject(*new QGraphicsScenePrivate, parent)
-{
- d_func()->init();
- setSceneRect(sceneRect);
-}
-
-/*!
- Constructs a QGraphicsScene object, using the rectangle specified
- by (\a x, \a y), and the given \a width and \a height for its
- scene rectangle. The \a parent parameter is passed to QObject's
- constructor.
-
- \sa sceneRect
-*/
-QGraphicsScene::QGraphicsScene(qreal x, qreal y, qreal width, qreal height, QObject *parent)
- : QObject(*new QGraphicsScenePrivate, parent)
-{
- d_func()->init();
- setSceneRect(x, y, width, height);
-}
-
-/*!
- Removes and deletes all items from the scene object
- before destroying the scene object. The scene object
- is removed from the application's global scene list,
- and it is removed from all associated views.
-*/
-QGraphicsScene::~QGraphicsScene()
-{
- Q_D(QGraphicsScene);
-
- // Remove this scene from qApp's global scene list.
- qApp->d_func()->scene_list.removeAll(this);
-
- clear();
-
- // Remove this scene from all associated views.
- for (int j = 0; j < d->views.size(); ++j)
- d->views.at(j)->setScene(0);
-}
-
-/*!
- \property QGraphicsScene::sceneRect
- \brief the scene rectangle; the bounding rectangle of the scene
-
- The scene rectangle defines the extent of the scene. It is
- primarily used by QGraphicsView to determine the view's default
- scrollable area, and by QGraphicsScene to manage item indexing.
-
- If unset, or if set to a null QRectF, sceneRect() will return the largest
- bounding rect of all items on the scene since the scene was created (i.e.,
- a rectangle that grows when items are added to or moved in the scene, but
- never shrinks).
-
- \sa width(), height(), QGraphicsView::sceneRect
-*/
-QRectF QGraphicsScene::sceneRect() const
-{
- Q_D(const QGraphicsScene);
- if (d->hasSceneRect)
- return d->sceneRect;
-
- if (d->dirtyGrowingItemsBoundingRect) {
- // Lazily update the growing items bounding rect
- QGraphicsScenePrivate *thatd = const_cast<QGraphicsScenePrivate *>(d);
- QRectF oldGrowingBoundingRect = thatd->growingItemsBoundingRect;
- thatd->growingItemsBoundingRect |= itemsBoundingRect();
- thatd->dirtyGrowingItemsBoundingRect = false;
- if (oldGrowingBoundingRect != thatd->growingItemsBoundingRect)
- emit const_cast<QGraphicsScene *>(this)->sceneRectChanged(thatd->growingItemsBoundingRect);
- }
- return d->growingItemsBoundingRect;
-}
-void QGraphicsScene::setSceneRect(const QRectF &rect)
-{
- Q_D(QGraphicsScene);
- if (rect != d->sceneRect) {
- d->hasSceneRect = !rect.isNull();
- d->sceneRect = rect;
- emit sceneRectChanged(d->hasSceneRect ? rect : d->growingItemsBoundingRect);
- }
-}
-
-/*!
- \fn qreal QGraphicsScene::width() const
-
- This convenience function is equivalent to calling sceneRect().width().
-
- \sa height()
-*/
-
-/*!
- \fn qreal QGraphicsScene::height() const
-
- This convenience function is equivalent to calling \c sceneRect().height().
-
- \sa width()
-*/
-
-/*!
- Renders the \a source rect from scene into \a target, using \a painter. This
- function is useful for capturing the contents of the scene onto a paint
- device, such as a QImage (e.g., to take a screenshot), or for printing
- with QPrinter. For example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp 1
-
- If \a source is a null rect, this function will use sceneRect() to
- determine what to render. If \a target is a null rect, the dimensions of \a
- painter's paint device will be used.
-
- The source rect contents will be transformed according to \a
- aspectRatioMode to fit into the target rect. By default, the aspect ratio
- is kept, and \a source is scaled to fit in \a target.
-
- \sa QGraphicsView::render()
-*/
-void QGraphicsScene::render(QPainter *painter, const QRectF &target, const QRectF &source,
- Qt::AspectRatioMode aspectRatioMode)
-{
- // ### Switch to using the recursive rendering algorithm instead.
-
- // Default source rect = scene rect
- QRectF sourceRect = source;
- if (sourceRect.isNull())
- sourceRect = sceneRect();
-
- // Default target rect = device rect
- QRectF targetRect = target;
- if (targetRect.isNull()) {
- if (painter->device()->devType() == QInternal::Picture)
- targetRect = sourceRect;
- else
- targetRect.setRect(0, 0, painter->device()->width(), painter->device()->height());
- }
-
- // Find the ideal x / y scaling ratio to fit \a source into \a target.
- qreal xratio = targetRect.width() / sourceRect.width();
- qreal yratio = targetRect.height() / sourceRect.height();
-
- // Scale according to the aspect ratio mode.
- switch (aspectRatioMode) {
- case Qt::KeepAspectRatio:
- xratio = yratio = qMin(xratio, yratio);
- break;
- case Qt::KeepAspectRatioByExpanding:
- xratio = yratio = qMax(xratio, yratio);
- break;
- case Qt::IgnoreAspectRatio:
- break;
- }
-
- // Find all items to draw, and reverse the list (we want to draw
- // in reverse order).
- QList<QGraphicsItem *> itemList = items(sourceRect, Qt::IntersectsItemBoundingRect);
- QGraphicsItem **itemArray = new QGraphicsItem *[itemList.size()];
- int numItems = itemList.size();
- for (int i = 0; i < numItems; ++i)
- itemArray[numItems - i - 1] = itemList.at(i);
- itemList.clear();
-
- painter->save();
-
- // Transform the painter.
- painter->setClipRect(targetRect, Qt::IntersectClip);
- QTransform painterTransform;
- painterTransform *= QTransform()
- .translate(targetRect.left(), targetRect.top())
- .scale(xratio, yratio)
- .translate(-sourceRect.left(), -sourceRect.top());
- painter->setWorldTransform(painterTransform, true);
-
- // Two unit vectors.
- QLineF v1(0, 0, 1, 0);
- QLineF v2(0, 0, 0, 1);
-
- // Generate the style options
- QStyleOptionGraphicsItem *styleOptionArray = new QStyleOptionGraphicsItem[numItems];
- for (int i = 0; i < numItems; ++i)
- itemArray[i]->d_ptr->initStyleOption(&styleOptionArray[i], painterTransform, targetRect.toRect());
-
- // Render the scene.
- drawBackground(painter, sourceRect);
- drawItems(painter, numItems, itemArray, styleOptionArray);
- drawForeground(painter, sourceRect);
-
- delete [] itemArray;
- delete [] styleOptionArray;
-
- painter->restore();
-}
-
-/*!
- \property QGraphicsScene::itemIndexMethod
- \brief the item indexing method.
-
- QGraphicsScene applies an indexing algorithm to the scene, to speed up
- item discovery functions like items() and itemAt(). Indexing is most
- efficient for static scenes (i.e., where items don't move around). For
- dynamic scenes, or scenes with many animated items, the index bookkeeping
- can outweight the fast lookup speeds.
-
- For the common case, the default index method BspTreeIndex works fine. If
- your scene uses many animations and you are experiencing slowness, you can
- disable indexing by calling \c setItemIndexMethod(NoIndex).
-
- \sa bspTreeDepth
-*/
-QGraphicsScene::ItemIndexMethod QGraphicsScene::itemIndexMethod() const
-{
- Q_D(const QGraphicsScene);
- return d->indexMethod;
-}
-void QGraphicsScene::setItemIndexMethod(ItemIndexMethod method)
-{
- Q_D(QGraphicsScene);
- if (d->indexMethod == method)
- return;
-
- d->indexMethod = method;
-
- QList<QGraphicsItem *> oldItems = d->index->items(Qt::DescendingOrder);
- delete d->index;
- if (method == BspTreeIndex)
- d->index = new QGraphicsSceneBspTreeIndex(this);
- else
- d->index = new QGraphicsSceneLinearIndex(this);
- for (int i = oldItems.size() - 1; i >= 0; --i)
- d->index->addItem(oldItems.at(i));
-}
-
-/*!
- \property QGraphicsScene::bspTreeDepth
- \brief the depth of QGraphicsScene's BSP index tree
- \since 4.3
-
- This property has no effect when NoIndex is used.
-
- This value determines the depth of QGraphicsScene's BSP tree. The depth
- directly affects QGraphicsScene's performance and memory usage; the latter
- growing exponentially with the depth of the tree. With an optimal tree
- depth, QGraphicsScene can instantly determine the locality of items, even
- for scenes with thousands or millions of items. This also greatly improves
- rendering performance.
-
- By default, the value is 0, in which case Qt will guess a reasonable
- default depth based on the size, location and number of items in the
- scene. If these parameters change frequently, however, you may experience
- slowdowns as QGraphicsScene retunes the depth internally. You can avoid
- potential slowdowns by fixating the tree depth through setting this
- property.
-
- The depth of the tree and the size of the scene rectangle decide the
- granularity of the scene's partitioning. The size of each scene segment is
- determined by the following algorithm:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp 2
-
- The BSP tree has an optimal size when each segment contains between 0 and
- 10 items.
-
- \sa itemIndexMethod
-*/
-int QGraphicsScene::bspTreeDepth() const
-{
- Q_D(const QGraphicsScene);
- QGraphicsSceneBspTreeIndex *bspTree = qobject_cast<QGraphicsSceneBspTreeIndex *>(d->index);
- return bspTree ? bspTree->bspTreeDepth() : 0;
-}
-void QGraphicsScene::setBspTreeDepth(int depth)
-{
- Q_D(QGraphicsScene);
- if (depth < 0) {
- qWarning("QGraphicsScene::setBspTreeDepth: invalid depth %d ignored; must be >= 0", depth);
- return;
- }
-
- QGraphicsSceneBspTreeIndex *bspTree = qobject_cast<QGraphicsSceneBspTreeIndex *>(d->index);
- if (!bspTree) {
- qWarning("QGraphicsScene::setBspTreeDepth: can not apply if indexing method is not BSP");
- return;
- }
- bspTree->setBspTreeDepth(depth);
-}
-
-/*!
- \property QGraphicsScene::sortCacheEnabled
- \brief whether sort caching is enabled
- \since 4.5
- \obsolete
-
- Since Qt 4.6, this property has no effect.
-*/
-bool QGraphicsScene::isSortCacheEnabled() const
-{
- Q_D(const QGraphicsScene);
- return d->sortCacheEnabled;
-}
-void QGraphicsScene::setSortCacheEnabled(bool enabled)
-{
- Q_D(QGraphicsScene);
- if (d->sortCacheEnabled == enabled)
- return;
- d->sortCacheEnabled = enabled;
-}
-
-/*!
- Calculates and returns the bounding rect of all items on the scene. This
- function works by iterating over all items, and because if this, it can
- be slow for large scenes.
-
- \sa sceneRect()
-*/
-QRectF QGraphicsScene::itemsBoundingRect() const
-{
- // Does not take untransformable items into account.
- QRectF boundingRect;
- foreach (QGraphicsItem *item, items())
- boundingRect |= item->sceneBoundingRect();
- return boundingRect;
-}
-
-/*!
- Returns a list of all items in the scene in descending stacking order.
-
- \sa addItem(), removeItem(), {QGraphicsItem#Sorting}{Sorting}
-*/
-QList<QGraphicsItem *> QGraphicsScene::items() const
-{
- Q_D(const QGraphicsScene);
- return d->index->items(Qt::DescendingOrder);
-}
-
-/*!
- Returns an ordered list of all items on the scene. \a order decides the
- stacking order.
-
- \sa addItem(), removeItem(), {QGraphicsItem#Sorting}{Sorting}
-*/
-QList<QGraphicsItem *> QGraphicsScene::items(Qt::SortOrder order) const
-{
- Q_D(const QGraphicsScene);
- return d->index->items(order);
-}
-
-/*!
- \obsolete
-
- Returns all visible items at position \a pos in the scene. The items are
- listed in descending stacking order (i.e., the first item in the list is the
- top-most item, and the last item is the bottom-most item).
-
- This function is deprecated and returns incorrect results if the scene
- contains items that ignore transformations. Use the overload that takes
- a QTransform instead.
-
- \sa itemAt(), {QGraphicsItem#Sorting}{Sorting}
-*/
-QList<QGraphicsItem *> QGraphicsScene::items(const QPointF &pos) const
-{
- Q_D(const QGraphicsScene);
- return d->index->items(pos, Qt::IntersectsItemShape, Qt::DescendingOrder);
-}
-
-/*!
- \overload
- \obsolete
-
- Returns all visible items that, depending on \a mode, are either inside or
- intersect with the specified \a rectangle.
-
- The default value for \a mode is Qt::IntersectsItemShape; all items whose
- exact shape intersects with or is contained by \a rectangle are returned.
-
- This function is deprecated and returns incorrect results if the scene
- contains items that ignore transformations. Use the overload that takes
- a QTransform instead.
-
- \sa itemAt(), {QGraphicsItem#Sorting}{Sorting}
-*/
-QList<QGraphicsItem *> QGraphicsScene::items(const QRectF &rectangle, Qt::ItemSelectionMode mode) const
-{
- Q_D(const QGraphicsScene);
- return d->index->items(rectangle, mode, Qt::DescendingOrder);
-}
-
-/*!
- \fn QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode) const
- \obsolete
- \since 4.3
-
- This convenience function is equivalent to calling items(QRectF(\a x, \a y, \a w, \a h), \a mode).
-
- This function is deprecated and returns incorrect results if the scene
- contains items that ignore transformations. Use the overload that takes
- a QTransform instead.
-*/
-
-/*!
- \fn QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const
- \overload
- \since 4.6
-
- \brief Returns all visible items that, depending on \a mode, are
- either inside or intersect with the rectangle defined by \a x, \a y,
- \a w and \a h, in a list sorted using \a order.
-
- \a deviceTransform is the transformation that applies to the view, and needs to
- be provided if the scene contains items that ignore transformations.
-*/
-
-/*!
- \fn QList<QGraphicsItem *> QGraphicsScene::items(const QPolygonF &polygon, Qt::ItemSelectionMode mode) const
- \overload
- \obsolete
-
- Returns all visible items that, depending on \a mode, are either inside or
- intersect with the polygon \a polygon.
-
- The default value for \a mode is Qt::IntersectsItemShape; all items whose
- exact shape intersects with or is contained by \a polygon are returned.
-
- This function is deprecated and returns incorrect results if the scene
- contains items that ignore transformations. Use the overload that takes
- a QTransform instead.
-
- \sa itemAt(), {QGraphicsItem#Sorting}{Sorting}
-*/
-QList<QGraphicsItem *> QGraphicsScene::items(const QPolygonF &polygon, Qt::ItemSelectionMode mode) const
-{
- Q_D(const QGraphicsScene);
- return d->index->items(polygon, mode, Qt::DescendingOrder);
-}
-
-/*!
- \fn QList<QGraphicsItem *> QGraphicsScene::items(const QPainterPath &path, Qt::ItemSelectionMode mode) const
- \overload
- \obsolete
-
- Returns all visible items that, depending on \a path, are either inside or
- intersect with the path \a path.
-
- The default value for \a mode is Qt::IntersectsItemShape; all items whose
- exact shape intersects with or is contained by \a path are returned.
-
- This function is deprecated and returns incorrect results if the scene
- contains items that ignore transformations. Use the overload that takes
- a QTransform instead.
-
- \sa itemAt(), {QGraphicsItem#Sorting}{Sorting}
-*/
-QList<QGraphicsItem *> QGraphicsScene::items(const QPainterPath &path, Qt::ItemSelectionMode mode) const
-{
- Q_D(const QGraphicsScene);
- return d->index->items(path, mode, Qt::DescendingOrder);
-}
-
-/*!
- \fn QList<QGraphicsItem *> QGraphicsScene::items(const QPointF &pos, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const
- \since 4.6
-
- \brief Returns all visible items that, depending on \a mode, are at
- the specified \a pos in a list sorted using \a order.
-
- The default value for \a mode is Qt::IntersectsItemShape; all items whose
- exact shape intersects with \a pos are returned.
-
- \a deviceTransform is the transformation that applies to the view, and needs to
- be provided if the scene contains items that ignore transformations.
-
- \sa itemAt(), {QGraphicsItem#Sorting}{Sorting}
-*/
-QList<QGraphicsItem *> QGraphicsScene::items(const QPointF &pos, Qt::ItemSelectionMode mode,
- Qt::SortOrder order, const QTransform &deviceTransform) const
-{
- Q_D(const QGraphicsScene);
- return d->index->items(pos, mode, order, deviceTransform);
-}
-
-/*!
- \fn QList<QGraphicsItem *> QGraphicsScene::items(const QRectF &rect, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const
- \overload
- \since 4.6
-
- \brief Returns all visible items that, depending on \a mode, are
- either inside or intersect with the specified \a rect and return a
- list sorted using \a order.
-
- The default value for \a mode is Qt::IntersectsItemShape; all items whose
- exact shape intersects with or is contained by \a rect are returned.
-
- \a deviceTransform is the transformation that applies to the view, and needs to
- be provided if the scene contains items that ignore transformations.
-
- \sa itemAt(), {QGraphicsItem#Sorting}{Sorting}
-*/
-QList<QGraphicsItem *> QGraphicsScene::items(const QRectF &rect, Qt::ItemSelectionMode mode,
- Qt::SortOrder order, const QTransform &deviceTransform) const
-{
- Q_D(const QGraphicsScene);
- return d->index->items(rect, mode, order, deviceTransform);
-}
-
-/*!
- \fn QList<QGraphicsItem *> QGraphicsScene::items(const QPolygonF &polygon, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const
- \overload
- \since 4.6
-
- \brief Returns all visible items that, depending on \a mode, are
- either inside or intersect with the specified \a polygon and return
- a list sorted using \a order.
-
- The default value for \a mode is Qt::IntersectsItemShape; all items whose
- exact shape intersects with or is contained by \a polygon are returned.
-
- \a deviceTransform is the transformation that applies to the view, and needs to
- be provided if the scene contains items that ignore transformations.
-
- \sa itemAt(), {QGraphicsItem#Sorting}{Sorting}
-*/
-QList<QGraphicsItem *> QGraphicsScene::items(const QPolygonF &polygon, Qt::ItemSelectionMode mode,
- Qt::SortOrder order, const QTransform &deviceTransform) const
-{
- Q_D(const QGraphicsScene);
- return d->index->items(polygon, mode, order, deviceTransform);
-}
-
-/*!
- \fn QList<QGraphicsItem *> QGraphicsScene::items(const QPainterPath &path, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const
- \overload
- \since 4.6
-
- \brief Returns all visible items that, depending on \a mode, are
- either inside or intersect with the specified \a path and return a
- list sorted using \a order.
-
- The default value for \a mode is Qt::IntersectsItemShape; all items whose
- exact shape intersects with or is contained by \a path are returned.
-
- \a deviceTransform is the transformation that applies to the view, and needs to
- be provided if the scene contains items that ignore transformations.
-
- \sa itemAt(), {QGraphicsItem#Sorting}{Sorting}
-*/
-QList<QGraphicsItem *> QGraphicsScene::items(const QPainterPath &path, Qt::ItemSelectionMode mode,
- Qt::SortOrder order, const QTransform &deviceTransform) const
-{
- Q_D(const QGraphicsScene);
- return d->index->items(path, mode, order, deviceTransform);
-}
-
-/*!
- Returns a list of all items that collide with \a item. Collisions are
- determined by calling QGraphicsItem::collidesWithItem(); the collision
- detection is determined by \a mode. By default, all items whose shape
- intersects \a item or is contained inside \a item's shape are returned.
-
- The items are returned in descending stacking order (i.e., the first item
- in the list is the uppermost item, and the last item is the lowermost
- item).
-
- \sa items(), itemAt(), QGraphicsItem::collidesWithItem(), {QGraphicsItem#Sorting}{Sorting}
-*/
-QList<QGraphicsItem *> QGraphicsScene::collidingItems(const QGraphicsItem *item,
- Qt::ItemSelectionMode mode) const
-{
- Q_D(const QGraphicsScene);
- if (!item) {
- qWarning("QGraphicsScene::collidingItems: cannot find collisions for null item");
- return QList<QGraphicsItem *>();
- }
-
- // Does not support ItemIgnoresTransformations.
- QList<QGraphicsItem *> tmp;
- foreach (QGraphicsItem *itemInVicinity, d->index->estimateItems(item->sceneBoundingRect(), Qt::DescendingOrder)) {
- if (item != itemInVicinity && item->collidesWithItem(itemInVicinity, mode))
- tmp << itemInVicinity;
- }
- return tmp;
-}
-
-/*!
- \overload
- \obsolete
-
- Returns the topmost visible item at the specified \a position, or 0 if
- there are no items at this position.
-
- This function is deprecated and returns incorrect results if the scene
- contains items that ignore transformations. Use the overload that takes
- a QTransform instead.
-
- \sa items(), collidingItems(), {QGraphicsItem#Sorting}{Sorting}
-*/
-QGraphicsItem *QGraphicsScene::itemAt(const QPointF &position) const
-{
- QList<QGraphicsItem *> itemsAtPoint = items(position);
- return itemsAtPoint.isEmpty() ? 0 : itemsAtPoint.first();
-}
-
-/*!
- \since 4.6
-
- Returns the topmost visible item at the specified \a position, or 0
- if there are no items at this position.
-
- \a deviceTransform is the transformation that applies to the view, and needs to
- be provided if the scene contains items that ignore transformations.
-
- \sa items(), collidingItems(), {QGraphicsItem#Sorting}{Sorting}
-*/
-QGraphicsItem *QGraphicsScene::itemAt(const QPointF &position, const QTransform &deviceTransform) const
-{
- QList<QGraphicsItem *> itemsAtPoint = items(position, Qt::IntersectsItemShape,
- Qt::DescendingOrder, deviceTransform);
- return itemsAtPoint.isEmpty() ? 0 : itemsAtPoint.first();
-}
-
-/*!
- \fn QGraphicsScene::itemAt(qreal x, qreal y, const QTransform &deviceTransform) const
- \overload
- \since 4.6
-
- Returns the topmost item at the position specified by (\a x, \a
- y), or 0 if there are no items at this position.
-
- \a deviceTransform is the transformation that applies to the view, and needs to
- be provided if the scene contains items that ignore transformations.
-
- This convenience function is equivalent to calling \c
- {itemAt(QPointF(x, y), deviceTransform)}.
-*/
-
-/*!
- \fn QGraphicsScene::itemAt(qreal x, qreal y) const
- \overload
- \obsolete
-
- Returns the topmost item at the position specified by (\a x, \a
- y), or 0 if there are no items at this position.
-
- This convenience function is equivalent to calling \c
- {itemAt(QPointF(x, y))}.
-
- This function is deprecated and returns incorrect results if the scene
- contains items that ignore transformations. Use the overload that takes
- a QTransform instead.
-*/
-
-/*!
- Returns a list of all currently selected items. The items are
- returned in no particular order.
-
- \sa setSelectionArea()
-*/
-QList<QGraphicsItem *> QGraphicsScene::selectedItems() const
-{
- Q_D(const QGraphicsScene);
-
- // Optimization: Lazily removes items that are not selected.
- QGraphicsScene *that = const_cast<QGraphicsScene *>(this);
- QSet<QGraphicsItem *> actuallySelectedSet;
- foreach (QGraphicsItem *item, that->d_func()->selectedItems) {
- if (item->isSelected())
- actuallySelectedSet << item;
- }
-
- that->d_func()->selectedItems = actuallySelectedSet;
-
- return d->selectedItems.values();
-}
-
-/*!
- Returns the selection area that was previously set with
- setSelectionArea(), or an empty QPainterPath if no selection area has been
- set.
-
- \sa setSelectionArea()
-*/
-QPainterPath QGraphicsScene::selectionArea() const
-{
- Q_D(const QGraphicsScene);
- return d->selectionArea;
-}
-
-/*!
- \since 4.6
-
- Sets the selection area to \a path. All items within this area are
- immediately selected, and all items outside are unselected. You can get
- the list of all selected items by calling selectedItems().
-
- \a deviceTransform is the transformation that applies to the view, and needs to
- be provided if the scene contains items that ignore transformations.
-
- For an item to be selected, it must be marked as \e selectable
- (QGraphicsItem::ItemIsSelectable).
-
- \sa clearSelection(), selectionArea()
-*/
-void QGraphicsScene::setSelectionArea(const QPainterPath &path, const QTransform &deviceTransform)
-{
- setSelectionArea(path, Qt::IntersectsItemShape, deviceTransform);
-}
-
-/*!
- \obsolete
- \overload
-
- Sets the selection area to \a path.
-
- This function is deprecated and leads to incorrect results if the scene
- contains items that ignore transformations. Use the overload that takes
- a QTransform instead.
-*/
-void QGraphicsScene::setSelectionArea(const QPainterPath &path)
-{
- setSelectionArea(path, Qt::IntersectsItemShape, QTransform());
-}
-
-/*!
- \obsolete
- \overload
- \since 4.3
-
- Sets the selection area to \a path using \a mode to determine if items are
- included in the selection area.
-
- \sa clearSelection(), selectionArea()
-*/
-void QGraphicsScene::setSelectionArea(const QPainterPath &path, Qt::ItemSelectionMode mode)
-{
- setSelectionArea(path, mode, QTransform());
-}
-
-/*!
- \overload
- \since 4.6
-
- Sets the selection area to \a path using \a mode to determine if items are
- included in the selection area.
-
- \a deviceTransform is the transformation that applies to the view, and needs to
- be provided if the scene contains items that ignore transformations.
-
- \sa clearSelection(), selectionArea()
-*/
-void QGraphicsScene::setSelectionArea(const QPainterPath &path, Qt::ItemSelectionMode mode,
- const QTransform &deviceTransform)
-{
- Q_D(QGraphicsScene);
-
- // Note: with boolean path operations, we can improve performance here
- // quite a lot by "growing" the old path instead of replacing it. That
- // allows us to only check the intersect area for changes, instead of
- // reevaluating the whole path over again.
- d->selectionArea = path;
-
- QSet<QGraphicsItem *> unselectItems = d->selectedItems;
-
- // Disable emitting selectionChanged() for individual items.
- ++d->selectionChanging;
- bool changed = false;
-
- // Set all items in path to selected.
- foreach (QGraphicsItem *item, items(path, mode, Qt::DescendingOrder, deviceTransform)) {
- if (item->flags() & QGraphicsItem::ItemIsSelectable) {
- if (!item->isSelected())
- changed = true;
- unselectItems.remove(item);
- item->setSelected(true);
- }
- }
-
- // Unselect all items outside path.
- foreach (QGraphicsItem *item, unselectItems) {
- item->setSelected(false);
- changed = true;
- }
-
- // Reenable emitting selectionChanged() for individual items.
- --d->selectionChanging;
-
- if (!d->selectionChanging && changed)
- emit selectionChanged();
-}
-
-/*!
- Clears the current selection.
-
- \sa setSelectionArea(), selectedItems()
-*/
-void QGraphicsScene::clearSelection()
-{
- Q_D(QGraphicsScene);
-
- // Disable emitting selectionChanged
- ++d->selectionChanging;
- bool changed = !d->selectedItems.isEmpty();
-
- foreach (QGraphicsItem *item, d->selectedItems)
- item->setSelected(false);
- d->selectedItems.clear();
-
- // Reenable emitting selectionChanged() for individual items.
- --d->selectionChanging;
-
- if (!d->selectionChanging && changed)
- emit selectionChanged();
-}
-
-/*!
- \since 4.4
-
- Removes and deletes all items from the scene, but otherwise leaves the
- state of the scene unchanged.
-
- \sa addItem()
-*/
-void QGraphicsScene::clear()
-{
- Q_D(QGraphicsScene);
- // NB! We have to clear the index before deleting items; otherwise the
- // index might try to access dangling item pointers.
- d->index->clear();
- // NB! QGraphicsScenePrivate::unregisterTopLevelItem() removes items
- while (!d->topLevelItems.isEmpty())
- delete d->topLevelItems.first();
- Q_ASSERT(d->topLevelItems.isEmpty());
- d->lastItemCount = 0;
- d->allItemsIgnoreHoverEvents = true;
- d->allItemsUseDefaultCursor = true;
- d->allItemsIgnoreTouchEvents = true;
-}
-
-/*!
- Groups all items in \a items into a new QGraphicsItemGroup, and returns a
- pointer to the group. The group is created with the common ancestor of \a
- items as its parent, and with position (0, 0). The items are all
- reparented to the group, and their positions and transformations are
- mapped to the group. If \a items is empty, this function will return an
- empty top-level QGraphicsItemGroup.
-
- QGraphicsScene has ownership of the group item; you do not need to delete
- it. To dismantle (ungroup) a group, call destroyItemGroup().
-
- \sa destroyItemGroup(), QGraphicsItemGroup::addToGroup()
-*/
-QGraphicsItemGroup *QGraphicsScene::createItemGroup(const QList<QGraphicsItem *> &items)
-{
- // Build a list of the first item's ancestors
- QList<QGraphicsItem *> ancestors;
- int n = 0;
- if (!items.isEmpty()) {
- QGraphicsItem *parent = items.at(n++);
- while ((parent = parent->parentItem()))
- ancestors.append(parent);
- }
-
- // Find the common ancestor for all items
- QGraphicsItem *commonAncestor = 0;
- if (!ancestors.isEmpty()) {
- while (n < items.size()) {
- int commonIndex = -1;
- QGraphicsItem *parent = items.at(n++);
- do {
- int index = ancestors.indexOf(parent, qMax(0, commonIndex));
- if (index != -1) {
- commonIndex = index;
- break;
- }
- } while ((parent = parent->parentItem()));
-
- if (commonIndex == -1) {
- commonAncestor = 0;
- break;
- }
-
- commonAncestor = ancestors.at(commonIndex);
- }
- }
-
- // Create a new group at that level
- QGraphicsItemGroup *group = new QGraphicsItemGroup(commonAncestor);
- if (!commonAncestor)
- addItem(group);
- foreach (QGraphicsItem *item, items)
- group->addToGroup(item);
- return group;
-}
-
-/*!
- Reparents all items in \a group to \a group's parent item, then removes \a
- group from the scene, and finally deletes it. The items' positions and
- transformations are mapped from the group to the group's parent.
-
- \sa createItemGroup(), QGraphicsItemGroup::removeFromGroup()
-*/
-void QGraphicsScene::destroyItemGroup(QGraphicsItemGroup *group)
-{
- foreach (QGraphicsItem *item, group->children())
- group->removeFromGroup(item);
- removeItem(group);
- delete group;
-}
-
-/*!
- Adds or moves the \a item and all its childen to this scene.
- This scene takes ownership of the \a item.
-
- If the item is visible (i.e., QGraphicsItem::isVisible() returns
- true), QGraphicsScene will emit changed() once control goes back
- to the event loop.
-
- If the item is already in a different scene, it will first be
- removed from its old scene, and then added to this scene as a
- top-level.
-
- QGraphicsScene will send ItemSceneChange notifications to \a item
- while it is added to the scene. If item does not currently belong
- to a scene, only one notification is sent. If it does belong to
- scene already (i.e., it is moved to this scene), QGraphicsScene
- will send an addition notification as the item is removed from its
- previous scene.
-
- If the item is a panel, the scene is active, and there is no
- active panel in the scene, then the item will be activated.
-
- \sa removeItem(), addEllipse(), addLine(), addPath(), addPixmap(),
- addRect(), addText(), addWidget(), {QGraphicsItem#Sorting}{Sorting}
-*/
-void QGraphicsScene::addItem(QGraphicsItem *item)
-{
- Q_D(QGraphicsScene);
- if (!item) {
- qWarning("QGraphicsScene::addItem: cannot add null item");
- return;
- }
- if (item->d_ptr->scene == this) {
- qWarning("QGraphicsScene::addItem: item has already been added to this scene");
- return;
- }
- // Remove this item from its existing scene
- if (QGraphicsScene *oldScene = item->d_ptr->scene)
- oldScene->removeItem(item);
-
- // Notify the item that its scene is changing, and allow the item to
- // react.
- const QVariant newSceneVariant(item->itemChange(QGraphicsItem::ItemSceneChange,
- QVariant::fromValue<QGraphicsScene *>(this)));
- QGraphicsScene *targetScene = qvariant_cast<QGraphicsScene *>(newSceneVariant);
- if (targetScene != this) {
- if (targetScene && item->d_ptr->scene != targetScene)
- targetScene->addItem(item);
- return;
- }
-
- // QDeclarativeItems do not rely on initial itemChanged message, as the componentComplete
- // function allows far more opportunity for delayed-construction optimization.
- if (!item->d_ptr->isDeclarativeItem) {
- if (d->unpolishedItems.isEmpty()) {
- QMetaMethod method = metaObject()->method(d->polishItemsIndex);
- method.invoke(this, Qt::QueuedConnection);
- }
- d->unpolishedItems.append(item);
- item->d_ptr->pendingPolish = true;
- }
-
- // Detach this item from its parent if the parent's scene is different
- // from this scene.
- if (QGraphicsItem *itemParent = item->d_ptr->parent) {
- if (itemParent->d_ptr->scene != this)
- item->setParentItem(0);
- }
-
- // Add the item to this scene
- item->d_func()->scene = targetScene;
-
- // Add the item in the index
- d->index->addItem(item);
-
- // Add to list of toplevels if this item is a toplevel.
- if (!item->d_ptr->parent)
- d->registerTopLevelItem(item);
-
- // Add to list of items that require an update. We cannot assume that the
- // item is fully constructed, so calling item->update() can lead to a pure
- // virtual function call to boundingRect().
- d->markDirty(item);
- d->dirtyGrowingItemsBoundingRect = true;
-
- // Disable selectionChanged() for individual items
- ++d->selectionChanging;
- int oldSelectedItemSize = d->selectedItems.size();
-
- // Enable mouse tracking if the item accepts hover events or has a cursor set.
- if (d->allItemsIgnoreHoverEvents && d->itemAcceptsHoverEvents_helper(item)) {
- d->allItemsIgnoreHoverEvents = false;
- d->enableMouseTrackingOnViews();
- }
-#ifndef QT_NO_CURSOR
- if (d->allItemsUseDefaultCursor && item->d_ptr->hasCursor) {
- d->allItemsUseDefaultCursor = false;
- if (d->allItemsIgnoreHoverEvents) // already enabled otherwise
- d->enableMouseTrackingOnViews();
- }
-#endif //QT_NO_CURSOR
-
- // Enable touch events if the item accepts touch events.
- if (d->allItemsIgnoreTouchEvents && item->d_ptr->acceptTouchEvents) {
- d->allItemsIgnoreTouchEvents = false;
- d->enableTouchEventsOnViews();
- }
-
-#ifndef QT_NO_GESTURES
- foreach (Qt::GestureType gesture, item->d_ptr->gestureContext.keys())
- d->grabGesture(item, gesture);
-#endif
-
- // Update selection lists
- if (item->isSelected())
- d->selectedItems << item;
- if (item->isWidget() && item->isVisible() && static_cast<QGraphicsWidget *>(item)->windowType() == Qt::Popup)
- d->addPopup(static_cast<QGraphicsWidget *>(item));
- if (item->isPanel() && item->isVisible() && item->panelModality() != QGraphicsItem::NonModal)
- d->enterModal(item);
-
- // Update creation order focus chain. Make sure to leave the widget's
- // internal tab order intact.
- if (item->isWidget()) {
- QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
- if (!d->tabFocusFirst) {
- // No first tab focus widget - make this the first tab focus
- // widget.
- d->tabFocusFirst = widget;
- } else if (!widget->parentWidget()) {
- // Adding a widget that is not part of a tab focus chain.
- QGraphicsWidget *last = d->tabFocusFirst->d_func()->focusPrev;
- QGraphicsWidget *lastNew = widget->d_func()->focusPrev;
- last->d_func()->focusNext = widget;
- widget->d_func()->focusPrev = last;
- d->tabFocusFirst->d_func()->focusPrev = lastNew;
- lastNew->d_func()->focusNext = d->tabFocusFirst;
- }
- }
-
- // Add all children recursively
- item->d_ptr->ensureSortedChildren();
- for (int i = 0; i < item->d_ptr->children.size(); ++i)
- addItem(item->d_ptr->children.at(i));
-
- // Resolve font and palette.
- item->d_ptr->resolveFont(d->font.resolve());
- item->d_ptr->resolvePalette(d->palette.resolve());
-
-
- // Reenable selectionChanged() for individual items
- --d->selectionChanging;
- if (!d->selectionChanging && d->selectedItems.size() != oldSelectedItemSize)
- emit selectionChanged();
-
- // Deliver post-change notification
- item->itemChange(QGraphicsItem::ItemSceneHasChanged, newSceneVariant);
-
- // Update explicit activation
- bool autoActivate = true;
- if (!d->childExplicitActivation && item->d_ptr->explicitActivate)
- d->childExplicitActivation = item->d_ptr->wantsActive ? 1 : 2;
- if (d->childExplicitActivation && item->isPanel()) {
- if (d->childExplicitActivation == 1)
- setActivePanel(item);
- else
- autoActivate = false;
- d->childExplicitActivation = 0;
- } else if (!item->d_ptr->parent) {
- d->childExplicitActivation = 0;
- }
-
- // Auto-activate this item's panel if nothing else has been activated
- if (autoActivate) {
- if (!d->lastActivePanel && !d->activePanel && item->isPanel()) {
- if (isActive())
- setActivePanel(item);
- else
- d->lastActivePanel = item;
- }
- }
-
- if (item->d_ptr->flags & QGraphicsItem::ItemSendsScenePositionChanges)
- d->registerScenePosItem(item);
-
- // Ensure that newly added items that have subfocus set, gain
- // focus automatically if there isn't a focus item already.
- if (!d->focusItem && item != d->lastFocusItem && item->focusItem() == item)
- item->focusItem()->setFocus();
-
- d->updateInputMethodSensitivityInViews();
-}
-
-/*!
- Creates and adds an ellipse item to the scene, and returns the item
- pointer. The geometry of the ellipse is defined by \a rect, and its pen
- and brush are initialized to \a pen and \a brush.
-
- Note that the item's geometry is provided in item coordinates, and its
- position is initialized to (0, 0).
-
- If the item is visible (i.e., QGraphicsItem::isVisible() returns true),
- QGraphicsScene will emit changed() once control goes back to the event
- loop.
-
- \sa addLine(), addPath(), addPixmap(), addRect(), addText(), addItem(),
- addWidget()
-*/
-QGraphicsEllipseItem *QGraphicsScene::addEllipse(const QRectF &rect, const QPen &pen, const QBrush &brush)
-{
- QGraphicsEllipseItem *item = new QGraphicsEllipseItem(rect);
- item->setPen(pen);
- item->setBrush(brush);
- addItem(item);
- return item;
-}
-
-/*!
- \fn QGraphicsEllipseItem *QGraphicsScene::addEllipse(qreal x, qreal y, qreal w, qreal h, const QPen &pen, const QBrush &brush)
- \since 4.3
-
- This convenience function is equivalent to calling addEllipse(QRectF(\a x,
- \a y, \a w, \a h), \a pen, \a brush).
-*/
-
-/*!
- Creates and adds a line item to the scene, and returns the item
- pointer. The geometry of the line is defined by \a line, and its pen
- is initialized to \a pen.
-
- Note that the item's geometry is provided in item coordinates, and its
- position is initialized to (0, 0).
-
- If the item is visible (i.e., QGraphicsItem::isVisible() returns true),
- QGraphicsScene will emit changed() once control goes back to the event
- loop.
-
- \sa addEllipse(), addPath(), addPixmap(), addRect(), addText(), addItem(),
- addWidget()
-*/
-QGraphicsLineItem *QGraphicsScene::addLine(const QLineF &line, const QPen &pen)
-{
- QGraphicsLineItem *item = new QGraphicsLineItem(line);
- item->setPen(pen);
- addItem(item);
- return item;
-}
-
-/*!
- \fn QGraphicsLineItem *QGraphicsScene::addLine(qreal x1, qreal y1, qreal x2, qreal y2, const QPen &pen)
- \since 4.3
-
- This convenience function is equivalent to calling addLine(QLineF(\a x1,
- \a y1, \a x2, \a y2), \a pen).
-*/
-
-/*!
- Creates and adds a path item to the scene, and returns the item
- pointer. The geometry of the path is defined by \a path, and its pen and
- brush are initialized to \a pen and \a brush.
-
- Note that the item's geometry is provided in item coordinates, and its
- position is initialized to (0, 0).
-
- If the item is visible (i.e., QGraphicsItem::isVisible() returns true),
- QGraphicsScene will emit changed() once control goes back to the event
- loop.
-
- \sa addEllipse(), addLine(), addPixmap(), addRect(), addText(), addItem(),
- addWidget()
-*/
-QGraphicsPathItem *QGraphicsScene::addPath(const QPainterPath &path, const QPen &pen, const QBrush &brush)
-{
- QGraphicsPathItem *item = new QGraphicsPathItem(path);
- item->setPen(pen);
- item->setBrush(brush);
- addItem(item);
- return item;
-}
-
-/*!
- Creates and adds a pixmap item to the scene, and returns the item
- pointer. The pixmap is defined by \a pixmap.
-
- Note that the item's geometry is provided in item coordinates, and its
- position is initialized to (0, 0).
-
- If the item is visible (i.e., QGraphicsItem::isVisible() returns true),
- QGraphicsScene will emit changed() once control goes back to the event
- loop.
-
- \sa addEllipse(), addLine(), addPath(), addRect(), addText(), addItem(),
- addWidget()
-*/
-QGraphicsPixmapItem *QGraphicsScene::addPixmap(const QPixmap &pixmap)
-{
- QGraphicsPixmapItem *item = new QGraphicsPixmapItem(pixmap);
- addItem(item);
- return item;
-}
-
-/*!
- Creates and adds a polygon item to the scene, and returns the item
- pointer. The polygon is defined by \a polygon, and its pen and
- brush are initialized to \a pen and \a brush.
-
- Note that the item's geometry is provided in item coordinates, and its
- position is initialized to (0, 0).
-
- If the item is visible (i.e., QGraphicsItem::isVisible() returns true),
- QGraphicsScene will emit changed() once control goes back to the event
- loop.
-
- \sa addEllipse(), addLine(), addPath(), addRect(), addText(), addItem(),
- addWidget()
-*/
-QGraphicsPolygonItem *QGraphicsScene::addPolygon(const QPolygonF &polygon,
- const QPen &pen, const QBrush &brush)
-{
- QGraphicsPolygonItem *item = new QGraphicsPolygonItem(polygon);
- item->setPen(pen);
- item->setBrush(brush);
- addItem(item);
- return item;
-}
-
-/*!
- Creates and adds a rectangle item to the scene, and returns the item
- pointer. The geometry of the rectangle is defined by \a rect, and its pen
- and brush are initialized to \a pen and \a brush.
-
- Note that the item's geometry is provided in item coordinates, and its
- position is initialized to (0, 0). For example, if a QRect(50, 50, 100,
- 100) is added, its top-left corner will be at (50, 50) relative to the
- origin in the items coordinate system.
-
- If the item is visible (i.e., QGraphicsItem::isVisible() returns true),
- QGraphicsScene will emit changed() once control goes back to the event
- loop.
-
- \sa addEllipse(), addLine(), addPixmap(), addPixmap(), addText(),
- addItem(), addWidget()
-*/
-QGraphicsRectItem *QGraphicsScene::addRect(const QRectF &rect, const QPen &pen, const QBrush &brush)
-{
- QGraphicsRectItem *item = new QGraphicsRectItem(rect);
- item->setPen(pen);
- item->setBrush(brush);
- addItem(item);
- return item;
-}
-
-/*!
- \fn QGraphicsRectItem *QGraphicsScene::addRect(qreal x, qreal y, qreal w, qreal h, const QPen &pen, const QBrush &brush)
- \since 4.3
-
- This convenience function is equivalent to calling addRect(QRectF(\a x,
- \a y, \a w, \a h), \a pen, \a brush).
-*/
-
-/*!
- Creates and adds a text item to the scene, and returns the item
- pointer. The text string is initialized to \a text, and its font
- is initialized to \a font.
-
- The item's position is initialized to (0, 0).
-
- If the item is visible (i.e., QGraphicsItem::isVisible() returns true),
- QGraphicsScene will emit changed() once control goes back to the event
- loop.
-
- \sa addEllipse(), addLine(), addPixmap(), addPixmap(), addRect(),
- addItem(), addWidget()
-*/
-QGraphicsTextItem *QGraphicsScene::addText(const QString &text, const QFont &font)
-{
- QGraphicsTextItem *item = new QGraphicsTextItem(text);
- item->setFont(font);
- addItem(item);
- return item;
-}
-
-/*!
- Creates and adds a QGraphicsSimpleTextItem to the scene, and returns the
- item pointer. The text string is initialized to \a text, and its font is
- initialized to \a font.
-
- The item's position is initialized to (0, 0).
-
- If the item is visible (i.e., QGraphicsItem::isVisible() returns true),
- QGraphicsScene will emit changed() once control goes back to the event
- loop.
-
- \sa addEllipse(), addLine(), addPixmap(), addPixmap(), addRect(),
- addItem(), addWidget()
-*/
-QGraphicsSimpleTextItem *QGraphicsScene::addSimpleText(const QString &text, const QFont &font)
-{
- QGraphicsSimpleTextItem *item = new QGraphicsSimpleTextItem(text);
- item->setFont(font);
- addItem(item);
- return item;
-}
-
-/*!
- Creates a new QGraphicsProxyWidget for \a widget, adds it to the scene,
- and returns a pointer to the proxy. \a wFlags set the default window flags
- for the embedding proxy widget.
-
- The item's position is initialized to (0, 0).
-
- If the item is visible (i.e., QGraphicsItem::isVisible() returns true),
- QGraphicsScene will emit changed() once control goes back to the event
- loop.
-
- Note that widgets with the Qt::WA_PaintOnScreen widget attribute
- set and widgets that wrap an external application or controller
- are not supported. Examples are QGLWidget and QAxWidget.
-
- \sa addEllipse(), addLine(), addPixmap(), addPixmap(), addRect(),
- addText(), addSimpleText(), addItem()
-*/
-QGraphicsProxyWidget *QGraphicsScene::addWidget(QWidget *widget, Qt::WindowFlags wFlags)
-{
- QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(0, wFlags);
- proxy->setWidget(widget);
- addItem(proxy);
- return proxy;
-}
-
-/*!
- Removes the item \a item and all its children from the scene. The
- ownership of \a item is passed on to the caller (i.e.,
- QGraphicsScene will no longer delete \a item when destroyed).
-
- \sa addItem()
-*/
-void QGraphicsScene::removeItem(QGraphicsItem *item)
-{
- // ### Refactoring: This function shares much functionality with _q_removeItemLater()
- Q_D(QGraphicsScene);
- if (!item) {
- qWarning("QGraphicsScene::removeItem: cannot remove 0-item");
- return;
- }
- if (item->scene() != this) {
- qWarning("QGraphicsScene::removeItem: item %p's scene (%p)"
- " is different from this scene (%p)",
- item, item->scene(), this);
- return;
- }
-
- // Notify the item that it's scene is changing to 0, allowing the item to
- // react.
- const QVariant newSceneVariant(item->itemChange(QGraphicsItem::ItemSceneChange,
- QVariant::fromValue<QGraphicsScene *>(0)));
- QGraphicsScene *targetScene = qvariant_cast<QGraphicsScene *>(newSceneVariant);
- if (targetScene != 0 && targetScene != this) {
- targetScene->addItem(item);
- return;
- }
-
- d->removeItemHelper(item);
-
- // Deliver post-change notification
- item->itemChange(QGraphicsItem::ItemSceneHasChanged, newSceneVariant);
-
- d->updateInputMethodSensitivityInViews();
-}
-
-/*!
- When the scene is active, this functions returns the scene's current focus
- item, or 0 if no item currently has focus. When the scene is inactive, this
- functions returns the item that will gain input focus when the scene becomes
- active.
-
- The focus item receives keyboard input when the scene receives a
- key event.
-
- \sa setFocusItem(), QGraphicsItem::hasFocus(), isActive()
-*/
-QGraphicsItem *QGraphicsScene::focusItem() const
-{
- Q_D(const QGraphicsScene);
- return isActive() ? d->focusItem : d->passiveFocusItem;
-}
-
-/*!
- Sets the scene's focus item to \a item, with the focus reason \a
- focusReason, after removing focus from any previous item that may have had
- focus.
-
- If \a item is 0, or if it either does not accept focus (i.e., it does not
- have the QGraphicsItem::ItemIsFocusable flag enabled), or is not visible
- or not enabled, this function only removes focus from any previous
- focusitem.
-
- If item is not 0, and the scene does not currently have focus (i.e.,
- hasFocus() returns false), this function will call setFocus()
- automatically.
-
- \sa focusItem(), hasFocus(), setFocus()
-*/
-void QGraphicsScene::setFocusItem(QGraphicsItem *item, Qt::FocusReason focusReason)
-{
- Q_D(QGraphicsScene);
- if (item)
- item->setFocus(focusReason);
- else
- d->setFocusItemHelper(item, focusReason);
-}
-
-/*!
- Returns true if the scene has focus; otherwise returns false. If the scene
- has focus, it will will forward key events from QKeyEvent to any item that
- has focus.
-
- \sa setFocus(), setFocusItem()
-*/
-bool QGraphicsScene::hasFocus() const
-{
- Q_D(const QGraphicsScene);
- return d->hasFocus;
-}
-
-/*!
- Sets focus on the scene by sending a QFocusEvent to the scene, passing \a
- focusReason as the reason. If the scene regains focus after having
- previously lost it while an item had focus, the last focus item will
- receive focus with \a focusReason as the reason.
-
- If the scene already has focus, this function does nothing.
-
- \sa hasFocus(), clearFocus(), setFocusItem()
-*/
-void QGraphicsScene::setFocus(Qt::FocusReason focusReason)
-{
- Q_D(QGraphicsScene);
- if (d->hasFocus || !isActive())
- return;
- QFocusEvent event(QEvent::FocusIn, focusReason);
- QCoreApplication::sendEvent(this, &event);
-}
-
-/*!
- Clears focus from the scene. If any item has focus when this function is
- called, it will lose focus, and regain focus again once the scene regains
- focus.
-
- A scene that does not have focus ignores key events.
-
- \sa hasFocus(), setFocus(), setFocusItem()
-*/
-void QGraphicsScene::clearFocus()
-{
- Q_D(QGraphicsScene);
- if (d->hasFocus) {
- d->hasFocus = false;
- d->passiveFocusItem = d->focusItem;
- setFocusItem(0, Qt::OtherFocusReason);
- }
-}
-
-/*!
- \property QGraphicsScene::stickyFocus
- \brief whether clicking into the scene background will clear focus
-
- \since 4.6
-
- In a QGraphicsScene with stickyFocus set to true, focus will remain
- unchanged when the user clicks into the scene background or on an item
- that does not accept focus. Otherwise, focus will be cleared.
-
- By default, this property is false.
-
- Focus changes in response to a mouse press. You can reimplement
- mousePressEvent() in a subclass of QGraphicsScene to toggle this property
- based on where the user has clicked.
-
- \sa clearFocus(), setFocusItem()
-*/
-void QGraphicsScene::setStickyFocus(bool enabled)
-{
- Q_D(QGraphicsScene);
- d->stickyFocus = enabled;
-}
-bool QGraphicsScene::stickyFocus() const
-{
- Q_D(const QGraphicsScene);
- return d->stickyFocus;
-}
-
-/*!
- Returns the current mouse grabber item, or 0 if no item is currently
- grabbing the mouse. The mouse grabber item is the item that receives all
- mouse events sent to the scene.
-
- An item becomes a mouse grabber when it receives and accepts a
- mouse press event, and it stays the mouse grabber until either of
- the following events occur:
-
- \list
- \o If the item receives a mouse release event when there are no other
- buttons pressed, it loses the mouse grab.
- \o If the item becomes invisible (i.e., someone calls \c {item->setVisible(false)}),
- or if it becomes disabled (i.e., someone calls \c {item->setEnabled(false)}),
- it loses the mouse grab.
- \o If the item is removed from the scene, it loses the mouse grab.
- \endlist
-
- If the item loses its mouse grab, the scene will ignore all mouse events
- until a new item grabs the mouse (i.e., until a new item receives a mouse
- press event).
-*/
-QGraphicsItem *QGraphicsScene::mouseGrabberItem() const
-{
- Q_D(const QGraphicsScene);
- return !d->mouseGrabberItems.isEmpty() ? d->mouseGrabberItems.last() : 0;
-}
-
-/*!
- \property QGraphicsScene::backgroundBrush
- \brief the background brush of the scene.
-
- Set this property to changes the scene's background to a different color,
- gradient or texture. The default background brush is Qt::NoBrush. The
- background is drawn before (behind) the items.
-
- Example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp 3
-
- QGraphicsScene::render() calls drawBackground() to draw the scene
- background. For more detailed control over how the background is drawn,
- you can reimplement drawBackground() in a subclass of QGraphicsScene.
-*/
-QBrush QGraphicsScene::backgroundBrush() const
-{
- Q_D(const QGraphicsScene);
- return d->backgroundBrush;
-}
-void QGraphicsScene::setBackgroundBrush(const QBrush &brush)
-{
- Q_D(QGraphicsScene);
- d->backgroundBrush = brush;
- foreach (QGraphicsView *view, d->views) {
- view->resetCachedContent();
- view->viewport()->update();
- }
- update();
-}
-
-/*!
- \property QGraphicsScene::foregroundBrush
- \brief the foreground brush of the scene.
-
- Change this property to set the scene's foreground to a different
- color, gradient or texture.
-
- The foreground is drawn after (on top of) the items. The default
- foreground brush is Qt::NoBrush ( i.e. the foreground is not
- drawn).
-
- Example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp 4
-
- QGraphicsScene::render() calls drawForeground() to draw the scene
- foreground. For more detailed control over how the foreground is
- drawn, you can reimplement the drawForeground() function in a
- QGraphicsScene subclass.
-*/
-QBrush QGraphicsScene::foregroundBrush() const
-{
- Q_D(const QGraphicsScene);
- return d->foregroundBrush;
-}
-void QGraphicsScene::setForegroundBrush(const QBrush &brush)
-{
- Q_D(QGraphicsScene);
- d->foregroundBrush = brush;
- foreach (QGraphicsView *view, views())
- view->viewport()->update();
- update();
-}
-
-/*!
- This method is used by input methods to query a set of properties of
- the scene to be able to support complex input method operations as support
- for surrounding text and reconversions.
-
- The \a query parameter specifies which property is queried.
-
- \sa QWidget::inputMethodQuery()
-*/
-QVariant QGraphicsScene::inputMethodQuery(Qt::InputMethodQuery query) const
-{
- Q_D(const QGraphicsScene);
- if (!d->focusItem || !(d->focusItem->flags() & QGraphicsItem::ItemAcceptsInputMethod))
- return QVariant();
- const QTransform matrix = d->focusItem->sceneTransform();
- QVariant value = d->focusItem->inputMethodQuery(query);
- if (value.type() == QVariant::RectF)
- value = matrix.mapRect(value.toRectF());
- else if (value.type() == QVariant::PointF)
- value = matrix.map(value.toPointF());
- else if (value.type() == QVariant::Rect)
- value = matrix.mapRect(value.toRect());
- else if (value.type() == QVariant::Point)
- value = matrix.map(value.toPoint());
- return value;
-}
-
-/*!
- \fn void QGraphicsScene::update(const QRectF &rect)
- Schedules a redraw of the area \a rect on the scene.
-
- \sa sceneRect(), changed()
-*/
-void QGraphicsScene::update(const QRectF &rect)
-{
- Q_D(QGraphicsScene);
- if (d->updateAll || (rect.isEmpty() && !rect.isNull()))
- return;
-
- // Check if anyone's connected; if not, we can send updates directly to
- // the views. Otherwise or if there are no views, use old behavior.
- bool directUpdates = !(d->isSignalConnected(d->changedSignalIndex)) && !d->views.isEmpty();
- if (rect.isNull()) {
- d->updateAll = true;
- d->updatedRects.clear();
- if (directUpdates) {
- // Update all views.
- for (int i = 0; i < d->views.size(); ++i)
- d->views.at(i)->d_func()->fullUpdatePending = true;
- }
- } else {
- if (directUpdates) {
- // Update all views.
- for (int i = 0; i < d->views.size(); ++i) {
- QGraphicsView *view = d->views.at(i);
- if (view->isTransformed())
- view->d_func()->updateRectF(view->viewportTransform().mapRect(rect));
- else
- view->d_func()->updateRectF(rect);
- }
- } else {
- d->updatedRects << rect;
- }
- }
-
- if (!d->calledEmitUpdated) {
- d->calledEmitUpdated = true;
- QMetaObject::invokeMethod(this, "_q_emitUpdated", Qt::QueuedConnection);
- }
-}
-
-/*!
- \fn void QGraphicsScene::update(qreal x, qreal y, qreal w, qreal h)
- \overload
- \since 4.3
-
- This function is equivalent to calling update(QRectF(\a x, \a y, \a w,
- \a h));
-*/
-
-/*!
- Invalidates and schedules a redraw of the \a layers in \a rect on the
- scene. Any cached content in \a layers is unconditionally invalidated and
- redrawn.
-
- You can use this function overload to notify QGraphicsScene of changes to
- the background or the foreground of the scene. This function is commonly
- used for scenes with tile-based backgrounds to notify changes when
- QGraphicsView has enabled
- \l{QGraphicsView::CacheBackground}{CacheBackground}.
-
- Example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp 5
-
- Note that QGraphicsView currently supports background caching only (see
- QGraphicsView::CacheBackground). This function is equivalent to calling
- update() if any layer but BackgroundLayer is passed.
-
- \sa QGraphicsView::resetCachedContent()
-*/
-void QGraphicsScene::invalidate(const QRectF &rect, SceneLayers layers)
-{
- foreach (QGraphicsView *view, views())
- view->invalidateScene(rect, layers);
- update(rect);
-}
-
-/*!
- \fn void QGraphicsScene::invalidate(qreal x, qreal y, qreal w, qreal h, SceneLayers layers)
- \overload
- \since 4.3
-
- This convenience function is equivalent to calling invalidate(QRectF(\a x, \a
- y, \a w, \a h), \a layers);
-*/
-
-/*!
- Returns a list of all the views that display this scene.
-
- \sa QGraphicsView::scene()
-*/
-QList <QGraphicsView *> QGraphicsScene::views() const
-{
- Q_D(const QGraphicsScene);
- return d->views;
-}
-
-/*!
- This slot \e advances the scene by one step, by calling
- QGraphicsItem::advance() for all items on the scene. This is done in two
- phases: in the first phase, all items are notified that the scene is about
- to change, and in the second phase all items are notified that they can
- move. In the first phase, QGraphicsItem::advance() is called passing a
- value of 0 as an argument, and 1 is passed in the second phase.
-
- \sa QGraphicsItem::advance(), QGraphicsItemAnimation, QTimeLine
-*/
-void QGraphicsScene::advance()
-{
- for (int i = 0; i < 2; ++i) {
- foreach (QGraphicsItem *item, items())
- item->advance(i);
- }
-}
-
-/*!
- Processes the event \a event, and dispatches it to the respective
- event handlers.
-
- In addition to calling the convenience event handlers, this
- function is responsible for converting mouse move events to hover
- events for when there is no mouse grabber item. Hover events are
- delivered directly to items; there is no convenience function for
- them.
-
- Unlike QWidget, QGraphicsScene does not have the convenience functions
- \l{QWidget::}{enterEvent()} and \l{QWidget::}{leaveEvent()}. Use this
- function to obtain those events instead.
-
- \sa contextMenuEvent(), keyPressEvent(), keyReleaseEvent(),
- mousePressEvent(), mouseMoveEvent(), mouseReleaseEvent(),
- mouseDoubleClickEvent(), focusInEvent(), focusOutEvent()
-*/
-bool QGraphicsScene::event(QEvent *event)
-{
- Q_D(QGraphicsScene);
-
- switch (event->type()) {
- case QEvent::GraphicsSceneMousePress:
- case QEvent::GraphicsSceneMouseMove:
- case QEvent::GraphicsSceneMouseRelease:
- case QEvent::GraphicsSceneMouseDoubleClick:
- case QEvent::GraphicsSceneHoverEnter:
- case QEvent::GraphicsSceneHoverLeave:
- case QEvent::GraphicsSceneHoverMove:
- case QEvent::TouchBegin:
- case QEvent::TouchUpdate:
- case QEvent::TouchEnd:
- // Reset the under-mouse list to ensure that this event gets fresh
- // item-under-mouse data. Be careful about this list; if people delete
- // items from inside event handlers, this list can quickly end up
- // having stale pointers in it. We need to clear it before dispatching
- // events that use it.
- // ### this should only be cleared if we received a new mouse move event,
- // which relies on us fixing the replay mechanism in QGraphicsView.
- d->cachedItemsUnderMouse.clear();
- default:
- break;
- }
-
- switch (event->type()) {
- case QEvent::GraphicsSceneDragEnter:
- dragEnterEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
- break;
- case QEvent::GraphicsSceneDragMove:
- dragMoveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
- break;
- case QEvent::GraphicsSceneDragLeave:
- dragLeaveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
- break;
- case QEvent::GraphicsSceneDrop:
- dropEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
- break;
- case QEvent::GraphicsSceneContextMenu:
- contextMenuEvent(static_cast<QGraphicsSceneContextMenuEvent *>(event));
- break;
- case QEvent::KeyPress:
- if (!d->focusItem) {
- QKeyEvent *k = static_cast<QKeyEvent *>(event);
- if (k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) {
- if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier?
- bool res = false;
- if (k->key() == Qt::Key_Backtab
- || (k->key() == Qt::Key_Tab && (k->modifiers() & Qt::ShiftModifier))) {
- res = focusNextPrevChild(false);
- } else if (k->key() == Qt::Key_Tab) {
- res = focusNextPrevChild(true);
- }
- if (!res)
- event->ignore();
- return true;
- }
- }
- }
- keyPressEvent(static_cast<QKeyEvent *>(event));
- break;
- case QEvent::KeyRelease:
- keyReleaseEvent(static_cast<QKeyEvent *>(event));
- break;
- case QEvent::ShortcutOverride: {
- QGraphicsItem *parent = focusItem();
- while (parent) {
- d->sendEvent(parent, event);
- if (event->isAccepted())
- return true;
- parent = parent->parentItem();
- }
- }
- return false;
- case QEvent::GraphicsSceneMouseMove:
- {
- QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);
- d->lastSceneMousePos = mouseEvent->scenePos();
- mouseMoveEvent(mouseEvent);
- break;
- }
- case QEvent::GraphicsSceneMousePress:
- mousePressEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
- break;
- case QEvent::GraphicsSceneMouseRelease:
- mouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
- break;
- case QEvent::GraphicsSceneMouseDoubleClick:
- mouseDoubleClickEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
- break;
- case QEvent::GraphicsSceneWheel:
- wheelEvent(static_cast<QGraphicsSceneWheelEvent *>(event));
- break;
- case QEvent::FocusIn:
- focusInEvent(static_cast<QFocusEvent *>(event));
- break;
- case QEvent::FocusOut:
- focusOutEvent(static_cast<QFocusEvent *>(event));
- break;
- case QEvent::GraphicsSceneHoverEnter:
- case QEvent::GraphicsSceneHoverLeave:
- case QEvent::GraphicsSceneHoverMove:
- {
- QGraphicsSceneHoverEvent *hoverEvent = static_cast<QGraphicsSceneHoverEvent *>(event);
- d->lastSceneMousePos = hoverEvent->scenePos();
- d->dispatchHoverEvent(hoverEvent);
- break;
- }
- case QEvent::Leave:
- // hackieshly unpacking the viewport pointer from the leave event.
- d->leaveScene(reinterpret_cast<QWidget *>(event->d));
- break;
- case QEvent::GraphicsSceneHelp:
- helpEvent(static_cast<QGraphicsSceneHelpEvent *>(event));
- break;
- case QEvent::InputMethod:
- inputMethodEvent(static_cast<QInputMethodEvent *>(event));
- break;
- case QEvent::WindowActivate:
- if (!d->activationRefCount++) {
- if (d->lastActivePanel) {
- // Activate the last panel.
- d->setActivePanelHelper(d->lastActivePanel, true);
- } else if (d->tabFocusFirst && d->tabFocusFirst->isPanel()) {
- // Activate the panel of the first item in the tab focus
- // chain.
- d->setActivePanelHelper(d->tabFocusFirst, true);
- } else {
- // Activate all toplevel items.
- QEvent event(QEvent::WindowActivate);
- foreach (QGraphicsItem *item, items()) {
- if (item->isVisible() && !item->isPanel() && !item->parentItem())
- sendEvent(item, &event);
- }
- }
- }
- break;
- case QEvent::WindowDeactivate:
- if (!--d->activationRefCount) {
- if (d->activePanel) {
- // Deactivate the active panel (but keep it so we can
- // reactivate it later).
- QGraphicsItem *lastActivePanel = d->activePanel;
- d->setActivePanelHelper(0, true);
- d->lastActivePanel = lastActivePanel;
- } else {
- // Activate all toplevel items.
- QEvent event(QEvent::WindowDeactivate);
- foreach (QGraphicsItem *item, items()) {
- if (item->isVisible() && !item->isPanel() && !item->parentItem())
- sendEvent(item, &event);
- }
- }
- }
- break;
- case QEvent::ApplicationFontChange: {
- // Resolve the existing scene font.
- d->resolveFont();
- break;
- }
- case QEvent::FontChange:
- // Update the entire scene when the font changes.
- update();
- break;
- case QEvent::ApplicationPaletteChange: {
- // Resolve the existing scene palette.
- d->resolvePalette();
- break;
- }
- case QEvent::PaletteChange:
- // Update the entire scene when the palette changes.
- update();
- break;
- case QEvent::StyleChange:
- // Reresolve all widgets' styles. Update all top-level widgets'
- // geometries that do not have an explicit style set.
- update();
- break;
- case QEvent::TouchBegin:
- case QEvent::TouchUpdate:
- case QEvent::TouchEnd:
- d->touchEventHandler(static_cast<QTouchEvent *>(event));
- break;
-#ifndef QT_NO_GESTURES
- case QEvent::Gesture:
- case QEvent::GestureOverride:
- d->gestureEventHandler(static_cast<QGestureEvent *>(event));
- break;
-#endif // QT_NO_GESTURES
- default:
- return QObject::event(event);
- }
- return true;
-}
-
-/*!
- \reimp
-
- QGraphicsScene filters QApplication's events to detect palette and font
- changes.
-*/
-bool QGraphicsScene::eventFilter(QObject *watched, QEvent *event)
-{
- if (watched != qApp)
- return false;
-
- switch (event->type()) {
- case QEvent::ApplicationPaletteChange:
- QApplication::postEvent(this, new QEvent(QEvent::ApplicationPaletteChange));
- break;
- case QEvent::ApplicationFontChange:
- QApplication::postEvent(this, new QEvent(QEvent::ApplicationFontChange));
- break;
- default:
- break;
- }
- return false;
-}
-
-/*!
- This event handler, for event \a contextMenuEvent, can be reimplemented in
- a subclass to receive context menu events. The default implementation
- forwards the event to the topmost item that accepts context menu events at
- the position of the event. If no items accept context menu events at this
- position, the event is ignored.
-
- \sa QGraphicsItem::contextMenuEvent()
-*/
-void QGraphicsScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent)
-{
- Q_D(QGraphicsScene);
- // Ignore by default.
- contextMenuEvent->ignore();
-
- // Send the event to all items at this position until one item accepts the
- // event.
- foreach (QGraphicsItem *item, d->itemsAtPosition(contextMenuEvent->screenPos(),
- contextMenuEvent->scenePos(),
- contextMenuEvent->widget())) {
- contextMenuEvent->setPos(item->d_ptr->genericMapFromScene(contextMenuEvent->scenePos(),
- contextMenuEvent->widget()));
- contextMenuEvent->accept();
- if (!d->sendEvent(item, contextMenuEvent))
- break;
-
- if (contextMenuEvent->isAccepted())
- break;
- }
-}
-
-/*!
- This event handler, for event \a event, can be reimplemented in a subclass
- to receive drag enter events for the scene.
-
- The default implementation accepts the event and prepares the scene to
- accept drag move events.
-
- \sa QGraphicsItem::dragEnterEvent(), dragMoveEvent(), dragLeaveEvent(),
- dropEvent()
-*/
-void QGraphicsScene::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
-{
- Q_D(QGraphicsScene);
- d->dragDropItem = 0;
- d->lastDropAction = Qt::IgnoreAction;
- event->accept();
-}
-
-/*!
- This event handler, for event \a event, can be reimplemented in a subclass
- to receive drag move events for the scene.
-
- \sa QGraphicsItem::dragMoveEvent(), dragEnterEvent(), dragLeaveEvent(),
- dropEvent()
-*/
-void QGraphicsScene::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
-{
- Q_D(QGraphicsScene);
- event->ignore();
-
- if (!d->mouseGrabberItems.isEmpty()) {
- // Mouse grabbers that start drag events lose the mouse grab.
- d->clearMouseGrabber();
- d->mouseGrabberButtonDownPos.clear();
- d->mouseGrabberButtonDownScenePos.clear();
- d->mouseGrabberButtonDownScreenPos.clear();
- }
-
- bool eventDelivered = false;
-
- // Find the topmost enabled items under the cursor. They are all
- // candidates for accepting drag & drop events.
- foreach (QGraphicsItem *item, d->itemsAtPosition(event->screenPos(),
- event->scenePos(),
- event->widget())) {
- if (!item->isEnabled() || !item->acceptDrops())
- continue;
-
- if (item != d->dragDropItem) {
- // Enter the new drag drop item. If it accepts the event, we send
- // the leave to the parent item.
- QGraphicsSceneDragDropEvent dragEnter(QEvent::GraphicsSceneDragEnter);
- d->cloneDragDropEvent(&dragEnter, event);
- dragEnter.setDropAction(event->proposedAction());
- d->sendDragDropEvent(item, &dragEnter);
- event->setAccepted(dragEnter.isAccepted());
- event->setDropAction(dragEnter.dropAction());
- if (!event->isAccepted()) {
- // Propagate to the item under
- continue;
- }
-
- d->lastDropAction = event->dropAction();
-
- if (d->dragDropItem) {
- // Leave the last drag drop item. A perfect implementation
- // would set the position of this event to the point where
- // this event and the last event intersect with the item's
- // shape, but that's not easy to do. :-)
- QGraphicsSceneDragDropEvent dragLeave(QEvent::GraphicsSceneDragLeave);
- d->cloneDragDropEvent(&dragLeave, event);
- d->sendDragDropEvent(d->dragDropItem, &dragLeave);
- }
-
- // We've got a new drag & drop item
- d->dragDropItem = item;
- }
-
- // Send the move event.
- event->setDropAction(d->lastDropAction);
- event->accept();
- d->sendDragDropEvent(item, event);
- if (event->isAccepted())
- d->lastDropAction = event->dropAction();
- eventDelivered = true;
- break;
- }
-
- if (!eventDelivered) {
- if (d->dragDropItem) {
- // Leave the last drag drop item
- QGraphicsSceneDragDropEvent dragLeave(QEvent::GraphicsSceneDragLeave);
- d->cloneDragDropEvent(&dragLeave, event);
- d->sendDragDropEvent(d->dragDropItem, &dragLeave);
- d->dragDropItem = 0;
- }
- // Propagate
- event->setDropAction(Qt::IgnoreAction);
- }
-}
-
-/*!
- This event handler, for event \a event, can be reimplemented in a subclass
- to receive drag leave events for the scene.
-
- \sa QGraphicsItem::dragLeaveEvent(), dragEnterEvent(), dragMoveEvent(),
- dropEvent()
-*/
-void QGraphicsScene::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
-{
- Q_D(QGraphicsScene);
- if (d->dragDropItem) {
- // Leave the last drag drop item
- d->sendDragDropEvent(d->dragDropItem, event);
- d->dragDropItem = 0;
- }
-}
-
-/*!
- This event handler, for event \a event, can be reimplemented in a subclass
- to receive drop events for the scene.
-
- \sa QGraphicsItem::dropEvent(), dragEnterEvent(), dragMoveEvent(),
- dragLeaveEvent()
-*/
-void QGraphicsScene::dropEvent(QGraphicsSceneDragDropEvent *event)
-{
- Q_UNUSED(event);
- Q_D(QGraphicsScene);
- if (d->dragDropItem) {
- // Drop on the last drag drop item
- d->sendDragDropEvent(d->dragDropItem, event);
- d->dragDropItem = 0;
- }
-}
-
-/*!
- This event handler, for event \a focusEvent, can be reimplemented in a
- subclass to receive focus in events.
-
- The default implementation sets focus on the scene, and then on the last
- focus item.
-
- \sa QGraphicsItem::focusOutEvent()
-*/
-void QGraphicsScene::focusInEvent(QFocusEvent *focusEvent)
-{
- Q_D(QGraphicsScene);
-
- d->hasFocus = true;
- switch (focusEvent->reason()) {
- case Qt::TabFocusReason:
- if (!focusNextPrevChild(true))
- focusEvent->ignore();
- break;
- case Qt::BacktabFocusReason:
- if (!focusNextPrevChild(false))
- focusEvent->ignore();
- break;
- default:
- if (d->passiveFocusItem) {
- // Set focus on the last focus item
- setFocusItem(d->passiveFocusItem, focusEvent->reason());
- }
- break;
- }
-}
-
-/*!
- This event handler, for event \a focusEvent, can be reimplemented in a
- subclass to receive focus out events.
-
- The default implementation removes focus from any focus item, then removes
- focus from the scene.
-
- \sa QGraphicsItem::focusInEvent()
-*/
-void QGraphicsScene::focusOutEvent(QFocusEvent *focusEvent)
-{
- Q_D(QGraphicsScene);
- d->hasFocus = false;
- d->passiveFocusItem = d->focusItem;
- setFocusItem(0, focusEvent->reason());
-
- // Remove all popups when the scene loses focus.
- if (!d->popupWidgets.isEmpty())
- d->removePopup(d->popupWidgets.first());
-}
-
-/*!
- This event handler, for event \a helpEvent, can be
- reimplemented in a subclass to receive help events. The events
- are of type QEvent::ToolTip, which are created when a tooltip is
- requested.
-
- The default implementation shows the tooltip of the topmost
- item, i.e., the item with the highest z-value, at the mouse
- cursor position. If no item has a tooltip set, this function
- does nothing.
-
- \sa QGraphicsItem::toolTip(), QGraphicsSceneHelpEvent
-*/
-void QGraphicsScene::helpEvent(QGraphicsSceneHelpEvent *helpEvent)
-{
-#ifdef QT_NO_TOOLTIP
- Q_UNUSED(helpEvent);
-#else
- // Find the first item that does tooltips
- Q_D(QGraphicsScene);
- QList<QGraphicsItem *> itemsAtPos = d->itemsAtPosition(helpEvent->screenPos(),
- helpEvent->scenePos(),
- helpEvent->widget());
- QGraphicsItem *toolTipItem = 0;
- for (int i = 0; i < itemsAtPos.size(); ++i) {
- QGraphicsItem *tmp = itemsAtPos.at(i);
- if (tmp->d_func()->isProxyWidget()) {
- // if the item is a proxy widget, the event is forwarded to it
- sendEvent(tmp, helpEvent);
- if (helpEvent->isAccepted())
- return;
- }
- if (!tmp->toolTip().isEmpty()) {
- toolTipItem = tmp;
- break;
- }
- }
-
- // Show or hide the tooltip
- QString text;
- QPoint point;
- if (toolTipItem && !toolTipItem->toolTip().isEmpty()) {
- text = toolTipItem->toolTip();
- point = helpEvent->screenPos();
- }
- QToolTip::showText(point, text, helpEvent->widget());
- helpEvent->setAccepted(!text.isEmpty());
-#endif
-}
-
-bool QGraphicsScenePrivate::itemAcceptsHoverEvents_helper(const QGraphicsItem *item) const
-{
- return (item->d_ptr->acceptsHover
- || (item->d_ptr->isWidget
- && static_cast<const QGraphicsWidget *>(item)->d_func()->hasDecoration()))
- && !item->isBlockedByModalPanel();
-}
-
-/*!
- This event handler, for event \a hoverEvent, can be reimplemented in a
- subclass to receive hover enter events. The default implementation
- forwards the event to the topmost item that accepts hover events at the
- scene position from the event.
-
- \sa QGraphicsItem::hoverEvent(), QGraphicsItem::setAcceptHoverEvents()
-*/
-bool QGraphicsScenePrivate::dispatchHoverEvent(QGraphicsSceneHoverEvent *hoverEvent)
-{
- if (allItemsIgnoreHoverEvents)
- return false;
-
- // Find the first item that accepts hover events, reusing earlier
- // calculated data is possible.
- if (cachedItemsUnderMouse.isEmpty()) {
- cachedItemsUnderMouse = itemsAtPosition(hoverEvent->screenPos(),
- hoverEvent->scenePos(),
- hoverEvent->widget());
- }
-
- QGraphicsItem *item = 0;
- for (int i = 0; i < cachedItemsUnderMouse.size(); ++i) {
- QGraphicsItem *tmp = cachedItemsUnderMouse.at(i);
- if (itemAcceptsHoverEvents_helper(tmp)) {
- item = tmp;
- break;
- }
- }
-
- // Find the common ancestor item for the new topmost hoverItem and the
- // last item in the hoverItem list.
- QGraphicsItem *commonAncestorItem = (item && !hoverItems.isEmpty()) ? item->commonAncestorItem(hoverItems.last()) : 0;
- while (commonAncestorItem && !itemAcceptsHoverEvents_helper(commonAncestorItem))
- commonAncestorItem = commonAncestorItem->parentItem();
- if (commonAncestorItem && commonAncestorItem->panel() != item->panel()) {
- // The common ancestor isn't in the same panel as the two hovered
- // items.
- commonAncestorItem = 0;
- }
-
- // Check if the common ancestor item is known.
- int index = commonAncestorItem ? hoverItems.indexOf(commonAncestorItem) : -1;
- // Send hover leaves to any existing hovered children of the common
- // ancestor item.
- for (int i = hoverItems.size() - 1; i > index; --i) {
- QGraphicsItem *lastItem = hoverItems.takeLast();
- if (itemAcceptsHoverEvents_helper(lastItem))
- sendHoverEvent(QEvent::GraphicsSceneHoverLeave, lastItem, hoverEvent);
- }
-
- // Item is a child of a known item. Generate enter events for the
- // missing links.
- QList<QGraphicsItem *> parents;
- QGraphicsItem *parent = item;
- while (parent && parent != commonAncestorItem) {
- parents.prepend(parent);
- if (parent->isPanel()) {
- // Stop at the panel - we don't deliver beyond this point.
- break;
- }
- parent = parent->parentItem();
- }
- for (int i = 0; i < parents.size(); ++i) {
- parent = parents.at(i);
- hoverItems << parent;
- if (itemAcceptsHoverEvents_helper(parent))
- sendHoverEvent(QEvent::GraphicsSceneHoverEnter, parent, hoverEvent);
- }
-
- // Generate a move event for the item itself
- if (item
- && !hoverItems.isEmpty()
- && item == hoverItems.last()) {
- sendHoverEvent(QEvent::GraphicsSceneHoverMove, item, hoverEvent);
- return true;
- }
- return false;
-}
-
-/*!
- \internal
-
- Handles all actions necessary to clean up the scene when the mouse leaves
- the view.
-*/
-void QGraphicsScenePrivate::leaveScene(QWidget *viewport)
-{
-#ifndef QT_NO_TOOLTIP
- QToolTip::hideText();
-#endif
- QGraphicsView *view = qobject_cast<QGraphicsView *>(viewport->parent());
- // Send HoverLeave events to all existing hover items, topmost first.
- QGraphicsSceneHoverEvent hoverEvent;
- hoverEvent.setWidget(viewport);
-
- if (view) {
- QPoint cursorPos = QCursor::pos();
- hoverEvent.setScenePos(view->mapToScene(viewport->mapFromGlobal(cursorPos)));
- hoverEvent.setLastScenePos(hoverEvent.scenePos());
- hoverEvent.setScreenPos(cursorPos);
- hoverEvent.setLastScreenPos(hoverEvent.screenPos());
- }
-
- while (!hoverItems.isEmpty()) {
- QGraphicsItem *lastItem = hoverItems.takeLast();
- if (itemAcceptsHoverEvents_helper(lastItem))
- sendHoverEvent(QEvent::GraphicsSceneHoverLeave, lastItem, &hoverEvent);
- }
-}
-
-/*!
- This event handler, for event \a keyEvent, can be reimplemented in a
- subclass to receive keypress events. The default implementation forwards
- the event to current focus item.
-
- \sa QGraphicsItem::keyPressEvent(), focusItem()
-*/
-void QGraphicsScene::keyPressEvent(QKeyEvent *keyEvent)
-{
- // ### Merge this function with keyReleaseEvent; they are identical
- // ### (except this comment).
- Q_D(QGraphicsScene);
- QGraphicsItem *item = !d->keyboardGrabberItems.isEmpty() ? d->keyboardGrabberItems.last() : 0;
- if (!item)
- item = focusItem();
- if (item) {
- QGraphicsItem *p = item;
- do {
- // Accept the event by default
- keyEvent->accept();
- // Send it; QGraphicsItem::keyPressEvent ignores it. If the event
- // is filtered out, stop propagating it.
- if (p->isBlockedByModalPanel())
- break;
- if (!d->sendEvent(p, keyEvent))
- break;
- } while (!keyEvent->isAccepted() && !p->isPanel() && (p = p->parentItem()));
- } else {
- keyEvent->ignore();
- }
-}
-
-/*!
- This event handler, for event \a keyEvent, can be reimplemented in a
- subclass to receive key release events. The default implementation
- forwards the event to current focus item.
-
- \sa QGraphicsItem::keyReleaseEvent(), focusItem()
-*/
-void QGraphicsScene::keyReleaseEvent(QKeyEvent *keyEvent)
-{
- // ### Merge this function with keyPressEvent; they are identical (except
- // ### this comment).
- Q_D(QGraphicsScene);
- QGraphicsItem *item = !d->keyboardGrabberItems.isEmpty() ? d->keyboardGrabberItems.last() : 0;
- if (!item)
- item = focusItem();
- if (item) {
- QGraphicsItem *p = item;
- do {
- // Accept the event by default
- keyEvent->accept();
- // Send it; QGraphicsItem::keyPressEvent ignores it. If the event
- // is filtered out, stop propagating it.
- if (p->isBlockedByModalPanel())
- break;
- if (!d->sendEvent(p, keyEvent))
- break;
- } while (!keyEvent->isAccepted() && !p->isPanel() && (p = p->parentItem()));
- } else {
- keyEvent->ignore();
- }
-}
-
-/*!
- This event handler, for event \a mouseEvent, can be reimplemented
- in a subclass to receive mouse press events for the scene.
-
- The default implementation depends on the state of the scene. If
- there is a mouse grabber item, then the event is sent to the mouse
- grabber. Otherwise, it is forwarded to the topmost item that
- accepts mouse events at the scene position from the event, and
- that item promptly becomes the mouse grabber item.
-
- If there is no item at the given position on the scene, the
- selection area is reset, any focus item loses its input focus, and
- the event is then ignored.
-
- \sa QGraphicsItem::mousePressEvent(),
- QGraphicsItem::setAcceptedMouseButtons()
-*/
-void QGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
-{
- Q_D(QGraphicsScene);
- if (d->mouseGrabberItems.isEmpty()) {
- // Dispatch hover events
- QGraphicsSceneHoverEvent hover;
- _q_hoverFromMouseEvent(&hover, mouseEvent);
- d->dispatchHoverEvent(&hover);
- }
-
- d->mousePressEventHandler(mouseEvent);
-}
-
-/*!
- This event handler, for event \a mouseEvent, can be reimplemented
- in a subclass to receive mouse move events for the scene.
-
- The default implementation depends on the mouse grabber state. If there is
- a mouse grabber item, the event is sent to the mouse grabber. If there
- are any items that accept hover events at the current position, the event
- is translated into a hover event and accepted; otherwise it's ignored.
-
- \sa QGraphicsItem::mousePressEvent(), QGraphicsItem::mouseReleaseEvent(),
- QGraphicsItem::mouseDoubleClickEvent(), QGraphicsItem::setAcceptedMouseButtons()
-*/
-void QGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
-{
- Q_D(QGraphicsScene);
- if (d->mouseGrabberItems.isEmpty()) {
- if (mouseEvent->buttons())
- return;
- QGraphicsSceneHoverEvent hover;
- _q_hoverFromMouseEvent(&hover, mouseEvent);
- mouseEvent->setAccepted(d->dispatchHoverEvent(&hover));
- return;
- }
-
- // Forward the event to the mouse grabber
- d->sendMouseEvent(mouseEvent);
- mouseEvent->accept();
-}
-
-/*!
- This event handler, for event \a mouseEvent, can be reimplemented
- in a subclass to receive mouse release events for the scene.
-
- The default implementation depends on the mouse grabber state. If
- there is no mouse grabber, the event is ignored. Otherwise, if
- there is a mouse grabber item, the event is sent to the mouse
- grabber. If this mouse release represents the last pressed button
- on the mouse, the mouse grabber item then loses the mouse grab.
-
- \sa QGraphicsItem::mousePressEvent(), QGraphicsItem::mouseMoveEvent(),
- QGraphicsItem::mouseDoubleClickEvent(), QGraphicsItem::setAcceptedMouseButtons()
-*/
-void QGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
-{
- Q_D(QGraphicsScene);
- if (d->mouseGrabberItems.isEmpty()) {
- mouseEvent->ignore();
- return;
- }
-
- // Forward the event to the mouse grabber
- d->sendMouseEvent(mouseEvent);
- mouseEvent->accept();
-
- // Reset the mouse grabber when the last mouse button has been released.
- if (!mouseEvent->buttons()) {
- if (!d->mouseGrabberItems.isEmpty()) {
- d->lastMouseGrabberItem = d->mouseGrabberItems.last();
- if (d->lastMouseGrabberItemHasImplicitMouseGrab)
- d->mouseGrabberItems.last()->ungrabMouse();
- } else {
- d->lastMouseGrabberItem = 0;
- }
-
- // Generate a hoverevent
- QGraphicsSceneHoverEvent hoverEvent;
- _q_hoverFromMouseEvent(&hoverEvent, mouseEvent);
- d->dispatchHoverEvent(&hoverEvent);
- }
-}
-
-/*!
- This event handler, for event \a mouseEvent, can be reimplemented
- in a subclass to receive mouse doubleclick events for the scene.
-
- If someone doubleclicks on the scene, the scene will first receive
- a mouse press event, followed by a release event (i.e., a click),
- then a doubleclick event, and finally a release event. If the
- doubleclick event is delivered to a different item than the one
- that received the first press and release, it will be delivered as
- a press event. However, tripleclick events are not delivered as
- doubleclick events in this case.
-
- The default implementation is similar to mousePressEvent().
-
- \sa QGraphicsItem::mousePressEvent(), QGraphicsItem::mouseMoveEvent(),
- QGraphicsItem::mouseReleaseEvent(), QGraphicsItem::setAcceptedMouseButtons()
-*/
-void QGraphicsScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *mouseEvent)
-{
- Q_D(QGraphicsScene);
- d->mousePressEventHandler(mouseEvent);
-}
-
-/*!
- This event handler, for event \a wheelEvent, can be reimplemented in a
- subclass to receive mouse wheel events for the scene.
-
- By default, the event is delivered to the topmost visible item under the
- cursor. If ignored, the event propagates to the item beneath, and again
- until the event is accepted, or it reaches the scene. If no items accept
- the event, it is ignored.
-
- \sa QGraphicsItem::wheelEvent()
-*/
-void QGraphicsScene::wheelEvent(QGraphicsSceneWheelEvent *wheelEvent)
-{
- Q_D(QGraphicsScene);
- QList<QGraphicsItem *> wheelCandidates = d->itemsAtPosition(wheelEvent->screenPos(),
- wheelEvent->scenePos(),
- wheelEvent->widget());
-
-#ifdef Q_WS_MAC
- // On Mac, ignore the event if the first item under the mouse is not the last opened
- // popup (or one of its descendant)
- if (!d->popupWidgets.isEmpty() && !wheelCandidates.isEmpty() && wheelCandidates.first() != d->popupWidgets.back() && !d->popupWidgets.back()->isAncestorOf(wheelCandidates.first())) {
- wheelEvent->accept();
- return;
- }
-#else
- // Find the first popup under the mouse (including the popup's descendants) starting from the last.
- // Remove all popups after the one found, or all or them if no popup is under the mouse.
- // Then continue with the event.
- QList<QGraphicsWidget *>::const_iterator iter = d->popupWidgets.end();
- while (--iter >= d->popupWidgets.begin() && !wheelCandidates.isEmpty()) {
- if (wheelCandidates.first() == *iter || (*iter)->isAncestorOf(wheelCandidates.first()))
- break;
- d->removePopup(*iter);
- }
-#endif
-
- bool hasSetFocus = false;
- foreach (QGraphicsItem *item, wheelCandidates) {
- if (!hasSetFocus && item->isEnabled()
- && ((item->flags() & QGraphicsItem::ItemIsFocusable) && item->d_ptr->mouseSetsFocus)) {
- if (item->isWidget() && static_cast<QGraphicsWidget *>(item)->focusPolicy() == Qt::WheelFocus) {
- hasSetFocus = true;
- if (item != focusItem())
- setFocusItem(item, Qt::MouseFocusReason);
- }
- }
-
- wheelEvent->setPos(item->d_ptr->genericMapFromScene(wheelEvent->scenePos(),
- wheelEvent->widget()));
- wheelEvent->accept();
- bool isPanel = item->isPanel();
- d->sendEvent(item, wheelEvent);
- if (isPanel || wheelEvent->isAccepted())
- break;
- }
-}
-
-/*!
- This event handler, for event \a event, can be reimplemented in a
- subclass to receive input method events for the scene.
-
- The default implementation forwards the event to the focusItem().
- If no item currently has focus or the current focus item does not
- accept input methods, this function does nothing.
-
- \sa QGraphicsItem::inputMethodEvent()
-*/
-void QGraphicsScene::inputMethodEvent(QInputMethodEvent *event)
-{
- Q_D(QGraphicsScene);
- if (d->focusItem && (d->focusItem->flags() & QGraphicsItem::ItemAcceptsInputMethod))
- d->sendEvent(d->focusItem, event);
-}
-
-/*!
- Draws the background of the scene using \a painter, before any items and
- the foreground are drawn. Reimplement this function to provide a custom
- background for the scene.
-
- All painting is done in \e scene coordinates. The \a rect
- parameter is the exposed rectangle.
-
- If all you want is to define a color, texture, or gradient for the
- background, you can call setBackgroundBrush() instead.
-
- \sa drawForeground(), drawItems()
-*/
-void QGraphicsScene::drawBackground(QPainter *painter, const QRectF &rect)
-{
- Q_D(QGraphicsScene);
-
- if (d->backgroundBrush.style() != Qt::NoBrush) {
- if (d->painterStateProtection)
- painter->save();
- painter->setBrushOrigin(0, 0);
- painter->fillRect(rect, backgroundBrush());
- if (d->painterStateProtection)
- painter->restore();
- }
-}
-
-/*!
- Draws the foreground of the scene using \a painter, after the background
- and all items have been drawn. Reimplement this function to provide a
- custom foreground for the scene.
-
- All painting is done in \e scene coordinates. The \a rect
- parameter is the exposed rectangle.
-
- If all you want is to define a color, texture or gradient for the
- foreground, you can call setForegroundBrush() instead.
-
- \sa drawBackground(), drawItems()
-*/
-void QGraphicsScene::drawForeground(QPainter *painter, const QRectF &rect)
-{
- Q_D(QGraphicsScene);
-
- if (d->foregroundBrush.style() != Qt::NoBrush) {
- if (d->painterStateProtection)
- painter->save();
- painter->setBrushOrigin(0, 0);
- painter->fillRect(rect, foregroundBrush());
- if (d->painterStateProtection)
- painter->restore();
- }
-}
-
-static void _q_paintItem(QGraphicsItem *item, QPainter *painter,
- const QStyleOptionGraphicsItem *option, QWidget *widget,
- bool useWindowOpacity, bool painterStateProtection)
-{
- if (!item->isWidget()) {
- item->paint(painter, option, widget);
- return;
- }
- QGraphicsWidget *widgetItem = static_cast<QGraphicsWidget *>(item);
- QGraphicsProxyWidget *proxy = qobject_cast<QGraphicsProxyWidget *>(widgetItem);
- const qreal windowOpacity = (proxy && proxy->widget() && useWindowOpacity)
- ? proxy->widget()->windowOpacity() : 1.0;
- const qreal oldPainterOpacity = painter->opacity();
-
- if (qFuzzyIsNull(windowOpacity))
- return;
- // Set new painter opacity.
- if (windowOpacity < 1.0)
- painter->setOpacity(oldPainterOpacity * windowOpacity);
-
- // set layoutdirection on the painter
- Qt::LayoutDirection oldLayoutDirection = painter->layoutDirection();
- painter->setLayoutDirection(widgetItem->layoutDirection());
-
- if (widgetItem->isWindow() && widgetItem->windowType() != Qt::Popup && widgetItem->windowType() != Qt::ToolTip
- && !(widgetItem->windowFlags() & Qt::FramelessWindowHint)) {
- if (painterStateProtection)
- painter->save();
- widgetItem->paintWindowFrame(painter, option, widget);
- if (painterStateProtection)
- painter->restore();
- } else if (widgetItem->autoFillBackground()) {
- painter->fillRect(option->exposedRect, widgetItem->palette().window());
- }
-
- widgetItem->paint(painter, option, widget);
-
- // Restore layoutdirection on the painter.
- painter->setLayoutDirection(oldLayoutDirection);
- // Restore painter opacity.
- if (windowOpacity < 1.0)
- painter->setOpacity(oldPainterOpacity);
-}
-
-static void _q_paintIntoCache(QPixmap *pix, QGraphicsItem *item, const QRegion &pixmapExposed,
- const QTransform &itemToPixmap, QPainter::RenderHints renderHints,
- const QStyleOptionGraphicsItem *option, bool painterStateProtection)
-{
- QPixmap subPix;
- QPainter pixmapPainter;
- QRect br = pixmapExposed.boundingRect();
-
- // Don't use subpixmap if we get a full update.
- if (pixmapExposed.isEmpty() || (pixmapExposed.rectCount() == 1 && br.contains(pix->rect()))) {
- pix->fill(Qt::transparent);
- pixmapPainter.begin(pix);
- } else {
- subPix = QPixmap(br.size());
- subPix.fill(Qt::transparent);
- pixmapPainter.begin(&subPix);
- pixmapPainter.translate(-br.topLeft());
- if (!pixmapExposed.isEmpty()) {
- // Applied to subPix; paint is adjusted to the coordinate space is
- // correct.
- pixmapPainter.setClipRegion(pixmapExposed);
- }
- }
-
- pixmapPainter.setRenderHints(pixmapPainter.renderHints(), false);
- pixmapPainter.setRenderHints(renderHints, true);
- pixmapPainter.setWorldTransform(itemToPixmap, true);
-
- // Render.
- _q_paintItem(item, &pixmapPainter, option, 0, false, painterStateProtection);
- pixmapPainter.end();
-
- if (!subPix.isNull()) {
- // Blit the subpixmap into the main pixmap.
- pixmapPainter.begin(pix);
- pixmapPainter.setCompositionMode(QPainter::CompositionMode_Source);
- pixmapPainter.setClipRegion(pixmapExposed);
- pixmapPainter.drawPixmap(br.topLeft(), subPix);
- pixmapPainter.end();
- }
-}
-
-// Copied from qpaintengine_vg.cpp
-// Returns true for 90, 180, and 270 degree rotations.
-static inline bool transformIsSimple(const QTransform& transform)
-{
- QTransform::TransformationType type = transform.type();
- if (type <= QTransform::TxScale) {
- return true;
- } else if (type == QTransform::TxRotate) {
- // Check for 90, and 270 degree rotations.
- qreal m11 = transform.m11();
- qreal m12 = transform.m12();
- qreal m21 = transform.m21();
- qreal m22 = transform.m22();
- if (m11 == 0.0f && m22 == 0.0f) {
- if (m12 == 1.0f && m21 == -1.0f)
- return true; // 90 degrees.
- else if (m12 == -1.0f && m21 == 1.0f)
- return true; // 270 degrees.
- else if (m12 == -1.0f && m21 == -1.0f)
- return true; // 90 degrees inverted y.
- else if (m12 == 1.0f && m21 == 1.0f)
- return true; // 270 degrees inverted y.
- }
- }
- return false;
-}
-
-/*!
- \internal
-
- Draws items directly, or using cache.
-*/
-void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painter,
- const QStyleOptionGraphicsItem *option, QWidget *widget,
- bool painterStateProtection)
-{
- QGraphicsItemPrivate *itemd = item->d_ptr.data();
- QGraphicsItem::CacheMode cacheMode = QGraphicsItem::CacheMode(itemd->cacheMode);
-
- // Render directly, using no cache.
- if (cacheMode == QGraphicsItem::NoCache
-#ifdef Q_WS_X11
- || !X11->use_xrender
-#endif
- ) {
- _q_paintItem(static_cast<QGraphicsWidget *>(item), painter, option, widget, true, painterStateProtection);
- return;
- }
-
- const qreal oldPainterOpacity = painter->opacity();
- qreal newPainterOpacity = oldPainterOpacity;
- QGraphicsProxyWidget *proxy = item->isWidget() ? qobject_cast<QGraphicsProxyWidget *>(static_cast<QGraphicsWidget *>(item)) : 0;
- if (proxy && proxy->widget()) {
- const qreal windowOpacity = proxy->widget()->windowOpacity();
- if (windowOpacity < 1.0)
- newPainterOpacity *= windowOpacity;
- }
-
- // Item's (local) bounding rect
- QRectF brect = item->boundingRect();
- QRectF adjustedBrect(brect);
- _q_adjustRect(&adjustedBrect);
- if (adjustedBrect.isEmpty())
- return;
-
- // Fetch the off-screen transparent buffer and exposed area info.
- QPixmapCache::Key pixmapKey;
- QPixmap pix;
- bool pixmapFound;
- QGraphicsItemCache *itemCache = itemd->extraItemCache();
- if (cacheMode == QGraphicsItem::ItemCoordinateCache) {
- pixmapKey = itemCache->key;
- } else {
- pixmapKey = itemCache->deviceData.value(widget).key;
- }
-
- // Find pixmap in cache.
- pixmapFound = QPixmapCache::find(pixmapKey, &pix);
-
- // Render using item coordinate cache mode.
- if (cacheMode == QGraphicsItem::ItemCoordinateCache) {
- QSize pixmapSize;
- bool fixedCacheSize = false;
- QRect br = brect.toAlignedRect();
- if ((fixedCacheSize = itemCache->fixedSize.isValid())) {
- pixmapSize = itemCache->fixedSize;
- } else {
- pixmapSize = br.size();
- }
-
- // Create or recreate the pixmap.
- int adjust = itemCache->fixedSize.isValid() ? 0 : 2;
- QSize adjustSize(adjust*2, adjust*2);
- br.adjust(-adjust, -adjust, adjust, adjust);
- if (pix.isNull() || (!fixedCacheSize && (pixmapSize + adjustSize) != pix.size())) {
- pix = QPixmap(pixmapSize + adjustSize);
- itemCache->boundingRect = br;
- itemCache->exposed.clear();
- itemCache->allExposed = true;
- } else if (itemCache->boundingRect != br) {
- itemCache->boundingRect = br;
- itemCache->exposed.clear();
- itemCache->allExposed = true;
- }
-
- // Redraw any newly exposed areas.
- if (itemCache->allExposed || !itemCache->exposed.isEmpty()) {
-
- //We know that we will modify the pixmap, removing it from the cache
- //will detach the one we have and avoid a deep copy
- if (pixmapFound)
- QPixmapCache::remove(pixmapKey);
-
- // Fit the item's bounding rect into the pixmap's coordinates.
- QTransform itemToPixmap;
- if (fixedCacheSize) {
- const QPointF scale(pixmapSize.width() / brect.width(), pixmapSize.height() / brect.height());
- itemToPixmap.scale(scale.x(), scale.y());
- }
- itemToPixmap.translate(-br.x(), -br.y());
-
- // Generate the item's exposedRect and map its list of expose
- // rects to device coordinates.
- styleOptionTmp = *option;
- QRegion pixmapExposed;
- QRectF exposedRect;
- if (!itemCache->allExposed) {
- for (int i = 0; i < itemCache->exposed.size(); ++i) {
- QRectF r = itemCache->exposed.at(i);
- exposedRect |= r;
- pixmapExposed += itemToPixmap.mapRect(r).toAlignedRect();
- }
- } else {
- exposedRect = brect;
- }
- styleOptionTmp.exposedRect = exposedRect;
-
- // Render.
- _q_paintIntoCache(&pix, item, pixmapExposed, itemToPixmap, painter->renderHints(),
- &styleOptionTmp, painterStateProtection);
-
- // insert this pixmap into the cache.
- itemCache->key = QPixmapCache::insert(pix);
-
- // Reset expose data.
- itemCache->allExposed = false;
- itemCache->exposed.clear();
- }
-
- // Redraw the exposed area using the transformed painter. Depending on
- // the hardware, this may be a server-side operation, or an expensive
- // qpixmap-image-transform-pixmap roundtrip.
- if (newPainterOpacity != oldPainterOpacity) {
- painter->setOpacity(newPainterOpacity);
- painter->drawPixmap(br.topLeft(), pix);
- painter->setOpacity(oldPainterOpacity);
- } else {
- painter->drawPixmap(br.topLeft(), pix);
- }
- return;
- }
-
- // Render using device coordinate cache mode.
- if (cacheMode == QGraphicsItem::DeviceCoordinateCache) {
- // Find the item's bounds in device coordinates.
- QRectF deviceBounds = painter->worldTransform().mapRect(brect);
- QRect deviceRect = deviceBounds.toRect().adjusted(-1, -1, 1, 1);
- if (deviceRect.isEmpty())
- return;
- QRect viewRect = widget ? widget->rect() : QRect();
- if (widget && !viewRect.intersects(deviceRect))
- return;
-
- // Resort to direct rendering if the device rect exceeds the
- // (optional) maximum bounds. (QGraphicsSvgItem uses this).
- QSize maximumCacheSize =
- itemd->extra(QGraphicsItemPrivate::ExtraMaxDeviceCoordCacheSize).toSize();
- if (!maximumCacheSize.isEmpty()
- && (deviceRect.width() > maximumCacheSize.width()
- || deviceRect.height() > maximumCacheSize.height())) {
- _q_paintItem(static_cast<QGraphicsWidget *>(item), painter, option, widget,
- oldPainterOpacity != newPainterOpacity, painterStateProtection);
- return;
- }
-
- // Create or reuse offscreen pixmap, possibly scroll/blit from the old one.
- // If the world transform is rotated we always recreate the cache to avoid
- // wrong blending.
- bool pixModified = false;
- QGraphicsItemCache::DeviceData *deviceData = &itemCache->deviceData[widget];
- bool invertable = true;
- QTransform diff = deviceData->lastTransform.inverted(&invertable);
- if (invertable)
- diff *= painter->worldTransform();
- deviceData->lastTransform = painter->worldTransform();
- bool allowPartialCacheExposure = false;
- bool simpleTransform = invertable && diff.type() <= QTransform::TxTranslate
- && transformIsSimple(painter->worldTransform());
- if (!simpleTransform) {
- pixModified = true;
- itemCache->allExposed = true;
- itemCache->exposed.clear();
- deviceData->cacheIndent = QPoint();
- pix = QPixmap();
- } else if (!viewRect.isNull()) {
- allowPartialCacheExposure = deviceData->cacheIndent != QPoint();
- }
-
- // Allow partial cache exposure if the device rect isn't fully contained and
- // deviceRect is 20% taller or wider than the viewRect.
- if (!allowPartialCacheExposure && !viewRect.isNull() && !viewRect.contains(deviceRect)) {
- allowPartialCacheExposure = (viewRect.width() * 1.2 < deviceRect.width())
- || (viewRect.height() * 1.2 < deviceRect.height());
- }
-
- QRegion scrollExposure;
- if (allowPartialCacheExposure) {
- // Part of pixmap is drawn. Either device contains viewrect (big
- // item covers whole screen) or parts of device are outside the
- // viewport. In either case the device rect must be the intersect
- // between the two.
- int dx = deviceRect.left() < viewRect.left() ? viewRect.left() - deviceRect.left() : 0;
- int dy = deviceRect.top() < viewRect.top() ? viewRect.top() - deviceRect.top() : 0;
- QPoint newCacheIndent(dx, dy);
- deviceRect &= viewRect;
-
- if (pix.isNull()) {
- deviceData->cacheIndent = QPoint();
- itemCache->allExposed = true;
- itemCache->exposed.clear();
- pixModified = true;
- }
-
- // Copy / "scroll" the old pixmap onto the new ole and calculate
- // scrolled exposure.
- if (newCacheIndent != deviceData->cacheIndent || deviceRect.size() != pix.size()) {
- QPoint diff = newCacheIndent - deviceData->cacheIndent;
- QPixmap newPix(deviceRect.size());
- // ### Investigate removing this fill (test with Plasma and
- // graphicssystem raster).
- newPix.fill(Qt::transparent);
- if (!pix.isNull()) {
- QPainter newPixPainter(&newPix);
- newPixPainter.drawPixmap(-diff, pix);
- newPixPainter.end();
- }
- QRegion exposed;
- exposed += newPix.rect();
- if (!pix.isNull())
- exposed -= QRect(-diff, pix.size());
- scrollExposure = exposed;
-
- pix = newPix;
- pixModified = true;
- }
- deviceData->cacheIndent = newCacheIndent;
- } else {
- // Full pixmap is drawn.
- deviceData->cacheIndent = QPoint();
-
- // Auto-adjust the pixmap size.
- if (deviceRect.size() != pix.size()) {
- // exposed needs to cover the whole pixmap
- pix = QPixmap(deviceRect.size());
- pixModified = true;
- itemCache->allExposed = true;
- itemCache->exposed.clear();
- }
- }
-
- // Check for newly invalidated areas.
- if (itemCache->allExposed || !itemCache->exposed.isEmpty() || !scrollExposure.isEmpty()) {
- //We know that we will modify the pixmap, removing it from the cache
- //will detach the one we have and avoid a deep copy
- if (pixmapFound)
- QPixmapCache::remove(pixmapKey);
-
- // Construct an item-to-pixmap transform.
- QPointF p = deviceRect.topLeft();
- QTransform itemToPixmap = painter->worldTransform();
- if (!p.isNull())
- itemToPixmap *= QTransform::fromTranslate(-p.x(), -p.y());
-
- // Map the item's logical expose to pixmap coordinates.
- QRegion pixmapExposed = scrollExposure;
- if (!itemCache->allExposed) {
- const QVector<QRectF> &exposed = itemCache->exposed;
- for (int i = 0; i < exposed.size(); ++i)
- pixmapExposed += itemToPixmap.mapRect(exposed.at(i)).toRect().adjusted(-1, -1, 1, 1);
- }
-
- // Calculate the style option's exposedRect.
- QRectF br;
- if (itemCache->allExposed) {
- br = item->boundingRect();
- } else {
- const QVector<QRectF> &exposed = itemCache->exposed;
- for (int i = 0; i < exposed.size(); ++i)
- br |= exposed.at(i);
- QTransform pixmapToItem = itemToPixmap.inverted();
- foreach (QRect r, scrollExposure.rects())
- br |= pixmapToItem.mapRect(r);
- }
- styleOptionTmp = *option;
- styleOptionTmp.exposedRect = br.adjusted(-1, -1, 1, 1);
-
- // Render the exposed areas.
- _q_paintIntoCache(&pix, item, pixmapExposed, itemToPixmap, painter->renderHints(),
- &styleOptionTmp, painterStateProtection);
-
- // Reset expose data.
- pixModified = true;
- itemCache->allExposed = false;
- itemCache->exposed.clear();
- }
-
- if (pixModified) {
- // Insert this pixmap into the cache.
- deviceData->key = QPixmapCache::insert(pix);
- }
-
- // Redraw the exposed area using an untransformed painter. This
- // effectively becomes a bitblit that does not transform the cache.
- QTransform restoreTransform = painter->worldTransform();
- painter->setWorldTransform(QTransform());
- if (newPainterOpacity != oldPainterOpacity) {
- painter->setOpacity(newPainterOpacity);
- painter->drawPixmap(deviceRect.topLeft(), pix);
- painter->setOpacity(oldPainterOpacity);
- } else {
- painter->drawPixmap(deviceRect.topLeft(), pix);
- }
- painter->setWorldTransform(restoreTransform);
- return;
- }
-}
-
-void QGraphicsScenePrivate::drawItems(QPainter *painter, const QTransform *const viewTransform,
- QRegion *exposedRegion, QWidget *widget)
-{
- // Make sure we don't have unpolished items before we draw.
- if (!unpolishedItems.isEmpty())
- _q_polishItems();
-
- updateAll = false;
- QRectF exposedSceneRect;
- if (exposedRegion && indexMethod != QGraphicsScene::NoIndex) {
- exposedSceneRect = exposedRegion->boundingRect().adjusted(-1, -1, 1, 1);
- if (viewTransform)
- exposedSceneRect = viewTransform->inverted().mapRect(exposedSceneRect);
- }
- const QList<QGraphicsItem *> tli = index->estimateTopLevelItems(exposedSceneRect, Qt::AscendingOrder);
- for (int i = 0; i < tli.size(); ++i)
- drawSubtreeRecursive(tli.at(i), painter, viewTransform, exposedRegion, widget);
-}
-
-void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *painter,
- const QTransform *const viewTransform,
- QRegion *exposedRegion, QWidget *widget,
- qreal parentOpacity, const QTransform *const effectTransform)
-{
- Q_ASSERT(item);
-
- if (!item->d_ptr->visible)
- return;
-
- const bool itemHasContents = !(item->d_ptr->flags & QGraphicsItem::ItemHasNoContents);
- const bool itemHasChildren = !item->d_ptr->children.isEmpty();
- if (!itemHasContents && !itemHasChildren)
- return; // Item has neither contents nor children!(?)
-
- const qreal opacity = item->d_ptr->combineOpacityFromParent(parentOpacity);
- const bool itemIsFullyTransparent = QGraphicsItemPrivate::isOpacityNull(opacity);
- if (itemIsFullyTransparent && (!itemHasChildren || item->d_ptr->childrenCombineOpacity()))
- return;
-
- QTransform transform(Qt::Uninitialized);
- QTransform *transformPtr = 0;
- bool translateOnlyTransform = false;
-#define ENSURE_TRANSFORM_PTR \
- if (!transformPtr) { \
- Q_ASSERT(!itemIsUntransformable); \
- if (viewTransform) { \
- transform = item->d_ptr->sceneTransform; \
- transform *= *viewTransform; \
- transformPtr = &transform; \
- } else { \
- transformPtr = &item->d_ptr->sceneTransform; \
- translateOnlyTransform = item->d_ptr->sceneTransformTranslateOnly; \
- } \
- }
-
- // Update the item's scene transform if the item is transformable;
- // otherwise calculate the full transform,
- bool wasDirtyParentSceneTransform = false;
- const bool itemIsUntransformable = item->d_ptr->itemIsUntransformable();
- if (itemIsUntransformable) {
- transform = item->deviceTransform(viewTransform ? *viewTransform : QTransform());
- transformPtr = &transform;
- } else if (item->d_ptr->dirtySceneTransform) {
- item->d_ptr->updateSceneTransformFromParent();
- Q_ASSERT(!item->d_ptr->dirtySceneTransform);
- wasDirtyParentSceneTransform = true;
- }
-
- const bool itemClipsChildrenToShape = (item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape);
- bool drawItem = itemHasContents && !itemIsFullyTransparent;
- if (drawItem) {
- const QRectF brect = adjustedItemEffectiveBoundingRect(item);
- ENSURE_TRANSFORM_PTR
- QRect viewBoundingRect = translateOnlyTransform ? brect.translated(transformPtr->dx(), transformPtr->dy()).toAlignedRect()
- : transformPtr->mapRect(brect).toAlignedRect();
- viewBoundingRect.adjust(-int(rectAdjust), -int(rectAdjust), rectAdjust, rectAdjust);
- if (widget)
- item->d_ptr->paintedViewBoundingRects.insert(widget, viewBoundingRect);
- drawItem = exposedRegion ? exposedRegion->intersects(viewBoundingRect)
- : !viewBoundingRect.normalized().isEmpty();
- if (!drawItem) {
- if (!itemHasChildren)
- return;
- if (itemClipsChildrenToShape) {
- if (wasDirtyParentSceneTransform)
- item->d_ptr->invalidateChildrenSceneTransform();
- return;
- }
- }
- } // else we know for sure this item has children we must process.
-
- if (itemHasChildren && itemClipsChildrenToShape)
- ENSURE_TRANSFORM_PTR;
-
-#ifndef QT_NO_GRAPHICSEFFECT
- if (item->d_ptr->graphicsEffect && item->d_ptr->graphicsEffect->isEnabled()) {
- ENSURE_TRANSFORM_PTR;
- QGraphicsItemPaintInfo info(viewTransform, transformPtr, effectTransform, exposedRegion, widget, &styleOptionTmp,
- painter, opacity, wasDirtyParentSceneTransform, itemHasContents && !itemIsFullyTransparent);
- QGraphicsEffectSource *source = item->d_ptr->graphicsEffect->d_func()->source;
- QGraphicsItemEffectSourcePrivate *sourced = static_cast<QGraphicsItemEffectSourcePrivate *>
- (source->d_func());
- sourced->info = &info;
- const QTransform restoreTransform = painter->worldTransform();
- if (effectTransform)
- painter->setWorldTransform(*transformPtr * *effectTransform);
- else
- painter->setWorldTransform(*transformPtr);
- painter->setOpacity(opacity);
-
- if (sourced->currentCachedSystem() != Qt::LogicalCoordinates
- && sourced->lastEffectTransform != painter->worldTransform())
- {
- if (sourced->lastEffectTransform.type() <= QTransform::TxTranslate
- && painter->worldTransform().type() <= QTransform::TxTranslate)
- {
- QRectF sourceRect = sourced->boundingRect(Qt::DeviceCoordinates);
- QRect effectRect = sourced->paddedEffectRect(Qt::DeviceCoordinates, sourced->currentCachedMode(), sourceRect);
-
- sourced->setCachedOffset(effectRect.topLeft());
- } else {
- sourced->invalidateCache(QGraphicsEffectSourcePrivate::TransformChanged);
- }
-
- sourced->lastEffectTransform = painter->worldTransform();
- }
-
- item->d_ptr->graphicsEffect->draw(painter);
- painter->setWorldTransform(restoreTransform);
- sourced->info = 0;
- } else
-#endif //QT_NO_GRAPHICSEFFECT
- {
- draw(item, painter, viewTransform, transformPtr, exposedRegion, widget, opacity,
- effectTransform, wasDirtyParentSceneTransform, drawItem);
- }
-}
-
-static inline void setClip(QPainter *painter, QGraphicsItem *item)
-{
- painter->save();
- QRectF clipRect;
- const QPainterPath clipPath(item->shape());
- if (QPathClipper::pathToRect(clipPath, &clipRect))
- painter->setClipRect(clipRect, Qt::IntersectClip);
- else
- painter->setClipPath(clipPath, Qt::IntersectClip);
-}
-
-static inline void setWorldTransform(QPainter *painter, const QTransform *const transformPtr,
- const QTransform *effectTransform)
-{
- Q_ASSERT(transformPtr);
- if (effectTransform)
- painter->setWorldTransform(*transformPtr * *effectTransform);
- else
- painter->setWorldTransform(*transformPtr);
-}
-
-void QGraphicsScenePrivate::draw(QGraphicsItem *item, QPainter *painter, const QTransform *const viewTransform,
- const QTransform *const transformPtr, QRegion *exposedRegion, QWidget *widget,
- qreal opacity, const QTransform *effectTransform,
- bool wasDirtyParentSceneTransform, bool drawItem)
-{
- const bool itemIsFullyTransparent = QGraphicsItemPrivate::isOpacityNull(opacity);
- const bool itemClipsChildrenToShape = (item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape);
- const bool itemHasChildren = !item->d_ptr->children.isEmpty();
- bool setChildClip = itemClipsChildrenToShape;
- bool itemHasChildrenStackedBehind = false;
-
- int i = 0;
- if (itemHasChildren) {
- if (itemClipsChildrenToShape)
- setWorldTransform(painter, transformPtr, effectTransform);
-
- item->d_ptr->ensureSortedChildren();
- // Items with the 'ItemStacksBehindParent' flag are put in front of the list
- // so all we have to do is to check the first item.
- itemHasChildrenStackedBehind = (item->d_ptr->children.at(0)->d_ptr->flags
- & QGraphicsItem::ItemStacksBehindParent);
-
- if (itemHasChildrenStackedBehind) {
- if (itemClipsChildrenToShape) {
- setClip(painter, item);
- setChildClip = false;
- }
-
- // Draw children behind
- for (i = 0; i < item->d_ptr->children.size(); ++i) {
- QGraphicsItem *child = item->d_ptr->children.at(i);
- if (wasDirtyParentSceneTransform)
- child->d_ptr->dirtySceneTransform = 1;
- if (!(child->d_ptr->flags & QGraphicsItem::ItemStacksBehindParent))
- break;
- if (itemIsFullyTransparent && !(child->d_ptr->flags & QGraphicsItem::ItemIgnoresParentOpacity))
- continue;
- drawSubtreeRecursive(child, painter, viewTransform, exposedRegion, widget, opacity, effectTransform);
- }
- }
- }
-
- // Draw item
- if (drawItem) {
- Q_ASSERT(!itemIsFullyTransparent);
- Q_ASSERT(!(item->d_ptr->flags & QGraphicsItem::ItemHasNoContents));
- Q_ASSERT(transformPtr);
- item->d_ptr->initStyleOption(&styleOptionTmp, *transformPtr, exposedRegion
- ? *exposedRegion : QRegion(), exposedRegion == 0);
-
- const bool itemClipsToShape = item->d_ptr->flags & QGraphicsItem::ItemClipsToShape;
- bool restorePainterClip = false;
-
- if (!itemHasChildren || !itemClipsChildrenToShape) {
- // Item does not have children or clip children to shape.
- setWorldTransform(painter, transformPtr, effectTransform);
- if ((restorePainterClip = itemClipsToShape))
- setClip(painter, item);
- } else if (itemHasChildrenStackedBehind){
- // Item clips children to shape and has children stacked behind, which means
- // the painter is already clipped to the item's shape.
- if (itemClipsToShape) {
- // The clip is already correct. Ensure correct world transform.
- setWorldTransform(painter, transformPtr, effectTransform);
- } else {
- // Remove clip (this also ensures correct world transform).
- painter->restore();
- setChildClip = true;
- }
- } else if (itemClipsToShape) {
- // Item clips children and itself to shape. It does not have hildren stacked
- // behind, which means the clip has not yet been set. We set it now and re-use it
- // for the children.
- setClip(painter, item);
- setChildClip = false;
- }
-
- if (painterStateProtection && !restorePainterClip)
- painter->save();
-
- painter->setOpacity(opacity);
- if (!item->d_ptr->cacheMode && !item->d_ptr->isWidget)
- item->paint(painter, &styleOptionTmp, widget);
- else
- drawItemHelper(item, painter, &styleOptionTmp, widget, painterStateProtection);
-
- if (painterStateProtection || restorePainterClip)
- painter->restore();
-
- static int drawRect = qgetenv("QT_DRAW_SCENE_ITEM_RECTS").toInt();
- if (drawRect) {
- QPen oldPen = painter->pen();
- QBrush oldBrush = painter->brush();
- quintptr ptr = reinterpret_cast<quintptr>(item);
- const QColor color = QColor::fromHsv(ptr % 255, 255, 255);
- painter->setPen(color);
- painter->setBrush(Qt::NoBrush);
- painter->drawRect(adjustedItemBoundingRect(item));
- painter->setPen(oldPen);
- painter->setBrush(oldBrush);
- }
- }
-
- // Draw children in front
- if (itemHasChildren) {
- if (setChildClip)
- setClip(painter, item);
-
- for (; i < item->d_ptr->children.size(); ++i) {
- QGraphicsItem *child = item->d_ptr->children.at(i);
- if (wasDirtyParentSceneTransform)
- child->d_ptr->dirtySceneTransform = 1;
- if (itemIsFullyTransparent && !(child->d_ptr->flags & QGraphicsItem::ItemIgnoresParentOpacity))
- continue;
- drawSubtreeRecursive(child, painter, viewTransform, exposedRegion, widget, opacity, effectTransform);
- }
-
- // Restore child clip
- if (itemClipsChildrenToShape)
- painter->restore();
- }
-}
-
-void QGraphicsScenePrivate::markDirty(QGraphicsItem *item, const QRectF &rect, bool invalidateChildren,
- bool force, bool ignoreOpacity, bool removingItemFromScene,
- bool updateBoundingRect)
-{
- Q_ASSERT(item);
- if (updateAll)
- return;
-
- if (removingItemFromScene && !ignoreOpacity && !item->d_ptr->ignoreOpacity) {
- // If any of the item's ancestors ignore opacity, it means that the opacity
- // was set to 0 (and the update request has not yet been processed). That
- // also means that we have to ignore the opacity for the item itself; otherwise
- // things like: parent->setOpacity(0); scene->removeItem(child) won't work.
- // Note that we only do this when removing items from the scene. In all other
- // cases the ignoreOpacity bit propagates properly in processDirtyItems, but
- // since the item is removed immediately it won't be processed there.
- QGraphicsItem *p = item->d_ptr->parent;
- while (p) {
- if (p->d_ptr->ignoreOpacity) {
- item->d_ptr->ignoreOpacity = true;
- break;
- }
- p = p->d_ptr->parent;
- }
- }
-
- if (item->d_ptr->discardUpdateRequest(/*ignoreVisibleBit=*/force,
- /*ignoreDirtyBit=*/removingItemFromScene || invalidateChildren,
- /*ignoreOpacity=*/ignoreOpacity)) {
- if (item->d_ptr->dirty) {
- // The item is already marked as dirty and will be processed later. However,
- // we have to make sure ignoreVisible and ignoreOpacity are set properly;
- // otherwise things like: item->update(); item->hide() (force is now true)
- // won't work as expected.
- if (force)
- item->d_ptr->ignoreVisible = 1;
- if (ignoreOpacity)
- item->d_ptr->ignoreOpacity = 1;
- }
- return;
- }
-
- const bool fullItemUpdate = rect.isNull();
- if (!fullItemUpdate && rect.isEmpty())
- return;
-
- if (!processDirtyItemsEmitted) {
- QMetaMethod method = q_ptr->metaObject()->method(processDirtyItemsIndex);
- method.invoke(q_ptr, Qt::QueuedConnection);
-// QMetaObject::invokeMethod(q_ptr, "_q_processDirtyItems", Qt::QueuedConnection);
- processDirtyItemsEmitted = true;
- }
-
- if (removingItemFromScene) {
- // Note that this function can be called from the item's destructor, so
- // do NOT call any virtual functions on it within this block.
- if (isSignalConnected(changedSignalIndex) || views.isEmpty()) {
- // This block of code is kept for compatibility. Since 4.5, by default
- // QGraphicsView does not connect the signal and we use the below
- // method of delivering updates.
- q_func()->update();
- return;
- }
-
- for (int i = 0; i < views.size(); ++i) {
- QGraphicsViewPrivate *viewPrivate = views.at(i)->d_func();
- QRect rect = item->d_ptr->paintedViewBoundingRects.value(viewPrivate->viewport);
- rect.translate(viewPrivate->dirtyScrollOffset);
- viewPrivate->updateRect(rect);
- }
- return;
- }
-
- bool hasNoContents = item->d_ptr->flags & QGraphicsItem::ItemHasNoContents;
- if (!hasNoContents) {
- item->d_ptr->dirty = 1;
- if (fullItemUpdate)
- item->d_ptr->fullUpdatePending = 1;
- else if (!item->d_ptr->fullUpdatePending)
- item->d_ptr->needsRepaint |= rect;
- } else if (item->d_ptr->graphicsEffect) {
- invalidateChildren = true;
- }
-
- if (invalidateChildren) {
- item->d_ptr->allChildrenDirty = 1;
- item->d_ptr->dirtyChildren = 1;
- }
-
- if (force)
- item->d_ptr->ignoreVisible = 1;
- if (ignoreOpacity)
- item->d_ptr->ignoreOpacity = 1;
-
- if (!updateBoundingRect)
- item->d_ptr->markParentDirty();
-}
-
-static inline bool updateHelper(QGraphicsViewPrivate *view, QGraphicsItemPrivate *item,
- const QRectF &rect, bool itemIsUntransformable)
-{
- Q_ASSERT(view);
- Q_ASSERT(item);
-
- QGraphicsItem *itemq = static_cast<QGraphicsItem *>(item->q_ptr);
- QGraphicsView *viewq = static_cast<QGraphicsView *>(view->q_ptr);
-
- if (itemIsUntransformable) {
- const QTransform xform = itemq->deviceTransform(viewq->viewportTransform());
- if (!item->hasBoundingRegionGranularity)
- return view->updateRectF(xform.mapRect(rect));
- return view->updateRegion(rect, xform);
- }
-
- if (item->sceneTransformTranslateOnly && view->identityMatrix) {
- const qreal dx = item->sceneTransform.dx();
- const qreal dy = item->sceneTransform.dy();
- QRectF r(rect);
- r.translate(dx - view->horizontalScroll(), dy - view->verticalScroll());
- return view->updateRectF(r);
- }
-
- if (!viewq->isTransformed()) {
- if (!item->hasBoundingRegionGranularity)
- return view->updateRectF(item->sceneTransform.mapRect(rect));
- return view->updateRegion(rect, item->sceneTransform);
- }
-
- QTransform xform = item->sceneTransform;
- xform *= viewq->viewportTransform();
- if (!item->hasBoundingRegionGranularity)
- return view->updateRectF(xform.mapRect(rect));
- return view->updateRegion(rect, xform);
-}
-
-void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool dirtyAncestorContainsChildren,
- qreal parentOpacity)
-{
- Q_Q(QGraphicsScene);
- Q_ASSERT(item);
- Q_ASSERT(!updateAll);
-
- if (!item->d_ptr->dirty && !item->d_ptr->dirtyChildren) {
- resetDirtyItem(item);
- return;
- }
-
- const bool itemIsHidden = !item->d_ptr->ignoreVisible && !item->d_ptr->visible;
- if (itemIsHidden) {
- resetDirtyItem(item, /*recursive=*/true);
- return;
- }
-
- bool itemHasContents = !(item->d_ptr->flags & QGraphicsItem::ItemHasNoContents);
- const bool itemHasChildren = !item->d_ptr->children.isEmpty();
- if (!itemHasContents) {
- if (!itemHasChildren) {
- resetDirtyItem(item);
- return; // Item has neither contents nor children!(?)
- }
- if (item->d_ptr->graphicsEffect)
- itemHasContents = true;
- }
-
- const qreal opacity = item->d_ptr->combineOpacityFromParent(parentOpacity);
- const bool itemIsFullyTransparent = !item->d_ptr->ignoreOpacity
- && QGraphicsItemPrivate::isOpacityNull(opacity);
- if (itemIsFullyTransparent && (!itemHasChildren || item->d_ptr->childrenCombineOpacity())) {
- resetDirtyItem(item, /*recursive=*/itemHasChildren);
- return;
- }
-
- bool wasDirtyParentSceneTransform = item->d_ptr->dirtySceneTransform;
- const bool itemIsUntransformable = item->d_ptr->itemIsUntransformable();
- if (wasDirtyParentSceneTransform && !itemIsUntransformable) {
- item->d_ptr->updateSceneTransformFromParent();
- Q_ASSERT(!item->d_ptr->dirtySceneTransform);
- }
-
- const bool wasDirtyParentViewBoundingRects = item->d_ptr->paintedViewBoundingRectsNeedRepaint;
- if (itemIsFullyTransparent || !itemHasContents || dirtyAncestorContainsChildren) {
- // Make sure we don't process invisible items or items with no content.
- item->d_ptr->dirty = 0;
- item->d_ptr->fullUpdatePending = 0;
- // Might have a dirty view bounding rect otherwise.
- if (itemIsFullyTransparent || !itemHasContents)
- item->d_ptr->paintedViewBoundingRectsNeedRepaint = 0;
- }
-
- if (!hasSceneRect && item->d_ptr->geometryChanged && item->d_ptr->visible) {
- // Update growingItemsBoundingRect.
- if (item->d_ptr->sceneTransformTranslateOnly) {
- growingItemsBoundingRect |= item->boundingRect().translated(item->d_ptr->sceneTransform.dx(),
- item->d_ptr->sceneTransform.dy());
- } else {
- growingItemsBoundingRect |= item->d_ptr->sceneTransform.mapRect(item->boundingRect());
- }
- }
-
- // Process item.
- if (item->d_ptr->dirty || item->d_ptr->paintedViewBoundingRectsNeedRepaint) {
- const bool useCompatUpdate = views.isEmpty() || isSignalConnected(changedSignalIndex);
- const QRectF itemBoundingRect = adjustedItemEffectiveBoundingRect(item);
-
- if (useCompatUpdate && !itemIsUntransformable && qFuzzyIsNull(item->boundingRegionGranularity())) {
- // This block of code is kept for compatibility. Since 4.5, by default
- // QGraphicsView does not connect the signal and we use the below
- // method of delivering updates.
- if (item->d_ptr->sceneTransformTranslateOnly) {
- q->update(itemBoundingRect.translated(item->d_ptr->sceneTransform.dx(),
- item->d_ptr->sceneTransform.dy()));
- } else {
- QRectF rect = item->d_ptr->sceneTransform.mapRect(itemBoundingRect);
- if (!rect.isEmpty())
- q->update(rect);
- }
- } else {
- QRectF dirtyRect;
- bool uninitializedDirtyRect = true;
-
- for (int j = 0; j < views.size(); ++j) {
- QGraphicsView *view = views.at(j);
- QGraphicsViewPrivate *viewPrivate = view->d_func();
- QRect &paintedViewBoundingRect = item->d_ptr->paintedViewBoundingRects[viewPrivate->viewport];
- if (viewPrivate->fullUpdatePending
- || viewPrivate->viewportUpdateMode == QGraphicsView::NoViewportUpdate) {
- // Okay, if we have a full update pending or no viewport update, this item's
- // paintedViewBoundingRect will be updated correctly in the next paintEvent if
- // it is inside the viewport, but for now we can pretend that it is outside.
- paintedViewBoundingRect = QRect(-1, -1, -1, -1);
- continue;
- }
-
- if (item->d_ptr->paintedViewBoundingRectsNeedRepaint) {
- paintedViewBoundingRect.translate(viewPrivate->dirtyScrollOffset);
- if (!viewPrivate->updateRect(paintedViewBoundingRect))
- paintedViewBoundingRect = QRect(-1, -1, -1, -1); // Outside viewport.
- }
-
- if (!item->d_ptr->dirty)
- continue;
-
- if (!item->d_ptr->paintedViewBoundingRectsNeedRepaint
- && paintedViewBoundingRect.x() == -1 && paintedViewBoundingRect.y() == -1
- && paintedViewBoundingRect.width() == -1 && paintedViewBoundingRect.height() == -1) {
- continue; // Outside viewport.
- }
-
- if (uninitializedDirtyRect) {
- dirtyRect = itemBoundingRect;
- if (!item->d_ptr->fullUpdatePending) {
- _q_adjustRect(&item->d_ptr->needsRepaint);
- dirtyRect &= item->d_ptr->needsRepaint;
- }
- uninitializedDirtyRect = false;
- }
-
- if (dirtyRect.isEmpty())
- continue; // Discard updates outside the bounding rect.
-
- if (!updateHelper(viewPrivate, item->d_ptr.data(), dirtyRect, itemIsUntransformable)
- && item->d_ptr->paintedViewBoundingRectsNeedRepaint) {
- paintedViewBoundingRect = QRect(-1, -1, -1, -1); // Outside viewport.
- }
- }
- }
- }
-
- // Process children.
- if (itemHasChildren && item->d_ptr->dirtyChildren) {
- const bool itemClipsChildrenToShape = item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape;
- // Items with no content are threated as 'dummy' items which means they are never drawn and
- // 'processed', so the painted view bounding rect is never up-to-date. This means that whenever
- // such an item changes geometry, its children have to take care of the update regardless
- // of whether the item clips children to shape or not.
- const bool bypassUpdateClip = !itemHasContents && wasDirtyParentViewBoundingRects;
- if (itemClipsChildrenToShape && !bypassUpdateClip) {
- // Make sure child updates are clipped to the item's bounding rect.
- for (int i = 0; i < views.size(); ++i)
- views.at(i)->d_func()->setUpdateClip(item);
- }
- if (!dirtyAncestorContainsChildren) {
- dirtyAncestorContainsChildren = item->d_ptr->fullUpdatePending
- && itemClipsChildrenToShape;
- }
- const bool allChildrenDirty = item->d_ptr->allChildrenDirty;
- const bool parentIgnoresVisible = item->d_ptr->ignoreVisible;
- const bool parentIgnoresOpacity = item->d_ptr->ignoreOpacity;
- for (int i = 0; i < item->d_ptr->children.size(); ++i) {
- QGraphicsItem *child = item->d_ptr->children.at(i);
- if (wasDirtyParentSceneTransform)
- child->d_ptr->dirtySceneTransform = 1;
- if (wasDirtyParentViewBoundingRects)
- child->d_ptr->paintedViewBoundingRectsNeedRepaint = 1;
- if (parentIgnoresVisible)
- child->d_ptr->ignoreVisible = 1;
- if (parentIgnoresOpacity)
- child->d_ptr->ignoreOpacity = 1;
- if (allChildrenDirty) {
- child->d_ptr->dirty = 1;
- child->d_ptr->fullUpdatePending = 1;
- child->d_ptr->dirtyChildren = 1;
- child->d_ptr->allChildrenDirty = 1;
- }
- processDirtyItemsRecursive(child, dirtyAncestorContainsChildren, opacity);
- }
-
- if (itemClipsChildrenToShape) {
- // Reset updateClip.
- for (int i = 0; i < views.size(); ++i)
- views.at(i)->d_func()->setUpdateClip(0);
- }
- } else if (wasDirtyParentSceneTransform) {
- item->d_ptr->invalidateChildrenSceneTransform();
- }
-
- resetDirtyItem(item);
-}
-
-/*!
- \obsolete
-
- Paints the given \a items using the provided \a painter, after the
- background has been drawn, and before the foreground has been
- drawn. All painting is done in \e scene coordinates. Before
- drawing each item, the painter must be transformed using
- QGraphicsItem::sceneTransform().
-
- The \a options parameter is the list of style option objects for
- each item in \a items. The \a numItems parameter is the number of
- items in \a items and options in \a options. The \a widget
- parameter is optional; if specified, it should point to the widget
- that is being painted on.
-
- The default implementation prepares the painter matrix, and calls
- QGraphicsItem::paint() on all items. Reimplement this function to
- provide custom painting of all items for the scene; gaining
- complete control over how each item is drawn. In some cases this
- can increase drawing performance significantly.
-
- Example:
-
- \snippet doc/src/snippets/graphicssceneadditemsnippet.cpp 0
-
- Since Qt 4.6, this function is not called anymore unless
- the QGraphicsView::IndirectPainting flag is given as an Optimization
- flag.
-
- \sa drawBackground(), drawForeground()
-*/
-void QGraphicsScene::drawItems(QPainter *painter,
- int numItems,
- QGraphicsItem *items[],
- const QStyleOptionGraphicsItem options[], QWidget *widget)
-{
- Q_D(QGraphicsScene);
- // Make sure we don't have unpolished items before we draw.
- if (!d->unpolishedItems.isEmpty())
- d->_q_polishItems();
-
- const qreal opacity = painter->opacity();
- QTransform viewTransform = painter->worldTransform();
- Q_UNUSED(options);
-
- // Determine view, expose and flags.
- QGraphicsView *view = widget ? qobject_cast<QGraphicsView *>(widget->parentWidget()) : 0;
- QRegion *expose = 0;
- const quint32 oldRectAdjust = d->rectAdjust;
- if (view) {
- d->updateAll = false;
- expose = &view->d_func()->exposedRegion;
- if (view->d_func()->optimizationFlags & QGraphicsView::DontAdjustForAntialiasing)
- d->rectAdjust = 1;
- else
- d->rectAdjust = 2;
- }
-
- // Find all toplevels, they are already sorted.
- QList<QGraphicsItem *> topLevelItems;
- for (int i = 0; i < numItems; ++i) {
- QGraphicsItem *item = items[i]->topLevelItem();
- if (!item->d_ptr->itemDiscovered) {
- topLevelItems << item;
- item->d_ptr->itemDiscovered = 1;
- d->drawSubtreeRecursive(item, painter, &viewTransform, expose, widget);
- }
- }
-
- d->rectAdjust = oldRectAdjust;
- // Reset discovery bits.
- for (int i = 0; i < topLevelItems.size(); ++i)
- topLevelItems.at(i)->d_ptr->itemDiscovered = 0;
-
- painter->setWorldTransform(viewTransform);
- painter->setOpacity(opacity);
-}
-
-/*!
- \since 4.4
-
- Finds a new widget to give the keyboard focus to, as appropriate for Tab
- and Shift+Tab, and returns true if it can find a new widget, or false if
- it cannot. If \a next is true, this function searches forward; if \a next
- is false, it searches backward.
-
- You can reimplement this function in a subclass of QGraphicsScene to
- provide fine-grained control over how tab focus passes inside your
- scene. The default implementation is based on the tab focus chain defined
- by QGraphicsWidget::setTabOrder().
-*/
-bool QGraphicsScene::focusNextPrevChild(bool next)
-{
- Q_D(QGraphicsScene);
-
- QGraphicsItem *item = focusItem();
- if (item && !item->isWidget()) {
- // Tab out of the scene.
- return false;
- }
- if (!item) {
- if (d->lastFocusItem && !d->lastFocusItem->isWidget()) {
- // Restore focus to the last focusable non-widget item that had
- // focus.
- setFocusItem(d->lastFocusItem, next ? Qt::TabFocusReason : Qt::BacktabFocusReason);
- return true;
- }
- }
- if (!d->tabFocusFirst) {
- // No widgets...
- return false;
- }
-
- // The item must be a widget.
- QGraphicsWidget *widget = 0;
- if (!item) {
- widget = next ? d->tabFocusFirst : d->tabFocusFirst->d_func()->focusPrev;
- } else {
- QGraphicsWidget *test = static_cast<QGraphicsWidget *>(item);
- widget = next ? test->d_func()->focusNext : test->d_func()->focusPrev;
- if ((next && widget == d->tabFocusFirst) || (!next && widget == d->tabFocusFirst->d_func()->focusPrev))
- return false;
- }
- QGraphicsWidget *widgetThatHadFocus = widget;
-
- // Run around the focus chain until we find a widget that can take tab focus.
- do {
- if (widget->flags() & QGraphicsItem::ItemIsFocusable
- && widget->isEnabled() && widget->isVisibleTo(0)
- && (widget->focusPolicy() & Qt::TabFocus)
- && (!item || !item->isPanel() || item->isAncestorOf(widget))
- ) {
- setFocusItem(widget, next ? Qt::TabFocusReason : Qt::BacktabFocusReason);
- return true;
- }
- widget = next ? widget->d_func()->focusNext : widget->d_func()->focusPrev;
- if ((next && widget == d->tabFocusFirst) || (!next && widget == d->tabFocusFirst->d_func()->focusPrev))
- return false;
- } while (widget != widgetThatHadFocus);
-
- return false;
-}
-
-/*!
- \fn QGraphicsScene::changed(const QList<QRectF> &region)
-
- This signal is emitted by QGraphicsScene when control reaches the
- event loop, if the scene content changes. The \a region parameter
- contains a list of scene rectangles that indicate the area that
- has been changed.
-
- \sa QGraphicsView::updateScene()
-*/
-
-/*!
- \fn QGraphicsScene::sceneRectChanged(const QRectF &rect)
-
- This signal is emitted by QGraphicsScene whenever the scene rect changes.
- The \a rect parameter is the new scene rectangle.
-
- \sa QGraphicsView::updateSceneRect()
-*/
-
-/*!
- \fn QGraphicsScene::selectionChanged()
- \since 4.3
-
- This signal is emitted by QGraphicsScene whenever the selection
- changes. You can call selectedItems() to get the new list of selected
- items.
-
- The selection changes whenever an item is selected or unselected, a
- selection area is set, cleared or otherwise changed, if a preselected item
- is added to the scene, or if a selected item is removed from the scene.
-
- QGraphicsScene emits this signal only once for group selection operations.
- For example, if you set a selection area, select or unselect a
- QGraphicsItemGroup, or if you add or remove from the scene a parent item
- that contains several selected items, selectionChanged() is emitted only
- once after the operation has completed (instead of once for each item).
-
- \sa setSelectionArea(), selectedItems(), QGraphicsItem::setSelected()
-*/
-
-/*!
- \since 4.4
-
- Returns the scene's style, or the same as QApplication::style() if the
- scene has not been explicitly assigned a style.
-
- \sa setStyle()
-*/
-QStyle *QGraphicsScene::style() const
-{
- Q_D(const QGraphicsScene);
- // ### This function, and the use of styles in general, is non-reentrant.
- return d->style ? d->style : QApplication::style();
-}
-
-/*!
- \since 4.4
-
- Sets or replaces the style of the scene to \a style, and reparents the
- style to this scene. Any previously assigned style is deleted. The scene's
- style defaults to QApplication::style(), and serves as the default for all
- QGraphicsWidget items in the scene.
-
- Changing the style, either directly by calling this function, or
- indirectly by calling QApplication::setStyle(), will automatically update
- the style for all widgets in the scene that do not have a style explicitly
- assigned to them.
-
- If \a style is 0, QGraphicsScene will revert to QApplication::style().
-
- \sa style()
-*/
-void QGraphicsScene::setStyle(QStyle *style)
-{
- Q_D(QGraphicsScene);
- // ### This function, and the use of styles in general, is non-reentrant.
- if (style == d->style)
- return;
-
- // Delete the old style,
- delete d->style;
- if ((d->style = style))
- d->style->setParent(this);
-
- // Notify the scene.
- QEvent event(QEvent::StyleChange);
- QApplication::sendEvent(this, &event);
-
- // Notify all widgets that don't have a style explicitly set.
- foreach (QGraphicsItem *item, items()) {
- if (item->isWidget()) {
- QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
- if (!widget->testAttribute(Qt::WA_SetStyle))
- QApplication::sendEvent(widget, &event);
- }
- }
-}
-
-/*!
- \property QGraphicsScene::font
- \since 4.4
- \brief the scene's default font
-
- This property provides the scene's font. The scene font defaults to,
- and resolves all its entries from, QApplication::font.
-
- If the scene's font changes, either directly through setFont() or
- indirectly when the application font changes, QGraphicsScene first
- sends itself a \l{QEvent::FontChange}{FontChange} event, and it then
- sends \l{QEvent::FontChange}{FontChange} events to all top-level
- widget items in the scene. These items respond by resolving their own
- fonts to the scene, and they then notify their children, who again
- notify their children, and so on, until all widget items have updated
- their fonts.
-
- Changing the scene font, (directly or indirectly through
- QApplication::setFont(),) automatically schedules a redraw the entire
- scene.
-
- \sa QWidget::font, QApplication::setFont(), palette, style()
-*/
-QFont QGraphicsScene::font() const
-{
- Q_D(const QGraphicsScene);
- return d->font;
-}
-void QGraphicsScene::setFont(const QFont &font)
-{
- Q_D(QGraphicsScene);
- QFont naturalFont = QApplication::font();
- naturalFont.resolve(0);
- QFont resolvedFont = font.resolve(naturalFont);
- d->setFont_helper(resolvedFont);
-}
-
-/*!
- \property QGraphicsScene::palette
- \since 4.4
- \brief the scene's default palette
-
- This property provides the scene's palette. The scene palette defaults to,
- and resolves all its entries from, QApplication::palette.
-
- If the scene's palette changes, either directly through setPalette() or
- indirectly when the application palette changes, QGraphicsScene first
- sends itself a \l{QEvent::PaletteChange}{PaletteChange} event, and it then
- sends \l{QEvent::PaletteChange}{PaletteChange} events to all top-level
- widget items in the scene. These items respond by resolving their own
- palettes to the scene, and they then notify their children, who again
- notify their children, and so on, until all widget items have updated
- their palettes.
-
- Changing the scene palette, (directly or indirectly through
- QApplication::setPalette(),) automatically schedules a redraw the entire
- scene.
-
- \sa QWidget::palette, QApplication::setPalette(), font, style()
-*/
-QPalette QGraphicsScene::palette() const
-{
- Q_D(const QGraphicsScene);
- return d->palette;
-}
-void QGraphicsScene::setPalette(const QPalette &palette)
-{
- Q_D(QGraphicsScene);
- QPalette naturalPalette = QApplication::palette();
- naturalPalette.resolve(0);
- QPalette resolvedPalette = palette.resolve(naturalPalette);
- d->setPalette_helper(resolvedPalette);
-}
-
-/*!
- \since 4.6
-
- Returns true if the scene is active (e.g., it's viewed by
- at least one QGraphicsView that is active); otherwise returns false.
-
- \sa QGraphicsItem::isActive(), QWidget::isActiveWindow()
-*/
-bool QGraphicsScene::isActive() const
-{
- Q_D(const QGraphicsScene);
- return d->activationRefCount > 0;
-}
-
-/*!
- \since 4.6
- Returns the current active panel, or 0 if no panel is currently active.
-
- \sa QGraphicsScene::setActivePanel()
-*/
-QGraphicsItem *QGraphicsScene::activePanel() const
-{
- Q_D(const QGraphicsScene);
- return d->activePanel;
-}
-
-/*!
- \since 4.6
- Activates \a item, which must be an item in this scene. You
- can also pass 0 for \a item, in which case QGraphicsScene will
- deactivate any currently active panel.
-
- If the scene is currently inactive, \a item remains inactive until the
- scene becomes active (or, ir \a item is 0, no item will be activated).
-
- \sa activePanel(), isActive(), QGraphicsItem::isActive()
-*/
-void QGraphicsScene::setActivePanel(QGraphicsItem *item)
-{
- Q_D(QGraphicsScene);
- d->setActivePanelHelper(item, false);
-}
-
-/*!
- \since 4.4
-
- Returns the current active window, or 0 if no window is currently
- active.
-
- \sa QGraphicsScene::setActiveWindow()
-*/
-QGraphicsWidget *QGraphicsScene::activeWindow() const
-{
- Q_D(const QGraphicsScene);
- if (d->activePanel && d->activePanel->isWindow())
- return static_cast<QGraphicsWidget *>(d->activePanel);
- return 0;
-}
-
-/*!
- \since 4.4
- Activates \a widget, which must be a widget in this scene. You can also
- pass 0 for \a widget, in which case QGraphicsScene will deactivate any
- currently active window.
-
- \sa activeWindow(), QGraphicsWidget::isActiveWindow()
-*/
-void QGraphicsScene::setActiveWindow(QGraphicsWidget *widget)
-{
- if (widget && widget->scene() != this) {
- qWarning("QGraphicsScene::setActiveWindow: widget %p must be part of this scene",
- widget);
- return;
- }
-
- // Activate the widget's panel (all windows are panels).
- QGraphicsItem *panel = widget ? widget->panel() : 0;
- setActivePanel(panel);
-
- // Raise
- if (panel) {
- QList<QGraphicsItem *> siblingWindows;
- QGraphicsItem *parent = panel->parentItem();
- // Raise ### inefficient for toplevels
- foreach (QGraphicsItem *sibling, parent ? parent->children() : items()) {
- if (sibling != panel && sibling->isWindow())
- siblingWindows << sibling;
- }
-
- // Find the highest z value.
- qreal z = panel->zValue();
- for (int i = 0; i < siblingWindows.size(); ++i)
- z = qMax(z, siblingWindows.at(i)->zValue());
-
- // This will probably never overflow.
- const qreal litt = qreal(0.001);
- panel->setZValue(z + litt);
- }
-}
-
-/*!
- \since 4.6
-
- Sends event \a event to item \a item through possible event filters.
-
- The event is sent only if the item is enabled.
-
- Returns \c false if the event was filtered or if the item is disabled.
- Otherwise returns the value that was returned from the event handler.
-
- \sa QGraphicsItem::sceneEvent(), QGraphicsItem::sceneEventFilter()
-*/
-bool QGraphicsScene::sendEvent(QGraphicsItem *item, QEvent *event)
-{
- Q_D(QGraphicsScene);
- if (!item) {
- qWarning("QGraphicsScene::sendEvent: cannot send event to a null item");
- return false;
- }
- if (item->scene() != this) {
- qWarning("QGraphicsScene::sendEvent: item %p's scene (%p)"
- " is different from this scene (%p)",
- item, item->scene(), this);
- return false;
- }
- return d->sendEvent(item, event);
-}
-
-void QGraphicsScenePrivate::addView(QGraphicsView *view)
-{
- views << view;
-#ifndef QT_NO_GESTURES
- foreach (Qt::GestureType gesture, grabbedGestures.keys())
- view->viewport()->grabGesture(gesture);
-#endif
-}
-
-void QGraphicsScenePrivate::removeView(QGraphicsView *view)
-{
- views.removeAll(view);
-}
-
-void QGraphicsScenePrivate::updateTouchPointsForItem(QGraphicsItem *item, QTouchEvent *touchEvent)
-{
- QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();
- for (int i = 0; i < touchPoints.count(); ++i) {
- QTouchEvent::TouchPoint &touchPoint = touchPoints[i];
- touchPoint.setRect(item->mapFromScene(touchPoint.sceneRect()).boundingRect());
- touchPoint.setStartPos(item->d_ptr->genericMapFromScene(touchPoint.startScenePos(), touchEvent->widget()));
- touchPoint.setLastPos(item->d_ptr->genericMapFromScene(touchPoint.lastScenePos(), touchEvent->widget()));
- }
- touchEvent->setTouchPoints(touchPoints);
-}
-
-int QGraphicsScenePrivate::findClosestTouchPointId(const QPointF &scenePos)
-{
- int closestTouchPointId = -1;
- qreal closestDistance = qreal(0.);
- foreach (const QTouchEvent::TouchPoint &touchPoint, sceneCurrentTouchPoints) {
- qreal distance = QLineF(scenePos, touchPoint.scenePos()).length();
- if (closestTouchPointId == -1|| distance < closestDistance) {
- closestTouchPointId = touchPoint.id();
- closestDistance = distance;
- }
- }
- return closestTouchPointId;
-}
-
-void QGraphicsScenePrivate::touchEventHandler(QTouchEvent *sceneTouchEvent)
-{
- typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint> > StatesAndTouchPoints;
- QHash<QGraphicsItem *, StatesAndTouchPoints> itemsNeedingEvents;
-
- for (int i = 0; i < sceneTouchEvent->touchPoints().count(); ++i) {
- const QTouchEvent::TouchPoint &touchPoint = sceneTouchEvent->touchPoints().at(i);
-
- // update state
- QGraphicsItem *item = 0;
- if (touchPoint.state() == Qt::TouchPointPressed) {
- if (sceneTouchEvent->deviceType() == QTouchEvent::TouchPad) {
- // on touch-pad devices, send all touch points to the same item
- item = itemForTouchPointId.isEmpty()
- ? 0
- : itemForTouchPointId.constBegin().value();
- }
-
- if (!item) {
- // determine which item this touch point will go to
- cachedItemsUnderMouse = itemsAtPosition(touchPoint.screenPos().toPoint(),
- touchPoint.scenePos(),
- sceneTouchEvent->widget());
- item = cachedItemsUnderMouse.isEmpty() ? 0 : cachedItemsUnderMouse.first();
- }
-
- if (sceneTouchEvent->deviceType() == QTouchEvent::TouchScreen) {
- // on touch-screens, combine this touch point with the closest one we find
- int closestTouchPointId = findClosestTouchPointId(touchPoint.scenePos());
- QGraphicsItem *closestItem = itemForTouchPointId.value(closestTouchPointId);
- if (!item || (closestItem && cachedItemsUnderMouse.contains(closestItem)))
- item = closestItem;
- }
- if (!item)
- continue;
-
- itemForTouchPointId.insert(touchPoint.id(), item);
- sceneCurrentTouchPoints.insert(touchPoint.id(), touchPoint);
- } else if (touchPoint.state() == Qt::TouchPointReleased) {
- item = itemForTouchPointId.take(touchPoint.id());
- if (!item)
- continue;
-
- sceneCurrentTouchPoints.remove(touchPoint.id());
- } else {
- item = itemForTouchPointId.value(touchPoint.id());
- if (!item)
- continue;
- Q_ASSERT(sceneCurrentTouchPoints.contains(touchPoint.id()));
- sceneCurrentTouchPoints[touchPoint.id()] = touchPoint;
- }
-
- StatesAndTouchPoints &statesAndTouchPoints = itemsNeedingEvents[item];
- statesAndTouchPoints.first |= touchPoint.state();
- statesAndTouchPoints.second.append(touchPoint);
- }
-
- if (itemsNeedingEvents.isEmpty()) {
- sceneTouchEvent->accept();
- return;
- }
-
- bool ignoreSceneTouchEvent = true;
- QHash<QGraphicsItem *, StatesAndTouchPoints>::ConstIterator it = itemsNeedingEvents.constBegin();
- const QHash<QGraphicsItem *, StatesAndTouchPoints>::ConstIterator end = itemsNeedingEvents.constEnd();
- for (; it != end; ++it) {
- QGraphicsItem *item = it.key();
-
- (void) item->isBlockedByModalPanel(&item);
-
- // determine event type from the state mask
- QEvent::Type eventType;
- switch (it.value().first) {
- case Qt::TouchPointPressed:
- // all touch points have pressed state
- eventType = QEvent::TouchBegin;
- break;
- case Qt::TouchPointReleased:
- // all touch points have released state
- eventType = QEvent::TouchEnd;
- break;
- case Qt::TouchPointStationary:
- // don't send the event if nothing changed
- continue;
- default:
- // all other combinations
- eventType = QEvent::TouchUpdate;
- break;
- }
-
- QTouchEvent touchEvent(eventType);
- touchEvent.setWidget(sceneTouchEvent->widget());
- touchEvent.setDeviceType(sceneTouchEvent->deviceType());
- touchEvent.setModifiers(sceneTouchEvent->modifiers());
- touchEvent.setTouchPointStates(it.value().first);
- touchEvent.setTouchPoints(it.value().second);
-
- switch (touchEvent.type()) {
- case QEvent::TouchBegin:
- {
- // if the TouchBegin handler recurses, we assume that means the event
- // has been implicitly accepted and continue to send touch events
- item->d_ptr->acceptedTouchBeginEvent = true;
- bool res = sendTouchBeginEvent(item, &touchEvent)
- && touchEvent.isAccepted();
- if (!res) {
- // forget about these touch points, we didn't handle them
- for (int i = 0; i < touchEvent.touchPoints().count(); ++i) {
- const QTouchEvent::TouchPoint &touchPoint = touchEvent.touchPoints().at(i);
- itemForTouchPointId.remove(touchPoint.id());
- sceneCurrentTouchPoints.remove(touchPoint.id());
- }
- ignoreSceneTouchEvent = false;
- }
- break;
- }
- default:
- if (item->d_ptr->acceptedTouchBeginEvent) {
- updateTouchPointsForItem(item, &touchEvent);
- (void) sendEvent(item, &touchEvent);
- ignoreSceneTouchEvent = false;
- }
- break;
- }
- }
- sceneTouchEvent->setAccepted(ignoreSceneTouchEvent);
-}
-
-bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEvent *touchEvent)
-{
- Q_Q(QGraphicsScene);
-
- if (cachedItemsUnderMouse.isEmpty() || cachedItemsUnderMouse.first() != origin) {
- const QTouchEvent::TouchPoint &firstTouchPoint = touchEvent->touchPoints().first();
- cachedItemsUnderMouse = itemsAtPosition(firstTouchPoint.screenPos().toPoint(),
- firstTouchPoint.scenePos(),
- touchEvent->widget());
- }
- Q_ASSERT(cachedItemsUnderMouse.first() == origin);
-
- // Set focus on the topmost enabled item that can take focus.
- bool setFocus = false;
-
- foreach (QGraphicsItem *item, cachedItemsUnderMouse) {
- if (item->isEnabled() && ((item->flags() & QGraphicsItem::ItemIsFocusable) && item->d_ptr->mouseSetsFocus)) {
- if (!item->isWidget() || ((QGraphicsWidget *)item)->focusPolicy() & Qt::ClickFocus) {
- setFocus = true;
- if (item != q->focusItem())
- q->setFocusItem(item, Qt::MouseFocusReason);
- break;
- }
- }
- if (item->isPanel())
- break;
- if (item->d_ptr->flags & QGraphicsItem::ItemStopsClickFocusPropagation)
- break;
- if (item->d_ptr->flags & QGraphicsItem::ItemStopsFocusHandling) {
- // Make sure we don't clear focus.
- setFocus = true;
- break;
- }
- }
-
- // If nobody could take focus, clear it.
- if (!stickyFocus && !setFocus)
- q->setFocusItem(0, Qt::MouseFocusReason);
-
- bool res = false;
- bool eventAccepted = touchEvent->isAccepted();
- foreach (QGraphicsItem *item, cachedItemsUnderMouse) {
- // first, try to deliver the touch event
- updateTouchPointsForItem(item, touchEvent);
- bool acceptTouchEvents = item->acceptTouchEvents();
- touchEvent->setAccepted(acceptTouchEvents);
- res = acceptTouchEvents && sendEvent(item, touchEvent);
- eventAccepted = touchEvent->isAccepted();
- if (itemForTouchPointId.value(touchEvent->touchPoints().first().id()) == 0) {
- // item was deleted
- item = 0;
- } else {
- item->d_ptr->acceptedTouchBeginEvent = (res && eventAccepted);
- }
- touchEvent->spont = false;
- if (res && eventAccepted) {
- // the first item to accept the TouchBegin gets an implicit grab.
- for (int i = 0; i < touchEvent->touchPoints().count(); ++i) {
- const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().at(i);
- itemForTouchPointId[touchPoint.id()] = item; // can be zero
- }
- break;
- }
- if (item && item->isPanel())
- break;
- }
-
- touchEvent->setAccepted(eventAccepted);
- return res;
-}
-
-void QGraphicsScenePrivate::enableTouchEventsOnViews()
-{
- foreach (QGraphicsView *view, views)
- view->viewport()->setAttribute(Qt::WA_AcceptTouchEvents, true);
-}
-
-void QGraphicsScenePrivate::updateInputMethodSensitivityInViews()
-{
- for (int i = 0; i < views.size(); ++i)
- views.at(i)->d_func()->updateInputMethodSensitivity();
-}
-
-void QGraphicsScenePrivate::enterModal(QGraphicsItem *panel, QGraphicsItem::PanelModality previousModality)
-{
- Q_Q(QGraphicsScene);
- Q_ASSERT(panel && panel->isPanel());
-
- QGraphicsItem::PanelModality panelModality = panel->d_ptr->panelModality;
- if (previousModality != QGraphicsItem::NonModal) {
- // the panel is changing from one modality type to another... temporarily set it back so
- // that blockedPanels is populated correctly
- panel->d_ptr->panelModality = previousModality;
- }
-
- QSet<QGraphicsItem *> blockedPanels;
- QList<QGraphicsItem *> items = q->items(); // ### store panels separately
- for (int i = 0; i < items.count(); ++i) {
- QGraphicsItem *item = items.at(i);
- if (item->isPanel() && item->isBlockedByModalPanel())
- blockedPanels.insert(item);
- }
- // blockedPanels contains all currently blocked panels
-
- if (previousModality != QGraphicsItem::NonModal) {
- // reset the modality to the proper value, since we changed it above
- panel->d_ptr->panelModality = panelModality;
- // remove this panel so that it will be reinserted at the front of the stack
- modalPanels.removeAll(panel);
- }
-
- modalPanels.prepend(panel);
-
- if (!hoverItems.isEmpty()) {
- // send GraphicsSceneHoverLeave events to newly blocked hoverItems
- QGraphicsSceneHoverEvent hoverEvent;
- hoverEvent.setScenePos(lastSceneMousePos);
- dispatchHoverEvent(&hoverEvent);
- }
-
- if (!mouseGrabberItems.isEmpty() && lastMouseGrabberItemHasImplicitMouseGrab) {
- QGraphicsItem *item = mouseGrabberItems.last();
- if (item->isBlockedByModalPanel())
- ungrabMouse(item, /*itemIsDying =*/ false);
- }
-
- QEvent windowBlockedEvent(QEvent::WindowBlocked);
- QEvent windowUnblockedEvent(QEvent::WindowUnblocked);
- for (int i = 0; i < items.count(); ++i) {
- QGraphicsItem *item = items.at(i);
- if (item->isPanel()) {
- if (!blockedPanels.contains(item) && item->isBlockedByModalPanel()) {
- // send QEvent::WindowBlocked to newly blocked panels
- sendEvent(item, &windowBlockedEvent);
- } else if (blockedPanels.contains(item) && !item->isBlockedByModalPanel()) {
- // send QEvent::WindowUnblocked to unblocked panels when downgrading
- // a panel from SceneModal to PanelModal
- sendEvent(item, &windowUnblockedEvent);
- }
- }
- }
-}
-
-void QGraphicsScenePrivate::leaveModal(QGraphicsItem *panel)
-{
- Q_Q(QGraphicsScene);
- Q_ASSERT(panel && panel->isPanel());
-
- QSet<QGraphicsItem *> blockedPanels;
- QList<QGraphicsItem *> items = q->items(); // ### same as above
- for (int i = 0; i < items.count(); ++i) {
- QGraphicsItem *item = items.at(i);
- if (item->isPanel() && item->isBlockedByModalPanel())
- blockedPanels.insert(item);
- }
-
- modalPanels.removeAll(panel);
-
- QEvent e(QEvent::WindowUnblocked);
- for (int i = 0; i < items.count(); ++i) {
- QGraphicsItem *item = items.at(i);
- if (item->isPanel() && blockedPanels.contains(item) && !item->isBlockedByModalPanel())
- sendEvent(item, &e);
- }
-
- // send GraphicsSceneHoverEnter events to newly unblocked items
- QGraphicsSceneHoverEvent hoverEvent;
- hoverEvent.setScenePos(lastSceneMousePos);
- dispatchHoverEvent(&hoverEvent);
-}
-
-#ifndef QT_NO_GESTURES
-void QGraphicsScenePrivate::gestureTargetsAtHotSpots(const QSet<QGesture *> &gestures,
- Qt::GestureFlag flag,
- QHash<QGraphicsObject *, QSet<QGesture *> > *targets,
- QSet<QGraphicsObject *> *itemsSet,
- QSet<QGesture *> *normal,
- QSet<QGesture *> *conflicts)
-{
- QSet<QGesture *> normalGestures; // that are not in conflicted state.
- foreach (QGesture *gesture, gestures) {
- if (!gesture->hasHotSpot())
- continue;
- const Qt::GestureType gestureType = gesture->gestureType();
- QList<QGraphicsItem *> items = itemsAtPosition(QPoint(), gesture->d_func()->sceneHotSpot, 0);
- for (int j = 0; j < items.size(); ++j) {
- QGraphicsItem *item = items.at(j);
-
- // Check if the item is blocked by a modal panel and use it as
- // a target instead of this item.
- (void) item->isBlockedByModalPanel(&item);
-
- if (QGraphicsObject *itemobj = item->toGraphicsObject()) {
- QGraphicsItemPrivate *d = item->QGraphicsItem::d_func();
- QMap<Qt::GestureType, Qt::GestureFlags>::const_iterator it =
- d->gestureContext.find(gestureType);
- if (it != d->gestureContext.end() && (!flag || (it.value() & flag))) {
- if (normalGestures.contains(gesture)) {
- normalGestures.remove(gesture);
- if (conflicts)
- conflicts->insert(gesture);
- } else {
- normalGestures.insert(gesture);
- }
- if (targets)
- (*targets)[itemobj].insert(gesture);
- if (itemsSet)
- (*itemsSet).insert(itemobj);
- }
- }
- // Don't propagate through panels.
- if (item->isPanel())
- break;
- }
- }
- if (normal)
- *normal = normalGestures;
-}
-
-void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event)
-{
- QWidget *viewport = event->widget();
- if (!viewport)
- return;
- QGraphicsView *graphicsView = qobject_cast<QGraphicsView *>(viewport->parent());
- if (!graphicsView)
- return;
-
- QList<QGesture *> allGestures = event->gestures();
- DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
- << "Gestures:" << allGestures;
-
- QSet<QGesture *> startedGestures;
- QPoint delta = viewport->mapFromGlobal(QPoint());
- QTransform toScene = QTransform::fromTranslate(delta.x(), delta.y())
- * graphicsView->viewportTransform().inverted();
- foreach (QGesture *gesture, allGestures) {
- // cache scene coordinates of the hot spot
- if (gesture->hasHotSpot()) {
- gesture->d_func()->sceneHotSpot = toScene.map(gesture->hotSpot());
- } else {
- gesture->d_func()->sceneHotSpot = QPointF();
- }
-
- QGraphicsObject *target = gestureTargets.value(gesture, 0);
- if (!target) {
- // when we are not in started mode but don't have a target
- // then the only one interested in gesture is the view/scene
- if (gesture->state() == Qt::GestureStarted)
- startedGestures.insert(gesture);
- }
- }
-
- if (!startedGestures.isEmpty()) {
- QSet<QGesture *> normalGestures; // that have just one target
- QSet<QGesture *> conflictedGestures; // that have multiple possible targets
- gestureTargetsAtHotSpots(startedGestures, Qt::GestureFlag(0), &cachedItemGestures, 0,
- &normalGestures, &conflictedGestures);
- cachedTargetItems = cachedItemGestures.keys();
- qSort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst);
- DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
- << "Normal gestures:" << normalGestures
- << "Conflicting gestures:" << conflictedGestures;
-
- // deliver conflicted gestures as override events AND remember
- // initial gesture targets
- if (!conflictedGestures.isEmpty()) {
- for (int i = 0; i < cachedTargetItems.size(); ++i) {
- QWeakPointer<QGraphicsObject> item = cachedTargetItems.at(i);
-
- // get gestures to deliver to the current item
- QSet<QGesture *> gestures = conflictedGestures & cachedItemGestures.value(item.data());
- if (gestures.isEmpty())
- continue;
-
- DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
- << "delivering override to"
- << item.data() << gestures;
- // send gesture override
- QGestureEvent ev(gestures.toList());
- ev.t = QEvent::GestureOverride;
- ev.setWidget(event->widget());
- // mark event and individual gestures as ignored
- ev.ignore();
- foreach(QGesture *g, gestures)
- ev.setAccepted(g, false);
- sendEvent(item.data(), &ev);
- // mark all accepted gestures to deliver them as normal gesture events
- foreach (QGesture *g, gestures) {
- if (ev.isAccepted() || ev.isAccepted(g)) {
- conflictedGestures.remove(g);
- // mark the item as a gesture target
- if (item) {
- gestureTargets.insert(g, item.data());
- QHash<QGraphicsObject *, QSet<QGesture *> >::iterator it, e;
- it = cachedItemGestures.begin();
- e = cachedItemGestures.end();
- for(; it != e; ++it)
- it.value().remove(g);
- cachedItemGestures[item.data()].insert(g);
- }
- DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
- << "override was accepted:"
- << g << item.data();
- }
- // remember the first item that received the override event
- // as it most likely become a target if no one else accepts
- // the override event
- if (!gestureTargets.contains(g) && item)
- gestureTargets.insert(g, item.data());
-
- }
- if (conflictedGestures.isEmpty())
- break;
- }
- }
- // remember the initial target item for each gesture that was not in
- // the conflicted state.
- if (!normalGestures.isEmpty()) {
- for (int i = 0; i < cachedTargetItems.size() && !normalGestures.isEmpty(); ++i) {
- QGraphicsObject *item = cachedTargetItems.at(i);
-
- // get gestures to deliver to the current item
- foreach (QGesture *g, cachedItemGestures.value(item)) {
- if (!gestureTargets.contains(g)) {
- gestureTargets.insert(g, item);
- normalGestures.remove(g);
- }
- }
- }
- }
- }
-
-
- // deliver all gesture events
- QSet<QGesture *> undeliveredGestures;
- QSet<QGesture *> parentPropagatedGestures;
- foreach (QGesture *gesture, allGestures) {
- if (QGraphicsObject *target = gestureTargets.value(gesture, 0)) {
- cachedItemGestures[target].insert(gesture);
- cachedTargetItems.append(target);
- undeliveredGestures.insert(gesture);
- QGraphicsItemPrivate *d = target->QGraphicsItem::d_func();
- const Qt::GestureFlags flags = d->gestureContext.value(gesture->gestureType());
- if (flags & Qt::IgnoredGesturesPropagateToParent)
- parentPropagatedGestures.insert(gesture);
- } else {
- DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
- << "no target for" << gesture << "at"
- << gesture->hotSpot() << gesture->d_func()->sceneHotSpot;
- }
- }
- qSort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst);
- for (int i = 0; i < cachedTargetItems.size(); ++i) {
- QWeakPointer<QGraphicsObject> receiver = cachedTargetItems.at(i);
- QSet<QGesture *> gestures =
- undeliveredGestures & cachedItemGestures.value(receiver.data());
- gestures -= cachedAlreadyDeliveredGestures.value(receiver.data());
-
- if (gestures.isEmpty())
- continue;
-
- cachedAlreadyDeliveredGestures[receiver.data()] += gestures;
- const bool isPanel = receiver.data()->isPanel();
-
- DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
- << "delivering to"
- << receiver.data() << gestures;
- QGestureEvent ev(gestures.toList());
- ev.setWidget(event->widget());
- sendEvent(receiver.data(), &ev);
- QSet<QGesture *> ignoredGestures;
- foreach (QGesture *g, gestures) {
- if (!ev.isAccepted() && !ev.isAccepted(g)) {
- // if the gesture was ignored by its target, we will update the
- // targetItems list with a possible target items (items that
- // want to receive partial gestures).
- // ### wont' work if the target was destroyed in the event
- // we will just stop delivering it.
- if (receiver && receiver.data() == gestureTargets.value(g, 0))
- ignoredGestures.insert(g);
- } else {
- if (receiver && g->state() == Qt::GestureStarted) {
- // someone accepted the propagated initial GestureStarted
- // event, let it be the new target for all following events.
- gestureTargets[g] = receiver.data();
- }
- undeliveredGestures.remove(g);
- }
- }
- if (undeliveredGestures.isEmpty())
- break;
-
- // ignoredGestures list is only filled when delivering to the gesture
- // target item, so it is safe to assume item == target.
- if (!ignoredGestures.isEmpty() && !isPanel) {
- // look for new potential targets for gestures that were ignored
- // and should be propagated.
-
- QSet<QGraphicsObject *> targetsSet = cachedTargetItems.toSet();
-
- if (receiver) {
- // first if the gesture should be propagated to parents only
- for (QSet<QGesture *>::iterator it = ignoredGestures.begin();
- it != ignoredGestures.end();) {
- if (parentPropagatedGestures.contains(*it)) {
- QGesture *gesture = *it;
- const Qt::GestureType gestureType = gesture->gestureType();
- QGraphicsItem *item = receiver.data();
- while (item) {
- if (QGraphicsObject *obj = item->toGraphicsObject()) {
- if (item->d_func()->gestureContext.contains(gestureType)) {
- targetsSet.insert(obj);
- cachedItemGestures[obj].insert(gesture);
- }
- }
- if (item->isPanel())
- break;
- item = item->parentItem();
- }
-
- it = ignoredGestures.erase(it);
- continue;
- }
- ++it;
- }
- }
-
- gestureTargetsAtHotSpots(ignoredGestures, Qt::ReceivePartialGestures,
- &cachedItemGestures, &targetsSet, 0, 0);
-
- cachedTargetItems = targetsSet.toList();
- qSort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst);
- DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
- << "new targets:" << cachedTargetItems;
- i = -1; // start delivery again
- continue;
- }
- }
-
- foreach (QGesture *g, startedGestures) {
- if (g->gestureCancelPolicy() == QGesture::CancelAllInContext) {
- DEBUG() << "lets try to cancel some";
- // find gestures in context in Qt::GestureStarted or Qt::GestureUpdated state and cancel them
- cancelGesturesForChildren(g);
- }
- }
-
- // forget about targets for gestures that have ended
- foreach (QGesture *g, allGestures) {
- switch (g->state()) {
- case Qt::GestureFinished:
- case Qt::GestureCanceled:
- gestureTargets.remove(g);
- break;
- default:
- break;
- }
- }
-
- cachedTargetItems.clear();
- cachedItemGestures.clear();
- cachedAlreadyDeliveredGestures.clear();
-}
-
-void QGraphicsScenePrivate::cancelGesturesForChildren(QGesture *original)
-{
- Q_ASSERT(original);
- QGraphicsItem *originalItem = gestureTargets.value(original);
- if (originalItem == 0) // we only act on accepted gestures, which implies it has a target.
- return;
-
- // iterate over all active gestures and for each find the owner
- // if the owner is part of our sub-hierarchy, cancel it.
-
- QSet<QGesture *> canceledGestures;
- QHash<QGesture *, QGraphicsObject *>::Iterator iter = gestureTargets.begin();
- while (iter != gestureTargets.end()) {
- QGraphicsObject *item = iter.value();
- // note that we don't touch the gestures for our originalItem
- if (item != originalItem && originalItem->isAncestorOf(item)) {
- DEBUG() << " found a gesture to cancel" << iter.key();
- iter.key()->d_func()->state = Qt::GestureCanceled;
- canceledGestures << iter.key();
- }
- ++iter;
- }
-
- // sort them per target item by cherry picking from almostCanceledGestures and delivering
- QSet<QGesture *> almostCanceledGestures = canceledGestures;
- QSet<QGesture *>::Iterator setIter;
- while (!almostCanceledGestures.isEmpty()) {
- QGraphicsObject *target = 0;
- QSet<QGesture*> gestures;
- setIter = almostCanceledGestures.begin();
- // sort per target item
- while (setIter != almostCanceledGestures.end()) {
- QGraphicsObject *item = gestureTargets.value(*setIter);
- if (target == 0)
- target = item;
- if (target == item) {
- gestures << *setIter;
- setIter = almostCanceledGestures.erase(setIter);
- } else {
- ++setIter;
- }
- }
- Q_ASSERT(target);
-
- QList<QGesture *> list = gestures.toList();
- QGestureEvent ev(list);
- sendEvent(target, &ev);
-
- foreach (QGesture *g, list) {
- if (ev.isAccepted() || ev.isAccepted(g))
- gestures.remove(g);
- }
-
- foreach (QGesture *g, gestures) {
- if (!g->hasHotSpot())
- continue;
-
- QList<QGraphicsItem *> items = itemsAtPosition(QPoint(), g->d_func()->sceneHotSpot, 0);
- for (int j = 0; j < items.size(); ++j) {
- QGraphicsObject *item = items.at(j)->toGraphicsObject();
- if (!item)
- continue;
- QGraphicsItemPrivate *d = item->QGraphicsItem::d_func();
- if (d->gestureContext.contains(g->gestureType())) {
- QList<QGesture *> list;
- list << g;
- QGestureEvent ev(list);
- sendEvent(item, &ev);
- if (ev.isAccepted() || ev.isAccepted(g))
- break; // successfully delivered
- }
- }
- }
- }
-
- QGestureManager *gestureManager = QApplicationPrivate::instance()->gestureManager;
- Q_ASSERT(gestureManager); // it would be very odd if we got called without a manager.
- for (setIter = canceledGestures.begin(); setIter != canceledGestures.end(); ++setIter) {
- gestureManager->recycle(*setIter);
- gestureTargets.remove(*setIter);
- }
-}
-
-void QGraphicsScenePrivate::grabGesture(QGraphicsItem *, Qt::GestureType gesture)
-{
- (void)QGestureManager::instance(); // create a gesture manager
- if (!grabbedGestures[gesture]++) {
- foreach (QGraphicsView *view, views)
- view->viewport()->grabGesture(gesture);
- }
-}
-
-void QGraphicsScenePrivate::ungrabGesture(QGraphicsItem *item, Qt::GestureType gesture)
-{
- // we know this can only be an object
- Q_ASSERT(item->d_ptr->isObject);
- QGraphicsObject *obj = static_cast<QGraphicsObject *>(item);
- QGestureManager::instance()->cleanupCachedGestures(obj, gesture);
- if (!--grabbedGestures[gesture]) {
- foreach (QGraphicsView *view, views)
- view->viewport()->ungrabGesture(gesture);
- }
-}
-#endif // QT_NO_GESTURES
-
-QT_END_NAMESPACE
-
-#include "moc_qgraphicsscene.cpp"
-
-#endif // QT_NO_GRAPHICSVIEW
diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h
deleted file mode 100644
index 9460a4dc51..0000000000
--- a/src/gui/graphicsview/qgraphicsscene_p.h
+++ /dev/null
@@ -1,359 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSSCENE_P_H
-#define QGRAPHICSSCENE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qgraphicsscene.h"
-
-#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
-
-#include "qgraphicssceneevent.h"
-#include "qgraphicsview.h"
-#include "qgraphicsview_p.h"
-#include "qgraphicsitem_p.h"
-
-#include <private/qobject_p.h>
-#include <QtCore/qbitarray.h>
-#include <QtCore/qlist.h>
-#include <QtCore/qmap.h>
-#include <QtCore/qset.h>
-#include <QtGui/qfont.h>
-#include <QtGui/qpalette.h>
-#include <QtGui/qstyle.h>
-#include <QtGui/qstyleoption.h>
-
-QT_BEGIN_NAMESPACE
-
-class QGraphicsSceneIndex;
-class QGraphicsView;
-class QGraphicsWidget;
-
-class Q_AUTOTEST_EXPORT QGraphicsScenePrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QGraphicsScene)
-public:
- QGraphicsScenePrivate();
- void init();
-
- static QGraphicsScenePrivate *get(QGraphicsScene *q);
-
- int changedSignalIndex;
- int processDirtyItemsIndex;
- int polishItemsIndex;
-
- QGraphicsScene::ItemIndexMethod indexMethod;
- QGraphicsSceneIndex *index;
-
- int lastItemCount;
-
- QRectF sceneRect;
-
- quint32 hasSceneRect : 1;
- quint32 dirtyGrowingItemsBoundingRect : 1;
- quint32 updateAll : 1;
- quint32 calledEmitUpdated : 1;
- quint32 processDirtyItemsEmitted : 1;
- quint32 needSortTopLevelItems : 1;
- quint32 holesInTopLevelSiblingIndex : 1;
- quint32 topLevelSequentialOrdering : 1;
- quint32 scenePosDescendantsUpdatePending : 1;
- quint32 stickyFocus : 1;
- quint32 hasFocus : 1;
- quint32 lastMouseGrabberItemHasImplicitMouseGrab : 1;
- quint32 allItemsIgnoreHoverEvents : 1;
- quint32 allItemsUseDefaultCursor : 1;
- quint32 painterStateProtection : 1;
- quint32 sortCacheEnabled : 1; // for compatibility
- quint32 allItemsIgnoreTouchEvents : 1;
- quint32 padding : 15;
-
- QRectF growingItemsBoundingRect;
-
- void _q_emitUpdated();
- QList<QRectF> updatedRects;
-
- QPainterPath selectionArea;
- int selectionChanging;
- QSet<QGraphicsItem *> selectedItems;
- QVector<QGraphicsItem *> unpolishedItems;
- QList<QGraphicsItem *> topLevelItems;
-
- QMap<QGraphicsItem *, QPointF> movingItemsInitialPositions;
- void registerTopLevelItem(QGraphicsItem *item);
- void unregisterTopLevelItem(QGraphicsItem *item);
- void _q_updateLater();
- void _q_polishItems();
-
- void _q_processDirtyItems();
-
- QSet<QGraphicsItem *> scenePosItems;
- void setScenePosItemEnabled(QGraphicsItem *item, bool enabled);
- void registerScenePosItem(QGraphicsItem *item);
- void unregisterScenePosItem(QGraphicsItem *item);
- void _q_updateScenePosDescendants();
-
- void removeItemHelper(QGraphicsItem *item);
-
- QBrush backgroundBrush;
- QBrush foregroundBrush;
-
- quint32 rectAdjust;
- QGraphicsItem *focusItem;
- QGraphicsItem *lastFocusItem;
- QGraphicsItem *passiveFocusItem;
- QGraphicsWidget *tabFocusFirst;
- QGraphicsItem *activePanel;
- QGraphicsItem *lastActivePanel;
- int activationRefCount;
- int childExplicitActivation;
- void setActivePanelHelper(QGraphicsItem *item, bool duringActivationEvent);
- void setFocusItemHelper(QGraphicsItem *item, Qt::FocusReason focusReason);
-
- QList<QGraphicsWidget *> popupWidgets;
- void addPopup(QGraphicsWidget *widget);
- void removePopup(QGraphicsWidget *widget, bool itemIsDying = false);
-
- QGraphicsItem *lastMouseGrabberItem;
- QList<QGraphicsItem *> mouseGrabberItems;
- void grabMouse(QGraphicsItem *item, bool implicit = false);
- void ungrabMouse(QGraphicsItem *item, bool itemIsDying = false);
- void clearMouseGrabber();
-
- QList<QGraphicsItem *> keyboardGrabberItems;
- void grabKeyboard(QGraphicsItem *item);
- void ungrabKeyboard(QGraphicsItem *item, bool itemIsDying = false);
- void clearKeyboardGrabber();
-
- QGraphicsItem *dragDropItem;
- QGraphicsWidget *enterWidget;
- Qt::DropAction lastDropAction;
- QList<QGraphicsItem *> cachedItemsUnderMouse;
- QList<QGraphicsItem *> hoverItems;
- QPointF lastSceneMousePos;
- void enableMouseTrackingOnViews();
- QMap<Qt::MouseButton, QPointF> mouseGrabberButtonDownPos;
- QMap<Qt::MouseButton, QPointF> mouseGrabberButtonDownScenePos;
- QMap<Qt::MouseButton, QPoint> mouseGrabberButtonDownScreenPos;
- QList<QGraphicsItem *> itemsAtPosition(const QPoint &screenPos,
- const QPointF &scenePos,
- QWidget *widget) const;
- void storeMouseButtonsForMouseGrabber(QGraphicsSceneMouseEvent *event);
-
- QList<QGraphicsView *> views;
- void addView(QGraphicsView *view);
- void removeView(QGraphicsView *view);
-
- QMultiMap<QGraphicsItem *, QGraphicsItem *> sceneEventFilters;
- void installSceneEventFilter(QGraphicsItem *watched, QGraphicsItem *filter);
- void removeSceneEventFilter(QGraphicsItem *watched, QGraphicsItem *filter);
- bool filterDescendantEvent(QGraphicsItem *item, QEvent *event);
- bool filterEvent(QGraphicsItem *item, QEvent *event);
- bool sendEvent(QGraphicsItem *item, QEvent *event);
-
- bool dispatchHoverEvent(QGraphicsSceneHoverEvent *hoverEvent);
- bool itemAcceptsHoverEvents_helper(const QGraphicsItem *item) const;
- void leaveScene(QWidget *viewport);
-
- void cloneDragDropEvent(QGraphicsSceneDragDropEvent *dest,
- QGraphicsSceneDragDropEvent *source);
- void sendDragDropEvent(QGraphicsItem *item,
- QGraphicsSceneDragDropEvent *dragDropEvent);
- void sendHoverEvent(QEvent::Type type, QGraphicsItem *item,
- QGraphicsSceneHoverEvent *hoverEvent);
- void sendMouseEvent(QGraphicsSceneMouseEvent *mouseEvent);
- void mousePressEventHandler(QGraphicsSceneMouseEvent *mouseEvent);
- QGraphicsWidget *windowForItem(const QGraphicsItem *item) const;
-
- void drawItemHelper(QGraphicsItem *item, QPainter *painter,
- const QStyleOptionGraphicsItem *option, QWidget *widget,
- bool painterStateProtection);
-
- void drawItems(QPainter *painter, const QTransform *const viewTransform,
- QRegion *exposedRegion, QWidget *widget);
-
- void drawSubtreeRecursive(QGraphicsItem *item, QPainter *painter, const QTransform *const,
- QRegion *exposedRegion, QWidget *widget, qreal parentOpacity = qreal(1.0),
- const QTransform *const effectTransform = 0);
- void draw(QGraphicsItem *, QPainter *, const QTransform *const, const QTransform *const,
- QRegion *, QWidget *, qreal, const QTransform *const, bool, bool);
-
- void markDirty(QGraphicsItem *item, const QRectF &rect = QRectF(), bool invalidateChildren = false,
- bool force = false, bool ignoreOpacity = false, bool removingItemFromScene = false,
- bool updateBoundingRect = false);
- void processDirtyItemsRecursive(QGraphicsItem *item, bool dirtyAncestorContainsChildren = false,
- qreal parentOpacity = qreal(1.0));
-
- inline void resetDirtyItem(QGraphicsItem *item, bool recursive = false)
- {
- Q_ASSERT(item);
- item->d_ptr->dirty = 0;
- item->d_ptr->paintedViewBoundingRectsNeedRepaint = 0;
- item->d_ptr->geometryChanged = 0;
- if (!item->d_ptr->dirtyChildren)
- recursive = false;
- item->d_ptr->dirtyChildren = 0;
- item->d_ptr->needsRepaint = QRectF();
- item->d_ptr->allChildrenDirty = 0;
- item->d_ptr->fullUpdatePending = 0;
- item->d_ptr->ignoreVisible = 0;
- item->d_ptr->ignoreOpacity = 0;
-#ifndef QT_NO_GRAPHICSEFFECT
- QGraphicsEffect::ChangeFlags flags;
- if (item->d_ptr->notifyBoundingRectChanged) {
- flags |= QGraphicsEffect::SourceBoundingRectChanged;
- item->d_ptr->notifyBoundingRectChanged = 0;
- }
- if (item->d_ptr->notifyInvalidated) {
- flags |= QGraphicsEffect::SourceInvalidated;
- item->d_ptr->notifyInvalidated = 0;
- }
-#endif //QT_NO_GRAPHICSEFFECT
- if (recursive) {
- for (int i = 0; i < item->d_ptr->children.size(); ++i)
- resetDirtyItem(item->d_ptr->children.at(i), recursive);
- }
-#ifndef QT_NO_GRAPHICSEFFECT
- if (flags && item->d_ptr->graphicsEffect)
- item->d_ptr->graphicsEffect->sourceChanged(flags);
-#endif //QT_NO_GRAPHICSEFFECT
- }
-
- inline void ensureSortedTopLevelItems()
- {
- if (needSortTopLevelItems) {
- qSort(topLevelItems.begin(), topLevelItems.end(), qt_notclosestLeaf);
- topLevelSequentialOrdering = false;
- needSortTopLevelItems = false;
- }
- }
-
- void ensureSequentialTopLevelSiblingIndexes();
-
- QStyle *style;
- QFont font;
- void setFont_helper(const QFont &font);
- void resolveFont();
- void updateFont(const QFont &font);
- QPalette palette;
- void setPalette_helper(const QPalette &palette);
- void resolvePalette();
- void updatePalette(const QPalette &palette);
-
- QStyleOptionGraphicsItem styleOptionTmp;
-
- QMap<int, QTouchEvent::TouchPoint> sceneCurrentTouchPoints;
- QMap<int, QGraphicsItem *> itemForTouchPointId;
- static void updateTouchPointsForItem(QGraphicsItem *item, QTouchEvent *touchEvent);
- int findClosestTouchPointId(const QPointF &scenePos);
- void touchEventHandler(QTouchEvent *touchEvent);
- bool sendTouchBeginEvent(QGraphicsItem *item, QTouchEvent *touchEvent);
- void enableTouchEventsOnViews();
-
- QList<QGraphicsObject *> cachedTargetItems;
-#ifndef QT_NO_GESTURES
- QHash<QGraphicsObject *, QSet<QGesture *> > cachedItemGestures;
- QHash<QGraphicsObject *, QSet<QGesture *> > cachedAlreadyDeliveredGestures;
- QHash<QGesture *, QGraphicsObject *> gestureTargets;
- QHash<Qt::GestureType, int> grabbedGestures;
- void gestureEventHandler(QGestureEvent *event);
- void gestureTargetsAtHotSpots(const QSet<QGesture *> &gestures,
- Qt::GestureFlag flag,
- QHash<QGraphicsObject *, QSet<QGesture *> > *targets,
- QSet<QGraphicsObject *> *itemsSet = 0,
- QSet<QGesture *> *normal = 0,
- QSet<QGesture *> *conflicts = 0);
- void cancelGesturesForChildren(QGesture *original);
- void grabGesture(QGraphicsItem *, Qt::GestureType gesture);
- void ungrabGesture(QGraphicsItem *, Qt::GestureType gesture);
-#endif // QT_NO_GESTURES
-
- void updateInputMethodSensitivityInViews();
-
- QList<QGraphicsItem *> modalPanels;
- void enterModal(QGraphicsItem *item,
- QGraphicsItem::PanelModality panelModality = QGraphicsItem::NonModal);
- void leaveModal(QGraphicsItem *item);
-};
-
-// QRectF::intersects() returns false always if either the source or target
-// rectangle's width or height are 0. This works around that problem.
-static inline void _q_adjustRect(QRectF *rect)
-{
- Q_ASSERT(rect);
- if (!rect->width())
- rect->adjust(qreal(-0.00001), 0, qreal(0.00001), 0);
- if (!rect->height())
- rect->adjust(0, qreal(-0.00001), 0, qreal(0.00001));
-}
-
-static inline QRectF adjustedItemBoundingRect(const QGraphicsItem *item)
-{
- Q_ASSERT(item);
- QRectF boundingRect(item->boundingRect());
- _q_adjustRect(&boundingRect);
- return boundingRect;
-}
-
-static inline QRectF adjustedItemEffectiveBoundingRect(const QGraphicsItem *item)
-{
- Q_ASSERT(item);
- QRectF boundingRect(QGraphicsItemPrivate::get(item)->effectiveBoundingRect());
- _q_adjustRect(&boundingRect);
- return boundingRect;
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_GRAPHICSVIEW
-
-#endif
diff --git a/src/gui/graphicsview/qgraphicssceneevent.cpp b/src/gui/graphicsview/qgraphicssceneevent.cpp
deleted file mode 100644
index 1b1f3db0aa..0000000000
--- a/src/gui/graphicsview/qgraphicssceneevent.cpp
+++ /dev/null
@@ -1,1674 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \class QGraphicsSceneEvent
- \brief The QGraphicsSceneEvent class provides a base class for all
- graphics view related events.
- \since 4.2
- \ingroup graphicsview-api
-
- When a QGraphicsView receives Qt mouse, keyboard, and drag and
- drop events (QMouseEvent, QKeyEvent, QDragEvent, etc.), it
- translates them into instances of QGraphicsSceneEvent subclasses
- and forwards them to the QGraphicsScene it displays. The scene
- then forwards the events to the relevant items.
-
- For example, when a QGraphicsView receives a QMouseEvent of type
- MousePress as a response to a user click, the view sends a
- QGraphicsSceneMouseEvent of type GraphicsSceneMousePress to the
- underlying QGraphicsScene through its
- \l{QGraphicsScene::}{mousePressEvent()} function. The default
- QGraphicsScene::mousePressEvent() implementation determines which
- item was clicked and forwards the event to
- QGraphicsItem::mousePressEvent().
-
- \omit ### Beskrive widget() \endomit
-
- Subclasses such as QGraphicsSceneMouseEvent and
- QGraphicsSceneContextMenuEvent provide the coordinates from the
- original QEvent in screen, scene, and item coordinates (see
- \l{QGraphicsSceneMouseEvent::}{screenPos()},
- \l{QGraphicsSceneMouseEvent::}{scenePos()}, and
- \l{QGraphicsSceneMouseEvent::}{pos()}). The item coordinates are
- set by the QGraphicsScene before it forwards the event to the
- event to a QGraphicsItem. The mouse events also add the
- possibility to retrieve the coordinates from the last event
- received by the view (see
- \l{QGraphicsSceneMouseEvent::}{lastScreenPos()},
- \l{QGraphicsSceneMouseEvent::}{lastScenePos()}, and
- \l{QGraphicsSceneMouseEvent::}{lastPos()}).
-
- \sa QEvent
-*/
-
-/*!
- \class QGraphicsSceneMouseEvent
- \brief The QGraphicsSceneMouseEvent class provides mouse events
- in the graphics view framework.
- \since 4.2
- \ingroup graphicsview-api
-
- When a QGraphicsView receives a QMouseEvent, it translates it to a
- QGraphicsSceneMouseEvent. The event is then forwarded to the
- QGraphicsScene associated with the view. If the event is not
- handled by the scene, the view may use it, e.g., for the
- \l{QGraphicsView::}{DragMode}.
-
- In addition to containing the item, scene, and screen coordinates
- of the event (as pos(), scenePos(), and screenPos()), mouse
- events also contain the coordinates of the previous mouse
- event received by the view. These can be retrieved with
- lastPos(), lastScreenPos(), and lastScenePos().
-
- \sa QGraphicsSceneContextMenuEvent,
- QGraphicsSceneHoverEvent, QGraphicsSceneWheelEvent,
- QMouseEvent
-*/
-
-/*!
- \class QGraphicsSceneWheelEvent
- \brief The QGraphicsSceneWheelEvent class provides wheel events
- in the graphics view framework.
- \brief The QGraphicsSceneWheelEvent class provides wheel events in the
- graphics view framework.
- \since 4.2
- \ingroup graphicsview-api
-
- \l{QWheelEvent}{QWheelEvent}s received by a QGraphicsView are translated
- into QGraphicsSceneWheelEvents; it translates the QWheelEvent::globalPos()
- into item, scene, and screen coordinates (pos(), scenePos(), and
- screenPos()).
-
- \sa QGraphicsSceneMouseEvent, QGraphicsSceneContextMenuEvent,
- QGraphicsSceneHoverEvent, QWheelEvent
-*/
-
-/*!
- \class QGraphicsSceneContextMenuEvent
- \brief The QGraphicsSceneContextMenuEvent class provides context
- menu events in the graphics view framework.
- \since 4.2
- \ingroup graphicsview-api
-
- A QContextMenuEvent received by a QGraphicsView is translated
- into a QGraphicsSceneContextMenuEvent. The
- QContextMenuEvent::globalPos() is translated into item, scene, and
- screen coordinates (pos(), scenePos(), and screenPos()).
-
- \sa QGraphicsSceneMouseEvent, QGraphicsSceneWheelEvent,
- QContextMenuEvent
-*/
-
-/*!
- \enum QGraphicsSceneContextMenuEvent::Reason
-
- This enum describes the reason why the context event was sent.
-
- \value Mouse The mouse caused the event to be sent. On most
- platforms, this means the right mouse button was clicked.
-
- \value Keyboard The keyboard caused this event to be sent. On
- Windows and Mac OS X, this means the menu button was pressed.
-
- \value Other The event was sent by some other means (i.e. not
- by the mouse or keyboard).
-*/
-
-/*!
- \class QGraphicsSceneHoverEvent
- \brief The QGraphicsSceneHoverEvent class provides hover events
- in the graphics view framework.
- \since 4.2
- \ingroup graphicsview-api
-
- When a QGraphicsView receives a QHoverEvent event, it translates
- it into QGraphicsSceneHoverEvent. The event is then forwarded to
- the QGraphicsScene associated with the view.
-
- \sa QGraphicsSceneMouseEvent, QGraphicsSceneContextMenuEvent,
- QGraphicsSceneWheelEvent, QHoverEvent
-*/
-
-/*!
- \class QGraphicsSceneHelpEvent
- \brief The QGraphicsSceneHelpEvent class provides events when a
- tooltip is requested.
- \since 4.2
- \ingroup graphicsview-api
-
- When a QGraphicsView receives a QEvent of type
- QEvent::ToolTip, it creates a QGraphicsSceneHelpEvent, which is
- forwarded to the scene. You can set a tooltip on a QGraphicsItem
- with \l{QGraphicsItem::}{setToolTip()}; by default QGraphicsScene
- displays the tooltip of the QGraphicsItem with the highest
- z-value (i.e, the top-most item) under the mouse position.
-
- QGraphicsView does not forward events when
- \l{QWhatsThis}{"What's This"} and \l{QStatusTipEvent}{status tip}
- help is requested. If you need this, you can reimplement
- QGraphicsView::viewportEvent() and forward QStatusTipEvent
- events and \l{QEvent}{QEvents} of type QEvent::WhatsThis to the
- scene.
-
- \sa QEvent
-*/
-
-/*!
- \class QGraphicsSceneDragDropEvent
- \brief The QGraphicsSceneDragDropEvent class provides events for
- drag and drop in the graphics view framework.
- \since 4.2
- \ingroup graphicsview-api
-
- QGraphicsView inherits the drag and drop functionality provided
- by QWidget. When it receives a drag and drop event, it translates
- it to a QGraphicsSceneDragDropEvent.
-
- QGraphicsSceneDragDropEvent stores events of type
- GraphicsSceneDragEnter, GraphicsSceneDragLeave,
- GraphicsSceneDragMove, or GraphicsSceneDrop.
-
- QGraphicsSceneDragDropEvent contains the position of the mouse
- cursor in both item, scene, and screen coordinates; this can be
- retrieved with pos(), scenePos(), and screenPos().
-
- The scene sends the event to the first QGraphicsItem under the
- mouse cursor that accepts drops; a graphics item is set to accept
- drops with \l{QGraphicsItem::}{setAcceptDrops()}.
-*/
-
-/*!
- \class QGraphicsSceneResizeEvent
- \brief The QGraphicsSceneResizeEvent class provides events for widget
- resizing in the graphics view framework.
- \since 4.4
- \ingroup graphicsview-api
-
- A QGraphicsWidget sends itself a QGraphicsSceneResizeEvent immediately
- when its geometry changes.
-
- It's similar to QResizeEvent, but its sizes, oldSize() and newSize(), use
- QSizeF instead of QSize.
-
- \sa QGraphicsWidget::setGeometry(), QGraphicsWidget::resize()
-*/
-
-/*!
- \class QGraphicsSceneMoveEvent
- \brief The QGraphicsSceneMoveEvent class provides events for widget
- moving in the graphics view framework.
- \since 4.4
- \ingroup graphicsview-api
-
- A QGraphicsWidget sends itself a QGraphicsSceneMoveEvent immediately when
- its local position changes. The delivery is implemented as part of
- QGraphicsItem::itemChange().
-
- It's similar to QMoveEvent, but its positions, oldPos() and newPos(), use
- QPointF instead of QPoint.
-
- \sa QGraphicsItem::setPos(), QGraphicsItem::ItemPositionChange,
- QGraphicsItem::ItemPositionHasChanged
-*/
-
-#include "qgraphicssceneevent.h"
-
-#ifndef QT_NO_GRAPHICSVIEW
-
-#ifndef QT_NO_DEBUG
-#include <QtCore/qdebug.h>
-#endif
-#include <QtCore/qmap.h>
-#include <QtCore/qpoint.h>
-#include <QtCore/qsize.h>
-#include <QtCore/qstring.h>
-#include "qgraphicsview.h"
-#include "qgraphicsitem.h"
-#include <QtGui/qgesture.h>
-#include <private/qevent_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QGraphicsSceneEventPrivate
-{
-public:
- inline QGraphicsSceneEventPrivate()
- : widget(0),
- q_ptr(0)
- { }
-
- inline virtual ~QGraphicsSceneEventPrivate()
- { }
-
- QWidget *widget;
- QGraphicsSceneEvent *q_ptr;
-};
-
-/*!
- \internal
-
- Constructs a generic graphics scene event of the specified \a type.
-*/
-QGraphicsSceneEvent::QGraphicsSceneEvent(Type type)
- : QEvent(type), d_ptr(new QGraphicsSceneEventPrivate)
-{
- d_ptr->q_ptr = this;
-}
-
-/*!
- \internal
-
- Constructs a generic graphics scene event.
-*/
-QGraphicsSceneEvent::QGraphicsSceneEvent(QGraphicsSceneEventPrivate &dd, Type type)
- : QEvent(type), d_ptr(&dd)
-{
- d_ptr->q_ptr = this;
-}
-
-/*!
- Destroys the event.
-*/
-QGraphicsSceneEvent::~QGraphicsSceneEvent()
-{
-}
-
-/*!
- Returns the widget where the event originated, or 0 if the event
- originates from another application.
-*/
-QWidget *QGraphicsSceneEvent::widget() const
-{
- return d_ptr->widget;
-}
-
-/*!
- \internal
-
- Sets the \a widget related to this event.
-
- \sa widget()
-*/
-void QGraphicsSceneEvent::setWidget(QWidget *widget)
-{
- d_ptr->widget = widget;
-}
-
-class QGraphicsSceneMouseEventPrivate : public QGraphicsSceneEventPrivate
-{
- Q_DECLARE_PUBLIC(QGraphicsSceneMouseEvent)
-public:
- inline QGraphicsSceneMouseEventPrivate()
- : button(Qt::NoButton),
- buttons(0), modifiers(0)
- { }
-
- QPointF pos;
- QPointF scenePos;
- QPoint screenPos;
- QPointF lastPos;
- QPointF lastScenePos;
- QPoint lastScreenPos;
- QMap<Qt::MouseButton, QPointF> buttonDownPos;
- QMap<Qt::MouseButton, QPointF> buttonDownScenePos;
- QMap<Qt::MouseButton, QPoint> buttonDownScreenPos;
- Qt::MouseButton button;
- Qt::MouseButtons buttons;
- Qt::KeyboardModifiers modifiers;
-};
-
-/*!
- \internal
-
- Constructs a generic graphics scene mouse event of the specified \a type.
-*/
-QGraphicsSceneMouseEvent::QGraphicsSceneMouseEvent(Type type)
- : QGraphicsSceneEvent(*new QGraphicsSceneMouseEventPrivate, type)
-{
-}
-
-/*!
- Destroys the event.
-*/
-QGraphicsSceneMouseEvent::~QGraphicsSceneMouseEvent()
-{
-}
-
-/*!
- Returns the mouse cursor position in item coordinates.
-
- \sa scenePos(), screenPos(), lastPos()
-*/
-QPointF QGraphicsSceneMouseEvent::pos() const
-{
- Q_D(const QGraphicsSceneMouseEvent);
- return d->pos;
-}
-
-/*!
- \internal
-*/
-void QGraphicsSceneMouseEvent::setPos(const QPointF &pos)
-{
- Q_D(QGraphicsSceneMouseEvent);
- d->pos = pos;
-}
-
-/*!
- Returns the mouse cursor position in scene coordinates.
-
- \sa pos(), screenPos(), lastScenePos()
-*/
-QPointF QGraphicsSceneMouseEvent::scenePos() const
-{
- Q_D(const QGraphicsSceneMouseEvent);
- return d->scenePos;
-}
-
-/*!
- \internal
-*/
-void QGraphicsSceneMouseEvent::setScenePos(const QPointF &pos)
-{
- Q_D(QGraphicsSceneMouseEvent);
- d->scenePos = pos;
-}
-
-/*!
- Returns the mouse cursor position in screen coordinates.
-
- \sa pos(), scenePos(), lastScreenPos()
-*/
-QPoint QGraphicsSceneMouseEvent::screenPos() const
-{
- Q_D(const QGraphicsSceneMouseEvent);
- return d->screenPos;
-}
-
-/*!
- \internal
-*/
-void QGraphicsSceneMouseEvent::setScreenPos(const QPoint &pos)
-{
- Q_D(QGraphicsSceneMouseEvent);
- d->screenPos = pos;
-}
-
-/*!
- Returns the mouse cursor position in item coordinates where the specified
- \a button was clicked.
-
- \sa buttonDownScenePos(), buttonDownScreenPos(), pos()
-*/
-QPointF QGraphicsSceneMouseEvent::buttonDownPos(Qt::MouseButton button) const
-{
- Q_D(const QGraphicsSceneMouseEvent);
- return d->buttonDownPos.value(button);
-}
-
-/*!
- \internal
-*/
-void QGraphicsSceneMouseEvent::setButtonDownPos(Qt::MouseButton button, const QPointF &pos)
-{
- Q_D(QGraphicsSceneMouseEvent);
- d->buttonDownPos.insert(button, pos);
-}
-
-/*!
- Returns the mouse cursor position in scene coordinates where the
- specified \a button was clicked.
-
- \sa buttonDownPos(), buttonDownScreenPos(), scenePos()
-*/
-QPointF QGraphicsSceneMouseEvent::buttonDownScenePos(Qt::MouseButton button) const
-{
- Q_D(const QGraphicsSceneMouseEvent);
- return d->buttonDownScenePos.value(button);
-}
-
-/*!
- \internal
-*/
-void QGraphicsSceneMouseEvent::setButtonDownScenePos(Qt::MouseButton button, const QPointF &pos)
-{
- Q_D(QGraphicsSceneMouseEvent);
- d->buttonDownScenePos.insert(button, pos);
-}
-
-/*!
- Returns the mouse cursor position in screen coordinates where the
- specified \a button was clicked.
-
- \sa screenPos(), buttonDownPos(), buttonDownScenePos()
-*/
-QPoint QGraphicsSceneMouseEvent::buttonDownScreenPos(Qt::MouseButton button) const
-{
- Q_D(const QGraphicsSceneMouseEvent);
- return d->buttonDownScreenPos.value(button);
-}
-
-/*!
- \internal
-*/
-void QGraphicsSceneMouseEvent::setButtonDownScreenPos(Qt::MouseButton button, const QPoint &pos)
-{
- Q_D(QGraphicsSceneMouseEvent);
- d->buttonDownScreenPos.insert(button, pos);
-}
-
-/*!
- Returns the last recorded mouse cursor position in item
- coordinates.
-
- \sa lastScenePos(), lastScreenPos(), pos()
-*/
-QPointF QGraphicsSceneMouseEvent::lastPos() const
-{
- Q_D(const QGraphicsSceneMouseEvent);
- return d->lastPos;
-}
-
-/*!
- \internal
-*/
-void QGraphicsSceneMouseEvent::setLastPos(const QPointF &pos)
-{
- Q_D(QGraphicsSceneMouseEvent);
- d->lastPos = pos;
-}
-
-/*!
- Returns the last recorded mouse cursor position in scene
- coordinates. The last recorded position is the position of
- the previous mouse event received by the view that created
- the event.
-
- \sa lastPos(), lastScreenPos(), scenePos()
-*/
-QPointF QGraphicsSceneMouseEvent::lastScenePos() const
-{
- Q_D(const QGraphicsSceneMouseEvent);
- return d->lastScenePos;
-}
-
-/*!
- \internal
-*/
-void QGraphicsSceneMouseEvent::setLastScenePos(const QPointF &pos)
-{
- Q_D(QGraphicsSceneMouseEvent);
- d->lastScenePos = pos;
-}
-
-/*!
- Returns the last recorded mouse cursor position in screen
- coordinates. The last recorded position is the position of
- the previous mouse event received by the view that created
- the event.
-
- \sa lastPos(), lastScenePos(), screenPos()
-*/
-QPoint QGraphicsSceneMouseEvent::lastScreenPos() const
-{
- Q_D(const QGraphicsSceneMouseEvent);
- return d->lastScreenPos;
-}
-
-/*!
- \internal
-*/
-void QGraphicsSceneMouseEvent::setLastScreenPos(const QPoint &pos)
-{
- Q_D(QGraphicsSceneMouseEvent);
- d->lastScreenPos = pos;
-}
-
-/*!
- Returns the combination of mouse buttons that were pressed at the
- time the event was sent.
-
- \sa button(), modifiers()
-*/
-Qt::MouseButtons QGraphicsSceneMouseEvent::buttons() const
-{
- Q_D(const QGraphicsSceneMouseEvent);
- return d->buttons;
-}
-
-/*!
- \internal
-*/
-void QGraphicsSceneMouseEvent::setButtons(Qt::MouseButtons buttons)
-{
- Q_D(QGraphicsSceneMouseEvent);
- d->buttons = buttons;
-}
-
-/*!
- Returns the mouse button (if any) that caused the event.
-
- \sa buttons(), modifiers()
-*/
-Qt::MouseButton QGraphicsSceneMouseEvent::button() const
-{
- Q_D(const QGraphicsSceneMouseEvent);
- return d->button;
-}
-
-/*!
- \internal
-*/
-void QGraphicsSceneMouseEvent::setButton(Qt::MouseButton button)
-{
- Q_D(QGraphicsSceneMouseEvent);
- d->button = button;
-}
-
-/*!
- Returns the keyboard modifiers in use at the time the event was
- sent.
-
- \sa buttons(), button()
-*/
-Qt::KeyboardModifiers QGraphicsSceneMouseEvent::modifiers() const
-{
- Q_D(const QGraphicsSceneMouseEvent);
- return d->modifiers;
-}
-
-/*!
- \internal
-*/
-void QGraphicsSceneMouseEvent::setModifiers(Qt::KeyboardModifiers modifiers)
-{
- Q_D(QGraphicsSceneMouseEvent);
- d->modifiers = modifiers;
-}
-
-class QGraphicsSceneWheelEventPrivate : public QGraphicsSceneEventPrivate
-{
- Q_DECLARE_PUBLIC(QGraphicsSceneWheelEvent)
-public:
- inline QGraphicsSceneWheelEventPrivate()
- : buttons(0), modifiers(0), delta(0), orientation(Qt::Horizontal)
- { }
-
- QPointF pos;
- QPointF scenePos;
- QPoint screenPos;
- Qt::MouseButtons buttons;
- Qt::KeyboardModifiers modifiers;
- int delta;
- Qt::Orientation orientation;
-};
-
-/*!
- \internal
-
- Constructs a QGraphicsSceneWheelEvent of type \a type, which
- is always QEvent::GraphicsSceneWheel.
-*/
-QGraphicsSceneWheelEvent::QGraphicsSceneWheelEvent(Type type)
- : QGraphicsSceneEvent(*new QGraphicsSceneWheelEventPrivate, type)
-{
-}
-
-/*!
- Destroys the QGraphicsSceneWheelEvent.
-*/
-QGraphicsSceneWheelEvent::~QGraphicsSceneWheelEvent()
-{
-}
-
-/*!
- Returns the position of the cursor in item coordinates when the
- wheel event occurred.
-
- \sa scenePos(), screenPos()
-*/
-QPointF QGraphicsSceneWheelEvent::pos() const
-{
- Q_D(const QGraphicsSceneWheelEvent);
- return d->pos;
-}
-
-/*!
- \internal
-*/
-void QGraphicsSceneWheelEvent::setPos(const QPointF &pos)
-{
- Q_D(QGraphicsSceneWheelEvent);
- d->pos = pos;
-}
-
-/*!
- Returns the position of the cursor in scene coordinates when the wheel
- event occurred.
-
- \sa pos(), screenPos()
-*/
-QPointF QGraphicsSceneWheelEvent::scenePos() const
-{
- Q_D(const QGraphicsSceneWheelEvent);
- return d->scenePos;
-}
-
-/*!
- \internal
-*/
-void QGraphicsSceneWheelEvent::setScenePos(const QPointF &pos)
-{
- Q_D(QGraphicsSceneWheelEvent);
- d->scenePos = pos;
-}
-
-/*!
- Returns the position of the cursor in screen coordinates when the wheel
- event occurred.
-
- \sa pos(), scenePos()
-*/
-QPoint QGraphicsSceneWheelEvent::screenPos() const
-{
- Q_D(const QGraphicsSceneWheelEvent);
- return d->screenPos;
-}
-
-/*!
- \internal
-*/
-void QGraphicsSceneWheelEvent::setScreenPos(const QPoint &pos)
-{
- Q_D(QGraphicsSceneWheelEvent);
- d->screenPos = pos;
-}
-
-/*!
- Returns the mouse buttons that were pressed when the wheel event occurred.
-
- \sa modifiers()
-*/
-Qt::MouseButtons QGraphicsSceneWheelEvent::buttons() const
-{
- Q_D(const QGraphicsSceneWheelEvent);
- return d->buttons;
-}
-
-/*!
- \internal
-*/
-void QGraphicsSceneWheelEvent::setButtons(Qt::MouseButtons buttons)
-{
- Q_D(QGraphicsSceneWheelEvent);
- d->buttons = buttons;
-}
-
-/*!
- Returns the keyboard modifiers that were active when the wheel event
- occurred.
-
- \sa buttons()
-*/
-Qt::KeyboardModifiers QGraphicsSceneWheelEvent::modifiers() const
-{
- Q_D(const QGraphicsSceneWheelEvent);
- return d->modifiers;
-}
-
-/*!
- \internal
-*/
-void QGraphicsSceneWheelEvent::setModifiers(Qt::KeyboardModifiers modifiers)
-{
- Q_D(QGraphicsSceneWheelEvent);
- d->modifiers = modifiers;
-}
-
-/*!
- Returns the distance that the wheel is rotated, in eighths (1/8s)
- of a degree. A positive value indicates that the wheel was
- rotated forwards away from the user; a negative value indicates
- that the wheel was rotated backwards toward the user.
-
- Most mouse types work in steps of 15 degrees, in which case the delta
- value is a multiple of 120 (== 15 * 8).
-*/
-int QGraphicsSceneWheelEvent::delta() const
-{
- Q_D(const QGraphicsSceneWheelEvent);
- return d->delta;
-}
-
-/*!
- \internal
-*/
-void QGraphicsSceneWheelEvent::setDelta(int delta)
-{
- Q_D(QGraphicsSceneWheelEvent);
- d->delta = delta;
-}
-
-/*!
- Returns the wheel orientation.
-*/
-Qt::Orientation QGraphicsSceneWheelEvent::orientation() const
-{
- Q_D(const QGraphicsSceneWheelEvent);
- return d->orientation;
-}
-
-/*!
- \internal
-*/
-void QGraphicsSceneWheelEvent::setOrientation(Qt::Orientation orientation)
-{
- Q_D(QGraphicsSceneWheelEvent);
- d->orientation = orientation;
-}
-
-class QGraphicsSceneContextMenuEventPrivate : public QGraphicsSceneEventPrivate
-{
- Q_DECLARE_PUBLIC(QGraphicsSceneContextMenuEvent)
- public:
- inline QGraphicsSceneContextMenuEventPrivate()
- : modifiers(0), reason(QGraphicsSceneContextMenuEvent::Other)
- { }
-
- QPointF pos;
- QPointF scenePos;
- QPoint screenPos;
- Qt::KeyboardModifiers modifiers;
- QGraphicsSceneContextMenuEvent::Reason reason;
-};
-
-/*!
- \internal
-
- Constructs a graphics scene context menu event of the specified \a type.
-*/
-QGraphicsSceneContextMenuEvent::QGraphicsSceneContextMenuEvent(Type type)
- : QGraphicsSceneEvent(*new QGraphicsSceneContextMenuEventPrivate, type)
-{
-}
-
-/*!
- Destroys the event.
-*/
-QGraphicsSceneContextMenuEvent::~QGraphicsSceneContextMenuEvent()
-{
-}
-
-/*!
- Returns the position of the mouse cursor in item coordinates at the moment
- the context menu was requested.
-
- \sa scenePos(), screenPos()
-*/
-QPointF QGraphicsSceneContextMenuEvent::pos() const
-{
- Q_D(const QGraphicsSceneContextMenuEvent);
- return d->pos;
-}
-
-/*!
- \fn void QGraphicsSceneContextMenuEvent::setPos(const QPointF &point)
- \internal
-
- Sets the position associated with the context menu to the given \a point
- in item coordinates.
-*/
-void QGraphicsSceneContextMenuEvent::setPos(const QPointF &pos)
-{
- Q_D(QGraphicsSceneContextMenuEvent);
- d->pos = pos;
-}
-
-/*!
- Returns the position of the mouse cursor in scene coordinates at the moment the
- the context menu was requested.
-
- \sa pos(), screenPos()
-*/
-QPointF QGraphicsSceneContextMenuEvent::scenePos() const
-{
- Q_D(const QGraphicsSceneContextMenuEvent);
- return d->scenePos;
-}
-
-/*!
- \fn void QGraphicsSceneContextMenuEvent::setScenePos(const QPointF &point)
- \internal
-
- Sets the position associated with the context menu to the given \a point
- in scene coordinates.
-*/
-void QGraphicsSceneContextMenuEvent::setScenePos(const QPointF &pos)
-{
- Q_D(QGraphicsSceneContextMenuEvent);
- d->scenePos = pos;
-}
-
-/*!
- Returns the position of the mouse cursor in screen coordinates at the moment the
- the context menu was requested.
-
- \sa pos(), scenePos()
-*/
-QPoint QGraphicsSceneContextMenuEvent::screenPos() const
-{
- Q_D(const QGraphicsSceneContextMenuEvent);
- return d->screenPos;
-}
-
-/*!
- \fn void QGraphicsSceneContextMenuEvent::setScreenPos(const QPoint &point)
- \internal
-
- Sets the position associated with the context menu to the given \a point
- in screen coordinates.
-*/
-void QGraphicsSceneContextMenuEvent::setScreenPos(const QPoint &pos)
-{
- Q_D(QGraphicsSceneContextMenuEvent);
- d->screenPos = pos;
-}
-
-/*!
- Returns the keyboard modifiers in use when the context menu was requested.
-*/
-Qt::KeyboardModifiers QGraphicsSceneContextMenuEvent::modifiers() const
-{
- Q_D(const QGraphicsSceneContextMenuEvent);
- return d->modifiers;
-}
-
-/*!
- \internal
-
- Sets the keyboard modifiers associated with the context menu to the \a
- modifiers specified.
-*/
-void QGraphicsSceneContextMenuEvent::setModifiers(Qt::KeyboardModifiers modifiers)
-{
- Q_D(QGraphicsSceneContextMenuEvent);
- d->modifiers = modifiers;
-}
-
-/*!
- Returns the reason for the context menu event.
-
- \sa QGraphicsSceneContextMenuEvent::Reason
-*/
-QGraphicsSceneContextMenuEvent::Reason QGraphicsSceneContextMenuEvent::reason() const
-{
- Q_D(const QGraphicsSceneContextMenuEvent);
- return d->reason;
-}
-
-/*!
- \internal
- Sets the reason for the context menu event to \a reason.
-
- \sa reason()
-*/
-void QGraphicsSceneContextMenuEvent::setReason(Reason reason)
-{
- Q_D(QGraphicsSceneContextMenuEvent);
- d->reason = reason;
-}
-
-class QGraphicsSceneHoverEventPrivate : public QGraphicsSceneEventPrivate
-{
-public:
- QPointF pos;
- QPointF scenePos;
- QPoint screenPos;
- QPointF lastPos;
- QPointF lastScenePos;
- QPoint lastScreenPos;
- Qt::KeyboardModifiers modifiers;
-};
-
-/*!
- \internal
-
- Constructs a graphics scene hover event of the specified \a type.
-*/
-QGraphicsSceneHoverEvent::QGraphicsSceneHoverEvent(Type type)
- : QGraphicsSceneEvent(*new QGraphicsSceneHoverEventPrivate, type)
-{
-}
-
-/*!
- Destroys the event.
-*/
-QGraphicsSceneHoverEvent::~QGraphicsSceneHoverEvent()
-{
-}
-
-/*!
- Returns the position of the mouse cursor in item coordinates at the moment
- the hover event was sent.
-
- \sa scenePos(), screenPos()
-*/
-QPointF QGraphicsSceneHoverEvent::pos() const
-{
- Q_D(const QGraphicsSceneHoverEvent);
- return d->pos;
-}
-
-/*!
- \fn void QGraphicsSceneHoverEvent::setPos(const QPointF &point)
- \internal
-
- Sets the position associated with the hover event to the given \a point in
- item coordinates.
-*/
-void QGraphicsSceneHoverEvent::setPos(const QPointF &pos)
-{
- Q_D(QGraphicsSceneHoverEvent);
- d->pos = pos;
-}
-
-/*!
- Returns the position of the mouse cursor in scene coordinates at the
- moment the hover event was sent.
-
- \sa pos(), screenPos()
-*/
-QPointF QGraphicsSceneHoverEvent::scenePos() const
-{
- Q_D(const QGraphicsSceneHoverEvent);
- return d->scenePos;
-}
-
-/*!
- \fn void QGraphicsSceneHoverEvent::setScenePos(const QPointF &point)
- \internal
-
- Sets the position associated with the hover event to the given \a point in
- scene coordinates.
-*/
-void QGraphicsSceneHoverEvent::setScenePos(const QPointF &pos)
-{
- Q_D(QGraphicsSceneHoverEvent);
- d->scenePos = pos;
-}
-
-/*!
- Returns the position of the mouse cursor in screen coordinates at the
- moment the hover event was sent.
-
- \sa pos(), scenePos()
-*/
-QPoint QGraphicsSceneHoverEvent::screenPos() const
-{
- Q_D(const QGraphicsSceneHoverEvent);
- return d->screenPos;
-}
-
-/*!
- \fn void QGraphicsSceneHoverEvent::setScreenPos(const QPoint &point)
- \internal
-
- Sets the position associated with the hover event to the given \a point in
- screen coordinates.
-*/
-void QGraphicsSceneHoverEvent::setScreenPos(const QPoint &pos)
-{
- Q_D(QGraphicsSceneHoverEvent);
- d->screenPos = pos;
-}
-
-/*!
- \since 4.4
-
- Returns the last recorded mouse cursor position in item coordinates.
-
- \sa lastScenePos(), lastScreenPos(), pos()
-*/
-QPointF QGraphicsSceneHoverEvent::lastPos() const
-{
- Q_D(const QGraphicsSceneHoverEvent);
- return d->lastPos;
-}
-
-/*!
- \internal
-*/
-void QGraphicsSceneHoverEvent::setLastPos(const QPointF &pos)
-{
- Q_D(QGraphicsSceneHoverEvent);
- d->lastPos = pos;
-}
-
-/*!
- \since 4.4
-
- Returns the last recorded, the scene coordinates of the previous mouse or
- hover event received by the view, that created the event mouse cursor
- position in scene coordinates.
-
- \sa lastPos(), lastScreenPos(), scenePos()
-*/
-QPointF QGraphicsSceneHoverEvent::lastScenePos() const
-{
- Q_D(const QGraphicsSceneHoverEvent);
- return d->lastScenePos;
-}
-
-/*!
- \internal
-*/
-void QGraphicsSceneHoverEvent::setLastScenePos(const QPointF &pos)
-{
- Q_D(QGraphicsSceneHoverEvent);
- d->lastScenePos = pos;
-}
-
-/*!
- \since 4.4
-
- Returns the last recorded mouse cursor position in screen coordinates. The
- last recorded position is the position of the previous mouse or hover
- event received by the view that created the event.
-
- \sa lastPos(), lastScenePos(), screenPos()
-*/
-QPoint QGraphicsSceneHoverEvent::lastScreenPos() const
-{
- Q_D(const QGraphicsSceneHoverEvent);
- return d->lastScreenPos;
-}
-
-/*!
- \internal
-*/
-void QGraphicsSceneHoverEvent::setLastScreenPos(const QPoint &pos)
-{
- Q_D(QGraphicsSceneHoverEvent);
- d->lastScreenPos = pos;
-}
-
-/*!
- \since 4.4
-
- Returns the keyboard modifiers at the moment the hover event was sent.
-*/
-Qt::KeyboardModifiers QGraphicsSceneHoverEvent::modifiers() const
-{
- Q_D(const QGraphicsSceneHoverEvent);
- return d->modifiers;
-}
-
-/*!
- \fn void QGraphicsSceneHoverEvent::setModifiers(Qt::KeyboardModifiers modifiers)
- \internal
-
- Sets the modifiers for the current hover event to \a modifiers.
-*/
-void QGraphicsSceneHoverEvent::setModifiers(Qt::KeyboardModifiers modifiers)
-{
- Q_D(QGraphicsSceneHoverEvent);
- d->modifiers = modifiers;
-}
-
-class QGraphicsSceneHelpEventPrivate : public QGraphicsSceneEventPrivate
-{
-public:
- QPointF scenePos;
- QPoint screenPos;
-};
-
-/*!
- \internal
-
- Constructs a graphics scene help event of the specified \a type.
-*/
-QGraphicsSceneHelpEvent::QGraphicsSceneHelpEvent(Type type)
- : QGraphicsSceneEvent(*new QGraphicsSceneHelpEventPrivate, type)
-{
-}
-
-/*!
- Destroys the event.
-*/
-QGraphicsSceneHelpEvent::~QGraphicsSceneHelpEvent()
-{
-}
-
-/*!
- Returns the position of the mouse cursor in scene coordinates at the
- moment the help event was sent.
-
- \sa screenPos()
-*/
-QPointF QGraphicsSceneHelpEvent::scenePos() const
-{
- Q_D(const QGraphicsSceneHelpEvent);
- return d->scenePos;
-}
-
-/*!
- \fn void QGraphicsSceneHelpEvent::setScenePos(const QPointF &point)
- \internal
-
- Sets the position associated with the context menu to the given \a point
- in scene coordinates.
-*/
-void QGraphicsSceneHelpEvent::setScenePos(const QPointF &pos)
-{
- Q_D(QGraphicsSceneHelpEvent);
- d->scenePos = pos;
-}
-
-/*!
- Returns the position of the mouse cursor in screen coordinates at the
- moment the help event was sent.
-
- \sa scenePos()
-*/
-QPoint QGraphicsSceneHelpEvent::screenPos() const
-{
- Q_D(const QGraphicsSceneHelpEvent);
- return d->screenPos;
-}
-
-/*!
- \fn void QGraphicsSceneHelpEvent::setScreenPos(const QPoint &point)
- \internal
-
- Sets the position associated with the context menu to the given \a point
- in screen coordinates.
-*/
-void QGraphicsSceneHelpEvent::setScreenPos(const QPoint &pos)
-{
- Q_D(QGraphicsSceneHelpEvent);
- d->screenPos = pos;
-}
-
-class QGraphicsSceneDragDropEventPrivate : public QGraphicsSceneEventPrivate
-{
- Q_DECLARE_PUBLIC(QGraphicsSceneDragDropEvent)
-public:
- inline QGraphicsSceneDragDropEventPrivate()
- : source(0), mimeData(0)
- { }
-
- QPointF pos;
- QPointF scenePos;
- QPoint screenPos;
- Qt::MouseButtons buttons;
- Qt::KeyboardModifiers modifiers;
- Qt::DropActions possibleActions;
- Qt::DropAction proposedAction;
- Qt::DropAction dropAction;
- QWidget *source;
- const QMimeData *mimeData;
-};
-
-/*!
- \internal
-
- Constructs a new QGraphicsSceneDragDropEvent of the
- specified \a type. The type can be either
- QEvent::GraphicsSceneDragEnter, QEvent::GraphicsSceneDragLeave,
- QEvent::GraphicsSceneDragMove, or QEvent::GraphicsSceneDrop.
-*/
-QGraphicsSceneDragDropEvent::QGraphicsSceneDragDropEvent(Type type)
- : QGraphicsSceneEvent(*new QGraphicsSceneDragDropEventPrivate, type)
-{
-}
-
-/*!
- Destroys the object.
-*/
-QGraphicsSceneDragDropEvent::~QGraphicsSceneDragDropEvent()
-{
-}
-
-/*!
- Returns the mouse position of the event relative to the
- view that sent the event.
-
- \sa QGraphicsView, screenPos(), scenePos()
-*/
-QPointF QGraphicsSceneDragDropEvent::pos() const
-{
- Q_D(const QGraphicsSceneDragDropEvent);
- return d->pos;
-}
-
-/*!
- \internal
- Sets the position of the mouse to \a pos; this should be
- relative to the widget that generated the event, which normally
- is a QGraphicsView.
-
- \sa pos(), setScenePos(), setScreenPos()
-*/
-
-void QGraphicsSceneDragDropEvent::setPos(const QPointF &pos)
-{
- Q_D(QGraphicsSceneDragDropEvent);
- d->pos = pos;
-}
-
-/*!
- Returns the position of the mouse in scene coordinates.
-
- \sa pos(), screenPos()
-*/
-QPointF QGraphicsSceneDragDropEvent::scenePos() const
-{
- Q_D(const QGraphicsSceneDragDropEvent);
- return d->scenePos;
-}
-
-/*!
- \internal
- Sets the scene position of the mouse to \a pos.
-
- \sa scenePos(), setScreenPos(), setPos()
-*/
-void QGraphicsSceneDragDropEvent::setScenePos(const QPointF &pos)
-{
- Q_D(QGraphicsSceneDragDropEvent);
- d->scenePos = pos;
-}
-
-/*!
- Returns the position of the mouse relative to the screen.
-
- \sa pos(), scenePos()
-*/
-QPoint QGraphicsSceneDragDropEvent::screenPos() const
-{
- Q_D(const QGraphicsSceneDragDropEvent);
- return d->screenPos;
-}
-
-/*!
- \internal
- Sets the mouse position relative to the screen to \a pos.
-
- \sa screenPos(), setScenePos(), setPos()
-*/
-void QGraphicsSceneDragDropEvent::setScreenPos(const QPoint &pos)
-{
- Q_D(QGraphicsSceneDragDropEvent);
- d->screenPos = pos;
-}
-
-/*!
- Returns a Qt::MouseButtons value indicating which buttons
- were pressed on the mouse when this mouse event was
- generated.
-
- \sa Qt::MouseButtons
-*/
-Qt::MouseButtons QGraphicsSceneDragDropEvent::buttons() const
-{
- Q_D(const QGraphicsSceneDragDropEvent);
- return d->buttons;
-}
-
-/*!
- \internal
- Sets the mouse buttons that were pressed when the event was
- created to \a buttons.
-
- \sa Qt::MouseButtons, buttons()
-*/
-void QGraphicsSceneDragDropEvent::setButtons(Qt::MouseButtons buttons)
-{
- Q_D(QGraphicsSceneDragDropEvent);
- d->buttons = buttons;
-}
-
-/*!
- Returns the keyboard modifiers that were pressed when the drag
- and drop event was created.
-
- \sa Qt::KeyboardModifiers
-*/
-Qt::KeyboardModifiers QGraphicsSceneDragDropEvent::modifiers() const
-{
- Q_D(const QGraphicsSceneDragDropEvent);
- return d->modifiers;
-}
-
-/*!
- \internal
- Sets the keyboard modifiers that were pressed when the event
- was created to \a modifiers.
-
- \sa Qt::KeyboardModifiers, modifiers()
-*/
-
-void QGraphicsSceneDragDropEvent::setModifiers(Qt::KeyboardModifiers modifiers)
-{
- Q_D(QGraphicsSceneDragDropEvent);
- d->modifiers = modifiers;
-}
-
-/*!
- Returns the possible drop actions that the drag and
- drop can result in.
-
- \sa Qt::DropActions
-*/
-
-Qt::DropActions QGraphicsSceneDragDropEvent::possibleActions() const
-{
- Q_D(const QGraphicsSceneDragDropEvent);
- return d->possibleActions;
-}
-
-/*!
- \internal
- Sets the possible drop actions that the drag can
- result in to \a actions.
-
- \sa Qt::DropActions, possibleActions()
-*/
-void QGraphicsSceneDragDropEvent::setPossibleActions(Qt::DropActions actions)
-{
- Q_D(QGraphicsSceneDragDropEvent);
- d->possibleActions = actions;
-}
-
-/*!
- Returns the drop action that is proposed, i.e., preferred.
- The action must be one of the possible actions as defined by
- \c possibleActions().
-
- \sa Qt::DropAction, possibleActions()
-*/
-
-Qt::DropAction QGraphicsSceneDragDropEvent::proposedAction() const
-{
- Q_D(const QGraphicsSceneDragDropEvent);
- return d->proposedAction;
-}
-
-/*!
- \internal
- Sets the proposed action to \a action. The proposed action
- is a Qt::DropAction that is one of the possible actions as
- given by \c possibleActions().
-
- \sa proposedAction(), Qt::DropAction, possibleActions()
-*/
-
-void QGraphicsSceneDragDropEvent::setProposedAction(Qt::DropAction action)
-{
- Q_D(QGraphicsSceneDragDropEvent);
- d->proposedAction = action;
-}
-
-/*!
- Sets the proposed action as accepted, i.e, the drop action
- is set to the proposed action. This is equal to:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicssceneevent.cpp 0
-
- When using this function, one should not call \c accept().
-
- \sa dropAction(), setDropAction(), proposedAction()
-*/
-
-void QGraphicsSceneDragDropEvent::acceptProposedAction()
-{
- Q_D(QGraphicsSceneDragDropEvent);
- d->dropAction = d->proposedAction;
-}
-
-/*!
- Returns the action that was performed in this drag and drop.
- This should be set by the receiver of the drop and is
- returned by QDrag::exec().
-
- \sa setDropAction(), acceptProposedAction()
-*/
-
-Qt::DropAction QGraphicsSceneDragDropEvent::dropAction() const
-{
- Q_D(const QGraphicsSceneDragDropEvent);
- return d->dropAction;
-}
-
-/*!
- This function lets the receiver of the drop set the drop
- action that was performed to \a action, which should be one
- of the
- \l{QGraphicsSceneDragDropEvent::possibleActions()}{possible
- actions}. Call \c accept() in stead of \c
- acceptProposedAction() if you use this function.
-
- \sa dropAction(), accept(), possibleActions()
-*/
-void QGraphicsSceneDragDropEvent::setDropAction(Qt::DropAction action)
-{
- Q_D(QGraphicsSceneDragDropEvent);
- d->dropAction = action;
-}
-
-/*!
- This function returns the QGraphicsView that created the
- QGraphicsSceneDragDropEvent.
-*/
-QWidget *QGraphicsSceneDragDropEvent::source() const
-{
- Q_D(const QGraphicsSceneDragDropEvent);
- return d->source;
-}
-
-/*!
- \internal
- This function set the source widget, i.e., the widget that
- created the drop event, to \a source.
-*/
-void QGraphicsSceneDragDropEvent::setSource(QWidget *source)
-{
- Q_D(QGraphicsSceneDragDropEvent);
- d->source = source;
-}
-
-/*!
- This function returns the MIME data of the event.
-*/
-const QMimeData *QGraphicsSceneDragDropEvent::mimeData() const
-{
- Q_D(const QGraphicsSceneDragDropEvent);
- return d->mimeData;
-}
-
-/*!
- \internal
- This function sets the MIME data for the event.
-*/
-void QGraphicsSceneDragDropEvent::setMimeData(const QMimeData *data)
-{
- Q_D(QGraphicsSceneDragDropEvent);
- d->mimeData = data;
-}
-
-class QGraphicsSceneResizeEventPrivate : public QGraphicsSceneEventPrivate
-{
- Q_DECLARE_PUBLIC(QGraphicsSceneResizeEvent)
-public:
- inline QGraphicsSceneResizeEventPrivate()
- { }
-
- QSizeF oldSize;
- QSizeF newSize;
-};
-
-/*!
- Constructs a QGraphicsSceneResizeEvent.
-*/
-QGraphicsSceneResizeEvent::QGraphicsSceneResizeEvent()
- : QGraphicsSceneEvent(*new QGraphicsSceneResizeEventPrivate, QEvent::GraphicsSceneResize)
-{
-}
-
-/*!
- Destroys the QGraphicsSceneResizeEvent.
-*/
-QGraphicsSceneResizeEvent::~QGraphicsSceneResizeEvent()
-{
-}
-
-/*!
- Returns the old size (i.e., the size immediately before the widget was
- resized).
-
- \sa newSize(), QGraphicsWidget::resize()
-*/
-QSizeF QGraphicsSceneResizeEvent::oldSize() const
-{
- Q_D(const QGraphicsSceneResizeEvent);
- return d->oldSize;
-}
-
-/*!
- \internal
-*/
-void QGraphicsSceneResizeEvent::setOldSize(const QSizeF &size)
-{
- Q_D(QGraphicsSceneResizeEvent);
- d->oldSize = size;
-}
-
-/*!
- Returns the new size (i.e., the current size).
-
- \sa oldSize(), QGraphicsWidget::resize()
-*/
-QSizeF QGraphicsSceneResizeEvent::newSize() const
-{
- Q_D(const QGraphicsSceneResizeEvent);
- return d->newSize;
-}
-
-/*!
- \internal
-*/
-void QGraphicsSceneResizeEvent::setNewSize(const QSizeF &size)
-{
- Q_D(QGraphicsSceneResizeEvent);
- d->newSize = size;
-}
-
-class QGraphicsSceneMoveEventPrivate : public QGraphicsSceneEventPrivate
-{
- Q_DECLARE_PUBLIC(QGraphicsSceneMoveEvent)
-public:
- inline QGraphicsSceneMoveEventPrivate()
- { }
-
- QPointF oldPos;
- QPointF newPos;
-};
-
-/*!
- Constructs a QGraphicsSceneMoveEvent.
-*/
-QGraphicsSceneMoveEvent::QGraphicsSceneMoveEvent()
- : QGraphicsSceneEvent(*new QGraphicsSceneMoveEventPrivate, QEvent::GraphicsSceneMove)
-{
-}
-
-/*!
- Destroys the QGraphicsSceneMoveEvent.
-*/
-QGraphicsSceneMoveEvent::~QGraphicsSceneMoveEvent()
-{
-}
-
-/*!
- Returns the old position (i.e., the position immediately before the widget
- was moved).
-
- \sa newPos(), QGraphicsItem::setPos()
-*/
-QPointF QGraphicsSceneMoveEvent::oldPos() const
-{
- Q_D(const QGraphicsSceneMoveEvent);
- return d->oldPos;
-}
-
-/*!
- \internal
-*/
-void QGraphicsSceneMoveEvent::setOldPos(const QPointF &pos)
-{
- Q_D(QGraphicsSceneMoveEvent);
- d->oldPos = pos;
-}
-
-/*!
- Returns the new position (i.e., the current position).
-
- \sa oldPos(), QGraphicsItem::setPos()
-*/
-QPointF QGraphicsSceneMoveEvent::newPos() const
-{
- Q_D(const QGraphicsSceneMoveEvent);
- return d->newPos;
-}
-
-/*!
- \internal
-*/
-void QGraphicsSceneMoveEvent::setNewPos(const QPointF &pos)
-{
- Q_D(QGraphicsSceneMoveEvent);
- d->newPos = pos;
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_GRAPHICSVIEW
diff --git a/src/gui/graphicsview/qgraphicsscenelinearindex_p.h b/src/gui/graphicsview/qgraphicsscenelinearindex_p.h
deleted file mode 100644
index ef72f57faf..0000000000
--- a/src/gui/graphicsview/qgraphicsscenelinearindex_p.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSSCENELINEARINDEX_H
-#define QGRAPHICSSCENELINEARINDEX_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qglobal.h>
-
-#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
-
-#include <QtCore/qrect.h>
-#include <QtCore/qlist.h>
-#include <QtGui/qgraphicsitem.h>
-#include <private/qgraphicssceneindex_p.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class Q_AUTOTEST_EXPORT QGraphicsSceneLinearIndex : public QGraphicsSceneIndex
-{
- Q_OBJECT
-
-public:
- QGraphicsSceneLinearIndex(QGraphicsScene *scene = 0) : QGraphicsSceneIndex(scene)
- { }
-
- QList<QGraphicsItem *> items(Qt::SortOrder order = Qt::DescendingOrder) const
- { Q_UNUSED(order); return m_items; }
-
- virtual QList<QGraphicsItem *> estimateItems(const QRectF &rect, Qt::SortOrder order) const
- {
- Q_UNUSED(rect);
- Q_UNUSED(order);
- return m_items;
- }
-
-protected :
- virtual void clear()
- { m_items.clear(); }
-
- virtual void addItem(QGraphicsItem *item)
- { m_items << item; }
-
- virtual void removeItem(QGraphicsItem *item)
- { m_items.removeOne(item); }
-
-private:
- QList<QGraphicsItem*> m_items;
-};
-
-#endif // QT_NO_GRAPHICSVIEW
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QGRAPHICSSCENELINEARINDEX_H
diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp
deleted file mode 100644
index 488a36af49..0000000000
--- a/src/gui/graphicsview/qgraphicsview.cpp
+++ /dev/null
@@ -1,3880 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-static const int QGRAPHICSVIEW_REGION_RECT_THRESHOLD = 50;
-
-static const int QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS = 503; // largest prime < 2^9
-
-/*!
- \class QGraphicsView
- \brief The QGraphicsView class provides a widget for displaying the
- contents of a QGraphicsScene.
- \since 4.2
- \ingroup graphicsview-api
-
-
- QGraphicsView visualizes the contents of a QGraphicsScene in a scrollable
- viewport. To create a scene with geometrical items, see QGraphicsScene's
- documentation. QGraphicsView is part of the \l{Graphics View Framework}.
-
- To visualize a scene, you start by constructing a QGraphicsView object,
- passing the address of the scene you want to visualize to QGraphicsView's
- constructor. Alternatively, you can call setScene() to set the scene at a
- later point. After you call show(), the view will by default scroll to the
- center of the scene and display any items that are visible at this
- point. For example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp 0
-
- You can explicitly scroll to any position on the scene by using the
- scroll bars, or by calling centerOn(). By passing a point to centerOn(),
- QGraphicsView will scroll its viewport to ensure that the point is
- centered in the view. An overload is provided for scrolling to a
- QGraphicsItem, in which case QGraphicsView will see to that the center of
- the item is centered in the view. If all you want is to ensure that a
- certain area is visible, (but not necessarily centered,) you can call
- ensureVisible() instead.
-
- QGraphicsView can be used to visualize a whole scene, or only parts of it.
- The visualized area is by default detected automatically when the view is
- displayed for the first time (by calling
- QGraphicsScene::itemsBoundingRect()). To set the visualized area rectangle
- yourself, you can call setSceneRect(). This will adjust the scroll bars'
- ranges appropriately. Note that although the scene supports a virtually
- unlimited size, the range of the scroll bars will never exceed the range of
- an integer (INT_MIN, INT_MAX).
-
- QGraphicsView visualizes the scene by calling render(). By default, the
- items are drawn onto the viewport by using a regular QPainter, and using
- default render hints. To change the default render hints that
- QGraphicsView passes to QPainter when painting items, you can call
- setRenderHints().
-
- By default, QGraphicsView provides a regular QWidget for the viewport
- widget. You can access this widget by calling viewport(), or you can
- replace it by calling setViewport(). To render using OpenGL, simply call
- setViewport(new QGLWidget). QGraphicsView takes ownership of the viewport
- widget.
-
- QGraphicsView supports affine transformations, using QTransform. You can
- either pass a matrix to setTransform(), or you can call one of the
- convenience functions rotate(), scale(), translate() or shear(). The most
- two common transformations are scaling, which is used to implement
- zooming, and rotation. QGraphicsView keeps the center of the view fixed
- during a transformation. Because of the scene alignment (setAligment()),
- translating the view will have no visual impact.
-
- You can interact with the items on the scene by using the mouse and
- keyboard. QGraphicsView translates the mouse and key events into \e scene
- events, (events that inherit QGraphicsSceneEvent,), and forward them to
- the visualized scene. In the end, it's the individual item that handles
- the events and reacts to them. For example, if you click on a selectable
- item, the item will typically let the scene know that it has been
- selected, and it will also redraw itself to display a selection
- rectangle. Similiary, if you click and drag the mouse to move a movable
- item, it's the item that handles the mouse moves and moves itself. Item
- interaction is enabled by default, and you can toggle it by calling
- setInteractive().
-
- You can also provide your own custom scene interaction, by creating a
- subclass of QGraphicsView, and reimplementing the mouse and key event
- handlers. To simplify how you programmatically interact with items in the
- view, QGraphicsView provides the mapping functions mapToScene() and
- mapFromScene(), and the item accessors items() and itemAt(). These
- functions allow you to map points, rectangles, polygons and paths between
- view coordinates and scene coordinates, and to find items on the scene
- using view coordinates.
-
- \img graphicsview-view.png
-
- \sa QGraphicsScene, QGraphicsItem, QGraphicsSceneEvent
-*/
-
-/*!
- \enum QGraphicsView::ViewportAnchor
-
- This enums describe the possible anchors that QGraphicsView can
- use when the user resizes the view or when the view is
- transformed.
-
- \value NoAnchor No anchor, i.e. the view leaves the scene's
- position unchanged.
- \value AnchorViewCenter The scene point at the center of the view
- is used as the anchor.
- \value AnchorUnderMouse The point under the mouse is used as the anchor.
-
- \sa resizeAnchor, transformationAnchor
-*/
-
-/*!
- \enum QGraphicsView::ViewportUpdateMode
-
- \since 4.3
-
- This enum describes how QGraphicsView updates its viewport when the scene
- contents change or are exposed.
-
- \value FullViewportUpdate When any visible part of the scene changes or is
- reexposed, QGraphicsView will update the entire viewport. This approach is
- fastest when QGraphicsView spends more time figuring out what to draw than
- it would spend drawing (e.g., when very many small items are repeatedly
- updated). This is the preferred update mode for viewports that do not
- support partial updates, such as QGLWidget, and for viewports that need to
- disable scroll optimization.
-
- \value MinimalViewportUpdate QGraphicsView will determine the minimal
- viewport region that requires a redraw, minimizing the time spent drawing
- by avoiding a redraw of areas that have not changed. This is
- QGraphicsView's default mode. Although this approach provides the best
- performance in general, if there are many small visible changes on the
- scene, QGraphicsView might end up spending more time finding the minimal
- approach than it will spend drawing.
-
- \value SmartViewportUpdate QGraphicsView will attempt to find an optimal
- update mode by analyzing the areas that require a redraw.
-
- \value BoundingRectViewportUpdate The bounding rectangle of all changes in
- the viewport will be redrawn. This mode has the advantage that
- QGraphicsView searches only one region for changes, minimizing time spent
- determining what needs redrawing. The disadvantage is that areas that have
- not changed also need to be redrawn.
-
- \value NoViewportUpdate QGraphicsView will never update its viewport when
- the scene changes; the user is expected to control all updates. This mode
- disables all (potentially slow) item visibility testing in QGraphicsView,
- and is suitable for scenes that either require a fixed frame rate, or where
- the viewport is otherwise updated externally.
-
- \sa viewportUpdateMode
-*/
-
-/*!
- \enum QGraphicsView::OptimizationFlag
-
- \since 4.3
-
- This enum describes flags that you can enable to improve rendering
- performance in QGraphicsView. By default, none of these flags are set.
- Note that setting a flag usually imposes a side effect, and this effect
- can vary between paint devices and platforms.
-
- \value DontClipPainter This value is obsolete and has no effect.
-
- \value DontSavePainterState When rendering, QGraphicsView protects the
- painter state (see QPainter::save()) when rendering the background or
- foreground, and when rendering each item. This allows you to leave the
- painter in an altered state (i.e., you can call QPainter::setPen() or
- QPainter::setBrush() without restoring the state after painting). However,
- if the items consistently do restore the state, you should enable this
- flag to prevent QGraphicsView from doing the same.
-
- \value DontAdjustForAntialiasing Disables QGraphicsView's antialiasing
- auto-adjustment of exposed areas. Items that render antialiased lines on
- the boundaries of their QGraphicsItem::boundingRect() can end up rendering
- parts of the line outside. To prevent rendering artifacts, QGraphicsView
- expands all exposed regions by 2 pixels in all directions. If you enable
- this flag, QGraphicsView will no longer perform these adjustments,
- minimizing the areas that require redrawing, which improves performance. A
- common side effect is that items that do draw with antialiasing can leave
- painting traces behind on the scene as they are moved.
-
- \value IndirectPainting Since Qt 4.6, restore the old painting algorithm
- that calls QGraphicsView::drawItems() and QGraphicsScene::drawItems().
- To be used only for compatibility with old code.
-*/
-
-/*!
- \enum QGraphicsView::CacheModeFlag
-
- This enum describes the flags that you can set for a QGraphicsView's cache
- mode.
-
- \value CacheNone All painting is done directly onto the viewport.
-
- \value CacheBackground The background is cached. This affects both custom
- backgrounds, and backgrounds based on the backgroundBrush property. When
- this flag is enabled, QGraphicsView will allocate one pixmap with the full
- size of the viewport.
-
- \sa cacheMode
-*/
-
-/*!
- \enum QGraphicsView::DragMode
-
- This enum describes the default action for the view when pressing and
- dragging the mouse over the viewport.
-
- \value NoDrag Nothing happens; the mouse event is ignored.
-
- \value ScrollHandDrag The cursor changes into a pointing hand, and
- dragging the mouse around will scroll the scrolbars. This mode works both
- in \l{QGraphicsView::interactive}{interactive} and non-interactive mode.
-
- \value RubberBandDrag A rubber band will appear. Dragging the mouse will
- set the rubber band geometry, and all items covered by the rubber band are
- selected. This mode is disabled for non-interactive views.
-
- \sa dragMode, QGraphicsScene::setSelectionArea()
-*/
-
-#include "qgraphicsview.h"
-#include "qgraphicsview_p.h"
-
-#ifndef QT_NO_GRAPHICSVIEW
-
-#include "qgraphicsitem.h"
-#include "qgraphicsitem_p.h"
-#include "qgraphicsscene.h"
-#include "qgraphicsscene_p.h"
-#include "qgraphicssceneevent.h"
-#include "qgraphicswidget.h"
-
-#include <QtCore/qdatetime.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/qmath.h>
-#include <QtGui/qapplication.h>
-#include <QtGui/qdesktopwidget.h>
-#include <QtGui/qevent.h>
-#include <QtGui/qlayout.h>
-#include <QtGui/qtransform.h>
-#include <QtGui/qmatrix.h>
-#include <QtGui/qpainter.h>
-#include <QtGui/qscrollbar.h>
-#include <QtGui/qstyleoption.h>
-#include <QtGui/qinputcontext.h>
-#ifdef Q_WS_X11
-#include <QtGui/qpaintengine.h>
-#include <private/qt_x11_p.h>
-#endif
-
-#include <private/qevent_p.h>
-
-QT_BEGIN_NAMESPACE
-
-bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event);
-
-inline int q_round_bound(qreal d) //### (int)(qreal) INT_MAX != INT_MAX for single precision
-{
- if (d <= (qreal) INT_MIN)
- return INT_MIN;
- else if (d >= (qreal) INT_MAX)
- return INT_MAX;
- return d >= 0.0 ? int(d + 0.5) : int(d - int(d-1) + 0.5) + int(d-1);
-}
-
-void QGraphicsViewPrivate::translateTouchEvent(QGraphicsViewPrivate *d, QTouchEvent *touchEvent)
-{
- QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();
- for (int i = 0; i < touchPoints.count(); ++i) {
- QTouchEvent::TouchPoint &touchPoint = touchPoints[i];
- // the scene will set the item local pos, startPos, lastPos, and rect before delivering to
- // an item, but for now those functions are returning the view's local coordinates
- touchPoint.setSceneRect(d->mapToScene(touchPoint.rect()));
- touchPoint.setStartScenePos(d->mapToScene(touchPoint.startPos()));
- touchPoint.setLastScenePos(d->mapToScene(touchPoint.lastPos()));
-
- // screenPos, startScreenPos, lastScreenPos, and screenRect are already set
- }
-
- touchEvent->setTouchPoints(touchPoints);
-}
-
-/*!
- \internal
-*/
-QGraphicsViewPrivate::QGraphicsViewPrivate()
- : renderHints(QPainter::TextAntialiasing),
- dragMode(QGraphicsView::NoDrag),
- sceneInteractionAllowed(true), hasSceneRect(false),
- connectedToScene(false),
- useLastMouseEvent(false),
- identityMatrix(true),
- dirtyScroll(true),
- accelerateScrolling(true),
- keepLastCenterPoint(true),
- transforming(false),
- handScrolling(false),
- mustAllocateStyleOptions(false),
- mustResizeBackgroundPixmap(true),
- fullUpdatePending(true),
- hasUpdateClip(false),
- mousePressButton(Qt::NoButton),
- leftIndent(0), topIndent(0),
- lastMouseEvent(QEvent::None, QPoint(), Qt::NoButton, 0, 0),
- alignment(Qt::AlignCenter),
- transformationAnchor(QGraphicsView::AnchorViewCenter), resizeAnchor(QGraphicsView::NoAnchor),
- viewportUpdateMode(QGraphicsView::MinimalViewportUpdate),
- optimizationFlags(0),
- scene(0),
-#ifndef QT_NO_RUBBERBAND
- rubberBanding(false),
- rubberBandSelectionMode(Qt::IntersectsItemShape),
-#endif
- handScrollMotions(0), cacheMode(0),
-#ifndef QT_NO_CURSOR
- hasStoredOriginalCursor(false),
-#endif
- lastDragDropEvent(0),
- updateSceneSlotReimplementedChecked(false)
-{
- styleOptions.reserve(QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS);
-}
-
-/*!
- \internal
-*/
-void QGraphicsViewPrivate::recalculateContentSize()
-{
- Q_Q(QGraphicsView);
-
- QSize maxSize = q->maximumViewportSize();
- int width = maxSize.width();
- int height = maxSize.height();
- QRectF viewRect = matrix.mapRect(q->sceneRect());
-
- bool frameOnlyAround = (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, 0, q));
- if (frameOnlyAround) {
- if (hbarpolicy == Qt::ScrollBarAlwaysOn)
- height -= frameWidth * 2;
- if (vbarpolicy == Qt::ScrollBarAlwaysOn)
- width -= frameWidth * 2;
- }
-
- // Adjust the maximum width and height of the viewport based on the width
- // of visible scroll bars.
- int scrollBarExtent = q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, q);
- if (frameOnlyAround)
- scrollBarExtent += frameWidth * 2;
-
- bool useHorizontalScrollBar = (viewRect.width() > width) && hbarpolicy != Qt::ScrollBarAlwaysOff;
- bool useVerticalScrollBar = (viewRect.height() > height) && vbarpolicy != Qt::ScrollBarAlwaysOff;
- if (useHorizontalScrollBar && !useVerticalScrollBar) {
- if (viewRect.height() > height - scrollBarExtent)
- useVerticalScrollBar = true;
- }
- if (useVerticalScrollBar && !useHorizontalScrollBar) {
- if (viewRect.width() > width - scrollBarExtent)
- useHorizontalScrollBar = true;
- }
- if (useHorizontalScrollBar && hbarpolicy != Qt::ScrollBarAlwaysOn)
- height -= scrollBarExtent;
- if (useVerticalScrollBar && vbarpolicy != Qt::ScrollBarAlwaysOn)
- width -= scrollBarExtent;
-
- // Setting the ranges of these scroll bars can/will cause the values to
- // change, and scrollContentsBy() will be called correspondingly. This
- // will reset the last center point.
- QPointF savedLastCenterPoint = lastCenterPoint;
-
- // Remember the former indent settings
- qreal oldLeftIndent = leftIndent;
- qreal oldTopIndent = topIndent;
-
- // If the whole scene fits horizontally, we center the scene horizontally,
- // and ignore the horizontal scroll bars.
- int left = q_round_bound(viewRect.left());
- int right = q_round_bound(viewRect.right() - width);
- if (left >= right) {
- hbar->setRange(0, 0);
-
- switch (alignment & Qt::AlignHorizontal_Mask) {
- case Qt::AlignLeft:
- leftIndent = -viewRect.left();
- break;
- case Qt::AlignRight:
- leftIndent = width - viewRect.width() - viewRect.left() - 1;
- break;
- case Qt::AlignHCenter:
- default:
- leftIndent = width / 2 - (viewRect.left() + viewRect.right()) / 2;
- break;
- }
- } else {
- hbar->setRange(left, right);
- hbar->setPageStep(width);
- hbar->setSingleStep(width / 20);
- leftIndent = 0;
- }
-
- // If the whole scene fits vertically, we center the scene vertically, and
- // ignore the vertical scroll bars.
- int top = q_round_bound(viewRect.top());
- int bottom = q_round_bound(viewRect.bottom() - height);
- if (top >= bottom) {
- vbar->setRange(0, 0);
-
- switch (alignment & Qt::AlignVertical_Mask) {
- case Qt::AlignTop:
- topIndent = -viewRect.top();
- break;
- case Qt::AlignBottom:
- topIndent = height - viewRect.height() - viewRect.top() - 1;
- break;
- case Qt::AlignVCenter:
- default:
- topIndent = height / 2 - (viewRect.top() + viewRect.bottom()) / 2;
- break;
- }
- } else {
- vbar->setRange(top, bottom);
- vbar->setPageStep(height);
- vbar->setSingleStep(height / 20);
- topIndent = 0;
- }
-
- // Restorethe center point from before the ranges changed.
- lastCenterPoint = savedLastCenterPoint;
-
- // Issue a full update if the indents change.
- // ### If the transform is still the same, we can get away with just a
- // scroll instead.
- if (oldLeftIndent != leftIndent || oldTopIndent != topIndent) {
- dirtyScroll = true;
- updateAll();
- } else if (q->isRightToLeft() && !leftIndent) {
- // In reverse mode, the horizontal scroll always changes after the content
- // size has changed, as the scroll is calculated by summing the min and
- // max values of the range and subtracting the current value. In normal
- // mode the scroll remains unchanged unless the indent has changed.
- dirtyScroll = true;
- }
-
- if (cacheMode & QGraphicsView::CacheBackground) {
- // Invalidate the background pixmap
- mustResizeBackgroundPixmap = true;
- }
-}
-
-/*!
- \internal
-*/
-void QGraphicsViewPrivate::centerView(QGraphicsView::ViewportAnchor anchor)
-{
- Q_Q(QGraphicsView);
- switch (anchor) {
- case QGraphicsView::AnchorUnderMouse: {
- if (q->underMouse()) {
- // Last scene pos: lastMouseMoveScenePoint
- // Current mouse pos:
- QPointF transformationDiff = q->mapToScene(viewport->rect().center())
- - q->mapToScene(viewport->mapFromGlobal(QCursor::pos()));
- q->centerOn(lastMouseMoveScenePoint + transformationDiff);
- } else {
- q->centerOn(lastCenterPoint);
- }
- break;
- }
- case QGraphicsView::AnchorViewCenter:
- q->centerOn(lastCenterPoint);
- break;
- case QGraphicsView::NoAnchor:
- break;
- }
-}
-
-/*!
- \internal
-*/
-void QGraphicsViewPrivate::updateLastCenterPoint()
-{
- Q_Q(QGraphicsView);
- lastCenterPoint = q->mapToScene(viewport->rect().center());
-}
-
-/*!
- \internal
-
- Returns the horizontal scroll value (the X value of the left edge of the
- viewport).
-*/
-qint64 QGraphicsViewPrivate::horizontalScroll() const
-{
- if (dirtyScroll)
- const_cast<QGraphicsViewPrivate *>(this)->updateScroll();
- return scrollX;
-}
-
-/*!
- \internal
-
- Returns the vertical scroll value (the X value of the top edge of the
- viewport).
-*/
-qint64 QGraphicsViewPrivate::verticalScroll() const
-{
- if (dirtyScroll)
- const_cast<QGraphicsViewPrivate *>(this)->updateScroll();
- return scrollY;
-}
-
-/*!
- \internal
-
- Maps the given rectangle to the scene using QTransform::mapRect()
-*/
-QRectF QGraphicsViewPrivate::mapRectToScene(const QRect &rect) const
-{
- if (dirtyScroll)
- const_cast<QGraphicsViewPrivate *>(this)->updateScroll();
- QRectF scrolled = QRectF(rect.translated(scrollX, scrollY));
- return identityMatrix ? scrolled : matrix.inverted().mapRect(scrolled);
-}
-
-
-/*!
- \internal
-
- Maps the given rectangle from the scene using QTransform::mapRect()
-*/
-QRectF QGraphicsViewPrivate::mapRectFromScene(const QRectF &rect) const
-{
- if (dirtyScroll)
- const_cast<QGraphicsViewPrivate *>(this)->updateScroll();
- return (identityMatrix ? rect : matrix.mapRect(rect)).translated(-scrollX, -scrollY);
-}
-
-/*!
- \internal
-*/
-void QGraphicsViewPrivate::updateScroll()
-{
- Q_Q(QGraphicsView);
- scrollX = qint64(-leftIndent);
- if (q->isRightToLeft()) {
- if (!leftIndent) {
- scrollX += hbar->minimum();
- scrollX += hbar->maximum();
- scrollX -= hbar->value();
- }
- } else {
- scrollX += hbar->value();
- }
-
- scrollY = qint64(vbar->value() - topIndent);
-
- dirtyScroll = false;
-}
-
-/*!
- \internal
-*/
-void QGraphicsViewPrivate::replayLastMouseEvent()
-{
- if (!useLastMouseEvent || !scene)
- return;
- mouseMoveEventHandler(&lastMouseEvent);
-}
-
-/*!
- \internal
-*/
-void QGraphicsViewPrivate::storeMouseEvent(QMouseEvent *event)
-{
- useLastMouseEvent = true;
- lastMouseEvent = QMouseEvent(QEvent::MouseMove, event->pos(), event->globalPos(),
- event->button(), event->buttons(), event->modifiers());
-}
-
-void QGraphicsViewPrivate::mouseMoveEventHandler(QMouseEvent *event)
-{
- Q_Q(QGraphicsView);
-
- storeMouseEvent(event);
- lastMouseEvent.setAccepted(false);
-
- if (!sceneInteractionAllowed)
- return;
- if (handScrolling)
- return;
- if (!scene)
- return;
-
- QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseMove);
- mouseEvent.setWidget(viewport);
- mouseEvent.setButtonDownScenePos(mousePressButton, mousePressScenePoint);
- mouseEvent.setButtonDownScreenPos(mousePressButton, mousePressScreenPoint);
- mouseEvent.setScenePos(q->mapToScene(event->pos()));
- mouseEvent.setScreenPos(event->globalPos());
- mouseEvent.setLastScenePos(lastMouseMoveScenePoint);
- mouseEvent.setLastScreenPos(lastMouseMoveScreenPoint);
- mouseEvent.setButtons(event->buttons());
- mouseEvent.setButton(event->button());
- mouseEvent.setModifiers(event->modifiers());
- lastMouseMoveScenePoint = mouseEvent.scenePos();
- lastMouseMoveScreenPoint = mouseEvent.screenPos();
- mouseEvent.setAccepted(false);
- if (event->spontaneous())
- qt_sendSpontaneousEvent(scene, &mouseEvent);
- else
- QApplication::sendEvent(scene, &mouseEvent);
-
- // Remember whether the last event was accepted or not.
- lastMouseEvent.setAccepted(mouseEvent.isAccepted());
-
- if (mouseEvent.isAccepted() && mouseEvent.buttons() != 0) {
- // The event was delivered to a mouse grabber; the press is likely to
- // have set a cursor, and we must not change it.
- return;
- }
-
-#ifndef QT_NO_CURSOR
- // If all the items ignore hover events, we don't look-up any items
- // in QGraphicsScenePrivate::dispatchHoverEvent, hence the
- // cachedItemsUnderMouse list will be empty. We therefore do the look-up
- // for cursor items here if not all items use the default cursor.
- if (scene->d_func()->allItemsIgnoreHoverEvents && !scene->d_func()->allItemsUseDefaultCursor
- && scene->d_func()->cachedItemsUnderMouse.isEmpty()) {
- scene->d_func()->cachedItemsUnderMouse = scene->d_func()->itemsAtPosition(mouseEvent.screenPos(),
- mouseEvent.scenePos(),
- mouseEvent.widget());
- }
- // Find the topmost item under the mouse with a cursor.
- foreach (QGraphicsItem *item, scene->d_func()->cachedItemsUnderMouse) {
- if (item->hasCursor()) {
- _q_setViewportCursor(item->cursor());
- return;
- }
- }
-
- // No items with cursors found; revert to the view cursor.
- if (hasStoredOriginalCursor) {
- // Restore the original viewport cursor.
- hasStoredOriginalCursor = false;
- viewport->setCursor(originalCursor);
- }
-#endif
-}
-
-/*!
- \internal
-*/
-#ifndef QT_NO_RUBBERBAND
-QRegion QGraphicsViewPrivate::rubberBandRegion(const QWidget *widget, const QRect &rect) const
-{
- QStyleHintReturnMask mask;
- QStyleOptionRubberBand option;
- option.initFrom(widget);
- option.rect = rect;
- option.opaque = false;
- option.shape = QRubberBand::Rectangle;
-
- QRegion tmp;
- tmp += rect;
- if (widget->style()->styleHint(QStyle::SH_RubberBand_Mask, &option, widget, &mask))
- tmp &= mask.region;
- return tmp;
-}
-#endif
-
-/*!
- \internal
-*/
-#ifndef QT_NO_CURSOR
-void QGraphicsViewPrivate::_q_setViewportCursor(const QCursor &cursor)
-{
- if (!hasStoredOriginalCursor) {
- hasStoredOriginalCursor = true;
- originalCursor = viewport->cursor();
- }
- viewport->setCursor(cursor);
-}
-#endif
-
-/*!
- \internal
-*/
-#ifndef QT_NO_CURSOR
-void QGraphicsViewPrivate::_q_unsetViewportCursor()
-{
- Q_Q(QGraphicsView);
- foreach (QGraphicsItem *item, q->items(lastMouseEvent.pos())) {
- if (item->hasCursor()) {
- _q_setViewportCursor(item->cursor());
- return;
- }
- }
-
- // Restore the original viewport cursor.
- if (hasStoredOriginalCursor) {
- hasStoredOriginalCursor = false;
- if (dragMode == QGraphicsView::ScrollHandDrag)
- viewport->setCursor(Qt::OpenHandCursor);
- else
- viewport->setCursor(originalCursor);
- }
-}
-#endif
-
-/*!
- \internal
-*/
-void QGraphicsViewPrivate::storeDragDropEvent(const QGraphicsSceneDragDropEvent *event)
-{
- delete lastDragDropEvent;
- lastDragDropEvent = new QGraphicsSceneDragDropEvent(event->type());
- lastDragDropEvent->setScenePos(event->scenePos());
- lastDragDropEvent->setScreenPos(event->screenPos());
- lastDragDropEvent->setButtons(event->buttons());
- lastDragDropEvent->setModifiers(event->modifiers());
- lastDragDropEvent->setPossibleActions(event->possibleActions());
- lastDragDropEvent->setProposedAction(event->proposedAction());
- lastDragDropEvent->setDropAction(event->dropAction());
- lastDragDropEvent->setMimeData(event->mimeData());
- lastDragDropEvent->setWidget(event->widget());
- lastDragDropEvent->setSource(event->source());
-}
-
-/*!
- \internal
-*/
-void QGraphicsViewPrivate::populateSceneDragDropEvent(QGraphicsSceneDragDropEvent *dest,
- QDropEvent *source)
-{
-#ifndef QT_NO_DRAGANDDROP
- Q_Q(QGraphicsView);
- dest->setScenePos(q->mapToScene(source->pos()));
- dest->setScreenPos(q->mapToGlobal(source->pos()));
- dest->setButtons(source->mouseButtons());
- dest->setModifiers(source->keyboardModifiers());
- dest->setPossibleActions(source->possibleActions());
- dest->setProposedAction(source->proposedAction());
- dest->setDropAction(source->dropAction());
- dest->setMimeData(source->mimeData());
- dest->setWidget(viewport);
- dest->setSource(source->source());
-#else
- Q_UNUSED(dest)
- Q_UNUSED(source)
-#endif
-}
-
-/*!
- \internal
-*/
-QRect QGraphicsViewPrivate::mapToViewRect(const QGraphicsItem *item, const QRectF &rect) const
-{
- Q_Q(const QGraphicsView);
- if (dirtyScroll)
- const_cast<QGraphicsViewPrivate *>(this)->updateScroll();
-
- if (item->d_ptr->itemIsUntransformable()) {
- QTransform itv = item->deviceTransform(q->viewportTransform());
- return itv.mapRect(rect).toAlignedRect();
- }
-
- // Translate-only
- // COMBINE
- QPointF offset;
- const QGraphicsItem *parentItem = item;
- const QGraphicsItemPrivate *itemd;
- do {
- itemd = parentItem->d_ptr.data();
- if (itemd->transformData)
- break;
- offset += itemd->pos;
- } while ((parentItem = itemd->parent));
-
- QRectF baseRect = rect.translated(offset.x(), offset.y());
- if (!parentItem) {
- if (identityMatrix) {
- baseRect.translate(-scrollX, -scrollY);
- return baseRect.toAlignedRect();
- }
- return matrix.mapRect(baseRect).translated(-scrollX, -scrollY).toAlignedRect();
- }
-
- QTransform tr = parentItem->sceneTransform();
- if (!identityMatrix)
- tr *= matrix;
- QRectF r = tr.mapRect(baseRect);
- r.translate(-scrollX, -scrollY);
- return r.toAlignedRect();
-}
-
-/*!
- \internal
-*/
-QRegion QGraphicsViewPrivate::mapToViewRegion(const QGraphicsItem *item, const QRectF &rect) const
-{
- Q_Q(const QGraphicsView);
- if (dirtyScroll)
- const_cast<QGraphicsViewPrivate *>(this)->updateScroll();
-
- // Accurate bounding region
- QTransform itv = item->deviceTransform(q->viewportTransform());
- return item->boundingRegion(itv) & itv.mapRect(rect).toAlignedRect();
-}
-
-/*!
- \internal
-*/
-void QGraphicsViewPrivate::processPendingUpdates()
-{
- if (!scene)
- return;
-
- if (fullUpdatePending) {
- viewport->update();
- } else if (viewportUpdateMode == QGraphicsView::BoundingRectViewportUpdate) {
- viewport->update(dirtyBoundingRect);
- } else {
- viewport->update(dirtyRegion); // Already adjusted in updateRect/Region.
- }
-
- dirtyBoundingRect = QRect();
- dirtyRegion = QRegion();
-}
-
-static inline bool intersectsViewport(const QRect &r, int width, int height)
-{ return !(r.left() > width) && !(r.right() < 0) && !(r.top() >= height) && !(r.bottom() < 0); }
-
-static inline bool containsViewport(const QRect &r, int width, int height)
-{ return r.left() <= 0 && r.top() <= 0 && r.right() >= width - 1 && r.bottom() >= height - 1; }
-
-static inline void QRect_unite(QRect *rect, const QRect &other)
-{
- if (rect->isEmpty()) {
- *rect = other;
- } else {
- rect->setCoords(qMin(rect->left(), other.left()), qMin(rect->top(), other.top()),
- qMax(rect->right(), other.right()), qMax(rect->bottom(), other.bottom()));
- }
-}
-
-/*
- Calling this function results in update rects being clipped to the item's
- bounding rect. Note that updates prior to this function call is not clipped.
- The clip is removed by passing 0.
-*/
-void QGraphicsViewPrivate::setUpdateClip(QGraphicsItem *item)
-{
- Q_Q(QGraphicsView);
- // We simply ignore the request if the update mode is either FullViewportUpdate
- // or NoViewportUpdate; in that case there's no point in clipping anything.
- if (!item || viewportUpdateMode == QGraphicsView::NoViewportUpdate
- || viewportUpdateMode == QGraphicsView::FullViewportUpdate) {
- hasUpdateClip = false;
- return;
- }
-
- // Calculate the clip (item's bounding rect in view coordinates).
- // Optimized version of:
- // QRect clip = item->deviceTransform(q->viewportTransform())
- // .mapRect(item->boundingRect()).toAlignedRect();
- QRect clip;
- if (item->d_ptr->itemIsUntransformable()) {
- QTransform xform = item->deviceTransform(q->viewportTransform());
- clip = xform.mapRect(item->boundingRect()).toAlignedRect();
- } else if (item->d_ptr->sceneTransformTranslateOnly && identityMatrix) {
- QRectF r(item->boundingRect());
- r.translate(item->d_ptr->sceneTransform.dx() - horizontalScroll(),
- item->d_ptr->sceneTransform.dy() - verticalScroll());
- clip = r.toAlignedRect();
- } else if (!q->isTransformed()) {
- clip = item->d_ptr->sceneTransform.mapRect(item->boundingRect()).toAlignedRect();
- } else {
- QTransform xform = item->d_ptr->sceneTransform;
- xform *= q->viewportTransform();
- clip = xform.mapRect(item->boundingRect()).toAlignedRect();
- }
-
- if (hasUpdateClip) {
- // Intersect with old clip.
- updateClip &= clip;
- } else {
- updateClip = clip;
- hasUpdateClip = true;
- }
-}
-
-bool QGraphicsViewPrivate::updateRegion(const QRectF &rect, const QTransform &xform)
-{
- if (rect.isEmpty())
- return false;
-
- if (viewportUpdateMode != QGraphicsView::MinimalViewportUpdate
- && viewportUpdateMode != QGraphicsView::SmartViewportUpdate) {
- // No point in updating with QRegion granularity; use the rect instead.
- return updateRectF(xform.mapRect(rect));
- }
-
- // Update mode is either Minimal or Smart, so we have to do a potentially slow operation,
- // which is clearly documented here: QGraphicsItem::setBoundingRegionGranularity.
- const QRegion region = xform.map(QRegion(rect.toAlignedRect()));
- QRect viewRect = region.boundingRect();
- const bool dontAdjustForAntialiasing = optimizationFlags & QGraphicsView::DontAdjustForAntialiasing;
- if (dontAdjustForAntialiasing)
- viewRect.adjust(-1, -1, 1, 1);
- else
- viewRect.adjust(-2, -2, 2, 2);
- if (!intersectsViewport(viewRect, viewport->width(), viewport->height()))
- return false; // Update region for sure outside viewport.
-
- const QVector<QRect> &rects = region.rects();
- for (int i = 0; i < rects.size(); ++i) {
- viewRect = rects.at(i);
- if (dontAdjustForAntialiasing)
- viewRect.adjust(-1, -1, 1, 1);
- else
- viewRect.adjust(-2, -2, 2, 2);
- if (hasUpdateClip)
- viewRect &= updateClip;
- dirtyRegion += viewRect;
- }
-
- return true;
-}
-
-// NB! Assumes the rect 'r' is already aligned and adjusted for antialiasing.
-// For QRectF use updateRectF(const QRectF &) to ensure proper adjustments.
-bool QGraphicsViewPrivate::updateRect(const QRect &r)
-{
- if (fullUpdatePending || viewportUpdateMode == QGraphicsView::NoViewportUpdate
- || !intersectsViewport(r, viewport->width(), viewport->height())) {
- return false;
- }
-
- switch (viewportUpdateMode) {
- case QGraphicsView::FullViewportUpdate:
- fullUpdatePending = true;
- viewport->update();
- break;
- case QGraphicsView::BoundingRectViewportUpdate:
- if (hasUpdateClip)
- QRect_unite(&dirtyBoundingRect, r & updateClip);
- else
- QRect_unite(&dirtyBoundingRect, r);
- if (containsViewport(dirtyBoundingRect, viewport->width(), viewport->height())) {
- fullUpdatePending = true;
- viewport->update();
- }
- break;
- case QGraphicsView::SmartViewportUpdate: // ### DEPRECATE
- case QGraphicsView::MinimalViewportUpdate:
- if (hasUpdateClip)
- dirtyRegion += r & updateClip;
- else
- dirtyRegion += r;
- break;
- default:
- break;
- }
-
- return true;
-}
-
-QStyleOptionGraphicsItem *QGraphicsViewPrivate::allocStyleOptionsArray(int numItems)
-{
- if (mustAllocateStyleOptions || (numItems > styleOptions.capacity()))
- // too many items, let's allocate on-the-fly
- return new QStyleOptionGraphicsItem[numItems];
-
- // expand only whenever necessary
- if (numItems > styleOptions.size())
- styleOptions.resize(numItems);
-
- mustAllocateStyleOptions = true;
- return styleOptions.data();
-}
-
-void QGraphicsViewPrivate::freeStyleOptionsArray(QStyleOptionGraphicsItem *array)
-{
- mustAllocateStyleOptions = false;
- if (array != styleOptions.data())
- delete [] array;
-}
-
-extern QPainterPath qt_regionToPath(const QRegion &region);
-
-/*!
- ### Adjustments in findItems: mapToScene(QRect) forces us to adjust the
- input rectangle by (0, 0, 1, 1), because it uses QRect::bottomRight()
- (etc) when mapping the rectangle to a polygon (which is _wrong_). In
- addition, as QGraphicsItem::boundingRect() is defined in logical space,
- but the default pen for QPainter is cosmetic with a width of 0, QPainter
- is at risk of painting 1 pixel outside the bounding rect. Therefore we
- must search for items with an adjustment of (-1, -1, 1, 1).
-*/
-QList<QGraphicsItem *> QGraphicsViewPrivate::findItems(const QRegion &exposedRegion, bool *allItems,
- const QTransform &viewTransform) const
-{
- Q_Q(const QGraphicsView);
-
- // Step 1) If all items are contained within the expose region, then
- // return a list of all visible items. ### the scene's growing bounding
- // rect does not take into account untransformable items.
- const QRectF exposedRegionSceneBounds = q->mapToScene(exposedRegion.boundingRect().adjusted(-1, -1, 1, 1))
- .boundingRect();
- if (exposedRegionSceneBounds.contains(scene->sceneRect())) {
- Q_ASSERT(allItems);
- *allItems = true;
-
- // All items are guaranteed within the exposed region.
- return scene->items(Qt::AscendingOrder);
- }
-
- // Step 2) If the expose region is a simple rect and the view is only
- // translated or scaled, search for items using
- // QGraphicsScene::items(QRectF).
- bool simpleRectLookup = exposedRegion.rectCount() == 1 && matrix.type() <= QTransform::TxScale;
- if (simpleRectLookup) {
- return scene->items(exposedRegionSceneBounds,
- Qt::IntersectsItemBoundingRect,
- Qt::AscendingOrder, viewTransform);
- }
-
- // If the region is complex or the view has a complex transform, adjust
- // the expose region, convert it to a path, and then search for items
- // using QGraphicsScene::items(QPainterPath);
- QRegion adjustedRegion;
- foreach (const QRect &r, exposedRegion.rects())
- adjustedRegion += r.adjusted(-1, -1, 1, 1);
-
- const QPainterPath exposedScenePath(q->mapToScene(qt_regionToPath(adjustedRegion)));
- return scene->items(exposedScenePath, Qt::IntersectsItemBoundingRect,
- Qt::AscendingOrder, viewTransform);
-}
-
-/*!
- \internal
-
- Enables input methods for the view if and only if the current focus item of
- the scene accepts input methods. Call function whenever that condition has
- potentially changed.
-*/
-void QGraphicsViewPrivate::updateInputMethodSensitivity()
-{
- Q_Q(QGraphicsView);
- QGraphicsItem *focusItem = 0;
- bool enabled = scene && (focusItem = scene->focusItem())
- && (focusItem->d_ptr->flags & QGraphicsItem::ItemAcceptsInputMethod);
- q->setAttribute(Qt::WA_InputMethodEnabled, enabled);
- q->viewport()->setAttribute(Qt::WA_InputMethodEnabled, enabled);
-
- if (!enabled) {
- q->setInputMethodHints(0);
- return;
- }
-
- QGraphicsProxyWidget *proxy = focusItem->d_ptr->isWidget && focusItem->d_ptr->isProxyWidget()
- ? static_cast<QGraphicsProxyWidget *>(focusItem) : 0;
- if (!proxy) {
- q->setInputMethodHints(focusItem->inputMethodHints());
- } else if (QWidget *widget = proxy->widget()) {
- if (QWidget *fw = widget->focusWidget())
- widget = fw;
- q->setInputMethodHints(widget->inputMethodHints());
- } else {
- q->setInputMethodHints(0);
- }
-}
-
-/*!
- Constructs a QGraphicsView. \a parent is passed to QWidget's constructor.
-*/
-QGraphicsView::QGraphicsView(QWidget *parent)
- : QAbstractScrollArea(*new QGraphicsViewPrivate, parent)
-{
- setViewport(0);
- setAcceptDrops(true);
- setBackgroundRole(QPalette::Base);
- // Investigate leaving these disabled by default.
- setAttribute(Qt::WA_InputMethodEnabled);
- viewport()->setAttribute(Qt::WA_InputMethodEnabled);
-}
-
-/*!
- Constructs a QGraphicsView and sets the visualized scene to \a
- scene. \a parent is passed to QWidget's constructor.
-*/
-QGraphicsView::QGraphicsView(QGraphicsScene *scene, QWidget *parent)
- : QAbstractScrollArea(*new QGraphicsViewPrivate, parent)
-{
- setScene(scene);
- setViewport(0);
- setAcceptDrops(true);
- setBackgroundRole(QPalette::Base);
- // Investigate leaving these disabled by default.
- setAttribute(Qt::WA_InputMethodEnabled);
- viewport()->setAttribute(Qt::WA_InputMethodEnabled);
-}
-
-/*!
- \internal
- */
-QGraphicsView::QGraphicsView(QGraphicsViewPrivate &dd, QWidget *parent)
- : QAbstractScrollArea(dd, parent)
-{
- setViewport(0);
- setAcceptDrops(true);
- setBackgroundRole(QPalette::Base);
- // Investigate leaving these disabled by default.
- setAttribute(Qt::WA_InputMethodEnabled);
- viewport()->setAttribute(Qt::WA_InputMethodEnabled);
-}
-
-/*!
- Destructs the QGraphicsView object.
-*/
-QGraphicsView::~QGraphicsView()
-{
- Q_D(QGraphicsView);
- if (d->scene)
- d->scene->d_func()->views.removeAll(this);
- delete d->lastDragDropEvent;
-}
-
-/*!
- \reimp
-*/
-QSize QGraphicsView::sizeHint() const
-{
- Q_D(const QGraphicsView);
- if (d->scene) {
- QSizeF baseSize = d->matrix.mapRect(sceneRect()).size();
- baseSize += QSizeF(d->frameWidth * 2, d->frameWidth * 2);
- return baseSize.boundedTo((3 * QApplication::desktop()->size()) / 4).toSize();
- }
- return QAbstractScrollArea::sizeHint();
-}
-
-/*!
- \property QGraphicsView::renderHints
- \brief the default render hints for the view
-
- These hints are
- used to initialize QPainter before each visible item is drawn. QPainter
- uses render hints to toggle rendering features such as antialiasing and
- smooth pixmap transformation.
-
- QPainter::TextAntialiasing is enabled by default.
-
- Example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp 1
-*/
-QPainter::RenderHints QGraphicsView::renderHints() const
-{
- Q_D(const QGraphicsView);
- return d->renderHints;
-}
-void QGraphicsView::setRenderHints(QPainter::RenderHints hints)
-{
- Q_D(QGraphicsView);
- if (hints == d->renderHints)
- return;
- d->renderHints = hints;
- d->updateAll();
-}
-
-/*!
- If \a enabled is true, the render hint \a hint is enabled; otherwise it
- is disabled.
-
- \sa renderHints
-*/
-void QGraphicsView::setRenderHint(QPainter::RenderHint hint, bool enabled)
-{
- Q_D(QGraphicsView);
- QPainter::RenderHints oldHints = d->renderHints;
- if (enabled)
- d->renderHints |= hint;
- else
- d->renderHints &= ~hint;
- if (oldHints != d->renderHints)
- d->updateAll();
-}
-
-/*!
- \property QGraphicsView::alignment
- \brief the alignment of the scene in the view when the whole
- scene is visible.
-
- If the whole scene is visible in the view, (i.e., there are no visible
- scroll bars,) the view's alignment will decide where the scene will be
- rendered in the view. For example, if the alignment is Qt::AlignCenter,
- which is default, the scene will be centered in the view, and if the
- alignment is (Qt::AlignLeft | Qt::AlignTop), the scene will be rendered in
- the top-left corner of the view.
-*/
-Qt::Alignment QGraphicsView::alignment() const
-{
- Q_D(const QGraphicsView);
- return d->alignment;
-}
-void QGraphicsView::setAlignment(Qt::Alignment alignment)
-{
- Q_D(QGraphicsView);
- if (d->alignment != alignment) {
- d->alignment = alignment;
- d->recalculateContentSize();
- }
-}
-
-/*!
- \property QGraphicsView::transformationAnchor
- \brief how the view should position the scene during transformations.
-
- QGraphicsView uses this property to decide how to position the scene in
- the viewport when the transformation matrix changes, and the coordinate
- system of the view is transformed. The default behavior, AnchorViewCenter,
- ensures that the scene point at the center of the view remains unchanged
- during transformations (e.g., when rotating, the scene will appear to
- rotate around the center of the view).
-
- Note that the effect of this property is noticeable when only a part of the
- scene is visible (i.e., when there are scroll bars). Otherwise, if the
- whole scene fits in the view, QGraphicsScene uses the view \l alignment to
- position the scene in the view.
-
- \sa alignment, resizeAnchor
-*/
-QGraphicsView::ViewportAnchor QGraphicsView::transformationAnchor() const
-{
- Q_D(const QGraphicsView);
- return d->transformationAnchor;
-}
-void QGraphicsView::setTransformationAnchor(ViewportAnchor anchor)
-{
- Q_D(QGraphicsView);
- d->transformationAnchor = anchor;
-
- // Ensure mouse tracking is enabled in the case we are using AnchorUnderMouse
- // in order to have up-to-date information for centering the view.
- if (d->transformationAnchor == AnchorUnderMouse)
- d->viewport->setMouseTracking(true);
-}
-
-/*!
- \property QGraphicsView::resizeAnchor
- \brief how the view should position the scene when the view is resized.
-
- QGraphicsView uses this property to decide how to position the scene in
- the viewport when the viewport widget's size changes. The default
- behavior, NoAnchor, leaves the scene's position unchanged during a resize;
- the top-left corner of the view will appear to be anchored while resizing.
-
- Note that the effect of this property is noticeable when only a part of the
- scene is visible (i.e., when there are scroll bars). Otherwise, if the
- whole scene fits in the view, QGraphicsScene uses the view \l alignment to
- position the scene in the view.
-
- \sa alignment, transformationAnchor, Qt::WNorthWestGravity
-*/
-QGraphicsView::ViewportAnchor QGraphicsView::resizeAnchor() const
-{
- Q_D(const QGraphicsView);
- return d->resizeAnchor;
-}
-void QGraphicsView::setResizeAnchor(ViewportAnchor anchor)
-{
- Q_D(QGraphicsView);
- d->resizeAnchor = anchor;
-
- // Ensure mouse tracking is enabled in the case we are using AnchorUnderMouse
- // in order to have up-to-date information for centering the view.
- if (d->resizeAnchor == AnchorUnderMouse)
- d->viewport->setMouseTracking(true);
-}
-
-/*!
- \property QGraphicsView::viewportUpdateMode
- \brief how the viewport should update its contents.
-
- \since 4.3
-
- QGraphicsView uses this property to decide how to update areas of the
- scene that have been reexposed or changed. Usually you do not need to
- modify this property, but there are some cases where doing so can improve
- rendering performance. See the ViewportUpdateMode documentation for
- specific details.
-
- The default value is MinimalViewportUpdate, where QGraphicsView will
- update as small an area of the viewport as possible when the contents
- change.
-
- \sa ViewportUpdateMode, cacheMode
-*/
-QGraphicsView::ViewportUpdateMode QGraphicsView::viewportUpdateMode() const
-{
- Q_D(const QGraphicsView);
- return d->viewportUpdateMode;
-}
-void QGraphicsView::setViewportUpdateMode(ViewportUpdateMode mode)
-{
- Q_D(QGraphicsView);
- d->viewportUpdateMode = mode;
-}
-
-/*!
- \property QGraphicsView::optimizationFlags
- \brief flags that can be used to tune QGraphicsView's performance.
-
- \since 4.3
-
- QGraphicsView uses clipping, extra bounding rect adjustments, and certain
- other aids to improve rendering quality and performance for the common
- case graphics scene. However, depending on the target platform, the scene,
- and the viewport in use, some of these operations can degrade performance.
-
- The effect varies from flag to flag; see the OptimizationFlags
- documentation for details.
-
- By default, no optimization flags are enabled.
-
- \sa setOptimizationFlag()
-*/
-QGraphicsView::OptimizationFlags QGraphicsView::optimizationFlags() const
-{
- Q_D(const QGraphicsView);
- return d->optimizationFlags;
-}
-void QGraphicsView::setOptimizationFlags(OptimizationFlags flags)
-{
- Q_D(QGraphicsView);
- d->optimizationFlags = flags;
-}
-
-/*!
- Enables \a flag if \a enabled is true; otherwise disables \a flag.
-
- \sa optimizationFlags
-*/
-void QGraphicsView::setOptimizationFlag(OptimizationFlag flag, bool enabled)
-{
- Q_D(QGraphicsView);
- if (enabled)
- d->optimizationFlags |= flag;
- else
- d->optimizationFlags &= ~flag;
-}
-
-/*!
- \property QGraphicsView::dragMode
- \brief the behavior for dragging the mouse over the scene while
- the left mouse button is pressed.
-
- This property defines what should happen when the user clicks on the scene
- background and drags the mouse (e.g., scrolling the viewport contents
- using a pointing hand cursor, or selecting multiple items with a rubber
- band). The default value, NoDrag, does nothing.
-
- This behavior only affects mouse clicks that are not handled by any item.
- You can define a custom behavior by creating a subclass of QGraphicsView
- and reimplementing mouseMoveEvent().
-*/
-QGraphicsView::DragMode QGraphicsView::dragMode() const
-{
- Q_D(const QGraphicsView);
- return d->dragMode;
-}
-void QGraphicsView::setDragMode(DragMode mode)
-{
- Q_D(QGraphicsView);
- if (d->dragMode == mode)
- return;
-
-#ifndef QT_NO_CURSOR
- if (d->dragMode == ScrollHandDrag)
- viewport()->unsetCursor();
-#endif
-
- // If dragMode is unset while dragging, e.g. via a keyEvent, we
- // don't unset the handScrolling state. When enabling scrolling
- // again the mouseMoveEvent will automatically start scrolling,
- // without a mousePress
- if (d->dragMode == ScrollHandDrag && mode == NoDrag && d->handScrolling)
- d->handScrolling = false;
-
- d->dragMode = mode;
-
-#ifndef QT_NO_CURSOR
- if (d->dragMode == ScrollHandDrag) {
- // Forget the stored viewport cursor when we enter scroll hand drag mode.
- d->hasStoredOriginalCursor = false;
- viewport()->setCursor(Qt::OpenHandCursor);
- }
-#endif
-}
-
-#ifndef QT_NO_RUBBERBAND
-/*!
- \property QGraphicsView::rubberBandSelectionMode
- \brief the behavior for selecting items with a rubber band selection rectangle.
- \since 4.3
-
- This property defines how items are selected when using the RubberBandDrag
- drag mode.
-
- The default value is Qt::IntersectsItemShape; all items whose shape
- intersects with or is contained by the rubber band are selected.
-
- \sa dragMode, items()
-*/
-Qt::ItemSelectionMode QGraphicsView::rubberBandSelectionMode() const
-{
- Q_D(const QGraphicsView);
- return d->rubberBandSelectionMode;
-}
-void QGraphicsView::setRubberBandSelectionMode(Qt::ItemSelectionMode mode)
-{
- Q_D(QGraphicsView);
- d->rubberBandSelectionMode = mode;
-}
-#endif
-
-/*!
- \property QGraphicsView::cacheMode
- \brief which parts of the view are cached
-
- QGraphicsView can cache pre-rendered content in a QPixmap, which is then
- drawn onto the viewport. The purpose of such caching is to speed up the
- total rendering time for areas that are slow to render. Texture, gradient
- and alpha blended backgrounds, for example, can be notibly slow to render;
- especially with a transformed view. The CacheBackground flag enables
- caching of the view's background. For example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp 2
-
- The cache is invalidated every time the view is transformed. However, when
- scrolling, only partial invalidation is required.
-
- By default, nothing is cached.
-
- \sa resetCachedContent(), QPixmapCache
-*/
-QGraphicsView::CacheMode QGraphicsView::cacheMode() const
-{
- Q_D(const QGraphicsView);
- return d->cacheMode;
-}
-void QGraphicsView::setCacheMode(CacheMode mode)
-{
- Q_D(QGraphicsView);
- if (mode == d->cacheMode)
- return;
- d->cacheMode = mode;
- resetCachedContent();
-}
-
-/*!
- Resets any cached content. Calling this function will clear
- QGraphicsView's cache. If the current cache mode is \l CacheNone, this
- function does nothing.
-
- This function is called automatically for you when the backgroundBrush or
- QGraphicsScene::backgroundBrush properties change; you only need to call
- this function if you have reimplemented QGraphicsScene::drawBackground()
- or QGraphicsView::drawBackground() to draw a custom background, and need
- to trigger a full redraw.
-
- \sa cacheMode()
-*/
-void QGraphicsView::resetCachedContent()
-{
- Q_D(QGraphicsView);
- if (d->cacheMode == CacheNone)
- return;
-
- if (d->cacheMode & CacheBackground) {
- // Background caching is enabled.
- d->mustResizeBackgroundPixmap = true;
- d->updateAll();
- } else if (d->mustResizeBackgroundPixmap) {
- // Background caching is disabled.
- // Cleanup, free some resources.
- d->mustResizeBackgroundPixmap = false;
- d->backgroundPixmap = QPixmap();
- d->backgroundPixmapExposed = QRegion();
- }
-}
-
-/*!
- Invalidates and schedules a redraw of \a layers inside \a rect. \a rect is
- in scene coordinates. Any cached content for \a layers inside \a rect is
- unconditionally invalidated and redrawn.
-
- You can call this function to notify QGraphicsView of changes to the
- background or the foreground of the scene. It is commonly used for scenes
- with tile-based backgrounds to notify changes when QGraphicsView has
- enabled background caching.
-
- Note that QGraphicsView currently supports background caching only (see
- QGraphicsView::CacheBackground). This function is equivalent to calling update() if any
- layer but QGraphicsScene::BackgroundLayer is passed.
-
- \sa QGraphicsScene::invalidate(), update()
-*/
-void QGraphicsView::invalidateScene(const QRectF &rect, QGraphicsScene::SceneLayers layers)
-{
- Q_D(QGraphicsView);
- if ((layers & QGraphicsScene::BackgroundLayer) && !d->mustResizeBackgroundPixmap) {
- QRect viewRect = mapFromScene(rect).boundingRect();
- if (viewport()->rect().intersects(viewRect)) {
- // The updated background area is exposed; schedule this area for
- // redrawing.
- d->backgroundPixmapExposed += viewRect;
- if (d->scene)
- d->scene->update(rect);
- }
- }
-}
-
-/*!
- \property QGraphicsView::interactive
- \brief whether the view allowed scene interaction.
-
- If enabled, this view is set to allow scene interaction. Otherwise, this
- view will not allow interaction, and any mouse or key events are ignored
- (i.e., it will act as a read-only view).
-
- By default, this property is true.
-*/
-bool QGraphicsView::isInteractive() const
-{
- Q_D(const QGraphicsView);
- return d->sceneInteractionAllowed;
-}
-void QGraphicsView::setInteractive(bool allowed)
-{
- Q_D(QGraphicsView);
- d->sceneInteractionAllowed = allowed;
-}
-
-/*!
- Returns a pointer to the scene that is currently visualized in the
- view. If no scene is currently visualized, 0 is returned.
-
- \sa setScene()
-*/
-QGraphicsScene *QGraphicsView::scene() const
-{
- Q_D(const QGraphicsView);
- return d->scene;
-}
-
-/*!
- Sets the current scene to \a scene. If \a scene is already being
- viewed, this function does nothing.
-
- When a scene is set on a view, the QGraphicsScene::changed() signal
- is automatically connected to this view's updateScene() slot, and the
- view's scroll bars are adjusted to fit the size of the scene.
-*/
-void QGraphicsView::setScene(QGraphicsScene *scene)
-{
- Q_D(QGraphicsView);
- if (d->scene == scene)
- return;
-
- // Always update the viewport when the scene changes.
- d->updateAll();
-
- // Remove the previously assigned scene.
- if (d->scene) {
- disconnect(d->scene, SIGNAL(changed(QList<QRectF>)),
- this, SLOT(updateScene(QList<QRectF>)));
- disconnect(d->scene, SIGNAL(sceneRectChanged(QRectF)),
- this, SLOT(updateSceneRect(QRectF)));
- d->scene->d_func()->removeView(this);
- d->connectedToScene = false;
-
- if (isActiveWindow() && isVisible()) {
- QEvent windowDeactivate(QEvent::WindowDeactivate);
- QApplication::sendEvent(d->scene, &windowDeactivate);
- }
- if(hasFocus())
- d->scene->clearFocus();
- }
-
- // Assign the new scene and update the contents (scrollbars, etc.)).
- if ((d->scene = scene)) {
- connect(d->scene, SIGNAL(sceneRectChanged(QRectF)),
- this, SLOT(updateSceneRect(QRectF)));
- d->updateSceneSlotReimplementedChecked = false;
- d->scene->d_func()->addView(this);
- d->recalculateContentSize();
- d->lastCenterPoint = sceneRect().center();
- d->keepLastCenterPoint = true;
- // We are only interested in mouse tracking if items accept
- // hover events or use non-default cursors.
- if (!d->scene->d_func()->allItemsIgnoreHoverEvents
- || !d->scene->d_func()->allItemsUseDefaultCursor) {
- d->viewport->setMouseTracking(true);
- }
-
- // enable touch events if any items is interested in them
- if (!d->scene->d_func()->allItemsIgnoreTouchEvents)
- d->viewport->setAttribute(Qt::WA_AcceptTouchEvents);
-
- if (isActiveWindow() && isVisible()) {
- QEvent windowActivate(QEvent::WindowActivate);
- QApplication::sendEvent(d->scene, &windowActivate);
- }
- } else {
- d->recalculateContentSize();
- }
-
- d->updateInputMethodSensitivity();
-
- if (d->scene && hasFocus())
- d->scene->setFocus();
-}
-
-/*!
- \property QGraphicsView::sceneRect
- \brief the area of the scene visualized by this view.
-
- The scene rectangle defines the extent of the scene, and in the view's case,
- this means the area of the scene that you can navigate using the scroll
- bars.
-
- If unset, or if a null QRectF is set, this property has the same value as
- QGraphicsScene::sceneRect, and it changes with
- QGraphicsScene::sceneRect. Otherwise, the view's scene rect is unaffected
- by the scene.
-
- Note that, although the scene supports a virtually unlimited size, the
- range of the scroll bars will never exceed the range of an integer
- (INT_MIN, INT_MAX). When the scene is larger than the scroll bars' values,
- you can choose to use translate() to navigate the scene instead.
-
- By default, this property contains a rectangle at the origin with zero
- width and height.
-
- \sa QGraphicsScene::sceneRect
-*/
-QRectF QGraphicsView::sceneRect() const
-{
- Q_D(const QGraphicsView);
- if (d->hasSceneRect)
- return d->sceneRect;
- if (d->scene)
- return d->scene->sceneRect();
- return QRectF();
-}
-void QGraphicsView::setSceneRect(const QRectF &rect)
-{
- Q_D(QGraphicsView);
- d->hasSceneRect = !rect.isNull();
- d->sceneRect = rect;
- d->recalculateContentSize();
-}
-
-/*!
- Returns the current transformation matrix for the view. If no current
- transformation is set, the identity matrix is returned.
-
- \sa setMatrix(), transform(), rotate(), scale(), shear(), translate()
-*/
-QMatrix QGraphicsView::matrix() const
-{
- Q_D(const QGraphicsView);
- return d->matrix.toAffine();
-}
-
-/*!
- Sets the view's current transformation matrix to \a matrix.
-
- If \a combine is true, then \a matrix is combined with the current matrix;
- otherwise, \a matrix \e replaces the current matrix. \a combine is false
- by default.
-
- The transformation matrix tranforms the scene into view coordinates. Using
- the default transformation, provided by the identity matrix, one pixel in
- the view represents one unit in the scene (e.g., a 10x10 rectangular item
- is drawn using 10x10 pixels in the view). If a 2x2 scaling matrix is
- applied, the scene will be drawn in 1:2 (e.g., a 10x10 rectangular item is
- then drawn using 20x20 pixels in the view).
-
- Example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp 3
-
- To simplify interation with items using a transformed view, QGraphicsView
- provides mapTo... and mapFrom... functions that can translate between
- scene and view coordinates. For example, you can call mapToScene() to map
- a view coordinate to a floating point scene coordinate, or mapFromScene()
- to map from floating point scene coordinates to view coordinates.
-
- \sa matrix(), setTransform(), rotate(), scale(), shear(), translate()
-*/
-void QGraphicsView::setMatrix(const QMatrix &matrix, bool combine)
-{
- setTransform(QTransform(matrix), combine);
-}
-
-/*!
- Resets the view transformation matrix to the identity matrix.
-
- \sa resetTransform()
-*/
-void QGraphicsView::resetMatrix()
-{
- resetTransform();
-}
-
-/*!
- Rotates the current view transformation \a angle degrees clockwise.
-
- \sa setTransform(), transform(), scale(), shear(), translate()
-*/
-void QGraphicsView::rotate(qreal angle)
-{
- Q_D(QGraphicsView);
- QTransform matrix = d->matrix;
- matrix.rotate(angle);
- setTransform(matrix);
-}
-
-/*!
- Scales the current view transformation by (\a sx, \a sy).
-
- \sa setTransform(), transform(), rotate(), shear(), translate()
-*/
-void QGraphicsView::scale(qreal sx, qreal sy)
-{
- Q_D(QGraphicsView);
- QTransform matrix = d->matrix;
- matrix.scale(sx, sy);
- setTransform(matrix);
-}
-
-/*!
- Shears the current view transformation by (\a sh, \a sv).
-
- \sa setTransform(), transform(), rotate(), scale(), translate()
-*/
-void QGraphicsView::shear(qreal sh, qreal sv)
-{
- Q_D(QGraphicsView);
- QTransform matrix = d->matrix;
- matrix.shear(sh, sv);
- setTransform(matrix);
-}
-
-/*!
- Translates the current view transformation by (\a dx, \a dy).
-
- \sa setTransform(), transform(), rotate(), shear()
-*/
-void QGraphicsView::translate(qreal dx, qreal dy)
-{
- Q_D(QGraphicsView);
- QTransform matrix = d->matrix;
- matrix.translate(dx, dy);
- setTransform(matrix);
-}
-
-/*!
- Scrolls the contents of the viewport to ensure that the scene
- coordinate \a pos, is centered in the view.
-
- Because \a pos is a floating point coordinate, and the scroll bars operate
- on integer coordinates, the centering is only an approximation.
-
- \note If the item is close to or outside the border, it will be visible
- in the view, but not centered.
-
- \sa ensureVisible()
-*/
-void QGraphicsView::centerOn(const QPointF &pos)
-{
- Q_D(QGraphicsView);
- qreal width = viewport()->width();
- qreal height = viewport()->height();
- QPointF viewPoint = d->matrix.map(pos);
- QPointF oldCenterPoint = pos;
-
- if (!d->leftIndent) {
- if (isRightToLeft()) {
- qint64 horizontal = 0;
- horizontal += horizontalScrollBar()->minimum();
- horizontal += horizontalScrollBar()->maximum();
- horizontal -= int(viewPoint.x() - width / 2.0);
- horizontalScrollBar()->setValue(horizontal);
- } else {
- horizontalScrollBar()->setValue(int(viewPoint.x() - width / 2.0));
- }
- }
- if (!d->topIndent)
- verticalScrollBar()->setValue(int(viewPoint.y() - height / 2.0));
- d->lastCenterPoint = oldCenterPoint;
-}
-
-/*!
- \fn QGraphicsView::centerOn(qreal x, qreal y)
- \overload
-
- This function is provided for convenience. It's equivalent to calling
- centerOn(QPointF(\a x, \a y)).
-*/
-
-/*!
- \overload
-
- Scrolls the contents of the viewport to ensure that \a item
- is centered in the view.
-
- \sa ensureVisible()
-*/
-void QGraphicsView::centerOn(const QGraphicsItem *item)
-{
- centerOn(item->sceneBoundingRect().center());
-}
-
-/*!
- Scrolls the contents of the viewport so that the scene rectangle \a rect
- is visible, with margins specified in pixels by \a xmargin and \a
- ymargin. If the specified rect cannot be reached, the contents are
- scrolled to the nearest valid position. The default value for both margins
- is 50 pixels.
-
- \sa centerOn()
-*/
-void QGraphicsView::ensureVisible(const QRectF &rect, int xmargin, int ymargin)
-{
- Q_D(QGraphicsView);
- qreal width = viewport()->width();
- qreal height = viewport()->height();
- QRectF viewRect = d->matrix.mapRect(rect);
-
- qreal left = d->horizontalScroll();
- qreal right = left + width;
- qreal top = d->verticalScroll();
- qreal bottom = top + height;
-
- if (viewRect.left() <= left + xmargin) {
- // need to scroll from the left
- if (!d->leftIndent)
- horizontalScrollBar()->setValue(int(viewRect.left() - xmargin - 0.5));
- }
- if (viewRect.right() >= right - xmargin) {
- // need to scroll from the right
- if (!d->leftIndent)
- horizontalScrollBar()->setValue(int(viewRect.right() - width + xmargin + 0.5));
- }
- if (viewRect.top() <= top + ymargin) {
- // need to scroll from the top
- if (!d->topIndent)
- verticalScrollBar()->setValue(int(viewRect.top() - ymargin - 0.5));
- }
- if (viewRect.bottom() >= bottom - ymargin) {
- // need to scroll from the bottom
- if (!d->topIndent)
- verticalScrollBar()->setValue(int(viewRect.bottom() - height + ymargin + 0.5));
- }
-}
-
-/*!
- \fn QGraphicsView::ensureVisible(qreal x, qreal y, qreal w, qreal h,
- int xmargin, int ymargin)
- \overload
-
- This function is provided for convenience. It's equivalent to calling
- ensureVisible(QRectF(\a x, \a y, \a w, \a h), \a xmargin, \a ymargin).
-*/
-
-/*!
- \overload
-
- Scrolls the contents of the viewport so that the center of item \a item is
- visible, with margins specified in pixels by \a xmargin and \a ymargin. If
- the specified point cannot be reached, the contents are scrolled to the
- nearest valid position. The default value for both margins is 50 pixels.
-
- \sa centerOn()
-*/
-void QGraphicsView::ensureVisible(const QGraphicsItem *item, int xmargin, int ymargin)
-{
- ensureVisible(item->sceneBoundingRect(), xmargin, ymargin);
-}
-
-/*!
- Scales the view matrix and scrolls the scroll bars to ensure that the
- scene rectangle \a rect fits inside the viewport. \a rect must be inside
- the scene rect; otherwise, fitInView() cannot guarantee that the whole
- rect is visible.
-
- This function keeps the view's rotation, translation, or shear. The view
- is scaled according to \a aspectRatioMode. \a rect will be centered in the
- view if it does not fit tightly.
-
- It's common to call fitInView() from inside a reimplementation of
- resizeEvent(), to ensure that the whole scene, or parts of the scene,
- scales automatically to fit the new size of the viewport as the view is
- resized. Note though, that calling fitInView() from inside resizeEvent()
- can lead to unwanted resize recursion, if the new transformation toggles
- the automatic state of the scrollbars. You can toggle the scrollbar
- policies to always on or always off to prevent this (see
- horizontalScrollBarPolicy() and verticalScrollBarPolicy()).
-
- If \a rect is empty, or if the viewport is too small, this
- function will do nothing.
-
- \sa setTransform(), ensureVisible(), centerOn()
-*/
-void QGraphicsView::fitInView(const QRectF &rect, Qt::AspectRatioMode aspectRatioMode)
-{
- Q_D(QGraphicsView);
- if (!d->scene || rect.isNull())
- return;
-
- // Reset the view scale to 1:1.
- QRectF unity = d->matrix.mapRect(QRectF(0, 0, 1, 1));
- if (unity.isEmpty())
- return;
- scale(1 / unity.width(), 1 / unity.height());
-
- // Find the ideal x / y scaling ratio to fit \a rect in the view.
- int margin = 2;
- QRectF viewRect = viewport()->rect().adjusted(margin, margin, -margin, -margin);
- if (viewRect.isEmpty())
- return;
- QRectF sceneRect = d->matrix.mapRect(rect);
- if (sceneRect.isEmpty())
- return;
- qreal xratio = viewRect.width() / sceneRect.width();
- qreal yratio = viewRect.height() / sceneRect.height();
-
- // Respect the aspect ratio mode.
- switch (aspectRatioMode) {
- case Qt::KeepAspectRatio:
- xratio = yratio = qMin(xratio, yratio);
- break;
- case Qt::KeepAspectRatioByExpanding:
- xratio = yratio = qMax(xratio, yratio);
- break;
- case Qt::IgnoreAspectRatio:
- break;
- }
-
- // Scale and center on the center of \a rect.
- scale(xratio, yratio);
- centerOn(rect.center());
-}
-
-/*!
- \fn void QGraphicsView::fitInView(qreal x, qreal y, qreal w, qreal h,
- Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio)
-
- \overload
-
- This convenience function is equivalent to calling
- fitInView(QRectF(\a x, \a y, \a w, \a h), \a aspectRatioMode).
-
- \sa ensureVisible(), centerOn()
-*/
-
-/*!
- \overload
-
- Ensures that \a item fits tightly inside the view, scaling the view
- according to \a aspectRatioMode.
-
- \sa ensureVisible(), centerOn()
-*/
-void QGraphicsView::fitInView(const QGraphicsItem *item, Qt::AspectRatioMode aspectRatioMode)
-{
- QPainterPath path = item->isClipped() ? item->clipPath() : item->shape();
- if (item->d_ptr->hasTranslateOnlySceneTransform()) {
- path.translate(item->d_ptr->sceneTransform.dx(), item->d_ptr->sceneTransform.dy());
- fitInView(path.boundingRect(), aspectRatioMode);
- } else {
- fitInView(item->d_ptr->sceneTransform.map(path).boundingRect(), aspectRatioMode);
- }
-}
-
-/*!
- Renders the \a source rect, which is in view coordinates, from the scene
- into \a target, which is in paint device coordinates, using \a
- painter. This function is useful for capturing the contents of the view
- onto a paint device, such as a QImage (e.g., to take a screenshot), or for
- printing to QPrinter. For example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp 4
-
- If \a source is a null rect, this function will use viewport()->rect() to
- determine what to draw. If \a target is a null rect, the full dimensions
- of \a painter's paint device (e.g., for a QPrinter, the page size) will be
- used.
-
- The source rect contents will be transformed according to \a
- aspectRatioMode to fit into the target rect. By default, the aspect ratio
- is kept, and \a source is scaled to fit in \a target.
-
- \sa QGraphicsScene::render()
-*/
-void QGraphicsView::render(QPainter *painter, const QRectF &target, const QRect &source,
- Qt::AspectRatioMode aspectRatioMode)
-{
- // ### Switch to using the recursive rendering algorithm instead.
-
- Q_D(QGraphicsView);
- if (!d->scene || !(painter && painter->isActive()))
- return;
-
- // Default source rect = viewport rect
- QRect sourceRect = source;
- if (source.isNull())
- sourceRect = viewport()->rect();
-
- // Default target rect = device rect
- QRectF targetRect = target;
- if (target.isNull()) {
- if (painter->device()->devType() == QInternal::Picture)
- targetRect = sourceRect;
- else
- targetRect.setRect(0, 0, painter->device()->width(), painter->device()->height());
- }
-
- // Find the ideal x / y scaling ratio to fit \a source into \a target.
- qreal xratio = targetRect.width() / sourceRect.width();
- qreal yratio = targetRect.height() / sourceRect.height();
-
- // Scale according to the aspect ratio mode.
- switch (aspectRatioMode) {
- case Qt::KeepAspectRatio:
- xratio = yratio = qMin(xratio, yratio);
- break;
- case Qt::KeepAspectRatioByExpanding:
- xratio = yratio = qMax(xratio, yratio);
- break;
- case Qt::IgnoreAspectRatio:
- break;
- }
-
- // Find all items to draw, and reverse the list (we want to draw
- // in reverse order).
- QPolygonF sourceScenePoly = mapToScene(sourceRect.adjusted(-1, -1, 1, 1));
- QList<QGraphicsItem *> itemList = d->scene->items(sourceScenePoly,
- Qt::IntersectsItemBoundingRect);
- QGraphicsItem **itemArray = new QGraphicsItem *[itemList.size()];
- int numItems = itemList.size();
- for (int i = 0; i < numItems; ++i)
- itemArray[numItems - i - 1] = itemList.at(i);
- itemList.clear();
-
- // Setup painter matrix.
- QTransform moveMatrix = QTransform::fromTranslate(-d->horizontalScroll(), -d->verticalScroll());
- QTransform painterMatrix = d->matrix * moveMatrix;
- painterMatrix *= QTransform()
- .translate(targetRect.left(), targetRect.top())
- .scale(xratio, yratio)
- .translate(-sourceRect.left(), -sourceRect.top());
-
- // Generate the style options
- QStyleOptionGraphicsItem *styleOptionArray = d->allocStyleOptionsArray(numItems);
- for (int i = 0; i < numItems; ++i)
- itemArray[i]->d_ptr->initStyleOption(&styleOptionArray[i], painterMatrix, targetRect.toRect());
-
- painter->save();
-
- // Clip in device coordinates to avoid QRegion transformations.
- painter->setClipRect(targetRect);
- QPainterPath path;
- path.addPolygon(sourceScenePoly);
- path.closeSubpath();
- painter->setClipPath(painterMatrix.map(path), Qt::IntersectClip);
-
- // Transform the painter.
- painter->setTransform(painterMatrix, true);
-
- // Render the scene.
- QRectF sourceSceneRect = sourceScenePoly.boundingRect();
- drawBackground(painter, sourceSceneRect);
- drawItems(painter, numItems, itemArray, styleOptionArray);
- drawForeground(painter, sourceSceneRect);
-
- delete [] itemArray;
- d->freeStyleOptionsArray(styleOptionArray);
-
- painter->restore();
-}
-
-/*!
- Returns a list of all the items in the associated scene, in descending
- stacking order (i.e., the first item in the returned list is the uppermost
- item).
-
- \sa QGraphicsScene::items(), {QGraphicsItem#Sorting}{Sorting}
-*/
-QList<QGraphicsItem *> QGraphicsView::items() const
-{
- Q_D(const QGraphicsView);
- if (!d->scene)
- return QList<QGraphicsItem *>();
- return d->scene->items();
-}
-
-/*!
- Returns a list of all the items at the position \a pos in the view. The
- items are listed in descending stacking order (i.e., the first item in the
- list is the uppermost item, and the last item is the lowermost item). \a
- pos is in viewport coordinates.
-
- This function is most commonly called from within mouse event handlers in
- a subclass in QGraphicsView. \a pos is in untransformed viewport
- coordinates, just like QMouseEvent::pos().
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp 5
-
- \sa QGraphicsScene::items(), {QGraphicsItem#Sorting}{Sorting}
-*/
-QList<QGraphicsItem *> QGraphicsView::items(const QPoint &pos) const
-{
- Q_D(const QGraphicsView);
- if (!d->scene)
- return QList<QGraphicsItem *>();
- // ### Unify these two, and use the items(QPointF) version in
- // QGraphicsScene instead. The scene items function could use the viewport
- // transform to map the point to a rect/polygon.
- if ((d->identityMatrix || d->matrix.type() <= QTransform::TxScale)) {
- // Use the rect version
- QTransform xinv = viewportTransform().inverted();
- return d->scene->items(xinv.mapRect(QRectF(pos.x(), pos.y(), 1, 1)),
- Qt::IntersectsItemShape,
- Qt::DescendingOrder,
- viewportTransform());
- }
- // Use the polygon version
- return d->scene->items(mapToScene(pos.x(), pos.y(), 1, 1),
- Qt::IntersectsItemShape,
- Qt::DescendingOrder,
- viewportTransform());
-}
-
-/*!
- \fn QGraphicsView::items(int x, int y) const
-
- This function is provided for convenience. It's equivalent to calling
- items(QPoint(\a x, \a y)).
-*/
-
-/*!
- \overload
-
- Returns a list of all the items that, depending on \a mode, are either
- contained by or intersect with \a rect. \a rect is in viewport
- coordinates.
-
- The default value for \a mode is Qt::IntersectsItemShape; all items whose
- exact shape intersects with or is contained by \a rect are returned.
-
- The items are sorted in descending stacking order (i.e., the first item in
- the returned list is the uppermost item).
-
- \sa itemAt(), items(), mapToScene(), {QGraphicsItem#Sorting}{Sorting}
-*/
-QList<QGraphicsItem *> QGraphicsView::items(const QRect &rect, Qt::ItemSelectionMode mode) const
-{
- Q_D(const QGraphicsView);
- if (!d->scene)
- return QList<QGraphicsItem *>();
- return d->scene->items(mapToScene(rect), mode, Qt::DescendingOrder, viewportTransform());
-}
-
-/*!
- \fn QList<QGraphicsItem *> QGraphicsView::items(int x, int y, int w, int h, Qt::ItemSelectionMode mode) const
- \since 4.3
-
- This convenience function is equivalent to calling items(QRectF(\a x, \a
- y, \a w, \a h), \a mode).
-*/
-
-/*!
- \overload
-
- Returns a list of all the items that, depending on \a mode, are either
- contained by or intersect with \a polygon. \a polygon is in viewport
- coordinates.
-
- The default value for \a mode is Qt::IntersectsItemShape; all items whose
- exact shape intersects with or is contained by \a polygon are returned.
-
- The items are sorted by descending stacking order (i.e., the first item in
- the returned list is the uppermost item).
-
- \sa itemAt(), items(), mapToScene(), {QGraphicsItem#Sorting}{Sorting}
-*/
-QList<QGraphicsItem *> QGraphicsView::items(const QPolygon &polygon, Qt::ItemSelectionMode mode) const
-{
- Q_D(const QGraphicsView);
- if (!d->scene)
- return QList<QGraphicsItem *>();
- return d->scene->items(mapToScene(polygon), mode, Qt::DescendingOrder, viewportTransform());
-}
-
-/*!
- \overload
-
- Returns a list of all the items that, depending on \a mode, are either
- contained by or intersect with \a path. \a path is in viewport
- coordinates.
-
- The default value for \a mode is Qt::IntersectsItemShape; all items whose
- exact shape intersects with or is contained by \a path are returned.
-
- \sa itemAt(), items(), mapToScene(), {QGraphicsItem#Sorting}{Sorting}
-*/
-QList<QGraphicsItem *> QGraphicsView::items(const QPainterPath &path, Qt::ItemSelectionMode mode) const
-{
- Q_D(const QGraphicsView);
- if (!d->scene)
- return QList<QGraphicsItem *>();
- return d->scene->items(mapToScene(path), mode, Qt::DescendingOrder, viewportTransform());
-}
-
-/*!
- Returns the item at position \a pos, which is in viewport coordinates.
- If there are several items at this position, this function returns
- the topmost item.
-
- Example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp 6
-
- \sa items(), {QGraphicsItem#Sorting}{Sorting}
-*/
-QGraphicsItem *QGraphicsView::itemAt(const QPoint &pos) const
-{
- Q_D(const QGraphicsView);
- if (!d->scene)
- return 0;
- QList<QGraphicsItem *> itemsAtPos = items(pos);
- return itemsAtPos.isEmpty() ? 0 : itemsAtPos.first();
-}
-
-/*!
- \overload
- \fn QGraphicsItem *QGraphicsView::itemAt(int x, int y) const
-
- This function is provided for convenience. It's equivalent to
- calling itemAt(QPoint(\a x, \a y)).
-*/
-
-/*!
- Returns the viewport coordinate \a point mapped to scene coordinates.
-
- Note: It can be useful to map the whole rectangle covered by the pixel at
- \a point instead of the point itself. To do this, you can call
- mapToScene(QRect(\a point, QSize(2, 2))).
-
- \sa mapFromScene()
-*/
-QPointF QGraphicsView::mapToScene(const QPoint &point) const
-{
- Q_D(const QGraphicsView);
- QPointF p = point;
- p.rx() += d->horizontalScroll();
- p.ry() += d->verticalScroll();
- return d->identityMatrix ? p : d->matrix.inverted().map(p);
-}
-
-/*!
- \fn QGraphicsView::mapToScene(int x, int y) const
-
- This function is provided for convenience. It's equivalent to calling
- mapToScene(QPoint(\a x, \a y)).
-*/
-
-/*!
- Returns the viewport rectangle \a rect mapped to a scene coordinate
- polygon.
-
- \sa mapFromScene()
-*/
-QPolygonF QGraphicsView::mapToScene(const QRect &rect) const
-{
- Q_D(const QGraphicsView);
- if (!rect.isValid())
- return QPolygonF();
-
- QPointF scrollOffset(d->horizontalScroll(), d->verticalScroll());
- QRect r = rect.adjusted(0, 0, 1, 1);
- QPointF tl = scrollOffset + r.topLeft();
- QPointF tr = scrollOffset + r.topRight();
- QPointF br = scrollOffset + r.bottomRight();
- QPointF bl = scrollOffset + r.bottomLeft();
-
- QPolygonF poly(4);
- if (!d->identityMatrix) {
- QTransform x = d->matrix.inverted();
- poly[0] = x.map(tl);
- poly[1] = x.map(tr);
- poly[2] = x.map(br);
- poly[3] = x.map(bl);
- } else {
- poly[0] = tl;
- poly[1] = tr;
- poly[2] = br;
- poly[3] = bl;
- }
- return poly;
-}
-
-/*!
- \fn QGraphicsView::mapToScene(int x, int y, int w, int h) const
-
- This function is provided for convenience. It's equivalent to calling
- mapToScene(QRect(\a x, \a y, \a w, \a h)).
-*/
-
-/*!
- Returns the viewport polygon \a polygon mapped to a scene coordinate
- polygon.
-
- \sa mapFromScene()
-*/
-QPolygonF QGraphicsView::mapToScene(const QPolygon &polygon) const
-{
- QPolygonF poly;
- foreach (const QPoint &point, polygon)
- poly << mapToScene(point);
- return poly;
-}
-
-/*!
- Returns the viewport painter path \a path mapped to a scene coordinate
- painter path.
-
- \sa mapFromScene()
-*/
-QPainterPath QGraphicsView::mapToScene(const QPainterPath &path) const
-{
- Q_D(const QGraphicsView);
- QTransform matrix = QTransform::fromTranslate(d->horizontalScroll(), d->verticalScroll());
- matrix *= d->matrix.inverted();
- return matrix.map(path);
-}
-
-/*!
- Returns the scene coordinate \a point to viewport coordinates.
-
- \sa mapToScene()
-*/
-QPoint QGraphicsView::mapFromScene(const QPointF &point) const
-{
- Q_D(const QGraphicsView);
- QPointF p = d->identityMatrix ? point : d->matrix.map(point);
- p.rx() -= d->horizontalScroll();
- p.ry() -= d->verticalScroll();
- return p.toPoint();
-}
-
-/*!
- \fn QGraphicsView::mapFromScene(qreal x, qreal y) const
-
- This function is provided for convenience. It's equivalent to
- calling mapFromScene(QPointF(\a x, \a y)).
-*/
-
-/*!
- Returns the scene rectangle \a rect to a viewport coordinate
- polygon.
-
- \sa mapToScene()
-*/
-QPolygon QGraphicsView::mapFromScene(const QRectF &rect) const
-{
- Q_D(const QGraphicsView);
- QPointF tl;
- QPointF tr;
- QPointF br;
- QPointF bl;
- if (!d->identityMatrix) {
- const QTransform &x = d->matrix;
- tl = x.map(rect.topLeft());
- tr = x.map(rect.topRight());
- br = x.map(rect.bottomRight());
- bl = x.map(rect.bottomLeft());
- } else {
- tl = rect.topLeft();
- tr = rect.topRight();
- br = rect.bottomRight();
- bl = rect.bottomLeft();
- }
- QPointF scrollOffset(d->horizontalScroll(), d->verticalScroll());
- tl -= scrollOffset;
- tr -= scrollOffset;
- br -= scrollOffset;
- bl -= scrollOffset;
-
- QPolygon poly(4);
- poly[0] = tl.toPoint();
- poly[1] = tr.toPoint();
- poly[2] = br.toPoint();
- poly[3] = bl.toPoint();
- return poly;
-}
-
-/*!
- \fn QGraphicsView::mapFromScene(qreal x, qreal y, qreal w, qreal h) const
-
- This function is provided for convenience. It's equivalent to
- calling mapFromScene(QRectF(\a x, \a y, \a w, \a h)).
-*/
-
-/*!
- Returns the scene coordinate polygon \a polygon to a viewport coordinate
- polygon.
-
- \sa mapToScene()
-*/
-QPolygon QGraphicsView::mapFromScene(const QPolygonF &polygon) const
-{
- QPolygon poly;
- foreach (const QPointF &point, polygon)
- poly << mapFromScene(point);
- return poly;
-}
-
-/*!
- Returns the scene coordinate painter path \a path to a viewport coordinate
- painter path.
-
- \sa mapToScene()
-*/
-QPainterPath QGraphicsView::mapFromScene(const QPainterPath &path) const
-{
- Q_D(const QGraphicsView);
- QTransform matrix = d->matrix;
- matrix *= QTransform::fromTranslate(-d->horizontalScroll(), -d->verticalScroll());
- return matrix.map(path);
-}
-
-/*!
- \reimp
-*/
-QVariant QGraphicsView::inputMethodQuery(Qt::InputMethodQuery query) const
-{
- Q_D(const QGraphicsView);
- if (!d->scene)
- return QVariant();
-
- QVariant value = d->scene->inputMethodQuery(query);
- if (value.type() == QVariant::RectF)
- value = d->mapRectFromScene(value.toRectF());
- else if (value.type() == QVariant::PointF)
- value = mapFromScene(value.toPointF());
- else if (value.type() == QVariant::Rect)
- value = d->mapRectFromScene(value.toRect()).toRect();
- else if (value.type() == QVariant::Point)
- value = mapFromScene(value.toPoint());
- return value;
-}
-
-/*!
- \property QGraphicsView::backgroundBrush
- \brief the background brush of the scene.
-
- This property sets the background brush for the scene in this view. It is
- used to override the scene's own background, and defines the behavior of
- drawBackground(). To provide custom background drawing for this view, you
- can reimplement drawBackground() instead.
-
- By default, this property contains a brush with the Qt::NoBrush pattern.
-
- \sa QGraphicsScene::backgroundBrush, foregroundBrush
-*/
-QBrush QGraphicsView::backgroundBrush() const
-{
- Q_D(const QGraphicsView);
- return d->backgroundBrush;
-}
-void QGraphicsView::setBackgroundBrush(const QBrush &brush)
-{
- Q_D(QGraphicsView);
- d->backgroundBrush = brush;
- d->updateAll();
-
- if (d->cacheMode & CacheBackground) {
- // Invalidate the background pixmap
- d->mustResizeBackgroundPixmap = true;
- }
-}
-
-/*!
- \property QGraphicsView::foregroundBrush
- \brief the foreground brush of the scene.
-
- This property sets the foreground brush for the scene in this view. It is
- used to override the scene's own foreground, and defines the behavior of
- drawForeground(). To provide custom foreground drawing for this view, you
- can reimplement drawForeground() instead.
-
- By default, this property contains a brush with the Qt::NoBrush pattern.
-
- \sa QGraphicsScene::foregroundBrush, backgroundBrush
-*/
-QBrush QGraphicsView::foregroundBrush() const
-{
- Q_D(const QGraphicsView);
- return d->foregroundBrush;
-}
-void QGraphicsView::setForegroundBrush(const QBrush &brush)
-{
- Q_D(QGraphicsView);
- d->foregroundBrush = brush;
- d->updateAll();
-}
-
-/*!
- Schedules an update of the scene rectangles \a rects.
-
- \sa QGraphicsScene::changed()
-*/
-void QGraphicsView::updateScene(const QList<QRectF> &rects)
-{
- // ### Note: Since 4.5, this slot is only called if the user explicitly
- // establishes a connection between the scene and the view, as the scene
- // and view are no longer connected. We need to keep it working (basically
- // leave it as it is), but the new delivery path is through
- // QGraphicsScenePrivate::itemUpdate().
- Q_D(QGraphicsView);
- if (d->fullUpdatePending || d->viewportUpdateMode == QGraphicsView::NoViewportUpdate)
- return;
-
- // Extract and reset dirty scene rect info.
- QVector<QRect> dirtyViewportRects;
- const QVector<QRect> &dirtyRects = d->dirtyRegion.rects();
- for (int i = 0; i < dirtyRects.size(); ++i)
- dirtyViewportRects += dirtyRects.at(i);
- d->dirtyRegion = QRegion();
- d->dirtyBoundingRect = QRect();
-
- bool fullUpdate = !d->accelerateScrolling || d->viewportUpdateMode == QGraphicsView::FullViewportUpdate;
- bool boundingRectUpdate = (d->viewportUpdateMode == QGraphicsView::BoundingRectViewportUpdate)
- || (d->viewportUpdateMode == QGraphicsView::SmartViewportUpdate
- && ((dirtyViewportRects.size() + rects.size()) >= QGRAPHICSVIEW_REGION_RECT_THRESHOLD));
-
- QRegion updateRegion;
- QRect boundingRect;
- QRect viewportRect = viewport()->rect();
- bool redraw = false;
- QTransform transform = viewportTransform();
-
- // Convert scene rects to viewport rects.
- foreach (const QRectF &rect, rects) {
- QRect xrect = transform.mapRect(rect).toAlignedRect();
- if (!(d->optimizationFlags & DontAdjustForAntialiasing))
- xrect.adjust(-2, -2, 2, 2);
- else
- xrect.adjust(-1, -1, 1, 1);
- if (!viewportRect.intersects(xrect))
- continue;
- dirtyViewportRects << xrect;
- }
-
- foreach (const QRect &rect, dirtyViewportRects) {
- // Add the exposed rect to the update region. In rect update
- // mode, we only count the bounding rect of items.
- if (!boundingRectUpdate) {
- updateRegion += rect;
- } else {
- boundingRect |= rect;
- }
- redraw = true;
- if (fullUpdate) {
- // If fullUpdate is true and we found a visible dirty rect,
- // we're done.
- break;
- }
- }
-
- if (!redraw)
- return;
-
- if (fullUpdate)
- viewport()->update();
- else if (boundingRectUpdate)
- viewport()->update(boundingRect);
- else
- viewport()->update(updateRegion);
-}
-
-/*!
- Notifies QGraphicsView that the scene's scene rect has changed. \a rect
- is the new scene rect. If the view already has an explicitly set scene
- rect, this function does nothing.
-
- \sa sceneRect, QGraphicsScene::sceneRectChanged()
-*/
-void QGraphicsView::updateSceneRect(const QRectF &rect)
-{
- Q_D(QGraphicsView);
- if (!d->hasSceneRect) {
- d->sceneRect = rect;
- d->recalculateContentSize();
- }
-}
-
-/*!
- This slot is called by QAbstractScrollArea after setViewport() has been
- called. Reimplement this function in a subclass of QGraphicsView to
- initialize the new viewport \a widget before it is used.
-
- \sa setViewport()
-*/
-void QGraphicsView::setupViewport(QWidget *widget)
-{
- Q_D(QGraphicsView);
-
- if (!widget) {
- qWarning("QGraphicsView::setupViewport: cannot initialize null widget");
- return;
- }
-
- const bool isGLWidget = widget->inherits("QGLWidget");
-
- d->accelerateScrolling = !(isGLWidget);
-
- widget->setFocusPolicy(Qt::StrongFocus);
-
- if (!isGLWidget) {
- // autoFillBackground enables scroll acceleration.
- widget->setAutoFillBackground(true);
- }
-
- // We are only interested in mouse tracking if items
- // accept hover events or use non-default cursors or if
- // AnchorUnderMouse is used as transformation or resize anchor.
- if ((d->scene && (!d->scene->d_func()->allItemsIgnoreHoverEvents
- || !d->scene->d_func()->allItemsUseDefaultCursor))
- || d->transformationAnchor == AnchorUnderMouse
- || d->resizeAnchor == AnchorUnderMouse) {
- widget->setMouseTracking(true);
- }
-
- // enable touch events if any items is interested in them
- if (d->scene && !d->scene->d_func()->allItemsIgnoreTouchEvents)
- widget->setAttribute(Qt::WA_AcceptTouchEvents);
-
-#ifndef QT_NO_GESTURES
- if (d->scene) {
- foreach (Qt::GestureType gesture, d->scene->d_func()->grabbedGestures.keys())
- widget->grabGesture(gesture);
- }
-#endif
-
- widget->setAcceptDrops(acceptDrops());
-}
-
-/*!
- \reimp
-*/
-bool QGraphicsView::event(QEvent *event)
-{
- Q_D(QGraphicsView);
-
- if (d->sceneInteractionAllowed) {
- switch (event->type()) {
- case QEvent::ShortcutOverride:
- if (d->scene)
- return QApplication::sendEvent(d->scene, event);
- break;
- case QEvent::KeyPress:
- if (d->scene) {
- QKeyEvent *k = static_cast<QKeyEvent *>(event);
- if (k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) {
- // Send the key events to the scene. This will invoke the
- // scene's tab focus handling, and if the event is
- // accepted, we return (prevent further event delivery),
- // and the base implementation will call QGraphicsView's
- // focusNextPrevChild() function. If the event is ignored,
- // we fall back to standard tab focus handling.
- QApplication::sendEvent(d->scene, event);
- if (event->isAccepted())
- return true;
- // Ensure the event doesn't propagate just because the
- // scene ignored it. If the event propagates, then tab
- // handling will be called twice (this and parent).
- event->accept();
- }
- }
- break;
- default:
- break;
- }
- }
-
- return QAbstractScrollArea::event(event);
-}
-
-/*!
- \reimp
-*/
-bool QGraphicsView::viewportEvent(QEvent *event)
-{
- Q_D(QGraphicsView);
- if (!d->scene)
- return QAbstractScrollArea::viewportEvent(event);
-
- switch (event->type()) {
- case QEvent::Enter:
- QApplication::sendEvent(d->scene, event);
- break;
- case QEvent::WindowActivate:
- QApplication::sendEvent(d->scene, event);
- break;
- case QEvent::WindowDeactivate:
- // ### This is a temporary fix for until we get proper mouse
- // grab events. mouseGrabberItem should be set to 0 if we lose
- // the mouse grab.
- // Remove all popups when the scene loses focus.
- if (!d->scene->d_func()->popupWidgets.isEmpty())
- d->scene->d_func()->removePopup(d->scene->d_func()->popupWidgets.first());
- QApplication::sendEvent(d->scene, event);
- break;
- case QEvent::Show:
- if (d->scene && isActiveWindow()) {
- QEvent windowActivate(QEvent::WindowActivate);
- QApplication::sendEvent(d->scene, &windowActivate);
- }
- break;
- case QEvent::Hide:
- // spontaneous event will generate a WindowDeactivate.
- if (!event->spontaneous() && d->scene && isActiveWindow()) {
- QEvent windowDeactivate(QEvent::WindowDeactivate);
- QApplication::sendEvent(d->scene, &windowDeactivate);
- }
- break;
- case QEvent::Leave:
- // ### This is a temporary fix for until we get proper mouse grab
- // events. activeMouseGrabberItem should be set to 0 if we lose the
- // mouse grab.
- if ((QApplication::activePopupWidget() && QApplication::activePopupWidget() != window())
- || (QApplication::activeModalWidget() && QApplication::activeModalWidget() != window())
- || (QApplication::activeWindow() != window())) {
- if (!d->scene->d_func()->popupWidgets.isEmpty())
- d->scene->d_func()->removePopup(d->scene->d_func()->popupWidgets.first());
- }
- d->useLastMouseEvent = false;
- // a hack to pass a viewport pointer to the scene inside the leave event
- Q_ASSERT(event->d == 0);
- event->d = reinterpret_cast<QEventPrivate *>(viewport());
- QApplication::sendEvent(d->scene, event);
- break;
-#ifndef QT_NO_TOOLTIP
- case QEvent::ToolTip: {
- QHelpEvent *toolTip = static_cast<QHelpEvent *>(event);
- QGraphicsSceneHelpEvent helpEvent(QEvent::GraphicsSceneHelp);
- helpEvent.setWidget(viewport());
- helpEvent.setScreenPos(toolTip->globalPos());
- helpEvent.setScenePos(mapToScene(toolTip->pos()));
- QApplication::sendEvent(d->scene, &helpEvent);
- toolTip->setAccepted(helpEvent.isAccepted());
- return true;
- }
-#endif
- case QEvent::Paint:
- // Reset full update
- d->fullUpdatePending = false;
- d->dirtyScrollOffset = QPoint();
- if (d->scene) {
- // Check if this view reimplements the updateScene slot; if it
- // does, we can't do direct update delivery and have to fall back
- // to connecting the changed signal.
- if (!d->updateSceneSlotReimplementedChecked) {
- d->updateSceneSlotReimplementedChecked = true;
- const QMetaObject *mo = metaObject();
- if (mo != &QGraphicsView::staticMetaObject) {
- if (mo->indexOfSlot("updateScene(QList<QRectF>)")
- != QGraphicsView::staticMetaObject.indexOfSlot("updateScene(QList<QRectF>)")) {
- connect(d->scene, SIGNAL(changed(QList<QRectF>)),
- this, SLOT(updateScene(QList<QRectF>)));
- }
- }
- }
- }
- break;
- case QEvent::TouchBegin:
- case QEvent::TouchUpdate:
- case QEvent::TouchEnd:
- {
- if (!isEnabled())
- return false;
-
- if (d->scene && d->sceneInteractionAllowed) {
- // Convert and deliver the touch event to the scene.
- QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);
- touchEvent->setWidget(viewport());
- QGraphicsViewPrivate::translateTouchEvent(d, touchEvent);
- (void) QApplication::sendEvent(d->scene, touchEvent);
- }
-
- return true;
- }
-#ifndef QT_NO_GESTURES
- case QEvent::Gesture:
- case QEvent::GestureOverride:
- {
- if (!isEnabled())
- return false;
-
- if (d->scene && d->sceneInteractionAllowed) {
- QGestureEvent *gestureEvent = static_cast<QGestureEvent *>(event);
- gestureEvent->setWidget(viewport());
- (void) QApplication::sendEvent(d->scene, gestureEvent);
- }
- return true;
- }
-#endif // QT_NO_GESTURES
- default:
- break;
- }
-
- return QAbstractScrollArea::viewportEvent(event);
-}
-
-#ifndef QT_NO_CONTEXTMENU
-/*!
- \reimp
-*/
-void QGraphicsView::contextMenuEvent(QContextMenuEvent *event)
-{
- Q_D(QGraphicsView);
- if (!d->scene || !d->sceneInteractionAllowed)
- return;
-
- d->mousePressViewPoint = event->pos();
- d->mousePressScenePoint = mapToScene(d->mousePressViewPoint);
- d->mousePressScreenPoint = event->globalPos();
- d->lastMouseMoveScenePoint = d->mousePressScenePoint;
- d->lastMouseMoveScreenPoint = d->mousePressScreenPoint;
-
- QGraphicsSceneContextMenuEvent contextEvent(QEvent::GraphicsSceneContextMenu);
- contextEvent.setWidget(viewport());
- contextEvent.setScenePos(d->mousePressScenePoint);
- contextEvent.setScreenPos(d->mousePressScreenPoint);
- contextEvent.setModifiers(event->modifiers());
- contextEvent.setReason((QGraphicsSceneContextMenuEvent::Reason)(event->reason()));
- contextEvent.setAccepted(event->isAccepted());
- QApplication::sendEvent(d->scene, &contextEvent);
- event->setAccepted(contextEvent.isAccepted());
-}
-#endif // QT_NO_CONTEXTMENU
-
-/*!
- \reimp
-*/
-void QGraphicsView::dropEvent(QDropEvent *event)
-{
-#ifndef QT_NO_DRAGANDDROP
- Q_D(QGraphicsView);
- if (!d->scene || !d->sceneInteractionAllowed)
- return;
-
- // Generate a scene event.
- QGraphicsSceneDragDropEvent sceneEvent(QEvent::GraphicsSceneDrop);
- d->populateSceneDragDropEvent(&sceneEvent, event);
-
- // Send it to the scene.
- QApplication::sendEvent(d->scene, &sceneEvent);
-
- // Accept the originating event if the scene accepted the scene event.
- event->setAccepted(sceneEvent.isAccepted());
- if (sceneEvent.isAccepted())
- event->setDropAction(sceneEvent.dropAction());
-
- delete d->lastDragDropEvent;
- d->lastDragDropEvent = 0;
-
-#else
- Q_UNUSED(event)
-#endif
-}
-
-/*!
- \reimp
-*/
-void QGraphicsView::dragEnterEvent(QDragEnterEvent *event)
-{
-#ifndef QT_NO_DRAGANDDROP
- Q_D(QGraphicsView);
- if (!d->scene || !d->sceneInteractionAllowed)
- return;
-
- // Disable replaying of mouse move events.
- d->useLastMouseEvent = false;
-
- // Generate a scene event.
- QGraphicsSceneDragDropEvent sceneEvent(QEvent::GraphicsSceneDragEnter);
- d->populateSceneDragDropEvent(&sceneEvent, event);
-
- // Store it for later use.
- d->storeDragDropEvent(&sceneEvent);
-
- // Send it to the scene.
- QApplication::sendEvent(d->scene, &sceneEvent);
-
- // Accept the originating event if the scene accepted the scene event.
- if (sceneEvent.isAccepted()) {
- event->setAccepted(true);
- event->setDropAction(sceneEvent.dropAction());
- }
-#else
- Q_UNUSED(event)
-#endif
-}
-
-/*!
- \reimp
-*/
-void QGraphicsView::dragLeaveEvent(QDragLeaveEvent *event)
-{
-#ifndef QT_NO_DRAGANDDROP
- Q_D(QGraphicsView);
- if (!d->scene || !d->sceneInteractionAllowed)
- return;
- if (!d->lastDragDropEvent) {
- qWarning("QGraphicsView::dragLeaveEvent: drag leave received before drag enter");
- return;
- }
-
- // Generate a scene event.
- QGraphicsSceneDragDropEvent sceneEvent(QEvent::GraphicsSceneDragLeave);
- sceneEvent.setScenePos(d->lastDragDropEvent->scenePos());
- sceneEvent.setScreenPos(d->lastDragDropEvent->screenPos());
- sceneEvent.setButtons(d->lastDragDropEvent->buttons());
- sceneEvent.setModifiers(d->lastDragDropEvent->modifiers());
- sceneEvent.setPossibleActions(d->lastDragDropEvent->possibleActions());
- sceneEvent.setProposedAction(d->lastDragDropEvent->proposedAction());
- sceneEvent.setDropAction(d->lastDragDropEvent->dropAction());
- sceneEvent.setMimeData(d->lastDragDropEvent->mimeData());
- sceneEvent.setWidget(d->lastDragDropEvent->widget());
- sceneEvent.setSource(d->lastDragDropEvent->source());
- delete d->lastDragDropEvent;
- d->lastDragDropEvent = 0;
-
- // Send it to the scene.
- QApplication::sendEvent(d->scene, &sceneEvent);
-
- // Accept the originating event if the scene accepted the scene event.
- if (sceneEvent.isAccepted())
- event->setAccepted(true);
-#else
- Q_UNUSED(event)
-#endif
-}
-
-/*!
- \reimp
-*/
-void QGraphicsView::dragMoveEvent(QDragMoveEvent *event)
-{
-#ifndef QT_NO_DRAGANDDROP
- Q_D(QGraphicsView);
- if (!d->scene || !d->sceneInteractionAllowed)
- return;
-
- // Generate a scene event.
- QGraphicsSceneDragDropEvent sceneEvent(QEvent::GraphicsSceneDragMove);
- d->populateSceneDragDropEvent(&sceneEvent, event);
-
- // Store it for later use.
- d->storeDragDropEvent(&sceneEvent);
-
- // Send it to the scene.
- QApplication::sendEvent(d->scene, &sceneEvent);
-
- // Ignore the originating event if the scene ignored the scene event.
- event->setAccepted(sceneEvent.isAccepted());
- if (sceneEvent.isAccepted())
- event->setDropAction(sceneEvent.dropAction());
-#else
- Q_UNUSED(event)
-#endif
-}
-
-/*!
- \reimp
-*/
-void QGraphicsView::focusInEvent(QFocusEvent *event)
-{
- Q_D(QGraphicsView);
- d->updateInputMethodSensitivity();
- QAbstractScrollArea::focusInEvent(event);
- if (d->scene)
- QApplication::sendEvent(d->scene, event);
- // Pass focus on if the scene cannot accept focus.
- if (!d->scene || !event->isAccepted())
- QAbstractScrollArea::focusInEvent(event);
-}
-
-/*!
- \reimp
-*/
-bool QGraphicsView::focusNextPrevChild(bool next)
-{
- return QAbstractScrollArea::focusNextPrevChild(next);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsView::focusOutEvent(QFocusEvent *event)
-{
- Q_D(QGraphicsView);
- QAbstractScrollArea::focusOutEvent(event);
- if (d->scene)
- QApplication::sendEvent(d->scene, event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsView::keyPressEvent(QKeyEvent *event)
-{
- Q_D(QGraphicsView);
- if (!d->scene || !d->sceneInteractionAllowed) {
- QAbstractScrollArea::keyPressEvent(event);
- return;
- }
- QApplication::sendEvent(d->scene, event);
- if (!event->isAccepted())
- QAbstractScrollArea::keyPressEvent(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsView::keyReleaseEvent(QKeyEvent *event)
-{
- Q_D(QGraphicsView);
- if (!d->scene || !d->sceneInteractionAllowed)
- return;
- QApplication::sendEvent(d->scene, event);
- if (!event->isAccepted())
- QAbstractScrollArea::keyReleaseEvent(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsView::mouseDoubleClickEvent(QMouseEvent *event)
-{
- Q_D(QGraphicsView);
- if (!d->scene || !d->sceneInteractionAllowed)
- return;
-
- d->storeMouseEvent(event);
- d->mousePressViewPoint = event->pos();
- d->mousePressScenePoint = mapToScene(d->mousePressViewPoint);
- d->mousePressScreenPoint = event->globalPos();
- d->lastMouseMoveScenePoint = d->mousePressScenePoint;
- d->lastMouseMoveScreenPoint = d->mousePressScreenPoint;
- d->mousePressButton = event->button();
-
- QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseDoubleClick);
- mouseEvent.setWidget(viewport());
- mouseEvent.setButtonDownScenePos(d->mousePressButton, d->mousePressScenePoint);
- mouseEvent.setButtonDownScreenPos(d->mousePressButton, d->mousePressScreenPoint);
- mouseEvent.setScenePos(mapToScene(d->mousePressViewPoint));
- mouseEvent.setScreenPos(d->mousePressScreenPoint);
- mouseEvent.setLastScenePos(d->lastMouseMoveScenePoint);
- mouseEvent.setLastScreenPos(d->lastMouseMoveScreenPoint);
- mouseEvent.setButtons(event->buttons());
- mouseEvent.setButtons(event->buttons());
- mouseEvent.setAccepted(false);
- mouseEvent.setButton(event->button());
- mouseEvent.setModifiers(event->modifiers());
- if (event->spontaneous())
- qt_sendSpontaneousEvent(d->scene, &mouseEvent);
- else
- QApplication::sendEvent(d->scene, &mouseEvent);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsView::mousePressEvent(QMouseEvent *event)
-{
- Q_D(QGraphicsView);
-
- // Store this event for replaying, finding deltas, and for
- // scroll-dragging; even in non-interactive mode, scroll hand dragging is
- // allowed, so we store the event at the very top of this function.
- d->storeMouseEvent(event);
- d->lastMouseEvent.setAccepted(false);
-
- if (d->sceneInteractionAllowed) {
- // Store some of the event's button-down data.
- d->mousePressViewPoint = event->pos();
- d->mousePressScenePoint = mapToScene(d->mousePressViewPoint);
- d->mousePressScreenPoint = event->globalPos();
- d->lastMouseMoveScenePoint = d->mousePressScenePoint;
- d->lastMouseMoveScreenPoint = d->mousePressScreenPoint;
- d->mousePressButton = event->button();
-
- if (d->scene) {
- // Convert and deliver the mouse event to the scene.
- QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMousePress);
- mouseEvent.setWidget(viewport());
- mouseEvent.setButtonDownScenePos(d->mousePressButton, d->mousePressScenePoint);
- mouseEvent.setButtonDownScreenPos(d->mousePressButton, d->mousePressScreenPoint);
- mouseEvent.setScenePos(d->mousePressScenePoint);
- mouseEvent.setScreenPos(d->mousePressScreenPoint);
- mouseEvent.setLastScenePos(d->lastMouseMoveScenePoint);
- mouseEvent.setLastScreenPos(d->lastMouseMoveScreenPoint);
- mouseEvent.setButtons(event->buttons());
- mouseEvent.setButton(event->button());
- mouseEvent.setModifiers(event->modifiers());
- mouseEvent.setAccepted(false);
- if (event->spontaneous())
- qt_sendSpontaneousEvent(d->scene, &mouseEvent);
- else
- QApplication::sendEvent(d->scene, &mouseEvent);
-
- // Update the original mouse event accepted state.
- bool isAccepted = mouseEvent.isAccepted();
- event->setAccepted(isAccepted);
-
- // Update the last mouse event accepted state.
- d->lastMouseEvent.setAccepted(isAccepted);
-
- if (isAccepted)
- return;
- }
- }
-
-#ifndef QT_NO_RUBBERBAND
- if (d->dragMode == QGraphicsView::RubberBandDrag && !d->rubberBanding) {
- if (d->sceneInteractionAllowed) {
- // Rubberbanding is only allowed in interactive mode.
- event->accept();
- d->rubberBanding = true;
- d->rubberBandRect = QRect();
- if (d->scene) {
- // Initiating a rubber band always clears the selection.
- d->scene->clearSelection();
- }
- }
- } else
-#endif
- if (d->dragMode == QGraphicsView::ScrollHandDrag && event->button() == Qt::LeftButton) {
- // Left-button press in scroll hand mode initiates hand scrolling.
- event->accept();
- d->handScrolling = true;
- d->handScrollMotions = 0;
-#ifndef QT_NO_CURSOR
- viewport()->setCursor(Qt::ClosedHandCursor);
-#endif
- }
-}
-
-/*!
- \reimp
-*/
-void QGraphicsView::mouseMoveEvent(QMouseEvent *event)
-{
- Q_D(QGraphicsView);
-
-#ifndef QT_NO_RUBBERBAND
- if (d->dragMode == QGraphicsView::RubberBandDrag && d->sceneInteractionAllowed) {
- d->storeMouseEvent(event);
- if (d->rubberBanding) {
- // Check for enough drag distance
- if ((d->mousePressViewPoint - event->pos()).manhattanLength()
- < QApplication::startDragDistance()) {
- return;
- }
-
- // Update old rubberband
- if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate && !d->rubberBandRect.isEmpty()) {
- if (d->viewportUpdateMode != FullViewportUpdate)
- viewport()->update(d->rubberBandRegion(viewport(), d->rubberBandRect));
- else
- d->updateAll();
- }
-
- // Stop rubber banding if the user has let go of all buttons (even
- // if we didn't get the release events).
- if (!event->buttons()) {
- d->rubberBanding = false;
- d->rubberBandRect = QRect();
- return;
- }
-
- // Update rubberband position
- const QPoint &mp = d->mousePressViewPoint;
- QPoint ep = event->pos();
- d->rubberBandRect = QRect(qMin(mp.x(), ep.x()), qMin(mp.y(), ep.y()),
- qAbs(mp.x() - ep.x()) + 1, qAbs(mp.y() - ep.y()) + 1);
-
- // Update new rubberband
- if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate){
- if (d->viewportUpdateMode != FullViewportUpdate)
- viewport()->update(d->rubberBandRegion(viewport(), d->rubberBandRect));
- else
- d->updateAll();
- }
- // Set the new selection area
- QPainterPath selectionArea;
- selectionArea.addPolygon(mapToScene(d->rubberBandRect));
- selectionArea.closeSubpath();
- if (d->scene)
- d->scene->setSelectionArea(selectionArea, d->rubberBandSelectionMode,
- viewportTransform());
- return;
- }
- } else
-#endif // QT_NO_RUBBERBAND
- if (d->dragMode == QGraphicsView::ScrollHandDrag) {
- if (d->handScrolling) {
- QScrollBar *hBar = horizontalScrollBar();
- QScrollBar *vBar = verticalScrollBar();
- QPoint delta = event->pos() - d->lastMouseEvent.pos();
- hBar->setValue(hBar->value() + (isRightToLeft() ? delta.x() : -delta.x()));
- vBar->setValue(vBar->value() - delta.y());
-
- // Detect how much we've scrolled to disambiguate scrolling from
- // clicking.
- ++d->handScrollMotions;
- }
- }
-
- d->mouseMoveEventHandler(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsView::mouseReleaseEvent(QMouseEvent *event)
-{
- Q_D(QGraphicsView);
-
-#ifndef QT_NO_RUBBERBAND
- if (d->dragMode == QGraphicsView::RubberBandDrag && d->sceneInteractionAllowed && !event->buttons()) {
- if (d->rubberBanding) {
- if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate){
- if (d->viewportUpdateMode != FullViewportUpdate)
- viewport()->update(d->rubberBandRegion(viewport(), d->rubberBandRect));
- else
- d->updateAll();
- }
- d->rubberBanding = false;
- d->rubberBandRect = QRect();
- }
- } else
-#endif
- if (d->dragMode == QGraphicsView::ScrollHandDrag && event->button() == Qt::LeftButton) {
-#ifndef QT_NO_CURSOR
- // Restore the open hand cursor. ### There might be items
- // under the mouse that have a valid cursor at this time, so
- // we could repeat the steps from mouseMoveEvent().
- viewport()->setCursor(Qt::OpenHandCursor);
-#endif
- d->handScrolling = false;
-
- if (d->scene && d->sceneInteractionAllowed && !d->lastMouseEvent.isAccepted() && d->handScrollMotions <= 6) {
- // If we've detected very little motion during the hand drag, and
- // no item accepted the last event, we'll interpret that as a
- // click to the scene, and reset the selection.
- d->scene->clearSelection();
- }
- }
-
- d->storeMouseEvent(event);
-
- if (!d->sceneInteractionAllowed)
- return;
-
- if (!d->scene)
- return;
-
- QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseRelease);
- mouseEvent.setWidget(viewport());
- mouseEvent.setButtonDownScenePos(d->mousePressButton, d->mousePressScenePoint);
- mouseEvent.setButtonDownScreenPos(d->mousePressButton, d->mousePressScreenPoint);
- mouseEvent.setScenePos(mapToScene(event->pos()));
- mouseEvent.setScreenPos(event->globalPos());
- mouseEvent.setLastScenePos(d->lastMouseMoveScenePoint);
- mouseEvent.setLastScreenPos(d->lastMouseMoveScreenPoint);
- mouseEvent.setButtons(event->buttons());
- mouseEvent.setButton(event->button());
- mouseEvent.setModifiers(event->modifiers());
- mouseEvent.setAccepted(false);
- if (event->spontaneous())
- qt_sendSpontaneousEvent(d->scene, &mouseEvent);
- else
- QApplication::sendEvent(d->scene, &mouseEvent);
-
- // Update the last mouse event selected state.
- d->lastMouseEvent.setAccepted(mouseEvent.isAccepted());
-
-#ifndef QT_NO_CURSOR
- if (mouseEvent.isAccepted() && mouseEvent.buttons() == 0 && viewport()->testAttribute(Qt::WA_SetCursor)) {
- // The last mouse release on the viewport will trigger clearing the cursor.
- d->_q_unsetViewportCursor();
- }
-#endif
-}
-
-#ifndef QT_NO_WHEELEVENT
-/*!
- \reimp
-*/
-void QGraphicsView::wheelEvent(QWheelEvent *event)
-{
- Q_D(QGraphicsView);
- if (!d->scene || !d->sceneInteractionAllowed) {
- QAbstractScrollArea::wheelEvent(event);
- return;
- }
-
- event->ignore();
-
- QGraphicsSceneWheelEvent wheelEvent(QEvent::GraphicsSceneWheel);
- wheelEvent.setWidget(viewport());
- wheelEvent.setScenePos(mapToScene(event->pos()));
- wheelEvent.setScreenPos(event->globalPos());
- wheelEvent.setButtons(event->buttons());
- wheelEvent.setModifiers(event->modifiers());
- wheelEvent.setDelta(event->delta());
- wheelEvent.setOrientation(event->orientation());
- wheelEvent.setAccepted(false);
- QApplication::sendEvent(d->scene, &wheelEvent);
- event->setAccepted(wheelEvent.isAccepted());
- if (!event->isAccepted())
- QAbstractScrollArea::wheelEvent(event);
-}
-#endif // QT_NO_WHEELEVENT
-
-/*!
- \reimp
-*/
-void QGraphicsView::paintEvent(QPaintEvent *event)
-{
- Q_D(QGraphicsView);
- if (!d->scene) {
- QAbstractScrollArea::paintEvent(event);
- return;
- }
-
- // Set up painter state protection.
- d->scene->d_func()->painterStateProtection = !(d->optimizationFlags & DontSavePainterState);
-
- // Determine the exposed region
- d->exposedRegion = event->region();
- QRectF exposedSceneRect = mapToScene(d->exposedRegion.boundingRect()).boundingRect();
-
- // Set up the painter
- QPainter painter(viewport());
-#ifndef QT_NO_RUBBERBAND
- if (d->rubberBanding && !d->rubberBandRect.isEmpty())
- painter.save();
-#endif
- // Set up render hints
- painter.setRenderHints(painter.renderHints(), false);
- painter.setRenderHints(d->renderHints, true);
-
- // Set up viewport transform
- const bool viewTransformed = isTransformed();
- if (viewTransformed)
- painter.setWorldTransform(viewportTransform());
- const QTransform viewTransform = painter.worldTransform();
-
- // Draw background
- if ((d->cacheMode & CacheBackground)
-#ifdef Q_WS_X11
- && X11->use_xrender
-#endif
- ) {
- // Recreate the background pixmap, and flag the whole background as
- // exposed.
- if (d->mustResizeBackgroundPixmap) {
- d->backgroundPixmap = QPixmap(viewport()->size());
- QBrush bgBrush = viewport()->palette().brush(viewport()->backgroundRole());
- if (!bgBrush.isOpaque())
- d->backgroundPixmap.fill(Qt::transparent);
- QPainter p(&d->backgroundPixmap);
- p.fillRect(0, 0, d->backgroundPixmap.width(), d->backgroundPixmap.height(), bgBrush);
- d->backgroundPixmapExposed = QRegion(viewport()->rect());
- d->mustResizeBackgroundPixmap = false;
- }
-
- // Redraw exposed areas
- if (!d->backgroundPixmapExposed.isEmpty()) {
- QPainter backgroundPainter(&d->backgroundPixmap);
- backgroundPainter.setClipRegion(d->backgroundPixmapExposed, Qt::ReplaceClip);
- if (viewTransformed)
- backgroundPainter.setTransform(viewTransform);
- QRectF backgroundExposedSceneRect = mapToScene(d->backgroundPixmapExposed.boundingRect()).boundingRect();
- drawBackground(&backgroundPainter, backgroundExposedSceneRect);
- d->backgroundPixmapExposed = QRegion();
- }
-
- // Blit the background from the background pixmap
- if (viewTransformed) {
- painter.setWorldTransform(QTransform());
- painter.drawPixmap(QPoint(), d->backgroundPixmap);
- painter.setWorldTransform(viewTransform);
- } else {
- painter.drawPixmap(QPoint(), d->backgroundPixmap);
- }
- } else {
- if (!(d->optimizationFlags & DontSavePainterState))
- painter.save();
- drawBackground(&painter, exposedSceneRect);
- if (!(d->optimizationFlags & DontSavePainterState))
- painter.restore();
- }
-
- // Items
- if (!(d->optimizationFlags & IndirectPainting)) {
- const quint32 oldRectAdjust = d->scene->d_func()->rectAdjust;
- if (d->optimizationFlags & QGraphicsView::DontAdjustForAntialiasing)
- d->scene->d_func()->rectAdjust = 1;
- else
- d->scene->d_func()->rectAdjust = 2;
- d->scene->d_func()->drawItems(&painter, viewTransformed ? &viewTransform : 0,
- &d->exposedRegion, viewport());
- d->scene->d_func()->rectAdjust = oldRectAdjust;
- // Make sure the painter's world transform is restored correctly when
- // drawing without painter state protection (DontSavePainterState).
- // We only change the worldTransform() so there's no need to do a full-blown
- // save() and restore(). Also note that we don't have to do this in case of
- // IndirectPainting (the else branch), because in that case we always save()
- // and restore() in QGraphicsScene::drawItems().
- if (!d->scene->d_func()->painterStateProtection)
- painter.setOpacity(1.0);
- painter.setWorldTransform(viewTransform);
- } else {
- // Make sure we don't have unpolished items before we draw
- if (!d->scene->d_func()->unpolishedItems.isEmpty())
- d->scene->d_func()->_q_polishItems();
- // We reset updateAll here (after we've issued polish events)
- // so that we can discard update requests coming from polishEvent().
- d->scene->d_func()->updateAll = false;
-
- // Find all exposed items
- bool allItems = false;
- QList<QGraphicsItem *> itemList = d->findItems(d->exposedRegion, &allItems, viewTransform);
- if (!itemList.isEmpty()) {
- // Generate the style options.
- const int numItems = itemList.size();
- QGraphicsItem **itemArray = &itemList[0]; // Relies on QList internals, but is perfectly valid.
- QStyleOptionGraphicsItem *styleOptionArray = d->allocStyleOptionsArray(numItems);
- QTransform transform(Qt::Uninitialized);
- for (int i = 0; i < numItems; ++i) {
- QGraphicsItem *item = itemArray[i];
- QGraphicsItemPrivate *itemd = item->d_ptr.data();
- itemd->initStyleOption(&styleOptionArray[i], viewTransform, d->exposedRegion, allItems);
- // Cache the item's area in view coordinates.
- // Note that we have to do this here in case the base class implementation
- // (QGraphicsScene::drawItems) is not called. If it is, we'll do this
- // operation twice, but that's the price one has to pay for using indirect
- // painting :-/.
- const QRectF brect = adjustedItemEffectiveBoundingRect(item);
- if (!itemd->itemIsUntransformable()) {
- transform = item->sceneTransform();
- if (viewTransformed)
- transform *= viewTransform;
- } else {
- transform = item->deviceTransform(viewTransform);
- }
- itemd->paintedViewBoundingRects.insert(d->viewport, transform.mapRect(brect).toRect());
- }
- // Draw the items.
- drawItems(&painter, numItems, itemArray, styleOptionArray);
- d->freeStyleOptionsArray(styleOptionArray);
- }
- }
-
- // Foreground
- drawForeground(&painter, exposedSceneRect);
-
-#ifndef QT_NO_RUBBERBAND
- // Rubberband
- if (d->rubberBanding && !d->rubberBandRect.isEmpty()) {
- painter.restore();
- QStyleOptionRubberBand option;
- option.initFrom(viewport());
- option.rect = d->rubberBandRect;
- option.shape = QRubberBand::Rectangle;
-
- QStyleHintReturnMask mask;
- if (viewport()->style()->styleHint(QStyle::SH_RubberBand_Mask, &option, viewport(), &mask)) {
- // painter clipping for masked rubberbands
- painter.setClipRegion(mask.region, Qt::IntersectClip);
- }
-
- viewport()->style()->drawControl(QStyle::CE_RubberBand, &option, &painter, viewport());
- }
-#endif
-
- painter.end();
-
- // Restore painter state protection.
- d->scene->d_func()->painterStateProtection = true;
-}
-
-/*!
- \reimp
-*/
-void QGraphicsView::resizeEvent(QResizeEvent *event)
-{
- Q_D(QGraphicsView);
- // Save the last center point - the resize may scroll the view, which
- // changes the center point.
- QPointF oldLastCenterPoint = d->lastCenterPoint;
-
- QAbstractScrollArea::resizeEvent(event);
- d->recalculateContentSize();
-
- // Restore the center point again.
- if (d->resizeAnchor == NoAnchor && !d->keepLastCenterPoint) {
- d->updateLastCenterPoint();
- } else {
- d->lastCenterPoint = oldLastCenterPoint;
- }
- d->centerView(d->resizeAnchor);
- d->keepLastCenterPoint = false;
-
- if (d->cacheMode & CacheBackground) {
- // Invalidate the background pixmap
- d->mustResizeBackgroundPixmap = true;
- }
-}
-
-/*!
- \reimp
-*/
-void QGraphicsView::scrollContentsBy(int dx, int dy)
-{
- Q_D(QGraphicsView);
- d->dirtyScroll = true;
- if (d->transforming)
- return;
- if (isRightToLeft())
- dx = -dx;
-
- if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate) {
- if (d->viewportUpdateMode != QGraphicsView::FullViewportUpdate) {
- if (d->accelerateScrolling) {
-#ifndef QT_NO_RUBBERBAND
- // Update new and old rubberband regions
- if (!d->rubberBandRect.isEmpty()) {
- QRegion rubberBandRegion(d->rubberBandRegion(viewport(), d->rubberBandRect));
- rubberBandRegion += rubberBandRegion.translated(-dx, -dy);
- viewport()->update(rubberBandRegion);
- }
-#endif
- d->dirtyScrollOffset.rx() += dx;
- d->dirtyScrollOffset.ry() += dy;
- d->dirtyRegion.translate(dx, dy);
- viewport()->scroll(dx, dy);
- } else {
- d->updateAll();
- }
- } else {
- d->updateAll();
- }
- }
-
- d->updateLastCenterPoint();
-
- if ((d->cacheMode & CacheBackground)
-#ifdef Q_WS_X11
- && X11->use_xrender
-#endif
- ) {
- // Scroll the background pixmap
- QRegion exposed;
- if (!d->backgroundPixmap.isNull())
- d->backgroundPixmap.scroll(dx, dy, d->backgroundPixmap.rect(), &exposed);
-
- // Invalidate the background pixmap
- d->backgroundPixmapExposed.translate(dx, dy);
- d->backgroundPixmapExposed += exposed;
- }
-
- // Always replay on scroll.
- if (d->sceneInteractionAllowed)
- d->replayLastMouseEvent();
-}
-
-/*!
- \reimp
-*/
-void QGraphicsView::showEvent(QShowEvent *event)
-{
- Q_D(QGraphicsView);
- d->recalculateContentSize();
- d->centerView(d->transformationAnchor);
- QAbstractScrollArea::showEvent(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsView::inputMethodEvent(QInputMethodEvent *event)
-{
- Q_D(QGraphicsView);
- if (d->scene)
- QApplication::sendEvent(d->scene, event);
-}
-
-/*!
- Draws the background of the scene using \a painter, before any items and
- the foreground are drawn. Reimplement this function to provide a custom
- background for this view.
-
- If all you want is to define a color, texture or gradient for the
- background, you can call setBackgroundBrush() instead.
-
- All painting is done in \e scene coordinates. \a rect is the exposed
- rectangle.
-
- The default implementation fills \a rect using the view's backgroundBrush.
- If no such brush is defined (the default), the scene's drawBackground()
- function is called instead.
-
- \sa drawForeground(), QGraphicsScene::drawBackground()
-*/
-void QGraphicsView::drawBackground(QPainter *painter, const QRectF &rect)
-{
- Q_D(QGraphicsView);
- if (d->scene && d->backgroundBrush.style() == Qt::NoBrush) {
- d->scene->drawBackground(painter, rect);
- return;
- }
-
- painter->fillRect(rect, d->backgroundBrush);
-}
-
-/*!
- Draws the foreground of the scene using \a painter, after the background
- and all items are drawn. Reimplement this function to provide a custom
- foreground for this view.
-
- If all you want is to define a color, texture or gradient for the
- foreground, you can call setForegroundBrush() instead.
-
- All painting is done in \e scene coordinates. \a rect is the exposed
- rectangle.
-
- The default implementation fills \a rect using the view's foregroundBrush.
- If no such brush is defined (the default), the scene's drawForeground()
- function is called instead.
-
- \sa drawBackground(), QGraphicsScene::drawForeground()
-*/
-void QGraphicsView::drawForeground(QPainter *painter, const QRectF &rect)
-{
- Q_D(QGraphicsView);
- if (d->scene && d->foregroundBrush.style() == Qt::NoBrush) {
- d->scene->drawForeground(painter, rect);
- return;
- }
-
- painter->fillRect(rect, d->foregroundBrush);
-}
-
-/*!
- \obsolete
-
- Draws the items \a items in the scene using \a painter, after the
- background and before the foreground are drawn. \a numItems is the number
- of items in \a items and options in \a options. \a options is a list of
- styleoptions; one for each item. Reimplement this function to provide
- custom item drawing for this view.
-
- The default implementation calls the scene's drawItems() function.
-
- Since Qt 4.6, this function is not called anymore unless
- the QGraphicsView::IndirectPainting flag is given as an Optimization
- flag.
-
- \sa drawForeground(), drawBackground(), QGraphicsScene::drawItems()
-*/
-void QGraphicsView::drawItems(QPainter *painter, int numItems,
- QGraphicsItem *items[],
- const QStyleOptionGraphicsItem options[])
-{
- Q_D(QGraphicsView);
- if (d->scene) {
- QWidget *widget = painter->device() == viewport() ? viewport() : 0;
- d->scene->drawItems(painter, numItems, items, options, widget);
- }
-}
-
-/*!
- Returns the current transformation matrix for the view. If no current
- transformation is set, the identity matrix is returned.
-
- \sa setTransform(), rotate(), scale(), shear(), translate()
-*/
-QTransform QGraphicsView::transform() const
-{
- Q_D(const QGraphicsView);
- return d->matrix;
-}
-
-/*!
- Returns a matrix that maps viewport coordinates to scene coordinates.
-
- \sa mapToScene(), mapFromScene()
-*/
-QTransform QGraphicsView::viewportTransform() const
-{
- Q_D(const QGraphicsView);
- QTransform moveMatrix = QTransform::fromTranslate(-d->horizontalScroll(), -d->verticalScroll());
- return d->identityMatrix ? moveMatrix : d->matrix * moveMatrix;
-}
-
-/*!
- \since 4.6
-
- Returns true if the view is transformed (i.e., a non-identity transform
- has been assigned, or the scrollbars are adjusted).
-
- \sa setTransform(), horizontalScrollBar(), verticalScrollBar()
-*/
-bool QGraphicsView::isTransformed() const
-{
- Q_D(const QGraphicsView);
- return !d->identityMatrix || d->horizontalScroll() || d->verticalScroll();
-}
-
-/*!
- Sets the view's current transformation matrix to \a matrix.
-
- If \a combine is true, then \a matrix is combined with the current matrix;
- otherwise, \a matrix \e replaces the current matrix. \a combine is false
- by default.
-
- The transformation matrix tranforms the scene into view coordinates. Using
- the default transformation, provided by the identity matrix, one pixel in
- the view represents one unit in the scene (e.g., a 10x10 rectangular item
- is drawn using 10x10 pixels in the view). If a 2x2 scaling matrix is
- applied, the scene will be drawn in 1:2 (e.g., a 10x10 rectangular item is
- then drawn using 20x20 pixels in the view).
-
- Example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp 7
-
- To simplify interation with items using a transformed view, QGraphicsView
- provides mapTo... and mapFrom... functions that can translate between
- scene and view coordinates. For example, you can call mapToScene() to map
- a view coordiate to a floating point scene coordinate, or mapFromScene()
- to map from floating point scene coordinates to view coordinates.
-
- \sa transform(), rotate(), scale(), shear(), translate()
-*/
-void QGraphicsView::setTransform(const QTransform &matrix, bool combine )
-{
- Q_D(QGraphicsView);
- QTransform oldMatrix = d->matrix;
- if (!combine)
- d->matrix = matrix;
- else
- d->matrix = matrix * d->matrix;
- if (oldMatrix == d->matrix)
- return;
-
- d->identityMatrix = d->matrix.isIdentity();
- d->transforming = true;
- if (d->scene) {
- d->recalculateContentSize();
- d->centerView(d->transformationAnchor);
- } else {
- d->updateLastCenterPoint();
- }
-
- if (d->sceneInteractionAllowed)
- d->replayLastMouseEvent();
- d->transforming = false;
-
- // Any matrix operation requires a full update.
- d->updateAll();
-}
-
-/*!
- Resets the view transformation to the identity matrix.
-
- \sa transform(), setTransform()
-*/
-void QGraphicsView::resetTransform()
-{
- setTransform(QTransform());
-}
-
-QPointF QGraphicsViewPrivate::mapToScene(const QPointF &point) const
-{
- QPointF p = point;
- p.rx() += horizontalScroll();
- p.ry() += verticalScroll();
- return identityMatrix ? p : matrix.inverted().map(p);
-}
-
-QRectF QGraphicsViewPrivate::mapToScene(const QRectF &rect) const
-{
- QPointF scrollOffset(horizontalScroll(), verticalScroll());
- QPointF tl = scrollOffset + rect.topLeft();
- QPointF tr = scrollOffset + rect.topRight();
- QPointF br = scrollOffset + rect.bottomRight();
- QPointF bl = scrollOffset + rect.bottomLeft();
-
- QPolygonF poly(4);
- if (!identityMatrix) {
- QTransform x = matrix.inverted();
- poly[0] = x.map(tl);
- poly[1] = x.map(tr);
- poly[2] = x.map(br);
- poly[3] = x.map(bl);
- } else {
- poly[0] = tl;
- poly[1] = tr;
- poly[2] = br;
- poly[3] = bl;
- }
- return poly.boundingRect();
-}
-
-QT_END_NAMESPACE
-
-#include "moc_qgraphicsview.cpp"
-
-#endif // QT_NO_GRAPHICSVIEW
diff --git a/src/gui/graphicsview/qgraphicsview.h b/src/gui/graphicsview/qgraphicsview.h
deleted file mode 100644
index b2a7bdb226..0000000000
--- a/src/gui/graphicsview/qgraphicsview.h
+++ /dev/null
@@ -1,316 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSVIEW_H
-#define QGRAPHICSVIEW_H
-
-#include <QtCore/qmetatype.h>
-#include <QtGui/qpainter.h>
-#include <QtGui/qscrollarea.h>
-#include <QtGui/qgraphicsscene.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
-
-class QGraphicsItem;
-class QPainterPath;
-class QPolygonF;
-class QStyleOptionGraphicsItem;
-
-class QGraphicsViewPrivate;
-class Q_GUI_EXPORT QGraphicsView : public QAbstractScrollArea
-{
- Q_OBJECT
- Q_FLAGS(QPainter::RenderHints CacheMode OptimizationFlags)
- Q_ENUMS(ViewportAnchor DragMode ViewportUpdateMode)
- Q_PROPERTY(QBrush backgroundBrush READ backgroundBrush WRITE setBackgroundBrush)
- Q_PROPERTY(QBrush foregroundBrush READ foregroundBrush WRITE setForegroundBrush)
- Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive)
- Q_PROPERTY(QRectF sceneRect READ sceneRect WRITE setSceneRect)
- Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
- Q_PROPERTY(QPainter::RenderHints renderHints READ renderHints WRITE setRenderHints)
- Q_PROPERTY(DragMode dragMode READ dragMode WRITE setDragMode)
- Q_PROPERTY(CacheMode cacheMode READ cacheMode WRITE setCacheMode)
- Q_PROPERTY(ViewportAnchor transformationAnchor READ transformationAnchor WRITE setTransformationAnchor)
- Q_PROPERTY(ViewportAnchor resizeAnchor READ resizeAnchor WRITE setResizeAnchor)
- Q_PROPERTY(ViewportUpdateMode viewportUpdateMode READ viewportUpdateMode WRITE setViewportUpdateMode)
-#ifndef QT_NO_RUBBERBAND
- Q_PROPERTY(Qt::ItemSelectionMode rubberBandSelectionMode READ rubberBandSelectionMode WRITE setRubberBandSelectionMode)
-#endif
- Q_PROPERTY(OptimizationFlags optimizationFlags READ optimizationFlags WRITE setOptimizationFlags)
-
-public:
- enum ViewportAnchor {
- NoAnchor,
- AnchorViewCenter,
- AnchorUnderMouse
- };
-
- enum CacheModeFlag {
- CacheNone = 0x0,
- CacheBackground = 0x1
- };
- Q_DECLARE_FLAGS(CacheMode, CacheModeFlag)
-
- enum DragMode {
- NoDrag,
- ScrollHandDrag,
- RubberBandDrag
- };
-
- enum ViewportUpdateMode {
- FullViewportUpdate,
- MinimalViewportUpdate,
- SmartViewportUpdate,
- NoViewportUpdate,
- BoundingRectViewportUpdate
- };
-
- enum OptimizationFlag {
- DontClipPainter = 0x1, // obsolete
- DontSavePainterState = 0x2,
- DontAdjustForAntialiasing = 0x4,
- IndirectPainting = 0x8
- };
- Q_DECLARE_FLAGS(OptimizationFlags, OptimizationFlag)
-
- QGraphicsView(QWidget *parent = 0);
- QGraphicsView(QGraphicsScene *scene, QWidget *parent = 0);
- ~QGraphicsView();
-
- QSize sizeHint() const;
-
- QPainter::RenderHints renderHints() const;
- void setRenderHint(QPainter::RenderHint hint, bool enabled = true);
- void setRenderHints(QPainter::RenderHints hints);
-
- Qt::Alignment alignment() const;
- void setAlignment(Qt::Alignment alignment);
-
- ViewportAnchor transformationAnchor() const;
- void setTransformationAnchor(ViewportAnchor anchor);
-
- ViewportAnchor resizeAnchor() const;
- void setResizeAnchor(ViewportAnchor anchor);
-
- ViewportUpdateMode viewportUpdateMode() const;
- void setViewportUpdateMode(ViewportUpdateMode mode);
-
- OptimizationFlags optimizationFlags() const;
- void setOptimizationFlag(OptimizationFlag flag, bool enabled = true);
- void setOptimizationFlags(OptimizationFlags flags);
-
- DragMode dragMode() const;
- void setDragMode(DragMode mode);
-
-#ifndef QT_NO_RUBBERBAND
- Qt::ItemSelectionMode rubberBandSelectionMode() const;
- void setRubberBandSelectionMode(Qt::ItemSelectionMode mode);
-#endif
-
- CacheMode cacheMode() const;
- void setCacheMode(CacheMode mode);
- void resetCachedContent();
-
- bool isInteractive() const;
- void setInteractive(bool allowed);
-
- QGraphicsScene *scene() const;
- void setScene(QGraphicsScene *scene);
-
- QRectF sceneRect() const;
- void setSceneRect(const QRectF &rect);
- inline void setSceneRect(qreal x, qreal y, qreal w, qreal h);
-
- QMatrix matrix() const;
- void setMatrix(const QMatrix &matrix, bool combine = false);
- void resetMatrix();
- QTransform transform() const;
- QTransform viewportTransform() const;
- bool isTransformed() const;
- void setTransform(const QTransform &matrix, bool combine = false);
- void resetTransform();
- void rotate(qreal angle);
- void scale(qreal sx, qreal sy);
- void shear(qreal sh, qreal sv);
- void translate(qreal dx, qreal dy);
-
- void centerOn(const QPointF &pos);
- inline void centerOn(qreal x, qreal y);
- void centerOn(const QGraphicsItem *item);
- void ensureVisible(const QRectF &rect, int xmargin = 50, int ymargin = 50);
- inline void ensureVisible(qreal x, qreal y, qreal w, qreal h, int xmargin = 50, int ymargin = 50);
- void ensureVisible(const QGraphicsItem *item, int xmargin = 50, int ymargin = 50);
- void fitInView(const QRectF &rect, Qt::AspectRatioMode aspectRadioMode = Qt::IgnoreAspectRatio);
- inline void fitInView(qreal x, qreal y, qreal w, qreal h,
- Qt::AspectRatioMode aspectRadioMode = Qt::IgnoreAspectRatio);
- void fitInView(const QGraphicsItem *item,
- Qt::AspectRatioMode aspectRadioMode = Qt::IgnoreAspectRatio);
-
- void render(QPainter *painter, const QRectF &target = QRectF(), const QRect &source = QRect(),
- Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio);
-
- QList<QGraphicsItem *> items() const;
- QList<QGraphicsItem *> items(const QPoint &pos) const;
- inline QList<QGraphicsItem *> items(int x, int y) const;
- QList<QGraphicsItem *> items(const QRect &rect, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const;
- inline QList<QGraphicsItem *> items(int x, int y, int w, int h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const;
- QList<QGraphicsItem *> items(const QPolygon &polygon, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const;
- QList<QGraphicsItem *> items(const QPainterPath &path, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const;
- QGraphicsItem *itemAt(const QPoint &pos) const;
- inline QGraphicsItem *itemAt(int x, int y) const;
-
- QPointF mapToScene(const QPoint &point) const;
- QPolygonF mapToScene(const QRect &rect) const;
- QPolygonF mapToScene(const QPolygon &polygon) const;
- QPainterPath mapToScene(const QPainterPath &path) const;
- QPoint mapFromScene(const QPointF &point) const;
- QPolygon mapFromScene(const QRectF &rect) const;
- QPolygon mapFromScene(const QPolygonF &polygon) const;
- QPainterPath mapFromScene(const QPainterPath &path) const;
- inline QPointF mapToScene(int x, int y) const;
- inline QPolygonF mapToScene(int x, int y, int w, int h) const;
- inline QPoint mapFromScene(qreal x, qreal y) const;
- inline QPolygon mapFromScene(qreal x, qreal y, qreal w, qreal h) const;
-
- QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
-
- QBrush backgroundBrush() const;
- void setBackgroundBrush(const QBrush &brush);
-
- QBrush foregroundBrush() const;
- void setForegroundBrush(const QBrush &brush);
-
-public Q_SLOTS:
- void updateScene(const QList<QRectF> &rects);
- void invalidateScene(const QRectF &rect = QRectF(), QGraphicsScene::SceneLayers layers = QGraphicsScene::AllLayers);
- void updateSceneRect(const QRectF &rect);
-
-protected Q_SLOTS:
- void setupViewport(QWidget *widget);
-
-protected:
- QGraphicsView(QGraphicsViewPrivate &, QWidget *parent = 0);
- bool event(QEvent *event);
- bool viewportEvent(QEvent *event);
-
-#ifndef QT_NO_CONTEXTMENU
- void contextMenuEvent(QContextMenuEvent *event);
-#endif
- void dragEnterEvent(QDragEnterEvent *event);
- void dragLeaveEvent(QDragLeaveEvent *event);
- void dragMoveEvent(QDragMoveEvent *event);
- void dropEvent(QDropEvent *event);
- void focusInEvent(QFocusEvent *event);
- bool focusNextPrevChild(bool next);
- void focusOutEvent(QFocusEvent *event);
- void keyPressEvent(QKeyEvent *event);
- void keyReleaseEvent(QKeyEvent *event);
- void mouseDoubleClickEvent(QMouseEvent *event);
- void mousePressEvent(QMouseEvent *event);
- void mouseMoveEvent(QMouseEvent *event);
- void mouseReleaseEvent(QMouseEvent *event);
-#ifndef QT_NO_WHEELEVENT
- void wheelEvent(QWheelEvent *event);
-#endif
- void paintEvent(QPaintEvent *event);
- void resizeEvent(QResizeEvent *event);
- void scrollContentsBy(int dx, int dy);
- void showEvent(QShowEvent *event);
- void inputMethodEvent(QInputMethodEvent *event);
-
- virtual void drawBackground(QPainter *painter, const QRectF &rect);
- virtual void drawForeground(QPainter *painter, const QRectF &rect);
- virtual void drawItems(QPainter *painter, int numItems,
- QGraphicsItem *items[],
- const QStyleOptionGraphicsItem options[]);
-
-private:
- Q_DECLARE_PRIVATE(QGraphicsView)
- Q_DISABLE_COPY(QGraphicsView)
-#ifndef QT_NO_CURSOR
- Q_PRIVATE_SLOT(d_func(), void _q_setViewportCursor(const QCursor &))
- Q_PRIVATE_SLOT(d_func(), void _q_unsetViewportCursor())
-#endif
- friend class QGraphicsSceneWidget;
- friend class QGraphicsScene;
- friend class QGraphicsScenePrivate;
- friend class QGraphicsItemPrivate;
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsView::CacheMode)
-Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsView::OptimizationFlags)
-
-inline void QGraphicsView::setSceneRect(qreal ax, qreal ay, qreal aw, qreal ah)
-{ setSceneRect(QRectF(ax, ay, aw, ah)); }
-inline void QGraphicsView::centerOn(qreal ax, qreal ay)
-{ centerOn(QPointF(ax, ay)); }
-inline void QGraphicsView::ensureVisible(qreal ax, qreal ay, qreal aw, qreal ah, int xmargin, int ymargin)
-{ ensureVisible(QRectF(ax, ay, aw, ah), xmargin, ymargin); }
-inline void QGraphicsView::fitInView(qreal ax, qreal ay, qreal w, qreal h, Qt::AspectRatioMode mode)
-{ fitInView(QRectF(ax, ay, w, h), mode); }
-inline QList<QGraphicsItem *> QGraphicsView::items(int ax, int ay) const
-{ return items(QPoint(ax, ay)); }
-inline QList<QGraphicsItem *> QGraphicsView::items(int ax, int ay, int w, int h, Qt::ItemSelectionMode mode) const
-{ return items(QRect(ax, ay, w, h), mode); }
-inline QGraphicsItem *QGraphicsView::itemAt(int ax, int ay) const
-{ return itemAt(QPoint(ax, ay)); }
-inline QPointF QGraphicsView::mapToScene(int ax, int ay) const
-{ return mapToScene(QPoint(ax, ay)); }
-inline QPolygonF QGraphicsView::mapToScene(int ax, int ay, int w, int h) const
-{ return mapToScene(QRect(ax, ay, w, h)); }
-inline QPoint QGraphicsView::mapFromScene(qreal ax, qreal ay) const
-{ return mapFromScene(QPointF(ax, ay)); }
-inline QPolygon QGraphicsView::mapFromScene(qreal ax, qreal ay, qreal w, qreal h) const
-{ return mapFromScene(QRectF(ax, ay, w, h)); }
-
-#endif // QT_NO_GRAPHICSVIEW
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QGRAPHICSVIEW_H
diff --git a/src/gui/graphicsview/qgraphicsview_p.h b/src/gui/graphicsview/qgraphicsview_p.h
deleted file mode 100644
index 5572b7e770..0000000000
--- a/src/gui/graphicsview/qgraphicsview_p.h
+++ /dev/null
@@ -1,233 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSVIEW_P_H
-#define QGRAPHICSVIEW_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qgraphicsview.h"
-
-#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
-
-#include <QtGui/qevent.h>
-#include <QtCore/qcoreapplication.h>
-#include "qgraphicssceneevent.h"
-#include <QtGui/qstyleoption.h>
-#include <private/qabstractscrollarea_p.h>
-#include <private/qapplication_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class Q_GUI_EXPORT QGraphicsViewPrivate : public QAbstractScrollAreaPrivate
-{
- Q_DECLARE_PUBLIC(QGraphicsView)
-public:
- QGraphicsViewPrivate();
-
- void recalculateContentSize();
- void centerView(QGraphicsView::ViewportAnchor anchor);
-
- QPainter::RenderHints renderHints;
-
- QGraphicsView::DragMode dragMode;
-
- quint32 sceneInteractionAllowed : 1;
- quint32 hasSceneRect : 1;
- quint32 connectedToScene : 1;
- quint32 useLastMouseEvent : 1;
- quint32 identityMatrix : 1;
- quint32 dirtyScroll : 1;
- quint32 accelerateScrolling : 1;
- quint32 keepLastCenterPoint : 1;
- quint32 transforming : 1;
- quint32 handScrolling : 1;
- quint32 mustAllocateStyleOptions : 1;
- quint32 mustResizeBackgroundPixmap : 1;
- quint32 fullUpdatePending : 1;
- quint32 hasUpdateClip : 1;
- quint32 padding : 18;
-
- QRectF sceneRect;
- void updateLastCenterPoint();
-
- qint64 horizontalScroll() const;
- qint64 verticalScroll() const;
-
- QRectF mapRectToScene(const QRect &rect) const;
- QRectF mapRectFromScene(const QRectF &rect) const;
-
- QRect updateClip;
- QPointF mousePressItemPoint;
- QPointF mousePressScenePoint;
- QPoint mousePressViewPoint;
- QPoint mousePressScreenPoint;
- QPointF lastMouseMoveScenePoint;
- QPoint lastMouseMoveScreenPoint;
- QPoint dirtyScrollOffset;
- Qt::MouseButton mousePressButton;
- QTransform matrix;
- qint64 scrollX, scrollY;
- void updateScroll();
-
- qreal leftIndent;
- qreal topIndent;
-
- // Replaying mouse events
- QMouseEvent lastMouseEvent;
- void replayLastMouseEvent();
- void storeMouseEvent(QMouseEvent *event);
- void mouseMoveEventHandler(QMouseEvent *event);
-
- QPointF lastCenterPoint;
- Qt::Alignment alignment;
-
- QGraphicsView::ViewportAnchor transformationAnchor;
- QGraphicsView::ViewportAnchor resizeAnchor;
- QGraphicsView::ViewportUpdateMode viewportUpdateMode;
- QGraphicsView::OptimizationFlags optimizationFlags;
-
- QPointer<QGraphicsScene> scene;
-#ifndef QT_NO_RUBBERBAND
- QRect rubberBandRect;
- QRegion rubberBandRegion(const QWidget *widget, const QRect &rect) const;
- bool rubberBanding;
- Qt::ItemSelectionMode rubberBandSelectionMode;
-#endif
- int handScrollMotions;
-
- QGraphicsView::CacheMode cacheMode;
-
- QVector<QStyleOptionGraphicsItem> styleOptions;
- QStyleOptionGraphicsItem *allocStyleOptionsArray(int numItems);
- void freeStyleOptionsArray(QStyleOptionGraphicsItem *array);
-
- QBrush backgroundBrush;
- QBrush foregroundBrush;
- QPixmap backgroundPixmap;
- QRegion backgroundPixmapExposed;
-
-#ifndef QT_NO_CURSOR
- QCursor originalCursor;
- bool hasStoredOriginalCursor;
- void _q_setViewportCursor(const QCursor &cursor);
- void _q_unsetViewportCursor();
-#endif
-
- QGraphicsSceneDragDropEvent *lastDragDropEvent;
- void storeDragDropEvent(const QGraphicsSceneDragDropEvent *event);
- void populateSceneDragDropEvent(QGraphicsSceneDragDropEvent *dest,
- QDropEvent *source);
-
- QRect mapToViewRect(const QGraphicsItem *item, const QRectF &rect) const;
- QRegion mapToViewRegion(const QGraphicsItem *item, const QRectF &rect) const;
- QRegion dirtyRegion;
- QRect dirtyBoundingRect;
- void processPendingUpdates();
- inline void updateAll()
- {
- viewport->update();
- fullUpdatePending = true;
- dirtyBoundingRect = QRect();
- dirtyRegion = QRegion();
- }
-
- inline void dispatchPendingUpdateRequests()
- {
-#ifdef Q_WS_MAC
- // QWidget::update() works slightly different on the Mac without the raster engine;
- // it's not part of our backing store so it needs special threatment.
- if (QApplicationPrivate::graphics_system_name != QLatin1String("raster")) {
- // At this point either HIViewSetNeedsDisplay (Carbon) or setNeedsDisplay: YES (Cocoa)
- // is called, which means there's a pending update request. We want to dispatch it
- // now because otherwise graphics view updates would require two
- // round-trips in the event loop before the item is painted.
- extern void qt_mac_dispatchPendingUpdateRequests(QWidget *);
- qt_mac_dispatchPendingUpdateRequests(viewport->window());
- } else
-#endif // !Q_WS_MAC
- {
- if (qt_widget_private(viewport)->paintOnScreen())
- QCoreApplication::sendPostedEvents(viewport, QEvent::UpdateRequest);
- else
- QCoreApplication::sendPostedEvents(viewport->window(), QEvent::UpdateRequest);
- }
- }
-
- void setUpdateClip(QGraphicsItem *);
-
- inline bool updateRectF(const QRectF &rect)
- {
- if (rect.isEmpty())
- return false;
- if (optimizationFlags & QGraphicsView::DontAdjustForAntialiasing)
- return updateRect(rect.toAlignedRect().adjusted(-1, -1, 1, 1));
- return updateRect(rect.toAlignedRect().adjusted(-2, -2, 2, 2));
- }
-
- bool updateRect(const QRect &rect);
- bool updateRegion(const QRectF &rect, const QTransform &xform);
- bool updateSceneSlotReimplementedChecked;
- QRegion exposedRegion;
-
- QList<QGraphicsItem *> findItems(const QRegion &exposedRegion, bool *allItems,
- const QTransform &viewTransform) const;
-
- QPointF mapToScene(const QPointF &point) const;
- QRectF mapToScene(const QRectF &rect) const;
- static void translateTouchEvent(QGraphicsViewPrivate *d, QTouchEvent *touchEvent);
- void updateInputMethodSensitivity();
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_GRAPHICSVIEW
-
-#endif
diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp
deleted file mode 100644
index 675a5c5c77..0000000000
--- a/src/gui/graphicsview/qgraphicswidget.cpp
+++ /dev/null
@@ -1,2388 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qglobal.h"
-
-#ifndef QT_NO_GRAPHICSVIEW
-
-#include "qgraphicswidget.h"
-#include "qgraphicswidget_p.h"
-#include "qgraphicslayout.h"
-#include "qgraphicslayout_p.h"
-#include "qgraphicsscene.h"
-#include "qgraphicssceneevent.h"
-
-#ifndef QT_NO_ACTION
-#include <private/qaction_p.h>
-#endif
-#include <private/qapplication_p.h>
-#include <private/qgraphicsscene_p.h>
-#ifndef QT_NO_SHORTCUT
-#include <private/qshortcutmap_p.h>
-#endif
-#include <QtCore/qmutex.h>
-#include <QtGui/qapplication.h>
-#include <QtGui/qgraphicsview.h>
-#include <QtGui/qgraphicsproxywidget.h>
-#include <QtGui/qpalette.h>
-#include <QtGui/qstyleoption.h>
-
-#include <qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QGraphicsWidget
- \brief The QGraphicsWidget class is the base class for all widget
- items in a QGraphicsScene.
- \since 4.4
- \ingroup graphicsview-api
-
- QGraphicsWidget is an extended base item that provides extra functionality
- over QGraphicsItem. It is similar to QWidget in many ways:
-
- \list
- \o Provides a \l palette, a \l font and a \l style().
- \o Has a defined geometry().
- \o Supports layouts with setLayout() and layout().
- \o Supports shortcuts and actions with grabShortcut() and insertAction()
- \endlist
-
- Unlike QGraphicsItem, QGraphicsWidget is not an abstract class; you can
- create instances of a QGraphicsWidget without having to subclass it.
- This approach is useful for widgets that only serve the purpose of
- organizing child widgets into a layout.
-
- QGraphicsWidget can be used as a base item for your own custom item if
- you require advanced input focus handling, e.g., tab focus and activation, or
- layouts.
-
- Since QGraphicsWidget resembles QWidget and has similar API, it is
- easier to port a widget from QWidget to QGraphicsWidget, instead of
- QGraphicsItem.
-
- \note QWidget-based widgets can be directly embedded into a
- QGraphicsScene using QGraphicsProxyWidget.
-
- Noticeable differences between QGraphicsWidget and QWidget are:
-
- \table
- \header \o QGraphicsWidget
- \o QWidget
- \row \o Coordinates and geometry are defined with qreals (doubles or
- floats, depending on the platform).
- \o QWidget uses integer geometry (QPoint, QRect).
- \row \o The widget is already visible by default; you do not have to
- call show() to display the widget.
- \o QWidget is hidden by default until you call show().
- \row \o A subset of widget attributes are supported.
- \o All widget attributes are supported.
- \row \o A top-level item's style defaults to QGraphicsScene::style
- \o A top-level widget's style defaults to QApplication::style
- \row \o Graphics View provides a custom drag and drop framework, different
- from QWidget.
- \o Standard drag and drop framework.
- \row \o Widget items do not support modality.
- \o Full modality support.
- \endtable
-
- QGraphicsWidget supports a subset of Qt's widget attributes,
- (Qt::WidgetAttribute), as shown in the table below. Any attributes not
- listed in this table are unsupported, or otherwise unused.
-
- \table
- \header \o Widget Attribute \o Usage
- \row \o Qt::WA_SetLayoutDirection
- \o Set by setLayoutDirection(), cleared by
- unsetLayoutDirection(). You can test this attribute to
- check if the widget has been explicitly assigned a
- \l{QGraphicsWidget::layoutDirection()}
- {layoutDirection}. If the attribute is not set, the
- \l{QGraphicsWidget::layoutDirection()}
- {layoutDirection()} is inherited.
- \row \o Qt::WA_RightToLeft
- \o Toggled by setLayoutDirection(). Inherited from the
- parent/scene. If set, the widget's layout will order
- horizontally arranged widgets from right to left.
- \row \o Qt::WA_SetStyle
- \o Set and cleared by setStyle(). If this attribute is
- set, the widget has been explicitly assigned a style.
- If it is unset, the widget will use the scene's or the
- application's style.
- \row \o Qt::WA_Resized
- \o Set by setGeometry() and resize().
- \row \o Qt::WA_SetPalette
- \o Set by setPalette().
- \row \o Qt::WA_SetFont
- \o Set by setPalette().
- \row \o Qt::WA_WindowPropagation
- \o Enables propagation to window widgets.
- \endtable
-
- Although QGraphicsWidget inherits from both QObject and QGraphicsItem,
- you should use the functions provided by QGraphicsItem, \e not QObject, to
- manage the relationships between parent and child items. These functions
- control the stacking order of items as well as their ownership.
-
- \note The QObject::parent() should always return 0 for QGraphicsWidgets,
- but this policy is not strictly defined.
-
- \sa QGraphicsProxyWidget, QGraphicsItem, {Widgets and Layouts}
-*/
-
-/*!
- Constructs a QGraphicsWidget instance. The optional \a parent argument is
- passed to QGraphicsItem's constructor. The optional \a wFlags argument
- specifies the widget's window flags (e.g., whether the widget should be a
- window, a tool, a popup, etc).
-*/
-QGraphicsWidget::QGraphicsWidget(QGraphicsItem *parent, Qt::WindowFlags wFlags)
- : QGraphicsObject(*new QGraphicsWidgetPrivate, 0, 0), QGraphicsLayoutItem(0, false)
-{
- Q_D(QGraphicsWidget);
- d->init(parent, wFlags);
-}
-
-/*!
- \internal
-
- Constructs a new QGraphicsWidget, using \a dd as parent.
-*/
-QGraphicsWidget::QGraphicsWidget(QGraphicsWidgetPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene, Qt::WindowFlags wFlags)
- : QGraphicsObject(dd, 0, scene), QGraphicsLayoutItem(0, false)
-{
- Q_D(QGraphicsWidget);
- d->init(parent, wFlags);
-}
-
-/*
- \internal
- \class QGraphicsWidgetStyles
-
- We use this thread-safe class to maintain a hash of styles for widgets
- styles. Note that QApplication::style() itself isn't thread-safe, QStyle
- isn't thread-safe, and we don't have a thread-safe factory for creating
- the default style, nor cloning a style.
-*/
-class QGraphicsWidgetStyles
-{
-public:
- QStyle *styleForWidget(const QGraphicsWidget *widget) const
- {
- QMutexLocker locker(&mutex);
- return styles.value(widget, 0);
- }
-
- void setStyleForWidget(QGraphicsWidget *widget, QStyle *style)
- {
- QMutexLocker locker(&mutex);
- if (style)
- styles[widget] = style;
- else
- styles.remove(widget);
- }
-
-private:
- QMap<const QGraphicsWidget *, QStyle *> styles;
- mutable QMutex mutex;
-};
-Q_GLOBAL_STATIC(QGraphicsWidgetStyles, widgetStyles)
-
-/*!
- Destroys the QGraphicsWidget instance.
-*/
-QGraphicsWidget::~QGraphicsWidget()
-{
- Q_D(QGraphicsWidget);
-#ifndef QT_NO_ACTION
- // Remove all actions from this widget
- for (int i = 0; i < d->actions.size(); ++i) {
- QActionPrivate *apriv = d->actions.at(i)->d_func();
- apriv->graphicsWidgets.removeAll(this);
- }
- d->actions.clear();
-#endif
-
- if (QGraphicsScene *scn = scene()) {
- QGraphicsScenePrivate *sceneD = scn->d_func();
- if (sceneD->tabFocusFirst == this)
- sceneD->tabFocusFirst = (d->focusNext == this ? 0 : d->focusNext);
- }
- d->focusPrev->d_func()->focusNext = d->focusNext;
- d->focusNext->d_func()->focusPrev = d->focusPrev;
-
- // Play it really safe
- d->focusNext = this;
- d->focusPrev = this;
-
- clearFocus();
-
- //we check if we have a layout previously
- if (d->layout) {
- QGraphicsLayout *temp = d->layout;
- foreach (QGraphicsItem * item, childItems()) {
- // In case of a custom layout which doesn't remove and delete items, we ensure that
- // the parent layout item does not point to the deleted layout. This code is here to
- // avoid regression from 4.4 to 4.5, because according to 4.5 docs it is not really needed.
- if (item->isWidget()) {
- QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
- if (widget->parentLayoutItem() == d->layout)
- widget->setParentLayoutItem(0);
- }
- }
- d->layout = 0;
- delete temp;
- }
-
- // Remove this graphics widget from widgetStyles
- widgetStyles()->setStyleForWidget(this, 0);
-}
-
-/*!
- \property QGraphicsWidget::size
- \brief the size of the widget
-
- Calling resize() resizes the widget to a \a size bounded by minimumSize()
- and maximumSize(). This property only affects the widget's width and
- height (e.g., its right and bottom edges); the widget's position and
- top-left corner remains unaffected.
-
- Resizing a widget triggers the widget to immediately receive a
- \l{QEvent::GraphicsSceneResize}{GraphicsSceneResize} event with the
- widget's old and new size. If the widget has a layout assigned when this
- event arrives, the layout will be activated and it will automatically
- update any child widgets's geometry.
-
- This property does not affect any layout of the parent widget. If the
- widget itself is managed by a parent layout; e.g., it has a parent widget
- with a layout assigned, that layout will not activate.
-
- By default, this property contains a size with zero width and height.
-
- \sa setGeometry(), QGraphicsSceneResizeEvent, QGraphicsLayout
-*/
-QSizeF QGraphicsWidget::size() const
-{
- return QGraphicsLayoutItem::geometry().size();
-}
-
-void QGraphicsWidget::resize(const QSizeF &size)
-{
- setGeometry(QRectF(pos(), size));
-}
-
-/*!
- \fn void QGraphicsWidget::resize(qreal w, qreal h)
-
- This convenience function is equivalent to calling resize(QSizeF(w, h)).
-
- \sa setGeometry(), setTransform()
-*/
-
-/*!
- \property QGraphicsWidget::sizePolicy
- \brief the size policy for the widget
- \sa sizePolicy(), setSizePolicy(), QWidget::sizePolicy()
-*/
-
-/*!
- \fn QGraphicsWidget::geometryChanged()
-
- This signal gets emitted whenever the geometry is changed in setGeometry().
-*/
-
-/*!
- \property QGraphicsWidget::geometry
- \brief the geometry of the widget
-
- Sets the item's geometry to \a rect. The item's position and size are
- modified as a result of calling this function. The item is first moved,
- then resized.
-
- A side effect of calling this function is that the widget will receive
- a move event and a resize event. Also, if the widget has a layout
- assigned, the layout will activate.
-
- \sa geometry(), resize()
-*/
-void QGraphicsWidget::setGeometry(const QRectF &rect)
-{
- QGraphicsWidgetPrivate *wd = QGraphicsWidget::d_func();
- QGraphicsLayoutItemPrivate *d = QGraphicsLayoutItem::d_ptr.data();
- QRectF newGeom;
- QPointF oldPos = d->geom.topLeft();
- if (!wd->inSetPos) {
- setAttribute(Qt::WA_Resized);
- newGeom = rect;
- newGeom.setSize(rect.size().expandedTo(effectiveSizeHint(Qt::MinimumSize))
- .boundedTo(effectiveSizeHint(Qt::MaximumSize)));
- if (newGeom == d->geom)
- return;
-
- // setPos triggers ItemPositionChange, which can adjust position
- wd->inSetGeometry = 1;
- setPos(newGeom.topLeft());
- wd->inSetGeometry = 0;
- newGeom.moveTopLeft(pos());
-
- if (newGeom == d->geom)
- return;
-
- // Update and prepare to change the geometry (remove from index) if the size has changed.
- if (wd->scene) {
- if (rect.topLeft() == d->geom.topLeft()) {
- prepareGeometryChange();
- }
- }
- }
-
- // Update the layout item geometry
- bool moved = oldPos != pos();
- if (moved) {
- // Send move event.
- QGraphicsSceneMoveEvent event;
- event.setOldPos(oldPos);
- event.setNewPos(pos());
- QApplication::sendEvent(this, &event);
- if (wd->inSetPos) {
- //set the new pos
- d->geom.moveTopLeft(pos());
- emit geometryChanged();
- return;
- }
- }
- QSizeF oldSize = size();
- QGraphicsLayoutItem::setGeometry(newGeom);
- // Send resize event
- bool resized = newGeom.size() != oldSize;
- if (resized) {
- QGraphicsSceneResizeEvent re;
- re.setOldSize(oldSize);
- re.setNewSize(newGeom.size());
- if (oldSize.width() != newGeom.size().width())
- emit widthChanged();
- if (oldSize.height() != newGeom.size().height())
- emit heightChanged();
- QApplication::sendEvent(this, &re);
- }
- emit geometryChanged();
-}
-
-/*!
- \fn QRectF QGraphicsWidget::rect() const
-
- Returns the item's local rect as a QRectF. This function is equivalent
- to QRectF(QPointF(), size()).
-
- \sa setGeometry(), resize()
-*/
-
-/*!
- \fn void QGraphicsWidget::setGeometry(qreal x, qreal y, qreal w, qreal h)
-
- This convenience function is equivalent to calling setGeometry(QRectF(
- \a x, \a y, \a w, \a h)).
-
- \sa geometry(), resize()
-*/
-
-/*!
- \property QGraphicsWidget::minimumSize
- \brief the minimum size of the widget
-
- \sa setMinimumSize(), minimumSize(), preferredSize, maximumSize
-*/
-
-/*!
- \property QGraphicsWidget::preferredSize
- \brief the preferred size of the widget
-
- \sa setPreferredSize(), preferredSize(), minimumSize, maximumSize
-*/
-
-/*!
- \property QGraphicsWidget::maximumSize
- \brief the maximum size of the widget
-
- \sa setMaximumSize(), maximumSize(), minimumSize, preferredSize
-*/
-
-/*!
- Sets the widget's contents margins to \a left, \a top, \a right and \a
- bottom.
-
- Contents margins are used by the assigned layout to define the placement
- of subwidgets and layouts. Margins are particularly useful for widgets
- that constrain subwidgets to only a section of its own geometry. For
- example, a group box with a layout will place subwidgets inside its frame,
- but below the title.
-
- Changing a widget's contents margins will always trigger an update(), and
- any assigned layout will be activated automatically. The widget will then
- receive a \l{QEvent::ContentsRectChange}{ContentsRectChange} event.
-
- \sa getContentsMargins(), setGeometry()
-*/
-void QGraphicsWidget::setContentsMargins(qreal left, qreal top, qreal right, qreal bottom)
-{
- Q_D(QGraphicsWidget);
-
- if (!d->margins && left == 0 && top == 0 && right == 0 && bottom == 0)
- return;
- d->ensureMargins();
- if (left == d->margins[d->Left]
- && top == d->margins[d->Top]
- && right == d->margins[d->Right]
- && bottom == d->margins[d->Bottom])
- return;
-
- d->margins[d->Left] = left;
- d->margins[d->Top] = top;
- d->margins[d->Right] = right;
- d->margins[d->Bottom] = bottom;
-
- if (QGraphicsLayout *l = d->layout)
- l->invalidate();
- else
- updateGeometry();
-
- QEvent e(QEvent::ContentsRectChange);
- QApplication::sendEvent(this, &e);
-}
-
-/*!
- Gets the widget's contents margins. The margins are stored in \a left, \a
- top, \a right and \a bottom, as pointers to qreals. Each argument can
- be \e {omitted} by passing 0.
-
- \sa setContentsMargins()
-*/
-void QGraphicsWidget::getContentsMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const
-{
- Q_D(const QGraphicsWidget);
- if (left || top || right || bottom)
- d->ensureMargins();
- if (left)
- *left = d->margins[d->Left];
- if (top)
- *top = d->margins[d->Top];
- if (right)
- *right = d->margins[d->Right];
- if (bottom)
- *bottom = d->margins[d->Bottom];
-}
-
-/*!
- Sets the widget's window frame margins to \a left, \a top, \a right and
- \a bottom. The default frame margins are provided by the style, and they
- depend on the current window flags.
-
- If you would like to draw your own window decoration, you can set your
- own frame margins to override the default margins.
-
- \sa unsetWindowFrameMargins(), getWindowFrameMargins(), windowFrameRect()
-*/
-void QGraphicsWidget::setWindowFrameMargins(qreal left, qreal top, qreal right, qreal bottom)
-{
- Q_D(QGraphicsWidget);
-
- if (!d->windowFrameMargins && left == 0 && top == 0 && right == 0 && bottom == 0)
- return;
- d->ensureWindowFrameMargins();
- bool unchanged =
- d->windowFrameMargins[d->Left] == left
- && d->windowFrameMargins[d->Top] == top
- && d->windowFrameMargins[d->Right] == right
- && d->windowFrameMargins[d->Bottom] == bottom;
- if (d->setWindowFrameMargins && unchanged)
- return;
- if (!unchanged)
- prepareGeometryChange();
- d->windowFrameMargins[d->Left] = left;
- d->windowFrameMargins[d->Top] = top;
- d->windowFrameMargins[d->Right] = right;
- d->windowFrameMargins[d->Bottom] = bottom;
- d->setWindowFrameMargins = true;
-}
-
-/*!
- Gets the widget's window frame margins. The margins are stored in \a left,
- \a top, \a right and \a bottom as pointers to qreals. Each argument can
- be \e {omitted} by passing 0.
-
- \sa setWindowFrameMargins(), windowFrameRect()
-*/
-void QGraphicsWidget::getWindowFrameMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const
-{
- Q_D(const QGraphicsWidget);
- if (left || top || right || bottom)
- d->ensureWindowFrameMargins();
- if (left)
- *left = d->windowFrameMargins[d->Left];
- if (top)
- *top = d->windowFrameMargins[d->Top];
- if (right)
- *right = d->windowFrameMargins[d->Right];
- if (bottom)
- *bottom = d->windowFrameMargins[d->Bottom];
-}
-
-/*!
- Resets the window frame margins to the default value, provided by the style.
-
- \sa setWindowFrameMargins(), getWindowFrameMargins(), windowFrameRect()
-*/
-void QGraphicsWidget::unsetWindowFrameMargins()
-{
- Q_D(QGraphicsWidget);
- if ((d->windowFlags & Qt::Window) && (d->windowFlags & Qt::WindowType_Mask) != Qt::Popup &&
- (d->windowFlags & Qt::WindowType_Mask) != Qt::ToolTip && !(d->windowFlags & Qt::FramelessWindowHint)) {
- QStyleOptionTitleBar bar;
- d->initStyleOptionTitleBar(&bar);
- QStyle *style = this->style();
- qreal margin = style->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth);
- qreal titleBarHeight = d->titleBarHeight(bar);
- setWindowFrameMargins(margin, titleBarHeight, margin, margin);
- } else {
- setWindowFrameMargins(0, 0, 0, 0);
- }
- d->setWindowFrameMargins = false;
-}
-
-/*!
- Returns the widget's geometry in parent coordinates including any window
- frame.
-
- \sa windowFrameRect(), getWindowFrameMargins(), setWindowFrameMargins()
-*/
-QRectF QGraphicsWidget::windowFrameGeometry() const
-{
- Q_D(const QGraphicsWidget);
- return d->windowFrameMargins
- ? geometry().adjusted(-d->windowFrameMargins[d->Left], -d->windowFrameMargins[d->Top],
- d->windowFrameMargins[d->Right], d->windowFrameMargins[d->Bottom])
- : geometry();
-}
-
-/*!
- Returns the widget's local rect including any window frame.
-
- \sa windowFrameGeometry(), getWindowFrameMargins(), setWindowFrameMargins()
-*/
-QRectF QGraphicsWidget::windowFrameRect() const
-{
- Q_D(const QGraphicsWidget);
- return d->windowFrameMargins
- ? rect().adjusted(-d->windowFrameMargins[d->Left], -d->windowFrameMargins[d->Top],
- d->windowFrameMargins[d->Right], d->windowFrameMargins[d->Bottom])
- : rect();
-}
-
-/*!
- Populates a style option object for this widget based on its current
- state, and stores the output in \a option. The default implementation
- populates \a option with the following properties.
-
- \table
- \header
- \o Style Option Property
- \o Value
- \row
- \o state & QStyle::State_Enabled
- \o Corresponds to QGraphicsItem::isEnabled().
- \row
- \o state & QStyle::State_HasFocus
- \o Corresponds to QGraphicsItem::hasFocus().
- \row
- \o state & QStyle::State_MouseOver
- \o Corresponds to QGraphicsItem::isUnderMouse().
- \row
- \o direction
- \o Corresponds to QGraphicsWidget::layoutDirection().
- \row
- \o rect
- \o Corresponds to QGraphicsWidget::rect().toRect().
- \row
- \o palette
- \o Corresponds to QGraphicsWidget::palette().
- \row
- \o fontMetrics
- \o Corresponds to QFontMetrics(QGraphicsWidget::font()).
- \endtable
-
- Subclasses of QGraphicsWidget should call the base implementation, and
- then test the type of \a option using qstyleoption_cast<>() or test
- QStyleOption::Type before storing widget-specific options.
-
- For example:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp 0
-
- \sa QStyleOption::initFrom()
-*/
-void QGraphicsWidget::initStyleOption(QStyleOption *option) const
-{
- Q_ASSERT(option);
-
- option->state = QStyle::State_None;
- if (isEnabled())
- option->state |= QStyle::State_Enabled;
- if (hasFocus())
- option->state |= QStyle::State_HasFocus;
- // if (window->testAttribute(Qt::WA_KeyboardFocusChange)) // ### Window
- // option->state |= QStyle::State_KeyboardFocusChange;
- if (isUnderMouse())
- option->state |= QStyle::State_MouseOver;
- if (QGraphicsWidget *w = window()) {
- if (w->isActiveWindow())
- option->state |= QStyle::State_Active;
- }
- if (isWindow())
- option->state |= QStyle::State_Window;
- /*
- ###
-#ifdef Q_WS_MAC
- extern bool qt_mac_can_clickThrough(const QGraphicsWidget *w); //qwidget_mac.cpp
- if (!(option->state & QStyle::State_Active) && !qt_mac_can_clickThrough(widget))
- option->state &= ~QStyle::State_Enabled;
-
- switch (QMacStyle::widgetSizePolicy(widget)) {
- case QMacStyle::SizeSmall:
- option->state |= QStyle::State_Small;
- break;
- case QMacStyle::SizeMini:
- option->state |= QStyle::State_Mini;
- break;
- default:
- ;
- }
-#endif
-#ifdef QT_KEYPAD_NAVIGATION
- if (widget->hasEditFocus())
- state |= QStyle::State_HasEditFocus;
-#endif
- */
- option->direction = layoutDirection();
- option->rect = rect().toRect(); // ### truncation!
- option->palette = palette();
- if (!isEnabled()) {
- option->palette.setCurrentColorGroup(QPalette::Disabled);
- } else if (isActiveWindow()) {
- option->palette.setCurrentColorGroup(QPalette::Active);
- } else {
- option->palette.setCurrentColorGroup(QPalette::Inactive);
- }
- option->fontMetrics = QFontMetrics(font());
-}
-
-/*!
- \reimp
-*/
-QSizeF QGraphicsWidget::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
-{
- Q_D(const QGraphicsWidget);
- QSizeF sh;
- if (d->layout) {
- QSizeF marginSize(0,0);
- if (d->margins) {
- marginSize = QSizeF(d->margins[d->Left] + d->margins[d->Right],
- d->margins[d->Top] + d->margins[d->Bottom]);
- }
- sh = d->layout->effectiveSizeHint(which, constraint - marginSize);
- sh += marginSize;
- } else {
- switch (which) {
- case Qt::MinimumSize:
- sh = QSizeF(0, 0);
- break;
- case Qt::PreferredSize:
- sh = QSizeF(50, 50); //rather arbitrary
- break;
- case Qt::MaximumSize:
- sh = QSizeF(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
- break;
- default:
- qWarning("QGraphicsWidget::sizeHint(): Don't know how to handle the value of 'which'");
- break;
- }
- }
- return sh;
-}
-
-/*!
- \property QGraphicsWidget::layout
- \brief The layout of the widget
-
- Any existing layout manager is deleted before the new layout is assigned. If
- \a layout is 0, the widget is left without a layout. Existing subwidgets'
- geometries will remain unaffected.
-
- QGraphicsWidget takes ownership of \a layout.
-
- All widgets that are currently managed by \a layout or all of its
- sublayouts, are automatically reparented to this item. The layout is then
- invalidated, and the child widget geometries are adjusted according to
- this item's geometry() and contentsMargins(). Children who are not
- explicitly managed by \a layout remain unaffected by the layout after
- it has been assigned to this widget.
-
- If no layout is currently managing this widget, layout() will return 0.
-
-*/
-
-/*!
- \fn void QGraphicsWidget::layoutChanged()
- This signal gets emitted whenever the layout of the item changes
- \internal
-*/
-
-/*!
- Returns this widget's layout, or 0 if no layout is currently managing this
- widget.
-
- \sa setLayout()
-*/
-QGraphicsLayout *QGraphicsWidget::layout() const
-{
- Q_D(const QGraphicsWidget);
- return d->layout;
-}
-
-/*!
- \fn void QGraphicsWidget::setLayout(QGraphicsLayout *layout)
-
- Sets the layout for this widget to \a layout. Any existing layout manager
- is deleted before the new layout is assigned. If \a layout is 0, the
- widget is left without a layout. Existing subwidgets' geometries will
- remain unaffected.
-
- All widgets that are currently managed by \a layout or all of its
- sublayouts, are automatically reparented to this item. The layout is then
- invalidated, and the child widget geometries are adjusted according to
- this item's geometry() and contentsMargins(). Children who are not
- explicitly managed by \a layout remain unaffected by the layout after
- it has been assigned to this widget.
-
- QGraphicsWidget takes ownership of \a layout.
-
- \sa layout(), QGraphicsLinearLayout::addItem(), QGraphicsLayout::invalidate()
-*/
-void QGraphicsWidget::setLayout(QGraphicsLayout *l)
-{
- Q_D(QGraphicsWidget);
- if (d->layout == l)
- return;
- d->setLayout_helper(l);
- if (!l)
- return;
-
- // Prevent assigning a layout that is already assigned to another widget.
- QGraphicsLayoutItem *oldParent = l->parentLayoutItem();
- if (oldParent && oldParent != this) {
- qWarning("QGraphicsWidget::setLayout: Attempting to set a layout on %s"
- " \"%s\", when the layout already has a parent",
- metaObject()->className(), qPrintable(objectName()));
- return;
- }
-
- // Install and activate the layout.
- l->setParentLayoutItem(this);
- l->d_func()->reparentChildItems(this);
- l->invalidate();
- emit layoutChanged();
-}
-
-/*!
- Adjusts the size of the widget to its effective preferred size hint.
-
- This function is called implicitly when the item is shown for the first
- time.
-
- \sa effectiveSizeHint(), Qt::MinimumSize
-*/
-void QGraphicsWidget::adjustSize()
-{
- QSizeF sz = effectiveSizeHint(Qt::PreferredSize);
- // What if sz is not valid?!
- if (sz.isValid())
- resize(sz);
-}
-
-/*!
- \property QGraphicsWidget::layoutDirection
- \brief the layout direction for this widget.
-
- This property modifies this widget's and all of its descendants'
- Qt::WA_RightToLeft attribute. It also sets this widget's
- Qt::WA_SetLayoutDirection attribute.
-
- The widget's layout direction determines the order in which the layout
- manager horizontally arranges subwidgets of this widget. The default
- value depends on the language and locale of the application, and is
- typically in the same direction as words are read and written. With
- Qt::LeftToRight, the layout starts placing subwidgets from the left
- side of this widget towards the right. Qt::RightToLeft does the opposite -
- the layout will place widgets starting from the right edge moving towards
- the left.
-
- Subwidgets inherit their layout direction from the parent. Top-level
- widget items inherit their layout direction from
- QGraphicsScene::layoutDirection. If you change a widget's layout direction
- by calling setLayoutDirection(), the widget will send itself a
- \l{QEvent::LayoutDirectionChange}{LayoutDirectionChange} event, and then
- propagate the new layout direction to all its descendants.
-
- \sa QWidget::layoutDirection, QApplication::layoutDirection
-*/
-Qt::LayoutDirection QGraphicsWidget::layoutDirection() const
-{
- return testAttribute(Qt::WA_RightToLeft) ? Qt::RightToLeft : Qt::LeftToRight;
-}
-void QGraphicsWidget::setLayoutDirection(Qt::LayoutDirection direction)
-{
- Q_D(QGraphicsWidget);
- setAttribute(Qt::WA_SetLayoutDirection, true);
- d->setLayoutDirection_helper(direction);
-}
-void QGraphicsWidget::unsetLayoutDirection()
-{
- Q_D(QGraphicsWidget);
- setAttribute(Qt::WA_SetLayoutDirection, false);
- d->resolveLayoutDirection();
-}
-
-/*!
- Returns a pointer to the widget's style. If this widget does not have any
- explicitly assigned style, the scene's style is returned instead. In turn,
- if the scene does not have any assigned style, this function returns
- QApplication::style().
-
- \sa setStyle()
-*/
-QStyle *QGraphicsWidget::style() const
-{
- if (QStyle *style = widgetStyles()->styleForWidget(this))
- return style;
- // ### This is not thread-safe. QApplication::style() is not thread-safe.
- return scene() ? scene()->style() : QApplication::style();
-}
-
-/*!
- Sets the widget's style to \a style. QGraphicsWidget does \e not take
- ownership of \a style.
-
- If no style is assigned, or \a style is 0, the widget will use
- QGraphicsScene::style() (if this has been set). Otherwise the widget will
- use QApplication::style().
-
- This function sets the Qt::WA_SetStyle attribute if \a style is not 0;
- otherwise it clears the attribute.
-
- \sa style()
-*/
-void QGraphicsWidget::setStyle(QStyle *style)
-{
- setAttribute(Qt::WA_SetStyle, style != 0);
- widgetStyles()->setStyleForWidget(this, style);
-
- // Deliver StyleChange to the widget itself (doesn't propagate).
- QEvent event(QEvent::StyleChange);
- QApplication::sendEvent(this, &event);
-}
-
-/*!
- \property QGraphicsWidget::font
- \brief the widgets' font
-
- This property provides the widget's font.
-
- QFont consists of font properties that have been explicitly defined and
- properties implicitly inherited from the widget's parent. Hence, font()
- can return a different font compared to the one set with setFont().
- This scheme allows you to define single entries in a font without
- affecting the font's inherited entries.
-
- When a widget's font changes, it resolves its entries against its
- parent widget. If the widget does not have a parent widget, it resolves
- its entries against the scene. The widget then sends itself a
- \l{QEvent::FontChange}{FontChange} event and notifies all its
- descendants so that they can resolve their fonts as well.
-
- By default, this property contains the application's default font.
-
- \sa QApplication::font(), QGraphicsScene::font, QFont::resolve()
-*/
-QFont QGraphicsWidget::font() const
-{
- Q_D(const QGraphicsWidget);
- QFont fnt = d->font;
- fnt.resolve(fnt.resolve() | d->inheritedFontResolveMask);
- return fnt;
-}
-void QGraphicsWidget::setFont(const QFont &font)
-{
- Q_D(QGraphicsWidget);
- setAttribute(Qt::WA_SetFont, font.resolve() != 0);
-
- QFont naturalFont = d->naturalWidgetFont();
- QFont resolvedFont = font.resolve(naturalFont);
- d->setFont_helper(resolvedFont);
-}
-
-/*!
- \property QGraphicsWidget::palette
- \brief the widget's palette
-
- This property provides the widget's palette. The palette provides colors
- and brushes for color groups (e.g., QPalette::Button) and states (e.g.,
- QPalette::Inactive), loosely defining the general look of the widget and
- its children.
-
- QPalette consists of color groups that have been explicitly defined, and
- groups that are implicitly inherited from the widget's parent. Because of
- this, palette() can return a different palette than what has been set with
- setPalette(). This scheme allows you to define single entries in a palette
- without affecting the palette's inherited entries.
-
- When a widget's palette changes, it resolves its entries against its
- parent widget, or if it doesn't have a parent widget, it resolves against
- the scene. It then sends itself a \l{QEvent::PaletteChange}{PaletteChange}
- event, and notifies all its descendants so they can resolve their palettes
- as well.
-
- By default, this property contains the application's default palette.
-
- \sa QApplication::palette(), QGraphicsScene::palette, QPalette::resolve()
-*/
-QPalette QGraphicsWidget::palette() const
-{
- Q_D(const QGraphicsWidget);
- return d->palette;
-}
-void QGraphicsWidget::setPalette(const QPalette &palette)
-{
- Q_D(QGraphicsWidget);
- setAttribute(Qt::WA_SetPalette, palette.resolve() != 0);
-
- QPalette naturalPalette = d->naturalWidgetPalette();
- QPalette resolvedPalette = palette.resolve(naturalPalette);
- d->setPalette_helper(resolvedPalette);
-}
-
-/*!
- \property QGraphicsWidget::autoFillBackground
- \brief whether the widget background is filled automatically
- \since 4.7
-
- If enabled, this property will cause Qt to fill the background of the
- widget before invoking the paint() method. The color used is defined by the
- QPalette::Window color role from the widget's \l{QPalette}{palette}.
-
- In addition, Windows are always filled with QPalette::Window, unless the
- WA_OpaquePaintEvent or WA_NoSystemBackground attributes are set.
-
- By default, this property is false.
-
- \sa Qt::WA_OpaquePaintEvent, Qt::WA_NoSystemBackground,
-*/
-bool QGraphicsWidget::autoFillBackground() const
-{
- Q_D(const QGraphicsWidget);
- return d->autoFillBackground;
-}
-void QGraphicsWidget::setAutoFillBackground(bool enabled)
-{
- Q_D(QGraphicsWidget);
- if (d->autoFillBackground != enabled) {
- d->autoFillBackground = enabled;
- update();
- }
-}
-
-/*!
- If this widget is currently managed by a layout, this function notifies
- the layout that the widget's size hints have changed and the layout
- may need to resize and reposition the widget accordingly.
-
- Call this function if the widget's sizeHint() has changed.
-
- \sa QGraphicsLayout::invalidate()
-*/
-void QGraphicsWidget::updateGeometry()
-{
- QGraphicsLayoutItem::updateGeometry();
- QGraphicsLayoutItem *parentItem = parentLayoutItem();
-
- if (parentItem && parentItem->isLayout()) {
- parentItem->updateGeometry();
- } else {
- if (parentItem) {
- QGraphicsWidget *parentWid = parentWidget(); //###
- if (parentWid->isVisible())
- QApplication::postEvent(parentWid, new QEvent(QEvent::LayoutRequest));
- }
- bool wasResized = testAttribute(Qt::WA_Resized);
- resize(size()); // this will restrict the size
- setAttribute(Qt::WA_Resized, wasResized);
- }
-}
-
-/*!
- \reimp
-
- QGraphicsWidget uses the base implementation of this function to catch and
- deliver events related to state changes in the item. Because of this, it is
- very important that subclasses call the base implementation.
-
- \a change specifies the type of change, and \a value is the new value.
-
- For example, QGraphicsWidget uses ItemVisibleChange to deliver
- \l{QEvent::Show} {Show} and \l{QEvent::Hide}{Hide} events,
- ItemPositionHasChanged to deliver \l{QEvent::Move}{Move} events,
- and ItemParentChange both to deliver \l{QEvent::ParentChange}
- {ParentChange} events, and for managing the focus chain.
-
- QGraphicsWidget enables the ItemSendsGeometryChanges flag by default in
- order to track position changes.
-
- \sa QGraphicsItem::itemChange()
-*/
-QVariant QGraphicsWidget::itemChange(GraphicsItemChange change, const QVariant &value)
-{
- Q_D(QGraphicsWidget);
- switch (change) {
- case ItemEnabledHasChanged: {
- // Send EnabledChange after the enabled state has changed.
- QEvent event(QEvent::EnabledChange);
- QApplication::sendEvent(this, &event);
- break;
- }
- case ItemVisibleChange:
- if (value.toBool()) {
- // Send Show event before the item has been shown.
- QShowEvent event;
- QApplication::sendEvent(this, &event);
- bool resized = testAttribute(Qt::WA_Resized);
- if (!resized) {
- adjustSize();
- setAttribute(Qt::WA_Resized, false);
- }
- }
- break;
- case ItemVisibleHasChanged:
- if (!value.toBool()) {
- // Send Hide event after the item has been hidden.
- QHideEvent event;
- QApplication::sendEvent(this, &event);
- }
- break;
- case ItemPositionHasChanged:
- d->setGeometryFromSetPos();
- break;
- case ItemParentChange: {
- // Deliver ParentAboutToChange.
- QEvent event(QEvent::ParentAboutToChange);
- QApplication::sendEvent(this, &event);
- break;
- }
- case ItemParentHasChanged: {
- // Deliver ParentChange.
- QEvent event(QEvent::ParentChange);
- QApplication::sendEvent(this, &event);
- break;
- }
- case ItemCursorHasChanged: {
- // Deliver CursorChange.
- QEvent event(QEvent::CursorChange);
- QApplication::sendEvent(this, &event);
- break;
- }
- case ItemToolTipHasChanged: {
- // Deliver ToolTipChange.
- QEvent event(QEvent::ToolTipChange);
- QApplication::sendEvent(this, &event);
- break;
- }
- default:
- break;
- }
- return QGraphicsItem::itemChange(change, value);
-}
-
-/*!
- \internal
-
- This virtual function is used to notify changes to any property (both
- dynamic properties, and registered with Q_PROPERTY) in the
- widget. Depending on the property itself, the notification can be
- delivered before or after the value has changed.
-
- \a propertyName is the name of the property (e.g., "size" or "font"), and
- \a value is the (proposed) new value of the property. The function returns
- the new value, which may be different from \a value if the notification
- supports adjusting the property value. The base implementation simply
- returns \a value for any \a propertyName.
-
- QGraphicsWidget delivers notifications for the following properties:
-
- \table \o propertyName \o Property
- \row \o layoutDirection \o QGraphicsWidget::layoutDirection
- \row \o size \o QGraphicsWidget::size
- \row \o font \o QGraphicsWidget::font
- \row \o palette \o QGraphicsWidget::palette
- \endtable
-
- \sa itemChange()
-*/
-QVariant QGraphicsWidget::propertyChange(const QString &propertyName, const QVariant &value)
-{
- Q_UNUSED(propertyName);
- return value;
-}
-
-/*!
- QGraphicsWidget's implementation of sceneEvent() simply passes \a event to
- QGraphicsWidget::event(). You can handle all events for your widget in
- event() or in any of the convenience functions; you should not have to
- reimplement this function in a subclass of QGraphicsWidget.
-
- \sa QGraphicsItem::sceneEvent()
-*/
-bool QGraphicsWidget::sceneEvent(QEvent *event)
-{
- return QGraphicsItem::sceneEvent(event);
-}
-
-/*!
- This event handler, for \a event, receives events for the window frame if
- this widget is a window. Its base implementation provides support for
- default window frame interaction such as moving, resizing, etc.
-
- You can reimplement this handler in a subclass of QGraphicsWidget to
- provide your own custom window frame interaction support.
-
- Returns true if \a event has been recognized and processed; otherwise,
- returns false.
-
- \sa event()
-*/
-bool QGraphicsWidget::windowFrameEvent(QEvent *event)
-{
- Q_D(QGraphicsWidget);
- switch (event->type()) {
- case QEvent::GraphicsSceneMousePress:
- d->windowFrameMousePressEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
- break;
- case QEvent::GraphicsSceneMouseMove:
- d->ensureWindowData();
- if (d->windowData->grabbedSection != Qt::NoSection) {
- d->windowFrameMouseMoveEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
- event->accept();
- }
- break;
- case QEvent::GraphicsSceneMouseRelease:
- d->windowFrameMouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
- break;
- case QEvent::GraphicsSceneHoverMove:
- d->windowFrameHoverMoveEvent(static_cast<QGraphicsSceneHoverEvent *>(event));
- break;
- case QEvent::GraphicsSceneHoverLeave:
- d->windowFrameHoverLeaveEvent(static_cast<QGraphicsSceneHoverEvent *>(event));
- break;
- default:
- break;
- }
- return event->isAccepted();
-}
-
-/*!
- \since 4.4
-
- Returns the window frame section at position \a pos, or
- Qt::NoSection if there is no window frame section at this
- position.
-
- This function is used in QGraphicsWidget's base implementation for window
- frame interaction.
-
- You can reimplement this function if you want to customize how a window
- can be interactively moved or resized. For instance, if you only want to
- allow a window to be resized by the bottom right corner, you can
- reimplement this function to return Qt::NoSection for all sections except
- Qt::BottomRightSection.
-
- \sa windowFrameEvent(), paintWindowFrame(), windowFrameGeometry()
-*/
-Qt::WindowFrameSection QGraphicsWidget::windowFrameSectionAt(const QPointF &pos) const
-{
- Q_D(const QGraphicsWidget);
-
- const QRectF r = windowFrameRect();
- if (!r.contains(pos))
- return Qt::NoSection;
-
- const qreal left = r.left();
- const qreal top = r.top();
- const qreal right = r.right();
- const qreal bottom = r.bottom();
- const qreal x = pos.x();
- const qreal y = pos.y();
-
- const qreal cornerMargin = 20;
- //### Not sure of this one, it should be the same value for all edges.
- const qreal windowFrameWidth = d->windowFrameMargins
- ? d->windowFrameMargins[d->Left] : 0;
-
- Qt::WindowFrameSection s = Qt::NoSection;
- if (x <= left + cornerMargin) {
- if (y <= top + windowFrameWidth || (x <= left + windowFrameWidth && y <= top + cornerMargin)) {
- s = Qt::TopLeftSection;
- } else if (y >= bottom - windowFrameWidth || (x <= left + windowFrameWidth && y >= bottom - windowFrameWidth)) {
- s = Qt::BottomLeftSection;
- } else if (x <= left + windowFrameWidth) {
- s = Qt::LeftSection;
- }
- } else if (x >= right - cornerMargin) {
- if (y <= top + windowFrameWidth || (x >= right - windowFrameWidth && y <= top + cornerMargin)) {
- s = Qt::TopRightSection;
- } else if (y >= bottom - windowFrameWidth || (x >= right - windowFrameWidth && y >= bottom - windowFrameWidth)) {
- s = Qt::BottomRightSection;
- } else if (x >= right - windowFrameWidth) {
- s = Qt::RightSection;
- }
- } else if (y <= top + windowFrameWidth) {
- s = Qt::TopSection;
- } else if (y >= bottom - windowFrameWidth) {
- s = Qt::BottomSection;
- }
- if (s == Qt::NoSection) {
- QRectF r1 = r;
- r1.setHeight(d->windowFrameMargins
- ? d->windowFrameMargins[d->Top] : 0);
- if (r1.contains(pos))
- s = Qt::TitleBarArea;
- }
- return s;
-}
-
-/*!
- \reimp
-
- Handles the \a event. QGraphicsWidget handles the following
- events:
-
- \table \o Event \o Usage
- \row \o Polish
- \o Delivered to the widget some time after it has been
- shown.
- \row \o GraphicsSceneMove
- \o Delivered to the widget after its local position has
- changed.
- \row \o GraphicsSceneResize
- \o Delivered to the widget after its size has changed.
- \row \o Show
- \o Delivered to the widget before it has been shown.
- \row \o Hide
- \o Delivered to the widget after it has been hidden.
- \row \o PaletteChange
- \o Delivered to the widget after its palette has changed.
- \row \o FontChange
- \o Delivered to the widget after its font has changed.
- \row \o EnabledChange
- \o Delivered to the widget after its enabled state has
- changed.
- \row \o StyleChange
- \o Delivered to the widget after its style has changed.
- \row \o LayoutDirectionChange
- \o Delivered to the widget after its layout direction has
- changed.
- \row \o ContentsRectChange
- \o Delivered to the widget after its contents margins/
- contents rect has changed.
- \endtable
-*/
-bool QGraphicsWidget::event(QEvent *event)
-{
- Q_D(QGraphicsWidget);
- // Forward the event to the layout first.
- if (d->layout)
- d->layout->widgetEvent(event);
-
- // Handle the event itself.
- switch (event->type()) {
- case QEvent::GraphicsSceneMove:
- moveEvent(static_cast<QGraphicsSceneMoveEvent *>(event));
- break;
- case QEvent::GraphicsSceneResize:
- resizeEvent(static_cast<QGraphicsSceneResizeEvent *>(event));
- break;
- case QEvent::Show:
- showEvent(static_cast<QShowEvent *>(event));
- break;
- case QEvent::Hide:
- hideEvent(static_cast<QHideEvent *>(event));
- break;
- case QEvent::Polish:
- polishEvent();
- d->polished = true;
- if (!d->font.isCopyOf(QApplication::font()))
- d->updateFont(d->font);
- break;
- case QEvent::WindowActivate:
- case QEvent::WindowDeactivate:
- update();
- break;
- // Taken from QWidget::event
- case QEvent::ActivationChange:
- case QEvent::EnabledChange:
- case QEvent::FontChange:
- case QEvent::StyleChange:
- case QEvent::PaletteChange:
- case QEvent::ParentChange:
- case QEvent::ContentsRectChange:
- case QEvent::LayoutDirectionChange:
- changeEvent(event);
- break;
- case QEvent::Close:
- closeEvent((QCloseEvent *)event);
- break;
- case QEvent::GrabMouse:
- grabMouseEvent(event);
- break;
- case QEvent::UngrabMouse:
- ungrabMouseEvent(event);
- break;
- case QEvent::GrabKeyboard:
- grabKeyboardEvent(event);
- break;
- case QEvent::UngrabKeyboard:
- ungrabKeyboardEvent(event);
- break;
- case QEvent::GraphicsSceneMousePress:
- if (d->hasDecoration() && windowFrameEvent(event))
- return true;
- case QEvent::GraphicsSceneMouseMove:
- case QEvent::GraphicsSceneMouseRelease:
- case QEvent::GraphicsSceneMouseDoubleClick:
- d->ensureWindowData();
- if (d->hasDecoration() && d->windowData->grabbedSection != Qt::NoSection)
- return windowFrameEvent(event);
- break;
- case QEvent::GraphicsSceneHoverEnter:
- case QEvent::GraphicsSceneHoverMove:
- case QEvent::GraphicsSceneHoverLeave:
- if (d->hasDecoration()) {
- windowFrameEvent(event);
- // Filter out hover events if they were sent to us only because of the
- // decoration (special case in QGraphicsScenePrivate::dispatchHoverEvent).
- if (!acceptsHoverEvents())
- return true;
- }
- break;
- default:
- break;
- }
- return QObject::event(event);
-}
-
-/*!
- This event handler can be reimplemented to handle state changes.
-
- The state being changed in this event can be retrieved through \a event.
-
- Change events include: QEvent::ActivationChange, QEvent::EnabledChange,
- QEvent::FontChange, QEvent::StyleChange, QEvent::PaletteChange,
- QEvent::ParentChange, QEvent::LayoutDirectionChange, and
- QEvent::ContentsRectChange.
-*/
-void QGraphicsWidget::changeEvent(QEvent *event)
-{
- Q_D(QGraphicsWidget);
- switch (event->type()) {
- case QEvent::StyleChange:
- // ### Don't unset if the margins are explicitly set.
- unsetWindowFrameMargins();
- if (d->layout)
- d->layout->invalidate();
- case QEvent::FontChange:
- update();
- updateGeometry();
- break;
- case QEvent::PaletteChange:
- update();
- break;
- case QEvent::ParentChange:
- d->resolveFont(d->inheritedFontResolveMask);
- d->resolvePalette(d->inheritedPaletteResolveMask);
- break;
- default:
- break;
- }
-}
-
-/*!
- This event handler, for \a event, can be reimplemented in a subclass to
- receive widget close events. The default implementation accepts the
- event.
-
- \sa close(), QCloseEvent
-*/
-void QGraphicsWidget::closeEvent(QCloseEvent *event)
-{
- event->accept();
-}
-
-/*!
- \reimp
-*/
-void QGraphicsWidget::focusInEvent(QFocusEvent *event)
-{
- Q_UNUSED(event);
- if (focusPolicy() != Qt::NoFocus)
- update();
-}
-
-/*!
- Finds a new widget to give the keyboard focus to, as appropriate for Tab
- and Shift+Tab, and returns true if it can find a new widget; returns false
- otherwise. If \a next is true, this function searches forward; if \a next
- is false, it searches backward.
-
- Sometimes, you will want to reimplement this function to provide special
- focus handling for your widget and its subwidgets. For example, a web
- browser might reimplement it to move its current active link forward or
- backward, and call the base implementation only when it reaches the last
- or first link on the page.
-
- Child widgets call focusNextPrevChild() on their parent widgets, but only
- the window that contains the child widgets decides where to redirect
- focus. By reimplementing this function for an object, you gain control of
- focus traversal for all child widgets.
-
- \sa focusPolicy()
-*/
-bool QGraphicsWidget::focusNextPrevChild(bool next)
-{
- Q_D(QGraphicsWidget);
- // Let the parent's focusNextPrevChild implementation decide what to do.
- QGraphicsWidget *parent = 0;
- if (!isWindow() && (parent = parentWidget()))
- return parent->focusNextPrevChild(next);
- if (!d->scene)
- return false;
- if (d->scene->focusNextPrevChild(next))
- return true;
- if (isWindow()) {
- setFocus(next ? Qt::TabFocusReason : Qt::BacktabFocusReason);
- if (hasFocus())
- return true;
- }
- return false;
-}
-
-/*!
- \reimp
-*/
-void QGraphicsWidget::focusOutEvent(QFocusEvent *event)
-{
- Q_UNUSED(event);
- if (focusPolicy() != Qt::NoFocus)
- update();
-}
-
-/*!
- This event handler, for \l{QEvent::Hide}{Hide} events, is delivered after
- the widget has been hidden, for example, setVisible(false) has been called
- for the widget or one of its ancestors when the widget was previously
- shown.
-
- You can reimplement this event handler to detect when your widget is
- hidden. Calling QEvent::accept() or QEvent::ignore() on \a event has no
- effect.
-
- \sa showEvent(), QWidget::hideEvent(), ItemVisibleChange
-*/
-void QGraphicsWidget::hideEvent(QHideEvent *event)
-{
- ///### focusNextPrevChild(true), don't lose focus when the focus widget
- // is hidden.
- Q_UNUSED(event);
-}
-
-/*!
- This event handler, for \l{QEvent::GraphicsSceneMove}{GraphicsSceneMove}
- events, is delivered after the widget has moved (e.g., its local position
- has changed).
-
- This event is only delivered when the item is moved locally. Calling
- setTransform() or moving any of the item's ancestors does not affect the
- item's local position.
-
- You can reimplement this event handler to detect when your widget has
- moved. Calling QEvent::accept() or QEvent::ignore() on \a event has no
- effect.
-
- \sa ItemPositionChange, ItemPositionHasChanged
-*/
-void QGraphicsWidget::moveEvent(QGraphicsSceneMoveEvent *event)
-{
- // ### Last position is always == current position
- Q_UNUSED(event);
-}
-
-/*!
- This event is delivered to the item by the scene at some point after it
- has been constructed, but before it is shown or otherwise accessed through
- the scene. You can use this event handler to do last-minute initializations
- of the widget which require the item to be fully constructed.
-
- The base implementation does nothing.
-*/
-void QGraphicsWidget::polishEvent()
-{
-}
-
-/*!
- This event handler, for
- \l{QEvent::GraphicsSceneResize}{GraphicsSceneResize} events, is
- delivered after the widget has been resized (i.e., its local size has
- changed). \a event contains both the old and the new size.
-
- This event is only delivered when the widget is resized locally; calling
- setTransform() on the widget or any of its ancestors or view, does not
- affect the widget's local size.
-
- You can reimplement this event handler to detect when your widget has been
- resized. Calling QEvent::accept() or QEvent::ignore() on \a event has no
- effect.
-
- \sa geometry(), setGeometry()
-*/
-void QGraphicsWidget::resizeEvent(QGraphicsSceneResizeEvent *event)
-{
- Q_UNUSED(event);
-}
-
-/*!
- This event handler, for \l{QEvent::Show}{Show} events, is delivered before
- the widget has been shown, for example, setVisible(true) has been called
- for the widget or one of its ancestors when the widget was previously
- hidden.
-
- You can reimplement this event handler to detect when your widget is
- shown. Calling QEvent::accept() or QEvent::ignore() on \a event has no
- effect.
-
- \sa hideEvent(), QWidget::showEvent(), ItemVisibleChange
-*/
-void QGraphicsWidget::showEvent(QShowEvent *event)
-{
- Q_UNUSED(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsWidget::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
-{
- Q_UNUSED(event);
-}
-
-/*!
- \reimp
-*/
-void QGraphicsWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
-{
- Q_UNUSED(event);
-}
-
-/*!
- This event handler, for \a event, can be reimplemented in a subclass to
- receive notifications for Qt::GrabMouse events.
-
- \sa grabMouse(), grabKeyboard()
-*/
-void QGraphicsWidget::grabMouseEvent(QEvent *event)
-{
- Q_UNUSED(event);
-}
-
-/*!
- This event handler, for \a event, can be reimplemented in a subclass to
- receive notifications for Qt::UngrabMouse events.
-
- \sa ungrabMouse(), ungrabKeyboard()
-*/
-void QGraphicsWidget::ungrabMouseEvent(QEvent *event)
-{
- Q_UNUSED(event);
-}
-
-/*!
- This event handler, for \a event, can be reimplemented in a subclass to
- receive notifications for Qt::GrabKeyboard events.
-
- \sa grabKeyboard(), grabMouse()
-*/
-void QGraphicsWidget::grabKeyboardEvent(QEvent *event)
-{
- Q_UNUSED(event);
-}
-
-/*!
- This event handler, for \a event, can be reimplemented in a subclass to
- receive notifications for Qt::UngrabKeyboard events.
-
- \sa ungrabKeyboard(), ungrabMouse()
-*/
-void QGraphicsWidget::ungrabKeyboardEvent(QEvent *event)
-{
- Q_UNUSED(event);
-}
-
-/*!
- Returns the widgets window type.
-
- \sa windowFlags(), isWindow(), isPanel()
-*/
-Qt::WindowType QGraphicsWidget::windowType() const
-{
- return Qt::WindowType(int(windowFlags()) & Qt::WindowType_Mask);
-}
-
-/*!
- \property QGraphicsWidget::windowFlags
- \brief the widget's window flags
-
- Window flags are a combination of a window type (e.g., Qt::Dialog) and
- several flags giving hints on the behavior of the window. The behavior
- is platform-dependent.
-
- By default, this property contains no window flags.
-
- Windows are panels. If you set the Qt::Window flag, the ItemIsPanel flag
- will be set automatically. If you clear the Qt::Window flag, the
- ItemIsPanel flag is also cleared. Note that the ItemIsPanel flag can be
- set independently of Qt::Window.
-
- \sa isWindow(), isPanel()
-*/
-Qt::WindowFlags QGraphicsWidget::windowFlags() const
-{
- Q_D(const QGraphicsWidget);
- return d->windowFlags;
-}
-void QGraphicsWidget::setWindowFlags(Qt::WindowFlags wFlags)
-{
- Q_D(QGraphicsWidget);
- if (d->windowFlags == wFlags)
- return;
- bool wasPopup = (d->windowFlags & Qt::WindowType_Mask) == Qt::Popup;
-
- d->adjustWindowFlags(&wFlags);
- d->windowFlags = wFlags;
- if (!d->setWindowFrameMargins)
- unsetWindowFrameMargins();
-
- setFlag(ItemIsPanel, d->windowFlags & Qt::Window);
-
- bool isPopup = (d->windowFlags & Qt::WindowType_Mask) == Qt::Popup;
- if (d->scene && isVisible() && wasPopup != isPopup) {
- // Popup state changed; update implicit mouse grab.
- if (!isPopup)
- d->scene->d_func()->removePopup(this);
- else
- d->scene->d_func()->addPopup(this);
- }
-
- if (d->scene && d->scene->d_func()->allItemsIgnoreHoverEvents && d->hasDecoration()) {
- d->scene->d_func()->allItemsIgnoreHoverEvents = false;
- d->scene->d_func()->enableMouseTrackingOnViews();
- }
-}
-
-/*!
- Returns true if this widget's window is in the active window, or if the
- widget does not have a window but is in an active scene (i.e., a scene
- that currently has focus).
-
- The active window is the window that either contains a child widget that
- currently has input focus, or that itself has input focus.
-
- \sa QGraphicsScene::activeWindow(), QGraphicsScene::setActiveWindow(), isActive()
-*/
-bool QGraphicsWidget::isActiveWindow() const
-{
- return isActive();
-}
-
-/*!
- \property QGraphicsWidget::windowTitle
- \brief This property holds the window title (caption).
-
- This property is only used for windows.
-
- By default, if no title has been set, this property contains an
- empty string.
-*/
-void QGraphicsWidget::setWindowTitle(const QString &title)
-{
- Q_D(QGraphicsWidget);
- d->ensureWindowData();
- d->windowData->windowTitle = title;
-}
-QString QGraphicsWidget::windowTitle() const
-{
- Q_D(const QGraphicsWidget);
- return d->windowData ? d->windowData->windowTitle : QString();
-}
-
-/*!
- \property QGraphicsWidget::focusPolicy
- \brief the way the widget accepts keyboard focus
-
- The focus policy is Qt::TabFocus if the widget accepts keyboard focus by
- tabbing, Qt::ClickFocus if the widget accepts focus by clicking,
- Qt::StrongFocus if it accepts both, and Qt::NoFocus (the default) if it
- does not accept focus at all.
-
- You must enable keyboard focus for a widget if it processes keyboard
- events. This is normally done from the widget's constructor. For instance,
- the QLineEdit constructor calls setFocusPolicy(Qt::StrongFocus).
-
- If you enable a focus policy (i.e., not Qt::NoFocus), QGraphicsWidget will
- automatically enable the ItemIsFocusable flag. Setting Qt::NoFocus on a
- widget will clear the ItemIsFocusable flag. If the widget currently has
- keyboard focus, the widget will automatically lose focus.
-
- \sa focusInEvent(), focusOutEvent(), keyPressEvent(), keyReleaseEvent(), enabled
-*/
-Qt::FocusPolicy QGraphicsWidget::focusPolicy() const
-{
- Q_D(const QGraphicsWidget);
- return d->focusPolicy;
-}
-void QGraphicsWidget::setFocusPolicy(Qt::FocusPolicy policy)
-{
- Q_D(QGraphicsWidget);
- if (d->focusPolicy == policy)
- return;
- d->focusPolicy = policy;
- if (hasFocus() && policy == Qt::NoFocus)
- clearFocus();
- setFlag(ItemIsFocusable, policy != Qt::NoFocus);
-}
-
-/*!
- If this widget, a child or descendant of this widget currently has input
- focus, this function will return a pointer to that widget. If
- no descendant widget has input focus, 0 is returned.
-
- \sa QGraphicsItem::focusItem(), QWidget::focusWidget()
-*/
-QGraphicsWidget *QGraphicsWidget::focusWidget() const
-{
- Q_D(const QGraphicsWidget);
- if (d->subFocusItem && d->subFocusItem->d_ptr->isWidget)
- return static_cast<QGraphicsWidget *>(d->subFocusItem);
- return 0;
-}
-
-#ifndef QT_NO_SHORTCUT
-/*!
- \since 4.5
-
- Adds a shortcut to Qt's shortcut system that watches for the given key \a
- sequence in the given \a context. If the \a context is
- Qt::ApplicationShortcut, the shortcut applies to the application as a
- whole. Otherwise, it is either local to this widget, Qt::WidgetShortcut,
- or to the window itself, Qt::WindowShortcut. For widgets that are not part
- of a window (i.e., top-level widgets and their children),
- Qt::WindowShortcut shortcuts apply to the scene.
-
- If the same key \a sequence has been grabbed by several widgets,
- when the key \a sequence occurs a QEvent::Shortcut event is sent
- to all the widgets to which it applies in a non-deterministic
- order, but with the ``ambiguous'' flag set to true.
-
- \warning You should not normally need to use this function;
- instead create \l{QAction}s with the shortcut key sequences you
- require (if you also want equivalent menu options and toolbar
- buttons), or create \l{QShortcut}s if you just need key sequences.
- Both QAction and QShortcut handle all the event filtering for you,
- and provide signals which are triggered when the user triggers the
- key sequence, so are much easier to use than this low-level
- function.
-
- \sa releaseShortcut() setShortcutEnabled() QWidget::grabShortcut()
-*/
-int QGraphicsWidget::grabShortcut(const QKeySequence &sequence, Qt::ShortcutContext context)
-{
- Q_ASSERT(qApp);
- if (sequence.isEmpty())
- return 0;
- // ### setAttribute(Qt::WA_GrabbedShortcut);
- return qApp->d_func()->shortcutMap.addShortcut(this, sequence, context);
-}
-
-/*!
- \since 4.5
-
- Removes the shortcut with the given \a id from Qt's shortcut
- system. The widget will no longer receive QEvent::Shortcut events
- for the shortcut's key sequence (unless it has other shortcuts
- with the same key sequence).
-
- \warning You should not normally need to use this function since
- Qt's shortcut system removes shortcuts automatically when their
- parent widget is destroyed. It is best to use QAction or
- QShortcut to handle shortcuts, since they are easier to use than
- this low-level function. Note also that this is an expensive
- operation.
-
- \sa grabShortcut() setShortcutEnabled() , QWidget::releaseShortcut()
-*/
-void QGraphicsWidget::releaseShortcut(int id)
-{
- Q_ASSERT(qApp);
- if (id)
- qApp->d_func()->shortcutMap.removeShortcut(id, this, 0);
-}
-
-/*!
- \since 4.5
-
- If \a enabled is true, the shortcut with the given \a id is
- enabled; otherwise the shortcut is disabled.
-
- \warning You should not normally need to use this function since
- Qt's shortcut system enables/disables shortcuts automatically as
- widgets become hidden/visible and gain or lose focus. It is best
- to use QAction or QShortcut to handle shortcuts, since they are
- easier to use than this low-level function.
-
- \sa grabShortcut() releaseShortcut(), QWidget::setShortcutEnabled()
-*/
-void QGraphicsWidget::setShortcutEnabled(int id, bool enabled)
-{
- Q_ASSERT(qApp);
- if (id)
- qApp->d_func()->shortcutMap.setShortcutEnabled(enabled, id, this, 0);
-}
-
-/*!
- \since 4.5
-
- If \a enabled is true, auto repeat of the shortcut with the
- given \a id is enabled; otherwise it is disabled.
-
- \sa grabShortcut() releaseShortcut() QWidget::setShortcutAutoRepeat()
-*/
-void QGraphicsWidget::setShortcutAutoRepeat(int id, bool enabled)
-{
- Q_ASSERT(qApp);
- if (id)
- qApp->d_func()->shortcutMap.setShortcutAutoRepeat(enabled, id, this, 0);
-}
-#endif
-
-#ifndef QT_NO_ACTION
-/*!
- \since 4.5
-
- Appends the action \a action to this widget's list of actions.
-
- All QGraphicsWidgets have a list of \l{QAction}s, however they can be
- represented graphically in many different ways. The default use of the
- QAction list (as returned by actions()) is to create a context QMenu.
-
- A QGraphicsWidget should only have one of each action and adding an action
- it already has will not cause the same action to be in the widget twice.
-
- \sa removeAction(), insertAction(), actions(), QWidget::addAction()
-*/
-void QGraphicsWidget::addAction(QAction *action)
-{
- insertAction(0, action);
-}
-
-/*!
- \since 4.5
-
- Appends the actions \a actions to this widget's list of actions.
-
- \sa removeAction(), QMenu, addAction(), QWidget::addActions()
-*/
-void QGraphicsWidget::addActions(QList<QAction *> actions)
-{
- for (int i = 0; i < actions.count(); ++i)
- insertAction(0, actions.at(i));
-}
-
-/*!
- \since 4.5
-
- Inserts the action \a action to this widget's list of actions,
- before the action \a before. It appends the action if \a before is 0 or
- \a before is not a valid action for this widget.
-
- A QGraphicsWidget should only have one of each action.
-
- \sa removeAction(), addAction(), QMenu, actions(),
- QWidget::insertActions()
-*/
-void QGraphicsWidget::insertAction(QAction *before, QAction *action)
-{
- if (!action) {
- qWarning("QWidget::insertAction: Attempt to insert null action");
- return;
- }
-
- Q_D(QGraphicsWidget);
- int index = d->actions.indexOf(action);
- if (index != -1)
- d->actions.removeAt(index);
-
- int pos = d->actions.indexOf(before);
- if (pos < 0) {
- before = 0;
- pos = d->actions.size();
- }
- d->actions.insert(pos, action);
-
- if (index == -1) {
- QActionPrivate *apriv = action->d_func();
- apriv->graphicsWidgets.append(this);
- }
-
- QActionEvent e(QEvent::ActionAdded, action, before);
- QApplication::sendEvent(this, &e);
-}
-
-/*!
- \since 4.5
-
- Inserts the actions \a actions to this widget's list of actions,
- before the action \a before. It appends the action if \a before is 0 or
- \a before is not a valid action for this widget.
-
- A QGraphicsWidget can have at most one of each action.
-
- \sa removeAction(), QMenu, insertAction(), QWidget::insertActions()
-*/
-void QGraphicsWidget::insertActions(QAction *before, QList<QAction *> actions)
-{
- for (int i = 0; i < actions.count(); ++i)
- insertAction(before, actions.at(i));
-}
-
-/*!
- \since 4.5
-
- Removes the action \a action from this widget's list of actions.
-
- \sa insertAction(), actions(), insertAction(), QWidget::removeAction()
-*/
-void QGraphicsWidget::removeAction(QAction *action)
-{
- if (!action)
- return;
-
- Q_D(QGraphicsWidget);
-
- QActionPrivate *apriv = action->d_func();
- apriv->graphicsWidgets.removeAll(this);
-
- if (d->actions.removeAll(action)) {
- QActionEvent e(QEvent::ActionRemoved, action);
- QApplication::sendEvent(this, &e);
- }
-}
-
-/*!
- \since 4.5
-
- Returns the (possibly empty) list of this widget's actions.
-
- \sa insertAction(), removeAction(), QWidget::actions(),
- QAction::associatedWidgets(), QAction::associatedGraphicsWidgets()
-*/
-QList<QAction *> QGraphicsWidget::actions() const
-{
- Q_D(const QGraphicsWidget);
- return d->actions;
-}
-#endif
-
-/*!
- Moves the \a second widget around the ring of focus widgets so that
- keyboard focus moves from the \a first widget to the \a second widget when
- the Tab key is pressed.
-
- Note that since the tab order of the \a second widget is changed, you
- should order a chain like this:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp 1
-
- \e not like this:
-
- \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp 2
-
- If \a first is 0, this indicates that \a second should be the first widget
- to receive input focus should the scene gain Tab focus (i.e., the user
- hits Tab so that focus passes into the scene). If \a second is 0, this
- indicates that \a first should be the first widget to gain focus if the
- scene gained BackTab focus.
-
- By default, tab order is defined implicitly using widget creation order.
-
- \sa focusPolicy, {Keyboard Focus}
-*/
-void QGraphicsWidget::setTabOrder(QGraphicsWidget *first, QGraphicsWidget *second)
-{
- if (!first && !second) {
- qWarning("QGraphicsWidget::setTabOrder(0, 0) is undefined");
- return;
- }
- if ((first && second) && first->scene() != second->scene()) {
- qWarning("QGraphicsWidget::setTabOrder: scenes %p and %p are different",
- first->scene(), second->scene());
- return;
- }
- QGraphicsScene *scene = first ? first->scene() : second->scene();
- if (!scene && (!first || !second)) {
- qWarning("QGraphicsWidget::setTabOrder: assigning tab order from/to the"
- " scene requires the item to be in a scene.");
- return;
- }
-
- // If either first or second are 0, the scene's tabFocusFirst is updated
- // to point to the first item in the scene's focus chain. Then first or
- // second are set to point to tabFocusFirst.
- QGraphicsScenePrivate *sceneD = scene->d_func();
- if (!first) {
- sceneD->tabFocusFirst = second;
- return;
- }
- if (!second) {
- sceneD->tabFocusFirst = first->d_func()->focusNext;
- return;
- }
-
- // Both first and second are != 0.
- QGraphicsWidget *firstFocusNext = first->d_func()->focusNext;
- if (firstFocusNext == second) {
- // Nothing to do.
- return;
- }
-
- // Update the focus chain.
- QGraphicsWidget *secondFocusPrev = second->d_func()->focusPrev;
- QGraphicsWidget *secondFocusNext = second->d_func()->focusNext;
- firstFocusNext->d_func()->focusPrev = second;
- first->d_func()->focusNext = second;
- second->d_func()->focusNext = firstFocusNext;
- second->d_func()->focusPrev = first;
- secondFocusPrev->d_func()->focusNext = secondFocusNext;
- secondFocusNext->d_func()->focusPrev = secondFocusPrev;
-
- Q_ASSERT(first->d_func()->focusNext->d_func()->focusPrev == first);
- Q_ASSERT(first->d_func()->focusPrev->d_func()->focusNext == first);
-
- Q_ASSERT(second->d_func()->focusNext->d_func()->focusPrev == second);
- Q_ASSERT(second->d_func()->focusPrev->d_func()->focusNext == second);
-
-}
-
-/*!
- If \a on is true, this function enables \a attribute; otherwise
- \a attribute is disabled.
-
- See the class documentation for QGraphicsWidget for a complete list of
- which attributes are supported, and what they are for.
-
- \sa testAttribute(), QWidget::setAttribute()
-*/
-void QGraphicsWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
-{
- Q_D(QGraphicsWidget);
- // ### most flags require some immediate action
- // ### we might want to qWarn use of unsupported attributes
- // ### we might want to not use Qt::WidgetAttribute, but roll our own instead
- d->setAttribute(attribute, on);
-}
-
-/*!
- Returns true if \a attribute is enabled for this widget; otherwise,
- returns false.
-
- \sa setAttribute()
-*/
-bool QGraphicsWidget::testAttribute(Qt::WidgetAttribute attribute) const
-{
- Q_D(const QGraphicsWidget);
- return d->testAttribute(attribute);
-}
-
-/*!
- \reimp
-*/
-int QGraphicsWidget::type() const
-{
- return Type;
-}
-
-/*!
- \reimp
-*/
-void QGraphicsWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
-{
- Q_UNUSED(painter);
- Q_UNUSED(option);
- Q_UNUSED(widget);
-}
-
-/*!
- This virtual function is called by QGraphicsScene to draw the window frame
- for windows using \a painter, \a option, and \a widget, in local
- coordinates. The base implementation uses the current style to render the
- frame and title bar.
-
- You can reimplement this function in a subclass of QGraphicsWidget to
- provide custom rendering of the widget's window frame.
-
- \sa QGraphicsItem::paint()
-*/
-void QGraphicsWidget::paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option,
- QWidget *widget)
-{
- const bool fillBackground = !testAttribute(Qt::WA_OpaquePaintEvent)
- && !testAttribute(Qt::WA_NoSystemBackground);
- QGraphicsProxyWidget *proxy = qobject_cast<QGraphicsProxyWidget *>(this);
- const bool embeddedWidgetFillsOwnBackground = proxy && proxy->widget();
-
- if (rect().contains(option->exposedRect)) {
- if (fillBackground && !embeddedWidgetFillsOwnBackground)
- painter->fillRect(option->exposedRect, palette().window());
- return;
- }
-
- Q_D(QGraphicsWidget);
-
- QRect windowFrameRect = QRect(QPoint(), windowFrameGeometry().size().toSize());
- QStyleOptionTitleBar bar;
- bar.QStyleOption::operator=(*option);
- d->initStyleOptionTitleBar(&bar); // this clear flags in bar.state
- d->ensureWindowData();
- if (d->windowData->buttonMouseOver)
- bar.state |= QStyle::State_MouseOver;
- else
- bar.state &= ~QStyle::State_MouseOver;
- if (d->windowData->buttonSunken)
- bar.state |= QStyle::State_Sunken;
- else
- bar.state &= ~QStyle::State_Sunken;
-
- bar.rect = windowFrameRect;
-
- // translate painter to make the style happy
- const QPointF styleOrigin = this->windowFrameRect().topLeft();
- painter->translate(styleOrigin);
-
-#ifdef Q_WS_MAC
- const QSize pixmapSize = windowFrameRect.size();
- if (pixmapSize.width() <= 0 || pixmapSize.height() <= 0)
- return;
- QPainter *realPainter = painter;
- QPixmap pm(pixmapSize);
- painter = new QPainter(&pm);
-#endif
-
- // Fill background
- QStyleHintReturnMask mask;
- bool setMask = style()->styleHint(QStyle::SH_WindowFrame_Mask, &bar, widget, &mask) && !mask.region.isEmpty();
- bool hasBorder = !style()->styleHint(QStyle::SH_TitleBar_NoBorder, &bar, widget);
- int frameWidth = style()->pixelMetric(QStyle::PM_MDIFrameWidth, &bar, widget);
- if (setMask) {
- painter->save();
- painter->setClipRegion(mask.region, Qt::IntersectClip);
- }
- if (fillBackground) {
- if (embeddedWidgetFillsOwnBackground) {
- // Don't fill the background twice.
- QPainterPath windowFrameBackground;
- windowFrameBackground.addRect(windowFrameRect);
- // Adjust with 0.5 to avoid border artifacts between
- // widget background and frame background.
- windowFrameBackground.addRect(rect().translated(-styleOrigin).adjusted(0.5, 0.5, -0.5, -0.5));
- painter->fillPath(windowFrameBackground, palette().window());
- } else {
- painter->fillRect(windowFrameRect, palette().window());
- }
- }
- painter->setRenderHint(QPainter::NonCosmeticDefaultPen);
-
- // Draw title
- int height = (int)d->titleBarHeight(bar);
- bar.rect.setHeight(height);
- if (hasBorder) // Frame is painted by PE_FrameWindow
- bar.rect.adjust(frameWidth, frameWidth, -frameWidth, 0);
-
- painter->save();
- painter->setFont(QApplication::font("QWorkspaceTitleBar"));
- style()->drawComplexControl(QStyle::CC_TitleBar, &bar, painter, widget);
- painter->restore();
- if (setMask)
- painter->restore();
- // Draw window frame
- QStyleOptionFrame frameOptions;
- frameOptions.QStyleOption::operator=(*option);
- initStyleOption(&frameOptions);
- if (!hasBorder)
- painter->setClipRect(windowFrameRect.adjusted(0, +height, 0, 0), Qt::IntersectClip);
- if (hasFocus()) {
- frameOptions.state |= QStyle::State_HasFocus;
- } else {
- frameOptions.state &= ~QStyle::State_HasFocus;
- }
- bool isActive = isActiveWindow();
- if (isActive) {
- frameOptions.state |= QStyle::State_Active;
- } else {
- frameOptions.state &= ~QStyle::State_Active;
- }
-
- frameOptions.palette.setCurrentColorGroup(isActive ? QPalette::Active : QPalette::Normal);
- frameOptions.rect = windowFrameRect;
- frameOptions.lineWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, widget);
- frameOptions.midLineWidth = 1;
- style()->drawPrimitive(QStyle::PE_FrameWindow, &frameOptions, painter, widget);
-
-#ifdef Q_WS_MAC
- realPainter->drawPixmap(QPoint(), pm);
- delete painter;
-#endif
-}
-
-/*!
- \reimp
-*/
-QRectF QGraphicsWidget::boundingRect() const
-{
- return windowFrameRect();
-}
-
-/*!
- \reimp
-*/
-QPainterPath QGraphicsWidget::shape() const
-{
- QPainterPath path;
- path.addRect(rect());
- return path;
-}
-
-/*!
- Call this function to close the widget.
-
- Returns true if the widget was closed; otherwise returns false.
- This slot will first send a QCloseEvent to the widget, which may or may
- not accept the event. If the event was ignored, nothing happens. If the
- event was accepted, it will hide() the widget.
-
- If the widget has the Qt::WA_DeleteOnClose attribute set it will be
- deleted.
-*/
-bool QGraphicsWidget::close()
-{
- QCloseEvent closeEvent;
- QApplication::sendEvent(this, &closeEvent);
- if (!closeEvent.isAccepted()) {
- return false;
- }
- // hide
- if (isVisible()) {
- hide();
- }
- if (testAttribute(Qt::WA_DeleteOnClose)) {
- deleteLater();
- }
- return true;
-}
-
-#ifdef Q_NO_USING_KEYWORD
-/*!
- \fn const QObjectList &QGraphicsWidget::children() const
- \internal
-
- This function returns the same value as QObject::children(). It's
- provided to differentiate between the obsolete member
- QGraphicsItem::children() and QObject::children(). QGraphicsItem now
- provides childItems() instead.
-*/
-#endif
-
-#if 0
-void QGraphicsWidget::dumpFocusChain()
-{
- qDebug() << "=========== Dumping focus chain ==============";
- int i = 0;
- QGraphicsWidget *next = this;
- QSet<QGraphicsWidget*> visited;
- do {
- if (!next) {
- qWarning("Found a focus chain that is not circular, (next == 0)");
- break;
- }
- qDebug() << i++ << QString::number(uint(next), 16) << next->className() << next->data(0) << QString::fromAscii("focusItem:%1").arg(next->hasFocus() ? '1' : '0') << QLatin1String("next:") << next->d_func()->focusNext->data(0) << QLatin1String("prev:") << next->d_func()->focusPrev->data(0);
- if (visited.contains(next)) {
- qWarning("Already visited this node. However, I expected to dump until I found myself.");
- break;
- }
- visited << next;
- next = next->d_func()->focusNext;
- } while (next != this);
-}
-#endif
-
-QT_END_NAMESPACE
-
-#endif //QT_NO_GRAPHICSVIEW
diff --git a/src/gui/graphicsview/qgraphicswidget.h b/src/gui/graphicsview/qgraphicswidget.h
deleted file mode 100644
index 6cbe579608..0000000000
--- a/src/gui/graphicsview/qgraphicswidget.h
+++ /dev/null
@@ -1,257 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSWIDGET_H
-#define QGRAPHICSWIDGET_H
-
-#include <QtGui/qfont.h>
-#include <QtGui/qgraphicslayoutitem.h>
-#include <QtGui/qgraphicsitem.h>
-#include <QtGui/qpalette.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QFont;
-class QFontMetrics;
-class QGraphicsLayout;
-class QGraphicsSceneMoveEvent;
-class QGraphicsWidgetPrivate;
-class QGraphicsSceneResizeEvent;
-class QStyle;
-class QStyleOption;
-
-#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
-
-class QGraphicsWidgetPrivate;
-
-class Q_GUI_EXPORT QGraphicsWidget : public QGraphicsObject, public QGraphicsLayoutItem
-{
- Q_OBJECT
- Q_INTERFACES(QGraphicsItem QGraphicsLayoutItem)
- Q_PROPERTY(QPalette palette READ palette WRITE setPalette)
- Q_PROPERTY(QFont font READ font WRITE setFont)
- Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection RESET unsetLayoutDirection)
- Q_PROPERTY(QSizeF size READ size WRITE resize NOTIFY geometryChanged)
- Q_PROPERTY(QSizeF minimumSize READ minimumSize WRITE setMinimumSize)
- Q_PROPERTY(QSizeF preferredSize READ preferredSize WRITE setPreferredSize)
- Q_PROPERTY(QSizeF maximumSize READ maximumSize WRITE setMaximumSize)
- Q_PROPERTY(QSizePolicy sizePolicy READ sizePolicy WRITE setSizePolicy)
- Q_PROPERTY(Qt::FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy)
- Q_PROPERTY(Qt::WindowFlags windowFlags READ windowFlags WRITE setWindowFlags)
- Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle)
- Q_PROPERTY(QRectF geometry READ geometry WRITE setGeometry NOTIFY geometryChanged)
- Q_PROPERTY(bool autoFillBackground READ autoFillBackground WRITE setAutoFillBackground)
- Q_PROPERTY(QGraphicsLayout* layout READ layout WRITE setLayout NOTIFY layoutChanged)
-public:
- QGraphicsWidget(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
- ~QGraphicsWidget();
- QGraphicsLayout *layout() const;
- void setLayout(QGraphicsLayout *layout);
- void adjustSize();
-
- Qt::LayoutDirection layoutDirection() const;
- void setLayoutDirection(Qt::LayoutDirection direction);
- void unsetLayoutDirection();
-
- QStyle *style() const;
- void setStyle(QStyle *style);
-
- QFont font() const;
- void setFont(const QFont &font);
-
- QPalette palette() const;
- void setPalette(const QPalette &palette);
-
- bool autoFillBackground() const;
- void setAutoFillBackground(bool enabled);
-
- void resize(const QSizeF &size);
- inline void resize(qreal w, qreal h) { resize(QSizeF(w, h)); }
- QSizeF size() const;
-
- void setGeometry(const QRectF &rect);
- inline void setGeometry(qreal x, qreal y, qreal w, qreal h);
- inline QRectF rect() const { return QRectF(QPointF(), size()); }
-
- void setContentsMargins(qreal left, qreal top, qreal right, qreal bottom);
- void getContentsMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const;
-
- void setWindowFrameMargins(qreal left, qreal top, qreal right, qreal bottom);
- void getWindowFrameMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const;
- void unsetWindowFrameMargins();
- QRectF windowFrameGeometry() const;
- QRectF windowFrameRect() const;
-
- // Window handling
- Qt::WindowFlags windowFlags() const;
- Qt::WindowType windowType() const;
- void setWindowFlags(Qt::WindowFlags wFlags);
- bool isActiveWindow() const;
- void setWindowTitle(const QString &title);
- QString windowTitle() const;
-
- // Focus handling
- Qt::FocusPolicy focusPolicy() const;
- void setFocusPolicy(Qt::FocusPolicy policy);
- static void setTabOrder(QGraphicsWidget *first, QGraphicsWidget *second);
- QGraphicsWidget *focusWidget() const;
-
-#ifndef QT_NO_SHORTCUT
- int grabShortcut(const QKeySequence &sequence, Qt::ShortcutContext context = Qt::WindowShortcut);
- void releaseShortcut(int id);
- void setShortcutEnabled(int id, bool enabled = true);
- void setShortcutAutoRepeat(int id, bool enabled = true);
-#endif
-
-#ifndef QT_NO_ACTION
- //actions
- void addAction(QAction *action);
- void addActions(QList<QAction*> actions);
- void insertAction(QAction *before, QAction *action);
- void insertActions(QAction *before, QList<QAction*> actions);
- void removeAction(QAction *action);
- QList<QAction*> actions() const;
-#endif
-
- void setAttribute(Qt::WidgetAttribute attribute, bool on = true);
- bool testAttribute(Qt::WidgetAttribute attribute) const;
-
- enum {
- Type = 11
- };
- int type() const;
-
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
- virtual void paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
- QRectF boundingRect() const;
- QPainterPath shape() const;
-
-#if 0
- void dumpFocusChain();
-#endif
-
- // ### Qt 5: Disambiguate
-#ifdef Q_NO_USING_KEYWORD
- const QObjectList &children() const { return QObject::children(); }
-#else
- using QObject::children;
-#endif
-
-Q_SIGNALS:
- void geometryChanged();
- void layoutChanged();
-
-public Q_SLOTS:
- bool close();
-
-protected:
- virtual void initStyleOption(QStyleOption *option) const;
-
- QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
- void updateGeometry();
-
- // Notification
- QVariant itemChange(GraphicsItemChange change, const QVariant &value);
- virtual QVariant propertyChange(const QString &propertyName, const QVariant &value);
-
- // Scene events
- bool sceneEvent(QEvent *event);
- virtual bool windowFrameEvent(QEvent *e);
- virtual Qt::WindowFrameSection windowFrameSectionAt(const QPointF& pos) const;
-
- // Base event handlers
- bool event(QEvent *event);
- //virtual void actionEvent(QActionEvent *event);
- virtual void changeEvent(QEvent *event);
- virtual void closeEvent(QCloseEvent *event);
- //void create(WId window = 0, bool initializeWindow = true, bool destroyOldWindow = true);
- //void destroy(bool destroyWindow = true, bool destroySubWindows = true);
- void focusInEvent(QFocusEvent *event);
- virtual bool focusNextPrevChild(bool next);
- void focusOutEvent(QFocusEvent *event);
- virtual void hideEvent(QHideEvent *event);
- //virtual bool macEvent(EventHandlerCallRef caller, EventRef event);
- //virtual int metric(PaintDeviceMetric m ) const;
- virtual void moveEvent(QGraphicsSceneMoveEvent *event);
- virtual void polishEvent();
- //virtual bool qwsEvent(QWSEvent *event);
- //void resetInputContext ();
- virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
- virtual void showEvent(QShowEvent *event);
- //virtual void tabletEvent(QTabletEvent *event);
- //virtual bool winEvent(MSG *message, long *result);
- //virtual bool x11Event(XEvent *event);
- virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
- virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
- virtual void grabMouseEvent(QEvent *event);
- virtual void ungrabMouseEvent(QEvent *event);
- virtual void grabKeyboardEvent(QEvent *event);
- virtual void ungrabKeyboardEvent(QEvent *event);
- QGraphicsWidget(QGraphicsWidgetPrivate &, QGraphicsItem *parent, QGraphicsScene *, Qt::WindowFlags wFlags = 0);
-
-private:
- Q_DISABLE_COPY(QGraphicsWidget)
- Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QGraphicsWidget)
- friend class QGraphicsScene;
- friend class QGraphicsScenePrivate;
- friend class QGraphicsView;
- friend class QGraphicsItem;
- friend class QGraphicsItemPrivate;
- friend class QGraphicsLayout;
- friend class QWidget;
- friend class QApplication;
-};
-
-inline void QGraphicsWidget::setGeometry(qreal ax, qreal ay, qreal aw, qreal ah)
-{ setGeometry(QRectF(ax, ay, aw, ah)); }
-
-#endif
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
-
diff --git a/src/gui/graphicsview/qgraphicswidget_p.cpp b/src/gui/graphicsview/qgraphicswidget_p.cpp
deleted file mode 100644
index 63d7298024..0000000000
--- a/src/gui/graphicsview/qgraphicswidget_p.cpp
+++ /dev/null
@@ -1,906 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qglobal.h"
-
-#ifndef QT_NO_GRAPHICSVIEW
-
-#include <QtCore/qdebug.h>
-#include <QtCore/qnumeric.h>
-#include "qgraphicswidget_p.h"
-#include "qgraphicslayoutitem_p.h"
-#include "qgraphicslayout.h"
-#include "qgraphicsscene_p.h"
-#include <QtGui/qapplication.h>
-#include <QtGui/qgraphicsscene.h>
-#include <QtGui/qstyleoption.h>
-#include <QtGui/QStyleOptionTitleBar>
-#include <QtGui/QGraphicsSceneMouseEvent>
-#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC)
-# include <QMacStyle>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-void QGraphicsWidgetPrivate::init(QGraphicsItem *parentItem, Qt::WindowFlags wFlags)
-{
- Q_Q(QGraphicsWidget);
-
- attributes = 0;
- isWidget = 1; // QGraphicsItem::isWidget() returns true.
- focusNext = focusPrev = q;
- focusPolicy = Qt::NoFocus;
-
- adjustWindowFlags(&wFlags);
- windowFlags = wFlags;
-
- if (parentItem)
- setParentItemHelper(parentItem, 0, 0);
-
- q->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred, QSizePolicy::DefaultType));
- q->setGraphicsItem(q);
-
- resolveLayoutDirection();
- q->unsetWindowFrameMargins();
- flags |= QGraphicsItem::ItemUsesExtendedStyleOption;
- flags |= QGraphicsItem::ItemSendsGeometryChanges;
- if (windowFlags & Qt::Window)
- flags |= QGraphicsItem::ItemIsPanel;
-}
-
-qreal QGraphicsWidgetPrivate::titleBarHeight(const QStyleOptionTitleBar &options) const
-{
- Q_Q(const QGraphicsWidget);
- int height = q->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options);
-#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC)
- if (qobject_cast<QMacStyle*>(q->style())) {
- height -=4;
- }
-#endif
- return (qreal)height;
-}
-
-/*!
- \internal
-*/
-QGraphicsWidgetPrivate::~QGraphicsWidgetPrivate()
-{
- // Remove any lazily allocated data
- delete[] margins;
- delete[] windowFrameMargins;
- delete windowData;
-}
-
-/*!
- \internal
-
- Ensures that margins is allocated.
- This function must be called before any dereferencing.
-*/
-void QGraphicsWidgetPrivate::ensureMargins() const
-{
- if (!margins) {
- margins = new qreal[4];
- for (int i = 0; i < 4; ++i)
- margins[i] = 0;
- }
-}
-
-/*!
- \internal
-
- Ensures that windowFrameMargins is allocated.
- This function must be called before any dereferencing.
-*/
-void QGraphicsWidgetPrivate::ensureWindowFrameMargins() const
-{
- if (!windowFrameMargins) {
- windowFrameMargins = new qreal[4];
- for (int i = 0; i < 4; ++i)
- windowFrameMargins[i] = 0;
- }
-}
-
-/*!
- \internal
-
- Ensures that windowData is allocated.
- This function must be called before any dereferencing.
-*/
-void QGraphicsWidgetPrivate::ensureWindowData()
-{
- if (!windowData)
- windowData = new WindowData;
-}
-
-void QGraphicsWidgetPrivate::setPalette_helper(const QPalette &palette)
-{
- if (this->palette == palette && this->palette.resolve() == palette.resolve())
- return;
- updatePalette(palette);
-}
-
-void QGraphicsWidgetPrivate::resolvePalette(uint inheritedMask)
-{
- inheritedPaletteResolveMask = inheritedMask;
- QPalette naturalPalette = naturalWidgetPalette();
- QPalette resolvedPalette = palette.resolve(naturalPalette);
- updatePalette(resolvedPalette);
-}
-
-void QGraphicsWidgetPrivate::updatePalette(const QPalette &palette)
-{
- Q_Q(QGraphicsWidget);
- // Update local palette setting.
- this->palette = palette;
-
- // Calculate new mask.
- if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation))
- inheritedPaletteResolveMask = 0;
- int mask = palette.resolve() | inheritedPaletteResolveMask;
-
- // Propagate to children.
- for (int i = 0; i < children.size(); ++i) {
- QGraphicsItem *item = children.at(i);
- if (item->isWidget()) {
- QGraphicsWidget *w = static_cast<QGraphicsWidget *>(item);
- if (!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))
- w->d_func()->resolvePalette(mask);
- } else {
- item->d_ptr->resolvePalette(mask);
- }
- }
-
- // Notify change.
- QEvent event(QEvent::PaletteChange);
- QApplication::sendEvent(q, &event);
-}
-
-void QGraphicsWidgetPrivate::setLayoutDirection_helper(Qt::LayoutDirection direction)
-{
- Q_Q(QGraphicsWidget);
- if ((direction == Qt::RightToLeft) == (testAttribute(Qt::WA_RightToLeft)))
- return;
- q->setAttribute(Qt::WA_RightToLeft, (direction == Qt::RightToLeft));
-
- // Propagate this change to all children.
- for (int i = 0; i < children.size(); ++i) {
- QGraphicsItem *item = children.at(i);
- if (item->isWidget()) {
- QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
- if (widget->parentWidget() && !widget->testAttribute(Qt::WA_SetLayoutDirection))
- widget->d_func()->setLayoutDirection_helper(direction);
- }
- }
-
- // Send the notification event to this widget item.
- QEvent e(QEvent::LayoutDirectionChange);
- QApplication::sendEvent(q, &e);
-}
-
-void QGraphicsWidgetPrivate::resolveLayoutDirection()
-{
- Q_Q(QGraphicsWidget);
- if (q->testAttribute(Qt::WA_SetLayoutDirection)) {
- return;
- }
- if (QGraphicsWidget *parentWidget = q->parentWidget()) {
- setLayoutDirection_helper(parentWidget->layoutDirection());
- } else if (scene) {
- // ### shouldn't the scene have a layoutdirection really? how does
- // ### QGraphicsWidget get changes from QApplication::layoutDirection?
- setLayoutDirection_helper(QApplication::layoutDirection());
- } else {
- setLayoutDirection_helper(QApplication::layoutDirection());
- }
-}
-
-QPalette QGraphicsWidgetPrivate::naturalWidgetPalette() const
-{
- Q_Q(const QGraphicsWidget);
- QPalette palette;
- if (QGraphicsWidget *parent = q->parentWidget()) {
- palette = parent->palette();
- } else if (scene) {
- palette = scene->palette();
- }
- palette.resolve(0);
- return palette;
-}
-
-void QGraphicsWidgetPrivate::setFont_helper(const QFont &font)
-{
- if (this->font == font && this->font.resolve() == font.resolve())
- return;
- updateFont(font);
-}
-
-void QGraphicsWidgetPrivate::resolveFont(uint inheritedMask)
-{
- Q_Q(QGraphicsWidget);
- inheritedFontResolveMask = inheritedMask;
- if (QGraphicsWidget *p = q->parentWidget())
- inheritedFontResolveMask |= p->d_func()->inheritedFontResolveMask;
- QFont naturalFont = naturalWidgetFont();
- QFont resolvedFont = font.resolve(naturalFont);
- updateFont(resolvedFont);
-}
-
-void QGraphicsWidgetPrivate::updateFont(const QFont &font)
-{
- Q_Q(QGraphicsWidget);
- // Update the local font setting.
- this->font = font;
-
- // Calculate new mask.
- if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation))
- inheritedFontResolveMask = 0;
- int mask = font.resolve() | inheritedFontResolveMask;
-
- // Propagate to children.
- for (int i = 0; i < children.size(); ++i) {
- QGraphicsItem *item = children.at(i);
- if (item->isWidget()) {
- QGraphicsWidget *w = static_cast<QGraphicsWidget *>(item);
- if (!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))
- w->d_func()->resolveFont(mask);
- } else {
- item->d_ptr->resolveFont(mask);
- }
- }
-
- if (!polished)
- return;
- // Notify change.
- QEvent event(QEvent::FontChange);
- QApplication::sendEvent(q, &event);
-}
-
-QFont QGraphicsWidgetPrivate::naturalWidgetFont() const
-{
- Q_Q(const QGraphicsWidget);
- QFont naturalFont; // ### no application font support
- if (QGraphicsWidget *parent = q->parentWidget()) {
- naturalFont = parent->font();
- } else if (scene) {
- naturalFont = scene->font();
- }
- naturalFont.resolve(0);
- return naturalFont;
-}
-
-void QGraphicsWidgetPrivate::initStyleOptionTitleBar(QStyleOptionTitleBar *option)
-{
- Q_Q(QGraphicsWidget);
- ensureWindowData();
- q->initStyleOption(option);
- option->rect.setHeight(titleBarHeight(*option));
- option->titleBarFlags = windowFlags;
- option->subControls = QStyle::SC_TitleBarCloseButton | QStyle::SC_TitleBarLabel | QStyle::SC_TitleBarSysMenu;
- option->activeSubControls = windowData->hoveredSubControl;
- bool isActive = q->isActiveWindow();
- if (isActive) {
- option->state |= QStyle::State_Active;
- option->titleBarState = Qt::WindowActive;
- option->titleBarState |= QStyle::State_Active;
- } else {
- option->state &= ~QStyle::State_Active;
- option->titleBarState = Qt::WindowNoState;
- }
- QFont windowTitleFont = QApplication::font("QWorkspaceTitleBar");
- QRect textRect = q->style()->subControlRect(QStyle::CC_TitleBar, option, QStyle::SC_TitleBarLabel, 0);
- option->text = QFontMetrics(windowTitleFont).elidedText(
- windowData->windowTitle, Qt::ElideRight, textRect.width());
-}
-
-void QGraphicsWidgetPrivate::adjustWindowFlags(Qt::WindowFlags *flags)
-{
- bool customize = (*flags & (Qt::CustomizeWindowHint
- | Qt::FramelessWindowHint
- | Qt::WindowTitleHint
- | Qt::WindowSystemMenuHint
- | Qt::WindowMinimizeButtonHint
- | Qt::WindowMaximizeButtonHint
- | Qt::WindowContextHelpButtonHint));
-
- uint type = (*flags & Qt::WindowType_Mask);
- if (customize)
- ;
- else if (type == Qt::Dialog || type == Qt::Sheet)
- *flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint;
- else if (type == Qt::Tool)
- *flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint;
- else if (type == Qt::Window || type == Qt::SubWindow)
- *flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint
- | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint;
-}
-
-void QGraphicsWidgetPrivate::windowFrameMouseReleaseEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_Q(QGraphicsWidget);
- ensureWindowData();
- if (windowData->grabbedSection != Qt::NoSection) {
- if (windowData->grabbedSection == Qt::TitleBarArea) {
- windowData->buttonSunken = false;
- QStyleOptionTitleBar bar;
- initStyleOptionTitleBar(&bar);
- // make sure that the coordinates (rect and pos) we send to the style are positive.
- bar.rect = q->windowFrameRect().toRect();
- bar.rect.moveTo(0,0);
- bar.rect.setHeight(q->style()->pixelMetric(QStyle::PM_TitleBarHeight, &bar));
- QPointF pos = event->pos();
- if (windowFrameMargins) {
- pos.rx() += windowFrameMargins[Left];
- pos.ry() += windowFrameMargins[Top];
- }
- bar.subControls = QStyle::SC_TitleBarCloseButton;
- if (q->style()->subControlRect(QStyle::CC_TitleBar, &bar,
- QStyle::SC_TitleBarCloseButton,
- event->widget()).contains(pos.toPoint())) {
- q->close();
- }
- }
- if (!(static_cast<QGraphicsSceneMouseEvent *>(event)->buttons()))
- windowData->grabbedSection = Qt::NoSection;
- event->accept();
- }
-}
-
-void QGraphicsWidgetPrivate::windowFrameMousePressEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_Q(QGraphicsWidget);
- if (event->button() != Qt::LeftButton)
- return;
-
- ensureWindowData();
- windowData->startGeometry = q->geometry();
- windowData->grabbedSection = q->windowFrameSectionAt(event->pos());
- ensureWindowData();
- if (windowData->grabbedSection == Qt::TitleBarArea
- && windowData->hoveredSubControl == QStyle::SC_TitleBarCloseButton) {
- windowData->buttonSunken = true;
- q->update();
- }
- event->setAccepted(windowData->grabbedSection != Qt::NoSection);
-}
-
-/*!
- Used to calculate the
- Precondition:
- \a widget should support either hfw or wfh
-
- If \a heightForWidth is set to false, this function will query the width for height
- instead. \a width will then be interpreted as height, \a minh and \a maxh will be interpreted
- as minimum width and maximum width.
- */
-static qreal minimumHeightForWidth(qreal width, qreal minh, qreal maxh,
- const QGraphicsWidget *widget,
- bool heightForWidth = true)
-{
- qreal minimumHeightForWidth = -1;
- const bool hasHFW = QGraphicsLayoutItemPrivate::get(widget)->hasHeightForWidth();
- if (hasHFW == heightForWidth) {
- minimumHeightForWidth = hasHFW
- ? widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(width, -1)).height()
- : widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, width)).width(); //"width" is here height!
- } else {
- // widthForHeight
- const qreal constraint = width;
- while (maxh - minh > 0.1) {
- qreal middle = minh + (maxh - minh)/2;
- // ### really bad, if we are a widget with a layout it will call
- // layout->effectiveSizeHint(Qt::MiniumumSize), which again will call
- // sizeHint three times because of how the cache works
- qreal hfw = hasHFW
- ? widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(middle, -1)).height()
- : widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, middle)).width();
- if (hfw > constraint) {
- minh = middle;
- } else if (hfw <= constraint) {
- maxh = middle;
- }
- }
- minimumHeightForWidth = maxh;
- }
- return minimumHeightForWidth;
-}
-
-static qreal minimumWidthForHeight(qreal height, qreal minw, qreal maxw,
- const QGraphicsWidget *widget)
-{
- return minimumHeightForWidth(height, minw, maxw, widget, false);
-}
-
-static QSizeF closestAcceptableSize(const QSizeF &proposed,
- const QGraphicsWidget *widget)
-{
- const QSizeF current = widget->size();
-
- qreal minw = proposed.width();
- qreal maxw = current.width();
- qreal minh = proposed.height();
- qreal maxh = current.height();
-
- qreal middlew = maxw;
- qreal middleh = maxh;
- qreal min_hfw;
- min_hfw = minimumHeightForWidth(maxw, minh, maxh, widget);
-
- do {
- if (maxw - minw < 0.1) {
- // we still havent found anything, cut off binary search
- minw = maxw;
- minh = maxh;
- }
- middlew = minw + (maxw - minw)/2.0;
- middleh = minh + (maxh - minh)/2.0;
-
- min_hfw = minimumHeightForWidth(middlew, minh, maxh, widget);
-
- if (min_hfw > middleh) {
- minw = middlew;
- minh = middleh;
- } else if (min_hfw <= middleh) {
- maxw = middlew;
- maxh = middleh;
- }
- } while (maxw != minw);
-
- min_hfw = minimumHeightForWidth(middlew, minh, maxh, widget);
-
- QSizeF result;
- if (min_hfw < maxh) {
- result = QSizeF(middlew, min_hfw);
- } else {
- // Needed because of the cut-off we do above.
- result = QSizeF(minimumWidthForHeight(maxh, proposed.width(), current.width(), widget), maxh);
- }
- return result;
-}
-
-static void _q_boundGeometryToSizeConstraints(const QRectF &startGeometry,
- QRectF *rect, Qt::WindowFrameSection section,
- const QSizeF &min, const QSizeF &max,
- const QGraphicsWidget *widget)
-{
- const QRectF proposedRect = *rect;
- qreal width = qBound(min.width(), proposedRect.width(), max.width());
- qreal height = qBound(min.height(), proposedRect.height(), max.height());
-
- const bool hasHFW = QGraphicsLayoutItemPrivate::get(widget)->hasHeightForWidth();
- const bool hasWFH = QGraphicsLayoutItemPrivate::get(widget)->hasWidthForHeight();
-
- const bool widthChanged = proposedRect.width() != widget->size().width();
- const bool heightChanged = proposedRect.height() != widget->size().height();
-
- if (hasHFW || hasWFH) {
- if (widthChanged || heightChanged) {
- qreal minExtent;
- qreal maxExtent;
- qreal constraint;
- qreal proposed;
- if (hasHFW) {
- minExtent = min.height();
- maxExtent = max.height();
- constraint = width;
- proposed = proposedRect.height();
- } else {
- // width for height
- minExtent = min.width();
- maxExtent = max.width();
- constraint = height;
- proposed = proposedRect.width();
- }
- if (minimumHeightForWidth(constraint, minExtent, maxExtent, widget, hasHFW) > proposed) {
- QSizeF effectiveSize = closestAcceptableSize(QSizeF(width, height), widget);
- width = effectiveSize.width();
- height = effectiveSize.height();
- }
- }
- }
-
- switch (section) {
- case Qt::LeftSection:
- rect->setRect(startGeometry.right() - qRound(width), startGeometry.top(),
- qRound(width), startGeometry.height());
- break;
- case Qt::TopLeftSection:
- rect->setRect(startGeometry.right() - qRound(width), startGeometry.bottom() - qRound(height),
- qRound(width), qRound(height));
- break;
- case Qt::TopSection:
- rect->setRect(startGeometry.left(), startGeometry.bottom() - qRound(height),
- startGeometry.width(), qRound(height));
- break;
- case Qt::TopRightSection:
- rect->setTop(rect->bottom() - qRound(height));
- rect->setWidth(qRound(width));
- break;
- case Qt::RightSection:
- rect->setWidth(qRound(width));
- break;
- case Qt::BottomRightSection:
- rect->setWidth(qRound(width));
- rect->setHeight(qRound(height));
- break;
- case Qt::BottomSection:
- rect->setHeight(qRound(height));
- break;
- case Qt::BottomLeftSection:
- rect->setRect(startGeometry.right() - qRound(width), startGeometry.top(),
- qRound(width), qRound(height));
- break;
- default:
- break;
- }
-}
-
-void QGraphicsWidgetPrivate::windowFrameMouseMoveEvent(QGraphicsSceneMouseEvent *event)
-{
- Q_Q(QGraphicsWidget);
- ensureWindowData();
- if (!(event->buttons() & Qt::LeftButton) || windowData->hoveredSubControl != QStyle::SC_TitleBarLabel)
- return;
-
- QLineF delta(q->mapFromScene(event->buttonDownScenePos(Qt::LeftButton)), event->pos());
- QLineF parentDelta(q->mapToParent(delta.p1()), q->mapToParent(delta.p2()));
- QLineF parentXDelta(q->mapToParent(QPointF(delta.p1().x(), 0)), q->mapToParent(QPointF(delta.p2().x(), 0)));
- QLineF parentYDelta(q->mapToParent(QPointF(0, delta.p1().y())), q->mapToParent(QPointF(0, delta.p2().y())));
-
- QRectF newGeometry;
- switch (windowData->grabbedSection) {
- case Qt::LeftSection:
- newGeometry = QRectF(windowData->startGeometry.topLeft()
- + QPointF(parentXDelta.dx(), parentXDelta.dy()),
- windowData->startGeometry.size() - QSizeF(delta.dx(), delta.dy()));
- break;
- case Qt::TopLeftSection:
- newGeometry = QRectF(windowData->startGeometry.topLeft()
- + QPointF(parentDelta.dx(), parentDelta.dy()),
- windowData->startGeometry.size() - QSizeF(delta.dx(), delta.dy()));
- break;
- case Qt::TopSection:
- newGeometry = QRectF(windowData->startGeometry.topLeft()
- + QPointF(parentYDelta.dx(), parentYDelta.dy()),
- windowData->startGeometry.size() - QSizeF(0, delta.dy()));
- break;
- case Qt::TopRightSection:
- newGeometry = QRectF(windowData->startGeometry.topLeft()
- + QPointF(parentYDelta.dx(), parentYDelta.dy()),
- windowData->startGeometry.size() - QSizeF(-delta.dx(), delta.dy()));
- break;
- case Qt::RightSection:
- newGeometry = QRectF(windowData->startGeometry.topLeft(),
- windowData->startGeometry.size() + QSizeF(delta.dx(), 0));
- break;
- case Qt::BottomRightSection:
- newGeometry = QRectF(windowData->startGeometry.topLeft(),
- windowData->startGeometry.size() + QSizeF(delta.dx(), delta.dy()));
- break;
- case Qt::BottomSection:
- newGeometry = QRectF(windowData->startGeometry.topLeft(),
- windowData->startGeometry.size() + QSizeF(0, delta.dy()));
- break;
- case Qt::BottomLeftSection:
- newGeometry = QRectF(windowData->startGeometry.topLeft()
- + QPointF(parentXDelta.dx(), parentXDelta.dy()),
- windowData->startGeometry.size() - QSizeF(delta.dx(), -delta.dy()));
- break;
- case Qt::TitleBarArea:
- newGeometry = QRectF(windowData->startGeometry.topLeft()
- + QPointF(parentDelta.dx(), parentDelta.dy()),
- windowData->startGeometry.size());
- break;
- case Qt::NoSection:
- break;
- }
-
- if (windowData->grabbedSection != Qt::NoSection) {
- _q_boundGeometryToSizeConstraints(windowData->startGeometry, &newGeometry,
- windowData->grabbedSection,
- q->effectiveSizeHint(Qt::MinimumSize),
- q->effectiveSizeHint(Qt::MaximumSize),
- q);
- q->setGeometry(newGeometry);
- }
-}
-
-void QGraphicsWidgetPrivate::windowFrameHoverMoveEvent(QGraphicsSceneHoverEvent *event)
-{
- Q_Q(QGraphicsWidget);
- if (!hasDecoration())
- return;
-
- ensureWindowData();
-
- if (q->rect().contains(event->pos())) {
- if (windowData->buttonMouseOver || windowData->hoveredSubControl != QStyle::SC_None)
- windowFrameHoverLeaveEvent(event);
- return;
- }
-
- bool wasMouseOver = windowData->buttonMouseOver;
- QRect oldButtonRect = windowData->buttonRect;
- windowData->buttonRect = QRect();
- windowData->buttonMouseOver = false;
- QPointF pos = event->pos();
- QStyleOptionTitleBar bar;
- // make sure that the coordinates (rect and pos) we send to the style are positive.
- if (windowFrameMargins) {
- pos.rx() += windowFrameMargins[Left];
- pos.ry() += windowFrameMargins[Top];
- }
- initStyleOptionTitleBar(&bar);
- bar.rect = q->windowFrameRect().toRect();
- bar.rect.moveTo(0,0);
- bar.rect.setHeight(int(titleBarHeight(bar)));
-
- Qt::CursorShape cursorShape = Qt::ArrowCursor;
- bool needsSetCursorCall = true;
- switch (q->windowFrameSectionAt(event->pos())) {
- case Qt::TopLeftSection:
- case Qt::BottomRightSection:
- cursorShape = Qt::SizeFDiagCursor;
- break;
- case Qt::TopRightSection:
- case Qt::BottomLeftSection:
- cursorShape = Qt::SizeBDiagCursor;
- break;
- case Qt::LeftSection:
- case Qt::RightSection:
- cursorShape = Qt::SizeHorCursor;
- break;
- case Qt::TopSection:
- case Qt::BottomSection:
- cursorShape = Qt::SizeVerCursor;
- break;
- case Qt::TitleBarArea:
- windowData->buttonRect = q->style()->subControlRect(
- QStyle::CC_TitleBar, &bar, QStyle::SC_TitleBarCloseButton, 0);
-#ifdef Q_WS_MAC
- // On mac we should hover if we are in the 'area' of the buttons
- windowData->buttonRect |= q->style()->subControlRect(
- QStyle::CC_TitleBar, &bar, QStyle::SC_TitleBarMinButton, 0);
- windowData->buttonRect |= q->style()->subControlRect(
- QStyle::CC_TitleBar, &bar, QStyle::SC_TitleBarMaxButton, 0);
-#endif
- if (windowData->buttonRect.contains(pos.toPoint()))
- windowData->buttonMouseOver = true;
- event->ignore();
- break;
- default:
- needsSetCursorCall = false;
- event->ignore();
- }
-#ifndef QT_NO_CURSOR
- if (needsSetCursorCall)
- q->setCursor(cursorShape);
-#endif
- // update buttons if we hover over them
- windowData->hoveredSubControl = q->style()->hitTestComplexControl(QStyle::CC_TitleBar, &bar, pos.toPoint(), 0);
- if (windowData->hoveredSubControl != QStyle::SC_TitleBarCloseButton)
- windowData->hoveredSubControl = QStyle::SC_TitleBarLabel;
-
- if (windowData->buttonMouseOver != wasMouseOver) {
- if (!oldButtonRect.isNull())
- q->update(QRectF(oldButtonRect).translated(q->windowFrameRect().topLeft()));
- if (!windowData->buttonRect.isNull())
- q->update(QRectF(windowData->buttonRect).translated(q->windowFrameRect().topLeft()));
- }
-}
-
-void QGraphicsWidgetPrivate::windowFrameHoverLeaveEvent(QGraphicsSceneHoverEvent *event)
-{
- Q_UNUSED(event);
- Q_Q(QGraphicsWidget);
- if (hasDecoration()) {
- // ### restore the cursor, don't override it
-#ifndef QT_NO_CURSOR
- q->unsetCursor();
-#endif
-
- ensureWindowData();
-
- bool needsUpdate = false;
- if (windowData->hoveredSubControl == QStyle::SC_TitleBarCloseButton
- || windowData->buttonMouseOver)
- needsUpdate = true;
-
- // update the hover state (of buttons etc...)
- windowData->hoveredSubControl = QStyle::SC_None;
- windowData->buttonMouseOver = false;
- windowData->buttonRect = QRect();
- if (needsUpdate)
- q->update(windowData->buttonRect);
- }
-}
-
-bool QGraphicsWidgetPrivate::hasDecoration() const
-{
- return (windowFlags & Qt::Window) && (windowFlags & Qt::WindowTitleHint);
-}
-
-/**
- * is called after a reparent has taken place to fix up the focus chain(s)
- */
-void QGraphicsWidgetPrivate::fixFocusChainBeforeReparenting(QGraphicsWidget *newParent, QGraphicsScene *oldScene, QGraphicsScene *newScene)
-{
- Q_Q(QGraphicsWidget);
-
- Q_ASSERT(focusNext && focusPrev);
-
- QGraphicsWidget *n = q; //last one in 'new' list
- QGraphicsWidget *o = 0; //last one in 'old' list
-
- QGraphicsWidget *w = focusNext;
-
- QGraphicsWidget *firstOld = 0;
- bool wasPreviousNew = true;
-
- while (w != q) {
- bool isCurrentNew = q->isAncestorOf(w);
- if (isCurrentNew) {
- if (!wasPreviousNew) {
- n->d_func()->focusNext = w;
- w->d_func()->focusPrev = n;
- }
- n = w;
- } else /*if (!isCurrentNew)*/ {
- if (wasPreviousNew) {
- if (o) {
- o->d_func()->focusNext = w;
- w->d_func()->focusPrev = o;
- } else {
- firstOld = w;
- }
- }
- o = w;
- }
- w = w->d_func()->focusNext;
- wasPreviousNew = isCurrentNew;
- }
-
- // repair the 'old' chain
- if (firstOld) {
- o->d_func()->focusNext = firstOld;
- firstOld->d_func()->focusPrev = o;
- }
-
- // update tabFocusFirst for oldScene if the item is going to be removed from oldScene
- if (newParent)
- newScene = newParent->scene();
-
- if (oldScene && newScene != oldScene)
- oldScene->d_func()->tabFocusFirst = (firstOld && firstOld->scene() == oldScene) ? firstOld : 0;
-
- QGraphicsItem *topLevelItem = newParent ? newParent->topLevelItem() : 0;
- QGraphicsWidget *topLevel = 0;
- if (topLevelItem && topLevelItem->isWidget())
- topLevel = static_cast<QGraphicsWidget *>(topLevelItem);
-
- if (topLevel && newParent) {
- QGraphicsWidget *last = topLevel->d_func()->focusPrev;
- // link last with new chain
- last->d_func()->focusNext = q;
- focusPrev = last;
-
- // link last in chain with
- topLevel->d_func()->focusPrev = n;
- n->d_func()->focusNext = topLevel;
- } else {
- // q is the start of the focus chain
- n->d_func()->focusNext = q;
- focusPrev = n;
- }
-
-}
-
-void QGraphicsWidgetPrivate::setLayout_helper(QGraphicsLayout *l)
-{
- delete (this->layout);
- layout = l;
- if (!l) {
- Q_Q(QGraphicsWidget);
- q->updateGeometry();
- }
-}
-
-qreal QGraphicsWidgetPrivate::width() const
-{
- Q_Q(const QGraphicsWidget);
- return q->geometry().width();
-}
-
-void QGraphicsWidgetPrivate::setWidth(qreal w)
-{
- if (qIsNaN(w))
- return;
- Q_Q(QGraphicsWidget);
- if (q->geometry().width() == w)
- return;
-
- q->setGeometry(QRectF(q->x(), q->y(), w, height()));
-}
-
-void QGraphicsWidgetPrivate::resetWidth()
-{
- Q_Q(QGraphicsWidget);
- q->setGeometry(QRectF(q->x(), q->y(), 0, height()));
-}
-
-qreal QGraphicsWidgetPrivate::height() const
-{
- Q_Q(const QGraphicsWidget);
- return q->geometry().height();
-}
-
-void QGraphicsWidgetPrivate::setHeight(qreal h)
-{
- if (qIsNaN(h))
- return;
- Q_Q(QGraphicsWidget);
- if (q->geometry().height() == h)
- return;
-
- q->setGeometry(QRectF(q->x(), q->y(), width(), h));
-}
-
-void QGraphicsWidgetPrivate::resetHeight()
-{
- Q_Q(QGraphicsWidget);
- q->setGeometry(QRectF(q->x(), q->y(), width(), 0));
-}
-
-void QGraphicsWidgetPrivate::setGeometryFromSetPos()
-{
- if (inSetGeometry)
- return;
- Q_Q(QGraphicsWidget);
- inSetPos = 1;
- // Ensure setGeometry is called (avoid recursion when setPos is
- // called from within setGeometry).
- q->setGeometry(QRectF(pos, q->size()));
- inSetPos = 0 ;
-}
-
-QT_END_NAMESPACE
-
-#endif //QT_NO_GRAPHICSVIEW
diff --git a/src/gui/graphicsview/qgraphicswidget_p.h b/src/gui/graphicsview/qgraphicswidget_p.h
deleted file mode 100644
index 4379eafbde..0000000000
--- a/src/gui/graphicsview/qgraphicswidget_p.h
+++ /dev/null
@@ -1,226 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSWIDGET_P_H
-#define QGRAPHICSWIDGET_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <private/qobject_p.h>
-#include "qgraphicsitem_p.h"
-#include "qgraphicswidget.h"
-#include <QtGui/qfont.h>
-#include <QtGui/qpalette.h>
-#include <QtGui/qsizepolicy.h>
-#include <QtGui/qstyle.h>
-
-QT_BEGIN_NAMESPACE
-
-class QGraphicsLayout;
-class QStyleOptionTitleBar;
-
-#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
-
-class QGraphicsWidgetPrivate : public QGraphicsItemPrivate
-{
- Q_DECLARE_PUBLIC(QGraphicsWidget)
-public:
- QGraphicsWidgetPrivate()
- : margins(0),
- layout(0),
- inheritedPaletteResolveMask(0),
- inheritedFontResolveMask(0),
- inSetGeometry(0),
- polished(0),
- inSetPos(0),
- autoFillBackground(0),
- focusPolicy(Qt::NoFocus),
- focusNext(0),
- focusPrev(0),
- windowFlags(0),
- windowData(0),
- setWindowFrameMargins(false),
- windowFrameMargins(0)
- { }
- virtual ~QGraphicsWidgetPrivate();
-
- void init(QGraphicsItem *parentItem, Qt::WindowFlags wFlags);
- qreal titleBarHeight(const QStyleOptionTitleBar &options) const;
-
- // Margins
- enum {Left, Top, Right, Bottom};
- mutable qreal *margins;
- void ensureMargins() const;
-
- void fixFocusChainBeforeReparenting(QGraphicsWidget *newParent, QGraphicsScene *oldScene, QGraphicsScene *newScene = 0);
- void setLayout_helper(QGraphicsLayout *l);
-
- // Layouts
- QGraphicsLayout *layout;
- void setLayoutDirection_helper(Qt::LayoutDirection direction);
- void resolveLayoutDirection();
-
- // Style
- QPalette palette;
- uint inheritedPaletteResolveMask;
- void setPalette_helper(const QPalette &palette);
- void resolvePalette(uint inheritedMask);
- void updatePalette(const QPalette &palette);
- QPalette naturalWidgetPalette() const;
- QFont font;
- uint inheritedFontResolveMask;
- void setFont_helper(const QFont &font);
- void resolveFont(uint inheritedMask);
- void updateFont(const QFont &font);
- QFont naturalWidgetFont() const;
-
- // Window specific
- void initStyleOptionTitleBar(QStyleOptionTitleBar *option);
- void adjustWindowFlags(Qt::WindowFlags *wFlags);
- void windowFrameMouseReleaseEvent(QGraphicsSceneMouseEvent *event);
- void windowFrameMousePressEvent(QGraphicsSceneMouseEvent *event);
- void windowFrameMouseMoveEvent(QGraphicsSceneMouseEvent *event);
- void windowFrameHoverMoveEvent(QGraphicsSceneHoverEvent *event);
- void windowFrameHoverLeaveEvent(QGraphicsSceneHoverEvent *event);
- bool hasDecoration() const;
-
- // Private Properties
- qreal width() const;
- void setWidth(qreal);
- void resetWidth();
-
- qreal height() const;
- void setHeight(qreal);
- void resetHeight();
- void setGeometryFromSetPos();
-
- // State
- inline int attributeToBitIndex(Qt::WidgetAttribute att) const
- {
- int bit = -1;
- switch (att) {
- case Qt::WA_SetLayoutDirection: bit = 0; break;
- case Qt::WA_RightToLeft: bit = 1; break;
- case Qt::WA_SetStyle: bit = 2; break;
- case Qt::WA_Resized: bit = 3; break;
- case Qt::WA_DeleteOnClose: bit = 4; break;
- case Qt::WA_NoSystemBackground: bit = 5; break;
- case Qt::WA_OpaquePaintEvent: bit = 6; break;
- case Qt::WA_SetPalette: bit = 7; break;
- case Qt::WA_SetFont: bit = 8; break;
- case Qt::WA_WindowPropagation: bit = 9; break;
- default: break;
- }
- return bit;
- }
- inline void setAttribute(Qt::WidgetAttribute att, bool value)
- {
- int bit = attributeToBitIndex(att);
- if (bit == -1) {
- qWarning("QGraphicsWidget::setAttribute: unsupported attribute %d", int(att));
- return;
- }
- if (value)
- attributes |= (1 << bit);
- else
- attributes &= ~(1 << bit);
- }
- inline bool testAttribute(Qt::WidgetAttribute att) const
- {
- int bit = attributeToBitIndex(att);
- if (bit == -1)
- return false;
- return (attributes & (1 << bit)) != 0;
- }
- quint32 attributes : 10;
- quint32 inSetGeometry : 1;
- quint32 polished: 1;
- quint32 inSetPos : 1;
- quint32 autoFillBackground : 1;
-
- // Focus
- Qt::FocusPolicy focusPolicy;
- QGraphicsWidget *focusNext;
- QGraphicsWidget *focusPrev;
-
- // Windows
- Qt::WindowFlags windowFlags;
- struct WindowData {
- QString windowTitle;
- QStyle::SubControl hoveredSubControl;
- Qt::WindowFrameSection grabbedSection;
- uint buttonMouseOver : 1;
- uint buttonSunken : 1;
- QRectF startGeometry;
- QRect buttonRect;
- WindowData()
- : hoveredSubControl(QStyle::SC_None)
- , grabbedSection(Qt::NoSection)
- , buttonMouseOver(false)
- , buttonSunken(false)
- {}
- } *windowData;
- void ensureWindowData();
-
- bool setWindowFrameMargins;
- mutable qreal *windowFrameMargins;
- void ensureWindowFrameMargins() const;
-
-#ifndef QT_NO_ACTION
- QList<QAction *> actions;
-#endif
-};
-
-#endif //!defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
-
-QT_END_NAMESPACE
-
-#endif //QGRAPHICSWIDGET_P_H
-
diff --git a/src/gui/gui.pro b/src/gui/gui.pro
index 072553a05c..f9ae32b6b5 100644
--- a/src/gui/gui.pro
+++ b/src/gui/gui.pro
@@ -6,63 +6,24 @@ CONFIG += module
MODULE_PRI = ../modules/qt_gui.pri
DEFINES += QT_BUILD_GUI_LIB QT_NO_USING_NAMESPACE
-win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x65000000
-irix-cc*:QMAKE_CXXFLAGS += -no_prelink -ptused
-
-!win32:!embedded:!qpa:!mac:!symbian:CONFIG += x11
unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES = QtCore
include(../qbase.pri)
-contains(QT_CONFIG, x11sm):CONFIG += x11sm
-
-#platforms
-x11:include(kernel/x11.pri)
-mac:include(kernel/mac.pri)
-win32:include(kernel/win.pri)
-embedded:include(embedded/embedded.pri)
-symbian {
- include(kernel/symbian.pri)
- include(s60framework/s60framework.pri)
-}
-
-#modules
-include(animation/animation.pri)
-include(kernel/kernel.pri)
+# stuff that goes into new QtGui
+include(guikernel/guikernel.pri)
include(image/image.pri)
-include(painting/painting.pri)
include(text/text.pri)
-include(styles/styles.pri)
-include(widgets/widgets.pri)
-include(dialogs/dialogs.pri)
-include(accessible/accessible.pri)
-include(itemviews/itemviews.pri)
-include(inputmethod/inputmethod.pri)
-include(graphicsview/graphicsview.pri)
-include(util/util.pri)
-include(statemachine/statemachine.pri)
+include(painting/painting.pri)
+include(guiutil/guiutil.pri)
include(math3d/math3d.pri)
-include(effects/effects.pri)
include(egl/egl.pri)
-win32:!wince*: DEFINES += QT_NO_EGL
-embedded: QT += network
QMAKE_LIBS += $$QMAKE_LIBS_GUI
-contains(DEFINES,QT_EVAL):include($$QT_SOURCE_TREE/src/corelib/eval.pri)
-
-QMAKE_DYNAMIC_LIST_FILE = $$PWD/QtGui.dynlist
-
DEFINES += Q_INTERNAL_QAPP_SRC
-symbian {
- TARGET.UID3=0x2001B2DD
-
- # ro-section in gui can exceed default allocated space, so move rw-section a little further
- QMAKE_LFLAGS.ARMCC += --rw-base 0x800000
- QMAKE_LFLAGS.GCCE += -Tdata 0x800000
-}
neon:*-g++* {
DEFINES += QT_HAVE_NEON
diff --git a/src/gui/guikernel/guikernel.pri b/src/gui/guikernel/guikernel.pri
new file mode 100644
index 0000000000..8e41b55049
--- /dev/null
+++ b/src/gui/guikernel/guikernel.pri
@@ -0,0 +1,88 @@
+# Qt kernel module
+
+# Only used on platforms with CONFIG += precompile_header
+PRECOMPILED_HEADER = guikernel/qt_gui_pch.h
+
+
+KERNEL_P= guikernel
+HEADERS += \
+ guikernel/qclipboard.h \
+ guikernel/qcursor.h \
+ guikernel/qcursor_p.h \
+ guikernel/qevent.h \
+ guikernel/qevent_p.h \
+ guikernel/qkeysequence.h \
+ guikernel/qkeysequence_p.h \
+ guikernel/qkeymapper_p.h \
+ guikernel/qmime.h \
+ guikernel/qpalette.h \
+ guikernel/qsessionmanager.h \
+ guikernel/qwindowdefs.h \
+
+SOURCES += \
+ guikernel/qclipboard.cpp \
+ guikernel/qcursor.cpp \
+ guikernel/qevent.cpp \
+ guikernel/qkeysequence.cpp \
+ guikernel/qkeymapper.cpp \
+ guikernel/qkeymapper_qpa.cpp \
+ guikernel/qmime.cpp \
+ guikernel/qpalette.cpp \
+ guikernel/qguivariant.cpp \
+
+qpa {
+ HEADERS += \
+ guikernel/qgenericpluginfactory_qpa.h \
+ guikernel/qgenericplugin_qpa.h \
+ guikernel/qeventdispatcher_qpa_p.h \
+ guikernel/qwindowsysteminterface_qpa.h \
+ guikernel/qwindowsysteminterface_qpa_p.h \
+ guikernel/qplatformintegration_qpa.h \
+ guikernel/qplatformscreen_qpa.h \
+ guikernel/qplatformintegrationfactory_qpa_p.h \
+ guikernel/qplatformintegrationplugin_qpa.h \
+ guikernel/qplatformwindow_qpa.h \
+ guikernel/qplatformglcontext_qpa.h \
+ guikernel/qwindowcontext_qpa.h \
+ guikernel/qplatformeventloopintegration_qpa.h \
+ guikernel/qplatformcursor_qpa.h \
+ guikernel/qplatformclipboard_qpa.h \
+ guikernel/qplatformnativeinterface_qpa.h \
+ guikernel/qwindowformat_qpa.h \
+ guikernel/qguiapplication.h \
+ guikernel/qguiapplication_p.h \
+ guikernel/qwindow_p.h \
+ guikernel/qwindow.h
+
+ SOURCES += \
+ guikernel/qclipboard_qpa.cpp \
+ guikernel/qcursor_qpa.cpp \
+ guikernel/qgenericpluginfactory_qpa.cpp \
+ guikernel/qgenericplugin_qpa.cpp \
+ guikernel/qeventdispatcher_qpa.cpp \
+ guikernel/qwindowsysteminterface_qpa.cpp \
+ guikernel/qplatformintegration_qpa.cpp \
+ guikernel/qplatformscreen_qpa.cpp \
+ guikernel/qplatformintegrationfactory_qpa.cpp \
+ guikernel/qplatformintegrationplugin_qpa.cpp \
+ guikernel/qplatformwindow_qpa.cpp \
+ guikernel/qplatformeventloopintegration_qpa.cpp \
+ guikernel/qplatformglcontext_qpa.cpp \
+ guikernel/qwindowcontext_qpa.cpp \
+ guikernel/qplatformcursor_qpa.cpp \
+ guikernel/qplatformclipboard_qpa.cpp \
+ guikernel/qplatformnativeinterface_qpa.cpp \
+ guikernel/qsessionmanager_qpa.cpp \
+ guikernel/qwindowformat_qpa.cpp \
+ guikernel/qguiapplication.cpp \
+ guikernel/qwindow.cpp
+
+ contains(QT_CONFIG, glib) {
+ SOURCES += \
+ guikernel/qeventdispatcher_glib_qpa.cpp
+ HEADERS += \
+ guikernel/qeventdispatcher_glib_qpa_p.h
+ QMAKE_CXXFLAGS += $$QT_CFLAGS_GLIB
+ LIBS_PRIVATE +=$$QT_LIBS_GLIB
+ }
+}
diff --git a/src/gui/guikernel/qclipboard.cpp b/src/gui/guikernel/qclipboard.cpp
new file mode 100644
index 0000000000..83d1c9183a
--- /dev/null
+++ b/src/gui/guikernel/qclipboard.cpp
@@ -0,0 +1,665 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qclipboard.h"
+
+#ifndef QT_NO_CLIPBOARD
+
+#include "qpixmap.h"
+#include "qclipboard_p.h"
+#include "qvariant.h"
+#include "qbuffer.h"
+#include "qimage.h"
+#include "qtextcodec.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QClipboard
+ \brief The QClipboard class provides access to the window system clipboard.
+
+ The clipboard offers a simple mechanism to copy and paste data
+ between applications.
+
+ QClipboard supports the same data types that QDrag does, and uses
+ similar mechanisms. For advanced clipboard usage read \l{Drag and
+ Drop}.
+
+ There is a single QClipboard object in an application, accessible
+ as QApplication::clipboard().
+
+ Example:
+ \snippet doc/src/snippets/code/src_gui_kernel_qclipboard.cpp 0
+
+ QClipboard features some convenience functions to access common
+ data types: setText() allows the exchange of Unicode text and
+ setPixmap() and setImage() allows the exchange of QPixmaps and
+ QImages between applications. The setMimeData() function is the
+ ultimate in flexibility: it allows you to add any QMimeData into
+ the clipboard. There are corresponding getters for each of these,
+ e.g. text(), image() and pixmap(). You can clear the clipboard by
+ calling clear().
+
+ A typical example of the use of these functions follows:
+
+ \snippet doc/src/snippets/droparea.cpp 0
+
+ \section1 Notes for X11 Users
+
+ \list
+
+ \i The X11 Window System has the concept of a separate selection
+ and clipboard. When text is selected, it is immediately available
+ as the global mouse selection. The global mouse selection may
+ later be copied to the clipboard. By convention, the middle mouse
+ button is used to paste the global mouse selection.
+
+ \i X11 also has the concept of ownership; if you change the
+ selection within a window, X11 will only notify the owner and the
+ previous owner of the change, i.e. it will not notify all
+ applications that the selection or clipboard data changed.
+
+ \i Lastly, the X11 clipboard is event driven, i.e. the clipboard
+ will not function properly if the event loop is not running.
+ Similarly, it is recommended that the contents of the clipboard
+ are stored or retrieved in direct response to user-input events,
+ e.g. mouse button or key presses and releases. You should not
+ store or retrieve the clipboard contents in response to timer or
+ non-user-input events.
+
+ \i Since there is no standard way to copy and paste files between
+ applications on X11, various MIME types and conventions are currently
+ in use. For instance, Nautilus expects files to be supplied with a
+ \c{x-special/gnome-copied-files} MIME type with data beginning with
+ the cut/copy action, a newline character, and the URL of the file.
+
+ \endlist
+
+ \section1 Notes for Mac OS X Users
+
+ Mac OS X supports a separate find buffer that holds the current
+ search string in Find operations. This find clipboard can be accessed
+ by specifying the FindBuffer mode.
+
+ \section1 Notes for Windows and Mac OS X Users
+
+ \list
+
+ \i Windows and Mac OS X do not support the global mouse
+ selection; they only supports the global clipboard, i.e. they
+ only add text to the clipboard when an explicit copy or cut is
+ made.
+
+ \i Windows and Mac OS X does not have the concept of ownership;
+ the clipboard is a fully global resource so all applications are
+ notified of changes.
+
+ \endlist
+
+ \sa QApplication
+*/
+
+#ifndef Q_WS_X11
+// for X11 there is a separate implementation of a constructor.
+/*!
+ \internal
+
+ Constructs a clipboard object.
+
+ Do not call this function.
+
+ Call QApplication::clipboard() instead to get a pointer to the
+ application's global clipboard object.
+
+ There is only one clipboard in the window system, and creating
+ more than one object to represent it is almost certainly an error.
+*/
+
+QClipboard::QClipboard(QObject *parent)
+ : QObject(*new QClipboardPrivate, parent)
+{
+ // nothing
+}
+#endif
+
+#ifndef Q_WS_WIN32
+/*!
+ \internal
+
+ Destroys the clipboard.
+
+ You should never delete the clipboard. QApplication will do this
+ when the application terminates.
+*/
+QClipboard::~QClipboard()
+{
+}
+#endif
+
+/*!
+ \fn void QClipboard::changed(QClipboard::Mode mode)
+ \since 4.2
+
+ This signal is emitted when the data for the given clipboard \a
+ mode is changed.
+
+ \sa dataChanged(), selectionChanged(), findBufferChanged()
+*/
+
+/*!
+ \fn void QClipboard::dataChanged()
+
+ This signal is emitted when the clipboard data is changed.
+
+ On Mac OS X and with Qt version 4.3 or higher, clipboard
+ changes made by other applications will only be detected
+ when the application is activated.
+
+ \sa findBufferChanged(), selectionChanged(), changed()
+*/
+
+/*!
+ \fn void QClipboard::selectionChanged()
+
+ This signal is emitted when the selection is changed. This only
+ applies to windowing systems that support selections, e.g. X11.
+ Windows and Mac OS X don't support selections.
+
+ \sa dataChanged(), findBufferChanged(), changed()
+*/
+
+/*!
+ \fn void QClipboard::findBufferChanged()
+ \since 4.2
+
+ This signal is emitted when the find buffer is changed. This only
+ applies to Mac OS X.
+
+ With Qt version 4.3 or higher, clipboard changes made by other
+ applications will only be detected when the application is activated.
+
+ \sa dataChanged(), selectionChanged(), changed()
+*/
+
+
+/*! \enum QClipboard::Mode
+ \keyword clipboard mode
+
+ This enum type is used to control which part of the system clipboard is
+ used by QClipboard::mimeData(), QClipboard::setMimeData() and related functions.
+
+ \value Clipboard indicates that data should be stored and retrieved from
+ the global clipboard.
+
+ \value Selection indicates that data should be stored and retrieved from
+ the global mouse selection. Support for \c Selection is provided only on
+ systems with a global mouse selection (e.g. X11).
+
+ \value FindBuffer indicates that data should be stored and retrieved from
+ the Find buffer. This mode is used for holding search strings on Mac OS X.
+
+ \omitvalue LastMode
+
+ \sa QClipboard::supportsSelection()
+*/
+
+
+/*****************************************************************************
+ QApplication member functions related to QClipboard.
+ *****************************************************************************/
+
+// text handling is done directly in qclipboard_qws, for now
+
+/*!
+ \fn bool QClipboard::event(QEvent *e)
+ \reimp
+*/
+
+/*!
+ \overload
+
+ Returns the clipboard text in subtype \a subtype, or an empty string
+ if the clipboard does not contain any text. If \a subtype is null,
+ any subtype is acceptable, and \a subtype is set to the chosen
+ subtype.
+
+ The \a mode argument is used to control which part of the system
+ clipboard is used. If \a mode is QClipboard::Clipboard, the
+ text is retrieved from the global clipboard. If \a mode is
+ QClipboard::Selection, the text is retrieved from the global
+ mouse selection.
+
+ Common values for \a subtype are "plain" and "html".
+
+ Note that calling this function repeatedly, for instance from a
+ key event handler, may be slow. In such cases, you should use the
+ \c dataChanged() signal instead.
+
+ \sa setText(), mimeData()
+*/
+QString QClipboard::text(QString &subtype, Mode mode) const
+{
+ const QMimeData *const data = mimeData(mode);
+ if (!data)
+ return QString();
+
+ const QStringList formats = data->formats();
+ if (subtype.isEmpty()) {
+ if (formats.contains(QLatin1String("text/plain")))
+ subtype = QLatin1String("plain");
+ else {
+ for (int i = 0; i < formats.size(); ++i)
+ if (formats.at(i).startsWith(QLatin1String("text/"))) {
+ subtype = formats.at(i).mid(5);
+ break;
+ }
+ if (subtype.isEmpty())
+ return QString();
+ }
+ } else if (!formats.contains(QLatin1String("text/") + subtype)) {
+ return QString();
+ }
+
+ const QByteArray rawData = data->data(QLatin1String("text/") + subtype);
+
+#ifndef QT_NO_TEXTCODEC
+ QTextCodec* codec = QTextCodec::codecForMib(106); // utf-8 is default
+ if (subtype == QLatin1String("html"))
+ codec = QTextCodec::codecForHtml(rawData, codec);
+ else
+ codec = QTextCodec::codecForUtfText(rawData, codec);
+ return codec->toUnicode(rawData);
+#else //QT_NO_TEXTCODEC
+ return rawData;
+#endif //QT_NO_TEXTCODEC
+}
+
+/*!
+ Returns the clipboard text as plain text, or an empty string if the
+ clipboard does not contain any text.
+
+ The \a mode argument is used to control which part of the system
+ clipboard is used. If \a mode is QClipboard::Clipboard, the
+ text is retrieved from the global clipboard. If \a mode is
+ QClipboard::Selection, the text is retrieved from the global
+ mouse selection. If \a mode is QClipboard::FindBuffer, the
+ text is retrieved from the search string buffer.
+
+ \sa setText(), mimeData()
+*/
+QString QClipboard::text(Mode mode) const
+{
+ const QMimeData *data = mimeData(mode);
+ return data ? data->text() : QString();
+}
+
+/*!
+ Copies \a text into the clipboard as plain text.
+
+ The \a mode argument is used to control which part of the system
+ clipboard is used. If \a mode is QClipboard::Clipboard, the
+ text is stored in the global clipboard. If \a mode is
+ QClipboard::Selection, the text is stored in the global
+ mouse selection. If \a mode is QClipboard::FindBuffer, the
+ text is stored in the search string buffer.
+
+ \sa text(), setMimeData()
+*/
+void QClipboard::setText(const QString &text, Mode mode)
+{
+ QMimeData *data = new QMimeData;
+ data->setText(text);
+ setMimeData(data, mode);
+}
+
+/*!
+ Returns the clipboard image, or returns a null image if the
+ clipboard does not contain an image or if it contains an image in
+ an unsupported image format.
+
+ The \a mode argument is used to control which part of the system
+ clipboard is used. If \a mode is QClipboard::Clipboard, the
+ image is retrieved from the global clipboard. If \a mode is
+ QClipboard::Selection, the image is retrieved from the global
+ mouse selection.
+
+ \sa setImage() pixmap() mimeData(), QImage::isNull()
+*/
+QImage QClipboard::image(Mode mode) const
+{
+ const QMimeData *data = mimeData(mode);
+ if (!data)
+ return QImage();
+ return qvariant_cast<QImage>(data->imageData());
+}
+
+/*!
+ Copies the \a image into the clipboard.
+
+ The \a mode argument is used to control which part of the system
+ clipboard is used. If \a mode is QClipboard::Clipboard, the
+ image is stored in the global clipboard. If \a mode is
+ QClipboard::Selection, the data is stored in the global
+ mouse selection.
+
+ This is shorthand for:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qclipboard.cpp 1
+
+ \sa image(), setPixmap() setMimeData()
+*/
+void QClipboard::setImage(const QImage &image, Mode mode)
+{
+ QMimeData *data = new QMimeData;
+ data->setImageData(image);
+ setMimeData(data, mode);
+}
+
+/*!
+ Returns the clipboard pixmap, or null if the clipboard does not
+ contain a pixmap. Note that this can lose information. For
+ example, if the image is 24-bit and the display is 8-bit, the
+ result is converted to 8 bits, and if the image has an alpha
+ channel, the result just has a mask.
+
+ The \a mode argument is used to control which part of the system
+ clipboard is used. If \a mode is QClipboard::Clipboard, the
+ pixmap is retrieved from the global clipboard. If \a mode is
+ QClipboard::Selection, the pixmap is retrieved from the global
+ mouse selection.
+
+ \sa setPixmap() image() mimeData() QPixmap::convertFromImage()
+*/
+QPixmap QClipboard::pixmap(Mode mode) const
+{
+ const QMimeData *data = mimeData(mode);
+ return data ? qvariant_cast<QPixmap>(data->imageData()) : QPixmap();
+}
+
+/*!
+ Copies \a pixmap into the clipboard. Note that this is slower
+ than setImage() because it needs to convert the QPixmap to a
+ QImage first.
+
+ The \a mode argument is used to control which part of the system
+ clipboard is used. If \a mode is QClipboard::Clipboard, the
+ pixmap is stored in the global clipboard. If \a mode is
+ QClipboard::Selection, the pixmap is stored in the global
+ mouse selection.
+
+ \sa pixmap() setImage() setMimeData()
+*/
+void QClipboard::setPixmap(const QPixmap &pixmap, Mode mode)
+{
+ QMimeData *data = new QMimeData;
+ data->setImageData(pixmap);
+ setMimeData(data, mode);
+}
+
+
+/*!
+ \fn QMimeData *QClipboard::mimeData(Mode mode) const
+
+ Returns a reference to a QMimeData representation of the current
+ clipboard data.
+
+ The \a mode argument is used to control which part of the system
+ clipboard is used. If \a mode is QClipboard::Clipboard, the
+ data is retrieved from the global clipboard. If \a mode is
+ QClipboard::Selection, the data is retrieved from the global
+ mouse selection. If \a mode is QClipboard::FindBuffer, the
+ data is retrieved from the search string buffer.
+
+ The text(), image(), and pixmap() functions are simpler
+ wrappers for retrieving text, image, and pixmap data.
+
+ \sa setMimeData()
+*/
+
+/*!
+ \fn void QClipboard::setMimeData(QMimeData *src, Mode mode)
+
+ Sets the clipboard data to \a src. Ownership of the data is
+ transferred to the clipboard. If you want to remove the data
+ either call clear() or call setMimeData() again with new data.
+
+ The \a mode argument is used to control which part of the system
+ clipboard is used. If \a mode is QClipboard::Clipboard, the
+ data is stored in the global clipboard. If \a mode is
+ QClipboard::Selection, the data is stored in the global
+ mouse selection. If \a mode is QClipboard::FindBuffer, the
+ data is stored in the search string buffer.
+
+ The setText(), setImage() and setPixmap() functions are simpler
+ wrappers for setting text, image and pixmap data respectively.
+
+ \sa mimeData()
+*/
+
+/*!
+ \fn void QClipboard::clear(Mode mode)
+ Clear the clipboard contents.
+
+ The \a mode argument is used to control which part of the system
+ clipboard is used. If \a mode is QClipboard::Clipboard, this
+ function clears the global clipboard contents. If \a mode is
+ QClipboard::Selection, this function clears the global mouse
+ selection contents. If \a mode is QClipboard::FindBuffer, this
+ function clears the search string buffer.
+
+ \sa QClipboard::Mode, supportsSelection()
+*/
+
+#ifdef QT3_SUPPORT
+/*!
+ \fn QMimeSource *QClipboard::data(Mode mode) const
+ \compat
+
+ Use mimeData() instead.
+*/
+QMimeSource *QClipboard::data(Mode mode) const
+{
+ Q_D(const QClipboard);
+
+ if (supportsMode(mode) == false)
+ return 0;
+
+ if (d->compat_data[mode])
+ return d->compat_data[mode];
+
+ d->wrapper[mode]->data = mimeData(mode);
+ return d->wrapper[mode];
+}
+
+
+/*!
+ \fn void QClipboard::setData(QMimeSource *src, Mode mode)
+ \compat
+
+ Use setMimeData() instead.
+*/
+void QClipboard::setData(QMimeSource *source, Mode mode)
+{
+ Q_D(QClipboard);
+
+ if (supportsMode(mode) == false)
+ return;
+
+ d->compat_data[mode] = source;
+ setMimeData(new QMimeSourceWrapper(d, mode), mode);
+}
+#endif // QT3_SUPPORT
+
+/*!
+ Returns true if the clipboard supports mouse selection; otherwise
+ returns false.
+*/
+bool QClipboard::supportsSelection() const
+{
+ return supportsMode(Selection);
+}
+
+/*!
+ Returns true if the clipboard supports a separate search buffer; otherwise
+ returns false.
+*/
+bool QClipboard::supportsFindBuffer() const
+{
+ return supportsMode(FindBuffer);
+}
+
+/*!
+ Returns true if this clipboard object owns the clipboard data;
+ otherwise returns false.
+*/
+bool QClipboard::ownsClipboard() const
+{
+ return ownsMode(Clipboard);
+}
+
+/*!
+ Returns true if this clipboard object owns the mouse selection
+ data; otherwise returns false.
+*/
+bool QClipboard::ownsSelection() const
+{
+ return ownsMode(Selection);
+}
+
+/*!
+ \since 4.2
+
+ Returns true if this clipboard object owns the find buffer data;
+ otherwise returns false.
+*/
+bool QClipboard::ownsFindBuffer() const
+{
+ return ownsMode(FindBuffer);
+}
+
+/*!
+ \internal
+ \fn bool QClipboard::supportsMode(Mode mode) const;
+ Returns true if the clipboard supports the clipboard mode speacified by \a mode;
+ otherwise returns false.
+*/
+
+/*!
+ \internal
+ \fn bool QClipboard::ownsMode(Mode mode) const;
+ Returns true if the clipboard supports the clipboard data speacified by \a mode;
+ otherwise returns false.
+*/
+
+/*!
+ \internal
+ Emits the appropriate changed signal for \a mode.
+*/
+void QClipboard::emitChanged(Mode mode)
+{
+ switch (mode) {
+ case Clipboard:
+ emit dataChanged();
+ break;
+ case Selection:
+ emit selectionChanged();
+ break;
+ case FindBuffer:
+ emit findBufferChanged();
+ break;
+ default:
+ break;
+ }
+ emit changed(mode);
+}
+
+const char* QMimeDataWrapper::format(int n) const
+{
+ if (formats.isEmpty()) {
+ QStringList fmts = data->formats();
+ for (int i = 0; i < fmts.size(); ++i)
+ formats.append(fmts.at(i).toLatin1());
+ }
+ if (n < 0 || n >= formats.size())
+ return 0;
+ return formats.at(n).data();
+}
+
+QByteArray QMimeDataWrapper::encodedData(const char *format) const
+{
+ if (QLatin1String(format) != QLatin1String("application/x-qt-image")){
+ return data->data(QLatin1String(format));
+ } else{
+ QVariant variant = data->imageData();
+ QImage img = qvariant_cast<QImage>(variant);
+ QByteArray ba;
+ QBuffer buffer(&ba);
+ buffer.open(QIODevice::WriteOnly);
+ img.save(&buffer, "PNG");
+ return ba;
+ }
+}
+
+QVariant QMimeSourceWrapper::retrieveData(const QString &mimetype, QVariant::Type) const
+{
+ return source->encodedData(mimetype.toLatin1());
+}
+
+bool QMimeSourceWrapper::hasFormat(const QString &mimetype) const
+{
+ return source->provides(mimetype.toLatin1());
+}
+
+QStringList QMimeSourceWrapper::formats() const
+{
+ QStringList fmts;
+ int i = 0;
+ const char *fmt;
+ while ((fmt = source->format(i))) {
+ fmts.append(QLatin1String(fmt));
+ ++i;
+ }
+ return fmts;
+}
+
+#endif // QT_NO_CLIPBOARD
+
+QT_END_NAMESPACE
diff --git a/src/gui/guikernel/qclipboard.h b/src/gui/guikernel/qclipboard.h
new file mode 100644
index 0000000000..989ba19c2c
--- /dev/null
+++ b/src/gui/guikernel/qclipboard.h
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCLIPBOARD_H
+#define QCLIPBOARD_H
+
+#include <QtCore/qobject.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_CLIPBOARD
+
+class QMimeSource;
+class QMimeData;
+class QImage;
+class QPixmap;
+
+class QClipboardPrivate;
+
+class Q_GUI_EXPORT QClipboard : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QClipboard)
+private:
+ QClipboard(QObject *parent);
+ ~QClipboard();
+
+public:
+ enum Mode { Clipboard, Selection, FindBuffer, LastMode = FindBuffer };
+
+ void clear(Mode mode = Clipboard);
+
+ bool supportsSelection() const;
+ bool supportsFindBuffer() const;
+
+ bool ownsSelection() const;
+ bool ownsClipboard() const;
+ bool ownsFindBuffer() const;
+
+ QString text(Mode mode = Clipboard) const;
+ QString text(QString& subtype, Mode mode = Clipboard) const;
+ void setText(const QString &, Mode mode = Clipboard);
+
+#ifdef QT3_SUPPORT
+ QT3_SUPPORT QMimeSource *data(Mode mode = Clipboard) const;
+ QT3_SUPPORT void setData(QMimeSource*, Mode mode = Clipboard);
+#endif
+ const QMimeData *mimeData(Mode mode = Clipboard ) const;
+ void setMimeData(QMimeData *data, Mode mode = Clipboard);
+
+ QImage image(Mode mode = Clipboard) const;
+ QPixmap pixmap(Mode mode = Clipboard) const;
+ void setImage(const QImage &, Mode mode = Clipboard);
+ void setPixmap(const QPixmap &, Mode mode = Clipboard);
+
+Q_SIGNALS:
+ void changed(QClipboard::Mode mode);
+ void selectionChanged();
+ void findBufferChanged();
+ void dataChanged();
+private Q_SLOTS:
+ void ownerDestroyed();
+
+protected:
+ void connectNotify(const char *);
+ bool event(QEvent *);
+
+ friend class QApplication;
+ friend class QApplicationPrivate;
+ friend class QGuiApplication;
+ friend class QBaseApplication;
+ friend class QDragManager;
+ friend class QMimeSource;
+ friend class QPlatformClipboard;
+
+private:
+ Q_DISABLE_COPY(QClipboard)
+
+ bool supportsMode(Mode mode) const;
+ bool ownsMode(Mode mode) const;
+ void emitChanged(Mode mode);
+};
+
+#endif // QT_NO_CLIPBOARD
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QCLIPBOARD_H
diff --git a/src/gui/kernel/qclipboard_p.h b/src/gui/guikernel/qclipboard_p.h
index c82694cfb8..c82694cfb8 100644
--- a/src/gui/kernel/qclipboard_p.h
+++ b/src/gui/guikernel/qclipboard_p.h
diff --git a/src/gui/guikernel/qclipboard_qpa.cpp b/src/gui/guikernel/qclipboard_qpa.cpp
new file mode 100644
index 0000000000..6aa7c1d6d9
--- /dev/null
+++ b/src/gui/guikernel/qclipboard_qpa.cpp
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qclipboard.h"
+
+#ifndef QT_NO_CLIPBOARD
+
+#include "qmimedata.h"
+#include "private/qguiapplication_p.h"
+#include "qplatformclipboard_qpa.h"
+
+QT_BEGIN_NAMESPACE
+
+QT_USE_NAMESPACE
+
+void QClipboard::clear(Mode mode)
+{
+ setMimeData(0,mode);
+}
+
+
+bool QClipboard::event(QEvent *e)
+{
+ return QObject::event(e);
+}
+
+const QMimeData* QClipboard::mimeData(Mode mode) const
+{
+ QPlatformClipboard *clipboard = QGuiApplicationPrivate::platformIntegration()->clipboard();
+ if (!clipboard->supportsMode(mode)) return 0;
+ return clipboard->mimeData(mode);
+}
+
+void QClipboard::setMimeData(QMimeData* src, Mode mode)
+{
+ QPlatformClipboard *clipboard = QGuiApplicationPrivate::platformIntegration()->clipboard();
+ if (!clipboard->supportsMode(mode)) return;
+
+ clipboard->setMimeData(src,mode);
+
+ emitChanged(mode);
+}
+
+bool QClipboard::supportsMode(Mode mode) const
+{
+ QPlatformClipboard *clipboard = QGuiApplicationPrivate::platformIntegration()->clipboard();
+ return clipboard->supportsMode(mode);
+}
+
+bool QClipboard::ownsMode(Mode mode) const
+{
+ if (mode == Clipboard)
+ qWarning("QClipboard::ownsClipboard: UNIMPLEMENTED!");
+ return false;
+}
+
+void QClipboard::connectNotify( const char * )
+{
+}
+
+void QClipboard::ownerDestroyed()
+{
+}
+
+#endif // QT_NO_CLIPBOARD
+
+QT_END_NAMESPACE
diff --git a/src/gui/guikernel/qcursor.cpp b/src/gui/guikernel/qcursor.cpp
new file mode 100644
index 0000000000..be533a365f
--- /dev/null
+++ b/src/gui/guikernel/qcursor.cpp
@@ -0,0 +1,573 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qcursor.h"
+
+#ifndef QT_NO_CURSOR
+
+#include <qcoreapplication.h>
+#include <qbitmap.h>
+#include <qimage.h>
+#include <qdatastream.h>
+#include <qvariant.h>
+#include <private/qcursor_p.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QCursor
+
+ \brief The QCursor class provides a mouse cursor with an arbitrary
+ shape.
+
+ \ingroup appearance
+ \ingroup shared
+
+
+ This class is mainly used to create mouse cursors that are
+ associated with particular widgets and to get and set the position
+ of the mouse cursor.
+
+ Qt has a number of standard cursor shapes, but you can also make
+ custom cursor shapes based on a QBitmap, a mask and a hotspot.
+
+ To associate a cursor with a widget, use QWidget::setCursor(). To
+ associate a cursor with all widgets (normally for a short period
+ of time), use QGuiApplication::setOverrideCursor().
+
+ To set a cursor shape use QCursor::setShape() or use the QCursor
+ constructor which takes the shape as argument, or you can use one
+ of the predefined cursors defined in the \l Qt::CursorShape enum.
+
+ If you want to create a cursor with your own bitmap, either use
+ the QCursor constructor which takes a bitmap and a mask or the
+ constructor which takes a pixmap as arguments.
+
+ To set or get the position of the mouse cursor use the static
+ methods QCursor::pos() and QCursor::setPos().
+
+ \bold{Note:} It is possible to create a QCursor before
+ QGuiApplication, but it is not useful except as a place-holder for a
+ real QCursor created after QGuiApplication. Attempting to use a
+ QCursor that was created before QGuiApplication will result in a
+ crash.
+
+ \section1 A Note for X11 Users
+
+ On X11, Qt supports the \link
+ http://www.xfree86.org/4.3.0/Xcursor.3.html Xcursor\endlink
+ library, which allows for full color icon themes. The table below
+ shows the cursor name used for each Qt::CursorShape value. If a
+ cursor cannot be found using the name shown below, a standard X11
+ cursor will be used instead. Note: X11 does not provide
+ appropriate cursors for all possible Qt::CursorShape values. It
+ is possible that some cursors will be taken from the Xcursor
+ theme, while others will use an internal bitmap cursor.
+
+ \table
+ \header \o Shape \o Qt::CursorShape Value \o Cursor Name
+ \o Shape \o Qt::CursorShape Value \o Cursor Name
+ \row \o \inlineimage cursor-arrow.png
+ \o Qt::ArrowCursor \o \c left_ptr
+ \o \inlineimage cursor-sizev.png
+ \o Qt::SizeVerCursor \o \c size_ver
+ \row \o \inlineimage cursor-uparrow.png
+ \o Qt::UpArrowCursor \o \c up_arrow
+ \o \inlineimage cursor-sizeh.png
+ \o Qt::SizeHorCursor \o \c size_hor
+ \row \o \inlineimage cursor-cross.png
+ \o Qt::CrossCursor \o \c cross
+ \o \inlineimage cursor-sizeb.png
+ \o Qt::SizeBDiagCursor \o \c size_bdiag
+ \row \o \inlineimage cursor-ibeam.png
+ \o Qt::IBeamCursor \o \c ibeam
+ \o \inlineimage cursor-sizef.png
+ \o Qt::SizeFDiagCursor \o \c size_fdiag
+ \row \o \inlineimage cursor-wait.png
+ \o Qt::WaitCursor \o \c wait
+ \o \inlineimage cursor-sizeall.png
+ \o Qt::SizeAllCursor \o \c size_all
+ \row \o \inlineimage cursor-busy.png
+ \o Qt::BusyCursor \o \c left_ptr_watch
+ \o \inlineimage cursor-vsplit.png
+ \o Qt::SplitVCursor \o \c split_v
+ \row \o \inlineimage cursor-forbidden.png
+ \o Qt::ForbiddenCursor \o \c forbidden
+ \o \inlineimage cursor-hsplit.png
+ \o Qt::SplitHCursor \o \c split_h
+ \row \o \inlineimage cursor-hand.png
+ \o Qt::PointingHandCursor \o \c pointing_hand
+ \o \inlineimage cursor-openhand.png
+ \o Qt::OpenHandCursor \o \c openhand
+ \row \o \inlineimage cursor-whatsthis.png
+ \o Qt::WhatsThisCursor \o \c whats_this
+ \o \inlineimage cursor-closedhand.png
+ \o Qt::ClosedHandCursor \o \c closedhand
+ \row \o
+ \o Qt::DragMoveCursor \o \c dnd-move or \c move
+ \o
+ \o Qt::DragCopyCursor \o \c dnd-copy or \c copy
+ \row \o
+ \o Qt::DragLinkCursor \o \c dnd-link or \c link
+ \endtable
+
+ \sa QWidget, {fowler}{GUI Design Handbook: Cursors}
+*/
+
+/*!
+ \fn HCURSOR_or_HANDLE QCursor::handle() const
+
+ Returns a platform-specific cursor handle. The \c
+ HCURSOR_or_HANDLE type is \c HCURSOR on Windows and Qt::HANDLE on X11
+ and Mac OS X. On \l{Qt for Embedded Linux} it is an integer.
+
+ \warning Using the value returned by this function is not
+ portable.
+*/
+
+/*!
+ \fn QCursor::QCursor(HCURSOR cursor)
+
+ Constructs a Qt cursor from the given Windows \a cursor.
+
+ \warning This function is only available on Windows.
+
+ \sa handle()
+*/
+
+/*!
+ \fn QCursor::QCursor(Qt::HANDLE handle)
+
+ Constructs a Qt cursor from the given \a handle.
+
+ \warning This function is only available on X11.
+
+ \sa handle()
+*/
+
+/*!
+ \fn QPoint QCursor::pos()
+
+ Returns the position of the cursor (hot spot) in global screen
+ coordinates.
+
+ You can call QWidget::mapFromGlobal() to translate it to widget
+ coordinates.
+
+ \sa setPos(), QWidget::mapFromGlobal(), QWidget::mapToGlobal()
+*/
+
+/*!
+ \fn void QCursor::setPos(int x, int y)
+
+ Moves the cursor (hot spot) to the global screen position (\a x,
+ \a y).
+
+ You can call QWidget::mapToGlobal() to translate widget
+ coordinates to global screen coordinates.
+
+ \sa pos(), QWidget::mapFromGlobal(), QWidget::mapToGlobal()
+*/
+
+/*!
+ \fn void QCursor::setPos (const QPoint &p)
+
+ \overload
+
+ Moves the cursor (hot spot) to the global screen position at point
+ \a p.
+*/
+
+/*****************************************************************************
+ QCursor stream functions
+ *****************************************************************************/
+
+#ifndef QT_NO_DATASTREAM
+
+
+/*!
+ \fn QDataStream &operator<<(QDataStream &stream, const QCursor &cursor)
+ \relates QCursor
+
+ Writes the \a cursor to the \a stream.
+
+ \sa {Serializing Qt Data Types}
+*/
+
+QDataStream &operator<<(QDataStream &s, const QCursor &c)
+{
+ s << (qint16)c.shape(); // write shape id to stream
+ if (c.shape() == Qt::BitmapCursor) { // bitmap cursor
+ bool isPixmap = false;
+ if (s.version() >= 7) {
+ isPixmap = !c.pixmap().isNull();
+ s << isPixmap;
+ }
+ if (isPixmap)
+ s << c.pixmap();
+ else
+ s << *c.bitmap() << *c.mask();
+ s << c.hotSpot();
+ }
+ return s;
+}
+
+/*!
+ \fn QDataStream &operator>>(QDataStream &stream, QCursor &cursor)
+ \relates QCursor
+
+ Reads the \a cursor from the \a stream.
+
+ \sa {Serializing Qt Data Types}
+*/
+
+QDataStream &operator>>(QDataStream &s, QCursor &c)
+{
+ qint16 shape;
+ s >> shape; // read shape id from stream
+ if (shape == Qt::BitmapCursor) { // read bitmap cursor
+ bool isPixmap = false;
+ if (s.version() >= 7)
+ s >> isPixmap;
+ if (isPixmap) {
+ QPixmap pm;
+ QPoint hot;
+ s >> pm >> hot;
+ c = QCursor(pm, hot.x(), hot.y());
+ } else {
+ QBitmap bm, bmm;
+ QPoint hot;
+ s >> bm >> bmm >> hot;
+ c = QCursor(bm, bmm, hot.x(), hot.y());
+ }
+ } else {
+ c.setShape((Qt::CursorShape)shape); // create cursor with shape
+ }
+ return s;
+}
+#endif // QT_NO_DATASTREAM
+
+
+/*!
+ Constructs a custom pixmap cursor.
+
+ \a pixmap is the image. It is usual to give it a mask (set using
+ QPixmap::setMask()). \a hotX and \a hotY define the cursor's hot
+ spot.
+
+ If \a hotX is negative, it is set to the \c{pixmap().width()/2}.
+ If \a hotY is negative, it is set to the \c{pixmap().height()/2}.
+
+ Valid cursor sizes depend on the display hardware (or the
+ underlying window system). We recommend using 32 x 32 cursors,
+ because this size is supported on all platforms. Some platforms
+ also support 16 x 16, 48 x 48, and 64 x 64 cursors.
+
+ \note On Windows CE, the cursor size is fixed. If the pixmap
+ is bigger than the system size, it will be scaled.
+
+ \sa QPixmap::QPixmap(), QPixmap::setMask()
+*/
+
+QCursor::QCursor(const QPixmap &pixmap, int hotX, int hotY)
+ : d(0)
+{
+ QImage img = pixmap.toImage().convertToFormat(QImage::Format_Indexed8, Qt::ThresholdDither|Qt::AvoidDither);
+ QBitmap bm = QBitmap::fromImage(img, Qt::ThresholdDither|Qt::AvoidDither);
+ QBitmap bmm = pixmap.mask();
+ if (!bmm.isNull()) {
+ QBitmap nullBm;
+ bm.setMask(nullBm);
+ }
+ else if (!pixmap.mask().isNull()) {
+ QImage mimg = pixmap.mask().toImage().convertToFormat(QImage::Format_Indexed8, Qt::ThresholdDither|Qt::AvoidDither);
+ bmm = QBitmap::fromImage(mimg, Qt::ThresholdDither|Qt::AvoidDither);
+ }
+ else {
+ bmm = QBitmap(bm.size());
+ bmm.fill(Qt::color1);
+ }
+
+ d = QCursorData::setBitmap(bm, bmm, hotX, hotY);
+ d->pixmap = pixmap;
+}
+
+
+
+/*!
+ Constructs a custom bitmap cursor.
+
+ \a bitmap and
+ \a mask make up the bitmap.
+ \a hotX and
+ \a hotY define the cursor's hot spot.
+
+ If \a hotX is negative, it is set to the \c{bitmap().width()/2}.
+ If \a hotY is negative, it is set to the \c{bitmap().height()/2}.
+
+ The cursor \a bitmap (B) and \a mask (M) bits are combined like this:
+ \list
+ \o B=1 and M=1 gives black.
+ \o B=0 and M=1 gives white.
+ \o B=0 and M=0 gives transparent.
+ \o B=1 and M=0 gives an XOR'd result under Windows, undefined
+ results on all other platforms.
+ \endlist
+
+ Use the global Qt color Qt::color0 to draw 0-pixels and Qt::color1 to
+ draw 1-pixels in the bitmaps.
+
+ Valid cursor sizes depend on the display hardware (or the
+ underlying window system). We recommend using 32 x 32 cursors,
+ because this size is supported on all platforms. Some platforms
+ also support 16 x 16, 48 x 48, and 64 x 64 cursors.
+
+ \note On Windows CE, the cursor size is fixed. If the pixmap
+ is bigger than the system size, it will be scaled.
+
+ \sa QBitmap::QBitmap(), QBitmap::setMask()
+*/
+
+QCursor::QCursor(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY)
+ : d(0)
+{
+ d = QCursorData::setBitmap(bitmap, mask, hotX, hotY);
+}
+
+QCursorData *qt_cursorTable[Qt::LastCursor + 1];
+bool QCursorData::initialized = false;
+
+/*! \internal */
+void QCursorData::cleanup()
+{
+ if(!QCursorData::initialized)
+ return;
+
+ for (int shape = 0; shape <= Qt::LastCursor; ++shape) {
+ // In case someone has a static QCursor defined with this shape
+ if (!qt_cursorTable[shape]->ref.deref())
+ delete qt_cursorTable[shape];
+ qt_cursorTable[shape] = 0;
+ }
+ QCursorData::initialized = false;
+}
+
+/*! \internal */
+void QCursorData::initialize()
+{
+ if (QCursorData::initialized)
+ return;
+#ifdef Q_WS_MAC
+ // DRSWAT - Not Needed Cocoa or Carbon
+ //InitCursor();
+#endif
+ for (int shape = 0; shape <= Qt::LastCursor; ++shape)
+ qt_cursorTable[shape] = new QCursorData((Qt::CursorShape)shape);
+ QCursorData::initialized = true;
+}
+
+/*!
+ Constructs a cursor with the default arrow shape.
+*/
+QCursor::QCursor()
+{
+ if (!QCursorData::initialized) {
+ if (QCoreApplication::startingUp()) {
+ d = 0;
+ return;
+ }
+ QCursorData::initialize();
+ }
+ QCursorData *c = qt_cursorTable[0];
+ c->ref.ref();
+ d = c;
+}
+
+/*!
+ Constructs a cursor with the specified \a shape.
+
+ See \l Qt::CursorShape for a list of shapes.
+
+ \sa setShape()
+*/
+QCursor::QCursor(Qt::CursorShape shape)
+ : d(0)
+{
+ if (!QCursorData::initialized)
+ QCursorData::initialize();
+ setShape(shape);
+}
+
+
+/*!
+ Returns the cursor shape identifier. The return value is one of
+ the \l Qt::CursorShape enum values (cast to an int).
+
+ \sa setShape()
+*/
+Qt::CursorShape QCursor::shape() const
+{
+ if (!QCursorData::initialized)
+ QCursorData::initialize();
+ return d->cshape;
+}
+
+/*!
+ Sets the cursor to the shape identified by \a shape.
+
+ See \l Qt::CursorShape for the list of cursor shapes.
+
+ \sa shape()
+*/
+void QCursor::setShape(Qt::CursorShape shape)
+{
+ if (!QCursorData::initialized)
+ QCursorData::initialize();
+ QCursorData *c = uint(shape) <= Qt::LastCursor ? qt_cursorTable[shape] : 0;
+ if (!c)
+ c = qt_cursorTable[0];
+ c->ref.ref();
+ if (!d) {
+ d = c;
+ } else {
+ if (!d->ref.deref())
+ delete d;
+ d = c;
+ }
+}
+
+/*!
+ Returns the cursor bitmap, or 0 if it is one of the standard
+ cursors.
+*/
+const QBitmap *QCursor::bitmap() const
+{
+ if (!QCursorData::initialized)
+ QCursorData::initialize();
+ return d->bm;
+}
+
+/*!
+ Returns the cursor bitmap mask, or 0 if it is one of the standard
+ cursors.
+*/
+
+const QBitmap *QCursor::mask() const
+{
+ if (!QCursorData::initialized)
+ QCursorData::initialize();
+ return d->bmm;
+}
+
+/*!
+ Returns the cursor pixmap. This is only valid if the cursor is a
+ pixmap cursor.
+*/
+
+QPixmap QCursor::pixmap() const
+{
+ if (!QCursorData::initialized)
+ QCursorData::initialize();
+ return d->pixmap;
+}
+
+/*!
+ Returns the cursor hot spot, or (0, 0) if it is one of the
+ standard cursors.
+*/
+
+QPoint QCursor::hotSpot() const
+{
+ if (!QCursorData::initialized)
+ QCursorData::initialize();
+ return QPoint(d->hx, d->hy);
+}
+
+/*!
+ Constructs a copy of the cursor \a c.
+*/
+
+QCursor::QCursor(const QCursor &c)
+{
+ if (!QCursorData::initialized)
+ QCursorData::initialize();
+ d = c.d;
+ d->ref.ref();
+}
+
+/*!
+ Destroys the cursor.
+*/
+
+QCursor::~QCursor()
+{
+ if (d && !d->ref.deref())
+ delete d;
+}
+
+
+/*!
+ Assigns \a c to this cursor and returns a reference to this
+ cursor.
+*/
+
+QCursor &QCursor::operator=(const QCursor &c)
+{
+ if (!QCursorData::initialized)
+ QCursorData::initialize();
+ if (c.d)
+ c.d->ref.ref();
+ if (d && !d->ref.deref())
+ delete d;
+ d = c.d;
+ return *this;
+}
+
+/*!
+ Returns the cursor as a QVariant.
+*/
+QCursor::operator QVariant() const
+{
+ return QVariant(QVariant::Cursor, this);
+}
+QT_END_NAMESPACE
+#endif // QT_NO_CURSOR
+
diff --git a/src/gui/guikernel/qcursor.h b/src/gui/guikernel/qcursor.h
new file mode 100644
index 0000000000..b47ec04d66
--- /dev/null
+++ b/src/gui/guikernel/qcursor.h
@@ -0,0 +1,168 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCURSOR_H
+#define QCURSOR_H
+
+#include <QtCore/qpoint.h>
+#include <QtGui/qwindowdefs.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QVariant;
+
+/*
+ ### The fake cursor has to go first with old qdoc.
+*/
+#ifdef QT_NO_CURSOR
+
+class Q_GUI_EXPORT QCursor
+{
+public:
+ static QPoint pos();
+ static void setPos(int x, int y);
+ inline static void setPos(const QPoint &p) { setPos(p.x(), p.y()); }
+private:
+ QCursor();
+};
+
+#endif // QT_NO_CURSOR
+
+#ifndef QT_NO_CURSOR
+
+class QCursorData;
+class QBitmap;
+class QPixmap;
+
+#if defined(Q_WS_MAC)
+void qt_mac_set_cursor(const QCursor *c);
+#endif
+#if defined(Q_OS_SYMBIAN)
+extern void qt_symbian_show_pointer_sprite();
+extern void qt_symbian_hide_pointer_sprite();
+extern void qt_symbian_set_pointer_sprite(const QCursor& cursor);
+extern void qt_symbian_move_cursor_sprite();
+#endif
+
+class Q_GUI_EXPORT QCursor
+{
+public:
+ QCursor();
+ QCursor(Qt::CursorShape shape);
+ QCursor(const QBitmap &bitmap, const QBitmap &mask, int hotX=-1, int hotY=-1);
+ QCursor(const QPixmap &pixmap, int hotX=-1, int hotY=-1);
+ QCursor(const QCursor &cursor);
+ ~QCursor();
+ QCursor &operator=(const QCursor &cursor);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QCursor &operator=(QCursor &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
+ operator QVariant() const;
+
+ Qt::CursorShape shape() const;
+ void setShape(Qt::CursorShape newShape);
+
+ const QBitmap *bitmap() const;
+ const QBitmap *mask() const;
+ QPixmap pixmap() const;
+ QPoint hotSpot() const;
+
+ static QPoint pos();
+ static void setPos(int x, int y);
+ inline static void setPos(const QPoint &p) { setPos(p.x(), p.y()); }
+
+#ifdef qdoc
+ HCURSOR_or_HANDLE handle() const;
+ QCursor(HCURSOR cursor);
+ QCursor(Qt::HANDLE cursor);
+#endif
+
+#ifndef qdoc
+#if defined(Q_WS_WIN)
+ HCURSOR handle() const;
+ QCursor(HCURSOR cursor);
+#elif defined(Q_WS_X11)
+ Qt::HANDLE handle() const;
+ QCursor(Qt::HANDLE cursor);
+ static int x11Screen();
+#elif defined(Q_WS_MAC)
+ Qt::HANDLE handle() const;
+#elif defined(Q_WS_QWS) || defined(Q_WS_QPA)
+ int handle() const;
+#elif defined(Q_OS_SYMBIAN)
+ Qt::HANDLE handle() const;
+#endif
+#endif
+
+private:
+ QCursorData *d;
+#if defined(Q_WS_MAC)
+ friend void *qt_mac_nsCursorForQCursor(const QCursor &c);
+ friend void qt_mac_set_cursor(const QCursor *c);
+ friend void qt_mac_updateCursorWithWidgetUnderMouse(QWidget *widgetUnderMouse);
+#endif
+#if defined(Q_OS_SYMBIAN)
+ friend void qt_symbian_show_pointer_sprite();
+ friend void qt_symbian_hide_pointer_sprite();
+ friend void qt_symbian_set_pointer_sprite(const QCursor& cursor);
+ friend void qt_symbian_move_cursor_sprite();
+#endif
+};
+
+/*****************************************************************************
+ QCursor stream functions
+ *****************************************************************************/
+#ifndef QT_NO_DATASTREAM
+Q_GUI_EXPORT QDataStream &operator<<(QDataStream &outS, const QCursor &cursor);
+Q_GUI_EXPORT QDataStream &operator>>(QDataStream &inS, QCursor &cursor);
+#endif
+#endif // QT_NO_CURSOR
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QCURSOR_H
diff --git a/src/gui/kernel/qcursor_p.h b/src/gui/guikernel/qcursor_p.h
index 660a2a5e8b..660a2a5e8b 100644
--- a/src/gui/kernel/qcursor_p.h
+++ b/src/gui/guikernel/qcursor_p.h
diff --git a/src/gui/kernel/qcursor_qpa.cpp b/src/gui/guikernel/qcursor_qpa.cpp
index a6ae7d30f5..a6ae7d30f5 100644
--- a/src/gui/kernel/qcursor_qpa.cpp
+++ b/src/gui/guikernel/qcursor_qpa.cpp
diff --git a/src/gui/guikernel/qevent.cpp b/src/gui/guikernel/qevent.cpp
new file mode 100644
index 0000000000..2b2277dfd4
--- /dev/null
+++ b/src/gui/guikernel/qevent.cpp
@@ -0,0 +1,4305 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qevent.h"
+#include "qcursor.h"
+#include "private/qguiapplication_p.h"
+#include "private/qevent_p.h"
+#include "private/qkeysequence_p.h"
+#include "qdebug.h"
+#include "qmime.h"
+//#include "private/qdnd_p.h"
+#include "qevent_p.h"
+
+#ifdef Q_OS_SYMBIAN
+#include "private/qcore_symbian_p.h"
+#endif
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QInputEvent
+ \ingroup events
+
+ \brief The QInputEvent class is the base class for events that
+ describe user input.
+*/
+
+/*!
+ \internal
+*/
+QInputEvent::QInputEvent(Type type, Qt::KeyboardModifiers modifiers)
+ : QEvent(type), modState(modifiers)
+{}
+
+/*!
+ \internal
+*/
+QInputEvent::~QInputEvent()
+{
+}
+
+/*!
+ \fn Qt::KeyboardModifiers QInputEvent::modifiers() const
+
+ Returns the keyboard modifier flags that existed immediately
+ before the event occurred.
+
+ \sa QApplication::keyboardModifiers()
+*/
+
+/*! \fn void QInputEvent::setModifiers(Qt::KeyboardModifiers modifiers)
+
+ \internal
+
+ Sets the keyboard modifiers flags for this event.
+*/
+
+/*!
+ \class QMouseEvent
+ \ingroup events
+
+ \brief The QMouseEvent class contains parameters that describe a mouse event.
+
+ Mouse events occur when a mouse button is pressed or released
+ inside a widget, or when the mouse cursor is moved.
+
+ Mouse move events will occur only when a mouse button is pressed
+ down, unless mouse tracking has been enabled with
+ QWidget::setMouseTracking().
+
+ Qt automatically grabs the mouse when a mouse button is pressed
+ inside a widget; the widget will continue to receive mouse events
+ until the last mouse button is released.
+
+ A mouse event contains a special accept flag that indicates
+ whether the receiver wants the event. You should call ignore() if
+ the mouse event is not handled by your widget. A mouse event is
+ propagated up the parent widget chain until a widget accepts it
+ with accept(), or an event filter consumes it.
+
+ \note If a mouse event is propagated to a \l{QWidget}{widget} for
+ which Qt::WA_NoMousePropagation has been set, that mouse event
+ will not be propagated further up the parent widget chain.
+
+ The state of the keyboard modifier keys can be found by calling the
+ \l{QInputEvent::modifiers()}{modifiers()} function, inherited from
+ QInputEvent.
+
+ The functions pos(), x(), and y() give the cursor position
+ relative to the widget that receives the mouse event. If you
+ move the widget as a result of the mouse event, use the global
+ position returned by globalPos() to avoid a shaking motion.
+
+ The QWidget::setEnabled() function can be used to enable or
+ disable mouse and keyboard events for a widget.
+
+ Reimplement the QWidget event handlers, QWidget::mousePressEvent(),
+ QWidget::mouseReleaseEvent(), QWidget::mouseDoubleClickEvent(),
+ and QWidget::mouseMoveEvent() to receive mouse events in your own
+ widgets.
+
+ \sa QWidget::setMouseTracking() QWidget::grabMouse()
+ QCursor::pos()
+*/
+
+/*!
+ Constructs a mouse event object.
+
+ The \a type parameter must be one of QEvent::MouseButtonPress,
+ QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
+ or QEvent::MouseMove.
+
+ The \a position is the mouse cursor's position relative to the
+ receiving widget.
+ The \a button that caused the event is given as a value from
+ the Qt::MouseButton enum. If the event \a type is
+ \l MouseMove, the appropriate button for this event is Qt::NoButton.
+ The mouse and keyboard states at the time of the event are specified by
+ \a buttons and \a modifiers.
+
+ The globalPos() is initialized to QCursor::pos(), which may not
+ be appropriate. Use the other constructor to specify the global
+ position explicitly.
+*/
+
+QMouseEvent::QMouseEvent(Type type, const QPoint &position, Qt::MouseButton button,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
+ : QInputEvent(type, modifiers), p(position), b(button), mouseState(buttons)
+{
+ g = QCursor::pos();
+}
+
+/*!
+ \internal
+*/
+QMouseEvent::~QMouseEvent()
+{
+}
+
+
+/*!
+ Constructs a mouse event object.
+
+ The \a type parameter must be QEvent::MouseButtonPress,
+ QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
+ or QEvent::MouseMove.
+
+ The \a pos is the mouse cursor's position relative to the
+ receiving widget. The cursor's position in global coordinates is
+ specified by \a globalPos. The \a button that caused the event is
+ given as a value from the \l Qt::MouseButton enum. If the event \a
+ type is \l MouseMove, the appropriate button for this event is
+ Qt::NoButton. \a buttons is the state of all buttons at the
+ time of the event, \a modifiers the state of all keyboard
+ modifiers.
+
+*/
+QMouseEvent::QMouseEvent(Type type, const QPoint &pos, const QPoint &globalPos,
+ Qt::MouseButton button, Qt::MouseButtons buttons,
+ Qt::KeyboardModifiers modifiers)
+ : QInputEvent(type, modifiers), p(pos), g(globalPos), b(button), mouseState(buttons)
+{}
+
+/*!
+ \internal
+*/
+QMouseEvent *QMouseEvent::createExtendedMouseEvent(Type type, const QPointF &pos,
+ const QPoint &globalPos, Qt::MouseButton button,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
+{
+ return new QMouseEventEx(type, pos, globalPos, button, buttons, modifiers);
+}
+
+/*!
+ \fn bool QMouseEvent::hasExtendedInfo() const
+ \internal
+*/
+
+/*!
+ \since 4.4
+
+ Returns the position of the mouse cursor as a QPointF, relative to the
+ widget that received the event.
+
+ If you move the widget as a result of the mouse event, use the
+ global position returned by globalPos() to avoid a shaking
+ motion.
+
+ \sa x() y() pos() globalPos()
+*/
+QPointF QMouseEvent::posF() const
+{
+ return hasExtendedInfo() ? reinterpret_cast<const QMouseEventEx *>(this)->posF : QPointF(pos());
+}
+
+/*!
+ \internal
+*/
+QMouseEventEx::QMouseEventEx(Type type, const QPointF &pos, const QPoint &globalPos,
+ Qt::MouseButton button, Qt::MouseButtons buttons,
+ Qt::KeyboardModifiers modifiers)
+ : QMouseEvent(type, pos.toPoint(), globalPos, button, buttons, modifiers), posF(pos)
+{
+ d = reinterpret_cast<QEventPrivate *>(this);
+}
+
+/*!
+ \internal
+*/
+QMouseEventEx::~QMouseEventEx()
+{
+}
+
+/*!
+ \fn const QPoint &QMouseEvent::pos() const
+
+ Returns the position of the mouse cursor, relative to the widget
+ that received the event.
+
+ If you move the widget as a result of the mouse event, use the
+ global position returned by globalPos() to avoid a shaking
+ motion.
+
+ \sa x() y() globalPos()
+*/
+
+/*!
+ \fn const QPoint &QMouseEvent::globalPos() const
+
+ Returns the global position of the mouse cursor \e{at the time
+ of the event}. This is important on asynchronous window systems
+ like X11. Whenever you move your widgets around in response to
+ mouse events, globalPos() may differ a lot from the current
+ pointer position QCursor::pos(), and from
+ QWidget::mapToGlobal(pos()).
+
+ \sa globalX() globalY()
+*/
+
+/*!
+ \fn int QMouseEvent::x() const
+
+ Returns the x position of the mouse cursor, relative to the
+ widget that received the event.
+
+ \sa y() pos()
+*/
+
+/*!
+ \fn int QMouseEvent::y() const
+
+ Returns the y position of the mouse cursor, relative to the
+ widget that received the event.
+
+ \sa x() pos()
+*/
+
+/*!
+ \fn int QMouseEvent::globalX() const
+
+ Returns the global x position of the mouse cursor at the time of
+ the event.
+
+ \sa globalY() globalPos()
+*/
+
+/*!
+ \fn int QMouseEvent::globalY() const
+
+ Returns the global y position of the mouse cursor at the time of
+ the event.
+
+ \sa globalX() globalPos()
+*/
+
+/*!
+ \fn Qt::MouseButton QMouseEvent::button() const
+
+ Returns the button that caused the event.
+
+ Note that the returned value is always Qt::NoButton for mouse
+ move events.
+
+ \sa buttons() Qt::MouseButton
+*/
+
+/*!
+ \fn Qt::MouseButton QMouseEvent::buttons() const
+
+ Returns the button state when the event was generated. The button
+ state is a combination of Qt::LeftButton, Qt::RightButton,
+ Qt::MidButton using the OR operator. For mouse move events,
+ this is all buttons that are pressed down. For mouse press and
+ double click events this includes the button that caused the
+ event. For mouse release events this excludes the button that
+ caused the event.
+
+ \sa button() Qt::MouseButton
+*/
+
+
+/*!
+ \fn Qt::ButtonState QMouseEvent::state() const
+
+ Returns the button state immediately before the event was
+ generated. The button state is a combination of mouse buttons
+ (see Qt::ButtonState) and keyboard modifiers (Qt::MouseButtons).
+
+ Use buttons() and/or modifiers() instead. Be aware that buttons()
+ return the state immediately \e after the event was generated.
+*/
+
+/*!
+ \fn Qt::ButtonState QMouseEvent::stateAfter() const
+
+ Returns the button state immediately after the event was
+ generated. The button state is a combination of mouse buttons
+ (see Qt::ButtonState) and keyboard modifiers (Qt::MouseButtons).
+
+ Use buttons() and/or modifiers() instead.
+*/
+
+/*!
+ \class QHoverEvent
+ \ingroup events
+
+ \brief The QHoverEvent class contains parameters that describe a mouse event.
+
+ Mouse events occur when a mouse cursor is moved into, out of, or within a
+ widget, and if the widget has the Qt::WA_Hover attribute.
+
+ The function pos() gives the current cursor position, while oldPos() gives
+ the old mouse position.
+
+ There are a few similarities between the events QEvent::HoverEnter
+ and QEvent::HoverLeave, and the events QEvent::Enter and QEvent::Leave.
+ However, they are slightly different because we do an update() in the event
+ handler of HoverEnter and HoverLeave.
+
+ QEvent::HoverMove is also slightly different from QEvent::MouseMove. Let us
+ consider a top-level window A containing a child B which in turn contains a
+ child C (all with mouse tracking enabled):
+
+ \image hoverevents.png
+
+ Now, if you move the cursor from the top to the bottom in the middle of A,
+ you will get the following QEvent::MouseMove events:
+
+ \list 1
+ \o A::MouseMove
+ \o B::MouseMove
+ \o C::MouseMove
+ \endlist
+
+ You will get the same events for QEvent::HoverMove, except that the event
+ always propagates to the top-level regardless whether the event is accepted
+ or not. It will only stop propagating with the Qt::WA_NoMousePropagation
+ attribute.
+
+ In this case the events will occur in the following way:
+
+ \list 1
+ \o A::HoverMove
+ \o A::HoverMove, B::HoverMove
+ \o A::HoverMove, B::HoverMove, C::HoverMove
+ \endlist
+
+*/
+
+/*!
+ \fn const QPoint &QHoverEvent::pos() const
+
+ Returns the position of the mouse cursor, relative to the widget
+ that received the event.
+
+ On QEvent::HoverLeave events, this position will always be
+ QPoint(-1, -1).
+
+ \sa oldPos()
+*/
+
+/*!
+ \fn const QPoint &QHoverEvent::oldPos() const
+
+ Returns the previous position of the mouse cursor, relative to the widget
+ that received the event. If there is no previous position, oldPos() will
+ return the same position as pos().
+
+ On QEvent::HoverEnter events, this position will always be
+ QPoint(-1, -1).
+
+ \sa pos()
+*/
+
+/*!
+ Constructs a hover event object.
+
+ The \a type parameter must be QEvent::HoverEnter,
+ QEvent::HoverLeave, or QEvent::HoverMove.
+
+ The \a pos is the current mouse cursor's position relative to the
+ receiving widget, while \a oldPos is the previous mouse cursor's
+ position relative to the receiving widget.
+*/
+QHoverEvent::QHoverEvent(Type type, const QPoint &pos, const QPoint &oldPos)
+ : QEvent(type), p(pos), op(oldPos)
+{
+}
+
+/*!
+ \internal
+*/
+QHoverEvent::~QHoverEvent()
+{
+}
+
+
+/*!
+ \class QWheelEvent
+ \brief The QWheelEvent class contains parameters that describe a wheel event.
+
+ \ingroup events
+
+ Wheel events are sent to the widget under the mouse cursor, but
+ if that widget does not handle the event they are sent to the
+ focus widget. The rotation distance is provided by delta().
+ The functions pos() and globalPos() return the mouse cursor's
+ location at the time of the event.
+
+ A wheel event contains a special accept flag that indicates
+ whether the receiver wants the event. You should call ignore() if
+ you do not handle the wheel event; this ensures that it will be
+ sent to the parent widget.
+
+ The QWidget::setEnabled() function can be used to enable or
+ disable mouse and keyboard events for a widget.
+
+ The event handler QWidget::wheelEvent() receives wheel events.
+
+ \sa QMouseEvent QWidget::grabMouse()
+*/
+
+/*!
+ \fn Qt::MouseButtons QWheelEvent::buttons() const
+
+ Returns the mouse state when the event occurred.
+*/
+
+/*!
+ \fn Qt::Orientation QWheelEvent::orientation() const
+
+ Returns the wheel's orientation.
+*/
+
+/*!
+ Constructs a wheel event object.
+
+ The position, \a pos, is the location of the mouse cursor within
+ the widget. The globalPos() is initialized to QCursor::pos()
+ which is usually, but not always, correct.
+ Use the other constructor if you need to specify the global
+ position explicitly.
+
+ The \a buttons describe the state of the mouse buttons at the time
+ of the event, \a delta contains the rotation distance,
+ \a modifiers holds the keyboard modifier flags at the time of the
+ event, and \a orient holds the wheel's orientation.
+
+ \sa pos() delta() state()
+*/
+#ifndef QT_NO_WHEELEVENT
+QWheelEvent::QWheelEvent(const QPoint &pos, int delta,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
+ Qt::Orientation orient)
+ : QInputEvent(Wheel, modifiers), p(pos), d(delta), mouseState(buttons), o(orient)
+{
+ g = QCursor::pos();
+}
+
+/*!
+ \internal
+*/
+QWheelEvent::~QWheelEvent()
+{
+}
+
+/*!
+ Constructs a wheel event object.
+
+ The \a pos provides the location of the mouse cursor
+ within the widget. The position in global coordinates is specified
+ by \a globalPos. \a delta contains the rotation distance, \a modifiers
+ holds the keyboard modifier flags at the time of the event, and
+ \a orient holds the wheel's orientation.
+
+ \sa pos() globalPos() delta() state()
+*/
+QWheelEvent::QWheelEvent(const QPoint &pos, const QPoint& globalPos, int delta,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
+ Qt::Orientation orient)
+ : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), d(delta), mouseState(buttons), o(orient)
+{}
+
+#endif // QT_NO_WHEELEVENT
+
+/*!
+ \fn int QWheelEvent::delta() const
+
+ Returns the distance that the wheel is rotated, in eighths of a
+ degree. A positive value indicates that the wheel was rotated
+ forwards away from the user; a negative value indicates that the
+ wheel was rotated backwards toward the user.
+
+ Most mouse types work in steps of 15 degrees, in which case the
+ delta value is a multiple of 120; i.e., 120 units * 1/8 = 15 degrees.
+
+ However, some mice have finer-resolution wheels and send delta values
+ that are less than 120 units (less than 15 degrees). To support this
+ possibility, you can either cumulatively add the delta values from events
+ until the value of 120 is reached, then scroll the widget, or you can
+ partially scroll the widget in response to each wheel event.
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qevent.cpp 0
+*/
+
+/*!
+ \fn const QPoint &QWheelEvent::pos() const
+
+ Returns the position of the mouse cursor relative to the widget
+ that received the event.
+
+ If you move your widgets around in response to mouse events,
+ use globalPos() instead of this function.
+
+ \sa x() y() globalPos()
+*/
+
+/*!
+ \fn int QWheelEvent::x() const
+
+ Returns the x position of the mouse cursor, relative to the
+ widget that received the event.
+
+ \sa y() pos()
+*/
+
+/*!
+ \fn int QWheelEvent::y() const
+
+ Returns the y position of the mouse cursor, relative to the
+ widget that received the event.
+
+ \sa x() pos()
+*/
+
+
+/*!
+ \fn const QPoint &QWheelEvent::globalPos() const
+
+ Returns the global position of the mouse pointer \e{at the time
+ of the event}. This is important on asynchronous window systems
+ such as X11; whenever you move your widgets around in response to
+ mouse events, globalPos() can differ a lot from the current
+ cursor position returned by QCursor::pos().
+
+ \sa globalX() globalY()
+*/
+
+/*!
+ \fn int QWheelEvent::globalX() const
+
+ Returns the global x position of the mouse cursor at the time of
+ the event.
+
+ \sa globalY() globalPos()
+*/
+
+/*!
+ \fn int QWheelEvent::globalY() const
+
+ Returns the global y position of the mouse cursor at the time of
+ the event.
+
+ \sa globalX() globalPos()
+*/
+
+
+/*! \obsolete
+ \fn Qt::ButtonState QWheelEvent::state() const
+
+ Returns the keyboard modifier flags at the time of the event.
+
+ The returned value is a selection of the following values,
+ combined using the OR operator: Qt::ShiftButton,
+ Qt::ControlButton, and Qt::AltButton.
+*/
+
+
+/*!
+ \class QKeyEvent
+ \brief The QKeyEvent class describes a key event.
+
+ \ingroup events
+
+ Key events are sent to the widget with keyboard input focus
+ when keys are pressed or released.
+
+ A key event contains a special accept flag that indicates whether
+ the receiver will handle the key event. You should call ignore()
+ if the key press or release event is not handled by your widget.
+ A key event is propagated up the parent widget chain until a
+ widget accepts it with accept() or an event filter consumes it.
+ Key events for multimedia keys are ignored by default. You should
+ call accept() if your widget handles those events.
+
+ The QWidget::setEnable() function can be used to enable or disable
+ mouse and keyboard events for a widget.
+
+ The event handlers QWidget::keyPressEvent(), QWidget::keyReleaseEvent(),
+ QGraphicsItem::keyPressEvent() and QGraphicsItem::keyReleaseEvent()
+ receive key events.
+
+ \sa QFocusEvent, QWidget::grabKeyboard()
+*/
+
+/*!
+ Constructs a key event object.
+
+ The \a type parameter must be QEvent::KeyPress, QEvent::KeyRelease,
+ or QEvent::ShortcutOverride.
+
+ Int \a key is the code for the Qt::Key that the event loop should listen
+ for. If \a key is 0, the event is not a result of a known key; for
+ example, it may be the result of a compose sequence or keyboard macro.
+ The \a modifiers holds the keyboard modifiers, and the given \a text
+ is the Unicode text that the key generated. If \a autorep is true,
+ isAutoRepeat() will be true. \a count is the number of keys involved
+ in the event.
+*/
+QKeyEvent::QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text,
+ bool autorep, ushort count)
+ : QInputEvent(type, modifiers), txt(text), k(key), c(count), autor(autorep)
+{
+}
+
+/*!
+ \internal
+*/
+QKeyEvent::~QKeyEvent()
+{
+}
+
+/*!
+ \internal
+*/
+QKeyEvent *QKeyEvent::createExtendedKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers,
+ quint32 nativeScanCode, quint32 nativeVirtualKey,
+ quint32 nativeModifiers,
+ const QString& text, bool autorep, ushort count)
+{
+ return new QKeyEventEx(type, key, modifiers, text, autorep, count,
+ nativeScanCode, nativeVirtualKey, nativeModifiers);
+}
+
+/*!
+ \fn bool QKeyEvent::hasExtendedInfo() const
+ \internal
+*/
+
+/*!
+ \since 4.2
+
+ Returns the native scan code of the key event. If the key event
+ does not contain this data 0 is returned.
+
+ Note: The native scan code may be 0, even if the key event contains
+ extended information.
+
+ Note: On Mac OS/X, this function is not useful, because there is no
+ way to get the scan code from Carbon or Cocoa. The function always
+ returns 1 (or 0 in the case explained above).
+*/
+quint32 QKeyEvent::nativeScanCode() const
+{
+ return (reinterpret_cast<const QKeyEvent*>(d) != this
+ ? 0 : reinterpret_cast<const QKeyEventEx*>(this)->nScanCode);
+}
+
+/*!
+ \since 4.2
+
+ Returns the native virtual key, or key sym of the key event.
+ If the key event does not contain this data 0 is returned.
+
+ Note: The native virtual key may be 0, even if the key event contains extended information.
+*/
+quint32 QKeyEvent::nativeVirtualKey() const
+{
+ return (reinterpret_cast<const QKeyEvent*>(d) != this
+ ? 0 : reinterpret_cast<const QKeyEventEx*>(this)->nVirtualKey);
+}
+
+/*!
+ \since 4.2
+
+ Returns the native modifiers of a key event.
+ If the key event does not contain this data 0 is returned.
+
+ Note: The native modifiers may be 0, even if the key event contains extended information.
+*/
+quint32 QKeyEvent::nativeModifiers() const
+{
+ return (reinterpret_cast<const QKeyEvent*>(d) != this
+ ? 0 : reinterpret_cast<const QKeyEventEx*>(this)->nModifiers);
+}
+
+/*!
+ \internal
+ Creates an extended key event object, which in addition to the normal key event data, also
+ contains the native scan code, virtual key and modifiers. This extra data is used by the
+ shortcut system, to determine which shortcuts to trigger.
+*/
+QKeyEventEx::QKeyEventEx(Type type, int key, Qt::KeyboardModifiers modifiers,
+ const QString &text, bool autorep, ushort count,
+ quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers)
+ : QKeyEvent(type, key, modifiers, text, autorep, count),
+ nScanCode(nativeScanCode), nVirtualKey(nativeVirtualKey), nModifiers(nativeModifiers)
+{
+ d = reinterpret_cast<QEventPrivate*>(this);
+}
+
+/*!
+ \internal
+ Creates a copy of an other extended key event.
+*/
+QKeyEventEx::QKeyEventEx(const QKeyEventEx &other)
+ : QKeyEvent(QEvent::Type(other.t), other.k, other.modState, other.txt, other.autor, other.c),
+ nScanCode(other.nScanCode), nVirtualKey(other.nVirtualKey), nModifiers(other.nModifiers)
+{
+ d = reinterpret_cast<QEventPrivate*>(this);
+}
+
+/*!
+ \internal
+*/
+QKeyEventEx::~QKeyEventEx()
+{
+}
+
+/*!
+ \fn int QKeyEvent::key() const
+
+ Returns the code of the key that was pressed or released.
+
+ See \l Qt::Key for the list of keyboard codes. These codes are
+ independent of the underlying window system. Note that this
+ function does not distinguish between capital and non-capital
+ letters, use the text() function (returning the Unicode text the
+ key generated) for this purpose.
+
+ A value of either 0 or Qt::Key_unknown means that the event is not
+ the result of a known key; for example, it may be the result of
+ a compose sequence, a keyboard macro, or due to key event
+ compression.
+
+ \sa Qt::WA_KeyCompression
+*/
+
+/*!
+ \fn QString QKeyEvent::text() const
+
+ Returns the Unicode text that this key generated. The text
+ returned can be an empty string in cases
+ where modifier keys, such as Shift, Control, Alt, and Meta,
+ are being pressed or released. In such cases key() will contain
+ a valid value.
+
+ \sa Qt::WA_KeyCompression
+*/
+
+/*!
+ Returns the keyboard modifier flags that existed immediately
+ after the event occurred.
+
+ \warning This function cannot always be trusted. The user can
+ confuse it by pressing both \key{Shift} keys simultaneously and
+ releasing one of them, for example.
+
+ \sa QApplication::keyboardModifiers()
+*/
+//###### We must check with XGetModifierMapping
+Qt::KeyboardModifiers QKeyEvent::modifiers() const
+{
+ if (key() == Qt::Key_Shift)
+ return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::ShiftModifier);
+ if (key() == Qt::Key_Control)
+ return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::ControlModifier);
+ if (key() == Qt::Key_Alt)
+ return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::AltModifier);
+ if (key() == Qt::Key_Meta)
+ return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::MetaModifier);
+ return QInputEvent::modifiers();
+}
+
+#ifndef QT_NO_SHORTCUT
+/*!
+ \fn bool QKeyEvent::matches(QKeySequence::StandardKey key) const
+ \since 4.2
+
+ Returns true if the key event matches the given standard \a key;
+ otherwise returns false.
+*/
+bool QKeyEvent::matches(QKeySequence::StandardKey matchKey) const
+{
+ uint searchkey = (modifiers() | key()) & ~(Qt::KeypadModifier); //The keypad modifier should not make a difference
+ uint platform = QGuiApplicationPrivate::currentKeyPlatform();
+
+#ifdef Q_WS_MAC
+ if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
+ uint oldSearchKey = searchkey;
+ searchkey &= ~(Qt::ControlModifier | Qt::MetaModifier);
+ if (oldSearchKey & Qt::ControlModifier)
+ searchkey |= Qt::MetaModifier;
+ if (oldSearchKey & Qt::MetaModifier)
+ searchkey |= Qt::ControlModifier;
+ }
+#endif
+
+ uint N = QKeySequencePrivate::numberOfKeyBindings;
+ int first = 0;
+ int last = N - 1;
+
+ while (first <= last) {
+ int mid = (first + last) / 2;
+ QKeyBinding midVal = QKeySequencePrivate::keyBindings[mid];
+
+ if (searchkey > midVal.shortcut){
+ first = mid + 1; // Search in top half
+ }
+ else if (searchkey < midVal.shortcut){
+ last = mid - 1; // Search in bottom half
+ }
+ else {
+ //found correct shortcut value, now we must check for platform match
+ if ((midVal.platform & platform) && (midVal.standardKey == matchKey)) {
+ return true;
+ } else { //We may have several equal values for different platforms, so we must search in both directions
+
+ //search forward
+ for ( unsigned int i = mid + 1 ; i < N - 1 ; ++i) {
+ QKeyBinding current = QKeySequencePrivate::keyBindings[i];
+ if (current.shortcut != searchkey)
+ break;
+ else if (current.platform & platform && current.standardKey == matchKey)
+ return true;
+ }
+
+ //search back
+ for ( int i = mid - 1 ; i >= 0 ; --i) {
+ QKeyBinding current = QKeySequencePrivate::keyBindings[i];
+ if (current.shortcut != searchkey)
+ break;
+ else if (current.platform & platform && current.standardKey == matchKey)
+ return true;
+ }
+ return false; //we could not find it among the matching keySequences
+ }
+ }
+ }
+ return false; //we could not find matching keySequences at all
+}
+#endif // QT_NO_SHORTCUT
+
+
+/*!
+ \fn bool QKeyEvent::isAutoRepeat() const
+
+ Returns true if this event comes from an auto-repeating key;
+ returns false if it comes from an initial key press.
+
+ Note that if the event is a multiple-key compressed event that is
+ partly due to auto-repeat, this function could return either true
+ or false indeterminately.
+*/
+
+/*!
+ \fn int QKeyEvent::count() const
+
+ Returns the number of keys involved in this event. If text()
+ is not empty, this is simply the length of the string.
+
+ \sa Qt::WA_KeyCompression
+*/
+
+/*!
+ \class QFocusEvent
+ \brief The QFocusEvent class contains event parameters for widget focus
+ events.
+
+ \ingroup events
+
+ Focus events are sent to widgets when the keyboard input focus
+ changes. Focus events occur due to mouse actions, key presses
+ (such as \gui{Tab} or \gui{Backtab}), the window system, popup
+ menus, keyboard shortcuts, or other application-specific reasons.
+ The reason for a particular focus event is returned by reason()
+ in the appropriate event handler.
+
+ The event handlers QWidget::focusInEvent(),
+ QWidget::focusOutEvent(), QGraphicsItem::focusInEvent and
+ QGraphicsItem::focusOutEvent() receive focus events.
+
+ \sa QWidget::setFocus(), QWidget::setFocusPolicy(), {Keyboard Focus}
+*/
+
+/*!
+ Constructs a focus event object.
+
+ The \a type parameter must be either QEvent::FocusIn or
+ QEvent::FocusOut. The \a reason describes the cause of the change
+ in focus.
+*/
+QFocusEvent::QFocusEvent(Type type, Qt::FocusReason reason)
+ : QEvent(type), m_reason(reason)
+{}
+
+/*!
+ \internal
+*/
+QFocusEvent::~QFocusEvent()
+{
+}
+
+// ### Qt 5: remove
+/*!
+ \internal
+ */
+Qt::FocusReason QFocusEvent::reason()
+{
+ return m_reason;
+}
+
+/*!
+ Returns the reason for this focus event.
+ */
+Qt::FocusReason QFocusEvent::reason() const
+{
+ return m_reason;
+}
+
+/*!
+ \fn bool QFocusEvent::gotFocus() const
+
+ Returns true if type() is QEvent::FocusIn; otherwise returns
+ false.
+*/
+
+/*!
+ \fn bool QFocusEvent::lostFocus() const
+
+ Returns true if type() is QEvent::FocusOut; otherwise returns
+ false.
+*/
+
+
+/*!
+ \class QPaintEvent
+ \brief The QPaintEvent class contains event parameters for paint events.
+
+ \ingroup events
+
+ Paint events are sent to widgets that need to update themselves,
+ for instance when part of a widget is exposed because a covering
+ widget was moved.
+
+ The event contains a region() that needs to be updated, and a
+ rect() that is the bounding rectangle of that region. Both are
+ provided because many widgets can't make much use of region(),
+ and rect() can be much faster than region().boundingRect().
+
+ \section1 Automatic Clipping
+
+ Painting is clipped to region() during the processing of a paint
+ event. This clipping is performed by Qt's paint system and is
+ independent of any clipping that may be applied to a QPainter used to
+ draw on the paint device.
+
+ As a result, the value returned by QPainter::clipRegion() on
+ a newly-constructed QPainter will not reflect the clip region that is
+ used by the paint system.
+
+ \sa QPainter, QWidget::update(), QWidget::repaint(),
+ QWidget::paintEvent()
+*/
+
+/*!
+ \fn bool QPaintEvent::erased() const
+ \compat
+
+ Returns true if the paint event region (or rectangle) has been
+ erased with the widget's background; otherwise returns false.
+
+ Qt 4 \e always erases regions that require painting. The exception
+ to this rule is if the widget sets the Qt::WA_OpaquePaintEvent or
+ Qt::WA_NoSystemBackground attributes. If either one of those
+ attributes is set \e and the window system does not make use of
+ subwidget alpha composition (currently X11 and Windows, but this
+ may change), then the region is not erased.
+*/
+
+/*!
+ \fn void QPaintEvent::setErased(bool b) { m_erased = b; }
+ \internal
+*/
+
+/*!
+ Constructs a paint event object with the region that needs to
+ be updated. The region is specified by \a paintRegion.
+*/
+QPaintEvent::QPaintEvent(const QRegion& paintRegion)
+ : QEvent(Paint), m_rect(paintRegion.boundingRect()), m_region(paintRegion), m_erased(false)
+{}
+
+/*!
+ Constructs a paint event object with the rectangle that needs
+ to be updated. The region is specified by \a paintRect.
+*/
+QPaintEvent::QPaintEvent(const QRect &paintRect)
+ : QEvent(Paint), m_rect(paintRect),m_region(paintRect), m_erased(false)
+{}
+
+
+/*!
+ \internal
+*/
+QPaintEvent::~QPaintEvent()
+{
+}
+
+/*!
+ \fn const QRect &QPaintEvent::rect() const
+
+ Returns the rectangle that needs to be updated.
+
+ \sa region() QPainter::setClipRect()
+*/
+
+/*!
+ \fn const QRegion &QPaintEvent::region() const
+
+ Returns the region that needs to be updated.
+
+ \sa rect() QPainter::setClipRegion()
+*/
+
+
+QUpdateLaterEvent::QUpdateLaterEvent(const QRegion& paintRegion)
+ : QEvent(UpdateLater), m_region(paintRegion)
+{
+}
+
+QUpdateLaterEvent::~QUpdateLaterEvent()
+{
+}
+
+/*!
+ \class QMoveEvent
+ \brief The QMoveEvent class contains event parameters for move events.
+
+ \ingroup events
+
+ Move events are sent to widgets that have been moved to a new
+ position relative to their parent.
+
+ The event handler QWidget::moveEvent() receives move events.
+
+ \sa QWidget::move(), QWidget::setGeometry()
+*/
+
+/*!
+ Constructs a move event with the new and old widget positions,
+ \a pos and \a oldPos respectively.
+*/
+QMoveEvent::QMoveEvent(const QPoint &pos, const QPoint &oldPos)
+ : QEvent(Move), p(pos), oldp(oldPos)
+{}
+
+/*!
+ \internal
+*/
+QMoveEvent::~QMoveEvent()
+{
+}
+
+/*!
+ \fn const QPoint &QMoveEvent::pos() const
+
+ Returns the new position of the widget. This excludes the window
+ frame for top level widgets.
+*/
+
+/*!
+ \fn const QPoint &QMoveEvent::oldPos() const
+
+ Returns the old position of the widget.
+*/
+
+
+/*!
+ \class QResizeEvent
+ \brief The QResizeEvent class contains event parameters for resize events.
+
+ \ingroup events
+
+ Resize events are sent to widgets that have been resized.
+
+ The event handler QWidget::resizeEvent() receives resize events.
+
+ \sa QWidget::resize() QWidget::setGeometry()
+*/
+
+/*!
+ Constructs a resize event with the new and old widget sizes, \a
+ size and \a oldSize respectively.
+*/
+QResizeEvent::QResizeEvent(const QSize &size, const QSize &oldSize)
+ : QEvent(Resize), s(size), olds(oldSize)
+{}
+
+/*!
+ \internal
+*/
+QResizeEvent::~QResizeEvent()
+{
+}
+
+/*!
+ \fn const QSize &QResizeEvent::size() const
+
+ Returns the new size of the widget. This is the same as
+ QWidget::size().
+*/
+
+/*!
+ \fn const QSize &QResizeEvent::oldSize() const
+
+ Returns the old size of the widget.
+*/
+
+
+/*!
+ \class QCloseEvent
+ \brief The QCloseEvent class contains parameters that describe a close event.
+
+ \ingroup events
+
+ Close events are sent to widgets that the user wants to close,
+ usually by choosing "Close" from the window menu, or by clicking
+ the \gui{X} title bar button. They are also sent when you call
+ QWidget::close() to close a widget programmatically.
+
+ Close events contain a flag that indicates whether the receiver
+ wants the widget to be closed or not. When a widget accepts the
+ close event, it is hidden (and destroyed if it was created with
+ the Qt::WA_DeleteOnClose flag). If it refuses to accept the close
+ event nothing happens. (Under X11 it is possible that the window
+ manager will forcibly close the window; but at the time of writing
+ we are not aware of any window manager that does this.)
+
+ The event handler QWidget::closeEvent() receives close events. The
+ default implementation of this event handler accepts the close
+ event. If you do not want your widget to be hidden, or want some
+ special handing, you should reimplement the event handler and
+ ignore() the event.
+
+ The \l{mainwindows/application#close event handler}{closeEvent() in the
+ Application example} shows a close event handler that
+ asks whether to save a document before closing.
+
+ If you want the widget to be deleted when it is closed, create it
+ with the Qt::WA_DeleteOnClose flag. This is very useful for
+ independent top-level windows in a multi-window application.
+
+ \l{QObject}s emits the \l{QObject::destroyed()}{destroyed()}
+ signal when they are deleted.
+
+ If the last top-level window is closed, the
+ QApplication::lastWindowClosed() signal is emitted.
+
+ The isAccepted() function returns true if the event's receiver has
+ agreed to close the widget; call accept() to agree to close the
+ widget and call ignore() if the receiver of this event does not
+ want the widget to be closed.
+
+ \sa QWidget::close(), QWidget::hide(), QObject::destroyed(),
+ QCoreApplication::exec(), QCoreApplication::quit(),
+ QApplication::lastWindowClosed()
+*/
+
+/*!
+ Constructs a close event object.
+
+ \sa accept()
+*/
+QCloseEvent::QCloseEvent()
+ : QEvent(Close)
+{}
+
+/*! \internal
+*/
+QCloseEvent::~QCloseEvent()
+{
+}
+
+/*!
+ \class QIconDragEvent
+ \brief The QIconDragEvent class indicates that a main icon drag has begun.
+
+ \ingroup events
+
+ Icon drag events are sent to widgets when the main icon of a window
+ has been dragged away. On Mac OS X, this happens when the proxy
+ icon of a window is dragged off the title bar.
+
+ It is normal to begin using drag and drop in response to this
+ event.
+
+ \sa {Drag and Drop}, QMimeData, QDrag
+*/
+
+/*!
+ Constructs an icon drag event object with the accept flag set to
+ false.
+
+ \sa accept()
+*/
+QIconDragEvent::QIconDragEvent()
+ : QEvent(IconDrag)
+{ ignore(); }
+
+/*! \internal */
+QIconDragEvent::~QIconDragEvent()
+{
+}
+
+/*!
+ \class QContextMenuEvent
+ \brief The QContextMenuEvent class contains parameters that describe a context menu event.
+
+ \ingroup events
+
+ Context menu events are sent to widgets when a user performs
+ an action associated with opening a context menu.
+ The actions required to open context menus vary between platforms;
+ for example, on Windows, pressing the menu button or clicking the
+ right mouse button will cause this event to be sent.
+
+ When this event occurs it is customary to show a QMenu with a
+ context menu, if this is relevant to the context.
+
+ Context menu events contain a special accept flag that indicates
+ whether the receiver accepted the event. If the event handler does
+ not accept the event then, if possible, whatever triggered the event will be
+ handled as a regular input event.
+*/
+
+#ifndef QT_NO_CONTEXTMENU
+/*!
+ Constructs a context menu event object with the accept parameter
+ flag set to false.
+
+ The \a reason parameter must be QContextMenuEvent::Mouse or
+ QContextMenuEvent::Keyboard.
+
+ The \a pos parameter specifies the mouse position relative to the
+ receiving widget. \a globalPos is the mouse position in absolute
+ coordinates.
+*/
+QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos)
+ : QInputEvent(ContextMenu), p(pos), gp(globalPos), reas(reason)
+{}
+
+/*!
+ Constructs a context menu event object with the accept parameter
+ flag set to false.
+
+ The \a reason parameter must be QContextMenuEvent::Mouse or
+ QContextMenuEvent::Keyboard.
+
+ The \a pos parameter specifies the mouse position relative to the
+ receiving widget. \a globalPos is the mouse position in absolute
+ coordinates. The \a modifiers holds the keyboard modifiers.
+*/
+QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos,
+ Qt::KeyboardModifiers modifiers)
+ : QInputEvent(ContextMenu, modifiers), p(pos), gp(globalPos), reas(reason)
+{}
+
+
+/*! \internal */
+QContextMenuEvent::~QContextMenuEvent()
+{
+}
+/*!
+ Constructs a context menu event object with the accept parameter
+ flag set to false.
+
+ The \a reason parameter must be QContextMenuEvent::Mouse or
+ QContextMenuEvent::Keyboard.
+
+ The \a pos parameter specifies the mouse position relative to the
+ receiving widget.
+
+ The globalPos() is initialized to QCursor::pos(), which may not be
+ appropriate. Use the other constructor to specify the global
+ position explicitly.
+*/
+QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos)
+ : QInputEvent(ContextMenu), p(pos), reas(reason)
+{
+ gp = QCursor::pos();
+}
+
+/*!
+ \fn const QPoint &QContextMenuEvent::pos() const
+
+ Returns the position of the mouse pointer relative to the widget
+ that received the event.
+
+ \sa x(), y(), globalPos()
+*/
+
+/*!
+ \fn int QContextMenuEvent::x() const
+
+ Returns the x position of the mouse pointer, relative to the
+ widget that received the event.
+
+ \sa y(), pos()
+*/
+
+/*!
+ \fn int QContextMenuEvent::y() const
+
+ Returns the y position of the mouse pointer, relative to the
+ widget that received the event.
+
+ \sa x(), pos()
+*/
+
+/*!
+ \fn const QPoint &QContextMenuEvent::globalPos() const
+
+ Returns the global position of the mouse pointer at the time of
+ the event.
+
+ \sa x(), y(), pos()
+*/
+
+/*!
+ \fn int QContextMenuEvent::globalX() const
+
+ Returns the global x position of the mouse pointer at the time of
+ the event.
+
+ \sa globalY(), globalPos()
+*/
+
+/*!
+ \fn int QContextMenuEvent::globalY() const
+
+ Returns the global y position of the mouse pointer at the time of
+ the event.
+
+ \sa globalX(), globalPos()
+*/
+#endif // QT_NO_CONTEXTMENU
+
+/*!
+ \fn Qt::ButtonState QContextMenuEvent::state() const
+
+ Returns the button state (a combination of mouse buttons
+ and keyboard modifiers) immediately before the event was
+ generated.
+
+ The returned value is a selection of the following values,
+ combined with the OR operator:
+ Qt::LeftButton, Qt::RightButton, Qt::MidButton,
+ Qt::ShiftButton, Qt::ControlButton, and Qt::AltButton.
+*/
+
+/*!
+ \enum QContextMenuEvent::Reason
+
+ This enum describes the reason why the event was sent.
+
+ \value Mouse The mouse caused the event to be sent. Normally this
+ means the right mouse button was clicked, but this is platform
+ dependent.
+
+ \value Keyboard The keyboard caused this event to be sent. On
+ Windows, this means the menu button was pressed.
+
+ \value Other The event was sent by some other means (i.e. not by
+ the mouse or keyboard).
+*/
+
+
+/*!
+ \fn QContextMenuEvent::Reason QContextMenuEvent::reason() const
+
+ Returns the reason for this context event.
+*/
+
+
+/*!
+ \class QInputMethodEvent
+ \brief The QInputMethodEvent class provides parameters for input method events.
+
+ \ingroup events
+
+ Input method events are sent to widgets when an input method is
+ used to enter text into a widget. Input methods are widely used
+ to enter text for languages with non-Latin alphabets.
+
+ Note that when creating custom text editing widgets, the
+ Qt::WA_InputMethodEnabled window attribute must be set explicitly
+ (using the QWidget::setAttribute() function) in order to receive
+ input method events.
+
+ The events are of interest to authors of keyboard entry widgets
+ who want to be able to correctly handle languages with complex
+ character input. Text input in such languages is usually a three
+ step process:
+
+ \list 1
+ \o \bold{Starting to Compose}
+
+ When the user presses the first key on a keyboard, an input
+ context is created. This input context will contain a string
+ of the typed characters.
+
+ \o \bold{Composing}
+
+ With every new key pressed, the input method will try to create a
+ matching string for the text typed so far called preedit
+ string. While the input context is active, the user can only move
+ the cursor inside the string belonging to this input context.
+
+ \o \bold{Completing}
+
+ At some point, the user will activate a user interface component
+ (perhaps using a particular key) where they can choose from a
+ number of strings matching the text they have typed so far. The
+ user can either confirm their choice cancel the input; in either
+ case the input context will be closed.
+ \endlist
+
+ QInputMethodEvent models these three stages, and transfers the
+ information needed to correctly render the intermediate result. A
+ QInputMethodEvent has two main parameters: preeditString() and
+ commitString(). The preeditString() parameter gives the currently
+ active preedit string. The commitString() parameter gives a text
+ that should get added to (or replace parts of) the text of the
+ editor widget. It usually is a result of the input operations and
+ has to be inserted to the widgets text directly before the preedit
+ string.
+
+ If the commitString() should replace parts of the of the text in
+ the editor, replacementLength() will contain the number of
+ characters to be replaced. replacementStart() contains the position
+ at which characters are to be replaced relative from the start of
+ the preedit string.
+
+ A number of attributes control the visual appearance of the
+ preedit string (the visual appearance of text outside the preedit
+ string is controlled by the widget only). The AttributeType enum
+ describes the different attributes that can be set.
+
+ A class implementing QWidget::inputMethodEvent() or
+ QGraphicsItem::inputMethodEvent() should at least understand and
+ honor the \l TextFormat and \l Cursor attributes.
+
+ Since input methods need to be able to query certain properties
+ from the widget or graphics item, subclasses must also implement
+ QWidget::inputMethodQuery() and QGraphicsItem::inputMethodQuery(),
+ respectively.
+
+ When receiving an input method event, the text widget has to performs the
+ following steps:
+
+ \list 1
+ \o If the widget has selected text, the selected text should get
+ removed.
+
+ \o Remove the text starting at replacementStart() with length
+ replacementLength() and replace it by the commitString(). If
+ replacementLength() is 0, replacementStart() gives the insertion
+ position for the commitString().
+
+ When doing replacement the area of the preedit
+ string is ignored, thus a replacement starting at -1 with a length
+ of 2 will remove the last character before the preedit string and
+ the first character afterwards, and insert the commit string
+ directly before the preedit string.
+
+ If the widget implements undo/redo, this operation gets added to
+ the undo stack.
+
+ \o If there is no current preedit string, insert the
+ preeditString() at the current cursor position; otherwise replace
+ the previous preeditString with the one received from this event.
+
+ If the widget implements undo/redo, the preeditString() should not
+ influence the undo/redo stack in any way.
+
+ The widget should examine the list of attributes to apply to the
+ preedit string. It has to understand at least the TextFormat and
+ Cursor attributes and render them as specified.
+ \endlist
+
+ \sa QInputContext
+*/
+
+/*!
+ \enum QInputMethodEvent::AttributeType
+
+ \value TextFormat
+ A QTextCharFormat for the part of the preedit string specified by
+ start and length. value contains a QVariant of type QTextFormat
+ specifying rendering of this part of the preedit string. There
+ should be at most one format for every part of the preedit
+ string. If several are specified for any character in the string the
+ behaviour is undefined. A conforming implementation has to at least
+ honor the backgroundColor, textColor and fontUnderline properties
+ of the format.
+
+ \value Cursor If set, a cursor should be shown inside the preedit
+ string at position start. The length variable determines whether
+ the cursor is visible or not. If the length is 0 the cursor is
+ invisible. If value is a QVariant of type QColor this color will
+ be used for rendering the cursor, otherwise the color of the
+ surrounding text will be used. There should be at most one Cursor
+ attribute per event. If several are specified the behaviour is
+ undefined.
+
+ \value Language
+ The variant contains a QLocale object specifying the language of a
+ certain part of the preedit string. There should be at most one
+ language set for every part of the preedit string. If several are
+ specified for any character in the string the behavior is undefined.
+
+ \value Ruby
+ The ruby text for a part of the preedit string. There should be at
+ most one ruby text set for every part of the preedit string. If
+ several are specified for any character in the string the behaviour
+ is undefined.
+
+ \value Selection
+ If set, the edit cursor should be moved to the specified position
+ in the editor text contents. In contrast with \c Cursor, this
+ attribute does not work on the preedit text, but on the surrounding
+ text. The cursor will be moved after the commit string has been
+ committed, and the preedit string will be located at the new edit
+ position.
+ The start position specifies the new position and the length
+ variable can be used to set a selection starting from that point.
+ The value is unused.
+
+ \sa Attribute
+*/
+
+/*!
+ \class QInputMethodEvent::Attribute
+ \brief The QInputMethodEvent::Attribute class stores an input method attribute.
+*/
+
+/*!
+ \fn QInputMethodEvent::Attribute::Attribute(AttributeType type, int start, int length, QVariant value)
+
+ Constructs an input method attribute. \a type specifies the type
+ of attribute, \a start and \a length the position of the
+ attribute, and \a value the value of the attribute.
+*/
+
+/*!
+ Constructs an event of type QEvent::InputMethod. The
+ attributes(), preeditString(), commitString(), replacementStart(),
+ and replacementLength() are initialized to default values.
+
+ \sa setCommitString()
+*/
+QInputMethodEvent::QInputMethodEvent()
+ : QEvent(QEvent::InputMethod), replace_from(0), replace_length(0)
+{
+}
+
+/*!
+ Construcs an event of type QEvent::InputMethod. The
+ preedit text is set to \a preeditText, the attributes to
+ \a attributes.
+
+ The commitString(), replacementStart(), and replacementLength()
+ values can be set using setCommitString().
+
+ \sa preeditString(), attributes()
+*/
+QInputMethodEvent::QInputMethodEvent(const QString &preeditText, const QList<Attribute> &attributes)
+ : QEvent(QEvent::InputMethod), preedit(preeditText), attrs(attributes),
+ replace_from(0), replace_length(0)
+{
+}
+
+/*!
+ Constructs a copy of \a other.
+*/
+QInputMethodEvent::QInputMethodEvent(const QInputMethodEvent &other)
+ : QEvent(QEvent::InputMethod), preedit(other.preedit), attrs(other.attrs),
+ commit(other.commit), replace_from(other.replace_from), replace_length(other.replace_length)
+{
+}
+
+/*!
+ Sets the commit string to \a commitString.
+
+ The commit string is the text that should get added to (or
+ replace parts of) the text of the editor widget. It usually is a
+ result of the input operations and has to be inserted to the
+ widgets text directly before the preedit string.
+
+ If the commit string should replace parts of the of the text in
+ the editor, \a replaceLength specifies the number of
+ characters to be replaced. \a replaceFrom specifies the position
+ at which characters are to be replaced relative from the start of
+ the preedit string.
+
+ \sa commitString(), replacementStart(), replacementLength()
+*/
+void QInputMethodEvent::setCommitString(const QString &commitString, int replaceFrom, int replaceLength)
+{
+ commit = commitString;
+ replace_from = replaceFrom;
+ replace_length = replaceLength;
+}
+
+/*!
+ \fn const QList<Attribute> &QInputMethodEvent::attributes() const
+
+ Returns the list of attributes passed to the QInputMethodEvent
+ constructor. The attributes control the visual appearance of the
+ preedit string (the visual appearance of text outside the preedit
+ string is controlled by the widget only).
+
+ \sa preeditString(), Attribute
+*/
+
+/*!
+ \fn const QString &QInputMethodEvent::preeditString() const
+
+ Returns the preedit text, i.e. the text before the user started
+ editing it.
+
+ \sa commitString(), attributes()
+*/
+
+/*!
+ \fn const QString &QInputMethodEvent::commitString() const
+
+ Returns the text that should get added to (or replace parts of)
+ the text of the editor widget. It usually is a result of the
+ input operations and has to be inserted to the widgets text
+ directly before the preedit string.
+
+ \sa setCommitString(), preeditString(), replacementStart(), replacementLength()
+*/
+
+/*!
+ \fn int QInputMethodEvent::replacementStart() const
+
+ Returns the position at which characters are to be replaced relative
+ from the start of the preedit string.
+
+ \sa replacementLength(), setCommitString()
+*/
+
+/*!
+ \fn int QInputMethodEvent::replacementLength() const
+
+ Returns the number of characters to be replaced in the preedit
+ string.
+
+ \sa replacementStart(), setCommitString()
+*/
+
+#ifndef QT_NO_TABLETEVENT
+
+/*!
+ \class QTabletEvent
+ \brief The QTabletEvent class contains parameters that describe a Tablet event.
+
+ \ingroup events
+
+ Tablet Events are generated from a Wacom tablet. Most of the time you will
+ want to deal with events from the tablet as if they were events from a
+ mouse; for example, you would retrieve the cursor position with x(), y(),
+ pos(), globalX(), globalY(), and globalPos(). In some situations you may
+ wish to retrieve the extra information provided by the tablet device
+ driver; for example, you might want to do subpixeling with higher
+ resolution coordinates or you may want to adjust color brightness based on
+ pressure. QTabletEvent allows you to read the pressure(), the xTilt(), and
+ yTilt(), as well as the type of device being used with device() (see
+ \l{TabletDevice}). It can also give you the minimum and maximum values for
+ each device's pressure and high resolution coordinates.
+
+ A tablet event contains a special accept flag that indicates whether the
+ receiver wants the event. You should call QTabletEvent::accept() if you
+ handle the tablet event; otherwise it will be sent to the parent widget.
+ The exception are TabletEnterProximity and TabletLeaveProximity events,
+ these are only sent to QApplication and don't check whether or not they are
+ accepted.
+
+ The QWidget::setEnabled() function can be used to enable or
+ disable mouse and keyboard events for a widget.
+
+ The event handler QWidget::tabletEvent() receives all three types of
+ tablet events. Qt will first send a tabletEvent then, if it is not
+ accepted, it will send a mouse event. This allows applications that
+ don't utilize tablets to use a tablet like a mouse, while also
+ enabling those who want to use both tablets and mouses differently.
+
+ \section1 Notes for X11 Users
+
+ Qt uses the following hard-coded names to identify tablet
+ devices from the xorg.conf file on X11 (apart from IRIX):
+ 'stylus', 'pen', and 'eraser'. If the devices have other names,
+ they will not be picked up Qt.
+*/
+
+/*!
+ \enum QTabletEvent::TabletDevice
+
+ This enum defines what type of device is generating the event.
+
+ \value NoDevice No device, or an unknown device.
+ \value Puck A Puck (a device that is similar to a flat mouse with
+ a transparent circle with cross-hairs).
+ \value Stylus A Stylus.
+ \value Airbrush An airbrush
+ \value FourDMouse A 4D Mouse.
+ \value RotationStylus A special stylus that also knows about rotation
+ (a 6D stylus). \since 4.1
+ \omitvalue XFreeEraser
+*/
+
+/*!
+ \enum QTabletEvent::PointerType
+
+ This enum defines what type of point is generating the event.
+
+ \value UnknownPointer An unknown device.
+ \value Pen Tip end of a stylus-like device (the narrow end of the pen).
+ \value Cursor Any puck-like device.
+ \value Eraser Eraser end of a stylus-like device (the broad end of the pen).
+
+ \sa pointerType()
+*/
+
+/*!
+ Construct a tablet event of the given \a type.
+
+ The \a pos parameter indicates where the event occurred in the
+ widget; \a globalPos is the corresponding position in absolute
+ coordinates. The \a hiResGlobalPos contains a high resolution
+ measurement of the position.
+
+ \a pressure contains the pressure exerted on the \a device.
+
+ \a pointerType describes the type of pen that is being used.
+
+ \a xTilt and \a yTilt contain the device's degree of tilt from the
+ x and y axes respectively.
+
+ \a keyState specifies which keyboard modifiers are pressed (e.g.,
+ \key{Ctrl}).
+
+ The \a uniqueID parameter contains the unique ID for the current device.
+
+ The \a z parameter contains the coordinate of the device on the tablet, this
+ is usually given by a wheel on 4D mouse. If the device does not support a
+ Z-axis, pass zero here.
+
+ The \a tangentialPressure parameter contins the tangential pressure of an air
+ brush. If the device does not support tangential pressure, pass 0 here.
+
+ \a rotation contains the device's rotation in degrees. 4D mice support
+ rotation. If the device does not support rotation, pass 0 here.
+
+ \sa pos() globalPos() device() pressure() xTilt() yTilt() uniqueId(), rotation(), tangentialPressure(), z()
+*/
+
+QTabletEvent::QTabletEvent(Type type, const QPoint &pos, const QPoint &globalPos,
+ const QPointF &hiResGlobalPos, int device, int pointerType,
+ qreal pressure, int xTilt, int yTilt, qreal tangentialPressure,
+ qreal rotation, int z, Qt::KeyboardModifiers keyState, qint64 uniqueID)
+ : QInputEvent(type, keyState),
+ mPos(pos),
+ mGPos(globalPos),
+ mHiResGlobalPos(hiResGlobalPos),
+ mDev(device),
+ mPointerType(pointerType),
+ mXT(xTilt),
+ mYT(yTilt),
+ mZ(z),
+ mPress(pressure),
+ mTangential(tangentialPressure),
+ mRot(rotation),
+ mUnique(uniqueID),
+ mExtra(0)
+{
+}
+
+/*!
+ \internal
+*/
+QTabletEvent::~QTabletEvent()
+{
+}
+
+/*!
+ \fn TabletDevices QTabletEvent::device() const
+
+ Returns the type of device that generated the event.
+
+ \sa TabletDevice
+*/
+
+/*!
+ \fn PointerType QTabletEvent::pointerType() const
+
+ Returns the type of point that generated the event.
+*/
+
+/*!
+ \fn qreal QTabletEvent::tangentialPressure() const
+
+ Returns the tangential pressure for the device. This is typically given by a finger
+ wheel on an airbrush tool. The range is from -1.0 to 1.0. 0.0 indicates a
+ neutral position. Current airbrushes can only move in the positive
+ direction from the neutrual position. If the device does not support
+ tangential pressure, this value is always 0.0.
+
+ \sa pressure()
+*/
+
+/*!
+ \fn qreal QTabletEvent::rotation() const
+
+ Returns the rotation of the current device in degress. This is usually
+ given by a 4D Mouse. If the device doesn't support rotation this value is
+ always 0.0.
+
+*/
+
+/*!
+ \fn qreal QTabletEvent::pressure() const
+
+ Returns the pressure for the device. 0.0 indicates that the stylus is not
+ on the tablet, 1.0 indicates the maximum amount of pressure for the stylus.
+
+ \sa tangentialPressure()
+*/
+
+/*!
+ \fn int QTabletEvent::xTilt() const
+
+ Returns the angle between the device (a pen, for example) and the
+ perpendicular in the direction of the x axis.
+ Positive values are towards the tablet's physical right. The angle
+ is in the range -60 to +60 degrees.
+
+ \img qtabletevent-tilt.png
+
+ \sa yTilt()
+*/
+
+/*!
+ \fn int QTabletEvent::yTilt() const
+
+ Returns the angle between the device (a pen, for example) and the
+ perpendicular in the direction of the y axis.
+ Positive values are towards the bottom of the tablet. The angle is
+ within the range -60 to +60 degrees.
+
+ \sa xTilt()
+*/
+
+/*!
+ \fn const QPoint &QTabletEvent::pos() const
+
+ Returns the position of the device, relative to the widget that
+ received the event.
+
+ If you move widgets around in response to mouse events, use
+ globalPos() instead of this function.
+
+ \sa x() y() globalPos()
+*/
+
+/*!
+ \fn int QTabletEvent::x() const
+
+ Returns the x position of the device, relative to the widget that
+ received the event.
+
+ \sa y() pos()
+*/
+
+/*!
+ \fn int QTabletEvent::y() const
+
+ Returns the y position of the device, relative to the widget that
+ received the event.
+
+ \sa x() pos()
+*/
+
+/*!
+ \fn int QTabletEvent::z() const
+
+ Returns the z position of the device. Typically this is represented by a
+ wheel on a 4D Mouse. If the device does not support a Z-axis, this value is
+ always zero. This is \bold not the same as pressure.
+
+ \sa pressure()
+*/
+
+/*!
+ \fn const QPoint &QTabletEvent::globalPos() const
+
+ Returns the global position of the device \e{at the time of the
+ event}. This is important on asynchronous windows systems like X11;
+ whenever you move your widgets around in response to mouse events,
+ globalPos() can differ significantly from the current position
+ QCursor::pos().
+
+ \sa globalX() globalY() hiResGlobalPos()
+*/
+
+/*!
+ \fn int QTabletEvent::globalX() const
+
+ Returns the global x position of the mouse pointer at the time of
+ the event.
+
+ \sa globalY() globalPos() hiResGlobalX()
+*/
+
+/*!
+ \fn int QTabletEvent::globalY() const
+
+ Returns the global y position of the tablet device at the time of
+ the event.
+
+ \sa globalX() globalPos() hiResGlobalY()
+*/
+
+/*!
+ \fn qint64 QTabletEvent::uniqueId() const
+
+ Returns a unique ID for the current device, making it possible
+ to differentiate between multiple devices being used at the same
+ time on the tablet.
+
+ Support of this feature is dependent on the tablet.
+
+ Values for the same device may vary from OS to OS.
+
+ Later versions of the Wacom driver for Linux will now report
+ the ID information. If you have a tablet that supports unique ID
+ and are not getting the information on Linux, consider upgrading
+ your driver.
+
+ As of Qt 4.2, the unique ID is the same regardless of the orientation
+ of the pen. Earlier versions would report a different value when using
+ the eraser-end versus the pen-end of the stylus on some OS's.
+
+ \sa pointerType()
+*/
+
+/*!
+ \fn const QPointF &QTabletEvent::hiResGlobalPos() const
+
+ The high precision coordinates delivered from the tablet expressed.
+ Sub pixeling information is in the fractional part of the QPointF.
+
+ \sa globalPos() hiResGlobalX() hiResGlobalY()
+*/
+
+/*!
+ \fn qreal &QTabletEvent::hiResGlobalX() const
+
+ The high precision x position of the tablet device.
+*/
+
+/*!
+ \fn qreal &QTabletEvent::hiResGlobalY() const
+
+ The high precision y position of the tablet device.
+*/
+
+#endif // QT_NO_TABLETEVENT
+
+#ifndef QT_NO_DRAGANDDROP
+/*!
+ Creates a QDragMoveEvent of the required \a type indicating
+ that the mouse is at position \a pos given within a widget.
+
+ The mouse and keyboard states are specified by \a buttons and
+ \a modifiers, and the \a actions describe the types of drag
+ and drop operation that are possible.
+ The drag data is passed as MIME-encoded information in \a data.
+
+ \warning Do not attempt to create a QDragMoveEvent yourself.
+ These objects rely on Qt's internal state.
+*/
+QDragMoveEvent::QDragMoveEvent(const QPoint& pos, Qt::DropActions actions, const QMimeData *data,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type)
+ : QDropEvent(pos, actions, data, buttons, modifiers, type)
+ , rect(pos, QSize(1, 1))
+{}
+
+/*!
+ Destroys the event.
+*/
+QDragMoveEvent::~QDragMoveEvent()
+{
+}
+
+/*!
+ \fn void QDragMoveEvent::accept(bool y)
+
+ Calls setAccepted(\a y) instead.
+*/
+
+/*!
+ \fn void QDragMoveEvent::accept(const QRect &rectangle)
+
+ The same as accept(), but also notifies that future moves will
+ also be acceptable if they remain within the \a rectangle
+ given on the widget. This can improve performance, but may
+ also be ignored by the underlying system.
+
+ If the rectangle is empty, drag move events will be sent
+ continuously. This is useful if the source is scrolling in a
+ timer event.
+*/
+
+/*!
+ \fn void QDragMoveEvent::accept()
+
+ \overload
+
+ Calls QDropEvent::accept().
+*/
+
+/*!
+ \fn void QDragMoveEvent::ignore()
+
+ \overload
+
+ Calls QDropEvent::ignore().
+*/
+
+/*!
+ \fn void QDragMoveEvent::ignore(const QRect &rectangle)
+
+ The opposite of the accept(const QRect&) function.
+ Moves within the \a rectangle are not acceptable, and will be
+ ignored.
+*/
+
+/*!
+ \fn QRect QDragMoveEvent::answerRect() const
+
+ Returns the rectangle in the widget where the drop will occur if accepted.
+ You can use this information to restrict drops to certain places on the
+ widget.
+*/
+
+
+/*!
+ \class QDropEvent
+ \ingroup events
+ \ingroup draganddrop
+
+ \brief The QDropEvent class provides an event which is sent when a
+ drag and drop action is completed.
+
+ When a widget \l{QWidget::setAcceptDrops()}{accepts drop events}, it will
+ receive this event if it has accepted the most recent QDragEnterEvent or
+ QDragMoveEvent sent to it.
+
+ The drop event contains a proposed action, available from proposedAction(), for
+ the widget to either accept or ignore. If the action can be handled by the
+ widget, you should call the acceptProposedAction() function. Since the
+ proposed action can be a combination of \l Qt::DropAction values, it may be
+ useful to either select one of these values as a default action or ask
+ the user to select their preferred action.
+
+ If the proposed drop action is not suitable, perhaps because your custom
+ widget does not support that action, you can replace it with any of the
+ \l{possibleActions()}{possible drop actions} by calling setDropAction()
+ with your preferred action. If you set a value that is not present in the
+ bitwise OR combination of values returned by possibleActions(), the default
+ copy action will be used. Once a replacement drop action has been set, call
+ accept() instead of acceptProposedAction() to complete the drop operation.
+
+ The mimeData() function provides the data dropped on the widget in a QMimeData
+ object. This contains information about the MIME type of the data in addition to
+ the data itself.
+
+ \sa QMimeData, QDrag, {Drag and Drop}
+*/
+
+/*!
+ \fn const QMimeData *QDropEvent::mimeData() const
+
+ Returns the data that was dropped on the widget and its associated MIME
+ type information.
+*/
+
+/*!
+ Constructs a drop event of a certain \a type corresponding to a
+ drop at the point specified by \a pos in the destination widget's
+ coordinate system.
+
+ The \a actions indicate which types of drag and drop operation can
+ be performed, and the drag data is stored as MIME-encoded data in \a data.
+
+ The states of the mouse buttons and keyboard modifiers at the time of
+ the drop are specified by \a buttons and \a modifiers.
+*/ // ### pos is in which coordinate system?
+QDropEvent::QDropEvent(const QPoint& pos, Qt::DropActions actions, const QMimeData *data,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type)
+ : QEvent(type), p(pos), mouseState(buttons),
+ modState(modifiers), act(actions),
+ mdata(data)
+{
+ default_action = Qt::CopyAction; // ### Qt5: QDragManager::self()->defaultAction(act, modifiers);
+ drop_action = default_action;
+ ignore();
+}
+
+/*! \internal */
+QDropEvent::~QDropEvent()
+{
+}
+
+/*!
+ \compat
+ Returns a byte array containing the drag's data, in \a format.
+
+ data() normally needs to get the data from the drag source, which
+ is potentially very slow, so it's advisable to call this function
+ only if you're sure that you will need the data in that
+ particular \a format.
+
+ The resulting data will have a size of 0 if the format was not
+ available.
+
+ \sa format() QByteArray::size()
+*/
+
+QByteArray QDropEvent::encodedData(const char *format) const
+{
+ return mdata->data(QLatin1String(format));
+}
+
+/*!
+ \compat
+ Returns a string describing one of the available data types for
+ this drag. Common examples are "text/plain" and "image/gif".
+ If \a n is less than zero or greater than the number of available
+ data types, format() returns 0.
+
+ This function is provided mainly for debugging. Most drop targets
+ will use provides().
+
+ \sa data() provides()
+*/
+
+const char* QDropEvent::format(int n) const
+{
+ if (fmts.isEmpty()) {
+ QStringList formats = mdata->formats();
+ for (int i = 0; i < formats.size(); ++i)
+ fmts.append(formats.at(i).toLatin1());
+ }
+ if (n < 0 || n >= fmts.size())
+ return 0;
+ return fmts.at(n).constData();
+}
+
+/*!
+ \compat
+ Returns true if this event provides format \a mimeType; otherwise
+ returns false.
+
+ \sa data()
+*/
+
+bool QDropEvent::provides(const char *mimeType) const
+{
+ return mdata->formats().contains(QLatin1String(mimeType));
+}
+
+/*!
+ If the source of the drag operation is a widget in this
+ application, this function returns that source; otherwise it
+ returns 0. The source of the operation is the first parameter to
+ the QDrag object used instantiate the drag.
+
+ This is useful if your widget needs special behavior when dragging
+ to itself.
+
+ \sa QDrag::QDrag()
+*/
+QWidget* QDropEvent::source() const
+{
+ return 0;
+ // ### Qt5
+// QDragManager *manager = QDragManager::self();
+// return manager ? manager->source() : 0;
+}
+
+
+void QDropEvent::setDropAction(Qt::DropAction action)
+{
+ if (!(action & act) && action != Qt::IgnoreAction)
+ action = default_action;
+ drop_action = action;
+}
+
+/*!
+ \fn const QPoint& QDropEvent::pos() const
+
+ Returns the position where the drop was made.
+*/
+
+/*!
+ \fn Qt::MouseButtons QDropEvent::mouseButtons() const
+
+ Returns the mouse buttons that are pressed..
+*/
+
+/*!
+ \fn Qt::KeyboardModifiers QDropEvent::keyboardModifiers() const
+
+ Returns the modifier keys that are pressed.
+*/
+
+/*!
+ \fn void QDropEvent::accept()
+ \internal
+*/
+
+/*!
+ \fn void QDropEvent::accept(bool accept)
+
+ Call setAccepted(\a accept) instead.
+*/
+
+/*!
+ \fn void QDropEvent::acceptAction(bool accept = true)
+
+ Call this to indicate that the action described by action() is
+ accepted (i.e. if \a accept is true, which is the default), not merely
+ the default copy action. If you call acceptAction(true), there is
+ no need to also call accept(true).
+*/
+
+/*!
+ \enum QDropEvent::Action
+ \compat
+
+ When a drag and drop action is completed, the target is expected
+ to perform an action on the data provided by the source. This
+ will be one of the following:
+
+ \value Copy The default action. The source simply uses the data
+ provided in the operation.
+ \value Link The source should somehow create a link to the
+ location specified by the data.
+ \value Move The source should somehow move the object from the
+ location specified by the data to a new location.
+ \value Private The target has special knowledge of the MIME type,
+ which the source should respond to in a similar way to
+ a Copy.
+ \value UserAction The source and target can co-operate using
+ special actions. This feature is not currently
+ supported.
+
+ The Link and Move actions only makes sense if the data is a
+ reference, for example, text/uri-list file lists (see QUriDrag).
+*/
+
+/*!
+ \fn void QDropEvent::setDropAction(Qt::DropAction action)
+
+ Sets the \a action to be performed on the data by the target.
+ Use this to override the \l{proposedAction()}{proposed action}
+ with one of the \l{possibleActions()}{possible actions}.
+
+ If you set a drop action that is not one of the possible actions, the
+ drag and drop operation will default to a copy operation.
+
+ Once you have supplied a replacement drop action, call accept()
+ instead of acceptProposedAction().
+
+ \sa dropAction()
+*/
+
+/*!
+ \fn Qt::DropAction QDropEvent::dropAction() const
+
+ Returns the action to be performed on the data by the target. This may be
+ different from the action supplied in proposedAction() if you have called
+ setDropAction() to explicitly choose a drop action.
+
+ \sa setDropAction()
+*/
+
+/*!
+ \fn Qt::DropActions QDropEvent::possibleActions() const
+
+ Returns an OR-combination of possible drop actions.
+
+ \sa dropAction()
+*/
+
+/*!
+ \fn Qt::DropAction QDropEvent::proposedAction() const
+
+ Returns the proposed drop action.
+
+ \sa dropAction()
+*/
+
+/*!
+ \fn void QDropEvent::acceptProposedAction()
+
+ Sets the drop action to be the proposed action.
+
+ \sa setDropAction(), proposedAction(), {QEvent::accept()}{accept()}
+*/
+
+/*!
+ \fn void QDropEvent::setPoint(const QPoint &point)
+ \compat
+
+ Sets the drop to happen at the given \a point. You do not normally
+ need to use this as it will be set internally before your widget
+ receives the drop event.
+*/ // ### here too - what coordinate system?
+
+
+/*!
+ \class QDragEnterEvent
+ \brief The QDragEnterEvent class provides an event which is sent
+ to a widget when a drag and drop action enters it.
+
+ \ingroup events
+ \ingroup draganddrop
+
+ A widget must accept this event in order to receive the \l
+ {QDragMoveEvent}{drag move events} that are sent while the drag
+ and drop action is in progress. The drag enter event is always
+ immediately followed by a drag move event.
+
+ QDragEnterEvent inherits most of its functionality from
+ QDragMoveEvent, which in turn inherits most of its functionality
+ from QDropEvent.
+
+ \sa QDragLeaveEvent, QDragMoveEvent, QDropEvent
+*/
+
+/*!
+ Constructs a QDragEnterEvent that represents a drag entering a
+ widget at the given \a point with mouse and keyboard states specified by
+ \a buttons and \a modifiers.
+
+ The drag data is passed as MIME-encoded information in \a data, and the
+ specified \a actions describe the possible types of drag and drop
+ operation that can be performed.
+
+ \warning Do not create a QDragEnterEvent yourself since these
+ objects rely on Qt's internal state.
+*/
+QDragEnterEvent::QDragEnterEvent(const QPoint& point, Qt::DropActions actions, const QMimeData *data,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
+ : QDragMoveEvent(point, actions, data, buttons, modifiers, DragEnter)
+{}
+
+/*! \internal
+*/
+QDragEnterEvent::~QDragEnterEvent()
+{
+}
+
+/*!
+ Constructs a drag response event containing the \a accepted value,
+ indicating whether the drag and drop operation was accepted by the
+ recipient.
+*/
+QDragResponseEvent::QDragResponseEvent(bool accepted)
+ : QEvent(DragResponse), a(accepted)
+{}
+
+/*! \internal
+*/
+QDragResponseEvent::~QDragResponseEvent()
+{
+}
+
+/*!
+ \class QDragMoveEvent
+ \brief The QDragMoveEvent class provides an event which is sent while a drag and drop action is in progress.
+
+ \ingroup events
+ \ingroup draganddrop
+
+ A widget will receive drag move events repeatedly while the drag
+ is within its boundaries, if it accepts
+ \l{QWidget::setAcceptDrops()}{drop events} and \l
+ {QWidget::dragEnterEvent()}{enter events}. The widget should
+ examine the event to see what kind of data it
+ \l{QDragMoveEvent::provides()}{provides}, and call the accept()
+ function to accept the drop if appropriate.
+
+ The rectangle supplied by the answerRect() function can be used to restrict
+ drops to certain parts of the widget. For example, we can check whether the
+ rectangle intersects with the geometry of a certain child widget and only
+ call \l{QDropEvent::acceptProposedAction()}{acceptProposedAction()} if that
+ is the case.
+
+ Note that this class inherits most of its functionality from
+ QDropEvent.
+
+ \sa QDragEnterEvent, QDragLeaveEvent, QDropEvent
+*/
+
+/*!
+ \class QDragLeaveEvent
+ \brief The QDragLeaveEvent class provides an event that is sent to a widget when a drag and drop action leaves it.
+
+ \ingroup events
+ \ingroup draganddrop
+
+ This event is always preceded by a QDragEnterEvent and a series
+ of \l{QDragMoveEvent}s. It is not sent if a QDropEvent is sent
+ instead.
+
+ \sa QDragEnterEvent, QDragMoveEvent, QDropEvent
+*/
+
+/*!
+ Constructs a QDragLeaveEvent.
+
+ \warning Do not create a QDragLeaveEvent yourself since these
+ objects rely on Qt's internal state.
+*/
+QDragLeaveEvent::QDragLeaveEvent()
+ : QEvent(DragLeave)
+{}
+
+/*! \internal
+*/
+QDragLeaveEvent::~QDragLeaveEvent()
+{
+}
+#endif // QT_NO_DRAGANDDROP
+
+/*!
+ \class QHelpEvent
+ \brief The QHelpEvent class provides an event that is used to request helpful information
+ about a particular point in a widget.
+
+ \ingroup events
+ \ingroup helpsystem
+
+ This event can be intercepted in applications to provide tooltips
+ or "What's This?" help for custom widgets. The type() can be
+ either QEvent::ToolTip or QEvent::WhatsThis.
+
+ \sa QToolTip, QWhatsThis, QStatusTipEvent, QWhatsThisClickedEvent
+*/
+
+/*!
+ Constructs a help event with the given \a type corresponding to the
+ widget-relative position specified by \a pos and the global position
+ specified by \a globalPos.
+
+ \a type must be either QEvent::ToolTip or QEvent::WhatsThis.
+
+ \sa pos(), globalPos()
+*/
+QHelpEvent::QHelpEvent(Type type, const QPoint &pos, const QPoint &globalPos)
+ : QEvent(type), p(pos), gp(globalPos)
+{}
+
+/*!
+ \fn int QHelpEvent::x() const
+
+ Same as pos().x().
+
+ \sa y(), pos(), globalPos()
+*/
+
+/*!
+ \fn int QHelpEvent::y() const
+
+ Same as pos().y().
+
+ \sa x(), pos(), globalPos()
+*/
+
+/*!
+ \fn int QHelpEvent::globalX() const
+
+ Same as globalPos().x().
+
+ \sa x(), globalY(), globalPos()
+*/
+
+/*!
+ \fn int QHelpEvent::globalY() const
+
+ Same as globalPos().y().
+
+ \sa y(), globalX(), globalPos()
+*/
+
+/*!
+ \fn const QPoint &QHelpEvent::pos() const
+
+ Returns the mouse cursor position when the event was generated,
+ relative to the widget to which the event is dispatched.
+
+ \sa globalPos(), x(), y()
+*/
+
+/*!
+ \fn const QPoint &QHelpEvent::globalPos() const
+
+ Returns the mouse cursor position when the event was generated
+ in global coordinates.
+
+ \sa pos(), globalX(), globalY()
+*/
+
+/*! \internal
+*/
+QHelpEvent::~QHelpEvent()
+{
+}
+
+#ifndef QT_NO_STATUSTIP
+
+/*!
+ \class QStatusTipEvent
+ \brief The QStatusTipEvent class provides an event that is used to show messages in a status bar.
+
+ \ingroup events
+ \ingroup helpsystem
+
+ Status tips can be set on a widget using the
+ QWidget::setStatusTip() function. They are shown in the status
+ bar when the mouse cursor enters the widget. For example:
+
+ \table 100%
+ \row
+ \o
+ \snippet doc/src/snippets/qstatustipevent/main.cpp 1
+ \dots
+ \snippet doc/src/snippets/qstatustipevent/main.cpp 3
+ \o
+ \image qstatustipevent-widget.png Widget with status tip.
+ \endtable
+
+ Status tips can also be set on actions using the
+ QAction::setStatusTip() function:
+
+ \table 100%
+ \row
+ \o
+ \snippet doc/src/snippets/qstatustipevent/main.cpp 0
+ \snippet doc/src/snippets/qstatustipevent/main.cpp 2
+ \dots
+ \snippet doc/src/snippets/qstatustipevent/main.cpp 3
+ \o
+ \image qstatustipevent-action.png Action with status tip.
+ \endtable
+
+ Finally, status tips are supported for the item view classes
+ through the Qt::StatusTipRole enum value.
+
+ \sa QStatusBar, QHelpEvent, QWhatsThisClickedEvent
+*/
+
+/*!
+ Constructs a status tip event with the text specified by \a tip.
+
+ \sa tip()
+*/
+QStatusTipEvent::QStatusTipEvent(const QString &tip)
+ : QEvent(StatusTip), s(tip)
+{}
+
+/*! \internal
+*/
+QStatusTipEvent::~QStatusTipEvent()
+{
+}
+
+/*!
+ \fn QString QStatusTipEvent::tip() const
+
+ Returns the message to show in the status bar.
+
+ \sa QStatusBar::showMessage()
+*/
+
+#endif // QT_NO_STATUSTIP
+
+#ifndef QT_NO_WHATSTHIS
+
+/*!
+ \class QWhatsThisClickedEvent
+ \brief The QWhatsThisClickedEvent class provides an event that
+ can be used to handle hyperlinks in a "What's This?" text.
+
+ \ingroup events
+ \ingroup helpsystem
+
+ \sa QWhatsThis, QHelpEvent, QStatusTipEvent
+*/
+
+/*!
+ Constructs an event containing a URL specified by \a href when a link
+ is clicked in a "What's This?" message.
+
+ \sa href()
+*/
+QWhatsThisClickedEvent::QWhatsThisClickedEvent(const QString &href)
+ : QEvent(WhatsThisClicked), s(href)
+{}
+
+/*! \internal
+*/
+QWhatsThisClickedEvent::~QWhatsThisClickedEvent()
+{
+}
+
+/*!
+ \fn QString QWhatsThisClickedEvent::href() const
+
+ Returns the URL that was clicked by the user in the "What's
+ This?" text.
+*/
+
+#endif // QT_NO_WHATSTHIS
+
+#ifndef QT_NO_ACTION
+
+/*!
+ \class QActionEvent
+ \brief The QActionEvent class provides an event that is generated
+ when a QAction is added, removed, or changed.
+
+ \ingroup events
+
+ Actions can be added to widgets using QWidget::addAction(). This
+ generates an \l ActionAdded event, which you can handle to provide
+ custom behavior. For example, QToolBar reimplements
+ QWidget::actionEvent() to create \l{QToolButton}s for the
+ actions.
+
+ \sa QAction, QWidget::addAction(), QWidget::removeAction(), QWidget::actions()
+*/
+
+/*!
+ Constructs an action event. The \a type can be \l ActionChanged,
+ \l ActionAdded, or \l ActionRemoved.
+
+ \a action is the action that is changed, added, or removed. If \a
+ type is ActionAdded, the action is to be inserted before the
+ action \a before. If \a before is 0, the action is appended.
+*/
+QActionEvent::QActionEvent(int type, QAction *action, QAction *before)
+ : QEvent(static_cast<QEvent::Type>(type)), act(action), bef(before)
+{}
+
+/*! \internal
+*/
+QActionEvent::~QActionEvent()
+{
+}
+
+/*!
+ \fn QAction *QActionEvent::action() const
+
+ Returns the action that is changed, added, or removed.
+
+ \sa before()
+*/
+
+/*!
+ \fn QAction *QActionEvent::before() const
+
+ If type() is \l ActionAdded, returns the action that should
+ appear before action(). If this function returns 0, the action
+ should be appended to already existing actions on the same
+ widget.
+
+ \sa action(), QWidget::actions()
+*/
+
+#endif // QT_NO_ACTION
+
+/*!
+ \class QHideEvent
+ \brief The QHideEvent class provides an event which is sent after a widget is hidden.
+
+ \ingroup events
+
+ This event is sent just before QWidget::hide() returns, and also
+ when a top-level window has been hidden (iconified) by the user.
+
+ If spontaneous() is true, the event originated outside the
+ application. In this case, the user hid the window using the
+ window manager controls, either by iconifying the window or by
+ switching to another virtual desktop where the window isn't
+ visible. The window will become hidden but not withdrawn. If the
+ window was iconified, QWidget::isMinimized() returns true.
+
+ \sa QShowEvent
+*/
+
+/*!
+ Constructs a QHideEvent.
+*/
+QHideEvent::QHideEvent()
+ : QEvent(Hide)
+{}
+
+/*! \internal
+*/
+QHideEvent::~QHideEvent()
+{
+}
+
+/*!
+ \class QShowEvent
+ \brief The QShowEvent class provides an event that is sent when a widget is shown.
+
+ \ingroup events
+
+ There are two kinds of show events: show events caused by the
+ window system (spontaneous), and internal show events. Spontaneous (QEvent::spontaneous())
+ show events are sent just after the window system shows the
+ window; they are also sent when a top-level window is redisplayed
+ after being iconified. Internal show events are delivered just
+ before the widget becomes visible.
+
+ \sa QHideEvent
+*/
+
+/*!
+ Constructs a QShowEvent.
+*/
+QShowEvent::QShowEvent()
+ : QEvent(Show)
+{}
+
+/*! \internal
+*/
+QShowEvent::~QShowEvent()
+{
+}
+
+/*!
+ \fn QByteArray QDropEvent::data(const char* f) const
+
+ \obsolete
+
+ The encoded data is in \a f.
+ Use QDropEvent::encodedData().
+*/
+
+/*!
+ \class QFileOpenEvent
+ \brief The QFileOpenEvent class provides an event that will be
+ sent when there is a request to open a file or a URL.
+
+ \ingroup events
+
+ File open events will be sent to the QApplication::instance()
+ when the operating system requests that a file or URL should be opened.
+ This is a high-level event that can be caused by different user actions
+ depending on the user's desktop environment; for example, double
+ clicking on an file icon in the Finder on Mac OS X.
+
+ This event is only used to notify the application of a request.
+ It may be safely ignored.
+
+ \note This class is currently supported for Mac OS X and Symbian only.
+*/
+
+QFileOpenEventPrivate::~QFileOpenEventPrivate()
+{
+#ifdef Q_OS_SYMBIAN
+ file.Close();
+#endif
+}
+
+/*!
+ \internal
+
+ Constructs a file open event for the given \a file.
+*/
+QFileOpenEvent::QFileOpenEvent(const QString &file)
+ : QEvent(FileOpen), f(file)
+{
+ d = reinterpret_cast<QEventPrivate *>(new QFileOpenEventPrivate(QUrl::fromLocalFile(file)));
+}
+
+/*!
+ \internal
+
+ Constructs a file open event for the given \a url.
+*/
+QFileOpenEvent::QFileOpenEvent(const QUrl &url)
+ : QEvent(FileOpen)
+{
+ d = reinterpret_cast<QEventPrivate *>(new QFileOpenEventPrivate(url));
+ f = url.toLocalFile();
+}
+
+#ifdef Q_OS_SYMBIAN
+/*! \internal
+*/
+QFileOpenEvent::QFileOpenEvent(const RFile &fileHandle)
+ : QEvent(FileOpen)
+{
+ TFileName fullName;
+ fileHandle.FullName(fullName);
+ f = qt_TDesC2QString(fullName);
+ QScopedPointer<QFileOpenEventPrivate> priv(new QFileOpenEventPrivate(QUrl::fromLocalFile(f)));
+ // Duplicate here allows the file handle to be valid after S60 app construction is complete.
+ qt_symbian_throwIfError(priv->file.Duplicate(fileHandle));
+ d = reinterpret_cast<QEventPrivate *>(priv.take());
+}
+#endif
+
+/*! \internal
+*/
+QFileOpenEvent::~QFileOpenEvent()
+{
+ delete reinterpret_cast<QFileOpenEventPrivate *>(d);
+}
+
+/*!
+ \fn QString QFileOpenEvent::file() const
+
+ Returns the file that is being opened.
+*/
+
+/*!
+ \fn QUrl QFileOpenEvent::url() const
+
+ Returns the url that is being opened.
+
+ \since 4.6
+*/
+QUrl QFileOpenEvent::url() const
+{
+ return reinterpret_cast<const QFileOpenEventPrivate *>(d)->url;
+}
+
+/*!
+ \fn bool openFile(QFile &file, QIODevice::OpenMode flags) const
+
+ Opens a QFile on the file referenced by this event.
+ Returns true if successful; otherwise returns false.
+
+ This is necessary as some files cannot be opened by name, but require specific
+ information stored in this event.
+ For example, if this QFileOpenEvent contains a request to open a Symbian data caged file,
+ the QFile could only be opened from the Symbian RFile used in the construction of this event.
+
+ \since 4.8
+*/
+bool QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const
+{
+ file.setFileName(f);
+#ifdef Q_OS_SYMBIAN
+ const QFileOpenEventPrivate *priv = reinterpret_cast<const QFileOpenEventPrivate *>(d);
+ if (priv->file.SubSessionHandle()) {
+ RFile dup;
+ // Duplicate here means that the opened QFile will continue to be valid beyond the lifetime of this QFileOpenEvent.
+ // It also allows openFile to be used in threads other than the thread in which the QFileOpenEvent was created.
+ if (dup.Duplicate(priv->file) == KErrNone) {
+ QScopedPointer<RFile, QScopedPointerRCloser<RFile> > dupCloser(&dup);
+ bool open = file.open(dup, flags, QFile::AutoCloseHandle);
+ dupCloser.take();
+ return open;
+ }
+ }
+#endif
+ return file.open(flags);
+}
+
+#ifndef QT_NO_TOOLBAR
+/*!
+ \internal
+ \class QToolBarChangeEvent
+ \brief The QToolBarChangeEvent class provides an event that is
+ sent whenever a the toolbar button is clicked on Mac OS X.
+
+ \ingroup events
+
+ The QToolBarChangeEvent is sent when the toolbar button is clicked. On Mac
+ OS X, this is the long oblong button on the right side of the window
+ title bar. The default implementation is to toggle the appearance (hidden or
+ shown) of the associated toolbars for the window.
+*/
+
+/*!
+ \internal
+
+ Construct a QToolBarChangeEvent given the current button state in \a state.
+*/
+QToolBarChangeEvent::QToolBarChangeEvent(bool t)
+ : QEvent(ToolBarChange), tog(t)
+{}
+
+/*! \internal
+*/
+QToolBarChangeEvent::~QToolBarChangeEvent()
+{
+}
+
+/*!
+ \fn bool QToolBarChangeEvent::toggle() const
+ \internal
+*/
+
+/*
+ \fn Qt::ButtonState QToolBarChangeEvent::state() const
+
+ Returns the keyboard modifier flags at the time of the event.
+
+ The returned value is a selection of the following values,
+ combined using the OR operator:
+ Qt::ShiftButton, Qt::ControlButton, Qt::MetaButton, and Qt::AltButton.
+*/
+
+#endif // QT_NO_TOOLBAR
+
+#ifndef QT_NO_SHORTCUT
+
+/*!
+ Constructs a shortcut event for the given \a key press,
+ associated with the QShortcut ID \a id.
+
+ \a ambiguous specifies whether there is more than one QShortcut
+ for the same key sequence.
+*/
+QShortcutEvent::QShortcutEvent(const QKeySequence &key, int id, bool ambiguous)
+ : QEvent(Shortcut), sequence(key), ambig(ambiguous), sid(id)
+{
+}
+
+/*!
+ Destroys the event object.
+*/
+QShortcutEvent::~QShortcutEvent()
+{
+}
+
+#endif // QT_NO_SHORTCUT
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const QEvent *e) {
+#ifndef Q_BROKEN_DEBUG_STREAM
+ // More useful event output could be added here
+ if (!e)
+ return dbg << "QEvent(this = 0x0)";
+ const char *n = 0;
+ switch (e->type()) {
+ case QEvent::Timer:
+ n = "Timer";
+ break;
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseMove:
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseButtonDblClick:
+ {
+ const QMouseEvent *me = static_cast<const QMouseEvent*>(e);
+ switch(me->type()) {
+ case QEvent::MouseButtonPress:
+ n = "MouseButtonPress";
+ break;
+ case QEvent::MouseMove:
+ n = "MouseMove";
+ break;
+ case QEvent::MouseButtonRelease:
+ n = "MouseButtonRelease";
+ break;
+ case QEvent::MouseButtonDblClick:
+ default:
+ n = "MouseButtonDblClick";
+ break;
+ }
+ dbg.nospace() << "QMouseEvent(" << n
+ << ", " << me->button()
+ << ", " << hex << (int)me->buttons()
+ << ", " << hex << (int)me->modifiers()
+ << ')';
+ }
+ return dbg.space();
+
+#ifndef QT_NO_TOOLTIP
+ case QEvent::ToolTip:
+ n = "ToolTip";
+ break;
+#endif
+ case QEvent::WindowActivate:
+ n = "WindowActivate";
+ break;
+ case QEvent::WindowDeactivate:
+ n = "WindowDeactivate";
+ break;
+ case QEvent::ActivationChange:
+ n = "ActivationChange";
+ break;
+#ifndef QT_NO_WHEELEVENT
+ case QEvent::Wheel:
+ dbg.nospace() << "QWheelEvent(" << static_cast<const QWheelEvent *>(e)->delta()
+ << ')';
+ return dbg.space();
+#endif
+ case QEvent::KeyPress:
+ case QEvent::KeyRelease:
+ case QEvent::ShortcutOverride:
+ {
+ const QKeyEvent *ke = static_cast<const QKeyEvent*>(e);
+ switch(ke->type()) {
+ case QEvent::ShortcutOverride:
+ n = "ShortcutOverride";
+ break;
+ case QEvent::KeyRelease:
+ n = "KeyRelease";
+ break;
+ case QEvent::KeyPress:
+ default:
+ n = "KeyPress";
+ break;
+ }
+ dbg.nospace() << "QKeyEvent(" << n
+ << ", " << hex << ke->key()
+ << ", " << hex << (int)ke->modifiers()
+ << ", \"" << ke->text()
+ << "\", " << ke->isAutoRepeat()
+ << ", " << ke->count()
+ << ')';
+ }
+ return dbg.space();
+ case QEvent::FocusIn:
+ n = "FocusIn";
+ break;
+ case QEvent::FocusOut:
+ n = "FocusOut";
+ break;
+ case QEvent::Enter:
+ n = "Enter";
+ break;
+ case QEvent::Leave:
+ n = "Leave";
+ break;
+ case QEvent::PaletteChange:
+ n = "PaletteChange";
+ break;
+ case QEvent::PolishRequest:
+ n = "PolishRequest";
+ break;
+ case QEvent::Polish:
+ n = "Polish";
+ break;
+ case QEvent::UpdateRequest:
+ n = "UpdateRequest";
+ break;
+ case QEvent::Paint:
+ n = "Paint";
+ break;
+ case QEvent::Move:
+ n = "Move";
+ break;
+ case QEvent::Resize:
+ n = "Resize";
+ break;
+ case QEvent::Create:
+ n = "Create";
+ break;
+ case QEvent::Destroy:
+ n = "Destroy";
+ break;
+ case QEvent::Close:
+ n = "Close";
+ break;
+ case QEvent::Quit:
+ n = "Quit";
+ break;
+ case QEvent::FileOpen:
+ n = "FileOpen";
+ break;
+ case QEvent::Show:
+ n = "Show";
+ break;
+ case QEvent::ShowToParent:
+ n = "ShowToParent";
+ break;
+ case QEvent::Hide:
+ n = "Hide";
+ break;
+ case QEvent::HideToParent:
+ n = "HideToParent";
+ break;
+ case QEvent::None:
+ n = "None";
+ break;
+ case QEvent::ParentChange:
+ n = "ParentChange";
+ break;
+ case QEvent::ParentAboutToChange:
+ n = "ParentAboutToChange";
+ break;
+ case QEvent::HoverEnter:
+ n = "HoverEnter";
+ break;
+ case QEvent::HoverMove:
+ n = "HoverMove";
+ break;
+ case QEvent::HoverLeave:
+ n = "HoverLeave";
+ break;
+ case QEvent::ZOrderChange:
+ n = "ZOrderChange";
+ break;
+ case QEvent::StyleChange:
+ n = "StyleChange";
+ break;
+ case QEvent::DragEnter:
+ n = "DragEnter";
+ break;
+ case QEvent::DragMove:
+ n = "DragMove";
+ break;
+ case QEvent::DragLeave:
+ n = "DragLeave";
+ break;
+ case QEvent::Drop:
+ n = "Drop";
+ break;
+ case QEvent::GraphicsSceneMouseMove:
+ n = "GraphicsSceneMouseMove";
+ break;
+ case QEvent::GraphicsSceneMousePress:
+ n = "GraphicsSceneMousePress";
+ break;
+ case QEvent::GraphicsSceneMouseRelease:
+ n = "GraphicsSceneMouseRelease";
+ break;
+ case QEvent::GraphicsSceneMouseDoubleClick:
+ n = "GraphicsSceneMouseDoubleClick";
+ break;
+ case QEvent::GraphicsSceneContextMenu:
+ n = "GraphicsSceneContextMenu";
+ break;
+ case QEvent::GraphicsSceneHoverEnter:
+ n = "GraphicsSceneHoverEnter";
+ break;
+ case QEvent::GraphicsSceneHoverMove:
+ n = "GraphicsSceneHoverMove";
+ break;
+ case QEvent::GraphicsSceneHoverLeave:
+ n = "GraphicsSceneHoverLeave";
+ break;
+ case QEvent::GraphicsSceneHelp:
+ n = "GraphicsSceneHelp";
+ break;
+ case QEvent::GraphicsSceneDragEnter:
+ n = "GraphicsSceneDragEnter";
+ break;
+ case QEvent::GraphicsSceneDragMove:
+ n = "GraphicsSceneDragMove";
+ break;
+ case QEvent::GraphicsSceneDragLeave:
+ n = "GraphicsSceneDragLeave";
+ break;
+ case QEvent::GraphicsSceneDrop:
+ n = "GraphicsSceneDrop";
+ break;
+ case QEvent::GraphicsSceneWheel:
+ n = "GraphicsSceneWheel";
+ break;
+ case QEvent::GraphicsSceneResize:
+ n = "GraphicsSceneResize";
+ break;
+ case QEvent::GraphicsSceneMove:
+ n = "GraphicsSceneMove";
+ break;
+ case QEvent::CursorChange:
+ n = "CursorChange";
+ break;
+ case QEvent::ToolTipChange:
+ n = "ToolTipChange";
+ break;
+ case QEvent::StatusTip:
+ n = "StatusTip";
+ break;
+ case QEvent::WhatsThis:
+ n = "WhatsThis";
+ break;
+ case QEvent::FontChange:
+ n = "FontChange";
+ break;
+ case QEvent::Style:
+ n = "Style";
+ break;
+ case QEvent::KeyboardLayoutChange:
+ n = "KeyboardLayoutChange";
+ break;
+ case QEvent::DynamicPropertyChange:
+ n = "DynamicPropertyChange";
+ break;
+ case QEvent::GrabMouse:
+ n = "GrabMouse";
+ break;
+ case QEvent::UngrabMouse:
+ n = "UngrabMouse";
+ break;
+ case QEvent::GrabKeyboard:
+ n = "GrabKeyboard";
+ break;
+ case QEvent::UngrabKeyboard:
+ n = "UngrabKeyboard";
+ break;
+ case QEvent::ChildAdded: n = n ? n : "ChildAdded";
+ case QEvent::ChildPolished: n = n ? n : "ChildPolished";
+ case QEvent::ChildRemoved: n = n ? n : "ChildRemoved";
+ dbg.nospace() << "QChildEvent(" << n << ", " << (static_cast<const QChildEvent*>(e))->child();
+ return dbg.space();
+#ifndef QT_NO_GESTURES
+ case QEvent::Gesture:
+ n = "Gesture";
+ break;
+#endif
+ default:
+ dbg.nospace() << "QEvent(" << (const void *)e << ", type = " << e->type() << ')';
+ return dbg.space();
+ }
+
+ dbg.nospace() << 'Q' << n << "Event(" << (const void *)e << ')';
+ return dbg.space();
+#else
+ qWarning("This compiler doesn't support streaming QEvent to QDebug");
+ return dbg;
+ Q_UNUSED(e);
+#endif
+}
+#endif
+
+#ifndef QT_NO_CLIPBOARD
+/*!
+ \class QClipboardEvent
+ \ingroup events
+ \internal
+
+ \brief The QClipboardEvent class provides the parameters used in a clipboard event.
+
+ This class is for internal use only, and exists to aid the clipboard on various
+ platforms to get all the information it needs. Use QEvent::Clipboard instead.
+
+ \sa QClipboard
+*/
+
+QClipboardEvent::QClipboardEvent(QEventPrivate *data)
+ : QEvent(QEvent::Clipboard)
+{
+ d = data;
+}
+
+QClipboardEvent::~QClipboardEvent()
+{
+}
+#endif // QT_NO_CLIPBOARD
+
+/*!
+ \class QShortcutEvent
+ \brief The QShortcutEvent class provides an event which is generated when
+ the user presses a key combination.
+
+ \ingroup events
+
+ Normally you don't need to use this class directly; QShortcut
+ provides a higher-level interface to handle shortcut keys.
+
+ \sa QShortcut
+*/
+
+/*!
+ \fn const QKeySequence &QShortcutEvent::key() const
+
+ Returns the key sequence that triggered the event.
+*/
+
+// ### Qt 5: remove
+/*!
+ \fn const QKeySequence &QShortcutEvent::key()
+
+ \internal
+*/
+
+/*!
+ \fn int QShortcutEvent::shortcutId() const
+
+ Returns the ID of the QShortcut object for which this event was
+ generated.
+
+ \sa QShortcut::id()
+*/
+
+// ### Qt 5: remove
+/*!
+ \fn int QShortcutEvent::shortcutId()
+ \overload
+
+ \internal
+*/
+
+/*!
+ \fn bool QShortcutEvent::isAmbiguous() const
+
+ Returns true if the key sequence that triggered the event is
+ ambiguous.
+
+ \sa QShortcut::activatedAmbiguously()
+*/
+
+// ### Qt 5: remove
+/*!
+ \fn bool QShortcutEvent::isAmbiguous()
+
+ \internal
+*/
+
+/*!
+ \class QWindowStateChangeEvent
+ \ingroup events
+
+ \brief The QWindowStateChangeEvent class provides the window state before a
+ window state change.
+*/
+
+/*! \fn Qt::WindowStates QWindowStateChangeEvent::oldState() const
+
+ Returns the state of the window before the change.
+*/
+
+/*! \internal
+ */
+QWindowStateChangeEvent::QWindowStateChangeEvent(Qt::WindowStates s)
+ : QEvent(WindowStateChange), ostate(s)
+{
+}
+
+/*! \internal
+ */
+QWindowStateChangeEvent::QWindowStateChangeEvent(Qt::WindowStates s, bool isOverride)
+ : QEvent(WindowStateChange), ostate(s)
+{
+ if (isOverride)
+ d = (QEventPrivate*)(this);
+}
+
+/*! \internal
+ */
+bool QWindowStateChangeEvent::isOverride() const
+{
+ return (d != 0);
+}
+
+/*! \internal
+*/
+QWindowStateChangeEvent::~QWindowStateChangeEvent()
+{
+}
+
+
+/*!
+ \class QTouchEvent
+ \brief The QTouchEvent class contains parameters that describe a touch event.
+ \since 4.6
+ \ingroup events
+ \ingroup touch
+
+ \section1 Enabling Touch Events
+
+ Touch events occur when pressing, releasing, or moving one or more touch points on a touch
+ device (such as a touch-screen or track-pad). To receive touch events, widgets have to have the
+ Qt::WA_AcceptTouchEvents attribute set and graphics items need to have the
+ \l{QGraphicsItem::setAcceptTouchEvents()}{acceptTouchEvents} attribute set to true.
+
+ When using QAbstractScrollArea based widgets, you should enable the Qt::WA_AcceptTouchEvents
+ attribute on the scroll area's \l{QAbstractScrollArea::viewport()}{viewport}.
+
+ Similarly to QMouseEvent, Qt automatically grabs each touch point on the first press inside a
+ widget, and the widget will receive all updates for the touch point until it is released.
+ Note that it is possible for a widget to receive events for numerous touch points, and that
+ multiple widgets may be receiving touch events at the same time.
+
+ \section1 Event Handling
+
+ All touch events are of type QEvent::TouchBegin, QEvent::TouchUpdate, or QEvent::TouchEnd.
+ Reimplement QWidget::event() or QAbstractScrollArea::viewportEvent() for widgets and
+ QGraphicsItem::sceneEvent() for items in a graphics view to receive touch events.
+
+ The QEvent::TouchUpdate and QEvent::TouchEnd events are sent to the widget or item that
+ accepted the QEvent::TouchBegin event. If the QEvent::TouchBegin event is not accepted and not
+ filtered by an event filter, then no further touch events are sent until the next
+ QEvent::TouchBegin.
+
+ The touchPoints() function returns a list of all touch points contained in the event.
+ Information about each touch point can be retrieved using the QTouchEvent::TouchPoint class.
+ The Qt::TouchPointState enum describes the different states that a touch point may have.
+
+ \section1 Event Delivery and Propagation
+
+ By default, QWidget::event() translates the first non-primary touch point in a QTouchEvent into
+ a QMouseEvent. This makes it possible to enable touch events on existing widgets that do not
+ normally handle QTouchEvent. See below for information on some special considerations needed
+ when doing this.
+
+ QEvent::TouchBegin is the first touch event sent to a widget. The QEvent::TouchBegin event
+ contains a special accept flag that indicates whether the receiver wants the event. By default,
+ the event is accepted. You should call ignore() if the touch event is not handled by your
+ widget. The QEvent::TouchBegin event is propagated up the parent widget chain until a widget
+ accepts it with accept(), or an event filter consumes it. For QGraphicsItems, the
+ QEvent::TouchBegin event is propagated to items under the mouse (similar to mouse event
+ propagation for QGraphicsItems).
+
+ \section1 Touch Point Grouping
+
+ As mentioned above, it is possible that several widgets can be receiving QTouchEvents at the
+ same time. However, Qt makes sure to never send duplicate QEvent::TouchBegin events to the same
+ widget, which could theoretically happen during propagation if, for example, the user touched 2
+ separate widgets in a QGroupBox and both widgets ignored the QEvent::TouchBegin event.
+
+ To avoid this, Qt will group new touch points together using the following rules:
+
+ \list
+
+ \i When the first touch point is detected, the destination widget is determined firstly by the
+ location on screen and secondly by the propagation rules.
+
+ \i When additional touch points are detected, Qt first looks to see if there are any active
+ touch points on any ancestor or descendent of the widget under the new touch point. If there
+ are, the new touch point is grouped with the first, and the new touch point will be sent in a
+ single QTouchEvent to the widget that handled the first touch point. (The widget under the new
+ touch point will not receive an event).
+
+ \endlist
+
+ This makes it possible for sibling widgets to handle touch events independently while making
+ sure that the sequence of QTouchEvents is always correct.
+
+ \section1 Mouse Events and the Primary Touch Point
+
+ QTouchEvent delivery is independent from that of QMouseEvent. On some windowing systems, mouse
+ events are also sent for the \l{QTouchEvent::TouchPoint::isPrimary()}{primary touch point}.
+ This means it is possible for your widget to receive both QTouchEvent and QMouseEvent for the
+ same user interaction point. You can use the QTouchEvent::TouchPoint::isPrimary() function to
+ identify the primary touch point.
+
+ Note that on some systems, it is possible to receive touch events without a primary touch
+ point. All this means is that there will be no mouse event generated for the touch points in
+ the QTouchEvent.
+
+ \section1 Caveats
+
+ \list
+
+ \i As mentioned above, enabling touch events means multiple widgets can be receiving touch
+ events simultaneously. Combined with the default QWidget::event() handling for QTouchEvents,
+ this gives you great flexibility in designing touch user interfaces. Be aware of the
+ implications. For example, it is possible that the user is moving a QSlider with one finger and
+ pressing a QPushButton with another. The signals emitted by these widgets will be
+ interleaved.
+
+ \i Recursion into the event loop using one of the exec() methods (e.g., QDialog::exec() or
+ QMenu::exec()) in a QTouchEvent event handler is not supported. Since there are multiple event
+ recipients, recursion may cause problems, including but not limited to lost events
+ and unexpected infinite recursion.
+
+ \i QTouchEvents are not affected by a \l{QWidget::grabMouse()}{mouse grab} or an
+ \l{QApplication::activePopupWidget()}{active pop-up widget}. The behavior of QTouchEvents is
+ undefined when opening a pop-up or grabbing the mouse while there are more than one active touch
+ points.
+
+ \endlist
+
+ \sa QTouchEvent::TouchPoint, Qt::TouchPointState, Qt::WA_AcceptTouchEvents,
+ QGraphicsItem::acceptTouchEvents()
+*/
+
+/*! \enum Qt::TouchPointState
+ \since 4.6
+
+ This enum represents the state of a touch point at the time the
+ QTouchEvent occurred.
+
+ \value TouchPointPressed The touch point is now pressed.
+ \value TouchPointMoved The touch point moved.
+ \value TouchPointStationary The touch point did not move.
+ \value TouchPointReleased The touch point was released.
+
+ \omitvalue TouchPointStateMask
+ \omitvalue TouchPointPrimary
+*/
+
+/*! \enum QTouchEvent::DeviceType
+
+ This enum represents the type of device that generated a QTouchEvent.
+
+ \value TouchScreen In this type of device, the touch surface and display are integrated. This
+ means the surface and display typically have the same size, such that there
+ is a direct relationship between the touch points' physical positions and the
+ coordinate reported by QTouchEvent::TouchPoint. As a result, Qt allows the
+ user to interact directly with multiple QWidgets and QGraphicsItems at the
+ same time.
+
+ \value TouchPad In this type of device, the touch surface is separate from the display. There
+ is not a direct relationship between the physical touch location and the
+ on-screen coordinates. Instead, they are calculated relative to the current
+ mouse position, and the user must use the touch-pad to move this reference
+ point. Unlike touch-screens, Qt allows users to only interact with a single
+ QWidget or QGraphicsItem at a time.
+*/
+
+/*!
+ Constructs a QTouchEvent with the given \a eventType, \a deviceType, and \a touchPoints.
+ The \a touchPointStates and \a modifiers are the current touch point states and keyboard
+ modifiers at the time of the event.
+*/
+QTouchEvent::QTouchEvent(QEvent::Type eventType,
+ QTouchEvent::DeviceType deviceType,
+ Qt::KeyboardModifiers modifiers,
+ Qt::TouchPointStates touchPointStates,
+ const QList<QTouchEvent::TouchPoint> &touchPoints)
+ : QInputEvent(eventType, modifiers),
+ _widget(0),
+ _deviceType(deviceType),
+ _touchPointStates(touchPointStates),
+ _touchPoints(touchPoints)
+{ }
+
+/*!
+ Destroys the QTouchEvent.
+*/
+QTouchEvent::~QTouchEvent()
+{ }
+
+/*! \fn QWidget *QTouchEvent::widget() const
+
+ Returns the widget on which the event occurred.
+*/
+
+
+/*! \fn Qt::TouchPointStates QTouchEvent::touchPointStates() const
+
+ Returns a bitwise OR of all the touch point states for this event.
+*/
+
+/*! \fn const QList<QTouchEvent::TouchPoint> &QTouchEvent::touchPoints() const
+
+ Returns the list of touch points contained in the touch event.
+*/
+
+/*! \fn QTouchEvent::DeviceType QTouchEvent::deviceType() const
+
+ Returns the touch device Type, which is of type \l {QTouchEvent::DeviceType} {DeviceType}.
+*/
+
+/*! \fn void QTouchEvent::setWidget(QWidget *widget)
+
+ \internal
+
+ Sets the widget for this event.
+*/
+
+/*! \fn void QTouchEvent::setTouchPointStates(Qt::TouchPointStates touchPointStates)
+
+ \internal
+
+ Sets a bitwise OR of all the touch point states for this event.
+*/
+
+/*! \fn void QTouchEvent::setTouchPoints(const QList<QTouchEvent::TouchPoint> &touchPoints)
+
+ \internal
+
+ Sets the list of touch points for this event.
+*/
+
+/*! \fn void QTouchEvent::setDeviceType(DeviceType deviceType)
+
+ \internal
+
+ Sets the device type to \a deviceType, which is of type \l {QTouchEvent::DeviceType}
+ {DeviceType}.
+*/
+
+/*! \class QTouchEvent::TouchPoint
+ \brief The TouchPoint class provides information about a touch point in a QTouchEvent.
+ \since 4.6
+*/
+
+/*! \internal
+
+ Constructs a QTouchEvent::TouchPoint for use in a QTouchEvent.
+*/
+QTouchEvent::TouchPoint::TouchPoint(int id)
+ : d(new QTouchEventTouchPointPrivate(id))
+{ }
+
+/*! \internal
+
+ Constructs a copy of \a other.
+*/
+QTouchEvent::TouchPoint::TouchPoint(const QTouchEvent::TouchPoint &other)
+ : d(other.d)
+{
+ d->ref.ref();
+}
+
+/*! \internal
+
+ Destroys the QTouchEvent::TouchPoint.
+*/
+QTouchEvent::TouchPoint::~TouchPoint()
+{
+ if (!d->ref.deref())
+ delete d;
+}
+
+/*!
+ Returns the id number of this touch point.
+
+ Id numbers are globally sequential, starting at zero, meaning the
+ first touch point in the application has id 0, the second has id 1,
+ and so on.
+*/
+int QTouchEvent::TouchPoint::id() const
+{
+ return d->id;
+}
+
+/*!
+ Returns the current state of this touch point.
+*/
+Qt::TouchPointState QTouchEvent::TouchPoint::state() const
+{
+ return Qt::TouchPointState(int(d->state) & Qt::TouchPointStateMask);
+}
+
+/*!
+ Returns true if this touch point is the primary touch point. The primary touch point is the
+ point for which the windowing system generates mouse events.
+*/
+bool QTouchEvent::TouchPoint::isPrimary() const
+{
+ return (d->state & Qt::TouchPointPrimary) != 0;
+}
+
+/*!
+ Returns the position of this touch point, relative to the widget
+ or QGraphicsItem that received the event.
+
+ \sa startPos(), lastPos(), screenPos(), scenePos(), normalizedPos()
+*/
+QPointF QTouchEvent::TouchPoint::pos() const
+{
+ return d->rect.center();
+}
+
+/*!
+ Returns the scene position of this touch point.
+
+ The scene position is the position in QGraphicsScene coordinates
+ if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
+ reimplementation, and identical to the screen position for
+ widgets.
+
+ \sa startScenePos(), lastScenePos(), pos()
+*/
+QPointF QTouchEvent::TouchPoint::scenePos() const
+{
+ return d->sceneRect.center();
+}
+
+/*!
+ Returns the screen position of this touch point.
+
+ \sa startScreenPos(), lastScreenPos(), pos()
+*/
+QPointF QTouchEvent::TouchPoint::screenPos() const
+{
+ return d->screenRect.center();
+}
+
+/*!
+ Returns the normalized position of this touch point.
+
+ The coordinates are normalized to the size of the touch device,
+ i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
+
+ \sa startNormalizedPos(), lastNormalizedPos(), pos()
+*/
+QPointF QTouchEvent::TouchPoint::normalizedPos() const
+{
+ return d->normalizedPos;
+}
+
+/*!
+ Returns the starting position of this touch point, relative to the
+ widget or QGraphicsItem that received the event.
+
+ \sa pos(), lastPos()
+*/
+QPointF QTouchEvent::TouchPoint::startPos() const
+{
+ return d->startPos;
+}
+
+/*!
+ Returns the starting scene position of this touch point.
+
+ The scene position is the position in QGraphicsScene coordinates
+ if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
+ reimplementation, and identical to the screen position for
+ widgets.
+
+ \sa scenePos(), lastScenePos()
+*/
+QPointF QTouchEvent::TouchPoint::startScenePos() const
+{
+ return d->startScenePos;
+}
+
+/*!
+ Returns the starting screen position of this touch point.
+
+ \sa screenPos(), lastScreenPos()
+*/
+QPointF QTouchEvent::TouchPoint::startScreenPos() const
+{
+ return d->startScreenPos;
+}
+
+/*!
+ Returns the normalized starting position of this touch point.
+
+ The coordinates are normalized to the size of the touch device,
+ i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
+
+ \sa normalizedPos(), lastNormalizedPos()
+*/
+QPointF QTouchEvent::TouchPoint::startNormalizedPos() const
+{
+ return d->startNormalizedPos;
+}
+
+/*!
+ Returns the position of this touch point from the previous touch
+ event, relative to the widget or QGraphicsItem that received the event.
+
+ \sa pos(), startPos()
+*/
+QPointF QTouchEvent::TouchPoint::lastPos() const
+{
+ return d->lastPos;
+}
+
+/*!
+ Returns the scene position of this touch point from the previous
+ touch event.
+
+ The scene position is the position in QGraphicsScene coordinates
+ if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
+ reimplementation, and identical to the screen position for
+ widgets.
+
+ \sa scenePos(), startScenePos()
+*/
+QPointF QTouchEvent::TouchPoint::lastScenePos() const
+{
+ return d->lastScenePos;
+}
+
+/*!
+ Returns the screen position of this touch point from the previous
+ touch event.
+
+ \sa screenPos(), startScreenPos()
+*/
+QPointF QTouchEvent::TouchPoint::lastScreenPos() const
+{
+ return d->lastScreenPos;
+}
+
+/*!
+ Returns the normalized position of this touch point from the
+ previous touch event.
+
+ The coordinates are normalized to the size of the touch device,
+ i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
+
+ \sa normalizedPos(), startNormalizedPos()
+*/
+QPointF QTouchEvent::TouchPoint::lastNormalizedPos() const
+{
+ return d->lastNormalizedPos;
+}
+
+/*!
+ Returns the rect for this touch point, relative to the widget
+ or QGraphicsItem that received the event. The rect is centered
+ around the point returned by pos().
+
+ \note This function returns an empty rect if the device does not report touch point sizes.
+*/
+QRectF QTouchEvent::TouchPoint::rect() const
+{
+ return d->rect;
+}
+
+/*!
+ Returns the rect for this touch point in scene coordinates.
+
+ \note This function returns an empty rect if the device does not report touch point sizes.
+
+ \sa scenePos(), rect()
+*/
+QRectF QTouchEvent::TouchPoint::sceneRect() const
+{
+ return d->sceneRect;
+}
+
+/*!
+ Returns the rect for this touch point in screen coordinates.
+
+ \note This function returns an empty rect if the device does not report touch point sizes.
+
+ \sa screenPos(), rect()
+*/
+QRectF QTouchEvent::TouchPoint::screenRect() const
+{
+ return d->screenRect;
+}
+
+/*!
+ Returns the pressure of this touch point. The return value is in
+ the range 0.0 to 1.0.
+*/
+qreal QTouchEvent::TouchPoint::pressure() const
+{
+ return d->pressure;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setId(int id)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->id = id;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setState(Qt::TouchPointStates state)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->state = state;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setPos(const QPointF &pos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->rect.moveCenter(pos);
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setScenePos(const QPointF &scenePos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->sceneRect.moveCenter(scenePos);
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setScreenPos(const QPointF &screenPos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->screenRect.moveCenter(screenPos);
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setNormalizedPos(const QPointF &normalizedPos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->normalizedPos = normalizedPos;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setStartPos(const QPointF &startPos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->startPos = startPos;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setStartScenePos(const QPointF &startScenePos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->startScenePos = startScenePos;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setStartScreenPos(const QPointF &startScreenPos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->startScreenPos = startScreenPos;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setStartNormalizedPos(const QPointF &startNormalizedPos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->startNormalizedPos = startNormalizedPos;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setLastPos(const QPointF &lastPos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->lastPos = lastPos;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setLastScenePos(const QPointF &lastScenePos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->lastScenePos = lastScenePos;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setLastScreenPos(const QPointF &lastScreenPos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->lastScreenPos = lastScreenPos;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setLastNormalizedPos(const QPointF &lastNormalizedPos)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->lastNormalizedPos = lastNormalizedPos;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setRect(const QRectF &rect)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->rect = rect;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setSceneRect(const QRectF &sceneRect)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->sceneRect = sceneRect;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setScreenRect(const QRectF &screenRect)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->screenRect = screenRect;
+}
+
+/*! \internal */
+void QTouchEvent::TouchPoint::setPressure(qreal pressure)
+{
+ if (d->ref != 1)
+ d = d->detach();
+ d->pressure = pressure;
+}
+
+/*! \internal */
+QTouchEvent::TouchPoint &QTouchEvent::TouchPoint::operator=(const QTouchEvent::TouchPoint &other)
+{
+ other.d->ref.ref();
+ if (!d->ref.deref())
+ delete d;
+ d = other.d;
+ return *this;
+}
+
+
+/*!
+ \class QScrollPrepareEvent
+ \since 4.8
+ \ingroup events
+
+ \brief The QScrollPrepareEvent class is send in preparation of a scrolling.
+
+ The scroll prepare event is send before scrolling (usually by QScroller) is started.
+ The object receiving this event should set viewportSize, maxContentPos and contentPos.
+ It also should accept this event to indicate that scrolling should be started.
+
+ It is not guaranteed that a QScrollEvent will be send after an acceepted
+ QScrollPrepareEvent, e.g. in a case where the maximum content position is (0,0).
+
+ \sa QScrollEvent, QScroller
+*/
+
+/*!
+ Creates new QScrollPrepareEvent
+ The \a startPos is the position of a touch or mouse event that started the scrolling.
+*/
+QScrollPrepareEvent::QScrollPrepareEvent(const QPointF &startPos)
+ : QEvent(QEvent::ScrollPrepare)
+{
+ d = reinterpret_cast<QEventPrivate *>(new QScrollPrepareEventPrivate());
+ d_func()->startPos = startPos;
+}
+
+/*!
+ Destroys QScrollEvent.
+*/
+QScrollPrepareEvent::~QScrollPrepareEvent()
+{
+ delete reinterpret_cast<QScrollPrepareEventPrivate *>(d);
+}
+
+/*!
+ Returns the position of the touch or mouse event that started the scrolling.
+*/
+QPointF QScrollPrepareEvent::startPos() const
+{
+ return d_func()->startPos;
+}
+
+/*!
+ Returns size of the area that is to be scrolled as set by setViewportSize
+
+ \sa setViewportSize()
+*/
+QSizeF QScrollPrepareEvent::viewportSize() const
+{
+ return d_func()->viewportSize;
+}
+
+/*!
+ Returns the range of coordinates for the content as set by setContentPosRange().
+*/
+QRectF QScrollPrepareEvent::contentPosRange() const
+{
+ return d_func()->contentPosRange;
+}
+
+/*!
+ Returns the current position of the content as set by setContentPos.
+*/
+QPointF QScrollPrepareEvent::contentPos() const
+{
+ return d_func()->contentPos;
+}
+
+
+/*!
+ Sets the size of the area that is to be scrolled to \a size.
+
+ \sa viewportSize()
+*/
+void QScrollPrepareEvent::setViewportSize(const QSizeF &size)
+{
+ d_func()->viewportSize = size;
+}
+
+/*!
+ Sets the range of content coordinates to \a rect.
+
+ \sa contentPosRange()
+*/
+void QScrollPrepareEvent::setContentPosRange(const QRectF &rect)
+{
+ d_func()->contentPosRange = rect;
+}
+
+/*!
+ Sets the current content position to \a pos.
+
+ \sa contentPos()
+*/
+void QScrollPrepareEvent::setContentPos(const QPointF &pos)
+{
+ d_func()->contentPos = pos;
+}
+
+
+/*!
+ \internal
+*/
+QScrollPrepareEventPrivate *QScrollPrepareEvent::d_func()
+{
+ return reinterpret_cast<QScrollPrepareEventPrivate *>(d);
+}
+
+/*!
+ \internal
+*/
+const QScrollPrepareEventPrivate *QScrollPrepareEvent::d_func() const
+{
+ return reinterpret_cast<const QScrollPrepareEventPrivate *>(d);
+}
+
+/*!
+ \class QScrollEvent
+ \since 4.8
+ \ingroup events
+
+ \brief The QScrollEvent class is send when scrolling.
+
+ The scroll event is send to indicate that the receiver should be scrolled.
+ Usually the receiver should be something visual like QWidget or QGraphicsObject.
+
+ Some care should be taken that no conflicting QScrollEvents are sent from two
+ sources. Using QScroller::scrollTo is save however.
+
+ \sa QScrollPrepareEvent, QScroller
+*/
+
+/*!
+ \enum QScrollEvent::ScrollState
+
+ This enum describes the states a scroll event can have.
+
+ \value ScrollStarted Set for the first scroll event of a scroll activity.
+
+ \value ScrollUpdated Set for all but the first and the last scroll event of a scroll activity.
+
+ \value ScrollFinished Set for the last scroll event of a scroll activity.
+
+ \sa QScrollEvent::scrollState()
+*/
+
+/*!
+ Creates a new QScrollEvent
+ \a contentPos is the new content position, \a overshootDistance is the
+ new overshoot distance while \a scrollState indicates if this scroll
+ event is the first one, the last one or some event in between.
+*/
+QScrollEvent::QScrollEvent(const QPointF &contentPos, const QPointF &overshootDistance, ScrollState scrollState)
+ : QEvent(QEvent::Scroll)
+{
+ d = reinterpret_cast<QEventPrivate *>(new QScrollEventPrivate());
+ d_func()->contentPos = contentPos;
+ d_func()->overshoot= overshootDistance;
+ d_func()->state = scrollState;
+}
+
+/*!
+ Destroys QScrollEvent.
+*/
+QScrollEvent::~QScrollEvent()
+{
+ delete reinterpret_cast<QScrollEventPrivate *>(d);
+}
+
+/*!
+ Returns the new scroll position.
+*/
+QPointF QScrollEvent::contentPos() const
+{
+ return d_func()->contentPos;
+}
+
+/*!
+ Returns the new overshoot distance.
+ See QScroller for an explanation of the term overshoot.
+
+ \sa QScroller
+*/
+QPointF QScrollEvent::overshootDistance() const
+{
+ return d_func()->overshoot;
+}
+
+/*!
+ Returns the current scroll state as a combination of ScrollStateFlag values.
+ ScrollStarted (or ScrollFinished) will be set, if this scroll event is the first (or last) event in a scrolling activity.
+ Please note that both values can be set at the same time, if the activity consists of a single QScrollEvent.
+ All other scroll events in between will have their state set to ScrollUpdated.
+
+ A widget could for example revert selections when scrolling is started and stopped.
+*/
+QScrollEvent::ScrollState QScrollEvent::scrollState() const
+{
+ return d_func()->state;
+}
+
+/*!
+ \internal
+*/
+QScrollEventPrivate *QScrollEvent::d_func()
+{
+ return reinterpret_cast<QScrollEventPrivate *>(d);
+}
+
+/*!
+ \internal
+*/
+const QScrollEventPrivate *QScrollEvent::d_func() const
+{
+ return reinterpret_cast<const QScrollEventPrivate *>(d);
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/guikernel/qevent.h b/src/gui/guikernel/qevent.h
new file mode 100644
index 0000000000..45b11d4795
--- /dev/null
+++ b/src/gui/guikernel/qevent.h
@@ -0,0 +1,812 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QEVENT_H
+#define QEVENT_H
+
+#include <QtGui/qwindowdefs.h>
+#include <QtCore/qobject.h>
+#include <QtGui/qregion.h>
+#include <QtCore/qnamespace.h>
+#include <QtCore/qstring.h>
+#include <QtGui/qkeysequence.h>
+#include <QtCore/qcoreevent.h>
+#include <QtGui/qmime.h>
+#include <QtCore/qvariant.h>
+#include <QtCore/qmap.h>
+#include <QtCore/qset.h>
+#include <QtCore/qfile.h>
+
+#ifdef Q_OS_SYMBIAN
+class RFile;
+#endif
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QAction;
+#ifndef QT_NO_GESTURES
+class QGesture;
+#endif
+
+class Q_GUI_EXPORT QInputEvent : public QEvent
+{
+public:
+ QInputEvent(Type type, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
+ ~QInputEvent();
+ inline Qt::KeyboardModifiers modifiers() const { return modState; }
+ inline void setModifiers(Qt::KeyboardModifiers amodifiers) { modState = amodifiers; }
+protected:
+ Qt::KeyboardModifiers modState;
+};
+
+class Q_GUI_EXPORT QMouseEvent : public QInputEvent
+{
+public:
+ QMouseEvent(Type type, const QPoint &pos, Qt::MouseButton button,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
+ QMouseEvent(Type type, const QPoint &pos, const QPoint &globalPos,
+ Qt::MouseButton button, Qt::MouseButtons buttons,
+ Qt::KeyboardModifiers modifiers);
+ ~QMouseEvent();
+
+ inline const QPoint &pos() const { return p; }
+ inline const QPoint &globalPos() const { return g; }
+ inline int x() const { return p.x(); }
+ inline int y() const { return p.y(); }
+ inline int globalX() const { return g.x(); }
+ inline int globalY() const { return g.y(); }
+ inline Qt::MouseButton button() const { return b; }
+ inline Qt::MouseButtons buttons() const { return mouseState; }
+
+ static QMouseEvent *createExtendedMouseEvent(Type type, const QPointF &pos,
+ const QPoint &globalPos, Qt::MouseButton button,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
+ inline bool hasExtendedInfo() const { return reinterpret_cast<const QMouseEvent *>(d) == this; }
+ QPointF posF() const;
+
+protected:
+ QPoint p, g;
+ Qt::MouseButton b;
+ Qt::MouseButtons mouseState;
+};
+
+class Q_GUI_EXPORT QHoverEvent : public QEvent
+{
+public:
+ QHoverEvent(Type type, const QPoint &pos, const QPoint &oldPos);
+ ~QHoverEvent();
+
+ inline const QPoint &pos() const { return p; }
+ inline const QPoint &oldPos() const { return op; }
+
+protected:
+ QPoint p, op;
+};
+
+#ifndef QT_NO_WHEELEVENT
+class Q_GUI_EXPORT QWheelEvent : public QInputEvent
+{
+public:
+ QWheelEvent(const QPoint &pos, int delta,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
+ Qt::Orientation orient = Qt::Vertical);
+ QWheelEvent(const QPoint &pos, const QPoint& globalPos, int delta,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
+ Qt::Orientation orient = Qt::Vertical);
+ ~QWheelEvent();
+
+ inline int delta() const { return d; }
+ inline const QPoint &pos() const { return p; }
+ inline const QPoint &globalPos() const { return g; }
+ inline int x() const { return p.x(); }
+ inline int y() const { return p.y(); }
+ inline int globalX() const { return g.x(); }
+ inline int globalY() const { return g.y(); }
+
+ inline Qt::MouseButtons buttons() const { return mouseState; }
+ Qt::Orientation orientation() const { return o; }
+
+protected:
+ QPoint p;
+ QPoint g;
+ int d;
+ Qt::MouseButtons mouseState;
+ Qt::Orientation o;
+};
+#endif
+
+#ifndef QT_NO_TABLETEVENT
+class Q_GUI_EXPORT QTabletEvent : public QInputEvent
+{
+public:
+ enum TabletDevice { NoDevice, Puck, Stylus, Airbrush, FourDMouse,
+ XFreeEraser /*internal*/, RotationStylus };
+ enum PointerType { UnknownPointer, Pen, Cursor, Eraser };
+ QTabletEvent(Type t, const QPoint &pos, const QPoint &globalPos, const QPointF &hiResGlobalPos,
+ int device, int pointerType, qreal pressure, int xTilt, int yTilt,
+ qreal tangentialPressure, qreal rotation, int z,
+ Qt::KeyboardModifiers keyState, qint64 uniqueID);
+ ~QTabletEvent();
+
+ inline const QPoint &pos() const { return mPos; }
+ inline const QPoint &globalPos() const { return mGPos; }
+ inline const QPointF &hiResGlobalPos() const { return mHiResGlobalPos; }
+ inline int x() const { return mPos.x(); }
+ inline int y() const { return mPos.y(); }
+ inline int globalX() const { return mGPos.x(); }
+ inline int globalY() const { return mGPos.y(); }
+ inline qreal hiResGlobalX() const { return mHiResGlobalPos.x(); }
+ inline qreal hiResGlobalY() const { return mHiResGlobalPos.y(); }
+ inline TabletDevice device() const { return TabletDevice(mDev); }
+ inline PointerType pointerType() const { return PointerType(mPointerType); }
+ inline qint64 uniqueId() const { return mUnique; }
+ inline qreal pressure() const { return mPress; }
+ inline int z() const { return mZ; }
+ inline qreal tangentialPressure() const { return mTangential; }
+ inline qreal rotation() const { return mRot; }
+ inline int xTilt() const { return mXT; }
+ inline int yTilt() const { return mYT; }
+
+protected:
+ QPoint mPos, mGPos;
+ QPointF mHiResGlobalPos;
+ int mDev, mPointerType, mXT, mYT, mZ;
+ qreal mPress, mTangential, mRot;
+ qint64 mUnique;
+
+ // I don't know what the future holds for tablets but there could be some
+ // new devices coming along, and there seem to be "holes" in the
+ // OS-specific events for this.
+ void *mExtra;
+};
+#endif // QT_NO_TABLETEVENT
+
+class Q_GUI_EXPORT QKeyEvent : public QInputEvent
+{
+public:
+ QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text = QString(),
+ bool autorep = false, ushort count = 1);
+ ~QKeyEvent();
+
+ int key() const { return k; }
+#ifndef QT_NO_SHORTCUT
+ bool matches(QKeySequence::StandardKey key) const;
+#endif
+ Qt::KeyboardModifiers modifiers() const;
+ inline QString text() const { return txt; }
+ inline bool isAutoRepeat() const { return autor; }
+ inline int count() const { return int(c); }
+
+ // Functions for the extended key event information
+ static QKeyEvent *createExtendedKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers,
+ quint32 nativeScanCode, quint32 nativeVirtualKey,
+ quint32 nativeModifiers,
+ const QString& text = QString(), bool autorep = false,
+ ushort count = 1);
+ inline bool hasExtendedInfo() const { return reinterpret_cast<const QKeyEvent*>(d) == this; }
+ quint32 nativeScanCode() const;
+ quint32 nativeVirtualKey() const;
+ quint32 nativeModifiers() const;
+
+protected:
+ QString txt;
+ int k;
+ ushort c;
+ uint autor:1;
+};
+
+
+class Q_GUI_EXPORT QFocusEvent : public QEvent
+{
+public:
+ QFocusEvent(Type type, Qt::FocusReason reason=Qt::OtherFocusReason);
+ ~QFocusEvent();
+
+ inline bool gotFocus() const { return type() == FocusIn; }
+ inline bool lostFocus() const { return type() == FocusOut; }
+
+ Qt::FocusReason reason();
+ Qt::FocusReason reason() const;
+
+private:
+ Qt::FocusReason m_reason;
+};
+
+
+class Q_GUI_EXPORT QPaintEvent : public QEvent
+{
+public:
+ QPaintEvent(const QRegion& paintRegion);
+ QPaintEvent(const QRect &paintRect);
+ ~QPaintEvent();
+
+ inline const QRect &rect() const { return m_rect; }
+ inline const QRegion &region() const { return m_region; }
+
+protected:
+ friend class QApplication;
+ friend class QCoreApplication;
+ QRect m_rect;
+ QRegion m_region;
+ bool m_erased;
+};
+
+// ### Qt5: make internal
+class Q_GUI_EXPORT QUpdateLaterEvent : public QEvent
+{
+public:
+ QUpdateLaterEvent(const QRegion& paintRegion);
+ ~QUpdateLaterEvent();
+
+ inline const QRegion &region() const { return m_region; }
+
+protected:
+ QRegion m_region;
+};
+
+class Q_GUI_EXPORT QMoveEvent : public QEvent
+{
+public:
+ QMoveEvent(const QPoint &pos, const QPoint &oldPos);
+ ~QMoveEvent();
+
+ inline const QPoint &pos() const { return p; }
+ inline const QPoint &oldPos() const { return oldp;}
+protected:
+ QPoint p, oldp;
+ friend class QApplication;
+ friend class QCoreApplication;
+};
+
+
+class Q_GUI_EXPORT QResizeEvent : public QEvent
+{
+public:
+ QResizeEvent(const QSize &size, const QSize &oldSize);
+ ~QResizeEvent();
+
+ inline const QSize &size() const { return s; }
+ inline const QSize &oldSize()const { return olds;}
+protected:
+ QSize s, olds;
+ friend class QApplication;
+ friend class QCoreApplication;
+};
+
+
+class Q_GUI_EXPORT QCloseEvent : public QEvent
+{
+public:
+ QCloseEvent();
+ ~QCloseEvent();
+};
+
+
+class Q_GUI_EXPORT QIconDragEvent : public QEvent
+{
+public:
+ QIconDragEvent();
+ ~QIconDragEvent();
+};
+
+
+class Q_GUI_EXPORT QShowEvent : public QEvent
+{
+public:
+ QShowEvent();
+ ~QShowEvent();
+};
+
+
+class Q_GUI_EXPORT QHideEvent : public QEvent
+{
+public:
+ QHideEvent();
+ ~QHideEvent();
+};
+
+#ifndef QT_NO_CONTEXTMENU
+class Q_GUI_EXPORT QContextMenuEvent : public QInputEvent
+{
+public:
+ enum Reason { Mouse, Keyboard, Other };
+
+ QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos,
+ Qt::KeyboardModifiers modifiers);
+ QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos);
+ QContextMenuEvent(Reason reason, const QPoint &pos);
+ ~QContextMenuEvent();
+
+ inline int x() const { return p.x(); }
+ inline int y() const { return p.y(); }
+ inline int globalX() const { return gp.x(); }
+ inline int globalY() const { return gp.y(); }
+
+ inline const QPoint& pos() const { return p; }
+ inline const QPoint& globalPos() const { return gp; }
+
+ inline Reason reason() const { return Reason(reas); }
+
+protected:
+ QPoint p;
+ QPoint gp;
+ uint reas : 8;
+};
+#endif // QT_NO_CONTEXTMENU
+
+#ifndef QT_NO_INPUTMETHOD
+class Q_GUI_EXPORT QInputMethodEvent : public QEvent
+{
+public:
+ enum AttributeType {
+ TextFormat,
+ Cursor,
+ Language,
+ Ruby,
+ Selection
+ };
+ class Attribute {
+ public:
+ Attribute(AttributeType t, int s, int l, QVariant val) : type(t), start(s), length(l), value(val) {}
+ AttributeType type;
+
+ int start;
+ int length;
+ QVariant value;
+ };
+ QInputMethodEvent();
+ QInputMethodEvent(const QString &preeditText, const QList<Attribute> &attributes);
+ void setCommitString(const QString &commitString, int replaceFrom = 0, int replaceLength = 0);
+
+ inline const QList<Attribute> &attributes() const { return attrs; }
+ inline const QString &preeditString() const { return preedit; }
+
+ inline const QString &commitString() const { return commit; }
+ inline int replacementStart() const { return replace_from; }
+ inline int replacementLength() const { return replace_length; }
+
+ QInputMethodEvent(const QInputMethodEvent &other);
+
+private:
+ QString preedit;
+ QList<Attribute> attrs;
+ QString commit;
+ int replace_from;
+ int replace_length;
+};
+#endif // QT_NO_INPUTMETHOD
+
+#ifndef QT_NO_DRAGANDDROP
+
+class QMimeData;
+
+class Q_GUI_EXPORT QDropEvent : public QEvent
+// QT3_SUPPORT
+ , public QMimeSource
+// END QT3_SUPPORT
+{
+public:
+ QDropEvent(const QPoint& pos, Qt::DropActions actions, const QMimeData *data,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type = Drop);
+ ~QDropEvent();
+
+ inline const QPoint &pos() const { return p; }
+ inline Qt::MouseButtons mouseButtons() const { return mouseState; }
+ inline Qt::KeyboardModifiers keyboardModifiers() const { return modState; }
+
+ inline Qt::DropActions possibleActions() const { return act; }
+ inline Qt::DropAction proposedAction() const { return default_action; }
+ inline void acceptProposedAction() { drop_action = default_action; accept(); }
+
+ inline Qt::DropAction dropAction() const { return drop_action; }
+ void setDropAction(Qt::DropAction action);
+
+ QWidget* source() const;
+ inline const QMimeData *mimeData() const { return mdata; }
+
+// QT3_SUPPORT
+ const char* format(int n = 0) const;
+ QByteArray encodedData(const char*) const;
+ bool provides(const char*) const;
+// END QT3_SUPPORT
+
+
+protected:
+ friend class QApplication;
+ QPoint p;
+ Qt::MouseButtons mouseState;
+ Qt::KeyboardModifiers modState;
+ Qt::DropActions act;
+ Qt::DropAction drop_action;
+ Qt::DropAction default_action;
+ const QMimeData *mdata;
+ mutable QList<QByteArray> fmts; // only used for QT3_SUPPORT
+};
+
+
+class Q_GUI_EXPORT QDragMoveEvent : public QDropEvent
+{
+public:
+ QDragMoveEvent(const QPoint &pos, Qt::DropActions actions, const QMimeData *data,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type = DragMove);
+ ~QDragMoveEvent();
+
+ inline QRect answerRect() const { return rect; }
+
+ inline void accept() { QDropEvent::accept(); }
+ inline void ignore() { QDropEvent::ignore(); }
+
+ inline void accept(const QRect & r) { accept(); rect = r; }
+ inline void ignore(const QRect & r) { ignore(); rect = r; }
+
+protected:
+ friend class QApplication;
+ QRect rect;
+};
+
+
+class Q_GUI_EXPORT QDragEnterEvent : public QDragMoveEvent
+{
+public:
+ QDragEnterEvent(const QPoint &pos, Qt::DropActions actions, const QMimeData *data,
+ Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
+ ~QDragEnterEvent();
+};
+
+
+/* An internal class */
+class Q_GUI_EXPORT QDragResponseEvent : public QEvent
+{
+public:
+ QDragResponseEvent(bool accepted);
+ ~QDragResponseEvent();
+
+ inline bool dragAccepted() const { return a; }
+protected:
+ bool a;
+};
+
+
+class Q_GUI_EXPORT QDragLeaveEvent : public QEvent
+{
+public:
+ QDragLeaveEvent();
+ ~QDragLeaveEvent();
+};
+#endif // QT_NO_DRAGANDDROP
+
+
+class Q_GUI_EXPORT QHelpEvent : public QEvent
+{
+public:
+ QHelpEvent(Type type, const QPoint &pos, const QPoint &globalPos);
+ ~QHelpEvent();
+
+ inline int x() const { return p.x(); }
+ inline int y() const { return p.y(); }
+ inline int globalX() const { return gp.x(); }
+ inline int globalY() const { return gp.y(); }
+
+ inline const QPoint& pos() const { return p; }
+ inline const QPoint& globalPos() const { return gp; }
+
+private:
+ QPoint p;
+ QPoint gp;
+};
+
+#ifndef QT_NO_STATUSTIP
+class Q_GUI_EXPORT QStatusTipEvent : public QEvent
+{
+public:
+ QStatusTipEvent(const QString &tip);
+ ~QStatusTipEvent();
+
+ inline QString tip() const { return s; }
+private:
+ QString s;
+};
+#endif
+
+#ifndef QT_NO_WHATSTHIS
+class Q_GUI_EXPORT QWhatsThisClickedEvent : public QEvent
+{
+public:
+ QWhatsThisClickedEvent(const QString &href);
+ ~QWhatsThisClickedEvent();
+
+ inline QString href() const { return s; }
+private:
+ QString s;
+};
+#endif
+
+#ifndef QT_NO_ACTION
+class Q_GUI_EXPORT QActionEvent : public QEvent
+{
+ QAction *act, *bef;
+public:
+ QActionEvent(int type, QAction *action, QAction *before = 0);
+ ~QActionEvent();
+
+ inline QAction *action() const { return act; }
+ inline QAction *before() const { return bef; }
+};
+#endif
+
+class Q_GUI_EXPORT QFileOpenEvent : public QEvent
+{
+public:
+ QFileOpenEvent(const QString &file);
+ QFileOpenEvent(const QUrl &url);
+#ifdef Q_OS_SYMBIAN
+ QFileOpenEvent(const RFile &fileHandle);
+#endif
+ ~QFileOpenEvent();
+
+ inline QString file() const { return f; }
+ QUrl url() const;
+ bool openFile(QFile &file, QIODevice::OpenMode flags) const;
+private:
+ QString f;
+};
+
+#ifndef QT_NO_TOOLBAR
+class Q_GUI_EXPORT QToolBarChangeEvent : public QEvent
+{
+public:
+ QToolBarChangeEvent(bool t);
+ ~QToolBarChangeEvent();
+
+ inline bool toggle() const { return tog; }
+private:
+ uint tog : 1;
+};
+#endif
+
+#ifndef QT_NO_SHORTCUT
+class Q_GUI_EXPORT QShortcutEvent : public QEvent
+{
+public:
+ QShortcutEvent(const QKeySequence &key, int id, bool ambiguous = false);
+ ~QShortcutEvent();
+
+ inline const QKeySequence &key() { return sequence; }
+ inline const QKeySequence &key() const { return sequence; }
+ inline int shortcutId() { return sid; }
+ inline int shortcutId() const { return sid; }
+ inline bool isAmbiguous() { return ambig; }
+ inline bool isAmbiguous() const { return ambig; }
+protected:
+ QKeySequence sequence;
+ bool ambig;
+ int sid;
+};
+#endif
+
+#ifndef QT_NO_CLIPBOARD
+class Q_GUI_EXPORT QClipboardEvent : public QEvent
+{
+public:
+ QClipboardEvent(QEventPrivate *data);
+ ~QClipboardEvent();
+
+ QEventPrivate *data() { return d; }
+};
+#endif
+
+class Q_GUI_EXPORT QWindowStateChangeEvent: public QEvent
+{
+public:
+ QWindowStateChangeEvent(Qt::WindowStates aOldState);
+ QWindowStateChangeEvent(Qt::WindowStates aOldState, bool isOverride);
+ ~QWindowStateChangeEvent();
+
+ inline Qt::WindowStates oldState() const { return ostate; }
+ bool isOverride() const;
+
+private:
+ Qt::WindowStates ostate;
+};
+
+#ifndef QT_NO_DEBUG_STREAM
+Q_GUI_EXPORT QDebug operator<<(QDebug, const QEvent *);
+#endif
+
+#ifndef QT_NO_SHORTCUT
+inline bool operator==(QKeyEvent *e, QKeySequence::StandardKey key){return (e ? e->matches(key) : false);}
+inline bool operator==(QKeySequence::StandardKey key, QKeyEvent *e){return (e ? e->matches(key) : false);}
+#endif // QT_NO_SHORTCUT
+
+class QTouchEventTouchPointPrivate;
+class Q_GUI_EXPORT QTouchEvent : public QInputEvent
+{
+public:
+ class Q_GUI_EXPORT TouchPoint
+ {
+ public:
+ TouchPoint(int id = -1);
+ TouchPoint(const QTouchEvent::TouchPoint &other);
+ ~TouchPoint();
+
+ int id() const;
+
+ Qt::TouchPointState state() const;
+ bool isPrimary() const;
+
+ QPointF pos() const;
+ QPointF startPos() const;
+ QPointF lastPos() const;
+
+ QPointF scenePos() const;
+ QPointF startScenePos() const;
+ QPointF lastScenePos() const;
+
+ QPointF screenPos() const;
+ QPointF startScreenPos() const;
+ QPointF lastScreenPos() const;
+
+ QPointF normalizedPos() const;
+ QPointF startNormalizedPos() const;
+ QPointF lastNormalizedPos() const;
+
+ QRectF rect() const;
+ QRectF sceneRect() const;
+ QRectF screenRect() const;
+
+ qreal pressure() const;
+
+ // internal
+ void setId(int id);
+ void setState(Qt::TouchPointStates state);
+ void setPos(const QPointF &pos);
+ void setScenePos(const QPointF &scenePos);
+ void setScreenPos(const QPointF &screenPos);
+ void setNormalizedPos(const QPointF &normalizedPos);
+ void setStartPos(const QPointF &startPos);
+ void setStartScenePos(const QPointF &startScenePos);
+ void setStartScreenPos(const QPointF &startScreenPos);
+ void setStartNormalizedPos(const QPointF &startNormalizedPos);
+ void setLastPos(const QPointF &lastPos);
+ void setLastScenePos(const QPointF &lastScenePos);
+ void setLastScreenPos(const QPointF &lastScreenPos);
+ void setLastNormalizedPos(const QPointF &lastNormalizedPos);
+ void setRect(const QRectF &rect);
+ void setSceneRect(const QRectF &sceneRect);
+ void setScreenRect(const QRectF &screenRect);
+ void setPressure(qreal pressure);
+ QTouchEvent::TouchPoint &operator=(const QTouchEvent::TouchPoint &other);
+
+ private:
+ QTouchEventTouchPointPrivate *d;
+ friend class QApplication;
+ friend class QApplicationPrivate;
+ };
+
+ enum DeviceType {
+ TouchScreen,
+ TouchPad
+ };
+
+ QTouchEvent(QEvent::Type eventType,
+ QTouchEvent::DeviceType deviceType = TouchScreen,
+ Qt::KeyboardModifiers modifiers = Qt::NoModifier,
+ Qt::TouchPointStates touchPointStates = 0,
+ const QList<QTouchEvent::TouchPoint> &touchPoints = QList<QTouchEvent::TouchPoint>());
+ ~QTouchEvent();
+
+ inline QWidget *widget() const { return _widget; }
+ inline QTouchEvent::DeviceType deviceType() const { return _deviceType; }
+ inline Qt::TouchPointStates touchPointStates() const { return _touchPointStates; }
+ inline const QList<QTouchEvent::TouchPoint> &touchPoints() const { return _touchPoints; }
+
+ // internal
+ inline void setWidget(QWidget *awidget) { _widget = awidget; }
+ inline void setDeviceType(DeviceType adeviceType) { _deviceType = adeviceType; }
+ inline void setTouchPointStates(Qt::TouchPointStates aTouchPointStates) { _touchPointStates = aTouchPointStates; }
+ inline void setTouchPoints(const QList<QTouchEvent::TouchPoint> &atouchPoints) { _touchPoints = atouchPoints; }
+
+protected:
+ QWidget *_widget;
+ QTouchEvent::DeviceType _deviceType;
+ Qt::TouchPointStates _touchPointStates;
+ QList<QTouchEvent::TouchPoint> _touchPoints;
+
+ friend class QApplication;
+ friend class QApplicationPrivate;
+};
+
+
+class QScrollPrepareEventPrivate;
+class Q_GUI_EXPORT QScrollPrepareEvent : public QEvent
+{
+public:
+ QScrollPrepareEvent(const QPointF &startPos);
+ ~QScrollPrepareEvent();
+
+ QPointF startPos() const;
+
+ QSizeF viewportSize() const;
+ QRectF contentPosRange() const;
+ QPointF contentPos() const;
+
+ void setViewportSize(const QSizeF &size);
+ void setContentPosRange(const QRectF &rect);
+ void setContentPos(const QPointF &pos);
+
+private:
+ QScrollPrepareEventPrivate *d_func();
+ const QScrollPrepareEventPrivate *d_func() const;
+};
+
+
+class QScrollEventPrivate;
+class Q_GUI_EXPORT QScrollEvent : public QEvent
+{
+public:
+ enum ScrollState
+ {
+ ScrollStarted,
+ ScrollUpdated,
+ ScrollFinished
+ };
+
+ QScrollEvent(const QPointF &contentPos, const QPointF &overshoot, ScrollState scrollState);
+ ~QScrollEvent();
+
+ QPointF contentPos() const;
+ QPointF overshootDistance() const;
+ ScrollState scrollState() const;
+
+private:
+ QScrollEventPrivate *d_func();
+ const QScrollEventPrivate *d_func() const;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QEVENT_H
diff --git a/src/gui/guikernel/qevent_p.h b/src/gui/guikernel/qevent_p.h
new file mode 100644
index 0000000000..38060ea4ae
--- /dev/null
+++ b/src/gui/guikernel/qevent_p.h
@@ -0,0 +1,172 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QEVENT_P_H
+#define QEVENT_P_H
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qurl.h>
+#include <QtGui/qevent.h>
+
+#ifdef Q_OS_SYMBIAN
+#include <f32file.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+//
+// 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.
+//
+
+// ### Qt 5: remove
+class QKeyEventEx : public QKeyEvent
+{
+public:
+ QKeyEventEx(Type type, int key, Qt::KeyboardModifiers modifiers,
+ const QString &text, bool autorep, ushort count,
+ quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers);
+ QKeyEventEx(const QKeyEventEx &other);
+
+ ~QKeyEventEx();
+
+protected:
+ quint32 nScanCode;
+ quint32 nVirtualKey;
+ quint32 nModifiers;
+ friend class QKeyEvent;
+};
+
+// ### Qt 5: remove
+class QMouseEventEx : public QMouseEvent
+{
+public:
+ QMouseEventEx(Type type, const QPointF &pos, const QPoint &globalPos,
+ Qt::MouseButton button, Qt::MouseButtons buttons,
+ Qt::KeyboardModifiers modifiers);
+ ~QMouseEventEx();
+
+protected:
+ QPointF posF;
+ friend class QMouseEvent;
+};
+
+class QTouchEventTouchPointPrivate
+{
+public:
+ inline QTouchEventTouchPointPrivate(int id)
+ : ref(1),
+ id(id),
+ state(Qt::TouchPointReleased),
+ pressure(qreal(-1.))
+ { }
+
+ inline QTouchEventTouchPointPrivate *detach()
+ {
+ QTouchEventTouchPointPrivate *d = new QTouchEventTouchPointPrivate(*this);
+ d->ref = 1;
+ if (!this->ref.deref())
+ delete this;
+ return d;
+ }
+
+ QAtomicInt ref;
+ int id;
+ Qt::TouchPointStates state;
+ QRectF rect, sceneRect, screenRect;
+ QPointF normalizedPos,
+ startPos, startScenePos, startScreenPos, startNormalizedPos,
+ lastPos, lastScenePos, lastScreenPos, lastNormalizedPos;
+ qreal pressure;
+};
+
+class QFileOpenEventPrivate
+{
+public:
+ inline QFileOpenEventPrivate(const QUrl &url)
+ : url(url)
+ {
+ }
+ ~QFileOpenEventPrivate();
+
+ QUrl url;
+#ifdef Q_OS_SYMBIAN
+ RFile file;
+#endif
+};
+
+
+class QScrollPrepareEventPrivate
+{
+public:
+ inline QScrollPrepareEventPrivate()
+ : target(0)
+ {
+ }
+
+ QObject* target;
+ QPointF startPos;
+ QSizeF viewportSize;
+ QRectF contentPosRange;
+ QPointF contentPos;
+};
+
+class QScrollEventPrivate
+{
+public:
+ inline QScrollEventPrivate()
+ {
+ }
+
+ QPointF contentPos;
+ QPointF overshoot;
+ QScrollEvent::ScrollState state;
+};
+
+QT_END_NAMESPACE
+
+#endif // QEVENT_P_H
diff --git a/src/gui/guikernel/qeventdispatcher_glib_qpa.cpp b/src/gui/guikernel/qeventdispatcher_glib_qpa.cpp
new file mode 100644
index 0000000000..b601e89bd7
--- /dev/null
+++ b/src/gui/guikernel/qeventdispatcher_glib_qpa.cpp
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qeventdispatcher_glib_qpa_p.h"
+
+#include "qguiapplication.h"
+
+#include "qplatformdefs.h"
+
+#include <glib.h>
+#include "private/qguiapplication_p.h"
+
+#include <qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+struct GUserEventSource
+{
+ GSource source;
+ QPAEventDispatcherGlib *q;
+};
+
+static gboolean userEventSourcePrepare(GSource *s, gint *timeout)
+{
+ Q_UNUSED(s)
+ Q_UNUSED(timeout)
+
+ return QWindowSystemInterfacePrivate::windowSystemEventsQueued() > 0;
+}
+
+static gboolean userEventSourceCheck(GSource *source)
+{
+ return userEventSourcePrepare(source, 0);
+}
+
+static gboolean userEventSourceDispatch(GSource *s, GSourceFunc, gpointer)
+{
+ GUserEventSource * source = reinterpret_cast<GUserEventSource *>(s);
+
+ QWindowSystemInterfacePrivate::WindowSystemEvent * event;
+ while (QWindowSystemInterfacePrivate::windowSystemEventsQueued()) {
+ event = QWindowSystemInterfacePrivate::getWindowSystemEvent();
+ if (!event)
+ break;
+
+ // send through event filter
+ if (source->q->filterEvent(event)) {
+ delete event;
+ continue;
+ }
+ QGuiApplicationPrivate::processWindowSystemEvent(event);
+ delete event;
+ }
+
+ return true;
+}
+
+
+static GSourceFuncs userEventSourceFuncs = {
+ userEventSourcePrepare,
+ userEventSourceCheck,
+ userEventSourceDispatch,
+ NULL,
+ NULL,
+ NULL
+};
+
+QPAEventDispatcherGlibPrivate::QPAEventDispatcherGlibPrivate(GMainContext *context)
+ : QEventDispatcherGlibPrivate(context)
+{
+ userEventSource = reinterpret_cast<GUserEventSource *>(g_source_new(&userEventSourceFuncs,
+ sizeof(GUserEventSource)));
+ userEventSource->q = 0;
+ g_source_set_can_recurse(&userEventSource->source, true);
+ g_source_attach(&userEventSource->source, mainContext);
+}
+
+
+QPAEventDispatcherGlib::QPAEventDispatcherGlib(QObject *parent)
+ : QEventDispatcherGlib(*new QPAEventDispatcherGlibPrivate, parent)
+{
+ Q_D(QPAEventDispatcherGlib);
+ d->userEventSource->q = this;
+}
+
+QPAEventDispatcherGlib::~QPAEventDispatcherGlib()
+{
+ Q_D(QPAEventDispatcherGlib);
+
+ g_source_destroy(&d->userEventSource->source);
+ g_source_unref(&d->userEventSource->source);
+ d->userEventSource = 0;
+}
+
+bool QPAEventDispatcherGlib::processEvents(QEventLoop::ProcessEventsFlags flags)
+{
+ static bool init = false;
+ if (!init) {
+ if (QGuiApplicationPrivate::platformIntegration()->createEventLoopIntegration()) {
+ qWarning("Eventloop integration is not supported by the glib event dispatcher");
+ qWarning("Use the UNIX event dispatcher by defining environment variable QT_NO_GLIB=1");
+ }
+ init = true;
+ }
+ return QEventDispatcherGlib::processEvents(flags);
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qeventdispatcher_glib_qpa_p.h b/src/gui/guikernel/qeventdispatcher_glib_qpa_p.h
index 701f6735c4..701f6735c4 100644
--- a/src/gui/kernel/qeventdispatcher_glib_qpa_p.h
+++ b/src/gui/guikernel/qeventdispatcher_glib_qpa_p.h
diff --git a/src/gui/guikernel/qeventdispatcher_qpa.cpp b/src/gui/guikernel/qeventdispatcher_qpa.cpp
new file mode 100644
index 0000000000..690209a265
--- /dev/null
+++ b/src/gui/guikernel/qeventdispatcher_qpa.cpp
@@ -0,0 +1,334 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformdefs.h"
+#include "qcoreapplication.h"
+#include "qeventdispatcher_qpa_p.h"
+#include "private/qeventdispatcher_unix_p.h"
+#include "private/qguiapplication_p.h"
+#include "qplatformeventloopintegration_qpa.h"
+
+#include <QWindowSystemInterface>
+#include <QtCore/QElapsedTimer>
+#include <QtCore/QAtomicInt>
+#include <QtCore/QSemaphore>
+
+#include <QtCore/QDebug>
+
+#include <errno.h>
+
+QT_BEGIN_NAMESPACE
+
+QT_USE_NAMESPACE
+
+class Rendezvous
+{
+public:
+ void checkpoint()
+ {
+ if (state.testAndSetOrdered(0,1)) {
+ semaphore.acquire();
+ } else if (state.testAndSetAcquire(1,0)) {
+ semaphore.release();
+ } else {
+ qWarning("Barrier internal error");
+ }
+ }
+private:
+ QSemaphore semaphore;
+ QAtomicInt state;
+};
+
+class SelectWorker : public QThread
+{
+public:
+ SelectWorker(QEventDispatcherQPAPrivate *eventDispatcherPrivate)
+ : QThread(),
+ m_edPrivate(eventDispatcherPrivate),
+ m_retVal(0)
+ {
+ }
+
+ void setSelectValues(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds)
+ {
+ m_nfds = nfds;
+ m_readfds = readfds;
+ m_writefds = writefds;
+ m_exceptfds = exceptfds;
+
+
+ }
+
+ int retVal() const {
+ return m_retVal;
+ }
+
+protected:
+ void run();
+
+private:
+ QEventDispatcherQPAPrivate *m_edPrivate;
+ int m_retVal;
+
+ int m_nfds;
+ fd_set *m_readfds, *m_writefds, *m_exceptfds;
+};
+
+class QEventDispatcherQPAPrivate : public QEventDispatcherUNIXPrivate
+{
+ Q_DECLARE_PUBLIC(QEventDispatcherQPA)
+public:
+ QEventDispatcherQPAPrivate()
+ : eventLoopIntegration(0),
+ barrierBeforeBlocking(0),
+ barrierReturnValue(0),
+ selectReturnMutex(0),
+ selectWorkerNeedsSync(true),
+ selectWorkerHasResult(false),
+ m_integrationInitialised(false),
+ m_hasIntegration(false),
+ m_isEventLoopIntegrationRunning(false)
+ {
+
+ }
+
+ ~QEventDispatcherQPAPrivate()
+ {
+ delete selectWorker;
+ delete eventLoopIntegration;
+ delete barrierBeforeBlocking;
+ delete barrierReturnValue;
+ delete selectReturnMutex;
+ }
+
+ bool hasIntegration() const
+ {
+ if (!m_integrationInitialised) {
+ QEventDispatcherQPAPrivate *that = const_cast<QEventDispatcherQPAPrivate *>(this);
+ if (qApp && (qApp->thread() == QThread::currentThread())) { // guiThread
+ if (QGuiApplicationPrivate::platformIntegration()) {
+ that->eventLoopIntegration = QGuiApplicationPrivate::platformIntegration()->createEventLoopIntegration();
+ if (that->eventLoopIntegration) {
+ that->selectWorker = new SelectWorker(that);
+ that->barrierBeforeBlocking = new Rendezvous;
+ that->barrierReturnValue = new Rendezvous;
+ that->selectReturnMutex = new QMutex;
+ that->selectWorker->start();
+ that->m_hasIntegration = true;
+ if (!QElapsedTimer::isMonotonic())
+ qWarning("Having eventloop integration without monotonic timers can lead to undefined behaviour");
+ }
+ }
+ }
+ that->m_integrationInitialised = true;
+ }
+ return m_hasIntegration;
+ }
+
+ bool isEventLoopIntegrationRunning() const
+ {
+ return m_isEventLoopIntegrationRunning;
+ }
+
+ void runEventLoopIntegration()
+ {
+ if (qApp && (qApp->thread() == QThread::currentThread())) {
+ m_isEventLoopIntegrationRunning = true;
+ eventLoopIntegration->startEventLoop();
+ }
+ }
+
+ QPlatformEventLoopIntegration *eventLoopIntegration;
+ Rendezvous *barrierBeforeBlocking;
+ Rendezvous *barrierReturnValue;
+
+ QMutex *selectReturnMutex;
+ bool selectWorkerNeedsSync;
+ bool selectWorkerHasResult;
+
+ SelectWorker *selectWorker;
+private:
+ bool m_integrationInitialised;
+ bool m_hasIntegration;
+ bool m_isEventLoopIntegrationRunning;
+};
+
+QEventDispatcherQPA::QEventDispatcherQPA(QObject *parent)
+ : QEventDispatcherUNIX(*new QEventDispatcherQPAPrivate, parent)
+{ }
+
+QEventDispatcherQPA::~QEventDispatcherQPA()
+{ }
+
+bool QEventDispatcherQPA::processEvents(QEventLoop::ProcessEventsFlags flags)
+{
+ Q_D(QEventDispatcherQPA);
+
+ if (d->hasIntegration()) {
+ if (!d->isEventLoopIntegrationRunning()) {
+ d->runEventLoopIntegration();
+ }
+ if (d->threadData->quitNow) {
+ d->eventLoopIntegration->quitEventLoop();
+ return false;
+ }
+ }
+
+ int nevents = 0;
+
+ // handle gui and posted events
+ d->interrupt = false;
+ QCoreApplication::sendPostedEvents();
+
+ while (!d->interrupt) { // also flushes output buffer ###can be optimized
+ QWindowSystemInterfacePrivate::WindowSystemEvent *event;
+ if (!(flags & QEventLoop::ExcludeUserInputEvents)
+ && QWindowSystemInterfacePrivate::windowSystemEventsQueued() > 0) {
+ // process a pending user input event
+ event = QWindowSystemInterfacePrivate::getWindowSystemEvent();
+ if (!event)
+ break;
+ } else {
+ break;
+ }
+
+ if (filterEvent(event)) {
+ delete event;
+ continue;
+ }
+ nevents++;
+
+ QGuiApplicationPrivate::processWindowSystemEvent(event);
+ delete event;
+ }
+
+ if (!d->interrupt) {
+ if (QEventDispatcherUNIX::processEvents(flags)) {
+ QEventDispatcherUNIX::processEvents(flags);
+ return true;
+ }
+ }
+ return (nevents > 0);
+}
+
+bool QEventDispatcherQPA::hasPendingEvents()
+{
+ extern uint qGlobalPostedEventsCount(); // from qapplication.cpp
+ return qGlobalPostedEventsCount() || QWindowSystemInterfacePrivate::windowSystemEventsQueued();
+}
+
+void QEventDispatcherQPA::registerSocketNotifier(QSocketNotifier *notifier)
+{
+ Q_D(QEventDispatcherQPA);
+ QEventDispatcherUNIX::registerSocketNotifier(notifier);
+ if (d->hasIntegration())
+ wakeUp();
+
+}
+
+void QEventDispatcherQPA::unregisterSocketNotifier(QSocketNotifier *notifier)
+{
+ Q_D(QEventDispatcherQPA);
+ QEventDispatcherUNIX::unregisterSocketNotifier(notifier);
+ if (d->hasIntegration())
+ wakeUp();
+}
+
+void QEventDispatcherQPA::flush()
+{
+ if(qApp)
+ qApp->sendPostedEvents();
+}
+
+int QEventDispatcherQPA::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
+ timeval *timeout)
+{
+ Q_D(QEventDispatcherQPA);
+ int retVal = 0;
+ if (d->hasIntegration()) {
+ qint64 timeoutmsec = 0;
+ if (timeout)
+ timeoutmsec = timeout->tv_sec * 1000 + (timeout->tv_usec/1000);
+ d->selectReturnMutex->lock();
+ if (d->selectWorkerNeedsSync) {
+ if (d->selectWorkerHasResult) {
+ retVal = d->selectWorker->retVal();
+ d->selectWorkerHasResult = false;
+
+ d->selectReturnMutex->unlock();
+ d->barrierReturnValue->checkpoint();
+ d->eventLoopIntegration->setNextTimerEvent(0);
+ return retVal;
+ } else {
+ d->selectWorkerNeedsSync = false;
+ d->selectWorker->setSelectValues(nfds,readfds, writefds, exceptfds);
+ d->barrierBeforeBlocking->checkpoint();
+ }
+ }
+ d->selectReturnMutex->unlock();
+ d->eventLoopIntegration->setNextTimerEvent(timeoutmsec);
+ retVal = 0; //is 0 if select has not returned
+ } else {
+ retVal = QEventDispatcherUNIX::select(nfds, readfds, writefds, exceptfds, timeout);
+ }
+ return retVal;
+}
+
+
+void SelectWorker::run()
+{
+
+ while(true) {
+ m_retVal = 0;
+ m_edPrivate->barrierBeforeBlocking->checkpoint(); // wait for mainthread
+ int tmpRet = qt_safe_select(m_nfds,m_readfds,m_writefds,m_exceptfds,0);
+ m_edPrivate->selectReturnMutex->lock();
+ m_edPrivate->eventLoopIntegration->qtNeedsToProcessEvents();
+
+ m_edPrivate->selectWorkerNeedsSync = true;
+ m_edPrivate->selectWorkerHasResult = true;
+ m_retVal = tmpRet;
+
+ m_edPrivate->selectReturnMutex->unlock();
+ m_edPrivate->barrierReturnValue->checkpoint();
+ }
+}
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qeventdispatcher_qpa_p.h b/src/gui/guikernel/qeventdispatcher_qpa_p.h
index d4d2be1f38..d4d2be1f38 100644
--- a/src/gui/kernel/qeventdispatcher_qpa_p.h
+++ b/src/gui/guikernel/qeventdispatcher_qpa_p.h
diff --git a/src/gui/kernel/qgenericplugin_qpa.cpp b/src/gui/guikernel/qgenericplugin_qpa.cpp
index 43d6525bb6..43d6525bb6 100644
--- a/src/gui/kernel/qgenericplugin_qpa.cpp
+++ b/src/gui/guikernel/qgenericplugin_qpa.cpp
diff --git a/src/gui/kernel/qgenericplugin_qpa.h b/src/gui/guikernel/qgenericplugin_qpa.h
index e1792cd417..e1792cd417 100644
--- a/src/gui/kernel/qgenericplugin_qpa.h
+++ b/src/gui/guikernel/qgenericplugin_qpa.h
diff --git a/src/gui/guikernel/qgenericpluginfactory_qpa.cpp b/src/gui/guikernel/qgenericpluginfactory_qpa.cpp
new file mode 100644
index 0000000000..2f74747428
--- /dev/null
+++ b/src/gui/guikernel/qgenericpluginfactory_qpa.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgenericpluginfactory_qpa.h"
+
+#include "qguiapplication.h"
+#include "private/qfactoryloader_p.h"
+#include "qgenericplugin_qpa.h"
+#include "qdebug.h"
+
+QT_BEGIN_NAMESPACE
+
+#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
+#ifndef QT_NO_LIBRARY
+
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
+ (QGenericPluginFactoryInterface_iid,
+ QLatin1String("/generic"), Qt::CaseInsensitive))
+
+#endif //QT_NO_LIBRARY
+#endif //QT_MAKEDLL
+
+/*!
+ \class QGenericPluginFactory
+ \ingroup qpa
+
+ \brief The QGenericPluginFactory class creates window-system
+ related plugin drivers in Qt QPA.
+
+ Note that this class is only available in \l{Qt QPA}.
+
+
+ \sa QGenericPlugin
+*/
+
+/*!
+ Creates the driver specified by \a key, using the given \a specification.
+
+ Note that the keys are case-insensitive.
+
+ \sa keys()
+*/
+QObject *QGenericPluginFactory::create(const QString& key, const QString &specification)
+{
+ QString driver = key.toLower();
+
+#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
+#ifndef QT_NO_LIBRARY
+ if (QGenericPluginFactoryInterface *factory = qobject_cast<QGenericPluginFactoryInterface*>(loader()->instance(driver)))
+ return factory->create(driver, specification);
+#endif
+#endif
+ return 0;
+}
+
+/*!
+ Returns the list of valid keys, i.e. the available mouse drivers.
+
+ \sa create()
+*/
+QStringList QGenericPluginFactory::keys()
+{
+ QStringList list;
+
+#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
+#ifndef QT_NO_LIBRARY
+ QStringList plugins = loader()->keys();
+ for (int i = 0; i < plugins.size(); ++i) {
+ if (!list.contains(plugins.at(i)))
+ list += plugins.at(i);
+ }
+#endif //QT_NO_LIBRARY
+#endif //QT_MAKEDLL
+ return list;
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qgenericpluginfactory_qpa.h b/src/gui/guikernel/qgenericpluginfactory_qpa.h
index 59eac386ed..59eac386ed 100644
--- a/src/gui/kernel/qgenericpluginfactory_qpa.h
+++ b/src/gui/guikernel/qgenericpluginfactory_qpa.h
diff --git a/src/gui/guikernel/qguiapplication.cpp b/src/gui/guikernel/qguiapplication.cpp
new file mode 100644
index 0000000000..86fb7f5e1d
--- /dev/null
+++ b/src/gui/guikernel/qguiapplication.cpp
@@ -0,0 +1,1059 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qguiapplication.h"
+
+#include "private/qguiapplication_p.h"
+#include "private/qplatformintegrationfactory_qpa_p.h"
+#include "private/qevent_p.h"
+
+#if !defined(QT_NO_GLIB)
+#include "qeventdispatcher_glib_qpa_p.h"
+#endif
+#include "qeventdispatcher_qpa_p.h"
+
+#include <QtCore/QAbstractEventDispatcher>
+#include <QtCore/private/qcoreapplication_p.h>
+#include <QtCore/private/qabstracteventdispatcher_p.h>
+#include <QtCore/qmutex.h>
+#include <QtDebug>
+#include <qpalette.h>
+
+#include <QtGui/QPlatformIntegration>
+#include <QtGui/QGenericPluginFactory>
+
+#include <QWindowSystemInterface>
+#include "private/qwindowsysteminterface_qpa_p.h"
+#include "private/qwindow_p.h"
+#include "private/qkeymapper_p.h"
+#include "private/qcursor_p.h"
+
+#include <QtGui/QPixmap>
+
+#ifndef QT_NO_CLIPBOARD
+#include <QtGui/QClipboard>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+Q_GUI_EXPORT bool qt_is_gui_used = true;
+
+Qt::MouseButtons QGuiApplicationPrivate::mouse_buttons = Qt::NoButton;
+Qt::KeyboardModifiers QGuiApplicationPrivate::modifier_buttons = Qt::NoModifier;
+
+int QGuiApplicationPrivate::keyboard_input_time = 0;
+int QGuiApplicationPrivate::mouse_double_click_time = 0;
+
+QPlatformIntegration *QGuiApplicationPrivate::platform_integration = 0;
+
+bool QGuiApplicationPrivate::app_do_modal = false;
+
+QPalette *QGuiApplicationPrivate::app_pal = 0; // default application palette
+
+int qt_last_x = 0;
+int qt_last_y = 0;
+
+Qt::MouseButtons QGuiApplicationPrivate::buttons = Qt::NoButton;
+ulong QGuiApplicationPrivate::mousePressTime = 0;
+Qt::MouseButton QGuiApplicationPrivate::mousePressButton = Qt::NoButton;
+int QGuiApplicationPrivate::mousePressX = 0;
+int QGuiApplicationPrivate::mousePressY = 0;
+int QGuiApplicationPrivate::mouse_double_click_distance = 5;
+
+static Qt::LayoutDirection layout_direction = Qt::LeftToRight;
+static bool force_reverse = false;
+
+QGuiApplicationPrivate *QGuiApplicationPrivate::self = 0;
+
+#ifndef QT_NO_CLIPBOARD
+QClipboard *QGuiApplicationPrivate::qt_clipboard = 0;
+#endif
+
+QWindowList QGuiApplicationPrivate::window_list;
+
+Q_GLOBAL_STATIC(QMutex, applicationFontMutex)
+QFont *QGuiApplicationPrivate::app_font = 0;
+
+extern int qRegisterGuiVariant();
+extern int qUnregisterGuiVariant();
+extern void qInitDrawhelperAsm();
+extern void qInitImageConversions();
+
+static bool qt_detectRTLLanguage()
+{
+ return force_reverse ^
+ (QCoreApplication::tr("QT_LAYOUT_DIRECTION",
+ "Translate this string to the string 'LTR' in left-to-right"
+ " languages or to 'RTL' in right-to-left languages (such as Hebrew"
+ " and Arabic) to get proper widget layout.") == QLatin1String("RTL"));
+}
+
+
+QGuiApplication::QGuiApplication(int &argc, char **argv, int flags)
+ : QCoreApplication(*new QGuiApplicationPrivate(argc, argv, flags))
+{
+ d_func()->init();
+
+ QCoreApplicationPrivate::eventDispatcher->startingUp();
+}
+
+QGuiApplication::QGuiApplication(QGuiApplicationPrivate &p)
+ : QCoreApplication(p)
+{
+ d_func()->init();
+}
+
+QGuiApplication::~QGuiApplication()
+{
+ Q_D(QGuiApplication);
+ // flush clipboard contents
+ if (QGuiApplicationPrivate::qt_clipboard) {
+ QEvent event(QEvent::Clipboard);
+ QGuiApplication::sendEvent(QGuiApplicationPrivate::qt_clipboard, &event);
+ }
+
+ d->eventDispatcher->closingDown();
+ d->eventDispatcher = 0;
+
+ delete QGuiApplicationPrivate::qt_clipboard;
+ QGuiApplicationPrivate::qt_clipboard = 0;
+
+ delete QGuiApplicationPrivate::app_pal;
+ QGuiApplicationPrivate::app_pal = 0;
+
+ qUnregisterGuiVariant();
+
+#ifndef QT_NO_CURSOR
+ d->cursor_list.clear();
+#endif
+}
+
+QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags)
+ : QCoreApplicationPrivate(argc, argv, flags)
+{
+ self = this;
+}
+
+QWindowList QGuiApplication::topLevelWindows()
+{
+ return QGuiApplicationPrivate::window_list;
+}
+
+static void init_platform(const QString &name, const QString &platformPluginPath)
+{
+ QGuiApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, platformPluginPath);
+ if (!QGuiApplicationPrivate::platform_integration) {
+ QStringList keys = QPlatformIntegrationFactory::keys(platformPluginPath);
+ QString fatalMessage =
+ QString::fromLatin1("Failed to load platform plugin \"%1\". Available platforms are: \n").arg(name);
+ foreach(QString key, keys) {
+ fatalMessage.append(key + QString::fromLatin1("\n"));
+ }
+ qFatal("%s", fatalMessage.toLocal8Bit().constData());
+
+ }
+
+}
+
+static void init_plugins(const QList<QByteArray> pluginList)
+{
+ for (int i = 0; i < pluginList.count(); ++i) {
+ QByteArray pluginSpec = pluginList.at(i);
+ qDebug() << "init_plugins" << i << pluginSpec;
+ int colonPos = pluginSpec.indexOf(':');
+ QObject *plugin;
+ if (colonPos < 0)
+ plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec), QString());
+ else
+ plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec.mid(0, colonPos)),
+ QLatin1String(pluginSpec.mid(colonPos+1)));
+ qDebug() << " created" << plugin;
+ }
+}
+
+void QGuiApplicationPrivate::createEventDispatcher()
+{
+ Q_Q(QGuiApplication);
+#if !defined(QT_NO_GLIB)
+ if (qgetenv("QT_NO_GLIB").isEmpty() && QEventDispatcherGlib::versionSupported())
+ eventDispatcher = new QPAEventDispatcherGlib(q);
+ else
+#endif
+ eventDispatcher = new QEventDispatcherQPA(q);
+}
+
+void QGuiApplicationPrivate::init()
+{
+ QList<QByteArray> pluginList;
+ QString platformPluginPath = QLatin1String(qgetenv("QT_QPA_PLATFORM_PLUGIN_PATH"));
+ QByteArray platformName;
+#ifdef QT_QPA_DEFAULT_PLATFORM_NAME
+ platformName = QT_QPA_DEFAULT_PLATFORM_NAME;
+#endif
+ QByteArray platformNameEnv = qgetenv("QT_QPA_PLATFORM");
+ if (!platformNameEnv.isEmpty()) {
+ platformName = platformNameEnv;
+ }
+
+ // Get command line params
+
+ int j = argc ? 1 : 0;
+ for (int i=1; i<argc; i++) {
+ if (argv[i] && *argv[i] != '-') {
+ argv[j++] = argv[i];
+ continue;
+ }
+ QByteArray arg = argv[i];
+ if (arg == "-platformpluginpath") {
+ if (++i < argc)
+ platformPluginPath = QLatin1String(argv[i]);
+ } else if (arg == "-platform") {
+ if (++i < argc)
+ platformName = argv[i];
+ } else if (arg == "-plugin") {
+ if (++i < argc)
+ pluginList << argv[i];
+ } else if (arg == "-reverse") {
+ force_reverse = true;
+ QGuiApplication::setLayoutDirection(Qt::RightToLeft);
+ } else {
+ argv[j++] = argv[i];
+ }
+ }
+
+ argv[j] = 0;
+ argc = j;
+
+#if 0
+ QByteArray pluginEnv = qgetenv("QT_QPA_PLUGINS");
+ if (!pluginEnv.isEmpty()) {
+ pluginList.append(pluginEnv.split(';'));
+ }
+#endif
+
+ init_platform(QLatin1String(platformName), platformPluginPath);
+ init_plugins(pluginList);
+
+ // Set up which span functions should be used in raster engine...
+ qInitDrawhelperAsm();
+ // and QImage conversion functions
+ qInitImageConversions();
+
+ QFont::initialize();
+
+#ifndef QT_NO_CURSOR
+ QCursorData::initialize();
+#endif
+
+ // trigger registering of QVariant's GUI types
+ qRegisterGuiVariant();
+
+ is_app_running = true;
+}
+
+QGuiApplicationPrivate::~QGuiApplicationPrivate()
+{
+ delete platform_integration;
+ platform_integration = 0;
+
+ is_app_closing = true;
+ is_app_running = false;
+
+ QFont::cleanup();
+
+#ifndef QT_NO_CURSOR
+ QCursorData::cleanup();
+#endif
+
+ layout_direction = Qt::LeftToRight;
+}
+
+#if 0
+#ifndef QT_NO_CURSOR
+QCursor *overrideCursor();
+void setOverrideCursor(const QCursor &);
+void changeOverrideCursor(const QCursor &);
+void restoreOverrideCursor();
+#endif
+
+static QFont font();
+static QFont font(const QWidget*);
+static QFont font(const char *className);
+static void setFont(const QFont &, const char* className = 0);
+static QFontMetrics fontMetrics();
+
+#ifndef QT_NO_CLIPBOARD
+static QClipboard *clipboard();
+#endif
+#endif
+
+Qt::KeyboardModifiers QGuiApplication::keyboardModifiers()
+{
+ return QGuiApplicationPrivate::modifier_buttons;
+}
+
+Qt::MouseButtons QGuiApplication::mouseButtons()
+{
+ return QGuiApplicationPrivate::mouse_buttons;
+}
+
+void QGuiApplication::setDoubleClickInterval(int ms)
+{
+ QGuiApplicationPrivate::mouse_double_click_time = ms;
+}
+
+int QGuiApplication::doubleClickInterval()
+{
+ return QGuiApplicationPrivate::mouse_double_click_time;
+}
+
+void QGuiApplication::setKeyboardInputInterval(int ms)
+{
+ QGuiApplicationPrivate::keyboard_input_time = ms;
+}
+
+int QGuiApplication::keyboardInputInterval()
+{
+ return QGuiApplicationPrivate::keyboard_input_time;
+}
+
+QPlatformNativeInterface *QGuiApplication::platformNativeInterface()
+{
+ QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration();
+ return pi->nativeInterface();
+}
+
+int QGuiApplication::exec()
+{
+ return QCoreApplication::exec();
+}
+
+bool QGuiApplication::notify(QObject *object, QEvent *event)
+{
+ return QCoreApplication::notify(object, event);
+}
+
+bool QGuiApplication::event(QEvent *e)
+{
+ if(e->type() == QEvent::LanguageChange) {
+ setLayoutDirection(qt_detectRTLLanguage()?Qt::RightToLeft:Qt::LeftToRight);
+ }
+ return QCoreApplication::event(e);
+}
+
+bool QGuiApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventList *postedEvents)
+{
+ return QCoreApplication::compressEvent(event, receiver, postedEvents);
+}
+
+void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e)
+{
+ switch(e->type) {
+ case QWindowSystemInterfacePrivate::Mouse:
+ QGuiApplicationPrivate::processMouseEvent(static_cast<QWindowSystemInterfacePrivate::MouseEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::Wheel:
+ QGuiApplicationPrivate::processWheelEvent(static_cast<QWindowSystemInterfacePrivate::WheelEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::Key:
+ QGuiApplicationPrivate::processKeyEvent(static_cast<QWindowSystemInterfacePrivate::KeyEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::Touch:
+ QGuiApplicationPrivate::processTouchEvent(static_cast<QWindowSystemInterfacePrivate::TouchEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::GeometryChange:
+ QGuiApplicationPrivate::processGeometryChangeEvent(static_cast<QWindowSystemInterfacePrivate::GeometryChangeEvent*>(e));
+ break;
+ case QWindowSystemInterfacePrivate::Enter:
+ QGuiApplicationPrivate::processEnterEvent(static_cast<QWindowSystemInterfacePrivate::EnterEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::Leave:
+ QGuiApplicationPrivate::processLeaveEvent(static_cast<QWindowSystemInterfacePrivate::LeaveEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::ActivatedWindow:
+ QGuiApplicationPrivate::processActivatedEvent(static_cast<QWindowSystemInterfacePrivate::ActivatedWindowEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::Close:
+ QGuiApplicationPrivate::processCloseEvent(
+ static_cast<QWindowSystemInterfacePrivate::CloseEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::ScreenCountChange:
+ QGuiApplicationPrivate::reportScreenCount(
+ static_cast<QWindowSystemInterfacePrivate::ScreenCountEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::ScreenGeometry:
+ QGuiApplicationPrivate::reportGeometryChange(
+ static_cast<QWindowSystemInterfacePrivate::ScreenGeometryEvent *>(e));
+ break;
+ case QWindowSystemInterfacePrivate::ScreenAvailableGeometry:
+ QGuiApplicationPrivate::reportAvailableGeometryChange(
+ static_cast<QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *>(e));
+ break;
+ default:
+ qWarning() << "Unknown user input event type:" << e->type;
+ break;
+ }
+}
+
+void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e)
+{
+ QEvent::Type type;
+ // move first
+ Qt::MouseButtons stateChange = e->buttons ^ buttons;
+ if (e->globalPos != QPoint(qt_last_x, qt_last_y) && (stateChange != Qt::NoButton)) {
+ QWindowSystemInterfacePrivate::MouseEvent * newMouseEvent =
+ new QWindowSystemInterfacePrivate::MouseEvent(e->window.data(), e->timestamp, e->localPos, e->globalPos, e->buttons);
+ QWindowSystemInterfacePrivate::windowSystemEventQueue.prepend(newMouseEvent); // just in case the move triggers a new event loop
+ stateChange = Qt::NoButton;
+ }
+
+ QWindow *window = e->window.data();
+
+ QPoint localPoint = e->localPos;
+ QPoint globalPoint = e->globalPos;
+
+ Qt::MouseButton button = Qt::NoButton;
+
+ if (qt_last_x != globalPoint.x() || qt_last_y != globalPoint.y()) {
+ type = QEvent::MouseMove;
+ qt_last_x = globalPoint.x();
+ qt_last_y = globalPoint.y();
+ if (qAbs(globalPoint.x() - mousePressX) > mouse_double_click_distance||
+ qAbs(globalPoint.y() - mousePressY) > mouse_double_click_distance)
+ mousePressButton = Qt::NoButton;
+ }
+ else { // check to see if a new button has been pressed/released
+ for (int check = Qt::LeftButton;
+ check <= Qt::XButton2;
+ check = check << 1) {
+ if (check & stateChange) {
+ button = Qt::MouseButton(check);
+ break;
+ }
+ }
+ if (button == Qt::NoButton) {
+ // Ignore mouse events that don't change the current state
+ return;
+ }
+ buttons = e->buttons;
+ if (button & e->buttons) {
+ if ((e->timestamp - mousePressTime) < static_cast<ulong>(QGuiApplication::doubleClickInterval()) && button == mousePressButton) {
+ type = QEvent::MouseButtonDblClick;
+ mousePressButton = Qt::NoButton;
+ }
+ else {
+ type = QEvent::MouseButtonPress;
+ mousePressTime = e->timestamp;
+ mousePressButton = button;
+ mousePressX = qt_last_x;
+ mousePressY = qt_last_y;
+ }
+ }
+ else
+ type = QEvent::MouseButtonRelease;
+ }
+
+
+ if (window) {
+ QMouseEvent ev(type, localPoint, globalPoint, button, buttons, QGuiApplication::keyboardModifiers());
+ QGuiApplication::sendSpontaneousEvent(window, &ev);
+ return;
+ }
+}
+
+
+//### there's a lot of duplicated logic here -- refactoring required!
+
+void QGuiApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e)
+{
+ QPoint globalPoint = e->globalPos;
+
+ qt_last_x = globalPoint.x();
+ qt_last_y = globalPoint.y();
+
+ QWindow *window = e->window.data();
+
+ if (window) {
+ QWheelEvent ev(e->localPos, e->globalPos, e->delta, buttons, QGuiApplication::keyboardModifiers(),
+ e->orient);
+ QGuiApplication::sendSpontaneousEvent(window, &ev);
+ return;
+ }
+}
+
+
+
+// Remember, Qt convention is: keyboard state is state *before*
+
+void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e)
+{
+ QWindow *window = e->window.data();
+ if (!window)
+ return;
+
+ QObject *target = window;
+
+ if (e->nativeScanCode || e->nativeVirtualKey || e->nativeModifiers) {
+ QKeyEventEx ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount,
+ e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers);
+ QGuiApplication::sendSpontaneousEvent(target, &ev);
+ } else {
+ QKeyEvent ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount);
+ QGuiApplication::sendSpontaneousEvent(target, &ev);
+ }
+}
+
+void QGuiApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e)
+{
+ QEvent event(QEvent::Enter);
+ QCoreApplication::sendSpontaneousEvent(e->enter.data(), &event);
+}
+
+void QGuiApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e)
+{
+ QEvent event(QEvent::Leave);
+ QCoreApplication::sendSpontaneousEvent(e->leave.data(), &event);
+}
+
+void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *)
+{
+// QGuiApplication::setActiveWindow(e->activated.data());
+}
+
+void QGuiApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e)
+{
+ if (e->tlw.isNull())
+ return;
+
+ QWindow *window = e->tlw.data();
+ if (!window)
+ return;
+
+ QRect newRect = e->newGeometry;
+ QRect cr = window->geometry();
+
+ bool isResize = cr.size() != newRect.size();
+ bool isMove = cr.topLeft() != newRect.topLeft();
+
+ window->d_func()->geometry = newRect;
+
+ if (isResize) {
+ QResizeEvent e(newRect.size(), cr.size());
+ QGuiApplication::sendSpontaneousEvent(window, &e);
+ }
+
+ if (isMove) {
+ //### frame geometry
+ QMoveEvent e(newRect.topLeft(), cr.topLeft());
+ QGuiApplication::sendSpontaneousEvent(window, &e);
+ }
+}
+
+void QGuiApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e)
+{
+ if (e->window.isNull())
+ return;
+
+ QCloseEvent event;
+ QGuiApplication::sendSpontaneousEvent(e->window.data(), &event);
+}
+
+void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *)
+{
+// translateRawTouchEvent(e->widget.data(), e->devType, e->points);
+}
+
+void QGuiApplicationPrivate::reportScreenCount(QWindowSystemInterfacePrivate::ScreenCountEvent *)
+{
+ // This operation only makes sense after the QGuiApplication constructor runs
+ if (QCoreApplication::startingUp())
+ return;
+
+ //QGuiApplication::desktop()->d_func()->updateScreenList();
+ // signal anything listening for creation or deletion of screens
+ //QDesktopWidget *desktop = QGuiApplication::desktop();
+ //emit desktop->screenCountChanged(e->count);
+}
+
+void QGuiApplicationPrivate::reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *)
+{
+ // This operation only makes sense after the QGuiApplication constructor runs
+ if (QCoreApplication::startingUp())
+ return;
+}
+
+void QGuiApplicationPrivate::reportAvailableGeometryChange(
+ QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *)
+{
+ // This operation only makes sense after the QGuiApplication constructor runs
+ if (QCoreApplication::startingUp())
+ return;
+}
+
+#ifndef QT_NO_CLIPBOARD
+QClipboard * QGuiApplication::clipboard()
+{
+ if (QGuiApplicationPrivate::qt_clipboard == 0) {
+ if (!qApp) {
+ qWarning("QGuiApplication: Must construct a QGuiApplication before accessing a QClipboard");
+ return 0;
+ }
+ QGuiApplicationPrivate::qt_clipboard = new QClipboard(0);
+ }
+ return QGuiApplicationPrivate::qt_clipboard;
+}
+#endif
+
+/*!
+ Returns the application palette.
+
+ \sa setPalette(), QWidget::palette()
+*/
+QPalette QGuiApplication::palette()
+{
+ if (!QGuiApplicationPrivate::app_pal)
+ QGuiApplicationPrivate::app_pal = new QPalette(Qt::black);
+ return *QGuiApplicationPrivate::app_pal;
+}
+
+QFont QGuiApplication::font()
+{
+ QMutexLocker locker(applicationFontMutex());
+ if (!QGuiApplicationPrivate::app_font)
+ QGuiApplicationPrivate::app_font = new QFont(QLatin1String("Helvetica"));
+ return *QGuiApplicationPrivate::app_font;
+}
+
+void QGuiApplication::setFont(const QFont &font)
+{
+ QMutexLocker locker(applicationFontMutex());
+ if (!QGuiApplicationPrivate::app_font)
+ QGuiApplicationPrivate::app_font = new QFont(font);
+ else
+ *QGuiApplicationPrivate::app_font = font;
+}
+
+/*!
+ \fn bool QGuiApplication::isRightToLeft()
+
+ Returns true if the application's layout direction is
+ Qt::RightToLeft; otherwise returns false.
+
+ \sa layoutDirection(), isLeftToRight()
+*/
+
+/*!
+ \fn bool QGuiApplication::isLeftToRight()
+
+ Returns true if the application's layout direction is
+ Qt::LeftToRight; otherwise returns false.
+
+ \sa layoutDirection(), isRightToLeft()
+*/
+
+void QGuiApplicationPrivate::notifyLayoutDirectionChange()
+{
+}
+
+/*!
+ \property QGuiApplication::layoutDirection
+ \brief the default layout direction for this application
+
+ On system start-up, the default layout direction depends on the
+ application's language.
+
+ \sa QWidget::layoutDirection, isLeftToRight(), isRightToLeft()
+ */
+
+void QGuiApplication::setLayoutDirection(Qt::LayoutDirection direction)
+{
+ if (layout_direction == direction || direction == Qt::LayoutDirectionAuto)
+ return;
+
+ layout_direction = direction;
+
+ QGuiApplicationPrivate::self->notifyLayoutDirectionChange();
+}
+
+Qt::LayoutDirection QGuiApplication::layoutDirection()
+{
+ return layout_direction;
+}
+
+/*!
+ \fn QCursor *QGuiApplication::overrideCursor()
+
+ Returns the active application override cursor.
+
+ This function returns 0 if no application cursor has been defined (i.e. the
+ internal cursor stack is empty).
+
+ \sa setOverrideCursor(), restoreOverrideCursor()
+*/
+#ifndef QT_NO_CURSOR
+QCursor *QGuiApplication::overrideCursor()
+{
+ return qGuiApp->d_func()->cursor_list.isEmpty() ? 0 : &qGuiApp->d_func()->cursor_list.first();
+}
+
+/*!
+ Changes the currently active application override cursor to \a cursor.
+
+ This function has no effect if setOverrideCursor() was not called.
+
+ \sa setOverrideCursor(), overrideCursor(), restoreOverrideCursor(),
+ QWidget::setCursor()
+ */
+void QGuiApplication::changeOverrideCursor(const QCursor &cursor)
+{
+ if (qGuiApp->d_func()->cursor_list.isEmpty())
+ return;
+ qGuiApp->d_func()->cursor_list.removeFirst();
+ setOverrideCursor(cursor);
+}
+#endif
+
+/*!
+ \fn void QGuiApplication::setOverrideCursor(const QCursor &cursor, bool replace)
+
+ Use changeOverrideCursor(\a cursor) (if \a replace is true) or
+ setOverrideCursor(\a cursor) (if \a replace is false).
+*/
+
+#ifndef QT_NO_CURSOR
+void QGuiApplication::setOverrideCursor(const QCursor &cursor)
+{
+ qGuiApp->d_func()->cursor_list.prepend(cursor);
+}
+
+void QGuiApplication::restoreOverrideCursor()
+{
+ if (qGuiApp->d_func()->cursor_list.isEmpty())
+ return;
+ qGuiApp->d_func()->cursor_list.removeFirst();
+}
+#endif// QT_NO_CURSOR
+
+
+// Returns the current platform used by keyBindings
+uint QGuiApplicationPrivate::currentKeyPlatform()
+{
+ uint platform = KB_Win;
+#ifdef Q_WS_MAC
+ platform = KB_Mac;
+#elif defined Q_WS_X11
+ platform = KB_X11;
+ // ## TODO: detect these
+#if 0
+ if (X11->desktopEnvironment == DE_KDE)
+ platform |= KB_KDE;
+ if (X11->desktopEnvironment == DE_GNOME)
+ platform |= KB_Gnome;
+ if (X11->desktopEnvironment == DE_CDE)
+ platform |= KB_CDE;
+#endif
+#endif
+ return platform;
+}
+
+/*!
+ \since 4.2
+
+ Returns the current keyboard input locale.
+*/
+QLocale QGuiApplication::keyboardInputLocale()
+{
+ if (!QGuiApplicationPrivate::checkInstance("keyboardInputLocale"))
+ return QLocale::c();
+ return qt_keymapper_private()->keyboardInputLocale;
+}
+
+/*!
+ \since 4.2
+
+ Returns the current keyboard input direction.
+*/
+Qt::LayoutDirection QGuiApplication::keyboardInputDirection()
+{
+ if (!QGuiApplicationPrivate::checkInstance("keyboardInputDirection"))
+ return Qt::LeftToRight;
+ return qt_keymapper_private()->keyboardInputDirection;
+}
+
+/*!
+ \since 4.5
+ \fn void QGuiApplication::fontDatabaseChanged()
+
+ This signal is emitted when application fonts are loaded or removed.
+
+ \sa QFontDatabase::addApplicationFont(),
+ QFontDatabase::addApplicationFontFromData(),
+ QFontDatabase::removeAllApplicationFonts(),
+ QFontDatabase::removeApplicationFont()
+*/
+
+// These pixmaps approximate the images in the Windows User Interface Guidelines.
+
+// XPM
+
+static const char * const move_xpm[] = {
+"11 20 3 1",
+". c None",
+#if defined(Q_WS_WIN)
+"a c #000000",
+"X c #FFFFFF", // Windows cursor is traditionally white
+#else
+"a c #FFFFFF",
+"X c #000000", // X11 cursor is traditionally black
+#endif
+"aa.........",
+"aXa........",
+"aXXa.......",
+"aXXXa......",
+"aXXXXa.....",
+"aXXXXXa....",
+"aXXXXXXa...",
+"aXXXXXXXa..",
+"aXXXXXXXXa.",
+"aXXXXXXXXXa",
+"aXXXXXXaaaa",
+"aXXXaXXa...",
+"aXXaaXXa...",
+"aXa..aXXa..",
+"aa...aXXa..",
+"a.....aXXa.",
+"......aXXa.",
+".......aXXa",
+".......aXXa",
+"........aa."};
+
+#ifdef Q_WS_WIN
+/* XPM */
+static const char * const ignore_xpm[] = {
+"24 30 3 1",
+". c None",
+"a c #000000",
+"X c #FFFFFF",
+"aa......................",
+"aXa.....................",
+"aXXa....................",
+"aXXXa...................",
+"aXXXXa..................",
+"aXXXXXa.................",
+"aXXXXXXa................",
+"aXXXXXXXa...............",
+"aXXXXXXXXa..............",
+"aXXXXXXXXXa.............",
+"aXXXXXXaaaa.............",
+"aXXXaXXa................",
+"aXXaaXXa................",
+"aXa..aXXa...............",
+"aa...aXXa...............",
+"a.....aXXa..............",
+"......aXXa.....XXXX.....",
+".......aXXa..XXaaaaXX...",
+".......aXXa.XaaaaaaaaX..",
+"........aa.XaaaXXXXaaaX.",
+"...........XaaaaX..XaaX.",
+"..........XaaXaaaX..XaaX",
+"..........XaaXXaaaX.XaaX",
+"..........XaaX.XaaaXXaaX",
+"..........XaaX..XaaaXaaX",
+"...........XaaX..XaaaaX.",
+"...........XaaaXXXXaaaX.",
+"............XaaaaaaaaX..",
+".............XXaaaaXX...",
+"...............XXXX....."};
+#endif
+
+/* XPM */
+static const char * const copy_xpm[] = {
+"24 30 3 1",
+". c None",
+"a c #000000",
+"X c #FFFFFF",
+#if defined(Q_WS_WIN) // Windows cursor is traditionally white
+"aa......................",
+"aXa.....................",
+"aXXa....................",
+"aXXXa...................",
+"aXXXXa..................",
+"aXXXXXa.................",
+"aXXXXXXa................",
+"aXXXXXXXa...............",
+"aXXXXXXXXa..............",
+"aXXXXXXXXXa.............",
+"aXXXXXXaaaa.............",
+"aXXXaXXa................",
+"aXXaaXXa................",
+"aXa..aXXa...............",
+"aa...aXXa...............",
+"a.....aXXa..............",
+"......aXXa..............",
+".......aXXa.............",
+".......aXXa.............",
+"........aa...aaaaaaaaaaa",
+#else
+"XX......................",
+"XaX.....................",
+"XaaX....................",
+"XaaaX...................",
+"XaaaaX..................",
+"XaaaaaX.................",
+"XaaaaaaX................",
+"XaaaaaaaX...............",
+"XaaaaaaaaX..............",
+"XaaaaaaaaaX.............",
+"XaaaaaaXXXX.............",
+"XaaaXaaX................",
+"XaaXXaaX................",
+"XaX..XaaX...............",
+"XX...XaaX...............",
+"X.....XaaX..............",
+"......XaaX..............",
+".......XaaX.............",
+".......XaaX.............",
+"........XX...aaaaaaaaaaa",
+#endif
+".............aXXXXXXXXXa",
+".............aXXXXXXXXXa",
+".............aXXXXaXXXXa",
+".............aXXXXaXXXXa",
+".............aXXaaaaaXXa",
+".............aXXXXaXXXXa",
+".............aXXXXaXXXXa",
+".............aXXXXXXXXXa",
+".............aXXXXXXXXXa",
+".............aaaaaaaaaaa"};
+
+/* XPM */
+static const char * const link_xpm[] = {
+"24 30 3 1",
+". c None",
+"a c #000000",
+"X c #FFFFFF",
+#if defined(Q_WS_WIN) // Windows cursor is traditionally white
+"aa......................",
+"aXa.....................",
+"aXXa....................",
+"aXXXa...................",
+"aXXXXa..................",
+"aXXXXXa.................",
+"aXXXXXXa................",
+"aXXXXXXXa...............",
+"aXXXXXXXXa..............",
+"aXXXXXXXXXa.............",
+"aXXXXXXaaaa.............",
+"aXXXaXXa................",
+"aXXaaXXa................",
+"aXa..aXXa...............",
+"aa...aXXa...............",
+"a.....aXXa..............",
+"......aXXa..............",
+".......aXXa.............",
+".......aXXa.............",
+"........aa...aaaaaaaaaaa",
+#else
+"XX......................",
+"XaX.....................",
+"XaaX....................",
+"XaaaX...................",
+"XaaaaX..................",
+"XaaaaaX.................",
+"XaaaaaaX................",
+"XaaaaaaaX...............",
+"XaaaaaaaaX..............",
+"XaaaaaaaaaX.............",
+"XaaaaaaXXXX.............",
+"XaaaXaaX................",
+"XaaXXaaX................",
+"XaX..XaaX...............",
+"XX...XaaX...............",
+"X.....XaaX..............",
+"......XaaX..............",
+".......XaaX.............",
+".......XaaX.............",
+"........XX...aaaaaaaaaaa",
+#endif
+".............aXXXXXXXXXa",
+".............aXXXaaaaXXa",
+".............aXXXXaaaXXa",
+".............aXXXaaaaXXa",
+".............aXXaaaXaXXa",
+".............aXXaaXXXXXa",
+".............aXXaXXXXXXa",
+".............aXXXaXXXXXa",
+".............aXXXXXXXXXa",
+".............aaaaaaaaaaa"};
+
+QPixmap QGuiApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape)
+{
+#if defined(Q_WS_X11) || defined(Q_WS_WIN)
+ if (!move_cursor) {
+ move_cursor = new QPixmap((const char **)move_xpm);
+ copy_cursor = new QPixmap((const char **)copy_xpm);
+ link_cursor = new QPixmap((const char **)link_xpm);
+#ifdef Q_WS_WIN
+ ignore_cursor = new QPixmap((const char **)ignore_xpm);
+#endif
+ }
+
+ switch (cshape) {
+ case Qt::DragMoveCursor:
+ return *move_cursor;
+ case Qt::DragCopyCursor:
+ return *copy_cursor;
+ case Qt::DragLinkCursor:
+ return *link_cursor;
+#ifdef Q_WS_WIN
+ case Qt::ForbiddenCursor:
+ return *ignore_cursor;
+#endif
+ default:
+ break;
+ }
+#else
+ Q_UNUSED(cshape);
+#endif
+ return QPixmap();
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/guikernel/qguiapplication.h b/src/gui/guikernel/qguiapplication.h
new file mode 100644
index 0000000000..1b2484519c
--- /dev/null
+++ b/src/gui/guikernel/qguiapplication.h
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGUIAPPLICATION_QPA_H
+#define QGUIAPPLICATION_QPA_H
+
+#include <QtCore/qcoreapplication.h>
+#include <QtGui/qwindowdefs.h>
+#include <QtCore/qlocale.h>
+#include <QtCore/qpoint.h>
+#include <QtCore/qsize.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QGuiApplicationPrivate;
+class QPlatformNativeInterface;
+class QPalette;
+
+#if defined(qApp)
+#undef qApp
+#endif
+#define qApp (static_cast<QGuiApplication *>(QCoreApplication::instance()))
+
+#if defined(qGuiApp)
+#undef qGuiApp
+#endif
+#define qGuiApp (static_cast<QGuiApplication *>(QCoreApplication::instance()))
+
+class Q_GUI_EXPORT QGuiApplication : public QCoreApplication
+{
+ Q_OBJECT
+ Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection)
+ Q_PROPERTY(int doubleClickInterval READ doubleClickInterval WRITE setDoubleClickInterval)
+ Q_PROPERTY(int keyboardInputInterval READ keyboardInputInterval WRITE setKeyboardInputInterval)
+
+public:
+ QGuiApplication(int &argc, char **argv, int = ApplicationFlags);
+ virtual ~QGuiApplication();
+
+ static QWindowList topLevelWindows();
+
+#ifndef QT_NO_CURSOR
+ static QCursor *overrideCursor();
+ static void setOverrideCursor(const QCursor &);
+ static void changeOverrideCursor(const QCursor &);
+ static void restoreOverrideCursor();
+#endif
+
+ static QFont font();
+ static void setFont(const QFont &);
+
+#ifndef QT_NO_CLIPBOARD
+ static QClipboard *clipboard();
+#endif
+
+ static QPalette palette();
+
+ static Qt::KeyboardModifiers keyboardModifiers();
+ static Qt::MouseButtons mouseButtons();
+
+ static void setDoubleClickInterval(int);
+ static int doubleClickInterval();
+
+ static void setKeyboardInputInterval(int);
+ static int keyboardInputInterval();
+
+ static void setLayoutDirection(Qt::LayoutDirection direction);
+ static Qt::LayoutDirection layoutDirection();
+
+ static inline bool isRightToLeft() { return layoutDirection() == Qt::RightToLeft; }
+ static inline bool isLeftToRight() { return layoutDirection() == Qt::LeftToRight; }
+
+ static QLocale keyboardInputLocale();
+ static Qt::LayoutDirection keyboardInputDirection();
+
+ static QPlatformNativeInterface *platformNativeInterface();
+
+ static int exec();
+ bool notify(QObject *, QEvent *);
+
+Q_SIGNALS:
+ void fontDatabaseChanged();
+
+protected:
+ bool event(QEvent *);
+ bool compressEvent(QEvent *, QObject *receiver, QPostEventList *);
+
+ QGuiApplication(QGuiApplicationPrivate &p);
+
+private:
+ Q_DISABLE_COPY(QGuiApplication)
+ Q_DECLARE_PRIVATE(QGuiApplication)
+
+#ifndef QT_NO_GESTURES
+ friend class QGestureManager;
+#endif
+ friend class QFontDatabasePrivate;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QGUIAPPLICATION_QPA_H
diff --git a/src/gui/guikernel/qguiapplication_p.h b/src/gui/guikernel/qguiapplication_p.h
new file mode 100644
index 0000000000..dfe73a4c69
--- /dev/null
+++ b/src/gui/guikernel/qguiapplication_p.h
@@ -0,0 +1,169 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGUIAPPLICATION_QPA_P_H
+#define QGUIAPPLICATION_QPA_P_H
+
+#include <QtGui/qguiapplication.h>
+
+#include <QtCore/private/qcoreapplication_p.h>
+
+#include <QtCore/private/qthread_p.h>
+
+#include <QWindowSystemInterface>
+#include "private/qwindowsysteminterface_qpa_p.h"
+#include "QtGui/qplatformintegration_qpa.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QPlatformIntegration;
+
+class Q_GUI_EXPORT QGuiApplicationPrivate : public QCoreApplicationPrivate
+{
+ Q_DECLARE_PUBLIC(QGuiApplication)
+public:
+ QGuiApplicationPrivate(int &argc, char **argv, int flags);
+ ~QGuiApplicationPrivate();
+
+ void createEventDispatcher();
+
+ virtual void notifyLayoutDirectionChange();
+
+ static int keyboard_input_time;
+ static int mouse_double_click_time;
+
+ static Qt::KeyboardModifiers modifier_buttons;
+ static Qt::MouseButtons mouse_buttons;
+
+ static QPlatformIntegration *platform_integration;
+
+ static QPlatformIntegration *platformIntegration()
+ { return platform_integration; }
+
+ enum KeyPlatform {
+ KB_Win = 1,
+ KB_Mac = 2,
+ KB_X11 = 4,
+ KB_KDE = 8,
+ KB_Gnome = 16,
+ KB_CDE = 32,
+ KB_S60 = 64,
+ KB_All = 0xffff
+ };
+
+ static uint currentKeyPlatform();
+
+ static QAbstractEventDispatcher *qt_qpa_core_dispatcher()
+ { return QCoreApplication::instance()->d_func()->threadData->eventDispatcher; }
+
+ static void processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e);
+ static void processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e);
+ static void processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e);
+ static void processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e);
+
+ static void processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e);
+
+ static void processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e);
+
+ static void processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e);
+ static void processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e);
+
+ static void processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e);
+
+ static void processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e);
+
+ static void reportScreenCount(QWindowSystemInterfacePrivate::ScreenCountEvent *e);
+ static void reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e);
+ static void reportAvailableGeometryChange(QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e);
+
+ static inline Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
+ {
+ if (!(alignment & Qt::AlignHorizontal_Mask))
+ alignment |= Qt::AlignLeft;
+ if ((alignment & Qt::AlignAbsolute) == 0 && (alignment & (Qt::AlignLeft | Qt::AlignRight))) {
+ if (direction == Qt::RightToLeft)
+ alignment ^= (Qt::AlignLeft | Qt::AlignRight);
+ alignment |= Qt::AlignAbsolute;
+ }
+ return alignment;
+ }
+
+ QPixmap getPixmapCursor(Qt::CursorShape cshape);
+
+ static QGuiApplicationPrivate *instance() { return self; }
+
+ static bool app_do_modal;
+
+ static Qt::MouseButtons buttons;
+ static ulong mousePressTime;
+ static Qt::MouseButton mousePressButton;
+ static int mousePressX;
+ static int mousePressY;
+ static int mouse_double_click_distance;
+
+#ifndef QT_NO_CLIPBOARD
+ static QClipboard *qt_clipboard;
+#endif
+
+ static QPalette *app_pal;
+
+ static QWindowList window_list;
+
+#ifndef QT_NO_CURSOR
+ QList<QCursor> cursor_list;
+#endif
+
+ static QFont *app_font;
+private:
+ void init();
+
+ static QGuiApplicationPrivate *self;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QGUIAPPLICATION_QPA_P_H
diff --git a/src/gui/guikernel/qguivariant.cpp b/src/gui/guikernel/qguivariant.cpp
new file mode 100644
index 0000000000..c1e07e55a5
--- /dev/null
+++ b/src/gui/guikernel/qguivariant.cpp
@@ -0,0 +1,789 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qvariant.h"
+
+#include "qbitmap.h"
+#include "qbrush.h"
+#include "qcolor.h"
+#include "qcursor.h"
+#include "qdatastream.h"
+#include "qdebug.h"
+#include "qfont.h"
+#include "qimage.h"
+#include "qkeysequence.h"
+#include "qtransform.h"
+#include "qmatrix.h"
+#include "qpalette.h"
+#include "qpen.h"
+#include "qpixmap.h"
+#include "qpolygon.h"
+#include "qregion.h"
+#include "qtextformat.h"
+#include "qmatrix4x4.h"
+#include "qvector2d.h"
+#include "qvector3d.h"
+#include "qvector4d.h"
+#include "qquaternion.h"
+
+#include "private/qvariant_p.h"
+
+QT_BEGIN_NAMESPACE
+
+Q_GUI_EXPORT const QVariant::Handler *qt_widgets_variant_handler = 0;
+
+Q_CORE_EXPORT const QVariant::Handler *qcoreVariantHandler();
+
+static void construct(QVariant::Private *x, const void *copy)
+{
+ switch (x->type) {
+ case QVariant::Bitmap:
+ v_construct<QBitmap>(x, copy);
+ break;
+ case QVariant::Region:
+ v_construct<QRegion>(x, copy);
+ break;
+ case QVariant::Polygon:
+ v_construct<QPolygon>(x, copy);
+ break;
+ case QVariant::Font:
+ v_construct<QFont>(x, copy);
+ break;
+ case QVariant::Pixmap:
+ v_construct<QPixmap>(x, copy);
+ break;
+ case QVariant::Image:
+ v_construct<QImage>(x, copy);
+ break;
+ case QVariant::Brush:
+ v_construct<QBrush>(x, copy);
+ break;
+ case QVariant::Color:
+ v_construct<QColor>(x, copy);
+ break;
+ case QVariant::Palette:
+ v_construct<QPalette>(x, copy);
+ break;
+ case QVariant::Matrix:
+ v_construct<QMatrix>(x, copy);
+ break;
+ case QVariant::Transform:
+ v_construct<QTransform>(x, copy);
+ break;
+ case QVariant::TextFormat:
+ v_construct<QTextFormat>(x, copy);
+ break;
+ case QVariant::TextLength:
+ v_construct<QTextLength>(x, copy);
+ break;
+#ifndef QT_NO_SHORTCUT
+ case QVariant::KeySequence:
+ v_construct<QKeySequence>(x, copy);
+ break;
+#endif
+ case QVariant::Pen:
+ v_construct<QPen>(x, copy);
+ break;
+#ifndef QT_NO_CURSOR
+ case QVariant::Cursor:
+ v_construct<QCursor>(x, copy);
+ break;
+#endif
+ case 62: {
+ // small 'trick' to let a QVariant(Qt::blue) create a variant
+ // of type QColor
+ x->type = QVariant::Color;
+ QColor color(*reinterpret_cast<const Qt::GlobalColor *>(copy));
+ v_construct<QColor>(x, &color);
+ break;
+ }
+#ifndef QT_NO_MATRIX4X4
+ case QVariant::Matrix4x4:
+ v_construct<QMatrix4x4>(x, copy);
+ break;
+#endif
+#ifndef QT_NO_VECTOR2D
+ case QVariant::Vector2D:
+ v_construct<QVector2D>(x, copy);
+ break;
+#endif
+#ifndef QT_NO_VECTOR3D
+ case QVariant::Vector3D:
+ v_construct<QVector3D>(x, copy);
+ break;
+#endif
+#ifndef QT_NO_VECTOR4D
+ case QVariant::Vector4D:
+ v_construct<QVector4D>(x, copy);
+ break;
+#endif
+#ifndef QT_NO_QUATERNION
+ case QVariant::Quaternion:
+ v_construct<QQuaternion>(x, copy);
+ break;
+#endif
+ case QVariant::SizePolicy:
+ case QVariant::Icon:
+ if (qt_widgets_variant_handler) {
+ qt_widgets_variant_handler->construct(x, copy);
+ return;
+ }
+ break;
+ default:
+ qcoreVariantHandler()->construct(x, copy);
+ return;
+ }
+ x->is_null = !copy;
+}
+
+static void clear(QVariant::Private *d)
+{
+ switch (d->type) {
+ case QVariant::Bitmap:
+ v_clear<QBitmap>(d);
+ break;
+ case QVariant::Cursor:
+ v_clear<QCursor>(d);
+ break;
+ case QVariant::Region:
+ v_clear<QRegion>(d);
+ break;
+ case QVariant::Polygon:
+ v_clear<QPolygon>(d);
+ break;
+ case QVariant::Font:
+ v_clear<QFont>(d);
+ break;
+ case QVariant::Pixmap:
+ v_clear<QPixmap>(d);
+ break;
+ case QVariant::Image:
+ v_clear<QImage>(d);
+ break;
+ case QVariant::Brush:
+ v_clear<QBrush>(d);
+ break;
+ case QVariant::Color:
+ v_clear<QColor>(d);
+ break;
+ case QVariant::Palette:
+ v_clear<QPalette>(d);
+ break;
+ case QVariant::Matrix:
+ v_clear<QMatrix>(d);
+ break;
+ case QVariant::Transform:
+ v_clear<QTransform>(d);
+ break;
+ case QVariant::TextFormat:
+ v_clear<QTextFormat>(d);
+ break;
+ case QVariant::TextLength:
+ v_clear<QTextLength>(d);
+ break;
+#ifndef QT_NO_SHORTCUT
+ case QVariant::KeySequence:
+ v_clear<QKeySequence>(d);
+ break;
+#endif
+ case QVariant::Pen:
+ v_clear<QPen>(d);
+ break;
+#ifndef QT_NO_MATRIX4X4
+ case QVariant::Matrix4x4:
+ v_clear<QMatrix4x4>(d);
+ break;
+#endif
+#ifndef QT_NO_VECTOR2D
+ case QVariant::Vector2D:
+ v_clear<QVector2D>(d);
+ break;
+#endif
+#ifndef QT_NO_VECTOR3D
+ case QVariant::Vector3D:
+ v_clear<QVector3D>(d);
+ break;
+#endif
+#ifndef QT_NO_VECTOR4D
+ case QVariant::Vector4D:
+ v_clear<QVector4D>(d);
+ break;
+#endif
+#ifndef QT_NO_QUATERNION
+ case QVariant::Quaternion:
+ v_clear<QVector4D>(d);
+ break;
+#endif
+ case QVariant::SizePolicy:
+ case QVariant::Icon:
+ if (qt_widgets_variant_handler) {
+ qt_widgets_variant_handler->clear(d);
+ return;
+ }
+ break;
+ default:
+ qcoreVariantHandler()->clear(d);
+ return;
+ }
+
+ d->type = QVariant::Invalid;
+ d->is_null = true;
+ d->is_shared = false;
+}
+
+
+static bool isNull(const QVariant::Private *d)
+{
+ switch(d->type) {
+ case QVariant::Bitmap:
+ return v_cast<QBitmap>(d)->isNull();
+ case QVariant::Region:
+ return v_cast<QRegion>(d)->isEmpty();
+ case QVariant::Polygon:
+ return v_cast<QPolygon>(d)->isEmpty();
+ case QVariant::Pixmap:
+ return v_cast<QPixmap>(d)->isNull();
+ case QVariant::Image:
+ return v_cast<QImage>(d)->isNull();
+ case QVariant::Matrix:
+ case QVariant::TextFormat:
+ case QVariant::TextLength:
+ case QVariant::Cursor:
+ case QVariant::StringList:
+ case QVariant::Font:
+ case QVariant::Brush:
+ case QVariant::Color:
+ case QVariant::Palette:
+ case QVariant::SizePolicy:
+#ifndef QT_NO_SHORTCUT
+ case QVariant::KeySequence:
+#endif
+ case QVariant::Pen:
+#ifndef QT_NO_MATRIX4X4
+ case QVariant::Matrix4x4:
+#endif
+ break;
+#ifndef QT_NO_VECTOR2D
+ case QVariant::Vector2D:
+ return v_cast<QVector2D>(d)->isNull();
+#endif
+#ifndef QT_NO_VECTOR3D
+ case QVariant::Vector3D:
+ return v_cast<QVector3D>(d)->isNull();
+#endif
+#ifndef QT_NO_VECTOR4D
+ case QVariant::Vector4D:
+ return v_cast<QVector4D>(d)->isNull();
+#endif
+#ifndef QT_NO_QUATERNION
+ case QVariant::Quaternion:
+ return v_cast<QQuaternion>(d)->isNull();
+#endif
+ case QVariant::Icon:
+ if (qt_widgets_variant_handler)
+ return qt_widgets_variant_handler->isNull(d);
+ break;
+ default:
+ return qcoreVariantHandler()->isNull(d);
+ }
+ return d->is_null;
+}
+
+static bool compare(const QVariant::Private *a, const QVariant::Private *b)
+{
+ Q_ASSERT(a->type == b->type);
+ switch(a->type) {
+ case QVariant::Cursor:
+#ifndef QT_NO_CURSOR
+ return v_cast<QCursor>(a)->shape() == v_cast<QCursor>(b)->shape();
+#endif
+ case QVariant::Bitmap:
+ return v_cast<QBitmap>(a)->cacheKey()
+ == v_cast<QBitmap>(b)->cacheKey();
+ case QVariant::Polygon:
+ return *v_cast<QPolygon>(a) == *v_cast<QPolygon>(b);
+ case QVariant::Region:
+ return *v_cast<QRegion>(a) == *v_cast<QRegion>(b);
+ case QVariant::Font:
+ return *v_cast<QFont>(a) == *v_cast<QFont>(b);
+ case QVariant::Pixmap:
+ return v_cast<QPixmap>(a)->cacheKey() == v_cast<QPixmap>(b)->cacheKey();
+ case QVariant::Image:
+ return *v_cast<QImage>(a) == *v_cast<QImage>(b);
+ case QVariant::Brush:
+ return *v_cast<QBrush>(a) == *v_cast<QBrush>(b);
+ case QVariant::Color:
+ return *v_cast<QColor>(a) == *v_cast<QColor>(b);
+ case QVariant::Palette:
+ return *v_cast<QPalette>(a) == *v_cast<QPalette>(b);
+#ifndef QT_NO_ICON
+ case QVariant::Icon:
+ /* QIcon::operator==() cannot be reasonably implemented for QIcon,
+ * so we always return false. */
+ return false;
+#endif
+ case QVariant::Matrix:
+ return *v_cast<QMatrix>(a) == *v_cast<QMatrix>(b);
+ case QVariant::Transform:
+ return *v_cast<QTransform>(a) == *v_cast<QTransform>(b);
+ case QVariant::TextFormat:
+ return *v_cast<QTextFormat>(a) == *v_cast<QTextFormat>(b);
+ case QVariant::TextLength:
+ return *v_cast<QTextLength>(a) == *v_cast<QTextLength>(b);
+#ifndef QT_NO_SHORTCUT
+ case QVariant::KeySequence:
+ return *v_cast<QKeySequence>(a) == *v_cast<QKeySequence>(b);
+#endif
+ case QVariant::Pen:
+ return *v_cast<QPen>(a) == *v_cast<QPen>(b);
+#ifndef QT_NO_MATRIX4X4
+ case QVariant::Matrix4x4:
+ return *v_cast<QMatrix4x4>(a) == *v_cast<QMatrix4x4>(b);
+#endif
+#ifndef QT_NO_VECTOR2D
+ case QVariant::Vector2D:
+ return *v_cast<QVector2D>(a) == *v_cast<QVector2D>(b);
+#endif
+#ifndef QT_NO_VECTOR3D
+ case QVariant::Vector3D:
+ return *v_cast<QVector3D>(a) == *v_cast<QVector3D>(b);
+#endif
+#ifndef QT_NO_VECTOR4D
+ case QVariant::Vector4D:
+ return *v_cast<QVector4D>(a) == *v_cast<QVector4D>(b);
+#endif
+#ifndef QT_NO_QUATERNION
+ case QVariant::Quaternion:
+ return *v_cast<QQuaternion>(a) == *v_cast<QQuaternion>(b);
+#endif
+ case QVariant::SizePolicy:
+ if (qt_widgets_variant_handler)
+ return qt_widgets_variant_handler->compare(a, b);
+ break;
+ default:
+ break;
+ }
+ return qcoreVariantHandler()->compare(a, b);
+}
+
+
+
+static bool convert(const QVariant::Private *d, QVariant::Type t,
+ void *result, bool *ok)
+{
+ switch (t) {
+ case QVariant::ByteArray:
+ if (d->type == QVariant::Color) {
+ *static_cast<QByteArray *>(result) = v_cast<QColor>(d)->name().toLatin1();
+ return true;
+ }
+ break;
+ case QVariant::String: {
+ QString *str = static_cast<QString *>(result);
+ switch (d->type) {
+#ifndef QT_NO_SHORTCUT
+ case QVariant::KeySequence:
+ *str = QString(*v_cast<QKeySequence>(d));
+ return true;
+#endif
+ case QVariant::Font:
+ *str = v_cast<QFont>(d)->toString();
+ return true;
+ case QVariant::Color:
+ *str = v_cast<QColor>(d)->name();
+ return true;
+ default:
+ break;
+ }
+ break;
+ }
+ case QVariant::Pixmap:
+ if (d->type == QVariant::Image) {
+ *static_cast<QPixmap *>(result) = QPixmap::fromImage(*v_cast<QImage>(d));
+ return true;
+ } else if (d->type == QVariant::Bitmap) {
+ *static_cast<QPixmap *>(result) = *v_cast<QBitmap>(d);
+ return true;
+ } else if (d->type == QVariant::Brush) {
+ if (v_cast<QBrush>(d)->style() == Qt::TexturePattern) {
+ *static_cast<QPixmap *>(result) = v_cast<QBrush>(d)->texture();
+ return true;
+ }
+ }
+ break;
+ case QVariant::Image:
+ if (d->type == QVariant::Pixmap) {
+ *static_cast<QImage *>(result) = v_cast<QPixmap>(d)->toImage();
+ return true;
+ } else if (d->type == QVariant::Bitmap) {
+ *static_cast<QImage *>(result) = v_cast<QBitmap>(d)->toImage();
+ return true;
+ }
+ break;
+ case QVariant::Bitmap:
+ if (d->type == QVariant::Pixmap) {
+ *static_cast<QBitmap *>(result) = *v_cast<QPixmap>(d);
+ return true;
+ } else if (d->type == QVariant::Image) {
+ *static_cast<QBitmap *>(result) = QBitmap::fromImage(*v_cast<QImage>(d));
+ return true;
+ }
+ break;
+#ifndef QT_NO_SHORTCUT
+ case QVariant::Int:
+ if (d->type == QVariant::KeySequence) {
+ *static_cast<int *>(result) = (int)(*(v_cast<QKeySequence>(d)));
+ return true;
+ }
+ break;
+#endif
+ case QVariant::Font:
+ if (d->type == QVariant::String) {
+ QFont *f = static_cast<QFont *>(result);
+ f->fromString(*v_cast<QString>(d));
+ return true;
+ }
+ break;
+ case QVariant::Color:
+ if (d->type == QVariant::String) {
+ static_cast<QColor *>(result)->setNamedColor(*v_cast<QString>(d));
+ return static_cast<QColor *>(result)->isValid();
+ } else if (d->type == QVariant::ByteArray) {
+ static_cast<QColor *>(result)->setNamedColor(QString::fromLatin1(
+ *v_cast<QByteArray>(d)));
+ return true;
+ } else if (d->type == QVariant::Brush) {
+ if (v_cast<QBrush>(d)->style() == Qt::SolidPattern) {
+ *static_cast<QColor *>(result) = v_cast<QBrush>(d)->color();
+ return true;
+ }
+ }
+ break;
+ case QVariant::Brush:
+ if (d->type == QVariant::Color) {
+ *static_cast<QBrush *>(result) = QBrush(*v_cast<QColor>(d));
+ return true;
+ } else if (d->type == QVariant::Pixmap) {
+ *static_cast<QBrush *>(result) = QBrush(*v_cast<QPixmap>(d));
+ return true;
+ }
+ break;
+#ifndef QT_NO_SHORTCUT
+ case QVariant::KeySequence: {
+ QKeySequence *seq = static_cast<QKeySequence *>(result);
+ switch (d->type) {
+ case QVariant::String:
+ *seq = QKeySequence(*v_cast<QString>(d));
+ return true;
+ case QVariant::Int:
+ *seq = QKeySequence(d->data.i);
+ return true;
+ default:
+ break;
+ }
+ }
+#endif
+ default:
+ break;
+ }
+ return qcoreVariantHandler()->convert(d, t, result, ok);
+}
+
+#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
+static void streamDebug(QDebug dbg, const QVariant &v)
+{
+ switch(v.type()) {
+ case QVariant::Cursor:
+#ifndef QT_NO_CURSOR
+// dbg.nospace() << qvariant_cast<QCursor>(v); //FIXME
+#endif
+ break;
+ case QVariant::Bitmap:
+// dbg.nospace() << qvariant_cast<QBitmap>(v); //FIXME
+ break;
+ case QVariant::Polygon:
+ dbg.nospace() << qvariant_cast<QPolygon>(v);
+ break;
+ case QVariant::Region:
+ dbg.nospace() << qvariant_cast<QRegion>(v);
+ break;
+ case QVariant::Font:
+// dbg.nospace() << qvariant_cast<QFont>(v); //FIXME
+ break;
+ case QVariant::Matrix:
+ dbg.nospace() << qvariant_cast<QMatrix>(v);
+ break;
+ case QVariant::Transform:
+ dbg.nospace() << qvariant_cast<QTransform>(v);
+ break;
+ case QVariant::Pixmap:
+// dbg.nospace() << qvariant_cast<QPixmap>(v); //FIXME
+ break;
+ case QVariant::Image:
+// dbg.nospace() << qvariant_cast<QImage>(v); //FIXME
+ break;
+ case QVariant::Brush:
+ dbg.nospace() << qvariant_cast<QBrush>(v);
+ break;
+ case QVariant::Color:
+ dbg.nospace() << qvariant_cast<QColor>(v);
+ break;
+ case QVariant::Palette:
+// dbg.nospace() << qvariant_cast<QPalette>(v); //FIXME
+ break;
+#ifndef QT_NO_ICON
+ case QVariant::Icon:
+// dbg.nospace() << qvariant_cast<QIcon>(v); // FIXME
+ break;
+#endif
+ case QVariant::SizePolicy:
+// dbg.nospace() << qvariant_cast<QSizePolicy>(v); //FIXME
+ break;
+#ifndef QT_NO_SHORTCUT
+ case QVariant::KeySequence:
+ dbg.nospace() << qvariant_cast<QKeySequence>(v);
+ break;
+#endif
+ case QVariant::Pen:
+ dbg.nospace() << qvariant_cast<QPen>(v);
+ break;
+#ifndef QT_NO_MATRIX4X4
+ case QVariant::Matrix4x4:
+ dbg.nospace() << qvariant_cast<QMatrix4x4>(v);
+ break;
+#endif
+#ifndef QT_NO_VECTOR2D
+ case QVariant::Vector2D:
+ dbg.nospace() << qvariant_cast<QVector2D>(v);
+ break;
+#endif
+#ifndef QT_NO_VECTOR3D
+ case QVariant::Vector3D:
+ dbg.nospace() << qvariant_cast<QVector3D>(v);
+ break;
+#endif
+#ifndef QT_NO_VECTOR4D
+ case QVariant::Vector4D:
+ dbg.nospace() << qvariant_cast<QVector4D>(v);
+ break;
+#endif
+#ifndef QT_NO_QUATERNION
+ case QVariant::Quaternion:
+ dbg.nospace() << qvariant_cast<QQuaternion>(v);
+ break;
+#endif
+ default:
+ qcoreVariantHandler()->debugStream(dbg, v);
+ break;
+ }
+}
+#endif
+
+const QVariant::Handler qt_gui_variant_handler = {
+ construct,
+ clear,
+ isNull,
+#ifndef QT_NO_DATASTREAM
+ 0,
+ 0,
+#endif
+ compare,
+ convert,
+ 0,
+#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
+ streamDebug
+#else
+ 0
+#endif
+};
+
+struct QMetaTypeGuiHelper
+{
+ QMetaType::Constructor constr;
+ QMetaType::Destructor destr;
+#ifndef QT_NO_DATASTREAM
+ QMetaType::SaveOperator saveOp;
+ QMetaType::LoadOperator loadOp;
+#endif
+};
+
+extern Q_CORE_EXPORT const QMetaTypeGuiHelper *qMetaTypeGuiHelper;
+
+
+#ifdef QT_NO_DATASTREAM
+# define Q_DECL_METATYPE_HELPER(TYPE) \
+ typedef void *(*QConstruct##TYPE)(const TYPE *); \
+ static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper<TYPE>; \
+ typedef void (*QDestruct##TYPE)(TYPE *); \
+ static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDeleteHelper<TYPE>;
+#else
+# define Q_DECL_METATYPE_HELPER(TYPE) \
+ typedef void *(*QConstruct##TYPE)(const TYPE *); \
+ static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper<TYPE>; \
+ typedef void (*QDestruct##TYPE)(TYPE *); \
+ static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDeleteHelper<TYPE>; \
+ typedef void (*QSave##TYPE)(QDataStream &, const TYPE *); \
+ static const QSave##TYPE qSave##TYPE = qMetaTypeSaveHelper<TYPE>; \
+ typedef void (*QLoad##TYPE)(QDataStream &, TYPE *); \
+ static const QLoad##TYPE qLoad##TYPE = qMetaTypeLoadHelper<TYPE>;
+#endif
+
+Q_DECL_METATYPE_HELPER(QFont)
+Q_DECL_METATYPE_HELPER(QPixmap)
+Q_DECL_METATYPE_HELPER(QBrush)
+Q_DECL_METATYPE_HELPER(QColor)
+Q_DECL_METATYPE_HELPER(QPalette)
+Q_DECL_METATYPE_HELPER(QImage)
+Q_DECL_METATYPE_HELPER(QPolygon)
+Q_DECL_METATYPE_HELPER(QRegion)
+Q_DECL_METATYPE_HELPER(QBitmap)
+#ifndef QT_NO_CURSOR
+Q_DECL_METATYPE_HELPER(QCursor)
+#endif
+#ifndef QT_NO_SHORTCUT
+Q_DECL_METATYPE_HELPER(QKeySequence)
+#endif
+Q_DECL_METATYPE_HELPER(QPen)
+Q_DECL_METATYPE_HELPER(QTextLength)
+Q_DECL_METATYPE_HELPER(QTextFormat)
+Q_DECL_METATYPE_HELPER(QMatrix)
+Q_DECL_METATYPE_HELPER(QTransform)
+#ifndef QT_NO_MATRIX4X4
+Q_DECL_METATYPE_HELPER(QMatrix4x4)
+#endif
+#ifndef QT_NO_VECTOR2D
+Q_DECL_METATYPE_HELPER(QVector2D)
+#endif
+#ifndef QT_NO_VECTOR3D
+Q_DECL_METATYPE_HELPER(QVector3D)
+#endif
+#ifndef QT_NO_VECTOR4D
+Q_DECL_METATYPE_HELPER(QVector4D)
+#endif
+#ifndef QT_NO_QUATERNION
+Q_DECL_METATYPE_HELPER(QQuaternion)
+#endif
+
+#ifdef QT_NO_DATASTREAM
+# define Q_IMPL_METATYPE_HELPER(TYPE) \
+ { reinterpret_cast<QMetaType::Constructor>(qConstruct##TYPE), \
+ reinterpret_cast<QMetaType::Destructor>(qDestruct##TYPE) }
+#else
+# define Q_IMPL_METATYPE_HELPER(TYPE) \
+ { reinterpret_cast<QMetaType::Constructor>(qConstruct##TYPE), \
+ reinterpret_cast<QMetaType::Destructor>(qDestruct##TYPE), \
+ reinterpret_cast<QMetaType::SaveOperator>(qSave##TYPE), \
+ reinterpret_cast<QMetaType::LoadOperator>(qLoad##TYPE) \
+ }
+#endif
+
+static const QMetaTypeGuiHelper qVariantGuiHelper[] = {
+ Q_IMPL_METATYPE_HELPER(QFont),
+ Q_IMPL_METATYPE_HELPER(QPixmap),
+ Q_IMPL_METATYPE_HELPER(QBrush),
+ Q_IMPL_METATYPE_HELPER(QColor),
+ Q_IMPL_METATYPE_HELPER(QPalette),
+ Q_IMPL_METATYPE_HELPER(QImage),
+ Q_IMPL_METATYPE_HELPER(QPolygon),
+ Q_IMPL_METATYPE_HELPER(QRegion),
+ Q_IMPL_METATYPE_HELPER(QBitmap),
+#ifdef QT_NO_CURSOR
+ {0, 0, 0, 0},
+#else
+ Q_IMPL_METATYPE_HELPER(QCursor),
+#endif
+#ifdef QT_NO_SHORTCUT
+ {0, 0, 0, 0},
+#else
+ Q_IMPL_METATYPE_HELPER(QKeySequence),
+#endif
+ Q_IMPL_METATYPE_HELPER(QPen),
+ Q_IMPL_METATYPE_HELPER(QTextLength),
+ Q_IMPL_METATYPE_HELPER(QTextFormat),
+ Q_IMPL_METATYPE_HELPER(QMatrix),
+ Q_IMPL_METATYPE_HELPER(QTransform),
+#ifndef QT_NO_MATRIX4X4
+ Q_IMPL_METATYPE_HELPER(QMatrix4x4),
+#else
+ {0, 0, 0, 0},
+#endif
+#ifndef QT_NO_VECTOR2D
+ Q_IMPL_METATYPE_HELPER(QVector2D),
+#else
+ {0, 0, 0, 0},
+#endif
+#ifndef QT_NO_VECTOR3D
+ Q_IMPL_METATYPE_HELPER(QVector3D),
+#else
+ {0, 0, 0, 0},
+#endif
+#ifndef QT_NO_VECTOR4D
+ Q_IMPL_METATYPE_HELPER(QVector4D),
+#else
+ {0, 0, 0, 0},
+#endif
+#ifndef QT_NO_QUATERNION
+ Q_IMPL_METATYPE_HELPER(QQuaternion)
+#else
+ {0, 0, 0, 0}
+#endif
+};
+
+static const QVariant::Handler *qt_guivariant_last_handler = 0;
+int qRegisterGuiVariant()
+{
+ qt_guivariant_last_handler = QVariant::handler;
+ QVariant::handler = &qt_gui_variant_handler;
+ qMetaTypeGuiHelper = qVariantGuiHelper;
+ return 1;
+}
+Q_CONSTRUCTOR_FUNCTION(qRegisterGuiVariant)
+
+int qUnregisterGuiVariant()
+{
+ QVariant::handler = qt_guivariant_last_handler;
+ qMetaTypeGuiHelper = 0;
+ return 1;
+}
+Q_DESTRUCTOR_FUNCTION(qUnregisterGuiVariant)
+
+
+QT_END_NAMESPACE
diff --git a/src/gui/guikernel/qkeymapper.cpp b/src/gui/guikernel/qkeymapper.cpp
new file mode 100644
index 0000000000..02e0231ecd
--- /dev/null
+++ b/src/gui/guikernel/qkeymapper.cpp
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "qguiapplication.h"
+
+#include <private/qobject_p.h>
+#include "qkeymapper_p.h"
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QKeyMapper
+ \since 4.2
+ \internal
+
+ \sa QObject
+*/
+
+/*!
+ Constructs a new key mapper.
+*/
+QKeyMapper::QKeyMapper()
+ : QObject(*new QKeyMapperPrivate, 0)
+{
+}
+
+/*!
+ Destroys the key mapper.
+*/
+QKeyMapper::~QKeyMapper()
+{
+}
+
+QList<int> QKeyMapper::possibleKeys(QKeyEvent *e)
+{
+ QList<int> result;
+
+ if (!e->nativeScanCode()) {
+ if (e->key() && (e->key() != Qt::Key_unknown))
+ result << int(e->key() + e->modifiers());
+ else if (!e->text().isEmpty())
+ result << int(e->text().at(0).unicode() + e->modifiers());
+ return result;
+ }
+
+ return instance()->d_func()->possibleKeys(e);
+}
+
+extern bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event); // in qapplication_*.cpp
+void QKeyMapper::changeKeyboard()
+{
+ instance()->d_func()->clearMappings();
+
+ // ## TODO: Support KeyboardLayoutChange on QPA
+#if 0
+ // inform all toplevel widgets of the change
+ QEvent e(QEvent::KeyboardLayoutChange);
+ QWidgetList list = QApplication::topLevelWidgets();
+ for (int i = 0; i < list.size(); ++i) {
+ QWidget *w = list.at(i);
+ qt_sendSpontaneousEvent(w, &e);
+ }
+#endif
+}
+
+Q_GLOBAL_STATIC(QKeyMapper, keymapper)
+/*!
+ Returns the pointer to the single instance of QKeyMapper in the application.
+ If none yet exists, the function ensures that one is created.
+*/
+QKeyMapper *QKeyMapper::instance()
+{
+ return keymapper();
+}
+
+QKeyMapperPrivate *qt_keymapper_private()
+{
+ return QKeyMapper::instance()->d_func();
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/guikernel/qkeymapper_p.h b/src/gui/guikernel/qkeymapper_p.h
new file mode 100644
index 0000000000..03ba092dec
--- /dev/null
+++ b/src/gui/guikernel/qkeymapper_p.h
@@ -0,0 +1,226 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QKEYMAPPER_P_H
+#define QKEYMAPPER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <qobject.h>
+#include <private/qobject_p.h>
+#include <qkeysequence.h>
+#include <qlist.h>
+#include <qlocale.h>
+#include <qevent.h>
+#include <qhash.h>
+
+#if defined (Q_WS_MAC64)
+# include <private/qt_mac_p.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+class QKeyMapperPrivate;
+class Q_GUI_EXPORT QKeyMapper : public QObject
+{
+ Q_OBJECT
+public:
+ explicit QKeyMapper();
+ ~QKeyMapper();
+
+ static QKeyMapper *instance();
+ static void changeKeyboard();
+#ifndef Q_WS_QPA
+ static bool sendKeyEvent(QWidget *widget, bool grab,
+ QEvent::Type type, int code, Qt::KeyboardModifiers modifiers,
+ const QString &text, bool autorepeat, int count,
+ quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers,
+ bool *unusedExceptForCocoa = 0);
+#endif
+ static QList<int> possibleKeys(QKeyEvent *e);
+
+private:
+ friend QKeyMapperPrivate *qt_keymapper_private();
+ Q_DECLARE_PRIVATE(QKeyMapper)
+ Q_DISABLE_COPY(QKeyMapper)
+};
+
+
+
+#if defined(Q_OS_WIN)
+enum WindowsNativeModifiers {
+ ShiftLeft = 0x00000001,
+ ControlLeft = 0x00000002,
+ AltLeft = 0x00000004,
+ MetaLeft = 0x00000008,
+ ShiftRight = 0x00000010,
+ ControlRight = 0x00000020,
+ AltRight = 0x00000040,
+ MetaRight = 0x00000080,
+ CapsLock = 0x00000100,
+ NumLock = 0x00000200,
+ ScrollLock = 0x00000400,
+ ExtendedKey = 0x01000000,
+
+ // Convenience mappings
+ ShiftAny = 0x00000011,
+ ControlAny = 0x00000022,
+ AltAny = 0x00000044,
+ MetaAny = 0x00000088,
+ LockAny = 0x00000700
+};
+# if !defined(tagMSG)
+ typedef struct tagMSG MSG;
+# endif
+#elif defined(Q_WS_MAC)
+QT_BEGIN_INCLUDE_NAMESPACE
+# include <private/qt_mac_p.h>
+QT_END_INCLUDE_NAMESPACE
+#elif defined(Q_WS_X11)
+
+QT_BEGIN_INCLUDE_NAMESPACE
+typedef ulong XID;
+typedef XID KeySym;
+QT_END_INCLUDE_NAMESPACE
+
+struct QXCoreDesc {
+ int min_keycode;
+ int max_keycode;
+ int keysyms_per_keycode;
+ KeySym *keysyms;
+ uchar mode_switch;
+ uchar num_lock;
+ KeySym lock_meaning;
+};
+
+#endif
+
+struct KeyboardLayoutItem;
+typedef struct __TISInputSource * TISInputSourceRef;
+class QKeyEvent;
+class QKeyMapperPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QKeyMapper)
+public:
+ QKeyMapperPrivate();
+ ~QKeyMapperPrivate();
+
+ void clearMappings();
+ QList<int> possibleKeys(QKeyEvent *e);
+
+ QLocale keyboardInputLocale;
+ Qt::LayoutDirection keyboardInputDirection;
+
+#if defined(Q_OS_WIN)
+ void clearRecordedKeys();
+ void updateKeyMap(const MSG &msg);
+ bool translateKeyEvent(QWidget *receiver, const MSG &msg, bool grab);
+ void updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32 scancode, quint32 vk_key);
+ bool isADeadKey(unsigned int vk_key, unsigned int modifiers);
+ void deleteLayouts();
+
+ KeyboardLayoutItem *keyLayout[256];
+
+#elif defined(Q_WS_X11)
+
+ QList<int> possibleKeysXKB(QKeyEvent *event);
+ QList<int> possibleKeysCore(QKeyEvent *event);
+
+ bool translateKeyEventInternal(QWidget *keywidget,
+ const XEvent *,
+ KeySym &keysym,
+ int& count,
+ QString& text,
+ Qt::KeyboardModifiers& modifiers,
+ int &code,
+ QEvent::Type &type,
+ bool statefulTranslation = true);
+ bool translateKeyEvent(QWidget *keywidget,
+ const XEvent *,
+ bool grab);
+
+ int xkb_currentGroup;
+ QXCoreDesc coreDesc;
+
+#elif defined(Q_WS_MAC)
+ bool updateKeyboard();
+ void updateKeyMap(EventHandlerCallRef, EventRef, void *);
+ bool translateKeyEvent(QWidget *, EventHandlerCallRef, EventRef, void *, bool);
+ void deleteLayouts();
+
+ enum { NullMode, UnicodeMode, OtherMode } keyboard_mode;
+ union {
+ const UCKeyboardLayout *unicode;
+ void *other;
+ } keyboard_layout_format;
+#ifdef Q_WS_MAC64
+ QCFType<TISInputSourceRef> currentInputSource;
+#else
+ KeyboardLayoutRef currentKeyboardLayout;
+#endif
+ KeyboardLayoutKind keyboard_kind;
+ UInt32 keyboard_dead;
+ KeyboardLayoutItem *keyLayout[256];
+#elif defined(Q_WS_QWS)
+#elif defined(Q_OS_SYMBIAN)
+public:
+ QString translateKeyEvent(int keySym, Qt::KeyboardModifiers modifiers);
+ int mapS60KeyToQt(TUint s60key);
+ int mapS60ScanCodesToQt(TUint s60key);
+ int mapQtToS60Key(int qtKey);
+ int mapQtToS60ScanCodes(int qtKey);
+ void updateInputLanguage();
+#endif
+};
+
+QKeyMapperPrivate *qt_keymapper_private(); // from qkeymapper.cpp
+
+QT_END_NAMESPACE
+
+#endif // QKEYMAPPER_P_H
diff --git a/src/gui/kernel/qkeymapper_qws.cpp b/src/gui/guikernel/qkeymapper_qpa.cpp
index 7e4114057f..7e4114057f 100644
--- a/src/gui/kernel/qkeymapper_qws.cpp
+++ b/src/gui/guikernel/qkeymapper_qpa.cpp
diff --git a/src/gui/guikernel/qkeysequence.cpp b/src/gui/guikernel/qkeysequence.cpp
new file mode 100644
index 0000000000..71661438e1
--- /dev/null
+++ b/src/gui/guikernel/qkeysequence.cpp
@@ -0,0 +1,1725 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qkeysequence.h"
+#include "qkeysequence_p.h"
+#include "private/qguiapplication_p.h"
+
+#ifndef QT_NO_SHORTCUT
+
+#include "qdebug.h"
+#ifndef QT_NO_REGEXP
+# include "qregexp.h"
+#endif
+#ifndef QT_NO_DATASTREAM
+# include "qdatastream.h"
+#endif
+#include "qvariant.h"
+
+#ifdef Q_WS_MAC
+# include <private/qt_mac_p.h>
+
+#endif
+
+QT_BEGIN_NAMESPACE
+
+#ifdef Q_WS_MAC
+static bool qt_sequence_no_mnemonics = true;
+struct MacSpecialKey {
+ int key;
+ ushort macSymbol;
+};
+
+static const int NumEntries = 21;
+static const MacSpecialKey entries[NumEntries] = {
+ { Qt::Key_Escape, 0x238B },
+ { Qt::Key_Tab, 0x21E5 },
+ { Qt::Key_Backtab, 0x21E4 },
+ { Qt::Key_Backspace, 0x232B },
+ { Qt::Key_Return, 0x21B5 },
+ { Qt::Key_Enter, 0x2324 },
+ { Qt::Key_Delete, 0x2326 },
+ { Qt::Key_Home, 0x2196 },
+ { Qt::Key_End, 0x2198 },
+ { Qt::Key_Left, 0x2190 },
+ { Qt::Key_Up, 0x2191 },
+ { Qt::Key_Right, 0x2192 },
+ { Qt::Key_Down, 0x2193 },
+ { Qt::Key_PageUp, 0x21DE },
+ { Qt::Key_PageDown, 0x21DF },
+ { Qt::Key_Shift, kShiftUnicode },
+ { Qt::Key_Control, kCommandUnicode },
+ { Qt::Key_Meta, kControlUnicode },
+ { Qt::Key_Alt, kOptionUnicode },
+ { Qt::Key_CapsLock, 0x21EA },
+};
+
+static bool operator<(const MacSpecialKey &entry, int key)
+{
+ return entry.key < key;
+}
+
+static bool operator<(int key, const MacSpecialKey &entry)
+{
+ return key < entry.key;
+}
+
+static const MacSpecialKey * const MacSpecialKeyEntriesEnd = entries + NumEntries;
+
+QChar qt_macSymbolForQtKey(int key)
+{
+ const MacSpecialKey *i = qBinaryFind(entries, MacSpecialKeyEntriesEnd, key);
+ if (i == MacSpecialKeyEntriesEnd)
+ return QChar();
+ ushort macSymbol = i->macSymbol;
+ if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)
+ && (macSymbol == kControlUnicode || macSymbol == kCommandUnicode)) {
+ if (macSymbol == kControlUnicode)
+ macSymbol = kCommandUnicode;
+ else
+ macSymbol = kControlUnicode;
+ }
+
+ return QChar(macSymbol);
+}
+
+static int qtkeyForMacSymbol(const QChar ch)
+{
+ const ushort unicode = ch.unicode();
+ for (int i = 0; i < NumEntries; ++i) {
+ const MacSpecialKey &entry = entries[i];
+ if (entry.macSymbol == unicode) {
+ int key = entry.key;
+ if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)
+ && (unicode == kControlUnicode || unicode == kCommandUnicode)) {
+ if (unicode == kControlUnicode)
+ key = Qt::Key_Control;
+ else
+ key = Qt::Key_Meta;
+ }
+ return key;
+ }
+ }
+ return -1;
+}
+
+#else
+static bool qt_sequence_no_mnemonics = false;
+#endif
+void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b) { qt_sequence_no_mnemonics = !b; }
+
+/*!
+ \class QKeySequence
+ \brief The QKeySequence class encapsulates a key sequence as used
+ by shortcuts.
+
+ \ingroup shared
+
+
+ In its most common form, a key sequence describes a combination of
+ keys that must be used together to perform some action. Key sequences
+ are used with QAction objects to specify which keyboard shortcuts can
+ be used to trigger actions.
+
+ Key sequences can be constructed for use as keyboard shortcuts in
+ three different ways:
+
+ \list
+ \o For standard shortcuts, a \l{QKeySequence::StandardKey}{standard key}
+ can be used to request the platform-specific key sequence associated
+ with each shortcut.
+ \o For custom shortcuts, human-readable strings such as "Ctrl+X" can
+ be used, and these can be translated into the appropriate shortcuts
+ for users of different languages. Translations are made in the
+ "QShortcut" context.
+ \o For hard-coded shortcuts, integer key codes can be specified with
+ a combination of values defined by the Qt::Key and Qt::Modifier enum
+ values. Each key code consists of a single Qt::Key value and zero or
+ more modifiers, such as Qt::SHIFT, Qt::CTRL, Qt::ALT and Qt::META.
+ \endlist
+
+ For example, \gui{Ctrl P} might be a sequence used as a shortcut for
+ printing a document, and can be specified in any of the following
+ ways:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qkeysequence.cpp 0
+
+ Note that, for letters, the case used in the specification string
+ does not matter. In the above examples, the user does not need to
+ hold down the \key{Shift} key to activate a shortcut specified
+ with "Ctrl+P". However, for other keys, the use of \key{Shift} as
+ an unspecified extra modifier key can lead to confusion for users
+ of an application whose keyboards have different layouts to those
+ used by the developers. See the \l{Keyboard Layout Issues} section
+ below for more details.
+
+ It is preferable to use standard shortcuts where possible.
+ When creating key sequences for non-standard shortcuts, you should use
+ human-readable strings in preference to hard-coded integer values.
+
+ QKeySequence objects can be cast to a QString to obtain a human-readable
+ translated version of the sequence. Similarly, the toString() function
+ produces human-readable strings for use in menus. On Mac OS X, the
+ appropriate symbols are used to describe keyboard shortcuts using special
+ keys on the Macintosh keyboard.
+
+ An alternative way to specify hard-coded key codes is to use the Unicode
+ code point of the character; for example, 'A' gives the same key sequence
+ as Qt::Key_A.
+
+ \bold{Note:} On Mac OS X, references to "Ctrl", Qt::CTRL, Qt::Control
+ and Qt::ControlModifier correspond to the \key Command keys on the
+ Macintosh keyboard, and references to "Meta", Qt::META, Qt::Meta and
+ Qt::MetaModifier correspond to the \key Control keys. Developers on
+ Mac OS X can use the same shortcut descriptions across all platforms,
+ and their applications will automatically work as expected on Mac OS X.
+
+ \section1 Standard Shortcuts
+
+ QKeySequence defines many \l{QKeySequence::StandardKey} {standard
+ keyboard shortcuts} to reduce the amount of effort required when
+ setting up actions in a typical application. The table below shows
+ some common key sequences that are often used for these standard
+ shortcuts by applications on four widely-used platforms. Note
+ that on Mac OS X, the \key Ctrl value corresponds to the \key
+ Command keys on the Macintosh keyboard, and the \key Meta value
+ corresponds to the \key Control keys.
+
+ \table
+ \header \i StandardKey \i Windows \i Mac OS X \i KDE \i GNOME \i S60
+ \row \i HelpContents \i F1 \i Ctrl+? \i F1 \i F1 \i F2
+ \row \i WhatsThis \i Shift+F1 \i Shift+F1 \i Shift+F1 \i Shift+F1 \i Shift+F1
+ \row \i Open \i Ctrl+O \i Ctrl+O \i Ctrl+O \i Ctrl+O \i (none)
+ \row \i Close \i Ctrl+F4, Ctrl+W \i Ctrl+W, Ctrl+F4 \i Ctrl+W \i Ctrl+W \i (none)
+ \row \i Save \i Ctrl+S \i Ctrl+S \i Ctrl+S \i Ctrl+S \i (none)
+ \row \i Quit \i \i Ctrl+Q \i Qtrl+Q \i Qtrl+Q \i (none)
+ \row \i SaveAs \i \i Ctrl+Shift+S \i \i Ctrl+Shift+S \i (none)
+ \row \i New \i Ctrl+N \i Ctrl+N \i Ctrl+N \i Ctrl+N \i (none)
+ \row \i Delete \i Del \i Del, Meta+D \i Del, Ctrl+D \i Del, Ctrl+D \i Del
+ \row \i Cut \i Ctrl+X, Shift+Del \i Ctrl+X \i Ctrl+X, F20, Shift+Del \i Ctrl+X, F20, Shift+Del \i Ctrl+X
+ \row \i Copy \i Ctrl+C, Ctrl+Ins \i Ctrl+C \i Ctrl+C, F16, Ctrl+Ins \i Ctrl+C, F16, Ctrl+Ins \i Ctrl+C
+ \row \i Paste \i Ctrl+V, Shift+Ins \i Ctrl+V \i Ctrl+V, F18, Shift+Ins \i Ctrl+V, F18, Shift+Ins \i Ctrl+V
+ \row \i Preferences \i \i Ctrl+, \i \i \i (none)
+ \row \i Undo \i Ctrl+Z, Alt+Backspace \i Ctrl+Z \i Ctrl+Z, F14 \i Ctrl+Z, F14 \i Ctrl+Z
+ \row \i Redo \i Ctrl+Y, Shift+Ctrl+Z, Alt+Shift+Backspace \i Ctrl+Shift+Z \i Ctrl+Shift+Z \i Ctrl+Shift+Z \i (none)
+ \row \i Back \i Alt+Left, Backspace \i Ctrl+[ \i Alt+Left \i Alt+Left \i (none)
+ \row \i Forward \i Alt+Right, Shift+Backspace \i Ctrl+] \i Alt+Right \i Alt+Right \i (none)
+ \row \i Refresh \i F5 \i F5 \i F5 \i Ctrl+R, F5 \i (none)
+ \row \i ZoomIn \i Ctrl+Plus \i Ctrl+Plus \i Ctrl+Plus \i Ctrl+Plus \i (none)
+ \row \i ZoomOut \i Ctrl+Minus \i Ctrl+Minus \i Ctrl+Minus \i Ctrl+Minus \i (none)
+ \row \i Print \i Ctrl+P \i Ctrl+P \i Ctrl+P \i Ctrl+P \i (none)
+ \row \i AddTab \i Ctrl+T \i Ctrl+T \i Ctrl+Shift+N, Ctrl+T \i Ctrl+T \i (none)
+ \row \i NextChild \i Ctrl+Tab, Forward, Ctrl+F6 \i Ctrl+}, Forward, Ctrl+Tab \i Ctrl+Tab, Forward, Ctrl+Comma \i Ctrl+Tab, Forward \i (none)
+ \row \i PreviousChild \i Ctrl+Shift+Tab, Back, Ctrl+Shift+F6 \i Ctrl+{, Back, Ctrl+Shift+Tab \i Ctrl+Shift+Tab, Back, Ctrl+Period \i Ctrl+Shift+Tab, Back \i (none)
+ \row \i Find \i Ctrl+F \i Ctrl+F \i Ctrl+F \i Ctrl+F \i (none)
+ \row \i FindNext \i F3, Ctrl+G \i Ctrl+G \i F3 \i Ctrl+G, F3 \i (none)
+ \row \i FindPrevious \i Shift+F3, Ctrl+Shift+G \i Ctrl+Shift+G \i Shift+F3 \i Ctrl+Shift+G, Shift+F3 \i (none)
+ \row \i Replace \i Ctrl+H \i (none) \i Ctrl+R \i Ctrl+H \i (none)
+ \row \i SelectAll \i Ctrl+A \i Ctrl+A \i Ctrl+A \i Ctrl+A \i (none)
+ \row \i Bold \i Ctrl+B \i Ctrl+B \i Ctrl+B \i Ctrl+B \i (none)
+ \row \i Italic \i Ctrl+I \i Ctrl+I \i Ctrl+I \i Ctrl+I \i (none)
+ \row \i Underline \i Ctrl+U \i Ctrl+U \i Ctrl+U \i Ctrl+U \i (none)
+ \row \i MoveToNextChar \i Right \i Right \i Right \i Right \i Right
+ \row \i MoveToPreviousChar \i Left \i Left \i Left \i Left \i Left
+ \row \i MoveToNextWord \i Ctrl+Right \i Alt+Right \i Ctrl+Right \i Ctrl+Right \i Ctrl+Right
+ \row \i MoveToPreviousWord \i Ctrl+Left \i Alt+Left \i Ctrl+Left \i Ctrl+Left \i Ctrl+Left
+ \row \i MoveToNextLine \i Down \i Down \i Down \i Down \i Down
+ \row \i MoveToPreviousLine \i Up \i Up \i Up \i Up \i Up
+ \row \i MoveToNextPage \i PgDown \i PgDown, Alt+PgDown, Meta+Down, Meta+PgDown\i PgDown \i PgDown \i PgDown
+ \row \i MoveToPreviousPage \i PgUp \i PgUp, Alt+PgUp, Meta+Up, Meta+PgUp \i PgUp \i PgUp \i PgUp
+ \row \i MoveToStartOfLine \i Home \i Ctrl+Left, Meta+Left \i Home \i Home \i Home
+ \row \i MoveToEndOfLine \i End \i Ctrl+Right, Meta+Right \i End \i End \i End
+ \row \i MoveToStartOfBlock \i (none) \i Alt+Up, Meta+A \i (none) \i (none) \i (none)
+ \row \i MoveToEndOfBlock \i (none) \i Alt+Down, Meta+E \i (none) \i (none) \i (none)
+ \row \i MoveToStartOfDocument\i Ctrl+Home \i Ctrl+Up, Home \i Ctrl+Home \i Ctrl+Home \i Ctrl+Home
+ \row \i MoveToEndOfDocument \i Ctrl+End \i Ctrl+Down, End \i Ctrl+End \i Ctrl+End \i Ctrl+End
+ \row \i SelectNextChar \i Shift+Right \i Shift+Right \i Shift+Right \i Shift+Right \i Shift+Right
+ \row \i SelectPreviousChar \i Shift+Left \i Shift+Left \i Shift+Left \i Shift+Left \i Shift+Left
+ \row \i SelectNextWord \i Ctrl+Shift+Right \i Alt+Shift+Right \i Ctrl+Shift+Right \i Ctrl+Shift+Right \i Ctrl+Shift+Right
+ \row \i SelectPreviousWord \i Ctrl+Shift+Left \i Alt+Shift+Left \i Ctrl+Shift+Left \i Ctrl+Shift+Left \i Ctrl+Shift+Left
+ \row \i SelectNextLine \i Shift+Down \i Shift+Down \i Shift+Down \i Shift+Down \i Shift+Down
+ \row \i SelectPreviousLine \i Shift+Up \i Shift+Up \i Shift+Up \i Shift+Up \i Shift+Up
+ \row \i SelectNextPage \i Shift+PgDown \i Shift+PgDown \i Shift+PgDown \i Shift+PgDown \i Shift+PgDown
+ \row \i SelectPreviousPage \i Shift+PgUp \i Shift+PgUp \i Shift+PgUp \i Shift+PgUp \i Shift+PgUp
+ \row \i SelectStartOfLine \i Shift+Home \i Ctrl+Shift+Left \i Shift+Home \i Shift+Home \i Shift+Home
+ \row \i SelectEndOfLine \i Shift+End \i Ctrl+Shift+Right \i Shift+End \i Shift+End \i Shift+End
+ \row \i SelectStartOfBlock \i (none) \i Alt+Shift+Up, Meta+Shift+A \i (none) \i (none) \i (none)
+ \row \i SelectEndOfBlock \i (none) \i Alt+Shift+Down, Meta+Shift+E \i (none) \i (none) \i (none)
+ \row \i SelectStartOfDocument\i Ctrl+Shift+Home \i Ctrl+Shift+Up, Shift+Home \i Ctrl+Shift+Home\i Ctrl+Shift+Home \i Ctrl+Shift+Home
+ \row \i SelectEndOfDocument \i Ctrl+Shift+End \i Ctrl+Shift+Down, Shift+End \i Ctrl+Shift+End \i Ctrl+Shift+End \i Ctrl+Shift+End
+ \row \i DeleteStartOfWord \i Ctrl+Backspace \i Alt+Backspace \i Ctrl+Backspace \i Ctrl+Backspace \i (none)
+ \row \i DeleteEndOfWord \i Ctrl+Del \i (none) \i Ctrl+Del \i Ctrl+Del \i (none)
+ \row \i DeleteEndOfLine \i (none) \i (none) \i Ctrl+K \i Ctrl+K \i (none)
+ \row \i InsertParagraphSeparator \i Enter \i Enter \i Enter \i Enter \i (none)
+ \row \i InsertLineSeparator \i Shift+Enter \i Meta+Enter \i Shift+Enter \i Shift+Enter \i (none)
+ \endtable
+
+ Note that, since the key sequences used for the standard shortcuts differ
+ between platforms, you still need to test your shortcuts on each platform
+ to ensure that you do not unintentionally assign the same key sequence to
+ many actions.
+
+ \section1 Keyboard Layout Issues
+
+ Many key sequence specifications are chosen by developers based on the
+ layout of certain types of keyboard, rather than choosing keys that
+ represent the first letter of an action's name, such as \key{Ctrl S}
+ ("Ctrl+S") or \key{Ctrl C} ("Ctrl+C").
+ Additionally, because certain symbols can only be entered with the
+ help of modifier keys on certain keyboard layouts, key sequences intended
+ for use with one keyboard layout may map to a different key, map to no
+ keys at all, or require an additional modifier key to be used on
+ different keyboard layouts.
+
+ For example, the shortcuts, \key{Ctrl plus} and \key{Ctrl minus}, are often
+ used as shortcuts for zoom operations in graphics applications, and these
+ may be specified as "Ctrl++" and "Ctrl+-" respectively. However, the way
+ these shortcuts are specified and interpreted depends on the keyboard layout.
+ Users of Norwegian keyboards will note that the \key{+} and \key{-} keys
+ are not adjacent on the keyboard, but will still be able to activate both
+ shortcuts without needing to press the \key{Shift} key. However, users
+ with British keyboards will need to hold down the \key{Shift} key
+ to enter the \key{+} symbol, making the shortcut effectively the same as
+ "Ctrl+Shift+=".
+
+ Although some developers might resort to fully specifying all the modifiers
+ they use on their keyboards to activate a shortcut, this will also result
+ in unexpected behavior for users of different keyboard layouts.
+
+ For example, a developer using a British keyboard may decide to specify
+ "Ctrl+Shift+=" as the key sequence in order to create a shortcut that
+ coincidentally behaves in the same way as \key{Ctrl plus}. However, the
+ \key{=} key needs to be accessed using the \key{Shift} key on Norwegian
+ keyboard, making the required shortcut effectively \key{Ctrl Shift Shift =}
+ (an impossible key combination).
+
+ As a result, both human-readable strings and hard-coded key codes
+ can both be problematic to use when specifying a key sequence that
+ can be used on a variety of different keyboard layouts. Only the
+ use of \l{QKeySequence::StandardKey} {standard shortcuts}
+ guarantees that the user will be able to use the shortcuts that
+ the developer intended.
+
+ Despite this, we can address this issue by ensuring that human-readable
+ strings are used, making it possible for translations of key sequences to
+ be made for users of different languages. This approach will be successful
+ for users whose keyboards have the most typical layout for the language
+ they are using.
+
+ \section1 GNU Emacs Style Key Sequences
+
+ Key sequences similar to those used in \l{GNU Emacs}, allowing up to four
+ key codes, can be created by using the multiple argument constructor,
+ or by passing a human-readable string of comma-separated key sequences.
+
+ For example, the key sequence, \key{Ctrl X} followed by \key{Ctrl C}, can
+ be specified using either of the following ways:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qkeysequence.cpp 1
+
+ \warning A QApplication instance must have been constructed before a
+ QKeySequence is created; otherwise, your application may crash.
+
+ \sa QShortcut
+*/
+
+/*!
+ \enum QKeySequence::SequenceMatch
+
+ \value NoMatch The key sequences are different; not even partially
+ matching.
+ \value PartialMatch The key sequences match partially, but are not
+ the same.
+ \value ExactMatch The key sequences are the same.
+ \omitvalue Identical
+*/
+
+/*!
+ \enum QKeySequence::SequenceFormat
+
+ \value NativeText The key sequence as a platform specific string.
+ This means that it will be shown translated and on the Mac it will
+ resemble a key sequence from the menu bar. This enum is best used when you
+ want to display the string to the user.
+
+ \value PortableText The key sequence is given in a "portable" format,
+ suitable for reading and writing to a file. In many cases, it will look
+ similar to the native text on Windows and X11.
+*/
+
+static const struct {
+ int key;
+ const char* name;
+} keyname[] = {
+ //: This and all following "incomprehensible" strings in QShortcut context
+ //: are key names. Please use the localized names appearing on actual
+ //: keyboards or whatever is commonly used.
+ { Qt::Key_Space, QT_TRANSLATE_NOOP("QShortcut", "Space") },
+ { Qt::Key_Escape, QT_TRANSLATE_NOOP("QShortcut", "Esc") },
+ { Qt::Key_Tab, QT_TRANSLATE_NOOP("QShortcut", "Tab") },
+ { Qt::Key_Backtab, QT_TRANSLATE_NOOP("QShortcut", "Backtab") },
+ { Qt::Key_Backspace, QT_TRANSLATE_NOOP("QShortcut", "Backspace") },
+ { Qt::Key_Return, QT_TRANSLATE_NOOP("QShortcut", "Return") },
+ { Qt::Key_Enter, QT_TRANSLATE_NOOP("QShortcut", "Enter") },
+ { Qt::Key_Insert, QT_TRANSLATE_NOOP("QShortcut", "Ins") },
+ { Qt::Key_Delete, QT_TRANSLATE_NOOP("QShortcut", "Del") },
+ { Qt::Key_Pause, QT_TRANSLATE_NOOP("QShortcut", "Pause") },
+ { Qt::Key_Print, QT_TRANSLATE_NOOP("QShortcut", "Print") },
+ { Qt::Key_SysReq, QT_TRANSLATE_NOOP("QShortcut", "SysReq") },
+ { Qt::Key_Home, QT_TRANSLATE_NOOP("QShortcut", "Home") },
+ { Qt::Key_End, QT_TRANSLATE_NOOP("QShortcut", "End") },
+ { Qt::Key_Left, QT_TRANSLATE_NOOP("QShortcut", "Left") },
+ { Qt::Key_Up, QT_TRANSLATE_NOOP("QShortcut", "Up") },
+ { Qt::Key_Right, QT_TRANSLATE_NOOP("QShortcut", "Right") },
+ { Qt::Key_Down, QT_TRANSLATE_NOOP("QShortcut", "Down") },
+ { Qt::Key_PageUp, QT_TRANSLATE_NOOP("QShortcut", "PgUp") },
+ { Qt::Key_PageDown, QT_TRANSLATE_NOOP("QShortcut", "PgDown") },
+ { Qt::Key_CapsLock, QT_TRANSLATE_NOOP("QShortcut", "CapsLock") },
+ { Qt::Key_NumLock, QT_TRANSLATE_NOOP("QShortcut", "NumLock") },
+ { Qt::Key_ScrollLock, QT_TRANSLATE_NOOP("QShortcut", "ScrollLock") },
+ { Qt::Key_Menu, QT_TRANSLATE_NOOP("QShortcut", "Menu") },
+ { Qt::Key_Help, QT_TRANSLATE_NOOP("QShortcut", "Help") },
+
+ // Special keys
+ // Includes multimedia, launcher, lan keys ( bluetooth, wireless )
+ // window navigation
+ { Qt::Key_Back, QT_TRANSLATE_NOOP("QShortcut", "Back") },
+ { Qt::Key_Forward, QT_TRANSLATE_NOOP("QShortcut", "Forward") },
+ { Qt::Key_Stop, QT_TRANSLATE_NOOP("QShortcut", "Stop") },
+ { Qt::Key_Refresh, QT_TRANSLATE_NOOP("QShortcut", "Refresh") },
+ { Qt::Key_VolumeDown, QT_TRANSLATE_NOOP("QShortcut", "Volume Down") },
+ { Qt::Key_VolumeMute, QT_TRANSLATE_NOOP("QShortcut", "Volume Mute") },
+ { Qt::Key_VolumeUp, QT_TRANSLATE_NOOP("QShortcut", "Volume Up") },
+ { Qt::Key_BassBoost, QT_TRANSLATE_NOOP("QShortcut", "Bass Boost") },
+ { Qt::Key_BassUp, QT_TRANSLATE_NOOP("QShortcut", "Bass Up") },
+ { Qt::Key_BassDown, QT_TRANSLATE_NOOP("QShortcut", "Bass Down") },
+ { Qt::Key_TrebleUp, QT_TRANSLATE_NOOP("QShortcut", "Treble Up") },
+ { Qt::Key_TrebleDown, QT_TRANSLATE_NOOP("QShortcut", "Treble Down") },
+ { Qt::Key_MediaPlay, QT_TRANSLATE_NOOP("QShortcut", "Media Play") },
+ { Qt::Key_MediaStop, QT_TRANSLATE_NOOP("QShortcut", "Media Stop") },
+ { Qt::Key_MediaPrevious, QT_TRANSLATE_NOOP("QShortcut", "Media Previous") },
+ { Qt::Key_MediaNext, QT_TRANSLATE_NOOP("QShortcut", "Media Next") },
+ { Qt::Key_MediaRecord, QT_TRANSLATE_NOOP("QShortcut", "Media Record") },
+ //: Media player pause button
+ { Qt::Key_MediaPause, QT_TRANSLATE_NOOP("QShortcut", "Media Pause") },
+ //: Media player button to toggle between playing and paused
+ { Qt::Key_MediaTogglePlayPause, QT_TRANSLATE_NOOP("QShortcut", "Toggle Media Play/Pause") },
+ { Qt::Key_HomePage, QT_TRANSLATE_NOOP("QShortcut", "Home Page") },
+ { Qt::Key_Favorites, QT_TRANSLATE_NOOP("QShortcut", "Favorites") },
+ { Qt::Key_Search, QT_TRANSLATE_NOOP("QShortcut", "Search") },
+ { Qt::Key_Standby, QT_TRANSLATE_NOOP("QShortcut", "Standby") },
+ { Qt::Key_OpenUrl, QT_TRANSLATE_NOOP("QShortcut", "Open URL") },
+ { Qt::Key_LaunchMail, QT_TRANSLATE_NOOP("QShortcut", "Launch Mail") },
+ { Qt::Key_LaunchMedia, QT_TRANSLATE_NOOP("QShortcut", "Launch Media") },
+ { Qt::Key_Launch0, QT_TRANSLATE_NOOP("QShortcut", "Launch (0)") },
+ { Qt::Key_Launch1, QT_TRANSLATE_NOOP("QShortcut", "Launch (1)") },
+ { Qt::Key_Launch2, QT_TRANSLATE_NOOP("QShortcut", "Launch (2)") },
+ { Qt::Key_Launch3, QT_TRANSLATE_NOOP("QShortcut", "Launch (3)") },
+ { Qt::Key_Launch4, QT_TRANSLATE_NOOP("QShortcut", "Launch (4)") },
+ { Qt::Key_Launch5, QT_TRANSLATE_NOOP("QShortcut", "Launch (5)") },
+ { Qt::Key_Launch6, QT_TRANSLATE_NOOP("QShortcut", "Launch (6)") },
+ { Qt::Key_Launch7, QT_TRANSLATE_NOOP("QShortcut", "Launch (7)") },
+ { Qt::Key_Launch8, QT_TRANSLATE_NOOP("QShortcut", "Launch (8)") },
+ { Qt::Key_Launch9, QT_TRANSLATE_NOOP("QShortcut", "Launch (9)") },
+ { Qt::Key_LaunchA, QT_TRANSLATE_NOOP("QShortcut", "Launch (A)") },
+ { Qt::Key_LaunchB, QT_TRANSLATE_NOOP("QShortcut", "Launch (B)") },
+ { Qt::Key_LaunchC, QT_TRANSLATE_NOOP("QShortcut", "Launch (C)") },
+ { Qt::Key_LaunchD, QT_TRANSLATE_NOOP("QShortcut", "Launch (D)") },
+ { Qt::Key_LaunchE, QT_TRANSLATE_NOOP("QShortcut", "Launch (E)") },
+ { Qt::Key_LaunchF, QT_TRANSLATE_NOOP("QShortcut", "Launch (F)") },
+ { Qt::Key_MonBrightnessUp, QT_TRANSLATE_NOOP("QShortcut", "Monitor Brightness Up") },
+ { Qt::Key_MonBrightnessDown, QT_TRANSLATE_NOOP("QShortcut", "Monitor Brightness Down") },
+ { Qt::Key_KeyboardLightOnOff, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Light On/Off") },
+ { Qt::Key_KeyboardBrightnessUp, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Brightness Up") },
+ { Qt::Key_KeyboardBrightnessDown, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Brightness Down") },
+ { Qt::Key_PowerOff, QT_TRANSLATE_NOOP("QShortcut", "Power Off") },
+ { Qt::Key_WakeUp, QT_TRANSLATE_NOOP("QShortcut", "Wake Up") },
+ { Qt::Key_Eject, QT_TRANSLATE_NOOP("QShortcut", "Eject") },
+ { Qt::Key_ScreenSaver, QT_TRANSLATE_NOOP("QShortcut", "Screensaver") },
+ { Qt::Key_WWW, QT_TRANSLATE_NOOP("QShortcut", "WWW") },
+ { Qt::Key_Sleep, QT_TRANSLATE_NOOP("QShortcut", "Sleep") },
+ { Qt::Key_LightBulb, QT_TRANSLATE_NOOP("QShortcut", "LightBulb") },
+ { Qt::Key_Shop, QT_TRANSLATE_NOOP("QShortcut", "Shop") },
+ { Qt::Key_History, QT_TRANSLATE_NOOP("QShortcut", "History") },
+ { Qt::Key_AddFavorite, QT_TRANSLATE_NOOP("QShortcut", "Add Favorite") },
+ { Qt::Key_HotLinks, QT_TRANSLATE_NOOP("QShortcut", "Hot Links") },
+ { Qt::Key_BrightnessAdjust, QT_TRANSLATE_NOOP("QShortcut", "Adjust Brightness") },
+ { Qt::Key_Finance, QT_TRANSLATE_NOOP("QShortcut", "Finance") },
+ { Qt::Key_Community, QT_TRANSLATE_NOOP("QShortcut", "Community") },
+ { Qt::Key_AudioRewind, QT_TRANSLATE_NOOP("QShortcut", "Audio Rewind") },
+ { Qt::Key_BackForward, QT_TRANSLATE_NOOP("QShortcut", "Back Forward") },
+ { Qt::Key_ApplicationLeft, QT_TRANSLATE_NOOP("QShortcut", "Application Left") },
+ { Qt::Key_ApplicationRight, QT_TRANSLATE_NOOP("QShortcut", "Application Right") },
+ { Qt::Key_Book, QT_TRANSLATE_NOOP("QShortcut", "Book") },
+ { Qt::Key_CD, QT_TRANSLATE_NOOP("QShortcut", "CD") },
+ { Qt::Key_Calculator, QT_TRANSLATE_NOOP("QShortcut", "Calculator") },
+ { Qt::Key_Clear, QT_TRANSLATE_NOOP("QShortcut", "Clear") },
+ { Qt::Key_ClearGrab, QT_TRANSLATE_NOOP("QShortcut", "Clear Grab") },
+ { Qt::Key_Close, QT_TRANSLATE_NOOP("QShortcut", "Close") },
+ { Qt::Key_Copy, QT_TRANSLATE_NOOP("QShortcut", "Copy") },
+ { Qt::Key_Cut, QT_TRANSLATE_NOOP("QShortcut", "Cut") },
+ { Qt::Key_Display, QT_TRANSLATE_NOOP("QShortcut", "Display") },
+ { Qt::Key_DOS, QT_TRANSLATE_NOOP("QShortcut", "DOS") },
+ { Qt::Key_Documents, QT_TRANSLATE_NOOP("QShortcut", "Documents") },
+ { Qt::Key_Excel, QT_TRANSLATE_NOOP("QShortcut", "Spreadsheet") },
+ { Qt::Key_Explorer, QT_TRANSLATE_NOOP("QShortcut", "Browser") },
+ { Qt::Key_Game, QT_TRANSLATE_NOOP("QShortcut", "Game") },
+ { Qt::Key_Go, QT_TRANSLATE_NOOP("QShortcut", "Go") },
+ { Qt::Key_iTouch, QT_TRANSLATE_NOOP("QShortcut", "iTouch") },
+ { Qt::Key_LogOff, QT_TRANSLATE_NOOP("QShortcut", "Logoff") },
+ { Qt::Key_Market, QT_TRANSLATE_NOOP("QShortcut", "Market") },
+ { Qt::Key_Meeting, QT_TRANSLATE_NOOP("QShortcut", "Meeting") },
+ { Qt::Key_MenuKB, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Menu") },
+ { Qt::Key_MenuPB, QT_TRANSLATE_NOOP("QShortcut", "Menu PB") },
+ { Qt::Key_MySites, QT_TRANSLATE_NOOP("QShortcut", "My Sites") },
+ { Qt::Key_News, QT_TRANSLATE_NOOP("QShortcut", "News") },
+ { Qt::Key_OfficeHome, QT_TRANSLATE_NOOP("QShortcut", "Home Office") },
+ { Qt::Key_Option, QT_TRANSLATE_NOOP("QShortcut", "Option") },
+ { Qt::Key_Paste, QT_TRANSLATE_NOOP("QShortcut", "Paste") },
+ { Qt::Key_Phone, QT_TRANSLATE_NOOP("QShortcut", "Phone") },
+ { Qt::Key_Reply, QT_TRANSLATE_NOOP("QShortcut", "Reply") },
+ { Qt::Key_Reload, QT_TRANSLATE_NOOP("QShortcut", "Reload") },
+ { Qt::Key_RotateWindows, QT_TRANSLATE_NOOP("QShortcut", "Rotate Windows") },
+ { Qt::Key_RotationPB, QT_TRANSLATE_NOOP("QShortcut", "Rotation PB") },
+ { Qt::Key_RotationKB, QT_TRANSLATE_NOOP("QShortcut", "Rotation KB") },
+ { Qt::Key_Save, QT_TRANSLATE_NOOP("QShortcut", "Save") },
+ { Qt::Key_Send, QT_TRANSLATE_NOOP("QShortcut", "Send") },
+ { Qt::Key_Spell, QT_TRANSLATE_NOOP("QShortcut", "Spellchecker") },
+ { Qt::Key_SplitScreen, QT_TRANSLATE_NOOP("QShortcut", "Split Screen") },
+ { Qt::Key_Support, QT_TRANSLATE_NOOP("QShortcut", "Support") },
+ { Qt::Key_TaskPane, QT_TRANSLATE_NOOP("QShortcut", "Task Panel") },
+ { Qt::Key_Terminal, QT_TRANSLATE_NOOP("QShortcut", "Terminal") },
+ { Qt::Key_Tools, QT_TRANSLATE_NOOP("QShortcut", "Tools") },
+ { Qt::Key_Travel, QT_TRANSLATE_NOOP("QShortcut", "Travel") },
+ { Qt::Key_Video, QT_TRANSLATE_NOOP("QShortcut", "Video") },
+ { Qt::Key_Word, QT_TRANSLATE_NOOP("QShortcut", "Word Processor") },
+ { Qt::Key_Xfer, QT_TRANSLATE_NOOP("QShortcut", "XFer") },
+ { Qt::Key_ZoomIn, QT_TRANSLATE_NOOP("QShortcut", "Zoom In") },
+ { Qt::Key_ZoomOut, QT_TRANSLATE_NOOP("QShortcut", "Zoom Out") },
+ { Qt::Key_Away, QT_TRANSLATE_NOOP("QShortcut", "Away") },
+ { Qt::Key_Messenger, QT_TRANSLATE_NOOP("QShortcut", "Messenger") },
+ { Qt::Key_WebCam, QT_TRANSLATE_NOOP("QShortcut", "WebCam") },
+ { Qt::Key_MailForward, QT_TRANSLATE_NOOP("QShortcut", "Mail Forward") },
+ { Qt::Key_Pictures, QT_TRANSLATE_NOOP("QShortcut", "Pictures") },
+ { Qt::Key_Music, QT_TRANSLATE_NOOP("QShortcut", "Music") },
+ { Qt::Key_Battery, QT_TRANSLATE_NOOP("QShortcut", "Battery") },
+ { Qt::Key_Bluetooth, QT_TRANSLATE_NOOP("QShortcut", "Bluetooth") },
+ { Qt::Key_WLAN, QT_TRANSLATE_NOOP("QShortcut", "Wireless") },
+ { Qt::Key_UWB, QT_TRANSLATE_NOOP("QShortcut", "Ultra Wide Band") },
+ { Qt::Key_AudioForward, QT_TRANSLATE_NOOP("QShortcut", "Audio Forward") },
+ { Qt::Key_AudioRepeat, QT_TRANSLATE_NOOP("QShortcut", "Audio Repeat") },
+ { Qt::Key_AudioRandomPlay, QT_TRANSLATE_NOOP("QShortcut", "Audio Random Play") },
+ { Qt::Key_Subtitle, QT_TRANSLATE_NOOP("QShortcut", "Subtitle") },
+ { Qt::Key_AudioCycleTrack, QT_TRANSLATE_NOOP("QShortcut", "Audio Cycle Track") },
+ { Qt::Key_Time, QT_TRANSLATE_NOOP("QShortcut", "Time") },
+ { Qt::Key_Select, QT_TRANSLATE_NOOP("QShortcut", "Select") },
+ { Qt::Key_View, QT_TRANSLATE_NOOP("QShortcut", "View") },
+ { Qt::Key_TopMenu, QT_TRANSLATE_NOOP("QShortcut", "Top Menu") },
+ { Qt::Key_Suspend, QT_TRANSLATE_NOOP("QShortcut", "Suspend") },
+ { Qt::Key_Hibernate, QT_TRANSLATE_NOOP("QShortcut", "Hibernate") },
+
+ // --------------------------------------------------------------
+ // More consistent namings
+ { Qt::Key_Print, QT_TRANSLATE_NOOP("QShortcut", "Print Screen") },
+ { Qt::Key_PageUp, QT_TRANSLATE_NOOP("QShortcut", "Page Up") },
+ { Qt::Key_PageDown, QT_TRANSLATE_NOOP("QShortcut", "Page Down") },
+ { Qt::Key_CapsLock, QT_TRANSLATE_NOOP("QShortcut", "Caps Lock") },
+ { Qt::Key_NumLock, QT_TRANSLATE_NOOP("QShortcut", "Num Lock") },
+ { Qt::Key_NumLock, QT_TRANSLATE_NOOP("QShortcut", "Number Lock") },
+ { Qt::Key_ScrollLock, QT_TRANSLATE_NOOP("QShortcut", "Scroll Lock") },
+ { Qt::Key_Insert, QT_TRANSLATE_NOOP("QShortcut", "Insert") },
+ { Qt::Key_Delete, QT_TRANSLATE_NOOP("QShortcut", "Delete") },
+ { Qt::Key_Escape, QT_TRANSLATE_NOOP("QShortcut", "Escape") },
+ { Qt::Key_SysReq, QT_TRANSLATE_NOOP("QShortcut", "System Request") },
+
+ // --------------------------------------------------------------
+ // Keypad navigation keys
+ { Qt::Key_Select, QT_TRANSLATE_NOOP("QShortcut", "Select") },
+ { Qt::Key_Yes, QT_TRANSLATE_NOOP("QShortcut", "Yes") },
+ { Qt::Key_No, QT_TRANSLATE_NOOP("QShortcut", "No") },
+
+ // --------------------------------------------------------------
+ // Device keys
+ { Qt::Key_Context1, QT_TRANSLATE_NOOP("QShortcut", "Context1") },
+ { Qt::Key_Context2, QT_TRANSLATE_NOOP("QShortcut", "Context2") },
+ { Qt::Key_Context3, QT_TRANSLATE_NOOP("QShortcut", "Context3") },
+ { Qt::Key_Context4, QT_TRANSLATE_NOOP("QShortcut", "Context4") },
+ //: Button to start a call (note: a separate button is used to end the call)
+ { Qt::Key_Call, QT_TRANSLATE_NOOP("QShortcut", "Call") },
+ //: Button to end a call (note: a separate button is used to start the call)
+ { Qt::Key_Hangup, QT_TRANSLATE_NOOP("QShortcut", "Hangup") },
+ //: Button that will hang up if we're in call, or make a call if we're not.
+ { Qt::Key_ToggleCallHangup, QT_TRANSLATE_NOOP("QShortcut", "Toggle Call/Hangup") },
+ { Qt::Key_Flip, QT_TRANSLATE_NOOP("QShortcut", "Flip") },
+ //: Button to trigger voice dialing
+ { Qt::Key_VoiceDial, QT_TRANSLATE_NOOP("QShortcut", "Voice Dial") },
+ //: Button to redial the last number called
+ { Qt::Key_LastNumberRedial, QT_TRANSLATE_NOOP("QShortcut", "Last Number Redial") },
+ //: Button to trigger the camera shutter (take a picture)
+ { Qt::Key_Camera, QT_TRANSLATE_NOOP("QShortcut", "Camera Shutter") },
+ //: Button to focus the camera
+ { Qt::Key_CameraFocus, QT_TRANSLATE_NOOP("QShortcut", "Camera Focus") },
+
+ // --------------------------------------------------------------
+ // Japanese keyboard support
+ { Qt::Key_Kanji, QT_TRANSLATE_NOOP("QShortcut", "Kanji") },
+ { Qt::Key_Muhenkan, QT_TRANSLATE_NOOP("QShortcut", "Muhenkan") },
+ { Qt::Key_Henkan, QT_TRANSLATE_NOOP("QShortcut", "Henkan") },
+ { Qt::Key_Romaji, QT_TRANSLATE_NOOP("QShortcut", "Romaji") },
+ { Qt::Key_Hiragana, QT_TRANSLATE_NOOP("QShortcut", "Hiragana") },
+ { Qt::Key_Katakana, QT_TRANSLATE_NOOP("QShortcut", "Katakana") },
+ { Qt::Key_Hiragana_Katakana,QT_TRANSLATE_NOOP("QShortcut", "Hiragana Katakana") },
+ { Qt::Key_Zenkaku, QT_TRANSLATE_NOOP("QShortcut", "Zenkaku") },
+ { Qt::Key_Hankaku, QT_TRANSLATE_NOOP("QShortcut", "Hankaku") },
+ { Qt::Key_Zenkaku_Hankaku, QT_TRANSLATE_NOOP("QShortcut", "Zenkaku Hankaku") },
+ { Qt::Key_Touroku, QT_TRANSLATE_NOOP("QShortcut", "Touroku") },
+ { Qt::Key_Massyo, QT_TRANSLATE_NOOP("QShortcut", "Massyo") },
+ { Qt::Key_Kana_Lock, QT_TRANSLATE_NOOP("QShortcut", "Kana Lock") },
+ { Qt::Key_Kana_Shift, QT_TRANSLATE_NOOP("QShortcut", "Kana Shift") },
+ { Qt::Key_Eisu_Shift, QT_TRANSLATE_NOOP("QShortcut", "Eisu Shift") },
+ { Qt::Key_Eisu_toggle, QT_TRANSLATE_NOOP("QShortcut", "Eisu toggle") },
+ { Qt::Key_Codeinput, QT_TRANSLATE_NOOP("QShortcut", "Code input") },
+ { Qt::Key_MultipleCandidate,QT_TRANSLATE_NOOP("QShortcut", "Multiple Candidate") },
+ { Qt::Key_PreviousCandidate,QT_TRANSLATE_NOOP("QShortcut", "Previous Candidate") },
+
+ // --------------------------------------------------------------
+ // Korean keyboard support
+ { Qt::Key_Hangul, QT_TRANSLATE_NOOP("QShortcut", "Hangul") },
+ { Qt::Key_Hangul_Start, QT_TRANSLATE_NOOP("QShortcut", "Hangul Start") },
+ { Qt::Key_Hangul_End, QT_TRANSLATE_NOOP("QShortcut", "Hangul End") },
+ { Qt::Key_Hangul_Hanja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Hanja") },
+ { Qt::Key_Hangul_Jamo, QT_TRANSLATE_NOOP("QShortcut", "Hangul Jamo") },
+ { Qt::Key_Hangul_Romaja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Romaja") },
+ { Qt::Key_Hangul_Jeonja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Jeonja") },
+ { Qt::Key_Hangul_Banja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Banja") },
+ { Qt::Key_Hangul_PreHanja, QT_TRANSLATE_NOOP("QShortcut", "Hangul PreHanja") },
+ { Qt::Key_Hangul_PostHanja,QT_TRANSLATE_NOOP("QShortcut", "Hangul PostHanja") },
+ { Qt::Key_Hangul_Special, QT_TRANSLATE_NOOP("QShortcut", "Hangul Special") },
+
+ { 0, 0 }
+};
+
+//Table of key bindings. It must be sorted on key sequence.
+//A priority of 1 indicates that this is the primary key binding when multiple are defined.
+
+const QKeyBinding QKeySequencePrivate::keyBindings[] = {
+// StandardKey Priority Key Sequence Platforms
+ {QKeySequence::Back, 0, Qt::Key_Backspace, QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::InsertParagraphSeparator,0, Qt::Key_Return, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::InsertParagraphSeparator,0, Qt::Key_Enter, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Delete, 1, Qt::Key_Delete, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::MoveToStartOfLine, 0, Qt::Key_Home, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::MoveToStartOfDocument, 0, Qt::Key_Home, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::MoveToEndOfLine, 0, Qt::Key_End, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::MoveToEndOfDocument, 0, Qt::Key_End, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::MoveToPreviousChar, 0, Qt::Key_Left, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::MoveToPreviousLine, 0, Qt::Key_Up, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::MoveToNextChar, 0, Qt::Key_Right, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::MoveToNextLine, 0, Qt::Key_Down, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::MoveToPreviousPage, 1, Qt::Key_PageUp, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::MoveToNextPage, 1, Qt::Key_PageDown, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::HelpContents, 0, Qt::Key_F1, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
+ {QKeySequence::HelpContents, 0, Qt::Key_F2, QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::FindNext, 0, Qt::Key_F3, QGuiApplicationPrivate::KB_X11},
+ {QKeySequence::FindNext, 1, Qt::Key_F3, QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::Refresh, 0, Qt::Key_F5, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
+ {QKeySequence::Undo, 0, Qt::Key_F14, QGuiApplicationPrivate::KB_X11}, //Undo on sun keyboards
+ {QKeySequence::Copy, 0, Qt::Key_F16, QGuiApplicationPrivate::KB_X11}, //Copy on sun keyboards
+ {QKeySequence::Paste, 0, Qt::Key_F18, QGuiApplicationPrivate::KB_X11}, //Paste on sun keyboards
+ {QKeySequence::Cut, 0, Qt::Key_F20, QGuiApplicationPrivate::KB_X11}, //Cut on sun keyboards
+ {QKeySequence::PreviousChild, 0, Qt::Key_Back, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::NextChild, 0, Qt::Key_Forward, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Forward, 0, Qt::SHIFT | Qt::Key_Backspace, QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::Delete, 0, Qt::SHIFT | Qt::Key_Backspace, QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::InsertLineSeparator, 0, Qt::SHIFT | Qt::Key_Return, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::InsertLineSeparator, 0, Qt::SHIFT | Qt::Key_Enter, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Paste, 0, Qt::SHIFT | Qt::Key_Insert, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
+ {QKeySequence::Cut, 0, Qt::SHIFT | Qt::Key_Delete, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11}, //## Check if this should work on mac
+ {QKeySequence::SelectStartOfLine, 0, Qt::SHIFT | Qt::Key_Home, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::SelectStartOfDocument, 0, Qt::SHIFT | Qt::Key_Home, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::SelectEndOfLine, 0, Qt::SHIFT | Qt::Key_End, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::SelectEndOfDocument, 0, Qt::SHIFT | Qt::Key_End, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::SelectPreviousChar, 0, Qt::SHIFT | Qt::Key_Left, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::SelectPreviousLine, 0, Qt::SHIFT | Qt::Key_Up, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::SelectNextChar, 0, Qt::SHIFT | Qt::Key_Right, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::SelectNextLine, 0, Qt::SHIFT | Qt::Key_Down, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::SelectPreviousPage, 0, Qt::SHIFT | Qt::Key_PageUp, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::SelectNextPage, 0, Qt::SHIFT | Qt::Key_PageDown, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::WhatsThis, 1, Qt::SHIFT | Qt::Key_F1, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::FindPrevious, 0, Qt::SHIFT | Qt::Key_F3, QGuiApplicationPrivate::KB_X11},
+ {QKeySequence::FindPrevious, 1, Qt::SHIFT | Qt::Key_F3, QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::ZoomIn, 1, Qt::CTRL | Qt::Key_Plus, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_Comma, QGuiApplicationPrivate::KB_KDE},
+ {QKeySequence::Preferences, 0, Qt::CTRL | Qt::Key_Comma, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::ZoomOut, 1, Qt::CTRL | Qt::Key_Minus, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::Key_Period, QGuiApplicationPrivate::KB_KDE},
+ {QKeySequence::HelpContents, 1, Qt::CTRL | Qt::Key_Question, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::SelectAll, 1, Qt::CTRL | Qt::Key_A, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Bold, 1, Qt::CTRL | Qt::Key_B, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Copy, 1, Qt::CTRL | Qt::Key_C, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Delete, 0, Qt::CTRL | Qt::Key_D, QGuiApplicationPrivate::KB_X11}, //emacs (line edit only)
+ {QKeySequence::Find, 0, Qt::CTRL | Qt::Key_F, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::FindNext, 1, Qt::CTRL | Qt::Key_G, QGuiApplicationPrivate::KB_Gnome | QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::FindNext, 0, Qt::CTRL | Qt::Key_G, QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_H, QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_H, QGuiApplicationPrivate::KB_Gnome},
+ {QKeySequence::Italic, 0, Qt::CTRL | Qt::Key_I, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::DeleteEndOfLine, 0, Qt::CTRL | Qt::Key_K, QGuiApplicationPrivate::KB_X11}, //emacs (line edit only)
+ {QKeySequence::New, 1, Qt::CTRL | Qt::Key_N, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Open, 1, Qt::CTRL | Qt::Key_O, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Print, 1, Qt::CTRL | Qt::Key_P, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Quit, 0, Qt::CTRL | Qt::Key_Q, QGuiApplicationPrivate::KB_Gnome | QGuiApplicationPrivate::KB_KDE | QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::Refresh, 1, Qt::CTRL | Qt::Key_R, QGuiApplicationPrivate::KB_Gnome | QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_R, QGuiApplicationPrivate::KB_KDE},
+ {QKeySequence::Save, 1, Qt::CTRL | Qt::Key_S, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::AddTab, 0, Qt::CTRL | Qt::Key_T, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Underline, 1, Qt::CTRL | Qt::Key_U, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Paste, 1, Qt::CTRL | Qt::Key_V, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Close, 0, Qt::CTRL | Qt::Key_W, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
+ {QKeySequence::Close, 1, Qt::CTRL | Qt::Key_W, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::Cut, 1, Qt::CTRL | Qt::Key_X, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Redo, 1, Qt::CTRL | Qt::Key_Y, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::Undo, 1, Qt::CTRL | Qt::Key_Z, QGuiApplicationPrivate::KB_All},
+ {QKeySequence::Back, 1, Qt::CTRL | Qt::Key_BracketLeft, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::Forward, 1, Qt::CTRL | Qt::Key_BracketRight, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::PreviousChild, 1, Qt::CTRL | Qt::Key_BraceLeft, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::NextChild, 1, Qt::CTRL | Qt::Key_BraceRight, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::NextChild, 1, Qt::CTRL | Qt::Key_Tab, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
+ {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_Tab, QGuiApplicationPrivate::KB_Mac}, //different priority from above
+ {QKeySequence::DeleteStartOfWord, 0, Qt::CTRL | Qt::Key_Backspace, QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::Copy, 0, Qt::CTRL | Qt::Key_Insert, QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::DeleteEndOfWord, 0, Qt::CTRL | Qt::Key_Delete, QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::MoveToStartOfDocument, 0, Qt::CTRL | Qt::Key_Home, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::MoveToEndOfDocument, 0, Qt::CTRL | Qt::Key_End, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::Back, 0, Qt::CTRL | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::MoveToPreviousWord, 0, Qt::CTRL | Qt::Key_Left, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::MoveToStartOfLine, 0, Qt::CTRL | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac },
+ {QKeySequence::MoveToStartOfDocument, 1, Qt::CTRL | Qt::Key_Up, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::Forward, 0, Qt::CTRL | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::MoveToEndOfLine, 0, Qt::CTRL | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac },
+ {QKeySequence::MoveToNextWord, 0, Qt::CTRL | Qt::Key_Right, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::MoveToEndOfDocument, 1, Qt::CTRL | Qt::Key_Down, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::Close, 1, Qt::CTRL | Qt::Key_F4, QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::Close, 0, Qt::CTRL | Qt::Key_F4, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_F6, QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::FindPrevious, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_G, QGuiApplicationPrivate::KB_Gnome | QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::FindPrevious, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_G, QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::AddTab, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_N, QGuiApplicationPrivate::KB_KDE},
+ {QKeySequence::SaveAs, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_S, QGuiApplicationPrivate::KB_Gnome | QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::PreviousChild, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
+ {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, QGuiApplicationPrivate::KB_Mac },//different priority from above
+ {QKeySequence::Paste, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Insert, QGuiApplicationPrivate::KB_X11},
+ {QKeySequence::SelectStartOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Home, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::SelectEndOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_End, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::SelectPreviousWord, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Left, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::SelectStartOfLine, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac },
+ {QKeySequence::SelectStartOfDocument, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Up, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::SelectNextWord, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Right, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11 | QGuiApplicationPrivate::KB_S60},
+ {QKeySequence::SelectEndOfLine, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac },
+ {QKeySequence::SelectEndOfDocument, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Down, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_F6, QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::Undo, 0, Qt::ALT | Qt::Key_Backspace, QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::DeleteStartOfWord, 0, Qt::ALT | Qt::Key_Backspace, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::DeleteEndOfWord, 0, Qt::ALT | Qt::Key_Delete, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::Back, 1, Qt::ALT | Qt::Key_Left, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
+ {QKeySequence::MoveToPreviousWord, 0, Qt::ALT | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::MoveToStartOfBlock, 0, Qt::ALT | Qt::Key_Up, QGuiApplicationPrivate::KB_Mac}, //mac only
+ {QKeySequence::MoveToNextWord, 0, Qt::ALT | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::Forward, 1, Qt::ALT | Qt::Key_Right, QGuiApplicationPrivate::KB_Win | QGuiApplicationPrivate::KB_X11},
+ {QKeySequence::MoveToEndOfBlock, 0, Qt::ALT | Qt::Key_Down, QGuiApplicationPrivate::KB_Mac}, //mac only
+ {QKeySequence::MoveToPreviousPage, 0, Qt::ALT | Qt::Key_PageUp, QGuiApplicationPrivate::KB_Mac },
+ {QKeySequence::MoveToNextPage, 0, Qt::ALT | Qt::Key_PageDown, QGuiApplicationPrivate::KB_Mac },
+ {QKeySequence::Redo, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Backspace,QGuiApplicationPrivate::KB_Win},
+ {QKeySequence::SelectPreviousWord, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::SelectStartOfBlock, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Up, QGuiApplicationPrivate::KB_Mac}, //mac only
+ {QKeySequence::SelectNextWord, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::SelectEndOfBlock, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Down, QGuiApplicationPrivate::KB_Mac}, //mac only
+ {QKeySequence::MoveToStartOfBlock, 0, Qt::META | Qt::Key_A, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::Delete, 0, Qt::META | Qt::Key_D, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::MoveToEndOfBlock, 0, Qt::META | Qt::Key_E, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::InsertLineSeparator, 0, Qt::META | Qt::Key_Return, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::InsertLineSeparator, 0, Qt::META | Qt::Key_Enter, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::MoveToStartOfLine, 0, Qt::META | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::MoveToPreviousPage, 0, Qt::META | Qt::Key_Up, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::MoveToEndOfLine, 0, Qt::META | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::MoveToNextPage, 0, Qt::META | Qt::Key_Down, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::MoveToPreviousPage, 0, Qt::META | Qt::Key_PageUp, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::MoveToNextPage, 0, Qt::META | Qt::Key_PageDown, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::SelectStartOfBlock, 0, Qt::META | Qt::SHIFT | Qt::Key_A, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::SelectEndOfBlock, 0, Qt::META | Qt::SHIFT | Qt::Key_E, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::SelectStartOfLine, 0, Qt::META | Qt::SHIFT | Qt::Key_Left, QGuiApplicationPrivate::KB_Mac},
+ {QKeySequence::SelectEndOfLine, 0, Qt::META | Qt::SHIFT | Qt::Key_Right, QGuiApplicationPrivate::KB_Mac}
+};
+
+const uint QKeySequencePrivate::numberOfKeyBindings = sizeof(QKeySequencePrivate::keyBindings)/(sizeof(QKeyBinding));
+
+
+/*!
+ \enum QKeySequence::StandardKey
+ \since 4.2
+
+ This enum represent standard key bindings. They can be used to
+ assign platform dependent keyboard shortcuts to a QAction.
+
+ Note that the key bindings are platform dependent. The currently
+ bound shortcuts can be queried using keyBindings().
+
+ \value AddTab Add new tab.
+ \value Back Navigate back.
+ \value Bold Bold text.
+ \value Close Close document/tab.
+ \value Copy Copy.
+ \value Cut Cut.
+ \value Delete Delete.
+ \value DeleteEndOfLine Delete end of line.
+ \value DeleteEndOfWord Delete word from the end of the cursor.
+ \value DeleteStartOfWord Delete the beginning of a word up to the cursor.
+ \value Find Find in document.
+ \value FindNext Find next result.
+ \value FindPrevious Find previous result.
+ \value Forward Navigate forward.
+ \value HelpContents Open help contents.
+ \value InsertLineSeparator Insert a new line.
+ \value InsertParagraphSeparator Insert a new paragraph.
+ \value Italic Italic text.
+ \value MoveToEndOfBlock Move cursor to end of block. This shortcut is only used on the OS X.
+ \value MoveToEndOfDocument Move cursor to end of document.
+ \value MoveToEndOfLine Move cursor to end of line.
+ \value MoveToNextChar Move cursor to next character.
+ \value MoveToNextLine Move cursor to next line.
+ \value MoveToNextPage Move cursor to next page.
+ \value MoveToNextWord Move cursor to next word.
+ \value MoveToPreviousChar Move cursor to previous character.
+ \value MoveToPreviousLine Move cursor to previous line.
+ \value MoveToPreviousPage Move cursor to previous page.
+ \value MoveToPreviousWord Move cursor to previous word.
+ \value MoveToStartOfBlock Move cursor to start of a block. This shortcut is only used on OS X.
+ \value MoveToStartOfDocument Move cursor to start of document.
+ \value MoveToStartOfLine Move cursor to start of line.
+ \value New Create new document.
+ \value NextChild Navigate to next tab or child window.
+ \value Open Open document.
+ \value Paste Paste.
+ \value Preferences Open the preferences dialog.
+ \value PreviousChild Navigate to previous tab or child window.
+ \value Print Print document.
+ \value Quit Quit the application.
+ \value Redo Redo.
+ \value Refresh Refresh or reload current document.
+ \value Replace Find and replace.
+ \value SaveAs Save document after prompting the user for a file name.
+ \value Save Save document.
+ \value SelectAll Select all text.
+ \value SelectEndOfBlock Extend selection to the end of a text block. This shortcut is only used on OS X.
+ \value SelectEndOfDocument Extend selection to end of document.
+ \value SelectEndOfLine Extend selection to end of line.
+ \value SelectNextChar Extend selection to next character.
+ \value SelectNextLine Extend selection to next line.
+ \value SelectNextPage Extend selection to next page.
+ \value SelectNextWord Extend selection to next word.
+ \value SelectPreviousChar Extend selection to previous character.
+ \value SelectPreviousLine Extend selection to previous line.
+ \value SelectPreviousPage Extend selection to previous page.
+ \value SelectPreviousWord Extend selection to previous word.
+ \value SelectStartOfBlock Extend selection to the start of a text block. This shortcut is only used on OS X.
+ \value SelectStartOfDocument Extend selection to start of document.
+ \value SelectStartOfLine Extend selection to start of line.
+ \value Underline Underline text.
+ \value Undo Undo.
+ \value UnknownKey Unbound key.
+ \value WhatsThis Activate whats this.
+ \value ZoomIn Zoom in.
+ \value ZoomOut Zoom out.
+*/
+
+/*!
+ \since 4.2
+
+ Constructs a QKeySequence object for the given \a key.
+ The result will depend on the currently running platform.
+
+ The resulting object will be based on the first element in the
+ list of key bindings for the \a key.
+*/
+QKeySequence::QKeySequence(StandardKey key)
+{
+ const QList <QKeySequence> bindings = keyBindings(key);
+ //pick only the first/primary shortcut from current bindings
+ if (bindings.size() > 0) {
+ d = bindings.first().d;
+ d->ref.ref();
+ }
+ else
+ d = new QKeySequencePrivate();
+}
+
+
+/*!
+ Constructs an empty key sequence.
+*/
+QKeySequence::QKeySequence()
+{
+ static QKeySequencePrivate shared_empty;
+ d = &shared_empty;
+ d->ref.ref();
+}
+
+/*!
+ Creates a key sequence from the \a key string. For example
+ "Ctrl+O" gives CTRL+'O'. The strings "Ctrl",
+ "Shift", "Alt" and "Meta" are recognized, as well as their
+ translated equivalents in the "QShortcut" context (using
+ QObject::tr()).
+
+ Up to four key codes may be entered by separating them with
+ commas, e.g. "Alt+X,Ctrl+S,Q".
+
+ \a key should be in NativeText format.
+
+ This constructor is typically used with \link QObject::tr() tr
+ \endlink(), so that shortcut keys can be replaced in
+ translations:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qkeysequence.cpp 2
+
+ Note the "File|Open" translator comment. It is by no means
+ necessary, but it provides some context for the human translator.
+*/
+QKeySequence::QKeySequence(const QString &key)
+{
+ d = new QKeySequencePrivate();
+ assign(key);
+}
+
+/*!
+ \since 4.x
+ Creates a key sequence from the \a key string based on \a format.
+*/
+QKeySequence::QKeySequence(const QString &key, QKeySequence::SequenceFormat format)
+{
+ d = new QKeySequencePrivate();
+ assign(key, format);
+}
+
+/*!
+ Constructs a key sequence with up to 4 keys \a k1, \a k2,
+ \a k3 and \a k4.
+
+ The key codes are listed in Qt::Key and can be combined with
+ modifiers (see Qt::Modifier) such as Qt::SHIFT, Qt::CTRL,
+ Qt::ALT, or Qt::META.
+*/
+QKeySequence::QKeySequence(int k1, int k2, int k3, int k4)
+{
+ d = new QKeySequencePrivate();
+ d->key[0] = k1;
+ d->key[1] = k2;
+ d->key[2] = k3;
+ d->key[3] = k4;
+}
+
+/*!
+ Copy constructor. Makes a copy of \a keysequence.
+ */
+QKeySequence::QKeySequence(const QKeySequence& keysequence)
+ : d(keysequence.d)
+{
+ d->ref.ref();
+}
+
+#ifdef Q_WS_MAC
+static inline int maybeSwapShortcut(int shortcut)
+{
+ if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
+ uint oldshortcut = shortcut;
+ shortcut &= ~(Qt::CTRL | Qt::META);
+ if (oldshortcut & Qt::CTRL)
+ shortcut |= Qt::META;
+ if (oldshortcut & Qt::META)
+ shortcut |= Qt::CTRL;
+ }
+ return shortcut;
+}
+#endif
+
+/*!
+ \since 4.2
+
+ Returns a list of key bindings for the given \a key.
+ The result of calling this function will vary based on the target platform.
+ The first element of the list indicates the primary shortcut for the given platform.
+ If the result contains more than one result, these can
+ be considered alternative shortcuts on the same platform for the given \a key.
+*/
+QList<QKeySequence> QKeySequence::keyBindings(StandardKey key)
+{
+ uint platform = QGuiApplicationPrivate::currentKeyPlatform();
+ QList <QKeySequence> list;
+ for (uint i = 0; i < QKeySequencePrivate::numberOfKeyBindings ; ++i) {
+ QKeyBinding keyBinding = QKeySequencePrivate::keyBindings[i];
+ if (keyBinding.standardKey == key && (keyBinding.platform & platform)) {
+ uint shortcut =
+#ifdef Q_WS_MAC
+ maybeSwapShortcut(QKeySequencePrivate::keyBindings[i].shortcut);
+#else
+ QKeySequencePrivate::keyBindings[i].shortcut;
+#endif
+ if (keyBinding.priority > 0)
+ list.prepend(QKeySequence(shortcut));
+ else
+ list.append(QKeySequence(shortcut));
+ }
+ }
+ return list;
+}
+
+/*!
+ Destroys the key sequence.
+ */
+QKeySequence::~QKeySequence()
+{
+ if (!d->ref.deref())
+ delete d;
+}
+
+/*!
+ \internal
+ KeySequences should never be modified, but rather just created.
+ Internally though we do need to modify to keep pace in event
+ delivery.
+*/
+
+void QKeySequence::setKey(int key, int index)
+{
+ Q_ASSERT_X(index >= 0 && index < 4, "QKeySequence::setKey", "index out of range");
+ qAtomicDetach(d);
+ d->key[index] = key;
+}
+
+/*!
+ Returns the number of keys in the key sequence.
+ The maximum is 4.
+ */
+uint QKeySequence::count() const
+{
+ if (!d->key[0])
+ return 0;
+ if (!d->key[1])
+ return 1;
+ if (!d->key[2])
+ return 2;
+ if (!d->key[3])
+ return 3;
+ return 4;
+}
+
+
+/*!
+ Returns true if the key sequence is empty; otherwise returns
+ false.
+*/
+bool QKeySequence::isEmpty() const
+{
+ return !d->key[0];
+}
+
+
+/*!
+ Returns the shortcut key sequence for the mnemonic in \a text,
+ or an empty key sequence if no mnemonics are found.
+
+ For example, mnemonic("E&xit") returns \c{Qt::ALT+Qt::Key_X},
+ mnemonic("&Quit") returns \c{ALT+Key_Q}, and mnemonic("Quit")
+ returns an empty QKeySequence.
+
+ We provide a \l{accelerators.html}{list of common mnemonics}
+ in English. At the time of writing, Microsoft and Open Group do
+ not appear to have issued equivalent recommendations for other
+ languages.
+
+ \sa qt_set_sequence_auto_mnemonic()
+*/
+QKeySequence QKeySequence::mnemonic(const QString &text)
+{
+ QKeySequence ret;
+
+ if(qt_sequence_no_mnemonics)
+ return ret;
+
+ bool found = false;
+ int p = 0;
+ while (p >= 0) {
+ p = text.indexOf(QLatin1Char('&'), p) + 1;
+ if (p <= 0 || p >= (int)text.length())
+ break;
+ if (text.at(p) != QLatin1Char('&')) {
+ QChar c = text.at(p);
+ if (c.isPrint()) {
+ if (!found) {
+ c = c.toUpper();
+ ret = QKeySequence(c.unicode() + Qt::ALT);
+#ifdef QT_NO_DEBUG
+ return ret;
+#else
+ found = true;
+ } else {
+ qWarning("QKeySequence::mnemonic: \"%s\" contains multiple occurrences of '&'", qPrintable(text));
+#endif
+ }
+ }
+ }
+ p++;
+ }
+ return ret;
+}
+
+/*!
+ \fn int QKeySequence::assign(const QString &keys)
+
+ Adds the given \a keys to the key sequence. \a keys may
+ contain up to four key codes, provided they are separated by a
+ comma; for example, "Alt+X,Ctrl+S,Z". The return value is the
+ number of key codes added.
+ \a keys should be in NativeText format.
+*/
+int QKeySequence::assign(const QString &ks)
+{
+ return assign(ks, NativeText);
+}
+
+/*!
+ \fn int QKeySequence::assign(const QString &keys, QKeySequence::SequenceFormat format)
+ \since 4.x
+
+ Adds the given \a keys to the key sequence (based on \a format).
+ \a keys may contain up to four key codes, provided they are
+ separated by a comma; for example, "Alt+X,Ctrl+S,Z". The return
+ value is the number of key codes added.
+*/
+int QKeySequence::assign(const QString &ks, QKeySequence::SequenceFormat format)
+{
+ QString keyseq = ks;
+ QString part;
+ int n = 0;
+ int p = 0, diff = 0;
+
+ // Run through the whole string, but stop
+ // if we have 4 keys before the end.
+ while (keyseq.length() && n < 4) {
+ // We MUST use something to separate each sequence, and space
+ // does not cut it, since some of the key names have space
+ // in them.. (Let's hope no one translate with a comma in it:)
+ p = keyseq.indexOf(QLatin1Char(','));
+ if (-1 != p) {
+ if (p == keyseq.count() - 1) { // Last comma 'Ctrl+,'
+ p = -1;
+ } else {
+ if (QLatin1Char(',') == keyseq.at(p+1)) // e.g. 'Ctrl+,, Shift+,,'
+ p++;
+ if (QLatin1Char(' ') == keyseq.at(p+1)) { // Space after comma
+ diff = 1;
+ p++;
+ } else {
+ diff = 0;
+ }
+ }
+ }
+ part = keyseq.left(-1 == p ? keyseq.length() : p - diff);
+ keyseq = keyseq.right(-1 == p ? 0 : keyseq.length() - (p + 1));
+ d->key[n] = QKeySequencePrivate::decodeString(part, format);
+ ++n;
+ }
+ return n;
+}
+
+struct QModifKeyName {
+ QModifKeyName() { }
+ QModifKeyName(int q, QChar n) : qt_key(q), name(n) { }
+ QModifKeyName(int q, const QString &n) : qt_key(q), name(n) { }
+ int qt_key;
+ QString name;
+};
+
+Q_GLOBAL_STATIC(QList<QModifKeyName>, globalModifs)
+Q_GLOBAL_STATIC(QList<QModifKeyName>, globalPortableModifs)
+
+/*!
+ Constructs a single key from the string \a str.
+*/
+int QKeySequence::decodeString(const QString &str)
+{
+ return QKeySequencePrivate::decodeString(str, NativeText);
+}
+
+int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::SequenceFormat format)
+{
+ int ret = 0;
+ QString accel = str.toLower();
+ bool nativeText = (format == QKeySequence::NativeText);
+
+ QList<QModifKeyName> *gmodifs;
+ if (nativeText) {
+ gmodifs = globalModifs();
+ if (gmodifs->isEmpty()) {
+#ifdef Q_WS_MAC
+ const bool dontSwap = qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta);
+ if (dontSwap)
+ *gmodifs << QModifKeyName(Qt::META, QChar(kCommandUnicode));
+ else
+ *gmodifs << QModifKeyName(Qt::CTRL, QChar(kCommandUnicode));
+ *gmodifs << QModifKeyName(Qt::ALT, QChar(kOptionUnicode));
+ if (dontSwap)
+ *gmodifs << QModifKeyName(Qt::CTRL, QChar(kControlUnicode));
+ else
+ *gmodifs << QModifKeyName(Qt::META, QChar(kControlUnicode));
+ *gmodifs << QModifKeyName(Qt::SHIFT, QChar(kShiftUnicode));
+#endif
+ *gmodifs << QModifKeyName(Qt::CTRL, QLatin1String("ctrl+"))
+ << QModifKeyName(Qt::SHIFT, QLatin1String("shift+"))
+ << QModifKeyName(Qt::ALT, QLatin1String("alt+"))
+ << QModifKeyName(Qt::META, QLatin1String("meta+"));
+ }
+ } else {
+ gmodifs = globalPortableModifs();
+ if (gmodifs->isEmpty()) {
+ *gmodifs << QModifKeyName(Qt::CTRL, QLatin1String("ctrl+"))
+ << QModifKeyName(Qt::SHIFT, QLatin1String("shift+"))
+ << QModifKeyName(Qt::ALT, QLatin1String("alt+"))
+ << QModifKeyName(Qt::META, QLatin1String("meta+"));
+ }
+ }
+ if (!gmodifs) return ret;
+
+
+ QList<QModifKeyName> modifs;
+ if (nativeText) {
+ modifs << QModifKeyName(Qt::CTRL, QCoreApplication::translate("QShortcut", "Ctrl").toLower().append(QLatin1Char('+')))
+ << QModifKeyName(Qt::SHIFT, QCoreApplication::translate("QShortcut", "Shift").toLower().append(QLatin1Char('+')))
+ << QModifKeyName(Qt::ALT, QCoreApplication::translate("QShortcut", "Alt").toLower().append(QLatin1Char('+')))
+ << QModifKeyName(Qt::META, QCoreApplication::translate("QShortcut", "Meta").toLower().append(QLatin1Char('+')));
+ }
+ modifs += *gmodifs; // Test non-translated ones last
+
+ QString sl = accel;
+#ifdef Q_WS_MAC
+ for (int i = 0; i < modifs.size(); ++i) {
+ const QModifKeyName &mkf = modifs.at(i);
+ if (sl.contains(mkf.name)) {
+ ret |= mkf.qt_key;
+ accel.remove(mkf.name);
+ sl = accel;
+ }
+ }
+#else
+ int i = 0;
+ int lastI = 0;
+ while ((i = sl.indexOf(QLatin1Char('+'), i + 1)) != -1) {
+ const QString sub = sl.mid(lastI, i - lastI + 1);
+ // Just shortcut the check here if we only have one character.
+ // Rational: A modifier will contain the name AND +, so longer than 1, a length of 1 is just
+ // the remaining part of the shortcut (ei. The 'C' in "Ctrl+C"), so no need to check that.
+ if (sub.length() > 1) {
+ for (int j = 0; j < modifs.size(); ++j) {
+ const QModifKeyName &mkf = modifs.at(j);
+ if (sub == mkf.name) {
+ ret |= mkf.qt_key;
+ break; // Shortcut, since if we find an other it would/should just be a dup
+ }
+ }
+ }
+ lastI = i + 1;
+ }
+#endif
+
+ int p = accel.lastIndexOf(QLatin1Char('+'), str.length() - 2); // -2 so that Ctrl++ works
+ if(p > 0)
+ accel = accel.mid(p + 1);
+
+ int fnum = 0;
+ if (accel.length() == 1) {
+#ifdef Q_WS_MAC
+ int qtKey = qtkeyForMacSymbol(accel[0]);
+ if (qtKey != -1) {
+ ret |= qtKey;
+ } else
+#endif
+ {
+ ret |= accel[0].toUpper().unicode();
+ }
+ } else if (accel[0] == QLatin1Char('f') && (fnum = accel.mid(1).toInt()) && (fnum >= 1) && (fnum <= 35)) {
+ ret |= Qt::Key_F1 + fnum - 1;
+ } else {
+ // For NativeText, check the traslation table first,
+ // if we don't find anything then try it out with just the untranlated stuff.
+ // PortableText will only try the untranlated table.
+ bool found = false;
+ for (int tran = 0; tran < 2; ++tran) {
+ if (!nativeText)
+ ++tran;
+ for (int i = 0; keyname[i].name; ++i) {
+ QString keyName(tran == 0
+ ? QCoreApplication::translate("QShortcut", keyname[i].name)
+ : QString::fromLatin1(keyname[i].name));
+ if (accel == keyName.toLower()) {
+ ret |= keyname[i].key;
+ found = true;
+ break;
+ }
+ }
+ if (found)
+ break;
+ }
+ }
+ return ret;
+}
+
+/*!
+ Creates a shortcut string for \a key. For example,
+ Qt::CTRL+Qt::Key_O gives "Ctrl+O". The strings, "Ctrl", "Shift", etc. are
+ translated (using QObject::tr()) in the "QShortcut" context.
+ */
+QString QKeySequence::encodeString(int key)
+{
+ return QKeySequencePrivate::encodeString(key, NativeText);
+}
+
+static inline void addKey(QString &str, const QString &theKey, QKeySequence::SequenceFormat format)
+{
+ if (!str.isEmpty())
+ str += (format == QKeySequence::NativeText) ? QCoreApplication::translate("QShortcut", "+")
+ : QString::fromLatin1("+");
+ str += theKey;
+}
+
+QString QKeySequencePrivate::encodeString(int key, QKeySequence::SequenceFormat format)
+{
+ bool nativeText = (format == QKeySequence::NativeText);
+ QString s;
+#if defined(Q_WS_MAC)
+ if (nativeText) {
+ // On Mac OS X the order (by default) is Meta, Alt, Shift, Control.
+ // If the AA_MacDontSwapCtrlAndMeta is enabled, then the order
+ // is Ctrl, Alt, Shift, Meta. The macSymbolForQtKey does this swap
+ // for us, which means that we have to adjust our order here.
+ // The upshot is a lot more infrastructure to keep the number of
+ // if tests down and the code relatively clean.
+ static const int ModifierOrder[] = { Qt::META, Qt::ALT, Qt::SHIFT, Qt::CTRL, 0 };
+ static const int QtKeyOrder[] = { Qt::Key_Meta, Qt::Key_Alt, Qt::Key_Shift, Qt::Key_Control, 0 };
+ static const int DontSwapModifierOrder[] = { Qt::CTRL, Qt::ALT, Qt::SHIFT, Qt::META, 0 };
+ static const int DontSwapQtKeyOrder[] = { Qt::Key_Control, Qt::Key_Alt, Qt::Key_Shift, Qt::Key_Meta, 0 };
+ const int *modifierOrder;
+ const int *qtkeyOrder;
+ if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
+ modifierOrder = DontSwapModifierOrder;
+ qtkeyOrder = DontSwapQtKeyOrder;
+ } else {
+ modifierOrder = ModifierOrder;
+ qtkeyOrder = QtKeyOrder;
+ }
+
+ for (int i = 0; modifierOrder[i] != 0; ++i) {
+ if (key & modifierOrder[i])
+ s += qt_macSymbolForQtKey(qtkeyOrder[i]);
+ }
+ } else
+#endif
+ {
+ // On other systems the order is Meta, Control, Alt, Shift
+ if ((key & Qt::META) == Qt::META)
+ s = nativeText ? QCoreApplication::translate("QShortcut", "Meta") : QString::fromLatin1("Meta");
+ if ((key & Qt::CTRL) == Qt::CTRL)
+ addKey(s, nativeText ? QCoreApplication::translate("QShortcut", "Ctrl") : QString::fromLatin1("Ctrl"), format);
+ if ((key & Qt::ALT) == Qt::ALT)
+ addKey(s, nativeText ? QCoreApplication::translate("QShortcut", "Alt") : QString::fromLatin1("Alt"), format);
+ if ((key & Qt::SHIFT) == Qt::SHIFT)
+ addKey(s, nativeText ? QCoreApplication::translate("QShortcut", "Shift") : QString::fromLatin1("Shift"), format);
+ }
+
+
+ key &= ~(Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier);
+ QString p;
+
+ if (key && key < Qt::Key_Escape && key != Qt::Key_Space) {
+ if (key < 0x10000) {
+ p = QChar(key & 0xffff).toUpper();
+ } else {
+ p = QChar((key-0x10000)/0x400+0xd800);
+ p += QChar((key-0x10000)%400+0xdc00);
+ }
+ } else if (key >= Qt::Key_F1 && key <= Qt::Key_F35) {
+ p = nativeText ? QCoreApplication::translate("QShortcut", "F%1").arg(key - Qt::Key_F1 + 1)
+ : QString::fromLatin1("F%1").arg(key - Qt::Key_F1 + 1);
+ } else if (key) {
+ int i=0;
+#if defined(Q_WS_MAC)
+ if (nativeText) {
+ QChar ch = qt_macSymbolForQtKey(key);
+ if (!ch.isNull())
+ p = ch;
+ else
+ goto NonSymbol;
+ } else
+#endif
+ {
+#ifdef Q_WS_MAC
+NonSymbol:
+#endif
+ while (keyname[i].name) {
+ if (key == keyname[i].key) {
+ p = nativeText ? QCoreApplication::translate("QShortcut", keyname[i].name)
+ : QString::fromLatin1(keyname[i].name);
+ break;
+ }
+ ++i;
+ }
+ // If we can't find the actual translatable keyname,
+ // fall back on the unicode representation of it...
+ // Or else characters like Qt::Key_aring may not get displayed
+ // (Really depends on you locale)
+ if (!keyname[i].name) {
+ if (key < 0x10000) {
+ p = QChar(key & 0xffff).toUpper();
+ } else {
+ p = QChar((key-0x10000)/0x400+0xd800);
+ p += QChar((key-0x10000)%400+0xdc00);
+ }
+ }
+ }
+ }
+
+#ifdef Q_WS_MAC
+ if (nativeText)
+ s += p;
+ else
+#endif
+ addKey(s, p, format);
+ return s;
+}
+/*!
+ Matches the sequence with \a seq. Returns ExactMatch if
+ successful, PartialMatch if \a seq matches incompletely,
+ and NoMatch if the sequences have nothing in common.
+ Returns NoMatch if \a seq is shorter.
+*/
+QKeySequence::SequenceMatch QKeySequence::matches(const QKeySequence &seq) const
+{
+ uint userN = count(),
+ seqN = seq.count();
+
+ if (userN > seqN)
+ return NoMatch;
+
+ // If equal in length, we have a potential ExactMatch sequence,
+ // else we already know it can only be partial.
+ SequenceMatch match = (userN == seqN ? ExactMatch : PartialMatch);
+
+ for (uint i = 0; i < userN; ++i) {
+ int userKey = (*this)[i],
+ sequenceKey = seq[i];
+ if (userKey != sequenceKey)
+ return NoMatch;
+ }
+ return match;
+}
+
+
+/*!
+ \obsolete
+
+ Use toString() instead.
+
+ Returns the key sequence as a QString. This is equivalent to
+ calling toString(QKeySequence::NativeText). Note that the
+ result is not platform independent.
+*/
+QKeySequence::operator QString() const
+{
+ return QKeySequence::toString(QKeySequence::NativeText);
+}
+
+/*!
+ Returns the key sequence as a QVariant
+*/
+QKeySequence::operator QVariant() const
+{
+ return QVariant(QVariant::KeySequence, this);
+}
+
+/*!
+ \obsolete
+ For backward compatibility: returns the first keycode
+ as integer. If the key sequence is empty, 0 is returned.
+ */
+QKeySequence::operator int () const
+{
+ if (1 <= count())
+ return d->key[0];
+ return 0;
+}
+
+
+/*!
+ Returns a reference to the element at position \a index in the key
+ sequence. This can only be used to read an element.
+ */
+int QKeySequence::operator[](uint index) const
+{
+ Q_ASSERT_X(index < 4, "QKeySequence::operator[]", "index out of range");
+ return d->key[index];
+}
+
+
+/*!
+ Assignment operator. Assigns the \a other key sequence to this
+ object.
+ */
+QKeySequence &QKeySequence::operator=(const QKeySequence &other)
+{
+ qAtomicAssign(d, other.d);
+ return *this;
+}
+
+/*!
+ \fn void QKeySequence::swap(QKeySequence &other)
+ \since 4.8
+
+ Swaps key sequence \a other with this key sequence. This operation is very
+ fast and never fails.
+*/
+
+/*!
+ \fn bool QKeySequence::operator!=(const QKeySequence &other) const
+
+ Returns true if this key sequence is not equal to the \a other
+ key sequence; otherwise returns false.
+*/
+
+
+/*!
+ Returns true if this key sequence is equal to the \a other
+ key sequence; otherwise returns false.
+ */
+bool QKeySequence::operator==(const QKeySequence &other) const
+{
+ return (d->key[0] == other.d->key[0] &&
+ d->key[1] == other.d->key[1] &&
+ d->key[2] == other.d->key[2] &&
+ d->key[3] == other.d->key[3]);
+}
+
+
+/*!
+ Provides an arbitrary comparison of this key sequence and
+ \a other key sequence. All that is guaranteed is that the
+ operator returns false if both key sequences are equal and
+ that (ks1 \< ks2) == !( ks2 \< ks1) if the key sequences
+ are not equal.
+
+ This function is useful in some circumstances, for example
+ if you want to use QKeySequence objects as keys in a QMap.
+
+ \sa operator==() operator!=() operator>() operator<=() operator>=()
+*/
+bool QKeySequence::operator< (const QKeySequence &other) const
+{
+ for (int i = 0; i < 4; ++i)
+ if (d->key[i] != other.d->key[i])
+ return d->key[i] < other.d->key[i];
+ return false;
+}
+
+/*!
+ \fn bool QKeySequence::operator> (const QKeySequence &other) const
+
+ Returns true if this key sequence is larger than the \a other key
+ sequence; otherwise returns false.
+
+ \sa operator==() operator!=() operator<() operator<=() operator>=()
+*/
+
+/*!
+ \fn bool QKeySequence::operator<= (const QKeySequence &other) const
+
+ Returns true if this key sequence is smaller or equal to the
+ \a other key sequence; otherwise returns false.
+
+ \sa operator==() operator!=() operator<() operator>() operator>=()
+*/
+
+/*!
+ \fn bool QKeySequence::operator>= (const QKeySequence &other) const
+
+ Returns true if this key sequence is larger or equal to the
+ \a other key sequence; otherwise returns false.
+
+ \sa operator==() operator!=() operator<() operator>() operator<=()
+*/
+
+/*!
+ \internal
+*/
+bool QKeySequence::isDetached() const
+{
+ return d->ref == 1;
+}
+
+/*!
+ \since 4.1
+
+ Return a string representation of the key sequence,
+ based on \a format.
+
+ For example, the value Qt::CTRL+Qt::Key_O results in "Ctrl+O".
+ If the key sequence has multiple key codes, each is separated
+ by commas in the string returned, such as "Alt+X, Ctrl+Y, Z".
+ The strings, "Ctrl", "Shift", etc. are translated using
+ QObject::tr() in the "QShortcut" context.
+
+ If the key sequence has no keys, an empty string is returned.
+
+ On Mac OS X, the string returned resembles the sequence that is
+ shown in the menu bar.
+
+ \sa fromString()
+*/
+QString QKeySequence::toString(SequenceFormat format) const
+{
+ QString finalString;
+ // A standard string, with no translation or anything like that. In some ways it will
+ // look like our latin case on Windows and X11
+ int end = count();
+ for (int i = 0; i < end; ++i) {
+ finalString += d->encodeString(d->key[i], format);
+ finalString += QLatin1String(", ");
+ }
+ finalString.truncate(finalString.length() - 2);
+ return finalString;
+}
+
+/*!
+ \since 4.1
+
+ Return a QKeySequence from the string \a str based on \a format.
+
+ \sa toString()
+*/
+QKeySequence QKeySequence::fromString(const QString &str, SequenceFormat format)
+{
+ return QKeySequence(str, format);
+}
+
+/*****************************************************************************
+ QKeySequence stream functions
+ *****************************************************************************/
+#if !defined(QT_NO_DATASTREAM)
+/*!
+ \fn QDataStream &operator<<(QDataStream &stream, const QKeySequence &sequence)
+ \relates QKeySequence
+
+ Writes the key \a sequence to the \a stream.
+
+ \sa \link datastreamformat.html Format of the QDataStream operators \endlink
+*/
+QDataStream &operator<<(QDataStream &s, const QKeySequence &keysequence)
+{
+ QList<quint32> list;
+ list << keysequence.d->key[0];
+
+ if (s.version() >= 5 && keysequence.count() > 1) {
+ list << keysequence.d->key[1];
+ list << keysequence.d->key[2];
+ list << keysequence.d->key[3];
+ }
+ s << list;
+ return s;
+}
+
+
+/*!
+ \fn QDataStream &operator>>(QDataStream &stream, QKeySequence &sequence)
+ \relates QKeySequence
+
+ Reads a key sequence from the \a stream into the key \a sequence.
+
+ \sa \link datastreamformat.html Format of the QDataStream operators \endlink
+*/
+QDataStream &operator>>(QDataStream &s, QKeySequence &keysequence)
+{
+ qAtomicDetach(keysequence.d);
+ QList<quint32> list;
+ s >> list;
+ for (int i = 0; i < 4; ++i)
+ keysequence.d->key[i] = list.value(i);
+ return s;
+}
+
+#endif //QT_NO_DATASTREAM
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const QKeySequence &p)
+{
+#ifndef Q_BROKEN_DEBUG_STREAM
+ dbg.nospace() << "QKeySequence(" << p.toString() << ')';
+ return dbg.space();
+#else
+ qWarning("This compiler doesn't support streaming QKeySequence to QDebug");
+ return dbg;
+ Q_UNUSED(p);
+#endif
+}
+#endif
+
+#endif // QT_NO_SHORTCUT
+
+
+/*!
+ \typedef QKeySequence::DataPtr
+ \internal
+*/
+
+ /*!
+ \fn DataPtr &QKeySequence::data_ptr()
+ \internal
+*/
+
+QT_END_NAMESPACE
diff --git a/src/gui/guikernel/qkeysequence.h b/src/gui/guikernel/qkeysequence.h
new file mode 100644
index 0000000000..c61501036a
--- /dev/null
+++ b/src/gui/guikernel/qkeysequence.h
@@ -0,0 +1,237 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QKEYSEQUENCE_H
+#define QKEYSEQUENCE_H
+
+#include <QtCore/qnamespace.h>
+#include <QtCore/qstring.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_SHORTCUT
+
+/*****************************************************************************
+ QKeySequence stream functions
+ *****************************************************************************/
+#ifndef QT_NO_DATASTREAM
+class QKeySequence;
+Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks);
+Q_GUI_EXPORT QDataStream &operator>>(QDataStream &out, QKeySequence &ks);
+#endif
+
+#ifdef qdoc
+void qt_set_sequence_auto_mnemonic(bool b);
+#endif
+
+class QVariant;
+class QKeySequencePrivate;
+
+class Q_GUI_EXPORT QKeySequence
+{
+public:
+ enum StandardKey {
+ UnknownKey,
+ HelpContents,
+ WhatsThis,
+ Open,
+ Close,
+ Save,
+ New,
+ Delete,
+ Cut,
+ Copy,
+ Paste,
+ Undo,
+ Redo,
+ Back,
+ Forward,
+ Refresh,
+ ZoomIn,
+ ZoomOut,
+ Print,
+ AddTab,
+ NextChild,
+ PreviousChild,
+ Find,
+ FindNext,
+ FindPrevious,
+ Replace,
+ SelectAll,
+ Bold,
+ Italic,
+ Underline,
+ MoveToNextChar,
+ MoveToPreviousChar,
+ MoveToNextWord,
+ MoveToPreviousWord,
+ MoveToNextLine,
+ MoveToPreviousLine,
+ MoveToNextPage,
+ MoveToPreviousPage,
+ MoveToStartOfLine,
+ MoveToEndOfLine,
+ MoveToStartOfBlock,
+ MoveToEndOfBlock,
+ MoveToStartOfDocument,
+ MoveToEndOfDocument,
+ SelectNextChar,
+ SelectPreviousChar,
+ SelectNextWord,
+ SelectPreviousWord,
+ SelectNextLine,
+ SelectPreviousLine,
+ SelectNextPage,
+ SelectPreviousPage,
+ SelectStartOfLine,
+ SelectEndOfLine,
+ SelectStartOfBlock,
+ SelectEndOfBlock,
+ SelectStartOfDocument,
+ SelectEndOfDocument,
+ DeleteStartOfWord,
+ DeleteEndOfWord,
+ DeleteEndOfLine,
+ InsertParagraphSeparator,
+ InsertLineSeparator,
+ SaveAs,
+ Preferences,
+ Quit
+ };
+
+ enum SequenceFormat {
+ NativeText,
+ PortableText
+ };
+
+ QKeySequence();
+ QKeySequence(const QString &key);
+ QKeySequence(const QString &key, SequenceFormat format);
+ QKeySequence(int k1, int k2 = 0, int k3 = 0, int k4 = 0);
+ QKeySequence(const QKeySequence &ks);
+ QKeySequence(StandardKey key);
+ ~QKeySequence();
+
+ uint count() const; // ### Qt 5: return 'int'
+ bool isEmpty() const;
+
+ enum SequenceMatch {
+ NoMatch,
+ PartialMatch,
+ ExactMatch
+ };
+
+ QString toString(SequenceFormat format = PortableText) const;
+ static QKeySequence fromString(const QString &str, SequenceFormat format = PortableText);
+
+ SequenceMatch matches(const QKeySequence &seq) const;
+ static QKeySequence mnemonic(const QString &text);
+ static QList<QKeySequence> keyBindings(StandardKey key);
+
+ // ### Qt 5: kill 'operator QString' - it's evil
+ operator QString() const;
+ operator QVariant() const;
+ operator int() const;
+ int operator[](uint i) const;
+ QKeySequence &operator=(const QKeySequence &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QKeySequence &operator=(QKeySequence &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
+ inline void swap(QKeySequence &other) { qSwap(d, other.d); }
+ bool operator==(const QKeySequence &other) const;
+ inline bool operator!= (const QKeySequence &other) const
+ { return !(*this == other); }
+ bool operator< (const QKeySequence &ks) const;
+ inline bool operator> (const QKeySequence &other) const
+ { return other < *this; }
+ inline bool operator<= (const QKeySequence &other) const
+ { return !(other < *this); }
+ inline bool operator>= (const QKeySequence &other) const
+ { return !(*this < other); }
+
+ bool isDetached() const;
+private:
+ static int decodeString(const QString &ks);
+ static QString encodeString(int key);
+ int assign(const QString &str);
+ int assign(const QString &str, SequenceFormat format);
+ void setKey(int key, int index);
+
+ QKeySequencePrivate *d;
+
+ friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks);
+ friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QKeySequence &ks);
+ friend class Q3AccelManager;
+ friend class QShortcutMap;
+ friend class QShortcut;
+
+public:
+ typedef QKeySequencePrivate * DataPtr;
+ inline DataPtr &data_ptr() { return d; }
+};
+Q_DECLARE_TYPEINFO(QKeySequence, Q_MOVABLE_TYPE);
+Q_DECLARE_SHARED(QKeySequence)
+
+#ifndef QT_NO_DEBUG_STREAM
+Q_GUI_EXPORT QDebug operator<<(QDebug, const QKeySequence &);
+#endif
+
+#else
+
+class Q_GUI_EXPORT QKeySequence
+{
+public:
+ QKeySequence() {}
+ QKeySequence(int) {}
+};
+
+#endif // QT_NO_SHORTCUT
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QKEYSEQUENCE_H
diff --git a/src/gui/kernel/qkeysequence_p.h b/src/gui/guikernel/qkeysequence_p.h
index c1e5977663..c1e5977663 100644
--- a/src/gui/kernel/qkeysequence_p.h
+++ b/src/gui/guikernel/qkeysequence_p.h
diff --git a/src/gui/kernel/qmime.cpp b/src/gui/guikernel/qmime.cpp
index 4e15ddf624..4e15ddf624 100644
--- a/src/gui/kernel/qmime.cpp
+++ b/src/gui/guikernel/qmime.cpp
diff --git a/src/gui/kernel/qmime.h b/src/gui/guikernel/qmime.h
index a791f68cf0..a791f68cf0 100644
--- a/src/gui/kernel/qmime.h
+++ b/src/gui/guikernel/qmime.h
diff --git a/src/gui/guikernel/qpalette.cpp b/src/gui/guikernel/qpalette.cpp
new file mode 100644
index 0000000000..33b1c2a2a8
--- /dev/null
+++ b/src/gui/guikernel/qpalette.cpp
@@ -0,0 +1,1091 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qpalette.h"
+#include "qguiapplication.h"
+#include "qdatastream.h"
+#include "qvariant.h"
+
+QT_BEGIN_NAMESPACE
+
+static int qt_palette_count = 1;
+
+class QPalettePrivate {
+public:
+ QPalettePrivate() : ref(1), ser_no(qt_palette_count++), detach_no(0) { }
+ QAtomicInt ref;
+ QBrush br[QPalette::NColorGroups][QPalette::NColorRoles];
+ int ser_no;
+ int detach_no;
+};
+
+static QColor qt_mix_colors(QColor a, QColor b)
+{
+ return QColor((a.red() + b.red()) / 2, (a.green() + b.green()) / 2,
+ (a.blue() + b.blue()) / 2, (a.alpha() + b.alpha()) / 2);
+}
+
+/*!
+ \fn const QColor &QPalette::color(ColorRole role) const
+
+ \overload
+
+ Returns the color that has been set for the given color \a role in
+ the current ColorGroup.
+
+ \sa brush() ColorRole
+ */
+
+/*!
+ \fn const QBrush &QPalette::brush(ColorRole role) const
+
+ \overload
+
+ Returns the brush that has been set for the given color \a role in
+ the current ColorGroup.
+
+ \sa color() setBrush() ColorRole
+*/
+
+/*!
+ \fn void QPalette::setColor(ColorRole role, const QColor &color)
+
+ \overload
+
+ Sets the color used for the given color \a role, in all color
+ groups, to the specified solid \a color.
+
+ \sa brush() setColor() ColorRole
+*/
+
+/*!
+ \fn void QPalette::setBrush(ColorRole role, const QBrush &brush)
+
+ Sets the brush for the given color \a role to the specified \a
+ brush for all groups in the palette.
+
+ \sa brush() setColor() ColorRole
+*/
+
+/*!
+ \fn const QBrush & QPalette::foreground() const
+ \obsolete
+
+ Use windowText() instead.
+*/
+
+/*!
+ \fn const QBrush & QPalette::windowText() const
+
+ Returns the window text (general foreground) brush of the
+ current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::button() const
+
+ Returns the button brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::light() const
+
+ Returns the light brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush& QPalette::midlight() const
+
+ Returns the midlight brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::dark() const
+
+ Returns the dark brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::mid() const
+
+ Returns the mid brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::text() const
+
+ Returns the text foreground brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::brightText() const
+
+ Returns the bright text foreground brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::buttonText() const
+
+ Returns the button text foreground brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::base() const
+
+ Returns the base brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::alternateBase() const
+
+ Returns the alternate base brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::toolTipBase() const
+ \since 4.4
+
+ Returns the tool tip base brush of the current color group. This brush is
+ used by QToolTip and QWhatsThis.
+
+ \note Tool tips use the Inactive color group of QPalette, because tool
+ tips are not active windows.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::toolTipText() const
+ \since 4.4
+
+ Returns the tool tip text brush of the current color group. This brush is
+ used by QToolTip and QWhatsThis.
+
+ \note Tool tips use the Inactive color group of QPalette, because tool
+ tips are not active windows.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::background() const
+ \obsolete
+
+ Use window() instead.
+*/
+
+/*!
+ \fn const QBrush & QPalette::window() const
+
+ Returns the window (general background) brush of the current
+ color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::shadow() const
+
+ Returns the shadow brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::highlight() const
+
+ Returns the highlight brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::highlightedText() const
+
+ Returns the highlighted text brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::link() const
+
+ Returns the unvisited link text brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn const QBrush & QPalette::linkVisited() const
+
+ Returns the visited link text brush of the current color group.
+
+ \sa ColorRole brush()
+*/
+
+/*!
+ \fn ColorGroup QPalette::currentColorGroup() const
+
+ Returns the palette's current color group.
+*/
+
+/*!
+ \fn void QPalette::setCurrentColorGroup(ColorGroup cg)
+
+ Set the palette's current color group to \a cg.
+*/
+
+/*!
+ \class QPalette
+
+ \brief The QPalette class contains color groups for each widget state.
+
+ \ingroup appearance
+ \ingroup shared
+ \ingroup painting
+
+
+ A palette consists of three color groups: \e Active, \e Disabled,
+ and \e Inactive. All widgets in Qt contain a palette and
+ use their palette to draw themselves. This makes the user
+ interface easily configurable and easier to keep consistent.
+
+
+ If you create a new widget we strongly recommend that you use the
+ colors in the palette rather than hard-coding specific colors.
+
+ The color groups:
+ \list
+ \i The Active group is used for the window that has keyboard focus.
+ \i The Inactive group is used for other windows.
+ \i The Disabled group is used for widgets (not windows) that are
+ disabled for some reason.
+ \endlist
+
+ Both active and inactive windows can contain disabled widgets.
+ (Disabled widgets are often called \e inaccessible or \e{grayed
+ out}.)
+
+ In most styles, Active and Inactive look the same.
+
+ Colors and brushes can be set for particular roles in any of a palette's
+ color groups with setColor() and setBrush(). A color group contains a
+ group of colors used by widgets for drawing themselves. We recommend that
+ widgets use color group roles from the palette such as "foreground" and
+ "base" rather than literal colors like "red" or "turquoise". The color
+ roles are enumerated and defined in the \l ColorRole documentation.
+
+ We strongly recommend that you use the default palette of the
+ current style (returned by QGuiApplication::palette()) and
+ modify that as necessary. This is done by Qt's widgets when they
+ are drawn.
+
+ To modify a color group you call the functions
+ setColor() and setBrush(), depending on whether you want a pure
+ color or a pixmap pattern.
+
+ There are also corresponding color() and brush() getters, and a
+ commonly used convenience function to get the ColorRole for the current ColorGroup:
+ window(), windowText(), base(), etc.
+
+
+ You can copy a palette using the copy constructor and test to see
+ if two palettes are \e identical using isCopyOf().
+
+ QPalette is optimized by the use of \l{implicit sharing},
+ so it is very efficient to pass QPalette objects as arguments.
+
+ \warning Some styles do not use the palette for all drawing, for
+ instance, if they make use of native theme engines. This is the
+ case for both the Windows XP, Windows Vista, and the Mac OS X
+ styles.
+
+ \sa QApplication::setPalette(), QWidget::setPalette(), QColor
+*/
+
+/*!
+ \enum QPalette::ColorGroup
+
+ \value Disabled
+ \value Active
+ \value Inactive
+ \value Normal synonym for Active
+
+ \omitvalue All
+ \omitvalue NColorGroups
+ \omitvalue Current
+*/
+
+/*!
+ \enum QPalette::ColorRole
+
+ \img palette.png Color Roles
+
+ The ColorRole enum defines the different symbolic color roles used
+ in current GUIs.
+
+ The central roles are:
+
+ \value Window A general background color.
+
+ \value Background This value is obsolete. Use Window instead.
+
+ \value WindowText A general foreground color.
+
+ \value Foreground This value is obsolete. Use WindowText instead.
+
+ \value Base Used mostly as the background color for text entry widgets,
+ but can also be used for other painting - such as the
+ background of combobox drop down lists and toolbar handles.
+ It is usually white or another light color.
+
+ \value AlternateBase Used as the alternate background color in views with
+ alternating row colors (see
+ QAbstractItemView::setAlternatingRowColors()).
+
+ \value ToolTipBase Used as the background color for QToolTip and
+ QWhatsThis. Tool tips use the Inactive color group
+ of QPalette, because tool tips are not active
+ windows.
+
+ \value ToolTipText Used as the foreground color for QToolTip and
+ QWhatsThis. Tool tips use the Inactive color group
+ of QPalette, because tool tips are not active
+ windows.
+
+ \value Text The foreground color used with \c Base. This is usually
+ the same as the \c WindowText, in which case it must provide
+ good contrast with \c Window and \c Base.
+
+ \value Button The general button background color. This background can be different from
+ \c Window as some styles require a different background color for buttons.
+
+ \value ButtonText A foreground color used with the \c Button color.
+
+ \value BrightText A text color that is very different from
+ \c WindowText, and contrasts well with e.g. \c
+ Dark. Typically used for text that needs to be
+ drawn where \c Text or \c WindowText would give
+ poor contrast, such as on pressed push buttons.
+ Note that text colors can be used for things
+ other than just words; text colors are \e
+ usually used for text, but it's quite common to
+ use the text color roles for lines, icons, etc.
+
+
+ There are some color roles used mostly for 3D bevel and shadow effects.
+ All of these are normally derived from \c Window, and used in ways that
+ depend on that relationship. For example, buttons depend on it to make the
+ bevels look attractive, and Motif scroll bars depend on \c Mid to be
+ slightly different from \c Window.
+
+ \value Light Lighter than \c Button color.
+
+ \value Midlight Between \c Button and \c Light.
+
+ \value Dark Darker than \c Button.
+
+ \value Mid Between \c Button and \c Dark.
+
+ \value Shadow A very dark color. By default, the shadow color is
+ Qt::black.
+
+
+ Selected (marked) items have two roles:
+
+ \value Highlight A color to indicate a selected item or the current
+ item. By default, the highlight color is
+ Qt::darkBlue.
+
+ \value HighlightedText A text color that contrasts with \c Highlight.
+ By default, the highlighted text color is Qt::white.
+
+ There are two color roles related to hyperlinks:
+
+ \value Link A text color used for unvisited hyperlinks.
+ By default, the link color is Qt::blue.
+
+ \value LinkVisited A text color used for already visited hyperlinks.
+ By default, the linkvisited color is Qt::magenta.
+
+ Note that we do not use the \c Link and \c LinkVisited roles when
+ rendering rich text in Qt, and that we recommend that you use CSS
+ and the QTextDocument::setDefaultStyleSheet() function to alter
+ the appearance of links. For example:
+
+ \snippet doc/src/snippets/textdocument-css/main.cpp 0
+
+ \value NoRole No role; this special role is often used to indicate that a
+ role has not been assigned.
+
+ \omitvalue NColorRoles
+*/
+
+/*!
+ Constructs a palette object that uses the application's default palette.
+
+ \sa QApplication::setPalette(), QApplication::palette()
+*/
+QPalette::QPalette()
+ : d(QGuiApplication::palette().d),
+ current_group(Active),
+ resolve_mask(0)
+{
+ d->ref.ref();
+}
+
+static void qt_palette_from_color(QPalette &pal, const QColor & button)
+{
+ QColor bg = button,
+ btn = button,
+ fg, base;
+ int h, s, v;
+ bg.getHsv(&h, &s, &v);
+ if(v > 128) {
+ fg = Qt::black;
+ base = Qt::white;
+ } else {
+ fg = Qt::white;
+ base = Qt::black;
+ }
+ //inactive and active are the same..
+ pal.setColorGroup(QPalette::Active, QBrush(fg), QBrush(btn), QBrush(btn.lighter(150)),
+ QBrush(btn.darker()), QBrush(btn.darker(150)), QBrush(fg), QBrush(Qt::white),
+ QBrush(base), QBrush(bg));
+ pal.setColorGroup(QPalette::Inactive, QBrush(fg), QBrush(btn), QBrush(btn.lighter(150)),
+ QBrush(btn.darker()), QBrush(btn.darker(150)), QBrush(fg), QBrush(Qt::white),
+ QBrush(base), QBrush(bg));
+ pal.setColorGroup(QPalette::Disabled, QBrush(btn.darker()), QBrush(btn), QBrush(btn.lighter(150)),
+ QBrush(btn.darker()), QBrush(btn.darker(150)), QBrush(btn.darker()),
+ QBrush(Qt::white), QBrush(bg), QBrush(bg));
+}
+
+
+/*!
+ Constructs a palette from the \a button color. The other colors are
+ automatically calculated, based on this color. \c Window will be
+ the button color as well.
+*/
+QPalette::QPalette(const QColor &button)
+{
+ init();
+ qt_palette_from_color(*this, button);
+}
+
+/*!
+ Constructs a palette from the \a button color. The other colors are
+ automatically calculated, based on this color. \c Window will be
+ the button color as well.
+*/
+QPalette::QPalette(Qt::GlobalColor button)
+{
+ init();
+ qt_palette_from_color(*this, button);
+}
+
+/*!
+ Constructs a palette. You can pass either brushes, pixmaps or
+ plain colors for \a windowText, \a button, \a light, \a dark, \a
+ mid, \a text, \a bright_text, \a base and \a window.
+
+ \sa QBrush
+*/
+QPalette::QPalette(const QBrush &windowText, const QBrush &button,
+ const QBrush &light, const QBrush &dark,
+ const QBrush &mid, const QBrush &text,
+ const QBrush &bright_text, const QBrush &base,
+ const QBrush &window)
+{
+ init();
+ setColorGroup(All, windowText, button, light, dark, mid, text, bright_text,
+ base, window);
+}
+
+
+/*!\obsolete
+
+ Constructs a palette with the specified \a windowText, \a
+ window, \a light, \a dark, \a mid, \a text, and \a base colors.
+ The button color will be set to the window color.
+*/
+QPalette::QPalette(const QColor &windowText, const QColor &window,
+ const QColor &light, const QColor &dark, const QColor &mid,
+ const QColor &text, const QColor &base)
+{
+ init();
+ setColorGroup(All, QBrush(windowText), QBrush(window), QBrush(light),
+ QBrush(dark), QBrush(mid), QBrush(text), QBrush(light),
+ QBrush(base), QBrush(window));
+}
+
+/*!
+ Constructs a palette from a \a button color and a \a window.
+ The other colors are automatically calculated, based on these
+ colors.
+*/
+QPalette::QPalette(const QColor &button, const QColor &window)
+{
+ init();
+ QColor bg = window, btn = button, fg, base, disfg;
+ int h, s, v;
+ bg.getHsv(&h, &s, &v);
+ if(v > 128) {
+ fg = Qt::black;
+ base = Qt::white;
+ disfg = Qt::darkGray;
+ } else {
+ fg = Qt::white;
+ base = Qt::black;
+ disfg = Qt::darkGray;
+ }
+ //inactive and active are identical
+ setColorGroup(Inactive, QBrush(fg), QBrush(btn), QBrush(btn.lighter(150)), QBrush(btn.darker()),
+ QBrush(btn.darker(150)), QBrush(fg), QBrush(Qt::white), QBrush(base),
+ QBrush(bg));
+ setColorGroup(Active, QBrush(fg), QBrush(btn), QBrush(btn.lighter(150)), QBrush(btn.darker()),
+ QBrush(btn.darker(150)), QBrush(fg), QBrush(Qt::white), QBrush(base),
+ QBrush(bg));
+ setColorGroup(Disabled, QBrush(disfg), QBrush(btn), QBrush(btn.lighter(150)),
+ QBrush(btn.darker()), QBrush(btn.darker(150)), QBrush(disfg),
+ QBrush(Qt::white), QBrush(base), QBrush(bg));
+}
+
+/*!
+ Constructs a copy of \a p.
+
+ This constructor is fast thanks to \l{implicit sharing}.
+*/
+QPalette::QPalette(const QPalette &p)
+{
+ d = p.d;
+ d->ref.ref();
+ resolve_mask = p.resolve_mask;
+ current_group = p.current_group;
+}
+
+/*!
+ Destroys the palette.
+*/
+QPalette::~QPalette()
+{
+ if(!d->ref.deref())
+ delete d;
+}
+
+/*!\internal*/
+void QPalette::init() {
+ d = new QPalettePrivate;
+ resolve_mask = 0;
+ current_group = Active; //as a default..
+}
+
+/*!
+ Assigns \a p to this palette and returns a reference to this
+ palette.
+
+ This operation is fast thanks to \l{implicit sharing}.
+*/
+QPalette &QPalette::operator=(const QPalette &p)
+{
+ p.d->ref.ref();
+ resolve_mask = p.resolve_mask;
+ current_group = p.current_group;
+ if(!d->ref.deref())
+ delete d;
+ d = p.d;
+ return *this;
+}
+
+/*!
+ Returns the palette as a QVariant
+*/
+QPalette::operator QVariant() const
+{
+ return QVariant(QVariant::Palette, this);
+}
+
+/*!
+ \fn const QColor &QPalette::color(ColorGroup group, ColorRole role) const
+
+ Returns the color in the specified color \a group, used for the
+ given color \a role.
+
+ \sa brush() setColor() ColorRole
+*/
+
+/*!
+ \fn const QBrush &QPalette::brush(ColorGroup group, ColorRole role) const
+
+ Returns the brush in the specified color \a group, used for the
+ given color \a role.
+
+ \sa color() setBrush() ColorRole
+*/
+const QBrush &QPalette::brush(ColorGroup gr, ColorRole cr) const
+{
+ Q_ASSERT(cr < NColorRoles);
+ if(gr >= (int)NColorGroups) {
+ if(gr == Current) {
+ gr = (ColorGroup)current_group;
+ } else {
+ qWarning("QPalette::brush: Unknown ColorGroup: %d", (int)gr);
+ gr = Active;
+ }
+ }
+ return d->br[gr][cr];
+}
+
+/*!
+ \fn void QPalette::setColor(ColorGroup group, ColorRole role, const QColor &color)
+
+ Sets the color in the specified color \a group, used for the given
+ color \a role, to the specified solid \a color.
+
+ \sa setBrush() color() ColorRole
+*/
+
+/*!
+ \fn void QPalette::setBrush(ColorGroup group, ColorRole role, const QBrush &brush)
+ \overload
+
+ Sets the brush in the specified color \a group, used for the given
+ color \a role, to \a brush.
+
+ \sa brush() setColor() ColorRole
+*/
+void QPalette::setBrush(ColorGroup cg, ColorRole cr, const QBrush &b)
+{
+ Q_ASSERT(cr < NColorRoles);
+ detach();
+ if(cg >= (int)NColorGroups) {
+ if(cg == All) {
+ for(int i = 0; i < (int)NColorGroups; i++)
+ d->br[i][cr] = b;
+ resolve_mask |= (1<<cr);
+ return;
+ } else if(cg == Current) {
+ cg = (ColorGroup)current_group;
+ } else {
+ qWarning("QPalette::setBrush: Unknown ColorGroup: %d", (int)cg);
+ cg = Active;
+ }
+ }
+ d->br[cg][cr] = b;
+ resolve_mask |= (1<<cr);
+}
+
+/*!
+ \since 4.2
+
+ Returns true if the ColorGroup \a cg and ColorRole \a cr has been
+ set previously on this palette; otherwise returns false.
+
+ \sa setBrush()
+*/
+bool QPalette::isBrushSet(ColorGroup cg, ColorRole cr) const
+{
+ Q_UNUSED(cg);
+ return (resolve_mask & (1<<cr));
+}
+
+/*!
+ \internal
+*/
+void QPalette::detach()
+{
+ if (d->ref != 1) {
+ QPalettePrivate *x = new QPalettePrivate;
+ for(int grp = 0; grp < (int)NColorGroups; grp++) {
+ for(int role = 0; role < (int)NColorRoles; role++)
+ x->br[grp][role] = d->br[grp][role];
+ }
+ if(!d->ref.deref())
+ delete d;
+ d = x;
+ }
+ ++d->detach_no;
+}
+
+/*!
+ \fn bool QPalette::operator!=(const QPalette &p) const
+
+ Returns true (slowly) if this palette is different from \a p;
+ otherwise returns false (usually quickly).
+
+ \note The current ColorGroup is not taken into account when
+ comparing palettes
+
+ \sa operator==()
+*/
+
+/*!
+ Returns true (usually quickly) if this palette is equal to \a p;
+ otherwise returns false (slowly).
+
+ \note The current ColorGroup is not taken into account when
+ comparing palettes
+
+ \sa operator!=()
+*/
+bool QPalette::operator==(const QPalette &p) const
+{
+ if (isCopyOf(p))
+ return true;
+ for(int grp = 0; grp < (int)NColorGroups; grp++) {
+ for(int role = 0; role < (int)NColorRoles; role++) {
+ if(d->br[grp][role] != p.d->br[grp][role])
+ return false;
+ }
+ }
+ return true;
+}
+
+/*!
+ \fn bool QPalette::isEqual(ColorGroup cg1, ColorGroup cg2) const
+
+ Returns true (usually quickly) if color group \a cg1 is equal to
+ \a cg2; otherwise returns false.
+*/
+bool QPalette::isEqual(QPalette::ColorGroup group1, QPalette::ColorGroup group2) const
+{
+ if(group1 >= (int)NColorGroups) {
+ if(group1 == Current) {
+ group1 = (ColorGroup)current_group;
+ } else {
+ qWarning("QPalette::brush: Unknown ColorGroup(1): %d", (int)group1);
+ group1 = Active;
+ }
+ }
+ if(group2 >= (int)NColorGroups) {
+ if(group2 == Current) {
+ group2 = (ColorGroup)current_group;
+ } else {
+ qWarning("QPalette::brush: Unknown ColorGroup(2): %d", (int)group2);
+ group2 = Active;
+ }
+ }
+ if(group1 == group2)
+ return true;
+ for(int role = 0; role < (int)NColorRoles; role++) {
+ if(d->br[group1][role] != d->br[group2][role])
+ return false;
+ }
+ return true;
+}
+
+/*! \obsolete
+
+ Returns a number that identifies the contents of this QPalette
+ object. Distinct QPalette objects can only have the same serial
+ number if they refer to the same contents (but they don't have
+ to). Also, the serial number of a QPalette may change during the
+ lifetime of the object.
+
+ Use cacheKey() instead.
+
+ \warning The serial number doesn't necessarily change when the
+ palette is altered. This means that it may be dangerous to use it
+ as a cache key.
+
+ \sa operator==()
+*/
+int QPalette::serialNumber() const
+{
+ return d->ser_no;
+}
+
+/*!
+ Returns a number that identifies the contents of this QPalette
+ object. Distinct QPalette objects can have the same key if
+ they refer to the same contents.
+
+ The cacheKey() will change when the palette is altered.
+*/
+qint64 QPalette::cacheKey() const
+{
+ return (((qint64) d->ser_no) << 32) | ((qint64) (d->detach_no));
+}
+
+/*!
+ Returns a new QPalette that has attributes copied from \a other.
+*/
+QPalette QPalette::resolve(const QPalette &other) const
+{
+ if ((*this == other && resolve_mask == other.resolve_mask)
+ || resolve_mask == 0) {
+ QPalette o = other;
+ o.resolve_mask = resolve_mask;
+ return o;
+ }
+
+ QPalette palette(*this);
+ palette.detach();
+
+ for(int role = 0; role < (int)NColorRoles; role++)
+ if (!(resolve_mask & (1<<role)))
+ for(int grp = 0; grp < (int)NColorGroups; grp++)
+ palette.d->br[grp][role] = other.d->br[grp][role];
+
+ return palette;
+}
+
+/*!
+ \fn uint QPalette::resolve() const
+ \internal
+*/
+
+/*!
+ \fn void QPalette::resolve(uint mask)
+ \internal
+*/
+
+
+/*****************************************************************************
+ QPalette stream functions
+ *****************************************************************************/
+
+#ifndef QT_NO_DATASTREAM
+
+static const int NumOldRoles = 7;
+static const int oldRoles[7] = { QPalette::Foreground, QPalette::Background, QPalette::Light,
+ QPalette::Dark, QPalette::Mid, QPalette::Text, QPalette::Base };
+
+/*!
+ \relates QPalette
+
+ Writes the palette, \a p to the stream \a s and returns a
+ reference to the stream.
+
+ \sa \link datastreamformat.html Format of the QDataStream operators \endlink
+*/
+
+QDataStream &operator<<(QDataStream &s, const QPalette &p)
+{
+ for (int grp = 0; grp < (int)QPalette::NColorGroups; grp++) {
+ if (s.version() == 1) {
+ // Qt 1.x
+ for (int i = 0; i < NumOldRoles; ++i)
+ s << p.d->br[grp][oldRoles[i]].color();
+ } else {
+ int max = QPalette::ToolTipText + 1;
+ if (s.version() <= QDataStream::Qt_2_1)
+ max = QPalette::HighlightedText + 1;
+ else if (s.version() <= QDataStream::Qt_4_3)
+ max = QPalette::AlternateBase + 1;
+ for (int r = 0; r < max; r++)
+ s << p.d->br[grp][r];
+ }
+ }
+ return s;
+}
+
+static void readV1ColorGroup(QDataStream &s, QPalette &pal, QPalette::ColorGroup grp)
+{
+ for (int i = 0; i < NumOldRoles; ++i) {
+ QColor col;
+ s >> col;
+ pal.setColor(grp, (QPalette::ColorRole)oldRoles[i], col);
+ }
+}
+
+/*!
+ \relates QPalette
+
+ Reads a palette from the stream, \a s into the palette \a p, and
+ returns a reference to the stream.
+
+ \sa \link datastreamformat.html Format of the QDataStream operators \endlink
+*/
+
+QDataStream &operator>>(QDataStream &s, QPalette &p)
+{
+ if(s.version() == 1) {
+ p = QPalette();
+ readV1ColorGroup(s, p, QPalette::Active);
+ readV1ColorGroup(s, p, QPalette::Disabled);
+ readV1ColorGroup(s, p, QPalette::Inactive);
+ } else {
+ int max = QPalette::NColorRoles;
+ if (s.version() <= QDataStream::Qt_2_1) {
+ p = QPalette();
+ max = QPalette::HighlightedText + 1;
+ } else if (s.version() <= QDataStream::Qt_4_3) {
+ p = QPalette();
+ max = QPalette::AlternateBase + 1;
+ }
+
+ QBrush tmp;
+ for(int grp = 0; grp < (int)QPalette::NColorGroups; ++grp) {
+ for(int role = 0; role < max; ++role) {
+ s >> tmp;
+ p.setBrush((QPalette::ColorGroup)grp, (QPalette::ColorRole)role, tmp);
+ }
+ }
+ }
+ return s;
+}
+#endif //QT_NO_DATASTREAM
+
+/*!
+ Returns true if this palette and \a p are copies of each other,
+ i.e. one of them was created as a copy of the other and neither
+ was subsequently modified; otherwise returns false. This is much
+ stricter than equality.
+
+ \sa operator=() operator==()
+*/
+
+bool QPalette::isCopyOf(const QPalette &p) const
+{
+ return d == p.d;
+}
+
+/*!
+
+ Sets a the group at \a cg. You can pass either brushes, pixmaps or
+ plain colors for \a windowText, \a button, \a light, \a dark, \a
+ mid, \a text, \a bright_text, \a base and \a window.
+
+ \sa QBrush
+*/
+void QPalette::setColorGroup(ColorGroup cg, const QBrush &windowText, const QBrush &button,
+ const QBrush &light, const QBrush &dark, const QBrush &mid,
+ const QBrush &text, const QBrush &bright_text, const QBrush &base,
+ const QBrush &window)
+{
+ QBrush alt_base = QBrush(qt_mix_colors(base.color(), button.color()));
+ QBrush mid_light = QBrush(qt_mix_colors(button.color(), light.color()));
+ QColor toolTipBase(255, 255, 220);
+ QColor toolTipText(0, 0, 0);
+
+ setColorGroup(cg, windowText, button, light, dark, mid, text, bright_text, base,
+ alt_base, window, mid_light, text,
+ QBrush(Qt::black), QBrush(Qt::darkBlue), QBrush(Qt::white),
+ QBrush(Qt::blue), QBrush(Qt::magenta), QBrush(toolTipBase),
+ QBrush(toolTipText));
+
+ resolve_mask &= ~(1 << Highlight);
+ resolve_mask &= ~(1 << HighlightedText);
+ resolve_mask &= ~(1 << LinkVisited);
+ resolve_mask &= ~(1 << Link);
+}
+
+
+/*!\internal*/
+void
+QPalette::setColorGroup(ColorGroup cg, const QBrush &foreground, const QBrush &button,
+ const QBrush &light, const QBrush &dark, const QBrush &mid,
+ const QBrush &text, const QBrush &bright_text,
+ const QBrush &base, const QBrush &alternate_base,
+ const QBrush &background, const QBrush &midlight,
+ const QBrush &button_text, const QBrush &shadow,
+ const QBrush &highlight, const QBrush &highlighted_text,
+ const QBrush &link, const QBrush &link_visited)
+{
+ setColorGroup(cg, foreground, button, light, dark, mid,
+ text, bright_text, base, alternate_base, background,
+ midlight, button_text, shadow, highlight, highlighted_text,
+ link, link_visited, background, foreground);
+}
+
+/*!\internal*/
+void QPalette::setColorGroup(ColorGroup cg, const QBrush &foreground, const QBrush &button,
+ const QBrush &light, const QBrush &dark, const QBrush &mid,
+ const QBrush &text, const QBrush &bright_text,
+ const QBrush &base, const QBrush &alternate_base,
+ const QBrush &background, const QBrush &midlight,
+ const QBrush &button_text, const QBrush &shadow,
+ const QBrush &highlight, const QBrush &highlighted_text,
+ const QBrush &link, const QBrush &link_visited,
+ const QBrush &toolTipBase, const QBrush &toolTipText)
+{
+ detach();
+ setBrush(cg, WindowText, foreground);
+ setBrush(cg, Button, button);
+ setBrush(cg, Light, light);
+ setBrush(cg, Dark, dark);
+ setBrush(cg, Mid, mid);
+ setBrush(cg, Text, text);
+ setBrush(cg, BrightText, bright_text);
+ setBrush(cg, Base, base);
+ setBrush(cg, AlternateBase, alternate_base);
+ setBrush(cg, Window, background);
+ setBrush(cg, Midlight, midlight);
+ setBrush(cg, ButtonText, button_text);
+ setBrush(cg, Shadow, shadow);
+ setBrush(cg, Highlight, highlight);
+ setBrush(cg, HighlightedText, highlighted_text);
+ setBrush(cg, Link, link);
+ setBrush(cg, LinkVisited, link_visited);
+ setBrush(cg, ToolTipBase, toolTipBase);
+ setBrush(cg, ToolTipText, toolTipText);
+}
+
+/*!
+ \fn QPalette QPalette::copy() const
+
+ Use simple assignment instead.
+*/
+
+
+QT_END_NAMESPACE
diff --git a/src/gui/guikernel/qpalette.h b/src/gui/guikernel/qpalette.h
new file mode 100644
index 0000000000..17f3d0f653
--- /dev/null
+++ b/src/gui/guikernel/qpalette.h
@@ -0,0 +1,197 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPALETTE_H
+#define QPALETTE_H
+
+#include <QtGui/qwindowdefs.h>
+#include <QtGui/qcolor.h>
+#include <QtGui/qbrush.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QPalettePrivate;
+class QVariant;
+
+class Q_GUI_EXPORT QPalette
+{
+ Q_GADGET
+ Q_ENUMS(ColorGroup ColorRole)
+public:
+ QPalette();
+ QPalette(const QColor &button);
+ QPalette(Qt::GlobalColor button);
+ QPalette(const QColor &button, const QColor &window);
+ QPalette(const QBrush &windowText, const QBrush &button, const QBrush &light,
+ const QBrush &dark, const QBrush &mid, const QBrush &text,
+ const QBrush &bright_text, const QBrush &base, const QBrush &window);
+ QPalette(const QColor &windowText, const QColor &window, const QColor &light,
+ const QColor &dark, const QColor &mid, const QColor &text, const QColor &base);
+ QPalette(const QPalette &palette);
+ ~QPalette();
+ QPalette &operator=(const QPalette &palette);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QPalette &operator=(QPalette &&other)
+ {
+ resolve_mask = other.resolve_mask;
+ current_group = other.current_group;
+ qSwap(d, other.d); return *this;
+ }
+#endif
+ operator QVariant() const;
+
+ // Do not change the order, the serialization format depends on it
+ enum ColorGroup { Active, Disabled, Inactive, NColorGroups, Current, All, Normal = Active };
+ enum ColorRole { WindowText, Button, Light, Midlight, Dark, Mid,
+ Text, BrightText, ButtonText, Base, Window, Shadow,
+ Highlight, HighlightedText,
+ Link, LinkVisited, // ### Qt 5: remove
+ AlternateBase,
+ NoRole, // ### Qt 5: value should be 0 or -1
+ ToolTipBase, ToolTipText,
+ NColorRoles = ToolTipText + 1,
+ Foreground = WindowText, Background = Window // ### Qt 5: remove
+ };
+
+ inline ColorGroup currentColorGroup() const { return static_cast<ColorGroup>(current_group); }
+ inline void setCurrentColorGroup(ColorGroup cg) { current_group = cg; }
+
+ inline const QColor &color(ColorGroup cg, ColorRole cr) const
+ { return brush(cg, cr).color(); }
+ const QBrush &brush(ColorGroup cg, ColorRole cr) const;
+ inline void setColor(ColorGroup cg, ColorRole cr, const QColor &color);
+ inline void setColor(ColorRole cr, const QColor &color);
+ inline void setBrush(ColorRole cr, const QBrush &brush);
+ bool isBrushSet(ColorGroup cg, ColorRole cr) const;
+ void setBrush(ColorGroup cg, ColorRole cr, const QBrush &brush);
+ void setColorGroup(ColorGroup cr, const QBrush &windowText, const QBrush &button,
+ const QBrush &light, const QBrush &dark, const QBrush &mid,
+ const QBrush &text, const QBrush &bright_text, const QBrush &base,
+ const QBrush &window);
+ bool isEqual(ColorGroup cr1, ColorGroup cr2) const;
+
+ inline const QColor &color(ColorRole cr) const { return color(Current, cr); }
+ inline const QBrush &brush(ColorRole cr) const { return brush(Current, cr); }
+ inline const QBrush &foreground() const { return brush(WindowText); }
+ inline const QBrush &windowText() const { return brush(WindowText); }
+ inline const QBrush &button() const { return brush(Button); }
+ inline const QBrush &light() const { return brush(Light); }
+ inline const QBrush &dark() const { return brush(Dark); }
+ inline const QBrush &mid() const { return brush(Mid); }
+ inline const QBrush &text() const { return brush(Text); }
+ inline const QBrush &base() const { return brush(Base); }
+ inline const QBrush &alternateBase() const { return brush(AlternateBase); }
+ inline const QBrush &toolTipBase() const { return brush(ToolTipBase); }
+ inline const QBrush &toolTipText() const { return brush(ToolTipText); }
+ inline const QBrush &background() const { return brush(Window); }
+ inline const QBrush &window() const { return brush(Window); }
+ inline const QBrush &midlight() const { return brush(Midlight); }
+ inline const QBrush &brightText() const { return brush(BrightText); }
+ inline const QBrush &buttonText() const { return brush(ButtonText); }
+ inline const QBrush &shadow() const { return brush(Shadow); }
+ inline const QBrush &highlight() const { return brush(Highlight); }
+ inline const QBrush &highlightedText() const { return brush(HighlightedText); }
+ inline const QBrush &link() const { return brush(Link); }
+ inline const QBrush &linkVisited() const { return brush(LinkVisited); }
+
+ bool operator==(const QPalette &p) const;
+ inline bool operator!=(const QPalette &p) const { return !(operator==(p)); }
+ bool isCopyOf(const QPalette &p) const;
+
+ int serialNumber() const;
+ qint64 cacheKey() const;
+
+ QPalette resolve(const QPalette &) const;
+ inline uint resolve() const { return resolve_mask; }
+ inline void resolve(uint mask) { resolve_mask = mask; }
+
+private:
+ void setColorGroup(ColorGroup cr, const QBrush &windowText, const QBrush &button,
+ const QBrush &light, const QBrush &dark, const QBrush &mid,
+ const QBrush &text, const QBrush &bright_text,
+ const QBrush &base, const QBrush &alternate_base,
+ const QBrush &window, const QBrush &midlight,
+ const QBrush &button_text, const QBrush &shadow,
+ const QBrush &highlight, const QBrush &highlighted_text,
+ const QBrush &link, const QBrush &link_visited);
+ void setColorGroup(ColorGroup cr, const QBrush &windowText, const QBrush &button,
+ const QBrush &light, const QBrush &dark, const QBrush &mid,
+ const QBrush &text, const QBrush &bright_text,
+ const QBrush &base, const QBrush &alternate_base,
+ const QBrush &window, const QBrush &midlight,
+ const QBrush &button_text, const QBrush &shadow,
+ const QBrush &highlight, const QBrush &highlighted_text,
+ const QBrush &link, const QBrush &link_visited,
+ const QBrush &toolTipBase, const QBrush &toolTipText);
+ void init();
+ void detach();
+
+ QPalettePrivate *d;
+ uint current_group : 4;
+ uint resolve_mask : 28;
+ friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &s, const QPalette &p);
+};
+
+inline void QPalette::setColor(ColorGroup acg, ColorRole acr,
+ const QColor &acolor)
+{ setBrush(acg, acr, QBrush(acolor)); }
+inline void QPalette::setColor(ColorRole acr, const QColor &acolor)
+{ setColor(All, acr, acolor); }
+inline void QPalette::setBrush(ColorRole acr, const QBrush &abrush)
+{ setBrush(All, acr, abrush); }
+
+/*****************************************************************************
+ QPalette stream functions
+ *****************************************************************************/
+#ifndef QT_NO_DATASTREAM
+Q_GUI_EXPORT QDataStream &operator<<(QDataStream &ds, const QPalette &p);
+Q_GUI_EXPORT QDataStream &operator>>(QDataStream &ds, QPalette &p);
+#endif // QT_NO_DATASTREAM
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPALETTE_H
diff --git a/src/gui/kernel/qplatformclipboard_qpa.cpp b/src/gui/guikernel/qplatformclipboard_qpa.cpp
index 302df683bd..302df683bd 100644
--- a/src/gui/kernel/qplatformclipboard_qpa.cpp
+++ b/src/gui/guikernel/qplatformclipboard_qpa.cpp
diff --git a/src/gui/kernel/qplatformclipboard_qpa.h b/src/gui/guikernel/qplatformclipboard_qpa.h
index e1be8aa22f..e1be8aa22f 100644
--- a/src/gui/kernel/qplatformclipboard_qpa.h
+++ b/src/gui/guikernel/qplatformclipboard_qpa.h
diff --git a/src/gui/guikernel/qplatformcursor_qpa.cpp b/src/gui/guikernel/qplatformcursor_qpa.cpp
new file mode 100644
index 0000000000..f43eca640f
--- /dev/null
+++ b/src/gui/guikernel/qplatformcursor_qpa.cpp
@@ -0,0 +1,659 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtOpenVG module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qplatformcursor_qpa.h"
+
+#include <QPainter>
+#include <QBitmap>
+#include <QGuiApplication>
+
+#include <QDebug>
+
+QT_BEGIN_NAMESPACE
+
+QList <QWeakPointer<QPlatformCursor> > QPlatformCursorPrivate::instances;
+
+/*!
+ \class QGraphicsSystemCursor
+
+ \brief The QGraphicsSystemCursor class provides information about
+ pointer device events (movement, buttons), and requests to change
+ the currently displayed cursor.
+
+ Note that QGraphicsSystemCursor does not include any graphics for
+ display. An application that sets a QCursor may provide its own
+ graphics.
+
+ \sa QGraphicsSystemCursorImage
+*/
+
+/*!
+ \fn virtual void QGraphicsSystemCursor::pointerEvent(const QMouseEvent & event)
+
+ This method is called by Qt whenever a QMouseEvent is generated by the
+ underlying pointer input. \a event is a reference to the QMouseEvent in
+ question. A default do-nothing implementation is provided.
+
+ \sa QApplicationPrivate::handleMouseEvent()
+*/
+
+/*!
+ \fn virtual void QGraphicsSystemCursor::changeCursor(QCursor * widgetCursor, QWidget * widget)
+
+ \brief This method is called by Qt whenever the cursor graphic should be changed.
+
+ Implementation of this method is mandatory for a subclass of QGraphicsSystemCursor.
+
+ \a widgetCursor is a pointer to the QCursor that should be displayed.
+
+ \a widget is a pointer to the widget currently displayed at QCursor::pos(). Note
+ that this may be 0 if the current position is not occupied by a displayed widget.
+
+ \sa QApplicationPrivate::handleMouseEvent(), QCursor::pos()
+*/
+
+/*!
+ \fn QGraphicsSystemCursor::QGraphicsSystemCursor()
+
+ \brief Constructs a QGraphicsSystemCursor
+*/
+QPlatformCursor::QPlatformCursor(QPlatformScreen *scr )
+ : screen(scr)
+{
+ QPlatformCursorPrivate::instances.append(this);
+}
+
+// End of display and pointer event handling code
+// Beginning of built-in cursor graphics
+// from src/gui/embedded/QGraphicsSystemCursorImage_qws.cpp
+
+/*!
+ \class QGraphicsSystemCursorImage
+
+ \brief The QGraphicsSystemCursorImage class provides a set of graphics
+ intended to be used as cursors.
+
+ \sa QGraphicsSystemCursor
+*/
+
+static QPlatformCursorImage *systemCursorTable[Qt::LastCursor+1];
+static bool systemCursorTableInit = false;
+
+// 16 x 16
+static const uchar cur_arrow_bits[] = {
+ 0x07, 0x00, 0x39, 0x00, 0xc1, 0x01, 0x02, 0x0e, 0x02, 0x10, 0x02, 0x08,
+ 0x04, 0x04, 0x04, 0x02, 0x04, 0x04, 0x88, 0x08, 0x48, 0x11, 0x28, 0x22,
+ 0x10, 0x44, 0x00, 0x28, 0x00, 0x10, 0x00, 0x00 };
+static const uchar mcur_arrow_bits[] = {
+ 0x07, 0x00, 0x3f, 0x00, 0xff, 0x01, 0xfe, 0x0f, 0xfe, 0x1f, 0xfe, 0x0f,
+ 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x0f, 0x78, 0x1f, 0x38, 0x3e,
+ 0x10, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00, 0x00 };
+
+static const unsigned char cur_up_arrow_bits[] = {
+ 0x80, 0x00, 0x40, 0x01, 0x40, 0x01, 0x20, 0x02, 0x20, 0x02, 0x10, 0x04,
+ 0x10, 0x04, 0x08, 0x08, 0x78, 0x0f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01,
+ 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01};
+static const unsigned char mcur_up_arrow_bits[] = {
+ 0x80, 0x00, 0xc0, 0x01, 0xc0, 0x01, 0xe0, 0x03, 0xe0, 0x03, 0xf0, 0x07,
+ 0xf0, 0x07, 0xf8, 0x0f, 0xf8, 0x0f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
+ 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01};
+
+static const unsigned char cur_cross_bits[] = {
+ 0xc0, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01,
+ 0x7f, 0x7f, 0x01, 0x40, 0x7f, 0x7f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01,
+ 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01, 0x00, 0x00};
+static const unsigned char mcur_cross_bits[] = {
+ 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
+ 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
+ 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00};
+
+static const uchar cur_ibeam_bits[] = {
+ 0x00, 0x00, 0xe0, 0x03, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00,
+ 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00,
+ 0x80, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00 };
+static const uchar mcur_ibeam_bits[] = {
+ 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
+ 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
+ 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0x00, 0x00 };
+
+static const uchar cur_ver_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f,
+ 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f,
+ 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 };
+static const uchar mcur_ver_bits[] = {
+ 0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f,
+ 0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f,
+ 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 };
+
+static const uchar cur_hor_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18,
+ 0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uchar mcur_hor_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c,
+ 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c,
+ 0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 };
+static const uchar cur_bdiag_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e,
+ 0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00,
+ 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uchar mcur_bdiag_bits[] = {
+ 0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f,
+ 0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01,
+ 0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 };
+static const uchar cur_fdiag_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00,
+ 0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c,
+ 0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 };
+static const uchar mcur_fdiag_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00,
+ 0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e,
+ 0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 };
+
+// 20 x 20
+static const uchar forbidden_bits[] = {
+ 0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01,
+ 0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06,
+ 0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03,
+ 0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 };
+
+static const uchar forbiddenm_bits[] = {
+ 0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03,
+ 0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f,
+ 0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07,
+ 0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00};
+
+// 32 x 32
+static const uchar wait_data_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00,
+ 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x08, 0x20, 0x00,
+ 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00,
+ 0x00, 0x50, 0x15, 0x00, 0x00, 0xa0, 0x0a, 0x00, 0x00, 0x40, 0x05, 0x00,
+ 0x00, 0x80, 0x02, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x20, 0x08, 0x00,
+ 0x00, 0x10, 0x10, 0x00, 0x00, 0x08, 0x21, 0x00, 0x00, 0x88, 0x22, 0x00,
+ 0x00, 0x48, 0x25, 0x00, 0x00, 0xa8, 0x2a, 0x00, 0x00, 0xfc, 0x7f, 0x00,
+ 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uchar wait_mask_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00,
+ 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xf8, 0x3f, 0x00,
+ 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00,
+ 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xc0, 0x07, 0x00,
+ 0x00, 0x80, 0x03, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xe0, 0x0f, 0x00,
+ 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00,
+ 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00,
+ 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+static const uchar hsplit_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
+ 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
+ 0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03,
+ 0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00,
+ 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
+ 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uchar hsplitm_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
+ 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00,
+ 0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07,
+ 0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00,
+ 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
+ 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uchar vsplit_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00,
+ 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uchar vsplitm_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00,
+ 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
+ 0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
+ 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
+ 0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
+ 0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00,
+ 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uchar phand_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00,
+ 0x7e, 0x04, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x70, 0x08, 0x00, 0x00,
+ 0x08, 0x08, 0x00, 0x00, 0x70, 0x14, 0x00, 0x00, 0x08, 0x22, 0x00, 0x00,
+ 0x30, 0x41, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0x40, 0x12, 0x00, 0x00,
+ 0x80, 0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uchar phandm_bits[] = {
+ 0xfe, 0x01, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0xff, 0x07, 0x00, 0x00,
+ 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00,
+ 0xfc, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00,
+ 0xf8, 0xff, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00,
+ 0xc0, 0x1f, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00,
+ 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+static const uchar size_all_data_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x80, 0x81, 0xc0, 0x00,
+ 0xc0, 0xff, 0xff, 0x01, 0x80, 0x81, 0xc0, 0x00, 0x00, 0x81, 0x40, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00,
+ 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+static const uchar size_all_mask_bits[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
+ 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00,
+ 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc2, 0x21, 0x00,
+ 0x00, 0xc3, 0x61, 0x00, 0x80, 0xc3, 0xe1, 0x00, 0xc0, 0xff, 0xff, 0x01,
+ 0xe0, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0x01, 0x80, 0xc3, 0xe1, 0x00,
+ 0x00, 0xc3, 0x61, 0x00, 0x00, 0xc2, 0x21, 0x00, 0x00, 0xc0, 0x01, 0x00,
+ 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0xe0, 0x03, 0x00,
+ 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
+
+static const uchar whatsthis_bits[] = {
+ 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00,
+ 0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00,
+ 0x41, 0x1c, 0x0e, 0x00, 0x81, 0x1c, 0x0e, 0x00, 0x01, 0x01, 0x07, 0x00,
+ 0x01, 0x82, 0x03, 0x00, 0xc1, 0xc7, 0x01, 0x00, 0x49, 0xc0, 0x01, 0x00,
+ 0x95, 0xc0, 0x01, 0x00, 0x93, 0xc0, 0x01, 0x00, 0x21, 0x01, 0x00, 0x00,
+ 0x20, 0xc1, 0x01, 0x00, 0x40, 0xc2, 0x01, 0x00, 0x40, 0x02, 0x00, 0x00,
+ 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
+static const uchar whatsthism_bits[] = {
+ 0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00,
+ 0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00,
+ 0x7f, 0x3e, 0x1f, 0x00, 0xff, 0x3e, 0x1f, 0x00, 0xff, 0x9d, 0x0f, 0x00,
+ 0xff, 0xc3, 0x07, 0x00, 0xff, 0xe7, 0x03, 0x00, 0x7f, 0xe0, 0x03, 0x00,
+ 0xf7, 0xe0, 0x03, 0x00, 0xf3, 0xe0, 0x03, 0x00, 0xe1, 0xe1, 0x03, 0x00,
+ 0xe0, 0xe1, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00,
+ 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
+
+static const uchar busy_bits[] = {
+ 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
+ 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00,
+ 0x41, 0xe0, 0xff, 0x00, 0x81, 0x20, 0x80, 0x00, 0x01, 0xe1, 0xff, 0x00,
+ 0x01, 0x42, 0x40, 0x00, 0xc1, 0x47, 0x40, 0x00, 0x49, 0x40, 0x55, 0x00,
+ 0x95, 0x80, 0x2a, 0x00, 0x93, 0x00, 0x15, 0x00, 0x21, 0x01, 0x0a, 0x00,
+ 0x20, 0x01, 0x11, 0x00, 0x40, 0x82, 0x20, 0x00, 0x40, 0x42, 0x44, 0x00,
+ 0x80, 0x41, 0x4a, 0x00, 0x00, 0x40, 0x55, 0x00, 0x00, 0xe0, 0xff, 0x00,
+ 0x00, 0x20, 0x80, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+static const uchar busym_bits[] = {
+ 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
+ 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00,
+ 0x7f, 0xe0, 0xff, 0x00, 0xff, 0xe0, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00,
+ 0xff, 0xc3, 0x7f, 0x00, 0xff, 0xc7, 0x7f, 0x00, 0x7f, 0xc0, 0x7f, 0x00,
+ 0xf7, 0x80, 0x3f, 0x00, 0xf3, 0x00, 0x1f, 0x00, 0xe1, 0x01, 0x0e, 0x00,
+ 0xe0, 0x01, 0x1f, 0x00, 0xc0, 0x83, 0x3f, 0x00, 0xc0, 0xc3, 0x7f, 0x00,
+ 0x80, 0xc1, 0x7f, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0x00,
+ 0x00, 0xe0, 0xff, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+
+// 16 x 16
+static const uchar openhand_bits[] = {
+ 0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92,
+ 0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20,
+ 0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00};
+static const uchar openhandm_bits[] = {
+ 0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff,
+ 0xfe,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f,
+ 0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00};
+static const uchar closedhand_bits[] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50,
+ 0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10,
+ 0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00};
+static const uchar closedhandm_bits[] = {
+ 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f,
+ 0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f,
+ 0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00};
+
+void QPlatformCursorImage::createSystemCursor(int id)
+{
+ if (!systemCursorTableInit) {
+ for (int i = 0; i <= Qt::LastCursor; i++)
+ systemCursorTable[i] = 0;
+ systemCursorTableInit = true;
+ }
+ switch (id) {
+ // 16x16 cursors
+ case Qt::ArrowCursor:
+ systemCursorTable[Qt::ArrowCursor] =
+ new QPlatformCursorImage(cur_arrow_bits, mcur_arrow_bits, 16, 16, 0, 0);
+ break;
+
+ case Qt::UpArrowCursor:
+ systemCursorTable[Qt::UpArrowCursor] =
+ new QPlatformCursorImage(cur_up_arrow_bits, mcur_up_arrow_bits, 16, 16, 7, 0);
+ break;
+
+ case Qt::CrossCursor:
+ systemCursorTable[Qt::CrossCursor] =
+ new QPlatformCursorImage(cur_cross_bits, mcur_cross_bits, 16, 16, 7, 7);
+ break;
+
+ case Qt::IBeamCursor:
+ systemCursorTable[Qt::IBeamCursor] =
+ new QPlatformCursorImage(cur_ibeam_bits, mcur_ibeam_bits, 16, 16, 7, 7);
+ break;
+
+ case Qt::SizeVerCursor:
+ systemCursorTable[Qt::SizeVerCursor] =
+ new QPlatformCursorImage(cur_ver_bits, mcur_ver_bits, 16, 16, 7, 7);
+ break;
+
+ case Qt::SizeHorCursor:
+ systemCursorTable[Qt::SizeHorCursor] =
+ new QPlatformCursorImage(cur_hor_bits, mcur_hor_bits, 16, 16, 7, 7);
+ break;
+
+ case Qt::SizeBDiagCursor:
+ systemCursorTable[Qt::SizeBDiagCursor] =
+ new QPlatformCursorImage(cur_bdiag_bits, mcur_bdiag_bits, 16, 16, 7, 7);
+ break;
+
+ case Qt::SizeFDiagCursor:
+ systemCursorTable[Qt::SizeFDiagCursor] =
+ new QPlatformCursorImage(cur_fdiag_bits, mcur_fdiag_bits, 16, 16, 7, 7);
+ break;
+
+ case Qt::BlankCursor:
+ systemCursorTable[Qt::BlankCursor] =
+ new QPlatformCursorImage(0, 0, 0, 0, 0, 0);
+ break;
+
+ // 20x20 cursors
+ case Qt::ForbiddenCursor:
+ systemCursorTable[Qt::ForbiddenCursor] =
+ new QPlatformCursorImage(forbidden_bits, forbiddenm_bits, 20, 20, 10, 10);
+ break;
+
+ // 32x32 cursors
+ case Qt::WaitCursor:
+ systemCursorTable[Qt::WaitCursor] =
+ new QPlatformCursorImage(wait_data_bits, wait_mask_bits, 32, 32, 15, 15);
+ break;
+
+ case Qt::SplitVCursor:
+ systemCursorTable[Qt::SplitVCursor] =
+ new QPlatformCursorImage(vsplit_bits, vsplitm_bits, 32, 32, 15, 15);
+ break;
+
+ case Qt::SplitHCursor:
+ systemCursorTable[Qt::SplitHCursor] =
+ new QPlatformCursorImage(hsplit_bits, hsplitm_bits, 32, 32, 15, 15);
+ break;
+
+ case Qt::SizeAllCursor:
+ systemCursorTable[Qt::SizeAllCursor] =
+ new QPlatformCursorImage(size_all_data_bits, size_all_mask_bits, 32, 32, 15, 15);
+ break;
+
+ case Qt::PointingHandCursor:
+ systemCursorTable[Qt::PointingHandCursor] =
+ new QPlatformCursorImage(phand_bits, phandm_bits, 32, 32, 0, 0);
+ break;
+
+ case Qt::WhatsThisCursor:
+ systemCursorTable[Qt::WhatsThisCursor] =
+ new QPlatformCursorImage(whatsthis_bits, whatsthism_bits, 32, 32, 0, 0);
+ break;
+ case Qt::BusyCursor:
+ systemCursorTable[Qt::BusyCursor] =
+ new QPlatformCursorImage(busy_bits, busym_bits, 32, 32, 0, 0);
+ break;
+
+ case Qt::OpenHandCursor:
+ systemCursorTable[Qt::OpenHandCursor] =
+ new QPlatformCursorImage(openhand_bits, openhandm_bits, 16, 16, 8, 8);
+ break;
+ case Qt::ClosedHandCursor:
+ systemCursorTable[Qt::ClosedHandCursor] =
+ new QPlatformCursorImage(closedhand_bits, closedhandm_bits, 16, 16, 8, 8);
+ break;
+ default:
+ qWarning("Unknown system cursor %d", id);
+ }
+}
+
+/*!
+ \fn void QGraphicsSystemCursorImage::set(Qt::CursorShape id)
+
+ \brief Calling this method sets the cursor image to the specified shape
+
+ \a id is one of the defined Qt::CursorShape values.
+
+ If id is invalid, Qt::BitmapCursor, or unknown by the implementation,
+ Qt::ArrowCursor is used instead.
+*/
+
+void QPlatformCursorImage::set(Qt::CursorShape id)
+{
+ QPlatformCursorImage *cursor = 0;
+ if (id >= 0 && id <= Qt::LastCursor) {
+ if (!systemCursorTable[id])
+ createSystemCursor(id);
+ cursor = systemCursorTable[id];
+ }
+
+ if (cursor == 0) {
+ if (!systemCursorTable[Qt::ArrowCursor])
+ createSystemCursor(Qt::ArrowCursor);
+ cursor = systemCursorTable[Qt::ArrowCursor];
+ }
+ cursorImage = cursor->cursorImage;
+ hot = cursor->hot;
+}
+
+/*!
+ \fn void QGraphicsSystemCursorImage::set(const QImage * image, int hx, int hy)
+
+ \brief Set the cursor image to the specified QImage, with the hotsport at (hx, hy)
+
+ \a image A pointer to a QImage
+
+ \a hx The x coordinate of the cursor's hotspot
+
+ \a hy the y coordinate of the cursor's hotspot
+*/
+
+void QPlatformCursorImage::set(const QImage &image, int hx, int hy)
+{
+ hot.setX(hx);
+ hot.setY(hy);
+ cursorImage = image;
+}
+
+/*!
+ \fn void QGraphicsSystemCursorImage::set(const uchar *data, const uchar *mask, int width, int height, int hx, int hy)
+
+ \brief set the cursor image to the graphic represented by the combination of data, mask,
+ width, and height
+
+ \a data The pixel data of the graphic
+
+ \a mask Mask data for the graphic. pixels in data with a corresponding mask bit of 0 are not drawn
+
+ \a width The width of the graphic in pixels
+
+ \a height The height of the graphic in pixels
+
+ \a hx The X hotspot of the cursor graphic
+
+ \a hy The Y hotspot of the cursor graphic
+*/
+void QPlatformCursorImage::set(const uchar *data, const uchar *mask,
+ int width, int height, int hx, int hy)
+{
+ hot.setX(hx);
+ hot.setY(hy);
+
+ cursorImage = QImage(width,height, QImage::Format_Indexed8);
+
+ if (!width || !height || !data || !mask || cursorImage.isNull())
+ return;
+
+ cursorImage.setNumColors(3);
+ cursorImage.setColor(0, 0xff000000);
+ cursorImage.setColor(1, 0xffffffff);
+ cursorImage.setColor(2, 0x00000000);
+
+ int bytesPerLine = (width + 7) / 8;
+ int p = 0;
+ int d, m;
+
+ int x = -1, w = 0;
+
+ uchar *cursor_data = cursorImage.bits();
+ int bpl = cursorImage.bytesPerLine();
+ for (int i = 0; i < height; i++)
+ {
+ for (int j = 0; j < bytesPerLine; j++, data++, mask++)
+ {
+ for (int b = 0; b < 8 && j*8+b < width; b++)
+ {
+ d = *data & (1 << b);
+ m = *mask & (1 << b);
+ if (d && m) p = 0;
+ else if (!d && m) p = 1;
+ else p = 2;
+ cursor_data[j*8+b] = p;
+
+ // calc region
+ if (x < 0 && m)
+ x = j*8+b;
+ else if (x >= 0 && !m) {
+ x = -1;
+ w = 0;
+ }
+ if (m)
+ w++;
+ }
+ }
+ if (x >= 0) {
+ x = -1;
+ w = 0;
+ }
+ cursor_data += bpl;
+ }
+
+}
+
+/*!
+ \fn QGraphicsSystemCursorImage::QGraphicsSystemCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY)
+
+ \brief set the cursor image to the graphic represented by the combination of data, mask,
+ width, and height
+
+ \a data The pixel data of the graphic
+
+ \a mask Mask data for the graphic. pixels in data with a corresponding mask bit of 0 are not drawn
+
+ \a width The width of the graphic in pixels
+
+ \a height The height of the graphic in pixels
+
+ \a hotX The X hotspot of the cursor graphic
+
+ \a hotY The Y hotspot of the cursor graphic
+
+ \sa set
+*/
+
+/*!
+ \fn QImage *QGraphicsSystemCursorImage::image()
+
+ \brief Return the cursor graphic as a pointer to a QImage
+*/
+
+/*!
+ \fn QPoint QGraphicsSystemCursorImage::hotspot()
+
+ \brief Return the cursor's hotspot
+*/
+
+QT_END_NAMESPACE
diff --git a/src/gui/guikernel/qplatformcursor_qpa.h b/src/gui/guikernel/qplatformcursor_qpa.h
new file mode 100644
index 0000000000..48e13bb954
--- /dev/null
+++ b/src/gui/guikernel/qplatformcursor_qpa.h
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtOpenVG module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QGRAPHICSSYSTEMCURSOR_H
+#define QGRAPHICSSYSTEMCURSOR_H
+
+#include <QtCore/QList>
+#include <QtGui/QImage>
+#include <QtGui/QMouseEvent>
+#include <QtCore/QWeakPointer>
+#include <QtCore/QObject>
+#include <QtGui/QPlatformScreen>
+#include <QtGui/QCursor>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+// Cursor graphics management
+class Q_GUI_EXPORT QPlatformCursorImage {
+public:
+ QPlatformCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY)
+ { set(data, mask, width, height, hotX, hotY); }
+ QImage * image() { return &cursorImage; }
+ QPoint hotspot() { return hot; }
+ void set(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY);
+ void set(const QImage &image, int hx, int hy);
+ void set(Qt::CursorShape);
+private:
+ static void createSystemCursor(int id);
+ QImage cursorImage;
+ QPoint hot;
+};
+
+class QPlatformCursor;
+
+class Q_GUI_EXPORT QPlatformCursorPrivate {
+public:
+ static QList<QWeakPointer<QPlatformCursor> > getInstances() { return instances; }
+ static QList<QWeakPointer<QPlatformCursor> > instances;
+};
+
+class Q_GUI_EXPORT QPlatformCursor : public QObject {
+public:
+ QPlatformCursor(QPlatformScreen *);
+
+ // input methods
+ virtual void pointerEvent(const QMouseEvent & event) { Q_UNUSED(event); }
+ virtual void changeCursor(QCursor * widgetCursor, QWindow * widget) = 0;
+
+protected:
+ QPlatformScreen* screen; // Where to request an update
+
+private:
+ Q_DECLARE_PRIVATE(QPlatformCursor);
+ friend void qt_qpa_set_cursor(QWidget * w, bool force);
+ friend class QApplicationPrivate;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QGRAPHICSSYSTEMCURSOR_H
diff --git a/src/gui/kernel/qplatformeventloopintegration_qpa.cpp b/src/gui/guikernel/qplatformeventloopintegration_qpa.cpp
index 0ed43eb4b5..0ed43eb4b5 100644
--- a/src/gui/kernel/qplatformeventloopintegration_qpa.cpp
+++ b/src/gui/guikernel/qplatformeventloopintegration_qpa.cpp
diff --git a/src/gui/kernel/qplatformeventloopintegration_qpa.h b/src/gui/guikernel/qplatformeventloopintegration_qpa.h
index 87df7aefe4..87df7aefe4 100644
--- a/src/gui/kernel/qplatformeventloopintegration_qpa.h
+++ b/src/gui/guikernel/qplatformeventloopintegration_qpa.h
diff --git a/src/gui/guikernel/qplatformglcontext_qpa.cpp b/src/gui/guikernel/qplatformglcontext_qpa.cpp
new file mode 100644
index 0000000000..2177a01d9b
--- /dev/null
+++ b/src/gui/guikernel/qplatformglcontext_qpa.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtOpenGL module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformglcontext_qpa.h"
+
+/*!
+ \class QPlatformGLContext
+ \since 4.8
+ \internal
+ \preliminary
+ \ingroup qpa
+
+ \brief The QPlatformGLContext class provides an abstraction for native GL contexts.
+
+ In QPA the way to support OpenGL or OpenVG or other technologies that requires a native GL
+ context is through the QPlatformGLContext wrapper.
+
+ There is no factory function for QPlatformGLContexts, but rather only one accessor function.
+ The only place to retrieve a QPlatformGLContext from is through a QPlatformWindow.
+
+ The context which is current for a specific thread can be collected by the currentContext()
+ function. This is how QPlatformGLContext also makes it possible to use the QtOpenGL module
+ withhout using QGLWidget. When using QGLContext::currentContext(), it will ask
+ QPlatformGLContext for the currentContext. Then a corresponding QGLContext will be returned,
+ which maps to the QPlatformGLContext.
+*/
+
+/*! \fn void swapBuffers()
+ Reimplement in subclass to native swap buffers calls
+*/
+
+/*! getProcAddress(const QString& procName)
+ Reimplement in subclass to native getProcAddr calls.
+
+ Note: its convenient to use qPrintable(const QString &str) to get the const char * pointer
+*/
+
+/*! platformWindowFormat() const
+ QWidget has the function qplatformWindowFormat(). That function is for the application
+ programmer to request the format of the window and the context that he wants.
+
+ Reimplement this function in a subclass to indicate what format the glContext actually has.
+*/
diff --git a/src/gui/guikernel/qplatformglcontext_qpa.h b/src/gui/guikernel/qplatformglcontext_qpa.h
new file mode 100644
index 0000000000..fbd43b2b48
--- /dev/null
+++ b/src/gui/guikernel/qplatformglcontext_qpa.h
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtOpenGL module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLATFORM_GL_CONTEXT_H
+#define QPLATFORM_GL_CONTEXT_H
+
+#include <QtCore/qnamespace.h>
+#include <QtGui/qwindowformat_qpa.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class Q_GUI_EXPORT QPlatformGLContext
+{
+public:
+ virtual ~QPlatformGLContext() {}
+
+ virtual void makeCurrent() = 0;
+ virtual void doneCurrent() = 0;
+ virtual void swapBuffers() = 0;
+ virtual void *getProcAddress(const QString& procName) = 0;
+
+ virtual QWindowFormat windowFormat() const = 0;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+
+#endif // QPLATFORM_GL_CONTEXT_H
diff --git a/src/gui/guikernel/qplatformintegration_qpa.cpp b/src/gui/guikernel/qplatformintegration_qpa.cpp
new file mode 100644
index 0000000000..9967a444c2
--- /dev/null
+++ b/src/gui/guikernel/qplatformintegration_qpa.cpp
@@ -0,0 +1,225 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformintegration_qpa.h"
+
+#include <QtGui/QPlatformFontDatabase>
+#include <QtGui/QPlatformClipboard>
+
+QT_BEGIN_NAMESPACE
+
+QPixmap QPlatformIntegration::grabWindow(WId window, int x, int y, int width, int height) const
+{
+ Q_UNUSED(window);
+ Q_UNUSED(x);
+ Q_UNUSED(y);
+ Q_UNUSED(width);
+ Q_UNUSED(height);
+ return QPixmap();
+}
+
+/*!
+ Factory function for the eventloop integration interface.
+
+ Default implementation returns 0, which causes the eventloop to run in a single thread mode.
+
+ \sa QPlatformEventLoopIntegration
+*/
+QPlatformEventLoopIntegration *QPlatformIntegration::createEventLoopIntegration() const
+{
+ return 0;
+}
+
+/*!
+ Accessor for the platform integrations fontdatabase.
+
+ Default implementation returns a default QPlatformFontDatabase.
+
+ \sa QPlatformFontDatabase
+*/
+QPlatformFontDatabase *QPlatformIntegration::fontDatabase() const
+{
+ static QPlatformFontDatabase *db = 0;
+ if (!db) {
+ db = new QPlatformFontDatabase;
+ }
+ return db;
+}
+
+/*!
+ Accessor for the platform integrations clipboard.
+
+ Default implementation returns a default QPlatformClipboard.
+
+ \sa QPlatformClipboard
+
+*/
+
+#ifndef QT_NO_CLIPBOARD
+
+QPlatformClipboard *QPlatformIntegration::clipboard() const
+{
+ static QPlatformClipboard *clipboard = 0;
+ if (!clipboard) {
+ clipboard = new QPlatformClipboard;
+ }
+ return clipboard;
+}
+
+#endif
+
+QPlatformNativeInterface * QPlatformIntegration::nativeInterface() const
+{
+ return 0;
+}
+
+/*!
+ \class QPlatformIntegration
+ \since 4.8
+ \internal
+ \preliminary
+ \ingroup qpa
+ \brief The QPlatformIntegration class is the entry for WindowSystem specific functionality.
+
+ QPlatformIntegration is the single entry point for windowsystem specific functionality when
+ using the QPA platform. It has factory functions for creating platform specific pixmaps and
+ windows. The class also controls the font subsystem.
+
+ QPlatformIntegration is a singelton class which gets instansiated in the QApplication
+ constructor. The QPlatformIntegration instance do not have ownership of objects it creates in
+ functions where the name starts with create. However, functions which don't have a name
+ starting with create acts as assessors to member variables.
+
+ It is not trivial to create or build a platform plugin outside of the Qt source tree. Therefor
+ the recommended approach for making new platform plugin is to copy an existing plugin inside
+ the QTSRCTREE/src/plugins/platform and develop the plugin inside the source tree.
+
+ The minimal platformintegration is the smallest platform integration it is possible to make,
+ which makes it an ideal starting point for new plugins. For a slightly more advanced plugin,
+ consider reviewing the directfb plugin, or the testlite plugin.
+*/
+
+/*!
+ \fn QPixmapData *createPixmapData(QPixmapData::PixelType type) const
+
+ Factory function for QPixmapData. PixelType can be either PixmapType or BitmapType.
+ \sa QPixmapData
+*/
+
+/*!
+ \fn QPlatformWindow *createPlatformWindow(QWindow *window, WId winId = 0) const
+
+ Factory function for QPlatformWindow. The widget parameter is a pointer to the top level
+ widget(tlw) which the QPlatformWindow is suppose to be created for. The WId handle is actually
+ never used, but there for future reference. Its purpose is if it is going to be possible to
+ create QPlatformWindows on existing WId.
+
+ All tlw has to have a QPlatformWindow, and it will be created when the QPlatformWindow is set
+ to be visible for the first time. If the tlw's window flags are changed, or if the tlw's
+ QPlatformWindowFormat is changed, then the tlw's QPlatformWindow is deleted and a new one is
+ created.
+
+ \sa QPlatformWindow, QPlatformWindowFormat
+ \sa createWindowSurface(QWindow *window, WId winId) const
+*/
+
+/*!
+ \fn QWindowSurface *createWindowSurface(QWindow *window, WId winId) const
+
+ Factory function for QWindowSurface. The QWindow parameter is a pointer to the
+ top level widget(tlw) the window surface is created for. A QPlatformWindow is always created
+ before the QWindowSurface for tlw where the widget also requires a WindowSurface. It is
+ possible to create top level QWindow without a QWindowSurface by specifying
+ QPlatformWindowFormat::setWindowSurface(false) for the tlw QPlatformWindowFormat.
+
+ \sa QWindowSurface
+ \sa createPlatformWindow(QWindow *window, WId winId = 0) const
+*/
+
+/*!
+ \fn void moveToScreen(QWindow *window, int screen)
+
+ This function is called when a QWindow is displayed on screen, or the QWindow is to be
+ displayed on a new screen. The QWindow parameter is a pointer to the top level widget and
+ the int parameter is the index to the screen in QList<QPlatformScreen *> screens() const.
+
+ Default implementation does nothing.
+
+ \sa screens() const
+*/
+
+/*!
+ \fn QList<QPlatformScreen *> screens() const
+
+ Accessor function to a list of all the screens on the current system. The screen with the
+ index == 0 is the default/main screen.
+*/
+
+/*!
+ \fn bool isVirtualDesktop()
+
+ Returns if the current windowing system configuration defines all the screens to be one
+ desktop(virtual desktop), or if each screen is a desktop of its own.
+
+ Default implementation returns false.
+*/
+
+/*!
+ \fn QPixmap grabWindow(WId window, int x, int y, int width, int height) const
+
+ This function is called when Qt needs to be able to grab the content of a window.
+
+ Returnes the content of the window specified with the WId handle within the boundaries of
+ QRect(x,y,width,height).
+*/
+
+
+bool QPlatformIntegration::hasCapability(Capability cap) const
+{
+ Q_UNUSED(cap);
+ return false;
+}
+
+
+
+
+
+QT_END_NAMESPACE
diff --git a/src/gui/guikernel/qplatformintegration_qpa.h b/src/gui/guikernel/qplatformintegration_qpa.h
new file mode 100644
index 0000000000..eb29a4bd0d
--- /dev/null
+++ b/src/gui/guikernel/qplatformintegration_qpa.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLATFORMINTEGRATION_H
+#define QPLATFORMINTEGRATION_H
+
+#include <QtGui/qwindowdefs.h>
+#include <QtGui/private/qwindowsurface_p.h>
+#include <QtGui/private/qpixmapdata_p.h>
+#include <QtGui/qplatformscreen_qpa.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QPlatformWindow;
+class QWindow;
+class QBlittable;
+class QPlatformEventLoopIntegration;
+class QPlatformFontDatabase;
+class QPlatformClipboard;
+class QPlatformNativeInterface;
+
+
+class Q_GUI_EXPORT QPlatformIntegration
+{
+public:
+ enum Capability {
+ ThreadedPixmaps = 1,
+ OpenGL = 2
+ };
+
+ virtual ~QPlatformIntegration() { }
+
+ virtual bool hasCapability(Capability cap) const;
+
+// GraphicsSystem functions
+ virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const = 0;
+ virtual QPlatformWindow *createPlatformWindow(QWindow *window) const = 0;
+ virtual QWindowSurface *createWindowSurface(QWindow *window, WId winId) const = 0;
+
+// Window System functions
+ virtual QList<QPlatformScreen *> screens() const = 0;
+ virtual void moveToScreen(QWindow *window, int screen) {Q_UNUSED(window); Q_UNUSED(screen);}
+ virtual bool isVirtualDesktop() { return false; }
+ virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const;
+
+//Deeper window system integrations
+ virtual QPlatformFontDatabase *fontDatabase() const;
+#ifndef QT_NO_CLIPBOARD
+ virtual QPlatformClipboard *clipboard() const;
+#endif
+
+// Experimental in mainthread eventloop integration
+// This should only be used if it is only possible to do window system event processing in
+// the gui thread. All of the functions in QWindowSystemInterface are thread safe.
+ virtual QPlatformEventLoopIntegration *createEventLoopIntegration() const;
+
+// Access native handles. The window handle is already available from Wid;
+ virtual QPlatformNativeInterface *nativeInterface() const;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPLATFORMINTEGRATION_H
diff --git a/src/gui/guikernel/qplatformintegrationfactory_qpa.cpp b/src/gui/guikernel/qplatformintegrationfactory_qpa.cpp
new file mode 100644
index 0000000000..e679800ef4
--- /dev/null
+++ b/src/gui/guikernel/qplatformintegrationfactory_qpa.cpp
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformintegrationfactory_qpa_p.h"
+#include <QPlatformIntegrationPlugin>
+#include "private/qfactoryloader_p.h"
+#include "qmutex.h"
+
+#include "qguiapplication.h"
+#include "qdebug.h"
+
+QT_BEGIN_NAMESPACE
+
+#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
+ (QPlatformIntegrationFactoryInterface_iid, QLatin1String("/platforms"), Qt::CaseInsensitive))
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
+ (QPlatformIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
+#endif
+
+QPlatformIntegration *QPlatformIntegrationFactory::create(const QString& key, const QString &platformPluginPath)
+{
+ QPlatformIntegration *ret = 0;
+ QStringList paramList = key.split(QLatin1Char(':'));
+ QString platform = paramList.takeFirst().toLower();
+
+#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
+ // Try loading the plugin from platformPluginPath first:
+ if (!platformPluginPath.isEmpty()) {
+ QCoreApplication::addLibraryPath(platformPluginPath);
+ if (QPlatformIntegrationFactoryInterface *factory =
+ qobject_cast<QPlatformIntegrationFactoryInterface*>(directLoader()->instance(platform)))
+ ret = factory->create(key, paramList);
+
+ if (ret)
+ return ret;
+ }
+ if (QPlatformIntegrationFactoryInterface *factory = qobject_cast<QPlatformIntegrationFactoryInterface*>(loader()->instance(platform)))
+ ret = factory->create(platform, paramList);
+#endif
+
+ return ret;
+}
+
+/*!
+ Returns the list of valid keys, i.e. the keys this factory can
+ create styles for.
+
+ \sa create()
+*/
+QStringList QPlatformIntegrationFactory::keys(const QString &platformPluginPath)
+{
+#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
+ QStringList list;
+
+ if (!platformPluginPath.isEmpty()) {
+ QCoreApplication::addLibraryPath(platformPluginPath);
+ foreach (const QString &key, directLoader()->keys()) {
+ list += key + QString(QLatin1String(" (from %1)")).arg(platformPluginPath);
+ }
+ }
+
+ list += loader()->keys();
+#else
+ QStringList list;
+#endif
+ return list;
+}
+
+QT_END_NAMESPACE
+
diff --git a/src/gui/kernel/qplatformintegrationfactory_qpa_p.h b/src/gui/guikernel/qplatformintegrationfactory_qpa_p.h
index a6042a81e0..a6042a81e0 100644
--- a/src/gui/kernel/qplatformintegrationfactory_qpa_p.h
+++ b/src/gui/guikernel/qplatformintegrationfactory_qpa_p.h
diff --git a/src/gui/kernel/qplatformintegrationplugin_qpa.cpp b/src/gui/guikernel/qplatformintegrationplugin_qpa.cpp
index 62920b6992..62920b6992 100644
--- a/src/gui/kernel/qplatformintegrationplugin_qpa.cpp
+++ b/src/gui/guikernel/qplatformintegrationplugin_qpa.cpp
diff --git a/src/gui/kernel/qplatformintegrationplugin_qpa.h b/src/gui/guikernel/qplatformintegrationplugin_qpa.h
index 17bcba0e46..17bcba0e46 100644
--- a/src/gui/kernel/qplatformintegrationplugin_qpa.h
+++ b/src/gui/guikernel/qplatformintegrationplugin_qpa.h
diff --git a/src/gui/guikernel/qplatformnativeinterface_qpa.cpp b/src/gui/guikernel/qplatformnativeinterface_qpa.cpp
new file mode 100644
index 0000000000..f160ec2899
--- /dev/null
+++ b/src/gui/guikernel/qplatformnativeinterface_qpa.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformnativeinterface_qpa.h"
+
+QT_BEGIN_NAMESPACE
+
+void *QPlatformNativeInterface::nativeResourceForWindow(const QByteArray &resource, QWindow *window)
+{
+ Q_UNUSED(resource);
+ Q_UNUSED(window);
+ return 0;
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/guikernel/qplatformnativeinterface_qpa.h b/src/gui/guikernel/qplatformnativeinterface_qpa.h
new file mode 100644
index 0000000000..ff3eacf2e0
--- /dev/null
+++ b/src/gui/guikernel/qplatformnativeinterface_qpa.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLATFORMNATIVEINTERFACE_QPA_H
+#define QPLATFORMNATIVEINTERFACE_QPA_H
+
+#include <QtGui/qwindowdefs.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QWindow;
+
+class Q_GUI_EXPORT QPlatformNativeInterface
+{
+public:
+ virtual void *nativeResourceForWindow(const QByteArray &resource, QWindow *window);
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPLATFORMNATIVEINTERFACE_QPA_H
diff --git a/src/gui/guikernel/qplatformscreen_qpa.cpp b/src/gui/guikernel/qplatformscreen_qpa.cpp
new file mode 100644
index 0000000000..8759aa4a88
--- /dev/null
+++ b/src/gui/guikernel/qplatformscreen_qpa.cpp
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformscreen_qpa.h"
+#include <QtGui/qguiapplication.h>
+#include <QtGui/private/qguiapplication_p.h>
+#include <QtGui/qplatformintegration_qpa.h>
+#include <QtGui/qwindow.h>
+
+/*!
+ Return the given top level window for a given position.
+
+ Default implementation retrieves a list of all top level windows and finds the first window
+ which contains point \a pos
+*/
+QWindow *QPlatformScreen::topLevelAt(const QPoint & pos) const
+{
+ QWindowList list = QGuiApplication::topLevelWindows();
+ for (int i = list.size()-1; i >= 0; --i) {
+ QWindow *w = list[i];
+ if (w->visible() && w->geometry().contains(pos))
+ return w;
+ }
+
+ return 0;
+}
+
+/*! \fn physicalSize() const
+ Reimplement in subclass to return the physical size of the screen. This function is used by
+ QFont to convert point sizes to pixel sizes.
+
+ Default implementation takes the pixel size of the screen, considers a dpi of 100 and returns
+ the calculated (and probably wrong) physical size
+*/
+QSize QPlatformScreen::physicalSize() const
+{
+ static const int dpi = 100;
+ int width = geometry().width() / dpi * qreal(25.4) ;
+ int height = geometry().height() / dpi * qreal(25.4) ;
+ return QSize(width,height);
+}
+
+QPlatformScreen * QPlatformScreen::platformScreenForWindow(const QWindow *)
+{
+ return QGuiApplicationPrivate::platformIntegration()->screens().at(0);
+}
+
+/*!
+ \class QPlatformScreen
+ \since 4.8
+ \internal
+ \preliminary
+ \ingroup qpa
+
+ \brief The QPlatformScreen class provides an abstraction for visual displays.
+
+ Many window systems has support for retrieving information on the attached displays. To be able
+ to query the display QPA uses QPlatformScreen. Qt its self is most dependent on the
+ physicalSize() function, since this is the function it uses to calculate the dpi to use when
+ converting point sizes to pixels sizes. However, this is unfortunate on some systems, as the
+ native system fakes its dpi size.
+
+ QPlatformScreen is also used by the public api QDesktopWidget for information about the desktop.
+ */
+
+/*! \fn geometry() const
+ Reimplement in subclass to return the pixel geometry of the screen
+*/
+
+/*! \fn availableGeometry() const
+ Reimplement in subclass to return the pixel geometry of the available space
+ This normally is the desktop screen minus the task manager, global menubar etc.
+*/
+
+/*! \fn depth() const
+ Reimplement in subclass to return current depth of the screen
+*/
+
+/*! \fn format() const
+ Reimplement in subclass to return the image format which corresponds to the screen format
+*/
+
diff --git a/src/gui/guikernel/qplatformscreen_qpa.h b/src/gui/guikernel/qplatformscreen_qpa.h
new file mode 100644
index 0000000000..9492788b4f
--- /dev/null
+++ b/src/gui/guikernel/qplatformscreen_qpa.h
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLATFORMSCREEN_H
+#define QPLATFORMSCREEN_H
+
+#include <QtCore/qmetatype.h>
+#include <QtCore/qnamespace.h>
+#include <QtCore/qcoreevent.h>
+#include <QtCore/qvariant.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qobject.h>
+
+#include <QtGui/qcursor.h>
+#include <QtGui/qimage.h>
+#include <QtGui/qwindowdefs.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class Q_GUI_EXPORT QPlatformScreen : public QObject
+{
+ Q_OBJECT
+public:
+ virtual ~QPlatformScreen() { }
+
+ virtual QRect geometry() const = 0;
+ virtual QRect availableGeometry() const {return geometry();}
+ virtual int depth() const = 0;
+ virtual QImage::Format format() const = 0;
+ virtual QSize physicalSize() const;
+ //jl: should setDirty be removed.
+ virtual void setDirty(const QRect &) {}
+ virtual QWindow *topLevelAt(const QPoint &point) const;
+
+ //jl: should this function be in QPlatformIntegration
+ //jl: maybe screenForWindow is a better name?
+ static QPlatformScreen *platformScreenForWindow(const QWindow *window);
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPLATFORMSCREEN_H
diff --git a/src/gui/guikernel/qplatformwindow_qpa.cpp b/src/gui/guikernel/qplatformwindow_qpa.cpp
new file mode 100644
index 0000000000..24c337cf57
--- /dev/null
+++ b/src/gui/guikernel/qplatformwindow_qpa.cpp
@@ -0,0 +1,216 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformwindow_qpa.h"
+
+#include <QtGui/qwindowsysteminterface_qpa.h>
+#include <QtGui/qwindow.h>
+
+class QPlatformWindowPrivate
+{
+ QWindow *window;
+ QRect rect;
+ friend class QPlatformWindow;
+};
+
+/*!
+ Constructs a platform window with the given top level window.
+*/
+
+QPlatformWindow::QPlatformWindow(QWindow *window)
+ : d_ptr(new QPlatformWindowPrivate)
+{
+ Q_D(QPlatformWindow);
+ d->window = window;
+}
+
+/*!
+ Virtual destructor does not delete its top level window.
+*/
+QPlatformWindow::~QPlatformWindow()
+{
+}
+
+/*!
+ Returnes the window which belongs to the QPlatformWindow
+*/
+QWindow *QPlatformWindow::window() const
+{
+ Q_D(const QPlatformWindow);
+ return d->window;
+}
+
+/*!
+ This function is called by Qt whenever a window is moved or the window is resized. The resize
+ can happen programatically(from ie. user application) or by the window manager. This means that
+ there is no need to call this function specifically from the window manager callback, instead
+ call QWindowSystemInterface::handleGeometryChange(QWindow *w, const QRect &newRect);
+*/
+void QPlatformWindow::setGeometry(const QRect &rect)
+{
+ Q_D(QPlatformWindow);
+ d->rect = rect;
+}
+
+/*!
+ Returnes the current geometry of a window
+*/
+QRect QPlatformWindow::geometry() const
+{
+ Q_D(const QPlatformWindow);
+ return d->rect;
+}
+
+/*!
+ Reimplemented in subclasses to show the surface
+ if \a visible is \c true, and hide it if \a visible is \c false.
+*/
+void QPlatformWindow::setVisible(bool visible)
+{
+ Q_UNUSED(visible);
+}
+/*!
+ Requests setting the window flags of this surface
+ to \a type. Returns the actual flags set.
+*/
+Qt::WindowFlags QPlatformWindow::setWindowFlags(Qt::WindowFlags flags)
+{
+ return flags;
+}
+
+/*!
+ Reimplement in subclasses to return a handle to the native window
+*/
+WId QPlatformWindow::winId() const { return WId(0); }
+
+/*!
+ This function is called to enable native child window in QPA. It is common not to support this
+ feature in Window systems, but can be faked. When this function is called all geometry of this
+ platform window will be relative to the parent.
+*/
+//jl: It would be useful to have a property on the platform window which indicated if the sub-class
+// supported the setParent. If not, then geometry would be in screen coordinates.
+void QPlatformWindow::setParent(const QPlatformWindow *parent)
+{
+ Q_UNUSED(parent);
+ qWarning("This plugin does not support setParent!");
+}
+
+/*!
+ Reimplement to set the window title to \a title
+*/
+void QPlatformWindow::setWindowTitle(const QString &title) { Q_UNUSED(title); }
+
+/*!
+ Reimplement to be able to let Qt rais windows to the top of the desktop
+*/
+void QPlatformWindow::raise() { qWarning("This plugin does not support raise()"); }
+
+/*!
+ Reimplement to be able to let Qt lower windows to the bottom of the desktop
+*/
+void QPlatformWindow::lower() { qWarning("This plugin does not support lower()"); }
+
+/*!
+ Reimplement to be able to let Qt set the opacity level of a window
+*/
+void QPlatformWindow::setOpacity(qreal level)
+{
+ Q_UNUSED(level);
+ qWarning("This plugin does not support setting window opacity");
+}
+
+/*!
+ Reimplement to let Qt be able to request activation/focus for a window
+
+ Some window systems will probably not have callbacks for this functionality,
+ and then calling QWindowSystemInterface::handleWindowActivated(QWindow *w)
+ would be sufficient.
+
+ If the window system has some event handling/callbacks then call
+ QWindowSystemInterface::handleWindowActivated(QWindow *w) when the window system
+ gives the notification.
+
+ Default implementation calls QWindowSystem::handleWindowActivated(QWindow *w)
+*/
+void QPlatformWindow::requestActivateWindow()
+{
+ QWindowSystemInterface::handleWindowActivated(window());
+}
+
+/*!
+ Reimplement to return the glContext associated with the window.
+*/
+QPlatformGLContext *QPlatformWindow::glContext() const
+{
+ return 0;
+}
+
+/*!
+ \class QPlatformWindow
+ \since 4.8
+ \internal
+ \preliminary
+ \ingroup qpa
+
+ \brief The QPlatformWindow class provides an abstraction for top-level windows.
+
+ The QPlatformWindow abstraction is used by QWindow for all its top level windows. It is being
+ created by calling the createPlatformWindow function in the loaded QPlatformIntegration
+ instance.
+
+ QPlatformWindow is used to signal to the windowing system, how Qt persieves its frame.
+ However, it is not concerned with how Qt renders into the window it represents.
+
+ Visible QWindows will always have a QPlatformWindow. However, it is not necessary for
+ all windows to have a QWindowSurface. This is the case for QGLWidget. And could be the case for
+ windows where some 3.party renders into it.
+
+ The platform specific window handle can be retrieved by the winId function.
+
+ QPlatformWindow is also the way QPA defines how native child windows should be supported
+ through the setParent function.
+
+ The only way to retrieve a QPlatformGLContext in QPA is by calling the glContext() function
+ on QPlatformWindow.
+
+ \sa QWindowSurface, QWindow
+*/
diff --git a/src/gui/guikernel/qplatformwindow_qpa.h b/src/gui/guikernel/qplatformwindow_qpa.h
new file mode 100644
index 0000000000..1730f3d85e
--- /dev/null
+++ b/src/gui/guikernel/qplatformwindow_qpa.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QPLATFORMWINDOW_H
+#define QPLATFORMWINDOW_H
+
+
+#include <QtCore/qscopedpointer.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qstring.h>
+#include <QtGui/qwindowdefs.h>
+
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QPlatformWindowPrivate;
+class QWindow;
+class QPlatformGLContext;
+
+class Q_GUI_EXPORT QPlatformWindow
+{
+ Q_DECLARE_PRIVATE(QPlatformWindow)
+public:
+ QPlatformWindow(QWindow *window);
+ virtual ~QPlatformWindow();
+
+ QWindow *window() const;
+ virtual void setGeometry(const QRect &rect);
+ virtual QRect geometry() const;
+
+ virtual void setVisible(bool visible);
+ virtual Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags);
+ virtual WId winId() const;
+ virtual void setParent(const QPlatformWindow *window);
+
+ virtual void setWindowTitle(const QString &title);
+ virtual void raise();
+ virtual void lower();
+
+ virtual void setOpacity(qreal level);
+ virtual void requestActivateWindow();
+
+ virtual QPlatformGLContext *glContext() const;
+protected:
+ QScopedPointer<QPlatformWindowPrivate> d_ptr;
+private:
+ Q_DISABLE_COPY(QPlatformWindow)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+#endif //QPLATFORMWINDOW_H
diff --git a/src/gui/guikernel/qsessionmanager.h b/src/gui/guikernel/qsessionmanager.h
new file mode 100644
index 0000000000..66ca0b8282
--- /dev/null
+++ b/src/gui/guikernel/qsessionmanager.h
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSESSIONMANAGER_H
+#define QSESSIONMANAGER_H
+
+#include <QtCore/qobject.h>
+#include <QtGui/qwindowdefs.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qstringlist.h>
+
+#ifndef QT_NO_SESSIONMANAGER
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QSessionManagerPrivate;
+
+class Q_GUI_EXPORT QSessionManager : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QSessionManager)
+ QSessionManager(QGuiApplication *app, QString &id, QString &key);
+ ~QSessionManager();
+public:
+ QString sessionId() const;
+ QString sessionKey() const;
+#if defined(Q_WS_X11) || defined(Q_WS_MAC)
+ void *handle() const;
+#endif
+
+ bool allowsInteraction();
+ bool allowsErrorInteraction();
+ void release();
+
+ void cancel();
+
+ enum RestartHint {
+ RestartIfRunning,
+ RestartAnyway,
+ RestartImmediately,
+ RestartNever
+ };
+ void setRestartHint(RestartHint);
+ RestartHint restartHint() const;
+
+ void setRestartCommand(const QStringList&);
+ QStringList restartCommand() const;
+ void setDiscardCommand(const QStringList&);
+ QStringList discardCommand() const;
+
+ void setManagerProperty(const QString& name, const QString& value);
+ void setManagerProperty(const QString& name, const QStringList& value);
+
+ bool isPhase2() const;
+ void requestPhase2();
+
+private:
+ friend class QApplication;
+ friend class QApplicationPrivate;
+ friend class QBaseApplication;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QT_NO_SESSIONMANAGER
+
+#endif // QSESSIONMANAGER_H
diff --git a/src/gui/guikernel/qsessionmanager_qpa.cpp b/src/gui/guikernel/qsessionmanager_qpa.cpp
new file mode 100644
index 0000000000..1b4e6a612b
--- /dev/null
+++ b/src/gui/guikernel/qsessionmanager_qpa.cpp
@@ -0,0 +1,173 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qsessionmanager.h>
+
+#include <private/qobject_p.h>
+
+#ifndef QT_NO_SESSIONMANAGER
+
+QT_BEGIN_NAMESPACE
+
+class QSessionManagerPrivate : public QObjectPrivate
+{
+public:
+ QSessionManagerPrivate(QSessionManager *m, const QString &id,
+ const QString &key);
+
+ QStringList restartCommand;
+ QStringList discardCommand;
+ const QString sessionId;
+ const QString sessionKey;
+ QSessionManager::RestartHint restartHint;
+};
+
+QSessionManagerPrivate::QSessionManagerPrivate(QSessionManager*,
+ const QString &id,
+ const QString &key)
+ : QObjectPrivate(), sessionId(id), sessionKey(key)
+{
+}
+
+QSessionManager::QSessionManager(QGuiApplication *app, QString &id, QString &key)
+ : QObject(*(new QSessionManagerPrivate(this, id, key)), app)
+{
+ Q_D(QSessionManager);
+ d->restartHint = RestartIfRunning;
+}
+
+QSessionManager::~QSessionManager()
+{
+}
+
+QString QSessionManager::sessionId() const
+{
+ Q_D(const QSessionManager);
+ return d->sessionId;
+}
+
+QString QSessionManager::sessionKey() const
+{
+ Q_D(const QSessionManager);
+ return d->sessionKey;
+}
+
+
+bool QSessionManager::allowsInteraction()
+{
+ return false;
+}
+
+bool QSessionManager::allowsErrorInteraction()
+{
+ return false;
+}
+
+void QSessionManager::release()
+{
+}
+
+void QSessionManager::cancel()
+{
+}
+
+void QSessionManager::setRestartHint(QSessionManager::RestartHint hint)
+{
+ Q_D(QSessionManager);
+ d->restartHint = hint;
+}
+
+QSessionManager::RestartHint QSessionManager::restartHint() const
+{
+ Q_D(const QSessionManager);
+ return d->restartHint;
+}
+
+void QSessionManager::setRestartCommand(const QStringList &command)
+{
+ Q_D(QSessionManager);
+ d->restartCommand = command;
+}
+
+QStringList QSessionManager::restartCommand() const
+{
+ Q_D(const QSessionManager);
+ return d->restartCommand;
+}
+
+void QSessionManager::setDiscardCommand(const QStringList &command)
+{
+ Q_D(QSessionManager);
+ d->discardCommand = command;
+}
+
+QStringList QSessionManager::discardCommand() const
+{
+ Q_D(const QSessionManager);
+ return d->discardCommand;
+}
+
+void QSessionManager::setManagerProperty(const QString &name,
+ const QString &value)
+{
+ Q_UNUSED(name);
+ Q_UNUSED(value);
+}
+
+void QSessionManager::setManagerProperty(const QString &name,
+ const QStringList &value)
+{
+ Q_UNUSED(name);
+ Q_UNUSED(value);
+}
+
+bool QSessionManager::isPhase2() const
+{
+ return false;
+}
+
+void QSessionManager::requestPhase2()
+{
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_SESSIONMANAGER
diff --git a/src/gui/guikernel/qt_gui_pch.h b/src/gui/guikernel/qt_gui_pch.h
new file mode 100644
index 0000000000..79450219fa
--- /dev/null
+++ b/src/gui/guikernel/qt_gui_pch.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ * This is a precompiled header file for use in Xcode / Mac GCC /
+ * GCC >= 3.4 / VC to greatly speed the building of Qt. It may also be
+ * of use to people developing their own project, but it is probably
+ * better to define your own header. Use of this header is currently
+ * UNSUPPORTED.
+ */
+
+// from corelib/global/qt_pch.h
+#if defined __cplusplus
+#include <qglobal.h>
+
+
+#ifdef Q_WS_WIN
+# define _POSIX_
+# include <limits.h>
+# undef _POSIX_
+#endif
+
+#include <qcoreapplication.h>
+#include <qlist.h>
+#include <qvariant.h> // All moc genereated code has this include
+#include <qobject.h>
+#include <qregexp.h>
+#include <qstring.h>
+#include <qstringlist.h>
+#include <qtextcodec.h>
+
+#include <qguiapplication.h>
+#include <qbitmap.h>
+#include <qcursor.h>
+#include <qevent.h>
+#include <qimage.h>
+#include <qpainter.h>
+#include <qpixmap.h>
+#include <qtimer.h>
+
+#include <stdlib.h>
+
+#endif
diff --git a/src/gui/guikernel/qwindow.cpp b/src/gui/guikernel/qwindow.cpp
new file mode 100644
index 0000000000..7faf49395a
--- /dev/null
+++ b/src/gui/guikernel/qwindow.cpp
@@ -0,0 +1,457 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwindow.h"
+
+#include "qplatformwindow_qpa.h"
+#include "qwindowformat_qpa.h"
+#include "qplatformglcontext_qpa.h"
+#include "qwindowcontext_qpa.h"
+
+#include "qwindow_p.h"
+#include "qguiapplication_p.h"
+
+#include <QtCore/QDebug>
+
+QT_BEGIN_NAMESPACE
+
+QWindow::QWindow(QWindow *parent)
+ : QObject(*new QWindowPrivate(), parent)
+{
+ Q_D(QWindow);
+ d->parentWindow = parent;
+}
+
+QWindow::~QWindow()
+{
+ destroy();
+}
+
+void QWindow::setVisible(bool visible)
+{
+ Q_D(QWindow);
+ if (!d->platformWindow) {
+ create();
+ }
+ d->platformWindow->setVisible(visible);
+}
+
+bool QWindow::visible() const
+{
+ Q_D(const QWindow);
+
+ return d->visible;
+}
+
+void QWindow::create()
+{
+ Q_D(QWindow);
+ if (!d->platformWindow) {
+ d->platformWindow = QGuiApplicationPrivate::platformIntegration()->createPlatformWindow(this);
+ d->windowFlags = d->platformWindow->setWindowFlags(d->windowFlags);
+ if (!d->windowTitle.isNull())
+ d->platformWindow->setWindowTitle(d->windowTitle);
+
+ QObjectList childObjects = children();
+ for (int i = 0; i < childObjects.size(); i ++) {
+ QObject *object = childObjects.at(i);
+ if(object->isWindowType()) {
+ QWindow *window = static_cast<QWindow *>(object);
+ if (window->d_func()->platformWindow)
+ window->d_func()->platformWindow->setParent(d->platformWindow);
+ }
+ }
+ }
+}
+
+WId QWindow::winId() const
+{
+ Q_D(const QWindow);
+ if(!d->platformWindow)
+ const_cast<QWindow *>(this)->create();
+ return d->platformWindow->winId();
+}
+
+QWindow *QWindow::parent() const
+{
+ Q_D(const QWindow);
+ return d->parentWindow;
+}
+
+/**
+ Sets the parent Window. This will lead to the windowing system managing the clip of the window, so it will be clipped to the parent window.
+ Setting parent to be 0(NULL) means map it as a top level window. If the parent window has grabbed its window system resources, then the current window will also grab its window system resources.
+ **/
+
+void QWindow::setParent(QWindow *parent)
+{
+ Q_D(QWindow);
+
+ if (d->parentWindow == parent)
+ return;
+
+ QObject::setParent(parent);
+
+ if (d->platformWindow) {
+ if (parent && parent->d_func()->platformWindow) {
+ d->platformWindow->setParent(parent->d_func()->platformWindow);
+ } else if (!parent) {
+ d->platformWindow->setParent(0);
+ }
+ }
+
+ d->parentWindow = parent;
+}
+
+void QWindow::setWindowFormat(const QWindowFormat &format)
+{
+ Q_D(QWindow);
+ d->requestedFormat = format;
+}
+
+QWindowFormat QWindow::requestedWindowFormat() const
+{
+ Q_D(const QWindow);
+ return d->requestedFormat;
+}
+
+QWindowFormat QWindow::actualWindowFormat() const
+{
+ return glContext()->handle()->windowFormat();
+}
+
+void QWindow::setSurfaceType(SurfaceType type)
+{
+ Q_D(QWindow);
+ d->surfaceType = type;
+}
+
+QWindow::SurfaceType QWindow::surfaceType() const
+{
+ Q_D(const QWindow);
+ return d->surfaceType;
+}
+
+void QWindow::setWindowFlags(Qt::WindowFlags flags)
+{
+ Q_D(QWindow);
+ if (d->platformWindow)
+ d->windowFlags = d->platformWindow->setWindowFlags(flags);
+ else
+ d->windowFlags = flags;
+}
+
+Qt::WindowFlags QWindow::windowFlags() const
+{
+ Q_D(const QWindow);
+ return d->windowFlags;
+}
+
+void QWindow::setWindowTitle(const QString &title)
+{
+ Q_D(QWindow);
+ d->windowTitle = title;
+ if (d->platformWindow) {
+ d->platformWindow->setWindowTitle(title);
+ }
+}
+
+QString QWindow::windowTitle() const
+{
+ Q_D(const QWindow);
+ return d->windowTitle;
+}
+
+void QWindow::raise()
+{
+ Q_D(QWindow);
+ if (d->platformWindow) {
+ d->platformWindow->raise();
+ }
+}
+
+void QWindow::lower()
+{
+ Q_D(QWindow);
+ if (d->platformWindow) {
+ d->platformWindow->lower();
+ }
+}
+
+void QWindow::setOpacity(qreal level)
+{
+ Q_D(QWindow);
+ if (d->platformWindow) {
+ d->platformWindow->setOpacity(level);
+ }
+}
+
+void QWindow::requestActivateWindow()
+{
+ Q_D(QWindow);
+ if (d->platformWindow) {
+ d->platformWindow->requestActivateWindow();
+ }
+}
+
+Qt::WindowStates QWindow::windowState() const
+{
+ qDebug() << "unimplemented:" << __FILE__ << __LINE__;
+ return Qt::WindowNoState;
+}
+
+void QWindow::setWindowState(Qt::WindowStates state)
+{
+ Q_UNUSED(state);
+ qDebug() << "unimplemented:" << __FILE__ << __LINE__;
+}
+
+QSize QWindow::minimumSize() const
+{
+ qDebug() << "unimplemented:" << __FILE__ << __LINE__;
+ return QSize();
+}
+
+QSize QWindow::maximumSize() const
+{
+ qDebug() << "unimplemented:" << __FILE__ << __LINE__;
+ return QSize();
+}
+
+void QWindow::setMinimumSize(const QSize &size) const
+{
+ Q_UNUSED(size);
+ qDebug() << "unimplemented:" << __FILE__ << __LINE__;
+}
+
+void QWindow::setMaximumSize(const QSize &size) const
+{
+ Q_UNUSED(size);
+ qDebug() << "unimplemented:" << __FILE__ << __LINE__;
+}
+
+void QWindow::setGeometry(const QRect &rect)
+{
+ Q_D(QWindow);
+ d->geometry = rect;
+ if (d->platformWindow) {
+ d->platformWindow->setGeometry(rect);
+ }
+}
+
+QRect QWindow::geometry() const
+{
+ Q_D(const QWindow);
+ return d->geometry;
+}
+
+void QWindow::setWindowIcon(const QImage &icon) const
+{
+ Q_UNUSED(icon);
+ qDebug() << "unimplemented:" << __FILE__ << __LINE__;
+}
+
+QWindowContext * QWindow::glContext() const
+{
+ Q_D(const QWindow);
+ if (d->platformWindow && !d->glContext)
+ const_cast<QWindowPrivate *>(d)->glContext = new QWindowContext(const_cast<QWindow *>(this));
+ return d->glContext;
+}
+
+void QWindow::setRequestFormat(const QWindowFormat &format)
+{
+ Q_D(QWindow);
+ d->requestedFormat = format;
+}
+
+QWindowFormat QWindow::format() const
+{
+ return QWindowFormat();
+}
+
+void QWindow::destroy()
+{
+ Q_D(QWindow);
+ if (d->glContext) {
+ d->glContext->deleteQGLContext();
+ }
+ delete d->glContext;
+ d->glContext = 0;
+ delete d->platformWindow;
+ d->platformWindow = 0;
+}
+
+QPlatformWindow *QWindow::handle() const
+{
+ Q_D(const QWindow);
+ return d->platformWindow;
+}
+
+QWindowSurface *QWindow::surface() const
+{
+ Q_D(const QWindow);
+ return d->surface;
+}
+
+void QWindow::showMinimized()
+{
+ qDebug() << "unimplemented:" << __FILE__ << __LINE__;
+}
+
+void QWindow::showMaximized()
+{
+ qDebug() << "unimplemented:" << __FILE__ << __LINE__;
+}
+
+void QWindow::showFullScreen()
+{
+ qDebug() << "unimplemented:" << __FILE__ << __LINE__;
+}
+
+void QWindow::showNormal()
+{
+ qDebug() << "unimplemented:" << __FILE__ << __LINE__;
+}
+
+bool QWindow::close()
+{
+ //should we have close?
+ qDebug() << "unimplemented:" << __FILE__ << __LINE__;
+ return true;
+}
+
+void QWindow::resizeEvent(QResizeEvent *)
+{
+}
+
+void QWindow::showEvent(QShowEvent *)
+{
+ qDebug() << "unimplemented:" << __FILE__ << __LINE__;
+}
+
+void QWindow::hideEvent(QHideEvent *)
+{
+ qDebug() << "unimplemented:" << __FILE__ << __LINE__;
+}
+
+bool QWindow::event(QEvent *event)
+{
+ switch (event->type()) {
+ case QEvent::MouseMove:
+ mouseMoveEvent(static_cast<QMouseEvent*>(event));
+ break;
+
+ case QEvent::MouseButtonPress:
+ mousePressEvent(static_cast<QMouseEvent*>(event));
+ break;
+
+ case QEvent::MouseButtonRelease:
+ mouseReleaseEvent(static_cast<QMouseEvent*>(event));
+ break;
+
+ case QEvent::MouseButtonDblClick:
+ mouseDoubleClickEvent(static_cast<QMouseEvent*>(event));
+ break;
+
+ case QEvent::Resize:
+ resizeEvent(static_cast<QResizeEvent*>(event));
+ break;
+
+ case QEvent::KeyPress:
+ keyPressEvent(static_cast<QKeyEvent *>(event));
+ break;
+
+ case QEvent::KeyRelease:
+ keyReleaseEvent(static_cast<QKeyEvent *>(event));
+ break;
+
+#ifndef QT_NO_WHEELEVENT
+ case QEvent::Wheel:
+ wheelEvent(static_cast<QWheelEvent*>(event));
+ break;
+#endif
+
+ case QEvent::Close:
+ destroy();
+ break;
+
+ default:
+ return QObject::event(event);
+ }
+ return true;
+}
+
+void QWindow::keyPressEvent(QKeyEvent *)
+{
+}
+
+void QWindow::keyReleaseEvent(QKeyEvent *)
+{
+}
+
+void QWindow::inputMethodEvent(QInputMethodEvent *)
+{
+}
+
+void QWindow::mousePressEvent(QMouseEvent *)
+{
+}
+
+void QWindow::mouseReleaseEvent(QMouseEvent *)
+{
+}
+
+void QWindow::mouseDoubleClickEvent(QMouseEvent *)
+{
+}
+
+void QWindow::mouseMoveEvent(QMouseEvent *)
+{
+}
+
+#ifndef QT_NO_WHEELEVENT
+void QWindow::wheelEvent(QWheelEvent *)
+{
+}
+#endif //QT_NO_WHEELEVENT
+
+QT_END_NAMESPACE
diff --git a/src/gui/guikernel/qwindow.h b/src/gui/guikernel/qwindow.h
new file mode 100644
index 0000000000..f2fde2d532
--- /dev/null
+++ b/src/gui/guikernel/qwindow.h
@@ -0,0 +1,186 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINDOW_QPA_H
+#define QWINDOW_QPA_H
+
+#include <QtCore/QObject>
+#include <QtCore/QEvent>
+#include <QtGui/qwindowformat_qpa.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QWindowPrivate;
+
+class QResizeEvent;
+class QShowEvent;
+class QHideEvent;
+class QKeyEvent;
+class QInputMethodEvent;
+class QMouseEvent;
+#ifndef QT_NO_WHEELEVENT
+class QWheelEvent;
+#endif
+
+class QPlatformWindow;
+class QWindowContext;
+class QWindowSurface;
+
+class Q_GUI_EXPORT QWindow : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWindow)
+
+ Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle)
+
+public:
+ enum SurfaceType {
+ RasterSurface,
+ OpenGLSurface
+ };
+
+ QWindow(QWindow *parent = 0);
+ virtual ~QWindow();
+
+ void setVisible(bool visible);
+ bool visible() const;
+
+ void create();
+
+ WId winId() const;
+
+ QWindow *parent() const;
+ void setParent(QWindow *parent);
+
+ QWindow *topLevelWindow() const;
+
+ void setWindowFormat(const QWindowFormat &format);
+ QWindowFormat requestedWindowFormat() const;
+ QWindowFormat actualWindowFormat() const;
+
+ void setSurfaceType(SurfaceType type);
+ SurfaceType surfaceType() const;
+
+ void setWindowFlags(Qt::WindowFlags flags);
+ Qt::WindowFlags windowFlags() const;
+
+ QString windowTitle() const;
+
+ void setOpacity(qreal level);
+ void requestActivateWindow();
+
+ Qt::WindowStates windowState() const;
+ void setWindowState(Qt::WindowStates state);
+
+ QSize minimumSize() const;
+ QSize maximumSize() const;
+
+ void setMinimumSize(const QSize &size) const;
+ void setMaximumSize(const QSize &size) const;
+
+ void setGeometry(const QRect &rect);
+ QRect geometry() const;
+
+ void setWindowIcon(const QImage &icon) const;
+
+ QWindowContext *glContext() const;
+
+ void setRequestFormat(const QWindowFormat &format);
+ QWindowFormat format() const;
+
+ void destroy();
+
+ QPlatformWindow *handle() const;
+ QWindowSurface *surface() const;
+
+public Q_SLOTS:
+ inline void show() { setVisible(true); }
+ inline void hide() { setVisible(false); }
+
+ void showMinimized();
+ void showMaximized();
+ void showFullScreen();
+ void showNormal();
+
+ bool close();
+ void raise();
+ void lower();
+
+ void setWindowTitle(const QString &);
+
+Q_SIGNALS:
+ void backBufferReady();
+
+protected:
+ virtual void resizeEvent(QResizeEvent *);
+
+ virtual void showEvent(QShowEvent *);
+ virtual void hideEvent(QHideEvent *);
+
+ virtual bool event(QEvent *);
+ virtual void keyPressEvent(QKeyEvent *);
+ virtual void keyReleaseEvent(QKeyEvent *);
+ virtual void inputMethodEvent(QInputMethodEvent *);
+ virtual void mousePressEvent(QMouseEvent *);
+ virtual void mouseReleaseEvent(QMouseEvent *);
+ virtual void mouseDoubleClickEvent(QMouseEvent *);
+ virtual void mouseMoveEvent(QMouseEvent *);
+#ifndef QT_NO_WHEELEVENT
+ virtual void wheelEvent(QWheelEvent *);
+#endif
+
+private:
+ Q_DISABLE_COPY(QWindow)
+
+ friend class QGuiApplication;
+ friend class QGuiApplicationPrivate;
+ friend class QWindowSurface;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QWINDOW_QPA_H
diff --git a/src/gui/guikernel/qwindow_p.h b/src/gui/guikernel/qwindow_p.h
new file mode 100644
index 0000000000..6f1038e8c4
--- /dev/null
+++ b/src/gui/guikernel/qwindow_p.h
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINDOW_QPA_P_H
+#define QWINDOW_QPA_P_H
+
+#include <QtGui/qwindow.h>
+
+#include <QtCore/private/qobject_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QWindowPrivate : public QObjectPrivate
+{
+public:
+ QWindowPrivate()
+ : QObjectPrivate()
+ , windowFlags(Qt::Window)
+ , surfaceType(QWindow::RasterSurface)
+ , parentWindow(0)
+ , platformWindow(0)
+ , visible(false)
+ , glContext(0)
+ , surface(0)
+ {
+ isWindow = true;
+ }
+
+ ~QWindowPrivate()
+ {
+ }
+
+ Qt::WindowFlags windowFlags;
+ QWindow::SurfaceType surfaceType;
+ QWindow *parentWindow;
+ QPlatformWindow *platformWindow;
+ bool visible;
+ QWindowFormat requestedFormat;
+ QString windowTitle;
+ QRect geometry;
+ QWindowContext *glContext;
+ QWindowSurface *surface;
+};
+
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QWINDOW_QPA_P_H
diff --git a/src/gui/guikernel/qwindowcontext_qpa.cpp b/src/gui/guikernel/qwindowcontext_qpa.cpp
new file mode 100644
index 0000000000..f121e846b2
--- /dev/null
+++ b/src/gui/guikernel/qwindowcontext_qpa.cpp
@@ -0,0 +1,201 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtOpenGL module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformglcontext_qpa.h"
+#include "qwindowcontext_qpa.h"
+#include "qwindow.h"
+
+#include <QtCore/QThreadStorage>
+#include <QtCore/QThread>
+
+#include <QDebug>
+
+class QWindowThreadContext
+{
+public:
+ ~QWindowThreadContext() {
+ if (context)
+ context->doneCurrent();
+ }
+ QWindowContext *context;
+};
+
+static QThreadStorage<QWindowThreadContext *> qwindow_context_storage;
+
+class QWindowContextPrivate
+{
+public:
+ QWindowContextPrivate()
+ :qGLContextHandle(0)
+ {
+ }
+
+ virtual ~QWindowContextPrivate()
+ {
+ //do not delete the QGLContext handle here as it is deleted in
+ //QWidgetPrivate::deleteTLSysExtra()
+ }
+ void *qGLContextHandle;
+ void (*qGLContextDeleteFunction)(void *handle);
+ QPlatformGLContext *platformGLContext;
+ static QWindowContext *staticSharedContext;
+
+ static void setCurrentContext(QWindowContext *context);
+};
+
+QWindowContext *QWindowContextPrivate::staticSharedContext = 0;
+
+void QWindowContextPrivate::setCurrentContext(QWindowContext *context)
+{
+ QWindowThreadContext *threadContext = qwindow_context_storage.localData();
+ if (!threadContext) {
+ if (!QThread::currentThread()) {
+ qWarning("No QTLS available. currentContext wont work");
+ return;
+ }
+ threadContext = new QWindowThreadContext;
+ qwindow_context_storage.setLocalData(threadContext);
+ }
+ threadContext->context = context;
+}
+
+/*!
+ Returns the last context which called makeCurrent. This function is thread aware.
+*/
+QWindowContext* QWindowContext::currentContext()
+{
+ QWindowThreadContext *threadContext = qwindow_context_storage.localData();
+ if(threadContext) {
+ return threadContext->context;
+ }
+ return 0;
+}
+
+QPlatformGLContext *QWindowContext::handle() const
+{
+ Q_D(const QWindowContext);
+ return d->platformGLContext;
+}
+
+/*!
+ All subclasses needs to specify the platformWindow. It can be a null window.
+*/
+QWindowContext::QWindowContext(QWindow *window)
+ :d_ptr(new QWindowContextPrivate())
+{
+ Q_D(QWindowContext);
+ Q_ASSERT(window);
+ if (!window->handle())
+ window->create();
+ d->platformGLContext = window->handle()->glContext();
+}
+
+/*!
+ If this is the current context for the thread, doneCurrent is called
+*/
+QWindowContext::~QWindowContext()
+{
+ if (QWindowContext::currentContext() == this) {
+ doneCurrent();
+ }
+
+}
+
+/*!
+ Reimplement in subclass to do makeCurrent on native GL context
+*/
+void QWindowContext::makeCurrent()
+{
+ Q_D(QWindowContext);
+ QWindowContextPrivate::setCurrentContext(this);
+ d->platformGLContext->makeCurrent();
+}
+
+/*!
+ Reimplement in subclass to release current context.
+ Typically this is calling makeCurrent with 0 "surface"
+*/
+void QWindowContext::doneCurrent()
+{
+ Q_D(QWindowContext);
+ d->platformGLContext->doneCurrent();
+ QWindowContextPrivate::setCurrentContext(0);
+}
+
+void QWindowContext::swapBuffers()
+{
+ Q_D(QWindowContext);
+ d->platformGLContext->swapBuffers();
+}
+
+void (*QWindowContext::getProcAddress(const QByteArray &procName)) ()
+{
+ Q_D(QWindowContext);
+ void *result = d->platformGLContext->getProcAddress(QString::fromAscii(procName.constData()));
+ return (void (*)())result;
+}
+
+/*
+ internal: Needs to have a pointer to qGLContext. But since this is in QtGui we cant
+ have any type information.
+*/
+void *QWindowContext::qGLContextHandle() const
+{
+ Q_D(const QWindowContext);
+ return d->qGLContextHandle;
+}
+
+void QWindowContext::setQGLContextHandle(void *handle,void (*qGLContextDeleteFunction)(void *))
+{
+ Q_D(QWindowContext);
+ d->qGLContextHandle = handle;
+ d->qGLContextDeleteFunction = qGLContextDeleteFunction;
+}
+
+void QWindowContext::deleteQGLContext()
+{
+ Q_D(QWindowContext);
+ if (d->qGLContextDeleteFunction && d->qGLContextHandle) {
+ d->qGLContextDeleteFunction(d->qGLContextHandle);
+ d->qGLContextDeleteFunction = 0;
+ d->qGLContextHandle = 0;
+ }
+}
diff --git a/src/gui/guikernel/qwindowcontext_qpa.h b/src/gui/guikernel/qwindowcontext_qpa.h
new file mode 100644
index 0000000000..c16666a7f4
--- /dev/null
+++ b/src/gui/guikernel/qwindowcontext_qpa.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtOpenGL module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINDOWCONTEXT_H
+#define QWINDOWCONTEXT_H
+
+#include <QtCore/qnamespace.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QWindowContextPrivate;
+class QPlatformGLContext;
+
+class Q_GUI_EXPORT QWindowContext
+{
+Q_DECLARE_PRIVATE(QWindowContext);
+public:
+ ~QWindowContext();
+
+ void makeCurrent();
+ void doneCurrent();
+ void swapBuffers();
+ void (*getProcAddress(const QByteArray &procName)) ();
+
+ static QWindowContext *currentContext();
+
+ QPlatformGLContext *handle() const;
+
+private:
+ QWindowContext(QWindow *window);
+
+ QScopedPointer<QWindowContextPrivate> d_ptr;
+
+ //hack to make it work with QGLContext::CurrentContext
+ friend class QGLContext;
+ friend class QWidgetPrivate;
+ friend class QWindow;
+ void *qGLContextHandle() const;
+ void setQGLContextHandle(void *handle,void (*qGLContextDeleteFunction)(void *));
+ void deleteQGLContext();
+ Q_DISABLE_COPY(QWindowContext);
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QWINDOWCONTEXT_H
diff --git a/src/gui/guikernel/qwindowdefs.h b/src/gui/guikernel/qwindowdefs.h
new file mode 100644
index 0000000000..b9fea38da8
--- /dev/null
+++ b/src/gui/guikernel/qwindowdefs.h
@@ -0,0 +1,162 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINDOWDEFS_H
+#define QWINDOWDEFS_H
+
+#include <QtCore/qobjectdefs.h>
+#include <QtCore/qnamespace.h>
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+// Class forward definitions
+
+class QPaintDevice;
+class QWidget;
+class QWindow;
+class QDialog;
+class QColor;
+class QPalette;
+class QCursor;
+class QPoint;
+class QSize;
+class QRect;
+class QPolygon;
+class QPainter;
+class QRegion;
+class QFont;
+class QFontMetrics;
+class QFontInfo;
+class QPen;
+class QBrush;
+class QMatrix;
+class QPixmap;
+class QBitmap;
+class QMovie;
+class QImage;
+class QPicture;
+class QPrinter;
+class QTimer;
+class QTime;
+class QClipboard;
+class QString;
+class QByteArray;
+class QApplication;
+
+template<typename T> class QList;
+typedef QList<QWidget *> QWidgetList;
+typedef QList<QWindow *> QWindowList;
+
+QT_END_NAMESPACE
+QT_END_HEADER
+
+// Window system dependent definitions
+
+#if defined(Q_WS_MAC) && !defined(Q_WS_QWS)
+
+#include <QtGui/qmacdefines_mac.h>
+
+#ifdef Q_WS_MAC32
+typedef int WId;
+#else
+typedef long WId;
+#endif
+
+#endif // Q_WS_MAC
+
+#if defined(Q_WS_WIN)
+#include <QtGui/qwindowdefs_win.h>
+#endif // Q_WS_WIN
+
+#if defined(Q_WS_X11)
+
+typedef struct _XDisplay Display;
+typedef union _XEvent XEvent;
+typedef struct _XGC *GC;
+typedef struct _XRegion *Region;
+typedef unsigned long WId;
+
+#endif // Q_WS_X11
+
+#if defined(Q_WS_QWS)
+
+typedef unsigned long WId;
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+struct QWSEvent;
+QT_END_NAMESPACE
+QT_END_HEADER
+
+#endif // Q_WS_QWS
+
+#if defined(Q_WS_QPA)
+
+typedef unsigned long WId;
+
+#endif // Q_WS_QPA
+
+#if defined(Q_OS_SYMBIAN)
+class CCoeControl;
+typedef CCoeControl * WId;
+#endif // Q_OS_SYMBIAN
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+
+template<class K, class V> class QHash;
+typedef QHash<WId, QWidget *> QWidgetMapper;
+
+template<class V> class QSet;
+typedef QSet<QWidget *> QWidgetSet;
+
+QT_END_NAMESPACE
+QT_END_HEADER
+
+#if defined(QT_NEEDS_QMAIN)
+#define main qMain
+#endif
+
+// Global platform-independent types and functions
+
+#endif // QWINDOWDEFS_H
diff --git a/src/gui/guikernel/qwindowformat_qpa.cpp b/src/gui/guikernel/qwindowformat_qpa.cpp
new file mode 100644
index 0000000000..03ccba7b07
--- /dev/null
+++ b/src/gui/guikernel/qwindowformat_qpa.cpp
@@ -0,0 +1,406 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwindowformat_qpa.h"
+
+#include "qplatformglcontext_qpa.h"
+
+#include <QtCore/QDebug>
+
+class QWindowFormatPrivate
+{
+public:
+ QWindowFormatPrivate()
+ : ref(1)
+ , opts(QWindowFormat::DoubleBuffer | QWindowFormat::WindowSurface)
+ , redBufferSize(-1)
+ , greenBufferSize(-1)
+ , blueBufferSize(-1)
+ , alphaBufferSize(-1)
+ , depthSize(-1)
+ , stencilSize(-1)
+ , swapBehavior(QWindowFormat::DefaultSwapBehavior)
+ , numSamples(-1)
+ , sharedContext(0)
+ {
+ }
+
+ QWindowFormatPrivate(const QWindowFormatPrivate *other)
+ : ref(1),
+ opts(other->opts),
+ redBufferSize(other->redBufferSize),
+ greenBufferSize(other->greenBufferSize),
+ blueBufferSize(other->blueBufferSize),
+ alphaBufferSize(other->alphaBufferSize),
+ depthSize(other->depthSize),
+ stencilSize(other->stencilSize),
+ swapBehavior(other->swapBehavior),
+ numSamples(other->numSamples),
+ sharedContext(other->sharedContext)
+ {
+ }
+ QAtomicInt ref;
+ QWindowFormat::FormatOptions opts;
+ int redBufferSize;
+ int greenBufferSize;
+ int blueBufferSize;
+ int alphaBufferSize;
+ int depthSize;
+ int stencilSize;
+ QWindowFormat::SwapBehavior swapBehavior;
+ int numSamples;
+ QWindowContext *sharedContext;
+};
+
+QWindowFormat::QWindowFormat()
+{
+ d = new QWindowFormatPrivate;
+}
+
+QWindowFormat::QWindowFormat(QWindowFormat::FormatOptions options)
+{
+ d = new QWindowFormatPrivate;
+ d->opts = options;
+}
+
+/*!
+ \internal
+*/
+void QWindowFormat::detach()
+{
+ if (d->ref != 1) {
+ QWindowFormatPrivate *newd = new QWindowFormatPrivate(d);
+ if (!d->ref.deref())
+ delete d;
+ d = newd;
+ }
+}
+
+/*!
+ Constructs a copy of \a other.
+*/
+
+QWindowFormat::QWindowFormat(const QWindowFormat &other)
+{
+ d = other.d;
+ d->ref.ref();
+}
+
+/*!
+ Assigns \a other to this object.
+*/
+
+QWindowFormat &QWindowFormat::operator=(const QWindowFormat &other)
+{
+ if (d != other.d) {
+ other.d->ref.ref();
+ if (!d->ref.deref())
+ delete d;
+ d = other.d;
+ }
+ return *this;
+}
+
+/*!
+ Destroys the QWindowFormat.
+*/
+QWindowFormat::~QWindowFormat()
+{
+ if (!d->ref.deref())
+ delete d;
+}
+
+/*!
+ \fn bool QWindowFormat::stereo() const
+
+ Returns true if stereo buffering is enabled; otherwise returns
+ false. Stereo buffering is disabled by default.
+
+ \sa setStereo()
+*/
+
+/*!
+ If \a enable is true enables stereo buffering; otherwise disables
+ stereo buffering.
+
+ Stereo buffering is disabled by default.
+
+ Stereo buffering provides extra color buffers to generate left-eye
+ and right-eye images.
+
+ \sa stereo()
+*/
+
+void QWindowFormat::setStereo(bool enable)
+{
+ if (enable) {
+ d->opts |= QWindowFormat::StereoBuffers;
+ } else {
+ d->opts &= ~QWindowFormat::StereoBuffers;
+ }
+}
+
+/*!
+ Returns the number of samples per pixel when multisampling is
+ enabled. By default, the highest number of samples that is
+ available is used.
+
+ \sa setSampleBuffers(), sampleBuffers(), setSamples()
+*/
+int QWindowFormat::samples() const
+{
+ return d->numSamples;
+}
+
+/*!
+ Set the preferred number of samples per pixel when multisampling
+ is enabled to \a numSamples. By default, the highest number of
+ samples available is used.
+
+ \sa setSampleBuffers(), sampleBuffers(), samples()
+*/
+void QWindowFormat::setSamples(int numSamples)
+{
+ detach();
+ d->numSamples = numSamples;
+}
+
+
+
+void QWindowFormat::setSharedContext(QWindowContext *context)
+{
+ d->sharedContext = context;
+}
+
+QWindowContext *QWindowFormat::sharedContext() const
+{
+ return d->sharedContext;
+}
+
+/*!
+ \fn bool QWindowFormat::hasWindowSurface() const
+
+ Returns true if the corresponding widget has an instance of QWindowSurface.
+
+ Otherwise returns false.
+
+ WindowSurface is enabled by default.
+
+ \sa setOverlay()
+*/
+
+void QWindowFormat::setWindowSurface(bool enable)
+{
+ if (enable) {
+ d->opts |= QWindowFormat::WindowSurface;
+ } else {
+ d->opts &= ~QWindowFormat::WindowSurface;
+ }
+}
+
+/*!
+ Sets the format option to \a opt.
+
+ \sa testOption()
+*/
+
+void QWindowFormat::setOption(QWindowFormat::FormatOptions opt)
+{
+ detach();
+ d->opts |= opt;
+}
+
+/*!
+ Returns true if format option \a opt is set; otherwise returns false.
+
+ \sa setOption()
+*/
+
+bool QWindowFormat::testOption(QWindowFormat::FormatOptions opt) const
+{
+ return d->opts & opt;
+}
+
+/*!
+ Set the minimum depth buffer size to \a size.
+
+ \sa depthBufferSize(), setDepth(), depth()
+*/
+void QWindowFormat::setDepthBufferSize(int size)
+{
+ detach();
+ d->depthSize = size;
+}
+
+/*!
+ Returns the depth buffer size.
+
+ \sa depth(), setDepth(), setDepthBufferSize()
+*/
+int QWindowFormat::depthBufferSize() const
+{
+ return d->depthSize;
+}
+
+void QWindowFormat::setSwapBehavior(SwapBehavior behavior)
+{
+ d->swapBehavior = behavior;
+}
+
+QWindowFormat::SwapBehavior QWindowFormat::swapBehavior() const
+{
+ return d->swapBehavior;
+}
+
+bool QWindowFormat::hasAlpha() const
+{
+ return d->alphaBufferSize > 0;
+}
+
+/*!
+ Set the preferred stencil buffer size to \a size.
+
+ \sa stencilBufferSize(), setStencil(), stencil()
+*/
+void QWindowFormat::setStencilBufferSize(int size)
+{
+ detach();
+ d->stencilSize = size;
+}
+
+/*!
+ Returns the stencil buffer size.
+
+ \sa stencil(), setStencil(), setStencilBufferSize()
+*/
+int QWindowFormat::stencilBufferSize() const
+{
+ return d->stencilSize;
+}
+
+int QWindowFormat::redBufferSize() const
+{
+ return d->redBufferSize;
+}
+
+int QWindowFormat::greenBufferSize() const
+{
+ return d->greenBufferSize;
+}
+
+int QWindowFormat::blueBufferSize() const
+{
+ return d->blueBufferSize;
+}
+
+int QWindowFormat::alphaBufferSize() const
+{
+ return d->alphaBufferSize;
+}
+
+void QWindowFormat::setRedBufferSize(int size)
+{
+ d->redBufferSize = size;
+}
+
+void QWindowFormat::setGreenBufferSize(int size)
+{
+ d->greenBufferSize = size;
+}
+
+void QWindowFormat::setBlueBufferSize(int size)
+{
+ d->blueBufferSize = size;
+}
+
+void QWindowFormat::setAlphaBufferSize(int size)
+{
+ d->alphaBufferSize = size;
+}
+
+bool operator==(const QWindowFormat& a, const QWindowFormat& b)
+{
+ return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts
+ && a.d->stencilSize == b.d->stencilSize
+ && a.d->redBufferSize == b.d->redBufferSize
+ && a.d->greenBufferSize == b.d->greenBufferSize
+ && a.d->blueBufferSize == b.d->blueBufferSize
+ && a.d->alphaBufferSize == b.d->alphaBufferSize
+ && a.d->depthSize == b.d->depthSize
+ && a.d->numSamples == b.d->numSamples
+ && a.d->swapBehavior == b.d->swapBehavior
+ && a.d->sharedContext == b.d->sharedContext);
+}
+
+
+/*!
+ Returns false if all the options of the two QWindowFormat objects
+ \a a and \a b are equal; otherwise returns true.
+
+ \relates QWindowFormat
+*/
+
+bool operator!=(const QWindowFormat& a, const QWindowFormat& b)
+{
+ return !(a == b);
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const QWindowFormat &f)
+{
+ const QWindowFormatPrivate * const d = f.d;
+
+ dbg.nospace() << "QWindowFormat("
+ << "options " << d->opts
+ << ", depthBufferSize " << d->depthSize
+ << ", redBufferSize " << d->redBufferSize
+ << ", greenBufferSize " << d->greenBufferSize
+ << ", blueBufferSize " << d->blueBufferSize
+ << ", alphaBufferSize " << d->alphaBufferSize
+ << ", stencilBufferSize " << d->stencilSize
+ << ", samples " << d->numSamples
+ << ", swapBehavior " << d->swapBehavior
+ << ", sharedContext " << d->sharedContext
+ << ')';
+
+ return dbg.space();
+}
+#endif
diff --git a/src/gui/guikernel/qwindowformat_qpa.h b/src/gui/guikernel/qwindowformat_qpa.h
new file mode 100644
index 0000000000..9bc2ccdfaa
--- /dev/null
+++ b/src/gui/guikernel/qwindowformat_qpa.h
@@ -0,0 +1,155 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QPLATFORMWINDOWFORMAT_QPA_H
+#define QPLATFORMWINDOWFORMAT_QPA_H
+
+#include <QtGui/QPlatformWindow>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QWindowContext;
+class QWindowFormatPrivate;
+
+class Q_GUI_EXPORT QWindowFormat
+{
+public:
+ enum FormatOption {
+ StereoBuffers = 0x0001,
+ WindowSurface = 0x0002
+ };
+ Q_DECLARE_FLAGS(FormatOptions, FormatOption)
+
+ enum SwapBehavior {
+ DefaultSwapBehavior,
+ SingleBuffer,
+ DoubleBuffer,
+ TripleBuffer
+ };
+
+ enum OpenGLContextProfile {
+ NoProfile,
+ CoreProfile,
+ CompatibilityProfile
+ };
+
+ QWindowFormat();
+ QWindowFormat(FormatOptions options);
+ QWindowFormat(const QWindowFormat &other);
+ QWindowFormat &operator=(const QWindowFormat &other);
+ ~QWindowFormat();
+
+ void setDepthBufferSize(int size);
+ int depthBufferSize() const;
+
+ void setStencilBufferSize(int size);
+ int stencilBufferSize() const;
+
+ void setRedBufferSize(int size);
+ int redBufferSize() const;
+ void setGreenBufferSize(int size);
+ int greenBufferSize() const;
+ void setBlueBufferSize(int size);
+ int blueBufferSize() const;
+ void setAlphaBufferSize(int size);
+ int alphaBufferSize() const;
+
+ void setSamples(int numSamples);
+ int samples() const;
+
+ void setSwapBehavior(SwapBehavior behavior);
+ SwapBehavior swapBehavior() const;
+
+ bool hasAlpha() const;
+
+ void setProfile(OpenGLContextProfile profile);
+ OpenGLContextProfile profile() const;
+
+ void setSharedContext(QWindowContext *context);
+ QWindowContext *sharedContext() const;
+
+ bool stereo() const;
+ void setStereo(bool enable);
+ bool windowSurface() const;
+ void setWindowSurface(bool enable);
+
+ void setOption(QWindowFormat::FormatOptions opt);
+ bool testOption(QWindowFormat::FormatOptions opt) const;
+
+private:
+ QWindowFormatPrivate *d;
+
+ void detach();
+
+ friend Q_GUI_EXPORT bool operator==(const QWindowFormat&, const QWindowFormat&);
+ friend Q_GUI_EXPORT bool operator!=(const QWindowFormat&, const QWindowFormat&);
+#ifndef QT_NO_DEBUG_STREAM
+ friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QWindowFormat &);
+#endif
+};
+
+Q_GUI_EXPORT bool operator==(const QWindowFormat&, const QWindowFormat&);
+Q_GUI_EXPORT bool operator!=(const QWindowFormat&, const QWindowFormat&);
+
+#ifndef QT_NO_DEBUG_STREAM
+Q_OPENGL_EXPORT QDebug operator<<(QDebug, const QWindowFormat &);
+#endif
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QWindowFormat::FormatOptions)
+
+inline bool QWindowFormat::stereo() const
+{
+ return testOption(QWindowFormat::StereoBuffers);
+}
+
+inline bool QWindowFormat::windowSurface() const
+{
+ return testOption(QWindowFormat::WindowSurface);
+}
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif //QPLATFORMWINDOWFORMAT_QPA_H
diff --git a/src/gui/guikernel/qwindowsysteminterface_qpa.cpp b/src/gui/guikernel/qwindowsysteminterface_qpa.cpp
new file mode 100644
index 0000000000..aece0fec18
--- /dev/null
+++ b/src/gui/guikernel/qwindowsysteminterface_qpa.cpp
@@ -0,0 +1,254 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qwindowsysteminterface_qpa.h"
+#include "qwindowsysteminterface_qpa_p.h"
+#include "private/qguiapplication_p.h"
+#include <QAbstractEventDispatcher>
+
+QT_BEGIN_NAMESPACE
+
+
+QTime QWindowSystemInterfacePrivate::eventTime;
+
+//------------------------------------------------------------
+//
+// Callback functions for plugins:
+//
+
+QList<QWindowSystemInterfacePrivate::WindowSystemEvent *> QWindowSystemInterfacePrivate::windowSystemEventQueue;
+QMutex QWindowSystemInterfacePrivate::queueMutex;
+
+extern QPointer<QWindow> qt_last_mouse_receiver;
+
+
+void QWindowSystemInterface::handleEnterEvent(QWindow *tlw)
+{
+ if (tlw) {
+ QWindowSystemInterfacePrivate::EnterEvent *e = new QWindowSystemInterfacePrivate::EnterEvent(tlw);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+ }
+}
+
+void QWindowSystemInterface::handleLeaveEvent(QWindow *tlw)
+{
+ QWindowSystemInterfacePrivate::LeaveEvent *e = new QWindowSystemInterfacePrivate::LeaveEvent(tlw);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+}
+
+void QWindowSystemInterface::handleWindowActivated(QWindow *tlw)
+{
+ QWindowSystemInterfacePrivate::ActivatedWindowEvent *e = new QWindowSystemInterfacePrivate::ActivatedWindowEvent(tlw);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+}
+
+void QWindowSystemInterface::handleGeometryChange(QWindow *tlw, const QRect &newRect)
+{
+ QWindowSystemInterfacePrivate::GeometryChangeEvent *e = new QWindowSystemInterfacePrivate::GeometryChangeEvent(tlw,newRect);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+}
+
+
+void QWindowSystemInterface::handleCloseEvent(QWindow *tlw)
+{
+ if (tlw) {
+ QWindowSystemInterfacePrivate::CloseEvent *e =
+ new QWindowSystemInterfacePrivate::CloseEvent(tlw);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+ }
+}
+
+/*!
+
+\a tlw == 0 means that \a ev is in global coords only
+
+
+*/
+void QWindowSystemInterface::handleMouseEvent(QWindow *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b) {
+ unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
+ handleMouseEvent(w, time, local, global, b);
+}
+
+void QWindowSystemInterface::handleMouseEvent(QWindow *tlw, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b)
+{
+ QWindowSystemInterfacePrivate::MouseEvent * e =
+ new QWindowSystemInterfacePrivate::MouseEvent(tlw, timestamp, local, global, b);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+}
+
+void QWindowSystemInterface::handleKeyEvent(QWindow *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count) {
+ unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
+ handleKeyEvent(w, time, t, k, mods, text, autorep, count);
+}
+
+void QWindowSystemInterface::handleKeyEvent(QWindow *tlw, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count)
+{
+ QWindowSystemInterfacePrivate::KeyEvent * e =
+ new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, t, k, mods, text, autorep, count);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+}
+
+void QWindowSystemInterface::handleExtendedKeyEvent(QWindow *w, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
+ quint32 nativeScanCode, quint32 nativeVirtualKey,
+ quint32 nativeModifiers,
+ const QString& text, bool autorep,
+ ushort count)
+{
+ unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
+ handleExtendedKeyEvent(w, time, type, key, modifiers, nativeScanCode, nativeVirtualKey, nativeModifiers,
+ text, autorep, count);
+}
+
+void QWindowSystemInterface::handleExtendedKeyEvent(QWindow *tlw, ulong timestamp, QEvent::Type type, int key,
+ Qt::KeyboardModifiers modifiers,
+ quint32 nativeScanCode, quint32 nativeVirtualKey,
+ quint32 nativeModifiers,
+ const QString& text, bool autorep,
+ ushort count)
+{
+ QWindowSystemInterfacePrivate::KeyEvent * e =
+ new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, type, key, modifiers,
+ nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+}
+
+void QWindowSystemInterface::handleWheelEvent(QWindow *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) {
+ unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
+ handleWheelEvent(w, time, local, global, d, o);
+}
+
+void QWindowSystemInterface::handleWheelEvent(QWindow *tlw, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o)
+{
+ QWindowSystemInterfacePrivate::WheelEvent *e =
+ new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, d, o);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+}
+
+int QWindowSystemInterfacePrivate::windowSystemEventsQueued()
+{
+ queueMutex.lock();
+ int ret = windowSystemEventQueue.count();
+ queueMutex.unlock();
+ return ret;
+}
+
+QWindowSystemInterfacePrivate::WindowSystemEvent * QWindowSystemInterfacePrivate::getWindowSystemEvent()
+{
+ queueMutex.lock();
+ QWindowSystemInterfacePrivate::WindowSystemEvent *ret;
+ if (windowSystemEventQueue.isEmpty())
+ ret = 0;
+ else
+ ret = windowSystemEventQueue.takeFirst();
+ queueMutex.unlock();
+ return ret;
+}
+
+void QWindowSystemInterfacePrivate::queueWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *ev)
+{
+ queueMutex.lock();
+ windowSystemEventQueue.append(ev);
+ queueMutex.unlock();
+
+ QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::qt_qpa_core_dispatcher();
+ if (dispatcher)
+ dispatcher->wakeUp();
+}
+
+void QWindowSystemInterface::handleTouchEvent(QWindow *w, QEvent::Type type, QTouchEvent::DeviceType devType, const QList<struct TouchPoint> &points) {
+ unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
+ handleTouchEvent(w, time, type, devType, points);
+}
+
+void QWindowSystemInterface::handleTouchEvent(QWindow *tlw, ulong timestamp, QEvent::Type type, QTouchEvent::DeviceType devType, const QList<struct TouchPoint> &points)
+{
+ if (!points.size()) // Touch events must have at least one point
+ return;
+
+ QList<QTouchEvent::TouchPoint> touchPoints;
+ Qt::TouchPointStates states;
+ QTouchEvent::TouchPoint p;
+
+ QList<struct TouchPoint>::const_iterator point = points.constBegin();
+ QList<struct TouchPoint>::const_iterator end = points.constEnd();
+ while (point != end) {
+ p.setId(point->id);
+ p.setPressure(point->pressure);
+ states |= point->state;
+ Qt::TouchPointStates state = point->state;
+ if (point->isPrimary) {
+ state |= Qt::TouchPointPrimary;
+ }
+ p.setState(state);
+ p.setRect(point->area);
+ p.setScreenPos(point->area.center());
+ p.setNormalizedPos(point->normalPosition);
+
+ touchPoints.append(p);
+ ++point;
+ }
+
+ QWindowSystemInterfacePrivate::TouchEvent *e =
+ new QWindowSystemInterfacePrivate::TouchEvent(tlw, timestamp, type, devType, touchPoints);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+}
+
+void QWindowSystemInterface::handleScreenGeometryChange(int screenIndex)
+{
+ QWindowSystemInterfacePrivate::ScreenGeometryEvent *e =
+ new QWindowSystemInterfacePrivate::ScreenGeometryEvent(screenIndex);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+}
+
+void QWindowSystemInterface::handleScreenAvailableGeometryChange(int screenIndex)
+{
+ QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e =
+ new QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent(screenIndex);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+}
+
+void QWindowSystemInterface::handleScreenCountChange(int count)
+{
+ QWindowSystemInterfacePrivate::ScreenCountEvent *e =
+ new QWindowSystemInterfacePrivate::ScreenCountEvent(count);
+ QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/guikernel/qwindowsysteminterface_qpa.h b/src/gui/guikernel/qwindowsysteminterface_qpa.h
new file mode 100644
index 0000000000..bd8139933c
--- /dev/null
+++ b/src/gui/guikernel/qwindowsysteminterface_qpa.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QWINDOWSYSTEMINTERFACE_H
+#define QWINDOWSYSTEMINTERFACE_H
+
+#include <QtCore/QTime>
+#include <QtGui/qwindowdefs.h>
+#include <QtCore/QEvent>
+#include <QtGui/QWindow>
+#include <QtCore/QWeakPointer>
+#include <QtCore/QMutex>
+#include <QtGui/QTouchEvent>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class Q_GUI_EXPORT QWindowSystemInterface
+{
+public:
+ static void handleMouseEvent(QWindow *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b);
+ static void handleMouseEvent(QWindow *w, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b);
+
+ static void handleKeyEvent(QWindow *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
+ static void handleKeyEvent(QWindow *w, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
+
+ static void handleExtendedKeyEvent(QWindow *w, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
+ quint32 nativeScanCode, quint32 nativeVirtualKey,
+ quint32 nativeModifiers,
+ const QString& text = QString(), bool autorep = false,
+ ushort count = 1);
+ static void handleExtendedKeyEvent(QWindow *w, ulong timestamp, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
+ quint32 nativeScanCode, quint32 nativeVirtualKey,
+ quint32 nativeModifiers,
+ const QString& text = QString(), bool autorep = false,
+ ushort count = 1);
+
+ static void handleWheelEvent(QWindow *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o);
+ static void handleWheelEvent(QWindow *w, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o);
+
+ struct TouchPoint {
+ int id; // for application use
+ bool isPrimary; // for application use
+ QPointF normalPosition; // touch device coordinates, (0 to 1, 0 to 1)
+ QRectF area; // the touched area, centered at position in screen coordinates
+ qreal pressure; // 0 to 1
+ Qt::TouchPointState state; //Qt::TouchPoint{Pressed|Moved|Stationary|Released}
+ };
+
+ static void handleTouchEvent(QWindow *w, QEvent::Type type, QTouchEvent::DeviceType devType, const QList<struct TouchPoint> &points);
+ static void handleTouchEvent(QWindow *w, ulong timestamp, QEvent::Type type, QTouchEvent::DeviceType devType, const QList<struct TouchPoint> &points);
+
+ static void handleGeometryChange(QWindow *w, const QRect &newRect);
+ static void handleCloseEvent(QWindow *w);
+ static void handleEnterEvent(QWindow *w);
+ static void handleLeaveEvent(QWindow *w);
+ static void handleWindowActivated(QWindow *w);
+
+ // Changes to the screen
+ static void handleScreenGeometryChange(int screenIndex);
+ static void handleScreenAvailableGeometryChange(int screenIndex);
+ static void handleScreenCountChange(int count);
+};
+
+QT_END_NAMESPACE
+QT_END_HEADER
+#endif // QWINDOWSYSTEMINTERFACE_H
diff --git a/src/gui/guikernel/qwindowsysteminterface_qpa_p.h b/src/gui/guikernel/qwindowsysteminterface_qpa_p.h
new file mode 100644
index 0000000000..30adecc405
--- /dev/null
+++ b/src/gui/guikernel/qwindowsysteminterface_qpa_p.h
@@ -0,0 +1,208 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QWINDOWSYSTEMINTERFACE_QPA_P_H
+#define QWINDOWSYSTEMINTERFACE_QPA_P_H
+
+#include "qwindowsysteminterface_qpa.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QWindowSystemInterfacePrivate {
+public:
+ enum EventType {
+ Close,
+ GeometryChange,
+ Enter,
+ Leave,
+ ActivatedWindow,
+ Mouse,
+ Wheel,
+ Key,
+ Touch,
+ ScreenGeometry,
+ ScreenAvailableGeometry,
+ ScreenCountChange
+ };
+
+ class WindowSystemEvent {
+ public:
+ WindowSystemEvent(EventType t)
+ : type(t) { }
+ EventType type;
+ };
+
+ class CloseEvent : public WindowSystemEvent {
+ public:
+ CloseEvent(QWindow *w)
+ : WindowSystemEvent(Close), window(w) { }
+ QWeakPointer<QWindow> window;
+ };
+
+ class GeometryChangeEvent : public WindowSystemEvent {
+ public:
+ GeometryChangeEvent(QWindow *tlw, const QRect &newGeometry)
+ : WindowSystemEvent(GeometryChange), tlw(tlw), newGeometry(newGeometry)
+ { }
+ QWeakPointer<QWindow> tlw;
+ QRect newGeometry;
+ };
+
+ class EnterEvent : public WindowSystemEvent {
+ public:
+ EnterEvent(QWindow *enter)
+ : WindowSystemEvent(Enter), enter(enter)
+ { }
+ QWeakPointer<QWindow> enter;
+ };
+
+ class LeaveEvent : public WindowSystemEvent {
+ public:
+ LeaveEvent(QWindow *leave)
+ : WindowSystemEvent(Leave), leave(leave)
+ { }
+ QWeakPointer<QWindow> leave;
+ };
+
+ class ActivatedWindowEvent : public WindowSystemEvent {
+ public:
+ ActivatedWindowEvent(QWindow *activatedWindow)
+ : WindowSystemEvent(ActivatedWindow), activated(activatedWindow)
+ { }
+ QWeakPointer<QWindow> activated;
+ };
+
+ class UserEvent : public WindowSystemEvent {
+ public:
+ UserEvent(QWindow * w, ulong time, EventType t)
+ : WindowSystemEvent(t), window(w), timestamp(time) { }
+ QWeakPointer<QWindow> window;
+ unsigned long timestamp;
+ };
+
+ class MouseEvent : public UserEvent {
+ public:
+ MouseEvent(QWindow * w, ulong time, const QPoint & local, const QPoint & global, Qt::MouseButtons b)
+ : UserEvent(w, time, Mouse), localPos(local), globalPos(global), buttons(b) { }
+ QPoint localPos;
+ QPoint globalPos;
+ Qt::MouseButtons buttons;
+ };
+
+ class WheelEvent : public UserEvent {
+ public:
+ WheelEvent(QWindow *w, ulong time, const QPoint & local, const QPoint & global, int d, Qt::Orientation o)
+ : UserEvent(w, time, Wheel), delta(d), localPos(local), globalPos(global), orient(o) { }
+ int delta;
+ QPoint localPos;
+ QPoint globalPos;
+ Qt::Orientation orient;
+ };
+
+ class KeyEvent : public UserEvent {
+ public:
+ KeyEvent(QWindow *w, ulong time, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1)
+ :UserEvent(w, time, Key), key(k), unicode(text), repeat(autorep),
+ repeatCount(count), modifiers(mods), keyType(t),
+ nativeScanCode(0), nativeVirtualKey(0), nativeModifiers(0) { }
+ KeyEvent(QWindow *w, ulong time, QEvent::Type t, int k, Qt::KeyboardModifiers mods,
+ quint32 nativeSC, quint32 nativeVK, quint32 nativeMods,
+ const QString & text = QString(), bool autorep = false, ushort count = 1)
+ :UserEvent(w, time, Key), key(k), unicode(text), repeat(autorep),
+ repeatCount(count), modifiers(mods), keyType(t),
+ nativeScanCode(nativeSC), nativeVirtualKey(nativeVK), nativeModifiers(nativeMods) { }
+ int key;
+ QString unicode;
+ bool repeat;
+ ushort repeatCount;
+ Qt::KeyboardModifiers modifiers;
+ QEvent::Type keyType;
+ quint32 nativeScanCode;
+ quint32 nativeVirtualKey;
+ quint32 nativeModifiers;
+ };
+
+ class TouchEvent : public UserEvent {
+ public:
+ TouchEvent(QWindow *w, ulong time, QEvent::Type t, QTouchEvent::DeviceType d, const QList<QTouchEvent::TouchPoint> &p)
+ :UserEvent(w, time, Touch), devType(d), points(p), touchType(t) { }
+ QTouchEvent::DeviceType devType;
+ QList<QTouchEvent::TouchPoint> points;
+ QEvent::Type touchType;
+
+ };
+
+ class ScreenCountEvent : public WindowSystemEvent {
+ public:
+ ScreenCountEvent (int count)
+ : WindowSystemEvent(ScreenCountChange) , count(count) { }
+ int count;
+ };
+
+ class ScreenGeometryEvent : public WindowSystemEvent {
+ public:
+ ScreenGeometryEvent(int index)
+ : WindowSystemEvent(ScreenGeometry), index(index) { }
+ int index;
+ };
+
+ class ScreenAvailableGeometryEvent : public WindowSystemEvent {
+ public:
+ ScreenAvailableGeometryEvent(int index)
+ : WindowSystemEvent(ScreenAvailableGeometry), index(index) { }
+ int index;
+ };
+
+ static QList<WindowSystemEvent *> windowSystemEventQueue;
+ static QMutex queueMutex;
+
+ static int windowSystemEventsQueued();
+ static WindowSystemEvent * getWindowSystemEvent();
+ static void queueWindowSystemEvent(WindowSystemEvent *ev);
+
+ static QTime eventTime;
+};
+
+QT_END_HEADER
+QT_END_NAMESPACE
+
+#endif // QWINDOWSYSTEMINTERFACE_QPA_P_H
diff --git a/src/gui/guiutil/guiutil.pri b/src/gui/guiutil/guiutil.pri
new file mode 100644
index 0000000000..95ec2cfc0f
--- /dev/null
+++ b/src/gui/guiutil/guiutil.pri
@@ -0,0 +1,10 @@
+# Qt util module
+
+HEADERS += \
+ guiutil/qdesktopservices.h \
+ guiutil/qhexstring_p.h \
+ guiutil/qvalidator.h
+
+SOURCES += \
+ guiutil/qdesktopservices.cpp \
+ guiutil/qvalidator.cpp
diff --git a/src/gui/guiutil/qdesktopservices.cpp b/src/gui/guiutil/qdesktopservices.cpp
new file mode 100644
index 0000000000..2c2c3308ca
--- /dev/null
+++ b/src/gui/guiutil/qdesktopservices.cpp
@@ -0,0 +1,309 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdesktopservices.h"
+
+#ifndef QT_NO_DESKTOPSERVICES
+
+#include <qdebug.h>
+
+#if defined(Q_WS_QWS) || defined(Q_WS_QPA)
+#include "qdesktopservices_qpa.cpp"
+#elif defined(Q_WS_X11)
+#include "qdesktopservices_x11.cpp"
+#elif defined(Q_WS_WIN)
+#include "qdesktopservices_win.cpp"
+#elif defined(Q_WS_MAC)
+#include "qdesktopservices_mac.cpp"
+#elif defined(Q_OS_SYMBIAN)
+#include "qdesktopservices_s60.cpp"
+#endif
+
+#include <qhash.h>
+#include <qobject.h>
+#include <qcoreapplication.h>
+#include <qurl.h>
+#include <qmutex.h>
+
+QT_BEGIN_NAMESPACE
+
+class QOpenUrlHandlerRegistry : public QObject
+{
+ Q_OBJECT
+public:
+ inline QOpenUrlHandlerRegistry() : mutex(QMutex::Recursive) {}
+
+ QMutex mutex;
+
+ struct Handler
+ {
+ QObject *receiver;
+ QByteArray name;
+ };
+ typedef QHash<QString, Handler> HandlerHash;
+ HandlerHash handlers;
+
+public Q_SLOTS:
+ void handlerDestroyed(QObject *handler);
+
+};
+
+Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
+
+void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
+{
+ HandlerHash::Iterator it = handlers.begin();
+ while (it != handlers.end()) {
+ if (it->receiver == handler) {
+ it = handlers.erase(it);
+ } else {
+ ++it;
+ }
+ }
+}
+
+/*!
+ \class QDesktopServices
+ \brief The QDesktopServices class provides methods for accessing common desktop services.
+ \since 4.2
+ \ingroup desktop
+
+ Many desktop environments provide services that can be used by applications to
+ perform common tasks, such as opening a web page, in a way that is both consistent
+ and takes into account the user's application preferences.
+
+ This class contains functions that provide simple interfaces to these services
+ that indicate whether they succeeded or failed.
+
+ The openUrl() function is used to open files located at arbitrary URLs in external
+ applications. For URLs that correspond to resources on the local filing system
+ (where the URL scheme is "file"), a suitable application will be used to open the
+ file; otherwise, a web browser will be used to fetch and display the file.
+
+ The user's desktop settings control whether certain executable file types are
+ opened for browsing, or if they are executed instead. Some desktop environments
+ are configured to prevent users from executing files obtained from non-local URLs,
+ or to ask the user's permission before doing so.
+
+ \section1 URL Handlers
+
+ The behavior of the openUrl() function can be customized for individual URL
+ schemes to allow applications to override the default handling behavior for
+ certain types of URLs.
+
+ The dispatch mechanism allows only one custom handler to be used for each URL
+ scheme; this is set using the setUrlHandler() function. Each handler is
+ implemented as a slot which accepts only a single QUrl argument.
+
+ The existing handlers for each scheme can be removed with the
+ unsetUrlHandler() function. This returns the handling behavior for the given
+ scheme to the default behavior.
+
+ This system makes it easy to implement a help system, for example. Help could be
+ provided in labels and text browsers using \gui{help://myapplication/mytopic}
+ URLs, and by registering a handler it becomes possible to display the help text
+ inside the application:
+
+ \snippet doc/src/snippets/code/src_gui_util_qdesktopservices.cpp 0
+
+ If inside the handler you decide that you can't open the requested
+ URL, you can just call QDesktopServices::openUrl() again with the
+ same argument, and it will try to open the URL using the
+ appropriate mechanism for the user's desktop environment.
+
+ \sa QSystemTrayIcon, QProcess
+*/
+
+/*!
+ Opens the given \a url in the appropriate Web browser for the user's desktop
+ environment, and returns true if successful; otherwise returns false.
+
+ If the URL is a reference to a local file (i.e., the URL scheme is "file") then
+ it will be opened with a suitable application instead of a Web browser.
+
+ The following example opens a file on the Windows file system residing on a path
+ that contains spaces:
+
+ \snippet doc/src/snippets/code/src_gui_util_qdesktopservices.cpp 2
+
+ If a \c mailto URL is specified, the user's e-mail client will be used to open a
+ composer window containing the options specified in the URL, similar to the way
+ \c mailto links are handled by a Web browser.
+
+ For example, the following URL contains a recipient (\c{user@foo.com}), a
+ subject (\c{Test}), and a message body (\c{Just a test}):
+
+ \snippet doc/src/snippets/code/src_gui_util_qdesktopservices.cpp 1
+
+ \warning Although many e-mail clients can send attachments and are
+ Unicode-aware, the user may have configured their client without these features.
+ Also, certain e-mail clients (e.g., Lotus Notes) have problems with long URLs.
+
+ \sa setUrlHandler()
+*/
+bool QDesktopServices::openUrl(const QUrl &url)
+{
+ QOpenUrlHandlerRegistry *registry = handlerRegistry();
+ QMutexLocker locker(&registry->mutex);
+ static bool insideOpenUrlHandler = false;
+
+ if (!insideOpenUrlHandler) {
+ QOpenUrlHandlerRegistry::HandlerHash::ConstIterator handler = registry->handlers.constFind(url.scheme());
+ if (handler != registry->handlers.constEnd()) {
+ insideOpenUrlHandler = true;
+ bool result = QMetaObject::invokeMethod(handler->receiver, handler->name.constData(), Qt::DirectConnection, Q_ARG(QUrl, url));
+ insideOpenUrlHandler = false;
+ return result; // ### support bool slot return type
+ }
+ }
+
+ bool result;
+ if (url.scheme() == QLatin1String("file"))
+ result = openDocument(url);
+ else
+ result = launchWebBrowser(url);
+
+ return result;
+}
+
+/*!
+ Sets the handler for the given \a scheme to be the handler \a method provided by
+ the \a receiver object.
+
+ This function provides a way to customize the behavior of openUrl(). If openUrl()
+ is called with a URL with the specified \a scheme then the given \a method on the
+ \a receiver object is called instead of QDesktopServices launching an external
+ application.
+
+ The provided method must be implemented as a slot that only accepts a single QUrl
+ argument.
+
+ If setUrlHandler() is used to set a new handler for a scheme which already
+ has a handler, the existing handler is simply replaced with the new one.
+ Since QDesktopServices does not take ownership of handlers, no objects are
+ deleted when a handler is replaced.
+
+ Note that the handler will always be called from within the same thread that
+ calls QDesktopServices::openUrl().
+
+ \sa openUrl(), unsetUrlHandler()
+*/
+void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, const char *method)
+{
+ QOpenUrlHandlerRegistry *registry = handlerRegistry();
+ QMutexLocker locker(&registry->mutex);
+ if (!receiver) {
+ registry->handlers.remove(scheme);
+ return;
+ }
+ QOpenUrlHandlerRegistry::Handler h;
+ h.receiver = receiver;
+ h.name = method;
+ registry->handlers.insert(scheme, h);
+ QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
+ registry, SLOT(handlerDestroyed(QObject*)));
+}
+
+/*!
+ Removes a previously set URL handler for the specified \a scheme.
+
+ \sa setUrlHandler()
+*/
+void QDesktopServices::unsetUrlHandler(const QString &scheme)
+{
+ setUrlHandler(scheme, 0, 0);
+}
+
+/*!
+ \enum QDesktopServices::StandardLocation
+ \since 4.4
+
+ This enum describes the different locations that can be queried by
+ QDesktopServices::storageLocation and QDesktopServices::displayName.
+
+ \value DesktopLocation Returns the user's desktop directory.
+ \value DocumentsLocation Returns the user's document.
+ \value FontsLocation Returns the user's fonts.
+ \value ApplicationsLocation Returns the user's applications.
+ \value MusicLocation Returns the users music.
+ \value MoviesLocation Returns the user's movies.
+ \value PicturesLocation Returns the user's pictures.
+ \value TempLocation Returns the system's temporary directory.
+ \value HomeLocation Returns the user's home directory.
+ \value DataLocation Returns a directory location where persistent
+ application data can be stored. QCoreApplication::applicationName
+ and QCoreApplication::organizationName should work on all
+ platforms.
+ \value CacheLocation Returns a directory location where user-specific
+ non-essential (cached) data should be written.
+
+ \sa storageLocation() displayName()
+*/
+
+/*!
+ \fn QString QDesktopServices::storageLocation(StandardLocation type)
+ \since 4.4
+
+ Returns the default system directory where files of \a type belong, or an empty string
+ if the location cannot be determined.
+
+ \note The storage location returned can be a directory that does not exist; i.e., it
+ may need to be created by the system or the user.
+
+ \note On Symbian OS, ApplicationsLocation always point /sys/bin folder on the same drive
+ with executable. FontsLocation always points to folder on ROM drive. Symbian OS does not
+ have desktop concept, DesktopLocation returns same path as DocumentsLocation.
+ Rest of the standard locations point to folder on same drive with executable, except
+ that if executable is in ROM the folder from C drive is returned.
+*/
+
+/*!
+ \fn QString QDesktopServices::displayName(StandardLocation type)
+
+ Returns a localized display name for the given location \a type or
+ an empty QString if no relevant location can be found.
+*/
+
+QT_END_NAMESPACE
+
+#include "qdesktopservices.moc"
+
+#endif // QT_NO_DESKTOPSERVICES
diff --git a/src/gui/util/qdesktopservices.h b/src/gui/guiutil/qdesktopservices.h
index 9d5657ecca..9d5657ecca 100644
--- a/src/gui/util/qdesktopservices.h
+++ b/src/gui/guiutil/qdesktopservices.h
diff --git a/src/gui/util/qdesktopservices_mac.cpp b/src/gui/guiutil/qdesktopservices_mac.cpp
index e9868471cb..e9868471cb 100644
--- a/src/gui/util/qdesktopservices_mac.cpp
+++ b/src/gui/guiutil/qdesktopservices_mac.cpp
diff --git a/src/gui/util/qdesktopservices_qws.cpp b/src/gui/guiutil/qdesktopservices_qpa.cpp
index 324fa51a62..324fa51a62 100644
--- a/src/gui/util/qdesktopservices_qws.cpp
+++ b/src/gui/guiutil/qdesktopservices_qpa.cpp
diff --git a/src/gui/util/qdesktopservices_s60.cpp b/src/gui/guiutil/qdesktopservices_s60.cpp
index 8caeb74fec..8caeb74fec 100644
--- a/src/gui/util/qdesktopservices_s60.cpp
+++ b/src/gui/guiutil/qdesktopservices_s60.cpp
diff --git a/src/gui/util/qdesktopservices_win.cpp b/src/gui/guiutil/qdesktopservices_win.cpp
index 783970ba82..783970ba82 100644
--- a/src/gui/util/qdesktopservices_win.cpp
+++ b/src/gui/guiutil/qdesktopservices_win.cpp
diff --git a/src/gui/util/qdesktopservices_x11.cpp b/src/gui/guiutil/qdesktopservices_x11.cpp
index e685bed0b9..e685bed0b9 100644
--- a/src/gui/util/qdesktopservices_x11.cpp
+++ b/src/gui/guiutil/qdesktopservices_x11.cpp
diff --git a/src/gui/guiutil/qhexstring_p.h b/src/gui/guiutil/qhexstring_p.h
new file mode 100644
index 0000000000..3c8d562756
--- /dev/null
+++ b/src/gui/guiutil/qhexstring_p.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qpoint.h>
+#include <QtCore/qstring.h>
+#include <QtGui/qpolygon.h>
+#include <QtCore/qstringbuilder.h>
+
+#ifndef QHEXSTRING_P_H
+#define QHEXSTRING_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.
+//
+
+QT_BEGIN_NAMESPACE
+
+// internal helper. Converts an integer value to an unique string token
+template <typename T>
+ struct HexString
+{
+ inline HexString(const T t)
+ : val(t)
+ {}
+
+ inline void write(QChar *&dest) const
+ {
+ const ushort hexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
+ const char *c = reinterpret_cast<const char *>(&val);
+ for (uint i = 0; i < sizeof(T); ++i) {
+ *dest++ = hexChars[*c & 0xf];
+ *dest++ = hexChars[(*c & 0xf0) >> 4];
+ ++c;
+ }
+ }
+ const T val;
+};
+
+// specialization to enable fast concatenating of our string tokens to a string
+template <typename T>
+ struct QConcatenable<HexString<T> >
+{
+ typedef HexString<T> type;
+ enum { ExactSize = true };
+ static int size(const HexString<T> &) { return sizeof(T) * 2; }
+ static inline void appendTo(const HexString<T> &str, QChar *&out) { str.write(out); }
+ typedef QString ConvertTo;
+};
+
+QT_END_NAMESPACE
+
+#endif // QHEXSTRING_P_H
diff --git a/src/gui/widgets/qvalidator.cpp b/src/gui/guiutil/qvalidator.cpp
index a76f7bb6e8..a76f7bb6e8 100644
--- a/src/gui/widgets/qvalidator.cpp
+++ b/src/gui/guiutil/qvalidator.cpp
diff --git a/src/gui/widgets/qvalidator.h b/src/gui/guiutil/qvalidator.h
index 5a0162afd5..5a0162afd5 100644
--- a/src/gui/widgets/qvalidator.h
+++ b/src/gui/guiutil/qvalidator.h
diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri
index 72738c9fa8..25da543b08 100644
--- a/src/gui/image/image.pri
+++ b/src/gui/image/image.pri
@@ -5,11 +5,6 @@
HEADERS += \
image/qbitmap.h \
- image/qicon.h \
- image/qicon_p.h \
- image/qiconloader_p.h \
- image/qiconengine.h \
- image/qiconengineplugin.h \
image/qimage.h \
image/qimage_p.h \
image/qimageiohandler.h \
@@ -28,7 +23,6 @@ HEADERS += \
image/qpixmapcache_p.h \
image/qpixmapdata_p.h \
image/qpixmapdatafactory_p.h \
- image/qpixmapfilter_p.h \
image/qimagepixmapcleanuphooks_p.h \
image/qvolatileimage_p.h \
image/qvolatileimagedata_p.h \
@@ -36,8 +30,6 @@ HEADERS += \
SOURCES += \
image/qbitmap.cpp \
- image/qicon.cpp \
- image/qiconloader.cpp \
image/qimage.cpp \
image/qimageiohandler.cpp \
image/qimagereader.cpp \
@@ -49,9 +41,6 @@ SOURCES += \
image/qpixmapcache.cpp \
image/qpixmapdata.cpp \
image/qpixmapdatafactory.cpp \
- image/qpixmapfilter.cpp \
- image/qiconengine.cpp \
- image/qiconengineplugin.cpp \
image/qmovie.cpp \
image/qpixmap_raster.cpp \
image/qpixmap_blitter.cpp \
@@ -62,9 +51,6 @@ SOURCES += \
win32 {
SOURCES += image/qpixmap_win.cpp
}
-else:embedded {
- SOURCES += image/qpixmap_qws.cpp
-}
else:qpa {
SOURCES += image/qpixmap_qpa.cpp
}
diff --git a/src/gui/image/qbitmap.cpp b/src/gui/image/qbitmap.cpp
index 260b397140..6cd8363374 100644
--- a/src/gui/image/qbitmap.cpp
+++ b/src/gui/image/qbitmap.cpp
@@ -44,8 +44,7 @@
#include "qimage.h"
#include "qvariant.h"
#include <qpainter.h>
-#include <private/qgraphicssystem_p.h>
-#include <private/qapplication_p.h>
+#include <private/qguiapplication_p.h>
QT_BEGIN_NAMESPACE
@@ -205,20 +204,6 @@ QBitmap &QBitmap::operator=(const QPixmap &pixmap)
return *this;
}
-
-#ifdef QT3_SUPPORT
-QBitmap::QBitmap(int w, int h, const uchar *bits, bool isXbitmap)
-{
- *this = fromData(QSize(w, h), bits, isXbitmap ? QImage::Format_MonoLSB : QImage::Format_Mono);
-}
-
-
-QBitmap::QBitmap(const QSize &size, const uchar *bits, bool isXbitmap)
-{
- *this = fromData(size, bits, isXbitmap ? QImage::Format_MonoLSB : QImage::Format_Mono);
-}
-#endif
-
/*!
Destroys the bitmap.
*/
@@ -275,9 +260,7 @@ QBitmap QBitmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags)
img.setColor(1, c0);
}
- QGraphicsSystem* gs = QApplicationPrivate::graphicsSystem();
- QScopedPointer<QPixmapData> data(gs ? gs->createPixmapData(QPixmapData::BitmapType)
- : QGraphicsSystem::createDefaultPixmapData(QPixmapData::BitmapType));
+ QScopedPointer<QPixmapData> data(QGuiApplicationPrivate::platformIntegration()->createPixmapData(QPixmapData::BitmapType));
data->fromImage(img, flags | Qt::MonoOnly);
return QPixmap(data.take());
@@ -335,77 +318,4 @@ QBitmap QBitmap::transformed(const QMatrix &matrix) const
return transformed(QTransform(matrix));
}
-#ifdef QT3_SUPPORT
-/*!
- \fn QBitmap QBitmap::xForm(const QMatrix &matrix) const
-
- Returns a copy of this bitmap, transformed according to the given
- \a matrix.
-
- Use transformed() instead.
-*/
-
-/*!
- \fn QBitmap::QBitmap(const QSize &size, bool clear)
-
- Constructs a bitmap with the given \a size. If \a clear is true,
- the bits are initialized to Qt::color0.
-
- Use the corresponding QBitmap() constructor instead, and then call
- the clear() function if the \a clear parameter is true.
-*/
-
-/*!
- \fn QBitmap::QBitmap(int width, int height, bool clear)
-
- Constructs a bitmap with the given \a width and \a height. If \a
- clear is true, the bits are initialized to Qt::color0.
-
- Use the corresponding QBitmap() constructor instead, and then call
- the clear() function if the \a clear parameter is true.
-*/
-
-/*!
- \fn QBitmap::QBitmap(int width, int height, const uchar *bits, bool isXbitmap)
-
- Constructs a bitmap with the given \a width and \a height, and
- sets the contents to the \a bits supplied. The \a isXbitmap flag
- should be true if \a bits was generated by the X11 bitmap
- program.
-
- Use the static fromData() function instead. If \a isXbitmap is
- true, use the default bit order(QImage_FormatMonoLSB) otherwise
- use QImage::Format_Mono.
-
- \omit
- The X bitmap bit order is little endian. The QImage
- documentation discusses bit order of monochrome images. Opposed to
- QImage, the data has to be byte aligned.
-
- Example (creates an arrow bitmap):
- \snippet doc/src/snippets/code/src_gui_image_qbitmap.cpp 0
- \endomit
-*/
-
-
-/*!
- \fn QBitmap::QBitmap(const QSize &size, const uchar *bits, bool isXbitmap)
-
- \overload
-
- Constructs a bitmap with the given \a size, and sets the contents
- to the \a bits supplied. The \a isXbitmap flag should be true if
- \a bits was generated by the X11 bitmap program.
-
- \omit
- The X bitmap bit order is little endian. The QImage documentation
- discusses bit order of monochrome images.
- \endomit
-
- Use the static fromData() function instead. If \a isXbitmap is
- true, use the default bit order(QImage_FormatMonoLSB) otherwise
- use QImage::Format_Mono.
-*/
-#endif
-
QT_END_NAMESPACE
diff --git a/src/gui/image/qbitmap.h b/src/gui/image/qbitmap.h
index f1771e3e43..9dff0816dd 100644
--- a/src/gui/image/qbitmap.h
+++ b/src/gui/image/qbitmap.h
@@ -74,34 +74,11 @@ public:
QBitmap transformed(const QMatrix &) const;
QBitmap transformed(const QTransform &matrix) const;
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT_CONSTRUCTOR QBitmap(int w, int h, bool clear);
- inline QT3_SUPPORT_CONSTRUCTOR QBitmap(const QSize &, bool clear);
- QT3_SUPPORT_CONSTRUCTOR QBitmap(int w, int h, const uchar *bits, bool isXbitmap=false);
- QT3_SUPPORT_CONSTRUCTOR QBitmap(const QSize &, const uchar *bits, bool isXbitmap=false);
- inline QT3_SUPPORT QBitmap xForm(const QMatrix &matrix) const { return transformed(QTransform(matrix)); }
- QT3_SUPPORT_CONSTRUCTOR QBitmap(const QImage &image) { *this = fromImage(image); }
- QT3_SUPPORT QBitmap &operator=(const QImage &image) { *this = fromImage(image); return *this; }
-#endif
typedef QExplicitlySharedDataPointer<QPixmapData> DataPtr;
};
Q_DECLARE_SHARED(QBitmap)
-#ifdef QT3_SUPPORT
-inline QBitmap::QBitmap(int w, int h, bool clear)
- : QPixmap(QSize(w, h), 1)
-{
- if (clear) this->clear();
-}
-
-inline QBitmap::QBitmap(const QSize &size, bool clear)
- : QPixmap(size, 1)
-{
- if (clear) this->clear();
-}
-#endif
-
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp
deleted file mode 100644
index 7182062e59..0000000000
--- a/src/gui/image/qicon.cpp
+++ /dev/null
@@ -1,1258 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qicon.h"
-#include "qicon_p.h"
-#include "qiconengine.h"
-#include "qiconengineplugin.h"
-#include "private/qfactoryloader_p.h"
-#include "private/qiconloader_p.h"
-#include "qapplication.h"
-#include "qstyleoption.h"
-#include "qpainter.h"
-#include "qfileinfo.h"
-#include "qstyle.h"
-#include "qpixmapcache.h"
-#include "qvariant.h"
-#include "qcache.h"
-#include "qdebug.h"
-#include "private/qguiplatformplugin_p.h"
-
-#ifdef Q_WS_MAC
-#include <private/qt_mac_p.h>
-#include <private/qt_cocoa_helpers_mac_p.h>
-#endif
-
-#ifdef Q_WS_X11
-#include "private/qt_x11_p.h"
-#include "private/qkde_p.h"
-#endif
-
-#include "private/qstylehelper_p.h"
-
-#ifndef QT_NO_ICON
-QT_BEGIN_NAMESPACE
-
-/*!
- \enum QIcon::Mode
-
- This enum type describes the mode for which a pixmap is intended
- to be used. The currently defined modes are:
-
- \value Normal
- Display the pixmap when the user is
- not interacting with the icon, but the
- functionality represented by the icon is available.
- \value Disabled
- Display the pixmap when the
- functionality represented by the icon is not available.
- \value Active
- Display the pixmap when the
- functionality represented by the icon is available and
- the user is interacting with the icon, for example, moving the
- mouse over it or clicking it.
- \value Selected
- Display the pixmap when the item represented by the icon is
- selected.
-*/
-
-/*!
- \enum QIcon::State
-
- This enum describes the state for which a pixmap is intended to be
- used. The \e state can be:
-
- \value Off Display the pixmap when the widget is in an "off" state
- \value On Display the pixmap when the widget is in an "on" state
-*/
-
-static QBasicAtomicInt serialNumCounter = Q_BASIC_ATOMIC_INITIALIZER(1);
-
-static void qt_cleanup_icon_cache();
-typedef QCache<QString, QIcon> IconCache;
-Q_GLOBAL_STATIC_WITH_INITIALIZER(IconCache, qtIconCache, qAddPostRoutine(qt_cleanup_icon_cache))
-
-static void qt_cleanup_icon_cache()
-{
- qtIconCache()->clear();
-}
-
-QIconPrivate::QIconPrivate()
- : engine(0), ref(1),
- serialNum(serialNumCounter.fetchAndAddRelaxed(1)),
- detach_no(0),
- engine_version(2),
- v1RefCount(0)
-{
-}
-
-QPixmapIconEngine::QPixmapIconEngine()
-{
-}
-
-QPixmapIconEngine::QPixmapIconEngine(const QPixmapIconEngine &other)
- : QIconEngineV2(other), pixmaps(other.pixmaps)
-{
-}
-
-QPixmapIconEngine::~QPixmapIconEngine()
-{
-}
-
-void QPixmapIconEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state)
-{
- QSize pixmapSize = rect.size();
-#if defined(Q_WS_MAC)
- pixmapSize *= qt_mac_get_scalefactor();
-#endif
- painter->drawPixmap(rect, pixmap(pixmapSize, mode, state));
-}
-
-static inline int area(const QSize &s) { return s.width() * s.height(); }
-
-// returns the smallest of the two that is still larger than or equal to size.
-static QPixmapIconEngineEntry *bestSizeMatch( const QSize &size, QPixmapIconEngineEntry *pa, QPixmapIconEngineEntry *pb)
-{
- int s = area(size);
- if (pa->size == QSize() && pa->pixmap.isNull()) {
- pa->pixmap = QPixmap(pa->fileName);
- pa->size = pa->pixmap.size();
- }
- int a = area(pa->size);
- if (pb->size == QSize() && pb->pixmap.isNull()) {
- pb->pixmap = QPixmap(pb->fileName);
- pb->size = pb->pixmap.size();
- }
- int b = area(pb->size);
- int res = a;
- if (qMin(a,b) >= s)
- res = qMin(a,b);
- else
- res = qMax(a,b);
- if (res == a)
- return pa;
- return pb;
-}
-
-QPixmapIconEngineEntry *QPixmapIconEngine::tryMatch(const QSize &size, QIcon::Mode mode, QIcon::State state)
-{
- QPixmapIconEngineEntry *pe = 0;
- for (int i = 0; i < pixmaps.count(); ++i)
- if (pixmaps.at(i).mode == mode && pixmaps.at(i).state == state) {
- if (pe)
- pe = bestSizeMatch(size, &pixmaps[i], pe);
- else
- pe = &pixmaps[i];
- }
- return pe;
-}
-
-
-QPixmapIconEngineEntry *QPixmapIconEngine::bestMatch(const QSize &size, QIcon::Mode mode, QIcon::State state, bool sizeOnly)
-{
- QPixmapIconEngineEntry *pe = tryMatch(size, mode, state);
- while (!pe){
- QIcon::State oppositeState = (state == QIcon::On) ? QIcon::Off : QIcon::On;
- if (mode == QIcon::Disabled || mode == QIcon::Selected) {
- QIcon::Mode oppositeMode = (mode == QIcon::Disabled) ? QIcon::Selected : QIcon::Disabled;
- if ((pe = tryMatch(size, QIcon::Normal, state)))
- break;
- if ((pe = tryMatch(size, QIcon::Active, state)))
- break;
- if ((pe = tryMatch(size, mode, oppositeState)))
- break;
- if ((pe = tryMatch(size, QIcon::Normal, oppositeState)))
- break;
- if ((pe = tryMatch(size, QIcon::Active, oppositeState)))
- break;
- if ((pe = tryMatch(size, oppositeMode, state)))
- break;
- if ((pe = tryMatch(size, oppositeMode, oppositeState)))
- break;
- } else {
- QIcon::Mode oppositeMode = (mode == QIcon::Normal) ? QIcon::Active : QIcon::Normal;
- if ((pe = tryMatch(size, oppositeMode, state)))
- break;
- if ((pe = tryMatch(size, mode, oppositeState)))
- break;
- if ((pe = tryMatch(size, oppositeMode, oppositeState)))
- break;
- if ((pe = tryMatch(size, QIcon::Disabled, state)))
- break;
- if ((pe = tryMatch(size, QIcon::Selected, state)))
- break;
- if ((pe = tryMatch(size, QIcon::Disabled, oppositeState)))
- break;
- if ((pe = tryMatch(size, QIcon::Selected, oppositeState)))
- break;
- }
-
- if (!pe)
- return pe;
- }
-
- if (sizeOnly ? (pe->size.isNull() || !pe->size.isValid()) : pe->pixmap.isNull()) {
- pe->pixmap = QPixmap(pe->fileName);
- if (!pe->pixmap.isNull())
- pe->size = pe->pixmap.size();
- }
-
- return pe;
-}
-
-QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)
-{
- QPixmap pm;
- QPixmapIconEngineEntry *pe = bestMatch(size, mode, state, false);
- if (pe)
- pm = pe->pixmap;
-
- if (pm.isNull()) {
- int idx = pixmaps.count();
- while (--idx >= 0) {
- if (pe == &pixmaps[idx]) {
- pixmaps.remove(idx);
- break;
- }
- }
- if (pixmaps.isEmpty())
- return pm;
- else
- return pixmap(size, mode, state);
- }
-
- QSize actualSize = pm.size();
- if (!actualSize.isNull() && (actualSize.width() > size.width() || actualSize.height() > size.height()))
- actualSize.scale(size, Qt::KeepAspectRatio);
-
- QString key = QLatin1Literal("qt_")
- % HexString<quint64>(pm.cacheKey())
- % HexString<uint>(pe->mode)
- % HexString<quint64>(QApplication::palette().cacheKey())
- % HexString<uint>(actualSize.width())
- % HexString<uint>(actualSize.height());
-
- if (mode == QIcon::Active) {
- if (QPixmapCache::find(key % HexString<uint>(mode), pm))
- return pm; // horray
- if (QPixmapCache::find(key % HexString<uint>(QIcon::Normal), pm)) {
- QStyleOption opt(0);
- opt.palette = QApplication::palette();
- QPixmap active = QApplication::style()->generatedIconPixmap(QIcon::Active, pm, &opt);
- if (pm.cacheKey() == active.cacheKey())
- return pm;
- }
- }
-
- if (!QPixmapCache::find(key % HexString<uint>(mode), pm)) {
- if (pm.size() != actualSize)
- pm = pm.scaled(actualSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
- if (pe->mode != mode && mode != QIcon::Normal) {
- QStyleOption opt(0);
- opt.palette = QApplication::palette();
- QPixmap generated = QApplication::style()->generatedIconPixmap(mode, pm, &opt);
- if (!generated.isNull())
- pm = generated;
- }
- QPixmapCache::insert(key % HexString<uint>(mode), pm);
- }
- return pm;
-}
-
-QSize QPixmapIconEngine::actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state)
-{
- QSize actualSize;
- if (QPixmapIconEngineEntry *pe = bestMatch(size, mode, state, true))
- actualSize = pe->size;
-
- if (actualSize.isNull())
- return actualSize;
-
- if (!actualSize.isNull() && (actualSize.width() > size.width() || actualSize.height() > size.height()))
- actualSize.scale(size, Qt::KeepAspectRatio);
- return actualSize;
-}
-
-void QPixmapIconEngine::addPixmap(const QPixmap &pixmap, QIcon::Mode mode, QIcon::State state)
-{
- if (!pixmap.isNull()) {
- QPixmapIconEngineEntry *pe = tryMatch(pixmap.size(), mode, state);
- if(pe && pe->size == pixmap.size()) {
- pe->pixmap = pixmap;
- pe->fileName.clear();
- } else {
- pixmaps += QPixmapIconEngineEntry(pixmap, mode, state);
- }
- }
-}
-
-void QPixmapIconEngine::addFile(const QString &fileName, const QSize &_size, QIcon::Mode mode, QIcon::State state)
-{
- if (!fileName.isEmpty()) {
- QSize size = _size;
- QPixmap pixmap;
-
- QString abs = fileName;
- if (fileName.at(0) != QLatin1Char(':'))
- abs = QFileInfo(fileName).absoluteFilePath();
-
- for (int i = 0; i < pixmaps.count(); ++i) {
- if (pixmaps.at(i).mode == mode && pixmaps.at(i).state == state) {
- QPixmapIconEngineEntry *pe = &pixmaps[i];
- if(size == QSize()) {
- pixmap = QPixmap(abs);
- size = pixmap.size();
- }
- if (pe->size == QSize() && pe->pixmap.isNull()) {
- pe->pixmap = QPixmap(pe->fileName);
- pe->size = pe->pixmap.size();
- }
- if(pe->size == size) {
- pe->pixmap = pixmap;
- pe->fileName = abs;
- return;
- }
- }
- }
- QPixmapIconEngineEntry e(abs, size, mode, state);
- e.pixmap = pixmap;
- pixmaps += e;
- }
-}
-
-QString QPixmapIconEngine::key() const
-{
- return QLatin1String("QPixmapIconEngine");
-}
-
-QIconEngineV2 *QPixmapIconEngine::clone() const
-{
- return new QPixmapIconEngine(*this);
-}
-
-bool QPixmapIconEngine::read(QDataStream &in)
-{
- int num_entries;
- QPixmap pm;
- QString fileName;
- QSize sz;
- uint mode;
- uint state;
-
- in >> num_entries;
- for (int i=0; i < num_entries; ++i) {
- if (in.atEnd()) {
- pixmaps.clear();
- return false;
- }
- in >> pm;
- in >> fileName;
- in >> sz;
- in >> mode;
- in >> state;
- if (pm.isNull()) {
- addFile(fileName, sz, QIcon::Mode(mode), QIcon::State(state));
- } else {
- QPixmapIconEngineEntry pe(fileName, sz, QIcon::Mode(mode), QIcon::State(state));
- pe.pixmap = pm;
- pixmaps += pe;
- }
- }
- return true;
-}
-
-bool QPixmapIconEngine::write(QDataStream &out) const
-{
- int num_entries = pixmaps.size();
- out << num_entries;
- for (int i=0; i < num_entries; ++i) {
- if (pixmaps.at(i).pixmap.isNull())
- out << QPixmap(pixmaps.at(i).fileName);
- else
- out << pixmaps.at(i).pixmap;
- out << pixmaps.at(i).fileName;
- out << pixmaps.at(i).size;
- out << (uint) pixmaps.at(i).mode;
- out << (uint) pixmaps.at(i).state;
- }
- return true;
-}
-
-void QPixmapIconEngine::virtual_hook(int id, void *data)
-{
- switch (id) {
- case QIconEngineV2::AvailableSizesHook: {
- QIconEngineV2::AvailableSizesArgument &arg =
- *reinterpret_cast<QIconEngineV2::AvailableSizesArgument*>(data);
- arg.sizes.clear();
- for (int i = 0; i < pixmaps.size(); ++i) {
- QPixmapIconEngineEntry &pe = pixmaps[i];
- if (pe.size == QSize() && pe.pixmap.isNull()) {
- pe.pixmap = QPixmap(pe.fileName);
- pe.size = pe.pixmap.size();
- }
- if (pe.mode == arg.mode && pe.state == arg.state && !pe.size.isEmpty())
- arg.sizes.push_back(pe.size);
- }
- break;
- }
- default:
- QIconEngineV2::virtual_hook(id, data);
- }
-}
-
-#ifndef QT_NO_LIBRARY
-Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
- (QIconEngineFactoryInterface_iid, QLatin1String("/iconengines"), Qt::CaseInsensitive))
-Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loaderV2,
- (QIconEngineFactoryInterfaceV2_iid, QLatin1String("/iconengines"), Qt::CaseInsensitive))
-#endif
-
-
-
-/*!
- \class QIcon
-
- \brief The QIcon class provides scalable icons in different modes
- and states.
-
- \ingroup painting
- \ingroup shared
-
-
- A QIcon can generate smaller, larger, active, and disabled pixmaps
- from the set of pixmaps it is given. Such pixmaps are used by Qt
- widgets to show an icon representing a particular action.
-
- The simplest use of QIcon is to create one from a QPixmap file or
- resource, and then use it, allowing Qt to work out all the required
- icon styles and sizes. For example:
-
- \snippet doc/src/snippets/code/src_gui_image_qicon.cpp 0
-
- To undo a QIcon, simply set a null icon in its place:
-
- \snippet doc/src/snippets/code/src_gui_image_qicon.cpp 1
-
- Use the QImageReader::supportedImageFormats() and
- QImageWriter::supportedImageFormats() functions to retrieve a
- complete list of the supported file formats.
-
- When you retrieve a pixmap using pixmap(QSize, Mode, State), and no
- pixmap for this given size, mode and state has been added with
- addFile() or addPixmap(), then QIcon will generate one on the
- fly. This pixmap generation happens in a QIconEngineV2. The default
- engine scales pixmaps down if required, but never up, and it uses
- the current style to calculate a disabled appearance. By using
- custom icon engines, you can customize every aspect of generated
- icons. With QIconEnginePluginV2 it is possible to register different
- icon engines for different file suffixes, making it possible for
- third parties to provide additional icon engines to those included
- with Qt.
-
- \note Since Qt 4.2, an icon engine that supports SVG is included.
-
- \section1 Making Classes that Use QIcon
-
- If you write your own widgets that have an option to set a small
- pixmap, consider allowing a QIcon to be set for that pixmap. The
- Qt class QToolButton is an example of such a widget.
-
- Provide a method to set a QIcon, and when you draw the icon, choose
- whichever pixmap is appropriate for the current state of your widget.
- For example:
- \snippet doc/src/snippets/code/src_gui_image_qicon.cpp 2
-
- You might also make use of the \c Active mode, perhaps making your
- widget \c Active when the mouse is over the widget (see \l
- QWidget::enterEvent()), while the mouse is pressed pending the
- release that will activate the function, or when it is the currently
- selected item. If the widget can be toggled, the "On" mode might be
- used to draw a different icon.
-
- \img icon.png QIcon
-
- \sa {fowler}{GUI Design Handbook: Iconic Label}, {Icons Example}
-*/
-
-
-/*!
- Constructs a null icon.
-*/
-QIcon::QIcon()
- : d(0)
-{
-}
-
-/*!
- Constructs an icon from a \a pixmap.
- */
-QIcon::QIcon(const QPixmap &pixmap)
- :d(0)
-{
- addPixmap(pixmap);
-}
-
-/*!
- Constructs a copy of \a other. This is very fast.
-*/
-QIcon::QIcon(const QIcon &other)
- :d(other.d)
-{
- if (d)
- d->ref.ref();
-}
-
-/*!
- Constructs an icon from the file with the given \a fileName. The
- file will be loaded on demand.
-
- If \a fileName contains a relative path (e.g. the filename only)
- the relevant file must be found relative to the runtime working
- directory.
-
- The file name can be either refer to an actual file on disk or to
- one of the application's embedded resources. See the
- \l{resources.html}{Resource System} overview for details on how to
- embed images and other resource files in the application's
- executable.
-
- Use the QImageReader::supportedImageFormats() and
- QImageWriter::supportedImageFormats() functions to retrieve a
- complete list of the supported file formats.
-*/
-QIcon::QIcon(const QString &fileName)
- : d(0)
-{
- addFile(fileName);
-}
-
-
-/*!
- Creates an icon with a specific icon \a engine. The icon takes
- ownership of the engine.
-*/
-QIcon::QIcon(QIconEngine *engine)
- :d(new QIconPrivate)
-{
- d->engine_version = 1;
- d->engine = engine;
- d->v1RefCount = new QAtomicInt(1);
-}
-
-/*!
- Creates an icon with a specific icon \a engine. The icon takes
- ownership of the engine.
-*/
-QIcon::QIcon(QIconEngineV2 *engine)
- :d(new QIconPrivate)
-{
- d->engine_version = 2;
- d->engine = engine;
-}
-
-/*!
- Destroys the icon.
-*/
-QIcon::~QIcon()
-{
- if (d && !d->ref.deref())
- delete d;
-}
-
-/*!
- Assigns the \a other icon to this icon and returns a reference to
- this icon.
-*/
-QIcon &QIcon::operator=(const QIcon &other)
-{
- if (other.d)
- other.d->ref.ref();
- if (d && !d->ref.deref())
- delete d;
- d = other.d;
- return *this;
-}
-
-/*!
- \fn void QIcon::swap(QIcon &other)
- \since 4.8
-
- Swaps icon \a other with this icon. This operation is very
- fast and never fails.
-*/
-
-/*!
- Returns the icon as a QVariant.
-*/
-QIcon::operator QVariant() const
-{
- return QVariant(QVariant::Icon, this);
-}
-
-/*! \obsolete
-
- Returns a number that identifies the contents of this
- QIcon object. Distinct QIcon objects can have
- the same serial number if they refer to the same contents
- (but they don't have to). Also, the serial number of
- a QIcon object may change during its lifetime.
-
- Use cacheKey() instead.
-
- A null icon always has a serial number of 0.
-
- Serial numbers are mostly useful in conjunction with caching.
-
- \sa QPixmap::serialNumber()
-*/
-
-int QIcon::serialNumber() const
-{
- return d ? d->serialNum : 0;
-}
-
-/*!
- Returns a number that identifies the contents of this QIcon
- object. Distinct QIcon objects can have the same key if
- they refer to the same contents.
- \since 4.3
-
- The cacheKey() will change when the icon is altered via
- addPixmap() or addFile().
-
- Cache keys are mostly useful in conjunction with caching.
-
- \sa QPixmap::cacheKey()
-*/
-qint64 QIcon::cacheKey() const
-{
- if (!d)
- return 0;
- return (((qint64) d->serialNum) << 32) | ((qint64) (d->detach_no));
-}
-
-/*!
- Returns a pixmap with the requested \a size, \a mode, and \a
- state, generating one if necessary. The pixmap might be smaller than
- requested, but never larger.
-
- \sa actualSize(), paint()
-*/
-QPixmap QIcon::pixmap(const QSize &size, Mode mode, State state) const
-{
- if (!d)
- return QPixmap();
- return d->engine->pixmap(size, mode, state);
-}
-
-/*!
- \fn QPixmap QIcon::pixmap(int w, int h, Mode mode = Normal, State state = Off) const
-
- \overload
-
- Returns a pixmap of size QSize(\a w, \a h). The pixmap might be smaller than
- requested, but never larger.
-*/
-
-/*!
- \fn QPixmap QIcon::pixmap(int extent, Mode mode = Normal, State state = Off) const
-
- \overload
-
- Returns a pixmap of size QSize(\a extent, \a extent). The pixmap might be smaller
- than requested, but never larger.
-*/
-
-/*! Returns the actual size of the icon for the requested \a size, \a
- mode, and \a state. The result might be smaller than requested, but
- never larger.
-
- \sa pixmap(), paint()
-*/
-QSize QIcon::actualSize(const QSize &size, Mode mode, State state) const
-{
- if (!d)
- return QSize();
- return d->engine->actualSize(size, mode, state);
-}
-
-
-/*!
- Uses the \a painter to paint the icon with specified \a alignment,
- required \a mode, and \a state into the rectangle \a rect.
-
- \sa actualSize(), pixmap()
-*/
-void QIcon::paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment, Mode mode, State state) const
-{
- if (!d || !painter)
- return;
- QRect alignedRect = QStyle::alignedRect(painter->layoutDirection(), alignment, d->engine->actualSize(rect.size(), mode, state), rect);
- d->engine->paint(painter, alignedRect, mode, state);
-}
-
-/*!
- \fn void QIcon::paint(QPainter *painter, int x, int y, int w, int h, Qt::Alignment alignment,
- Mode mode, State state) const
-
- \overload
-
- Paints the icon into the rectangle QRect(\a x, \a y, \a w, \a h).
-*/
-
-/*!
- Returns true if the icon is empty; otherwise returns false.
-
- An icon is empty if it has neither a pixmap nor a filename.
-
- Note: Even a non-null icon might not be able to create valid
- pixmaps, eg. if the file does not exist or cannot be read.
-*/
-bool QIcon::isNull() const
-{
- return !d;
-}
-
-/*!\internal
- */
-bool QIcon::isDetached() const
-{
- return !d || d->ref == 1;
-}
-
-/*! \internal
- */
-void QIcon::detach()
-{
- if (d) {
- if (d->ref != 1) {
- QIconPrivate *x = new QIconPrivate;
- if (d->engine_version > 1) {
- QIconEngineV2 *engine = static_cast<QIconEngineV2 *>(d->engine);
- x->engine = engine->clone();
- } else {
- x->engine = d->engine;
- x->v1RefCount = d->v1RefCount;
- x->v1RefCount->ref();
- }
- x->engine_version = d->engine_version;
- if (!d->ref.deref())
- delete d;
- d = x;
- }
- ++d->detach_no;
- }
-}
-
-/*!
- Adds \a pixmap to the icon, as a specialization for \a mode and
- \a state.
-
- Custom icon engines are free to ignore additionally added
- pixmaps.
-
- \sa addFile()
-*/
-void QIcon::addPixmap(const QPixmap &pixmap, Mode mode, State state)
-{
- if (pixmap.isNull())
- return;
- if (!d) {
- d = new QIconPrivate;
- d->engine = new QPixmapIconEngine;
- } else {
- detach();
- }
- d->engine->addPixmap(pixmap, mode, state);
-}
-
-
-/*! Adds an image from the file with the given \a fileName to the
- icon, as a specialization for \a size, \a mode and \a state. The
- file will be loaded on demand. Note: custom icon engines are free
- to ignore additionally added pixmaps.
-
- If \a fileName contains a relative path (e.g. the filename only)
- the relevant file must be found relative to the runtime working
- directory.
-
- The file name can be either refer to an actual file on disk or to
- one of the application's embedded resources. See the
- \l{resources.html}{Resource System} overview for details on how to
- embed images and other resource files in the application's
- executable.
-
- Use the QImageReader::supportedImageFormats() and
- QImageWriter::supportedImageFormats() functions to retrieve a
- complete list of the supported file formats.
-
- Note: When you add a non-empty filename to a QIcon, the icon becomes
- non-null, even if the file doesn't exist or points to a corrupt file.
-
- \sa addPixmap()
- */
-void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State state)
-{
- if (fileName.isEmpty())
- return;
- if (!d) {
-#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
- QFileInfo info(fileName);
- QString suffix = info.suffix();
- if (!suffix.isEmpty()) {
- // first try version 2 engines..
- if (QIconEngineFactoryInterfaceV2 *factory = qobject_cast<QIconEngineFactoryInterfaceV2*>(loaderV2()->instance(suffix))) {
- if (QIconEngine *engine = factory->create(fileName)) {
- d = new QIconPrivate;
- d->engine = engine;
- }
- }
- // ..then fall back and try to load version 1 engines
- if (!d) {
- if (QIconEngineFactoryInterface *factory = qobject_cast<QIconEngineFactoryInterface*>(loader()->instance(suffix))) {
- if (QIconEngine *engine = factory->create(fileName)) {
- d = new QIconPrivate;
- d->engine = engine;
- d->engine_version = 1;
- d->v1RefCount = new QAtomicInt(1);
- }
- }
- }
- }
-#endif
- // ...then fall back to the default engine
- if (!d) {
- d = new QIconPrivate;
- d->engine = new QPixmapIconEngine;
- }
- } else {
- detach();
- }
- d->engine->addFile(fileName, size, mode, state);
-}
-
-/*!
- \since 4.5
-
- Returns a list of available icon sizes for the specified \a mode and
- \a state.
-*/
-QList<QSize> QIcon::availableSizes(Mode mode, State state) const
-{
- if (!d || !d->engine || d->engine_version < 2)
- return QList<QSize>();
- QIconEngineV2 *engine = static_cast<QIconEngineV2*>(d->engine);
- return engine->availableSizes(mode, state);
-}
-
-/*!
- \since 4.7
-
- Returns the name used to create the icon, if available.
-
- Depending on the way the icon was created, it may have an associated
- name. This is the case for icons created with fromTheme() or icons
- using a QIconEngine which supports the QIconEngineV2::IconNameHook.
-
- \sa fromTheme(), QIconEngine
-*/
-QString QIcon::name() const
-{
- if (!d || !d->engine || d->engine_version < 2)
- return QString();
- QIconEngineV2 *engine = static_cast<QIconEngineV2*>(d->engine);
- return engine->iconName();
-}
-
-/*!
- \since 4.6
-
- Sets the search paths for icon themes to \a paths.
- \sa themeSearchPaths(), fromTheme(), setThemeName()
-*/
-void QIcon::setThemeSearchPaths(const QStringList &paths)
-{
- QIconLoader::instance()->setThemeSearchPath(paths);
-}
-
-/*!
- \since 4.6
-
- Returns the search paths for icon themes.
-
- The default value will depend on the platform:
-
- On X11, the search path will use the XDG_DATA_DIRS environment
- variable if available.
-
- By default all platforms will have the resource directory
- \c{:\icons} as a fallback. You can use "rcc -project" to generate a
- resource file from your icon theme.
-
- \sa setThemeSearchPaths(), fromTheme(), setThemeName()
-*/
-QStringList QIcon::themeSearchPaths()
-{
- return QIconLoader::instance()->themeSearchPaths();
-}
-
-/*!
- \since 4.6
-
- Sets the current icon theme to \a name.
-
- The \a name should correspond to a directory name in the
- themeSearchPath() containing an index.theme
- file describing it's contents.
-
- \sa themeSearchPaths(), themeName()
-*/
-void QIcon::setThemeName(const QString &name)
-{
- QIconLoader::instance()->setThemeName(name);
-}
-
-/*!
- \since 4.6
-
- Returns the name of the current icon theme.
-
- On X11, the current icon theme depends on your desktop
- settings. On other platforms it is not set by default.
-
- \sa setThemeName(), themeSearchPaths(), fromTheme(),
- hasThemeIcon()
-*/
-QString QIcon::themeName()
-{
- return QIconLoader::instance()->themeName();
-}
-
-/*!
- \since 4.6
-
- Returns the QIcon corresponding to \a name in the current
- icon theme. If no such icon is found in the current theme
- \a fallback is returned instead.
-
- The latest version of the freedesktop icon specification and naming
- specification can be obtained here:
-
- \list
- \o \l{http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html}
- \o \l{http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html}
- \endlist
-
- To fetch an icon from the current icon theme:
-
- \snippet doc/src/snippets/code/src_gui_image_qicon.cpp 3
-
- Or if you want to provide a guaranteed fallback for platforms that
- do not support theme icons, you can use the second argument:
-
- \snippet doc/src/snippets/code/src_gui_image_qicon.cpp 4
-
- \note By default, only X11 will support themed icons. In order to
- use themed icons on Mac and Windows, you will have to bundle a
- compliant theme in one of your themeSearchPaths() and set the
- appropriate themeName().
-
- \sa themeName(), setThemeName(), themeSearchPaths()
-*/
-QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback)
-{
- QIcon icon;
-
- if (qtIconCache()->contains(name)) {
- icon = *qtIconCache()->object(name);
- } else {
- QIcon *cachedIcon = new QIcon(new QIconLoaderEngine(name));
- qtIconCache()->insert(name, cachedIcon);
- icon = *cachedIcon;
- }
-
- // Note the qapp check is to allow lazy loading of static icons
- // Supporting fallbacks will not work for this case.
- if (qApp && icon.availableSizes().isEmpty())
- return fallback;
-
- return icon;
-}
-
-/*!
- \since 4.6
-
- Returns true if there is an icon available for \a name in the
- current icon theme, otherwise returns false.
-
- \sa themeSearchPaths(), fromTheme(), setThemeName()
-*/
-bool QIcon::hasThemeIcon(const QString &name)
-{
- QIcon icon = fromTheme(name);
-
- return !icon.isNull();
-}
-
-
-/*****************************************************************************
- QIcon stream functions
- *****************************************************************************/
-#if !defined(QT_NO_DATASTREAM)
-/*!
- \fn QDataStream &operator<<(QDataStream &stream, const QIcon &icon)
- \relates QIcon
- \since 4.2
-
- Writes the given \a icon to the given \a stream as a PNG
- image. If the icon contains more than one image, all images will
- be written to the stream. Note that writing the stream to a file
- will not produce a valid image file.
-*/
-
-QDataStream &operator<<(QDataStream &s, const QIcon &icon)
-{
- if (s.version() >= QDataStream::Qt_4_3) {
- if (icon.isNull()) {
- s << QString();
- } else {
- if (icon.d->engine_version > 1) {
- QIconEngineV2 *engine = static_cast<QIconEngineV2 *>(icon.d->engine);
- s << engine->key();
- engine->write(s);
- } else {
- // not really supported
- qWarning("QIcon: Cannot stream QIconEngine. Use QIconEngineV2 instead.");
- }
- }
- } else if (s.version() == QDataStream::Qt_4_2) {
- if (icon.isNull()) {
- s << 0;
- } else {
- QPixmapIconEngine *engine = static_cast<QPixmapIconEngine *>(icon.d->engine);
- int num_entries = engine->pixmaps.size();
- s << num_entries;
- for (int i=0; i < num_entries; ++i) {
- s << engine->pixmaps.at(i).pixmap;
- s << engine->pixmaps.at(i).fileName;
- s << engine->pixmaps.at(i).size;
- s << (uint) engine->pixmaps.at(i).mode;
- s << (uint) engine->pixmaps.at(i).state;
- }
- }
- } else {
- s << QPixmap(icon.pixmap(22,22));
- }
- return s;
-}
-
-/*!
- \fn QDataStream &operator>>(QDataStream &stream, QIcon &icon)
- \relates QIcon
- \since 4.2
-
- Reads an image, or a set of images, from the given \a stream into
- the given \a icon.
-*/
-
-QDataStream &operator>>(QDataStream &s, QIcon &icon)
-{
- if (s.version() >= QDataStream::Qt_4_3) {
- icon = QIcon();
- QString key;
- s >> key;
- if (key == QLatin1String("QPixmapIconEngine")) {
- icon.d = new QIconPrivate;
- QIconEngineV2 *engine = new QPixmapIconEngine;
- icon.d->engine = engine;
- engine->read(s);
- } else if (key == QLatin1String("QIconLoaderEngine")) {
- icon.d = new QIconPrivate;
- QIconEngineV2 *engine = new QIconLoaderEngine();
- icon.d->engine = engine;
- engine->read(s);
-#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
- } else if (QIconEngineFactoryInterfaceV2 *factory = qobject_cast<QIconEngineFactoryInterfaceV2*>(loaderV2()->instance(key))) {
- if (QIconEngineV2 *engine= factory->create()) {
- icon.d = new QIconPrivate;
- icon.d->engine = engine;
- engine->read(s);
- }
-#endif
- }
- } else if (s.version() == QDataStream::Qt_4_2) {
- icon = QIcon();
- int num_entries;
- QPixmap pm;
- QString fileName;
- QSize sz;
- uint mode;
- uint state;
-
- s >> num_entries;
- for (int i=0; i < num_entries; ++i) {
- s >> pm;
- s >> fileName;
- s >> sz;
- s >> mode;
- s >> state;
- if (pm.isNull())
- icon.addFile(fileName, sz, QIcon::Mode(mode), QIcon::State(state));
- else
- icon.addPixmap(pm, QIcon::Mode(mode), QIcon::State(state));
- }
- } else {
- QPixmap pm;
- s >> pm;
- icon.addPixmap(pm);
- }
- return s;
-}
-
-#endif //QT_NO_DATASTREAM
-
-
-#ifdef QT3_SUPPORT
-
-static int widths[2] = { 22, 32 };
-static int heights[2] = { 22, 32 };
-
-static QSize pixmapSizeHelper(QIcon::Size which)
-{
- int i = 0;
- if (which == QIcon::Large)
- i = 1;
- return QSize(widths[i], heights[i]);
-}
-
-/*!
- \enum QIcon::Size
- \compat
-
- \value Small Use QStyle::pixelMetric(QStyle::PM_SmallIconSize) instead.
- \value Large Use QStyle::pixelMetric(QStyle::PM_LargeIconSize) instead.
- \value Automatic N/A.
-*/
-
-/*!
- Use pixmap(QSize(...), \a mode, \a state), where the first
- argument is an appropriate QSize instead of a \l Size value.
-
- \sa pixmapSize()
-*/
-QPixmap QIcon::pixmap(Size size, Mode mode, State state) const
-{ return pixmap(pixmapSizeHelper(size), mode, state); }
-
-/*!
- Use pixmap(QSize(...), mode, \a state), where the first argument
- is an appropriate QSize instead of a \l Size value, and the
- second argument is QIcon::Normal or QIcon::Disabled, depending on
- the value of \a enabled.
-
- \sa pixmapSize()
-*/
-QPixmap QIcon::pixmap(Size size, bool enabled, State state) const
-{ return pixmap(pixmapSizeHelper(size), enabled ? Normal : Disabled, state); }
-
-/*!
- Use one of the other pixmap() overloads.
-*/
-QPixmap QIcon::pixmap() const
-{ return pixmap(pixmapSizeHelper(Small), Normal, Off); }
-
-/*!
- The pixmap() function now takes a QSize instead of a QIcon::Size,
- so there is no need for this function in new code.
-*/
-void QIcon::setPixmapSize(Size which, const QSize &size)
-{
- int i = 0;
- if (which == Large)
- i = 1;
- widths[i] = size.width();
- heights[i] = size.height();
-}
-
-/*!
- Use QStyle::pixelMetric() with QStyle::PM_SmallIconSize or
- QStyle::PM_LargeIconSize as the first argument, depending on \a
- which.
-*/
-QSize QIcon::pixmapSize(Size which)
-{
- return pixmapSizeHelper(which);
-}
-
-/*!
- \fn void QIcon::reset(const QPixmap &pixmap, Size size)
-
- Use the constructor that takes a QPixmap and operator=().
-*/
-
-/*!
- \fn void QIcon::setPixmap(const QPixmap &pixmap, Size size, Mode mode, State state)
-
- Use addPixmap(\a pixmap, \a mode, \a state) instead. The \a size
- parameter is ignored.
-*/
-
-/*!
- \fn void QIcon::setPixmap(const QString &fileName, Size size, Mode mode, State state)
-
- Use addFile(\a fileName, \a mode, \a state) instead. The \a size
- parameter is ignored.
-*/
-
-#endif // QT3_SUPPORT
-
-/*!
- \fn DataPtr &QIcon::data_ptr()
- \internal
-*/
-
-/*!
- \typedef QIcon::DataPtr
- \internal
-*/
-
-QT_END_NAMESPACE
-#endif //QT_NO_ICON
diff --git a/src/gui/image/qicon.h b/src/gui/image/qicon.h
deleted file mode 100644
index 170559182b..0000000000
--- a/src/gui/image/qicon.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QICON_H
-#define QICON_H
-
-#include <QtCore/qglobal.h>
-#include <QtCore/qsize.h>
-#include <QtCore/qlist.h>
-#include <QtGui/qpixmap.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QIconPrivate;
-class QIconEngine;
-class QIconEngineV2;
-
-class Q_GUI_EXPORT QIcon
-{
-public:
- enum Mode { Normal, Disabled, Active, Selected };
- enum State { On, Off };
-
- QIcon();
- QIcon(const QPixmap &pixmap);
- QIcon(const QIcon &other);
- explicit QIcon(const QString &fileName); // file or resource name
- explicit QIcon(QIconEngine *engine);
- explicit QIcon(QIconEngineV2 *engine);
- ~QIcon();
- QIcon &operator=(const QIcon &other);
-#ifdef Q_COMPILER_RVALUE_REFS
- inline QIcon &operator=(QIcon &&other)
- { qSwap(d, other.d); return *this; }
-#endif
- inline void swap(QIcon &other) { qSwap(d, other.d); }
-
- operator QVariant() const;
-
- QPixmap pixmap(const QSize &size, Mode mode = Normal, State state = Off) const;
- inline QPixmap pixmap(int w, int h, Mode mode = Normal, State state = Off) const
- { return pixmap(QSize(w, h), mode, state); }
- inline QPixmap pixmap(int extent, Mode mode = Normal, State state = Off) const
- { return pixmap(QSize(extent, extent), mode, state); }
-
- QSize actualSize(const QSize &size, Mode mode = Normal, State state = Off) const;
-
- QString name() const;
-
- void paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment = Qt::AlignCenter, Mode mode = Normal, State state = Off) const;
- inline void paint(QPainter *painter, int x, int y, int w, int h, Qt::Alignment alignment = Qt::AlignCenter, Mode mode = Normal, State state = Off) const
- { paint(painter, QRect(x, y, w, h), alignment, mode, state); }
-
- bool isNull() const;
- bool isDetached() const;
- void detach();
-
- int serialNumber() const;
- qint64 cacheKey() const;
-
- void addPixmap(const QPixmap &pixmap, Mode mode = Normal, State state = Off);
- void addFile(const QString &fileName, const QSize &size = QSize(), Mode mode = Normal, State state = Off);
-
- QList<QSize> availableSizes(Mode mode = Normal, State state = Off) const;
-
- static QIcon fromTheme(const QString &name, const QIcon &fallback = QIcon());
- static bool hasThemeIcon(const QString &name);
-
- static QStringList themeSearchPaths();
- static void setThemeSearchPaths(const QStringList &searchpath);
-
- static QString themeName();
- static void setThemeName(const QString &path);
-
-
-#ifdef QT3_SUPPORT
- enum Size { Small, Large, Automatic = Small };
- static QT3_SUPPORT void setPixmapSize(Size which, const QSize &size);
- static QT3_SUPPORT QSize pixmapSize(Size which);
- inline QT3_SUPPORT void reset(const QPixmap &pixmap, Size /*size*/) { *this = QIcon(pixmap); }
- inline QT3_SUPPORT void setPixmap(const QPixmap &pixmap, Size, Mode mode = Normal, State state = Off)
- { addPixmap(pixmap, mode, state); }
- inline QT3_SUPPORT void setPixmap(const QString &fileName, Size, Mode mode = Normal, State state = Off)
- { addPixmap(QPixmap(fileName), mode, state); }
- QT3_SUPPORT QPixmap pixmap(Size size, Mode mode, State state = Off) const;
- QT3_SUPPORT QPixmap pixmap(Size size, bool enabled, State state = Off) const;
- QT3_SUPPORT QPixmap pixmap() const;
-#endif
-
- Q_DUMMY_COMPARISON_OPERATOR(QIcon)
-
-private:
- QIconPrivate *d;
-#if !defined(QT_NO_DATASTREAM)
- friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QIcon &);
- friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QIcon &);
-#endif
-
-public:
- typedef QIconPrivate * DataPtr;
- inline DataPtr &data_ptr() { return d; }
-};
-
-Q_DECLARE_SHARED(QIcon)
-Q_DECLARE_TYPEINFO(QIcon, Q_MOVABLE_TYPE);
-
-#if !defined(QT_NO_DATASTREAM)
-Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QIcon &);
-Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QIcon &);
-#endif
-
-#ifdef QT3_SUPPORT
-typedef QIcon QIconSet;
-#endif
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QICON_H
diff --git a/src/gui/image/qicon_p.h b/src/gui/image/qicon_p.h
deleted file mode 100644
index 0bf7e65cc1..0000000000
--- a/src/gui/image/qicon_p.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QICON_P_H
-#define QICON_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qglobal.h>
-#include <QtCore/qsize.h>
-#include <QtCore/qlist.h>
-#include <QtGui/qpixmap.h>
-#include <QtGui/qicon.h>
-#include <QtGui/qiconengine.h>
-
-#ifndef QT_NO_ICON
-QT_BEGIN_NAMESPACE
-
-class QIconPrivate
-{
-public:
- QIconPrivate();
-
- ~QIconPrivate() {
- if (engine_version == 1) {
- if (!v1RefCount->deref()) {
- delete engine;
- delete v1RefCount;
- }
- } else if (engine_version == 2) {
- delete engine;
- }
- }
-
- QIconEngine *engine;
-
- QAtomicInt ref;
- int serialNum;
- int detach_no;
- int engine_version;
-
- QAtomicInt *v1RefCount;
-};
-
-
-struct QPixmapIconEngineEntry
-{
- QPixmapIconEngineEntry():mode(QIcon::Normal), state(QIcon::Off){}
- QPixmapIconEngineEntry(const QPixmap &pm, QIcon::Mode m = QIcon::Normal, QIcon::State s = QIcon::Off)
- :pixmap(pm), size(pm.size()), mode(m), state(s){}
- QPixmapIconEngineEntry(const QString &file, const QSize &sz = QSize(), QIcon::Mode m = QIcon::Normal, QIcon::State s = QIcon::Off)
- :fileName(file), size(sz), mode(m), state(s){}
- QPixmap pixmap;
- QString fileName;
- QSize size;
- QIcon::Mode mode;
- QIcon::State state;
- bool isNull() const {return (fileName.isEmpty() && pixmap.isNull()); }
-};
-
-
-
-class QPixmapIconEngine : public QIconEngineV2 {
-public:
- QPixmapIconEngine();
- QPixmapIconEngine(const QPixmapIconEngine &);
- ~QPixmapIconEngine();
- void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state);
- QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
- QPixmapIconEngineEntry *bestMatch(const QSize &size, QIcon::Mode mode, QIcon::State state, bool sizeOnly);
- QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state);
- void addPixmap(const QPixmap &pixmap, QIcon::Mode mode, QIcon::State state);
- void addFile(const QString &fileName, const QSize &size, QIcon::Mode mode, QIcon::State state);
-
- // v2 functions
- QString key() const;
- QIconEngineV2 *clone() const;
- bool read(QDataStream &in);
- bool write(QDataStream &out) const;
- void virtual_hook(int id, void *data);
-
-private:
- QPixmapIconEngineEntry *tryMatch(const QSize &size, QIcon::Mode mode, QIcon::State state);
- QVector<QPixmapIconEngineEntry> pixmaps;
-
- friend QDataStream &operator<<(QDataStream &s, const QIcon &icon);
- friend class QIconThemeEngine;
-};
-
-QT_END_NAMESPACE
-#endif //QT_NO_ICON
-#endif // QICON_P_H
diff --git a/src/gui/image/qiconengine.h b/src/gui/image/qiconengine.h
deleted file mode 100644
index 12caea8a20..0000000000
--- a/src/gui/image/qiconengine.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QICONENGINE_H
-#define QICONENGINE_H
-
-#include <QtCore/qglobal.h>
-#include <QtCore/qlist.h>
-#include <QtGui/qicon.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class Q_GUI_EXPORT QIconEngine
-{
-public:
- virtual ~QIconEngine();
- virtual void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) = 0;
- virtual QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state);
- virtual QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
-
- virtual void addPixmap(const QPixmap &pixmap, QIcon::Mode mode, QIcon::State state);
- virtual void addFile(const QString &fileName, const QSize &size, QIcon::Mode mode, QIcon::State state);
-
-#if 0
- virtual int frameCount(QIcon::Mode fromMode, QIcon::State fromState, QIcon::Mode toMode, QIcon::State toState);
- virtual void paintFrame(QPainter *painter, const QRect &rect, int frameNumber, QIcon::Mode fromMode, QIcon::State fromState, QIcon::Mode toMode, QIcon::State toState);
-#endif
-};
-
-// ### Qt 5: move the below into QIconEngine
-class Q_GUI_EXPORT QIconEngineV2 : public QIconEngine
-{
-public:
- virtual QString key() const;
- virtual QIconEngineV2 *clone() const;
- virtual bool read(QDataStream &in);
- virtual bool write(QDataStream &out) const;
- virtual void virtual_hook(int id, void *data);
-
-public:
- enum IconEngineHook { AvailableSizesHook = 1, IconNameHook };
-
- struct AvailableSizesArgument
- {
- QIcon::Mode mode;
- QIcon::State state;
- QList<QSize> sizes;
- };
-
- // ### Qt 5: make this function const and virtual.
- QList<QSize> availableSizes(QIcon::Mode mode = QIcon::Normal,
- QIcon::State state = QIcon::Off);
-
- // ### Qt 5: make this function const and virtual.
- QString iconName();
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QICONENGINE_H
diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp
deleted file mode 100644
index 0a42f0af78..0000000000
--- a/src/gui/image/qiconloader.cpp
+++ /dev/null
@@ -1,570 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QT_NO_ICON
-#include <private/qiconloader_p.h>
-
-#include <private/qapplication_p.h>
-#include <private/qicon_p.h>
-#include <private/qguiplatformplugin_p.h>
-
-#include <QtGui/QIconEnginePlugin>
-#include <QtGui/QPixmapCache>
-#include <QtGui/QIconEngine>
-#include <QtGui/QStyleOption>
-#include <QtCore/QList>
-#include <QtCore/QHash>
-#include <QtCore/QDir>
-#include <QtCore/QSettings>
-#include <QtGui/QPainter>
-
-#ifdef Q_WS_MAC
-#include <private/qt_cocoa_helpers_mac_p.h>
-#endif
-
-#ifdef Q_WS_X11
-#include <private/qt_x11_p.h>
-#endif
-
-#include <private/qstylehelper_p.h>
-
-QT_BEGIN_NAMESPACE
-
-Q_GLOBAL_STATIC(QIconLoader, iconLoaderInstance)
-
-/* Theme to use in last resort, if the theme does not have the icon, neither the parents */
-static QString fallbackTheme()
-{
-#ifdef Q_WS_X11
- if (X11->desktopEnvironment == DE_GNOME) {
- return QLatin1String("gnome");
- } else if (X11->desktopEnvironment == DE_KDE) {
- return X11->desktopVersion >= 4
- ? QString::fromLatin1("oxygen")
- : QString::fromLatin1("crystalsvg");
- } else {
- return QLatin1String("hicolor");
- }
-#endif
- return QString();
-}
-
-QIconLoader::QIconLoader() :
- m_themeKey(1), m_supportsSvg(false), m_initialized(false)
-{
-}
-
-// We lazily initialize the loader to make static icons
-// work. Though we do not officially support this.
-void QIconLoader::ensureInitialized()
-{
- if (!m_initialized) {
- m_initialized = true;
-
- Q_ASSERT(qApp);
-
- m_systemTheme = qt_guiPlatformPlugin()->systemIconThemeName();
- if (m_systemTheme.isEmpty())
- m_systemTheme = fallbackTheme();
-#ifndef QT_NO_LIBRARY
- QFactoryLoader iconFactoryLoader(QIconEngineFactoryInterfaceV2_iid,
- QLatin1String("/iconengines"),
- Qt::CaseInsensitive);
- if (iconFactoryLoader.keys().contains(QLatin1String("svg")))
- m_supportsSvg = true;
-#endif //QT_NO_LIBRARY
- }
-}
-
-QIconLoader *QIconLoader::instance()
-{
- return iconLoaderInstance();
-}
-
-// Queries the system theme and invalidates existing
-// icons if the theme has changed.
-void QIconLoader::updateSystemTheme()
-{
- // Only change if this is not explicitly set by the user
- if (m_userTheme.isEmpty()) {
- QString theme = qt_guiPlatformPlugin()->systemIconThemeName();
- if (theme.isEmpty())
- theme = fallbackTheme();
- if (theme != m_systemTheme) {
- m_systemTheme = theme;
- invalidateKey();
- }
- }
-}
-
-void QIconLoader::setThemeName(const QString &themeName)
-{
- m_userTheme = themeName;
- invalidateKey();
-}
-
-void QIconLoader::setThemeSearchPath(const QStringList &searchPaths)
-{
- m_iconDirs = searchPaths;
- themeList.clear();
- invalidateKey();
-}
-
-QStringList QIconLoader::themeSearchPaths() const
-{
- if (m_iconDirs.isEmpty()) {
- m_iconDirs = qt_guiPlatformPlugin()->iconThemeSearchPaths();
- // Always add resource directory as search path
- m_iconDirs.append(QLatin1String(":/icons"));
- }
- return m_iconDirs;
-}
-
-QIconTheme::QIconTheme(const QString &themeName)
- : m_valid(false)
-{
- QFile themeIndex;
-
- QList <QIconDirInfo> keyList;
- QStringList iconDirs = QIcon::themeSearchPaths();
- for ( int i = 0 ; i < iconDirs.size() ; ++i) {
- QDir iconDir(iconDirs[i]);
- QString themeDir = iconDir.path() + QLatin1Char('/') + themeName;
- themeIndex.setFileName(themeDir + QLatin1String("/index.theme"));
- if (themeIndex.exists()) {
- m_contentDir = themeDir;
- m_valid = true;
- break;
- }
- }
-#ifndef QT_NO_SETTINGS
- if (themeIndex.exists()) {
- const QSettings indexReader(themeIndex.fileName(), QSettings::IniFormat);
- QStringListIterator keyIterator(indexReader.allKeys());
- while (keyIterator.hasNext()) {
-
- const QString key = keyIterator.next();
- if (key.endsWith(QLatin1String("/Size"))) {
- // Note the QSettings ini-format does not accept
- // slashes in key names, hence we have to cheat
- if (int size = indexReader.value(key).toInt()) {
- QString directoryKey = key.left(key.size() - 5);
- QIconDirInfo dirInfo(directoryKey);
- dirInfo.size = size;
- QString type = indexReader.value(directoryKey +
- QLatin1String("/Type")
- ).toString();
-
- if (type == QLatin1String("Fixed"))
- dirInfo.type = QIconDirInfo::Fixed;
- else if (type == QLatin1String("Scalable"))
- dirInfo.type = QIconDirInfo::Scalable;
- else
- dirInfo.type = QIconDirInfo::Threshold;
-
- dirInfo.threshold = indexReader.value(directoryKey +
- QLatin1String("/Threshold"),
- 2).toInt();
-
- dirInfo.minSize = indexReader.value(directoryKey +
- QLatin1String("/MinSize"),
- size).toInt();
-
- dirInfo.maxSize = indexReader.value(directoryKey +
- QLatin1String("/MaxSize"),
- size).toInt();
- m_keyList.append(dirInfo);
- }
- }
- }
-
- // Parent themes provide fallbacks for missing icons
- m_parents = indexReader.value(
- QLatin1String("Icon Theme/Inherits")).toStringList();
-
- // Ensure a default platform fallback for all themes
- if (m_parents.isEmpty())
- m_parents.append(fallbackTheme());
-
- // Ensure that all themes fall back to hicolor
- if (!m_parents.contains(QLatin1String("hicolor")))
- m_parents.append(QLatin1String("hicolor"));
- }
-#endif //QT_NO_SETTINGS
-}
-
-QThemeIconEntries QIconLoader::findIconHelper(const QString &themeName,
- const QString &iconName,
- QStringList &visited) const
-{
- QThemeIconEntries entries;
- Q_ASSERT(!themeName.isEmpty());
-
- QPixmap pixmap;
-
- // Used to protect against potential recursions
- visited << themeName;
-
- QIconTheme theme = themeList.value(themeName);
- if (!theme.isValid()) {
- theme = QIconTheme(themeName);
- if (!theme.isValid())
- theme = QIconTheme(fallbackTheme());
-
- themeList.insert(themeName, theme);
- }
-
- QString contentDir = theme.contentDir() + QLatin1Char('/');
- QList<QIconDirInfo> subDirs = theme.keyList();
-
- const QString svgext(QLatin1String(".svg"));
- const QString pngext(QLatin1String(".png"));
-
- // Add all relevant files
- for (int i = 0; i < subDirs.size() ; ++i) {
- const QIconDirInfo &dirInfo = subDirs.at(i);
- QString subdir = dirInfo.path;
- QDir currentDir(contentDir + subdir);
- if (currentDir.exists(iconName + pngext)) {
- PixmapEntry *iconEntry = new PixmapEntry;
- iconEntry->dir = dirInfo;
- iconEntry->filename = currentDir.filePath(iconName + pngext);
- // Notice we ensure that pixmap entries always come before
- // scalable to preserve search order afterwards
- entries.prepend(iconEntry);
- } else if (m_supportsSvg &&
- currentDir.exists(iconName + svgext)) {
- ScalableEntry *iconEntry = new ScalableEntry;
- iconEntry->dir = dirInfo;
- iconEntry->filename = currentDir.filePath(iconName + svgext);
- entries.append(iconEntry);
- }
- }
-
- if (entries.isEmpty()) {
- const QStringList parents = theme.parents();
- // Search recursively through inherited themes
- for (int i = 0 ; i < parents.size() ; ++i) {
-
- const QString parentTheme = parents.at(i).trimmed();
-
- if (!visited.contains(parentTheme)) // guard against recursion
- entries = findIconHelper(parentTheme, iconName, visited);
-
- if (!entries.isEmpty()) // success
- break;
- }
- }
- return entries;
-}
-
-QThemeIconEntries QIconLoader::loadIcon(const QString &name) const
-{
- if (!themeName().isEmpty()) {
- QStringList visited;
- return findIconHelper(themeName(), name, visited);
- }
-
- return QThemeIconEntries();
-}
-
-
-// -------- Icon Loader Engine -------- //
-
-
-QIconLoaderEngine::QIconLoaderEngine(const QString& iconName)
- : m_iconName(iconName), m_key(0)
-{
-}
-
-QIconLoaderEngine::~QIconLoaderEngine()
-{
- while (!m_entries.isEmpty())
- delete m_entries.takeLast();
- Q_ASSERT(m_entries.size() == 0);
-}
-
-QIconLoaderEngine::QIconLoaderEngine(const QIconLoaderEngine &other)
- : QIconEngineV2(other),
- m_iconName(other.m_iconName),
- m_key(0)
-{
-}
-
-QIconEngineV2 *QIconLoaderEngine::clone() const
-{
- return new QIconLoaderEngine(*this);
-}
-
-bool QIconLoaderEngine::read(QDataStream &in) {
- in >> m_iconName;
- return true;
-}
-
-bool QIconLoaderEngine::write(QDataStream &out) const
-{
- out << m_iconName;
- return true;
-}
-
-bool QIconLoaderEngine::hasIcon() const
-{
- return !(m_entries.isEmpty());
-}
-
-// Lazily load the icon
-void QIconLoaderEngine::ensureLoaded()
-{
-
- iconLoaderInstance()->ensureInitialized();
-
- if (!(iconLoaderInstance()->themeKey() == m_key)) {
-
- while (!m_entries.isEmpty())
- delete m_entries.takeLast();
-
- Q_ASSERT(m_entries.size() == 0);
- m_entries = iconLoaderInstance()->loadIcon(m_iconName);
- m_key = iconLoaderInstance()->themeKey();
- }
-}
-
-void QIconLoaderEngine::paint(QPainter *painter, const QRect &rect,
- QIcon::Mode mode, QIcon::State state)
-{
- QSize pixmapSize = rect.size();
-#if defined(Q_WS_MAC)
- pixmapSize *= qt_mac_get_scalefactor();
-#endif
- painter->drawPixmap(rect, pixmap(pixmapSize, mode, state));
-}
-
-/*
- * This algorithm is defined by the freedesktop spec:
- * http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html
- */
-static bool directoryMatchesSize(const QIconDirInfo &dir, int iconsize)
-{
- if (dir.type == QIconDirInfo::Fixed) {
- return dir.size == iconsize;
-
- } else if (dir.type == QIconDirInfo::Scalable) {
- return dir.size <= dir.maxSize &&
- iconsize >= dir.minSize;
-
- } else if (dir.type == QIconDirInfo::Threshold) {
- return iconsize >= dir.size - dir.threshold &&
- iconsize <= dir.size + dir.threshold;
- }
-
- Q_ASSERT(1); // Not a valid value
- return false;
-}
-
-/*
- * This algorithm is defined by the freedesktop spec:
- * http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html
- */
-static int directorySizeDistance(const QIconDirInfo &dir, int iconsize)
-{
- if (dir.type == QIconDirInfo::Fixed) {
- return qAbs(dir.size - iconsize);
-
- } else if (dir.type == QIconDirInfo::Scalable) {
- if (iconsize < dir.minSize)
- return dir.minSize - iconsize;
- else if (iconsize > dir.maxSize)
- return iconsize - dir.maxSize;
- else
- return 0;
-
- } else if (dir.type == QIconDirInfo::Threshold) {
- if (iconsize < dir.size - dir.threshold)
- return dir.minSize - iconsize;
- else if (iconsize > dir.size + dir.threshold)
- return iconsize - dir.maxSize;
- else return 0;
- }
-
- Q_ASSERT(1); // Not a valid value
- return INT_MAX;
-}
-
-QIconLoaderEngineEntry *QIconLoaderEngine::entryForSize(const QSize &size)
-{
- int iconsize = qMin(size.width(), size.height());
-
- // Note that m_entries are sorted so that png-files
- // come first
-
- // Search for exact matches first
- for (int i = 0; i < m_entries.count(); ++i) {
- QIconLoaderEngineEntry *entry = m_entries.at(i);
- if (directoryMatchesSize(entry->dir, iconsize)) {
- return entry;
- }
- }
-
- // Find the minimum distance icon
- int minimalSize = INT_MAX;
- QIconLoaderEngineEntry *closestMatch = 0;
- for (int i = 0; i < m_entries.count(); ++i) {
- QIconLoaderEngineEntry *entry = m_entries.at(i);
- int distance = directorySizeDistance(entry->dir, iconsize);
- if (distance < minimalSize) {
- minimalSize = distance;
- closestMatch = entry;
- }
- }
- return closestMatch;
-}
-
-/*
- * Returns the actual icon size. For scalable svg's this is equivalent
- * to the requested size. Otherwise the closest match is returned but
- * we can never return a bigger size than the requested size.
- *
- */
-QSize QIconLoaderEngine::actualSize(const QSize &size, QIcon::Mode mode,
- QIcon::State state)
-{
- ensureLoaded();
-
- QIconLoaderEngineEntry *entry = entryForSize(size);
- if (entry) {
- const QIconDirInfo &dir = entry->dir;
- if (dir.type == QIconDirInfo::Scalable)
- return size;
- else {
- int result = qMin<int>(dir.size, qMin(size.width(), size.height()));
- return QSize(result, result);
- }
- }
- return QIconEngineV2::actualSize(size, mode, state);
-}
-
-QPixmap PixmapEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)
-{
- Q_UNUSED(state);
-
- // Ensure that basePixmap is lazily initialized before generating the
- // key, otherwise the cache key is not unique
- if (basePixmap.isNull())
- basePixmap.load(filename);
-
- int actualSize = qMin(size.width(), size.height());
-
- QString key = QLatin1Literal("$qt_theme_")
- % HexString<qint64>(basePixmap.cacheKey())
- % HexString<int>(mode)
- % HexString<qint64>(qApp->palette().cacheKey())
- % HexString<int>(actualSize);
-
- QPixmap cachedPixmap;
- if (QPixmapCache::find(key, &cachedPixmap)) {
- return cachedPixmap;
- } else {
- QStyleOption opt(0);
- opt.palette = qApp->palette();
- cachedPixmap = qApp->style()->generatedIconPixmap(mode, basePixmap, &opt);
- QPixmapCache::insert(key, cachedPixmap);
- }
- return cachedPixmap;
-}
-
-QPixmap ScalableEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)
-{
- if (svgIcon.isNull())
- svgIcon = QIcon(filename);
-
- // Simply reuse svg icon engine
- return svgIcon.pixmap(size, mode, state);
-}
-
-QPixmap QIconLoaderEngine::pixmap(const QSize &size, QIcon::Mode mode,
- QIcon::State state)
-{
- ensureLoaded();
-
- QIconLoaderEngineEntry *entry = entryForSize(size);
- if (entry)
- return entry->pixmap(size, mode, state);
-
- return QPixmap();
-}
-
-QString QIconLoaderEngine::key() const
-{
- return QLatin1String("QIconLoaderEngine");
-}
-
-void QIconLoaderEngine::virtual_hook(int id, void *data)
-{
- ensureLoaded();
-
- switch (id) {
- case QIconEngineV2::AvailableSizesHook:
- {
- QIconEngineV2::AvailableSizesArgument &arg
- = *reinterpret_cast<QIconEngineV2::AvailableSizesArgument*>(data);
- const QList<QIconDirInfo> directoryKey = iconLoaderInstance()->theme().keyList();
- arg.sizes.clear();
-
- // Gets all sizes from the DirectoryInfo entries
- for (int i = 0 ; i < m_entries.size() ; ++i) {
- int size = m_entries.at(i)->dir.size;
- arg.sizes.append(QSize(size, size));
- }
- }
- break;
- case QIconEngineV2::IconNameHook:
- {
- QString &name = *reinterpret_cast<QString*>(data);
- name = m_iconName;
- }
- break;
- default:
- QIconEngineV2::virtual_hook(id, data);
- }
-}
-
-QT_END_NAMESPACE
-
-#endif //QT_NO_ICON
diff --git a/src/gui/image/qiconloader_p.h b/src/gui/image/qiconloader_p.h
deleted file mode 100644
index 00a3976b40..0000000000
--- a/src/gui/image/qiconloader_p.h
+++ /dev/null
@@ -1,192 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDESKTOPICON_P_H
-#define QDESKTOPICON_P_H
-
-#ifndef QT_NO_ICON
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtGui/QIcon>
-#include <QtGui/QIconEngine>
-#include <QtGui/QPixmapCache>
-#include <private/qicon_p.h>
-#include <private/qfactoryloader_p.h>
-#include <QtCore/QHash>
-
-QT_BEGIN_NAMESPACE
-
-class QIconLoader;
-
-struct QIconDirInfo
-{
- enum Type { Fixed, Scalable, Threshold };
- QIconDirInfo(const QString &_path = QString()) :
- path(_path),
- size(0),
- maxSize(0),
- minSize(0),
- threshold(0),
- type(Threshold) {}
- QString path;
- short size;
- short maxSize;
- short minSize;
- short threshold;
- Type type : 4;
-};
-
-class QIconLoaderEngineEntry
- {
-public:
- virtual ~QIconLoaderEngineEntry() {}
- virtual QPixmap pixmap(const QSize &size,
- QIcon::Mode mode,
- QIcon::State state) = 0;
- QString filename;
- QIconDirInfo dir;
- static int count;
-};
-
-struct ScalableEntry : public QIconLoaderEngineEntry
-{
- QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
- QIcon svgIcon;
-};
-
-struct PixmapEntry : public QIconLoaderEngineEntry
-{
- QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
- QPixmap basePixmap;
-};
-
-typedef QList<QIconLoaderEngineEntry*> QThemeIconEntries;
-
-class QIconLoaderEngine : public QIconEngineV2
-{
-public:
- QIconLoaderEngine(const QString& iconName = QString());
- ~QIconLoaderEngine();
-
- void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state);
- QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
- QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state);
- QIconEngineV2 *clone() const;
- bool read(QDataStream &in);
- bool write(QDataStream &out) const;
-
-private:
- QString key() const;
- bool hasIcon() const;
- void ensureLoaded();
- void virtual_hook(int id, void *data);
- QIconLoaderEngineEntry *entryForSize(const QSize &size);
- QIconLoaderEngine(const QIconLoaderEngine &other);
- QThemeIconEntries m_entries;
- QString m_iconName;
- uint m_key;
-
- friend class QIconLoader;
-};
-
-class QIconTheme
-{
-public:
- QIconTheme(const QString &name);
- QIconTheme() : m_valid(false) {}
- QStringList parents() { return m_parents; }
- QList <QIconDirInfo> keyList() { return m_keyList; }
- QString contentDir() { return m_contentDir; }
- bool isValid() { return m_valid; }
-
-private:
- QString m_contentDir;
- QList <QIconDirInfo> m_keyList;
- QStringList m_parents;
- bool m_valid;
-};
-
-class QIconLoader : public QObject
-{
-public:
- QIconLoader();
- QThemeIconEntries loadIcon(const QString &iconName) const;
- uint themeKey() const { return m_themeKey; }
-
- QString themeName() const { return m_userTheme.isEmpty() ? m_systemTheme : m_userTheme; }
- void setThemeName(const QString &themeName);
- QIconTheme theme() { return themeList.value(themeName()); }
- void setThemeSearchPath(const QStringList &searchPaths);
- QStringList themeSearchPaths() const;
- QIconDirInfo dirInfo(int dirindex);
- static QIconLoader *instance();
- void updateSystemTheme();
- void invalidateKey() { m_themeKey++; }
- void ensureInitialized();
-
-private:
- QThemeIconEntries findIconHelper(const QString &themeName,
- const QString &iconName,
- QStringList &visited) const;
- uint m_themeKey;
- bool m_supportsSvg;
- bool m_initialized;
-
- mutable QString m_userTheme;
- mutable QString m_systemTheme;
- mutable QStringList m_iconDirs;
- mutable QHash <QString, QIconTheme> themeList;
-};
-
-QT_END_NAMESPACE
-
-#endif // QDESKTOPICON_P_H
-
-#endif //QT_NO_ICON
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index 50b372ea63..448e1b4be0 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -124,9 +124,6 @@ QBasicAtomicInt qimage_serial_number = Q_BASIC_ATOMIC_INITIALIZER(1);
QImageData::QImageData()
: ref(0), width(0), height(0), depth(0), nbytes(0), data(0),
-#ifdef QT3_SUPPORT
- jumptable(0),
-#endif
format(QImage::Format_ARGB32), bytes_per_line(0),
ser_no(qimage_serial_number.fetchAndAddRelaxed(1)),
detach_no(0),
@@ -220,11 +217,6 @@ QImageData::~QImageData()
delete paintEngine;
if (data && own_data)
free(data);
-#ifdef QT3_SUPPORT
- if (jumptable)
- free(jumptable);
- jumptable = 0;
-#endif
data = 0;
}
@@ -757,27 +749,6 @@ const uchar *qt_get_bitflip_array() // called from QPixma
return bitflip;
}
-#if defined(QT3_SUPPORT)
-static QImage::Format formatFor(int depth, QImage::Endian bitOrder)
-{
- QImage::Format format;
- if (depth == 1) {
- format = bitOrder == QImage::BigEndian ? QImage::Format_Mono : QImage::Format_MonoLSB;
- } else if (depth == 8) {
- format = QImage::Format_Indexed8;
- } else if (depth == 32) {
- format = QImage::Format_RGB32;
- } else if (depth == 24) {
- format = QImage::Format_RGB888;
- } else if (depth == 16) {
- format = QImage::Format_RGB16;
- } else {
- qWarning("QImage: Depth %d not supported", depth);
- format = QImage::Format_Invalid;
- }
- return format;
-}
-#endif
/*!
Constructs a null image.
@@ -991,42 +962,6 @@ QImage::QImage(const QString &fileName, const char *format)
load(fileName, format);
}
-/*!
- Constructs an image and tries to load the image from the file with
- the given \a fileName.
-
- The loader attempts to read the image using the specified \a
- format. If the \a format is not specified (which is the default),
- the loader probes the file for a header to guess the file format.
-
- If the loading of the image failed, this object is a null image.
-
- The file name can either refer to an actual file on disk or to one
- of the application's embedded resources. See the
- \l{resources.html}{Resource System} overview for details on how to
- embed images and other resource files in the application's
- executable.
-
- You can disable this constructor by defining \c
- QT_NO_CAST_FROM_ASCII when you compile your applications. This can
- be useful, for example, if you want to ensure that all
- user-visible strings go through QObject::tr().
-
- \sa QString::fromAscii(), isNull(), {QImage#Reading and Writing
- Image Files}{Reading and Writing Image Files}
-*/
-#ifndef QT_NO_CAST_FROM_ASCII
-QImage::QImage(const char *fileName, const char *format)
- : QPaintDevice()
-{
- // ### Qt 5: if you remove the QImage(const QByteArray &) QT3_SUPPORT
- // constructor, remove this constructor as well. The constructor here
- // exists so that QImage("foo.png") compiles without ambiguity.
- d = 0;
- load(QString::fromAscii(fileName), format);
-}
-#endif
-
#ifndef QT_NO_IMAGEFORMAT_XPM
extern bool qt_read_xpm_image_or_array(QIODevice *device, const char * const *source, QImage &image);
@@ -1097,178 +1032,6 @@ QImage::QImage(const QImage &image)
}
}
-#ifdef QT3_SUPPORT
-/*!
- \fn QImage::QImage(int width, int height, int depth, int numColors, Endian bitOrder)
-
- Constructs an image with the given \a width, \a height, \a depth,
- \a numColors colors and \a bitOrder.
-
- Use the constructor that accepts a width, a height and a format
- (i.e. specifying the depth and bit order), in combination with the
- setColorCount() function, instead.
-
- \oldcode
- QImage image(width, height, depth, numColors);
- \newcode
- QImage image(width, height, format);
-
- // For 8 bit images the default number of colors is 256. If
- // another number of colors is required it can be specified
- // using the setColorCount() function.
- image.setColorCount(numColors);
- \endcode
-*/
-
-QImage::QImage(int w, int h, int depth, int colorCount, Endian bitOrder)
- : QPaintDevice()
-{
- d = QImageData::create(QSize(w, h), formatFor(depth, bitOrder), colorCount);
-}
-
-/*!
- Constructs an image with the given \a size, \a depth, \a numColors
- and \a bitOrder.
-
- Use the constructor that accepts a size and a format
- (i.e. specifying the depth and bit order), in combination with the
- setColorCount() function, instead.
-
- \oldcode
- QSize mySize(width, height);
- QImage image(mySize, depth, numColors);
- \newcode
- QSize mySize(width, height);
- QImage image(mySize, format);
-
- // For 8 bit images the default number of colors is 256. If
- // another number of colors is required it can be specified
- // using the setColorCount() function.
- image.setColorCount(numColors);
- \endcode
-*/
-QImage::QImage(const QSize& size, int depth, int numColors, Endian bitOrder)
- : QPaintDevice()
-{
- d = QImageData::create(size, formatFor(depth, bitOrder), numColors);
-}
-
-/*!
- \fn QImage::QImage(uchar* data, int width, int height, int depth, const QRgb* colortable, int numColors, Endian bitOrder)
-
- Constructs an image with the given \a width, \a height, depth, \a
- colortable, \a numColors and \a bitOrder, that uses an existing
- memory buffer, \a data.
-
- Use the constructor that accepts a uchar pointer, a width, a
- height and a format (i.e. specifying the depth and bit order), in
- combination with the setColorTable() function, instead.
-
- \oldcode
- uchar *myData;
- QRgb *myColorTable;
-
- QImage image(myData, width, height, depth,
- myColorTable, numColors, IgnoreEndian);
- \newcode
- uchar *myData;
- QVector<QRgb> myColorTable;
-
- QImage image(myData, width, height, format);
- image.setColorTable(myColorTable);
- \endcode
-*/
-QImage::QImage(uchar* data, int w, int h, int depth, const QRgb* colortable, int numColors, Endian bitOrder)
- : QPaintDevice()
-{
- d = 0;
- Format f = formatFor(depth, bitOrder);
- if (f == Format_Invalid)
- return;
-
- const int bytes_per_line = ((w*depth+31)/32)*4; // bytes per scanline
- if (w <= 0 || h <= 0 || numColors < 0 || !data
- || INT_MAX/sizeof(uchar *) < uint(h)
- || INT_MAX/uint(depth) < uint(w)
- || bytes_per_line <= 0
- || INT_MAX/uint(bytes_per_line) < uint(h))
- return; // invalid parameter(s)
- d = new QImageData;
- d->ref.ref();
-
- d->own_data = false;
- d->data = data;
- d->width = w;
- d->height = h;
- d->depth = depth;
- d->format = f;
- if (depth == 32)
- numColors = 0;
-
- d->bytes_per_line = bytes_per_line;
- d->nbytes = d->bytes_per_line * h;
- if (colortable) {
- d->colortable.resize(numColors);
- for (int i = 0; i < numColors; ++i)
- d->colortable[i] = colortable[i];
- } else if (numColors) {
- setColorCount(numColors);
- }
-}
-
-#ifdef Q_WS_QWS
-
-/*!
- \fn QImage::QImage(uchar* data, int width, int height, int depth, int bytesPerLine, const QRgb* colortable, int numColors, Endian bitOrder)
-
- Constructs an image with the given \a width, \a height, \a depth,
- \a bytesPerLine, \a colortable, \a numColors and \a bitOrder, that
- uses an existing memory buffer, \a data. The image does not delete
- the buffer at destruction.
-
- \warning This constructor is only available in Qt for Embedded Linux.
-
- The data has to be 32-bit aligned, and each scanline of data in the image
- must also be 32-bit aligned, so it's no longer possible to specify a custom
- \a bytesPerLine value.
-*/
-QImage::QImage(uchar* data, int w, int h, int depth, int bpl, const QRgb* colortable, int numColors, Endian bitOrder)
- : QPaintDevice()
-{
- d = 0;
- Format f = formatFor(depth, bitOrder);
- if (f == Format_Invalid)
- return;
- if (!data || w <= 0 || h <= 0 || depth <= 0 || numColors < 0
- || INT_MAX/sizeof(uchar *) < uint(h)
- || INT_MAX/uint(depth) < uint(w)
- || bpl <= 0
- || INT_MAX/uint(bpl) < uint(h))
- return; // invalid parameter(s)
-
- d = new QImageData;
- d->ref.ref();
- d->own_data = false;
- d->data = data;
- d->width = w;
- d->height = h;
- d->depth = depth;
- d->format = f;
- if (depth == 32)
- numColors = 0;
- d->bytes_per_line = bpl;
- d->nbytes = d->bytes_per_line * h;
- if (colortable) {
- d->colortable.resize(numColors);
- for (int i = 0; i < numColors; ++i)
- d->colortable[i] = colortable[i];
- } else if (numColors) {
- setColorCount(numColors);
- }
-}
-#endif // Q_WS_QWS
-#endif // QT3_SUPPORT
-
/*!
Destroys the image and cleans up.
*/
@@ -1613,75 +1376,6 @@ int QImage::colorCount() const
return d ? d->colortable.size() : 0;
}
-
-#ifdef QT3_SUPPORT
-/*!
- \fn QImage::Endian QImage::bitOrder() const
-
- Returns the bit order for the image. If it is a 1-bpp image, this
- function returns either QImage::BigEndian or
- QImage::LittleEndian. Otherwise, this function returns
- QImage::IgnoreEndian.
-
- Use the format() function instead for the monochrome formats. For
- non-monochrome formats the bit order is irrelevant.
-*/
-
-/*!
- Returns a pointer to the scanline pointer table. This is the
- beginning of the data block for the image.
- Returns 0 in case of an error.
-
- Use the bits() or scanLine() function instead.
-*/
-uchar **QImage::jumpTable()
-{
- if (!d)
- return 0;
- detach();
-
- // in case detach() ran out of memory..
- if (!d)
- return 0;
-
- if (!d->jumptable) {
- d->jumptable = (uchar **)malloc(d->height*sizeof(uchar *));
- if (!d->jumptable)
- return 0;
- uchar *data = d->data;
- int height = d->height;
- uchar **p = d->jumptable;
- while (height--) {
- *p++ = data;
- data += d->bytes_per_line;
- }
- }
- return d->jumptable;
-}
-
-/*!
- \overload
-*/
-const uchar * const *QImage::jumpTable() const
-{
- if (!d)
- return 0;
- if (!d->jumptable) {
- d->jumptable = (uchar **)malloc(d->height*sizeof(uchar *));
- if (!d->jumptable)
- return 0;
- uchar *data = d->data;
- int height = d->height;
- uchar **p = d->jumptable;
- while (height--) {
- *p++ = data;
- data += d->bytes_per_line;
- }
- }
- return d->jumptable;
-}
-#endif
-
/*!
Sets the color table used to translate color indexes to QRgb
values, to the specified \a colors.
@@ -2223,116 +1917,6 @@ QImage::Format QImage::format() const
}
-#ifdef QT3_SUPPORT
-/*!
- Returns true if alpha buffer mode is enabled; otherwise returns
- false.
-
- Use the hasAlphaChannel() function instead.
-
-*/
-bool QImage::hasAlphaBuffer() const
-{
- if (!d)
- return false;
-
- switch (d->format) {
- case Format_ARGB32:
- case Format_ARGB32_Premultiplied:
- case Format_ARGB8565_Premultiplied:
- case Format_ARGB8555_Premultiplied:
- case Format_ARGB6666_Premultiplied:
- case Format_ARGB4444_Premultiplied:
- return true;
- default:
- return false;
- }
-}
-
-/*!
- Enables alpha buffer mode if \a enable is true, otherwise disables
- it. The alpha buffer is used to set a mask when a QImage is
- translated to a QPixmap.
-
- If a monochrome or indexed 8-bit image has alpha channels in their
- color tables they will automatically detect that they have an
- alpha channel, so this function is not required. To force alpha
- channels on 32-bit images, use the convertToFormat() function.
-*/
-
-void QImage::setAlphaBuffer(bool enable)
-{
- if (!d
- || d->format == Format_Mono
- || d->format == Format_MonoLSB
- || d->format == Format_Indexed8)
- return;
- if (enable && (d->format == Format_ARGB32 ||
- d->format == Format_ARGB32_Premultiplied ||
- d->format == Format_ARGB8565_Premultiplied ||
- d->format == Format_ARGB6666_Premultiplied ||
- d->format == Format_ARGB8555_Premultiplied ||
- d->format == Format_ARGB4444_Premultiplied))
- {
- return;
- }
- if (!enable && (d->format == Format_RGB32 ||
- d->format == Format_RGB555 ||
- d->format == Format_RGB666 ||
- d->format == Format_RGB888 ||
- d->format == Format_RGB444))
- {
- return;
- }
- detach();
- d->format = (enable ? Format_ARGB32 : Format_RGB32);
-}
-
-
-/*!
- \fn bool QImage::create(int width, int height, int depth, int numColors, Endian bitOrder)
-
- Sets the image \a width, \a height, \a depth, its number of colors
- (in \a numColors), and bit order. Returns true if successful, or
- false if the parameters are incorrect or if memory cannot be
- allocated.
-
- The \a width and \a height is limited to 32767. \a depth must be
- 1, 8, or 32. If \a depth is 1, \a bitOrder must be set to
- either QImage::LittleEndian or QImage::BigEndian. For other depths
- \a bitOrder must be QImage::IgnoreEndian.
-
- This function allocates a color table and a buffer for the image
- data. The image data is not initialized. The image buffer is
- allocated as a single block that consists of a table of scanLine()
- pointers (jumpTable()) and the image data (bits()).
-
- Use a QImage constructor instead.
-*/
-bool QImage::create(int width, int height, int depth, int numColors, Endian bitOrder)
-{
- if (d && !d->ref.deref())
- delete d;
- d = QImageData::create(QSize(width, height), formatFor(depth, bitOrder), numColors);
- return true;
-}
-
-/*!
- \fn bool QImage::create(const QSize& size, int depth, int numColors, Endian bitOrder)
- \overload
-
- The width and height are specified in the \a size argument.
-
- Use a QImage constructor instead.
-*/
-bool QImage::create(const QSize& size, int depth, int numColors, QImage::Endian bitOrder)
-{
- if (d && !d->ref.deref())
- delete d;
- d = QImageData::create(size, formatFor(depth, bitOrder), numColors);
- return true;
-}
-#endif // QT3_SUPPORT
/*****************************************************************************
Internal routines for converting image depth.
@@ -4022,30 +3606,6 @@ QImage QImage::convertToFormat(Format format, const QVector<QRgb> &colorTable, Q
return image;
}
-#ifdef QT3_SUPPORT
-/*!
- Converts the depth (bpp) of the image to the given \a depth and
- returns the converted image. The original image is not changed.
- Returns this image if \a depth is equal to the image depth, or a
- null image if this image cannot be converted. The \a depth
- argument must be 1, 8 or 32. If the image needs to be modified to
- fit in a lower-resolution result (e.g. converting from 32-bit to
- 8-bit), use the \a flags to specify how you'd prefer this to
- happen.
-
- Use the convertToFormat() function instead.
-*/
-
-QImage QImage::convertDepth(int depth, Qt::ImageConversionFlags flags) const
-{
- if (!d || d->depth == depth)
- return *this;
-
- Format format = formatFor (depth, QImage::LittleEndian);
- return convertToFormat(format, flags);
-}
-#endif
-
/*!
\fn bool QImage::valid(const QPoint &pos) const
@@ -4264,41 +3824,6 @@ void QImage::setPixel(int x, int y, uint index_or_rgb)
}
}
-#ifdef QT3_SUPPORT
-/*!
- Converts the bit order of the image to the given \a bitOrder and
- returns the converted image. The original image is not changed.
- Returns this image if the given \a bitOrder is equal to the image
- current bit order, or a null image if this image cannot be
- converted.
-
- Use convertToFormat() instead.
-*/
-
-QImage QImage::convertBitOrder(Endian bitOrder) const
-{
- if (!d || isNull() || d->depth != 1 || !(bitOrder == BigEndian || bitOrder == LittleEndian))
- return QImage();
-
- if ((d->format == Format_Mono && bitOrder == BigEndian)
- || (d->format == Format_MonoLSB && bitOrder == LittleEndian))
- return *this;
-
- QImage image(d->width, d->height, d->format == Format_Mono ? Format_MonoLSB : Format_Mono);
-
- const uchar *data = d->data;
- const uchar *end = data + d->nbytes;
- uchar *ndata = image.d->data;
- while (data < end)
- *ndata++ = bitflip[*data++];
-
- image.setDotsPerMeterX(dotsPerMeterX());
- image.setDotsPerMeterY(dotsPerMeterY());
-
- image.d->colortable = d->colortable;
- return image;
-}
-#endif
/*!
Returns true if all the colors in the image are shades of gray
(i.e. their red, green and blue components are equal); otherwise
@@ -5283,66 +4808,6 @@ QDataStream &operator>>(QDataStream &s, QImage &image)
#endif // QT_NO_DATASTREAM
-#ifdef QT3_SUPPORT
-/*!
- \fn QImage QImage::convertDepthWithPalette(int depth, QRgb* palette, int palette_count, Qt::ImageConversionFlags flags) const
-
- Returns an image with the given \a depth, using the \a
- palette_count colors pointed to by \a palette. If \a depth is 1 or
- 8, the returned image will have its color table ordered in the
- same way as \a palette.
-
- If the image needs to be modified to fit in a lower-resolution
- result (e.g. converting from 32-bit to 8-bit), use the \a flags to
- specify how you'd prefer this to happen.
-
- Note: currently no closest-color search is made. If colors are
- found that are not in the palette, the palette may not be used at
- all. This result should not be considered valid because it may
- change in future implementations.
-
- Currently inefficient for non-32-bit images.
-
- Use the convertToFormat() function in combination with the
- setColorTable() function instead.
-*/
-QImage QImage::convertDepthWithPalette(int d, QRgb* palette, int palette_count, Qt::ImageConversionFlags flags) const
-{
- Format f = formatFor(d, QImage::LittleEndian);
- QVector<QRgb> colortable;
- for (int i = 0; i < palette_count; ++i)
- colortable.append(palette[i]);
- return convertToFormat(f, colortable, flags);
-}
-
-/*!
- \relates QImage
-
- Copies a block of pixels from \a src to \a dst. The pixels
- copied from source (src) are converted according to
- \a flags if it is incompatible with the destination
- (\a dst).
-
- \a sx, \a sy is the top-left pixel in \a src, \a dx, \a dy is the
- top-left position in \a dst and \a sw, \a sh is the size of the
- copied block. The copying is clipped if areas outside \a src or \a
- dst are specified. If \a sw is -1, it is adjusted to
- src->width(). Similarly, if \a sh is -1, it is adjusted to
- src->height().
-
- Currently inefficient for non 32-bit images.
-
- Use copy() or QPainter::drawImage() instead.
-*/
-void bitBlt(QImage *dst, int dx, int dy, const QImage *src, int sx, int sy, int sw, int sh,
- Qt::ImageConversionFlags flags)
-{
- if (dst->isNull() || src->isNull())
- return;
- QPainter p(dst);
- p.drawImage(QPoint(dx, dy), *src, QRect(sx, sy, sw, sh), flags);
-}
-#endif
/*!
\fn bool QImage::operator==(const QImage & image) const
@@ -6322,24 +5787,6 @@ int QImage::bitPlaneCount() const
return bpc;
}
-
-#ifdef QT3_SUPPORT
-#if defined(Q_WS_X11)
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <private/qt_x11_p.h>
-QT_END_INCLUDE_NAMESPACE
-#endif
-
-QImage::Endian QImage::systemBitOrder()
-{
-#if defined(Q_WS_X11)
- return BitmapBitOrder(X11->display) == MSBFirst ? BigEndian : LittleEndian;
-#else
- return BigEndian;
-#endif
-}
-#endif
-
/*!
\fn QImage QImage::copy(const QRect &rect, Qt::ImageConversionFlags flags) const
\compat
diff --git a/src/gui/image/qimage.h b/src/gui/image/qimage.h
index 496fe93c54..91a6a99a2a 100644
--- a/src/gui/image/qimage.h
+++ b/src/gui/image/qimage.h
@@ -132,9 +132,6 @@ public:
explicit QImage(const char * const xpm[]);
#endif
explicit QImage(const QString &fileName, const char *format = 0);
-#ifndef QT_NO_CAST_FROM_ASCII
- explicit QImage(const char *fileName, const char *format = 0);
-#endif
QImage(const QImage &);
~QImage();
@@ -283,50 +280,6 @@ public:
void setText(const char* key, const char* lang, const QString&);
#endif
-#ifdef QT3_SUPPORT
- enum Endian { BigEndian, LittleEndian, IgnoreEndian };
- QT3_SUPPORT_CONSTRUCTOR QImage(int width, int height, int depth, int numColors=0, Endian bitOrder=IgnoreEndian);
- QT3_SUPPORT_CONSTRUCTOR QImage(const QSize&, int depth, int numColors=0, Endian bitOrder=IgnoreEndian);
- QT3_SUPPORT_CONSTRUCTOR QImage(uchar *data, int w, int h, int depth, const QRgb *colortable, int numColors, Endian bitOrder);
-#ifdef Q_WS_QWS
- QT3_SUPPORT_CONSTRUCTOR QImage(uchar *data, int w, int h, int depth, int pbl, const QRgb *colortable, int numColors, Endian bitOrder);
-#endif
- inline QT3_SUPPORT Endian bitOrder() const {
- Format f = format();
- return f == Format_Mono ? BigEndian : (f == Format_MonoLSB ? LittleEndian : IgnoreEndian);
- }
- QT3_SUPPORT QImage convertDepth(int, Qt::ImageConversionFlags flags = Qt::AutoColor) const;
- QT3_SUPPORT QImage convertDepthWithPalette(int, QRgb* p, int pc, Qt::ImageConversionFlags flags = Qt::AutoColor) const;
- QT3_SUPPORT QImage convertBitOrder(Endian) const;
- QT3_SUPPORT bool hasAlphaBuffer() const;
- QT3_SUPPORT void setAlphaBuffer(bool);
- QT3_SUPPORT uchar **jumpTable();
- QT3_SUPPORT const uchar * const *jumpTable() const;
- inline QT3_SUPPORT void reset() { *this = QImage(); }
- static inline QT3_SUPPORT Endian systemByteOrder()
- { return QSysInfo::ByteOrder == QSysInfo::BigEndian ? BigEndian : LittleEndian; }
- inline QT3_SUPPORT QImage swapRGB() const { return rgbSwapped(); }
- inline QT3_SUPPORT QImage mirror(bool horizontally = false, bool vertically = true) const
- { return mirrored(horizontally, vertically); }
- QT3_SUPPORT bool create(const QSize&, int depth, int numColors=0, Endian bitOrder=IgnoreEndian);
- QT3_SUPPORT bool create(int width, int height, int depth, int numColors=0, Endian bitOrder=IgnoreEndian);
- inline QT3_SUPPORT QImage xForm(const QMatrix &matrix) const { return transformed(QTransform(matrix)); }
- inline QT3_SUPPORT QImage smoothScale(int w, int h, Qt::AspectRatioMode mode = Qt::IgnoreAspectRatio) const
- { return scaled(QSize(w, h), mode, Qt::SmoothTransformation); }
- inline QImage QT3_SUPPORT smoothScale(const QSize &s, Qt::AspectRatioMode mode = Qt::IgnoreAspectRatio) const
- { return scaled(s, mode, Qt::SmoothTransformation); }
- inline QT3_SUPPORT QImage scaleWidth(int w) const { return scaledToWidth(w); }
- inline QT3_SUPPORT QImage scaleHeight(int h) const { return scaledToHeight(h); }
- inline QT3_SUPPORT void invertPixels(bool invertAlpha) { invertAlpha ? invertPixels(InvertRgba) : invertPixels(InvertRgb); }
- inline QT3_SUPPORT QImage copy(int x, int y, int w, int h, Qt::ImageConversionFlags) const
- { return copy(QRect(x, y, w, h)); }
- inline QT3_SUPPORT QImage copy(const QRect &rect, Qt::ImageConversionFlags) const
- { return copy(rect); }
- static QT3_SUPPORT Endian systemBitOrder();
- inline QT3_SUPPORT_CONSTRUCTOR QImage(const QByteArray &data)
- { d = 0; *this = QImage::fromData(data); }
-#endif
-
protected:
virtual int metric(PaintDeviceMetric metric) const;
@@ -362,11 +315,6 @@ Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QImage &);
Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QImage &);
#endif
-#ifdef QT3_SUPPORT
-Q_GUI_EXPORT QT3_SUPPORT void bitBlt(QImage* dst, int dx, int dy, const QImage* src,
- int sx=0, int sy=0, int sw=-1, int sh=-1, Qt::ImageConversionFlags flags = Qt::AutoColor);
-#endif
-
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/gui/image/qimage_p.h b/src/gui/image/qimage_p.h
index db6620b39c..93ab8a78ba 100644
--- a/src/gui/image/qimage_p.h
+++ b/src/gui/image/qimage_p.h
@@ -79,9 +79,6 @@ struct Q_GUI_EXPORT QImageData { // internal image data
int nbytes; // number of bytes data
QVector<QRgb> colortable;
uchar *data;
-#ifdef QT3_SUPPORT
- uchar **jumptable;
-#endif
QImage::Format format;
int bytes_per_line;
int ser_no; // serial number
diff --git a/src/gui/image/qmovie.h b/src/gui/image/qmovie.h
index b64df29c41..98fcf68ee6 100644
--- a/src/gui/image/qmovie.h
+++ b/src/gui/image/qmovie.h
@@ -51,11 +51,6 @@
#include <QtCore/qobject.h>
#include <QtGui/qimagereader.h>
-#ifdef QT3_SUPPORT
-#include <QtGui/qimage.h>
-#include <QtGui/qpixmap.h>
-#endif
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -151,21 +146,6 @@ public Q_SLOTS:
private:
Q_DISABLE_COPY(QMovie)
Q_PRIVATE_SLOT(d_func(), void _q_loadNextFrame())
-
-#ifdef QT3_SUPPORT
-public:
- inline QT3_SUPPORT bool isNull() const { return isValid(); }
- inline QT3_SUPPORT int frameNumber() const { return currentFrameNumber(); }
- inline QT3_SUPPORT bool running() const { return state() == Running; }
- inline QT3_SUPPORT bool paused() const { return state() == Paused; }
- inline QT3_SUPPORT bool finished() const { return state() == NotRunning; }
- inline QT3_SUPPORT void restart() { stop(); start(); }
- inline QT3_SUPPORT QImage frameImage() const { return currentImage(); }
- inline QT3_SUPPORT QPixmap framePixmap() const { return currentPixmap(); }
- inline QT3_SUPPORT void step() { jumpToNextFrame(); }
- inline QT3_SUPPORT void pause() { setPaused(true); }
- inline QT3_SUPPORT void unpause() { setPaused(false); }
-#endif
};
QT_END_NAMESPACE
diff --git a/src/gui/image/qnativeimage.cpp b/src/gui/image/qnativeimage.cpp
index 8face87a92..501072d6e0 100644
--- a/src/gui/image/qnativeimage.cpp
+++ b/src/gui/image/qnativeimage.cpp
@@ -45,14 +45,12 @@
#include "private/qpaintengine_raster_p.h"
-#include "private/qapplication_p.h"
-#include "private/qgraphicssystem_p.h"
+#include "private/qguiapplication_p.h"
#if defined(Q_WS_X11) && !defined(QT_NO_MITSHM)
#include <qx11info_x11.h>
#include <sys/ipc.h>
#include <sys/shm.h>
-#include <qwidget.h>
#endif
#ifdef Q_WS_MAC
@@ -70,7 +68,7 @@ typedef struct {
} BITMAPINFO_MASK;
-QNativeImage::QNativeImage(int width, int height, QImage::Format format, bool isTextBuffer, QWidget *)
+QNativeImage::QNativeImage(int width, int height, QImage::Format format, bool isTextBuffer, QWindow *)
{
#ifndef Q_WS_WINCE
Q_UNUSED(isTextBuffer);
@@ -147,102 +145,9 @@ QImage::Format QNativeImage::systemFormat()
return QImage::Format_RGB32;
}
-
-#elif defined(Q_WS_X11) && !defined(QT_NO_MITSHM)
-
-QNativeImage::QNativeImage(int width, int height, QImage::Format format,bool /* isTextBuffer */, QWidget *widget)
- : xshmimg(0), xshmpm(0)
-{
- if (!X11->use_mitshm) {
- image = QImage(width, height, format);
- // follow good coding practice and set xshminfo attributes, though values not used in this case
- xshminfo.readOnly = true;
- xshminfo.shmaddr = 0;
- xshminfo.shmid = 0;
- xshminfo.shmseg = 0;
- return;
- }
-
- QX11Info info = widget->x11Info();
-
- int dd = info.depth();
- Visual *vis = (Visual*) info.visual();
-
- xshmimg = XShmCreateImage(X11->display, vis, dd, ZPixmap, 0, &xshminfo, width, height);
- if (!xshmimg) {
- qWarning("QNativeImage: Unable to create shared XImage.");
- return;
- }
-
- bool ok;
- xshminfo.shmid = shmget(IPC_PRIVATE, xshmimg->bytes_per_line * xshmimg->height,
- IPC_CREAT | 0777);
- ok = xshminfo.shmid != -1;
- if (ok) {
- xshmimg->data = (char*)shmat(xshminfo.shmid, 0, 0);
- xshminfo.shmaddr = xshmimg->data;
- ok = (xshminfo.shmaddr != (char*)-1);
- if (ok)
- image = QImage((uchar *)xshmimg->data, width, height, format);
- }
- xshminfo.readOnly = false;
- if (ok) {
- ok = XShmAttach(X11->display, &xshminfo);
- XSync(X11->display, False);
- if (shmctl(xshminfo.shmid, IPC_RMID, 0) == -1)
- qWarning() << "Error while marking the shared memory segment to be destroyed";
- }
- if (!ok) {
- qWarning() << "QNativeImage: Unable to attach to shared memory segment.";
- if (xshmimg->data) {
- free(xshmimg->data);
- xshmimg->data = 0;
- }
- XDestroyImage(xshmimg);
- xshmimg = 0;
- if (xshminfo.shmaddr)
- shmdt(xshminfo.shmaddr);
- if (xshminfo.shmid != -1)
- shmctl(xshminfo.shmid, IPC_RMID, 0);
- return;
- }
- if (X11->use_mitshm_pixmaps) {
- xshmpm = XShmCreatePixmap(X11->display, DefaultRootWindow(X11->display), xshmimg->data,
- &xshminfo, width, height, dd);
- if (!xshmpm) {
- qWarning() << "QNativeImage: Unable to create shared Pixmap.";
- }
- }
-}
-
-
-QNativeImage::~QNativeImage()
-{
- if (!xshmimg)
- return;
-
- if (xshmpm) {
- XFreePixmap(X11->display, xshmpm);
- xshmpm = 0;
- }
- XShmDetach(X11->display, &xshminfo);
- xshmimg->data = 0;
- XDestroyImage(xshmimg);
- xshmimg = 0;
- shmdt(xshminfo.shmaddr);
- shmctl(xshminfo.shmid, IPC_RMID, 0);
-}
-
-QImage::Format QNativeImage::systemFormat()
-{
- if (QX11Info::appDepth() == 16)
- return QImage::Format_RGB16;
- return QImage::Format_RGB32;
-}
-
#elif defined(Q_WS_MAC)
-QNativeImage::QNativeImage(int width, int height, QImage::Format format, bool /* isTextBuffer */, QWidget *widget)
+QNativeImage::QNativeImage(int width, int height, QImage::Format format, bool /* isTextBuffer */, QWindow *)
: image(width, height, format)
{
@@ -267,7 +172,7 @@ QNativeImage::QNativeImage(int width, int height, QImage::Format format, bool /*
#endif
cg = CGBitmapContextCreate(image.bits(), width, height, 8, image.bytesPerLine(),
- QCoreGraphicsPaintEngine::macDisplayColorSpace(widget), cgflags);
+ QCoreGraphicsPaintEngine::macDisplayColorSpace(0), cgflags);
CGContextTranslateCTM(cg, 0, height);
CGContextScaleCTM(cg, 1, -1);
@@ -289,7 +194,7 @@ QImage::Format QNativeImage::systemFormat()
#else // other platforms...
-QNativeImage::QNativeImage(int width, int height, QImage::Format format, bool /* isTextBuffer */, QWidget *)
+QNativeImage::QNativeImage(int width, int height, QImage::Format format, bool /* isTextBuffer */, QWindow *)
: image(width, height, format)
{
@@ -302,11 +207,7 @@ QNativeImage::~QNativeImage()
QImage::Format QNativeImage::systemFormat()
{
-#ifdef Q_WS_QPA
- return QApplicationPrivate::platformIntegration()->screens().at(0)->format();
-#else
- return QImage::Format_RGB32;
-#endif
+ return QGuiApplicationPrivate::platformIntegration()->screens().at(0)->format();
}
#endif // platforms
diff --git a/src/gui/image/qnativeimage_p.h b/src/gui/image/qnativeimage_p.h
index 12aa0f021a..00897d4d54 100644
--- a/src/gui/image/qnativeimage_p.h
+++ b/src/gui/image/qnativeimage_p.h
@@ -58,9 +58,6 @@
#ifdef Q_WS_WIN
#include "qt_windows.h"
-#elif defined(Q_WS_X11)
-#include <private/qt_x11_p.h>
-
#elif defined(Q_WS_MAC)
#include <private/qt_mac_p.h>
@@ -68,12 +65,12 @@
QT_BEGIN_NAMESPACE
-class QWidget;
+class QWindow;
class QNativeImage
{
public:
- QNativeImage(int width, int height, QImage::Format format, bool isTextBuffer = false, QWidget *widget = 0);
+ QNativeImage(int width, int height, QImage::Format format, bool isTextBuffer = false, QWindow *window = 0);
~QNativeImage();
inline int width() const;
@@ -88,11 +85,6 @@ public:
HBITMAP bitmap;
HBITMAP null_bitmap;
-#elif defined(Q_WS_X11) && !defined(QT_NO_MITSHM)
- XImage *xshmimg;
- Pixmap xshmpm;
- XShmSegmentInfo xshminfo;
-
#elif defined(Q_WS_MAC)
CGContextRef cg;
#endif
diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp
index 3f38c0ce2a..9fd4fbd59c 100644
--- a/src/gui/image/qpicture.cpp
+++ b/src/gui/image/qpicture.cpp
@@ -47,6 +47,7 @@
#include <private/qfactoryloader_p.h>
#include <private/qpaintengine_pic_p.h>
#include <private/qfont_p.h>
+#include <qguiapplication.h>
#include "qdatastream.h"
#include "qfile.h"
@@ -1217,7 +1218,6 @@ QDataStream &operator>>(QDataStream &s, QPicture &r)
QT_BEGIN_INCLUDE_NAMESPACE
#include "qregexp.h"
-#include "qapplication.h"
#include "qpictureformatplugin.h"
QT_END_INCLUDE_NAMESPACE
diff --git a/src/gui/image/qpicture.h b/src/gui/image/qpicture.h
index c478ed962e..3bcd87e5a0 100644
--- a/src/gui/image/qpicture.h
+++ b/src/gui/image/qpicture.h
@@ -104,9 +104,6 @@ protected:
QPicture(QPicturePrivate &data);
int metric(PaintDeviceMetric m) const;
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT QPicture copy() const { QPicture p(*this); p.detach(); return p; }
-#endif
private:
bool exec(QPainter *p, QDataStream &ds, int i);
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index c34f6ac1b2..21640ca4bb 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -48,14 +48,10 @@
#include "qbitmap.h"
#include "qcolormap.h"
#include "qimage.h"
-#include "qwidget.h"
#include "qpainter.h"
#include "qdatastream.h"
#include "qbuffer.h"
-#include "qapplication.h"
-#include <private/qapplication_p.h>
-#include <private/qgraphicssystem_p.h>
-#include <private/qwidget_p.h>
+#include <private/qguiapplication_p.h>
#include "qevent.h"
#include "qfile.h"
#include "qfileinfo.h"
@@ -65,6 +61,7 @@
#include "qimagewriter.h"
#include "qpaintengine.h"
#include "qthread.h"
+#include "qdebug.h"
#ifdef Q_WS_MAC
# include "private/qt_mac_p.h"
@@ -86,7 +83,7 @@
#endif
#include "qpixmap_raster_p.h"
-#include "private/qstylehelper_p.h"
+#include "private/qhexstring_p.h"
QT_BEGIN_NAMESPACE
@@ -98,25 +95,17 @@ Q_GUI_EXPORT qint64 qt_pixmap_id(const QPixmap &pixmap)
static bool qt_pixmap_thread_test()
{
- if (!qApp) {
+ if (!QCoreApplication::instance()) {
qFatal("QPixmap: Must construct a QApplication before a QPaintDevice");
return false;
}
if (qApp->thread() != QThread::currentThread()) {
bool fail = false;
-#if defined (Q_WS_X11)
- if (!QApplication::testAttribute(Qt::AA_X11InitThreads))
- fail = true;
-#elif defined (Q_WS_QPA)
- if (!QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedPixmaps)) {
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ThreadedPixmaps)) {
printf("Lighthouse plugin does not support threaded pixmaps!\n");
fail = true;
}
-#else
- if (QApplicationPrivate::graphics_system_name != QLatin1String("raster"))
- fail = true;
-#endif
if (fail) {
qWarning("QPixmap: It is not safe to use pixmaps outside the GUI thread");
return false;
@@ -130,16 +119,8 @@ void QPixmap::init(int w, int h, Type type)
init(w, h, int(type));
}
-extern QApplication::Type qt_appType;
-
void QPixmap::init(int w, int h, int type)
{
- if (qt_appType == QApplication::Tty) {
- qWarning("QPixmap: Cannot create a QPixmap when no GUI is being used");
- data = 0;
- return;
- }
-
if ((w > 0 && h > 0) || type == QPixmapData::BitmapType)
data = QPixmapData::create(w, h, (QPixmapData::PixelType) type);
else
@@ -657,65 +638,6 @@ int QPixmap::depth() const
pixmap = pixmap.copy(QRect(QPoint(0, 0), size));
\endcode
*/
-#ifdef QT3_SUPPORT
-void QPixmap::resize_helper(const QSize &s)
-{
- int w = s.width();
- int h = s.height();
- if (w < 1 || h < 1) {
- *this = QPixmap();
- return;
- }
-
- if (size() == s)
- return;
-
- // QPixmap.data member may be QRuntimePixmapData so use pixmapData() function to get
- // the actual underlaying runtime pixmap data.
- QPixmapData *pd = pixmapData();
-
- // Create new pixmap
- QPixmap pm(QSize(w, h), pd ? pd->type : QPixmapData::PixmapType);
- bool uninit = false;
-#if defined(Q_WS_X11)
- QX11PixmapData *x11Data = pd && pd->classId() == QPixmapData::X11Class ? static_cast<QX11PixmapData*>(pd) : 0;
- if (x11Data) {
- pm.x11SetScreen(x11Data->xinfo.screen());
- uninit = x11Data->flags & QX11PixmapData::Uninitialized;
- }
-#elif defined(Q_WS_MAC)
- QMacPixmapData *macData = pd && pd->classId() == QPixmapData::MacClass ? static_cast<QMacPixmapData*>(pd) : 0;
- if (macData)
- uninit = macData->uninit;
-#endif
- if (!uninit && !isNull()) {
- // Copy old pixmap
- if (hasAlphaChannel())
- pm.fill(Qt::transparent);
- QPainter p(&pm);
- p.drawPixmap(0, 0, *this, 0, 0, qMin(width(), w), qMin(height(), h));
- }
-
-#if defined(Q_WS_X11)
- if (x11Data && x11Data->x11_mask) {
- QPixmapData *newPd = pm.pixmapData();
- QX11PixmapData *pmData = (newPd && newPd->classId() == QPixmapData::X11Class)
- ? static_cast<QX11PixmapData*>(newPd) : 0;
- if (pmData) {
- pmData->x11_mask = (Qt::HANDLE)XCreatePixmap(X11->display,
- RootWindow(x11Data->xinfo.display(),
- x11Data->xinfo.screen()),
- w, h, 1);
- GC gc = XCreateGC(X11->display, pmData->x11_mask, 0, 0);
- XCopyArea(X11->display, x11Data->x11_mask, pmData->x11_mask, gc, 0, 0,
- qMin(width(), w), qMin(height(), h), 0, 0);
- XFreeGC(X11->display, gc);
- }
- }
-#endif
- *this = pm;
-}
-#endif
/*!
\fn void QPixmap::resize(int width, int height)
@@ -986,21 +908,24 @@ bool QPixmap::doImageIO(QImageWriter *writer, int quality) const
return writer->write(toImage());
}
-
-// The implementation (and documentation) of
-// QPixmap::fill(const QWidget *, const QPoint &)
-// is in qwidget.cpp
-
/*!
- \fn void QPixmap::fill(const QWidget *widget, int x, int y)
+ \fn void QPixmap::fill(const QPaintDevice *device, int x, int y)
\overload
- Fills the pixmap with the \a widget's background color or pixmap.
+ \obsolete
+
+ Fills the pixmap with the \a device's background color or pixmap.
The given point, (\a x, \a y), defines an offset in widget
coordinates to which the pixmap's top-left pixel will be mapped
to.
*/
+void QPixmap::fill(const QPaintDevice *, const QPoint &)
+{
+ qWarning() << "QPixmap::fill(const QPaintDevice *device, const QPoint &offset) is deprecated, ignored";
+}
+
+
/*!
Fills the pixmap with the given \a color.
@@ -1072,6 +997,7 @@ qint64 QPixmap::cacheKey() const
return data->cacheKey();
}
+#if 0
static void sendResizeEvents(QWidget *target)
{
QResizeEvent e(target->size(), QSize());
@@ -1084,9 +1010,10 @@ static void sendResizeEvents(QWidget *target)
sendResizeEvents(child);
}
}
+#endif
/*!
- \fn QPixmap QPixmap::grabWidget(QWidget * widget, const QRect &rectangle)
+ \fn QPixmap QPixmap::grabWidget(QPaintDevice * widget, const QRect &rectangle)
Creates a pixmap and paints the given \a widget, restricted by the
given \a rectangle, in it. If the \a widget has any children, then
@@ -1115,8 +1042,13 @@ static void sendResizeEvents(QWidget *target)
\sa grabWindow()
*/
-QPixmap QPixmap::grabWidget(QWidget * widget, const QRect &rect)
+QPixmap QPixmap::grabWidget(QPaintDevice *, const QRect &)
{
+ // ### Qt5: should we keep or remove this method?
+ // SC solution would be to install a callback form QtWidgets, but ugly.
+ qWarning() << "QPixmap::grabWidget is deprecated, use QWidget::render() instead";
+ return QPixmap();
+#if 0
if (!widget)
return QPixmap();
@@ -1142,6 +1074,7 @@ QPixmap QPixmap::grabWidget(QWidget * widget, const QRect &rect)
widget->d_func()->render(&res, QPoint(), r, QWidget::DrawWindowBackground
| QWidget::DrawChildren | QWidget::IgnoreMask, true);
return res;
+#endif
}
/*!
@@ -1217,7 +1150,6 @@ QPixmap QPixmap::grabWidget(QWidget * widget, const QRect &rect)
graphics system is explicitly enabled.
\sa detach()
- \sa QApplication::setGraphicsSystem()
*/
Qt::HANDLE QPixmap::handle() const
@@ -1232,104 +1164,6 @@ Qt::HANDLE QPixmap::handle() const
#endif
-#ifdef QT3_SUPPORT
-static Qt::ImageConversionFlags colorModeToFlags(QPixmap::ColorMode mode)
-{
- Qt::ImageConversionFlags flags = Qt::AutoColor;
- switch (mode) {
- case QPixmap::Color:
- flags |= Qt::ColorOnly;
- break;
- case QPixmap::Mono:
- flags |= Qt::MonoOnly;
- break;
- default:
- break;// Nothing.
- }
- return flags;
-}
-
-/*!
- Use the constructor that takes a Qt::ImageConversionFlag instead.
-*/
-
-QPixmap::QPixmap(const QString& fileName, const char *format, ColorMode mode)
- : QPaintDevice()
-{
- init(0, 0, QPixmapData::PixmapType);
- if (!qt_pixmap_thread_test())
- return;
-
- load(fileName, format, colorModeToFlags(mode));
-}
-
-/*!
- Constructs a pixmap from the QImage \a image.
-
- Use the static fromImage() function instead.
-*/
-QPixmap::QPixmap(const QImage& image)
- : QPaintDevice()
-{
- init(0, 0, QPixmapData::PixmapType);
- if (!qt_pixmap_thread_test())
- return;
-
- if (data && data->pixelType() == QPixmapData::BitmapType)
- *this = QBitmap::fromImage(image);
- else
- *this = fromImage(image);
-}
-
-/*!
- \overload
-
- Converts the given \a image to a pixmap that is assigned to this
- pixmap.
-
- Use the static fromImage() function instead.
-*/
-
-QPixmap &QPixmap::operator=(const QImage &image)
-{
- if (data && data->pixelType() == QPixmapData::BitmapType)
- *this = QBitmap::fromImage(image);
- else
- *this = fromImage(image);
- return *this;
-}
-
-/*!
- Use the load() function that takes a Qt::ImageConversionFlag instead.
-*/
-
-bool QPixmap::load(const QString &fileName, const char *format, ColorMode mode)
-{
- return load(fileName, format, colorModeToFlags(mode));
-}
-
-/*!
- Use the loadFromData() function that takes a Qt::ImageConversionFlag instead.
-*/
-
-bool QPixmap::loadFromData(const uchar *buf, uint len, const char *format, ColorMode mode)
-{
- return loadFromData(buf, len, format, colorModeToFlags(mode));
-}
-
-/*!
- Use the static fromImage() function instead.
-*/
-bool QPixmap::convertFromImage(const QImage &image, ColorMode mode)
-{
- if (data && data->pixelType() == QPixmapData::BitmapType)
- *this = QBitmap::fromImage(image, colorModeToFlags(mode));
- else
- *this = fromImage(image, colorModeToFlags(mode));
- return !isNull();
-}
-
-#endif
/*****************************************************************************
QPixmap stream functions
@@ -1375,34 +1209,6 @@ QDataStream &operator>>(QDataStream &stream, QPixmap &pixmap)
#endif // QT_NO_DATASTREAM
-#ifdef QT3_SUPPORT
-Q_GUI_EXPORT void copyBlt(QPixmap *dst, int dx, int dy,
- const QPixmap *src, int sx, int sy, int sw, int sh)
-{
- Q_ASSERT_X(dst, "::copyBlt", "Destination pixmap must be non-null");
- Q_ASSERT_X(src, "::copyBlt", "Source pixmap must be non-null");
-
- if (src->hasAlphaChannel()) {
- if (dst->paintEngine()->hasFeature(QPaintEngine::PorterDuff)) {
- QPainter p(dst);
- p.setCompositionMode(QPainter::CompositionMode_Source);
- p.drawPixmap(dx, dy, *src, sx, sy, sw, sh);
- } else {
- QImage image = dst->toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied);
- QPainter p(&image);
- p.setCompositionMode(QPainter::CompositionMode_Source);
- p.drawPixmap(dx, dy, *src, sx, sy, sw, sh);
- p.end();
- *dst = QPixmap::fromImage(image);
- }
- } else {
- QPainter p(dst);
- p.drawPixmap(dx, dy, *src, sx, sy, sw, sh);
- }
-
-}
-#endif
-
/*!
\internal
*/
@@ -1988,7 +1794,7 @@ int QPixmap::defaultDepth()
#elif defined(Q_OS_SYMBIAN)
return S60->screenDepth;
#elif defined(Q_WS_QPA)
- return 32; //LITE: use graphicssystem (we should do that in general)
+ return 32; //LITE: ### use graphicssystem (we should do that in general)
#endif
}
@@ -2080,9 +1886,7 @@ QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags)
if (image.isNull())
return QPixmap();
- QGraphicsSystem* gs = QApplicationPrivate::graphicsSystem();
- QScopedPointer<QPixmapData> data(gs ? gs->createPixmapData(QPixmapData::PixmapType)
- : QGraphicsSystem::createDefaultPixmapData(QPixmapData::PixmapType));
+ QScopedPointer<QPixmapData> data(QGuiApplicationPrivate::platformIntegration()->createPixmapData(QPixmapData::PixmapType));
data->fromImage(image, flags);
return QPixmap(data.take());
}
@@ -2101,9 +1905,7 @@ QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags)
*/
QPixmap QPixmap::fromImageReader(QImageReader *imageReader, Qt::ImageConversionFlags flags)
{
- QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem();
- QScopedPointer<QPixmapData> data(gs ? gs->createPixmapData(QPixmapData::PixmapType)
- : QGraphicsSystem::createDefaultPixmapData(QPixmapData::PixmapType));
+ QScopedPointer<QPixmapData> data(QGuiApplicationPrivate::platformIntegration()->createPixmapData(QPixmapData::PixmapType));
data->fromImageReader(imageReader, flags);
return QPixmap(data.take());
}
diff --git a/src/gui/image/qpixmap.h b/src/gui/image/qpixmap.h
index f2e79c14f4..1341ad2b1b 100644
--- a/src/gui/image/qpixmap.h
+++ b/src/gui/image/qpixmap.h
@@ -103,8 +103,8 @@ public:
static int defaultDepth();
void fill(const QColor &fillColor = Qt::white);
- void fill(const QWidget *widget, const QPoint &ofs);
- inline void fill(const QWidget *widget, int xofs, int yofs) { fill(widget, QPoint(xofs, yofs)); }
+ void fill(const QPaintDevice *device, const QPoint &ofs);
+ inline void fill(const QPaintDevice *device, int xofs, int yofs) { fill(device, QPoint(xofs, yofs)); }
QBitmap mask() const;
void setMask(const QBitmap &);
@@ -122,8 +122,8 @@ public:
QBitmap createMaskFromColor(const QColor &maskColor, Qt::MaskMode mode) const;
static QPixmap grabWindow(WId, int x=0, int y=0, int w=-1, int h=-1);
- static QPixmap grabWidget(QWidget *widget, const QRect &rect);
- static inline QPixmap grabWidget(QWidget *widget, int x=0, int y=0, int w=-1, int h=-1)
+ static QPixmap grabWidget(QPaintDevice *widget, const QRect &rect);
+ static inline QPixmap grabWidget(QPaintDevice *widget, int x=0, int y=0, int w=-1, int h=-1)
{ return grabWidget(widget, QRect(x, y, w, h)); }
@@ -224,26 +224,6 @@ public:
protected:
int metric(PaintDeviceMetric) const;
-#ifdef QT3_SUPPORT
-public:
- enum ColorMode { Auto, Color, Mono };
- QT3_SUPPORT_CONSTRUCTOR QPixmap(const QString& fileName, const char *format, ColorMode mode);
- QT3_SUPPORT bool load(const QString& fileName, const char *format, ColorMode mode);
- QT3_SUPPORT bool loadFromData(const uchar *buf, uint len, const char* format, ColorMode mode);
- QT3_SUPPORT_CONSTRUCTOR QPixmap(const QImage& image);
- QT3_SUPPORT QPixmap &operator=(const QImage &);
- inline QT3_SUPPORT QImage convertToImage() const { return toImage(); }
- QT3_SUPPORT bool convertFromImage(const QImage &, ColorMode mode);
- inline QT3_SUPPORT operator QImage() const { return toImage(); }
- inline QT3_SUPPORT QPixmap xForm(const QMatrix &matrix) const { return transformed(QTransform(matrix)); }
- inline QT3_SUPPORT bool selfMask() const { return false; }
-private:
- void resize_helper(const QSize &s);
-public:
- inline QT3_SUPPORT void resize(const QSize &s) { resize_helper(s); }
- inline QT3_SUPPORT void resize(int width, int height) { resize_helper(QSize(width, height)); }
-#endif
-
private:
QExplicitlySharedDataPointer<QPixmapData> data;
@@ -320,14 +300,6 @@ Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QPixmap &);
Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QPixmap &);
#endif
-/*****************************************************************************
- QPixmap (and QImage) helper functions
-*****************************************************************************/
-#ifdef QT3_SUPPORT
-QT3_SUPPORT Q_GUI_EXPORT void copyBlt(QPixmap *dst, int dx, int dy, const QPixmap *src,
- int sx=0, int sy=0, int sw=-1, int sh=-1);
-#endif // QT3_SUPPORT
-
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp
index e2cd745e7c..da1c8e135d 100644
--- a/src/gui/image/qpixmap_blitter.cpp
+++ b/src/gui/image/qpixmap_blitter.cpp
@@ -44,8 +44,7 @@
#include <qpainter.h>
#include <qimage.h>
-#include <private/qapplication_p.h>
-#include <private/qgraphicssystem_p.h>
+#include <private/qguiapplication_p.h>
#include <private/qblittable_p.h>
#include <private/qdrawhelper_p.h>
@@ -99,7 +98,7 @@ void QBlittablePixmapData::resize(int width, int height)
delete m_engine;
m_engine = 0;
#ifdef Q_WS_QPA
- d = QApplicationPrivate::platformIntegration()->screens().at(0)->depth();
+ d = QGuiApplicationPrivate::platformIntegration()->screens().at(0)->depth();
#endif
w = width;
h = height;
diff --git a/src/gui/image/qpixmap_qpa.cpp b/src/gui/image/qpixmap_qpa.cpp
index 61be2169d0..da301baa19 100644
--- a/src/gui/image/qpixmap_qpa.cpp
+++ b/src/gui/image/qpixmap_qpa.cpp
@@ -40,10 +40,9 @@
****************************************************************************/
#include <qpixmap.h>
-#include <private/qgraphicssystem_p.h>
-#include <private/qapplication_p.h>
+#include <private/qguiapplication_p.h>
QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h)
{
- return QApplicationPrivate::platformIntegration()->grabWindow(window, x, y, w, h);
+ return QGuiApplicationPrivate::platformIntegration()->grabWindow(window, x, y, w, h);
}
diff --git a/src/gui/image/qpixmap_qws.cpp b/src/gui/image/qpixmap_qws.cpp
deleted file mode 100644
index 3c1907089d..0000000000
--- a/src/gui/image/qpixmap_qws.cpp
+++ /dev/null
@@ -1,160 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qpixmap.h>
-#include <qapplication.h>
-#include <qwidget.h>
-#include <qdesktopwidget.h>
-#include <qscreen_qws.h>
-#include <qwsdisplay_qws.h>
-#include <private/qdrawhelper_p.h>
-#include <private/qpixmap_raster_p.h>
-
-
-QT_BEGIN_NAMESPACE
-
-QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h)
-{
- QWidget *widget = QWidget::find(window);
- if (!widget)
- return QPixmap();
-
- QRect grabRect = widget->frameGeometry();
- if (!widget->isWindow())
- grabRect.translate(widget->parentWidget()->mapToGlobal(QPoint()));
- if (w < 0)
- w = widget->width() - x;
- if (h < 0)
- h = widget->height() - y;
- grabRect &= QRect(x, y, w, h).translated(widget->mapToGlobal(QPoint()));
-
- QScreen *screen = qt_screen;
- QDesktopWidget *desktop = QApplication::desktop();
- if (!desktop)
- return QPixmap();
- if (desktop->numScreens() > 1) {
- const int screenNo = desktop->screenNumber(widget);
- if (screenNo != -1)
- screen = qt_screen->subScreens().at(screenNo);
- grabRect = grabRect.translated(-screen->region().boundingRect().topLeft());
- }
-
- if (screen->pixelFormat() == QImage::Format_Invalid) {
- qWarning("QPixmap::grabWindow(): Unable to copy pixels from framebuffer");
- return QPixmap();
- }
-
- if (screen->isTransformed()) {
- const QSize screenSize(screen->width(), screen->height());
- grabRect = screen->mapToDevice(grabRect, screenSize);
- }
-
- QWSDisplay::grab(false);
- QPixmap pixmap;
- QImage img(screen->base(),
- screen->deviceWidth(), screen->deviceHeight(),
- screen->linestep(), screen->pixelFormat());
- img = img.copy(grabRect);
- QWSDisplay::ungrab();
-
- if (screen->isTransformed()) {
- QMatrix matrix;
- switch (screen->transformOrientation()) {
- case 1: matrix.rotate(90); break;
- case 2: matrix.rotate(180); break;
- case 3: matrix.rotate(270); break;
- default: break;
- }
- img = img.transformed(matrix);
- }
-
- if (screen->pixelType() == QScreen::BGRPixel)
- img = img.rgbSwapped();
-
- return QPixmap::fromImage(img);
-}
-
-QRgb* QPixmap::clut() const
-{
- if (data && data->classId() == QPixmapData::RasterClass) {
- const QRasterPixmapData *d = static_cast<const QRasterPixmapData*>(data.data());
- return d->image.colorTable().data();
- }
-
- return 0;
-}
-
-int QPixmap::numCols() const
-{
- return colorCount();
-}
-
-int QPixmap::colorCount() const
-{
- if (data && data->classId() == QPixmapData::RasterClass) {
- const QRasterPixmapData *d = static_cast<const QRasterPixmapData*>(data.data());
- return d->image.colorCount();
- }
-
- return 0;
-}
-
-const uchar* QPixmap::qwsBits() const
-{
- if (data && data->classId() == QPixmapData::RasterClass) {
- const QRasterPixmapData *d = static_cast<const QRasterPixmapData*>(data.data());
- return d->image.bits();
- }
-
- return 0;
-}
-
-int QPixmap::qwsBytesPerLine() const
-{
- if (data && data->classId() == QPixmapData::RasterClass) {
- const QRasterPixmapData *d = static_cast<const QRasterPixmapData*>(data.data());
- return d->image.bytesPerLine();
- }
-
- return 0;
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/image/qpixmap_raster.cpp b/src/gui/image/qpixmap_raster.cpp
index 0a4d921795..b7fe17e537 100644
--- a/src/gui/image/qpixmap_raster.cpp
+++ b/src/gui/image/qpixmap_raster.cpp
@@ -54,7 +54,6 @@
#include <QImageReader>
#include <private/qimage_p.h>
#include <private/qsimd_p.h>
-#include <private/qwidget_p.h>
#include <private/qdrawhelper_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/image/qpixmapdata.cpp b/src/gui/image/qpixmapdata.cpp
index 8222d714dc..a56504ed94 100644
--- a/src/gui/image/qpixmapdata.cpp
+++ b/src/gui/image/qpixmapdata.cpp
@@ -43,8 +43,7 @@
#include <QtCore/qbuffer.h>
#include <QtGui/qbitmap.h>
#include <QtGui/qimagereader.h>
-#include <private/qgraphicssystem_p.h>
-#include <private/qapplication_p.h>
+#include <private/qguiapplication_p.h>
#include <private/qimagepixmapcleanuphooks_p.h>
QT_BEGIN_NAMESPACE
@@ -54,12 +53,7 @@ const uchar qt_pixmap_bit_mask[] = { 0x01, 0x02, 0x04, 0x08,
QPixmapData *QPixmapData::create(int w, int h, PixelType type)
{
- QPixmapData *data;
- QGraphicsSystem* gs = QApplicationPrivate::graphicsSystem();
- if (gs)
- data = gs->createPixmapData(static_cast<QPixmapData::PixelType>(type));
- else
- data = QGraphicsSystem::createDefaultPixmapData(static_cast<QPixmapData::PixelType>(type));
+ QPixmapData *data = QGuiApplicationPrivate::platformIntegration()->createPixmapData(static_cast<QPixmapData::PixelType>(type));
data->resize(w, h);
return data;
}
@@ -95,12 +89,7 @@ QPixmapData::~QPixmapData()
QPixmapData *QPixmapData::createCompatiblePixmapData() const
{
- QPixmapData *d;
- QGraphicsSystem *gs = QApplicationPrivate::graphicsSystem();
- if (gs)
- d = gs->createPixmapData(pixelType());
- else
- d = QGraphicsSystem::createDefaultPixmapData(pixelType());
+ QPixmapData *d = QGuiApplicationPrivate::platformIntegration()->createPixmapData(pixelType());
return d;
}
diff --git a/src/gui/image/qpixmapdatafactory.cpp b/src/gui/image/qpixmapdatafactory.cpp
index ec53dcb9c1..906d8ddd8e 100644
--- a/src/gui/image/qpixmapdatafactory.cpp
+++ b/src/gui/image/qpixmapdatafactory.cpp
@@ -60,8 +60,7 @@
# include <private/qpixmap_s60_p.h>
#endif
-#include "private/qapplication_p.h"
-#include "private/qgraphicssystem_p.h"
+#include "private/qguiapplication_p.h"
QT_BEGIN_NAMESPACE
@@ -76,22 +75,8 @@ public:
QPixmapData* QSimplePixmapDataFactory::create(QPixmapData::PixelType type)
{
- if (QApplicationPrivate::graphicsSystem())
- return QApplicationPrivate::graphicsSystem()->createPixmapData(type);
-
-#if defined(Q_WS_X11)
- return new QX11PixmapData(type);
-#elif defined(Q_WS_WIN)
- return new QRasterPixmapData(type);
-#elif defined(Q_WS_MAC)
- return new QMacPixmapData(type);
-#elif defined(Q_WS_QPA)
- return new QRasterPixmapData(type);
-#elif defined(Q_OS_SYMBIAN)
- return new QS60PixmapData(type);
-#else
-#error QSimplePixmapDataFactory::create() not implemented
-#endif
+ // ### should we always use Raster instead?
+ return QGuiApplicationPrivate::platformIntegration()->createPixmapData(type);
}
Q_GLOBAL_STATIC(QSimplePixmapDataFactory, factory)
diff --git a/src/gui/image/qpixmapfilter.cpp b/src/gui/image/qpixmapfilter.cpp
deleted file mode 100644
index c05afb052e..0000000000
--- a/src/gui/image/qpixmapfilter.cpp
+++ /dev/null
@@ -1,1382 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qglobal.h>
-
-#include <QDebug>
-
-#include "qpainter.h"
-#include "qpixmap.h"
-#include "qpixmapfilter_p.h"
-#include "qvarlengtharray.h"
-
-#include "private/qapplication_p.h"
-#include "private/qgraphicssystem_p.h"
-#include "private/qpaintengineex_p.h"
-#include "private/qpaintengine_raster_p.h"
-#include "qmath.h"
-#include "private/qmath_p.h"
-#include "private/qmemrotate_p.h"
-#include "private/qdrawhelper_p.h"
-
-#ifndef QT_NO_GRAPHICSEFFECT
-QT_BEGIN_NAMESPACE
-
-class QPixmapFilterPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QPixmapFilter)
-public:
- QPixmapFilter::FilterType type;
-};
-
-/*!
- \class QPixmapFilter
- \since 4.5
- \ingroup painting
-
- \brief The QPixmapFilter class provides the basic functionality for
- pixmap filter classes. Pixmap filter can be for example colorize or blur.
-
- QPixmapFilter is the base class for every pixmap filter. QPixmapFilter is
- an abstract class and cannot itself be instantiated. It provides a standard
- interface for filter processing.
-
- \internal
-*/
-
-/*!
- \enum QPixmapFilter::FilterType
-
- \internal
-
- This enum describes the types of filter that can be applied to pixmaps.
-
- \value ConvolutionFilter A filter that is used to calculate the convolution
- of the image with a kernel. See
- QPixmapConvolutionFilter for more information.
- \value ColorizeFilter A filter that is used to change the overall color
- of an image. See QPixmapColorizeFilter for more
- information.
- \value DropShadowFilter A filter that is used to add a drop shadow to an
- image. See QPixmapDropShadowFilter for more
- information.
- \value BlurFilter A filter that is used to blur an image using
- a simple blur radius. See QPixmapBlurFilter
- for more information.
-
- \value UserFilter The first filter type that can be used for
- application-specific purposes.
-*/
-
-
-/*!
- Constructs a default QPixmapFilter with the given \a type.
-
- This constructor should be used when subclassing QPixmapFilter to
- create custom user filters.
-
- \internal
-*/
-QPixmapFilter::QPixmapFilter(FilterType type, QObject *parent)
- : QObject(*new QPixmapFilterPrivate, parent)
-{
- d_func()->type = type;
-}
-
-
-
-/*!
- \internal
-*/
-QPixmapFilter::QPixmapFilter(QPixmapFilterPrivate&d, QPixmapFilter::FilterType type, QObject *parent)
- : QObject(d, parent)
-{
- d_func()->type = type;
-}
-
-
-/*!
- Destroys the pixmap filter.
-
- \internal
-*/
-QPixmapFilter::~QPixmapFilter()
-{
-}
-
-/*!
- Returns the type of the filter. All standard pixmap filter classes
- are associated with a unique value.
-
- \internal
-*/
-QPixmapFilter::FilterType QPixmapFilter::type() const
-{
- Q_D(const QPixmapFilter);
- return d->type;
-}
-
-/*!
- Returns the bounding rectangle that is affected by the pixmap
- filter if the filter is applied to the specified \a rect.
-
- \internal
-*/
-QRectF QPixmapFilter::boundingRectFor(const QRectF &rect) const
-{
- return rect;
-}
-
-/*!
- \fn void QPixmapFilter::draw(QPainter *painter, const QPointF &p, const QPixmap &src, const QRectF& srcRect) const
-
- Uses \a painter to draw filtered result of \a src at the point
- specified by \a p. If \a srcRect is specified the it will
- be used as a source rectangle to only draw a part of the source.
-
- draw() will affect the area which boundingRectFor() returns.
-
- \internal
-*/
-
-/*!
- \class QPixmapConvolutionFilter
- \since 4.5
- \ingroup painting
-
- \brief The QPixmapConvolutionFilter class provides convolution
- filtering for pixmaps.
-
- QPixmapConvolutionFilter implements a convolution pixmap filter,
- which is applied when \l{QPixmapFilter::}{draw()} is called. A
- convolution filter lets you distort an image by setting the values
- of a matrix of qreal values called its
- \l{setConvolutionKernel()}{kernel}. The matrix's values are
- usually between -1.0 and 1.0.
-
- \omit
- In convolution filtering, the pixel value is calculated from the
- neighboring pixels based on the weighting convolution kernel.
- This needs explaining to be useful.
- \endomit
-
- Example:
- \snippet doc/src/snippets/code/src_gui_image_qpixmapfilter.cpp 1
-
- \sa {Pixmap Filters Example}, QPixmapColorizeFilter, QPixmapDropShadowFilter
-
-
- \internal
-*/
-
-class QPixmapConvolutionFilterPrivate : public QPixmapFilterPrivate
-{
-public:
- QPixmapConvolutionFilterPrivate(): convolutionKernel(0), kernelWidth(0), kernelHeight(0), convoluteAlpha(false) {}
- ~QPixmapConvolutionFilterPrivate() {
- delete[] convolutionKernel;
- }
-
- qreal *convolutionKernel;
- int kernelWidth;
- int kernelHeight;
- bool convoluteAlpha;
-};
-
-
-/*!
- Constructs a pixmap convolution filter.
-
- By default there is no convolution kernel.
-
- \internal
-*/
-QPixmapConvolutionFilter::QPixmapConvolutionFilter(QObject *parent)
- : QPixmapFilter(*new QPixmapConvolutionFilterPrivate, ConvolutionFilter, parent)
-{
- Q_D(QPixmapConvolutionFilter);
- d->convoluteAlpha = true;
-}
-
-/*!
- Destructor of pixmap convolution filter.
-
- \internal
-*/
-QPixmapConvolutionFilter::~QPixmapConvolutionFilter()
-{
-}
-
-/*!
- Sets convolution kernel with the given number of \a rows and \a columns.
- Values from \a kernel are copied to internal data structure.
-
- To preserve the intensity of the pixmap, the sum of all the
- values in the convolution kernel should add up to 1.0. A sum
- greater than 1.0 produces a lighter result and a sum less than 1.0
- produces a darker and transparent result.
-
- \internal
-*/
-void QPixmapConvolutionFilter::setConvolutionKernel(const qreal *kernel, int rows, int columns)
-{
- Q_D(QPixmapConvolutionFilter);
- delete [] d->convolutionKernel;
- d->convolutionKernel = new qreal[rows * columns];
- memcpy(d->convolutionKernel, kernel, sizeof(qreal) * rows * columns);
- d->kernelWidth = columns;
- d->kernelHeight = rows;
-}
-
-/*!
- Gets the convolution kernel data.
-
- \internal
-*/
-const qreal *QPixmapConvolutionFilter::convolutionKernel() const
-{
- Q_D(const QPixmapConvolutionFilter);
- return d->convolutionKernel;
-}
-
-/*!
- Gets the number of rows in the convolution kernel.
-
- \internal
-*/
-int QPixmapConvolutionFilter::rows() const
-{
- Q_D(const QPixmapConvolutionFilter);
- return d->kernelHeight;
-}
-
-/*!
- Gets the number of columns in the convolution kernel.
-
- \internal
-*/
-int QPixmapConvolutionFilter::columns() const
-{
- Q_D(const QPixmapConvolutionFilter);
- return d->kernelWidth;
-}
-
-
-/*!
- \internal
-*/
-QRectF QPixmapConvolutionFilter::boundingRectFor(const QRectF &rect) const
-{
- Q_D(const QPixmapConvolutionFilter);
- return rect.adjusted(-d->kernelWidth / 2, -d->kernelHeight / 2, (d->kernelWidth - 1) / 2, (d->kernelHeight - 1) / 2);
-}
-
-// Convolutes the image
-static void convolute(
- QImage *destImage,
- const QPointF &pos,
- const QImage &srcImage,
- const QRectF &srcRect,
- QPainter::CompositionMode mode,
- qreal *kernel,
- int kernelWidth,
- int kernelHeight )
-{
- const QImage processImage = (srcImage.format() != QImage::Format_ARGB32_Premultiplied ) ? srcImage.convertToFormat(QImage::Format_ARGB32_Premultiplied) : srcImage;
- // TODO: support also other formats directly without copying
-
- int *fixedKernel = new int[kernelWidth*kernelHeight];
- for(int i = 0; i < kernelWidth*kernelHeight; i++)
- {
- fixedKernel[i] = (int)(65536 * kernel[i]);
- }
- QRectF trect = srcRect.isNull() ? processImage.rect() : srcRect;
- trect.moveTo(pos);
- QRectF bounded = trect.adjusted(-kernelWidth / 2, -kernelHeight / 2, (kernelWidth - 1) / 2, (kernelHeight - 1) / 2);
- QRect rect = bounded.toAlignedRect();
- QRect targetRect = rect.intersected(destImage->rect());
-
- QRectF srect = srcRect.isNull() ? processImage.rect() : srcRect;
- QRectF sbounded = srect.adjusted(-kernelWidth / 2, -kernelHeight / 2, (kernelWidth - 1) / 2, (kernelHeight - 1) / 2);
- QPoint srcStartPoint = sbounded.toAlignedRect().topLeft()+(targetRect.topLeft()-rect.topLeft());
-
- const uint *sourceStart = (uint*)processImage.scanLine(0);
- uint *outputStart = (uint*)destImage->scanLine(0);
-
- int yk = srcStartPoint.y();
- for (int y = targetRect.top(); y <= targetRect.bottom(); y++) {
- uint* output = outputStart + (destImage->bytesPerLine()/sizeof(uint))*y+targetRect.left();
- int xk = srcStartPoint.x();
- for(int x = targetRect.left(); x <= targetRect.right(); x++) {
- int r = 0;
- int g = 0;
- int b = 0;
- int a = 0;
-
- // some out of bounds pre-checking to avoid inner-loop ifs
- int kernely = -kernelHeight/2;
- int starty = 0;
- int endy = kernelHeight;
- if(yk+kernely+endy >= srcImage.height())
- endy = kernelHeight-((yk+kernely+endy)-srcImage.height())-1;
- if(yk+kernely < 0)
- starty = -(yk+kernely);
-
- int kernelx = -kernelWidth/2;
- int startx = 0;
- int endx = kernelWidth;
- if(xk+kernelx+endx >= srcImage.width())
- endx = kernelWidth-((xk+kernelx+endx)-srcImage.width())-1;
- if(xk+kernelx < 0)
- startx = -(xk+kernelx);
-
- for (int ys = starty; ys < endy; ys ++) {
- const uint *pix = sourceStart + (processImage.bytesPerLine()/sizeof(uint))*(yk+kernely+ys) + ((xk+kernelx+startx));
- const uint *endPix = pix+endx-startx;
- int kernelPos = ys*kernelWidth+startx;
- while (pix < endPix) {
- int factor = fixedKernel[kernelPos++];
- a += (((*pix) & 0xff000000)>>24) * factor;
- r += (((*pix) & 0x00ff0000)>>16) * factor;
- g += (((*pix) & 0x0000ff00)>>8 ) * factor;
- b += (((*pix) & 0x000000ff) ) * factor;
- pix++;
- }
- }
-
- r = qBound((int)0, r >> 16, (int)255);
- g = qBound((int)0, g >> 16, (int)255);
- b = qBound((int)0, b >> 16, (int)255);
- a = qBound((int)0, a >> 16, (int)255);
- // composition mode checking could be moved outside of loop
- if(mode == QPainter::CompositionMode_Source) {
- uint color = (a<<24)+(r<<16)+(g<<8)+b;
- *output++ = color;
- } else {
- uint current = *output;
- uchar ca = (current&0xff000000)>>24;
- uchar cr = (current&0x00ff0000)>>16;
- uchar cg = (current&0x0000ff00)>>8;
- uchar cb = (current&0x000000ff);
- uint color =
- (((ca*(255-a) >> 8)+a) << 24)+
- (((cr*(255-a) >> 8)+r) << 16)+
- (((cg*(255-a) >> 8)+g) << 8)+
- (((cb*(255-a) >> 8)+b));
- *output++ = color;;
- }
- xk++;
- }
- yk++;
- }
- delete[] fixedKernel;
-}
-
-/*!
- \internal
-*/
-void QPixmapConvolutionFilter::draw(QPainter *painter, const QPointF &p, const QPixmap &src, const QRectF& srcRect) const
-{
- Q_D(const QPixmapConvolutionFilter);
- if (!painter->isActive())
- return;
-
- if(d->kernelWidth<=0 || d->kernelHeight <= 0)
- return;
-
- if (src.isNull())
- return;
-
- QPixmapFilter *filter = painter->paintEngine() && painter->paintEngine()->isExtended() ?
- static_cast<QPaintEngineEx *>(painter->paintEngine())->pixmapFilter(type(), this) : 0;
- QPixmapConvolutionFilter *convolutionFilter = static_cast<QPixmapConvolutionFilter*>(filter);
- if (convolutionFilter) {
- convolutionFilter->setConvolutionKernel(d->convolutionKernel, d->kernelWidth, d->kernelHeight);
- convolutionFilter->d_func()->convoluteAlpha = d->convoluteAlpha;
- convolutionFilter->draw(painter, p, src, srcRect);
- return;
- }
-
- // falling back to raster implementation
-
- QImage *target = 0;
- if (painter->paintEngine()->paintDevice()->devType() == QInternal::Image) {
- target = static_cast<QImage *>(painter->paintEngine()->paintDevice());
-
- QTransform mat = painter->combinedTransform();
-
- if (mat.type() > QTransform::TxTranslate) {
- // Disabled because of transformation...
- target = 0;
- } else {
- QRasterPaintEngine *pe = static_cast<QRasterPaintEngine *>(painter->paintEngine());
- if (pe->clipType() == QRasterPaintEngine::ComplexClip)
- // disabled because of complex clipping...
- target = 0;
- else {
- QRectF clip = pe->clipBoundingRect();
- QRectF rect = boundingRectFor(srcRect.isEmpty() ? src.rect() : srcRect);
- QTransform x = painter->deviceTransform();
- if (!clip.contains(rect.translated(x.dx() + p.x(), x.dy() + p.y()))) {
- target = 0;
- }
-
- }
- }
- }
-
- if (target) {
- QTransform x = painter->deviceTransform();
- QPointF offset(x.dx(), x.dy());
-
- convolute(target, p+offset, src.toImage(), srcRect, QPainter::CompositionMode_SourceOver, d->convolutionKernel, d->kernelWidth, d->kernelHeight);
- } else {
- QRect srect = srcRect.isNull() ? src.rect() : srcRect.toRect();
- QRect rect = boundingRectFor(srect).toRect();
- QImage result = QImage(rect.size(), QImage::Format_ARGB32_Premultiplied);
- QPoint offset = srect.topLeft() - rect.topLeft();
- convolute(&result,
- offset,
- src.toImage(),
- srect,
- QPainter::CompositionMode_Source,
- d->convolutionKernel,
- d->kernelWidth,
- d->kernelHeight);
- painter->drawImage(p - offset, result);
- }
-}
-
-/*!
- \class QPixmapBlurFilter
- \since 4.6
- \ingroup multimedia
-
- \brief The QPixmapBlurFilter class provides blur filtering
- for pixmaps.
-
- QPixmapBlurFilter implements a blur pixmap filter,
- which is applied when \l{QPixmapFilter::}{draw()} is called.
-
- The filter lets you specialize the radius of the blur as well
- as hints as to whether to prefer performance or quality.
-
- By default, the blur effect is produced by applying an exponential
- filter generated from the specified blurRadius(). Paint engines
- may override this with a custom blur that is faster on the
- underlying hardware.
-
- \sa {Pixmap Filters Example}, QPixmapConvolutionFilter, QPixmapDropShadowFilter
-
- \internal
-*/
-
-class QPixmapBlurFilterPrivate : public QPixmapFilterPrivate
-{
-public:
- QPixmapBlurFilterPrivate() : radius(5), hints(QGraphicsBlurEffect::PerformanceHint) {}
-
- qreal radius;
- QGraphicsBlurEffect::BlurHints hints;
-};
-
-
-/*!
- Constructs a pixmap blur filter.
-
- \internal
-*/
-QPixmapBlurFilter::QPixmapBlurFilter(QObject *parent)
- : QPixmapFilter(*new QPixmapBlurFilterPrivate, BlurFilter, parent)
-{
-}
-
-/*!
- Destructor of pixmap blur filter.
-
- \internal
-*/
-QPixmapBlurFilter::~QPixmapBlurFilter()
-{
-}
-
-/*!
- Sets the radius of the blur filter. Higher radius produces increased blurriness.
-
- \internal
-*/
-void QPixmapBlurFilter::setRadius(qreal radius)
-{
- Q_D(QPixmapBlurFilter);
- d->radius = radius;
-}
-
-/*!
- Gets the radius of the blur filter.
-
- \internal
-*/
-qreal QPixmapBlurFilter::radius() const
-{
- Q_D(const QPixmapBlurFilter);
- return d->radius;
-}
-
-/*!
- Setting the blur hints to PerformanceHint causes the implementation
- to trade off visual quality to blur the image faster. Setting the
- blur hints to QualityHint causes the implementation to improve
- visual quality at the expense of speed.
-
- AnimationHint causes the implementation to optimize for animating
- the blur radius, possibly by caching blurred versions of the source
- pixmap.
-
- The implementation is free to ignore this value if it only has a single
- blur algorithm.
-
- \internal
-*/
-void QPixmapBlurFilter::setBlurHints(QGraphicsBlurEffect::BlurHints hints)
-{
- Q_D(QPixmapBlurFilter);
- d->hints = hints;
-}
-
-/*!
- Gets the blur hints of the blur filter.
-
- \internal
-*/
-QGraphicsBlurEffect::BlurHints QPixmapBlurFilter::blurHints() const
-{
- Q_D(const QPixmapBlurFilter);
- return d->hints;
-}
-
-const qreal radiusScale = qreal(2.5);
-
-/*!
- \internal
-*/
-QRectF QPixmapBlurFilter::boundingRectFor(const QRectF &rect) const
-{
- Q_D(const QPixmapBlurFilter);
- const qreal delta = radiusScale * d->radius + 1;
- return rect.adjusted(-delta, -delta, delta, delta);
-}
-
-template <int shift>
-inline int qt_static_shift(int value)
-{
- if (shift == 0)
- return value;
- else if (shift > 0)
- return value << (uint(shift) & 0x1f);
- else
- return value >> (uint(-shift) & 0x1f);
-}
-
-template<int aprec, int zprec>
-inline void qt_blurinner(uchar *bptr, int &zR, int &zG, int &zB, int &zA, int alpha)
-{
- QRgb *pixel = (QRgb *)bptr;
-
-#define Z_MASK (0xff << zprec)
- const int A_zprec = qt_static_shift<zprec - 24>(*pixel) & Z_MASK;
- const int R_zprec = qt_static_shift<zprec - 16>(*pixel) & Z_MASK;
- const int G_zprec = qt_static_shift<zprec - 8>(*pixel) & Z_MASK;
- const int B_zprec = qt_static_shift<zprec>(*pixel) & Z_MASK;
-#undef Z_MASK
-
- const int zR_zprec = zR >> aprec;
- const int zG_zprec = zG >> aprec;
- const int zB_zprec = zB >> aprec;
- const int zA_zprec = zA >> aprec;
-
- zR += alpha * (R_zprec - zR_zprec);
- zG += alpha * (G_zprec - zG_zprec);
- zB += alpha * (B_zprec - zB_zprec);
- zA += alpha * (A_zprec - zA_zprec);
-
-#define ZA_MASK (0xff << (zprec + aprec))
- *pixel =
- qt_static_shift<24 - zprec - aprec>(zA & ZA_MASK)
- | qt_static_shift<16 - zprec - aprec>(zR & ZA_MASK)
- | qt_static_shift<8 - zprec - aprec>(zG & ZA_MASK)
- | qt_static_shift<-zprec - aprec>(zB & ZA_MASK);
-#undef ZA_MASK
-}
-
-const int alphaIndex = (QSysInfo::ByteOrder == QSysInfo::BigEndian ? 0 : 3);
-
-template<int aprec, int zprec>
-inline void qt_blurinner_alphaOnly(uchar *bptr, int &z, int alpha)
-{
- const int A_zprec = int(*(bptr)) << zprec;
- const int z_zprec = z >> aprec;
- z += alpha * (A_zprec - z_zprec);
- *(bptr) = z >> (zprec + aprec);
-}
-
-template<int aprec, int zprec, bool alphaOnly>
-inline void qt_blurrow(QImage & im, int line, int alpha)
-{
- uchar *bptr = im.scanLine(line);
-
- int zR = 0, zG = 0, zB = 0, zA = 0;
-
- if (alphaOnly && im.format() != QImage::Format_Indexed8)
- bptr += alphaIndex;
-
- const int stride = im.depth() >> 3;
- const int im_width = im.width();
- for (int index = 0; index < im_width; ++index) {
- if (alphaOnly)
- qt_blurinner_alphaOnly<aprec, zprec>(bptr, zA, alpha);
- else
- qt_blurinner<aprec, zprec>(bptr, zR, zG, zB, zA, alpha);
- bptr += stride;
- }
-
- bptr -= stride;
-
- for (int index = im_width - 2; index >= 0; --index) {
- bptr -= stride;
- if (alphaOnly)
- qt_blurinner_alphaOnly<aprec, zprec>(bptr, zA, alpha);
- else
- qt_blurinner<aprec, zprec>(bptr, zR, zG, zB, zA, alpha);
- }
-}
-
-/*
-* expblur(QImage &img, int radius)
-*
-* Based on exponential blur algorithm by Jani Huhtanen
-*
-* In-place blur of image 'img' with kernel
-* of approximate radius 'radius'.
-*
-* Blurs with two sided exponential impulse
-* response.
-*
-* aprec = precision of alpha parameter
-* in fixed-point format 0.aprec
-*
-* zprec = precision of state parameters
-* zR,zG,zB and zA in fp format 8.zprec
-*/
-template <int aprec, int zprec, bool alphaOnly>
-void expblur(QImage &img, qreal radius, bool improvedQuality = false, int transposed = 0)
-{
- // halve the radius if we're using two passes
- if (improvedQuality)
- radius *= qreal(0.5);
-
- Q_ASSERT(img.format() == QImage::Format_ARGB32_Premultiplied
- || img.format() == QImage::Format_RGB32
- || img.format() == QImage::Format_Indexed8);
-
- // choose the alpha such that pixels at radius distance from a fully
- // saturated pixel will have an alpha component of no greater than
- // the cutOffIntensity
- const qreal cutOffIntensity = 2;
- int alpha = radius <= qreal(1e-5)
- ? ((1 << aprec)-1)
- : qRound((1<<aprec)*(1 - qPow(cutOffIntensity * (1 / qreal(255)), 1 / radius)));
-
- int img_height = img.height();
- for (int row = 0; row < img_height; ++row) {
- for (int i = 0; i <= int(improvedQuality); ++i)
- qt_blurrow<aprec, zprec, alphaOnly>(img, row, alpha);
- }
-
- QImage temp(img.height(), img.width(), img.format());
- if (transposed >= 0) {
- if (img.depth() == 8) {
- qt_memrotate270(reinterpret_cast<const quint8*>(img.bits()),
- img.width(), img.height(), img.bytesPerLine(),
- reinterpret_cast<quint8*>(temp.bits()),
- temp.bytesPerLine());
- } else {
- qt_memrotate270(reinterpret_cast<const quint32*>(img.bits()),
- img.width(), img.height(), img.bytesPerLine(),
- reinterpret_cast<quint32*>(temp.bits()),
- temp.bytesPerLine());
- }
- } else {
- if (img.depth() == 8) {
- qt_memrotate90(reinterpret_cast<const quint8*>(img.bits()),
- img.width(), img.height(), img.bytesPerLine(),
- reinterpret_cast<quint8*>(temp.bits()),
- temp.bytesPerLine());
- } else {
- qt_memrotate90(reinterpret_cast<const quint32*>(img.bits()),
- img.width(), img.height(), img.bytesPerLine(),
- reinterpret_cast<quint32*>(temp.bits()),
- temp.bytesPerLine());
- }
- }
-
- img_height = temp.height();
- for (int row = 0; row < img_height; ++row) {
- for (int i = 0; i <= int(improvedQuality); ++i)
- qt_blurrow<aprec, zprec, alphaOnly>(temp, row, alpha);
- }
-
- if (transposed == 0) {
- if (img.depth() == 8) {
- qt_memrotate90(reinterpret_cast<const quint8*>(temp.bits()),
- temp.width(), temp.height(), temp.bytesPerLine(),
- reinterpret_cast<quint8*>(img.bits()),
- img.bytesPerLine());
- } else {
- qt_memrotate90(reinterpret_cast<const quint32*>(temp.bits()),
- temp.width(), temp.height(), temp.bytesPerLine(),
- reinterpret_cast<quint32*>(img.bits()),
- img.bytesPerLine());
- }
- } else {
- img = temp;
- }
-}
-#define AVG(a,b) ( ((((a)^(b)) & 0xfefefefeUL) >> 1) + ((a)&(b)) )
-#define AVG16(a,b) ( ((((a)^(b)) & 0xf7deUL) >> 1) + ((a)&(b)) )
-
-Q_GUI_EXPORT QImage qt_halfScaled(const QImage &source)
-{
- if (source.width() < 2 || source.height() < 2)
- return QImage();
-
- QImage srcImage = source;
-
- if (source.format() == QImage::Format_Indexed8) {
- // assumes grayscale
- QImage dest(source.width() / 2, source.height() / 2, srcImage.format());
-
- const uchar *src = reinterpret_cast<const uchar*>(const_cast<const QImage &>(srcImage).bits());
- int sx = srcImage.bytesPerLine();
- int sx2 = sx << 1;
-
- uchar *dst = reinterpret_cast<uchar*>(dest.bits());
- int dx = dest.bytesPerLine();
- int ww = dest.width();
- int hh = dest.height();
-
- for (int y = hh; y; --y, dst += dx, src += sx2) {
- const uchar *p1 = src;
- const uchar *p2 = src + sx;
- uchar *q = dst;
- for (int x = ww; x; --x, ++q, p1 += 2, p2 += 2)
- *q = ((int(p1[0]) + int(p1[1]) + int(p2[0]) + int(p2[1])) + 2) >> 2;
- }
-
- return dest;
- } else if (source.format() == QImage::Format_ARGB8565_Premultiplied) {
- QImage dest(source.width() / 2, source.height() / 2, srcImage.format());
-
- const uchar *src = reinterpret_cast<const uchar*>(const_cast<const QImage &>(srcImage).bits());
- int sx = srcImage.bytesPerLine();
- int sx2 = sx << 1;
-
- uchar *dst = reinterpret_cast<uchar*>(dest.bits());
- int dx = dest.bytesPerLine();
- int ww = dest.width();
- int hh = dest.height();
-
- for (int y = hh; y; --y, dst += dx, src += sx2) {
- const uchar *p1 = src;
- const uchar *p2 = src + sx;
- uchar *q = dst;
- for (int x = ww; x; --x, q += 3, p1 += 6, p2 += 6) {
- // alpha
- q[0] = AVG(AVG(p1[0], p1[3]), AVG(p2[0], p2[3]));
- // rgb
- const quint16 p16_1 = (p1[2] << 8) | p1[1];
- const quint16 p16_2 = (p1[5] << 8) | p1[4];
- const quint16 p16_3 = (p2[2] << 8) | p2[1];
- const quint16 p16_4 = (p2[5] << 8) | p2[4];
- const quint16 result = AVG16(AVG16(p16_1, p16_2), AVG16(p16_3, p16_4));
- q[1] = result & 0xff;
- q[2] = result >> 8;
- }
- }
-
- return dest;
- } else if (source.format() != QImage::Format_ARGB32_Premultiplied
- && source.format() != QImage::Format_RGB32)
- {
- srcImage = source.convertToFormat(QImage::Format_ARGB32_Premultiplied);
- }
-
- QImage dest(source.width() / 2, source.height() / 2, srcImage.format());
-
- const quint32 *src = reinterpret_cast<const quint32*>(const_cast<const QImage &>(srcImage).bits());
- int sx = srcImage.bytesPerLine() >> 2;
- int sx2 = sx << 1;
-
- quint32 *dst = reinterpret_cast<quint32*>(dest.bits());
- int dx = dest.bytesPerLine() >> 2;
- int ww = dest.width();
- int hh = dest.height();
-
- for (int y = hh; y; --y, dst += dx, src += sx2) {
- const quint32 *p1 = src;
- const quint32 *p2 = src + sx;
- quint32 *q = dst;
- for (int x = ww; x; --x, q++, p1 += 2, p2 += 2)
- *q = AVG(AVG(p1[0], p1[1]), AVG(p2[0], p2[1]));
- }
-
- return dest;
-}
-
-Q_GUI_EXPORT void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0)
-{
- if (blurImage.format() != QImage::Format_ARGB32_Premultiplied
- && blurImage.format() != QImage::Format_RGB32)
- {
- blurImage = blurImage.convertToFormat(QImage::Format_ARGB32_Premultiplied);
- }
-
- qreal scale = 1;
- if (radius >= 4 && blurImage.width() >= 2 && blurImage.height() >= 2) {
- blurImage = qt_halfScaled(blurImage);
- scale = 2;
- radius *= qreal(0.5);
- }
-
- if (alphaOnly)
- expblur<12, 10, true>(blurImage, radius, quality, transposed);
- else
- expblur<12, 10, false>(blurImage, radius, quality, transposed);
-
- if (p) {
- p->scale(scale, scale);
- p->setRenderHint(QPainter::SmoothPixmapTransform);
- p->drawImage(QRect(0, 0, blurImage.width(), blurImage.height()), blurImage);
- }
-}
-
-Q_GUI_EXPORT void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed = 0)
-{
- if (blurImage.format() == QImage::Format_Indexed8)
- expblur<12, 10, true>(blurImage, radius, quality, transposed);
- else
- expblur<12, 10, false>(blurImage, radius, quality, transposed);
-}
-
-Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale);
-
-/*!
- \internal
-*/
-void QPixmapBlurFilter::draw(QPainter *painter, const QPointF &p, const QPixmap &src, const QRectF &rect) const
-{
- Q_D(const QPixmapBlurFilter);
- if (!painter->isActive())
- return;
-
- if (src.isNull())
- return;
-
- QRectF srcRect = rect;
- if (srcRect.isNull())
- srcRect = src.rect();
-
- if (d->radius <= 1) {
- painter->drawPixmap(srcRect.translated(p), src, srcRect);
- return;
- }
-
- qreal scaledRadius = radiusScale * d->radius;
- qreal scale;
- if (qt_scaleForTransform(painter->transform(), &scale))
- scaledRadius /= scale;
-
- QPixmapFilter *filter = painter->paintEngine() && painter->paintEngine()->isExtended() ?
- static_cast<QPaintEngineEx *>(painter->paintEngine())->pixmapFilter(type(), this) : 0;
- QPixmapBlurFilter *blurFilter = static_cast<QPixmapBlurFilter*>(filter);
- if (blurFilter) {
- blurFilter->setRadius(scaledRadius);
- blurFilter->setBlurHints(d->hints);
- blurFilter->draw(painter, p, src, srcRect);
- return;
- }
-
- QImage srcImage;
- QImage destImage;
-
- if (srcRect == src.rect()) {
- srcImage = src.toImage();
- } else {
- QRect rect = srcRect.toAlignedRect().intersected(src.rect());
- srcImage = src.copy(rect).toImage();
- }
-
- QTransform transform = painter->worldTransform();
- painter->translate(p);
- qt_blurImage(painter, srcImage, scaledRadius, (d->hints & QGraphicsBlurEffect::QualityHint), false);
- painter->setWorldTransform(transform);
-}
-
-// grayscales the image to dest (could be same). If rect isn't defined
-// destination image size is used to determine the dimension of grayscaling
-// process.
-static void grayscale(const QImage &image, QImage &dest, const QRect& rect = QRect())
-{
- QRect destRect = rect;
- QRect srcRect = rect;
- if (rect.isNull()) {
- srcRect = dest.rect();
- destRect = dest.rect();
- }
- if (&image != &dest) {
- destRect.moveTo(QPoint(0, 0));
- }
-
- unsigned int *data = (unsigned int *)image.bits();
- unsigned int *outData = (unsigned int *)dest.bits();
-
- if (dest.size() == image.size() && image.rect() == srcRect) {
- // a bit faster loop for grayscaling everything
- int pixels = dest.width() * dest.height();
- for (int i = 0; i < pixels; ++i) {
- int val = qGray(data[i]);
- outData[i] = qRgba(val, val, val, qAlpha(data[i]));
- }
- } else {
- int yd = destRect.top();
- for (int y = srcRect.top(); y <= srcRect.bottom() && y < image.height(); y++) {
- data = (unsigned int*)image.scanLine(y);
- outData = (unsigned int*)dest.scanLine(yd++);
- int xd = destRect.left();
- for (int x = srcRect.left(); x <= srcRect.right() && x < image.width(); x++) {
- int val = qGray(data[x]);
- outData[xd++] = qRgba(val, val, val, qAlpha(data[x]));
- }
- }
- }
-}
-
-/*!
- \class QPixmapColorizeFilter
- \since 4.5
- \ingroup painting
-
- \brief The QPixmapColorizeFilter class provides colorizing
- filtering for pixmaps.
-
- A colorize filter gives the pixmap a tint of its color(). The
- filter first grayscales the pixmap and then converts those to
- colorized values using QPainter::CompositionMode_Screen with the
- chosen color. The alpha-channel is not changed.
-
- Example:
- \snippet doc/src/snippets/code/src_gui_image_qpixmapfilter.cpp 0
-
- \sa QPainter::CompositionMode
-
- \internal
-*/
-class QPixmapColorizeFilterPrivate : public QPixmapFilterPrivate
-{
- Q_DECLARE_PUBLIC(QPixmapColorizeFilter)
-public:
- QColor color;
- qreal strength;
- quint32 opaque : 1;
- quint32 alphaBlend : 1;
- quint32 padding : 30;
-};
-
-/*!
- Constructs an pixmap colorize filter.
-
- Default color value for colorizing is QColor(0, 0, 192).
-
- \internal
-*/
-QPixmapColorizeFilter::QPixmapColorizeFilter(QObject *parent)
- : QPixmapFilter(*new QPixmapColorizeFilterPrivate, ColorizeFilter, parent)
-{
- Q_D(QPixmapColorizeFilter);
- d->color = QColor(0, 0, 192);
- d->strength = qreal(1);
- d->opaque = true;
- d->alphaBlend = false;
-}
-
-/*!
- Gets the color of the colorize filter.
-
- \internal
-*/
-QColor QPixmapColorizeFilter::color() const
-{
- Q_D(const QPixmapColorizeFilter);
- return d->color;
-}
-
-/*!
- Sets the color of the colorize filter to the \a color specified.
-
- \internal
-*/
-void QPixmapColorizeFilter::setColor(const QColor &color)
-{
- Q_D(QPixmapColorizeFilter);
- d->color = color;
-}
-
-/*!
- Gets the strength of the colorize filter, 1.0 means full colorized while
- 0.0 equals to no filtering at all.
-
- \internal
-*/
-qreal QPixmapColorizeFilter::strength() const
-{
- Q_D(const QPixmapColorizeFilter);
- return d->strength;
-}
-
-/*!
- Sets the strength of the colorize filter to \a strength.
-
- \internal
-*/
-void QPixmapColorizeFilter::setStrength(qreal strength)
-{
- Q_D(QPixmapColorizeFilter);
- d->strength = qBound(qreal(0), strength, qreal(1));
- d->opaque = !qFuzzyIsNull(d->strength);
- d->alphaBlend = !qFuzzyIsNull(d->strength - 1);
-}
-
-/*!
- \internal
-*/
-void QPixmapColorizeFilter::draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect) const
-{
- Q_D(const QPixmapColorizeFilter);
-
- if (src.isNull())
- return;
-
- QPixmapFilter *filter = painter->paintEngine() && painter->paintEngine()->isExtended() ?
- static_cast<QPaintEngineEx *>(painter->paintEngine())->pixmapFilter(type(), this) : 0;
- QPixmapColorizeFilter *colorizeFilter = static_cast<QPixmapColorizeFilter*>(filter);
- if (colorizeFilter) {
- colorizeFilter->setColor(d->color);
- colorizeFilter->setStrength(d->strength);
- colorizeFilter->draw(painter, dest, src, srcRect);
- return;
- }
-
- // falling back to raster implementation
-
- if (!d->opaque) {
- painter->drawPixmap(dest, src, srcRect);
- return;
- }
-
- QImage srcImage;
- QImage destImage;
-
- if (srcRect.isNull()) {
- srcImage = src.toImage();
- srcImage = srcImage.convertToFormat(srcImage.hasAlphaChannel() ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32);
- destImage = QImage(srcImage.size(), srcImage.format());
- } else {
- QRect rect = srcRect.toAlignedRect().intersected(src.rect());
-
- srcImage = src.copy(rect).toImage();
- srcImage = srcImage.convertToFormat(srcImage.hasAlphaChannel() ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32);
- destImage = QImage(rect.size(), srcImage.format());
- }
-
- // do colorizing
- QPainter destPainter(&destImage);
- grayscale(srcImage, destImage, srcImage.rect());
- destPainter.setCompositionMode(QPainter::CompositionMode_Screen);
- destPainter.fillRect(srcImage.rect(), d->color);
- destPainter.end();
-
- if (d->alphaBlend) {
- // alpha blending srcImage and destImage
- QImage buffer = srcImage;
- QPainter bufPainter(&buffer);
- bufPainter.setOpacity(d->strength);
- bufPainter.drawImage(0, 0, destImage);
- bufPainter.end();
- destImage = buffer;
- }
-
- if (srcImage.hasAlphaChannel())
- destImage.setAlphaChannel(srcImage.alphaChannel());
-
- painter->drawImage(dest, destImage);
-}
-
-class QPixmapDropShadowFilterPrivate : public QPixmapFilterPrivate
-{
-public:
- QPixmapDropShadowFilterPrivate()
- : offset(8, 8), color(63, 63, 63, 180), radius(1) {}
-
- QPointF offset;
- QColor color;
- qreal radius;
-};
-
-/*!
- \class QPixmapDropShadowFilter
- \since 4.5
- \ingroup painting
-
- \brief The QPixmapDropShadowFilter class is a convenience class
- for drawing pixmaps with drop shadows.
-
- The drop shadow is produced by taking a copy of the source pixmap
- and applying a color to the copy using a
- QPainter::CompositionMode_DestinationIn operation. This produces a
- homogeneously-colored pixmap which is then drawn using a
- QPixmapConvolutionFilter at an offset. The original pixmap is
- drawn on top.
-
- The QPixmapDropShadowFilter class provides some customization
- options to specify how the drop shadow should appear. The color of
- the drop shadow can be modified using the setColor() function, the
- drop shadow offset can be modified using the setOffset() function,
- and the blur radius of the drop shadow can be changed through the
- setBlurRadius() function.
-
- By default, the drop shadow is a dark gray shadow, blurred with a
- radius of 1 at an offset of 8 pixels towards the lower right.
-
- Example:
- \snippet doc/src/snippets/code/src_gui_image_qpixmapfilter.cpp 2
-
- \sa QPixmapColorizeFilter, QPixmapConvolutionFilter
-
- \internal
- */
-
-/*!
- Constructs drop shadow filter.
-
- \internal
-*/
-QPixmapDropShadowFilter::QPixmapDropShadowFilter(QObject *parent)
- : QPixmapFilter(*new QPixmapDropShadowFilterPrivate, DropShadowFilter, parent)
-{
-}
-
-/*!
- Destroys drop shadow filter.
-
- \internal
-*/
-QPixmapDropShadowFilter::~QPixmapDropShadowFilter()
-{
-}
-
-/*!
- Returns the radius in pixels of the blur on the drop shadow.
-
- A smaller radius results in a sharper shadow.
-
- \sa color(), offset()
-
- \internal
-*/
-qreal QPixmapDropShadowFilter::blurRadius() const
-{
- Q_D(const QPixmapDropShadowFilter);
- return d->radius;
-}
-
-/*!
- Sets the radius in pixels of the blur on the drop shadow to the \a radius specified.
-
- Using a smaller radius results in a sharper shadow.
-
- \sa setColor(), setOffset()
-
- \internal
-*/
-void QPixmapDropShadowFilter::setBlurRadius(qreal radius)
-{
- Q_D(QPixmapDropShadowFilter);
- d->radius = radius;
-}
-
-/*!
- Returns the color of the drop shadow.
-
- \sa blurRadius(), offset()
-
- \internal
-*/
-QColor QPixmapDropShadowFilter::color() const
-{
- Q_D(const QPixmapDropShadowFilter);
- return d->color;
-}
-
-/*!
- Sets the color of the drop shadow to the \a color specified.
-
- \sa setBlurRadius(), setOffset()
-
- \internal
-*/
-void QPixmapDropShadowFilter::setColor(const QColor &color)
-{
- Q_D(QPixmapDropShadowFilter);
- d->color = color;
-}
-
-/*!
- Returns the shadow offset in pixels.
-
- \sa blurRadius(), color()
-
- \internal
-*/
-QPointF QPixmapDropShadowFilter::offset() const
-{
- Q_D(const QPixmapDropShadowFilter);
- return d->offset;
-}
-
-/*!
- Sets the shadow offset in pixels to the \a offset specified.
-
- \sa setBlurRadius(), setColor()
-
- \internal
-*/
-void QPixmapDropShadowFilter::setOffset(const QPointF &offset)
-{
- Q_D(QPixmapDropShadowFilter);
- d->offset = offset;
-}
-
-/*!
- \fn void QPixmapDropShadowFilter::setOffset(qreal dx, qreal dy)
- \overload
-
- Sets the shadow offset in pixels to be the displacement specified by the
- horizontal \a dx and vertical \a dy coordinates.
-
- \sa setBlurRadius(), setColor()
-
- \internal
-*/
-
-/*!
- \internal
- */
-QRectF QPixmapDropShadowFilter::boundingRectFor(const QRectF &rect) const
-{
- Q_D(const QPixmapDropShadowFilter);
- return rect.united(rect.translated(d->offset).adjusted(-d->radius, -d->radius, d->radius, d->radius));
-}
-
-/*!
- \internal
- */
-void QPixmapDropShadowFilter::draw(QPainter *p,
- const QPointF &pos,
- const QPixmap &px,
- const QRectF &src) const
-{
- Q_D(const QPixmapDropShadowFilter);
-
- if (px.isNull())
- return;
-
- QPixmapFilter *filter = p->paintEngine() && p->paintEngine()->isExtended() ?
- static_cast<QPaintEngineEx *>(p->paintEngine())->pixmapFilter(type(), this) : 0;
- QPixmapDropShadowFilter *dropShadowFilter = static_cast<QPixmapDropShadowFilter*>(filter);
- if (dropShadowFilter) {
- dropShadowFilter->setColor(d->color);
- dropShadowFilter->setBlurRadius(d->radius);
- dropShadowFilter->setOffset(d->offset);
- dropShadowFilter->draw(p, pos, px, src);
- return;
- }
-
- QImage tmp(px.size(), QImage::Format_ARGB32_Premultiplied);
- tmp.fill(0);
- QPainter tmpPainter(&tmp);
- tmpPainter.setCompositionMode(QPainter::CompositionMode_Source);
- tmpPainter.drawPixmap(d->offset, px);
- tmpPainter.end();
-
- // blur the alpha channel
- QImage blurred(tmp.size(), QImage::Format_ARGB32_Premultiplied);
- blurred.fill(0);
- QPainter blurPainter(&blurred);
- qt_blurImage(&blurPainter, tmp, d->radius, false, true);
- blurPainter.end();
-
- tmp = blurred;
-
- // blacken the image...
- tmpPainter.begin(&tmp);
- tmpPainter.setCompositionMode(QPainter::CompositionMode_SourceIn);
- tmpPainter.fillRect(tmp.rect(), d->color);
- tmpPainter.end();
-
- // draw the blurred drop shadow...
- p->drawImage(pos, tmp);
-
- // Draw the actual pixmap...
- p->drawPixmap(pos, px, src);
-}
-
-QT_END_NAMESPACE
-
-#endif //QT_NO_GRAPHICSEFFECT
diff --git a/src/gui/image/qpixmapfilter_p.h b/src/gui/image/qpixmapfilter_p.h
deleted file mode 100644
index 961866c19b..0000000000
--- a/src/gui/image/qpixmapfilter_p.h
+++ /dev/null
@@ -1,196 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPIXMAPFILTER_H
-#define QPIXMAPFILTER_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qnamespace.h>
-#include <QtGui/qpixmap.h>
-#include <QtGui/qgraphicseffect.h>
-
-#ifndef QT_NO_GRAPHICSEFFECT
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QPainter;
-class QPixmapData;
-
-class QPixmapFilterPrivate;
-
-class Q_GUI_EXPORT QPixmapFilter : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QPixmapFilter)
-public:
- virtual ~QPixmapFilter() = 0;
-
- enum FilterType {
- ConvolutionFilter,
- ColorizeFilter,
- DropShadowFilter,
- BlurFilter,
-
- UserFilter = 1024
- };
-
- FilterType type() const;
-
- virtual QRectF boundingRectFor(const QRectF &rect) const;
-
- virtual void draw(QPainter *painter, const QPointF &p, const QPixmap &src, const QRectF &srcRect = QRectF()) const = 0;
-
-protected:
- QPixmapFilter(QPixmapFilterPrivate &d, FilterType type, QObject *parent);
- QPixmapFilter(FilterType type, QObject *parent);
-};
-
-class QPixmapConvolutionFilterPrivate;
-
-class Q_GUI_EXPORT QPixmapConvolutionFilter : public QPixmapFilter
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QPixmapConvolutionFilter)
-
-public:
- QPixmapConvolutionFilter(QObject *parent = 0);
- ~QPixmapConvolutionFilter();
-
- void setConvolutionKernel(const qreal *matrix, int rows, int columns);
-
- QRectF boundingRectFor(const QRectF &rect) const;
- void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect = QRectF()) const;
-
-private:
- friend class QGLPixmapConvolutionFilter;
- friend class QVGPixmapConvolutionFilter;
- const qreal *convolutionKernel() const;
- int rows() const;
- int columns() const;
-};
-
-class QPixmapBlurFilterPrivate;
-
-class Q_GUI_EXPORT QPixmapBlurFilter : public QPixmapFilter
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QPixmapBlurFilter)
-
-public:
- QPixmapBlurFilter(QObject *parent = 0);
- ~QPixmapBlurFilter();
-
- void setRadius(qreal radius);
- void setBlurHints(QGraphicsBlurEffect::BlurHints hints);
-
- qreal radius() const;
- QGraphicsBlurEffect::BlurHints blurHints() const;
-
- QRectF boundingRectFor(const QRectF &rect) const;
- void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect = QRectF()) const;
-
-private:
- friend class QGLPixmapBlurFilter;
-};
-
-class QPixmapColorizeFilterPrivate;
-
-class Q_GUI_EXPORT QPixmapColorizeFilter : public QPixmapFilter
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QPixmapColorizeFilter)
-
-public:
- QPixmapColorizeFilter(QObject *parent = 0);
-
- void setColor(const QColor& color);
- QColor color() const;
-
- void setStrength(qreal strength);
- qreal strength() const;
-
- void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect = QRectF()) const;
-};
-
-class QPixmapDropShadowFilterPrivate;
-
-class Q_GUI_EXPORT QPixmapDropShadowFilter : public QPixmapFilter
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QPixmapDropShadowFilter)
-
-public:
- QPixmapDropShadowFilter(QObject *parent = 0);
- ~QPixmapDropShadowFilter();
-
- QRectF boundingRectFor(const QRectF &rect) const;
- void draw(QPainter *p, const QPointF &pos, const QPixmap &px, const QRectF &src = QRectF()) const;
-
- qreal blurRadius() const;
- void setBlurRadius(qreal radius);
-
- QColor color() const;
- void setColor(const QColor &color);
-
- QPointF offset() const;
- void setOffset(const QPointF &offset);
- inline void setOffset(qreal dx, qreal dy) { setOffset(QPointF(dx, dy)); }
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif //QT_NO_GRAPHICSEFFECT
-#endif // QPIXMAPFILTER_H
diff --git a/src/gui/inputmethod/inputmethod.pri b/src/gui/inputmethod/inputmethod.pri
deleted file mode 100644
index d4394380dc..0000000000
--- a/src/gui/inputmethod/inputmethod.pri
+++ /dev/null
@@ -1,31 +0,0 @@
-# Qt inputmethod module
-
-HEADERS +=inputmethod/qinputcontextfactory.h \
- inputmethod/qinputcontextplugin.h \
- inputmethod/qinputcontext_p.h \
- inputmethod/qinputcontext.h
-SOURCES +=inputmethod/qinputcontextfactory.cpp \
- inputmethod/qinputcontextplugin.cpp \
- inputmethod/qinputcontext.cpp
-x11 {
- HEADERS += inputmethod/qximinputcontext_p.h
- SOURCES += inputmethod/qximinputcontext_x11.cpp
-}
-win32 {
- HEADERS += inputmethod/qwininputcontext_p.h
- SOURCES += inputmethod/qwininputcontext_win.cpp
-}
-embedded {
- HEADERS += inputmethod/qwsinputcontext_p.h
- SOURCES += inputmethod/qwsinputcontext_qws.cpp
-}
-mac:!embedded:!qpa {
- HEADERS += inputmethod/qmacinputcontext_p.h
- SOURCES += inputmethod/qmacinputcontext_mac.cpp
-}
-symbian:contains(QT_CONFIG, s60) {
- HEADERS += inputmethod/qcoefepinputcontext_p.h
- SOURCES += inputmethod/qcoefepinputcontext_s60.cpp
- LIBS += -lfepbase -lakninputlanguage
-}
-
diff --git a/src/gui/inputmethod/qinputcontext.h b/src/gui/inputmethod/qinputcontext.h
deleted file mode 100644
index 089e6cdb9a..0000000000
--- a/src/gui/inputmethod/qinputcontext.h
+++ /dev/null
@@ -1,139 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/****************************************************************************
-**
-** Definition of QInputContext class
-**
-** Copyright (C) 2003-2004 immodule for Qt Project. All rights reserved.
-**
-** This file is written to contribute to Nokia Corporation and/or its subsidiary(-ies) under their own
-** license. You may use this file under your Qt license. Following
-** description is copied from their original file headers. Contact
-** immodule-qt@freedesktop.org if any conditions of this licensing are
-** not clear to you.
-**
-****************************************************************************/
-
-#ifndef QINPUTCONTEXT_H
-#define QINPUTCONTEXT_H
-
-#include <QtCore/qobject.h>
-#include <QtCore/qglobal.h>
-#include <QtGui/qevent.h>
-#include <QtCore/qstring.h>
-#include <QtCore/qlist.h>
-#include <QtGui/qaction.h>
-
-#ifndef QT_NO_IM
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QWidget;
-class QFont;
-class QPopupMenu;
-class QInputContextPrivate;
-#ifdef Q_OS_SYMBIAN
-class QSymbianEvent;
-#endif
-
-class Q_GUI_EXPORT QInputContext : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QInputContext)
-public:
- explicit QInputContext(QObject* parent = 0);
- virtual ~QInputContext();
-
- virtual QString identifierName() = 0;
- virtual QString language() = 0;
-
- virtual void reset() = 0;
- virtual void update();
-
- virtual void mouseHandler( int x, QMouseEvent *event);
- virtual QFont font() const;
- virtual bool isComposing() const = 0;
-
- QWidget *focusWidget() const;
- virtual void setFocusWidget( QWidget *w );
-
- virtual void widgetDestroyed(QWidget *w);
-
- virtual QList<QAction *> actions();
-
-#if defined(Q_WS_X11)
- virtual bool x11FilterEvent( QWidget *keywidget, XEvent *event );
-#endif // Q_WS_X11
-#if defined(Q_OS_SYMBIAN)
- virtual bool symbianFilterEvent( QWidget *keywidget, const QSymbianEvent *event );
-#endif // Q_OS_SYMBIAN
- virtual bool filterEvent( const QEvent *event );
-
- void sendEvent(const QInputMethodEvent &event);
-
- enum StandardFormat {
- PreeditFormat,
- SelectionFormat
- };
- QTextFormat standardFormat(StandardFormat s) const;
-private:
- friend class QWidget;
- friend class QWidgetPrivate;
- friend class QInputContextFactory;
- friend class QApplication;
-private: // Disabled copy constructor and operator=
- QInputContext( const QInputContext & );
- QInputContext &operator=( const QInputContext & );
-
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif //Q_NO_IM
-
-#endif // QINPUTCONTEXT_H
diff --git a/src/gui/inputmethod/qmacinputcontext_p.h b/src/gui/inputmethod/qmacinputcontext_p.h
deleted file mode 100644
index c4575a3c60..0000000000
--- a/src/gui/inputmethod/qmacinputcontext_p.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMACINPUTCONTEXT_P_H
-#define QMACINPUTCONTEXT_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "QtGui/qinputcontext.h"
-#include "private/qt_mac_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class Q_GUI_EXPORT QMacInputContext : public QInputContext
-{
- Q_OBJECT
- //Q_DECLARE_PRIVATE(QMacInputContext)
- void createTextDocument();
-public:
- explicit QMacInputContext(QObject* parent = 0);
- virtual ~QMacInputContext();
-
- virtual void setFocusWidget(QWidget *w);
- virtual QString identifierName() { return QLatin1String("mac"); }
- virtual QString language();
-
- virtual void reset();
-
- virtual bool isComposing() const;
-
- static OSStatus globalEventProcessor(EventHandlerCallRef, EventRef, void *);
- static void initialize();
- static void cleanup();
-
- EventRef lastKeydownEvent() { return keydownEvent; }
- void setLastKeydownEvent(EventRef);
-
-protected:
- void mouseHandler(int pos, QMouseEvent *);
-private:
- bool composing;
- bool recursionGuard;
- TSMDocumentID textDocument;
- QString currentText;
- EventRef keydownEvent;
-};
-
-QT_END_NAMESPACE
-
-#endif // QMACINPUTCONTEXT_P_H
diff --git a/src/gui/inputmethod/qwininputcontext_p.h b/src/gui/inputmethod/qwininputcontext_p.h
deleted file mode 100644
index dc87000b6c..0000000000
--- a/src/gui/inputmethod/qwininputcontext_p.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWININPUTCONTEXT_P_H
-#define QWININPUTCONTEXT_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of qinputcontext.cpp. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "QtGui/qinputcontext.h"
-#include "QtCore/qt_windows.h"
-
-#if !defined(IMR_RECONVERTSTRING)
-typedef struct tagRECONVERTSTRING {
- DWORD dwSize;
- DWORD dwVersion;
- DWORD dwStrLen;
- DWORD dwStrOffset;
- DWORD dwCompStrLen;
- DWORD dwCompStrOffset;
- DWORD dwTargetStrLen;
- DWORD dwTargetStrOffset;
-} RECONVERTSTRING, *PRECONVERTSTRING;
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class QWinInputContext : public QInputContext
-{
- Q_OBJECT
-public:
- explicit QWinInputContext(QObject* parent = 0);
- virtual ~QWinInputContext();
-
- virtual QString identifierName() { return QLatin1String("win"); }
- virtual QString language();
-
- virtual void reset();
- virtual void update();
-
- virtual void mouseHandler(int x, QMouseEvent *event);
- virtual bool isComposing() const;
-
- virtual void setFocusWidget(QWidget *w);
-
- bool startComposition();
- bool endComposition();
- bool composition(LPARAM lparam);
- int reconvertString(RECONVERTSTRING *reconv);
-
- static void TranslateMessage(const MSG *msg);
- static LRESULT DefWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
-
- static void updateImeStatus(QWidget *w, bool hasFocus);
- static void enablePopupChild(QWidget *w, bool e);
- static void enable(QWidget *w, bool e);
-
-private:
- void init();
- bool recursionGuard;
-};
-
-QT_END_NAMESPACE
-
-#endif // QWININPUTCONTEXT_P_H
diff --git a/src/gui/inputmethod/qwsinputcontext_p.h b/src/gui/inputmethod/qwsinputcontext_p.h
deleted file mode 100644
index 72b06a0b8f..0000000000
--- a/src/gui/inputmethod/qwsinputcontext_p.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWSINPUTCONTEXT_P_H
-#define QWSINPUTCONTEXT_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QLibrary class. This header file may change from
-// version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "QtGui/qinputcontext.h"
-
-#ifndef QT_NO_QWS_INPUTMETHODS
-
-QT_BEGIN_NAMESPACE
-
-class QWSIMEvent;
-class QWSIMQueryEvent;
-class QWSIMInitEvent;
-
-class QWSInputContext : public QInputContext
-{
- Q_OBJECT
-public:
- explicit QWSInputContext(QObject* parent = 0);
- ~QWSInputContext() {}
-
-
- QString identifierName() { return QString(); }
- QString language() { return QString(); }
-
- void reset();
- void update();
- void mouseHandler( int x, QMouseEvent *event);
-
- void setFocusWidget( QWidget *w );
- void widgetDestroyed(QWidget *w);
-
- bool isComposing() const;
-
- static QWidget *activeWidget();
- static bool translateIMEvent(QWidget *w, const QWSIMEvent *e);
- static bool translateIMQueryEvent(QWidget *w, const QWSIMQueryEvent *e);
- static bool translateIMInitEvent(const QWSIMInitEvent *e);
- static void updateImeStatus(QWidget *w, bool hasFocus);
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_INPUTMETHODS
-
-#endif // QWSINPUTCONTEXT_P_H
diff --git a/src/gui/inputmethod/qwsinputcontext_qws.cpp b/src/gui/inputmethod/qwsinputcontext_qws.cpp
deleted file mode 100644
index d8d64f28d4..0000000000
--- a/src/gui/inputmethod/qwsinputcontext_qws.cpp
+++ /dev/null
@@ -1,246 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwsinputcontext_p.h"
-#include "qinputcontext_p.h"
-#include "qwsdisplay_qws.h"
-#include "qwsevent_qws.h"
-#include "private/qwscommand_qws_p.h"
-#include "qwindowsystem_qws.h"
-#include "qevent.h"
-#include "qtextformat.h"
-
-#include <qbuffer.h>
-
-#include <qdebug.h>
-
-#ifndef QT_NO_QWS_INPUTMETHODS
-
-QT_BEGIN_NAMESPACE
-
-static QWidget* activeWidget = 0;
-
-//#define EXTRA_DEBUG
-
-QWSInputContext::QWSInputContext(QObject *parent)
- :QInputContext(parent)
-{
-}
-
-void QWSInputContext::reset()
-{
- QPaintDevice::qwsDisplay()->resetIM();
-}
-
-
-void QWSInputContext::setFocusWidget( QWidget *w )
-{
- QWidget *oldFocus = focusWidget();
- if (oldFocus == w)
- return;
-
- if (w) {
- QWSInputContext::updateImeStatus(w, true);
- } else {
- if (oldFocus)
- QWSInputContext::updateImeStatus(oldFocus, false);
- }
-
- if (oldFocus) {
- QWidget *tlw = oldFocus->window();
- int winid = tlw->internalWinId();
-
- int widgetid = oldFocus->internalWinId();
- QPaintDevice::qwsDisplay()->sendIMUpdate(QWSInputMethod::FocusOut, winid, widgetid);
- }
-
- QInputContext::setFocusWidget(w);
-
- if (!w)
- return;
-
- QWidget *tlw = w->window();
- int winid = tlw->winId();
-
- int widgetid = w->winId();
- QPaintDevice::qwsDisplay()->sendIMUpdate(QWSInputMethod::FocusIn, winid, widgetid);
-
- //setfocus ???
-
- update();
-}
-
-
-void QWSInputContext::widgetDestroyed(QWidget *w)
-{
- if (w == QT_PREPEND_NAMESPACE(activeWidget))
- QT_PREPEND_NAMESPACE(activeWidget) = 0;
- QInputContext::widgetDestroyed(w);
-}
-
-void QWSInputContext::update()
-{
- QWidget *w = focusWidget();
- if (!w)
- return;
-
- QWidget *tlw = w->window();
- int winid = tlw->winId();
-
- int widgetid = w->winId();
- QPaintDevice::qwsDisplay()->sendIMUpdate(QWSInputMethod::Update, winid, widgetid);
-
-}
-
-void QWSInputContext::mouseHandler( int x, QMouseEvent *event)
-{
- if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonRelease)
- QPaintDevice::qwsDisplay()->sendIMMouseEvent( x, event->type() == QEvent::MouseButtonPress );
-}
-
-QWidget *QWSInputContext::activeWidget()
-{
- return QT_PREPEND_NAMESPACE(activeWidget);
-}
-
-
-bool QWSInputContext::isComposing() const
-{
- return QT_PREPEND_NAMESPACE(activeWidget) != 0;
-}
-
-bool QWSInputContext::translateIMQueryEvent(QWidget *w, const QWSIMQueryEvent *e)
-{
- Qt::InputMethodQuery type = static_cast<Qt::InputMethodQuery>(e->simpleData.property);
- QVariant result = w->inputMethodQuery(type);
- QWidget *tlw = w->window();
- int winId = tlw->winId();
-
- if ( type == Qt::ImMicroFocus ) {
- // translate to relative to tlw
- QRect mf = result.toRect();
- mf.moveTopLeft(w->mapTo(tlw,mf.topLeft()));
- result = mf;
- }
-
- QPaintDevice::qwsDisplay()->sendIMResponse(winId, e->simpleData.property, result);
-
- return false;
-}
-
-bool QWSInputContext::translateIMInitEvent(const QWSIMInitEvent *e)
-{
- Q_UNUSED(e);
- qDebug("### QWSInputContext::translateIMInitEvent not implemented ###");
- return false;
-}
-
-bool QWSInputContext::translateIMEvent(QWidget *w, const QWSIMEvent *e)
-{
- QDataStream stream(e->streamingData);
- QString preedit;
- QString commit;
-
- stream >> preedit;
- stream >> commit;
-
- if (preedit.isEmpty() && QT_PREPEND_NAMESPACE(activeWidget))
- w = QT_PREPEND_NAMESPACE(activeWidget);
-
- QInputContext *qic = w->inputContext();
- if (!qic)
- return false;
-
- QList<QInputMethodEvent::Attribute> attrs;
-
-
- while (!stream.atEnd()) {
- int type = -1;
- int start = -1;
- int length = -1;
- QVariant data;
- stream >> type >> start >> length >> data;
- if (stream.status() != QDataStream::Ok) {
- qWarning("corrupted QWSIMEvent");
- //qic->reset(); //???
- return false;
- }
- if (type == QInputMethodEvent::TextFormat)
- data = qic->standardFormat(static_cast<QInputContext::StandardFormat>(data.toInt()));
- attrs << QInputMethodEvent::Attribute(static_cast<QInputMethodEvent::AttributeType>(type), start, length, data);
- }
-#ifdef EXTRA_DEBUG
- qDebug() << "preedit" << preedit << "len" << preedit.length() <<"commit" << commit << "len" << commit.length()
- << "n attr" << attrs.count();
-#endif
-
- if (preedit.isEmpty())
- QT_PREPEND_NAMESPACE(activeWidget) = 0;
- else
- QT_PREPEND_NAMESPACE(activeWidget) = w;
-
-
- QInputMethodEvent ime(preedit, attrs);
- if (!commit.isEmpty() || e->simpleData.replaceLength > 0)
- ime.setCommitString(commit, e->simpleData.replaceFrom, e->simpleData.replaceLength);
-
-
- extern bool qt_sendSpontaneousEvent(QObject *, QEvent *); //qapplication_qws.cpp
- qt_sendSpontaneousEvent(w, &ime);
-
- return true;
-}
-
-Q_GUI_EXPORT void (*qt_qws_inputMethodStatusChanged)(QWidget*) = 0;
-
-void QWSInputContext::updateImeStatus(QWidget *w, bool hasFocus)
-{
- Q_UNUSED(hasFocus);
-
- if (!w || !qt_qws_inputMethodStatusChanged)
- return;
- qt_qws_inputMethodStatusChanged(w);
-}
-
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_INPUTMETHODS
diff --git a/src/gui/inputmethod/qximinputcontext_p.h b/src/gui/inputmethod/qximinputcontext_p.h
deleted file mode 100644
index 13c389cce6..0000000000
--- a/src/gui/inputmethod/qximinputcontext_p.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/****************************************************************************
-**
-** Definition of QXIMInputContext class
-**
-** Copyright (C) 2003-2004 immodule for Qt Project. All rights reserved.
-**
-** This file is written to contribute to Nokia Corporation and/or its subsidiary(-ies) under their own
-** license. You may use this file under your Qt license. Following
-** description is copied from their original file headers. Contact
-** immodule-qt@freedesktop.org if any conditions of this licensing are
-** not clear to you.
-**
-****************************************************************************/
-
-#ifndef QXIMINPUTCONTEXT_P_H
-#define QXIMINPUTCONTEXT_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.
-//
-
-#if !defined(Q_NO_IM)
-
-#include "QtCore/qglobal.h"
-#include "QtGui/qinputcontext.h"
-#include "QtGui/qfont.h"
-#include "QtCore/qhash.h"
-#ifdef Q_WS_X11
-#include "QtCore/qlist.h"
-#include "QtCore/qbitarray.h"
-#include "QtGui/qwindowdefs.h"
-#include "private/qt_x11_p.h"
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class QKeyEvent;
-class QWidget;
-class QFont;
-class QString;
-
-class QXIMInputContext : public QInputContext
-{
- Q_OBJECT
-public:
- struct ICData {
- XIC ic;
- XFontSet fontset;
- QWidget *widget;
- QString text;
- QBitArray selectedChars;
- bool composing;
- bool preeditEmpty;
- void clear();
- };
-
- QXIMInputContext();
- ~QXIMInputContext();
-
- QString identifierName();
- QString language();
-
- void reset();
-
- void mouseHandler( int x, QMouseEvent *event);
- bool isComposing() const;
-
- void setFocusWidget( QWidget *w );
- void widgetDestroyed(QWidget *w);
-
- void create_xim();
- void close_xim();
-
- void update();
-
- ICData *icData() const;
-protected:
- bool x11FilterEvent( QWidget *keywidget, XEvent *event );
-
-private:
- static XIMStyle xim_style;
-
- QString _language;
- XIM xim;
- QHash<WId, ICData *> ximData;
-
- ICData *createICData(QWidget *w);
-};
-
-QT_END_NAMESPACE
-
-#endif // Q_NO_IM
-
-#endif // QXIMINPUTCONTEXT_P_H
diff --git a/src/gui/itemviews/qabstractitemdelegate.h b/src/gui/itemviews/qabstractitemdelegate.h
deleted file mode 100644
index 6789317137..0000000000
--- a/src/gui/itemviews/qabstractitemdelegate.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QABSTRACTITEMDELEGATE_H
-#define QABSTRACTITEMDELEGATE_H
-
-#include <QtCore/qobject.h>
-#include <QtGui/qstyleoption.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_ITEMVIEWS
-
-class QPainter;
-class QModelIndex;
-class QAbstractItemModel;
-class QAbstractItemView;
-class QHelpEvent;
-
-class Q_GUI_EXPORT QAbstractItemDelegate : public QObject
-{
- Q_OBJECT
-
-public:
-
- enum EndEditHint {
- NoHint,
- EditNextItem,
- EditPreviousItem,
- SubmitModelCache,
- RevertModelCache
- };
-
- explicit QAbstractItemDelegate(QObject *parent = 0);
- virtual ~QAbstractItemDelegate();
-
- // painting
- virtual void paint(QPainter *painter,
- const QStyleOptionViewItem &option,
- const QModelIndex &index) const = 0;
-
- virtual QSize sizeHint(const QStyleOptionViewItem &option,
- const QModelIndex &index) const = 0;
-
- // editing
- virtual QWidget *createEditor(QWidget *parent,
- const QStyleOptionViewItem &option,
- const QModelIndex &index) const;
-
- virtual void setEditorData(QWidget *editor, const QModelIndex &index) const;
-
- virtual void setModelData(QWidget *editor,
- QAbstractItemModel *model,
- const QModelIndex &index) const;
-
- virtual void updateEditorGeometry(QWidget *editor,
- const QStyleOptionViewItem &option,
- const QModelIndex &index) const;
-
- // for non-widget editors
- virtual bool editorEvent(QEvent *event,
- QAbstractItemModel *model,
- const QStyleOptionViewItem &option,
- const QModelIndex &index);
-
- static QString elidedText(const QFontMetrics &fontMetrics, int width,
- Qt::TextElideMode mode, const QString &text);
-
-public Q_SLOTS:
- bool helpEvent(QHelpEvent *event,
- QAbstractItemView *view,
- const QStyleOptionViewItem &option,
- const QModelIndex &index);
-
-Q_SIGNALS:
- void commitData(QWidget *editor);
- void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint = NoHint);
- void sizeHintChanged(const QModelIndex &);
-
-protected:
- QAbstractItemDelegate(QObjectPrivate &, QObject *parent = 0);
-private:
- Q_DISABLE_COPY(QAbstractItemDelegate)
-};
-
-#endif // QT_NO_ITEMVIEWS
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QABSTRACTITEMDELEGATE_H
diff --git a/src/gui/itemviews/qabstractitemview.h b/src/gui/itemviews/qabstractitemview.h
deleted file mode 100644
index f11f209010..0000000000
--- a/src/gui/itemviews/qabstractitemview.h
+++ /dev/null
@@ -1,380 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QABSTRACTITEMVIEW_H
-#define QABSTRACTITEMVIEW_H
-
-#include <QtGui/qabstractscrollarea.h>
-#include <QtCore/qabstractitemmodel.h>
-#include <QtGui/qitemselectionmodel.h>
-#include <QtGui/qabstractitemdelegate.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_ITEMVIEWS
-
-class QMenu;
-class QDrag;
-class QEvent;
-class QAbstractItemViewPrivate;
-
-class Q_GUI_EXPORT QAbstractItemView : public QAbstractScrollArea
-{
- Q_OBJECT
- Q_ENUMS(SelectionMode SelectionBehavior ScrollHint ScrollMode DragDropMode)
- Q_FLAGS(EditTriggers)
- Q_PROPERTY(bool autoScroll READ hasAutoScroll WRITE setAutoScroll)
- Q_PROPERTY(int autoScrollMargin READ autoScrollMargin WRITE setAutoScrollMargin)
- Q_PROPERTY(EditTriggers editTriggers READ editTriggers WRITE setEditTriggers)
- Q_PROPERTY(bool tabKeyNavigation READ tabKeyNavigation WRITE setTabKeyNavigation)
-#ifndef QT_NO_DRAGANDDROP
- Q_PROPERTY(bool showDropIndicator READ showDropIndicator WRITE setDropIndicatorShown)
- Q_PROPERTY(bool dragEnabled READ dragEnabled WRITE setDragEnabled)
- Q_PROPERTY(bool dragDropOverwriteMode READ dragDropOverwriteMode WRITE setDragDropOverwriteMode)
- Q_PROPERTY(DragDropMode dragDropMode READ dragDropMode WRITE setDragDropMode)
- Q_PROPERTY(Qt::DropAction defaultDropAction READ defaultDropAction WRITE setDefaultDropAction)
-#endif
- Q_PROPERTY(bool alternatingRowColors READ alternatingRowColors WRITE setAlternatingRowColors)
- Q_PROPERTY(SelectionMode selectionMode READ selectionMode WRITE setSelectionMode)
- Q_PROPERTY(SelectionBehavior selectionBehavior READ selectionBehavior WRITE setSelectionBehavior)
- Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
- Q_PROPERTY(Qt::TextElideMode textElideMode READ textElideMode WRITE setTextElideMode)
- Q_PROPERTY(ScrollMode verticalScrollMode READ verticalScrollMode WRITE setVerticalScrollMode)
- Q_PROPERTY(ScrollMode horizontalScrollMode READ horizontalScrollMode WRITE setHorizontalScrollMode)
-
-public:
- enum SelectionMode {
- NoSelection,
- SingleSelection,
- MultiSelection,
- ExtendedSelection,
- ContiguousSelection
- };
-
- enum SelectionBehavior {
- SelectItems,
- SelectRows,
- SelectColumns
- };
-
- enum ScrollHint {
- EnsureVisible,
- PositionAtTop,
- PositionAtBottom,
- PositionAtCenter
- };
-
- enum EditTrigger {
- NoEditTriggers = 0,
- CurrentChanged = 1,
- DoubleClicked = 2,
- SelectedClicked = 4,
- EditKeyPressed = 8,
- AnyKeyPressed = 16,
- AllEditTriggers = 31
- };
-
- Q_DECLARE_FLAGS(EditTriggers, EditTrigger)
-
- enum ScrollMode {
- ScrollPerItem,
- ScrollPerPixel
- };
-
- explicit QAbstractItemView(QWidget *parent = 0);
- ~QAbstractItemView();
-
- virtual void setModel(QAbstractItemModel *model);
- QAbstractItemModel *model() const;
-
- virtual void setSelectionModel(QItemSelectionModel *selectionModel);
- QItemSelectionModel *selectionModel() const;
-
- void setItemDelegate(QAbstractItemDelegate *delegate);
- QAbstractItemDelegate *itemDelegate() const;
-
- void setSelectionMode(QAbstractItemView::SelectionMode mode);
- QAbstractItemView::SelectionMode selectionMode() const;
-
- void setSelectionBehavior(QAbstractItemView::SelectionBehavior behavior);
- QAbstractItemView::SelectionBehavior selectionBehavior() const;
-
- QModelIndex currentIndex() const;
- QModelIndex rootIndex() const;
-
- void setEditTriggers(EditTriggers triggers);
- EditTriggers editTriggers() const;
-
- void setVerticalScrollMode(ScrollMode mode);
- ScrollMode verticalScrollMode() const;
-
- void setHorizontalScrollMode(ScrollMode mode);
- ScrollMode horizontalScrollMode() const;
-
- void setAutoScroll(bool enable);
- bool hasAutoScroll() const;
-
- void setAutoScrollMargin(int margin);
- int autoScrollMargin() const;
-
- void setTabKeyNavigation(bool enable);
- bool tabKeyNavigation() const;
-
-#ifndef QT_NO_DRAGANDDROP
- void setDropIndicatorShown(bool enable);
- bool showDropIndicator() const;
-
- void setDragEnabled(bool enable);
- bool dragEnabled() const;
-
- void setDragDropOverwriteMode(bool overwrite);
- bool dragDropOverwriteMode() const;
-
- enum DragDropMode {
- NoDragDrop,
- DragOnly,
- DropOnly,
- DragDrop,
- InternalMove
- };
-
- void setDragDropMode(DragDropMode behavior);
- DragDropMode dragDropMode() const;
-
- void setDefaultDropAction(Qt::DropAction dropAction);
- Qt::DropAction defaultDropAction() const;
-#endif
-
- void setAlternatingRowColors(bool enable);
- bool alternatingRowColors() const;
-
- void setIconSize(const QSize &size);
- QSize iconSize() const;
-
- void setTextElideMode(Qt::TextElideMode mode);
- Qt::TextElideMode textElideMode() const;
-
- virtual void keyboardSearch(const QString &search);
-
- virtual QRect visualRect(const QModelIndex &index) const = 0;
- virtual void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) = 0;
- virtual QModelIndex indexAt(const QPoint &point) const = 0;
-
- QSize sizeHintForIndex(const QModelIndex &index) const;
- virtual int sizeHintForRow(int row) const;
- virtual int sizeHintForColumn(int column) const;
-
- void openPersistentEditor(const QModelIndex &index);
- void closePersistentEditor(const QModelIndex &index);
-
- void setIndexWidget(const QModelIndex &index, QWidget *widget);
- QWidget *indexWidget(const QModelIndex &index) const;
-
- void setItemDelegateForRow(int row, QAbstractItemDelegate *delegate);
- QAbstractItemDelegate *itemDelegateForRow(int row) const;
-
- void setItemDelegateForColumn(int column, QAbstractItemDelegate *delegate);
- QAbstractItemDelegate *itemDelegateForColumn(int column) const;
-
- QAbstractItemDelegate *itemDelegate(const QModelIndex &index) const;
-
- virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
-
-#ifdef Q_NO_USING_KEYWORD
- inline void update() { QAbstractScrollArea::update(); }
-#else
- using QAbstractScrollArea::update;
-#endif
-
-public Q_SLOTS:
- virtual void reset();
- virtual void setRootIndex(const QModelIndex &index);
- virtual void doItemsLayout();
- virtual void selectAll();
- void edit(const QModelIndex &index);
- void clearSelection();
- void setCurrentIndex(const QModelIndex &index);
- void scrollToTop();
- void scrollToBottom();
- void update(const QModelIndex &index);
-
-protected Q_SLOTS:
- virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
- virtual void rowsInserted(const QModelIndex &parent, int start, int end);
- virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
- virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
- virtual void currentChanged(const QModelIndex &current, const QModelIndex &previous);
- virtual void updateEditorData();
- virtual void updateEditorGeometries();
- virtual void updateGeometries();
- virtual void verticalScrollbarAction(int action);
- virtual void horizontalScrollbarAction(int action);
- virtual void verticalScrollbarValueChanged(int value);
- virtual void horizontalScrollbarValueChanged(int value);
- virtual void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint);
- virtual void commitData(QWidget *editor);
- virtual void editorDestroyed(QObject *editor);
-
-Q_SIGNALS:
- void pressed(const QModelIndex &index);
- void clicked(const QModelIndex &index);
- void doubleClicked(const QModelIndex &index);
-
- void activated(const QModelIndex &index);
- void entered(const QModelIndex &index);
- void viewportEntered();
-
-protected:
- QAbstractItemView(QAbstractItemViewPrivate &, QWidget *parent = 0);
-
- void setHorizontalStepsPerItem(int steps);
- int horizontalStepsPerItem() const;
- void setVerticalStepsPerItem(int steps);
- int verticalStepsPerItem() const;
-
- enum CursorAction { MoveUp, MoveDown, MoveLeft, MoveRight,
- MoveHome, MoveEnd, MovePageUp, MovePageDown,
- MoveNext, MovePrevious };
- virtual QModelIndex moveCursor(CursorAction cursorAction,
- Qt::KeyboardModifiers modifiers) = 0;
-
- virtual int horizontalOffset() const = 0;
- virtual int verticalOffset() const = 0;
-
- virtual bool isIndexHidden(const QModelIndex &index) const = 0;
-
- virtual void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) = 0;
- virtual QRegion visualRegionForSelection(const QItemSelection &selection) const = 0;
- virtual QModelIndexList selectedIndexes() const;
-
- virtual bool edit(const QModelIndex &index, EditTrigger trigger, QEvent *event);
-
- virtual QItemSelectionModel::SelectionFlags selectionCommand(const QModelIndex &index,
- const QEvent *event = 0) const;
-
-#ifndef QT_NO_DRAGANDDROP
- virtual void startDrag(Qt::DropActions supportedActions);
-#endif
-
- virtual QStyleOptionViewItem viewOptions() const;
-
- enum State {
- NoState,
- DraggingState,
- DragSelectingState,
- EditingState,
- ExpandingState,
- CollapsingState,
- AnimatingState
- };
-
- State state() const;
- void setState(State state);
-
- void scheduleDelayedItemsLayout();
- void executeDelayedItemsLayout();
-
- void setDirtyRegion(const QRegion &region);
- void scrollDirtyRegion(int dx, int dy);
- QPoint dirtyRegionOffset() const;
-
- void startAutoScroll();
- void stopAutoScroll();
- void doAutoScroll();
-
- bool focusNextPrevChild(bool next);
- bool event(QEvent *event);
- bool viewportEvent(QEvent *event);
- void mousePressEvent(QMouseEvent *event);
- void mouseMoveEvent(QMouseEvent *event);
- void mouseReleaseEvent(QMouseEvent *event);
- void mouseDoubleClickEvent(QMouseEvent *event);
-#ifndef QT_NO_DRAGANDDROP
- void dragEnterEvent(QDragEnterEvent *event);
- void dragMoveEvent(QDragMoveEvent *event);
- void dragLeaveEvent(QDragLeaveEvent *event);
- void dropEvent(QDropEvent *event);
-#endif
- void focusInEvent(QFocusEvent *event);
- void focusOutEvent(QFocusEvent *event);
- void keyPressEvent(QKeyEvent *event);
- void resizeEvent(QResizeEvent *event);
- void timerEvent(QTimerEvent *event);
- void inputMethodEvent(QInputMethodEvent *event);
-
-#ifndef QT_NO_DRAGANDDROP
- enum DropIndicatorPosition { OnItem, AboveItem, BelowItem, OnViewport };
- DropIndicatorPosition dropIndicatorPosition() const;
-#endif
-
-private:
- Q_DECLARE_PRIVATE(QAbstractItemView)
- Q_DISABLE_COPY(QAbstractItemView)
- Q_PRIVATE_SLOT(d_func(), void _q_columnsAboutToBeRemoved(const QModelIndex&, int, int))
- Q_PRIVATE_SLOT(d_func(), void _q_columnsRemoved(const QModelIndex&, int, int))
- Q_PRIVATE_SLOT(d_func(), void _q_columnsInserted(const QModelIndex&, int, int))
- Q_PRIVATE_SLOT(d_func(), void _q_rowsRemoved(const QModelIndex&, int, int))
- Q_PRIVATE_SLOT(d_func(), void _q_modelDestroyed())
- Q_PRIVATE_SLOT(d_func(), void _q_layoutChanged())
- Q_PRIVATE_SLOT(d_func(), void _q_headerDataChanged())
-#ifndef QT_NO_GESTURES
- Q_PRIVATE_SLOT(d_func(), void _q_scrollerStateChanged())
-#endif
-
- friend class QTreeViewPrivate; // needed to compile with MSVC
- friend class QAccessibleItemRow;
- friend class QListModeViewBase;
- friend class QListViewPrivate; // needed to compile for Symbian emulator
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractItemView::EditTriggers)
-
-#endif // QT_NO_ITEMVIEWS
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QABSTRACTITEMVIEW_H
diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h
deleted file mode 100644
index 6041e5e177..0000000000
--- a/src/gui/itemviews/qabstractitemview_p.h
+++ /dev/null
@@ -1,457 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QABSTRACTITEMVIEW_P_H
-#define QABSTRACTITEMVIEW_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "private/qabstractscrollarea_p.h"
-#include "private/qabstractitemmodel_p.h"
-#include "QtGui/qapplication.h"
-#include "QtGui/qevent.h"
-#include "QtGui/qmime.h"
-#include "QtGui/qpainter.h"
-#include "QtCore/qpair.h"
-#include "QtGui/qregion.h"
-#include "QtCore/qdebug.h"
-#include "QtGui/qpainter.h"
-#include "QtCore/qbasictimer.h"
-#include "QtCore/qelapsedtimer.h"
-
-#ifndef QT_NO_ITEMVIEWS
-
-QT_BEGIN_NAMESPACE
-
-struct QEditorInfo {
- QEditorInfo(QWidget *e, bool s): widget(QWeakPointer<QWidget>(e)), isStatic(s) {}
- QEditorInfo(): isStatic(false) {}
-
- QWeakPointer<QWidget> widget;
- bool isStatic;
-};
-
-// Fast associativity between Persistent editors and indices.
-typedef QHash<QWidget *, QPersistentModelIndex> QEditorIndexHash;
-typedef QHash<QPersistentModelIndex, QEditorInfo> QIndexEditorHash;
-
-typedef QPair<QRect, QModelIndex> QItemViewPaintPair;
-typedef QList<QItemViewPaintPair> QItemViewPaintPairs;
-
-class QEmptyModel : public QAbstractItemModel
-{
-public:
- explicit QEmptyModel(QObject *parent = 0) : QAbstractItemModel(parent) {}
- QModelIndex index(int, int, const QModelIndex &) const { return QModelIndex(); }
- QModelIndex parent(const QModelIndex &) const { return QModelIndex(); }
- int rowCount(const QModelIndex &) const { return 0; }
- int columnCount(const QModelIndex &) const { return 0; }
- bool hasChildren(const QModelIndex &) const { return false; }
- QVariant data(const QModelIndex &, int) const { return QVariant(); }
-};
-
-class Q_AUTOTEST_EXPORT QAbstractItemViewPrivate : public QAbstractScrollAreaPrivate
-{
- Q_DECLARE_PUBLIC(QAbstractItemView)
-
-public:
- QAbstractItemViewPrivate();
- virtual ~QAbstractItemViewPrivate();
-
- void init();
-
- virtual void _q_rowsRemoved(const QModelIndex &parent, int start, int end);
- virtual void _q_columnsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
- virtual void _q_columnsRemoved(const QModelIndex &parent, int start, int end);
- virtual void _q_columnsInserted(const QModelIndex &parent, int start, int end);
- virtual void _q_modelDestroyed();
- virtual void _q_layoutChanged();
- void _q_headerDataChanged() { doDelayedItemsLayout(); }
- void _q_scrollerStateChanged();
-
- void fetchMore();
-
- bool shouldEdit(QAbstractItemView::EditTrigger trigger, const QModelIndex &index) const;
- bool shouldForwardEvent(QAbstractItemView::EditTrigger trigger, const QEvent *event) const;
- bool shouldAutoScroll(const QPoint &pos) const;
- void doDelayedItemsLayout(int delay = 0);
- void interruptDelayedItemsLayout() const;
-
- void startAutoScroll()
- { // ### it would be nice to make this into a style hint one day
- int scrollInterval = (verticalScrollMode == QAbstractItemView::ScrollPerItem) ? 150 : 50;
- autoScrollTimer.start(scrollInterval, q_func());
- autoScrollCount = 0;
- }
- void stopAutoScroll() { autoScrollTimer.stop(); autoScrollCount = 0;}
-
-#ifndef QT_NO_DRAGANDDROP
- virtual bool dropOn(QDropEvent *event, int *row, int *col, QModelIndex *index);
-#endif
- bool droppingOnItself(QDropEvent *event, const QModelIndex &index);
-
- QWidget *editor(const QModelIndex &index, const QStyleOptionViewItem &options);
- bool sendDelegateEvent(const QModelIndex &index, QEvent *event) const;
- bool openEditor(const QModelIndex &index, QEvent *event);
- void updateEditorData(const QModelIndex &topLeft, const QModelIndex &bottomRight);
-
- QItemSelectionModel::SelectionFlags multiSelectionCommand(const QModelIndex &index,
- const QEvent *event) const;
- QItemSelectionModel::SelectionFlags extendedSelectionCommand(const QModelIndex &index,
- const QEvent *event) const;
- QItemSelectionModel::SelectionFlags contiguousSelectionCommand(const QModelIndex &index,
- const QEvent *event) const;
- virtual void selectAll(QItemSelectionModel::SelectionFlags command);
-
- void setHoverIndex(const QPersistentModelIndex &index);
-
- void checkMouseMove(const QPersistentModelIndex &index);
- inline void checkMouseMove(const QPoint &pos) { checkMouseMove(q_func()->indexAt(pos)); }
-
- inline QItemSelectionModel::SelectionFlags selectionBehaviorFlags() const
- {
- switch (selectionBehavior) {
- case QAbstractItemView::SelectRows: return QItemSelectionModel::Rows;
- case QAbstractItemView::SelectColumns: return QItemSelectionModel::Columns;
- case QAbstractItemView::SelectItems: default: return QItemSelectionModel::NoUpdate;
- }
- }
-
-#ifndef QT_NO_DRAGANDDROP
- virtual QAbstractItemView::DropIndicatorPosition position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const;
-
- inline bool canDecode(QDropEvent *e) const {
- QStringList modelTypes = model->mimeTypes();
- const QMimeData *mime = e->mimeData();
- for (int i = 0; i < modelTypes.count(); ++i)
- if (mime->hasFormat(modelTypes.at(i))
- && (e->dropAction() & model->supportedDropActions()))
- return true;
- return false;
- }
-
- inline void paintDropIndicator(QPainter *painter)
- {
- if (showDropIndicator && state == QAbstractItemView::DraggingState
-#ifndef QT_NO_CURSOR
- && viewport->cursor().shape() != Qt::ForbiddenCursor
-#endif
- ) {
- QStyleOption opt;
- opt.init(q_func());
- opt.rect = dropIndicatorRect;
- q_func()->style()->drawPrimitive(QStyle::PE_IndicatorItemViewItemDrop, &opt, painter, q_func());
- }
- }
-
-#endif
- virtual QItemViewPaintPairs draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const;
-
- inline void releaseEditor(QWidget *editor) const {
- if (editor) {
- QObject::disconnect(editor, SIGNAL(destroyed(QObject*)),
- q_func(), SLOT(editorDestroyed(QObject*)));
- editor->removeEventFilter(itemDelegate);
- editor->hide();
- editor->deleteLater();
- }
- }
-
- inline void executePostedLayout() const {
- if (delayedPendingLayout && state != QAbstractItemView::CollapsingState) {
- interruptDelayedItemsLayout();
- const_cast<QAbstractItemView*>(q_func())->doItemsLayout();
- }
- }
-
- inline void setDirtyRegion(const QRegion &visualRegion) {
- updateRegion += visualRegion;
- if (!updateTimer.isActive())
- updateTimer.start(0, q_func());
- }
-
- inline void scrollDirtyRegion(int dx, int dy) {
- scrollDelayOffset = QPoint(-dx, -dy);
- updateDirtyRegion();
- scrollDelayOffset = QPoint(0, 0);
- }
-
- inline void scrollContentsBy(int dx, int dy) {
- scrollDirtyRegion(dx, dy);
- viewport->scroll(dx, dy);
- }
-
- void updateDirtyRegion() {
- updateTimer.stop();
- viewport->update(updateRegion);
- updateRegion = QRegion();
- }
-
- void clearOrRemove();
- void checkPersistentEditorFocus();
-
- QPixmap renderToPixmap(const QModelIndexList &indexes, QRect *r) const;
-
- inline QPoint offset() const {
- const Q_Q(QAbstractItemView);
- return QPoint(q->isRightToLeft() ? -q->horizontalOffset()
- : q->horizontalOffset(), q->verticalOffset());
- }
-
- const QEditorInfo &editorForIndex(const QModelIndex &index) const;
- inline bool hasEditor(const QModelIndex &index) const {
- return indexEditorHash.find(index) != indexEditorHash.constEnd();
- }
-
- QModelIndex indexForEditor(QWidget *editor) const;
- void addEditor(const QModelIndex &index, QWidget *editor, bool isStatic);
- void removeEditor(QWidget *editor);
-
- inline bool isAnimating() const {
- return state == QAbstractItemView::AnimatingState;
- }
-
- inline QAbstractItemDelegate *delegateForIndex(const QModelIndex &index) const {
- QAbstractItemDelegate *del;
- if ((del = rowDelegates.value(index.row(), 0))) return del;
- if ((del = columnDelegates.value(index.column(), 0))) return del;
- return itemDelegate;
- }
-
- inline bool isIndexValid(const QModelIndex &index) const {
- return (index.row() >= 0) && (index.column() >= 0) && (index.model() == model);
- }
- inline bool isIndexSelectable(const QModelIndex &index) const {
- return (model->flags(index) & Qt::ItemIsSelectable);
- }
- inline bool isIndexEnabled(const QModelIndex &index) const {
- return (model->flags(index) & Qt::ItemIsEnabled);
- }
- inline bool isIndexDropEnabled(const QModelIndex &index) const {
- return (model->flags(index) & Qt::ItemIsDropEnabled);
- }
- inline bool isIndexDragEnabled(const QModelIndex &index) const {
- return (model->flags(index) & Qt::ItemIsDragEnabled);
- }
-
- virtual bool selectionAllowed(const QModelIndex &index) const {
- // in some views we want to go ahead with selections, even if the index is invalid
- return isIndexValid(index) && isIndexSelectable(index);
- }
-
- // reimplemented from QAbstractScrollAreaPrivate
- virtual QPoint contentsOffset() const {
- Q_Q(const QAbstractItemView);
- return QPoint(q->horizontalOffset(), q->verticalOffset());
- }
-
- /**
- * For now, assume that we have few editors, if we need a more efficient implementation
- * we should add a QMap<QAbstractItemDelegate*, int> member.
- */
- int delegateRefCount(const QAbstractItemDelegate *delegate) const
- {
- int ref = 0;
- if (itemDelegate == delegate)
- ++ref;
-
- for (int maps = 0; maps < 2; ++maps) {
- const QMap<int, QPointer<QAbstractItemDelegate> > *delegates = maps ? &columnDelegates : &rowDelegates;
- for (QMap<int, QPointer<QAbstractItemDelegate> >::const_iterator it = delegates->begin();
- it != delegates->end(); ++it) {
- if (it.value() == delegate) {
- ++ref;
- // optimization, we are only interested in the ref count values 0, 1 or >=2
- if (ref >= 2) {
- return ref;
- }
- }
- }
- }
- return ref;
- }
-
- /**
- * return true if the index is registered as a QPersistentModelIndex
- */
- inline bool isPersistent(const QModelIndex &index) const
- {
- return static_cast<QAbstractItemModelPrivate *>(model->d_ptr.data())->persistent.indexes.contains(index);
- }
-
- QModelIndexList selectedDraggableIndexes() const;
-
- QStyleOptionViewItemV4 viewOptionsV4() const;
-
- void doDelayedReset()
- {
- //we delay the reset of the timer because some views (QTableView)
- //with headers can't handle the fact that the model has been destroyed
- //all _q_modelDestroyed slots must have been called
- if (!delayedReset.isActive())
- delayedReset.start(0, q_func());
- }
-
- QAbstractItemModel *model;
- QPointer<QAbstractItemDelegate> itemDelegate;
- QMap<int, QPointer<QAbstractItemDelegate> > rowDelegates;
- QMap<int, QPointer<QAbstractItemDelegate> > columnDelegates;
- QPointer<QItemSelectionModel> selectionModel;
- QItemSelectionModel::SelectionFlag ctrlDragSelectionFlag;
- bool noSelectionOnMousePress;
-
- QAbstractItemView::SelectionMode selectionMode;
- QAbstractItemView::SelectionBehavior selectionBehavior;
-
- QEditorIndexHash editorIndexHash;
- QIndexEditorHash indexEditorHash;
- QSet<QWidget*> persistent;
- QWidget *currentlyCommittingEditor;
-
- QPersistentModelIndex enteredIndex;
- QPersistentModelIndex pressedIndex;
- Qt::KeyboardModifiers pressedModifiers;
- QPoint pressedPosition;
- bool pressedAlreadySelected;
-
- //forces the next mouseMoveEvent to send the viewportEntered signal
- //if the mouse is over the viewport and not over an item
- bool viewportEnteredNeeded;
-
- QAbstractItemView::State state;
- QAbstractItemView::State stateBeforeAnimation;
- QAbstractItemView::EditTriggers editTriggers;
- QAbstractItemView::EditTrigger lastTrigger;
-
- QPersistentModelIndex root;
- QPersistentModelIndex hover;
-
- bool tabKeyNavigation;
-
-#ifndef QT_NO_DRAGANDDROP
- bool showDropIndicator;
- QRect dropIndicatorRect;
- bool dragEnabled;
- QAbstractItemView::DragDropMode dragDropMode;
- bool overwrite;
- QAbstractItemView::DropIndicatorPosition dropIndicatorPosition;
- Qt::DropAction defaultDropAction;
-#endif
-
-#ifdef QT_SOFTKEYS_ENABLED
- QAction *doneSoftKey;
-#endif
-
- QString keyboardInput;
- QElapsedTimer keyboardInputTime;
-
- bool autoScroll;
- QBasicTimer autoScrollTimer;
- int autoScrollMargin;
- int autoScrollCount;
- bool shouldScrollToCurrentOnShow; //used to know if we should scroll to current on show event
- bool shouldClearStatusTip; //if there is a statustip currently shown that need to be cleared when leaving.
-
- bool alternatingColors;
-
- QSize iconSize;
- Qt::TextElideMode textElideMode;
-
- QRegion updateRegion; // used for the internal update system
- QPoint scrollDelayOffset;
-
- QBasicTimer updateTimer;
- QBasicTimer delayedEditing;
- QBasicTimer delayedAutoScroll; //used when an item is clicked
- QBasicTimer delayedReset;
-
- QAbstractItemView::ScrollMode verticalScrollMode;
- QAbstractItemView::ScrollMode horizontalScrollMode;
-
-#ifndef QT_NO_GESTURES
- // the selection before the last mouse down. In case we have to restore it for scrolling
- QItemSelection oldSelection;
- QModelIndex oldCurrent;
-#endif
-
- bool currentIndexSet;
-
- bool wrapItemText;
- mutable bool delayedPendingLayout;
- bool moveCursorUpdatedView;
-
-private:
- mutable QBasicTimer delayedLayout;
- mutable QBasicTimer fetchMoreTimer;
-};
-
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <qvector.h>
-QT_END_INCLUDE_NAMESPACE
-
-template <typename T>
-inline int qBinarySearch(const QVector<T> &vec, const T &item, int start, int end)
-{
- int i = (start + end + 1) >> 1;
- while (end - start > 0) {
- if (vec.at(i) > item)
- end = i - 1;
- else
- start = i;
- i = (start + end + 1) >> 1;
- }
- return i;
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_ITEMVIEWS
-
-#endif // QABSTRACTITEMVIEW_P_H
diff --git a/src/gui/itemviews/qcolumnview.h b/src/gui/itemviews/qcolumnview.h
deleted file mode 100644
index a3f74b89d5..0000000000
--- a/src/gui/itemviews/qcolumnview.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QCOLUMNVIEW_H
-#define QCOLUMNVIEW_H
-
-#include <QtGui/qabstractitemview.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_COLUMNVIEW
-
-class QColumnViewPrivate;
-
-class Q_GUI_EXPORT QColumnView : public QAbstractItemView {
-
-Q_OBJECT
- Q_PROPERTY(bool resizeGripsVisible READ resizeGripsVisible WRITE setResizeGripsVisible)
-
-Q_SIGNALS:
- void updatePreviewWidget(const QModelIndex &index);
-
-public:
- explicit QColumnView(QWidget *parent = 0);
- ~QColumnView();
-
- // QAbstractItemView overloads
- QModelIndex indexAt(const QPoint &point) const;
- void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible);
- QSize sizeHint() const;
- QRect visualRect(const QModelIndex &index) const;
- void setModel(QAbstractItemModel *model);
- void setSelectionModel(QItemSelectionModel * selectionModel);
- void setRootIndex(const QModelIndex &index);
- void selectAll();
-
- // QColumnView functions
- void setResizeGripsVisible(bool visible);
- bool resizeGripsVisible() const;
-
- QWidget *previewWidget() const;
- void setPreviewWidget(QWidget *widget);
-
- void setColumnWidths(const QList<int> &list);
- QList<int> columnWidths() const;
-
-protected:
- QColumnView(QColumnViewPrivate &dd, QWidget *parent = 0);
-
- // QAbstractItemView overloads
- bool isIndexHidden(const QModelIndex &index) const;
- QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
- void resizeEvent(QResizeEvent *event);
- void setSelection(const QRect & rect, QItemSelectionModel::SelectionFlags command);
- QRegion visualRegionForSelection(const QItemSelection &selection) const;
- int horizontalOffset() const;
- int verticalOffset() const;
- void rowsInserted(const QModelIndex &parent, int start, int end);
- void currentChanged(const QModelIndex &current, const QModelIndex &previous);
-
- // QColumnView functions
- void scrollContentsBy(int dx, int dy);
- virtual QAbstractItemView* createColumn(const QModelIndex &rootIndex);
- void initializeColumn(QAbstractItemView *column) const;
-
-private:
- Q_DECLARE_PRIVATE(QColumnView)
- Q_DISABLE_COPY(QColumnView)
- Q_PRIVATE_SLOT(d_func(), void _q_gripMoved(int))
- Q_PRIVATE_SLOT(d_func(), void _q_changeCurrentColumn())
- Q_PRIVATE_SLOT(d_func(), void _q_clicked(const QModelIndex &))
-};
-
-#endif // QT_NO_COLUMNVIEW
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QCOLUMNVIEW_H
-
diff --git a/src/gui/itemviews/qcolumnview_p.h b/src/gui/itemviews/qcolumnview_p.h
deleted file mode 100644
index c42c236445..0000000000
--- a/src/gui/itemviews/qcolumnview_p.h
+++ /dev/null
@@ -1,189 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QCOLUMNVIEW_P_H
-#define QCOLUMNVIEW_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qcolumnview.h"
-
-#ifndef QT_NO_QCOLUMNVIEW
-
-#include <private/qabstractitemview_p.h>
-
-#include <QtCore/qabstractitemmodel.h>
-#include <QtCore/qpropertyanimation.h>
-#include <QtGui/qabstractitemdelegate.h>
-#include <QtGui/qabstractitemview.h>
-#include <QtGui/qitemdelegate.h>
-#include <qlistview.h>
-#include <qevent.h>
-#include <qscrollbar.h>
-
-QT_BEGIN_NAMESPACE
-
-class QColumnViewPreviewColumn : public QAbstractItemView {
-
-public:
- QColumnViewPreviewColumn(QWidget *parent) : QAbstractItemView(parent), previewWidget(0) {
- }
-
- void setPreviewWidget(QWidget *widget) {
- previewWidget = widget;
- setMinimumWidth(previewWidget->minimumWidth());
- }
-
- void resizeEvent(QResizeEvent * event){
- if (!previewWidget)
- return;
- previewWidget->resize(
- qMax(previewWidget->minimumWidth(), event->size().width()),
- previewWidget->height());
- QSize p = viewport()->size();
- QSize v = previewWidget->size();
- horizontalScrollBar()->setRange(0, v.width() - p.width());
- horizontalScrollBar()->setPageStep(p.width());
- verticalScrollBar()->setRange(0, v.height() - p.height());
- verticalScrollBar()->setPageStep(p.height());
-
- QAbstractScrollArea::resizeEvent(event);
- }
-
- QRect visualRect(const QModelIndex &) const
- {
- return QRect();
- }
- void scrollTo(const QModelIndex &, ScrollHint)
- {
- }
- QModelIndex indexAt(const QPoint &) const
- {
- return QModelIndex();
- }
- QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers)
- {
- return QModelIndex();
- }
- int horizontalOffset () const {
- return 0;
- }
- int verticalOffset () const {
- return 0;
- }
- QRegion visualRegionForSelection(const QItemSelection &) const
- {
- return QRegion();
- }
- bool isIndexHidden(const QModelIndex &) const
- {
- return false;
- }
- void setSelection(const QRect &, QItemSelectionModel::SelectionFlags)
- {
- }
-private:
- QWidget *previewWidget;
-};
-
-class Q_AUTOTEST_EXPORT QColumnViewPrivate : public QAbstractItemViewPrivate
-{
- Q_DECLARE_PUBLIC(QColumnView)
-
-public:
- QColumnViewPrivate();
- ~QColumnViewPrivate();
- void initialize();
-
- QAbstractItemView *createColumn(const QModelIndex &index, bool show);
-
- void updateScrollbars();
- void closeColumns(const QModelIndex &parent = QModelIndex(), bool build = false);
- void doLayout();
- void setPreviewWidget(QWidget *widget);
- void checkColumnCreation(const QModelIndex &parent);
-
-
- void _q_gripMoved(int offset);
- void _q_changeCurrentColumn();
- void _q_clicked(const QModelIndex &index);
- void _q_columnsInserted(const QModelIndex &parent, int start, int end);
-
- QList<QAbstractItemView*> columns;
- QVector<int> columnSizes; // used during init and corner moving
- bool showResizeGrips;
- int offset;
-#ifndef QT_NO_ANIMATION
- QPropertyAnimation currentAnimation;
-#endif
- QWidget *previewWidget;
- QAbstractItemView *previewColumn;
-};
-
-/*!
- * This is a delegate that will paint the triangle
- */
-class QColumnViewDelegate : public QItemDelegate
-{
-
-public:
- explicit QColumnViewDelegate(QObject *parent = 0) : QItemDelegate(parent) {}
- ~QColumnViewDelegate() {}
-
- void paint(QPainter *painter,
- const QStyleOptionViewItem &option,
- const QModelIndex &index) const;
-};
-#endif // QT_NO_QCOLUMNVIEW
-
-
-QT_END_NAMESPACE
-#endif //QCOLUMNVIEW_P_H
-
diff --git a/src/gui/itemviews/qdirmodel.h b/src/gui/itemviews/qdirmodel.h
deleted file mode 100644
index 2b1cd9d81b..0000000000
--- a/src/gui/itemviews/qdirmodel.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDIRMODEL_H
-#define QDIRMODEL_H
-
-#include <QtCore/qabstractitemmodel.h>
-#include <QtCore/qdir.h>
-#include <QtGui/qfileiconprovider.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_DIRMODEL
-
-class QDirModelPrivate;
-
-class Q_GUI_EXPORT QDirModel : public QAbstractItemModel
-{
- Q_OBJECT
- Q_PROPERTY(bool resolveSymlinks READ resolveSymlinks WRITE setResolveSymlinks)
- Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
- Q_PROPERTY(bool lazyChildCount READ lazyChildCount WRITE setLazyChildCount)
-
-public:
- enum Roles {
- FileIconRole = Qt::DecorationRole,
- FilePathRole = Qt::UserRole + 1,
- FileNameRole
- };
-
- QDirModel(const QStringList &nameFilters, QDir::Filters filters,
- QDir::SortFlags sort, QObject *parent = 0);
- explicit QDirModel(QObject *parent = 0);
- ~QDirModel();
-
- 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;
-
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
-
- QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
-
- bool hasChildren(const QModelIndex &index = QModelIndex()) const;
- Qt::ItemFlags flags(const QModelIndex &index) const;
-
- void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
-
- QStringList mimeTypes() const;
- QMimeData *mimeData(const QModelIndexList &indexes) const;
- bool dropMimeData(const QMimeData *data, Qt::DropAction action,
- int row, int column, const QModelIndex &parent);
- Qt::DropActions supportedDropActions() const;
-
- // QDirModel specific API
-
- void setIconProvider(QFileIconProvider *provider);
- QFileIconProvider *iconProvider() const;
-
- void setNameFilters(const QStringList &filters);
- QStringList nameFilters() const;
-
- void setFilter(QDir::Filters filters);
- QDir::Filters filter() const;
-
- void setSorting(QDir::SortFlags sort);
- QDir::SortFlags sorting() const;
-
- void setResolveSymlinks(bool enable);
- bool resolveSymlinks() const;
-
- void setReadOnly(bool enable);
- bool isReadOnly() const;
-
- void setLazyChildCount(bool enable);
- bool lazyChildCount() const;
-
- QModelIndex index(const QString &path, int column = 0) const;
-
- bool isDir(const QModelIndex &index) const;
- QModelIndex mkdir(const QModelIndex &parent, const QString &name);
- bool rmdir(const QModelIndex &index);
- bool remove(const QModelIndex &index);
-
- QString filePath(const QModelIndex &index) const;
- QString fileName(const QModelIndex &index) const;
- QIcon fileIcon(const QModelIndex &index) const;
- QFileInfo fileInfo(const QModelIndex &index) const;
-
-#ifdef Q_NO_USING_KEYWORD
- inline QObject *parent() const { return QObject::parent(); }
-#else
- using QObject::parent;
-#endif
-
-public Q_SLOTS:
- void refresh(const QModelIndex &parent = QModelIndex());
-
-protected:
- QDirModel(QDirModelPrivate &, QObject *parent = 0);
- friend class QFileDialogPrivate;
-
-private:
- Q_DECLARE_PRIVATE(QDirModel)
- Q_DISABLE_COPY(QDirModel)
- Q_PRIVATE_SLOT(d_func(), void _q_refresh())
-};
-
-#endif // QT_NO_DIRMODEL
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDIRMODEL_H
diff --git a/src/gui/itemviews/qfileiconprovider.h b/src/gui/itemviews/qfileiconprovider.h
deleted file mode 100644
index 5a70f80062..0000000000
--- a/src/gui/itemviews/qfileiconprovider.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFILEICONPROVIDER_H
-#define QFILEICONPROVIDER_H
-
-#include <QtCore/qfileinfo.h>
-#include <QtCore/qscopedpointer.h>
-#include <QtGui/qicon.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_FILEICONPROVIDER
-
-class QFileIconProviderPrivate;
-
-class Q_GUI_EXPORT QFileIconProvider
-{
-public:
- QFileIconProvider();
- virtual ~QFileIconProvider();
- enum IconType { Computer, Desktop, Trashcan, Network, Drive, Folder, File };
- virtual QIcon icon(IconType type) const;
- virtual QIcon icon(const QFileInfo &info) const;
- virtual QString type(const QFileInfo &info) const;
-
-private:
- Q_DECLARE_PRIVATE(QFileIconProvider)
- QScopedPointer<QFileIconProviderPrivate> d_ptr;
- Q_DISABLE_COPY(QFileIconProvider)
-};
-
-#endif // QT_NO_FILEICONPROVIDER
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QFILEICONPROVIDER_H
-
diff --git a/src/gui/itemviews/qheaderview.h b/src/gui/itemviews/qheaderview.h
deleted file mode 100644
index bd0b7666b0..0000000000
--- a/src/gui/itemviews/qheaderview.h
+++ /dev/null
@@ -1,250 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QHEADERVIEW_H
-#define QHEADERVIEW_H
-
-#include <QtGui/qabstractitemview.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_ITEMVIEWS
-
-class QHeaderViewPrivate;
-class QStyleOptionHeader;
-
-class Q_GUI_EXPORT QHeaderView : public QAbstractItemView
-{
- Q_OBJECT
- Q_PROPERTY(bool showSortIndicator READ isSortIndicatorShown WRITE setSortIndicatorShown)
- Q_PROPERTY(bool highlightSections READ highlightSections WRITE setHighlightSections)
- Q_PROPERTY(bool stretchLastSection READ stretchLastSection WRITE setStretchLastSection)
- Q_PROPERTY(bool cascadingSectionResizes READ cascadingSectionResizes WRITE setCascadingSectionResizes)
- Q_PROPERTY(int defaultSectionSize READ defaultSectionSize WRITE setDefaultSectionSize)
- Q_PROPERTY(int minimumSectionSize READ minimumSectionSize WRITE setMinimumSectionSize)
- Q_PROPERTY(Qt::Alignment defaultAlignment READ defaultAlignment WRITE setDefaultAlignment)
- Q_ENUMS(ResizeMode)
-
-public:
-
- enum ResizeMode
- {
- Interactive,
- Stretch,
- Fixed,
- ResizeToContents,
- Custom = Fixed
- };
-
- explicit QHeaderView(Qt::Orientation orientation, QWidget *parent = 0);
- virtual ~QHeaderView();
-
- void setModel(QAbstractItemModel *model);
-
- Qt::Orientation orientation() const;
- int offset() const;
- int length() const;
- QSize sizeHint() const;
- int sectionSizeHint(int logicalIndex) const;
-
- int visualIndexAt(int position) const;
- int logicalIndexAt(int position) const;
-
- inline int logicalIndexAt(int x, int y) const;
- inline int logicalIndexAt(const QPoint &pos) const;
-
- int sectionSize(int logicalIndex) const;
- int sectionPosition(int logicalIndex) const;
- int sectionViewportPosition(int logicalIndex) const;
-
- void moveSection(int from, int to);
- void swapSections(int first, int second);
- void resizeSection(int logicalIndex, int size);
- void resizeSections(QHeaderView::ResizeMode mode);
-
- bool isSectionHidden(int logicalIndex) const;
- void setSectionHidden(int logicalIndex, bool hide);
- int hiddenSectionCount() const;
-
- inline void hideSection(int logicalIndex);
- inline void showSection(int logicalIndex);
-
- int count() const;
- int visualIndex(int logicalIndex) const;
- int logicalIndex(int visualIndex) const;
-
- void setMovable(bool movable);
- bool isMovable() const;
-
- void setClickable(bool clickable);
- bool isClickable() const;
-
- void setHighlightSections(bool highlight);
- bool highlightSections() const;
-
- void setResizeMode(ResizeMode mode);
- void setResizeMode(int logicalIndex, ResizeMode mode);
- ResizeMode resizeMode(int logicalIndex) const;
- int stretchSectionCount() const;
-
- void setSortIndicatorShown(bool show);
- bool isSortIndicatorShown() const;
-
- void setSortIndicator(int logicalIndex, Qt::SortOrder order);
- int sortIndicatorSection() const;
- Qt::SortOrder sortIndicatorOrder() const;
-
- bool stretchLastSection() const;
- void setStretchLastSection(bool stretch);
-
- bool cascadingSectionResizes() const;
- void setCascadingSectionResizes(bool enable);
-
- int defaultSectionSize() const;
- void setDefaultSectionSize(int size);
-
- int minimumSectionSize() const;
- void setMinimumSectionSize(int size);
-
- Qt::Alignment defaultAlignment() const;
- void setDefaultAlignment(Qt::Alignment alignment);
-
- void doItemsLayout();
- bool sectionsMoved() const;
- bool sectionsHidden() const;
-
-#ifndef QT_NO_DATASTREAM
- QByteArray saveState() const;
- bool restoreState(const QByteArray &state);
-#endif
-
- void reset();
-
-public Q_SLOTS:
- void setOffset(int offset);
- void setOffsetToSectionPosition(int visualIndex);
- void setOffsetToLastSection();
- void headerDataChanged(Qt::Orientation orientation, int logicalFirst, int logicalLast);
-
-Q_SIGNALS:
- void sectionMoved(int logicalIndex, int oldVisualIndex, int newVisualIndex);
- void sectionResized(int logicalIndex, int oldSize, int newSize);
- void sectionPressed(int logicalIndex);
- void sectionClicked(int logicalIndex);
- void sectionEntered(int logicalIndex);
- void sectionDoubleClicked(int logicalIndex);
- void sectionCountChanged(int oldCount, int newCount);
- void sectionHandleDoubleClicked(int logicalIndex);
- void sectionAutoResize(int logicalIndex, QHeaderView::ResizeMode mode);
- void geometriesChanged();
- void sortIndicatorChanged(int logicalIndex, Qt::SortOrder order);
-
-protected Q_SLOTS:
- void updateSection(int logicalIndex);
- void resizeSections();
- void sectionsInserted(const QModelIndex &parent, int logicalFirst, int logicalLast);
- void sectionsAboutToBeRemoved(const QModelIndex &parent, int logicalFirst, int logicalLast);
-
-protected:
- QHeaderView(QHeaderViewPrivate &dd, Qt::Orientation orientation, QWidget *parent = 0);
- void initialize();
-
- void initializeSections();
- void initializeSections(int start, int end);
- void currentChanged(const QModelIndex &current, const QModelIndex &old);
-
- bool event(QEvent *e);
- void paintEvent(QPaintEvent *e);
- void mousePressEvent(QMouseEvent *e);
- void mouseMoveEvent(QMouseEvent *e);
- void mouseReleaseEvent(QMouseEvent *e);
- void mouseDoubleClickEvent(QMouseEvent *e);
- bool viewportEvent(QEvent *e);
-
- virtual void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const;
- virtual QSize sectionSizeFromContents(int logicalIndex) const;
-
- int horizontalOffset() const;
- int verticalOffset() const;
- void updateGeometries();
- void scrollContentsBy(int dx, int dy);
-
- void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
- void rowsInserted(const QModelIndex &parent, int start, int end);
-
- QRect visualRect(const QModelIndex &index) const;
- void scrollTo(const QModelIndex &index, ScrollHint hint);
-
- QModelIndex indexAt(const QPoint &p) const;
- bool isIndexHidden(const QModelIndex &index) const;
-
- QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers);
- void setSelection(const QRect& rect, QItemSelectionModel::SelectionFlags flags);
- QRegion visualRegionForSelection(const QItemSelection &selection) const;
- void initStyleOption(QStyleOptionHeader *option) const;
-
-private:
- Q_PRIVATE_SLOT(d_func(), void _q_sectionsRemoved(const QModelIndex &parent, int logicalFirst, int logicalLast))
- Q_PRIVATE_SLOT(d_func(), void _q_layoutAboutToBeChanged())
- Q_DECLARE_PRIVATE(QHeaderView)
- Q_DISABLE_COPY(QHeaderView)
-};
-
-inline int QHeaderView::logicalIndexAt(int ax, int ay) const
-{ return orientation() == Qt::Horizontal ? logicalIndexAt(ax) : logicalIndexAt(ay); }
-inline int QHeaderView::logicalIndexAt(const QPoint &apos) const
-{ return logicalIndexAt(apos.x(), apos.y()); }
-inline void QHeaderView::hideSection(int alogicalIndex)
-{ setSectionHidden(alogicalIndex, true); }
-inline void QHeaderView::showSection(int alogicalIndex)
-{ setSectionHidden(alogicalIndex, false); }
-
-#endif // QT_NO_ITEMVIEWS
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QHEADERVIEW_H
diff --git a/src/gui/itemviews/qheaderview_p.h b/src/gui/itemviews/qheaderview_p.h
deleted file mode 100644
index f4b7ff7df0..0000000000
--- a/src/gui/itemviews/qheaderview_p.h
+++ /dev/null
@@ -1,366 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QHEADERVIEW_P_H
-#define QHEADERVIEW_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "private/qabstractitemview_p.h"
-
-#ifndef QT_NO_ITEMVIEWS
-
-#include "QtCore/qbitarray.h"
-#include "QtGui/qapplication.h"
-#include "QtGui/qlabel.h"
-
-QT_BEGIN_NAMESPACE
-
-class QHeaderViewPrivate: public QAbstractItemViewPrivate
-{
- Q_DECLARE_PUBLIC(QHeaderView)
-
-public:
- enum StateVersion { VersionMarker = 0xff };
-
- QHeaderViewPrivate()
- : state(NoState),
- offset(0),
- sortIndicatorOrder(Qt::DescendingOrder),
- sortIndicatorSection(0),
- sortIndicatorShown(false),
- lastPos(-1),
- firstPos(-1),
- originalSize(-1),
- section(-1),
- target(-1),
- pressed(-1),
- hover(-1),
- length(0),
- sectionCount(0),
- movableSections(false),
- clickableSections(false),
- highlightSelected(false),
- stretchLastSection(false),
- cascadingResizing(false),
- resizeRecursionBlock(false),
- stretchSections(0),
- contentsSections(0),
- minimumSectionSize(-1),
- lastSectionSize(0),
- sectionIndicatorOffset(0),
- sectionIndicator(0),
- globalResizeMode(QHeaderView::Interactive)
- {}
-
-
- int lastVisibleVisualIndex() const;
- int sectionHandleAt(int position);
- void setupSectionIndicator(int section, int position);
- void updateSectionIndicator(int section, int position);
- void updateHiddenSections(int logicalFirst, int logicalLast);
- void resizeSections(QHeaderView::ResizeMode globalMode, bool useGlobalMode = false);
- void _q_sectionsRemoved(const QModelIndex &,int,int);
- void _q_layoutAboutToBeChanged();
- void _q_layoutChanged();
-
- bool isSectionSelected(int section) const;
-
- inline bool rowIntersectsSelection(int row) const {
- return (selectionModel ? selectionModel->rowIntersectsSelection(row, root) : false);
- }
-
- inline bool columnIntersectsSelection(int column) const {
- return (selectionModel ? selectionModel->columnIntersectsSelection(column, root) : false);
- }
-
- inline bool sectionIntersectsSelection(int logical) const {
- return (orientation == Qt::Horizontal ? columnIntersectsSelection(logical) : rowIntersectsSelection(logical));
- }
-
- inline bool isRowSelected(int row) const {
- return (selectionModel ? selectionModel->isRowSelected(row, root) : false);
- }
-
- inline bool isColumnSelected(int column) const {
- return (selectionModel ? selectionModel->isColumnSelected(column, root) : false);
- }
-
- inline void prepareSectionSelected() {
- if (!selectionModel || !selectionModel->hasSelection())
- sectionSelected.clear();
- else if (sectionSelected.count() != sectionCount * 2)
- sectionSelected.fill(false, sectionCount * 2);
- else sectionSelected.fill(false);
- }
-
- inline bool reverse() const {
- return orientation == Qt::Horizontal && q_func()->isRightToLeft();
- }
-
- inline int logicalIndex(int visualIndex) const {
- return logicalIndices.isEmpty() ? visualIndex : logicalIndices.at(visualIndex);
- }
-
- inline int visualIndex(int logicalIndex) const {
- return visualIndices.isEmpty() ? logicalIndex : visualIndices.at(logicalIndex);
- }
-
- inline void setDefaultValues(Qt::Orientation o) {
- orientation = o;
- defaultSectionSize = (o == Qt::Horizontal ? 100
- : qMax(q_func()->minimumSectionSize(), 30));
- defaultAlignment = (o == Qt::Horizontal
- ? Qt::Alignment(Qt::AlignCenter)
- : Qt::AlignLeft|Qt::AlignVCenter);
- }
-
- inline bool isVisualIndexHidden(int visual) const {
- return !sectionHidden.isEmpty() && sectionHidden.at(visual);
- }
-
- inline void setVisualIndexHidden(int visual, bool hidden) {
- if (!sectionHidden.isEmpty()) sectionHidden.setBit(visual, hidden);
- }
-
- inline bool hasAutoResizeSections() const {
- return stretchSections || stretchLastSection || contentsSections;
- }
-
- QStyleOptionHeader getStyleOption() const;
-
- inline void invalidateCachedSizeHint() const {
- cachedSizeHint = QSize();
- }
-
- inline void initializeIndexMapping() const {
- if (visualIndices.count() != sectionCount
- || logicalIndices.count() != sectionCount) {
- visualIndices.resize(sectionCount);
- logicalIndices.resize(sectionCount);
- for (int s = 0; s < sectionCount; ++s) {
- visualIndices[s] = s;
- logicalIndices[s] = s;
- }
- }
- }
-
- inline void clearCascadingSections() {
- firstCascadingSection = sectionCount;
- lastCascadingSection = 0;
- cascadingSectionSize.clear();
- }
-
- inline void saveCascadingSectionSize(int visual, int size) {
- if (!cascadingSectionSize.contains(visual)) {
- cascadingSectionSize.insert(visual, size);
- firstCascadingSection = qMin(firstCascadingSection, visual);
- lastCascadingSection = qMax(lastCascadingSection, visual);
- }
- }
-
- inline bool sectionIsCascadable(int visual) const {
- return headerSectionResizeMode(visual) == QHeaderView::Interactive;
- }
-
- inline int modelSectionCount() const {
- return (orientation == Qt::Horizontal
- ? model->columnCount(root)
- : model->rowCount(root));
- }
-
- inline bool modelIsEmpty() const {
- return (model->rowCount(root) == 0 || model->columnCount(root) == 0);
- }
-
- inline void doDelayedResizeSections() {
- if (!delayedResize.isActive())
- delayedResize.start(0, q_func());
- }
-
- inline void executePostedResize() const {
- if (delayedResize.isActive() && state == NoState) {
- const_cast<QHeaderView*>(q_func())->resizeSections();
- }
- }
-
- void clear();
- void flipSortIndicator(int section);
- void cascadingResize(int visual, int newSize);
-
- enum State { NoState, ResizeSection, MoveSection, SelectSections, NoClear } state;
-
- int offset;
- Qt::Orientation orientation;
- Qt::SortOrder sortIndicatorOrder;
- int sortIndicatorSection;
- bool sortIndicatorShown;
-
- mutable QVector<int> visualIndices; // visualIndex = visualIndices.at(logicalIndex)
- mutable QVector<int> logicalIndices; // logicalIndex = row or column in the model
- mutable QBitArray sectionSelected; // from logical index to bit
- mutable QBitArray sectionHidden; // from visual index to bit
- mutable QHash<int, int> hiddenSectionSize; // from logical index to section size
- mutable QHash<int, int> cascadingSectionSize; // from visual index to section size
- mutable QSize cachedSizeHint;
- mutable QBasicTimer delayedResize;
-
- int firstCascadingSection;
- int lastCascadingSection;
-
- int lastPos;
- int firstPos;
- int originalSize;
- int section; // used for resizing and moving sections
- int target;
- int pressed;
- int hover;
-
- int length;
- int sectionCount;
- bool movableSections;
- bool clickableSections;
- bool highlightSelected;
- bool stretchLastSection;
- bool cascadingResizing;
- bool resizeRecursionBlock;
- int stretchSections;
- int contentsSections;
- int defaultSectionSize;
- int minimumSectionSize;
- int lastSectionSize; // $$$
- int sectionIndicatorOffset;
- Qt::Alignment defaultAlignment;
- QLabel *sectionIndicator;
- QHeaderView::ResizeMode globalResizeMode;
- QList<QPersistentModelIndex> persistentHiddenSections;
-
- // header section spans
-
- struct SectionSpan {
- int size;
- int count;
- QHeaderView::ResizeMode resizeMode;
- inline SectionSpan() : size(0), count(0), resizeMode(QHeaderView::Interactive) {}
- inline SectionSpan(int length, int sections, QHeaderView::ResizeMode mode)
- : size(length), count(sections), resizeMode(mode) {}
- inline int sectionSize() const { return (count > 0 ? size / count : 0); }
-#ifndef QT_NO_DATASTREAM
- inline void write(QDataStream &out) const
- { out << size; out << count; out << (int)resizeMode; }
- inline void read(QDataStream &in)
- { in >> size; in >> count; int m; in >> m; resizeMode = (QHeaderView::ResizeMode)m; }
-#endif
- };
-
- QVector<SectionSpan> sectionSpans;
-
- void createSectionSpan(int start, int end, int size, QHeaderView::ResizeMode mode);
- void removeSectionsFromSpans(int start, int end);
- void resizeSectionSpan(int visualIndex, int oldSize, int newSize);
- void setDefaultSectionSize(int size);
-
- inline int headerSectionCount() const { // for debugging
- int count = 0;
- for (int i = 0; i < sectionSpans.count(); ++i)
- count += sectionSpans.at(i).count;
- return count;
- }
-
- inline int headerLength() const { // for debugging
- int len = 0;
- for (int i = 0; i < sectionSpans.count(); ++i)
- len += sectionSpans.at(i).size;
- return len;
- }
-
- inline void removeSpans(const QList<int> &spans) {
- for (int i = spans.count() - 1; i >= 0; --i) {
- length -= sectionSpans.at(spans.at(i)).size;
- sectionSpans.remove(spans.at(i));
- }
- }
-
- inline int sectionSpanIndex(int visual) const {
- int section_start = 0;
- for (int i = 0; i < sectionSpans.count(); ++i) {
- int section_end = section_start + sectionSpans.at(i).count - 1;
- if (visual >= section_start && visual <= section_end)
- return i;
- section_start = section_end + 1;
- }
- return -1;
- }
-
- int headerSectionSize(int visual) const;
- int headerSectionPosition(int visual) const;
- int headerVisualIndexAt(int position) const;
-
- // resize mode
- void setHeaderSectionResizeMode(int visual, QHeaderView::ResizeMode mode);
- QHeaderView::ResizeMode headerSectionResizeMode(int visual) const;
- void setGlobalHeaderResizeMode(QHeaderView::ResizeMode mode);
-
- // other
- int viewSectionSizeHint(int logical) const;
- int adjustedVisualIndex(int visualIndex) const;
-
-#ifndef QT_NO_DATASTREAM
- void write(QDataStream &out) const;
- bool read(QDataStream &in);
-#endif
-
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_ITEMVIEWS
-
-#endif // QHEADERVIEW_P_H
diff --git a/src/gui/itemviews/qitemdelegate.h b/src/gui/itemviews/qitemdelegate.h
deleted file mode 100644
index 2df3d1c1c1..0000000000
--- a/src/gui/itemviews/qitemdelegate.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QITEMDELEGATE_H
-#define QITEMDELEGATE_H
-
-#include <QtGui/qabstractitemdelegate.h>
-#include <QtCore/qstring.h>
-#include <QtGui/qpixmap.h>
-#include <QtCore/qvariant.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_ITEMVIEWS
-
-class QItemDelegatePrivate;
-class QItemEditorFactory;
-
-class Q_GUI_EXPORT QItemDelegate : public QAbstractItemDelegate
-{
- Q_OBJECT
- Q_PROPERTY(bool clipping READ hasClipping WRITE setClipping)
-
-public:
- explicit QItemDelegate(QObject *parent = 0);
- ~QItemDelegate();
-
- bool hasClipping() const;
- void setClipping(bool clip);
-
- // painting
- void paint(QPainter *painter,
- const QStyleOptionViewItem &option,
- const QModelIndex &index) const;
- QSize sizeHint(const QStyleOptionViewItem &option,
- const QModelIndex &index) const;
-
- // editing
- 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;
-
- // editor factory
- QItemEditorFactory *itemEditorFactory() const;
- void setItemEditorFactory(QItemEditorFactory *factory);
-
-protected:
- virtual void drawDisplay(QPainter *painter, const QStyleOptionViewItem &option,
- const QRect &rect, const QString &text) const;
- virtual void drawDecoration(QPainter *painter, const QStyleOptionViewItem &option,
- const QRect &rect, const QPixmap &pixmap) const;
- virtual void drawFocus(QPainter *painter, const QStyleOptionViewItem &option,
- const QRect &rect) const;
- virtual void drawCheck(QPainter *painter, const QStyleOptionViewItem &option,
- const QRect &rect, Qt::CheckState state) const;
- void drawBackground(QPainter *painter, const QStyleOptionViewItem &option,
- const QModelIndex &index) const;
-
- void doLayout(const QStyleOptionViewItem &option,
- QRect *checkRect, QRect *iconRect, QRect *textRect, bool hint) const;
-
- QRect rect(const QStyleOptionViewItem &option, const QModelIndex &index, int role) const;
-
- bool eventFilter(QObject *object, QEvent *event);
- bool editorEvent(QEvent *event, QAbstractItemModel *model,
- const QStyleOptionViewItem &option, const QModelIndex &index);
-
- QStyleOptionViewItem setOptions(const QModelIndex &index,
- const QStyleOptionViewItem &option) const;
-
- QPixmap decoration(const QStyleOptionViewItem &option, const QVariant &variant) const;
- QPixmap *selected(const QPixmap &pixmap, const QPalette &palette, bool enabled) const;
-
- QRect check(const QStyleOptionViewItem &option, const QRect &bounding,
- const QVariant &variant) const;
- QRect textRectangle(QPainter *painter, const QRect &rect,
- const QFont &font, const QString &text) const;
-
-private:
- Q_DECLARE_PRIVATE(QItemDelegate)
- Q_DISABLE_COPY(QItemDelegate)
-
- Q_PRIVATE_SLOT(d_func(), void _q_commitDataAndCloseEditor(QWidget*))
-};
-
-#endif // QT_NO_ITEMVIEWS
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QITEMDELEGATE_H
diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp
deleted file mode 100644
index 44b45d835d..0000000000
--- a/src/gui/itemviews/qlistview.cpp
+++ /dev/null
@@ -1,3212 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qlistview.h"
-
-#ifndef QT_NO_LISTVIEW
-#include <qabstractitemdelegate.h>
-#include <qapplication.h>
-#include <qpainter.h>
-#include <qbitmap.h>
-#include <qvector.h>
-#include <qstyle.h>
-#include <qevent.h>
-#include <qscrollbar.h>
-#include <qrubberband.h>
-#include <private/qlistview_p.h>
-#include <qdebug.h>
-#ifndef QT_NO_ACCESSIBILITY
-#include <qaccessible.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QListView
-
- \brief The QListView class provides a list or icon view onto a model.
-
- \ingroup model-view
- \ingroup advanced
-
-
- A QListView presents items stored in a model, either as a simple
- non-hierarchical list, or as a collection of icons. This class is used
- to provide lists and icon views that were previously provided by the
- \c QListBox and \c QIconView classes, but using the more flexible
- approach provided by Qt's model/view architecture.
-
- The QListView class is one of the \l{Model/View Classes}
- and is part of Qt's \l{Model/View Programming}{model/view framework}.
-
- This view does not display horizontal or vertical headers; to display
- a list of items with a horizontal header, use QTreeView instead.
-
- QListView implements the interfaces defined by the
- QAbstractItemView class to allow it to display data provided by
- models derived from the QAbstractItemModel class.
-
- Items in a list view can be displayed using one of two view modes:
- In \l ListMode, the items are displayed in the form of a simple list;
- in \l IconMode, the list view takes the form of an \e{icon view} in
- which the items are displayed with icons like files in a file manager.
- By default, the list view is in \l ListMode. To change the view mode,
- use the setViewMode() function, and to determine the current view mode,
- use viewMode().
-
- Items in these views are laid out in the direction specified by the
- flow() of the list view. The items may be fixed in place, or allowed
- to move, depending on the view's movement() state.
-
- If the items in the model cannot be completely laid out in the
- direction of flow, they can be wrapped at the boundary of the view
- widget; this depends on isWrapping(). This property is useful when the
- items are being represented by an icon view.
-
- The resizeMode() and layoutMode() govern how and when the items are
- laid out. Items are spaced according to their spacing(), and can exist
- within a notional grid of size specified by gridSize(). The items can
- be rendered as large or small icons depending on their iconSize().
-
- \table 100%
- \row \o \inlineimage windowsxp-listview.png Screenshot of a Windows XP style list view
- \o \inlineimage macintosh-listview.png Screenshot of a Macintosh style table view
- \o \inlineimage plastique-listview.png Screenshot of a Plastique style table view
- \row \o A \l{Windows XP Style Widget Gallery}{Windows XP style} list view.
- \o A \l{Macintosh Style Widget Gallery}{Macintosh style} list view.
- \o A \l{Plastique Style Widget Gallery}{Plastique style} list view.
- \endtable
-
- \section1 Improving Performance
-
- It is possible to give the view hints about the data it is handling in order
- to improve its performance when displaying large numbers of items. One approach
- that can be taken for views that are intended to display items with equal sizes
- is to set the \l uniformItemSizes property to true.
-
- \sa {View Classes}, QTreeView, QTableView, QListWidget
-*/
-
-/*!
- \enum QListView::ViewMode
-
- \value ListMode The items are laid out using TopToBottom flow, with Small size and Static movement
- \value IconMode The items are laid out using LeftToRight flow, with Large size and Free movement
-*/
-
-/*!
- \enum QListView::Movement
-
- \value Static The items cannot be moved by the user.
- \value Free The items can be moved freely by the user.
- \value Snap The items snap to the specified grid when moved; see
- setGridSize().
-*/
-
-/*!
- \enum QListView::Flow
-
- \value LeftToRight The items are laid out in the view from the left
- to the right.
- \value TopToBottom The items are laid out in the view from the top
- to the bottom.
-*/
-
-/*!
- \enum QListView::ResizeMode
-
- \value Fixed The items will only be laid out the first time the view is shown.
- \value Adjust The items will be laid out every time the view is resized.
-*/
-
-/*!
- \enum QListView::LayoutMode
-
- \value SinglePass The items are laid out all at once.
- \value Batched The items are laid out in batches of \l batchSize items.
- \sa batchSize
-*/
-
-/*!
- \since 4.2
- \fn void QListView::indexesMoved(const QModelIndexList &indexes)
-
- This signal is emitted when the specified \a indexes are moved in the view.
-*/
-
-/*!
- Creates a new QListView with the given \a parent to view a model.
- Use setModel() to set the model.
-*/
-QListView::QListView(QWidget *parent)
- : QAbstractItemView(*new QListViewPrivate, parent)
-{
- setViewMode(ListMode);
- setSelectionMode(SingleSelection);
- setAttribute(Qt::WA_MacShowFocusRect);
- Q_D(QListView); // We rely on a qobject_cast for PM_DefaultFrameWidth to change
- d->updateStyledFrameWidths(); // hence we have to force an update now that the object has been constructed
-}
-
-/*!
- \internal
-*/
-QListView::QListView(QListViewPrivate &dd, QWidget *parent)
- : QAbstractItemView(dd, parent)
-{
- setViewMode(ListMode);
- setSelectionMode(SingleSelection);
- setAttribute(Qt::WA_MacShowFocusRect);
- Q_D(QListView); // We rely on a qobject_cast for PM_DefaultFrameWidth to change
- d->updateStyledFrameWidths(); // hence we have to force an update now that the object has been constructed
-}
-
-/*!
- Destroys the view.
-*/
-QListView::~QListView()
-{
-}
-
-/*!
- \property QListView::movement
- \brief whether the items can be moved freely, are snapped to a
- grid, or cannot be moved at all.
-
- This property determines how the user can move the items in the
- view. \l Static means that the items can't be moved the user. \l
- Free means that the user can drag and drop the items to any
- position in the view. \l Snap means that the user can drag and
- drop the items, but only to the positions in a notional grid
- signified by the gridSize property.
-
- Setting this property when the view is visible will cause the
- items to be laid out again.
-
- By default, this property is set to \l Static.
-
- \sa gridSize, resizeMode, viewMode
-*/
-void QListView::setMovement(Movement movement)
-{
- Q_D(QListView);
- d->modeProperties |= uint(QListViewPrivate::Movement);
- d->movement = movement;
-
-#ifndef QT_NO_DRAGANDDROP
- bool movable = (movement != Static);
- setDragEnabled(movable);
- d->viewport->setAcceptDrops(movable);
-#endif
- d->doDelayedItemsLayout();
-}
-
-QListView::Movement QListView::movement() const
-{
- Q_D(const QListView);
- return d->movement;
-}
-
-/*!
- \property QListView::flow
- \brief which direction the items layout should flow.
-
- If this property is \l LeftToRight, the items will be laid out left
- to right. If the \l isWrapping property is true, the layout will wrap
- when it reaches the right side of the visible area. If this
- property is \l TopToBottom, the items will be laid out from the top
- of the visible area, wrapping when it reaches the bottom.
-
- Setting this property when the view is visible will cause the
- items to be laid out again.
-
- By default, this property is set to \l TopToBottom.
-
- \sa viewMode
-*/
-void QListView::setFlow(Flow flow)
-{
- Q_D(QListView);
- d->modeProperties |= uint(QListViewPrivate::Flow);
- d->flow = flow;
- d->doDelayedItemsLayout();
-}
-
-QListView::Flow QListView::flow() const
-{
- Q_D(const QListView);
- return d->flow;
-}
-
-/*!
- \property QListView::isWrapping
- \brief whether the items layout should wrap.
-
- This property holds whether the layout should wrap when there is
- no more space in the visible area. The point at which the layout wraps
- depends on the \l flow property.
-
- Setting this property when the view is visible will cause the
- items to be laid out again.
-
- By default, this property is false.
-
- \sa viewMode
-*/
-void QListView::setWrapping(bool enable)
-{
- Q_D(QListView);
- d->modeProperties |= uint(QListViewPrivate::Wrap);
- d->setWrapping(enable);
- d->doDelayedItemsLayout();
-}
-
-bool QListView::isWrapping() const
-{
- Q_D(const QListView);
- return d->isWrapping();
-}
-
-/*!
- \property QListView::resizeMode
- \brief whether the items are laid out again when the view is resized.
-
- If this property is \l Adjust, the items will be laid out again
- when the view is resized. If the value is \l Fixed, the items will
- not be laid out when the view is resized.
-
- By default, this property is set to \l Fixed.
-
- \sa movement, gridSize, viewMode
-*/
-void QListView::setResizeMode(ResizeMode mode)
-{
- Q_D(QListView);
- d->modeProperties |= uint(QListViewPrivate::ResizeMode);
- d->resizeMode = mode;
-}
-
-QListView::ResizeMode QListView::resizeMode() const
-{
- Q_D(const QListView);
- return d->resizeMode;
-}
-
-/*!
- \property QListView::layoutMode
- \brief determines whether the layout of items should happen immediately or be delayed.
-
- This property holds the layout mode for the items. When the mode
- is \l SinglePass (the default), the items are laid out all in one go.
- When the mode is \l Batched, the items are laid out in batches of \l batchSize
- items, while processing events. This makes it possible to
- instantly view and interact with the visible items while the rest
- are being laid out.
-
- \sa viewMode
-*/
-void QListView::setLayoutMode(LayoutMode mode)
-{
- Q_D(QListView);
- d->layoutMode = mode;
-}
-
-QListView::LayoutMode QListView::layoutMode() const
-{
- Q_D(const QListView);
- return d->layoutMode;
-}
-
-/*!
- \property QListView::spacing
- \brief the space around the items in the layout
-
- This property is the size of the empty space that is padded around
- an item in the layout.
-
- Setting this property when the view is visible will cause the
- items to be laid out again.
-
- By default, this property contains a value of 0.
-
- \sa viewMode
-*/
-// ### Qt5: Use same semantic as layouts (spacing is the size of space
-// *between* items)
-void QListView::setSpacing(int space)
-{
- Q_D(QListView);
- d->modeProperties |= uint(QListViewPrivate::Spacing);
- d->setSpacing(space);
- d->doDelayedItemsLayout();
-}
-
-int QListView::spacing() const
-{
- Q_D(const QListView);
- return d->spacing();
-}
-
-/*!
- \property QListView::batchSize
- \brief the number of items laid out in each batch if \l layoutMode is
- set to \l Batched
-
- The default value is 100.
-
- \since 4.2
-*/
-
-void QListView::setBatchSize(int batchSize)
-{
- Q_D(QListView);
- if (batchSize <= 0) {
- qWarning("Invalid batchSize (%d)", batchSize);
- return;
- }
- d->batchSize = batchSize;
-}
-
-int QListView::batchSize() const
-{
- Q_D(const QListView);
- return d->batchSize;
-}
-
-/*!
- \property QListView::gridSize
- \brief the size of the layout grid
-
- This property is the size of the grid in which the items are laid
- out. The default is an empty size which means that there is no
- grid and the layout is not done in a grid. Setting this property
- to a non-empty size switches on the grid layout. (When a grid
- layout is in force the \l spacing property is ignored.)
-
- Setting this property when the view is visible will cause the
- items to be laid out again.
-
- \sa viewMode
-*/
-void QListView::setGridSize(const QSize &size)
-{
- Q_D(QListView);
- d->modeProperties |= uint(QListViewPrivate::GridSize);
- d->setGridSize(size);
- d->doDelayedItemsLayout();
-}
-
-QSize QListView::gridSize() const
-{
- Q_D(const QListView);
- return d->gridSize();
-}
-
-/*!
- \property QListView::viewMode
- \brief the view mode of the QListView.
-
- This property will change the other unset properties to conform
- with the set view mode. QListView-specific properties that have already been set
- will not be changed, unless clearPropertyFlags() has been called.
-
- Setting the view mode will enable or disable drag and drop based on the
- selected movement. For ListMode, the default movement is \l Static
- (drag and drop disabled); for IconMode, the default movement is
- \l Free (drag and drop enabled).
-
- \sa isWrapping, spacing, gridSize, flow, movement, resizeMode
-*/
-void QListView::setViewMode(ViewMode mode)
-{
- Q_D(QListView);
- if (d->commonListView && d->viewMode == mode)
- return;
- d->viewMode = mode;
-
- delete d->commonListView;
- if (mode == ListMode) {
- d->commonListView = new QListModeViewBase(this, d);
- if (!(d->modeProperties & QListViewPrivate::Wrap))
- d->setWrapping(false);
- if (!(d->modeProperties & QListViewPrivate::Spacing))
- d->setSpacing(0);
- if (!(d->modeProperties & QListViewPrivate::GridSize))
- d->setGridSize(QSize());
- if (!(d->modeProperties & QListViewPrivate::Flow))
- d->flow = TopToBottom;
- if (!(d->modeProperties & QListViewPrivate::Movement))
- d->movement = Static;
- if (!(d->modeProperties & QListViewPrivate::ResizeMode))
- d->resizeMode = Fixed;
- if (!(d->modeProperties & QListViewPrivate::SelectionRectVisible))
- d->showElasticBand = false;
- } else {
- d->commonListView = new QIconModeViewBase(this, d);
- if (!(d->modeProperties & QListViewPrivate::Wrap))
- d->setWrapping(true);
- if (!(d->modeProperties & QListViewPrivate::Spacing))
- d->setSpacing(0);
- if (!(d->modeProperties & QListViewPrivate::GridSize))
- d->setGridSize(QSize());
- if (!(d->modeProperties & QListViewPrivate::Flow))
- d->flow = LeftToRight;
- if (!(d->modeProperties & QListViewPrivate::Movement))
- d->movement = Free;
- if (!(d->modeProperties & QListViewPrivate::ResizeMode))
- d->resizeMode = Fixed;
- if (!(d->modeProperties & QListViewPrivate::SelectionRectVisible))
- d->showElasticBand = true;
- }
-
-#ifndef QT_NO_DRAGANDDROP
- bool movable = (d->movement != Static);
- setDragEnabled(movable);
- setAcceptDrops(movable);
-#endif
- d->clear();
- d->doDelayedItemsLayout();
-}
-
-QListView::ViewMode QListView::viewMode() const
-{
- Q_D(const QListView);
- return d->viewMode;
-}
-
-/*!
- Clears the QListView-specific property flags. See \l{viewMode}.
-
- Properties inherited from QAbstractItemView are not covered by the
- property flags. Specifically, \l{QAbstractItemView::dragEnabled}
- {dragEnabled} and \l{QAbstractItemView::acceptDrops}
- {acceptsDrops} are computed by QListView when calling
- setMovement() or setViewMode().
-*/
-void QListView::clearPropertyFlags()
-{
- Q_D(QListView);
- d->modeProperties = 0;
-}
-
-/*!
- Returns true if the \a row is hidden; otherwise returns false.
-*/
-bool QListView::isRowHidden(int row) const
-{
- Q_D(const QListView);
- return d->isHidden(row);
-}
-
-/*!
- If \a hide is true, the given \a row will be hidden; otherwise
- the \a row will be shown.
-*/
-void QListView::setRowHidden(int row, bool hide)
-{
- Q_D(QListView);
- const bool hidden = d->isHidden(row);
- if (hide && !hidden)
- d->commonListView->appendHiddenRow(row);
- else if (!hide && hidden)
- d->commonListView->removeHiddenRow(row);
- d->doDelayedItemsLayout();
- d->viewport->update();
-}
-
-/*!
- \reimp
-*/
-QRect QListView::visualRect(const QModelIndex &index) const
-{
- Q_D(const QListView);
- return d->mapToViewport(rectForIndex(index));
-}
-
-/*!
- \reimp
-*/
-void QListView::scrollTo(const QModelIndex &index, ScrollHint hint)
-{
- Q_D(QListView);
-
- if (index.parent() != d->root || index.column() != d->column)
- return;
-
- const QRect rect = visualRect(index);
- if (hint == EnsureVisible && d->viewport->rect().contains(rect)) {
- d->viewport->update(rect);
- return;
- }
-
- if (d->flow == QListView::TopToBottom || d->isWrapping()) // vertical
- verticalScrollBar()->setValue(d->verticalScrollToValue(index, rect, hint));
-
- if (d->flow == QListView::LeftToRight || d->isWrapping()) // horizontal
- horizontalScrollBar()->setValue(d->horizontalScrollToValue(index, rect, hint));
-}
-
-int QListViewPrivate::horizontalScrollToValue(const QModelIndex &index, const QRect &rect,
- QListView::ScrollHint hint) const
-{
- Q_Q(const QListView);
- const QRect area = viewport->rect();
- const bool leftOf = q->isRightToLeft()
- ? (rect.left() < area.left()) && (rect.right() < area.right())
- : rect.left() < area.left();
- const bool rightOf = q->isRightToLeft()
- ? rect.right() > area.right()
- : (rect.right() > area.right()) && (rect.left() > area.left());
- return commonListView->horizontalScrollToValue(q->visualIndex(index), hint, leftOf, rightOf, area, rect);
-}
-
-int QListViewPrivate::verticalScrollToValue(const QModelIndex &index, const QRect &rect,
- QListView::ScrollHint hint) const
-{
- Q_Q(const QListView);
- const QRect area = viewport->rect();
- const bool above = (hint == QListView::EnsureVisible && rect.top() < area.top());
- const bool below = (hint == QListView::EnsureVisible && rect.bottom() > area.bottom());
- return commonListView->verticalScrollToValue(q->visualIndex(index), hint, above, below, area, rect);
-}
-
-void QListViewPrivate::selectAll(QItemSelectionModel::SelectionFlags command)
-{
- if (!selectionModel)
- return;
-
- QItemSelection selection;
- QModelIndex topLeft;
- int row = 0;
- const int colCount = model->columnCount(root);
- for(; row < model->rowCount(root); ++row) {
- if (isHidden(row)) {
- //it might be the end of a selection range
- if (topLeft.isValid()) {
- QModelIndex bottomRight = model->index(row - 1, colCount - 1, root);
- selection.append(QItemSelectionRange(topLeft, bottomRight));
- topLeft = QModelIndex();
- }
- continue;
- }
-
- if (!topLeft.isValid()) //start of a new selection range
- topLeft = model->index(row, 0, root);
- }
-
- if (topLeft.isValid()) {
- //last selected range
- QModelIndex bottomRight = model->index(row - 1, colCount - 1, root);
- selection.append(QItemSelectionRange(topLeft, bottomRight));
- }
-
- if (!selection.isEmpty())
- selectionModel->select(selection, command);
-}
-
-/*!
- \reimp
-
- We have a QListView way of knowing what elements are on the viewport
- through the intersectingSet function
-*/
-QItemViewPaintPairs QListViewPrivate::draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const
-{
- Q_ASSERT(r);
- Q_Q(const QListView);
- QRect &rect = *r;
- const QRect viewportRect = viewport->rect();
- QItemViewPaintPairs ret;
- const QSet<QModelIndex> visibleIndexes = intersectingSet(viewportRect).toList().toSet();
- for (int i = 0; i < indexes.count(); ++i) {
- const QModelIndex &index = indexes.at(i);
- if (visibleIndexes.contains(index)) {
- const QRect current = q->visualRect(index);
- ret += qMakePair(current, index);
- rect |= current;
- }
- }
- rect &= viewportRect;
- return ret;
-}
-
-/*!
- \internal
-*/
-void QListView::reset()
-{
- Q_D(QListView);
- d->clear();
- d->hiddenRows.clear();
- QAbstractItemView::reset();
-}
-
-/*!
- \internal
-*/
-void QListView::setRootIndex(const QModelIndex &index)
-{
- Q_D(QListView);
- d->column = qBound(0, d->column, d->model->columnCount(index) - 1);
- QAbstractItemView::setRootIndex(index);
- // sometimes we get an update before reset() is called
- d->clear();
- d->hiddenRows.clear();
-}
-
-/*!
- \internal
-
- Scroll the view contents by \a dx and \a dy.
-*/
-
-void QListView::scrollContentsBy(int dx, int dy)
-{
- Q_D(QListView);
- d->delayedAutoScroll.stop(); // auto scroll was canceled by the user scrolling
- d->commonListView->scrollContentsBy(dx, dy, d->state == QListView::DragSelectingState);
-}
-
-/*!
- \internal
-
- Resize the internal contents to \a width and \a height and set the
- scroll bar ranges accordingly.
-*/
-void QListView::resizeContents(int width, int height)
-{
- Q_D(QListView);
- d->setContentsSize(width, height);
-}
-
-/*!
- \internal
-*/
-QSize QListView::contentsSize() const
-{
- Q_D(const QListView);
- return d->contentsSize();
-}
-
-/*!
- \reimp
-*/
-void QListView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
-{
- d_func()->commonListView->dataChanged(topLeft, bottomRight);
- QAbstractItemView::dataChanged(topLeft, bottomRight);
-}
-
-/*!
- \reimp
-*/
-void QListView::rowsInserted(const QModelIndex &parent, int start, int end)
-{
- Q_D(QListView);
- // ### be smarter about inserted items
- d->clear();
- d->doDelayedItemsLayout();
- QAbstractItemView::rowsInserted(parent, start, end);
-}
-
-/*!
- \reimp
-*/
-void QListView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
-{
- Q_D(QListView);
- // if the parent is above d->root in the tree, nothing will happen
- QAbstractItemView::rowsAboutToBeRemoved(parent, start, end);
- if (parent == d->root) {
- QSet<QPersistentModelIndex>::iterator it = d->hiddenRows.begin();
- while (it != d->hiddenRows.end()) {
- int hiddenRow = it->row();
- if (hiddenRow >= start && hiddenRow <= end) {
- it = d->hiddenRows.erase(it);
- } else {
- ++it;
- }
- }
- }
- d->clear();
- d->doDelayedItemsLayout();
-}
-
-/*!
- \reimp
-*/
-void QListView::mouseMoveEvent(QMouseEvent *e)
-{
- if (!isVisible())
- return;
- Q_D(QListView);
- QAbstractItemView::mouseMoveEvent(e);
- if (state() == DragSelectingState
- && d->showElasticBand
- && d->selectionMode != SingleSelection
- && d->selectionMode != NoSelection) {
- QRect rect(d->pressedPosition, e->pos() + QPoint(horizontalOffset(), verticalOffset()));
- rect = rect.normalized();
- d->viewport->update(d->mapToViewport(rect.united(d->elasticBand)));
- d->elasticBand = rect;
- }
-}
-
-/*!
- \reimp
-*/
-void QListView::mouseReleaseEvent(QMouseEvent *e)
-{
- Q_D(QListView);
- QAbstractItemView::mouseReleaseEvent(e);
- // #### move this implementation into a dynamic class
- if (d->showElasticBand && d->elasticBand.isValid()) {
- d->viewport->update(d->mapToViewport(d->elasticBand));
- d->elasticBand = QRect();
- }
-}
-
-/*!
- \reimp
-*/
-void QListView::timerEvent(QTimerEvent *e)
-{
- Q_D(QListView);
- if (e->timerId() == d->batchLayoutTimer.timerId()) {
- if (d->doItemsLayout(d->batchSize)) { // layout is done
- d->batchLayoutTimer.stop();
- updateGeometries();
- d->viewport->update();
- }
- }
- QAbstractItemView::timerEvent(e);
-}
-
-/*!
- \reimp
-*/
-void QListView::resizeEvent(QResizeEvent *e)
-{
- Q_D(QListView);
- if (d->delayedPendingLayout)
- return;
-
- QSize delta = e->size() - e->oldSize();
-
- if (delta.isNull())
- return;
-
- bool listWrap = (d->viewMode == ListMode) && d->wrapItemText;
- bool flowDimensionChanged = (d->flow == LeftToRight && delta.width() != 0)
- || (d->flow == TopToBottom && delta.height() != 0);
-
- // We post a delayed relayout in the following cases :
- // - we're wrapping
- // - the state is NoState, we're adjusting and the size has changed in the flowing direction
- if (listWrap
- || (state() == NoState && d->resizeMode == Adjust && flowDimensionChanged)) {
- d->doDelayedItemsLayout(100); // wait 1/10 sec before starting the layout
- } else {
- QAbstractItemView::resizeEvent(e);
- }
-}
-
-#ifndef QT_NO_DRAGANDDROP
-
-/*!
- \reimp
-*/
-void QListView::dragMoveEvent(QDragMoveEvent *e)
-{
- Q_D(QListView);
- if (!d->commonListView->filterDragMoveEvent(e)) {
- if (viewMode() == QListView::ListMode && flow() == QListView::LeftToRight)
- static_cast<QListModeViewBase *>(d->commonListView)->dragMoveEvent(e);
- else
- QAbstractItemView::dragMoveEvent(e);
- }
-}
-
-
-/*!
- \reimp
-*/
-void QListView::dragLeaveEvent(QDragLeaveEvent *e)
-{
- if (!d_func()->commonListView->filterDragLeaveEvent(e))
- QAbstractItemView::dragLeaveEvent(e);
-}
-
-/*!
- \reimp
-*/
-void QListView::dropEvent(QDropEvent *e)
-{
- if (!d_func()->commonListView->filterDropEvent(e))
- QAbstractItemView::dropEvent(e);
-}
-
-/*!
- \reimp
-*/
-void QListView::startDrag(Qt::DropActions supportedActions)
-{
- if (!d_func()->commonListView->filterStartDrag(supportedActions))
- QAbstractItemView::startDrag(supportedActions);
-}
-
-/*!
- \internal
-
- Called whenever items from the view is dropped on the viewport.
- The \a event provides additional information.
-*/
-void QListView::internalDrop(QDropEvent *event)
-{
- // ### Qt5: remove that function
- Q_UNUSED(event);
-}
-
-/*!
- \internal
-
- Called whenever the user starts dragging items and the items are movable,
- enabling internal dragging and dropping of items.
-*/
-void QListView::internalDrag(Qt::DropActions supportedActions)
-{
- // ### Qt5: remove that function
- Q_UNUSED(supportedActions);
-}
-
-#endif // QT_NO_DRAGANDDROP
-
-/*!
- \reimp
-*/
-QStyleOptionViewItem QListView::viewOptions() const
-{
- Q_D(const QListView);
- QStyleOptionViewItem option = QAbstractItemView::viewOptions();
- if (!d->iconSize.isValid()) { // otherwise it was already set in abstractitemview
- int pm = (d->viewMode == ListMode
- ? style()->pixelMetric(QStyle::PM_ListViewIconSize, 0, this)
- : style()->pixelMetric(QStyle::PM_IconViewIconSize, 0, this));
- option.decorationSize = QSize(pm, pm);
- }
- if (d->viewMode == IconMode) {
- option.showDecorationSelected = false;
- option.decorationPosition = QStyleOptionViewItem::Top;
- option.displayAlignment = Qt::AlignCenter;
- } else {
- option.decorationPosition = QStyleOptionViewItem::Left;
- }
- return option;
-}
-
-
-/*!
- \reimp
-*/
-void QListView::paintEvent(QPaintEvent *e)
-{
- Q_D(QListView);
- if (!d->itemDelegate)
- return;
- QStyleOptionViewItemV4 option = d->viewOptionsV4();
- QPainter painter(d->viewport);
-
- const QVector<QModelIndex> toBeRendered = d->intersectingSet(e->rect().translated(horizontalOffset(), verticalOffset()), false);
-
- const QModelIndex current = currentIndex();
- const QModelIndex hover = d->hover;
- const QAbstractItemModel *itemModel = d->model;
- const QItemSelectionModel *selections = d->selectionModel;
- const bool focus = (hasFocus() || d->viewport->hasFocus()) && current.isValid();
- const bool alternate = d->alternatingColors;
- const QStyle::State state = option.state;
- const QAbstractItemView::State viewState = this->state();
- const bool enabled = (state & QStyle::State_Enabled) != 0;
-
- bool alternateBase = false;
- int previousRow = -2; // trigger the alternateBase adjustment on first pass
-
- int maxSize = (flow() == TopToBottom)
- ? qMax(viewport()->size().width(), d->contentsSize().width()) - 2 * d->spacing()
- : qMax(viewport()->size().height(), d->contentsSize().height()) - 2 * d->spacing();
-
- QVector<QModelIndex>::const_iterator end = toBeRendered.constEnd();
- for (QVector<QModelIndex>::const_iterator it = toBeRendered.constBegin(); it != end; ++it) {
- Q_ASSERT((*it).isValid());
- option.rect = visualRect(*it);
-
- if (flow() == TopToBottom)
- option.rect.setWidth(qMin(maxSize, option.rect.width()));
- else
- option.rect.setHeight(qMin(maxSize, option.rect.height()));
-
- option.state = state;
- if (selections && selections->isSelected(*it))
- option.state |= QStyle::State_Selected;
- if (enabled) {
- QPalette::ColorGroup cg;
- if ((itemModel->flags(*it) & Qt::ItemIsEnabled) == 0) {
- option.state &= ~QStyle::State_Enabled;
- cg = QPalette::Disabled;
- } else {
- cg = QPalette::Normal;
- }
- option.palette.setCurrentColorGroup(cg);
- }
- if (focus && current == *it) {
- option.state |= QStyle::State_HasFocus;
- if (viewState == EditingState)
- option.state |= QStyle::State_Editing;
- }
- if (*it == hover)
- option.state |= QStyle::State_MouseOver;
- else
- option.state &= ~QStyle::State_MouseOver;
-
- if (alternate) {
- int row = (*it).row();
- if (row != previousRow + 1) {
- // adjust alternateBase according to rows in the "gap"
- if (!d->hiddenRows.isEmpty()) {
- for (int r = qMax(previousRow + 1, 0); r < row; ++r) {
- if (!d->isHidden(r))
- alternateBase = !alternateBase;
- }
- } else {
- alternateBase = (row & 1) != 0;
- }
- }
- if (alternateBase) {
- option.features |= QStyleOptionViewItemV2::Alternate;
- } else {
- option.features &= ~QStyleOptionViewItemV2::Alternate;
- }
-
- // draw background of the item (only alternate row). rest of the background
- // is provided by the delegate
- QStyle::State oldState = option.state;
- option.state &= ~QStyle::State_Selected;
- style()->drawPrimitive(QStyle::PE_PanelItemViewRow, &option, &painter, this);
- option.state = oldState;
-
- alternateBase = !alternateBase;
- previousRow = row;
- }
-
- d->delegateForIndex(*it)->paint(&painter, option, *it);
- }
-
-#ifndef QT_NO_DRAGANDDROP
- d->commonListView->paintDragDrop(&painter);
-#endif
-
-#ifndef QT_NO_RUBBERBAND
- // #### move this implementation into a dynamic class
- if (d->showElasticBand && d->elasticBand.isValid()) {
- QStyleOptionRubberBand opt;
- opt.initFrom(this);
- opt.shape = QRubberBand::Rectangle;
- opt.opaque = false;
- opt.rect = d->mapToViewport(d->elasticBand, false).intersected(
- d->viewport->rect().adjusted(-16, -16, 16, 16));
- painter.save();
- style()->drawControl(QStyle::CE_RubberBand, &opt, &painter);
- painter.restore();
- }
-#endif
-}
-
-/*!
- \reimp
-*/
-QModelIndex QListView::indexAt(const QPoint &p) const
-{
- Q_D(const QListView);
- QRect rect(p.x() + horizontalOffset(), p.y() + verticalOffset(), 1, 1);
- const QVector<QModelIndex> intersectVector = d->intersectingSet(rect);
- QModelIndex index = intersectVector.count() > 0
- ? intersectVector.last() : QModelIndex();
- if (index.isValid() && visualRect(index).contains(p))
- return index;
- return QModelIndex();
-}
-
-/*!
- \reimp
-*/
-int QListView::horizontalOffset() const
-{
- return d_func()->commonListView->horizontalOffset();
-}
-
-/*!
- \reimp
-*/
-int QListView::verticalOffset() const
-{
- return d_func()->commonListView->verticalOffset();
-}
-
-/*!
- \reimp
-*/
-QModelIndex QListView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers)
-{
- Q_D(QListView);
- Q_UNUSED(modifiers);
-
- QModelIndex current = currentIndex();
- if (!current.isValid()) {
- int rowCount = d->model->rowCount(d->root);
- if (!rowCount)
- return QModelIndex();
- int row = 0;
- while (row < rowCount && d->isHiddenOrDisabled(row))
- ++row;
- if (row >= rowCount)
- return QModelIndex();
- return d->model->index(row, d->column, d->root);
- }
-
- const QRect initialRect = rectForIndex(current);
- QRect rect = initialRect;
- if (rect.isEmpty()) {
- return d->model->index(0, d->column, d->root);
- }
- if (d->gridSize().isValid()) rect.setSize(d->gridSize());
-
- QSize contents = d->contentsSize();
- QVector<QModelIndex> intersectVector;
-
- switch (cursorAction) {
- case MoveLeft:
- while (intersectVector.isEmpty()) {
- rect.translate(-rect.width(), 0);
- if (rect.right() <= 0)
- return current;
- if (rect.left() < 0)
- rect.setLeft(0);
- intersectVector = d->intersectingSet(rect);
- d->removeCurrentAndDisabled(&intersectVector, current);
- }
- return d->closestIndex(initialRect, intersectVector);
- case MoveRight:
- while (intersectVector.isEmpty()) {
- rect.translate(rect.width(), 0);
- if (rect.left() >= contents.width())
- return current;
- if (rect.right() > contents.width())
- rect.setRight(contents.width());
- intersectVector = d->intersectingSet(rect);
- d->removeCurrentAndDisabled(&intersectVector, current);
- }
- return d->closestIndex(initialRect, intersectVector);
- case MovePageUp:
- // move current by (visibileRowCount - 1) items.
- // rect.translate(0, -rect.height()); will happen in the switch fallthrough for MoveUp.
- rect.moveTop(rect.top() - d->viewport->height() + 2 * rect.height());
- if (rect.top() < rect.height())
- rect.moveTop(rect.height());
- case MovePrevious:
- case MoveUp:
- while (intersectVector.isEmpty()) {
- rect.translate(0, -rect.height());
- if (rect.bottom() <= 0) {
-#ifdef QT_KEYPAD_NAVIGATION
- if (QApplication::keypadNavigationEnabled()) {
- int row = d->batchStartRow() - 1;
- while (row >= 0 && d->isHiddenOrDisabled(row))
- --row;
- if (row >= 0)
- return d->model->index(row, d->column, d->root);
- }
-#endif
- return current;
- }
- if (rect.top() < 0)
- rect.setTop(0);
- intersectVector = d->intersectingSet(rect);
- d->removeCurrentAndDisabled(&intersectVector, current);
- }
- return d->closestIndex(initialRect, intersectVector);
- case MovePageDown:
- // move current by (visibileRowCount - 1) items.
- // rect.translate(0, rect.height()); will happen in the switch fallthrough for MoveDown.
- rect.moveTop(rect.top() + d->viewport->height() - 2 * rect.height());
- if (rect.bottom() > contents.height() - rect.height())
- rect.moveBottom(contents.height() - rect.height());
- case MoveNext:
- case MoveDown:
- while (intersectVector.isEmpty()) {
- rect.translate(0, rect.height());
- if (rect.top() >= contents.height()) {
-#ifdef QT_KEYPAD_NAVIGATION
- if (QApplication::keypadNavigationEnabled()) {
- int rowCount = d->model->rowCount(d->root);
- int row = 0;
- while (row < rowCount && d->isHiddenOrDisabled(row))
- ++row;
- if (row < rowCount)
- return d->model->index(row, d->column, d->root);
- }
-#endif
- return current;
- }
- if (rect.bottom() > contents.height())
- rect.setBottom(contents.height());
- intersectVector = d->intersectingSet(rect);
- d->removeCurrentAndDisabled(&intersectVector, current);
- }
- return d->closestIndex(initialRect, intersectVector);
- case MoveHome:
- return d->model->index(0, d->column, d->root);
- case MoveEnd:
- return d->model->index(d->batchStartRow() - 1, d->column, d->root);}
-
- return current;
-}
-
-/*!
- Returns the rectangle of the item at position \a index in the
- model. The rectangle is in contents coordinates.
-
- \sa visualRect()
-*/
-QRect QListView::rectForIndex(const QModelIndex &index) const
-{
- return d_func()->rectForIndex(index);
-}
-
-/*!
- \since 4.1
-
- Sets the contents position of the item at \a index in the model to the given
- \a position.
- If the list view's movement mode is Static or its view mode is ListView,
- this function will have no effect.
-*/
-void QListView::setPositionForIndex(const QPoint &position, const QModelIndex &index)
-{
- Q_D(QListView);
- if (d->movement == Static
- || !d->isIndexValid(index)
- || index.parent() != d->root
- || index.column() != d->column)
- return;
-
- d->executePostedLayout();
- d->commonListView->setPositionForIndex(position, index);
-}
-
-/*!
- \reimp
-*/
-void QListView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command)
-{
- Q_D(QListView);
- if (!d->selectionModel)
- return;
-
- // if we are wrapping, we can only selecte inside the contents rectangle
- int w = qMax(d->contentsSize().width(), d->viewport->width());
- int h = qMax(d->contentsSize().height(), d->viewport->height());
- if (d->wrap && !QRect(0, 0, w, h).intersects(rect))
- return;
-
- QItemSelection selection;
-
- if (rect.width() == 1 && rect.height() == 1) {
- const QVector<QModelIndex> intersectVector = d->intersectingSet(rect.translated(horizontalOffset(), verticalOffset()));
- QModelIndex tl;
- if (!intersectVector.isEmpty())
- tl = intersectVector.last(); // special case for mouse press; only select the top item
- if (tl.isValid() && d->isIndexEnabled(tl))
- selection.select(tl, tl);
- } else {
- if (state() == DragSelectingState) { // visual selection mode (rubberband selection)
- selection = d->selection(rect.translated(horizontalOffset(), verticalOffset()));
- } else { // logical selection mode (key and mouse click selection)
- QModelIndex tl, br;
- // get the first item
- const QRect topLeft(rect.left() + horizontalOffset(), rect.top() + verticalOffset(), 1, 1);
- QVector<QModelIndex> intersectVector = d->intersectingSet(topLeft);
- if (!intersectVector.isEmpty())
- tl = intersectVector.last();
- // get the last item
- const QRect bottomRight(rect.right() + horizontalOffset(), rect.bottom() + verticalOffset(), 1, 1);
- intersectVector = d->intersectingSet(bottomRight);
- if (!intersectVector.isEmpty())
- br = intersectVector.last();
-
- // get the ranges
- if (tl.isValid() && br.isValid()
- && d->isIndexEnabled(tl)
- && d->isIndexEnabled(br)) {
- QRect first = rectForIndex(tl);
- QRect last = rectForIndex(br);
- QRect middle;
- if (d->flow == LeftToRight) {
- QRect &top = first;
- QRect &bottom = last;
- // if bottom is above top, swap them
- if (top.center().y() > bottom.center().y()) {
- QRect tmp = top;
- top = bottom;
- bottom = tmp;
- }
- // if the rect are on differnet lines, expand
- if (top.top() != bottom.top()) {
- // top rectangle
- if (isRightToLeft())
- top.setLeft(0);
- else
- top.setRight(contentsSize().width());
- // bottom rectangle
- if (isRightToLeft())
- bottom.setRight(contentsSize().width());
- else
- bottom.setLeft(0);
- } else if (top.left() > bottom.right()) {
- if (isRightToLeft())
- bottom.setLeft(top.right());
- else
- bottom.setRight(top.left());
- } else {
- if (isRightToLeft())
- top.setLeft(bottom.right());
- else
- top.setRight(bottom.left());
- }
- // middle rectangle
- if (top.bottom() < bottom.top()) {
- if (gridSize().isValid() && !gridSize().isNull())
- middle.setTop(top.top() + gridSize().height());
- else
- middle.setTop(top.bottom() + 1);
- middle.setLeft(qMin(top.left(), bottom.left()));
- middle.setBottom(bottom.top() - 1);
- middle.setRight(qMax(top.right(), bottom.right()));
- }
- } else { // TopToBottom
- QRect &left = first;
- QRect &right = last;
- if (left.center().x() > right.center().x())
- qSwap(left, right);
-
- int ch = contentsSize().height();
- if (left.left() != right.left()) {
- // left rectangle
- if (isRightToLeft())
- left.setTop(0);
- else
- left.setBottom(ch);
-
- // top rectangle
- if (isRightToLeft())
- right.setBottom(ch);
- else
- right.setTop(0);
- // only set middle if the
- middle.setTop(0);
- middle.setBottom(ch);
- if (gridSize().isValid() && !gridSize().isNull())
- middle.setLeft(left.left() + gridSize().width());
- else
- middle.setLeft(left.right() + 1);
- middle.setRight(right.left() - 1);
- } else if (left.bottom() < right.top()) {
- left.setBottom(right.top() - 1);
- } else {
- right.setBottom(left.top() - 1);
- }
- }
-
- // do the selections
- QItemSelection topSelection = d->selection(first);
- QItemSelection middleSelection = d->selection(middle);
- QItemSelection bottomSelection = d->selection(last);
- // merge
- selection.merge(topSelection, QItemSelectionModel::Select);
- selection.merge(middleSelection, QItemSelectionModel::Select);
- selection.merge(bottomSelection, QItemSelectionModel::Select);
- }
- }
- }
-
- d->selectionModel->select(selection, command);
-}
-
-/*!
- \reimp
-
- Since 4.7, the returned region only contains rectangles intersecting
- (or included in) the viewport.
-*/
-QRegion QListView::visualRegionForSelection(const QItemSelection &selection) const
-{
- Q_D(const QListView);
- // ### NOTE: this is a potential bottleneck in non-static mode
- int c = d->column;
- QRegion selectionRegion;
- const QRect &viewportRect = d->viewport->rect();
- for (int i = 0; i < selection.count(); ++i) {
- if (!selection.at(i).isValid())
- continue;
- QModelIndex parent = selection.at(i).topLeft().parent();
- //we only display the children of the root in a listview
- //we're not interested in the other model indexes
- if (parent != d->root)
- continue;
- int t = selection.at(i).topLeft().row();
- int b = selection.at(i).bottomRight().row();
- if (d->viewMode == IconMode || d->isWrapping()) { // in non-static mode, we have to go through all selected items
- for (int r = t; r <= b; ++r) {
- const QRect &rect = visualRect(d->model->index(r, c, parent));
- if (viewportRect.intersects(rect))
- selectionRegion += rect;
- }
- } else { // in static mode, we can optimize a bit
- while (t <= b && d->isHidden(t)) ++t;
- while (b >= t && d->isHidden(b)) --b;
- const QModelIndex top = d->model->index(t, c, parent);
- const QModelIndex bottom = d->model->index(b, c, parent);
- QRect rect(visualRect(top).topLeft(),
- visualRect(bottom).bottomRight());
- if (viewportRect.intersects(rect))
- selectionRegion += rect;
- }
- }
-
- return selectionRegion;
-}
-
-/*!
- \reimp
-*/
-QModelIndexList QListView::selectedIndexes() const
-{
- Q_D(const QListView);
- if (!d->selectionModel)
- return QModelIndexList();
-
- QModelIndexList viewSelected = d->selectionModel->selectedIndexes();
- for (int i = 0; i < viewSelected.count(); ++i) {
- const QModelIndex &index = viewSelected.at(i);
- if (!isIndexHidden(index) && index.parent() == d->root && index.column() == d->column)
- ++i;
- else
- viewSelected.removeAt(i);
- }
- return viewSelected;
-}
-
-/*!
- \internal
-
- Layout the items according to the flow and wrapping properties.
-*/
-void QListView::doItemsLayout()
-{
- Q_D(QListView);
- // showing the scroll bars will trigger a resize event,
- // so we set the state to expanding to avoid
- // triggering another layout
- QAbstractItemView::State oldState = state();
- setState(ExpandingState);
- if (d->model->columnCount(d->root) > 0) { // no columns means no contents
- d->resetBatchStartRow();
- if (layoutMode() == SinglePass)
- d->doItemsLayout(d->model->rowCount(d->root)); // layout everything
- else if (!d->batchLayoutTimer.isActive()) {
- if (!d->doItemsLayout(d->batchSize)) // layout is done
- d->batchLayoutTimer.start(0, this); // do a new batch as fast as possible
- }
- }
- QAbstractItemView::doItemsLayout();
- setState(oldState); // restoring the oldState
-}
-
-/*!
- \reimp
-*/
-void QListView::updateGeometries()
-{
- Q_D(QListView);
- if (d->model->rowCount(d->root) <= 0 || d->model->columnCount(d->root) <= 0) {
- horizontalScrollBar()->setRange(0, 0);
- verticalScrollBar()->setRange(0, 0);
- } else {
- QModelIndex index = d->model->index(0, d->column, d->root);
- QStyleOptionViewItemV4 option = d->viewOptionsV4();
- QSize step = d->itemSize(option, index);
- d->commonListView->updateHorizontalScrollBar(step);
- d->commonListView->updateVerticalScrollBar(step);
- }
-
- QAbstractItemView::updateGeometries();
-
- // if the scroll bars are turned off, we resize the contents to the viewport
- if (d->movement == Static && !d->isWrapping()) {
- const QSize maxSize = maximumViewportSize();
- if (d->flow == TopToBottom) {
- if (horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) {
- d->setContentsSize(maxSize.width(), contentsSize().height());
- horizontalScrollBar()->setRange(0, 0); // we see all the contents anyway
- }
- } else { // LeftToRight
- if (verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) {
- d->setContentsSize(contentsSize().width(), maxSize.height());
- verticalScrollBar()->setRange(0, 0); // we see all the contents anyway
- }
- }
- }
-
-}
-
-/*!
- \reimp
-*/
-bool QListView::isIndexHidden(const QModelIndex &index) const
-{
- Q_D(const QListView);
- return (d->isHidden(index.row())
- && (index.parent() == d->root)
- && index.column() == d->column);
-}
-
-/*!
- \property QListView::modelColumn
- \brief the column in the model that is visible
-
- By default, this property contains 0, indicating that the first
- column in the model will be shown.
-*/
-void QListView::setModelColumn(int column)
-{
- Q_D(QListView);
- if (column < 0 || column >= d->model->columnCount(d->root))
- return;
- d->column = column;
- d->doDelayedItemsLayout();
-}
-
-int QListView::modelColumn() const
-{
- Q_D(const QListView);
- return d->column;
-}
-
-/*!
- \property QListView::uniformItemSizes
- \brief whether all items in the listview have the same size
- \since 4.1
-
- This property should only be set to true if it is guaranteed that all items
- in the view have the same size. This enables the view to do some
- optimizations for performance purposes.
-
- By default, this property is false.
-*/
-void QListView::setUniformItemSizes(bool enable)
-{
- Q_D(QListView);
- d->uniformItemSizes = enable;
-}
-
-bool QListView::uniformItemSizes() const
-{
- Q_D(const QListView);
- return d->uniformItemSizes;
-}
-
-/*!
- \property QListView::wordWrap
- \brief the item text word-wrapping policy
- \since 4.2
-
- If this property is true then the item text is wrapped where
- necessary at word-breaks; otherwise it is not wrapped at all.
- This property is false by default.
-
- Please note that even if wrapping is enabled, the cell will not be
- expanded to make room for the text. It will print ellipsis for
- text that cannot be shown, according to the view's
- \l{QAbstractItemView::}{textElideMode}.
-*/
-void QListView::setWordWrap(bool on)
-{
- Q_D(QListView);
- if (d->wrapItemText == on)
- return;
- d->wrapItemText = on;
- d->doDelayedItemsLayout();
-}
-
-bool QListView::wordWrap() const
-{
- Q_D(const QListView);
- return d->wrapItemText;
-}
-
-/*!
- \property QListView::selectionRectVisible
- \brief if the selection rectangle should be visible
- \since 4.3
-
- If this property is true then the selection rectangle is visible;
- otherwise it will be hidden.
-
- \note The selection rectangle will only be visible if the selection mode
- is in a mode where more than one item can be selected; i.e., it will not
- draw a selection rectangle if the selection mode is
- QAbstractItemView::SingleSelection.
-
- By default, this property is false.
-*/
-void QListView::setSelectionRectVisible(bool show)
-{
- Q_D(QListView);
- d->modeProperties |= uint(QListViewPrivate::SelectionRectVisible);
- d->setSelectionRectVisible(show);
-}
-
-bool QListView::isSelectionRectVisible() const
-{
- Q_D(const QListView);
- return d->isSelectionRectVisible();
-}
-
-/*!
- \reimp
-*/
-bool QListView::event(QEvent *e)
-{
- return QAbstractItemView::event(e);
-}
-
-/*
- * private object implementation
- */
-
-QListViewPrivate::QListViewPrivate()
- : QAbstractItemViewPrivate(),
- commonListView(0),
- wrap(false),
- space(0),
- flow(QListView::TopToBottom),
- movement(QListView::Static),
- resizeMode(QListView::Fixed),
- layoutMode(QListView::SinglePass),
- viewMode(QListView::ListMode),
- modeProperties(0),
- column(0),
- uniformItemSizes(false),
- batchSize(100),
- showElasticBand(false)
-{
-}
-
-QListViewPrivate::~QListViewPrivate()
-{
- delete commonListView;
-}
-
-void QListViewPrivate::clear()
-{
- // initialization of data structs
- cachedItemSize = QSize();
- commonListView->clear();
-}
-
-void QListViewPrivate::prepareItemsLayout()
-{
- Q_Q(QListView);
- clear();
-
- //take the size as if there were scrollbar in order to prevent scrollbar to blink
- layoutBounds = QRect(QPoint(), q->maximumViewportSize());
-
- int frameAroundContents = 0;
- if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents))
- frameAroundContents = q->style()->pixelMetric(QStyle::PM_DefaultFrameWidth) * 2;
-
- // maximumViewportSize() already takes scrollbar into account if policy is
- // Qt::ScrollBarAlwaysOn but scrollbar extent must be deduced if policy
- // is Qt::ScrollBarAsNeeded
- int verticalMargin = vbarpolicy==Qt::ScrollBarAsNeeded
- ? q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, vbar) + frameAroundContents
- : 0;
- int horizontalMargin = hbarpolicy==Qt::ScrollBarAsNeeded
- ? q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, hbar) + frameAroundContents
- : 0;
-
- layoutBounds.adjust(0, 0, -verticalMargin, -horizontalMargin);
-
- int rowCount = model->columnCount(root) <= 0 ? 0 : model->rowCount(root);
- commonListView->setRowCount(rowCount);
-}
-
-/*!
- \internal
-*/
-bool QListViewPrivate::doItemsLayout(int delta)
-{
- int max = model->rowCount(root) - 1;
- int first = batchStartRow();
- int last = qMin(first + delta - 1, max);
-
- if (first == 0) {
- layoutChildren(); // make sure the viewport has the right size
- prepareItemsLayout();
- }
-
- if (max < 0 || last < first) {
- return true; // nothing to do
- }
-
- QListViewLayoutInfo info;
- info.bounds = layoutBounds;
- info.grid = gridSize();
- info.spacing = (info.grid.isValid() ? 0 : spacing());
- info.first = first;
- info.last = last;
- info.wrap = isWrapping();
- info.flow = flow;
- info.max = max;
-
- return commonListView->doBatchedItemLayout(info, max);
-}
-
-QListViewItem QListViewPrivate::indexToListViewItem(const QModelIndex &index) const
-{
- if (!index.isValid() || isHidden(index.row()))
- return QListViewItem();
-
- return commonListView->indexToListViewItem(index);
-}
-
-QRect QListViewPrivate::mapToViewport(const QRect &rect, bool extend) const
-{
- Q_Q(const QListView);
- if (!rect.isValid())
- return rect;
-
- QRect result = extend ? commonListView->mapToViewport(rect) : rect;
- int dx = -q->horizontalOffset();
- int dy = -q->verticalOffset();
- return result.adjusted(dx, dy, dx, dy);
-}
-
-QModelIndex QListViewPrivate::closestIndex(const QRect &target,
- const QVector<QModelIndex> &candidates) const
-{
- int distance = 0;
- int shortest = INT_MAX;
- QModelIndex closest;
- QVector<QModelIndex>::const_iterator it = candidates.begin();
-
- for (; it != candidates.end(); ++it) {
- if (!(*it).isValid())
- continue;
-
- const QRect indexRect = indexToListViewItem(*it).rect();
-
- //if the center x (or y) position of an item is included in the rect of the other item,
- //we define the distance between them as the difference in x (or y) of their respective center.
- // Otherwise, we use the nahattan length between the 2 items
- if ((target.center().x() >= indexRect.x() && target.center().x() < indexRect.right())
- || (indexRect.center().x() >= target.x() && indexRect.center().x() < target.right())) {
- //one item's center is at the vertical of the other
- distance = qAbs(indexRect.center().y() - target.center().y());
- } else if ((target.center().y() >= indexRect.y() && target.center().y() < indexRect.bottom())
- || (indexRect.center().y() >= target.y() && indexRect.center().y() < target.bottom())) {
- //one item's center is at the vertical of the other
- distance = qAbs(indexRect.center().x() - target.center().x());
- } else {
- distance = (indexRect.center() - target.center()).manhattanLength();
- }
- if (distance < shortest) {
- shortest = distance;
- closest = *it;
- }
- }
- return closest;
-}
-
-QSize QListViewPrivate::itemSize(const QStyleOptionViewItem &option, const QModelIndex &index) const
-{
- if (!uniformItemSizes) {
- const QAbstractItemDelegate *delegate = delegateForIndex(index);
- return delegate ? delegate->sizeHint(option, index) : QSize();
- }
- if (!cachedItemSize.isValid()) { // the last item is probaly the largest, so we use its size
- int row = model->rowCount(root) - 1;
- QModelIndex sample = model->index(row, column, root);
- const QAbstractItemDelegate *delegate = delegateForIndex(sample);
- cachedItemSize = delegate ? delegate->sizeHint(option, sample) : QSize();
- }
- return cachedItemSize;
-}
-
-QItemSelection QListViewPrivate::selection(const QRect &rect) const
-{
- QItemSelection selection;
- QModelIndex tl, br;
- const QVector<QModelIndex> intersectVector = intersectingSet(rect);
- QVector<QModelIndex>::const_iterator it = intersectVector.begin();
- for (; it != intersectVector.end(); ++it) {
- if (!tl.isValid() && !br.isValid()) {
- tl = br = *it;
- } else if ((*it).row() == (tl.row() - 1)) {
- tl = *it; // expand current range
- } else if ((*it).row() == (br.row() + 1)) {
- br = (*it); // expand current range
- } else {
- selection.select(tl, br); // select current range
- tl = br = *it; // start new range
- }
- }
-
- if (tl.isValid() && br.isValid())
- selection.select(tl, br);
- else if (tl.isValid())
- selection.select(tl, tl);
- else if (br.isValid())
- selection.select(br, br);
-
- return selection;
-}
-
-#ifndef QT_NO_DRAGANDDROP
-QAbstractItemView::DropIndicatorPosition QListViewPrivate::position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const
-{
- if (viewMode == QListView::ListMode && flow == QListView::LeftToRight)
- return static_cast<QListModeViewBase *>(commonListView)->position(pos, rect, idx);
- else
- return QAbstractItemViewPrivate::position(pos, rect, idx);
-}
-
-bool QListViewPrivate::dropOn(QDropEvent *event, int *dropRow, int *dropCol, QModelIndex *dropIndex)
-{
- if (viewMode == QListView::ListMode && flow == QListView::LeftToRight)
- return static_cast<QListModeViewBase *>(commonListView)->dropOn(event, dropRow, dropCol, dropIndex);
- else
- return QAbstractItemViewPrivate::dropOn(event, dropRow, dropCol, dropIndex);
-}
-#endif
-
-/*
- * Common ListView Implementation
-*/
-
-void QCommonListViewBase::appendHiddenRow(int row)
-{
- dd->hiddenRows.insert(dd->model->index(row, 0, qq->rootIndex()));
-}
-
-void QCommonListViewBase::removeHiddenRow(int row)
-{
- dd->hiddenRows.remove(dd->model->index(row, 0, qq->rootIndex()));
-}
-
-void QCommonListViewBase::updateHorizontalScrollBar(const QSize &step)
-{
- horizontalScrollBar()->setSingleStep(step.width() + spacing());
- horizontalScrollBar()->setPageStep(viewport()->width());
- horizontalScrollBar()->setRange(0, contentsSize.width() - viewport()->width());
-}
-
-void QCommonListViewBase::updateVerticalScrollBar(const QSize &step)
-{
- verticalScrollBar()->setSingleStep(step.height() + spacing());
- verticalScrollBar()->setPageStep(viewport()->height());
- verticalScrollBar()->setRange(0, contentsSize.height() - viewport()->height());
-}
-
-void QCommonListViewBase::scrollContentsBy(int dx, int dy, bool /*scrollElasticBand*/)
-{
- dd->scrollContentsBy(isRightToLeft() ? -dx : dx, dy);
-}
-
-int QCommonListViewBase::verticalScrollToValue(int /*index*/, QListView::ScrollHint hint,
- bool above, bool below, const QRect &area, const QRect &rect) const
-{
- int verticalValue = verticalScrollBar()->value();
- QRect adjusted = rect.adjusted(-spacing(), -spacing(), spacing(), spacing());
- if (hint == QListView::PositionAtTop || above)
- verticalValue += adjusted.top();
- else if (hint == QListView::PositionAtBottom || below)
- verticalValue += qMin(adjusted.top(), adjusted.bottom() - area.height() + 1);
- else if (hint == QListView::PositionAtCenter)
- verticalValue += adjusted.top() - ((area.height() - adjusted.height()) / 2);
- return verticalValue;
-}
-
-int QCommonListViewBase::horizontalOffset() const
-{
- return (isRightToLeft() ? horizontalScrollBar()->maximum() - horizontalScrollBar()->value() : horizontalScrollBar()->value());
-}
-
-int QCommonListViewBase::horizontalScrollToValue(const int /*index*/, QListView::ScrollHint hint,
- bool leftOf, bool rightOf, const QRect &area, const QRect &rect) const
-{
- int horizontalValue = horizontalScrollBar()->value();
- if (isRightToLeft()) {
- if (hint == QListView::PositionAtCenter) {
- horizontalValue += ((area.width() - rect.width()) / 2) - rect.left();
- } else {
- if (leftOf)
- horizontalValue -= rect.left();
- else if (rightOf)
- horizontalValue += qMin(rect.left(), area.width() - rect.right());
- }
- } else {
- if (hint == QListView::PositionAtCenter) {
- horizontalValue += rect.left() - ((area.width()- rect.width()) / 2);
- } else {
- if (leftOf)
- horizontalValue += rect.left();
- else if (rightOf)
- horizontalValue += qMin(rect.left(), rect.right() - area.width());
- }
- }
- return horizontalValue;
-}
-
-/*
- * ListMode ListView Implementation
-*/
-
-#ifndef QT_NO_DRAGANDDROP
-void QListModeViewBase::paintDragDrop(QPainter *painter)
-{
- // FIXME: Until the we can provide a proper drop indicator
- // in IconMode, it makes no sense to show it
- dd->paintDropIndicator(painter);
-}
-
-QAbstractItemView::DropIndicatorPosition QListModeViewBase::position(const QPoint &pos, const QRect &rect, const QModelIndex &index) const
-{
- QAbstractItemView::DropIndicatorPosition r = QAbstractItemView::OnViewport;
- if (!dd->overwrite) {
- const int margin = 2;
- if (pos.x() - rect.left() < margin) {
- r = QAbstractItemView::AboveItem; // Visually, on the left
- } else if (rect.right() - pos.x() < margin) {
- r = QAbstractItemView::BelowItem; // Visually, on the right
- } else if (rect.contains(pos, true)) {
- r = QAbstractItemView::OnItem;
- }
- } else {
- QRect touchingRect = rect;
- touchingRect.adjust(-1, -1, 1, 1);
- if (touchingRect.contains(pos, false)) {
- r = QAbstractItemView::OnItem;
- }
- }
-
- if (r == QAbstractItemView::OnItem && (!(dd->model->flags(index) & Qt::ItemIsDropEnabled)))
- r = pos.x() < rect.center().x() ? QAbstractItemView::AboveItem : QAbstractItemView::BelowItem;
-
- return r;
-}
-
-void QListModeViewBase::dragMoveEvent(QDragMoveEvent *event)
-{
- if (qq->dragDropMode() == QAbstractItemView::InternalMove
- && (event->source() != qq || !(event->possibleActions() & Qt::MoveAction)))
- return;
-
- // ignore by default
- event->ignore();
-
- // can't use indexAt, doesn't account for spacing.
- QPoint p = event->pos();
- QRect rect(p.x() + horizontalOffset(), p.y() + verticalOffset(), 1, 1);
- rect.adjust(-dd->spacing(), -dd->spacing(), dd->spacing(), dd->spacing());
- const QVector<QModelIndex> intersectVector = dd->intersectingSet(rect);
- QModelIndex index = intersectVector.count() > 0
- ? intersectVector.last() : QModelIndex();
- dd->hover = index;
- if (!dd->droppingOnItself(event, index)
- && dd->canDecode(event)) {
-
- if (index.isValid() && dd->showDropIndicator) {
- QRect rect = qq->visualRect(index);
- dd->dropIndicatorPosition = position(event->pos(), rect, index);
- // if spacing, should try to draw between items, not just next to item.
- switch (dd->dropIndicatorPosition) {
- case QAbstractItemView::AboveItem:
- if (dd->isIndexDropEnabled(index.parent())) {
- dd->dropIndicatorRect = QRect(rect.left()-dd->spacing(), rect.top(), 0, rect.height());
- event->accept();
- } else {
- dd->dropIndicatorRect = QRect();
- }
- break;
- case QAbstractItemView::BelowItem:
- if (dd->isIndexDropEnabled(index.parent())) {
- dd->dropIndicatorRect = QRect(rect.right()+dd->spacing(), rect.top(), 0, rect.height());
- event->accept();
- } else {
- dd->dropIndicatorRect = QRect();
- }
- break;
- case QAbstractItemView::OnItem:
- if (dd->isIndexDropEnabled(index)) {
- dd->dropIndicatorRect = rect;
- event->accept();
- } else {
- dd->dropIndicatorRect = QRect();
- }
- break;
- case QAbstractItemView::OnViewport:
- dd->dropIndicatorRect = QRect();
- if (dd->isIndexDropEnabled(qq->rootIndex())) {
- event->accept(); // allow dropping in empty areas
- }
- break;
- }
- } else {
- dd->dropIndicatorRect = QRect();
- dd->dropIndicatorPosition = QAbstractItemView::OnViewport;
- if (dd->isIndexDropEnabled(qq->rootIndex())) {
- event->accept(); // allow dropping in empty areas
- }
- }
- dd->viewport->update();
- } // can decode
-
- if (dd->shouldAutoScroll(event->pos()))
- qq->startAutoScroll();
-}
-
-/*!
- If the event hasn't already been accepted, determines the index to drop on.
-
- if (row == -1 && col == -1)
- // append to this drop index
- else
- // place at row, col in drop index
-
- If it returns true a drop can be done, and dropRow, dropCol and dropIndex reflects the position of the drop.
- \internal
- */
-bool QListModeViewBase::dropOn(QDropEvent *event, int *dropRow, int *dropCol, QModelIndex *dropIndex)
-{
- if (event->isAccepted())
- return false;
-
- QModelIndex index;
- if (dd->viewport->rect().contains(event->pos())) {
- // can't use indexAt, doesn't account for spacing.
- QPoint p = event->pos();
- QRect rect(p.x() + horizontalOffset(), p.y() + verticalOffset(), 1, 1);
- rect.adjust(-dd->spacing(), -dd->spacing(), dd->spacing(), dd->spacing());
- const QVector<QModelIndex> intersectVector = dd->intersectingSet(rect);
- index = intersectVector.count() > 0
- ? intersectVector.last() : QModelIndex();
- if (!index.isValid())
- index = dd->root;
- }
-
- // If we are allowed to do the drop
- if (dd->model->supportedDropActions() & event->dropAction()) {
- int row = -1;
- int col = -1;
- if (index != dd->root) {
- dd->dropIndicatorPosition = position(event->pos(), qq->visualRect(index), index);
- switch (dd->dropIndicatorPosition) {
- case QAbstractItemView::AboveItem:
- row = index.row();
- col = index.column();
- index = index.parent();
- break;
- case QAbstractItemView::BelowItem:
- row = index.row() + 1;
- col = index.column();
- index = index.parent();
- break;
- case QAbstractItemView::OnItem:
- case QAbstractItemView::OnViewport:
- break;
- }
- } else {
- dd->dropIndicatorPosition = QAbstractItemView::OnViewport;
- }
- *dropIndex = index;
- *dropRow = row;
- *dropCol = col;
- if (!dd->droppingOnItself(event, index))
- return true;
- }
- return false;
-}
-
-#endif //QT_NO_DRAGANDDROP
-
-void QListModeViewBase::updateVerticalScrollBar(const QSize &step)
-{
- if (verticalScrollMode() == QAbstractItemView::ScrollPerItem
- && ((flow() == QListView::TopToBottom && !isWrapping())
- || (flow() == QListView::LeftToRight && isWrapping()))) {
- const int steps = (flow() == QListView::TopToBottom ? scrollValueMap : segmentPositions).count() - 1;
- if (steps > 0) {
- const int pageSteps = perItemScrollingPageSteps(viewport()->height(), contentsSize.height(), isWrapping());
- verticalScrollBar()->setSingleStep(1);
- verticalScrollBar()->setPageStep(pageSteps);
- verticalScrollBar()->setRange(0, steps - pageSteps);
- } else {
- verticalScrollBar()->setRange(0, 0);
- }
- // } else if (vertical && d->isWrapping() && d->movement == Static) {
- // ### wrapped scrolling in flow direction
- } else {
- QCommonListViewBase::updateVerticalScrollBar(step);
- }
-}
-
-void QListModeViewBase::updateHorizontalScrollBar(const QSize &step)
-{
- if (horizontalScrollMode() == QAbstractItemView::ScrollPerItem
- && ((flow() == QListView::TopToBottom && isWrapping())
- || (flow() == QListView::LeftToRight && !isWrapping()))) {
- int steps = (flow() == QListView::TopToBottom ? segmentPositions : scrollValueMap).count() - 1;
- if (steps > 0) {
- const int pageSteps = perItemScrollingPageSteps(viewport()->width(), contentsSize.width(), isWrapping());
- horizontalScrollBar()->setSingleStep(1);
- horizontalScrollBar()->setPageStep(pageSteps);
- horizontalScrollBar()->setRange(0, steps - pageSteps);
- } else {
- horizontalScrollBar()->setRange(0, 0);
- }
- } else {
- QCommonListViewBase::updateHorizontalScrollBar(step);
- }
-}
-
-int QListModeViewBase::verticalScrollToValue(int index, QListView::ScrollHint hint,
- bool above, bool below, const QRect &area, const QRect &rect) const
-{
- if (verticalScrollMode() == QAbstractItemView::ScrollPerItem) {
- int value;
- if (scrollValueMap.isEmpty())
- value = 0;
- else
- value = qBound(0, scrollValueMap.at(verticalScrollBar()->value()), flowPositions.count() - 1);
- if (above)
- hint = QListView::PositionAtTop;
- else if (below)
- hint = QListView::PositionAtBottom;
- if (hint == QListView::EnsureVisible)
- return value;
-
- return perItemScrollToValue(index, value, area.height(), hint, Qt::Vertical, isWrapping(), rect.height());
- }
-
- return QCommonListViewBase::verticalScrollToValue(index, hint, above, below, area, rect);
-}
-
-int QListModeViewBase::horizontalOffset() const
-{
- if (horizontalScrollMode() == QAbstractItemView::ScrollPerItem) {
- if (isWrapping()) {
- if (flow() == QListView::TopToBottom && !segmentPositions.isEmpty()) {
- const int max = segmentPositions.count() - 1;
- int currentValue = qBound(0, horizontalScrollBar()->value(), max);
- int position = segmentPositions.at(currentValue);
- int maximumValue = qBound(0, horizontalScrollBar()->maximum(), max);
- int maximum = segmentPositions.at(maximumValue);
- return (isRightToLeft() ? maximum - position : position);
- }
- } else if (flow() == QListView::LeftToRight && !flowPositions.isEmpty()) {
- int position = flowPositions.at(scrollValueMap.at(horizontalScrollBar()->value()));
- int maximum = flowPositions.at(scrollValueMap.at(horizontalScrollBar()->maximum()));
- return (isRightToLeft() ? maximum - position : position);
- }
- }
- return QCommonListViewBase::horizontalOffset();
-}
-
-int QListModeViewBase::verticalOffset() const
-{
- if (verticalScrollMode() == QAbstractItemView::ScrollPerItem) {
- if (isWrapping()) {
- if (flow() == QListView::LeftToRight && !segmentPositions.isEmpty()) {
- int value = verticalScrollBar()->value();
- if (value >= segmentPositions.count())
- return 0;
- return segmentPositions.at(value) - spacing();
- }
- } else if (flow() == QListView::TopToBottom && !flowPositions.isEmpty()) {
- int value = verticalScrollBar()->value();
- if (value > scrollValueMap.count())
- return 0;
- return flowPositions.at(scrollValueMap.at(value)) - spacing();
- }
- }
- return QCommonListViewBase::verticalOffset();
-}
-
-int QListModeViewBase::horizontalScrollToValue(int index, QListView::ScrollHint hint,
- bool leftOf, bool rightOf, const QRect &area, const QRect &rect) const
-{
- if (horizontalScrollMode() != QAbstractItemView::ScrollPerItem)
- return QCommonListViewBase::horizontalScrollToValue(index, hint, leftOf, rightOf, area, rect);
-
- int value;
- if (scrollValueMap.isEmpty())
- value = 0;
- else
- value = qBound(0, scrollValueMap.at(horizontalScrollBar()->value()), flowPositions.count() - 1);
- if (leftOf)
- hint = QListView::PositionAtTop;
- else if (rightOf)
- hint = QListView::PositionAtBottom;
- if (hint == QListView::EnsureVisible)
- return value;
-
- return perItemScrollToValue(index, value, area.width(), hint, Qt::Horizontal, isWrapping(), rect.width());
-}
-
-void QListModeViewBase::scrollContentsBy(int dx, int dy, bool scrollElasticBand)
-{
- // ### reorder this logic
- const int verticalValue = verticalScrollBar()->value();
- const int horizontalValue = horizontalScrollBar()->value();
- const bool vertical = (verticalScrollMode() == QAbstractItemView::ScrollPerItem);
- const bool horizontal = (horizontalScrollMode() == QAbstractItemView::ScrollPerItem);
-
- if (isWrapping()) {
- if (segmentPositions.isEmpty())
- return;
- const int max = segmentPositions.count() - 1;
- if (horizontal && flow() == QListView::TopToBottom && dx != 0) {
- int currentValue = qBound(0, horizontalValue, max);
- int previousValue = qBound(0, currentValue + dx, max);
- int currentCoordinate = segmentPositions.at(currentValue) - spacing();
- int previousCoordinate = segmentPositions.at(previousValue) - spacing();
- dx = previousCoordinate - currentCoordinate;
- } else if (vertical && flow() == QListView::LeftToRight && dy != 0) {
- int currentValue = qBound(0, verticalValue, max);
- int previousValue = qBound(0, currentValue + dy, max);
- int currentCoordinate = segmentPositions.at(currentValue) - spacing();
- int previousCoordinate = segmentPositions.at(previousValue) - spacing();
- dy = previousCoordinate - currentCoordinate;
- }
- } else {
- if (flowPositions.isEmpty())
- return;
- const int max = scrollValueMap.count() - 1;
- if (vertical && flow() == QListView::TopToBottom && dy != 0) {
- int currentValue = qBound(0, verticalValue, max);
- int previousValue = qBound(0, currentValue + dy, max);
- int currentCoordinate = flowPositions.at(scrollValueMap.at(currentValue));
- int previousCoordinate = flowPositions.at(scrollValueMap.at(previousValue));
- dy = previousCoordinate - currentCoordinate;
- } else if (horizontal && flow() == QListView::LeftToRight && dx != 0) {
- int currentValue = qBound(0, horizontalValue, max);
- int previousValue = qBound(0, currentValue + dx, max);
- int currentCoordinate = flowPositions.at(scrollValueMap.at(currentValue));
- int previousCoordinate = flowPositions.at(scrollValueMap.at(previousValue));
- dx = previousCoordinate - currentCoordinate;
- }
- }
- QCommonListViewBase::scrollContentsBy(dx, dy, scrollElasticBand);
-}
-
-bool QListModeViewBase::doBatchedItemLayout(const QListViewLayoutInfo &info, int max)
-{
- doStaticLayout(info);
- if (batchStartRow > max) { // stop items layout
- flowPositions.resize(flowPositions.count());
- segmentPositions.resize(segmentPositions.count());
- segmentStartRows.resize(segmentStartRows.count());
- return true; // done
- }
- return false; // not done
-}
-
-QListViewItem QListModeViewBase::indexToListViewItem(const QModelIndex &index) const
-{
- if (flowPositions.isEmpty()
- || segmentPositions.isEmpty()
- || index.row() >= flowPositions.count())
- return QListViewItem();
-
- const int segment = qBinarySearch<int>(segmentStartRows, index.row(),
- 0, segmentStartRows.count() - 1);
-
-
- QStyleOptionViewItemV4 options = viewOptions();
- options.rect.setSize(contentsSize);
- QSize size = (uniformItemSizes() && cachedItemSize().isValid())
- ? cachedItemSize() : itemSize(options, index);
-
- QPoint pos;
- if (flow() == QListView::LeftToRight) {
- pos.setX(flowPositions.at(index.row()));
- pos.setY(segmentPositions.at(segment));
- } else { // TopToBottom
- pos.setY(flowPositions.at(index.row()));
- pos.setX(segmentPositions.at(segment));
- if (isWrapping()) { // make the items as wide as the segment
- int right = (segment + 1 >= segmentPositions.count()
- ? contentsSize.width()
- : segmentPositions.at(segment + 1));
- size.setWidth(right - pos.x());
- } else { // make the items as wide as the viewport
- size.setWidth(qMax(size.width(), viewport()->width()));
- }
- }
-
- return QListViewItem(QRect(pos, size), index.row());
-}
-
-QPoint QListModeViewBase::initStaticLayout(const QListViewLayoutInfo &info)
-{
- int x, y;
- if (info.first == 0) {
- flowPositions.clear();
- segmentPositions.clear();
- segmentStartRows.clear();
- segmentExtents.clear();
- scrollValueMap.clear();
- x = info.bounds.left() + info.spacing;
- y = info.bounds.top() + info.spacing;
- segmentPositions.append(info.flow == QListView::LeftToRight ? y : x);
- segmentStartRows.append(0);
- } else if (info.wrap) {
- if (info.flow == QListView::LeftToRight) {
- x = batchSavedPosition;
- y = segmentPositions.last();
- } else { // flow == QListView::TopToBottom
- x = segmentPositions.last();
- y = batchSavedPosition;
- }
- } else { // not first and not wrap
- if (info.flow == QListView::LeftToRight) {
- x = batchSavedPosition;
- y = info.bounds.top() + info.spacing;
- } else { // flow == QListView::TopToBottom
- x = info.bounds.left() + info.spacing;
- y = batchSavedPosition;
- }
- }
- return QPoint(x, y);
-}
-
-/*!
- \internal
-*/
-void QListModeViewBase::doStaticLayout(const QListViewLayoutInfo &info)
-{
- const bool useItemSize = !info.grid.isValid();
- const QPoint topLeft = initStaticLayout(info);
- QStyleOptionViewItemV4 option = viewOptions();
- option.rect = info.bounds;
- option.rect.adjust(info.spacing, info.spacing, -info.spacing, -info.spacing);
-
- // The static layout data structures are as follows:
- // One vector contains the coordinate in the direction of layout flow.
- // Another vector contains the coordinates of the segments.
- // A third vector contains the index (model row) of the first item
- // of each segment.
-
- int segStartPosition;
- int segEndPosition;
- int deltaFlowPosition;
- int deltaSegPosition;
- int deltaSegHint;
- int flowPosition;
- int segPosition;
-
- if (info.flow == QListView::LeftToRight) {
- segStartPosition = info.bounds.left();
- segEndPosition = info.bounds.width();
- flowPosition = topLeft.x();
- segPosition = topLeft.y();
- deltaFlowPosition = info.grid.width(); // dx
- deltaSegPosition = useItemSize ? batchSavedDeltaSeg : info.grid.height(); // dy
- deltaSegHint = info.grid.height();
- } else { // flow == QListView::TopToBottom
- segStartPosition = info.bounds.top();
- segEndPosition = info.bounds.height();
- flowPosition = topLeft.y();
- segPosition = topLeft.x();
- deltaFlowPosition = info.grid.height(); // dy
- deltaSegPosition = useItemSize ? batchSavedDeltaSeg : info.grid.width(); // dx
- deltaSegHint = info.grid.width();
- }
-
- for (int row = info.first; row <= info.last; ++row) {
- if (isHidden(row)) { // ###
- flowPositions.append(flowPosition);
- } else {
- // if we are not using a grid, we need to find the deltas
- if (useItemSize) {
- QSize hint = itemSize(option, modelIndex(row));
- if (info.flow == QListView::LeftToRight) {
- deltaFlowPosition = hint.width() + info.spacing;
- deltaSegHint = hint.height() + info.spacing;
- } else { // TopToBottom
- deltaFlowPosition = hint.height() + info.spacing;
- deltaSegHint = hint.width() + info.spacing;
- }
- }
- // create new segment
- if (info.wrap && (flowPosition + deltaFlowPosition >= segEndPosition)) {
- segmentExtents.append(flowPosition);
- flowPosition = info.spacing + segStartPosition;
- segPosition += deltaSegPosition;
- if (info.wrap)
- segPosition += info.spacing;
- segmentPositions.append(segPosition);
- segmentStartRows.append(row);
- deltaSegPosition = 0;
- }
- // save the flow position of this item
- scrollValueMap.append(flowPositions.count());
- flowPositions.append(flowPosition);
- // prepare for the next item
- deltaSegPosition = qMax(deltaSegHint, deltaSegPosition);
- flowPosition += info.spacing + deltaFlowPosition;
- }
- }
- // used when laying out next batch
- batchSavedPosition = flowPosition;
- batchSavedDeltaSeg = deltaSegPosition;
- batchStartRow = info.last + 1;
- if (info.last == info.max)
- flowPosition -= info.spacing; // remove extra spacing
- // set the contents size
- QRect rect = info.bounds;
- if (info.flow == QListView::LeftToRight) {
- rect.setRight(segmentPositions.count() == 1 ? flowPosition : info.bounds.right());
- rect.setBottom(segPosition + deltaSegPosition);
- } else { // TopToBottom
- rect.setRight(segPosition + deltaSegPosition);
- rect.setBottom(segmentPositions.count() == 1 ? flowPosition : info.bounds.bottom());
- }
- contentsSize = QSize(rect.right(), rect.bottom());
- // if it is the last batch, save the end of the segments
- if (info.last == info.max) {
- segmentExtents.append(flowPosition);
- scrollValueMap.append(flowPositions.count());
- flowPositions.append(flowPosition);
- segmentPositions.append(info.wrap ? segPosition + deltaSegPosition : INT_MAX);
- }
- // if the new items are visble, update the viewport
- QRect changedRect(topLeft, rect.bottomRight());
- if (clipRect().intersects(changedRect))
- viewport()->update();
-}
-
-/*!
- \internal
- Finds the set of items intersecting with \a area.
- In this function, itemsize is counted from topleft to the start of the next item.
-*/
-QVector<QModelIndex> QListModeViewBase::intersectingSet(const QRect &area) const
-{
- QVector<QModelIndex> ret;
- int segStartPosition;
- int segEndPosition;
- int flowStartPosition;
- int flowEndPosition;
- if (flow() == QListView::LeftToRight) {
- segStartPosition = area.top();
- segEndPosition = area.bottom();
- flowStartPosition = area.left();
- flowEndPosition = area.right();
- } else {
- segStartPosition = area.left();
- segEndPosition = area.right();
- flowStartPosition = area.top();
- flowEndPosition = area.bottom();
- }
- if (segmentPositions.count() < 2 || flowPositions.isEmpty())
- return ret;
- // the last segment position is actually the edge of the last segment
- const int segLast = segmentPositions.count() - 2;
- int seg = qBinarySearch<int>(segmentPositions, segStartPosition, 0, segLast + 1);
- for (; seg <= segLast && segmentPositions.at(seg) <= segEndPosition; ++seg) {
- int first = segmentStartRows.at(seg);
- int last = (seg < segLast ? segmentStartRows.at(seg + 1) : batchStartRow) - 1;
- if (segmentExtents.at(seg) < flowStartPosition)
- continue;
- int row = qBinarySearch<int>(flowPositions, flowStartPosition, first, last);
- for (; row <= last && flowPositions.at(row) <= flowEndPosition; ++row) {
- if (isHidden(row))
- continue;
- QModelIndex index = modelIndex(row);
- if (index.isValid())
- ret += index;
-#if 0 // for debugging
- else
- qWarning("intersectingSet: row %d was invalid", row);
-#endif
- }
- }
- return ret;
-}
-
-void QListModeViewBase::dataChanged(const QModelIndex &, const QModelIndex &)
-{
- dd->doDelayedItemsLayout();
-}
-
-
-QRect QListModeViewBase::mapToViewport(const QRect &rect) const
-{
- if (isWrapping())
- return rect;
- // If the listview is in "listbox-mode", the items are as wide as the view.
- // But we don't shrink the items.
- QRect result = rect;
- if (flow() == QListView::TopToBottom) {
- result.setLeft(spacing());
- result.setWidth(qMax(rect.width(), qMax(contentsSize.width(), viewport()->width()) - 2 * spacing()));
- } else { // LeftToRight
- result.setTop(spacing());
- result.setHeight(qMax(rect.height(), qMax(contentsSize.height(), viewport()->height()) - 2 * spacing()));
- }
- return result;
-}
-
-int QListModeViewBase::perItemScrollingPageSteps(int length, int bounds, bool wrap) const
-{
- QVector<int> positions;
- if (wrap)
- positions = segmentPositions;
- else if (!flowPositions.isEmpty()) {
- positions.reserve(scrollValueMap.size());
- foreach (int itemShown, scrollValueMap)
- positions.append(flowPositions.at(itemShown));
- }
- if (positions.isEmpty() || bounds <= length)
- return positions.count();
- if (uniformItemSizes()) {
- for (int i = 1; i < positions.count(); ++i)
- if (positions.at(i) > 0)
- return length / positions.at(i);
- return 0; // all items had height 0
- }
- int pageSteps = 0;
- int steps = positions.count() - 1;
- int max = qMax(length, bounds);
- int min = qMin(length, bounds);
- int pos = min - (max - positions.last());
-
- while (pos >= 0 && steps > 0) {
- pos -= (positions.at(steps) - positions.at(steps - 1));
- if (pos >= 0) //this item should be visible
- ++pageSteps;
- --steps;
- }
-
- // at this point we know that positions has at least one entry
- return qMax(pageSteps, 1);
-}
-
-int QListModeViewBase::perItemScrollToValue(int index, int scrollValue, int viewportSize,
- QAbstractItemView::ScrollHint hint,
- Qt::Orientation orientation, bool wrap, int itemExtent) const
-{
- if (index < 0)
- return scrollValue;
- if (!wrap) {
- int topIndex = index;
- const int bottomIndex = topIndex;
- const int bottomCoordinate = flowPositions.at(index);
-
- while (topIndex > 0 &&
- (bottomCoordinate - flowPositions.at(topIndex-1) + itemExtent) <= (viewportSize)) {
- topIndex--;
- }
-
- const int itemCount = bottomIndex - topIndex + 1;
- switch (hint) {
- case QAbstractItemView::PositionAtTop:
- return index;
- case QAbstractItemView::PositionAtBottom:
- return index - itemCount + 1;
- case QAbstractItemView::PositionAtCenter:
- return index - (itemCount / 2);
- default:
- break;
- }
- } else { // wrapping
- Qt::Orientation flowOrientation = (flow() == QListView::LeftToRight
- ? Qt::Horizontal : Qt::Vertical);
- if (flowOrientation == orientation) { // scrolling in the "flow" direction
- // ### wrapped scrolling in the flow direction
- return flowPositions.at(index); // ### always pixel based for now
- } else if (!segmentStartRows.isEmpty()) { // we are scrolling in the "segment" direction
- int segment = qBinarySearch<int>(segmentStartRows, index, 0, segmentStartRows.count() - 1);
- int leftSegment = segment;
- const int rightSegment = leftSegment;
- const int bottomCoordinate = segmentPositions.at(segment);
-
- while (leftSegment > scrollValue &&
- (bottomCoordinate - segmentPositions.at(leftSegment-1) + itemExtent) <= (viewportSize)) {
- leftSegment--;
- }
-
- const int segmentCount = rightSegment - leftSegment + 1;
- switch (hint) {
- case QAbstractItemView::PositionAtTop:
- return segment;
- case QAbstractItemView::PositionAtBottom:
- return segment - segmentCount + 1;
- case QAbstractItemView::PositionAtCenter:
- return segment - (segmentCount / 2);
- default:
- break;
- }
- }
- }
- return scrollValue;
-}
-
-void QListModeViewBase::clear()
-{
- flowPositions.clear();
- segmentPositions.clear();
- segmentStartRows.clear();
- segmentExtents.clear();
- batchSavedPosition = 0;
- batchStartRow = 0;
- batchSavedDeltaSeg = 0;
-}
-
-/*
- * IconMode ListView Implementation
-*/
-
-void QIconModeViewBase::setPositionForIndex(const QPoint &position, const QModelIndex &index)
-{
- if (index.row() >= items.count())
- return;
- const QSize oldContents = contentsSize;
- qq->update(index); // update old position
- moveItem(index.row(), position);
- qq->update(index); // update new position
-
- if (contentsSize != oldContents)
- dd->viewUpdateGeometries(); // update the scroll bars
-}
-
-void QIconModeViewBase::appendHiddenRow(int row)
-{
- if (row >= 0 && row < items.count()) //remove item
- tree.removeLeaf(items.at(row).rect(), row);
- QCommonListViewBase::appendHiddenRow(row);
-}
-
-void QIconModeViewBase::removeHiddenRow(int row)
-{
- QCommonListViewBase::removeHiddenRow(row);
- if (row >= 0 && row < items.count()) //insert item
- tree.insertLeaf(items.at(row).rect(), row);
-}
-
-#ifndef QT_NO_DRAGANDDROP
-void QIconModeViewBase::paintDragDrop(QPainter *painter)
-{
- if (!draggedItems.isEmpty() && viewport()->rect().contains(draggedItemsPos)) {
- //we need to draw the items that arre dragged
- painter->translate(draggedItemsDelta());
- QStyleOptionViewItemV4 option = viewOptions();
- option.state &= ~QStyle::State_MouseOver;
- QVector<QModelIndex>::const_iterator it = draggedItems.begin();
- QListViewItem item = indexToListViewItem(*it);
- for (; it != draggedItems.end(); ++it) {
- item = indexToListViewItem(*it);
- option.rect = viewItemRect(item);
- delegate(*it)->paint(painter, option, *it);
- }
- }
-}
-
-bool QIconModeViewBase::filterStartDrag(Qt::DropActions supportedActions)
-{
- // This function does the same thing as in QAbstractItemView::startDrag(),
- // plus adding viewitems to the draggedItems list.
- // We need these items to draw the drag items
- QModelIndexList indexes = dd->selectionModel->selectedIndexes();
- if (indexes.count() > 0 ) {
- if (viewport()->acceptDrops()) {
- QModelIndexList::ConstIterator it = indexes.constBegin();
- for (; it != indexes.constEnd(); ++it)
- if (dd->model->flags(*it) & Qt::ItemIsDragEnabled
- && (*it).column() == dd->column)
- draggedItems.push_back(*it);
- }
- QDrag *drag = new QDrag(qq);
- drag->setMimeData(dd->model->mimeData(indexes));
- Qt::DropAction action = drag->exec(supportedActions, Qt::CopyAction);
- draggedItems.clear();
- if (action == Qt::MoveAction)
- dd->clearOrRemove();
- }
- return true;
-}
-
-bool QIconModeViewBase::filterDropEvent(QDropEvent *e)
-{
- if (e->source() != qq)
- return false;
-
- const QSize contents = contentsSize;
- QPoint offset(horizontalOffset(), verticalOffset());
- QPoint end = e->pos() + offset;
- if (qq->acceptDrops()) {
- const Qt::ItemFlags dropableFlags = Qt::ItemIsDropEnabled|Qt::ItemIsEnabled;
- const QVector<QModelIndex> &dropIndices = intersectingSet(QRect(end, QSize(1, 1)));
- foreach (const QModelIndex &index, dropIndices)
- if ((index.flags() & dropableFlags) == dropableFlags)
- return false;
- }
- QPoint start = dd->pressedPosition;
- QPoint delta = (dd->movement == QListView::Snap ? snapToGrid(end) - snapToGrid(start) : end - start);
- QList<QModelIndex> indexes = dd->selectionModel->selectedIndexes();
- for (int i = 0; i < indexes.count(); ++i) {
- QModelIndex index = indexes.at(i);
- QRect rect = dd->rectForIndex(index);
- viewport()->update(dd->mapToViewport(rect, false));
- QPoint dest = rect.topLeft() + delta;
- if (qq->isRightToLeft())
- dest.setX(dd->flipX(dest.x()) - rect.width());
- moveItem(index.row(), dest);
- qq->update(index);
- }
- dd->stopAutoScroll();
- draggedItems.clear();
- dd->emitIndexesMoved(indexes);
- e->accept(); // we have handled the event
- // if the size has not grown, we need to check if it has shrinked
- if (contentsSize != contents) {
- if ((contentsSize.width() <= contents.width()
- || contentsSize.height() <= contents.height())) {
- updateContentsSize();
- }
- dd->viewUpdateGeometries();
- }
- return true;
-}
-
-bool QIconModeViewBase::filterDragLeaveEvent(QDragLeaveEvent *e)
-{
- viewport()->update(draggedItemsRect()); // erase the area
- draggedItemsPos = QPoint(-1, -1); // don't draw the dragged items
- return QCommonListViewBase::filterDragLeaveEvent(e);
-}
-
-bool QIconModeViewBase::filterDragMoveEvent(QDragMoveEvent *e)
-{
- if (e->source() != qq || !dd->canDecode(e))
- return false;
-
- // ignore by default
- e->ignore();
- // get old dragged items rect
- QRect itemsRect = this->itemsRect(draggedItems);
- viewport()->update(itemsRect.translated(draggedItemsDelta()));
- // update position
- draggedItemsPos = e->pos();
- // get new items rect
- viewport()->update(itemsRect.translated(draggedItemsDelta()));
- // set the item under the cursor to current
- QModelIndex index;
- if (movement() == QListView::Snap) {
- QRect rect(snapToGrid(e->pos() + offset()), gridSize());
- const QVector<QModelIndex> intersectVector = intersectingSet(rect);
- index = intersectVector.count() > 0 ? intersectVector.last() : QModelIndex();
- } else {
- index = qq->indexAt(e->pos());
- }
- // check if we allow drops here
- if (draggedItems.contains(index))
- e->accept(); // allow changing item position
- else if (dd->model->flags(index) & Qt::ItemIsDropEnabled)
- e->accept(); // allow dropping on dropenabled items
- else if (!index.isValid())
- e->accept(); // allow dropping in empty areas
-
- // the event was treated. do autoscrolling
- if (dd->shouldAutoScroll(e->pos()))
- dd->startAutoScroll();
- return true;
-}
-#endif // QT_NO_DRAGANDDROP
-
-void QIconModeViewBase::setRowCount(int rowCount)
-{
- tree.create(qMax(rowCount - hiddenCount(), 0));
-}
-
-void QIconModeViewBase::scrollContentsBy(int dx, int dy, bool scrollElasticBand)
-{
- if (scrollElasticBand)
- dd->scrollElasticBandBy(isRightToLeft() ? -dx : dx, dy);
-
- QCommonListViewBase::scrollContentsBy(dx, dy, scrollElasticBand);
- if (!draggedItems.isEmpty())
- viewport()->update(draggedItemsRect().translated(dx, dy));
-}
-
-void QIconModeViewBase::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
-{
- if (column() >= topLeft.column() && column() <= bottomRight.column()) {
- QStyleOptionViewItemV4 option = viewOptions();
- int bottom = qMin(items.count(), bottomRight.row() + 1);
- for (int row = topLeft.row(); row < bottom; ++row)
- items[row].resize(itemSize(option, modelIndex(row)));
- }
-}
-
-bool QIconModeViewBase::doBatchedItemLayout(const QListViewLayoutInfo &info, int max)
-{
- if (info.last >= items.count()) {
- //first we create the items
- QStyleOptionViewItemV4 option = viewOptions();
- for (int row = items.count(); row <= info.last; ++row) {
- QSize size = itemSize(option, modelIndex(row));
- QListViewItem item(QRect(0, 0, size.width(), size.height()), row); // default pos
- items.append(item);
- }
- doDynamicLayout(info);
- }
- return (batchStartRow > max); // done
-}
-
-QListViewItem QIconModeViewBase::indexToListViewItem(const QModelIndex &index) const
-{
- if (index.isValid() && index.row() < items.count())
- return items.at(index.row());
- return QListViewItem();
-}
-
-void QIconModeViewBase::initBspTree(const QSize &contents)
-{
- // remove all items from the tree
- int leafCount = tree.leafCount();
- for (int l = 0; l < leafCount; ++l)
- tree.leaf(l).clear();
- // we have to get the bounding rect of the items before we can initialize the tree
- QBspTree::Node::Type type = QBspTree::Node::Both; // 2D
- // simple heuristics to get better bsp
- if (contents.height() / contents.width() >= 3)
- type = QBspTree::Node::HorizontalPlane;
- else if (contents.width() / contents.height() >= 3)
- type = QBspTree::Node::VerticalPlane;
- // build tree for the bounding rect (not just the contents rect)
- tree.init(QRect(0, 0, contents.width(), contents.height()), type);
-}
-
-QPoint QIconModeViewBase::initDynamicLayout(const QListViewLayoutInfo &info)
-{
- int x, y;
- if (info.first == 0) {
- x = info.bounds.x() + info.spacing;
- y = info.bounds.y() + info.spacing;
- items.reserve(rowCount() - hiddenCount());
- } else {
- int idx = info.first - 1;
- while (idx > 0 && !items.at(idx).isValid())
- --idx;
- const QListViewItem &item = items.at(idx);
- x = item.x;
- y = item.y;
- if (info.flow == QListView::LeftToRight)
- x += (info.grid.isValid() ? info.grid.width() : item.w) + info.spacing;
- else
- y += (info.grid.isValid() ? info.grid.height() : item.h) + info.spacing;
- }
- return QPoint(x, y);
-}
-
-/*!
- \internal
-*/
-void QIconModeViewBase::doDynamicLayout(const QListViewLayoutInfo &info)
-{
- const bool useItemSize = !info.grid.isValid();
- const QPoint topLeft = initDynamicLayout(info);
-
- int segStartPosition;
- int segEndPosition;
- int deltaFlowPosition;
- int deltaSegPosition;
- int deltaSegHint;
- int flowPosition;
- int segPosition;
-
- if (info.flow == QListView::LeftToRight) {
- segStartPosition = info.bounds.left() + info.spacing;
- segEndPosition = info.bounds.right();
- deltaFlowPosition = info.grid.width(); // dx
- deltaSegPosition = (useItemSize ? batchSavedDeltaSeg : info.grid.height()); // dy
- deltaSegHint = info.grid.height();
- flowPosition = topLeft.x();
- segPosition = topLeft.y();
- } else { // flow == QListView::TopToBottom
- segStartPosition = info.bounds.top() + info.spacing;
- segEndPosition = info.bounds.bottom();
- deltaFlowPosition = info.grid.height(); // dy
- deltaSegPosition = (useItemSize ? batchSavedDeltaSeg : info.grid.width()); // dx
- deltaSegHint = info.grid.width();
- flowPosition = topLeft.y();
- segPosition = topLeft.x();
- }
-
- if (moved.count() != items.count())
- moved.resize(items.count());
-
- QRect rect(QPoint(), topLeft);
- QListViewItem *item = 0;
- for (int row = info.first; row <= info.last; ++row) {
- item = &items[row];
- if (isHidden(row)) {
- item->invalidate();
- } else {
- // if we are not using a grid, we need to find the deltas
- if (useItemSize) {
- if (info.flow == QListView::LeftToRight)
- deltaFlowPosition = item->w + info.spacing;
- else
- deltaFlowPosition = item->h + info.spacing;
- } else {
- item->w = qMin<int>(info.grid.width(), item->w);
- item->h = qMin<int>(info.grid.height(), item->h);
- }
-
- // create new segment
- if (info.wrap
- && flowPosition + deltaFlowPosition > segEndPosition
- && flowPosition > segStartPosition) {
- flowPosition = segStartPosition;
- segPosition += deltaSegPosition;
- if (useItemSize)
- deltaSegPosition = 0;
- }
- // We must delay calculation of the seg adjustment, as this item
- // may have caused a wrap to occur
- if (useItemSize) {
- if (info.flow == QListView::LeftToRight)
- deltaSegHint = item->h + info.spacing;
- else
- deltaSegHint = item->w + info.spacing;
- deltaSegPosition = qMax(deltaSegPosition, deltaSegHint);
- }
-
- // set the position of the item
- // ### idealy we should have some sort of alignment hint for the item
- // ### (normally that would be a point between the icon and the text)
- if (!moved.testBit(row)) {
- if (info.flow == QListView::LeftToRight) {
- if (useItemSize) {
- item->x = flowPosition;
- item->y = segPosition;
- } else { // use grid
- item->x = flowPosition + ((deltaFlowPosition - item->w) / 2);
- item->y = segPosition;
- }
- } else { // TopToBottom
- if (useItemSize) {
- item->y = flowPosition;
- item->x = segPosition;
- } else { // use grid
- item->y = flowPosition + ((deltaFlowPosition - item->h) / 2);
- item->x = segPosition;
- }
- }
- }
-
- // let the contents contain the new item
- if (useItemSize)
- rect |= item->rect();
- else if (info.flow == QListView::LeftToRight)
- rect |= QRect(flowPosition, segPosition, deltaFlowPosition, deltaSegPosition);
- else // flow == TopToBottom
- rect |= QRect(segPosition, flowPosition, deltaSegPosition, deltaFlowPosition);
-
- // prepare for next item
- flowPosition += deltaFlowPosition; // current position + item width + gap
- }
- }
- batchSavedDeltaSeg = deltaSegPosition;
- batchStartRow = info.last + 1;
- bool done = (info.last >= rowCount() - 1);
- // resize the content area
- if (done || !info.bounds.contains(item->rect())) {
- contentsSize = rect.size();
- if (info.flow == QListView::LeftToRight)
- contentsSize.rheight() += info.spacing;
- else
- contentsSize.rwidth() += info.spacing;
- }
- if (rect.size().isEmpty())
- return;
- // resize tree
- int insertFrom = info.first;
- if (done || info.first == 0) {
- initBspTree(rect.size());
- insertFrom = 0;
- }
- // insert items in tree
- for (int row = insertFrom; row <= info.last; ++row)
- tree.insertLeaf(items.at(row).rect(), row);
- // if the new items are visble, update the viewport
- QRect changedRect(topLeft, rect.bottomRight());
- if (clipRect().intersects(changedRect))
- viewport()->update();
-}
-
-QVector<QModelIndex> QIconModeViewBase::intersectingSet(const QRect &area) const
-{
- QIconModeViewBase *that = const_cast<QIconModeViewBase*>(this);
- QBspTree::Data data(static_cast<void*>(that));
- QVector<QModelIndex> res;
- that->interSectingVector = &res;
- that->tree.climbTree(area, &QIconModeViewBase::addLeaf, data);
- that->interSectingVector = 0;
- return res;
-}
-
-QRect QIconModeViewBase::itemsRect(const QVector<QModelIndex> &indexes) const
-{
- QVector<QModelIndex>::const_iterator it = indexes.begin();
- QListViewItem item = indexToListViewItem(*it);
- QRect rect(item.x, item.y, item.w, item.h);
- for (; it != indexes.end(); ++it) {
- item = indexToListViewItem(*it);
- rect |= viewItemRect(item);
- }
- return rect;
-}
-
-int QIconModeViewBase::itemIndex(const QListViewItem &item) const
-{
- if (!item.isValid())
- return -1;
- int i = item.indexHint;
- if (i < items.count()) {
- if (items.at(i) == item)
- return i;
- } else {
- i = items.count() - 1;
- }
-
- int j = i;
- int c = items.count();
- bool a = true;
- bool b = true;
-
- while (a || b) {
- if (a) {
- if (items.at(i) == item) {
- items.at(i).indexHint = i;
- return i;
- }
- a = ++i < c;
- }
- if (b) {
- if (items.at(j) == item) {
- items.at(j).indexHint = j;
- return j;
- }
- b = --j > -1;
- }
- }
- return -1;
-}
-
-void QIconModeViewBase::addLeaf(QVector<int> &leaf, const QRect &area,
- uint visited, QBspTree::Data data)
-{
- QListViewItem *vi;
- QIconModeViewBase *_this = static_cast<QIconModeViewBase *>(data.ptr);
- for (int i = 0; i < leaf.count(); ++i) {
- int idx = leaf.at(i);
- if (idx < 0 || idx >= _this->items.count())
- continue;
- vi = &_this->items[idx];
- Q_ASSERT(vi);
- if (vi->isValid() && vi->rect().intersects(area) && vi->visited != visited) {
- QModelIndex index = _this->dd->listViewItemToIndex(*vi);
- Q_ASSERT(index.isValid());
- _this->interSectingVector->append(index);
- vi->visited = visited;
- }
- }
-}
-
-void QIconModeViewBase::moveItem(int index, const QPoint &dest)
-{
- // does not impact on the bintree itself or the contents rect
- QListViewItem *item = &items[index];
- QRect rect = item->rect();
-
- // move the item without removing it from the tree
- tree.removeLeaf(rect, index);
- item->move(dest);
- tree.insertLeaf(QRect(dest, rect.size()), index);
-
- // resize the contents area
- contentsSize = (QRect(QPoint(0, 0), contentsSize)|QRect(dest, rect.size())).size();
-
- // mark the item as moved
- if (moved.count() != items.count())
- moved.resize(items.count());
- moved.setBit(index, true);
-}
-
-QPoint QIconModeViewBase::snapToGrid(const QPoint &pos) const
-{
- int x = pos.x() - (pos.x() % gridSize().width());
- int y = pos.y() - (pos.y() % gridSize().height());
- return QPoint(x, y);
-}
-
-QPoint QIconModeViewBase::draggedItemsDelta() const
-{
- if (movement() == QListView::Snap) {
- QPoint snapdelta = QPoint((offset().x() % gridSize().width()),
- (offset().y() % gridSize().height()));
- return snapToGrid(draggedItemsPos + snapdelta) - snapToGrid(pressedPosition()) - snapdelta;
- }
- return draggedItemsPos - pressedPosition();
-}
-
-QRect QIconModeViewBase::draggedItemsRect() const
-{
- QRect rect = itemsRect(draggedItems);
- rect.translate(draggedItemsDelta());
- return rect;
-}
-
-void QListViewPrivate::scrollElasticBandBy(int dx, int dy)
-{
- if (dx > 0) // right
- elasticBand.moveRight(elasticBand.right() + dx);
- else if (dx < 0) // left
- elasticBand.moveLeft(elasticBand.left() - dx);
- if (dy > 0) // down
- elasticBand.moveBottom(elasticBand.bottom() + dy);
- else if (dy < 0) // up
- elasticBand.moveTop(elasticBand.top() - dy);
-}
-
-void QIconModeViewBase::clear()
-{
- tree.destroy();
- items.clear();
- moved.clear();
- batchStartRow = 0;
- batchSavedDeltaSeg = 0;
-}
-
-void QIconModeViewBase::updateContentsSize()
-{
- QRect bounding;
- for (int i = 0; i < items.count(); ++i)
- bounding |= items.at(i).rect();
- contentsSize = bounding.size();
-}
-
-/*!
- \reimp
-*/
-void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
-{
-#ifndef QT_NO_ACCESSIBILITY
- if (QAccessible::isActive()) {
- if (current.isValid()) {
- int entry = visualIndex(current) + 1;
- QAccessible::updateAccessibility(viewport(), entry, QAccessible::Focus);
- }
- }
-#endif
- QAbstractItemView::currentChanged(current, previous);
-}
-
-/*!
- \reimp
-*/
-void QListView::selectionChanged(const QItemSelection &selected,
- const QItemSelection &deselected)
-{
-#ifndef QT_NO_ACCESSIBILITY
- if (QAccessible::isActive()) {
- // ### does not work properly for selection ranges.
- QModelIndex sel = selected.indexes().value(0);
- if (sel.isValid()) {
- int entry = visualIndex(sel) + 1;
- QAccessible::updateAccessibility(viewport(), entry, QAccessible::Selection);
- }
- QModelIndex desel = deselected.indexes().value(0);
- if (desel.isValid()) {
- int entry = visualIndex(desel) + 1;
- QAccessible::updateAccessibility(viewport(), entry, QAccessible::SelectionRemove);
- }
- }
-#endif
- QAbstractItemView::selectionChanged(selected, deselected);
-}
-
-int QListView::visualIndex(const QModelIndex &index) const
-{
- Q_D(const QListView);
- d->executePostedLayout();
- QListViewItem itm = d->indexToListViewItem(index);
- return d->commonListView->itemIndex(itm);
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_LISTVIEW
diff --git a/src/gui/itemviews/qlistview.h b/src/gui/itemviews/qlistview.h
deleted file mode 100644
index 3d6dd421f7..0000000000
--- a/src/gui/itemviews/qlistview.h
+++ /dev/null
@@ -1,203 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QLISTVIEW_H
-#define QLISTVIEW_H
-
-#include <QtGui/qabstractitemview.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_LISTVIEW
-
-class QListViewPrivate;
-
-class Q_GUI_EXPORT QListView : public QAbstractItemView
-{
- Q_OBJECT
- Q_ENUMS(Movement Flow ResizeMode LayoutMode ViewMode)
- Q_PROPERTY(Movement movement READ movement WRITE setMovement)
- Q_PROPERTY(Flow flow READ flow WRITE setFlow)
- Q_PROPERTY(bool isWrapping READ isWrapping WRITE setWrapping)
- Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode)
- Q_PROPERTY(LayoutMode layoutMode READ layoutMode WRITE setLayoutMode)
- Q_PROPERTY(int spacing READ spacing WRITE setSpacing)
- Q_PROPERTY(QSize gridSize READ gridSize WRITE setGridSize)
- Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode)
- Q_PROPERTY(int modelColumn READ modelColumn WRITE setModelColumn)
- Q_PROPERTY(bool uniformItemSizes READ uniformItemSizes WRITE setUniformItemSizes)
- Q_PROPERTY(int batchSize READ batchSize WRITE setBatchSize)
- Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
- Q_PROPERTY(bool selectionRectVisible READ isSelectionRectVisible WRITE setSelectionRectVisible)
-
-public:
- enum Movement { Static, Free, Snap };
- enum Flow { LeftToRight, TopToBottom };
- enum ResizeMode { Fixed, Adjust };
- enum LayoutMode { SinglePass, Batched };
- enum ViewMode { ListMode, IconMode };
-
- explicit QListView(QWidget *parent = 0);
- ~QListView();
-
- void setMovement(Movement movement);
- Movement movement() const;
-
- void setFlow(Flow flow);
- Flow flow() const;
-
- void setWrapping(bool enable);
- bool isWrapping() const;
-
- void setResizeMode(ResizeMode mode);
- ResizeMode resizeMode() const;
-
- void setLayoutMode(LayoutMode mode);
- LayoutMode layoutMode() const;
-
- void setSpacing(int space);
- int spacing() const;
-
- void setBatchSize(int batchSize);
- int batchSize() const;
-
- void setGridSize(const QSize &size);
- QSize gridSize() const;
-
- void setViewMode(ViewMode mode);
- ViewMode viewMode() const;
-
- void clearPropertyFlags();
-
- bool isRowHidden(int row) const;
- void setRowHidden(int row, bool hide);
-
- void setModelColumn(int column);
- int modelColumn() const;
-
- void setUniformItemSizes(bool enable);
- bool uniformItemSizes() const;
-
- void setWordWrap(bool on);
- bool wordWrap() const;
-
- void setSelectionRectVisible(bool show);
- bool isSelectionRectVisible() const;
-
- QRect visualRect(const QModelIndex &index) const;
- void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible);
- QModelIndex indexAt(const QPoint &p) const;
-
- void doItemsLayout();
- void reset();
- void setRootIndex(const QModelIndex &index);
-
-Q_SIGNALS:
- void indexesMoved(const QModelIndexList &indexes);
-
-protected:
- QListView(QListViewPrivate &, QWidget *parent = 0);
-
- bool event(QEvent *e);
-
- void scrollContentsBy(int dx, int dy);
-
- void resizeContents(int width, int height);
- QSize contentsSize() const;
-
- void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
- void rowsInserted(const QModelIndex &parent, int start, int end);
- void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
-
- void mouseMoveEvent(QMouseEvent *e);
- void mouseReleaseEvent(QMouseEvent *e);
-
- void timerEvent(QTimerEvent *e);
- void resizeEvent(QResizeEvent *e);
-#ifndef QT_NO_DRAGANDDROP
- void dragMoveEvent(QDragMoveEvent *e);
- void dragLeaveEvent(QDragLeaveEvent *e);
- void dropEvent(QDropEvent *e);
- void startDrag(Qt::DropActions supportedActions);
-
- void internalDrop(QDropEvent *e);
- void internalDrag(Qt::DropActions supportedActions);
-#endif // QT_NO_DRAGANDDROP
-
- QStyleOptionViewItem viewOptions() const;
- void paintEvent(QPaintEvent *e);
-
- int horizontalOffset() const;
- int verticalOffset() const;
- QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
- QRect rectForIndex(const QModelIndex &index) const;
- void setPositionForIndex(const QPoint &position, const QModelIndex &index);
-
- void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command);
- QRegion visualRegionForSelection(const QItemSelection &selection) const;
- QModelIndexList selectedIndexes() const;
-
- void updateGeometries();
-
- bool isIndexHidden(const QModelIndex &index) const;
-
- void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
- void currentChanged(const QModelIndex &current, const QModelIndex &previous);
-
-private:
- friend class QAccessibleItemView;
- int visualIndex(const QModelIndex &index) const;
-
- Q_DECLARE_PRIVATE(QListView)
- Q_DISABLE_COPY(QListView)
-};
-
-#endif // QT_NO_LISTVIEW
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QLISTVIEW_H
diff --git a/src/gui/itemviews/qlistwidget.h b/src/gui/itemviews/qlistwidget.h
deleted file mode 100644
index ff6616dfac..0000000000
--- a/src/gui/itemviews/qlistwidget.h
+++ /dev/null
@@ -1,335 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QLISTWIDGET_H
-#define QLISTWIDGET_H
-
-#include <QtGui/qlistview.h>
-#include <QtCore/qvariant.h>
-#include <QtCore/qvector.h>
-#include <QtGui/qitemselectionmodel.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_LISTWIDGET
-
-class QListWidget;
-class QListModel;
-class QWidgetItemData;
-class QListWidgetItemPrivate;
-
-class Q_GUI_EXPORT QListWidgetItem
-{
- friend class QListModel;
- friend class QListWidget;
-public:
- enum ItemType { Type = 0, UserType = 1000 };
- explicit QListWidgetItem(QListWidget *view = 0, int type = Type);
- explicit QListWidgetItem(const QString &text, QListWidget *view = 0, int type = Type);
- explicit QListWidgetItem(const QIcon &icon, const QString &text,
- QListWidget *view = 0, int type = Type);
- QListWidgetItem(const QListWidgetItem &other);
- virtual ~QListWidgetItem();
-
- virtual QListWidgetItem *clone() const;
-
- inline QListWidget *listWidget() const { return view; }
-
- inline void setSelected(bool select);
- inline bool isSelected() const;
-
- inline void setHidden(bool hide);
- inline bool isHidden() const;
-
- inline Qt::ItemFlags flags() const { return itemFlags; }
- void setFlags(Qt::ItemFlags flags);
-
- inline QString text() const
- { return data(Qt::DisplayRole).toString(); }
- inline void setText(const QString &text);
-
- inline QIcon icon() const
- { return qvariant_cast<QIcon>(data(Qt::DecorationRole)); }
- inline void setIcon(const QIcon &icon);
-
- inline QString statusTip() const
- { return data(Qt::StatusTipRole).toString(); }
- inline void setStatusTip(const QString &statusTip);
-
-#ifndef QT_NO_TOOLTIP
- inline QString toolTip() const
- { return data(Qt::ToolTipRole).toString(); }
- inline void setToolTip(const QString &toolTip);
-#endif
-
-#ifndef QT_NO_WHATSTHIS
- inline QString whatsThis() const
- { return data(Qt::WhatsThisRole).toString(); }
- inline void setWhatsThis(const QString &whatsThis);
-#endif
-
- inline QFont font() const
- { return qvariant_cast<QFont>(data(Qt::FontRole)); }
- inline void setFont(const QFont &font);
-
- inline int textAlignment() const
- { return data(Qt::TextAlignmentRole).toInt(); }
- inline void setTextAlignment(int alignment)
- { setData(Qt::TextAlignmentRole, alignment); }
-
- inline QColor backgroundColor() const
- { return qvariant_cast<QColor>(data(Qt::BackgroundColorRole)); }
- virtual void setBackgroundColor(const QColor &color)
- { setData(Qt::BackgroundColorRole, color); }
-
- inline QBrush background() const
- { return qvariant_cast<QBrush>(data(Qt::BackgroundRole)); }
- inline void setBackground(const QBrush &brush)
- { setData(Qt::BackgroundRole, brush); }
-
- inline QColor textColor() const
- { return qvariant_cast<QColor>(data(Qt::TextColorRole)); }
- inline void setTextColor(const QColor &color)
- { setData(Qt::TextColorRole, color); }
-
- inline QBrush foreground() const
- { return qvariant_cast<QBrush>(data(Qt::ForegroundRole)); }
- inline void setForeground(const QBrush &brush)
- { setData(Qt::ForegroundRole, brush); }
-
- inline Qt::CheckState checkState() const
- { return static_cast<Qt::CheckState>(data(Qt::CheckStateRole).toInt()); }
- inline void setCheckState(Qt::CheckState state)
- { setData(Qt::CheckStateRole, static_cast<int>(state)); }
-
- inline QSize sizeHint() const
- { return qvariant_cast<QSize>(data(Qt::SizeHintRole)); }
- inline void setSizeHint(const QSize &size)
- { setData(Qt::SizeHintRole, size); }
-
- virtual QVariant data(int role) const;
- virtual void setData(int role, const QVariant &value);
-
- virtual bool operator<(const QListWidgetItem &other) const;
-
-#ifndef QT_NO_DATASTREAM
- virtual void read(QDataStream &in);
- virtual void write(QDataStream &out) const;
-#endif
- QListWidgetItem &operator=(const QListWidgetItem &other);
-
- inline int type() const { return rtti; }
-
-private:
- int rtti;
- QVector<void *> dummy;
- QListWidget *view;
- QListWidgetItemPrivate *d;
- Qt::ItemFlags itemFlags;
-};
-
-inline void QListWidgetItem::setText(const QString &atext)
-{ setData(Qt::DisplayRole, atext); }
-
-inline void QListWidgetItem::setIcon(const QIcon &aicon)
-{ setData(Qt::DecorationRole, aicon); }
-
-inline void QListWidgetItem::setStatusTip(const QString &astatusTip)
-{ setData(Qt::StatusTipRole, astatusTip); }
-
-#ifndef QT_NO_TOOLTIP
-inline void QListWidgetItem::setToolTip(const QString &atoolTip)
-{ setData(Qt::ToolTipRole, atoolTip); }
-#endif
-
-#ifndef QT_NO_WHATSTHIS
-inline void QListWidgetItem::setWhatsThis(const QString &awhatsThis)
-{ setData(Qt::WhatsThisRole, awhatsThis); }
-#endif
-
-inline void QListWidgetItem::setFont(const QFont &afont)
-{ setData(Qt::FontRole, afont); }
-
-#ifndef QT_NO_DATASTREAM
-Q_GUI_EXPORT QDataStream &operator<<(QDataStream &out, const QListWidgetItem &item);
-Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QListWidgetItem &item);
-#endif
-
-class QListWidgetPrivate;
-
-class Q_GUI_EXPORT QListWidget : public QListView
-{
- Q_OBJECT
- Q_PROPERTY(int count READ count)
- Q_PROPERTY(int currentRow READ currentRow WRITE setCurrentRow NOTIFY currentRowChanged USER true)
- Q_PROPERTY(bool sortingEnabled READ isSortingEnabled WRITE setSortingEnabled)
-
- friend class QListWidgetItem;
- friend class QListModel;
-public:
- explicit QListWidget(QWidget *parent = 0);
- ~QListWidget();
-
- QListWidgetItem *item(int row) const;
- int row(const QListWidgetItem *item) const;
- void insertItem(int row, QListWidgetItem *item);
- void insertItem(int row, const QString &label);
- void insertItems(int row, const QStringList &labels);
- inline void addItem(const QString &label) { insertItem(count(), label); }
- inline void addItem(QListWidgetItem *item);
- inline void addItems(const QStringList &labels) { insertItems(count(), labels); }
- QListWidgetItem *takeItem(int row);
- int count() const;
-
- QListWidgetItem *currentItem() const;
- void setCurrentItem(QListWidgetItem *item);
- void setCurrentItem(QListWidgetItem *item, QItemSelectionModel::SelectionFlags command);
-
- int currentRow() const;
- void setCurrentRow(int row);
- void setCurrentRow(int row, QItemSelectionModel::SelectionFlags command);
-
- QListWidgetItem *itemAt(const QPoint &p) const;
- inline QListWidgetItem *itemAt(int x, int y) const;
- QRect visualItemRect(const QListWidgetItem *item) const;
-
- void sortItems(Qt::SortOrder order = Qt::AscendingOrder);
- void setSortingEnabled(bool enable);
- bool isSortingEnabled() const;
-
- void editItem(QListWidgetItem *item);
- void openPersistentEditor(QListWidgetItem *item);
- void closePersistentEditor(QListWidgetItem *item);
-
- QWidget *itemWidget(QListWidgetItem *item) const;
- void setItemWidget(QListWidgetItem *item, QWidget *widget);
- inline void removeItemWidget(QListWidgetItem *item);
-
- bool isItemSelected(const QListWidgetItem *item) const;
- void setItemSelected(const QListWidgetItem *item, bool select);
- QList<QListWidgetItem*> selectedItems() const;
- QList<QListWidgetItem*> findItems(const QString &text, Qt::MatchFlags flags) const;
-
- bool isItemHidden(const QListWidgetItem *item) const;
- void setItemHidden(const QListWidgetItem *item, bool hide);
- void dropEvent(QDropEvent *event);
-
-public Q_SLOTS:
- void scrollToItem(const QListWidgetItem *item, QAbstractItemView::ScrollHint hint = EnsureVisible);
- void clear();
-
-Q_SIGNALS:
- void itemPressed(QListWidgetItem *item);
- void itemClicked(QListWidgetItem *item);
- void itemDoubleClicked(QListWidgetItem *item);
- void itemActivated(QListWidgetItem *item);
- void itemEntered(QListWidgetItem *item);
- void itemChanged(QListWidgetItem *item);
-
- void currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous);
- void currentTextChanged(const QString &currentText);
- void currentRowChanged(int currentRow);
-
- void itemSelectionChanged();
-
-protected:
- bool event(QEvent *e);
- virtual QStringList mimeTypes() const;
- virtual QMimeData *mimeData(const QList<QListWidgetItem*> items) const;
-#ifndef QT_NO_DRAGANDDROP
- virtual bool dropMimeData(int index, const QMimeData *data, Qt::DropAction action);
- virtual Qt::DropActions supportedDropActions() const;
-#endif
- QList<QListWidgetItem*> items(const QMimeData *data) const;
-
- QModelIndex indexFromItem(QListWidgetItem *item) const;
- QListWidgetItem *itemFromIndex(const QModelIndex &index) const;
-
-private:
- void setModel(QAbstractItemModel *model);
- Qt::SortOrder sortOrder() const;
-
- Q_DECLARE_PRIVATE(QListWidget)
- Q_DISABLE_COPY(QListWidget)
-
- Q_PRIVATE_SLOT(d_func(), void _q_emitItemPressed(const QModelIndex &index))
- Q_PRIVATE_SLOT(d_func(), void _q_emitItemClicked(const QModelIndex &index))
- Q_PRIVATE_SLOT(d_func(), void _q_emitItemDoubleClicked(const QModelIndex &index))
- Q_PRIVATE_SLOT(d_func(), void _q_emitItemActivated(const QModelIndex &index))
- Q_PRIVATE_SLOT(d_func(), void _q_emitItemEntered(const QModelIndex &index))
- Q_PRIVATE_SLOT(d_func(), void _q_emitItemChanged(const QModelIndex &index))
- Q_PRIVATE_SLOT(d_func(), void _q_emitCurrentItemChanged(const QModelIndex &previous, const QModelIndex &current))
- Q_PRIVATE_SLOT(d_func(), void _q_sort())
- Q_PRIVATE_SLOT(d_func(), void _q_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight))
-};
-
-inline void QListWidget::removeItemWidget(QListWidgetItem *aItem)
-{ setItemWidget(aItem, 0); }
-
-inline void QListWidget::addItem(QListWidgetItem *aitem)
-{ insertItem(count(), aitem); }
-
-inline QListWidgetItem *QListWidget::itemAt(int ax, int ay) const
-{ return itemAt(QPoint(ax, ay)); }
-
-inline void QListWidgetItem::setSelected(bool aselect)
-{ if (view) view->setItemSelected(this, aselect); }
-
-inline bool QListWidgetItem::isSelected() const
-{ return (view ? view->isItemSelected(this) : false); }
-
-inline void QListWidgetItem::setHidden(bool ahide)
-{ if (view) view->setItemHidden(this, ahide); }
-
-inline bool QListWidgetItem::isHidden() const
-{ return (view ? view->isItemHidden(this) : false); }
-
-#endif // QT_NO_LISTWIDGET
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QLISTWIDGET_H
diff --git a/src/gui/itemviews/qlistwidget_p.h b/src/gui/itemviews/qlistwidget_p.h
deleted file mode 100644
index 0614b66799..0000000000
--- a/src/gui/itemviews/qlistwidget_p.h
+++ /dev/null
@@ -1,175 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QLISTWIDGET_P_H
-#define QLISTWIDGET_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. This header file may change
-// from version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qabstractitemmodel.h>
-#include <QtGui/qabstractitemview.h>
-#include <QtGui/qlistwidget.h>
-#include <qitemdelegate.h>
-#include <private/qlistview_p.h>
-#include <private/qwidgetitemdata_p.h>
-
-#ifndef QT_NO_LISTWIDGET
-
-QT_BEGIN_NAMESPACE
-
-class QListModelLessThan
-{
-public:
- inline bool operator()(QListWidgetItem *i1, QListWidgetItem *i2) const
- { return *i1 < *i2; }
-};
-
-class QListModelGreaterThan
-{
-public:
- inline bool operator()(QListWidgetItem *i1, QListWidgetItem *i2) const
- { return *i2 < *i1; }
-};
-
-class Q_AUTOTEST_EXPORT QListModel : public QAbstractListModel
-{
- Q_OBJECT
-public:
- QListModel(QListWidget *parent);
- ~QListModel();
-
- void clear();
- QListWidgetItem *at(int row) const;
- void insert(int row, QListWidgetItem *item);
- void insert(int row, const QStringList &items);
- void remove(QListWidgetItem *item);
- QListWidgetItem *take(int row);
- void move(int srcRow, int dstRow);
-
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
-
- QModelIndex index(QListWidgetItem *item) const;
- QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
-
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- bool setData(const QModelIndex &index, const QVariant &value, int role);
-
- QMap<int, QVariant> itemData(const QModelIndex &index) const;
-
- bool insertRows(int row, int count = 1, const QModelIndex &parent = QModelIndex());
- bool removeRows(int row, int count = 1, const QModelIndex &parent = QModelIndex());
-
- Qt::ItemFlags flags(const QModelIndex &index) const;
-
- void sort(int column, Qt::SortOrder order);
- void ensureSorted(int column, Qt::SortOrder order, int start, int end);
- static bool itemLessThan(const QPair<QListWidgetItem*,int> &left,
- const QPair<QListWidgetItem*,int> &right);
- static bool itemGreaterThan(const QPair<QListWidgetItem*,int> &left,
- const QPair<QListWidgetItem*,int> &right);
- static QList<QListWidgetItem*>::iterator sortedInsertionIterator(
- const QList<QListWidgetItem*>::iterator &begin,
- const QList<QListWidgetItem*>::iterator &end,
- Qt::SortOrder order, QListWidgetItem *item);
-
- void itemChanged(QListWidgetItem *item);
-
- // dnd
- QStringList mimeTypes() const;
- QMimeData *mimeData(const QModelIndexList &indexes) const;
-#ifndef QT_NO_DRAGANDDROP
- bool dropMimeData(const QMimeData *data, Qt::DropAction action,
- int row, int column, const QModelIndex &parent);
- Qt::DropActions supportedDropActions() const;
-#endif
-
- QMimeData *internalMimeData() const;
-private:
- QList<QListWidgetItem*> items;
-
- // A cache must be mutable if get-functions should have const modifiers
- mutable QModelIndexList cachedIndexes;
-};
-
-
-
-class QListWidgetPrivate : public QListViewPrivate
-{
- Q_DECLARE_PUBLIC(QListWidget)
-public:
- QListWidgetPrivate() : QListViewPrivate(), sortOrder(Qt::AscendingOrder), sortingEnabled(false) {}
- inline QListModel *listModel() const { return qobject_cast<QListModel*>(model); }
- void setup();
- void _q_emitItemPressed(const QModelIndex &index);
- void _q_emitItemClicked(const QModelIndex &index);
- void _q_emitItemDoubleClicked(const QModelIndex &index);
- void _q_emitItemActivated(const QModelIndex &index);
- void _q_emitItemEntered(const QModelIndex &index);
- void _q_emitItemChanged(const QModelIndex &index);
- void _q_emitCurrentItemChanged(const QModelIndex &current, const QModelIndex &previous);
- void _q_sort();
- void _q_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
- Qt::SortOrder sortOrder;
- bool sortingEnabled;
-};
-
-class QListWidgetItemPrivate
-{
-public:
- QListWidgetItemPrivate(QListWidgetItem *item) : q(item), theid(-1) {}
- QListWidgetItem *q;
- QVector<QWidgetItemData> values;
- int theid;
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_LISTWIDGET
-
-#endif // QLISTWIDGET_P_H
diff --git a/src/gui/itemviews/qsortfilterproxymodel.h b/src/gui/itemviews/qsortfilterproxymodel.h
deleted file mode 100644
index afeaa6936d..0000000000
--- a/src/gui/itemviews/qsortfilterproxymodel.h
+++ /dev/null
@@ -1,201 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSORTFILTERPROXYMODEL_H
-#define QSORTFILTERPROXYMODEL_H
-
-#include <QtGui/qabstractproxymodel.h>
-
-#ifndef QT_NO_SORTFILTERPROXYMODEL
-
-#include <QtCore/qregexp.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QSortFilterProxyModelPrivate;
-class QSortFilterProxyModelLessThan;
-class QSortFilterProxyModelGreaterThan;
-
-class Q_GUI_EXPORT QSortFilterProxyModel : public QAbstractProxyModel
-{
- friend class QSortFilterProxyModelLessThan;
- friend class QSortFilterProxyModelGreaterThan;
-
- Q_OBJECT
- Q_PROPERTY(QRegExp filterRegExp READ filterRegExp WRITE setFilterRegExp)
- Q_PROPERTY(int filterKeyColumn READ filterKeyColumn WRITE setFilterKeyColumn)
- Q_PROPERTY(bool dynamicSortFilter READ dynamicSortFilter WRITE setDynamicSortFilter)
- Q_PROPERTY(Qt::CaseSensitivity filterCaseSensitivity READ filterCaseSensitivity WRITE setFilterCaseSensitivity)
- Q_PROPERTY(Qt::CaseSensitivity sortCaseSensitivity READ sortCaseSensitivity WRITE setSortCaseSensitivity)
- Q_PROPERTY(bool isSortLocaleAware READ isSortLocaleAware WRITE setSortLocaleAware)
- Q_PROPERTY(int sortRole READ sortRole WRITE setSortRole)
- Q_PROPERTY(int filterRole READ filterRole WRITE setFilterRole)
-
-public:
- QSortFilterProxyModel(QObject *parent = 0);
- ~QSortFilterProxyModel();
-
- void setSourceModel(QAbstractItemModel *sourceModel);
-
- QModelIndex mapToSource(const QModelIndex &proxyIndex) const;
- QModelIndex mapFromSource(const QModelIndex &sourceIndex) const;
-
- QItemSelection mapSelectionToSource(const QItemSelection &proxySelection) const;
- QItemSelection mapSelectionFromSource(const QItemSelection &sourceSelection) const;
-
- QRegExp filterRegExp() const;
- void setFilterRegExp(const QRegExp &regExp);
-
- int filterKeyColumn() const;
- void setFilterKeyColumn(int column);
-
- Qt::CaseSensitivity filterCaseSensitivity() const;
- void setFilterCaseSensitivity(Qt::CaseSensitivity cs);
-
- Qt::CaseSensitivity sortCaseSensitivity() const;
- void setSortCaseSensitivity(Qt::CaseSensitivity cs);
-
- bool isSortLocaleAware() const;
- void setSortLocaleAware(bool on);
-
- int sortColumn() const;
- Qt::SortOrder sortOrder() const;
-
- bool dynamicSortFilter() const;
- void setDynamicSortFilter(bool enable);
-
- int sortRole() const;
- void setSortRole(int role);
-
- int filterRole() const;
- void setFilterRole(int role);
-
-public Q_SLOTS:
- void setFilterRegExp(const QString &pattern);
- void setFilterWildcard(const QString &pattern);
- void setFilterFixedString(const QString &pattern);
- void clear();
- void invalidate();
-
-protected:
- virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
- virtual bool filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const;
- virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
-
- void filterChanged();
- void invalidateFilter();
-
-public:
-#ifdef Q_NO_USING_KEYWORD
- inline QObject *parent() const { return QObject::parent(); }
-#else
- using QObject::parent;
-#endif
-
- 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;
- bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
-
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
-
- QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
- bool setHeaderData(int section, Qt::Orientation orientation,
- const QVariant &value, int role = Qt::EditRole);
-
- QMimeData *mimeData(const QModelIndexList &indexes) const;
- bool dropMimeData(const QMimeData *data, Qt::DropAction action,
- int row, int column, const QModelIndex &parent);
-
- bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
- bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex());
- bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
- bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex());
-
- void fetchMore(const QModelIndex &parent);
- bool canFetchMore(const QModelIndex &parent) const;
- Qt::ItemFlags flags(const QModelIndex &index) const;
-
- QModelIndex buddy(const QModelIndex &index) const;
- QModelIndexList match(const QModelIndex &start, int role,
- const QVariant &value, int hits = 1,
- Qt::MatchFlags flags =
- Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const;
- QSize span(const QModelIndex &index) const;
- void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
-
- QStringList mimeTypes() const;
- Qt::DropActions supportedDropActions() const;
-private:
- Q_DECLARE_PRIVATE(QSortFilterProxyModel)
- Q_DISABLE_COPY(QSortFilterProxyModel)
-
- Q_PRIVATE_SLOT(d_func(), void _q_sourceDataChanged(const QModelIndex &source_top_left, const QModelIndex &source_bottom_right))
- Q_PRIVATE_SLOT(d_func(), void _q_sourceHeaderDataChanged(Qt::Orientation orientation, int start, int end))
- Q_PRIVATE_SLOT(d_func(), void _q_sourceAboutToBeReset())
- Q_PRIVATE_SLOT(d_func(), void _q_sourceReset())
- Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutAboutToBeChanged())
- Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutChanged())
- Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeInserted(const QModelIndex &source_parent, int start, int end))
- Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsInserted(const QModelIndex &source_parent, int start, int end))
- Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeRemoved(const QModelIndex &source_parent, int start, int end))
- Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsRemoved(const QModelIndex &source_parent, int start, int end))
- Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeInserted(const QModelIndex &source_parent, int start, int end))
- Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsInserted(const QModelIndex &source_parent, int start, int end))
- Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeRemoved(const QModelIndex &source_parent, int start, int end))
- Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsRemoved(const QModelIndex &source_parent, int start, int end))
- Q_PRIVATE_SLOT(d_func(), void _q_clearMapping())
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_SORTFILTERPROXYMODEL
-
-#endif // QSORTFILTERPROXYMODEL_H
diff --git a/src/gui/itemviews/qstandarditemmodel.h b/src/gui/itemviews/qstandarditemmodel.h
deleted file mode 100644
index 6cc0270dad..0000000000
--- a/src/gui/itemviews/qstandarditemmodel.h
+++ /dev/null
@@ -1,456 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSTANDARDITEMMODEL_H
-#define QSTANDARDITEMMODEL_H
-
-#include <QtCore/qabstractitemmodel.h>
-#include <QtGui/qbrush.h>
-#include <QtGui/qfont.h>
-#include <QtGui/qicon.h>
-#ifndef QT_NO_DATASTREAM
-#include <QtCore/qdatastream.h>
-#endif
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_STANDARDITEMMODEL
-
-template <class T> class QList;
-
-class QStandardItemModel;
-
-class QStandardItemPrivate;
-class Q_GUI_EXPORT QStandardItem
-{
-public:
- QStandardItem();
- QStandardItem(const QString &text);
- QStandardItem(const QIcon &icon, const QString &text);
- explicit QStandardItem(int rows, int columns = 1);
- virtual ~QStandardItem();
-
- virtual QVariant data(int role = Qt::UserRole + 1) const;
- virtual void setData(const QVariant &value, int role = Qt::UserRole + 1);
-
- inline QString text() const {
- return qvariant_cast<QString>(data(Qt::DisplayRole));
- }
- inline void setText(const QString &text);
-
- inline QIcon icon() const {
- return qvariant_cast<QIcon>(data(Qt::DecorationRole));
- }
- inline void setIcon(const QIcon &icon);
-
-#ifndef QT_NO_TOOLTIP
- inline QString toolTip() const {
- return qvariant_cast<QString>(data(Qt::ToolTipRole));
- }
- inline void setToolTip(const QString &toolTip);
-#endif
-
-#ifndef QT_NO_STATUSTIP
- inline QString statusTip() const {
- return qvariant_cast<QString>(data(Qt::StatusTipRole));
- }
- inline void setStatusTip(const QString &statusTip);
-#endif
-
-#ifndef QT_NO_WHATSTHIS
- inline QString whatsThis() const {
- return qvariant_cast<QString>(data(Qt::WhatsThisRole));
- }
- inline void setWhatsThis(const QString &whatsThis);
-#endif
-
- inline QSize sizeHint() const {
- return qvariant_cast<QSize>(data(Qt::SizeHintRole));
- }
- inline void setSizeHint(const QSize &sizeHint);
-
- inline QFont font() const {
- return qvariant_cast<QFont>(data(Qt::FontRole));
- }
- inline void setFont(const QFont &font);
-
- inline Qt::Alignment textAlignment() const {
- return Qt::Alignment(qvariant_cast<int>(data(Qt::TextAlignmentRole)));
- }
- inline void setTextAlignment(Qt::Alignment textAlignment);
-
- inline QBrush background() const {
- return qvariant_cast<QBrush>(data(Qt::BackgroundRole));
- }
- inline void setBackground(const QBrush &brush);
-
- inline QBrush foreground() const {
- return qvariant_cast<QBrush>(data(Qt::ForegroundRole));
- }
- inline void setForeground(const QBrush &brush);
-
- inline Qt::CheckState checkState() const {
- return Qt::CheckState(qvariant_cast<int>(data(Qt::CheckStateRole)));
- }
- inline void setCheckState(Qt::CheckState checkState);
-
- inline QString accessibleText() const {
- return qvariant_cast<QString>(data(Qt::AccessibleTextRole));
- }
- inline void setAccessibleText(const QString &accessibleText);
-
- inline QString accessibleDescription() const {
- return qvariant_cast<QString>(data(Qt::AccessibleDescriptionRole));
- }
- inline void setAccessibleDescription(const QString &accessibleDescription);
-
- Qt::ItemFlags flags() const;
- void setFlags(Qt::ItemFlags flags);
-
- inline bool isEnabled() const {
- return (flags() & Qt::ItemIsEnabled) != 0;
- }
- void setEnabled(bool enabled);
-
- inline bool isEditable() const {
- return (flags() & Qt::ItemIsEditable) != 0;
- }
- void setEditable(bool editable);
-
- inline bool isSelectable() const {
- return (flags() & Qt::ItemIsSelectable) != 0;
- }
- void setSelectable(bool selectable);
-
- inline bool isCheckable() const {
- return (flags() & Qt::ItemIsUserCheckable) != 0;
- }
- void setCheckable(bool checkable);
-
- inline bool isTristate() const {
- return (flags() & Qt::ItemIsTristate) != 0;
- }
- void setTristate(bool tristate);
-
-#ifndef QT_NO_DRAGANDDROP
- inline bool isDragEnabled() const {
- return (flags() & Qt::ItemIsDragEnabled) != 0;
- }
- void setDragEnabled(bool dragEnabled);
-
- inline bool isDropEnabled() const {
- return (flags() & Qt::ItemIsDropEnabled) != 0;
- }
- void setDropEnabled(bool dropEnabled);
-#endif // QT_NO_DRAGANDDROP
-
- QStandardItem *parent() const;
- int row() const;
- int column() const;
- QModelIndex index() const;
- QStandardItemModel *model() const;
-
- int rowCount() const;
- void setRowCount(int rows);
- int columnCount() const;
- void setColumnCount(int columns);
-
- bool hasChildren() const;
- QStandardItem *child(int row, int column = 0) const;
- void setChild(int row, int column, QStandardItem *item);
- inline void setChild(int row, QStandardItem *item);
-
- void insertRow(int row, const QList<QStandardItem*> &items);
- void insertColumn(int column, const QList<QStandardItem*> &items);
- void insertRows(int row, const QList<QStandardItem*> &items);
- void insertRows(int row, int count);
- void insertColumns(int column, int count);
-
- void removeRow(int row);
- void removeColumn(int column);
- void removeRows(int row, int count);
- void removeColumns(int column, int count);
-
- inline void appendRow(const QList<QStandardItem*> &items);
- inline void appendRows(const QList<QStandardItem*> &items);
- inline void appendColumn(const QList<QStandardItem*> &items);
- inline void insertRow(int row, QStandardItem *item);
- inline void appendRow(QStandardItem *item);
-
- QStandardItem *takeChild(int row, int column = 0);
- QList<QStandardItem*> takeRow(int row);
- QList<QStandardItem*> takeColumn(int column);
-
- void sortChildren(int column, Qt::SortOrder order = Qt::AscendingOrder);
-
- virtual QStandardItem *clone() const;
-
- enum ItemType { Type = 0, UserType = 1000 };
- virtual int type() const;
-
-#ifndef QT_NO_DATASTREAM
- virtual void read(QDataStream &in);
- virtual void write(QDataStream &out) const;
-#endif
- virtual bool operator<(const QStandardItem &other) const;
-
-protected:
- QStandardItem(const QStandardItem &other);
- QStandardItem(QStandardItemPrivate &dd);
- QStandardItem &operator=(const QStandardItem &other);
- QScopedPointer<QStandardItemPrivate> d_ptr;
-
- void emitDataChanged();
-
-private:
- Q_DECLARE_PRIVATE(QStandardItem)
- friend class QStandardItemModelPrivate;
- friend class QStandardItemModel;
-};
-
-inline void QStandardItem::setText(const QString &atext)
-{ setData(atext, Qt::DisplayRole); }
-
-inline void QStandardItem::setIcon(const QIcon &aicon)
-{ setData(aicon, Qt::DecorationRole); }
-
-#ifndef QT_NO_TOOLTIP
-inline void QStandardItem::setToolTip(const QString &atoolTip)
-{ setData(atoolTip, Qt::ToolTipRole); }
-#endif
-
-#ifndef QT_NO_STATUSTIP
-inline void QStandardItem::setStatusTip(const QString &astatusTip)
-{ setData(astatusTip, Qt::StatusTipRole); }
-#endif
-
-#ifndef QT_NO_WHATSTHIS
-inline void QStandardItem::setWhatsThis(const QString &awhatsThis)
-{ setData(awhatsThis, Qt::WhatsThisRole); }
-#endif
-
-inline void QStandardItem::setSizeHint(const QSize &asizeHint)
-{ setData(asizeHint, Qt::SizeHintRole); }
-
-inline void QStandardItem::setFont(const QFont &afont)
-{ setData(afont, Qt::FontRole); }
-
-inline void QStandardItem::setTextAlignment(Qt::Alignment atextAlignment)
-{ setData(int(atextAlignment), Qt::TextAlignmentRole); }
-
-inline void QStandardItem::setBackground(const QBrush &abrush)
-{ setData(abrush, Qt::BackgroundRole); }
-
-inline void QStandardItem::setForeground(const QBrush &abrush)
-{ setData(abrush, Qt::ForegroundRole); }
-
-inline void QStandardItem::setCheckState(Qt::CheckState acheckState)
-{ setData(acheckState, Qt::CheckStateRole); }
-
-inline void QStandardItem::setAccessibleText(const QString &aaccessibleText)
-{ setData(aaccessibleText, Qt::AccessibleTextRole); }
-
-inline void QStandardItem::setAccessibleDescription(const QString &aaccessibleDescription)
-{ setData(aaccessibleDescription, Qt::AccessibleDescriptionRole); }
-
-inline void QStandardItem::setChild(int arow, QStandardItem *aitem)
-{ setChild(arow, 0, aitem); }
-
-inline void QStandardItem::appendRow(const QList<QStandardItem*> &aitems)
-{ insertRow(rowCount(), aitems); }
-
-inline void QStandardItem::appendRows(const QList<QStandardItem*> &aitems)
-{ insertRows(rowCount(), aitems); }
-
-inline void QStandardItem::appendColumn(const QList<QStandardItem*> &aitems)
-{ insertColumn(columnCount(), aitems); }
-
-inline void QStandardItem::insertRow(int arow, QStandardItem *aitem)
-{ insertRow(arow, QList<QStandardItem*>() << aitem); }
-
-inline void QStandardItem::appendRow(QStandardItem *aitem)
-{ insertRow(rowCount(), aitem); }
-
-class QStandardItemModelPrivate;
-
-class Q_GUI_EXPORT QStandardItemModel : public QAbstractItemModel
-{
- Q_OBJECT
- Q_PROPERTY(int sortRole READ sortRole WRITE setSortRole)
-
-public:
- explicit QStandardItemModel(QObject *parent = 0);
- QStandardItemModel(int rows, int columns, QObject *parent = 0);
- ~QStandardItemModel();
-
- 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;
- bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
-
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
-
- QVariant headerData(int section, Qt::Orientation orientation,
- int role = Qt::DisplayRole) const;
- bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value,
- int role = Qt::EditRole);
-
- bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
- bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex());
- bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
- bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex());
-
- Qt::ItemFlags flags(const QModelIndex &index) const;
- Qt::DropActions supportedDropActions() const;
-
- QMap<int, QVariant> itemData(const QModelIndex &index) const;
- bool setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles);
-
- void clear();
-
-#ifdef Q_NO_USING_KEYWORD
- inline QObject *parent() const { return QObject::parent(); }
-#else
- using QObject::parent;
-#endif
-
- void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
-
- QStandardItem *itemFromIndex(const QModelIndex &index) const;
- QModelIndex indexFromItem(const QStandardItem *item) const;
-
- QStandardItem *item(int row, int column = 0) const;
- void setItem(int row, int column, QStandardItem *item);
- inline void setItem(int row, QStandardItem *item);
- QStandardItem *invisibleRootItem() const;
-
- QStandardItem *horizontalHeaderItem(int column) const;
- void setHorizontalHeaderItem(int column, QStandardItem *item);
- QStandardItem *verticalHeaderItem(int row) const;
- void setVerticalHeaderItem(int row, QStandardItem *item);
-
- void setHorizontalHeaderLabels(const QStringList &labels);
- void setVerticalHeaderLabels(const QStringList &labels);
-
- void setRowCount(int rows);
- void setColumnCount(int columns);
-
- void appendRow(const QList<QStandardItem*> &items);
- void appendColumn(const QList<QStandardItem*> &items);
- inline void appendRow(QStandardItem *item);
-
- void insertRow(int row, const QList<QStandardItem*> &items);
- void insertColumn(int column, const QList<QStandardItem*> &items);
- inline void insertRow(int row, QStandardItem *item);
-
- inline bool insertRow(int row, const QModelIndex &parent = QModelIndex());
- inline bool insertColumn(int column, const QModelIndex &parent = QModelIndex());
-
- QStandardItem *takeItem(int row, int column = 0);
- QList<QStandardItem*> takeRow(int row);
- QList<QStandardItem*> takeColumn(int column);
-
- QStandardItem *takeHorizontalHeaderItem(int column);
- QStandardItem *takeVerticalHeaderItem(int row);
-
- const QStandardItem *itemPrototype() const;
- void setItemPrototype(const QStandardItem *item);
-
- QList<QStandardItem*> findItems(const QString &text,
- Qt::MatchFlags flags = Qt::MatchExactly,
- int column = 0) const;
-
- int sortRole() const;
- void setSortRole(int role);
-
- QStringList mimeTypes() const;
- QMimeData *mimeData(const QModelIndexList &indexes) const;
- bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
-
-Q_SIGNALS:
- void itemChanged(QStandardItem *item);
-
-protected:
- QStandardItemModel(QStandardItemModelPrivate &dd, QObject *parent = 0);
-
-private:
- friend class QStandardItemPrivate;
- friend class QStandardItem;
- Q_DISABLE_COPY(QStandardItemModel)
- Q_DECLARE_PRIVATE(QStandardItemModel)
-
- Q_PRIVATE_SLOT(d_func(), void _q_emitItemChanged(const QModelIndex &topLeft,
- const QModelIndex &bottomRight))
-};
-
-inline void QStandardItemModel::setItem(int arow, QStandardItem *aitem)
-{ setItem(arow, 0, aitem); }
-
-inline void QStandardItemModel::appendRow(QStandardItem *aitem)
-{ appendRow(QList<QStandardItem*>() << aitem); }
-
-inline void QStandardItemModel::insertRow(int arow, QStandardItem *aitem)
-{ insertRow(arow, QList<QStandardItem*>() << aitem); }
-
-inline bool QStandardItemModel::insertRow(int arow, const QModelIndex &aparent)
-{ return QAbstractItemModel::insertRow(arow, aparent); }
-inline bool QStandardItemModel::insertColumn(int acolumn, const QModelIndex &aparent)
-{ return QAbstractItemModel::insertColumn(acolumn, aparent); }
-
-#ifndef QT_NO_DATASTREAM
-Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QStandardItem &item);
-Q_GUI_EXPORT QDataStream &operator<<(QDataStream &out, const QStandardItem &item);
-#endif
-
-#endif // QT_NO_STANDARDITEMMODEL
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif //QSTANDARDITEMMODEL_H
diff --git a/src/gui/itemviews/qstringlistmodel.h b/src/gui/itemviews/qstringlistmodel.h
deleted file mode 100644
index b9b284cfc5..0000000000
--- a/src/gui/itemviews/qstringlistmodel.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSTRINGLISTMODEL_H
-#define QSTRINGLISTMODEL_H
-
-#include <QtCore/qstringlist.h>
-#include <QtGui/qabstractitemview.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_STRINGLISTMODEL
-
-class Q_GUI_EXPORT QStringListModel : public QAbstractListModel
-{
- Q_OBJECT
-public:
- explicit QStringListModel(QObject *parent = 0);
- QStringListModel(const QStringList &strings, QObject *parent = 0);
-
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
-
- QVariant data(const QModelIndex &index, int role) const;
- bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
-
- Qt::ItemFlags flags(const QModelIndex &index) const;
-
- bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
- bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
-
- void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
-
- QStringList stringList() const;
- void setStringList(const QStringList &strings);
-
- Qt::DropActions supportedDropActions() const;
-
-private:
- Q_DISABLE_COPY(QStringListModel)
- QStringList lst;
-};
-
-#endif // QT_NO_STRINGLISTMODEL
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSTRINGLISTMODEL_H
diff --git a/src/gui/itemviews/qstyleditemdelegate.h b/src/gui/itemviews/qstyleditemdelegate.h
deleted file mode 100644
index 1c8299b07c..0000000000
--- a/src/gui/itemviews/qstyleditemdelegate.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSTYLEDITEMDELEGATE_H
-#define QSTYLEDITEMDELEGATE_H
-
-#include <QtGui/qabstractitemdelegate.h>
-#include <QtCore/qstring.h>
-#include <QtGui/qpixmap.h>
-#include <QtCore/qvariant.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_ITEMVIEWS
-
-class QStyledItemDelegatePrivate;
-class QItemEditorFactory;
-
-class Q_GUI_EXPORT QStyledItemDelegate : public QAbstractItemDelegate
-{
- Q_OBJECT
-
-public:
- explicit QStyledItemDelegate(QObject *parent = 0);
- ~QStyledItemDelegate();
-
- // painting
- void paint(QPainter *painter,
- const QStyleOptionViewItem &option, const QModelIndex &index) const;
- QSize sizeHint(const QStyleOptionViewItem &option,
- const QModelIndex &index) const;
-
- // editing
- 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;
-
- // editor factory
- QItemEditorFactory *itemEditorFactory() const;
- void setItemEditorFactory(QItemEditorFactory *factory);
-
- virtual QString displayText(const QVariant &value, const QLocale &locale) const;
-
-protected:
- virtual void initStyleOption(QStyleOptionViewItem *option,
- const QModelIndex &index) const;
-
- bool eventFilter(QObject *object, QEvent *event);
- bool editorEvent(QEvent *event, QAbstractItemModel *model,
- const QStyleOptionViewItem &option, const QModelIndex &index);
-
-private:
- Q_DECLARE_PRIVATE(QStyledItemDelegate)
- Q_DISABLE_COPY(QStyledItemDelegate)
-
- Q_PRIVATE_SLOT(d_func(), void _q_commitDataAndCloseEditor(QWidget*))
-};
-
-#endif // QT_NO_ITEMVIEWS
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSTYLEDITEMDELEGATE_H
diff --git a/src/gui/itemviews/qtableview.h b/src/gui/itemviews/qtableview.h
deleted file mode 100644
index 7ab9d0817c..0000000000
--- a/src/gui/itemviews/qtableview.h
+++ /dev/null
@@ -1,198 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTABLEVIEW_H
-#define QTABLEVIEW_H
-
-#include <QtGui/qabstractitemview.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_TABLEVIEW
-
-class QHeaderView;
-class QTableViewPrivate;
-
-class Q_GUI_EXPORT QTableView : public QAbstractItemView
-{
- Q_OBJECT
- Q_PROPERTY(bool showGrid READ showGrid WRITE setShowGrid)
- Q_PROPERTY(Qt::PenStyle gridStyle READ gridStyle WRITE setGridStyle)
- Q_PROPERTY(bool sortingEnabled READ isSortingEnabled WRITE setSortingEnabled)
- Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
- Q_PROPERTY(bool cornerButtonEnabled READ isCornerButtonEnabled WRITE setCornerButtonEnabled)
-
-public:
- explicit QTableView(QWidget *parent = 0);
- ~QTableView();
-
- void setModel(QAbstractItemModel *model);
- void setRootIndex(const QModelIndex &index);
- void setSelectionModel(QItemSelectionModel *selectionModel);
- void doItemsLayout();
-
- QHeaderView *horizontalHeader() const;
- QHeaderView *verticalHeader() const;
- void setHorizontalHeader(QHeaderView *header);
- void setVerticalHeader(QHeaderView *header);
-
- int rowViewportPosition(int row) const;
- int rowAt(int y) const;
-
- void setRowHeight(int row, int height);
- int rowHeight(int row) const;
-
- int columnViewportPosition(int column) const;
- int columnAt(int x) const;
-
- void setColumnWidth(int column, int width);
- int columnWidth(int column) const;
-
- bool isRowHidden(int row) const;
- void setRowHidden(int row, bool hide);
-
- bool isColumnHidden(int column) const;
- void setColumnHidden(int column, bool hide);
-
- void setSortingEnabled(bool enable);
- bool isSortingEnabled() const;
-
- bool showGrid() const;
-
- Qt::PenStyle gridStyle() const;
- void setGridStyle(Qt::PenStyle style);
-
- void setWordWrap(bool on);
- bool wordWrap() const;
-
- void setCornerButtonEnabled(bool enable);
- bool isCornerButtonEnabled() const;
-
- QRect visualRect(const QModelIndex &index) const;
- void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible);
- QModelIndex indexAt(const QPoint &p) const;
-
- void setSpan(int row, int column, int rowSpan, int columnSpan);
- int rowSpan(int row, int column) const;
- int columnSpan(int row, int column) const;
- void clearSpans();
-
- void sortByColumn(int column, Qt::SortOrder order);
-
-public Q_SLOTS:
- void selectRow(int row);
- void selectColumn(int column);
- void hideRow(int row);
- void hideColumn(int column);
- void showRow(int row);
- void showColumn(int column);
- void resizeRowToContents(int row);
- void resizeRowsToContents();
- void resizeColumnToContents(int column);
- void resizeColumnsToContents();
- void sortByColumn(int column);
- void setShowGrid(bool show);
-
-protected Q_SLOTS:
- void rowMoved(int row, int oldIndex, int newIndex);
- void columnMoved(int column, int oldIndex, int newIndex);
- void rowResized(int row, int oldHeight, int newHeight);
- void columnResized(int column, int oldWidth, int newWidth);
- void rowCountChanged(int oldCount, int newCount);
- void columnCountChanged(int oldCount, int newCount);
-
-protected:
- QTableView(QTableViewPrivate &, QWidget *parent);
- void scrollContentsBy(int dx, int dy);
-
- QStyleOptionViewItem viewOptions() const;
- void paintEvent(QPaintEvent *e);
-
- void timerEvent(QTimerEvent *event);
-
- int horizontalOffset() const;
- int verticalOffset() const;
- QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
-
- void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command);
- QRegion visualRegionForSelection(const QItemSelection &selection) const;
- QModelIndexList selectedIndexes() const;
-
- void updateGeometries();
-
- int sizeHintForRow(int row) const;
- int sizeHintForColumn(int column) const;
-
- void verticalScrollbarAction(int action);
- void horizontalScrollbarAction(int action);
-
- bool isIndexHidden(const QModelIndex &index) const;
-
- void selectionChanged(const QItemSelection &selected,
- const QItemSelection &deselected);
- void currentChanged(const QModelIndex &current,
- const QModelIndex &previous);
-
-private:
- friend class QAccessibleItemView;
- int visualIndex(const QModelIndex &index) const;
-
- Q_DECLARE_PRIVATE(QTableView)
- Q_DISABLE_COPY(QTableView)
- Q_PRIVATE_SLOT(d_func(), void _q_selectRow(int))
- Q_PRIVATE_SLOT(d_func(), void _q_selectColumn(int))
- Q_PRIVATE_SLOT(d_func(), void _q_updateSpanInsertedRows(QModelIndex,int,int))
- Q_PRIVATE_SLOT(d_func(), void _q_updateSpanInsertedColumns(QModelIndex,int,int))
- Q_PRIVATE_SLOT(d_func(), void _q_updateSpanRemovedRows(QModelIndex,int,int))
- Q_PRIVATE_SLOT(d_func(), void _q_updateSpanRemovedColumns(QModelIndex,int,int))
-};
-
-#endif // QT_NO_TABLEVIEW
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QTABLEVIEW_H
diff --git a/src/gui/itemviews/qtablewidget.h b/src/gui/itemviews/qtablewidget.h
deleted file mode 100644
index 35e3b29628..0000000000
--- a/src/gui/itemviews/qtablewidget.h
+++ /dev/null
@@ -1,377 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTABLEWIDGET_H
-#define QTABLEWIDGET_H
-
-#include <QtGui/qtableview.h>
-#include <QtCore/qvariant.h>
-#include <QtCore/qvector.h>
-//#include <QtGui/qitemselectionmodel.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_TABLEWIDGET
-
-class Q_GUI_EXPORT QTableWidgetSelectionRange
-{
-public:
- QTableWidgetSelectionRange();
- QTableWidgetSelectionRange(int top, int left, int bottom, int right);
- QTableWidgetSelectionRange(const QTableWidgetSelectionRange &other);
- ~QTableWidgetSelectionRange();
-
- inline int topRow() const { return top; }
- inline int bottomRow() const { return bottom; }
- inline int leftColumn() const { return left; }
- inline int rightColumn() const { return right; }
- inline int rowCount() const { return bottom - top + 1; }
- inline int columnCount() const { return right - left + 1; }
-
-private:
- int top, left, bottom, right;
-};
-
-class QTableWidget;
-class QTableModel;
-class QWidgetItemData;
-class QTableWidgetItemPrivate;
-
-class Q_GUI_EXPORT QTableWidgetItem
-{
- friend class QTableWidget;
- friend class QTableModel;
-public:
- enum ItemType { Type = 0, UserType = 1000 };
- QTableWidgetItem(int type = Type);
- explicit QTableWidgetItem(const QString &text, int type = Type);
- explicit QTableWidgetItem(const QIcon &icon, const QString &text, int type = Type);
- QTableWidgetItem(const QTableWidgetItem &other);
- virtual ~QTableWidgetItem();
-
- virtual QTableWidgetItem *clone() const;
-
- inline QTableWidget *tableWidget() const { return view; }
-
- inline int row() const;
- inline int column() const;
-
- inline void setSelected(bool select);
- inline bool isSelected() const;
-
- inline Qt::ItemFlags flags() const { return itemFlags; }
- void setFlags(Qt::ItemFlags flags);
-
- inline QString text() const
- { return data(Qt::DisplayRole).toString(); }
- inline void setText(const QString &text);
-
- inline QIcon icon() const
- { return qvariant_cast<QIcon>(data(Qt::DecorationRole)); }
- inline void setIcon(const QIcon &icon);
-
- inline QString statusTip() const
- { return data(Qt::StatusTipRole).toString(); }
- inline void setStatusTip(const QString &statusTip);
-
-#ifndef QT_NO_TOOLTIP
- inline QString toolTip() const
- { return data(Qt::ToolTipRole).toString(); }
- inline void setToolTip(const QString &toolTip);
-#endif
-
-#ifndef QT_NO_WHATSTHIS
- inline QString whatsThis() const
- { return data(Qt::WhatsThisRole).toString(); }
- inline void setWhatsThis(const QString &whatsThis);
-#endif
-
- inline QFont font() const
- { return qvariant_cast<QFont>(data(Qt::FontRole)); }
- inline void setFont(const QFont &font);
-
- inline int textAlignment() const
- { return data(Qt::TextAlignmentRole).toInt(); }
- inline void setTextAlignment(int alignment)
- { setData(Qt::TextAlignmentRole, alignment); }
-
- inline QColor backgroundColor() const
- { return qvariant_cast<QColor>(data(Qt::BackgroundColorRole)); }
- inline void setBackgroundColor(const QColor &color)
- { setData(Qt::BackgroundColorRole, color); }
-
- inline QBrush background() const
- { return qvariant_cast<QBrush>(data(Qt::BackgroundRole)); }
- inline void setBackground(const QBrush &brush)
- { setData(Qt::BackgroundRole, brush); }
-
- inline QColor textColor() const
- { return qvariant_cast<QColor>(data(Qt::TextColorRole)); }
- inline void setTextColor(const QColor &color)
- { setData(Qt::TextColorRole, color); }
-
- inline QBrush foreground() const
- { return qvariant_cast<QBrush>(data(Qt::ForegroundRole)); }
- inline void setForeground(const QBrush &brush)
- { setData(Qt::ForegroundRole, brush); }
-
- inline Qt::CheckState checkState() const
- { return static_cast<Qt::CheckState>(data(Qt::CheckStateRole).toInt()); }
- inline void setCheckState(Qt::CheckState state)
- { setData(Qt::CheckStateRole, state); }
-
- inline QSize sizeHint() const
- { return qvariant_cast<QSize>(data(Qt::SizeHintRole)); }
- inline void setSizeHint(const QSize &size)
- { setData(Qt::SizeHintRole, size); }
-
- virtual QVariant data(int role) const;
- virtual void setData(int role, const QVariant &value);
-
- virtual bool operator<(const QTableWidgetItem &other) const;
-
-#ifndef QT_NO_DATASTREAM
- virtual void read(QDataStream &in);
- virtual void write(QDataStream &out) const;
-#endif
- QTableWidgetItem &operator=(const QTableWidgetItem &other);
-
- inline int type() const { return rtti; }
-
-private:
- int rtti;
- QVector<QWidgetItemData> values;
- QTableWidget *view;
- QTableWidgetItemPrivate *d;
- Qt::ItemFlags itemFlags;
-};
-
-inline void QTableWidgetItem::setText(const QString &atext)
-{ setData(Qt::DisplayRole, atext); }
-
-inline void QTableWidgetItem::setIcon(const QIcon &aicon)
-{ setData(Qt::DecorationRole, aicon); }
-
-inline void QTableWidgetItem::setStatusTip(const QString &astatusTip)
-{ setData(Qt::StatusTipRole, astatusTip); }
-
-#ifndef QT_NO_TOOLTIP
-inline void QTableWidgetItem::setToolTip(const QString &atoolTip)
-{ setData(Qt::ToolTipRole, atoolTip); }
-#endif
-
-#ifndef QT_NO_WHATSTHIS
-inline void QTableWidgetItem::setWhatsThis(const QString &awhatsThis)
-{ setData(Qt::WhatsThisRole, awhatsThis); }
-#endif
-
-inline void QTableWidgetItem::setFont(const QFont &afont)
-{ setData(Qt::FontRole, afont); }
-
-#ifndef QT_NO_DATASTREAM
-Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QTableWidgetItem &item);
-Q_GUI_EXPORT QDataStream &operator<<(QDataStream &out, const QTableWidgetItem &item);
-#endif
-
-class QTableWidgetPrivate;
-
-class Q_GUI_EXPORT QTableWidget : public QTableView
-{
- Q_OBJECT
- Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount)
- Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount)
-
- friend class QTableModel;
-public:
- explicit QTableWidget(QWidget *parent = 0);
- QTableWidget(int rows, int columns, QWidget *parent = 0);
- ~QTableWidget();
-
- void setRowCount(int rows);
- int rowCount() const;
-
- void setColumnCount(int columns);
- int columnCount() const;
-
- int row(const QTableWidgetItem *item) const;
- int column(const QTableWidgetItem *item) const;
-
- QTableWidgetItem *item(int row, int column) const;
- void setItem(int row, int column, QTableWidgetItem *item);
- QTableWidgetItem *takeItem(int row, int column);
-
- QTableWidgetItem *verticalHeaderItem(int row) const;
- void setVerticalHeaderItem(int row, QTableWidgetItem *item);
- QTableWidgetItem *takeVerticalHeaderItem(int row);
-
- QTableWidgetItem *horizontalHeaderItem(int column) const;
- void setHorizontalHeaderItem(int column, QTableWidgetItem *item);
- QTableWidgetItem *takeHorizontalHeaderItem(int column);
- void setVerticalHeaderLabels(const QStringList &labels);
- void setHorizontalHeaderLabels(const QStringList &labels);
-
- int currentRow() const;
- int currentColumn() const;
- QTableWidgetItem *currentItem() const;
- void setCurrentItem(QTableWidgetItem *item);
- void setCurrentItem(QTableWidgetItem *item, QItemSelectionModel::SelectionFlags command);
- void setCurrentCell(int row, int column);
- void setCurrentCell(int row, int column, QItemSelectionModel::SelectionFlags command);
-
- void sortItems(int column, Qt::SortOrder order = Qt::AscendingOrder);
- void setSortingEnabled(bool enable);
- bool isSortingEnabled() const;
-
- void editItem(QTableWidgetItem *item);
- void openPersistentEditor(QTableWidgetItem *item);
- void closePersistentEditor(QTableWidgetItem *item);
-
- QWidget *cellWidget(int row, int column) const;
- void setCellWidget(int row, int column, QWidget *widget);
- inline void removeCellWidget(int row, int column);
-
- bool isItemSelected(const QTableWidgetItem *item) const;
- void setItemSelected(const QTableWidgetItem *item, bool select);
- void setRangeSelected(const QTableWidgetSelectionRange &range, bool select);
-
- QList<QTableWidgetSelectionRange> selectedRanges() const;
- QList<QTableWidgetItem*> selectedItems();
- QList<QTableWidgetItem*> findItems(const QString &text, Qt::MatchFlags flags) const;
-
- int visualRow(int logicalRow) const;
- int visualColumn(int logicalColumn) const;
-
- QTableWidgetItem *itemAt(const QPoint &p) const;
- inline QTableWidgetItem *itemAt(int x, int y) const;
- QRect visualItemRect(const QTableWidgetItem *item) const;
-
- const QTableWidgetItem *itemPrototype() const;
- void setItemPrototype(const QTableWidgetItem *item);
-
-public Q_SLOTS:
- void scrollToItem(const QTableWidgetItem *item, QAbstractItemView::ScrollHint hint = EnsureVisible);
- void insertRow(int row);
- void insertColumn(int column);
- void removeRow(int row);
- void removeColumn(int column);
- void clear();
- void clearContents();
-
-Q_SIGNALS:
- void itemPressed(QTableWidgetItem *item);
- void itemClicked(QTableWidgetItem *item);
- void itemDoubleClicked(QTableWidgetItem *item);
-
- void itemActivated(QTableWidgetItem *item);
- void itemEntered(QTableWidgetItem *item);
- void itemChanged(QTableWidgetItem *item);
-
- void currentItemChanged(QTableWidgetItem *current, QTableWidgetItem *previous);
- void itemSelectionChanged();
-
- void cellPressed(int row, int column);
- void cellClicked(int row, int column);
- void cellDoubleClicked(int row, int column);
-
- void cellActivated(int row, int column);
- void cellEntered(int row, int column);
- void cellChanged(int row, int column);
-
- void currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn);
-
-protected:
- bool event(QEvent *e);
- virtual QStringList mimeTypes() const;
- virtual QMimeData *mimeData(const QList<QTableWidgetItem*> items) const;
- virtual bool dropMimeData(int row, int column, const QMimeData *data, Qt::DropAction action);
- virtual Qt::DropActions supportedDropActions() const;
- QList<QTableWidgetItem*> items(const QMimeData *data) const;
-
- QModelIndex indexFromItem(QTableWidgetItem *item) const;
- QTableWidgetItem *itemFromIndex(const QModelIndex &index) const;
- void dropEvent(QDropEvent *event);
-
-private:
- void setModel(QAbstractItemModel *model);
-
- Q_DECLARE_PRIVATE(QTableWidget)
- Q_DISABLE_COPY(QTableWidget)
-
- Q_PRIVATE_SLOT(d_func(), void _q_emitItemPressed(const QModelIndex &index))
- Q_PRIVATE_SLOT(d_func(), void _q_emitItemClicked(const QModelIndex &index))
- Q_PRIVATE_SLOT(d_func(), void _q_emitItemDoubleClicked(const QModelIndex &index))
- Q_PRIVATE_SLOT(d_func(), void _q_emitItemActivated(const QModelIndex &index))
- Q_PRIVATE_SLOT(d_func(), void _q_emitItemEntered(const QModelIndex &index))
- Q_PRIVATE_SLOT(d_func(), void _q_emitItemChanged(const QModelIndex &index))
- Q_PRIVATE_SLOT(d_func(), void _q_emitCurrentItemChanged(const QModelIndex &previous, const QModelIndex &current))
- Q_PRIVATE_SLOT(d_func(), void _q_sort())
- Q_PRIVATE_SLOT(d_func(), void _q_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight))
-};
-
-inline void QTableWidget::removeCellWidget(int arow, int acolumn)
-{ setCellWidget(arow, acolumn, 0); }
-
-inline QTableWidgetItem *QTableWidget::itemAt(int ax, int ay) const
-{ return itemAt(QPoint(ax, ay)); }
-
-inline int QTableWidgetItem::row() const
-{ return (view ? view->row(this) : -1); }
-
-inline int QTableWidgetItem::column() const
-{ return (view ? view->column(this) : -1); }
-
-inline void QTableWidgetItem::setSelected(bool aselect)
-{ if (view) view->setItemSelected(this, aselect); }
-
-inline bool QTableWidgetItem::isSelected() const
-{ return (view ? view->isItemSelected(this) : false); }
-
-#endif // QT_NO_TABLEWIDGET
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QTABLEWIDGET_H
diff --git a/src/gui/itemviews/qtreeview.h b/src/gui/itemviews/qtreeview.h
deleted file mode 100644
index 49b8419389..0000000000
--- a/src/gui/itemviews/qtreeview.h
+++ /dev/null
@@ -1,239 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTREEVIEW_H
-#define QTREEVIEW_H
-
-#include <QtGui/qabstractitemview.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_TREEVIEW
-
-class QTreeViewPrivate;
-class QHeaderView;
-
-class Q_GUI_EXPORT QTreeView : public QAbstractItemView
-{
- Q_OBJECT
- Q_PROPERTY(int autoExpandDelay READ autoExpandDelay WRITE setAutoExpandDelay)
- Q_PROPERTY(int indentation READ indentation WRITE setIndentation)
- Q_PROPERTY(bool rootIsDecorated READ rootIsDecorated WRITE setRootIsDecorated)
- Q_PROPERTY(bool uniformRowHeights READ uniformRowHeights WRITE setUniformRowHeights)
- Q_PROPERTY(bool itemsExpandable READ itemsExpandable WRITE setItemsExpandable)
- Q_PROPERTY(bool sortingEnabled READ isSortingEnabled WRITE setSortingEnabled)
- Q_PROPERTY(bool animated READ isAnimated WRITE setAnimated)
- Q_PROPERTY(bool allColumnsShowFocus READ allColumnsShowFocus WRITE setAllColumnsShowFocus)
- Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
- Q_PROPERTY(bool headerHidden READ isHeaderHidden WRITE setHeaderHidden)
- Q_PROPERTY(bool expandsOnDoubleClick READ expandsOnDoubleClick WRITE setExpandsOnDoubleClick)
-
-public:
- explicit QTreeView(QWidget *parent = 0);
- ~QTreeView();
-
- void setModel(QAbstractItemModel *model);
- void setRootIndex(const QModelIndex &index);
- void setSelectionModel(QItemSelectionModel *selectionModel);
-
- QHeaderView *header() const;
- void setHeader(QHeaderView *header);
-
- int autoExpandDelay() const;
- void setAutoExpandDelay(int delay);
-
- int indentation() const;
- void setIndentation(int i);
-
- bool rootIsDecorated() const;
- void setRootIsDecorated(bool show);
-
- bool uniformRowHeights() const;
- void setUniformRowHeights(bool uniform);
-
- bool itemsExpandable() const;
- void setItemsExpandable(bool enable);
-
- bool expandsOnDoubleClick() const;
- void setExpandsOnDoubleClick(bool enable);
-
- int columnViewportPosition(int column) const;
- int columnWidth(int column) const;
- void setColumnWidth(int column, int width);
- int columnAt(int x) const;
-
- bool isColumnHidden(int column) const;
- void setColumnHidden(int column, bool hide);
-
- bool isHeaderHidden() const;
- void setHeaderHidden(bool hide);
-
- bool isRowHidden(int row, const QModelIndex &parent) const;
- void setRowHidden(int row, const QModelIndex &parent, bool hide);
-
- bool isFirstColumnSpanned(int row, const QModelIndex &parent) const;
- void setFirstColumnSpanned(int row, const QModelIndex &parent, bool span);
-
- bool isExpanded(const QModelIndex &index) const;
- void setExpanded(const QModelIndex &index, bool expand);
-
- void setSortingEnabled(bool enable);
- bool isSortingEnabled() const;
-
- void setAnimated(bool enable);
- bool isAnimated() const;
-
- void setAllColumnsShowFocus(bool enable);
- bool allColumnsShowFocus() const;
-
- void setWordWrap(bool on);
- bool wordWrap() const;
-
- void keyboardSearch(const QString &search);
-
- QRect visualRect(const QModelIndex &index) const;
- void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible);
- QModelIndex indexAt(const QPoint &p) const;
- QModelIndex indexAbove(const QModelIndex &index) const;
- QModelIndex indexBelow(const QModelIndex &index) const;
-
- void doItemsLayout();
- void reset();
-
- void sortByColumn(int column, Qt::SortOrder order);
-
- void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
- void selectAll();
-
-Q_SIGNALS:
- void expanded(const QModelIndex &index);
- void collapsed(const QModelIndex &index);
-
-public Q_SLOTS:
- void hideColumn(int column);
- void showColumn(int column);
- void expand(const QModelIndex &index);
- void collapse(const QModelIndex &index);
- void resizeColumnToContents(int column);
- void sortByColumn(int column);
- void expandAll();
- void collapseAll();
- void expandToDepth(int depth);
-
-protected Q_SLOTS:
- void columnResized(int column, int oldSize, int newSize);
- void columnCountChanged(int oldCount, int newCount);
- void columnMoved();
- void reexpand();
- void rowsRemoved(const QModelIndex &parent, int first, int last);
-
-protected:
- QTreeView(QTreeViewPrivate &dd, QWidget *parent = 0);
- void scrollContentsBy(int dx, int dy);
- void rowsInserted(const QModelIndex &parent, int start, int end);
- void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
-
- QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
- int horizontalOffset() const;
- int verticalOffset() const;
-
- void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command);
- QRegion visualRegionForSelection(const QItemSelection &selection) const;
- QModelIndexList selectedIndexes() const;
-
- void timerEvent(QTimerEvent *event);
- void paintEvent(QPaintEvent *event);
-
- void drawTree(QPainter *painter, const QRegion &region) const;
- virtual void drawRow(QPainter *painter,
- const QStyleOptionViewItem &options,
- const QModelIndex &index) const;
- virtual void drawBranches(QPainter *painter,
- const QRect &rect,
- const QModelIndex &index) const;
-
- void mousePressEvent(QMouseEvent *event);
- void mouseReleaseEvent(QMouseEvent *event);
- void mouseDoubleClickEvent(QMouseEvent *event);
- void mouseMoveEvent(QMouseEvent *event);
- void keyPressEvent(QKeyEvent *event);
-#ifndef QT_NO_DRAGANDDROP
- void dragMoveEvent(QDragMoveEvent *event);
-#endif
- bool viewportEvent(QEvent *event);
-
- void updateGeometries();
-
- int sizeHintForColumn(int column) const;
- int indexRowSizeHint(const QModelIndex &index) const;
- int rowHeight(const QModelIndex &index) const;
-
- void horizontalScrollbarAction(int action);
-
- bool isIndexHidden(const QModelIndex &index) const;
- void selectionChanged(const QItemSelection &selected,
- const QItemSelection &deselected);
- void currentChanged(const QModelIndex &current, const QModelIndex &previous);
-
-private:
- friend class QAccessibleItemView;
- int visualIndex(const QModelIndex &index) const;
-
- Q_DECLARE_PRIVATE(QTreeView)
- Q_DISABLE_COPY(QTreeView)
-#ifndef QT_NO_ANIMATION
- Q_PRIVATE_SLOT(d_func(), void _q_endAnimatedOperation())
-#endif //QT_NO_ANIMATION
- Q_PRIVATE_SLOT(d_func(), void _q_modelAboutToBeReset())
- Q_PRIVATE_SLOT(d_func(), void _q_sortIndicatorChanged(int column, Qt::SortOrder order))
-};
-
-#endif // QT_NO_TREEVIEW
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QTREEVIEW_H
diff --git a/src/gui/itemviews/qtreewidget.h b/src/gui/itemviews/qtreewidget.h
deleted file mode 100644
index 59532dd594..0000000000
--- a/src/gui/itemviews/qtreewidget.h
+++ /dev/null
@@ -1,432 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTREEWIDGET_H
-#define QTREEWIDGET_H
-
-#include <QtGui/qtreeview.h>
-#include <QtGui/qtreewidgetitemiterator.h>
-#include <QtCore/qvariant.h>
-#include <QtCore/qvector.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_TREEWIDGET
-
-class QTreeWidget;
-class QTreeModel;
-class QWidgetItemData;
-class QTreeWidgetItemPrivate;
-
-class Q_GUI_EXPORT QTreeWidgetItem
-{
- friend class QTreeModel;
- friend class QTreeWidget;
- friend class QTreeWidgetPrivate;
- friend class QTreeWidgetItemIterator;
- friend class QTreeWidgetItemPrivate;
-public:
- enum ItemType { Type = 0, UserType = 1000 };
- explicit QTreeWidgetItem(int type = Type);
- QTreeWidgetItem(const QStringList &strings, int type = Type);
- explicit QTreeWidgetItem(QTreeWidget *view, int type = Type);
- QTreeWidgetItem(QTreeWidget *view, const QStringList &strings, int type = Type);
- QTreeWidgetItem(QTreeWidget *view, QTreeWidgetItem *after, int type = Type);
- explicit QTreeWidgetItem(QTreeWidgetItem *parent, int type = Type);
- QTreeWidgetItem(QTreeWidgetItem *parent, const QStringList &strings, int type = Type);
- QTreeWidgetItem(QTreeWidgetItem *parent, QTreeWidgetItem *after, int type = Type);
- QTreeWidgetItem(const QTreeWidgetItem &other);
- virtual ~QTreeWidgetItem();
-
- virtual QTreeWidgetItem *clone() const;
-
- inline QTreeWidget *treeWidget() const { return view; }
-
- inline void setSelected(bool select);
- inline bool isSelected() const;
-
- inline void setHidden(bool hide);
- inline bool isHidden() const;
-
- inline void setExpanded(bool expand);
- inline bool isExpanded() const;
-
- inline void setFirstColumnSpanned(bool span);
- inline bool isFirstColumnSpanned() const;
-
- inline void setDisabled(bool disabled);
- inline bool isDisabled() const;
-
- enum ChildIndicatorPolicy { ShowIndicator, DontShowIndicator, DontShowIndicatorWhenChildless };
- void setChildIndicatorPolicy(QTreeWidgetItem::ChildIndicatorPolicy policy);
- QTreeWidgetItem::ChildIndicatorPolicy childIndicatorPolicy() const;
-
- Qt::ItemFlags flags() const;
- void setFlags(Qt::ItemFlags flags);
-
- inline QString text(int column) const
- { return data(column, Qt::DisplayRole).toString(); }
- inline void setText(int column, const QString &text);
-
- inline QIcon icon(int column) const
- { return qvariant_cast<QIcon>(data(column, Qt::DecorationRole)); }
- inline void setIcon(int column, const QIcon &icon);
-
- inline QString statusTip(int column) const
- { return data(column, Qt::StatusTipRole).toString(); }
- inline void setStatusTip(int column, const QString &statusTip);
-
-#ifndef QT_NO_TOOLTIP
- inline QString toolTip(int column) const
- { return data(column, Qt::ToolTipRole).toString(); }
- inline void setToolTip(int column, const QString &toolTip);
-#endif
-
-#ifndef QT_NO_WHATSTHIS
- inline QString whatsThis(int column) const
- { return data(column, Qt::WhatsThisRole).toString(); }
- inline void setWhatsThis(int column, const QString &whatsThis);
-#endif
-
- inline QFont font(int column) const
- { return qvariant_cast<QFont>(data(column, Qt::FontRole)); }
- inline void setFont(int column, const QFont &font);
-
- inline int textAlignment(int column) const
- { return data(column, Qt::TextAlignmentRole).toInt(); }
- inline void setTextAlignment(int column, int alignment)
- { setData(column, Qt::TextAlignmentRole, alignment); }
-
- inline QColor backgroundColor(int column) const
- { return qvariant_cast<QColor>(data(column, Qt::BackgroundColorRole)); }
- inline void setBackgroundColor(int column, const QColor &color)
- { setData(column, Qt::BackgroundColorRole, color); }
-
- inline QBrush background(int column) const
- { return qvariant_cast<QBrush>(data(column, Qt::BackgroundRole)); }
- inline void setBackground(int column, const QBrush &brush)
- { setData(column, Qt::BackgroundRole, brush); }
-
- inline QColor textColor(int column) const
- { return qvariant_cast<QColor>(data(column, Qt::TextColorRole)); }
- inline void setTextColor(int column, const QColor &color)
- { setData(column, Qt::TextColorRole, color); }
-
- inline QBrush foreground(int column) const
- { return qvariant_cast<QBrush>(data(column, Qt::ForegroundRole)); }
- inline void setForeground(int column, const QBrush &brush)
- { setData(column, Qt::ForegroundRole, brush); }
-
- inline Qt::CheckState checkState(int column) const
- { return static_cast<Qt::CheckState>(data(column, Qt::CheckStateRole).toInt()); }
- inline void setCheckState(int column, Qt::CheckState state)
- { setData(column, Qt::CheckStateRole, state); }
-
- inline QSize sizeHint(int column) const
- { return qvariant_cast<QSize>(data(column, Qt::SizeHintRole)); }
- inline void setSizeHint(int column, const QSize &size)
- { setData(column, Qt::SizeHintRole, size); }
-
- virtual QVariant data(int column, int role) const;
- virtual void setData(int column, int role, const QVariant &value);
-
- virtual bool operator<(const QTreeWidgetItem &other) const;
-
-#ifndef QT_NO_DATASTREAM
- virtual void read(QDataStream &in);
- virtual void write(QDataStream &out) const;
-#endif
- QTreeWidgetItem &operator=(const QTreeWidgetItem &other);
-
- inline QTreeWidgetItem *parent() const { return par; }
- inline QTreeWidgetItem *child(int index) const {
- if (index < 0 || index >= children.size())
- return 0;
- executePendingSort();
- return children.at(index);
- }
- inline int childCount() const { return children.count(); }
- inline int columnCount() const { return values.count(); }
- inline int indexOfChild(QTreeWidgetItem *child) const;
-
- void addChild(QTreeWidgetItem *child);
- void insertChild(int index, QTreeWidgetItem *child);
- void removeChild(QTreeWidgetItem *child);
- QTreeWidgetItem *takeChild(int index);
-
- void addChildren(const QList<QTreeWidgetItem*> &children);
- void insertChildren(int index, const QList<QTreeWidgetItem*> &children);
- QList<QTreeWidgetItem*> takeChildren();
-
- inline int type() const { return rtti; }
- inline void sortChildren(int column, Qt::SortOrder order)
- { sortChildren(column, order, false); }
-
-protected:
- void emitDataChanged();
-
-private:
- void sortChildren(int column, Qt::SortOrder order, bool climb);
- QVariant childrenCheckState(int column) const;
- void itemChanged();
- void executePendingSort() const;
-
- int rtti;
- // One item has a vector of column entries. Each column has a vector of (role, value) pairs.
- QVector< QVector<QWidgetItemData> > values;
- QTreeWidget *view;
- QTreeWidgetItemPrivate *d;
- QTreeWidgetItem *par;
- QList<QTreeWidgetItem*> children;
- Qt::ItemFlags itemFlags;
-};
-
-inline void QTreeWidgetItem::setText(int column, const QString &atext)
-{ setData(column, Qt::DisplayRole, atext); }
-
-inline void QTreeWidgetItem::setIcon(int column, const QIcon &aicon)
-{ setData(column, Qt::DecorationRole, aicon); }
-
-#ifndef QT_NO_STATUSTIP
-inline void QTreeWidgetItem::setStatusTip(int column, const QString &astatusTip)
-{ setData(column, Qt::StatusTipRole, astatusTip); }
-#endif
-
-#ifndef QT_NO_TOOLTIP
-inline void QTreeWidgetItem::setToolTip(int column, const QString &atoolTip)
-{ setData(column, Qt::ToolTipRole, atoolTip); }
-#endif
-
-#ifndef QT_NO_WHATSTHIS
-inline void QTreeWidgetItem::setWhatsThis(int column, const QString &awhatsThis)
-{ setData(column, Qt::WhatsThisRole, awhatsThis); }
-#endif
-
-inline void QTreeWidgetItem::setFont(int column, const QFont &afont)
-{ setData(column, Qt::FontRole, afont); }
-
-inline int QTreeWidgetItem::indexOfChild(QTreeWidgetItem *achild) const
-{ executePendingSort(); return children.indexOf(achild); }
-
-#ifndef QT_NO_DATASTREAM
-Q_GUI_EXPORT QDataStream &operator<<(QDataStream &out, const QTreeWidgetItem &item);
-Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QTreeWidgetItem &item);
-#endif
-
-class QTreeWidgetPrivate;
-
-class Q_GUI_EXPORT QTreeWidget : public QTreeView
-{
- Q_OBJECT
- Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount)
- Q_PROPERTY(int topLevelItemCount READ topLevelItemCount)
-
- friend class QTreeModel;
- friend class QTreeWidgetItem;
-public:
- explicit QTreeWidget(QWidget *parent = 0);
- ~QTreeWidget();
-
- int columnCount() const;
- void setColumnCount(int columns);
-
- QTreeWidgetItem *invisibleRootItem() const;
- QTreeWidgetItem *topLevelItem(int index) const;
- int topLevelItemCount() const;
- void insertTopLevelItem(int index, QTreeWidgetItem *item);
- void addTopLevelItem(QTreeWidgetItem *item);
- QTreeWidgetItem *takeTopLevelItem(int index);
- int indexOfTopLevelItem(QTreeWidgetItem *item); // ### Qt 5: remove me
- int indexOfTopLevelItem(QTreeWidgetItem *item) const;
-
- void insertTopLevelItems(int index, const QList<QTreeWidgetItem*> &items);
- void addTopLevelItems(const QList<QTreeWidgetItem*> &items);
-
- QTreeWidgetItem *headerItem() const;
- void setHeaderItem(QTreeWidgetItem *item);
- void setHeaderLabels(const QStringList &labels);
- inline void setHeaderLabel(const QString &label);
-
- QTreeWidgetItem *currentItem() const;
- int currentColumn() const;
- void setCurrentItem(QTreeWidgetItem *item);
- void setCurrentItem(QTreeWidgetItem *item, int column);
- void setCurrentItem(QTreeWidgetItem *item, int column, QItemSelectionModel::SelectionFlags command);
-
- QTreeWidgetItem *itemAt(const QPoint &p) const;
- inline QTreeWidgetItem *itemAt(int x, int y) const;
- QRect visualItemRect(const QTreeWidgetItem *item) const;
-
- int sortColumn() const;
- void sortItems(int column, Qt::SortOrder order);
- void setSortingEnabled(bool enable);
- bool isSortingEnabled() const;
-
- void editItem(QTreeWidgetItem *item, int column = 0);
- void openPersistentEditor(QTreeWidgetItem *item, int column = 0);
- void closePersistentEditor(QTreeWidgetItem *item, int column = 0);
-
- QWidget *itemWidget(QTreeWidgetItem *item, int column) const;
- void setItemWidget(QTreeWidgetItem *item, int column, QWidget *widget);
- inline void removeItemWidget(QTreeWidgetItem *item, int column);
-
- bool isItemSelected(const QTreeWidgetItem *item) const;
- void setItemSelected(const QTreeWidgetItem *item, bool select);
- QList<QTreeWidgetItem*> selectedItems() const;
- QList<QTreeWidgetItem*> findItems(const QString &text, Qt::MatchFlags flags,
- int column = 0) const;
-
- bool isItemHidden(const QTreeWidgetItem *item) const;
- void setItemHidden(const QTreeWidgetItem *item, bool hide);
-
- bool isItemExpanded(const QTreeWidgetItem *item) const;
- void setItemExpanded(const QTreeWidgetItem *item, bool expand);
-
- bool isFirstItemColumnSpanned(const QTreeWidgetItem *item) const;
- void setFirstItemColumnSpanned(const QTreeWidgetItem *item, bool span);
-
- QTreeWidgetItem *itemAbove(const QTreeWidgetItem *item) const;
- QTreeWidgetItem *itemBelow(const QTreeWidgetItem *item) const;
-
- void setSelectionModel(QItemSelectionModel *selectionModel);
-
-public Q_SLOTS:
- void scrollToItem(const QTreeWidgetItem *item,
- QAbstractItemView::ScrollHint hint = EnsureVisible);
- void expandItem(const QTreeWidgetItem *item);
- void collapseItem(const QTreeWidgetItem *item);
- void clear();
-
-Q_SIGNALS:
- void itemPressed(QTreeWidgetItem *item, int column);
- void itemClicked(QTreeWidgetItem *item, int column);
- void itemDoubleClicked(QTreeWidgetItem *item, int column);
- void itemActivated(QTreeWidgetItem *item, int column);
- void itemEntered(QTreeWidgetItem *item, int column);
- void itemChanged(QTreeWidgetItem *item, int column);
- void itemExpanded(QTreeWidgetItem *item);
- void itemCollapsed(QTreeWidgetItem *item);
- void currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
- void itemSelectionChanged();
-
-protected:
- bool event(QEvent *e);
- virtual QStringList mimeTypes() const;
- virtual QMimeData *mimeData(const QList<QTreeWidgetItem*> items) const;
- virtual bool dropMimeData(QTreeWidgetItem *parent, int index,
- const QMimeData *data, Qt::DropAction action);
- virtual Qt::DropActions supportedDropActions() const;
- QList<QTreeWidgetItem*> items(const QMimeData *data) const;
-
- QModelIndex indexFromItem(QTreeWidgetItem *item, int column = 0) const;
- QTreeWidgetItem *itemFromIndex(const QModelIndex &index) const;
- void dropEvent(QDropEvent *event);
-
-private:
- void setModel(QAbstractItemModel *model);
-
- Q_DECLARE_PRIVATE(QTreeWidget)
- Q_DISABLE_COPY(QTreeWidget)
-
- Q_PRIVATE_SLOT(d_func(), void _q_emitItemPressed(const QModelIndex &index))
- Q_PRIVATE_SLOT(d_func(), void _q_emitItemClicked(const QModelIndex &index))
- Q_PRIVATE_SLOT(d_func(), void _q_emitItemDoubleClicked(const QModelIndex &index))
- Q_PRIVATE_SLOT(d_func(), void _q_emitItemActivated(const QModelIndex &index))
- Q_PRIVATE_SLOT(d_func(), void _q_emitItemEntered(const QModelIndex &index))
- Q_PRIVATE_SLOT(d_func(), void _q_emitItemChanged(const QModelIndex &index))
- Q_PRIVATE_SLOT(d_func(), void _q_emitItemExpanded(const QModelIndex &index))
- Q_PRIVATE_SLOT(d_func(), void _q_emitItemCollapsed(const QModelIndex &index))
- Q_PRIVATE_SLOT(d_func(), void _q_emitCurrentItemChanged(const QModelIndex &previous, const QModelIndex &current))
- Q_PRIVATE_SLOT(d_func(), void _q_sort())
- Q_PRIVATE_SLOT(d_func(), void _q_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight))
- Q_PRIVATE_SLOT(d_func(), void _q_selectionChanged(const QItemSelection &selected, const QItemSelection &deselected))
-};
-
-inline void QTreeWidget::removeItemWidget(QTreeWidgetItem *item, int column)
-{ setItemWidget(item, column, 0); }
-
-inline QTreeWidgetItem *QTreeWidget::itemAt(int ax, int ay) const
-{ return itemAt(QPoint(ax, ay)); }
-
-inline void QTreeWidget::setHeaderLabel(const QString &alabel)
-{ setHeaderLabels(QStringList(alabel)); }
-
-inline void QTreeWidgetItem::setSelected(bool aselect)
-{ if (view) view->setItemSelected(this, aselect); }
-
-inline bool QTreeWidgetItem::isSelected() const
-{ return (view ? view->isItemSelected(this) : false); }
-
-inline void QTreeWidgetItem::setHidden(bool ahide)
-{ if (view) view->setItemHidden(this, ahide); }
-
-inline bool QTreeWidgetItem::isHidden() const
-{ return (view ? view->isItemHidden(this) : false); }
-
-inline void QTreeWidgetItem::setExpanded(bool aexpand)
-{ if (view) view->setItemExpanded(this, aexpand); }
-
-inline bool QTreeWidgetItem::isExpanded() const
-{ return (view ? view->isItemExpanded(this) : false); }
-
-inline void QTreeWidgetItem::setFirstColumnSpanned(bool aspan)
-{ if (view) view->setFirstItemColumnSpanned(this, aspan); }
-
-inline bool QTreeWidgetItem::isFirstColumnSpanned() const
-{ return (view ? view->isFirstItemColumnSpanned(this) : false); }
-
-inline void QTreeWidgetItem::setDisabled(bool disabled)
-{ setFlags(disabled ? (flags() & ~Qt::ItemIsEnabled) : flags() | Qt::ItemIsEnabled); }
-
-inline bool QTreeWidgetItem::isDisabled() const
-{ return !(flags() & Qt::ItemIsEnabled); }
-
-#endif // QT_NO_TREEWIDGET
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QTREEWIDGET_H
diff --git a/src/gui/itemviews/qtreewidget_p.h b/src/gui/itemviews/qtreewidget_p.h
deleted file mode 100644
index 7395e6a5db..0000000000
--- a/src/gui/itemviews/qtreewidget_p.h
+++ /dev/null
@@ -1,248 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTREEWIDGET_P_H
-#define QTREEWIDGET_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. This header file may change
-// from version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qabstractitemmodel.h>
-#include <private/qabstractitemmodel_p.h>
-#include <QtCore/qpair.h>
-#include <QtCore/qbasictimer.h>
-#include <QtGui/qtreewidget.h>
-#include <private/qtreeview_p.h>
-#include <QtGui/qheaderview.h>
-
-#ifndef QT_NO_TREEWIDGET
-
-QT_BEGIN_NAMESPACE
-
-class QTreeWidgetItem;
-class QTreeWidgetItemIterator;
-class QTreeModelPrivate;
-
-class QTreeModel : public QAbstractItemModel
-{
- Q_OBJECT
- friend class QTreeWidget;
- friend class QTreeWidgetPrivate;
- friend class QTreeWidgetItem;
- friend class QTreeWidgetItemPrivate;
- friend class QTreeWidgetItemIterator;
- friend class QTreeWidgetItemIteratorPrivate;
-
-public:
- explicit QTreeModel(int columns = 0, QTreeWidget *parent = 0);
- ~QTreeModel();
-
- inline QTreeWidget *view() const
- { return qobject_cast<QTreeWidget*>(QObject::parent()); }
-
- void clear();
- void setColumnCount(int columns);
-
- QTreeWidgetItem *item(const QModelIndex &index) const;
- void itemChanged(QTreeWidgetItem *item);
-
- QModelIndex index(const QTreeWidgetItem *item, int column) const;
- 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 = QModelIndex()) const;
- bool hasChildren(const QModelIndex &parent) const;
-
- QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
- bool setData(const QModelIndex &index, const QVariant &value, int role);
-
- QMap<int, QVariant> itemData(const QModelIndex &index) const;
-
- QVariant headerData(int section, Qt::Orientation orientation, int role) const;
- bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value,
- int role);
-
- Qt::ItemFlags flags(const QModelIndex &index) const;
-
- void sort(int column, Qt::SortOrder order);
- void ensureSorted(int column, Qt::SortOrder order,
- int start, int end, const QModelIndex &parent);
- static bool itemLessThan(const QPair<QTreeWidgetItem*,int> &left,
- const QPair<QTreeWidgetItem*,int> &right);
- static bool itemGreaterThan(const QPair<QTreeWidgetItem*,int> &left,
- const QPair<QTreeWidgetItem*,int> &right);
- static QList<QTreeWidgetItem*>::iterator sortedInsertionIterator(
- const QList<QTreeWidgetItem*>::iterator &begin,
- const QList<QTreeWidgetItem*>::iterator &end,
- Qt::SortOrder order, QTreeWidgetItem *item);
-
- bool insertRows(int row, int count, const QModelIndex &);
- bool insertColumns(int column, int count, const QModelIndex &);
-
- bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
-
- // dnd
- QStringList mimeTypes() const;
- QMimeData *mimeData(const QModelIndexList &indexes) const;
- bool dropMimeData(const QMimeData *data, Qt::DropAction action,
- int row, int column, const QModelIndex &parent);
- Qt::DropActions supportedDropActions() const;
-
- QMimeData *internalMimeData() const;
-
- inline QModelIndex createIndexFromItem(int row, int col, QTreeWidgetItem *item) const
- { return createIndex(row, col, item); }
-
-protected:
- QTreeModel(QTreeModelPrivate &, QTreeWidget *parent = 0);
- void emitDataChanged(QTreeWidgetItem *item, int column);
- void beginInsertItems(QTreeWidgetItem *parent, int row, int count);
- void endInsertItems();
- void beginRemoveItems(QTreeWidgetItem *parent, int row, int count);
- void endRemoveItems();
- void sortItems(QList<QTreeWidgetItem*> *items, int column, Qt::SortOrder order);
- void timerEvent(QTimerEvent *);
-
-private:
- QTreeWidgetItem *rootItem;
- QTreeWidgetItem *headerItem;
-
- mutable QModelIndexList cachedIndexes;
- QList<QTreeWidgetItemIterator*> iterators;
-
- mutable QBasicTimer sortPendingTimer;
- mutable bool skipPendingSort; //while doing internal operation we don't care about sorting
- bool inline executePendingSort() const;
-
- bool isChanging() const;
-
-private:
- Q_DECLARE_PRIVATE(QTreeModel)
-public:
- struct SkipSorting
- {
- const QTreeModel * const model;
- const bool previous;
- SkipSorting(const QTreeModel *m) : model(m), previous(model->skipPendingSort)
- { model->skipPendingSort = true; }
- ~SkipSorting() { model->skipPendingSort = previous; }
- };
- friend struct SkipSorting;
-};
-
-QT_BEGIN_INCLUDE_NAMESPACE
-#include "private/qabstractitemmodel_p.h"
-QT_END_INCLUDE_NAMESPACE
-
-class QTreeModelPrivate : public QAbstractItemModelPrivate
-{
- Q_DECLARE_PUBLIC(QTreeModel)
-};
-
-class QTreeWidgetItemPrivate
-{
-public:
- QTreeWidgetItemPrivate(QTreeWidgetItem *item)
- : q(item), disabled(false), selected(false), rowGuess(-1), policy(QTreeWidgetItem::DontShowIndicatorWhenChildless) {}
- void propagateDisabled(QTreeWidgetItem *item);
- void sortChildren(int column, Qt::SortOrder order, bool climb);
- QTreeWidgetItem *q;
- QVariantList display;
- uint disabled : 1;
- uint selected : 1;
- int rowGuess;
- QTreeWidgetItem::ChildIndicatorPolicy policy;
-};
-
-
-inline bool QTreeModel::executePendingSort() const
-{
- if (!skipPendingSort && sortPendingTimer.isActive() && !isChanging()) {
- sortPendingTimer.stop();
- int column = view()->header()->sortIndicatorSection();
- Qt::SortOrder order = view()->header()->sortIndicatorOrder();
- QTreeModel *that = const_cast<QTreeModel*>(this);
- that->sort(column, order);
- return true;
- }
- return false;
-}
-
-class QTreeWidgetPrivate : public QTreeViewPrivate
-{
- friend class QTreeModel;
- Q_DECLARE_PUBLIC(QTreeWidget)
-public:
- QTreeWidgetPrivate() : QTreeViewPrivate(), explicitSortColumn(-1) {}
- inline QTreeModel *treeModel() const { return qobject_cast<QTreeModel*>(model); }
- inline QModelIndex index(const QTreeWidgetItem *item, int column = 0) const
- { return treeModel()->index(item, column); }
- inline QTreeWidgetItem *item(const QModelIndex &index) const
- { return treeModel()->item(index); }
- void _q_emitItemPressed(const QModelIndex &index);
- void _q_emitItemClicked(const QModelIndex &index);
- void _q_emitItemDoubleClicked(const QModelIndex &index);
- void _q_emitItemActivated(const QModelIndex &index);
- void _q_emitItemEntered(const QModelIndex &index);
- void _q_emitItemChanged(const QModelIndex &index);
- void _q_emitItemExpanded(const QModelIndex &index);
- void _q_emitItemCollapsed(const QModelIndex &index);
- void _q_emitCurrentItemChanged(const QModelIndex &previous, const QModelIndex &index);
- void _q_sort();
- void _q_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
- void _q_selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
-
- // used by QTreeWidgetItem::sortChildren to make sure the column argument is used
- int explicitSortColumn;
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_TREEWIDGET
-
-#endif // QTREEWIDGET_P_H
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri
deleted file mode 100644
index 3c57368bab..0000000000
--- a/src/gui/kernel/kernel.pri
+++ /dev/null
@@ -1,329 +0,0 @@
-# Qt kernel module
-
-# Only used on platforms with CONFIG += precompile_header
-PRECOMPILED_HEADER = kernel/qt_gui_pch.h
-
-
-KERNEL_P= kernel
-HEADERS += \
- kernel/qaction.h \
- kernel/qaction_p.h \
- kernel/qactiongroup.h \
- kernel/qapplication.h \
- kernel/qapplication_p.h \
- kernel/qboxlayout.h \
- kernel/qclipboard.h \
- kernel/qcursor.h \
- kernel/qdesktopwidget.h \
- kernel/qdrag.h \
- kernel/qdnd_p.h \
- kernel/qevent.h \
- kernel/qevent_p.h \
- kernel/qformlayout.h \
- kernel/qgridlayout.h \
- kernel/qkeysequence.h \
- kernel/qlayout.h \
- kernel/qlayout_p.h \
- kernel/qlayoutengine_p.h \
- kernel/qlayoutitem.h \
- kernel/qmime.h \
- kernel/qsessionmanager.h \
- kernel/qshortcut.h \
- kernel/qshortcutmap_p.h \
- kernel/qsizepolicy.h \
- kernel/qpalette.h \
- kernel/qstackedlayout.h \
- kernel/qtooltip.h \
- kernel/qwhatsthis.h \
- kernel/qwidget.h \
- kernel/qwidget_p.h \
- kernel/qwidgetaction.h \
- kernel/qwidgetaction_p.h \
- kernel/qwindowdefs.h \
- kernel/qkeymapper_p.h \
- kernel/qgesture.h \
- kernel/qgesture_p.h \
- kernel/qstandardgestures_p.h \
- kernel/qgesturerecognizer.h \
- kernel/qgesturemanager_p.h \
- kernel/qsoftkeymanager_p.h \
- kernel/qsoftkeymanager_common_p.h \
- kernel/qguiplatformplugin_p.h \
-
-SOURCES += \
- kernel/qaction.cpp \
- kernel/qactiongroup.cpp \
- kernel/qapplication.cpp \
- kernel/qboxlayout.cpp \
- kernel/qclipboard.cpp \
- kernel/qcursor.cpp \
- kernel/qdrag.cpp \
- kernel/qdnd.cpp \
- kernel/qevent.cpp \
- kernel/qformlayout.cpp \
- kernel/qgridlayout.cpp \
- kernel/qkeysequence.cpp \
- kernel/qlayout.cpp \
- kernel/qlayoutengine.cpp \
- kernel/qlayoutitem.cpp \
- kernel/qmime.cpp \
- kernel/qpalette.cpp \
- kernel/qshortcut.cpp \
- kernel/qshortcutmap.cpp \
- kernel/qstackedlayout.cpp \
- kernel/qtooltip.cpp \
- kernel/qguivariant.cpp \
- kernel/qwhatsthis.cpp \
- kernel/qwidget.cpp \
- kernel/qwidgetaction.cpp \
- kernel/qkeymapper.cpp \
- kernel/qgesture.cpp \
- kernel/qstandardgestures.cpp \
- kernel/qgesturerecognizer.cpp \
- kernel/qgesturemanager.cpp \
- kernel/qsoftkeymanager.cpp \
- kernel/qdesktopwidget.cpp \
- kernel/qguiplatformplugin.cpp
-
-win32 {
- DEFINES += QT_NO_DIRECTDRAW
-
- HEADERS += \
- kernel/qwinnativepangesturerecognizer_win_p.h
-
- SOURCES += \
- kernel/qapplication_win.cpp \
- kernel/qclipboard_win.cpp \
- kernel/qcursor_win.cpp \
- kernel/qdesktopwidget_win.cpp \
- kernel/qdnd_win.cpp \
- kernel/qmime_win.cpp \
- kernel/qsound_win.cpp \
- kernel/qwidget_win.cpp \
- kernel/qole_win.cpp \
- kernel/qkeymapper_win.cpp \
- kernel/qwinnativepangesturerecognizer_win.cpp
-
- !contains(DEFINES, QT_NO_DIRECTDRAW):LIBS += ddraw.lib
-}
-
-symbian {
- exists($${EPOCROOT}epoc32/include/platform/mw/akntranseffect.h): DEFINES += QT_SYMBIAN_HAVE_AKNTRANSEFFECT_H
-
- SOURCES += \
- kernel/qapplication_s60.cpp \
- kernel/qeventdispatcher_s60.cpp \
- kernel/qwidget_s60.cpp \
- kernel/qcursor_s60.cpp \
- kernel/qdesktopwidget_s60.cpp \
- kernel/qkeymapper_s60.cpp\
- kernel/qclipboard_s60.cpp\
- kernel/qdnd_s60.cpp \
- kernel/qsound_s60.cpp
-
- HEADERS += \
- kernel/qt_s60_p.h \
- kernel/qeventdispatcher_s60_p.h
-
- LIBS += -lbafl -lestor
-
- INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE
- INCLUDEPATH += ../3rdparty/s60
-
- contains(QT_CONFIG, s60) {
- SOURCES += kernel/qsoftkeymanager_s60.cpp
- HEADERS += kernel/qsoftkeymanager_s60_p.h
- }
-}
-
-
-unix:x11 {
- INCLUDEPATH += ../3rdparty/xorg
- HEADERS += \
- kernel/qx11embed_x11.h \
- kernel/qx11info_x11.h \
- kernel/qkde_p.h
-
- SOURCES += \
- kernel/qapplication_x11.cpp \
- kernel/qclipboard_x11.cpp \
- kernel/qcursor_x11.cpp \
- kernel/qdnd_x11.cpp \
- kernel/qdesktopwidget_x11.cpp \
- kernel/qmotifdnd_x11.cpp \
- kernel/qsound_x11.cpp \
- kernel/qwidget_x11.cpp \
- kernel/qwidgetcreate_x11.cpp \
- kernel/qx11embed_x11.cpp \
- kernel/qx11info_x11.cpp \
- kernel/qkeymapper_x11.cpp \
- kernel/qkde.cpp
-
- contains(QT_CONFIG, glib) {
- SOURCES += \
- kernel/qguieventdispatcher_glib.cpp
- HEADERS += \
- kernel/qguieventdispatcher_glib_p.h
- QMAKE_CXXFLAGS += $$QT_CFLAGS_GLIB
- LIBS_PRIVATE +=$$QT_LIBS_GLIB
- }
- SOURCES += \
- kernel/qeventdispatcher_x11.cpp
- HEADERS += \
- kernel/qeventdispatcher_x11_p.h
-}
-
-embedded {
- HEADERS += \
- kernel/qeventdispatcher_qws_p.h
-
- SOURCES += \
- kernel/qapplication_qws.cpp \
- kernel/qclipboard_qws.cpp \
- kernel/qcursor_qws.cpp \
- kernel/qdesktopwidget_qws.cpp \
- kernel/qdnd_qws.cpp \
- kernel/qeventdispatcher_qws.cpp \
- kernel/qsound_qws.cpp \
- kernel/qwidget_qws.cpp \
- kernel/qkeymapper_qws.cpp \
- kernel/qsessionmanager_qws.cpp
-
- contains(QT_CONFIG, glib) {
- SOURCES += \
- kernel/qeventdispatcher_glib_qws.cpp
- HEADERS += \
- kernel/qeventdispatcher_glib_qws_p.h
- QMAKE_CXXFLAGS += $$QT_CFLAGS_GLIB
- LIBS_PRIVATE +=$$QT_LIBS_GLIB
- }
-}
-
-!qpa {
- HEADERS += \
- kernel/qsound.h \
- kernel/qsound_p.h
-
- SOURCES += \
- kernel/qsound.cpp
-}
-
-qpa {
- HEADERS += \
- kernel/qgenericpluginfactory_qpa.h \
- kernel/qgenericplugin_qpa.h \
- kernel/qeventdispatcher_qpa_p.h \
- kernel/qwindowsysteminterface_qpa.h \
- kernel/qwindowsysteminterface_qpa_p.h \
- kernel/qplatformintegration_qpa.h \
- kernel/qplatformscreen_qpa.h \
- kernel/qplatformintegrationfactory_qpa_p.h \
- kernel/qplatformintegrationplugin_qpa.h \
- kernel/qplatformwindow_qpa.h \
- kernel/qplatformwindowformat_qpa.h \
- kernel/qplatformglcontext_qpa.h \
- kernel/qdesktopwidget_qpa_p.h \
- kernel/qplatformeventloopintegration_qpa.h \
- kernel/qplatformcursor_qpa.h \
- kernel/qplatformclipboard_qpa.h \
- kernel/qplatformnativeinterface_qpa.h
-
- SOURCES += \
- kernel/qapplication_qpa.cpp \
- kernel/qclipboard_qpa.cpp \
- kernel/qcursor_qpa.cpp \
- kernel/qdnd_qws.cpp \
- kernel/qdesktopwidget_qpa.cpp \
- kernel/qgenericpluginfactory_qpa.cpp \
- kernel/qgenericplugin_qpa.cpp \
- kernel/qkeymapper_qws.cpp \
- kernel/qwidget_qpa.cpp \
- kernel/qeventdispatcher_qpa.cpp \
- kernel/qwindowsysteminterface_qpa.cpp \
- kernel/qplatformintegration_qpa.cpp \
- kernel/qplatformscreen_qpa.cpp \
- kernel/qplatformintegrationfactory_qpa.cpp \
- kernel/qplatformintegrationplugin_qpa.cpp \
- kernel/qplatformwindow_qpa.cpp \
- kernel/qplatformwindowformat_qpa.cpp \
- kernel/qplatformeventloopintegration_qpa.cpp \
- kernel/qplatformglcontext_qpa.cpp \
- kernel/qplatformcursor_qpa.cpp \
- kernel/qplatformclipboard_qpa.cpp \
- kernel/qplatformnativeinterface_qpa.cpp \
- kernel/qsessionmanager_qpa.cpp
-
- contains(QT_CONFIG, glib) {
- SOURCES += \
- kernel/qeventdispatcher_glib_qpa.cpp
- HEADERS += \
- kernel/qeventdispatcher_glib_qpa_p.h
- QMAKE_CXXFLAGS += $$QT_CFLAGS_GLIB
- LIBS_PRIVATE +=$$QT_LIBS_GLIB
- }
-}
-
-!embedded:!qpa:!x11:mac {
- SOURCES += \
- kernel/qclipboard_mac.cpp \
- kernel/qmime_mac.cpp \
- kernel/qt_mac.cpp \
- kernel/qkeymapper_mac.cpp
-
- OBJECTIVE_HEADERS += \
- qcocoawindow_mac_p.h \
- qcocoapanel_mac_p.h \
- qcocoawindowdelegate_mac_p.h \
- qcocoaview_mac_p.h \
- qcocoaapplication_mac_p.h \
- qcocoaapplicationdelegate_mac_p.h \
- qmacgesturerecognizer_mac_p.h \
- qmultitouch_mac_p.h \
- qcocoasharedwindowmethods_mac_p.h \
- qcocoaintrospection_p.h
-
- OBJECTIVE_SOURCES += \
- kernel/qcursor_mac.mm \
- kernel/qdnd_mac.mm \
- kernel/qsound_mac.mm \
- kernel/qapplication_mac.mm \
- kernel/qwidget_mac.mm \
- kernel/qcocoapanel_mac.mm \
- kernel/qcocoaview_mac.mm \
- kernel/qcocoawindow_mac.mm \
- kernel/qcocoawindowdelegate_mac.mm \
- kernel/qcocoamenuloader_mac.mm \
- kernel/qcocoaapplication_mac.mm \
- kernel/qcocoaapplicationdelegate_mac.mm \
- kernel/qt_cocoa_helpers_mac.mm \
- kernel/qdesktopwidget_mac.mm \
- kernel/qeventdispatcher_mac.mm \
- kernel/qcocoawindowcustomthemeframe_mac.mm \
- kernel/qmacgesturerecognizer_mac.mm \
- kernel/qmultitouch_mac.mm \
- kernel/qcocoaintrospection_mac.mm
-
- HEADERS += \
- kernel/qt_cocoa_helpers_mac_p.h \
- kernel/qcocoaapplication_mac_p.h \
- kernel/qcocoaapplicationdelegate_mac_p.h \
- kernel/qeventdispatcher_mac_p.h
-
- MENU_NIB.files = mac/qt_menu.nib
- MENU_NIB.path = Resources
- MENU_NIB.version = Versions
- QMAKE_BUNDLE_DATA += MENU_NIB
- RESOURCES += mac/macresources.qrc
-
- LIBS_PRIVATE += -framework AppKit
-}
-
-wince*: {
- HEADERS += \
- ../corelib/kernel/qfunctions_wince.h \
- kernel/qguifunctions_wince.h
-
- SOURCES += \
- ../corelib/kernel/qfunctions_wince.cpp \
- kernel/qguifunctions_wince.cpp
-}
diff --git a/src/gui/kernel/mac.pri b/src/gui/kernel/mac.pri
deleted file mode 100644
index 21acd06e65..0000000000
--- a/src/gui/kernel/mac.pri
+++ /dev/null
@@ -1,4 +0,0 @@
-!x11:!embedded:!qpa:mac {
- LIBS_PRIVATE += -framework Carbon -lz
- *-mwerks:INCLUDEPATH += compat
-}
diff --git a/src/gui/kernel/qaction.h b/src/gui/kernel/qaction.h
deleted file mode 100644
index 856fd92f10..0000000000
--- a/src/gui/kernel/qaction.h
+++ /dev/null
@@ -1,264 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QACTION_H
-#define QACTION_H
-
-#include <QtGui/qkeysequence.h>
-#include <QtCore/qstring.h>
-#include <QtGui/qwidget.h>
-#include <QtCore/qvariant.h>
-#include <QtGui/qicon.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_ACTION
-
-class QMenu;
-class QActionGroup;
-class QActionPrivate;
-class QGraphicsWidget;
-
-class Q_GUI_EXPORT QAction : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QAction)
-
- Q_ENUMS(MenuRole)
- Q_ENUMS(SoftKeyRole)
- Q_ENUMS(Priority)
- Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY changed)
- Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled)
- Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY changed)
- Q_PROPERTY(QIcon icon READ icon WRITE setIcon NOTIFY changed)
- Q_PROPERTY(QString text READ text WRITE setText NOTIFY changed)
- Q_PROPERTY(QString iconText READ iconText WRITE setIconText NOTIFY changed)
- Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip NOTIFY changed)
- Q_PROPERTY(QString statusTip READ statusTip WRITE setStatusTip NOTIFY changed)
- Q_PROPERTY(QString whatsThis READ whatsThis WRITE setWhatsThis NOTIFY changed)
- Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY changed)
-#ifndef QT_NO_SHORTCUT
- Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut NOTIFY changed)
- Q_PROPERTY(Qt::ShortcutContext shortcutContext READ shortcutContext WRITE setShortcutContext NOTIFY changed)
- Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat NOTIFY changed)
-#endif
- Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY changed)
- Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
- Q_PROPERTY(SoftKeyRole softKeyRole READ softKeyRole WRITE setSoftKeyRole NOTIFY changed)
- Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
- Q_PROPERTY(Priority priority READ priority WRITE setPriority)
-
-public:
- enum MenuRole { NoRole, TextHeuristicRole, ApplicationSpecificRole, AboutQtRole,
- AboutRole, PreferencesRole, QuitRole };
- enum SoftKeyRole {
- NoSoftKey, PositiveSoftKey, NegativeSoftKey, SelectSoftKey };
- enum Priority { LowPriority = 0,
- NormalPriority = 128,
- HighPriority = 256};
- explicit QAction(QObject* parent);
- QAction(const QString &text, QObject* parent);
- QAction(const QIcon &icon, const QString &text, QObject* parent);
-
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QAction(QObject* parent, const char* name);
- QT3_SUPPORT_CONSTRUCTOR QAction(const QString &text, const QKeySequence &shortcut,
- QObject* parent, const char* name);
- QT3_SUPPORT_CONSTRUCTOR QAction(const QIcon &icon, const QString &text,
- const QKeySequence &shortcut,
- QObject* parent, const char* name);
-#endif
- ~QAction();
-
- void setActionGroup(QActionGroup *group);
- QActionGroup *actionGroup() const;
- void setIcon(const QIcon &icon);
- QIcon icon() const;
-
- void setText(const QString &text);
- QString text() const;
-
- void setIconText(const QString &text);
- QString iconText() const;
-
- void setToolTip(const QString &tip);
- QString toolTip() const;
-
- void setStatusTip(const QString &statusTip);
- QString statusTip() const;
-
- void setWhatsThis(const QString &what);
- QString whatsThis() const;
-
- void setPriority(Priority priority);
- Priority priority() const;
-
-#ifndef QT_NO_MENU
- QMenu *menu() const;
- void setMenu(QMenu *menu);
-#endif
-
- void setSeparator(bool b);
- bool isSeparator() const;
-
-#ifndef QT_NO_SHORTCUT
- void setShortcut(const QKeySequence &shortcut);
- QKeySequence shortcut() const;
-
- void setShortcuts(const QList<QKeySequence> &shortcuts);
- void setShortcuts(QKeySequence::StandardKey);
- QList<QKeySequence> shortcuts() const;
-
- void setShortcutContext(Qt::ShortcutContext context);
- Qt::ShortcutContext shortcutContext() const;
-
- void setAutoRepeat(bool);
- bool autoRepeat() const;
-#endif
-
- void setFont(const QFont &font);
- QFont font() const;
-
- void setCheckable(bool);
- bool isCheckable() const;
-
- QVariant data() const;
- void setData(const QVariant &var);
-
- bool isChecked() const;
-
- bool isEnabled() const;
-
- bool isVisible() const;
-
- enum ActionEvent { Trigger, Hover };
- void activate(ActionEvent event);
- bool showStatusText(QWidget *widget=0);
-
- void setMenuRole(MenuRole menuRole);
- MenuRole menuRole() const;
-
- void setSoftKeyRole(SoftKeyRole softKeyRole);
- SoftKeyRole softKeyRole() const;
-
- void setIconVisibleInMenu(bool visible);
- bool isIconVisibleInMenu() const;
-
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT void setMenuText(const QString &text) { setText(text); }
- inline QT3_SUPPORT QString menuText() const { return text(); }
- inline QT3_SUPPORT bool isOn() const { return isChecked(); }
- inline QT3_SUPPORT bool isToggleAction() const { return isCheckable(); }
- inline QT3_SUPPORT void setToggleAction(bool b) { setCheckable(b); }
- inline QT3_SUPPORT void setIconSet(const QIcon &i) { setIcon(i); }
- inline QT3_SUPPORT QIcon iconSet() const { return icon(); }
- inline QT3_SUPPORT bool addTo(QWidget *w) { w->addAction(this); return true; }
- inline QT3_SUPPORT bool removeFrom(QWidget *w) { w->removeAction(this); return true; }
- inline QT3_SUPPORT void setAccel(const QKeySequence &shortcut) { setShortcut(shortcut); }
- inline QT3_SUPPORT QKeySequence accel() const { return shortcut(); }
-#endif
-
- QWidget *parentWidget() const;
-
- QList<QWidget *> associatedWidgets() const;
-#ifndef QT_NO_GRAPHICSVIEW
- QList<QGraphicsWidget *> associatedGraphicsWidgets() const; // ### suboptimal
-#endif
-
-protected:
- bool event(QEvent *);
- QAction(QActionPrivate &dd, QObject *parent);
-
-public Q_SLOTS:
-#ifdef QT3_SUPPORT
- inline QT_MOC_COMPAT void setOn(bool b) { setChecked(b); }
-#endif
- void trigger() { activate(Trigger); }
- void hover() { activate(Hover); }
- void setChecked(bool);
- void toggle();
- void setEnabled(bool);
- inline void setDisabled(bool b) { setEnabled(!b); }
- void setVisible(bool);
-
-Q_SIGNALS:
- void changed();
- void triggered(bool checked = false);
- void hovered();
- void toggled(bool);
-#ifdef QT3_SUPPORT
- QT_MOC_COMPAT void activated(int = 0);
-#endif
-
-private:
- Q_DISABLE_COPY(QAction)
-
-#ifdef QT3_SUPPORT
- friend class QMenuItem;
-#endif
- friend class QGraphicsWidget;
- friend class QWidget;
- friend class QActionGroup;
- friend class QMenu;
- friend class QMenuPrivate;
- friend class QMenuBar;
- friend class QShortcutMap;
- friend class QToolButton;
-#ifdef Q_WS_MAC
- friend void qt_mac_clear_status_text(QAction *action);
-#endif
-};
-
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <QtGui/qactiongroup.h>
-QT_END_INCLUDE_NAMESPACE
-
-#endif // QT_NO_ACTION
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QACTION_H
diff --git a/src/gui/kernel/qaction_p.h b/src/gui/kernel/qaction_p.h
deleted file mode 100644
index f3154f90c1..0000000000
--- a/src/gui/kernel/qaction_p.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QACTION_P_H
-#define QACTION_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "QtGui/qaction.h"
-#include "QtGui/qmenu.h"
-#include "private/qgraphicswidget_p.h"
-#include "private/qobject_p.h"
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_ACTION
-
-#ifdef QT3_SUPPORT
-class QMenuItemEmitter;
-#endif
-
-class QShortcutMap;
-
-class Q_AUTOTEST_EXPORT QActionPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QAction)
-public:
- QActionPrivate();
- ~QActionPrivate();
-
- static QActionPrivate *get(QAction *q)
- {
- return q->d_func();
- }
-
- bool showStatusText(QWidget *w, const QString &str);
-
- QPointer<QActionGroup> group;
- QString text;
- QString iconText;
- QIcon icon;
- QString tooltip;
- QString statustip;
- QString whatsthis;
-#ifndef QT_NO_SHORTCUT
- QKeySequence shortcut;
- QList<QKeySequence> alternateShortcuts;
-#endif
- QVariant userData;
-#ifndef QT_NO_SHORTCUT
- int shortcutId;
- QList<int> alternateShortcutIds;
- Qt::ShortcutContext shortcutContext;
- uint autorepeat : 1;
-#endif
- QFont font;
- QPointer<QMenu> menu;
- uint enabled : 1, forceDisabled : 1;
- uint visible : 1, forceInvisible : 1;
- uint checkable : 1;
- uint checked : 1;
- uint separator : 1;
- uint fontSet : 1;
-
- //for soft keys management
- uint forceEnabledInSoftkeys : 1;
- uint menuActionSoftkeys : 1;
- int iconVisibleInMenu : 3; // Only has values -1, 0, and 1
-
- QAction::MenuRole menuRole;
- QAction::SoftKeyRole softKeyRole;
- QAction::Priority priority;
-
- QList<QWidget *> widgets;
-#ifndef QT_NO_GRAPHICSVIEW
- QList<QGraphicsWidget *> graphicsWidgets;
-#endif
-#ifndef QT_NO_SHORTCUT
- void redoGrab(QShortcutMap &map);
- void redoGrabAlternate(QShortcutMap &map);
- void setShortcutEnabled(bool enable, QShortcutMap &map);
-
- static QShortcutMap *globalMap;
-#endif // QT_NO_SHORTCUT
-
-#ifdef QT3_SUPPORT //for menubar/menu compat
- QMenuItemEmitter *act_signal;
- int id, param;
-#endif
- void sendDataChanged();
-};
-
-#endif // QT_NO_ACTION
-
-QT_END_NAMESPACE
-
-#endif // QACTION_P_H
diff --git a/src/gui/kernel/qactiongroup.h b/src/gui/kernel/qactiongroup.h
deleted file mode 100644
index 88f4fe8eac..0000000000
--- a/src/gui/kernel/qactiongroup.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QACTIONGROUP_H
-#define QACTIONGROUP_H
-
-#include <QtGui/qaction.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_ACTION
-
-class QActionGroupPrivate;
-
-class Q_GUI_EXPORT QActionGroup : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QActionGroup)
-
- Q_PROPERTY(bool exclusive READ isExclusive WRITE setExclusive)
- Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
- Q_PROPERTY(bool visible READ isVisible WRITE setVisible)
-
-public:
- explicit QActionGroup(QObject* parent);
- ~QActionGroup();
-
- QAction *addAction(QAction* a);
- QAction *addAction(const QString &text);
- QAction *addAction(const QIcon &icon, const QString &text);
- void removeAction(QAction *a);
- QList<QAction*> actions() const;
-
- QAction *checkedAction() const;
- bool isExclusive() const;
- bool isEnabled() const;
- bool isVisible() const;
-
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT void add(QAction* a) { addAction(a); }
- inline QT3_SUPPORT void addSeparator()
- { QAction *act = new QAction(this); act->setSeparator(true); addAction(act); }
- inline QT3_SUPPORT bool addTo(QWidget *w) { w->addActions(actions()); return true; }
-#endif
-
-public Q_SLOTS:
- void setEnabled(bool);
- inline void setDisabled(bool b) { setEnabled(!b); }
- void setVisible(bool);
- void setExclusive(bool);
-
-Q_SIGNALS:
- void triggered(QAction *);
- QT_MOC_COMPAT void selected(QAction *);
- void hovered(QAction *);
-
-private:
- Q_DISABLE_COPY(QActionGroup)
- Q_PRIVATE_SLOT(d_func(), void _q_actionTriggered())
- Q_PRIVATE_SLOT(d_func(), void _q_actionChanged())
- Q_PRIVATE_SLOT(d_func(), void _q_actionHovered())
-};
-
-#endif // QT_NO_ACTION
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QACTIONGROUP_H
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
deleted file mode 100644
index 4096bf378b..0000000000
--- a/src/gui/kernel/qapplication.cpp
+++ /dev/null
@@ -1,6139 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qplatformdefs.h"
-#include "qabstracteventdispatcher.h"
-#include "qaccessible.h"
-#include "qapplication.h"
-#include "qclipboard.h"
-#include "qcursor.h"
-#include "qdesktopwidget.h"
-#include "qdir.h"
-#include "qevent.h"
-#include "qfile.h"
-#include "qfileinfo.h"
-#include "qgraphicsscene.h"
-#include "qhash.h"
-#include "qset.h"
-#include "qlayout.h"
-#include "qsessionmanager.h"
-#include "qstyle.h"
-#include "qstylefactory.h"
-#include "qtextcodec.h"
-#include "qtranslator.h"
-#include "qvariant.h"
-#include "qwidget.h"
-#include "qdnd_p.h"
-#include "qcolormap.h"
-#include "qdebug.h"
-#include "private/qgraphicssystemfactory_p.h"
-#include "private/qgraphicssystem_p.h"
-#include "private/qstylesheetstyle_p.h"
-#include "private/qstyle_p.h"
-#include "qmessagebox.h"
-#include <QtGui/qgraphicsproxywidget.h>
-
-#ifdef QT_GRAPHICSSYSTEM_RUNTIME
-#include "private/qgraphicssystem_runtime_p.h"
-#endif
-
-#include "qinputcontext.h"
-#include "qkeymapper_p.h"
-
-#ifdef Q_WS_X11
-#include <private/qt_x11_p.h>
-#endif
-
-#if defined(Q_WS_X11) || defined(Q_OS_SYMBIAN)
-#include "qinputcontextfactory.h"
-#endif
-
-#include "qguiplatformplugin_p.h"
-
-#include <qthread.h>
-#include <private/qthread_p.h>
-
-#include <private/qfont_p.h>
-
-#include <stdlib.h>
-
-#if defined(Q_WS_X11) && !defined(QT_NO_EGL)
-#include <link.h>
-#endif
-
-#include "qapplication_p.h"
-#include "qevent_p.h"
-#include "qwidget_p.h"
-
-#include "qapplication.h"
-
-#include "qgesture.h"
-#include "private/qgesturemanager_p.h"
-
-#ifndef QT_NO_LIBRARY
-#include "qlibrary.h"
-#endif
-
-#ifdef Q_WS_WINCE
-#include "qdatetime.h"
-#include "qguifunctions_wince.h"
-extern bool qt_wince_is_smartphone(); //qguifunctions_wince.cpp
-extern bool qt_wince_is_mobile(); //qguifunctions_wince.cpp
-extern bool qt_wince_is_pocket_pc(); //qguifunctions_wince.cpp
-#endif
-
-#include "qdatetime.h"
-
-#ifdef QT_MAC_USE_COCOA
-#include <private/qt_cocoa_helpers_mac_p.h>
-#endif
-
-//#define ALIEN_DEBUG
-
-#if defined(Q_OS_SYMBIAN)
-#include "qt_s60_p.h"
-#endif
-
-static void initResources()
-{
-#if defined(Q_WS_WINCE)
- Q_INIT_RESOURCE_EXTERN(qstyle_wince)
- Q_INIT_RESOURCE(qstyle_wince);
-#elif defined(Q_OS_SYMBIAN)
- Q_INIT_RESOURCE_EXTERN(qstyle_s60)
- Q_INIT_RESOURCE(qstyle_s60);
-#else
- Q_INIT_RESOURCE_EXTERN(qstyle)
- Q_INIT_RESOURCE(qstyle);
-#endif
- Q_INIT_RESOURCE_EXTERN(qmessagebox)
- Q_INIT_RESOURCE(qmessagebox);
-#if !defined(QT_NO_PRINTDIALOG)
- Q_INIT_RESOURCE_EXTERN(qprintdialog)
- Q_INIT_RESOURCE(qprintdialog);
-#endif
-
-}
-
-QT_BEGIN_NAMESPACE
-
-Q_CORE_EXPORT void qt_call_post_routines();
-
-QApplication::Type qt_appType=QApplication::Tty;
-QApplicationPrivate *QApplicationPrivate::self = 0;
-
-QInputContext *QApplicationPrivate::inputContext = 0;
-
-bool QApplicationPrivate::quitOnLastWindowClosed = true;
-
-#ifdef Q_WS_WINCE
-int QApplicationPrivate::autoMaximizeThreshold = -1;
-bool QApplicationPrivate::autoSipEnabled = false;
-#else
-bool QApplicationPrivate::autoSipEnabled = true;
-#endif
-
-QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::Type type, int flags)
- : QCoreApplicationPrivate(argc, argv, flags)
-{
- application_type = type;
- qt_appType = type;
-
-#ifndef QT_NO_SESSIONMANAGER
- is_session_restored = false;
-#endif
-
- quitOnLastWindowClosed = true;
-
-#ifdef QT3_SUPPORT
- qt_compat_used = 0;
- qt_compat_resolved = 0;
- qt_tryAccelEvent = 0;
- qt_tryComposeUnicode = 0;
- qt_dispatchAccelEvent = 0;
-#endif
-#if defined(Q_WS_QWS) && !defined(QT_NO_DIRECTPAINTER)
- directPainters = 0;
-#endif
-
-#ifndef QT_NO_GESTURES
- gestureManager = 0;
- gestureWidget = 0;
-#endif // QT_NO_GESTURES
-
-#if defined(Q_WS_X11) || defined(Q_WS_WIN)
- move_cursor = 0;
- copy_cursor = 0;
- link_cursor = 0;
-#endif
-#if defined(Q_WS_WIN)
- ignore_cursor = 0;
-#endif
-
- if (!self)
- self = this;
-}
-
-QApplicationPrivate::~QApplicationPrivate()
-{
- if (self == this)
- self = 0;
-}
-
-/*!
- \class QApplication
- \brief The QApplication class manages the GUI application's control
- flow and main settings.
-
- QApplication contains the main event loop, where all events from the window
- system and other sources are processed and dispatched. It also handles the
- application's initialization, finalization, and provides session
- management. In addition, QApplication handles most of the system-wide and
- application-wide settings.
-
- For any GUI application using Qt, there is precisely \bold one QApplication
- object, no matter whether the application has 0, 1, 2 or more windows at
- any given time. For non-GUI Qt applications, use QCoreApplication instead,
- as it does not depend on the \l QtGui library.
-
- The QApplication object is accessible through the instance() function that
- returns a pointer equivalent to the global qApp pointer.
-
- QApplication's main areas of responsibility are:
- \list
- \o It initializes the application with the user's desktop settings
- such as palette(), font() and doubleClickInterval(). It keeps
- track of these properties in case the user changes the desktop
- globally, for example through some kind of control panel.
-
- \o It performs event handling, meaning that it receives events
- from the underlying window system and dispatches them to the
- relevant widgets. By using sendEvent() and postEvent() you can
- send your own events to widgets.
-
- \o It parses common command line arguments and sets its internal
- state accordingly. See the \l{QApplication::QApplication()}
- {constructor documentation} below for more details.
-
- \o It defines the application's look and feel, which is
- encapsulated in a QStyle object. This can be changed at runtime
- with setStyle().
-
- \o It specifies how the application is to allocate colors. See
- setColorSpec() for details.
-
- \o It provides localization of strings that are visible to the
- user via translate().
-
- \o It provides some magical objects like the desktop() and the
- clipboard().
-
- \o It knows about the application's windows. You can ask which
- widget is at a certain position using widgetAt(), get a list of
- topLevelWidgets() and closeAllWindows(), etc.
-
- \o It manages the application's mouse cursor handling, see
- setOverrideCursor()
-
- \o On the X window system, it provides functions to flush and sync
- the communication stream, see flushX() and syncX().
-
- \o It provides support for sophisticated \l{Session Management}
- {session management}. This makes it possible for applications
- to terminate gracefully when the user logs out, to cancel a
- shutdown process if termination isn't possible and even to
- preserve the entire application's state for a future session.
- See isSessionRestored(), sessionId() and commitData() and
- saveState() for details.
- \endlist
-
- Since the QApplication object does so much initialization, it \e{must} be
- created before any other objects related to the user interface are created.
- QApplication also deals with common command line arguments. Hence, it is
- usually a good idea to create it \e before any interpretation or
- modification of \c argv is done in the application itself.
-
- \table
- \header
- \o{2,1} Groups of functions
-
- \row
- \o System settings
- \o desktopSettingsAware(),
- setDesktopSettingsAware(),
- cursorFlashTime(),
- setCursorFlashTime(),
- doubleClickInterval(),
- setDoubleClickInterval(),
- setKeyboardInputInterval(),
- wheelScrollLines(),
- setWheelScrollLines(),
- palette(),
- setPalette(),
- font(),
- setFont(),
- fontMetrics().
-
- \row
- \o Event handling
- \o exec(),
- processEvents(),
- exit(),
- quit().
- sendEvent(),
- postEvent(),
- sendPostedEvents(),
- removePostedEvents(),
- hasPendingEvents(),
- notify(),
- macEventFilter(),
- qwsEventFilter(),
- x11EventFilter(),
- x11ProcessEvent(),
- winEventFilter().
-
- \row
- \o GUI Styles
- \o style(),
- setStyle().
-
- \row
- \o Color usage
- \o colorSpec(),
- setColorSpec(),
- qwsSetCustomColors().
-
- \row
- \o Text handling
- \o installTranslator(),
- removeTranslator()
- translate().
-
- \row
- \o Widgets
- \o allWidgets(),
- topLevelWidgets(),
- desktop(),
- activePopupWidget(),
- activeModalWidget(),
- clipboard(),
- focusWidget(),
- activeWindow(),
- widgetAt().
-
- \row
- \o Advanced cursor handling
- \o overrideCursor(),
- setOverrideCursor(),
- restoreOverrideCursor().
-
- \row
- \o X Window System synchronization
- \o flushX(),
- syncX().
-
- \row
- \o Session management
- \o isSessionRestored(),
- sessionId(),
- commitData(),
- saveState().
-
- \row
- \o Miscellaneous
- \o closeAllWindows(),
- startingUp(),
- closingDown(),
- type().
- \endtable
-
- \sa QCoreApplication, QAbstractEventDispatcher, QEventLoop, QSettings
-*/
-
-/*!
- \enum QApplication::Type
-
- \value Tty a console application
- \value GuiClient a GUI client application
- \value GuiServer a GUI server application (for Qt for Embedded Linux)
-*/
-
-/*!
- \enum QApplication::ColorSpec
-
- \value NormalColor the default color allocation policy
- \value CustomColor the same as NormalColor for X11; allocates colors
- to a palette on demand under Windows
- \value ManyColor the right choice for applications that use thousands of
- colors
-
- See setColorSpec() for full details.
-*/
-
-/*!
- \fn QWidget *QApplication::topLevelAt(const QPoint &point)
-
- Returns the top-level widget at the given \a point; returns 0 if
- there is no such widget.
-*/
-
-/*!
- \fn QWidget *QApplication::topLevelAt(int x, int y)
-
- \overload
-
- Returns the top-level widget at the point (\a{x}, \a{y}); returns
- 0 if there is no such widget.
-*/
-
-
-/*
- The qt_init() and qt_cleanup() functions are implemented in the
- qapplication_xyz.cpp file.
-*/
-
-void qt_init(QApplicationPrivate *priv, int type
-#ifdef Q_WS_X11
- , Display *display = 0, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0
-#endif
- );
-void qt_cleanup();
-
-Qt::MouseButtons QApplicationPrivate::mouse_buttons = Qt::NoButton;
-Qt::KeyboardModifiers QApplicationPrivate::modifier_buttons = Qt::NoModifier;
-
-QStyle *QApplicationPrivate::app_style = 0; // default application style
-QString QApplicationPrivate::styleOverride; // style override
-
-#ifndef QT_NO_STYLE_STYLESHEET
-QString QApplicationPrivate::styleSheet; // default application stylesheet
-#endif
-QPointer<QWidget> QApplicationPrivate::leaveAfterRelease = 0;
-
-int QApplicationPrivate::app_cspec = QApplication::NormalColor;
-QPalette *QApplicationPrivate::app_pal = 0; // default application palette
-QPalette *QApplicationPrivate::sys_pal = 0; // default system palette
-QPalette *QApplicationPrivate::set_pal = 0; // default palette set by programmer
-
-QGraphicsSystem *QApplicationPrivate::graphics_system = 0; // default graphics system
-#if defined(Q_WS_QPA)
-QPlatformIntegration *QApplicationPrivate::platform_integration = 0;
-#endif
-QString QApplicationPrivate::graphics_system_name; // graphics system id - for delayed initialization
-bool QApplicationPrivate::runtime_graphics_system = false;
-
-Q_GLOBAL_STATIC(QMutex, applicationFontMutex)
-QFont *QApplicationPrivate::app_font = 0; // default application font
-QFont *QApplicationPrivate::sys_font = 0; // default system font
-QFont *QApplicationPrivate::set_font = 0; // default font set by programmer
-
-QIcon *QApplicationPrivate::app_icon = 0;
-QWidget *QApplicationPrivate::main_widget = 0; // main application widget
-QWidget *QApplicationPrivate::focus_widget = 0; // has keyboard input focus
-QWidget *QApplicationPrivate::hidden_focus_widget = 0; // will get keyboard input focus after show()
-QWidget *QApplicationPrivate::active_window = 0; // toplevel with keyboard focus
-bool QApplicationPrivate::obey_desktop_settings = true; // use winsys resources
-int QApplicationPrivate::cursor_flash_time = 1000; // text caret flash time
-int QApplicationPrivate::mouse_double_click_time = 400; // mouse dbl click limit
-int QApplicationPrivate::keyboard_input_time = 400; // keyboard input interval
-#ifndef QT_NO_WHEELEVENT
-int QApplicationPrivate::wheel_scroll_lines; // number of lines to scroll
-#endif
-bool qt_is_gui_used;
-bool Q_GUI_EXPORT qt_tab_all_widgets = true;
-bool qt_in_tab_key_event = false;
-int qt_antialiasing_threshold = -1;
-static int drag_time = 500;
-#ifndef QT_GUI_DRAG_DISTANCE
-#define QT_GUI_DRAG_DISTANCE 4
-#endif
-#ifdef Q_OS_SYMBIAN
-// The screens are a bit too small to for your thumb when using only 4 pixels drag distance.
-static int drag_distance = 12; //XXX move to qplatformdefs.h
-#else
-static int drag_distance = QT_GUI_DRAG_DISTANCE;
-#endif
-static Qt::LayoutDirection layout_direction = Qt::LeftToRight;
-QSize QApplicationPrivate::app_strut = QSize(0,0); // no default application strut
-bool QApplicationPrivate::animate_ui = true;
-bool QApplicationPrivate::animate_menu = false;
-bool QApplicationPrivate::fade_menu = false;
-bool QApplicationPrivate::animate_combo = false;
-bool QApplicationPrivate::animate_tooltip = false;
-bool QApplicationPrivate::fade_tooltip = false;
-bool QApplicationPrivate::animate_toolbox = false;
-bool QApplicationPrivate::widgetCount = false;
-bool QApplicationPrivate::load_testability = false;
-QString QApplicationPrivate::qmljs_debug_arguments;
-#ifdef QT_KEYPAD_NAVIGATION
-# ifdef Q_OS_SYMBIAN
-Qt::NavigationMode QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadDirectional;
-# else
-Qt::NavigationMode QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadTabOrder;
-# endif
-QWidget *QApplicationPrivate::oldEditFocus = 0;
-#endif
-
-bool qt_tabletChokeMouse = false;
-static bool force_reverse = false;
-
-inline bool QApplicationPrivate::isAlien(QWidget *widget)
-{
- if (!widget)
- return false;
-#if defined(Q_WS_QWS) || defined(Q_WS_QPA)
- return !widget->isWindow()
-# ifdef Q_BACKINGSTORE_SUBSURFACES
- && !(widget->d_func()->maybeTopData() && widget->d_func()->maybeTopData()->windowSurface)
-# endif
- ;
-#else
- return !widget->internalWinId();
-#endif
-}
-
-// ######## move to QApplicationPrivate
-// Default application palettes and fonts (per widget type)
-Q_GLOBAL_STATIC(PaletteHash, app_palettes)
-PaletteHash *qt_app_palettes_hash()
-{
- return app_palettes();
-}
-
-Q_GLOBAL_STATIC(FontHash, app_fonts)
-FontHash *qt_app_fonts_hash()
-{
- return app_fonts();
-}
-
-QWidgetList *QApplicationPrivate::popupWidgets = 0; // has keyboard input focus
-
-QDesktopWidget *qt_desktopWidget = 0; // root window widgets
-#ifndef QT_NO_CLIPBOARD
-QClipboard *qt_clipboard = 0; // global clipboard object
-#endif
-QWidgetList * qt_modal_stack=0; // stack of modal widgets
-
-/*!
- \internal
-*/
-void QApplicationPrivate::process_cmdline()
-{
- // process platform-indep command line
- if (!qt_is_gui_used || !argc)
- return;
-
- int i, j;
-
- j = 1;
- for (i=1; i<argc; i++) { // if you add anything here, modify QCoreApplication::arguments()
- if (argv[i] && *argv[i] != '-') {
- argv[j++] = argv[i];
- continue;
- }
- QByteArray arg = argv[i];
- arg = arg;
- QString s;
- if (arg == "-qdevel" || arg == "-qdebug") {
- // obsolete argument
- } else if (arg.indexOf("-qmljsdebugger=", 0) != -1) {
- qmljs_debug_arguments = QString::fromLocal8Bit(arg.right(arg.length() - 15));
- } else if (arg.indexOf("-style=", 0) != -1) {
- s = QString::fromLocal8Bit(arg.right(arg.length() - 7).toLower());
- } else if (arg == "-style" && i < argc-1) {
- s = QString::fromLocal8Bit(argv[++i]).toLower();
-#ifndef QT_NO_SESSIONMANAGER
- } else if (arg == "-session" && i < argc-1) {
- ++i;
- if (argv[i] && *argv[i]) {
- session_id = QString::fromLatin1(argv[i]);
- int p = session_id.indexOf(QLatin1Char('_'));
- if (p >= 0) {
- session_key = session_id.mid(p +1);
- session_id = session_id.left(p);
- }
- is_session_restored = true;
- }
-#endif
-#ifndef QT_NO_STYLE_STYLESHEET
- } else if (arg == "-stylesheet" && i < argc -1) {
- styleSheet = QLatin1String("file:///");
- styleSheet.append(QString::fromLocal8Bit(argv[++i]));
- } else if (arg.indexOf("-stylesheet=") != -1) {
- styleSheet = QLatin1String("file:///");
- styleSheet.append(QString::fromLocal8Bit(arg.right(arg.length() - 12)));
-#endif
- } else if (qstrcmp(arg, "-reverse") == 0) {
- force_reverse = true;
- QApplication::setLayoutDirection(Qt::RightToLeft);
- } else if (qstrcmp(arg, "-widgetcount") == 0) {
- widgetCount = true;
- } else if (qstrcmp(arg, "-testability") == 0) {
- load_testability = true;
- } else if (arg == "-graphicssystem" && i < argc-1) {
- graphics_system_name = QString::fromLocal8Bit(argv[++i]);
- } else {
- argv[j++] = argv[i];
- }
- if (!s.isEmpty()) {
- if (app_style) {
- delete app_style;
- app_style = 0;
- }
- styleOverride = s;
- }
- }
-
- if(j < argc) {
- argv[j] = 0;
- argc = j;
- }
-}
-
-/*!
- Initializes the window system and constructs an application object with
- \a argc command line arguments in \a argv.
-
- \warning The data referred to by \a argc and \a argv must stay valid for
- the entire lifetime of the QApplication object. In addition, \a argc must
- be greater than zero and \a argv must contain at least one valid character
- string.
-
- The global \c qApp pointer refers to this application object. Only one
- application object should be created.
-
- This application object must be constructed before any \l{QPaintDevice}
- {paint devices} (including widgets, pixmaps, bitmaps etc.).
-
- \note \a argc and \a argv might be changed as Qt removes command line
- arguments that it recognizes.
-
- Qt debugging options (not available if Qt was compiled without the QT_DEBUG
- flag defined):
- \list
- \o -nograb, tells Qt that it must never grab the mouse or the
- keyboard.
- \o -dograb (only under X11), running under a debugger can cause an
- implicit -nograb, use -dograb to override.
- \o -sync (only under X11), switches to synchronous mode for
- debugging.
- \endlist
-
- See \l{Debugging Techniques} for a more detailed explanation.
-
- All Qt programs automatically support the following command line options:
- \list
- \o -style= \e style, sets the application GUI style. Possible values
- are \c motif, \c windows, and \c platinum. If you compiled Qt with
- additional styles or have additional styles as plugins these will
- be available to the \c -style command line option.
- \o -style \e style, is the same as listed above.
- \o -stylesheet= \e stylesheet, sets the application \l styleSheet. The
- value must be a path to a file that contains the Style Sheet.
- \note Relative URLs in the Style Sheet file are relative to the
- Style Sheet file's path.
- \o -stylesheet \e stylesheet, is the same as listed above.
- \o -session= \e session, restores the application from an earlier
- \l{Session Management}{session}.
- \o -session \e session, is the same as listed above.
- \o -widgetcount, prints debug message at the end about number of
- widgets left undestroyed and maximum number of widgets existed at
- the same time
- \o -reverse, sets the application's layout direction to
- Qt::RightToLeft
- \o -graphicssystem, sets the backend to be used for on-screen widgets
- and QPixmaps. Available options are \c{raster} and \c{opengl}.
- \o -qmljsdebugger=, activates the QML/JS debugger with a specified port.
- The value must be of format port:1234[,block], where block is optional
- and will make the application wait until a debugger connects to it.
- \endlist
-
- The X11 version of Qt supports some traditional X11 command line options:
- \list
- \o -display \e display, sets the X display (default is $DISPLAY).
- \o -geometry \e geometry, sets the client geometry of the first window
- that is shown.
- \o -fn or \c -font \e font, defines the application font. The font
- should be specified using an X logical font description. Note that
- this option is ignored when Qt is built with fontconfig support enabled.
- \o -bg or \c -background \e color, sets the default background color
- and an application palette (light and dark shades are calculated).
- \o -fg or \c -foreground \e color, sets the default foreground color.
- \o -btn or \c -button \e color, sets the default button color.
- \o -name \e name, sets the application name.
- \o -title \e title, sets the application title.
- \o -visual \c TrueColor, forces the application to use a TrueColor
- visual on an 8-bit display.
- \o -ncols \e count, limits the number of colors allocated in the color
- cube on an 8-bit display, if the application is using the
- QApplication::ManyColor color specification. If \e count is 216
- then a 6x6x6 color cube is used (i.e. 6 levels of red, 6 of green,
- and 6 of blue); for other values, a cube approximately proportional
- to a 2x3x1 cube is used.
- \o -cmap, causes the application to install a private color map on an
- 8-bit display.
- \o -im, sets the input method server (equivalent to setting the
- XMODIFIERS environment variable)
- \o -inputstyle, defines how the input is inserted into the given
- widget, e.g., \c onTheSpot makes the input appear directly in the
- widget, while \c overTheSpot makes the input appear in a box
- floating over the widget and is not inserted until the editing is
- done.
- \endlist
-
- \section1 X11 Notes
-
- If QApplication fails to open the X11 display, it will terminate
- the process. This behavior is consistent with most X11
- applications.
-
- \sa arguments()
-*/
-
-QApplication::QApplication(int &argc, char **argv)
- : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient, 0x040000))
-{ Q_D(QApplication); d->construct(); }
-
-QApplication::QApplication(int &argc, char **argv, int _internal)
- : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient, _internal))
-{ Q_D(QApplication); d->construct(); }
-
-
-/*!
- Constructs an application object with \a argc command line arguments in
- \a argv. If \a GUIenabled is true, a GUI application is constructed,
- otherwise a non-GUI (console) application is created.
-
- \warning The data referred to by \a argc and \a argv must stay valid for
- the entire lifetime of the QApplication object. In addition, \a argc must
- be greater than zero and \a argv must contain at least one valid character
- string.
-
- Set \a GUIenabled to false for programs without a graphical user interface
- that should be able to run without a window system.
-
- On X11, the window system is initialized if \a GUIenabled is true. If
- \a GUIenabled is false, the application does not connect to the X server.
- On Windows and Mac OS, currently the window system is always initialized,
- regardless of the value of GUIenabled. This may change in future versions
- of Qt.
-
- The following example shows how to create an application that uses a
- graphical interface when available.
-
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 0
-*/
-
-QApplication::QApplication(int &argc, char **argv, bool GUIenabled )
- : QCoreApplication(*new QApplicationPrivate(argc, argv, GUIenabled ? GuiClient : Tty, 0x040000))
-{ Q_D(QApplication); d->construct(); }
-
-QApplication::QApplication(int &argc, char **argv, bool GUIenabled , int _internal)
- : QCoreApplication(*new QApplicationPrivate(argc, argv, GUIenabled ? GuiClient : Tty, _internal))
-{ Q_D(QApplication); d->construct();}
-
-
-
-/*!
- Constructs an application object with \a argc command line arguments in
- \a argv.
-
- \warning The data referred to by \a argc and \a argv must stay valid for
- the entire lifetime of the QApplication object. In addition, \a argc must
- be greater than zero and \a argv must contain at least one valid character
- string.
-
- With Qt for Embedded Linux, passing QApplication::GuiServer for \a type
- makes this application the server (equivalent to running with the
- \c -qws option).
-*/
-QApplication::QApplication(int &argc, char **argv, Type type)
- : QCoreApplication(*new QApplicationPrivate(argc, argv, type, 0x040000))
-{ Q_D(QApplication); d->construct(); }
-
-QApplication::QApplication(int &argc, char **argv, Type type , int _internal)
- : QCoreApplication(*new QApplicationPrivate(argc, argv, type, _internal))
-{ Q_D(QApplication); d->construct(); }
-
-#if defined(Q_WS_X11) && !defined(QT_NO_EGL)
-static int qt_matchLibraryName(dl_phdr_info *info, size_t, void *data)
-{
- const char *name = static_cast<const char *>(data);
- return strstr(info->dlpi_name, name) != 0;
-}
-#endif
-
-/*!
- \internal
-*/
-void QApplicationPrivate::construct(
-#ifdef Q_WS_X11
- Display *dpy, Qt::HANDLE visual, Qt::HANDLE cmap
-#endif
- )
-{
- initResources();
-
- qt_is_gui_used = (qt_appType != QApplication::Tty);
- process_cmdline();
- // the environment variable has the lowest precedence of runtime graphicssystem switches
- if (graphics_system_name.isEmpty())
- graphics_system_name = QString::fromLocal8Bit(qgetenv("QT_GRAPHICSSYSTEM"));
-
-#if defined(Q_WS_X11) && !defined(QT_NO_EGL)
- if (graphics_system_name.isEmpty()) {
- bool linksWithMeeGoTouch = dl_iterate_phdr(qt_matchLibraryName, const_cast<char *>("libmeegotouchcore"));
- bool linksWithMeeGoGraphicsSystemHelper = dl_iterate_phdr(qt_matchLibraryName, const_cast<char *>("libQtMeeGoGraphicsSystemHelper"));
-
- if (linksWithMeeGoTouch && !linksWithMeeGoGraphicsSystemHelper) {
- qWarning("Running non-meego graphics system enabled MeeGo touch, forcing native graphicssystem\n");
- graphics_system_name = QLatin1String("native");
- }
- }
-#endif
-
- // Must be called before initialize()
- qt_init(this, qt_appType
-#ifdef Q_WS_X11
- , dpy, visual, cmap
-#endif
- );
- initialize();
- eventDispatcher->startingUp();
-
-#ifdef QT_EVAL
- extern void qt_gui_eval_init(uint);
- qt_gui_eval_init(application_type);
-#endif
-
-#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE)
- symbianInit();
-#endif
-
-#ifndef QT_NO_LIBRARY
- if(load_testability) {
- QLibrary testLib(QLatin1String("qttestability"));
- if (testLib.load()) {
- typedef void (*TasInitialize)(void);
- TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init");
-#ifdef Q_OS_SYMBIAN
- // resolving method by name does not work on Symbian OS so need to use ordinal
- if(!initFunction) {
- initFunction = (TasInitialize)testLib.resolve("1");
- }
-#endif
- if (initFunction) {
- initFunction();
- } else {
- qCritical("Library qttestability resolve failed!");
- }
- } else {
- qCritical("Library qttestability load failed!");
- }
- }
-
- //make sure the plugin is loaded
- if (qt_is_gui_used)
- qt_guiPlatformPlugin();
-#endif
-}
-
-#if defined(Q_WS_X11)
-// ### a string literal is a cont char*
-// ### using it as a char* is wrong and could lead to segfaults
-// ### if aargv is modified someday
-// ########## make it work with argc == argv == 0
-static int aargc = 1;
-static char *aargv[] = { (char*)"unknown", 0 };
-
-/*!
- \fn QApplication::QApplication(Display* display, Qt::HANDLE visual, Qt::HANDLE colormap)
-
- Creates an application, given an already open display \a display. If
- \a visual and \a colormap are non-zero, the application will use those
- values as the default Visual and Colormap contexts.
-
- \warning Qt only supports TrueColor visuals at depths higher than 8
- bits-per-pixel.
-
- This function is only available on X11.
-*/
-QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap)
- : QCoreApplication(*new QApplicationPrivate(aargc, aargv, GuiClient, 0x040000))
-{
- if (! dpy)
- qWarning("QApplication: Invalid Display* argument");
- Q_D(QApplication);
- d->construct(dpy, visual, colormap);
-}
-
-QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap, int _internal)
- : QCoreApplication(*new QApplicationPrivate(aargc, aargv, GuiClient, _internal))
-{
- if (! dpy)
- qWarning("QApplication: Invalid Display* argument");
- Q_D(QApplication);
- d->construct(dpy, visual, colormap);
- QApplicationPrivate::app_compile_version = _internal;
-}
-
-/*!
- \fn QApplication::QApplication(Display *display, int &argc, char **argv,
- Qt::HANDLE visual, Qt::HANDLE colormap)
-
- Creates an application, given an already open \a display and using \a argc
- command line arguments in \a argv. If \a visual and \a colormap are
- non-zero, the application will use those values as the default Visual
- and Colormap contexts.
-
- \warning Qt only supports TrueColor visuals at depths higher than 8
- bits-per-pixel.
-
- This function is only available on X11.
-*/
-QApplication::QApplication(Display *dpy, int &argc, char **argv,
- Qt::HANDLE visual, Qt::HANDLE colormap)
- : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient, 0x040000))
-{
- if (! dpy)
- qWarning("QApplication: Invalid Display* argument");
- Q_D(QApplication);
- d->construct(dpy, visual, colormap);
-}
-
-QApplication::QApplication(Display *dpy, int &argc, char **argv,
- Qt::HANDLE visual, Qt::HANDLE colormap, int _internal)
- : QCoreApplication(*new QApplicationPrivate(argc, argv, GuiClient, _internal))
-{
- if (! dpy)
- qWarning("QApplication: Invalid Display* argument");
- Q_D(QApplication);
- d->construct(dpy, visual, colormap);
- QApplicationPrivate::app_compile_version = _internal;
-}
-
-#endif // Q_WS_X11
-
-extern void qInitDrawhelperAsm();
-extern void qInitImageConversions();
-extern int qRegisterGuiVariant();
-extern int qUnregisterGuiVariant();
-#ifndef QT_NO_STATEMACHINE
-extern int qRegisterGuiStateMachine();
-extern int qUnregisterGuiStateMachine();
-#endif
-
-/*!
- \fn void QApplicationPrivate::initialize()
-
- Initializes the QApplication object, called from the constructors.
-*/
-void QApplicationPrivate::initialize()
-{
- QWidgetPrivate::mapper = new QWidgetMapper;
- QWidgetPrivate::allWidgets = new QWidgetSet;
-
-#if !defined(Q_WS_X11) && !defined(Q_WS_QWS) && !defined(Q_WS_QPA)
- // initialize the graphics system - on X11 this is initialized inside
- // qt_init() in qapplication_x11.cpp because of several reasons.
- // On QWS, the graphics system is set by the QScreen plugin.
- // We don't use graphics systems in Qt QPA
- graphics_system = QGraphicsSystemFactory::create(graphics_system_name);
-#endif
-
- if (qt_appType != QApplication::Tty)
- (void) QApplication::style(); // trigger creation of application style
- // trigger registering of QVariant's GUI types
- qRegisterGuiVariant();
-#ifndef QT_NO_STATEMACHINE
- // trigger registering of QStateMachine's GUI types
- qRegisterGuiStateMachine();
-#endif
-
- is_app_running = true; // no longer starting up
-
- Q_Q(QApplication);
-#ifndef QT_NO_SESSIONMANAGER
- // connect to the session manager
- session_manager = new QSessionManager(q, session_id, session_key);
-#endif
-
- if (qgetenv("QT_USE_NATIVE_WINDOWS").toInt() > 0)
- q->setAttribute(Qt::AA_NativeWindows);
-
-#ifdef Q_WS_WINCE
-#ifdef QT_AUTO_MAXIMIZE_THRESHOLD
- autoMaximizeThreshold = QT_AUTO_MAXIMIZE_THRESHOLD;
-#else
- if (qt_wince_is_mobile())
- autoMaximizeThreshold = 50;
- else
- autoMaximizeThreshold = -1;
-#endif //QT_AUTO_MAXIMIZE_THRESHOLD
-#endif //Q_WS_WINCE
-
- // Set up which span functions should be used in raster engine...
- qInitDrawhelperAsm();
- // and QImage conversion functions
- qInitImageConversions();
-
-#ifndef QT_NO_WHEELEVENT
- QApplicationPrivate::wheel_scroll_lines = 3;
-#endif
-
- if (qt_is_gui_used)
- initializeMultitouch();
-}
-
-/*!
- Returns the type of application (\l Tty, GuiClient, or
- GuiServer). The type is set when constructing the QApplication
- object.
-*/
-QApplication::Type QApplication::type()
-{
- return qt_appType;
-}
-
-/*****************************************************************************
- Functions returning the active popup and modal widgets.
- *****************************************************************************/
-
-/*!
- Returns the active popup widget.
-
- A popup widget is a special top-level widget that sets the \c
- Qt::WType_Popup widget flag, e.g. the QMenu widget. When the application
- opens a popup widget, all events are sent to the popup. Normal widgets and
- modal widgets cannot be accessed before the popup widget is closed.
-
- Only other popup widgets may be opened when a popup widget is shown. The
- popup widgets are organized in a stack. This function returns the active
- popup widget at the top of the stack.
-
- \sa activeModalWidget(), topLevelWidgets()
-*/
-
-QWidget *QApplication::activePopupWidget()
-{
- return QApplicationPrivate::popupWidgets && !QApplicationPrivate::popupWidgets->isEmpty() ?
- QApplicationPrivate::popupWidgets->last() : 0;
-}
-
-
-/*!
- Returns the active modal widget.
-
- A modal widget is a special top-level widget which is a subclass of QDialog
- that specifies the modal parameter of the constructor as true. A modal
- widget must be closed before the user can continue with other parts of the
- program.
-
- Modal widgets are organized in a stack. This function returns the active
- modal widget at the top of the stack.
-
- \sa activePopupWidget(), topLevelWidgets()
-*/
-
-QWidget *QApplication::activeModalWidget()
-{
- return qt_modal_stack && !qt_modal_stack->isEmpty() ? qt_modal_stack->first() : 0;
-}
-
-/*!
- Cleans up any window system resources that were allocated by this
- application. Sets the global variable \c qApp to 0.
-*/
-
-QApplication::~QApplication()
-{
- Q_D(QApplication);
-
-#ifndef QT_NO_CLIPBOARD
- // flush clipboard contents
- if (qt_clipboard) {
- QEvent event(QEvent::Clipboard);
- QApplication::sendEvent(qt_clipboard, &event);
- }
-#endif
-
- //### this should probable be done even later
- qt_call_post_routines();
-
- // kill timers before closing down the dispatcher
- d->toolTipWakeUp.stop();
- d->toolTipFallAsleep.stop();
-
- d->eventDispatcher->closingDown();
- d->eventDispatcher = 0;
- QApplicationPrivate::is_app_closing = true;
- QApplicationPrivate::is_app_running = false;
-
- delete QWidgetPrivate::mapper;
- QWidgetPrivate::mapper = 0;
-
- // delete all widgets
- if (QWidgetPrivate::allWidgets) {
- QWidgetSet *mySet = QWidgetPrivate::allWidgets;
- QWidgetPrivate::allWidgets = 0;
- for (QWidgetSet::ConstIterator it = mySet->constBegin(); it != mySet->constEnd(); ++it) {
- register QWidget *w = *it;
- if (!w->parent()) // window
- w->destroy(true, true);
- }
- delete mySet;
- }
-
- delete qt_desktopWidget;
- qt_desktopWidget = 0;
-
-#ifndef QT_NO_CLIPBOARD
- delete qt_clipboard;
- qt_clipboard = 0;
-#endif
-
-#if defined(Q_WS_X11) || defined(Q_WS_WIN)
- delete d->move_cursor; d->move_cursor = 0;
- delete d->copy_cursor; d->copy_cursor = 0;
- delete d->link_cursor; d->link_cursor = 0;
-#endif
-#if defined(Q_WS_WIN)
- delete d->ignore_cursor; d->ignore_cursor = 0;
-#endif
-
- delete QApplicationPrivate::app_pal;
- QApplicationPrivate::app_pal = 0;
- delete QApplicationPrivate::sys_pal;
- QApplicationPrivate::sys_pal = 0;
- delete QApplicationPrivate::set_pal;
- QApplicationPrivate::set_pal = 0;
- app_palettes()->clear();
-
- {
- QMutexLocker locker(applicationFontMutex());
- delete QApplicationPrivate::app_font;
- QApplicationPrivate::app_font = 0;
- }
- delete QApplicationPrivate::sys_font;
- QApplicationPrivate::sys_font = 0;
- delete QApplicationPrivate::set_font;
- QApplicationPrivate::set_font = 0;
- app_fonts()->clear();
-
- delete QApplicationPrivate::app_style;
- QApplicationPrivate::app_style = 0;
- delete QApplicationPrivate::app_icon;
- QApplicationPrivate::app_icon = 0;
- delete QApplicationPrivate::graphics_system;
- QApplicationPrivate::graphics_system = 0;
-#ifndef QT_NO_CURSOR
- d->cursor_list.clear();
-#endif
-
-#ifndef QT_NO_DRAGANDDROP
- if (qt_is_gui_used)
- delete QDragManager::self();
-#endif
-
- d->cleanupMultitouch();
-
- qt_cleanup();
-
- if (QApplicationPrivate::widgetCount)
- qDebug("Widgets left: %i Max widgets: %i \n", QWidgetPrivate::instanceCounter, QWidgetPrivate::maxInstances);
-#ifndef QT_NO_SESSIONMANAGER
- delete d->session_manager;
- d->session_manager = 0;
-#endif //QT_NO_SESSIONMANAGER
-
- QApplicationPrivate::obey_desktop_settings = true;
- QApplicationPrivate::cursor_flash_time = 1000;
- QApplicationPrivate::mouse_double_click_time = 400;
- QApplicationPrivate::keyboard_input_time = 400;
-
- drag_time = 500;
- drag_distance = 4;
- layout_direction = Qt::LeftToRight;
- QApplicationPrivate::app_strut = QSize(0, 0);
- QApplicationPrivate::animate_ui = true;
- QApplicationPrivate::animate_menu = false;
- QApplicationPrivate::fade_menu = false;
- QApplicationPrivate::animate_combo = false;
- QApplicationPrivate::animate_tooltip = false;
- QApplicationPrivate::fade_tooltip = false;
- QApplicationPrivate::widgetCount = false;
-
-#ifndef QT_NO_STATEMACHINE
- // trigger unregistering of QStateMachine's GUI types
- qUnregisterGuiStateMachine();
-#endif
- // trigger unregistering of QVariant's GUI types
- qUnregisterGuiVariant();
-}
-
-
-/*!
- \fn QWidget *QApplication::widgetAt(const QPoint &point)
-
- Returns the widget at global screen position \a point, or 0 if there is no
- Qt widget there.
-
- This function can be slow.
-
- \sa QCursor::pos(), QWidget::grabMouse(), QWidget::grabKeyboard()
-*/
-QWidget *QApplication::widgetAt(const QPoint &p)
-{
- QWidget *window = QApplication::topLevelAt(p);
- if (!window)
- return 0;
-
- QWidget *child = 0;
-
- if (!window->testAttribute(Qt::WA_TransparentForMouseEvents))
- child = window->childAt(window->mapFromGlobal(p));
-
- if (child)
- return child;
-
- if (window->testAttribute(Qt::WA_TransparentForMouseEvents)) {
- //shoot a hole in the widget and try once again,
- //suboptimal on Qt for Embedded Linux where we do
- //know the stacking order of the toplevels.
- int x = p.x();
- int y = p.y();
- QRegion oldmask = window->mask();
- QPoint wpoint = window->mapFromGlobal(QPoint(x, y));
- QRegion newmask = (oldmask.isEmpty() ? QRegion(window->rect()) : oldmask)
- - QRegion(wpoint.x(), wpoint.y(), 1, 1);
- window->setMask(newmask);
- QWidget *recurse = 0;
- if (QApplication::topLevelAt(p) != window) // verify recursion will terminate
- recurse = widgetAt(x, y);
- if (oldmask.isEmpty())
- window->clearMask();
- else
- window->setMask(oldmask);
- return recurse;
- }
- return window;
-}
-
-/*!
- \fn QWidget *QApplication::widgetAt(int x, int y)
-
- \overload
-
- Returns the widget at global screen position (\a x, \a y), or 0 if there is
- no Qt widget there.
-*/
-
-/*!
- \fn void QApplication::setArgs(int argc, char **argv)
- \internal
-*/
-
-
-
-/*!
- \internal
-*/
-bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventList *postedEvents)
-{
- if ((event->type() == QEvent::UpdateRequest
-#ifdef QT3_SUPPORT
- || event->type() == QEvent::LayoutHint
-#endif
- || event->type() == QEvent::LayoutRequest
- || event->type() == QEvent::Resize
- || event->type() == QEvent::Move
- || event->type() == QEvent::LanguageChange
- || event->type() == QEvent::UpdateSoftKeys
- || event->type() == QEvent::InputMethod)) {
- for (int i = 0; i < postedEvents->size(); ++i) {
- const QPostEvent &cur = postedEvents->at(i);
- if (cur.receiver != receiver || cur.event == 0 || cur.event->type() != event->type())
- continue;
- if (cur.event->type() == QEvent::LayoutRequest
-#ifdef QT3_SUPPORT
- || cur.event->type() == QEvent::LayoutHint
-#endif
- || cur.event->type() == QEvent::UpdateRequest) {
- ;
- } else if (cur.event->type() == QEvent::Resize) {
- ((QResizeEvent *)(cur.event))->s = ((QResizeEvent *)event)->s;
- } else if (cur.event->type() == QEvent::Move) {
- ((QMoveEvent *)(cur.event))->p = ((QMoveEvent *)event)->p;
- } else if (cur.event->type() == QEvent::LanguageChange) {
- ;
- } else if (cur.event->type() == QEvent::UpdateSoftKeys) {
- ;
- } else if ( cur.event->type() == QEvent::InputMethod ) {
- *(QInputMethodEvent *)(cur.event) = *(QInputMethodEvent *)event;
- } else {
- continue;
- }
- delete event;
- return true;
- }
- return false;
- }
- return QCoreApplication::compressEvent(event, receiver, postedEvents);
-}
-
-/*!
- \property QApplication::styleSheet
- \brief the application style sheet
- \since 4.2
-
- By default, this property returns an empty string unless the user specifies
- the \c{-stylesheet} option on the command line when running the application.
-
- \sa QWidget::setStyle(), {Qt Style Sheets}
-*/
-
-/*!
- \property QApplication::autoMaximizeThreshold
- \since 4.4
- \brief defines a threshold for auto maximizing widgets
-
- \bold{The auto maximize threshold is only available as part of Qt for
- Windows CE.}
-
- This property defines a threshold for the size of a window as a percentage
- of the screen size. If the minimum size hint of a window exceeds the
- threshold, calling show() will cause the window to be maximized
- automatically.
-
- Setting the threshold to 100 or greater means that the widget will always
- be maximized. Alternatively, setting the threshold to 50 means that the
- widget will be maximized only if the vertical minimum size hint is at least
- 50% of the vertical screen size.
-
- Setting the threshold to -1 disables the feature.
-
- On Windows CE the default is -1 (i.e., it is disabled).
- On Windows Mobile the default is 40.
-*/
-
-/*!
- \property QApplication::autoSipEnabled
- \since 4.5
- \brief toggles automatic SIP (software input panel) visibility
-
- Set this property to \c true to automatically display the SIP when entering
- widgets that accept keyboard input. This property only affects widgets with
- the WA_InputMethodEnabled attribute set, and is typically used to launch
- a virtual keyboard on devices which have very few or no keys.
-
- \bold{ The property only has an effect on platforms which use software input
- panels, such as Windows CE and Symbian.}
-
- The default is platform dependent.
-*/
-
-#ifdef Q_WS_WINCE
-void QApplication::setAutoMaximizeThreshold(const int threshold)
-{
- QApplicationPrivate::autoMaximizeThreshold = threshold;
-}
-
-int QApplication::autoMaximizeThreshold() const
-{
- return QApplicationPrivate::autoMaximizeThreshold;
-}
-#endif
-
-void QApplication::setAutoSipEnabled(const bool enabled)
-{
- QApplicationPrivate::autoSipEnabled = enabled;
-}
-
-bool QApplication::autoSipEnabled() const
-{
- return QApplicationPrivate::autoSipEnabled;
-}
-
-#ifndef QT_NO_STYLE_STYLESHEET
-
-QString QApplication::styleSheet() const
-{
- return QApplicationPrivate::styleSheet;
-}
-
-void QApplication::setStyleSheet(const QString& styleSheet)
-{
- QApplicationPrivate::styleSheet = styleSheet;
- QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle*>(QApplicationPrivate::app_style);
- if (styleSheet.isEmpty()) { // application style sheet removed
- if (!proxy)
- return; // there was no stylesheet before
- setStyle(proxy->base);
- } else if (proxy) { // style sheet update, just repolish
- proxy->repolish(qApp);
- } else { // stylesheet set the first time
- QStyleSheetStyle *newProxy = new QStyleSheetStyle(QApplicationPrivate::app_style);
- QApplicationPrivate::app_style->setParent(newProxy);
- setStyle(newProxy);
- }
-}
-
-#endif // QT_NO_STYLE_STYLESHEET
-
-/*!
- Returns the application's style object.
-
- \sa setStyle(), QStyle
-*/
-QStyle *QApplication::style()
-{
- if (QApplicationPrivate::app_style)
- return QApplicationPrivate::app_style;
- if (!qt_is_gui_used) {
- Q_ASSERT(!"No style available in non-gui applications!");
- return 0;
- }
-
- if (!QApplicationPrivate::app_style) {
- // Compile-time search for default style
- //
- QString style;
-#ifdef QT_BUILD_INTERNAL
- QString envStyle = QString::fromLocal8Bit(qgetenv("QT_STYLE_OVERRIDE"));
-#else
- QString envStyle;
-#endif
- if (!QApplicationPrivate::styleOverride.isEmpty()) {
- style = QApplicationPrivate::styleOverride;
- } else if (!envStyle.isEmpty()) {
- style = envStyle;
- } else {
- style = QApplicationPrivate::desktopStyleKey();
- }
-
- QStyle *&app_style = QApplicationPrivate::app_style;
- app_style = QStyleFactory::create(style);
- if (!app_style) {
- QStringList styles = QStyleFactory::keys();
- for (int i = 0; i < styles.size(); ++i) {
- if ((app_style = QStyleFactory::create(styles.at(i))))
- break;
- }
- }
- if (!app_style) {
- Q_ASSERT(!"No styles available!");
- return 0;
- }
- }
- // take ownership of the style
- QApplicationPrivate::app_style->setParent(qApp);
-
- if (!QApplicationPrivate::sys_pal)
- QApplicationPrivate::setSystemPalette(QApplicationPrivate::app_style->standardPalette());
- if (QApplicationPrivate::set_pal) // repolish set palette with the new style
- QApplication::setPalette(*QApplicationPrivate::set_pal);
-
-#ifndef QT_NO_STYLE_STYLESHEET
- if (!QApplicationPrivate::styleSheet.isEmpty()) {
- qApp->setStyleSheet(QApplicationPrivate::styleSheet);
- } else
-#endif
- QApplicationPrivate::app_style->polish(qApp);
-
- return QApplicationPrivate::app_style;
-}
-
-/*!
- Sets the application's GUI style to \a style. Ownership of the style object
- is transferred to QApplication, so QApplication will delete the style
- object on application exit or when a new style is set and the old style is
- still the parent of the application object.
-
- Example usage:
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 1
-
- When switching application styles, the color palette is set back to the
- initial colors or the system defaults. This is necessary since certain
- styles have to adapt the color palette to be fully style-guide compliant.
-
- Setting the style before a palette has been se, i.e., before creating
- QApplication, will cause the application to use QStyle::standardPalette()
- for the palette.
-
- \warning Qt style sheets are currently not supported for custom QStyle
- subclasses. We plan to address this in some future release.
-
- \sa style(), QStyle, setPalette(), desktopSettingsAware()
-*/
-void QApplication::setStyle(QStyle *style)
-{
- if (!style || style == QApplicationPrivate::app_style)
- return;
-
- QWidgetList all = allWidgets();
-
- // clean up the old style
- if (QApplicationPrivate::app_style) {
- if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {
- for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) {
- register QWidget *w = *it;
- if (!(w->windowType() == Qt::Desktop) && // except desktop
- w->testAttribute(Qt::WA_WState_Polished)) { // has been polished
- QApplicationPrivate::app_style->unpolish(w);
- }
- }
- }
- QApplicationPrivate::app_style->unpolish(qApp);
- }
-
- QStyle *old = QApplicationPrivate::app_style; // save
-
-#ifndef QT_NO_STYLE_STYLESHEET
- if (!QApplicationPrivate::styleSheet.isEmpty() && !qobject_cast<QStyleSheetStyle *>(style)) {
- // we have a stylesheet already and a new style is being set
- QStyleSheetStyle *newProxy = new QStyleSheetStyle(style);
- style->setParent(newProxy);
- QApplicationPrivate::app_style = newProxy;
- } else
-#endif // QT_NO_STYLE_STYLESHEET
- QApplicationPrivate::app_style = style;
- QApplicationPrivate::app_style->setParent(qApp); // take ownership
-
- // take care of possible palette requirements of certain gui
- // styles. Do it before polishing the application since the style
- // might call QApplication::setPalette() itself
- if (QApplicationPrivate::set_pal) {
- QApplication::setPalette(*QApplicationPrivate::set_pal);
- } else if (QApplicationPrivate::sys_pal) {
- QApplicationPrivate::initializeWidgetPaletteHash();
- QApplicationPrivate::setPalette_helper(*QApplicationPrivate::sys_pal, /*className=*/0, /*clearWidgetPaletteHash=*/false);
- } else if (!QApplicationPrivate::sys_pal) {
- // Initialize the sys_pal if it hasn't happened yet...
- QApplicationPrivate::setSystemPalette(QApplicationPrivate::app_style->standardPalette());
- }
-
- // initialize the application with the new style
- QApplicationPrivate::app_style->polish(qApp);
-
- // re-polish existing widgets if necessary
- if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {
- for (QWidgetList::ConstIterator it1 = all.constBegin(); it1 != all.constEnd(); ++it1) {
- register QWidget *w = *it1;
- if (w->windowType() != Qt::Desktop && w->testAttribute(Qt::WA_WState_Polished)) {
- if (w->style() == QApplicationPrivate::app_style)
- QApplicationPrivate::app_style->polish(w); // repolish
-#ifndef QT_NO_STYLE_STYLESHEET
- else
- w->setStyleSheet(w->styleSheet()); // touch
-#endif
- }
- }
-
- for (QWidgetList::ConstIterator it2 = all.constBegin(); it2 != all.constEnd(); ++it2) {
- register QWidget *w = *it2;
- if (w->windowType() != Qt::Desktop && !w->testAttribute(Qt::WA_SetStyle)) {
- QEvent e(QEvent::StyleChange);
- QApplication::sendEvent(w, &e);
-#ifdef QT3_SUPPORT
- if (old)
- w->styleChange(*old);
-#endif
- w->update();
- }
- }
- }
-
-#ifndef QT_NO_STYLE_STYLESHEET
- if (QStyleSheetStyle *oldProxy = qobject_cast<QStyleSheetStyle *>(old)) {
- oldProxy->deref();
- } else
-#endif
- if (old && old->parent() == qApp) {
- delete old;
- }
-
- if (QApplicationPrivate::focus_widget) {
- QFocusEvent in(QEvent::FocusIn, Qt::OtherFocusReason);
- QApplication::sendEvent(QApplicationPrivate::focus_widget->style(), &in);
- QApplicationPrivate::focus_widget->update();
- }
-}
-
-/*!
- \overload
-
- Requests a QStyle object for \a style from the QStyleFactory.
-
- The string must be one of the QStyleFactory::keys(), typically one of
- "windows", "motif", "cde", "plastique", "windowsxp", or "macintosh". Style
- names are case insensitive.
-
- Returns 0 if an unknown \a style is passed, otherwise the QStyle object
- returned is set as the application's GUI style.
-
- \warning To ensure that the application's style is set correctly, it is
- best to call this function before the QApplication constructor, if
- possible.
-*/
-QStyle* QApplication::setStyle(const QString& style)
-{
- QStyle *s = QStyleFactory::create(style);
- if (!s)
- return 0;
-
- setStyle(s);
- return s;
-}
-
-/*!
- \since 4.5
-
- Sets the default graphics backend to \a system, which will be used for
- on-screen widgets and QPixmaps. The available systems are \c{"native"},
- \c{"raster"} and \c{"opengl"}.
-
- There are several ways to set the graphics backend, in order of decreasing
- precedence:
- \list
- \o the application commandline \c{-graphicssystem} switch
- \o QApplication::setGraphicsSystem()
- \o the QT_GRAPHICSSYSTEM environment variable
- \o the Qt configure \c{-graphicssystem} switch
- \endlist
- If the highest precedence switch sets an invalid name, the error will be
- ignored and the default backend will be used.
-
- \warning This function is only effective before the QApplication constructor
- is called.
-
- \note The \c{"opengl"} option is currently experimental.
-*/
-
-void QApplication::setGraphicsSystem(const QString &system)
-{
-#ifdef Q_WS_QPA
- Q_UNUSED(system);
-#else
-# ifdef QT_GRAPHICSSYSTEM_RUNTIME
- if (QApplicationPrivate::graphics_system_name == QLatin1String("runtime")) {
- QRuntimeGraphicsSystem *r =
- static_cast<QRuntimeGraphicsSystem *>(QApplicationPrivate::graphics_system);
- r->setGraphicsSystem(system);
- } else
-# endif
- QApplicationPrivate::graphics_system_name = system;
-#endif
-}
-
-/*!
- Returns the color specification.
-
- \sa QApplication::setColorSpec()
-*/
-
-int QApplication::colorSpec()
-{
- return QApplicationPrivate::app_cspec;
-}
-
-/*!
- Sets the color specification for the application to \a spec.
-
- The color specification controls how the application allocates colors when
- run on a display with a limited amount of colors, e.g. 8 bit / 256 color
- displays.
-
- The color specification must be set before you create the QApplication
- object.
-
- The options are:
- \list
- \o QApplication::NormalColor. This is the default color allocation
- strategy. Use this option if your application uses buttons, menus,
- texts and pixmaps with few colors. With this option, the
- application uses system global colors. This works fine for most
- applications under X11, but on the Windows platform, it may cause
- dithering of non-standard colors.
- \o QApplication::CustomColor. Use this option if your application
- needs a small number of custom colors. On X11, this option is the
- same as NormalColor. On Windows, Qt creates a Windows palette, and
- allocates colors to it on demand.
- \o QApplication::ManyColor. Use this option if your application is
- very color hungry, e.g., it requires thousands of colors. \br
- Under X11 the effect is:
- \list
- \o For 256-color displays which have at best a 256 color true
- color visual, the default visual is used, and colors are
- allocated from a color cube. The color cube is the 6x6x6
- (216 color) "Web palette" (the red, green, and blue
- components always have one of the following values: 0x00,
- 0x33, 0x66, 0x99, 0xCC, or 0xFF), but the number of colors
- can be changed by the \e -ncols option. The user can force
- the application to use the true color visual with the
- \l{QApplication::QApplication()}{-visual} option.
- \o For 256-color displays which have a true color visual with
- more than 256 colors, use that visual. Silicon Graphics X
- servers this feature, for example. They provide an 8 bit
- visual by default but can deliver true color when asked.
- \endlist
- On Windows, Qt creates a Windows palette, and fills it with a color
- cube.
- \endlist
-
- Be aware that the CustomColor and ManyColor choices may lead to colormap
- flashing: The foreground application gets (most) of the available colors,
- while the background windows will look less attractive.
-
- Example:
-
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 2
-
- \sa colorSpec()
-*/
-
-void QApplication::setColorSpec(int spec)
-{
- if (qApp)
- qWarning("QApplication::setColorSpec: This function must be "
- "called before the QApplication object is created");
- QApplicationPrivate::app_cspec = spec;
-}
-
-/*!
- \property QApplication::globalStrut
- \brief the minimum size that any GUI element that the user can interact
- with should have
-
- For example, no button should be resized to be smaller than the global
- strut size. The strut size should be considered when reimplementing GUI
- controls that may be used on touch-screens or similar I/O devices.
-
- Example:
-
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 3
-
- By default, this property contains a QSize object with zero width and height.
-*/
-QSize QApplication::globalStrut()
-{
- return QApplicationPrivate::app_strut;
-}
-
-void QApplication::setGlobalStrut(const QSize& strut)
-{
- QApplicationPrivate::app_strut = strut;
-}
-
-/*!
- Returns the application palette.
-
- \sa setPalette(), QWidget::palette()
-*/
-QPalette QApplication::palette()
-{
- if (!QApplicationPrivate::app_pal)
- QApplicationPrivate::app_pal = new QPalette(Qt::black);
- return *QApplicationPrivate::app_pal;
-}
-
-/*!
- \fn QPalette QApplication::palette(const QWidget* widget)
- \overload
-
- If a \a widget is passed, the default palette for the widget's class is
- returned. This may or may not be the application palette. In most cases
- there is no special palette for certain types of widgets, but one notable
- exception is the popup menu under Windows, if the user has defined a
- special background color for menus in the display settings.
-
- \sa setPalette(), QWidget::palette()
-*/
-QPalette QApplication::palette(const QWidget* w)
-{
- PaletteHash *hash = app_palettes();
- if (w && hash && hash->size()) {
- QHash<QByteArray, QPalette>::ConstIterator it = hash->constFind(w->metaObject()->className());
- if (it != hash->constEnd())
- return *it;
- for (it = hash->constBegin(); it != hash->constEnd(); ++it) {
- if (w->inherits(it.key()))
- return it.value();
- }
- }
- return palette();
-}
-
-/*!
- \overload
-
- Returns the palette for widgets of the given \a className.
-
- \sa setPalette(), QWidget::palette()
-*/
-QPalette QApplication::palette(const char *className)
-{
- if (!QApplicationPrivate::app_pal)
- palette();
- PaletteHash *hash = app_palettes();
- if (className && hash && hash->size()) {
- QHash<QByteArray, QPalette>::ConstIterator it = hash->constFind(className);
- if (it != hash->constEnd())
- return *it;
- }
- return *QApplicationPrivate::app_pal;
-}
-
-void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* className, bool clearWidgetPaletteHash)
-{
- QPalette pal = palette;
-
- if (QApplicationPrivate::app_style)
- QApplicationPrivate::app_style->polish(pal); // NB: non-const reference
-
- bool all = false;
- PaletteHash *hash = app_palettes();
- if (!className) {
- if (QApplicationPrivate::app_pal && pal.isCopyOf(*QApplicationPrivate::app_pal))
- return;
- if (!QApplicationPrivate::app_pal)
- QApplicationPrivate::app_pal = new QPalette(pal);
- else
- *QApplicationPrivate::app_pal = pal;
- if (hash && hash->size()) {
- all = true;
- if (clearWidgetPaletteHash)
- hash->clear();
- }
- } else if (hash) {
- hash->insert(className, pal);
- }
-
- if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {
- // Send ApplicationPaletteChange to qApp itself, and to the widgets.
- QEvent e(QEvent::ApplicationPaletteChange);
- QApplication::sendEvent(QApplication::instance(), &e);
-
- QWidgetList wids = QApplication::allWidgets();
- for (QWidgetList::ConstIterator it = wids.constBegin(); it != wids.constEnd(); ++it) {
- register QWidget *w = *it;
- if (all || (!className && w->isWindow()) || w->inherits(className)) // matching class
- QApplication::sendEvent(w, &e);
- }
-
- // Send to all scenes as well.
-#ifndef QT_NO_GRAPHICSVIEW
- QList<QGraphicsScene *> &scenes = qApp->d_func()->scene_list;
- for (QList<QGraphicsScene *>::ConstIterator it = scenes.constBegin();
- it != scenes.constEnd(); ++it) {
- QApplication::sendEvent(*it, &e);
- }
-#endif //QT_NO_GRAPHICSVIEW
- }
- if (!className && (!QApplicationPrivate::sys_pal || !palette.isCopyOf(*QApplicationPrivate::sys_pal))) {
- if (!QApplicationPrivate::set_pal)
- QApplicationPrivate::set_pal = new QPalette(palette);
- else
- *QApplicationPrivate::set_pal = palette;
- }
-}
-
-/*!
- Changes the default application palette to \a palette.
-
- If \a className is passed, the change applies only to widgets that inherit
- \a className (as reported by QObject::inherits()). If \a className is left
- 0, the change affects all widgets, thus overriding any previously set class
- specific palettes.
-
- The palette may be changed according to the current GUI style in
- QStyle::polish().
-
- \warning Do not use this function in conjunction with \l{Qt Style Sheets}.
- When using style sheets, the palette of a widget can be customized using
- the "color", "background-color", "selection-color",
- "selection-background-color" and "alternate-background-color".
-
- \note Some styles do not use the palette for all drawing, for instance, if
- they make use of native theme engines. This is the case for the Windows XP,
- Windows Vista, and Mac OS X styles.
-
- \sa QWidget::setPalette(), palette(), QStyle::polish()
-*/
-
-void QApplication::setPalette(const QPalette &palette, const char* className)
-{
- QApplicationPrivate::setPalette_helper(palette, className, /*clearWidgetPaletteHash=*/ true);
-}
-
-
-
-void QApplicationPrivate::setSystemPalette(const QPalette &pal)
-{
- QPalette adjusted;
-
-#if 0
- // adjust the system palette to avoid dithering
- QColormap cmap = QColormap::instance();
- if (cmap.depths() > 4 && cmap.depths() < 24) {
- for (int g = 0; g < QPalette::NColorGroups; g++)
- for (int i = 0; i < QPalette::NColorRoles; i++) {
- QColor color = pal.color((QPalette::ColorGroup)g, (QPalette::ColorRole)i);
- color = cmap.colorAt(cmap.pixel(color));
- adjusted.setColor((QPalette::ColorGroup)g, (QPalette::ColorRole) i, color);
- }
- }
-#else
- adjusted = pal;
-#endif
-
- if (!sys_pal)
- sys_pal = new QPalette(adjusted);
- else
- *sys_pal = adjusted;
-
-
- if (!QApplicationPrivate::set_pal)
- QApplication::setPalette(*sys_pal);
-}
-
-/*!
- Returns the default application font.
-
- \sa fontMetrics(), QWidget::font()
-*/
-QFont QApplication::font()
-{
- QMutexLocker locker(applicationFontMutex());
- if (!QApplicationPrivate::app_font)
- QApplicationPrivate::app_font = new QFont(QLatin1String("Helvetica"));
- return *QApplicationPrivate::app_font;
-}
-
-/*!
- \overload
-
- Returns the default font for the \a widget.
-
- \sa fontMetrics(), QWidget::setFont()
-*/
-
-QFont QApplication::font(const QWidget *widget)
-{
- FontHash *hash = app_fonts();
-
-#ifdef Q_WS_MAC
- // short circuit for small and mini controls
- if (widget->testAttribute(Qt::WA_MacSmallSize)) {
- return hash->value("QSmallFont");
- } else if (widget->testAttribute(Qt::WA_MacMiniSize)) {
- return hash->value("QMiniFont");
- }
-#endif
- if (widget && hash && hash->size()) {
- QHash<QByteArray, QFont>::ConstIterator it =
- hash->constFind(widget->metaObject()->className());
- if (it != hash->constEnd())
- return it.value();
- for (it = hash->constBegin(); it != hash->constEnd(); ++it) {
- if (widget->inherits(it.key()))
- return it.value();
- }
- }
- return font();
-}
-
-/*!
- \overload
-
- Returns the font for widgets of the given \a className.
-
- \sa setFont(), QWidget::font()
-*/
-QFont QApplication::font(const char *className)
-{
- FontHash *hash = app_fonts();
- if (className && hash && hash->size()) {
- QHash<QByteArray, QFont>::ConstIterator it = hash->constFind(className);
- if (it != hash->constEnd())
- return *it;
- }
- return font();
-}
-
-
-/*!
- Changes the default application font to \a font. If \a className is passed,
- the change applies only to classes that inherit \a className (as reported
- by QObject::inherits()).
-
- On application start-up, the default font depends on the window system. It
- can vary depending on both the window system version and the locale. This
- function lets you override the default font; but overriding may be a bad
- idea because, for example, some locales need extra large fonts to support
- their special characters.
-
- \warning Do not use this function in conjunction with \l{Qt Style Sheets}.
- The font of an application can be customized using the "font" style sheet
- property. To set a bold font for all QPushButtons, set the application
- styleSheet() as "QPushButton { font: bold }"
-
- \sa font(), fontMetrics(), QWidget::setFont()
-*/
-
-void QApplication::setFont(const QFont &font, const char *className)
-{
- bool all = false;
- FontHash *hash = app_fonts();
- if (!className) {
- QMutexLocker locker(applicationFontMutex());
- if (!QApplicationPrivate::app_font)
- QApplicationPrivate::app_font = new QFont(font);
- else
- *QApplicationPrivate::app_font = font;
- if (hash && hash->size()) {
- all = true;
- hash->clear();
- }
- } else if (hash) {
- hash->insert(className, font);
- }
- if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {
- // Send ApplicationFontChange to qApp itself, and to the widgets.
- QEvent e(QEvent::ApplicationFontChange);
- QApplication::sendEvent(QApplication::instance(), &e);
-
- QWidgetList wids = QApplication::allWidgets();
- for (QWidgetList::ConstIterator it = wids.constBegin(); it != wids.constEnd(); ++it) {
- register QWidget *w = *it;
- if (all || (!className && w->isWindow()) || w->inherits(className)) // matching class
- sendEvent(w, &e);
- }
-
-#ifndef QT_NO_GRAPHICSVIEW
- // Send to all scenes as well.
- QList<QGraphicsScene *> &scenes = qApp->d_func()->scene_list;
- for (QList<QGraphicsScene *>::ConstIterator it = scenes.constBegin();
- it != scenes.constEnd(); ++it) {
- QApplication::sendEvent(*it, &e);
- }
-#endif //QT_NO_GRAPHICSVIEW
- }
- if (!className && (!QApplicationPrivate::sys_font || !font.isCopyOf(*QApplicationPrivate::sys_font))) {
- if (!QApplicationPrivate::set_font)
- QApplicationPrivate::set_font = new QFont(font);
- else
- *QApplicationPrivate::set_font = font;
- }
-}
-
-/*! \internal
-*/
-void QApplicationPrivate::setSystemFont(const QFont &font)
-{
- if (!sys_font)
- sys_font = new QFont(font);
- else
- *sys_font = font;
-
- if (!QApplicationPrivate::set_font)
- QApplication::setFont(*sys_font);
-}
-
-/*! \internal
-*/
-QString QApplicationPrivate::desktopStyleKey()
-{
- return qt_guiPlatformPlugin()->styleName();
-}
-
-/*!
- \property QApplication::windowIcon
- \brief the default window icon
-
- \sa QWidget::setWindowIcon(), {Setting the Application Icon}
-*/
-QIcon QApplication::windowIcon()
-{
- return QApplicationPrivate::app_icon ? *QApplicationPrivate::app_icon : QIcon();
-}
-
-void QApplication::setWindowIcon(const QIcon &icon)
-{
- if (!QApplicationPrivate::app_icon)
- QApplicationPrivate::app_icon = new QIcon();
- *QApplicationPrivate::app_icon = icon;
- if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {
-#ifdef Q_WS_MAC
- void qt_mac_set_app_icon(const QPixmap &); //qapplication_mac.cpp
- QSize size = QApplicationPrivate::app_icon->actualSize(QSize(128, 128));
- qt_mac_set_app_icon(QApplicationPrivate::app_icon->pixmap(size));
-#endif
- QEvent e(QEvent::ApplicationWindowIconChange);
- QWidgetList all = QApplication::allWidgets();
- for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) {
- register QWidget *w = *it;
- if (w->isWindow())
- sendEvent(w, &e);
- }
- }
-}
-
-/*!
- Returns a list of the top-level widgets (windows) in the application.
-
- \note Some of the top-level widgets may be hidden, for example a tooltip if
- no tooltip is currently shown.
-
- Example:
-
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 4
-
- \sa allWidgets(), QWidget::isWindow(), QWidget::isHidden()
-*/
-QWidgetList QApplication::topLevelWidgets()
-{
- QWidgetList list;
- QWidgetList all = allWidgets();
-
- for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) {
- QWidget *w = *it;
- if (w->isWindow() && w->windowType() != Qt::Desktop)
- list.append(w);
- }
- return list;
-}
-
-/*!
- Returns a list of all the widgets in the application.
-
- The list is empty (QList::isEmpty()) if there are no widgets.
-
- \note Some of the widgets may be hidden.
-
- Example:
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 5
-
- \sa topLevelWidgets(), QWidget::isVisible()
-*/
-
-QWidgetList QApplication::allWidgets()
-{
- if (QWidgetPrivate::allWidgets)
- return QWidgetPrivate::allWidgets->toList();
- return QWidgetList();
-}
-
-/*!
- Returns the application widget that has the keyboard input focus, or 0 if
- no widget in this application has the focus.
-
- \sa QWidget::setFocus(), QWidget::hasFocus(), activeWindow(), focusChanged()
-*/
-
-QWidget *QApplication::focusWidget()
-{
- return QApplicationPrivate::focus_widget;
-}
-
-void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason)
-{
-#ifndef QT_NO_GRAPHICSVIEW
- if (focus && focus->window()->graphicsProxyWidget())
- return;
-#endif
-
- hidden_focus_widget = 0;
-
- if (focus != focus_widget) {
- if (focus && focus->isHidden()) {
- hidden_focus_widget = focus;
- return;
- }
-
- if (focus && (reason == Qt::BacktabFocusReason || reason == Qt::TabFocusReason)
- && qt_in_tab_key_event)
- focus->window()->setAttribute(Qt::WA_KeyboardFocusChange);
- else if (focus && reason == Qt::ShortcutFocusReason) {
- focus->window()->setAttribute(Qt::WA_KeyboardFocusChange);
- }
- QWidget *prev = focus_widget;
- focus_widget = focus;
-#ifndef QT_NO_IM
- if (prev && ((reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason
- && prev->testAttribute(Qt::WA_InputMethodEnabled))
- // Do reset the input context, in case the new focus widget won't accept keyboard input
- // or it is not created fully yet.
- || (focus_widget && (!focus_widget->testAttribute(Qt::WA_InputMethodEnabled)
- || !focus_widget->testAttribute(Qt::WA_WState_Created))))) {
- QInputContext *qic = prev->inputContext();
- if(qic) {
- qic->reset();
- qic->setFocusWidget(0);
- }
- }
-#endif //QT_NO_IM
-
- if(focus_widget)
- focus_widget->d_func()->setFocus_sys();
-
- if (reason != Qt::NoFocusReason) {
-
- //send events
- if (prev) {
-#ifdef QT_KEYPAD_NAVIGATION
- if (QApplication::keypadNavigationEnabled()) {
- if (prev->hasEditFocus() && reason != Qt::PopupFocusReason
-#ifdef Q_OS_SYMBIAN
- && reason != Qt::ActiveWindowFocusReason
-#endif
- )
- prev->setEditFocus(false);
- }
-#endif
-#ifndef QT_NO_IM
- if (focus) {
- QInputContext *prevIc;
- prevIc = prev->inputContext();
- if (prevIc && prevIc != focus->inputContext()) {
- QEvent closeSIPEvent(QEvent::CloseSoftwareInputPanel);
- QApplication::sendEvent(prev, &closeSIPEvent);
- }
- }
-#endif
- QFocusEvent out(QEvent::FocusOut, reason);
- QPointer<QWidget> that = prev;
- QApplication::sendEvent(prev, &out);
- if (that)
- QApplication::sendEvent(that->style(), &out);
- }
- if(focus && QApplicationPrivate::focus_widget == focus) {
-#ifndef QT_NO_IM
- if (focus->testAttribute(Qt::WA_InputMethodEnabled)) {
- QInputContext *qic = focus->inputContext();
- if (qic && focus->testAttribute(Qt::WA_WState_Created)
- && focus->isEnabled())
- qic->setFocusWidget(focus);
- }
-#endif //QT_NO_IM
- QFocusEvent in(QEvent::FocusIn, reason);
- QPointer<QWidget> that = focus;
- QApplication::sendEvent(focus, &in);
- if (that)
- QApplication::sendEvent(that->style(), &in);
- }
- emit qApp->focusChanged(prev, focus_widget);
- }
- }
-}
-
-
-/*!
- Returns the application top-level window that has the keyboard input focus,
- or 0 if no application window has the focus. There might be an
- activeWindow() even if there is no focusWidget(), for example if no widget
- in that window accepts key events.
-
- \sa QWidget::setFocus(), QWidget::hasFocus(), focusWidget()
-*/
-
-QWidget *QApplication::activeWindow()
-{
- return QApplicationPrivate::active_window;
-}
-
-/*!
- Returns display (screen) font metrics for the application font.
-
- \sa font(), setFont(), QWidget::fontMetrics(), QPainter::fontMetrics()
-*/
-
-QFontMetrics QApplication::fontMetrics()
-{
- return desktop()->fontMetrics();
-}
-
-
-/*!
- Closes all top-level windows.
-
- This function is particularly useful for applications with many top-level
- windows. It could, for example, be connected to a \gui{Exit} entry in the
- \gui{File} menu:
-
- \snippet examples/mainwindows/mdi/mainwindow.cpp 0
-
- The windows are closed in random order, until one window does not accept
- the close event. The application quits when the last window was
- successfully closed; this can be turned off by setting
- \l quitOnLastWindowClosed to false.
-
- \sa quitOnLastWindowClosed, lastWindowClosed(), QWidget::close(),
- QWidget::closeEvent(), lastWindowClosed(), quit(), topLevelWidgets(),
- QWidget::isWindow()
-*/
-void QApplication::closeAllWindows()
-{
- bool did_close = true;
- QWidget *w;
- while ((w = activeModalWidget()) && did_close) {
- if (!w->isVisible() || w->data->is_closing)
- break;
- did_close = w->close();
- }
- QWidgetList list = QApplication::topLevelWidgets();
- for (int i = 0; did_close && i < list.size(); ++i) {
- w = list.at(i);
- if (w->isVisible()
- && w->windowType() != Qt::Desktop
- && !w->data->is_closing) {
- did_close = w->close();
- list = QApplication::topLevelWidgets();
- i = -1;
- }
- }
-}
-
-/*!
- Displays a simple message box about Qt. The message includes the version
- number of Qt being used by the application.
-
- This is useful for inclusion in the \gui Help menu of an application, as
- shown in the \l{mainwindows/menus}{Menus} example.
-
- This function is a convenience slot for QMessageBox::aboutQt().
-*/
-void QApplication::aboutQt()
-{
-#ifndef QT_NO_MESSAGEBOX
- QMessageBox::aboutQt(
-#ifdef Q_WS_MAC
- 0
-#else
- activeWindow()
-#endif // Q_WS_MAC
- );
-#endif // QT_NO_MESSAGEBOX
-}
-
-
-/*!
- \fn void QApplication::lastWindowClosed()
-
- This signal is emitted from QApplication::exec() when the last visible
- primary window (i.e. window with no parent) with the Qt::WA_QuitOnClose
- attribute set is closed.
-
- By default,
-
- \list
- \o this attribute is set for all widgets except transient windows such
- as splash screens, tool windows, and popup menus
-
- \o QApplication implicitly quits when this signal is emitted.
- \endlist
-
- This feature can be turned off by setting \l quitOnLastWindowClosed to
- false.
-
- \sa QWidget::close()
-*/
-
-/*!
- \since 4.1
- \fn void QApplication::focusChanged(QWidget *old, QWidget *now)
-
- This signal is emitted when the widget that has keyboard focus changed from
- \a old to \a now, i.e., because the user pressed the tab-key, clicked into
- a widget or changed the active window. Both \a old and \a now can be the
- null-pointer.
-
- The signal is emitted after both widget have been notified about the change
- through QFocusEvent.
-
- \sa QWidget::setFocus(), QWidget::clearFocus(), Qt::FocusReason
-*/
-
-/*!
- \since 4.5
- \fn void QApplication::fontDatabaseChanged()
-
- This signal is emitted when application fonts are loaded or removed.
-
- \sa QFontDatabase::addApplicationFont(),
- QFontDatabase::addApplicationFontFromData(),
- QFontDatabase::removeAllApplicationFonts(),
- QFontDatabase::removeApplicationFont()
-*/
-
-#ifndef QT_NO_TRANSLATION
-static bool qt_detectRTLLanguage()
-{
- return force_reverse ^
- (QApplication::tr("QT_LAYOUT_DIRECTION",
- "Translate this string to the string 'LTR' in left-to-right"
- " languages or to 'RTL' in right-to-left languages (such as Hebrew"
- " and Arabic) to get proper widget layout.") == QLatin1String("RTL"));
-}
-#if defined(Q_WS_MAC)
-static const char *application_menu_strings[] = {
- QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Services"),
- QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide %1"),
- QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide Others"),
- QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Show All"),
- QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Preferences..."),
- QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Quit %1"),
- QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","About %1")
- };
-QString qt_mac_applicationmenu_string(int type)
-{
- QString menuString = QString::fromLatin1(application_menu_strings[type]);
- QString translated = qApp->translate("QMenuBar", application_menu_strings[type]);
- if (translated != menuString)
- return translated;
- else
- return qApp->translate("MAC_APPLICATION_MENU",
- application_menu_strings[type]);
-}
-#endif
-#endif
-
-/*!\reimp
-
-*/
-bool QApplication::event(QEvent *e)
-{
- Q_D(QApplication);
- if(e->type() == QEvent::Close) {
-#if defined(Q_OS_SYMBIAN)
- // In order to have proper application-exit effects on Symbian, certain
- // native APIs have to be called _before_ closing/destroying the widgets.
- bool effectStarted = qt_beginFullScreenEffect();
-#endif
- QCloseEvent *ce = static_cast<QCloseEvent*>(e);
- ce->accept();
- closeAllWindows();
-
- QWidgetList list = topLevelWidgets();
- for (int i = 0; i < list.size(); ++i) {
- QWidget *w = list.at(i);
- if (w->isVisible() && !(w->windowType() == Qt::Desktop) && !(w->windowType() == Qt::Popup) &&
- (!(w->windowType() == Qt::Dialog) || !w->parentWidget())) {
- ce->ignore();
- break;
- }
- }
- if (ce->isAccepted()) {
- return true;
- } else {
-#if defined(Q_OS_SYMBIAN)
- if (effectStarted)
- qt_abortFullScreenEffect();
-#endif
- }
- } else if(e->type() == QEvent::LanguageChange) {
-#ifndef QT_NO_TRANSLATION
- setLayoutDirection(qt_detectRTLLanguage()?Qt::RightToLeft:Qt::LeftToRight);
-#endif
-#if defined(QT_MAC_USE_COCOA)
- qt_mac_post_retranslateAppMenu();
-#endif
- QWidgetList list = topLevelWidgets();
- for (int i = 0; i < list.size(); ++i) {
- QWidget *w = list.at(i);
- if (!(w->windowType() == Qt::Desktop))
- postEvent(w, new QEvent(QEvent::LanguageChange));
- }
-#ifndef Q_OS_WIN
- } else if (e->type() == QEvent::LocaleChange) {
- // on Windows the event propagation is taken care by the
- // WM_SETTINGCHANGE event handler.
- QWidgetList list = topLevelWidgets();
- for (int i = 0; i < list.size(); ++i) {
- QWidget *w = list.at(i);
- if (!(w->windowType() == Qt::Desktop)) {
- if (!w->testAttribute(Qt::WA_SetLocale))
- w->d_func()->setLocale_helper(QLocale(), true);
- }
- }
-#endif
- } else if (e->type() == QEvent::Timer) {
- QTimerEvent *te = static_cast<QTimerEvent*>(e);
- Q_ASSERT(te != 0);
- if (te->timerId() == d->toolTipWakeUp.timerId()) {
- d->toolTipWakeUp.stop();
- if (d->toolTipWidget) {
- QWidget *w = d->toolTipWidget->window();
- // show tooltip if WA_AlwaysShowToolTips is set, or if
- // any ancestor of d->toolTipWidget is the active
- // window
- bool showToolTip = w->testAttribute(Qt::WA_AlwaysShowToolTips);
- while (w && !showToolTip) {
- showToolTip = w->isActiveWindow();
- w = w->parentWidget();
- w = w ? w->window() : 0;
- }
- if (showToolTip) {
- QHelpEvent e(QEvent::ToolTip, d->toolTipPos, d->toolTipGlobalPos);
- QApplication::sendEvent(d->toolTipWidget, &e);
- if (e.isAccepted())
- d->toolTipFallAsleep.start(2000, this);
- }
- }
- } else if (te->timerId() == d->toolTipFallAsleep.timerId()) {
- d->toolTipFallAsleep.stop();
- }
- }
- return QCoreApplication::event(e);
-}
-#if !defined(Q_WS_X11)
-
-// The doc and X implementation of this function is in qapplication_x11.cpp
-
-void QApplication::syncX() {} // do nothing
-
-#endif
-
-/*!
- \fn Qt::WindowsVersion QApplication::winVersion()
-
- Use \l QSysInfo::WindowsVersion instead.
-*/
-
-/*!
- \fn void QApplication::setActiveWindow(QWidget* active)
-
- Sets the active window to the \a active widget in response to a system
- event. The function is called from the platform specific event handlers.
-
- \warning This function does \e not set the keyboard focus to the active
- widget. Call QWidget::activateWindow() instead.
-
- It sets the activeWindow() and focusWidget() attributes and sends proper
- \l{QEvent::WindowActivate}{WindowActivate}/\l{QEvent::WindowDeactivate}
- {WindowDeactivate} and \l{QEvent::FocusIn}{FocusIn}/\l{QEvent::FocusOut}
- {FocusOut} events to all appropriate widgets. The window will then be
- painted in active state (e.g. cursors in line edits will blink), and it
- will have tool tips enabled.
-
- \sa activeWindow(), QWidget::activateWindow()
-*/
-void QApplication::setActiveWindow(QWidget* act)
-{
- QWidget* window = act?act->window():0;
-
- if (QApplicationPrivate::active_window == window)
- return;
-
-#ifndef QT_NO_GRAPHICSVIEW
- if (window && window->graphicsProxyWidget()) {
- // Activate the proxy's view->viewport() ?
- return;
- }
-#endif
-
- QWidgetList toBeActivated;
- QWidgetList toBeDeactivated;
-
- if (QApplicationPrivate::active_window) {
- if (style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, QApplicationPrivate::active_window)) {
- QWidgetList list = topLevelWidgets();
- for (int i = 0; i < list.size(); ++i) {
- QWidget *w = list.at(i);
- if (w->isVisible() && w->isActiveWindow())
- toBeDeactivated.append(w);
- }
- } else {
- toBeDeactivated.append(QApplicationPrivate::active_window);
- }
- }
-
-#if !defined(Q_WS_MAC)
- QWidget *previousActiveWindow = QApplicationPrivate::active_window;
-#endif
- QApplicationPrivate::active_window = window;
-
- if (QApplicationPrivate::active_window) {
- if (style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, QApplicationPrivate::active_window)) {
- QWidgetList list = topLevelWidgets();
- for (int i = 0; i < list.size(); ++i) {
- QWidget *w = list.at(i);
- if (w->isVisible() && w->isActiveWindow())
- toBeActivated.append(w);
- }
- } else {
- toBeActivated.append(QApplicationPrivate::active_window);
- }
-
- }
-
- // first the activation/deactivation events
- QEvent activationChange(QEvent::ActivationChange);
- QEvent windowActivate(QEvent::WindowActivate);
- QEvent windowDeactivate(QEvent::WindowDeactivate);
-
-#if !defined(Q_WS_MAC)
- if (!previousActiveWindow) {
- QEvent appActivate(QEvent::ApplicationActivate);
- sendSpontaneousEvent(qApp, &appActivate);
- }
-#endif
-
- for (int i = 0; i < toBeActivated.size(); ++i) {
- QWidget *w = toBeActivated.at(i);
- sendSpontaneousEvent(w, &windowActivate);
- sendSpontaneousEvent(w, &activationChange);
- }
-
-#ifdef QT_MAC_USE_COCOA
- // In case the user clicked on a child window, we need to
- // reestablish the stacking order of the window so
- // it pops in front of other child windows in cocoa:
- qt_cocoaStackChildWindowOnTopOfOtherChildren(window);
-#endif
-
- for(int i = 0; i < toBeDeactivated.size(); ++i) {
- QWidget *w = toBeDeactivated.at(i);
- sendSpontaneousEvent(w, &windowDeactivate);
- sendSpontaneousEvent(w, &activationChange);
- }
-
-#if !defined(Q_WS_MAC)
- if (!QApplicationPrivate::active_window) {
- QEvent appDeactivate(QEvent::ApplicationDeactivate);
- sendSpontaneousEvent(qApp, &appDeactivate);
- }
-#endif
-
- if (QApplicationPrivate::popupWidgets == 0) { // !inPopupMode()
- // then focus events
- if (!QApplicationPrivate::active_window && QApplicationPrivate::focus_widget) {
- QApplicationPrivate::setFocusWidget(0, Qt::ActiveWindowFocusReason);
- } else if (QApplicationPrivate::active_window) {
- QWidget *w = QApplicationPrivate::active_window->focusWidget();
- if (w && w->isVisible() /*&& w->focusPolicy() != QWidget::NoFocus*/)
- w->setFocus(Qt::ActiveWindowFocusReason);
- else {
- w = QApplicationPrivate::focusNextPrevChild_helper(QApplicationPrivate::active_window, true);
- if (w) {
- w->setFocus(Qt::ActiveWindowFocusReason);
- } else {
- // If the focus widget is not in the activate_window, clear the focus
- w = QApplicationPrivate::focus_widget;
- if (!w && QApplicationPrivate::active_window->focusPolicy() != Qt::NoFocus)
- QApplicationPrivate::setFocusWidget(QApplicationPrivate::active_window, Qt::ActiveWindowFocusReason);
- else if (!QApplicationPrivate::active_window->isAncestorOf(w))
- QApplicationPrivate::setFocusWidget(0, Qt::ActiveWindowFocusReason);
- }
- }
- }
- }
-}
-
-/*!internal
- * Helper function that returns the new focus widget, but does not set the focus reason.
- * Returns 0 if a new focus widget could not be found.
- * Shared with QGraphicsProxyWidgetPrivate::findFocusChild()
-*/
-QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool next)
-{
- uint focus_flag = qt_tab_all_widgets ? Qt::TabFocus : Qt::StrongFocus;
-
- QWidget *f = toplevel->focusWidget();
- if (!f)
- f = toplevel;
-
- QWidget *w = f;
- QWidget *test = f->d_func()->focus_next;
- while (test && test != f) {
- if ((test->focusPolicy() & focus_flag) == focus_flag
- && !(test->d_func()->extra && test->d_func()->extra->focus_proxy)
- && test->isVisibleTo(toplevel) && test->isEnabled()
- && !(w->windowType() == Qt::SubWindow && !w->isAncestorOf(test))
- && (toplevel->windowType() != Qt::SubWindow || toplevel->isAncestorOf(test))) {
- w = test;
- if (next)
- break;
- }
- test = test->d_func()->focus_next;
- }
- if (w == f) {
- if (qt_in_tab_key_event) {
- w->window()->setAttribute(Qt::WA_KeyboardFocusChange);
- w->update();
- }
- return 0;
- }
- return w;
-}
-
-/*!
- \fn void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave)
- \internal
-
- Creates the proper Enter/Leave event when widget \a enter is entered and
- widget \a leave is left.
- */
-void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) {
-#if 0
- if (leave) {
- QEvent e(QEvent::Leave);
- QApplication::sendEvent(leave, & e);
- }
- if (enter) {
- QEvent e(QEvent::Enter);
- QApplication::sendEvent(enter, & e);
- }
- return;
-#endif
-
- QWidget* w ;
- if ((!enter && !leave) || (enter == leave))
- return;
-#ifdef ALIEN_DEBUG
- qDebug() << "QApplicationPrivate::dispatchEnterLeave, ENTER:" << enter << "LEAVE:" << leave;
-#endif
- QWidgetList leaveList;
- QWidgetList enterList;
-
- bool sameWindow = leave && enter && leave->window() == enter->window();
- if (leave && !sameWindow) {
- w = leave;
- do {
- leaveList.append(w);
- } while (!w->isWindow() && (w = w->parentWidget()));
- }
- if (enter && !sameWindow) {
- w = enter;
- do {
- enterList.prepend(w);
- } while (!w->isWindow() && (w = w->parentWidget()));
- }
- if (sameWindow) {
- int enterDepth = 0;
- int leaveDepth = 0;
- w = enter;
- while (!w->isWindow() && (w = w->parentWidget()))
- enterDepth++;
- w = leave;
- while (!w->isWindow() && (w = w->parentWidget()))
- leaveDepth++;
- QWidget* wenter = enter;
- QWidget* wleave = leave;
- while (enterDepth > leaveDepth) {
- wenter = wenter->parentWidget();
- enterDepth--;
- }
- while (leaveDepth > enterDepth) {
- wleave = wleave->parentWidget();
- leaveDepth--;
- }
- while (!wenter->isWindow() && wenter != wleave) {
- wenter = wenter->parentWidget();
- wleave = wleave->parentWidget();
- }
-
- w = leave;
- while (w != wleave) {
- leaveList.append(w);
- w = w->parentWidget();
- }
- w = enter;
- while (w != wenter) {
- enterList.prepend(w);
- w = w->parentWidget();
- }
- }
-
- QEvent leaveEvent(QEvent::Leave);
- for (int i = 0; i < leaveList.size(); ++i) {
- w = leaveList.at(i);
- if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) {
-#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_MAC)
- if (leaveAfterRelease == w)
- leaveAfterRelease = 0;
-#endif
- QApplication::sendEvent(w, &leaveEvent);
- if (w->testAttribute(Qt::WA_Hover) &&
- (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) {
- Q_ASSERT(instance());
- QHoverEvent he(QEvent::HoverLeave, QPoint(-1, -1), w->mapFromGlobal(QApplicationPrivate::instance()->hoverGlobalPos));
- qApp->d_func()->notify_helper(w, &he);
- }
- }
- }
- QPoint posEnter = QCursor::pos();
- QEvent enterEvent(QEvent::Enter);
- for (int i = 0; i < enterList.size(); ++i) {
- w = enterList.at(i);
- if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) {
- QApplication::sendEvent(w, &enterEvent);
- if (w->testAttribute(Qt::WA_Hover) &&
- (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) {
- QHoverEvent he(QEvent::HoverEnter, w->mapFromGlobal(posEnter), QPoint(-1, -1));
- qApp->d_func()->notify_helper(w, &he);
- }
- }
- }
-
-#ifndef QT_NO_CURSOR
- // Update cursor for alien/graphics widgets.
-
- const bool enterOnAlien = (enter && (isAlien(enter) || enter->testAttribute(Qt::WA_DontShowOnScreen)));
-#if defined(Q_WS_X11) || defined(Q_WS_QPA)
- //Whenever we leave an alien widget on X11, we need to reset its nativeParentWidget()'s cursor.
- // This is not required on Windows as the cursor is reset on every single mouse move.
- QWidget *parentOfLeavingCursor = 0;
- for (int i = 0; i < leaveList.size(); ++i) {
- w = leaveList.at(i);
- if (!isAlien(w))
- break;
- if (w->testAttribute(Qt::WA_SetCursor)) {
- QWidget *parent = w->parentWidget();
- while (parent && parent->d_func()->data.in_destructor)
- parent = parent->parentWidget();
- parentOfLeavingCursor = parent;
- //continue looping, we need to find the downest alien widget with a cursor.
- // (downest on the screen)
- }
- }
- //check that we will not call qt_x11_enforce_cursor twice with the same native widget
- if (parentOfLeavingCursor && (!enterOnAlien
- || parentOfLeavingCursor->effectiveWinId() != enter->effectiveWinId())) {
-#ifndef QT_NO_GRAPHICSVIEW
- if (!parentOfLeavingCursor->window()->graphicsProxyWidget())
-#endif
- {
-#if defined(Q_WS_X11)
- qt_x11_enforce_cursor(parentOfLeavingCursor,true);
-#elif defined(Q_WS_QPA)
- if (enter == QApplication::desktop()) {
- qt_qpa_set_cursor(enter, true);
- } else {
- qt_qpa_set_cursor(parentOfLeavingCursor, true);
- }
-#endif
- }
- }
-#endif
- if (enterOnAlien) {
- QWidget *cursorWidget = enter;
- while (!cursorWidget->isWindow() && !cursorWidget->isEnabled())
- cursorWidget = cursorWidget->parentWidget();
-
- if (!cursorWidget)
- return;
-
-#ifndef QT_NO_GRAPHICSVIEW
- if (cursorWidget->window()->graphicsProxyWidget()) {
- QWidgetPrivate::nearestGraphicsProxyWidget(cursorWidget)->setCursor(cursorWidget->cursor());
- } else
-#endif
- {
-#if defined(Q_WS_WIN)
- qt_win_set_cursor(cursorWidget, true);
-#elif defined(Q_WS_X11)
- qt_x11_enforce_cursor(cursorWidget, true);
-#elif defined(Q_OS_SYMBIAN)
- qt_symbian_set_cursor(cursorWidget, true);
-#elif defined(Q_WS_QPA)
- qt_qpa_set_cursor(cursorWidget, true);
-#endif
- }
- }
-#endif
-}
-
-/* exported for the benefit of testing tools */
-Q_GUI_EXPORT bool qt_tryModalHelper(QWidget *widget, QWidget **rettop)
-{
- return QApplicationPrivate::tryModalHelper(widget, rettop);
-}
-
-/*! \internal
- Returns true if \a widget is blocked by a modal window.
- */
-bool QApplicationPrivate::isBlockedByModal(QWidget *widget)
-{
- widget = widget->window();
- if (!modalState())
- return false;
- if (QApplication::activePopupWidget() == widget)
- return false;
-
- for (int i = 0; i < qt_modal_stack->size(); ++i) {
- QWidget *modalWidget = qt_modal_stack->at(i);
-
- {
- // check if the active modal widget is our widget or a parent of our widget
- QWidget *w = widget;
- while (w) {
- if (w == modalWidget)
- return false;
- w = w->parentWidget();
- }
-#ifdef Q_WS_WIN
- if ((widget->testAttribute(Qt::WA_WState_Created) || widget->data->winid)
- && (modalWidget->testAttribute(Qt::WA_WState_Created) || modalWidget->data->winid)
- && IsChild(modalWidget->data->winid, widget->data->winid))
- return false;
-#endif
- }
-
- Qt::WindowModality windowModality = modalWidget->windowModality();
- if (windowModality == Qt::NonModal) {
- // determine the modality type if it hasn't been set on the
- // modalWidget, this normally happens when waiting for a
- // native dialog. use WindowModal if we are the child of a
- // group leader; otherwise use ApplicationModal.
- QWidget *m = modalWidget;
- while (m && !m->testAttribute(Qt::WA_GroupLeader)) {
- m = m->parentWidget();
- if (m)
- m = m->window();
- }
- windowModality = (m && m->testAttribute(Qt::WA_GroupLeader))
- ? Qt::WindowModal
- : Qt::ApplicationModal;
- }
-
- switch (windowModality) {
- case Qt::ApplicationModal:
- {
- QWidget *groupLeaderForWidget = widget;
- while (groupLeaderForWidget && !groupLeaderForWidget->testAttribute(Qt::WA_GroupLeader))
- groupLeaderForWidget = groupLeaderForWidget->parentWidget();
-
- if (groupLeaderForWidget) {
- // if \a widget has WA_GroupLeader, it can only be blocked by ApplicationModal children
- QWidget *m = modalWidget;
- while (m && m != groupLeaderForWidget && !m->testAttribute(Qt::WA_GroupLeader))
- m = m->parentWidget();
- if (m == groupLeaderForWidget)
- return true;
- } else if (modalWidget != widget) {
- return true;
- }
- break;
- }
- case Qt::WindowModal:
- {
- QWidget *w = widget;
- do {
- QWidget *m = modalWidget;
- do {
- if (m == w)
- return true;
- m = m->parentWidget();
- if (m)
- m = m->window();
- } while (m);
- w = w->parentWidget();
- if (w)
- w = w->window();
- } while (w);
- break;
- }
- default:
- Q_ASSERT_X(false, "QApplication", "internal error, a modal widget cannot be modeless");
- break;
- }
- }
- return false;
-}
-
-/*!\internal
- */
-void QApplicationPrivate::enterModal(QWidget *widget)
-{
- QSet<QWidget*> blocked;
- QList<QWidget*> windows = QApplication::topLevelWidgets();
- for (int i = 0; i < windows.count(); ++i) {
- QWidget *window = windows.at(i);
- if (window->windowType() != Qt::Tool && isBlockedByModal(window))
- blocked.insert(window);
- }
-
- enterModal_sys(widget);
-
- windows = QApplication::topLevelWidgets();
- QEvent e(QEvent::WindowBlocked);
- for (int i = 0; i < windows.count(); ++i) {
- QWidget *window = windows.at(i);
- if (!blocked.contains(window) && window->windowType() != Qt::Tool && isBlockedByModal(window))
- QApplication::sendEvent(window, &e);
- }
-}
-
-/*!\internal
- */
-void QApplicationPrivate::leaveModal(QWidget *widget)
-{
- QSet<QWidget*> blocked;
- QList<QWidget*> windows = QApplication::topLevelWidgets();
- for (int i = 0; i < windows.count(); ++i) {
- QWidget *window = windows.at(i);
- if (window->windowType() != Qt::Tool && isBlockedByModal(window))
- blocked.insert(window);
- }
-
- leaveModal_sys(widget);
-
- windows = QApplication::topLevelWidgets();
- QEvent e(QEvent::WindowUnblocked);
- for (int i = 0; i < windows.count(); ++i) {
- QWidget *window = windows.at(i);
- if(blocked.contains(window) && window->windowType() != Qt::Tool && !isBlockedByModal(window))
- QApplication::sendEvent(window, &e);
- }
-}
-
-
-
-/*!\internal
-
- Called from qapplication_\e{platform}.cpp, returns true
- if the widget should accept the event.
- */
-bool QApplicationPrivate::tryModalHelper(QWidget *widget, QWidget **rettop)
-{
- QWidget *top = QApplication::activeModalWidget();
- if (rettop)
- *rettop = top;
-
- // the active popup widget always gets the input event
- if (QApplication::activePopupWidget())
- return true;
-
-#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
- top = QApplicationPrivate::tryModalHelper_sys(top);
- if (rettop)
- *rettop = top;
-#endif
-
- return !isBlockedByModal(widget->window());
-}
-
-/*
- \internal
-*/
-QWidget *QApplicationPrivate::pickMouseReceiver(QWidget *candidate, const QPoint &globalPos,
- QPoint &pos, QEvent::Type type,
- Qt::MouseButtons buttons, QWidget *buttonDown,
- QWidget *alienWidget)
-{
- Q_ASSERT(candidate);
-
- QWidget *mouseGrabber = QWidget::mouseGrabber();
- if (((type == QEvent::MouseMove && buttons) || (type == QEvent::MouseButtonRelease))
- && !buttonDown && !mouseGrabber) {
- return 0;
- }
-
- if (alienWidget && alienWidget->internalWinId())
- alienWidget = 0;
-
- QWidget *receiver = candidate;
-
- if (!mouseGrabber)
- mouseGrabber = (buttonDown && !isBlockedByModal(buttonDown)) ? buttonDown : alienWidget;
-
- if (mouseGrabber && mouseGrabber != candidate) {
- receiver = mouseGrabber;
- pos = receiver->mapFromGlobal(globalPos);
-#ifdef ALIEN_DEBUG
- qDebug() << " ** receiver adjusted to:" << receiver << "pos:" << pos;
-#endif
- }
-
- return receiver;
-
-}
-
-/*
- \internal
-*/
-bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
- QWidget *alienWidget, QWidget *nativeWidget,
- QWidget **buttonDown, QPointer<QWidget> &lastMouseReceiver,
- bool spontaneous)
-{
- Q_ASSERT(receiver);
- Q_ASSERT(event);
- Q_ASSERT(nativeWidget);
- Q_ASSERT(buttonDown);
-
- if (alienWidget && !isAlien(alienWidget))
- alienWidget = 0;
-
- QPointer<QWidget> receiverGuard = receiver;
- QPointer<QWidget> nativeGuard = nativeWidget;
- QPointer<QWidget> alienGuard = alienWidget;
- QPointer<QWidget> activePopupWidget = QApplication::activePopupWidget();
-
- const bool graphicsWidget = nativeWidget->testAttribute(Qt::WA_DontShowOnScreen);
-
- if (*buttonDown) {
- if (!graphicsWidget) {
- // Register the widget that shall receive a leave event
- // after the last button is released.
- if ((alienWidget || !receiver->internalWinId()) && !leaveAfterRelease && !QWidget::mouseGrabber())
- leaveAfterRelease = *buttonDown;
- if (event->type() == QEvent::MouseButtonRelease && !event->buttons())
- *buttonDown = 0;
- }
- } else if (lastMouseReceiver) {
- // Dispatch enter/leave if we move:
- // 1) from an alien widget to another alien widget or
- // from a native widget to an alien widget (first OR case)
- // 2) from an alien widget to a native widget (second OR case)
- if ((alienWidget && alienWidget != lastMouseReceiver)
- || (isAlien(lastMouseReceiver) && !alienWidget)) {
- if (activePopupWidget) {
- if (!QWidget::mouseGrabber())
- dispatchEnterLeave(alienWidget ? alienWidget : nativeWidget, lastMouseReceiver);
- } else {
- dispatchEnterLeave(receiver, lastMouseReceiver);
- }
-
- }
- }
-
-#ifdef ALIEN_DEBUG
- qDebug() << "QApplicationPrivate::sendMouseEvent: receiver:" << receiver
- << "pos:" << event->pos() << "alien" << alienWidget << "button down"
- << *buttonDown << "last" << lastMouseReceiver << "leave after release"
- << leaveAfterRelease;
-#endif
-
- // We need this quard in case someone opens a modal dialog / popup. If that's the case
- // leaveAfterRelease is set to null, but we shall not update lastMouseReceiver.
- const bool wasLeaveAfterRelease = leaveAfterRelease != 0;
- bool result;
- if (spontaneous)
- result = QApplication::sendSpontaneousEvent(receiver, event);
- else
- result = QApplication::sendEvent(receiver, event);
-
- if (!graphicsWidget && leaveAfterRelease && event->type() == QEvent::MouseButtonRelease
- && !event->buttons() && QWidget::mouseGrabber() != leaveAfterRelease) {
- // Dispatch enter/leave if:
- // 1) the mouse grabber is an alien widget
- // 2) the button is released on an alien widget
- QWidget *enter = 0;
- if (nativeGuard)
- enter = alienGuard ? alienWidget : nativeWidget;
- else // The receiver is typically deleted on mouse release with drag'n'drop.
- enter = QApplication::widgetAt(event->globalPos());
- dispatchEnterLeave(enter, leaveAfterRelease);
- leaveAfterRelease = 0;
- lastMouseReceiver = enter;
- } else if (!wasLeaveAfterRelease) {
- if (activePopupWidget) {
- if (!QWidget::mouseGrabber())
- lastMouseReceiver = alienGuard ? alienWidget : (nativeGuard ? nativeWidget : 0);
- } else {
- lastMouseReceiver = receiverGuard ? receiver : QApplication::widgetAt(event->globalPos());
- }
- }
-
- return result;
-}
-
-#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_QPA)
-/*
- This function should only be called when the widget changes visibility, i.e.
- when the \a widget is shown, hidden or deleted. This function does nothing
- if the widget is a top-level or native, i.e. not an alien widget. In that
- case enter/leave events are genereated by the underlying windowing system.
-*/
-extern QPointer<QWidget> qt_last_mouse_receiver;
-extern QWidget *qt_button_down;
-void QApplicationPrivate::sendSyntheticEnterLeave(QWidget *widget)
-{
-#ifndef QT_NO_CURSOR
-#if defined(Q_WS_QWS) || defined(Q_WS_QPA)
- if (!widget || widget->isWindow())
- return;
-#else
- if (!widget || widget->internalWinId() || widget->isWindow())
- return;
-#endif
- const bool widgetInShow = widget->isVisible() && !widget->data->in_destructor;
- if (!widgetInShow && widget != qt_last_mouse_receiver)
- return; // Widget was not under the cursor when it was hidden/deleted.
-
- if (widgetInShow && widget->parentWidget()->data->in_show)
- return; // Ingore recursive show.
-
- QWidget *mouseGrabber = QWidget::mouseGrabber();
- if (mouseGrabber && mouseGrabber != widget)
- return; // Someone else has the grab; enter/leave should not occur.
-
- QWidget *tlw = widget->window();
- if (tlw->data->in_destructor || tlw->data->is_closing)
- return; // Closing down the business.
-
- if (widgetInShow && (!qt_last_mouse_receiver || qt_last_mouse_receiver->window() != tlw))
- return; // Mouse cursor not inside the widget's top-level.
-
- const QPoint globalPos(QCursor::pos());
- QPoint pos = tlw->mapFromGlobal(globalPos);
-
- // Find the current widget under the mouse. If this function was called from
- // the widget's destructor, we have to make sure childAt() doesn't take into
- // account widgets that are about to be destructed.
- QWidget *widgetUnderCursor = tlw->d_func()->childAt_helper(pos, widget->data->in_destructor);
- if (!widgetUnderCursor)
- widgetUnderCursor = tlw;
- else
- pos = widgetUnderCursor->mapFrom(tlw, pos);
-
- if (widgetInShow && widgetUnderCursor != widget && !widget->isAncestorOf(widgetUnderCursor))
- return; // Mouse cursor not inside the widget or any of its children.
-
- if (widget->data->in_destructor && qt_button_down == widget)
- qt_button_down = 0;
-
- // Send enter/leave events followed by a mouse move on the entered widget.
- QMouseEvent e(QEvent::MouseMove, pos, globalPos, Qt::NoButton, Qt::NoButton, Qt::NoModifier);
- sendMouseEvent(widgetUnderCursor, &e, widgetUnderCursor, tlw, &qt_button_down, qt_last_mouse_receiver);
-#endif // QT_NO_CURSOR
-}
-#endif // Q_WS_WIN || Q_WS_X11 || Q_WS_MAC
-
-/*!
- Returns the desktop widget (also called the root window).
-
- The desktop may be composed of multiple screens, so it would be incorrect,
- for example, to attempt to \e center some widget in the desktop's geometry.
- QDesktopWidget has various functions for obtaining useful geometries upon
- the desktop, such as QDesktopWidget::screenGeometry() and
- QDesktopWidget::availableGeometry().
-
- On X11, it is also possible to draw on the desktop.
-*/
-QDesktopWidget *QApplication::desktop()
-{
- if (!qt_desktopWidget || // not created yet
- !(qt_desktopWidget->windowType() == Qt::Desktop)) { // reparented away
- qt_desktopWidget = new QDesktopWidget();
- }
- return qt_desktopWidget;
-}
-
-#ifndef QT_NO_CLIPBOARD
-/*!
- Returns a pointer to the application global clipboard.
-
- \note The QApplication object should already be constructed before
- accessing the clipboard.
-*/
-QClipboard *QApplication::clipboard()
-{
- if (qt_clipboard == 0) {
- if (!qApp) {
- qWarning("QApplication: Must construct a QApplication before accessing a QClipboard");
- return 0;
- }
- qt_clipboard = new QClipboard(0);
- }
- return qt_clipboard;
-}
-#endif // QT_NO_CLIPBOARD
-
-/*!
- Sets whether Qt should use the system's standard colors, fonts, etc., to
- \a on. By default, this is true.
-
- This function must be called before creating the QApplication object, like
- this:
-
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 6
-
- \sa desktopSettingsAware()
-*/
-void QApplication::setDesktopSettingsAware(bool on)
-{
- QApplicationPrivate::obey_desktop_settings = on;
-}
-
-/*!
- Returns true if Qt is set to use the system's standard colors, fonts, etc.;
- otherwise returns false. The default is true.
-
- \sa setDesktopSettingsAware()
-*/
-bool QApplication::desktopSettingsAware()
-{
- return QApplicationPrivate::obey_desktop_settings;
-}
-
-/*!
- Returns the current state of the modifier keys on the keyboard. The current
- state is updated sychronously as the event queue is emptied of events that
- will spontaneously change the keyboard state (QEvent::KeyPress and
- QEvent::KeyRelease events).
-
- It should be noted this may not reflect the actual keys held on the input
- device at the time of calling but rather the modifiers as last reported in
- one of the above events. If no keys are being held Qt::NoModifier is
- returned.
-
- \sa mouseButtons()
-*/
-
-Qt::KeyboardModifiers QApplication::keyboardModifiers()
-{
- return QApplicationPrivate::modifier_buttons;
-}
-
-/*!
- Returns the current state of the buttons on the mouse. The current state is
- updated syncronously as the event queue is emptied of events that will
- spontaneously change the mouse state (QEvent::MouseButtonPress and
- QEvent::MouseButtonRelease events).
-
- It should be noted this may not reflect the actual buttons held on the
- input device at the time of calling but rather the mouse buttons as last
- reported in one of the above events. If no mouse buttons are being held
- Qt::NoButton is returned.
-
- \sa keyboardModifiers()
-*/
-
-Qt::MouseButtons QApplication::mouseButtons()
-{
- return QApplicationPrivate::mouse_buttons;
-}
-
-/*!
- \fn bool QApplication::isSessionRestored() const
-
- Returns true if the application has been restored from an earlier
- \l{Session Management}{session}; otherwise returns false.
-
- \sa sessionId(), commitData(), saveState()
-*/
-
-
-/*!
- \fn QString QApplication::sessionId() const
-
- Returns the current \l{Session Management}{session's} identifier.
-
- If the application has been restored from an earlier session, this
- identifier is the same as it was in that previous session. The session
- identifier is guaranteed to be unique both for different applications
- and for different instances of the same application.
-
- \sa isSessionRestored(), sessionKey(), commitData(), saveState()
-*/
-
-/*!
- \fn QString QApplication::sessionKey() const
-
- Returns the session key in the current \l{Session Management}{session}.
-
- If the application has been restored from an earlier session, this key is
- the same as it was when the previous session ended.
-
- The session key changes with every call of commitData() or saveState().
-
- \sa isSessionRestored(), sessionId(), commitData(), saveState()
-*/
-#ifndef QT_NO_SESSIONMANAGER
-bool QApplication::isSessionRestored() const
-{
- Q_D(const QApplication);
- return d->is_session_restored;
-}
-
-QString QApplication::sessionId() const
-{
- Q_D(const QApplication);
- return d->session_id;
-}
-
-QString QApplication::sessionKey() const
-{
- Q_D(const QApplication);
- return d->session_key;
-}
-#endif
-
-
-
-/*!
- \since 4.2
- \fn void QApplication::commitDataRequest(QSessionManager &manager)
-
- This signal deals with \l{Session Management}{session management}. It is
- emitted when the QSessionManager wants the application to commit all its
- data.
-
- Usually this means saving all open files, after getting permission from
- the user. Furthermore you may want to provide a means by which the user
- can cancel the shutdown.
-
- You should not exit the application within this signal. Instead,
- the session manager may or may not do this afterwards, depending on the
- context.
-
- \warning Within this signal, no user interaction is possible, \e
- unless you ask the \a manager for explicit permission. See
- QSessionManager::allowsInteraction() and
- QSessionManager::allowsErrorInteraction() for details and example
- usage.
-
- \note You should use Qt::DirectConnection when connecting to this signal.
-
- \sa isSessionRestored(), sessionId(), saveState(), {Session Management}
-*/
-
-/*!
- This function deals with \l{Session Management}{session management}. It is
- invoked when the QSessionManager wants the application to commit all its
- data.
-
- Usually this means saving all open files, after getting permission from the
- user. Furthermore you may want to provide a means by which the user can
- cancel the shutdown.
-
- You should not exit the application within this function. Instead, the
- session manager may or may not do this afterwards, depending on the
- context.
-
- \warning Within this function, no user interaction is possible, \e
- unless you ask the \a manager for explicit permission. See
- QSessionManager::allowsInteraction() and
- QSessionManager::allowsErrorInteraction() for details and example
- usage.
-
- The default implementation requests interaction and sends a close event to
- all visible top-level widgets. If any event was rejected, the shutdown is
- canceled.
-
- \sa isSessionRestored(), sessionId(), saveState(), {Session Management}
-*/
-#ifndef QT_NO_SESSIONMANAGER
-void QApplication::commitData(QSessionManager& manager )
-{
- emit commitDataRequest(manager);
- if (manager.allowsInteraction()) {
- QWidgetList done;
- QWidgetList list = QApplication::topLevelWidgets();
- bool cancelled = false;
- for (int i = 0; !cancelled && i < list.size(); ++i) {
- QWidget* w = list.at(i);
- if (w->isVisible() && !done.contains(w)) {
- cancelled = !w->close();
- if (!cancelled)
- done.append(w);
- list = QApplication::topLevelWidgets();
- i = -1;
- }
- }
- if (cancelled)
- manager.cancel();
- }
-}
-
-/*!
- \since 4.2
- \fn void QApplication::saveStateRequest(QSessionManager &manager)
-
- This signal deals with \l{Session Management}{session management}. It is
- invoked when the \l{QSessionManager}{session manager} wants the application
- to preserve its state for a future session.
-
- For example, a text editor would create a temporary file that includes the
- current contents of its edit buffers, the location of the cursor and other
- aspects of the current editing session.
-
- You should never exit the application within this signal. Instead, the
- session manager may or may not do this afterwards, depending on the
- context. Futhermore, most session managers will very likely request a saved
- state immediately after the application has been started. This permits the
- session manager to learn about the application's restart policy.
-
- \warning Within this function, no user interaction is possible, \e
- unless you ask the \a manager for explicit permission. See
- QSessionManager::allowsInteraction() and
- QSessionManager::allowsErrorInteraction() for details.
-
- \note You should use Qt::DirectConnection when connecting to this signal.
-
- \sa isSessionRestored(), sessionId(), commitData(), {Session Management}
-*/
-
-/*!
- This function deals with \l{Session Management}{session management}. It is
- invoked when the \l{QSessionManager}{session manager} wants the application
- to preserve its state for a future session.
-
- For example, a text editor would create a temporary file that includes the
- current contents of its edit buffers, the location of the cursor and other
- aspects of the current editing session.
-
- You should never exit the application within this function. Instead, the
- session manager may or may not do this afterwards, depending on the
- context. Futhermore, most session managers will very likely request a saved
- state immediately after the application has been started. This permits the
- session manager to learn about the application's restart policy.
-
- \warning Within this function, no user interaction is possible, \e
- unless you ask the \a manager for explicit permission. See
- QSessionManager::allowsInteraction() and
- QSessionManager::allowsErrorInteraction() for details.
-
- \sa isSessionRestored(), sessionId(), commitData(), {Session Management}
-*/
-
-void QApplication::saveState(QSessionManager &manager)
-{
- emit saveStateRequest(manager);
-}
-#endif //QT_NO_SESSIONMANAGER
-/*
- Sets the time after which a drag should start to \a ms ms.
-
- \sa startDragTime()
-*/
-
-void QApplication::setStartDragTime(int ms)
-{
- drag_time = ms;
-}
-
-/*!
- \property QApplication::startDragTime
- \brief the time in milliseconds that a mouse button must be held down
- before a drag and drop operation will begin
-
- If you support drag and drop in your application, and want to start a drag
- and drop operation after the user has held down a mouse button for a
- certain amount of time, you should use this property's value as the delay.
-
- Qt also uses this delay internally, e.g. in QTextEdit and QLineEdit, for
- starting a drag.
-
- The default value is 500 ms.
-
- \sa startDragDistance(), {Drag and Drop}
-*/
-
-int QApplication::startDragTime()
-{
- return drag_time;
-}
-
-/*
- Sets the distance after which a drag should start to \a l pixels.
-
- \sa startDragDistance()
-*/
-
-void QApplication::setStartDragDistance(int l)
-{
- drag_distance = l;
-}
-
-/*!
- \property QApplication::startDragDistance
-
- If you support drag and drop in your application, and want to start a drag
- and drop operation after the user has moved the cursor a certain distance
- with a button held down, you should use this property's value as the
- minimum distance required.
-
- For example, if the mouse position of the click is stored in \c startPos
- and the current position (e.g. in the mouse move event) is \c currentPos,
- you can find out if a drag should be started with code like this:
-
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 7
-
- Qt uses this value internally, e.g. in QFileDialog.
-
- The default value is 4 pixels.
-
- \sa startDragTime() QPoint::manhattanLength() {Drag and Drop}
-*/
-
-int QApplication::startDragDistance()
-{
- return drag_distance;
-}
-
-/*!
- \fn void QApplication::setReverseLayout(bool reverse)
-
- Use setLayoutDirection() instead.
-*/
-
-/*!
- \fn void QApplication::reverseLayout()
-
- Use layoutDirection() instead.
-*/
-
-/*!
- \fn bool QApplication::isRightToLeft()
-
- Returns true if the application's layout direction is
- Qt::RightToLeft; otherwise returns false.
-
- \sa layoutDirection(), isLeftToRight()
-*/
-
-/*!
- \fn bool QApplication::isLeftToRight()
-
- Returns true if the application's layout direction is
- Qt::LeftToRight; otherwise returns false.
-
- \sa layoutDirection(), isRightToLeft()
-*/
-
-/*!
- \property QApplication::layoutDirection
- \brief the default layout direction for this application
-
- On system start-up, the default layout direction depends on the
- application's language.
-
- \sa QWidget::layoutDirection, isLeftToRight(), isRightToLeft()
- */
-
-void QApplication::setLayoutDirection(Qt::LayoutDirection direction)
-{
- if (layout_direction == direction || direction == Qt::LayoutDirectionAuto)
- return;
-
- layout_direction = direction;
-
- QWidgetList list = topLevelWidgets();
- for (int i = 0; i < list.size(); ++i) {
- QWidget *w = list.at(i);
- QEvent ev(QEvent::ApplicationLayoutDirectionChange);
- sendEvent(w, &ev);
- }
-}
-
-Qt::LayoutDirection QApplication::layoutDirection()
-{
- return layout_direction;
-}
-
-
-/*!
- \obsolete
-
- Strips out vertical alignment flags and transforms an alignment \a align
- of Qt::AlignLeft into Qt::AlignLeft or Qt::AlignRight according to the
- language used.
-*/
-
-#ifdef QT3_SUPPORT
-Qt::Alignment QApplication::horizontalAlignment(Qt::Alignment align)
-{
- return QStyle::visualAlignment(layoutDirection(), align);
-}
-#endif
-
-
-/*!
- \fn QCursor *QApplication::overrideCursor()
-
- Returns the active application override cursor.
-
- This function returns 0 if no application cursor has been defined (i.e. the
- internal cursor stack is empty).
-
- \sa setOverrideCursor(), restoreOverrideCursor()
-*/
-#ifndef QT_NO_CURSOR
-QCursor *QApplication::overrideCursor()
-{
- return qApp->d_func()->cursor_list.isEmpty() ? 0 : &qApp->d_func()->cursor_list.first();
-}
-
-/*!
- Changes the currently active application override cursor to \a cursor.
-
- This function has no effect if setOverrideCursor() was not called.
-
- \sa setOverrideCursor(), overrideCursor(), restoreOverrideCursor(),
- QWidget::setCursor()
- */
-void QApplication::changeOverrideCursor(const QCursor &cursor)
-{
- if (qApp->d_func()->cursor_list.isEmpty())
- return;
- qApp->d_func()->cursor_list.removeFirst();
- setOverrideCursor(cursor);
-}
-#endif
-
-/*!
- \fn void QApplication::setOverrideCursor(const QCursor &cursor, bool replace)
-
- Use changeOverrideCursor(\a cursor) (if \a replace is true) or
- setOverrideCursor(\a cursor) (if \a replace is false).
-*/
-
-/*!
- Enters the main event loop and waits until exit() is called, then returns
- the value that was set to exit() (which is 0 if exit() is called via
- quit()).
-
- It is necessary to call this function to start event handling. The main
- event loop receives events from the window system and dispatches these to
- the application widgets.
-
- Generally, no user interaction can take place before calling exec(). As a
- special case, modal widgets like QMessageBox can be used before calling
- exec(), because modal widgets call exec() to start a local event loop.
-
- To make your application perform idle processing, i.e., executing a special
- function whenever there are no pending events, use a QTimer with 0 timeout.
- More advanced idle processing schemes can be achieved using processEvents().
-
- We recommend that you connect clean-up code to the
- \l{QCoreApplication::}{aboutToQuit()} signal, instead of putting it in your
- application's \c{main()} function. This is because, on some platforms the
- QApplication::exec() call may not return. For example, on the Windows
- platform, when the user logs off, the system terminates the process after Qt
- closes all top-level windows. Hence, there is \e{no guarantee} that the
- application will have time to exit its event loop and execute code at the
- end of the \c{main()} function, after the QApplication::exec() call.
-
- \sa quitOnLastWindowClosed, quit(), exit(), processEvents(),
- QCoreApplication::exec()
-*/
-int QApplication::exec()
-{
-#ifndef QT_NO_ACCESSIBILITY
- QAccessible::setRootObject(qApp);
-#endif
- return QCoreApplication::exec();
-}
-
-/*! \reimp
- */
-bool QApplication::notify(QObject *receiver, QEvent *e)
-{
- Q_D(QApplication);
- // no events are delivered after ~QCoreApplication() has started
- if (QApplicationPrivate::is_app_closing)
- return true;
-
- if (receiver == 0) { // serious error
- qWarning("QApplication::notify: Unexpected null receiver");
- return true;
- }
-
-#ifndef QT_NO_DEBUG
- d->checkReceiverThread(receiver);
-#endif
-
- // capture the current mouse/keyboard state
- if(e->spontaneous()) {
- if (e->type() == QEvent::KeyPress
- || e->type() == QEvent::KeyRelease) {
- QKeyEvent *ke = static_cast<QKeyEvent*>(e);
- QApplicationPrivate::modifier_buttons = ke->modifiers();
- } else if(e->type() == QEvent::MouseButtonPress
- || e->type() == QEvent::MouseButtonRelease) {
- QMouseEvent *me = static_cast<QMouseEvent*>(e);
- QApplicationPrivate::modifier_buttons = me->modifiers();
- if(me->type() == QEvent::MouseButtonPress)
- QApplicationPrivate::mouse_buttons |= me->button();
- else
- QApplicationPrivate::mouse_buttons &= ~me->button();
- }
-#if !defined(QT_NO_WHEELEVENT) || !defined(QT_NO_TABLETEVENT)
- else if (false
-# ifndef QT_NO_WHEELEVENT
- || e->type() == QEvent::Wheel
-# endif
-# ifndef QT_NO_TABLETEVENT
- || e->type() == QEvent::TabletMove
- || e->type() == QEvent::TabletPress
- || e->type() == QEvent::TabletRelease
-# endif
- ) {
- QInputEvent *ie = static_cast<QInputEvent*>(e);
- QApplicationPrivate::modifier_buttons = ie->modifiers();
- }
-#endif // !QT_NO_WHEELEVENT || !QT_NO_TABLETEVENT
- }
-
-#ifndef QT_NO_GESTURES
- // walk through parents and check for gestures
- if (d->gestureManager) {
- switch (e->type()) {
- case QEvent::Paint:
- case QEvent::MetaCall:
- case QEvent::DeferredDelete:
- case QEvent::DragEnter: case QEvent::DragMove: case QEvent::DragLeave:
- case QEvent::Drop: case QEvent::DragResponse:
- case QEvent::ChildAdded: case QEvent::ChildPolished:
-#ifdef QT3_SUPPORT
- case QEvent::ChildInsertedRequest:
- case QEvent::ChildInserted:
- case QEvent::LayoutHint:
-#endif
- case QEvent::ChildRemoved:
- case QEvent::UpdateRequest:
- case QEvent::UpdateLater:
- case QEvent::AccessibilityPrepare:
- case QEvent::LocaleChange:
- case QEvent::Style:
- case QEvent::IconDrag:
- case QEvent::StyleChange:
- case QEvent::AccessibilityHelp:
- case QEvent::AccessibilityDescription:
- case QEvent::GraphicsSceneDragEnter:
- case QEvent::GraphicsSceneDragMove:
- case QEvent::GraphicsSceneDragLeave:
- case QEvent::GraphicsSceneDrop:
- case QEvent::DynamicPropertyChange:
- case QEvent::NetworkReplyUpdated:
- break;
- default:
- if (receiver->isWidgetType()) {
- if (d->gestureManager->filterEvent(static_cast<QWidget *>(receiver), e))
- return true;
- } else {
- // a special case for events that go to QGesture objects.
- // We pass the object to the gesture manager and it'll figure
- // out if it's QGesture or not.
- if (d->gestureManager->filterEvent(receiver, e))
- return true;
- }
- }
- }
-#endif // QT_NO_GESTURES
-
- // User input and window activation makes tooltips sleep
- switch (e->type()) {
- case QEvent::Wheel:
- case QEvent::ActivationChange:
- case QEvent::KeyPress:
- case QEvent::KeyRelease:
- case QEvent::FocusOut:
- case QEvent::FocusIn:
- case QEvent::MouseButtonPress:
- case QEvent::MouseButtonRelease:
- case QEvent::MouseButtonDblClick:
- d->toolTipFallAsleep.stop();
- // fall-through
- case QEvent::Leave:
- d->toolTipWakeUp.stop();
- default:
- break;
- }
-
- bool res = false;
- if (!receiver->isWidgetType()) {
- res = d->notify_helper(receiver, e);
- } else switch (e->type()) {
-#if defined QT3_SUPPORT && !defined(QT_NO_SHORTCUT)
- case QEvent::Accel:
- {
- if (d->use_compat()) {
- QKeyEvent* key = static_cast<QKeyEvent*>(e);
- res = d->notify_helper(receiver, e);
-
- if (!res && !key->isAccepted())
- res = d->qt_dispatchAccelEvent(static_cast<QWidget *>(receiver), key);
-
- // next lines are for compatibility with Qt <= 3.0.x: old
- // QAccel was listening on toplevel widgets
- if (!res && !key->isAccepted() && !static_cast<QWidget *>(receiver)->isWindow())
- res = d->notify_helper(static_cast<QWidget *>(receiver)->window(), e);
- }
- break;
- }
-#endif //QT3_SUPPORT && !QT_NO_SHORTCUT
- case QEvent::ShortcutOverride:
- case QEvent::KeyPress:
- case QEvent::KeyRelease:
- {
- bool isWidget = receiver->isWidgetType();
- bool isGraphicsWidget = false;
-#ifndef QT_NO_GRAPHICSVIEW
- isGraphicsWidget = !isWidget && qobject_cast<QGraphicsWidget *>(receiver);
-#endif
- if (!isWidget && !isGraphicsWidget) {
- res = d->notify_helper(receiver, e);
- break;
- }
-
- QKeyEvent* key = static_cast<QKeyEvent*>(e);
-#if defined QT3_SUPPORT && !defined(QT_NO_SHORTCUT)
- if (d->use_compat() && d->qt_tryComposeUnicode(static_cast<QWidget*>(receiver), key))
- break;
-#endif
- if (key->type()==QEvent::KeyPress) {
-#ifndef QT_NO_SHORTCUT
- // Try looking for a Shortcut before sending key events
- if ((res = qApp->d_func()->shortcutMap.tryShortcutEvent(receiver, key)))
- return res;
-#endif
- qt_in_tab_key_event = (key->key() == Qt::Key_Backtab
- || key->key() == Qt::Key_Tab
- || key->key() == Qt::Key_Left
- || key->key() == Qt::Key_Up
- || key->key() == Qt::Key_Right
- || key->key() == Qt::Key_Down);
- }
- bool def = key->isAccepted();
- QPointer<QObject> pr = receiver;
- while (receiver) {
- if (def)
- key->accept();
- else
- key->ignore();
- res = d->notify_helper(receiver, e);
- QWidget *w = isWidget ? static_cast<QWidget *>(receiver) : 0;
-#ifndef QT_NO_GRAPHICSVIEW
- QGraphicsWidget *gw = isGraphicsWidget ? static_cast<QGraphicsWidget *>(receiver) : 0;
-#endif
-
- if ((res && key->isAccepted())
- /*
- QLineEdit will emit a signal on Key_Return, but
- ignore the event, and sometimes the connected
- slot deletes the QLineEdit (common in itemview
- delegates), so we have to check if the widget
- was destroyed even if the event was ignored (to
- prevent a crash)
-
- note that we don't have to reset pw while
- propagating (because the original receiver will
- be destroyed if one of its ancestors is)
- */
- || !pr
- || (isWidget && (w->isWindow() || !w->parentWidget()))
-#ifndef QT_NO_GRAPHICSVIEW
- || (isGraphicsWidget && (gw->isWindow() || !gw->parentWidget()))
-#endif
- ) {
- break;
- }
-
-#ifndef QT_NO_GRAPHICSVIEW
- receiver = w ? (QObject *)w->parentWidget() : (QObject *)gw->parentWidget();
-#else
- receiver = w->parentWidget();
-#endif
- }
- qt_in_tab_key_event = false;
- }
- break;
- case QEvent::MouseButtonPress:
- case QEvent::MouseButtonRelease:
- case QEvent::MouseButtonDblClick:
- case QEvent::MouseMove:
- {
- QWidget* w = static_cast<QWidget *>(receiver);
-
- QMouseEvent* mouse = static_cast<QMouseEvent*>(e);
- QPoint relpos = mouse->pos();
-
- if (e->spontaneous()) {
-#ifndef QT_NO_IM
- QInputContext *ic = w->inputContext();
- if (ic
- && w->testAttribute(Qt::WA_InputMethodEnabled)
- && ic->filterEvent(mouse))
- return true;
-#endif
-
- if (e->type() == QEvent::MouseButtonPress) {
- QApplicationPrivate::giveFocusAccordingToFocusPolicy(w,
- Qt::ClickFocus,
- Qt::MouseFocusReason);
- }
-
- // ### Qt 5 These dynamic tool tips should be an OPT-IN feature. Some platforms
- // like Mac OS X (probably others too), can optimize their views by not
- // dispatching mouse move events. We have attributes to control hover,
- // and mouse tracking, but as long as we are deciding to implement this
- // feature without choice of opting-in or out, you ALWAYS have to have
- // tracking enabled. Therefore, the other properties give a false sense of
- // performance enhancement.
- if (e->type() == QEvent::MouseMove && mouse->buttons() == 0) {
- d->toolTipWidget = w;
- d->toolTipPos = relpos;
- d->toolTipGlobalPos = mouse->globalPos();
- d->toolTipWakeUp.start(d->toolTipFallAsleep.isActive()?20:700, this);
- }
- }
-
- bool eventAccepted = mouse->isAccepted();
-
- QPointer<QWidget> pw = w;
- while (w) {
- QMouseEvent me(mouse->type(), relpos, mouse->globalPos(), mouse->button(), mouse->buttons(),
- mouse->modifiers());
- me.spont = mouse->spontaneous();
- // throw away any mouse-tracking-only mouse events
- if (!w->hasMouseTracking()
- && mouse->type() == QEvent::MouseMove && mouse->buttons() == 0) {
- // but still send them through all application event filters (normally done by notify_helper)
- for (int i = 0; i < d->eventFilters.size(); ++i) {
- register QObject *obj = d->eventFilters.at(i);
- if (!obj)
- continue;
- if (obj->d_func()->threadData != w->d_func()->threadData) {
- qWarning("QApplication: Object event filter cannot be in a different thread.");
- continue;
- }
- if (obj->eventFilter(w, w == receiver ? mouse : &me))
- break;
- }
- res = true;
- } else {
- w->setAttribute(Qt::WA_NoMouseReplay, false);
- res = d->notify_helper(w, w == receiver ? mouse : &me);
- e->spont = false;
- }
- eventAccepted = (w == receiver ? mouse : &me)->isAccepted();
- if (res && eventAccepted)
- break;
- if (w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation))
- break;
- relpos += w->pos();
- w = w->parentWidget();
- }
-
- mouse->setAccepted(eventAccepted);
-
- if (e->type() == QEvent::MouseMove) {
- if (!pw)
- break;
-
- w = static_cast<QWidget *>(receiver);
- relpos = mouse->pos();
- QPoint diff = relpos - w->mapFromGlobal(d->hoverGlobalPos);
- while (w) {
- if (w->testAttribute(Qt::WA_Hover) &&
- (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) {
- QHoverEvent he(QEvent::HoverMove, relpos, relpos - diff);
- d->notify_helper(w, &he);
- }
- if (w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation))
- break;
- relpos += w->pos();
- w = w->parentWidget();
- }
- }
-
- d->hoverGlobalPos = mouse->globalPos();
- }
- break;
-#ifndef QT_NO_WHEELEVENT
- case QEvent::Wheel:
- {
- QWidget* w = static_cast<QWidget *>(receiver);
- QWheelEvent* wheel = static_cast<QWheelEvent*>(e);
- QPoint relpos = wheel->pos();
- bool eventAccepted = wheel->isAccepted();
-
- if (e->spontaneous()) {
- QApplicationPrivate::giveFocusAccordingToFocusPolicy(w,
- Qt::WheelFocus,
- Qt::MouseFocusReason);
- }
-
- while (w) {
- QWheelEvent we(relpos, wheel->globalPos(), wheel->delta(), wheel->buttons(),
- wheel->modifiers(), wheel->orientation());
- we.spont = wheel->spontaneous();
- res = d->notify_helper(w, w == receiver ? wheel : &we);
- eventAccepted = ((w == receiver) ? wheel : &we)->isAccepted();
- e->spont = false;
- if ((res && eventAccepted)
- || w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation))
- break;
-
- relpos += w->pos();
- w = w->parentWidget();
- }
- wheel->setAccepted(eventAccepted);
- }
- break;
-#endif
-#ifndef QT_NO_CONTEXTMENU
- case QEvent::ContextMenu:
- {
- QWidget* w = static_cast<QWidget *>(receiver);
- QContextMenuEvent *context = static_cast<QContextMenuEvent*>(e);
- QPoint relpos = context->pos();
- bool eventAccepted = context->isAccepted();
- while (w) {
- QContextMenuEvent ce(context->reason(), relpos, context->globalPos(), context->modifiers());
- ce.spont = e->spontaneous();
- res = d->notify_helper(w, w == receiver ? context : &ce);
- eventAccepted = ((w == receiver) ? context : &ce)->isAccepted();
- e->spont = false;
-
- if ((res && eventAccepted)
- || w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation))
- break;
-
- relpos += w->pos();
- w = w->parentWidget();
- }
- context->setAccepted(eventAccepted);
- }
- break;
-#endif // QT_NO_CONTEXTMENU
-#ifndef QT_NO_TABLETEVENT
- case QEvent::TabletMove:
- case QEvent::TabletPress:
- case QEvent::TabletRelease:
- {
- QWidget *w = static_cast<QWidget *>(receiver);
- QTabletEvent *tablet = static_cast<QTabletEvent*>(e);
- QPoint relpos = tablet->pos();
- bool eventAccepted = tablet->isAccepted();
- while (w) {
- QTabletEvent te(tablet->type(), relpos, tablet->globalPos(),
- tablet->hiResGlobalPos(), tablet->device(), tablet->pointerType(),
- tablet->pressure(), tablet->xTilt(), tablet->yTilt(),
- tablet->tangentialPressure(), tablet->rotation(), tablet->z(),
- tablet->modifiers(), tablet->uniqueId());
- te.spont = e->spontaneous();
- res = d->notify_helper(w, w == receiver ? tablet : &te);
- eventAccepted = ((w == receiver) ? tablet : &te)->isAccepted();
- e->spont = false;
- if ((res && eventAccepted)
- || w->isWindow()
- || w->testAttribute(Qt::WA_NoMousePropagation))
- break;
-
- relpos += w->pos();
- w = w->parentWidget();
- }
- tablet->setAccepted(eventAccepted);
- qt_tabletChokeMouse = tablet->isAccepted();
- }
- break;
-#endif // QT_NO_TABLETEVENT
-
-#if !defined(QT_NO_TOOLTIP) || !defined(QT_NO_WHATSTHIS)
- case QEvent::ToolTip:
- case QEvent::WhatsThis:
- case QEvent::QueryWhatsThis:
- {
- QWidget* w = static_cast<QWidget *>(receiver);
- QHelpEvent *help = static_cast<QHelpEvent*>(e);
- QPoint relpos = help->pos();
- bool eventAccepted = help->isAccepted();
- while (w) {
- QHelpEvent he(help->type(), relpos, help->globalPos());
- he.spont = e->spontaneous();
- res = d->notify_helper(w, w == receiver ? help : &he);
- e->spont = false;
- eventAccepted = (w == receiver ? help : &he)->isAccepted();
- if ((res && eventAccepted) || w->isWindow())
- break;
-
- relpos += w->pos();
- w = w->parentWidget();
- }
- help->setAccepted(eventAccepted);
- }
- break;
-#endif
-#if !defined(QT_NO_STATUSTIP) || !defined(QT_NO_WHATSTHIS)
- case QEvent::StatusTip:
- case QEvent::WhatsThisClicked:
- {
- QWidget *w = static_cast<QWidget *>(receiver);
- while (w) {
- res = d->notify_helper(w, e);
- if ((res && e->isAccepted()) || w->isWindow())
- break;
- w = w->parentWidget();
- }
- }
- break;
-#endif
-
-#ifndef QT_NO_DRAGANDDROP
- case QEvent::DragEnter: {
- QWidget* w = static_cast<QWidget *>(receiver);
- QDragEnterEvent *dragEvent = static_cast<QDragEnterEvent *>(e);
-#ifdef Q_WS_MAC
- // HIView has a slight difference in how it delivers events to children and parents
- // It will not give a leave to a child's parent when it enters a child.
- QWidget *currentTarget = QDragManager::self()->currentTarget();
- if (currentTarget) {
- // Assume currentTarget did not get a leave
- QDragLeaveEvent event;
- QApplication::sendEvent(currentTarget, &event);
- }
-#endif
-#ifndef QT_NO_GRAPHICSVIEW
- // QGraphicsProxyWidget handles its own propagation,
- // and we must not change QDragManagers currentTarget.
- QWExtra *extra = w->window()->d_func()->extra;
- if (extra && extra->proxyWidget) {
- res = d->notify_helper(w, dragEvent);
- break;
- }
-#endif
- while (w) {
- if (w->isEnabled() && w->acceptDrops()) {
- res = d->notify_helper(w, dragEvent);
- if (res && dragEvent->isAccepted()) {
- QDragManager::self()->setCurrentTarget(w);
- break;
- }
- }
- if (w->isWindow())
- break;
- dragEvent->p = w->mapToParent(dragEvent->p);
- w = w->parentWidget();
- }
- }
- break;
- case QEvent::DragMove:
- case QEvent::Drop:
- case QEvent::DragLeave: {
- QWidget* w = static_cast<QWidget *>(receiver);
-#ifndef QT_NO_GRAPHICSVIEW
- // QGraphicsProxyWidget handles its own propagation,
- // and we must not change QDragManagers currentTarget.
- QWExtra *extra = w->window()->d_func()->extra;
- bool isProxyWidget = extra && extra->proxyWidget;
- if (!isProxyWidget)
-#endif
- w = QDragManager::self()->currentTarget();
-
- if (!w) {
-#ifdef Q_WS_MAC
- // HIView has a slight difference in how it delivers events to children and parents
- // It will not give an enter to a child's parent when it leaves the child.
- if (e->type() == QEvent::DragLeave)
- break;
- // Assume that w did not get an enter.
- QDropEvent *dropEvent = static_cast<QDropEvent *>(e);
- QDragEnterEvent dragEnterEvent(dropEvent->pos(), dropEvent->possibleActions(),
- dropEvent->mimeData(), dropEvent->mouseButtons(),
- dropEvent->keyboardModifiers());
- QApplication::sendEvent(receiver, &dragEnterEvent);
- w = QDragManager::self()->currentTarget();
- if (!w)
-#endif
- break;
- }
- if (e->type() == QEvent::DragMove || e->type() == QEvent::Drop) {
- QDropEvent *dragEvent = static_cast<QDropEvent *>(e);
- QWidget *origReciver = static_cast<QWidget *>(receiver);
- while (origReciver && w != origReciver) {
- dragEvent->p = origReciver->mapToParent(dragEvent->p);
- origReciver = origReciver->parentWidget();
- }
- }
- res = d->notify_helper(w, e);
- if (e->type() != QEvent::DragMove
-#ifndef QT_NO_GRAPHICSVIEW
- && !isProxyWidget
-#endif
- )
- QDragManager::self()->setCurrentTarget(0, e->type() == QEvent::Drop);
- }
- break;
-#endif
- case QEvent::TouchBegin:
- // Note: TouchUpdate and TouchEnd events are never propagated
- {
- QWidget *widget = static_cast<QWidget *>(receiver);
- QTouchEvent *touchEvent = static_cast<QTouchEvent *>(e);
- bool eventAccepted = touchEvent->isAccepted();
- if (widget->testAttribute(Qt::WA_AcceptTouchEvents) && e->spontaneous()) {
- // give the widget focus if the focus policy allows it
- QApplicationPrivate::giveFocusAccordingToFocusPolicy(widget,
- Qt::ClickFocus,
- Qt::MouseFocusReason);
- }
-
- while (widget) {
- // first, try to deliver the touch event
- bool acceptTouchEvents = widget->testAttribute(Qt::WA_AcceptTouchEvents);
- touchEvent->setWidget(widget);
- touchEvent->setAccepted(acceptTouchEvents);
- QWeakPointer<QWidget> p = widget;
- res = acceptTouchEvents && d->notify_helper(widget, touchEvent);
- eventAccepted = touchEvent->isAccepted();
- if (p.isNull()) {
- // widget was deleted
- widget = 0;
- } else {
- widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, res && eventAccepted);
- }
- touchEvent->spont = false;
- if (res && eventAccepted) {
- // the first widget to accept the TouchBegin gets an implicit grab.
- for (int i = 0; i < touchEvent->touchPoints().count(); ++i) {
- const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().at(i);
- d->widgetForTouchPointId[touchPoint.id()] = widget;
- }
- break;
- } else if (p.isNull() || widget->isWindow() || widget->testAttribute(Qt::WA_NoMousePropagation)) {
- break;
- }
- QPoint offset = widget->pos();
- widget = widget->parentWidget();
- touchEvent->setWidget(widget);
- for (int i = 0; i < touchEvent->_touchPoints.size(); ++i) {
- QTouchEvent::TouchPoint &pt = touchEvent->_touchPoints[i];
- QRectF rect = pt.rect();
- rect.moveCenter(offset);
- pt.d->rect = rect;
- pt.d->startPos = pt.startPos() + offset;
- pt.d->lastPos = pt.lastPos() + offset;
- }
- }
-
- touchEvent->setAccepted(eventAccepted);
- break;
- }
- case QEvent::RequestSoftwareInputPanel:
- case QEvent::CloseSoftwareInputPanel:
-#ifndef QT_NO_IM
- if (receiver->isWidgetType()) {
- QWidget *w = static_cast<QWidget *>(receiver);
- QInputContext *ic = w->inputContext();
- if (ic && ic->filterEvent(e)) {
- break;
- }
- }
-#endif
- res = d->notify_helper(receiver, e);
- break;
-
-#ifndef QT_NO_GESTURES
- case QEvent::NativeGesture:
- {
- // only propagate the first gesture event (after the GID_BEGIN)
- QWidget *w = static_cast<QWidget *>(receiver);
- while (w) {
- e->ignore();
- res = d->notify_helper(w, e);
- if ((res && e->isAccepted()) || w->isWindow())
- break;
- w = w->parentWidget();
- }
- break;
- }
- case QEvent::Gesture:
- case QEvent::GestureOverride:
- {
- if (receiver->isWidgetType()) {
- QWidget *w = static_cast<QWidget *>(receiver);
- QGestureEvent *gestureEvent = static_cast<QGestureEvent *>(e);
- QList<QGesture *> allGestures = gestureEvent->gestures();
-
- bool eventAccepted = gestureEvent->isAccepted();
- bool wasAccepted = eventAccepted;
- while (w) {
- // send only gestures the widget expects
- QList<QGesture *> gestures;
- QWidgetPrivate *wd = w->d_func();
- for (int i = 0; i < allGestures.size();) {
- QGesture *g = allGestures.at(i);
- Qt::GestureType type = g->gestureType();
- QMap<Qt::GestureType, Qt::GestureFlags>::iterator contextit =
- wd->gestureContext.find(type);
- bool deliver = contextit != wd->gestureContext.end() &&
- (g->state() == Qt::GestureStarted || w == receiver ||
- (contextit.value() & Qt::ReceivePartialGestures));
- if (deliver) {
- allGestures.removeAt(i);
- gestures.append(g);
- } else {
- ++i;
- }
- }
- if (!gestures.isEmpty()) { // we have gestures for this w
- QGestureEvent ge(gestures);
- ge.t = gestureEvent->t;
- ge.spont = gestureEvent->spont;
- ge.m_accept = wasAccepted;
- ge.d_func()->accepted = gestureEvent->d_func()->accepted;
- res = d->notify_helper(w, &ge);
- gestureEvent->spont = false;
- eventAccepted = ge.isAccepted();
- for (int i = 0; i < gestures.size(); ++i) {
- QGesture *g = gestures.at(i);
- // Ignore res [event return value] because handling of multiple gestures
- // packed into a single QEvent depends on not consuming the event
- if (eventAccepted || ge.isAccepted(g)) {
- // if the gesture was accepted, mark the target widget for it
- gestureEvent->d_func()->targetWidgets[g->gestureType()] = w;
- gestureEvent->setAccepted(g, true);
- } else {
- // if the gesture was explicitly ignored by the application,
- // put it back so a parent can get it
- allGestures.append(g);
- }
- }
- }
- if (allGestures.isEmpty()) // everything delivered
- break;
- if (w->isWindow())
- break;
- w = w->parentWidget();
- }
- foreach (QGesture *g, allGestures)
- gestureEvent->setAccepted(g, false);
- gestureEvent->m_accept = false; // to make sure we check individual gestures
- } else {
- res = d->notify_helper(receiver, e);
- }
- break;
- }
-#endif // QT_NO_GESTURES
-#ifdef QT_MAC_USE_COCOA
- case QEvent::Enter:
- if (receiver->isWidgetType()) {
- QWidget *w = static_cast<QWidget *>(receiver);
- if (w->testAttribute(Qt::WA_AcceptTouchEvents))
- qt_widget_private(w)->registerTouchWindow(true);
- }
- res = d->notify_helper(receiver, e);
- break;
- case QEvent::Leave:
- if (receiver->isWidgetType()) {
- QWidget *w = static_cast<QWidget *>(receiver);
- if (w->testAttribute(Qt::WA_AcceptTouchEvents))
- qt_widget_private(w)->registerTouchWindow(false);
- }
- res = d->notify_helper(receiver, e);
- break;
-#endif
- default:
- res = d->notify_helper(receiver, e);
- break;
- }
-
- return res;
-}
-
-bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e)
-{
- // send to all application event filters
- if (sendThroughApplicationEventFilters(receiver, e))
- return true;
-
- if (receiver->isWidgetType()) {
- QWidget *widget = static_cast<QWidget *>(receiver);
-
-#if !defined(Q_WS_WINCE) || (defined(GWES_ICONCURS) && !defined(QT_NO_CURSOR))
- // toggle HasMouse widget state on enter and leave
- if ((e->type() == QEvent::Enter || e->type() == QEvent::DragEnter) &&
- (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == widget->window()))
- widget->setAttribute(Qt::WA_UnderMouse, true);
- else if (e->type() == QEvent::Leave || e->type() == QEvent::DragLeave)
- widget->setAttribute(Qt::WA_UnderMouse, false);
-#endif
-
- if (QLayout *layout=widget->d_func()->layout) {
- layout->widgetEvent(e);
- }
- }
-
- // send to all receiver event filters
- if (sendThroughObjectEventFilters(receiver, e))
- return true;
-
- // deliver the event
- bool consumed = receiver->event(e);
- e->spont = false;
- return consumed;
-}
-
-
-/*!
- \class QSessionManager
- \brief The QSessionManager class provides access to the session manager.
-
- A session manager in a desktop environment (in which Qt GUI applications
- live) keeps track of a session, which is a group of running applications,
- each of which has a particular state. The state of an application contains
- (most notably) the documents the application has open and the position and
- size of its windows.
-
- The session manager is used to save the session, e.g., when the machine is
- shut down, and to restore a session, e.g., when the machine is started up.
- We recommend that you use QSettings to save an application's settings,
- for example, window positions, recently used files, etc. When the
- application is restarted by the session manager, you can restore the
- settings.
-
- QSessionManager provides an interface between the application and the
- session manager so that the program can work well with the session manager.
- In Qt, session management requests for action are handled by the two
- virtual functions QApplication::commitData() and QApplication::saveState().
- Both provide a reference to a session manager object as argument, to allow
- the application to communicate with the session manager. The session
- manager can only be accessed through these functions.
-
- No user interaction is possible \e unless the application gets explicit
- permission from the session manager. You ask for permission by calling
- allowsInteraction() or, if it is really urgent, allowsErrorInteraction().
- Qt does not enforce this, but the session manager may.
-
- You can try to abort the shutdown process by calling cancel(). The default
- commitData() function does this if some top-level window rejected its
- closeEvent().
-
- For sophisticated session managers provided on Unix/X11, QSessionManager
- offers further possibilities to fine-tune an application's session
- management behavior: setRestartCommand(), setDiscardCommand(),
- setRestartHint(), setProperty(), requestPhase2(). See the respective
- function descriptions for further details.
-
- \sa QApplication, {Session Management}
-*/
-
-/*! \enum QSessionManager::RestartHint
-
- This enum type defines the circumstances under which this application wants
- to be restarted by the session manager. The current values are:
-
- \value RestartIfRunning If the application is still running when the
- session is shut down, it wants to be restarted
- at the start of the next session.
-
- \value RestartAnyway The application wants to be started at the
- start of the next session, no matter what.
- (This is useful for utilities that run just
- after startup and then quit.)
-
- \value RestartImmediately The application wants to be started immediately
- whenever it is not running.
-
- \value RestartNever The application does not want to be restarted
- automatically.
-
- The default hint is \c RestartIfRunning.
-*/
-
-
-/*!
- \fn QString QSessionManager::sessionId() const
-
- Returns the identifier of the current session.
-
- If the application has been restored from an earlier session, this
- identifier is the same as it was in the earlier session.
-
- \sa sessionKey(), QApplication::sessionId()
-*/
-
-/*!
- \fn QString QSessionManager::sessionKey() const
-
- Returns the session key in the current session.
-
- If the application has been restored from an earlier session, this key is
- the same as it was when the previous session ended.
-
- The session key changes with every call of commitData() or saveState().
-
- \sa sessionId(), QApplication::sessionKey()
-*/
-
-/*!
- \fn void* QSessionManager::handle() const
-
- \internal
-*/
-
-/*!
- \fn bool QSessionManager::allowsInteraction()
-
- Asks the session manager for permission to interact with the user. Returns
- true if interaction is permitted; otherwise returns false.
-
- The rationale behind this mechanism is to make it possible to synchronize
- user interaction during a shutdown. Advanced session managers may ask all
- applications simultaneously to commit their data, resulting in a much
- faster shutdown.
-
- When the interaction is completed we strongly recommend releasing the user
- interaction semaphore with a call to release(). This way, other
- applications may get the chance to interact with the user while your
- application is still busy saving data. (The semaphore is implicitly
- released when the application exits.)
-
- If the user decides to cancel the shutdown process during the interaction
- phase, you must tell the session manager that this has happened by calling
- cancel().
-
- Here's an example of how an application's QApplication::commitData() might
- be implemented:
-
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 8
-
- If an error occurred within the application while saving its data, you may
- want to try allowsErrorInteraction() instead.
-
- \sa QApplication::commitData(), release(), cancel()
-*/
-
-
-/*!
- \fn bool QSessionManager::allowsErrorInteraction()
-
- Returns true if error interaction is permitted; otherwise returns false.
-
- This is similar to allowsInteraction(), but also enables the application to
- tell the user about any errors that occur. Session managers may give error
- interaction requests higher priority, which means that it is more likely
- that an error interaction is permitted. However, you are still not
- guaranteed that the session manager will allow interaction.
-
- \sa allowsInteraction(), release(), cancel()
-*/
-
-/*!
- \fn void QSessionManager::release()
-
- Releases the session manager's interaction semaphore after an interaction
- phase.
-
- \sa allowsInteraction(), allowsErrorInteraction()
-*/
-
-/*!
- \fn void QSessionManager::cancel()
-
- Tells the session manager to cancel the shutdown process. Applications
- should not call this function without asking the user first.
-
- \sa allowsInteraction(), allowsErrorInteraction()
-*/
-
-/*!
- \fn void QSessionManager::setRestartHint(RestartHint hint)
-
- Sets the application's restart hint to \a hint. On application startup, the
- hint is set to \c RestartIfRunning.
-
- \note These flags are only hints, a session manager may or may not respect
- them.
-
- We recommend setting the restart hint in QApplication::saveState() because
- most session managers perform a checkpoint shortly after an application's
- startup.
-
- \sa restartHint()
-*/
-
-/*!
- \fn QSessionManager::RestartHint QSessionManager::restartHint() const
-
- Returns the application's current restart hint. The default is
- \c RestartIfRunning.
-
- \sa setRestartHint()
-*/
-
-/*!
- \fn void QSessionManager::setRestartCommand(const QStringList& command)
-
- If the session manager is capable of restoring sessions it will execute
- \a command in order to restore the application. The command defaults to
-
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 9
-
- The \c -session option is mandatory; otherwise QApplication cannot tell
- whether it has been restored or what the current session identifier is.
- See QApplication::isSessionRestored() and QApplication::sessionId() for
- details.
-
- If your application is very simple, it may be possible to store the entire
- application state in additional command line options. This is usually a
- very bad idea because command lines are often limited to a few hundred
- bytes. Instead, use QSettings, temporary files, or a database for this
- purpose. By marking the data with the unique sessionId(), you will be able
- to restore the application in a future session.
-
- \sa restartCommand(), setDiscardCommand(), setRestartHint()
-*/
-
-/*!
- \fn QStringList QSessionManager::restartCommand() const
-
- Returns the currently set restart command.
-
- To iterate over the list, you can use the \l foreach pseudo-keyword:
-
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 10
-
- \sa setRestartCommand(), restartHint()
-*/
-
-/*!
- \fn void QSessionManager::setDiscardCommand(const QStringList& list)
-
- Sets the discard command to the given \a list.
-
- \sa discardCommand(), setRestartCommand()
-*/
-
-
-/*!
- \fn QStringList QSessionManager::discardCommand() const
-
- Returns the currently set discard command.
-
- To iterate over the list, you can use the \l foreach pseudo-keyword:
-
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 11
-
- \sa setDiscardCommand(), restartCommand(), setRestartCommand()
-*/
-
-/*!
- \fn void QSessionManager::setManagerProperty(const QString &name, const QString &value)
- \overload
-
- Low-level write access to the application's identification and state
- records are kept in the session manager.
-
- The property called \a name has its value set to the string \a value.
-*/
-
-/*!
- \fn void QSessionManager::setManagerProperty(const QString& name,
- const QStringList& value)
-
- Low-level write access to the application's identification and state record
- are kept in the session manager.
-
- The property called \a name has its value set to the string list \a value.
-*/
-
-/*!
- \fn bool QSessionManager::isPhase2() const
-
- Returns true if the session manager is currently performing a second
- session management phase; otherwise returns false.
-
- \sa requestPhase2()
-*/
-
-/*!
- \fn void QSessionManager::requestPhase2()
-
- Requests a second session management phase for the application. The
- application may then return immediately from the QApplication::commitData()
- or QApplication::saveState() function, and they will be called again once
- most or all other applications have finished their session management.
-
- The two phases are useful for applications such as the X11 window manager
- that need to store information about another application's windows and
- therefore have to wait until these applications have completed their
- respective session management tasks.
-
- \note If another application has requested a second phase it may get called
- before, simultaneously with, or after your application's second phase.
-
- \sa isPhase2()
-*/
-
-/*****************************************************************************
- Stubbed session management support
- *****************************************************************************/
-#ifndef QT_NO_SESSIONMANAGER
-#if defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_WS_QWS)
-
-#if defined(Q_OS_WINCE)
-HRESULT qt_CoCreateGuid(GUID* guid)
-{
- // We will use the following information to create the GUID
- // 1. absolute path to application
- wchar_t tempFilename[MAX_PATH];
- if (!GetModuleFileName(0, tempFilename, MAX_PATH))
- return S_FALSE;
- unsigned int hash = qHash(QString::fromWCharArray(tempFilename));
- guid->Data1 = hash;
- // 2. creation time of file
- QFileInfo info(QString::fromWCharArray(tempFilename));
- guid->Data2 = qHash(info.created().toTime_t());
- // 3. current system time
- guid->Data3 = qHash(QDateTime::currentDateTime().toTime_t());
- return S_OK;
-}
-#if !defined(OLE32_MCOMGUID) || defined(QT_WINCE_FORCE_CREATE_GUID)
-#define CoCreateGuid qt_CoCreateGuid
-#endif
-
-#endif
-
-class QSessionManagerPrivate : public QObjectPrivate
-{
-public:
- QStringList restartCommand;
- QStringList discardCommand;
- QString sessionId;
- QString sessionKey;
- QSessionManager::RestartHint restartHint;
-};
-
-QSessionManager* qt_session_manager_self = 0;
-QSessionManager::QSessionManager(QApplication * app, QString &id, QString &key)
- : QObject(*new QSessionManagerPrivate, app)
-{
- Q_D(QSessionManager);
- setObjectName(QLatin1String("qt_sessionmanager"));
- qt_session_manager_self = this;
-#if defined(Q_WS_WIN)
- wchar_t guidstr[40];
- GUID guid;
- CoCreateGuid(&guid);
- StringFromGUID2(guid, guidstr, 40);
- id = QString::fromWCharArray(guidstr);
- CoCreateGuid(&guid);
- StringFromGUID2(guid, guidstr, 40);
- key = QString::fromWCharArray(guidstr);
-#endif
- d->sessionId = id;
- d->sessionKey = key;
- d->restartHint = RestartIfRunning;
-}
-
-QSessionManager::~QSessionManager()
-{
- qt_session_manager_self = 0;
-}
-
-QString QSessionManager::sessionId() const
-{
- Q_D(const QSessionManager);
- return d->sessionId;
-}
-
-QString QSessionManager::sessionKey() const
-{
- Q_D(const QSessionManager);
- return d->sessionKey;
-}
-
-
-#if defined(Q_WS_X11) || defined(Q_WS_MAC)
-void* QSessionManager::handle() const
-{
- return 0;
-}
-#endif
-
-#if !defined(Q_WS_WIN)
-bool QSessionManager::allowsInteraction()
-{
- return true;
-}
-
-bool QSessionManager::allowsErrorInteraction()
-{
- return true;
-}
-void QSessionManager::release()
-{
-}
-
-void QSessionManager::cancel()
-{
-}
-#endif
-
-
-void QSessionManager::setRestartHint(QSessionManager::RestartHint hint)
-{
- Q_D(QSessionManager);
- d->restartHint = hint;
-}
-
-QSessionManager::RestartHint QSessionManager::restartHint() const
-{
- Q_D(const QSessionManager);
- return d->restartHint;
-}
-
-void QSessionManager::setRestartCommand(const QStringList& command)
-{
- Q_D(QSessionManager);
- d->restartCommand = command;
-}
-
-QStringList QSessionManager::restartCommand() const
-{
- Q_D(const QSessionManager);
- return d->restartCommand;
-}
-
-void QSessionManager::setDiscardCommand(const QStringList& command)
-{
- Q_D(QSessionManager);
- d->discardCommand = command;
-}
-
-QStringList QSessionManager::discardCommand() const
-{
- Q_D(const QSessionManager);
- return d->discardCommand;
-}
-
-void QSessionManager::setManagerProperty(const QString&, const QString&)
-{
-}
-
-void QSessionManager::setManagerProperty(const QString&, const QStringList&)
-{
-}
-
-bool QSessionManager::isPhase2() const
-{
- return false;
-}
-
-void QSessionManager::requestPhase2()
-{
-}
-
-#endif
-#endif // QT_NO_SESSIONMANAGER
-
-/*!
- \typedef QApplication::ColorMode
- \compat
-
- Use ColorSpec instead.
-*/
-
-/*!
- \fn Qt::MacintoshVersion QApplication::macVersion()
-
- Use QSysInfo::MacintoshVersion instead.
-*/
-
-/*!
- \fn QApplication::ColorMode QApplication::colorMode()
-
- Use colorSpec() instead, and use ColorSpec as the enum type.
-*/
-
-/*!
- \fn void QApplication::setColorMode(ColorMode mode)
-
- Use setColorSpec() instead, and pass a ColorSpec value instead.
-*/
-
-/*!
- \fn bool QApplication::hasGlobalMouseTracking()
-
- This feature does not exist anymore. This function always returns true
- in Qt 4.
-*/
-
-/*!
- \fn void QApplication::setGlobalMouseTracking(bool dummy)
-
- This function does nothing in Qt 4. The \a dummy parameter is ignored.
-*/
-
-/*!
- \fn void QApplication::flushX()
-
- Use flush() instead.
-*/
-
-/*!
- \fn void QApplication::setWinStyleHighlightColor(const QColor &c)
-
- Use the palette instead.
-
- \oldcode
- app.setWinStyleHighlightColor(color);
- \newcode
- QPalette palette(QApplication::palette());
- palette.setColor(QPalette::Highlight, color);
- QApplication::setPalette(palette);
- \endcode
-*/
-
-/*!
- \fn void QApplication::setPalette(const QPalette &pal, bool b, const char* className = 0)
-
- Use the two-argument overload instead.
-*/
-
-/*!
- \fn void QApplication::setFont(const QFont &font, bool b, const char* className = 0)
-
- Use the two-argument overload instead.
-*/
-
-/*!
- \fn const QColor &QApplication::winStyleHighlightColor()
-
- Use QApplication::palette().color(QPalette::Active, QPalette::Highlight) instead.
-*/
-
-/*!
- \fn QWidget *QApplication::widgetAt(int x, int y, bool child)
-
- Use the two-argument widgetAt() overload to get the child widget. To get
- the top-level widget do this:
-
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 12
-*/
-
-/*!
- \fn QWidget *QApplication::widgetAt(const QPoint &point, bool child)
-
- Use the single-argument widgetAt() overload to get the child widget. To get
- the top-level widget do this:
-
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 13
-*/
-
-#ifdef QT3_SUPPORT
-QWidget *QApplication::mainWidget()
-{
- return QApplicationPrivate::main_widget;
-}
-#endif
-bool QApplicationPrivate::inPopupMode() const
-{
- return QApplicationPrivate::popupWidgets != 0;
-}
-
-/*!
- \property QApplication::quitOnLastWindowClosed
-
- \brief whether the application implicitly quits when the last window is
- closed.
-
- The default is true.
-
- If this property is true, the applications quits when the last visible
- primary window (i.e. window with no parent) with the Qt::WA_QuitOnClose
- attribute set is closed. By default this attribute is set for all widgets
- except for sub-windows. Refer to \l{Qt::WindowType} for a detailed list of
- Qt::Window objects.
-
- \sa quit(), QWidget::close()
- */
-
-void QApplication::setQuitOnLastWindowClosed(bool quit)
-{
- QApplicationPrivate::quitOnLastWindowClosed = quit;
-}
-
-bool QApplication::quitOnLastWindowClosed()
-{
- return QApplicationPrivate::quitOnLastWindowClosed;
-}
-
-void QApplicationPrivate::emitLastWindowClosed()
-{
- if (qApp && qApp->d_func()->in_exec) {
- if (QApplicationPrivate::quitOnLastWindowClosed) {
- // get ready to quit, this event might be removed if the
- // event loop is re-entered, however
- QApplication::postEvent(qApp, new QEvent(QEvent::Quit));
- }
- emit qApp->lastWindowClosed();
- }
-}
-
-/*! \variable QApplication::NormalColors
- \compat
-
- Use \l NormalColor instead.
-*/
-
-/*! \variable QApplication::CustomColors
- \compat
-
- Use \l CustomColor instead.
-*/
-
-#ifdef QT_KEYPAD_NAVIGATION
-/*!
- Sets the kind of focus navigation Qt should use to \a mode.
-
- This feature is available in Qt for Embedded Linux, Symbian and Windows CE
- only.
-
- \note On Windows CE this feature is disabled by default for touch device
- mkspecs. To enable keypad navigation, build Qt with
- QT_KEYPAD_NAVIGATION defined.
-
- \note On Symbian, setting the mode to Qt::NavigationModeCursorAuto will enable a
- virtual mouse cursor on non touchscreen devices, which is controlled
- by the cursor keys if there is no analog pointer device.
- On other platforms and on touchscreen devices, it has the same
- meaning as Qt::NavigationModeNone.
-
- \since 4.6
-
- \sa keypadNavigationEnabled()
-*/
-void QApplication::setNavigationMode(Qt::NavigationMode mode)
-{
-#ifdef Q_OS_SYMBIAN
- QApplicationPrivate::setNavigationMode(mode);
-#else
- QApplicationPrivate::navigationMode = mode;
-#endif
-}
-
-/*!
- Returns what kind of focus navigation Qt is using.
-
- This feature is available in Qt for Embedded Linux, Symbian and Windows CE
- only.
-
- \note On Windows CE this feature is disabled by default for touch device
- mkspecs. To enable keypad navigation, build Qt with
- QT_KEYPAD_NAVIGATION defined.
-
- \note On Symbian, the default mode is Qt::NavigationModeNone for touch
- devices, and Qt::NavigationModeKeypadDirectional.
-
- \since 4.6
-
- \sa keypadNavigationEnabled()
-*/
-Qt::NavigationMode QApplication::navigationMode()
-{
- return QApplicationPrivate::navigationMode;
-}
-
-/*!
- Sets whether Qt should use focus navigation suitable for use with a
- minimal keypad.
-
- This feature is available in Qt for Embedded Linux, Symbian and Windows CE
- only.
-
- \note On Windows CE this feature is disabled by default for touch device
- mkspecs. To enable keypad navigation, build Qt with
- QT_KEYPAD_NAVIGATION defined.
-
- \deprecated
-
- \sa setNavigationMode()
-*/
-void QApplication::setKeypadNavigationEnabled(bool enable)
-{
- if (enable) {
-#ifdef Q_OS_SYMBIAN
- QApplication::setNavigationMode(Qt::NavigationModeKeypadDirectional);
-#else
- QApplication::setNavigationMode(Qt::NavigationModeKeypadTabOrder);
-#endif
- }
- else {
- QApplication::setNavigationMode(Qt::NavigationModeNone);
- }
-}
-
-/*!
- Returns true if Qt is set to use keypad navigation; otherwise returns
- false. The default value is true on Symbian, but false on other platforms.
-
- This feature is available in Qt for Embedded Linux, Symbian and Windows CE
- only.
-
- \note On Windows CE this feature is disabled by default for touch device
- mkspecs. To enable keypad navigation, build Qt with
- QT_KEYPAD_NAVIGATION defined.
-
- \deprecated
-
- \sa navigationMode()
-*/
-bool QApplication::keypadNavigationEnabled()
-{
- return QApplicationPrivate::navigationMode == Qt::NavigationModeKeypadTabOrder ||
- QApplicationPrivate::navigationMode == Qt::NavigationModeKeypadDirectional;
-}
-#endif
-
-/*!
- \fn void QApplication::alert(QWidget *widget, int msec)
- \since 4.3
-
- Causes an alert to be shown for \a widget if the window is not the active
- window. The alert is shown for \a msec miliseconds. If \a msec is zero (the
- default), then the alert is shown indefinitely until the window becomes
- active again.
-
- Currently this function does nothing on Qt for Embedded Linux.
-
- On Mac OS X, this works more at the application level and will cause the
- application icon to bounce in the dock.
-
- On Windows, this causes the window's taskbar entry to flash for a time. If
- \a msec is zero, the flashing will stop and the taskbar entry will turn a
- different color (currently orange).
-
- On X11, this will cause the window to be marked as "demands attention", the
- window must not be hidden (i.e. not have hide() called on it, but be
- visible in some sort of way) in order for this to work.
-*/
-
-/*!
- \property QApplication::cursorFlashTime
- \brief the text cursor's flash (blink) time in milliseconds
-
- The flash time is the time required to display, invert and restore the
- caret display. Usually the text cursor is displayed for half the cursor
- flash time, then hidden for the same amount of time, but this may vary.
-
- The default value on X11 is 1000 milliseconds. On Windows, the
- \gui{Control Panel} value is used and setting this property sets the cursor
- flash time for all applications.
-
- We recommend that widgets do not cache this value as it may change at any
- time if the user changes the global desktop settings.
-*/
-
-/*!
- \property QApplication::doubleClickInterval
- \brief the time limit in milliseconds that distinguishes a double click
- from two consecutive mouse clicks
-
- The default value on X11 is 400 milliseconds. On Windows and Mac OS, the
- operating system's value is used. However, on Windows and Symbian OS,
- calling this function sets the double click interval for all applications.
-*/
-
-/*!
- \property QApplication::keyboardInputInterval
- \brief the time limit in milliseconds that distinguishes a key press
- from two consecutive key presses
- \since 4.2
-
- The default value on X11 is 400 milliseconds. On Windows and Mac OS, the
- operating system's value is used.
-*/
-
-/*!
- \property QApplication::wheelScrollLines
- \brief the number of lines to scroll a widget, when the
- mouse wheel is rotated.
-
- If the value exceeds the widget's number of visible lines, the widget
- should interpret the scroll operation as a single \e{page up} or
- \e{page down}. If the widget is an \l{QAbstractItemView}{item view class},
- then the result of scrolling one \e line depends on the setting of the
- widget's \l{QAbstractItemView::verticalScrollMode()}{scroll mode}. Scroll
- one \e line can mean \l{QAbstractItemView::ScrollPerItem}{scroll one item}
- or \l{QAbstractItemView::ScrollPerPixel}{scroll one pixel}.
-
- By default, this property has a value of 3.
-*/
-
-/*!
- \fn void QApplication::setEffectEnabled(Qt::UIEffect effect, bool enable)
-
- Enables the UI effect \a effect if \a enable is true, otherwise the effect
- will not be used.
-
- \note All effects are disabled on screens running at less than 16-bit color
- depth.
-
- \sa isEffectEnabled(), Qt::UIEffect, setDesktopSettingsAware()
-*/
-
-/*!
- \fn bool QApplication::isEffectEnabled(Qt::UIEffect effect)
-
- Returns true if \a effect is enabled; otherwise returns false.
-
- By default, Qt will try to use the desktop settings. To prevent this, call
- setDesktopSettingsAware(false).
-
- \note All effects are disabled on screens running at less than 16-bit color
- depth.
-
- \sa setEffectEnabled(), Qt::UIEffect
-*/
-
-/*!
- \fn QWidget *QApplication::mainWidget()
-
- Returns the main application widget, or 0 if there is no main widget.
-*/
-
-/*!
- \fn void QApplication::setMainWidget(QWidget *mainWidget)
-
- Sets the application's main widget to \a mainWidget.
-
- In most respects the main widget is like any other widget, except that if
- it is closed, the application exits. QApplication does \e not take
- ownership of the \a mainWidget, so if you create your main widget on the
- heap you must delete it yourself.
-
- You need not have a main widget; connecting lastWindowClosed() to quit()
- is an alternative.
-
- On X11, this function also resizes and moves the main widget according
- to the \e -geometry command-line option, so you should set the default
- geometry (using \l QWidget::setGeometry()) before calling setMainWidget().
-
- \sa mainWidget(), exec(), quit()
-*/
-
-/*!
- \fn void QApplication::beep()
-
- Sounds the bell, using the default volume and sound. The function is \e not
- available in Qt for Embedded Linux.
-*/
-
-/*!
- \fn void QApplication::setOverrideCursor(const QCursor &cursor)
-
- Sets the application override cursor to \a cursor.
-
- Application override cursors are intended for showing the user that the
- application is in a special state, for example during an operation that
- might take some time.
-
- This cursor will be displayed in all the application's widgets until
- restoreOverrideCursor() or another setOverrideCursor() is called.
-
- Application cursors are stored on an internal stack. setOverrideCursor()
- pushes the cursor onto the stack, and restoreOverrideCursor() pops the
- active cursor off the stack. changeOverrideCursor() changes the curently
- active application override cursor.
-
- Every setOverrideCursor() must eventually be followed by a corresponding
- restoreOverrideCursor(), otherwise the stack will never be emptied.
-
- Example:
- \snippet doc/src/snippets/code/src_gui_kernel_qapplication_x11.cpp 0
-
- \sa overrideCursor(), restoreOverrideCursor(), changeOverrideCursor(),
- QWidget::setCursor()
-*/
-
-/*!
- \fn void QApplication::restoreOverrideCursor()
-
- Undoes the last setOverrideCursor().
-
- If setOverrideCursor() has been called twice, calling
- restoreOverrideCursor() will activate the first cursor set. Calling this
- function a second time restores the original widgets' cursors.
-
- \sa setOverrideCursor(), overrideCursor()
-*/
-
-/*!
- \macro qApp
- \relates QApplication
-
- A global pointer referring to the unique application object. It is
- equivalent to the pointer returned by the QCoreApplication::instance()
- function except that, in GUI applications, it is a pointer to a
- QApplication instance.
-
- Only one application object can be created.
-
- \sa QCoreApplication::instance()
-*/
-
-#ifndef QT_NO_IM
-// ************************************************************************
-// Input Method support
-// ************************************************************************
-
-/*!
- This function replaces the QInputContext instance used by the application
- with \a inputContext.
-
- Qt takes ownership of the given \a inputContext.
-
- \sa inputContext()
-*/
-void QApplication::setInputContext(QInputContext *inputContext)
-{
- if (inputContext == QApplicationPrivate::inputContext)
- return;
- if (!inputContext) {
- qWarning("QApplication::setInputContext: called with 0 input context");
- return;
- }
- delete QApplicationPrivate::inputContext;
- QApplicationPrivate::inputContext = inputContext;
- QApplicationPrivate::inputContext->setParent(this);
-}
-
-/*!
- Returns the QInputContext instance used by the application.
-
- \sa setInputContext()
-*/
-QInputContext *QApplication::inputContext() const
-{
- Q_D(const QApplication);
- Q_UNUSED(d);// only static members being used.
- if (QApplicationPrivate::is_app_closing)
- return d->inputContext;
-#ifdef Q_WS_X11
- if (!X11)
- return 0;
- if (!d->inputContext) {
- QApplication *that = const_cast<QApplication *>(this);
- QInputContext *qic = QInputContextFactory::create(X11->default_im, that);
- // fallback to default X Input Method.
- if (!qic)
- qic = QInputContextFactory::create(QLatin1String("xim"), that);
- that->d_func()->inputContext = qic;
- }
-#elif defined(Q_OS_SYMBIAN)
- if (!d->inputContext) {
- QApplication *that = const_cast<QApplication *>(this);
- const QStringList keys = QInputContextFactory::keys();
- // Try hbim and coefep first, then try others.
- if (keys.contains(QLatin1String("hbim"))) {
- that->d_func()->inputContext = QInputContextFactory::create(QLatin1String("hbim"), that);
- } else if (keys.contains(QLatin1String("coefep"))) {
- that->d_func()->inputContext = QInputContextFactory::create(QLatin1String("coefep"), that);
- } else {
- for (int c = 0; c < keys.size() && !d->inputContext; ++c) {
- that->d_func()->inputContext = QInputContextFactory::create(keys[c], that);
- }
- }
- }
-#endif
- return d->inputContext;
-}
-#endif // QT_NO_IM
-
-//Returns the current platform used by keyBindings
-uint QApplicationPrivate::currentPlatform(){
- uint platform = KB_Win;
-#ifdef Q_WS_MAC
- platform = KB_Mac;
-#elif defined Q_WS_X11
- platform = KB_X11;
- if (X11->desktopEnvironment == DE_KDE)
- platform |= KB_KDE;
- if (X11->desktopEnvironment == DE_GNOME)
- platform |= KB_Gnome;
- if (X11->desktopEnvironment == DE_CDE)
- platform |= KB_CDE;
-#elif defined(Q_OS_SYMBIAN)
- platform = KB_S60;
-#endif
- return platform;
-}
-
-bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event)
-{
- return QCoreApplication::sendSpontaneousEvent(receiver, event);
-}
-
-
-/*!
- \since 4.2
-
- Returns the current keyboard input locale.
-*/
-QLocale QApplication::keyboardInputLocale()
-{
- if (!QApplicationPrivate::checkInstance("keyboardInputLocale"))
- return QLocale::c();
- return qt_keymapper_private()->keyboardInputLocale;
-}
-
-/*!
- \since 4.2
-
- Returns the current keyboard input direction.
-*/
-Qt::LayoutDirection QApplication::keyboardInputDirection()
-{
- if (!QApplicationPrivate::checkInstance("keyboardInputDirection"))
- return Qt::LeftToRight;
- return qt_keymapper_private()->keyboardInputDirection;
-}
-
-void QApplicationPrivate::giveFocusAccordingToFocusPolicy(QWidget *widget,
- Qt::FocusPolicy focusPolicy,
- Qt::FocusReason focusReason)
-{
- QWidget *focusWidget = widget;
- while (focusWidget) {
- if (focusWidget->isEnabled()
- && QApplicationPrivate::shouldSetFocus(focusWidget, focusPolicy)) {
- focusWidget->setFocus(focusReason);
- break;
- }
- if (focusWidget->isWindow())
- break;
- focusWidget = focusWidget->parentWidget();
- }
-}
-
-bool QApplicationPrivate::shouldSetFocus(QWidget *w, Qt::FocusPolicy policy)
-{
- QWidget *f = w;
- while (f->d_func()->extra && f->d_func()->extra->focus_proxy)
- f = f->d_func()->extra->focus_proxy;
-
- if ((w->focusPolicy() & policy) != policy)
- return false;
- if (w != f && (f->focusPolicy() & policy) != policy)
- return false;
- return true;
-}
-
-/*! \fn QDecoration &QApplication::qwsDecoration()
- Return the QWSDecoration used for decorating windows.
-
- \warning This method is non-portable. It is only available in
- Qt for Embedded Linux.
-
- \sa QDecoration
-*/
-
-/*!
- \fn void QApplication::qwsSetDecoration(QDecoration *decoration)
-
- Sets the QDecoration derived class to use for decorating the
- windows used by Qt for Embedded Linux to the \a decoration
- specified.
-
- This method is non-portable. It is only available in Qt for Embedded Linux.
-
- \sa QDecoration
-*/
-
-/*! \fn QDecoration* QApplication::qwsSetDecoration(const QString &decoration)
- \overload
-
- Requests a QDecoration object for \a decoration from the
- QDecorationFactory.
-
- The string must be one of the QDecorationFactory::keys(). Keys are case
- insensitive.
-
- A later call to the QApplication constructor will override the requested
- style when a "-style" option is passed in as a commandline parameter.
-
- Returns 0 if an unknown \a decoration is passed, otherwise the QStyle object
- returned is set as the application's GUI style.
-*/
-
-/*!
- \fn bool QApplication::qwsEventFilter(QWSEvent *event)
-
- This virtual function is only implemented under Qt for Embedded Linux.
-
- If you create an application that inherits QApplication and
- reimplement this function, you get direct access to all QWS (Q
- Window System) events that the are received from the QWS master
- process. The events are passed in the \a event parameter.
-
- Return true if you want to stop the event from being processed.
- Return false for normal event dispatching. The default
- implementation returns false.
-*/
-
-/*! \fn void QApplication::qwsSetCustomColors(QRgb *colorTable, int start, int numColors)
- Set Qt for Embedded Linux custom color table.
-
- Qt for Embedded Linux on 8-bpp displays allocates a standard 216 color cube.
- The remaining 40 colors may be used by setting a custom color
- table in the QWS master process before any clients connect.
-
- \a colorTable is an array of up to 40 custom colors. \a start is
- the starting index (0-39) and \a numColors is the number of colors
- to be set (1-40).
-
- This method is non-portable. It is available \e only in
- Qt for Embedded Linux.
-
- \note The custom colors will not be used by the default screen
- driver. To make use of the new colors, implement a custom screen
- driver, or use QDirectPainter.
-*/
-
-/*! \fn int QApplication::qwsProcessEvent(QWSEvent* event)
- \internal
-*/
-
-/*! \fn int QApplication::x11ClientMessage(QWidget* w, XEvent* event, bool passive_only)
- \internal
-*/
-
-/*! \fn int QApplication::x11ProcessEvent(XEvent* event)
- This function does the core processing of individual X
- \a{event}s, normally by dispatching Qt events to the right
- destination.
-
- It returns 1 if the event was consumed by special handling, 0 if
- the \a event was consumed by normal handling, and -1 if the \a
- event was for an unrecognized widget.
-
- \sa x11EventFilter()
-*/
-
-/*!
- \fn bool QApplication::x11EventFilter(XEvent *event)
-
- \warning This virtual function is only implemented under X11.
-
- If you create an application that inherits QApplication and
- reimplement this function, you get direct access to all X events
- that the are received from the X server. The events are passed in
- the \a event parameter.
-
- Return true if you want to stop the event from being processed.
- Return false for normal event dispatching. The default
- implementation returns false.
-
- It is only the directly addressed messages that are filtered.
- You must install an event filter directly on the event
- dispatcher, which is returned by
- QAbstractEventDispatcher::instance(), to handle system wide
- messages.
-
- \sa x11ProcessEvent()
-*/
-
-/*! \fn void QApplication::winFocus(QWidget *widget, bool gotFocus)
- \internal
- \since 4.1
-
- If \a gotFocus is true, \a widget will become the active window.
- Otherwise the active window is reset to 0.
-*/
-
-/*! \fn void QApplication::winMouseButtonUp()
- \internal
- */
-
-/*! \fn void QApplication::syncX()
- Synchronizes with the X server in the X11 implementation.
- This normally takes some time. Does nothing on other platforms.
-*/
-
-void QApplicationPrivate::updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent)
-{
- for (int i = 0; i < touchEvent->touchPoints().count(); ++i) {
- QTouchEvent::TouchPoint &touchPoint = touchEvent->_touchPoints[i];
-
- // preserve the sub-pixel resolution
- QRectF rect = touchPoint.screenRect();
- const QPointF screenPos = rect.center();
- const QPointF delta = screenPos - screenPos.toPoint();
-
- rect.moveCenter(widget->mapFromGlobal(screenPos.toPoint()) + delta);
- touchPoint.d->rect = rect;
- if (touchPoint.state() == Qt::TouchPointPressed) {
- touchPoint.d->startPos = widget->mapFromGlobal(touchPoint.startScreenPos().toPoint()) + delta;
- touchPoint.d->lastPos = widget->mapFromGlobal(touchPoint.lastScreenPos().toPoint()) + delta;
- }
- }
-}
-
-void QApplicationPrivate::initializeMultitouch()
-{
- widgetForTouchPointId.clear();
- appCurrentTouchPoints.clear();
-
- initializeMultitouch_sys();
-}
-
-void QApplicationPrivate::cleanupMultitouch()
-{
- cleanupMultitouch_sys();
-
- widgetForTouchPointId.clear();
- appCurrentTouchPoints.clear();
-}
-
-int QApplicationPrivate::findClosestTouchPointId(const QPointF &screenPos)
-{
- int closestTouchPointId = -1;
- qreal closestDistance = qreal(0.);
- foreach (const QTouchEvent::TouchPoint &touchPoint, appCurrentTouchPoints) {
- qreal distance = QLineF(screenPos, touchPoint.screenPos()).length();
- if (closestTouchPointId == -1 || distance < closestDistance) {
- closestTouchPointId = touchPoint.id();
- closestDistance = distance;
- }
- }
- return closestTouchPointId;
-}
-
-void QApplicationPrivate::translateRawTouchEvent(QWidget *window,
- QTouchEvent::DeviceType deviceType,
- const QList<QTouchEvent::TouchPoint> &touchPoints)
-{
- QApplicationPrivate *d = self;
- typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint> > StatesAndTouchPoints;
- QHash<QWidget *, StatesAndTouchPoints> widgetsNeedingEvents;
-
- for (int i = 0; i < touchPoints.count(); ++i) {
- QTouchEvent::TouchPoint touchPoint = touchPoints.at(i);
- // explicitly detach from the original touch point that we got, so even
- // if the touchpoint structs are reused, we will make a copy that we'll
- // deliver to the user (which might want to store the struct for later use).
- touchPoint.d = touchPoint.d->detach();
-
- // update state
- QWeakPointer<QWidget> widget;
- switch (touchPoint.state()) {
- case Qt::TouchPointPressed:
- {
- if (deviceType == QTouchEvent::TouchPad) {
- // on touch-pads, send all touch points to the same widget
- widget = d->widgetForTouchPointId.isEmpty()
- ? QWeakPointer<QWidget>()
- : d->widgetForTouchPointId.constBegin().value();
- }
-
- if (!widget) {
- // determine which widget this event will go to
- if (!window)
- window = QApplication::topLevelAt(touchPoint.screenPos().toPoint());
- if (!window)
- continue;
- widget = window->childAt(window->mapFromGlobal(touchPoint.screenPos().toPoint()));
- if (!widget)
- widget = window;
- }
-
- if (deviceType == QTouchEvent::TouchScreen) {
- int closestTouchPointId = d->findClosestTouchPointId(touchPoint.screenPos());
- QWidget *closestWidget = d->widgetForTouchPointId.value(closestTouchPointId).data();
- if (closestWidget
- && (widget.data()->isAncestorOf(closestWidget) || closestWidget->isAncestorOf(widget.data()))) {
- widget = closestWidget;
- }
- }
-
- d->widgetForTouchPointId[touchPoint.id()] = widget;
- touchPoint.d->startScreenPos = touchPoint.screenPos();
- touchPoint.d->lastScreenPos = touchPoint.screenPos();
- touchPoint.d->startNormalizedPos = touchPoint.normalizedPos();
- touchPoint.d->lastNormalizedPos = touchPoint.normalizedPos();
- if (touchPoint.pressure() < qreal(0.))
- touchPoint.d->pressure = qreal(1.);
-
- d->appCurrentTouchPoints.insert(touchPoint.id(), touchPoint);
- break;
- }
- case Qt::TouchPointReleased:
- {
- widget = d->widgetForTouchPointId.take(touchPoint.id());
- if (!widget)
- continue;
-
- QTouchEvent::TouchPoint previousTouchPoint = d->appCurrentTouchPoints.take(touchPoint.id());
- touchPoint.d->startScreenPos = previousTouchPoint.startScreenPos();
- touchPoint.d->lastScreenPos = previousTouchPoint.screenPos();
- touchPoint.d->startPos = previousTouchPoint.startPos();
- touchPoint.d->lastPos = previousTouchPoint.pos();
- touchPoint.d->startNormalizedPos = previousTouchPoint.startNormalizedPos();
- touchPoint.d->lastNormalizedPos = previousTouchPoint.normalizedPos();
- if (touchPoint.pressure() < qreal(0.))
- touchPoint.d->pressure = qreal(0.);
- break;
- }
- default:
- widget = d->widgetForTouchPointId.value(touchPoint.id());
- if (!widget)
- continue;
-
- Q_ASSERT(d->appCurrentTouchPoints.contains(touchPoint.id()));
- QTouchEvent::TouchPoint previousTouchPoint = d->appCurrentTouchPoints.value(touchPoint.id());
- touchPoint.d->startScreenPos = previousTouchPoint.startScreenPos();
- touchPoint.d->lastScreenPos = previousTouchPoint.screenPos();
- touchPoint.d->startPos = previousTouchPoint.startPos();
- touchPoint.d->lastPos = previousTouchPoint.pos();
- touchPoint.d->startNormalizedPos = previousTouchPoint.startNormalizedPos();
- touchPoint.d->lastNormalizedPos = previousTouchPoint.normalizedPos();
- if (touchPoint.pressure() < qreal(0.))
- touchPoint.d->pressure = qreal(1.);
- d->appCurrentTouchPoints[touchPoint.id()] = touchPoint;
- break;
- }
- Q_ASSERT(widget.data() != 0);
-
- // make the *scene* functions return the same as the *screen* functions
- touchPoint.d->sceneRect = touchPoint.screenRect();
- touchPoint.d->startScenePos = touchPoint.startScreenPos();
- touchPoint.d->lastScenePos = touchPoint.lastScreenPos();
-
- StatesAndTouchPoints &maskAndPoints = widgetsNeedingEvents[widget.data()];
- maskAndPoints.first |= touchPoint.state();
- if (touchPoint.isPrimary())
- maskAndPoints.first |= Qt::TouchPointPrimary;
- maskAndPoints.second.append(touchPoint);
- }
-
- if (widgetsNeedingEvents.isEmpty())
- return;
-
- QHash<QWidget *, StatesAndTouchPoints>::ConstIterator it = widgetsNeedingEvents.constBegin();
- const QHash<QWidget *, StatesAndTouchPoints>::ConstIterator end = widgetsNeedingEvents.constEnd();
- for (; it != end; ++it) {
- QWidget *widget = it.key();
- if (!QApplicationPrivate::tryModalHelper(widget, 0))
- continue;
-
- QEvent::Type eventType;
- switch (it.value().first & Qt::TouchPointStateMask) {
- case Qt::TouchPointPressed:
- eventType = QEvent::TouchBegin;
- break;
- case Qt::TouchPointReleased:
- eventType = QEvent::TouchEnd;
- break;
- case Qt::TouchPointStationary:
- // don't send the event if nothing changed
- continue;
- default:
- eventType = QEvent::TouchUpdate;
- break;
- }
-
- QTouchEvent touchEvent(eventType,
- deviceType,
- QApplication::keyboardModifiers(),
- it.value().first,
- it.value().second);
- updateTouchPointsForWidget(widget, &touchEvent);
-
- switch (touchEvent.type()) {
- case QEvent::TouchBegin:
- {
- // if the TouchBegin handler recurses, we assume that means the event
- // has been implicitly accepted and continue to send touch events
- widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent);
- (void ) QApplication::sendSpontaneousEvent(widget, &touchEvent);
- break;
- }
- default:
- if (widget->testAttribute(Qt::WA_WState_AcceptedTouchBeginEvent)) {
- if (touchEvent.type() == QEvent::TouchEnd)
- widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, false);
- (void) QApplication::sendSpontaneousEvent(widget, &touchEvent);
- }
- break;
- }
- }
-}
-
-Q_GUI_EXPORT void qt_translateRawTouchEvent(QWidget *window,
- QTouchEvent::DeviceType deviceType,
- const QList<QTouchEvent::TouchPoint> &touchPoints)
-{
- QApplicationPrivate::translateRawTouchEvent(window, deviceType, touchPoints);
-}
-
-#ifndef QT_NO_GESTURES
-QGestureManager* QGestureManager::instance()
-{
- QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
- if (!qAppPriv)
- return 0;
- if (!qAppPriv->gestureManager)
- qAppPriv->gestureManager = new QGestureManager(qApp);
- return qAppPriv->gestureManager;
-}
-#endif // QT_NO_GESTURES
-
-// These pixmaps approximate the images in the Windows User Interface Guidelines.
-
-// XPM
-
-static const char * const move_xpm[] = {
-"11 20 3 1",
-". c None",
-#if defined(Q_WS_WIN)
-"a c #000000",
-"X c #FFFFFF", // Windows cursor is traditionally white
-#else
-"a c #FFFFFF",
-"X c #000000", // X11 cursor is traditionally black
-#endif
-"aa.........",
-"aXa........",
-"aXXa.......",
-"aXXXa......",
-"aXXXXa.....",
-"aXXXXXa....",
-"aXXXXXXa...",
-"aXXXXXXXa..",
-"aXXXXXXXXa.",
-"aXXXXXXXXXa",
-"aXXXXXXaaaa",
-"aXXXaXXa...",
-"aXXaaXXa...",
-"aXa..aXXa..",
-"aa...aXXa..",
-"a.....aXXa.",
-"......aXXa.",
-".......aXXa",
-".......aXXa",
-"........aa."};
-
-#ifdef Q_WS_WIN
-/* XPM */
-static const char * const ignore_xpm[] = {
-"24 30 3 1",
-". c None",
-"a c #000000",
-"X c #FFFFFF",
-"aa......................",
-"aXa.....................",
-"aXXa....................",
-"aXXXa...................",
-"aXXXXa..................",
-"aXXXXXa.................",
-"aXXXXXXa................",
-"aXXXXXXXa...............",
-"aXXXXXXXXa..............",
-"aXXXXXXXXXa.............",
-"aXXXXXXaaaa.............",
-"aXXXaXXa................",
-"aXXaaXXa................",
-"aXa..aXXa...............",
-"aa...aXXa...............",
-"a.....aXXa..............",
-"......aXXa.....XXXX.....",
-".......aXXa..XXaaaaXX...",
-".......aXXa.XaaaaaaaaX..",
-"........aa.XaaaXXXXaaaX.",
-"...........XaaaaX..XaaX.",
-"..........XaaXaaaX..XaaX",
-"..........XaaXXaaaX.XaaX",
-"..........XaaX.XaaaXXaaX",
-"..........XaaX..XaaaXaaX",
-"...........XaaX..XaaaaX.",
-"...........XaaaXXXXaaaX.",
-"............XaaaaaaaaX..",
-".............XXaaaaXX...",
-"...............XXXX....."};
-#endif
-
-/* XPM */
-static const char * const copy_xpm[] = {
-"24 30 3 1",
-". c None",
-"a c #000000",
-"X c #FFFFFF",
-#if defined(Q_WS_WIN) // Windows cursor is traditionally white
-"aa......................",
-"aXa.....................",
-"aXXa....................",
-"aXXXa...................",
-"aXXXXa..................",
-"aXXXXXa.................",
-"aXXXXXXa................",
-"aXXXXXXXa...............",
-"aXXXXXXXXa..............",
-"aXXXXXXXXXa.............",
-"aXXXXXXaaaa.............",
-"aXXXaXXa................",
-"aXXaaXXa................",
-"aXa..aXXa...............",
-"aa...aXXa...............",
-"a.....aXXa..............",
-"......aXXa..............",
-".......aXXa.............",
-".......aXXa.............",
-"........aa...aaaaaaaaaaa",
-#else
-"XX......................",
-"XaX.....................",
-"XaaX....................",
-"XaaaX...................",
-"XaaaaX..................",
-"XaaaaaX.................",
-"XaaaaaaX................",
-"XaaaaaaaX...............",
-"XaaaaaaaaX..............",
-"XaaaaaaaaaX.............",
-"XaaaaaaXXXX.............",
-"XaaaXaaX................",
-"XaaXXaaX................",
-"XaX..XaaX...............",
-"XX...XaaX...............",
-"X.....XaaX..............",
-"......XaaX..............",
-".......XaaX.............",
-".......XaaX.............",
-"........XX...aaaaaaaaaaa",
-#endif
-".............aXXXXXXXXXa",
-".............aXXXXXXXXXa",
-".............aXXXXaXXXXa",
-".............aXXXXaXXXXa",
-".............aXXaaaaaXXa",
-".............aXXXXaXXXXa",
-".............aXXXXaXXXXa",
-".............aXXXXXXXXXa",
-".............aXXXXXXXXXa",
-".............aaaaaaaaaaa"};
-
-/* XPM */
-static const char * const link_xpm[] = {
-"24 30 3 1",
-". c None",
-"a c #000000",
-"X c #FFFFFF",
-#if defined(Q_WS_WIN) // Windows cursor is traditionally white
-"aa......................",
-"aXa.....................",
-"aXXa....................",
-"aXXXa...................",
-"aXXXXa..................",
-"aXXXXXa.................",
-"aXXXXXXa................",
-"aXXXXXXXa...............",
-"aXXXXXXXXa..............",
-"aXXXXXXXXXa.............",
-"aXXXXXXaaaa.............",
-"aXXXaXXa................",
-"aXXaaXXa................",
-"aXa..aXXa...............",
-"aa...aXXa...............",
-"a.....aXXa..............",
-"......aXXa..............",
-".......aXXa.............",
-".......aXXa.............",
-"........aa...aaaaaaaaaaa",
-#else
-"XX......................",
-"XaX.....................",
-"XaaX....................",
-"XaaaX...................",
-"XaaaaX..................",
-"XaaaaaX.................",
-"XaaaaaaX................",
-"XaaaaaaaX...............",
-"XaaaaaaaaX..............",
-"XaaaaaaaaaX.............",
-"XaaaaaaXXXX.............",
-"XaaaXaaX................",
-"XaaXXaaX................",
-"XaX..XaaX...............",
-"XX...XaaX...............",
-"X.....XaaX..............",
-"......XaaX..............",
-".......XaaX.............",
-".......XaaX.............",
-"........XX...aaaaaaaaaaa",
-#endif
-".............aXXXXXXXXXa",
-".............aXXXaaaaXXa",
-".............aXXXXaaaXXa",
-".............aXXXaaaaXXa",
-".............aXXaaaXaXXa",
-".............aXXaaXXXXXa",
-".............aXXaXXXXXXa",
-".............aXXXaXXXXXa",
-".............aXXXXXXXXXa",
-".............aaaaaaaaaaa"};
-
-QPixmap QApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape)
-{
-#if defined(Q_WS_X11) || defined(Q_WS_WIN)
- if (!move_cursor) {
- move_cursor = new QPixmap((const char **)move_xpm);
- copy_cursor = new QPixmap((const char **)copy_xpm);
- link_cursor = new QPixmap((const char **)link_xpm);
-#ifdef Q_WS_WIN
- ignore_cursor = new QPixmap((const char **)ignore_xpm);
-#endif
- }
-
- switch (cshape) {
- case Qt::DragMoveCursor:
- return *move_cursor;
- case Qt::DragCopyCursor:
- return *copy_cursor;
- case Qt::DragLinkCursor:
- return *link_cursor;
-#ifdef Q_WS_WIN
- case Qt::ForbiddenCursor:
- return *ignore_cursor;
-#endif
- default:
- break;
- }
-#else
- Q_UNUSED(cshape);
-#endif
- return QPixmap();
-}
-
-QString QApplicationPrivate::qmljsDebugArgumentsString()
-{
- return qmljs_debug_arguments;
-}
-
-QT_END_NAMESPACE
-
-#include "moc_qapplication.cpp"
diff --git a/src/gui/kernel/qapplication.h b/src/gui/kernel/qapplication.h
deleted file mode 100644
index fb61d36307..0000000000
--- a/src/gui/kernel/qapplication.h
+++ /dev/null
@@ -1,430 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QAPPLICATION_H
-#define QAPPLICATION_H
-
-#include <QtCore/qcoreapplication.h>
-#include <QtGui/qwindowdefs.h>
-#include <QtCore/qpoint.h>
-#include <QtCore/qsize.h>
-#include <QtGui/qcursor.h>
-#ifdef QT_INCLUDE_COMPAT
-# include <QtGui/qdesktopwidget.h>
-#endif
-#ifdef QT3_SUPPORT
-# include <QtGui/qwidget.h>
-# include <QtGui/qpalette.h>
-#endif
-#ifdef Q_WS_QWS
-# include <QtGui/qrgb.h>
-# include <QtGui/qtransportauth_qws.h>
-#endif
-
-QT_BEGIN_HEADER
-
-#if defined(Q_OS_SYMBIAN)
-class CApaApplication;
-#endif
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QSessionManager;
-class QDesktopWidget;
-class QStyle;
-class QEventLoop;
-class QIcon;
-class QInputContext;
-template <typename T> class QList;
-class QLocale;
-#if defined(Q_WS_QWS)
-class QDecoration;
-#elif defined(Q_WS_QPA)
-class QPlatformNativeInterface;
-#endif
-#if defined(Q_OS_SYMBIAN)
-class QSymbianEvent;
-#endif
-
-class QApplication;
-class QApplicationPrivate;
-#if defined(qApp)
-#undef qApp
-#endif
-#define qApp (static_cast<QApplication *>(QCoreApplication::instance()))
-
-
-class Q_GUI_EXPORT QApplication : public QCoreApplication
-{
- Q_OBJECT
- Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection)
- Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon)
- Q_PROPERTY(int cursorFlashTime READ cursorFlashTime WRITE setCursorFlashTime)
- Q_PROPERTY(int doubleClickInterval READ doubleClickInterval WRITE setDoubleClickInterval)
- Q_PROPERTY(int keyboardInputInterval READ keyboardInputInterval WRITE setKeyboardInputInterval)
-#ifndef QT_NO_WHEELEVENT
- Q_PROPERTY(int wheelScrollLines READ wheelScrollLines WRITE setWheelScrollLines)
-#endif
- Q_PROPERTY(QSize globalStrut READ globalStrut WRITE setGlobalStrut)
- Q_PROPERTY(int startDragTime READ startDragTime WRITE setStartDragTime)
- Q_PROPERTY(int startDragDistance READ startDragDistance WRITE setStartDragDistance)
- Q_PROPERTY(bool quitOnLastWindowClosed READ quitOnLastWindowClosed WRITE setQuitOnLastWindowClosed)
-#ifndef QT_NO_STYLE_STYLESHEET
- Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
-#endif
-#ifdef Q_WS_WINCE
- Q_PROPERTY(int autoMaximizeThreshold READ autoMaximizeThreshold WRITE setAutoMaximizeThreshold)
-#endif
- Q_PROPERTY(bool autoSipEnabled READ autoSipEnabled WRITE setAutoSipEnabled)
-
-public:
- enum Type { Tty, GuiClient, GuiServer };
-
-#ifdef Q_OS_SYMBIAN
- typedef CApaApplication * (*QS60MainApplicationFactory)();
-#endif
-
-#ifndef qdoc
- QApplication(int &argc, char **argv, int = ApplicationFlags);
- QApplication(int &argc, char **argv, bool GUIenabled, int = ApplicationFlags);
- QApplication(int &argc, char **argv, Type, int = ApplicationFlags);
-#if defined(Q_WS_X11)
- QApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0, int = ApplicationFlags);
- QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0, int = ApplicationFlags);
-#endif
-#if defined(Q_OS_SYMBIAN)
- QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv, int = ApplicationFlags);
-#endif
-#endif
- virtual ~QApplication();
-
- static Type type();
-
- static QStyle *style();
- static void setStyle(QStyle*);
- static QStyle *setStyle(const QString&);
- enum ColorSpec { NormalColor=0, CustomColor=1, ManyColor=2 };
- static int colorSpec();
- static void setColorSpec(int);
- static void setGraphicsSystem(const QString &);
-
-#ifndef QT_NO_CURSOR
- static QCursor *overrideCursor();
- static void setOverrideCursor(const QCursor &);
- static void changeOverrideCursor(const QCursor &);
- static void restoreOverrideCursor();
-#endif
- static QPalette palette();
- static QPalette palette(const QWidget *);
- static QPalette palette(const char *className);
- static void setPalette(const QPalette &, const char* className = 0);
- static QFont font();
- static QFont font(const QWidget*);
- static QFont font(const char *className);
- static void setFont(const QFont &, const char* className = 0);
- static QFontMetrics fontMetrics();
-
- static void setWindowIcon(const QIcon &icon);
- static QIcon windowIcon();
-
-
-#ifdef QT3_SUPPORT
- static QT3_SUPPORT QWidget *mainWidget();
- static QT3_SUPPORT void setMainWidget(QWidget *);
-#endif
-
- static QWidgetList allWidgets();
- static QWidgetList topLevelWidgets();
-
- static QDesktopWidget *desktop();
-
- static QWidget *activePopupWidget();
- static QWidget *activeModalWidget();
-#ifndef QT_NO_CLIPBOARD
- static QClipboard *clipboard();
-#endif
- static QWidget *focusWidget();
-
- static QWidget *activeWindow();
- static void setActiveWindow(QWidget* act);
-
- static QWidget *widgetAt(const QPoint &p);
- static inline QWidget *widgetAt(int x, int y) { return widgetAt(QPoint(x, y)); }
- static QWidget *topLevelAt(const QPoint &p);
- static inline QWidget *topLevelAt(int x, int y) { return topLevelAt(QPoint(x, y)); }
-
- static void syncX();
- static void beep();
- static void alert(QWidget *widget, int duration = 0);
-
- static Qt::KeyboardModifiers keyboardModifiers();
- static Qt::MouseButtons mouseButtons();
-
- static void setDesktopSettingsAware(bool);
- static bool desktopSettingsAware();
-
- static void setCursorFlashTime(int);
- static int cursorFlashTime();
-
- static void setDoubleClickInterval(int);
- static int doubleClickInterval();
-
- static void setKeyboardInputInterval(int);
- static int keyboardInputInterval();
-
-#ifndef QT_NO_WHEELEVENT
- static void setWheelScrollLines(int);
- static int wheelScrollLines();
-#endif
- static void setGlobalStrut(const QSize &);
- static QSize globalStrut();
-
- static void setStartDragTime(int ms);
- static int startDragTime();
- static void setStartDragDistance(int l);
- static int startDragDistance();
-
- static void setLayoutDirection(Qt::LayoutDirection direction);
- static Qt::LayoutDirection layoutDirection();
-
- static inline bool isRightToLeft() { return layoutDirection() == Qt::RightToLeft; }
- static inline bool isLeftToRight() { return layoutDirection() == Qt::LeftToRight; }
-
- static bool isEffectEnabled(Qt::UIEffect);
- static void setEffectEnabled(Qt::UIEffect, bool enable = true);
-
-#if defined(Q_WS_MAC)
- virtual bool macEventFilter(EventHandlerCallRef, EventRef);
-#endif
-#if defined(Q_WS_X11)
- virtual bool x11EventFilter(XEvent *);
- virtual int x11ClientMessage(QWidget*, XEvent*, bool passive_only);
- int x11ProcessEvent(XEvent*);
-#endif
-#if defined(Q_OS_SYMBIAN)
- int symbianProcessEvent(const QSymbianEvent *event);
- virtual bool symbianEventFilter(const QSymbianEvent *event);
-#endif
-#if defined(Q_WS_QWS)
- virtual bool qwsEventFilter(QWSEvent *);
- int qwsProcessEvent(QWSEvent*);
- void qwsSetCustomColors(QRgb *colortable, int start, int numColors);
-#ifndef QT_NO_QWS_MANAGER
- static QDecoration &qwsDecoration();
- static void qwsSetDecoration(QDecoration *);
- static QDecoration *qwsSetDecoration(const QString &decoration);
-#endif
-#endif
-
-#if defined(Q_WS_QPA)
- static QPlatformNativeInterface *platformNativeInterface();
-#endif
-
-
-#if defined(Q_WS_WIN)
- void winFocus(QWidget *, bool);
- static void winMouseButtonUp();
-#endif
-#ifndef QT_NO_SESSIONMANAGER
- // session management
- bool isSessionRestored() const;
- QString sessionId() const;
- QString sessionKey() const;
- virtual void commitData(QSessionManager& sm);
- virtual void saveState(QSessionManager& sm);
-#endif
-
-#ifndef QT_NO_IM
- void setInputContext(QInputContext *);
- QInputContext *inputContext() const;
-#endif
-
- static QLocale keyboardInputLocale();
- static Qt::LayoutDirection keyboardInputDirection();
-
- static int exec();
- bool notify(QObject *, QEvent *);
-
-
- static void setQuitOnLastWindowClosed(bool quit);
- static bool quitOnLastWindowClosed();
-
-#ifdef QT_KEYPAD_NAVIGATION
- static Q_DECL_DEPRECATED void setKeypadNavigationEnabled(bool);
- static bool keypadNavigationEnabled();
- static void setNavigationMode(Qt::NavigationMode mode);
- static Qt::NavigationMode navigationMode();
-#endif
-
-Q_SIGNALS:
- void lastWindowClosed();
- void focusChanged(QWidget *old, QWidget *now);
- void fontDatabaseChanged();
-#ifndef QT_NO_SESSIONMANAGER
- void commitDataRequest(QSessionManager &sessionManager);
- void saveStateRequest(QSessionManager &sessionManager);
-#endif
-
-public:
- QString styleSheet() const;
-public Q_SLOTS:
-#ifndef QT_NO_STYLE_STYLESHEET
- void setStyleSheet(const QString& sheet);
-#endif
-#ifdef Q_WS_WINCE
- void setAutoMaximizeThreshold(const int threshold);
- int autoMaximizeThreshold() const;
-#endif
- void setAutoSipEnabled(const bool enabled);
- bool autoSipEnabled() const;
- static void closeAllWindows();
- static void aboutQt();
-
-protected:
-#if defined(Q_WS_QWS)
- void setArgs(int, char **);
-#endif
- bool event(QEvent *);
- bool compressEvent(QEvent *, QObject *receiver, QPostEventList *);
-
-#ifdef QT3_SUPPORT
-public:
- static inline QT3_SUPPORT void setReverseLayout(bool b) { setLayoutDirection(b?Qt::RightToLeft:Qt::LeftToRight); }
- static inline bool QT3_SUPPORT reverseLayout() { return layoutDirection() == Qt::RightToLeft; }
- static QT3_SUPPORT Qt::Alignment horizontalAlignment(Qt::Alignment align);
- typedef int ColorMode;
- enum { NormalColors = NormalColor, CustomColors = CustomColor };
- static inline QT3_SUPPORT ColorMode colorMode() { return static_cast<ColorMode>(colorSpec()); }
- static inline QT3_SUPPORT void setColorMode(ColorMode mode) { setColorSpec(int(mode)); }
-#if defined(Q_OS_WIN32) || defined(Q_OS_CYGWIN)
- static QT3_SUPPORT Qt::WindowsVersion winVersion() { return (Qt::WindowsVersion)QSysInfo::WindowsVersion; }
-#endif
-#if defined(Q_OS_MAC)
- static QT3_SUPPORT Qt::MacintoshVersion macVersion() { return (Qt::MacintoshVersion)QSysInfo::MacintoshVersion; }
-#endif
-# ifndef QT_NO_CURSOR
- inline static QT3_SUPPORT void setOverrideCursor(const QCursor &cursor, bool replace)
- { if (replace) changeOverrideCursor(cursor); else setOverrideCursor(cursor); }
-# endif
- inline static QT3_SUPPORT bool hasGlobalMouseTracking() {return true;}
- inline static QT3_SUPPORT void setGlobalMouseTracking(bool) {}
- inline static QT3_SUPPORT void flushX() { flush(); }
- static inline QT3_SUPPORT void setWinStyleHighlightColor(const QColor &c) {
- QPalette p(palette());
- p.setColor(QPalette::Highlight, c);
- setPalette(p);
- }
- static inline QT3_SUPPORT const QColor &winStyleHighlightColor()
- { return palette().color(QPalette::Active, QPalette::Highlight); }
- static inline QT3_SUPPORT void setPalette(const QPalette &pal, bool, const char* className = 0)
- { setPalette(pal, className); }
- static inline QT3_SUPPORT void setFont(const QFont &font, bool, const char* className = 0)
- { setFont(font, className); }
-
- static inline QT3_SUPPORT QWidget *widgetAt(int x, int y, bool child)
- { QWidget *w = widgetAt(x, y); return child ? w : (w ? w->window() : 0); }
- static inline QT3_SUPPORT QWidget *widgetAt(const QPoint &p, bool child)
- { QWidget *w = widgetAt(p); return child ? w : (w ? w->window() : 0); }
-#endif // QT3_SUPPORT
-
-#if defined(Q_INTERNAL_QAPP_SRC) || defined(qdoc)
- QApplication(int &argc, char **argv);
- QApplication(int &argc, char **argv, bool GUIenabled);
- QApplication(int &argc, char **argv, Type);
-#if defined(Q_WS_X11)
- QApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0);
- QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0);
-#endif
-#if defined(Q_OS_SYMBIAN) || defined(qdoc)
- QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv);
-#endif
-#endif
-
-private:
- Q_DISABLE_COPY(QApplication)
- Q_DECLARE_PRIVATE(QApplication)
-
- friend class QGraphicsWidget;
- friend class QGraphicsItem;
- friend class QGraphicsScene;
- friend class QGraphicsScenePrivate;
- friend class QWidget;
- friend class QWidgetPrivate;
- friend class QETWidget;
- friend class Q3AccelManager;
- friend class QTranslator;
- friend class QWidgetAnimator;
-#ifndef QT_NO_SHORTCUT
- friend class QShortcut;
- friend class QLineEdit;
- friend class QTextControl;
-#endif
- friend class QAction;
- friend class QFontDatabasePrivate;
-
-#if defined(Q_WS_QWS)
- friend class QInputContext;
- friend class QWSDirectPainterSurface;
- friend class QDirectPainter;
- friend class QDirectPainterPrivate;
-#endif
-#ifndef QT_NO_GESTURES
- friend class QGestureManager;
-#endif
-
-#if defined(Q_WS_MAC) || defined(Q_WS_X11)
- Q_PRIVATE_SLOT(d_func(), void _q_alertTimeOut())
-#endif
-#if defined(QT_RX71_MULTITOUCH)
- Q_PRIVATE_SLOT(d_func(), void _q_readRX71MultiTouchEvents())
-#endif
-#if defined(Q_OS_SYMBIAN)
- Q_PRIVATE_SLOT(d_func(), void _q_aboutToQuit())
-#endif
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QAPPLICATION_H
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h
deleted file mode 100644
index 954c6deb90..0000000000
--- a/src/gui/kernel/qapplication_p.h
+++ /dev/null
@@ -1,683 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QAPPLICATION_P_H
-#define QAPPLICATION_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of qapplication_*.cpp, qwidget*.cpp, qcolor_x11.cpp, qfiledialog.cpp
-// and many other. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "QtGui/qapplication.h"
-#include "QtGui/qevent.h"
-#include "QtGui/qfont.h"
-#include "QtGui/qcursor.h"
-#include "QtGui/qregion.h"
-#include "QtCore/qmutex.h"
-#include "QtCore/qtranslator.h"
-#include "QtCore/qbasictimer.h"
-#include "QtCore/qhash.h"
-#include "QtCore/qpointer.h"
-#include "private/qcoreapplication_p.h"
-#include "QtGui/private/qshortcutmap_p.h"
-#include <private/qthread_p.h>
-#include "QtCore/qpoint.h"
-#include <QTime>
-#ifdef Q_WS_QWS
-#include "QtGui/qscreen_qws.h"
-#include <private/qgraphicssystem_qws_p.h>
-#endif
-#ifdef Q_OS_SYMBIAN
-#include <w32std.h>
-#endif
-#ifdef Q_WS_QPA
-#include <QWindowSystemInterface>
-#include "qwindowsysteminterface_qpa_p.h"
-#include "QtGui/qplatformintegration_qpa.h"
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class QClipboard;
-class QGraphicsScene;
-class QGraphicsSystem;
-class QInputContext;
-class QObject;
-class QWidget;
-class QSocketNotifier;
-#ifndef QT_NO_GESTURES
-class QGestureManager;
-#endif
-
-extern bool qt_is_gui_used;
-#ifndef QT_NO_CLIPBOARD
-extern QClipboard *qt_clipboard;
-#endif
-
-#if defined (Q_OS_WIN32) || defined (Q_OS_CYGWIN) || defined(Q_OS_WINCE)
-extern QSysInfo::WinVersion qt_winver;
-enum { QT_TABLET_NPACKETQSIZE = 128 };
-# ifdef Q_OS_WINCE
- extern DWORD qt_cever;
-# endif
-#elif defined (Q_OS_MAC)
-extern QSysInfo::MacVersion qt_macver;
-#endif
-#if defined(Q_WS_QWS)
-class QWSManager;
-class QDirectPainter;
-struct QWSServerCleaner { ~QWSServerCleaner(); };
-#endif
-
-#ifndef QT_NO_TABLET
-struct QTabletDeviceData
-{
-#ifndef Q_WS_MAC
- int minPressure;
- int maxPressure;
- int minTanPressure;
- int maxTanPressure;
- int minX, maxX, minY, maxY, minZ, maxZ;
- inline QPointF scaleCoord(int coordX, int coordY, int outOriginX, int outExtentX,
- int outOriginY, int outExtentY) const;
-#endif
-
-#if defined(Q_WS_X11) || (defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA))
- QPointer<QWidget> widgetToGetPress;
-#endif
-
-#ifdef Q_WS_X11
- int deviceType;
- enum {
- TOTAL_XINPUT_EVENTS = 64
- };
- void *device;
- int eventCount;
- long unsigned int eventList[TOTAL_XINPUT_EVENTS]; // XEventClass is in fact a long unsigned int
-
- int xinput_motion;
- int xinput_key_press;
- int xinput_key_release;
- int xinput_button_press;
- int xinput_button_release;
- int xinput_proximity_in;
- int xinput_proximity_out;
-#elif defined(Q_WS_WIN)
- qint64 llId;
- int currentDevice;
- int currentPointerType;
-#elif defined(Q_WS_MAC)
- quint64 tabletUniqueID;
- int tabletDeviceType;
- int tabletPointerType;
- int capabilityMask;
-#endif
-};
-
-static inline int sign(int x)
-{
- return x >= 0 ? 1 : -1;
-}
-
-#ifndef Q_WS_MAC
-inline QPointF QTabletDeviceData::scaleCoord(int coordX, int coordY,
- int outOriginX, int outExtentX,
- int outOriginY, int outExtentY) const
-{
- QPointF ret;
-
- if (sign(outExtentX) == sign(maxX))
- ret.setX(((coordX - minX) * qAbs(outExtentX) / qAbs(qreal(maxX - minX))) + outOriginX);
- else
- ret.setX(((qAbs(maxX) - (coordX - minX)) * qAbs(outExtentX) / qAbs(qreal(maxX - minX)))
- + outOriginX);
-
- if (sign(outExtentY) == sign(maxY))
- ret.setY(((coordY - minY) * qAbs(outExtentY) / qAbs(qreal(maxY - minY))) + outOriginY);
- else
- ret.setY(((qAbs(maxY) - (coordY - minY)) * qAbs(outExtentY) / qAbs(qreal(maxY - minY)))
- + outOriginY);
-
- return ret;
-}
-#endif
-
-typedef QList<QTabletDeviceData> QTabletDeviceDataList;
-QTabletDeviceDataList *qt_tablet_devices();
-# if defined(Q_WS_MAC)
-typedef QHash<int, QTabletDeviceData> QMacTabletHash;
-QMacTabletHash *qt_mac_tablet_hash();
-# endif
-#endif
-
-#ifdef QT3_SUPPORT
-extern "C" {
- typedef bool (*Ptrqt_tryAccelEvent)(QWidget *w, QKeyEvent *e);
- typedef bool (*Ptrqt_tryComposeUnicode)(QWidget *w, QKeyEvent *e);
- typedef bool (*Ptrqt_dispatchAccelEvent)(QWidget *w, QKeyEvent *e);
-}
-#endif
-
-#if defined(Q_WS_WIN)
-typedef BOOL (WINAPI *PtrRegisterTouchWindow)(HWND, ULONG);
-typedef BOOL (WINAPI *PtrGetTouchInputInfo)(HANDLE, UINT, PVOID, int);
-typedef BOOL (WINAPI *PtrCloseTouchInputHandle)(HANDLE);
-
-#ifndef QT_NO_GESTURES
-typedef BOOL (WINAPI *PtrGetGestureInfo)(HANDLE, PVOID);
-typedef BOOL (WINAPI *PtrGetGestureExtraArgs)(HANDLE, UINT, PBYTE);
-typedef BOOL (WINAPI *PtrCloseGestureInfoHandle)(HANDLE);
-typedef BOOL (WINAPI *PtrSetGestureConfig)(HWND, DWORD, UINT, PVOID, UINT);
-typedef BOOL (WINAPI *PtrGetGestureConfig)(HWND, DWORD, DWORD, PUINT, PVOID, UINT);
-
-typedef BOOL (WINAPI *PtrBeginPanningFeedback)(HWND);
-typedef BOOL (WINAPI *PtrUpdatePanningFeedback)(HWND, LONG, LONG, BOOL);
-typedef BOOL (WINAPI *PtrEndPanningFeedback)(HWND, BOOL);
-
-#ifndef WM_GESTURE
-# define WM_GESTURE 0x0119
-
-# define GID_BEGIN 1
-# define GID_END 2
-# define GID_ZOOM 3
-# define GID_PAN 4
-# define GID_ROTATE 5
-# define GID_TWOFINGERTAP 6
-# define GID_ROLLOVER 7
-
-typedef struct tagGESTUREINFO
-{
- UINT cbSize;
- DWORD dwFlags;
- DWORD dwID;
- HWND hwndTarget;
- POINTS ptsLocation;
- DWORD dwInstanceID;
- DWORD dwSequenceID;
- ULONGLONG ullArguments;
- UINT cbExtraArgs;
-} GESTUREINFO;
-
-# define GC_PAN 0x00000001
-# define GC_PAN_WITH_SINGLE_FINGER_VERTICALLY 0x00000002
-# define GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY 0x00000004
-
-# define GC_ZOOM 0x00000001
-# define GC_ROTATE 0x00000001
-
-typedef struct tagGESTURECONFIG
-{
- DWORD dwID;
- DWORD dwWant;
- DWORD dwBlock;
-} GESTURECONFIG;
-
-# define GID_ROTATE_ANGLE_FROM_ARGUMENT(arg) ((((double)(arg) / 65535.0) * 4.0 * 3.14159265) - 2.0*3.14159265)
-
-#endif // WM_GESTURE
-
-#if defined(Q_WS_WINCE_WM) && defined(QT_WINCE_GESTURES)
-#undef GID_ZOOM
-#define GID_ZOOM 0xf000
-#undef GID_ROTATE
-#define GID_ROTATE 0xf001
-#undef GID_TWOFINGERTAP
-#define GID_TWOFINGERTAP 0xf002
-#undef GID_ROLLOVER
-#define GID_ROLLOVER 0xf003
-#endif
-
-#endif // QT_NO_GESTURES
-
-#endif // Q_WS_WIN
-
-class QScopedLoopLevelCounter
-{
- QThreadData *threadData;
-public:
- QScopedLoopLevelCounter(QThreadData *threadData)
- : threadData(threadData)
- { ++threadData->loopLevel; }
- ~QScopedLoopLevelCounter()
- { --threadData->loopLevel; }
-};
-
-typedef QHash<QByteArray, QFont> FontHash;
-FontHash *qt_app_fonts_hash();
-
-typedef QHash<QByteArray, QPalette> PaletteHash;
-PaletteHash *qt_app_palettes_hash();
-
-class Q_GUI_EXPORT QApplicationPrivate : public QCoreApplicationPrivate
-{
- Q_DECLARE_PUBLIC(QApplication)
-public:
- QApplicationPrivate(int &argc, char **argv, QApplication::Type type, int flags);
- ~QApplicationPrivate();
-
-#if defined(Q_WS_X11)
-#ifndef QT_NO_SETTINGS
- static bool x11_apply_settings();
-#endif
- static void reset_instance_pointer();
-#elif defined(Q_WS_QWS)
- static bool qws_apply_settings();
- static QWidget *findWidget(const QObjectList&, const QPoint &, bool rec);
-#endif
- static bool quitOnLastWindowClosed;
- static void emitLastWindowClosed();
-#ifdef Q_WS_WINCE
- static int autoMaximizeThreshold;
-#endif
- static bool autoSipEnabled;
- static QString desktopStyleKey();
-
- static QGraphicsSystem *graphicsSystem()
-#if defined(Q_WS_QWS)
- { return QScreen::instance()->graphicsSystem(); }
-#else
- { return graphics_system; }
-#endif
-
-#if defined(Q_WS_QPA)
- static QPlatformIntegration *platformIntegration()
- { return platform_integration; }
-
- static QAbstractEventDispatcher *qt_qpa_core_dispatcher()
- { return QCoreApplication::instance()->d_func()->threadData->eventDispatcher; }
-#endif
-
- void createEventDispatcher();
- QString appName() const;
- static void dispatchEnterLeave(QWidget *enter, QWidget *leave);
-
- //modality
- static void enterModal(QWidget*);
- static void leaveModal(QWidget*);
- static void enterModal_sys(QWidget*);
- static void leaveModal_sys(QWidget*);
- static bool isBlockedByModal(QWidget *widget);
- static bool modalState();
- static bool tryModalHelper(QWidget *widget, QWidget **rettop = 0);
-#ifdef Q_WS_MAC
- static QWidget *tryModalHelper_sys(QWidget *top);
- bool canQuit();
-#endif
-
- bool notify_helper(QObject *receiver, QEvent * e);
-
- void construct(
-#ifdef Q_WS_X11
- Display *dpy = 0, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0
-#endif
- );
- void initialize();
- void process_cmdline();
-
-#if defined(Q_WS_X11)
- static void x11_initialize_style();
-#endif
-
- enum KeyPlatform {
- KB_Win = 1,
- KB_Mac = 2,
- KB_X11 = 4,
- KB_KDE = 8,
- KB_Gnome = 16,
- KB_CDE = 32,
- KB_S60 = 64,
- KB_All = 0xffff
- };
-
- static uint currentPlatform();
- bool inPopupMode() const;
- void closePopup(QWidget *popup);
- void openPopup(QWidget *popup);
- static void setFocusWidget(QWidget *focus, Qt::FocusReason reason);
- static QWidget *focusNextPrevChild_helper(QWidget *toplevel, bool next);
-
-#ifndef QT_NO_SESSIONMANAGER
- QSessionManager *session_manager;
- QString session_id;
- QString session_key;
- bool is_session_restored;
-#endif
-
-#ifndef QT_NO_CURSOR
- QList<QCursor> cursor_list;
-#endif
-#ifndef QT_NO_GRAPHICSVIEW
- // Maintain a list of all scenes to ensure font and palette propagation to
- // all scenes.
- QList<QGraphicsScene *> scene_list;
-#endif
-
- QBasicTimer toolTipWakeUp, toolTipFallAsleep;
- QPoint toolTipPos, toolTipGlobalPos, hoverGlobalPos;
- QPointer<QWidget> toolTipWidget;
-#ifndef QT_NO_SHORTCUT
- QShortcutMap shortcutMap;
-#endif
-
-#ifdef QT3_SUPPORT
- bool qt_compat_used;
- bool qt_compat_resolved;
- Ptrqt_tryAccelEvent qt_tryAccelEvent;
- Ptrqt_tryComposeUnicode qt_tryComposeUnicode;
- Ptrqt_dispatchAccelEvent qt_dispatchAccelEvent;
-
- bool use_compat() {
- return qt_tryAccelEvent
- && qt_tryComposeUnicode
- && qt_dispatchAccelEvent;
- }
-#endif
- static QInputContext *inputContext;
-
- static Qt::MouseButtons mouse_buttons;
- static Qt::KeyboardModifiers modifier_buttons;
-
- static QSize app_strut;
- static QWidgetList *popupWidgets;
- static QStyle *app_style;
- static int app_cspec;
- static QPalette *app_pal;
- static QPalette *sys_pal;
- static QPalette *set_pal;
- static QGraphicsSystem *graphics_system;
- static QString graphics_system_name;
- static bool runtime_graphics_system;
-#ifdef Q_WS_QPA
- static QPlatformIntegration *platform_integration;
-#endif
-
-private:
- static QFont *app_font; // private for a reason! Always use QApplication::font() instead!
-public:
- static QFont *sys_font;
- static QFont *set_font;
- static QWidget *main_widget;
- static QWidget *focus_widget;
- static QWidget *hidden_focus_widget;
- static QWidget *active_window;
- static QIcon *app_icon;
- static bool obey_desktop_settings;
- static int cursor_flash_time;
- static int mouse_double_click_time;
- static int keyboard_input_time;
-#ifndef QT_NO_WHEELEVENT
- static int wheel_scroll_lines;
-#endif
-
- static bool animate_ui;
- static bool animate_menu;
- static bool animate_tooltip;
- static bool animate_combo;
- static bool fade_menu;
- static bool fade_tooltip;
- static bool animate_toolbox;
- static bool widgetCount; // Coupled with -widgetcount switch
- static bool load_testability; // Coupled with -testability switch
- static QString qmljs_debug_arguments; // a string containing arguments for js/qml debugging.
- static QString qmljsDebugArgumentsString(); // access string from other libraries
-
-#ifdef Q_WS_MAC
- static bool native_modal_dialog_active;
-#endif
-
- static void setSystemPalette(const QPalette &pal);
- static void setPalette_helper(const QPalette &palette, const char* className, bool clearWidgetPaletteHash);
- static void initializeWidgetPaletteHash();
- static void setSystemFont(const QFont &font);
-
-#if defined(Q_WS_X11)
- static void applyX11SpecificCommandLineArguments(QWidget *main_widget);
-#elif defined(Q_WS_QWS)
- static void applyQWSSpecificCommandLineArguments(QWidget *main_widget);
-#endif
-
-#ifdef Q_WS_MAC
- static OSStatus globalEventProcessor(EventHandlerCallRef, EventRef, void *);
- static OSStatus globalAppleEventProcessor(const AppleEvent *, AppleEvent *, long);
- static OSStatus tabletProximityCallback(EventHandlerCallRef, EventRef, void *);
-#ifdef QT_MAC_USE_COCOA
- static void qt_initAfterNSAppStarted();
- static void setupAppleEvents();
-#endif
- static bool qt_mac_apply_settings();
-#endif
-
-#ifdef Q_WS_QPA
- static void processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e);
- static void processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e);
- static void processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e);
- static void processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e);
-
- static void processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e);
-
- static void processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e);
-
- static void processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e);
- static void processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e);
-
- static void processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e);
-
- static void processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e);
-
-// static void reportScreenCount(int count);
- static void reportScreenCount(QWindowSystemInterfacePrivate::ScreenCountEvent *e);
-// static void reportGeometryChange(int screenIndex);
- static void reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e);
-// static void reportAvailableGeometryChange(int screenIndex);
- static void reportAvailableGeometryChange(QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e);
-
-#endif
-
-#ifdef Q_WS_QWS
- QPointer<QWSManager> last_manager;
- QWSServerCleaner qwsServerCleaner;
-# ifndef QT_NO_DIRECTPAINTER
- QMap<WId, QDirectPainter *> *directPainters;
-# endif
- QRect maxWindowRect(const QScreen *screen) const { return maxWindowRects[screen]; }
- void setMaxWindowRect(const QScreen *screen, int screenNo, const QRect &rect);
- void setScreenTransformation(QScreen *screen, int screenNo, int transformation);
-#endif
-
- static QApplicationPrivate *instance() { return self; }
-
- static QString styleOverride;
-
-#ifdef QT_KEYPAD_NAVIGATION
- static QWidget *oldEditFocus;
- static Qt::NavigationMode navigationMode;
-#endif
-
-#if defined(Q_WS_MAC) || defined(Q_WS_X11)
- void _q_alertTimeOut();
- QHash<QWidget *, QTimer *> alertTimerHash;
-#endif
-#ifndef QT_NO_STYLE_STYLESHEET
- static QString styleSheet;
-#endif
- static QPointer<QWidget> leaveAfterRelease;
- static QWidget *pickMouseReceiver(QWidget *candidate, const QPoint &globalPos, QPoint &pos,
- QEvent::Type type, Qt::MouseButtons buttons,
- QWidget *buttonDown, QWidget *alienWidget);
- static bool sendMouseEvent(QWidget *receiver, QMouseEvent *event, QWidget *alienWidget,
- QWidget *native, QWidget **buttonDown, QPointer<QWidget> &lastMouseReceiver,
- bool spontaneous = true);
-#ifdef Q_OS_SYMBIAN
- static void setNavigationMode(Qt::NavigationMode mode);
- static TUint resolveS60ScanCode(TInt scanCode, TUint keysym);
- QSet<WId> nativeWindows;
-
- int symbianProcessWsEvent(const QSymbianEvent *symbianEvent);
- int symbianHandleCommand(const QSymbianEvent *symbianEvent);
- int symbianResourceChange(const QSymbianEvent *symbianEvent);
-
- void _q_aboutToQuit();
-#endif
-#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_QPA)
- void sendSyntheticEnterLeave(QWidget *widget);
-#endif
-
-#ifndef QT_NO_GESTURES
- QGestureManager *gestureManager;
- QWidget *gestureWidget;
-#endif
-#if defined(Q_WS_X11) || defined(Q_WS_WIN)
- QPixmap *move_cursor;
- QPixmap *copy_cursor;
- QPixmap *link_cursor;
-#endif
-#if defined(Q_WS_WIN)
- QPixmap *ignore_cursor;
-#endif
- QPixmap getPixmapCursor(Qt::CursorShape cshape);
-
- QMap<int, QWeakPointer<QWidget> > widgetForTouchPointId;
- QMap<int, QTouchEvent::TouchPoint> appCurrentTouchPoints;
- static void updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent);
- void initializeMultitouch();
- void initializeMultitouch_sys();
- void cleanupMultitouch();
- void cleanupMultitouch_sys();
- int findClosestTouchPointId(const QPointF &screenPos);
- void appendTouchPoint(const QTouchEvent::TouchPoint &touchPoint);
- void removeTouchPoint(int touchPointId);
- static void translateRawTouchEvent(QWidget *widget,
- QTouchEvent::DeviceType deviceType,
- const QList<QTouchEvent::TouchPoint> &touchPoints);
-
-#if defined(Q_WS_WIN)
- static bool HasTouchSupport;
- static PtrRegisterTouchWindow RegisterTouchWindow;
- static PtrGetTouchInputInfo GetTouchInputInfo;
- static PtrCloseTouchInputHandle CloseTouchInputHandle;
-
- QHash<DWORD, int> touchInputIDToTouchPointID;
- bool translateTouchEvent(const MSG &msg);
-
-#ifndef QT_NO_GESTURES
- PtrGetGestureInfo GetGestureInfo;
- PtrGetGestureExtraArgs GetGestureExtraArgs;
- PtrCloseGestureInfoHandle CloseGestureInfoHandle;
- PtrSetGestureConfig SetGestureConfig;
- PtrGetGestureConfig GetGestureConfig;
- PtrBeginPanningFeedback BeginPanningFeedback;
- PtrUpdatePanningFeedback UpdatePanningFeedback;
- PtrEndPanningFeedback EndPanningFeedback;
-#endif // QT_NO_GESTURES
-#endif
-
-#ifdef QT_RX71_MULTITOUCH
- bool hasRX71MultiTouch;
-
- struct RX71TouchPointState {
- QSocketNotifier *socketNotifier;
- QTouchEvent::TouchPoint touchPoint;
-
- int minX, maxX, scaleX;
- int minY, maxY, scaleY;
- int minZ, maxZ;
- };
- QList<RX71TouchPointState> allRX71TouchPoints;
-
- bool readRX71MultiTouchEvents(int deviceNumber);
- void fakeMouseEventFromRX71TouchEvent();
- void _q_readRX71MultiTouchEvents();
-#endif
-
-#if defined(Q_OS_SYMBIAN)
- int pressureSupported;
- int maxTouchPressure;
- QList<QTouchEvent::TouchPoint> appAllTouchPoints;
-
- bool useTranslucentEGLSurfaces;
-#endif
-
-private:
-#ifdef Q_WS_QWS
- QMap<const QScreen*, QRect> maxWindowRects;
-#endif
-
-#ifdef Q_OS_SYMBIAN
- QHash<TInt, TUint> scanCodeCache;
-#endif
-
- static QApplicationPrivate *self;
-
- static void giveFocusAccordingToFocusPolicy(QWidget *w,
- Qt::FocusPolicy focusPolicy,
- Qt::FocusReason focusReason);
- static bool shouldSetFocus(QWidget *w, Qt::FocusPolicy policy);
-
-
- static bool isAlien(QWidget *);
-};
-
-Q_GUI_EXPORT void qt_translateRawTouchEvent(QWidget *window,
- QTouchEvent::DeviceType deviceType,
- const QList<QTouchEvent::TouchPoint> &touchPoints);
-
-#if defined(Q_WS_WIN)
- extern void qt_win_set_cursor(QWidget *, bool);
-#elif defined(Q_WS_X11)
- extern void qt_x11_enforce_cursor(QWidget *, bool);
- extern void qt_x11_enforce_cursor(QWidget *);
-#elif defined(Q_OS_SYMBIAN)
- extern void qt_symbian_set_cursor(QWidget *, bool);
-#elif defined (Q_WS_QPA)
- extern void qt_qpa_set_cursor(QWidget *, bool);
-#endif
-
-QT_END_NAMESPACE
-
-#endif // QAPPLICATION_P_H
diff --git a/src/gui/kernel/qapplication_qpa.cpp b/src/gui/kernel/qapplication_qpa.cpp
deleted file mode 100644
index b754cf7de8..0000000000
--- a/src/gui/kernel/qapplication_qpa.cpp
+++ /dev/null
@@ -1,965 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qapplication_p.h"
-#include "qcolormap.h"
-#include "qpixmapcache.h"
-#if !defined(QT_NO_GLIB)
-#include "qeventdispatcher_glib_qpa_p.h"
-#endif
-#include "qeventdispatcher_qpa_p.h"
-#ifndef QT_NO_CURSOR
-#include "private/qcursor_p.h"
-#endif
-
-#include "private/qwidget_p.h"
-#include "private/qevent_p.h"
-
-#include "qgenericpluginfactory_qpa.h"
-#include "qplatformintegrationfactory_qpa_p.h"
-#include <qdesktopwidget.h>
-
-#include <qinputcontext.h>
-#include <QPlatformCursor>
-#include <qdebug.h>
-#include <QWindowSystemInterface>
-#include "qwindowsysteminterface_qpa_p.h"
-#include <QPlatformIntegration>
-
-#include "qdesktopwidget_qpa_p.h"
-
-QT_BEGIN_NAMESPACE
-
-static QString appName;
-static QString appFont;
-
-QWidget *qt_button_down = 0; // widget got last button-down
-
-static bool app_do_modal = false;
-extern QWidgetList *qt_modal_stack; // stack of modal widgets
-
-int qt_last_x = 0;
-int qt_last_y = 0;
-QPointer<QWidget> qt_last_mouse_receiver = 0;
-
-static Qt::MouseButtons buttons = Qt::NoButton;
-static ulong mousePressTime;
-static Qt::MouseButton mousePressButton = Qt::NoButton;
-static int mousePressX;
-static int mousePressY;
-static int mouse_double_click_distance = 5;
-
-void QApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e)
-{
- switch(e->type) {
- case QWindowSystemInterfacePrivate::Mouse:
- QApplicationPrivate::processMouseEvent(static_cast<QWindowSystemInterfacePrivate::MouseEvent *>(e));
- break;
- case QWindowSystemInterfacePrivate::Wheel:
- QApplicationPrivate::processWheelEvent(static_cast<QWindowSystemInterfacePrivate::WheelEvent *>(e));
- break;
- case QWindowSystemInterfacePrivate::Key:
- QApplicationPrivate::processKeyEvent(static_cast<QWindowSystemInterfacePrivate::KeyEvent *>(e));
- break;
- case QWindowSystemInterfacePrivate::Touch:
- QApplicationPrivate::processTouchEvent(static_cast<QWindowSystemInterfacePrivate::TouchEvent *>(e));
- break;
- case QWindowSystemInterfacePrivate::GeometryChange:
- QApplicationPrivate::processGeometryChangeEvent(static_cast<QWindowSystemInterfacePrivate::GeometryChangeEvent*>(e));
- break;
- case QWindowSystemInterfacePrivate::Enter:
- QApplicationPrivate::processEnterEvent(static_cast<QWindowSystemInterfacePrivate::EnterEvent *>(e));
- break;
- case QWindowSystemInterfacePrivate::Leave:
- QApplicationPrivate::processLeaveEvent(static_cast<QWindowSystemInterfacePrivate::LeaveEvent *>(e));
- break;
- case QWindowSystemInterfacePrivate::ActivatedWindow:
- QApplicationPrivate::processActivatedEvent(static_cast<QWindowSystemInterfacePrivate::ActivatedWindowEvent *>(e));
- break;
- case QWindowSystemInterfacePrivate::Close:
- QApplicationPrivate::processCloseEvent(
- static_cast<QWindowSystemInterfacePrivate::CloseEvent *>(e));
- break;
- case QWindowSystemInterfacePrivate::ScreenCountChange:
- QApplicationPrivate::reportScreenCount(
- static_cast<QWindowSystemInterfacePrivate::ScreenCountEvent *>(e));
- break;
- case QWindowSystemInterfacePrivate::ScreenGeometry:
- QApplicationPrivate::reportGeometryChange(
- static_cast<QWindowSystemInterfacePrivate::ScreenGeometryEvent *>(e));
- break;
- case QWindowSystemInterfacePrivate::ScreenAvailableGeometry:
- QApplicationPrivate::reportAvailableGeometryChange(
- static_cast<QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *>(e));
- break;
- default:
- qWarning() << "Unknown user input event type:" << e->type;
- break;
- }
-}
-
-QString QApplicationPrivate::appName() const
-{
- return QT_PREPEND_NAMESPACE(appName);
-}
-
-void QApplicationPrivate::createEventDispatcher()
-{
- Q_Q(QApplication);
-#if !defined(QT_NO_GLIB)
- if (qgetenv("QT_NO_GLIB").isEmpty() && QEventDispatcherGlib::versionSupported())
- eventDispatcher = new QPAEventDispatcherGlib(q);
- else
-#endif
- eventDispatcher = new QEventDispatcherQPA(q);
-}
-
-static bool qt_try_modal(QWidget *widget, QEvent::Type type)
-{
- QWidget * top = 0;
-
- if (QApplicationPrivate::tryModalHelper(widget, &top))
- return true;
-
- bool block_event = false;
- bool paint_event = false;
-
- switch (type) {
-#if 0
- case QEvent::Focus:
- if (!static_cast<QWSFocusEvent*>(event)->simpleData.get_focus)
- break;
- // drop through
-#endif
- case QEvent::MouseButtonPress: // disallow mouse/key events
- case QEvent::MouseButtonRelease:
- case QEvent::MouseMove:
- case QEvent::KeyPress:
- case QEvent::KeyRelease:
- block_event = true;
- break;
- default:
- break;
- }
-
- if ((block_event || paint_event) && top->parentWidget() == 0)
- top->raise();
-
- return !block_event;
-}
-
-
-
-void QApplicationPrivate::enterModal_sys(QWidget *widget)
-{
- if (!qt_modal_stack)
- qt_modal_stack = new QWidgetList;
- qt_modal_stack->insert(0, widget);
- app_do_modal = true;
-}
-
-void QApplicationPrivate::leaveModal_sys(QWidget *widget )
-{
- if (qt_modal_stack && qt_modal_stack->removeAll(widget)) {
- if (qt_modal_stack->isEmpty()) {
- delete qt_modal_stack;
- qt_modal_stack = 0;
- }
- }
- app_do_modal = qt_modal_stack != 0;
-}
-
-bool QApplicationPrivate::modalState()
-{
- return app_do_modal;
-}
-
-void QApplicationPrivate::closePopup(QWidget *popup)
-{
- Q_Q(QApplication);
- if (!popupWidgets)
- return;
- popupWidgets->removeAll(popup);
-
-//###
-// if (popup == qt_popup_down) {
-// qt_button_down = 0;
-// qt_popup_down = 0;
-// }
-
- if (QApplicationPrivate::popupWidgets->count() == 0) { // this was the last popup
- delete QApplicationPrivate::popupWidgets;
- QApplicationPrivate::popupWidgets = 0;
-
- //### replay mouse event?
-
- //### transfer/release mouse grab
-
- //### transfer/release keyboard grab
-
- //give back focus
-
- if (active_window) {
- if (QWidget *fw = active_window->focusWidget()) {
- if (fw != QApplication::focusWidget()) {
- fw->setFocus(Qt::PopupFocusReason);
- } else {
- QFocusEvent e(QEvent::FocusIn, Qt::PopupFocusReason);
- q->sendEvent(fw, &e);
- }
- }
- }
-
- } else {
- // A popup was closed, so the previous popup gets the focus.
-
- QWidget* aw = QApplicationPrivate::popupWidgets->last();
- if (QWidget *fw = aw->focusWidget())
- fw->setFocus(Qt::PopupFocusReason);
-
- //### regrab the keyboard and mouse in case 'popup' lost the grab
-
-
- }
-
-}
-
-static int openPopupCount = 0;
-void QApplicationPrivate::openPopup(QWidget *popup)
-{
- openPopupCount++;
- if (!popupWidgets) { // create list
- popupWidgets = new QWidgetList;
-
- /* only grab if you are the first/parent popup */
- //#### ->grabMouse(popup,true);
- //#### ->grabKeyboard(popup,true);
- //### popupGrabOk = true;
- }
- popupWidgets->append(popup); // add to end of list
-
- // popups are not focus-handled by the window system (the first
- // popup grabbed the keyboard), so we have to do that manually: A
- // new popup gets the focus
- if (popup->focusWidget()) {
- popup->focusWidget()->setFocus(Qt::PopupFocusReason);
- } else if (popupWidgets->count() == 1) { // this was the first popup
- if (QWidget *fw = QApplication::focusWidget()) {
- QFocusEvent e(QEvent::FocusOut, Qt::PopupFocusReason);
- QApplication::sendEvent(fw, &e);
- }
- }
-}
-
-void QApplicationPrivate::initializeMultitouch_sys()
-{
-}
-
-void QApplicationPrivate::cleanupMultitouch_sys()
-{
-}
-
-void QApplicationPrivate::initializeWidgetPaletteHash()
-{
-}
-
-void QApplication::setCursorFlashTime(int msecs)
-{
- QApplicationPrivate::cursor_flash_time = msecs;
-}
-
-int QApplication::cursorFlashTime()
-{
- return QApplicationPrivate::cursor_flash_time;
-}
-
-void QApplication::setDoubleClickInterval(int ms)
-{
- QApplicationPrivate::mouse_double_click_time = ms;
-}
-
-int QApplication::doubleClickInterval()
-{
- return QApplicationPrivate::mouse_double_click_time;
-}
-
-void QApplication::setKeyboardInputInterval(int ms)
-{
- QApplicationPrivate::keyboard_input_time = ms;
-}
-
-int QApplication::keyboardInputInterval()
-{
- return QApplicationPrivate::keyboard_input_time;
-}
-
-#ifndef QT_NO_WHEELEVENT
-void QApplication::setWheelScrollLines(int lines)
-{
- QApplicationPrivate::wheel_scroll_lines = lines;
-}
-
-int QApplication::wheelScrollLines()
-{
- return QApplicationPrivate::wheel_scroll_lines;
-}
-#endif
-
-void QApplication::setEffectEnabled(Qt::UIEffect effect, bool enable)
-{
- switch (effect) {
- case Qt::UI_AnimateMenu:
- QApplicationPrivate::animate_menu = enable;
- break;
- case Qt::UI_FadeMenu:
- if (enable)
- QApplicationPrivate::animate_menu = true;
- QApplicationPrivate::fade_menu = enable;
- break;
- case Qt::UI_AnimateCombo:
- QApplicationPrivate::animate_combo = enable;
- break;
- case Qt::UI_AnimateTooltip:
- QApplicationPrivate::animate_tooltip = enable;
- break;
- case Qt::UI_FadeTooltip:
- if (enable)
- QApplicationPrivate::animate_tooltip = true;
- QApplicationPrivate::fade_tooltip = enable;
- break;
- case Qt::UI_AnimateToolBox:
- QApplicationPrivate::animate_toolbox = enable;
- break;
- default:
- QApplicationPrivate::animate_ui = enable;
- break;
- }
-}
-
-bool QApplication::isEffectEnabled(Qt::UIEffect effect)
-{
- if (QColormap::instance().depth() < 16 || !QApplicationPrivate::animate_ui)
- return false;
-
- switch(effect) {
- case Qt::UI_AnimateMenu:
- return QApplicationPrivate::animate_menu;
- case Qt::UI_FadeMenu:
- return QApplicationPrivate::fade_menu;
- case Qt::UI_AnimateCombo:
- return QApplicationPrivate::animate_combo;
- case Qt::UI_AnimateTooltip:
- return QApplicationPrivate::animate_tooltip;
- case Qt::UI_FadeTooltip:
- return QApplicationPrivate::fade_tooltip;
- case Qt::UI_AnimateToolBox:
- return QApplicationPrivate::animate_toolbox;
- default:
- return QApplicationPrivate::animate_ui;
- }
-}
-
-#ifndef QT_NO_CURSOR
-void QApplication::setOverrideCursor(const QCursor &cursor)
-{
- qApp->d_func()->cursor_list.prepend(cursor);
- qt_qpa_set_cursor(0, false);
-}
-
-void QApplication::restoreOverrideCursor()
-{
- if (qApp->d_func()->cursor_list.isEmpty())
- return;
- qApp->d_func()->cursor_list.removeFirst();
- qt_qpa_set_cursor(0, false);
-}
-
-#endif// QT_NO_CURSOR
-
-QWidget *QApplication::topLevelAt(const QPoint &pos)
-{
- QPlatformIntegration *pi = QApplicationPrivate::platformIntegration();
-
- QList<QPlatformScreen *> screens = pi->screens();
- QList<QPlatformScreen *>::const_iterator screen = screens.constBegin();
- QList<QPlatformScreen *>::const_iterator end = screens.constEnd();
-
- // The first screen in a virtual environment should know about all top levels
- if (pi->isVirtualDesktop()) {
- QWidget *w = (*screen)->topLevelAt(pos);
- return w;
- }
-
- while (screen != end) {
- if ((*screen)->geometry().contains(pos))
- return (*screen)->topLevelAt(pos);
- ++screen;
- }
- return 0;
-}
-
-void QApplication::beep()
-{
-}
-
-void QApplication::alert(QWidget *, int)
-{
-}
-
-QPlatformNativeInterface *QApplication::platformNativeInterface()
-{
- QPlatformIntegration *pi = QApplicationPrivate::platformIntegration();
- return pi->nativeInterface();
-}
-
-static void init_platform(const QString &name, const QString &platformPluginPath)
-{
- QApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, platformPluginPath);
- if (!QApplicationPrivate::platform_integration) {
- QStringList keys = QPlatformIntegrationFactory::keys(platformPluginPath);
- QString fatalMessage =
- QString::fromLatin1("Failed to load platform plugin \"%1\". Available platforms are: \n").arg(name);
- foreach(QString key, keys) {
- fatalMessage.append(key + QString::fromLatin1("\n"));
- }
- qFatal("%s", fatalMessage.toLocal8Bit().constData());
-
- }
-
-}
-
-
-static void cleanup_platform()
-{
- delete QApplicationPrivate::platform_integration;
- QApplicationPrivate::platform_integration = 0;
-}
-
-static void init_plugins(const QList<QByteArray> pluginList)
-{
- for (int i = 0; i < pluginList.count(); ++i) {
- QByteArray pluginSpec = pluginList.at(i);
- qDebug() << "init_plugins" << i << pluginSpec;
- int colonPos = pluginSpec.indexOf(':');
- QObject *plugin;
- if (colonPos < 0)
- plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec), QString());
- else
- plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec.mid(0, colonPos)),
- QLatin1String(pluginSpec.mid(colonPos+1)));
- qDebug() << " created" << plugin;
- }
-}
-
-#ifndef QT_NO_QWS_INPUTMETHODS
-class QDummyInputContext : public QInputContext
-{
-public:
- explicit QDummyInputContext(QObject* parent = 0) : QInputContext(parent) {}
- ~QDummyInputContext() {}
- QString identifierName() { return QString(); }
- QString language() { return QString(); }
-
- void reset() {}
- bool isComposing() const { return false; }
-
-};
-#endif // QT_NO_QWS_INPUTMETHODS
-
-void qt_init(QApplicationPrivate *priv, int type)
-{
- Q_UNUSED(type);
-
- qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
- char *p;
- char **argv = priv->argv;
- int argc = priv->argc;
-
- if (argv && *argv) { //apparently, we allow people to pass 0 on the other platforms
- p = strrchr(argv[0], '/');
- appName = QString::fromLocal8Bit(p ? p + 1 : argv[0]);
- }
-
- QList<QByteArray> pluginList;
- QString platformPluginPath = QLatin1String(qgetenv("QT_QPA_PLATFORM_PLUGIN_PATH"));
- QByteArray platformName;
-#ifdef QT_QPA_DEFAULT_PLATFORM_NAME
- platformName = QT_QPA_DEFAULT_PLATFORM_NAME;
-#endif
- QByteArray platformNameEnv = qgetenv("QT_QPA_PLATFORM");
- if (!platformNameEnv.isEmpty()) {
- platformName = platformNameEnv;
- }
-
- // Get command line params
-
- int j = argc ? 1 : 0;
- for (int i=1; i<argc; i++) {
- if (argv[i] && *argv[i] != '-') {
- argv[j++] = argv[i];
- continue;
- }
- QByteArray arg = argv[i];
- if (arg == "-fn" || arg == "-font") {
- if (++i < argc)
- appFont = QString::fromLocal8Bit(argv[i]);
- } else if (arg == "-platformpluginpath") {
- if (++i < argc)
- platformPluginPath = QLatin1String(argv[i]);
- } else if (arg == "-platform") {
- if (++i < argc)
- platformName = argv[i];
- } else if (arg == "-plugin") {
- if (++i < argc)
- pluginList << argv[i];
- } else {
- argv[j++] = argv[i];
- }
- }
-
- if (j < priv->argc) {
- priv->argv[j] = 0;
- priv->argc = j;
- }
-
-#if 0
- QByteArray pluginEnv = qgetenv("QT_QPA_PLUGINS");
- if (!pluginEnv.isEmpty()) {
- pluginList.append(pluginEnv.split(';'));
- }
-#endif
-
- init_platform(QLatin1String(platformName), platformPluginPath);
- init_plugins(pluginList);
-
- QColormap::initialize();
- QFont::initialize();
-#ifndef QT_NO_CURSOR
-// QCursorData::initialize();
-#endif
-
- qApp->setObjectName(appName);
-
-#ifndef QT_NO_QWS_INPUTMETHODS
- qApp->setInputContext(new QDummyInputContext(qApp));
-#endif
-}
-
-void qt_cleanup()
-{
- cleanup_platform();
-
- QPixmapCache::clear();
-#ifndef QT_NO_CURSOR
- QCursorData::cleanup();
-#endif
- QFont::cleanup();
- QColormap::cleanup();
- delete QApplicationPrivate::inputContext;
- QApplicationPrivate::inputContext = 0;
-
- QApplicationPrivate::active_window = 0; //### this should not be necessary
-}
-
-
-#ifdef QT3_SUPPORT
-void QApplication::setMainWidget(QWidget *mainWidget)
-{
- QApplicationPrivate::main_widget = mainWidget;
- if (QApplicationPrivate::main_widget && windowIcon().isNull()
- && QApplicationPrivate::main_widget->testAttribute(Qt::WA_SetWindowIcon))
- setWindowIcon(QApplicationPrivate::main_widget->windowIcon());
-}
-#endif
-
-void QApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::MouseEvent *e)
-{
- // qDebug() << "handleMouseEvent" << tlw << ev.pos() << ev.globalPos() << hex << ev.buttons();
- static QWeakPointer<QWidget> implicit_mouse_grabber;
-
- QEvent::Type type;
- // move first
- Qt::MouseButtons stateChange = e->buttons ^ buttons;
- if (e->globalPos != QPoint(qt_last_x, qt_last_y) && (stateChange != Qt::NoButton)) {
- QWindowSystemInterfacePrivate::MouseEvent * newMouseEvent =
- new QWindowSystemInterfacePrivate::MouseEvent(e->widget.data(), e->timestamp, e->localPos, e->globalPos, e->buttons);
- QWindowSystemInterfacePrivate::windowSystemEventQueue.prepend(newMouseEvent); // just in case the move triggers a new event loop
- stateChange = Qt::NoButton;
- }
-
- QWidget * tlw = e->widget.data();
-
- QPoint localPoint = e->localPos;
- QPoint globalPoint = e->globalPos;
- QWidget *mouseWindow = tlw;
-
- Qt::MouseButton button = Qt::NoButton;
-
-
- if (qt_last_x != globalPoint.x() || qt_last_y != globalPoint.y()) {
- type = QEvent::MouseMove;
- qt_last_x = globalPoint.x();
- qt_last_y = globalPoint.y();
- if (qAbs(globalPoint.x() - mousePressX) > mouse_double_click_distance||
- qAbs(globalPoint.y() - mousePressY) > mouse_double_click_distance)
- mousePressButton = Qt::NoButton;
- }
- else { // check to see if a new button has been pressed/released
- for (int check = Qt::LeftButton;
- check <= Qt::XButton2;
- check = check << 1) {
- if (check & stateChange) {
- button = Qt::MouseButton(check);
- break;
- }
- }
- if (button == Qt::NoButton) {
- // Ignore mouse events that don't change the current state
- return;
- }
- buttons = e->buttons;
- if (button & e->buttons) {
- if ((e->timestamp - mousePressTime) < static_cast<ulong>(QApplication::doubleClickInterval()) && button == mousePressButton) {
- type = QEvent::MouseButtonDblClick;
- mousePressButton = Qt::NoButton;
- }
- else {
- type = QEvent::MouseButtonPress;
- mousePressTime = e->timestamp;
- mousePressButton = button;
- mousePressX = qt_last_x;
- mousePressY = qt_last_y;
- }
- }
- else
- type = QEvent::MouseButtonRelease;
- }
-
- if (self->inPopupMode()) {
- //popup mouse handling is magical...
- mouseWindow = qApp->activePopupWidget();
-
- implicit_mouse_grabber.clear();
- //### how should popup mode and implicit mouse grab interact?
-
- } else if (tlw && app_do_modal && !qt_try_modal(tlw, QEvent::MouseButtonRelease) ) {
- //even if we're blocked by modality, we should deliver the mouse release event..
- //### this code is not completely correct: multiple buttons can be pressed simultaneously
- if (!(implicit_mouse_grabber && buttons == Qt::NoButton)) {
- //qDebug() << "modal blocked mouse event to" << tlw;
- return;
- }
- }
-
- // find the tlw if we didn't get it from the plugin
- if (!mouseWindow) {
- mouseWindow = QApplication::topLevelAt(globalPoint);
- }
-
- if (!mouseWindow && !implicit_mouse_grabber)
- mouseWindow = QApplication::desktop();
-
- if (mouseWindow && mouseWindow != tlw) {
- //we did not get a sensible localPoint from the window system, so let's calculate it
- localPoint = mouseWindow->mapFromGlobal(globalPoint);
- }
-
- // which child should have it?
- QWidget *mouseWidget = mouseWindow;
- if (mouseWindow) {
- QWidget *w = mouseWindow->childAt(localPoint);
- if (w) {
- mouseWidget = w;
- }
- }
-
- //handle implicit mouse grab
- if (type == QEvent::MouseButtonPress && !implicit_mouse_grabber) {
- implicit_mouse_grabber = mouseWidget;
-
- Q_ASSERT(mouseWindow);
- mouseWindow->activateWindow(); //focus
- } else if (implicit_mouse_grabber) {
- mouseWidget = implicit_mouse_grabber.data();
- mouseWindow = mouseWidget->window();
- if (mouseWindow != tlw)
- localPoint = mouseWindow->mapFromGlobal(globalPoint);
- }
-
- Q_ASSERT(mouseWidget);
-
- //localPoint is local to mouseWindow, but it needs to be local to mouseWidget
- localPoint = mouseWidget->mapFrom(mouseWindow, localPoint);
-
- if (buttons == Qt::NoButton) {
- //qDebug() << "resetting mouse grabber";
- implicit_mouse_grabber.clear();
- }
-
- if (mouseWidget != qt_last_mouse_receiver) {
- dispatchEnterLeave(mouseWidget, qt_last_mouse_receiver);
- qt_last_mouse_receiver = mouseWidget;
- }
-
- // Remember, we might enter a modal event loop when sending the event,
- // so think carefully before adding code below this point.
-
- // qDebug() << "sending mouse ev." << ev.type() << localPoint << globalPoint << ev.button() << ev.buttons() << mouseWidget << "mouse grabber" << implicit_mouse_grabber;
-
- QMouseEvent ev(type, localPoint, globalPoint, button, buttons, QApplication::keyboardModifiers());
-
- QList<QWeakPointer<QPlatformCursor> > cursors = QPlatformCursorPrivate::getInstances();
- foreach (QWeakPointer<QPlatformCursor> cursor, cursors) {
- if (cursor)
- cursor.data()->pointerEvent(ev);
- }
-
- int oldOpenPopupCount = openPopupCount;
- QApplication::sendSpontaneousEvent(mouseWidget, &ev);
-
-#ifndef QT_NO_CONTEXTMENU
- if (type == QEvent::MouseButtonPress && button == Qt::RightButton && (openPopupCount == oldOpenPopupCount)) {
- QContextMenuEvent e(QContextMenuEvent::Mouse, localPoint, globalPoint, QApplication::keyboardModifiers());
- QApplication::sendSpontaneousEvent(mouseWidget, &e);
- }
-#endif // QT_NO_CONTEXTMENU
-}
-
-
-//### there's a lot of duplicated logic here -- refactoring required!
-
-void QApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::WheelEvent *e)
-{
-// QPoint localPoint = ev.pos();
- QPoint globalPoint = e->globalPos;
-// bool trustLocalPoint = !!tlw; //is there something the local point can be local to?
- QWidget *mouseWidget;
-
- qt_last_x = globalPoint.x();
- qt_last_y = globalPoint.y();
-
- QWidget *mouseWindow = e->widget.data();
-
- // find the tlw if we didn't get it from the plugin
- if (!mouseWindow) {
- mouseWindow = QApplication::topLevelAt(globalPoint);
- }
-
- if (!mouseWindow)
- return;
-
- mouseWidget = mouseWindow;
-
- if (app_do_modal && !qt_try_modal(mouseWindow, QEvent::Wheel) ) {
- qDebug() << "modal blocked wheel event" << mouseWindow;
- return;
- }
- QPoint p = mouseWindow->mapFromGlobal(globalPoint);
- QWidget *w = mouseWindow->childAt(p);
- if (w) {
- mouseWidget = w;
- p = mouseWidget->mapFromGlobal(globalPoint);
- }
-
- QWheelEvent ev(p, globalPoint, e->delta, buttons, QApplication::keyboardModifiers(),
- e->orient);
- QApplication::sendSpontaneousEvent(mouseWidget, &ev);
-}
-
-
-
-// Remember, Qt convention is: keyboard state is state *before*
-
-void QApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyEvent *e)
-{
- QWidget *focusW = 0;
- if (self->inPopupMode()) {
- QWidget *popupW = qApp->activePopupWidget();
- focusW = popupW->focusWidget() ? popupW->focusWidget() : popupW;
- }
- if (!focusW)
- focusW = QApplication::focusWidget();
- if (!focusW) {
- focusW = e->widget.data();
- }
- if (!focusW)
- focusW = QApplication::activeWindow();
-
- //qDebug() << "handleKeyEvent" << hex << e->key() << e->modifiers() << e->text() << "widget" << focusW;
-
- if (!focusW)
- return;
- if (app_do_modal && !qt_try_modal(focusW, e->keyType))
- return;
-
- if (e->nativeScanCode || e->nativeVirtualKey || e->nativeModifiers) {
- QKeyEventEx ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount,
- e->nativeScanCode, e->nativeVirtualKey, e->nativeModifiers);
- QApplication::sendSpontaneousEvent(focusW, &ev);
- } else {
- QKeyEvent ev(e->keyType, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount);
- QApplication::sendSpontaneousEvent(focusW, &ev);
- }
-}
-
-void QApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e)
-{
- QApplicationPrivate::dispatchEnterLeave(e->enter.data(),0);
- qt_last_mouse_receiver = e->enter.data();
-}
-
-void QApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e)
-{
- QApplicationPrivate::dispatchEnterLeave(0,qt_last_mouse_receiver);
-
- if (e->leave.data() && !e->leave.data()->isAncestorOf(qt_last_mouse_receiver)) //(???) this should not happen
- QApplicationPrivate::dispatchEnterLeave(0, e->leave.data());
- qt_last_mouse_receiver = 0;
-
-}
-
-void QApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e)
-{
- QApplication::setActiveWindow(e->activated.data());
-}
-
-void QApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e)
-{
- if (e->tlw.isNull())
- return;
- QWidget *tlw = e->tlw.data();
- if (!tlw->isWindow())
- return; //geo of native child widgets is controlled by lighthouse
- //so we already have sent the events; besides this new rect
- //is not mapped to parent
-
- QRect newRect = e->newGeometry;
- QRect cr(tlw->geometry());
- bool isResize = cr.size() != newRect.size();
- bool isMove = cr.topLeft() != newRect.topLeft();
- tlw->data->crect = newRect;
- if (isResize) {
- QResizeEvent e(tlw->data->crect.size(), cr.size());
- QApplication::sendSpontaneousEvent(tlw, &e);
- tlw->update();
- }
-
- if (isMove) {
- //### frame geometry
- QMoveEvent e(tlw->data->crect.topLeft(), cr.topLeft());
- QApplication::sendSpontaneousEvent(tlw, &e);
- }
-}
-
-void QApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::CloseEvent *e)
-{
- if (e->topLevel.isNull()) {
- //qDebug() << "QApplicationPrivate::processCloseEvent NULL";
- return;
- }
- e->topLevel.data()->d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent);
-}
-
-void QApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e)
-{
- translateRawTouchEvent(e->widget.data(), e->devType, e->points);
-}
-
-void QApplicationPrivate::reportScreenCount(QWindowSystemInterfacePrivate::ScreenCountEvent *e)
-{
- // This operation only makes sense after the QApplication constructor runs
- if (QCoreApplication::startingUp())
- return;
-
- QApplication::desktop()->d_func()->updateScreenList();
- // signal anything listening for creation or deletion of screens
- QDesktopWidget *desktop = QApplication::desktop();
- emit desktop->screenCountChanged(e->count);
-}
-
-void QApplicationPrivate::reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e)
-{
- // This operation only makes sense after the QApplication constructor runs
- if (QCoreApplication::startingUp())
- return;
-
- QApplication::desktop()->d_func()->updateScreenList();
-
- // signal anything listening for screen geometry changes
- QDesktopWidget *desktop = QApplication::desktop();
- emit desktop->resized(e->index);
-
- // make sure maximized and fullscreen windows are updated
- QWidgetList list = QApplication::topLevelWidgets();
- for (int i = list.size() - 1; i >= 0; --i) {
- QWidget *w = list.at(i);
- if (w->isFullScreen())
- w->d_func()->setFullScreenSize_helper();
- else if (w->isMaximized())
- w->d_func()->setMaxWindowState_helper();
- }
-}
-
-void QApplicationPrivate::reportAvailableGeometryChange(
- QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e)
-{
- // This operation only makes sense after the QApplication constructor runs
- if (QCoreApplication::startingUp())
- return;
-
- QApplication::desktop()->d_func()->updateScreenList();
-
- // signal anything listening for screen geometry changes
- QDesktopWidget *desktop = QApplication::desktop();
- emit desktop->workAreaResized(e->index);
-
- // make sure maximized and fullscreen windows are updated
- QWidgetList list = QApplication::topLevelWidgets();
- for (int i = list.size() - 1; i >= 0; --i) {
- QWidget *w = list.at(i);
- if (w->isFullScreen())
- w->d_func()->setFullScreenSize_helper();
- else if (w->isMaximized())
- w->d_func()->setMaxWindowState_helper();
- }
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qapplication_qws.cpp b/src/gui/kernel/qapplication_qws.cpp
deleted file mode 100644
index 642d3e6afc..0000000000
--- a/src/gui/kernel/qapplication_qws.cpp
+++ /dev/null
@@ -1,3797 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qglobal.h"
-#include "qlibrary.h"
-#include "qcursor.h"
-#include "qapplication.h"
-#include "private/qapplication_p.h"
-#include "qwidget.h"
-#include "qbitarray.h"
-#include "qpainter.h"
-#include "qpixmapcache.h"
-#include "qdatetime.h"
-#include "qtextcodec.h"
-#include "qdatastream.h"
-#include "qbuffer.h"
-#include "qsocketnotifier.h"
-#include "qsessionmanager.h"
-#include "qclipboard.h"
-#include "qbitmap.h"
-#include "qwssocket_qws.h"
-#include "qtransportauth_qws.h"
-#include "private/qtransportauth_qws_p.h"
-#include "qwsevent_qws.h"
-#include "private/qwscommand_qws_p.h"
-#include "qwsproperty_qws.h"
-#include "qscreen_qws.h"
-#include "qscreenproxy_qws.h"
-#include "qcopchannel_qws.h"
-#include "private/qlock_p.h"
-#include "private/qwslock_p.h"
-//#include "qmemorymanager_qws.h"
-#include "qwsmanager_qws.h"
-//#include "qwsregionmanager_qws.h"
-#include "qwindowsystem_qws.h"
-#include "private/qwindowsystem_p.h"
-#include "qdecorationfactory_qws.h"
-
-#include "qwsdisplay_qws.h"
-#include "private/qwsdisplay_qws_p.h"
-#include "private/qwsinputcontext_p.h"
-#include "qfile.h"
-#include "qhash.h"
-#include "qdesktopwidget.h"
-#include "qcolormap.h"
-#include "private/qcursor_p.h"
-#include "qsettings.h"
-#include "qdebug.h"
-#include "qeventdispatcher_qws_p.h"
-#if !defined(QT_NO_GLIB)
-# include "qeventdispatcher_glib_qws_p.h"
-#endif
-
-
-#include "private/qwidget_p.h"
-#include "private/qbackingstore_p.h"
-#include "private/qwindowsurface_qws_p.h"
-#include "private/qfont_p.h"
-
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <locale.h>
-#include <errno.h>
-#include <fcntl.h>
-#ifdef Q_OS_VXWORKS
-# include <sys/times.h>
-#else
-# include <sys/time.h>
-#endif
-#include <sys/stat.h>
-#include <sys/types.h>
-
-#include <qvfbhdr.h>
-
-#ifndef QT_NO_QWS_MULTIPROCESS
-#ifdef QT_NO_QSHM
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#ifndef Q_OS_DARWIN
-# include <sys/sem.h>
-#endif
-#include <sys/socket.h>
-#else
-#include "private/qwssharedmemory_p.h"
-#endif
-#endif
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_DIRECTPAINTER
-class QDirectPainter;
-extern void qt_directpainter_region(QDirectPainter *dp, const QRegion &alloc, int type);
-#ifndef QT_NO_QWSEMBEDWIDGET
-extern void qt_directpainter_embedevent(QDirectPainter *dp,
- const QWSEmbedEvent *e);
-#endif
-#endif // QT_NO_DIRECTPAINTER
-
-const int qwsSharedRamSize = 1 * 1024; // misc data, written by server, read by clients
-
-extern QApplication::Type qt_appType;
-extern QDesktopWidget *qt_desktopWidget;
-
-//these used to be environment variables, they are initialized from
-//environment variables in
-
-bool qws_savefonts = false;
-bool qws_screen_is_interlaced=false; //### should be detected
-bool qws_shared_memory = false;
-bool qws_sw_cursor = true;
-bool qws_accel = true; // ### never set
-QByteArray qws_display_spec(":0");
-Q_GUI_EXPORT int qws_display_id = 0;
-Q_GUI_EXPORT int qws_client_id = 0;
-QWidget *qt_pressGrab = 0;
-QWidget *qt_mouseGrb = 0;
-int *qt_last_x = 0;
-int *qt_last_y = 0;
-
-static int mouse_x_root = -1;
-static int mouse_y_root = -1;
-static int mouse_state = 0;
-static int mouse_double_click_distance = 5;
-
-int qt_servershmid = -1;
-
-bool qws_overrideCursor = false;
-#ifndef QT_NO_QWS_MANAGER
-
-extern Q_GUI_EXPORT QWSServer *qwsServer;
-
-static QDecoration *qws_decoration = 0;
-#endif
-
-#if defined(QT_DEBUG)
-/*
-extern "C" void dumpmem(const char* m)
-{
- static int init=0;
- static int prev=0;
- FILE* f = fopen("/proc/meminfo","r");
- // char line[100];
- int total=0,used=0,free=0,shared=0,buffers=0,cached=0;
- fscanf(f,"%*[^M]Mem: %d %d %d %d %d %d",&total,&used,&free,&shared,&buffers,&cached);
- used -= buffers + cached;
- if (!init) {
- init=used;
- } else {
- printf("%40s: %+8d = %8d\n",m,used-init-prev,used-init);
- prev = used-init;
- }
- fclose(f);
-}
-*/
-#endif
-
-// Get the name of the directory where Qt for Embedded Linux temporary data should
-// live.
-QString qws_dataDir()
-{
- static QString result;
- if (!result.isEmpty())
- return result;
- result = QT_VFB_DATADIR(qws_display_id);
- QByteArray dataDir = result.toLocal8Bit();
-
-#if defined(Q_OS_INTEGRITY)
- /* ensure filesystem is ready before starting requests */
- WaitForFileSystemInitialization();
-#endif
-
- if (QT_MKDIR(dataDir, 0700)) {
- if (errno != EEXIST) {
- qFatal("Cannot create Qt for Embedded Linux data directory: %s", dataDir.constData());
- }
- }
-
- QT_STATBUF buf;
- if (QT_LSTAT(dataDir, &buf))
- qFatal("stat failed for Qt for Embedded Linux data directory: %s", dataDir.constData());
-
- if (!S_ISDIR(buf.st_mode))
- qFatal("%s is not a directory", dataDir.constData());
-
-#if !defined(Q_OS_INTEGRITY) && !defined(Q_OS_VXWORKS)
- if (buf.st_uid != getuid())
- qFatal("Qt for Embedded Linux data directory is not owned by user %d", getuid());
-
- if ((buf.st_mode & 0677) != 0600)
- qFatal("Qt for Embedded Linux data directory has incorrect permissions: %s", dataDir.constData());
-#endif
-
- result.append("/");
- return result;
-}
-
-// Get the filename of the pipe Qt for Embedded Linux uses for server/client comms
-Q_GUI_EXPORT QString qws_qtePipeFilename()
-{
- qws_dataDir();
- return QTE_PIPE(qws_display_id);
-}
-
-static void setMaxWindowRect(const QRect &rect)
-{
- const QList<QScreen*> subScreens = qt_screen->subScreens();
- QScreen *screen = qt_screen;
- int screenNo = 0;
- for (int i = 0; i < subScreens.size(); ++i) {
- if (subScreens.at(i)->region().contains(rect)) {
- screen = subScreens.at(i);
- screenNo = i;
- break;
- }
- }
-
- QApplicationPrivate *ap = QApplicationPrivate::instance();
- ap->setMaxWindowRect(screen, screenNo, rect);
-}
-
-void QApplicationPrivate::setMaxWindowRect(const QScreen *screen, int screenNo,
- const QRect &rect)
-{
- if (maxWindowRects.value(screen) == rect)
- return;
-
- maxWindowRects[screen] = rect;
-
- // Re-resize any maximized windows
- QWidgetList l = QApplication::topLevelWidgets();
- for (int i = 0; i < l.size(); ++i) {
- QWidget *w = l.at(i);
- QScreen *s = w->d_func()->getScreen();
- if (w->isMaximized() && s == screen)
- w->d_func()->setMaxWindowState_helper();
- }
-
- if ( qt_desktopWidget ) // XXX workaround crash
- emit QApplication::desktop()->workAreaResized(screenNo);
-}
-
-#ifndef QT_NO_QWS_DYNAMICSCREENTRANSFORMATION
-
-typedef void (*TransformFunc)(QScreen *, int);
-#ifndef QT_NO_QWS_TRANSFORMED
-extern "C" void qws_setScreenTransformation(QScreen *, int);
-#endif
-static TransformFunc getTransformationFunction()
-{
- static TransformFunc func = 0;
-
- if (!func) {
-#ifdef QT_NO_QWS_TRANSFORMED
-# ifndef QT_NO_LIBRARY
- // symbol is not built into the library, search for the plugin
- const QStringList paths = QApplication::libraryPaths();
- foreach (const QString &path, paths) {
- const QString file = path + QLatin1String("/gfxdrivers/libqgfxtransformed");
- func = (TransformFunc)QLibrary::resolve(file,
- "qws_setScreenTransformation");
- if (func)
- break;
- }
-# endif
-#else
- func = qws_setScreenTransformation;
-#endif
- if (!func)
- func = (TransformFunc)-1;
- }
-
- if (func == (TransformFunc)-1)
- return 0;
-
- return func;
-}
-
-static void setScreenTransformation(int screenNo, int transformation)
-{
- QScreen *screen = QScreen::instance();
- const QList<QScreen*> subScreens = screen->subScreens();
-
- if (screenNo == -1)
- screenNo = 0;
-
- if (screenNo == -1 && !subScreens.isEmpty())
- screenNo = 0;
-
- if (subScreens.isEmpty() && screenNo == 0) {
- // nothing
- } else if (screenNo < 0 || screenNo >= subScreens.size()) {
- qWarning("setScreenTransformation: invalid screen %i", screenNo);
- return;
- }
-
- if (screenNo < subScreens.size())
- screen = subScreens.at(screenNo);
-
- QApplicationPrivate *ap = QApplicationPrivate::instance();
- ap->setScreenTransformation(screen, screenNo, transformation);
-}
-
-void QApplicationPrivate::setScreenTransformation(QScreen *screen,
- int screenNo,
- int transformation)
-{
- QScreen *transformed = screen;
-
- while (transformed->classId() == QScreen::ProxyClass)
- transformed = static_cast<QProxyScreen*>(transformed)->screen();
-
- if (transformed->classId() != QScreen::TransformedClass)
- return;
-
- TransformFunc setScreenTransformation = getTransformationFunction();
- if (!setScreenTransformation)
- return;
-
- setScreenTransformation(transformed, transformation);
-
- // need to re-configure() proxies bottom-up
- if (screen->classId() == QScreen::ProxyClass) {
- QList<QProxyScreen*> proxies;
- QScreen *s = screen;
-
- do {
- QProxyScreen *proxy = static_cast<QProxyScreen*>(s);
- proxies.append(proxy);
- s = proxy->screen();
- } while (s->classId() == QScreen::ProxyClass);
-
- do {
- QProxyScreen *proxy = proxies.takeLast();
- proxy->setScreen(proxy->screen()); // triggers configure()
- } while (!proxies.isEmpty());
- }
-
- if (qt_desktopWidget) { // XXX workaround crash for early screen transform events
- QDesktopWidget *desktop = QApplication::desktop();
-
- emit desktop->resized(screenNo);
- if (maxWindowRect(screen).isEmpty()) // not explicitly set
- emit desktop->workAreaResized(screenNo);
- }
-
- QWSServer *server = QWSServer::instance();
- if (server) {
- server->updateWindowRegions();
- QRegion r = screen->region();
- server->refresh(r);
- }
-
- // make sure maximized and fullscreen windows are updated
- QWidgetList list = QApplication::topLevelWidgets();
- for (int i = list.size() - 1; i >= 0; --i) {
- QWidget *w = list.at(i);
- if (w->isFullScreen())
- w->d_func()->setFullScreenSize_helper();
- else if (w->isMaximized())
- w->d_func()->setMaxWindowState_helper();
- }
-}
-
-#endif // QT_NO_QWS_DYNAMICSCREENTRANSFORMATION
-
-/*****************************************************************************
- Internal variables and functions
- *****************************************************************************/
-
-
-static QString appName; // application name
-static const char *appFont = 0; // application font
-static const char *appBGCol = 0; // application bg color
-static const char *appFGCol = 0; // application fg color
-static const char *appBTNCol = 0; // application btn color
-static const char *mwGeometry = 0; // main widget geometry
-static const char *mwTitle = 0; // main widget title
-//static bool mwIconic = false; // main widget iconified
-
-static bool app_do_modal = false; // modal mode
-Q_GUI_EXPORT QWSDisplay *qt_fbdpy = 0; // QWS `display'
-QLock *QWSDisplay::lock = 0;
-
-static int mouseButtonPressed = 0; // last mouse button pressed
-static int mouseButtonPressTime = 0; // when was a button pressed
-static short mouseXPos, mouseYPos; // mouse position in act window
-
-extern QWidgetList *qt_modal_stack; // stack of modal widgets
-
-static QWidget *popupButtonFocus = 0;
-static QWidget *popupOfPopupButtonFocus = 0;
-static bool popupCloseDownMode = false;
-static bool popupGrabOk;
-static QPointer<QWidget> *mouseInWidget = 0;
-QPointer<QWidget> qt_last_mouse_receiver = 0;
-
-static bool sm_blockUserInput = false; // session management
-
-QWidget *qt_button_down = 0; // widget got last button-down
-WId qt_last_cursor = 0xffffffff; // Was -1, but WIds are unsigned
-
-class QWSMouseEvent;
-class QWSKeyEvent;
-
-class QETWidget : public QWidget // event translator widget
-{
-public:
- bool translateMouseEvent(const QWSMouseEvent *, int oldstate);
- bool translateKeyEvent(const QWSKeyEvent *, bool grab);
- bool translateRegionEvent(const QWSRegionEvent *);
-#ifndef QT_NO_QWSEMBEDWIDGET
- void translateEmbedEvent(const QWSEmbedEvent *event);
-#endif
- bool translateWheelEvent(const QWSMouseEvent *me);
- void repaintDecoration(QRegion r, bool post);
- void updateRegion();
-
- bool raiseOnClick()
- {
- // With limited windowmanagement/taskbar/etc., raising big windows
- // (eg. spreadsheet) over the top of everything else (eg. calculator)
- // is just annoying.
- return !isMaximized() && !isFullScreen();
- }
-};
-
-void QApplicationPrivate::createEventDispatcher()
-{
- Q_Q(QApplication);
-#if !defined(QT_NO_GLIB)
- if (qgetenv("QT_NO_GLIB").isEmpty() && QEventDispatcherGlib::versionSupported())
- eventDispatcher = (q->type() != QApplication::Tty
- ? new QWSEventDispatcherGlib(q)
- : new QEventDispatcherGlib(q));
- else
-#endif
- eventDispatcher = (q->type() != QApplication::Tty
- ? new QEventDispatcherQWS(q)
- : new QEventDispatcherUNIX(q));
-}
-
-// Single-process stuff. This should maybe move into qwindowsystem_qws.cpp
-
-static bool qws_single_process;
-static QList<QWSEvent*> incoming;
-static QList<QWSCommand*> outgoing;
-
-void qt_client_enqueue(const QWSEvent *event)
-{
- QWSEvent *copy = QWSEvent::factory(event->type);
- copy->copyFrom(event);
- incoming.append(copy);
-}
-
-QList<QWSCommand*> *qt_get_server_queue()
-{
- return &outgoing;
-}
-
-void qt_server_enqueue(const QWSCommand *command)
-{
- QWSCommand *copy = QWSCommand::factory(command->type);
- QT_TRY {
- copy->copyFrom(command);
- outgoing.append(copy);
- } QT_CATCH(...) {
- delete copy;
- QT_RETHROW;
- }
-}
-
-QWSDisplay::Data::Data(QObject* parent, bool singleProcess)
-{
-#ifdef QT_NO_QWS_MULTIPROCESS
- Q_UNUSED(parent);
- Q_UNUSED(singleProcess);
-#else
- if (singleProcess)
- csocket = 0;
- else {
- csocket = new QWSSocket(parent);
- QObject::connect(csocket, SIGNAL(disconnected()),
- qApp, SLOT(quit()));
- }
- clientLock = 0;
-#endif
- init();
-}
-
-QWSDisplay::Data::~Data()
-{
-// delete rgnMan; rgnMan = 0;
-// delete memorymanager; memorymanager = 0;
- qt_screen->disconnect();
- delete qt_screen; qt_screen = 0;
-#ifndef QT_NO_QWS_CURSOR
- delete qt_screencursor; qt_screencursor = 0;
-#endif
-#ifndef QT_NO_QWS_MULTIPROCESS
- shm.detach();
- if (csocket) {
- QWSCommand shutdownCmd(QWSCommand::Shutdown, 0, 0);
- shutdownCmd.write(csocket);
- csocket->flush(); // may be pending QCop message, eg.
- delete csocket;
- }
- delete clientLock;
- clientLock = 0;
-#endif
- delete connected_event;
- delete mouse_event;
- delete current_event;
- qDeleteAll(queue);
-#ifndef QT_NO_COP
- delete qcop_response;
-#endif
-}
-
-#ifndef QT_NO_QWS_MULTIPROCESS
-bool QWSDisplay::Data::lockClient(QWSLock::LockType type, int timeout)
-{
- return !clientLock || clientLock->lock(type, timeout);
-}
-
-void QWSDisplay::Data::unlockClient(QWSLock::LockType type)
-{
- if (clientLock) clientLock->unlock(type);
-}
-
-bool QWSDisplay::Data::waitClient(QWSLock::LockType type, int timeout)
-{
- return !clientLock || clientLock->wait(type, timeout);
-}
-
-QWSLock* QWSDisplay::Data::getClientLock()
-{
- return clientLock;
-}
-#endif // QT_NO_QWS_MULTIPROCESS
-
-void QWSDisplay::Data::flush()
-{
-#ifndef QT_NO_QWS_MULTIPROCESS
- if (csocket) {
- csocket->waitForReadyRead(0);
- csocket->flush();
- }
-#endif
-}
-
-#if 0
-void QWSDisplay::Data::debugQueue() {
- for (int i = 0; i < queue.size(); ++i) {
- QWSEvent *e = queue.at(i);
- qDebug( " ev %d type %d sl %d rl %d", i, e->type, e->simpleLen, e->rawLen);
- }
-}
-#endif
-
-bool QWSDisplay::Data::queueNotEmpty()
-{
- return mouse_event/*||region_event*/||queue.count() > 0;
-}
-QWSEvent* QWSDisplay::Data::dequeue()
-{
- QWSEvent *r=0;
- if (queue.count()) {
- r = queue.first();
- queue.removeFirst();
- if (r->type == QWSEvent::Region)
- region_events_count--;
- } else if (mouse_event) {
- r = mouse_event;
- mouse_event = 0;
-#ifdef QAPPLICATION_EXTRA_DEBUG
- mouse_event_count = 0;
-#endif
- }
- return r;
-}
-
-QWSEvent* QWSDisplay::Data::peek()
-{
- return queue.first();
-}
-
-bool QWSDisplay::Data::directServerConnection()
-{
-#ifndef QT_NO_QWS_MULTIPROCESS
- return csocket == 0;
-#else
- return true;
-#endif
-}
-
-void QWSDisplay::Data::create(int n)
-{
- QWSCreateCommand cmd(n);
- sendCommand(cmd);
-}
-
-void QWSDisplay::Data::flushCommands()
-{
-#ifndef QT_NO_QWS_MULTIPROCESS
- if (csocket)
- csocket->flush();
-#endif
-}
-
-void QWSDisplay::Data::sendCommand(QWSCommand & cmd)
-{
-#ifndef QT_NO_QWS_MULTIPROCESS
- if (csocket)
- cmd.write(csocket);
- else
-#endif
- qt_server_enqueue(&cmd);
-}
-
-void QWSDisplay::Data::sendSynchronousCommand(QWSCommand & cmd)
-{
-#ifndef QT_NO_QWS_MULTIPROCESS
- if (csocket) {
- lockClient(QWSLock::Communication);
- cmd.write(csocket);
- bool ok = true;
- while (csocket->bytesToWrite() > 0) {
- if (!csocket->waitForBytesWritten(-1)) {
- qCritical("QWSDisplay::Data::sendSynchronousCommand: %s",
- qPrintable(csocket->errorString()));
- ok = false;
- break;
- }
- }
- if (ok)
- waitClient(QWSLock::Communication);
- } else
-#endif
- qt_server_enqueue(&cmd);
-}
-
-int QWSDisplay::Data::takeId()
-{
- int unusedIdCount = unused_identifiers.count();
- if (unusedIdCount <= 10)
- create(15);
- if (unusedIdCount == 0) {
- create(1); // Make sure we have an incoming id to wait for, just in case we're recursive
- waitForCreation();
- }
-
- return unused_identifiers.takeFirst();
-}
-
-void QWSDisplay::Data::setMouseFilter(void (*filter)(QWSMouseEvent*))
-{
- mouseFilter = filter;
-}
-
-#ifndef QT_NO_QWS_MULTIPROCESS
-
-QWSLock* QWSDisplay::Data::clientLock = 0;
-
-void Q_GUI_EXPORT qt_app_reinit( const QString& newAppName )
-{
- qt_fbdpy->d->reinit( newAppName );
-}
-
-#endif // QT_NO_QWS_MULTIPROCESS
-
-class QDesktopWidget;
-
-#ifndef QT_NO_QWS_MULTIPROCESS
-void QWSDisplay::Data::reinit( const QString& newAppName )
-{
- Q_ASSERT(csocket);
-
- delete connected_event;
- connected_event = 0;
- region_events_count = 0;
-// region_ack = 0;
- delete mouse_event;
- mouse_event = 0;
-// region_event = 0;
- region_offset_window = 0;
-#ifndef QT_NO_COP
- delete qcop_response;
- qcop_response = 0;
-#endif
- delete current_event;
- current_event = 0;
-#ifdef QAPPLICATION_EXTRA_DEBUG
- mouse_event_count = 0;
-#endif
- mouseFilter = 0;
-
- qt_desktopWidget = 0;
- delete QWSDisplay::Data::clientLock;
- QWSDisplay::Data::clientLock = 0;
-
- QString pipe = qws_qtePipeFilename();
-
- // QWS client
- // Cleanup all cached ids
- unused_identifiers.clear();
- delete csocket;
-
- appName = newAppName;
- qApp->setObjectName( appName );
-
- csocket = new QWSSocket();
- QObject::connect(csocket, SIGNAL(disconnected()),
- qApp, SLOT(quit()));
- csocket->connectToLocalFile(pipe);
-
- QWSDisplay::Data::clientLock = new QWSLock();
-
- QWSIdentifyCommand cmd;
- cmd.setId(appName, QWSDisplay::Data::clientLock->id());
-
-#ifndef QT_NO_SXE
- QTransportAuth *a = QTransportAuth::getInstance();
- QTransportAuth::Data *d = a->connectTransport(
- QTransportAuth::UnixStreamSock |
- QTransportAuth::Trusted,
- csocket->socketDescriptor());
- QAuthDevice *ad = a->authBuf( d, csocket );
- ad->setClient( csocket );
-
- cmd.write(ad);
-#else
- cmd.write(csocket);
-#endif
-
- // wait for connect confirmation
- waitForConnection();
-
- qws_client_id = connected_event->simpleData.clientId;
-
- if (!QWSDisplay::initLock(pipe, false))
- qFatal("Cannot get display lock");
-
- if (shm.attach(connected_event->simpleData.servershmid)) {
- sharedRam = static_cast<uchar *>(shm.address());
- QScreen *s = qt_get_screen(qws_display_id, qws_display_spec.constData());
- if (s)
- sharedRamSize += s->memoryNeeded(QLatin1String(qws_display_spec.constData()));
- } else {
- perror("QWSDisplay::Data::init");
- qFatal("Client can't attach to main ram memory.");
- }
-
- qApp->desktop();
-
- // We wait for creation mainly so that we can process important
- // initialization events such as MaxWindowRect that are sent
- // before object id creation. Waiting here avoids later window
- // resizing since we have the MWR before windows are displayed.
- waitForCreation();
-
- sharedRamSize -= sizeof(int);
- qt_last_x = reinterpret_cast<int *>(sharedRam + sharedRamSize);
- sharedRamSize -= sizeof(int);
- qt_last_y = reinterpret_cast<int *>(sharedRam + sharedRamSize);
-
-#ifndef QT_NO_COP
- QCopChannel::reregisterAll();
-#endif
- csocket->flush();
-}
-#endif
-
-void QWSDisplay::Data::init()
-{
- connected_event = 0;
- region_events_count = 0;
-// region_ack = 0;
- mouse_event = 0;
- mouse_state = -1;
- mouse_winid = 0;
-// region_event = 0;
- region_offset_window = 0;
-#ifndef QT_NO_COP
- qcop_response = 0;
-#endif
- current_event = 0;
-#ifdef QAPPLICATION_EXTRA_DEBUG
- mouse_event_count = 0;
-#endif
- mouseFilter = 0;
-
- QString pipe = qws_qtePipeFilename();
-
- sharedRamSize = qwsSharedRamSize;
-
-#ifndef QT_NO_QWS_MULTIPROCESS
- if (csocket) {
- // QWS client
-
- connectToPipe();
-
- QWSDisplay::Data::clientLock = new QWSLock();
-
- QWSIdentifyCommand cmd;
- cmd.setId(appName, QWSDisplay::Data::clientLock->id());
-#ifndef QT_NO_SXE
- QTransportAuth *a = QTransportAuth::getInstance();
- QTransportAuth::Data *d = a->connectTransport(
- QTransportAuth::UnixStreamSock |
- QTransportAuth::Trusted,
- csocket->socketDescriptor());
- QAuthDevice *ad = a->authBuf( d, csocket );
- ad->setClient( csocket );
- cmd.write(ad);
-#else
- cmd.write(csocket);
-#endif
-
- // create(30); // not necessary, server will send ids anyway
- waitForConnection();
-
- qws_client_id = connected_event->simpleData.clientId;
-
- // now we want to get the exact display spec to use if we haven't
- // specified anything.
- if (qws_display_spec.at(0) == ':')
- qws_display_spec = connected_event->display;
-
- if (!QWSDisplay::initLock(pipe, false))
- qFatal("Cannot get display lock");
-
- if (shm.attach(connected_event->simpleData.servershmid)) {
- sharedRam = static_cast<uchar *>(shm.address());
- QScreen *s = qt_get_screen(qws_display_id, qws_display_spec.constData());
- if (s)
- sharedRamSize += s->memoryNeeded(QLatin1String(qws_display_spec.constData()));
- } else {
- perror("QWSDisplay::Data::init");
- qFatal("Client can't attach to main ram memory.");
- }
-
- // We wait for creation mainly so that we can process important
- // initialization events such as MaxWindowRect that are sent
- // before object id creation. Waiting here avoids later window
- // resizing since we have the MWR before windows are displayed.
- waitForCreation();
- } else
-#endif
- {
- create(30);
-
- // QWS server
- if (!QWSDisplay::initLock(pipe, true))
- qFatal("Cannot get display lock");
-
- QScreen *s = qt_get_screen(qws_display_id, qws_display_spec.constData());
- if (s)
- sharedRamSize += s->memoryNeeded(QLatin1String(qws_display_spec.constData()));
-
-#ifndef QT_NO_QWS_MULTIPROCESS
-
- if (!shm.create(sharedRamSize)) {
- perror("Cannot create main ram shared memory\n");
- qFatal("Unable to allocate %d bytes of shared memory", sharedRamSize);
- }
- qt_servershmid = shm.id();
- sharedRam = static_cast<uchar *>(shm.address());
-#else
- sharedRam=static_cast<uchar *>(malloc(sharedRamSize));
-#endif
- // Need to zero index count at end of block, might as well zero
- // the rest too
- memset(sharedRam,0,sharedRamSize);
-
- QWSIdentifyCommand cmd;
- cmd.setId(appName, -1);
- qt_server_enqueue(&cmd);
- }
-
- // Allow some memory for the graphics driver too
- //### Note that sharedRamSize() has side effects; it must be called
- //### once, and only once, and before initDevice()
- sharedRamSize -= qt_screen->sharedRamSize(sharedRam+sharedRamSize);
-
-#ifndef QT_NO_QWS_MULTIPROCESS
- if(!csocket)
-#endif
- {
- //QWS server process
- if (!qt_screen->initDevice())
- qFatal("Unable to initialize screen driver!");
- }
-
- sharedRamSize -= sizeof(int);
- qt_last_x = reinterpret_cast<int *>(sharedRam + sharedRamSize);
- sharedRamSize -= sizeof(int);
- qt_last_y = reinterpret_cast<int *>(sharedRam + sharedRamSize);
-
- /* Initialise framebuffer memory manager */
- /* Add 4k for luck and to avoid clobbering hardware cursor */
-// int screensize=qt_screen->screenSize();
-// memorymanager=new QMemoryManager(qt_screen->base()+screensize+4096,
-// qt_screen->totalSize()-(screensize+4096),0);
-
-// #ifndef QT_NO_QWS_MULTIPROCESS
-// rgnMan = new QWSRegionManager(pipe, csocket);
-// #else
-// rgnMan = new QWSRegionManager(pipe, 0); //####### not necessary
-// #endif
-#ifndef QT_NO_QWS_MULTIPROCESS
- if (csocket)
- csocket->flush();
-#endif
-}
-
-
-QWSEvent* QWSDisplay::Data::readMore()
-{
-#ifdef QT_NO_QWS_MULTIPROCESS
- return incoming.isEmpty() ? 0 : incoming.takeFirst();
-#else
- if (!csocket)
- return incoming.isEmpty() ? 0 : incoming.takeFirst();
- // read next event
- if (!current_event) {
- int event_type = qws_read_uint(csocket);
-
- if (event_type >= 0) {
- current_event = QWSEvent::factory(event_type);
- }
- }
-
- if (current_event) {
- if (current_event->read(csocket)) {
- // Finished reading a whole event.
- QWSEvent* result = current_event;
- current_event = 0;
- return result;
- }
- }
-
- // Not finished reading a whole event.
- return 0;
-#endif
-}
-
-void QWSDisplay::Data::fillQueue()
-{
- QWSServer::processEventQueue();
- QWSEvent *e = readMore();
-#ifndef QT_NO_QWS_MULTIPROCESS
- int bytesAvailable = csocket ? csocket->bytesAvailable() : 0;
- int bytesRead = 0;
-#endif
- while (e) {
-#ifndef QT_NO_QWS_MULTIPROCESS
- bytesRead += QWS_PROTOCOL_ITEM_SIZE((*e));
-#endif
- if (e->type == QWSEvent::Connected) {
- connected_event = static_cast<QWSConnectedEvent *>(e);
- return;
- } else if (e->type == QWSEvent::Creation) {
- QWSCreationEvent *ce = static_cast<QWSCreationEvent*>(e);
- int id = ce->simpleData.objectid;
- int count = ce->simpleData.count;
- for (int i = 0; i < count; ++i)
- unused_identifiers.append(id++);
- delete e;
- } else if (e->type == QWSEvent::Mouse) {
- if (!qt_screen) {
- delete e;
- } else {
- QWSMouseEvent *me = static_cast<QWSMouseEvent*>(e);
- if (mouseFilter)
- mouseFilter(me);
-#ifdef QAPPLICATION_EXTRA_DEBUG
- static const char *defaultAction= "INITIAL";
- const char * action = defaultAction;
-#endif
- delete mouse_event;
- if (mouse_winid != me->window ()
- || mouse_state != me->simpleData.state) {
- queue.append(me);
- mouse_winid = me->window();
- mouse_state = me->simpleData.state;
- mouse_event = 0;
-#ifdef QAPPLICATION_EXTRA_DEBUG
- mouse_event_count = 0;
- action = "ENQUEUE";
-#endif
- } else {
-#ifdef QAPPLICATION_EXTRA_DEBUG
- if (mouse_event)
- action = "COMPRESS";
- mouse_event_count++;
-#endif
- mouse_event = me;
- }
-#ifdef QAPPLICATION_EXTRA_DEBUG
- if (me->simpleData.state !=0 || action != defaultAction || mouse_event_count != 0)
- qDebug("fillQueue %s (%d,%d), state %x win %d count %d", action,
- me->simpleData.x_root, me->simpleData.y_root, me->simpleData.state,
- me->window(), mouse_event_count);
-#endif
- }
-#ifndef QT_NO_QWS_MULTIPROCESS
- } else if (e->type == QWSEvent::Region && clientLock) {
- // not really an unlock, decrements the semaphore
- region_events_count++;
- clientLock->unlock(QWSLock::RegionEvent);
- queue.append(e);
-#endif
-#ifndef QT_NO_QWS_PROPERTIES
- } else if (e->type == QWSEvent::PropertyReply) {
- QWSPropertyReplyEvent *pe = static_cast<QWSPropertyReplyEvent*>(e);
- int len = pe->simpleData.len;
- char *data;
- if (len <= 0) {
- data = 0;
- } else {
- data = new char[len];
- memcpy(data, pe->data, len) ;
- }
- QPaintDevice::qwsDisplay()->getPropertyLen = len;
- QPaintDevice::qwsDisplay()->getPropertyData = data;
- delete e;
-#endif // QT_NO_QWS_PROPERTIES
- } else if (e->type==QWSEvent::MaxWindowRect && qt_screen) {
- // Process this ASAP, in case new widgets are created (startup)
- setMaxWindowRect((static_cast<QWSMaxWindowRectEvent*>(e))->simpleData.rect);
- delete e;
-#ifndef QT_NO_QWS_DYNAMICSCREENTRANSFORMATION
- } else if (e->type == QWSEvent::ScreenTransformation) {
- QWSScreenTransformationEvent *pe = static_cast<QWSScreenTransformationEvent*>(e);
- setScreenTransformation(pe->simpleData.screen,
- pe->simpleData.transformation);
- delete e;
-#endif
-#ifndef QT_NO_COP
- } else if (e->type == QWSEvent::QCopMessage) {
- QWSQCopMessageEvent *pe = static_cast<QWSQCopMessageEvent*>(e);
- if (pe->simpleData.is_response) {
- qcop_response = pe;
- } else {
- queue.append(e);
- }
-#endif
- } else {
- queue.append(e);
- }
- //debugQueue();
-#ifndef QT_NO_QWS_MULTIPROCESS
- if (csocket && bytesRead >= bytesAvailable)
- break;
-#endif
- e = readMore();
- }
-}
-
-#ifndef QT_NO_QWS_MULTIPROCESS
-
-static int qws_connection_timeout = 5;
-
-void QWSDisplay::Data::connectToPipe()
-{
- Q_ASSERT(csocket);
-
- int timeout = qgetenv("QWS_CONNECTION_TIMEOUT").toInt();
- if (timeout)
- qws_connection_timeout = timeout;
-
- const QString pipe = qws_qtePipeFilename();
- int i = 0;
- while (!csocket->connectToLocalFile(pipe)) {
- if (++i > qws_connection_timeout) {
- qWarning("No Qt for Embedded Linux server appears to be running.");
- qWarning("If you want to run this program as a server,");
- qWarning("add the \"-qws\" command-line option.");
- exit(1);
- }
- sleep(1);
- }
-}
-
-void QWSDisplay::Data::waitForConnection()
-{
- connected_event = 0;
-
- for (int i = 0; i < qws_connection_timeout; i++) {
- fillQueue();
- if (connected_event)
- return;
- csocket->flush();
- csocket->waitForReadyRead(1000);
- }
-
- csocket->flush();
- if (!connected_event)
- qFatal("Did not receive a connection event from the qws server");
-}
-
-void QWSDisplay::Data::waitForRegionAck(int winId)
-{
- QWSEvent *ack = 0;
-
- if (csocket) { // GuiClient
- int i = 0;
- while (!ack) {
- fillQueue();
-
- while (i < queue.size()) {
- QWSEvent *e = queue.at(i);
- if (e->type == QWSEvent::Region && e->window() == winId) {
- ack = e;
- queue.removeAt(i);
- break;
- }
- ++i;
- }
-
- if (!ack) {
- csocket->flush();
- csocket->waitForReadyRead(1000);
- }
- }
- } else { // GuiServer
- fillQueue();
- for (int i = 0; i < queue.size(); /* nothing */) {
- QWSEvent *e = queue.at(i);
- if (e->type == QWSEvent::Region && e->window() == winId) {
- ack = e;
- queue.removeAt(i);
- break;
- }
- ++i;
- }
- if (!ack) // already processed
- return;
- }
-
- Q_ASSERT(ack);
-
- qApp->qwsProcessEvent(ack);
- delete ack;
- region_events_count--;
-}
-
-void QWSDisplay::Data::waitForRegionEvents(int winId, bool ungrabDisplay)
-{
- if (!clientLock)
- return;
-
- int removedEventsCount = 0;
-
- // fill queue with unreceived region events
- if (!clientLock->hasLock(QWSLock::RegionEvent)) {
- bool ungrabbed = false;
- if (ungrabDisplay && QWSDisplay::grabbed()) {
- QWSDisplay::ungrab();
- ungrabbed = true;
- }
-
- for (;;) {
- fillQueue();
- if (clientLock->hasLock(QWSLock::RegionEvent))
- break;
- csocket->flush();
- csocket->waitForReadyRead(1000);
- }
-
- if (ungrabbed)
- QWSDisplay::grab(true);
- }
-
- // check the queue for pending region events
- QWSEvent *regionEvent = 0;
- for (int i = 0; i < queue.size(); /* nothing */) {
- QWSEvent *e = queue.at(i);
- if (e->type == QWSEvent::Region && e->window() == winId) {
- QWSRegionEvent *re = static_cast<QWSRegionEvent*>(e);
- if (re->simpleData.type == QWSRegionEvent::Allocation) {
- delete regionEvent;
- regionEvent = re;
- }
- queue.removeAt(i);
- removedEventsCount++;
- } else {
- ++i;
- }
- }
-
- if (regionEvent) {
- qApp->qwsProcessEvent(regionEvent);
- delete regionEvent;
- }
- region_events_count -= removedEventsCount;
-}
-
-bool QWSDisplay::Data::hasPendingRegionEvents() const
-{
- if (clientLock && !clientLock->hasLock(QWSLock::RegionEvent))
- return true;
-
- return region_events_count > 0;
-}
-
-#endif // QT_NO_QWS_MULTIPROCESS
-
-void QWSDisplay::Data::waitForCreation()
-{
- fillQueue();
-#ifndef QT_NO_QWS_MULTIPROCESS
- while (unused_identifiers.count() == 0) {
- if (csocket) {
- csocket->flush();
- csocket->waitForReadyRead(1000);
- }
- fillQueue();
- }
-#endif
-}
-
-
-#ifndef QT_NO_QWS_MULTIPROCESS
-void QWSDisplay::Data::waitForPropertyReply()
-{
- if (!csocket)
- return;
- fillQueue();
- while (qt_fbdpy->getPropertyLen == -2) {
- csocket->flush();
- csocket->waitForReadyRead(1000);
- fillQueue();
- }
-}
-#endif
-
-#ifndef QT_NO_COP
-void QWSDisplay::Data::waitForQCopResponse()
-{
- for (;;) {
- fillQueue();
- if (qcop_response)
- break;
-#ifndef QT_NO_QWS_MULTIPROCESS
- if (csocket) {
- csocket->flush();
- csocket->waitForReadyRead(1000);
- }
-#endif
- }
- queue.prepend(qcop_response);
- qcop_response = 0;
-}
-#endif
-
-/*!
- \class QWSDisplay
- \brief The QWSDisplay class provides a display for QWS; it is an internal class.
-
- \internal
-
- \ingroup qws
-*/
-
-QWSDisplay::QWSDisplay()
-{
- d = new Data(0, qws_single_process);
-}
-
-QWSDisplay::~QWSDisplay()
-{
- delete d;
- delete lock;
- lock = 0;
-}
-
-bool QWSDisplay::grabbed()
-{
- return lock->locked();
-}
-
-void QWSDisplay::grab()
-{
- lock->lock(QLock::Read);
-}
-
-void QWSDisplay::grab(bool write)
-{
- lock->lock(write ? QLock::Write : QLock::Read);
-
-}
-void QWSDisplay::ungrab()
-{
- lock->unlock();
-}
-
-#if 0
-QWSRegionManager *QWSDisplay::regionManager() const
-{
- return d->rgnMan;
-}
-#endif
-
-bool QWSDisplay::eventPending() const
-{
-#ifndef QT_NO_QWS_MULTIPROCESS
- d->flush();
-#endif
- d->fillQueue();
- return d->queueNotEmpty();
-}
-
-
-/*
- Caller must delete return value!
- */
-QWSEvent *QWSDisplay::getEvent()
-{
- d->fillQueue();
- Q_ASSERT(d->queueNotEmpty());
- QWSEvent* e = d->dequeue();
-
- return e;
-}
-
-uchar* QWSDisplay::frameBuffer() const { return qt_screen->base(); }
-int QWSDisplay::width() const { return qt_screen->width(); }
-int QWSDisplay::height() const { return qt_screen->height(); }
-int QWSDisplay::depth() const { return qt_screen->depth(); }
-int QWSDisplay::pixmapDepth() const { return qt_screen->pixmapDepth(); }
-bool QWSDisplay::supportsDepth(int depth) const { return qt_screen->supportsDepth(depth); }
-uchar *QWSDisplay::sharedRam() const { return d->sharedRam; }
-int QWSDisplay::sharedRamSize() const { return d->sharedRamSize; }
-
-#ifndef QT_NO_QWS_PROPERTIES
-
-void QWSDisplay::addProperty(int winId, int property)
-{
- QWSAddPropertyCommand cmd;
- cmd.simpleData.windowid = winId;
- cmd.simpleData.property = property;
- d->sendCommand(cmd);
-}
-
-void QWSDisplay::setProperty(int winId, int property, int mode, const QByteArray &data)
-{
- QWSSetPropertyCommand cmd;
- cmd.simpleData.windowid = winId;
- cmd.simpleData.property = property;
- cmd.simpleData.mode = mode;
- cmd.setData(data.constData(), data.size());
- d->sendCommand(cmd);
-}
-
-void QWSDisplay::setProperty(int winId, int property, int mode,
- const char * data)
-{
- QWSSetPropertyCommand cmd;
- cmd.simpleData.windowid = winId;
- cmd.simpleData.property = property;
- cmd.simpleData.mode = mode;
- cmd.setData(data, strlen(data));
- d->sendCommand(cmd);
-}
-
-void QWSDisplay::removeProperty(int winId, int property)
-{
- QWSRemovePropertyCommand cmd;
- cmd.simpleData.windowid = winId;
- cmd.simpleData.property = property;
- d->sendCommand(cmd);
-}
-
-/*
- It is the caller's responsibility to delete[] \a data.
- */
-bool QWSDisplay::getProperty(int winId, int property, char *&data, int &len)
-{
- if (d->directServerConnection()) {
- const char *propertyData;
- bool retval = qwsServer->d_func()->get_property(winId, property, propertyData, len);
- if (len <= 0) {
- data = 0;
- } else {
- data = new char[len];
- memcpy(data, propertyData, len) ;
- }
- return retval;
- }
- QWSGetPropertyCommand cmd;
- cmd.simpleData.windowid = winId;
- cmd.simpleData.property = property;
- d->sendCommand(cmd);
-
- getPropertyLen = -2;
- getPropertyData = 0;
-
-#ifndef QT_NO_QWS_MULTIPROCESS
- d->waitForPropertyReply();
-#endif
-
- len = getPropertyLen;
- data = getPropertyData;
-
- getPropertyLen = -2;
- getPropertyData = 0;
-
- return len != -1;
-}
-
-#endif // QT_NO_QWS_PROPERTIES
-
-void QWSDisplay::setAltitude(int winId, int alt, bool fixed)
-{
- QWSChangeAltitudeCommand cmd;
-#ifdef QT_DEBUG
- memset(cmd.simpleDataPtr, 0, sizeof(cmd.simpleData)); //shut up Valgrind
-#endif
- cmd.simpleData.windowid = winId;
- cmd.simpleData.altitude = QWSChangeAltitudeCommand::Altitude(alt);
- cmd.simpleData.fixed = fixed;
- if (d->directServerConnection()) {
- qwsServer->d_func()->set_altitude(&cmd);
- } else {
- d->sendSynchronousCommand(cmd);
- }
-}
-
-void QWSDisplay::setOpacity(int winId, int opacity)
-{
- QWSSetOpacityCommand cmd;
- cmd.simpleData.windowid = winId;
- cmd.simpleData.opacity = opacity;
- if (d->directServerConnection()) {
- qwsServer->d_func()->set_opacity(&cmd);
- } else {
- d->sendCommand(cmd);
- }
-}
-
-
-
-void QWSDisplay::requestFocus(int winId, bool get)
-{
- QWSRequestFocusCommand cmd;
- cmd.simpleData.windowid = winId;
- cmd.simpleData.flag = get;
- if (d->directServerConnection())
- qwsServer->d_func()->request_focus(&cmd);
- else
- d->sendCommand(cmd);
-}
-
-void QWSDisplay::setIdentity(const QString &appName)
-{
- QWSIdentifyCommand cmd;
-#ifdef QT_NO_QWS_MULTIPROCESS
- const int id = -1;
-#else
- const int id = QWSDisplay::Data::clientLock ? QWSDisplay::Data::clientLock->id() : -1;
-#endif
- cmd.setId(appName, id);
- if (d->directServerConnection())
- qwsServer->d_func()->set_identity(&cmd);
- else
- d->sendCommand(cmd);
-}
-
-void QWSDisplay::nameRegion(int winId, const QString& n, const QString &c)
-{
- QWSRegionNameCommand cmd;
- cmd.simpleData.windowid = winId;
- cmd.setName(n, c);
- if (d->directServerConnection())
- qwsServer->d_func()->name_region(&cmd);
- else
- d->sendCommand(cmd);
-}
-
-void QWSDisplay::requestRegion(int winId, const QString &surfaceKey,
- const QByteArray &surfaceData,
- const QRegion &region)
-{
- if (d->directServerConnection()) {
- qwsServer->d_func()->request_region(winId, surfaceKey,
- surfaceData, region);
- } else {
- QWSRegionCommand cmd;
- cmd.setData(winId, surfaceKey, surfaceData, region);
- d->sendSynchronousCommand(cmd);
- }
-}
-
-void QWSDisplay::repaintRegion(int winId, int windowFlags, bool opaque, QRegion r)
-{
- if (d->directServerConnection()) {
- qwsServer->d_func()->repaint_region(winId, windowFlags, opaque, r);
- } else {
- QVector<QRect> ra = r.rects();
-
- /*
- for (int i = 0; i < ra.size(); i++) {
- QRect r(ra[i]);
- qDebug("rect: %d %d %d %d", r.x(), r.y(), r.right(), r.bottom());
- }
- */
-
- QWSRepaintRegionCommand cmd;
- /* XXX QWSRegionCommand is padded out in a compiler dependent way.
- Zeroed out to avoid valgrind reporting uninitialized memory usage.
- */
-#ifdef QT_DEBUG
- memset(cmd.simpleDataPtr, 0, sizeof(cmd.simpleData)); //shut up Valgrind
-#endif
- cmd.simpleData.windowid = winId;
- cmd.simpleData.windowFlags = windowFlags;
- cmd.simpleData.opaque = opaque;
- cmd.simpleData.nrectangles = ra.count();
- cmd.setData(reinterpret_cast<const char *>(ra.constData()),
- ra.count() * sizeof(QRect), false);
-
- d->sendSynchronousCommand(cmd);
- }
-}
-
-
-void QWSDisplay::moveRegion(int winId, int dx, int dy)
-{
- QWSRegionMoveCommand cmd;
- cmd.simpleData.windowid = winId;
- cmd.simpleData.dx = dx;
- cmd.simpleData.dy = dy;
-
- if (d->directServerConnection()) {
- qwsServer->d_func()->move_region(&cmd);
- } else {
- d->sendSynchronousCommand(cmd);
- }
-// d->offsetPendingExpose(winId, QPoint(cmd.simpleData.dx, cmd.simpleData.dy));
-}
-
-void QWSDisplay::destroyRegion(int winId)
-{
- QWSRegionDestroyCommand cmd;
- cmd.simpleData.windowid = winId;
- if (d->directServerConnection()) {
- qwsServer->d_func()->destroy_region(&cmd);
- } else {
- d->sendCommand(cmd);
- }
-}
-
-#ifndef QT_NO_QWS_INPUTMETHODS
-
-void QWSDisplay::sendIMUpdate(int type, int winId, int widgetid)
-{
- QWSIMUpdateCommand cmd;
- cmd.simpleData.windowid = winId;
- cmd.simpleData.widgetid = widgetid;
-
- cmd.simpleData.type = type;
-
- if (d->directServerConnection()) {
- qwsServer->d_func()->im_update(&cmd);
- } else {
- d->sendCommand(cmd);
- }
-}
-
-void QWSDisplay::sendIMResponse(int winId, int property, const QVariant &result)
-{
- QWSIMResponseCommand cmd;
- cmd.simpleData.windowid = winId;
- cmd.simpleData.property = property;
-
- cmd.setResult(result);
-
- if (d->directServerConnection()) {
- qwsServer->d_func()->im_response(&cmd);
- } else {
- d->sendCommand(cmd);
- }
-}
-
-void QWSDisplay::resetIM()
-{
- sendIMUpdate(QWSInputMethod::Reset, -1, -1);
-}
-
-void QWSDisplay::sendIMMouseEvent(int index, bool isPress)
-{
- QWSIMMouseCommand cmd;
- cmd.simpleData.index = index;
- cmd.simpleData.state = isPress ? QWSServer::MousePress : QWSServer::MouseRelease;
- if (d->directServerConnection()) {
- qwsServer->d_func()->send_im_mouse(&cmd);
- } else {
- d->sendCommand(cmd);
- }
-}
-
-#endif
-
-int QWSDisplay::takeId()
-{
- return d->takeId();
-}
-
-bool QWSDisplay::initLock(const QString &filename, bool create)
-{
- if (!lock) {
- lock = new QLock(filename, 'd', create);
-
- if (!lock->isValid()) {
- delete lock;
- lock = 0;
- return false;
- }
- }
-
- return true;
-}
-
-void QWSDisplay::setSelectionOwner(int winId, const QTime &time)
-{
- QWSSetSelectionOwnerCommand cmd;
- cmd.simpleData.windowid = winId;
- cmd.simpleData.hour = time.hour();
- cmd.simpleData.minute = time.minute();
- cmd.simpleData.sec = time.second();
- cmd.simpleData.ms = time.msec();
- d->sendCommand(cmd);
-}
-
-void QWSDisplay::convertSelection(int winId, int selectionProperty, const QString &mimeTypes)
-{
-#ifdef QT_NO_QWS_PROPERTIES
- Q_UNUSED(mimeTypes);
-#else
- // ### we need the atom/property thingy like in X here
- addProperty(winId, QT_QWS_PROPERTY_CONVERTSELECTION);
- setProperty(winId, QT_QWS_PROPERTY_CONVERTSELECTION,
- int(QWSPropertyManager::PropReplace), mimeTypes.toLatin1());
-#endif
- QWSConvertSelectionCommand cmd;
- cmd.simpleData.requestor = winId;
- cmd.simpleData.selection = selectionProperty;
- cmd.simpleData.mimeTypes = QT_QWS_PROPERTY_CONVERTSELECTION;
- d->sendCommand(cmd);
-}
-
-void QWSDisplay::defineCursor(int id, const QBitmap &curs, const QBitmap &mask,
- int hotX, int hotY)
-{
- const QImage cursImg = curs.toImage().convertToFormat(QImage::Format_MonoLSB);
- const QImage maskImg = mask.toImage().convertToFormat(QImage::Format_MonoLSB);
-
- QWSDefineCursorCommand cmd;
- cmd.simpleData.width = curs.width();
- cmd.simpleData.height = curs.height();
- cmd.simpleData.hotX = hotX;
- cmd.simpleData.hotY = hotY;
- cmd.simpleData.id = id;
-
-
- // must copy each scanline since there might be gaps between them
- const int height = curs.height();
- const int width = curs.width();
- const int dst_bpl = (width + 7) / 8;
-
- int dataLen = dst_bpl * height;
- uchar *data = new uchar[dataLen*2];
- uchar *dst = data;
-
- int src_bpl = cursImg.bytesPerLine();
- const uchar *cursSrc = cursImg.bits();
- for (int i = 0; i < height; ++i) {
- memcpy(dst, cursSrc + i*src_bpl, dst_bpl);
- dst += dst_bpl;
- }
-
- src_bpl = maskImg.bytesPerLine();
- const uchar *maskSrc = maskImg.bits();
- for (int i = 0; i < height; ++i) {
- memcpy(dst, maskSrc + i*src_bpl, dst_bpl);
- dst += dst_bpl;
- }
-
- cmd.setData(reinterpret_cast<char*>(data), dataLen*2);
- delete [] data;
- d->sendCommand(cmd);
-}
-
-void QWSDisplay::destroyCursor(int id)
-{
- QWSDefineCursorCommand cmd;
- cmd.simpleData.width = 0;
- cmd.simpleData.height = 0;
- cmd.simpleData.hotX = 0;
- cmd.simpleData.hotY = 0;
- cmd.simpleData.id = id;
- cmd.setData(0, 0);
-
- d->sendCommand(cmd);
-}
-
-#ifndef QT_NO_SOUND
-void QWSDisplay::playSoundFile(const QString& f)
-{
- QWSPlaySoundCommand cmd;
- cmd.setFileName(f);
- d->sendCommand(cmd);
-}
-#endif
-
-#ifndef QT_NO_COP
-void QWSDisplay::registerChannel(const QString& channel)
-{
- QWSQCopRegisterChannelCommand reg;
- reg.setChannel(channel);
- qt_fbdpy->d->sendCommand(reg);
-}
-
-void QWSDisplay::sendMessage(const QString &channel, const QString &msg,
- const QByteArray &data)
-{
- QWSQCopSendCommand com;
- com.setMessage(channel, msg, data);
- qt_fbdpy->d->sendCommand(com);
-}
-
-void QWSDisplay::flushCommands()
-{
- qt_fbdpy->d->flushCommands();
-}
-
-/*
- caller deletes result
-*/
-QWSQCopMessageEvent* QWSDisplay::waitForQCopResponse()
-{
- qt_fbdpy->d->waitForQCopResponse();
- QWSQCopMessageEvent *e = static_cast<QWSQCopMessageEvent*>(qt_fbdpy->d->dequeue());
- Q_ASSERT(e->type == QWSEvent::QCopMessage);
- return e;
-}
-#endif
-
-void QWSDisplay::sendFontCommand(int type, const QByteArray &fontName)
-{
- QWSFontCommand cmd;
- cmd.simpleData.type = type;
- cmd.setFontName(fontName);
- d->sendCommand(cmd);
-}
-
-void QWSDisplay::setWindowCaption(QWidget *w, const QString &c)
-{
- if (w->isWindow()) {
- nameRegion(w->internalWinId(), w->objectName(), c);
- static_cast<QETWidget *>(w)->repaintDecoration(qApp->desktop()->rect(), true);
- }
-}
-
-void QWSDisplay::selectCursor(QWidget *w, unsigned int cursId)
-{
- if (cursId != qt_last_cursor)
- {
- QWidget *top = w->window();
- qt_last_cursor = cursId;
- QWSSelectCursorCommand cmd;
- cmd.simpleData.windowid = top->internalWinId();
- cmd.simpleData.id = cursId;
- d->sendCommand(cmd);
- d->flush();
- }
-}
-
-void QWSDisplay::setCursorPosition(int x, int y)
-{
- QWSPositionCursorCommand cmd;
- cmd.simpleData.newX = x;
- cmd.simpleData.newY = y;
- d->sendCommand(cmd);
- d->flush();
-}
-
-void QWSDisplay::grabMouse(QWidget *w, bool grab)
-{
- QWidget *top = w->window();
- QWSGrabMouseCommand cmd;
-#ifdef QT_DEBUG
- memset(cmd.simpleDataPtr, 0, sizeof(cmd.simpleData)); //shut up Valgrind
-#endif
- cmd.simpleData.windowid = top->winId();
- cmd.simpleData.grab = grab;
- d->sendCommand(cmd);
- d->flush();
-}
-
-void QWSDisplay::grabKeyboard(QWidget *w, bool grab)
-{
- QWidget *top = w->window();
- QWSGrabKeyboardCommand cmd;
-#ifdef QT_DEBUG
- memset(cmd.simpleDataPtr, 0, sizeof(cmd.simpleData)); //shut up Valgrind
-#endif
- cmd.simpleData.windowid = top->winId();
- cmd.simpleData.grab = grab;
- d->sendCommand(cmd);
- d->flush();
-}
-
-QList<QWSWindowInfo> QWSDisplay::windowList()
-{
- QList<QWSWindowInfo> ret;
- if(d->directServerConnection()) {
- QList<QWSInternalWindowInfo*> * qin=QWSServer::windowList();
- for (int i = 0; i < qin->count(); ++i) {
- QWSInternalWindowInfo * qwi = qin->at(i);
- QWSWindowInfo tmp;
- tmp.winid = qwi->winid;
- tmp.clientid = qwi->clientid;
- tmp.name = QString(qwi->name);
- ret.append(tmp);
- }
- qDeleteAll(*qin);
- delete qin;
- }
- return ret;
-}
-
-int QWSDisplay::windowAt(const QPoint &p)
-{
- //### currently only implemented for the server process
- int ret = 0;
- if(d->directServerConnection()) {
- QWSWindow *win = qwsServer->windowAt(p);
- if (win)
- return win->winId();
- }
- return ret;
-}
-
-void QWSDisplay::setRawMouseEventFilter(void (*filter)(QWSMouseEvent *))
-{
- if (qt_fbdpy)
- qt_fbdpy->d->setMouseFilter(filter);
-}
-
-/*!
- \relates QScreen
-
- Here it is. \a transformation and \a screenNo
- */
-void QWSDisplay::setTransformation(int transformation, int screenNo)
-{
- QWSScreenTransformCommand cmd;
- cmd.setTransformation(screenNo, transformation);
- QWSDisplay::instance()->d->sendCommand(cmd);
-}
-
-static bool qt_try_modal(QWidget *, QWSEvent *);
-
-/*****************************************************************************
- qt_init() - initializes Qt/FB
- *****************************************************************************/
-
-static void qt_set_qws_resources()
-
-{
- if (QApplication::desktopSettingsAware())
- QApplicationPrivate::qws_apply_settings();
-
- if (appFont)
- QApplication::setFont(QFont(QString::fromLocal8Bit(appFont)));
-
- if (appBGCol || appBTNCol || appFGCol) {
- (void) QApplication::style(); // trigger creation of application style and system palettes
- QColor btn;
- QColor bg;
- QColor fg;
- if (appBGCol)
- bg = QColor(appBGCol);
- else
- bg = QApplicationPrivate::sys_pal->color(QPalette::Window);
- if (appFGCol)
- fg = QColor(appFGCol);
- else
- fg = QApplicationPrivate::sys_pal->color(QPalette::WindowText);
- if (appBTNCol)
- btn = QColor(appBTNCol);
- else
- btn = QApplicationPrivate::sys_pal->color(QPalette::Button);
-
- int h,s,v;
- fg.getHsv(&h,&s,&v);
- QColor base = Qt::white;
- bool bright_mode = false;
- if (v >= 255 - 50) {
- base = btn.darker(150);
- bright_mode = true;
- }
-
- QPalette pal(fg, btn, btn.lighter(), btn.darker(), btn.darker(150), fg, Qt::white, base, bg);
- if (bright_mode) {
- pal.setColor(QPalette::HighlightedText, base);
- pal.setColor(QPalette::Highlight, Qt::white);
- } else {
- pal.setColor(QPalette::HighlightedText, Qt::white);
- pal.setColor(QPalette::Highlight, Qt::darkBlue);
- }
- QColor disabled((fg.red() + btn.red()) / 2,
- (fg.green() + btn.green())/ 2,
- (fg.blue() + btn.blue()) / 2);
- pal.setColorGroup(QPalette::Disabled, disabled, btn, btn.lighter(125),
- btn.darker(), btn.darker(150), disabled, Qt::white, Qt::white, bg);
- if (bright_mode) {
- pal.setColor(QPalette::Disabled, QPalette::HighlightedText, base);
- pal.setColor(QPalette::Disabled, QPalette::Highlight, Qt::white);
- } else {
- pal.setColor(QPalette::Disabled, QPalette::HighlightedText, Qt::white);
- pal.setColor(QPalette::Disabled, QPalette::Highlight, Qt::darkBlue);
- }
- QApplicationPrivate::setSystemPalette(pal);
-
- }
-}
-
-void QApplicationPrivate::initializeWidgetPaletteHash()
-{
-}
-
-/*! \internal
- apply the settings to the application
-*/
-bool QApplicationPrivate::qws_apply_settings()
-{
-#ifndef QT_NO_SETTINGS
- QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
- settings.beginGroup(QLatin1String("Qt"));
-
- QStringList strlist;
- int i;
- QPalette pal(Qt::black);
- int groupCount = 0;
- strlist = settings.value(QLatin1String("Palette/active")).toStringList();
- if (strlist.count() == QPalette::NColorRoles) {
- ++groupCount;
- for (i = 0; i < QPalette::NColorRoles; i++)
- pal.setColor(QPalette::Active, (QPalette::ColorRole) i,
- QColor(strlist[i]));
- }
- strlist = settings.value(QLatin1String("Palette/inactive")).toStringList();
- if (strlist.count() == QPalette::NColorRoles) {
- ++groupCount;
- for (i = 0; i < QPalette::NColorRoles; i++)
- pal.setColor(QPalette::Inactive, (QPalette::ColorRole) i,
- QColor(strlist[i]));
- }
- strlist = settings.value(QLatin1String("Palette/disabled")).toStringList();
- if (strlist.count() == QPalette::NColorRoles) {
- ++groupCount;
- for (i = 0; i < QPalette::NColorRoles; i++)
- pal.setColor(QPalette::Disabled, (QPalette::ColorRole) i,
- QColor(strlist[i]));
- }
-
-
- if (groupCount == QPalette::NColorGroups)
- QApplicationPrivate::setSystemPalette(pal);
-
- QString str = settings.value(QLatin1String("font")).toString();
- if (!str.isEmpty()) {
- QFont font(QApplication::font());
- font.fromString(str);
- QApplicationPrivate::setSystemFont(font);
- }
-
- // read library (ie. plugin) path list
- QString libpathkey =
- QString::fromLatin1("%1.%2/libraryPath")
- .arg(QT_VERSION >> 16)
- .arg((QT_VERSION & 0xff00) >> 8);
- QStringList pathlist = settings.value(libpathkey).toString().split(QLatin1Char(':'));
-#ifndef QT_NO_LIBRARY
- if (! pathlist.isEmpty()) {
- QStringList::ConstIterator it = pathlist.constBegin();
- while (it != pathlist.constEnd())
- QApplication::addLibraryPath(*it++);
- }
-#endif
-
- // read new QStyle
- QString stylename = settings.value(QLatin1String("style")).toString();
- if (QCoreApplication::startingUp()) {
- if (!stylename.isEmpty() && QApplicationPrivate::styleOverride.isNull())
- QApplicationPrivate::styleOverride = stylename;
- } else {
- QApplication::setStyle(stylename);
- }
-
- int num =
- settings.value(QLatin1String("doubleClickInterval"),
- QApplication::doubleClickInterval()).toInt();
- QApplication::setDoubleClickInterval(num);
-
- num =
- settings.value(QLatin1String("cursorFlashTime"),
- QApplication::cursorFlashTime()).toInt();
- QApplication::setCursorFlashTime(num);
-
-#ifndef QT_NO_WHEELEVENT
- num =
- settings.value(QLatin1String("wheelScrollLines"),
- QApplication::wheelScrollLines()).toInt();
- QApplication::setWheelScrollLines(num);
-#endif
-
- QString colorspec = settings.value(QLatin1String("colorSpec"),
- QVariant(QLatin1String("default"))).toString();
- if (colorspec == QLatin1String("normal"))
- QApplication::setColorSpec(QApplication::NormalColor);
- else if (colorspec == QLatin1String("custom"))
- QApplication::setColorSpec(QApplication::CustomColor);
- else if (colorspec == QLatin1String("many"))
- QApplication::setColorSpec(QApplication::ManyColor);
- else if (colorspec != QLatin1String("default"))
- colorspec = QLatin1String("default");
-
-#ifndef QT_NO_TEXTCODEC
- QString defaultcodec = settings.value(QLatin1String("defaultCodec"),
- QVariant(QLatin1String("none"))).toString();
- if (defaultcodec != QLatin1String("none")) {
- QTextCodec *codec = QTextCodec::codecForName(defaultcodec.toLatin1());
- if (codec)
- QTextCodec::setCodecForTr(codec);
- }
-#endif
-
- int w = settings.value(QLatin1String("globalStrut/width")).toInt();
- int h = settings.value(QLatin1String("globalStrut/height")).toInt();
- QSize strut(w, h);
- if (strut.isValid())
- QApplication::setGlobalStrut(strut);
-
- QStringList effects = settings.value(QLatin1String("GUIEffects")).toStringList();
- QApplication::setEffectEnabled(Qt::UI_General,
- effects.contains(QLatin1String("general")));
- QApplication::setEffectEnabled(Qt::UI_AnimateMenu,
- effects.contains(QLatin1String("animatemenu")));
- QApplication::setEffectEnabled(Qt::UI_FadeMenu,
- effects.contains(QLatin1String("fademenu")));
- QApplication::setEffectEnabled(Qt::UI_AnimateCombo,
- effects.contains(QLatin1String("animatecombo")));
- QApplication::setEffectEnabled(Qt::UI_AnimateTooltip,
- effects.contains(QLatin1String("animatetooltip")));
- QApplication::setEffectEnabled(Qt::UI_FadeTooltip,
- effects.contains(QLatin1String("fadetooltip")));
- QApplication::setEffectEnabled(Qt::UI_AnimateToolBox,
- effects.contains(QLatin1String("animatetoolbox")));
-
- settings.beginGroup(QLatin1String("Font Substitutions"));
- QStringList fontsubs = settings.childKeys();
- if (!fontsubs.isEmpty()) {
- QStringList::Iterator it = fontsubs.begin();
- for (; it != fontsubs.end(); ++it) {
- QString fam = *it;
- QStringList subs = settings.value(fam).toStringList();
- QFont::insertSubstitutions(fam, subs);
- }
- }
- settings.endGroup();
-
- settings.endGroup(); // Qt
-
- settings.beginGroup(QLatin1String("QWS Font Fallbacks"));
- if (!settings.childKeys().isEmpty()) {
- // from qfontdatabase_qws.cpp
- extern void qt_applyFontDatabaseSettings(const QSettings &);
- qt_applyFontDatabaseSettings(settings);
- }
- settings.endGroup();
-
- return true;
-#else
- return false;
-#endif // QT_NO_SETTINGS
-}
-
-
-
-static void init_display()
-{
- if (qt_fbdpy) return; // workaround server==client case
-
- // Connect to FB server
- qt_fbdpy = new QWSDisplay();
-
- // Get display parameters
- // Set paintdevice parameters
- // XXX initial info sent from server
- // Misc. initialization
-
- QColormap::initialize();
- QFont::initialize();
-#ifndef QT_NO_CURSOR
- QCursorData::initialize();
-#endif
-
- qApp->setObjectName(appName);
-
- if (!QApplicationPrivate::sys_font) {
-#ifdef QT_NO_FREETYPE
- QFont f = QFont(QLatin1String("helvetica"), 10);
-#else
- QFont f = QFont(QLatin1String("DejaVu Sans"), 12);
-#endif
- QApplicationPrivate::setSystemFont(f);
- }
- qt_set_qws_resources();
-}
-
-void qt_init_display()
-{
- qt_is_gui_used = true;
- qws_single_process = true;
- init_display();
-}
-
-static bool read_bool_env_var(const char *var, bool defaultvalue)
-{
- // returns true if env variable is set to non-zero
- // returns false if env var is set to zero
- // returns defaultvalue if env var not set
- char *x = ::getenv(var);
- return (x && *x) ? (strcmp(x,"0") != 0) : defaultvalue;
-}
-
-static int read_int_env_var(const char *var, int defaultvalue)
-{
- bool ok;
- int r = qgetenv(var).toInt(&ok);
- return ok ? r : defaultvalue;
-}
-
-void qt_init(QApplicationPrivate *priv, int type)
-{
-#ifdef QT_NO_QWS_MULTIPROCESS
- if (type == QApplication::GuiClient)
- type = QApplication::GuiServer;
-#endif
- if (type == QApplication::GuiServer)
- qt_is_gui_used = false; //we'll turn it on in a second
- qws_sw_cursor = read_bool_env_var("QWS_SW_CURSOR",qws_sw_cursor);
- qws_screen_is_interlaced = read_bool_env_var("QWS_INTERLACE",false);
-
- const char *display = ::getenv("QWS_DISPLAY");
- if (display)
- qws_display_spec = display; // since we setenv later!
-
- //qws_savefonts = qgetenv("QWS_SAVEFONTS") != 0;
- //qws_shared_memory = qgetenv("QWS_NOSHARED") == 0;
-
- mouse_double_click_distance = read_int_env_var("QWS_DBLCLICK_DISTANCE", 5);
-
- priv->inputContext = 0;
-
- int flags = 0;
- char *p;
- int argc = priv->argc;
- char **argv = priv->argv;
- int j;
-
- // Set application name
-
- if (argv && *argv) { //apparently, we allow people to pass 0 on the other platforms
- p = strrchr(argv[0], '/');
- appName = QString::fromLocal8Bit(p ? p + 1 : argv[0]);
- }
-
- // Get command line params
-
- j = argc ? 1 : 0;
- QString decoration;
- for (int i=1; i<argc; i++) {
- if (argv[i] && *argv[i] != '-') {
- argv[j++] = argv[i];
- continue;
- }
- QByteArray arg = argv[i];
- if (arg == "-fn" || arg == "-font") {
- if (++i < argc)
- appFont = argv[i];
- } else if (arg == "-bg" || arg == "-background") {
- if (++i < argc)
- appBGCol = argv[i];
- } else if (arg == "-btn" || arg == "-button") {
- if (++i < argc)
- appBTNCol = argv[i];
- } else if (arg == "-fg" || arg == "-foreground") {
- if (++i < argc)
- appFGCol = argv[i];
- } else if (arg == "-name") {
- if (++i < argc)
- appName = QString::fromLocal8Bit(argv[i]);
- } else if (arg == "-title") {
- if (++i < argc)
- mwTitle = argv[i];
- } else if (arg == "-geometry") {
- if (++i < argc)
- mwGeometry = argv[i];
- } else if (arg == "-shared") {
- qws_shared_memory = true;
- } else if (arg == "-noshared") {
- qws_shared_memory = false;
- } else if (arg == "-savefonts") {
- qws_savefonts = true;
- } else if (arg == "-nosavefonts") {
- qws_savefonts = false;
- } else if (arg == "-swcursor") {
- qws_sw_cursor = true;
- } else if (arg == "-noswcursor") {
- qws_sw_cursor = false;
- } else if (arg == "-keyboard") {
- flags &= ~QWSServer::DisableKeyboard;
- } else if (arg == "-nokeyboard") {
- flags |= QWSServer::DisableKeyboard;
- } else if (arg == "-mouse") {
- flags &= ~QWSServer::DisableMouse;
- } else if (arg == "-nomouse") {
- flags |= QWSServer::DisableMouse;
- } else if (arg == "-qws") {
- type = QApplication::GuiServer;
- } else if (arg == "-interlaced") {
- qws_screen_is_interlaced = true;
- } else if (arg == "-display") {
- if (++i < argc)
- qws_display_spec = argv[i];
- } else if (arg == "-decoration") {
- if (++i < argc)
- decoration = QString::fromLocal8Bit(argv[i]);
- } else {
- argv[j++] = argv[i];
- }
- }
- if(j < priv->argc) {
- priv->argv[j] = 0;
- priv->argc = j;
- }
-
- mouseInWidget = new QPointer<QWidget>;
-
- const QString disp = QString::fromLatin1(qws_display_spec);
- QRegExp regexp(QLatin1String(":(\\d+)$"));
- if (regexp.lastIndexIn(disp) != -1) {
- const QString capture = regexp.cap(1);
- bool ok = false;
- int id = capture.toInt(&ok);
- if (ok)
- qws_display_id = id;
- }
-
- if (type == QApplication::GuiServer) {
- qt_appType = QApplication::Type(type);
- qws_single_process = true;
- QWSServer::startup(flags);
- if (!display) // if not already set
- qputenv("QWS_DISPLAY", qws_display_spec);
- }
-
- if(qt_is_gui_used) {
- init_display();
-#ifndef QT_NO_QWS_MANAGER
- if (decoration.isEmpty() && !qws_decoration) {
- const QStringList keys = QDecorationFactory::keys();
- if (!keys.isEmpty())
- decoration = keys.first();
- }
- if (!decoration.isEmpty())
- qws_decoration = QApplication::qwsSetDecoration(decoration);
-#endif // QT_NO_QWS_MANAGER
-#ifndef QT_NO_QWS_INPUTMETHODS
- qApp->setInputContext(new QWSInputContext(qApp));
-#endif
- }
-
-/*### convert interlace style
- if (qws_screen_is_interlaced)
- QApplication::setStyle(new QInterlaceStyle);
-*/
-}
-
-/*****************************************************************************
- qt_cleanup() - cleans up when the application is finished
- *****************************************************************************/
-
-void qt_cleanup()
-{
- QPixmapCache::clear();
-#ifndef QT_NO_CURSOR
- QCursorData::cleanup();
-#endif
- QFont::cleanup();
- QColormap::cleanup();
-
- if (qws_single_process) {
- QWSServer::closedown();
- }
-
- qDeleteAll(outgoing);
- outgoing.clear();
- qDeleteAll(incoming);
- incoming.clear();
-
- if (qt_is_gui_used) {
- delete qt_fbdpy;
- }
- qt_fbdpy = 0;
-
-#ifndef QT_NO_QWS_MANAGER
- delete qws_decoration;
- qws_decoration = 0;
-#endif
-
- delete mouseInWidget;
- mouseInWidget = 0;
-
-#if !defined(QT_NO_IM)
- delete QApplicationPrivate::inputContext;
- QApplicationPrivate::inputContext = 0;
-#endif
-}
-
-
-/*****************************************************************************
- Platform specific global and internal functions
- *****************************************************************************/
-
-QString QApplicationPrivate::appName() const // get application name
-{
- return QT_PREPEND_NAMESPACE(appName);
-}
-
-/*****************************************************************************
- Platform specific QApplication members
- *****************************************************************************/
-
-#define NoValue 0x0000
-#define XValue 0x0001
-#define YValue 0x0002
-#define WidthValue 0x0004
-#define HeightValue 0x0008
-#define AllValues 0x000F
-#define XNegative 0x0010
-#define YNegative 0x0020
-
-/* Copyright notice for ReadInteger and parseGeometry
-
-Copyright (c) 1985, 1986, 1987 X Consortium
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice shall be included
-in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of the X Consortium shall
-not be used in advertising or otherwise to promote the sale, use or
-other dealings in this Software without prior written authorization
-from the X Consortium.
-
-*/
-/*
- * XParseGeometry parses strings of the form
- * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
- * width, height, xoffset, and yoffset are unsigned integers.
- * Example: "=80x24+300-49"
- * The equal sign is optional.
- * It returns a bitmask that indicates which of the four values
- * were actually found in the string. For each value found,
- * the corresponding argument is updated; for each value
- * not found, the corresponding argument is left unchanged.
- */
-
-static int
-ReadInteger(char *string, char **NextString)
-{
- register int Result = 0;
- int Sign = 1;
-
- if (*string == '+')
- string++;
- else if (*string == '-')
- {
- string++;
- Sign = -1;
- }
- for (; (*string >= '0') && (*string <= '9'); string++)
- {
- Result = (Result * 10) + (*string - '0');
- }
- *NextString = string;
- if (Sign >= 0)
- return Result;
- else
- return -Result;
-}
-
-static int parseGeometry(const char* string,
- int* x, int* y, int* width, int* height)
-{
- int mask = NoValue;
- register char *strind;
- unsigned int tempWidth=0, tempHeight=0;
- int tempX=0, tempY=0;
- char *nextCharacter;
-
- if (!string || (*string == '\0')) return mask;
- if (*string == '=')
- string++; /* ignore possible '=' at beg of geometry spec */
-
- strind = const_cast<char *>(string);
- if (*strind != '+' && *strind != '-' && *strind != 'x') {
- tempWidth = ReadInteger(strind, &nextCharacter);
- if (strind == nextCharacter)
- return 0;
- strind = nextCharacter;
- mask |= WidthValue;
- }
-
- if (*strind == 'x' || *strind == 'X') {
- strind++;
- tempHeight = ReadInteger(strind, &nextCharacter);
- if (strind == nextCharacter)
- return 0;
- strind = nextCharacter;
- mask |= HeightValue;
- }
-
- if ((*strind == '+') || (*strind == '-')) {
- if (*strind == '-') {
- strind++;
- tempX = -ReadInteger(strind, &nextCharacter);
- if (strind == nextCharacter)
- return 0;
- strind = nextCharacter;
- mask |= XNegative;
-
- }
- else
- { strind++;
- tempX = ReadInteger(strind, &nextCharacter);
- if (strind == nextCharacter)
- return 0;
- strind = nextCharacter;
- }
- mask |= XValue;
- if ((*strind == '+') || (*strind == '-')) {
- if (*strind == '-') {
- strind++;
- tempY = -ReadInteger(strind, &nextCharacter);
- if (strind == nextCharacter)
- return 0;
- strind = nextCharacter;
- mask |= YNegative;
-
- }
- else
- {
- strind++;
- tempY = ReadInteger(strind, &nextCharacter);
- if (strind == nextCharacter)
- return 0;
- strind = nextCharacter;
- }
- mask |= YValue;
- }
- }
-
- /* If strind isn't at the end of the string then it's an invalid
- geometry specification. */
-
- if (*strind != '\0') return 0;
-
- if (mask & XValue)
- *x = tempX;
- if (mask & YValue)
- *y = tempY;
- if (mask & WidthValue)
- *width = tempWidth;
- if (mask & HeightValue)
- *height = tempHeight;
- return mask;
-}
-
-#ifdef QT3_SUPPORT
-void QApplication::setMainWidget(QWidget *mainWidget)
-{
- QApplicationPrivate::main_widget = mainWidget;
- if (QApplicationPrivate::main_widget) // give WM command line
- QApplicationPrivate::applyQWSSpecificCommandLineArguments(QApplicationPrivate::main_widget);
-}
-#endif
-
-void QApplicationPrivate::applyQWSSpecificCommandLineArguments(QWidget *main_widget)
-{
- static bool beenHereDoneThat = false;
- if (beenHereDoneThat)
- return;
- beenHereDoneThat = true;
- if (qApp->windowIcon().isNull() && main_widget->testAttribute(Qt::WA_SetWindowIcon))
- qApp->setWindowIcon(main_widget->windowIcon());
- if (mwTitle) // && main_widget->windowTitle().isEmpty())
- main_widget->setWindowTitle(QString::fromLocal8Bit(mwTitle));
- if (mwGeometry) { // parse geometry
- int x = 0;
- int y = 0;
- int w = 0;
- int h = 0;
- int m = parseGeometry(mwGeometry, &x, &y, &w, &h);
- QSize minSize = main_widget->minimumSize();
- QSize maxSize = main_widget->maximumSize();
- if ((m & XValue) == 0)
- x = main_widget->geometry().x();
- if ((m & YValue) == 0)
- y = main_widget->geometry().y();
- if ((m & WidthValue) == 0)
- w = main_widget->width();
- if ((m & HeightValue) == 0)
- h = main_widget->height();
- w = qMin(w,maxSize.width());
- h = qMin(h,maxSize.height());
- w = qMax(w,minSize.width());
- h = qMax(h,minSize.height());
- if ((m & XNegative)) {
- x = qApp->desktop()->width() + x - w;
- x -= (main_widget->frameGeometry().width() - main_widget->width()) / 2;
- } else {
- x += (main_widget->geometry().x() - main_widget->x());
- }
- if ((m & YNegative)) {
- y = qApp->desktop()->height() + y - h;
- } else {
- y += (main_widget->geometry().y() - main_widget->y());
- }
-
- main_widget->setGeometry(x, y, w, h);
- }
-}
-
-/*****************************************************************************
- QApplication cursor stack
- *****************************************************************************/
-#ifndef QT_NO_CURSOR
-void QApplication::setOverrideCursor(const QCursor &cursor)
-{
- qApp->d_func()->cursor_list.prepend(cursor);
-
- QWidget *w = QWidget::mouseGrabber();
- if (!w && qt_last_x)
- w = topLevelAt(*qt_last_x, *qt_last_y);
- if (!w)
- w = desktop();
- QPaintDevice::qwsDisplay()->selectCursor(w, qApp->d_func()->cursor_list.first().handle());
-}
-
-void QApplication::restoreOverrideCursor()
-{
- if (qApp->d_func()->cursor_list.isEmpty())
- return;
- qApp->d_func()->cursor_list.removeFirst();
-
- QWidget *w = QWidget::mouseGrabber();
- if (!w && qt_last_x)
- w = topLevelAt(*qt_last_x, *qt_last_y);
- if (!w)
- w = desktop();
-
- int cursor_handle = Qt::ArrowCursor;
- if (qApp->d_func()->cursor_list.isEmpty()) {
- qws_overrideCursor = false;
- QWidget *upw = QApplication::widgetAt(*qt_last_x, *qt_last_y);
- if (upw)
- cursor_handle = upw->cursor().handle();
- } else {
- cursor_handle = qApp->d_func()->cursor_list.first().handle();
- }
- QPaintDevice::qwsDisplay()->selectCursor(w, cursor_handle);
-}
-#endif// QT_NO_CURSOR
-
-
-
-/*****************************************************************************
- Routines to find a Qt widget from a screen position
- *****************************************************************************/
-
-/*!
- \internal
-*/
-QWidget *QApplicationPrivate::findWidget(const QObjectList& list,
- const QPoint &pos, bool rec)
-{
- QWidget *w;
-
- for (int i = list.size()-1; i >= 0; --i) {
- if (list.at(i)->isWidgetType()) {
- w = static_cast<QWidget*>(list.at(i));
- if (w->isVisible() && !w->testAttribute(Qt::WA_TransparentForMouseEvents) && w->geometry().contains(pos)
- && (!w->d_func()->extra || w->d_func()->extra->mask.isEmpty() || w->d_func()->extra->mask.contains(pos - w->geometry().topLeft()) )) {
- if (!rec)
- return w;
- QWidget *c = w->childAt(w->mapFromParent(pos));
- return c ? c : w;
- }
- }
- }
- return 0;
-}
-
-
-QWidget *QApplication::topLevelAt(const QPoint &pos)
-{
- //### QWSDisplay::windowAt() is currently only implemented in the server process
- int winId = QPaintDevice::qwsDisplay()->windowAt(pos);
- if (winId !=0)
- return QWidget::find(winId);
-
-#if 1
- // fallback implementation for client processes
-//### This is slightly wrong: we have no guarantee that the list is in
-//### stacking order, so if the topmost window is transparent, we may
-//### return the wrong widget
-
- QWidgetList list = topLevelWidgets();
- for (int i = list.size()-1; i >= 0; --i) {
- QWidget *w = list[i];
- if (w != QApplication::desktop() &&
- w->isVisible() && w->d_func()->localAllocatedRegion().contains(w->mapFromParent(pos))
- )
- return w;
- }
-#endif
- return 0;
-}
-
-void QApplication::beep()
-{
-}
-
-void QApplication::alert(QWidget *, int)
-{
-}
-
-int QApplication::qwsProcessEvent(QWSEvent* event)
-{
- Q_D(QApplication);
- QScopedLoopLevelCounter loopLevelCounter(d->threadData);
- int oldstate = -1;
- bool isMove = false;
- if (event->type == QWSEvent::Mouse) {
- QWSMouseEvent::SimpleData &mouse = event->asMouse()->simpleData;
- isMove = mouse_x_root != mouse.x_root || mouse_y_root != mouse.y_root;
- oldstate = mouse_state;
- mouse_x_root = mouse.x_root;
- mouse_y_root = mouse.y_root;
- mouse_state = mouse.state;
- }
-
- long unused;
- if (filterEvent(event, &unused)) // send through app filter
- return 1;
-
- if (qwsEventFilter(event)) // send through app filter
- return 1;
-
-
-#ifndef QT_NO_QWS_PROPERTIES
- if (event->type == QWSEvent::PropertyNotify) {
- QWSPropertyNotifyEvent *e = static_cast<QWSPropertyNotifyEvent*>(event);
- if (e->simpleData.property == 424242) { // Clipboard
-#ifndef QT_NO_CLIPBOARD
- if (qt_clipboard) {
- QClipboardEvent e(reinterpret_cast<QEventPrivate*>(event));
- QApplication::sendEvent(qt_clipboard, &e);
- }
-#endif
- }
- }
-#endif //QT_NO_QWS_PROPERTIES
-#ifndef QT_NO_COP
- else if (event->type == QWSEvent::QCopMessage) {
- QWSQCopMessageEvent *e = static_cast<QWSQCopMessageEvent*>(event);
- QCopChannel::sendLocally(QLatin1String(e->channel), QLatin1String(e->message), e->data);
- return 0;
- }
-#endif
-#if !defined(QT_NO_QWS_QPF2)
- else if (event->type == QWSEvent::Font) {
- QWSFontEvent *e = static_cast<QWSFontEvent *>(event);
- if (e->simpleData.type == QWSFontEvent::FontRemoved) {
- QFontCache::instance()->removeEngineForFont(e->fontName);
- }
- }
-#endif
-
- QPointer<QETWidget> widget = static_cast<QETWidget*>(QWidget::find(WId(event->window())));
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- if (!widget) { // XXX: hw: hack for accessing subsurfaces
- extern QWSWindowSurface* qt_findWindowSurface(int);
- QWSWindowSurface *s = qt_findWindowSurface(event->window());
- if (s)
- widget = static_cast<QETWidget*>(s->window());
- }
-#endif
-
-#ifndef QT_NO_DIRECTPAINTER
- if (!widget && d->directPainters) {
- QDirectPainter *dp = d->directPainters->value(WId(event->window()));
- if (dp == 0) {
- } else if (event->type == QWSEvent::Region) {
- QWSRegionEvent *e = static_cast<QWSRegionEvent*>(event);
- QRegion reg;
- reg.setRects(e->rectangles, e->simpleData.nrectangles);
- qt_directpainter_region(dp, reg, e->simpleData.type);
- return 1;
-#ifndef QT_NO_QWSEMBEDWIDGET
- } else if (event->type == QWSEvent::Embed) {
- QWSEmbedEvent *e = static_cast<QWSEmbedEvent*>(event);
- qt_directpainter_embedevent(dp, e);
- return 1;
- #endif // QT_NO_QWSEMBEDWIDGET
- }
- }
-#endif // QT_NO_DIRECTPAINTER
-
-#ifndef QT_NO_QWS_MANAGER
- if (d->last_manager && event->type == QWSEvent::Mouse) {
- QPoint pos(event->asMouse()->simpleData.x_root, event->asMouse()->simpleData.y_root);
- if (!d->last_manager->cachedRegion().contains(pos)) {
- // MouseEvent not yet delivered, so QCursor::pos() is not yet updated, sending 2 x pos
- QMouseEvent outside(QEvent::MouseMove, pos, pos, Qt::NoButton, 0, 0);
- QApplication::sendSpontaneousEvent(d->last_manager, &outside);
- d->last_manager = 0;
- qt_last_cursor = 0xffffffff; //decoration is like another window; must redo cursor
- }
- }
-#endif // QT_NO_QWS_MANAGER
-
- QETWidget *keywidget=0;
- bool grabbed=false;
- if (event->type==QWSEvent::Key || event->type == QWSEvent::IMEvent || event->type == QWSEvent::IMQuery) {
- keywidget = static_cast<QETWidget*>(QWidget::keyboardGrabber());
- if (keywidget) {
- grabbed = true;
- } else {
- if (QWidget *popup = QApplication::activePopupWidget()) {
- if (popup->focusWidget())
- keywidget = static_cast<QETWidget*>(popup->focusWidget());
- else
- keywidget = static_cast<QETWidget*>(popup);
- } else if (QApplicationPrivate::focus_widget && QApplicationPrivate::focus_widget->isVisible())
- keywidget = static_cast<QETWidget*>(QApplicationPrivate::focus_widget);
- else if (widget)
- keywidget = static_cast<QETWidget*>(widget->window());
- }
- } else if (event->type==QWSEvent::MaxWindowRect) {
- QRect r = static_cast<QWSMaxWindowRectEvent*>(event)->simpleData.rect;
- setMaxWindowRect(r);
- return 0;
-#ifndef QT_NO_QWS_DYNAMICSCREENTRANSFORMATION
- } else if (event->type == QWSEvent::ScreenTransformation) {
- QWSScreenTransformationEvent *pe = static_cast<QWSScreenTransformationEvent*>(event);
- setScreenTransformation(pe->simpleData.screen,
- pe->simpleData.transformation);
- return 0;
-#endif
- } else if (widget && event->type==QWSEvent::Mouse) {
- // The mouse event is to one of my top-level widgets
- // which one?
- const int btnMask = Qt::LeftButton | Qt::RightButton | Qt::MidButton;
- QPoint p(event->asMouse()->simpleData.x_root,
- event->asMouse()->simpleData.y_root);
- int mouseButtonState = event->asMouse()->simpleData.state & btnMask;
- static int btnstate = 0;
-
- QETWidget *w = static_cast<QETWidget*>(QWidget::mouseGrabber());
- if (w && !mouseButtonState && qt_pressGrab == w)
- qt_pressGrab = 0;
-#ifndef QT_NO_QWS_MANAGER
- if (!w)
- w = static_cast<QETWidget*>(QWSManager::grabbedMouse());
-#endif
- if (w) {
- // Our mouse is grabbed - send it.
- widget = w;
- btnstate = mouseButtonState;
- } else {
- static QWidget *gw = 0;
- // Three jobs to do here:
- // 1. find the child widget this event belongs to.
- // 2. make sure the cursor is correct.
- // 3. handle implicit mouse grab due to button press.
- w = widget; // w is the widget the cursor is in.
-
- //### ??? alloc_region
- //#### why should we get events outside alloc_region ????
- if (1 /*widget->data->alloc_region.contains(dp) */) {
- // Find the child widget that the cursor is in.
- w = static_cast<QETWidget*>(widget->childAt(widget->mapFromParent(p)));
- if (!w)
- w = widget;
-#ifndef QT_NO_CURSOR
- // Update Cursor.
- if (!gw || gw != w || qt_last_cursor == 0xffffffff) {
- QCursor *curs = 0;
- if (!qApp->d_func()->cursor_list.isEmpty())
- curs = &qApp->d_func()->cursor_list.first();
- else if (w->d_func()->extraData())
- curs = w->d_func()->extraData()->curs;
- QWidget *pw = w;
- // If this widget has no cursor set, try parent.
- while (!curs) {
- pw = pw->parentWidget();
- if (!pw)
- break;
- if (pw->d_func()->extraData())
- curs = pw->d_func()->extraData()->curs;
- }
- if (!qws_overrideCursor) {
- if (curs)
- QPaintDevice::qwsDisplay()->selectCursor(widget, curs->handle());
- else
- QPaintDevice::qwsDisplay()->selectCursor(widget, Qt::ArrowCursor);
- }
- }
-#endif
- gw = w;
- } else {
- // This event is not for any of our widgets
- gw = 0;
- }
- if (mouseButtonState && !btnstate) {
- // The server has grabbed the mouse for us.
- // Remember which of my widgets has it.
- qt_pressGrab = w;
- if (!widget->isActiveWindow() &&
- (!app_do_modal || QApplication::activeModalWidget() == widget) &&
- !((widget->windowFlags() & Qt::FramelessWindowHint) || (widget->windowType() == Qt::Tool))) {
- widget->activateWindow();
- if (widget->raiseOnClick())
- widget->raise();
- }
- }
- btnstate = mouseButtonState;
- widget = w;
- }
- }
-
- if (!widget) { // don't know this window
- if (!QWidget::mouseGrabber()
-#ifndef QT_NO_QWS_MANAGER
- && !QWSManager::grabbedMouse()
-#endif
- ) {
- qt_last_cursor = 0xffffffff; // cursor can be changed by another application
- }
-
- QWidget* popup = QApplication::activePopupWidget();
- if (popup) {
-
- /*
- That is more than suboptimal. The real solution should
- do some keyevent and buttonevent translation, so that
- the popup still continues to work as the user expects.
- Unfortunately this translation is currently only
- possible with a known widget. I'll change that soon
- (Matthias).
- */
-
- // Danger - make sure we don't lock the server
- switch (event->type) {
- case QWSEvent::Mouse:
- case QWSEvent::Key:
- do {
- popup->close();
- } while ((popup = qApp->activePopupWidget()));
- return 1;
- }
- }
- if (event->type == QWSEvent::Mouse && *mouseInWidget) {
- QApplicationPrivate::dispatchEnterLeave(0, *mouseInWidget);
- (*mouseInWidget) = 0;
- }
- return -1;
- }
-
- if (app_do_modal) // modal event handling
- if (!qt_try_modal(widget, event)) {
- return 1;
- }
-
- if (widget->qwsEvent(event)) // send through widget filter
- return 1;
- switch (event->type) {
-
- case QWSEvent::Mouse: { // mouse event
- QWSMouseEvent *me = event->asMouse();
- QWSMouseEvent::SimpleData &mouse = me->simpleData;
-
- // Translate a QWS event into separate move
- // and press/release events
- // Beware of reentrancy: we can enter a modal state
- // inside translateMouseEvent
-
- if (isMove) {
- QWSMouseEvent move = *me;
- move.simpleData.state = oldstate;
- widget->translateMouseEvent(&move, oldstate);
- }
- if ((mouse.state&Qt::MouseButtonMask) != (oldstate&Qt::MouseButtonMask)) {
- widget->translateMouseEvent(me, oldstate);
- }
-
- if (mouse.delta != 0)
- widget->translateWheelEvent(me);
-
- if (qt_button_down && (mouse_state & Qt::MouseButtonMask) == 0)
- qt_button_down = 0;
-
- break;
- }
- case QWSEvent::Key: // keyboard event
- if (keywidget) // should always exist
- keywidget->translateKeyEvent(static_cast<QWSKeyEvent*>(event), grabbed);
- break;
-
-#ifndef QT_NO_QWS_INPUTMETHODS
- case QWSEvent::IMEvent:
- if (keywidget) // should always exist
- QWSInputContext::translateIMEvent(keywidget, static_cast<QWSIMEvent*>(event));
- break;
-
- case QWSEvent::IMQuery:
- if (keywidget) // should always exist
- QWSInputContext::translateIMQueryEvent(keywidget, static_cast<QWSIMQueryEvent*>(event));
- break;
-
- case QWSEvent::IMInit:
- QWSInputContext::translateIMInitEvent(static_cast<QWSIMInitEvent*>(event));
- break;
-#endif
- case QWSEvent::Region:
- widget->translateRegionEvent(static_cast<QWSRegionEvent*>(event));
- break;
- case QWSEvent::Focus:
- if ((static_cast<QWSFocusEvent*>(event))->simpleData.get_focus) {
- if (widget == static_cast<QWidget *>(desktop()))
- return true; // not interesting
- if (activeWindow() != widget) {
- setActiveWindow(widget);
- if (QApplicationPrivate::active_window)
- static_cast<QETWidget *>(QApplicationPrivate::active_window)->repaintDecoration(desktop()->rect(), false);
- if (widget && !d->inPopupMode()) {
- QWidget *w = widget->focusWidget();
- while (w && w->focusProxy())
- w = w->focusProxy();
- if (w && (w->focusPolicy() != Qt::NoFocus))
- w->setFocus();
- else
- widget->QWidget::focusNextPrevChild(true);
- if (!QApplicationPrivate::focus_widget) {
- if (widget->focusWidget())
- widget->focusWidget()->setFocus();
- else
- widget->window()->setFocus();
- }
- }
- }
- } else { // lost focus
- if (widget == static_cast<QWidget *>(desktop()))
- return true; // not interesting
- if (QApplicationPrivate::focus_widget) {
- QETWidget *old = static_cast<QETWidget *>(QApplicationPrivate::active_window);
- setActiveWindow(0);
- qt_last_cursor = 0xffffffff;
- //QApplicationPrivate::active_window = 0;
- if (old)
- old->repaintDecoration(desktop()->rect(), false);
- /* activateWindow() sends focus events
- QApplication::setFocusWidget(0);
- */
- }
- }
- break;
-
- case QWSEvent::WindowOperation:
- if (static_cast<QWidget *>(widget) == desktop())
- return true;
- switch ((static_cast<QWSWindowOperationEvent *>(event))->simpleData.op) {
- case QWSWindowOperationEvent::Show:
- widget->show();
- break;
- case QWSWindowOperationEvent::Hide:
- widget->hide();
- break;
- case QWSWindowOperationEvent::ShowMaximized:
- widget->showMaximized();
- break;
- case QWSWindowOperationEvent::ShowMinimized:
- widget->showMinimized();
- break;
- case QWSWindowOperationEvent::ShowNormal:
- widget->showNormal();
- break;
- case QWSWindowOperationEvent::Close:
- widget->d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent);
- break;
- }
- break;
-#ifndef QT_NO_QWSEMBEDWIDGET
- case QWSEvent::Embed:
- widget->translateEmbedEvent(static_cast<QWSEmbedEvent*>(event));
- break;
-#endif
- default:
- break;
- }
-
- return 0;
-}
-
-bool QApplication::qwsEventFilter(QWSEvent *)
-{
- return false;
-}
-
-void QApplication::qwsSetCustomColors(QRgb *colorTable, int start, int numColors)
-{
- if (start < 0 || start > 39) {
- qWarning("QApplication::qwsSetCustomColors: start < 0 || start > 39");
- return;
- }
- if (start + numColors > 40) {
- numColors = 40 - start;
- qWarning("QApplication::qwsSetCustomColors: Too many colors");
- }
- start += 216;
- for (int i = 0; i < numColors; i++) {
- qt_screen->set(start + i, qRed(colorTable[i]), qGreen(colorTable[i]),
- qBlue(colorTable[i]));
- }
-}
-
-#ifndef QT_NO_QWS_MANAGER
-QDecoration &QApplication::qwsDecoration()
-{
- return *qws_decoration;
-}
-
-void QApplication::qwsSetDecoration(QDecoration *dec)
-{
- if (dec) {
- delete qws_decoration;
- qws_decoration = dec;
- QWidgetList widgets = topLevelWidgets();
- for (int i = 0; i < widgets.size(); ++i) {
- QWidget *w = widgets[i];
- if (w->isVisible() && w != desktop()) {
- static_cast<QETWidget *>(w)->updateRegion();
- static_cast<QETWidget *>(w)->repaintDecoration(desktop()->rect(), false);
- if (w->isMaximized())
- w->showMaximized();
- }
- }
- }
-}
-
-QDecoration* QApplication::qwsSetDecoration(const QString &decoration)
-{
- QDecoration *decore = QDecorationFactory::create(decoration);
- if (!decore)
- return 0;
-
- qwsSetDecoration(decore);
- return decore;
-}
-
-#endif
-
-bool QApplicationPrivate::modalState()
-{
- return app_do_modal;
-}
-
-void QApplicationPrivate::enterModal_sys(QWidget *widget)
-{
- if (!qt_modal_stack)
- qt_modal_stack = new QWidgetList;
- qt_modal_stack->insert(0, widget);
- app_do_modal = true;
-}
-
-void QApplicationPrivate::leaveModal_sys(QWidget *widget)
-{
- if (qt_modal_stack && qt_modal_stack->removeAll(widget)) {
- if (qt_modal_stack->isEmpty()) {
- delete qt_modal_stack;
- qt_modal_stack = 0;
- }
- }
- app_do_modal = qt_modal_stack != 0;
-}
-
-static bool qt_try_modal(QWidget *widget, QWSEvent *event)
-{
- QWidget * top = 0;
-
- if (QApplicationPrivate::tryModalHelper(widget, &top))
- return true;
-
- bool block_event = false;
- bool paint_event = false;
-
- switch (event->type) {
- case QWSEvent::Focus:
- if (!static_cast<QWSFocusEvent*>(event)->simpleData.get_focus)
- break;
- // drop through
- case QWSEvent::Mouse: // disallow mouse/key events
- case QWSEvent::Key:
- block_event = true;
- break;
- }
-
- if (top->parentWidget() == 0 && (block_event || paint_event))
- top->raise();
-
- return !block_event;
-}
-
-static int openPopupCount = 0;
-void QApplicationPrivate::openPopup(QWidget *popup)
-{
- openPopupCount++;
- if (!popupWidgets) { // create list
- popupWidgets = new QWidgetList;
-
- /* only grab if you are the first/parent popup */
- QPaintDevice::qwsDisplay()->grabMouse(popup,true);
- QPaintDevice::qwsDisplay()->grabKeyboard(popup,true);
- popupGrabOk = true;
- }
- popupWidgets->append(popup); // add to end of list
-
- // popups are not focus-handled by the window system (the first
- // popup grabbed the keyboard), so we have to do that manually: A
- // new popup gets the focus
- if (popup->focusWidget()) {
- popup->focusWidget()->setFocus(Qt::PopupFocusReason);
- } else if (popupWidgets->count() == 1) { // this was the first popup
- if (QWidget *fw = QApplication::focusWidget()) {
- QFocusEvent e(QEvent::FocusOut, Qt::PopupFocusReason);
- QApplication::sendEvent(fw, &e);
- }
- }
-}
-
-void QApplicationPrivate::closePopup(QWidget *popup)
-{
- if (!popupWidgets)
- return;
-
- popupWidgets->removeAll(popup);
- if (popup == popupOfPopupButtonFocus) {
- popupButtonFocus = 0;
- popupOfPopupButtonFocus = 0;
- }
- if (popupWidgets->count() == 0) { // this was the last popup
- popupCloseDownMode = true; // control mouse events
- delete popupWidgets;
- popupWidgets = 0;
- if (popupGrabOk) { // grabbing not disabled
- QPaintDevice::qwsDisplay()->grabMouse(popup,false);
- QPaintDevice::qwsDisplay()->grabKeyboard(popup,false);
- popupGrabOk = false;
- // XXX ungrab keyboard
- }
- if (active_window) {
- if (QWidget *fw = active_window->focusWidget()) {
- if (fw != QApplication::focusWidget()) {
- fw->setFocus(Qt::PopupFocusReason);
- } else {
- QFocusEvent e(QEvent::FocusIn, Qt::PopupFocusReason);
- QApplication::sendEvent(fw, &e);
- }
- }
- }
- } else {
- // popups are not focus-handled by the window system (the
- // first popup grabbed the keyboard), so we have to do that
- // manually: A popup was closed, so the previous popup gets
- // the focus.
- QWidget* aw = popupWidgets->last();
- if (QWidget *fw = aw->focusWidget())
- fw->setFocus(Qt::PopupFocusReason);
- }
-}
-
-/*****************************************************************************
- Event translation; translates FB events to Qt events
- *****************************************************************************/
-
-//
-// Mouse event translation
-//
-// FB doesn't give mouse double click events, so we generate them by
-// comparing window, time and position between two mouse press events.
-//
-
-
-// Needed for QCursor::pos
-
-static const int AnyButton = (Qt::LeftButton | Qt::MidButton | Qt::RightButton);
-
-
-
-//
-// Wheel event translation
-//
-bool QETWidget::translateWheelEvent(const QWSMouseEvent *me)
-{
-#ifdef QT_NO_WHEELEVENT
- Q_UNUSED(me);
- return false;
-#else
- const QWSMouseEvent::SimpleData &mouse = me->simpleData;
-
- // Figure out wheeling direction:
- // Horizontal wheel w/o Alt
- // OR Vertical wheel w/ Alt ==> Horizontal wheeling
- // ..all other permutations ==> Vertical wheeling
- int axis = mouse.delta / 120; // WHEEL_DELTA?
- Qt::Orientation orient = ((axis == 2 || axis == -2) && ((mouse.state & Qt::AltModifier) == 0))
- ||((axis == 1 || axis == -1) && mouse.state & Qt::AltModifier)
- ? Qt::Horizontal : Qt::Vertical;
-
- QPoint mousePoint = QPoint(mouse.x_root, mouse.y_root);
-
- // send the event to the widget or its ancestors
- QWidget* popup = qApp->activePopupWidget();
- if (popup && window() != popup)
- popup->close();
- QWheelEvent we(mapFromGlobal(mousePoint), mousePoint, mouse.delta,
- Qt::MouseButtons(mouse.state & Qt::MouseButtonMask),
- Qt::KeyboardModifiers(mouse.state & Qt::KeyboardModifierMask), orient);
- if (QApplication::sendSpontaneousEvent(this, &we))
- return true;
-
- // send the event to the widget that has the focus or its ancestors, if different
- QWidget *w = this;
- if (w != qApp->focusWidget() && (w = qApp->focusWidget())) {
- QWidget* popup = qApp->activePopupWidget();
- if (popup && w != popup)
- popup->hide();
- if (QApplication::sendSpontaneousEvent(w, &we))
- return true;
- }
- return false;
-#endif
-}
-
-bool QETWidget::translateMouseEvent(const QWSMouseEvent *event, int prevstate)
-{
- static bool manualGrab = false;
- QPoint pos;
- QPoint globalPos;
- int button = 0;
-
- if (sm_blockUserInput) // block user interaction during session management
- return true;
- const QWSMouseEvent::SimpleData &mouse = event->simpleData;
- pos = mapFromGlobal(QPoint(mouse.x_root, mouse.y_root));
-// if (qt_last_x) {
-// *qt_last_x=mouse.x_root;
-// *qt_last_y=mouse.y_root;
-// }
- globalPos.rx() = mouse.x_root;
- globalPos.ry() = mouse.y_root;
-
- QEvent::Type type = QEvent::None;
-
- Qt::MouseButtons buttonstate = Qt::MouseButtons(mouse.state & Qt::MouseButtonMask);
- Qt::KeyboardModifiers keystate = Qt::KeyboardModifiers(mouse.state & Qt::KeyboardModifierMask);
-
- if (mouse.state == prevstate) {
- // mouse move
- type = QEvent::MouseMove;
- } else if ((mouse.state&AnyButton) != (prevstate&AnyButton)) {
- Qt::MouseButtons current_buttons = Qt::MouseButtons(prevstate&Qt::MouseButtonMask);
- for (button = Qt::LeftButton; !type && button <= Qt::MidButton; button<<=1) {
- if ((mouse.state&button) != (current_buttons&button)) {
- // button press or release
- current_buttons = Qt::MouseButtons(current_buttons ^ button);
-
-#ifndef QT_NO_QWS_INPUTMETHODS
- //############ We used to do a QInputContext::reset(oldFocus);
- // when we changed the focus widget. See change 93389 for where the
- // focus code went. The IM code was (after testing for ClickToFocus):
- //if (mouse.state&button && w != QInputContext::microFocusWidget()) //button press
- // QInputContext::reset(oldFocus);
-
-#endif
- if (mouse.state&button) { //button press
- qt_button_down = childAt(pos);
- if (!qt_button_down)
- qt_button_down = this;
- if (/*XXX mouseActWindow == this &&*/
- mouseButtonPressed == button &&
- long(mouse.time) -long(mouseButtonPressTime)
- < QApplication::doubleClickInterval() &&
- qAbs(mouse.x_root - mouseXPos) < mouse_double_click_distance &&
- qAbs(mouse.y_root - mouseYPos) < mouse_double_click_distance ) {
- type = QEvent::MouseButtonDblClick;
- mouseButtonPressTime -= 2000; // no double-click next time
- } else {
- type = QEvent::MouseButtonPress;
- mouseButtonPressTime = mouse.time;
- }
- mouseButtonPressed = button; // save event params for
- mouseXPos = globalPos.x(); // future double click tests
- mouseYPos = globalPos.y();
- } else { // mouse button released
- if (manualGrab) { // release manual grab
- manualGrab = false;
- // XXX XUngrabPointer(x11Display(), CurrentTime);
- }
-
- type = QEvent::MouseButtonRelease;
- }
- }
- }
- button >>= 1;
- }
- //XXX mouseActWindow = winId(); // save some event params
-
- if (type == 0) { // event consumed
- return false; //EXIT in the normal case
- }
-
- if (qApp->d_func()->inPopupMode()) { // in popup mode
- QWidget *popup = qApp->activePopupWidget();
- // in X11, this would be the window we are over.
- // in QWS this is the top level popup. to allow mouse
- // events to other widgets, need to go through qApp->QApplicationPrivate::popupWidgets.
- QSize s(qt_screen->width(), qt_screen->height());
- for (int i = 0; i < QApplicationPrivate::popupWidgets->size(); ++i) {
- QWidget *w = QApplicationPrivate::popupWidgets->at(i);
-
- if ((w->windowType() == Qt::Popup) && w->d_func()->localAllocatedRegion().contains(globalPos - w->geometry().topLeft()))
- {
- popup = w;
- break;
- }
- }
- pos = popup->mapFromGlobal(globalPos);
- bool releaseAfter = false;
- QWidget *popupChild = popup->childAt(pos);
- QWidget *popupTarget = popupChild ? popupChild : popup;
-
- if (popup != popupOfPopupButtonFocus){
- popupButtonFocus = 0;
- popupOfPopupButtonFocus = 0;
- }
-
- if (!popupTarget->isEnabled()) {
- return false; //EXIT special case
- }
-
- switch (type) {
- case QEvent::MouseButtonPress:
- case QEvent::MouseButtonDblClick:
- popupButtonFocus = popupChild;
- popupOfPopupButtonFocus = popup;
- break;
- case QEvent::MouseButtonRelease:
- releaseAfter = true;
- break;
- default:
- break; // nothing for mouse move
- }
-
- int oldOpenPopupCount = openPopupCount;
-
- if (popupButtonFocus) {
- QMouseEvent e(type, popupButtonFocus->mapFromGlobal(globalPos),
- globalPos, Qt::MouseButton(button), buttonstate, keystate);
- QApplication::sendSpontaneousEvent(popupButtonFocus, & e);
- if (releaseAfter) {
- popupButtonFocus = 0;
- popupOfPopupButtonFocus = 0;
- }
- } else if (popupChild) {
- QMouseEvent e(type, popupChild->mapFromGlobal(globalPos),
- globalPos, Qt::MouseButton(button), buttonstate, keystate);
- QApplication::sendSpontaneousEvent(popupChild, & e);
- } else {
- QMouseEvent e(type, pos, globalPos, Qt::MouseButton(button), buttonstate, keystate);
- QApplication::sendSpontaneousEvent(popupChild ? popupChild : popup, & e);
- }
-#ifndef QT_NO_CONTEXTMENU
- if (type == QEvent::MouseButtonPress && button == Qt::RightButton && (openPopupCount == oldOpenPopupCount)) {
- QWidget *popupEvent = popup;
- if(popupButtonFocus)
- popupEvent = popupButtonFocus;
- else if(popupChild)
- popupEvent = popupChild;
- QContextMenuEvent e(QContextMenuEvent::Mouse, pos, globalPos, keystate);
- QApplication::sendSpontaneousEvent(popupEvent, &e);
- }
-#endif // QT_NO_CONTEXTMENU
-
- if (releaseAfter)
- qt_button_down = 0;
-
- } else { //qApp not in popup mode
- QWidget *widget = this;
- QWidget *w = QWidget::mouseGrabber();
- if (!w && qt_button_down)
- w = qt_button_down;
- if (w && w != this) {
- widget = w;
- pos = mapToGlobal(pos);
- pos = w->mapFromGlobal(pos);
- }
-
- if (popupCloseDownMode) {
- popupCloseDownMode = false;
- if ((windowType() == Qt::Popup)) // ignore replayed event
- return true; //EXIT
- }
-
- QPointer<QWidget> leaveAfterRelease = 0;
- if (type == QEvent::MouseButtonRelease &&
- (mouse.state & (~button) & (Qt::LeftButton |
- Qt::MidButton |
- Qt::RightButton)) == 0) {
- // Button released outside the widget -> leave the widget after the
- // release event has been delivered.
- if (widget == qt_button_down && (pos.x() < 0 || pos.y() < 0))
- leaveAfterRelease = qt_button_down;
- qt_button_down = 0;
- }
-
- int oldOpenPopupCount = openPopupCount;
-
- QMouseEvent e(type, pos, globalPos, Qt::MouseButton(button), buttonstate, keystate);
-#ifndef QT_NO_QWS_MANAGER
- if (widget->isWindow() && widget->d_func()->topData()->qwsManager
- && (widget->d_func()->topData()->qwsManager->region().contains(globalPos)
- || QWSManager::grabbedMouse() )) {
- if ((*mouseInWidget)) {
- QApplicationPrivate::dispatchEnterLeave(0, *mouseInWidget);
- (*mouseInWidget) = 0;
- }
- QApplication::sendSpontaneousEvent(widget->d_func()->topData()->qwsManager, &e);
- qApp->d_func()->last_manager = widget->d_func()->topData()->qwsManager;
- } else
-#endif
- {
- if (widget != (*mouseInWidget)) {
- QApplicationPrivate::dispatchEnterLeave(widget, *mouseInWidget);
- (*mouseInWidget) = widget;
- qt_last_mouse_receiver = widget;
- }
- QApplication::sendSpontaneousEvent(widget, &e);
- if (leaveAfterRelease && !QWidget::mouseGrabber()) {
- *mouseInWidget = QApplication::widgetAt(globalPos);
- qt_last_mouse_receiver = *mouseInWidget;
- QApplicationPrivate::dispatchEnterLeave(*mouseInWidget, leaveAfterRelease);
- leaveAfterRelease = 0;
- }
- }
-#ifndef QT_NO_CONTEXTMENU
- if (type == QEvent::MouseButtonPress && button == Qt::RightButton && (openPopupCount == oldOpenPopupCount)) {
- QContextMenuEvent e(QContextMenuEvent::Mouse, pos, globalPos, keystate);
- QApplication::sendSpontaneousEvent(widget, &e);
- }
-#endif // QT_NO_CONTEXTMENU
- }
- return true;
-}
-
-
-bool QETWidget::translateKeyEvent(const QWSKeyEvent *event, bool grab) /* grab is used in the #ifdef */
-{
- int code = -1;
- //### Qt assumes keyboard state is state *before*, while QWS uses state after the event
- static Qt::KeyboardModifiers oldstate;
- Qt::KeyboardModifiers state = oldstate;
- oldstate = event->simpleData.modifiers;
-
- if (sm_blockUserInput) // block user interaction during session management
- return true;
-
- if (!isEnabled())
- return true;
-
- QEvent::Type type = event->simpleData.is_press ?
- QEvent::KeyPress : QEvent::KeyRelease;
- bool autor = event->simpleData.is_auto_repeat;
- QString text;
- char ascii = 0;
- if (event->simpleData.unicode) {
- QChar ch(event->simpleData.unicode);
- if (ch.unicode() != 0xffff)
- text += ch;
- ascii = ch.toLatin1();
- }
- code = event->simpleData.keycode;
-
-#if defined QT3_SUPPORT && !defined(QT_NO_SHORTCUT)
- if (type == QEvent::KeyPress && !grab
- && static_cast<QApplicationPrivate*>(qApp->d_ptr.data())->use_compat()) {
- // send accel events if the keyboard is not grabbed
- QKeyEvent a(type, code, state, text, autor, int(text.length()));
- if (static_cast<QApplicationPrivate*>(qApp->d_ptr.data())->qt_tryAccelEvent(this, &a))
- return true;
- }
-#else
- Q_UNUSED(grab);
-#endif
- if (!text.isEmpty() && testAttribute(Qt::WA_KeyCompression)) {
- // the widget wants key compression so it gets it
-
- // XXX not implemented
- }
-
- QKeyEvent e(type, code, state, text, autor, int(text.length()));
- return QApplication::sendSpontaneousEvent(this, &e);
-}
-
-bool QETWidget::translateRegionEvent(const QWSRegionEvent *event)
-{
- QWSWindowSurface *surface = static_cast<QWSWindowSurface*>(windowSurface());
- Q_ASSERT(surface);
-
- QRegion region;
- region.setRects(event->rectangles, event->simpleData.nrectangles);
-
- switch (event->simpleData.type) {
- case QWSRegionEvent::Allocation:
- region.translate(-mapToGlobal(QPoint()));
- surface->setClipRegion(region);
- break;
-#ifdef QT_QWS_CLIENTBLIT
- case QWSRegionEvent::DirectPaint:
- surface->setDirectRegion(region, event->simpleData.id);
- break;
-#endif
- default:
- break;
- }
-
- return true;
-}
-
-#ifndef QT_NO_QWSEMBEDWIDGET
-void QETWidget::translateEmbedEvent(const QWSEmbedEvent *event)
-{
- if (event->simpleData.type | QWSEmbedEvent::Region) {
- const QRegion region = event->region;
- setGeometry(region.boundingRect());
- setVisible(!region.isEmpty());
- }
-}
-#endif // QT_NO_QWSEMBEDWIDGET
-
-void QETWidget::repaintDecoration(QRegion r, bool post)
-{
- Q_UNUSED(post);
-#ifdef QT_NO_QWS_MANAGER
- Q_UNUSED(r);
-#else
- //please note that qwsManager is a QObject, not a QWidget.
- //therefore, normal ways of painting do not work.
- // However, it does listen to paint events.
-
- Q_D(QWidget);
- if (isWindow() && d->topData()->qwsManager && isVisible()) {
- QWSManager *manager = d->topData()->qwsManager;
- r &= manager->region();
- if (!r.isEmpty())
- manager->repaintRegion(QDecoration::All, QDecoration::Normal);
- }
-#endif
-}
-
-void QETWidget::updateRegion()
-{
- Q_D(QWidget);
-
- QTLWExtra *topextra = d->maybeTopData();
- if (!topextra)
- return;
-
- QRegion myregion = d->localRequestedRegion();
- myregion.translate(geometry().topLeft());
-
-#ifndef QT_NO_QWS_MANAGER
- QWSManager *manager = topextra->qwsManager;
- if (manager)
- myregion += manager->region();
-#endif
-
- QRect br(myregion.boundingRect());
- topextra->frameStrut.setCoords(d->data.crect.x() - br.x(),
- d->data.crect.y() - br.y(),
- br.right() - d->data.crect.right(),
- br.bottom() - d->data.crect.bottom());
-}
-
-void QApplication::setCursorFlashTime(int msecs)
-{
- QApplicationPrivate::cursor_flash_time = msecs;
-}
-
-
-int QApplication::cursorFlashTime()
-{
- return QApplicationPrivate::cursor_flash_time;
-}
-
-void QApplication::setDoubleClickInterval(int ms)
-{
- QApplicationPrivate::mouse_double_click_time = ms;
-}
-
-int QApplication::doubleClickInterval()
-{
- return QApplicationPrivate::mouse_double_click_time;
-}
-
-void QApplication::setKeyboardInputInterval(int ms)
-{
- QApplicationPrivate::keyboard_input_time = ms;
-}
-
-int QApplication::keyboardInputInterval()
-{
- return QApplicationPrivate::keyboard_input_time;
-}
-
-#ifndef QT_NO_WHEELEVENT
-void QApplication::setWheelScrollLines(int lines)
-{
- QApplicationPrivate::wheel_scroll_lines = lines;
-}
-
-int QApplication::wheelScrollLines()
-{
- return QApplicationPrivate::wheel_scroll_lines;
-}
-#endif
-
-void QApplication::setEffectEnabled(Qt::UIEffect effect, bool enable)
-{
- switch (effect) {
- case Qt::UI_AnimateMenu:
- QApplicationPrivate::animate_menu = enable;
- break;
- case Qt::UI_FadeMenu:
- if (enable)
- QApplicationPrivate::animate_menu = true;
- QApplicationPrivate::fade_menu = enable;
- break;
- case Qt::UI_AnimateCombo:
- QApplicationPrivate::animate_combo = enable;
- break;
- case Qt::UI_AnimateTooltip:
- QApplicationPrivate::animate_tooltip = enable;
- break;
- case Qt::UI_FadeTooltip:
- if (enable)
- QApplicationPrivate::animate_tooltip = true;
- QApplicationPrivate::fade_tooltip = enable;
- break;
- case Qt::UI_AnimateToolBox:
- QApplicationPrivate::animate_toolbox = enable;
- break;
- default:
- QApplicationPrivate::animate_ui = enable;
- break;
- }
-}
-
-bool QApplication::isEffectEnabled(Qt::UIEffect effect)
-{
- if (QColormap::instance().depth() < 16 || !QApplicationPrivate::animate_ui)
- return false;
-
- switch(effect) {
- case Qt::UI_AnimateMenu:
- return QApplicationPrivate::animate_menu;
- case Qt::UI_FadeMenu:
- return QApplicationPrivate::fade_menu;
- case Qt::UI_AnimateCombo:
- return QApplicationPrivate::animate_combo;
- case Qt::UI_AnimateTooltip:
- return QApplicationPrivate::animate_tooltip;
- case Qt::UI_FadeTooltip:
- return QApplicationPrivate::fade_tooltip;
- case Qt::UI_AnimateToolBox:
- return QApplicationPrivate::animate_toolbox;
- default:
- return QApplicationPrivate::animate_ui;
- }
-}
-
-void QApplication::setArgs(int c, char **v)
-{
- Q_D(QApplication);
- d->argc = c;
- d->argv = v;
-}
-
-void QApplicationPrivate::initializeMultitouch_sys()
-{ }
-void QApplicationPrivate::cleanupMultitouch_sys()
-{ }
-
-/* \internal
- This is used to clean up the qws server
- in case the QApplication constructor threw an exception
-*/
-QWSServerCleaner::~QWSServerCleaner()
-{
- if (qwsServer && qws_single_process)
- QWSServer::closedown();
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qboxlayout.h b/src/gui/kernel/qboxlayout.h
deleted file mode 100644
index 66ce23a9f5..0000000000
--- a/src/gui/kernel/qboxlayout.h
+++ /dev/null
@@ -1,173 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QBOXLAYOUT_H
-#define QBOXLAYOUT_H
-
-#include <QtGui/qlayout.h>
-#ifdef QT_INCLUDE_COMPAT
-#include <QtGui/qwidget.h>
-#endif
-
-#include <limits.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QBoxLayoutPrivate;
-
-class Q_GUI_EXPORT QBoxLayout : public QLayout
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QBoxLayout)
-public:
- enum Direction { LeftToRight, RightToLeft, TopToBottom, BottomToTop,
- Down = TopToBottom, Up = BottomToTop };
-
- explicit QBoxLayout(Direction, QWidget *parent = 0);
-
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QBoxLayout(QWidget *parent, Direction, int border = 0, int spacing = -1,
- const char *name = 0);
- QT3_SUPPORT_CONSTRUCTOR QBoxLayout(QLayout *parentLayout, Direction, int spacing = -1,
- const char *name = 0);
- QT3_SUPPORT_CONSTRUCTOR QBoxLayout(Direction, int spacing, const char *name = 0);
-#endif
- ~QBoxLayout();
-
- Direction direction() const;
- void setDirection(Direction);
-
- void addSpacing(int size);
- void addStretch(int stretch = 0);
- void addSpacerItem(QSpacerItem *spacerItem);
- void addWidget(QWidget *, int stretch = 0, Qt::Alignment alignment = 0);
- void addLayout(QLayout *layout, int stretch = 0);
- void addStrut(int);
- void addItem(QLayoutItem *);
-
- void insertSpacing(int index, int size);
- void insertStretch(int index, int stretch = 0);
- void insertSpacerItem(int index, QSpacerItem *spacerItem);
- void insertWidget(int index, QWidget *widget, int stretch = 0, Qt::Alignment alignment = 0);
- void insertLayout(int index, QLayout *layout, int stretch = 0);
-
- int spacing() const;
- void setSpacing(int spacing);
-
- bool setStretchFactor(QWidget *w, int stretch);
- bool setStretchFactor(QLayout *l, int stretch);
- void setStretch(int index, int stretch);
- int stretch(int index) const;
-
- QSize sizeHint() const;
- QSize minimumSize() const;
- QSize maximumSize() const;
-
- bool hasHeightForWidth() const;
- int heightForWidth(int) const;
- int minimumHeightForWidth(int) const;
-
- Qt::Orientations expandingDirections() const;
- void invalidate();
- QLayoutItem *itemAt(int) const;
- QLayoutItem *takeAt(int);
- int count() const;
- void setGeometry(const QRect&);
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT int findWidget(QWidget* w) {return indexOf(w);}
-#endif
-protected:
- // ### Qt 5: make public
- void insertItem(int index, QLayoutItem *);
-
-private:
- Q_DISABLE_COPY(QBoxLayout)
-};
-
-class Q_GUI_EXPORT QHBoxLayout : public QBoxLayout
-{
- Q_OBJECT
-public:
- QHBoxLayout();
- explicit QHBoxLayout(QWidget *parent);
- ~QHBoxLayout();
-
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QHBoxLayout(QWidget *parent, int border,
- int spacing = -1, const char *name = 0);
- QT3_SUPPORT_CONSTRUCTOR QHBoxLayout(QLayout *parentLayout,
- int spacing = -1, const char *name = 0);
- QT3_SUPPORT_CONSTRUCTOR QHBoxLayout(int spacing, const char *name = 0);
-#endif
-
-private:
- Q_DISABLE_COPY(QHBoxLayout)
-};
-
-class Q_GUI_EXPORT QVBoxLayout : public QBoxLayout
-{
- Q_OBJECT
-public:
- QVBoxLayout();
- explicit QVBoxLayout(QWidget *parent);
- ~QVBoxLayout();
-
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QVBoxLayout(QWidget *parent, int border,
- int spacing = -1, const char *name = 0);
- QT3_SUPPORT_CONSTRUCTOR QVBoxLayout(QLayout *parentLayout,
- int spacing = -1, const char *name = 0);
- QT3_SUPPORT_CONSTRUCTOR QVBoxLayout(int spacing, const char *name = 0);
-#endif
-
-private:
- Q_DISABLE_COPY(QVBoxLayout)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QBOXLAYOUT_H
diff --git a/src/gui/kernel/qclipboard.cpp b/src/gui/kernel/qclipboard.cpp
deleted file mode 100644
index ba7ad0caac..0000000000
--- a/src/gui/kernel/qclipboard.cpp
+++ /dev/null
@@ -1,667 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qclipboard.h"
-
-#ifndef QT_NO_CLIPBOARD
-
-#include "qapplication.h"
-#include "qapplication_p.h"
-#include "qpixmap.h"
-#include "qclipboard_p.h"
-#include "qvariant.h"
-#include "qbuffer.h"
-#include "qimage.h"
-#include "qtextcodec.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QClipboard
- \brief The QClipboard class provides access to the window system clipboard.
-
- The clipboard offers a simple mechanism to copy and paste data
- between applications.
-
- QClipboard supports the same data types that QDrag does, and uses
- similar mechanisms. For advanced clipboard usage read \l{Drag and
- Drop}.
-
- There is a single QClipboard object in an application, accessible
- as QApplication::clipboard().
-
- Example:
- \snippet doc/src/snippets/code/src_gui_kernel_qclipboard.cpp 0
-
- QClipboard features some convenience functions to access common
- data types: setText() allows the exchange of Unicode text and
- setPixmap() and setImage() allows the exchange of QPixmaps and
- QImages between applications. The setMimeData() function is the
- ultimate in flexibility: it allows you to add any QMimeData into
- the clipboard. There are corresponding getters for each of these,
- e.g. text(), image() and pixmap(). You can clear the clipboard by
- calling clear().
-
- A typical example of the use of these functions follows:
-
- \snippet doc/src/snippets/droparea.cpp 0
-
- \section1 Notes for X11 Users
-
- \list
-
- \i The X11 Window System has the concept of a separate selection
- and clipboard. When text is selected, it is immediately available
- as the global mouse selection. The global mouse selection may
- later be copied to the clipboard. By convention, the middle mouse
- button is used to paste the global mouse selection.
-
- \i X11 also has the concept of ownership; if you change the
- selection within a window, X11 will only notify the owner and the
- previous owner of the change, i.e. it will not notify all
- applications that the selection or clipboard data changed.
-
- \i Lastly, the X11 clipboard is event driven, i.e. the clipboard
- will not function properly if the event loop is not running.
- Similarly, it is recommended that the contents of the clipboard
- are stored or retrieved in direct response to user-input events,
- e.g. mouse button or key presses and releases. You should not
- store or retrieve the clipboard contents in response to timer or
- non-user-input events.
-
- \i Since there is no standard way to copy and paste files between
- applications on X11, various MIME types and conventions are currently
- in use. For instance, Nautilus expects files to be supplied with a
- \c{x-special/gnome-copied-files} MIME type with data beginning with
- the cut/copy action, a newline character, and the URL of the file.
-
- \endlist
-
- \section1 Notes for Mac OS X Users
-
- Mac OS X supports a separate find buffer that holds the current
- search string in Find operations. This find clipboard can be accessed
- by specifying the FindBuffer mode.
-
- \section1 Notes for Windows and Mac OS X Users
-
- \list
-
- \i Windows and Mac OS X do not support the global mouse
- selection; they only supports the global clipboard, i.e. they
- only add text to the clipboard when an explicit copy or cut is
- made.
-
- \i Windows and Mac OS X does not have the concept of ownership;
- the clipboard is a fully global resource so all applications are
- notified of changes.
-
- \endlist
-
- \sa QApplication
-*/
-
-#ifndef Q_WS_X11
-// for X11 there is a separate implementation of a constructor.
-/*!
- \internal
-
- Constructs a clipboard object.
-
- Do not call this function.
-
- Call QApplication::clipboard() instead to get a pointer to the
- application's global clipboard object.
-
- There is only one clipboard in the window system, and creating
- more than one object to represent it is almost certainly an error.
-*/
-
-QClipboard::QClipboard(QObject *parent)
- : QObject(*new QClipboardPrivate, parent)
-{
- // nothing
-}
-#endif
-
-#ifndef Q_WS_WIN32
-/*!
- \internal
-
- Destroys the clipboard.
-
- You should never delete the clipboard. QApplication will do this
- when the application terminates.
-*/
-QClipboard::~QClipboard()
-{
-}
-#endif
-
-/*!
- \fn void QClipboard::changed(QClipboard::Mode mode)
- \since 4.2
-
- This signal is emitted when the data for the given clipboard \a
- mode is changed.
-
- \sa dataChanged(), selectionChanged(), findBufferChanged()
-*/
-
-/*!
- \fn void QClipboard::dataChanged()
-
- This signal is emitted when the clipboard data is changed.
-
- On Mac OS X and with Qt version 4.3 or higher, clipboard
- changes made by other applications will only be detected
- when the application is activated.
-
- \sa findBufferChanged(), selectionChanged(), changed()
-*/
-
-/*!
- \fn void QClipboard::selectionChanged()
-
- This signal is emitted when the selection is changed. This only
- applies to windowing systems that support selections, e.g. X11.
- Windows and Mac OS X don't support selections.
-
- \sa dataChanged(), findBufferChanged(), changed()
-*/
-
-/*!
- \fn void QClipboard::findBufferChanged()
- \since 4.2
-
- This signal is emitted when the find buffer is changed. This only
- applies to Mac OS X.
-
- With Qt version 4.3 or higher, clipboard changes made by other
- applications will only be detected when the application is activated.
-
- \sa dataChanged(), selectionChanged(), changed()
-*/
-
-
-/*! \enum QClipboard::Mode
- \keyword clipboard mode
-
- This enum type is used to control which part of the system clipboard is
- used by QClipboard::mimeData(), QClipboard::setMimeData() and related functions.
-
- \value Clipboard indicates that data should be stored and retrieved from
- the global clipboard.
-
- \value Selection indicates that data should be stored and retrieved from
- the global mouse selection. Support for \c Selection is provided only on
- systems with a global mouse selection (e.g. X11).
-
- \value FindBuffer indicates that data should be stored and retrieved from
- the Find buffer. This mode is used for holding search strings on Mac OS X.
-
- \omitvalue LastMode
-
- \sa QClipboard::supportsSelection()
-*/
-
-
-/*****************************************************************************
- QApplication member functions related to QClipboard.
- *****************************************************************************/
-
-// text handling is done directly in qclipboard_qws, for now
-
-/*!
- \fn bool QClipboard::event(QEvent *e)
- \reimp
-*/
-
-/*!
- \overload
-
- Returns the clipboard text in subtype \a subtype, or an empty string
- if the clipboard does not contain any text. If \a subtype is null,
- any subtype is acceptable, and \a subtype is set to the chosen
- subtype.
-
- The \a mode argument is used to control which part of the system
- clipboard is used. If \a mode is QClipboard::Clipboard, the
- text is retrieved from the global clipboard. If \a mode is
- QClipboard::Selection, the text is retrieved from the global
- mouse selection.
-
- Common values for \a subtype are "plain" and "html".
-
- Note that calling this function repeatedly, for instance from a
- key event handler, may be slow. In such cases, you should use the
- \c dataChanged() signal instead.
-
- \sa setText(), mimeData()
-*/
-QString QClipboard::text(QString &subtype, Mode mode) const
-{
- const QMimeData *const data = mimeData(mode);
- if (!data)
- return QString();
-
- const QStringList formats = data->formats();
- if (subtype.isEmpty()) {
- if (formats.contains(QLatin1String("text/plain")))
- subtype = QLatin1String("plain");
- else {
- for (int i = 0; i < formats.size(); ++i)
- if (formats.at(i).startsWith(QLatin1String("text/"))) {
- subtype = formats.at(i).mid(5);
- break;
- }
- if (subtype.isEmpty())
- return QString();
- }
- } else if (!formats.contains(QLatin1String("text/") + subtype)) {
- return QString();
- }
-
- const QByteArray rawData = data->data(QLatin1String("text/") + subtype);
-
-#ifndef QT_NO_TEXTCODEC
- QTextCodec* codec = QTextCodec::codecForMib(106); // utf-8 is default
- if (subtype == QLatin1String("html"))
- codec = QTextCodec::codecForHtml(rawData, codec);
- else
- codec = QTextCodec::codecForUtfText(rawData, codec);
- return codec->toUnicode(rawData);
-#else //QT_NO_TEXTCODEC
- return rawData;
-#endif //QT_NO_TEXTCODEC
-}
-
-/*!
- Returns the clipboard text as plain text, or an empty string if the
- clipboard does not contain any text.
-
- The \a mode argument is used to control which part of the system
- clipboard is used. If \a mode is QClipboard::Clipboard, the
- text is retrieved from the global clipboard. If \a mode is
- QClipboard::Selection, the text is retrieved from the global
- mouse selection. If \a mode is QClipboard::FindBuffer, the
- text is retrieved from the search string buffer.
-
- \sa setText(), mimeData()
-*/
-QString QClipboard::text(Mode mode) const
-{
- const QMimeData *data = mimeData(mode);
- return data ? data->text() : QString();
-}
-
-/*!
- Copies \a text into the clipboard as plain text.
-
- The \a mode argument is used to control which part of the system
- clipboard is used. If \a mode is QClipboard::Clipboard, the
- text is stored in the global clipboard. If \a mode is
- QClipboard::Selection, the text is stored in the global
- mouse selection. If \a mode is QClipboard::FindBuffer, the
- text is stored in the search string buffer.
-
- \sa text(), setMimeData()
-*/
-void QClipboard::setText(const QString &text, Mode mode)
-{
- QMimeData *data = new QMimeData;
- data->setText(text);
- setMimeData(data, mode);
-}
-
-/*!
- Returns the clipboard image, or returns a null image if the
- clipboard does not contain an image or if it contains an image in
- an unsupported image format.
-
- The \a mode argument is used to control which part of the system
- clipboard is used. If \a mode is QClipboard::Clipboard, the
- image is retrieved from the global clipboard. If \a mode is
- QClipboard::Selection, the image is retrieved from the global
- mouse selection.
-
- \sa setImage() pixmap() mimeData(), QImage::isNull()
-*/
-QImage QClipboard::image(Mode mode) const
-{
- const QMimeData *data = mimeData(mode);
- if (!data)
- return QImage();
- return qvariant_cast<QImage>(data->imageData());
-}
-
-/*!
- Copies the \a image into the clipboard.
-
- The \a mode argument is used to control which part of the system
- clipboard is used. If \a mode is QClipboard::Clipboard, the
- image is stored in the global clipboard. If \a mode is
- QClipboard::Selection, the data is stored in the global
- mouse selection.
-
- This is shorthand for:
-
- \snippet doc/src/snippets/code/src_gui_kernel_qclipboard.cpp 1
-
- \sa image(), setPixmap() setMimeData()
-*/
-void QClipboard::setImage(const QImage &image, Mode mode)
-{
- QMimeData *data = new QMimeData;
- data->setImageData(image);
- setMimeData(data, mode);
-}
-
-/*!
- Returns the clipboard pixmap, or null if the clipboard does not
- contain a pixmap. Note that this can lose information. For
- example, if the image is 24-bit and the display is 8-bit, the
- result is converted to 8 bits, and if the image has an alpha
- channel, the result just has a mask.
-
- The \a mode argument is used to control which part of the system
- clipboard is used. If \a mode is QClipboard::Clipboard, the
- pixmap is retrieved from the global clipboard. If \a mode is
- QClipboard::Selection, the pixmap is retrieved from the global
- mouse selection.
-
- \sa setPixmap() image() mimeData() QPixmap::convertFromImage()
-*/
-QPixmap QClipboard::pixmap(Mode mode) const
-{
- const QMimeData *data = mimeData(mode);
- return data ? qvariant_cast<QPixmap>(data->imageData()) : QPixmap();
-}
-
-/*!
- Copies \a pixmap into the clipboard. Note that this is slower
- than setImage() because it needs to convert the QPixmap to a
- QImage first.
-
- The \a mode argument is used to control which part of the system
- clipboard is used. If \a mode is QClipboard::Clipboard, the
- pixmap is stored in the global clipboard. If \a mode is
- QClipboard::Selection, the pixmap is stored in the global
- mouse selection.
-
- \sa pixmap() setImage() setMimeData()
-*/
-void QClipboard::setPixmap(const QPixmap &pixmap, Mode mode)
-{
- QMimeData *data = new QMimeData;
- data->setImageData(pixmap);
- setMimeData(data, mode);
-}
-
-
-/*!
- \fn QMimeData *QClipboard::mimeData(Mode mode) const
-
- Returns a reference to a QMimeData representation of the current
- clipboard data.
-
- The \a mode argument is used to control which part of the system
- clipboard is used. If \a mode is QClipboard::Clipboard, the
- data is retrieved from the global clipboard. If \a mode is
- QClipboard::Selection, the data is retrieved from the global
- mouse selection. If \a mode is QClipboard::FindBuffer, the
- data is retrieved from the search string buffer.
-
- The text(), image(), and pixmap() functions are simpler
- wrappers for retrieving text, image, and pixmap data.
-
- \sa setMimeData()
-*/
-
-/*!
- \fn void QClipboard::setMimeData(QMimeData *src, Mode mode)
-
- Sets the clipboard data to \a src. Ownership of the data is
- transferred to the clipboard. If you want to remove the data
- either call clear() or call setMimeData() again with new data.
-
- The \a mode argument is used to control which part of the system
- clipboard is used. If \a mode is QClipboard::Clipboard, the
- data is stored in the global clipboard. If \a mode is
- QClipboard::Selection, the data is stored in the global
- mouse selection. If \a mode is QClipboard::FindBuffer, the
- data is stored in the search string buffer.
-
- The setText(), setImage() and setPixmap() functions are simpler
- wrappers for setting text, image and pixmap data respectively.
-
- \sa mimeData()
-*/
-
-/*!
- \fn void QClipboard::clear(Mode mode)
- Clear the clipboard contents.
-
- The \a mode argument is used to control which part of the system
- clipboard is used. If \a mode is QClipboard::Clipboard, this
- function clears the global clipboard contents. If \a mode is
- QClipboard::Selection, this function clears the global mouse
- selection contents. If \a mode is QClipboard::FindBuffer, this
- function clears the search string buffer.
-
- \sa QClipboard::Mode, supportsSelection()
-*/
-
-#ifdef QT3_SUPPORT
-/*!
- \fn QMimeSource *QClipboard::data(Mode mode) const
- \compat
-
- Use mimeData() instead.
-*/
-QMimeSource *QClipboard::data(Mode mode) const
-{
- Q_D(const QClipboard);
-
- if (supportsMode(mode) == false)
- return 0;
-
- if (d->compat_data[mode])
- return d->compat_data[mode];
-
- d->wrapper[mode]->data = mimeData(mode);
- return d->wrapper[mode];
-}
-
-
-/*!
- \fn void QClipboard::setData(QMimeSource *src, Mode mode)
- \compat
-
- Use setMimeData() instead.
-*/
-void QClipboard::setData(QMimeSource *source, Mode mode)
-{
- Q_D(QClipboard);
-
- if (supportsMode(mode) == false)
- return;
-
- d->compat_data[mode] = source;
- setMimeData(new QMimeSourceWrapper(d, mode), mode);
-}
-#endif // QT3_SUPPORT
-
-/*!
- Returns true if the clipboard supports mouse selection; otherwise
- returns false.
-*/
-bool QClipboard::supportsSelection() const
-{
- return supportsMode(Selection);
-}
-
-/*!
- Returns true if the clipboard supports a separate search buffer; otherwise
- returns false.
-*/
-bool QClipboard::supportsFindBuffer() const
-{
- return supportsMode(FindBuffer);
-}
-
-/*!
- Returns true if this clipboard object owns the clipboard data;
- otherwise returns false.
-*/
-bool QClipboard::ownsClipboard() const
-{
- return ownsMode(Clipboard);
-}
-
-/*!
- Returns true if this clipboard object owns the mouse selection
- data; otherwise returns false.
-*/
-bool QClipboard::ownsSelection() const
-{
- return ownsMode(Selection);
-}
-
-/*!
- \since 4.2
-
- Returns true if this clipboard object owns the find buffer data;
- otherwise returns false.
-*/
-bool QClipboard::ownsFindBuffer() const
-{
- return ownsMode(FindBuffer);
-}
-
-/*!
- \internal
- \fn bool QClipboard::supportsMode(Mode mode) const;
- Returns true if the clipboard supports the clipboard mode speacified by \a mode;
- otherwise returns false.
-*/
-
-/*!
- \internal
- \fn bool QClipboard::ownsMode(Mode mode) const;
- Returns true if the clipboard supports the clipboard data speacified by \a mode;
- otherwise returns false.
-*/
-
-/*!
- \internal
- Emits the appropriate changed signal for \a mode.
-*/
-void QClipboard::emitChanged(Mode mode)
-{
- switch (mode) {
- case Clipboard:
- emit dataChanged();
- break;
- case Selection:
- emit selectionChanged();
- break;
- case FindBuffer:
- emit findBufferChanged();
- break;
- default:
- break;
- }
- emit changed(mode);
-}
-
-const char* QMimeDataWrapper::format(int n) const
-{
- if (formats.isEmpty()) {
- QStringList fmts = data->formats();
- for (int i = 0; i < fmts.size(); ++i)
- formats.append(fmts.at(i).toLatin1());
- }
- if (n < 0 || n >= formats.size())
- return 0;
- return formats.at(n).data();
-}
-
-QByteArray QMimeDataWrapper::encodedData(const char *format) const
-{
- if (QLatin1String(format) != QLatin1String("application/x-qt-image")){
- return data->data(QLatin1String(format));
- } else{
- QVariant variant = data->imageData();
- QImage img = qvariant_cast<QImage>(variant);
- QByteArray ba;
- QBuffer buffer(&ba);
- buffer.open(QIODevice::WriteOnly);
- img.save(&buffer, "PNG");
- return ba;
- }
-}
-
-QVariant QMimeSourceWrapper::retrieveData(const QString &mimetype, QVariant::Type) const
-{
- return source->encodedData(mimetype.toLatin1());
-}
-
-bool QMimeSourceWrapper::hasFormat(const QString &mimetype) const
-{
- return source->provides(mimetype.toLatin1());
-}
-
-QStringList QMimeSourceWrapper::formats() const
-{
- QStringList fmts;
- int i = 0;
- const char *fmt;
- while ((fmt = source->format(i))) {
- fmts.append(QLatin1String(fmt));
- ++i;
- }
- return fmts;
-}
-
-#endif // QT_NO_CLIPBOARD
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qclipboard.h b/src/gui/kernel/qclipboard.h
deleted file mode 100644
index 019917e5cd..0000000000
--- a/src/gui/kernel/qclipboard.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QCLIPBOARD_H
-#define QCLIPBOARD_H
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_CLIPBOARD
-
-class QMimeSource;
-class QMimeData;
-class QImage;
-class QPixmap;
-
-class QClipboardPrivate;
-
-class Q_GUI_EXPORT QClipboard : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QClipboard)
-private:
- QClipboard(QObject *parent);
- ~QClipboard();
-
-public:
- enum Mode { Clipboard, Selection, FindBuffer, LastMode = FindBuffer };
-
- void clear(Mode mode = Clipboard);
-
- bool supportsSelection() const;
- bool supportsFindBuffer() const;
-
- bool ownsSelection() const;
- bool ownsClipboard() const;
- bool ownsFindBuffer() const;
-
- QString text(Mode mode = Clipboard) const;
- QString text(QString& subtype, Mode mode = Clipboard) const;
- void setText(const QString &, Mode mode = Clipboard);
-
-#ifdef QT3_SUPPORT
- QT3_SUPPORT QMimeSource *data(Mode mode = Clipboard) const;
- QT3_SUPPORT void setData(QMimeSource*, Mode mode = Clipboard);
-#endif
- const QMimeData *mimeData(Mode mode = Clipboard ) const;
- void setMimeData(QMimeData *data, Mode mode = Clipboard);
-
- QImage image(Mode mode = Clipboard) const;
- QPixmap pixmap(Mode mode = Clipboard) const;
- void setImage(const QImage &, Mode mode = Clipboard);
- void setPixmap(const QPixmap &, Mode mode = Clipboard);
-
-Q_SIGNALS:
- void changed(QClipboard::Mode mode);
- void selectionChanged();
- void findBufferChanged();
- void dataChanged();
-private Q_SLOTS:
- void ownerDestroyed();
-
-protected:
- void connectNotify(const char *);
- bool event(QEvent *);
-
- friend class QApplication;
- friend class QApplicationPrivate;
- friend class QBaseApplication;
- friend class QDragManager;
- friend class QMimeSource;
- friend class QPlatformClipboard;
-
-private:
- Q_DISABLE_COPY(QClipboard)
-
- bool supportsMode(Mode mode) const;
- bool ownsMode(Mode mode) const;
- void emitChanged(Mode mode);
-};
-
-#endif // QT_NO_CLIPBOARD
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QCLIPBOARD_H
diff --git a/src/gui/kernel/qclipboard_qpa.cpp b/src/gui/kernel/qclipboard_qpa.cpp
deleted file mode 100644
index b8ce60e00d..0000000000
--- a/src/gui/kernel/qclipboard_qpa.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qclipboard.h"
-
-#ifndef QT_NO_CLIPBOARD
-
-#include "qmimedata.h"
-#include "private/qapplication_p.h"
-#include "qplatformclipboard_qpa.h"
-
-QT_BEGIN_NAMESPACE
-
-QT_USE_NAMESPACE
-
-void QClipboard::clear(Mode mode)
-{
- setMimeData(0,mode);
-}
-
-
-bool QClipboard::event(QEvent *e)
-{
- return QObject::event(e);
-}
-
-const QMimeData* QClipboard::mimeData(Mode mode) const
-{
- QPlatformClipboard *clipboard = QApplicationPrivate::platformIntegration()->clipboard();
- if (!clipboard->supportsMode(mode)) return 0;
- return clipboard->mimeData(mode);
-}
-
-void QClipboard::setMimeData(QMimeData* src, Mode mode)
-{
- QPlatformClipboard *clipboard = QApplicationPrivate::platformIntegration()->clipboard();
- if (!clipboard->supportsMode(mode)) return;
-
- clipboard->setMimeData(src,mode);
-
- emitChanged(mode);
-}
-
-bool QClipboard::supportsMode(Mode mode) const
-{
- QPlatformClipboard *clipboard = QApplicationPrivate::platformIntegration()->clipboard();
- return clipboard->supportsMode(mode);
-}
-
-bool QClipboard::ownsMode(Mode mode) const
-{
- if (mode == Clipboard)
- qWarning("QClipboard::ownsClipboard: UNIMPLEMENTED!");
- return false;
-}
-
-void QClipboard::connectNotify( const char * )
-{
-}
-
-void QClipboard::ownerDestroyed()
-{
-}
-
-#endif // QT_NO_CLIPBOARD
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qclipboard_qws.cpp b/src/gui/kernel/qclipboard_qws.cpp
deleted file mode 100644
index d50b412215..0000000000
--- a/src/gui/kernel/qclipboard_qws.cpp
+++ /dev/null
@@ -1,304 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qclipboard.h"
-
-#ifndef QT_NO_CLIPBOARD
-
-#include "qapplication.h"
-#include "qbitmap.h"
-#include "qdatetime.h"
-#include "qbuffer.h"
-#include "qwidget.h"
-#include "qevent.h"
-
-#include <qwsdisplay_qws.h>
-#include <qwsproperty_qws.h>
-#include <qwsevent_qws.h>
-
-QT_BEGIN_NAMESPACE
-
-QT_USE_NAMESPACE
-
-
-/*****************************************************************************
- Internal QClipboard functions for Qt for Embedded Linux
- *****************************************************************************/
-
-static const int TextClipboard=424242;
-static bool init = false;
-
-static inline void qwsInitClipboard()
-{
- //### this should go into QWSServer; it only needs to happen once.
- if( !init ) {
- QPaintDevice::qwsDisplay()->addProperty(0, TextClipboard);
- init = true;
- }
-}
-
-static QString qwsClipboardText()
-{
- char * data;
- int len;
- qwsInitClipboard();
- if( !QPaintDevice::qwsDisplay()->getProperty(0, TextClipboard, data, len) ) {
-// qDebug("Property received: %d bytes", len);
- }
-
- QString s((const QChar*)data, len/sizeof(QChar));
- // qDebug("Property received: '%s'", s.toAscii().constData());
- delete[] data;
- return s;
-}
-
-
-static void qwsSetClipboardText(const QString& s)
-{
- qwsInitClipboard();
- // qDebug("qwsSetClipboardText( %s )", s.toAscii().data());
- int len = s.length()*sizeof(QChar);
- QByteArray ba((const char*)s.unicode(), len);
- QPaintDevice::qwsDisplay()->
- setProperty(0, TextClipboard, QWSPropertyManager::PropReplace, ba);
-
-}
-
-class QClipboardData
-{
-public:
- QClipboardData();
- ~QClipboardData();
-
- void setSource(QMimeData* s)
- {
- if (s == src)
- return;
- delete src;
- src = s;
- }
- QMimeData* source()
- { return src; }
-#if 0
- void addTransferredPixmap(QPixmap pm)
- { /* TODO: queue them */
- transferred[tindex] = pm;
- tindex=(tindex+1)%2;
- }
- void clearTransfers()
- {
- transferred[0] = QPixmap();
- transferred[1] = QPixmap();
- }
-#endif
-
- void clear();
-
-private:
- QMimeData* src;
-
-#if 0
- QPixmap transferred[2];
- int tindex;
-#endif
-};
-
-QClipboardData::QClipboardData()
-{
- src = 0;
-#if 0
- tindex=0;
-#endif
-}
-
-QClipboardData::~QClipboardData()
-{
- delete src;
-}
-
-void QClipboardData::clear()
-{
- delete src;
- src = 0;
-}
-
-
-static QClipboardData *internalCbData = 0;
-
-static void cleanupClipboardData()
-{
- delete internalCbData;
- internalCbData = 0;
-}
-
-static QClipboardData *clipboardData()
-{
- if (internalCbData == 0) {
- internalCbData = new QClipboardData;
- qAddPostRoutine(cleanupClipboardData);
- }
- return internalCbData;
-}
-
-
-/*****************************************************************************
- QClipboard member functions for FB.
- *****************************************************************************/
-
-#if 0
-
-QString QClipboard::text() const
-{
- return qwsClipboardText();
-}
-
-void QClipboard::setText(const QString &text)
-{
- qwsSetClipboardText(text);
-}
-
-QString QClipboard::text(QString& subtype) const
-{
- QString r;
- if (subtype == "plain")
- r = text();
- return r;
-}
-
-#endif
-
-void QClipboard::clear(Mode mode)
-{
- setText(QString(), mode);
-}
-
-
-bool QClipboard::event(QEvent *e)
-{
- static bool recursionWatch = false;
- if (e->type() != QEvent::Clipboard || recursionWatch)
- return QObject::event(e);
-
- recursionWatch = true;
- QWSPropertyNotifyEvent *event = (QWSPropertyNotifyEvent *)(((QClipboardEvent *)e)->data());
- if (event && event->simpleData.state == QWSPropertyNotifyEvent::PropertyNewValue) {
- QClipboardData *d = clipboardData();
- QString t = qwsClipboardText();
- if( (d->source() == 0 && !t.isEmpty()) || (d->source() != 0 && d->source()->text() != t) ) {
- if( !d->source() )
- d->setSource(new QMimeData);
- d->source()->setText( t );
- emitChanged(QClipboard::Clipboard);
- }
- }
-
- recursionWatch = false;
- return true;
-}
-
-const QMimeData* QClipboard::mimeData(Mode mode) const
-{
- if (mode != Clipboard) return 0;
-
- QClipboardData *d = clipboardData();
- // Try and get data from QWSProperty if no mime data has been set on us.
- if( !d->source() ) {
- QString t = qwsClipboardText();
- if( !t.isEmpty() ) {
- QMimeData* nd = new QMimeData;
- nd->setText( t );
- d->setSource( nd );
- }
- }
- return d->source();
-}
-
-void QClipboard::setMimeData(QMimeData* src, Mode mode)
-{
- if (mode != Clipboard) return;
-
- QClipboardData *d = clipboardData();
-
- /* Propagate text data to other QWSClients */
-
- QString newText;
- if( src != 0 )
- newText = src->text();
- QString oldText;
- if( d->source() != 0 )
- oldText = d->source()->text();
-
- d->setSource(src);
-
- if( oldText != newText ) {
- if( d->source() == 0 ) {
- qwsSetClipboardText( QString() );
- } else {
- qwsSetClipboardText( d->source()->text() );
- }
- }
-
- emitChanged(QClipboard::Clipboard);
-}
-
-bool QClipboard::supportsMode(Mode mode) const
-{
- return (mode == Clipboard);
-}
-
-bool QClipboard::ownsMode(Mode mode) const
-{
- if (mode == Clipboard)
- qWarning("QClipboard::ownsClipboard: UNIMPLEMENTED!");
- return false;
-}
-
-void QClipboard::connectNotify( const char * )
-{
-}
-
-void QClipboard::ownerDestroyed()
-{
-}
-
-#endif // QT_NO_CLIPBOARD
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qcursor.cpp b/src/gui/kernel/qcursor.cpp
deleted file mode 100644
index 823f6f1e8c..0000000000
--- a/src/gui/kernel/qcursor.cpp
+++ /dev/null
@@ -1,573 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qcursor.h"
-
-#ifndef QT_NO_CURSOR
-
-#include <qapplication.h>
-#include <qbitmap.h>
-#include <qimage.h>
-#include <qdatastream.h>
-#include <qvariant.h>
-#include <private/qcursor_p.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QCursor
-
- \brief The QCursor class provides a mouse cursor with an arbitrary
- shape.
-
- \ingroup appearance
- \ingroup shared
-
-
- This class is mainly used to create mouse cursors that are
- associated with particular widgets and to get and set the position
- of the mouse cursor.
-
- Qt has a number of standard cursor shapes, but you can also make
- custom cursor shapes based on a QBitmap, a mask and a hotspot.
-
- To associate a cursor with a widget, use QWidget::setCursor(). To
- associate a cursor with all widgets (normally for a short period
- of time), use QApplication::setOverrideCursor().
-
- To set a cursor shape use QCursor::setShape() or use the QCursor
- constructor which takes the shape as argument, or you can use one
- of the predefined cursors defined in the \l Qt::CursorShape enum.
-
- If you want to create a cursor with your own bitmap, either use
- the QCursor constructor which takes a bitmap and a mask or the
- constructor which takes a pixmap as arguments.
-
- To set or get the position of the mouse cursor use the static
- methods QCursor::pos() and QCursor::setPos().
-
- \bold{Note:} It is possible to create a QCursor before
- QApplication, but it is not useful except as a place-holder for a
- real QCursor created after QApplication. Attempting to use a
- QCursor that was created before QApplication will result in a
- crash.
-
- \section1 A Note for X11 Users
-
- On X11, Qt supports the \link
- http://www.xfree86.org/4.3.0/Xcursor.3.html Xcursor\endlink
- library, which allows for full color icon themes. The table below
- shows the cursor name used for each Qt::CursorShape value. If a
- cursor cannot be found using the name shown below, a standard X11
- cursor will be used instead. Note: X11 does not provide
- appropriate cursors for all possible Qt::CursorShape values. It
- is possible that some cursors will be taken from the Xcursor
- theme, while others will use an internal bitmap cursor.
-
- \table
- \header \o Shape \o Qt::CursorShape Value \o Cursor Name
- \o Shape \o Qt::CursorShape Value \o Cursor Name
- \row \o \inlineimage cursor-arrow.png
- \o Qt::ArrowCursor \o \c left_ptr
- \o \inlineimage cursor-sizev.png
- \o Qt::SizeVerCursor \o \c size_ver
- \row \o \inlineimage cursor-uparrow.png
- \o Qt::UpArrowCursor \o \c up_arrow
- \o \inlineimage cursor-sizeh.png
- \o Qt::SizeHorCursor \o \c size_hor
- \row \o \inlineimage cursor-cross.png
- \o Qt::CrossCursor \o \c cross
- \o \inlineimage cursor-sizeb.png
- \o Qt::SizeBDiagCursor \o \c size_bdiag
- \row \o \inlineimage cursor-ibeam.png
- \o Qt::IBeamCursor \o \c ibeam
- \o \inlineimage cursor-sizef.png
- \o Qt::SizeFDiagCursor \o \c size_fdiag
- \row \o \inlineimage cursor-wait.png
- \o Qt::WaitCursor \o \c wait
- \o \inlineimage cursor-sizeall.png
- \o Qt::SizeAllCursor \o \c size_all
- \row \o \inlineimage cursor-busy.png
- \o Qt::BusyCursor \o \c left_ptr_watch
- \o \inlineimage cursor-vsplit.png
- \o Qt::SplitVCursor \o \c split_v
- \row \o \inlineimage cursor-forbidden.png
- \o Qt::ForbiddenCursor \o \c forbidden
- \o \inlineimage cursor-hsplit.png
- \o Qt::SplitHCursor \o \c split_h
- \row \o \inlineimage cursor-hand.png
- \o Qt::PointingHandCursor \o \c pointing_hand
- \o \inlineimage cursor-openhand.png
- \o Qt::OpenHandCursor \o \c openhand
- \row \o \inlineimage cursor-whatsthis.png
- \o Qt::WhatsThisCursor \o \c whats_this
- \o \inlineimage cursor-closedhand.png
- \o Qt::ClosedHandCursor \o \c closedhand
- \row \o
- \o Qt::DragMoveCursor \o \c dnd-move or \c move
- \o
- \o Qt::DragCopyCursor \o \c dnd-copy or \c copy
- \row \o
- \o Qt::DragLinkCursor \o \c dnd-link or \c link
- \endtable
-
- \sa QWidget, {fowler}{GUI Design Handbook: Cursors}
-*/
-
-/*!
- \fn HCURSOR_or_HANDLE QCursor::handle() const
-
- Returns a platform-specific cursor handle. The \c
- HCURSOR_or_HANDLE type is \c HCURSOR on Windows and Qt::HANDLE on X11
- and Mac OS X. On \l{Qt for Embedded Linux} it is an integer.
-
- \warning Using the value returned by this function is not
- portable.
-*/
-
-/*!
- \fn QCursor::QCursor(HCURSOR cursor)
-
- Constructs a Qt cursor from the given Windows \a cursor.
-
- \warning This function is only available on Windows.
-
- \sa handle()
-*/
-
-/*!
- \fn QCursor::QCursor(Qt::HANDLE handle)
-
- Constructs a Qt cursor from the given \a handle.
-
- \warning This function is only available on X11.
-
- \sa handle()
-*/
-
-/*!
- \fn QPoint QCursor::pos()
-
- Returns the position of the cursor (hot spot) in global screen
- coordinates.
-
- You can call QWidget::mapFromGlobal() to translate it to widget
- coordinates.
-
- \sa setPos(), QWidget::mapFromGlobal(), QWidget::mapToGlobal()
-*/
-
-/*!
- \fn void QCursor::setPos(int x, int y)
-
- Moves the cursor (hot spot) to the global screen position (\a x,
- \a y).
-
- You can call QWidget::mapToGlobal() to translate widget
- coordinates to global screen coordinates.
-
- \sa pos(), QWidget::mapFromGlobal(), QWidget::mapToGlobal()
-*/
-
-/*!
- \fn void QCursor::setPos (const QPoint &p)
-
- \overload
-
- Moves the cursor (hot spot) to the global screen position at point
- \a p.
-*/
-
-/*****************************************************************************
- QCursor stream functions
- *****************************************************************************/
-
-#ifndef QT_NO_DATASTREAM
-
-
-/*!
- \fn QDataStream &operator<<(QDataStream &stream, const QCursor &cursor)
- \relates QCursor
-
- Writes the \a cursor to the \a stream.
-
- \sa {Serializing Qt Data Types}
-*/
-
-QDataStream &operator<<(QDataStream &s, const QCursor &c)
-{
- s << (qint16)c.shape(); // write shape id to stream
- if (c.shape() == Qt::BitmapCursor) { // bitmap cursor
- bool isPixmap = false;
- if (s.version() >= 7) {
- isPixmap = !c.pixmap().isNull();
- s << isPixmap;
- }
- if (isPixmap)
- s << c.pixmap();
- else
- s << *c.bitmap() << *c.mask();
- s << c.hotSpot();
- }
- return s;
-}
-
-/*!
- \fn QDataStream &operator>>(QDataStream &stream, QCursor &cursor)
- \relates QCursor
-
- Reads the \a cursor from the \a stream.
-
- \sa {Serializing Qt Data Types}
-*/
-
-QDataStream &operator>>(QDataStream &s, QCursor &c)
-{
- qint16 shape;
- s >> shape; // read shape id from stream
- if (shape == Qt::BitmapCursor) { // read bitmap cursor
- bool isPixmap = false;
- if (s.version() >= 7)
- s >> isPixmap;
- if (isPixmap) {
- QPixmap pm;
- QPoint hot;
- s >> pm >> hot;
- c = QCursor(pm, hot.x(), hot.y());
- } else {
- QBitmap bm, bmm;
- QPoint hot;
- s >> bm >> bmm >> hot;
- c = QCursor(bm, bmm, hot.x(), hot.y());
- }
- } else {
- c.setShape((Qt::CursorShape)shape); // create cursor with shape
- }
- return s;
-}
-#endif // QT_NO_DATASTREAM
-
-
-/*!
- Constructs a custom pixmap cursor.
-
- \a pixmap is the image. It is usual to give it a mask (set using
- QPixmap::setMask()). \a hotX and \a hotY define the cursor's hot
- spot.
-
- If \a hotX is negative, it is set to the \c{pixmap().width()/2}.
- If \a hotY is negative, it is set to the \c{pixmap().height()/2}.
-
- Valid cursor sizes depend on the display hardware (or the
- underlying window system). We recommend using 32 x 32 cursors,
- because this size is supported on all platforms. Some platforms
- also support 16 x 16, 48 x 48, and 64 x 64 cursors.
-
- \note On Windows CE, the cursor size is fixed. If the pixmap
- is bigger than the system size, it will be scaled.
-
- \sa QPixmap::QPixmap(), QPixmap::setMask()
-*/
-
-QCursor::QCursor(const QPixmap &pixmap, int hotX, int hotY)
- : d(0)
-{
- QImage img = pixmap.toImage().convertToFormat(QImage::Format_Indexed8, Qt::ThresholdDither|Qt::AvoidDither);
- QBitmap bm = QBitmap::fromImage(img, Qt::ThresholdDither|Qt::AvoidDither);
- QBitmap bmm = pixmap.mask();
- if (!bmm.isNull()) {
- QBitmap nullBm;
- bm.setMask(nullBm);
- }
- else if (!pixmap.mask().isNull()) {
- QImage mimg = pixmap.mask().toImage().convertToFormat(QImage::Format_Indexed8, Qt::ThresholdDither|Qt::AvoidDither);
- bmm = QBitmap::fromImage(mimg, Qt::ThresholdDither|Qt::AvoidDither);
- }
- else {
- bmm = QBitmap(bm.size());
- bmm.fill(Qt::color1);
- }
-
- d = QCursorData::setBitmap(bm, bmm, hotX, hotY);
- d->pixmap = pixmap;
-}
-
-
-
-/*!
- Constructs a custom bitmap cursor.
-
- \a bitmap and
- \a mask make up the bitmap.
- \a hotX and
- \a hotY define the cursor's hot spot.
-
- If \a hotX is negative, it is set to the \c{bitmap().width()/2}.
- If \a hotY is negative, it is set to the \c{bitmap().height()/2}.
-
- The cursor \a bitmap (B) and \a mask (M) bits are combined like this:
- \list
- \o B=1 and M=1 gives black.
- \o B=0 and M=1 gives white.
- \o B=0 and M=0 gives transparent.
- \o B=1 and M=0 gives an XOR'd result under Windows, undefined
- results on all other platforms.
- \endlist
-
- Use the global Qt color Qt::color0 to draw 0-pixels and Qt::color1 to
- draw 1-pixels in the bitmaps.
-
- Valid cursor sizes depend on the display hardware (or the
- underlying window system). We recommend using 32 x 32 cursors,
- because this size is supported on all platforms. Some platforms
- also support 16 x 16, 48 x 48, and 64 x 64 cursors.
-
- \note On Windows CE, the cursor size is fixed. If the pixmap
- is bigger than the system size, it will be scaled.
-
- \sa QBitmap::QBitmap(), QBitmap::setMask()
-*/
-
-QCursor::QCursor(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY)
- : d(0)
-{
- d = QCursorData::setBitmap(bitmap, mask, hotX, hotY);
-}
-
-QCursorData *qt_cursorTable[Qt::LastCursor + 1];
-bool QCursorData::initialized = false;
-
-/*! \internal */
-void QCursorData::cleanup()
-{
- if(!QCursorData::initialized)
- return;
-
- for (int shape = 0; shape <= Qt::LastCursor; ++shape) {
- // In case someone has a static QCursor defined with this shape
- if (!qt_cursorTable[shape]->ref.deref())
- delete qt_cursorTable[shape];
- qt_cursorTable[shape] = 0;
- }
- QCursorData::initialized = false;
-}
-
-/*! \internal */
-void QCursorData::initialize()
-{
- if (QCursorData::initialized)
- return;
-#ifdef Q_WS_MAC
- // DRSWAT - Not Needed Cocoa or Carbon
- //InitCursor();
-#endif
- for (int shape = 0; shape <= Qt::LastCursor; ++shape)
- qt_cursorTable[shape] = new QCursorData((Qt::CursorShape)shape);
- QCursorData::initialized = true;
-}
-
-/*!
- Constructs a cursor with the default arrow shape.
-*/
-QCursor::QCursor()
-{
- if (!QCursorData::initialized) {
- if (QApplication::startingUp()) {
- d = 0;
- return;
- }
- QCursorData::initialize();
- }
- QCursorData *c = qt_cursorTable[0];
- c->ref.ref();
- d = c;
-}
-
-/*!
- Constructs a cursor with the specified \a shape.
-
- See \l Qt::CursorShape for a list of shapes.
-
- \sa setShape()
-*/
-QCursor::QCursor(Qt::CursorShape shape)
- : d(0)
-{
- if (!QCursorData::initialized)
- QCursorData::initialize();
- setShape(shape);
-}
-
-
-/*!
- Returns the cursor shape identifier. The return value is one of
- the \l Qt::CursorShape enum values (cast to an int).
-
- \sa setShape()
-*/
-Qt::CursorShape QCursor::shape() const
-{
- if (!QCursorData::initialized)
- QCursorData::initialize();
- return d->cshape;
-}
-
-/*!
- Sets the cursor to the shape identified by \a shape.
-
- See \l Qt::CursorShape for the list of cursor shapes.
-
- \sa shape()
-*/
-void QCursor::setShape(Qt::CursorShape shape)
-{
- if (!QCursorData::initialized)
- QCursorData::initialize();
- QCursorData *c = uint(shape) <= Qt::LastCursor ? qt_cursorTable[shape] : 0;
- if (!c)
- c = qt_cursorTable[0];
- c->ref.ref();
- if (!d) {
- d = c;
- } else {
- if (!d->ref.deref())
- delete d;
- d = c;
- }
-}
-
-/*!
- Returns the cursor bitmap, or 0 if it is one of the standard
- cursors.
-*/
-const QBitmap *QCursor::bitmap() const
-{
- if (!QCursorData::initialized)
- QCursorData::initialize();
- return d->bm;
-}
-
-/*!
- Returns the cursor bitmap mask, or 0 if it is one of the standard
- cursors.
-*/
-
-const QBitmap *QCursor::mask() const
-{
- if (!QCursorData::initialized)
- QCursorData::initialize();
- return d->bmm;
-}
-
-/*!
- Returns the cursor pixmap. This is only valid if the cursor is a
- pixmap cursor.
-*/
-
-QPixmap QCursor::pixmap() const
-{
- if (!QCursorData::initialized)
- QCursorData::initialize();
- return d->pixmap;
-}
-
-/*!
- Returns the cursor hot spot, or (0, 0) if it is one of the
- standard cursors.
-*/
-
-QPoint QCursor::hotSpot() const
-{
- if (!QCursorData::initialized)
- QCursorData::initialize();
- return QPoint(d->hx, d->hy);
-}
-
-/*!
- Constructs a copy of the cursor \a c.
-*/
-
-QCursor::QCursor(const QCursor &c)
-{
- if (!QCursorData::initialized)
- QCursorData::initialize();
- d = c.d;
- d->ref.ref();
-}
-
-/*!
- Destroys the cursor.
-*/
-
-QCursor::~QCursor()
-{
- if (d && !d->ref.deref())
- delete d;
-}
-
-
-/*!
- Assigns \a c to this cursor and returns a reference to this
- cursor.
-*/
-
-QCursor &QCursor::operator=(const QCursor &c)
-{
- if (!QCursorData::initialized)
- QCursorData::initialize();
- if (c.d)
- c.d->ref.ref();
- if (d && !d->ref.deref())
- delete d;
- d = c.d;
- return *this;
-}
-
-/*!
- Returns the cursor as a QVariant.
-*/
-QCursor::operator QVariant() const
-{
- return QVariant(QVariant::Cursor, this);
-}
-QT_END_NAMESPACE
-#endif // QT_NO_CURSOR
-
diff --git a/src/gui/kernel/qcursor.h b/src/gui/kernel/qcursor.h
deleted file mode 100644
index c993763634..0000000000
--- a/src/gui/kernel/qcursor.h
+++ /dev/null
@@ -1,180 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QCURSOR_H
-#define QCURSOR_H
-
-#include <QtCore/qpoint.h>
-#include <QtGui/qwindowdefs.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QVariant;
-
-/*
- ### The fake cursor has to go first with old qdoc.
-*/
-#ifdef QT_NO_CURSOR
-
-class Q_GUI_EXPORT QCursor
-{
-public:
- static QPoint pos();
- static void setPos(int x, int y);
- inline static void setPos(const QPoint &p) { setPos(p.x(), p.y()); }
-private:
- QCursor();
-};
-
-#endif // QT_NO_CURSOR
-
-#ifndef QT_NO_CURSOR
-
-class QCursorData;
-class QBitmap;
-class QPixmap;
-
-#if defined(Q_WS_MAC)
-void qt_mac_set_cursor(const QCursor *c);
-#endif
-#if defined(Q_OS_SYMBIAN)
-extern void qt_symbian_show_pointer_sprite();
-extern void qt_symbian_hide_pointer_sprite();
-extern void qt_symbian_set_pointer_sprite(const QCursor& cursor);
-extern void qt_symbian_move_cursor_sprite();
-#endif
-
-class Q_GUI_EXPORT QCursor
-{
-public:
- QCursor();
- QCursor(Qt::CursorShape shape);
- QCursor(const QBitmap &bitmap, const QBitmap &mask, int hotX=-1, int hotY=-1);
- QCursor(const QPixmap &pixmap, int hotX=-1, int hotY=-1);
- QCursor(const QCursor &cursor);
- ~QCursor();
- QCursor &operator=(const QCursor &cursor);
-#ifdef Q_COMPILER_RVALUE_REFS
- inline QCursor &operator=(QCursor &&other)
- { qSwap(d, other.d); return *this; }
-#endif
- operator QVariant() const;
-
- Qt::CursorShape shape() const;
- void setShape(Qt::CursorShape newShape);
-
- const QBitmap *bitmap() const;
- const QBitmap *mask() const;
- QPixmap pixmap() const;
- QPoint hotSpot() const;
-
- static QPoint pos();
- static void setPos(int x, int y);
- inline static void setPos(const QPoint &p) { setPos(p.x(), p.y()); }
-
-#ifdef qdoc
- HCURSOR_or_HANDLE handle() const;
- QCursor(HCURSOR cursor);
- QCursor(Qt::HANDLE cursor);
-#endif
-
-#ifndef qdoc
-#if defined(Q_WS_WIN)
- HCURSOR handle() const;
- QCursor(HCURSOR cursor);
-#elif defined(Q_WS_X11)
- Qt::HANDLE handle() const;
- QCursor(Qt::HANDLE cursor);
- static int x11Screen();
-#elif defined(Q_WS_MAC)
- Qt::HANDLE handle() const;
-#elif defined(Q_WS_QWS) || defined(Q_WS_QPA)
- int handle() const;
-#elif defined(Q_OS_SYMBIAN)
- Qt::HANDLE handle() const;
-#endif
-#endif
-
-private:
- QCursorData *d;
-#if defined(Q_WS_MAC)
- friend void *qt_mac_nsCursorForQCursor(const QCursor &c);
- friend void qt_mac_set_cursor(const QCursor *c);
- friend void qt_mac_updateCursorWithWidgetUnderMouse(QWidget *widgetUnderMouse);
-#endif
-#if defined(Q_OS_SYMBIAN)
- friend void qt_symbian_show_pointer_sprite();
- friend void qt_symbian_hide_pointer_sprite();
- friend void qt_symbian_set_pointer_sprite(const QCursor& cursor);
- friend void qt_symbian_move_cursor_sprite();
-#endif
-};
-
-#ifdef QT3_SUPPORT
-// CursorShape is defined in X11/X.h
-#ifdef CursorShape
-#define X_CursorShape CursorShape
-#undef CursorShape
-#endif
-typedef Qt::CursorShape QCursorShape;
-#ifdef X_CursorShape
-#define CursorShape X_CursorShape
-#endif
-#endif
-
-/*****************************************************************************
- QCursor stream functions
- *****************************************************************************/
-#ifndef QT_NO_DATASTREAM
-Q_GUI_EXPORT QDataStream &operator<<(QDataStream &outS, const QCursor &cursor);
-Q_GUI_EXPORT QDataStream &operator>>(QDataStream &inS, QCursor &cursor);
-#endif
-#endif // QT_NO_CURSOR
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QCURSOR_H
diff --git a/src/gui/kernel/qcursor_qws.cpp b/src/gui/kernel/qcursor_qws.cpp
deleted file mode 100644
index 60674c9507..0000000000
--- a/src/gui/kernel/qcursor_qws.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qcursor.h>
-#include <private/qcursor_p.h>
-#include <qbitmap.h>
-#include <qwsdisplay_qws.h>
-
-QT_BEGIN_NAMESPACE
-
-QT_USE_NAMESPACE
-
-#ifndef QT_NO_CURSOR
-
-static int nextCursorId = Qt::BitmapCursor;
-
-/*****************************************************************************
- Internal QCursorData class
- *****************************************************************************/
-
-QCursorData::QCursorData(Qt::CursorShape s)
- : cshape(s), bm(0), bmm(0), hx(0), hy(0), id(s)
-{
- ref = 1;
-}
-
-QCursorData::~QCursorData()
-{
- delete bm;
- delete bmm;
- QT_TRY {
- QPaintDevice::qwsDisplay()->destroyCursor(id);
- } QT_CATCH(const std::bad_alloc &) {
- // do nothing.
- }
-}
-
-
-/*****************************************************************************
- Global cursors
- *****************************************************************************/
-
-int QCursor::handle() const
-{
- return d->id;
-}
-
-
-QCursorData *QCursorData::setBitmap(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY)
-{
- if (!QCursorData::initialized)
- QCursorData::initialize();
- if (bitmap.depth() != 1 || mask.depth() != 1 || bitmap.size() != mask.size()) {
- qWarning("QCursor: Cannot create bitmap cursor; invalid bitmap(s)");
- QCursorData *c = qt_cursorTable[0];
- c->ref.ref();
- return c;
- }
- QCursorData *d = new QCursorData;
- d->bm = new QBitmap(bitmap);
- d->bmm = new QBitmap(mask);
- d->cshape = Qt::BitmapCursor;
- d->id = ++nextCursorId;
- d->hx = hotX >= 0 ? hotX : bitmap.width() / 2;
- d->hy = hotY >= 0 ? hotY : bitmap.height() / 2;
-
- QPaintDevice::qwsDisplay()->defineCursor(d->id, *d->bm, *d->bmm, d->hx, d->hy);
- return d;
-}
-
-void QCursorData::update()
-{
-}
-
-#endif //QT_NO_CURSOR
-
-extern int *qt_last_x,*qt_last_y;
-
-QPoint QCursor::pos()
-{
- // This doesn't know about hotspots yet so we disable it
- //qt_accel_update_cursor();
- if (qt_last_x)
- return QPoint(*qt_last_x, *qt_last_y);
- else
- return QPoint();
-}
-
-void QCursor::setPos(int x, int y)
-{
- // Need to check, since some X servers generate null mouse move
- // events, causing looping in applications which call setPos() on
- // every mouse move event.
- //
- if (pos() == QPoint(x, y))
- return;
- QPaintDevice::qwsDisplay()->setCursorPosition(x, y);
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qdesktopwidget.h b/src/gui/kernel/qdesktopwidget.h
deleted file mode 100644
index deb896029a..0000000000
--- a/src/gui/kernel/qdesktopwidget.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDESKTOPWIDGET_H
-#define QDESKTOPWIDGET_H
-
-#include <QtGui/qwidget.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QApplication;
-class QDesktopWidgetPrivate;
-
-class Q_GUI_EXPORT QDesktopWidget : public QWidget
-{
- Q_OBJECT
- Q_PROPERTY(bool virtualDesktop READ isVirtualDesktop)
- Q_PROPERTY(int screenCount READ screenCount NOTIFY screenCountChanged)
- Q_PROPERTY(int primaryScreen READ primaryScreen)
-public:
- QDesktopWidget();
- ~QDesktopWidget();
-
- bool isVirtualDesktop() const;
-
- int numScreens() const;
- int screenCount() const;
- int primaryScreen() const;
-
- int screenNumber(const QWidget *widget = 0) const;
- int screenNumber(const QPoint &) const;
-
- QWidget *screen(int screen = -1);
-
- const QRect screenGeometry(int screen = -1) const;
- const QRect screenGeometry(const QWidget *widget) const;
- const QRect screenGeometry(const QPoint &point) const
- { return screenGeometry(screenNumber(point)); }
-
- const QRect availableGeometry(int screen = -1) const;
- const QRect availableGeometry(const QWidget *widget) const;
- const QRect availableGeometry(const QPoint &point) const
- { return availableGeometry(screenNumber(point)); }
-
-Q_SIGNALS:
- void resized(int);
- void workAreaResized(int);
- void screenCountChanged(int);
-
-protected:
- void resizeEvent(QResizeEvent *e);
-
-private:
- Q_DISABLE_COPY(QDesktopWidget)
- Q_DECLARE_PRIVATE(QDesktopWidget)
-
- friend class QApplication;
- friend class QApplicationPrivate;
-};
-
-inline int QDesktopWidget::screenCount() const
-{ return numScreens(); }
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDESKTOPWIDGET_H
diff --git a/src/gui/kernel/qdesktopwidget_qpa.cpp b/src/gui/kernel/qdesktopwidget_qpa.cpp
deleted file mode 100644
index 6257a8bc06..0000000000
--- a/src/gui/kernel/qdesktopwidget_qpa.cpp
+++ /dev/null
@@ -1,176 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdesktopwidget.h"
-#include "private/qapplication_p.h"
-#include "private/qgraphicssystem_p.h"
-#include <QWidget>
-#include "private/qwidget_p.h"
-#include "private/qdesktopwidget_qpa_p.h"
-QT_BEGIN_NAMESPACE
-
-QT_USE_NAMESPACE
-
-void QDesktopWidgetPrivate::updateScreenList()
-{
- Q_Q(QDesktopWidget);
-
- QList<QPlatformScreen *> screenList = QApplicationPrivate::platformIntegration()->screens();
- int targetLength = screenList.length();
- int currentLength = screens.length();
-
- // Add or remove screen widgets as necessary
- if(currentLength > targetLength) {
- QDesktopScreenWidget *screen;
- while (currentLength-- > targetLength) {
- screen = screens.takeLast();
- delete screen;
- }
- }
- else if (currentLength < targetLength) {
- QDesktopScreenWidget *screen;
- while (currentLength < targetLength) {
- screen = new QDesktopScreenWidget(currentLength++);
- screens.append(screen);
- }
- }
-
- QRegion virtualGeometry;
-
- // update the geometry of each screen widget
- for (int i = 0; i < screens.length(); i++) {
- QRect screenGeometry = screenList.at(i)->geometry();
- screens.at(i)->setGeometry(screenGeometry);
- virtualGeometry += screenGeometry;
- }
-
- q->setGeometry(virtualGeometry.boundingRect());
-}
-
-QDesktopWidget::QDesktopWidget()
- : QWidget(*new QDesktopWidgetPrivate, 0, Qt::Desktop)
-{
- Q_D(QDesktopWidget);
- setObjectName(QLatin1String("desktop"));
- d->updateScreenList();
-}
-
-QDesktopWidget::~QDesktopWidget()
-{
-}
-
-bool QDesktopWidget::isVirtualDesktop() const
-{
- return QApplicationPrivate::platformIntegration()->isVirtualDesktop();
-}
-
-int QDesktopWidget::primaryScreen() const
-{
- return 0;
-}
-
-int QDesktopWidget::numScreens() const
-{
- QPlatformIntegration *pi = QApplicationPrivate::platformIntegration();
- return qMax(pi->screens().size(), 1);
-}
-
-QWidget *QDesktopWidget::screen(int screen)
-{
- Q_D(QDesktopWidget);
- if (screen < 0 || screen >= d->screens.length())
- return d->screens.at(0);
- return d->screens.at(screen);
-}
-
-const QRect QDesktopWidget::availableGeometry(int screenNo) const
-{
- QPlatformIntegration *pi = QApplicationPrivate::platformIntegration();
- QList<QPlatformScreen *> screens = pi->screens();
- if (screenNo == -1)
- screenNo = 0;
- if (screenNo < 0 || screenNo >= screens.size())
- return QRect();
- else
- return screens[screenNo]->availableGeometry();
-}
-
-const QRect QDesktopWidget::screenGeometry(int screenNo) const
-{
- QPlatformIntegration *pi = QApplicationPrivate::platformIntegration();
- QList<QPlatformScreen *> screens = pi->screens();
- if (screenNo == -1)
- screenNo = 0;
- if (screenNo < 0 || screenNo >= screens.size())
- return QRect();
- else
- return screens[screenNo]->geometry();
-}
-
-int QDesktopWidget::screenNumber(const QWidget *w) const
-{
- if (!w)
- return 0;
-
- QRect frame = w->frameGeometry();
- if (!w->isWindow())
- frame.moveTopLeft(w->mapToGlobal(QPoint(0, 0)));
- const QPoint midpoint = (frame.topLeft() + frame.bottomRight()) / 2;
- return screenNumber(midpoint);
-}
-
-int QDesktopWidget::screenNumber(const QPoint &p) const
-{
- QPlatformIntegration *pi = QApplicationPrivate::platformIntegration();
- QList<QPlatformScreen *> screens = pi->screens();
-
- for (int i = 0; i < screens.size(); ++i)
- if (screens[i]->geometry().contains(p))
- return i;
-
- return primaryScreen(); //even better would be closest screen
-}
-
-void QDesktopWidget::resizeEvent(QResizeEvent *)
-{
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qdesktopwidget_qws.cpp b/src/gui/kernel/qdesktopwidget_qws.cpp
deleted file mode 100644
index 1e21845df6..0000000000
--- a/src/gui/kernel/qdesktopwidget_qws.cpp
+++ /dev/null
@@ -1,159 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdesktopwidget.h"
-#include "qscreen_qws.h"
-#include "private/qapplication_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QT_USE_NAMESPACE
-
-QDesktopWidget::QDesktopWidget()
- : QWidget(0, Qt::Desktop)
-{
- setObjectName(QLatin1String("desktop"));
-}
-
-QDesktopWidget::~QDesktopWidget()
-{
-}
-
-bool QDesktopWidget::isVirtualDesktop() const
-{
- return true;
-}
-
-int QDesktopWidget::primaryScreen() const
-{
- return 0;
-}
-
-int QDesktopWidget::numScreens() const
-{
- QScreen *screen = QScreen::instance();
- if (!screen)
- return 0;
-
- const QList<QScreen*> subScreens = screen->subScreens();
- return qMax(subScreens.size(), 1);
-}
-
-QWidget *QDesktopWidget::screen(int)
-{
- return this;
-}
-
-const QRect QDesktopWidget::availableGeometry(int screenNo) const
-{
- const QScreen *screen = QScreen::instance();
- if (screenNo == -1)
- screenNo = 0;
- if (!screen || screenNo < 0)
- return QRect();
-
- const QList<QScreen*> subScreens = screen->subScreens();
- if (!subScreens.isEmpty()) {
- if (screenNo >= subScreens.size())
- return QRect();
- screen = subScreens.at(screenNo);
- }
-
- QApplicationPrivate *ap = QApplicationPrivate::instance();
- const QRect r = ap->maxWindowRect(screen);
- if (!r.isEmpty())
- return r;
-
- return screen->region().boundingRect();
-}
-
-const QRect QDesktopWidget::screenGeometry(int screenNo) const
-{
- const QScreen *screen = QScreen::instance();
- if (screenNo == -1)
- screenNo = 0;
- if (!screen || screenNo < 0)
- return QRect();
-
- const QList<QScreen*> subScreens = screen->subScreens();
- if (subScreens.size() == 0 && screenNo == 0)
- return screen->region().boundingRect();
-
- if (screenNo >= subScreens.size())
- return QRect();
-
- return subScreens.at(screenNo)->region().boundingRect();
-}
-
-int QDesktopWidget::screenNumber(const QWidget *w) const
-{
- if (!w)
- return 0;
-
- QRect frame = w->frameGeometry();
- if (!w->isWindow())
- frame.moveTopLeft(w->mapToGlobal(QPoint(0, 0)));
- const QPoint midpoint = (frame.topLeft() + frame.bottomRight()) / 2;
- return screenNumber(midpoint);
-}
-
-int QDesktopWidget::screenNumber(const QPoint &p) const
-{
- const QScreen *screen = QScreen::instance();
- if (!screen || !screen->region().contains(p))
- return -1;
-
- const QList<QScreen*> subScreens = screen->subScreens();
- if (subScreens.size() == 0)
- return 0;
-
- for (int i = 0; i < subScreens.size(); ++i)
- if (subScreens.at(i)->region().contains(p))
- return i;
-
- return -1;
-}
-
-void QDesktopWidget::resizeEvent(QResizeEvent *)
-{
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qdnd.cpp b/src/gui/kernel/qdnd.cpp
deleted file mode 100644
index 7063828610..0000000000
--- a/src/gui/kernel/qdnd.cpp
+++ /dev/null
@@ -1,491 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qplatformdefs.h"
-
-#include "qbitmap.h"
-#include "qdrag.h"
-#include "qpixmap.h"
-#include "qevent.h"
-#include "qfile.h"
-#include "qtextcodec.h"
-#include "qapplication.h"
-#include "qpoint.h"
-#include "qwidget.h"
-#include "qbuffer.h"
-#include "qimage.h"
-#include "qregexp.h"
-#include "qdir.h"
-#include "qdnd_p.h"
-#include "qimagereader.h"
-#include "qimagewriter.h"
-#include "qdebug.h"
-#include <ctype.h>
-
-#include <private/qapplication_p.h>
-
-#ifndef QT_NO_DRAGANDDROP
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_DRAGANDDROP
-
-//#define QDND_DEBUG
-
-#ifdef QDND_DEBUG
-QString dragActionsToString(Qt::DropActions actions)
-{
- QString str;
- if (actions == Qt::IgnoreAction) {
- if (!str.isEmpty())
- str += " | ";
- str += "IgnoreAction";
- }
- if (actions & Qt::LinkAction) {
- if (!str.isEmpty())
- str += " | ";
- str += "LinkAction";
- }
- if (actions & Qt::CopyAction) {
- if (!str.isEmpty())
- str += " | ";
- str += "CopyAction";
- }
- if (actions & Qt::MoveAction) {
- if (!str.isEmpty())
- str += " | ";
- str += "MoveAction";
- }
- if ((actions & Qt::TargetMoveAction) == Qt::TargetMoveAction ) {
- if (!str.isEmpty())
- str += " | ";
- str += "TargetMoveAction";
- }
- return str;
-}
-
-QString KeyboardModifiersToString(Qt::KeyboardModifiers moderfies)
-{
- QString str;
- if (moderfies & Qt::ControlModifier) {
- if (!str.isEmpty())
- str += " | ";
- str += Qt::ControlModifier;
- }
- if (moderfies & Qt::AltModifier) {
- if (!str.isEmpty())
- str += " | ";
- str += Qt::AltModifier;
- }
- if (moderfies & Qt::ShiftModifier) {
- if (!str.isEmpty())
- str += " | ";
- str += Qt::ShiftModifier;
- }
- return str;
-}
-#endif
-
-
-// the universe's only drag manager
-QDragManager *QDragManager::instance = 0;
-
-
-QDragManager::QDragManager()
- : QObject(qApp)
-{
- Q_ASSERT(!instance);
-
-#ifdef Q_WS_QWS
- currentActionForOverrideCursor = Qt::IgnoreAction;
-#endif
- object = 0;
- beingCancelled = false;
- restoreCursor = false;
- willDrop = false;
- eventLoop = 0;
- dropData = new QDropData();
- currentDropTarget = 0;
-#ifdef Q_WS_X11
- xdndMimeTransferedPixmapIndex = 0;
-#endif
-}
-
-
-QDragManager::~QDragManager()
-{
-#ifndef QT_NO_CURSOR
- if (restoreCursor)
- QApplication::restoreOverrideCursor();
-#endif
- instance = 0;
- delete dropData;
-}
-
-QDragManager *QDragManager::self()
-{
- if (!instance && !QApplication::closingDown())
- instance = new QDragManager;
- return instance;
-}
-
-QPixmap QDragManager::dragCursor(Qt::DropAction action) const
-{
- QDragPrivate * d = dragPrivate();
- if (d && d->customCursors.contains(action))
- return d->customCursors[action];
- else if (action == Qt::MoveAction)
- return QApplicationPrivate::instance()->getPixmapCursor(Qt::DragMoveCursor);
- else if (action == Qt::CopyAction)
- return QApplicationPrivate::instance()->getPixmapCursor(Qt::DragCopyCursor);
- else if (action == Qt::LinkAction)
- return QApplicationPrivate::instance()->getPixmapCursor(Qt::DragLinkCursor);
-#ifdef Q_WS_WIN
- else if (action == Qt::IgnoreAction)
- return QApplicationPrivate::instance()->getPixmapCursor(Qt::ForbiddenCursor);
-#endif
- return QPixmap();
-}
-
-bool QDragManager::hasCustomDragCursors() const
-{
- QDragPrivate * d = dragPrivate();
- return d && !d->customCursors.isEmpty();
-}
-
-Qt::DropAction QDragManager::defaultAction(Qt::DropActions possibleActions,
- Qt::KeyboardModifiers modifiers) const
-{
-#ifdef QDND_DEBUG
- qDebug("QDragManager::defaultAction(Qt::DropActions possibleActions)");
- qDebug("keyboard modifiers : %s", KeyboardModifiersToString(modifiers).latin1());
-#endif
-
- QDragPrivate *d = dragPrivate();
- Qt::DropAction defaultAction = d ? d->defaultDropAction : Qt::IgnoreAction;
-
- if (defaultAction == Qt::IgnoreAction) {
- //This means that the drag was initiated by QDrag::start and we need to
- //preserve the old behavior
-#ifdef Q_WS_MAC
- defaultAction = Qt::MoveAction;
-#else
- defaultAction = Qt::CopyAction;
-#endif
- }
-
-#ifdef Q_WS_MAC
- if (modifiers & Qt::ControlModifier && modifiers & Qt::AltModifier)
- defaultAction = Qt::LinkAction;
- else if (modifiers & Qt::AltModifier)
- defaultAction = Qt::CopyAction;
- else if (modifiers & Qt::ControlModifier)
- defaultAction = Qt::MoveAction;
-#else
- if (modifiers & Qt::ControlModifier && modifiers & Qt::ShiftModifier)
- defaultAction = Qt::LinkAction;
- else if (modifiers & Qt::ControlModifier)
- defaultAction = Qt::CopyAction;
- else if (modifiers & Qt::ShiftModifier)
- defaultAction = Qt::MoveAction;
- else if (modifiers & Qt::AltModifier)
- defaultAction = Qt::LinkAction;
-#endif
-
- // if the object is set take the list of possibles from it
- if (object)
- possibleActions = object->d_func()->possible_actions;
-
-#ifdef QDND_DEBUG
- qDebug("possible actions : %s", dragActionsToString(possibleActions).latin1());
-#endif
-
- // Check if the action determined is allowed
- if (!(possibleActions & defaultAction)) {
- if (possibleActions & Qt::CopyAction)
- defaultAction = Qt::CopyAction;
- else if (possibleActions & Qt::MoveAction)
- defaultAction = Qt::MoveAction;
- else if (possibleActions & Qt::LinkAction)
- defaultAction = Qt::LinkAction;
- else
- defaultAction = Qt::IgnoreAction;
- }
-
-#ifdef QDND_DEBUG
- qDebug("default action : %s", dragActionsToString(defaultAction).latin1());
-#endif
-
- return defaultAction;
-}
-
-void QDragManager::setCurrentTarget(QWidget *target, bool dropped)
-{
- if (currentDropTarget == target)
- return;
-
- currentDropTarget = target;
- if (!dropped && object) {
- object->d_func()->target = target;
- emit object->targetChanged(target);
- }
-
-}
-
-QWidget *QDragManager::currentTarget()
-{
- return currentDropTarget;
-}
-
-#endif
-
-QDropData::QDropData()
- : QInternalMimeData()
-{
-}
-
-QDropData::~QDropData()
-{
-}
-#endif // QT_NO_DRAGANDDROP
-
-#if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD))
-
-static QStringList imageReadMimeFormats()
-{
- QStringList formats;
- QList<QByteArray> imageFormats = QImageReader::supportedImageFormats();
- for (int i = 0; i < imageFormats.size(); ++i) {
- QString format = QLatin1String("image/");
- format += QString::fromLatin1(imageFormats.at(i).toLower());
- formats.append(format);
- }
-
- //put png at the front because it is best
- int pngIndex = formats.indexOf(QLatin1String("image/png"));
- if (pngIndex != -1 && pngIndex != 0)
- formats.move(pngIndex, 0);
-
- return formats;
-}
-
-
-static QStringList imageWriteMimeFormats()
-{
- QStringList formats;
- QList<QByteArray> imageFormats = QImageWriter::supportedImageFormats();
- for (int i = 0; i < imageFormats.size(); ++i) {
- QString format = QLatin1String("image/");
- format += QString::fromLatin1(imageFormats.at(i).toLower());
- formats.append(format);
- }
-
- //put png at the front because it is best
- int pngIndex = formats.indexOf(QLatin1String("image/png"));
- if (pngIndex != -1 && pngIndex != 0)
- formats.move(pngIndex, 0);
-
- return formats;
-}
-
-QInternalMimeData::QInternalMimeData()
- : QMimeData()
-{
-}
-
-QInternalMimeData::~QInternalMimeData()
-{
-}
-
-bool QInternalMimeData::hasFormat(const QString &mimeType) const
-{
- bool foundFormat = hasFormat_sys(mimeType);
- if (!foundFormat && mimeType == QLatin1String("application/x-qt-image")) {
- QStringList imageFormats = imageReadMimeFormats();
- for (int i = 0; i < imageFormats.size(); ++i) {
- if ((foundFormat = hasFormat_sys(imageFormats.at(i))))
- break;
- }
- }
- return foundFormat;
-}
-
-QStringList QInternalMimeData::formats() const
-{
- QStringList realFormats = formats_sys();
- if (!realFormats.contains(QLatin1String("application/x-qt-image"))) {
- QStringList imageFormats = imageReadMimeFormats();
- for (int i = 0; i < imageFormats.size(); ++i) {
- if (realFormats.contains(imageFormats.at(i))) {
- realFormats += QLatin1String("application/x-qt-image");
- break;
- }
- }
- }
- return realFormats;
-}
-
-QVariant QInternalMimeData::retrieveData(const QString &mimeType, QVariant::Type type) const
-{
- QVariant data = retrieveData_sys(mimeType, type);
- if (mimeType == QLatin1String("application/x-qt-image")) {
- if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty())) {
- // try to find an image
- QStringList imageFormats = imageReadMimeFormats();
- for (int i = 0; i < imageFormats.size(); ++i) {
- data = retrieveData_sys(imageFormats.at(i), type);
- if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty()))
- continue;
- break;
- }
- }
- // we wanted some image type, but all we got was a byte array. Convert it to an image.
- if (data.type() == QVariant::ByteArray
- && (type == QVariant::Image || type == QVariant::Pixmap || type == QVariant::Bitmap))
- data = QImage::fromData(data.toByteArray());
-
- } else if (mimeType == QLatin1String("application/x-color") && data.type() == QVariant::ByteArray) {
- QColor c;
- QByteArray ba = data.toByteArray();
- if (ba.size() == 8) {
- ushort * colBuf = (ushort *)ba.data();
- c.setRgbF(qreal(colBuf[0]) / qreal(0xFFFF),
- qreal(colBuf[1]) / qreal(0xFFFF),
- qreal(colBuf[2]) / qreal(0xFFFF),
- qreal(colBuf[3]) / qreal(0xFFFF));
- data = c;
- } else {
- qWarning("Qt: Invalid color format");
- }
- } else if (data.type() != type && data.type() == QVariant::ByteArray) {
- // try to use mime data's internal conversion stuf.
- QInternalMimeData *that = const_cast<QInternalMimeData *>(this);
- that->setData(mimeType, data.toByteArray());
- data = QMimeData::retrieveData(mimeType, type);
- that->clear();
- }
- return data;
-}
-
-bool QInternalMimeData::canReadData(const QString &mimeType)
-{
- return imageReadMimeFormats().contains(mimeType);
-}
-
-// helper functions for rendering mimedata to the system, this is needed because QMimeData is in core.
-QStringList QInternalMimeData::formatsHelper(const QMimeData *data)
-{
- QStringList realFormats = data->formats();
- if (realFormats.contains(QLatin1String("application/x-qt-image"))) {
- // add all supported image formats
- QStringList imageFormats = imageWriteMimeFormats();
- for (int i = 0; i < imageFormats.size(); ++i) {
- if (!realFormats.contains(imageFormats.at(i)))
- realFormats.append(imageFormats.at(i));
- }
- }
- return realFormats;
-}
-
-bool QInternalMimeData::hasFormatHelper(const QString &mimeType, const QMimeData *data)
-{
-
- bool foundFormat = data->hasFormat(mimeType);
- if (!foundFormat) {
- if (mimeType == QLatin1String("application/x-qt-image")) {
- // check all supported image formats
- QStringList imageFormats = imageWriteMimeFormats();
- for (int i = 0; i < imageFormats.size(); ++i) {
- if ((foundFormat = data->hasFormat(imageFormats.at(i))))
- break;
- }
- } else if (mimeType.startsWith(QLatin1String("image/"))) {
- return data->hasImage() && imageWriteMimeFormats().contains(mimeType);
- }
- }
- return foundFormat;
-}
-
-QByteArray QInternalMimeData::renderDataHelper(const QString &mimeType, const QMimeData *data)
-{
- QByteArray ba;
- if (mimeType == QLatin1String("application/x-color")) {
- /* QMimeData can only provide colors as QColor or the name
- of a color as a QByteArray or a QString. So we need to do
- the conversion to application/x-color here.
- The application/x-color format is :
- type: application/x-color
- format: 16
- data[0]: red
- data[1]: green
- data[2]: blue
- data[3]: opacity
- */
- ba.resize(8);
- ushort * colBuf = (ushort *)ba.data();
- QColor c = qvariant_cast<QColor>(data->colorData());
- colBuf[0] = ushort(c.redF() * 0xFFFF);
- colBuf[1] = ushort(c.greenF() * 0xFFFF);
- colBuf[2] = ushort(c.blueF() * 0xFFFF);
- colBuf[3] = ushort(c.alphaF() * 0xFFFF);
- } else {
- ba = data->data(mimeType);
- if (ba.isEmpty()) {
- if (mimeType == QLatin1String("application/x-qt-image") && data->hasImage()) {
- QImage image = qvariant_cast<QImage>(data->imageData());
- QBuffer buf(&ba);
- buf.open(QBuffer::WriteOnly);
- // would there not be PNG ??
- image.save(&buf, "PNG");
- } else if (mimeType.startsWith(QLatin1String("image/")) && data->hasImage()) {
- QImage image = qvariant_cast<QImage>(data->imageData());
- QBuffer buf(&ba);
- buf.open(QBuffer::WriteOnly);
- image.save(&buf, mimeType.mid(mimeType.indexOf(QLatin1Char('/')) + 1).toLatin1().toUpper());
- }
- }
- }
- return ba;
-}
-
-#endif // QT_NO_DRAGANDDROP && QT_NO_CLIPBOARD
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qdnd_p.h b/src/gui/kernel/qdnd_p.h
deleted file mode 100644
index 754366637c..0000000000
--- a/src/gui/kernel/qdnd_p.h
+++ /dev/null
@@ -1,336 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDND_P_H
-#define QDND_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "QtCore/qobject.h"
-#include "QtCore/qmap.h"
-#include "QtGui/qmime.h"
-#include "QtGui/qdrag.h"
-#include "QtGui/qpixmap.h"
-#include "QtGui/qcursor.h"
-#include "QtCore/qpoint.h"
-#include "private/qobject_p.h"
-#ifdef Q_WS_MAC
-# include "private/qt_mac_p.h"
-#endif
-
-#if defined(Q_WS_WIN)
-# include <qt_windows.h>
-# include <objidl.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class QEventLoop;
-
-#if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD))
-
-class Q_GUI_EXPORT QInternalMimeData : public QMimeData
-{
- Q_OBJECT
-public:
- QInternalMimeData();
- ~QInternalMimeData();
-
- bool hasFormat(const QString &mimeType) const;
- QStringList formats() const;
- static bool canReadData(const QString &mimeType);
-
-
- static QStringList formatsHelper(const QMimeData *data);
- static bool hasFormatHelper(const QString &mimeType, const QMimeData *data);
- static QByteArray renderDataHelper(const QString &mimeType, const QMimeData *data);
-
-protected:
- QVariant retrieveData(const QString &mimeType, QVariant::Type type) const;
-
- virtual bool hasFormat_sys(const QString &mimeType) const = 0;
- virtual QStringList formats_sys() const = 0;
- virtual QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const = 0;
-};
-
-#ifdef Q_WS_WIN
-class QOleDataObject : public IDataObject
-{
-public:
- explicit QOleDataObject(QMimeData *mimeData);
- virtual ~QOleDataObject();
-
- void releaseQt();
- const QMimeData *mimeData() const;
- DWORD reportedPerformedEffect() const;
-
- // IUnknown methods
- STDMETHOD(QueryInterface)(REFIID riid, void FAR* FAR* ppvObj);
- STDMETHOD_(ULONG,AddRef)(void);
- STDMETHOD_(ULONG,Release)(void);
-
- // IDataObject methods
- STDMETHOD(GetData)(LPFORMATETC pformatetcIn, LPSTGMEDIUM pmedium);
- STDMETHOD(GetDataHere)(LPFORMATETC pformatetc, LPSTGMEDIUM pmedium);
- STDMETHOD(QueryGetData)(LPFORMATETC pformatetc);
- STDMETHOD(GetCanonicalFormatEtc)(LPFORMATETC pformatetc, LPFORMATETC pformatetcOut);
- STDMETHOD(SetData)(LPFORMATETC pformatetc, STGMEDIUM FAR * pmedium,
- BOOL fRelease);
- STDMETHOD(EnumFormatEtc)(DWORD dwDirection, LPENUMFORMATETC FAR* ppenumFormatEtc);
- STDMETHOD(DAdvise)(FORMATETC FAR* pFormatetc, DWORD advf,
- LPADVISESINK pAdvSink, DWORD FAR* pdwConnection);
- STDMETHOD(DUnadvise)(DWORD dwConnection);
- STDMETHOD(EnumDAdvise)(LPENUMSTATDATA FAR* ppenumAdvise);
-
-private:
- ULONG m_refs;
- QPointer<QMimeData> data;
- int CF_PERFORMEDDROPEFFECT;
- DWORD performedEffect;
-};
-
-class QOleEnumFmtEtc : public IEnumFORMATETC
-{
-public:
- explicit QOleEnumFmtEtc(const QVector<FORMATETC> &fmtetcs);
- explicit QOleEnumFmtEtc(const QVector<LPFORMATETC> &lpfmtetcs);
- virtual ~QOleEnumFmtEtc();
-
- bool isNull() const;
-
- // IUnknown methods
- STDMETHOD(QueryInterface)(REFIID riid, void FAR* FAR* ppvObj);
- STDMETHOD_(ULONG,AddRef)(void);
- STDMETHOD_(ULONG,Release)(void);
-
- // IEnumFORMATETC methods
- STDMETHOD(Next)(ULONG celt, LPFORMATETC rgelt, ULONG FAR* pceltFetched);
- STDMETHOD(Skip)(ULONG celt);
- STDMETHOD(Reset)(void);
- STDMETHOD(Clone)(LPENUMFORMATETC FAR* newEnum);
-
-private:
- bool copyFormatEtc(LPFORMATETC dest, LPFORMATETC src) const;
-
- ULONG m_dwRefs;
- ULONG m_nIndex;
- QVector<LPFORMATETC> m_lpfmtetcs;
- bool m_isNull;
-};
-
-#endif
-
-#endif //QT_NO_DRAGANDDROP && QT_NO_CLIPBOARD
-
-#ifndef QT_NO_DRAGANDDROP
-
-class QDragPrivate : public QObjectPrivate
-{
-public:
- QWidget *source;
- QWidget *target;
- QMimeData *data;
- QPixmap pixmap;
- QPoint hotspot;
- Qt::DropActions possible_actions;
- Qt::DropAction executed_action;
- QMap<Qt::DropAction, QPixmap> customCursors;
- Qt::DropAction defaultDropAction;
-};
-
-class QDropData : public QInternalMimeData
-{
- Q_OBJECT
-public:
- QDropData();
- ~QDropData();
-
-protected:
- bool hasFormat_sys(const QString &mimeType) const;
- QStringList formats_sys() const;
- QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const;
-
-#if defined(Q_WS_WIN)
-public:
- LPDATAOBJECT currentDataObject;
-#endif
-};
-
-class QDragManager: public QObject {
- Q_OBJECT
-
- QDragManager();
- ~QDragManager();
- // only friend classes can use QDragManager.
- friend class QDrag;
- friend class QDragMoveEvent;
- friend class QDropEvent;
- friend class QApplication;
-#ifdef Q_WS_MAC
- friend class QWidgetPrivate; //dnd is implemented here
-#endif
-
- bool eventFilter(QObject *, QEvent *);
- void timerEvent(QTimerEvent*);
-
-public:
- Qt::DropAction drag(QDrag *);
-
- void cancel(bool deleteSource = true);
- void move(const QPoint &);
- void drop();
- void updatePixmap();
- QWidget *source() const { return object ? object->d_func()->source : 0; }
- QDragPrivate *dragPrivate() const { return object ? object->d_func() : 0; }
- static QDragPrivate *dragPrivate(QDrag *drag) { return drag ? drag->d_func() : 0; }
-
- static QDragManager *self();
- Qt::DropAction defaultAction(Qt::DropActions possibleActions,
- Qt::KeyboardModifiers modifiers) const;
-
- QDrag *object;
-
- void updateCursor();
-
- bool beingCancelled;
- bool restoreCursor;
- bool willDrop;
- QEventLoop *eventLoop;
-
- QPixmap dragCursor(Qt::DropAction action) const;
-
- bool hasCustomDragCursors() const;
-
- QDropData *dropData;
-
- void emitActionChanged(Qt::DropAction newAction) { if (object) emit object->actionChanged(newAction); }
-
- void setCurrentTarget(QWidget *target, bool dropped = false);
- QWidget *currentTarget();
-
-#ifdef Q_WS_X11
- QPixmap xdndMimeTransferedPixmap[2];
- int xdndMimeTransferedPixmapIndex;
-#endif
-
-private:
-#if defined(Q_WS_QWS) || defined(Q_WS_QPA)
- Qt::DropAction currentActionForOverrideCursor;
-#endif
-#ifdef Q_OS_SYMBIAN
-#ifndef QT_NO_CURSOR
- QCursor overrideCursor;
-#endif
-#endif
- QWidget *currentDropTarget;
-
- static QDragManager *instance;
- Q_DISABLE_COPY(QDragManager)
-};
-
-
-#if defined(Q_WS_WIN)
-
-class QOleDropTarget : public IDropTarget
-{
-public:
- QOleDropTarget(QWidget* w);
- virtual ~QOleDropTarget() {}
-
- void releaseQt();
-
- // IUnknown methods
- STDMETHOD(QueryInterface)(REFIID riid, void FAR* FAR* ppvObj);
- STDMETHOD_(ULONG, AddRef)(void);
- STDMETHOD_(ULONG, Release)(void);
-
- // IDropTarget methods
- STDMETHOD(DragEnter)(LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect);
- STDMETHOD(DragOver)(DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect);
- STDMETHOD(DragLeave)();
- STDMETHOD(Drop)(LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect);
-
-private:
- ULONG m_refs;
- QWidget* widget;
- QPointer<QWidget> currentWidget;
- QRect answerRect;
- QPoint lastPoint;
- DWORD chosenEffect;
- DWORD lastKeyState;
-
- void sendDragEnterEvent(QWidget *to, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect);
-};
-
-#endif
-
-#if defined (Q_WS_MAC)
-class QCocoaDropData : public QInternalMimeData
-{
- Q_OBJECT
-public:
- QCocoaDropData(CFStringRef pasteboard);
- ~QCocoaDropData();
-
-protected:
- bool hasFormat_sys(const QString &mimeType) const;
- QStringList formats_sys() const;
- QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const;
-public:
- CFStringRef dropPasteboard;
-};
-#endif
-
-#endif // !QT_NO_DRAGANDDROP
-
-
-QT_END_NAMESPACE
-
-#endif // QDND_P_H
diff --git a/src/gui/kernel/qdnd_qws.cpp b/src/gui/kernel/qdnd_qws.cpp
deleted file mode 100644
index b744c2f085..0000000000
--- a/src/gui/kernel/qdnd_qws.cpp
+++ /dev/null
@@ -1,426 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qapplication.h"
-
-#ifndef QT_NO_DRAGANDDROP
-
-#include "qwidget.h"
-#include "qdatetime.h"
-#include "qbitmap.h"
-#include "qcursor.h"
-#include "qevent.h"
-#include "qpainter.h"
-#include "qdnd_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QT_USE_NAMESPACE
-
-static QPixmap *defaultPm = 0;
-static const int default_pm_hotx = -2;
-static const int default_pm_hoty = -16;
-static const char *const default_pm[] = {
-"13 9 3 1",
-". c None",
-" c #000000",
-"X c #FFFFFF",
-"X X X X X X X",
-" X X X X X X ",
-"X ......... X",
-" X.........X ",
-"X ......... X",
-" X.........X ",
-"X ......... X",
-" X X X X X X ",
-"X X X X X X X",
-};
-
-// Shift/Ctrl handling, and final drop status
-static Qt::DropAction global_accepted_action = Qt::CopyAction;
-static Qt::DropActions possible_actions = Qt::IgnoreAction;
-
-
-// static variables in place of a proper cross-process solution
-static QDrag *drag_object;
-static bool qt_qws_dnd_dragging = false;
-
-
-static Qt::KeyboardModifiers oldstate;
-
-class QShapedPixmapWidget : public QWidget {
- QPixmap pixmap;
-public:
- QShapedPixmapWidget() :
- QWidget(0, Qt::Tool | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint)
- {
- // ### Temporary workaround for 4.2-rc1!!! To prevent flickering when
- // using drag'n drop in a client application. (task 126956)
- // setAttribute() should be done unconditionally!
- if (QApplication::type() == QApplication::GuiServer)
- setAttribute(Qt::WA_TransparentForMouseEvents);
- }
-
- void setPixmap(QPixmap pm)
- {
- pixmap = pm;
- if (!pixmap.mask().isNull()) {
- setMask(pixmap.mask());
- } else {
- clearMask();
- }
- resize(pm.width(),pm.height());
- }
-
- void paintEvent(QPaintEvent*)
- {
- QPainter p(this);
- p.drawPixmap(0,0,pixmap);
- }
-};
-
-
-static QShapedPixmapWidget *qt_qws_dnd_deco = 0;
-
-
-void QDragManager::updatePixmap()
-{
- if (qt_qws_dnd_deco) {
- QPixmap pm;
- QPoint pm_hot(default_pm_hotx,default_pm_hoty);
- if (drag_object) {
- pm = drag_object->pixmap();
- if (!pm.isNull())
- pm_hot = drag_object->hotSpot();
- }
- if (pm.isNull()) {
- if (!defaultPm)
- defaultPm = new QPixmap(default_pm);
- pm = *defaultPm;
- }
- qt_qws_dnd_deco->setPixmap(pm);
- qt_qws_dnd_deco->move(QCursor::pos()-pm_hot);
- if (willDrop) {
- qt_qws_dnd_deco->show();
- } else {
- qt_qws_dnd_deco->hide();
- }
- }
-}
-
-void QDragManager::timerEvent(QTimerEvent *) { }
-
-void QDragManager::move(const QPoint &) { }
-
-void QDragManager::updateCursor()
-{
-#ifndef QT_NO_CURSOR
- if (willDrop) {
- if (qt_qws_dnd_deco)
- qt_qws_dnd_deco->show();
- if (currentActionForOverrideCursor != global_accepted_action) {
- QApplication::changeOverrideCursor(QCursor(dragCursor(global_accepted_action), 0, 0));
- currentActionForOverrideCursor = global_accepted_action;
- }
- } else {
- QCursor *overrideCursor = QApplication::overrideCursor();
- if (!overrideCursor || overrideCursor->shape() != Qt::ForbiddenCursor) {
- QApplication::changeOverrideCursor(QCursor(Qt::ForbiddenCursor));
- currentActionForOverrideCursor = Qt::IgnoreAction;
- }
- if (qt_qws_dnd_deco)
- qt_qws_dnd_deco->hide();
- }
-#endif
-}
-
-
-bool QDragManager::eventFilter(QObject *o, QEvent *e)
-{
- if (beingCancelled) {
- if (e->type() == QEvent::KeyRelease && static_cast<QKeyEvent*>(e)->key() == Qt::Key_Escape) {
- qApp->removeEventFilter(this);
- Q_ASSERT(object == 0);
- beingCancelled = false;
- eventLoop->exit();
- return true; // block the key release
- }
- return false;
- }
-
-
-
- if (!o->isWidgetType())
- return false;
-
- switch(e->type()) {
- case QEvent::ShortcutOverride:
- // prevent accelerators from firing while dragging
- e->accept();
- return true;
-
- case QEvent::KeyPress:
- case QEvent::KeyRelease:
- {
- QKeyEvent *ke = ((QKeyEvent*)e);
- if (ke->key() == Qt::Key_Escape && e->type() == QEvent::KeyPress) {
- cancel();
- qApp->removeEventFilter(this);
- beingCancelled = false;
- eventLoop->exit();
- } else {
- updateCursor();
- }
- return true; // Eat all key events
- }
-
- case QEvent::MouseButtonPress:
- case QEvent::MouseMove:
- {
- if (!object) { //#### this should not happen
- qWarning("QDragManager::eventFilter: No object");
- return true;
- }
-
- QDragManager *manager = QDragManager::self();
- QMimeData *dropData = manager->object ? manager->dragPrivate()->data : manager->dropData;
- if (manager->object)
- possible_actions = manager->dragPrivate()->possible_actions;
- else
- possible_actions = Qt::IgnoreAction;
-
- QMouseEvent *me = (QMouseEvent *)e;
- if (me->buttons()) {
- Qt::DropAction prevAction = global_accepted_action;
- QWidget *cw = QApplication::widgetAt(me->globalPos());
-
- // Fix for when we move mouse on to the deco widget
- if (qt_qws_dnd_deco && cw == qt_qws_dnd_deco)
- cw = object->target();
-
- while (cw && !cw->acceptDrops() && !cw->isWindow())
- cw = cw->parentWidget();
-
- if (object->target() != cw) {
- if (object->target()) {
- QDragLeaveEvent dle;
- QApplication::sendEvent(object->target(), &dle);
- willDrop = false;
- global_accepted_action = Qt::IgnoreAction;
- updateCursor();
- restoreCursor = true;
- object->d_func()->target = 0;
- }
- if (cw && cw->acceptDrops()) {
- object->d_func()->target = cw;
- QDragEnterEvent dee(cw->mapFromGlobal(me->globalPos()), possible_actions, dropData,
- me->buttons(), me->modifiers());
- QApplication::sendEvent(object->target(), &dee);
- willDrop = dee.isAccepted() && dee.dropAction() != Qt::IgnoreAction;
- global_accepted_action = willDrop ? dee.dropAction() : Qt::IgnoreAction;
- updateCursor();
- restoreCursor = true;
- }
- } else if (cw) {
- QDragMoveEvent dme(cw->mapFromGlobal(me->globalPos()), possible_actions, dropData,
- me->buttons(), me->modifiers());
- if (global_accepted_action != Qt::IgnoreAction) {
- dme.setDropAction(global_accepted_action);
- dme.accept();
- }
- QApplication::sendEvent(cw, &dme);
- willDrop = dme.isAccepted();
- global_accepted_action = willDrop ? dme.dropAction() : Qt::IgnoreAction;
- updatePixmap();
- updateCursor();
- }
- if (global_accepted_action != prevAction)
- emitActionChanged(global_accepted_action);
- }
- return true; // Eat all mouse events
- }
-
- case QEvent::MouseButtonRelease:
- {
- qApp->removeEventFilter(this);
- if (restoreCursor) {
- willDrop = false;
-#ifndef QT_NO_CURSOR
- QApplication::restoreOverrideCursor();
-#endif
- restoreCursor = false;
- }
- if (object && object->target()) {
- QMouseEvent *me = (QMouseEvent *)e;
-
- QDragManager *manager = QDragManager::self();
- QMimeData *dropData = manager->object ? manager->dragPrivate()->data : manager->dropData;
-
- QDropEvent de(object->target()->mapFromGlobal(me->globalPos()), possible_actions, dropData,
- me->buttons(), me->modifiers());
- QApplication::sendEvent(object->target(), &de);
- if (de.isAccepted())
- global_accepted_action = de.dropAction();
- else
- global_accepted_action = Qt::IgnoreAction;
-
- if (object)
- object->deleteLater();
- drag_object = object = 0;
- }
- eventLoop->exit();
- return true; // Eat all mouse events
- }
-
- default:
- break;
- }
-
- return false;
-}
-
-Qt::DropAction QDragManager::drag(QDrag *o)
-{
- if (object == o || !o || !o->source())
- return Qt::IgnoreAction;
-
- if (object) {
- cancel();
- qApp->removeEventFilter(this);
- beingCancelled = false;
- }
-
- object = drag_object = o;
- qt_qws_dnd_deco = new QShapedPixmapWidget();
- oldstate = Qt::NoModifier; // #### Should use state that caused the drag
-// drag_mode = mode;
-
- willDrop = false;
- updatePixmap();
- updateCursor();
- restoreCursor = true;
- object->d_func()->target = 0;
- qApp->installEventFilter(this);
-
- global_accepted_action = Qt::CopyAction;
-#ifndef QT_NO_CURSOR
- qApp->setOverrideCursor(Qt::ArrowCursor);
- restoreCursor = true;
- updateCursor();
-#endif
-
- qt_qws_dnd_dragging = true;
-
- eventLoop = new QEventLoop;
- (void) eventLoop->exec();
- delete eventLoop;
- eventLoop = 0;
-
- delete qt_qws_dnd_deco;
- qt_qws_dnd_deco = 0;
- qt_qws_dnd_dragging = false;
-
-
- return global_accepted_action;
-}
-
-
-void QDragManager::cancel(bool deleteSource)
-{
-// qDebug("QDragManager::cancel");
- beingCancelled = true;
-
- if (object->target()) {
- QDragLeaveEvent dle;
- QApplication::sendEvent(object->target(), &dle);
- }
-
-#ifndef QT_NO_CURSOR
- if (restoreCursor) {
- QApplication::restoreOverrideCursor();
- restoreCursor = false;
- }
-#endif
-
- if (drag_object) {
- if (deleteSource)
- object->deleteLater();
- drag_object = object = 0;
- }
-
- delete qt_qws_dnd_deco;
- qt_qws_dnd_deco = 0;
-
- global_accepted_action = Qt::IgnoreAction;
-}
-
-
-void QDragManager::drop()
-{
-}
-
-QVariant QDropData::retrieveData_sys(const QString &mimetype, QVariant::Type type) const
-{
- if (!drag_object)
- return QVariant();
- QByteArray data = drag_object->mimeData()->data(mimetype);
- if (type == QVariant::String)
- return QString::fromUtf8(data);
- return data;
-}
-
-bool QDropData::hasFormat_sys(const QString &format) const
-{
- return formats().contains(format);
-}
-
-QStringList QDropData::formats_sys() const
-{
- if (drag_object)
- return drag_object->mimeData()->formats();
- return QStringList();
-}
-
-
-#endif // QT_NO_DRAGANDDROP
-
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qdnd_x11.cpp b/src/gui/kernel/qdnd_x11.cpp
deleted file mode 100644
index 1c59d41a94..0000000000
--- a/src/gui/kernel/qdnd_x11.cpp
+++ /dev/null
@@ -1,2076 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qplatformdefs.h"
-
-#include "qapplication.h"
-
-#ifndef QT_NO_DRAGANDDROP
-
-#include "qwidget.h"
-#include "qpainter.h"
-#include "qpixmap.h"
-#include "qbitmap.h"
-#include "qdesktopwidget.h"
-#include "qevent.h"
-#include "qiodevice.h"
-#include "qpointer.h"
-#include "qcursor.h"
-#include "qelapsedtimer.h"
-#include "qvariant.h"
-#include "qvector.h"
-#include "qurl.h"
-#include "qdebug.h"
-#include "qimagewriter.h"
-#include "qbuffer.h"
-#include "qtextcodec.h"
-
-#include "qdnd_p.h"
-#include "qapplication_p.h"
-#include "qt_x11_p.h"
-#include "qx11info_x11.h"
-
-#include "qwidget_p.h"
-#include "qcursor_p.h"
-
-QT_BEGIN_NAMESPACE
-
-// #define DND_DEBUG
-#ifdef DND_DEBUG
-#define DEBUG qDebug
-#else
-#define DEBUG if(0) qDebug
-#endif
-
-#ifdef DND_DEBUG
-#define DNDDEBUG qDebug()
-#else
-#define DNDDEBUG if(0) qDebug()
-#endif
-
-static int findXdndDropTransactionByWindow(Window window)
-{
- int at = -1;
- for (int i = 0; i < X11->dndDropTransactions.count(); ++i) {
- const QXdndDropTransaction &t = X11->dndDropTransactions.at(i);
- if (t.target == window || t.proxy_target == window) {
- at = i;
- break;
- }
- }
- return at;
-}
-
-static int findXdndDropTransactionByTime(Time timestamp)
-{
- int at = -1;
- for (int i = 0; i < X11->dndDropTransactions.count(); ++i) {
- const QXdndDropTransaction &t = X11->dndDropTransactions.at(i);
- if (t.timestamp == timestamp) {
- at = i;
- break;
- }
- }
- return at;
-}
-
-// timer used to discard old XdndDrop transactions
-static int transaction_expiry_timer = -1;
-enum { XdndDropTransactionTimeout = 5000 }; // 5 seconds
-
-static void restartXdndDropExpiryTimer()
-{
- if (transaction_expiry_timer != -1)
- QDragManager::self()->killTimer(transaction_expiry_timer);
- transaction_expiry_timer = QDragManager::self()->startTimer(XdndDropTransactionTimeout);
-}
-
-
-// find an ancestor with XdndAware on it
-static Window findXdndAwareParent(Window window)
-{
- Window target = 0;
- forever {
- // check if window has XdndAware
- Atom type = 0;
- int f;
- unsigned long n, a;
- unsigned char *data = 0;
- if (XGetWindowProperty(X11->display, window, ATOM(XdndAware), 0, 0, False,
- AnyPropertyType, &type, &f,&n,&a,&data) == Success) {
- if (data)
- XFree(data);
- if (type) {
- target = window;
- break;
- }
- }
-
- // try window's parent
- Window root;
- Window parent;
- Window *children;
- uint unused;
- if (!XQueryTree(X11->display, window, &root, &parent, &children, &unused))
- break;
- if (children)
- XFree(children);
- if (window == root)
- break;
- window = parent;
- }
- return target;
-}
-
-
-
-
-// and all this stuff is copied -into- qapp_x11.cpp
-
-static void handle_xdnd_position(QWidget *, const XEvent *, bool);
-static void handle_xdnd_status(QWidget * w, const XEvent * xe, bool /*passive*/);
-
-const int xdnd_version = 5;
-
-static Qt::DropAction xdndaction_to_qtaction(Atom atom)
-{
- if (atom == ATOM(XdndActionCopy) || atom == 0)
- return Qt::CopyAction;
- if (atom == ATOM(XdndActionLink))
- return Qt::LinkAction;
- if (atom == ATOM(XdndActionMove))
- return Qt::MoveAction;
- return Qt::CopyAction;
-}
-
-static int qtaction_to_xdndaction(Qt::DropAction a)
-{
- switch (a) {
- case Qt::CopyAction:
- return ATOM(XdndActionCopy);
- case Qt::LinkAction:
- return ATOM(XdndActionLink);
- case Qt::MoveAction:
- case Qt::TargetMoveAction:
- return ATOM(XdndActionMove);
- case Qt::IgnoreAction:
- return XNone;
- default:
- return ATOM(XdndActionCopy);
- }
-}
-
-// clean up the stuff used.
-static void qt_xdnd_cleanup();
-
-static void qt_xdnd_send_leave();
-
-// real variables:
-// xid of current drag source
-static Atom qt_xdnd_dragsource_xid = 0;
-
-// the types in this drop. 100 is no good, but at least it's big.
-const int qt_xdnd_max_type = 100;
-static Atom qt_xdnd_types[qt_xdnd_max_type + 1];
-
-// timer used when target wants "continuous" move messages (eg. scroll)
-static int heartbeat = -1;
-// rectangle in which the answer will be the same
-static QRect qt_xdnd_source_sameanswer;
-// top-level window we sent position to last.
-static Window qt_xdnd_current_target;
-// window to send events to (always valid if qt_xdnd_current_target)
-static Window qt_xdnd_current_proxy_target;
-static Time qt_xdnd_source_current_time;
-
-// widget we forwarded position to last, and local position
-static QPointer<QWidget> qt_xdnd_current_widget;
-static QPoint qt_xdnd_current_position;
-// timestamp from the XdndPosition and XdndDrop
-static Time qt_xdnd_target_current_time;
-// screen number containing the pointer... -1 means default
-static int qt_xdnd_current_screen = -1;
-// state of dragging... true if dragging, false if not
-bool qt_xdnd_dragging = false;
-
-static bool waiting_for_status = false;
-
-// used to preset each new QDragMoveEvent
-static Qt::DropAction last_target_accepted_action = Qt::IgnoreAction;
-
-// Shift/Ctrl handling, and final drop status
-static Qt::DropAction global_accepted_action = Qt::CopyAction;
-static Qt::DropActions possible_actions = Qt::IgnoreAction;
-
-// for embedding only
-static QWidget* current_embedding_widget = 0;
-static XEvent last_enter_event;
-
-// cursors
-static QCursor *noDropCursor = 0;
-static QCursor *moveCursor = 0;
-static QCursor *copyCursor = 0;
-static QCursor *linkCursor = 0;
-
-static QPixmap *defaultPm = 0;
-
-static const int default_pm_hotx = -2;
-static const int default_pm_hoty = -16;
-static const char* const default_pm[] = {
-"13 9 3 1",
-". c None",
-" c #000000",
-"X c #FFFFFF",
-"X X X X X X X",
-" X X X X X X ",
-"X ......... X",
-" X.........X ",
-"X ......... X",
-" X.........X ",
-"X ......... X",
-" X X X X X X ",
-"X X X X X X X"
-};
-
-class QShapedPixmapWidget : public QWidget
-{
- Q_OBJECT
-public:
- QShapedPixmapWidget(QWidget* w) :
- QWidget(w,
- Qt::Tool | Qt::FramelessWindowHint
- | Qt::X11BypassWindowManagerHint
- | Qt::BypassGraphicsProxyWidget)
- {
- setAttribute(Qt::WA_X11NetWmWindowTypeDND);
- }
-
- void setPixmap(const QPixmap &pm)
- {
- QBitmap mask = pm.mask();
- if (!mask.isNull()) {
- setMask(mask);
- } else {
- clearMask();
- }
- resize(pm.width(),pm.height());
- pixmap = pm;
- update();
- }
- QPoint pm_hot;
-
-protected:
- QPixmap pixmap;
- void paintEvent(QPaintEvent*)
- {
- QPainter p(this);
- p.drawPixmap(0, 0, pixmap);
- }
-};
-
-#include "qdnd_x11.moc"
-
-struct XdndData {
- QShapedPixmapWidget *deco;
- QWidget* desktop_proxy;
-};
-
-static XdndData xdnd_data = { 0, 0 };
-
-class QExtraWidget : public QWidget
-{
- Q_DECLARE_PRIVATE(QWidget)
-public:
- inline QWExtra* extraData();
- inline QTLWExtra* topData();
-};
-
-inline QWExtra* QExtraWidget::extraData() { return d_func()->extraData(); }
-inline QTLWExtra* QExtraWidget::topData() { return d_func()->topData(); }
-
-
-static WId xdndProxy(WId w)
-{
- Atom type = XNone;
- int f;
- unsigned long n, a;
- unsigned char *retval = 0;
- XGetWindowProperty(X11->display, w, ATOM(XdndProxy), 0, 1, False,
- XA_WINDOW, &type, &f,&n,&a,&retval);
- WId *proxy_id_ptr = (WId *)retval;
- WId proxy_id = 0;
- if (type == XA_WINDOW && proxy_id_ptr) {
- proxy_id = *proxy_id_ptr;
- XFree(proxy_id_ptr);
- proxy_id_ptr = 0;
- // Already exists. Real?
- X11->ignoreBadwindow();
- XGetWindowProperty(X11->display, proxy_id, ATOM(XdndProxy), 0, 1, False,
- XA_WINDOW, &type, &f,&n,&a,&retval);
- proxy_id_ptr = (WId *)retval;
- if (X11->badwindow() || type != XA_WINDOW || !proxy_id_ptr || *proxy_id_ptr != proxy_id)
- // Bogus - we will overwrite.
- proxy_id = 0;
- }
- if (proxy_id_ptr)
- XFree(proxy_id_ptr);
- return proxy_id;
-}
-
-static bool xdndEnable(QWidget* w, bool on)
-{
- DNDDEBUG << "xdndEnable" << w << on;
- if (on) {
- QWidget * xdnd_widget = 0;
- if ((w->windowType() == Qt::Desktop)) {
- if (xdnd_data.desktop_proxy) // *WE* already have one.
- return false;
-
- // As per Xdnd4, use XdndProxy
- XGrabServer(X11->display);
- Q_ASSERT(w->testAttribute(Qt::WA_WState_Created));
- WId proxy_id = xdndProxy(w->effectiveWinId());
-
- if (!proxy_id) {
- xdnd_widget = xdnd_data.desktop_proxy = new QWidget;
- proxy_id = xdnd_data.desktop_proxy->effectiveWinId();
- XChangeProperty (X11->display, w->effectiveWinId(), ATOM(XdndProxy),
- XA_WINDOW, 32, PropModeReplace, (unsigned char *)&proxy_id, 1);
- XChangeProperty (X11->display, proxy_id, ATOM(XdndProxy),
- XA_WINDOW, 32, PropModeReplace, (unsigned char *)&proxy_id, 1);
- }
-
- XUngrabServer(X11->display);
- } else {
- xdnd_widget = w->window();
- }
- if (xdnd_widget) {
- DNDDEBUG << "setting XdndAware for" << xdnd_widget << xdnd_widget->effectiveWinId();
- Atom atm = (Atom)xdnd_version;
- Q_ASSERT(xdnd_widget->testAttribute(Qt::WA_WState_Created));
- XChangeProperty(X11->display, xdnd_widget->effectiveWinId(), ATOM(XdndAware),
- XA_ATOM, 32, PropModeReplace, (unsigned char *)&atm, 1);
- return true;
- } else {
- return false;
- }
- } else {
- if ((w->windowType() == Qt::Desktop)) {
- XDeleteProperty(X11->display, w->internalWinId(), ATOM(XdndProxy));
- delete xdnd_data.desktop_proxy;
- xdnd_data.desktop_proxy = 0;
- } else {
- DNDDEBUG << "not deleting XDndAware";
- }
- return true;
- }
-}
-
-QByteArray QX11Data::xdndAtomToString(Atom a)
-{
- if (!a) return 0;
-
- if (a == XA_STRING || a == ATOM(UTF8_STRING)) {
- return "text/plain"; // some Xdnd clients are dumb
- }
- char *atom = XGetAtomName(display, a);
- QByteArray result = atom;
- XFree(atom);
- return result;
-}
-
-Atom QX11Data::xdndStringToAtom(const char *mimeType)
-{
- if (!mimeType || !*mimeType)
- return 0;
- return XInternAtom(display, mimeType, False);
-}
-
-//$$$
-QString QX11Data::xdndMimeAtomToString(Atom a)
-{
- QString atomName;
- if (a) {
- char *atom = XGetAtomName(display, a);
- atomName = QString::fromLatin1(atom);
- XFree(atom);
- }
- return atomName;
-}
-
-//$$$
-Atom QX11Data::xdndMimeStringToAtom(const QString &mimeType)
-{
- if (mimeType.isEmpty())
- return 0;
- return XInternAtom(display, mimeType.toLatin1().constData(), False);
-}
-
-//$$$ replace ccxdndAtomToString()
-QStringList QX11Data::xdndMimeFormatsForAtom(Atom a)
-{
- QStringList formats;
- if (a) {
- QString atomName = xdndMimeAtomToString(a);
- formats.append(atomName);
-
- // special cases for string type
- if (a == ATOM(UTF8_STRING) || a == XA_STRING
- || a == ATOM(TEXT) || a == ATOM(COMPOUND_TEXT))
- formats.append(QLatin1String("text/plain"));
-
- // special cases for uris
- if (atomName == QLatin1String("text/x-moz-url"))
- formats.append(QLatin1String("text/uri-list"));
-
- // special case for images
- if (a == XA_PIXMAP)
- formats.append(QLatin1String("image/ppm"));
- }
- return formats;
-}
-
-//$$$
-bool QX11Data::xdndMimeDataForAtom(Atom a, QMimeData *mimeData, QByteArray *data, Atom *atomFormat, int *dataFormat)
-{
- bool ret = false;
- *atomFormat = a;
- *dataFormat = 8;
- QString atomName = xdndMimeAtomToString(a);
- if (QInternalMimeData::hasFormatHelper(atomName, mimeData)) {
- *data = QInternalMimeData::renderDataHelper(atomName, mimeData);
- if (atomName == QLatin1String("application/x-color"))
- *dataFormat = 16;
- ret = true;
- } else {
- if ((a == ATOM(UTF8_STRING) || a == XA_STRING
- || a == ATOM(TEXT) || a == ATOM(COMPOUND_TEXT))
- && QInternalMimeData::hasFormatHelper(QLatin1String("text/plain"), mimeData)) {
- if (a == ATOM(UTF8_STRING)){
- *data = QInternalMimeData::renderDataHelper(QLatin1String("text/plain"), mimeData);
- ret = true;
- } else if (a == XA_STRING) {
- *data = QString::fromUtf8(QInternalMimeData::renderDataHelper(
- QLatin1String("text/plain"), mimeData)).toLocal8Bit();
- ret = true;
- } else if (a == ATOM(TEXT) || a == ATOM(COMPOUND_TEXT)) {
- // the ICCCM states that TEXT and COMPOUND_TEXT are in the
- // encoding of choice, so we choose the encoding of the locale
- QByteArray strData = QString::fromUtf8(QInternalMimeData::renderDataHelper(
- QLatin1String("text/plain"), mimeData)).toLocal8Bit();
- char *list[] = { strData.data(), NULL };
-
- XICCEncodingStyle style = (a == ATOM(COMPOUND_TEXT))
- ? XCompoundTextStyle : XStdICCTextStyle;
- XTextProperty textprop;
- if (list[0] != NULL
- && XmbTextListToTextProperty(X11->display, list, 1, style,
- &textprop) == Success) {
- *atomFormat = textprop.encoding;
- *dataFormat = textprop.format;
- *data = QByteArray((const char *) textprop.value, textprop.nitems * textprop.format / 8);
- ret = true;
-
- DEBUG(" textprop type %lx\n"
- " textprop name '%s'\n"
- " format %d\n"
- " %ld items\n"
- " %d bytes\n",
- textprop.encoding,
- X11->xdndMimeAtomToString(textprop.encoding).toLatin1().data(),
- textprop.format, textprop.nitems, data->size());
-
- XFree(textprop.value);
- }
- }
- } else if (atomName == QLatin1String("text/x-moz-url") &&
- QInternalMimeData::hasFormatHelper(QLatin1String("text/uri-list"), mimeData)) {
- QByteArray uri = QInternalMimeData::renderDataHelper(
- QLatin1String("text/uri-list"), mimeData).split('\n').first();
- QString mozUri = QString::fromLatin1(uri, uri.size());
- mozUri += QLatin1Char('\n');
- *data = QByteArray(reinterpret_cast<const char *>(mozUri.utf16()), mozUri.length() * 2);
- ret = true;
- } else if ((a == XA_PIXMAP || a == XA_BITMAP) && mimeData->hasImage()) {
- QPixmap pm = qvariant_cast<QPixmap>(mimeData->imageData());
- if (a == XA_BITMAP && pm.depth() != 1) {
- QImage img = pm.toImage();
- img = img.convertToFormat(QImage::Format_MonoLSB);
- pm = QPixmap::fromImage(img);
- }
- QDragManager *dm = QDragManager::self();
- if (dm) {
- Pixmap handle = pm.handle();
- *data = QByteArray((const char *) &handle, sizeof(Pixmap));
- dm->xdndMimeTransferedPixmap[dm->xdndMimeTransferedPixmapIndex] = pm;
- dm->xdndMimeTransferedPixmapIndex =
- (dm->xdndMimeTransferedPixmapIndex + 1) % 2;
- ret = true;
- }
- } else {
- DEBUG("QClipboard: xdndMimeDataForAtom(): converting to type '%s' is not supported", qPrintable(atomName));
- }
- }
- return ret && data != 0;
-}
-
-//$$$
-QList<Atom> QX11Data::xdndMimeAtomsForFormat(const QString &format)
-{
- QList<Atom> atoms;
- atoms.append(xdndMimeStringToAtom(format));
-
- // special cases for strings
- if (format == QLatin1String("text/plain")) {
- atoms.append(ATOM(UTF8_STRING));
- atoms.append(XA_STRING);
- atoms.append(ATOM(TEXT));
- atoms.append(ATOM(COMPOUND_TEXT));
- }
-
- // special cases for uris
- if (format == QLatin1String("text/uri-list")) {
- atoms.append(xdndMimeStringToAtom(QLatin1String("text/x-moz-url")));
- }
-
- //special cases for images
- if (format == QLatin1String("image/ppm"))
- atoms.append(XA_PIXMAP);
- if (format == QLatin1String("image/pbm"))
- atoms.append(XA_BITMAP);
-
- return atoms;
-}
-
-//$$$
-QVariant QX11Data::xdndMimeConvertToFormat(Atom a, const QByteArray &data, const QString &format, QVariant::Type requestedType, const QByteArray &encoding)
-{
- QString atomName = xdndMimeAtomToString(a);
- if (atomName == format)
- return data;
-
- if (!encoding.isEmpty()
- && atomName == format + QLatin1String(";charset=") + QString::fromLatin1(encoding)) {
-
- if (requestedType == QVariant::String) {
- QTextCodec *codec = QTextCodec::codecForName(encoding);
- if (codec)
- return codec->toUnicode(data);
- }
-
- return data;
- }
-
- // special cases for string types
- if (format == QLatin1String("text/plain")) {
- if (a == ATOM(UTF8_STRING))
- return QString::fromUtf8(data);
- if (a == XA_STRING)
- return QString::fromLatin1(data);
- if (a == ATOM(TEXT) || a == ATOM(COMPOUND_TEXT))
- // #### might be wrong for COMPUND_TEXT
- return QString::fromLocal8Bit(data, data.size());
- }
-
- // special case for uri types
- if (format == QLatin1String("text/uri-list")) {
- if (atomName == QLatin1String("text/x-moz-url")) {
- // we expect this as utf16 <url><space><title>
- // the first part is a url that should only contain ascci char
- // so it should be safe to check that the second char is 0
- // to verify that it is utf16
- if (data.size() > 1 && data.at(1) == 0)
- return QString::fromRawData((const QChar *)data.constData(),
- data.size() / 2).split(QLatin1Char('\n')).first().toLatin1();
- }
- }
-
- // special cas for images
- if (format == QLatin1String("image/ppm")) {
- if (a == XA_PIXMAP && data.size() == sizeof(Pixmap)) {
- Pixmap xpm = *((Pixmap*)data.data());
- if (!xpm)
- return QByteArray();
- QPixmap qpm = QPixmap::fromX11Pixmap(xpm);
- QImageWriter imageWriter;
- imageWriter.setFormat("PPMRAW");
- QImage imageToWrite = qpm.toImage();
- QBuffer buf;
- buf.open(QIODevice::WriteOnly);
- imageWriter.setDevice(&buf);
- imageWriter.write(imageToWrite);
- return buf.buffer();
- }
- }
- return QVariant();
-}
-
-//$$$ middle of xdndObtainData
-Atom QX11Data::xdndMimeAtomForFormat(const QString &format, QVariant::Type requestedType, const QList<Atom> &atoms, QByteArray *encoding)
-{
- encoding->clear();
-
- // find matches for string types
- if (format == QLatin1String("text/plain")) {
- if (atoms.contains(ATOM(UTF8_STRING)))
- return ATOM(UTF8_STRING);
- if (atoms.contains(ATOM(COMPOUND_TEXT)))
- return ATOM(COMPOUND_TEXT);
- if (atoms.contains(ATOM(TEXT)))
- return ATOM(TEXT);
- if (atoms.contains(XA_STRING))
- return XA_STRING;
- }
-
- // find matches for uri types
- if (format == QLatin1String("text/uri-list")) {
- Atom a = xdndMimeStringToAtom(format);
- if (a && atoms.contains(a))
- return a;
- a = xdndMimeStringToAtom(QLatin1String("text/x-moz-url"));
- if (a && atoms.contains(a))
- return a;
- }
-
- // find match for image
- if (format == QLatin1String("image/ppm")) {
- if (atoms.contains(XA_PIXMAP))
- return XA_PIXMAP;
- }
-
- // for string/text requests try to use a format with a well-defined charset
- // first to avoid encoding problems
- if (requestedType == QVariant::String
- && format.startsWith(QLatin1String("text/"))
- && !format.contains(QLatin1String("charset="))) {
-
- QString formatWithCharset = format;
- formatWithCharset.append(QLatin1String(";charset=utf-8"));
-
- Atom a = xdndMimeStringToAtom(formatWithCharset);
- if (a && atoms.contains(a)) {
- *encoding = "utf-8";
- return a;
- }
- }
-
- Atom a = xdndMimeStringToAtom(format);
- if (a && atoms.contains(a))
- return a;
-
- return 0;
-}
-
-void QX11Data::xdndSetup() {
- QCursorData::initialize();
- qAddPostRoutine(qt_xdnd_cleanup);
-}
-
-
-void qt_xdnd_cleanup()
-{
- delete noDropCursor;
- noDropCursor = 0;
- delete copyCursor;
- copyCursor = 0;
- delete moveCursor;
- moveCursor = 0;
- delete linkCursor;
- linkCursor = 0;
- delete defaultPm;
- defaultPm = 0;
- delete xdnd_data.desktop_proxy;
- xdnd_data.desktop_proxy = 0;
- delete xdnd_data.deco;
- xdnd_data.deco = 0;
-}
-
-
-static QWidget *find_child(QWidget *tlw, QPoint & p)
-{
- QWidget *widget = tlw;
-
- p = widget->mapFromGlobal(p);
- bool done = false;
- while (!done) {
- done = true;
- if (((QExtraWidget*)widget)->extraData() &&
- ((QExtraWidget*)widget)->extraData()->xDndProxy != 0)
- break; // stop searching for widgets under the mouse cursor if found widget is a proxy.
- QObjectList children = widget->children();
- if (!children.isEmpty()) {
- for(int i = children.size(); i > 0;) {
- --i;
- QWidget *w = qobject_cast<QWidget *>(children.at(i));
- if (!w)
- continue;
- if (w->testAttribute(Qt::WA_TransparentForMouseEvents))
- continue;
- if (w->isVisible() &&
- w->geometry().contains(p) &&
- !w->isWindow()) {
- widget = w;
- done = false;
- p = widget->mapFromParent(p);
- break;
- }
- }
- }
- }
- return widget;
-}
-
-
-static bool checkEmbedded(QWidget* w, const XEvent* xe)
-{
- if (!w)
- return false;
-
- if (current_embedding_widget != 0 && current_embedding_widget != w) {
- qt_xdnd_current_target = ((QExtraWidget*)current_embedding_widget)->extraData()->xDndProxy;
- qt_xdnd_current_proxy_target = qt_xdnd_current_target;
- qt_xdnd_send_leave();
- qt_xdnd_current_target = 0;
- qt_xdnd_current_proxy_target = 0;
- current_embedding_widget = 0;
- }
-
- QWExtra* extra = ((QExtraWidget*)w)->extraData();
- if (extra && extra->xDndProxy != 0) {
-
- if (current_embedding_widget != w) {
-
- last_enter_event.xany.window = extra->xDndProxy;
- XSendEvent(X11->display, extra->xDndProxy, False, NoEventMask, &last_enter_event);
- current_embedding_widget = w;
- }
-
- ((XEvent*)xe)->xany.window = extra->xDndProxy;
- XSendEvent(X11->display, extra->xDndProxy, False, NoEventMask, (XEvent*)xe);
- if (qt_xdnd_current_widget != w) {
- qt_xdnd_current_widget = w;
- }
- return true;
- }
- current_embedding_widget = 0;
- return false;
-}
-
-void QX11Data::xdndHandleEnter(QWidget *, const XEvent * xe, bool /*passive*/)
-{
- motifdnd_active = false;
-
- last_enter_event.xclient = xe->xclient;
-
- const long *l = xe->xclient.data.l;
- int version = (int)(((unsigned long)(l[1])) >> 24);
-
- if (version > xdnd_version)
- return;
-
- qt_xdnd_dragsource_xid = l[0];
-
- int j = 0;
- if (l[1] & 1) {
- // get the types from XdndTypeList
- Atom type = XNone;
- int f;
- unsigned long n, a;
- unsigned char *retval = 0;
- XGetWindowProperty(X11->display, qt_xdnd_dragsource_xid, ATOM(XdndTypelist), 0,
- qt_xdnd_max_type, False, XA_ATOM, &type, &f,&n,&a,&retval);
- if (retval) {
- Atom *data = (Atom *)retval;
- for (; j<qt_xdnd_max_type && j < (int)n; j++) {
- qt_xdnd_types[j] = data[j];
- }
- XFree((uchar*)data);
- }
- } else {
- // get the types from the message
- int i;
- for(i=2; i < 5; i++) {
- qt_xdnd_types[j++] = l[i];
- }
- }
- qt_xdnd_types[j] = 0;
-}
-
-static void handle_xdnd_position(QWidget *w, const XEvent * xe, bool passive)
-{
- const unsigned long *l = (const unsigned long *)xe->xclient.data.l;
-
- QPoint p((l[2] & 0xffff0000) >> 16, l[2] & 0x0000ffff);
- QWidget * c = find_child(w, p); // changes p to to c-local coordinates
-
- if (!passive && checkEmbedded(c, xe))
- return;
-
- if (!c || (!c->acceptDrops() && (c->windowType() == Qt::Desktop)))
- return;
-
- if (l[0] != qt_xdnd_dragsource_xid) {
- DEBUG("xdnd drag position from unexpected source (%08lx not %08lx)", l[0], qt_xdnd_dragsource_xid);
- return;
- }
-
- // timestamp from the source
- if (l[3] != 0) {
- // Some X server/client combination swallow the first 32 bit and
- // interpret a set bit 31 as negative sign.
- qt_xdnd_target_current_time = X11->userTime =
- ((sizeof(Time) == 8 && xe->xclient.data.l[3] < 0)
- ? uint(l[3])
- : l[3]);
- }
-
- QDragManager *manager = QDragManager::self();
- QMimeData *dropData = manager->object ? manager->dragPrivate()->data : manager->dropData;
-
- XClientMessageEvent response;
- response.type = ClientMessage;
- response.window = qt_xdnd_dragsource_xid;
- response.format = 32;
- response.message_type = ATOM(XdndStatus);
- response.data.l[0] = w->effectiveWinId();
- response.data.l[1] = 0; // flags
- response.data.l[2] = 0; // x, y
- response.data.l[3] = 0; // w, h
- response.data.l[4] = 0; // action
-
- if (!passive) { // otherwise just reject
- while (c && !c->acceptDrops() && !c->isWindow()) {
- p = c->mapToParent(p);
- c = c->parentWidget();
- }
- QWidget *target_widget = c && c->acceptDrops() ? c : 0;
-
- QRect answerRect(c->mapToGlobal(p), QSize(1,1));
-
- if (manager->object) {
- possible_actions = manager->dragPrivate()->possible_actions;
- } else {
- possible_actions = Qt::DropActions(xdndaction_to_qtaction(l[4]));
-// possible_actions |= Qt::CopyAction;
- }
- QDragMoveEvent me(p, possible_actions, dropData, QApplication::mouseButtons(), QApplication::keyboardModifiers());
-
- Qt::DropAction accepted_action = Qt::IgnoreAction;
-
-
- if (target_widget != qt_xdnd_current_widget) {
- if (qt_xdnd_current_widget) {
- QDragLeaveEvent e;
- QApplication::sendEvent(qt_xdnd_current_widget, &e);
- }
- if (qt_xdnd_current_widget != target_widget) {
- qt_xdnd_current_widget = target_widget;
- }
- if (target_widget) {
- qt_xdnd_current_position = p;
-
- last_target_accepted_action = Qt::IgnoreAction;
- QDragEnterEvent de(p, possible_actions, dropData, QApplication::mouseButtons(), QApplication::keyboardModifiers());
- QApplication::sendEvent(target_widget, &de);
- if (de.isAccepted() && de.dropAction() != Qt::IgnoreAction)
- last_target_accepted_action = de.dropAction();
- }
- }
-
- DEBUG() << "qt_handle_xdnd_position action=" << X11->xdndAtomToString(l[4]);
- if (!target_widget) {
- answerRect = QRect(p, QSize(1, 1));
- } else {
- qt_xdnd_current_widget = c;
- qt_xdnd_current_position = p;
-
- if (last_target_accepted_action != Qt::IgnoreAction) {
- me.setDropAction(last_target_accepted_action);
- me.accept();
- }
- QApplication::sendEvent(c, &me);
- if (me.isAccepted()) {
- response.data.l[1] = 1; // yes
- accepted_action = me.dropAction();
- last_target_accepted_action = accepted_action;
- } else {
- response.data.l[0] = 0;
- last_target_accepted_action = Qt::IgnoreAction;
- }
- answerRect = me.answerRect().intersected(c->rect());
- }
- answerRect = QRect(c->mapToGlobal(answerRect.topLeft()), answerRect.size());
-
- if (answerRect.left() < 0)
- answerRect.setLeft(0);
- if (answerRect.right() > 4096)
- answerRect.setRight(4096);
- if (answerRect.top() < 0)
- answerRect.setTop(0);
- if (answerRect.bottom() > 4096)
- answerRect.setBottom(4096);
- if (answerRect.width() < 0)
- answerRect.setWidth(0);
- if (answerRect.height() < 0)
- answerRect.setHeight(0);
-
- response.data.l[2] = (answerRect.x() << 16) + answerRect.y();
- response.data.l[3] = (answerRect.width() << 16) + answerRect.height();
- response.data.l[4] = qtaction_to_xdndaction(accepted_action);
- }
-
- // reset
- qt_xdnd_target_current_time = CurrentTime;
-
- QWidget * source = QWidget::find(qt_xdnd_dragsource_xid);
- if (source && (source->windowType() == Qt::Desktop) && !source->acceptDrops())
- source = 0;
-
- DEBUG() << "sending XdndStatus";
- if (source)
- handle_xdnd_status(source, (const XEvent *)&response, passive);
- else
- XSendEvent(X11->display, qt_xdnd_dragsource_xid, False, NoEventMask, (XEvent*)&response);
-}
-
-static Bool xdnd_position_scanner(Display *, XEvent *event, XPointer)
-{
- if (event->type != ClientMessage)
- return false;
- XClientMessageEvent *ev = &event->xclient;
-
- if (ev->message_type == ATOM(XdndPosition))
- return true;
-
- return false;
-}
-
-void QX11Data::xdndHandlePosition(QWidget * w, const XEvent * xe, bool passive)
-{
- DEBUG("xdndHandlePosition");
- while (XCheckIfEvent(X11->display, (XEvent *)xe, xdnd_position_scanner, 0))
- ;
-
- handle_xdnd_position(w, xe, passive);
-}
-
-
-static void handle_xdnd_status(QWidget *, const XEvent * xe, bool)
-{
- const unsigned long *l = (const unsigned long *)xe->xclient.data.l;
- // ignore late status messages
- if (l[0] && l[0] != qt_xdnd_current_proxy_target)
- return;
- Qt::DropAction newAction = (l[1] & 0x1) ? xdndaction_to_qtaction(l[4]) : Qt::IgnoreAction;
-
- if ((int)(l[1] & 2) == 0) {
- QPoint p((l[2] & 0xffff0000) >> 16, l[2] & 0x0000ffff);
- QSize s((l[3] & 0xffff0000) >> 16, l[3] & 0x0000ffff);
- qt_xdnd_source_sameanswer = QRect(p, s);
- } else {
- qt_xdnd_source_sameanswer = QRect();
- }
- QDragManager *manager = QDragManager::self();
- manager->willDrop = (l[1] & 0x1);
- if (global_accepted_action != newAction)
- manager->emitActionChanged(newAction);
- global_accepted_action = newAction;
- manager->updateCursor();
- waiting_for_status = false;
-}
-
-static Bool xdnd_status_scanner(Display *, XEvent *event, XPointer)
-{
- if (event->type != ClientMessage)
- return false;
- XClientMessageEvent *ev = &event->xclient;
-
- if (ev->message_type == ATOM(XdndStatus))
- return true;
-
- return false;
-}
-
-void QX11Data::xdndHandleStatus(QWidget * w, const XEvent * xe, bool passive)
-{
- DEBUG("xdndHandleStatus");
- while (XCheckIfEvent(X11->display, (XEvent *)xe, xdnd_status_scanner, 0))
- ;
-
- handle_xdnd_status(w, xe, passive);
- DEBUG("xdndHandleStatus end");
-}
-
-void QX11Data::xdndHandleLeave(QWidget *w, const XEvent * xe, bool /*passive*/)
-{
- DEBUG("xdnd leave");
- if (!qt_xdnd_current_widget ||
- w->window() != qt_xdnd_current_widget->window()) {
- return; // sanity
- }
-
- if (checkEmbedded(current_embedding_widget, xe)) {
- current_embedding_widget = 0;
- qt_xdnd_current_widget = 0;
- return;
- }
-
- const unsigned long *l = (const unsigned long *)xe->xclient.data.l;
-
- QDragLeaveEvent e;
- QApplication::sendEvent(qt_xdnd_current_widget, &e);
-
- if (l[0] != qt_xdnd_dragsource_xid) {
- // This often happens - leave other-process window quickly
- DEBUG("xdnd drag leave from unexpected source (%08lx not %08lx", l[0], qt_xdnd_dragsource_xid);
- qt_xdnd_current_widget = 0;
- return;
- }
-
- qt_xdnd_dragsource_xid = 0;
- qt_xdnd_types[0] = 0;
- qt_xdnd_current_widget = 0;
-}
-
-
-void qt_xdnd_send_leave()
-{
- if (!qt_xdnd_current_target)
- return;
-
- QDragManager *manager = QDragManager::self();
-
- XClientMessageEvent leave;
- leave.type = ClientMessage;
- leave.window = qt_xdnd_current_target;
- leave.format = 32;
- leave.message_type = ATOM(XdndLeave);
- leave.data.l[0] = manager->dragPrivate()->source->effectiveWinId();
- leave.data.l[1] = 0; // flags
- leave.data.l[2] = 0; // x, y
- leave.data.l[3] = 0; // w, h
- leave.data.l[4] = 0; // just null
-
- QWidget * w = QWidget::find(qt_xdnd_current_proxy_target);
-
- if (w && (w->windowType() == Qt::Desktop) && !w->acceptDrops())
- w = 0;
-
- if (w)
- X11->xdndHandleLeave(w, (const XEvent *)&leave, false);
- else
- XSendEvent(X11->display, qt_xdnd_current_proxy_target, False,
- NoEventMask, (XEvent*)&leave);
-
- // reset the drag manager state
- manager->willDrop = false;
- if (global_accepted_action != Qt::IgnoreAction)
- manager->emitActionChanged(Qt::IgnoreAction);
- global_accepted_action = Qt::IgnoreAction;
- manager->updateCursor();
- qt_xdnd_current_target = 0;
- qt_xdnd_current_proxy_target = 0;
- qt_xdnd_source_current_time = 0;
- waiting_for_status = false;
-}
-
-// TODO: remove and use QApplication::currentKeyboardModifiers() in Qt 4.8.
-static Qt::KeyboardModifiers currentKeyboardModifiers()
-{
- Window root;
- Window child;
- int root_x, root_y, win_x, win_y;
- uint keybstate;
- for (int i = 0; i < ScreenCount(X11->display); ++i) {
- if (XQueryPointer(X11->display, QX11Info::appRootWindow(i), &root, &child,
- &root_x, &root_y, &win_x, &win_y, &keybstate))
- return X11->translateModifiers(keybstate & 0x00ff);
- }
- return 0;
-}
-
-void QX11Data::xdndHandleDrop(QWidget *, const XEvent * xe, bool passive)
-{
- DEBUG("xdndHandleDrop");
- if (!qt_xdnd_current_widget) {
- qt_xdnd_dragsource_xid = 0;
- return; // sanity
- }
-
- if (!passive && checkEmbedded(qt_xdnd_current_widget, xe)){
- current_embedding_widget = 0;
- qt_xdnd_dragsource_xid = 0;
- qt_xdnd_current_widget = 0;
- return;
- }
- const unsigned long *l = (const unsigned long *)xe->xclient.data.l;
-
- QDragManager *manager = QDragManager::self();
- DEBUG("xdnd drop");
-
- if (l[0] != qt_xdnd_dragsource_xid) {
- DEBUG("xdnd drop from unexpected source (%08lx not %08lx", l[0], qt_xdnd_dragsource_xid);
- return;
- }
-
- // update the "user time" from the timestamp in the event.
- if (l[2] != 0) {
- // Some X server/client combination swallow the first 32 bit and
- // interpret a set bit 31 as negative sign.
- qt_xdnd_target_current_time = X11->userTime =
- ((sizeof(Time) == 8 && xe->xclient.data.l[2] < 0)
- ? uint(l[2])
- : l[2]);
- }
-
- if (!passive) {
- // this could be a same-application drop, just proxied due to
- // some XEMBEDding, so try to find the real QMimeData used
- // based on the timestamp for this drop.
- QMimeData *dropData = 0;
- int at = findXdndDropTransactionByTime(qt_xdnd_target_current_time);
- if (at != -1)
- dropData = QDragManager::dragPrivate(X11->dndDropTransactions.at(at).object)->data;
- // if we can't find it, then use the data in the drag manager
- if (!dropData)
- dropData = (manager->object) ? manager->dragPrivate()->data : manager->dropData;
-
- // Drop coming from another app? Update keyboard modifiers.
- if (!qt_xdnd_dragging) {
- QApplicationPrivate::modifier_buttons = currentKeyboardModifiers();
- }
-
- QDropEvent de(qt_xdnd_current_position, possible_actions, dropData,
- QApplication::mouseButtons(), QApplication::keyboardModifiers());
- QApplication::sendEvent(qt_xdnd_current_widget, &de);
- if (!de.isAccepted()) {
- // Ignore a failed drag
- global_accepted_action = Qt::IgnoreAction;
- } else {
- global_accepted_action = de.dropAction();
- }
- XClientMessageEvent finished;
- finished.type = ClientMessage;
- finished.window = qt_xdnd_dragsource_xid;
- finished.format = 32;
- finished.message_type = ATOM(XdndFinished);
- DNDDEBUG << "xdndHandleDrop"
- << "qt_xdnd_current_widget" << qt_xdnd_current_widget
- << (qt_xdnd_current_widget ? qt_xdnd_current_widget->effectiveWinId() : 0)
- << "t_xdnd_current_widget->window()"
- << (qt_xdnd_current_widget ? qt_xdnd_current_widget->window() : 0)
- << (qt_xdnd_current_widget ? qt_xdnd_current_widget->window()->internalWinId() : 0);
- finished.data.l[0] = qt_xdnd_current_widget?qt_xdnd_current_widget->window()->internalWinId():0;
- finished.data.l[1] = de.isAccepted() ? 1 : 0; // flags
- finished.data.l[2] = qtaction_to_xdndaction(global_accepted_action);
- XSendEvent(X11->display, qt_xdnd_dragsource_xid, False,
- NoEventMask, (XEvent*)&finished);
- } else {
- QDragLeaveEvent e;
- QApplication::sendEvent(qt_xdnd_current_widget, &e);
- }
- qt_xdnd_dragsource_xid = 0;
- qt_xdnd_current_widget = 0;
- waiting_for_status = false;
-
- // reset
- qt_xdnd_target_current_time = CurrentTime;
-}
-
-
-void QX11Data::xdndHandleFinished(QWidget *, const XEvent * xe, bool passive)
-{
- DEBUG("xdndHandleFinished");
- const unsigned long *l = (const unsigned long *)xe->xclient.data.l;
-
- DNDDEBUG << "xdndHandleFinished, l[0]" << l[0]
- << "qt_xdnd_current_target" << qt_xdnd_current_target
- << "qt_xdnd_current_proxy_targe" << qt_xdnd_current_proxy_target;
-
- if (l[0]) {
- int at = findXdndDropTransactionByWindow(l[0]);
- if (at != -1) {
- restartXdndDropExpiryTimer();
-
- QXdndDropTransaction t = X11->dndDropTransactions.takeAt(at);
- QDragManager *manager = QDragManager::self();
-
- Window target = qt_xdnd_current_target;
- Window proxy_target = qt_xdnd_current_proxy_target;
- QWidget *embedding_widget = current_embedding_widget;
- QDrag *currentObject = manager->object;
-
- qt_xdnd_current_target = t.target;
- qt_xdnd_current_proxy_target = t.proxy_target;
- current_embedding_widget = t.embedding_widget;
- manager->object = t.object;
-
- if (!passive)
- (void) checkEmbedded(qt_xdnd_current_widget, xe);
-
- current_embedding_widget = 0;
- qt_xdnd_current_target = 0;
- qt_xdnd_current_proxy_target = 0;
-
- if (t.object)
- t.object->deleteLater();
-
- qt_xdnd_current_target = target;
- qt_xdnd_current_proxy_target = proxy_target;
- current_embedding_widget = embedding_widget;
- manager->object = currentObject;
- }
- }
- waiting_for_status = false;
-}
-
-
-void QDragManager::timerEvent(QTimerEvent* e)
-{
- if (e->timerId() == heartbeat && qt_xdnd_source_sameanswer.isNull()) {
- move(QCursor::pos());
- } else if (e->timerId() == transaction_expiry_timer) {
- for (int i = 0; i < X11->dndDropTransactions.count(); ++i) {
- const QXdndDropTransaction &t = X11->dndDropTransactions.at(i);
- if (t.targetWidget) {
- // dnd within the same process, don't delete these
- continue;
- }
- t.object->deleteLater();
- X11->dndDropTransactions.removeAt(i--);
- }
-
- killTimer(transaction_expiry_timer);
- transaction_expiry_timer = -1;
- }
-}
-
-bool QDragManager::eventFilter(QObject * o, QEvent * e)
-{
- if (beingCancelled) {
- if (e->type() == QEvent::KeyRelease && ((QKeyEvent*)e)->key() == Qt::Key_Escape) {
- qApp->removeEventFilter(this);
- Q_ASSERT(object == 0);
- beingCancelled = false;
- eventLoop->exit();
- return true; // block the key release
- }
- return false;
- }
-
- Q_ASSERT(object != 0);
-
- if (!o->isWidgetType())
- return false;
-
- if (e->type() == QEvent::MouseMove) {
- QMouseEvent* me = (QMouseEvent *)e;
- move(me->globalPos());
- return true;
- } else if (e->type() == QEvent::MouseButtonRelease) {
- DEBUG("pre drop");
- qApp->removeEventFilter(this);
- if (willDrop)
- drop();
- else
- cancel();
- DEBUG("drop, resetting object");
- beingCancelled = false;
- eventLoop->exit();
- return true;
- }
-
- if (e->type() == QEvent::ShortcutOverride) {
- // prevent accelerators from firing while dragging
- e->accept();
- return true;
- }
-
- if (e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease) {
- QKeyEvent *ke = ((QKeyEvent*)e);
- if (ke->key() == Qt::Key_Escape && e->type() == QEvent::KeyPress) {
- cancel();
- qApp->removeEventFilter(this);
- beingCancelled = false;
- eventLoop->exit();
- } else {
- qt_xdnd_source_sameanswer = QRect(); // force move
- move(QCursor::pos());
- }
- return true; // Eat all key events
- }
-
- // ### We bind modality to widgets, so we have to do this
- // ### "manually".
- // DnD is modal - eat all other interactive events
- switch (e->type()) {
- case QEvent::MouseButtonPress:
- case QEvent::MouseButtonRelease:
- case QEvent::MouseButtonDblClick:
- case QEvent::MouseMove:
- case QEvent::KeyPress:
- case QEvent::KeyRelease:
- case QEvent::Wheel:
- case QEvent::ShortcutOverride:
-#ifdef QT3_SUPPORT
- case QEvent::Accel:
- case QEvent::AccelAvailable:
-#endif
- return true;
- default:
- return false;
- }
-}
-
-void QDragManager::updateCursor()
-{
- if (!noDropCursor) {
-#ifndef QT_NO_CURSOR
- noDropCursor = new QCursor(Qt::ForbiddenCursor);
- moveCursor = new QCursor(Qt::DragMoveCursor);
- copyCursor = new QCursor(Qt::DragCopyCursor);
- linkCursor = new QCursor(Qt::DragLinkCursor);
-#endif
- }
-
- QCursor *c;
- if (willDrop) {
- if (global_accepted_action == Qt::CopyAction) {
- c = copyCursor;
- } else if (global_accepted_action == Qt::LinkAction) {
- c = linkCursor;
- } else {
- c = moveCursor;
- }
- if (xdnd_data.deco) {
- xdnd_data.deco->show();
- xdnd_data.deco->raise();
- }
- } else {
- c = noDropCursor;
- //if (qt_xdnd_deco)
- // qt_xdnd_deco->hide();
- }
-#ifndef QT_NO_CURSOR
- if (c)
- qApp->changeOverrideCursor(*c);
-#endif
-}
-
-
-void QDragManager::cancel(bool deleteSource)
-{
- DEBUG("QDragManager::cancel");
- Q_ASSERT(heartbeat != -1);
- killTimer(heartbeat);
- heartbeat = -1;
- beingCancelled = true;
- qt_xdnd_dragging = false;
-
- if (qt_xdnd_current_target)
- qt_xdnd_send_leave();
-
-#ifndef QT_NO_CURSOR
- if (restoreCursor) {
- QApplication::restoreOverrideCursor();
- restoreCursor = false;
- }
-#endif
-
- if (deleteSource && object)
- object->deleteLater();
- object = 0;
- qDeleteInEventHandler(xdnd_data.deco);
- xdnd_data.deco = 0;
-
- global_accepted_action = Qt::IgnoreAction;
-}
-
-static
-Window findRealWindow(const QPoint & pos, Window w, int md)
-{
- if (xdnd_data.deco && w == xdnd_data.deco->effectiveWinId())
- return 0;
-
- if (md) {
- X11->ignoreBadwindow();
- XWindowAttributes attr;
- XGetWindowAttributes(X11->display, w, &attr);
- if (X11->badwindow())
- return 0;
-
- if (attr.map_state == IsViewable
- && QRect(attr.x,attr.y,attr.width,attr.height).contains(pos)) {
- {
- Atom type = XNone;
- int f;
- unsigned long n, a;
- unsigned char *data;
-
- XGetWindowProperty(X11->display, w, ATOM(XdndAware), 0, 0, False,
- AnyPropertyType, &type, &f,&n,&a,&data);
- if (data) XFree(data);
- if (type)
- return w;
- }
-
- Window r, p;
- Window* c;
- uint nc;
- if (XQueryTree(X11->display, w, &r, &p, &c, &nc)) {
- r=0;
- for (uint i=nc; !r && i--;) {
- r = findRealWindow(pos-QPoint(attr.x,attr.y),
- c[i], md-1);
- }
- XFree(c);
- if (r)
- return r;
-
- // We didn't find a client window! Just use the
- // innermost window.
- }
-
- // No children!
- return w;
- }
- }
- return 0;
-}
-
-void QDragManager::move(const QPoint & globalPos)
-{
-#ifdef QT_NO_CURSOR
- Q_UNUSED(globalPos);
- return;
-#else
- DEBUG() << "QDragManager::move enter";
- if (!object) {
- // perhaps the target crashed?
- return;
- }
-
- int screen = QCursor::x11Screen();
- if ((qt_xdnd_current_screen == -1 && screen != X11->defaultScreen) || (screen != qt_xdnd_current_screen)) {
- // recreate the pixmap on the new screen...
- delete xdnd_data.deco;
- QWidget* parent = object->source()->window()->x11Info().screen() == screen
- ? object->source()->window() : QApplication::desktop()->screen(screen);
- xdnd_data.deco = new QShapedPixmapWidget(parent);
- if (!QWidget::mouseGrabber()) {
- updatePixmap();
- xdnd_data.deco->grabMouse();
- }
- }
- xdnd_data.deco->move(QCursor::pos() - xdnd_data.deco->pm_hot);
-
- if (qt_xdnd_source_sameanswer.contains(globalPos) && qt_xdnd_source_sameanswer.isValid())
- return;
-
- qt_xdnd_current_screen = screen;
- Window rootwin = QX11Info::appRootWindow(qt_xdnd_current_screen);
- Window target = 0;
- int lx = 0, ly = 0;
- if (!XTranslateCoordinates(X11->display, rootwin, rootwin, globalPos.x(), globalPos.y(), &lx, &ly, &target))
- // some weird error...
- return;
-
- if (target == rootwin) {
- // Ok.
- } else if (target) {
- //me
- Window src = rootwin;
- while (target != 0) {
- DNDDEBUG << "checking target for XdndAware" << QWidget::find(target) << target;
- int lx2, ly2;
- Window t;
- // translate coordinates
- if (!XTranslateCoordinates(X11->display, src, target, lx, ly, &lx2, &ly2, &t)) {
- target = 0;
- break;
- }
- lx = lx2;
- ly = ly2;
- src = target;
-
- // check if it has XdndAware
- Atom type = 0;
- int f;
- unsigned long n, a;
- unsigned char *data = 0;
- XGetWindowProperty(X11->display, target, ATOM(XdndAware), 0, 0, False,
- AnyPropertyType, &type, &f,&n,&a,&data);
- if (data)
- XFree(data);
- if (type) {
- DNDDEBUG << "Found XdndAware on " << QWidget::find(target) << target;
- break;
- }
-
- // find child at the coordinates
- if (!XTranslateCoordinates(X11->display, src, src, lx, ly, &lx2, &ly2, &target)) {
- target = 0;
- break;
- }
- }
- if (xdnd_data.deco && (!target || target == xdnd_data.deco->effectiveWinId())) {
- DNDDEBUG << "need to find real window";
- target = findRealWindow(globalPos, rootwin, 6);
- DNDDEBUG << "real window found" << QWidget::find(target) << target;
- }
- }
-
- QWidget* w;
- if (target) {
- w = QWidget::find((WId)target);
- if (w && (w->windowType() == Qt::Desktop) && !w->acceptDrops())
- w = 0;
- } else {
- w = 0;
- target = rootwin;
- }
-
- DNDDEBUG << "and the final target is " << QWidget::find(target) << target;
- DNDDEBUG << "the widget w is" << w;
-
- WId proxy_target = xdndProxy(target);
- if (!proxy_target)
- proxy_target = target;
- int target_version = 1;
-
- if (proxy_target) {
- Atom type = XNone;
- int r, f;
- unsigned long n, a;
- unsigned char *retval;
- X11->ignoreBadwindow();
- r = XGetWindowProperty(X11->display, proxy_target, ATOM(XdndAware), 0,
- 1, False, AnyPropertyType, &type, &f,&n,&a,&retval);
- int *tv = (int *)retval;
- if (r != Success || X11->badwindow()) {
- target = 0;
- } else {
- target_version = qMin(xdnd_version,tv ? *tv : 1);
- if (tv)
- XFree(tv);
-// if (!(!X11->badwindow() && type))
-// target = 0;
- }
- }
-
- if (target != qt_xdnd_current_target) {
- if (qt_xdnd_current_target)
- qt_xdnd_send_leave();
-
- qt_xdnd_current_target = target;
- qt_xdnd_current_proxy_target = proxy_target;
- if (target) {
- QVector<Atom> types;
- int flags = target_version << 24;
- QStringList fmts = QInternalMimeData::formatsHelper(dragPrivate()->data);
- for (int i = 0; i < fmts.size(); ++i) {
- QList<Atom> atoms = X11->xdndMimeAtomsForFormat(fmts.at(i));
- for (int j = 0; j < atoms.size(); ++j) {
- if (!types.contains(atoms.at(j)))
- types.append(atoms.at(j));
- }
- }
- if (types.size() > 3) {
- XChangeProperty(X11->display,
- dragPrivate()->source->effectiveWinId(), ATOM(XdndTypelist),
- XA_ATOM, 32, PropModeReplace,
- (unsigned char *)types.data(),
- types.size());
- flags |= 0x0001;
- }
- XClientMessageEvent enter;
- enter.type = ClientMessage;
- enter.window = target;
- enter.format = 32;
- enter.message_type = ATOM(XdndEnter);
- enter.data.l[0] = dragPrivate()->source->effectiveWinId();
- enter.data.l[1] = flags;
- enter.data.l[2] = types.size()>0 ? types.at(0) : 0;
- enter.data.l[3] = types.size()>1 ? types.at(1) : 0;
- enter.data.l[4] = types.size()>2 ? types.at(2) : 0;
- // provisionally set the rectangle to 5x5 pixels...
- qt_xdnd_source_sameanswer = QRect(globalPos.x() - 2,
- globalPos.y() -2 , 5, 5);
-
- DEBUG("sending Xdnd enter");
- if (w)
- X11->xdndHandleEnter(w, (const XEvent *)&enter, false);
- else if (target)
- XSendEvent(X11->display, proxy_target, False, NoEventMask, (XEvent*)&enter);
- waiting_for_status = false;
- }
- }
- if (waiting_for_status)
- return;
-
- if (target) {
- waiting_for_status = true;
-
- XClientMessageEvent move;
- move.type = ClientMessage;
- move.window = target;
- move.format = 32;
- move.message_type = ATOM(XdndPosition);
- move.window = target;
- move.data.l[0] = dragPrivate()->source->effectiveWinId();
- move.data.l[1] = 0; // flags
- move.data.l[2] = (globalPos.x() << 16) + globalPos.y();
- move.data.l[3] = X11->time;
- move.data.l[4] = qtaction_to_xdndaction(defaultAction(dragPrivate()->possible_actions, QApplication::keyboardModifiers()));
- DEBUG("sending Xdnd position");
-
- qt_xdnd_source_current_time = X11->time;
-
- if (w)
- handle_xdnd_position(w, (const XEvent *)&move, false);
- else
- XSendEvent(X11->display, proxy_target, False, NoEventMask,
- (XEvent*)&move);
- } else {
- if (willDrop) {
- willDrop = false;
- updateCursor();
- }
- }
- DEBUG() << "QDragManager::move leave";
-#endif
-}
-
-
-void QDragManager::drop()
-{
- Q_ASSERT(heartbeat != -1);
- killTimer(heartbeat);
- heartbeat = -1;
- qt_xdnd_dragging = false;
-
- if (!qt_xdnd_current_target)
- return;
-
- qDeleteInEventHandler(xdnd_data.deco);
- xdnd_data.deco = 0;
-
- XClientMessageEvent drop;
- drop.type = ClientMessage;
- drop.window = qt_xdnd_current_target;
- drop.format = 32;
- drop.message_type = ATOM(XdndDrop);
- drop.data.l[0] = dragPrivate()->source->effectiveWinId();
- drop.data.l[1] = 0; // flags
- drop.data.l[2] = X11->time;
-
- drop.data.l[3] = 0;
- drop.data.l[4] = 0;
-
- QWidget * w = QWidget::find(qt_xdnd_current_proxy_target);
-
- if (w && (w->windowType() == Qt::Desktop) && !w->acceptDrops())
- w = 0;
-
- QXdndDropTransaction t = {
- X11->time,
- qt_xdnd_current_target,
- qt_xdnd_current_proxy_target,
- w,
- current_embedding_widget,
- object
- };
- X11->dndDropTransactions.append(t);
- restartXdndDropExpiryTimer();
-
- if (w)
- X11->xdndHandleDrop(w, (const XEvent *)&drop, false);
- else
- XSendEvent(X11->display, qt_xdnd_current_proxy_target, False,
- NoEventMask, (XEvent*)&drop);
-
- qt_xdnd_current_target = 0;
- qt_xdnd_current_proxy_target = 0;
- qt_xdnd_source_current_time = 0;
- current_embedding_widget = 0;
- object = 0;
-
-#ifndef QT_NO_CURSOR
- if (restoreCursor) {
- QApplication::restoreOverrideCursor();
- restoreCursor = false;
- }
-#endif
-}
-
-
-
-bool QX11Data::xdndHandleBadwindow()
-{
- if (qt_xdnd_current_target) {
- QDragManager *manager = QDragManager::self();
- if (manager->object) {
- qt_xdnd_current_target = 0;
- qt_xdnd_current_proxy_target = 0;
- manager->object->deleteLater();
- manager->object = 0;
- delete xdnd_data.deco;
- xdnd_data.deco = 0;
- return true;
- }
- }
- if (qt_xdnd_dragsource_xid) {
- qt_xdnd_dragsource_xid = 0;
- if (qt_xdnd_current_widget) {
- QApplication::postEvent(qt_xdnd_current_widget, new QDragLeaveEvent);
- qt_xdnd_current_widget = 0;
- }
- return true;
- }
- return false;
-}
-
-void QX11Data::xdndHandleSelectionRequest(const XSelectionRequestEvent * req)
-{
- if (!req)
- return;
- XEvent evt;
- evt.xselection.type = SelectionNotify;
- evt.xselection.display = req->display;
- evt.xselection.requestor = req->requestor;
- evt.xselection.selection = req->selection;
- evt.xselection.target = XNone;
- evt.xselection.property = XNone;
- evt.xselection.time = req->time;
-
- QDragManager *manager = QDragManager::self();
- QDrag *currentObject = manager->object;
-
- // which transaction do we use? (note: -2 means use current manager->object)
- int at = -1;
-
- // figure out which data the requestor is really interested in
- if (manager->object && req->time == qt_xdnd_source_current_time) {
- // requestor wants the current drag data
- at = -2;
- } else {
- // if someone has requested data in response to XdndDrop, find the corresponding transaction. the
- // spec says to call XConvertSelection() using the timestamp from the XdndDrop
- at = findXdndDropTransactionByTime(req->time);
- if (at == -1) {
- // no dice, perhaps the client was nice enough to use the same window id in XConvertSelection()
- // that we sent the XdndDrop event to.
- at = findXdndDropTransactionByWindow(req->requestor);
- }
- if (at == -1 && req->time == CurrentTime) {
- // previous Qt versions always requested the data on a child of the target window
- // using CurrentTime... but it could be asking for either drop data or the current drag's data
- Window target = findXdndAwareParent(req->requestor);
- if (target) {
- if (qt_xdnd_current_target && qt_xdnd_current_target == target)
- at = -2;
- else
- at = findXdndDropTransactionByWindow(target);
- }
- }
- }
- if (at >= 0) {
- restartXdndDropExpiryTimer();
-
- // use the drag object from an XdndDrop tansaction
- manager->object = X11->dndDropTransactions.at(at).object;
- } else if (at != -2) {
- // no transaction found, we'll have to reject the request
- manager->object = 0;
- }
- if (manager->object) {
- Atom atomFormat = req->target;
- int dataFormat = 0;
- QByteArray data;
- if (X11->xdndMimeDataForAtom(req->target, manager->dragPrivate()->data,
- &data, &atomFormat, &dataFormat)) {
- int dataSize = data.size() / (dataFormat / 8);
- XChangeProperty (X11->display, req->requestor, req->property,
- atomFormat, dataFormat, PropModeReplace,
- (unsigned char *)data.data(), dataSize);
- evt.xselection.property = req->property;
- evt.xselection.target = atomFormat;
- }
- }
-
- // reset manager->object in case we modified it above
- manager->object = currentObject;
-
- // ### this can die if req->requestor crashes at the wrong
- // ### moment
- XSendEvent(X11->display, req->requestor, False, 0, &evt);
-}
-
-static QVariant xdndObtainData(const char *format, QVariant::Type requestedType)
-{
- QByteArray result;
-
- QWidget* w;
- QDragManager *manager = QDragManager::self();
- if (qt_xdnd_dragsource_xid && manager->object &&
- (w=QWidget::find(qt_xdnd_dragsource_xid))
- && (!(w->windowType() == Qt::Desktop) || w->acceptDrops()))
- {
- QDragPrivate * o = QDragManager::self()->dragPrivate();
- if (o->data->hasFormat(QLatin1String(format)))
- result = o->data->data(QLatin1String(format));
- return result;
- }
-
- QList<Atom> atoms;
- int i = 0;
- while ((qt_xdnd_types[i])) {
- atoms.append(qt_xdnd_types[i]);
- ++i;
- }
- QByteArray encoding;
- Atom a = X11->xdndMimeAtomForFormat(QLatin1String(format), requestedType, atoms, &encoding);
- if (!a)
- return result;
-
- if (XGetSelectionOwner(X11->display, ATOM(XdndSelection)) == XNone)
- return result; // should never happen?
-
- QWidget* tw = qt_xdnd_current_widget;
- if (!qt_xdnd_current_widget || (qt_xdnd_current_widget->windowType() == Qt::Desktop))
- tw = new QWidget;
-
- XConvertSelection(X11->display, ATOM(XdndSelection), a, ATOM(XdndSelection), tw->effectiveWinId(),
- qt_xdnd_target_current_time);
- XFlush(X11->display);
-
- XEvent xevent;
- bool got=X11->clipboardWaitForEvent(tw->effectiveWinId(), SelectionNotify, &xevent, 5000);
- if (got) {
- Atom type;
-
- if (X11->clipboardReadProperty(tw->effectiveWinId(), ATOM(XdndSelection), true, &result, 0, &type, 0)) {
- if (type == ATOM(INCR)) {
- int nbytes = result.size() >= 4 ? *((int*)result.data()) : 0;
- result = X11->clipboardReadIncrementalProperty(tw->effectiveWinId(), ATOM(XdndSelection), nbytes, false);
- } else if (type != a && type != XNone) {
- DEBUG("Qt clipboard: unknown atom %ld", type);
- }
- }
- }
- if (!qt_xdnd_current_widget || (qt_xdnd_current_widget->windowType() == Qt::Desktop))
- delete tw;
-
- return X11->xdndMimeConvertToFormat(a, result, QLatin1String(format), requestedType, encoding);
-}
-
-
-/*
- Enable drag and drop for widget w by installing the proper
- properties on w's toplevel widget.
-*/
-bool QX11Data::dndEnable(QWidget* w, bool on)
-{
- w = w->window();
-
- if (bool(((QExtraWidget*)w)->topData()->dnd) == on)
- return true; // been there, done that
- ((QExtraWidget*)w)->topData()->dnd = on ? 1 : 0;
-
- motifdndEnable(w, on);
- return xdndEnable(w, on);
-}
-
-Qt::DropAction QDragManager::drag(QDrag * o)
-{
- if (object == o || !o || !o->d_func()->source)
- return Qt::IgnoreAction;
-
- if (object) {
- cancel();
- qApp->removeEventFilter(this);
- beingCancelled = false;
- }
-
- if (object) {
- // the last drag and drop operation hasn't finished, so we are going to wait
- // for one second to see if it does... if the finish message comes after this,
- // then we could still have problems, but this is highly unlikely
- QApplication::flush();
-
- QElapsedTimer timer;
- timer.start();
- do {
- XEvent event;
- if (XCheckTypedEvent(X11->display, ClientMessage, &event))
- qApp->x11ProcessEvent(&event);
-
- // sleep 50 ms, so we don't use up CPU cycles all the time.
- struct timeval usleep_tv;
- usleep_tv.tv_sec = 0;
- usleep_tv.tv_usec = 50000;
- select(0, 0, 0, 0, &usleep_tv);
- } while (object && timer.hasExpired(1000));
- }
-
- object = o;
- object->d_func()->target = 0;
- xdnd_data.deco = new QShapedPixmapWidget(object->source()->window());
-
- willDrop = false;
-
- updatePixmap();
-
- qApp->installEventFilter(this);
- XSetSelectionOwner(X11->display, ATOM(XdndSelection), dragPrivate()->source->window()->internalWinId(), X11->time);
- global_accepted_action = Qt::CopyAction;
- qt_xdnd_source_sameanswer = QRect();
-#ifndef QT_NO_CURSOR
- // set the override cursor (must be done here, since it is updated
- // in the call to move() below)
- qApp->setOverrideCursor(Qt::ArrowCursor);
- restoreCursor = true;
-#endif
- move(QCursor::pos());
- heartbeat = startTimer(200);
-
- qt_xdnd_dragging = true;
-
- if (!QWidget::mouseGrabber())
- xdnd_data.deco->grabMouse();
-
- eventLoop = new QEventLoop;
- (void) eventLoop->exec();
- delete eventLoop;
- eventLoop = 0;
-
-#ifndef QT_NO_CURSOR
- if (restoreCursor) {
- qApp->restoreOverrideCursor();
- restoreCursor = false;
- }
-#endif
-
- // delete cursors as they may be different next drag.
- delete noDropCursor;
- noDropCursor = 0;
- delete copyCursor;
- copyCursor = 0;
- delete moveCursor;
- moveCursor = 0;
- delete linkCursor;
- linkCursor = 0;
-
- delete xdnd_data.deco;
- xdnd_data.deco = 0;
- if (heartbeat != -1)
- killTimer(heartbeat);
- heartbeat = -1;
- qt_xdnd_current_screen = -1;
- qt_xdnd_dragging = false;
-
- return global_accepted_action;
- // object persists until we get an xdnd_finish message
-}
-
-void QDragManager::updatePixmap()
-{
- if (xdnd_data.deco) {
- QPixmap pm;
- QPoint pm_hot(default_pm_hotx,default_pm_hoty);
- if (object) {
- pm = dragPrivate()->pixmap;
- if (!pm.isNull())
- pm_hot = dragPrivate()->hotspot;
- }
- if (pm.isNull()) {
- if (!defaultPm)
- defaultPm = new QPixmap(default_pm);
- pm = *defaultPm;
- }
- xdnd_data.deco->pm_hot = pm_hot;
- xdnd_data.deco->setPixmap(pm);
- xdnd_data.deco->move(QCursor::pos()-pm_hot);
- xdnd_data.deco->show();
- }
-}
-
-QVariant QDropData::retrieveData_sys(const QString &mimetype, QVariant::Type requestedType) const
-{
- QByteArray mime = mimetype.toLatin1();
- QVariant data = X11->motifdnd_active
- ? X11->motifdndObtainData(mime)
- : xdndObtainData(mime, requestedType);
- return data;
-}
-
-bool QDropData::hasFormat_sys(const QString &format) const
-{
- return formats().contains(format);
-}
-
-QStringList QDropData::formats_sys() const
-{
- QStringList formats;
- if (X11->motifdnd_active) {
- int i = 0;
- QByteArray fmt;
- while (!(fmt = X11->motifdndFormat(i)).isEmpty()) {
- formats.append(QLatin1String(fmt));
- ++i;
- }
- } else {
- int i = 0;
- while ((qt_xdnd_types[i])) {
- QStringList formatsForAtom = X11->xdndMimeFormatsForAtom(qt_xdnd_types[i]);
- for (int j = 0; j < formatsForAtom.size(); ++j) {
- if (!formats.contains(formatsForAtom.at(j)))
- formats.append(formatsForAtom.at(j));
- }
- ++i;
- }
- }
- return formats;
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_DRAGANDDROP
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
deleted file mode 100644
index 277a5e845d..0000000000
--- a/src/gui/kernel/qevent.cpp
+++ /dev/null
@@ -1,4851 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qevent.h"
-#include "qcursor.h"
-#include "qapplication.h"
-#include "private/qapplication_p.h"
-#include "private/qevent_p.h"
-#include "private/qkeysequence_p.h"
-#include "qwidget.h"
-#include "qgraphicsview.h"
-#include "qdebug.h"
-#include "qmime.h"
-#include "qdnd_p.h"
-#include "qevent_p.h"
-#include "qgesture.h"
-#include "qgesture_p.h"
-
-#ifdef Q_OS_SYMBIAN
-#include "private/qcore_symbian_p.h"
-#endif
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QInputEvent
- \ingroup events
-
- \brief The QInputEvent class is the base class for events that
- describe user input.
-*/
-
-/*!
- \internal
-*/
-QInputEvent::QInputEvent(Type type, Qt::KeyboardModifiers modifiers)
- : QEvent(type), modState(modifiers)
-{}
-
-/*!
- \internal
-*/
-QInputEvent::~QInputEvent()
-{
-}
-
-/*!
- \fn Qt::KeyboardModifiers QInputEvent::modifiers() const
-
- Returns the keyboard modifier flags that existed immediately
- before the event occurred.
-
- \sa QApplication::keyboardModifiers()
-*/
-
-/*! \fn void QInputEvent::setModifiers(Qt::KeyboardModifiers modifiers)
-
- \internal
-
- Sets the keyboard modifiers flags for this event.
-*/
-
-/*!
- \class QMouseEvent
- \ingroup events
-
- \brief The QMouseEvent class contains parameters that describe a mouse event.
-
- Mouse events occur when a mouse button is pressed or released
- inside a widget, or when the mouse cursor is moved.
-
- Mouse move events will occur only when a mouse button is pressed
- down, unless mouse tracking has been enabled with
- QWidget::setMouseTracking().
-
- Qt automatically grabs the mouse when a mouse button is pressed
- inside a widget; the widget will continue to receive mouse events
- until the last mouse button is released.
-
- A mouse event contains a special accept flag that indicates
- whether the receiver wants the event. You should call ignore() if
- the mouse event is not handled by your widget. A mouse event is
- propagated up the parent widget chain until a widget accepts it
- with accept(), or an event filter consumes it.
-
- \note If a mouse event is propagated to a \l{QWidget}{widget} for
- which Qt::WA_NoMousePropagation has been set, that mouse event
- will not be propagated further up the parent widget chain.
-
- The state of the keyboard modifier keys can be found by calling the
- \l{QInputEvent::modifiers()}{modifiers()} function, inherited from
- QInputEvent.
-
- The functions pos(), x(), and y() give the cursor position
- relative to the widget that receives the mouse event. If you
- move the widget as a result of the mouse event, use the global
- position returned by globalPos() to avoid a shaking motion.
-
- The QWidget::setEnabled() function can be used to enable or
- disable mouse and keyboard events for a widget.
-
- Reimplement the QWidget event handlers, QWidget::mousePressEvent(),
- QWidget::mouseReleaseEvent(), QWidget::mouseDoubleClickEvent(),
- and QWidget::mouseMoveEvent() to receive mouse events in your own
- widgets.
-
- \sa QWidget::setMouseTracking() QWidget::grabMouse()
- QCursor::pos()
-*/
-
-/*!
- Constructs a mouse event object.
-
- The \a type parameter must be one of QEvent::MouseButtonPress,
- QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
- or QEvent::MouseMove.
-
- The \a position is the mouse cursor's position relative to the
- receiving widget.
- The \a button that caused the event is given as a value from
- the Qt::MouseButton enum. If the event \a type is
- \l MouseMove, the appropriate button for this event is Qt::NoButton.
- The mouse and keyboard states at the time of the event are specified by
- \a buttons and \a modifiers.
-
- The globalPos() is initialized to QCursor::pos(), which may not
- be appropriate. Use the other constructor to specify the global
- position explicitly.
-*/
-
-QMouseEvent::QMouseEvent(Type type, const QPoint &position, Qt::MouseButton button,
- Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
- : QInputEvent(type, modifiers), p(position), b(button), mouseState(buttons)
-{
- g = QCursor::pos();
-}
-
-/*!
- \internal
-*/
-QMouseEvent::~QMouseEvent()
-{
-}
-
-#ifdef QT3_SUPPORT
-/*!
- Use QMouseEvent(\a type, \a pos, \a button, \c buttons, \c
- modifiers) instead, where \c buttons is \a state &
- Qt::MouseButtonMask and \c modifiers is \a state &
- Qt::KeyButtonMask.
-*/
-QMouseEvent::QMouseEvent(Type type, const QPoint &pos, Qt::ButtonState button, int state)
- : QInputEvent(type), p(pos), b((Qt::MouseButton)button)
-{
- g = QCursor::pos();
- mouseState = Qt::MouseButtons((state ^ b) & Qt::MouseButtonMask);
- modState = Qt::KeyboardModifiers(state & (int)Qt::KeyButtonMask);
-}
-
-/*!
- Use QMouseEvent(\a type, \a pos, \a globalPos, \a button,
- \c buttons, \c modifiers) instead, where
- \c buttons is \a state & Qt::MouseButtonMask and
- \c modifiers is \a state & Qt::KeyButtonMask.
-*/
-QMouseEvent::QMouseEvent(Type type, const QPoint &pos, const QPoint &globalPos,
- Qt::ButtonState button, int state)
- : QInputEvent(type), p(pos), g(globalPos), b((Qt::MouseButton)button)
-{
- mouseState = Qt::MouseButtons((state ^ b) & Qt::MouseButtonMask);
- modState = Qt::KeyboardModifiers(state & (int)Qt::KeyButtonMask);
-}
-#endif
-
-
-/*!
- Constructs a mouse event object.
-
- The \a type parameter must be QEvent::MouseButtonPress,
- QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
- or QEvent::MouseMove.
-
- The \a pos is the mouse cursor's position relative to the
- receiving widget. The cursor's position in global coordinates is
- specified by \a globalPos. The \a button that caused the event is
- given as a value from the \l Qt::MouseButton enum. If the event \a
- type is \l MouseMove, the appropriate button for this event is
- Qt::NoButton. \a buttons is the state of all buttons at the
- time of the event, \a modifiers the state of all keyboard
- modifiers.
-
-*/
-QMouseEvent::QMouseEvent(Type type, const QPoint &pos, const QPoint &globalPos,
- Qt::MouseButton button, Qt::MouseButtons buttons,
- Qt::KeyboardModifiers modifiers)
- : QInputEvent(type, modifiers), p(pos), g(globalPos), b(button), mouseState(buttons)
-{}
-
-/*!
- \internal
-*/
-QMouseEvent *QMouseEvent::createExtendedMouseEvent(Type type, const QPointF &pos,
- const QPoint &globalPos, Qt::MouseButton button,
- Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
-{
- return new QMouseEventEx(type, pos, globalPos, button, buttons, modifiers);
-}
-
-/*!
- \fn bool QMouseEvent::hasExtendedInfo() const
- \internal
-*/
-
-/*!
- \since 4.4
-
- Returns the position of the mouse cursor as a QPointF, relative to the
- widget that received the event.
-
- If you move the widget as a result of the mouse event, use the
- global position returned by globalPos() to avoid a shaking
- motion.
-
- \sa x() y() pos() globalPos()
-*/
-QPointF QMouseEvent::posF() const
-{
- return hasExtendedInfo() ? reinterpret_cast<const QMouseEventEx *>(this)->posF : QPointF(pos());
-}
-
-/*!
- \internal
-*/
-QMouseEventEx::QMouseEventEx(Type type, const QPointF &pos, const QPoint &globalPos,
- Qt::MouseButton button, Qt::MouseButtons buttons,
- Qt::KeyboardModifiers modifiers)
- : QMouseEvent(type, pos.toPoint(), globalPos, button, buttons, modifiers), posF(pos)
-{
- d = reinterpret_cast<QEventPrivate *>(this);
-}
-
-/*!
- \internal
-*/
-QMouseEventEx::~QMouseEventEx()
-{
-}
-
-/*!
- \fn const QPoint &QMouseEvent::pos() const
-
- Returns the position of the mouse cursor, relative to the widget
- that received the event.
-
- If you move the widget as a result of the mouse event, use the
- global position returned by globalPos() to avoid a shaking
- motion.
-
- \sa x() y() globalPos()
-*/
-
-/*!
- \fn const QPoint &QMouseEvent::globalPos() const
-
- Returns the global position of the mouse cursor \e{at the time
- of the event}. This is important on asynchronous window systems
- like X11. Whenever you move your widgets around in response to
- mouse events, globalPos() may differ a lot from the current
- pointer position QCursor::pos(), and from
- QWidget::mapToGlobal(pos()).
-
- \sa globalX() globalY()
-*/
-
-/*!
- \fn int QMouseEvent::x() const
-
- Returns the x position of the mouse cursor, relative to the
- widget that received the event.
-
- \sa y() pos()
-*/
-
-/*!
- \fn int QMouseEvent::y() const
-
- Returns the y position of the mouse cursor, relative to the
- widget that received the event.
-
- \sa x() pos()
-*/
-
-/*!
- \fn int QMouseEvent::globalX() const
-
- Returns the global x position of the mouse cursor at the time of
- the event.
-
- \sa globalY() globalPos()
-*/
-
-/*!
- \fn int QMouseEvent::globalY() const
-
- Returns the global y position of the mouse cursor at the time of
- the event.
-
- \sa globalX() globalPos()
-*/
-
-/*!
- \fn Qt::MouseButton QMouseEvent::button() const
-
- Returns the button that caused the event.
-
- Note that the returned value is always Qt::NoButton for mouse
- move events.
-
- \sa buttons() Qt::MouseButton
-*/
-
-/*!
- \fn Qt::MouseButton QMouseEvent::buttons() const
-
- Returns the button state when the event was generated. The button
- state is a combination of Qt::LeftButton, Qt::RightButton,
- Qt::MidButton using the OR operator. For mouse move events,
- this is all buttons that are pressed down. For mouse press and
- double click events this includes the button that caused the
- event. For mouse release events this excludes the button that
- caused the event.
-
- \sa button() Qt::MouseButton
-*/
-
-
-/*!
- \fn Qt::ButtonState QMouseEvent::state() const
-
- Returns the button state immediately before the event was
- generated. The button state is a combination of mouse buttons
- (see Qt::ButtonState) and keyboard modifiers (Qt::MouseButtons).
-
- Use buttons() and/or modifiers() instead. Be aware that buttons()
- return the state immediately \e after the event was generated.
-*/
-
-/*!
- \fn Qt::ButtonState QMouseEvent::stateAfter() const
-
- Returns the button state immediately after the event was
- generated. The button state is a combination of mouse buttons
- (see Qt::ButtonState) and keyboard modifiers (Qt::MouseButtons).
-
- Use buttons() and/or modifiers() instead.
-*/
-
-/*!
- \class QHoverEvent
- \ingroup events
-
- \brief The QHoverEvent class contains parameters that describe a mouse event.
-
- Mouse events occur when a mouse cursor is moved into, out of, or within a
- widget, and if the widget has the Qt::WA_Hover attribute.
-
- The function pos() gives the current cursor position, while oldPos() gives
- the old mouse position.
-
- There are a few similarities between the events QEvent::HoverEnter
- and QEvent::HoverLeave, and the events QEvent::Enter and QEvent::Leave.
- However, they are slightly different because we do an update() in the event
- handler of HoverEnter and HoverLeave.
-
- QEvent::HoverMove is also slightly different from QEvent::MouseMove. Let us
- consider a top-level window A containing a child B which in turn contains a
- child C (all with mouse tracking enabled):
-
- \image hoverevents.png
-
- Now, if you move the cursor from the top to the bottom in the middle of A,
- you will get the following QEvent::MouseMove events:
-
- \list 1
- \o A::MouseMove
- \o B::MouseMove
- \o C::MouseMove
- \endlist
-
- You will get the same events for QEvent::HoverMove, except that the event
- always propagates to the top-level regardless whether the event is accepted
- or not. It will only stop propagating with the Qt::WA_NoMousePropagation
- attribute.
-
- In this case the events will occur in the following way:
-
- \list 1
- \o A::HoverMove
- \o A::HoverMove, B::HoverMove
- \o A::HoverMove, B::HoverMove, C::HoverMove
- \endlist
-
-*/
-
-/*!
- \fn const QPoint &QHoverEvent::pos() const
-
- Returns the position of the mouse cursor, relative to the widget
- that received the event.
-
- On QEvent::HoverLeave events, this position will always be
- QPoint(-1, -1).
-
- \sa oldPos()
-*/
-
-/*!
- \fn const QPoint &QHoverEvent::oldPos() const
-
- Returns the previous position of the mouse cursor, relative to the widget
- that received the event. If there is no previous position, oldPos() will
- return the same position as pos().
-
- On QEvent::HoverEnter events, this position will always be
- QPoint(-1, -1).
-
- \sa pos()
-*/
-
-/*!
- Constructs a hover event object.
-
- The \a type parameter must be QEvent::HoverEnter,
- QEvent::HoverLeave, or QEvent::HoverMove.
-
- The \a pos is the current mouse cursor's position relative to the
- receiving widget, while \a oldPos is the previous mouse cursor's
- position relative to the receiving widget.
-*/
-QHoverEvent::QHoverEvent(Type type, const QPoint &pos, const QPoint &oldPos)
- : QEvent(type), p(pos), op(oldPos)
-{
-}
-
-/*!
- \internal
-*/
-QHoverEvent::~QHoverEvent()
-{
-}
-
-
-/*!
- \class QWheelEvent
- \brief The QWheelEvent class contains parameters that describe a wheel event.
-
- \ingroup events
-
- Wheel events are sent to the widget under the mouse cursor, but
- if that widget does not handle the event they are sent to the
- focus widget. The rotation distance is provided by delta().
- The functions pos() and globalPos() return the mouse cursor's
- location at the time of the event.
-
- A wheel event contains a special accept flag that indicates
- whether the receiver wants the event. You should call ignore() if
- you do not handle the wheel event; this ensures that it will be
- sent to the parent widget.
-
- The QWidget::setEnabled() function can be used to enable or
- disable mouse and keyboard events for a widget.
-
- The event handler QWidget::wheelEvent() receives wheel events.
-
- \sa QMouseEvent QWidget::grabMouse()
-*/
-
-/*!
- \fn Qt::MouseButtons QWheelEvent::buttons() const
-
- Returns the mouse state when the event occurred.
-*/
-
-/*!
- \fn Qt::Orientation QWheelEvent::orientation() const
-
- Returns the wheel's orientation.
-*/
-
-/*!
- Constructs a wheel event object.
-
- The position, \a pos, is the location of the mouse cursor within
- the widget. The globalPos() is initialized to QCursor::pos()
- which is usually, but not always, correct.
- Use the other constructor if you need to specify the global
- position explicitly.
-
- The \a buttons describe the state of the mouse buttons at the time
- of the event, \a delta contains the rotation distance,
- \a modifiers holds the keyboard modifier flags at the time of the
- event, and \a orient holds the wheel's orientation.
-
- \sa pos() delta() state()
-*/
-#ifndef QT_NO_WHEELEVENT
-QWheelEvent::QWheelEvent(const QPoint &pos, int delta,
- Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
- Qt::Orientation orient)
- : QInputEvent(Wheel, modifiers), p(pos), d(delta), mouseState(buttons), o(orient)
-{
- g = QCursor::pos();
-}
-
-/*!
- \internal
-*/
-QWheelEvent::~QWheelEvent()
-{
-}
-
-#ifdef QT3_SUPPORT
-/*!
- Use one of the other constructors instead.
-*/
-QWheelEvent::QWheelEvent(const QPoint &pos, int delta, int state, Qt::Orientation orient)
- : QInputEvent(Wheel), p(pos), d(delta), o(orient)
-{
- g = QCursor::pos();
- mouseState = Qt::MouseButtons(state & Qt::MouseButtonMask);
- modState = Qt::KeyboardModifiers(state & (int)Qt::KeyButtonMask);
-}
-#endif
-
-/*!
- Constructs a wheel event object.
-
- The \a pos provides the location of the mouse cursor
- within the widget. The position in global coordinates is specified
- by \a globalPos. \a delta contains the rotation distance, \a modifiers
- holds the keyboard modifier flags at the time of the event, and
- \a orient holds the wheel's orientation.
-
- \sa pos() globalPos() delta() state()
-*/
-QWheelEvent::QWheelEvent(const QPoint &pos, const QPoint& globalPos, int delta,
- Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
- Qt::Orientation orient)
- : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), d(delta), mouseState(buttons), o(orient)
-{}
-
-#ifdef QT3_SUPPORT
-/*!
- Use one of the other constructors instead.
-*/
-QWheelEvent::QWheelEvent(const QPoint &pos, const QPoint& globalPos, int delta, int state,
- Qt::Orientation orient)
- : QInputEvent(Wheel), p(pos), g(globalPos), d(delta), o(orient)
-{
- mouseState = Qt::MouseButtons(state & Qt::MouseButtonMask);
- modState = Qt::KeyboardModifiers(state & (int) Qt::KeyButtonMask);
-}
-#endif
-#endif // QT_NO_WHEELEVENT
-
-/*!
- \fn int QWheelEvent::delta() const
-
- Returns the distance that the wheel is rotated, in eighths of a
- degree. A positive value indicates that the wheel was rotated
- forwards away from the user; a negative value indicates that the
- wheel was rotated backwards toward the user.
-
- Most mouse types work in steps of 15 degrees, in which case the
- delta value is a multiple of 120; i.e., 120 units * 1/8 = 15 degrees.
-
- However, some mice have finer-resolution wheels and send delta values
- that are less than 120 units (less than 15 degrees). To support this
- possibility, you can either cumulatively add the delta values from events
- until the value of 120 is reached, then scroll the widget, or you can
- partially scroll the widget in response to each wheel event.
-
- Example:
-
- \snippet doc/src/snippets/code/src_gui_kernel_qevent.cpp 0
-*/
-
-/*!
- \fn const QPoint &QWheelEvent::pos() const
-
- Returns the position of the mouse cursor relative to the widget
- that received the event.
-
- If you move your widgets around in response to mouse events,
- use globalPos() instead of this function.
-
- \sa x() y() globalPos()
-*/
-
-/*!
- \fn int QWheelEvent::x() const
-
- Returns the x position of the mouse cursor, relative to the
- widget that received the event.
-
- \sa y() pos()
-*/
-
-/*!
- \fn int QWheelEvent::y() const
-
- Returns the y position of the mouse cursor, relative to the
- widget that received the event.
-
- \sa x() pos()
-*/
-
-
-/*!
- \fn const QPoint &QWheelEvent::globalPos() const
-
- Returns the global position of the mouse pointer \e{at the time
- of the event}. This is important on asynchronous window systems
- such as X11; whenever you move your widgets around in response to
- mouse events, globalPos() can differ a lot from the current
- cursor position returned by QCursor::pos().
-
- \sa globalX() globalY()
-*/
-
-/*!
- \fn int QWheelEvent::globalX() const
-
- Returns the global x position of the mouse cursor at the time of
- the event.
-
- \sa globalY() globalPos()
-*/
-
-/*!
- \fn int QWheelEvent::globalY() const
-
- Returns the global y position of the mouse cursor at the time of
- the event.
-
- \sa globalX() globalPos()
-*/
-
-
-/*! \obsolete
- \fn Qt::ButtonState QWheelEvent::state() const
-
- Returns the keyboard modifier flags at the time of the event.
-
- The returned value is a selection of the following values,
- combined using the OR operator: Qt::ShiftButton,
- Qt::ControlButton, and Qt::AltButton.
-*/
-
-
-/*!
- \class QKeyEvent
- \brief The QKeyEvent class describes a key event.
-
- \ingroup events
-
- Key events are sent to the widget with keyboard input focus
- when keys are pressed or released.
-
- A key event contains a special accept flag that indicates whether
- the receiver will handle the key event. You should call ignore()
- if the key press or release event is not handled by your widget.
- A key event is propagated up the parent widget chain until a
- widget accepts it with accept() or an event filter consumes it.
- Key events for multimedia keys are ignored by default. You should
- call accept() if your widget handles those events.
-
- The QWidget::setEnable() function can be used to enable or disable
- mouse and keyboard events for a widget.
-
- The event handlers QWidget::keyPressEvent(), QWidget::keyReleaseEvent(),
- QGraphicsItem::keyPressEvent() and QGraphicsItem::keyReleaseEvent()
- receive key events.
-
- \sa QFocusEvent, QWidget::grabKeyboard()
-*/
-
-/*!
- Constructs a key event object.
-
- The \a type parameter must be QEvent::KeyPress, QEvent::KeyRelease,
- or QEvent::ShortcutOverride.
-
- Int \a key is the code for the Qt::Key that the event loop should listen
- for. If \a key is 0, the event is not a result of a known key; for
- example, it may be the result of a compose sequence or keyboard macro.
- The \a modifiers holds the keyboard modifiers, and the given \a text
- is the Unicode text that the key generated. If \a autorep is true,
- isAutoRepeat() will be true. \a count is the number of keys involved
- in the event.
-*/
-QKeyEvent::QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text,
- bool autorep, ushort count)
- : QInputEvent(type, modifiers), txt(text), k(key), c(count), autor(autorep)
-{
-}
-
-/*!
- \internal
-*/
-QKeyEvent::~QKeyEvent()
-{
-}
-
-/*!
- \internal
-*/
-QKeyEvent *QKeyEvent::createExtendedKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers,
- quint32 nativeScanCode, quint32 nativeVirtualKey,
- quint32 nativeModifiers,
- const QString& text, bool autorep, ushort count)
-{
- return new QKeyEventEx(type, key, modifiers, text, autorep, count,
- nativeScanCode, nativeVirtualKey, nativeModifiers);
-}
-
-/*!
- \fn bool QKeyEvent::hasExtendedInfo() const
- \internal
-*/
-
-/*!
- \since 4.2
-
- Returns the native scan code of the key event. If the key event
- does not contain this data 0 is returned.
-
- Note: The native scan code may be 0, even if the key event contains
- extended information.
-
- Note: On Mac OS/X, this function is not useful, because there is no
- way to get the scan code from Carbon or Cocoa. The function always
- returns 1 (or 0 in the case explained above).
-*/
-quint32 QKeyEvent::nativeScanCode() const
-{
- return (reinterpret_cast<const QKeyEvent*>(d) != this
- ? 0 : reinterpret_cast<const QKeyEventEx*>(this)->nScanCode);
-}
-
-/*!
- \since 4.2
-
- Returns the native virtual key, or key sym of the key event.
- If the key event does not contain this data 0 is returned.
-
- Note: The native virtual key may be 0, even if the key event contains extended information.
-*/
-quint32 QKeyEvent::nativeVirtualKey() const
-{
- return (reinterpret_cast<const QKeyEvent*>(d) != this
- ? 0 : reinterpret_cast<const QKeyEventEx*>(this)->nVirtualKey);
-}
-
-/*!
- \since 4.2
-
- Returns the native modifiers of a key event.
- If the key event does not contain this data 0 is returned.
-
- Note: The native modifiers may be 0, even if the key event contains extended information.
-*/
-quint32 QKeyEvent::nativeModifiers() const
-{
- return (reinterpret_cast<const QKeyEvent*>(d) != this
- ? 0 : reinterpret_cast<const QKeyEventEx*>(this)->nModifiers);
-}
-
-/*!
- \internal
- Creates an extended key event object, which in addition to the normal key event data, also
- contains the native scan code, virtual key and modifiers. This extra data is used by the
- shortcut system, to determine which shortcuts to trigger.
-*/
-QKeyEventEx::QKeyEventEx(Type type, int key, Qt::KeyboardModifiers modifiers,
- const QString &text, bool autorep, ushort count,
- quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers)
- : QKeyEvent(type, key, modifiers, text, autorep, count),
- nScanCode(nativeScanCode), nVirtualKey(nativeVirtualKey), nModifiers(nativeModifiers)
-{
- d = reinterpret_cast<QEventPrivate*>(this);
-}
-
-/*!
- \internal
- Creates a copy of an other extended key event.
-*/
-QKeyEventEx::QKeyEventEx(const QKeyEventEx &other)
- : QKeyEvent(QEvent::Type(other.t), other.k, other.modState, other.txt, other.autor, other.c),
- nScanCode(other.nScanCode), nVirtualKey(other.nVirtualKey), nModifiers(other.nModifiers)
-{
- d = reinterpret_cast<QEventPrivate*>(this);
-}
-
-/*!
- \internal
-*/
-QKeyEventEx::~QKeyEventEx()
-{
-}
-
-/*!
- \fn int QKeyEvent::key() const
-
- Returns the code of the key that was pressed or released.
-
- See \l Qt::Key for the list of keyboard codes. These codes are
- independent of the underlying window system. Note that this
- function does not distinguish between capital and non-capital
- letters, use the text() function (returning the Unicode text the
- key generated) for this purpose.
-
- A value of either 0 or Qt::Key_unknown means that the event is not
- the result of a known key; for example, it may be the result of
- a compose sequence, a keyboard macro, or due to key event
- compression.
-
- \sa Qt::WA_KeyCompression
-*/
-
-/*!
- \fn QString QKeyEvent::text() const
-
- Returns the Unicode text that this key generated. The text
- returned can be an empty string in cases
- where modifier keys, such as Shift, Control, Alt, and Meta,
- are being pressed or released. In such cases key() will contain
- a valid value.
-
- \sa Qt::WA_KeyCompression
-*/
-
-/*!
- Returns the keyboard modifier flags that existed immediately
- after the event occurred.
-
- \warning This function cannot always be trusted. The user can
- confuse it by pressing both \key{Shift} keys simultaneously and
- releasing one of them, for example.
-
- \sa QApplication::keyboardModifiers()
-*/
-//###### We must check with XGetModifierMapping
-Qt::KeyboardModifiers QKeyEvent::modifiers() const
-{
- if (key() == Qt::Key_Shift)
- return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::ShiftModifier);
- if (key() == Qt::Key_Control)
- return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::ControlModifier);
- if (key() == Qt::Key_Alt)
- return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::AltModifier);
- if (key() == Qt::Key_Meta)
- return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::MetaModifier);
- return QInputEvent::modifiers();
-}
-
-#ifndef QT_NO_SHORTCUT
-/*!
- \fn bool QKeyEvent::matches(QKeySequence::StandardKey key) const
- \since 4.2
-
- Returns true if the key event matches the given standard \a key;
- otherwise returns false.
-*/
-bool QKeyEvent::matches(QKeySequence::StandardKey matchKey) const
-{
- uint searchkey = (modifiers() | key()) & ~(Qt::KeypadModifier); //The keypad modifier should not make a difference
- uint platform = QApplicationPrivate::currentPlatform();
-
-#ifdef Q_WS_MAC
- if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
- uint oldSearchKey = searchkey;
- searchkey &= ~(Qt::ControlModifier | Qt::MetaModifier);
- if (oldSearchKey & Qt::ControlModifier)
- searchkey |= Qt::MetaModifier;
- if (oldSearchKey & Qt::MetaModifier)
- searchkey |= Qt::ControlModifier;
- }
-#endif
-
- uint N = QKeySequencePrivate::numberOfKeyBindings;
- int first = 0;
- int last = N - 1;
-
- while (first <= last) {
- int mid = (first + last) / 2;
- QKeyBinding midVal = QKeySequencePrivate::keyBindings[mid];
-
- if (searchkey > midVal.shortcut){
- first = mid + 1; // Search in top half
- }
- else if (searchkey < midVal.shortcut){
- last = mid - 1; // Search in bottom half
- }
- else {
- //found correct shortcut value, now we must check for platform match
- if ((midVal.platform & platform) && (midVal.standardKey == matchKey)) {
- return true;
- } else { //We may have several equal values for different platforms, so we must search in both directions
-
- //search forward
- for ( unsigned int i = mid + 1 ; i < N - 1 ; ++i) {
- QKeyBinding current = QKeySequencePrivate::keyBindings[i];
- if (current.shortcut != searchkey)
- break;
- else if (current.platform & platform && current.standardKey == matchKey)
- return true;
- }
-
- //search back
- for ( int i = mid - 1 ; i >= 0 ; --i) {
- QKeyBinding current = QKeySequencePrivate::keyBindings[i];
- if (current.shortcut != searchkey)
- break;
- else if (current.platform & platform && current.standardKey == matchKey)
- return true;
- }
- return false; //we could not find it among the matching keySequences
- }
- }
- }
- return false; //we could not find matching keySequences at all
-}
-#endif // QT_NO_SHORTCUT
-
-
-/*!
- \fn bool QKeyEvent::isAutoRepeat() const
-
- Returns true if this event comes from an auto-repeating key;
- returns false if it comes from an initial key press.
-
- Note that if the event is a multiple-key compressed event that is
- partly due to auto-repeat, this function could return either true
- or false indeterminately.
-*/
-
-/*!
- \fn int QKeyEvent::count() const
-
- Returns the number of keys involved in this event. If text()
- is not empty, this is simply the length of the string.
-
- \sa Qt::WA_KeyCompression
-*/
-
-#ifdef QT3_SUPPORT
-/*!
- \fn QKeyEvent::QKeyEvent(Type type, int key, int ascii,
- int modifiers, const QString &text,
- bool autorep, ushort count)
-
- Use one of the other constructors instead.
-*/
-
-/*!
- \fn int QKeyEvent::ascii() const
-
- Use text() instead.
-*/
-
-/*!
- \fn Qt::ButtonState QKeyEvent::state() const
-
- Use QInputEvent::modifiers() instead.
-*/
-
-/*!
- \fn Qt::ButtonState QKeyEvent::stateAfter() const
-
- Use modifiers() instead.
-*/
-#endif
-
-/*!
- \class QFocusEvent
- \brief The QFocusEvent class contains event parameters for widget focus
- events.
-
- \ingroup events
-
- Focus events are sent to widgets when the keyboard input focus
- changes. Focus events occur due to mouse actions, key presses
- (such as \gui{Tab} or \gui{Backtab}), the window system, popup
- menus, keyboard shortcuts, or other application-specific reasons.
- The reason for a particular focus event is returned by reason()
- in the appropriate event handler.
-
- The event handlers QWidget::focusInEvent(),
- QWidget::focusOutEvent(), QGraphicsItem::focusInEvent and
- QGraphicsItem::focusOutEvent() receive focus events.
-
- \sa QWidget::setFocus(), QWidget::setFocusPolicy(), {Keyboard Focus}
-*/
-
-/*!
- Constructs a focus event object.
-
- The \a type parameter must be either QEvent::FocusIn or
- QEvent::FocusOut. The \a reason describes the cause of the change
- in focus.
-*/
-QFocusEvent::QFocusEvent(Type type, Qt::FocusReason reason)
- : QEvent(type), m_reason(reason)
-{}
-
-/*!
- \internal
-*/
-QFocusEvent::~QFocusEvent()
-{
-}
-
-// ### Qt 5: remove
-/*!
- \internal
- */
-Qt::FocusReason QFocusEvent::reason()
-{
- return m_reason;
-}
-
-/*!
- Returns the reason for this focus event.
- */
-Qt::FocusReason QFocusEvent::reason() const
-{
- return m_reason;
-}
-
-/*!
- \fn bool QFocusEvent::gotFocus() const
-
- Returns true if type() is QEvent::FocusIn; otherwise returns
- false.
-*/
-
-/*!
- \fn bool QFocusEvent::lostFocus() const
-
- Returns true if type() is QEvent::FocusOut; otherwise returns
- false.
-*/
-
-#ifdef QT3_SUPPORT
-/*!
- \enum QFocusEvent::Reason
- \compat
-
- Use Qt::FocusReason instead.
-
- \value Mouse Same as Qt::MouseFocusReason.
- \value Tab Same as Qt::TabFocusReason.
- \value Backtab Same as Qt::BacktabFocusReason.
- \value MenuBar Same as Qt::MenuBarFocusReason.
- \value ActiveWindow Same as Qt::ActiveWindowFocusReason
- \value Other Same as Qt::OtherFocusReason
- \value Popup Same as Qt::PopupFocusReason
- \value Shortcut Same as Qt::ShortcutFocusReason
-*/
-#endif
-
-/*!
- \class QPaintEvent
- \brief The QPaintEvent class contains event parameters for paint events.
-
- \ingroup events
-
- Paint events are sent to widgets that need to update themselves,
- for instance when part of a widget is exposed because a covering
- widget was moved.
-
- The event contains a region() that needs to be updated, and a
- rect() that is the bounding rectangle of that region. Both are
- provided because many widgets can't make much use of region(),
- and rect() can be much faster than region().boundingRect().
-
- \section1 Automatic Clipping
-
- Painting is clipped to region() during the processing of a paint
- event. This clipping is performed by Qt's paint system and is
- independent of any clipping that may be applied to a QPainter used to
- draw on the paint device.
-
- As a result, the value returned by QPainter::clipRegion() on
- a newly-constructed QPainter will not reflect the clip region that is
- used by the paint system.
-
- \sa QPainter, QWidget::update(), QWidget::repaint(),
- QWidget::paintEvent()
-*/
-
-/*!
- \fn bool QPaintEvent::erased() const
- \compat
-
- Returns true if the paint event region (or rectangle) has been
- erased with the widget's background; otherwise returns false.
-
- Qt 4 \e always erases regions that require painting. The exception
- to this rule is if the widget sets the Qt::WA_OpaquePaintEvent or
- Qt::WA_NoSystemBackground attributes. If either one of those
- attributes is set \e and the window system does not make use of
- subwidget alpha composition (currently X11 and Windows, but this
- may change), then the region is not erased.
-*/
-
-/*!
- \fn void QPaintEvent::setErased(bool b) { m_erased = b; }
- \internal
-*/
-
-/*!
- Constructs a paint event object with the region that needs to
- be updated. The region is specified by \a paintRegion.
-*/
-QPaintEvent::QPaintEvent(const QRegion& paintRegion)
- : QEvent(Paint), m_rect(paintRegion.boundingRect()), m_region(paintRegion), m_erased(false)
-{}
-
-/*!
- Constructs a paint event object with the rectangle that needs
- to be updated. The region is specified by \a paintRect.
-*/
-QPaintEvent::QPaintEvent(const QRect &paintRect)
- : QEvent(Paint), m_rect(paintRect),m_region(paintRect), m_erased(false)
-{}
-
-
-#ifdef QT3_SUPPORT
- /*!
- Constructs a paint event object with both a \a paintRegion and a
- \a paintRect, both of which represent the area of the widget that
- needs to be updated.
-
-*/
-QPaintEvent::QPaintEvent(const QRegion &paintRegion, const QRect &paintRect)
- : QEvent(Paint), m_rect(paintRect), m_region(paintRegion), m_erased(false)
-{}
-#endif
-
-/*!
- \internal
-*/
-QPaintEvent::~QPaintEvent()
-{
-}
-
-/*!
- \fn const QRect &QPaintEvent::rect() const
-
- Returns the rectangle that needs to be updated.
-
- \sa region() QPainter::setClipRect()
-*/
-
-/*!
- \fn const QRegion &QPaintEvent::region() const
-
- Returns the region that needs to be updated.
-
- \sa rect() QPainter::setClipRegion()
-*/
-
-
-QUpdateLaterEvent::QUpdateLaterEvent(const QRegion& paintRegion)
- : QEvent(UpdateLater), m_region(paintRegion)
-{
-}
-
-QUpdateLaterEvent::~QUpdateLaterEvent()
-{
-}
-
-/*!
- \class QMoveEvent
- \brief The QMoveEvent class contains event parameters for move events.
-
- \ingroup events
-
- Move events are sent to widgets that have been moved to a new
- position relative to their parent.
-
- The event handler QWidget::moveEvent() receives move events.
-
- \sa QWidget::move(), QWidget::setGeometry()
-*/
-
-/*!
- Constructs a move event with the new and old widget positions,
- \a pos and \a oldPos respectively.
-*/
-QMoveEvent::QMoveEvent(const QPoint &pos, const QPoint &oldPos)
- : QEvent(Move), p(pos), oldp(oldPos)
-{}
-
-/*!
- \internal
-*/
-QMoveEvent::~QMoveEvent()
-{
-}
-
-/*!
- \fn const QPoint &QMoveEvent::pos() const
-
- Returns the new position of the widget. This excludes the window
- frame for top level widgets.
-*/
-
-/*!
- \fn const QPoint &QMoveEvent::oldPos() const
-
- Returns the old position of the widget.
-*/
-
-
-/*!
- \class QResizeEvent
- \brief The QResizeEvent class contains event parameters for resize events.
-
- \ingroup events
-
- Resize events are sent to widgets that have been resized.
-
- The event handler QWidget::resizeEvent() receives resize events.
-
- \sa QWidget::resize() QWidget::setGeometry()
-*/
-
-/*!
- Constructs a resize event with the new and old widget sizes, \a
- size and \a oldSize respectively.
-*/
-QResizeEvent::QResizeEvent(const QSize &size, const QSize &oldSize)
- : QEvent(Resize), s(size), olds(oldSize)
-{}
-
-/*!
- \internal
-*/
-QResizeEvent::~QResizeEvent()
-{
-}
-
-/*!
- \fn const QSize &QResizeEvent::size() const
-
- Returns the new size of the widget. This is the same as
- QWidget::size().
-*/
-
-/*!
- \fn const QSize &QResizeEvent::oldSize() const
-
- Returns the old size of the widget.
-*/
-
-
-/*!
- \class QCloseEvent
- \brief The QCloseEvent class contains parameters that describe a close event.
-
- \ingroup events
-
- Close events are sent to widgets that the user wants to close,
- usually by choosing "Close" from the window menu, or by clicking
- the \gui{X} title bar button. They are also sent when you call
- QWidget::close() to close a widget programmatically.
-
- Close events contain a flag that indicates whether the receiver
- wants the widget to be closed or not. When a widget accepts the
- close event, it is hidden (and destroyed if it was created with
- the Qt::WA_DeleteOnClose flag). If it refuses to accept the close
- event nothing happens. (Under X11 it is possible that the window
- manager will forcibly close the window; but at the time of writing
- we are not aware of any window manager that does this.)
-
- The event handler QWidget::closeEvent() receives close events. The
- default implementation of this event handler accepts the close
- event. If you do not want your widget to be hidden, or want some
- special handing, you should reimplement the event handler and
- ignore() the event.
-
- The \l{mainwindows/application#close event handler}{closeEvent() in the
- Application example} shows a close event handler that
- asks whether to save a document before closing.
-
- If you want the widget to be deleted when it is closed, create it
- with the Qt::WA_DeleteOnClose flag. This is very useful for
- independent top-level windows in a multi-window application.
-
- \l{QObject}s emits the \l{QObject::destroyed()}{destroyed()}
- signal when they are deleted.
-
- If the last top-level window is closed, the
- QApplication::lastWindowClosed() signal is emitted.
-
- The isAccepted() function returns true if the event's receiver has
- agreed to close the widget; call accept() to agree to close the
- widget and call ignore() if the receiver of this event does not
- want the widget to be closed.
-
- \sa QWidget::close(), QWidget::hide(), QObject::destroyed(),
- QCoreApplication::exec(), QCoreApplication::quit(),
- QApplication::lastWindowClosed()
-*/
-
-/*!
- Constructs a close event object.
-
- \sa accept()
-*/
-QCloseEvent::QCloseEvent()
- : QEvent(Close)
-{}
-
-/*! \internal
-*/
-QCloseEvent::~QCloseEvent()
-{
-}
-
-/*!
- \class QIconDragEvent
- \brief The QIconDragEvent class indicates that a main icon drag has begun.
-
- \ingroup events
-
- Icon drag events are sent to widgets when the main icon of a window
- has been dragged away. On Mac OS X, this happens when the proxy
- icon of a window is dragged off the title bar.
-
- It is normal to begin using drag and drop in response to this
- event.
-
- \sa {Drag and Drop}, QMimeData, QDrag
-*/
-
-/*!
- Constructs an icon drag event object with the accept flag set to
- false.
-
- \sa accept()
-*/
-QIconDragEvent::QIconDragEvent()
- : QEvent(IconDrag)
-{ ignore(); }
-
-/*! \internal */
-QIconDragEvent::~QIconDragEvent()
-{
-}
-
-/*!
- \class QContextMenuEvent
- \brief The QContextMenuEvent class contains parameters that describe a context menu event.
-
- \ingroup events
-
- Context menu events are sent to widgets when a user performs
- an action associated with opening a context menu.
- The actions required to open context menus vary between platforms;
- for example, on Windows, pressing the menu button or clicking the
- right mouse button will cause this event to be sent.
-
- When this event occurs it is customary to show a QMenu with a
- context menu, if this is relevant to the context.
-
- Context menu events contain a special accept flag that indicates
- whether the receiver accepted the event. If the event handler does
- not accept the event then, if possible, whatever triggered the event will be
- handled as a regular input event.
-*/
-
-#ifndef QT_NO_CONTEXTMENU
-/*!
- Constructs a context menu event object with the accept parameter
- flag set to false.
-
- The \a reason parameter must be QContextMenuEvent::Mouse or
- QContextMenuEvent::Keyboard.
-
- The \a pos parameter specifies the mouse position relative to the
- receiving widget. \a globalPos is the mouse position in absolute
- coordinates.
-*/
-QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos)
- : QInputEvent(ContextMenu), p(pos), gp(globalPos), reas(reason)
-{}
-
-/*!
- Constructs a context menu event object with the accept parameter
- flag set to false.
-
- The \a reason parameter must be QContextMenuEvent::Mouse or
- QContextMenuEvent::Keyboard.
-
- The \a pos parameter specifies the mouse position relative to the
- receiving widget. \a globalPos is the mouse position in absolute
- coordinates. The \a modifiers holds the keyboard modifiers.
-*/
-QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos,
- Qt::KeyboardModifiers modifiers)
- : QInputEvent(ContextMenu, modifiers), p(pos), gp(globalPos), reas(reason)
-{}
-
-#ifdef QT3_SUPPORT
-/*!
- Constructs a context menu event with the given \a reason for the
- position specified by \a pos in widget coordinates and \a globalPos
- in global screen coordinates. \a dummy is ignored.
-*/
-QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos,
- int /* dummy */)
- : QInputEvent(ContextMenu), p(pos), gp(globalPos), reas(reason)
-{}
-#endif
-
-/*! \internal */
-QContextMenuEvent::~QContextMenuEvent()
-{
-}
-/*!
- Constructs a context menu event object with the accept parameter
- flag set to false.
-
- The \a reason parameter must be QContextMenuEvent::Mouse or
- QContextMenuEvent::Keyboard.
-
- The \a pos parameter specifies the mouse position relative to the
- receiving widget.
-
- The globalPos() is initialized to QCursor::pos(), which may not be
- appropriate. Use the other constructor to specify the global
- position explicitly.
-*/
-QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos)
- : QInputEvent(ContextMenu), p(pos), reas(reason)
-{
- gp = QCursor::pos();
-}
-
-#ifdef QT3_SUPPORT
-/*!
- Constructs a context menu event with the given \a reason for the
- position specified by \a pos in widget coordinates. \a dummy is
- ignored.
-*/
-QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, int /* dummy */)
- : QInputEvent(ContextMenu), p(pos), reas(reason)
-{
- gp = QCursor::pos();
-}
-
-Qt::ButtonState QContextMenuEvent::state() const
-{
- return Qt::ButtonState(int(QApplication::keyboardModifiers())|QApplication::mouseButtons());
-}
-#endif
-
-/*!
- \fn const QPoint &QContextMenuEvent::pos() const
-
- Returns the position of the mouse pointer relative to the widget
- that received the event.
-
- \sa x(), y(), globalPos()
-*/
-
-/*!
- \fn int QContextMenuEvent::x() const
-
- Returns the x position of the mouse pointer, relative to the
- widget that received the event.
-
- \sa y(), pos()
-*/
-
-/*!
- \fn int QContextMenuEvent::y() const
-
- Returns the y position of the mouse pointer, relative to the
- widget that received the event.
-
- \sa x(), pos()
-*/
-
-/*!
- \fn const QPoint &QContextMenuEvent::globalPos() const
-
- Returns the global position of the mouse pointer at the time of
- the event.
-
- \sa x(), y(), pos()
-*/
-
-/*!
- \fn int QContextMenuEvent::globalX() const
-
- Returns the global x position of the mouse pointer at the time of
- the event.
-
- \sa globalY(), globalPos()
-*/
-
-/*!
- \fn int QContextMenuEvent::globalY() const
-
- Returns the global y position of the mouse pointer at the time of
- the event.
-
- \sa globalX(), globalPos()
-*/
-#endif // QT_NO_CONTEXTMENU
-
-/*!
- \fn Qt::ButtonState QContextMenuEvent::state() const
-
- Returns the button state (a combination of mouse buttons
- and keyboard modifiers) immediately before the event was
- generated.
-
- The returned value is a selection of the following values,
- combined with the OR operator:
- Qt::LeftButton, Qt::RightButton, Qt::MidButton,
- Qt::ShiftButton, Qt::ControlButton, and Qt::AltButton.
-*/
-
-/*!
- \enum QContextMenuEvent::Reason
-
- This enum describes the reason why the event was sent.
-
- \value Mouse The mouse caused the event to be sent. Normally this
- means the right mouse button was clicked, but this is platform
- dependent.
-
- \value Keyboard The keyboard caused this event to be sent. On
- Windows, this means the menu button was pressed.
-
- \value Other The event was sent by some other means (i.e. not by
- the mouse or keyboard).
-*/
-
-
-/*!
- \fn QContextMenuEvent::Reason QContextMenuEvent::reason() const
-
- Returns the reason for this context event.
-*/
-
-
-/*!
- \class QInputMethodEvent
- \brief The QInputMethodEvent class provides parameters for input method events.
-
- \ingroup events
-
- Input method events are sent to widgets when an input method is
- used to enter text into a widget. Input methods are widely used
- to enter text for languages with non-Latin alphabets.
-
- Note that when creating custom text editing widgets, the
- Qt::WA_InputMethodEnabled window attribute must be set explicitly
- (using the QWidget::setAttribute() function) in order to receive
- input method events.
-
- The events are of interest to authors of keyboard entry widgets
- who want to be able to correctly handle languages with complex
- character input. Text input in such languages is usually a three
- step process:
-
- \list 1
- \o \bold{Starting to Compose}
-
- When the user presses the first key on a keyboard, an input
- context is created. This input context will contain a string
- of the typed characters.
-
- \o \bold{Composing}
-
- With every new key pressed, the input method will try to create a
- matching string for the text typed so far called preedit
- string. While the input context is active, the user can only move
- the cursor inside the string belonging to this input context.
-
- \o \bold{Completing}
-
- At some point, the user will activate a user interface component
- (perhaps using a particular key) where they can choose from a
- number of strings matching the text they have typed so far. The
- user can either confirm their choice cancel the input; in either
- case the input context will be closed.
- \endlist
-
- QInputMethodEvent models these three stages, and transfers the
- information needed to correctly render the intermediate result. A
- QInputMethodEvent has two main parameters: preeditString() and
- commitString(). The preeditString() parameter gives the currently
- active preedit string. The commitString() parameter gives a text
- that should get added to (or replace parts of) the text of the
- editor widget. It usually is a result of the input operations and
- has to be inserted to the widgets text directly before the preedit
- string.
-
- If the commitString() should replace parts of the of the text in
- the editor, replacementLength() will contain the number of
- characters to be replaced. replacementStart() contains the position
- at which characters are to be replaced relative from the start of
- the preedit string.
-
- A number of attributes control the visual appearance of the
- preedit string (the visual appearance of text outside the preedit
- string is controlled by the widget only). The AttributeType enum
- describes the different attributes that can be set.
-
- A class implementing QWidget::inputMethodEvent() or
- QGraphicsItem::inputMethodEvent() should at least understand and
- honor the \l TextFormat and \l Cursor attributes.
-
- Since input methods need to be able to query certain properties
- from the widget or graphics item, subclasses must also implement
- QWidget::inputMethodQuery() and QGraphicsItem::inputMethodQuery(),
- respectively.
-
- When receiving an input method event, the text widget has to performs the
- following steps:
-
- \list 1
- \o If the widget has selected text, the selected text should get
- removed.
-
- \o Remove the text starting at replacementStart() with length
- replacementLength() and replace it by the commitString(). If
- replacementLength() is 0, replacementStart() gives the insertion
- position for the commitString().
-
- When doing replacement the area of the preedit
- string is ignored, thus a replacement starting at -1 with a length
- of 2 will remove the last character before the preedit string and
- the first character afterwards, and insert the commit string
- directly before the preedit string.
-
- If the widget implements undo/redo, this operation gets added to
- the undo stack.
-
- \o If there is no current preedit string, insert the
- preeditString() at the current cursor position; otherwise replace
- the previous preeditString with the one received from this event.
-
- If the widget implements undo/redo, the preeditString() should not
- influence the undo/redo stack in any way.
-
- The widget should examine the list of attributes to apply to the
- preedit string. It has to understand at least the TextFormat and
- Cursor attributes and render them as specified.
- \endlist
-
- \sa QInputContext
-*/
-
-/*!
- \enum QInputMethodEvent::AttributeType
-
- \value TextFormat
- A QTextCharFormat for the part of the preedit string specified by
- start and length. value contains a QVariant of type QTextFormat
- specifying rendering of this part of the preedit string. There
- should be at most one format for every part of the preedit
- string. If several are specified for any character in the string the
- behaviour is undefined. A conforming implementation has to at least
- honor the backgroundColor, textColor and fontUnderline properties
- of the format.
-
- \value Cursor If set, a cursor should be shown inside the preedit
- string at position start. The length variable determines whether
- the cursor is visible or not. If the length is 0 the cursor is
- invisible. If value is a QVariant of type QColor this color will
- be used for rendering the cursor, otherwise the color of the
- surrounding text will be used. There should be at most one Cursor
- attribute per event. If several are specified the behaviour is
- undefined.
-
- \value Language
- The variant contains a QLocale object specifying the language of a
- certain part of the preedit string. There should be at most one
- language set for every part of the preedit string. If several are
- specified for any character in the string the behavior is undefined.
-
- \value Ruby
- The ruby text for a part of the preedit string. There should be at
- most one ruby text set for every part of the preedit string. If
- several are specified for any character in the string the behaviour
- is undefined.
-
- \value Selection
- If set, the edit cursor should be moved to the specified position
- in the editor text contents. In contrast with \c Cursor, this
- attribute does not work on the preedit text, but on the surrounding
- text. The cursor will be moved after the commit string has been
- committed, and the preedit string will be located at the new edit
- position.
- The start position specifies the new position and the length
- variable can be used to set a selection starting from that point.
- The value is unused.
-
- \sa Attribute
-*/
-
-/*!
- \class QInputMethodEvent::Attribute
- \brief The QInputMethodEvent::Attribute class stores an input method attribute.
-*/
-
-/*!
- \fn QInputMethodEvent::Attribute::Attribute(AttributeType type, int start, int length, QVariant value)
-
- Constructs an input method attribute. \a type specifies the type
- of attribute, \a start and \a length the position of the
- attribute, and \a value the value of the attribute.
-*/
-
-/*!
- Constructs an event of type QEvent::InputMethod. The
- attributes(), preeditString(), commitString(), replacementStart(),
- and replacementLength() are initialized to default values.
-
- \sa setCommitString()
-*/
-QInputMethodEvent::QInputMethodEvent()
- : QEvent(QEvent::InputMethod), replace_from(0), replace_length(0)
-{
-}
-
-/*!
- Construcs an event of type QEvent::InputMethod. The
- preedit text is set to \a preeditText, the attributes to
- \a attributes.
-
- The commitString(), replacementStart(), and replacementLength()
- values can be set using setCommitString().
-
- \sa preeditString(), attributes()
-*/
-QInputMethodEvent::QInputMethodEvent(const QString &preeditText, const QList<Attribute> &attributes)
- : QEvent(QEvent::InputMethod), preedit(preeditText), attrs(attributes),
- replace_from(0), replace_length(0)
-{
-}
-
-/*!
- Constructs a copy of \a other.
-*/
-QInputMethodEvent::QInputMethodEvent(const QInputMethodEvent &other)
- : QEvent(QEvent::InputMethod), preedit(other.preedit), attrs(other.attrs),
- commit(other.commit), replace_from(other.replace_from), replace_length(other.replace_length)
-{
-}
-
-/*!
- Sets the commit string to \a commitString.
-
- The commit string is the text that should get added to (or
- replace parts of) the text of the editor widget. It usually is a
- result of the input operations and has to be inserted to the
- widgets text directly before the preedit string.
-
- If the commit string should replace parts of the of the text in
- the editor, \a replaceLength specifies the number of
- characters to be replaced. \a replaceFrom specifies the position
- at which characters are to be replaced relative from the start of
- the preedit string.
-
- \sa commitString(), replacementStart(), replacementLength()
-*/
-void QInputMethodEvent::setCommitString(const QString &commitString, int replaceFrom, int replaceLength)
-{
- commit = commitString;
- replace_from = replaceFrom;
- replace_length = replaceLength;
-}
-
-/*!
- \fn const QList<Attribute> &QInputMethodEvent::attributes() const
-
- Returns the list of attributes passed to the QInputMethodEvent
- constructor. The attributes control the visual appearance of the
- preedit string (the visual appearance of text outside the preedit
- string is controlled by the widget only).
-
- \sa preeditString(), Attribute
-*/
-
-/*!
- \fn const QString &QInputMethodEvent::preeditString() const
-
- Returns the preedit text, i.e. the text before the user started
- editing it.
-
- \sa commitString(), attributes()
-*/
-
-/*!
- \fn const QString &QInputMethodEvent::commitString() const
-
- Returns the text that should get added to (or replace parts of)
- the text of the editor widget. It usually is a result of the
- input operations and has to be inserted to the widgets text
- directly before the preedit string.
-
- \sa setCommitString(), preeditString(), replacementStart(), replacementLength()
-*/
-
-/*!
- \fn int QInputMethodEvent::replacementStart() const
-
- Returns the position at which characters are to be replaced relative
- from the start of the preedit string.
-
- \sa replacementLength(), setCommitString()
-*/
-
-/*!
- \fn int QInputMethodEvent::replacementLength() const
-
- Returns the number of characters to be replaced in the preedit
- string.
-
- \sa replacementStart(), setCommitString()
-*/
-
-#ifndef QT_NO_TABLETEVENT
-
-/*!
- \class QTabletEvent
- \brief The QTabletEvent class contains parameters that describe a Tablet event.
-
- \ingroup events
-
- Tablet Events are generated from a Wacom tablet. Most of the time you will
- want to deal with events from the tablet as if they were events from a
- mouse; for example, you would retrieve the cursor position with x(), y(),
- pos(), globalX(), globalY(), and globalPos(). In some situations you may
- wish to retrieve the extra information provided by the tablet device
- driver; for example, you might want to do subpixeling with higher
- resolution coordinates or you may want to adjust color brightness based on
- pressure. QTabletEvent allows you to read the pressure(), the xTilt(), and
- yTilt(), as well as the type of device being used with device() (see
- \l{TabletDevice}). It can also give you the minimum and maximum values for
- each device's pressure and high resolution coordinates.
-
- A tablet event contains a special accept flag that indicates whether the
- receiver wants the event. You should call QTabletEvent::accept() if you
- handle the tablet event; otherwise it will be sent to the parent widget.
- The exception are TabletEnterProximity and TabletLeaveProximity events,
- these are only sent to QApplication and don't check whether or not they are
- accepted.
-
- The QWidget::setEnabled() function can be used to enable or
- disable mouse and keyboard events for a widget.
-
- The event handler QWidget::tabletEvent() receives all three types of
- tablet events. Qt will first send a tabletEvent then, if it is not
- accepted, it will send a mouse event. This allows applications that
- don't utilize tablets to use a tablet like a mouse, while also
- enabling those who want to use both tablets and mouses differently.
-
- \section1 Notes for X11 Users
-
- Qt uses the following hard-coded names to identify tablet
- devices from the xorg.conf file on X11 (apart from IRIX):
- 'stylus', 'pen', and 'eraser'. If the devices have other names,
- they will not be picked up Qt.
-*/
-
-/*!
- \enum QTabletEvent::TabletDevice
-
- This enum defines what type of device is generating the event.
-
- \value NoDevice No device, or an unknown device.
- \value Puck A Puck (a device that is similar to a flat mouse with
- a transparent circle with cross-hairs).
- \value Stylus A Stylus.
- \value Airbrush An airbrush
- \value FourDMouse A 4D Mouse.
- \value RotationStylus A special stylus that also knows about rotation
- (a 6D stylus). \since 4.1
- \omitvalue XFreeEraser
-*/
-
-/*!
- \enum QTabletEvent::PointerType
-
- This enum defines what type of point is generating the event.
-
- \value UnknownPointer An unknown device.
- \value Pen Tip end of a stylus-like device (the narrow end of the pen).
- \value Cursor Any puck-like device.
- \value Eraser Eraser end of a stylus-like device (the broad end of the pen).
-
- \sa pointerType()
-*/
-
-/*!
- Construct a tablet event of the given \a type.
-
- The \a pos parameter indicates where the event occurred in the
- widget; \a globalPos is the corresponding position in absolute
- coordinates. The \a hiResGlobalPos contains a high resolution
- measurement of the position.
-
- \a pressure contains the pressure exerted on the \a device.
-
- \a pointerType describes the type of pen that is being used.
-
- \a xTilt and \a yTilt contain the device's degree of tilt from the
- x and y axes respectively.
-
- \a keyState specifies which keyboard modifiers are pressed (e.g.,
- \key{Ctrl}).
-
- The \a uniqueID parameter contains the unique ID for the current device.
-
- The \a z parameter contains the coordinate of the device on the tablet, this
- is usually given by a wheel on 4D mouse. If the device does not support a
- Z-axis, pass zero here.
-
- The \a tangentialPressure parameter contins the tangential pressure of an air
- brush. If the device does not support tangential pressure, pass 0 here.
-
- \a rotation contains the device's rotation in degrees. 4D mice support
- rotation. If the device does not support rotation, pass 0 here.
-
- \sa pos() globalPos() device() pressure() xTilt() yTilt() uniqueId(), rotation(), tangentialPressure(), z()
-*/
-
-QTabletEvent::QTabletEvent(Type type, const QPoint &pos, const QPoint &globalPos,
- const QPointF &hiResGlobalPos, int device, int pointerType,
- qreal pressure, int xTilt, int yTilt, qreal tangentialPressure,
- qreal rotation, int z, Qt::KeyboardModifiers keyState, qint64 uniqueID)
- : QInputEvent(type, keyState),
- mPos(pos),
- mGPos(globalPos),
- mHiResGlobalPos(hiResGlobalPos),
- mDev(device),
- mPointerType(pointerType),
- mXT(xTilt),
- mYT(yTilt),
- mZ(z),
- mPress(pressure),
- mTangential(tangentialPressure),
- mRot(rotation),
- mUnique(uniqueID),
- mExtra(0)
-{
-}
-
-/*!
- \internal
-*/
-QTabletEvent::~QTabletEvent()
-{
-}
-
-/*!
- \fn TabletDevices QTabletEvent::device() const
-
- Returns the type of device that generated the event.
-
- \sa TabletDevice
-*/
-
-/*!
- \fn PointerType QTabletEvent::pointerType() const
-
- Returns the type of point that generated the event.
-*/
-
-/*!
- \fn qreal QTabletEvent::tangentialPressure() const
-
- Returns the tangential pressure for the device. This is typically given by a finger
- wheel on an airbrush tool. The range is from -1.0 to 1.0. 0.0 indicates a
- neutral position. Current airbrushes can only move in the positive
- direction from the neutrual position. If the device does not support
- tangential pressure, this value is always 0.0.
-
- \sa pressure()
-*/
-
-/*!
- \fn qreal QTabletEvent::rotation() const
-
- Returns the rotation of the current device in degress. This is usually
- given by a 4D Mouse. If the device doesn't support rotation this value is
- always 0.0.
-
-*/
-
-/*!
- \fn qreal QTabletEvent::pressure() const
-
- Returns the pressure for the device. 0.0 indicates that the stylus is not
- on the tablet, 1.0 indicates the maximum amount of pressure for the stylus.
-
- \sa tangentialPressure()
-*/
-
-/*!
- \fn int QTabletEvent::xTilt() const
-
- Returns the angle between the device (a pen, for example) and the
- perpendicular in the direction of the x axis.
- Positive values are towards the tablet's physical right. The angle
- is in the range -60 to +60 degrees.
-
- \img qtabletevent-tilt.png
-
- \sa yTilt()
-*/
-
-/*!
- \fn int QTabletEvent::yTilt() const
-
- Returns the angle between the device (a pen, for example) and the
- perpendicular in the direction of the y axis.
- Positive values are towards the bottom of the tablet. The angle is
- within the range -60 to +60 degrees.
-
- \sa xTilt()
-*/
-
-/*!
- \fn const QPoint &QTabletEvent::pos() const
-
- Returns the position of the device, relative to the widget that
- received the event.
-
- If you move widgets around in response to mouse events, use
- globalPos() instead of this function.
-
- \sa x() y() globalPos()
-*/
-
-/*!
- \fn int QTabletEvent::x() const
-
- Returns the x position of the device, relative to the widget that
- received the event.
-
- \sa y() pos()
-*/
-
-/*!
- \fn int QTabletEvent::y() const
-
- Returns the y position of the device, relative to the widget that
- received the event.
-
- \sa x() pos()
-*/
-
-/*!
- \fn int QTabletEvent::z() const
-
- Returns the z position of the device. Typically this is represented by a
- wheel on a 4D Mouse. If the device does not support a Z-axis, this value is
- always zero. This is \bold not the same as pressure.
-
- \sa pressure()
-*/
-
-/*!
- \fn const QPoint &QTabletEvent::globalPos() const
-
- Returns the global position of the device \e{at the time of the
- event}. This is important on asynchronous windows systems like X11;
- whenever you move your widgets around in response to mouse events,
- globalPos() can differ significantly from the current position
- QCursor::pos().
-
- \sa globalX() globalY() hiResGlobalPos()
-*/
-
-/*!
- \fn int QTabletEvent::globalX() const
-
- Returns the global x position of the mouse pointer at the time of
- the event.
-
- \sa globalY() globalPos() hiResGlobalX()
-*/
-
-/*!
- \fn int QTabletEvent::globalY() const
-
- Returns the global y position of the tablet device at the time of
- the event.
-
- \sa globalX() globalPos() hiResGlobalY()
-*/
-
-/*!
- \fn qint64 QTabletEvent::uniqueId() const
-
- Returns a unique ID for the current device, making it possible
- to differentiate between multiple devices being used at the same
- time on the tablet.
-
- Support of this feature is dependent on the tablet.
-
- Values for the same device may vary from OS to OS.
-
- Later versions of the Wacom driver for Linux will now report
- the ID information. If you have a tablet that supports unique ID
- and are not getting the information on Linux, consider upgrading
- your driver.
-
- As of Qt 4.2, the unique ID is the same regardless of the orientation
- of the pen. Earlier versions would report a different value when using
- the eraser-end versus the pen-end of the stylus on some OS's.
-
- \sa pointerType()
-*/
-
-/*!
- \fn const QPointF &QTabletEvent::hiResGlobalPos() const
-
- The high precision coordinates delivered from the tablet expressed.
- Sub pixeling information is in the fractional part of the QPointF.
-
- \sa globalPos() hiResGlobalX() hiResGlobalY()
-*/
-
-/*!
- \fn qreal &QTabletEvent::hiResGlobalX() const
-
- The high precision x position of the tablet device.
-*/
-
-/*!
- \fn qreal &QTabletEvent::hiResGlobalY() const
-
- The high precision y position of the tablet device.
-*/
-
-#endif // QT_NO_TABLETEVENT
-
-#ifndef QT_NO_DRAGANDDROP
-/*!
- Creates a QDragMoveEvent of the required \a type indicating
- that the mouse is at position \a pos given within a widget.
-
- The mouse and keyboard states are specified by \a buttons and
- \a modifiers, and the \a actions describe the types of drag
- and drop operation that are possible.
- The drag data is passed as MIME-encoded information in \a data.
-
- \warning Do not attempt to create a QDragMoveEvent yourself.
- These objects rely on Qt's internal state.
-*/
-QDragMoveEvent::QDragMoveEvent(const QPoint& pos, Qt::DropActions actions, const QMimeData *data,
- Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type)
- : QDropEvent(pos, actions, data, buttons, modifiers, type)
- , rect(pos, QSize(1, 1))
-{}
-
-/*!
- Destroys the event.
-*/
-QDragMoveEvent::~QDragMoveEvent()
-{
-}
-
-/*!
- \fn void QDragMoveEvent::accept(bool y)
-
- Calls setAccepted(\a y) instead.
-*/
-
-/*!
- \fn void QDragMoveEvent::accept(const QRect &rectangle)
-
- The same as accept(), but also notifies that future moves will
- also be acceptable if they remain within the \a rectangle
- given on the widget. This can improve performance, but may
- also be ignored by the underlying system.
-
- If the rectangle is empty, drag move events will be sent
- continuously. This is useful if the source is scrolling in a
- timer event.
-*/
-
-/*!
- \fn void QDragMoveEvent::accept()
-
- \overload
-
- Calls QDropEvent::accept().
-*/
-
-/*!
- \fn void QDragMoveEvent::ignore()
-
- \overload
-
- Calls QDropEvent::ignore().
-*/
-
-/*!
- \fn void QDragMoveEvent::ignore(const QRect &rectangle)
-
- The opposite of the accept(const QRect&) function.
- Moves within the \a rectangle are not acceptable, and will be
- ignored.
-*/
-
-/*!
- \fn QRect QDragMoveEvent::answerRect() const
-
- Returns the rectangle in the widget where the drop will occur if accepted.
- You can use this information to restrict drops to certain places on the
- widget.
-*/
-
-
-/*!
- \class QDropEvent
- \ingroup events
- \ingroup draganddrop
-
- \brief The QDropEvent class provides an event which is sent when a
- drag and drop action is completed.
-
- When a widget \l{QWidget::setAcceptDrops()}{accepts drop events}, it will
- receive this event if it has accepted the most recent QDragEnterEvent or
- QDragMoveEvent sent to it.
-
- The drop event contains a proposed action, available from proposedAction(), for
- the widget to either accept or ignore. If the action can be handled by the
- widget, you should call the acceptProposedAction() function. Since the
- proposed action can be a combination of \l Qt::DropAction values, it may be
- useful to either select one of these values as a default action or ask
- the user to select their preferred action.
-
- If the proposed drop action is not suitable, perhaps because your custom
- widget does not support that action, you can replace it with any of the
- \l{possibleActions()}{possible drop actions} by calling setDropAction()
- with your preferred action. If you set a value that is not present in the
- bitwise OR combination of values returned by possibleActions(), the default
- copy action will be used. Once a replacement drop action has been set, call
- accept() instead of acceptProposedAction() to complete the drop operation.
-
- The mimeData() function provides the data dropped on the widget in a QMimeData
- object. This contains information about the MIME type of the data in addition to
- the data itself.
-
- \sa QMimeData, QDrag, {Drag and Drop}
-*/
-
-/*!
- \fn const QMimeData *QDropEvent::mimeData() const
-
- Returns the data that was dropped on the widget and its associated MIME
- type information.
-*/
-
-/*!
- Constructs a drop event of a certain \a type corresponding to a
- drop at the point specified by \a pos in the destination widget's
- coordinate system.
-
- The \a actions indicate which types of drag and drop operation can
- be performed, and the drag data is stored as MIME-encoded data in \a data.
-
- The states of the mouse buttons and keyboard modifiers at the time of
- the drop are specified by \a buttons and \a modifiers.
-*/ // ### pos is in which coordinate system?
-QDropEvent::QDropEvent(const QPoint& pos, Qt::DropActions actions, const QMimeData *data,
- Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type)
- : QEvent(type), p(pos), mouseState(buttons),
- modState(modifiers), act(actions),
- mdata(data)
-{
- default_action = QDragManager::self()->defaultAction(act, modifiers);
- drop_action = default_action;
- ignore();
-}
-
-/*! \internal */
-QDropEvent::~QDropEvent()
-{
-}
-
-/*!
- \compat
- Returns a byte array containing the drag's data, in \a format.
-
- data() normally needs to get the data from the drag source, which
- is potentially very slow, so it's advisable to call this function
- only if you're sure that you will need the data in that
- particular \a format.
-
- The resulting data will have a size of 0 if the format was not
- available.
-
- \sa format() QByteArray::size()
-*/
-
-QByteArray QDropEvent::encodedData(const char *format) const
-{
- return mdata->data(QLatin1String(format));
-}
-
-/*!
- \compat
- Returns a string describing one of the available data types for
- this drag. Common examples are "text/plain" and "image/gif".
- If \a n is less than zero or greater than the number of available
- data types, format() returns 0.
-
- This function is provided mainly for debugging. Most drop targets
- will use provides().
-
- \sa data() provides()
-*/
-
-const char* QDropEvent::format(int n) const
-{
- if (fmts.isEmpty()) {
- QStringList formats = mdata->formats();
- for (int i = 0; i < formats.size(); ++i)
- fmts.append(formats.at(i).toLatin1());
- }
- if (n < 0 || n >= fmts.size())
- return 0;
- return fmts.at(n).constData();
-}
-
-/*!
- \compat
- Returns true if this event provides format \a mimeType; otherwise
- returns false.
-
- \sa data()
-*/
-
-bool QDropEvent::provides(const char *mimeType) const
-{
- return mdata->formats().contains(QLatin1String(mimeType));
-}
-
-/*!
- If the source of the drag operation is a widget in this
- application, this function returns that source; otherwise it
- returns 0. The source of the operation is the first parameter to
- the QDrag object used instantiate the drag.
-
- This is useful if your widget needs special behavior when dragging
- to itself.
-
- \sa QDrag::QDrag()
-*/
-QWidget* QDropEvent::source() const
-{
- QDragManager *manager = QDragManager::self();
- return manager ? manager->source() : 0;
-}
-
-
-void QDropEvent::setDropAction(Qt::DropAction action)
-{
- if (!(action & act) && action != Qt::IgnoreAction)
- action = default_action;
- drop_action = action;
-}
-
-/*!
- \fn const QPoint& QDropEvent::pos() const
-
- Returns the position where the drop was made.
-*/
-
-/*!
- \fn Qt::MouseButtons QDropEvent::mouseButtons() const
-
- Returns the mouse buttons that are pressed..
-*/
-
-/*!
- \fn Qt::KeyboardModifiers QDropEvent::keyboardModifiers() const
-
- Returns the modifier keys that are pressed.
-*/
-
-/*!
- \fn void QDropEvent::accept()
- \internal
-*/
-
-/*!
- \fn void QDropEvent::accept(bool accept)
-
- Call setAccepted(\a accept) instead.
-*/
-
-/*!
- \fn void QDropEvent::acceptAction(bool accept = true)
-
- Call this to indicate that the action described by action() is
- accepted (i.e. if \a accept is true, which is the default), not merely
- the default copy action. If you call acceptAction(true), there is
- no need to also call accept(true).
-*/
-
-/*!
- \enum QDropEvent::Action
- \compat
-
- When a drag and drop action is completed, the target is expected
- to perform an action on the data provided by the source. This
- will be one of the following:
-
- \value Copy The default action. The source simply uses the data
- provided in the operation.
- \value Link The source should somehow create a link to the
- location specified by the data.
- \value Move The source should somehow move the object from the
- location specified by the data to a new location.
- \value Private The target has special knowledge of the MIME type,
- which the source should respond to in a similar way to
- a Copy.
- \value UserAction The source and target can co-operate using
- special actions. This feature is not currently
- supported.
-
- The Link and Move actions only makes sense if the data is a
- reference, for example, text/uri-list file lists (see QUriDrag).
-*/
-
-/*!
- \fn void QDropEvent::setDropAction(Qt::DropAction action)
-
- Sets the \a action to be performed on the data by the target.
- Use this to override the \l{proposedAction()}{proposed action}
- with one of the \l{possibleActions()}{possible actions}.
-
- If you set a drop action that is not one of the possible actions, the
- drag and drop operation will default to a copy operation.
-
- Once you have supplied a replacement drop action, call accept()
- instead of acceptProposedAction().
-
- \sa dropAction()
-*/
-
-/*!
- \fn Qt::DropAction QDropEvent::dropAction() const
-
- Returns the action to be performed on the data by the target. This may be
- different from the action supplied in proposedAction() if you have called
- setDropAction() to explicitly choose a drop action.
-
- \sa setDropAction()
-*/
-
-/*!
- \fn Qt::DropActions QDropEvent::possibleActions() const
-
- Returns an OR-combination of possible drop actions.
-
- \sa dropAction()
-*/
-
-/*!
- \fn Qt::DropAction QDropEvent::proposedAction() const
-
- Returns the proposed drop action.
-
- \sa dropAction()
-*/
-
-/*!
- \fn void QDropEvent::acceptProposedAction()
-
- Sets the drop action to be the proposed action.
-
- \sa setDropAction(), proposedAction(), {QEvent::accept()}{accept()}
-*/
-
-#ifdef QT3_SUPPORT
-/*!
- Use dropAction() instead.
-
- The table below shows the correspondance between the return type
- of action() and the return type of dropAction().
-
- \table
- \header \i Old enum value \i New enum value
- \row \i QDropEvent::Copy \i Qt::CopyAction
- \row \i QDropEvent::Move \i Qt::MoveAction
- \row \i QDropEvent::Link \i Qt::LinkAction
- \row \i other \i Qt::CopyAction
- \endtable
-*/
-
-QT3_SUPPORT QDropEvent::Action QDropEvent::action() const
-{
- switch(drop_action) {
- case Qt::CopyAction:
- return Copy;
- case Qt::MoveAction:
- return Move;
- case Qt::LinkAction:
- return Link;
- default:
- return Copy;
- }
-}
-#endif
-
-/*!
- \fn void QDropEvent::setPoint(const QPoint &point)
- \compat
-
- Sets the drop to happen at the given \a point. You do not normally
- need to use this as it will be set internally before your widget
- receives the drop event.
-*/ // ### here too - what coordinate system?
-
-
-/*!
- \class QDragEnterEvent
- \brief The QDragEnterEvent class provides an event which is sent
- to a widget when a drag and drop action enters it.
-
- \ingroup events
- \ingroup draganddrop
-
- A widget must accept this event in order to receive the \l
- {QDragMoveEvent}{drag move events} that are sent while the drag
- and drop action is in progress. The drag enter event is always
- immediately followed by a drag move event.
-
- QDragEnterEvent inherits most of its functionality from
- QDragMoveEvent, which in turn inherits most of its functionality
- from QDropEvent.
-
- \sa QDragLeaveEvent, QDragMoveEvent, QDropEvent
-*/
-
-/*!
- Constructs a QDragEnterEvent that represents a drag entering a
- widget at the given \a point with mouse and keyboard states specified by
- \a buttons and \a modifiers.
-
- The drag data is passed as MIME-encoded information in \a data, and the
- specified \a actions describe the possible types of drag and drop
- operation that can be performed.
-
- \warning Do not create a QDragEnterEvent yourself since these
- objects rely on Qt's internal state.
-*/
-QDragEnterEvent::QDragEnterEvent(const QPoint& point, Qt::DropActions actions, const QMimeData *data,
- Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
- : QDragMoveEvent(point, actions, data, buttons, modifiers, DragEnter)
-{}
-
-/*! \internal
-*/
-QDragEnterEvent::~QDragEnterEvent()
-{
-}
-
-/*!
- Constructs a drag response event containing the \a accepted value,
- indicating whether the drag and drop operation was accepted by the
- recipient.
-*/
-QDragResponseEvent::QDragResponseEvent(bool accepted)
- : QEvent(DragResponse), a(accepted)
-{}
-
-/*! \internal
-*/
-QDragResponseEvent::~QDragResponseEvent()
-{
-}
-
-/*!
- \class QDragMoveEvent
- \brief The QDragMoveEvent class provides an event which is sent while a drag and drop action is in progress.
-
- \ingroup events
- \ingroup draganddrop
-
- A widget will receive drag move events repeatedly while the drag
- is within its boundaries, if it accepts
- \l{QWidget::setAcceptDrops()}{drop events} and \l
- {QWidget::dragEnterEvent()}{enter events}. The widget should
- examine the event to see what kind of data it
- \l{QDragMoveEvent::provides()}{provides}, and call the accept()
- function to accept the drop if appropriate.
-
- The rectangle supplied by the answerRect() function can be used to restrict
- drops to certain parts of the widget. For example, we can check whether the
- rectangle intersects with the geometry of a certain child widget and only
- call \l{QDropEvent::acceptProposedAction()}{acceptProposedAction()} if that
- is the case.
-
- Note that this class inherits most of its functionality from
- QDropEvent.
-
- \sa QDragEnterEvent, QDragLeaveEvent, QDropEvent
-*/
-
-/*!
- \class QDragLeaveEvent
- \brief The QDragLeaveEvent class provides an event that is sent to a widget when a drag and drop action leaves it.
-
- \ingroup events
- \ingroup draganddrop
-
- This event is always preceded by a QDragEnterEvent and a series
- of \l{QDragMoveEvent}s. It is not sent if a QDropEvent is sent
- instead.
-
- \sa QDragEnterEvent, QDragMoveEvent, QDropEvent
-*/
-
-/*!
- Constructs a QDragLeaveEvent.
-
- \warning Do not create a QDragLeaveEvent yourself since these
- objects rely on Qt's internal state.
-*/
-QDragLeaveEvent::QDragLeaveEvent()
- : QEvent(DragLeave)
-{}
-
-/*! \internal
-*/
-QDragLeaveEvent::~QDragLeaveEvent()
-{
-}
-#endif // QT_NO_DRAGANDDROP
-
-/*!
- \class QHelpEvent
- \brief The QHelpEvent class provides an event that is used to request helpful information
- about a particular point in a widget.
-
- \ingroup events
- \ingroup helpsystem
-
- This event can be intercepted in applications to provide tooltips
- or "What's This?" help for custom widgets. The type() can be
- either QEvent::ToolTip or QEvent::WhatsThis.
-
- \sa QToolTip, QWhatsThis, QStatusTipEvent, QWhatsThisClickedEvent
-*/
-
-/*!
- Constructs a help event with the given \a type corresponding to the
- widget-relative position specified by \a pos and the global position
- specified by \a globalPos.
-
- \a type must be either QEvent::ToolTip or QEvent::WhatsThis.
-
- \sa pos(), globalPos()
-*/
-QHelpEvent::QHelpEvent(Type type, const QPoint &pos, const QPoint &globalPos)
- : QEvent(type), p(pos), gp(globalPos)
-{}
-
-/*!
- \fn int QHelpEvent::x() const
-
- Same as pos().x().
-
- \sa y(), pos(), globalPos()
-*/
-
-/*!
- \fn int QHelpEvent::y() const
-
- Same as pos().y().
-
- \sa x(), pos(), globalPos()
-*/
-
-/*!
- \fn int QHelpEvent::globalX() const
-
- Same as globalPos().x().
-
- \sa x(), globalY(), globalPos()
-*/
-
-/*!
- \fn int QHelpEvent::globalY() const
-
- Same as globalPos().y().
-
- \sa y(), globalX(), globalPos()
-*/
-
-/*!
- \fn const QPoint &QHelpEvent::pos() const
-
- Returns the mouse cursor position when the event was generated,
- relative to the widget to which the event is dispatched.
-
- \sa globalPos(), x(), y()
-*/
-
-/*!
- \fn const QPoint &QHelpEvent::globalPos() const
-
- Returns the mouse cursor position when the event was generated
- in global coordinates.
-
- \sa pos(), globalX(), globalY()
-*/
-
-/*! \internal
-*/
-QHelpEvent::~QHelpEvent()
-{
-}
-
-#ifndef QT_NO_STATUSTIP
-
-/*!
- \class QStatusTipEvent
- \brief The QStatusTipEvent class provides an event that is used to show messages in a status bar.
-
- \ingroup events
- \ingroup helpsystem
-
- Status tips can be set on a widget using the
- QWidget::setStatusTip() function. They are shown in the status
- bar when the mouse cursor enters the widget. For example:
-
- \table 100%
- \row
- \o
- \snippet doc/src/snippets/qstatustipevent/main.cpp 1
- \dots
- \snippet doc/src/snippets/qstatustipevent/main.cpp 3
- \o
- \image qstatustipevent-widget.png Widget with status tip.
- \endtable
-
- Status tips can also be set on actions using the
- QAction::setStatusTip() function:
-
- \table 100%
- \row
- \o
- \snippet doc/src/snippets/qstatustipevent/main.cpp 0
- \snippet doc/src/snippets/qstatustipevent/main.cpp 2
- \dots
- \snippet doc/src/snippets/qstatustipevent/main.cpp 3
- \o
- \image qstatustipevent-action.png Action with status tip.
- \endtable
-
- Finally, status tips are supported for the item view classes
- through the Qt::StatusTipRole enum value.
-
- \sa QStatusBar, QHelpEvent, QWhatsThisClickedEvent
-*/
-
-/*!
- Constructs a status tip event with the text specified by \a tip.
-
- \sa tip()
-*/
-QStatusTipEvent::QStatusTipEvent(const QString &tip)
- : QEvent(StatusTip), s(tip)
-{}
-
-/*! \internal
-*/
-QStatusTipEvent::~QStatusTipEvent()
-{
-}
-
-/*!
- \fn QString QStatusTipEvent::tip() const
-
- Returns the message to show in the status bar.
-
- \sa QStatusBar::showMessage()
-*/
-
-#endif // QT_NO_STATUSTIP
-
-#ifndef QT_NO_WHATSTHIS
-
-/*!
- \class QWhatsThisClickedEvent
- \brief The QWhatsThisClickedEvent class provides an event that
- can be used to handle hyperlinks in a "What's This?" text.
-
- \ingroup events
- \ingroup helpsystem
-
- \sa QWhatsThis, QHelpEvent, QStatusTipEvent
-*/
-
-/*!
- Constructs an event containing a URL specified by \a href when a link
- is clicked in a "What's This?" message.
-
- \sa href()
-*/
-QWhatsThisClickedEvent::QWhatsThisClickedEvent(const QString &href)
- : QEvent(WhatsThisClicked), s(href)
-{}
-
-/*! \internal
-*/
-QWhatsThisClickedEvent::~QWhatsThisClickedEvent()
-{
-}
-
-/*!
- \fn QString QWhatsThisClickedEvent::href() const
-
- Returns the URL that was clicked by the user in the "What's
- This?" text.
-*/
-
-#endif // QT_NO_WHATSTHIS
-
-#ifndef QT_NO_ACTION
-
-/*!
- \class QActionEvent
- \brief The QActionEvent class provides an event that is generated
- when a QAction is added, removed, or changed.
-
- \ingroup events
-
- Actions can be added to widgets using QWidget::addAction(). This
- generates an \l ActionAdded event, which you can handle to provide
- custom behavior. For example, QToolBar reimplements
- QWidget::actionEvent() to create \l{QToolButton}s for the
- actions.
-
- \sa QAction, QWidget::addAction(), QWidget::removeAction(), QWidget::actions()
-*/
-
-/*!
- Constructs an action event. The \a type can be \l ActionChanged,
- \l ActionAdded, or \l ActionRemoved.
-
- \a action is the action that is changed, added, or removed. If \a
- type is ActionAdded, the action is to be inserted before the
- action \a before. If \a before is 0, the action is appended.
-*/
-QActionEvent::QActionEvent(int type, QAction *action, QAction *before)
- : QEvent(static_cast<QEvent::Type>(type)), act(action), bef(before)
-{}
-
-/*! \internal
-*/
-QActionEvent::~QActionEvent()
-{
-}
-
-/*!
- \fn QAction *QActionEvent::action() const
-
- Returns the action that is changed, added, or removed.
-
- \sa before()
-*/
-
-/*!
- \fn QAction *QActionEvent::before() const
-
- If type() is \l ActionAdded, returns the action that should
- appear before action(). If this function returns 0, the action
- should be appended to already existing actions on the same
- widget.
-
- \sa action(), QWidget::actions()
-*/
-
-#endif // QT_NO_ACTION
-
-/*!
- \class QHideEvent
- \brief The QHideEvent class provides an event which is sent after a widget is hidden.
-
- \ingroup events
-
- This event is sent just before QWidget::hide() returns, and also
- when a top-level window has been hidden (iconified) by the user.
-
- If spontaneous() is true, the event originated outside the
- application. In this case, the user hid the window using the
- window manager controls, either by iconifying the window or by
- switching to another virtual desktop where the window isn't
- visible. The window will become hidden but not withdrawn. If the
- window was iconified, QWidget::isMinimized() returns true.
-
- \sa QShowEvent
-*/
-
-/*!
- Constructs a QHideEvent.
-*/
-QHideEvent::QHideEvent()
- : QEvent(Hide)
-{}
-
-/*! \internal
-*/
-QHideEvent::~QHideEvent()
-{
-}
-
-/*!
- \class QShowEvent
- \brief The QShowEvent class provides an event that is sent when a widget is shown.
-
- \ingroup events
-
- There are two kinds of show events: show events caused by the
- window system (spontaneous), and internal show events. Spontaneous (QEvent::spontaneous())
- show events are sent just after the window system shows the
- window; they are also sent when a top-level window is redisplayed
- after being iconified. Internal show events are delivered just
- before the widget becomes visible.
-
- \sa QHideEvent
-*/
-
-/*!
- Constructs a QShowEvent.
-*/
-QShowEvent::QShowEvent()
- : QEvent(Show)
-{}
-
-/*! \internal
-*/
-QShowEvent::~QShowEvent()
-{
-}
-
-/*!
- \fn QByteArray QDropEvent::data(const char* f) const
-
- \obsolete
-
- The encoded data is in \a f.
- Use QDropEvent::encodedData().
-*/
-
-/*!
- \class QFileOpenEvent
- \brief The QFileOpenEvent class provides an event that will be
- sent when there is a request to open a file or a URL.
-
- \ingroup events
-
- File open events will be sent to the QApplication::instance()
- when the operating system requests that a file or URL should be opened.
- This is a high-level event that can be caused by different user actions
- depending on the user's desktop environment; for example, double
- clicking on an file icon in the Finder on Mac OS X.
-
- This event is only used to notify the application of a request.
- It may be safely ignored.
-
- \note This class is currently supported for Mac OS X and Symbian only.
-*/
-
-QFileOpenEventPrivate::~QFileOpenEventPrivate()
-{
-#ifdef Q_OS_SYMBIAN
- file.Close();
-#endif
-}
-
-/*!
- \internal
-
- Constructs a file open event for the given \a file.
-*/
-QFileOpenEvent::QFileOpenEvent(const QString &file)
- : QEvent(FileOpen), f(file)
-{
- d = reinterpret_cast<QEventPrivate *>(new QFileOpenEventPrivate(QUrl::fromLocalFile(file)));
-}
-
-/*!
- \internal
-
- Constructs a file open event for the given \a url.
-*/
-QFileOpenEvent::QFileOpenEvent(const QUrl &url)
- : QEvent(FileOpen)
-{
- d = reinterpret_cast<QEventPrivate *>(new QFileOpenEventPrivate(url));
- f = url.toLocalFile();
-}
-
-#ifdef Q_OS_SYMBIAN
-/*! \internal
-*/
-QFileOpenEvent::QFileOpenEvent(const RFile &fileHandle)
- : QEvent(FileOpen)
-{
- TFileName fullName;
- fileHandle.FullName(fullName);
- f = qt_TDesC2QString(fullName);
- QScopedPointer<QFileOpenEventPrivate> priv(new QFileOpenEventPrivate(QUrl::fromLocalFile(f)));
- // Duplicate here allows the file handle to be valid after S60 app construction is complete.
- qt_symbian_throwIfError(priv->file.Duplicate(fileHandle));
- d = reinterpret_cast<QEventPrivate *>(priv.take());
-}
-#endif
-
-/*! \internal
-*/
-QFileOpenEvent::~QFileOpenEvent()
-{
- delete reinterpret_cast<QFileOpenEventPrivate *>(d);
-}
-
-/*!
- \fn QString QFileOpenEvent::file() const
-
- Returns the file that is being opened.
-*/
-
-/*!
- \fn QUrl QFileOpenEvent::url() const
-
- Returns the url that is being opened.
-
- \since 4.6
-*/
-QUrl QFileOpenEvent::url() const
-{
- return reinterpret_cast<const QFileOpenEventPrivate *>(d)->url;
-}
-
-/*!
- \fn bool openFile(QFile &file, QIODevice::OpenMode flags) const
-
- Opens a QFile on the file referenced by this event.
- Returns true if successful; otherwise returns false.
-
- This is necessary as some files cannot be opened by name, but require specific
- information stored in this event.
- For example, if this QFileOpenEvent contains a request to open a Symbian data caged file,
- the QFile could only be opened from the Symbian RFile used in the construction of this event.
-
- \since 4.8
-*/
-bool QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const
-{
- file.setFileName(f);
-#ifdef Q_OS_SYMBIAN
- const QFileOpenEventPrivate *priv = reinterpret_cast<const QFileOpenEventPrivate *>(d);
- if (priv->file.SubSessionHandle()) {
- RFile dup;
- // Duplicate here means that the opened QFile will continue to be valid beyond the lifetime of this QFileOpenEvent.
- // It also allows openFile to be used in threads other than the thread in which the QFileOpenEvent was created.
- if (dup.Duplicate(priv->file) == KErrNone) {
- QScopedPointer<RFile, QScopedPointerRCloser<RFile> > dupCloser(&dup);
- bool open = file.open(dup, flags, QFile::AutoCloseHandle);
- dupCloser.take();
- return open;
- }
- }
-#endif
- return file.open(flags);
-}
-
-#ifndef QT_NO_TOOLBAR
-/*!
- \internal
- \class QToolBarChangeEvent
- \brief The QToolBarChangeEvent class provides an event that is
- sent whenever a the toolbar button is clicked on Mac OS X.
-
- \ingroup events
-
- The QToolBarChangeEvent is sent when the toolbar button is clicked. On Mac
- OS X, this is the long oblong button on the right side of the window
- title bar. The default implementation is to toggle the appearance (hidden or
- shown) of the associated toolbars for the window.
-*/
-
-/*!
- \internal
-
- Construct a QToolBarChangeEvent given the current button state in \a state.
-*/
-QToolBarChangeEvent::QToolBarChangeEvent(bool t)
- : QEvent(ToolBarChange), tog(t)
-{}
-
-/*! \internal
-*/
-QToolBarChangeEvent::~QToolBarChangeEvent()
-{
-}
-
-/*!
- \fn bool QToolBarChangeEvent::toggle() const
- \internal
-*/
-
-/*
- \fn Qt::ButtonState QToolBarChangeEvent::state() const
-
- Returns the keyboard modifier flags at the time of the event.
-
- The returned value is a selection of the following values,
- combined using the OR operator:
- Qt::ShiftButton, Qt::ControlButton, Qt::MetaButton, and Qt::AltButton.
-*/
-
-#endif // QT_NO_TOOLBAR
-
-#ifndef QT_NO_SHORTCUT
-
-/*!
- Constructs a shortcut event for the given \a key press,
- associated with the QShortcut ID \a id.
-
- \a ambiguous specifies whether there is more than one QShortcut
- for the same key sequence.
-*/
-QShortcutEvent::QShortcutEvent(const QKeySequence &key, int id, bool ambiguous)
- : QEvent(Shortcut), sequence(key), ambig(ambiguous), sid(id)
-{
-}
-
-/*!
- Destroys the event object.
-*/
-QShortcutEvent::~QShortcutEvent()
-{
-}
-
-#endif // QT_NO_SHORTCUT
-
-#ifndef QT_NO_DEBUG_STREAM
-QDebug operator<<(QDebug dbg, const QEvent *e) {
-#ifndef Q_BROKEN_DEBUG_STREAM
- // More useful event output could be added here
- if (!e)
- return dbg << "QEvent(this = 0x0)";
- const char *n = 0;
- switch (e->type()) {
- case QEvent::Timer:
- n = "Timer";
- break;
- case QEvent::MouseButtonPress:
- case QEvent::MouseMove:
- case QEvent::MouseButtonRelease:
- case QEvent::MouseButtonDblClick:
- {
- const QMouseEvent *me = static_cast<const QMouseEvent*>(e);
- switch(me->type()) {
- case QEvent::MouseButtonPress:
- n = "MouseButtonPress";
- break;
- case QEvent::MouseMove:
- n = "MouseMove";
- break;
- case QEvent::MouseButtonRelease:
- n = "MouseButtonRelease";
- break;
- case QEvent::MouseButtonDblClick:
- default:
- n = "MouseButtonDblClick";
- break;
- }
- dbg.nospace() << "QMouseEvent(" << n
- << ", " << me->button()
- << ", " << hex << (int)me->buttons()
- << ", " << hex << (int)me->modifiers()
- << ')';
- }
- return dbg.space();
-
-#ifndef QT_NO_TOOLTIP
- case QEvent::ToolTip:
- n = "ToolTip";
- break;
-#endif
- case QEvent::WindowActivate:
- n = "WindowActivate";
- break;
- case QEvent::WindowDeactivate:
- n = "WindowDeactivate";
- break;
- case QEvent::ActivationChange:
- n = "ActivationChange";
- break;
-#ifndef QT_NO_WHEELEVENT
- case QEvent::Wheel:
- dbg.nospace() << "QWheelEvent(" << static_cast<const QWheelEvent *>(e)->delta()
- << ')';
- return dbg.space();
-#endif
- case QEvent::KeyPress:
- case QEvent::KeyRelease:
- case QEvent::ShortcutOverride:
- {
- const QKeyEvent *ke = static_cast<const QKeyEvent*>(e);
- switch(ke->type()) {
- case QEvent::ShortcutOverride:
- n = "ShortcutOverride";
- break;
- case QEvent::KeyRelease:
- n = "KeyRelease";
- break;
- case QEvent::KeyPress:
- default:
- n = "KeyPress";
- break;
- }
- dbg.nospace() << "QKeyEvent(" << n
- << ", " << hex << ke->key()
- << ", " << hex << (int)ke->modifiers()
- << ", \"" << ke->text()
- << "\", " << ke->isAutoRepeat()
- << ", " << ke->count()
- << ')';
- }
- return dbg.space();
- case QEvent::FocusIn:
- n = "FocusIn";
- break;
- case QEvent::FocusOut:
- n = "FocusOut";
- break;
- case QEvent::Enter:
- n = "Enter";
- break;
- case QEvent::Leave:
- n = "Leave";
- break;
- case QEvent::PaletteChange:
- n = "PaletteChange";
- break;
- case QEvent::PolishRequest:
- n = "PolishRequest";
- break;
- case QEvent::Polish:
- n = "Polish";
- break;
- case QEvent::UpdateRequest:
- n = "UpdateRequest";
- break;
- case QEvent::Paint:
- n = "Paint";
- break;
- case QEvent::Move:
- n = "Move";
- break;
- case QEvent::Resize:
- n = "Resize";
- break;
- case QEvent::Create:
- n = "Create";
- break;
- case QEvent::Destroy:
- n = "Destroy";
- break;
- case QEvent::Close:
- n = "Close";
- break;
- case QEvent::Quit:
- n = "Quit";
- break;
- case QEvent::FileOpen:
- n = "FileOpen";
- break;
- case QEvent::Show:
- n = "Show";
- break;
- case QEvent::ShowToParent:
- n = "ShowToParent";
- break;
- case QEvent::Hide:
- n = "Hide";
- break;
- case QEvent::HideToParent:
- n = "HideToParent";
- break;
- case QEvent::None:
- n = "None";
- break;
- case QEvent::ParentChange:
- n = "ParentChange";
- break;
- case QEvent::ParentAboutToChange:
- n = "ParentAboutToChange";
- break;
- case QEvent::HoverEnter:
- n = "HoverEnter";
- break;
- case QEvent::HoverMove:
- n = "HoverMove";
- break;
- case QEvent::HoverLeave:
- n = "HoverLeave";
- break;
- case QEvent::ZOrderChange:
- n = "ZOrderChange";
- break;
- case QEvent::StyleChange:
- n = "StyleChange";
- break;
- case QEvent::DragEnter:
- n = "DragEnter";
- break;
- case QEvent::DragMove:
- n = "DragMove";
- break;
- case QEvent::DragLeave:
- n = "DragLeave";
- break;
- case QEvent::Drop:
- n = "Drop";
- break;
- case QEvent::GraphicsSceneMouseMove:
- n = "GraphicsSceneMouseMove";
- break;
- case QEvent::GraphicsSceneMousePress:
- n = "GraphicsSceneMousePress";
- break;
- case QEvent::GraphicsSceneMouseRelease:
- n = "GraphicsSceneMouseRelease";
- break;
- case QEvent::GraphicsSceneMouseDoubleClick:
- n = "GraphicsSceneMouseDoubleClick";
- break;
- case QEvent::GraphicsSceneContextMenu:
- n = "GraphicsSceneContextMenu";
- break;
- case QEvent::GraphicsSceneHoverEnter:
- n = "GraphicsSceneHoverEnter";
- break;
- case QEvent::GraphicsSceneHoverMove:
- n = "GraphicsSceneHoverMove";
- break;
- case QEvent::GraphicsSceneHoverLeave:
- n = "GraphicsSceneHoverLeave";
- break;
- case QEvent::GraphicsSceneHelp:
- n = "GraphicsSceneHelp";
- break;
- case QEvent::GraphicsSceneDragEnter:
- n = "GraphicsSceneDragEnter";
- break;
- case QEvent::GraphicsSceneDragMove:
- n = "GraphicsSceneDragMove";
- break;
- case QEvent::GraphicsSceneDragLeave:
- n = "GraphicsSceneDragLeave";
- break;
- case QEvent::GraphicsSceneDrop:
- n = "GraphicsSceneDrop";
- break;
- case QEvent::GraphicsSceneWheel:
- n = "GraphicsSceneWheel";
- break;
- case QEvent::GraphicsSceneResize:
- n = "GraphicsSceneResize";
- break;
- case QEvent::GraphicsSceneMove:
- n = "GraphicsSceneMove";
- break;
- case QEvent::CursorChange:
- n = "CursorChange";
- break;
- case QEvent::ToolTipChange:
- n = "ToolTipChange";
- break;
- case QEvent::StatusTip:
- n = "StatusTip";
- break;
- case QEvent::WhatsThis:
- n = "WhatsThis";
- break;
- case QEvent::FontChange:
- n = "FontChange";
- break;
- case QEvent::Style:
- n = "Style";
- break;
- case QEvent::KeyboardLayoutChange:
- n = "KeyboardLayoutChange";
- break;
- case QEvent::DynamicPropertyChange:
- n = "DynamicPropertyChange";
- break;
- case QEvent::GrabMouse:
- n = "GrabMouse";
- break;
- case QEvent::UngrabMouse:
- n = "UngrabMouse";
- break;
- case QEvent::GrabKeyboard:
- n = "GrabKeyboard";
- break;
- case QEvent::UngrabKeyboard:
- n = "UngrabKeyboard";
- break;
-#ifdef QT3_SUPPORT
- case QEvent::ChildInsertedRequest:
- n = "ChildInsertedRequest";
- break;
- case QEvent::ChildInserted: n = "ChildInserted";
-#endif
- case QEvent::ChildAdded: n = n ? n : "ChildAdded";
- case QEvent::ChildPolished: n = n ? n : "ChildPolished";
- case QEvent::ChildRemoved: n = n ? n : "ChildRemoved";
- dbg.nospace() << "QChildEvent(" << n << ", " << (static_cast<const QChildEvent*>(e))->child();
- return dbg.space();
-#ifndef QT_NO_GESTURES
- case QEvent::Gesture:
- n = "Gesture";
- break;
-#endif
- default:
- dbg.nospace() << "QEvent(" << (const void *)e << ", type = " << e->type() << ')';
- return dbg.space();
- }
-
- dbg.nospace() << 'Q' << n << "Event(" << (const void *)e << ')';
- return dbg.space();
-#else
- qWarning("This compiler doesn't support streaming QEvent to QDebug");
- return dbg;
- Q_UNUSED(e);
-#endif
-}
-#endif
-
-#ifndef QT_NO_CLIPBOARD
-/*!
- \class QClipboardEvent
- \ingroup events
- \internal
-
- \brief The QClipboardEvent class provides the parameters used in a clipboard event.
-
- This class is for internal use only, and exists to aid the clipboard on various
- platforms to get all the information it needs. Use QEvent::Clipboard instead.
-
- \sa QClipboard
-*/
-
-QClipboardEvent::QClipboardEvent(QEventPrivate *data)
- : QEvent(QEvent::Clipboard)
-{
- d = data;
-}
-
-QClipboardEvent::~QClipboardEvent()
-{
-}
-#endif // QT_NO_CLIPBOARD
-
-/*!
- \class QShortcutEvent
- \brief The QShortcutEvent class provides an event which is generated when
- the user presses a key combination.
-
- \ingroup events
-
- Normally you don't need to use this class directly; QShortcut
- provides a higher-level interface to handle shortcut keys.
-
- \sa QShortcut
-*/
-
-/*!
- \fn const QKeySequence &QShortcutEvent::key() const
-
- Returns the key sequence that triggered the event.
-*/
-
-// ### Qt 5: remove
-/*!
- \fn const QKeySequence &QShortcutEvent::key()
-
- \internal
-*/
-
-/*!
- \fn int QShortcutEvent::shortcutId() const
-
- Returns the ID of the QShortcut object for which this event was
- generated.
-
- \sa QShortcut::id()
-*/
-
-// ### Qt 5: remove
-/*!
- \fn int QShortcutEvent::shortcutId()
- \overload
-
- \internal
-*/
-
-/*!
- \fn bool QShortcutEvent::isAmbiguous() const
-
- Returns true if the key sequence that triggered the event is
- ambiguous.
-
- \sa QShortcut::activatedAmbiguously()
-*/
-
-// ### Qt 5: remove
-/*!
- \fn bool QShortcutEvent::isAmbiguous()
-
- \internal
-*/
-
-/*!
- \class QWindowStateChangeEvent
- \ingroup events
-
- \brief The QWindowStateChangeEvent class provides the window state before a
- window state change.
-*/
-
-/*! \fn Qt::WindowStates QWindowStateChangeEvent::oldState() const
-
- Returns the state of the window before the change.
-*/
-
-/*! \internal
- */
-QWindowStateChangeEvent::QWindowStateChangeEvent(Qt::WindowStates s)
- : QEvent(WindowStateChange), ostate(s)
-{
-}
-
-/*! \internal
- */
-QWindowStateChangeEvent::QWindowStateChangeEvent(Qt::WindowStates s, bool isOverride)
- : QEvent(WindowStateChange), ostate(s)
-{
- if (isOverride)
- d = (QEventPrivate*)(this);
-}
-
-/*! \internal
- */
-bool QWindowStateChangeEvent::isOverride() const
-{
- return (d != 0);
-}
-
-/*! \internal
-*/
-QWindowStateChangeEvent::~QWindowStateChangeEvent()
-{
-}
-
-#ifdef QT3_SUPPORT
-
-/*!
- \class QMenubarUpdatedEvent
- \internal
- Event sent by QMenuBar to tell Q3Workspace to update itself.
-*/
-
-/*! \internal
-
-*/
-QMenubarUpdatedEvent::QMenubarUpdatedEvent(QMenuBar * const menuBar)
-:QEvent(QEvent::MenubarUpdated), m_menuBar(menuBar) {}
-
-/*!
- \fn QMenuBar *QMenubarUpdatedEvent::menuBar()
- \internal
-*/
-
-/*!
- \fn bool operator==(QKeyEvent *e, QKeySequence::StandardKey key)
-
- \relates QKeyEvent
-
- Returns true if \a key is currently bound to the key combination
- specified by \a e.
-
- Equivalent to \c {e->matches(key)}.
-*/
-
-/*!
- \fn bool operator==(QKeySequence::StandardKey key, QKeyEvent *e)
-
- \relates QKeyEvent
-
- Returns true if \a key is currently bound to the key combination
- specified by \a e.
-
- Equivalent to \c {e->matches(key)}.
-*/
-
-/*!
- \internal
-
- \class QKeyEventEx
- \ingroup events
-
- \brief The QKeyEventEx class provides more extended information about a keyevent.
-
- This class is for internal use only, and exists to aid the shortcut system on
- various platforms to get all the information it needs.
-*/
-
-#endif
-
-/*!
- \class QTouchEvent
- \brief The QTouchEvent class contains parameters that describe a touch event.
- \since 4.6
- \ingroup events
- \ingroup touch
-
- \section1 Enabling Touch Events
-
- Touch events occur when pressing, releasing, or moving one or more touch points on a touch
- device (such as a touch-screen or track-pad). To receive touch events, widgets have to have the
- Qt::WA_AcceptTouchEvents attribute set and graphics items need to have the
- \l{QGraphicsItem::setAcceptTouchEvents()}{acceptTouchEvents} attribute set to true.
-
- When using QAbstractScrollArea based widgets, you should enable the Qt::WA_AcceptTouchEvents
- attribute on the scroll area's \l{QAbstractScrollArea::viewport()}{viewport}.
-
- Similarly to QMouseEvent, Qt automatically grabs each touch point on the first press inside a
- widget, and the widget will receive all updates for the touch point until it is released.
- Note that it is possible for a widget to receive events for numerous touch points, and that
- multiple widgets may be receiving touch events at the same time.
-
- \section1 Event Handling
-
- All touch events are of type QEvent::TouchBegin, QEvent::TouchUpdate, or QEvent::TouchEnd.
- Reimplement QWidget::event() or QAbstractScrollArea::viewportEvent() for widgets and
- QGraphicsItem::sceneEvent() for items in a graphics view to receive touch events.
-
- The QEvent::TouchUpdate and QEvent::TouchEnd events are sent to the widget or item that
- accepted the QEvent::TouchBegin event. If the QEvent::TouchBegin event is not accepted and not
- filtered by an event filter, then no further touch events are sent until the next
- QEvent::TouchBegin.
-
- The touchPoints() function returns a list of all touch points contained in the event.
- Information about each touch point can be retrieved using the QTouchEvent::TouchPoint class.
- The Qt::TouchPointState enum describes the different states that a touch point may have.
-
- \section1 Event Delivery and Propagation
-
- By default, QWidget::event() translates the first non-primary touch point in a QTouchEvent into
- a QMouseEvent. This makes it possible to enable touch events on existing widgets that do not
- normally handle QTouchEvent. See below for information on some special considerations needed
- when doing this.
-
- QEvent::TouchBegin is the first touch event sent to a widget. The QEvent::TouchBegin event
- contains a special accept flag that indicates whether the receiver wants the event. By default,
- the event is accepted. You should call ignore() if the touch event is not handled by your
- widget. The QEvent::TouchBegin event is propagated up the parent widget chain until a widget
- accepts it with accept(), or an event filter consumes it. For QGraphicsItems, the
- QEvent::TouchBegin event is propagated to items under the mouse (similar to mouse event
- propagation for QGraphicsItems).
-
- \section1 Touch Point Grouping
-
- As mentioned above, it is possible that several widgets can be receiving QTouchEvents at the
- same time. However, Qt makes sure to never send duplicate QEvent::TouchBegin events to the same
- widget, which could theoretically happen during propagation if, for example, the user touched 2
- separate widgets in a QGroupBox and both widgets ignored the QEvent::TouchBegin event.
-
- To avoid this, Qt will group new touch points together using the following rules:
-
- \list
-
- \i When the first touch point is detected, the destination widget is determined firstly by the
- location on screen and secondly by the propagation rules.
-
- \i When additional touch points are detected, Qt first looks to see if there are any active
- touch points on any ancestor or descendent of the widget under the new touch point. If there
- are, the new touch point is grouped with the first, and the new touch point will be sent in a
- single QTouchEvent to the widget that handled the first touch point. (The widget under the new
- touch point will not receive an event).
-
- \endlist
-
- This makes it possible for sibling widgets to handle touch events independently while making
- sure that the sequence of QTouchEvents is always correct.
-
- \section1 Mouse Events and the Primary Touch Point
-
- QTouchEvent delivery is independent from that of QMouseEvent. On some windowing systems, mouse
- events are also sent for the \l{QTouchEvent::TouchPoint::isPrimary()}{primary touch point}.
- This means it is possible for your widget to receive both QTouchEvent and QMouseEvent for the
- same user interaction point. You can use the QTouchEvent::TouchPoint::isPrimary() function to
- identify the primary touch point.
-
- Note that on some systems, it is possible to receive touch events without a primary touch
- point. All this means is that there will be no mouse event generated for the touch points in
- the QTouchEvent.
-
- \section1 Caveats
-
- \list
-
- \i As mentioned above, enabling touch events means multiple widgets can be receiving touch
- events simultaneously. Combined with the default QWidget::event() handling for QTouchEvents,
- this gives you great flexibility in designing touch user interfaces. Be aware of the
- implications. For example, it is possible that the user is moving a QSlider with one finger and
- pressing a QPushButton with another. The signals emitted by these widgets will be
- interleaved.
-
- \i Recursion into the event loop using one of the exec() methods (e.g., QDialog::exec() or
- QMenu::exec()) in a QTouchEvent event handler is not supported. Since there are multiple event
- recipients, recursion may cause problems, including but not limited to lost events
- and unexpected infinite recursion.
-
- \i QTouchEvents are not affected by a \l{QWidget::grabMouse()}{mouse grab} or an
- \l{QApplication::activePopupWidget()}{active pop-up widget}. The behavior of QTouchEvents is
- undefined when opening a pop-up or grabbing the mouse while there are more than one active touch
- points.
-
- \endlist
-
- \sa QTouchEvent::TouchPoint, Qt::TouchPointState, Qt::WA_AcceptTouchEvents,
- QGraphicsItem::acceptTouchEvents()
-*/
-
-/*! \enum Qt::TouchPointState
- \since 4.6
-
- This enum represents the state of a touch point at the time the
- QTouchEvent occurred.
-
- \value TouchPointPressed The touch point is now pressed.
- \value TouchPointMoved The touch point moved.
- \value TouchPointStationary The touch point did not move.
- \value TouchPointReleased The touch point was released.
-
- \omitvalue TouchPointStateMask
- \omitvalue TouchPointPrimary
-*/
-
-/*! \enum QTouchEvent::DeviceType
-
- This enum represents the type of device that generated a QTouchEvent.
-
- \value TouchScreen In this type of device, the touch surface and display are integrated. This
- means the surface and display typically have the same size, such that there
- is a direct relationship between the touch points' physical positions and the
- coordinate reported by QTouchEvent::TouchPoint. As a result, Qt allows the
- user to interact directly with multiple QWidgets and QGraphicsItems at the
- same time.
-
- \value TouchPad In this type of device, the touch surface is separate from the display. There
- is not a direct relationship between the physical touch location and the
- on-screen coordinates. Instead, they are calculated relative to the current
- mouse position, and the user must use the touch-pad to move this reference
- point. Unlike touch-screens, Qt allows users to only interact with a single
- QWidget or QGraphicsItem at a time.
-*/
-
-/*!
- Constructs a QTouchEvent with the given \a eventType, \a deviceType, and \a touchPoints.
- The \a touchPointStates and \a modifiers are the current touch point states and keyboard
- modifiers at the time of the event.
-*/
-QTouchEvent::QTouchEvent(QEvent::Type eventType,
- QTouchEvent::DeviceType deviceType,
- Qt::KeyboardModifiers modifiers,
- Qt::TouchPointStates touchPointStates,
- const QList<QTouchEvent::TouchPoint> &touchPoints)
- : QInputEvent(eventType, modifiers),
- _widget(0),
- _deviceType(deviceType),
- _touchPointStates(touchPointStates),
- _touchPoints(touchPoints)
-{ }
-
-/*!
- Destroys the QTouchEvent.
-*/
-QTouchEvent::~QTouchEvent()
-{ }
-
-/*! \fn QWidget *QTouchEvent::widget() const
-
- Returns the widget on which the event occurred.
-*/
-
-
-/*! \fn Qt::TouchPointStates QTouchEvent::touchPointStates() const
-
- Returns a bitwise OR of all the touch point states for this event.
-*/
-
-/*! \fn const QList<QTouchEvent::TouchPoint> &QTouchEvent::touchPoints() const
-
- Returns the list of touch points contained in the touch event.
-*/
-
-/*! \fn QTouchEvent::DeviceType QTouchEvent::deviceType() const
-
- Returns the touch device Type, which is of type \l {QTouchEvent::DeviceType} {DeviceType}.
-*/
-
-/*! \fn void QTouchEvent::setWidget(QWidget *widget)
-
- \internal
-
- Sets the widget for this event.
-*/
-
-/*! \fn void QTouchEvent::setTouchPointStates(Qt::TouchPointStates touchPointStates)
-
- \internal
-
- Sets a bitwise OR of all the touch point states for this event.
-*/
-
-/*! \fn void QTouchEvent::setTouchPoints(const QList<QTouchEvent::TouchPoint> &touchPoints)
-
- \internal
-
- Sets the list of touch points for this event.
-*/
-
-/*! \fn void QTouchEvent::setDeviceType(DeviceType deviceType)
-
- \internal
-
- Sets the device type to \a deviceType, which is of type \l {QTouchEvent::DeviceType}
- {DeviceType}.
-*/
-
-/*! \class QTouchEvent::TouchPoint
- \brief The TouchPoint class provides information about a touch point in a QTouchEvent.
- \since 4.6
-*/
-
-/*! \internal
-
- Constructs a QTouchEvent::TouchPoint for use in a QTouchEvent.
-*/
-QTouchEvent::TouchPoint::TouchPoint(int id)
- : d(new QTouchEventTouchPointPrivate(id))
-{ }
-
-/*! \internal
-
- Constructs a copy of \a other.
-*/
-QTouchEvent::TouchPoint::TouchPoint(const QTouchEvent::TouchPoint &other)
- : d(other.d)
-{
- d->ref.ref();
-}
-
-/*! \internal
-
- Destroys the QTouchEvent::TouchPoint.
-*/
-QTouchEvent::TouchPoint::~TouchPoint()
-{
- if (!d->ref.deref())
- delete d;
-}
-
-/*!
- Returns the id number of this touch point.
-
- Id numbers are globally sequential, starting at zero, meaning the
- first touch point in the application has id 0, the second has id 1,
- and so on.
-*/
-int QTouchEvent::TouchPoint::id() const
-{
- return d->id;
-}
-
-/*!
- Returns the current state of this touch point.
-*/
-Qt::TouchPointState QTouchEvent::TouchPoint::state() const
-{
- return Qt::TouchPointState(int(d->state) & Qt::TouchPointStateMask);
-}
-
-/*!
- Returns true if this touch point is the primary touch point. The primary touch point is the
- point for which the windowing system generates mouse events.
-*/
-bool QTouchEvent::TouchPoint::isPrimary() const
-{
- return (d->state & Qt::TouchPointPrimary) != 0;
-}
-
-/*!
- Returns the position of this touch point, relative to the widget
- or QGraphicsItem that received the event.
-
- \sa startPos(), lastPos(), screenPos(), scenePos(), normalizedPos()
-*/
-QPointF QTouchEvent::TouchPoint::pos() const
-{
- return d->rect.center();
-}
-
-/*!
- Returns the scene position of this touch point.
-
- The scene position is the position in QGraphicsScene coordinates
- if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
- reimplementation, and identical to the screen position for
- widgets.
-
- \sa startScenePos(), lastScenePos(), pos()
-*/
-QPointF QTouchEvent::TouchPoint::scenePos() const
-{
- return d->sceneRect.center();
-}
-
-/*!
- Returns the screen position of this touch point.
-
- \sa startScreenPos(), lastScreenPos(), pos()
-*/
-QPointF QTouchEvent::TouchPoint::screenPos() const
-{
- return d->screenRect.center();
-}
-
-/*!
- Returns the normalized position of this touch point.
-
- The coordinates are normalized to the size of the touch device,
- i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
-
- \sa startNormalizedPos(), lastNormalizedPos(), pos()
-*/
-QPointF QTouchEvent::TouchPoint::normalizedPos() const
-{
- return d->normalizedPos;
-}
-
-/*!
- Returns the starting position of this touch point, relative to the
- widget or QGraphicsItem that received the event.
-
- \sa pos(), lastPos()
-*/
-QPointF QTouchEvent::TouchPoint::startPos() const
-{
- return d->startPos;
-}
-
-/*!
- Returns the starting scene position of this touch point.
-
- The scene position is the position in QGraphicsScene coordinates
- if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
- reimplementation, and identical to the screen position for
- widgets.
-
- \sa scenePos(), lastScenePos()
-*/
-QPointF QTouchEvent::TouchPoint::startScenePos() const
-{
- return d->startScenePos;
-}
-
-/*!
- Returns the starting screen position of this touch point.
-
- \sa screenPos(), lastScreenPos()
-*/
-QPointF QTouchEvent::TouchPoint::startScreenPos() const
-{
- return d->startScreenPos;
-}
-
-/*!
- Returns the normalized starting position of this touch point.
-
- The coordinates are normalized to the size of the touch device,
- i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
-
- \sa normalizedPos(), lastNormalizedPos()
-*/
-QPointF QTouchEvent::TouchPoint::startNormalizedPos() const
-{
- return d->startNormalizedPos;
-}
-
-/*!
- Returns the position of this touch point from the previous touch
- event, relative to the widget or QGraphicsItem that received the event.
-
- \sa pos(), startPos()
-*/
-QPointF QTouchEvent::TouchPoint::lastPos() const
-{
- return d->lastPos;
-}
-
-/*!
- Returns the scene position of this touch point from the previous
- touch event.
-
- The scene position is the position in QGraphicsScene coordinates
- if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
- reimplementation, and identical to the screen position for
- widgets.
-
- \sa scenePos(), startScenePos()
-*/
-QPointF QTouchEvent::TouchPoint::lastScenePos() const
-{
- return d->lastScenePos;
-}
-
-/*!
- Returns the screen position of this touch point from the previous
- touch event.
-
- \sa screenPos(), startScreenPos()
-*/
-QPointF QTouchEvent::TouchPoint::lastScreenPos() const
-{
- return d->lastScreenPos;
-}
-
-/*!
- Returns the normalized position of this touch point from the
- previous touch event.
-
- The coordinates are normalized to the size of the touch device,
- i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
-
- \sa normalizedPos(), startNormalizedPos()
-*/
-QPointF QTouchEvent::TouchPoint::lastNormalizedPos() const
-{
- return d->lastNormalizedPos;
-}
-
-/*!
- Returns the rect for this touch point, relative to the widget
- or QGraphicsItem that received the event. The rect is centered
- around the point returned by pos().
-
- \note This function returns an empty rect if the device does not report touch point sizes.
-*/
-QRectF QTouchEvent::TouchPoint::rect() const
-{
- return d->rect;
-}
-
-/*!
- Returns the rect for this touch point in scene coordinates.
-
- \note This function returns an empty rect if the device does not report touch point sizes.
-
- \sa scenePos(), rect()
-*/
-QRectF QTouchEvent::TouchPoint::sceneRect() const
-{
- return d->sceneRect;
-}
-
-/*!
- Returns the rect for this touch point in screen coordinates.
-
- \note This function returns an empty rect if the device does not report touch point sizes.
-
- \sa screenPos(), rect()
-*/
-QRectF QTouchEvent::TouchPoint::screenRect() const
-{
- return d->screenRect;
-}
-
-/*!
- Returns the pressure of this touch point. The return value is in
- the range 0.0 to 1.0.
-*/
-qreal QTouchEvent::TouchPoint::pressure() const
-{
- return d->pressure;
-}
-
-/*! \internal */
-void QTouchEvent::TouchPoint::setId(int id)
-{
- if (d->ref != 1)
- d = d->detach();
- d->id = id;
-}
-
-/*! \internal */
-void QTouchEvent::TouchPoint::setState(Qt::TouchPointStates state)
-{
- if (d->ref != 1)
- d = d->detach();
- d->state = state;
-}
-
-/*! \internal */
-void QTouchEvent::TouchPoint::setPos(const QPointF &pos)
-{
- if (d->ref != 1)
- d = d->detach();
- d->rect.moveCenter(pos);
-}
-
-/*! \internal */
-void QTouchEvent::TouchPoint::setScenePos(const QPointF &scenePos)
-{
- if (d->ref != 1)
- d = d->detach();
- d->sceneRect.moveCenter(scenePos);
-}
-
-/*! \internal */
-void QTouchEvent::TouchPoint::setScreenPos(const QPointF &screenPos)
-{
- if (d->ref != 1)
- d = d->detach();
- d->screenRect.moveCenter(screenPos);
-}
-
-/*! \internal */
-void QTouchEvent::TouchPoint::setNormalizedPos(const QPointF &normalizedPos)
-{
- if (d->ref != 1)
- d = d->detach();
- d->normalizedPos = normalizedPos;
-}
-
-/*! \internal */
-void QTouchEvent::TouchPoint::setStartPos(const QPointF &startPos)
-{
- if (d->ref != 1)
- d = d->detach();
- d->startPos = startPos;
-}
-
-/*! \internal */
-void QTouchEvent::TouchPoint::setStartScenePos(const QPointF &startScenePos)
-{
- if (d->ref != 1)
- d = d->detach();
- d->startScenePos = startScenePos;
-}
-
-/*! \internal */
-void QTouchEvent::TouchPoint::setStartScreenPos(const QPointF &startScreenPos)
-{
- if (d->ref != 1)
- d = d->detach();
- d->startScreenPos = startScreenPos;
-}
-
-/*! \internal */
-void QTouchEvent::TouchPoint::setStartNormalizedPos(const QPointF &startNormalizedPos)
-{
- if (d->ref != 1)
- d = d->detach();
- d->startNormalizedPos = startNormalizedPos;
-}
-
-/*! \internal */
-void QTouchEvent::TouchPoint::setLastPos(const QPointF &lastPos)
-{
- if (d->ref != 1)
- d = d->detach();
- d->lastPos = lastPos;
-}
-
-/*! \internal */
-void QTouchEvent::TouchPoint::setLastScenePos(const QPointF &lastScenePos)
-{
- if (d->ref != 1)
- d = d->detach();
- d->lastScenePos = lastScenePos;
-}
-
-/*! \internal */
-void QTouchEvent::TouchPoint::setLastScreenPos(const QPointF &lastScreenPos)
-{
- if (d->ref != 1)
- d = d->detach();
- d->lastScreenPos = lastScreenPos;
-}
-
-/*! \internal */
-void QTouchEvent::TouchPoint::setLastNormalizedPos(const QPointF &lastNormalizedPos)
-{
- if (d->ref != 1)
- d = d->detach();
- d->lastNormalizedPos = lastNormalizedPos;
-}
-
-/*! \internal */
-void QTouchEvent::TouchPoint::setRect(const QRectF &rect)
-{
- if (d->ref != 1)
- d = d->detach();
- d->rect = rect;
-}
-
-/*! \internal */
-void QTouchEvent::TouchPoint::setSceneRect(const QRectF &sceneRect)
-{
- if (d->ref != 1)
- d = d->detach();
- d->sceneRect = sceneRect;
-}
-
-/*! \internal */
-void QTouchEvent::TouchPoint::setScreenRect(const QRectF &screenRect)
-{
- if (d->ref != 1)
- d = d->detach();
- d->screenRect = screenRect;
-}
-
-/*! \internal */
-void QTouchEvent::TouchPoint::setPressure(qreal pressure)
-{
- if (d->ref != 1)
- d = d->detach();
- d->pressure = pressure;
-}
-
-/*! \internal */
-QTouchEvent::TouchPoint &QTouchEvent::TouchPoint::operator=(const QTouchEvent::TouchPoint &other)
-{
- other.d->ref.ref();
- if (!d->ref.deref())
- delete d;
- d = other.d;
- return *this;
-}
-
-#ifndef QT_NO_GESTURES
-/*!
- \class QGestureEvent
- \since 4.6
- \ingroup events
- \ingroup gestures
-
- \brief The QGestureEvent class provides the description of triggered gestures.
-
- The QGestureEvent class contains a list of gestures, which can be obtained using the
- gestures() function.
-
- The gestures are either active or canceled. A list of those that are currently being
- executed can be obtained using the activeGestures() function. A list of those which
- were previously active and have been canceled can be accessed using the
- canceledGestures() function. A gesture might be canceled if the current window loses
- focus, for example, or because of a timeout, or for other reasons.
-
- If the event handler does not accept the event by calling the generic
- QEvent::accept() function, all individual QGesture object that were not
- accepted and in the Qt::GestureStarted state will be propagated up the
- parent widget chain until a widget accepts them individually, by calling
- QGestureEvent::accept() for each of them, or an event filter consumes the
- event.
-
- \section1 Further Reading
-
- For an overview of gesture handling in Qt and information on using gestures
- in your applications, see the \l{Gestures Programming} document.
-
- \sa QGesture, QGestureRecognizer,
- QWidget::grabGesture(), QGraphicsObject::grabGesture()
-*/
-
-/*!
- Creates new QGestureEvent containing a list of \a gestures.
-*/
-QGestureEvent::QGestureEvent(const QList<QGesture *> &gestures)
- : QEvent(QEvent::Gesture)
-{
- d = reinterpret_cast<QEventPrivate *>(new QGestureEventPrivate(gestures));
-}
-
-/*!
- Destroys QGestureEvent.
-*/
-QGestureEvent::~QGestureEvent()
-{
- delete reinterpret_cast<QGestureEventPrivate *>(d);
-}
-
-/*!
- Returns all gestures that are delivered in the event.
-*/
-QList<QGesture *> QGestureEvent::gestures() const
-{
- return d_func()->gestures;
-}
-
-/*!
- Returns a gesture object by \a type.
-*/
-QGesture *QGestureEvent::gesture(Qt::GestureType type) const
-{
- const QGestureEventPrivate *d = d_func();
- for(int i = 0; i < d->gestures.size(); ++i)
- if (d->gestures.at(i)->gestureType() == type)
- return d->gestures.at(i);
- return 0;
-}
-
-/*!
- Returns a list of active (not canceled) gestures.
-*/
-QList<QGesture *> QGestureEvent::activeGestures() const
-{
- QList<QGesture *> gestures;
- foreach (QGesture *gesture, d_func()->gestures) {
- if (gesture->state() != Qt::GestureCanceled)
- gestures.append(gesture);
- }
- return gestures;
-}
-
-/*!
- Returns a list of canceled gestures.
-*/
-QList<QGesture *> QGestureEvent::canceledGestures() const
-{
- QList<QGesture *> gestures;
- foreach (QGesture *gesture, d_func()->gestures) {
- if (gesture->state() == Qt::GestureCanceled)
- gestures.append(gesture);
- }
- return gestures;
-}
-
-/*!
- Sets the accept flag of the given \a gesture object to the specified \a value.
-
- Setting the accept flag indicates that the event receiver wants the \a gesture.
- Unwanted gestures may be propagated to the parent widget.
-
- By default, gestures in events of type QEvent::Gesture are accepted, and
- gestures in QEvent::GestureOverride events are ignored.
-
- For convenience, the accept flag can also be set with
- \l{QGestureEvent::accept()}{accept(gesture)}, and cleared with
- \l{QGestureEvent::ignore()}{ignore(gesture)}.
-*/
-void QGestureEvent::setAccepted(QGesture *gesture, bool value)
-{
- if (gesture)
- setAccepted(gesture->gestureType(), value);
-}
-
-/*!
- Sets the accept flag of the given \a gesture object, the equivalent of calling
- \l{QGestureEvent::setAccepted()}{setAccepted(gesture, true)}.
-
- Setting the accept flag indicates that the event receiver wants the
- gesture. Unwanted gestures may be propagated to the parent widget.
-
- \sa QGestureEvent::ignore()
-*/
-void QGestureEvent::accept(QGesture *gesture)
-{
- if (gesture)
- setAccepted(gesture->gestureType(), true);
-}
-
-/*!
- Clears the accept flag parameter of the given \a gesture object, the equivalent
- of calling \l{QGestureEvent::setAccepted()}{setAccepted(gesture, false)}.
-
- Clearing the accept flag indicates that the event receiver does not
- want the gesture. Unwanted gestures may be propagated to the parent widget.
-
- \sa QGestureEvent::accept()
-*/
-void QGestureEvent::ignore(QGesture *gesture)
-{
- if (gesture)
- setAccepted(gesture->gestureType(), false);
-}
-
-/*!
- Returns true if the \a gesture is accepted; otherwise returns false.
-*/
-bool QGestureEvent::isAccepted(QGesture *gesture) const
-{
- return gesture ? isAccepted(gesture->gestureType()) : false;
-}
-
-/*!
- Sets the accept flag of the given \a gestureType object to the specified
- \a value.
-
- Setting the accept flag indicates that the event receiver wants to receive
- gestures of the specified type, \a gestureType. Unwanted gestures may be
- propagated to the parent widget.
-
- By default, gestures in events of type QEvent::Gesture are accepted, and
- gestures in QEvent::GestureOverride events are ignored.
-
- For convenience, the accept flag can also be set with
- \l{QGestureEvent::accept()}{accept(gestureType)}, and cleared with
- \l{QGestureEvent::ignore()}{ignore(gestureType)}.
-*/
-void QGestureEvent::setAccepted(Qt::GestureType gestureType, bool value)
-{
- setAccepted(false);
- d_func()->accepted[gestureType] = value;
-}
-
-/*!
- Sets the accept flag of the given \a gestureType, the equivalent of calling
- \l{QGestureEvent::setAccepted()}{setAccepted(gestureType, true)}.
-
- Setting the accept flag indicates that the event receiver wants the
- gesture. Unwanted gestures may be propagated to the parent widget.
-
- \sa QGestureEvent::ignore()
-*/
-void QGestureEvent::accept(Qt::GestureType gestureType)
-{
- setAccepted(gestureType, true);
-}
-
-/*!
- Clears the accept flag parameter of the given \a gestureType, the equivalent
- of calling \l{QGestureEvent::setAccepted()}{setAccepted(gesture, false)}.
-
- Clearing the accept flag indicates that the event receiver does not
- want the gesture. Unwanted gestures may be propgated to the parent widget.
-
- \sa QGestureEvent::accept()
-*/
-void QGestureEvent::ignore(Qt::GestureType gestureType)
-{
- setAccepted(gestureType, false);
-}
-
-/*!
- Returns true if the gesture of type \a gestureType is accepted; otherwise
- returns false.
-*/
-bool QGestureEvent::isAccepted(Qt::GestureType gestureType) const
-{
- return d_func()->accepted.value(gestureType, true);
-}
-
-/*!
- \internal
-
- Sets the widget for this event to the \a widget specified.
-*/
-void QGestureEvent::setWidget(QWidget *widget)
-{
- d_func()->widget = widget;
-}
-
-/*!
- Returns the widget on which the event occurred.
-*/
-QWidget *QGestureEvent::widget() const
-{
- return d_func()->widget;
-}
-
-#ifndef QT_NO_GRAPHICSVIEW
-/*!
- Returns the scene-local coordinates if the \a gesturePoint is inside a
- graphics view.
-
- This functional might be useful when the gesture event is delivered to a
- QGraphicsObject to translate a point in screen coordinates to scene-local
- coordinates.
-
- \sa QPointF::isNull().
-*/
-QPointF QGestureEvent::mapToGraphicsScene(const QPointF &gesturePoint) const
-{
- QWidget *w = widget();
- if (w) // we get the viewport as widget, not the graphics view
- w = w->parentWidget();
- QGraphicsView *view = qobject_cast<QGraphicsView*>(w);
- if (view) {
- return view->mapToScene(view->mapFromGlobal(gesturePoint.toPoint()));
- }
- return QPointF();
-}
-#endif //QT_NO_GRAPHICSVIEW
-
-/*!
- \internal
-*/
-QGestureEventPrivate *QGestureEvent::d_func()
-{
- return reinterpret_cast<QGestureEventPrivate *>(d);
-}
-
-/*!
- \internal
-*/
-const QGestureEventPrivate *QGestureEvent::d_func() const
-{
- return reinterpret_cast<const QGestureEventPrivate *>(d);
-}
-
-#ifdef Q_NO_USING_KEYWORD
-/*!
- \fn void QGestureEvent::setAccepted(bool accepted)
-
- Sets or clears the event's internal flag that determines whether it should
- be delivered to other objects.
-
- Calling this function with a value of true for \a accepted indicates that the
- caller has accepted the event and that it should not be propagated further.
- Calling this function with a value of false indicates that the caller has
- ignored the event and that it should be delivered to other objects.
-
- For convenience, the accept flag can also be set with accept(), and cleared
- with ignore().
-
- \sa QEvent::accepted
-*/
-/*!
- \fn bool QGestureEvent::isAccepted() const
-
- Returns true is the event has been accepted; otherwise returns false.
-
- \sa QEvent::accepted
-*/
-/*!
- \fn void QGestureEvent::accept()
-
- Accepts the event, the equivalent of calling setAccepted(true).
-
- \sa QEvent::accept()
-*/
-/*!
- \fn void QGestureEvent::ignore()
-
- Ignores the event, the equivalent of calling setAccepted(false).
-
- \sa QEvent::ignore()
-*/
-#endif
-
-#endif // QT_NO_GESTURES
-
-/*!
- \class QScrollPrepareEvent
- \since 4.8
- \ingroup events
-
- \brief The QScrollPrepareEvent class is send in preparation of a scrolling.
-
- The scroll prepare event is send before scrolling (usually by QScroller) is started.
- The object receiving this event should set viewportSize, maxContentPos and contentPos.
- It also should accept this event to indicate that scrolling should be started.
-
- It is not guaranteed that a QScrollEvent will be send after an acceepted
- QScrollPrepareEvent, e.g. in a case where the maximum content position is (0,0).
-
- \sa QScrollEvent, QScroller
-*/
-
-/*!
- Creates new QScrollPrepareEvent
- The \a startPos is the position of a touch or mouse event that started the scrolling.
-*/
-QScrollPrepareEvent::QScrollPrepareEvent(const QPointF &startPos)
- : QEvent(QEvent::ScrollPrepare)
-{
- d = reinterpret_cast<QEventPrivate *>(new QScrollPrepareEventPrivate());
- d_func()->startPos = startPos;
-}
-
-/*!
- Destroys QScrollEvent.
-*/
-QScrollPrepareEvent::~QScrollPrepareEvent()
-{
- delete reinterpret_cast<QScrollPrepareEventPrivate *>(d);
-}
-
-/*!
- Returns the position of the touch or mouse event that started the scrolling.
-*/
-QPointF QScrollPrepareEvent::startPos() const
-{
- return d_func()->startPos;
-}
-
-/*!
- Returns size of the area that is to be scrolled as set by setViewportSize
-
- \sa setViewportSize()
-*/
-QSizeF QScrollPrepareEvent::viewportSize() const
-{
- return d_func()->viewportSize;
-}
-
-/*!
- Returns the range of coordinates for the content as set by setContentPosRange().
-*/
-QRectF QScrollPrepareEvent::contentPosRange() const
-{
- return d_func()->contentPosRange;
-}
-
-/*!
- Returns the current position of the content as set by setContentPos.
-*/
-QPointF QScrollPrepareEvent::contentPos() const
-{
- return d_func()->contentPos;
-}
-
-
-/*!
- Sets the size of the area that is to be scrolled to \a size.
-
- \sa viewportSize()
-*/
-void QScrollPrepareEvent::setViewportSize(const QSizeF &size)
-{
- d_func()->viewportSize = size;
-}
-
-/*!
- Sets the range of content coordinates to \a rect.
-
- \sa contentPosRange()
-*/
-void QScrollPrepareEvent::setContentPosRange(const QRectF &rect)
-{
- d_func()->contentPosRange = rect;
-}
-
-/*!
- Sets the current content position to \a pos.
-
- \sa contentPos()
-*/
-void QScrollPrepareEvent::setContentPos(const QPointF &pos)
-{
- d_func()->contentPos = pos;
-}
-
-
-/*!
- \internal
-*/
-QScrollPrepareEventPrivate *QScrollPrepareEvent::d_func()
-{
- return reinterpret_cast<QScrollPrepareEventPrivate *>(d);
-}
-
-/*!
- \internal
-*/
-const QScrollPrepareEventPrivate *QScrollPrepareEvent::d_func() const
-{
- return reinterpret_cast<const QScrollPrepareEventPrivate *>(d);
-}
-
-/*!
- \class QScrollEvent
- \since 4.8
- \ingroup events
-
- \brief The QScrollEvent class is send when scrolling.
-
- The scroll event is send to indicate that the receiver should be scrolled.
- Usually the receiver should be something visual like QWidget or QGraphicsObject.
-
- Some care should be taken that no conflicting QScrollEvents are sent from two
- sources. Using QScroller::scrollTo is save however.
-
- \sa QScrollPrepareEvent, QScroller
-*/
-
-/*!
- \enum QScrollEvent::ScrollState
-
- This enum describes the states a scroll event can have.
-
- \value ScrollStarted Set for the first scroll event of a scroll activity.
-
- \value ScrollUpdated Set for all but the first and the last scroll event of a scroll activity.
-
- \value ScrollFinished Set for the last scroll event of a scroll activity.
-
- \sa QScrollEvent::scrollState()
-*/
-
-/*!
- Creates a new QScrollEvent
- \a contentPos is the new content position, \a overshootDistance is the
- new overshoot distance while \a scrollState indicates if this scroll
- event is the first one, the last one or some event in between.
-*/
-QScrollEvent::QScrollEvent(const QPointF &contentPos, const QPointF &overshootDistance, ScrollState scrollState)
- : QEvent(QEvent::Scroll)
-{
- d = reinterpret_cast<QEventPrivate *>(new QScrollEventPrivate());
- d_func()->contentPos = contentPos;
- d_func()->overshoot= overshootDistance;
- d_func()->state = scrollState;
-}
-
-/*!
- Destroys QScrollEvent.
-*/
-QScrollEvent::~QScrollEvent()
-{
- delete reinterpret_cast<QScrollEventPrivate *>(d);
-}
-
-/*!
- Returns the new scroll position.
-*/
-QPointF QScrollEvent::contentPos() const
-{
- return d_func()->contentPos;
-}
-
-/*!
- Returns the new overshoot distance.
- See QScroller for an explanation of the term overshoot.
-
- \sa QScroller
-*/
-QPointF QScrollEvent::overshootDistance() const
-{
- return d_func()->overshoot;
-}
-
-/*!
- Returns the current scroll state as a combination of ScrollStateFlag values.
- ScrollStarted (or ScrollFinished) will be set, if this scroll event is the first (or last) event in a scrolling activity.
- Please note that both values can be set at the same time, if the activity consists of a single QScrollEvent.
- All other scroll events in between will have their state set to ScrollUpdated.
-
- A widget could for example revert selections when scrolling is started and stopped.
-*/
-QScrollEvent::ScrollState QScrollEvent::scrollState() const
-{
- return d_func()->state;
-}
-
-/*!
- \internal
-*/
-QScrollEventPrivate *QScrollEvent::d_func()
-{
- return reinterpret_cast<QScrollEventPrivate *>(d);
-}
-
-/*!
- \internal
-*/
-const QScrollEventPrivate *QScrollEvent::d_func() const
-{
- return reinterpret_cast<const QScrollEventPrivate *>(d);
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
deleted file mode 100644
index 93c2bc53b6..0000000000
--- a/src/gui/kernel/qevent.h
+++ /dev/null
@@ -1,942 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QEVENT_H
-#define QEVENT_H
-
-#include <QtGui/qwindowdefs.h>
-#include <QtCore/qobject.h>
-#include <QtGui/qregion.h>
-#include <QtCore/qnamespace.h>
-#include <QtCore/qstring.h>
-#include <QtGui/qkeysequence.h>
-#include <QtCore/qcoreevent.h>
-#include <QtGui/qmime.h>
-#include <QtGui/qdrag.h>
-#include <QtCore/qvariant.h>
-#include <QtCore/qmap.h>
-#include <QtCore/qset.h>
-#include <QtCore/qfile.h>
-
-#ifdef Q_OS_SYMBIAN
-class RFile;
-#endif
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QAction;
-#ifndef QT_NO_GESTURES
-class QGesture;
-#endif
-
-class Q_GUI_EXPORT QInputEvent : public QEvent
-{
-public:
- QInputEvent(Type type, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
- ~QInputEvent();
- inline Qt::KeyboardModifiers modifiers() const { return modState; }
- inline void setModifiers(Qt::KeyboardModifiers amodifiers) { modState = amodifiers; }
-protected:
- Qt::KeyboardModifiers modState;
-};
-
-class Q_GUI_EXPORT QMouseEvent : public QInputEvent
-{
-public:
- QMouseEvent(Type type, const QPoint &pos, Qt::MouseButton button,
- Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
- QMouseEvent(Type type, const QPoint &pos, const QPoint &globalPos,
- Qt::MouseButton button, Qt::MouseButtons buttons,
- Qt::KeyboardModifiers modifiers);
- ~QMouseEvent();
-
- inline const QPoint &pos() const { return p; }
- inline const QPoint &globalPos() const { return g; }
- inline int x() const { return p.x(); }
- inline int y() const { return p.y(); }
- inline int globalX() const { return g.x(); }
- inline int globalY() const { return g.y(); }
- inline Qt::MouseButton button() const { return b; }
- inline Qt::MouseButtons buttons() const { return mouseState; }
-
- static QMouseEvent *createExtendedMouseEvent(Type type, const QPointF &pos,
- const QPoint &globalPos, Qt::MouseButton button,
- Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
- inline bool hasExtendedInfo() const { return reinterpret_cast<const QMouseEvent *>(d) == this; }
- QPointF posF() const;
-
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QMouseEvent(Type type, const QPoint &pos, Qt::ButtonState button, int state);
- QT3_SUPPORT_CONSTRUCTOR QMouseEvent(Type type, const QPoint &pos, const QPoint &globalPos,
- Qt::ButtonState button, int state);
- inline QT3_SUPPORT Qt::ButtonState state() const
- { return Qt::ButtonState((mouseState^b)|int(modifiers())); }
- inline QT3_SUPPORT Qt::ButtonState stateAfter() const
- { return Qt::ButtonState(int(mouseState)|int(modifiers())); }
-#endif
-protected:
- QPoint p, g;
- Qt::MouseButton b;
- Qt::MouseButtons mouseState;
-};
-
-class Q_GUI_EXPORT QHoverEvent : public QEvent
-{
-public:
- QHoverEvent(Type type, const QPoint &pos, const QPoint &oldPos);
- ~QHoverEvent();
-
- inline const QPoint &pos() const { return p; }
- inline const QPoint &oldPos() const { return op; }
-
-protected:
- QPoint p, op;
-};
-
-#ifndef QT_NO_WHEELEVENT
-class Q_GUI_EXPORT QWheelEvent : public QInputEvent
-{
-public:
- QWheelEvent(const QPoint &pos, int delta,
- Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
- Qt::Orientation orient = Qt::Vertical);
- QWheelEvent(const QPoint &pos, const QPoint& globalPos, int delta,
- Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
- Qt::Orientation orient = Qt::Vertical);
- ~QWheelEvent();
-
- inline int delta() const { return d; }
- inline const QPoint &pos() const { return p; }
- inline const QPoint &globalPos() const { return g; }
- inline int x() const { return p.x(); }
- inline int y() const { return p.y(); }
- inline int globalX() const { return g.x(); }
- inline int globalY() const { return g.y(); }
-
- inline Qt::MouseButtons buttons() const { return mouseState; }
- Qt::Orientation orientation() const { return o; }
-
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QWheelEvent(const QPoint &pos, int delta, int state,
- Qt::Orientation orient = Qt::Vertical);
- QT3_SUPPORT_CONSTRUCTOR QWheelEvent(const QPoint &pos, const QPoint& globalPos, int delta, int state,
- Qt::Orientation orient = Qt::Vertical);
- inline QT3_SUPPORT Qt::ButtonState state() const
- { return static_cast<Qt::ButtonState>(int(buttons())|int(modifiers())); }
-#endif
-protected:
- QPoint p;
- QPoint g;
- int d;
- Qt::MouseButtons mouseState;
- Qt::Orientation o;
-};
-#endif
-
-#ifndef QT_NO_TABLETEVENT
-class Q_GUI_EXPORT QTabletEvent : public QInputEvent
-{
-public:
- enum TabletDevice { NoDevice, Puck, Stylus, Airbrush, FourDMouse,
- XFreeEraser /*internal*/, RotationStylus };
- enum PointerType { UnknownPointer, Pen, Cursor, Eraser };
- QTabletEvent(Type t, const QPoint &pos, const QPoint &globalPos, const QPointF &hiResGlobalPos,
- int device, int pointerType, qreal pressure, int xTilt, int yTilt,
- qreal tangentialPressure, qreal rotation, int z,
- Qt::KeyboardModifiers keyState, qint64 uniqueID);
- ~QTabletEvent();
-
- inline const QPoint &pos() const { return mPos; }
- inline const QPoint &globalPos() const { return mGPos; }
- inline const QPointF &hiResGlobalPos() const { return mHiResGlobalPos; }
- inline int x() const { return mPos.x(); }
- inline int y() const { return mPos.y(); }
- inline int globalX() const { return mGPos.x(); }
- inline int globalY() const { return mGPos.y(); }
- inline qreal hiResGlobalX() const { return mHiResGlobalPos.x(); }
- inline qreal hiResGlobalY() const { return mHiResGlobalPos.y(); }
- inline TabletDevice device() const { return TabletDevice(mDev); }
- inline PointerType pointerType() const { return PointerType(mPointerType); }
- inline qint64 uniqueId() const { return mUnique; }
- inline qreal pressure() const { return mPress; }
- inline int z() const { return mZ; }
- inline qreal tangentialPressure() const { return mTangential; }
- inline qreal rotation() const { return mRot; }
- inline int xTilt() const { return mXT; }
- inline int yTilt() const { return mYT; }
-
-protected:
- QPoint mPos, mGPos;
- QPointF mHiResGlobalPos;
- int mDev, mPointerType, mXT, mYT, mZ;
- qreal mPress, mTangential, mRot;
- qint64 mUnique;
-
- // I don't know what the future holds for tablets but there could be some
- // new devices coming along, and there seem to be "holes" in the
- // OS-specific events for this.
- void *mExtra;
-};
-#endif // QT_NO_TABLETEVENT
-
-class Q_GUI_EXPORT QKeyEvent : public QInputEvent
-{
-public:
- QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text = QString(),
- bool autorep = false, ushort count = 1);
- ~QKeyEvent();
-
- int key() const { return k; }
-#ifndef QT_NO_SHORTCUT
- bool matches(QKeySequence::StandardKey key) const;
-#endif
- Qt::KeyboardModifiers modifiers() const;
- inline QString text() const { return txt; }
- inline bool isAutoRepeat() const { return autor; }
- inline int count() const { return int(c); }
-
- // Functions for the extended key event information
- static QKeyEvent *createExtendedKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers,
- quint32 nativeScanCode, quint32 nativeVirtualKey,
- quint32 nativeModifiers,
- const QString& text = QString(), bool autorep = false,
- ushort count = 1);
- inline bool hasExtendedInfo() const { return reinterpret_cast<const QKeyEvent*>(d) == this; }
- quint32 nativeScanCode() const;
- quint32 nativeVirtualKey() const;
- quint32 nativeModifiers() const;
-
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT_CONSTRUCTOR QKeyEvent(Type type, int key, int /*ascii*/,
- int modifiers, const QString& text = QString(),
- bool autorep = false, ushort count = 1)
- : QInputEvent(type, Qt::KeyboardModifiers(modifiers & (int)Qt::KeyButtonMask)), txt(text), k(key),
- c(count), autor(autorep)
- {
- if (key >= Qt::Key_Back && key <= Qt::Key_MediaLast)
- ignore();
- }
- inline QT3_SUPPORT int ascii() const
- { return (txt.length() ? txt.unicode()->toLatin1() : 0); }
- inline QT3_SUPPORT Qt::ButtonState state() const { return Qt::ButtonState(QInputEvent::modifiers()); }
- inline QT3_SUPPORT Qt::ButtonState stateAfter() const { return Qt::ButtonState(modifiers()); }
-#endif
-
-protected:
- QString txt;
- int k;
- ushort c;
- uint autor:1;
-};
-
-
-class Q_GUI_EXPORT QFocusEvent : public QEvent
-{
-public:
- QFocusEvent(Type type, Qt::FocusReason reason=Qt::OtherFocusReason);
- ~QFocusEvent();
-
- inline bool gotFocus() const { return type() == FocusIn; }
- inline bool lostFocus() const { return type() == FocusOut; }
-
-#ifdef QT3_SUPPORT
- enum Reason { Mouse=Qt::MouseFocusReason, Tab=Qt::TabFocusReason,
- Backtab=Qt::BacktabFocusReason, MenuBar=Qt::MenuBarFocusReason,
- ActiveWindow=Qt::ActiveWindowFocusReason, Other=Qt::OtherFocusReason,
- Popup=Qt::PopupFocusReason, Shortcut=Qt::ShortcutFocusReason };
-#endif
- Qt::FocusReason reason();
- Qt::FocusReason reason() const;
-
-private:
- Qt::FocusReason m_reason;
-};
-
-
-class Q_GUI_EXPORT QPaintEvent : public QEvent
-{
-public:
- QPaintEvent(const QRegion& paintRegion);
- QPaintEvent(const QRect &paintRect);
- ~QPaintEvent();
-
- inline const QRect &rect() const { return m_rect; }
- inline const QRegion &region() const { return m_region; }
-
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QPaintEvent(const QRegion &paintRegion, const QRect &paintRect);
- inline QT3_SUPPORT bool erased() const { return m_erased; }
- inline QT3_SUPPORT void setErased(bool b) { m_erased = b; }
-#endif
-
-protected:
- friend class QApplication;
- friend class QCoreApplication;
- QRect m_rect;
- QRegion m_region;
- bool m_erased;
-};
-
-class QUpdateLaterEvent : public QEvent
-{
-public:
- QUpdateLaterEvent(const QRegion& paintRegion);
- ~QUpdateLaterEvent();
-
- inline const QRegion &region() const { return m_region; }
-
-protected:
- QRegion m_region;
-};
-
-class Q_GUI_EXPORT QMoveEvent : public QEvent
-{
-public:
- QMoveEvent(const QPoint &pos, const QPoint &oldPos);
- ~QMoveEvent();
-
- inline const QPoint &pos() const { return p; }
- inline const QPoint &oldPos() const { return oldp;}
-protected:
- QPoint p, oldp;
- friend class QApplication;
- friend class QCoreApplication;
-};
-
-
-class Q_GUI_EXPORT QResizeEvent : public QEvent
-{
-public:
- QResizeEvent(const QSize &size, const QSize &oldSize);
- ~QResizeEvent();
-
- inline const QSize &size() const { return s; }
- inline const QSize &oldSize()const { return olds;}
-protected:
- QSize s, olds;
- friend class QApplication;
- friend class QCoreApplication;
-};
-
-
-class Q_GUI_EXPORT QCloseEvent : public QEvent
-{
-public:
- QCloseEvent();
- ~QCloseEvent();
-};
-
-
-class Q_GUI_EXPORT QIconDragEvent : public QEvent
-{
-public:
- QIconDragEvent();
- ~QIconDragEvent();
-};
-
-
-class Q_GUI_EXPORT QShowEvent : public QEvent
-{
-public:
- QShowEvent();
- ~QShowEvent();
-};
-
-
-class Q_GUI_EXPORT QHideEvent : public QEvent
-{
-public:
- QHideEvent();
- ~QHideEvent();
-};
-
-#ifndef QT_NO_CONTEXTMENU
-class Q_GUI_EXPORT QContextMenuEvent : public QInputEvent
-{
-public:
- enum Reason { Mouse, Keyboard, Other };
-
- QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos,
- Qt::KeyboardModifiers modifiers);
- QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos);
- QContextMenuEvent(Reason reason, const QPoint &pos);
- ~QContextMenuEvent();
-
- inline int x() const { return p.x(); }
- inline int y() const { return p.y(); }
- inline int globalX() const { return gp.x(); }
- inline int globalY() const { return gp.y(); }
-
- inline const QPoint& pos() const { return p; }
- inline const QPoint& globalPos() const { return gp; }
-
- inline Reason reason() const { return Reason(reas); }
-
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos, int);
- QT3_SUPPORT_CONSTRUCTOR QContextMenuEvent(Reason reason, const QPoint &pos, int);
-
- QT3_SUPPORT Qt::ButtonState state() const;
-#endif
-protected:
- QPoint p;
- QPoint gp;
- uint reas : 8;
-};
-#endif // QT_NO_CONTEXTMENU
-
-#ifndef QT_NO_INPUTMETHOD
-class Q_GUI_EXPORT QInputMethodEvent : public QEvent
-{
-public:
- enum AttributeType {
- TextFormat,
- Cursor,
- Language,
- Ruby,
- Selection
- };
- class Attribute {
- public:
- Attribute(AttributeType t, int s, int l, QVariant val) : type(t), start(s), length(l), value(val) {}
- AttributeType type;
-
- int start;
- int length;
- QVariant value;
- };
- QInputMethodEvent();
- QInputMethodEvent(const QString &preeditText, const QList<Attribute> &attributes);
- void setCommitString(const QString &commitString, int replaceFrom = 0, int replaceLength = 0);
-
- inline const QList<Attribute> &attributes() const { return attrs; }
- inline const QString &preeditString() const { return preedit; }
-
- inline const QString &commitString() const { return commit; }
- inline int replacementStart() const { return replace_from; }
- inline int replacementLength() const { return replace_length; }
-
- QInputMethodEvent(const QInputMethodEvent &other);
-
-private:
- QString preedit;
- QList<Attribute> attrs;
- QString commit;
- int replace_from;
- int replace_length;
-};
-#endif // QT_NO_INPUTMETHOD
-
-#ifndef QT_NO_DRAGANDDROP
-
-class QMimeData;
-
-class Q_GUI_EXPORT QDropEvent : public QEvent
-// QT3_SUPPORT
- , public QMimeSource
-// END QT3_SUPPORT
-{
-public:
- QDropEvent(const QPoint& pos, Qt::DropActions actions, const QMimeData *data,
- Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type = Drop);
- ~QDropEvent();
-
- inline const QPoint &pos() const { return p; }
- inline Qt::MouseButtons mouseButtons() const { return mouseState; }
- inline Qt::KeyboardModifiers keyboardModifiers() const { return modState; }
-
- inline Qt::DropActions possibleActions() const { return act; }
- inline Qt::DropAction proposedAction() const { return default_action; }
- inline void acceptProposedAction() { drop_action = default_action; accept(); }
-
- inline Qt::DropAction dropAction() const { return drop_action; }
- void setDropAction(Qt::DropAction action);
-
- QWidget* source() const;
- inline const QMimeData *mimeData() const { return mdata; }
-
-// QT3_SUPPORT
- const char* format(int n = 0) const;
- QByteArray encodedData(const char*) const;
- bool provides(const char*) const;
-// END QT3_SUPPORT
-#ifdef QT3_SUPPORT
- inline void accept() { QEvent::accept(); }
- inline QT3_SUPPORT void accept(bool y) { setAccepted(y); }
- inline QT3_SUPPORT QByteArray data(const char* f) const { return encodedData(f); }
-
- enum Action { Copy, Link, Move, Private, UserAction = Private };
- QT3_SUPPORT Action action() const;
- inline QT3_SUPPORT void acceptAction(bool y = true) { if (y) { drop_action = default_action; accept(); } }
- inline QT3_SUPPORT void setPoint(const QPoint& np) { p = np; }
-#endif
-
-
-protected:
- friend class QApplication;
- QPoint p;
- Qt::MouseButtons mouseState;
- Qt::KeyboardModifiers modState;
- Qt::DropActions act;
- Qt::DropAction drop_action;
- Qt::DropAction default_action;
- const QMimeData *mdata;
- mutable QList<QByteArray> fmts; // only used for QT3_SUPPORT
-};
-
-
-class Q_GUI_EXPORT QDragMoveEvent : public QDropEvent
-{
-public:
- QDragMoveEvent(const QPoint &pos, Qt::DropActions actions, const QMimeData *data,
- Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type = DragMove);
- ~QDragMoveEvent();
-
- inline QRect answerRect() const { return rect; }
-
- inline void accept() { QDropEvent::accept(); }
- inline void ignore() { QDropEvent::ignore(); }
-
- inline void accept(const QRect & r) { accept(); rect = r; }
- inline void ignore(const QRect & r) { ignore(); rect = r; }
-
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT void accept(bool y) { setAccepted(y); }
-#endif
-
-protected:
- friend class QApplication;
- QRect rect;
-};
-
-
-class Q_GUI_EXPORT QDragEnterEvent : public QDragMoveEvent
-{
-public:
- QDragEnterEvent(const QPoint &pos, Qt::DropActions actions, const QMimeData *data,
- Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
- ~QDragEnterEvent();
-};
-
-
-/* An internal class */
-class Q_GUI_EXPORT QDragResponseEvent : public QEvent
-{
-public:
- QDragResponseEvent(bool accepted);
- ~QDragResponseEvent();
-
- inline bool dragAccepted() const { return a; }
-protected:
- bool a;
-};
-
-
-class Q_GUI_EXPORT QDragLeaveEvent : public QEvent
-{
-public:
- QDragLeaveEvent();
- ~QDragLeaveEvent();
-};
-#endif // QT_NO_DRAGANDDROP
-
-
-class Q_GUI_EXPORT QHelpEvent : public QEvent
-{
-public:
- QHelpEvent(Type type, const QPoint &pos, const QPoint &globalPos);
- ~QHelpEvent();
-
- inline int x() const { return p.x(); }
- inline int y() const { return p.y(); }
- inline int globalX() const { return gp.x(); }
- inline int globalY() const { return gp.y(); }
-
- inline const QPoint& pos() const { return p; }
- inline const QPoint& globalPos() const { return gp; }
-
-private:
- QPoint p;
- QPoint gp;
-};
-
-#ifndef QT_NO_STATUSTIP
-class Q_GUI_EXPORT QStatusTipEvent : public QEvent
-{
-public:
- QStatusTipEvent(const QString &tip);
- ~QStatusTipEvent();
-
- inline QString tip() const { return s; }
-private:
- QString s;
-};
-#endif
-
-#ifndef QT_NO_WHATSTHIS
-class Q_GUI_EXPORT QWhatsThisClickedEvent : public QEvent
-{
-public:
- QWhatsThisClickedEvent(const QString &href);
- ~QWhatsThisClickedEvent();
-
- inline QString href() const { return s; }
-private:
- QString s;
-};
-#endif
-
-#ifndef QT_NO_ACTION
-class Q_GUI_EXPORT QActionEvent : public QEvent
-{
- QAction *act, *bef;
-public:
- QActionEvent(int type, QAction *action, QAction *before = 0);
- ~QActionEvent();
-
- inline QAction *action() const { return act; }
- inline QAction *before() const { return bef; }
-};
-#endif
-
-class Q_GUI_EXPORT QFileOpenEvent : public QEvent
-{
-public:
- QFileOpenEvent(const QString &file);
- QFileOpenEvent(const QUrl &url);
-#ifdef Q_OS_SYMBIAN
- QFileOpenEvent(const RFile &fileHandle);
-#endif
- ~QFileOpenEvent();
-
- inline QString file() const { return f; }
- QUrl url() const;
- bool openFile(QFile &file, QIODevice::OpenMode flags) const;
-private:
- QString f;
-};
-
-#ifndef QT_NO_TOOLBAR
-class Q_GUI_EXPORT QToolBarChangeEvent : public QEvent
-{
-public:
- QToolBarChangeEvent(bool t);
- ~QToolBarChangeEvent();
-
- inline bool toggle() const { return tog; }
-private:
- uint tog : 1;
-};
-#endif
-
-#ifndef QT_NO_SHORTCUT
-class Q_GUI_EXPORT QShortcutEvent : public QEvent
-{
-public:
- QShortcutEvent(const QKeySequence &key, int id, bool ambiguous = false);
- ~QShortcutEvent();
-
- inline const QKeySequence &key() { return sequence; }
- inline const QKeySequence &key() const { return sequence; }
- inline int shortcutId() { return sid; }
- inline int shortcutId() const { return sid; }
- inline bool isAmbiguous() { return ambig; }
- inline bool isAmbiguous() const { return ambig; }
-protected:
- QKeySequence sequence;
- bool ambig;
- int sid;
-};
-#endif
-
-#ifndef QT_NO_CLIPBOARD
-class Q_GUI_EXPORT QClipboardEvent : public QEvent
-{
-public:
- QClipboardEvent(QEventPrivate *data);
- ~QClipboardEvent();
-
- QEventPrivate *data() { return d; }
-};
-#endif
-
-class Q_GUI_EXPORT QWindowStateChangeEvent: public QEvent
-{
-public:
- QWindowStateChangeEvent(Qt::WindowStates aOldState);
- QWindowStateChangeEvent(Qt::WindowStates aOldState, bool isOverride);
- ~QWindowStateChangeEvent();
-
- inline Qt::WindowStates oldState() const { return ostate; }
- bool isOverride() const;
-
-private:
- Qt::WindowStates ostate;
-};
-
-#ifdef QT3_SUPPORT
-class QMenuBar;
-class Q_GUI_EXPORT QMenubarUpdatedEvent: public QEvent
-{
-public:
- QMenubarUpdatedEvent(QMenuBar * const menBar);
- inline QMenuBar *menuBar() { return m_menuBar; }
-private:
- QMenuBar *m_menuBar;
-};
-#endif
-
-#ifndef QT_NO_DEBUG_STREAM
-Q_GUI_EXPORT QDebug operator<<(QDebug, const QEvent *);
-#endif
-
-#ifndef QT_NO_SHORTCUT
-inline bool operator==(QKeyEvent *e, QKeySequence::StandardKey key){return (e ? e->matches(key) : false);}
-inline bool operator==(QKeySequence::StandardKey key, QKeyEvent *e){return (e ? e->matches(key) : false);}
-#endif // QT_NO_SHORTCUT
-
-class QTouchEventTouchPointPrivate;
-class Q_GUI_EXPORT QTouchEvent : public QInputEvent
-{
-public:
- class Q_GUI_EXPORT TouchPoint
- {
- public:
- TouchPoint(int id = -1);
- TouchPoint(const QTouchEvent::TouchPoint &other);
- ~TouchPoint();
-
- int id() const;
-
- Qt::TouchPointState state() const;
- bool isPrimary() const;
-
- QPointF pos() const;
- QPointF startPos() const;
- QPointF lastPos() const;
-
- QPointF scenePos() const;
- QPointF startScenePos() const;
- QPointF lastScenePos() const;
-
- QPointF screenPos() const;
- QPointF startScreenPos() const;
- QPointF lastScreenPos() const;
-
- QPointF normalizedPos() const;
- QPointF startNormalizedPos() const;
- QPointF lastNormalizedPos() const;
-
- QRectF rect() const;
- QRectF sceneRect() const;
- QRectF screenRect() const;
-
- qreal pressure() const;
-
- // internal
- void setId(int id);
- void setState(Qt::TouchPointStates state);
- void setPos(const QPointF &pos);
- void setScenePos(const QPointF &scenePos);
- void setScreenPos(const QPointF &screenPos);
- void setNormalizedPos(const QPointF &normalizedPos);
- void setStartPos(const QPointF &startPos);
- void setStartScenePos(const QPointF &startScenePos);
- void setStartScreenPos(const QPointF &startScreenPos);
- void setStartNormalizedPos(const QPointF &startNormalizedPos);
- void setLastPos(const QPointF &lastPos);
- void setLastScenePos(const QPointF &lastScenePos);
- void setLastScreenPos(const QPointF &lastScreenPos);
- void setLastNormalizedPos(const QPointF &lastNormalizedPos);
- void setRect(const QRectF &rect);
- void setSceneRect(const QRectF &sceneRect);
- void setScreenRect(const QRectF &screenRect);
- void setPressure(qreal pressure);
- QTouchEvent::TouchPoint &operator=(const QTouchEvent::TouchPoint &other);
-
- private:
- QTouchEventTouchPointPrivate *d;
- friend class QApplication;
- friend class QApplicationPrivate;
- };
-
- enum DeviceType {
- TouchScreen,
- TouchPad
- };
-
- QTouchEvent(QEvent::Type eventType,
- QTouchEvent::DeviceType deviceType = TouchScreen,
- Qt::KeyboardModifiers modifiers = Qt::NoModifier,
- Qt::TouchPointStates touchPointStates = 0,
- const QList<QTouchEvent::TouchPoint> &touchPoints = QList<QTouchEvent::TouchPoint>());
- ~QTouchEvent();
-
- inline QWidget *widget() const { return _widget; }
- inline QTouchEvent::DeviceType deviceType() const { return _deviceType; }
- inline Qt::TouchPointStates touchPointStates() const { return _touchPointStates; }
- inline const QList<QTouchEvent::TouchPoint> &touchPoints() const { return _touchPoints; }
-
- // internal
- inline void setWidget(QWidget *awidget) { _widget = awidget; }
- inline void setDeviceType(DeviceType adeviceType) { _deviceType = adeviceType; }
- inline void setTouchPointStates(Qt::TouchPointStates aTouchPointStates) { _touchPointStates = aTouchPointStates; }
- inline void setTouchPoints(const QList<QTouchEvent::TouchPoint> &atouchPoints) { _touchPoints = atouchPoints; }
-
-protected:
- QWidget *_widget;
- QTouchEvent::DeviceType _deviceType;
- Qt::TouchPointStates _touchPointStates;
- QList<QTouchEvent::TouchPoint> _touchPoints;
-
- friend class QApplication;
- friend class QApplicationPrivate;
-};
-
-#ifndef QT_NO_GESTURES
-class QGesture;
-class QGestureEventPrivate;
-class Q_GUI_EXPORT QGestureEvent : public QEvent
-{
-public:
- QGestureEvent(const QList<QGesture *> &gestures);
- ~QGestureEvent();
-
- QList<QGesture *> gestures() const;
- QGesture *gesture(Qt::GestureType type) const;
-
- QList<QGesture *> activeGestures() const;
- QList<QGesture *> canceledGestures() const;
-
-#ifdef Q_NO_USING_KEYWORD
- inline void setAccepted(bool accepted) { QEvent::setAccepted(accepted); }
- inline bool isAccepted() const { return QEvent::isAccepted(); }
-
- inline void accept() { QEvent::accept(); }
- inline void ignore() { QEvent::ignore(); }
-#else
- using QEvent::setAccepted;
- using QEvent::isAccepted;
- using QEvent::accept;
- using QEvent::ignore;
-#endif
-
- void setAccepted(QGesture *, bool);
- void accept(QGesture *);
- void ignore(QGesture *);
- bool isAccepted(QGesture *) const;
-
- void setAccepted(Qt::GestureType, bool);
- void accept(Qt::GestureType);
- void ignore(Qt::GestureType);
- bool isAccepted(Qt::GestureType) const;
-
- void setWidget(QWidget *widget);
- QWidget *widget() const;
-
-#ifndef QT_NO_GRAPHICSVIEW
- QPointF mapToGraphicsScene(const QPointF &gesturePoint) const;
-#endif
-
-private:
- QGestureEventPrivate *d_func();
- const QGestureEventPrivate *d_func() const;
-
- friend class QApplication;
- friend class QGestureManager;
-};
-#endif // QT_NO_GESTURES
-
-class QScrollPrepareEventPrivate;
-class Q_GUI_EXPORT QScrollPrepareEvent : public QEvent
-{
-public:
- QScrollPrepareEvent(const QPointF &startPos);
- ~QScrollPrepareEvent();
-
- QPointF startPos() const;
-
- QSizeF viewportSize() const;
- QRectF contentPosRange() const;
- QPointF contentPos() const;
-
- void setViewportSize(const QSizeF &size);
- void setContentPosRange(const QRectF &rect);
- void setContentPos(const QPointF &pos);
-
-private:
- QScrollPrepareEventPrivate *d_func();
- const QScrollPrepareEventPrivate *d_func() const;
-};
-
-
-class QScrollEventPrivate;
-class Q_GUI_EXPORT QScrollEvent : public QEvent
-{
-public:
- enum ScrollState
- {
- ScrollStarted,
- ScrollUpdated,
- ScrollFinished
- };
-
- QScrollEvent(const QPointF &contentPos, const QPointF &overshoot, ScrollState scrollState);
- ~QScrollEvent();
-
- QPointF contentPos() const;
- QPointF overshootDistance() const;
- ScrollState scrollState() const;
-
-private:
- QScrollEventPrivate *d_func();
- const QScrollEventPrivate *d_func() const;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QEVENT_H
diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h
deleted file mode 100644
index b79f372d8d..0000000000
--- a/src/gui/kernel/qevent_p.h
+++ /dev/null
@@ -1,219 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QEVENT_P_H
-#define QEVENT_P_H
-
-#include <QtCore/qglobal.h>
-#include <QtCore/qurl.h>
-#include <QtGui/qevent.h>
-
-#ifdef Q_OS_SYMBIAN
-#include <f32file.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-//
-// 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.
-//
-
-// ### Qt 5: remove
-class QKeyEventEx : public QKeyEvent
-{
-public:
- QKeyEventEx(Type type, int key, Qt::KeyboardModifiers modifiers,
- const QString &text, bool autorep, ushort count,
- quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers);
- QKeyEventEx(const QKeyEventEx &other);
-
- ~QKeyEventEx();
-
-protected:
- quint32 nScanCode;
- quint32 nVirtualKey;
- quint32 nModifiers;
- friend class QKeyEvent;
-};
-
-// ### Qt 5: remove
-class QMouseEventEx : public QMouseEvent
-{
-public:
- QMouseEventEx(Type type, const QPointF &pos, const QPoint &globalPos,
- Qt::MouseButton button, Qt::MouseButtons buttons,
- Qt::KeyboardModifiers modifiers);
- ~QMouseEventEx();
-
-protected:
- QPointF posF;
- friend class QMouseEvent;
-};
-
-class QTouchEventTouchPointPrivate
-{
-public:
- inline QTouchEventTouchPointPrivate(int id)
- : ref(1),
- id(id),
- state(Qt::TouchPointReleased),
- pressure(qreal(-1.))
- { }
-
- inline QTouchEventTouchPointPrivate *detach()
- {
- QTouchEventTouchPointPrivate *d = new QTouchEventTouchPointPrivate(*this);
- d->ref = 1;
- if (!this->ref.deref())
- delete this;
- return d;
- }
-
- QAtomicInt ref;
- int id;
- Qt::TouchPointStates state;
- QRectF rect, sceneRect, screenRect;
- QPointF normalizedPos,
- startPos, startScenePos, startScreenPos, startNormalizedPos,
- lastPos, lastScenePos, lastScreenPos, lastNormalizedPos;
- qreal pressure;
-};
-
-#ifndef QT_NO_GESTURES
-class QNativeGestureEvent : public QEvent
-{
-public:
- enum Type {
- None,
- GestureBegin,
- GestureEnd,
- Pan,
- Zoom,
- Rotate,
- Swipe
- };
-
- QNativeGestureEvent()
- : QEvent(QEvent::NativeGesture), gestureType(None), percentage(0)
-#ifdef Q_WS_WIN
- , sequenceId(0), argument(0)
-#endif
- {
- }
-
- Type gestureType;
- float percentage;
- QPoint position;
- float angle;
-#ifdef Q_WS_WIN
- ulong sequenceId;
- quint64 argument;
-#endif
-};
-
-class QGestureEventPrivate
-{
-public:
- inline QGestureEventPrivate(const QList<QGesture *> &list)
- : gestures(list), widget(0)
- {
- }
-
- QList<QGesture *> gestures;
- QWidget *widget;
- QMap<Qt::GestureType, bool> accepted;
- QMap<Qt::GestureType, QWidget *> targetWidgets;
-};
-#endif // QT_NO_GESTURES
-
-class QFileOpenEventPrivate
-{
-public:
- inline QFileOpenEventPrivate(const QUrl &url)
- : url(url)
- {
- }
- ~QFileOpenEventPrivate();
-
- QUrl url;
-#ifdef Q_OS_SYMBIAN
- RFile file;
-#endif
-};
-
-
-class QScrollPrepareEventPrivate
-{
-public:
- inline QScrollPrepareEventPrivate()
- : target(0)
- {
- }
-
- QObject* target;
- QPointF startPos;
- QSizeF viewportSize;
- QRectF contentPosRange;
- QPointF contentPos;
-};
-
-class QScrollEventPrivate
-{
-public:
- inline QScrollEventPrivate()
- {
- }
-
- QPointF contentPos;
- QPointF overshoot;
- QScrollEvent::ScrollState state;
-};
-
-QT_END_NAMESPACE
-
-#endif // QEVENT_P_H
diff --git a/src/gui/kernel/qeventdispatcher_glib_qpa.cpp b/src/gui/kernel/qeventdispatcher_glib_qpa.cpp
deleted file mode 100644
index 603aa2dbe7..0000000000
--- a/src/gui/kernel/qeventdispatcher_glib_qpa.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qeventdispatcher_glib_qpa_p.h"
-
-#include "qapplication.h"
-
-#include "qplatformdefs.h"
-#include "qapplication.h"
-
-#include <glib.h>
-#include "qapplication_p.h"
-
-#include <qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-struct GUserEventSource
-{
- GSource source;
- QPAEventDispatcherGlib *q;
-};
-
-static gboolean userEventSourcePrepare(GSource *s, gint *timeout)
-{
- Q_UNUSED(s)
- Q_UNUSED(timeout)
-
- return QWindowSystemInterfacePrivate::windowSystemEventsQueued() > 0;
-}
-
-static gboolean userEventSourceCheck(GSource *source)
-{
- return userEventSourcePrepare(source, 0);
-}
-
-static gboolean userEventSourceDispatch(GSource *s, GSourceFunc, gpointer)
-{
- GUserEventSource * source = reinterpret_cast<GUserEventSource *>(s);
-
- QWindowSystemInterfacePrivate::WindowSystemEvent * event;
- while (QWindowSystemInterfacePrivate::windowSystemEventsQueued()) {
- event = QWindowSystemInterfacePrivate::getWindowSystemEvent();
- if (!event)
- break;
-
- // send through event filter
- if (source->q->filterEvent(event)) {
- delete event;
- continue;
- }
- QApplicationPrivate::processWindowSystemEvent(event);
- delete event;
- }
-
- return true;
-}
-
-
-static GSourceFuncs userEventSourceFuncs = {
- userEventSourcePrepare,
- userEventSourceCheck,
- userEventSourceDispatch,
- NULL,
- NULL,
- NULL
-};
-
-QPAEventDispatcherGlibPrivate::QPAEventDispatcherGlibPrivate(GMainContext *context)
- : QEventDispatcherGlibPrivate(context)
-{
- userEventSource = reinterpret_cast<GUserEventSource *>(g_source_new(&userEventSourceFuncs,
- sizeof(GUserEventSource)));
- userEventSource->q = 0;
- g_source_set_can_recurse(&userEventSource->source, true);
- g_source_attach(&userEventSource->source, mainContext);
-}
-
-
-QPAEventDispatcherGlib::QPAEventDispatcherGlib(QObject *parent)
- : QEventDispatcherGlib(*new QPAEventDispatcherGlibPrivate, parent)
-{
- Q_D(QPAEventDispatcherGlib);
- d->userEventSource->q = this;
-}
-
-QPAEventDispatcherGlib::~QPAEventDispatcherGlib()
-{
- Q_D(QPAEventDispatcherGlib);
-
- g_source_destroy(&d->userEventSource->source);
- g_source_unref(&d->userEventSource->source);
- d->userEventSource = 0;
-}
-
-bool QPAEventDispatcherGlib::processEvents(QEventLoop::ProcessEventsFlags flags)
-{
- static bool init = false;
- if (!init) {
- if (QApplicationPrivate::platformIntegration()->createEventLoopIntegration()) {
- qWarning("Eventloop integration is not supported by the glib event dispatcher");
- qWarning("Use the UNIX event dispatcher by defining environment variable QT_NO_GLIB=1");
- }
- init = true;
- }
- return QEventDispatcherGlib::processEvents(flags);
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qeventdispatcher_glib_qws.cpp b/src/gui/kernel/qeventdispatcher_glib_qws.cpp
deleted file mode 100644
index 7a800cea07..0000000000
--- a/src/gui/kernel/qeventdispatcher_glib_qws.cpp
+++ /dev/null
@@ -1,195 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qeventdispatcher_glib_qws_p.h"
-
-#include "qapplication.h"
-
-#include "qplatformdefs.h"
-#include "qapplication.h"
-#include "private/qwscommand_qws_p.h"
-#include "qwsdisplay_qws.h"
-#include "qwsevent_qws.h"
-#include "qwindowsystem_qws.h"
-
-#include <glib.h>
-
-QT_BEGIN_NAMESPACE
-
-// from qapplication_qws.cpp
-extern QWSDisplay* qt_fbdpy; // QWS `display'
-
-//from qwindowsystem_qws.cpp
-extern QList<QWSCommand*> *qt_get_server_queue();
-
-struct GQWSEventSource
-{
- GSource source;
- QEventLoop::ProcessEventsFlags flags;
- QWSEventDispatcherGlib *q;
- QWSEventDispatcherGlibPrivate *d;
-};
-
-class QWSEventDispatcherGlibPrivate : public QEventDispatcherGlibPrivate
-{
- Q_DECLARE_PUBLIC(QWSEventDispatcherGlib)
-
-public:
- QWSEventDispatcherGlibPrivate();
- GQWSEventSource *qwsEventSource;
- QList<QWSEvent*> queuedUserInputEvents;
-};
-
-static gboolean qwsEventSourcePrepare(GSource *s, gint *timeout)
-{
- if (timeout)
- *timeout = -1;
- GQWSEventSource *source = reinterpret_cast<GQWSEventSource *>(s);
- return qt_fbdpy->eventPending() || !source->d->queuedUserInputEvents.isEmpty()
- || !qt_get_server_queue()->isEmpty() ;
-}
-
-static gboolean qwsEventSourceCheck(GSource *s)
-{
- GQWSEventSource *source = reinterpret_cast<GQWSEventSource *>(s);
- return qt_fbdpy->eventPending() || !source->d->queuedUserInputEvents.isEmpty()
- || !qt_get_server_queue()->isEmpty() ;
-}
-
-static gboolean qwsEventSourceDispatch(GSource *s, GSourceFunc callback, gpointer user_data)
-{
- GQWSEventSource *source = reinterpret_cast<GQWSEventSource *>(s);
-
- //??? ulong marker = XNextRequest(X11->display);
- do {
- QWSEvent *event;
- if (!(source->flags & QEventLoop::ExcludeUserInputEvents)
- && !source->d->queuedUserInputEvents.isEmpty()) {
- // process a pending user input event
- event = source->d->queuedUserInputEvents.takeFirst();
- } else if (qt_fbdpy->eventPending()) {
- event = qt_fbdpy->getEvent();
-
- if (source->flags & QEventLoop::ExcludeUserInputEvents) {
- // queue user input events
-
- if (event->type == QWSEvent::Mouse || event->type == QWSEvent::Key) {
- source->d->queuedUserInputEvents.append(event);
- continue;
- }
- }
- } else {
- // no event to process
- break;
- }
-
- // send through event filter
- if (source->q->filterEvent(event)) {
- delete event;
- continue;
- }
-
- bool ret = qApp->qwsProcessEvent(event) == 1;
- delete event;
- if (ret) {
- return true;
- }
-
- } while (qt_fbdpy->eventPending());
-
- if (callback)
- callback(user_data);
- return true;
-}
-
-static GSourceFuncs qwsEventSourceFuncs = {
- qwsEventSourcePrepare,
- qwsEventSourceCheck,
- qwsEventSourceDispatch,
- NULL,
- NULL,
- NULL
-};
-
-QWSEventDispatcherGlibPrivate::QWSEventDispatcherGlibPrivate()
-{
- qwsEventSource = reinterpret_cast<GQWSEventSource *>(g_source_new(&qwsEventSourceFuncs,
- sizeof(GQWSEventSource)));
- g_source_set_can_recurse(&qwsEventSource->source, true);
-
- qwsEventSource->flags = QEventLoop::AllEvents;
- qwsEventSource->q = 0;
- qwsEventSource->d = 0;
-
- g_source_attach(&qwsEventSource->source, mainContext);
-}
-
-QWSEventDispatcherGlib::QWSEventDispatcherGlib(QObject *parent)
- : QEventDispatcherGlib(*new QWSEventDispatcherGlibPrivate, parent)
-{
-}
-
-QWSEventDispatcherGlib::~QWSEventDispatcherGlib()
-{
- Q_D(QWSEventDispatcherGlib);
-
- g_source_destroy(&d->qwsEventSource->source);
- d->qwsEventSource = 0;
-}
-
-bool QWSEventDispatcherGlib::processEvents(QEventLoop::ProcessEventsFlags flags)
-{
- Q_D(QWSEventDispatcherGlib);
- QEventLoop::ProcessEventsFlags saved_flags = d->qwsEventSource->flags;
- d->qwsEventSource->flags = flags;
- bool returnValue = QEventDispatcherGlib::processEvents(flags);
- d->qwsEventSource->flags = saved_flags;
- return returnValue;
-}
-
-void QWSEventDispatcherGlib::startingUp()
-{
- Q_D(QWSEventDispatcherGlib);
- d->qwsEventSource->q = this;
- d->qwsEventSource->d = d;
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qeventdispatcher_glib_qws_p.h b/src/gui/kernel/qeventdispatcher_glib_qws_p.h
deleted file mode 100644
index 66cb2fc9dc..0000000000
--- a/src/gui/kernel/qeventdispatcher_glib_qws_p.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWSEVENTDISPATCHER_GLIB_P_H
-#define QWSEVENTDISPATCHER_GLIB_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QLibrary class. This header file may change from
-// version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/private/qeventdispatcher_glib_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QWSEventDispatcherGlibPrivate;
-
-class QWSEventDispatcherGlib : public QEventDispatcherGlib
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QWSEventDispatcherGlib)
-
-public:
- explicit QWSEventDispatcherGlib(QObject *parent = 0);
- ~QWSEventDispatcherGlib();
-
- bool processEvents(QEventLoop::ProcessEventsFlags flags);
-
- void startingUp();
-};
-
-QT_END_NAMESPACE
-
-#endif // QWSEVENTDISPATCHER_GLIB_P_H
diff --git a/src/gui/kernel/qeventdispatcher_qpa.cpp b/src/gui/kernel/qeventdispatcher_qpa.cpp
deleted file mode 100644
index de53618fa8..0000000000
--- a/src/gui/kernel/qeventdispatcher_qpa.cpp
+++ /dev/null
@@ -1,334 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qplatformdefs.h"
-#include "qapplication.h"
-#include "qeventdispatcher_qpa_p.h"
-#include "private/qeventdispatcher_unix_p.h"
-#include "qapplication_p.h"
-#include "qplatformeventloopintegration_qpa.h"
-
-#include <QWindowSystemInterface>
-#include <QtCore/QElapsedTimer>
-#include <QtCore/QAtomicInt>
-#include <QtCore/QSemaphore>
-
-#include <QtCore/QDebug>
-
-#include <errno.h>
-
-QT_BEGIN_NAMESPACE
-
-QT_USE_NAMESPACE
-
-class Rendezvous
-{
-public:
- void checkpoint()
- {
- if (state.testAndSetOrdered(0,1)) {
- semaphore.acquire();
- } else if (state.testAndSetAcquire(1,0)) {
- semaphore.release();
- } else {
- qWarning("Barrier internal error");
- }
- }
-private:
- QSemaphore semaphore;
- QAtomicInt state;
-};
-
-class SelectWorker : public QThread
-{
-public:
- SelectWorker(QEventDispatcherQPAPrivate *eventDispatcherPrivate)
- : QThread(),
- m_edPrivate(eventDispatcherPrivate),
- m_retVal(0)
- {
- }
-
- void setSelectValues(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds)
- {
- m_nfds = nfds;
- m_readfds = readfds;
- m_writefds = writefds;
- m_exceptfds = exceptfds;
-
-
- }
-
- int retVal() const {
- return m_retVal;
- }
-
-protected:
- void run();
-
-private:
- QEventDispatcherQPAPrivate *m_edPrivate;
- int m_retVal;
-
- int m_nfds;
- fd_set *m_readfds, *m_writefds, *m_exceptfds;
-};
-
-class QEventDispatcherQPAPrivate : public QEventDispatcherUNIXPrivate
-{
- Q_DECLARE_PUBLIC(QEventDispatcherQPA)
-public:
- QEventDispatcherQPAPrivate()
- : eventLoopIntegration(0),
- barrierBeforeBlocking(0),
- barrierReturnValue(0),
- selectReturnMutex(0),
- selectWorkerNeedsSync(true),
- selectWorkerHasResult(false),
- m_integrationInitialised(false),
- m_hasIntegration(false),
- m_isEventLoopIntegrationRunning(false)
- {
-
- }
-
- ~QEventDispatcherQPAPrivate()
- {
- delete selectWorker;
- delete eventLoopIntegration;
- delete barrierBeforeBlocking;
- delete barrierReturnValue;
- delete selectReturnMutex;
- }
-
- bool hasIntegration() const
- {
- if (!m_integrationInitialised) {
- QEventDispatcherQPAPrivate *that = const_cast<QEventDispatcherQPAPrivate *>(this);
- if (qApp && (qApp->thread() == QThread::currentThread())) { // guiThread
- if (QApplicationPrivate::platformIntegration()) {
- that->eventLoopIntegration = QApplicationPrivate::platformIntegration()->createEventLoopIntegration();
- if (that->eventLoopIntegration) {
- that->selectWorker = new SelectWorker(that);
- that->barrierBeforeBlocking = new Rendezvous;
- that->barrierReturnValue = new Rendezvous;
- that->selectReturnMutex = new QMutex;
- that->selectWorker->start();
- that->m_hasIntegration = true;
- if (!QElapsedTimer::isMonotonic())
- qWarning("Having eventloop integration without monotonic timers can lead to undefined behaviour");
- }
- }
- }
- that->m_integrationInitialised = true;
- }
- return m_hasIntegration;
- }
-
- bool isEventLoopIntegrationRunning() const
- {
- return m_isEventLoopIntegrationRunning;
- }
-
- void runEventLoopIntegration()
- {
- if (qApp && (qApp->thread() == QThread::currentThread())) {
- m_isEventLoopIntegrationRunning = true;
- eventLoopIntegration->startEventLoop();
- }
- }
-
- QPlatformEventLoopIntegration *eventLoopIntegration;
- Rendezvous *barrierBeforeBlocking;
- Rendezvous *barrierReturnValue;
-
- QMutex *selectReturnMutex;
- bool selectWorkerNeedsSync;
- bool selectWorkerHasResult;
-
- SelectWorker *selectWorker;
-private:
- bool m_integrationInitialised;
- bool m_hasIntegration;
- bool m_isEventLoopIntegrationRunning;
-};
-
-QEventDispatcherQPA::QEventDispatcherQPA(QObject *parent)
- : QEventDispatcherUNIX(*new QEventDispatcherQPAPrivate, parent)
-{ }
-
-QEventDispatcherQPA::~QEventDispatcherQPA()
-{ }
-
-bool QEventDispatcherQPA::processEvents(QEventLoop::ProcessEventsFlags flags)
-{
- Q_D(QEventDispatcherQPA);
-
- if (d->hasIntegration()) {
- if (!d->isEventLoopIntegrationRunning()) {
- d->runEventLoopIntegration();
- }
- if (d->threadData->quitNow) {
- d->eventLoopIntegration->quitEventLoop();
- return false;
- }
- }
-
- int nevents = 0;
-
- // handle gui and posted events
- d->interrupt = false;
- QApplication::sendPostedEvents();
-
- while (!d->interrupt) { // also flushes output buffer ###can be optimized
- QWindowSystemInterfacePrivate::WindowSystemEvent *event;
- if (!(flags & QEventLoop::ExcludeUserInputEvents)
- && QWindowSystemInterfacePrivate::windowSystemEventsQueued() > 0) {
- // process a pending user input event
- event = QWindowSystemInterfacePrivate::getWindowSystemEvent();
- if (!event)
- break;
- } else {
- break;
- }
-
- if (filterEvent(event)) {
- delete event;
- continue;
- }
- nevents++;
-
- QApplicationPrivate::processWindowSystemEvent(event);
- delete event;
- }
-
- if (!d->interrupt) {
- if (QEventDispatcherUNIX::processEvents(flags)) {
- QEventDispatcherUNIX::processEvents(flags);
- return true;
- }
- }
- return (nevents > 0);
-}
-
-bool QEventDispatcherQPA::hasPendingEvents()
-{
- extern uint qGlobalPostedEventsCount(); // from qapplication.cpp
- return qGlobalPostedEventsCount() || QWindowSystemInterfacePrivate::windowSystemEventsQueued();
-}
-
-void QEventDispatcherQPA::registerSocketNotifier(QSocketNotifier *notifier)
-{
- Q_D(QEventDispatcherQPA);
- QEventDispatcherUNIX::registerSocketNotifier(notifier);
- if (d->hasIntegration())
- wakeUp();
-
-}
-
-void QEventDispatcherQPA::unregisterSocketNotifier(QSocketNotifier *notifier)
-{
- Q_D(QEventDispatcherQPA);
- QEventDispatcherUNIX::unregisterSocketNotifier(notifier);
- if (d->hasIntegration())
- wakeUp();
-}
-
-void QEventDispatcherQPA::flush()
-{
- if(qApp)
- qApp->sendPostedEvents();
-}
-
-int QEventDispatcherQPA::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
- timeval *timeout)
-{
- Q_D(QEventDispatcherQPA);
- int retVal = 0;
- if (d->hasIntegration()) {
- qint64 timeoutmsec = 0;
- if (timeout)
- timeoutmsec = timeout->tv_sec * 1000 + (timeout->tv_usec/1000);
- d->selectReturnMutex->lock();
- if (d->selectWorkerNeedsSync) {
- if (d->selectWorkerHasResult) {
- retVal = d->selectWorker->retVal();
- d->selectWorkerHasResult = false;
-
- d->selectReturnMutex->unlock();
- d->barrierReturnValue->checkpoint();
- d->eventLoopIntegration->setNextTimerEvent(0);
- return retVal;
- } else {
- d->selectWorkerNeedsSync = false;
- d->selectWorker->setSelectValues(nfds,readfds, writefds, exceptfds);
- d->barrierBeforeBlocking->checkpoint();
- }
- }
- d->selectReturnMutex->unlock();
- d->eventLoopIntegration->setNextTimerEvent(timeoutmsec);
- retVal = 0; //is 0 if select has not returned
- } else {
- retVal = QEventDispatcherUNIX::select(nfds, readfds, writefds, exceptfds, timeout);
- }
- return retVal;
-}
-
-
-void SelectWorker::run()
-{
-
- while(true) {
- m_retVal = 0;
- m_edPrivate->barrierBeforeBlocking->checkpoint(); // wait for mainthread
- int tmpRet = qt_safe_select(m_nfds,m_readfds,m_writefds,m_exceptfds,0);
- m_edPrivate->selectReturnMutex->lock();
- m_edPrivate->eventLoopIntegration->qtNeedsToProcessEvents();
-
- m_edPrivate->selectWorkerNeedsSync = true;
- m_edPrivate->selectWorkerHasResult = true;
- m_retVal = tmpRet;
-
- m_edPrivate->selectReturnMutex->unlock();
- m_edPrivate->barrierReturnValue->checkpoint();
- }
-}
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qeventdispatcher_qws.cpp b/src/gui/kernel/qeventdispatcher_qws.cpp
deleted file mode 100644
index c5df07ea86..0000000000
--- a/src/gui/kernel/qeventdispatcher_qws.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qplatformdefs.h"
-#include "qapplication.h"
-#include "private/qwscommand_qws_p.h"
-#include "qwsdisplay_qws.h"
-#include "qwsevent_qws.h"
-#include "qwindowsystem_qws.h"
-#include "qeventdispatcher_qws_p.h"
-#include "private/qeventdispatcher_unix_p.h"
-#ifndef QT_NO_THREAD
-# include "qmutex.h"
-#endif
-
-#include <errno.h>
-
-QT_BEGIN_NAMESPACE
-
-QT_USE_NAMESPACE
-
-class QEventDispatcherQWSPrivate : public QEventDispatcherUNIXPrivate
-{
- Q_DECLARE_PUBLIC(QEventDispatcherQWS)
-public:
- inline QEventDispatcherQWSPrivate()
- { }
- QList<QWSEvent*> queuedUserInputEvents;
-};
-
-
-QEventDispatcherQWS::QEventDispatcherQWS(QObject *parent)
- : QEventDispatcherUNIX(*new QEventDispatcherQWSPrivate, parent)
-{ }
-
-QEventDispatcherQWS::~QEventDispatcherQWS()
-{ }
-
-
-
-// from qapplication_qws.cpp
-extern QWSDisplay* qt_fbdpy; // QWS `display'
-
-//#define ZERO_FOR_THE_MOMENT
-
-bool QEventDispatcherQWS::processEvents(QEventLoop::ProcessEventsFlags flags)
-{
- Q_D(QEventDispatcherQWS);
- // process events from the QWS server
- int nevents = 0;
-
- // handle gui and posted events
- d->interrupt = false;
- QApplication::sendPostedEvents();
-
- while (!d->interrupt) { // also flushes output buffer ###can be optimized
- QWSEvent *event;
- if (!(flags & QEventLoop::ExcludeUserInputEvents)
- && !d->queuedUserInputEvents.isEmpty()) {
- // process a pending user input event
- event = d->queuedUserInputEvents.takeFirst();
- } else if (qt_fbdpy->eventPending()) {
- event = qt_fbdpy->getEvent(); // get next event
- if (flags & QEventLoop::ExcludeUserInputEvents) {
- // queue user input events
- if (event->type == QWSEvent::Mouse || event->type == QWSEvent::Key) {
- d->queuedUserInputEvents.append(event);
- continue;
- }
- }
- } else {
- break;
- }
-
- if (filterEvent(event)) {
- delete event;
- continue;
- }
- nevents++;
-
- bool ret = qApp->qwsProcessEvent(event) == 1;
- delete event;
- if (ret) {
- return true;
- }
- }
-
- if (!d->interrupt) {
- extern QList<QWSCommand*> *qt_get_server_queue();
- if (!qt_get_server_queue()->isEmpty()) {
- QWSServer::processEventQueue();
- }
-
- if (QEventDispatcherUNIX::processEvents(flags))
- return true;
- }
- return (nevents > 0);
-}
-
-bool QEventDispatcherQWS::hasPendingEvents()
-{
- extern uint qGlobalPostedEventsCount(); // from qapplication.cpp
- return qGlobalPostedEventsCount() || qt_fbdpy->eventPending();
-}
-
-void QEventDispatcherQWS::startingUp()
-{
-
-}
-
-void QEventDispatcherQWS::closingDown()
-{
-
-}
-
-void QEventDispatcherQWS::flush()
-{
- if(qApp)
- qApp->sendPostedEvents();
- (void)qt_fbdpy->eventPending(); // flush
-}
-
-
-int QEventDispatcherQWS::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
- timeval *timeout)
-{
- return QEventDispatcherUNIX::select(nfds, readfds, writefds, exceptfds, timeout);
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qeventdispatcher_qws_p.h b/src/gui/kernel/qeventdispatcher_qws_p.h
deleted file mode 100644
index e73ed6ce5e..0000000000
--- a/src/gui/kernel/qeventdispatcher_qws_p.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QEVENTDISPATCHER_QWS_P_H
-#define QEVENTDISPATCHER_QWS_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "private/qeventdispatcher_unix_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QEventDispatcherQWSPrivate;
-
-class QEventDispatcherQWS : public QEventDispatcherUNIX
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QEventDispatcherQWS)
-
-public:
- explicit QEventDispatcherQWS(QObject *parent = 0);
- ~QEventDispatcherQWS();
-
- bool processEvents(QEventLoop::ProcessEventsFlags flags);
- bool hasPendingEvents();
-
- void flush();
-
- void startingUp();
- void closingDown();
-
-protected:
- int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
- timeval *timeout);
-};
-
-QT_END_NAMESPACE
-
-#endif // QEVENTDISPATCHER_QWS_P_H
diff --git a/src/gui/kernel/qformlayout.h b/src/gui/kernel/qformlayout.h
deleted file mode 100644
index f229ac2d83..0000000000
--- a/src/gui/kernel/qformlayout.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFORMLAYOUT_H
-#define QFORMLAYOUT_H
-
-#include <QtGui/QLayout>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QFormLayoutPrivate;
-
-class Q_GUI_EXPORT QFormLayout : public QLayout
-{
- Q_OBJECT
- Q_ENUMS(FormStyle FieldGrowthPolicy RowWrapPolicy ItemRole)
- Q_DECLARE_PRIVATE(QFormLayout)
- Q_PROPERTY(FieldGrowthPolicy fieldGrowthPolicy READ fieldGrowthPolicy WRITE setFieldGrowthPolicy RESET resetFieldGrowthPolicy)
- Q_PROPERTY(RowWrapPolicy rowWrapPolicy READ rowWrapPolicy WRITE setRowWrapPolicy RESET resetRowWrapPolicy)
- Q_PROPERTY(Qt::Alignment labelAlignment READ labelAlignment WRITE setLabelAlignment RESET resetLabelAlignment)
- Q_PROPERTY(Qt::Alignment formAlignment READ formAlignment WRITE setFormAlignment RESET resetFormAlignment)
- Q_PROPERTY(int horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing)
- Q_PROPERTY(int verticalSpacing READ verticalSpacing WRITE setVerticalSpacing)
-
-public:
- enum FieldGrowthPolicy {
- FieldsStayAtSizeHint,
- ExpandingFieldsGrow,
- AllNonFixedFieldsGrow
- };
-
- enum RowWrapPolicy {
- DontWrapRows,
- WrapLongRows,
- WrapAllRows
- };
-
- enum ItemRole {
- LabelRole = 0,
- FieldRole = 1,
- SpanningRole = 2
- };
-
- explicit QFormLayout(QWidget *parent = 0);
- ~QFormLayout();
-
- void setFieldGrowthPolicy(FieldGrowthPolicy policy);
- FieldGrowthPolicy fieldGrowthPolicy() const;
- void setRowWrapPolicy(RowWrapPolicy policy);
- RowWrapPolicy rowWrapPolicy() const;
- void setLabelAlignment(Qt::Alignment alignment);
- Qt::Alignment labelAlignment() const;
- void setFormAlignment(Qt::Alignment alignment);
- Qt::Alignment formAlignment() const;
-
- void setHorizontalSpacing(int spacing);
- int horizontalSpacing() const;
- void setVerticalSpacing(int spacing);
- int verticalSpacing() const;
-
- int spacing() const;
- void setSpacing(int);
-
- void addRow(QWidget *label, QWidget *field);
- void addRow(QWidget *label, QLayout *field);
- void addRow(const QString &labelText, QWidget *field);
- void addRow(const QString &labelText, QLayout *field);
- void addRow(QWidget *widget);
- void addRow(QLayout *layout);
-
- void insertRow(int row, QWidget *label, QWidget *field);
- void insertRow(int row, QWidget *label, QLayout *field);
- void insertRow(int row, const QString &labelText, QWidget *field);
- void insertRow(int row, const QString &labelText, QLayout *field);
- void insertRow(int row, QWidget *widget);
- void insertRow(int row, QLayout *layout);
-
- void setItem(int row, ItemRole role, QLayoutItem *item);
- void setWidget(int row, ItemRole role, QWidget *widget);
- void setLayout(int row, ItemRole role, QLayout *layout);
-
- QLayoutItem *itemAt(int row, ItemRole role) const;
- void getItemPosition(int index, int *rowPtr, ItemRole *rolePtr) const;
- void getWidgetPosition(QWidget *widget, int *rowPtr, ItemRole *rolePtr) const;
- void getLayoutPosition(QLayout *layout, int *rowPtr, ItemRole *rolePtr) const;
- QWidget *labelForField(QWidget *field) const;
- QWidget *labelForField(QLayout *field) const;
-
- // reimplemented from QLayout
- void addItem(QLayoutItem *item);
- QLayoutItem *itemAt(int index) const;
- QLayoutItem *takeAt(int index);
-
- void setGeometry(const QRect &rect);
- QSize minimumSize() const;
- QSize sizeHint() const;
- void invalidate();
-
- bool hasHeightForWidth() const;
- int heightForWidth(int width) const;
- Qt::Orientations expandingDirections() const;
- int count() const;
-
- int rowCount() const;
-
-#if 0
- void dump() const;
-#endif
-
-private:
- void resetFieldGrowthPolicy();
- void resetRowWrapPolicy();
- void resetLabelAlignment();
- void resetFormAlignment();
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/gui/kernel/qgenericpluginfactory_qpa.cpp b/src/gui/kernel/qgenericpluginfactory_qpa.cpp
deleted file mode 100644
index abc575ae86..0000000000
--- a/src/gui/kernel/qgenericpluginfactory_qpa.cpp
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgenericpluginfactory_qpa.h"
-
-#include "qapplication.h"
-#include "private/qfactoryloader_p.h"
-#include "qgenericplugin_qpa.h"
-#include "qdebug.h"
-
-QT_BEGIN_NAMESPACE
-
-#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
-#ifndef QT_NO_LIBRARY
-
-Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
- (QGenericPluginFactoryInterface_iid,
- QLatin1String("/generic"), Qt::CaseInsensitive))
-
-#endif //QT_NO_LIBRARY
-#endif //QT_MAKEDLL
-
-/*!
- \class QGenericPluginFactory
- \ingroup qpa
-
- \brief The QGenericPluginFactory class creates window-system
- related plugin drivers in Qt QPA.
-
- Note that this class is only available in \l{Qt QPA}.
-
-
- \sa QGenericPlugin
-*/
-
-/*!
- Creates the driver specified by \a key, using the given \a specification.
-
- Note that the keys are case-insensitive.
-
- \sa keys()
-*/
-QObject *QGenericPluginFactory::create(const QString& key, const QString &specification)
-{
- QString driver = key.toLower();
-
-#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
-#ifndef QT_NO_LIBRARY
- if (QGenericPluginFactoryInterface *factory = qobject_cast<QGenericPluginFactoryInterface*>(loader()->instance(driver)))
- return factory->create(driver, specification);
-#endif
-#endif
- return 0;
-}
-
-/*!
- Returns the list of valid keys, i.e. the available mouse drivers.
-
- \sa create()
-*/
-QStringList QGenericPluginFactory::keys()
-{
- QStringList list;
-
-#if !defined(Q_OS_WIN32) || defined(QT_MAKEDLL)
-#ifndef QT_NO_LIBRARY
- QStringList plugins = loader()->keys();
- for (int i = 0; i < plugins.size(); ++i) {
- if (!list.contains(plugins.at(i)))
- list += plugins.at(i);
- }
-#endif //QT_NO_LIBRARY
-#endif //QT_MAKEDLL
- return list;
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp
deleted file mode 100644
index 56daba2efc..0000000000
--- a/src/gui/kernel/qgesture.cpp
+++ /dev/null
@@ -1,807 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgesture.h"
-#include "private/qgesture_p.h"
-#include "private/qstandardgestures_p.h"
-
-#ifndef QT_NO_GESTURES
-
-QT_BEGIN_NAMESPACE
-
- /*!
- \class QGesture
- \since 4.6
- \ingroup gestures
-
- \brief The QGesture class represents a gesture, containing properties that
- describe the corresponding user input.
-
- Gesture objects are not constructed directly by developers. They are created by
- the QGestureRecognizer object that is registered with the application; see
- QGestureRecognizer::registerRecognizer().
-
- For an overview of gesture handling in Qt and information on using gestures
- in your applications, see the \l{Gestures Programming} document.
-
- \section1 Gesture Properties
-
- The class has a list of properties that can be queried by the user to get
- some gesture-specific arguments. For example, the pinch gesture has a scale
- factor that is exposed as a property.
-
- Developers of custom gesture recognizers can add additional properties in
- order to provide additional information about a gesture. This can be done
- by adding new dynamic properties to a QGesture object, or by subclassing
- the QGesture class (or one of its subclasses).
-
- \section1 Lifecycle of a Gesture Object
-
- A QGesture instance is implicitly created when needed and is owned by Qt.
- Developers should never destroy them or store them for later use as Qt may
- destroy particular instances of them and create new ones to replace them.
-
- The registered gesture recognizer monitors the input events for the target
- object via its \l{QGestureRecognizer::}{recognize()} function, updating the
- properties of the gesture object as required.
-
- The gesture object may be delivered to the target object in a QGestureEvent if
- the corresponding gesture is active or has just been canceled. Each event that
- is delivered contains a list of gesture objects, since support for more than
- one gesture may be enabled for the target object. Due to the way events are
- handled in Qt, gesture events may be filtered by other objects.
-
- \sa QGestureEvent, QGestureRecognizer
-*/
-
-/*!
- Constructs a new gesture object with the given \a parent.
-
- QGesture objects are created by gesture recognizers in the
- QGestureRecognizer::create() function.
-*/
-QGesture::QGesture(QObject *parent)
- : QObject(*new QGesturePrivate, parent)
-{
- d_func()->gestureType = Qt::CustomGesture;
-}
-
-/*!
- \internal
-*/
-QGesture::QGesture(QGesturePrivate &dd, QObject *parent)
- : QObject(dd, parent)
-{
-}
-
-/*!
- Destroys the gesture object.
-*/
-QGesture::~QGesture()
-{
-}
-
-/*!
- \property QGesture::state
- \brief the current state of the gesture
-*/
-
-/*!
- \property QGesture::gestureType
- \brief the type of the gesture
-*/
-
-/*!
- \property QGesture::hotSpot
-
- \brief The point that is used to find the receiver for the gesture event.
-
- The hot-spot is a point in the global coordinate system, use
- QWidget::mapFromGlobal() or QGestureEvent::mapToGraphicsScene() to get a
- local hot-spot.
-
- The hot-spot should be set by the gesture recognizer to allow gesture event
- delivery to a QGraphicsObject.
-*/
-
-/*!
- \property QGesture::hasHotSpot
- \brief whether the gesture has a hot-spot
-*/
-
-Qt::GestureType QGesture::gestureType() const
-{
- return d_func()->gestureType;
-}
-
-Qt::GestureState QGesture::state() const
-{
- return d_func()->state;
-}
-
-QPointF QGesture::hotSpot() const
-{
- return d_func()->hotSpot;
-}
-
-void QGesture::setHotSpot(const QPointF &value)
-{
- Q_D(QGesture);
- d->hotSpot = value;
- d->isHotSpotSet = true;
-}
-
-bool QGesture::hasHotSpot() const
-{
- return d_func()->isHotSpotSet;
-}
-
-void QGesture::unsetHotSpot()
-{
- d_func()->isHotSpotSet = false;
-}
-
-/*!
- \property QGesture::gestureCancelPolicy
- \brief the policy for deciding what happens on accepting a gesture
-
- On accepting one gesture Qt can automatically cancel other gestures
- that belong to other targets. The policy is normally set to not cancel
- any other gestures and can be set to cancel all active gestures in the
- context. For example for all child widgets.
-*/
-
-/*!
- \enum QGesture::GestureCancelPolicy
-
- This enum describes how accepting a gesture can cancel other gestures
- automatically.
-
- \value CancelNone On accepting this gesture no other gestures will be affected.
-
- \value CancelAllInContext On accepting this gesture all gestures that are
- active in the context (respecting the Qt::GestureFlag that were specified
- when subscribed to the gesture) will be cancelled.
-*/
-
-void QGesture::setGestureCancelPolicy(GestureCancelPolicy policy)
-{
- Q_D(QGesture);
- d->gestureCancelPolicy = static_cast<uint>(policy);
-}
-
-QGesture::GestureCancelPolicy QGesture::gestureCancelPolicy() const
-{
- Q_D(const QGesture);
- return static_cast<GestureCancelPolicy>(d->gestureCancelPolicy);
-}
-
-/*!
- \class QPanGesture
- \since 4.6
- \brief The QPanGesture class describes a panning gesture made by the user.
- \ingroup gestures
-
- \image pangesture.png
-
- For an overview of gesture handling in Qt and information on using gestures
- in your applications, see the \l{Gestures Programming} document.
-
- \sa QPinchGesture, QSwipeGesture
-*/
-
-/*!
- \property QPanGesture::lastOffset
- \brief the last offset recorded for this gesture
-
- The last offset contains the change in position of the user's input as
- reported in the \l offset property when a previous gesture event was
- delivered for this gesture.
-
- If no previous event was delivered with information about this gesture
- (i.e., this gesture object contains information about the first movement
- in the gesture) then this property contains a zero size.
-*/
-
-/*!
- \property QPanGesture::offset
- \brief the total offset from the first input position to the current input
- position
-
- The offset measures the total change in position of the user's input
- covered by the gesture on the input device.
-*/
-
-/*!
- \property QPanGesture::delta
- \brief the offset from the previous input position to the current input
-
- This is essentially the same as the difference between offset() and
- lastOffset().
-*/
-
-/*!
- \property QPanGesture::acceleration
- \brief the acceleration in the motion of the touch point for this gesture
-*/
-
-/*!
- \property QPanGesture::horizontalVelocity
- \brief the horizontal component of the motion of the touch point for this
- gesture
- \since 4.7.1
- \internal
-
- \sa verticalVelocity, acceleration
-*/
-
-/*!
- \property QPanGesture::verticalVelocity
- \brief the vertical component of the motion of the touch point for this
- gesture
- \since 4.7.1
- \internal
-
- \sa horizontalVelocity, acceleration
-*/
-
-/*!
- \internal
-*/
-QPanGesture::QPanGesture(QObject *parent)
- : QGesture(*new QPanGesturePrivate, parent)
-{
- d_func()->gestureType = Qt::PanGesture;
-}
-
-
-QPointF QPanGesture::lastOffset() const
-{
- return d_func()->lastOffset;
-}
-
-QPointF QPanGesture::offset() const
-{
- return d_func()->offset;
-}
-
-QPointF QPanGesture::delta() const
-{
- Q_D(const QPanGesture);
- return d->offset - d->lastOffset;
-}
-
-qreal QPanGesture::acceleration() const
-{
- return d_func()->acceleration;
-}
-
-void QPanGesture::setLastOffset(const QPointF &value)
-{
- d_func()->lastOffset = value;
-}
-
-void QPanGesture::setOffset(const QPointF &value)
-{
- d_func()->offset = value;
-}
-
-void QPanGesture::setAcceleration(qreal value)
-{
- d_func()->acceleration = value;
-}
-
-/*!
- \class QPinchGesture
- \since 4.6
- \brief The QPinchGesture class describes a pinch gesture made by the user.
- \ingroup touch
- \ingroup gestures
-
- A pinch gesture is a form of touch user input in which the user typically
- touches two points on the input device with a thumb and finger, before moving
- them closer together or further apart to change the scale factor, zoom, or level
- of detail of the user interface.
-
- For an overview of gesture handling in Qt and information on using gestures
- in your applications, see the \l{Gestures Programming} document.
-
- \image pinchgesture.png
-
- Instead of repeatedly applying the same pinching gesture, the user may
- continue to touch the input device in one place, and apply a second touch
- to a new point, continuing the gesture. When this occurs, gesture events
- will continue to be delivered to the target object, containing an instance
- of QPinchGesture in the Qt::GestureUpdated state.
-
- \sa QPanGesture, QSwipeGesture
-*/
-
-/*!
- \enum QPinchGesture::ChangeFlag
-
- This enum describes the changes that can occur to the properties of
- the gesture object.
-
- \value ScaleFactorChanged The scale factor held by scaleFactor changed.
- \value RotationAngleChanged The rotation angle held by rotationAngle changed.
- \value CenterPointChanged The center point held by centerPoint changed.
-
- \sa changeFlags, totalChangeFlags
-*/
-
-/*!
- \property QPinchGesture::totalChangeFlags
- \brief the property of the gesture that has change
-
- This property indicates which of the other properties has changed since the
- gesture has started. You can use this information to determine which aspect
- of your user interface needs to be updated.
-
- \sa changeFlags, scaleFactor, rotationAngle, centerPoint
-*/
-
-/*!
- \property QPinchGesture::changeFlags
- \brief the property of the gesture that has changed in the current step
-
- This property indicates which of the other properties has changed since
- the previous gesture event included information about this gesture. You
- can use this information to determine which aspect of your user interface
- needs to be updated.
-
- \sa totalChangeFlags, scaleFactor, rotationAngle, centerPoint
-*/
-
-/*!
- \property QPinchGesture::totalScaleFactor
- \brief the total scale factor
-
- The total scale factor measures the total change in scale factor from the
- original value to the current scale factor.
-
- \sa scaleFactor, lastScaleFactor
-*/
-/*!
- \property QPinchGesture::lastScaleFactor
- \brief the last scale factor recorded for this gesture
-
- The last scale factor contains the scale factor reported in the
- \l scaleFactor property when a previous gesture event included
- information about this gesture.
-
- If no previous event was delivered with information about this gesture
- (i.e., this gesture object contains information about the first movement
- in the gesture) then this property contains zero.
-
- \sa scaleFactor, totalScaleFactor
-*/
-/*!
- \property QPinchGesture::scaleFactor
- \brief the current scale factor
-
- The scale factor measures the scale factor associated with the distance
- between two of the user's inputs on a touch device.
-
- \sa totalScaleFactor, lastScaleFactor
-*/
-
-/*!
- \property QPinchGesture::totalRotationAngle
- \brief the total angle covered by the gesture
-
- This total angle measures the complete angle covered by the gesture. Usually, this
- is equal to the value held by the \l rotationAngle property, except in the case where
- the user performs multiple rotations by removing and repositioning one of the touch
- points, as described above. In this case, the total angle will be the sum of the
- rotation angles for the multiple stages of the gesture.
-
- \sa rotationAngle, lastRotationAngle
-*/
-/*!
- \property QPinchGesture::lastRotationAngle
- \brief the last reported angle covered by the gesture motion
-
- The last rotation angle is the angle as reported in the \l rotationAngle property
- when a previous gesture event was delivered for this gesture.
-
- \sa rotationAngle, totalRotationAngle
-*/
-/*!
- \property QPinchGesture::rotationAngle
- \brief the angle covered by the gesture motion
-
- \sa totalRotationAngle, lastRotationAngle
-*/
-
-/*!
- \property QPinchGesture::startCenterPoint
- \brief the starting position of the center point
-
- \sa centerPoint, lastCenterPoint
-*/
-/*!
- \property QPinchGesture::lastCenterPoint
- \brief the last position of the center point recorded for this gesture
-
- \sa centerPoint, startCenterPoint
-*/
-/*!
- \property QPinchGesture::centerPoint
- \brief the current center point
-
- The center point is the midpoint between the two input points in the gesture.
-
- \sa startCenterPoint, lastCenterPoint
-*/
-
-/*!
- \internal
-*/
-QPinchGesture::QPinchGesture(QObject *parent)
- : QGesture(*new QPinchGesturePrivate, parent)
-{
- d_func()->gestureType = Qt::PinchGesture;
-}
-
-QPinchGesture::ChangeFlags QPinchGesture::totalChangeFlags() const
-{
- return d_func()->totalChangeFlags;
-}
-
-void QPinchGesture::setTotalChangeFlags(QPinchGesture::ChangeFlags value)
-{
- d_func()->totalChangeFlags = value;
-}
-
-QPinchGesture::ChangeFlags QPinchGesture::changeFlags() const
-{
- return d_func()->changeFlags;
-}
-
-void QPinchGesture::setChangeFlags(QPinchGesture::ChangeFlags value)
-{
- d_func()->changeFlags = value;
-}
-
-QPointF QPinchGesture::startCenterPoint() const
-{
- return d_func()->startCenterPoint;
-}
-
-QPointF QPinchGesture::lastCenterPoint() const
-{
- return d_func()->lastCenterPoint;
-}
-
-QPointF QPinchGesture::centerPoint() const
-{
- return d_func()->centerPoint;
-}
-
-void QPinchGesture::setStartCenterPoint(const QPointF &value)
-{
- d_func()->startCenterPoint = value;
-}
-
-void QPinchGesture::setLastCenterPoint(const QPointF &value)
-{
- d_func()->lastCenterPoint = value;
-}
-
-void QPinchGesture::setCenterPoint(const QPointF &value)
-{
- d_func()->centerPoint = value;
-}
-
-
-qreal QPinchGesture::totalScaleFactor() const
-{
- return d_func()->totalScaleFactor;
-}
-
-qreal QPinchGesture::lastScaleFactor() const
-{
- return d_func()->lastScaleFactor;
-}
-
-qreal QPinchGesture::scaleFactor() const
-{
- return d_func()->scaleFactor;
-}
-
-void QPinchGesture::setTotalScaleFactor(qreal value)
-{
- d_func()->totalScaleFactor = value;
-}
-
-void QPinchGesture::setLastScaleFactor(qreal value)
-{
- d_func()->lastScaleFactor = value;
-}
-
-void QPinchGesture::setScaleFactor(qreal value)
-{
- d_func()->scaleFactor = value;
-}
-
-
-qreal QPinchGesture::totalRotationAngle() const
-{
- return d_func()->totalRotationAngle;
-}
-
-qreal QPinchGesture::lastRotationAngle() const
-{
- return d_func()->lastRotationAngle;
-}
-
-qreal QPinchGesture::rotationAngle() const
-{
- return d_func()->rotationAngle;
-}
-
-void QPinchGesture::setTotalRotationAngle(qreal value)
-{
- d_func()->totalRotationAngle = value;
-}
-
-void QPinchGesture::setLastRotationAngle(qreal value)
-{
- d_func()->lastRotationAngle = value;
-}
-
-void QPinchGesture::setRotationAngle(qreal value)
-{
- d_func()->rotationAngle = value;
-}
-
-/*!
- \class QSwipeGesture
- \since 4.6
- \brief The QSwipeGesture class describes a swipe gesture made by the user.
- \ingroup gestures
-
- \image swipegesture.png
-
- For an overview of gesture handling in Qt and information on using gestures
- in your applications, see the \l{Gestures Programming} document.
-
- \sa QPanGesture, QPinchGesture
-*/
-
-/*!
- \enum QSwipeGesture::SwipeDirection
-
- This enum describes the possible directions for the gesture's motion
- along the horizontal and vertical axes.
-
- \value NoDirection The gesture had no motion associated with it on a particular axis.
- \value Left The gesture involved a horizontal motion to the left.
- \value Right The gesture involved a horizontal motion to the right.
- \value Up The gesture involved an upward vertical motion.
- \value Down The gesture involved a downward vertical motion.
-*/
-
-/*!
- \property QSwipeGesture::horizontalDirection
- \brief the horizontal direction of the gesture
-
- If the gesture has a horizontal component, the horizontal direction
- is either Left or Right; otherwise, it is NoDirection.
-
- \sa verticalDirection, swipeAngle
-*/
-
-/*!
- \property QSwipeGesture::verticalDirection
- \brief the vertical direction of the gesture
-
- If the gesture has a vertical component, the vertical direction
- is either Up or Down; otherwise, it is NoDirection.
-
- \sa horizontalDirection, swipeAngle
-*/
-
-/*!
- \property QSwipeGesture::swipeAngle
- \brief the angle of the motion associated with the gesture
-
- If the gesture has either a horizontal or vertical component, the
- swipe angle describes the angle between the direction of motion and the
- x-axis as defined using the standard widget
- \l{Coordinate System}{coordinate system}.
-
- \sa horizontalDirection, verticalDirection
-*/
-
-/*!
- \property QSwipeGesture::velocity
- \since 4.7.1
- \internal
-*/
-
-/*!
- \internal
-*/
-QSwipeGesture::QSwipeGesture(QObject *parent)
- : QGesture(*new QSwipeGesturePrivate, parent)
-{
- d_func()->gestureType = Qt::SwipeGesture;
-}
-
-QSwipeGesture::SwipeDirection QSwipeGesture::horizontalDirection() const
-{
- Q_D(const QSwipeGesture);
- if (d->swipeAngle < 0 || d->swipeAngle == 90 || d->swipeAngle == 270)
- return QSwipeGesture::NoDirection;
- else if (d->swipeAngle < 90 || d->swipeAngle > 270)
- return QSwipeGesture::Right;
- else
- return QSwipeGesture::Left;
-}
-
-QSwipeGesture::SwipeDirection QSwipeGesture::verticalDirection() const
-{
- Q_D(const QSwipeGesture);
- if (d->swipeAngle <= 0 || d->swipeAngle == 180)
- return QSwipeGesture::NoDirection;
- else if (d->swipeAngle < 180)
- return QSwipeGesture::Up;
- else
- return QSwipeGesture::Down;
-}
-
-qreal QSwipeGesture::swipeAngle() const
-{
- return d_func()->swipeAngle;
-}
-
-void QSwipeGesture::setSwipeAngle(qreal value)
-{
- d_func()->swipeAngle = value;
-}
-
-/*!
- \class QTapGesture
- \since 4.6
- \brief The QTapGesture class describes a tap gesture made by the user.
- \ingroup gestures
-
- For an overview of gesture handling in Qt and information on using gestures
- in your applications, see the \l{Gestures Programming} document.
-
- \sa QPanGesture, QPinchGesture
-*/
-
-/*!
- \property QTapGesture::position
- \brief the position of the tap
-*/
-
-/*!
- \internal
-*/
-QTapGesture::QTapGesture(QObject *parent)
- : QGesture(*new QTapGesturePrivate, parent)
-{
- d_func()->gestureType = Qt::TapGesture;
-}
-
-QPointF QTapGesture::position() const
-{
- return d_func()->position;
-}
-
-void QTapGesture::setPosition(const QPointF &value)
-{
- d_func()->position = value;
-}
-/*!
- \class QTapAndHoldGesture
- \since 4.6
- \brief The QTapAndHoldGesture class describes a tap-and-hold (aka LongTap)
- gesture made by the user.
- \ingroup gestures
-
- For an overview of gesture handling in Qt and information on using gestures
- in your applications, see the \l{Gestures Programming} document.
-
- \sa QPanGesture, QPinchGesture
-*/
-
-/*!
- \property QTapAndHoldGesture::position
- \brief the position of the tap
-*/
-
-/*!
- \internal
-*/
-QTapAndHoldGesture::QTapAndHoldGesture(QObject *parent)
- : QGesture(*new QTapAndHoldGesturePrivate, parent)
-{
- d_func()->gestureType = Qt::TapAndHoldGesture;
-}
-
-QPointF QTapAndHoldGesture::position() const
-{
- return d_func()->position;
-}
-
-void QTapAndHoldGesture::setPosition(const QPointF &value)
-{
- d_func()->position = value;
-}
-
-/*!
- Set the timeout, in milliseconds, before the gesture triggers.
-
- The recognizer will detect a touch down and and if \a msecs
- later the touch is still down, it will trigger the QTapAndHoldGesture.
- The default value is 700 milliseconds.
-*/
-// static
-void QTapAndHoldGesture::setTimeout(int msecs)
-{
- QTapAndHoldGesturePrivate::Timeout = msecs;
-}
-
-/*!
- Gets the timeout, in milliseconds, before the gesture triggers.
-
- The recognizer will detect a touch down and and if timeout()
- later the touch is still down, it will trigger the QTapAndHoldGesture.
- The default value is 700 milliseconds.
-*/
-// static
-int QTapAndHoldGesture::timeout()
-{
- return QTapAndHoldGesturePrivate::Timeout;
-}
-
-int QTapAndHoldGesturePrivate::Timeout = 700; // in ms
-
-QT_END_NAMESPACE
-
-#include <moc_qgesture.cpp>
-
-#endif // QT_NO_GESTURES
diff --git a/src/gui/kernel/qgesture.h b/src/gui/kernel/qgesture.h
deleted file mode 100644
index 6f9c994b1e..0000000000
--- a/src/gui/kernel/qgesture.h
+++ /dev/null
@@ -1,275 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGESTURE_H
-#define QGESTURE_H
-
-#include <QtCore/qobject.h>
-#include <QtCore/qlist.h>
-#include <QtCore/qdatetime.h>
-#include <QtCore/qpoint.h>
-#include <QtCore/qrect.h>
-#include <QtCore/qmetatype.h>
-
-#ifndef QT_NO_GESTURES
-
-QT_BEGIN_HEADER
-
-Q_DECLARE_METATYPE(Qt::GestureState)
-Q_DECLARE_METATYPE(Qt::GestureType)
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QGesturePrivate;
-class Q_GUI_EXPORT QGesture : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QGesture)
-
- Q_PROPERTY(Qt::GestureState state READ state)
- Q_PROPERTY(Qt::GestureType gestureType READ gestureType)
- Q_PROPERTY(QGesture::GestureCancelPolicy gestureCancelPolicy READ gestureCancelPolicy WRITE setGestureCancelPolicy)
- Q_PROPERTY(QPointF hotSpot READ hotSpot WRITE setHotSpot RESET unsetHotSpot)
- Q_PROPERTY(bool hasHotSpot READ hasHotSpot)
-
-public:
- explicit QGesture(QObject *parent = 0);
- ~QGesture();
-
- Qt::GestureType gestureType() const;
-
- Qt::GestureState state() const;
-
- QPointF hotSpot() const;
- void setHotSpot(const QPointF &value);
- bool hasHotSpot() const;
- void unsetHotSpot();
-
- enum GestureCancelPolicy {
- CancelNone = 0,
- CancelAllInContext
- };
-
- void setGestureCancelPolicy(GestureCancelPolicy policy);
- GestureCancelPolicy gestureCancelPolicy() const;
-
-protected:
- QGesture(QGesturePrivate &dd, QObject *parent);
-
-private:
- friend class QGestureEvent;
- friend class QGestureRecognizer;
- friend class QGestureManager;
- friend class QGraphicsScenePrivate;
-};
-
-class QPanGesturePrivate;
-class Q_GUI_EXPORT QPanGesture : public QGesture
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QPanGesture)
-
- Q_PROPERTY(QPointF lastOffset READ lastOffset WRITE setLastOffset)
- Q_PROPERTY(QPointF offset READ offset WRITE setOffset)
- Q_PROPERTY(QPointF delta READ delta STORED false)
- Q_PROPERTY(qreal acceleration READ acceleration WRITE setAcceleration)
- Q_PRIVATE_PROPERTY(QPanGesture::d_func(), qreal horizontalVelocity READ horizontalVelocity WRITE setHorizontalVelocity)
- Q_PRIVATE_PROPERTY(QPanGesture::d_func(), qreal verticalVelocity READ verticalVelocity WRITE setVerticalVelocity)
-
-public:
- QPanGesture(QObject *parent = 0);
-
- QPointF lastOffset() const;
- QPointF offset() const;
- QPointF delta() const;
- qreal acceleration() const;
-
- void setLastOffset(const QPointF &value);
- void setOffset(const QPointF &value);
- void setAcceleration(qreal value);
-
- friend class QPanGestureRecognizer;
- friend class QWinNativePanGestureRecognizer;
-};
-
-class QPinchGesturePrivate;
-class Q_GUI_EXPORT QPinchGesture : public QGesture
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QPinchGesture)
- Q_FLAGS(ChangeFlags ChangeFlag)
-
-public:
- enum ChangeFlag {
- ScaleFactorChanged = 0x1,
- RotationAngleChanged = 0x2,
- CenterPointChanged = 0x4
- };
- Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)
-
- Q_PROPERTY(ChangeFlags totalChangeFlags READ totalChangeFlags WRITE setTotalChangeFlags)
- Q_PROPERTY(ChangeFlags changeFlags READ changeFlags WRITE setChangeFlags)
-
- Q_PROPERTY(qreal totalScaleFactor READ totalScaleFactor WRITE setTotalScaleFactor)
- Q_PROPERTY(qreal lastScaleFactor READ lastScaleFactor WRITE setLastScaleFactor)
- Q_PROPERTY(qreal scaleFactor READ scaleFactor WRITE setScaleFactor)
-
- Q_PROPERTY(qreal totalRotationAngle READ totalRotationAngle WRITE setTotalRotationAngle)
- Q_PROPERTY(qreal lastRotationAngle READ lastRotationAngle WRITE setLastRotationAngle)
- Q_PROPERTY(qreal rotationAngle READ rotationAngle WRITE setRotationAngle)
-
- Q_PROPERTY(QPointF startCenterPoint READ startCenterPoint WRITE setStartCenterPoint)
- Q_PROPERTY(QPointF lastCenterPoint READ lastCenterPoint WRITE setLastCenterPoint)
- Q_PROPERTY(QPointF centerPoint READ centerPoint WRITE setCenterPoint)
-
-public:
- QPinchGesture(QObject *parent = 0);
-
- ChangeFlags totalChangeFlags() const;
- void setTotalChangeFlags(ChangeFlags value);
-
- ChangeFlags changeFlags() const;
- void setChangeFlags(ChangeFlags value);
-
- QPointF startCenterPoint() const;
- QPointF lastCenterPoint() const;
- QPointF centerPoint() const;
- void setStartCenterPoint(const QPointF &value);
- void setLastCenterPoint(const QPointF &value);
- void setCenterPoint(const QPointF &value);
-
- qreal totalScaleFactor() const;
- qreal lastScaleFactor() const;
- qreal scaleFactor() const;
- void setTotalScaleFactor(qreal value);
- void setLastScaleFactor(qreal value);
- void setScaleFactor(qreal value);
-
- qreal totalRotationAngle() const;
- qreal lastRotationAngle() const;
- qreal rotationAngle() const;
- void setTotalRotationAngle(qreal value);
- void setLastRotationAngle(qreal value);
- void setRotationAngle(qreal value);
-
- friend class QPinchGestureRecognizer;
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QPinchGesture::ChangeFlags)
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QPinchGesture::ChangeFlags)
-
-QT_BEGIN_NAMESPACE
-
-class QSwipeGesturePrivate;
-class Q_GUI_EXPORT QSwipeGesture : public QGesture
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QSwipeGesture)
- Q_ENUMS(SwipeDirection)
-
- Q_PROPERTY(SwipeDirection horizontalDirection READ horizontalDirection STORED false)
- Q_PROPERTY(SwipeDirection verticalDirection READ verticalDirection STORED false)
- Q_PROPERTY(qreal swipeAngle READ swipeAngle WRITE setSwipeAngle)
- Q_PRIVATE_PROPERTY(QSwipeGesture::d_func(), qreal velocity READ velocity WRITE setVelocity)
-
-public:
- enum SwipeDirection { NoDirection, Left, Right, Up, Down };
- QSwipeGesture(QObject *parent = 0);
-
- SwipeDirection horizontalDirection() const;
- SwipeDirection verticalDirection() const;
-
- qreal swipeAngle() const;
- void setSwipeAngle(qreal value);
-
- friend class QSwipeGestureRecognizer;
-};
-
-class QTapGesturePrivate;
-class Q_GUI_EXPORT QTapGesture : public QGesture
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QTapGesture)
-
- Q_PROPERTY(QPointF position READ position WRITE setPosition)
-
-public:
- QTapGesture(QObject *parent = 0);
-
- QPointF position() const;
- void setPosition(const QPointF &pos);
-
- friend class QTapGestureRecognizer;
-};
-
-class QTapAndHoldGesturePrivate;
-class Q_GUI_EXPORT QTapAndHoldGesture : public QGesture
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QTapAndHoldGesture)
-
- Q_PROPERTY(QPointF position READ position WRITE setPosition)
-
-public:
- QTapAndHoldGesture(QObject *parent = 0);
-
- QPointF position() const;
- void setPosition(const QPointF &pos);
-
- static void setTimeout(int msecs);
- static int timeout();
-
- friend class QTapAndHoldGestureRecognizer;
-};
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QGesture::GestureCancelPolicy)
-QT_END_HEADER
-
-#endif // QT_NO_GESTURES
-
-#endif // QGESTURE_H
diff --git a/src/gui/kernel/qgesture_p.h b/src/gui/kernel/qgesture_p.h
deleted file mode 100644
index 4fd4446cb6..0000000000
--- a/src/gui/kernel/qgesture_p.h
+++ /dev/null
@@ -1,197 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGESTURE_P_H
-#define QGESTURE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qrect.h"
-#include "qpoint.h"
-#include "qgesture.h"
-#include "qelapsedtimer.h"
-#include "private/qobject_p.h"
-
-#ifndef QT_NO_GESTURES
-
-QT_BEGIN_NAMESPACE
-
-class QGesturePrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QGesture)
-
-public:
- QGesturePrivate()
- : gestureType(Qt::CustomGesture), state(Qt::NoGesture),
- isHotSpotSet(false), gestureCancelPolicy(0)
- {
- }
-
- Qt::GestureType gestureType;
- Qt::GestureState state;
- QPointF hotSpot;
- QPointF sceneHotSpot;
- uint isHotSpotSet : 1;
- uint gestureCancelPolicy : 2;
-};
-
-class QPanGesturePrivate : public QGesturePrivate
-{
- Q_DECLARE_PUBLIC(QPanGesture)
-
-public:
- QPanGesturePrivate()
- : acceleration(0), xVelocity(0), yVelocity(0)
- {
- }
-
- qreal horizontalVelocity() const { return xVelocity; }
- void setHorizontalVelocity(qreal value) { xVelocity = value; }
- qreal verticalVelocity() const { return yVelocity; }
- void setVerticalVelocity(qreal value) { yVelocity = value; }
-
- QPointF lastOffset;
- QPointF offset;
- QPoint startPosition;
- qreal acceleration;
- qreal xVelocity;
- qreal yVelocity;
-};
-
-class QPinchGesturePrivate : public QGesturePrivate
-{
- Q_DECLARE_PUBLIC(QPinchGesture)
-
-public:
- QPinchGesturePrivate()
- : totalChangeFlags(0), changeFlags(0),
- totalScaleFactor(1), lastScaleFactor(1), scaleFactor(1),
- totalRotationAngle(0), lastRotationAngle(0), rotationAngle(0),
- isNewSequence(true)
- {
- }
-
- QPinchGesture::ChangeFlags totalChangeFlags;
- QPinchGesture::ChangeFlags changeFlags;
-
- QPointF startCenterPoint;
- QPointF lastCenterPoint;
- QPointF centerPoint;
-
- qreal totalScaleFactor;
- qreal lastScaleFactor;
- qreal scaleFactor;
-
- qreal totalRotationAngle;
- qreal lastRotationAngle;
- qreal rotationAngle;
-
- bool isNewSequence;
- QPointF startPosition[2];
-};
-
-class QSwipeGesturePrivate : public QGesturePrivate
-{
- Q_DECLARE_PUBLIC(QSwipeGesture)
-
-public:
- QSwipeGesturePrivate()
- : horizontalDirection(QSwipeGesture::NoDirection),
- verticalDirection(QSwipeGesture::NoDirection),
- swipeAngle(0),
- started(false), velocityValue(0)
- {
- }
-
- qreal velocity() const { return velocityValue; }
- void setVelocity(qreal value) { velocityValue = value; }
-
- QSwipeGesture::SwipeDirection horizontalDirection;
- QSwipeGesture::SwipeDirection verticalDirection;
- qreal swipeAngle;
-
- QPoint lastPositions[3];
- bool started;
- qreal velocityValue;
- QElapsedTimer time;
-};
-
-class QTapGesturePrivate : public QGesturePrivate
-{
- Q_DECLARE_PUBLIC(QTapGesture)
-
-public:
- QTapGesturePrivate()
- {
- }
-
- QPointF position;
-};
-
-class QTapAndHoldGesturePrivate : public QGesturePrivate
-{
- Q_DECLARE_PUBLIC(QTapAndHoldGesture)
-
-public:
- QTapAndHoldGesturePrivate()
- : timerId(0)
- {
- }
-
- QPointF position;
- int timerId;
- static int Timeout;
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_GESTURES
-
-#endif // QGESTURE_P_H
diff --git a/src/gui/kernel/qgridlayout.h b/src/gui/kernel/qgridlayout.h
deleted file mode 100644
index 0ac66e8f87..0000000000
--- a/src/gui/kernel/qgridlayout.h
+++ /dev/null
@@ -1,176 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRIDLAYOUT_H
-#define QGRIDLAYOUT_H
-
-#include <QtGui/qlayout.h>
-#ifdef QT_INCLUDE_COMPAT
-#include <QtGui/qwidget.h>
-#endif
-
-#include <limits.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QGridLayoutPrivate;
-
-class Q_GUI_EXPORT QGridLayout : public QLayout
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QGridLayout)
- QDOC_PROPERTY(int horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing)
- QDOC_PROPERTY(int verticalSpacing READ verticalSpacing WRITE setVerticalSpacing)
-
-public:
- explicit QGridLayout(QWidget *parent);
- QGridLayout();
-
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QGridLayout(QWidget *parent, int nRows , int nCols = 1, int border = 0,
- int spacing = -1, const char *name = 0);
- QT3_SUPPORT_CONSTRUCTOR QGridLayout(int nRows , int nCols = 1, int spacing = -1, const char *name = 0);
- QT3_SUPPORT_CONSTRUCTOR QGridLayout(QLayout *parentLayout, int nRows = 1, int nCols = 1, int spacing = -1,
- const char *name = 0);
-#endif
- ~QGridLayout();
-
- QSize sizeHint() const;
- QSize minimumSize() const;
- QSize maximumSize() const;
-
- void setHorizontalSpacing(int spacing);
- int horizontalSpacing() const;
- void setVerticalSpacing(int spacing);
- int verticalSpacing() const;
- void setSpacing(int spacing);
- int spacing() const;
-
- void setRowStretch(int row, int stretch);
- void setColumnStretch(int column, int stretch);
- int rowStretch(int row) const;
- int columnStretch(int column) const;
-
- void setRowMinimumHeight(int row, int minSize);
- void setColumnMinimumWidth(int column, int minSize);
- int rowMinimumHeight(int row) const;
- int columnMinimumWidth(int column) const;
-
- int columnCount() const;
- int rowCount() const;
-
- QRect cellRect(int row, int column) const;
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT QRect cellGeometry(int row, int column) const {return cellRect(row, column);}
-#endif
-
- bool hasHeightForWidth() const;
- int heightForWidth(int) const;
- int minimumHeightForWidth(int) const;
-
- Qt::Orientations expandingDirections() const;
- void invalidate();
-
- inline void addWidget(QWidget *w) { QLayout::addWidget(w); }
- void addWidget(QWidget *, int row, int column, Qt::Alignment = 0);
- void addWidget(QWidget *, int row, int column, int rowSpan, int columnSpan, Qt::Alignment = 0);
- void addLayout(QLayout *, int row, int column, Qt::Alignment = 0);
- void addLayout(QLayout *, int row, int column, int rowSpan, int columnSpan, Qt::Alignment = 0);
-
- void setOriginCorner(Qt::Corner);
- Qt::Corner originCorner() const;
-
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT void setOrigin(Qt::Corner corner) { setOriginCorner(corner); }
- inline QT3_SUPPORT Qt::Corner origin() const { return originCorner(); }
-#endif
- QLayoutItem *itemAt(int index) const;
- QLayoutItem *itemAtPosition(int row, int column) const;
- QLayoutItem *takeAt(int index);
- int count() const;
- void setGeometry(const QRect&);
-
- void addItem(QLayoutItem *item, int row, int column, int rowSpan = 1, int columnSpan = 1, Qt::Alignment = 0);
-
- void setDefaultPositioning(int n, Qt::Orientation orient);
- void getItemPosition(int idx, int *row, int *column, int *rowSpan, int *columnSpan);
-
-protected:
-#ifdef QT3_SUPPORT
- QT3_SUPPORT bool findWidget(QWidget* w, int *r, int *c);
-#endif
- void addItem(QLayoutItem *);
-
-private:
- Q_DISABLE_COPY(QGridLayout)
-
-#ifdef QT3_SUPPORT
-public:
- QT3_SUPPORT void expand(int rows, int cols);
- inline QT3_SUPPORT void addRowSpacing(int row, int minsize) { addItem(new QSpacerItem(0,minsize), row, 0); }
- inline QT3_SUPPORT void addColSpacing(int col, int minsize) { addItem(new QSpacerItem(minsize,0), 0, col); }
- inline QT3_SUPPORT void addMultiCellWidget(QWidget *w, int fromRow, int toRow, int fromCol, int toCol, Qt::Alignment _align = 0)
- { addWidget(w, fromRow, fromCol, (toRow < 0) ? -1 : toRow - fromRow + 1, (toCol < 0) ? -1 : toCol - fromCol + 1, _align); }
- inline QT3_SUPPORT void addMultiCell(QLayoutItem *l, int fromRow, int toRow, int fromCol, int toCol, Qt::Alignment _align = 0)
- { addItem(l, fromRow, fromCol, (toRow < 0) ? -1 : toRow - fromRow + 1, (toCol < 0) ? -1 : toCol - fromCol + 1, _align); }
- inline QT3_SUPPORT void addMultiCellLayout(QLayout *layout, int fromRow, int toRow, int fromCol, int toCol, Qt::Alignment _align = 0)
- { addLayout(layout, fromRow, fromCol, (toRow < 0) ? -1 : toRow - fromRow + 1, (toCol < 0) ? -1 : toCol - fromCol + 1, _align); }
-
- inline QT3_SUPPORT int numRows() const { return rowCount(); }
- inline QT3_SUPPORT int numCols() const { return columnCount(); }
- inline QT3_SUPPORT void setColStretch(int col, int stretch) {setColumnStretch(col, stretch); }
- inline QT3_SUPPORT int colStretch(int col) const {return columnStretch(col); }
- inline QT3_SUPPORT void setColSpacing(int col, int minSize) { setColumnMinimumWidth(col, minSize); }
- inline QT3_SUPPORT int colSpacing(int col) const { return columnMinimumWidth(col); }
- inline QT3_SUPPORT void setRowSpacing(int row, int minSize) {setRowMinimumHeight(row, minSize); }
- inline QT3_SUPPORT int rowSpacing(int row) const {return rowMinimumHeight(row); }
-#endif
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QGRIDLAYOUT_H
diff --git a/src/gui/kernel/qguiplatformplugin_p.h b/src/gui/kernel/qguiplatformplugin_p.h
deleted file mode 100644
index 49e2d9294a..0000000000
--- a/src/gui/kernel/qguiplatformplugin_p.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGUIPLATFORM_P_H
-#define QGUIPLATFORM_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qplugin.h>
-#include <QtCore/qfactoryinterface.h>
-#include <QtGui/qdialog.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QStyle;
-class QPalette;
-class QIcon;
-class QFileDialog;
-class QColorDialog;
-class QFileInfo;
-
-struct Q_GUI_EXPORT QGuiPlatformPluginInterface : public QFactoryInterface
-{
-};
-
-#define QGuiPlatformPluginInterface_iid "com.nokia.qt.QGuiPlatformPluginInterface"
-
-Q_DECLARE_INTERFACE(QGuiPlatformPluginInterface, QGuiPlatformPluginInterface_iid)
-
-class Q_GUI_EXPORT QGuiPlatformPlugin : public QObject, public QGuiPlatformPluginInterface
-{
- Q_OBJECT
- Q_INTERFACES(QGuiPlatformPluginInterface:QFactoryInterface)
- public:
- explicit QGuiPlatformPlugin(QObject *parent = 0);
- ~QGuiPlatformPlugin();
-
- virtual QStringList keys() const { return QStringList() << QLatin1String("default"); };
-
- virtual QString styleName();
- virtual QPalette palette();
- virtual QString systemIconThemeName();
- virtual QStringList iconThemeSearchPaths();
- virtual QIcon fileSystemIcon(const QFileInfo &);
-
- enum PlatformHint { PH_ToolButtonStyle, PH_ToolBarIconSize, PH_ItemView_ActivateItemOnSingleClick };
- virtual int platformHint(PlatformHint hint);
-
-
- virtual void fileDialogDelete(QFileDialog *) {}
- virtual bool fileDialogSetVisible(QFileDialog *, bool) { return false; }
- virtual QDialog::DialogCode fileDialogResultCode(QFileDialog *) { return QDialog::Rejected; }
- virtual void fileDialogSetDirectory(QFileDialog *, const QString &) {}
- virtual QString fileDialogDirectory(const QFileDialog *) const { return QString(); }
- virtual void fileDialogSelectFile(QFileDialog *, const QString &) {}
- virtual QStringList fileDialogSelectedFiles(const QFileDialog *) const { return QStringList(); }
- virtual void fileDialogSetFilter(QFileDialog *) {}
- virtual void fileDialogSetNameFilters(QFileDialog *, const QStringList &) {}
- virtual void fileDialogSelectNameFilter(QFileDialog *, const QString &) {}
- virtual QString fileDialogSelectedNameFilter(const QFileDialog *) const { return QString(); }
-
- virtual void colorDialogDelete(QColorDialog *) {}
- virtual bool colorDialogSetVisible(QColorDialog *, bool) { return false; }
- virtual void colorDialogSetCurrentColor(QColorDialog *, const QColor &) {}
-};
-
-//internal
-QGuiPlatformPlugin *qt_guiPlatformPlugin();
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-
-#endif // QGUIPLATFORMPLUGIN_H
diff --git a/src/gui/kernel/qguivariant.cpp b/src/gui/kernel/qguivariant.cpp
deleted file mode 100644
index badff80834..0000000000
--- a/src/gui/kernel/qguivariant.cpp
+++ /dev/null
@@ -1,828 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qvariant.h"
-
-#include "qbitmap.h"
-#include "qbrush.h"
-#include "qcolor.h"
-#include "qcursor.h"
-#include "qdatastream.h"
-#include "qdebug.h"
-#include "qfont.h"
-#include "qicon.h"
-#include "qimage.h"
-#include "qkeysequence.h"
-#include "qtransform.h"
-#include "qmatrix.h"
-#include "qpalette.h"
-#include "qpen.h"
-#include "qpixmap.h"
-#include "qpolygon.h"
-#include "qregion.h"
-#include "qsizepolicy.h"
-#include "qtextformat.h"
-#include "qmatrix4x4.h"
-#include "qvector2d.h"
-#include "qvector3d.h"
-#include "qvector4d.h"
-#include "qquaternion.h"
-
-#include "private/qvariant_p.h"
-
-QT_BEGIN_NAMESPACE
-
-#ifdef QT3_SUPPORT
-extern QDataStream &qt_stream_out_qcolorgroup(QDataStream &s, const QColorGroup &g);
-extern QDataStream &qt_stream_in_qcolorgroup(QDataStream &s, QColorGroup &g);
-#endif
-
-Q_CORE_EXPORT const QVariant::Handler *qcoreVariantHandler();
-
-static void construct(QVariant::Private *x, const void *copy)
-{
- switch (x->type) {
- case QVariant::Bitmap:
- v_construct<QBitmap>(x, copy);
- break;
- case QVariant::Region:
- v_construct<QRegion>(x, copy);
- break;
- case QVariant::Polygon:
- v_construct<QPolygon>(x, copy);
- break;
- case QVariant::Font:
- v_construct<QFont>(x, copy);
- break;
- case QVariant::Pixmap:
- v_construct<QPixmap>(x, copy);
- break;
- case QVariant::Image:
- v_construct<QImage>(x, copy);
- break;
- case QVariant::Brush:
- v_construct<QBrush>(x, copy);
- break;
- case QVariant::Color:
- v_construct<QColor>(x, copy);
- break;
- case QVariant::Palette:
- v_construct<QPalette>(x, copy);
- break;
-#ifdef QT3_SUPPORT
- case QVariant::ColorGroup:
- v_construct<QColorGroup>(x, copy);
- break;
-#endif
-#ifndef QT_NO_ICON
- case QVariant::Icon:
- v_construct<QIcon>(x, copy);
- break;
-#endif
- case QVariant::Matrix:
- v_construct<QMatrix>(x, copy);
- break;
- case QVariant::Transform:
- v_construct<QTransform>(x, copy);
- break;
- case QVariant::TextFormat:
- v_construct<QTextFormat>(x, copy);
- break;
- case QVariant::TextLength:
- v_construct<QTextLength>(x, copy);
- break;
-#ifndef QT_NO_SHORTCUT
- case QVariant::KeySequence:
- v_construct<QKeySequence>(x, copy);
- break;
-#endif
- case QVariant::Pen:
- v_construct<QPen>(x, copy);
- break;
- case QVariant::SizePolicy:
- v_construct<QSizePolicy>(x, copy);
- break;
-#ifndef QT_NO_CURSOR
- case QVariant::Cursor:
- v_construct<QCursor>(x, copy);
- break;
-#endif
- case 62: {
- // small 'trick' to let a QVariant(Qt::blue) create a variant
- // of type QColor
- x->type = QVariant::Color;
- QColor color(*reinterpret_cast<const Qt::GlobalColor *>(copy));
- v_construct<QColor>(x, &color);
- break;
- }
-#ifndef QT_NO_MATRIX4X4
- case QVariant::Matrix4x4:
- v_construct<QMatrix4x4>(x, copy);
- break;
-#endif
-#ifndef QT_NO_VECTOR2D
- case QVariant::Vector2D:
- v_construct<QVector2D>(x, copy);
- break;
-#endif
-#ifndef QT_NO_VECTOR3D
- case QVariant::Vector3D:
- v_construct<QVector3D>(x, copy);
- break;
-#endif
-#ifndef QT_NO_VECTOR4D
- case QVariant::Vector4D:
- v_construct<QVector4D>(x, copy);
- break;
-#endif
-#ifndef QT_NO_QUATERNION
- case QVariant::Quaternion:
- v_construct<QQuaternion>(x, copy);
- break;
-#endif
- default:
- qcoreVariantHandler()->construct(x, copy);
- return;
- }
- x->is_null = !copy;
-}
-
-static void clear(QVariant::Private *d)
-{
- switch (d->type) {
- case QVariant::Bitmap:
- v_clear<QBitmap>(d);
- break;
- case QVariant::Cursor:
- v_clear<QCursor>(d);
- break;
- case QVariant::Region:
- v_clear<QRegion>(d);
- break;
- case QVariant::Polygon:
- v_clear<QPolygon>(d);
- break;
- case QVariant::Font:
- v_clear<QFont>(d);
- break;
- case QVariant::Pixmap:
- v_clear<QPixmap>(d);
- break;
- case QVariant::Image:
- v_clear<QImage>(d);
- break;
- case QVariant::Brush:
- v_clear<QBrush>(d);
- break;
- case QVariant::Color:
- v_clear<QColor>(d);
- break;
- case QVariant::Palette:
- v_clear<QPalette>(d);
- break;
-#ifdef QT3_SUPPORT
- case QVariant::ColorGroup:
- v_clear<QColorGroup>(d);
- break;
-#endif
-#ifndef QT_NO_ICON
- case QVariant::Icon:
- v_clear<QIcon>(d);
- break;
-#endif
- case QVariant::Matrix:
- v_clear<QMatrix>(d);
- break;
- case QVariant::Transform:
- v_clear<QTransform>(d);
- break;
- case QVariant::TextFormat:
- v_clear<QTextFormat>(d);
- break;
- case QVariant::TextLength:
- v_clear<QTextLength>(d);
- break;
- case QVariant::SizePolicy:
- v_clear<QSizePolicy>(d);
- break;
-#ifndef QT_NO_SHORTCUT
- case QVariant::KeySequence:
- v_clear<QKeySequence>(d);
- break;
-#endif
- case QVariant::Pen:
- v_clear<QPen>(d);
- break;
-#ifndef QT_NO_MATRIX4X4
- case QVariant::Matrix4x4:
- v_clear<QMatrix4x4>(d);
- break;
-#endif
-#ifndef QT_NO_VECTOR2D
- case QVariant::Vector2D:
- v_clear<QVector2D>(d);
- break;
-#endif
-#ifndef QT_NO_VECTOR3D
- case QVariant::Vector3D:
- v_clear<QVector3D>(d);
- break;
-#endif
-#ifndef QT_NO_VECTOR4D
- case QVariant::Vector4D:
- v_clear<QVector4D>(d);
- break;
-#endif
-#ifndef QT_NO_QUATERNION
- case QVariant::Quaternion:
- v_clear<QVector4D>(d);
- break;
-#endif
- default:
- qcoreVariantHandler()->clear(d);
- return;
- }
-
- d->type = QVariant::Invalid;
- d->is_null = true;
- d->is_shared = false;
-}
-
-
-static bool isNull(const QVariant::Private *d)
-{
- switch(d->type) {
- case QVariant::Bitmap:
- return v_cast<QBitmap>(d)->isNull();
- case QVariant::Region:
- return v_cast<QRegion>(d)->isEmpty();
- case QVariant::Polygon:
- return v_cast<QPolygon>(d)->isEmpty();
- case QVariant::Pixmap:
- return v_cast<QPixmap>(d)->isNull();
- case QVariant::Image:
- return v_cast<QImage>(d)->isNull();
-#ifndef QT_NO_ICON
- case QVariant::Icon:
- return v_cast<QIcon>(d)->isNull();
-#endif
- case QVariant::Matrix:
- case QVariant::TextFormat:
- case QVariant::TextLength:
- case QVariant::Cursor:
- case QVariant::StringList:
- case QVariant::Font:
- case QVariant::Brush:
- case QVariant::Color:
- case QVariant::Palette:
-#ifdef QT3_SUPPORT
- case QVariant::ColorGroup:
-#endif
- case QVariant::SizePolicy:
-#ifndef QT_NO_SHORTCUT
- case QVariant::KeySequence:
-#endif
- case QVariant::Pen:
-#ifndef QT_NO_MATRIX4X4
- case QVariant::Matrix4x4:
-#endif
- break;
-#ifndef QT_NO_VECTOR2D
- case QVariant::Vector2D:
- return v_cast<QVector2D>(d)->isNull();
-#endif
-#ifndef QT_NO_VECTOR3D
- case QVariant::Vector3D:
- return v_cast<QVector3D>(d)->isNull();
-#endif
-#ifndef QT_NO_VECTOR4D
- case QVariant::Vector4D:
- return v_cast<QVector4D>(d)->isNull();
-#endif
-#ifndef QT_NO_QUATERNION
- case QVariant::Quaternion:
- return v_cast<QQuaternion>(d)->isNull();
-#endif
- default:
- return qcoreVariantHandler()->isNull(d);
- }
- return d->is_null;
-}
-
-static bool compare(const QVariant::Private *a, const QVariant::Private *b)
-{
- Q_ASSERT(a->type == b->type);
- switch(a->type) {
- case QVariant::Cursor:
-#ifndef QT_NO_CURSOR
- return v_cast<QCursor>(a)->shape() == v_cast<QCursor>(b)->shape();
-#endif
- case QVariant::Bitmap:
- return v_cast<QBitmap>(a)->cacheKey()
- == v_cast<QBitmap>(b)->cacheKey();
- case QVariant::Polygon:
- return *v_cast<QPolygon>(a) == *v_cast<QPolygon>(b);
- case QVariant::Region:
- return *v_cast<QRegion>(a) == *v_cast<QRegion>(b);
- case QVariant::Font:
- return *v_cast<QFont>(a) == *v_cast<QFont>(b);
- case QVariant::Pixmap:
- return v_cast<QPixmap>(a)->cacheKey() == v_cast<QPixmap>(b)->cacheKey();
- case QVariant::Image:
- return *v_cast<QImage>(a) == *v_cast<QImage>(b);
- case QVariant::Brush:
- return *v_cast<QBrush>(a) == *v_cast<QBrush>(b);
- case QVariant::Color:
- return *v_cast<QColor>(a) == *v_cast<QColor>(b);
- case QVariant::Palette:
- return *v_cast<QPalette>(a) == *v_cast<QPalette>(b);
-#ifdef QT3_SUPPORT
- case QVariant::ColorGroup:
- return *v_cast<QColorGroup>(a) == *v_cast<QColorGroup>(b);
-#endif
-#ifndef QT_NO_ICON
- case QVariant::Icon:
- /* QIcon::operator==() cannot be reasonably implemented for QIcon,
- * so we always return false. */
- return false;
-#endif
- case QVariant::Matrix:
- return *v_cast<QMatrix>(a) == *v_cast<QMatrix>(b);
- case QVariant::Transform:
- return *v_cast<QTransform>(a) == *v_cast<QTransform>(b);
- case QVariant::TextFormat:
- return *v_cast<QTextFormat>(a) == *v_cast<QTextFormat>(b);
- case QVariant::TextLength:
- return *v_cast<QTextLength>(a) == *v_cast<QTextLength>(b);
- case QVariant::SizePolicy:
- return *v_cast<QSizePolicy>(a) == *v_cast<QSizePolicy>(b);
-#ifndef QT_NO_SHORTCUT
- case QVariant::KeySequence:
- return *v_cast<QKeySequence>(a) == *v_cast<QKeySequence>(b);
-#endif
- case QVariant::Pen:
- return *v_cast<QPen>(a) == *v_cast<QPen>(b);
-#ifndef QT_NO_MATRIX4X4
- case QVariant::Matrix4x4:
- return *v_cast<QMatrix4x4>(a) == *v_cast<QMatrix4x4>(b);
-#endif
-#ifndef QT_NO_VECTOR2D
- case QVariant::Vector2D:
- return *v_cast<QVector2D>(a) == *v_cast<QVector2D>(b);
-#endif
-#ifndef QT_NO_VECTOR3D
- case QVariant::Vector3D:
- return *v_cast<QVector3D>(a) == *v_cast<QVector3D>(b);
-#endif
-#ifndef QT_NO_VECTOR4D
- case QVariant::Vector4D:
- return *v_cast<QVector4D>(a) == *v_cast<QVector4D>(b);
-#endif
-#ifndef QT_NO_QUATERNION
- case QVariant::Quaternion:
- return *v_cast<QQuaternion>(a) == *v_cast<QQuaternion>(b);
-#endif
- default:
- break;
- }
- return qcoreVariantHandler()->compare(a, b);
-}
-
-
-
-static bool convert(const QVariant::Private *d, QVariant::Type t,
- void *result, bool *ok)
-{
- switch (t) {
- case QVariant::ByteArray:
- if (d->type == QVariant::Color) {
- *static_cast<QByteArray *>(result) = v_cast<QColor>(d)->name().toLatin1();
- return true;
- }
- break;
- case QVariant::String: {
- QString *str = static_cast<QString *>(result);
- switch (d->type) {
-#ifndef QT_NO_SHORTCUT
- case QVariant::KeySequence:
- *str = QString(*v_cast<QKeySequence>(d));
- return true;
-#endif
- case QVariant::Font:
- *str = v_cast<QFont>(d)->toString();
- return true;
- case QVariant::Color:
- *str = v_cast<QColor>(d)->name();
- return true;
- default:
- break;
- }
- break;
- }
- case QVariant::Pixmap:
- if (d->type == QVariant::Image) {
- *static_cast<QPixmap *>(result) = QPixmap::fromImage(*v_cast<QImage>(d));
- return true;
- } else if (d->type == QVariant::Bitmap) {
- *static_cast<QPixmap *>(result) = *v_cast<QBitmap>(d);
- return true;
- } else if (d->type == QVariant::Brush) {
- if (v_cast<QBrush>(d)->style() == Qt::TexturePattern) {
- *static_cast<QPixmap *>(result) = v_cast<QBrush>(d)->texture();
- return true;
- }
- }
- break;
- case QVariant::Image:
- if (d->type == QVariant::Pixmap) {
- *static_cast<QImage *>(result) = v_cast<QPixmap>(d)->toImage();
- return true;
- } else if (d->type == QVariant::Bitmap) {
- *static_cast<QImage *>(result) = v_cast<QBitmap>(d)->toImage();
- return true;
- }
- break;
- case QVariant::Bitmap:
- if (d->type == QVariant::Pixmap) {
- *static_cast<QBitmap *>(result) = *v_cast<QPixmap>(d);
- return true;
- } else if (d->type == QVariant::Image) {
- *static_cast<QBitmap *>(result) = QBitmap::fromImage(*v_cast<QImage>(d));
- return true;
- }
- break;
-#ifndef QT_NO_SHORTCUT
- case QVariant::Int:
- if (d->type == QVariant::KeySequence) {
- *static_cast<int *>(result) = (int)(*(v_cast<QKeySequence>(d)));
- return true;
- }
- break;
-#endif
- case QVariant::Font:
- if (d->type == QVariant::String) {
- QFont *f = static_cast<QFont *>(result);
- f->fromString(*v_cast<QString>(d));
- return true;
- }
- break;
- case QVariant::Color:
- if (d->type == QVariant::String) {
- static_cast<QColor *>(result)->setNamedColor(*v_cast<QString>(d));
- return static_cast<QColor *>(result)->isValid();
- } else if (d->type == QVariant::ByteArray) {
- static_cast<QColor *>(result)->setNamedColor(QString::fromLatin1(
- *v_cast<QByteArray>(d)));
- return true;
- } else if (d->type == QVariant::Brush) {
- if (v_cast<QBrush>(d)->style() == Qt::SolidPattern) {
- *static_cast<QColor *>(result) = v_cast<QBrush>(d)->color();
- return true;
- }
- }
- break;
- case QVariant::Brush:
- if (d->type == QVariant::Color) {
- *static_cast<QBrush *>(result) = QBrush(*v_cast<QColor>(d));
- return true;
- } else if (d->type == QVariant::Pixmap) {
- *static_cast<QBrush *>(result) = QBrush(*v_cast<QPixmap>(d));
- return true;
- }
- break;
-#ifndef QT_NO_SHORTCUT
- case QVariant::KeySequence: {
- QKeySequence *seq = static_cast<QKeySequence *>(result);
- switch (d->type) {
- case QVariant::String:
- *seq = QKeySequence(*v_cast<QString>(d));
- return true;
- case QVariant::Int:
- *seq = QKeySequence(d->data.i);
- return true;
- default:
- break;
- }
- }
-#endif
- default:
- break;
- }
- return qcoreVariantHandler()->convert(d, t, result, ok);
-}
-
-#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
-static void streamDebug(QDebug dbg, const QVariant &v)
-{
- switch(v.type()) {
- case QVariant::Cursor:
-#ifndef QT_NO_CURSOR
-// dbg.nospace() << qvariant_cast<QCursor>(v); //FIXME
-#endif
- break;
- case QVariant::Bitmap:
-// dbg.nospace() << qvariant_cast<QBitmap>(v); //FIXME
- break;
- case QVariant::Polygon:
- dbg.nospace() << qvariant_cast<QPolygon>(v);
- break;
- case QVariant::Region:
- dbg.nospace() << qvariant_cast<QRegion>(v);
- break;
- case QVariant::Font:
-// dbg.nospace() << qvariant_cast<QFont>(v); //FIXME
- break;
- case QVariant::Matrix:
- dbg.nospace() << qvariant_cast<QMatrix>(v);
- break;
- case QVariant::Transform:
- dbg.nospace() << qvariant_cast<QTransform>(v);
- break;
- case QVariant::Pixmap:
-// dbg.nospace() << qvariant_cast<QPixmap>(v); //FIXME
- break;
- case QVariant::Image:
-// dbg.nospace() << qvariant_cast<QImage>(v); //FIXME
- break;
- case QVariant::Brush:
- dbg.nospace() << qvariant_cast<QBrush>(v);
- break;
- case QVariant::Color:
- dbg.nospace() << qvariant_cast<QColor>(v);
- break;
- case QVariant::Palette:
-// dbg.nospace() << qvariant_cast<QPalette>(v); //FIXME
- break;
-#ifndef QT_NO_ICON
- case QVariant::Icon:
-// dbg.nospace() << qvariant_cast<QIcon>(v); // FIXME
- break;
-#endif
- case QVariant::SizePolicy:
-// dbg.nospace() << qvariant_cast<QSizePolicy>(v); //FIXME
- break;
-#ifndef QT_NO_SHORTCUT
- case QVariant::KeySequence:
- dbg.nospace() << qvariant_cast<QKeySequence>(v);
- break;
-#endif
- case QVariant::Pen:
- dbg.nospace() << qvariant_cast<QPen>(v);
- break;
-#ifndef QT_NO_MATRIX4X4
- case QVariant::Matrix4x4:
- dbg.nospace() << qvariant_cast<QMatrix4x4>(v);
- break;
-#endif
-#ifndef QT_NO_VECTOR2D
- case QVariant::Vector2D:
- dbg.nospace() << qvariant_cast<QVector2D>(v);
- break;
-#endif
-#ifndef QT_NO_VECTOR3D
- case QVariant::Vector3D:
- dbg.nospace() << qvariant_cast<QVector3D>(v);
- break;
-#endif
-#ifndef QT_NO_VECTOR4D
- case QVariant::Vector4D:
- dbg.nospace() << qvariant_cast<QVector4D>(v);
- break;
-#endif
-#ifndef QT_NO_QUATERNION
- case QVariant::Quaternion:
- dbg.nospace() << qvariant_cast<QQuaternion>(v);
- break;
-#endif
- default:
- qcoreVariantHandler()->debugStream(dbg, v);
- break;
- }
-}
-#endif
-
-const QVariant::Handler qt_gui_variant_handler = {
- construct,
- clear,
- isNull,
-#ifndef QT_NO_DATASTREAM
- 0,
- 0,
-#endif
- compare,
- convert,
- 0,
-#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
- streamDebug
-#else
- 0
-#endif
-};
-
-struct QMetaTypeGuiHelper
-{
- QMetaType::Constructor constr;
- QMetaType::Destructor destr;
-#ifndef QT_NO_DATASTREAM
- QMetaType::SaveOperator saveOp;
- QMetaType::LoadOperator loadOp;
-#endif
-};
-
-extern Q_CORE_EXPORT const QMetaTypeGuiHelper *qMetaTypeGuiHelper;
-
-
-#ifdef QT_NO_DATASTREAM
-# define Q_DECL_METATYPE_HELPER(TYPE) \
- typedef void *(*QConstruct##TYPE)(const TYPE *); \
- static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper<TYPE>; \
- typedef void (*QDestruct##TYPE)(TYPE *); \
- static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDeleteHelper<TYPE>;
-#else
-# define Q_DECL_METATYPE_HELPER(TYPE) \
- typedef void *(*QConstruct##TYPE)(const TYPE *); \
- static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper<TYPE>; \
- typedef void (*QDestruct##TYPE)(TYPE *); \
- static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDeleteHelper<TYPE>; \
- typedef void (*QSave##TYPE)(QDataStream &, const TYPE *); \
- static const QSave##TYPE qSave##TYPE = qMetaTypeSaveHelper<TYPE>; \
- typedef void (*QLoad##TYPE)(QDataStream &, TYPE *); \
- static const QLoad##TYPE qLoad##TYPE = qMetaTypeLoadHelper<TYPE>;
-#endif
-
-#ifdef QT3_SUPPORT
-Q_DECL_METATYPE_HELPER(QColorGroup)
-#endif
-Q_DECL_METATYPE_HELPER(QFont)
-Q_DECL_METATYPE_HELPER(QPixmap)
-Q_DECL_METATYPE_HELPER(QBrush)
-Q_DECL_METATYPE_HELPER(QColor)
-Q_DECL_METATYPE_HELPER(QPalette)
-#ifndef QT_NO_ICON
-Q_DECL_METATYPE_HELPER(QIcon)
-#endif
-Q_DECL_METATYPE_HELPER(QImage)
-Q_DECL_METATYPE_HELPER(QPolygon)
-Q_DECL_METATYPE_HELPER(QRegion)
-Q_DECL_METATYPE_HELPER(QBitmap)
-#ifndef QT_NO_CURSOR
-Q_DECL_METATYPE_HELPER(QCursor)
-#endif
-Q_DECL_METATYPE_HELPER(QSizePolicy)
-#ifndef QT_NO_SHORTCUT
-Q_DECL_METATYPE_HELPER(QKeySequence)
-#endif
-Q_DECL_METATYPE_HELPER(QPen)
-Q_DECL_METATYPE_HELPER(QTextLength)
-Q_DECL_METATYPE_HELPER(QTextFormat)
-Q_DECL_METATYPE_HELPER(QMatrix)
-Q_DECL_METATYPE_HELPER(QTransform)
-#ifndef QT_NO_MATRIX4X4
-Q_DECL_METATYPE_HELPER(QMatrix4x4)
-#endif
-#ifndef QT_NO_VECTOR2D
-Q_DECL_METATYPE_HELPER(QVector2D)
-#endif
-#ifndef QT_NO_VECTOR3D
-Q_DECL_METATYPE_HELPER(QVector3D)
-#endif
-#ifndef QT_NO_VECTOR4D
-Q_DECL_METATYPE_HELPER(QVector4D)
-#endif
-#ifndef QT_NO_QUATERNION
-Q_DECL_METATYPE_HELPER(QQuaternion)
-#endif
-
-#ifdef QT_NO_DATASTREAM
-# define Q_IMPL_METATYPE_HELPER(TYPE) \
- { reinterpret_cast<QMetaType::Constructor>(qConstruct##TYPE), \
- reinterpret_cast<QMetaType::Destructor>(qDestruct##TYPE) }
-#else
-# define Q_IMPL_METATYPE_HELPER(TYPE) \
- { reinterpret_cast<QMetaType::Constructor>(qConstruct##TYPE), \
- reinterpret_cast<QMetaType::Destructor>(qDestruct##TYPE), \
- reinterpret_cast<QMetaType::SaveOperator>(qSave##TYPE), \
- reinterpret_cast<QMetaType::LoadOperator>(qLoad##TYPE) \
- }
-#endif
-
-static const QMetaTypeGuiHelper qVariantGuiHelper[] = {
-#ifdef QT3_SUPPORT
- Q_IMPL_METATYPE_HELPER(QColorGroup),
-#else
- {0, 0, 0, 0},
-#endif
- Q_IMPL_METATYPE_HELPER(QFont),
- Q_IMPL_METATYPE_HELPER(QPixmap),
- Q_IMPL_METATYPE_HELPER(QBrush),
- Q_IMPL_METATYPE_HELPER(QColor),
- Q_IMPL_METATYPE_HELPER(QPalette),
-#ifdef QT_NO_ICON
- {0, 0, 0, 0},
-#else
- Q_IMPL_METATYPE_HELPER(QIcon),
-#endif
- Q_IMPL_METATYPE_HELPER(QImage),
- Q_IMPL_METATYPE_HELPER(QPolygon),
- Q_IMPL_METATYPE_HELPER(QRegion),
- Q_IMPL_METATYPE_HELPER(QBitmap),
-#ifdef QT_NO_CURSOR
- {0, 0, 0, 0},
-#else
- Q_IMPL_METATYPE_HELPER(QCursor),
-#endif
- Q_IMPL_METATYPE_HELPER(QSizePolicy),
-#ifdef QT_NO_SHORTCUT
- {0, 0, 0, 0},
-#else
- Q_IMPL_METATYPE_HELPER(QKeySequence),
-#endif
- Q_IMPL_METATYPE_HELPER(QPen),
- Q_IMPL_METATYPE_HELPER(QTextLength),
- Q_IMPL_METATYPE_HELPER(QTextFormat),
- Q_IMPL_METATYPE_HELPER(QMatrix),
- Q_IMPL_METATYPE_HELPER(QTransform),
-#ifndef QT_NO_MATRIX4X4
- Q_IMPL_METATYPE_HELPER(QMatrix4x4),
-#else
- {0, 0, 0, 0},
-#endif
-#ifndef QT_NO_VECTOR2D
- Q_IMPL_METATYPE_HELPER(QVector2D),
-#else
- {0, 0, 0, 0},
-#endif
-#ifndef QT_NO_VECTOR3D
- Q_IMPL_METATYPE_HELPER(QVector3D),
-#else
- {0, 0, 0, 0},
-#endif
-#ifndef QT_NO_VECTOR4D
- Q_IMPL_METATYPE_HELPER(QVector4D),
-#else
- {0, 0, 0, 0},
-#endif
-#ifndef QT_NO_QUATERNION
- Q_IMPL_METATYPE_HELPER(QQuaternion)
-#else
- {0, 0, 0, 0}
-#endif
-};
-
-static const QVariant::Handler *qt_guivariant_last_handler = 0;
-int qRegisterGuiVariant()
-{
- qt_guivariant_last_handler = QVariant::handler;
- QVariant::handler = &qt_gui_variant_handler;
- qMetaTypeGuiHelper = qVariantGuiHelper;
- return 1;
-}
-Q_CONSTRUCTOR_FUNCTION(qRegisterGuiVariant)
-
-int qUnregisterGuiVariant()
-{
- QVariant::handler = qt_guivariant_last_handler;
- qMetaTypeGuiHelper = 0;
- return 1;
-}
-Q_DESTRUCTOR_FUNCTION(qUnregisterGuiVariant)
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qkde_p.h b/src/gui/kernel/qkde_p.h
deleted file mode 100644
index 4e108f6e9e..0000000000
--- a/src/gui/kernel/qkde_p.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QKDE_H
-#define QKDE_H
-
-#include <QtCore/qglobal.h>
-#include <QtGui/QPalette>
-#include <QtGui/QIcon>
-
-//
-// 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.
-//
-#if defined(Q_WS_X11)
-
-
-QT_BEGIN_NAMESPACE
-
-/*!\internal
- This namespace contains helper function to help KDE integration
- They are only used if we detect the use of KDE and the KDE platform plugin is not found (old KDE version)
- Or if the detected KDE version is KDE3
-*/
-namespace QKde {
- QString kdeHome();
- QString kdeStyle();
- QPalette kdePalette();
- int kdeToolButtonStyle();
- int kdeToolBarIconSize();
-}
-
-
-QT_END_NAMESPACE
-
-#endif // Q_WS_X11
-#endif // QKDE_H
diff --git a/src/gui/kernel/qkeymapper.cpp b/src/gui/kernel/qkeymapper.cpp
deleted file mode 100644
index e6ba3ce142..0000000000
--- a/src/gui/kernel/qkeymapper.cpp
+++ /dev/null
@@ -1,118 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include "qapplication.h"
-
-#include <private/qobject_p.h>
-#include "qkeymapper_p.h"
-#include <qwidget.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QKeyMapper
- \since 4.2
- \internal
-
- \sa QObject
-*/
-
-/*!
- Constructs a new key mapper.
-*/
-QKeyMapper::QKeyMapper()
- : QObject(*new QKeyMapperPrivate, 0)
-{
-}
-
-/*!
- Destroys the key mapper.
-*/
-QKeyMapper::~QKeyMapper()
-{
-}
-
-QList<int> QKeyMapper::possibleKeys(QKeyEvent *e)
-{
- QList<int> result;
-
- if (!e->nativeScanCode()) {
- if (e->key() && (e->key() != Qt::Key_unknown))
- result << int(e->key() + e->modifiers());
- else if (!e->text().isEmpty())
- result << int(e->text().at(0).unicode() + e->modifiers());
- return result;
- }
-
- return instance()->d_func()->possibleKeys(e);
-}
-
-extern bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event); // in qapplication_*.cpp
-void QKeyMapper::changeKeyboard()
-{
- instance()->d_func()->clearMappings();
-
- // inform all toplevel widgets of the change
- QEvent e(QEvent::KeyboardLayoutChange);
- QWidgetList list = QApplication::topLevelWidgets();
- for (int i = 0; i < list.size(); ++i) {
- QWidget *w = list.at(i);
- qt_sendSpontaneousEvent(w, &e);
- }
-}
-
-Q_GLOBAL_STATIC(QKeyMapper, keymapper)
-/*!
- Returns the pointer to the single instance of QKeyMapper in the application.
- If none yet exists, the function ensures that one is created.
-*/
-QKeyMapper *QKeyMapper::instance()
-{
- return keymapper();
-}
-
-QKeyMapperPrivate *qt_keymapper_private()
-{
- return QKeyMapper::instance()->d_func();
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qkeymapper_p.h b/src/gui/kernel/qkeymapper_p.h
deleted file mode 100644
index ec2d8492fe..0000000000
--- a/src/gui/kernel/qkeymapper_p.h
+++ /dev/null
@@ -1,224 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QKEYMAPPER_P_H
-#define QKEYMAPPER_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <qobject.h>
-#include <private/qobject_p.h>
-#include <qkeysequence.h>
-#include <qlist.h>
-#include <qlocale.h>
-#include <qevent.h>
-#include <qhash.h>
-
-#if defined (Q_WS_MAC64)
-# include <private/qt_mac_p.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class QKeyMapperPrivate;
-class QKeyMapper : public QObject
-{
- Q_OBJECT
-public:
- explicit QKeyMapper();
- ~QKeyMapper();
-
- static QKeyMapper *instance();
- static void changeKeyboard();
- static bool sendKeyEvent(QWidget *widget, bool grab,
- QEvent::Type type, int code, Qt::KeyboardModifiers modifiers,
- const QString &text, bool autorepeat, int count,
- quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers,
- bool *unusedExceptForCocoa = 0);
- static QList<int> possibleKeys(QKeyEvent *e);
-
-private:
- friend QKeyMapperPrivate *qt_keymapper_private();
- Q_DECLARE_PRIVATE(QKeyMapper)
- Q_DISABLE_COPY(QKeyMapper)
-};
-
-
-
-#if defined(Q_OS_WIN)
-enum WindowsNativeModifiers {
- ShiftLeft = 0x00000001,
- ControlLeft = 0x00000002,
- AltLeft = 0x00000004,
- MetaLeft = 0x00000008,
- ShiftRight = 0x00000010,
- ControlRight = 0x00000020,
- AltRight = 0x00000040,
- MetaRight = 0x00000080,
- CapsLock = 0x00000100,
- NumLock = 0x00000200,
- ScrollLock = 0x00000400,
- ExtendedKey = 0x01000000,
-
- // Convenience mappings
- ShiftAny = 0x00000011,
- ControlAny = 0x00000022,
- AltAny = 0x00000044,
- MetaAny = 0x00000088,
- LockAny = 0x00000700
-};
-# if !defined(tagMSG)
- typedef struct tagMSG MSG;
-# endif
-#elif defined(Q_WS_MAC)
-QT_BEGIN_INCLUDE_NAMESPACE
-# include <private/qt_mac_p.h>
-QT_END_INCLUDE_NAMESPACE
-#elif defined(Q_WS_X11)
-
-QT_BEGIN_INCLUDE_NAMESPACE
-typedef ulong XID;
-typedef XID KeySym;
-QT_END_INCLUDE_NAMESPACE
-
-struct QXCoreDesc {
- int min_keycode;
- int max_keycode;
- int keysyms_per_keycode;
- KeySym *keysyms;
- uchar mode_switch;
- uchar num_lock;
- KeySym lock_meaning;
-};
-
-#endif
-
-struct KeyboardLayoutItem;
-typedef struct __TISInputSource * TISInputSourceRef;
-class QKeyEvent;
-class QKeyMapperPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QKeyMapper)
-public:
- QKeyMapperPrivate();
- ~QKeyMapperPrivate();
-
- void clearMappings();
- QList<int> possibleKeys(QKeyEvent *e);
-
- QLocale keyboardInputLocale;
- Qt::LayoutDirection keyboardInputDirection;
-
-#if defined(Q_OS_WIN)
- void clearRecordedKeys();
- void updateKeyMap(const MSG &msg);
- bool translateKeyEvent(QWidget *receiver, const MSG &msg, bool grab);
- void updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32 scancode, quint32 vk_key);
- bool isADeadKey(unsigned int vk_key, unsigned int modifiers);
- void deleteLayouts();
-
- KeyboardLayoutItem *keyLayout[256];
-
-#elif defined(Q_WS_X11)
-
- QList<int> possibleKeysXKB(QKeyEvent *event);
- QList<int> possibleKeysCore(QKeyEvent *event);
-
- bool translateKeyEventInternal(QWidget *keywidget,
- const XEvent *,
- KeySym &keysym,
- int& count,
- QString& text,
- Qt::KeyboardModifiers& modifiers,
- int &code,
- QEvent::Type &type,
- bool statefulTranslation = true);
- bool translateKeyEvent(QWidget *keywidget,
- const XEvent *,
- bool grab);
-
- int xkb_currentGroup;
- QXCoreDesc coreDesc;
-
-#elif defined(Q_WS_MAC)
- bool updateKeyboard();
- void updateKeyMap(EventHandlerCallRef, EventRef, void *);
- bool translateKeyEvent(QWidget *, EventHandlerCallRef, EventRef, void *, bool);
- void deleteLayouts();
-
- enum { NullMode, UnicodeMode, OtherMode } keyboard_mode;
- union {
- const UCKeyboardLayout *unicode;
- void *other;
- } keyboard_layout_format;
-#ifdef Q_WS_MAC64
- QCFType<TISInputSourceRef> currentInputSource;
-#else
- KeyboardLayoutRef currentKeyboardLayout;
-#endif
- KeyboardLayoutKind keyboard_kind;
- UInt32 keyboard_dead;
- KeyboardLayoutItem *keyLayout[256];
-#elif defined(Q_WS_QWS)
-#elif defined(Q_OS_SYMBIAN)
-public:
- QString translateKeyEvent(int keySym, Qt::KeyboardModifiers modifiers);
- int mapS60KeyToQt(TUint s60key);
- int mapS60ScanCodesToQt(TUint s60key);
- int mapQtToS60Key(int qtKey);
- int mapQtToS60ScanCodes(int qtKey);
- void updateInputLanguage();
-#endif
-};
-
-QKeyMapperPrivate *qt_keymapper_private(); // from qkeymapper.cpp
-
-QT_END_NAMESPACE
-
-#endif // QKEYMAPPER_P_H
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
deleted file mode 100644
index 3cf5dc5275..0000000000
--- a/src/gui/kernel/qkeysequence.cpp
+++ /dev/null
@@ -1,1726 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qkeysequence.h"
-#include "qkeysequence_p.h"
-#include "private/qapplication_p.h"
-
-#ifndef QT_NO_SHORTCUT
-
-#include "qshortcut.h"
-#include "qdebug.h"
-#ifndef QT_NO_REGEXP
-# include "qregexp.h"
-#endif
-#ifndef QT_NO_DATASTREAM
-# include "qdatastream.h"
-#endif
-#include "qvariant.h"
-
-#ifdef Q_WS_MAC
-# include <private/qt_mac_p.h>
-
-#endif
-
-QT_BEGIN_NAMESPACE
-
-#ifdef Q_WS_MAC
-static bool qt_sequence_no_mnemonics = true;
-struct MacSpecialKey {
- int key;
- ushort macSymbol;
-};
-
-static const int NumEntries = 21;
-static const MacSpecialKey entries[NumEntries] = {
- { Qt::Key_Escape, 0x238B },
- { Qt::Key_Tab, 0x21E5 },
- { Qt::Key_Backtab, 0x21E4 },
- { Qt::Key_Backspace, 0x232B },
- { Qt::Key_Return, 0x21B5 },
- { Qt::Key_Enter, 0x2324 },
- { Qt::Key_Delete, 0x2326 },
- { Qt::Key_Home, 0x2196 },
- { Qt::Key_End, 0x2198 },
- { Qt::Key_Left, 0x2190 },
- { Qt::Key_Up, 0x2191 },
- { Qt::Key_Right, 0x2192 },
- { Qt::Key_Down, 0x2193 },
- { Qt::Key_PageUp, 0x21DE },
- { Qt::Key_PageDown, 0x21DF },
- { Qt::Key_Shift, kShiftUnicode },
- { Qt::Key_Control, kCommandUnicode },
- { Qt::Key_Meta, kControlUnicode },
- { Qt::Key_Alt, kOptionUnicode },
- { Qt::Key_CapsLock, 0x21EA },
-};
-
-static bool operator<(const MacSpecialKey &entry, int key)
-{
- return entry.key < key;
-}
-
-static bool operator<(int key, const MacSpecialKey &entry)
-{
- return key < entry.key;
-}
-
-static const MacSpecialKey * const MacSpecialKeyEntriesEnd = entries + NumEntries;
-
-QChar qt_macSymbolForQtKey(int key)
-{
- const MacSpecialKey *i = qBinaryFind(entries, MacSpecialKeyEntriesEnd, key);
- if (i == MacSpecialKeyEntriesEnd)
- return QChar();
- ushort macSymbol = i->macSymbol;
- if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)
- && (macSymbol == kControlUnicode || macSymbol == kCommandUnicode)) {
- if (macSymbol == kControlUnicode)
- macSymbol = kCommandUnicode;
- else
- macSymbol = kControlUnicode;
- }
-
- return QChar(macSymbol);
-}
-
-static int qtkeyForMacSymbol(const QChar ch)
-{
- const ushort unicode = ch.unicode();
- for (int i = 0; i < NumEntries; ++i) {
- const MacSpecialKey &entry = entries[i];
- if (entry.macSymbol == unicode) {
- int key = entry.key;
- if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)
- && (unicode == kControlUnicode || unicode == kCommandUnicode)) {
- if (unicode == kControlUnicode)
- key = Qt::Key_Control;
- else
- key = Qt::Key_Meta;
- }
- return key;
- }
- }
- return -1;
-}
-
-#else
-static bool qt_sequence_no_mnemonics = false;
-#endif
-void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b) { qt_sequence_no_mnemonics = !b; }
-
-/*!
- \class QKeySequence
- \brief The QKeySequence class encapsulates a key sequence as used
- by shortcuts.
-
- \ingroup shared
-
-
- In its most common form, a key sequence describes a combination of
- keys that must be used together to perform some action. Key sequences
- are used with QAction objects to specify which keyboard shortcuts can
- be used to trigger actions.
-
- Key sequences can be constructed for use as keyboard shortcuts in
- three different ways:
-
- \list
- \o For standard shortcuts, a \l{QKeySequence::StandardKey}{standard key}
- can be used to request the platform-specific key sequence associated
- with each shortcut.
- \o For custom shortcuts, human-readable strings such as "Ctrl+X" can
- be used, and these can be translated into the appropriate shortcuts
- for users of different languages. Translations are made in the
- "QShortcut" context.
- \o For hard-coded shortcuts, integer key codes can be specified with
- a combination of values defined by the Qt::Key and Qt::Modifier enum
- values. Each key code consists of a single Qt::Key value and zero or
- more modifiers, such as Qt::SHIFT, Qt::CTRL, Qt::ALT and Qt::META.
- \endlist
-
- For example, \gui{Ctrl P} might be a sequence used as a shortcut for
- printing a document, and can be specified in any of the following
- ways:
-
- \snippet doc/src/snippets/code/src_gui_kernel_qkeysequence.cpp 0
-
- Note that, for letters, the case used in the specification string
- does not matter. In the above examples, the user does not need to
- hold down the \key{Shift} key to activate a shortcut specified
- with "Ctrl+P". However, for other keys, the use of \key{Shift} as
- an unspecified extra modifier key can lead to confusion for users
- of an application whose keyboards have different layouts to those
- used by the developers. See the \l{Keyboard Layout Issues} section
- below for more details.
-
- It is preferable to use standard shortcuts where possible.
- When creating key sequences for non-standard shortcuts, you should use
- human-readable strings in preference to hard-coded integer values.
-
- QKeySequence objects can be cast to a QString to obtain a human-readable
- translated version of the sequence. Similarly, the toString() function
- produces human-readable strings for use in menus. On Mac OS X, the
- appropriate symbols are used to describe keyboard shortcuts using special
- keys on the Macintosh keyboard.
-
- An alternative way to specify hard-coded key codes is to use the Unicode
- code point of the character; for example, 'A' gives the same key sequence
- as Qt::Key_A.
-
- \bold{Note:} On Mac OS X, references to "Ctrl", Qt::CTRL, Qt::Control
- and Qt::ControlModifier correspond to the \key Command keys on the
- Macintosh keyboard, and references to "Meta", Qt::META, Qt::Meta and
- Qt::MetaModifier correspond to the \key Control keys. Developers on
- Mac OS X can use the same shortcut descriptions across all platforms,
- and their applications will automatically work as expected on Mac OS X.
-
- \section1 Standard Shortcuts
-
- QKeySequence defines many \l{QKeySequence::StandardKey} {standard
- keyboard shortcuts} to reduce the amount of effort required when
- setting up actions in a typical application. The table below shows
- some common key sequences that are often used for these standard
- shortcuts by applications on four widely-used platforms. Note
- that on Mac OS X, the \key Ctrl value corresponds to the \key
- Command keys on the Macintosh keyboard, and the \key Meta value
- corresponds to the \key Control keys.
-
- \table
- \header \i StandardKey \i Windows \i Mac OS X \i KDE \i GNOME \i S60
- \row \i HelpContents \i F1 \i Ctrl+? \i F1 \i F1 \i F2
- \row \i WhatsThis \i Shift+F1 \i Shift+F1 \i Shift+F1 \i Shift+F1 \i Shift+F1
- \row \i Open \i Ctrl+O \i Ctrl+O \i Ctrl+O \i Ctrl+O \i (none)
- \row \i Close \i Ctrl+F4, Ctrl+W \i Ctrl+W, Ctrl+F4 \i Ctrl+W \i Ctrl+W \i (none)
- \row \i Save \i Ctrl+S \i Ctrl+S \i Ctrl+S \i Ctrl+S \i (none)
- \row \i Quit \i \i Ctrl+Q \i Qtrl+Q \i Qtrl+Q \i (none)
- \row \i SaveAs \i \i Ctrl+Shift+S \i \i Ctrl+Shift+S \i (none)
- \row \i New \i Ctrl+N \i Ctrl+N \i Ctrl+N \i Ctrl+N \i (none)
- \row \i Delete \i Del \i Del, Meta+D \i Del, Ctrl+D \i Del, Ctrl+D \i Del
- \row \i Cut \i Ctrl+X, Shift+Del \i Ctrl+X \i Ctrl+X, F20, Shift+Del \i Ctrl+X, F20, Shift+Del \i Ctrl+X
- \row \i Copy \i Ctrl+C, Ctrl+Ins \i Ctrl+C \i Ctrl+C, F16, Ctrl+Ins \i Ctrl+C, F16, Ctrl+Ins \i Ctrl+C
- \row \i Paste \i Ctrl+V, Shift+Ins \i Ctrl+V \i Ctrl+V, F18, Shift+Ins \i Ctrl+V, F18, Shift+Ins \i Ctrl+V
- \row \i Preferences \i \i Ctrl+, \i \i \i (none)
- \row \i Undo \i Ctrl+Z, Alt+Backspace \i Ctrl+Z \i Ctrl+Z, F14 \i Ctrl+Z, F14 \i Ctrl+Z
- \row \i Redo \i Ctrl+Y, Shift+Ctrl+Z, Alt+Shift+Backspace \i Ctrl+Shift+Z \i Ctrl+Shift+Z \i Ctrl+Shift+Z \i (none)
- \row \i Back \i Alt+Left, Backspace \i Ctrl+[ \i Alt+Left \i Alt+Left \i (none)
- \row \i Forward \i Alt+Right, Shift+Backspace \i Ctrl+] \i Alt+Right \i Alt+Right \i (none)
- \row \i Refresh \i F5 \i F5 \i F5 \i Ctrl+R, F5 \i (none)
- \row \i ZoomIn \i Ctrl+Plus \i Ctrl+Plus \i Ctrl+Plus \i Ctrl+Plus \i (none)
- \row \i ZoomOut \i Ctrl+Minus \i Ctrl+Minus \i Ctrl+Minus \i Ctrl+Minus \i (none)
- \row \i Print \i Ctrl+P \i Ctrl+P \i Ctrl+P \i Ctrl+P \i (none)
- \row \i AddTab \i Ctrl+T \i Ctrl+T \i Ctrl+Shift+N, Ctrl+T \i Ctrl+T \i (none)
- \row \i NextChild \i Ctrl+Tab, Forward, Ctrl+F6 \i Ctrl+}, Forward, Ctrl+Tab \i Ctrl+Tab, Forward, Ctrl+Comma \i Ctrl+Tab, Forward \i (none)
- \row \i PreviousChild \i Ctrl+Shift+Tab, Back, Ctrl+Shift+F6 \i Ctrl+{, Back, Ctrl+Shift+Tab \i Ctrl+Shift+Tab, Back, Ctrl+Period \i Ctrl+Shift+Tab, Back \i (none)
- \row \i Find \i Ctrl+F \i Ctrl+F \i Ctrl+F \i Ctrl+F \i (none)
- \row \i FindNext \i F3, Ctrl+G \i Ctrl+G \i F3 \i Ctrl+G, F3 \i (none)
- \row \i FindPrevious \i Shift+F3, Ctrl+Shift+G \i Ctrl+Shift+G \i Shift+F3 \i Ctrl+Shift+G, Shift+F3 \i (none)
- \row \i Replace \i Ctrl+H \i (none) \i Ctrl+R \i Ctrl+H \i (none)
- \row \i SelectAll \i Ctrl+A \i Ctrl+A \i Ctrl+A \i Ctrl+A \i (none)
- \row \i Bold \i Ctrl+B \i Ctrl+B \i Ctrl+B \i Ctrl+B \i (none)
- \row \i Italic \i Ctrl+I \i Ctrl+I \i Ctrl+I \i Ctrl+I \i (none)
- \row \i Underline \i Ctrl+U \i Ctrl+U \i Ctrl+U \i Ctrl+U \i (none)
- \row \i MoveToNextChar \i Right \i Right \i Right \i Right \i Right
- \row \i MoveToPreviousChar \i Left \i Left \i Left \i Left \i Left
- \row \i MoveToNextWord \i Ctrl+Right \i Alt+Right \i Ctrl+Right \i Ctrl+Right \i Ctrl+Right
- \row \i MoveToPreviousWord \i Ctrl+Left \i Alt+Left \i Ctrl+Left \i Ctrl+Left \i Ctrl+Left
- \row \i MoveToNextLine \i Down \i Down \i Down \i Down \i Down
- \row \i MoveToPreviousLine \i Up \i Up \i Up \i Up \i Up
- \row \i MoveToNextPage \i PgDown \i PgDown, Alt+PgDown, Meta+Down, Meta+PgDown\i PgDown \i PgDown \i PgDown
- \row \i MoveToPreviousPage \i PgUp \i PgUp, Alt+PgUp, Meta+Up, Meta+PgUp \i PgUp \i PgUp \i PgUp
- \row \i MoveToStartOfLine \i Home \i Ctrl+Left, Meta+Left \i Home \i Home \i Home
- \row \i MoveToEndOfLine \i End \i Ctrl+Right, Meta+Right \i End \i End \i End
- \row \i MoveToStartOfBlock \i (none) \i Alt+Up, Meta+A \i (none) \i (none) \i (none)
- \row \i MoveToEndOfBlock \i (none) \i Alt+Down, Meta+E \i (none) \i (none) \i (none)
- \row \i MoveToStartOfDocument\i Ctrl+Home \i Ctrl+Up, Home \i Ctrl+Home \i Ctrl+Home \i Ctrl+Home
- \row \i MoveToEndOfDocument \i Ctrl+End \i Ctrl+Down, End \i Ctrl+End \i Ctrl+End \i Ctrl+End
- \row \i SelectNextChar \i Shift+Right \i Shift+Right \i Shift+Right \i Shift+Right \i Shift+Right
- \row \i SelectPreviousChar \i Shift+Left \i Shift+Left \i Shift+Left \i Shift+Left \i Shift+Left
- \row \i SelectNextWord \i Ctrl+Shift+Right \i Alt+Shift+Right \i Ctrl+Shift+Right \i Ctrl+Shift+Right \i Ctrl+Shift+Right
- \row \i SelectPreviousWord \i Ctrl+Shift+Left \i Alt+Shift+Left \i Ctrl+Shift+Left \i Ctrl+Shift+Left \i Ctrl+Shift+Left
- \row \i SelectNextLine \i Shift+Down \i Shift+Down \i Shift+Down \i Shift+Down \i Shift+Down
- \row \i SelectPreviousLine \i Shift+Up \i Shift+Up \i Shift+Up \i Shift+Up \i Shift+Up
- \row \i SelectNextPage \i Shift+PgDown \i Shift+PgDown \i Shift+PgDown \i Shift+PgDown \i Shift+PgDown
- \row \i SelectPreviousPage \i Shift+PgUp \i Shift+PgUp \i Shift+PgUp \i Shift+PgUp \i Shift+PgUp
- \row \i SelectStartOfLine \i Shift+Home \i Ctrl+Shift+Left \i Shift+Home \i Shift+Home \i Shift+Home
- \row \i SelectEndOfLine \i Shift+End \i Ctrl+Shift+Right \i Shift+End \i Shift+End \i Shift+End
- \row \i SelectStartOfBlock \i (none) \i Alt+Shift+Up, Meta+Shift+A \i (none) \i (none) \i (none)
- \row \i SelectEndOfBlock \i (none) \i Alt+Shift+Down, Meta+Shift+E \i (none) \i (none) \i (none)
- \row \i SelectStartOfDocument\i Ctrl+Shift+Home \i Ctrl+Shift+Up, Shift+Home \i Ctrl+Shift+Home\i Ctrl+Shift+Home \i Ctrl+Shift+Home
- \row \i SelectEndOfDocument \i Ctrl+Shift+End \i Ctrl+Shift+Down, Shift+End \i Ctrl+Shift+End \i Ctrl+Shift+End \i Ctrl+Shift+End
- \row \i DeleteStartOfWord \i Ctrl+Backspace \i Alt+Backspace \i Ctrl+Backspace \i Ctrl+Backspace \i (none)
- \row \i DeleteEndOfWord \i Ctrl+Del \i (none) \i Ctrl+Del \i Ctrl+Del \i (none)
- \row \i DeleteEndOfLine \i (none) \i (none) \i Ctrl+K \i Ctrl+K \i (none)
- \row \i InsertParagraphSeparator \i Enter \i Enter \i Enter \i Enter \i (none)
- \row \i InsertLineSeparator \i Shift+Enter \i Meta+Enter \i Shift+Enter \i Shift+Enter \i (none)
- \endtable
-
- Note that, since the key sequences used for the standard shortcuts differ
- between platforms, you still need to test your shortcuts on each platform
- to ensure that you do not unintentionally assign the same key sequence to
- many actions.
-
- \section1 Keyboard Layout Issues
-
- Many key sequence specifications are chosen by developers based on the
- layout of certain types of keyboard, rather than choosing keys that
- represent the first letter of an action's name, such as \key{Ctrl S}
- ("Ctrl+S") or \key{Ctrl C} ("Ctrl+C").
- Additionally, because certain symbols can only be entered with the
- help of modifier keys on certain keyboard layouts, key sequences intended
- for use with one keyboard layout may map to a different key, map to no
- keys at all, or require an additional modifier key to be used on
- different keyboard layouts.
-
- For example, the shortcuts, \key{Ctrl plus} and \key{Ctrl minus}, are often
- used as shortcuts for zoom operations in graphics applications, and these
- may be specified as "Ctrl++" and "Ctrl+-" respectively. However, the way
- these shortcuts are specified and interpreted depends on the keyboard layout.
- Users of Norwegian keyboards will note that the \key{+} and \key{-} keys
- are not adjacent on the keyboard, but will still be able to activate both
- shortcuts without needing to press the \key{Shift} key. However, users
- with British keyboards will need to hold down the \key{Shift} key
- to enter the \key{+} symbol, making the shortcut effectively the same as
- "Ctrl+Shift+=".
-
- Although some developers might resort to fully specifying all the modifiers
- they use on their keyboards to activate a shortcut, this will also result
- in unexpected behavior for users of different keyboard layouts.
-
- For example, a developer using a British keyboard may decide to specify
- "Ctrl+Shift+=" as the key sequence in order to create a shortcut that
- coincidentally behaves in the same way as \key{Ctrl plus}. However, the
- \key{=} key needs to be accessed using the \key{Shift} key on Norwegian
- keyboard, making the required shortcut effectively \key{Ctrl Shift Shift =}
- (an impossible key combination).
-
- As a result, both human-readable strings and hard-coded key codes
- can both be problematic to use when specifying a key sequence that
- can be used on a variety of different keyboard layouts. Only the
- use of \l{QKeySequence::StandardKey} {standard shortcuts}
- guarantees that the user will be able to use the shortcuts that
- the developer intended.
-
- Despite this, we can address this issue by ensuring that human-readable
- strings are used, making it possible for translations of key sequences to
- be made for users of different languages. This approach will be successful
- for users whose keyboards have the most typical layout for the language
- they are using.
-
- \section1 GNU Emacs Style Key Sequences
-
- Key sequences similar to those used in \l{GNU Emacs}, allowing up to four
- key codes, can be created by using the multiple argument constructor,
- or by passing a human-readable string of comma-separated key sequences.
-
- For example, the key sequence, \key{Ctrl X} followed by \key{Ctrl C}, can
- be specified using either of the following ways:
-
- \snippet doc/src/snippets/code/src_gui_kernel_qkeysequence.cpp 1
-
- \warning A QApplication instance must have been constructed before a
- QKeySequence is created; otherwise, your application may crash.
-
- \sa QShortcut
-*/
-
-/*!
- \enum QKeySequence::SequenceMatch
-
- \value NoMatch The key sequences are different; not even partially
- matching.
- \value PartialMatch The key sequences match partially, but are not
- the same.
- \value ExactMatch The key sequences are the same.
- \omitvalue Identical
-*/
-
-/*!
- \enum QKeySequence::SequenceFormat
-
- \value NativeText The key sequence as a platform specific string.
- This means that it will be shown translated and on the Mac it will
- resemble a key sequence from the menu bar. This enum is best used when you
- want to display the string to the user.
-
- \value PortableText The key sequence is given in a "portable" format,
- suitable for reading and writing to a file. In many cases, it will look
- similar to the native text on Windows and X11.
-*/
-
-static const struct {
- int key;
- const char* name;
-} keyname[] = {
- //: This and all following "incomprehensible" strings in QShortcut context
- //: are key names. Please use the localized names appearing on actual
- //: keyboards or whatever is commonly used.
- { Qt::Key_Space, QT_TRANSLATE_NOOP("QShortcut", "Space") },
- { Qt::Key_Escape, QT_TRANSLATE_NOOP("QShortcut", "Esc") },
- { Qt::Key_Tab, QT_TRANSLATE_NOOP("QShortcut", "Tab") },
- { Qt::Key_Backtab, QT_TRANSLATE_NOOP("QShortcut", "Backtab") },
- { Qt::Key_Backspace, QT_TRANSLATE_NOOP("QShortcut", "Backspace") },
- { Qt::Key_Return, QT_TRANSLATE_NOOP("QShortcut", "Return") },
- { Qt::Key_Enter, QT_TRANSLATE_NOOP("QShortcut", "Enter") },
- { Qt::Key_Insert, QT_TRANSLATE_NOOP("QShortcut", "Ins") },
- { Qt::Key_Delete, QT_TRANSLATE_NOOP("QShortcut", "Del") },
- { Qt::Key_Pause, QT_TRANSLATE_NOOP("QShortcut", "Pause") },
- { Qt::Key_Print, QT_TRANSLATE_NOOP("QShortcut", "Print") },
- { Qt::Key_SysReq, QT_TRANSLATE_NOOP("QShortcut", "SysReq") },
- { Qt::Key_Home, QT_TRANSLATE_NOOP("QShortcut", "Home") },
- { Qt::Key_End, QT_TRANSLATE_NOOP("QShortcut", "End") },
- { Qt::Key_Left, QT_TRANSLATE_NOOP("QShortcut", "Left") },
- { Qt::Key_Up, QT_TRANSLATE_NOOP("QShortcut", "Up") },
- { Qt::Key_Right, QT_TRANSLATE_NOOP("QShortcut", "Right") },
- { Qt::Key_Down, QT_TRANSLATE_NOOP("QShortcut", "Down") },
- { Qt::Key_PageUp, QT_TRANSLATE_NOOP("QShortcut", "PgUp") },
- { Qt::Key_PageDown, QT_TRANSLATE_NOOP("QShortcut", "PgDown") },
- { Qt::Key_CapsLock, QT_TRANSLATE_NOOP("QShortcut", "CapsLock") },
- { Qt::Key_NumLock, QT_TRANSLATE_NOOP("QShortcut", "NumLock") },
- { Qt::Key_ScrollLock, QT_TRANSLATE_NOOP("QShortcut", "ScrollLock") },
- { Qt::Key_Menu, QT_TRANSLATE_NOOP("QShortcut", "Menu") },
- { Qt::Key_Help, QT_TRANSLATE_NOOP("QShortcut", "Help") },
-
- // Special keys
- // Includes multimedia, launcher, lan keys ( bluetooth, wireless )
- // window navigation
- { Qt::Key_Back, QT_TRANSLATE_NOOP("QShortcut", "Back") },
- { Qt::Key_Forward, QT_TRANSLATE_NOOP("QShortcut", "Forward") },
- { Qt::Key_Stop, QT_TRANSLATE_NOOP("QShortcut", "Stop") },
- { Qt::Key_Refresh, QT_TRANSLATE_NOOP("QShortcut", "Refresh") },
- { Qt::Key_VolumeDown, QT_TRANSLATE_NOOP("QShortcut", "Volume Down") },
- { Qt::Key_VolumeMute, QT_TRANSLATE_NOOP("QShortcut", "Volume Mute") },
- { Qt::Key_VolumeUp, QT_TRANSLATE_NOOP("QShortcut", "Volume Up") },
- { Qt::Key_BassBoost, QT_TRANSLATE_NOOP("QShortcut", "Bass Boost") },
- { Qt::Key_BassUp, QT_TRANSLATE_NOOP("QShortcut", "Bass Up") },
- { Qt::Key_BassDown, QT_TRANSLATE_NOOP("QShortcut", "Bass Down") },
- { Qt::Key_TrebleUp, QT_TRANSLATE_NOOP("QShortcut", "Treble Up") },
- { Qt::Key_TrebleDown, QT_TRANSLATE_NOOP("QShortcut", "Treble Down") },
- { Qt::Key_MediaPlay, QT_TRANSLATE_NOOP("QShortcut", "Media Play") },
- { Qt::Key_MediaStop, QT_TRANSLATE_NOOP("QShortcut", "Media Stop") },
- { Qt::Key_MediaPrevious, QT_TRANSLATE_NOOP("QShortcut", "Media Previous") },
- { Qt::Key_MediaNext, QT_TRANSLATE_NOOP("QShortcut", "Media Next") },
- { Qt::Key_MediaRecord, QT_TRANSLATE_NOOP("QShortcut", "Media Record") },
- //: Media player pause button
- { Qt::Key_MediaPause, QT_TRANSLATE_NOOP("QShortcut", "Media Pause") },
- //: Media player button to toggle between playing and paused
- { Qt::Key_MediaTogglePlayPause, QT_TRANSLATE_NOOP("QShortcut", "Toggle Media Play/Pause") },
- { Qt::Key_HomePage, QT_TRANSLATE_NOOP("QShortcut", "Home Page") },
- { Qt::Key_Favorites, QT_TRANSLATE_NOOP("QShortcut", "Favorites") },
- { Qt::Key_Search, QT_TRANSLATE_NOOP("QShortcut", "Search") },
- { Qt::Key_Standby, QT_TRANSLATE_NOOP("QShortcut", "Standby") },
- { Qt::Key_OpenUrl, QT_TRANSLATE_NOOP("QShortcut", "Open URL") },
- { Qt::Key_LaunchMail, QT_TRANSLATE_NOOP("QShortcut", "Launch Mail") },
- { Qt::Key_LaunchMedia, QT_TRANSLATE_NOOP("QShortcut", "Launch Media") },
- { Qt::Key_Launch0, QT_TRANSLATE_NOOP("QShortcut", "Launch (0)") },
- { Qt::Key_Launch1, QT_TRANSLATE_NOOP("QShortcut", "Launch (1)") },
- { Qt::Key_Launch2, QT_TRANSLATE_NOOP("QShortcut", "Launch (2)") },
- { Qt::Key_Launch3, QT_TRANSLATE_NOOP("QShortcut", "Launch (3)") },
- { Qt::Key_Launch4, QT_TRANSLATE_NOOP("QShortcut", "Launch (4)") },
- { Qt::Key_Launch5, QT_TRANSLATE_NOOP("QShortcut", "Launch (5)") },
- { Qt::Key_Launch6, QT_TRANSLATE_NOOP("QShortcut", "Launch (6)") },
- { Qt::Key_Launch7, QT_TRANSLATE_NOOP("QShortcut", "Launch (7)") },
- { Qt::Key_Launch8, QT_TRANSLATE_NOOP("QShortcut", "Launch (8)") },
- { Qt::Key_Launch9, QT_TRANSLATE_NOOP("QShortcut", "Launch (9)") },
- { Qt::Key_LaunchA, QT_TRANSLATE_NOOP("QShortcut", "Launch (A)") },
- { Qt::Key_LaunchB, QT_TRANSLATE_NOOP("QShortcut", "Launch (B)") },
- { Qt::Key_LaunchC, QT_TRANSLATE_NOOP("QShortcut", "Launch (C)") },
- { Qt::Key_LaunchD, QT_TRANSLATE_NOOP("QShortcut", "Launch (D)") },
- { Qt::Key_LaunchE, QT_TRANSLATE_NOOP("QShortcut", "Launch (E)") },
- { Qt::Key_LaunchF, QT_TRANSLATE_NOOP("QShortcut", "Launch (F)") },
- { Qt::Key_MonBrightnessUp, QT_TRANSLATE_NOOP("QShortcut", "Monitor Brightness Up") },
- { Qt::Key_MonBrightnessDown, QT_TRANSLATE_NOOP("QShortcut", "Monitor Brightness Down") },
- { Qt::Key_KeyboardLightOnOff, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Light On/Off") },
- { Qt::Key_KeyboardBrightnessUp, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Brightness Up") },
- { Qt::Key_KeyboardBrightnessDown, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Brightness Down") },
- { Qt::Key_PowerOff, QT_TRANSLATE_NOOP("QShortcut", "Power Off") },
- { Qt::Key_WakeUp, QT_TRANSLATE_NOOP("QShortcut", "Wake Up") },
- { Qt::Key_Eject, QT_TRANSLATE_NOOP("QShortcut", "Eject") },
- { Qt::Key_ScreenSaver, QT_TRANSLATE_NOOP("QShortcut", "Screensaver") },
- { Qt::Key_WWW, QT_TRANSLATE_NOOP("QShortcut", "WWW") },
- { Qt::Key_Sleep, QT_TRANSLATE_NOOP("QShortcut", "Sleep") },
- { Qt::Key_LightBulb, QT_TRANSLATE_NOOP("QShortcut", "LightBulb") },
- { Qt::Key_Shop, QT_TRANSLATE_NOOP("QShortcut", "Shop") },
- { Qt::Key_History, QT_TRANSLATE_NOOP("QShortcut", "History") },
- { Qt::Key_AddFavorite, QT_TRANSLATE_NOOP("QShortcut", "Add Favorite") },
- { Qt::Key_HotLinks, QT_TRANSLATE_NOOP("QShortcut", "Hot Links") },
- { Qt::Key_BrightnessAdjust, QT_TRANSLATE_NOOP("QShortcut", "Adjust Brightness") },
- { Qt::Key_Finance, QT_TRANSLATE_NOOP("QShortcut", "Finance") },
- { Qt::Key_Community, QT_TRANSLATE_NOOP("QShortcut", "Community") },
- { Qt::Key_AudioRewind, QT_TRANSLATE_NOOP("QShortcut", "Audio Rewind") },
- { Qt::Key_BackForward, QT_TRANSLATE_NOOP("QShortcut", "Back Forward") },
- { Qt::Key_ApplicationLeft, QT_TRANSLATE_NOOP("QShortcut", "Application Left") },
- { Qt::Key_ApplicationRight, QT_TRANSLATE_NOOP("QShortcut", "Application Right") },
- { Qt::Key_Book, QT_TRANSLATE_NOOP("QShortcut", "Book") },
- { Qt::Key_CD, QT_TRANSLATE_NOOP("QShortcut", "CD") },
- { Qt::Key_Calculator, QT_TRANSLATE_NOOP("QShortcut", "Calculator") },
- { Qt::Key_Clear, QT_TRANSLATE_NOOP("QShortcut", "Clear") },
- { Qt::Key_ClearGrab, QT_TRANSLATE_NOOP("QShortcut", "Clear Grab") },
- { Qt::Key_Close, QT_TRANSLATE_NOOP("QShortcut", "Close") },
- { Qt::Key_Copy, QT_TRANSLATE_NOOP("QShortcut", "Copy") },
- { Qt::Key_Cut, QT_TRANSLATE_NOOP("QShortcut", "Cut") },
- { Qt::Key_Display, QT_TRANSLATE_NOOP("QShortcut", "Display") },
- { Qt::Key_DOS, QT_TRANSLATE_NOOP("QShortcut", "DOS") },
- { Qt::Key_Documents, QT_TRANSLATE_NOOP("QShortcut", "Documents") },
- { Qt::Key_Excel, QT_TRANSLATE_NOOP("QShortcut", "Spreadsheet") },
- { Qt::Key_Explorer, QT_TRANSLATE_NOOP("QShortcut", "Browser") },
- { Qt::Key_Game, QT_TRANSLATE_NOOP("QShortcut", "Game") },
- { Qt::Key_Go, QT_TRANSLATE_NOOP("QShortcut", "Go") },
- { Qt::Key_iTouch, QT_TRANSLATE_NOOP("QShortcut", "iTouch") },
- { Qt::Key_LogOff, QT_TRANSLATE_NOOP("QShortcut", "Logoff") },
- { Qt::Key_Market, QT_TRANSLATE_NOOP("QShortcut", "Market") },
- { Qt::Key_Meeting, QT_TRANSLATE_NOOP("QShortcut", "Meeting") },
- { Qt::Key_MenuKB, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Menu") },
- { Qt::Key_MenuPB, QT_TRANSLATE_NOOP("QShortcut", "Menu PB") },
- { Qt::Key_MySites, QT_TRANSLATE_NOOP("QShortcut", "My Sites") },
- { Qt::Key_News, QT_TRANSLATE_NOOP("QShortcut", "News") },
- { Qt::Key_OfficeHome, QT_TRANSLATE_NOOP("QShortcut", "Home Office") },
- { Qt::Key_Option, QT_TRANSLATE_NOOP("QShortcut", "Option") },
- { Qt::Key_Paste, QT_TRANSLATE_NOOP("QShortcut", "Paste") },
- { Qt::Key_Phone, QT_TRANSLATE_NOOP("QShortcut", "Phone") },
- { Qt::Key_Reply, QT_TRANSLATE_NOOP("QShortcut", "Reply") },
- { Qt::Key_Reload, QT_TRANSLATE_NOOP("QShortcut", "Reload") },
- { Qt::Key_RotateWindows, QT_TRANSLATE_NOOP("QShortcut", "Rotate Windows") },
- { Qt::Key_RotationPB, QT_TRANSLATE_NOOP("QShortcut", "Rotation PB") },
- { Qt::Key_RotationKB, QT_TRANSLATE_NOOP("QShortcut", "Rotation KB") },
- { Qt::Key_Save, QT_TRANSLATE_NOOP("QShortcut", "Save") },
- { Qt::Key_Send, QT_TRANSLATE_NOOP("QShortcut", "Send") },
- { Qt::Key_Spell, QT_TRANSLATE_NOOP("QShortcut", "Spellchecker") },
- { Qt::Key_SplitScreen, QT_TRANSLATE_NOOP("QShortcut", "Split Screen") },
- { Qt::Key_Support, QT_TRANSLATE_NOOP("QShortcut", "Support") },
- { Qt::Key_TaskPane, QT_TRANSLATE_NOOP("QShortcut", "Task Panel") },
- { Qt::Key_Terminal, QT_TRANSLATE_NOOP("QShortcut", "Terminal") },
- { Qt::Key_Tools, QT_TRANSLATE_NOOP("QShortcut", "Tools") },
- { Qt::Key_Travel, QT_TRANSLATE_NOOP("QShortcut", "Travel") },
- { Qt::Key_Video, QT_TRANSLATE_NOOP("QShortcut", "Video") },
- { Qt::Key_Word, QT_TRANSLATE_NOOP("QShortcut", "Word Processor") },
- { Qt::Key_Xfer, QT_TRANSLATE_NOOP("QShortcut", "XFer") },
- { Qt::Key_ZoomIn, QT_TRANSLATE_NOOP("QShortcut", "Zoom In") },
- { Qt::Key_ZoomOut, QT_TRANSLATE_NOOP("QShortcut", "Zoom Out") },
- { Qt::Key_Away, QT_TRANSLATE_NOOP("QShortcut", "Away") },
- { Qt::Key_Messenger, QT_TRANSLATE_NOOP("QShortcut", "Messenger") },
- { Qt::Key_WebCam, QT_TRANSLATE_NOOP("QShortcut", "WebCam") },
- { Qt::Key_MailForward, QT_TRANSLATE_NOOP("QShortcut", "Mail Forward") },
- { Qt::Key_Pictures, QT_TRANSLATE_NOOP("QShortcut", "Pictures") },
- { Qt::Key_Music, QT_TRANSLATE_NOOP("QShortcut", "Music") },
- { Qt::Key_Battery, QT_TRANSLATE_NOOP("QShortcut", "Battery") },
- { Qt::Key_Bluetooth, QT_TRANSLATE_NOOP("QShortcut", "Bluetooth") },
- { Qt::Key_WLAN, QT_TRANSLATE_NOOP("QShortcut", "Wireless") },
- { Qt::Key_UWB, QT_TRANSLATE_NOOP("QShortcut", "Ultra Wide Band") },
- { Qt::Key_AudioForward, QT_TRANSLATE_NOOP("QShortcut", "Audio Forward") },
- { Qt::Key_AudioRepeat, QT_TRANSLATE_NOOP("QShortcut", "Audio Repeat") },
- { Qt::Key_AudioRandomPlay, QT_TRANSLATE_NOOP("QShortcut", "Audio Random Play") },
- { Qt::Key_Subtitle, QT_TRANSLATE_NOOP("QShortcut", "Subtitle") },
- { Qt::Key_AudioCycleTrack, QT_TRANSLATE_NOOP("QShortcut", "Audio Cycle Track") },
- { Qt::Key_Time, QT_TRANSLATE_NOOP("QShortcut", "Time") },
- { Qt::Key_Select, QT_TRANSLATE_NOOP("QShortcut", "Select") },
- { Qt::Key_View, QT_TRANSLATE_NOOP("QShortcut", "View") },
- { Qt::Key_TopMenu, QT_TRANSLATE_NOOP("QShortcut", "Top Menu") },
- { Qt::Key_Suspend, QT_TRANSLATE_NOOP("QShortcut", "Suspend") },
- { Qt::Key_Hibernate, QT_TRANSLATE_NOOP("QShortcut", "Hibernate") },
-
- // --------------------------------------------------------------
- // More consistent namings
- { Qt::Key_Print, QT_TRANSLATE_NOOP("QShortcut", "Print Screen") },
- { Qt::Key_PageUp, QT_TRANSLATE_NOOP("QShortcut", "Page Up") },
- { Qt::Key_PageDown, QT_TRANSLATE_NOOP("QShortcut", "Page Down") },
- { Qt::Key_CapsLock, QT_TRANSLATE_NOOP("QShortcut", "Caps Lock") },
- { Qt::Key_NumLock, QT_TRANSLATE_NOOP("QShortcut", "Num Lock") },
- { Qt::Key_NumLock, QT_TRANSLATE_NOOP("QShortcut", "Number Lock") },
- { Qt::Key_ScrollLock, QT_TRANSLATE_NOOP("QShortcut", "Scroll Lock") },
- { Qt::Key_Insert, QT_TRANSLATE_NOOP("QShortcut", "Insert") },
- { Qt::Key_Delete, QT_TRANSLATE_NOOP("QShortcut", "Delete") },
- { Qt::Key_Escape, QT_TRANSLATE_NOOP("QShortcut", "Escape") },
- { Qt::Key_SysReq, QT_TRANSLATE_NOOP("QShortcut", "System Request") },
-
- // --------------------------------------------------------------
- // Keypad navigation keys
- { Qt::Key_Select, QT_TRANSLATE_NOOP("QShortcut", "Select") },
- { Qt::Key_Yes, QT_TRANSLATE_NOOP("QShortcut", "Yes") },
- { Qt::Key_No, QT_TRANSLATE_NOOP("QShortcut", "No") },
-
- // --------------------------------------------------------------
- // Device keys
- { Qt::Key_Context1, QT_TRANSLATE_NOOP("QShortcut", "Context1") },
- { Qt::Key_Context2, QT_TRANSLATE_NOOP("QShortcut", "Context2") },
- { Qt::Key_Context3, QT_TRANSLATE_NOOP("QShortcut", "Context3") },
- { Qt::Key_Context4, QT_TRANSLATE_NOOP("QShortcut", "Context4") },
- //: Button to start a call (note: a separate button is used to end the call)
- { Qt::Key_Call, QT_TRANSLATE_NOOP("QShortcut", "Call") },
- //: Button to end a call (note: a separate button is used to start the call)
- { Qt::Key_Hangup, QT_TRANSLATE_NOOP("QShortcut", "Hangup") },
- //: Button that will hang up if we're in call, or make a call if we're not.
- { Qt::Key_ToggleCallHangup, QT_TRANSLATE_NOOP("QShortcut", "Toggle Call/Hangup") },
- { Qt::Key_Flip, QT_TRANSLATE_NOOP("QShortcut", "Flip") },
- //: Button to trigger voice dialing
- { Qt::Key_VoiceDial, QT_TRANSLATE_NOOP("QShortcut", "Voice Dial") },
- //: Button to redial the last number called
- { Qt::Key_LastNumberRedial, QT_TRANSLATE_NOOP("QShortcut", "Last Number Redial") },
- //: Button to trigger the camera shutter (take a picture)
- { Qt::Key_Camera, QT_TRANSLATE_NOOP("QShortcut", "Camera Shutter") },
- //: Button to focus the camera
- { Qt::Key_CameraFocus, QT_TRANSLATE_NOOP("QShortcut", "Camera Focus") },
-
- // --------------------------------------------------------------
- // Japanese keyboard support
- { Qt::Key_Kanji, QT_TRANSLATE_NOOP("QShortcut", "Kanji") },
- { Qt::Key_Muhenkan, QT_TRANSLATE_NOOP("QShortcut", "Muhenkan") },
- { Qt::Key_Henkan, QT_TRANSLATE_NOOP("QShortcut", "Henkan") },
- { Qt::Key_Romaji, QT_TRANSLATE_NOOP("QShortcut", "Romaji") },
- { Qt::Key_Hiragana, QT_TRANSLATE_NOOP("QShortcut", "Hiragana") },
- { Qt::Key_Katakana, QT_TRANSLATE_NOOP("QShortcut", "Katakana") },
- { Qt::Key_Hiragana_Katakana,QT_TRANSLATE_NOOP("QShortcut", "Hiragana Katakana") },
- { Qt::Key_Zenkaku, QT_TRANSLATE_NOOP("QShortcut", "Zenkaku") },
- { Qt::Key_Hankaku, QT_TRANSLATE_NOOP("QShortcut", "Hankaku") },
- { Qt::Key_Zenkaku_Hankaku, QT_TRANSLATE_NOOP("QShortcut", "Zenkaku Hankaku") },
- { Qt::Key_Touroku, QT_TRANSLATE_NOOP("QShortcut", "Touroku") },
- { Qt::Key_Massyo, QT_TRANSLATE_NOOP("QShortcut", "Massyo") },
- { Qt::Key_Kana_Lock, QT_TRANSLATE_NOOP("QShortcut", "Kana Lock") },
- { Qt::Key_Kana_Shift, QT_TRANSLATE_NOOP("QShortcut", "Kana Shift") },
- { Qt::Key_Eisu_Shift, QT_TRANSLATE_NOOP("QShortcut", "Eisu Shift") },
- { Qt::Key_Eisu_toggle, QT_TRANSLATE_NOOP("QShortcut", "Eisu toggle") },
- { Qt::Key_Codeinput, QT_TRANSLATE_NOOP("QShortcut", "Code input") },
- { Qt::Key_MultipleCandidate,QT_TRANSLATE_NOOP("QShortcut", "Multiple Candidate") },
- { Qt::Key_PreviousCandidate,QT_TRANSLATE_NOOP("QShortcut", "Previous Candidate") },
-
- // --------------------------------------------------------------
- // Korean keyboard support
- { Qt::Key_Hangul, QT_TRANSLATE_NOOP("QShortcut", "Hangul") },
- { Qt::Key_Hangul_Start, QT_TRANSLATE_NOOP("QShortcut", "Hangul Start") },
- { Qt::Key_Hangul_End, QT_TRANSLATE_NOOP("QShortcut", "Hangul End") },
- { Qt::Key_Hangul_Hanja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Hanja") },
- { Qt::Key_Hangul_Jamo, QT_TRANSLATE_NOOP("QShortcut", "Hangul Jamo") },
- { Qt::Key_Hangul_Romaja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Romaja") },
- { Qt::Key_Hangul_Jeonja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Jeonja") },
- { Qt::Key_Hangul_Banja, QT_TRANSLATE_NOOP("QShortcut", "Hangul Banja") },
- { Qt::Key_Hangul_PreHanja, QT_TRANSLATE_NOOP("QShortcut", "Hangul PreHanja") },
- { Qt::Key_Hangul_PostHanja,QT_TRANSLATE_NOOP("QShortcut", "Hangul PostHanja") },
- { Qt::Key_Hangul_Special, QT_TRANSLATE_NOOP("QShortcut", "Hangul Special") },
-
- { 0, 0 }
-};
-
-//Table of key bindings. It must be sorted on key sequence.
-//A priority of 1 indicates that this is the primary key binding when multiple are defined.
-
-const QKeyBinding QKeySequencePrivate::keyBindings[] = {
-// StandardKey Priority Key Sequence Platforms
- {QKeySequence::Back, 0, Qt::Key_Backspace, QApplicationPrivate::KB_Win},
- {QKeySequence::InsertParagraphSeparator,0, Qt::Key_Return, QApplicationPrivate::KB_All},
- {QKeySequence::InsertParagraphSeparator,0, Qt::Key_Enter, QApplicationPrivate::KB_All},
- {QKeySequence::Delete, 1, Qt::Key_Delete, QApplicationPrivate::KB_All},
- {QKeySequence::MoveToStartOfLine, 0, Qt::Key_Home, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60},
- {QKeySequence::MoveToStartOfDocument, 0, Qt::Key_Home, QApplicationPrivate::KB_Mac},
- {QKeySequence::MoveToEndOfLine, 0, Qt::Key_End, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60},
- {QKeySequence::MoveToEndOfDocument, 0, Qt::Key_End, QApplicationPrivate::KB_Mac},
- {QKeySequence::MoveToPreviousChar, 0, Qt::Key_Left, QApplicationPrivate::KB_All},
- {QKeySequence::MoveToPreviousLine, 0, Qt::Key_Up, QApplicationPrivate::KB_All},
- {QKeySequence::MoveToNextChar, 0, Qt::Key_Right, QApplicationPrivate::KB_All},
- {QKeySequence::MoveToNextLine, 0, Qt::Key_Down, QApplicationPrivate::KB_All},
- {QKeySequence::MoveToPreviousPage, 1, Qt::Key_PageUp, QApplicationPrivate::KB_All},
- {QKeySequence::MoveToNextPage, 1, Qt::Key_PageDown, QApplicationPrivate::KB_All},
- {QKeySequence::HelpContents, 0, Qt::Key_F1, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11},
- {QKeySequence::HelpContents, 0, Qt::Key_F2, QApplicationPrivate::KB_S60},
- {QKeySequence::FindNext, 0, Qt::Key_F3, QApplicationPrivate::KB_X11},
- {QKeySequence::FindNext, 1, Qt::Key_F3, QApplicationPrivate::KB_Win},
- {QKeySequence::Refresh, 0, Qt::Key_F5, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11},
- {QKeySequence::Undo, 0, Qt::Key_F14, QApplicationPrivate::KB_X11}, //Undo on sun keyboards
- {QKeySequence::Copy, 0, Qt::Key_F16, QApplicationPrivate::KB_X11}, //Copy on sun keyboards
- {QKeySequence::Paste, 0, Qt::Key_F18, QApplicationPrivate::KB_X11}, //Paste on sun keyboards
- {QKeySequence::Cut, 0, Qt::Key_F20, QApplicationPrivate::KB_X11}, //Cut on sun keyboards
- {QKeySequence::PreviousChild, 0, Qt::Key_Back, QApplicationPrivate::KB_All},
- {QKeySequence::NextChild, 0, Qt::Key_Forward, QApplicationPrivate::KB_All},
- {QKeySequence::Forward, 0, Qt::SHIFT | Qt::Key_Backspace, QApplicationPrivate::KB_Win},
- {QKeySequence::Delete, 0, Qt::SHIFT | Qt::Key_Backspace, QApplicationPrivate::KB_S60},
- {QKeySequence::InsertLineSeparator, 0, Qt::SHIFT | Qt::Key_Return, QApplicationPrivate::KB_All},
- {QKeySequence::InsertLineSeparator, 0, Qt::SHIFT | Qt::Key_Enter, QApplicationPrivate::KB_All},
- {QKeySequence::Paste, 0, Qt::SHIFT | Qt::Key_Insert, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11},
- {QKeySequence::Cut, 0, Qt::SHIFT | Qt::Key_Delete, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11}, //## Check if this should work on mac
- {QKeySequence::SelectStartOfLine, 0, Qt::SHIFT | Qt::Key_Home, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60},
- {QKeySequence::SelectStartOfDocument, 0, Qt::SHIFT | Qt::Key_Home, QApplicationPrivate::KB_Mac},
- {QKeySequence::SelectEndOfLine, 0, Qt::SHIFT | Qt::Key_End, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60},
- {QKeySequence::SelectEndOfDocument, 0, Qt::SHIFT | Qt::Key_End, QApplicationPrivate::KB_Mac},
- {QKeySequence::SelectPreviousChar, 0, Qt::SHIFT | Qt::Key_Left, QApplicationPrivate::KB_All},
- {QKeySequence::SelectPreviousLine, 0, Qt::SHIFT | Qt::Key_Up, QApplicationPrivate::KB_All},
- {QKeySequence::SelectNextChar, 0, Qt::SHIFT | Qt::Key_Right, QApplicationPrivate::KB_All},
- {QKeySequence::SelectNextLine, 0, Qt::SHIFT | Qt::Key_Down, QApplicationPrivate::KB_All},
- {QKeySequence::SelectPreviousPage, 0, Qt::SHIFT | Qt::Key_PageUp, QApplicationPrivate::KB_All},
- {QKeySequence::SelectNextPage, 0, Qt::SHIFT | Qt::Key_PageDown, QApplicationPrivate::KB_All},
- {QKeySequence::WhatsThis, 1, Qt::SHIFT | Qt::Key_F1, QApplicationPrivate::KB_All},
- {QKeySequence::FindPrevious, 0, Qt::SHIFT | Qt::Key_F3, QApplicationPrivate::KB_X11},
- {QKeySequence::FindPrevious, 1, Qt::SHIFT | Qt::Key_F3, QApplicationPrivate::KB_Win},
- {QKeySequence::ZoomIn, 1, Qt::CTRL | Qt::Key_Plus, QApplicationPrivate::KB_All},
- {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_Comma, QApplicationPrivate::KB_KDE},
- {QKeySequence::Preferences, 0, Qt::CTRL | Qt::Key_Comma, QApplicationPrivate::KB_Mac},
- {QKeySequence::ZoomOut, 1, Qt::CTRL | Qt::Key_Minus, QApplicationPrivate::KB_All},
- {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::Key_Period, QApplicationPrivate::KB_KDE},
- {QKeySequence::HelpContents, 1, Qt::CTRL | Qt::Key_Question, QApplicationPrivate::KB_Mac},
- {QKeySequence::SelectAll, 1, Qt::CTRL | Qt::Key_A, QApplicationPrivate::KB_All},
- {QKeySequence::Bold, 1, Qt::CTRL | Qt::Key_B, QApplicationPrivate::KB_All},
- {QKeySequence::Copy, 1, Qt::CTRL | Qt::Key_C, QApplicationPrivate::KB_All},
- {QKeySequence::Delete, 0, Qt::CTRL | Qt::Key_D, QApplicationPrivate::KB_X11}, //emacs (line edit only)
- {QKeySequence::Find, 0, Qt::CTRL | Qt::Key_F, QApplicationPrivate::KB_All},
- {QKeySequence::FindNext, 1, Qt::CTRL | Qt::Key_G, QApplicationPrivate::KB_Gnome | QApplicationPrivate::KB_Mac},
- {QKeySequence::FindNext, 0, Qt::CTRL | Qt::Key_G, QApplicationPrivate::KB_Win},
- {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_H, QApplicationPrivate::KB_Win},
- {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_H, QApplicationPrivate::KB_Gnome},
- {QKeySequence::Italic, 0, Qt::CTRL | Qt::Key_I, QApplicationPrivate::KB_All},
- {QKeySequence::DeleteEndOfLine, 0, Qt::CTRL | Qt::Key_K, QApplicationPrivate::KB_X11}, //emacs (line edit only)
- {QKeySequence::New, 1, Qt::CTRL | Qt::Key_N, QApplicationPrivate::KB_All},
- {QKeySequence::Open, 1, Qt::CTRL | Qt::Key_O, QApplicationPrivate::KB_All},
- {QKeySequence::Print, 1, Qt::CTRL | Qt::Key_P, QApplicationPrivate::KB_All},
- {QKeySequence::Quit, 0, Qt::CTRL | Qt::Key_Q, QApplicationPrivate::KB_Gnome | QApplicationPrivate::KB_KDE | QApplicationPrivate::KB_Mac},
- {QKeySequence::Refresh, 1, Qt::CTRL | Qt::Key_R, QApplicationPrivate::KB_Gnome | QApplicationPrivate::KB_Mac},
- {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_R, QApplicationPrivate::KB_KDE},
- {QKeySequence::Save, 1, Qt::CTRL | Qt::Key_S, QApplicationPrivate::KB_All},
- {QKeySequence::AddTab, 0, Qt::CTRL | Qt::Key_T, QApplicationPrivate::KB_All},
- {QKeySequence::Underline, 1, Qt::CTRL | Qt::Key_U, QApplicationPrivate::KB_All},
- {QKeySequence::Paste, 1, Qt::CTRL | Qt::Key_V, QApplicationPrivate::KB_All},
- {QKeySequence::Close, 0, Qt::CTRL | Qt::Key_W, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11},
- {QKeySequence::Close, 1, Qt::CTRL | Qt::Key_W, QApplicationPrivate::KB_Mac},
- {QKeySequence::Cut, 1, Qt::CTRL | Qt::Key_X, QApplicationPrivate::KB_All},
- {QKeySequence::Redo, 1, Qt::CTRL | Qt::Key_Y, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_S60},
- {QKeySequence::Undo, 1, Qt::CTRL | Qt::Key_Z, QApplicationPrivate::KB_All},
- {QKeySequence::Back, 1, Qt::CTRL | Qt::Key_BracketLeft, QApplicationPrivate::KB_Mac},
- {QKeySequence::Forward, 1, Qt::CTRL | Qt::Key_BracketRight, QApplicationPrivate::KB_Mac},
- {QKeySequence::PreviousChild, 1, Qt::CTRL | Qt::Key_BraceLeft, QApplicationPrivate::KB_Mac},
- {QKeySequence::NextChild, 1, Qt::CTRL | Qt::Key_BraceRight, QApplicationPrivate::KB_Mac},
- {QKeySequence::NextChild, 1, Qt::CTRL | Qt::Key_Tab, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11},
- {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_Tab, QApplicationPrivate::KB_Mac}, //different priority from above
- {QKeySequence::DeleteStartOfWord, 0, Qt::CTRL | Qt::Key_Backspace, QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_Win},
- {QKeySequence::Copy, 0, Qt::CTRL | Qt::Key_Insert, QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_Win},
- {QKeySequence::DeleteEndOfWord, 0, Qt::CTRL | Qt::Key_Delete, QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_Win},
- {QKeySequence::MoveToStartOfDocument, 0, Qt::CTRL | Qt::Key_Home, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60},
- {QKeySequence::MoveToEndOfDocument, 0, Qt::CTRL | Qt::Key_End, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60},
- {QKeySequence::Back, 0, Qt::CTRL | Qt::Key_Left, QApplicationPrivate::KB_Mac},
- {QKeySequence::MoveToPreviousWord, 0, Qt::CTRL | Qt::Key_Left, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60},
- {QKeySequence::MoveToStartOfLine, 0, Qt::CTRL | Qt::Key_Left, QApplicationPrivate::KB_Mac },
- {QKeySequence::MoveToStartOfDocument, 1, Qt::CTRL | Qt::Key_Up, QApplicationPrivate::KB_Mac},
- {QKeySequence::Forward, 0, Qt::CTRL | Qt::Key_Right, QApplicationPrivate::KB_Mac},
- {QKeySequence::MoveToEndOfLine, 0, Qt::CTRL | Qt::Key_Right, QApplicationPrivate::KB_Mac },
- {QKeySequence::MoveToNextWord, 0, Qt::CTRL | Qt::Key_Right, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60},
- {QKeySequence::MoveToEndOfDocument, 1, Qt::CTRL | Qt::Key_Down, QApplicationPrivate::KB_Mac},
- {QKeySequence::Close, 1, Qt::CTRL | Qt::Key_F4, QApplicationPrivate::KB_Win},
- {QKeySequence::Close, 0, Qt::CTRL | Qt::Key_F4, QApplicationPrivate::KB_Mac},
- {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_F6, QApplicationPrivate::KB_Win},
- {QKeySequence::FindPrevious, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_G, QApplicationPrivate::KB_Gnome | QApplicationPrivate::KB_Mac},
- {QKeySequence::FindPrevious, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_G, QApplicationPrivate::KB_Win},
- {QKeySequence::AddTab, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_N, QApplicationPrivate::KB_KDE},
- {QKeySequence::SaveAs, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_S, QApplicationPrivate::KB_Gnome | QApplicationPrivate::KB_Mac},
- {QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60},
- {QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, QApplicationPrivate::KB_Mac},
- {QKeySequence::PreviousChild, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11},
- {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, QApplicationPrivate::KB_Mac },//different priority from above
- {QKeySequence::Paste, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Insert, QApplicationPrivate::KB_X11},
- {QKeySequence::SelectStartOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Home, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60},
- {QKeySequence::SelectEndOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_End, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60},
- {QKeySequence::SelectPreviousWord, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Left, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60},
- {QKeySequence::SelectStartOfLine, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Left, QApplicationPrivate::KB_Mac },
- {QKeySequence::SelectStartOfDocument, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Up, QApplicationPrivate::KB_Mac},
- {QKeySequence::SelectNextWord, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Right, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11 | QApplicationPrivate::KB_S60},
- {QKeySequence::SelectEndOfLine, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Right, QApplicationPrivate::KB_Mac },
- {QKeySequence::SelectEndOfDocument, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Down, QApplicationPrivate::KB_Mac},
- {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_F6, QApplicationPrivate::KB_Win},
- {QKeySequence::Undo, 0, Qt::ALT | Qt::Key_Backspace, QApplicationPrivate::KB_Win},
- {QKeySequence::DeleteStartOfWord, 0, Qt::ALT | Qt::Key_Backspace, QApplicationPrivate::KB_Mac},
- {QKeySequence::DeleteEndOfWord, 0, Qt::ALT | Qt::Key_Delete, QApplicationPrivate::KB_Mac},
- {QKeySequence::Back, 1, Qt::ALT | Qt::Key_Left, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11},
- {QKeySequence::MoveToPreviousWord, 0, Qt::ALT | Qt::Key_Left, QApplicationPrivate::KB_Mac},
- {QKeySequence::MoveToStartOfBlock, 0, Qt::ALT | Qt::Key_Up, QApplicationPrivate::KB_Mac}, //mac only
- {QKeySequence::MoveToNextWord, 0, Qt::ALT | Qt::Key_Right, QApplicationPrivate::KB_Mac},
- {QKeySequence::Forward, 1, Qt::ALT | Qt::Key_Right, QApplicationPrivate::KB_Win | QApplicationPrivate::KB_X11},
- {QKeySequence::MoveToEndOfBlock, 0, Qt::ALT | Qt::Key_Down, QApplicationPrivate::KB_Mac}, //mac only
- {QKeySequence::MoveToPreviousPage, 0, Qt::ALT | Qt::Key_PageUp, QApplicationPrivate::KB_Mac },
- {QKeySequence::MoveToNextPage, 0, Qt::ALT | Qt::Key_PageDown, QApplicationPrivate::KB_Mac },
- {QKeySequence::Redo, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Backspace,QApplicationPrivate::KB_Win},
- {QKeySequence::SelectPreviousWord, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Left, QApplicationPrivate::KB_Mac},
- {QKeySequence::SelectStartOfBlock, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Up, QApplicationPrivate::KB_Mac}, //mac only
- {QKeySequence::SelectNextWord, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Right, QApplicationPrivate::KB_Mac},
- {QKeySequence::SelectEndOfBlock, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Down, QApplicationPrivate::KB_Mac}, //mac only
- {QKeySequence::MoveToStartOfBlock, 0, Qt::META | Qt::Key_A, QApplicationPrivate::KB_Mac},
- {QKeySequence::Delete, 0, Qt::META | Qt::Key_D, QApplicationPrivate::KB_Mac},
- {QKeySequence::MoveToEndOfBlock, 0, Qt::META | Qt::Key_E, QApplicationPrivate::KB_Mac},
- {QKeySequence::InsertLineSeparator, 0, Qt::META | Qt::Key_Return, QApplicationPrivate::KB_Mac},
- {QKeySequence::InsertLineSeparator, 0, Qt::META | Qt::Key_Enter, QApplicationPrivate::KB_Mac},
- {QKeySequence::MoveToStartOfLine, 0, Qt::META | Qt::Key_Left, QApplicationPrivate::KB_Mac},
- {QKeySequence::MoveToPreviousPage, 0, Qt::META | Qt::Key_Up, QApplicationPrivate::KB_Mac},
- {QKeySequence::MoveToEndOfLine, 0, Qt::META | Qt::Key_Right, QApplicationPrivate::KB_Mac},
- {QKeySequence::MoveToNextPage, 0, Qt::META | Qt::Key_Down, QApplicationPrivate::KB_Mac},
- {QKeySequence::MoveToPreviousPage, 0, Qt::META | Qt::Key_PageUp, QApplicationPrivate::KB_Mac},
- {QKeySequence::MoveToNextPage, 0, Qt::META | Qt::Key_PageDown, QApplicationPrivate::KB_Mac},
- {QKeySequence::SelectStartOfBlock, 0, Qt::META | Qt::SHIFT | Qt::Key_A, QApplicationPrivate::KB_Mac},
- {QKeySequence::SelectEndOfBlock, 0, Qt::META | Qt::SHIFT | Qt::Key_E, QApplicationPrivate::KB_Mac},
- {QKeySequence::SelectStartOfLine, 0, Qt::META | Qt::SHIFT | Qt::Key_Left, QApplicationPrivate::KB_Mac},
- {QKeySequence::SelectEndOfLine, 0, Qt::META | Qt::SHIFT | Qt::Key_Right, QApplicationPrivate::KB_Mac}
-};
-
-const uint QKeySequencePrivate::numberOfKeyBindings = sizeof(QKeySequencePrivate::keyBindings)/(sizeof(QKeyBinding));
-
-
-/*!
- \enum QKeySequence::StandardKey
- \since 4.2
-
- This enum represent standard key bindings. They can be used to
- assign platform dependent keyboard shortcuts to a QAction.
-
- Note that the key bindings are platform dependent. The currently
- bound shortcuts can be queried using keyBindings().
-
- \value AddTab Add new tab.
- \value Back Navigate back.
- \value Bold Bold text.
- \value Close Close document/tab.
- \value Copy Copy.
- \value Cut Cut.
- \value Delete Delete.
- \value DeleteEndOfLine Delete end of line.
- \value DeleteEndOfWord Delete word from the end of the cursor.
- \value DeleteStartOfWord Delete the beginning of a word up to the cursor.
- \value Find Find in document.
- \value FindNext Find next result.
- \value FindPrevious Find previous result.
- \value Forward Navigate forward.
- \value HelpContents Open help contents.
- \value InsertLineSeparator Insert a new line.
- \value InsertParagraphSeparator Insert a new paragraph.
- \value Italic Italic text.
- \value MoveToEndOfBlock Move cursor to end of block. This shortcut is only used on the OS X.
- \value MoveToEndOfDocument Move cursor to end of document.
- \value MoveToEndOfLine Move cursor to end of line.
- \value MoveToNextChar Move cursor to next character.
- \value MoveToNextLine Move cursor to next line.
- \value MoveToNextPage Move cursor to next page.
- \value MoveToNextWord Move cursor to next word.
- \value MoveToPreviousChar Move cursor to previous character.
- \value MoveToPreviousLine Move cursor to previous line.
- \value MoveToPreviousPage Move cursor to previous page.
- \value MoveToPreviousWord Move cursor to previous word.
- \value MoveToStartOfBlock Move cursor to start of a block. This shortcut is only used on OS X.
- \value MoveToStartOfDocument Move cursor to start of document.
- \value MoveToStartOfLine Move cursor to start of line.
- \value New Create new document.
- \value NextChild Navigate to next tab or child window.
- \value Open Open document.
- \value Paste Paste.
- \value Preferences Open the preferences dialog.
- \value PreviousChild Navigate to previous tab or child window.
- \value Print Print document.
- \value Quit Quit the application.
- \value Redo Redo.
- \value Refresh Refresh or reload current document.
- \value Replace Find and replace.
- \value SaveAs Save document after prompting the user for a file name.
- \value Save Save document.
- \value SelectAll Select all text.
- \value SelectEndOfBlock Extend selection to the end of a text block. This shortcut is only used on OS X.
- \value SelectEndOfDocument Extend selection to end of document.
- \value SelectEndOfLine Extend selection to end of line.
- \value SelectNextChar Extend selection to next character.
- \value SelectNextLine Extend selection to next line.
- \value SelectNextPage Extend selection to next page.
- \value SelectNextWord Extend selection to next word.
- \value SelectPreviousChar Extend selection to previous character.
- \value SelectPreviousLine Extend selection to previous line.
- \value SelectPreviousPage Extend selection to previous page.
- \value SelectPreviousWord Extend selection to previous word.
- \value SelectStartOfBlock Extend selection to the start of a text block. This shortcut is only used on OS X.
- \value SelectStartOfDocument Extend selection to start of document.
- \value SelectStartOfLine Extend selection to start of line.
- \value Underline Underline text.
- \value Undo Undo.
- \value UnknownKey Unbound key.
- \value WhatsThis Activate whats this.
- \value ZoomIn Zoom in.
- \value ZoomOut Zoom out.
-*/
-
-/*!
- \since 4.2
-
- Constructs a QKeySequence object for the given \a key.
- The result will depend on the currently running platform.
-
- The resulting object will be based on the first element in the
- list of key bindings for the \a key.
-*/
-QKeySequence::QKeySequence(StandardKey key)
-{
- const QList <QKeySequence> bindings = keyBindings(key);
- //pick only the first/primary shortcut from current bindings
- if (bindings.size() > 0) {
- d = bindings.first().d;
- d->ref.ref();
- }
- else
- d = new QKeySequencePrivate();
-}
-
-
-/*!
- Constructs an empty key sequence.
-*/
-QKeySequence::QKeySequence()
-{
- static QKeySequencePrivate shared_empty;
- d = &shared_empty;
- d->ref.ref();
-}
-
-/*!
- Creates a key sequence from the \a key string. For example
- "Ctrl+O" gives CTRL+'O'. The strings "Ctrl",
- "Shift", "Alt" and "Meta" are recognized, as well as their
- translated equivalents in the "QShortcut" context (using
- QObject::tr()).
-
- Up to four key codes may be entered by separating them with
- commas, e.g. "Alt+X,Ctrl+S,Q".
-
- \a key should be in NativeText format.
-
- This constructor is typically used with \link QObject::tr() tr
- \endlink(), so that shortcut keys can be replaced in
- translations:
-
- \snippet doc/src/snippets/code/src_gui_kernel_qkeysequence.cpp 2
-
- Note the "File|Open" translator comment. It is by no means
- necessary, but it provides some context for the human translator.
-*/
-QKeySequence::QKeySequence(const QString &key)
-{
- d = new QKeySequencePrivate();
- assign(key);
-}
-
-/*!
- \since 4.x
- Creates a key sequence from the \a key string based on \a format.
-*/
-QKeySequence::QKeySequence(const QString &key, QKeySequence::SequenceFormat format)
-{
- d = new QKeySequencePrivate();
- assign(key, format);
-}
-
-/*!
- Constructs a key sequence with up to 4 keys \a k1, \a k2,
- \a k3 and \a k4.
-
- The key codes are listed in Qt::Key and can be combined with
- modifiers (see Qt::Modifier) such as Qt::SHIFT, Qt::CTRL,
- Qt::ALT, or Qt::META.
-*/
-QKeySequence::QKeySequence(int k1, int k2, int k3, int k4)
-{
- d = new QKeySequencePrivate();
- d->key[0] = k1;
- d->key[1] = k2;
- d->key[2] = k3;
- d->key[3] = k4;
-}
-
-/*!
- Copy constructor. Makes a copy of \a keysequence.
- */
-QKeySequence::QKeySequence(const QKeySequence& keysequence)
- : d(keysequence.d)
-{
- d->ref.ref();
-}
-
-#ifdef Q_WS_MAC
-static inline int maybeSwapShortcut(int shortcut)
-{
- if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
- uint oldshortcut = shortcut;
- shortcut &= ~(Qt::CTRL | Qt::META);
- if (oldshortcut & Qt::CTRL)
- shortcut |= Qt::META;
- if (oldshortcut & Qt::META)
- shortcut |= Qt::CTRL;
- }
- return shortcut;
-}
-#endif
-
-/*!
- \since 4.2
-
- Returns a list of key bindings for the given \a key.
- The result of calling this function will vary based on the target platform.
- The first element of the list indicates the primary shortcut for the given platform.
- If the result contains more than one result, these can
- be considered alternative shortcuts on the same platform for the given \a key.
-*/
-QList<QKeySequence> QKeySequence::keyBindings(StandardKey key)
-{
- uint platform = QApplicationPrivate::currentPlatform();
- QList <QKeySequence> list;
- for (uint i = 0; i < QKeySequencePrivate::numberOfKeyBindings ; ++i) {
- QKeyBinding keyBinding = QKeySequencePrivate::keyBindings[i];
- if (keyBinding.standardKey == key && (keyBinding.platform & platform)) {
- uint shortcut =
-#ifdef Q_WS_MAC
- maybeSwapShortcut(QKeySequencePrivate::keyBindings[i].shortcut);
-#else
- QKeySequencePrivate::keyBindings[i].shortcut;
-#endif
- if (keyBinding.priority > 0)
- list.prepend(QKeySequence(shortcut));
- else
- list.append(QKeySequence(shortcut));
- }
- }
- return list;
-}
-
-/*!
- Destroys the key sequence.
- */
-QKeySequence::~QKeySequence()
-{
- if (!d->ref.deref())
- delete d;
-}
-
-/*!
- \internal
- KeySequences should never be modified, but rather just created.
- Internally though we do need to modify to keep pace in event
- delivery.
-*/
-
-void QKeySequence::setKey(int key, int index)
-{
- Q_ASSERT_X(index >= 0 && index < 4, "QKeySequence::setKey", "index out of range");
- qAtomicDetach(d);
- d->key[index] = key;
-}
-
-/*!
- Returns the number of keys in the key sequence.
- The maximum is 4.
- */
-uint QKeySequence::count() const
-{
- if (!d->key[0])
- return 0;
- if (!d->key[1])
- return 1;
- if (!d->key[2])
- return 2;
- if (!d->key[3])
- return 3;
- return 4;
-}
-
-
-/*!
- Returns true if the key sequence is empty; otherwise returns
- false.
-*/
-bool QKeySequence::isEmpty() const
-{
- return !d->key[0];
-}
-
-
-/*!
- Returns the shortcut key sequence for the mnemonic in \a text,
- or an empty key sequence if no mnemonics are found.
-
- For example, mnemonic("E&xit") returns \c{Qt::ALT+Qt::Key_X},
- mnemonic("&Quit") returns \c{ALT+Key_Q}, and mnemonic("Quit")
- returns an empty QKeySequence.
-
- We provide a \l{accelerators.html}{list of common mnemonics}
- in English. At the time of writing, Microsoft and Open Group do
- not appear to have issued equivalent recommendations for other
- languages.
-
- \sa qt_set_sequence_auto_mnemonic()
-*/
-QKeySequence QKeySequence::mnemonic(const QString &text)
-{
- QKeySequence ret;
-
- if(qt_sequence_no_mnemonics)
- return ret;
-
- bool found = false;
- int p = 0;
- while (p >= 0) {
- p = text.indexOf(QLatin1Char('&'), p) + 1;
- if (p <= 0 || p >= (int)text.length())
- break;
- if (text.at(p) != QLatin1Char('&')) {
- QChar c = text.at(p);
- if (c.isPrint()) {
- if (!found) {
- c = c.toUpper();
- ret = QKeySequence(c.unicode() + Qt::ALT);
-#ifdef QT_NO_DEBUG
- return ret;
-#else
- found = true;
- } else {
- qWarning("QKeySequence::mnemonic: \"%s\" contains multiple occurrences of '&'", qPrintable(text));
-#endif
- }
- }
- }
- p++;
- }
- return ret;
-}
-
-/*!
- \fn int QKeySequence::assign(const QString &keys)
-
- Adds the given \a keys to the key sequence. \a keys may
- contain up to four key codes, provided they are separated by a
- comma; for example, "Alt+X,Ctrl+S,Z". The return value is the
- number of key codes added.
- \a keys should be in NativeText format.
-*/
-int QKeySequence::assign(const QString &ks)
-{
- return assign(ks, NativeText);
-}
-
-/*!
- \fn int QKeySequence::assign(const QString &keys, QKeySequence::SequenceFormat format)
- \since 4.x
-
- Adds the given \a keys to the key sequence (based on \a format).
- \a keys may contain up to four key codes, provided they are
- separated by a comma; for example, "Alt+X,Ctrl+S,Z". The return
- value is the number of key codes added.
-*/
-int QKeySequence::assign(const QString &ks, QKeySequence::SequenceFormat format)
-{
- QString keyseq = ks;
- QString part;
- int n = 0;
- int p = 0, diff = 0;
-
- // Run through the whole string, but stop
- // if we have 4 keys before the end.
- while (keyseq.length() && n < 4) {
- // We MUST use something to separate each sequence, and space
- // does not cut it, since some of the key names have space
- // in them.. (Let's hope no one translate with a comma in it:)
- p = keyseq.indexOf(QLatin1Char(','));
- if (-1 != p) {
- if (p == keyseq.count() - 1) { // Last comma 'Ctrl+,'
- p = -1;
- } else {
- if (QLatin1Char(',') == keyseq.at(p+1)) // e.g. 'Ctrl+,, Shift+,,'
- p++;
- if (QLatin1Char(' ') == keyseq.at(p+1)) { // Space after comma
- diff = 1;
- p++;
- } else {
- diff = 0;
- }
- }
- }
- part = keyseq.left(-1 == p ? keyseq.length() : p - diff);
- keyseq = keyseq.right(-1 == p ? 0 : keyseq.length() - (p + 1));
- d->key[n] = QKeySequencePrivate::decodeString(part, format);
- ++n;
- }
- return n;
-}
-
-struct QModifKeyName {
- QModifKeyName() { }
- QModifKeyName(int q, QChar n) : qt_key(q), name(n) { }
- QModifKeyName(int q, const QString &n) : qt_key(q), name(n) { }
- int qt_key;
- QString name;
-};
-
-Q_GLOBAL_STATIC(QList<QModifKeyName>, globalModifs)
-Q_GLOBAL_STATIC(QList<QModifKeyName>, globalPortableModifs)
-
-/*!
- Constructs a single key from the string \a str.
-*/
-int QKeySequence::decodeString(const QString &str)
-{
- return QKeySequencePrivate::decodeString(str, NativeText);
-}
-
-int QKeySequencePrivate::decodeString(const QString &str, QKeySequence::SequenceFormat format)
-{
- int ret = 0;
- QString accel = str.toLower();
- bool nativeText = (format == QKeySequence::NativeText);
-
- QList<QModifKeyName> *gmodifs;
- if (nativeText) {
- gmodifs = globalModifs();
- if (gmodifs->isEmpty()) {
-#ifdef Q_WS_MAC
- const bool dontSwap = qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta);
- if (dontSwap)
- *gmodifs << QModifKeyName(Qt::META, QChar(kCommandUnicode));
- else
- *gmodifs << QModifKeyName(Qt::CTRL, QChar(kCommandUnicode));
- *gmodifs << QModifKeyName(Qt::ALT, QChar(kOptionUnicode));
- if (dontSwap)
- *gmodifs << QModifKeyName(Qt::CTRL, QChar(kControlUnicode));
- else
- *gmodifs << QModifKeyName(Qt::META, QChar(kControlUnicode));
- *gmodifs << QModifKeyName(Qt::SHIFT, QChar(kShiftUnicode));
-#endif
- *gmodifs << QModifKeyName(Qt::CTRL, QLatin1String("ctrl+"))
- << QModifKeyName(Qt::SHIFT, QLatin1String("shift+"))
- << QModifKeyName(Qt::ALT, QLatin1String("alt+"))
- << QModifKeyName(Qt::META, QLatin1String("meta+"));
- }
- } else {
- gmodifs = globalPortableModifs();
- if (gmodifs->isEmpty()) {
- *gmodifs << QModifKeyName(Qt::CTRL, QLatin1String("ctrl+"))
- << QModifKeyName(Qt::SHIFT, QLatin1String("shift+"))
- << QModifKeyName(Qt::ALT, QLatin1String("alt+"))
- << QModifKeyName(Qt::META, QLatin1String("meta+"));
- }
- }
- if (!gmodifs) return ret;
-
-
- QList<QModifKeyName> modifs;
- if (nativeText) {
- modifs << QModifKeyName(Qt::CTRL, QShortcut::tr("Ctrl").toLower().append(QLatin1Char('+')))
- << QModifKeyName(Qt::SHIFT, QShortcut::tr("Shift").toLower().append(QLatin1Char('+')))
- << QModifKeyName(Qt::ALT, QShortcut::tr("Alt").toLower().append(QLatin1Char('+')))
- << QModifKeyName(Qt::META, QShortcut::tr("Meta").toLower().append(QLatin1Char('+')));
- }
- modifs += *gmodifs; // Test non-translated ones last
-
- QString sl = accel;
-#ifdef Q_WS_MAC
- for (int i = 0; i < modifs.size(); ++i) {
- const QModifKeyName &mkf = modifs.at(i);
- if (sl.contains(mkf.name)) {
- ret |= mkf.qt_key;
- accel.remove(mkf.name);
- sl = accel;
- }
- }
-#else
- int i = 0;
- int lastI = 0;
- while ((i = sl.indexOf(QLatin1Char('+'), i + 1)) != -1) {
- const QString sub = sl.mid(lastI, i - lastI + 1);
- // Just shortcut the check here if we only have one character.
- // Rational: A modifier will contain the name AND +, so longer than 1, a length of 1 is just
- // the remaining part of the shortcut (ei. The 'C' in "Ctrl+C"), so no need to check that.
- if (sub.length() > 1) {
- for (int j = 0; j < modifs.size(); ++j) {
- const QModifKeyName &mkf = modifs.at(j);
- if (sub == mkf.name) {
- ret |= mkf.qt_key;
- break; // Shortcut, since if we find an other it would/should just be a dup
- }
- }
- }
- lastI = i + 1;
- }
-#endif
-
- int p = accel.lastIndexOf(QLatin1Char('+'), str.length() - 2); // -2 so that Ctrl++ works
- if(p > 0)
- accel = accel.mid(p + 1);
-
- int fnum = 0;
- if (accel.length() == 1) {
-#ifdef Q_WS_MAC
- int qtKey = qtkeyForMacSymbol(accel[0]);
- if (qtKey != -1) {
- ret |= qtKey;
- } else
-#endif
- {
- ret |= accel[0].toUpper().unicode();
- }
- } else if (accel[0] == QLatin1Char('f') && (fnum = accel.mid(1).toInt()) && (fnum >= 1) && (fnum <= 35)) {
- ret |= Qt::Key_F1 + fnum - 1;
- } else {
- // For NativeText, check the traslation table first,
- // if we don't find anything then try it out with just the untranlated stuff.
- // PortableText will only try the untranlated table.
- bool found = false;
- for (int tran = 0; tran < 2; ++tran) {
- if (!nativeText)
- ++tran;
- for (int i = 0; keyname[i].name; ++i) {
- QString keyName(tran == 0
- ? QShortcut::tr(keyname[i].name)
- : QString::fromLatin1(keyname[i].name));
- if (accel == keyName.toLower()) {
- ret |= keyname[i].key;
- found = true;
- break;
- }
- }
- if (found)
- break;
- }
- }
- return ret;
-}
-
-/*!
- Creates a shortcut string for \a key. For example,
- Qt::CTRL+Qt::Key_O gives "Ctrl+O". The strings, "Ctrl", "Shift", etc. are
- translated (using QObject::tr()) in the "QShortcut" context.
- */
-QString QKeySequence::encodeString(int key)
-{
- return QKeySequencePrivate::encodeString(key, NativeText);
-}
-
-static inline void addKey(QString &str, const QString &theKey, QKeySequence::SequenceFormat format)
-{
- if (!str.isEmpty())
- str += (format == QKeySequence::NativeText) ? QShortcut::tr("+")
- : QString::fromLatin1("+");
- str += theKey;
-}
-
-QString QKeySequencePrivate::encodeString(int key, QKeySequence::SequenceFormat format)
-{
- bool nativeText = (format == QKeySequence::NativeText);
- QString s;
-#if defined(Q_WS_MAC)
- if (nativeText) {
- // On Mac OS X the order (by default) is Meta, Alt, Shift, Control.
- // If the AA_MacDontSwapCtrlAndMeta is enabled, then the order
- // is Ctrl, Alt, Shift, Meta. The macSymbolForQtKey does this swap
- // for us, which means that we have to adjust our order here.
- // The upshot is a lot more infrastructure to keep the number of
- // if tests down and the code relatively clean.
- static const int ModifierOrder[] = { Qt::META, Qt::ALT, Qt::SHIFT, Qt::CTRL, 0 };
- static const int QtKeyOrder[] = { Qt::Key_Meta, Qt::Key_Alt, Qt::Key_Shift, Qt::Key_Control, 0 };
- static const int DontSwapModifierOrder[] = { Qt::CTRL, Qt::ALT, Qt::SHIFT, Qt::META, 0 };
- static const int DontSwapQtKeyOrder[] = { Qt::Key_Control, Qt::Key_Alt, Qt::Key_Shift, Qt::Key_Meta, 0 };
- const int *modifierOrder;
- const int *qtkeyOrder;
- if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
- modifierOrder = DontSwapModifierOrder;
- qtkeyOrder = DontSwapQtKeyOrder;
- } else {
- modifierOrder = ModifierOrder;
- qtkeyOrder = QtKeyOrder;
- }
-
- for (int i = 0; modifierOrder[i] != 0; ++i) {
- if (key & modifierOrder[i])
- s += qt_macSymbolForQtKey(qtkeyOrder[i]);
- }
- } else
-#endif
- {
- // On other systems the order is Meta, Control, Alt, Shift
- if ((key & Qt::META) == Qt::META)
- s = nativeText ? QShortcut::tr("Meta") : QString::fromLatin1("Meta");
- if ((key & Qt::CTRL) == Qt::CTRL)
- addKey(s, nativeText ? QShortcut::tr("Ctrl") : QString::fromLatin1("Ctrl"), format);
- if ((key & Qt::ALT) == Qt::ALT)
- addKey(s, nativeText ? QShortcut::tr("Alt") : QString::fromLatin1("Alt"), format);
- if ((key & Qt::SHIFT) == Qt::SHIFT)
- addKey(s, nativeText ? QShortcut::tr("Shift") : QString::fromLatin1("Shift"), format);
- }
-
-
- key &= ~(Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier);
- QString p;
-
- if (key && key < Qt::Key_Escape && key != Qt::Key_Space) {
- if (key < 0x10000) {
- p = QChar(key & 0xffff).toUpper();
- } else {
- p = QChar((key-0x10000)/0x400+0xd800);
- p += QChar((key-0x10000)%400+0xdc00);
- }
- } else if (key >= Qt::Key_F1 && key <= Qt::Key_F35) {
- p = nativeText ? QShortcut::tr("F%1").arg(key - Qt::Key_F1 + 1)
- : QString::fromLatin1("F%1").arg(key - Qt::Key_F1 + 1);
- } else if (key) {
- int i=0;
-#if defined(Q_WS_MAC)
- if (nativeText) {
- QChar ch = qt_macSymbolForQtKey(key);
- if (!ch.isNull())
- p = ch;
- else
- goto NonSymbol;
- } else
-#endif
- {
-#ifdef Q_WS_MAC
-NonSymbol:
-#endif
- while (keyname[i].name) {
- if (key == keyname[i].key) {
- p = nativeText ? QShortcut::tr(keyname[i].name)
- : QString::fromLatin1(keyname[i].name);
- break;
- }
- ++i;
- }
- // If we can't find the actual translatable keyname,
- // fall back on the unicode representation of it...
- // Or else characters like Qt::Key_aring may not get displayed
- // (Really depends on you locale)
- if (!keyname[i].name) {
- if (key < 0x10000) {
- p = QChar(key & 0xffff).toUpper();
- } else {
- p = QChar((key-0x10000)/0x400+0xd800);
- p += QChar((key-0x10000)%400+0xdc00);
- }
- }
- }
- }
-
-#ifdef Q_WS_MAC
- if (nativeText)
- s += p;
- else
-#endif
- addKey(s, p, format);
- return s;
-}
-/*!
- Matches the sequence with \a seq. Returns ExactMatch if
- successful, PartialMatch if \a seq matches incompletely,
- and NoMatch if the sequences have nothing in common.
- Returns NoMatch if \a seq is shorter.
-*/
-QKeySequence::SequenceMatch QKeySequence::matches(const QKeySequence &seq) const
-{
- uint userN = count(),
- seqN = seq.count();
-
- if (userN > seqN)
- return NoMatch;
-
- // If equal in length, we have a potential ExactMatch sequence,
- // else we already know it can only be partial.
- SequenceMatch match = (userN == seqN ? ExactMatch : PartialMatch);
-
- for (uint i = 0; i < userN; ++i) {
- int userKey = (*this)[i],
- sequenceKey = seq[i];
- if (userKey != sequenceKey)
- return NoMatch;
- }
- return match;
-}
-
-
-/*!
- \obsolete
-
- Use toString() instead.
-
- Returns the key sequence as a QString. This is equivalent to
- calling toString(QKeySequence::NativeText). Note that the
- result is not platform independent.
-*/
-QKeySequence::operator QString() const
-{
- return QKeySequence::toString(QKeySequence::NativeText);
-}
-
-/*!
- Returns the key sequence as a QVariant
-*/
-QKeySequence::operator QVariant() const
-{
- return QVariant(QVariant::KeySequence, this);
-}
-
-/*!
- \obsolete
- For backward compatibility: returns the first keycode
- as integer. If the key sequence is empty, 0 is returned.
- */
-QKeySequence::operator int () const
-{
- if (1 <= count())
- return d->key[0];
- return 0;
-}
-
-
-/*!
- Returns a reference to the element at position \a index in the key
- sequence. This can only be used to read an element.
- */
-int QKeySequence::operator[](uint index) const
-{
- Q_ASSERT_X(index < 4, "QKeySequence::operator[]", "index out of range");
- return d->key[index];
-}
-
-
-/*!
- Assignment operator. Assigns the \a other key sequence to this
- object.
- */
-QKeySequence &QKeySequence::operator=(const QKeySequence &other)
-{
- qAtomicAssign(d, other.d);
- return *this;
-}
-
-/*!
- \fn void QKeySequence::swap(QKeySequence &other)
- \since 4.8
-
- Swaps key sequence \a other with this key sequence. This operation is very
- fast and never fails.
-*/
-
-/*!
- \fn bool QKeySequence::operator!=(const QKeySequence &other) const
-
- Returns true if this key sequence is not equal to the \a other
- key sequence; otherwise returns false.
-*/
-
-
-/*!
- Returns true if this key sequence is equal to the \a other
- key sequence; otherwise returns false.
- */
-bool QKeySequence::operator==(const QKeySequence &other) const
-{
- return (d->key[0] == other.d->key[0] &&
- d->key[1] == other.d->key[1] &&
- d->key[2] == other.d->key[2] &&
- d->key[3] == other.d->key[3]);
-}
-
-
-/*!
- Provides an arbitrary comparison of this key sequence and
- \a other key sequence. All that is guaranteed is that the
- operator returns false if both key sequences are equal and
- that (ks1 \< ks2) == !( ks2 \< ks1) if the key sequences
- are not equal.
-
- This function is useful in some circumstances, for example
- if you want to use QKeySequence objects as keys in a QMap.
-
- \sa operator==() operator!=() operator>() operator<=() operator>=()
-*/
-bool QKeySequence::operator< (const QKeySequence &other) const
-{
- for (int i = 0; i < 4; ++i)
- if (d->key[i] != other.d->key[i])
- return d->key[i] < other.d->key[i];
- return false;
-}
-
-/*!
- \fn bool QKeySequence::operator> (const QKeySequence &other) const
-
- Returns true if this key sequence is larger than the \a other key
- sequence; otherwise returns false.
-
- \sa operator==() operator!=() operator<() operator<=() operator>=()
-*/
-
-/*!
- \fn bool QKeySequence::operator<= (const QKeySequence &other) const
-
- Returns true if this key sequence is smaller or equal to the
- \a other key sequence; otherwise returns false.
-
- \sa operator==() operator!=() operator<() operator>() operator>=()
-*/
-
-/*!
- \fn bool QKeySequence::operator>= (const QKeySequence &other) const
-
- Returns true if this key sequence is larger or equal to the
- \a other key sequence; otherwise returns false.
-
- \sa operator==() operator!=() operator<() operator>() operator<=()
-*/
-
-/*!
- \internal
-*/
-bool QKeySequence::isDetached() const
-{
- return d->ref == 1;
-}
-
-/*!
- \since 4.1
-
- Return a string representation of the key sequence,
- based on \a format.
-
- For example, the value Qt::CTRL+Qt::Key_O results in "Ctrl+O".
- If the key sequence has multiple key codes, each is separated
- by commas in the string returned, such as "Alt+X, Ctrl+Y, Z".
- The strings, "Ctrl", "Shift", etc. are translated using
- QObject::tr() in the "QShortcut" context.
-
- If the key sequence has no keys, an empty string is returned.
-
- On Mac OS X, the string returned resembles the sequence that is
- shown in the menu bar.
-
- \sa fromString()
-*/
-QString QKeySequence::toString(SequenceFormat format) const
-{
- QString finalString;
- // A standard string, with no translation or anything like that. In some ways it will
- // look like our latin case on Windows and X11
- int end = count();
- for (int i = 0; i < end; ++i) {
- finalString += d->encodeString(d->key[i], format);
- finalString += QLatin1String(", ");
- }
- finalString.truncate(finalString.length() - 2);
- return finalString;
-}
-
-/*!
- \since 4.1
-
- Return a QKeySequence from the string \a str based on \a format.
-
- \sa toString()
-*/
-QKeySequence QKeySequence::fromString(const QString &str, SequenceFormat format)
-{
- return QKeySequence(str, format);
-}
-
-/*****************************************************************************
- QKeySequence stream functions
- *****************************************************************************/
-#if !defined(QT_NO_DATASTREAM)
-/*!
- \fn QDataStream &operator<<(QDataStream &stream, const QKeySequence &sequence)
- \relates QKeySequence
-
- Writes the key \a sequence to the \a stream.
-
- \sa \link datastreamformat.html Format of the QDataStream operators \endlink
-*/
-QDataStream &operator<<(QDataStream &s, const QKeySequence &keysequence)
-{
- QList<quint32> list;
- list << keysequence.d->key[0];
-
- if (s.version() >= 5 && keysequence.count() > 1) {
- list << keysequence.d->key[1];
- list << keysequence.d->key[2];
- list << keysequence.d->key[3];
- }
- s << list;
- return s;
-}
-
-
-/*!
- \fn QDataStream &operator>>(QDataStream &stream, QKeySequence &sequence)
- \relates QKeySequence
-
- Reads a key sequence from the \a stream into the key \a sequence.
-
- \sa \link datastreamformat.html Format of the QDataStream operators \endlink
-*/
-QDataStream &operator>>(QDataStream &s, QKeySequence &keysequence)
-{
- qAtomicDetach(keysequence.d);
- QList<quint32> list;
- s >> list;
- for (int i = 0; i < 4; ++i)
- keysequence.d->key[i] = list.value(i);
- return s;
-}
-
-#endif //QT_NO_DATASTREAM
-
-#ifndef QT_NO_DEBUG_STREAM
-QDebug operator<<(QDebug dbg, const QKeySequence &p)
-{
-#ifndef Q_BROKEN_DEBUG_STREAM
- dbg.nospace() << "QKeySequence(" << p.toString() << ')';
- return dbg.space();
-#else
- qWarning("This compiler doesn't support streaming QKeySequence to QDebug");
- return dbg;
- Q_UNUSED(p);
-#endif
-}
-#endif
-
-#endif // QT_NO_SHORTCUT
-
-
-/*!
- \typedef QKeySequence::DataPtr
- \internal
-*/
-
- /*!
- \fn DataPtr &QKeySequence::data_ptr()
- \internal
-*/
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qkeysequence.h b/src/gui/kernel/qkeysequence.h
deleted file mode 100644
index 9eabb89d29..0000000000
--- a/src/gui/kernel/qkeysequence.h
+++ /dev/null
@@ -1,240 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QKEYSEQUENCE_H
-#define QKEYSEQUENCE_H
-
-#include <QtCore/qnamespace.h>
-#include <QtCore/qstring.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_SHORTCUT
-
-/*****************************************************************************
- QKeySequence stream functions
- *****************************************************************************/
-#ifndef QT_NO_DATASTREAM
-class QKeySequence;
-Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks);
-Q_GUI_EXPORT QDataStream &operator>>(QDataStream &out, QKeySequence &ks);
-#endif
-
-#ifdef qdoc
-void qt_set_sequence_auto_mnemonic(bool b);
-#endif
-
-class QVariant;
-class QKeySequencePrivate;
-
-class Q_GUI_EXPORT QKeySequence
-{
-public:
- enum StandardKey {
- UnknownKey,
- HelpContents,
- WhatsThis,
- Open,
- Close,
- Save,
- New,
- Delete,
- Cut,
- Copy,
- Paste,
- Undo,
- Redo,
- Back,
- Forward,
- Refresh,
- ZoomIn,
- ZoomOut,
- Print,
- AddTab,
- NextChild,
- PreviousChild,
- Find,
- FindNext,
- FindPrevious,
- Replace,
- SelectAll,
- Bold,
- Italic,
- Underline,
- MoveToNextChar,
- MoveToPreviousChar,
- MoveToNextWord,
- MoveToPreviousWord,
- MoveToNextLine,
- MoveToPreviousLine,
- MoveToNextPage,
- MoveToPreviousPage,
- MoveToStartOfLine,
- MoveToEndOfLine,
- MoveToStartOfBlock,
- MoveToEndOfBlock,
- MoveToStartOfDocument,
- MoveToEndOfDocument,
- SelectNextChar,
- SelectPreviousChar,
- SelectNextWord,
- SelectPreviousWord,
- SelectNextLine,
- SelectPreviousLine,
- SelectNextPage,
- SelectPreviousPage,
- SelectStartOfLine,
- SelectEndOfLine,
- SelectStartOfBlock,
- SelectEndOfBlock,
- SelectStartOfDocument,
- SelectEndOfDocument,
- DeleteStartOfWord,
- DeleteEndOfWord,
- DeleteEndOfLine,
- InsertParagraphSeparator,
- InsertLineSeparator,
- SaveAs,
- Preferences,
- Quit
- };
-
- enum SequenceFormat {
- NativeText,
- PortableText
- };
-
- QKeySequence();
- QKeySequence(const QString &key);
- QKeySequence(const QString &key, SequenceFormat format);
- QKeySequence(int k1, int k2 = 0, int k3 = 0, int k4 = 0);
- QKeySequence(const QKeySequence &ks);
- QKeySequence(StandardKey key);
- ~QKeySequence();
-
- uint count() const; // ### Qt 5: return 'int'
- bool isEmpty() const;
-
- enum SequenceMatch {
- NoMatch,
- PartialMatch,
- ExactMatch
-#ifdef QT3_SUPPORT
- , Identical = ExactMatch
-#endif
- };
-
- QString toString(SequenceFormat format = PortableText) const;
- static QKeySequence fromString(const QString &str, SequenceFormat format = PortableText);
-
- SequenceMatch matches(const QKeySequence &seq) const;
- static QKeySequence mnemonic(const QString &text);
- static QList<QKeySequence> keyBindings(StandardKey key);
-
- // ### Qt 5: kill 'operator QString' - it's evil
- operator QString() const;
- operator QVariant() const;
- operator int() const;
- int operator[](uint i) const;
- QKeySequence &operator=(const QKeySequence &other);
-#ifdef Q_COMPILER_RVALUE_REFS
- inline QKeySequence &operator=(QKeySequence &&other)
- { qSwap(d, other.d); return *this; }
-#endif
- inline void swap(QKeySequence &other) { qSwap(d, other.d); }
- bool operator==(const QKeySequence &other) const;
- inline bool operator!= (const QKeySequence &other) const
- { return !(*this == other); }
- bool operator< (const QKeySequence &ks) const;
- inline bool operator> (const QKeySequence &other) const
- { return other < *this; }
- inline bool operator<= (const QKeySequence &other) const
- { return !(other < *this); }
- inline bool operator>= (const QKeySequence &other) const
- { return !(*this < other); }
-
- bool isDetached() const;
-private:
- static int decodeString(const QString &ks);
- static QString encodeString(int key);
- int assign(const QString &str);
- int assign(const QString &str, SequenceFormat format);
- void setKey(int key, int index);
-
- QKeySequencePrivate *d;
-
- friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks);
- friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QKeySequence &ks);
- friend class Q3AccelManager;
- friend class QShortcutMap;
- friend class QShortcut;
-
-public:
- typedef QKeySequencePrivate * DataPtr;
- inline DataPtr &data_ptr() { return d; }
-};
-Q_DECLARE_TYPEINFO(QKeySequence, Q_MOVABLE_TYPE);
-Q_DECLARE_SHARED(QKeySequence)
-
-#ifndef QT_NO_DEBUG_STREAM
-Q_GUI_EXPORT QDebug operator<<(QDebug, const QKeySequence &);
-#endif
-
-#else
-
-class Q_GUI_EXPORT QKeySequence
-{
-public:
- QKeySequence() {}
- QKeySequence(int) {}
-};
-
-#endif // QT_NO_SHORTCUT
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QKEYSEQUENCE_H
diff --git a/src/gui/kernel/qlayout.h b/src/gui/kernel/qlayout.h
deleted file mode 100644
index 5333150072..0000000000
--- a/src/gui/kernel/qlayout.h
+++ /dev/null
@@ -1,245 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QLAYOUT_H
-#define QLAYOUT_H
-
-#include <QtCore/qobject.h>
-#include <QtGui/qlayoutitem.h>
-#include <QtGui/qsizepolicy.h>
-#include <QtCore/qrect.h>
-#include <QtCore/qmargins.h>
-
-#include <limits.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QLayout;
-class QSize;
-
-#ifdef QT3_SUPPORT
-class Q_GUI_EXPORT QLayoutIterator
-{
-public:
- inline QT3_SUPPORT_CONSTRUCTOR QLayoutIterator(QLayout *i) : layout(i), index(0) {}
- inline QLayoutIterator(const QLayoutIterator &i)
- : layout(i.layout), index(i.index) {}
- inline QLayoutIterator &operator=(const QLayoutIterator &i) {
- layout = i.layout;
- index = i.index;
- return *this;
- }
- inline QT3_SUPPORT QLayoutItem *operator++();
- inline QT3_SUPPORT QLayoutItem *current();
- inline QT3_SUPPORT QLayoutItem *takeCurrent();
- inline QT3_SUPPORT void deleteCurrent();
-
-private:
- // hack to avoid deprecated warning
- friend class QLayout;
- inline QLayoutIterator(QLayout *i, bool) : layout(i), index(0) {}
- QLayout *layout;
- int index;
-};
-#endif
-
-class QLayoutPrivate;
-
-class Q_GUI_EXPORT QLayout : public QObject, public QLayoutItem
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QLayout)
-
- Q_ENUMS(SizeConstraint)
- Q_PROPERTY(int margin READ margin WRITE setMargin)
- Q_PROPERTY(int spacing READ spacing WRITE setSpacing)
- Q_PROPERTY(SizeConstraint sizeConstraint READ sizeConstraint WRITE setSizeConstraint)
-public:
- enum SizeConstraint {
- SetDefaultConstraint,
- SetNoConstraint,
- SetMinimumSize,
- SetFixedSize,
- SetMaximumSize,
- SetMinAndMaxSize
-#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
- , Auto = SetDefaultConstraint,
- FreeResize = SetNoConstraint,
- Minimum = SetMinimumSize,
- Fixed = SetFixedSize
-#endif
- };
-
- QLayout(QWidget *parent);
- QLayout();
- ~QLayout();
-
- int margin() const;
- int spacing() const;
-
- void setMargin(int);
- void setSpacing(int);
-
- void setContentsMargins(int left, int top, int right, int bottom);
- void setContentsMargins(const QMargins &margins);
- void getContentsMargins(int *left, int *top, int *right, int *bottom) const;
- QMargins contentsMargins() const;
- QRect contentsRect() const;
-
- bool setAlignment(QWidget *w, Qt::Alignment alignment);
- bool setAlignment(QLayout *l, Qt::Alignment alignment);
-#ifdef Q_NO_USING_KEYWORD
- inline void setAlignment(Qt::Alignment alignment) { QLayoutItem::setAlignment(alignment); }
-#else
- using QLayoutItem::setAlignment;
-#endif
-
- void setSizeConstraint(SizeConstraint);
- SizeConstraint sizeConstraint() const;
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT void setResizeMode(SizeConstraint s) {setSizeConstraint(s);}
- inline QT3_SUPPORT SizeConstraint resizeMode() const {return sizeConstraint();}
-#endif
- void setMenuBar(QWidget *w);
- QWidget *menuBar() const;
-
- QWidget *parentWidget() const;
-
- void invalidate();
- QRect geometry() const;
- bool activate();
- void update();
-
- void addWidget(QWidget *w);
- virtual void addItem(QLayoutItem *) = 0;
-
- void removeWidget(QWidget *w);
- void removeItem(QLayoutItem *);
-
- Qt::Orientations expandingDirections() const;
- QSize minimumSize() const;
- QSize maximumSize() const;
- virtual void setGeometry(const QRect&);
- virtual QLayoutItem *itemAt(int index) const = 0;
- virtual QLayoutItem *takeAt(int index) = 0;
- virtual int indexOf(QWidget *) const;
- virtual int count() const = 0;
- bool isEmpty() const;
-
- int totalHeightForWidth(int w) const;
- QSize totalMinimumSize() const;
- QSize totalMaximumSize() const;
- QSize totalSizeHint() const;
- QLayout *layout();
-
- void setEnabled(bool);
- bool isEnabled() const;
-
-#ifdef QT3_SUPPORT
- QT3_SUPPORT void freeze(int w=0, int h=0);
- QT3_SUPPORT bool isTopLevel() const;
-#endif
-
- static QSize closestAcceptableSize(const QWidget *w, const QSize &s);
-
-protected:
- void widgetEvent(QEvent *);
- void childEvent(QChildEvent *e);
- void addChildLayout(QLayout *l);
- void addChildWidget(QWidget *w);
-#ifdef QT3_SUPPORT
- QT3_SUPPORT void deleteAllItems();
-#endif
-
- QRect alignmentRect(const QRect&) const;
-protected:
- QLayout(QLayoutPrivate &d, QLayout*, QWidget*);
-
-private:
- Q_DISABLE_COPY(QLayout)
-
- static void activateRecursiveHelper(QLayoutItem *item);
-
- friend class QApplicationPrivate;
- friend class QWidget;
-
-#ifdef QT3_SUPPORT
-public:
- QT3_SUPPORT_CONSTRUCTOR QLayout(QWidget *parent, int margin, int spacing = -1,
- const char *name = 0);
- QT3_SUPPORT_CONSTRUCTOR QLayout(QLayout *parentLayout, int spacing = -1, const char *name = 0);
- QT3_SUPPORT_CONSTRUCTOR QLayout(int spacing, const char *name = 0);
- inline QT3_SUPPORT QWidget *mainWidget() const { return parentWidget(); }
- inline QT3_SUPPORT void remove(QWidget *w) { removeWidget(w); }
- inline QT3_SUPPORT void add(QWidget *w) { addWidget(w); }
-
- QT3_SUPPORT void setAutoAdd(bool a);
- QT3_SUPPORT bool autoAdd() const;
- inline QT3_SUPPORT QLayoutIterator iterator() { return QLayoutIterator(this,true); }
-
- inline QT3_SUPPORT int defaultBorder() const { return spacing(); }
-#endif
-};
-
-#ifdef QT3_SUPPORT
-inline QLayoutItem *QLayoutIterator::operator++() { return layout->itemAt(++index); }
-inline QLayoutItem *QLayoutIterator::current() { return layout->itemAt(index); }
-inline QLayoutItem *QLayoutIterator::takeCurrent() { return layout->takeAt(index); }
-inline void QLayoutIterator::deleteCurrent() { delete layout->takeAt(index); }
-#endif
-
-//### support old includes
-#if 1 //def QT3_SUPPORT
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <QtGui/qboxlayout.h>
-#include <QtGui/qgridlayout.h>
-QT_END_INCLUDE_NAMESPACE
-#endif
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QLAYOUT_H
diff --git a/src/gui/kernel/qlayoutengine_p.h b/src/gui/kernel/qlayoutengine_p.h
deleted file mode 100644
index da07f3bab1..0000000000
--- a/src/gui/kernel/qlayoutengine_p.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QLAYOUTENGINE_P_H
-#define QLAYOUTENGINE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "QtGui/qlayoutitem.h"
-#include "QtGui/qstyle.h"
-
-QT_BEGIN_NAMESPACE
-
-template <typename T> class QVector;
-
-struct QLayoutStruct
-{
- inline void init(int stretchFactor = 0, int minSize = 0) {
- stretch = stretchFactor;
- minimumSize = sizeHint = minSize;
- maximumSize = QLAYOUTSIZE_MAX;
- expansive = false;
- empty = true;
- spacing = 0;
- }
-
- int smartSizeHint() {
- return (stretch > 0) ? minimumSize : sizeHint;
- }
- int effectiveSpacer(int uniformSpacer) const {
- Q_ASSERT(uniformSpacer >= 0 || spacing >= 0);
- return (uniformSpacer >= 0) ? uniformSpacer : spacing;
- }
-
- // parameters
- int stretch;
- int sizeHint;
- int maximumSize;
- int minimumSize;
- bool expansive;
- bool empty;
- int spacing;
-
- // temporary storage
- bool done;
-
- // result
- int pos;
- int size;
-};
-
-
-Q_GUI_EXPORT void qGeomCalc(QVector<QLayoutStruct> &chain, int start, int count,
- int pos, int space, int spacer = -1);
-Q_GUI_EXPORT QSize qSmartMinSize(const QSize &sizeHint, const QSize &minSizeHint,
- const QSize &minSize, const QSize &maxSize,
- const QSizePolicy &sizePolicy);
-Q_GUI_EXPORT QSize qSmartMinSize(const QWidgetItem *i);
-Q_GUI_EXPORT QSize qSmartMinSize(const QWidget *w);
-Q_GUI_EXPORT QSize qSmartMaxSize(const QSize &sizeHint,
- const QSize &minSize, const QSize &maxSize,
- const QSizePolicy &sizePolicy, Qt::Alignment align = 0);
-Q_GUI_EXPORT QSize qSmartMaxSize(const QWidgetItem *i, Qt::Alignment align = 0);
-Q_GUI_EXPORT QSize qSmartMaxSize(const QWidget *w, Qt::Alignment align = 0);
-
-Q_GUI_EXPORT int qSmartSpacing(const QLayout *layout, QStyle::PixelMetric pm);
-
-/*
- Modify total maximum (max), total expansion (exp), and total empty
- when adding boxmax/boxexp.
-
- Expansive boxes win over non-expansive boxes.
- Non-empty boxes win over empty boxes.
-*/
-static inline void qMaxExpCalc(int & max, bool &exp, bool &empty,
- int boxmax, bool boxexp, bool boxempty)
-{
- if (exp) {
- if (boxexp)
- max = qMax(max, boxmax);
- } else {
- if (boxexp || (empty && (!boxempty || max == 0)))
- max = boxmax;
- else if (empty == boxempty)
- max = qMin(max, boxmax);
- }
- exp = exp || boxexp;
- empty = empty && boxempty;
-}
-
-QT_END_NAMESPACE
-
-#endif // QLAYOUTENGINE_P_H
diff --git a/src/gui/kernel/qlayoutitem.h b/src/gui/kernel/qlayoutitem.h
deleted file mode 100644
index a75011f3ff..0000000000
--- a/src/gui/kernel/qlayoutitem.h
+++ /dev/null
@@ -1,182 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QLAYOUTITEM_H
-#define QLAYOUTITEM_H
-
-#include <QtGui/qsizepolicy.h>
-#include <QtCore/qrect.h>
-
-#include <limits.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-static const int QLAYOUTSIZE_MAX = INT_MAX/256/16;
-
-class QLayout;
-class QLayoutItem;
-class QSpacerItem;
-class QWidget;
-class QSize;
-
-class Q_GUI_EXPORT QLayoutItem
-{
-public:
- inline explicit QLayoutItem(Qt::Alignment alignment = 0);
- virtual ~QLayoutItem();
- virtual QSize sizeHint() const = 0;
- virtual QSize minimumSize() const = 0;
- virtual QSize maximumSize() const = 0;
- virtual Qt::Orientations expandingDirections() const = 0;
- virtual void setGeometry(const QRect&) = 0;
- virtual QRect geometry() const = 0;
- virtual bool isEmpty() const = 0;
- virtual bool hasHeightForWidth() const;
- virtual int heightForWidth(int) const;
- virtual int minimumHeightForWidth(int) const;
- virtual void invalidate();
-
- virtual QWidget *widget();
- virtual QLayout *layout();
- virtual QSpacerItem *spacerItem();
-
- Qt::Alignment alignment() const { return align; }
- void setAlignment(Qt::Alignment a);
- QSizePolicy::ControlTypes controlTypes() const;
-
-protected:
- Qt::Alignment align;
-};
-
-inline QLayoutItem::QLayoutItem(Qt::Alignment aalignment)
- : align(aalignment) { }
-
-class Q_GUI_EXPORT QSpacerItem : public QLayoutItem
-{
-public:
- QSpacerItem(int w, int h,
- QSizePolicy::Policy hData = QSizePolicy::Minimum,
- QSizePolicy::Policy vData = QSizePolicy::Minimum)
- : width(w), height(h), sizeP(hData, vData) { }
- void changeSize(int w, int h,
- QSizePolicy::Policy hData = QSizePolicy::Minimum,
- QSizePolicy::Policy vData = QSizePolicy::Minimum);
- QSize sizeHint() const;
- QSize minimumSize() const;
- QSize maximumSize() const;
- Qt::Orientations expandingDirections() const;
- bool isEmpty() const;
- void setGeometry(const QRect&);
- QRect geometry() const;
- QSpacerItem *spacerItem();
-
-private:
- int width;
- int height;
- QSizePolicy sizeP;
- QRect rect;
-};
-
-class Q_GUI_EXPORT QWidgetItem : public QLayoutItem
-{
- Q_DISABLE_COPY(QWidgetItem)
-
-public:
- explicit QWidgetItem(QWidget *w) : wid(w) { }
- QSize sizeHint() const;
- QSize minimumSize() const;
- QSize maximumSize() const;
- Qt::Orientations expandingDirections() const;
- bool isEmpty() const;
- void setGeometry(const QRect&);
- QRect geometry() const;
- virtual QWidget *widget();
-
- bool hasHeightForWidth() const;
- int heightForWidth(int) const;
-
-protected:
- QWidget *wid;
-};
-
-class Q_GUI_EXPORT QWidgetItemV2 : public QWidgetItem
-{
-public:
- explicit QWidgetItemV2(QWidget *widget);
- ~QWidgetItemV2();
-
- QSize sizeHint() const;
- QSize minimumSize() const;
- QSize maximumSize() const;
- int heightForWidth(int width) const;
-
-private:
- enum { Dirty = -123, HfwCacheMaxSize = 3 };
-
- inline bool useSizeCache() const;
- void updateCacheIfNecessary() const;
- inline void invalidateSizeCache() {
- q_cachedMinimumSize.setWidth(Dirty);
- q_hfwCacheSize = 0;
- }
-
- mutable QSize q_cachedMinimumSize;
- mutable QSize q_cachedSizeHint;
- mutable QSize q_cachedMaximumSize;
- mutable QSize q_cachedHfws[HfwCacheMaxSize];
- mutable short q_firstCachedHfw;
- mutable short q_hfwCacheSize;
- void *d;
-
- friend class QWidgetPrivate;
-
- Q_DISABLE_COPY(QWidgetItemV2)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QLAYOUTITEM_H
diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp
deleted file mode 100644
index 490d442616..0000000000
--- a/src/gui/kernel/qpalette.cpp
+++ /dev/null
@@ -1,1406 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qpalette.h"
-#include "qapplication.h"
-#include "qdatastream.h"
-#include "qvariant.h"
-
-QT_BEGIN_NAMESPACE
-
-static int qt_palette_count = 1;
-
-class QPalettePrivate {
-public:
- QPalettePrivate() : ref(1), ser_no(qt_palette_count++), detach_no(0) { }
- QAtomicInt ref;
- QBrush br[QPalette::NColorGroups][QPalette::NColorRoles];
- int ser_no;
- int detach_no;
-};
-
-static QColor qt_mix_colors(QColor a, QColor b)
-{
- return QColor((a.red() + b.red()) / 2, (a.green() + b.green()) / 2,
- (a.blue() + b.blue()) / 2, (a.alpha() + b.alpha()) / 2);
-}
-
-#ifdef QT3_SUPPORT
-
-#ifndef QT_NO_DATASTREAM
-QDataStream &qt_stream_out_qcolorgroup(QDataStream &s, const QColorGroup &g)
-{
- if(s.version() == 1) {
- // Qt 1.x
- s << g.color(QPalette::Foreground) << g.color(QPalette::Background)
- << g.color(QPalette::Light) << g.color(QPalette::Dark)
- << g.color(QPalette::Mid) << g.color(QPalette::Text) << g.color(QPalette::Base);
- } else {
- int max = QPalette::NColorRoles;
- if (s.version() <= QDataStream::Qt_2_1)
- max = QPalette::HighlightedText + 1;
- else if (s.version() <= QDataStream::Qt_4_3)
- max = QPalette::AlternateBase + 1;
- for(int r = 0 ; r < max ; r++)
- s << g.brush((QPalette::ColorRole)r);
- }
- return s;
-}
-
-QDataStream &qt_stream_in_qcolorgroup(QDataStream &s, QColorGroup &g)
-{
- if(s.version() == 1) { // Qt 1.x
- QColor fg, bg, light, dark, mid, text, base;
- s >> fg >> bg >> light >> dark >> mid >> text >> base;
- QPalette p(bg);
- p.setColor(QPalette::Active, QPalette::Foreground, fg);
- p.setColor(QPalette::Active, QPalette::Light, light);
- p.setColor(QPalette::Active, QPalette::Dark, dark);
- p.setColor(QPalette::Active, QPalette::Mid, mid);
- p.setColor(QPalette::Active, QPalette::Text, text);
- p.setColor(QPalette::Active, QPalette::Base, base);
- g = p;
- g.setCurrentColorGroup(QPalette::Active);
- } else {
- int max = QPalette::NColorRoles;
- if (s.version() <= QDataStream::Qt_2_1)
- max = QPalette::HighlightedText + 1;
- else if (s.version() <= QDataStream::Qt_3_0)
- max = QPalette::LinkVisited + 1;
- else if (s.version() <= QDataStream::Qt_4_3)
- max = QPalette::AlternateBase + 1;
- QBrush tmp;
- for(int r = 0 ; r < max; r++) {
- s >> tmp;
- g.setBrush((QPalette::ColorRole)r, tmp);
- }
- }
- return s;
-}
-
-QDataStream &operator<<(QDataStream &s, const QColorGroup &g)
-{
- return qt_stream_out_qcolorgroup(s, g);
-}
-
-QDataStream &operator>>(QDataStream &s, QColorGroup &g)
-{
- return qt_stream_in_qcolorgroup(s, g);
-}
-#endif // QT_NO_DATASTREAM
-
-/*!
- Constructs a palette with the specified \a active, \a disabled and
- \a inactive color groups.
-*/
-QPalette::QPalette(const QColorGroup &active, const QColorGroup &disabled,
- const QColorGroup &inactive)
-{
- Q_ASSERT(QPalette::NColorRoles == QPalette::ToolTipText + 1);
- init();
- setColorGroup(Active, active);
- setColorGroup(Disabled, disabled);
- setColorGroup(Inactive, inactive);
-}
-
-QColorGroup QPalette::createColorGroup(ColorGroup cr) const
-{
- QColorGroup ret(*this);
- ret.setCurrentColorGroup(cr);
- return ret;
-}
-
-void QPalette::setColorGroup(ColorGroup cg, const QColorGroup &g)
-{
- setColorGroup(cg, g.brush(WindowText), g.brush(Button), g.brush(Light),
- g.brush(Dark), g.brush(Mid), g.brush(Text), g.brush(BrightText),
- g.brush(Base), g.brush(AlternateBase), g.brush(Window),
- g.brush(Midlight), g.brush(ButtonText), g.brush(Shadow),
- g.brush(Highlight), g.brush(HighlightedText), g.brush(Link),
- g.brush(LinkVisited), g.brush(ToolTipBase), g.brush(ToolTipText));
-}
-
-#endif // QT3_SUPPORT
-
-/*!
- \fn const QColor &QPalette::color(ColorRole role) const
-
- \overload
-
- Returns the color that has been set for the given color \a role in
- the current ColorGroup.
-
- \sa brush() ColorRole
- */
-
-/*!
- \fn const QBrush &QPalette::brush(ColorRole role) const
-
- \overload
-
- Returns the brush that has been set for the given color \a role in
- the current ColorGroup.
-
- \sa color() setBrush() ColorRole
-*/
-
-/*!
- \fn void QPalette::setColor(ColorRole role, const QColor &color)
-
- \overload
-
- Sets the color used for the given color \a role, in all color
- groups, to the specified solid \a color.
-
- \sa brush() setColor() ColorRole
-*/
-
-/*!
- \fn void QPalette::setBrush(ColorRole role, const QBrush &brush)
-
- Sets the brush for the given color \a role to the specified \a
- brush for all groups in the palette.
-
- \sa brush() setColor() ColorRole
-*/
-
-/*!
- \fn const QBrush & QPalette::foreground() const
- \obsolete
-
- Use windowText() instead.
-*/
-
-/*!
- \fn const QBrush & QPalette::windowText() const
-
- Returns the window text (general foreground) brush of the
- current color group.
-
- \sa ColorRole brush()
-*/
-
-/*!
- \fn const QBrush & QPalette::button() const
-
- Returns the button brush of the current color group.
-
- \sa ColorRole brush()
-*/
-
-/*!
- \fn const QBrush & QPalette::light() const
-
- Returns the light brush of the current color group.
-
- \sa ColorRole brush()
-*/
-
-/*!
- \fn const QBrush& QPalette::midlight() const
-
- Returns the midlight brush of the current color group.
-
- \sa ColorRole brush()
-*/
-
-/*!
- \fn const QBrush & QPalette::dark() const
-
- Returns the dark brush of the current color group.
-
- \sa ColorRole brush()
-*/
-
-/*!
- \fn const QBrush & QPalette::mid() const
-
- Returns the mid brush of the current color group.
-
- \sa ColorRole brush()
-*/
-
-/*!
- \fn const QBrush & QPalette::text() const
-
- Returns the text foreground brush of the current color group.
-
- \sa ColorRole brush()
-*/
-
-/*!
- \fn const QBrush & QPalette::brightText() const
-
- Returns the bright text foreground brush of the current color group.
-
- \sa ColorRole brush()
-*/
-
-/*!
- \fn const QBrush & QPalette::buttonText() const
-
- Returns the button text foreground brush of the current color group.
-
- \sa ColorRole brush()
-*/
-
-/*!
- \fn const QBrush & QPalette::base() const
-
- Returns the base brush of the current color group.
-
- \sa ColorRole brush()
-*/
-
-/*!
- \fn const QBrush & QPalette::alternateBase() const
-
- Returns the alternate base brush of the current color group.
-
- \sa ColorRole brush()
-*/
-
-/*!
- \fn const QBrush & QPalette::toolTipBase() const
- \since 4.4
-
- Returns the tool tip base brush of the current color group. This brush is
- used by QToolTip and QWhatsThis.
-
- \note Tool tips use the Inactive color group of QPalette, because tool
- tips are not active windows.
-
- \sa ColorRole brush()
-*/
-
-/*!
- \fn const QBrush & QPalette::toolTipText() const
- \since 4.4
-
- Returns the tool tip text brush of the current color group. This brush is
- used by QToolTip and QWhatsThis.
-
- \note Tool tips use the Inactive color group of QPalette, because tool
- tips are not active windows.
-
- \sa ColorRole brush()
-*/
-
-/*!
- \fn const QBrush & QPalette::background() const
- \obsolete
-
- Use window() instead.
-*/
-
-/*!
- \fn const QBrush & QPalette::window() const
-
- Returns the window (general background) brush of the current
- color group.
-
- \sa ColorRole brush()
-*/
-
-/*!
- \fn const QBrush & QPalette::shadow() const
-
- Returns the shadow brush of the current color group.
-
- \sa ColorRole brush()
-*/
-
-/*!
- \fn const QBrush & QPalette::highlight() const
-
- Returns the highlight brush of the current color group.
-
- \sa ColorRole brush()
-*/
-
-/*!
- \fn const QBrush & QPalette::highlightedText() const
-
- Returns the highlighted text brush of the current color group.
-
- \sa ColorRole brush()
-*/
-
-/*!
- \fn const QBrush & QPalette::link() const
-
- Returns the unvisited link text brush of the current color group.
-
- \sa ColorRole brush()
-*/
-
-/*!
- \fn const QBrush & QPalette::linkVisited() const
-
- Returns the visited link text brush of the current color group.
-
- \sa ColorRole brush()
-*/
-
-/*!
- \fn ColorGroup QPalette::currentColorGroup() const
-
- Returns the palette's current color group.
-*/
-
-/*!
- \fn void QPalette::setCurrentColorGroup(ColorGroup cg)
-
- Set the palette's current color group to \a cg.
-*/
-
-/*!
- \class QPalette
-
- \brief The QPalette class contains color groups for each widget state.
-
- \ingroup appearance
- \ingroup shared
- \ingroup painting
-
-
- A palette consists of three color groups: \e Active, \e Disabled,
- and \e Inactive. All widgets in Qt contain a palette and
- use their palette to draw themselves. This makes the user
- interface easily configurable and easier to keep consistent.
-
-
- If you create a new widget we strongly recommend that you use the
- colors in the palette rather than hard-coding specific colors.
-
- The color groups:
- \list
- \i The Active group is used for the window that has keyboard focus.
- \i The Inactive group is used for other windows.
- \i The Disabled group is used for widgets (not windows) that are
- disabled for some reason.
- \endlist
-
- Both active and inactive windows can contain disabled widgets.
- (Disabled widgets are often called \e inaccessible or \e{grayed
- out}.)
-
- In most styles, Active and Inactive look the same.
-
- Colors and brushes can be set for particular roles in any of a palette's
- color groups with setColor() and setBrush(). A color group contains a
- group of colors used by widgets for drawing themselves. We recommend that
- widgets use color group roles from the palette such as "foreground" and
- "base" rather than literal colors like "red" or "turquoise". The color
- roles are enumerated and defined in the \l ColorRole documentation.
-
- We strongly recommend that you use the default palette of the
- current style (returned by QApplication::palette()) and
- modify that as necessary. This is done by Qt's widgets when they
- are drawn.
-
- To modify a color group you call the functions
- setColor() and setBrush(), depending on whether you want a pure
- color or a pixmap pattern.
-
- There are also corresponding color() and brush() getters, and a
- commonly used convenience function to get the ColorRole for the current ColorGroup:
- window(), windowText(), base(), etc.
-
-
- You can copy a palette using the copy constructor and test to see
- if two palettes are \e identical using isCopyOf().
-
- QPalette is optimized by the use of \l{implicit sharing},
- so it is very efficient to pass QPalette objects as arguments.
-
- \warning Some styles do not use the palette for all drawing, for
- instance, if they make use of native theme engines. This is the
- case for both the Windows XP, Windows Vista, and the Mac OS X
- styles.
-
- \sa QApplication::setPalette(), QWidget::setPalette(), QColor
-*/
-
-/*!
- \enum QPalette::ColorGroup
-
- \value Disabled
- \value Active
- \value Inactive
- \value Normal synonym for Active
-
- \omitvalue All
- \omitvalue NColorGroups
- \omitvalue Current
-*/
-
-/*!
- \enum QPalette::ColorRole
-
- \img palette.png Color Roles
-
- The ColorRole enum defines the different symbolic color roles used
- in current GUIs.
-
- The central roles are:
-
- \value Window A general background color.
-
- \value Background This value is obsolete. Use Window instead.
-
- \value WindowText A general foreground color.
-
- \value Foreground This value is obsolete. Use WindowText instead.
-
- \value Base Used mostly as the background color for text entry widgets,
- but can also be used for other painting - such as the
- background of combobox drop down lists and toolbar handles.
- It is usually white or another light color.
-
- \value AlternateBase Used as the alternate background color in views with
- alternating row colors (see
- QAbstractItemView::setAlternatingRowColors()).
-
- \value ToolTipBase Used as the background color for QToolTip and
- QWhatsThis. Tool tips use the Inactive color group
- of QPalette, because tool tips are not active
- windows.
-
- \value ToolTipText Used as the foreground color for QToolTip and
- QWhatsThis. Tool tips use the Inactive color group
- of QPalette, because tool tips are not active
- windows.
-
- \value Text The foreground color used with \c Base. This is usually
- the same as the \c WindowText, in which case it must provide
- good contrast with \c Window and \c Base.
-
- \value Button The general button background color. This background can be different from
- \c Window as some styles require a different background color for buttons.
-
- \value ButtonText A foreground color used with the \c Button color.
-
- \value BrightText A text color that is very different from
- \c WindowText, and contrasts well with e.g. \c
- Dark. Typically used for text that needs to be
- drawn where \c Text or \c WindowText would give
- poor contrast, such as on pressed push buttons.
- Note that text colors can be used for things
- other than just words; text colors are \e
- usually used for text, but it's quite common to
- use the text color roles for lines, icons, etc.
-
-
- There are some color roles used mostly for 3D bevel and shadow effects.
- All of these are normally derived from \c Window, and used in ways that
- depend on that relationship. For example, buttons depend on it to make the
- bevels look attractive, and Motif scroll bars depend on \c Mid to be
- slightly different from \c Window.
-
- \value Light Lighter than \c Button color.
-
- \value Midlight Between \c Button and \c Light.
-
- \value Dark Darker than \c Button.
-
- \value Mid Between \c Button and \c Dark.
-
- \value Shadow A very dark color. By default, the shadow color is
- Qt::black.
-
-
- Selected (marked) items have two roles:
-
- \value Highlight A color to indicate a selected item or the current
- item. By default, the highlight color is
- Qt::darkBlue.
-
- \value HighlightedText A text color that contrasts with \c Highlight.
- By default, the highlighted text color is Qt::white.
-
- There are two color roles related to hyperlinks:
-
- \value Link A text color used for unvisited hyperlinks.
- By default, the link color is Qt::blue.
-
- \value LinkVisited A text color used for already visited hyperlinks.
- By default, the linkvisited color is Qt::magenta.
-
- Note that we do not use the \c Link and \c LinkVisited roles when
- rendering rich text in Qt, and that we recommend that you use CSS
- and the QTextDocument::setDefaultStyleSheet() function to alter
- the appearance of links. For example:
-
- \snippet doc/src/snippets/textdocument-css/main.cpp 0
-
- \value NoRole No role; this special role is often used to indicate that a
- role has not been assigned.
-
- \omitvalue NColorRoles
-*/
-
-/*!
- Constructs a palette object that uses the application's default palette.
-
- \sa QApplication::setPalette(), QApplication::palette()
-*/
-QPalette::QPalette()
- : d(QApplication::palette().d),
- current_group(Active),
- resolve_mask(0)
-{
- d->ref.ref();
-}
-
-static void qt_palette_from_color(QPalette &pal, const QColor & button)
-{
- QColor bg = button,
- btn = button,
- fg, base;
- int h, s, v;
- bg.getHsv(&h, &s, &v);
- if(v > 128) {
- fg = Qt::black;
- base = Qt::white;
- } else {
- fg = Qt::white;
- base = Qt::black;
- }
- //inactive and active are the same..
- pal.setColorGroup(QPalette::Active, QBrush(fg), QBrush(btn), QBrush(btn.lighter(150)),
- QBrush(btn.darker()), QBrush(btn.darker(150)), QBrush(fg), QBrush(Qt::white),
- QBrush(base), QBrush(bg));
- pal.setColorGroup(QPalette::Inactive, QBrush(fg), QBrush(btn), QBrush(btn.lighter(150)),
- QBrush(btn.darker()), QBrush(btn.darker(150)), QBrush(fg), QBrush(Qt::white),
- QBrush(base), QBrush(bg));
- pal.setColorGroup(QPalette::Disabled, QBrush(btn.darker()), QBrush(btn), QBrush(btn.lighter(150)),
- QBrush(btn.darker()), QBrush(btn.darker(150)), QBrush(btn.darker()),
- QBrush(Qt::white), QBrush(bg), QBrush(bg));
-}
-
-
-/*!
- Constructs a palette from the \a button color. The other colors are
- automatically calculated, based on this color. \c Window will be
- the button color as well.
-*/
-QPalette::QPalette(const QColor &button)
-{
- init();
- qt_palette_from_color(*this, button);
-}
-
-/*!
- Constructs a palette from the \a button color. The other colors are
- automatically calculated, based on this color. \c Window will be
- the button color as well.
-*/
-QPalette::QPalette(Qt::GlobalColor button)
-{
- init();
- qt_palette_from_color(*this, button);
-}
-
-/*!
- Constructs a palette. You can pass either brushes, pixmaps or
- plain colors for \a windowText, \a button, \a light, \a dark, \a
- mid, \a text, \a bright_text, \a base and \a window.
-
- \sa QBrush
-*/
-QPalette::QPalette(const QBrush &windowText, const QBrush &button,
- const QBrush &light, const QBrush &dark,
- const QBrush &mid, const QBrush &text,
- const QBrush &bright_text, const QBrush &base,
- const QBrush &window)
-{
- init();
- setColorGroup(All, windowText, button, light, dark, mid, text, bright_text,
- base, window);
-}
-
-
-/*!\obsolete
-
- Constructs a palette with the specified \a windowText, \a
- window, \a light, \a dark, \a mid, \a text, and \a base colors.
- The button color will be set to the window color.
-*/
-QPalette::QPalette(const QColor &windowText, const QColor &window,
- const QColor &light, const QColor &dark, const QColor &mid,
- const QColor &text, const QColor &base)
-{
- init();
- setColorGroup(All, QBrush(windowText), QBrush(window), QBrush(light),
- QBrush(dark), QBrush(mid), QBrush(text), QBrush(light),
- QBrush(base), QBrush(window));
-}
-
-/*!
- Constructs a palette from a \a button color and a \a window.
- The other colors are automatically calculated, based on these
- colors.
-*/
-QPalette::QPalette(const QColor &button, const QColor &window)
-{
- init();
- QColor bg = window, btn = button, fg, base, disfg;
- int h, s, v;
- bg.getHsv(&h, &s, &v);
- if(v > 128) {
- fg = Qt::black;
- base = Qt::white;
- disfg = Qt::darkGray;
- } else {
- fg = Qt::white;
- base = Qt::black;
- disfg = Qt::darkGray;
- }
- //inactive and active are identical
- setColorGroup(Inactive, QBrush(fg), QBrush(btn), QBrush(btn.lighter(150)), QBrush(btn.darker()),
- QBrush(btn.darker(150)), QBrush(fg), QBrush(Qt::white), QBrush(base),
- QBrush(bg));
- setColorGroup(Active, QBrush(fg), QBrush(btn), QBrush(btn.lighter(150)), QBrush(btn.darker()),
- QBrush(btn.darker(150)), QBrush(fg), QBrush(Qt::white), QBrush(base),
- QBrush(bg));
- setColorGroup(Disabled, QBrush(disfg), QBrush(btn), QBrush(btn.lighter(150)),
- QBrush(btn.darker()), QBrush(btn.darker(150)), QBrush(disfg),
- QBrush(Qt::white), QBrush(base), QBrush(bg));
-}
-
-/*!
- Constructs a copy of \a p.
-
- This constructor is fast thanks to \l{implicit sharing}.
-*/
-QPalette::QPalette(const QPalette &p)
-{
- d = p.d;
- d->ref.ref();
- resolve_mask = p.resolve_mask;
- current_group = p.current_group;
-}
-
-/*!
- Destroys the palette.
-*/
-QPalette::~QPalette()
-{
- if(!d->ref.deref())
- delete d;
-}
-
-/*!\internal*/
-void QPalette::init() {
- d = new QPalettePrivate;
- resolve_mask = 0;
- current_group = Active; //as a default..
-}
-
-/*!
- Assigns \a p to this palette and returns a reference to this
- palette.
-
- This operation is fast thanks to \l{implicit sharing}.
-*/
-QPalette &QPalette::operator=(const QPalette &p)
-{
- p.d->ref.ref();
- resolve_mask = p.resolve_mask;
- current_group = p.current_group;
- if(!d->ref.deref())
- delete d;
- d = p.d;
- return *this;
-}
-
-/*!
- Returns the palette as a QVariant
-*/
-QPalette::operator QVariant() const
-{
- return QVariant(QVariant::Palette, this);
-}
-
-/*!
- \fn const QColor &QPalette::color(ColorGroup group, ColorRole role) const
-
- Returns the color in the specified color \a group, used for the
- given color \a role.
-
- \sa brush() setColor() ColorRole
-*/
-
-/*!
- \fn const QBrush &QPalette::brush(ColorGroup group, ColorRole role) const
-
- Returns the brush in the specified color \a group, used for the
- given color \a role.
-
- \sa color() setBrush() ColorRole
-*/
-const QBrush &QPalette::brush(ColorGroup gr, ColorRole cr) const
-{
- Q_ASSERT(cr < NColorRoles);
- if(gr >= (int)NColorGroups) {
- if(gr == Current) {
- gr = (ColorGroup)current_group;
- } else {
- qWarning("QPalette::brush: Unknown ColorGroup: %d", (int)gr);
- gr = Active;
- }
- }
- return d->br[gr][cr];
-}
-
-/*!
- \fn void QPalette::setColor(ColorGroup group, ColorRole role, const QColor &color)
-
- Sets the color in the specified color \a group, used for the given
- color \a role, to the specified solid \a color.
-
- \sa setBrush() color() ColorRole
-*/
-
-/*!
- \fn void QPalette::setBrush(ColorGroup group, ColorRole role, const QBrush &brush)
- \overload
-
- Sets the brush in the specified color \a group, used for the given
- color \a role, to \a brush.
-
- \sa brush() setColor() ColorRole
-*/
-void QPalette::setBrush(ColorGroup cg, ColorRole cr, const QBrush &b)
-{
- Q_ASSERT(cr < NColorRoles);
- detach();
- if(cg >= (int)NColorGroups) {
- if(cg == All) {
- for(int i = 0; i < (int)NColorGroups; i++)
- d->br[i][cr] = b;
- resolve_mask |= (1<<cr);
- return;
- } else if(cg == Current) {
- cg = (ColorGroup)current_group;
- } else {
- qWarning("QPalette::setBrush: Unknown ColorGroup: %d", (int)cg);
- cg = Active;
- }
- }
- d->br[cg][cr] = b;
- resolve_mask |= (1<<cr);
-}
-
-/*!
- \since 4.2
-
- Returns true if the ColorGroup \a cg and ColorRole \a cr has been
- set previously on this palette; otherwise returns false.
-
- \sa setBrush()
-*/
-bool QPalette::isBrushSet(ColorGroup cg, ColorRole cr) const
-{
- Q_UNUSED(cg);
- return (resolve_mask & (1<<cr));
-}
-
-/*!
- \internal
-*/
-void QPalette::detach()
-{
- if (d->ref != 1) {
- QPalettePrivate *x = new QPalettePrivate;
- for(int grp = 0; grp < (int)NColorGroups; grp++) {
- for(int role = 0; role < (int)NColorRoles; role++)
- x->br[grp][role] = d->br[grp][role];
- }
- if(!d->ref.deref())
- delete d;
- d = x;
- }
- ++d->detach_no;
-}
-
-/*!
- \fn bool QPalette::operator!=(const QPalette &p) const
-
- Returns true (slowly) if this palette is different from \a p;
- otherwise returns false (usually quickly).
-
- \note The current ColorGroup is not taken into account when
- comparing palettes
-
- \sa operator==()
-*/
-
-/*!
- Returns true (usually quickly) if this palette is equal to \a p;
- otherwise returns false (slowly).
-
- \note The current ColorGroup is not taken into account when
- comparing palettes
-
- \sa operator!=()
-*/
-bool QPalette::operator==(const QPalette &p) const
-{
- if (isCopyOf(p))
- return true;
- for(int grp = 0; grp < (int)NColorGroups; grp++) {
- for(int role = 0; role < (int)NColorRoles; role++) {
- if(d->br[grp][role] != p.d->br[grp][role])
- return false;
- }
- }
- return true;
-}
-
-#ifdef QT3_SUPPORT
-bool QColorGroup::operator==(const QColorGroup &other) const
-{
- if (isCopyOf(other))
- return true;
- for (int role = 0; role < int(NColorRoles); role++) {
- if(d->br[current_group][role] != other.d->br[other.current_group][role])
- return false;
- }
- return true;
-}
-
-/*!
- Returns the color group as a QVariant
-*/
-QColorGroup::operator QVariant() const
-{
- return QVariant(QVariant::ColorGroup, this);
-}
-#endif
-
-/*!
- \fn bool QPalette::isEqual(ColorGroup cg1, ColorGroup cg2) const
-
- Returns true (usually quickly) if color group \a cg1 is equal to
- \a cg2; otherwise returns false.
-*/
-bool QPalette::isEqual(QPalette::ColorGroup group1, QPalette::ColorGroup group2) const
-{
- if(group1 >= (int)NColorGroups) {
- if(group1 == Current) {
- group1 = (ColorGroup)current_group;
- } else {
- qWarning("QPalette::brush: Unknown ColorGroup(1): %d", (int)group1);
- group1 = Active;
- }
- }
- if(group2 >= (int)NColorGroups) {
- if(group2 == Current) {
- group2 = (ColorGroup)current_group;
- } else {
- qWarning("QPalette::brush: Unknown ColorGroup(2): %d", (int)group2);
- group2 = Active;
- }
- }
- if(group1 == group2)
- return true;
- for(int role = 0; role < (int)NColorRoles; role++) {
- if(d->br[group1][role] != d->br[group2][role])
- return false;
- }
- return true;
-}
-
-/*! \obsolete
-
- Returns a number that identifies the contents of this QPalette
- object. Distinct QPalette objects can only have the same serial
- number if they refer to the same contents (but they don't have
- to). Also, the serial number of a QPalette may change during the
- lifetime of the object.
-
- Use cacheKey() instead.
-
- \warning The serial number doesn't necessarily change when the
- palette is altered. This means that it may be dangerous to use it
- as a cache key.
-
- \sa operator==()
-*/
-int QPalette::serialNumber() const
-{
- return d->ser_no;
-}
-
-/*!
- Returns a number that identifies the contents of this QPalette
- object. Distinct QPalette objects can have the same key if
- they refer to the same contents.
-
- The cacheKey() will change when the palette is altered.
-*/
-qint64 QPalette::cacheKey() const
-{
- return (((qint64) d->ser_no) << 32) | ((qint64) (d->detach_no));
-}
-
-/*!
- Returns a new QPalette that has attributes copied from \a other.
-*/
-QPalette QPalette::resolve(const QPalette &other) const
-{
- if ((*this == other && resolve_mask == other.resolve_mask)
- || resolve_mask == 0) {
- QPalette o = other;
- o.resolve_mask = resolve_mask;
- return o;
- }
-
- QPalette palette(*this);
- palette.detach();
-
- for(int role = 0; role < (int)NColorRoles; role++)
- if (!(resolve_mask & (1<<role)))
- for(int grp = 0; grp < (int)NColorGroups; grp++)
- palette.d->br[grp][role] = other.d->br[grp][role];
-
- return palette;
-}
-
-/*!
- \fn uint QPalette::resolve() const
- \internal
-*/
-
-/*!
- \fn void QPalette::resolve(uint mask)
- \internal
-*/
-
-
-/*****************************************************************************
- QPalette stream functions
- *****************************************************************************/
-
-#ifndef QT_NO_DATASTREAM
-
-static const int NumOldRoles = 7;
-static const int oldRoles[7] = { QPalette::Foreground, QPalette::Background, QPalette::Light,
- QPalette::Dark, QPalette::Mid, QPalette::Text, QPalette::Base };
-
-/*!
- \relates QPalette
-
- Writes the palette, \a p to the stream \a s and returns a
- reference to the stream.
-
- \sa \link datastreamformat.html Format of the QDataStream operators \endlink
-*/
-
-QDataStream &operator<<(QDataStream &s, const QPalette &p)
-{
- for (int grp = 0; grp < (int)QPalette::NColorGroups; grp++) {
- if (s.version() == 1) {
- // Qt 1.x
- for (int i = 0; i < NumOldRoles; ++i)
- s << p.d->br[grp][oldRoles[i]].color();
- } else {
- int max = QPalette::ToolTipText + 1;
- if (s.version() <= QDataStream::Qt_2_1)
- max = QPalette::HighlightedText + 1;
- else if (s.version() <= QDataStream::Qt_4_3)
- max = QPalette::AlternateBase + 1;
- for (int r = 0; r < max; r++)
- s << p.d->br[grp][r];
- }
- }
- return s;
-}
-
-static void readV1ColorGroup(QDataStream &s, QPalette &pal, QPalette::ColorGroup grp)
-{
- for (int i = 0; i < NumOldRoles; ++i) {
- QColor col;
- s >> col;
- pal.setColor(grp, (QPalette::ColorRole)oldRoles[i], col);
- }
-}
-
-/*!
- \relates QPalette
-
- Reads a palette from the stream, \a s into the palette \a p, and
- returns a reference to the stream.
-
- \sa \link datastreamformat.html Format of the QDataStream operators \endlink
-*/
-
-QDataStream &operator>>(QDataStream &s, QPalette &p)
-{
- if(s.version() == 1) {
- p = QPalette();
- readV1ColorGroup(s, p, QPalette::Active);
- readV1ColorGroup(s, p, QPalette::Disabled);
- readV1ColorGroup(s, p, QPalette::Inactive);
- } else {
- int max = QPalette::NColorRoles;
- if (s.version() <= QDataStream::Qt_2_1) {
- p = QPalette();
- max = QPalette::HighlightedText + 1;
- } else if (s.version() <= QDataStream::Qt_4_3) {
- p = QPalette();
- max = QPalette::AlternateBase + 1;
- }
-
- QBrush tmp;
- for(int grp = 0; grp < (int)QPalette::NColorGroups; ++grp) {
- for(int role = 0; role < max; ++role) {
- s >> tmp;
- p.setBrush((QPalette::ColorGroup)grp, (QPalette::ColorRole)role, tmp);
- }
- }
- }
- return s;
-}
-#endif //QT_NO_DATASTREAM
-
-/*!
- Returns true if this palette and \a p are copies of each other,
- i.e. one of them was created as a copy of the other and neither
- was subsequently modified; otherwise returns false. This is much
- stricter than equality.
-
- \sa operator=() operator==()
-*/
-
-bool QPalette::isCopyOf(const QPalette &p) const
-{
- return d == p.d;
-}
-
-/*!
-
- Sets a the group at \a cg. You can pass either brushes, pixmaps or
- plain colors for \a windowText, \a button, \a light, \a dark, \a
- mid, \a text, \a bright_text, \a base and \a window.
-
- \sa QBrush
-*/
-void QPalette::setColorGroup(ColorGroup cg, const QBrush &windowText, const QBrush &button,
- const QBrush &light, const QBrush &dark, const QBrush &mid,
- const QBrush &text, const QBrush &bright_text, const QBrush &base,
- const QBrush &window)
-{
- QBrush alt_base = QBrush(qt_mix_colors(base.color(), button.color()));
- QBrush mid_light = QBrush(qt_mix_colors(button.color(), light.color()));
- QColor toolTipBase(255, 255, 220);
- QColor toolTipText(0, 0, 0);
-
- setColorGroup(cg, windowText, button, light, dark, mid, text, bright_text, base,
- alt_base, window, mid_light, text,
- QBrush(Qt::black), QBrush(Qt::darkBlue), QBrush(Qt::white),
- QBrush(Qt::blue), QBrush(Qt::magenta), QBrush(toolTipBase),
- QBrush(toolTipText));
-
- resolve_mask &= ~(1 << Highlight);
- resolve_mask &= ~(1 << HighlightedText);
- resolve_mask &= ~(1 << LinkVisited);
- resolve_mask &= ~(1 << Link);
-}
-
-
-/*!\internal*/
-void
-QPalette::setColorGroup(ColorGroup cg, const QBrush &foreground, const QBrush &button,
- const QBrush &light, const QBrush &dark, const QBrush &mid,
- const QBrush &text, const QBrush &bright_text,
- const QBrush &base, const QBrush &alternate_base,
- const QBrush &background, const QBrush &midlight,
- const QBrush &button_text, const QBrush &shadow,
- const QBrush &highlight, const QBrush &highlighted_text,
- const QBrush &link, const QBrush &link_visited)
-{
- setColorGroup(cg, foreground, button, light, dark, mid,
- text, bright_text, base, alternate_base, background,
- midlight, button_text, shadow, highlight, highlighted_text,
- link, link_visited, background, foreground);
-}
-
-/*!\internal*/
-void QPalette::setColorGroup(ColorGroup cg, const QBrush &foreground, const QBrush &button,
- const QBrush &light, const QBrush &dark, const QBrush &mid,
- const QBrush &text, const QBrush &bright_text,
- const QBrush &base, const QBrush &alternate_base,
- const QBrush &background, const QBrush &midlight,
- const QBrush &button_text, const QBrush &shadow,
- const QBrush &highlight, const QBrush &highlighted_text,
- const QBrush &link, const QBrush &link_visited,
- const QBrush &toolTipBase, const QBrush &toolTipText)
-{
- detach();
- setBrush(cg, WindowText, foreground);
- setBrush(cg, Button, button);
- setBrush(cg, Light, light);
- setBrush(cg, Dark, dark);
- setBrush(cg, Mid, mid);
- setBrush(cg, Text, text);
- setBrush(cg, BrightText, bright_text);
- setBrush(cg, Base, base);
- setBrush(cg, AlternateBase, alternate_base);
- setBrush(cg, Window, background);
- setBrush(cg, Midlight, midlight);
- setBrush(cg, ButtonText, button_text);
- setBrush(cg, Shadow, shadow);
- setBrush(cg, Highlight, highlight);
- setBrush(cg, HighlightedText, highlighted_text);
- setBrush(cg, Link, link);
- setBrush(cg, LinkVisited, link_visited);
- setBrush(cg, ToolTipBase, toolTipBase);
- setBrush(cg, ToolTipText, toolTipText);
-}
-
-/*!
- \fn QPalette QPalette::copy() const
-
- Use simple assignment instead.
-*/
-
-/*!
- \fn QColorGroup QPalette::normal() const
- \obsolete
-
- Returns the active color group. Use active() instead.
-
- Use createColorGroup(Active) instead.
-*/
-
-/*!
- \fn void QPalette::setNormal(const QColorGroup &colorGroup)
-
- Sets the normal color group to \a colorGroup.
-
- \sa QColorGroup
-*/
-
-/*!
- \fn QColorGroup QPalette::active() const
-
- Returns the active color group.
- \sa QColorGroup
-*/
-
-/*!
- \fn QColorGroup QPalette::disabled() const
-
- Returns the disabled color group.
- \sa QColorGroup
-*/
-
-/*!
- \fn QColorGroup QPalette::inactive() const
-
- Returns the inactive color group.
- \sa QColorGroup
-*/
-
-/*!
- \fn void QPalette::setActive(const QColorGroup &colorGroup)
-
- Sets the active color group to \a colorGroup.
- \sa QColorGroup
-*/
-
-/*!
- \fn void QPalette::setDisabled(const QColorGroup &colorGroup)
-
- Sets the disabled color group to \a colorGroup.
- \sa QColorGroup
-*/
-
-/*!
- \fn void QPalette::setInactive(const QColorGroup &colorGroup)
-
- Sets the inactive color group.
- \sa QColorGroup
-*/
-
-/*! \class QColorGroup
- \brief The QColorGroup class contains color groups for each widget state.
- \compat
-*/
-
-/*! \fn QColorGroup::QColorGroup()
-
- Use QPalette() instead.
-*/
-
-/*! \fn QColorGroup::QColorGroup(const QBrush &foreground, const QBrush &button, \
- const QBrush &light, const QBrush &dark, const QBrush &mid, \
- const QBrush &text, const QBrush &bright_text,
- const QBrush &base, const QBrush &background)
-
- Use QPalette(\a foreground, \a button, \a light, \a dark, \a mid,
- \a text, \a bright_text, \a base, \a background) instead.
-*/
-
-/*! \fn QColorGroup::QColorGroup(const QColor &foreground, const QColor &background, \
- const QColor &light, const QColor &dark, const QColor &mid, \
- const QColor &text, const QColor &base)
-
- Use QColorGroup(\a foreground, \a background, \a light, \a dark,
- \a mid, \a text, \a base) instead.
-*/
-
-/*! \fn QColorGroup::QColorGroup(const QColorGroup &other)
-
- Use QPalette(\a other) instead.
-*/
-
-/*! \fn QColorGroup::QColorGroup(const QPalette &pal)
-
- Use QPalette(\a pal) instead.
-*/
-
-/*! \fn const QColor &QColorGroup::foreground() const
-
- Use QPalette::windowText().color() instead.
-*/
-
-/*! \fn const QColor &QColorGroup::button() const
-
- Use QPalette::button().color() instead.
-*/
-
-/*! \fn const QColor &QColorGroup::light() const
-
- Use QPalette::light().color() instead.
-*/
-
-/*! \fn const QColor &QColorGroup::dark() const
-
- Use QPalette::dark().color() instead.
-*/
-
-/*! \fn const QColor &QColorGroup::mid() const
-
- Use QPalette::mid().color() instead.
-*/
-
-/*! \fn const QColor &QColorGroup::text() const
-
- Use QPalette::text().color() instead.
-*/
-
-/*! \fn const QColor &QColorGroup::base() const
-
- Use QPalette::base().color() instead.
-*/
-
-/*! \fn const QColor &QColorGroup::background() const
-
- Use QPalette::window().color() instead.
-*/
-
-/*! \fn const QColor &QColorGroup::midlight() const
-
- Use QPalette::midlight().color() instead.
-*/
-
-/*! \fn const QColor &QColorGroup::brightText() const
-
- Use QPalette::brightText().color() instead.
-*/
-
-/*! \fn const QColor &QColorGroup::buttonText() const
-
- Use QPalette::buttonText().color() instead.
-*/
-
-/*! \fn const QColor &QColorGroup::shadow() const
-
- Use QPalette::shadow().color() instead.
-*/
-
-/*! \fn const QColor &QColorGroup::highlight() const
-
- Use QPalette::highlight().color() instead.
-*/
-
-/*! \fn const QColor &QColorGroup::highlightedText() const
-
- Use QPalette::highlightedText().color() instead.
-*/
-
-/*! \fn const QColor &QColorGroup::link() const
-
- Use QPalette::link().color() instead.
-*/
-
-/*! \fn const QColor &QColorGroup::linkVisited() const
-
- Use QPalette::linkVisited().color() instead.
-*/
-
-/*! \fn QDataStream &operator<<(QDataStream &ds, const QColorGroup &colorGroup)
- \relates QColorGroup
- \compat
-*/
-
-/*! \fn QDataStream &operator>>(QDataStream &ds, QColorGroup &colorGroup)
- \relates QColorGroup
- \compat
-*/
-
-/*! \fn bool QColorGroup::operator==(const QColorGroup &other) const
-
- Returns true if this color group is equal to \a other; otherwise
- returns false.
-*/
-
-/*! \fn bool QColorGroup::operator!=(const QColorGroup &other) const
-
- Returns true if this color group is not equal to \a other;
- otherwise returns false.
-*/
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qpalette.h b/src/gui/kernel/qpalette.h
deleted file mode 100644
index dffd2cbec8..0000000000
--- a/src/gui/kernel/qpalette.h
+++ /dev/null
@@ -1,270 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPALETTE_H
-#define QPALETTE_H
-
-#include <QtGui/qwindowdefs.h>
-#include <QtGui/qcolor.h>
-#include <QtGui/qbrush.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifdef QT3_SUPPORT
-class QColorGroup;
-#endif
-class QPalettePrivate;
-class QVariant;
-
-class Q_GUI_EXPORT QPalette
-{
- Q_GADGET
- Q_ENUMS(ColorGroup ColorRole)
-public:
- QPalette();
- QPalette(const QColor &button);
- QPalette(Qt::GlobalColor button);
- QPalette(const QColor &button, const QColor &window);
- QPalette(const QBrush &windowText, const QBrush &button, const QBrush &light,
- const QBrush &dark, const QBrush &mid, const QBrush &text,
- const QBrush &bright_text, const QBrush &base, const QBrush &window);
- QPalette(const QColor &windowText, const QColor &window, const QColor &light,
- const QColor &dark, const QColor &mid, const QColor &text, const QColor &base);
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QPalette(const QColorGroup &active, const QColorGroup &disabled, const QColorGroup &inactive);
-#endif
- QPalette(const QPalette &palette);
- ~QPalette();
- QPalette &operator=(const QPalette &palette);
-#ifdef Q_COMPILER_RVALUE_REFS
- inline QPalette &operator=(QPalette &&other)
- {
- resolve_mask = other.resolve_mask;
- current_group = other.current_group;
- qSwap(d, other.d); return *this;
- }
-#endif
- operator QVariant() const;
-
- // Do not change the order, the serialization format depends on it
- enum ColorGroup { Active, Disabled, Inactive, NColorGroups, Current, All, Normal = Active };
- enum ColorRole { WindowText, Button, Light, Midlight, Dark, Mid,
- Text, BrightText, ButtonText, Base, Window, Shadow,
- Highlight, HighlightedText,
- Link, LinkVisited, // ### Qt 5: remove
- AlternateBase,
- NoRole, // ### Qt 5: value should be 0 or -1
- ToolTipBase, ToolTipText,
- NColorRoles = ToolTipText + 1,
- Foreground = WindowText, Background = Window // ### Qt 5: remove
- };
-
- inline ColorGroup currentColorGroup() const { return static_cast<ColorGroup>(current_group); }
- inline void setCurrentColorGroup(ColorGroup cg) { current_group = cg; }
-
- inline const QColor &color(ColorGroup cg, ColorRole cr) const
- { return brush(cg, cr).color(); }
- const QBrush &brush(ColorGroup cg, ColorRole cr) const;
- inline void setColor(ColorGroup cg, ColorRole cr, const QColor &color);
- inline void setColor(ColorRole cr, const QColor &color);
- inline void setBrush(ColorRole cr, const QBrush &brush);
- bool isBrushSet(ColorGroup cg, ColorRole cr) const;
- void setBrush(ColorGroup cg, ColorRole cr, const QBrush &brush);
- void setColorGroup(ColorGroup cr, const QBrush &windowText, const QBrush &button,
- const QBrush &light, const QBrush &dark, const QBrush &mid,
- const QBrush &text, const QBrush &bright_text, const QBrush &base,
- const QBrush &window);
- bool isEqual(ColorGroup cr1, ColorGroup cr2) const;
-
- inline const QColor &color(ColorRole cr) const { return color(Current, cr); }
- inline const QBrush &brush(ColorRole cr) const { return brush(Current, cr); }
- inline const QBrush &foreground() const { return brush(WindowText); }
- inline const QBrush &windowText() const { return brush(WindowText); }
- inline const QBrush &button() const { return brush(Button); }
- inline const QBrush &light() const { return brush(Light); }
- inline const QBrush &dark() const { return brush(Dark); }
- inline const QBrush &mid() const { return brush(Mid); }
- inline const QBrush &text() const { return brush(Text); }
- inline const QBrush &base() const { return brush(Base); }
- inline const QBrush &alternateBase() const { return brush(AlternateBase); }
- inline const QBrush &toolTipBase() const { return brush(ToolTipBase); }
- inline const QBrush &toolTipText() const { return brush(ToolTipText); }
- inline const QBrush &background() const { return brush(Window); }
- inline const QBrush &window() const { return brush(Window); }
- inline const QBrush &midlight() const { return brush(Midlight); }
- inline const QBrush &brightText() const { return brush(BrightText); }
- inline const QBrush &buttonText() const { return brush(ButtonText); }
- inline const QBrush &shadow() const { return brush(Shadow); }
- inline const QBrush &highlight() const { return brush(Highlight); }
- inline const QBrush &highlightedText() const { return brush(HighlightedText); }
- inline const QBrush &link() const { return brush(Link); }
- inline const QBrush &linkVisited() const { return brush(LinkVisited); }
-
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT QPalette copy() const { QPalette p = *this; p.detach(); return p; }
- QT3_SUPPORT QColorGroup normal() const;
- inline QT3_SUPPORT void setNormal(const QColorGroup &cg) { setColorGroup(Active, cg); }
-
- QT3_SUPPORT QColorGroup active() const;
- QT3_SUPPORT QColorGroup disabled() const;
- QT3_SUPPORT QColorGroup inactive() const;
- inline QT3_SUPPORT void setActive(const QColorGroup &cg) { setColorGroup(Active, cg); }
- inline QT3_SUPPORT void setDisabled(const QColorGroup &cg) { setColorGroup(Disabled, cg); }
- inline QT3_SUPPORT void setInactive(const QColorGroup &cg) { setColorGroup(Inactive, cg); }
-#endif
-
- bool operator==(const QPalette &p) const;
- inline bool operator!=(const QPalette &p) const { return !(operator==(p)); }
- bool isCopyOf(const QPalette &p) const;
-
- int serialNumber() const;
- qint64 cacheKey() const;
-
- QPalette resolve(const QPalette &) const;
- inline uint resolve() const { return resolve_mask; }
- inline void resolve(uint mask) { resolve_mask = mask; }
-
-private:
- void setColorGroup(ColorGroup cr, const QBrush &windowText, const QBrush &button,
- const QBrush &light, const QBrush &dark, const QBrush &mid,
- const QBrush &text, const QBrush &bright_text,
- const QBrush &base, const QBrush &alternate_base,
- const QBrush &window, const QBrush &midlight,
- const QBrush &button_text, const QBrush &shadow,
- const QBrush &highlight, const QBrush &highlighted_text,
- const QBrush &link, const QBrush &link_visited);
- void setColorGroup(ColorGroup cr, const QBrush &windowText, const QBrush &button,
- const QBrush &light, const QBrush &dark, const QBrush &mid,
- const QBrush &text, const QBrush &bright_text,
- const QBrush &base, const QBrush &alternate_base,
- const QBrush &window, const QBrush &midlight,
- const QBrush &button_text, const QBrush &shadow,
- const QBrush &highlight, const QBrush &highlighted_text,
- const QBrush &link, const QBrush &link_visited,
- const QBrush &toolTipBase, const QBrush &toolTipText);
-#ifdef QT3_SUPPORT
- friend class QColorGroup;
- void setColorGroup(ColorGroup, const QColorGroup &);
- QColorGroup createColorGroup(ColorGroup) const;
-#endif
- void init();
- void detach();
-
- QPalettePrivate *d;
- uint current_group : 4;
- uint resolve_mask : 28;
- friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &s, const QPalette &p);
-};
-
-inline void QPalette::setColor(ColorGroup acg, ColorRole acr,
- const QColor &acolor)
-{ setBrush(acg, acr, QBrush(acolor)); }
-inline void QPalette::setColor(ColorRole acr, const QColor &acolor)
-{ setColor(All, acr, acolor); }
-inline void QPalette::setBrush(ColorRole acr, const QBrush &abrush)
-{ setBrush(All, acr, abrush); }
-
-#ifdef QT3_SUPPORT
-class Q_GUI_EXPORT QColorGroup : public QPalette
-{
-public:
- inline QColorGroup() : QPalette() {}
- inline QColorGroup(const QBrush &foreground, const QBrush &button, const QBrush &light,
- const QBrush &dark, const QBrush &mid, const QBrush &text,
- const QBrush &bright_text, const QBrush &base, const QBrush &background)
- : QPalette(foreground, button, light, dark, mid, text, bright_text, base, background)
- {}
- inline QColorGroup(const QColor &foreground, const QColor &background, const QColor &light,
- const QColor &dark, const QColor &mid, const QColor &text, const QColor &base)
- : QPalette(foreground, background, light, dark, mid, text, base) {}
- inline QColorGroup(const QColorGroup &cg) : QPalette(cg) {}
- inline QColorGroup(const QPalette &pal) : QPalette(pal) {}
- bool operator==(const QColorGroup &other) const;
- inline bool operator!=(const QColorGroup &other) const { return !(operator==(other)); }
- operator QVariant() const;
-
- inline QT3_SUPPORT const QColor &foreground() const { return color(WindowText); }
- inline QT3_SUPPORT const QColor &button() const { return color(Button); }
- inline QT3_SUPPORT const QColor &light() const { return color(Light); }
- inline QT3_SUPPORT const QColor &dark() const { return color(Dark); }
- inline QT3_SUPPORT const QColor &mid() const { return color(Mid); }
- inline QT3_SUPPORT const QColor &text() const { return color(Text); }
- inline QT3_SUPPORT const QColor &base() const { return color(Base); }
- inline QT3_SUPPORT const QColor &background() const { return color(Window); }
- inline QT3_SUPPORT const QColor &midlight() const { return color(Midlight); }
- inline QT3_SUPPORT const QColor &brightText() const { return color(BrightText); }
- inline QT3_SUPPORT const QColor &buttonText() const { return color(ButtonText); }
- inline QT3_SUPPORT const QColor &shadow() const { return color(Shadow); }
- inline QT3_SUPPORT const QColor &highlight() const { return color(Highlight); }
- inline QT3_SUPPORT const QColor &highlightedText() const { return color(HighlightedText); }
- inline QT3_SUPPORT const QColor &link() const { return color(Link); }
- inline QT3_SUPPORT const QColor &linkVisited() const { return color(LinkVisited); }
-};
-
-#ifndef QT_NO_DATASTREAM
-Q_GUI_EXPORT QT3_SUPPORT QDataStream &operator<<(QDataStream &ds, const QColorGroup &cg);
-Q_GUI_EXPORT QT3_SUPPORT QDataStream &operator>>(QDataStream &ds, QColorGroup &cg);
-#endif
-
-inline QColorGroup QPalette::inactive() const { return createColorGroup(Inactive); }
-inline QColorGroup QPalette::disabled() const { return createColorGroup(Disabled); }
-inline QColorGroup QPalette::active() const { return createColorGroup(Active); }
-inline QColorGroup QPalette::normal() const { return createColorGroup(Active); }
-
-#endif
-
-/*****************************************************************************
- QPalette stream functions
- *****************************************************************************/
-#ifndef QT_NO_DATASTREAM
-Q_GUI_EXPORT QDataStream &operator<<(QDataStream &ds, const QPalette &p);
-Q_GUI_EXPORT QDataStream &operator>>(QDataStream &ds, QPalette &p);
-#endif // QT_NO_DATASTREAM
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QPALETTE_H
diff --git a/src/gui/kernel/qplatformcursor_qpa.cpp b/src/gui/kernel/qplatformcursor_qpa.cpp
deleted file mode 100644
index 2ea8332ecc..0000000000
--- a/src/gui/kernel/qplatformcursor_qpa.cpp
+++ /dev/null
@@ -1,660 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "qplatformcursor_qpa.h"
-
-#include <QWidget>
-#include <QPainter>
-#include <QBitmap>
-#include <QApplication>
-
-#include <QDebug>
-
-QT_BEGIN_NAMESPACE
-
-QList <QWeakPointer<QPlatformCursor> > QPlatformCursorPrivate::instances;
-
-/*!
- \class QGraphicsSystemCursor
-
- \brief The QGraphicsSystemCursor class provides information about
- pointer device events (movement, buttons), and requests to change
- the currently displayed cursor.
-
- Note that QGraphicsSystemCursor does not include any graphics for
- display. An application that sets a QCursor may provide its own
- graphics.
-
- \sa QGraphicsSystemCursorImage
-*/
-
-/*!
- \fn virtual void QGraphicsSystemCursor::pointerEvent(const QMouseEvent & event)
-
- This method is called by Qt whenever a QMouseEvent is generated by the
- underlying pointer input. \a event is a reference to the QMouseEvent in
- question. A default do-nothing implementation is provided.
-
- \sa QApplicationPrivate::handleMouseEvent()
-*/
-
-/*!
- \fn virtual void QGraphicsSystemCursor::changeCursor(QCursor * widgetCursor, QWidget * widget)
-
- \brief This method is called by Qt whenever the cursor graphic should be changed.
-
- Implementation of this method is mandatory for a subclass of QGraphicsSystemCursor.
-
- \a widgetCursor is a pointer to the QCursor that should be displayed.
-
- \a widget is a pointer to the widget currently displayed at QCursor::pos(). Note
- that this may be 0 if the current position is not occupied by a displayed widget.
-
- \sa QApplicationPrivate::handleMouseEvent(), QCursor::pos()
-*/
-
-/*!
- \fn QGraphicsSystemCursor::QGraphicsSystemCursor()
-
- \brief Constructs a QGraphicsSystemCursor
-*/
-QPlatformCursor::QPlatformCursor(QPlatformScreen *scr )
- : screen(scr)
-{
- QPlatformCursorPrivate::instances.append(this);
-}
-
-// End of display and pointer event handling code
-// Beginning of built-in cursor graphics
-// from src/gui/embedded/QGraphicsSystemCursorImage_qws.cpp
-
-/*!
- \class QGraphicsSystemCursorImage
-
- \brief The QGraphicsSystemCursorImage class provides a set of graphics
- intended to be used as cursors.
-
- \sa QGraphicsSystemCursor
-*/
-
-static QPlatformCursorImage *systemCursorTable[Qt::LastCursor+1];
-static bool systemCursorTableInit = false;
-
-// 16 x 16
-static const uchar cur_arrow_bits[] = {
- 0x07, 0x00, 0x39, 0x00, 0xc1, 0x01, 0x02, 0x0e, 0x02, 0x10, 0x02, 0x08,
- 0x04, 0x04, 0x04, 0x02, 0x04, 0x04, 0x88, 0x08, 0x48, 0x11, 0x28, 0x22,
- 0x10, 0x44, 0x00, 0x28, 0x00, 0x10, 0x00, 0x00 };
-static const uchar mcur_arrow_bits[] = {
- 0x07, 0x00, 0x3f, 0x00, 0xff, 0x01, 0xfe, 0x0f, 0xfe, 0x1f, 0xfe, 0x0f,
- 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x07, 0xf8, 0x0f, 0x78, 0x1f, 0x38, 0x3e,
- 0x10, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00, 0x00 };
-
-static const unsigned char cur_up_arrow_bits[] = {
- 0x80, 0x00, 0x40, 0x01, 0x40, 0x01, 0x20, 0x02, 0x20, 0x02, 0x10, 0x04,
- 0x10, 0x04, 0x08, 0x08, 0x78, 0x0f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01,
- 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01};
-static const unsigned char mcur_up_arrow_bits[] = {
- 0x80, 0x00, 0xc0, 0x01, 0xc0, 0x01, 0xe0, 0x03, 0xe0, 0x03, 0xf0, 0x07,
- 0xf0, 0x07, 0xf8, 0x0f, 0xf8, 0x0f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
- 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01};
-
-static const unsigned char cur_cross_bits[] = {
- 0xc0, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01,
- 0x7f, 0x7f, 0x01, 0x40, 0x7f, 0x7f, 0x40, 0x01, 0x40, 0x01, 0x40, 0x01,
- 0x40, 0x01, 0x40, 0x01, 0xc0, 0x01, 0x00, 0x00};
-static const unsigned char mcur_cross_bits[] = {
- 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
- 0xff, 0x7f, 0xff, 0x7f, 0xff, 0x7f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
- 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00};
-
-static const uchar cur_ibeam_bits[] = {
- 0x00, 0x00, 0xe0, 0x03, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00,
- 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00,
- 0x80, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x00, 0x00 };
-static const uchar mcur_ibeam_bits[] = {
- 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
- 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01,
- 0xf0, 0x07, 0xf0, 0x07, 0xf0, 0x07, 0x00, 0x00 };
-
-static const uchar cur_ver_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f,
- 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xf0, 0x0f,
- 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00 };
-static const uchar mcur_ver_bits[] = {
- 0x00, 0x00, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, 0x1f, 0xf8, 0x3f,
- 0xfc, 0x7f, 0xc0, 0x07, 0xc0, 0x07, 0xc0, 0x07, 0xfc, 0x7f, 0xf8, 0x3f,
- 0xf0, 0x1f, 0xe0, 0x0f, 0xc0, 0x07, 0x80, 0x03 };
-
-static const uchar cur_hor_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x30, 0x18,
- 0x38, 0x38, 0xfc, 0x7f, 0xfc, 0x7f, 0x38, 0x38, 0x30, 0x18, 0x20, 0x08,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-static const uchar mcur_hor_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x60, 0x0c, 0x70, 0x1c, 0x78, 0x3c,
- 0xfc, 0x7f, 0xfe, 0xff, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x7f, 0x78, 0x3c,
- 0x70, 0x1c, 0x60, 0x0c, 0x40, 0x04, 0x00, 0x00 };
-static const uchar cur_bdiag_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x3e, 0x00, 0x3c, 0x00, 0x3e,
- 0x00, 0x37, 0x88, 0x23, 0xd8, 0x01, 0xf8, 0x00, 0x78, 0x00, 0xf8, 0x00,
- 0xf8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-static const uchar mcur_bdiag_bits[] = {
- 0x00, 0x00, 0xc0, 0x7f, 0x80, 0x7f, 0x00, 0x7f, 0x00, 0x7e, 0x04, 0x7f,
- 0x8c, 0x7f, 0xdc, 0x77, 0xfc, 0x63, 0xfc, 0x41, 0xfc, 0x00, 0xfc, 0x01,
- 0xfc, 0x03, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00 };
-static const uchar cur_fdiag_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf8, 0x00, 0x78, 0x00,
- 0xf8, 0x00, 0xd8, 0x01, 0x88, 0x23, 0x00, 0x37, 0x00, 0x3e, 0x00, 0x3c,
- 0x00, 0x3e, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00 };
-static const uchar mcur_fdiag_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x03, 0xfc, 0x01, 0xfc, 0x00,
- 0xfc, 0x41, 0xfc, 0x63, 0xdc, 0x77, 0x8c, 0x7f, 0x04, 0x7f, 0x00, 0x7e,
- 0x00, 0x7f, 0x80, 0x7f, 0xc0, 0x7f, 0x00, 0x00 };
-
-// 20 x 20
-static const uchar forbidden_bits[] = {
- 0x00,0x00,0x00,0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xf0,0x00,0x38,0xc0,0x01,
- 0x7c,0x80,0x03,0xec,0x00,0x03,0xce,0x01,0x07,0x86,0x03,0x06,0x06,0x07,0x06,
- 0x06,0x0e,0x06,0x06,0x1c,0x06,0x0e,0x38,0x07,0x0c,0x70,0x03,0x1c,0xe0,0x03,
- 0x38,0xc0,0x01,0xf0,0xe0,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00,0x00,0x00,0x00 };
-
-static const uchar forbiddenm_bits[] = {
- 0x80,0x1f,0x00,0xe0,0x7f,0x00,0xf0,0xff,0x00,0xf8,0xff,0x01,0xfc,0xf0,0x03,
- 0xfe,0xc0,0x07,0xfe,0x81,0x07,0xff,0x83,0x0f,0xcf,0x07,0x0f,0x8f,0x0f,0x0f,
- 0x0f,0x1f,0x0f,0x0f,0x3e,0x0f,0x1f,0xfc,0x0f,0x1e,0xf8,0x07,0x3e,0xf0,0x07,
- 0xfc,0xe0,0x03,0xf8,0xff,0x01,0xf0,0xff,0x00,0xe0,0x7f,0x00,0x80,0x1f,0x00};
-
-// 32 x 32
-static const uchar wait_data_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00,
- 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x08, 0x20, 0x00,
- 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00, 0x00, 0x08, 0x20, 0x00,
- 0x00, 0x50, 0x15, 0x00, 0x00, 0xa0, 0x0a, 0x00, 0x00, 0x40, 0x05, 0x00,
- 0x00, 0x80, 0x02, 0x00, 0x00, 0x40, 0x04, 0x00, 0x00, 0x20, 0x08, 0x00,
- 0x00, 0x10, 0x10, 0x00, 0x00, 0x08, 0x21, 0x00, 0x00, 0x88, 0x22, 0x00,
- 0x00, 0x48, 0x25, 0x00, 0x00, 0xa8, 0x2a, 0x00, 0x00, 0xfc, 0x7f, 0x00,
- 0x00, 0x04, 0x40, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-static const uchar wait_mask_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x7f, 0x00,
- 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xf8, 0x3f, 0x00,
- 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00,
- 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xe0, 0x0f, 0x00, 0x00, 0xc0, 0x07, 0x00,
- 0x00, 0x80, 0x03, 0x00, 0x00, 0xc0, 0x07, 0x00, 0x00, 0xe0, 0x0f, 0x00,
- 0x00, 0xf0, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00,
- 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00,
- 0x00, 0xfc, 0x7f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const uchar hsplit_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
- 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
- 0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03,
- 0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00,
- 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
- 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-static const uchar hsplitm_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
- 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00,
- 0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07,
- 0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00,
- 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
- 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-static const uchar vsplit_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00,
- 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-static const uchar vsplitm_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
- 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00,
- 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
- 0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
- 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
- 0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
- 0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00,
- 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-static const uchar phand_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00,
- 0x7e, 0x04, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x70, 0x08, 0x00, 0x00,
- 0x08, 0x08, 0x00, 0x00, 0x70, 0x14, 0x00, 0x00, 0x08, 0x22, 0x00, 0x00,
- 0x30, 0x41, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0x40, 0x12, 0x00, 0x00,
- 0x80, 0x08, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-static const uchar phandm_bits[] = {
- 0xfe, 0x01, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0xff, 0x07, 0x00, 0x00,
- 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x1f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00,
- 0xfc, 0x1f, 0x00, 0x00, 0xf8, 0x3f, 0x00, 0x00, 0xfc, 0x7f, 0x00, 0x00,
- 0xf8, 0xff, 0x00, 0x00, 0xf0, 0x7f, 0x00, 0x00, 0xe0, 0x3f, 0x00, 0x00,
- 0xc0, 0x1f, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00,
- 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const uchar size_all_data_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0x81, 0x40, 0x00, 0x80, 0x81, 0xc0, 0x00,
- 0xc0, 0xff, 0xff, 0x01, 0x80, 0x81, 0xc0, 0x00, 0x00, 0x81, 0x40, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00,
- 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-static const uchar size_all_mask_bits[] = {
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
- 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00,
- 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc2, 0x21, 0x00,
- 0x00, 0xc3, 0x61, 0x00, 0x80, 0xc3, 0xe1, 0x00, 0xc0, 0xff, 0xff, 0x01,
- 0xe0, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0x01, 0x80, 0xc3, 0xe1, 0x00,
- 0x00, 0xc3, 0x61, 0x00, 0x00, 0xc2, 0x21, 0x00, 0x00, 0xc0, 0x01, 0x00,
- 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0xe0, 0x03, 0x00,
- 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static const uchar whatsthis_bits[] = {
- 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0xf0, 0x07, 0x00,
- 0x09, 0x18, 0x0e, 0x00, 0x11, 0x1c, 0x0e, 0x00, 0x21, 0x1c, 0x0e, 0x00,
- 0x41, 0x1c, 0x0e, 0x00, 0x81, 0x1c, 0x0e, 0x00, 0x01, 0x01, 0x07, 0x00,
- 0x01, 0x82, 0x03, 0x00, 0xc1, 0xc7, 0x01, 0x00, 0x49, 0xc0, 0x01, 0x00,
- 0x95, 0xc0, 0x01, 0x00, 0x93, 0xc0, 0x01, 0x00, 0x21, 0x01, 0x00, 0x00,
- 0x20, 0xc1, 0x01, 0x00, 0x40, 0xc2, 0x01, 0x00, 0x40, 0x02, 0x00, 0x00,
- 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
-static const uchar whatsthism_bits[] = {
- 0x01, 0x00, 0x00, 0x00, 0x03, 0xf0, 0x07, 0x00, 0x07, 0xf8, 0x0f, 0x00,
- 0x0f, 0xfc, 0x1f, 0x00, 0x1f, 0x3e, 0x1f, 0x00, 0x3f, 0x3e, 0x1f, 0x00,
- 0x7f, 0x3e, 0x1f, 0x00, 0xff, 0x3e, 0x1f, 0x00, 0xff, 0x9d, 0x0f, 0x00,
- 0xff, 0xc3, 0x07, 0x00, 0xff, 0xe7, 0x03, 0x00, 0x7f, 0xe0, 0x03, 0x00,
- 0xf7, 0xe0, 0x03, 0x00, 0xf3, 0xe0, 0x03, 0x00, 0xe1, 0xe1, 0x03, 0x00,
- 0xe0, 0xe1, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00, 0xc0, 0xe3, 0x03, 0x00,
- 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
-
-static const uchar busy_bits[] = {
- 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
- 0x09, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00,
- 0x41, 0xe0, 0xff, 0x00, 0x81, 0x20, 0x80, 0x00, 0x01, 0xe1, 0xff, 0x00,
- 0x01, 0x42, 0x40, 0x00, 0xc1, 0x47, 0x40, 0x00, 0x49, 0x40, 0x55, 0x00,
- 0x95, 0x80, 0x2a, 0x00, 0x93, 0x00, 0x15, 0x00, 0x21, 0x01, 0x0a, 0x00,
- 0x20, 0x01, 0x11, 0x00, 0x40, 0x82, 0x20, 0x00, 0x40, 0x42, 0x44, 0x00,
- 0x80, 0x41, 0x4a, 0x00, 0x00, 0x40, 0x55, 0x00, 0x00, 0xe0, 0xff, 0x00,
- 0x00, 0x20, 0x80, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-static const uchar busym_bits[] = {
- 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
- 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00,
- 0x7f, 0xe0, 0xff, 0x00, 0xff, 0xe0, 0xff, 0x00, 0xff, 0xe1, 0xff, 0x00,
- 0xff, 0xc3, 0x7f, 0x00, 0xff, 0xc7, 0x7f, 0x00, 0x7f, 0xc0, 0x7f, 0x00,
- 0xf7, 0x80, 0x3f, 0x00, 0xf3, 0x00, 0x1f, 0x00, 0xe1, 0x01, 0x0e, 0x00,
- 0xe0, 0x01, 0x1f, 0x00, 0xc0, 0x83, 0x3f, 0x00, 0xc0, 0xc3, 0x7f, 0x00,
- 0x80, 0xc1, 0x7f, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00, 0xe0, 0xff, 0x00,
- 0x00, 0xe0, 0xff, 0x00, 0x00, 0xe0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
-
-// 16 x 16
-static const uchar openhand_bits[] = {
- 0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92,
- 0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20,
- 0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00};
-static const uchar openhandm_bits[] = {
- 0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff,
- 0xfe,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f,
- 0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00};
-static const uchar closedhand_bits[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50,
- 0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10,
- 0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00};
-static const uchar closedhandm_bits[] = {
- 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f,
- 0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f,
- 0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00};
-
-void QPlatformCursorImage::createSystemCursor(int id)
-{
- if (!systemCursorTableInit) {
- for (int i = 0; i <= Qt::LastCursor; i++)
- systemCursorTable[i] = 0;
- systemCursorTableInit = true;
- }
- switch (id) {
- // 16x16 cursors
- case Qt::ArrowCursor:
- systemCursorTable[Qt::ArrowCursor] =
- new QPlatformCursorImage(cur_arrow_bits, mcur_arrow_bits, 16, 16, 0, 0);
- break;
-
- case Qt::UpArrowCursor:
- systemCursorTable[Qt::UpArrowCursor] =
- new QPlatformCursorImage(cur_up_arrow_bits, mcur_up_arrow_bits, 16, 16, 7, 0);
- break;
-
- case Qt::CrossCursor:
- systemCursorTable[Qt::CrossCursor] =
- new QPlatformCursorImage(cur_cross_bits, mcur_cross_bits, 16, 16, 7, 7);
- break;
-
- case Qt::IBeamCursor:
- systemCursorTable[Qt::IBeamCursor] =
- new QPlatformCursorImage(cur_ibeam_bits, mcur_ibeam_bits, 16, 16, 7, 7);
- break;
-
- case Qt::SizeVerCursor:
- systemCursorTable[Qt::SizeVerCursor] =
- new QPlatformCursorImage(cur_ver_bits, mcur_ver_bits, 16, 16, 7, 7);
- break;
-
- case Qt::SizeHorCursor:
- systemCursorTable[Qt::SizeHorCursor] =
- new QPlatformCursorImage(cur_hor_bits, mcur_hor_bits, 16, 16, 7, 7);
- break;
-
- case Qt::SizeBDiagCursor:
- systemCursorTable[Qt::SizeBDiagCursor] =
- new QPlatformCursorImage(cur_bdiag_bits, mcur_bdiag_bits, 16, 16, 7, 7);
- break;
-
- case Qt::SizeFDiagCursor:
- systemCursorTable[Qt::SizeFDiagCursor] =
- new QPlatformCursorImage(cur_fdiag_bits, mcur_fdiag_bits, 16, 16, 7, 7);
- break;
-
- case Qt::BlankCursor:
- systemCursorTable[Qt::BlankCursor] =
- new QPlatformCursorImage(0, 0, 0, 0, 0, 0);
- break;
-
- // 20x20 cursors
- case Qt::ForbiddenCursor:
- systemCursorTable[Qt::ForbiddenCursor] =
- new QPlatformCursorImage(forbidden_bits, forbiddenm_bits, 20, 20, 10, 10);
- break;
-
- // 32x32 cursors
- case Qt::WaitCursor:
- systemCursorTable[Qt::WaitCursor] =
- new QPlatformCursorImage(wait_data_bits, wait_mask_bits, 32, 32, 15, 15);
- break;
-
- case Qt::SplitVCursor:
- systemCursorTable[Qt::SplitVCursor] =
- new QPlatformCursorImage(vsplit_bits, vsplitm_bits, 32, 32, 15, 15);
- break;
-
- case Qt::SplitHCursor:
- systemCursorTable[Qt::SplitHCursor] =
- new QPlatformCursorImage(hsplit_bits, hsplitm_bits, 32, 32, 15, 15);
- break;
-
- case Qt::SizeAllCursor:
- systemCursorTable[Qt::SizeAllCursor] =
- new QPlatformCursorImage(size_all_data_bits, size_all_mask_bits, 32, 32, 15, 15);
- break;
-
- case Qt::PointingHandCursor:
- systemCursorTable[Qt::PointingHandCursor] =
- new QPlatformCursorImage(phand_bits, phandm_bits, 32, 32, 0, 0);
- break;
-
- case Qt::WhatsThisCursor:
- systemCursorTable[Qt::WhatsThisCursor] =
- new QPlatformCursorImage(whatsthis_bits, whatsthism_bits, 32, 32, 0, 0);
- break;
- case Qt::BusyCursor:
- systemCursorTable[Qt::BusyCursor] =
- new QPlatformCursorImage(busy_bits, busym_bits, 32, 32, 0, 0);
- break;
-
- case Qt::OpenHandCursor:
- systemCursorTable[Qt::OpenHandCursor] =
- new QPlatformCursorImage(openhand_bits, openhandm_bits, 16, 16, 8, 8);
- break;
- case Qt::ClosedHandCursor:
- systemCursorTable[Qt::ClosedHandCursor] =
- new QPlatformCursorImage(closedhand_bits, closedhandm_bits, 16, 16, 8, 8);
- break;
- default:
- qWarning("Unknown system cursor %d", id);
- }
-}
-
-/*!
- \fn void QGraphicsSystemCursorImage::set(Qt::CursorShape id)
-
- \brief Calling this method sets the cursor image to the specified shape
-
- \a id is one of the defined Qt::CursorShape values.
-
- If id is invalid, Qt::BitmapCursor, or unknown by the implementation,
- Qt::ArrowCursor is used instead.
-*/
-
-void QPlatformCursorImage::set(Qt::CursorShape id)
-{
- QPlatformCursorImage *cursor = 0;
- if (id >= 0 && id <= Qt::LastCursor) {
- if (!systemCursorTable[id])
- createSystemCursor(id);
- cursor = systemCursorTable[id];
- }
-
- if (cursor == 0) {
- if (!systemCursorTable[Qt::ArrowCursor])
- createSystemCursor(Qt::ArrowCursor);
- cursor = systemCursorTable[Qt::ArrowCursor];
- }
- cursorImage = cursor->cursorImage;
- hot = cursor->hot;
-}
-
-/*!
- \fn void QGraphicsSystemCursorImage::set(const QImage * image, int hx, int hy)
-
- \brief Set the cursor image to the specified QImage, with the hotsport at (hx, hy)
-
- \a image A pointer to a QImage
-
- \a hx The x coordinate of the cursor's hotspot
-
- \a hy the y coordinate of the cursor's hotspot
-*/
-
-void QPlatformCursorImage::set(const QImage &image, int hx, int hy)
-{
- hot.setX(hx);
- hot.setY(hy);
- cursorImage = image;
-}
-
-/*!
- \fn void QGraphicsSystemCursorImage::set(const uchar *data, const uchar *mask, int width, int height, int hx, int hy)
-
- \brief set the cursor image to the graphic represented by the combination of data, mask,
- width, and height
-
- \a data The pixel data of the graphic
-
- \a mask Mask data for the graphic. pixels in data with a corresponding mask bit of 0 are not drawn
-
- \a width The width of the graphic in pixels
-
- \a height The height of the graphic in pixels
-
- \a hx The X hotspot of the cursor graphic
-
- \a hy The Y hotspot of the cursor graphic
-*/
-void QPlatformCursorImage::set(const uchar *data, const uchar *mask,
- int width, int height, int hx, int hy)
-{
- hot.setX(hx);
- hot.setY(hy);
-
- cursorImage = QImage(width,height, QImage::Format_Indexed8);
-
- if (!width || !height || !data || !mask || cursorImage.isNull())
- return;
-
- cursorImage.setNumColors(3);
- cursorImage.setColor(0, 0xff000000);
- cursorImage.setColor(1, 0xffffffff);
- cursorImage.setColor(2, 0x00000000);
-
- int bytesPerLine = (width + 7) / 8;
- int p = 0;
- int d, m;
-
- int x = -1, w = 0;
-
- uchar *cursor_data = cursorImage.bits();
- int bpl = cursorImage.bytesPerLine();
- for (int i = 0; i < height; i++)
- {
- for (int j = 0; j < bytesPerLine; j++, data++, mask++)
- {
- for (int b = 0; b < 8 && j*8+b < width; b++)
- {
- d = *data & (1 << b);
- m = *mask & (1 << b);
- if (d && m) p = 0;
- else if (!d && m) p = 1;
- else p = 2;
- cursor_data[j*8+b] = p;
-
- // calc region
- if (x < 0 && m)
- x = j*8+b;
- else if (x >= 0 && !m) {
- x = -1;
- w = 0;
- }
- if (m)
- w++;
- }
- }
- if (x >= 0) {
- x = -1;
- w = 0;
- }
- cursor_data += bpl;
- }
-
-}
-
-/*!
- \fn QGraphicsSystemCursorImage::QGraphicsSystemCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY)
-
- \brief set the cursor image to the graphic represented by the combination of data, mask,
- width, and height
-
- \a data The pixel data of the graphic
-
- \a mask Mask data for the graphic. pixels in data with a corresponding mask bit of 0 are not drawn
-
- \a width The width of the graphic in pixels
-
- \a height The height of the graphic in pixels
-
- \a hotX The X hotspot of the cursor graphic
-
- \a hotY The Y hotspot of the cursor graphic
-
- \sa set
-*/
-
-/*!
- \fn QImage *QGraphicsSystemCursorImage::image()
-
- \brief Return the cursor graphic as a pointer to a QImage
-*/
-
-/*!
- \fn QPoint QGraphicsSystemCursorImage::hotspot()
-
- \brief Return the cursor's hotspot
-*/
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformcursor_qpa.h b/src/gui/kernel/qplatformcursor_qpa.h
deleted file mode 100644
index 71d0e87444..0000000000
--- a/src/gui/kernel/qplatformcursor_qpa.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QGRAPHICSSYSTEMCURSOR_H
-#define QGRAPHICSSYSTEMCURSOR_H
-
-#include <QtCore/QList>
-#include <QtGui/QImage>
-#include <QtGui/QMouseEvent>
-#include <QtCore/QWeakPointer>
-#include <QtCore/QObject>
-#include <QtGui/QPlatformScreen>
-#include <QtGui/QCursor>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-// Cursor graphics management
-class Q_GUI_EXPORT QPlatformCursorImage {
-public:
- QPlatformCursorImage(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY)
- { set(data, mask, width, height, hotX, hotY); }
- QImage * image() { return &cursorImage; }
- QPoint hotspot() { return hot; }
- void set(const uchar *data, const uchar *mask, int width, int height, int hotX, int hotY);
- void set(const QImage &image, int hx, int hy);
- void set(Qt::CursorShape);
-private:
- static void createSystemCursor(int id);
- QImage cursorImage;
- QPoint hot;
-};
-
-class QPlatformCursor;
-
-class QPlatformCursorPrivate {
-public:
- static QList<QWeakPointer<QPlatformCursor> > getInstances() { return instances; }
- static QList<QWeakPointer<QPlatformCursor> > instances;
-};
-
-class Q_GUI_EXPORT QPlatformCursor : public QObject {
-public:
- QPlatformCursor(QPlatformScreen *);
-
- // input methods
- virtual void pointerEvent(const QMouseEvent & event) { Q_UNUSED(event); }
- virtual void changeCursor(QCursor * widgetCursor, QWidget * widget) = 0;
-
-protected:
- QPlatformScreen* screen; // Where to request an update
-
-private:
- Q_DECLARE_PRIVATE(QPlatformCursor);
- friend void qt_qpa_set_cursor(QWidget * w, bool force);
- friend class QApplicationPrivate;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QGRAPHICSSYSTEMCURSOR_H
diff --git a/src/gui/kernel/qplatformglcontext_qpa.cpp b/src/gui/kernel/qplatformglcontext_qpa.cpp
deleted file mode 100644
index 181053223f..0000000000
--- a/src/gui/kernel/qplatformglcontext_qpa.cpp
+++ /dev/null
@@ -1,209 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenGL module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qplatformglcontext_qpa.h"
-
-#include <QtCore/QThreadStorage>
-#include <QtCore/QThread>
-
-#include <QDebug>
-
-class QPlatformGLThreadContext
-{
-public:
- ~QPlatformGLThreadContext() {
- if (context)
- context->doneCurrent();
- }
- QPlatformGLContext *context;
-};
-
-static QThreadStorage<QPlatformGLThreadContext *> qplatformgl_context_storage;
-
-class QPlatformGLContextPrivate
-{
-public:
- QPlatformGLContextPrivate()
- :qGLContextHandle(0)
- {
- }
-
- virtual ~QPlatformGLContextPrivate()
- {
- //do not delete the QGLContext handle here as it is deleted in
- //QWidgetPrivate::deleteTLSysExtra()
- }
- void *qGLContextHandle;
- void (*qGLContextDeleteFunction)(void *handle);
- static QPlatformGLContext *staticSharedContext;
-
- static void setCurrentContext(QPlatformGLContext *context);
-};
-
-QPlatformGLContext *QPlatformGLContextPrivate::staticSharedContext = 0;
-
-void QPlatformGLContextPrivate::setCurrentContext(QPlatformGLContext *context)
-{
- QPlatformGLThreadContext *threadContext = qplatformgl_context_storage.localData();
- if (!threadContext) {
- if (!QThread::currentThread()) {
- qWarning("No QTLS available. currentContext wont work");
- return;
- }
- threadContext = new QPlatformGLThreadContext;
- qplatformgl_context_storage.setLocalData(threadContext);
- }
- threadContext->context = context;
-}
-
-/*!
- Returns the last context which called makeCurrent. This function is thread aware.
-*/
-const QPlatformGLContext* QPlatformGLContext::currentContext()
-{
- QPlatformGLThreadContext *threadContext = qplatformgl_context_storage.localData();
- if(threadContext) {
- return threadContext->context;
- }
- return 0;
-}
-
-/*!
- All subclasses needs to specify the platformWindow. It can be a null window.
-*/
-QPlatformGLContext::QPlatformGLContext()
- :d_ptr(new QPlatformGLContextPrivate())
-{
-}
-
-/*!
- If this is the current context for the thread, doneCurrent is called
-*/
-QPlatformGLContext::~QPlatformGLContext()
-{
- if (QPlatformGLContext::currentContext() == this) {
- doneCurrent();
- }
-
-}
-
-/*!
- Reimplement in subclass to do makeCurrent on native GL context
-*/
-void QPlatformGLContext::makeCurrent()
-{
- QPlatformGLContextPrivate::setCurrentContext(this);
-}
-
-/*!
- Reimplement in subclass to release current context.
- Typically this is calling makeCurrent with 0 "surface"
-*/
-void QPlatformGLContext::doneCurrent()
-{
- QPlatformGLContextPrivate::setCurrentContext(0);
-}
-
-/*
- internal: Needs to have a pointer to qGLContext. But since this is in QtGui we cant
- have any type information.
-*/
-void *QPlatformGLContext::qGLContextHandle() const
-{
- Q_D(const QPlatformGLContext);
- return d->qGLContextHandle;
-}
-
-void QPlatformGLContext::setQGLContextHandle(void *handle,void (*qGLContextDeleteFunction)(void *))
-{
- Q_D(QPlatformGLContext);
- d->qGLContextHandle = handle;
- d->qGLContextDeleteFunction = qGLContextDeleteFunction;
-}
-
-void QPlatformGLContext::deleteQGLContext()
-{
- Q_D(QPlatformGLContext);
- if (d->qGLContextDeleteFunction && d->qGLContextHandle) {
- d->qGLContextDeleteFunction(d->qGLContextHandle);
- d->qGLContextDeleteFunction = 0;
- d->qGLContextHandle = 0;
- }
-}
-
-/*!
- \class QPlatformGLContext
- \since 4.8
- \internal
- \preliminary
- \ingroup qpa
-
- \brief The QPlatformGLContext class provides an abstraction for native GL contexts.
-
- In QPA the way to support OpenGL or OpenVG or other technologies that requires a native GL
- context is through the QPlatformGLContext wrapper.
-
- There is no factory function for QPlatformGLContexts, but rather only one accessor function.
- The only place to retrieve a QPlatformGLContext from is through a QPlatformWindow.
-
- The context which is current for a specific thread can be collected by the currentContext()
- function. This is how QPlatformGLContext also makes it possible to use the QtOpenGL module
- withhout using QGLWidget. When using QGLContext::currentContext(), it will ask
- QPlatformGLContext for the currentContext. Then a corresponding QGLContext will be returned,
- which maps to the QPlatformGLContext.
-*/
-
-/*! \fn void swapBuffers()
- Reimplement in subclass to native swap buffers calls
-*/
-
-/*! getProcAddress(const QString& procName)
- Reimplement in subclass to native getProcAddr calls.
-
- Note: its convenient to use qPrintable(const QString &str) to get the const char * pointer
-*/
-
-/*! platformWindowFormat() const
- QWidget has the function qplatformWindowFormat(). That function is for the application
- programmer to request the format of the window and the context that he wants.
-
- Reimplement this function in a subclass to indicate what format the glContext actually has.
-*/
diff --git a/src/gui/kernel/qplatformglcontext_qpa.h b/src/gui/kernel/qplatformglcontext_qpa.h
deleted file mode 100644
index 28923a9457..0000000000
--- a/src/gui/kernel/qplatformglcontext_qpa.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenGL module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPLATFORM_GL_CONTEXT_H
-#define QPLATFORM_GL_CONTEXT_H
-
-#include <QtCore/qnamespace.h>
-#include <QtGui/QPlatformWindowFormat>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QPlatformGLContextPrivate;
-
-class Q_OPENGL_EXPORT QPlatformGLContext
-{
-Q_DECLARE_PRIVATE(QPlatformGLContext);
-
-public:
- explicit QPlatformGLContext();
- virtual ~QPlatformGLContext();
-
- virtual void makeCurrent();
- virtual void doneCurrent();
- virtual void swapBuffers() = 0;
- virtual void* getProcAddress(const QString& procName) = 0;
-
- virtual QPlatformWindowFormat platformWindowFormat() const = 0;
-
- const static QPlatformGLContext *currentContext();
-
-protected:
- QScopedPointer<QPlatformGLContextPrivate> d_ptr;
-
-private:
- //hack to make it work with QGLContext::CurrentContext
- friend class QGLContext;
- friend class QWidgetPrivate;
- void *qGLContextHandle() const;
- void setQGLContextHandle(void *handle,void (*qGLContextDeleteFunction)(void *));
- void deleteQGLContext();
- Q_DISABLE_COPY(QPlatformGLContext);
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-
-#endif // QPLATFORM_GL_INTEGRATION_P_H
diff --git a/src/gui/kernel/qplatformintegration_qpa.cpp b/src/gui/kernel/qplatformintegration_qpa.cpp
deleted file mode 100644
index 8ff12ebf9c..0000000000
--- a/src/gui/kernel/qplatformintegration_qpa.cpp
+++ /dev/null
@@ -1,225 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qplatformintegration_qpa.h"
-
-#include <QtGui/QPlatformFontDatabase>
-#include <QtGui/QPlatformClipboard>
-
-QT_BEGIN_NAMESPACE
-
-QPixmap QPlatformIntegration::grabWindow(WId window, int x, int y, int width, int height) const
-{
- Q_UNUSED(window);
- Q_UNUSED(x);
- Q_UNUSED(y);
- Q_UNUSED(width);
- Q_UNUSED(height);
- return QPixmap();
-}
-
-/*!
- Factory function for the eventloop integration interface.
-
- Default implementation returns 0, which causes the eventloop to run in a single thread mode.
-
- \sa QPlatformEventLoopIntegration
-*/
-QPlatformEventLoopIntegration *QPlatformIntegration::createEventLoopIntegration() const
-{
- return 0;
-}
-
-/*!
- Accessor for the platform integrations fontdatabase.
-
- Default implementation returns a default QPlatformFontDatabase.
-
- \sa QPlatformFontDatabase
-*/
-QPlatformFontDatabase *QPlatformIntegration::fontDatabase() const
-{
- static QPlatformFontDatabase *db = 0;
- if (!db) {
- db = new QPlatformFontDatabase;
- }
- return db;
-}
-
-/*!
- Accessor for the platform integrations clipboard.
-
- Default implementation returns a default QPlatformClipboard.
-
- \sa QPlatformClipboard
-
-*/
-
-#ifndef QT_NO_CLIPBOARD
-
-QPlatformClipboard *QPlatformIntegration::clipboard() const
-{
- static QPlatformClipboard *clipboard = 0;
- if (!clipboard) {
- clipboard = new QPlatformClipboard;
- }
- return clipboard;
-}
-
-#endif
-
-QPlatformNativeInterface * QPlatformIntegration::nativeInterface() const
-{
- return 0;
-}
-
-/*!
- \class QPlatformIntegration
- \since 4.8
- \internal
- \preliminary
- \ingroup qpa
- \brief The QPlatformIntegration class is the entry for WindowSystem specific functionality.
-
- QPlatformIntegration is the single entry point for windowsystem specific functionality when
- using the QPA platform. It has factory functions for creating platform specific pixmaps and
- windows. The class also controls the font subsystem.
-
- QPlatformIntegration is a singelton class which gets instansiated in the QApplication
- constructor. The QPlatformIntegration instance do not have ownership of objects it creates in
- functions where the name starts with create. However, functions which don't have a name
- starting with create acts as assessors to member variables.
-
- It is not trivial to create or build a platform plugin outside of the Qt source tree. Therefor
- the recommended approach for making new platform plugin is to copy an existing plugin inside
- the QTSRCTREE/src/plugins/platform and develop the plugin inside the source tree.
-
- The minimal platformintegration is the smallest platform integration it is possible to make,
- which makes it an ideal starting point for new plugins. For a slightly more advanced plugin,
- consider reviewing the directfb plugin, or the testlite plugin.
-*/
-
-/*!
- \fn QPixmapData *createPixmapData(QPixmapData::PixelType type) const
-
- Factory function for QPixmapData. PixelType can be either PixmapType or BitmapType.
- \sa QPixmapData
-*/
-
-/*!
- \fn QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const
-
- Factory function for QPlatformWindow. The widget parameter is a pointer to the top level
- widget(tlw) which the QPlatformWindow is suppose to be created for. The WId handle is actually
- never used, but there for future reference. Its purpose is if it is going to be possible to
- create QPlatformWindows on existing WId.
-
- All tlw has to have a QPlatformWindow, and it will be created when the QPlatformWindow is set
- to be visible for the first time. If the tlw's window flags are changed, or if the tlw's
- QPlatformWindowFormat is changed, then the tlw's QPlatformWindow is deleted and a new one is
- created.
-
- \sa QPlatformWindow, QPlatformWindowFormat
- \sa createWindowSurface(QWidget *widget, WId winId) const
-*/
-
-/*!
- \fn QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const
-
- Factory function for QWindowSurface. The QWidget parameter is a pointer to the
- top level widget(tlw) the window surface is created for. A QPlatformWindow is always created
- before the QWindowSurface for tlw where the widget also requires a WindowSurface. It is
- possible to create top level QWidgets without a QWindowSurface by specifying
- QPlatformWindowFormat::setWindowSurface(false) for the tlw QPlatformWindowFormat.
-
- \sa QWindowSurface
- \sa createPlatformWindow(QWidget *widget, WId winId = 0) const
-*/
-
-/*!
- \fn void moveToScreen(QWidget *window, int screen)
-
- This function is called when a QWidget is displayed on screen, or the QWidget is to be
- displayed on a new screen. The QWidget parameter is a pointer to the top level widget and
- the int parameter is the index to the screen in QList<QPlatformScreen *> screens() const.
-
- Default implementation does nothing.
-
- \sa screens() const
-*/
-
-/*!
- \fn QList<QPlatformScreen *> screens() const
-
- Accessor function to a list of all the screens on the current system. The screen with the
- index == 0 is the default/main screen.
-*/
-
-/*!
- \fn bool isVirtualDesktop()
-
- Returns if the current windowing system configuration defines all the screens to be one
- desktop(virtual desktop), or if each screen is a desktop of its own.
-
- Default implementation returns false.
-*/
-
-/*!
- \fn QPixmap grabWindow(WId window, int x, int y, int width, int height) const
-
- This function is called when Qt needs to be able to grab the content of a window.
-
- Returnes the content of the window specified with the WId handle within the boundaries of
- QRect(x,y,width,height).
-*/
-
-
-bool QPlatformIntegration::hasCapability(Capability cap) const
-{
- Q_UNUSED(cap);
- return false;
-}
-
-
-
-
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformintegration_qpa.h b/src/gui/kernel/qplatformintegration_qpa.h
deleted file mode 100644
index d06272ce01..0000000000
--- a/src/gui/kernel/qplatformintegration_qpa.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPLATFORMINTEGRATION_H
-#define QPLATFORMINTEGRATION_H
-
-#include <QtGui/qwindowdefs.h>
-#include <QtGui/private/qwindowsurface_p.h>
-#include <QtGui/private/qpixmapdata_p.h>
-#include <QtGui/qplatformscreen_qpa.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QPlatformWindow;
-class QWindowSurface;
-class QBlittable;
-class QWidget;
-class QPlatformEventLoopIntegration;
-class QPlatformFontDatabase;
-class QPlatformClipboard;
-class QPlatformNativeInterface;
-
-class Q_GUI_EXPORT QPlatformIntegration
-{
-public:
- enum Capability {
- ThreadedPixmaps = 1,
- OpenGL = 2
- };
-
- virtual ~QPlatformIntegration() { }
-
- virtual bool hasCapability(Capability cap) const;
-
-// GraphicsSystem functions
- virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const = 0;
- virtual QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId = 0) const = 0;
- virtual QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const = 0;
-
-// Window System functions
- virtual QList<QPlatformScreen *> screens() const = 0;
- virtual void moveToScreen(QWidget *window, int screen) {Q_UNUSED(window); Q_UNUSED(screen);}
- virtual bool isVirtualDesktop() { return false; }
- virtual QPixmap grabWindow(WId window, int x, int y, int width, int height) const;
-
-//Deeper window system integrations
- virtual QPlatformFontDatabase *fontDatabase() const;
-#ifndef QT_NO_CLIPBOARD
- virtual QPlatformClipboard *clipboard() const;
-#endif
-
-// Experimental in mainthread eventloop integration
-// This should only be used if it is only possible to do window system event processing in
-// the gui thread. All of the functions in QWindowSystemInterface are thread safe.
- virtual QPlatformEventLoopIntegration *createEventLoopIntegration() const;
-
-// Access native handles. The window handle is already available from Wid;
- virtual QPlatformNativeInterface *nativeInterface() const;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QPLATFORMINTEGRATION_H
diff --git a/src/gui/kernel/qplatformintegrationfactory_qpa.cpp b/src/gui/kernel/qplatformintegrationfactory_qpa.cpp
deleted file mode 100644
index 4135c9e86a..0000000000
--- a/src/gui/kernel/qplatformintegrationfactory_qpa.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qplatformintegrationfactory_qpa_p.h"
-#include <QPlatformIntegrationPlugin>
-#include "private/qfactoryloader_p.h"
-#include "qmutex.h"
-
-#include "qapplication.h"
-#include "qdebug.h"
-
-QT_BEGIN_NAMESPACE
-
-#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
-Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
- (QPlatformIntegrationFactoryInterface_iid, QLatin1String("/platforms"), Qt::CaseInsensitive))
-Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
- (QPlatformIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
-#endif
-
-QPlatformIntegration *QPlatformIntegrationFactory::create(const QString& key, const QString &platformPluginPath)
-{
- QPlatformIntegration *ret = 0;
- QStringList paramList = key.split(QLatin1Char(':'));
- QString platform = paramList.takeFirst().toLower();
-
-#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
- // Try loading the plugin from platformPluginPath first:
- if (!platformPluginPath.isEmpty()) {
- QCoreApplication::addLibraryPath(platformPluginPath);
- if (QPlatformIntegrationFactoryInterface *factory =
- qobject_cast<QPlatformIntegrationFactoryInterface*>(directLoader()->instance(platform)))
- ret = factory->create(key, paramList);
-
- if (ret)
- return ret;
- }
- if (QPlatformIntegrationFactoryInterface *factory = qobject_cast<QPlatformIntegrationFactoryInterface*>(loader()->instance(platform)))
- ret = factory->create(platform, paramList);
-#endif
-
- return ret;
-}
-
-/*!
- Returns the list of valid keys, i.e. the keys this factory can
- create styles for.
-
- \sa create()
-*/
-QStringList QPlatformIntegrationFactory::keys(const QString &platformPluginPath)
-{
-#if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
- QStringList list;
-
- if (!platformPluginPath.isEmpty()) {
- QCoreApplication::addLibraryPath(platformPluginPath);
- foreach (const QString &key, directLoader()->keys()) {
- list += key + QString(QLatin1String(" (from %1)")).arg(platformPluginPath);
- }
- }
-
- list += loader()->keys();
-#else
- QStringList list;
-#endif
- return list;
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/gui/kernel/qplatformnativeinterface_qpa.cpp b/src/gui/kernel/qplatformnativeinterface_qpa.cpp
deleted file mode 100644
index 281aeba302..0000000000
--- a/src/gui/kernel/qplatformnativeinterface_qpa.cpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qplatformnativeinterface_qpa.h"
-
-QT_BEGIN_NAMESPACE
-
-void *QPlatformNativeInterface::nativeResourceForWidget(const QByteArray &resource, QWidget *widget)
-{
- Q_UNUSED(resource);
- Q_UNUSED(widget);
- return 0;
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformnativeinterface_qpa.h b/src/gui/kernel/qplatformnativeinterface_qpa.h
deleted file mode 100644
index b9d061982a..0000000000
--- a/src/gui/kernel/qplatformnativeinterface_qpa.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPLATFORMNATIVEINTERFACE_QPA_H
-#define QPLATFORMNATIVEINTERFACE_QPA_H
-
-#include <QtGui/qwindowdefs.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QWidget;
-
-class Q_GUI_EXPORT QPlatformNativeInterface
-{
-public:
- virtual void *nativeResourceForWidget(const QByteArray &resource, QWidget *widget);
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QPLATFORMNATIVEINTERFACE_QPA_H
diff --git a/src/gui/kernel/qplatformscreen_qpa.cpp b/src/gui/kernel/qplatformscreen_qpa.cpp
deleted file mode 100644
index c9f3dc6f34..0000000000
--- a/src/gui/kernel/qplatformscreen_qpa.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qplatformscreen_qpa.h"
-#include <QtGui/qapplication.h>
-#include <QtGui/private/qapplication_p.h>
-#include <QtGui/qdesktopwidget.h>
-#include <QtGui/qplatformintegration_qpa.h>
-#include <QtGui/qwidget.h>
-#include <QtGui/private/qwidget_p.h>
-
-/*!
- Return the given top level widget for a given position.
-
- Default implementation retrieves a list of all top level widgets and finds the first widget
- which contains point \a pos
-*/
-QWidget *QPlatformScreen::topLevelAt(const QPoint & pos) const
-{
- QWidgetList list = QApplication::topLevelWidgets();
- for (int i = list.size()-1; i >= 0; --i) {
- QWidget *w = list[i];
- //### mask is ignored
- if (w != QApplication::desktop() && w->isVisible() && w->geometry().contains(pos))
- return w;
- }
-
- return 0;
-}
-
-/*! \fn physicalSize() const
- Reimplement in subclass to return the physical size of the screen. This function is used by
- QFont to convert point sizes to pixel sizes.
-
- Default implementation takes the pixel size of the screen, considers a dpi of 100 and returns
- the calculated (and probably wrong) physical size
-*/
-QSize QPlatformScreen::physicalSize() const
-{
- static const int dpi = 100;
- int width = geometry().width() / dpi * qreal(25.4) ;
- int height = geometry().height() / dpi * qreal(25.4) ;
- return QSize(width,height);
-}
-
-Q_GUI_EXPORT extern QWidgetPrivate *qt_widget_private(QWidget *widget);
-QPlatformScreen * QPlatformScreen::platformScreenForWidget(const QWidget *widget)
-{
- QWidget *window = widget->window();
- QWidgetPrivate *windowPrivate = qt_widget_private(window);
- QTLWExtra * topData = windowPrivate->topData();
- QPlatformIntegration *integration =
- QApplicationPrivate::platformIntegration();
- return integration->screens()[topData->screenIndex];
-}
-
-/*!
- \class QPlatformScreen
- \since 4.8
- \internal
- \preliminary
- \ingroup qpa
-
- \brief The QPlatformScreen class provides an abstraction for visual displays.
-
- Many window systems has support for retrieving information on the attached displays. To be able
- to query the display QPA uses QPlatformScreen. Qt its self is most dependent on the
- physicalSize() function, since this is the function it uses to calculate the dpi to use when
- converting point sizes to pixels sizes. However, this is unfortunate on some systems, as the
- native system fakes its dpi size.
-
- QPlatformScreen is also used by the public api QDesktopWidget for information about the desktop.
- */
-
-/*! \fn geometry() const
- Reimplement in subclass to return the pixel geometry of the screen
-*/
-
-/*! \fn availableGeometry() const
- Reimplement in subclass to return the pixel geometry of the available space
- This normally is the desktop screen minus the task manager, global menubar etc.
-*/
-
-/*! \fn depth() const
- Reimplement in subclass to return current depth of the screen
-*/
-
-/*! \fn format() const
- Reimplement in subclass to return the image format which corresponds to the screen format
-*/
-
diff --git a/src/gui/kernel/qplatformscreen_qpa.h b/src/gui/kernel/qplatformscreen_qpa.h
deleted file mode 100644
index b3bb121331..0000000000
--- a/src/gui/kernel/qplatformscreen_qpa.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPLATFORMSCREEN_H
-#define QPLATFORMSCREEN_H
-
-#include <QtCore/qmetatype.h>
-#include <QtCore/qnamespace.h>
-#include <QtCore/qcoreevent.h>
-#include <QtCore/qvariant.h>
-#include <QtCore/qrect.h>
-#include <QtCore/qobject.h>
-
-#include <QtGui/qcursor.h>
-#include <QtGui/qimage.h>
-#include <QtGui/qwidget.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class Q_GUI_EXPORT QPlatformScreen : public QObject
-{
- Q_OBJECT
-public:
- virtual ~QPlatformScreen() { }
-
- virtual QRect geometry() const = 0;
- virtual QRect availableGeometry() const {return geometry();}
- virtual int depth() const = 0;
- virtual QImage::Format format() const = 0;
- virtual QSize physicalSize() const;
- //jl: should setDirty be removed.
- virtual void setDirty(const QRect &) {}
- virtual QWidget *topLevelAt(const QPoint &point) const;
-
- //jl: should this function be in QPlatformIntegration
- //jl: maybe screenForWidget is a better name?
- static QPlatformScreen *platformScreenForWidget(const QWidget *widget);
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QPLATFORMSCREEN_H
diff --git a/src/gui/kernel/qplatformwindow_qpa.cpp b/src/gui/kernel/qplatformwindow_qpa.cpp
deleted file mode 100644
index f3654b676d..0000000000
--- a/src/gui/kernel/qplatformwindow_qpa.cpp
+++ /dev/null
@@ -1,229 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qplatformwindow_qpa.h"
-
-#include <QtGui/qwindowsysteminterface_qpa.h>
-#include <QtGui/qwidget.h>
-
-class QPlatformWindowPrivate
-{
- QWidget *tlw;
- QRect rect;
- Qt::WindowFlags flags;
- friend class QPlatformWindow;
-};
-
-/*!
- Constructs a platform window with the given top level widget.
-*/
-
-QPlatformWindow::QPlatformWindow(QWidget *tlw)
- : d_ptr(new QPlatformWindowPrivate)
-{
- Q_D(QPlatformWindow);
- d->tlw = tlw;
- tlw->setPlatformWindow(this);
-}
-
-/*!
- Virtual destructor does not delete its top level widget.
-*/
-QPlatformWindow::~QPlatformWindow()
-{
-}
-
-/*!
- Returnes the widget which belongs to the QPlatformWindow
-*/
-QWidget *QPlatformWindow::widget() const
-{
- Q_D(const QPlatformWindow);
- return d->tlw;
-}
-
-/*!
- This function is called by Qt whenever a window is moved or the window is resized. The resize
- can happen programatically(from ie. user application) or by the window manager. This means that
- there is no need to call this function specifically from the window manager callback, instead
- call QWindowSystemInterface::handleGeometryChange(QWidget *w, const QRect &newRect);
-*/
-void QPlatformWindow::setGeometry(const QRect &rect)
-{
- Q_D(QPlatformWindow);
- d->rect = rect;
-}
-
-/*!
- Returnes the current geometry of a window
-*/
-QRect QPlatformWindow::geometry() const
-{
- Q_D(const QPlatformWindow);
- return d->rect;
-}
-
-/*!
- Reimplemented in subclasses to show the surface
- if \a visible is \c true, and hide it if \a visible is \c false.
-*/
-void QPlatformWindow::setVisible(bool visible)
-{
- Q_UNUSED(visible);
-}
-/*!
- Requests setting the window flags of this surface
- to \a type. Returns the actual flags set.
-*/
-Qt::WindowFlags QPlatformWindow::setWindowFlags(Qt::WindowFlags flags)
-{
- Q_D(QPlatformWindow);
- d->flags = flags;
- return flags;
-}
-
-/*!
- Returns the effective window flags for this surface.
-*/
-Qt::WindowFlags QPlatformWindow::windowFlags() const
-{
- Q_D(const QPlatformWindow);
- return d->flags;
-}
-
-/*!
- Reimplement in subclasses to return a handle to the native window
-*/
-WId QPlatformWindow::winId() const { return WId(0); }
-
-/*!
- This function is called to enable native child widgets in QPA. It is common not to support this
- feature in Window systems, but can be faked. When this function is called all geometry of this
- platform window will be relative to the parent.
-*/
-//jl: It would be useful to have a property on the platform window which indicated if the sub-class
-// supported the setParent. If not, then geometry would be in screen coordinates.
-void QPlatformWindow::setParent(const QPlatformWindow *parent)
-{
- Q_UNUSED(parent);
- qWarning("This plugin does not support setParent!");
-}
-
-/*!
- Reimplement to set the window title to \a title
-*/
-void QPlatformWindow::setWindowTitle(const QString &) {}
-
-/*!
- Reimplement to be able to let Qt rais windows to the top of the desktop
-*/
-void QPlatformWindow::raise() { qWarning("This plugin does not support raise()"); }
-
-/*!
- Reimplement to be able to let Qt lower windows to the bottom of the desktop
-*/
-void QPlatformWindow::lower() { qWarning("This plugin does not support lower()"); }
-
-/*!
- Reimplement to be able to let Qt set the opacity level of a window
-*/
-void QPlatformWindow::setOpacity(qreal level)
-{
- Q_UNUSED(level);
- qWarning("This plugin does not support setting window opacity");
-}
-
-/*!
- Reimplement to let Qt be able to request activation/focus for a window
-
- Some window systems will probably not have callbacks for this functionality,
- and then calling QWindowSystemInterface::handleWindowActivated(QWidget *w)
- would be sufficient.
-
- If the window system has some event handling/callbacks then call
- QWindowSystemInterface::handleWindowActivated(QWidget *w) when the window system
- gives the notification.
-
- Default implementation calls QWindowSystem::handleWindowActivated(QWidget *w)
-*/
-void QPlatformWindow::requestActivateWindow()
-{
- QWindowSystemInterface::handleWindowActivated(widget());
-}
-
-/*!
- Reimplement to return the glContext associated with the window.
-*/
-QPlatformGLContext *QPlatformWindow::glContext() const
-{
- return 0;
-}
-
-/*!
- \class QPlatformWindow
- \since 4.8
- \internal
- \preliminary
- \ingroup qpa
-
- \brief The QPlatformWindow class provides an abstraction for top-level windows.
-
- The QPlatformWindow abstraction is used by QWidget for all its top level widgets. It is being
- created by calling the createPlatformWindow function in the loaded QPlatformIntegration
- instance.
-
- QPlatformWindow is used to signal to the windowing system, how Qt persieves its frame.
- However, it is not concerned with how Qt renders into the window it represents.
-
- Top level QWidgets(tlw) will always have a QPlatformWindow. However, it is not necessary for
- all tlw to have a QWindowSurface. This is the case for QGLWidget. And could be the case for
- widgets where some 3.party renders into it.
-
- The platform specific window handle can be retrieved by the winId function.
-
- QPlatformWindow is also the way QPA defines how native child windows should be supported
- through the setParent function.
-
- The only way to retrieve a QPlatformGLContext in QPA is by calling the glContext() function
- on QPlatformWindow.
-
- \sa QWindowSurface, QWidget
-*/
diff --git a/src/gui/kernel/qplatformwindow_qpa.h b/src/gui/kernel/qplatformwindow_qpa.h
deleted file mode 100644
index 41a4bac7e0..0000000000
--- a/src/gui/kernel/qplatformwindow_qpa.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QPLATFORMWINDOW_H
-#define QPLATFORMWINDOW_H
-
-
-#include <QtCore/qscopedpointer.h>
-#include <QtCore/qrect.h>
-#include <QtCore/qstring.h>
-#include <QtGui/qwindowdefs.h>
-
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QPlatformWindowPrivate;
-class QWidget;
-class QPlatformGLContext;
-
-class Q_GUI_EXPORT QPlatformWindow
-{
- Q_DECLARE_PRIVATE(QPlatformWindow)
-public:
- QPlatformWindow(QWidget *tlw);
- virtual ~QPlatformWindow();
-
- QWidget *widget() const;
- virtual void setGeometry(const QRect &rect);
- virtual QRect geometry() const;
-
- virtual void setVisible(bool visible);
- virtual Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags);
- virtual Qt::WindowFlags windowFlags() const;
- virtual WId winId() const;
- virtual void setParent(const QPlatformWindow *window);
-
- virtual void setWindowTitle(const QString &title);
- virtual void raise();
- virtual void lower();
-
- virtual void setOpacity(qreal level);
- virtual void requestActivateWindow();
-
- virtual QPlatformGLContext *glContext() const;
-protected:
- QScopedPointer<QPlatformWindowPrivate> d_ptr;
-private:
- Q_DISABLE_COPY(QPlatformWindow)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-#endif //QPLATFORMWINDOW_H
diff --git a/src/gui/kernel/qplatformwindowformat_qpa.cpp b/src/gui/kernel/qplatformwindowformat_qpa.cpp
deleted file mode 100644
index c165c8513a..0000000000
--- a/src/gui/kernel/qplatformwindowformat_qpa.cpp
+++ /dev/null
@@ -1,1008 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qplatformwindowformat_qpa.h"
-
-#include <QtCore/QDebug>
-
-Q_GLOBAL_STATIC(QPlatformWindowFormat, q_platformwindow_default_format);
-
-class QPlatformWindowFormatPrivate
-{
-public:
- QPlatformWindowFormatPrivate()
- : ref(1)
- , opts(QPlatformWindowFormat::DoubleBuffer | QPlatformWindowFormat::DepthBuffer
- | QPlatformWindowFormat::Rgba | QPlatformWindowFormat::DirectRendering
- | QPlatformWindowFormat::StencilBuffer | QPlatformWindowFormat::DeprecatedFunctions
- | QPlatformWindowFormat::HasWindowSurface)
- , depthSize(-1)
- , accumSize(-1)
- , stencilSize(-1)
- , redSize(-1)
- , greenSize(-1)
- , blueSize(-1)
- , alphaSize(-1)
- , numSamples(-1)
- , swapInterval(-1)
- , windowApi(QPlatformWindowFormat::Raster)
- , sharedContext(0)
- {
- }
-
- QPlatformWindowFormatPrivate(const QPlatformWindowFormatPrivate *other)
- : ref(1),
- opts(other->opts),
- depthSize(other->depthSize),
- accumSize(other->accumSize),
- stencilSize(other->stencilSize),
- redSize(other->redSize),
- greenSize(other->greenSize),
- blueSize(other->blueSize),
- alphaSize(other->alphaSize),
- numSamples(other->numSamples),
- swapInterval(other->swapInterval),
- windowApi(other->windowApi),
- sharedContext(other->sharedContext)
- {
- }
- QAtomicInt ref;
- QPlatformWindowFormat::FormatOptions opts;
- int depthSize;
- int accumSize;
- int stencilSize;
- int redSize;
- int greenSize;
- int blueSize;
- int alphaSize;
- int numSamples;
- int swapInterval;
- QPlatformWindowFormat::WindowApi windowApi;
- QPlatformGLContext *sharedContext;
-};
-
-/*!
- \class QPlatformWindowFormat
- \brief The QPlatformWindowFormat class specifies the display format of an OpenGL
- rendering context and if possible attributes of the corresponding QPlatformWindow.
-
- \ingroup painting
-
- QWidget has a setter and getter function for QPlatformWindowFormat. These functions can be used
- by the application programmer to signal what kind of format he wants to the window and glcontext
- should have. However, it is not always possible to fulfill these requirements. The application
- programmer should therefore check the resulting QPlatformWindowFormat from QPlatformGLContext
- to see the format that was actually created.
-
- A display format has several characteristics:
- \list
- \i \link setDoubleBuffer() Double or single buffering.\endlink
- \i \link setDepth() Depth buffer.\endlink
- \i \link setRgba() RGBA or color index mode.\endlink
- \i \link setAlpha() Alpha channel.\endlink
- \i \link setAccum() Accumulation buffer.\endlink
- \i \link setStencil() Stencil buffer.\endlink
- \i \link setStereo() Stereo buffers.\endlink
- \i \link setDirectRendering() Direct rendering.\endlink
- \i \link setOverlay() Presence of an overlay.\endlink
- \i \link setPlane() Plane of an overlay.\endlink
- \i \link setSampleBuffers() Multisample buffers.\endlink
- \endlist
-
- You can also specify preferred bit depths for the color buffer,
- depth buffer, alpha buffer, accumulation buffer and the stencil
- buffer with the functions: setRedBufferSize(), setGreenBufferSize(),
- setBlueBufferSize(), setDepthBufferSize(), setAlphaBufferSize(),
- setAccumBufferSize() and setStencilBufferSize().
-
- Note that even if you specify that you prefer a 32 bit depth
- buffer (e.g. with setDepthBufferSize(32)), the format that is
- chosen may not have a 32 bit depth buffer, even if there is a
- format available with a 32 bit depth buffer. The main reason for
- this is how the system dependant picking algorithms work on the
- different platforms, and some format options may have higher
- precedence than others.
-
- You create and tell a QPlatformWindowFormat object what rendering options you
- want from an OpenGL rendering context.
-
- OpenGL drivers or accelerated hardware may or may not support
- advanced features such as alpha channel or stereographic viewing.
- If you request some features that the driver/hardware does not
- provide when you create a QGLWidget, you will get a rendering
- context with the nearest subset of features.
-
- There are different ways to define the display characteristics of
- a rendering context. One is to create a QPlatformWindowFormat and make it the
- default for the entire application:
- \snippet doc/src/snippets/code/src_opengl_qgl.cpp 0
-
- Or you can specify the desired format when creating an object of
- your QGLWidget subclass:
- \snippet doc/src/snippets/code/src_opengl_qgl.cpp 1
-
- After the widget has been created, you can find out which of the
- requested features the system was able to provide:
- \snippet doc/src/snippets/code/src_opengl_qgl.cpp 2
-
- \legalese
- OpenGL is a trademark of Silicon Graphics, Inc. in the
- United States and other countries.
- \endlegalese
-
- \sa QPlatformContext, QWidget
-*/
-
-/*!
- Constructs a QPlatformWindowFormat object with the following default settings:
- \list
- \i \link setDoubleBuffer() Double buffer:\endlink Enabled.
- \i \link setDepth() Depth buffer:\endlink Enabled.
- \i \link setRgba() RGBA:\endlink Enabled (i.e., color index disabled).
- \i \link setAlpha() Alpha channel:\endlink Disabled.
- \i \link setAccum() Accumulator buffer:\endlink Disabled.
- \i \link setStencil() Stencil buffer:\endlink Enabled.
- \i \link setStereo() Stereo:\endlink Disabled.
- \i \link setDirectRendering() Direct rendering:\endlink Enabled.
- \i \link setOverlay() Overlay:\endlink Disabled.
- \i \link setPlane() Plane:\endlink 0 (i.e., normal plane).
- \i \link setSampleBuffers() Multisample buffers:\endlink Disabled.
- \endlist
-*/
-
-QPlatformWindowFormat::QPlatformWindowFormat()
-{
- d = new QPlatformWindowFormatPrivate;
-}
-
-
-/*!
- Creates a QPlatformWindowFormat object that is a copy of the current
- defaultFormat().
-
- If \a options is not 0, the default format is modified by the
- specified format options. The \a options parameter should be
- QGL::FormatOption values OR'ed together.
-
- This constructor makes it easy to specify a certain desired format
- in classes derived from QGLWidget, for example:
- \snippet doc/src/snippets/code/src_opengl_qgl.cpp 3
-
- Note that there are QGL::FormatOption values to turn format settings
- both on and off, e.g. QGL::DepthBuffer and QGL::NoDepthBuffer,
- QGL::DirectRendering and QGL::IndirectRendering, etc.
-
- The \a plane parameter defaults to 0 and is the plane which this
- format should be associated with. Not all OpenGL implementations
- supports overlay/underlay rendering planes.
-
- \sa defaultFormat(), setOption(), setPlane()
-*/
-
-QPlatformWindowFormat::QPlatformWindowFormat(QPlatformWindowFormat::FormatOptions options)
-{
- d = new QPlatformWindowFormatPrivate;
- QPlatformWindowFormat::FormatOptions newOpts = options;
- d->opts = defaultFormat().d->opts;
- d->opts |= (newOpts & 0xffff);
- d->opts &= ~(newOpts >> 16);
-}
-
-/*!
- \internal
-*/
-void QPlatformWindowFormat::detach()
-{
- if (d->ref != 1) {
- QPlatformWindowFormatPrivate *newd = new QPlatformWindowFormatPrivate(d);
- if (!d->ref.deref())
- delete d;
- d = newd;
- }
-}
-
-/*!
- Constructs a copy of \a other.
-*/
-
-QPlatformWindowFormat::QPlatformWindowFormat(const QPlatformWindowFormat &other)
-{
- d = other.d;
- d->ref.ref();
-}
-
-/*!
- Assigns \a other to this object.
-*/
-
-QPlatformWindowFormat &QPlatformWindowFormat::operator=(const QPlatformWindowFormat &other)
-{
- if (d != other.d) {
- other.d->ref.ref();
- if (!d->ref.deref())
- delete d;
- d = other.d;
- }
- return *this;
-}
-
-/*!
- Destroys the QPlatformWindowFormat.
-*/
-QPlatformWindowFormat::~QPlatformWindowFormat()
-{
- if (!d->ref.deref())
- delete d;
-}
-
-/*!
- \fn bool QPlatformWindowFormat::doubleBuffer() const
-
- Returns true if double buffering is enabled; otherwise returns
- false. Double buffering is enabled by default.
-
- \sa setDoubleBuffer()
-*/
-
-/*!
- If \a enable is true sets double buffering; otherwise sets single
- buffering.
-
- Double buffering is enabled by default.
-
- Double buffering is a technique where graphics are rendered on an
- off-screen buffer and not directly to the screen. When the drawing
- has been completed, the program calls a swapBuffers() function to
- exchange the screen contents with the buffer. The result is
- flicker-free drawing and often better performance.
-
- \sa doubleBuffer(), QGLContext::swapBuffers(),
- QGLWidget::swapBuffers()
-*/
-
-void QPlatformWindowFormat::setDoubleBuffer(bool enable)
-{
- setOption(enable ? QPlatformWindowFormat::DoubleBuffer : QPlatformWindowFormat::SingleBuffer);
-}
-
-
-/*!
- \fn bool QPlatformWindowFormat::depth() const
-
- Returns true if the depth buffer is enabled; otherwise returns
- false. The depth buffer is enabled by default.
-
- \sa setDepth(), setDepthBufferSize()
-*/
-
-/*!
- If \a enable is true enables the depth buffer; otherwise disables
- the depth buffer.
-
- The depth buffer is enabled by default.
-
- The purpose of a depth buffer (or Z-buffering) is to remove hidden
- surfaces. Pixels are assigned Z values based on the distance to
- the viewer. A pixel with a high Z value is closer to the viewer
- than a pixel with a low Z value. This information is used to
- decide whether to draw a pixel or not.
-
- \sa depth(), setDepthBufferSize()
-*/
-
-void QPlatformWindowFormat::setDepth(bool enable)
-{
- setOption(enable ? QPlatformWindowFormat::DepthBuffer : QPlatformWindowFormat::NoDepthBuffer);
-}
-
-
-/*!
- \fn bool QPlatformWindowFormat::rgba() const
-
- Returns true if RGBA color mode is set. Returns false if color
- index mode is set. The default color mode is RGBA.
-
- \sa setRgba()
-*/
-
-/*!
- If \a enable is true sets RGBA mode. If \a enable is false sets
- color index mode.
-
- The default color mode is RGBA.
-
- RGBA is the preferred mode for most OpenGL applications. In RGBA
- color mode you specify colors as red + green + blue + alpha
- quadruplets.
-
- In color index mode you specify an index into a color lookup
- table.
-
- \sa rgba()
-*/
-
-void QPlatformWindowFormat::setRgba(bool enable)
-{
- setOption(enable ? QPlatformWindowFormat::Rgba : QPlatformWindowFormat::ColorIndex);
-}
-
-
-/*!
- \fn bool QPlatformWindowFormat::alpha() const
-
- Returns true if the alpha buffer in the framebuffer is enabled;
- otherwise returns false. The alpha buffer is disabled by default.
-
- \sa setAlpha(), setAlphaBufferSize()
-*/
-
-/*!
- If \a enable is true enables the alpha buffer; otherwise disables
- the alpha buffer.
-
- The alpha buffer is disabled by default.
-
- The alpha buffer is typically used for implementing transparency
- or translucency. The A in RGBA specifies the transparency of a
- pixel.
-
- \sa alpha(), setAlphaBufferSize()
-*/
-
-void QPlatformWindowFormat::setAlpha(bool enable)
-{
- setOption(enable ? QPlatformWindowFormat::AlphaChannel : QPlatformWindowFormat::NoAlphaChannel);
-}
-
-
-/*!
- \fn bool QPlatformWindowFormat::accum() const
-
- Returns true if the accumulation buffer is enabled; otherwise
- returns false. The accumulation buffer is disabled by default.
-
- \sa setAccum(), setAccumBufferSize()
-*/
-
-/*!
- If \a enable is true enables the accumulation buffer; otherwise
- disables the accumulation buffer.
-
- The accumulation buffer is disabled by default.
-
- The accumulation buffer is used to create blur effects and
- multiple exposures.
-
- \sa accum(), setAccumBufferSize()
-*/
-
-void QPlatformWindowFormat::setAccum(bool enable)
-{
- setOption(enable ? QPlatformWindowFormat::AccumBuffer : QPlatformWindowFormat::NoAccumBuffer);
-}
-
-
-/*!
- \fn bool QPlatformWindowFormat::stencil() const
-
- Returns true if the stencil buffer is enabled; otherwise returns
- false. The stencil buffer is enabled by default.
-
- \sa setStencil(), setStencilBufferSize()
-*/
-
-/*!
- If \a enable is true enables the stencil buffer; otherwise
- disables the stencil buffer.
-
- The stencil buffer is enabled by default.
-
- The stencil buffer masks certain parts of the drawing area so that
- masked parts are not drawn on.
-
- \sa stencil(), setStencilBufferSize()
-*/
-
-void QPlatformWindowFormat::setStencil(bool enable)
-{
- setOption(enable ? QPlatformWindowFormat::StencilBuffer: QPlatformWindowFormat::NoStencilBuffer);
-}
-
-
-/*!
- \fn bool QPlatformWindowFormat::stereo() const
-
- Returns true if stereo buffering is enabled; otherwise returns
- false. Stereo buffering is disabled by default.
-
- \sa setStereo()
-*/
-
-/*!
- If \a enable is true enables stereo buffering; otherwise disables
- stereo buffering.
-
- Stereo buffering is disabled by default.
-
- Stereo buffering provides extra color buffers to generate left-eye
- and right-eye images.
-
- \sa stereo()
-*/
-
-void QPlatformWindowFormat::setStereo(bool enable)
-{
- setOption(enable ? QPlatformWindowFormat::StereoBuffers : QPlatformWindowFormat::NoStereoBuffers);
-}
-
-
-/*!
- \fn bool QPlatformWindowFormat::directRendering() const
-
- Returns true if direct rendering is enabled; otherwise returns
- false.
-
- Direct rendering is enabled by default.
-
- \sa setDirectRendering()
-*/
-
-/*!
- If \a enable is true enables direct rendering; otherwise disables
- direct rendering.
-
- Direct rendering is enabled by default.
-
- Enabling this option will make OpenGL bypass the underlying window
- system and render directly from hardware to the screen, if this is
- supported by the system.
-
- \sa directRendering()
-*/
-
-void QPlatformWindowFormat::setDirectRendering(bool enable)
-{
- setOption(enable ? QPlatformWindowFormat::DirectRendering : QPlatformWindowFormat::IndirectRendering);
-}
-
-/*!
- \fn bool QPlatformWindowFormat::sampleBuffers() const
-
- Returns true if multisample buffer support is enabled; otherwise
- returns false.
-
- The multisample buffer is disabled by default.
-
- \sa setSampleBuffers()
-*/
-
-/*!
- If \a enable is true, a GL context with multisample buffer support
- is picked; otherwise ignored.
-
- \sa sampleBuffers(), setSamples(), samples()
-*/
-void QPlatformWindowFormat::setSampleBuffers(bool enable)
-{
- setOption(enable ? QPlatformWindowFormat::SampleBuffers : QPlatformWindowFormat::NoSampleBuffers);
-}
-
-/*!
- Returns the number of samples per pixel when multisampling is
- enabled. By default, the highest number of samples that is
- available is used.
-
- \sa setSampleBuffers(), sampleBuffers(), setSamples()
-*/
-int QPlatformWindowFormat::samples() const
-{
- return d->numSamples;
-}
-
-/*!
- Set the preferred number of samples per pixel when multisampling
- is enabled to \a numSamples. By default, the highest number of
- samples available is used.
-
- \sa setSampleBuffers(), sampleBuffers(), samples()
-*/
-void QPlatformWindowFormat::setSamples(int numSamples)
-{
- detach();
- if (numSamples < 0) {
- qWarning("QPlatformWindowFormat::setSamples: Cannot have negative number of samples per pixel %d", numSamples);
- return;
- }
- d->numSamples = numSamples;
- setSampleBuffers(numSamples > 0);
-}
-
-/*!
- \since 4.2
-
- Set the preferred swap interval. This can be used to sync the GL
- drawing into a system window to the vertical refresh of the screen.
- Setting an \a interval value of 0 will turn the vertical refresh syncing
- off, any value higher than 0 will turn the vertical syncing on.
-
- Under Windows and under X11, where the \c{WGL_EXT_swap_control}
- and \c{GLX_SGI_video_sync} extensions are used, the \a interval
- parameter can be used to set the minimum number of video frames
- that are displayed before a buffer swap will occur. In effect,
- setting the \a interval to 10, means there will be 10 vertical
- retraces between every buffer swap.
-
- Under Windows the \c{WGL_EXT_swap_control} extension has to be present,
- and under X11 the \c{GLX_SGI_video_sync} extension has to be present.
-*/
-void QPlatformWindowFormat::setSwapInterval(int interval)
-{
- detach();
- d->swapInterval = interval;
-}
-
-/*!
- \since 4.2
-
- Returns the currently set swap interval. -1 is returned if setting
- the swap interval isn't supported in the system GL implementation.
-*/
-int QPlatformWindowFormat::swapInterval() const
-{
- return d->swapInterval;
-}
-
-void QPlatformWindowFormat::setWindowApi(QPlatformWindowFormat::WindowApi api)
-{
- detach();
- d->windowApi = api;
-}
-
-QPlatformWindowFormat::WindowApi QPlatformWindowFormat::windowApi() const
-{
- return d->windowApi;
-}
-
-void QPlatformWindowFormat::setSharedContext(QPlatformGLContext *context)
-{
- d->sharedContext = context;
-}
-
-QPlatformGLContext *QPlatformWindowFormat::sharedGLContext() const
-{
- return d->sharedContext;
-}
-
-/*!
- \fn bool QPlatformWindowFormat::hasWindowSurface() const
-
- Returns true if the corresponding widget has an instance of QWindowSurface.
-
- Otherwise returns false.
-
- WindowSurface is enabled by default.
-
- \sa setOverlay()
-*/
-
-/*!
- If \a enable is true a top level QWidget will create a QWindowSurface at creation;
-
- otherwise the QWidget will only have a QPlatformWindow.
-
- This is useful for ie. QGLWidget where the QPlatformGLContext controls the surface.
-
- \sa hasOverlay()
-*/
-
-void QPlatformWindowFormat::setWindowSurface(bool enable)
-{
- setOption(enable ? QPlatformWindowFormat::HasWindowSurface : QPlatformWindowFormat::NoWindowSurface);
-}
-
-/*!
- Sets the format option to \a opt.
-
- \sa testOption()
-*/
-
-void QPlatformWindowFormat::setOption(QPlatformWindowFormat::FormatOptions opt)
-{
- detach();
- if (opt & 0xffff)
- d->opts |= opt;
- else
- d->opts &= ~(opt >> 16);
-}
-
-
-
-/*!
- Returns true if format option \a opt is set; otherwise returns false.
-
- \sa setOption()
-*/
-
-bool QPlatformWindowFormat::testOption(QPlatformWindowFormat::FormatOptions opt) const
-{
- if (opt & 0xffff)
- return (d->opts & opt) != 0;
- else
- return (d->opts & (opt >> 16)) == 0;
-}
-
-/*!
- Set the minimum depth buffer size to \a size.
-
- \sa depthBufferSize(), setDepth(), depth()
-*/
-void QPlatformWindowFormat::setDepthBufferSize(int size)
-{
- detach();
- if (size < 0) {
- qWarning("QPlatformWindowFormat::setDepthBufferSize: Cannot set negative depth buffer size %d", size);
- return;
- }
- d->depthSize = size;
- setDepth(size > 0);
-}
-
-/*!
- Returns the depth buffer size.
-
- \sa depth(), setDepth(), setDepthBufferSize()
-*/
-int QPlatformWindowFormat::depthBufferSize() const
-{
- return d->depthSize;
-}
-
-/*!
- \since 4.2
-
- Set the preferred red buffer size to \a size.
-
- \sa setGreenBufferSize(), setBlueBufferSize(), setAlphaBufferSize()
-*/
-void QPlatformWindowFormat::setRedBufferSize(int size)
-{
- detach();
- if (size < 0) {
- qWarning("QPlatformWindowFormat::setRedBufferSize: Cannot set negative red buffer size %d", size);
- return;
- }
- d->redSize = size;
-}
-
-/*!
- \since 4.2
-
- Returns the red buffer size.
-
- \sa setRedBufferSize()
-*/
-int QPlatformWindowFormat::redBufferSize() const
-{
- return d->redSize;
-}
-
-/*!
- \since 4.2
-
- Set the preferred green buffer size to \a size.
-
- \sa setRedBufferSize(), setBlueBufferSize(), setAlphaBufferSize()
-*/
-void QPlatformWindowFormat::setGreenBufferSize(int size)
-{
- detach();
- if (size < 0) {
- qWarning("QPlatformWindowFormat::setGreenBufferSize: Cannot set negative green buffer size %d", size);
- return;
- }
- d->greenSize = size;
-}
-
-/*!
- \since 4.2
-
- Returns the green buffer size.
-
- \sa setGreenBufferSize()
-*/
-int QPlatformWindowFormat::greenBufferSize() const
-{
- return d->greenSize;
-}
-
-/*!
- \since 4.2
-
- Set the preferred blue buffer size to \a size.
-
- \sa setRedBufferSize(), setGreenBufferSize(), setAlphaBufferSize()
-*/
-void QPlatformWindowFormat::setBlueBufferSize(int size)
-{
- detach();
- if (size < 0) {
- qWarning("QPlatformWindowFormat::setBlueBufferSize: Cannot set negative blue buffer size %d", size);
- return;
- }
- d->blueSize = size;
-}
-
-/*!
- \since 4.2
-
- Returns the blue buffer size.
-
- \sa setBlueBufferSize()
-*/
-int QPlatformWindowFormat::blueBufferSize() const
-{
- return d->blueSize;
-}
-
-/*!
- Set the preferred alpha buffer size to \a size.
- This function implicitly enables the alpha channel.
-
- \sa setRedBufferSize(), setGreenBufferSize(), alphaBufferSize()
-*/
-void QPlatformWindowFormat::setAlphaBufferSize(int size)
-{
- detach();
- if (size < 0) {
- qWarning("QPlatformWindowFormat::setAlphaBufferSize: Cannot set negative alpha buffer size %d", size);
- return;
- }
- d->alphaSize = size;
- setAlpha(size > 0);
-}
-
-/*!
- Returns the alpha buffer size.
-
- \sa alpha(), setAlpha(), setAlphaBufferSize()
-*/
-int QPlatformWindowFormat::alphaBufferSize() const
-{
- return d->alphaSize;
-}
-
-/*!
- Set the preferred accumulation buffer size, where \a size is the
- bit depth for each RGBA component.
-
- \sa accum(), setAccum(), accumBufferSize()
-*/
-void QPlatformWindowFormat::setAccumBufferSize(int size)
-{
- detach();
- if (size < 0) {
- qWarning("QPlatformWindowFormat::setAccumBufferSize: Cannot set negative accumulate buffer size %d", size);
- return;
- }
- d->accumSize = size;
- setAccum(size > 0);
-}
-
-/*!
- Returns the accumulation buffer size.
-
- \sa setAccumBufferSize(), accum(), setAccum()
-*/
-int QPlatformWindowFormat::accumBufferSize() const
-{
- return d->accumSize;
-}
-
-/*!
- Set the preferred stencil buffer size to \a size.
-
- \sa stencilBufferSize(), setStencil(), stencil()
-*/
-void QPlatformWindowFormat::setStencilBufferSize(int size)
-{
- detach();
- if (size < 0) {
- qWarning("QPlatformWindowFormat::setStencilBufferSize: Cannot set negative stencil buffer size %d", size);
- return;
- }
- d->stencilSize = size;
- setStencil(size > 0);
-}
-
-/*!
- Returns the stencil buffer size.
-
- \sa stencil(), setStencil(), setStencilBufferSize()
-*/
-int QPlatformWindowFormat::stencilBufferSize() const
-{
- return d->stencilSize;
-}
-
-/*!
- Returns the default QPlatformWindowFormat for the application. All QGLWidget
- objects that are created use this format unless another format is
- specified, e.g. when they are constructed.
-
- If no special default format has been set using
- setDefaultFormat(), the default format is the same as that created
- with QPlatformWindowFormat().
-
- \sa setDefaultFormat()
-*/
-
-QPlatformWindowFormat QPlatformWindowFormat::defaultFormat()
-{
- return *q_platformwindow_default_format();
-}
-
-/*!
- Sets a new default QPlatformWindowFormat for the application to \a f. For
- example, to set single buffering as the default instead of double
- buffering, your main() might contain code like this:
- \snippet doc/src/snippets/code/src_opengl_qgl.cpp 4
-
- \sa defaultFormat()
-*/
-
-void QPlatformWindowFormat::setDefaultFormat(const QPlatformWindowFormat &f)
-{
- *q_platformwindow_default_format() = f;
-}
-
-
-/*!
- Returns the default QPlatformWindowFormat for overlay contexts.
-
- The default overlay format is:
- \list
- \i \link setDoubleBuffer() Double buffer:\endlink Disabled.
- \i \link setDepth() Depth buffer:\endlink Disabled.
- \i \link setRgba() RGBA:\endlink Disabled (i.e., color index enabled).
- \i \link setAlpha() Alpha channel:\endlink Disabled.
- \i \link setAccum() Accumulator buffer:\endlink Disabled.
- \i \link setStencil() Stencil buffer:\endlink Disabled.
- \i \link setStereo() Stereo:\endlink Disabled.
- \i \link setDirectRendering() Direct rendering:\endlink Enabled.
- \i \link setOverlay() Overlay:\endlink Disabled.
- \i \link setSampleBuffers() Multisample buffers:\endlink Disabled.
- \i \link setPlane() Plane:\endlink 1 (i.e., first overlay plane).
- \endlist
-
- \sa setDefaultFormat()
-*/
-
-//QPlatformWindowFormat QPlatformWindowFormat::defaultOverlayFormat()
-//{
-// return *defaultOverlayFormatInstance();
-//}
-
-///*!
-// Sets a new default QPlatformWindowFormat for overlay contexts to \a f. This
-// format is used whenever a QGLWidget is created with a format that
-// hasOverlay() enabled.
-
-// For example, to get a double buffered overlay context (if
-// available), use code like this:
-
-// \snippet doc/src/snippets/code/src_opengl_qgl.cpp 5
-
-// As usual, you can find out after widget creation whether the
-// underlying OpenGL system was able to provide the requested
-// specification:
-
-// \snippet doc/src/snippets/code/src_opengl_qgl.cpp 6
-
-// \sa defaultOverlayFormat()
-//*/
-
-//void QPlatformWindowFormat::setDefaultOverlayFormat(const QPlatformWindowFormat &f)
-//{
-// QPlatformWindowFormat *defaultFormat = defaultOverlayFormatInstance();
-// *defaultFormat = f;
-// // Make sure the user doesn't request that the overlays themselves
-// // have overlays, since it is unlikely that the system supports
-// // infinitely many planes...
-// defaultFormat->setOverlay(false);
-//}
-
-
-/*!
- Returns true if all the options of the two QPlatformWindowFormat objects
- \a a and \a b are equal; otherwise returns false.
-
- \relates QPlatformWindowFormat
-*/
-
-bool operator==(const QPlatformWindowFormat& a, const QPlatformWindowFormat& b)
-{
- return (a.d == b.d) || ((int) a.d->opts == (int) b.d->opts
- && a.d->alphaSize == b.d->alphaSize
- && a.d->accumSize == b.d->accumSize
- && a.d->stencilSize == b.d->stencilSize
- && a.d->depthSize == b.d->depthSize
- && a.d->redSize == b.d->redSize
- && a.d->greenSize == b.d->greenSize
- && a.d->blueSize == b.d->blueSize
- && a.d->numSamples == b.d->numSamples
- && a.d->swapInterval == b.d->swapInterval
- && a.d->windowApi == b.d->windowApi);
-}
-
-
-/*!
- Returns false if all the options of the two QPlatformWindowFormat objects
- \a a and \a b are equal; otherwise returns true.
-
- \relates QPlatformWindowFormat
-*/
-
-bool operator!=(const QPlatformWindowFormat& a, const QPlatformWindowFormat& b)
-{
- return !(a == b);
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-QDebug operator<<(QDebug dbg, const QPlatformWindowFormat &f)
-{
- const QPlatformWindowFormatPrivate * const d = f.d;
-
- dbg.nospace() << "QGLFormat("
- << "options " << d->opts
- << ", depthBufferSize " << d->depthSize
- << ", accumBufferSize " << d->accumSize
- << ", stencilBufferSize " << d->stencilSize
- << ", redBufferSize " << d->redSize
- << ", greenBufferSize " << d->greenSize
- << ", blueBufferSize " << d->blueSize
- << ", alphaBufferSize " << d->alphaSize
- << ", samples " << d->numSamples
- << ", swapInterval " << d->swapInterval
- << ')';
-
- return dbg.space();
-}
-#endif
diff --git a/src/gui/kernel/qplatformwindowformat_qpa.h b/src/gui/kernel/qplatformwindowformat_qpa.h
deleted file mode 100644
index ba21ba4626..0000000000
--- a/src/gui/kernel/qplatformwindowformat_qpa.h
+++ /dev/null
@@ -1,234 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QPLATFORMWINDOWFORMAT_QPA_H
-#define QPLATFORMWINDOWFORMAT_QPA_H
-
-#include <QtGui/QPlatformWindow>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QPlatformWindowFormatPrivate;
-
-class Q_GUI_EXPORT QPlatformWindowFormat
-{
-public:
- enum FormatOption {
- DoubleBuffer = 0x0001,
- DepthBuffer = 0x0002,
- Rgba = 0x0004,
- AlphaChannel = 0x0008,
- AccumBuffer = 0x0010,
- StencilBuffer = 0x0020,
- StereoBuffers = 0x0040,
- DirectRendering = 0x0080,
- HasOverlay = 0x0100,
- SampleBuffers = 0x0200,
- DeprecatedFunctions = 0x0400,
- HasWindowSurface = 0x0800,
- SingleBuffer = DoubleBuffer << 16,
- NoDepthBuffer = DepthBuffer << 16,
- ColorIndex = Rgba << 16,
- NoAlphaChannel = AlphaChannel << 16,
- NoAccumBuffer = AccumBuffer << 16,
- NoStencilBuffer = StencilBuffer << 16,
- NoStereoBuffers = StereoBuffers << 16,
- IndirectRendering = DirectRendering << 16,
- NoOverlay = HasOverlay << 16,
- NoSampleBuffers = SampleBuffers << 16,
- NoDeprecatedFunctions = DeprecatedFunctions << 16,
- NoWindowSurface = HasWindowSurface << 16
-
- };
- Q_DECLARE_FLAGS(FormatOptions, FormatOption)
-
- enum WindowApi {
- Raster,
- OpenGL,
- OpenVG
- };
-
- QPlatformWindowFormat();
- QPlatformWindowFormat(FormatOptions options);
- QPlatformWindowFormat(const QPlatformWindowFormat &other);
- QPlatformWindowFormat &operator=(const QPlatformWindowFormat &other);
- ~QPlatformWindowFormat();
-
- void setDepthBufferSize(int size);
- int depthBufferSize() const;
-
- void setAccumBufferSize(int size);
- int accumBufferSize() const;
-
- void setRedBufferSize(int size);
- int redBufferSize() const;
-
- void setGreenBufferSize(int size);
- int greenBufferSize() const;
-
- void setBlueBufferSize(int size);
- int blueBufferSize() const;
-
- void setAlphaBufferSize(int size);
- int alphaBufferSize() const;
-
- void setStencilBufferSize(int size);
- int stencilBufferSize() const;
-
- void setSampleBuffers(bool enable);
- bool sampleBuffers() const;
-
- void setSamples(int numSamples);
- int samples() const;
-
- void setSwapInterval(int interval);
- int swapInterval() const;
-
- void setWindowApi(QPlatformWindowFormat::WindowApi api);
- WindowApi windowApi() const;
-
- void setSharedContext(QPlatformGLContext *context);
- QPlatformGLContext *sharedGLContext() const;
-
- bool doubleBuffer() const;
- void setDoubleBuffer(bool enable);
- bool depth() const;
- void setDepth(bool enable);
- bool rgba() const;
- void setRgba(bool enable);
- bool alpha() const;
- void setAlpha(bool enable);
- bool accum() const;
- void setAccum(bool enable);
- bool stencil() const;
- void setStencil(bool enable);
- bool stereo() const;
- void setStereo(bool enable);
- bool directRendering() const;
- void setDirectRendering(bool enable);
- bool hasWindowSurface() const;
- void setWindowSurface(bool enable);
-
- void setOption(QPlatformWindowFormat::FormatOptions opt);
- bool testOption(QPlatformWindowFormat::FormatOptions opt) const;
-
- static QPlatformWindowFormat defaultFormat();
- static void setDefaultFormat(const QPlatformWindowFormat& f);
-
-private:
- QPlatformWindowFormatPrivate *d;
-
- void detach();
-
- friend Q_GUI_EXPORT bool operator==(const QPlatformWindowFormat&, const QPlatformWindowFormat&);
- friend Q_GUI_EXPORT bool operator!=(const QPlatformWindowFormat&, const QPlatformWindowFormat&);
-#ifndef QT_NO_DEBUG_STREAM
- friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QPlatformWindowFormat &);
-#endif
-};
-
-Q_GUI_EXPORT bool operator==(const QPlatformWindowFormat&, const QPlatformWindowFormat&);
-Q_GUI_EXPORT bool operator!=(const QPlatformWindowFormat&, const QPlatformWindowFormat&);
-
-#ifndef QT_NO_DEBUG_STREAM
-Q_OPENGL_EXPORT QDebug operator<<(QDebug, const QPlatformWindowFormat &);
-#endif
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QPlatformWindowFormat::FormatOptions)
-
-inline bool QPlatformWindowFormat::doubleBuffer() const
-{
- return testOption(QPlatformWindowFormat::DoubleBuffer);
-}
-
-inline bool QPlatformWindowFormat::depth() const
-{
- return testOption(QPlatformWindowFormat::DepthBuffer);
-}
-
-inline bool QPlatformWindowFormat::rgba() const
-{
- return testOption(QPlatformWindowFormat::Rgba);
-}
-
-inline bool QPlatformWindowFormat::alpha() const
-{
- return testOption(QPlatformWindowFormat::AlphaChannel);
-}
-
-inline bool QPlatformWindowFormat::accum() const
-{
- return testOption(QPlatformWindowFormat::AccumBuffer);
-}
-
-inline bool QPlatformWindowFormat::stencil() const
-{
- return testOption(QPlatformWindowFormat::StencilBuffer);
-}
-
-inline bool QPlatformWindowFormat::stereo() const
-{
- return testOption(QPlatformWindowFormat::StereoBuffers);
-}
-
-inline bool QPlatformWindowFormat::directRendering() const
-{
- return testOption(QPlatformWindowFormat::DirectRendering);
-}
-
-inline bool QPlatformWindowFormat::hasWindowSurface() const
-{
- return testOption(QPlatformWindowFormat::HasWindowSurface);
-}
-
-inline bool QPlatformWindowFormat::sampleBuffers() const
-{
- return testOption(QPlatformWindowFormat::SampleBuffers);
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif //QPLATFORMWINDOWFORMAT_QPA_H
diff --git a/src/gui/kernel/qsessionmanager.h b/src/gui/kernel/qsessionmanager.h
deleted file mode 100644
index bd851b87e9..0000000000
--- a/src/gui/kernel/qsessionmanager.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSESSIONMANAGER_H
-#define QSESSIONMANAGER_H
-
-#include <QtCore/qobject.h>
-#include <QtGui/qwindowdefs.h>
-#include <QtCore/qstring.h>
-#include <QtCore/qstringlist.h>
-
-#ifndef QT_NO_SESSIONMANAGER
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QSessionManagerPrivate;
-
-class Q_GUI_EXPORT QSessionManager : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QSessionManager)
- QSessionManager(QApplication *app, QString &id, QString &key);
- ~QSessionManager();
-public:
- QString sessionId() const;
- QString sessionKey() const;
-#if defined(Q_WS_X11) || defined(Q_WS_MAC)
- void *handle() const;
-#endif
-
- bool allowsInteraction();
- bool allowsErrorInteraction();
- void release();
-
- void cancel();
-
- enum RestartHint {
- RestartIfRunning,
- RestartAnyway,
- RestartImmediately,
- RestartNever
- };
- void setRestartHint(RestartHint);
- RestartHint restartHint() const;
-
- void setRestartCommand(const QStringList&);
- QStringList restartCommand() const;
- void setDiscardCommand(const QStringList&);
- QStringList discardCommand() const;
-
- void setManagerProperty(const QString& name, const QString& value);
- void setManagerProperty(const QString& name, const QStringList& value);
-
- bool isPhase2() const;
- void requestPhase2();
-
-private:
- friend class QApplication;
- friend class QApplicationPrivate;
- friend class QBaseApplication;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_SESSIONMANAGER
-
-#endif // QSESSIONMANAGER_H
diff --git a/src/gui/kernel/qsessionmanager_qpa.cpp b/src/gui/kernel/qsessionmanager_qpa.cpp
deleted file mode 100644
index 68685b4fed..0000000000
--- a/src/gui/kernel/qsessionmanager_qpa.cpp
+++ /dev/null
@@ -1,174 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qsessionmanager.h>
-
-#include <private/qobject_p.h>
-#include <qapplication.h>
-
-#ifndef QT_NO_SESSIONMANAGER
-
-QT_BEGIN_NAMESPACE
-
-class QSessionManagerPrivate : public QObjectPrivate
-{
-public:
- QSessionManagerPrivate(QSessionManager *m, const QString &id,
- const QString &key);
-
- QStringList restartCommand;
- QStringList discardCommand;
- const QString sessionId;
- const QString sessionKey;
- QSessionManager::RestartHint restartHint;
-};
-
-QSessionManagerPrivate::QSessionManagerPrivate(QSessionManager*,
- const QString &id,
- const QString &key)
- : QObjectPrivate(), sessionId(id), sessionKey(key)
-{
-}
-
-QSessionManager::QSessionManager(QApplication *app, QString &id, QString &key)
- : QObject(*(new QSessionManagerPrivate(this, id, key)), app)
-{
- Q_D(QSessionManager);
- d->restartHint = RestartIfRunning;
-}
-
-QSessionManager::~QSessionManager()
-{
-}
-
-QString QSessionManager::sessionId() const
-{
- Q_D(const QSessionManager);
- return d->sessionId;
-}
-
-QString QSessionManager::sessionKey() const
-{
- Q_D(const QSessionManager);
- return d->sessionKey;
-}
-
-
-bool QSessionManager::allowsInteraction()
-{
- return false;
-}
-
-bool QSessionManager::allowsErrorInteraction()
-{
- return false;
-}
-
-void QSessionManager::release()
-{
-}
-
-void QSessionManager::cancel()
-{
-}
-
-void QSessionManager::setRestartHint(QSessionManager::RestartHint hint)
-{
- Q_D(QSessionManager);
- d->restartHint = hint;
-}
-
-QSessionManager::RestartHint QSessionManager::restartHint() const
-{
- Q_D(const QSessionManager);
- return d->restartHint;
-}
-
-void QSessionManager::setRestartCommand(const QStringList &command)
-{
- Q_D(QSessionManager);
- d->restartCommand = command;
-}
-
-QStringList QSessionManager::restartCommand() const
-{
- Q_D(const QSessionManager);
- return d->restartCommand;
-}
-
-void QSessionManager::setDiscardCommand(const QStringList &command)
-{
- Q_D(QSessionManager);
- d->discardCommand = command;
-}
-
-QStringList QSessionManager::discardCommand() const
-{
- Q_D(const QSessionManager);
- return d->discardCommand;
-}
-
-void QSessionManager::setManagerProperty(const QString &name,
- const QString &value)
-{
- Q_UNUSED(name);
- Q_UNUSED(value);
-}
-
-void QSessionManager::setManagerProperty(const QString &name,
- const QStringList &value)
-{
- Q_UNUSED(name);
- Q_UNUSED(value);
-}
-
-bool QSessionManager::isPhase2() const
-{
- return false;
-}
-
-void QSessionManager::requestPhase2()
-{
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_SESSIONMANAGER
diff --git a/src/gui/kernel/qsessionmanager_qws.cpp b/src/gui/kernel/qsessionmanager_qws.cpp
deleted file mode 100644
index e355d055ad..0000000000
--- a/src/gui/kernel/qsessionmanager_qws.cpp
+++ /dev/null
@@ -1,171 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qsessionmanager.h>
-
-#ifndef QT_NO_SESSIONMANAGER
-
-QT_BEGIN_NAMESPACE
-
-class QSessionManagerPrivate : public QObjectPrivate
-{
-public:
- QSessionManagerPrivate(QSessionManager *m, const QString &id,
- const QString &key);
-
- QStringList restartCommand;
- QStringList discardCommand;
- const QString sessionId;
- const QString sessionKey;
- QSessionManager::RestartHint restartHint;
-};
-
-QSessionManagerPrivate::QSessionManagerPrivate(QSessionManager*,
- const QString &id,
- const QString &key)
- : QObjectPrivate(), sessionId(id), sessionKey(key)
-{
-}
-
-QSessionManager::QSessionManager(QApplication *app, QString &id, QString &key)
- : QObject(*new QSessionManagerPrivate(this, id, key), app)
-{
- Q_D(QSessionManager);
- d->restartHint = RestartIfRunning;
-}
-
-QSessionManager::~QSessionManager()
-{
-}
-
-QString QSessionManager::sessionId() const
-{
- Q_D(const QSessionManager);
- return d->sessionId;
-}
-
-QString QSessionManager::sessionKey() const
-{
- Q_D(const QSessionManager);
- return d->sessionKey;
-}
-
-
-bool QSessionManager::allowsInteraction()
-{
- return false;
-}
-
-bool QSessionManager::allowsErrorInteraction()
-{
- return false;
-}
-
-void QSessionManager::release()
-{
-}
-
-void QSessionManager::cancel()
-{
-}
-
-void QSessionManager::setRestartHint(QSessionManager::RestartHint hint)
-{
- Q_D(QSessionManager);
- d->restartHint = hint;
-}
-
-QSessionManager::RestartHint QSessionManager::restartHint() const
-{
- Q_D(const QSessionManager);
- return d->restartHint;
-}
-
-void QSessionManager::setRestartCommand(const QStringList &command)
-{
- Q_D(QSessionManager);
- d->restartCommand = command;
-}
-
-QStringList QSessionManager::restartCommand() const
-{
- Q_D(const QSessionManager);
- return d->restartCommand;
-}
-
-void QSessionManager::setDiscardCommand(const QStringList &command)
-{
- Q_D(QSessionManager);
- d->discardCommand = command;
-}
-
-QStringList QSessionManager::discardCommand() const
-{
- Q_D(const QSessionManager);
- return d->discardCommand;
-}
-
-void QSessionManager::setManagerProperty(const QString &name,
- const QString &value)
-{
- Q_UNUSED(name);
- Q_UNUSED(value);
-}
-
-void QSessionManager::setManagerProperty(const QString &name,
- const QStringList &value)
-{
- Q_UNUSED(name);
- Q_UNUSED(value);
-}
-
-bool QSessionManager::isPhase2() const
-{
- return false;
-}
-
-void QSessionManager::requestPhase2()
-{
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_SESSIONMANAGER
diff --git a/src/gui/kernel/qshortcut.h b/src/gui/kernel/qshortcut.h
deleted file mode 100644
index f432d9ad97..0000000000
--- a/src/gui/kernel/qshortcut.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSHORTCUT_H
-#define QSHORTCUT_H
-
-#include <QtGui/qwidget.h>
-#include <QtGui/qkeysequence.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_SHORTCUT
-
-class QShortcutPrivate;
-class Q_GUI_EXPORT QShortcut : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QShortcut)
- Q_PROPERTY(QKeySequence key READ key WRITE setKey)
- Q_PROPERTY(QString whatsThis READ whatsThis WRITE setWhatsThis)
- Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
- Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat)
- Q_PROPERTY(Qt::ShortcutContext context READ context WRITE setContext)
-public:
- explicit QShortcut(QWidget *parent);
- QShortcut(const QKeySequence& key, QWidget *parent,
- const char *member = 0, const char *ambiguousMember = 0,
- Qt::ShortcutContext context = Qt::WindowShortcut);
- ~QShortcut();
-
- void setKey(const QKeySequence& key);
- QKeySequence key() const;
-
- void setEnabled(bool enable);
- bool isEnabled() const;
-
- void setContext(Qt::ShortcutContext context);
- Qt::ShortcutContext context();
-
- void setWhatsThis(const QString &text);
- QString whatsThis() const;
-
- void setAutoRepeat(bool on);
- bool autoRepeat() const;
-
- int id() const;
-
- inline QWidget *parentWidget() const
- { return static_cast<QWidget *>(QObject::parent()); }
-
-Q_SIGNALS:
- void activated();
- void activatedAmbiguously();
-
-protected:
- bool event(QEvent *e);
-};
-
-#endif // QT_NO_SHORTCUT
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSHORTCUT_H
diff --git a/src/gui/kernel/qshortcutmap.cpp b/src/gui/kernel/qshortcutmap.cpp
deleted file mode 100644
index 5e65e676d9..0000000000
--- a/src/gui/kernel/qshortcutmap.cpp
+++ /dev/null
@@ -1,897 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qshortcutmap_p.h"
-#include "private/qobject_p.h"
-#include "qkeysequence.h"
-#include "qgraphicsscene.h"
-#include "qgraphicsview.h"
-#include "qdebug.h"
-#include "qevent.h"
-#include "qwidget.h"
-#include "qapplication.h"
-#include "qvector.h"
-#include "qmenu.h"
-#include "qmenubar.h"
-#include "qshortcut.h"
-#include "qapplication_p.h"
-#include <private/qaction_p.h>
-#include <private/qkeymapper_p.h>
-#include <private/qwidget_p.h>
-
-#ifndef QT_NO_SHORTCUT
-
-QT_BEGIN_NAMESPACE
-
-// To enable verbose output uncomment below
-//#define DEBUG_QSHORTCUTMAP
-
-/* \internal
- Entry data for QShortcutMap
- Contains:
- Keysequence for entry
- Pointer to parent owning the sequence
-*/
-struct QShortcutEntry
-{
- QShortcutEntry()
- : keyseq(0), context(Qt::WindowShortcut), enabled(false), autorepeat(1), id(0), owner(0)
- {}
-
- QShortcutEntry(const QKeySequence &k)
- : keyseq(k), context(Qt::WindowShortcut), enabled(false), autorepeat(1), id(0), owner(0)
- {}
-
- QShortcutEntry(QObject *o, const QKeySequence &k, Qt::ShortcutContext c, int i)
- : keyseq(k), context(c), enabled(true), autorepeat(1), id(i), owner(o)
- {}
-
- QShortcutEntry(QObject *o, const QKeySequence &k, Qt::ShortcutContext c, int i, bool a)
- : keyseq(k), context(c), enabled(true), autorepeat(a), id(i), owner(o)
- {}
-
- bool operator<(const QShortcutEntry &f) const
- { return keyseq < f.keyseq; }
-
- QKeySequence keyseq;
- Qt::ShortcutContext context;
- bool enabled : 1;
- bool autorepeat : 1;
- signed int id;
- QObject *owner;
-};
-
-#if 0 //ndef QT_NO_DEBUG_STREAM
-/*! \internal
- QDebug operator<< for easy debug output of the shortcut entries.
-*/
-static QDebug &operator<<(QDebug &dbg, const QShortcutEntry *se) {
- if (!se)
- return dbg << "QShortcutEntry(0x0)";
- dbg.nospace()
- << "QShortcutEntry(" << se->keyseq
- << "), id(" << se->id << "), enabled(" << se->enabled << "), autorepeat(" << se->autorepeat
- << "), owner(" << se->owner << ')';
- return dbg.space();
-}
-#endif // QT_NO_DEBUGSTREAM
-
-/* \internal
- Private data for QShortcutMap
-*/
-class QShortcutMapPrivate
-{
- Q_DECLARE_PUBLIC(QShortcutMap)
-
-public:
- QShortcutMapPrivate(QShortcutMap* parent)
- : q_ptr(parent), currentId(0), ambigCount(0), currentState(QKeySequence::NoMatch)
- {
- identicals.reserve(10);
- currentSequences.reserve(10);
- }
- QShortcutMap *q_ptr; // Private's parent
-
- QList<QShortcutEntry> sequences; // All sequences!
-
- int currentId; // Global shortcut ID number
- int ambigCount; // Index of last enabled ambiguous dispatch
- QKeySequence::SequenceMatch currentState;
- QVector<QKeySequence> currentSequences; // Sequence for the current state
- QVector<QKeySequence> newEntries;
- QKeySequence prevSequence; // Sequence for the previous identical match
- QVector<const QShortcutEntry*> identicals; // Last identical matches
-};
-
-
-/*! \internal
- QShortcutMap constructor.
-*/
-QShortcutMap::QShortcutMap()
- : d_ptr(new QShortcutMapPrivate(this))
-{
- resetState();
-}
-
-/*! \internal
- QShortcutMap destructor.
-*/
-QShortcutMap::~QShortcutMap()
-{
-}
-
-/*! \internal
- Adds a shortcut to the global map.
- Returns the id of the newly added shortcut.
-*/
-int QShortcutMap::addShortcut(QObject *owner, const QKeySequence &key, Qt::ShortcutContext context)
-{
- Q_ASSERT_X(owner, "QShortcutMap::addShortcut", "All shortcuts need an owner");
- Q_ASSERT_X(!key.isEmpty(), "QShortcutMap::addShortcut", "Cannot add keyless shortcuts to map");
- Q_D(QShortcutMap);
-
- QShortcutEntry newEntry(owner, key, context, --(d->currentId), true);
- QList<QShortcutEntry>::iterator it = qUpperBound(d->sequences.begin(), d->sequences.end(), newEntry);
- d->sequences.insert(it, newEntry); // Insert sorted
-#if defined(DEBUG_QSHORTCUTMAP)
- qDebug().nospace()
- << "QShortcutMap::addShortcut(" << owner << ", "
- << key << ", " << context << ") = " << d->currentId;
-#endif
- return d->currentId;
-}
-
-/*! \internal
- Removes a shortcut from the global map.
- If \a owner is 0, all entries in the map with the key sequence specified
- is removed. If \a key is null, all sequences for \a owner is removed from
- the map. If \a id is 0, any identical \a key sequences owned by \a owner
- are removed.
- Returns the number of sequences removed from the map.
-*/
-
-int QShortcutMap::removeShortcut(int id, QObject *owner, const QKeySequence &key)
-{
- Q_D(QShortcutMap);
- int itemsRemoved = 0;
- bool allOwners = (owner == 0);
- bool allKeys = key.isEmpty();
- bool allIds = id == 0;
-
- // Special case, remove everything
- if (allOwners && allKeys && id == 0) {
- itemsRemoved = d->sequences.size();
- d->sequences.clear();
- return itemsRemoved;
- }
-
- int i = d->sequences.size()-1;
- while (i>=0)
- {
- const QShortcutEntry &entry = d->sequences.at(i);
- int entryId = entry.id;
- if ((allOwners || entry.owner == owner)
- && (allIds || entry.id == id)
- && (allKeys || entry.keyseq == key)) {
- d->sequences.removeAt(i);
- ++itemsRemoved;
- }
- if (id == entryId)
- return itemsRemoved;
- --i;
- }
-#if defined(DEBUG_QSHORTCUTMAP)
- qDebug().nospace()
- << "QShortcutMap::removeShortcut(" << id << ", " << owner << ", "
- << key << ") = " << itemsRemoved;
-#endif
- return itemsRemoved;
-}
-
-/*! \internal
- Changes the enable state of a shortcut to \a enable.
- If \a owner is 0, all entries in the map with the key sequence specified
- is removed. If \a key is null, all sequences for \a owner is removed from
- the map. If \a id is 0, any identical \a key sequences owned by \a owner
- are changed.
- Returns the number of sequences which are matched in the map.
-*/
-int QShortcutMap::setShortcutEnabled(bool enable, int id, QObject *owner, const QKeySequence &key)
-{
- Q_D(QShortcutMap);
- int itemsChanged = 0;
- bool allOwners = (owner == 0);
- bool allKeys = key.isEmpty();
- bool allIds = id == 0;
-
- int i = d->sequences.size()-1;
- while (i>=0)
- {
- QShortcutEntry entry = d->sequences.at(i);
- if ((allOwners || entry.owner == owner)
- && (allIds || entry.id == id)
- && (allKeys || entry.keyseq == key)) {
- d->sequences[i].enabled = enable;
- ++itemsChanged;
- }
- if (id == entry.id)
- return itemsChanged;
- --i;
- }
-#if defined(DEBUG_QSHORTCUTMAP)
- qDebug().nospace()
- << "QShortcutMap::setShortcutEnabled(" << enable << ", " << id << ", "
- << owner << ", " << key << ") = " << itemsChanged;
-#endif
- return itemsChanged;
-}
-
-/*! \internal
- Changes the auto repeat state of a shortcut to \a enable.
- If \a owner is 0, all entries in the map with the key sequence specified
- is removed. If \a key is null, all sequences for \a owner is removed from
- the map. If \a id is 0, any identical \a key sequences owned by \a owner
- are changed.
- Returns the number of sequences which are matched in the map.
-*/
-int QShortcutMap::setShortcutAutoRepeat(bool on, int id, QObject *owner, const QKeySequence &key)
-{
- Q_D(QShortcutMap);
- int itemsChanged = 0;
- bool allOwners = (owner == 0);
- bool allKeys = key.isEmpty();
- bool allIds = id == 0;
-
- int i = d->sequences.size()-1;
- while (i>=0)
- {
- QShortcutEntry entry = d->sequences.at(i);
- if ((allOwners || entry.owner == owner)
- && (allIds || entry.id == id)
- && (allKeys || entry.keyseq == key)) {
- d->sequences[i].autorepeat = on;
- ++itemsChanged;
- }
- if (id == entry.id)
- return itemsChanged;
- --i;
- }
-#if defined(DEBUG_QSHORTCUTMAP)
- qDebug().nospace()
- << "QShortcutMap::setShortcutAutoRepeat(" << on << ", " << id << ", "
- << owner << ", " << key << ") = " << itemsChanged;
-#endif
- return itemsChanged;
-}
-
-/*! \internal
- Resets the state of the statemachine to NoMatch
-*/
-void QShortcutMap::resetState()
-{
- Q_D(QShortcutMap);
- d->currentState = QKeySequence::NoMatch;
- clearSequence(d->currentSequences);
-}
-
-/*! \internal
- Returns the current state of the statemachine
-*/
-QKeySequence::SequenceMatch QShortcutMap::state()
-{
- Q_D(QShortcutMap);
- return d->currentState;
-}
-
-/*! \internal
- Uses ShortcutOverride event to see if any widgets want to override
- the event. If not, uses nextState(QKeyEvent) to check for a grabbed
- Shortcut, and dispatchEvent() is found an identical.
- \sa nextState dispatchEvent
-*/
-bool QShortcutMap::tryShortcutEvent(QObject *o, QKeyEvent *e)
-{
- Q_D(QShortcutMap);
-
- bool wasAccepted = e->isAccepted();
- bool wasSpontaneous = e->spont;
- if (d->currentState == QKeySequence::NoMatch) {
- ushort orgType = e->t;
- e->t = QEvent::ShortcutOverride;
- e->ignore();
- QApplication::sendEvent(o, e);
- e->t = orgType;
- e->spont = wasSpontaneous;
- if (e->isAccepted()) {
- if (!wasAccepted)
- e->ignore();
- return false;
- }
- }
-
- QKeySequence::SequenceMatch result = nextState(e);
- bool stateWasAccepted = e->isAccepted();
- if (wasAccepted)
- e->accept();
- else
- e->ignore();
-
- int identicalMatches = d->identicals.count();
-
- switch(result) {
- case QKeySequence::NoMatch:
- return stateWasAccepted;
- case QKeySequence::ExactMatch:
- resetState();
- dispatchEvent(e);
- default:
- break;
- }
- // If nextState is QKeySequence::ExactMatch && identicals.count == 0
- // we've only found disabled shortcuts
- return identicalMatches > 0 || result == QKeySequence::PartialMatch;
-}
-
-/*! \internal
- Returns the next state of the statemachine
- If return value is SequenceMatch::ExactMatch, then a call to matches()
- will return a QObjects* list of all matching objects for the last matching
- sequence.
-*/
-QKeySequence::SequenceMatch QShortcutMap::nextState(QKeyEvent *e)
-{
- Q_D(QShortcutMap);
- // Modifiers can NOT be shortcuts...
- if (e->key() >= Qt::Key_Shift &&
- e->key() <= Qt::Key_Alt)
- return d->currentState;
-
- QKeySequence::SequenceMatch result = QKeySequence::NoMatch;
-
- // We start fresh each time..
- d->identicals.resize(0);
-
- result = find(e);
- if (result == QKeySequence::NoMatch && e->modifiers() & Qt::ShiftModifier) {
- // If Shift + Key_Backtab, also try Shift + Qt::Key_Tab
- if (e->key() == Qt::Key_Backtab) {
- QKeyEvent pe = QKeyEvent(e->type(), Qt::Key_Tab, e->modifiers(), e->text());
- result = find(&pe);
- }
- }
-
- // Should we eat this key press?
- if (d->currentState == QKeySequence::PartialMatch
- || (d->currentState == QKeySequence::ExactMatch && d->identicals.count()))
- e->accept();
- // Does the new state require us to clean up?
- if (result == QKeySequence::NoMatch)
- clearSequence(d->currentSequences);
- d->currentState = result;
-
-#if defined(DEBUG_QSHORTCUTMAP)
- qDebug().nospace() << "QShortcutMap::nextState(" << e << ") = " << result;
-#endif
- return result;
-}
-
-
-/*! \internal
- Determines if an enabled shortcut has a matcing key sequence.
-*/
-bool QShortcutMap::hasShortcutForKeySequence(const QKeySequence &seq) const
-{
- Q_D(const QShortcutMap);
- QShortcutEntry entry(seq); // needed for searching
- QList<QShortcutEntry>::ConstIterator itEnd = d->sequences.constEnd();
- QList<QShortcutEntry>::ConstIterator it = qLowerBound(d->sequences.constBegin(), itEnd, entry);
-
- for (;it != itEnd; ++it) {
- if (matches(entry.keyseq, (*it).keyseq) == QKeySequence::ExactMatch && correctContext(*it) && (*it).enabled) {
- return true;
- }
- }
-
- //end of the loop: we didn't find anything
- return false;
-}
-
-/*! \internal
- Returns the next state of the statemachine, based
- on the new key event \a e.
- Matches are appended to the vector of identicals,
- which can be access through matches().
- \sa matches
-*/
-QKeySequence::SequenceMatch QShortcutMap::find(QKeyEvent *e)
-{
- Q_D(QShortcutMap);
- if (!d->sequences.count())
- return QKeySequence::NoMatch;
-
- createNewSequences(e, d->newEntries);
-#if defined(DEBUG_QSHORTCUTMAP)
- qDebug() << "Possible shortcut key sequences:" << d->newEntries;
-#endif
-
- // Should never happen
- if (d->newEntries == d->currentSequences) {
- Q_ASSERT_X(e->key() != Qt::Key_unknown || e->text().length(),
- "QShortcutMap::find", "New sequence to find identical to previous");
- return QKeySequence::NoMatch;
- }
-
- // Looking for new identicals, scrap old
- d->identicals.resize(0);
-
- bool partialFound = false;
- bool identicalDisabledFound = false;
- QVector<QKeySequence> okEntries;
- int result = QKeySequence::NoMatch;
- for (int i = d->newEntries.count()-1; i >= 0 ; --i) {
- QShortcutEntry entry(d->newEntries.at(i)); // needed for searching
- QList<QShortcutEntry>::ConstIterator itEnd = d->sequences.constEnd();
- QList<QShortcutEntry>::ConstIterator it =
- qLowerBound(d->sequences.constBegin(), itEnd, entry);
-
- int oneKSResult = QKeySequence::NoMatch;
- int tempRes = QKeySequence::NoMatch;
- do {
- if (it == itEnd)
- break;
- tempRes = matches(entry.keyseq, (*it).keyseq);
- oneKSResult = qMax(oneKSResult, tempRes);
- if (tempRes != QKeySequence::NoMatch && correctContext(*it)) {
- if (tempRes == QKeySequence::ExactMatch) {
- if ((*it).enabled)
- d->identicals.append(&*it);
- else
- identicalDisabledFound = true;
- } else if (tempRes == QKeySequence::PartialMatch) {
- // We don't need partials, if we have identicals
- if (d->identicals.size())
- break;
- // We only care about enabled partials, so we don't consume
- // key events when all partials are disabled!
- partialFound |= (*it).enabled;
- }
- }
- ++it;
- // If we got a valid match on this run, there might still be more keys to check against,
- // so we'll loop once more. If we get NoMatch, there's guaranteed no more possible
- // matches in the shortcutmap.
- } while (tempRes != QKeySequence::NoMatch);
-
- // If the type of match improves (ergo, NoMatch->Partial, or Partial->Exact), clear the
- // previous list. If this match is equal or better than the last match, append to the list
- if (oneKSResult > result) {
- okEntries.clear();
-#if defined(DEBUG_QSHORTCUTMAP)
- qDebug() << "Found better match (" << d->newEntries << "), clearing key sequence list";
-#endif
- }
- if (oneKSResult && oneKSResult >= result) {
- okEntries << d->newEntries.at(i);
-#if defined(DEBUG_QSHORTCUTMAP)
- qDebug() << "Added ok key sequence" << d->newEntries;
-#endif
- }
- }
-
- if (d->identicals.size()) {
- result = QKeySequence::ExactMatch;
- } else if (partialFound) {
- result = QKeySequence::PartialMatch;
- } else if (identicalDisabledFound) {
- result = QKeySequence::ExactMatch;
- } else {
- clearSequence(d->currentSequences);
- result = QKeySequence::NoMatch;
- }
- if (result != QKeySequence::NoMatch)
- d->currentSequences = okEntries;
-#if defined(DEBUG_QSHORTCUTMAP)
- qDebug() << "Returning shortcut match == " << result;
-#endif
- return QKeySequence::SequenceMatch(result);
-}
-
-/*! \internal
- Clears \a seq to an empty QKeySequence.
- Same as doing (the slower)
- \snippet doc/src/snippets/code/src_gui_kernel_qshortcutmap.cpp 0
-*/
-void QShortcutMap::clearSequence(QVector<QKeySequence> &ksl)
-{
- ksl.clear();
- d_func()->newEntries.clear();
-}
-
-/*! \internal
- Alters \a seq to the new sequence state, based on the
- current sequence state, and the new key event \a e.
-*/
-void QShortcutMap::createNewSequences(QKeyEvent *e, QVector<QKeySequence> &ksl)
-{
- Q_D(QShortcutMap);
- QList<int> possibleKeys = QKeyMapper::possibleKeys(e);
- int pkTotal = possibleKeys.count();
- if (!pkTotal)
- return;
-
- int ssActual = d->currentSequences.count();
- int ssTotal = qMax(1, ssActual);
- // Resize to possible permutations of the current sequence(s).
- ksl.resize(pkTotal * ssTotal);
-
- int index = ssActual ? d->currentSequences.at(0).count() : 0;
- for (int pkNum = 0; pkNum < pkTotal; ++pkNum) {
- for (int ssNum = 0; ssNum < ssTotal; ++ssNum) {
- int i = (pkNum * ssTotal) + ssNum;
- QKeySequence &curKsl = ksl[i];
- if (ssActual) {
- const QKeySequence &curSeq = d->currentSequences.at(ssNum);
- curKsl.setKey(curSeq[0], 0);
- curKsl.setKey(curSeq[1], 1);
- curKsl.setKey(curSeq[2], 2);
- curKsl.setKey(curSeq[3], 3);
- } else {
- curKsl.setKey(0, 0);
- curKsl.setKey(0, 1);
- curKsl.setKey(0, 2);
- curKsl.setKey(0, 3);
- }
- // Filtering keycode here with 0xdfffffff to ignore the Keypad modifier
- curKsl.setKey(possibleKeys.at(pkNum) & 0xdfffffff, index);
- }
- }
-}
-
-/*! \internal
- Basically the same function as QKeySequence::matches(const QKeySequence &seq) const
- only that is specially handles Key_hyphen as Key_Minus, as people mix these up all the time and
- they conceptually the same.
-*/
-QKeySequence::SequenceMatch QShortcutMap::matches(const QKeySequence &seq1,
- const QKeySequence &seq2) const
-{
- uint userN = seq1.count(),
- seqN = seq2.count();
-
- if (userN > seqN)
- return QKeySequence::NoMatch;
-
- // If equal in length, we have a potential ExactMatch sequence,
- // else we already know it can only be partial.
- QKeySequence::SequenceMatch match = (userN == seqN
- ? QKeySequence::ExactMatch
- : QKeySequence::PartialMatch);
-
- for (uint i = 0; i < userN; ++i) {
- int userKey = seq1[i],
- sequenceKey = seq2[i];
- if ((userKey & Qt::Key_unknown) == Qt::Key_hyphen)
- userKey = (userKey & Qt::KeyboardModifierMask) | Qt::Key_Minus;
- if ((sequenceKey & Qt::Key_unknown) == Qt::Key_hyphen)
- sequenceKey = (sequenceKey & Qt::KeyboardModifierMask) | Qt::Key_Minus;
- if (userKey != sequenceKey)
- return QKeySequence::NoMatch;
- }
- return match;
-}
-
-/*! \internal
- Returns true if the widget \a w is a logical sub window of the current
- top-level widget.
-*/
-bool QShortcutMap::correctContext(const QShortcutEntry &item) const {
- Q_ASSERT_X(item.owner, "QShortcutMap", "Shortcut has no owner. Illegal map state!");
-
- QWidget *active_window = QApplication::activeWindow();
-
- // popups do not become the active window,
- // so we fake it here to get the correct context
- // for the shortcut system.
- if (QApplication::activePopupWidget())
- active_window = QApplication::activePopupWidget();
-
- if (!active_window)
- return false;
-#ifndef QT_NO_ACTION
- if (QAction *a = qobject_cast<QAction *>(item.owner))
- return correctContext(item.context, a, active_window);
-#endif
-#ifndef QT_NO_GRAPHICSVIEW
- if (QGraphicsWidget *gw = qobject_cast<QGraphicsWidget *>(item.owner))
- return correctGraphicsWidgetContext(item.context, gw, active_window);
-#endif
- QWidget *w = qobject_cast<QWidget *>(item.owner);
- if (!w) {
- QShortcut *s = qobject_cast<QShortcut *>(item.owner);
- w = s->parentWidget();
- }
- return correctWidgetContext(item.context, w, active_window);
-}
-
-bool QShortcutMap::correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidget *active_window) const
-{
- bool visible = w->isVisible();
-#ifdef Q_WS_MAC
- if (!qApp->testAttribute(Qt::AA_DontUseNativeMenuBar) && qobject_cast<QMenuBar *>(w))
- visible = true;
-#endif
-
- if (!visible || !w->isEnabled())
- return false;
-
- if (context == Qt::ApplicationShortcut)
- return QApplicationPrivate::tryModalHelper(w, 0); // true, unless w is shadowed by a modal dialog
-
- if (context == Qt::WidgetShortcut)
- return w == QApplication::focusWidget();
-
- if (context == Qt::WidgetWithChildrenShortcut) {
- const QWidget *tw = QApplication::focusWidget();
- while (tw && tw != w && (tw->windowType() == Qt::Widget || tw->windowType() == Qt::Popup))
- tw = tw->parentWidget();
- return tw == w;
- }
-
- // Below is Qt::WindowShortcut context
- QWidget *tlw = w->window();
-#ifndef QT_NO_GRAPHICSVIEW
- if (QWExtra *topData = tlw->d_func()->extra) {
- if (topData->proxyWidget) {
- bool res = correctGraphicsWidgetContext(context, (QGraphicsWidget *)topData->proxyWidget, active_window);
- return res;
- }
- }
-#endif
-
- /* if a floating tool window is active, keep shortcuts on the
- * parent working */
- if (active_window != tlw && active_window && active_window->windowType() == Qt::Tool && active_window->parentWidget()) {
- active_window = active_window->parentWidget()->window();
- }
-
- if (active_window != tlw)
- return false;
-
- /* if we live in a MDI subwindow, ignore the event if we are
- not the active document window */
- const QWidget* sw = w;
- while (sw && !(sw->windowType() == Qt::SubWindow) && !sw->isWindow())
- sw = sw->parentWidget();
- if (sw && (sw->windowType() == Qt::SubWindow)) {
- QWidget *focus_widget = QApplication::focusWidget();
- while (focus_widget && focus_widget != sw)
- focus_widget = focus_widget->parentWidget();
- return sw == focus_widget;
- }
-
-#if defined(DEBUG_QSHORTCUTMAP)
- qDebug().nospace() << "..true [Pass-through]";
-#endif
- return true;
-}
-
-#ifndef QT_NO_GRAPHICSVIEW
-bool QShortcutMap::correctGraphicsWidgetContext(Qt::ShortcutContext context, QGraphicsWidget *w, QWidget *active_window) const
-{
- bool visible = w->isVisible();
-#ifdef Q_WS_MAC
- if (!qApp->testAttribute(Qt::AA_DontUseNativeMenuBar) && qobject_cast<QMenuBar *>(w))
- visible = true;
-#endif
-
- if (!visible || !w->isEnabled() || !w->scene())
- return false;
-
- if (context == Qt::ApplicationShortcut) {
- // Applicationwide shortcuts are always reachable unless their owner
- // is shadowed by modality. In QGV there's no modality concept, but we
- // must still check if all views are shadowed.
- QList<QGraphicsView *> views = w->scene()->views();
- for (int i = 0; i < views.size(); ++i) {
- if (QApplicationPrivate::tryModalHelper(views.at(i), 0))
- return true;
- }
- return false;
- }
-
- if (context == Qt::WidgetShortcut)
- return static_cast<QGraphicsItem *>(w) == w->scene()->focusItem();
-
- if (context == Qt::WidgetWithChildrenShortcut) {
- const QGraphicsItem *ti = w->scene()->focusItem();
- if (ti && ti->isWidget()) {
- const QGraphicsWidget *tw = static_cast<const QGraphicsWidget *>(ti);
- while (tw && tw != w && (tw->windowType() == Qt::Widget || tw->windowType() == Qt::Popup))
- tw = tw->parentWidget();
- return tw == w;
- }
- return false;
- }
-
- // Below is Qt::WindowShortcut context
-
- // Find the active view (if any).
- QList<QGraphicsView *> views = w->scene()->views();
- QGraphicsView *activeView = 0;
- for (int i = 0; i < views.size(); ++i) {
- QGraphicsView *view = views.at(i);
- if (view->window() == active_window) {
- activeView = view;
- break;
- }
- }
- if (!activeView)
- return false;
-
- // The shortcut is reachable if owned by a windowless widget, or if the
- // widget's window is the same as the focus item's window.
- QGraphicsWidget *a = w->scene()->activeWindow();
- return !w->window() || a == w->window();
-}
-#endif
-
-#ifndef QT_NO_ACTION
-bool QShortcutMap::correctContext(Qt::ShortcutContext context, QAction *a, QWidget *active_window) const
-{
- const QList<QWidget *> &widgets = a->d_func()->widgets;
-#if defined(DEBUG_QSHORTCUTMAP)
- if (widgets.isEmpty())
- qDebug() << a << "not connected to any widgets; won't trigger";
-#endif
- for (int i = 0; i < widgets.size(); ++i) {
- QWidget *w = widgets.at(i);
-#ifndef QT_NO_MENU
- if (QMenu *menu = qobject_cast<QMenu *>(w)) {
- QAction *a = menu->menuAction();
- if (correctContext(context, a, active_window))
- return true;
- } else
-#endif
- if (correctWidgetContext(context, w, active_window))
- return true;
- }
-
-#ifndef QT_NO_GRAPHICSVIEW
- const QList<QGraphicsWidget *> &graphicsWidgets = a->d_func()->graphicsWidgets;
-#if defined(DEBUG_QSHORTCUTMAP)
- if (graphicsWidgets.isEmpty())
- qDebug() << a << "not connected to any widgets; won't trigger";
-#endif
- for (int i = 0; i < graphicsWidgets.size(); ++i) {
- QGraphicsWidget *w = graphicsWidgets.at(i);
- if (correctGraphicsWidgetContext(context, w, active_window))
- return true;
- }
-#endif
- return false;
-}
-#endif // QT_NO_ACTION
-
-/*! \internal
- Converts keyboard button states into modifier states
-*/
-int QShortcutMap::translateModifiers(Qt::KeyboardModifiers modifiers)
-{
- int result = 0;
- if (modifiers & Qt::ShiftModifier)
- result |= Qt::SHIFT;
- if (modifiers & Qt::ControlModifier)
- result |= Qt::CTRL;
- if (modifiers & Qt::MetaModifier)
- result |= Qt::META;
- if (modifiers & Qt::AltModifier)
- result |= Qt::ALT;
- return result;
-}
-
-/*! \internal
- Returns the vector of QShortcutEntry's matching the last Identical state.
-*/
-QVector<const QShortcutEntry*> QShortcutMap::matches() const
-{
- Q_D(const QShortcutMap);
- return d->identicals;
-}
-
-/*! \internal
- Dispatches QShortcutEvents to widgets who grabbed the matched key sequence.
-*/
-void QShortcutMap::dispatchEvent(QKeyEvent *e)
-{
- Q_D(QShortcutMap);
- if (!d->identicals.size())
- return;
-
- const QKeySequence &curKey = d->identicals.at(0)->keyseq;
- if (d->prevSequence != curKey) {
- d->ambigCount = 0;
- d->prevSequence = curKey;
- }
- // Find next
- const QShortcutEntry *current = 0, *next = 0;
- int i = 0, enabledShortcuts = 0;
- while(i < d->identicals.size()) {
- current = d->identicals.at(i);
- if (current->enabled || !next){
- ++enabledShortcuts;
- if (enabledShortcuts > d->ambigCount + 1)
- break;
- next = current;
- }
- ++i;
- }
- d->ambigCount = (d->identicals.size() == i ? 0 : d->ambigCount + 1);
- // Don't trigger shortcut if we're autorepeating and the shortcut is
- // grabbed with not accepting autorepeats.
- if (!next || (e->isAutoRepeat() && !next->autorepeat))
- return;
- // Dispatch next enabled
-#if defined(DEBUG_QSHORTCUTMAP)
- qDebug().nospace()
- << "QShortcutMap::dispatchEvent(): Sending QShortcutEvent(\""
- << (QString)next->keyseq << "\", " << next->id << ", "
- << (bool)(enabledShortcuts>1) << ") to object(" << next->owner << ')';
-#endif
- QShortcutEvent se(next->keyseq, next->id, enabledShortcuts>1);
- QApplication::sendEvent(const_cast<QObject *>(next->owner), &se);
-}
-
-/* \internal
- QShortcutMap dump function, only available when DEBUG_QSHORTCUTMAP is
- defined.
-*/
-#if defined(Dump_QShortcutMap)
-void QShortcutMap::dumpMap() const
-{
- Q_D(const QShortcutMap);
- for (int i = 0; i < d->sequences.size(); ++i)
- qDebug().nospace() << &(d->sequences.at(i));
-}
-#endif
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_SHORTCUT
diff --git a/src/gui/kernel/qsoftkeymanager_p.h b/src/gui/kernel/qsoftkeymanager_p.h
deleted file mode 100644
index 78999a97bd..0000000000
--- a/src/gui/kernel/qsoftkeymanager_p.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSOFTKEYMANAGER_P_H
-#define QSOFTKEYMANAGER_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qobject.h>
-#include "QtGui/qaction.h"
-
-QT_BEGIN_HEADER
-
-#ifndef QT_NO_SOFTKEYMANAGER
-QT_BEGIN_NAMESPACE
-
-class QSoftKeyManagerPrivate;
-
-class Q_AUTOTEST_EXPORT QSoftKeyManager : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QSoftKeyManager)
-
-public:
-
- enum StandardSoftKey {
- OkSoftKey,
- SelectSoftKey,
- DoneSoftKey,
- MenuSoftKey,
- CancelSoftKey
- };
-
- static void updateSoftKeys();
-#ifdef Q_WS_S60
- static bool handleCommand(int);
-#endif
-
- static QAction *createAction(StandardSoftKey standardKey, QWidget *actionWidget);
- static QAction *createKeyedAction(StandardSoftKey standardKey, Qt::Key key, QWidget *actionWidget);
- static QString standardSoftKeyText(StandardSoftKey standardKey);
- static void setForceEnabledInSoftkeys(QAction *action);
- static bool isForceEnabledInSofkeys(QAction *action);
-
-protected:
- bool event(QEvent *e);
-
-private:
- QSoftKeyManager();
- static QSoftKeyManager *instance();
- bool appendSoftkeys(const QWidget &source, int level);
- QWidget *softkeySource(QWidget *previousSource, bool& recursiveMerging);
- bool handleUpdateSoftKeys();
-
-private Q_SLOTS:
- void cleanupHash(QObject* obj);
- void sendKeyEvent();
-
-private:
- Q_DISABLE_COPY(QSoftKeyManager)
-};
-
-QT_END_NAMESPACE
-#endif //QT_NO_SOFTKEYMANAGER
-
-QT_END_HEADER
-
-#endif //QSOFTKEYMANAGER_P_H
diff --git a/src/gui/kernel/qsound.cpp b/src/gui/kernel/qsound.cpp
deleted file mode 100644
index a61310a4eb..0000000000
--- a/src/gui/kernel/qsound.cpp
+++ /dev/null
@@ -1,390 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qsound.h"
-
-#ifndef QT_NO_SOUND
-
-#include "qlist.h"
-#include <private/qobject_p.h>
-#include "qsound_p.h"
-
-QT_BEGIN_NAMESPACE
-
-static QList<QAuServer*> *servers=0;
-
-QAuServer::QAuServer(QObject* parent)
- : QObject(parent)
-{
- if (!servers)
- servers = new QList<QAuServer*>;
- servers->prepend(this);
-}
-
-QAuServer::~QAuServer()
-{
- servers->removeAll(this);
- if (servers->count() == 0) {
- delete servers;
- servers = 0;
- }
-}
-
-void QAuServer::play(const QString& filename)
-{
- QSound s(filename);
- play(&s);
-}
-
-extern QAuServer* qt_new_audio_server();
-
-static QAuServer& server()
-{
- if (!servers) qt_new_audio_server();
- return *servers->first();
-}
-
-class QSoundPrivate : public QObjectPrivate
-{
-public:
- QSoundPrivate(const QString& fname)
- : filename(fname), bucket(0), looprem(0), looptotal(1)
- {
- }
-
- ~QSoundPrivate()
- {
- delete bucket;
- }
-
- QString filename;
- QAuBucket* bucket;
- int looprem;
- int looptotal;
-};
-
-/*!
- \class QSound
- \brief The QSound class provides access to the platform audio facilities.
-
- \ingroup multimedia
-
-
- Qt provides the most commonly required audio operation in GUI
- applications: asynchronously playing a sound file. This is most
- easily accomplished using the static play() function:
-
- \snippet doc/src/snippets/code/src_gui_kernel_qsound.cpp 0
-
- Alternatively, create a QSound object from the sound file first
- and then call the play() slot:
-
- \snippet doc/src/snippets/code/src_gui_kernel_qsound.cpp 1
-
- Once created a QSound object can be queried for its fileName() and
- total number of loops() (i.e. the number of times the sound will
- play). The number of repetitions can be altered using the
- setLoops() function. While playing the sound, the loopsRemaining()
- function returns the remaining number of repetitions. Use the
- isFinished() function to determine whether the sound has finished
- playing.
-
- Sounds played using a QSound object may use more memory than the
- static play() function, but it may also play more immediately
- (depending on the underlying platform audio facilities). Use the
- static isAvailable() function to determine whether sound
- facilities exist on the platform. Which facilities that are
- actually used varies:
-
- \table
- \header \o Platform \o Audio Facility
- \row
- \o Microsoft Windows
- \o The underlying multimedia system is used; only WAVE format sound files
- are supported.
- \row
- \o X11
- \o The \l{ftp://ftp.x.org/contrib/audio/nas/}{Network Audio System}
- is used if available, otherwise all operations work silently. NAS
- supports WAVE and AU files.
- \row
- \o Mac OS X
- \o NSSound is used. All formats that NSSound supports, including QuickTime formats,
- are supported by Qt for Mac OS X.
- \row
- \o Qt for Embedded Linux
- \o A built-in mixing sound server is used, accessing \c /dev/dsp
- directly. Only the WAVE format is supported.
- \row
- \o Symbian
- \o CMdaAudioPlayerUtility is used. All formats that Symbian OS or devices support
- are supported also by Qt.
- \endtable
-
- Note that QSound does not support \l{resources.html}{resources}.
- This might be fixed in a future Qt version.
-*/
-
-/*!
- Plays the sound stored in the file specified by the given \a filename.
-
- \sa stop(), loopsRemaining(), isFinished()
-*/
-void QSound::play(const QString& filename)
-{
- server().play(filename);
-}
-
-/*!
- Constructs a QSound object from the file specified by the given \a
- filename and with the given \a parent.
-
- This may use more memory than the static play() function, but it
- may also play more immediately (depending on the underlying
- platform audio facilities).
-
- \sa play()
-*/
-QSound::QSound(const QString& filename, QObject* parent)
- : QObject(*new QSoundPrivate(filename), parent)
-{
- server().init(this);
-}
-
-#ifdef QT3_SUPPORT
-/*!
- \obsolete
-
- Constructs a QSound object from the file specified by the given \a
- filename and with the given \a parent and \a name. Use the
- QSound() construcor and QObject::setObjectName() instead.
-
- \oldcode
- QSound *mySound = new QSound(filename, parent, name);
- \newcode
- QSounc *mySound = new QSound(filename, parent);
- mySound->setObjectName(name);
- \endcode
-*/
-QSound::QSound(const QString& filename, QObject* parent, const char* name)
- : QObject(*new QSoundPrivate(filename), parent)
-{
- setObjectName(QString::fromAscii(name));
- server().init(this);
-}
-#endif
-
-/*!
- Destroys this sound object. If the sound is not finished playing,
- the stop() function is called before the sound object is
- destructed.
-
- \sa stop(), isFinished()
-*/
-QSound::~QSound()
-{
- if (!isFinished())
- stop();
-}
-
-/*!
- Returns true if the sound has finished playing; otherwise returns false.
-
- \warning On Windows this function always returns true for unlooped sounds.
-*/
-bool QSound::isFinished() const
-{
- Q_D(const QSound);
- return d->looprem == 0;
-}
-
-/*!
- \overload
-
- Starts playing the sound specified by this QSound object.
-
- The function returns immediately. Depending on the platform audio
- facilities, other sounds may stop or be mixed with the new
- sound. The sound can be played again at any time, possibly mixing
- or replacing previous plays of the sound.
-
- \sa fileName()
-*/
-void QSound::play()
-{
- Q_D(QSound);
- d->looprem = d->looptotal;
- server().play(this);
-}
-
-/*!
- Returns the number of times the sound will play.
-
- \sa loopsRemaining(), setLoops()
-*/
-int QSound::loops() const
-{
- Q_D(const QSound);
- return d->looptotal;
-}
-
-/*!
- Returns the remaining number of times the sound will loop (this
- value decreases each time the sound is played).
-
- \sa loops(), isFinished()
-*/
-int QSound::loopsRemaining() const
-{
- Q_D(const QSound);
- return d->looprem;
-}
-
-/*!
- \fn void QSound::setLoops(int number)
-
- Sets the sound to repeat the given \a number of times when it is
- played.
-
- Note that passing the value -1 will cause the sound to loop
- indefinitely.
-
- \sa loops()
-*/
-void QSound::setLoops(int n)
-{
- Q_D(QSound);
- d->looptotal = n;
-}
-
-/*!
- Returns the filename associated with this QSound object.
-
- \sa QSound()
-*/
-QString QSound::fileName() const
-{
- Q_D(const QSound);
- return d->filename;
-}
-
-/*!
- Stops the sound playing.
-
- Note that on Windows the current loop will finish if a sound is
- played in a loop.
-
- \sa play()
-*/
-void QSound::stop()
-{
- Q_D(QSound);
- server().stop(this);
- d->looprem = 0;
-}
-
-
-/*!
- Returns true if sound facilities exist on the platform; otherwise
- returns false.
-
- If no sound is available, all QSound operations work silently and
- quickly. An application may choose either to notify the user if
- sound is crucial to the application or to operate silently without
- bothering the user.
-
- Note: On Windows this always returns true because some sound card
- drivers do not implement a way to find out whether it is available
- or not.
-*/
-bool QSound::isAvailable()
-{
- return server().okay();
-}
-
-/*!
- Sets the internal bucket record of sound \a s to \a b, deleting
- any previous setting.
-*/
-void QAuServer::setBucket(QSound* s, QAuBucket* b)
-{
- delete s->d_func()->bucket;
- s->d_func()->bucket = b;
-}
-
-/*!
- Returns the internal bucket record of sound \a s.
-*/
-QAuBucket* QAuServer::bucket(QSound* s)
-{
- return s->d_func()->bucket;
-}
-
-/*!
- Decrements the QSound::loopRemaining() value for sound \a s,
- returning the result.
-*/
-int QAuServer::decLoop(QSound* s)
-{
- if (s->d_func()->looprem > 0)
- --s->d_func()->looprem;
- return s->d_func()->looprem;
-}
-
-/*!
- Initializes the sound. The default implementation does nothing.
-*/
-void QAuServer::init(QSound*)
-{
-}
-
-QAuBucket::~QAuBucket()
-{
-}
-/*!
- \fn bool QSound::available()
-
- Use the isAvailable() function instead.
-*/
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_SOUND
diff --git a/src/gui/kernel/qsound.h b/src/gui/kernel/qsound.h
deleted file mode 100644
index 70957762b2..0000000000
--- a/src/gui/kernel/qsound.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSOUND_H
-#define QSOUND_H
-
-#include <QtCore/qobject.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_SOUND
-
-class QSoundPrivate;
-
-class Q_GUI_EXPORT QSound : public QObject
-{
- Q_OBJECT
-
-public:
- static bool isAvailable();
- static void play(const QString& filename);
-
- explicit QSound(const QString& filename, QObject* parent = 0);
- ~QSound();
-
- int loops() const;
- int loopsRemaining() const;
- void setLoops(int);
- QString fileName() const;
-
- bool isFinished() const;
-
-public Q_SLOTS:
- void play();
- void stop();
-
-public:
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QSound(const QString& filename, QObject* parent, const char* name);
- static inline QT3_SUPPORT bool available() { return isAvailable(); }
-#endif
-private:
- Q_DECLARE_PRIVATE(QSound)
- friend class QAuServer;
-};
-
-#endif // QT_NO_SOUND
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSOUND_H
diff --git a/src/gui/kernel/qsound_qws.cpp b/src/gui/kernel/qsound_qws.cpp
deleted file mode 100644
index c48347bf76..0000000000
--- a/src/gui/kernel/qsound_qws.cpp
+++ /dev/null
@@ -1,350 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qapplication.h"
-
-#ifndef QT_NO_SOUND
-
-#include "qsound.h"
-#include "qpaintdevice.h"
-#include "qwsdisplay_qws.h"
-#include "qsound_p.h"
-
-#include "qsoundqss_qws.h"
-
-#include "qhash.h"
-#include "qfileinfo.h"
-
-#include "qbytearray.h"
-#include "quuid.h"
-#include "qdatastream.h"
-#include "qcopchannel_qws.h"
-#include "qbuffer.h"
-
-
-QT_BEGIN_NAMESPACE
-
-#ifdef MEDIA_SERVER
-
-#define SERVER_CHANNEL "QPE/MediaServer"
-
-class QCopMessage : public QDataStream
-{
-public:
- QCopMessage( const QString& channel, const QString& message )
- : QDataStream( new QBuffer ), m_channel( channel ), m_message( message )
- {
- device()->open( QIODevice::WriteOnly );
- }
-
- ~QCopMessage()
- {
- QCopChannel::send( m_channel, m_message, ((QBuffer*)device())->buffer() );
- delete device();
- }
-
-private:
- QString m_channel;
- QString m_message;
-};
-
-#endif // MEDIA_SERVER
-
-class QAuServerQWS;
-
-class QAuBucketQWS : public QObject, public QAuBucket
-{
- Q_OBJECT
-public:
- QAuBucketQWS( QAuServerQWS*, QSound*, QObject* parent = 0 );
-
- ~QAuBucketQWS();
-
-#ifndef MEDIA_SERVER
- int id() const { return id_; }
-#endif
-
- QSound* sound() const { return sound_; }
-
-#ifdef MEDIA_SERVER
- void play();
-
- void stop();
-#endif
-
-signals:
- // Only for Media Server
- void done( QAuBucketQWS* );
-
-private slots:
- // Only for Media Server
- void processMessage( const QString& msg, const QByteArray& data );
-
-private:
-#ifdef MEDIA_SERVER
- QCopChannel *m_channel;
- QUuid m_id;
-#endif
-
-#ifndef MEDIA_SERVER
- int id_;
-#endif
- QSound *sound_;
- QAuServerQWS *server_;
-
- static int next;
-};
-
-int QAuBucketQWS::next = 0;
-
-class QAuServerQWS : public QAuServer
-{
- Q_OBJECT
-public:
- QAuServerQWS( QObject* parent );
-
- void init( QSound* s )
- {
- QAuBucketQWS *bucket = new QAuBucketQWS( this, s );
-#ifdef MEDIA_SERVER
- connect( bucket, SIGNAL(done(QAuBucketQWS*)),
- this, SLOT(complete(QAuBucketQWS*)) );
-#endif
- setBucket( s, bucket );
- }
-
-#ifndef MEDIA_SERVER
- // Register bucket
- void insert( QAuBucketQWS *bucket )
- {
- buckets.insert( bucket->id(), bucket );
- }
-
- // Remove bucket from register
- void remove( QAuBucketQWS *bucket )
- {
- buckets.remove( bucket->id() );
- }
-#endif
-
- void play( QSound* s )
- {
- QString filepath = QFileInfo( s->fileName() ).absoluteFilePath();
-#if defined(QT_NO_QWS_SOUNDSERVER)
- server->playFile( bucket( s )->id(), filepath );
-#elif defined(MEDIA_SERVER)
- bucket( s )->play();
-#else
- client->play( bucket( s )->id(), filepath );
-#endif
- }
-
- void stop( QSound* s )
- {
-#if defined(QT_NO_QWS_SOUNDSERVER)
- server->stopFile( bucket( s )->id() );
-#elif defined(MEDIA_SERVER)
- bucket( s )->stop();
-#else
- client->stop( bucket( s )->id() );
-#endif
- }
-
- bool okay() { return true; }
-
-private slots:
- // Continue playing sound if loops remain
- void complete( int id )
- {
-#ifndef MEDIA_SERVER
- QAuBucketQWS *bucket = find( id );
- if( bucket ) {
- QSound *sound = bucket->sound();
- if( decLoop( sound ) ) {
- play( sound );
- }
- }
-#else
- Q_UNUSED(id);
-#endif
- }
-
- // Only for Media Server
- void complete( QAuBucketQWS* bucket )
- {
-#ifndef MEDIA_SERVER
- Q_UNUSED(bucket);
-#else
- QSound *sound = bucket->sound();
- if( decLoop( sound ) ) {
- play( sound );
- }
-#endif
- }
-
-protected:
- QAuBucketQWS* bucket( QSound *s )
- {
- return (QAuBucketQWS*)QAuServer::bucket( s );
- }
-
-private:
-#ifndef MEDIA_SERVER
- // Find registered bucket with given id, return null if none found
- QAuBucketQWS* find( int id )
- {
- QHash<int, QAuBucketQWS*>::Iterator it = buckets.find( id );
- if( it != buckets.end() ) {
- return it.value();
- }
-
- return 0;
- }
-
- QHash<int, QAuBucketQWS*> buckets; // ### possible problem with overlapping keys
-
-#ifdef QT_NO_QWS_SOUNDSERVER
- QWSSoundServer *server;
-#else
- QWSSoundClient *client;
-#endif
-
-#endif // MEDIA_SERVER
-};
-
-QAuServerQWS::QAuServerQWS(QObject* parent) :
- QAuServer(parent)
-{
-#ifndef MEDIA_SERVER
- setObjectName(QLatin1String("qauserverqws"));
-
-#ifdef QT_NO_QWS_SOUNDSERVER
- server = new QWSSoundServer( this ); // ### only suitable for single application
-
- connect( server, SIGNAL(soundCompleted(int)),
- this, SLOT(complete(int)) );
-#else
- client = new QWSSoundClient( this ); // ### requires successful connection
-
- connect( client, SIGNAL(soundCompleted(int)),
- this, SLOT(complete(int)) );
-#endif
-
-#endif // MEDIA_SERVER
-}
-
-QAuBucketQWS::QAuBucketQWS( QAuServerQWS *server, QSound *sound, QObject* parent )
- : QObject( parent ), sound_( sound ), server_( server )
-{
-#ifdef MEDIA_SERVER
- m_id = QUuid::createUuid();
-
- sound->setObjectName( m_id.toString() );
-
- m_channel = new QCopChannel(QLatin1String("QPE/QSound/") + m_id, this );
- connect( m_channel, SIGNAL(received(QString,QByteArray)),
- this, SLOT(processMessage(QString,QByteArray)) );
-
- {
- QCopMessage message( QLatin1String(SERVER_CHANNEL), QLatin1String("subscribe(QUuid)") );
- message << m_id;
- }
-
- {
- QString filepath = QFileInfo( sound_->fileName() ).absoluteFilePath();
- QCopMessage message( QLatin1String(SERVER_CHANNEL), QLatin1String("open(QUuid,QString)") );
- message << m_id << filepath;
- }
-#else
- id_ = next++;
- server_->insert( this );
-#endif
-}
-
-#ifdef MEDIA_SERVER
-void QAuBucketQWS::play()
-{
- QString filepath = QFileInfo( sound_->fileName() ).absoluteFilePath();
-
- QCopMessage message( QLatin1String(SERVER_CHANNEL), QLatin1String("play(QUuid)") );
- message << m_id;
-}
-
-void QAuBucketQWS::stop()
-{
- QCopMessage message( QLatin1String(SERVER_CHANNEL), QLatin1String("stop(QUuid)") );
- message << m_id;
-}
-#endif // MEDIA_SERVER
-
-void QAuBucketQWS::processMessage( const QString& msg, const QByteArray& data )
-{
- Q_UNUSED(data);
-#ifndef MEDIA_SERVER
- Q_UNUSED(msg);
-#else
- if( msg == QLatin1String("done()") ) {
- emit done( this );
- }
-#endif
-}
-
-QAuBucketQWS::~QAuBucketQWS()
-{
-#ifdef MEDIA_SERVER
- QCopMessage message( QLatin1String(SERVER_CHANNEL), QLatin1String("revoke(QUuid)") );
- message << m_id;
-#else
- server_->remove( this );
-#endif
-}
-
-
-QAuServer* qt_new_audio_server()
-{
- return new QAuServerQWS(qApp);
-}
-
-#include "qsound_qws.moc"
-
-#endif // QT_NO_SOUND
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qstackedlayout.h b/src/gui/kernel/qstackedlayout.h
deleted file mode 100644
index 49b80c6445..0000000000
--- a/src/gui/kernel/qstackedlayout.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSTACKEDLAYOUT_H
-#define QSTACKEDLAYOUT_H
-
-#include <QtGui/qlayout.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QStackedLayoutPrivate;
-
-class Q_GUI_EXPORT QStackedLayout : public QLayout
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QStackedLayout)
- Q_ENUMS(StackingMode)
- Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
- Q_PROPERTY(StackingMode stackingMode READ stackingMode WRITE setStackingMode)
- QDOC_PROPERTY(int count READ count)
-
-public:
- enum StackingMode {
- StackOne,
- StackAll
- };
-
- QStackedLayout();
- explicit QStackedLayout(QWidget *parent);
- explicit QStackedLayout(QLayout *parentLayout);
- ~QStackedLayout();
-
- int addWidget(QWidget *w);
- int insertWidget(int index, QWidget *w);
-
- QWidget *currentWidget() const;
- int currentIndex() const;
-#ifdef Q_NO_USING_KEYWORD
- inline QWidget *widget() { return QLayout::widget(); }
-#else
- using QLayout::widget;
-#endif
- QWidget *widget(int) const;
- int count() const;
-
- StackingMode stackingMode() const;
- void setStackingMode(StackingMode stackingMode);
-
- // abstract virtual functions:
- void addItem(QLayoutItem *item);
- QSize sizeHint() const;
- QSize minimumSize() const;
- QLayoutItem *itemAt(int) const;
- QLayoutItem *takeAt(int);
- void setGeometry(const QRect &rect);
-
-Q_SIGNALS:
- void widgetRemoved(int index);
- void currentChanged(int index);
-
-public Q_SLOTS:
- void setCurrentIndex(int index);
- void setCurrentWidget(QWidget *w);
-
-private:
- Q_DISABLE_COPY(QStackedLayout)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSTACKEDLAYOUT_H
diff --git a/src/gui/kernel/qtooltip.h b/src/gui/kernel/qtooltip.h
deleted file mode 100644
index 4195f1cb3e..0000000000
--- a/src/gui/kernel/qtooltip.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTOOLTIP_H
-#define QTOOLTIP_H
-
-#include <QtGui/qwidget.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_TOOLTIP
-
-class Q_GUI_EXPORT QToolTip
-{
- QToolTip();
-public:
- static void showText(const QPoint &pos, const QString &text, QWidget *w = 0);
- static void showText(const QPoint &pos, const QString &text, QWidget *w, const QRect &rect);
- static inline void hideText() { showText(QPoint(), QString()); }
-
- static bool isVisible();
- static QString text();
-
- static QPalette palette();
- static void setPalette(const QPalette &);
- static QFont font();
- static void setFont(const QFont &);
-#ifdef QT3_SUPPORT
- static inline QT3_SUPPORT void add(QWidget *w, const QString &s) { w->setToolTip(s); }
- static inline QT3_SUPPORT void add(QWidget *w, const QRect &, const QString &s)
- { w->setToolTip(s); }
- static inline QT3_SUPPORT void remove(QWidget *w) { w->setToolTip(QString()); }
-#endif
-};
-
-#endif // QT_NO_TOOLTIP
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QTOOLTIP_H
diff --git a/src/gui/kernel/qwhatsthis.cpp b/src/gui/kernel/qwhatsthis.cpp
deleted file mode 100644
index 5e47ffa56b..0000000000
--- a/src/gui/kernel/qwhatsthis.cpp
+++ /dev/null
@@ -1,777 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwhatsthis.h"
-#ifndef QT_NO_WHATSTHIS
-#include "qpointer.h"
-#include "qapplication.h"
-#include "qdesktopwidget.h"
-#include "qevent.h"
-#include "qpixmap.h"
-#include "qpainter.h"
-#include "qtimer.h"
-#include "qhash.h"
-#include "qaction.h"
-#include "qcursor.h"
-#include "qbitmap.h"
-#include "qtextdocument.h"
-#include "../text/qtextdocumentlayout_p.h"
-#include "qtoolbutton.h"
-#include "qdebug.h"
-#ifndef QT_NO_ACCESSIBILITY
-#include "qaccessible.h"
-#endif
-#if defined(Q_WS_WIN)
-#include "qt_windows.h"
-#ifndef SPI_GETDROPSHADOW
-#define SPI_GETDROPSHADOW 0x1024
-#endif
-#endif
-#if defined(Q_WS_X11)
-#include "qx11info_x11.h"
-#include <qwidget.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QWhatsThis
- \brief The QWhatsThis class provides a simple description of any
- widget, i.e. answering the question "What's This?".
-
- \ingroup helpsystem
-
-
- "What's This?" help is part of an application's online help
- system, and provides users with information about the
- functionality and usage of a particular widget. "What's This?"
- help texts are typically longer and more detailed than \link
- QToolTip tooltips\endlink, but generally provide less information
- than that supplied by separate help windows.
-
- QWhatsThis provides a single window with an explanatory text that
- pops up when the user asks "What's This?". The default way for
- users to ask the question is to move the focus to the relevant
- widget and press Shift+F1. The help text appears immediately; it
- goes away as soon as the user does something else.
- (Note that if there is a shortcut for Shift+F1, this mechanism
- will not work.) Some dialogs provide a "?" button that users can
- click to enter "What's This?" mode; they then click the relevant
- widget to pop up the "What's This?" window. It is also possible to
- provide a a menu option or toolbar button to switch into "What's
- This?" mode.
-
- To add "What's This?" text to a widget or an action, you simply
- call QWidget::setWhatsThis() or QAction::setWhatsThis().
-
- The text can be either rich text or plain text. If you specify a
- rich text formatted string, it will be rendered using the default
- stylesheet, making it possible to embed images in the displayed
- text. To be as fast as possible, the default stylesheet uses a
- simple method to determine whether the text can be rendered as
- plain text. See Qt::mightBeRichText() for details.
-
- \snippet doc/src/snippets/whatsthis/whatsthis.cpp 0
-
- An alternative way to enter "What's This?" mode is to call
- createAction(), and add the returned QAction to either a menu or
- a tool bar. By invoking this context help action (in the picture
- below, the button with the arrow and question mark icon) the user
- switches into "What's This?" mode. If they now click on a widget
- the appropriate help text is shown. The mode is left when help is
- given or when the user presses Esc.
-
- \img whatsthis.png
-
- You can enter "What's This?" mode programmatically with
- enterWhatsThisMode(), check the mode with inWhatsThisMode(), and
- return to normal mode with leaveWhatsThisMode().
-
- If you want to control the "What's This?" behavior of a widget
- manually see Qt::WA_CustomWhatsThis.
-
- It is also possible to show different help texts for different
- regions of a widget, by using a QHelpEvent of type
- QEvent::WhatsThis. Intercept the help event in your widget's
- QWidget::event() function and call QWhatsThis::showText() with the
- text you want to display for the position specified in
- QHelpEvent::pos(). If the text is rich text and the user clicks
- on a link, the widget also receives a QWhatsThisClickedEvent with
- the link's reference as QWhatsThisClickedEvent::href(). If a
- QWhatsThisClickedEvent is handled (i.e. QWidget::event() returns
- true), the help window remains visible. Call
- QWhatsThis::hideText() to hide it explicitly.
-
- \sa QToolTip
-*/
-
-Q_CORE_EXPORT void qDeleteInEventHandler(QObject *o);
-
-class QWhatsThat : public QWidget
-{
- Q_OBJECT
-
-public:
- QWhatsThat(const QString& txt, QWidget* parent, QWidget *showTextFor);
- ~QWhatsThat() ;
-
- static QWhatsThat *instance;
-
-protected:
- void showEvent(QShowEvent *e);
- void mousePressEvent(QMouseEvent*);
- void mouseReleaseEvent(QMouseEvent*);
- void mouseMoveEvent(QMouseEvent*);
- void keyPressEvent(QKeyEvent*);
- void paintEvent(QPaintEvent*);
-
-private:
- QPointer<QWidget>widget;
- bool pressed;
- QString text;
- QTextDocument* doc;
- QString anchor;
- QPixmap background;
-};
-
-QWhatsThat *QWhatsThat::instance = 0;
-
-// shadowWidth not const, for XP drop-shadow-fu turns it to 0
-static int shadowWidth = 6; // also used as '5' and '6' and even '8' below
-static const int vMargin = 8;
-static const int hMargin = 12;
-
-QWhatsThat::QWhatsThat(const QString& txt, QWidget* parent, QWidget *showTextFor)
- : QWidget(parent, Qt::Popup),
- widget(showTextFor), pressed(false), text(txt)
-{
- delete instance;
- instance = this;
- setAttribute(Qt::WA_DeleteOnClose, true);
- setAttribute(Qt::WA_NoSystemBackground, true);
- if (parent)
- setPalette(parent->palette());
- setMouseTracking(true);
- setFocusPolicy(Qt::StrongFocus);
-#ifndef QT_NO_CURSOR
- setCursor(Qt::ArrowCursor);
-#endif
- QRect r;
- doc = 0;
- ensurePolished(); // Ensures style sheet font before size calc
- if (Qt::mightBeRichText(text)) {
- doc = new QTextDocument();
- doc->setUndoRedoEnabled(false);
- doc->setDefaultFont(QApplication::font(this));
-#ifdef QT_NO_TEXTHTMLPARSER
- doc->setPlainText(text);
-#else
- doc->setHtml(text);
-#endif
- doc->setUndoRedoEnabled(false);
- doc->adjustSize();
- r.setTop(0);
- r.setLeft(0);
- r.setSize(doc->size().toSize());
- }
- else
- {
- int sw = QApplication::desktop()->width() / 3;
- if (sw < 200)
- sw = 200;
- else if (sw > 300)
- sw = 300;
-
- r = fontMetrics().boundingRect(0, 0, sw, 1000,
- Qt::AlignLeft + Qt::AlignTop
- + Qt::TextWordWrap + Qt::TextExpandTabs,
- text);
- }
-#if defined(Q_WS_WIN)
- if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP
- && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based))
- {
- BOOL shadow;
- SystemParametersInfo(SPI_GETDROPSHADOW, 0, &shadow, 0);
- shadowWidth = shadow ? 0 : 6;
- }
-#endif
- resize(r.width() + 2*hMargin + shadowWidth, r.height() + 2*vMargin + shadowWidth);
-}
-
-QWhatsThat::~QWhatsThat()
-{
- instance = 0;
- if (doc)
- delete doc;
-}
-
-void QWhatsThat::showEvent(QShowEvent *)
-{
- background = QPixmap::grabWindow(QApplication::desktop()->internalWinId(),
- x(), y(), width(), height());
-}
-
-void QWhatsThat::mousePressEvent(QMouseEvent* e)
-{
- pressed = true;
- if (e->button() == Qt::LeftButton && rect().contains(e->pos())) {
- if (doc)
- anchor = doc->documentLayout()->anchorAt(e->pos() - QPoint(hMargin, vMargin));
- return;
- }
- close();
-}
-
-void QWhatsThat::mouseReleaseEvent(QMouseEvent* e)
-{
- if (!pressed)
- return;
- if (widget && e->button() == Qt::LeftButton && doc && rect().contains(e->pos())) {
- QString a = doc->documentLayout()->anchorAt(e->pos() - QPoint(hMargin, vMargin));
- QString href;
- if (anchor == a)
- href = a;
- anchor.clear();
- if (!href.isEmpty()) {
- QWhatsThisClickedEvent e(href);
- if (QApplication::sendEvent(widget, &e))
- return;
- }
- }
- close();
-}
-
-void QWhatsThat::mouseMoveEvent(QMouseEvent* e)
-{
-#ifdef QT_NO_CURSOR
- Q_UNUSED(e);
-#else
- if (!doc)
- return;
- QString a = doc->documentLayout()->anchorAt(e->pos() - QPoint(hMargin, vMargin));
- if (!a.isEmpty())
- setCursor(Qt::PointingHandCursor);
- else
- setCursor(Qt::ArrowCursor);
-#endif
-}
-
-void QWhatsThat::keyPressEvent(QKeyEvent*)
-{
- close();
-}
-
-void QWhatsThat::paintEvent(QPaintEvent*)
-{
- bool drawShadow = true;
-#if defined(Q_WS_WIN)
- if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP
- && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based))
- {
- BOOL shadow;
- SystemParametersInfo(SPI_GETDROPSHADOW, 0, &shadow, 0);
- drawShadow = !shadow;
- }
-#elif defined(Q_WS_MAC) || defined(Q_WS_QWS)
- drawShadow = false; // never draw it on OS X or QWS, as we get it for free
-#endif
-
- QRect r = rect();
- r.adjust(0, 0, -1, -1);
- if (drawShadow)
- r.adjust(0, 0, -shadowWidth, -shadowWidth);
- QPainter p(this);
- p.drawPixmap(0, 0, background);
- p.setPen(QPen(palette().toolTipText(), 0));
- p.setBrush(palette().toolTipBase());
- p.drawRect(r);
- int w = r.width();
- int h = r.height();
- p.setPen(palette().brush(QPalette::Dark).color());
- p.drawRect(1, 1, w-2, h-2);
- if (drawShadow) {
- p.setPen(palette().shadow().color());
- p.drawPoint(w + 5, 6);
- p.drawLine(w + 3, 6, w + 5, 8);
- p.drawLine(w + 1, 6, w + 5, 10);
- int i;
- for(i=7; i < h; i += 2)
- p.drawLine(w, i, w + 5, i + 5);
- for(i = w - i + h; i > 6; i -= 2)
- p.drawLine(i, h, i + 5, h + 5);
- for(; i > 0 ; i -= 2)
- p.drawLine(6, h + 6 - i, i + 5, h + 5);
- }
- r.adjust(0, 0, 1, 1);
- p.setPen(palette().toolTipText().color());
- r.adjust(hMargin, vMargin, -hMargin, -vMargin);
-
- if (doc) {
- p.translate(r.x(), r.y());
- QRect rect = r;
- rect.translate(-r.x(), -r.y());
- p.setClipRect(rect);
- QAbstractTextDocumentLayout::PaintContext context;
- context.palette.setBrush(QPalette::Text, context.palette.toolTipText());
- doc->documentLayout()->draw(&p, context);
- }
- else
- {
- p.drawText(r, Qt::AlignLeft + Qt::AlignTop + Qt::TextWordWrap + Qt::TextExpandTabs, text);
- }
-}
-
-static const char * const button_image[] = {
-"16 16 3 1",
-" c None",
-"o c #000000",
-"a c #000080",
-"o aaaaa ",
-"oo aaa aaa ",
-"ooo aaa aaa",
-"oooo aa aa",
-"ooooo aa aa",
-"oooooo a aaa",
-"ooooooo aaa ",
-"oooooooo aaa ",
-"ooooooooo aaa ",
-"ooooo aaa ",
-"oo ooo ",
-"o ooo aaa ",
-" ooo aaa ",
-" ooo ",
-" ooo ",
-" ooo "};
-
-class QWhatsThisPrivate : public QObject
-{
- public:
- QWhatsThisPrivate();
- ~QWhatsThisPrivate();
- static QWhatsThisPrivate *instance;
- bool eventFilter(QObject *, QEvent *);
- QPointer<QAction> action;
-#ifdef QT3_SUPPORT
- QPointer<QToolButton> button;
-#endif
- static void say(QWidget *, const QString &, int x = 0, int y = 0);
- static void notifyToplevels(QEvent *e);
- bool leaveOnMouseRelease;
-};
-
-void QWhatsThisPrivate::notifyToplevels(QEvent *e)
-{
- QWidgetList toplevels = QApplication::topLevelWidgets();
- for (int i = 0; i < toplevels.count(); ++i) {
- register QWidget *w = toplevels.at(i);
- QApplication::sendEvent(w, e);
- }
-}
-
-QWhatsThisPrivate *QWhatsThisPrivate::instance = 0;
-
-QWhatsThisPrivate::QWhatsThisPrivate()
- : leaveOnMouseRelease(false)
-{
- instance = this;
- qApp->installEventFilter(this);
-
- QPoint pos = QCursor::pos();
- if (QWidget *w = QApplication::widgetAt(pos)) {
- QHelpEvent e(QEvent::QueryWhatsThis, w->mapFromGlobal(pos), pos);
- bool sentEvent = QApplication::sendEvent(w, &e);
-#ifdef QT_NO_CURSOR
- Q_UNUSED(sentEvent);
-#else
- QApplication::setOverrideCursor((!sentEvent || !e.isAccepted())?
- Qt::ForbiddenCursor:Qt::WhatsThisCursor);
- } else {
- QApplication::setOverrideCursor(Qt::WhatsThisCursor);
-#endif
- }
-#ifndef QT_NO_ACCESSIBILITY
- QAccessible::updateAccessibility(this, 0, QAccessible::ContextHelpStart);
-#endif
-}
-
-QWhatsThisPrivate::~QWhatsThisPrivate()
-{
- if (action)
- action->setChecked(false);
-#ifdef QT3_SUPPORT
- if (button)
- button->setChecked(false);
-#endif
-#ifndef QT_NO_CURSOR
- QApplication::restoreOverrideCursor();
-#endif
-#ifndef QT_NO_ACCESSIBILITY
- QAccessible::updateAccessibility(this, 0, QAccessible::ContextHelpEnd);
-#endif
- instance = 0;
-}
-
-bool QWhatsThisPrivate::eventFilter(QObject *o, QEvent *e)
-{
- if (!o->isWidgetType())
- return false;
- QWidget * w = static_cast<QWidget *>(o);
- bool customWhatsThis = w->testAttribute(Qt::WA_CustomWhatsThis);
- switch (e->type()) {
- case QEvent::MouseButtonPress:
- {
- QMouseEvent *me = static_cast<QMouseEvent*>(e);
- if (me->button() == Qt::RightButton || customWhatsThis)
- return false;
- QHelpEvent e(QEvent::WhatsThis, me->pos(), me->globalPos());
- if (!QApplication::sendEvent(w, &e) || !e.isAccepted())
- leaveOnMouseRelease = true;
-
- } break;
-
- case QEvent::MouseMove:
- {
- QMouseEvent *me = static_cast<QMouseEvent*>(e);
- QHelpEvent e(QEvent::QueryWhatsThis, me->pos(), me->globalPos());
- bool sentEvent = QApplication::sendEvent(w, &e);
-#ifdef QT_NO_CURSOR
- Q_UNUSED(sentEvent);
-#else
- QApplication::changeOverrideCursor((!sentEvent || !e.isAccepted())?
- Qt::ForbiddenCursor:Qt::WhatsThisCursor);
-#endif
- }
- // fall through
- case QEvent::MouseButtonRelease:
- case QEvent::MouseButtonDblClick:
- if (leaveOnMouseRelease && e->type() == QEvent::MouseButtonRelease)
- QWhatsThis::leaveWhatsThisMode();
- if (static_cast<QMouseEvent*>(e)->button() == Qt::RightButton || customWhatsThis)
- return false; // ignore RMB release
- break;
- case QEvent::KeyPress:
- {
- QKeyEvent* kev = (QKeyEvent*)e;
-
- if (kev->key() == Qt::Key_Escape) {
- QWhatsThis::leaveWhatsThisMode();
- return true;
- } else if (customWhatsThis) {
- return false;
- } else if (kev->key() == Qt::Key_Menu ||
- (kev->key() == Qt::Key_F10 &&
- kev->modifiers() == Qt::ShiftModifier)) {
- // we don't react to these keys, they are used for context menus
- return false;
- } else if (kev->key() != Qt::Key_Shift && kev->key() != Qt::Key_Alt // not a modifier key
- && kev->key() != Qt::Key_Control && kev->key() != Qt::Key_Meta) {
- QWhatsThis::leaveWhatsThisMode();
- }
- } break;
- default:
- return false;
- }
- return true;
-}
-
-class QWhatsThisAction: public QAction
-{
- Q_OBJECT
-
-public:
- explicit QWhatsThisAction(QObject* parent = 0);
-
-private slots:
- void actionTriggered();
-};
-
-QWhatsThisAction::QWhatsThisAction(QObject *parent) : QAction(tr("What's This?"), parent)
-{
-#ifndef QT_NO_IMAGEFORMAT_XPM
- QPixmap p((const char**)button_image);
- setIcon(p);
-#endif
- setCheckable(true);
- connect(this, SIGNAL(triggered()), this, SLOT(actionTriggered()));
-#ifndef QT_NO_SHORTCUT
- setShortcut(Qt::ShiftModifier + Qt::Key_F1);
-#endif
-}
-
-void QWhatsThisAction::actionTriggered()
-{
- if (isChecked()) {
- QWhatsThis::enterWhatsThisMode();
- QWhatsThisPrivate::instance->action = this;
- }
-}
-
-QWhatsThis::QWhatsThis()
-{
-}
-
-#ifdef QT3_SUPPORT
-/*!
- \obsolete
-
- Sets the What's This text \a s for the widget \a w.
-
- Use QWidget::setWhatsThis() or QAction::setWhatsThis() instead.
-*/
-void QWhatsThis::add(QWidget *w, const QString &s)
-{
- w->setWhatsThis(s);
-}
-
-/*!
- \obsolete
-
- Remove's the What's This text for the widget \a w.
-
- Use QWidget::setWhatsThis() or QAction::setWhatsThis() instead.
-*/
-void QWhatsThis::remove(QWidget *w)
-{
- w->setWhatsThis(QString());
-}
-
-class QWhatsThisButton : public QToolButton
-{
- Q_OBJECT
-public:
- QWhatsThisButton(QWidget *p) : QToolButton(p) {
- setCheckable(true);
- QPixmap pix( const_cast<const char**>(button_image) );
- setIcon( pix );
- QObject::connect(this, SIGNAL(toggled(bool)), this, SLOT(whatToggled(bool)));
- setAutoRaise(true);
- setFocusPolicy(Qt::NoFocus);
- }
-
-public slots:
- void whatToggled(bool b) {
- if (b) {
- QWhatsThis::enterWhatsThisMode();
- QWhatsThisPrivate::instance->button = this;
- }
- }
-};
-
-/*!
- Returns a new "What's This?" QToolButton with the given \a
- parent. To do this now, create your own QToolButton and a
- QWhatsThis object and call the QWhatsThis object's showText()
- function when the QToolButton is invoked.
-
- Use createAction() instead.
-*/
-QToolButton * QWhatsThis::whatsThisButton(QWidget * parent)
-{
- return new QWhatsThisButton(parent);
-}
-#endif
-
-/*!
- This function switches the user interface into "What's This?"
- mode. The user interface can be switched back into normal mode by
- the user (e.g. by them clicking or pressing Esc), or
- programmatically by calling leaveWhatsThisMode().
-
- When entering "What's This?" mode, a QEvent of type
- Qt::EnterWhatsThisMode is sent to all toplevel widgets.
-
- \sa inWhatsThisMode() leaveWhatsThisMode()
-*/
-void QWhatsThis::enterWhatsThisMode()
-{
- if (QWhatsThisPrivate::instance)
- return;
- (void) new QWhatsThisPrivate;
- QEvent e(QEvent::EnterWhatsThisMode);
- QWhatsThisPrivate::notifyToplevels(&e);
- }
-
-/*!
- Returns true if the user interface is in "What's This?" mode;
- otherwise returns false.
-
- \sa enterWhatsThisMode()
-*/
-bool QWhatsThis::inWhatsThisMode()
-{
- return (QWhatsThisPrivate::instance != 0);
-}
-
-/*!
- If the user interface is in "What's This?" mode, this function
- switches back to normal mode; otherwise it does nothing.
-
- When leaving "What's This?" mode, a QEvent of type
- Qt::LeaveWhatsThisMode is sent to all toplevel widgets.
-
- \sa enterWhatsThisMode() inWhatsThisMode()
-*/
-void QWhatsThis::leaveWhatsThisMode()
-{
- delete QWhatsThisPrivate::instance;
- QEvent e(QEvent::LeaveWhatsThisMode);
- QWhatsThisPrivate::notifyToplevels(&e);
-}
-
-void QWhatsThisPrivate::say(QWidget * widget, const QString &text, int x, int y)
-{
- if (text.size() == 0)
- return;
- // make a fresh widget, and set it up
- QWhatsThat *whatsThat = new QWhatsThat(
- text,
-#if defined(Q_WS_X11) && !defined(QT_NO_CURSOR)
- QApplication::desktop()->screen(widget ? widget->x11Info().screen() : QCursor::x11Screen()),
-#else
- 0,
-#endif
- widget
- );
-
-
- // okay, now to find a suitable location
-
- int scr = (widget ?
- QApplication::desktop()->screenNumber(widget) :
-#if defined(Q_WS_X11) && !defined(QT_NO_CURSOR)
- QCursor::x11Screen()
-#else
- QApplication::desktop()->screenNumber(QPoint(x,y))
-#endif // Q_WS_X11
- );
- QRect screen = QApplication::desktop()->screenGeometry(scr);
-
- int w = whatsThat->width();
- int h = whatsThat->height();
- int sx = screen.x();
- int sy = screen.y();
-
- // first try locating the widget immediately above/below,
- // with nice alignment if possible.
- QPoint pos;
- if (widget)
- pos = widget->mapToGlobal(QPoint(0,0));
-
- if (widget && w > widget->width() + 16)
- x = pos.x() + widget->width()/2 - w/2;
- else
- x = x - w/2;
-
- // squeeze it in if that would result in part of what's this
- // being only partially visible
- if (x + w + shadowWidth > sx+screen.width())
- x = (widget? (qMin(screen.width(),
- pos.x() + widget->width())
- ) : screen.width())
- - w;
-
- if (x < sx)
- x = sx;
-
- if (widget && h > widget->height() + 16) {
- y = pos.y() + widget->height() + 2; // below, two pixels spacing
- // what's this is above or below, wherever there's most space
- if (y + h + 10 > sy+screen.height())
- y = pos.y() + 2 - shadowWidth - h; // above, overlap
- }
- y = y + 2;
-
- // squeeze it in if that would result in part of what's this
- // being only partially visible
- if (y + h + shadowWidth > sy+screen.height())
- y = (widget ? (qMin(screen.height(),
- pos.y() + widget->height())
- ) : screen.height())
- - h;
- if (y < sy)
- y = sy;
-
- whatsThat->move(x, y);
- whatsThat->show();
- whatsThat->grabKeyboard();
-}
-
-/*!
- Shows \a text as a "What's This?" window, at global position \a
- pos. The optional widget argument, \a w, is used to determine the
- appropriate screen on multi-head systems.
-
- \sa hideText()
-*/
-void QWhatsThis::showText(const QPoint &pos, const QString &text, QWidget *w)
-{
- leaveWhatsThisMode();
- QWhatsThisPrivate::say(w, text, pos.x(), pos.y());
-}
-
-/*!
- If a "What's This?" window is showing, this destroys it.
-
- \sa showText()
-*/
-void QWhatsThis::hideText()
-{
- qDeleteInEventHandler(QWhatsThat::instance);
-}
-
-/*!
- Returns a ready-made QAction, used to invoke "What's This?" context
- help, with the given \a parent.
-
- The returned QAction provides a convenient way to let users enter
- "What's This?" mode.
-*/
-QAction *QWhatsThis::createAction(QObject *parent)
-{
- return new QWhatsThisAction(parent);
-}
-
-QT_END_NAMESPACE
-
-#include "qwhatsthis.moc"
-
-#endif // QT_NO_WHATSTHIS
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
deleted file mode 100644
index 434a788b89..0000000000
--- a/src/gui/kernel/qwidget.cpp
+++ /dev/null
@@ -1,12684 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qapplication.h"
-#include "qapplication_p.h"
-#include "qbrush.h"
-#include "qcursor.h"
-#include "qdesktopwidget.h"
-#include "qevent.h"
-#include "qhash.h"
-#include "qlayout.h"
-#include "qmenu.h"
-#include "qmetaobject.h"
-#include "qpixmap.h"
-#include "qpointer.h"
-#include "qstack.h"
-#include "qstyle.h"
-#include "qstylefactory.h"
-#include "qvariant.h"
-#include "qwidget.h"
-#include "qstyleoption.h"
-#ifndef QT_NO_ACCESSIBILITY
-# include "qaccessible.h"
-#endif
-#if defined(Q_WS_WIN)
-# include "qt_windows.h"
-#endif
-#ifdef Q_WS_MAC
-# include "qt_mac_p.h"
-# include "qt_cocoa_helpers_mac_p.h"
-# include "qmainwindow.h"
-# include "qtoolbar.h"
-# include <private/qmainwindowlayout_p.h>
-#endif
-#if defined(Q_WS_QWS)
-# include "qwsdisplay_qws.h"
-# include "qwsmanager_qws.h"
-# include "qpaintengine.h" // for PorterDuff
-# include "private/qwindowsurface_qws_p.h"
-#endif
-#if defined(Q_WS_QPA)
-#include "qplatformwindow_qpa.h"
-#endif
-#include "qpainter.h"
-#include "qtooltip.h"
-#include "qwhatsthis.h"
-#include "qdebug.h"
-#include "private/qstylesheetstyle_p.h"
-#include "private/qstyle_p.h"
-#include "private/qinputcontext_p.h"
-#include "qfileinfo.h"
-#include "private/qsoftkeymanager_p.h"
-
-#if defined (Q_WS_WIN)
-# include <private/qwininputcontext_p.h>
-#endif
-
-#if defined(Q_WS_X11)
-# include <private/qpaintengine_x11_p.h>
-# include "qx11info_x11.h"
-#endif
-
-#include <private/qgraphicseffect_p.h>
-#include <private/qwindowsurface_p.h>
-#include <private/qbackingstore_p.h>
-#ifdef Q_WS_MAC
-# include <private/qpaintengine_mac_p.h>
-#endif
-#include <private/qpaintengine_raster_p.h>
-
-#if defined(Q_OS_SYMBIAN)
-#include "private/qt_s60_p.h"
-#endif
-
-#include "qwidget_p.h"
-#include "qaction_p.h"
-#include "qlayout_p.h"
-#include "QtGui/qgraphicsproxywidget.h"
-#include "QtGui/qgraphicsscene.h"
-#include "private/qgraphicsproxywidget_p.h"
-#include "QtGui/qabstractscrollarea.h"
-#include "private/qabstractscrollarea_p.h"
-#include "private/qevent_p.h"
-
-#include "private/qgraphicssystem_p.h"
-#include "private/qgesturemanager_p.h"
-
-#ifdef QT_KEYPAD_NAVIGATION
-#include "qtabwidget.h" // Needed in inTabWidget()
-#endif // QT_KEYPAD_NAVIGATION
-
-#ifdef Q_WS_S60
-#include <aknappui.h>
-#endif
-
-// widget/widget data creation count
-//#define QWIDGET_EXTRA_DEBUG
-//#define ALIEN_DEBUG
-
-QT_BEGIN_NAMESPACE
-
-#if !defined(Q_WS_QWS)
-static bool qt_enable_backingstore = true;
-#endif
-#ifdef Q_WS_X11
-// for compatibility with Qt 4.0
-Q_GUI_EXPORT void qt_x11_set_global_double_buffer(bool enable)
-{
- qt_enable_backingstore = enable;
-}
-#endif
-
-#if defined(QT_MAC_USE_COCOA)
-bool qt_mac_clearDirtyOnWidgetInsideDrawWidget = false;
-#endif
-
-static inline bool qRectIntersects(const QRect &r1, const QRect &r2)
-{
- return (qMax(r1.left(), r2.left()) <= qMin(r1.right(), r2.right()) &&
- qMax(r1.top(), r2.top()) <= qMin(r1.bottom(), r2.bottom()));
-}
-
-static inline bool hasBackingStoreSupport()
-{
-#ifdef Q_WS_MAC
- return QApplicationPrivate::graphicsSystem() != 0;
-#else
- return true;
-#endif
-}
-
-#ifdef Q_WS_MAC
-# define QT_NO_PAINT_DEBUG
-#endif
-
-extern bool qt_sendSpontaneousEvent(QObject*, QEvent*); // qapplication.cpp
-extern QDesktopWidget *qt_desktopWidget; // qapplication.cpp
-
-/*!
- \internal
- \class QWidgetBackingStoreTracker
- \brief Class which allows tracking of which widgets are using a given backing store
-
- QWidgetBackingStoreTracker is a thin wrapper around a QWidgetBackingStore pointer,
- which maintains a list of the QWidgets which are currently using the backing
- store. This list is modified via the registerWidget and unregisterWidget functions.
- */
-
-QWidgetBackingStoreTracker::QWidgetBackingStoreTracker()
- : m_ptr(0)
-{
-
-}
-
-QWidgetBackingStoreTracker::~QWidgetBackingStoreTracker()
-{
- delete m_ptr;
-}
-
-/*!
- \internal
- Destroy the contained QWidgetBackingStore, if not null, and clear the list of
- widgets using the backing store, then create a new QWidgetBackingStore, providing
- the QWidget.
- */
-void QWidgetBackingStoreTracker::create(QWidget *widget)
-{
- destroy();
- m_ptr = new QWidgetBackingStore(widget);
-}
-
-/*!
- \internal
- Destroy the contained QWidgetBackingStore, if not null, and clear the list of
- widgets using the backing store.
- */
-void QWidgetBackingStoreTracker::destroy()
-{
- delete m_ptr;
- m_ptr = 0;
- m_widgets.clear();
-}
-
-/*!
- \internal
- Add the widget to the list of widgets currently using the backing store.
- If the widget was already in the list, this function is a no-op.
- */
-void QWidgetBackingStoreTracker::registerWidget(QWidget *w)
-{
- Q_ASSERT(m_ptr);
- Q_ASSERT(w->internalWinId());
- Q_ASSERT(qt_widget_private(w)->maybeBackingStore() == m_ptr);
- m_widgets.insert(w);
-}
-
-/*!
- \internal
- Remove the widget from the list of widgets currently using the backing store.
- If the widget was in the list, and removing it causes the list to be empty,
- the backing store is deleted.
- If the widget was not in the list, this function is a no-op.
- */
-void QWidgetBackingStoreTracker::unregisterWidget(QWidget *w)
-{
- if (m_widgets.remove(w) && m_widgets.isEmpty()) {
- delete m_ptr;
- m_ptr = 0;
- }
-}
-
-/*!
- \internal
- Recursively remove widget and all of its descendents.
- */
-void QWidgetBackingStoreTracker::unregisterWidgetSubtree(QWidget *widget)
-{
- unregisterWidget(widget);
- foreach (QObject *child, widget->children())
- if (QWidget *childWidget = qobject_cast<QWidget *>(child))
- unregisterWidgetSubtree(childWidget);
-}
-
-QWidgetPrivate::QWidgetPrivate(int version)
- : QObjectPrivate(version)
- , extra(0)
- , focus_next(0)
- , focus_prev(0)
- , focus_child(0)
- , layout(0)
- , needsFlush(0)
- , redirectDev(0)
- , widgetItem(0)
- , extraPaintEngine(0)
- , polished(0)
- , graphicsEffect(0)
-#if !defined(QT_NO_IM)
- , imHints(Qt::ImhNone)
-#endif
- , inheritedFontResolveMask(0)
- , inheritedPaletteResolveMask(0)
- , leftmargin(0)
- , topmargin(0)
- , rightmargin(0)
- , bottommargin(0)
- , leftLayoutItemMargin(0)
- , topLayoutItemMargin(0)
- , rightLayoutItemMargin(0)
- , bottomLayoutItemMargin(0)
- , hd(0)
- , size_policy(QSizePolicy::Preferred, QSizePolicy::Preferred)
- , fg_role(QPalette::NoRole)
- , bg_role(QPalette::NoRole)
- , dirtyOpaqueChildren(1)
- , isOpaque(0)
- , inDirtyList(0)
- , isScrolled(0)
- , isMoved(0)
- , isGLWidget(0)
- , usesDoubleBufferedGLContext(0)
-#ifndef QT_NO_IM
- , inheritsInputMethodHints(0)
-#endif
-#if defined(Q_WS_X11)
- , picture(0)
-#elif defined(Q_WS_WIN)
- , noPaintOnScreen(0)
- #ifndef QT_NO_GESTURES
- , nativeGesturePanEnabled(0)
- #endif
-#elif defined(Q_WS_MAC)
- , needWindowChange(0)
- , window_event(0)
- , qd_hd(0)
-#elif defined(Q_OS_SYMBIAN)
- , symbianScreenNumber(0)
- , fixNativeOrientationCalled(false)
-#endif
-{
- if (!qApp) {
- qFatal("QWidget: Must construct a QApplication before a QPaintDevice");
- return;
- }
-
- if (version != QObjectPrivateVersion)
- qFatal("Cannot mix incompatible Qt libraries");
-
- isWidget = true;
- memset(high_attributes, 0, sizeof(high_attributes));
-#if QT_MAC_USE_COCOA
- drawRectOriginalAdded = false;
- originalDrawMethod = true;
- changeMethods = false;
- isInUnifiedToolbar = false;
- unifiedSurface = 0;
- toolbar_ancestor = 0;
- flushRequested = false;
- touchEventsEnabled = false;
-#endif // QT_MAC_USE_COCOA
-#ifdef QWIDGET_EXTRA_DEBUG
- static int count = 0;
- qDebug() << "widgets" << ++count;
-#endif
-}
-
-
-QWidgetPrivate::~QWidgetPrivate()
-{
- if (widgetItem)
- widgetItem->wid = 0;
-
- if (extra)
- deleteExtra();
-
-#ifndef QT_NO_GRAPHICSEFFECT
- delete graphicsEffect;
-#endif //QT_NO_GRAPHICSEFFECT
-}
-
-class QDummyWindowSurface : public QWindowSurface
-{
-public:
- QDummyWindowSurface(QWidget *window) : QWindowSurface(window) {}
- QPaintDevice *paintDevice() { return window(); }
- void flush(QWidget *, const QRegion &, const QPoint &) {}
-};
-
-QWindowSurface *QWidgetPrivate::createDefaultWindowSurface()
-{
- Q_Q(QWidget);
-
- QWindowSurface *surface;
-#ifndef QT_NO_PROPERTIES
- if (q->property("_q_DummyWindowSurface").toBool()) {
- surface = new QDummyWindowSurface(q);
- } else
-#endif
- {
- if (QApplicationPrivate::graphicsSystem())
- surface = QApplicationPrivate::graphicsSystem()->createWindowSurface(q);
- else
- surface = createDefaultWindowSurface_sys();
- }
-
- return surface;
-}
-
-/*!
- \internal
-*/
-void QWidgetPrivate::scrollChildren(int dx, int dy)
-{
- Q_Q(QWidget);
- if (q->children().size() > 0) { // scroll children
- QPoint pd(dx, dy);
- QObjectList childObjects = q->children();
- for (int i = 0; i < childObjects.size(); ++i) { // move all children
- QWidget *w = qobject_cast<QWidget*>(childObjects.at(i));
- if (w && !w->isWindow()) {
- QPoint oldp = w->pos();
- QRect r(w->pos() + pd, w->size());
- w->data->crect = r;
-#ifndef Q_WS_QWS
- if (w->testAttribute(Qt::WA_WState_Created))
- w->d_func()->setWSGeometry();
-#endif
- w->d_func()->setDirtyOpaqueRegion();
- QMoveEvent e(r.topLeft(), oldp);
- QApplication::sendEvent(w, &e);
- }
- }
- }
-}
-
-QInputContext *QWidgetPrivate::assignedInputContext() const
-{
-#ifndef QT_NO_IM
- const QWidget *widget = q_func();
- while (widget) {
- if (QInputContext *qic = widget->d_func()->ic)
- return qic;
- widget = widget->parentWidget();
- }
-#endif
- return 0;
-}
-
-QInputContext *QWidgetPrivate::inputContext() const
-{
-#ifndef QT_NO_IM
- if (QInputContext *qic = assignedInputContext())
- return qic;
- return qApp->inputContext();
-#else
- return 0;
-#endif
-}
-
-/*!
- This function returns the QInputContext for this widget. By
- default the input context is inherited from the widgets
- parent. For toplevels it is inherited from QApplication.
-
- You can override this and set a special input context for this
- widget by using the setInputContext() method.
-
- \sa setInputContext()
-*/
-QInputContext *QWidget::inputContext()
-{
- Q_D(QWidget);
- if (!testAttribute(Qt::WA_InputMethodEnabled))
- return 0;
-
- return d->inputContext();
-}
-
-/*!
- This function sets the input context \a context
- on this widget.
-
- Qt takes ownership of the given input \a context.
-
- \sa inputContext()
-*/
-void QWidget::setInputContext(QInputContext *context)
-{
- Q_D(QWidget);
- if (!testAttribute(Qt::WA_InputMethodEnabled))
- return;
-#ifndef QT_NO_IM
- if (context == d->ic)
- return;
- if (d->ic)
- delete d->ic;
- d->ic = context;
- if (d->ic)
- d->ic->setParent(this);
-#endif
-}
-
-
-/*!
- \obsolete
-
- This function can be called on the widget that currently has focus
- to reset the input method operating on it.
-
- This function is providing for convenience, instead you should use
- \l{QInputContext::}{reset()} on the input context that was
- returned by inputContext().
-
- \sa QInputContext, inputContext(), QInputContext::reset()
-*/
-void QWidget::resetInputContext()
-{
- if (!hasFocus())
- return;
-#ifndef QT_NO_IM
- QInputContext *qic = this->inputContext();
- if(qic)
- qic->reset();
-#endif // QT_NO_IM
-}
-
-#ifdef QT_KEYPAD_NAVIGATION
-QPointer<QWidget> QWidgetPrivate::editingWidget;
-
-/*!
- Returns true if this widget currently has edit focus; otherwise false.
-
- This feature is only available in Qt for Embedded Linux.
-
- \sa setEditFocus(), QApplication::keypadNavigationEnabled()
-*/
-bool QWidget::hasEditFocus() const
-{
- const QWidget* w = this;
- while (w->d_func()->extra && w->d_func()->extra->focus_proxy)
- w = w->d_func()->extra->focus_proxy;
- return QWidgetPrivate::editingWidget == w;
-}
-
-/*!
- \fn void QWidget::setEditFocus(bool enable)
-
- If \a enable is true, make this widget have edit focus, in which
- case Qt::Key_Up and Qt::Key_Down will be delivered to the widget
- normally; otherwise, Qt::Key_Up and Qt::Key_Down are used to
- change focus.
-
- This feature is only available in Qt for Embedded Linux and Qt
- for Symbian.
-
- \sa hasEditFocus(), QApplication::keypadNavigationEnabled()
-*/
-void QWidget::setEditFocus(bool on)
-{
- QWidget *f = this;
- while (f->d_func()->extra && f->d_func()->extra->focus_proxy)
- f = f->d_func()->extra->focus_proxy;
-
- if (QWidgetPrivate::editingWidget && QWidgetPrivate::editingWidget != f)
- QWidgetPrivate::editingWidget->setEditFocus(false);
-
- if (on && !f->hasFocus())
- f->setFocus();
-
- if ((!on && !QWidgetPrivate::editingWidget)
- || (on && QWidgetPrivate::editingWidget == f)) {
- return;
- }
-
- if (!on && QWidgetPrivate::editingWidget == f) {
- QWidgetPrivate::editingWidget = 0;
- QEvent event(QEvent::LeaveEditFocus);
- QApplication::sendEvent(f, &event);
- QApplication::sendEvent(f->style(), &event);
- } else if (on) {
- QWidgetPrivate::editingWidget = f;
- QEvent event(QEvent::EnterEditFocus);
- QApplication::sendEvent(f, &event);
- QApplication::sendEvent(f->style(), &event);
- }
-}
-#endif
-
-/*!
- \property QWidget::autoFillBackground
- \brief whether the widget background is filled automatically
- \since 4.1
-
- If enabled, this property will cause Qt to fill the background of the
- widget before invoking the paint event. The color used is defined by the
- QPalette::Window color role from the widget's \l{QPalette}{palette}.
-
- In addition, Windows are always filled with QPalette::Window, unless the
- WA_OpaquePaintEvent or WA_NoSystemBackground attributes are set.
-
- This property cannot be turned off (i.e., set to false) if a widget's
- parent has a static gradient for its background.
-
- \warning Use this property with caution in conjunction with
- \l{Qt Style Sheets}. When a widget has a style sheet with a valid
- background or a border-image, this property is automatically disabled.
-
- By default, this property is false.
-
- \sa Qt::WA_OpaquePaintEvent, Qt::WA_NoSystemBackground,
- {QWidget#Transparency and Double Buffering}{Transparency and Double Buffering}
-*/
-bool QWidget::autoFillBackground() const
-{
- Q_D(const QWidget);
- return d->extra && d->extra->autoFillBackground;
-}
-
-void QWidget::setAutoFillBackground(bool enabled)
-{
- Q_D(QWidget);
- if (!d->extra)
- d->createExtra();
- if (d->extra->autoFillBackground == enabled)
- return;
-
- d->extra->autoFillBackground = enabled;
- d->updateIsOpaque();
- update();
- d->updateIsOpaque();
-}
-
-/*!
- \class QWidget
- \brief The QWidget class is the base class of all user interface objects.
-
- \ingroup basicwidgets
-
- The widget is the atom of the user interface: it receives mouse, keyboard
- and other events from the window system, and paints a representation of
- itself on the screen. Every widget is rectangular, and they are sorted in a
- Z-order. A widget is clipped by its parent and by the widgets in front of
- it.
-
- A widget that is not embedded in a parent widget is called a window.
- Usually, windows have a frame and a title bar, although it is also possible
- to create windows without such decoration using suitable
- \l{Qt::WindowFlags}{window flags}). In Qt, QMainWindow and the various
- subclasses of QDialog are the most common window types.
-
- Every widget's constructor accepts one or two standard arguments:
-
- \list 1
- \i \c{QWidget *parent = 0} is the parent of the new widget. If it is 0
- (the default), the new widget will be a window. If not, it will be
- a child of \e parent, and be constrained by \e parent's geometry
- (unless you specify Qt::Window as window flag).
- \i \c{Qt::WindowFlags f = 0} (where available) sets the window flags;
- the default is suitable for almost all widgets, but to get, for
- example, a window without a window system frame, you must use
- special flags.
- \endlist
-
- QWidget has many member functions, but some of them have little direct
- functionality; for example, QWidget has a font property, but never uses
- this itself. There are many subclasses which provide real functionality,
- such as QLabel, QPushButton, QListWidget, and QTabWidget.
-
-
- \section1 Top-Level and Child Widgets
-
- A widget without a parent widget is always an independent window (top-level
- widget). For these widgets, setWindowTitle() and setWindowIcon() set the
- title bar and icon respectively.
-
- Non-window widgets are child widgets, displayed within their parent
- widgets. Most widgets in Qt are mainly useful as child widgets. For
- example, it is possible to display a button as a top-level window, but most
- people prefer to put their buttons inside other widgets, such as QDialog.
-
- \image parent-child-widgets.png A parent widget containing various child widgets.
-
- The diagram above shows a QGroupBox widget being used to hold various child
- widgets in a layout provided by QGridLayout. The QLabel child widgets have
- been outlined to indicate their full sizes.
-
- If you want to use a QWidget to hold child widgets you will usually want to
- add a layout to the parent QWidget. See \l{Layout Management} for more
- information.
-
-
- \section1 Composite Widgets
-
- When a widget is used as a container to group a number of child widgets, it
- is known as a composite widget. These can be created by constructing a
- widget with the required visual properties - a QFrame, for example - and
- adding child widgets to it, usually managed by a layout. The above diagram
- shows such a composite widget that was created using \l{Qt Designer}.
-
- Composite widgets can also be created by subclassing a standard widget,
- such as QWidget or QFrame, and adding the necessary layout and child
- widgets in the constructor of the subclass. Many of the \l{Qt Examples}
- {examples provided with Qt} use this approach, and it is also covered in
- the Qt \l{Tutorials}.
-
-
- \section1 Custom Widgets and Painting
-
- Since QWidget is a subclass of QPaintDevice, subclasses can be used to
- display custom content that is composed using a series of painting
- operations with an instance of the QPainter class. This approach contrasts
- with the canvas-style approach used by the \l{Graphics View}
- {Graphics View Framework} where items are added to a scene by the
- application and are rendered by the framework itself.
-
- Each widget performs all painting operations from within its paintEvent()
- function. This is called whenever the widget needs to be redrawn, either
- as a result of some external change or when requested by the application.
-
- The \l{widgets/analogclock}{Analog Clock example} shows how a simple widget
- can handle paint events.
-
-
- \section1 Size Hints and Size Policies
-
- When implementing a new widget, it is almost always useful to reimplement
- sizeHint() to provide a reasonable default size for the widget and to set
- the correct size policy with setSizePolicy().
-
- By default, composite widgets which do not provide a size hint will be
- sized according to the space requirements of their child widgets.
-
- The size policy lets you supply good default behavior for the layout
- management system, so that other widgets can contain and manage yours
- easily. The default size policy indicates that the size hint represents
- the preferred size of the widget, and this is often good enough for many
- widgets.
-
- \note The size of top-level widgets are constrained to 2/3 of the desktop's
- height and width. You can resize() the widget manually if these bounds are
- inadequate.
-
-
- \section1 Events
-
- Widgets respond to events that are typically caused by user actions. Qt
- delivers events to widgets by calling specific event handler functions with
- instances of QEvent subclasses containing information about each event.
-
- If your widget only contains child widgets, you probably do not need to
- implement any event handlers. If you want to detect a mouse click in a
- child widget call the child's underMouse() function inside the widget's
- mousePressEvent().
-
- The \l{widgets/scribble}{Scribble example} implements a wider set of
- events to handle mouse movement, button presses, and window resizing.
-
- You will need to supply the behavior and content for your own widgets, but
- here is a brief overview of the events that are relevant to QWidget,
- starting with the most common ones:
-
- \list
- \i paintEvent() is called whenever the widget needs to be repainted.
- Every widget displaying custom content must implement it. Painting
- using a QPainter can only take place in a paintEvent() or a
- function called by a paintEvent().
- \i resizeEvent() is called when the widget has been resized.
- \i mousePressEvent() is called when a mouse button is pressed while
- the mouse cursor is inside the widget, or when the widget has
- grabbed the mouse using grabMouse(). Pressing the mouse without
- releasing it is effectively the same as calling grabMouse().
- \i mouseReleaseEvent() is called when a mouse button is released. A
- widget receives mouse release events when it has received the
- corresponding mouse press event. This means that if the user
- presses the mouse inside \e your widget, then drags the mouse
- somewhere else before releasing the mouse button, \e your widget
- receives the release event. There is one exception: if a popup menu
- appears while the mouse button is held down, this popup immediately
- steals the mouse events.
- \i mouseDoubleClickEvent() is called when the user double-clicks in
- the widget. If the user double-clicks, the widget receives a mouse
- press event, a mouse release event and finally this event instead
- of a second mouse press event. (Some mouse move events may also be
- received if the mouse is not held steady during this operation.) It
- is \e{not possible} to distinguish a click from a double-click
- until the second click arrives. (This is one reason why most GUI
- books recommend that double-clicks be an extension of
- single-clicks, rather than trigger a different action.)
- \endlist
-
- Widgets that accept keyboard input need to reimplement a few more event
- handlers:
-
- \list
- \i keyPressEvent() is called whenever a key is pressed, and again when
- a key has been held down long enough for it to auto-repeat. The
- \key Tab and \key Shift+Tab keys are only passed to the widget if
- they are not used by the focus-change mechanisms. To force those
- keys to be processed by your widget, you must reimplement
- QWidget::event().
- \i focusInEvent() is called when the widget gains keyboard focus
- (assuming you have called setFocusPolicy()). Well-behaved widgets
- indicate that they own the keyboard focus in a clear but discreet
- way.
- \i focusOutEvent() is called when the widget loses keyboard focus.
- \endlist
-
- You may be required to also reimplement some of the less common event
- handlers:
-
- \list
- \i mouseMoveEvent() is called whenever the mouse moves while a mouse
- button is held down. This can be useful during drag and drop
- operations. If you call \l{setMouseTracking()}{setMouseTracking}(true),
- you get mouse move events even when no buttons are held down.
- (See also the \l{Drag and Drop} guide.)
- \i keyReleaseEvent() is called whenever a key is released and while it
- is held down (if the key is auto-repeating). In that case, the
- widget will receive a pair of key release and key press event for
- every repeat. The \key Tab and \key Shift+Tab keys are only passed
- to the widget if they are not used by the focus-change mechanisms.
- To force those keys to be processed by your widget, you must
- reimplement QWidget::event().
- \i wheelEvent() is called whenever the user turns the mouse wheel
- while the widget has the focus.
- \i enterEvent() is called when the mouse enters the widget's screen
- space. (This excludes screen space owned by any of the widget's
- children.)
- \i leaveEvent() is called when the mouse leaves the widget's screen
- space. If the mouse enters a child widget it will not cause a
- leaveEvent().
- \i moveEvent() is called when the widget has been moved relative to
- its parent.
- \i closeEvent() is called when the user closes the widget (or when
- close() is called).
- \endlist
-
- There are also some rather obscure events described in the documentation
- for QEvent::Type. To handle these events, you need to reimplement event()
- directly.
-
- The default implementation of event() handles \key Tab and \key Shift+Tab
- (to move the keyboard focus), and passes on most of the other events to
- one of the more specialized handlers above.
-
- Events and the mechanism used to deliver them are covered in
- \l{The Event System}.
-
- \section1 Groups of Functions and Properties
-
- \table
- \header \i Context \i Functions and Properties
-
- \row \i Window functions \i
- show(),
- hide(),
- raise(),
- lower(),
- close().
-
- \row \i Top-level windows \i
- \l windowModified, \l windowTitle, \l windowIcon, \l windowIconText,
- \l isActiveWindow, activateWindow(), \l minimized, showMinimized(),
- \l maximized, showMaximized(), \l fullScreen, showFullScreen(),
- showNormal().
-
- \row \i Window contents \i
- update(),
- repaint(),
- scroll().
-
- \row \i Geometry \i
- \l pos, x(), y(), \l rect, \l size, width(), height(), move(), resize(),
- \l sizePolicy, sizeHint(), minimumSizeHint(),
- updateGeometry(), layout(),
- \l frameGeometry, \l geometry, \l childrenRect, \l childrenRegion,
- adjustSize(),
- mapFromGlobal(), mapToGlobal(),
- mapFromParent(), mapToParent(),
- \l maximumSize, \l minimumSize, \l sizeIncrement,
- \l baseSize, setFixedSize()
-
- \row \i Mode \i
- \l visible, isVisibleTo(),
- \l enabled, isEnabledTo(),
- \l modal,
- isWindow(),
- \l mouseTracking,
- \l updatesEnabled,
- visibleRegion().
-
- \row \i Look and feel \i
- style(),
- setStyle(),
- \l styleSheet,
- \l cursor,
- \l font,
- \l palette,
- backgroundRole(), setBackgroundRole(),
- fontInfo(), fontMetrics().
-
- \row \i Keyboard focus functions \i
- \l focus, \l focusPolicy,
- setFocus(), clearFocus(), setTabOrder(), setFocusProxy(),
- focusNextChild(), focusPreviousChild().
-
- \row \i Mouse and keyboard grabbing \i
- grabMouse(), releaseMouse(),
- grabKeyboard(), releaseKeyboard(),
- mouseGrabber(), keyboardGrabber().
-
- \row \i Event handlers \i
- event(),
- mousePressEvent(),
- mouseReleaseEvent(),
- mouseDoubleClickEvent(),
- mouseMoveEvent(),
- keyPressEvent(),
- keyReleaseEvent(),
- focusInEvent(),
- focusOutEvent(),
- wheelEvent(),
- enterEvent(),
- leaveEvent(),
- paintEvent(),
- moveEvent(),
- resizeEvent(),
- closeEvent(),
- dragEnterEvent(),
- dragMoveEvent(),
- dragLeaveEvent(),
- dropEvent(),
- childEvent(),
- showEvent(),
- hideEvent(),
- customEvent().
- changeEvent(),
-
- \row \i System functions \i
- parentWidget(), window(), setParent(), winId(),
- find(), metric().
-
- \row \i Interactive help \i
- setToolTip(), setWhatsThis()
-
- \endtable
-
-
- \section1 Widget Style Sheets
-
- In addition to the standard widget styles for each platform, widgets can
- also be styled according to rules specified in a \l{styleSheet}
- {style sheet}. This feature enables you to customize the appearance of
- specific widgets to provide visual cues to users about their purpose. For
- example, a button could be styled in a particular way to indicate that it
- performs a destructive action.
-
- The use of widget style sheets is described in more detail in the
- \l{Qt Style Sheets} document.
-
-
- \section1 Transparency and Double Buffering
-
- Since Qt 4.0, QWidget automatically double-buffers its painting, so there
- is no need to write double-buffering code in paintEvent() to avoid
- flicker.
-
- Since Qt 4.1, the Qt::WA_ContentsPropagated widget attribute has been
- deprecated. Instead, the contents of parent widgets are propagated by
- default to each of their children as long as Qt::WA_PaintOnScreen is not
- set. Custom widgets can be written to take advantage of this feature by
- updating irregular regions (to create non-rectangular child widgets), or
- painting with colors that have less than full alpha component. The
- following diagram shows how attributes and properties of a custom widget
- can be fine-tuned to achieve different effects.
-
- \image propagation-custom.png
-
- In the above diagram, a semi-transparent rectangular child widget with an
- area removed is constructed and added to a parent widget (a QLabel showing
- a pixmap). Then, different properties and widget attributes are set to
- achieve different effects:
-
- \list
- \i The left widget has no additional properties or widget attributes
- set. This default state suits most custom widgets using
- transparency, are irregularly-shaped, or do not paint over their
- entire area with an opaque brush.
- \i The center widget has the \l autoFillBackground property set. This
- property is used with custom widgets that rely on the widget to
- supply a default background, and do not paint over their entire
- area with an opaque brush.
- \i The right widget has the Qt::WA_OpaquePaintEvent widget attribute
- set. This indicates that the widget will paint over its entire area
- with opaque colors. The widget's area will initially be
- \e{uninitialized}, represented in the diagram with a red diagonal
- grid pattern that shines through the overpainted area. The
- Qt::WA_OpaquePaintArea attribute is useful for widgets that need to
- paint their own specialized contents quickly and do not need a
- default filled background.
- \endlist
-
- To rapidly update custom widgets with simple background colors, such as
- real-time plotting or graphing widgets, it is better to define a suitable
- background color (using setBackgroundRole() with the
- QPalette::Window role), set the \l autoFillBackground property, and only
- implement the necessary drawing functionality in the widget's paintEvent().
-
- To rapidly update custom widgets that constantly paint over their entire
- areas with opaque content, e.g., video streaming widgets, it is better to
- set the widget's Qt::WA_OpaquePaintEvent, avoiding any unnecessary overhead
- associated with repainting the widget's background.
-
- If a widget has both the Qt::WA_OpaquePaintEvent widget attribute \e{and}
- the \l autoFillBackground property set, the Qt::WA_OpaquePaintEvent
- attribute takes precedence. Depending on your requirements, you should
- choose either one of them.
-
- Since Qt 4.1, the contents of parent widgets are also propagated to
- standard Qt widgets. This can lead to some unexpected results if the
- parent widget is decorated in a non-standard way, as shown in the diagram
- below.
-
- \image propagation-standard.png
-
- The scope for customizing the painting behavior of standard Qt widgets,
- without resorting to subclassing, is slightly less than that possible for
- custom widgets. Usually, the desired appearance of a standard widget can be
- achieved by setting its \l autoFillBackground property.
-
-
- \section1 Creating Translucent Windows
-
- Since Qt 4.5, it has been possible to create windows with translucent regions
- on window systems that support compositing.
-
- To enable this feature in a top-level widget, set its Qt::WA_TranslucentBackground
- attribute with setAttribute() and ensure that its background is painted with
- non-opaque colors in the regions you want to be partially transparent.
-
- Platform notes:
-
- \list
- \o X11: This feature relies on the use of an X server that supports ARGB visuals
- and a compositing window manager.
- \o Windows: The widget needs to have the Qt::FramelessWindowHint window flag set
- for the translucency to work.
- \endlist
-
-
- \section1 Native Widgets vs Alien Widgets
-
- Introduced in Qt 4.4, alien widgets are widgets unknown to the windowing
- system. They do not have a native window handle associated with them. This
- feature significantly speeds up widget painting, resizing, and removes flicker.
-
- Should you require the old behavior with native windows, you can choose
- one of the following options:
-
- \list 1
- \i Use the \c{QT_USE_NATIVE_WINDOWS=1} in your environment.
- \i Set the Qt::AA_NativeWindows attribute on your application. All
- widgets will be native widgets.
- \i Set the Qt::WA_NativeWindow attribute on widgets: The widget itself
- and all of its ancestors will become native (unless
- Qt::WA_DontCreateNativeAncestors is set).
- \i Call QWidget::winId to enforce a native window (this implies 3).
- \i Set the Qt::WA_PaintOnScreen attribute to enforce a native window
- (this implies 3).
- \endlist
-
- \sa QEvent, QPainter, QGridLayout, QBoxLayout
-
- \section1 Softkeys
-
- Since Qt 4.6, Softkeys are usually physical keys on a device that have a corresponding label or
- other visual representation on the screen that is generally located next to its
- physical counterpart. They are most often found on mobile phone platforms. In
- modern touch based user interfaces it is also possible to have softkeys that do
- not correspond to any physical keys. Softkeys differ from other onscreen labels
- in that they are contextual.
-
- In Qt, contextual softkeys are added to a widget by calling addAction() and
- passing a \c QAction with a softkey role set on it. When the widget
- containing the softkey actions has focus, its softkeys should appear in
- the user interface. Softkeys are discovered by traversing the widget
- hierarchy so it is possible to define a single set of softkeys that are
- present at all times by calling addAction() for a given top level widget.
-
- On some platforms, this concept overlaps with \c QMenuBar such that if no
- other softkeys are found and the top level widget is a QMainWindow containing
- a QMenuBar, the menubar actions may appear on one of the softkeys.
-
- Note: Currently softkeys are only supported on the Symbian Platform.
-
- \sa addAction(), QAction, QMenuBar
-
-*/
-
-QWidgetMapper *QWidgetPrivate::mapper = 0; // widget with wid
-QWidgetSet *QWidgetPrivate::allWidgets = 0; // widgets with no wid
-
-
-/*****************************************************************************
- QWidget utility functions
- *****************************************************************************/
-
-QRegion qt_dirtyRegion(QWidget *widget)
-{
- if (!widget)
- return QRegion();
-
- QWidgetBackingStore *bs = qt_widget_private(widget)->maybeBackingStore();
- if (!bs)
- return QRegion();
-
- return bs->dirtyRegion(widget);
-}
-
-/*****************************************************************************
- QWidget member functions
- *****************************************************************************/
-
-/*
- Widget state flags:
- \list
- \i Qt::WA_WState_Created The widget has a valid winId().
- \i Qt::WA_WState_Visible The widget is currently visible.
- \i Qt::WA_WState_Hidden The widget is hidden, i.e. it won't
- become visible unless you call show() on it. Qt::WA_WState_Hidden
- implies !Qt::WA_WState_Visible.
- \i Qt::WA_WState_CompressKeys Compress keyboard events.
- \i Qt::WA_WState_BlockUpdates Repaints and updates are disabled.
- \i Qt::WA_WState_InPaintEvent Currently processing a paint event.
- \i Qt::WA_WState_Reparented The widget has been reparented.
- \i Qt::WA_WState_ConfigPending A configuration (resize/move) event is pending.
- \i Qt::WA_WState_DND (Deprecated) The widget supports drag and drop, see setAcceptDrops().
- \endlist
-*/
-
-struct QWidgetExceptionCleaner
-{
- /* this cleans up when the constructor throws an exception */
- static inline void cleanup(QWidget *that, QWidgetPrivate *d)
- {
-#ifdef QT_NO_EXCEPTIONS
- Q_UNUSED(that);
- Q_UNUSED(d);
-#else
- QWidgetPrivate::allWidgets->remove(that);
- if (d->focus_next != that) {
- if (d->focus_next)
- d->focus_next->d_func()->focus_prev = d->focus_prev;
- if (d->focus_prev)
- d->focus_prev->d_func()->focus_next = d->focus_next;
- }
-#endif
- }
-};
-
-/*!
- Constructs a widget which is a child of \a parent, with widget
- flags set to \a f.
-
- If \a parent is 0, the new widget becomes a window. If
- \a parent is another widget, this widget becomes a child window
- inside \a parent. The new widget is deleted when its \a parent is
- deleted.
-
- The widget flags argument, \a f, is normally 0, but it can be set
- to customize the frame of a window (i.e. \a
- parent must be 0). To customize the frame, use a value composed
- from the bitwise OR of any of the \l{Qt::WindowFlags}{window flags}.
-
- If you add a child widget to an already visible widget you must
- explicitly show the child to make it visible.
-
- Note that the X11 version of Qt may not be able to deliver all
- combinations of style flags on all systems. This is because on
- X11, Qt can only ask the window manager, and the window manager
- can override the application's settings. On Windows, Qt can set
- whatever flags you want.
-
- \sa windowFlags
-*/
-QWidget::QWidget(QWidget *parent, Qt::WindowFlags f)
- : QObject(*new QWidgetPrivate, 0), QPaintDevice()
-{
- QT_TRY {
- d_func()->init(parent, f);
- } QT_CATCH(...) {
- QWidgetExceptionCleaner::cleanup(this, d_func());
- QT_RETHROW;
- }
-}
-
-#ifdef QT3_SUPPORT
-/*!
- \overload
- \obsolete
- */
-QWidget::QWidget(QWidget *parent, const char *name, Qt::WindowFlags f)
- : QObject(*new QWidgetPrivate, 0), QPaintDevice()
-{
- QT_TRY {
- d_func()->init(parent , f);
- setObjectName(QString::fromAscii(name));
- } QT_CATCH(...) {
- QWidgetExceptionCleaner::cleanup(this, d_func());
- QT_RETHROW;
- }
-}
-#endif
-
-/*! \internal
-*/
-QWidget::QWidget(QWidgetPrivate &dd, QWidget* parent, Qt::WindowFlags f)
- : QObject(dd, 0), QPaintDevice()
-{
- Q_D(QWidget);
- QT_TRY {
- d->init(parent, f);
- } QT_CATCH(...) {
- QWidgetExceptionCleaner::cleanup(this, d_func());
- QT_RETHROW;
- }
-}
-
-/*!
- \internal
-*/
-int QWidget::devType() const
-{
- return QInternal::Widget;
-}
-
-
-//### w is a "this" ptr, passed as a param because QWorkspace needs special logic
-void QWidgetPrivate::adjustFlags(Qt::WindowFlags &flags, QWidget *w)
-{
- bool customize = (flags & (Qt::CustomizeWindowHint
- | Qt::FramelessWindowHint
- | Qt::WindowTitleHint
- | Qt::WindowSystemMenuHint
- | Qt::WindowMinimizeButtonHint
- | Qt::WindowMaximizeButtonHint
- | Qt::WindowCloseButtonHint
- | Qt::WindowContextHelpButtonHint));
-
- uint type = (flags & Qt::WindowType_Mask);
-
- if ((type == Qt::Widget || type == Qt::SubWindow) && w && !w->parent()) {
- type = Qt::Window;
- flags |= Qt::Window;
- }
-
- if (flags & Qt::CustomizeWindowHint) {
- // modify window flags to make them consistent.
- // Only enable this on non-Mac platforms. Since the old way of doing this would
- // interpret WindowSystemMenuHint as a close button and we can't change that behavior
- // we can't just add this in.
-#ifndef Q_WS_MAC
- if (flags & (Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | Qt::WindowContextHelpButtonHint)) {
- flags |= Qt::WindowSystemMenuHint;
-#else
- if (flags & (Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint
- | Qt::WindowSystemMenuHint)) {
-#endif
- flags |= Qt::WindowTitleHint;
- flags &= ~Qt::FramelessWindowHint;
- }
- } else if (customize && !(flags & Qt::FramelessWindowHint)) {
- // if any of the window hints that affect the titlebar are set
- // and the window is supposed to have frame, we add a titlebar
- // and system menu by default.
- flags |= Qt::WindowSystemMenuHint;
- flags |= Qt::WindowTitleHint;
- }
- if (customize)
- ; // don't modify window flags if the user explicitly set them.
- else if (type == Qt::Dialog || type == Qt::Sheet)
-#ifndef Q_WS_WINCE
- flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint | Qt::WindowCloseButtonHint;
-#else
- flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint;
-#endif
- else if (type == Qt::Tool)
- flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint;
- else
- flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint;
-
-
-}
-
-void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
-{
- Q_Q(QWidget);
- if (QApplication::type() == QApplication::Tty)
- qFatal("QWidget: Cannot create a QWidget when no GUI is being used");
-
- Q_ASSERT(allWidgets);
- if (allWidgets)
- allWidgets->insert(q);
-
- QWidget *desktopWidget = 0;
- if (parentWidget && parentWidget->windowType() == Qt::Desktop) {
- desktopWidget = parentWidget;
- parentWidget = 0;
- }
-
- q->data = &data;
-
-#ifndef QT_NO_THREAD
- if (!parent) {
- Q_ASSERT_X(q->thread() == qApp->thread(), "QWidget",
- "Widgets must be created in the GUI thread.");
- }
-#endif
-
-#if defined(Q_WS_X11)
- if (desktopWidget) {
- // make sure the widget is created on the same screen as the
- // programmer specified desktop widget
- xinfo = desktopWidget->d_func()->xinfo;
- }
-#elif defined(Q_OS_SYMBIAN)
- if (desktopWidget) {
- symbianScreenNumber = qt_widget_private(desktopWidget)->symbianScreenNumber;
- }
-#elif defined(Q_WS_QPA)
- if (desktopWidget) {
- int screen = desktopWidget->d_func()->topData()->screenIndex;
- QPlatformIntegration *platform = QApplicationPrivate::platformIntegration();
- platform->moveToScreen(q, screen);
- }
-#else
- Q_UNUSED(desktopWidget);
-#endif
-
- data.fstrut_dirty = true;
-
- data.winid = 0;
- data.widget_attributes = 0;
- data.window_flags = f;
- data.window_state = 0;
- data.focus_policy = 0;
- data.context_menu_policy = Qt::DefaultContextMenu;
- data.window_modality = Qt::NonModal;
-
- data.sizehint_forced = 0;
- data.is_closing = 0;
- data.in_show = 0;
- data.in_set_window_state = 0;
- data.in_destructor = false;
-
- // Widgets with Qt::MSWindowsOwnDC (typically QGLWidget) must have a window handle.
- if (f & Qt::MSWindowsOwnDC)
- q->setAttribute(Qt::WA_NativeWindow);
-
-//#ifdef Q_WS_MAC
-// q->setAttribute(Qt::WA_NativeWindow);
-//#endif
-
- q->setAttribute(Qt::WA_QuitOnClose); // might be cleared in adjustQuitOnCloseAttribute()
- adjustQuitOnCloseAttribute();
-
- q->setAttribute(Qt::WA_WState_Hidden);
-
- //give potential windows a bigger "pre-initial" size; create_sys() will give them a new size later
-#ifdef Q_OS_SYMBIAN
- if (isGLWidget) {
- // Don't waste GPU mem for unnecessary large egl surface until resized by application
- data.crect = QRect(0,0,1,1);
- } else {
- data.crect = parentWidget ? QRect(0,0,100,30) : QRect(0,0,360,640);
- }
-#else
- data.crect = parentWidget ? QRect(0,0,100,30) : QRect(0,0,640,480);
-#endif
-
- focus_next = focus_prev = q;
-
- if ((f & Qt::WindowType_Mask) == Qt::Desktop)
- q->create();
- else if (parentWidget)
- q->setParent(parentWidget, data.window_flags);
- else {
- adjustFlags(data.window_flags, q);
- resolveLayoutDirection();
- // opaque system background?
- const QBrush &background = q->palette().brush(QPalette::Window);
- setOpaque(q->isWindow() && background.style() != Qt::NoBrush && background.isOpaque());
- }
- data.fnt = QFont(data.fnt, q);
-#if defined(Q_WS_X11)
- data.fnt.x11SetScreen(xinfo.screen());
-#endif // Q_WS_X11
-
- q->setAttribute(Qt::WA_PendingMoveEvent);
- q->setAttribute(Qt::WA_PendingResizeEvent);
-
- if (++QWidgetPrivate::instanceCounter > QWidgetPrivate::maxInstances)
- QWidgetPrivate::maxInstances = QWidgetPrivate::instanceCounter;
-
- if (QApplicationPrivate::app_compile_version < 0x040200
- || QApplicationPrivate::testAttribute(Qt::AA_ImmediateWidgetCreation))
- q->create();
-
-
- QEvent e(QEvent::Create);
- QApplication::sendEvent(q, &e);
- QApplication::postEvent(q, new QEvent(QEvent::PolishRequest));
-
- extraPaintEngine = 0;
-
-#ifdef QT_MAC_USE_COCOA
- // If we add a child to the unified toolbar, we have to redirect the painting.
- if (parentWidget && parentWidget->d_func() && parentWidget->d_func()->isInUnifiedToolbar) {
- if (parentWidget->d_func()->unifiedSurface) {
- QWidget *toolbar = parentWidget->d_func()->toolbar_ancestor;
- parentWidget->d_func()->unifiedSurface->recursiveRedirect(toolbar, toolbar, toolbar->d_func()->toolbar_offset);
- }
- }
-#endif // QT_MAC_USE_COCOA
-}
-
-
-
-void QWidgetPrivate::createRecursively()
-{
- Q_Q(QWidget);
- q->create(0, true, true);
- for (int i = 0; i < children.size(); ++i) {
- QWidget *child = qobject_cast<QWidget *>(children.at(i));
- if (child && !child->isHidden() && !child->isWindow() && !child->testAttribute(Qt::WA_WState_Created))
- child->d_func()->createRecursively();
- }
-}
-
-
-
-
-/*!
- Creates a new widget window if \a window is 0, otherwise sets the
- widget's window to \a window.
-
- Initializes the window (sets the geometry etc.) if \a
- initializeWindow is true. If \a initializeWindow is false, no
- initialization is performed. This parameter only makes sense if \a
- window is a valid window.
-
- Destroys the old window if \a destroyOldWindow is true. If \a
- destroyOldWindow is false, you are responsible for destroying the
- window yourself (using platform native code).
-
- The QWidget constructor calls create(0,true,true) to create a
- window for this widget.
-*/
-
-void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow)
-{
- Q_D(QWidget);
- if (testAttribute(Qt::WA_WState_Created) && window == 0 && internalWinId())
- return;
-
- if (d->data.in_destructor)
- return;
-
- Qt::WindowType type = windowType();
- Qt::WindowFlags &flags = data->window_flags;
-
- if ((type == Qt::Widget || type == Qt::SubWindow) && !parentWidget()) {
- type = Qt::Window;
- flags |= Qt::Window;
- }
-
-#ifndef Q_WS_QPA
- if (QWidget *parent = parentWidget()) {
- if (type & Qt::Window) {
- if (!parent->testAttribute(Qt::WA_WState_Created))
- parent->createWinId();
- } else if (testAttribute(Qt::WA_NativeWindow) && !parent->internalWinId()
- && !testAttribute(Qt::WA_DontCreateNativeAncestors)) {
- // We're about to create a native child widget that doesn't have a native parent;
- // enforce a native handle for the parent unless the Qt::WA_DontCreateNativeAncestors
- // attribute is set.
- d->createWinId(window);
- // Nothing more to do.
- Q_ASSERT(testAttribute(Qt::WA_WState_Created));
- Q_ASSERT(internalWinId());
- return;
- }
- }
-#endif //Q_WS_QPA
-
-#ifdef QT3_SUPPORT
- if (flags & Qt::WStaticContents)
- setAttribute(Qt::WA_StaticContents);
- if (flags & Qt::WDestructiveClose)
- setAttribute(Qt::WA_DeleteOnClose);
- if (flags & Qt::WShowModal)
- setWindowModality(Qt::ApplicationModal);
- if (flags & Qt::WMouseNoMask)
- setAttribute(Qt::WA_MouseNoMask);
- if (flags & Qt::WGroupLeader)
- setAttribute(Qt::WA_GroupLeader);
- if (flags & Qt::WNoMousePropagation)
- setAttribute(Qt::WA_NoMousePropagation);
-#endif
-
- static int paintOnScreenEnv = -1;
- if (paintOnScreenEnv == -1)
- paintOnScreenEnv = qgetenv("QT_ONSCREEN_PAINT").toInt() > 0 ? 1 : 0;
- if (paintOnScreenEnv == 1)
- setAttribute(Qt::WA_PaintOnScreen);
-
- if (QApplicationPrivate::testAttribute(Qt::AA_NativeWindows))
- setAttribute(Qt::WA_NativeWindow);
-
-#ifdef ALIEN_DEBUG
- qDebug() << "QWidget::create:" << this << "parent:" << parentWidget()
- << "Alien?" << !testAttribute(Qt::WA_NativeWindow);
-#endif
-
-#if defined (Q_WS_WIN) && !defined(QT_NO_DRAGANDDROP)
- // Unregister the dropsite (if already registered) before we
- // re-create the widget with a native window.
- if (testAttribute(Qt::WA_WState_Created) && !internalWinId() && testAttribute(Qt::WA_NativeWindow)
- && d->extra && d->extra->dropTarget) {
- d->registerDropSite(false);
- }
-#endif // defined (Q_WS_WIN) && !defined(QT_NO_DRAGANDDROP)
-
- d->updateIsOpaque();
-
- setAttribute(Qt::WA_WState_Created); // set created flag
- d->create_sys(window, initializeWindow, destroyOldWindow);
-
- // a real toplevel window needs a backing store
- if (isWindow() && windowType() != Qt::Desktop) {
- d->topData()->backingStore.destroy();
- if (hasBackingStoreSupport())
- d->topData()->backingStore.create(this);
- }
-
- d->setModal_sys();
-
- if (!isWindow() && parentWidget() && parentWidget()->testAttribute(Qt::WA_DropSiteRegistered))
- setAttribute(Qt::WA_DropSiteRegistered, true);
-
-#ifdef QT_EVAL
- extern void qt_eval_init_widget(QWidget *w);
- qt_eval_init_widget(this);
-#endif
-
- // need to force the resting of the icon after changing parents
- if (testAttribute(Qt::WA_SetWindowIcon))
- d->setWindowIcon_sys(true);
- if (isWindow() && !d->topData()->iconText.isEmpty())
- d->setWindowIconText_helper(d->topData()->iconText);
- if (isWindow() && !d->topData()->caption.isEmpty())
- d->setWindowTitle_helper(d->topData()->caption);
- if (windowType() != Qt::Desktop) {
- d->updateSystemBackground();
-
- if (isWindow() && !testAttribute(Qt::WA_SetWindowIcon))
- d->setWindowIcon_sys();
- }
-}
-
-/*!
- Destroys the widget.
-
- All this widget's children are deleted first. The application
- exits if this widget is the main widget.
-*/
-
-QWidget::~QWidget()
-{
- Q_D(QWidget);
- d->data.in_destructor = true;
-
-#if defined (QT_CHECK_STATE)
- if (paintingActive())
- qWarning("QWidget: %s (%s) deleted while being painted", className(), name());
-#endif
-
-#ifndef QT_NO_GESTURES
- foreach (Qt::GestureType type, d->gestureContext.keys())
- ungrabGesture(type);
-#endif
-
- // force acceptDrops false before winId is destroyed.
- d->registerDropSite(false);
-
-#ifndef QT_NO_ACTION
- // remove all actions from this widget
- for (int i = 0; i < d->actions.size(); ++i) {
- QActionPrivate *apriv = d->actions.at(i)->d_func();
- apriv->widgets.removeAll(this);
- }
- d->actions.clear();
-#endif
-
-#ifndef QT_NO_SHORTCUT
- // Remove all shortcuts grabbed by this
- // widget, unless application is closing
- if (!QApplicationPrivate::is_app_closing && testAttribute(Qt::WA_GrabbedShortcut))
- qApp->d_func()->shortcutMap.removeShortcut(0, this, QKeySequence());
-#endif
-
- // delete layout while we still are a valid widget
- delete d->layout;
- d->layout = 0;
- // Remove myself from focus list
-
- Q_ASSERT(d->focus_next->d_func()->focus_prev == this);
- Q_ASSERT(d->focus_prev->d_func()->focus_next == this);
-
- if (d->focus_next != this) {
- d->focus_next->d_func()->focus_prev = d->focus_prev;
- d->focus_prev->d_func()->focus_next = d->focus_next;
- d->focus_next = d->focus_prev = 0;
- }
-
-#ifdef QT3_SUPPORT
- if (QApplicationPrivate::main_widget == this) { // reset main widget
- QApplicationPrivate::main_widget = 0;
- QApplication::quit();
- }
-#endif
-
- QT_TRY {
- clearFocus();
- } QT_CATCH(...) {
- // swallow this problem because we are in a destructor
- }
-
- d->setDirtyOpaqueRegion();
-
- if (isWindow() && isVisible() && internalWinId()) {
- QT_TRY {
- d->close_helper(QWidgetPrivate::CloseNoEvent);
- } QT_CATCH(...) {
- // if we're out of memory, at least hide the window.
- QT_TRY {
- hide();
- } QT_CATCH(...) {
- // and if that also doesn't work, then give up
- }
- }
- }
-
-#if defined(Q_WS_WIN) || defined(Q_WS_X11)|| defined(Q_WS_MAC)
- else if (!internalWinId() && isVisible()) {
- qApp->d_func()->sendSyntheticEnterLeave(this);
- }
-#elif defined(Q_WS_QWS) || defined(Q_WS_QPA)
- else if (isVisible()) {
- qApp->d_func()->sendSyntheticEnterLeave(this);
- }
-#endif
-
-#ifdef Q_OS_SYMBIAN
- if (d->extra && d->extra->topextra && d->extra->topextra->backingStore) {
- // Okay, we are about to destroy the top-level window that owns
- // the backing store. Make sure we delete the backing store right away
- // before the window handle is invalid. This is important because
- // the backing store will delete its window surface, which may or may
- // not have a reference to this widget that will be used later to
- // notify the window it no longer has a surface.
- d->extra->topextra->backingStore.destroy();
- }
-#endif
- if (QWidgetBackingStore *bs = d->maybeBackingStore()) {
- bs->removeDirtyWidget(this);
- if (testAttribute(Qt::WA_StaticContents))
- bs->removeStaticWidget(this);
- }
-
- delete d->needsFlush;
- d->needsFlush = 0;
-
- // set all QPointers for this object to zero
- if (d->hasGuards)
- QObjectPrivate::clearGuards(this);
-
- if (d->declarativeData) {
- QAbstractDeclarativeData::destroyed(d->declarativeData, this);
- d->declarativeData = 0; // don't activate again in ~QObject
- }
-
-#ifdef QT_MAC_USE_COCOA
- // QCocoaView holds a pointer back to this widget. Clear it now
- // to make sure it's not followed later on. The lifetime of the
- // QCocoaView might exceed the lifetime of this widget in cases
- // where Cocoa itself holds references to it.
- extern void qt_mac_clearCocoaViewQWidgetPointers(QWidget *);
- qt_mac_clearCocoaViewQWidgetPointers(this);
-#endif
-
- if (!d->children.isEmpty())
- d->deleteChildren();
-
- QApplication::removePostedEvents(this);
-
- QT_TRY {
- destroy(); // platform-dependent cleanup
- } QT_CATCH(...) {
- // if this fails we can't do anything about it but at least we are not allowed to throw.
- }
- --QWidgetPrivate::instanceCounter;
-
- if (QWidgetPrivate::allWidgets) // might have been deleted by ~QApplication
- QWidgetPrivate::allWidgets->remove(this);
-
- QT_TRY {
- QEvent e(QEvent::Destroy);
- QCoreApplication::sendEvent(this, &e);
- } QT_CATCH(const std::exception&) {
- // if this fails we can't do anything about it but at least we are not allowed to throw.
- }
-}
-
-int QWidgetPrivate::instanceCounter = 0; // Current number of widget instances
-int QWidgetPrivate::maxInstances = 0; // Maximum number of widget instances
-
-void QWidgetPrivate::setWinId(WId id) // set widget identifier
-{
- Q_Q(QWidget);
- // the user might create a widget with Qt::Desktop window
- // attribute (or create another QDesktopWidget instance), which
- // will have the same windowid (the root window id) as the
- // qt_desktopWidget. We should not add the second desktop widget
- // to the mapper.
- bool userDesktopWidget = qt_desktopWidget != 0 && qt_desktopWidget != q && q->windowType() == Qt::Desktop;
- if (mapper && data.winid && !userDesktopWidget) {
- mapper->remove(data.winid);
- }
-
- const WId oldWinId = data.winid;
-
- data.winid = id;
-#if defined(Q_WS_X11)
- hd = id; // X11: hd == ident
-#endif
- if (mapper && id && !userDesktopWidget) {
- mapper->insert(data.winid, q);
- }
-
- if(oldWinId != id) {
- QEvent e(QEvent::WinIdChange);
- QCoreApplication::sendEvent(q, &e);
- }
-}
-
-void QWidgetPrivate::createTLExtra()
-{
- if (!extra)
- createExtra();
- if (!extra->topextra) {
- QTLWExtra* x = extra->topextra = new QTLWExtra;
- x->icon = 0;
- x->iconPixmap = 0;
- x->windowSurface = 0;
- x->sharedPainter = 0;
- x->incw = x->inch = 0;
- x->basew = x->baseh = 0;
- x->frameStrut.setCoords(0, 0, 0, 0);
- x->normalGeometry = QRect(0,0,-1,-1);
- x->savedFlags = 0;
- x->opacity = 255;
- x->posFromMove = false;
- x->sizeAdjusted = false;
- x->inTopLevelResize = false;
- x->inRepaint = false;
- x->embedded = 0;
-#ifdef Q_WS_MAC
-#ifdef QT_MAC_USE_COCOA
- x->wasMaximized = false;
-#endif // QT_MAC_USE_COCOA
-#endif // Q_WS_MAC
- createTLSysExtra();
-#ifdef QWIDGET_EXTRA_DEBUG
- static int count = 0;
- qDebug() << "tlextra" << ++count;
-#endif
-#if defined(Q_WS_QPA)
- x->platformWindow = 0;
- x->platformWindowFormat = QPlatformWindowFormat::defaultFormat();
- x->screenIndex = 0;
-#endif
- }
-}
-
-/*!
- \internal
- Creates the widget extra data.
-*/
-
-void QWidgetPrivate::createExtra()
-{
- if (!extra) { // if not exists
- extra = new QWExtra;
- extra->glContext = 0;
- extra->topextra = 0;
-#ifndef QT_NO_GRAPHICSVIEW
- extra->proxyWidget = 0;
-#endif
-#ifndef QT_NO_CURSOR
- extra->curs = 0;
-#endif
- extra->minw = 0;
- extra->minh = 0;
- extra->maxw = QWIDGETSIZE_MAX;
- extra->maxh = QWIDGETSIZE_MAX;
- extra->customDpiX = 0;
- extra->customDpiY = 0;
- extra->explicitMinSize = 0;
- extra->explicitMaxSize = 0;
- extra->autoFillBackground = 0;
- extra->nativeChildrenForced = 0;
- extra->inRenderWithPainter = 0;
- extra->hasMask = 0;
- createSysExtra();
-#ifdef QWIDGET_EXTRA_DEBUG
- static int count = 0;
- qDebug() << "extra" << ++count;
-#endif
- }
-}
-
-
-/*!
- \internal
- Deletes the widget extra data.
-*/
-
-void QWidgetPrivate::deleteExtra()
-{
- if (extra) { // if exists
-#ifndef QT_NO_CURSOR
- delete extra->curs;
-#endif
- deleteSysExtra();
-#ifndef QT_NO_STYLE_STYLESHEET
- // dereference the stylesheet style
- if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(extra->style))
- proxy->deref();
-#endif
- if (extra->topextra) {
- deleteTLSysExtra();
- extra->topextra->backingStore.destroy();
- delete extra->topextra->icon;
- delete extra->topextra->iconPixmap;
-#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER)
- delete extra->topextra->qwsManager;
-#endif
- delete extra->topextra->windowSurface;
- delete extra->topextra;
- }
- delete extra;
- // extra->xic destroyed in QWidget::destroy()
- extra = 0;
- }
-}
-
-/*
- Returns true if there are widgets above this which overlap with
- \a rect, which is in parent's coordinate system (same as crect).
-*/
-
-bool QWidgetPrivate::isOverlapped(const QRect &rect) const
-{
- Q_Q(const QWidget);
-
- const QWidget *w = q;
- QRect r = rect;
- while (w) {
- if (w->isWindow())
- return false;
- QWidgetPrivate *pd = w->parentWidget()->d_func();
- bool above = false;
- for (int i = 0; i < pd->children.size(); ++i) {
- QWidget *sibling = qobject_cast<QWidget *>(pd->children.at(i));
- if (!sibling || !sibling->isVisible() || sibling->isWindow())
- continue;
- if (!above) {
- above = (sibling == w);
- continue;
- }
-
- if (qRectIntersects(sibling->d_func()->effectiveRectFor(sibling->data->crect), r)) {
- const QWExtra *siblingExtra = sibling->d_func()->extra;
- if (siblingExtra && siblingExtra->hasMask && !sibling->d_func()->graphicsEffect
- && !siblingExtra->mask.translated(sibling->data->crect.topLeft()).intersects(r)) {
- continue;
- }
- return true;
- }
- }
- w = w->parentWidget();
- r.translate(pd->data.crect.topLeft());
- }
- return false;
-}
-
-void QWidgetPrivate::syncBackingStore()
-{
- if (paintOnScreen()) {
- repaint_sys(dirty);
- dirty = QRegion();
- } else if (QWidgetBackingStore *bs = maybeBackingStore()) {
- bs->sync();
- }
-}
-
-void QWidgetPrivate::syncBackingStore(const QRegion &region)
-{
- if (paintOnScreen())
- repaint_sys(region);
- else if (QWidgetBackingStore *bs = maybeBackingStore()) {
- bs->sync(q_func(), region);
- }
-}
-
-void QWidgetPrivate::setUpdatesEnabled_helper(bool enable)
-{
- Q_Q(QWidget);
-
- if (enable && !q->isWindow() && q->parentWidget() && !q->parentWidget()->updatesEnabled())
- return; // nothing we can do
-
- if (enable != q->testAttribute(Qt::WA_UpdatesDisabled))
- return; // nothing to do
-
- q->setAttribute(Qt::WA_UpdatesDisabled, !enable);
- if (enable)
- q->update();
-
- Qt::WidgetAttribute attribute = enable ? Qt::WA_ForceUpdatesDisabled : Qt::WA_UpdatesDisabled;
- for (int i = 0; i < children.size(); ++i) {
- QWidget *w = qobject_cast<QWidget *>(children.at(i));
- if (w && !w->isWindow() && !w->testAttribute(attribute))
- w->d_func()->setUpdatesEnabled_helper(enable);
- }
-}
-
-/*!
- \internal
-
- Propagate this widget's palette to all children, except style sheet
- widgets, and windows that don't enable window propagation (palettes don't
- normally propagate to windows).
-*/
-void QWidgetPrivate::propagatePaletteChange()
-{
- Q_Q(QWidget);
- // Propagate a new inherited mask to all children.
-#ifndef QT_NO_GRAPHICSVIEW
- if (!q->parentWidget() && extra && extra->proxyWidget) {
- QGraphicsProxyWidget *p = extra->proxyWidget;
- inheritedPaletteResolveMask = p->d_func()->inheritedPaletteResolveMask | p->palette().resolve();
- } else
-#endif //QT_NO_GRAPHICSVIEW
- if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) {
- inheritedPaletteResolveMask = 0;
- }
- int mask = data.pal.resolve() | inheritedPaletteResolveMask;
-
- QEvent pc(QEvent::PaletteChange);
- QApplication::sendEvent(q, &pc);
- for (int i = 0; i < children.size(); ++i) {
- QWidget *w = qobject_cast<QWidget*>(children.at(i));
- if (w && !w->testAttribute(Qt::WA_StyleSheet)
- && (!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))) {
- QWidgetPrivate *wd = w->d_func();
- wd->inheritedPaletteResolveMask = mask;
- wd->resolvePalette();
- }
- }
-#if defined(QT3_SUPPORT)
- q->paletteChange(q->palette()); // compatibility
-#endif
-}
-
-/*
- Returns the widget's clipping rectangle.
-*/
-QRect QWidgetPrivate::clipRect() const
-{
- Q_Q(const QWidget);
- const QWidget * w = q;
- if (!w->isVisible())
- return QRect();
- QRect r = effectiveRectFor(q->rect());
- int ox = 0;
- int oy = 0;
- while (w
- && w->isVisible()
- && !w->isWindow()
- && w->parentWidget()) {
- ox -= w->x();
- oy -= w->y();
- w = w->parentWidget();
- r &= QRect(ox, oy, w->width(), w->height());
- }
- return r;
-}
-
-/*
- Returns the widget's clipping region (without siblings).
-*/
-QRegion QWidgetPrivate::clipRegion() const
-{
- Q_Q(const QWidget);
- if (!q->isVisible())
- return QRegion();
- QRegion r(q->rect());
- const QWidget * w = q;
- const QWidget *ignoreUpTo;
- int ox = 0;
- int oy = 0;
- while (w
- && w->isVisible()
- && !w->isWindow()
- && w->parentWidget()) {
- ox -= w->x();
- oy -= w->y();
- ignoreUpTo = w;
- w = w->parentWidget();
- r &= QRegion(ox, oy, w->width(), w->height());
-
- int i = 0;
- while(w->d_func()->children.at(i++) != static_cast<const QObject *>(ignoreUpTo))
- ;
- for ( ; i < w->d_func()->children.size(); ++i) {
- if(QWidget *sibling = qobject_cast<QWidget *>(w->d_func()->children.at(i))) {
- if(sibling->isVisible() && !sibling->isWindow()) {
- QRect siblingRect(ox+sibling->x(), oy+sibling->y(),
- sibling->width(), sibling->height());
- if (qRectIntersects(siblingRect, q->rect()))
- r -= QRegion(siblingRect);
- }
- }
- }
- }
- return r;
-}
-
-#ifndef QT_NO_GRAPHICSEFFECT
-void QWidgetPrivate::invalidateGraphicsEffectsRecursively()
-{
- Q_Q(QWidget);
- QWidget *w = q;
- do {
- if (w->graphicsEffect()) {
- QWidgetEffectSourcePrivate *sourced =
- static_cast<QWidgetEffectSourcePrivate *>(w->graphicsEffect()->source()->d_func());
- if (!sourced->updateDueToGraphicsEffect)
- w->graphicsEffect()->source()->d_func()->invalidateCache();
- }
- w = w->parentWidget();
- } while (w);
-}
-#endif //QT_NO_GRAPHICSEFFECT
-
-void QWidgetPrivate::setDirtyOpaqueRegion()
-{
- Q_Q(QWidget);
-
- dirtyOpaqueChildren = true;
-
-#ifndef QT_NO_GRAPHICSEFFECT
- invalidateGraphicsEffectsRecursively();
-#endif //QT_NO_GRAPHICSEFFECT
-
- if (q->isWindow())
- return;
-
- QWidget *parent = q->parentWidget();
- if (!parent)
- return;
-
- // TODO: instead of setting dirtyflag, manipulate the dirtyregion directly?
- QWidgetPrivate *pd = parent->d_func();
- if (!pd->dirtyOpaqueChildren)
- pd->setDirtyOpaqueRegion();
-}
-
-const QRegion &QWidgetPrivate::getOpaqueChildren() const
-{
- if (!dirtyOpaqueChildren)
- return opaqueChildren;
-
- QWidgetPrivate *that = const_cast<QWidgetPrivate*>(this);
- that->opaqueChildren = QRegion();
-
- for (int i = 0; i < children.size(); ++i) {
- QWidget *child = qobject_cast<QWidget *>(children.at(i));
- if (!child || !child->isVisible() || child->isWindow())
- continue;
-
- const QPoint offset = child->geometry().topLeft();
- QWidgetPrivate *childd = child->d_func();
- QRegion r = childd->isOpaque ? child->rect() : childd->getOpaqueChildren();
- if (childd->extra && childd->extra->hasMask)
- r &= childd->extra->mask;
- if (r.isEmpty())
- continue;
- r.translate(offset);
- that->opaqueChildren += r;
- }
-
- that->opaqueChildren &= q_func()->rect();
- that->dirtyOpaqueChildren = false;
-
- return that->opaqueChildren;
-}
-
-void QWidgetPrivate::subtractOpaqueChildren(QRegion &source, const QRect &clipRect) const
-{
- if (children.isEmpty() || clipRect.isEmpty())
- return;
-
- const QRegion &r = getOpaqueChildren();
- if (!r.isEmpty())
- source -= (r & clipRect);
-}
-
-//subtract any relatives that are higher up than me --- this is too expensive !!!
-void QWidgetPrivate::subtractOpaqueSiblings(QRegion &sourceRegion, bool *hasDirtySiblingsAbove,
- bool alsoNonOpaque) const
-{
- Q_Q(const QWidget);
- static int disableSubtractOpaqueSiblings = qgetenv("QT_NO_SUBTRACTOPAQUESIBLINGS").toInt();
- if (disableSubtractOpaqueSiblings || q->isWindow())
- return;
-
-#ifdef QT_MAC_USE_COCOA
- if (q->d_func()->isInUnifiedToolbar)
- return;
-#endif // QT_MAC_USE_COCOA
-
- QRect clipBoundingRect;
- bool dirtyClipBoundingRect = true;
-
- QRegion parentClip;
- bool dirtyParentClip = true;
-
- QPoint parentOffset = data.crect.topLeft();
-
- const QWidget *w = q;
-
- while (w) {
- if (w->isWindow())
- break;
- QWidgetPrivate *pd = w->parentWidget()->d_func();
- const int myIndex = pd->children.indexOf(const_cast<QWidget *>(w));
- const QRect widgetGeometry = w->d_func()->effectiveRectFor(w->data->crect);
- for (int i = myIndex + 1; i < pd->children.size(); ++i) {
- QWidget *sibling = qobject_cast<QWidget *>(pd->children.at(i));
- if (!sibling || !sibling->isVisible() || sibling->isWindow())
- continue;
-
- const QRect siblingGeometry = sibling->d_func()->effectiveRectFor(sibling->data->crect);
- if (!qRectIntersects(siblingGeometry, widgetGeometry))
- continue;
-
- if (dirtyClipBoundingRect) {
- clipBoundingRect = sourceRegion.boundingRect();
- dirtyClipBoundingRect = false;
- }
-
- if (!qRectIntersects(siblingGeometry, clipBoundingRect.translated(parentOffset)))
- continue;
-
- if (dirtyParentClip) {
- parentClip = sourceRegion.translated(parentOffset);
- dirtyParentClip = false;
- }
-
- const QPoint siblingPos(sibling->data->crect.topLeft());
- const QRect siblingClipRect(sibling->d_func()->clipRect());
- QRegion siblingDirty(parentClip);
- siblingDirty &= (siblingClipRect.translated(siblingPos));
- const bool hasMask = sibling->d_func()->extra && sibling->d_func()->extra->hasMask
- && !sibling->d_func()->graphicsEffect;
- if (hasMask)
- siblingDirty &= sibling->d_func()->extra->mask.translated(siblingPos);
- if (siblingDirty.isEmpty())
- continue;
-
- if (sibling->d_func()->isOpaque || alsoNonOpaque) {
- if (hasMask) {
- siblingDirty.translate(-parentOffset);
- sourceRegion -= siblingDirty;
- } else {
- sourceRegion -= siblingGeometry.translated(-parentOffset);
- }
- } else {
- if (hasDirtySiblingsAbove)
- *hasDirtySiblingsAbove = true;
- if (sibling->d_func()->children.isEmpty())
- continue;
- QRegion opaqueSiblingChildren(sibling->d_func()->getOpaqueChildren());
- opaqueSiblingChildren.translate(-parentOffset + siblingPos);
- sourceRegion -= opaqueSiblingChildren;
- }
- if (sourceRegion.isEmpty())
- return;
-
- dirtyClipBoundingRect = true;
- dirtyParentClip = true;
- }
-
- w = w->parentWidget();
- parentOffset += pd->data.crect.topLeft();
- dirtyParentClip = true;
- }
-}
-
-void QWidgetPrivate::clipToEffectiveMask(QRegion &region) const
-{
- Q_Q(const QWidget);
-
- const QWidget *w = q;
- QPoint offset;
-
-#ifndef QT_NO_GRAPHICSEFFECT
- if (graphicsEffect) {
- w = q->parentWidget();
- offset -= data.crect.topLeft();
- }
-#endif //QT_NO_GRAPHICSEFFECT
-
- while (w) {
- const QWidgetPrivate *wd = w->d_func();
- if (wd->extra && wd->extra->hasMask)
- region &= (w != q) ? wd->extra->mask.translated(offset) : wd->extra->mask;
- if (w->isWindow())
- return;
- offset -= wd->data.crect.topLeft();
- w = w->parentWidget();
- }
-}
-
-bool QWidgetPrivate::paintOnScreen() const
-{
-#if defined(Q_WS_QWS)
- return false;
-#elif defined(QT_NO_BACKINGSTORE)
- return true;
-#else
- Q_Q(const QWidget);
- if (q->testAttribute(Qt::WA_PaintOnScreen)
- || (!q->isWindow() && q->window()->testAttribute(Qt::WA_PaintOnScreen))) {
- return true;
- }
-
- return !qt_enable_backingstore;
-#endif
-}
-
-void QWidgetPrivate::updateIsOpaque()
-{
- // hw: todo: only needed if opacity actually changed
- setDirtyOpaqueRegion();
-
-#ifndef QT_NO_GRAPHICSEFFECT
- if (graphicsEffect) {
- // ### We should probably add QGraphicsEffect::isOpaque at some point.
- setOpaque(false);
- return;
- }
-#endif //QT_NO_GRAPHICSEFFECT
-
- Q_Q(QWidget);
-#ifdef Q_WS_X11
- if (q->testAttribute(Qt::WA_X11OpenGLOverlay)) {
- setOpaque(false);
- return;
- }
-#endif
-
-#ifdef Q_WS_S60
- if (q->windowType() == Qt::Dialog && q->testAttribute(Qt::WA_TranslucentBackground)
- && S60->avkonComponentsSupportTransparency) {
- setOpaque(false);
- return;
- }
-#endif
-
- if (q->testAttribute(Qt::WA_OpaquePaintEvent) || q->testAttribute(Qt::WA_PaintOnScreen)) {
- setOpaque(true);
- return;
- }
-
- const QPalette &pal = q->palette();
-
- if (q->autoFillBackground()) {
- const QBrush &autoFillBrush = pal.brush(q->backgroundRole());
- if (autoFillBrush.style() != Qt::NoBrush && autoFillBrush.isOpaque()) {
- setOpaque(true);
- return;
- }
- }
-
- if (q->isWindow() && !q->testAttribute(Qt::WA_NoSystemBackground)) {
- const QBrush &windowBrush = q->palette().brush(QPalette::Window);
- if (windowBrush.style() != Qt::NoBrush && windowBrush.isOpaque()) {
- setOpaque(true);
- return;
- }
- }
- setOpaque(false);
-}
-
-void QWidgetPrivate::setOpaque(bool opaque)
-{
- if (isOpaque == opaque)
- return;
- isOpaque = opaque;
-#ifdef Q_WS_MAC
- macUpdateIsOpaque();
-#endif
-#ifdef Q_WS_X11
- x11UpdateIsOpaque();
-#endif
-#ifdef Q_WS_WIN
- winUpdateIsOpaque();
-#endif
-#ifdef Q_OS_SYMBIAN
- s60UpdateIsOpaque();
-#endif
-}
-
-void QWidgetPrivate::updateIsTranslucent()
-{
-#ifdef Q_WS_MAC
- macUpdateIsOpaque();
-#endif
-#ifdef Q_WS_X11
- x11UpdateIsOpaque();
-#endif
-#ifdef Q_WS_WIN
- winUpdateIsOpaque();
-#endif
-#ifdef Q_OS_SYMBIAN
- s60UpdateIsOpaque();
-#endif
-}
-
-/*!
- \fn void QPixmap::fill(const QWidget *widget, const QPoint &offset)
-
- Fills the pixmap with the \a widget's background color or pixmap
- according to the given offset.
-
- The QPoint \a offset defines a point in widget coordinates to
- which the pixmap's top-left pixel will be mapped to. This is only
- significant if the widget has a background pixmap; otherwise the
- pixmap will simply be filled with the background color of the
- widget.
-*/
-
-void QPixmap::fill( const QWidget *widget, const QPoint &off )
-{
- QPainter p(this);
- p.translate(-off);
- widget->d_func()->paintBackground(&p, QRect(off, size()));
-}
-
-static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QBrush &brush)
-{
- Q_ASSERT(painter);
-
- if (brush.style() == Qt::TexturePattern) {
-#ifdef Q_WS_MAC
- // Optimize pattern filling on mac by using HITheme directly
- // when filling with the standard widget background.
- // Defined in qmacstyle_mac.cpp
- extern void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QBrush &brush);
- qt_mac_fill_background(painter, rgn, brush);
-#else
-#if !defined(QT_NO_STYLE_S60)
- // Defined in qs60style.cpp
- extern bool qt_s60_fill_background(QPainter *painter, const QRegion &rgn, const QBrush &brush);
- if (!qt_s60_fill_background(painter, rgn, brush))
-#endif // !defined(QT_NO_STYLE_S60)
- {
- const QRect rect(rgn.boundingRect());
- painter->setClipRegion(rgn);
- painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft());
- }
-#endif // Q_WS_MAC
-
- } else if (brush.gradient()
- && brush.gradient()->coordinateMode() == QGradient::ObjectBoundingMode) {
- painter->save();
- painter->setClipRegion(rgn);
- painter->fillRect(0, 0, painter->device()->width(), painter->device()->height(), brush);
- painter->restore();
- } else {
- const QVector<QRect> &rects = rgn.rects();
- for (int i = 0; i < rects.size(); ++i)
- painter->fillRect(rects.at(i), brush);
- }
-}
-
-void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, int flags) const
-{
- Q_Q(const QWidget);
-
-#ifndef QT_NO_SCROLLAREA
- bool resetBrushOrigin = false;
- QPointF oldBrushOrigin;
- //If we are painting the viewport of a scrollarea, we must apply an offset to the brush in case we are drawing a texture
- QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(parent);
- if (scrollArea && scrollArea->viewport() == q) {
- QObjectData *scrollPrivate = static_cast<QWidget *>(scrollArea)->d_ptr.data();
- QAbstractScrollAreaPrivate *priv = static_cast<QAbstractScrollAreaPrivate *>(scrollPrivate);
- oldBrushOrigin = painter->brushOrigin();
- resetBrushOrigin = true;
- painter->setBrushOrigin(-priv->contentsOffset());
-
- }
-#endif // QT_NO_SCROLLAREA
-
- const QBrush autoFillBrush = q->palette().brush(q->backgroundRole());
-
- if ((flags & DrawAsRoot) && !(q->autoFillBackground() && autoFillBrush.isOpaque())) {
- const QBrush bg = q->palette().brush(QPalette::Window);
-#ifdef Q_WS_QWS
- if (!(flags & DontSetCompositionMode) && painter->paintEngine()->hasFeature(QPaintEngine::PorterDuff))
- painter->setCompositionMode(QPainter::CompositionMode_Source); //copy alpha straight in
-#endif
- fillRegion(painter, rgn, bg);
- }
-
- if (q->autoFillBackground())
- fillRegion(painter, rgn, autoFillBrush);
-
- if (q->testAttribute(Qt::WA_StyledBackground)) {
- painter->setClipRegion(rgn);
- QStyleOption opt;
- opt.initFrom(q);
- q->style()->drawPrimitive(QStyle::PE_Widget, &opt, painter, q);
- }
-
-#ifndef QT_NO_SCROLLAREA
- if (resetBrushOrigin)
- painter->setBrushOrigin(oldBrushOrigin);
-#endif // QT_NO_SCROLLAREA
-}
-
-/*
- \internal
- This function is called when a widget is hidden or destroyed.
- It resets some application global pointers that should only refer active,
- visible widgets.
-*/
-
-#ifdef Q_WS_MAC
- extern QPointer<QWidget> qt_button_down;
-#else
- extern QWidget *qt_button_down;
-#endif
-
-void QWidgetPrivate::deactivateWidgetCleanup()
-{
- Q_Q(QWidget);
- // If this was the active application window, reset it
- if (QApplication::activeWindow() == q)
- QApplication::setActiveWindow(0);
- // If the is the active mouse press widget, reset it
- if (q == qt_button_down)
- qt_button_down = 0;
-}
-
-
-/*!
- Returns a pointer to the widget with window identifer/handle \a
- id.
-
- The window identifier type depends on the underlying window
- system, see \c qwindowdefs.h for the actual definition. If there
- is no widget with this identifier, 0 is returned.
-*/
-
-QWidget *QWidget::find(WId id)
-{
- return QWidgetPrivate::mapper ? QWidgetPrivate::mapper->value(id, 0) : 0;
-}
-
-
-
-/*!
- \fn WId QWidget::internalWinId() const
- \internal
- Returns the window system identifier of the widget, or 0 if the widget is not created yet.
-
-*/
-
-/*!
- \fn WId QWidget::winId() const
-
- Returns the window system identifier of the widget.
-
- Portable in principle, but if you use it you are probably about to
- do something non-portable. Be careful.
-
- If a widget is non-native (alien) and winId() is invoked on it, that widget
- will be provided a native handle.
-
- On Mac OS X, the type returned depends on which framework Qt was linked
- against. If Qt is using Carbon, the {WId} is actually an HIViewRef. If Qt
- is using Cocoa, {WId} is a pointer to an NSView.
-
- This value may change at run-time. An event with type QEvent::WinIdChange
- will be sent to the widget following a change in window system identifier.
-
- \sa find()
-*/
-WId QWidget::winId() const
-{
- if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) {
-#ifdef ALIEN_DEBUG
- qDebug() << "QWidget::winId: creating native window for" << this;
-#endif
- QWidget *that = const_cast<QWidget*>(this);
-#ifndef Q_WS_QPA
- that->setAttribute(Qt::WA_NativeWindow);
-#endif
- that->d_func()->createWinId();
- return that->data->winid;
- }
- return data->winid;
-}
-
-
-void QWidgetPrivate::createWinId(WId winid)
-{
- Q_Q(QWidget);
-
-#ifdef ALIEN_DEBUG
- qDebug() << "QWidgetPrivate::createWinId for" << q << winid;
-#endif
- const bool forceNativeWindow = q->testAttribute(Qt::WA_NativeWindow);
- if (!q->testAttribute(Qt::WA_WState_Created) || (forceNativeWindow && !q->internalWinId())) {
-#ifndef Q_WS_QPA
- if (!q->isWindow()) {
- QWidget *parent = q->parentWidget();
- QWidgetPrivate *pd = parent->d_func();
- if (forceNativeWindow && !q->testAttribute(Qt::WA_DontCreateNativeAncestors))
- parent->setAttribute(Qt::WA_NativeWindow);
- if (!parent->internalWinId()) {
- pd->createWinId();
- }
-
- for (int i = 0; i < pd->children.size(); ++i) {
- QWidget *w = qobject_cast<QWidget *>(pd->children.at(i));
- if (w && !w->isWindow() && (!w->testAttribute(Qt::WA_WState_Created)
- || (!w->internalWinId() && w->testAttribute(Qt::WA_NativeWindow)))) {
- if (w!=q) {
- w->create();
- } else {
- w->create(winid);
- // if the window has already been created, we
- // need to raise it to its proper stacking position
- if (winid)
- w->raise();
- }
- }
- }
- } else {
- q->create();
- }
-#else
- Q_UNUSED(winid);
- q->create();
-#endif //Q_WS_QPA
-
- }
-}
-
-
-/*!
-\internal
-Ensures that the widget has a window system identifier, i.e. that it is known to the windowing system.
-
-*/
-
-void QWidget::createWinId()
-{
- Q_D(QWidget);
-#ifdef ALIEN_DEBUG
- qDebug() << "QWidget::createWinId" << this;
-#endif
-// qWarning("QWidget::createWinId is obsolete, please fix your code.");
- d->createWinId();
-}
-
-/*!
- \since 4.4
-
- Returns the effective window system identifier of the widget, i.e. the
- native parent's window system identifier.
-
- If the widget is native, this function returns the native widget ID.
- Otherwise, the window ID of the first native parent widget, i.e., the
- top-level widget that contains this widget, is returned.
-
- \note We recommend that you do not store this value as it is likely to
- change at run-time.
-
- \sa nativeParentWidget()
-*/
-WId QWidget::effectiveWinId() const
-{
- WId id = internalWinId();
- if (id || !testAttribute(Qt::WA_WState_Created))
- return id;
- QWidget *realParent = nativeParentWidget();
- Q_ASSERT(realParent);
- Q_ASSERT(realParent->internalWinId());
- return realParent->internalWinId();
-}
-
-#ifndef QT_NO_STYLE_STYLESHEET
-
-/*!
- \property QWidget::styleSheet
- \brief the widget's style sheet
- \since 4.2
-
- The style sheet contains a textual description of customizations to the
- widget's style, as described in the \l{Qt Style Sheets} document.
-
- Since Qt 4.5, Qt style sheets fully supports Mac OS X.
-
- \warning Qt style sheets are currently not supported for custom QStyle
- subclasses. We plan to address this in some future release.
-
- \sa setStyle(), QApplication::styleSheet, {Qt Style Sheets}
-*/
-QString QWidget::styleSheet() const
-{
- Q_D(const QWidget);
- if (!d->extra)
- return QString();
- return d->extra->styleSheet;
-}
-
-void QWidget::setStyleSheet(const QString& styleSheet)
-{
- Q_D(QWidget);
- d->createExtra();
-
- QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(d->extra->style);
- d->extra->styleSheet = styleSheet;
- if (styleSheet.isEmpty()) { // stylesheet removed
- if (!proxy)
- return;
-
- d->inheritStyle();
- return;
- }
-
- if (proxy) { // style sheet update
- proxy->repolish(this);
- return;
- }
-
- if (testAttribute(Qt::WA_SetStyle)) {
- d->setStyle_helper(new QStyleSheetStyle(d->extra->style), true);
- } else {
- d->setStyle_helper(new QStyleSheetStyle(0), true);
- }
-}
-
-#endif // QT_NO_STYLE_STYLESHEET
-
-/*!
- \sa QWidget::setStyle(), QApplication::setStyle(), QApplication::style()
-*/
-
-QStyle *QWidget::style() const
-{
- Q_D(const QWidget);
-
- if (d->extra && d->extra->style)
- return d->extra->style;
- return QApplication::style();
-}
-
-/*!
- Sets the widget's GUI style to \a style. The ownership of the style
- object is not transferred.
-
- If no style is set, the widget uses the application's style,
- QApplication::style() instead.
-
- Setting a widget's style has no effect on existing or future child
- widgets.
-
- \warning This function is particularly useful for demonstration
- purposes, where you want to show Qt's styling capabilities. Real
- applications should avoid it and use one consistent GUI style
- instead.
-
- \warning Qt style sheets are currently not supported for custom QStyle
- subclasses. We plan to address this in some future release.
-
- \sa style(), QStyle, QApplication::style(), QApplication::setStyle()
-*/
-
-void QWidget::setStyle(QStyle *style)
-{
- Q_D(QWidget);
- setAttribute(Qt::WA_SetStyle, style != 0);
- d->createExtra();
-#ifndef QT_NO_STYLE_STYLESHEET
- if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(style)) {
- //if for some reason someone try to set a QStyleSheetStyle, ref it
- //(this may happen for exemple in QButtonDialogBox which propagates its style)
- proxy->ref();
- d->setStyle_helper(style, false);
- } else if (qobject_cast<QStyleSheetStyle *>(d->extra->style) || !qApp->styleSheet().isEmpty()) {
- // if we have an application stylesheet or have a proxy already, propagate
- d->setStyle_helper(new QStyleSheetStyle(style), true);
- } else
-#endif
- d->setStyle_helper(style, false);
-}
-
-void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate, bool
-#ifdef Q_WS_MAC
- metalHack
-#endif
- )
-{
- Q_Q(QWidget);
- QStyle *oldStyle = q->style();
-#ifndef QT_NO_STYLE_STYLESHEET
- QWeakPointer<QStyle> origStyle;
-#endif
-
-#ifdef Q_WS_MAC
- // the metalhack boolean allows Qt/Mac to do a proper re-polish depending
- // on how the Qt::WA_MacBrushedMetal attribute is set. It is only ever
- // set when changing that attribute and passes the widget's CURRENT style.
- // therefore no need to do a reassignment.
- if (!metalHack)
-#endif
- {
- createExtra();
-
-#ifndef QT_NO_STYLE_STYLESHEET
- origStyle = extra->style.data();
-#endif
- extra->style = newStyle;
- }
-
- // repolish
- if (q->windowType() != Qt::Desktop) {
- if (polished) {
- oldStyle->unpolish(q);
-#ifdef Q_WS_MAC
- if (metalHack)
- macUpdateMetalAttribute();
-#endif
- q->style()->polish(q);
-#ifdef Q_WS_MAC
- } else if (metalHack) {
- macUpdateMetalAttribute();
-#endif
- }
- }
-
- if (propagate) {
- for (int i = 0; i < children.size(); ++i) {
- QWidget *c = qobject_cast<QWidget*>(children.at(i));
- if (c)
- c->d_func()->inheritStyle();
- }
- }
-
-#ifndef QT_NO_STYLE_STYLESHEET
- if (!qobject_cast<QStyleSheetStyle*>(newStyle)) {
- if (const QStyleSheetStyle* cssStyle = qobject_cast<QStyleSheetStyle*>(origStyle.data())) {
- cssStyle->clearWidgetFont(q);
- }
- }
-#endif
-
- QEvent e(QEvent::StyleChange);
- QApplication::sendEvent(q, &e);
-#ifdef QT3_SUPPORT
- q->styleChange(*oldStyle);
-#endif
-
-#ifndef QT_NO_STYLE_STYLESHEET
- // dereference the old stylesheet style
- if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(origStyle.data()))
- proxy->deref();
-#endif
-}
-
-// Inherits style from the current parent and propagates it as necessary
-void QWidgetPrivate::inheritStyle()
-{
-#ifndef QT_NO_STYLE_STYLESHEET
- Q_Q(QWidget);
-
- QStyleSheetStyle *proxy = extra ? qobject_cast<QStyleSheetStyle *>(extra->style) : 0;
-
- if (!q->styleSheet().isEmpty()) {
- Q_ASSERT(proxy);
- proxy->repolish(q);
- return;
- }
-
- QStyle *origStyle = proxy ? proxy->base : (extra ? (QStyle*)extra->style : 0);
- QWidget *parent = q->parentWidget();
- QStyle *parentStyle = (parent && parent->d_func()->extra) ? (QStyle*)parent->d_func()->extra->style : 0;
- // If we have stylesheet on app or parent has stylesheet style, we need
- // to be running a proxy
- if (!qApp->styleSheet().isEmpty() || qobject_cast<QStyleSheetStyle *>(parentStyle)) {
- QStyle *newStyle = parentStyle;
- if (q->testAttribute(Qt::WA_SetStyle))
- newStyle = new QStyleSheetStyle(origStyle);
- else if (QStyleSheetStyle *newProxy = qobject_cast<QStyleSheetStyle *>(parentStyle))
- newProxy->ref();
-
- setStyle_helper(newStyle, true);
- return;
- }
-
- // So, we have no stylesheet on parent/app and we have an empty stylesheet
- // we just need our original style back
- if (origStyle == (extra ? (QStyle*)extra->style : 0)) // is it any different?
- return;
-
- // We could have inherited the proxy from our parent (which has a custom style)
- // In such a case we need to start following the application style (i.e revert
- // the propagation behavior of QStyleSheetStyle)
- if (!q->testAttribute(Qt::WA_SetStyle))
- origStyle = 0;
-
- setStyle_helper(origStyle, true);
-#endif // QT_NO_STYLE_STYLESHEET
-}
-
-#ifdef QT3_SUPPORT
-/*!
- \overload
-
- Sets the widget's GUI style to \a style using the QStyleFactory.
-*/
-QStyle* QWidget::setStyle(const QString &style)
-{
- QStyle *s = QStyleFactory::create(style);
- setStyle(s);
- return s;
-}
-#endif
-
-/*!
- \fn bool QWidget::isWindow() const
-
- Returns true if the widget is an independent window, otherwise
- returns false.
-
- A window is a widget that isn't visually the child of any other
- widget and that usually has a frame and a
- \l{QWidget::setWindowTitle()}{window title}.
-
- A window can have a \l{QWidget::parentWidget()}{parent widget}.
- It will then be grouped with its parent and deleted when the
- parent is deleted, minimized when the parent is minimized etc. If
- supported by the window manager, it will also have a common
- taskbar entry with its parent.
-
- QDialog and QMainWindow widgets are by default windows, even if a
- parent widget is specified in the constructor. This behavior is
- specified by the Qt::Window flag.
-
- \sa window(), isModal(), parentWidget()
-*/
-
-/*!
- \property QWidget::modal
- \brief whether the widget is a modal widget
-
- This property only makes sense for windows. A modal widget
- prevents widgets in all other windows from getting any input.
-
- By default, this property is false.
-
- \sa isWindow(), windowModality, QDialog
-*/
-
-/*!
- \property QWidget::windowModality
- \brief which windows are blocked by the modal widget
- \since 4.1
-
- This property only makes sense for windows. A modal widget
- prevents widgets in other windows from getting input. The value of
- this property controls which windows are blocked when the widget
- is visible. Changing this property while the window is visible has
- no effect; you must hide() the widget first, then show() it again.
-
- By default, this property is Qt::NonModal.
-
- \sa isWindow(), QWidget::modal, QDialog
-*/
-
-Qt::WindowModality QWidget::windowModality() const
-{
- return static_cast<Qt::WindowModality>(data->window_modality);
-}
-
-void QWidget::setWindowModality(Qt::WindowModality windowModality)
-{
- data->window_modality = windowModality;
- // setModal_sys() will be called by setAttribute()
- setAttribute(Qt::WA_ShowModal, (data->window_modality != Qt::NonModal));
- setAttribute(Qt::WA_SetWindowModality, true);
-}
-
-/*!
- \fn bool QWidget::underMouse() const
-
- Returns true if the widget is under the mouse cursor; otherwise
- returns false.
-
- This value is not updated properly during drag and drop
- operations.
-
- \sa enterEvent(), leaveEvent()
-*/
-
-/*!
- \property QWidget::minimized
- \brief whether this widget is minimized (iconified)
-
- This property is only relevant for windows.
-
- By default, this property is false.
-
- \sa showMinimized(), visible, show(), hide(), showNormal(), maximized
-*/
-bool QWidget::isMinimized() const
-{ return data->window_state & Qt::WindowMinimized; }
-
-/*!
- Shows the widget minimized, as an icon.
-
- Calling this function only affects \l{isWindow()}{windows}.
-
- \sa showNormal(), showMaximized(), show(), hide(), isVisible(),
- isMinimized()
-*/
-void QWidget::showMinimized()
-{
- bool isMin = isMinimized();
- if (isMin && isVisible())
- return;
-
- ensurePolished();
-#ifdef QT3_SUPPORT
- if (parent())
- QApplication::sendPostedEvents(parent(), QEvent::ChildInserted);
-#endif
-
- if (!isMin)
- setWindowState((windowState() & ~Qt::WindowActive) | Qt::WindowMinimized);
- show();
-}
-
-/*!
- \property QWidget::maximized
- \brief whether this widget is maximized
-
- This property is only relevant for windows.
-
- \note Due to limitations on some window systems, this does not always
- report the expected results (e.g., if the user on X11 maximizes the
- window via the window manager, Qt has no way of distinguishing this
- from any other resize). This is expected to improve as window manager
- protocols evolve.
-
- By default, this property is false.
-
- \sa windowState(), showMaximized(), visible, show(), hide(), showNormal(), minimized
-*/
-bool QWidget::isMaximized() const
-{ return data->window_state & Qt::WindowMaximized; }
-
-
-
-/*!
- Returns the current window state. The window state is a OR'ed
- combination of Qt::WindowState: Qt::WindowMinimized,
- Qt::WindowMaximized, Qt::WindowFullScreen, and Qt::WindowActive.
-
- \sa Qt::WindowState setWindowState()
- */
-Qt::WindowStates QWidget::windowState() const
-{
- return Qt::WindowStates(data->window_state);
-}
-
-/*!\internal
-
- The function sets the window state on child widgets similar to
- setWindowState(). The difference is that the window state changed
- event has the isOverride() flag set. It exists mainly to keep
- Q3Workspace working.
- */
-void QWidget::overrideWindowState(Qt::WindowStates newstate)
-{
- QWindowStateChangeEvent e(Qt::WindowStates(data->window_state), true);
- data->window_state = newstate;
- QApplication::sendEvent(this, &e);
-}
-
-/*!
- \fn void QWidget::setWindowState(Qt::WindowStates windowState)
-
- Sets the window state to \a windowState. The window state is a OR'ed
- combination of Qt::WindowState: Qt::WindowMinimized,
- Qt::WindowMaximized, Qt::WindowFullScreen, and Qt::WindowActive.
-
- If the window is not visible (i.e. isVisible() returns false), the
- window state will take effect when show() is called. For visible
- windows, the change is immediate. For example, to toggle between
- full-screen and normal mode, use the following code:
-
- \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 0
-
- In order to restore and activate a minimized window (while
- preserving its maximized and/or full-screen state), use the following:
-
- \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 1
-
- Calling this function will hide the widget. You must call show() to make
- the widget visible again.
-
- \note On some window systems Qt::WindowActive is not immediate, and may be
- ignored in certain cases.
-
- When the window state changes, the widget receives a changeEvent()
- of type QEvent::WindowStateChange.
-
- \sa Qt::WindowState windowState()
-*/
-
-/*!
- \property QWidget::fullScreen
- \brief whether the widget is shown in full screen mode
-
- A widget in full screen mode occupies the whole screen area and does not
- display window decorations, such as a title bar.
-
- By default, this property is false.
-
- \sa windowState(), minimized, maximized
-*/
-bool QWidget::isFullScreen() const
-{ return data->window_state & Qt::WindowFullScreen; }
-
-/*!
- Shows the widget in full-screen mode.
-
- Calling this function only affects \l{isWindow()}{windows}.
-
- To return from full-screen mode, call showNormal().
-
- Full-screen mode works fine under Windows, but has certain
- problems under X. These problems are due to limitations of the
- ICCCM protocol that specifies the communication between X11
- clients and the window manager. ICCCM simply does not understand
- the concept of non-decorated full-screen windows. Therefore, the
- best we can do is to request a borderless window and place and
- resize it to fill the entire screen. Depending on the window
- manager, this may or may not work. The borderless window is
- requested using MOTIF hints, which are at least partially
- supported by virtually all modern window managers.
-
- An alternative would be to bypass the window manager entirely and
- create a window with the Qt::X11BypassWindowManagerHint flag. This
- has other severe problems though, like totally broken keyboard focus
- and very strange effects on desktop changes or when the user raises
- other windows.
-
- X11 window managers that follow modern post-ICCCM specifications
- support full-screen mode properly.
-
- \sa showNormal(), showMaximized(), show(), hide(), isVisible()
-*/
-void QWidget::showFullScreen()
-{
-#ifdef Q_WS_MAC
- // If the unified toolbar is enabled, we have to disable it before going fullscreen.
- QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this);
- if (mainWindow && mainWindow->unifiedTitleAndToolBarOnMac()) {
- mainWindow->setUnifiedTitleAndToolBarOnMac(false);
- QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout());
- mainLayout->activateUnifiedToolbarAfterFullScreen = true;
- }
-#endif // Q_WS_MAC
- ensurePolished();
-#ifdef QT3_SUPPORT
- if (parent())
- QApplication::sendPostedEvents(parent(), QEvent::ChildInserted);
-#endif
-
- setWindowState((windowState() & ~(Qt::WindowMinimized | Qt::WindowMaximized))
- | Qt::WindowFullScreen);
- show();
- activateWindow();
-}
-
-/*!
- Shows the widget maximized.
-
- Calling this function only affects \l{isWindow()}{windows}.
-
- On X11, this function may not work properly with certain window
- managers. See the \l{Window Geometry} documentation for an explanation.
-
- \sa setWindowState(), showNormal(), showMinimized(), show(), hide(), isVisible()
-*/
-void QWidget::showMaximized()
-{
- ensurePolished();
-#ifdef QT3_SUPPORT
- if (parent())
- QApplication::sendPostedEvents(parent(), QEvent::ChildInserted);
-#endif
-
- setWindowState((windowState() & ~(Qt::WindowMinimized | Qt::WindowFullScreen))
- | Qt::WindowMaximized);
-#ifdef Q_WS_MAC
- // If the unified toolbar was enabled before going fullscreen, we have to enable it back.
- QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this);
- if (mainWindow)
- {
- QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout());
- if (mainLayout->activateUnifiedToolbarAfterFullScreen) {
- mainWindow->setUnifiedTitleAndToolBarOnMac(true);
- mainLayout->activateUnifiedToolbarAfterFullScreen = false;
- }
- }
-#endif // Q_WS_MAC
- show();
-}
-
-/*!
- Restores the widget after it has been maximized or minimized.
-
- Calling this function only affects \l{isWindow()}{windows}.
-
- \sa setWindowState(), showMinimized(), showMaximized(), show(), hide(), isVisible()
-*/
-void QWidget::showNormal()
-{
- ensurePolished();
-#ifdef QT3_SUPPORT
- if (parent())
- QApplication::sendPostedEvents(parent(), QEvent::ChildInserted);
-#endif
-
- setWindowState(windowState() & ~(Qt::WindowMinimized
- | Qt::WindowMaximized
- | Qt::WindowFullScreen));
-#ifdef Q_WS_MAC
- // If the unified toolbar was enabled before going fullscreen, we have to enable it back.
- QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this);
- if (mainWindow)
- {
- QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout());
- if (mainLayout->activateUnifiedToolbarAfterFullScreen) {
- mainWindow->setUnifiedTitleAndToolBarOnMac(true);
- mainLayout->activateUnifiedToolbarAfterFullScreen = false;
- }
- }
-#endif // Q_WS_MAC
- show();
-}
-
-/*!
- Returns true if this widget would become enabled if \a ancestor is
- enabled; otherwise returns false.
-
-
-
- This is the case if neither the widget itself nor every parent up
- to but excluding \a ancestor has been explicitly disabled.
-
- isEnabledTo(0) is equivalent to isEnabled().
-
- \sa setEnabled() enabled
-*/
-
-bool QWidget::isEnabledTo(QWidget* ancestor) const
-{
- const QWidget * w = this;
- while (!w->testAttribute(Qt::WA_ForceDisabled)
- && !w->isWindow()
- && w->parentWidget()
- && w->parentWidget() != ancestor)
- w = w->parentWidget();
- return !w->testAttribute(Qt::WA_ForceDisabled);
-}
-
-#ifndef QT_NO_ACTION
-/*!
- Appends the action \a action to this widget's list of actions.
-
- All QWidgets have a list of \l{QAction}s, however they can be
- represented graphically in many different ways. The default use of
- the QAction list (as returned by actions()) is to create a context
- QMenu.
-
- A QWidget should only have one of each action and adding an action
- it already has will not cause the same action to be in the widget twice.
-
- The ownership of \a action is not transferred to this QWidget.
-
- \sa removeAction(), insertAction(), actions(), QMenu
-*/
-void QWidget::addAction(QAction *action)
-{
- insertAction(0, action);
-}
-
-/*!
- Appends the actions \a actions to this widget's list of actions.
-
- \sa removeAction(), QMenu, addAction()
-*/
-void QWidget::addActions(QList<QAction*> actions)
-{
- for(int i = 0; i < actions.count(); i++)
- insertAction(0, actions.at(i));
-}
-
-/*!
- Inserts the action \a action to this widget's list of actions,
- before the action \a before. It appends the action if \a before is 0 or
- \a before is not a valid action for this widget.
-
- A QWidget should only have one of each action.
-
- \sa removeAction(), addAction(), QMenu, contextMenuPolicy, actions()
-*/
-void QWidget::insertAction(QAction *before, QAction *action)
-{
- if(!action) {
- qWarning("QWidget::insertAction: Attempt to insert null action");
- return;
- }
-
- Q_D(QWidget);
- if(d->actions.contains(action))
- removeAction(action);
-
- int pos = d->actions.indexOf(before);
- if (pos < 0) {
- before = 0;
- pos = d->actions.size();
- }
- d->actions.insert(pos, action);
-
- QActionPrivate *apriv = action->d_func();
- apriv->widgets.append(this);
-
- QActionEvent e(QEvent::ActionAdded, action, before);
- QApplication::sendEvent(this, &e);
-}
-
-/*!
- Inserts the actions \a actions to this widget's list of actions,
- before the action \a before. It appends the action if \a before is 0 or
- \a before is not a valid action for this widget.
-
- A QWidget can have at most one of each action.
-
- \sa removeAction(), QMenu, insertAction(), contextMenuPolicy
-*/
-void QWidget::insertActions(QAction *before, QList<QAction*> actions)
-{
- for(int i = 0; i < actions.count(); ++i)
- insertAction(before, actions.at(i));
-}
-
-/*!
- Removes the action \a action from this widget's list of actions.
- \sa insertAction(), actions(), insertAction()
-*/
-void QWidget::removeAction(QAction *action)
-{
- if (!action)
- return;
-
- Q_D(QWidget);
-
- QActionPrivate *apriv = action->d_func();
- apriv->widgets.removeAll(this);
-
- if (d->actions.removeAll(action)) {
- QActionEvent e(QEvent::ActionRemoved, action);
- QApplication::sendEvent(this, &e);
- }
-}
-
-/*!
- Returns the (possibly empty) list of this widget's actions.
-
- \sa contextMenuPolicy, insertAction(), removeAction()
-*/
-QList<QAction*> QWidget::actions() const
-{
- Q_D(const QWidget);
- return d->actions;
-}
-#endif // QT_NO_ACTION
-
-/*!
- \fn bool QWidget::isEnabledToTLW() const
- \obsolete
-
- This function is deprecated. It is equivalent to isEnabled()
-*/
-
-/*!
- \property QWidget::enabled
- \brief whether the widget is enabled
-
- An enabled widget handles keyboard and mouse events; a disabled
- widget does not.
-
- Some widgets display themselves differently when they are
- disabled. For example a button might draw its label grayed out. If
- your widget needs to know when it becomes enabled or disabled, you
- can use the changeEvent() with type QEvent::EnabledChange.
-
- Disabling a widget implicitly disables all its children. Enabling
- respectively enables all child widgets unless they have been
- explicitly disabled.
-
- By default, this property is true.
-
- \sa isEnabledTo(), QKeyEvent, QMouseEvent, changeEvent()
-*/
-void QWidget::setEnabled(bool enable)
-{
- Q_D(QWidget);
- setAttribute(Qt::WA_ForceDisabled, !enable);
- d->setEnabled_helper(enable);
-}
-
-void QWidgetPrivate::setEnabled_helper(bool enable)
-{
- Q_Q(QWidget);
-
- if (enable && !q->isWindow() && q->parentWidget() && !q->parentWidget()->isEnabled())
- return; // nothing we can do
-
- if (enable != q->testAttribute(Qt::WA_Disabled))
- return; // nothing to do
-
- q->setAttribute(Qt::WA_Disabled, !enable);
- updateSystemBackground();
-
- if (!enable && q->window()->focusWidget() == q) {
- bool parentIsEnabled = (!q->parentWidget() || q->parentWidget()->isEnabled());
- if (!parentIsEnabled || !q->focusNextChild())
- q->clearFocus();
- }
-
- Qt::WidgetAttribute attribute = enable ? Qt::WA_ForceDisabled : Qt::WA_Disabled;
- for (int i = 0; i < children.size(); ++i) {
- QWidget *w = qobject_cast<QWidget *>(children.at(i));
- if (w && !w->testAttribute(attribute))
- w->d_func()->setEnabled_helper(enable);
- }
-#if defined(Q_WS_X11)
- if (q->testAttribute(Qt::WA_SetCursor) || q->isWindow()) {
- // enforce the windows behavior of clearing the cursor on
- // disabled widgets
- qt_x11_enforce_cursor(q);
- }
-#endif
-#if defined(Q_WS_MAC)
- setEnabled_helper_sys(enable);
-#endif
-#ifndef QT_NO_IM
- if (q->testAttribute(Qt::WA_InputMethodEnabled) && q->hasFocus()) {
- QWidget *focusWidget = effectiveFocusWidget();
- QInputContext *qic = focusWidget->d_func()->inputContext();
- if (enable) {
- if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled))
- qic->setFocusWidget(focusWidget);
- } else {
- qic->reset();
- qic->setFocusWidget(0);
- }
- }
-#endif //QT_NO_IM
- QEvent e(QEvent::EnabledChange);
- QApplication::sendEvent(q, &e);
-#ifdef QT3_SUPPORT
- q->enabledChange(!enable); // compatibility
-#endif
-}
-
-/*!
- \property QWidget::acceptDrops
- \brief whether drop events are enabled for this widget
-
- Setting this property to true announces to the system that this
- widget \e may be able to accept drop events.
-
- If the widget is the desktop (windowType() == Qt::Desktop), this may
- fail if another application is using the desktop; you can call
- acceptDrops() to test if this occurs.
-
- \warning Do not modify this property in a drag and drop event handler.
-
- By default, this property is false.
-
- \sa {Drag and Drop}
-*/
-bool QWidget::acceptDrops() const
-{
- return testAttribute(Qt::WA_AcceptDrops);
-}
-
-void QWidget::setAcceptDrops(bool on)
-{
- setAttribute(Qt::WA_AcceptDrops, on);
-
-}
-
-/*!
- \fn void QWidget::enabledChange(bool)
-
- \internal
- \obsolete
-*/
-
-/*!
- \fn void QWidget::paletteChange(const QPalette &)
-
- \internal
- \obsolete
-*/
-
-/*!
- \fn void QWidget::fontChange(const QFont &)
-
- \internal
- \obsolete
-*/
-
-/*!
- \fn void QWidget::windowActivationChange(bool)
-
- \internal
- \obsolete
-*/
-
-/*!
- \fn void QWidget::languageChange()
-
- \obsolete
-*/
-
-/*!
- \fn void QWidget::styleChange(QStyle& style)
-
- \internal
- \obsolete
-*/
-
-/*!
- Disables widget input events if \a disable is true; otherwise
- enables input events.
-
- See the \l enabled documentation for more information.
-
- \sa isEnabledTo(), QKeyEvent, QMouseEvent, changeEvent()
-*/
-void QWidget::setDisabled(bool disable)
-{
- setEnabled(!disable);
-}
-
-/*!
- \property QWidget::frameGeometry
- \brief geometry of the widget relative to its parent including any
- window frame
-
- See the \l{Window Geometry} documentation for an overview of geometry
- issues with windows.
-
- By default, this property contains a value that depends on the user's
- platform and screen geometry.
-
- \sa geometry() x() y() pos()
-*/
-QRect QWidget::frameGeometry() const
-{
- Q_D(const QWidget);
- if (isWindow() && ! (windowType() == Qt::Popup)) {
- QRect fs = d->frameStrut();
- return QRect(data->crect.x() - fs.left(),
- data->crect.y() - fs.top(),
- data->crect.width() + fs.left() + fs.right(),
- data->crect.height() + fs.top() + fs.bottom());
- }
- return data->crect;
-}
-
-/*!
- \property QWidget::x
-
- \brief the x coordinate of the widget relative to its parent including
- any window frame
-
- See the \l{Window Geometry} documentation for an overview of geometry
- issues with windows.
-
- By default, this property has a value of 0.
-
- \sa frameGeometry, y, pos
-*/
-int QWidget::x() const
-{
- Q_D(const QWidget);
- if (isWindow() && ! (windowType() == Qt::Popup))
- return data->crect.x() - d->frameStrut().left();
- return data->crect.x();
-}
-
-/*!
- \property QWidget::y
- \brief the y coordinate of the widget relative to its parent and
- including any window frame
-
- See the \l{Window Geometry} documentation for an overview of geometry
- issues with windows.
-
- By default, this property has a value of 0.
-
- \sa frameGeometry, x, pos
-*/
-int QWidget::y() const
-{
- Q_D(const QWidget);
- if (isWindow() && ! (windowType() == Qt::Popup))
- return data->crect.y() - d->frameStrut().top();
- return data->crect.y();
-}
-
-/*!
- \property QWidget::pos
- \brief the position of the widget within its parent widget
-
- If the widget is a window, the position is that of the widget on
- the desktop, including its frame.
-
- When changing the position, the widget, if visible, receives a
- move event (moveEvent()) immediately. If the widget is not
- currently visible, it is guaranteed to receive an event before it
- is shown.
-
- By default, this property contains a position that refers to the
- origin.
-
- \warning Calling move() or setGeometry() inside moveEvent() can
- lead to infinite recursion.
-
- See the \l{Window Geometry} documentation for an overview of geometry
- issues with windows.
-
- \sa frameGeometry, size x(), y()
-*/
-QPoint QWidget::pos() const
-{
- Q_D(const QWidget);
- if (isWindow() && ! (windowType() == Qt::Popup)) {
- QRect fs = d->frameStrut();
- return QPoint(data->crect.x() - fs.left(), data->crect.y() - fs.top());
- }
- return data->crect.topLeft();
-}
-
-/*!
- \property QWidget::geometry
- \brief the geometry of the widget relative to its parent and
- excluding the window frame
-
- When changing the geometry, the widget, if visible, receives a
- move event (moveEvent()) and/or a resize event (resizeEvent())
- immediately. If the widget is not currently visible, it is
- guaranteed to receive appropriate events before it is shown.
-
- The size component is adjusted if it lies outside the range
- defined by minimumSize() and maximumSize().
-
- \warning Calling setGeometry() inside resizeEvent() or moveEvent()
- can lead to infinite recursion.
-
- See the \l{Window Geometry} documentation for an overview of geometry
- issues with windows.
-
- By default, this property contains a value that depends on the user's
- platform and screen geometry.
-
- \sa frameGeometry(), rect(), move(), resize(), moveEvent(),
- resizeEvent(), minimumSize(), maximumSize()
-*/
-
-/*!
- \property QWidget::normalGeometry
-
- \brief the geometry of the widget as it will appear when shown as
- a normal (not maximized or full screen) top-level widget
-
- For child widgets this property always holds an empty rectangle.
-
- By default, this property contains an empty rectangle.
-
- \sa QWidget::windowState(), QWidget::geometry
-*/
-
-/*!
- \property QWidget::size
- \brief the size of the widget excluding any window frame
-
- If the widget is visible when it is being resized, it receives a resize event
- (resizeEvent()) immediately. If the widget is not currently
- visible, it is guaranteed to receive an event before it is shown.
-
- The size is adjusted if it lies outside the range defined by
- minimumSize() and maximumSize().
-
- By default, this property contains a value that depends on the user's
- platform and screen geometry.
-
- \warning Calling resize() or setGeometry() inside resizeEvent() can
- lead to infinite recursion.
-
- \note Setting the size to \c{QSize(0, 0)} will cause the widget to not
- appear on screen. This also applies to windows.
-
- \sa pos, geometry, minimumSize, maximumSize, resizeEvent(), adjustSize()
-*/
-
-/*!
- \property QWidget::width
- \brief the width of the widget excluding any window frame
-
- See the \l{Window Geometry} documentation for an overview of geometry
- issues with windows.
-
- \note Do not use this function to find the width of a screen on
- a \l{QDesktopWidget}{multiple screen desktop}. Read
- \l{QDesktopWidget#Screen Geometry}{this note} for details.
-
- By default, this property contains a value that depends on the user's
- platform and screen geometry.
-
- \sa geometry, height, size
-*/
-
-/*!
- \property QWidget::height
- \brief the height of the widget excluding any window frame
-
- See the \l{Window Geometry} documentation for an overview of geometry
- issues with windows.
-
- \note Do not use this function to find the height of a screen
- on a \l{QDesktopWidget}{multiple screen desktop}. Read
- \l{QDesktopWidget#Screen Geometry}{this note} for details.
-
- By default, this property contains a value that depends on the user's
- platform and screen geometry.
-
- \sa geometry, width, size
-*/
-
-/*!
- \property QWidget::rect
- \brief the internal geometry of the widget excluding any window
- frame
-
- The rect property equals QRect(0, 0, width(), height()).
-
- See the \l{Window Geometry} documentation for an overview of geometry
- issues with windows.
-
- By default, this property contains a value that depends on the user's
- platform and screen geometry.
-
- \sa size
-*/
-
-
-QRect QWidget::normalGeometry() const
-{
- Q_D(const QWidget);
- if (!d->extra || !d->extra->topextra)
- return QRect();
-
- if (!isMaximized() && !isFullScreen())
- return geometry();
-
- return d->topData()->normalGeometry;
-}
-
-
-/*!
- \property QWidget::childrenRect
- \brief the bounding rectangle of the widget's children
-
- Hidden children are excluded.
-
- By default, for a widget with no children, this property contains a
- rectangle with zero width and height located at the origin.
-
- \sa childrenRegion() geometry()
-*/
-
-QRect QWidget::childrenRect() const
-{
- Q_D(const QWidget);
- QRect r(0, 0, 0, 0);
- for (int i = 0; i < d->children.size(); ++i) {
- QWidget *w = qobject_cast<QWidget *>(d->children.at(i));
- if (w && !w->isWindow() && !w->isHidden())
- r |= w->geometry();
- }
- return r;
-}
-
-/*!
- \property QWidget::childrenRegion
- \brief the combined region occupied by the widget's children
-
- Hidden children are excluded.
-
- By default, for a widget with no children, this property contains an
- empty region.
-
- \sa childrenRect() geometry() mask()
-*/
-
-QRegion QWidget::childrenRegion() const
-{
- Q_D(const QWidget);
- QRegion r;
- for (int i = 0; i < d->children.size(); ++i) {
- QWidget *w = qobject_cast<QWidget *>(d->children.at(i));
- if (w && !w->isWindow() && !w->isHidden()) {
- QRegion mask = w->mask();
- if (mask.isEmpty())
- r |= w->geometry();
- else
- r |= mask.translated(w->pos());
- }
- }
- return r;
-}
-
-
-/*!
- \property QWidget::minimumSize
- \brief the widget's minimum size
-
- The widget cannot be resized to a smaller size than the minimum
- widget size. The widget's size is forced to the minimum size if
- the current size is smaller.
-
- The minimum size set by this function will override the minimum size
- defined by QLayout. In order to unset the minimum size, use a
- value of \c{QSize(0, 0)}.
-
- By default, this property contains a size with zero width and height.
-
- \sa minimumWidth, minimumHeight, maximumSize, sizeIncrement
-*/
-
-QSize QWidget::minimumSize() const
-{
- Q_D(const QWidget);
- return d->extra ? QSize(d->extra->minw, d->extra->minh) : QSize(0, 0);
-}
-
-/*!
- \property QWidget::maximumSize
- \brief the widget's maximum size in pixels
-
- The widget cannot be resized to a larger size than the maximum
- widget size.
-
- By default, this property contains a size in which both width and height
- have values of 16777215.
-
- \note The definition of the \c QWIDGETSIZE_MAX macro limits the maximum size
- of widgets.
-
- \sa maximumWidth, maximumHeight, minimumSize, sizeIncrement
-*/
-
-QSize QWidget::maximumSize() const
-{
- Q_D(const QWidget);
- return d->extra ? QSize(d->extra->maxw, d->extra->maxh)
- : QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
-}
-
-
-/*!
- \property QWidget::minimumWidth
- \brief the widget's minimum width in pixels
-
- This property corresponds to the width held by the \l minimumSize property.
-
- By default, this property has a value of 0.
-
- \sa minimumSize, minimumHeight
-*/
-
-/*!
- \property QWidget::minimumHeight
- \brief the widget's minimum height in pixels
-
- This property corresponds to the height held by the \l minimumSize property.
-
- By default, this property has a value of 0.
-
- \sa minimumSize, minimumWidth
-*/
-
-/*!
- \property QWidget::maximumWidth
- \brief the widget's maximum width in pixels
-
- This property corresponds to the width held by the \l maximumSize property.
-
- By default, this property contains a value of 16777215.
-
- \note The definition of the \c QWIDGETSIZE_MAX macro limits the maximum size
- of widgets.
-
- \sa maximumSize, maximumHeight
-*/
-
-/*!
- \property QWidget::maximumHeight
- \brief the widget's maximum height in pixels
-
- This property corresponds to the height held by the \l maximumSize property.
-
- By default, this property contains a value of 16777215.
-
- \note The definition of the \c QWIDGETSIZE_MAX macro limits the maximum size
- of widgets.
-
- \sa maximumSize, maximumWidth
-*/
-
-/*!
- \property QWidget::sizeIncrement
- \brief the size increment of the widget
-
- When the user resizes the window, the size will move in steps of
- sizeIncrement().width() pixels horizontally and
- sizeIncrement.height() pixels vertically, with baseSize() as the
- basis. Preferred widget sizes are for non-negative integers \e i
- and \e j:
- \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 2
-
- Note that while you can set the size increment for all widgets, it
- only affects windows.
-
- By default, this property contains a size with zero width and height.
-
- \warning The size increment has no effect under Windows, and may
- be disregarded by the window manager on X11.
-
- \sa size, minimumSize, maximumSize
-*/
-QSize QWidget::sizeIncrement() const
-{
- Q_D(const QWidget);
- return (d->extra && d->extra->topextra)
- ? QSize(d->extra->topextra->incw, d->extra->topextra->inch)
- : QSize(0, 0);
-}
-
-/*!
- \property QWidget::baseSize
- \brief the base size of the widget
-
- The base size is used to calculate a proper widget size if the
- widget defines sizeIncrement().
-
- By default, for a newly-created widget, this property contains a size with
- zero width and height.
-
- \sa setSizeIncrement()
-*/
-
-QSize QWidget::baseSize() const
-{
- Q_D(const QWidget);
- return (d->extra != 0 && d->extra->topextra != 0)
- ? QSize(d->extra->topextra->basew, d->extra->topextra->baseh)
- : QSize(0, 0);
-}
-
-bool QWidgetPrivate::setMinimumSize_helper(int &minw, int &minh)
-{
- Q_Q(QWidget);
-
-#ifdef Q_WS_QWS
- if (q->isWindow()) {
- const QRect maxWindowRect = QApplication::desktop()->availableGeometry(QApplication::desktop()->screenNumber(q));
- if (!maxWindowRect.isEmpty()) {
- // ### This is really just a work-around. Layout shouldn't be
- // asking for minimum sizes bigger than the screen.
- if (minw > maxWindowRect.width())
- minw = maxWindowRect.width();
- if (minh > maxWindowRect.height())
- minh = maxWindowRect.height();
- }
- }
-#endif
- int mw = minw, mh = minh;
- if (mw == QWIDGETSIZE_MAX)
- mw = 0;
- if (mh == QWIDGETSIZE_MAX)
- mh = 0;
- if (minw > QWIDGETSIZE_MAX || minh > QWIDGETSIZE_MAX) {
- qWarning("QWidget::setMinimumSize: (%s/%s) "
- "The largest allowed size is (%d,%d)",
- q->objectName().toLocal8Bit().data(), q->metaObject()->className(), QWIDGETSIZE_MAX,
- QWIDGETSIZE_MAX);
- minw = mw = qMin<int>(minw, QWIDGETSIZE_MAX);
- minh = mh = qMin<int>(minh, QWIDGETSIZE_MAX);
- }
- if (minw < 0 || minh < 0) {
- qWarning("QWidget::setMinimumSize: (%s/%s) Negative sizes (%d,%d) "
- "are not possible",
- q->objectName().toLocal8Bit().data(), q->metaObject()->className(), minw, minh);
- minw = mw = qMax(minw, 0);
- minh = mh = qMax(minh, 0);
- }
- createExtra();
- if (extra->minw == mw && extra->minh == mh)
- return false;
- extra->minw = mw;
- extra->minh = mh;
- extra->explicitMinSize = (mw ? Qt::Horizontal : 0) | (mh ? Qt::Vertical : 0);
- return true;
-}
-
-/*!
- \overload
-
- This function corresponds to setMinimumSize(QSize(minw, minh)).
- Sets the minimum width to \a minw and the minimum height to \a
- minh.
-*/
-
-void QWidget::setMinimumSize(int minw, int minh)
-{
- Q_D(QWidget);
- if (!d->setMinimumSize_helper(minw, minh))
- return;
-
- if (isWindow())
- d->setConstraints_sys();
- if (minw > width() || minh > height()) {
- bool resized = testAttribute(Qt::WA_Resized);
- bool maximized = isMaximized();
- resize(qMax(minw,width()), qMax(minh,height()));
- setAttribute(Qt::WA_Resized, resized); //not a user resize
- if (maximized)
- data->window_state = data->window_state | Qt::WindowMaximized;
- }
-#ifndef QT_NO_GRAPHICSVIEW
- if (d->extra) {
- if (d->extra->proxyWidget)
- d->extra->proxyWidget->setMinimumSize(minw, minh);
- }
-#endif
- d->updateGeometry_helper(d->extra->minw == d->extra->maxw && d->extra->minh == d->extra->maxh);
-}
-
-bool QWidgetPrivate::setMaximumSize_helper(int &maxw, int &maxh)
-{
- Q_Q(QWidget);
- if (maxw > QWIDGETSIZE_MAX || maxh > QWIDGETSIZE_MAX) {
- qWarning("QWidget::setMaximumSize: (%s/%s) "
- "The largest allowed size is (%d,%d)",
- q->objectName().toLocal8Bit().data(), q->metaObject()->className(), QWIDGETSIZE_MAX,
- QWIDGETSIZE_MAX);
- maxw = qMin<int>(maxw, QWIDGETSIZE_MAX);
- maxh = qMin<int>(maxh, QWIDGETSIZE_MAX);
- }
- if (maxw < 0 || maxh < 0) {
- qWarning("QWidget::setMaximumSize: (%s/%s) Negative sizes (%d,%d) "
- "are not possible",
- q->objectName().toLocal8Bit().data(), q->metaObject()->className(), maxw, maxh);
- maxw = qMax(maxw, 0);
- maxh = qMax(maxh, 0);
- }
- createExtra();
- if (extra->maxw == maxw && extra->maxh == maxh)
- return false;
- extra->maxw = maxw;
- extra->maxh = maxh;
- extra->explicitMaxSize = (maxw != QWIDGETSIZE_MAX ? Qt::Horizontal : 0) |
- (maxh != QWIDGETSIZE_MAX ? Qt::Vertical : 0);
- return true;
-}
-
-/*!
- \overload
-
- This function corresponds to setMaximumSize(QSize(\a maxw, \a
- maxh)). Sets the maximum width to \a maxw and the maximum height
- to \a maxh.
-*/
-void QWidget::setMaximumSize(int maxw, int maxh)
-{
- Q_D(QWidget);
- if (!d->setMaximumSize_helper(maxw, maxh))
- return;
-
- if (isWindow())
- d->setConstraints_sys();
- if (maxw < width() || maxh < height()) {
- bool resized = testAttribute(Qt::WA_Resized);
- resize(qMin(maxw,width()), qMin(maxh,height()));
- setAttribute(Qt::WA_Resized, resized); //not a user resize
- }
-
-#ifndef QT_NO_GRAPHICSVIEW
- if (d->extra) {
- if (d->extra->proxyWidget)
- d->extra->proxyWidget->setMaximumSize(maxw, maxh);
- }
-#endif
-
- d->updateGeometry_helper(d->extra->minw == d->extra->maxw && d->extra->minh == d->extra->maxh);
-}
-
-/*!
- \overload
-
- Sets the x (width) size increment to \a w and the y (height) size
- increment to \a h.
-*/
-void QWidget::setSizeIncrement(int w, int h)
-{
- Q_D(QWidget);
- d->createTLExtra();
- QTLWExtra* x = d->topData();
- if (x->incw == w && x->inch == h)
- return;
- x->incw = w;
- x->inch = h;
- if (isWindow())
- d->setConstraints_sys();
-}
-
-/*!
- \overload
-
- This corresponds to setBaseSize(QSize(\a basew, \a baseh)). Sets
- the widgets base size to width \a basew and height \a baseh.
-*/
-void QWidget::setBaseSize(int basew, int baseh)
-{
- Q_D(QWidget);
- d->createTLExtra();
- QTLWExtra* x = d->topData();
- if (x->basew == basew && x->baseh == baseh)
- return;
- x->basew = basew;
- x->baseh = baseh;
- if (isWindow())
- d->setConstraints_sys();
-}
-
-/*!
- Sets both the minimum and maximum sizes of the widget to \a s,
- thereby preventing it from ever growing or shrinking.
-
- This will override the default size constraints set by QLayout.
-
- To remove constraints, set the size to QWIDGETSIZE_MAX.
-
- Alternatively, if you want the widget to have a
- fixed size based on its contents, you can call
- QLayout::setSizeConstraint(QLayout::SetFixedSize);
-
- \sa maximumSize, minimumSize
-*/
-
-void QWidget::setFixedSize(const QSize & s)
-{
- setFixedSize(s.width(), s.height());
-}
-
-
-/*!
- \fn void QWidget::setFixedSize(int w, int h)
- \overload
-
- Sets the width of the widget to \a w and the height to \a h.
-*/
-
-void QWidget::setFixedSize(int w, int h)
-{
- Q_D(QWidget);
-#ifdef Q_WS_QWS
- // temporary fix for 4.3.x.
- // Should move the embedded spesific contraints in setMinimumSize_helper into QLayout
- int tmpW = w;
- int tmpH = h;
- bool minSizeSet = d->setMinimumSize_helper(tmpW, tmpH);
-#else
- bool minSizeSet = d->setMinimumSize_helper(w, h);
-#endif
- bool maxSizeSet = d->setMaximumSize_helper(w, h);
- if (!minSizeSet && !maxSizeSet)
- return;
-
- if (isWindow())
- d->setConstraints_sys();
- else
- d->updateGeometry_helper(true);
-
- if (w != QWIDGETSIZE_MAX || h != QWIDGETSIZE_MAX)
- resize(w, h);
-}
-
-void QWidget::setMinimumWidth(int w)
-{
- Q_D(QWidget);
- d->createExtra();
- uint expl = d->extra->explicitMinSize | (w ? Qt::Horizontal : 0);
- setMinimumSize(w, minimumSize().height());
- d->extra->explicitMinSize = expl;
-}
-
-void QWidget::setMinimumHeight(int h)
-{
- Q_D(QWidget);
- d->createExtra();
- uint expl = d->extra->explicitMinSize | (h ? Qt::Vertical : 0);
- setMinimumSize(minimumSize().width(), h);
- d->extra->explicitMinSize = expl;
-}
-
-void QWidget::setMaximumWidth(int w)
-{
- Q_D(QWidget);
- d->createExtra();
- uint expl = d->extra->explicitMaxSize | (w == QWIDGETSIZE_MAX ? 0 : Qt::Horizontal);
- setMaximumSize(w, maximumSize().height());
- d->extra->explicitMaxSize = expl;
-}
-
-void QWidget::setMaximumHeight(int h)
-{
- Q_D(QWidget);
- d->createExtra();
- uint expl = d->extra->explicitMaxSize | (h == QWIDGETSIZE_MAX ? 0 : Qt::Vertical);
- setMaximumSize(maximumSize().width(), h);
- d->extra->explicitMaxSize = expl;
-}
-
-/*!
- Sets both the minimum and maximum width of the widget to \a w
- without changing the heights. Provided for convenience.
-
- \sa sizeHint() minimumSize() maximumSize() setFixedSize()
-*/
-
-void QWidget::setFixedWidth(int w)
-{
- Q_D(QWidget);
- d->createExtra();
- uint explMin = d->extra->explicitMinSize | Qt::Horizontal;
- uint explMax = d->extra->explicitMaxSize | Qt::Horizontal;
- setMinimumSize(w, minimumSize().height());
- setMaximumSize(w, maximumSize().height());
- d->extra->explicitMinSize = explMin;
- d->extra->explicitMaxSize = explMax;
-}
-
-
-/*!
- Sets both the minimum and maximum heights of the widget to \a h
- without changing the widths. Provided for convenience.
-
- \sa sizeHint() minimumSize() maximumSize() setFixedSize()
-*/
-
-void QWidget::setFixedHeight(int h)
-{
- Q_D(QWidget);
- d->createExtra();
- uint explMin = d->extra->explicitMinSize | Qt::Vertical;
- uint explMax = d->extra->explicitMaxSize | Qt::Vertical;
- setMinimumSize(minimumSize().width(), h);
- setMaximumSize(maximumSize().width(), h);
- d->extra->explicitMinSize = explMin;
- d->extra->explicitMaxSize = explMax;
-}
-
-
-/*!
- Translates the widget coordinate \a pos to the coordinate system
- of \a parent. The \a parent must not be 0 and must be a parent
- of the calling widget.
-
- \sa mapFrom() mapToParent() mapToGlobal() underMouse()
-*/
-
-QPoint QWidget::mapTo(QWidget * parent, const QPoint & pos) const
-{
- QPoint p = pos;
- if (parent) {
- const QWidget * w = this;
- while (w != parent) {
- Q_ASSERT_X(w, "QWidget::mapTo(QWidget *parent, const QPoint &pos)",
- "parent must be in parent hierarchy");
- p = w->mapToParent(p);
- w = w->parentWidget();
- }
- }
- return p;
-}
-
-
-/*!
- Translates the widget coordinate \a pos from the coordinate system
- of \a parent to this widget's coordinate system. The \a parent
- must not be 0 and must be a parent of the calling widget.
-
- \sa mapTo() mapFromParent() mapFromGlobal() underMouse()
-*/
-
-QPoint QWidget::mapFrom(QWidget * parent, const QPoint & pos) const
-{
- QPoint p(pos);
- if (parent) {
- const QWidget * w = this;
- while (w != parent) {
- Q_ASSERT_X(w, "QWidget::mapFrom(QWidget *parent, const QPoint &pos)",
- "parent must be in parent hierarchy");
-
- p = w->mapFromParent(p);
- w = w->parentWidget();
- }
- }
- return p;
-}
-
-
-/*!
- Translates the widget coordinate \a pos to a coordinate in the
- parent widget.
-
- Same as mapToGlobal() if the widget has no parent.
-
- \sa mapFromParent() mapTo() mapToGlobal() underMouse()
-*/
-
-QPoint QWidget::mapToParent(const QPoint &pos) const
-{
- return pos + data->crect.topLeft();
-}
-
-/*!
- Translates the parent widget coordinate \a pos to widget
- coordinates.
-
- Same as mapFromGlobal() if the widget has no parent.
-
- \sa mapToParent() mapFrom() mapFromGlobal() underMouse()
-*/
-
-QPoint QWidget::mapFromParent(const QPoint &pos) const
-{
- return pos - data->crect.topLeft();
-}
-
-
-/*!
- Returns the window for this widget, i.e. the next ancestor widget
- that has (or could have) a window-system frame.
-
- If the widget is a window, the widget itself is returned.
-
- Typical usage is changing the window title:
-
- \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 3
-
- \sa isWindow()
-*/
-
-QWidget *QWidget::window() const
-{
- QWidget *w = (QWidget *)this;
- QWidget *p = w->parentWidget();
- while (!w->isWindow() && p) {
- w = p;
- p = p->parentWidget();
- }
- return w;
-}
-
-/*!
- \since 4.4
-
- Returns the native parent for this widget, i.e. the next ancestor widget
- that has a system identifier, or 0 if it does not have any native parent.
-
- \sa effectiveWinId()
-*/
-QWidget *QWidget::nativeParentWidget() const
-{
- QWidget *parent = parentWidget();
- while (parent && !parent->internalWinId())
- parent = parent->parentWidget();
- return parent;
-}
-
-/*! \fn QWidget *QWidget::topLevelWidget() const
- \obsolete
-
- Use window() instead.
-*/
-
-#ifdef QT3_SUPPORT
-/*!
- Returns the color role used for painting the widget's background.
-
- Use QPalette(backgroundRole(()) instead.
-*/
-Qt::BackgroundMode QWidget::backgroundMode() const
-{
- if (testAttribute(Qt::WA_NoSystemBackground))
- return Qt::NoBackground;
- switch(backgroundRole()) {
- case QPalette::WindowText:
- return Qt::PaletteForeground;
- case QPalette::Button:
- return Qt::PaletteButton;
- case QPalette::Light:
- return Qt::PaletteLight;
- case QPalette::Midlight:
- return Qt::PaletteMidlight;
- case QPalette::Dark:
- return Qt::PaletteDark;
- case QPalette::Mid:
- return Qt::PaletteMid;
- case QPalette::Text:
- return Qt::PaletteText;
- case QPalette::BrightText:
- return Qt::PaletteBrightText;
- case QPalette::Base:
- return Qt::PaletteBase;
- case QPalette::Window:
- return Qt::PaletteBackground;
- case QPalette::Shadow:
- return Qt::PaletteShadow;
- case QPalette::Highlight:
- return Qt::PaletteHighlight;
- case QPalette::HighlightedText:
- return Qt::PaletteHighlightedText;
- case QPalette::ButtonText:
- return Qt::PaletteButtonText;
- case QPalette::Link:
- return Qt::PaletteLink;
- case QPalette::LinkVisited:
- return Qt::PaletteLinkVisited;
- default:
- break;
- }
- return Qt::NoBackground;
-}
-
-/*!
- \fn void QWidget::setBackgroundMode(Qt::BackgroundMode
- widgetBackground, Qt::BackgroundMode paletteBackground)
-
- Sets the color role used for painting the widget's background to
- background mode \a widgetBackground. The \a paletteBackground mode
- parameter is ignored.
-*/
-void QWidget::setBackgroundMode(Qt::BackgroundMode m, Qt::BackgroundMode)
-{
- Q_D(QWidget);
- if(m == Qt::NoBackground) {
- setAttribute(Qt::WA_NoSystemBackground, true);
- return;
- }
- setAttribute(Qt::WA_NoSystemBackground, false);
- d->fg_role = QPalette::NoRole;
- QPalette::ColorRole role = d->bg_role;
- switch(m) {
- case Qt::FixedColor:
- case Qt::FixedPixmap:
- break;
- case Qt::PaletteForeground:
- role = QPalette::WindowText;
- break;
- case Qt::PaletteButton:
- role = QPalette::Button;
- break;
- case Qt::PaletteLight:
- role = QPalette::Light;
- break;
- case Qt::PaletteMidlight:
- role = QPalette::Midlight;
- break;
- case Qt::PaletteDark:
- role = QPalette::Dark;
- break;
- case Qt::PaletteMid:
- role = QPalette::Mid;
- break;
- case Qt::PaletteText:
- role = QPalette::Text;
- break;
- case Qt::PaletteBrightText:
- role = QPalette::BrightText;
- break;
- case Qt::PaletteBase:
- role = QPalette::Base;
- break;
- case Qt::PaletteBackground:
- role = QPalette::Window;
- break;
- case Qt::PaletteShadow:
- role = QPalette::Shadow;
- break;
- case Qt::PaletteHighlight:
- role = QPalette::Highlight;
- break;
- case Qt::PaletteHighlightedText:
- role = QPalette::HighlightedText;
- break;
- case Qt::PaletteButtonText:
- role = QPalette::ButtonText;
- break;
- case Qt::PaletteLink:
- role = QPalette::Link;
- break;
- case Qt::PaletteLinkVisited:
- role = QPalette::LinkVisited;
- break;
- case Qt::X11ParentRelative:
- d->fg_role = role = QPalette::NoRole;
- default:
- break;
- }
- setBackgroundRole(role);
-}
-
-/*!
- The widget mapper is no longer part of the public API.
-*/
-QT3_SUPPORT QWidgetMapper *QWidget::wmapper() { return QWidgetPrivate::mapper; }
-
-#endif
-
-
-/*!
- Returns the background role of the widget.
-
- The background role defines the brush from the widget's \l palette that
- is used to render the background.
-
- If no explicit background role is set, the widget inherts its parent
- widget's background role.
-
- \sa setBackgroundRole(), foregroundRole()
- */
-QPalette::ColorRole QWidget::backgroundRole() const
-{
-
- const QWidget *w = this;
- do {
- QPalette::ColorRole role = w->d_func()->bg_role;
- if (role != QPalette::NoRole)
- return role;
- if (w->isWindow() || w->windowType() == Qt::SubWindow)
- break;
- w = w->parentWidget();
- } while (w);
- return QPalette::Window;
-}
-
-/*!
- Sets the background role of the widget to \a role.
-
- The background role defines the brush from the widget's \l palette that
- is used to render the background.
-
- If \a role is QPalette::NoRole, then the widget inherits its
- parent's background role.
-
- Note that styles are free to choose any color from the palette.
- You can modify the palette or set a style sheet if you don't
- achieve the result you want with setBackgroundRole().
-
- \sa backgroundRole(), foregroundRole()
- */
-
-void QWidget::setBackgroundRole(QPalette::ColorRole role)
-{
- Q_D(QWidget);
- d->bg_role = role;
- d->updateSystemBackground();
- d->propagatePaletteChange();
- d->updateIsOpaque();
-}
-
-/*!
- Returns the foreground role.
-
- The foreground role defines the color from the widget's \l palette that
- is used to draw the foreground.
-
- If no explicit foreground role is set, the function returns a role
- that contrasts with the background role.
-
- \sa setForegroundRole(), backgroundRole()
- */
-QPalette::ColorRole QWidget::foregroundRole() const
-{
- Q_D(const QWidget);
- QPalette::ColorRole rl = QPalette::ColorRole(d->fg_role);
- if (rl != QPalette::NoRole)
- return rl;
- QPalette::ColorRole role = QPalette::WindowText;
- switch (backgroundRole()) {
- case QPalette::Button:
- role = QPalette::ButtonText;
- break;
- case QPalette::Base:
- role = QPalette::Text;
- break;
- case QPalette::Dark:
- case QPalette::Shadow:
- role = QPalette::Light;
- break;
- case QPalette::Highlight:
- role = QPalette::HighlightedText;
- break;
- case QPalette::ToolTipBase:
- role = QPalette::ToolTipText;
- break;
- default:
- ;
- }
- return role;
-}
-
-/*!
- Sets the foreground role of the widget to \a role.
-
- The foreground role defines the color from the widget's \l palette that
- is used to draw the foreground.
-
- If \a role is QPalette::NoRole, the widget uses a foreground role
- that contrasts with the background role.
-
- Note that styles are free to choose any color from the palette.
- You can modify the palette or set a style sheet if you don't
- achieve the result you want with setForegroundRole().
-
- \sa foregroundRole(), backgroundRole()
- */
-void QWidget::setForegroundRole(QPalette::ColorRole role)
-{
- Q_D(QWidget);
- d->fg_role = role;
- d->updateSystemBackground();
- d->propagatePaletteChange();
-}
-
-/*!
- \property QWidget::palette
- \brief the widget's palette
-
- This property describes the widget's palette. The palette is used by the
- widget's style when rendering standard components, and is available as a
- means to ensure that custom widgets can maintain consistency with the
- native platform's look and feel. It's common that different platforms, or
- different styles, have different palettes.
-
- When you assign a new palette to a widget, the color roles from this
- palette are combined with the widget's default palette to form the
- widget's final palette. The palette entry for the widget's background role
- is used to fill the widget's background (see QWidget::autoFillBackground),
- and the foreground role initializes QPainter's pen.
-
- The default depends on the system environment. QApplication maintains a
- system/theme palette which serves as a default for all widgets. There may
- also be special palette defaults for certain types of widgets (e.g., on
- Windows XP and Vista, all classes that derive from QMenuBar have a special
- default palette). You can also define default palettes for widgets
- yourself by passing a custom palette and the name of a widget to
- QApplication::setPalette(). Finally, the style always has the option of
- polishing the palette as it's assigned (see QStyle::polish()).
-
- QWidget propagates explicit palette roles from parent to child. If you
- assign a brush or color to a specific role on a palette and assign that
- palette to a widget, that role will propagate to all the widget's
- children, overriding any system defaults for that role. Note that palettes
- by default don't propagate to windows (see isWindow()) unless the
- Qt::WA_WindowPropagation attribute is enabled.
-
- QWidget's palette propagation is similar to its font propagation.
-
- The current style, which is used to render the content of all standard Qt
- widgets, is free to choose colors and brushes from the widget palette, or
- in some cases, to ignore the palette (partially, or completely). In
- particular, certain styles like GTK style, Mac style, Windows XP, and
- Vista style, depend on third party APIs to render the content of widgets,
- and these styles typically do not follow the palette. Because of this,
- assigning roles to a widget's palette is not guaranteed to change the
- appearance of the widget. Instead, you may choose to apply a \l
- styleSheet. You can refer to our Knowledge Base article
- \l{http://qt.nokia.com/developer/knowledgebase/22}{here} for more
- information.
-
- \warning Do not use this function in conjunction with \l{Qt Style Sheets}.
- When using style sheets, the palette of a widget can be customized using
- the "color", "background-color", "selection-color",
- "selection-background-color" and "alternate-background-color".
-
- \sa QApplication::palette(), QWidget::font()
-*/
-const QPalette &QWidget::palette() const
-{
- if (!isEnabled()) {
- data->pal.setCurrentColorGroup(QPalette::Disabled);
- } else if ((!isVisible() || isActiveWindow())
-#if defined(Q_OS_WIN) && !defined(Q_WS_WINCE)
- && !QApplicationPrivate::isBlockedByModal(const_cast<QWidget *>(this))
-#endif
- ) {
- data->pal.setCurrentColorGroup(QPalette::Active);
- } else {
-#ifdef Q_WS_MAC
- extern bool qt_mac_can_clickThrough(const QWidget *); //qwidget_mac.cpp
- if (qt_mac_can_clickThrough(this))
- data->pal.setCurrentColorGroup(QPalette::Active);
- else
-#endif
- data->pal.setCurrentColorGroup(QPalette::Inactive);
- }
- return data->pal;
-}
-
-void QWidget::setPalette(const QPalette &palette)
-{
- Q_D(QWidget);
- setAttribute(Qt::WA_SetPalette, palette.resolve() != 0);
-
- // Determine which palette is inherited from this widget's ancestors and
- // QApplication::palette, resolve this against \a palette (attributes from
- // the inherited palette are copied over this widget's palette). Then
- // propagate this palette to this widget's children.
- QPalette naturalPalette = d->naturalWidgetPalette(d->inheritedPaletteResolveMask);
- QPalette resolvedPalette = palette.resolve(naturalPalette);
- d->setPalette_helper(resolvedPalette);
-}
-
-/*!
- \internal
-
- Returns the palette that the widget \a w inherits from its ancestors and
- QApplication::palette. \a inheritedMask is the combination of the widget's
- ancestors palette request masks (i.e., which attributes from the parent
- widget's palette are implicitly imposed on this widget by the user). Note
- that this font does not take into account the palette set on \a w itself.
-*/
-QPalette QWidgetPrivate::naturalWidgetPalette(uint inheritedMask) const
-{
- Q_Q(const QWidget);
- QPalette naturalPalette = QApplication::palette(q);
- if (!q->testAttribute(Qt::WA_StyleSheet)
- && (!q->isWindow() || q->testAttribute(Qt::WA_WindowPropagation)
-#ifndef QT_NO_GRAPHICSVIEW
- || (extra && extra->proxyWidget)
-#endif //QT_NO_GRAPHICSVIEW
- )) {
- if (QWidget *p = q->parentWidget()) {
- if (!p->testAttribute(Qt::WA_StyleSheet)) {
- if (!naturalPalette.isCopyOf(QApplication::palette())) {
- QPalette inheritedPalette = p->palette();
- inheritedPalette.resolve(inheritedMask);
- naturalPalette = inheritedPalette.resolve(naturalPalette);
- } else {
- naturalPalette = p->palette();
- }
- }
- }
-#ifndef QT_NO_GRAPHICSVIEW
- else if (extra && extra->proxyWidget) {
- QPalette inheritedPalette = extra->proxyWidget->palette();
- inheritedPalette.resolve(inheritedMask);
- naturalPalette = inheritedPalette.resolve(naturalPalette);
- }
-#endif //QT_NO_GRAPHICSVIEW
- }
- naturalPalette.resolve(0);
- return naturalPalette;
-}
-/*!
- \internal
-
- Determine which palette is inherited from this widget's ancestors and
- QApplication::palette, resolve this against this widget's palette
- (attributes from the inherited palette are copied over this widget's
- palette). Then propagate this palette to this widget's children.
-*/
-void QWidgetPrivate::resolvePalette()
-{
- QPalette naturalPalette = naturalWidgetPalette(inheritedPaletteResolveMask);
- QPalette resolvedPalette = data.pal.resolve(naturalPalette);
- setPalette_helper(resolvedPalette);
-}
-
-void QWidgetPrivate::setPalette_helper(const QPalette &palette)
-{
- Q_Q(QWidget);
- if (data.pal == palette && data.pal.resolve() == palette.resolve())
- return;
- data.pal = palette;
- updateSystemBackground();
- propagatePaletteChange();
- updateIsOpaque();
- q->update();
- updateIsOpaque();
-}
-
-/*!
- \property QWidget::font
- \brief the font currently set for the widget
-
- This property describes the widget's requested font. The font is used by
- the widget's style when rendering standard components, and is available as
- a means to ensure that custom widgets can maintain consistency with the
- native platform's look and feel. It's common that different platforms, or
- different styles, define different fonts for an application.
-
- When you assign a new font to a widget, the properties from this font are
- combined with the widget's default font to form the widget's final
- font. You can call fontInfo() to get a copy of the widget's final
- font. The final font is also used to initialize QPainter's font.
-
- The default depends on the system environment. QApplication maintains a
- system/theme font which serves as a default for all widgets. There may
- also be special font defaults for certain types of widgets. You can also
- define default fonts for widgets yourself by passing a custom font and the
- name of a widget to QApplication::setFont(). Finally, the font is matched
- against Qt's font database to find the best match.
-
- QWidget propagates explicit font properties from parent to child. If you
- change a specific property on a font and assign that font to a widget,
- that property will propagate to all the widget's children, overriding any
- system defaults for that property. Note that fonts by default don't
- propagate to windows (see isWindow()) unless the Qt::WA_WindowPropagation
- attribute is enabled.
-
- QWidget's font propagation is similar to its palette propagation.
-
- The current style, which is used to render the content of all standard Qt
- widgets, is free to choose to use the widget font, or in some cases, to
- ignore it (partially, or completely). In particular, certain styles like
- GTK style, Mac style, Windows XP, and Vista style, apply special
- modifications to the widget font to match the platform's native look and
- feel. Because of this, assigning properties to a widget's font is not
- guaranteed to change the appearance of the widget. Instead, you may choose
- to apply a \l styleSheet.
-
- \note If \l{Qt Style Sheets} are used on the same widget as setFont(),
- style sheets will take precedence if the settings conflict.
-
- \sa fontInfo(), fontMetrics()
-*/
-
-void QWidget::setFont(const QFont &font)
-{
- Q_D(QWidget);
-
-#ifndef QT_NO_STYLE_STYLESHEET
- const QStyleSheetStyle* style;
- if (d->extra && (style = qobject_cast<const QStyleSheetStyle*>(d->extra->style))) {
- style->saveWidgetFont(this, font);
- }
-#endif
-
- setAttribute(Qt::WA_SetFont, font.resolve() != 0);
-
- // Determine which font is inherited from this widget's ancestors and
- // QApplication::font, resolve this against \a font (attributes from the
- // inherited font are copied over). Then propagate this font to this
- // widget's children.
- QFont naturalFont = d->naturalWidgetFont(d->inheritedFontResolveMask);
- QFont resolvedFont = font.resolve(naturalFont);
- d->setFont_helper(resolvedFont);
-}
-
-/*
- \internal
-
- Returns the font that the widget \a w inherits from its ancestors and
- QApplication::font. \a inheritedMask is the combination of the widget's
- ancestors font request masks (i.e., which attributes from the parent
- widget's font are implicitly imposed on this widget by the user). Note
- that this font does not take into account the font set on \a w itself.
-
- ### Stylesheet has a different font propagation mechanism. When a stylesheet
- is applied, fonts are not propagated anymore
-*/
-QFont QWidgetPrivate::naturalWidgetFont(uint inheritedMask) const
-{
- Q_Q(const QWidget);
- QFont naturalFont = QApplication::font(q);
- if (!q->testAttribute(Qt::WA_StyleSheet)
- && (!q->isWindow() || q->testAttribute(Qt::WA_WindowPropagation)
-#ifndef QT_NO_GRAPHICSVIEW
- || (extra && extra->proxyWidget)
-#endif //QT_NO_GRAPHICSVIEW
- )) {
- if (QWidget *p = q->parentWidget()) {
- if (!p->testAttribute(Qt::WA_StyleSheet)) {
- if (!naturalFont.isCopyOf(QApplication::font())) {
- QFont inheritedFont = p->font();
- inheritedFont.resolve(inheritedMask);
- naturalFont = inheritedFont.resolve(naturalFont);
- } else {
- naturalFont = p->font();
- }
- }
- }
-#ifndef QT_NO_GRAPHICSVIEW
- else if (extra && extra->proxyWidget) {
- QFont inheritedFont = extra->proxyWidget->font();
- inheritedFont.resolve(inheritedMask);
- naturalFont = inheritedFont.resolve(naturalFont);
- }
-#endif //QT_NO_GRAPHICSVIEW
- }
- naturalFont.resolve(0);
- return naturalFont;
-}
-
-/*!
- \internal
-
- Determine which font is implicitly imposed on this widget by its ancestors
- and QApplication::font, resolve this against its own font (attributes from
- the implicit font are copied over). Then propagate this font to this
- widget's children.
-*/
-void QWidgetPrivate::resolveFont()
-{
- QFont naturalFont = naturalWidgetFont(inheritedFontResolveMask);
- QFont resolvedFont = data.fnt.resolve(naturalFont);
- setFont_helper(resolvedFont);
-}
-
-/*!
- \internal
-
- Assign \a font to this widget, and propagate it to all children, except
- style sheet widgets (handled differently) and windows that don't enable
- window propagation. \a implicitMask is the union of all ancestor widgets'
- font request masks, and determines which attributes from this widget's
- font should propagate.
-*/
-void QWidgetPrivate::updateFont(const QFont &font)
-{
- Q_Q(QWidget);
-#ifndef QT_NO_STYLE_STYLESHEET
- const QStyleSheetStyle* cssStyle;
- cssStyle = extra ? qobject_cast<const QStyleSheetStyle*>(extra->style) : 0;
-#endif
-
-#ifdef QT3_SUPPORT
- QFont old = data.fnt;
-#endif
- data.fnt = QFont(font, q);
-#if defined(Q_WS_X11)
- // make sure the font set on this widget is associated with the correct screen
- data.fnt.x11SetScreen(xinfo.screen());
-#endif
- // Combine new mask with natural mask and propagate to children.
-#ifndef QT_NO_GRAPHICSVIEW
- if (!q->parentWidget() && extra && extra->proxyWidget) {
- QGraphicsProxyWidget *p = extra->proxyWidget;
- inheritedFontResolveMask = p->d_func()->inheritedFontResolveMask | p->font().resolve();
- } else
-#endif //QT_NO_GRAPHICSVIEW
- if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) {
- inheritedFontResolveMask = 0;
- }
- uint newMask = data.fnt.resolve() | inheritedFontResolveMask;
-
- for (int i = 0; i < children.size(); ++i) {
- QWidget *w = qobject_cast<QWidget*>(children.at(i));
- if (w) {
- if (0) {
-#ifndef QT_NO_STYLE_STYLESHEET
- } else if (w->testAttribute(Qt::WA_StyleSheet)) {
- // Style sheets follow a different font propagation scheme.
- if (cssStyle)
- cssStyle->updateStyleSheetFont(w);
-#endif
- } else if ((!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))) {
- // Propagate font changes.
- QWidgetPrivate *wd = w->d_func();
- wd->inheritedFontResolveMask = newMask;
- wd->resolveFont();
- }
- }
- }
-
-#ifndef QT_NO_STYLE_STYLESHEET
- if (cssStyle) {
- cssStyle->updateStyleSheetFont(q);
- }
-#endif
-
- QEvent e(QEvent::FontChange);
- QApplication::sendEvent(q, &e);
-#ifdef QT3_SUPPORT
- q->fontChange(old);
-#endif
-}
-
-void QWidgetPrivate::setLayoutDirection_helper(Qt::LayoutDirection direction)
-{
- Q_Q(QWidget);
-
- if ( (direction == Qt::RightToLeft) == q->testAttribute(Qt::WA_RightToLeft))
- return;
- q->setAttribute(Qt::WA_RightToLeft, (direction == Qt::RightToLeft));
- if (!children.isEmpty()) {
- for (int i = 0; i < children.size(); ++i) {
- QWidget *w = qobject_cast<QWidget*>(children.at(i));
- if (w && !w->isWindow() && !w->testAttribute(Qt::WA_SetLayoutDirection))
- w->d_func()->setLayoutDirection_helper(direction);
- }
- }
- QEvent e(QEvent::LayoutDirectionChange);
- QApplication::sendEvent(q, &e);
-}
-
-void QWidgetPrivate::resolveLayoutDirection()
-{
- Q_Q(const QWidget);
- if (!q->testAttribute(Qt::WA_SetLayoutDirection))
- setLayoutDirection_helper(q->isWindow() ? QApplication::layoutDirection() : q->parentWidget()->layoutDirection());
-}
-
-/*!
- \property QWidget::layoutDirection
-
- \brief the layout direction for this widget
-
- By default, this property is set to Qt::LeftToRight.
-
- When the layout direction is set on a widget, it will propagate to
- the widget's children, but not to a child that is a window and not
- to a child for which setLayoutDirection() has been explicitly
- called. Also, child widgets added \e after setLayoutDirection()
- has been called for the parent do not inherit the parent's layout
- direction.
-
- This method no longer affects text layout direction since Qt 4.7.
-
- \sa QApplication::layoutDirection
-*/
-void QWidget::setLayoutDirection(Qt::LayoutDirection direction)
-{
- Q_D(QWidget);
-
- if (direction == Qt::LayoutDirectionAuto) {
- unsetLayoutDirection();
- return;
- }
-
- setAttribute(Qt::WA_SetLayoutDirection);
- d->setLayoutDirection_helper(direction);
-}
-
-Qt::LayoutDirection QWidget::layoutDirection() const
-{
- return testAttribute(Qt::WA_RightToLeft) ? Qt::RightToLeft : Qt::LeftToRight;
-}
-
-void QWidget::unsetLayoutDirection()
-{
- Q_D(QWidget);
- setAttribute(Qt::WA_SetLayoutDirection, false);
- d->resolveLayoutDirection();
-}
-
-/*!
- \fn QFontMetrics QWidget::fontMetrics() const
-
- Returns the font metrics for the widget's current font.
- Equivalent to QFontMetrics(widget->font()).
-
- \sa font(), fontInfo(), setFont()
-*/
-
-/*!
- \fn QFontInfo QWidget::fontInfo() const
-
- Returns the font info for the widget's current font.
- Equivalent to QFontInto(widget->font()).
-
- \sa font(), fontMetrics(), setFont()
-*/
-
-
-/*!
- \property QWidget::cursor
- \brief the cursor shape for this widget
-
- The mouse cursor will assume this shape when it's over this
- widget. See the \link Qt::CursorShape list of predefined cursor
- objects\endlink for a range of useful shapes.
-
- An editor widget might use an I-beam cursor:
- \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 6
-
- If no cursor has been set, or after a call to unsetCursor(), the
- parent's cursor is used.
-
- By default, this property contains a cursor with the Qt::ArrowCursor
- shape.
-
- Some underlying window implementations will reset the cursor if it
- leaves a widget even if the mouse is grabbed. If you want to have
- a cursor set for all widgets, even when outside the window, consider
- QApplication::setOverrideCursor().
-
- \sa QApplication::setOverrideCursor()
-*/
-
-#ifndef QT_NO_CURSOR
-QCursor QWidget::cursor() const
-{
- Q_D(const QWidget);
- if (testAttribute(Qt::WA_SetCursor))
- return (d->extra && d->extra->curs)
- ? *d->extra->curs
- : QCursor(Qt::ArrowCursor);
- if (isWindow() || !parentWidget())
- return QCursor(Qt::ArrowCursor);
- return parentWidget()->cursor();
-}
-
-void QWidget::setCursor(const QCursor &cursor)
-{
- Q_D(QWidget);
-// On Mac we must set the cursor even if it is the ArrowCursor.
-#if !defined(Q_WS_MAC) && !defined(Q_WS_QWS)
- if (cursor.shape() != Qt::ArrowCursor
- || (d->extra && d->extra->curs))
-#endif
- {
- d->createExtra();
- QCursor *newCursor = new QCursor(cursor);
- delete d->extra->curs;
- d->extra->curs = newCursor;
- }
- setAttribute(Qt::WA_SetCursor);
- d->setCursor_sys(cursor);
-
- QEvent event(QEvent::CursorChange);
- QApplication::sendEvent(this, &event);
-}
-
-void QWidget::unsetCursor()
-{
- Q_D(QWidget);
- if (d->extra) {
- delete d->extra->curs;
- d->extra->curs = 0;
- }
- if (!isWindow())
- setAttribute(Qt::WA_SetCursor, false);
- d->unsetCursor_sys();
-
- QEvent event(QEvent::CursorChange);
- QApplication::sendEvent(this, &event);
-}
-
-#endif
-
-/*!
- \enum QWidget::RenderFlag
-
- This enum describes how to render the widget when calling QWidget::render().
-
- \value DrawWindowBackground If you enable this option, the widget's background
- is rendered into the target even if autoFillBackground is not set. By default,
- this option is enabled.
-
- \value DrawChildren If you enable this option, the widget's children
- are rendered recursively into the target. By default, this option is enabled.
-
- \value IgnoreMask If you enable this option, the widget's QWidget::mask()
- is ignored when rendering into the target. By default, this option is disabled.
-
- \since 4.3
-*/
-
-/*!
- \since 4.3
-
- Renders the \a sourceRegion of this widget into the \a target
- using \a renderFlags to determine how to render. Rendering
- starts at \a targetOffset in the \a target. For example:
-
- \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 7
-
- If \a sourceRegion is a null region, this function will use QWidget::rect() as
- the region, i.e. the entire widget.
-
- Ensure that you call QPainter::end() for the \a target device's
- active painter (if any) before rendering. For example:
-
- \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 8
-
- \note To obtain the contents of an OpenGL widget, use QGLWidget::grabFrameBuffer()
- or QGLWidget::renderPixmap() instead.
-*/
-void QWidget::render(QPaintDevice *target, const QPoint &targetOffset,
- const QRegion &sourceRegion, RenderFlags renderFlags)
-{
- d_func()->render(target, targetOffset, sourceRegion, renderFlags, false);
-}
-
-/*!
- \overload
-
- Renders the widget into the \a painter's QPainter::device().
-
- Transformations and settings applied to the \a painter will be used
- when rendering.
-
- \note The \a painter must be active. On Mac OS X the widget will be
- rendered into a QPixmap and then drawn by the \a painter.
-
- \sa QPainter::device()
-*/
-void QWidget::render(QPainter *painter, const QPoint &targetOffset,
- const QRegion &sourceRegion, RenderFlags renderFlags)
-{
- if (!painter) {
- qWarning("QWidget::render: Null pointer to painter");
- return;
- }
-
- if (!painter->isActive()) {
- qWarning("QWidget::render: Cannot render with an inactive painter");
- return;
- }
-
- const qreal opacity = painter->opacity();
- if (qFuzzyIsNull(opacity))
- return; // Fully transparent.
-
- Q_D(QWidget);
- const bool inRenderWithPainter = d->extra && d->extra->inRenderWithPainter;
- const QRegion toBePainted = !inRenderWithPainter ? d->prepareToRender(sourceRegion, renderFlags)
- : sourceRegion;
- if (toBePainted.isEmpty())
- return;
-
- if (!d->extra)
- d->createExtra();
- d->extra->inRenderWithPainter = true;
-
-#ifdef Q_WS_MAC
- d->render_helper(painter, targetOffset, toBePainted, renderFlags);
-#else
- QPaintEngine *engine = painter->paintEngine();
- Q_ASSERT(engine);
- QPaintEnginePrivate *enginePriv = engine->d_func();
- Q_ASSERT(enginePriv);
- QPaintDevice *target = engine->paintDevice();
- Q_ASSERT(target);
-
- // Render via a pixmap when dealing with non-opaque painters or printers.
- if (!inRenderWithPainter && (opacity < 1.0 || (target->devType() == QInternal::Printer))) {
- d->render_helper(painter, targetOffset, toBePainted, renderFlags);
- d->extra->inRenderWithPainter = false;
- return;
- }
-
- // Set new shared painter.
- QPainter *oldPainter = d->sharedPainter();
- d->setSharedPainter(painter);
-
- // Save current system clip, viewport and transform,
- const QTransform oldTransform = enginePriv->systemTransform;
- const QRegion oldSystemClip = enginePriv->systemClip;
- const QRegion oldSystemViewport = enginePriv->systemViewport;
-
- // This ensures that all painting triggered by render() is clipped to the current engine clip.
- if (painter->hasClipping()) {
- const QRegion painterClip = painter->deviceTransform().map(painter->clipRegion());
- enginePriv->setSystemViewport(oldSystemClip.isEmpty() ? painterClip : oldSystemClip & painterClip);
- } else {
- enginePriv->setSystemViewport(oldSystemClip);
- }
-
- render(target, targetOffset, toBePainted, renderFlags);
-
- // Restore system clip, viewport and transform.
- enginePriv->systemClip = oldSystemClip;
- enginePriv->setSystemViewport(oldSystemViewport);
- enginePriv->setSystemTransform(oldTransform);
-
- // Restore shared painter.
- d->setSharedPainter(oldPainter);
-#endif
-
- d->extra->inRenderWithPainter = false;
-}
-
-/*!
- \brief The graphicsEffect function returns a pointer to the
- widget's graphics effect.
-
- If the widget has no graphics effect, 0 is returned.
-
- \since 4.6
-
- \sa setGraphicsEffect()
-*/
-#ifndef QT_NO_GRAPHICSEFFECT
-QGraphicsEffect *QWidget::graphicsEffect() const
-{
- Q_D(const QWidget);
- return d->graphicsEffect;
-}
-#endif //QT_NO_GRAPHICSEFFECT
-
-/*!
-
- \brief The setGraphicsEffect function is for setting the widget's graphics effect.
-
- Sets \a effect as the widget's effect. If there already is an effect installed
- on this widget, QWidget will delete the existing effect before installing
- the new \a effect.
-
- If \a effect is the installed on a different widget, setGraphicsEffect() will remove
- the effect from the widget and install it on this widget.
-
- QWidget takes ownership of \a effect.
-
- \note This function will apply the effect on itself and all its children.
-
- \since 4.6
-
- \sa graphicsEffect()
-*/
-#ifndef QT_NO_GRAPHICSEFFECT
-void QWidget::setGraphicsEffect(QGraphicsEffect *effect)
-{
- Q_D(QWidget);
- if (d->graphicsEffect == effect)
- return;
-
- if (d->graphicsEffect) {
- d->invalidateBuffer(rect());
- delete d->graphicsEffect;
- d->graphicsEffect = 0;
- }
-
- if (effect) {
- // Set new effect.
- QGraphicsEffectSourcePrivate *sourced = new QWidgetEffectSourcePrivate(this);
- QGraphicsEffectSource *source = new QGraphicsEffectSource(*sourced);
- d->graphicsEffect = effect;
- effect->d_func()->setGraphicsEffectSource(source);
- update();
- }
-
- d->updateIsOpaque();
-}
-#endif //QT_NO_GRAPHICSEFFECT
-
-bool QWidgetPrivate::isAboutToShow() const
-{
- if (data.in_show)
- return true;
-
- Q_Q(const QWidget);
- if (q->isHidden())
- return false;
-
- // The widget will be shown if any of its ancestors are about to show.
- QWidget *parent = q->parentWidget();
- return parent ? parent->d_func()->isAboutToShow() : false;
-}
-
-QRegion QWidgetPrivate::prepareToRender(const QRegion &region, QWidget::RenderFlags renderFlags)
-{
- Q_Q(QWidget);
- const bool isVisible = q->isVisible();
-
- // Make sure the widget is laid out correctly.
- if (!isVisible && !isAboutToShow()) {
- QWidget *topLevel = q->window();
- (void)topLevel->d_func()->topData(); // Make sure we at least have top-data.
- topLevel->ensurePolished();
-
- // Invalidate the layout of hidden ancestors (incl. myself) and pretend
- // they're not explicitly hidden.
- QWidget *widget = q;
- QWidgetList hiddenWidgets;
- while (widget) {
- if (widget->isHidden()) {
- widget->setAttribute(Qt::WA_WState_Hidden, false);
- hiddenWidgets.append(widget);
- if (!widget->isWindow() && widget->parentWidget()->d_func()->layout)
- widget->d_func()->updateGeometry_helper(true);
- }
- widget = widget->parentWidget();
- }
-
- // Activate top-level layout.
- if (topLevel->d_func()->layout)
- topLevel->d_func()->layout->activate();
-
- // Adjust size if necessary.
- QTLWExtra *topLevelExtra = topLevel->d_func()->maybeTopData();
- if (topLevelExtra && !topLevelExtra->sizeAdjusted
- && !topLevel->testAttribute(Qt::WA_Resized)) {
- topLevel->adjustSize();
- topLevel->setAttribute(Qt::WA_Resized, false);
- }
-
- // Activate child layouts.
- topLevel->d_func()->activateChildLayoutsRecursively();
-
- // We're not cheating with WA_WState_Hidden anymore.
- for (int i = 0; i < hiddenWidgets.size(); ++i) {
- QWidget *widget = hiddenWidgets.at(i);
- widget->setAttribute(Qt::WA_WState_Hidden);
- if (!widget->isWindow() && widget->parentWidget()->d_func()->layout)
- widget->parentWidget()->d_func()->layout->invalidate();
- }
- } else if (isVisible) {
- q->window()->d_func()->sendPendingMoveAndResizeEvents(true, true);
- }
-
- // Calculate the region to be painted.
- QRegion toBePainted = !region.isEmpty() ? region : QRegion(q->rect());
- if (!(renderFlags & QWidget::IgnoreMask) && extra && extra->hasMask)
- toBePainted &= extra->mask;
- return toBePainted;
-}
-
-void QWidgetPrivate::render_helper(QPainter *painter, const QPoint &targetOffset, const QRegion &toBePainted,
- QWidget::RenderFlags renderFlags)
-{
- Q_ASSERT(painter);
- Q_ASSERT(!toBePainted.isEmpty());
-
- Q_Q(QWidget);
-#ifndef Q_WS_MAC
- const QTransform originalTransform = painter->worldTransform();
- const bool useDeviceCoordinates = originalTransform.isScaling();
- if (!useDeviceCoordinates) {
-#endif
- // Render via a pixmap.
- const QRect rect = toBePainted.boundingRect();
- const QSize size = rect.size();
- if (size.isNull())
- return;
-
- QPixmap pixmap(size);
- if (!(renderFlags & QWidget::DrawWindowBackground) || !isOpaque)
- pixmap.fill(Qt::transparent);
- q->render(&pixmap, QPoint(), toBePainted, renderFlags);
-
- const bool restore = !(painter->renderHints() & QPainter::SmoothPixmapTransform);
- painter->setRenderHints(QPainter::SmoothPixmapTransform, true);
-
- painter->drawPixmap(targetOffset, pixmap);
-
- if (restore)
- painter->setRenderHints(QPainter::SmoothPixmapTransform, false);
-
-#ifndef Q_WS_MAC
- } else {
- // Render via a pixmap in device coordinates (to avoid pixmap scaling).
- QTransform transform = originalTransform;
- transform.translate(targetOffset.x(), targetOffset.y());
-
- QPaintDevice *device = painter->device();
- Q_ASSERT(device);
-
- // Calculate device rect.
- const QRectF rect(toBePainted.boundingRect());
- QRect deviceRect = transform.mapRect(QRectF(0, 0, rect.width(), rect.height())).toAlignedRect();
- deviceRect &= QRect(0, 0, device->width(), device->height());
-
- QPixmap pixmap(deviceRect.size());
- pixmap.fill(Qt::transparent);
-
- // Create a pixmap device coordinate painter.
- QPainter pixmapPainter(&pixmap);
- pixmapPainter.setRenderHints(painter->renderHints());
- transform *= QTransform::fromTranslate(-deviceRect.x(), -deviceRect.y());
- pixmapPainter.setTransform(transform);
-
- q->render(&pixmapPainter, QPoint(), toBePainted, renderFlags);
- pixmapPainter.end();
-
- // And then draw the pixmap.
- painter->setTransform(QTransform());
- painter->drawPixmap(deviceRect.topLeft(), pixmap);
- painter->setTransform(originalTransform);
- }
-#endif
-}
-
-void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags,
- QPainter *sharedPainter, QWidgetBackingStore *backingStore)
-{
- if (rgn.isEmpty())
- return;
-
-#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
- if (qt_mac_clearDirtyOnWidgetInsideDrawWidget)
- dirtyOnWidget = QRegion();
-
- // We disable the rendering of QToolBar in the backingStore if
- // it's supposed to be in the unified toolbar on Mac OS X.
- if (backingStore && isInUnifiedToolbar)
- return;
-#endif // Q_WS_MAC && QT_MAC_USE_COCOA
-
-
- Q_Q(QWidget);
-#ifndef QT_NO_GRAPHICSEFFECT
- if (graphicsEffect && graphicsEffect->isEnabled()) {
- QGraphicsEffectSource *source = graphicsEffect->d_func()->source;
- QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
- (source->d_func());
- if (!sourced->context) {
- QWidgetPaintContext context(pdev, rgn, offset, flags, sharedPainter, backingStore);
- sourced->context = &context;
- if (!sharedPainter) {
- QPaintEngine *paintEngine = pdev->paintEngine();
- paintEngine->d_func()->systemClip = rgn.translated(offset);
- QPainter p(pdev);
- p.translate(offset);
- context.painter = &p;
- graphicsEffect->draw(&p);
- paintEngine->d_func()->systemClip = QRegion();
- } else {
- context.painter = sharedPainter;
- if (sharedPainter->worldTransform() != sourced->lastEffectTransform) {
- sourced->invalidateCache();
- sourced->lastEffectTransform = sharedPainter->worldTransform();
- }
- sharedPainter->save();
- sharedPainter->translate(offset);
- graphicsEffect->draw(sharedPainter);
- sharedPainter->restore();
- }
- sourced->context = 0;
- return;
- }
- }
-#endif //QT_NO_GRAFFICSEFFECT
-
- const bool asRoot = flags & DrawAsRoot;
- const bool alsoOnScreen = flags & DrawPaintOnScreen;
- const bool recursive = flags & DrawRecursive;
- const bool alsoInvisible = flags & DrawInvisible;
-
- Q_ASSERT(sharedPainter ? sharedPainter->isActive() : true);
-
- QRegion toBePainted(rgn);
- if (asRoot && !alsoInvisible)
- toBePainted &= clipRect(); //(rgn & visibleRegion());
- if (!(flags & DontSubtractOpaqueChildren))
- subtractOpaqueChildren(toBePainted, q->rect());
-
- if (!toBePainted.isEmpty()) {
- bool onScreen = paintOnScreen();
- if (!onScreen || alsoOnScreen) {
- //update the "in paint event" flag
- if (q->testAttribute(Qt::WA_WState_InPaintEvent))
- qWarning("QWidget::repaint: Recursive repaint detected");
- q->setAttribute(Qt::WA_WState_InPaintEvent);
-
- //clip away the new area
-#ifndef QT_NO_PAINT_DEBUG
- bool flushed = QWidgetBackingStore::flushPaint(q, toBePainted);
-#endif
- QPaintEngine *paintEngine = pdev->paintEngine();
- if (paintEngine) {
- setRedirected(pdev, -offset);
-
-#ifdef Q_WS_MAC
- // (Alien support) Special case for Mac when redirecting: If the paint device
- // is of the Widget type we need to set WA_WState_InPaintEvent since painting
- // outside the paint event is not supported on QWidgets. The attributeis
- // restored further down.
- if (pdev->devType() == QInternal::Widget)
- static_cast<QWidget *>(pdev)->setAttribute(Qt::WA_WState_InPaintEvent);
-
-#endif
- if (sharedPainter)
- paintEngine->d_func()->systemClip = toBePainted;
- else
- paintEngine->d_func()->systemRect = q->data->crect;
-
- //paint the background
- if ((asRoot || q->autoFillBackground() || onScreen || q->testAttribute(Qt::WA_StyledBackground))
- && !q->testAttribute(Qt::WA_OpaquePaintEvent) && !q->testAttribute(Qt::WA_NoSystemBackground)) {
- QPainter p(q);
- paintBackground(&p, toBePainted, (asRoot || onScreen) ? flags | DrawAsRoot : 0);
- }
-
- if (!sharedPainter)
- paintEngine->d_func()->systemClip = toBePainted.translated(offset);
-
- if (!onScreen && !asRoot && !isOpaque && q->testAttribute(Qt::WA_TintedBackground)) {
- QPainter p(q);
- QColor tint = q->palette().window().color();
- tint.setAlphaF(qreal(.6));
- p.fillRect(toBePainted.boundingRect(), tint);
- }
- }
-
-#if 0
- qDebug() << "painting" << q << "opaque ==" << isOpaque();
- qDebug() << "clipping to" << toBePainted << "location == " << offset
- << "geometry ==" << QRect(q->mapTo(q->window(), QPoint(0, 0)), q->size());
-#endif
-
- //actually send the paint event
- QPaintEvent e(toBePainted);
- QCoreApplication::sendSpontaneousEvent(q, &e);
-#if !defined(Q_WS_QWS) && !defined(Q_WS_QPA)
- if (backingStore && !onScreen && !asRoot && (q->internalWinId() || !q->nativeParentWidget()->isWindow()))
- backingStore->markDirtyOnScreen(toBePainted, q, offset);
-#endif
-
- //restore
- if (paintEngine) {
-#ifdef Q_WS_MAC
- if (pdev->devType() == QInternal::Widget)
- static_cast<QWidget *>(pdev)->setAttribute(Qt::WA_WState_InPaintEvent, false);
-#endif
- restoreRedirected();
- if (!sharedPainter)
- paintEngine->d_func()->systemRect = QRect();
- else
- paintEngine->d_func()->currentClipWidget = 0;
- paintEngine->d_func()->systemClip = QRegion();
- }
- q->setAttribute(Qt::WA_WState_InPaintEvent, false);
- if (q->paintingActive() && !q->testAttribute(Qt::WA_PaintOutsidePaintEvent))
- qWarning("QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent");
-
- if (paintEngine && paintEngine->autoDestruct()) {
- delete paintEngine;
- }
-
-#ifndef QT_NO_PAINT_DEBUG
- if (flushed)
- QWidgetBackingStore::unflushPaint(q, toBePainted);
-#endif
- } else if (q->isWindow()) {
- QPaintEngine *engine = pdev->paintEngine();
- if (engine) {
- QPainter p(pdev);
- p.setClipRegion(toBePainted);
- const QBrush bg = q->palette().brush(QPalette::Window);
- if (bg.style() == Qt::TexturePattern)
- p.drawTiledPixmap(q->rect(), bg.texture());
- else
- p.fillRect(q->rect(), bg);
-
- if (engine->autoDestruct())
- delete engine;
- }
- }
- }
-
- if (recursive && !children.isEmpty()) {
- paintSiblingsRecursive(pdev, children, children.size() - 1, rgn, offset, flags & ~DrawAsRoot
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- , q->windowSurface()
-#endif
- , sharedPainter, backingStore);
- }
-}
-
-void QWidgetPrivate::render(QPaintDevice *target, const QPoint &targetOffset,
- const QRegion &sourceRegion, QWidget::RenderFlags renderFlags,
- bool readyToRender)
-{
- if (!target) {
- qWarning("QWidget::render: null pointer to paint device");
- return;
- }
-
- const bool inRenderWithPainter = extra && extra->inRenderWithPainter;
- QRegion paintRegion = !inRenderWithPainter && !readyToRender
- ? prepareToRender(sourceRegion, renderFlags)
- : sourceRegion;
- if (paintRegion.isEmpty())
- return;
-
-#ifndef Q_WS_MAC
- QPainter *oldSharedPainter = inRenderWithPainter ? sharedPainter() : 0;
-
- // Use the target's shared painter if set (typically set when doing
- // "other->render(widget);" in the widget's paintEvent.
- if (target->devType() == QInternal::Widget) {
- QWidgetPrivate *targetPrivate = static_cast<QWidget *>(target)->d_func();
- if (targetPrivate->extra && targetPrivate->extra->inRenderWithPainter) {
- QPainter *targetPainter = targetPrivate->sharedPainter();
- if (targetPainter && targetPainter->isActive())
- setSharedPainter(targetPainter);
- }
- }
-#endif
-
- // Use the target's redirected device if set and adjust offset and paint
- // region accordingly. This is typically the case when people call render
- // from the paintEvent.
- QPoint offset = targetOffset;
- offset -= paintRegion.boundingRect().topLeft();
- QPoint redirectionOffset;
- QPaintDevice *redirected = 0;
-
- if (target->devType() == QInternal::Widget)
- redirected = static_cast<QWidget *>(target)->d_func()->redirected(&redirectionOffset);
- if (!redirected)
- redirected = QPainter::redirected(target, &redirectionOffset);
-
- if (redirected) {
- target = redirected;
- offset -= redirectionOffset;
- }
-
- if (!inRenderWithPainter) { // Clip handled by shared painter (in qpainter.cpp).
- if (QPaintEngine *targetEngine = target->paintEngine()) {
- const QRegion targetSystemClip = targetEngine->systemClip();
- if (!targetSystemClip.isEmpty())
- paintRegion &= targetSystemClip.translated(-offset);
- }
- }
-
- // Set backingstore flags.
- int flags = DrawPaintOnScreen | DrawInvisible;
- if (renderFlags & QWidget::DrawWindowBackground)
- flags |= DrawAsRoot;
-
- if (renderFlags & QWidget::DrawChildren)
- flags |= DrawRecursive;
- else
- flags |= DontSubtractOpaqueChildren;
-
-#ifdef Q_WS_QWS
- flags |= DontSetCompositionMode;
-#endif
-
- if (target->devType() == QInternal::Printer) {
- QPainter p(target);
- render_helper(&p, targetOffset, paintRegion, renderFlags);
- return;
- }
-
-#ifndef Q_WS_MAC
- // Render via backingstore.
- drawWidget(target, paintRegion, offset, flags, sharedPainter());
-
- // Restore shared painter.
- if (oldSharedPainter)
- setSharedPainter(oldSharedPainter);
-#else
- // Render via backingstore (no shared painter).
- drawWidget(target, paintRegion, offset, flags, 0);
-#endif
-}
-
-void QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *pdev, const QObjectList& siblings, int index, const QRegion &rgn,
- const QPoint &offset, int flags
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- , const QWindowSurface *currentSurface
-#endif
- , QPainter *sharedPainter, QWidgetBackingStore *backingStore)
-{
- QWidget *w = 0;
- QRect boundingRect;
- bool dirtyBoundingRect = true;
- const bool exludeOpaqueChildren = (flags & DontDrawOpaqueChildren);
- const bool excludeNativeChildren = (flags & DontDrawNativeChildren);
-
- do {
- QWidget *x = qobject_cast<QWidget*>(siblings.at(index));
- if (x && !(exludeOpaqueChildren && x->d_func()->isOpaque) && !x->isHidden() && !x->isWindow()
- && !(excludeNativeChildren && x->internalWinId())) {
- if (dirtyBoundingRect) {
- boundingRect = rgn.boundingRect();
- dirtyBoundingRect = false;
- }
-
- if (qRectIntersects(boundingRect, x->d_func()->effectiveRectFor(x->data->crect))) {
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- if (x->windowSurface() == currentSurface)
-#endif
- {
- w = x;
- break;
- }
- }
- }
- --index;
- } while (index >= 0);
-
- if (!w)
- return;
-
- QWidgetPrivate *wd = w->d_func();
- const QPoint widgetPos(w->data->crect.topLeft());
- const bool hasMask = wd->extra && wd->extra->hasMask && !wd->graphicsEffect;
- if (index > 0) {
- QRegion wr(rgn);
- if (wd->isOpaque)
- wr -= hasMask ? wd->extra->mask.translated(widgetPos) : w->data->crect;
- paintSiblingsRecursive(pdev, siblings, --index, wr, offset, flags
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- , currentSurface
-#endif
- , sharedPainter, backingStore);
- }
-
- if (w->updatesEnabled()
-#ifndef QT_NO_GRAPHICSVIEW
- && (!w->d_func()->extra || !w->d_func()->extra->proxyWidget)
-#endif //QT_NO_GRAPHICSVIEW
- ) {
- QRegion wRegion(rgn);
- wRegion &= wd->effectiveRectFor(w->data->crect);
- wRegion.translate(-widgetPos);
- if (hasMask)
- wRegion &= wd->extra->mask;
- wd->drawWidget(pdev, wRegion, offset + widgetPos, flags, sharedPainter, backingStore);
- }
-}
-
-#ifndef QT_NO_GRAPHICSEFFECT
-QRectF QWidgetEffectSourcePrivate::boundingRect(Qt::CoordinateSystem system) const
-{
- if (system != Qt::DeviceCoordinates)
- return m_widget->rect();
-
- if (!context) {
- // Device coordinates without context not yet supported.
- qWarning("QGraphicsEffectSource::boundingRect: Not yet implemented, lacking device context");
- return QRectF();
- }
-
- return context->painter->worldTransform().mapRect(m_widget->rect());
-}
-
-void QWidgetEffectSourcePrivate::draw(QPainter *painter)
-{
- if (!context || context->painter != painter) {
- m_widget->render(painter);
- return;
- }
-
- // The region saved in the context is neither clipped to the rect
- // nor the mask, so we have to clip it here before calling drawWidget.
- QRegion toBePainted = context->rgn;
- toBePainted &= m_widget->rect();
- QWidgetPrivate *wd = qt_widget_private(m_widget);
- if (wd->extra && wd->extra->hasMask)
- toBePainted &= wd->extra->mask;
-
- wd->drawWidget(context->pdev, toBePainted, context->offset, context->flags,
- context->sharedPainter, context->backingStore);
-}
-
-QPixmap QWidgetEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset,
- QGraphicsEffect::PixmapPadMode mode) const
-{
- const bool deviceCoordinates = (system == Qt::DeviceCoordinates);
- if (!context && deviceCoordinates) {
- // Device coordinates without context not yet supported.
- qWarning("QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context");
- return QPixmap();
- }
-
- QPoint pixmapOffset;
- QRectF sourceRect = m_widget->rect();
-
- if (deviceCoordinates) {
- const QTransform &painterTransform = context->painter->worldTransform();
- sourceRect = painterTransform.mapRect(sourceRect);
- pixmapOffset = painterTransform.map(pixmapOffset);
- }
-
- QRect effectRect;
-
- if (mode == QGraphicsEffect::PadToEffectiveBoundingRect)
- effectRect = m_widget->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect();
- else if (mode == QGraphicsEffect::PadToTransparentBorder)
- effectRect = sourceRect.adjusted(-1, -1, 1, 1).toAlignedRect();
- else
- effectRect = sourceRect.toAlignedRect();
-
- if (offset)
- *offset = effectRect.topLeft();
-
- pixmapOffset -= effectRect.topLeft();
-
- QPixmap pixmap(effectRect.size());
- pixmap.fill(Qt::transparent);
- m_widget->render(&pixmap, pixmapOffset, QRegion(), QWidget::DrawChildren);
- return pixmap;
-}
-#endif //QT_NO_GRAPHICSEFFECT
-
-#ifndef QT_NO_GRAPHICSVIEW
-/*!
- \internal
-
- Finds the nearest widget embedded in a graphics proxy widget along the chain formed by this
- widget and its ancestors. The search starts at \a origin (inclusive).
- If successful, the function returns the proxy that embeds the widget, or 0 if no embedded
- widget was found.
-*/
-QGraphicsProxyWidget * QWidgetPrivate::nearestGraphicsProxyWidget(const QWidget *origin)
-{
- if (origin) {
- QWExtra *extra = origin->d_func()->extra;
- if (extra && extra->proxyWidget)
- return extra->proxyWidget;
- return nearestGraphicsProxyWidget(origin->parentWidget());
- }
- return 0;
-}
-#endif
-
-/*!
- \property QWidget::locale
- \brief the widget's locale
- \since 4.3
-
- As long as no special locale has been set, this is either
- the parent's locale or (if this widget is a top level widget),
- the default locale.
-
- If the widget displays dates or numbers, these should be formatted
- using the widget's locale.
-
- \sa QLocale QLocale::setDefault()
-*/
-
-void QWidgetPrivate::setLocale_helper(const QLocale &loc, bool forceUpdate)
-{
- Q_Q(QWidget);
- if (locale == loc && !forceUpdate)
- return;
-
- locale = loc;
-
- if (!children.isEmpty()) {
- for (int i = 0; i < children.size(); ++i) {
- QWidget *w = qobject_cast<QWidget*>(children.at(i));
- if (!w)
- continue;
- if (w->testAttribute(Qt::WA_SetLocale))
- continue;
- if (w->isWindow() && !w->testAttribute(Qt::WA_WindowPropagation))
- continue;
- w->d_func()->setLocale_helper(loc, forceUpdate);
- }
- }
- QEvent e(QEvent::LocaleChange);
- QApplication::sendEvent(q, &e);
-}
-
-void QWidget::setLocale(const QLocale &locale)
-{
- Q_D(QWidget);
-
- setAttribute(Qt::WA_SetLocale);
- d->setLocale_helper(locale);
-}
-
-QLocale QWidget::locale() const
-{
- Q_D(const QWidget);
-
- return d->locale;
-}
-
-void QWidgetPrivate::resolveLocale()
-{
- Q_Q(const QWidget);
-
- if (!q->testAttribute(Qt::WA_SetLocale)) {
- setLocale_helper(q->isWindow()
- ? QLocale()
- : q->parentWidget()->locale());
- }
-}
-
-void QWidget::unsetLocale()
-{
- Q_D(QWidget);
- setAttribute(Qt::WA_SetLocale, false);
- d->resolveLocale();
-}
-
-static QString constructWindowTitleFromFilePath(const QString &filePath)
-{
- QFileInfo fi(filePath);
- QString windowTitle = fi.fileName() + QLatin1String("[*]");
-#ifndef Q_WS_MAC
- QString appName = QApplication::applicationName();
- if (!appName.isEmpty())
- windowTitle += QLatin1Char(' ') + QChar(0x2014) + QLatin1Char(' ') + appName;
-#endif
- return windowTitle;
-}
-
-/*!
- \property QWidget::windowTitle
- \brief the window title (caption)
-
- This property only makes sense for top-level widgets, such as
- windows and dialogs. If no caption has been set, the title is based of the
- \l windowFilePath. If neither of these is set, then the title is
- an empty string.
-
- If you use the \l windowModified mechanism, the window title must
- contain a "[*]" placeholder, which indicates where the '*' should
- appear. Normally, it should appear right after the file name
- (e.g., "document1.txt[*] - Text Editor"). If the \l
- windowModified property is false (the default), the placeholder
- is simply removed.
-
- \sa windowIcon, windowIconText, windowModified, windowFilePath
-*/
-QString QWidget::windowTitle() const
-{
- Q_D(const QWidget);
- if (d->extra && d->extra->topextra) {
- if (!d->extra->topextra->caption.isEmpty())
- return d->extra->topextra->caption;
- if (!d->extra->topextra->filePath.isEmpty())
- return constructWindowTitleFromFilePath(d->extra->topextra->filePath);
- }
- return QString();
-}
-
-/*!
- Returns a modified window title with the [*] place holder
- replaced according to the rules described in QWidget::setWindowTitle
-
- This function assumes that "[*]" can be quoted by another
- "[*]", so it will replace two place holders by one and
- a single last one by either "*" or nothing depending on
- the modified flag.
-
- \internal
-*/
-QString qt_setWindowTitle_helperHelper(const QString &title, const QWidget *widget)
-{
- Q_ASSERT(widget);
-
-#ifdef QT_EVAL
- extern QString qt_eval_adapt_window_title(const QString &title);
- QString cap = qt_eval_adapt_window_title(title);
-#else
- QString cap = title;
-#endif
-
- if (cap.isEmpty())
- return cap;
-
- QLatin1String placeHolder("[*]");
- int placeHolderLength = 3; // QLatin1String doesn't have length()
-
- int index = cap.indexOf(placeHolder);
-
- // here the magic begins
- while (index != -1) {
- index += placeHolderLength;
- int count = 1;
- while (cap.indexOf(placeHolder, index) == index) {
- ++count;
- index += placeHolderLength;
- }
-
- if (count%2) { // odd number of [*] -> replace last one
- int lastIndex = cap.lastIndexOf(placeHolder, index - 1);
- if (widget->isWindowModified()
- && widget->style()->styleHint(QStyle::SH_TitleBar_ModifyNotification, 0, widget))
- cap.replace(lastIndex, 3, QWidget::tr("*"));
- else
- cap.remove(lastIndex, 3);
- }
-
- index = cap.indexOf(placeHolder, index);
- }
-
- cap.replace(QLatin1String("[*][*]"), placeHolder);
-
- return cap;
-}
-
-void QWidgetPrivate::setWindowTitle_helper(const QString &title)
-{
- Q_Q(QWidget);
- if (q->testAttribute(Qt::WA_WState_Created))
- setWindowTitle_sys(qt_setWindowTitle_helperHelper(title, q));
-}
-
-void QWidgetPrivate::setWindowIconText_helper(const QString &title)
-{
- Q_Q(QWidget);
- if (q->testAttribute(Qt::WA_WState_Created))
- setWindowIconText_sys(qt_setWindowTitle_helperHelper(title, q));
-}
-
-void QWidget::setWindowIconText(const QString &iconText)
-{
- if (QWidget::windowIconText() == iconText)
- return;
-
- Q_D(QWidget);
- d->topData()->iconText = iconText;
- d->setWindowIconText_helper(iconText);
-
- QEvent e(QEvent::IconTextChange);
- QApplication::sendEvent(this, &e);
-}
-
-void QWidget::setWindowTitle(const QString &title)
-{
- if (QWidget::windowTitle() == title && !title.isEmpty() && !title.isNull())
- return;
-
- Q_D(QWidget);
- d->topData()->caption = title;
- d->setWindowTitle_helper(title);
-
- QEvent e(QEvent::WindowTitleChange);
- QApplication::sendEvent(this, &e);
-}
-
-
-/*!
- \property QWidget::windowIcon
- \brief the widget's icon
-
- This property only makes sense for windows. If no icon
- has been set, windowIcon() returns the application icon
- (QApplication::windowIcon()).
-
- \sa windowIconText, windowTitle
-*/
-QIcon QWidget::windowIcon() const
-{
- const QWidget *w = this;
- while (w) {
- const QWidgetPrivate *d = w->d_func();
- if (d->extra && d->extra->topextra && d->extra->topextra->icon)
- return *d->extra->topextra->icon;
- w = w->parentWidget();
- }
- return QApplication::windowIcon();
-}
-
-void QWidgetPrivate::setWindowIcon_helper()
-{
- QEvent e(QEvent::WindowIconChange);
- QApplication::sendEvent(q_func(), &e);
- for (int i = 0; i < children.size(); ++i) {
- QWidget *w = qobject_cast<QWidget *>(children.at(i));
- if (w && !w->isWindow())
- QApplication::sendEvent(w, &e);
- }
-}
-
-void QWidget::setWindowIcon(const QIcon &icon)
-{
- Q_D(QWidget);
-
- setAttribute(Qt::WA_SetWindowIcon, !icon.isNull());
- d->createTLExtra();
-
- if (!d->extra->topextra->icon)
- d->extra->topextra->icon = new QIcon();
- *d->extra->topextra->icon = icon;
-
- delete d->extra->topextra->iconPixmap;
- d->extra->topextra->iconPixmap = 0;
-
- d->setWindowIcon_sys();
- d->setWindowIcon_helper();
-}
-
-
-/*!
- \property QWidget::windowIconText
- \brief the widget's icon text
-
- This property only makes sense for windows. If no icon
- text has been set, this functions returns an empty string.
-
- \sa windowIcon, windowTitle
-*/
-
-QString QWidget::windowIconText() const
-{
- Q_D(const QWidget);
- return (d->extra && d->extra->topextra) ? d->extra->topextra->iconText : QString();
-}
-
-/*!
- \property QWidget::windowFilePath
- \since 4.4
- \brief the file path associated with a widget
-
- This property only makes sense for windows. It associates a file path with
- a window. If you set the file path, but have not set the window title, Qt
- sets the window title to contain a string created using the following
- components.
-
- On Mac OS X:
-
- \list
- \o The file name of the specified path, obtained using QFileInfo::fileName().
- \endlist
-
- On Windows and X11:
-
- \list
- \o The file name of the specified path, obtained using QFileInfo::fileName().
- \o An optional \c{*} character, if the \l windowModified property is set.
- \o The \c{0x2014} unicode character, padded either side by spaces.
- \o The application name, obtained from the application's
- \l{QCoreApplication::}{applicationName} property.
- \endlist
-
- If the window title is set at any point, then the window title takes precedence and
- will be shown instead of the file path string.
-
- Additionally, on Mac OS X, this has an added benefit that it sets the
- \l{http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGWindows/chapter_17_section_3.html}{proxy icon}
- for the window, assuming that the file path exists.
-
- If no file path is set, this property contains an empty string.
-
- By default, this property contains an empty string.
-
- \sa windowTitle, windowIcon
-*/
-
-QString QWidget::windowFilePath() const
-{
- Q_D(const QWidget);
- return (d->extra && d->extra->topextra) ? d->extra->topextra->filePath : QString();
-}
-
-void QWidget::setWindowFilePath(const QString &filePath)
-{
- if (filePath == windowFilePath())
- return;
-
- Q_D(QWidget);
-
- d->createTLExtra();
- d->extra->topextra->filePath = filePath;
- d->setWindowFilePath_helper(filePath);
-}
-
-void QWidgetPrivate::setWindowFilePath_helper(const QString &filePath)
-{
- if (extra->topextra && extra->topextra->caption.isEmpty()) {
-#ifdef Q_WS_MAC
- setWindowTitle_helper(QFileInfo(filePath).fileName());
-#else
- Q_Q(QWidget);
- Q_UNUSED(filePath);
- setWindowTitle_helper(q->windowTitle());
-#endif
- }
-#ifdef Q_WS_MAC
- setWindowFilePath_sys(filePath);
-#endif
-}
-
-/*!
- Returns the window's role, or an empty string.
-
- \sa windowIcon, windowTitle
-*/
-
-QString QWidget::windowRole() const
-{
- Q_D(const QWidget);
- return (d->extra && d->extra->topextra) ? d->extra->topextra->role : QString();
-}
-
-/*!
- Sets the window's role to \a role. This only makes sense for
- windows on X11.
-*/
-void QWidget::setWindowRole(const QString &role)
-{
-#if defined(Q_WS_X11)
- Q_D(QWidget);
- d->topData()->role = role;
- d->setWindowRole();
-#else
- Q_UNUSED(role)
-#endif
-}
-
-/*!
- \property QWidget::mouseTracking
- \brief whether mouse tracking is enabled for the widget
-
- If mouse tracking is disabled (the default), the widget only
- receives mouse move events when at least one mouse button is
- pressed while the mouse is being moved.
-
- If mouse tracking is enabled, the widget receives mouse move
- events even if no buttons are pressed.
-
- \sa mouseMoveEvent()
-*/
-
-
-/*!
- Sets the widget's focus proxy to widget \a w. If \a w is 0, the
- function resets this widget to have no focus proxy.
-
- Some widgets can "have focus", but create a child widget, such as
- QLineEdit, to actually handle the focus. In this case, the widget
- can set the line edit to be its focus proxy.
-
- setFocusProxy() sets the widget which will actually get focus when
- "this widget" gets it. If there is a focus proxy, setFocus() and
- hasFocus() operate on the focus proxy.
-
- \sa focusProxy()
-*/
-
-void QWidget::setFocusProxy(QWidget * w)
-{
- Q_D(QWidget);
- if (!w && !d->extra)
- return;
-
- for (QWidget* fp = w; fp; fp = fp->focusProxy()) {
- if (fp == this) {
- qWarning("QWidget: %s (%s) already in focus proxy chain", metaObject()->className(), objectName().toLocal8Bit().constData());
- return;
- }
- }
-
- d->createExtra();
- d->extra->focus_proxy = w;
-}
-
-
-/*!
- Returns the focus proxy, or 0 if there is no focus proxy.
-
- \sa setFocusProxy()
-*/
-
-QWidget * QWidget::focusProxy() const
-{
- Q_D(const QWidget);
- return d->extra ? (QWidget *)d->extra->focus_proxy : 0;
-}
-
-
-/*!
- \property QWidget::focus
- \brief whether this widget (or its focus proxy) has the keyboard
- input focus
-
- By default, this property is false.
-
- \note Obtaining the value of this property for a widget is effectively equivalent
- to checking whether QApplication::focusWidget() refers to the widget.
-
- \sa setFocus(), clearFocus(), setFocusPolicy(), QApplication::focusWidget()
-*/
-bool QWidget::hasFocus() const
-{
- const QWidget* w = this;
- while (w->d_func()->extra && w->d_func()->extra->focus_proxy)
- w = w->d_func()->extra->focus_proxy;
- if (QWidget *window = w->window()) {
-#ifndef QT_NO_GRAPHICSVIEW
- QWExtra *e = window->d_func()->extra;
- if (e && e->proxyWidget && e->proxyWidget->hasFocus() && window->focusWidget() == w)
- return true;
-#endif
- }
- return (QApplication::focusWidget() == w);
-}
-
-/*!
- Gives the keyboard input focus to this widget (or its focus
- proxy) if this widget or one of its parents is the \link
- isActiveWindow() active window\endlink. The \a reason argument will
- be passed into any focus event sent from this function, it is used
- to give an explanation of what caused the widget to get focus.
- If the window is not active, the widget will be given the focus when
- the window becomes active.
-
- First, a focus out event is sent to the focus widget (if any) to
- tell it that it is about to lose the focus. Then a focus in event
- is sent to this widget to tell it that it just received the focus.
- (Nothing happens if the focus in and focus out widgets are the
- same.)
-
- \note On embedded platforms, setFocus() will not cause an input panel
- to be opened by the input method. If you want this to happen, you
- have to send a QEvent::RequestSoftwareInputPanel event to the
- widget yourself.
-
- setFocus() gives focus to a widget regardless of its focus policy,
- but does not clear any keyboard grab (see grabKeyboard()).
-
- Be aware that if the widget is hidden, it will not accept focus
- until it is shown.
-
- \warning If you call setFocus() in a function which may itself be
- called from focusOutEvent() or focusInEvent(), you may get an
- infinite recursion.
-
- \sa hasFocus(), clearFocus(), focusInEvent(), focusOutEvent(),
- setFocusPolicy(), focusWidget(), QApplication::focusWidget(), grabKeyboard(),
- grabMouse(), {Keyboard Focus}, QEvent::RequestSoftwareInputPanel
-*/
-
-void QWidget::setFocus(Qt::FocusReason reason)
-{
- if (!isEnabled())
- return;
-
- QWidget *f = this;
- while (f->d_func()->extra && f->d_func()->extra->focus_proxy)
- f = f->d_func()->extra->focus_proxy;
-
- if (QApplication::focusWidget() == f
-#if defined(Q_WS_WIN)
- && GetFocus() == f->internalWinId()
-#endif
- )
- return;
-
-#ifndef QT_NO_GRAPHICSVIEW
- QWidget *previousProxyFocus = 0;
- if (QWExtra *topData = window()->d_func()->extra) {
- if (topData->proxyWidget && topData->proxyWidget->hasFocus()) {
- previousProxyFocus = topData->proxyWidget->widget()->focusWidget();
- if (previousProxyFocus && previousProxyFocus->focusProxy())
- previousProxyFocus = previousProxyFocus->focusProxy();
- if (previousProxyFocus == this && !topData->proxyWidget->d_func()->proxyIsGivingFocus)
- return;
- }
- }
-#endif
-
- QWidget *w = f;
- if (isHidden()) {
- while (w && w->isHidden()) {
- w->d_func()->focus_child = f;
- w = w->isWindow() ? 0 : w->parentWidget();
- }
- } else {
- while (w) {
- w->d_func()->focus_child = f;
- w = w->isWindow() ? 0 : w->parentWidget();
- }
- }
-
-#ifndef QT_NO_GRAPHICSVIEW
- // Update proxy state
- if (QWExtra *topData = window()->d_func()->extra) {
- if (topData->proxyWidget && !topData->proxyWidget->hasFocus()) {
- topData->proxyWidget->d_func()->focusFromWidgetToProxy = 1;
- topData->proxyWidget->setFocus(reason);
- topData->proxyWidget->d_func()->focusFromWidgetToProxy = 0;
- }
- }
-#endif
-
- if (f->isActiveWindow()) {
- QApplicationPrivate::setFocusWidget(f, reason);
-#ifndef QT_NO_ACCESSIBILITY
-# ifdef Q_OS_WIN
- // The negation of the condition in setFocus_sys
- if (!(testAttribute(Qt::WA_WState_Created) && window()->windowType() != Qt::Popup && internalWinId()))
- //setFocusWidget will already post a focus event for us (that the AT client receives) on Windows
-# endif
- QAccessible::updateAccessibility(f, 0, QAccessible::Focus);
-#endif
-#ifndef QT_NO_GRAPHICSVIEW
- if (QWExtra *topData = window()->d_func()->extra) {
- if (topData->proxyWidget) {
- if (previousProxyFocus && previousProxyFocus != f) {
- // Send event to self
- QFocusEvent event(QEvent::FocusOut, reason);
- QPointer<QWidget> that = previousProxyFocus;
- QApplication::sendEvent(previousProxyFocus, &event);
- if (that)
- QApplication::sendEvent(that->style(), &event);
- }
- if (!isHidden()) {
-#ifndef QT_NO_GRAPHICSVIEW
- // Update proxy state
- if (QWExtra *topData = window()->d_func()->extra)
- if (topData->proxyWidget && topData->proxyWidget->hasFocus())
- topData->proxyWidget->d_func()->updateProxyInputMethodAcceptanceFromWidget();
-#endif
- // Send event to self
- QFocusEvent event(QEvent::FocusIn, reason);
- QPointer<QWidget> that = f;
- QApplication::sendEvent(f, &event);
- if (that)
- QApplication::sendEvent(that->style(), &event);
- }
- }
- }
-#endif
- }
-}
-
-/*!
- \fn void QWidget::setFocus()
- \overload
-
- Gives the keyboard input focus to this widget (or its focus
- proxy) if this widget or one of its parents is the
- \l{isActiveWindow()}{active window}.
-*/
-
-/*!
- Takes keyboard input focus from the widget.
-
- If the widget has active focus, a \link focusOutEvent() focus out
- event\endlink is sent to this widget to tell it that it is about
- to lose the focus.
-
- This widget must enable focus setting in order to get the keyboard
- input focus, i.e. it must call setFocusPolicy().
-
- \sa hasFocus(), setFocus(), focusInEvent(), focusOutEvent(),
- setFocusPolicy(), QApplication::focusWidget()
-*/
-
-void QWidget::clearFocus()
-{
- QWidget *w = this;
- while (w) {
- if (w->d_func()->focus_child == this)
- w->d_func()->focus_child = 0;
- w = w->parentWidget();
- }
-#ifndef QT_NO_GRAPHICSVIEW
- QWExtra *topData = d_func()->extra;
- if (topData && topData->proxyWidget)
- topData->proxyWidget->clearFocus();
-#endif
-
- if (hasFocus()) {
- // Update proxy state
- QApplicationPrivate::setFocusWidget(0, Qt::OtherFocusReason);
-#if defined(Q_WS_WIN)
- if (!(windowType() == Qt::Popup) && GetFocus() == internalWinId())
- SetFocus(0);
- else
-#endif
- {
-#ifndef QT_NO_ACCESSIBILITY
- QAccessible::updateAccessibility(this, 0, QAccessible::Focus);
-#endif
- }
- }
-}
-
-
-/*!
- \fn bool QWidget::focusNextChild()
-
- Finds a new widget to give the keyboard focus to, as appropriate
- for \key Tab, and returns true if it can find a new widget, or
- false if it can't.
-
- \sa focusPreviousChild()
-*/
-
-/*!
- \fn bool QWidget::focusPreviousChild()
-
- Finds a new widget to give the keyboard focus to, as appropriate
- for \key Shift+Tab, and returns true if it can find a new widget,
- or false if it can't.
-
- \sa focusNextChild()
-*/
-
-/*!
- Finds a new widget to give the keyboard focus to, as appropriate
- for Tab and Shift+Tab, and returns true if it can find a new
- widget, or false if it can't.
-
- If \a next is true, this function searches forward, if \a next
- is false, it searches backward.
-
- Sometimes, you will want to reimplement this function. For
- example, a web browser might reimplement it to move its "current
- active link" forward or backward, and call
- focusNextPrevChild() only when it reaches the last or
- first link on the "page".
-
- Child widgets call focusNextPrevChild() on their parent widgets,
- but only the window that contains the child widgets decides where
- to redirect focus. By reimplementing this function for an object,
- you thus gain control of focus traversal for all child widgets.
-
- \sa focusNextChild(), focusPreviousChild()
-*/
-
-bool QWidget::focusNextPrevChild(bool next)
-{
- Q_D(QWidget);
- QWidget* p = parentWidget();
- bool isSubWindow = (windowType() == Qt::SubWindow);
- if (!isWindow() && !isSubWindow && p)
- return p->focusNextPrevChild(next);
-#ifndef QT_NO_GRAPHICSVIEW
- if (d->extra && d->extra->proxyWidget)
- return d->extra->proxyWidget->focusNextPrevChild(next);
-#endif
- QWidget *w = QApplicationPrivate::focusNextPrevChild_helper(this, next);
- if (!w) return false;
-
- w->setFocus(next ? Qt::TabFocusReason : Qt::BacktabFocusReason);
- return true;
-}
-
-/*!
- Returns the last child of this widget that setFocus had been
- called on. For top level widgets this is the widget that will get
- focus in case this window gets activated
-
- This is not the same as QApplication::focusWidget(), which returns
- the focus widget in the currently active window.
-*/
-
-QWidget *QWidget::focusWidget() const
-{
- return const_cast<QWidget *>(d_func()->focus_child);
-}
-
-/*!
- Returns the next widget in this widget's focus chain.
-
- \sa previousInFocusChain()
-*/
-QWidget *QWidget::nextInFocusChain() const
-{
- return const_cast<QWidget *>(d_func()->focus_next);
-}
-
-/*!
- \brief The previousInFocusChain function returns the previous
- widget in this widget's focus chain.
-
- \sa nextInFocusChain()
-
- \since 4.6
-*/
-QWidget *QWidget::previousInFocusChain() const
-{
- return const_cast<QWidget *>(d_func()->focus_prev);
-}
-
-/*!
- \property QWidget::isActiveWindow
- \brief whether this widget's window is the active window
-
- The active window is the window that contains the widget that has
- keyboard focus (The window may still have focus if it has no
- widgets or none of its widgets accepts keyboard focus).
-
- When popup windows are visible, this property is true for both the
- active window \e and for the popup.
-
- By default, this property is false.
-
- \sa activateWindow(), QApplication::activeWindow()
-*/
-bool QWidget::isActiveWindow() const
-{
- QWidget *tlw = window();
- if(tlw == QApplication::activeWindow() || (isVisible() && (tlw->windowType() == Qt::Popup)))
- return true;
-
-#ifndef QT_NO_GRAPHICSVIEW
- if (QWExtra *tlwExtra = tlw->d_func()->extra) {
- if (isVisible() && tlwExtra->proxyWidget)
- return tlwExtra->proxyWidget->isActiveWindow();
- }
-#endif
-
-#ifdef Q_WS_MAC
- extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp
- if(qt_mac_is_macdrawer(tlw) &&
- tlw->parentWidget() && tlw->parentWidget()->isActiveWindow())
- return true;
-
- extern bool qt_mac_insideKeyWindow(const QWidget *); //qwidget_mac.cpp
- if (QApplication::testAttribute(Qt::AA_MacPluginApplication) && qt_mac_insideKeyWindow(tlw))
- return true;
-#endif
- if(style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, this)) {
- if(tlw->windowType() == Qt::Tool &&
- !tlw->isModal() &&
- (!tlw->parentWidget() || tlw->parentWidget()->isActiveWindow()))
- return true;
- QWidget *w = QApplication::activeWindow();
- while(w && tlw->windowType() == Qt::Tool &&
- !w->isModal() && w->parentWidget()) {
- w = w->parentWidget()->window();
- if(w == tlw)
- return true;
- }
- }
-#if defined(Q_WS_WIN32)
- HWND active = GetActiveWindow();
- if (!tlw->testAttribute(Qt::WA_WState_Created))
- return false;
- return active == tlw->internalWinId() || ::IsChild(active, tlw->internalWinId());
-#else
- return false;
-#endif
-}
-
-/*!
- Puts the \a second widget after the \a first widget in the focus order.
-
- Note that since the tab order of the \a second widget is changed, you
- should order a chain like this:
-
- \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 9
-
- \e not like this:
-
- \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 10
-
- If \a first or \a second has a focus proxy, setTabOrder()
- correctly substitutes the proxy.
-
- \sa setFocusPolicy(), setFocusProxy(), {Keyboard Focus}
-*/
-void QWidget::setTabOrder(QWidget* first, QWidget *second)
-{
- if (!first || !second || first->focusPolicy() == Qt::NoFocus || second->focusPolicy() == Qt::NoFocus)
- return;
-
- if (first->window() != second->window()) {
- qWarning("QWidget::setTabOrder: 'first' and 'second' must be in the same window");
- return;
- }
-
- QWidget *fp = first->focusProxy();
- if (fp) {
- // If first is redirected, set first to the last child of first
- // that can take keyboard focus so that second is inserted after
- // that last child, and the focus order within first is (more
- // likely to be) preserved.
- QList<QWidget *> l = first->findChildren<QWidget *>();
- for (int i = l.size()-1; i >= 0; --i) {
- QWidget * next = l.at(i);
- if (next->window() == fp->window()) {
- fp = next;
- if (fp->focusPolicy() != Qt::NoFocus)
- break;
- }
- }
- first = fp;
- }
-
- if (fp == second)
- return;
-
- if (QWidget *sp = second->focusProxy())
- second = sp;
-
-// QWidget *fp = first->d_func()->focus_prev;
- QWidget *fn = first->d_func()->focus_next;
-
- if (fn == second || first == second)
- return;
-
- QWidget *sp = second->d_func()->focus_prev;
- QWidget *sn = second->d_func()->focus_next;
-
- fn->d_func()->focus_prev = second;
- first->d_func()->focus_next = second;
-
- second->d_func()->focus_next = fn;
- second->d_func()->focus_prev = first;
-
- sp->d_func()->focus_next = sn;
- sn->d_func()->focus_prev = sp;
-
-
- Q_ASSERT(first->d_func()->focus_next->d_func()->focus_prev == first);
- Q_ASSERT(first->d_func()->focus_prev->d_func()->focus_next == first);
-
- Q_ASSERT(second->d_func()->focus_next->d_func()->focus_prev == second);
- Q_ASSERT(second->d_func()->focus_prev->d_func()->focus_next == second);
-}
-
-/*!\internal
-
- Moves the relevant subwidgets of this widget from the \a oldtlw's
- tab chain to that of the new parent, if there's anything to move and
- we're really moving
-
- This function is called from QWidget::reparent() *after* the widget
- has been reparented.
-
- \sa reparent()
-*/
-
-void QWidgetPrivate::reparentFocusWidgets(QWidget * oldtlw)
-{
- Q_Q(QWidget);
- if (oldtlw == q->window())
- return; // nothing to do
-
- if(focus_child)
- focus_child->clearFocus();
-
- // separate the focus chain into new (children of myself) and old (the rest)
- QWidget *firstOld = 0;
- //QWidget *firstNew = q; //invariant
- QWidget *o = 0; // last in the old list
- QWidget *n = q; // last in the new list
-
- bool prevWasNew = true;
- QWidget *w = focus_next;
-
- //Note: for efficiency, we do not maintain the list invariant inside the loop
- //we append items to the relevant list, and we optimize by not changing pointers
- //when subsequent items are going into the same list.
- while (w != q) {
- bool currentIsNew = q->isAncestorOf(w);
- if (currentIsNew) {
- if (!prevWasNew) {
- //prev was old -- append to new list
- n->d_func()->focus_next = w;
- w->d_func()->focus_prev = n;
- }
- n = w;
- } else {
- if (prevWasNew) {
- //prev was new -- append to old list, if there is one
- if (o) {
- o->d_func()->focus_next = w;
- w->d_func()->focus_prev = o;
- } else {
- // "create" the old list
- firstOld = w;
- }
- }
- o = w;
- }
- w = w->d_func()->focus_next;
- prevWasNew = currentIsNew;
- }
-
- //repair the old list:
- if (firstOld) {
- o->d_func()->focus_next = firstOld;
- firstOld->d_func()->focus_prev = o;
- }
-
- if (!q->isWindow()) {
- QWidget *topLevel = q->window();
- //insert new chain into toplevel's chain
-
- QWidget *prev = topLevel->d_func()->focus_prev;
-
- topLevel->d_func()->focus_prev = n;
- prev->d_func()->focus_next = q;
-
- focus_prev = prev;
- n->d_func()->focus_next = topLevel;
- } else {
- //repair the new list
- n->d_func()->focus_next = q;
- focus_prev = n;
- }
-
-}
-
-/*!\internal
-
- Measures the shortest distance from a point to a rect.
-
- This function is called from QDesktopwidget::screen(QPoint) to find the
- closest screen for a point.
- In directional KeypadNavigation, it is called to find the closest
- widget to the current focus widget center.
-*/
-int QWidgetPrivate::pointToRect(const QPoint &p, const QRect &r)
-{
- int dx = 0;
- int dy = 0;
- if (p.x() < r.left())
- dx = r.left() - p.x();
- else if (p.x() > r.right())
- dx = p.x() - r.right();
- if (p.y() < r.top())
- dy = r.top() - p.y();
- else if (p.y() > r.bottom())
- dy = p.y() - r.bottom();
- return dx + dy;
-}
-
-/*!
- \property QWidget::frameSize
- \brief the size of the widget including any window frame
-
- By default, this property contains a value that depends on the user's
- platform and screen geometry.
-*/
-QSize QWidget::frameSize() const
-{
- Q_D(const QWidget);
- if (isWindow() && !(windowType() == Qt::Popup)) {
- QRect fs = d->frameStrut();
- return QSize(data->crect.width() + fs.left() + fs.right(),
- data->crect.height() + fs.top() + fs.bottom());
- }
- return data->crect.size();
-}
-
-/*! \fn void QWidget::move(int x, int y)
-
- \overload
-
- This corresponds to move(QPoint(\a x, \a y)).
-*/
-
-void QWidget::move(const QPoint &p)
-{
- Q_D(QWidget);
- setAttribute(Qt::WA_Moved);
- if (isWindow())
- d->topData()->posFromMove = true;
- if (testAttribute(Qt::WA_WState_Created)) {
- d->setGeometry_sys(p.x() + geometry().x() - QWidget::x(),
- p.y() + geometry().y() - QWidget::y(),
- width(), height(), true);
- d->setDirtyOpaqueRegion();
- } else {
- data->crect.moveTopLeft(p); // no frame yet
- setAttribute(Qt::WA_PendingMoveEvent);
- }
-}
-
-/*! \fn void QWidget::resize(int w, int h)
- \overload
-
- This corresponds to resize(QSize(\a w, \a h)).
-*/
-
-void QWidget::resize(const QSize &s)
-{
- Q_D(QWidget);
- setAttribute(Qt::WA_Resized);
- if (testAttribute(Qt::WA_WState_Created)) {
- d->setGeometry_sys(geometry().x(), geometry().y(), s.width(), s.height(), false);
- d->setDirtyOpaqueRegion();
- } else {
- data->crect.setSize(s.boundedTo(maximumSize()).expandedTo(minimumSize()));
- setAttribute(Qt::WA_PendingResizeEvent);
- }
-}
-
-void QWidget::setGeometry(const QRect &r)
-{
- Q_D(QWidget);
- setAttribute(Qt::WA_Resized);
- setAttribute(Qt::WA_Moved);
- if (isWindow())
- d->topData()->posFromMove = false;
- if (testAttribute(Qt::WA_WState_Created)) {
- d->setGeometry_sys(r.x(), r.y(), r.width(), r.height(), true);
- d->setDirtyOpaqueRegion();
- } else {
- data->crect.setTopLeft(r.topLeft());
- data->crect.setSize(r.size().boundedTo(maximumSize()).expandedTo(minimumSize()));
- setAttribute(Qt::WA_PendingMoveEvent);
- setAttribute(Qt::WA_PendingResizeEvent);
- }
-}
-
-/*!
- \since 4.2
- Saves the current geometry and state for top-level widgets.
-
- To save the geometry when the window closes, you can
- implement a close event like this:
-
- \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 11
-
- See the \l{Window Geometry} documentation for an overview of geometry
- issues with windows.
-
- Use QMainWindow::saveState() to save the geometry and the state of
- toolbars and dock widgets.
-
- \sa restoreGeometry(), QMainWindow::saveState(), QMainWindow::restoreState()
-*/
-QByteArray QWidget::saveGeometry() const
-{
-#ifdef QT_MAC_USE_COCOA
- // We check if the window was maximized during this invocation. If so, we need to record the
- // starting position as 0,0.
- Q_D(const QWidget);
- QRect newFramePosition = frameGeometry();
- QRect newNormalPosition = normalGeometry();
- if(d->topData()->wasMaximized && !(windowState() & Qt::WindowMaximized)) {
- // Change the starting position
- newFramePosition.moveTo(0, 0);
- newNormalPosition.moveTo(0, 0);
- }
-#endif // QT_MAC_USE_COCOA
- QByteArray array;
- QDataStream stream(&array, QIODevice::WriteOnly);
- stream.setVersion(QDataStream::Qt_4_0);
- const quint32 magicNumber = 0x1D9D0CB;
- quint16 majorVersion = 1;
- quint16 minorVersion = 0;
- stream << magicNumber
- << majorVersion
- << minorVersion
-#ifdef QT_MAC_USE_COCOA
- << newFramePosition
- << newNormalPosition
-#else
- << frameGeometry()
- << normalGeometry()
-#endif // QT_MAC_USE_COCOA
- << qint32(QApplication::desktop()->screenNumber(this))
- << quint8(windowState() & Qt::WindowMaximized)
- << quint8(windowState() & Qt::WindowFullScreen);
- return array;
-}
-
-/*!
- \since 4.2
-
- Restores the geometry and state top-level widgets stored in the
- byte array \a geometry. Returns true on success; otherwise
- returns false.
-
- If the restored geometry is off-screen, it will be modified to be
- inside the available screen geometry.
-
- To restore geometry saved using QSettings, you can use code like
- this:
-
- \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 12
-
- See the \l{Window Geometry} documentation for an overview of geometry
- issues with windows.
-
- Use QMainWindow::restoreState() to restore the geometry and the
- state of toolbars and dock widgets.
-
- \sa saveGeometry(), QSettings, QMainWindow::saveState(), QMainWindow::restoreState()
-*/
-bool QWidget::restoreGeometry(const QByteArray &geometry)
-{
- if (geometry.size() < 4)
- return false;
- QDataStream stream(geometry);
- stream.setVersion(QDataStream::Qt_4_0);
-
- const quint32 magicNumber = 0x1D9D0CB;
- quint32 storedMagicNumber;
- stream >> storedMagicNumber;
- if (storedMagicNumber != magicNumber)
- return false;
-
- const quint16 currentMajorVersion = 1;
- quint16 majorVersion = 0;
- quint16 minorVersion = 0;
-
- stream >> majorVersion >> minorVersion;
-
- if (majorVersion != currentMajorVersion)
- return false;
- // (Allow all minor versions.)
-
- QRect restoredFrameGeometry;
- QRect restoredNormalGeometry;
- qint32 restoredScreenNumber;
- quint8 maximized;
- quint8 fullScreen;
-
- stream >> restoredFrameGeometry
- >> restoredNormalGeometry
- >> restoredScreenNumber
- >> maximized
- >> fullScreen;
-
- const int frameHeight = 20;
- if (!restoredFrameGeometry.isValid())
- restoredFrameGeometry = QRect(QPoint(0,0), sizeHint());
-
- if (!restoredNormalGeometry.isValid())
- restoredNormalGeometry = QRect(QPoint(0, frameHeight), sizeHint());
- if (!restoredNormalGeometry.isValid()) {
- // use the widget's adjustedSize if the sizeHint() doesn't help
- restoredNormalGeometry.setSize(restoredNormalGeometry
- .size()
- .expandedTo(d_func()->adjustedSize()));
- }
-
- const QDesktopWidget * const desktop = QApplication::desktop();
- if (restoredScreenNumber >= desktop->numScreens())
- restoredScreenNumber = desktop->primaryScreen();
-
- const QRect availableGeometry = desktop->availableGeometry(restoredScreenNumber);
-
- // Modify the restored geometry if we are about to restore to coordinates
- // that would make the window "lost". This happens if:
- // - The restored geometry is completely oustside the available geometry
- // - The title bar is outside the available geometry.
- // - (Mac only) The window is higher than the available geometry. It must
- // be possible to bring the size grip on screen by moving the window.
-#ifdef Q_WS_MAC
- restoredFrameGeometry.setHeight(qMin(restoredFrameGeometry.height(), availableGeometry.height()));
- restoredNormalGeometry.setHeight(qMin(restoredNormalGeometry.height(), availableGeometry.height() - frameHeight));
-#endif
-
- if (!restoredFrameGeometry.intersects(availableGeometry)) {
- restoredFrameGeometry.moveBottom(qMin(restoredFrameGeometry.bottom(), availableGeometry.bottom()));
- restoredFrameGeometry.moveLeft(qMax(restoredFrameGeometry.left(), availableGeometry.left()));
- restoredFrameGeometry.moveRight(qMin(restoredFrameGeometry.right(), availableGeometry.right()));
- }
- restoredFrameGeometry.moveTop(qMax(restoredFrameGeometry.top(), availableGeometry.top()));
-
- if (!restoredNormalGeometry.intersects(availableGeometry)) {
- restoredNormalGeometry.moveBottom(qMin(restoredNormalGeometry.bottom(), availableGeometry.bottom()));
- restoredNormalGeometry.moveLeft(qMax(restoredNormalGeometry.left(), availableGeometry.left()));
- restoredNormalGeometry.moveRight(qMin(restoredNormalGeometry.right(), availableGeometry.right()));
- }
- restoredNormalGeometry.moveTop(qMax(restoredNormalGeometry.top(), availableGeometry.top() + frameHeight));
-
- if (maximized || fullScreen) {
- // set geomerty before setting the window state to make
- // sure the window is maximized to the right screen.
- // Skip on windows: the window is restored into a broken
- // half-maximized state.
-#ifndef Q_WS_WIN
- setGeometry(restoredNormalGeometry);
-#endif
- Qt::WindowStates ws = windowState();
- if (maximized)
- ws |= Qt::WindowMaximized;
- if (fullScreen)
- ws |= Qt::WindowFullScreen;
- setWindowState(ws);
- d_func()->topData()->normalGeometry = restoredNormalGeometry;
- } else {
- QPoint offset;
-#ifdef Q_WS_X11
- if (isFullScreen())
- offset = d_func()->topData()->fullScreenOffset;
-#endif
- setWindowState(windowState() & ~(Qt::WindowMaximized | Qt::WindowFullScreen));
- move(restoredFrameGeometry.topLeft() + offset);
- resize(restoredNormalGeometry.size());
- }
- return true;
-}
-
-/*!\fn void QWidget::setGeometry(int x, int y, int w, int h)
- \overload
-
- This corresponds to setGeometry(QRect(\a x, \a y, \a w, \a h)).
-*/
-
-/*!
- Sets the margins around the contents of the widget to have the sizes
- \a left, \a top, \a right, and \a bottom. The margins are used by
- the layout system, and may be used by subclasses to specify the area
- to draw in (e.g. excluding the frame).
-
- Changing the margins will trigger a resizeEvent().
-
- \sa contentsRect(), getContentsMargins()
-*/
-void QWidget::setContentsMargins(int left, int top, int right, int bottom)
-{
- Q_D(QWidget);
- if (left == d->leftmargin && top == d->topmargin
- && right == d->rightmargin && bottom == d->bottommargin)
- return;
- d->leftmargin = left;
- d->topmargin = top;
- d->rightmargin = right;
- d->bottommargin = bottom;
-
- if (QLayout *l=d->layout)
- l->update(); //force activate; will do updateGeometry
- else
- updateGeometry();
-
- // ### Qt 5: compat, remove
- if (isVisible()) {
- update();
- QResizeEvent e(data->crect.size(), data->crect.size());
- QApplication::sendEvent(this, &e);
- } else {
- setAttribute(Qt::WA_PendingResizeEvent, true);
- }
-
- QEvent e(QEvent::ContentsRectChange);
- QApplication::sendEvent(this, &e);
-}
-
-/*!
- \overload
- \since 4.6
-
- \brief The setContentsMargins function sets the margins around the
- widget's contents.
-
- Sets the margins around the contents of the widget to have the
- sizes determined by \a margins. The margins are
- used by the layout system, and may be used by subclasses to
- specify the area to draw in (e.g. excluding the frame).
-
- Changing the margins will trigger a resizeEvent().
-
- \sa contentsRect(), getContentsMargins()
-*/
-void QWidget::setContentsMargins(const QMargins &margins)
-{
- setContentsMargins(margins.left(), margins.top(),
- margins.right(), margins.bottom());
-}
-
-/*!
- Returns the widget's contents margins for \a left, \a top, \a
- right, and \a bottom.
-
- \sa setContentsMargins(), contentsRect()
- */
-void QWidget::getContentsMargins(int *left, int *top, int *right, int *bottom) const
-{
- Q_D(const QWidget);
- if (left)
- *left = d->leftmargin;
- if (top)
- *top = d->topmargin;
- if (right)
- *right = d->rightmargin;
- if (bottom)
- *bottom = d->bottommargin;
-}
-
-/*!
- \since 4.6
-
- \brief The contentsMargins function returns the widget's contents margins.
-
- \sa getContentsMargins(), setContentsMargins(), contentsRect()
- */
-QMargins QWidget::contentsMargins() const
-{
- Q_D(const QWidget);
- return QMargins(d->leftmargin, d->topmargin, d->rightmargin, d->bottommargin);
-}
-
-
-/*!
- Returns the area inside the widget's margins.
-
- \sa setContentsMargins(), getContentsMargins()
-*/
-QRect QWidget::contentsRect() const
-{
- Q_D(const QWidget);
- return QRect(QPoint(d->leftmargin, d->topmargin),
- QPoint(data->crect.width() - 1 - d->rightmargin,
- data->crect.height() - 1 - d->bottommargin));
-
-}
-
-
-
-/*!
- \fn void QWidget::customContextMenuRequested(const QPoint &pos)
-
- This signal is emitted when the widget's \l contextMenuPolicy is
- Qt::CustomContextMenu, and the user has requested a context menu on
- the widget. The position \a pos is the position of the context menu
- event that the widget receives. Normally this is in widget
- coordinates. The exception to this rule is QAbstractScrollArea and
- its subclasses that map the context menu event to coordinates of the
- \link QAbstractScrollArea::viewport() viewport() \endlink .
-
-
- \sa mapToGlobal() QMenu contextMenuPolicy
-*/
-
-
-/*!
- \property QWidget::contextMenuPolicy
- \brief how the widget shows a context menu
-
- The default value of this property is Qt::DefaultContextMenu,
- which means the contextMenuEvent() handler is called. Other values
- are Qt::NoContextMenu, Qt::PreventContextMenu,
- Qt::ActionsContextMenu, and Qt::CustomContextMenu. With
- Qt::CustomContextMenu, the signal customContextMenuRequested() is
- emitted.
-
- \sa contextMenuEvent(), customContextMenuRequested(), actions()
-*/
-
-Qt::ContextMenuPolicy QWidget::contextMenuPolicy() const
-{
- return (Qt::ContextMenuPolicy)data->context_menu_policy;
-}
-
-void QWidget::setContextMenuPolicy(Qt::ContextMenuPolicy policy)
-{
- data->context_menu_policy = (uint) policy;
-}
-
-/*!
- \property QWidget::focusPolicy
- \brief the way the widget accepts keyboard focus
-
- The policy is Qt::TabFocus if the widget accepts keyboard
- focus by tabbing, Qt::ClickFocus if the widget accepts
- focus by clicking, Qt::StrongFocus if it accepts both, and
- Qt::NoFocus (the default) if it does not accept focus at
- all.
-
- You must enable keyboard focus for a widget if it processes
- keyboard events. This is normally done from the widget's
- constructor. For instance, the QLineEdit constructor calls
- setFocusPolicy(Qt::StrongFocus).
-
- If the widget has a focus proxy, then the focus policy will
- be propagated to it.
-
- \sa focusInEvent(), focusOutEvent(), keyPressEvent(), keyReleaseEvent(), enabled
-*/
-
-
-Qt::FocusPolicy QWidget::focusPolicy() const
-{
- return (Qt::FocusPolicy)data->focus_policy;
-}
-
-void QWidget::setFocusPolicy(Qt::FocusPolicy policy)
-{
- data->focus_policy = (uint) policy;
- Q_D(QWidget);
- if (d->extra && d->extra->focus_proxy)
- d->extra->focus_proxy->setFocusPolicy(policy);
-}
-
-/*!
- \property QWidget::updatesEnabled
- \brief whether updates are enabled
-
- An updates enabled widget receives paint events and has a system
- background; a disabled widget does not. This also implies that
- calling update() and repaint() has no effect if updates are
- disabled.
-
- By default, this property is true.
-
- setUpdatesEnabled() is normally used to disable updates for a
- short period of time, for instance to avoid screen flicker during
- large changes. In Qt, widgets normally do not generate screen
- flicker, but on X11 the server might erase regions on the screen
- when widgets get hidden before they can be replaced by other
- widgets. Disabling updates solves this.
-
- Example:
- \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 13
-
- Disabling a widget implicitly disables all its children. Enabling a widget
- enables all child widgets \e except top-level widgets or those that
- have been explicitly disabled. Re-enabling updates implicitly calls
- update() on the widget.
-
- \sa paintEvent()
-*/
-void QWidget::setUpdatesEnabled(bool enable)
-{
- Q_D(QWidget);
- setAttribute(Qt::WA_ForceUpdatesDisabled, !enable);
- d->setUpdatesEnabled_helper(enable);
-}
-
-/*! \fn void QWidget::show()
-
- Shows the widget and its child widgets. This function is
- equivalent to setVisible(true).
-
- \sa raise(), showEvent(), hide(), setVisible(), showMinimized(), showMaximized(),
- showNormal(), isVisible()
-*/
-
-
-/*! \internal
-
- Makes the widget visible in the isVisible() meaning of the word.
- It is only called for toplevels or widgets with visible parents.
- */
-void QWidgetPrivate::show_recursive()
-{
- Q_Q(QWidget);
- // polish if necessary
-
- if (!q->testAttribute(Qt::WA_WState_Created))
- createRecursively();
- q->ensurePolished();
-
-#ifdef QT3_SUPPORT
- if(sendChildEvents)
- QApplication::sendPostedEvents(q, QEvent::ChildInserted);
-#endif
- if (!q->isWindow() && q->parentWidget()->d_func()->layout && !q->parentWidget()->data->in_show)
- q->parentWidget()->d_func()->layout->activate();
- // activate our layout before we and our children become visible
- if (layout)
- layout->activate();
-
- show_helper();
-}
-
-void QWidgetPrivate::sendPendingMoveAndResizeEvents(bool recursive, bool disableUpdates)
-{
- Q_Q(QWidget);
-
- disableUpdates = disableUpdates && q->updatesEnabled();
- if (disableUpdates)
- q->setAttribute(Qt::WA_UpdatesDisabled);
-
- if (q->testAttribute(Qt::WA_PendingMoveEvent)) {
- QMoveEvent e(data.crect.topLeft(), data.crect.topLeft());
- QApplication::sendEvent(q, &e);
- q->setAttribute(Qt::WA_PendingMoveEvent, false);
- }
-
- if (q->testAttribute(Qt::WA_PendingResizeEvent)) {
- QResizeEvent e(data.crect.size(), QSize());
- QApplication::sendEvent(q, &e);
- q->setAttribute(Qt::WA_PendingResizeEvent, false);
- }
-
- if (disableUpdates)
- q->setAttribute(Qt::WA_UpdatesDisabled, false);
-
- if (!recursive)
- return;
-
- for (int i = 0; i < children.size(); ++i) {
- if (QWidget *child = qobject_cast<QWidget *>(children.at(i)))
- child->d_func()->sendPendingMoveAndResizeEvents(recursive, disableUpdates);
- }
-}
-
-void QWidgetPrivate::activateChildLayoutsRecursively()
-{
- sendPendingMoveAndResizeEvents(false, true);
-
- for (int i = 0; i < children.size(); ++i) {
- QWidget *child = qobject_cast<QWidget *>(children.at(i));
- if (!child || child->isHidden() || child->isWindow())
- continue;
-
- child->ensurePolished();
-
- // Activate child's layout
- QWidgetPrivate *childPrivate = child->d_func();
- if (childPrivate->layout)
- childPrivate->layout->activate();
-
- // Pretend we're visible.
- const bool wasVisible = child->isVisible();
- if (!wasVisible)
- child->setAttribute(Qt::WA_WState_Visible);
-
- // Do the same for all my children.
- childPrivate->activateChildLayoutsRecursively();
-
- // We're not cheating anymore.
- if (!wasVisible)
- child->setAttribute(Qt::WA_WState_Visible, false);
- }
-}
-
-void QWidgetPrivate::show_helper()
-{
- Q_Q(QWidget);
- data.in_show = true; // qws optimization
- // make sure we receive pending move and resize events
- sendPendingMoveAndResizeEvents();
-
- // become visible before showing all children
- q->setAttribute(Qt::WA_WState_Visible);
-
- // finally show all children recursively
- showChildren(false);
-
-#ifdef QT3_SUPPORT
- if (q->parentWidget() && sendChildEvents)
- QApplication::sendPostedEvents(q->parentWidget(),
- QEvent::ChildInserted);
-#endif
-
-
- // popup handling: new popups and tools need to be raised, and
- // existing popups must be closed. Also propagate the current
- // windows's KeyboardFocusChange status.
- if (q->isWindow()) {
- if ((q->windowType() == Qt::Tool) || (q->windowType() == Qt::Popup) || q->windowType() == Qt::ToolTip) {
- q->raise();
- if (q->parentWidget() && q->parentWidget()->window()->testAttribute(Qt::WA_KeyboardFocusChange))
- q->setAttribute(Qt::WA_KeyboardFocusChange);
- } else {
- while (QApplication::activePopupWidget()) {
- if (!QApplication::activePopupWidget()->close())
- break;
- }
- }
- }
-
- // Automatic embedding of child windows of widgets already embedded into
- // QGraphicsProxyWidget when they are shown the first time.
- bool isEmbedded = false;
-#ifndef QT_NO_GRAPHICSVIEW
- if (q->isWindow()) {
- isEmbedded = q->graphicsProxyWidget() ? true : false;
- if (!isEmbedded && !bypassGraphicsProxyWidget(q)) {
- QGraphicsProxyWidget *ancestorProxy = nearestGraphicsProxyWidget(q->parentWidget());
- if (ancestorProxy) {
- isEmbedded = true;
- ancestorProxy->d_func()->embedSubWindow(q);
- }
- }
- }
-#else
- Q_UNUSED(isEmbedded);
-#endif
-
- // On Windows, show the popup now so that our own focus handling
- // stores the correct old focus widget even if it's stolen in the
- // showevent
-#if defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN)
- if (!isEmbedded && q->windowType() == Qt::Popup)
- qApp->d_func()->openPopup(q);
-#endif
-
- // send the show event before showing the window
- QShowEvent showEvent;
- QApplication::sendEvent(q, &showEvent);
-
- if (!isEmbedded && q->isModal() && q->isWindow())
- // QApplicationPrivate::enterModal *before* show, otherwise the initial
- // stacking might be wrong
- QApplicationPrivate::enterModal(q);
-
-
- show_sys();
-
-#if !defined(Q_WS_WIN) && !defined(Q_WS_MAC) && !defined(Q_OS_SYMBIAN)
- if (!isEmbedded && q->windowType() == Qt::Popup)
- qApp->d_func()->openPopup(q);
-#endif
-
-#ifndef QT_NO_ACCESSIBILITY
- if (q->windowType() != Qt::ToolTip) // Tooltips are read aloud twice in MS narrator.
- QAccessible::updateAccessibility(q, 0, QAccessible::ObjectShow);
-#endif
-
- if (QApplicationPrivate::hidden_focus_widget == q) {
- QApplicationPrivate::hidden_focus_widget = 0;
- q->setFocus(Qt::OtherFocusReason);
- }
-
- // Process events when showing a Qt::SplashScreen widget before the event loop
- // is spinnning; otherwise it might not show up on particular platforms.
- // This makes QSplashScreen behave the same on all platforms.
- if (!qApp->d_func()->in_exec && q->windowType() == Qt::SplashScreen)
- QApplication::processEvents();
-
- data.in_show = false; // reset qws optimization
-}
-
-/*! \fn void QWidget::hide()
-
- Hides the widget. This function is equivalent to
- setVisible(false).
-
-
- \note If you are working with QDialog or its subclasses and you invoke
- the show() function after this function, the dialog will be displayed in
- its original position.
-
- \sa hideEvent(), isHidden(), show(), setVisible(), isVisible(), close()
-*/
-
-/*!\internal
- */
-void QWidgetPrivate::hide_helper()
-{
- Q_Q(QWidget);
-
- bool isEmbedded = false;
-#if !defined QT_NO_GRAPHICSVIEW
- isEmbedded = q->isWindow() && !bypassGraphicsProxyWidget(q) && nearestGraphicsProxyWidget(q->parentWidget()) != 0;
-#else
- Q_UNUSED(isEmbedded);
-#endif
-
- if (!isEmbedded && (q->windowType() == Qt::Popup))
- qApp->d_func()->closePopup(q);
-
- // Move test modal here. Otherwise, a modal dialog could get
- // destroyed and we lose all access to its parent because we haven't
- // left modality. (Eg. modal Progress Dialog)
- if (!isEmbedded && q->isModal() && q->isWindow())
- QApplicationPrivate::leaveModal(q);
-
-#if defined(Q_WS_WIN)
- if (q->isWindow() && !(q->windowType() == Qt::Popup) && q->parentWidget()
- && !q->parentWidget()->isHidden() && q->isActiveWindow())
- q->parentWidget()->activateWindow(); // Activate parent
-#endif
-
- q->setAttribute(Qt::WA_Mapped, false);
- hide_sys();
-
- bool wasVisible = q->testAttribute(Qt::WA_WState_Visible);
-
- if (wasVisible) {
- q->setAttribute(Qt::WA_WState_Visible, false);
-
- }
-
- QHideEvent hideEvent;
- QApplication::sendEvent(q, &hideEvent);
- hideChildren(false);
-
- // next bit tries to move the focus if the focus widget is now
- // hidden.
- if (wasVisible) {
-#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_QPA)
- qApp->d_func()->sendSyntheticEnterLeave(q);
-#endif
-
- QWidget *fw = QApplication::focusWidget();
- while (fw && !fw->isWindow()) {
- if (fw == q) {
- q->focusNextPrevChild(true);
- break;
- }
- fw = fw->parentWidget();
- }
- }
-
- if (QWidgetBackingStore *bs = maybeBackingStore())
- bs->removeDirtyWidget(q);
-
-#ifndef QT_NO_ACCESSIBILITY
- if (wasVisible)
- QAccessible::updateAccessibility(q, 0, QAccessible::ObjectHide);
-#endif
-}
-
-/*!
- \fn bool QWidget::isHidden() const
-
- Returns true if the widget is hidden, otherwise returns false.
-
- A hidden widget will only become visible when show() is called on
- it. It will not be automatically shown when the parent is shown.
-
- To check visibility, use !isVisible() instead (notice the exclamation mark).
-
- isHidden() implies !isVisible(), but a widget can be not visible
- and not hidden at the same time. This is the case for widgets that are children of
- widgets that are not visible.
-
-
- Widgets are hidden if:
- \list
- \o they were created as independent windows,
- \o they were created as children of visible widgets,
- \o hide() or setVisible(false) was called.
- \endlist
-*/
-
-
-void QWidget::setVisible(bool visible)
-{
- if (visible) { // show
- if (testAttribute(Qt::WA_WState_ExplicitShowHide) && !testAttribute(Qt::WA_WState_Hidden))
- return;
-
- Q_D(QWidget);
-
- // Designer uses a trick to make grabWidget work without showing
- if (!isWindow() && parentWidget() && parentWidget()->isVisible()
- && !parentWidget()->testAttribute(Qt::WA_WState_Created))
- parentWidget()->window()->d_func()->createRecursively();
-
- //we have to at least create toplevels before applyX11SpecificCommandLineArguments
- //but not children of non-visible parents
- QWidget *pw = parentWidget();
- if (!testAttribute(Qt::WA_WState_Created)
- && (isWindow() || pw->testAttribute(Qt::WA_WState_Created))) {
- create();
- }
-
-#if defined(Q_WS_X11)
- if (windowType() == Qt::Window)
- QApplicationPrivate::applyX11SpecificCommandLineArguments(this);
-#elif defined(Q_WS_QWS)
- if (windowType() == Qt::Window)
- QApplicationPrivate::applyQWSSpecificCommandLineArguments(this);
-#endif
-
- bool wasResized = testAttribute(Qt::WA_Resized);
- Qt::WindowStates initialWindowState = windowState();
-
- // polish if necessary
- ensurePolished();
-
- // remember that show was called explicitly
- setAttribute(Qt::WA_WState_ExplicitShowHide);
- // whether we need to inform the parent widget immediately
- bool needUpdateGeometry = !isWindow() && testAttribute(Qt::WA_WState_Hidden);
- // we are no longer hidden
- setAttribute(Qt::WA_WState_Hidden, false);
-
- if (needUpdateGeometry)
- d->updateGeometry_helper(true);
-
-#ifdef QT3_SUPPORT
- QApplication::sendPostedEvents(this, QEvent::ChildInserted);
-#endif
- // activate our layout before we and our children become visible
- if (d->layout)
- d->layout->activate();
-
- if (!isWindow()) {
- QWidget *parent = parentWidget();
- while (parent && parent->isVisible() && parent->d_func()->layout && !parent->data->in_show) {
- parent->d_func()->layout->activate();
- if (parent->isWindow())
- break;
- parent = parent->parentWidget();
- }
- if (parent)
- parent->d_func()->setDirtyOpaqueRegion();
- }
-
- // adjust size if necessary
- if (!wasResized
- && (isWindow() || !parentWidget()->d_func()->layout)) {
- if (isWindow()) {
- adjustSize();
- if (windowState() != initialWindowState)
- setWindowState(initialWindowState);
- } else {
- adjustSize();
- }
- setAttribute(Qt::WA_Resized, false);
- }
-
- setAttribute(Qt::WA_KeyboardFocusChange, false);
-
- if (isWindow() || parentWidget()->isVisible()) {
- // remove posted quit events when showing a new window
- QCoreApplication::removePostedEvents(qApp, QEvent::Quit);
-
- d->show_helper();
-
-#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_QPA)
- qApp->d_func()->sendSyntheticEnterLeave(this);
-#endif
- }
-
- QEvent showToParentEvent(QEvent::ShowToParent);
- QApplication::sendEvent(this, &showToParentEvent);
- } else { // hide
- if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden))
- return;
-#if defined(Q_WS_WIN)
- // reset WS_DISABLED style in a Blocked window
- if(isWindow() && testAttribute(Qt::WA_WState_Created)
- && QApplicationPrivate::isBlockedByModal(this))
- {
- LONG dwStyle = GetWindowLong(winId(), GWL_STYLE);
- dwStyle &= ~WS_DISABLED;
- SetWindowLong(winId(), GWL_STYLE, dwStyle);
- }
-#endif
- if (QApplicationPrivate::hidden_focus_widget == this)
- QApplicationPrivate::hidden_focus_widget = 0;
-
- Q_D(QWidget);
-
- // hw: The test on getOpaqueRegion() needs to be more intelligent
- // currently it doesn't work if the widget is hidden (the region will
- // be clipped). The real check should be testing the cached region
- // (and dirty flag) directly.
- if (!isWindow() && parentWidget()) // && !d->getOpaqueRegion().isEmpty())
- parentWidget()->d_func()->setDirtyOpaqueRegion();
-
- setAttribute(Qt::WA_WState_Hidden);
- setAttribute(Qt::WA_WState_ExplicitShowHide);
- if (testAttribute(Qt::WA_WState_Created))
- d->hide_helper();
-
- // invalidate layout similar to updateGeometry()
- if (!isWindow() && parentWidget()) {
- if (parentWidget()->d_func()->layout)
- parentWidget()->d_func()->layout->invalidate();
- else if (parentWidget()->isVisible())
- QApplication::postEvent(parentWidget(), new QEvent(QEvent::LayoutRequest));
- }
-
- QEvent hideToParentEvent(QEvent::HideToParent);
- QApplication::sendEvent(this, &hideToParentEvent);
- }
-}
-
-/*!\fn void QWidget::setHidden(bool hidden)
-
- Convenience function, equivalent to setVisible(!\a hidden).
-*/
-
-/*!\fn void QWidget::setShown(bool shown)
-
- Use setVisible(\a shown) instead.
-*/
-
-
-void QWidgetPrivate::_q_showIfNotHidden()
-{
- Q_Q(QWidget);
- if ( !(q->isHidden() && q->testAttribute(Qt::WA_WState_ExplicitShowHide)) )
- q->setVisible(true);
-}
-
-void QWidgetPrivate::showChildren(bool spontaneous)
-{
- QList<QObject*> childList = children;
- for (int i = 0; i < childList.size(); ++i) {
- QWidget *widget = qobject_cast<QWidget*>(childList.at(i));
- if (!widget
- || widget->isWindow()
- || widget->testAttribute(Qt::WA_WState_Hidden))
- continue;
- if (spontaneous) {
- widget->setAttribute(Qt::WA_Mapped);
- widget->d_func()->showChildren(true);
- QShowEvent e;
- QApplication::sendSpontaneousEvent(widget, &e);
- } else {
- if (widget->testAttribute(Qt::WA_WState_ExplicitShowHide))
- widget->d_func()->show_recursive();
- else
- widget->show();
- }
- }
-}
-
-void QWidgetPrivate::hideChildren(bool spontaneous)
-{
- QList<QObject*> childList = children;
- for (int i = 0; i < childList.size(); ++i) {
- QWidget *widget = qobject_cast<QWidget*>(childList.at(i));
- if (!widget || widget->isWindow() || widget->testAttribute(Qt::WA_WState_Hidden))
- continue;
-#ifdef QT_MAC_USE_COCOA
- // Before doing anything we need to make sure that we don't leave anything in a non-consistent state.
- // When hiding a widget we need to make sure that no mouse_down events are active, because
- // the mouse_up event will never be received by a hidden widget or one of its descendants.
- // The solution is simple, before going through with this we check if there are any mouse_down events in
- // progress, if so we check if it is related to this widget or not. If so, we just reset the mouse_down and
- // then we continue.
- // In X11 and Windows we send a mouse_release event, however we don't do that here because we were already
- // ignoring that from before. I.e. Carbon did not send the mouse release event, so we will not send the
- // mouse release event. There are two ways to interpret this:
- // 1. If we don't send the mouse release event, the widget might get into an inconsistent state, i.e. it
- // might be waiting for a release event that will never arrive.
- // 2. If we send the mouse release event, then the widget might decide to trigger an action that is not
- // supposed to trigger because it is not visible.
- if(widget == qt_button_down)
- qt_button_down = 0;
-#endif // QT_MAC_USE_COCOA
- if (spontaneous)
- widget->setAttribute(Qt::WA_Mapped, false);
- else
- widget->setAttribute(Qt::WA_WState_Visible, false);
- widget->d_func()->hideChildren(spontaneous);
- QHideEvent e;
- if (spontaneous) {
- QApplication::sendSpontaneousEvent(widget, &e);
- } else {
- QApplication::sendEvent(widget, &e);
- if (widget->internalWinId()
- && widget->testAttribute(Qt::WA_DontCreateNativeAncestors)) {
- // hide_sys() on an ancestor won't have any affect on this
- // widget, so it needs an explicit hide_sys() of its own
- widget->d_func()->hide_sys();
- }
- }
-#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_QPA)
- qApp->d_func()->sendSyntheticEnterLeave(widget);
-#endif
-#ifndef QT_NO_ACCESSIBILITY
- if (!spontaneous)
- QAccessible::updateAccessibility(widget, 0, QAccessible::ObjectHide);
-#endif
- }
-}
-
-bool QWidgetPrivate::close_helper(CloseMode mode)
-{
- if (data.is_closing)
- return true;
-
- Q_Q(QWidget);
- data.is_closing = 1;
-
- QPointer<QWidget> that = q;
- QPointer<QWidget> parentWidget = q->parentWidget();
-
-#ifdef QT3_SUPPORT
- bool isMain = (QApplicationPrivate::main_widget == q);
-#endif
- bool quitOnClose = q->testAttribute(Qt::WA_QuitOnClose);
- if (mode != CloseNoEvent) {
- QCloseEvent e;
- if (mode == CloseWithSpontaneousEvent)
- QApplication::sendSpontaneousEvent(q, &e);
- else
- QApplication::sendEvent(q, &e);
- if (!that.isNull() && !e.isAccepted()) {
- data.is_closing = 0;
- return false;
- }
- }
-
- if (!that.isNull() && !q->isHidden())
- q->hide();
-
-#ifdef QT3_SUPPORT
- if (isMain)
- QApplication::quit();
-#endif
- // Attempt to close the application only if this has WA_QuitOnClose set and a non-visible parent
- quitOnClose = quitOnClose && (parentWidget.isNull() || !parentWidget->isVisible());
-
- if (quitOnClose) {
- /* if there is no non-withdrawn primary window left (except
- the ones without QuitOnClose), we emit the lastWindowClosed
- signal */
- QWidgetList list = QApplication::topLevelWidgets();
- bool lastWindowClosed = true;
- for (int i = 0; i < list.size(); ++i) {
- QWidget *w = list.at(i);
- if (!w->isVisible() || w->parentWidget() || !w->testAttribute(Qt::WA_QuitOnClose))
- continue;
- lastWindowClosed = false;
- break;
- }
- if (lastWindowClosed)
- QApplicationPrivate::emitLastWindowClosed();
- }
-
- if (!that.isNull()) {
- data.is_closing = 0;
- if (q->testAttribute(Qt::WA_DeleteOnClose)) {
- q->setAttribute(Qt::WA_DeleteOnClose, false);
- q->deleteLater();
- }
- }
- return true;
-}
-
-
-/*!
- Closes this widget. Returns true if the widget was closed;
- otherwise returns false.
-
- First it sends the widget a QCloseEvent. The widget is \link
- hide() hidden\endlink if it \link QCloseEvent::accept()
- accepts\endlink the close event. If it \link QCloseEvent::ignore()
- ignores\endlink the event, nothing happens. The default
- implementation of QWidget::closeEvent() accepts the close event.
-
- If the widget has the Qt::WA_DeleteOnClose flag, the widget
- is also deleted. A close events is delivered to the widget no
- matter if the widget is visible or not.
-
- The \l QApplication::lastWindowClosed() signal is emitted when the
- last visible primary window (i.e. window with no parent) with the
- Qt::WA_QuitOnClose attribute set is closed. By default this
- attribute is set for all widgets except transient windows such as
- splash screens, tool windows, and popup menus.
-
-*/
-
-bool QWidget::close()
-{
- return d_func()->close_helper(QWidgetPrivate::CloseWithEvent);
-}
-
-/*!
- \property QWidget::visible
- \brief whether the widget is visible
-
- Calling setVisible(true) or show() sets the widget to visible
- status if all its parent widgets up to the window are visible. If
- an ancestor is not visible, the widget won't become visible until
- all its ancestors are shown. If its size or position has changed,
- Qt guarantees that a widget gets move and resize events just
- before it is shown. If the widget has not been resized yet, Qt
- will adjust the widget's size to a useful default using
- adjustSize().
-
- Calling setVisible(false) or hide() hides a widget explicitly. An
- explicitly hidden widget will never become visible, even if all
- its ancestors become visible, unless you show it.
-
- A widget receives show and hide events when its visibility status
- changes. Between a hide and a show event, there is no need to
- waste CPU cycles preparing or displaying information to the user.
- A video application, for example, might simply stop generating new
- frames.
-
- A widget that happens to be obscured by other windows on the
- screen is considered to be visible. The same applies to iconified
- windows and windows that exist on another virtual
- desktop (on platforms that support this concept). A widget
- receives spontaneous show and hide events when its mapping status
- is changed by the window system, e.g. a spontaneous hide event
- when the user minimizes the window, and a spontaneous show event
- when the window is restored again.
-
- You almost never have to reimplement the setVisible() function. If
- you need to change some settings before a widget is shown, use
- showEvent() instead. If you need to do some delayed initialization
- use the Polish event delivered to the event() function.
-
- \sa show(), hide(), isHidden(), isVisibleTo(), isMinimized(),
- showEvent(), hideEvent()
-*/
-
-
-/*!
- Returns true if this widget would become visible if \a ancestor is
- shown; otherwise returns false.
-
- The true case occurs if neither the widget itself nor any parent
- up to but excluding \a ancestor has been explicitly hidden.
-
- This function will still return true if the widget is obscured by
- other windows on the screen, but could be physically visible if it
- or they were to be moved.
-
- isVisibleTo(0) is identical to isVisible().
-
- \sa show() hide() isVisible()
-*/
-
-bool QWidget::isVisibleTo(QWidget* ancestor) const
-{
- if (!ancestor)
- return isVisible();
- const QWidget * w = this;
- while (!w->isHidden()
- && !w->isWindow()
- && w->parentWidget()
- && w->parentWidget() != ancestor)
- w = w->parentWidget();
- return !w->isHidden();
-}
-
-#ifdef QT3_SUPPORT
-/*!
- Use visibleRegion() instead.
-*/
-QRect QWidget::visibleRect() const
-{
- return d_func()->clipRect();
-}
-#endif
-
-/*!
- Returns the unobscured region where paint events can occur.
-
- For visible widgets, this is an approximation of the area not
- covered by other widgets; otherwise, this is an empty region.
-
- The repaint() function calls this function if necessary, so in
- general you do not need to call it.
-
-*/
-QRegion QWidget::visibleRegion() const
-{
- Q_D(const QWidget);
-
- QRect clipRect = d->clipRect();
- if (clipRect.isEmpty())
- return QRegion();
- QRegion r(clipRect);
- d->subtractOpaqueChildren(r, clipRect);
- d->subtractOpaqueSiblings(r);
-#ifdef Q_WS_QWS
- const QWSWindowSurface *surface = static_cast<const QWSWindowSurface*>(windowSurface());
- if (surface) {
- const QPoint offset = mapTo(surface->window(), QPoint());
- r &= surface->clipRegion().translated(-offset);
- }
-#endif
- return r;
-}
-
-
-QSize QWidgetPrivate::adjustedSize() const
-{
- Q_Q(const QWidget);
-
- QSize s = q->sizeHint();
-
- if (q->isWindow()) {
- Qt::Orientations exp;
- if (layout) {
- if (layout->hasHeightForWidth())
- s.setHeight(layout->totalHeightForWidth(s.width()));
- exp = layout->expandingDirections();
- } else
- {
- if (q->sizePolicy().hasHeightForWidth())
- s.setHeight(q->heightForWidth(s.width()));
- exp = q->sizePolicy().expandingDirections();
- }
- if (exp & Qt::Horizontal)
- s.setWidth(qMax(s.width(), 200));
- if (exp & Qt::Vertical)
- s.setHeight(qMax(s.height(), 100));
-#if defined(Q_WS_X11)
- QRect screen = QApplication::desktop()->screenGeometry(q->x11Info().screen());
-#else // all others
- QRect screen = QApplication::desktop()->screenGeometry(q->pos());
-#endif
-#if defined (Q_WS_WINCE) || defined (Q_OS_SYMBIAN)
- s.setWidth(qMin(s.width(), screen.width()));
- s.setHeight(qMin(s.height(), screen.height()));
-#else
- s.setWidth(qMin(s.width(), screen.width()*2/3));
- s.setHeight(qMin(s.height(), screen.height()*2/3));
-#endif
- if (QTLWExtra *extra = maybeTopData())
- extra->sizeAdjusted = true;
- }
-
- if (!s.isValid()) {
- QRect r = q->childrenRect(); // get children rectangle
- if (r.isNull())
- return s;
- s = r.size() + QSize(2 * r.x(), 2 * r.y());
- }
-
- return s;
-}
-
-/*!
- Adjusts the size of the widget to fit its contents.
-
- This function uses sizeHint() if it is valid, i.e., the size hint's width
- and height are \>= 0. Otherwise, it sets the size to the children
- rectangle that covers all child widgets (the union of all child widget
- rectangles).
-
- For windows, the screen size is also taken into account. If the sizeHint()
- is less than (200, 100) and the size policy is \l{QSizePolicy::Expanding}
- {expanding}, the window will be at least (200, 100). The maximum size of
- a window is 2/3 of the screen's width and height.
-
- \sa sizeHint(), childrenRect()
-*/
-
-void QWidget::adjustSize()
-{
- Q_D(QWidget);
- ensurePolished();
- QSize s = d->adjustedSize();
-
- if (d->layout)
- d->layout->activate();
-
- if (s.isValid())
- resize(s);
-}
-
-
-/*!
- \property QWidget::sizeHint
- \brief the recommended size for the widget
-
- If the value of this property is an invalid size, no size is
- recommended.
-
- The default implementation of sizeHint() returns an invalid size
- if there is no layout for this widget, and returns the layout's
- preferred size otherwise.
-
- \sa QSize::isValid(), minimumSizeHint(), sizePolicy(),
- setMinimumSize(), updateGeometry()
-*/
-
-QSize QWidget::sizeHint() const
-{
- Q_D(const QWidget);
- if (d->layout)
- return d->layout->totalSizeHint();
- return QSize(-1, -1);
-}
-
-/*!
- \property QWidget::minimumSizeHint
- \brief the recommended minimum size for the widget
-
- If the value of this property is an invalid size, no minimum size
- is recommended.
-
- The default implementation of minimumSizeHint() returns an invalid
- size if there is no layout for this widget, and returns the
- layout's minimum size otherwise. Most built-in widgets reimplement
- minimumSizeHint().
-
- \l QLayout will never resize a widget to a size smaller than the
- minimum size hint unless minimumSize() is set or the size policy is
- set to QSizePolicy::Ignore. If minimumSize() is set, the minimum
- size hint will be ignored.
-
- \sa QSize::isValid(), resize(), setMinimumSize(), sizePolicy()
-*/
-QSize QWidget::minimumSizeHint() const
-{
- Q_D(const QWidget);
- if (d->layout)
- return d->layout->totalMinimumSize();
- return QSize(-1, -1);
-}
-
-
-/*!
- \fn QWidget *QWidget::parentWidget() const
-
- Returns the parent of this widget, or 0 if it does not have any
- parent widget.
-*/
-
-
-/*!
- Returns true if this widget is a parent, (or grandparent and so on
- to any level), of the given \a child, and both widgets are within
- the same window; otherwise returns false.
-*/
-
-bool QWidget::isAncestorOf(const QWidget *child) const
-{
- while (child) {
- if (child == this)
- return true;
- if (child->isWindow())
- return false;
- child = child->parentWidget();
- }
- return false;
-}
-
-#if defined(Q_WS_WIN)
-inline void setDisabledStyle(QWidget *w, bool setStyle)
-{
- // set/reset WS_DISABLED style.
- if(w && w->isWindow() && w->isVisible() && w->isEnabled()) {
- LONG dwStyle = GetWindowLong(w->winId(), GWL_STYLE);
- LONG newStyle = dwStyle;
- if (setStyle)
- newStyle |= WS_DISABLED;
- else
- newStyle &= ~WS_DISABLED;
- if (newStyle != dwStyle) {
- SetWindowLong(w->winId(), GWL_STYLE, newStyle);
- // we might need to repaint in some situations (eg. menu)
- w->repaint();
- }
- }
-}
-#endif
-
-/*****************************************************************************
- QWidget event handling
- *****************************************************************************/
-
-/*!
- This is the main event handler; it handles event \a event. You can
- reimplement this function in a subclass, but we recommend using
- one of the specialized event handlers instead.
-
- Key press and release events are treated differently from other
- events. event() checks for Tab and Shift+Tab and tries to move the
- focus appropriately. If there is no widget to move the focus to
- (or the key press is not Tab or Shift+Tab), event() calls
- keyPressEvent().
-
- Mouse and tablet event handling is also slightly special: only
- when the widget is \l enabled, event() will call the specialized
- handlers such as mousePressEvent(); otherwise it will discard the
- event.
-
- This function returns true if the event was recognized, otherwise
- it returns false. If the recognized event was accepted (see \l
- QEvent::accepted), any further processing such as event
- propagation to the parent widget stops.
-
- \sa closeEvent(), focusInEvent(), focusOutEvent(), enterEvent(),
- keyPressEvent(), keyReleaseEvent(), leaveEvent(),
- mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(),
- mouseReleaseEvent(), moveEvent(), paintEvent(), resizeEvent(),
- QObject::event(), QObject::timerEvent()
-*/
-
-bool QWidget::event(QEvent *event)
-{
- Q_D(QWidget);
-
- // ignore mouse events when disabled
- if (!isEnabled()) {
- switch(event->type()) {
- case QEvent::TabletPress:
- case QEvent::TabletRelease:
- case QEvent::TabletMove:
- case QEvent::MouseButtonPress:
- case QEvent::MouseButtonRelease:
- case QEvent::MouseButtonDblClick:
- case QEvent::MouseMove:
- case QEvent::TouchBegin:
- case QEvent::TouchUpdate:
- case QEvent::TouchEnd:
- case QEvent::ContextMenu:
-#ifndef QT_NO_WHEELEVENT
- case QEvent::Wheel:
-#endif
- return false;
- default:
- break;
- }
- }
- switch (event->type()) {
- case QEvent::MouseMove:
- mouseMoveEvent((QMouseEvent*)event);
- break;
-
- case QEvent::MouseButtonPress:
- // Don't reset input context here. Whether reset or not is
- // a responsibility of input method. reset() will be
- // called by mouseHandler() of input method if necessary
- // via mousePressEvent() of text widgets.
-#if 0
- resetInputContext();
-#endif
- mousePressEvent((QMouseEvent*)event);
- break;
-
- case QEvent::MouseButtonRelease:
- mouseReleaseEvent((QMouseEvent*)event);
- break;
-
- case QEvent::MouseButtonDblClick:
- mouseDoubleClickEvent((QMouseEvent*)event);
- break;
-#ifndef QT_NO_WHEELEVENT
- case QEvent::Wheel:
- wheelEvent((QWheelEvent*)event);
- break;
-#endif
-#ifndef QT_NO_TABLETEVENT
- case QEvent::TabletMove:
- case QEvent::TabletPress:
- case QEvent::TabletRelease:
- tabletEvent((QTabletEvent*)event);
- break;
-#endif
-#ifdef QT3_SUPPORT
- case QEvent::Accel:
- event->ignore();
- return false;
-#endif
- case QEvent::KeyPress: {
- QKeyEvent *k = (QKeyEvent *)event;
- bool res = false;
- if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier?
- if (k->key() == Qt::Key_Backtab
- || (k->key() == Qt::Key_Tab && (k->modifiers() & Qt::ShiftModifier)))
- res = focusNextPrevChild(false);
- else if (k->key() == Qt::Key_Tab)
- res = focusNextPrevChild(true);
- if (res)
- break;
- }
- keyPressEvent(k);
-#ifdef QT_KEYPAD_NAVIGATION
- if (!k->isAccepted() && QApplication::keypadNavigationEnabled()
- && !(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier | Qt::ShiftModifier))) {
- if (QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder) {
- if (k->key() == Qt::Key_Up)
- res = focusNextPrevChild(false);
- else if (k->key() == Qt::Key_Down)
- res = focusNextPrevChild(true);
- } else if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) {
- if (k->key() == Qt::Key_Up)
- res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionNorth);
- else if (k->key() == Qt::Key_Right)
- res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionEast);
- else if (k->key() == Qt::Key_Down)
- res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionSouth);
- else if (k->key() == Qt::Key_Left)
- res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionWest);
- }
- if (res) {
- k->accept();
- break;
- }
- }
-#endif
-#ifndef QT_NO_WHATSTHIS
- if (!k->isAccepted()
- && k->modifiers() & Qt::ShiftModifier && k->key() == Qt::Key_F1
- && d->whatsThis.size()) {
- QWhatsThis::showText(mapToGlobal(inputMethodQuery(Qt::ImMicroFocus).toRect().center()), d->whatsThis, this);
- k->accept();
- }
-#endif
- }
- break;
-
- case QEvent::KeyRelease:
- keyReleaseEvent((QKeyEvent*)event);
- // fall through
- case QEvent::ShortcutOverride:
- break;
-
- case QEvent::InputMethod:
- inputMethodEvent((QInputMethodEvent *) event);
- break;
-
- case QEvent::PolishRequest:
- ensurePolished();
- break;
-
- case QEvent::Polish: {
- style()->polish(this);
- setAttribute(Qt::WA_WState_Polished);
- if (!QApplication::font(this).isCopyOf(QApplication::font()))
- d->resolveFont();
- if (!QApplication::palette(this).isCopyOf(QApplication::palette()))
- d->resolvePalette();
-#ifdef QT3_SUPPORT
- if(d->sendChildEvents)
- QApplication::sendPostedEvents(this, QEvent::ChildInserted);
-#endif
- }
- break;
-
- case QEvent::ApplicationWindowIconChange:
- if (isWindow() && !testAttribute(Qt::WA_SetWindowIcon)) {
- d->setWindowIcon_sys();
- d->setWindowIcon_helper();
- }
- break;
- case QEvent::FocusIn:
-#ifdef QT_SOFTKEYS_ENABLED
- QSoftKeyManager::updateSoftKeys();
-#endif
- focusInEvent((QFocusEvent*)event);
- break;
-
- case QEvent::FocusOut:
- focusOutEvent((QFocusEvent*)event);
- break;
-
- case QEvent::Enter:
-#ifndef QT_NO_STATUSTIP
- if (d->statusTip.size()) {
- QStatusTipEvent tip(d->statusTip);
- QApplication::sendEvent(const_cast<QWidget *>(this), &tip);
- }
-#endif
- enterEvent(event);
- break;
-
- case QEvent::Leave:
-#ifndef QT_NO_STATUSTIP
- if (d->statusTip.size()) {
- QString empty;
- QStatusTipEvent tip(empty);
- QApplication::sendEvent(const_cast<QWidget *>(this), &tip);
- }
-#endif
- leaveEvent(event);
- break;
-
- case QEvent::HoverEnter:
- case QEvent::HoverLeave:
- update();
- break;
-
- case QEvent::Paint:
- // At this point the event has to be delivered, regardless
- // whether the widget isVisible() or not because it
- // already went through the filters
- paintEvent((QPaintEvent*)event);
- break;
-
- case QEvent::Move:
- moveEvent((QMoveEvent*)event);
- break;
-
- case QEvent::Resize:
- resizeEvent((QResizeEvent*)event);
- break;
-
- case QEvent::Close:
- closeEvent((QCloseEvent *)event);
- break;
-
-#ifndef QT_NO_CONTEXTMENU
- case QEvent::ContextMenu:
- switch (data->context_menu_policy) {
- case Qt::PreventContextMenu:
- break;
- case Qt::DefaultContextMenu:
- contextMenuEvent(static_cast<QContextMenuEvent *>(event));
- break;
- case Qt::CustomContextMenu:
- emit customContextMenuRequested(static_cast<QContextMenuEvent *>(event)->pos());
- break;
-#ifndef QT_NO_MENU
- case Qt::ActionsContextMenu:
- if (d->actions.count()) {
- QMenu::exec(d->actions, static_cast<QContextMenuEvent *>(event)->globalPos(),
- 0, this);
- break;
- }
- // fall through
-#endif
- default:
- event->ignore();
- break;
- }
- break;
-#endif // QT_NO_CONTEXTMENU
-
-#ifndef QT_NO_DRAGANDDROP
- case QEvent::Drop:
- dropEvent((QDropEvent*) event);
- break;
-
- case QEvent::DragEnter:
- dragEnterEvent((QDragEnterEvent*) event);
- break;
-
- case QEvent::DragMove:
- dragMoveEvent((QDragMoveEvent*) event);
- break;
-
- case QEvent::DragLeave:
- dragLeaveEvent((QDragLeaveEvent*) event);
- break;
-#endif
-
- case QEvent::Show:
- showEvent((QShowEvent*) event);
- break;
-
- case QEvent::Hide:
- hideEvent((QHideEvent*) event);
- break;
-
- case QEvent::ShowWindowRequest:
- if (!isHidden())
- d->show_sys();
- break;
-
- case QEvent::ApplicationFontChange:
- d->resolveFont();
- break;
- case QEvent::ApplicationPaletteChange:
- if (!(windowType() == Qt::Desktop))
- d->resolvePalette();
- break;
-
- case QEvent::ToolBarChange:
- case QEvent::ActivationChange:
- case QEvent::EnabledChange:
- case QEvent::FontChange:
- case QEvent::StyleChange:
- case QEvent::PaletteChange:
- case QEvent::WindowTitleChange:
- case QEvent::IconTextChange:
- case QEvent::ModifiedChange:
- case QEvent::MouseTrackingChange:
- case QEvent::ParentChange:
- case QEvent::WindowStateChange:
- case QEvent::LocaleChange:
- case QEvent::MacSizeChange:
- case QEvent::ContentsRectChange:
- changeEvent(event);
- break;
-
- case QEvent::WindowActivate:
- case QEvent::WindowDeactivate: {
-#ifdef QT3_SUPPORT
- windowActivationChange(event->type() != QEvent::WindowActivate);
-#endif
- if (isVisible() && !palette().isEqual(QPalette::Active, QPalette::Inactive))
- update();
- QList<QObject*> childList = d->children;
- for (int i = 0; i < childList.size(); ++i) {
- QWidget *w = qobject_cast<QWidget *>(childList.at(i));
- if (w && w->isVisible() && !w->isWindow())
- QApplication::sendEvent(w, event);
- }
-
-#ifdef QT_SOFTKEYS_ENABLED
- if (isWindow())
- QSoftKeyManager::updateSoftKeys();
-#endif
-
- break; }
-
- case QEvent::LanguageChange:
-#ifdef QT3_SUPPORT
- languageChange();
-#endif
- changeEvent(event);
- {
- QList<QObject*> childList = d->children;
- for (int i = 0; i < childList.size(); ++i) {
- QObject *o = childList.at(i);
- if (o)
- QApplication::sendEvent(o, event);
- }
- }
- update();
- break;
-
- case QEvent::ApplicationLayoutDirectionChange:
- d->resolveLayoutDirection();
- break;
-
- case QEvent::LayoutDirectionChange:
- if (d->layout)
- d->layout->invalidate();
- update();
- changeEvent(event);
- break;
- case QEvent::UpdateRequest:
- d->syncBackingStore();
- break;
- case QEvent::UpdateLater:
- update(static_cast<QUpdateLaterEvent*>(event)->region());
- break;
-
- case QEvent::WindowBlocked:
- case QEvent::WindowUnblocked:
- {
- QList<QObject*> childList = d->children;
- for (int i = 0; i < childList.size(); ++i) {
- QObject *o = childList.at(i);
- if (o && o != QApplication::activeModalWidget()) {
- if (qobject_cast<QWidget *>(o) && static_cast<QWidget *>(o)->isWindow()) {
- // do not forward the event to child windows,
- // QApplication does this for us
- continue;
- }
- QApplication::sendEvent(o, event);
- }
- }
-#if defined(Q_WS_WIN)
- setDisabledStyle(this, (event->type() == QEvent::WindowBlocked));
-#endif
- }
- break;
-#ifndef QT_NO_TOOLTIP
- case QEvent::ToolTip:
- if (!d->toolTip.isEmpty())
- QToolTip::showText(static_cast<QHelpEvent*>(event)->globalPos(), d->toolTip, this);
- else
- event->ignore();
- break;
-#endif
-#ifndef QT_NO_WHATSTHIS
- case QEvent::WhatsThis:
- if (d->whatsThis.size())
- QWhatsThis::showText(static_cast<QHelpEvent *>(event)->globalPos(), d->whatsThis, this);
- else
- event->ignore();
- break;
- case QEvent::QueryWhatsThis:
- if (d->whatsThis.isEmpty())
- event->ignore();
- break;
-#endif
-#ifndef QT_NO_ACCESSIBILITY
- case QEvent::AccessibilityDescription:
- case QEvent::AccessibilityHelp: {
- QAccessibleEvent *ev = static_cast<QAccessibleEvent *>(event);
- if (ev->child())
- return false;
- switch (ev->type()) {
-#ifndef QT_NO_TOOLTIP
- case QEvent::AccessibilityDescription:
- ev->setValue(d->toolTip);
- break;
-#endif
-#ifndef QT_NO_WHATSTHIS
- case QEvent::AccessibilityHelp:
- ev->setValue(d->whatsThis);
- break;
-#endif
- default:
- return false;
- }
- break; }
-#endif
- case QEvent::EmbeddingControl:
- d->topData()->frameStrut.setCoords(0 ,0, 0, 0);
- data->fstrut_dirty = false;
-#if defined(Q_WS_WIN) || defined(Q_WS_X11)
- d->topData()->embedded = 1;
-#endif
- break;
-#ifndef QT_NO_ACTION
- case QEvent::ActionAdded:
- case QEvent::ActionRemoved:
- case QEvent::ActionChanged:
-#ifdef QT_SOFTKEYS_ENABLED
- QSoftKeyManager::updateSoftKeys();
-#endif
- actionEvent((QActionEvent*)event);
- break;
-#endif
-
- case QEvent::KeyboardLayoutChange:
- {
- changeEvent(event);
-
- // inform children of the change
- QList<QObject*> childList = d->children;
- for (int i = 0; i < childList.size(); ++i) {
- QWidget *w = qobject_cast<QWidget *>(childList.at(i));
- if (w && w->isVisible() && !w->isWindow())
- QApplication::sendEvent(w, event);
- }
- break;
- }
-#ifdef Q_WS_MAC
- case QEvent::MacGLWindowChange:
- d->needWindowChange = false;
- break;
-#endif
- case QEvent::TouchBegin:
- case QEvent::TouchUpdate:
- case QEvent::TouchEnd:
- {
-#ifndef Q_WS_MAC
- QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);
- const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().first();
- if (touchPoint.isPrimary() || touchEvent->deviceType() == QTouchEvent::TouchPad)
- break;
-
- // fake a mouse event!
- QEvent::Type eventType = QEvent::None;
- switch (touchEvent->type()) {
- case QEvent::TouchBegin:
- eventType = QEvent::MouseButtonPress;
- break;
- case QEvent::TouchUpdate:
- eventType = QEvent::MouseMove;
- break;
- case QEvent::TouchEnd:
- eventType = QEvent::MouseButtonRelease;
- break;
- default:
- Q_ASSERT(!true);
- break;
- }
- if (eventType == QEvent::None)
- break;
-
- QMouseEvent mouseEvent(eventType,
- touchPoint.pos().toPoint(),
- touchPoint.screenPos().toPoint(),
- Qt::LeftButton,
- Qt::LeftButton,
- touchEvent->modifiers());
- (void) QApplication::sendEvent(this, &mouseEvent);
-#endif // Q_WS_MAC
- break;
- }
-#ifndef QT_NO_GESTURES
- case QEvent::Gesture:
- event->ignore();
- break;
-#endif
-#ifndef QT_NO_PROPERTIES
- case QEvent::DynamicPropertyChange: {
- const QByteArray &propName = static_cast<QDynamicPropertyChangeEvent *>(event)->propertyName();
- if (!qstrncmp(propName, "_q_customDpi", 12) && propName.length() == 13) {
- uint value = property(propName.constData()).toUInt();
- if (!d->extra)
- d->createExtra();
- const char axis = propName.at(12);
- if (axis == 'X')
- d->extra->customDpiX = value;
- else if (axis == 'Y')
- d->extra->customDpiY = value;
- d->updateFont(d->data.fnt);
- }
- // fall through
- }
-#endif
- default:
- return QObject::event(event);
- }
- return true;
-}
-
-/*!
- This event handler can be reimplemented to handle state changes.
-
- The state being changed in this event can be retrieved through the \a event
- supplied.
-
- Change events include: QEvent::ToolBarChange,
- QEvent::ActivationChange, QEvent::EnabledChange, QEvent::FontChange,
- QEvent::StyleChange, QEvent::PaletteChange,
- QEvent::WindowTitleChange, QEvent::IconTextChange,
- QEvent::ModifiedChange, QEvent::MouseTrackingChange,
- QEvent::ParentChange, QEvent::WindowStateChange,
- QEvent::LanguageChange, QEvent::LocaleChange,
- QEvent::LayoutDirectionChange.
-
-*/
-void QWidget::changeEvent(QEvent * event)
-{
- switch(event->type()) {
- case QEvent::EnabledChange:
- update();
-#ifndef QT_NO_ACCESSIBILITY
- QAccessible::updateAccessibility(this, 0, QAccessible::StateChanged);
-#endif
- break;
-
- case QEvent::FontChange:
- case QEvent::StyleChange: {
- Q_D(QWidget);
- update();
- updateGeometry();
- if (d->layout)
- d->layout->invalidate();
-#ifdef Q_WS_QWS
- if (isWindow())
- d->data.fstrut_dirty = true;
-#endif
- break;
- }
-
- case QEvent::PaletteChange:
- update();
- break;
-
-#ifdef Q_WS_MAC
- case QEvent::MacSizeChange:
- updateGeometry();
- break;
- case QEvent::ToolTipChange:
- case QEvent::MouseTrackingChange:
- qt_mac_update_mouseTracking(this);
- break;
-#endif
-
- default:
- break;
- }
-}
-
-/*!
- This event handler, for event \a event, can be reimplemented in a
- subclass to receive mouse move events for the widget.
-
- If mouse tracking is switched off, mouse move events only occur if
- a mouse button is pressed while the mouse is being moved. If mouse
- tracking is switched on, mouse move events occur even if no mouse
- button is pressed.
-
- QMouseEvent::pos() reports the position of the mouse cursor,
- relative to this widget. For press and release events, the
- position is usually the same as the position of the last mouse
- move event, but it might be different if the user's hand shakes.
- This is a feature of the underlying window system, not Qt.
-
- If you want to show a tooltip immediately, while the mouse is
- moving (e.g., to get the mouse coordinates with QMouseEvent::pos()
- and show them as a tooltip), you must first enable mouse tracking
- as described above. Then, to ensure that the tooltip is updated
- immediately, you must call QToolTip::showText() instead of
- setToolTip() in your implementation of mouseMoveEvent().
-
- \sa setMouseTracking(), mousePressEvent(), mouseReleaseEvent(),
- mouseDoubleClickEvent(), event(), QMouseEvent, {Scribble Example}
-*/
-
-void QWidget::mouseMoveEvent(QMouseEvent *event)
-{
- event->ignore();
-}
-
-/*!
- This event handler, for event \a event, can be reimplemented in a
- subclass to receive mouse press events for the widget.
-
- If you create new widgets in the mousePressEvent() the
- mouseReleaseEvent() may not end up where you expect, depending on
- the underlying window system (or X11 window manager), the widgets'
- location and maybe more.
-
- The default implementation implements the closing of popup widgets
- when you click outside the window. For other widget types it does
- nothing.
-
- \sa mouseReleaseEvent(), mouseDoubleClickEvent(),
- mouseMoveEvent(), event(), QMouseEvent, {Scribble Example}
-*/
-
-void QWidget::mousePressEvent(QMouseEvent *event)
-{
- event->ignore();
- if ((windowType() == Qt::Popup)) {
- event->accept();
- QWidget* w;
- while ((w = QApplication::activePopupWidget()) && w != this){
- w->close();
- if (QApplication::activePopupWidget() == w) // widget does not want to disappear
- w->hide(); // hide at least
- }
- if (!rect().contains(event->pos())){
- close();
- }
- }
-}
-
-/*!
- This event handler, for event \a event, can be reimplemented in a
- subclass to receive mouse release events for the widget.
-
- \sa mousePressEvent(), mouseDoubleClickEvent(),
- mouseMoveEvent(), event(), QMouseEvent, {Scribble Example}
-*/
-
-void QWidget::mouseReleaseEvent(QMouseEvent *event)
-{
- event->ignore();
-}
-
-/*!
- This event handler, for event \a event, can be reimplemented in a
- subclass to receive mouse double click events for the widget.
-
- The default implementation generates a normal mouse press event.
-
- \note The widget will also receive mouse press and mouse release
- events in addition to the double click event. It is up to the
- developer to ensure that the application interprets these events
- correctly.
-
- \sa mousePressEvent(), mouseReleaseEvent() mouseMoveEvent(),
- event(), QMouseEvent
-*/
-
-void QWidget::mouseDoubleClickEvent(QMouseEvent *event)
-{
- mousePressEvent(event); // try mouse press event
-}
-
-#ifndef QT_NO_WHEELEVENT
-/*!
- This event handler, for event \a event, can be reimplemented in a
- subclass to receive wheel events for the widget.
-
- If you reimplement this handler, it is very important that you
- \link QWheelEvent ignore()\endlink the event if you do not handle
- it, so that the widget's parent can interpret it.
-
- The default implementation ignores the event.
-
- \sa QWheelEvent::ignore(), QWheelEvent::accept(), event(),
- QWheelEvent
-*/
-
-void QWidget::wheelEvent(QWheelEvent *event)
-{
- event->ignore();
-}
-#endif // QT_NO_WHEELEVENT
-
-#ifndef QT_NO_TABLETEVENT
-/*!
- This event handler, for event \a event, can be reimplemented in a
- subclass to receive tablet events for the widget.
-
- If you reimplement this handler, it is very important that you
- \link QTabletEvent ignore()\endlink the event if you do not handle
- it, so that the widget's parent can interpret it.
-
- The default implementation ignores the event.
-
- \sa QTabletEvent::ignore(), QTabletEvent::accept(), event(),
- QTabletEvent
-*/
-
-void QWidget::tabletEvent(QTabletEvent *event)
-{
- event->ignore();
-}
-#endif // QT_NO_TABLETEVENT
-
-/*!
- This event handler, for event \a event, can be reimplemented in a
- subclass to receive key press events for the widget.
-
- A widget must call setFocusPolicy() to accept focus initially and
- have focus in order to receive a key press event.
-
- If you reimplement this handler, it is very important that you
- call the base class implementation if you do not act upon the key.
-
- The default implementation closes popup widgets if the user
- presses Esc. Otherwise the event is ignored, so that the widget's
- parent can interpret it.
-
- Note that QKeyEvent starts with isAccepted() == true, so you do not
- need to call QKeyEvent::accept() - just do not call the base class
- implementation if you act upon the key.
-
- \sa keyReleaseEvent(), setFocusPolicy(),
- focusInEvent(), focusOutEvent(), event(), QKeyEvent, {Tetrix Example}
-*/
-
-void QWidget::keyPressEvent(QKeyEvent *event)
-{
- if ((windowType() == Qt::Popup) && event->key() == Qt::Key_Escape) {
- event->accept();
- close();
- } else {
- event->ignore();
- }
-}
-
-/*!
- This event handler, for event \a event, can be reimplemented in a
- subclass to receive key release events for the widget.
-
- A widget must \link setFocusPolicy() accept focus\endlink
- initially and \link hasFocus() have focus\endlink in order to
- receive a key release event.
-
- If you reimplement this handler, it is very important that you
- call the base class implementation if you do not act upon the key.
-
- The default implementation ignores the event, so that the widget's
- parent can interpret it.
-
- Note that QKeyEvent starts with isAccepted() == true, so you do not
- need to call QKeyEvent::accept() - just do not call the base class
- implementation if you act upon the key.
-
- \sa keyPressEvent(), QKeyEvent::ignore(), setFocusPolicy(),
- focusInEvent(), focusOutEvent(), event(), QKeyEvent
-*/
-
-void QWidget::keyReleaseEvent(QKeyEvent *event)
-{
- event->ignore();
-}
-
-/*!
- \fn void QWidget::focusInEvent(QFocusEvent *event)
-
- This event handler can be reimplemented in a subclass to receive
- keyboard focus events (focus received) for the widget. The event
- is passed in the \a event parameter
-
- A widget normally must setFocusPolicy() to something other than
- Qt::NoFocus in order to receive focus events. (Note that the
- application programmer can call setFocus() on any widget, even
- those that do not normally accept focus.)
-
- The default implementation updates the widget (except for windows
- that do not specify a focusPolicy()).
-
- \sa focusOutEvent(), setFocusPolicy(), keyPressEvent(),
- keyReleaseEvent(), event(), QFocusEvent
-*/
-
-void QWidget::focusInEvent(QFocusEvent *)
-{
- if (focusPolicy() != Qt::NoFocus || !isWindow()) {
- update();
- }
-}
-
-/*!
- \fn void QWidget::focusOutEvent(QFocusEvent *event)
-
- This event handler can be reimplemented in a subclass to receive
- keyboard focus events (focus lost) for the widget. The events is
- passed in the \a event parameter.
-
- A widget normally must setFocusPolicy() to something other than
- Qt::NoFocus in order to receive focus events. (Note that the
- application programmer can call setFocus() on any widget, even
- those that do not normally accept focus.)
-
- The default implementation updates the widget (except for windows
- that do not specify a focusPolicy()).
-
- \sa focusInEvent(), setFocusPolicy(), keyPressEvent(),
- keyReleaseEvent(), event(), QFocusEvent
-*/
-
-void QWidget::focusOutEvent(QFocusEvent *)
-{
- if (focusPolicy() != Qt::NoFocus || !isWindow())
- update();
-}
-
-/*!
- \fn void QWidget::enterEvent(QEvent *event)
-
- This event handler can be reimplemented in a subclass to receive
- widget enter events which are passed in the \a event parameter.
-
- An event is sent to the widget when the mouse cursor enters the
- widget.
-
- \sa leaveEvent(), mouseMoveEvent(), event()
-*/
-
-void QWidget::enterEvent(QEvent *)
-{
-}
-
-/*!
- \fn void QWidget::leaveEvent(QEvent *event)
-
- This event handler can be reimplemented in a subclass to receive
- widget leave events which are passed in the \a event parameter.
-
- A leave event is sent to the widget when the mouse cursor leaves
- the widget.
-
- \sa enterEvent(), mouseMoveEvent(), event()
-*/
-
-void QWidget::leaveEvent(QEvent *)
-{
-}
-
-/*!
- \fn void QWidget::paintEvent(QPaintEvent *event)
-
- This event handler can be reimplemented in a subclass to receive paint
- events passed in \a event.
-
- A paint event is a request to repaint all or part of a widget. It can
- happen for one of the following reasons:
-
- \list
- \o repaint() or update() was invoked,
- \o the widget was obscured and has now been uncovered, or
- \o many other reasons.
- \endlist
-
- Many widgets can simply repaint their entire surface when asked to, but
- some slow widgets need to optimize by painting only the requested region:
- QPaintEvent::region(). This speed optimization does not change the result,
- as painting is clipped to that region during event processing. QListView
- and QTableView do this, for example.
-
- Qt also tries to speed up painting by merging multiple paint events into
- one. When update() is called several times or the window system sends
- several paint events, Qt merges these events into one event with a larger
- region (see QRegion::united()). The repaint() function does not permit this
- optimization, so we suggest using update() whenever possible.
-
- When the paint event occurs, the update region has normally been erased, so
- you are painting on the widget's background.
-
- The background can be set using setBackgroundRole() and setPalette().
-
- Since Qt 4.0, QWidget automatically double-buffers its painting, so there
- is no need to write double-buffering code in paintEvent() to avoid flicker.
-
- \bold{Note for the X11 platform}: It is possible to toggle global double
- buffering by calling \c qt_x11_set_global_double_buffer(). For example,
-
- \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 14
-
- \note Generally, you should refrain from calling update() or repaint()
- \bold{inside} a paintEvent(). For example, calling update() or repaint() on
- children inside a paintevent() results in undefined behavior; the child may
- or may not get a paint event.
-
- \warning If you are using a custom paint engine without Qt's backingstore,
- Qt::WA_PaintOnScreen must be set. Otherwise, QWidget::paintEngine() will
- never be called; the backingstore will be used instead.
-
- \sa event(), repaint(), update(), QPainter, QPixmap, QPaintEvent,
- {Analog Clock Example}
-*/
-
-void QWidget::paintEvent(QPaintEvent *)
-{
-}
-
-
-/*!
- \fn void QWidget::moveEvent(QMoveEvent *event)
-
- This event handler can be reimplemented in a subclass to receive
- widget move events which are passed in the \a event parameter.
- When the widget receives this event, it is already at the new
- position.
-
- The old position is accessible through QMoveEvent::oldPos().
-
- \sa resizeEvent(), event(), move(), QMoveEvent
-*/
-
-void QWidget::moveEvent(QMoveEvent *)
-{
-}
-
-
-/*!
- This event handler can be reimplemented in a subclass to receive
- widget resize events which are passed in the \a event parameter.
- When resizeEvent() is called, the widget already has its new
- geometry. The old size is accessible through
- QResizeEvent::oldSize().
-
- The widget will be erased and receive a paint event immediately
- after processing the resize event. No drawing need be (or should
- be) done inside this handler.
-
-
- \sa moveEvent(), event(), resize(), QResizeEvent, paintEvent(),
- {Scribble Example}
-*/
-
-void QWidget::resizeEvent(QResizeEvent * /* event */)
-{
-}
-
-#ifndef QT_NO_ACTION
-/*!
- \fn void QWidget::actionEvent(QActionEvent *event)
-
- This event handler is called with the given \a event whenever the
- widget's actions are changed.
-
- \sa addAction(), insertAction(), removeAction(), actions(), QActionEvent
-*/
-void QWidget::actionEvent(QActionEvent *)
-{
-
-}
-#endif
-
-/*!
- This event handler is called with the given \a event when Qt receives a window
- close request for a top-level widget from the window system.
-
- By default, the event is accepted and the widget is closed. You can reimplement
- this function to change the way the widget responds to window close requests.
- For example, you can prevent the window from closing by calling \l{QEvent::}{ignore()}
- on all events.
-
- Main window applications typically use reimplementations of this function to check
- whether the user's work has been saved and ask for permission before closing.
- For example, the \l{Application Example} uses a helper function to determine whether
- or not to close the window:
-
- \snippet mainwindows/application/mainwindow.cpp 3
- \snippet mainwindows/application/mainwindow.cpp 4
-
- \sa event(), hide(), close(), QCloseEvent, {Application Example}
-*/
-
-void QWidget::closeEvent(QCloseEvent *event)
-{
- event->accept();
-}
-
-#ifndef QT_NO_CONTEXTMENU
-/*!
- This event handler, for event \a event, can be reimplemented in a
- subclass to receive widget context menu events.
-
- The handler is called when the widget's \l contextMenuPolicy is
- Qt::DefaultContextMenu.
-
- The default implementation ignores the context event.
- See the \l QContextMenuEvent documentation for more details.
-
- \sa event(), QContextMenuEvent customContextMenuRequested()
-*/
-
-void QWidget::contextMenuEvent(QContextMenuEvent *event)
-{
- event->ignore();
-}
-#endif // QT_NO_CONTEXTMENU
-
-
-/*!
- This event handler, for event \a event, can be reimplemented in a
- subclass to receive Input Method composition events. This handler
- is called when the state of the input method changes.
-
- Note that when creating custom text editing widgets, the
- Qt::WA_InputMethodEnabled window attribute must be set explicitly
- (using the setAttribute() function) in order to receive input
- method events.
-
- The default implementation calls event->ignore(), which rejects the
- Input Method event. See the \l QInputMethodEvent documentation for more
- details.
-
- \sa event(), QInputMethodEvent
-*/
-void QWidget::inputMethodEvent(QInputMethodEvent *event)
-{
- event->ignore();
-}
-
-/*!
- This method is only relevant for input widgets. It is used by the
- input method to query a set of properties of the widget to be
- able to support complex input method operations as support for
- surrounding text and reconversions.
-
- \a query specifies which property is queried.
-
- \sa inputMethodEvent(), QInputMethodEvent, QInputContext, inputMethodHints
-*/
-QVariant QWidget::inputMethodQuery(Qt::InputMethodQuery query) const
-{
- switch(query) {
- case Qt::ImMicroFocus:
- return QRect(width()/2, 0, 1, height());
- case Qt::ImFont:
- return font();
- case Qt::ImAnchorPosition:
- // Fallback.
- return inputMethodQuery(Qt::ImCursorPosition);
- default:
- return QVariant();
- }
-}
-
-/*!
- \property QWidget::inputMethodHints
- \brief What input method specific hints the widget has.
-
- This is only relevant for input widgets. It is used by
- the input method to retrieve hints as to how the input method
- should operate. For example, if the Qt::ImhFormattedNumbersOnly flag
- is set, the input method may change its visual components to reflect
- that only numbers can be entered.
-
- \note The flags are only hints, so the particular input method
- implementation is free to ignore them. If you want to be
- sure that a certain type of characters are entered,
- you should also set a QValidator on the widget.
-
- The default value is Qt::ImhNone.
-
- \since 4.6
-
- \sa inputMethodQuery(), QInputContext
-*/
-Qt::InputMethodHints QWidget::inputMethodHints() const
-{
-#ifndef QT_NO_IM
- const QWidgetPrivate *priv = d_func();
- while (priv->inheritsInputMethodHints) {
- priv = priv->q_func()->parentWidget()->d_func();
- Q_ASSERT(priv);
- }
- return priv->imHints;
-#else //QT_NO_IM
- return 0;
-#endif //QT_NO_IM
-}
-
-void QWidget::setInputMethodHints(Qt::InputMethodHints hints)
-{
-#ifndef QT_NO_IM
- Q_D(QWidget);
- d->imHints = hints;
- // Optimization to update input context only it has already been created.
- if (d->ic || qApp->d_func()->inputContext) {
- QInputContext *ic = inputContext();
- if (ic)
- ic->update();
- }
-#endif //QT_NO_IM
-}
-
-
-#ifndef QT_NO_DRAGANDDROP
-
-/*!
- \fn void QWidget::dragEnterEvent(QDragEnterEvent *event)
-
- This event handler is called when a drag is in progress and the
- mouse enters this widget. The event is passed in the \a event parameter.
-
- If the event is ignored, the widget won't receive any \l{dragMoveEvent()}{drag
- move events}.
-
- See the \link dnd.html Drag-and-drop documentation\endlink for an
- overview of how to provide drag-and-drop in your application.
-
- \sa QDrag, QDragEnterEvent
-*/
-void QWidget::dragEnterEvent(QDragEnterEvent *)
-{
-}
-
-/*!
- \fn void QWidget::dragMoveEvent(QDragMoveEvent *event)
-
- This event handler is called if a drag is in progress, and when
- any of the following conditions occur: the cursor enters this widget,
- the cursor moves within this widget, or a modifier key is pressed on
- the keyboard while this widget has the focus. The event is passed
- in the \a event parameter.
-
- See the \link dnd.html Drag-and-drop documentation\endlink for an
- overview of how to provide drag-and-drop in your application.
-
- \sa QDrag, QDragMoveEvent
-*/
-void QWidget::dragMoveEvent(QDragMoveEvent *)
-{
-}
-
-/*!
- \fn void QWidget::dragLeaveEvent(QDragLeaveEvent *event)
-
- This event handler is called when a drag is in progress and the
- mouse leaves this widget. The event is passed in the \a event
- parameter.
-
- See the \link dnd.html Drag-and-drop documentation\endlink for an
- overview of how to provide drag-and-drop in your application.
-
- \sa QDrag, QDragLeaveEvent
-*/
-void QWidget::dragLeaveEvent(QDragLeaveEvent *)
-{
-}
-
-/*!
- \fn void QWidget::dropEvent(QDropEvent *event)
-
- This event handler is called when the drag is dropped on this
- widget. The event is passed in the \a event parameter.
-
- See the \link dnd.html Drag-and-drop documentation\endlink for an
- overview of how to provide drag-and-drop in your application.
-
- \sa QDrag, QDropEvent
-*/
-void QWidget::dropEvent(QDropEvent *)
-{
-}
-
-#endif // QT_NO_DRAGANDDROP
-
-/*!
- \fn void QWidget::showEvent(QShowEvent *event)
-
- This event handler can be reimplemented in a subclass to receive
- widget show events which are passed in the \a event parameter.
-
- Non-spontaneous show events are sent to widgets immediately
- before they are shown. The spontaneous show events of windows are
- delivered afterwards.
-
- Note: A widget receives spontaneous show and hide events when its
- mapping status is changed by the window system, e.g. a spontaneous
- hide event when the user minimizes the window, and a spontaneous
- show event when the window is restored again. After receiving a
- spontaneous hide event, a widget is still considered visible in
- the sense of isVisible().
-
- \sa visible, event(), QShowEvent
-*/
-void QWidget::showEvent(QShowEvent *)
-{
-}
-
-/*!
- \fn void QWidget::hideEvent(QHideEvent *event)
-
- This event handler can be reimplemented in a subclass to receive
- widget hide events. The event is passed in the \a event parameter.
-
- Hide events are sent to widgets immediately after they have been
- hidden.
-
- Note: A widget receives spontaneous show and hide events when its
- mapping status is changed by the window system, e.g. a spontaneous
- hide event when the user minimizes the window, and a spontaneous
- show event when the window is restored again. After receiving a
- spontaneous hide event, a widget is still considered visible in
- the sense of isVisible().
-
- \sa visible, event(), QHideEvent
-*/
-void QWidget::hideEvent(QHideEvent *)
-{
-}
-
-/*
- \fn QWidget::x11Event(MSG *)
-
- This special event handler can be reimplemented in a subclass to receive
- native X11 events.
-
- In your reimplementation of this function, if you want to stop Qt from
- handling the event, return true. If you return false, this native event
- is passed back to Qt, which translates it into a Qt event and sends it to
- the widget.
-
- \note Events are only delivered to this event handler if the widget is
- native.
-
- \warning This function is not portable.
-
- \sa QApplication::x11EventFilter(), QWidget::winId()
-*/
-
-
-#if defined(Q_WS_MAC)
-
-/*!
- \fn bool QWidget::macEvent(EventHandlerCallRef caller, EventRef event)
-
- This special event handler can be reimplemented in a subclass to
- receive native Macintosh events.
-
- The parameters are a bit different depending if Qt is build against Carbon
- or Cocoa. In Carbon, \a caller and \a event are the corresponding
- EventHandlerCallRef and EventRef that correspond to the Carbon event
- handlers that are installed. In Cocoa, \a caller is always 0 and the
- EventRef is the EventRef generated from the NSEvent.
-
- In your reimplementation of this function, if you want to stop the
- event being handled by Qt, return true. If you return false, this
- native event is passed back to Qt, which translates the event into
- a Qt event and sends it to the widget.
-
- \warning This function is not portable.
-
- \warning This function was not called inside of Qt until Qt 4.4.
- If you need compatibility with earlier versions of Qt, consider QApplication::macEventFilter() instead.
-
- \sa QApplication::macEventFilter()
-*/
-
-bool QWidget::macEvent(EventHandlerCallRef, EventRef)
-{
- return false;
-}
-
-#endif
-#if defined(Q_WS_WIN)
-
-/*!
- This special event handler can be reimplemented in a subclass to
- receive native Windows events which are passed in the \a message
- parameter.
-
- In your reimplementation of this function, if you want to stop the
- event being handled by Qt, return true and set \a result to the value
- that the window procedure should return. If you return false, this
- native event is passed back to Qt, which translates the event into
- a Qt event and sends it to the widget.
-
- \warning This function is not portable.
-
- \sa QApplication::winEventFilter()
-*/
-bool QWidget::winEvent(MSG *message, long *result)
-{
- Q_UNUSED(message);
- Q_UNUSED(result);
- return false;
-}
-
-#endif
-#if defined(Q_WS_X11)
-
-/*!
- \fn bool QWidget::x11Event(XEvent *event)
-
- This special event handler can be reimplemented in a subclass to receive
- native X11 events passed in the \a event parameter.
-
- In your reimplementation of this function, if you want to stop Qt from
- handling the event, return true. If you return false, this native event
- is passed back to Qt, which translates it into a Qt event and sends it to
- the widget.
-
- \note Events are only delivered to this event handler if the widget is
- native.
-
- \warning This function is not portable.
-
- \sa QApplication::x11EventFilter(), QWidget::winId()
-*/
-bool QWidget::x11Event(XEvent *)
-{
- return false;
-}
-
-#endif
-#if defined(Q_WS_QWS)
-
-/*!
- \fn bool QWidget::qwsEvent(QWSEvent *event)
-
- This special event handler can be reimplemented in a subclass to
- receive native Qt for Embedded Linux events which are passed in the
- \a event parameter.
-
- In your reimplementation of this function, if you want to stop the
- event being handled by Qt, return true. If you return false, this
- native event is passed back to Qt, which translates the event into
- a Qt event and sends it to the widget.
-
- \warning This function is not portable.
-
- \sa QApplication::qwsEventFilter()
-*/
-bool QWidget::qwsEvent(QWSEvent *)
-{
- return false;
-}
-
-#endif
-
-
-/*!
- Ensures that the widget has been polished by QStyle (i.e., has a
- proper font and palette).
-
- QWidget calls this function after it has been fully constructed
- but before it is shown the very first time. You can call this
- function if you want to ensure that the widget is polished before
- doing an operation, e.g., the correct font size might be needed in
- the widget's sizeHint() reimplementation. Note that this function
- \e is called from the default implementation of sizeHint().
-
- Polishing is useful for final initialization that must happen after
- all constructors (from base classes as well as from subclasses)
- have been called.
-
- If you need to change some settings when a widget is polished,
- reimplement event() and handle the QEvent::Polish event type.
-
- \bold{Note:} The function is declared const so that it can be called from
- other const functions (e.g., sizeHint()).
-
- \sa event()
-*/
-void QWidget::ensurePolished() const
-{
- Q_D(const QWidget);
-
- const QMetaObject *m = metaObject();
- if (m == d->polished)
- return;
- d->polished = m;
-
- QEvent e(QEvent::Polish);
- QCoreApplication::sendEvent(const_cast<QWidget *>(this), &e);
-
- // polish children after 'this'
- QList<QObject*> children = d->children;
- for (int i = 0; i < children.size(); ++i) {
- QObject *o = children.at(i);
- if(!o->isWidgetType())
- continue;
- if (QWidget *w = qobject_cast<QWidget *>(o))
- w->ensurePolished();
- }
-
- if (d->parent && d->sendChildEvents) {
- QChildEvent e(QEvent::ChildPolished, const_cast<QWidget *>(this));
- QCoreApplication::sendEvent(d->parent, &e);
- }
-}
-
-/*!
- Returns the mask currently set on a widget. If no mask is set the
- return value will be an empty region.
-
- \sa setMask(), clearMask(), QRegion::isEmpty(), {Shaped Clock Example}
-*/
-QRegion QWidget::mask() const
-{
- Q_D(const QWidget);
- return d->extra ? d->extra->mask : QRegion();
-}
-
-/*!
- Returns the layout manager that is installed on this widget, or 0
- if no layout manager is installed.
-
- The layout manager sets the geometry of the widget's children
- that have been added to the layout.
-
- \sa setLayout(), sizePolicy(), {Layout Management}
-*/
-QLayout *QWidget::layout() const
-{
- return d_func()->layout;
-}
-
-
-/*!
- \fn void QWidget::setLayout(QLayout *layout)
-
- Sets the layout manager for this widget to \a layout.
-
- If there already is a layout manager installed on this widget,
- QWidget won't let you install another. You must first delete the
- existing layout manager (returned by layout()) before you can
- call setLayout() with the new layout.
-
- If \a layout is the layout manger on a different widget, setLayout()
- will reparent the layout and make it the layout manager for this widget.
-
- Example:
-
- \snippet examples/uitools/textfinder/textfinder.cpp 3b
-
- An alternative to calling this function is to pass this widget to
- the layout's constructor.
-
- The QWidget will take ownership of \a layout.
-
- \sa layout(), {Layout Management}
-*/
-
-void QWidget::setLayout(QLayout *l)
-{
- if (!l) {
- qWarning("QWidget::setLayout: Cannot set layout to 0");
- return;
- }
- if (layout()) {
- if (layout() != l)
- qWarning("QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", which already has a"
- " layout", l->objectName().toLocal8Bit().data(), metaObject()->className(),
- objectName().toLocal8Bit().data());
- return;
- }
-
- QObject *oldParent = l->parent();
- if (oldParent && oldParent != this) {
- if (oldParent->isWidgetType()) {
- // Steal the layout off a widget parent. Takes effect when
- // morphing laid-out container widgets in Designer.
- QWidget *oldParentWidget = static_cast<QWidget *>(oldParent);
- oldParentWidget->takeLayout();
- } else {
- qWarning("QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", when the QLayout already has a parent",
- l->objectName().toLocal8Bit().data(), metaObject()->className(),
- objectName().toLocal8Bit().data());
- return;
- }
- }
-
- Q_D(QWidget);
- l->d_func()->topLevel = true;
- d->layout = l;
- if (oldParent != this) {
- l->setParent(this);
- l->d_func()->reparentChildWidgets(this);
- l->invalidate();
- }
-
- if (isWindow() && d->maybeTopData())
- d->topData()->sizeAdjusted = false;
-}
-
-/*!
- \fn QLayout *QWidget::takeLayout()
-
- Remove the layout from the widget.
- \since 4.5
-*/
-
-QLayout *QWidget::takeLayout()
-{
- Q_D(QWidget);
- QLayout *l = layout();
- if (!l)
- return 0;
- d->layout = 0;
- l->setParent(0);
- return l;
-}
-
-/*!
- \property QWidget::sizePolicy
- \brief the default layout behavior of the widget
-
- If there is a QLayout that manages this widget's children, the
- size policy specified by that layout is used. If there is no such
- QLayout, the result of this function is used.
-
- The default policy is Preferred/Preferred, which means that the
- widget can be freely resized, but prefers to be the size
- sizeHint() returns. Button-like widgets set the size policy to
- specify that they may stretch horizontally, but are fixed
- vertically. The same applies to lineedit controls (such as
- QLineEdit, QSpinBox or an editable QComboBox) and other
- horizontally orientated widgets (such as QProgressBar).
- QToolButton's are normally square, so they allow growth in both
- directions. Widgets that support different directions (such as
- QSlider, QScrollBar or QHeader) specify stretching in the
- respective direction only. Widgets that can provide scroll bars
- (usually subclasses of QScrollArea) tend to specify that they can
- use additional space, and that they can make do with less than
- sizeHint().
-
- \sa sizeHint() QLayout QSizePolicy updateGeometry()
-*/
-QSizePolicy QWidget::sizePolicy() const
-{
- Q_D(const QWidget);
- return d->size_policy;
-}
-
-void QWidget::setSizePolicy(QSizePolicy policy)
-{
- Q_D(QWidget);
- setAttribute(Qt::WA_WState_OwnSizePolicy);
- if (policy == d->size_policy)
- return;
- d->size_policy = policy;
-
-#ifndef QT_NO_GRAPHICSVIEW
- if (QWExtra *extra = d->extra) {
- if (extra->proxyWidget)
- extra->proxyWidget->setSizePolicy(policy);
- }
-#endif
-
- updateGeometry();
-
- if (isWindow() && d->maybeTopData())
- d->topData()->sizeAdjusted = false;
-}
-
-/*!
- \fn void QWidget::setSizePolicy(QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical)
- \overload
-
- Sets the size policy of the widget to \a horizontal and \a
- vertical, with standard stretch and no height-for-width.
-
- \sa QSizePolicy::QSizePolicy()
-*/
-
-/*!
- Returns the preferred height for this widget, given the width \a w.
-
- If this widget has a layout, the default implementation returns
- the layout's preferred height. if there is no layout, the default
- implementation returns -1 indicating that the preferred height
- does not depend on the width.
-*/
-
-int QWidget::heightForWidth(int w) const
-{
- if (layout() && layout()->hasHeightForWidth())
- return layout()->totalHeightForWidth(w);
- return -1;
-}
-
-
-/*!
- \internal
-
- *virtual private*
-
- This is a bit hackish, but ideally we would have created a virtual function
- in the public API (however, too late...) so that subclasses could reimplement
- their own function.
- Instead we add a virtual function to QWidgetPrivate.
- ### Qt5: move to public class and make virtual
-*/
-bool QWidgetPrivate::hasHeightForWidth() const
-{
- return layout ? layout->hasHeightForWidth() : size_policy.hasHeightForWidth();
-}
-
-/*!
- \fn QWidget *QWidget::childAt(int x, int y) const
-
- Returns the visible child widget at the position (\a{x}, \a{y})
- in the widget's coordinate system. If there is no visible child
- widget at the specified position, the function returns 0.
-*/
-
-/*!
- \overload
-
- Returns the visible child widget at point \a p in the widget's own
- coordinate system.
-*/
-
-QWidget *QWidget::childAt(const QPoint &p) const
-{
- return d_func()->childAt_helper(p, false);
-}
-
-QWidget *QWidgetPrivate::childAt_helper(const QPoint &p, bool ignoreChildrenInDestructor) const
-{
- if (children.isEmpty())
- return 0;
-
-#ifdef Q_WS_MAC
- Q_Q(const QWidget);
- // Unified tool bars on the Mac require special handling since they live outside
- // QMainWindow's geometry(). See commit: 35667fd45ada49269a5987c235fdedfc43e92bb8
- bool includeFrame = q->isWindow() && qobject_cast<const QMainWindow *>(q)
- && static_cast<const QMainWindow *>(q)->unifiedTitleAndToolBarOnMac();
- if (includeFrame)
- return childAtRecursiveHelper(p, ignoreChildrenInDestructor, includeFrame);
-#endif
-
- if (!pointInsideRectAndMask(p))
- return 0;
- return childAtRecursiveHelper(p, ignoreChildrenInDestructor);
-}
-
-QWidget *QWidgetPrivate::childAtRecursiveHelper(const QPoint &p, bool ignoreChildrenInDestructor, bool includeFrame) const
-{
-#ifndef Q_WS_MAC
- Q_UNUSED(includeFrame);
-#endif
- for (int i = children.size() - 1; i >= 0; --i) {
- QWidget *child = qobject_cast<QWidget *>(children.at(i));
- if (!child || child->isWindow() || child->isHidden() || child->testAttribute(Qt::WA_TransparentForMouseEvents)
- || (ignoreChildrenInDestructor && child->data->in_destructor)) {
- continue;
- }
-
- // Map the point 'p' from parent coordinates to child coordinates.
- QPoint childPoint = p;
-#ifdef Q_WS_MAC
- // 'includeFrame' is true if the child's parent is a top-level QMainWindow with an unified tool bar.
- // An unified tool bar on the Mac lives outside QMainWindow's geometry(), so a normal
- // QWidget::mapFromParent won't do the trick.
- if (includeFrame && qobject_cast<QToolBar *>(child))
- childPoint = qt_mac_nativeMapFromParent(child, p);
- else
-#endif
- childPoint -= child->data->crect.topLeft();
-
- // Check if the point hits the child.
- if (!child->d_func()->pointInsideRectAndMask(childPoint))
- continue;
-
- // Do the same for the child's descendants.
- if (QWidget *w = child->d_func()->childAtRecursiveHelper(childPoint, ignoreChildrenInDestructor))
- return w;
-
- // We have found our target; namely the child at position 'p'.
- return child;
- }
- return 0;
-}
-
-void QWidgetPrivate::updateGeometry_helper(bool forceUpdate)
-{
- Q_Q(QWidget);
- if (widgetItem)
- widgetItem->invalidateSizeCache();
- QWidget *parent;
- if (forceUpdate || !extra || extra->minw != extra->maxw || extra->minh != extra->maxh) {
- if (!q->isWindow() && !q->isHidden() && (parent = q->parentWidget())) {
- if (parent->d_func()->layout)
- parent->d_func()->layout->invalidate();
- else if (parent->isVisible())
- QApplication::postEvent(parent, new QEvent(QEvent::LayoutRequest));
- }
- }
-}
-
-/*!
- Notifies the layout system that this widget has changed and may
- need to change geometry.
-
- Call this function if the sizeHint() or sizePolicy() have changed.
-
- For explicitly hidden widgets, updateGeometry() is a no-op. The
- layout system will be notified as soon as the widget is shown.
-*/
-
-void QWidget::updateGeometry()
-{
- Q_D(QWidget);
- d->updateGeometry_helper(false);
-}
-
-/*! \property QWidget::windowFlags
-
- Window flags are a combination of a type (e.g. Qt::Dialog) and
- zero or more hints to the window system (e.g.
- Qt::FramelessWindowHint).
-
- If the widget had type Qt::Widget or Qt::SubWindow and becomes a
- window (Qt::Window, Qt::Dialog, etc.), it is put at position (0,
- 0) on the desktop. If the widget is a window and becomes a
- Qt::Widget or Qt::SubWindow, it is put at position (0, 0)
- relative to its parent widget.
-
- \note This function calls setParent() when changing the flags for
- a window, causing the widget to be hidden. You must call show() to make
- the widget visible again..
-
- \sa windowType(), {Window Flags Example}
-*/
-void QWidget::setWindowFlags(Qt::WindowFlags flags)
-{
- if (data->window_flags == flags)
- return;
-
- Q_D(QWidget);
-
- if ((data->window_flags | flags) & Qt::Window) {
- // the old type was a window and/or the new type is a window
- QPoint oldPos = pos();
- bool visible = isVisible();
- setParent(parentWidget(), flags);
-
- // if both types are windows or neither of them are, we restore
- // the old position
- if (!((data->window_flags ^ flags) & Qt::Window)
- && (visible || testAttribute(Qt::WA_Moved))) {
- move(oldPos);
- }
- // for backward-compatibility we change Qt::WA_QuitOnClose attribute value only when the window was recreated.
- d->adjustQuitOnCloseAttribute();
- } else {
- data->window_flags = flags;
- }
-}
-
-/*!
- Sets the window flags for the widget to \a flags,
- \e without telling the window system.
-
- \warning Do not call this function unless you really know what
- you're doing.
-
- \sa setWindowFlags()
-*/
-void QWidget::overrideWindowFlags(Qt::WindowFlags flags)
-{
- data->window_flags = flags;
-}
-
-/*!
- \fn Qt::WindowType QWidget::windowType() const
-
- Returns the window type of this widget. This is identical to
- windowFlags() & Qt::WindowType_Mask.
-
- \sa windowFlags
-*/
-
-/*!
- Sets the parent of the widget to \a parent, and resets the window
- flags. The widget is moved to position (0, 0) in its new parent.
-
- If the new parent widget is in a different window, the
- reparented widget and its children are appended to the end of the
- \l{setFocusPolicy()}{tab chain} of the new parent
- widget, in the same internal order as before. If one of the moved
- widgets had keyboard focus, setParent() calls clearFocus() for that
- widget.
-
- If the new parent widget is in the same window as the
- old parent, setting the parent doesn't change the tab order or
- keyboard focus.
-
- If the "new" parent widget is the old parent widget, this function
- does nothing.
-
- \note The widget becomes invisible as part of changing its parent,
- even if it was previously visible. You must call show() to make the
- widget visible again.
-
- \warning It is very unlikely that you will ever need this
- function. If you have a widget that changes its content
- dynamically, it is far easier to use \l QStackedWidget.
-
- \sa setWindowFlags()
-*/
-void QWidget::setParent(QWidget *parent)
-{
- if (parent == parentWidget())
- return;
- setParent((QWidget*)parent, windowFlags() & ~Qt::WindowType_Mask);
-}
-
-/*!
- \overload
-
- This function also takes widget flags, \a f as an argument.
-*/
-
-void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
-{
- Q_D(QWidget);
- bool resized = testAttribute(Qt::WA_Resized);
- bool wasCreated = testAttribute(Qt::WA_WState_Created);
- QWidget *oldtlw = window();
-
- QWidget *desktopWidget = 0;
- if (parent && parent->windowType() == Qt::Desktop)
- desktopWidget = parent;
- bool newParent = (parent != parentWidget()) || !wasCreated || desktopWidget;
-
-#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN)
- if (newParent && parent && !desktopWidget) {
- if (testAttribute(Qt::WA_NativeWindow) && !qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings)
-#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
- // On Mac, toolbars inside the unified title bar will never overlap with
- // siblings in the content view. So we skip enforce native siblings in that case
- && !d->isInUnifiedToolbar && parentWidget() && parentWidget()->isWindow()
-#endif // Q_WS_MAC && QT_MAC_USE_COCOA
- )
- parent->d_func()->enforceNativeChildren();
- else if (parent->d_func()->nativeChildrenForced() || parent->testAttribute(Qt::WA_PaintOnScreen))
- setAttribute(Qt::WA_NativeWindow);
- }
-#endif
-
- if (wasCreated) {
- if (!testAttribute(Qt::WA_WState_Hidden)) {
- hide();
- setAttribute(Qt::WA_WState_ExplicitShowHide, false);
- }
- if (newParent) {
- QEvent e(QEvent::ParentAboutToChange);
- QApplication::sendEvent(this, &e);
- }
- }
- if (newParent && isAncestorOf(focusWidget()))
- focusWidget()->clearFocus();
-
- QTLWExtra *oldTopExtra = window()->d_func()->maybeTopData();
- QWidgetBackingStoreTracker *oldBsTracker = oldTopExtra ? &oldTopExtra->backingStore : 0;
-
- d->setParent_sys(parent, f);
-
- QTLWExtra *topExtra = window()->d_func()->maybeTopData();
- QWidgetBackingStoreTracker *bsTracker = topExtra ? &topExtra->backingStore : 0;
- if (oldBsTracker && oldBsTracker != bsTracker)
- oldBsTracker->unregisterWidgetSubtree(this);
-
- if (desktopWidget)
- parent = 0;
-
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- QTLWExtra *extra = d->maybeTopData();
- QWindowSurface *windowSurface = (extra ? extra->windowSurface : 0);
- if (newParent && windowSurface) {
- QWidgetBackingStore *oldBs = oldtlw->d_func()->maybeBackingStore();
- if (oldBs)
- oldBs->subSurfaces.removeAll(windowSurface);
-
- if (parent) {
- QWidgetBackingStore *newBs = parent->d_func()->maybeBackingStore();
- if (newBs)
- newBs->subSurfaces.append(windowSurface);
- }
- }
-#endif
-
- if (QWidgetBackingStore *oldBs = oldtlw->d_func()->maybeBackingStore()) {
- if (newParent)
- oldBs->removeDirtyWidget(this);
- // Move the widget and all its static children from
- // the old backing store to the new one.
- oldBs->moveStaticWidgets(this);
- }
-
- if ((QApplicationPrivate::app_compile_version < 0x040200
- || QApplicationPrivate::testAttribute(Qt::AA_ImmediateWidgetCreation))
- && !testAttribute(Qt::WA_WState_Created))
- create();
-
- d->reparentFocusWidgets(oldtlw);
- setAttribute(Qt::WA_Resized, resized);
- if (!testAttribute(Qt::WA_StyleSheet)
- && (!parent || !parent->testAttribute(Qt::WA_StyleSheet))) {
- d->resolveFont();
- d->resolvePalette();
- }
- d->resolveLayoutDirection();
- d->resolveLocale();
-
- // Note: GL widgets under WGL or EGL will always need a ParentChange
- // event to handle recreation/rebinding of the GL context, hence the
- // (f & Qt::MSWindowsOwnDC) clause (which is set on QGLWidgets on all
- // platforms).
- if (newParent
-#if defined(Q_WS_WIN) || defined(QT_OPENGL_ES)
- || (f & Qt::MSWindowsOwnDC)
-#endif
- ) {
- // propagate enabled updates enabled state to non-windows
- if (!isWindow()) {
- if (!testAttribute(Qt::WA_ForceDisabled))
- d->setEnabled_helper(parent ? parent->isEnabled() : true);
- if (!testAttribute(Qt::WA_ForceUpdatesDisabled))
- d->setUpdatesEnabled_helper(parent ? parent->updatesEnabled() : true);
- }
- d->inheritStyle();
-
- // send and post remaining QObject events
- if (parent && d->sendChildEvents) {
- QChildEvent e(QEvent::ChildAdded, this);
- QApplication::sendEvent(parent, &e);
-#ifdef QT3_SUPPORT
- if (parent->d_func()->pendingChildInsertedEvents.isEmpty()) {
- QApplication::postEvent(parent,
- new QEvent(QEvent::ChildInsertedRequest),
- Qt::HighEventPriority);
- }
- parent->d_func()->pendingChildInsertedEvents.append(this);
-#endif
- }
-
-//### already hidden above ---> must probably do something smart on the mac
-// #ifdef Q_WS_MAC
-// extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp
-// if(!qt_mac_is_macdrawer(q)) //special case
-// q->setAttribute(Qt::WA_WState_Hidden);
-// #else
-// q->setAttribute(Qt::WA_WState_Hidden);
-//#endif
-
- if (parent && d->sendChildEvents && d->polished) {
- QChildEvent e(QEvent::ChildPolished, this);
- QCoreApplication::sendEvent(parent, &e);
- }
-
- QEvent e(QEvent::ParentChange);
- QApplication::sendEvent(this, &e);
- }
-
- if (!wasCreated) {
- if (isWindow() || parentWidget()->isVisible())
- setAttribute(Qt::WA_WState_Hidden, true);
- else if (!testAttribute(Qt::WA_WState_ExplicitShowHide))
- setAttribute(Qt::WA_WState_Hidden, false);
- }
-
- d->updateIsOpaque();
-
-#ifndef QT_NO_GRAPHICSVIEW
- // Embed the widget into a proxy if the parent is embedded.
- // ### Doesn't handle reparenting out of an embedded widget.
- if (oldtlw->graphicsProxyWidget()) {
- if (QGraphicsProxyWidget *ancestorProxy = d->nearestGraphicsProxyWidget(oldtlw))
- ancestorProxy->d_func()->unembedSubWindow(this);
- }
- if (isWindow() && parent && !graphicsProxyWidget() && !bypassGraphicsProxyWidget(this)) {
- if (QGraphicsProxyWidget *ancestorProxy = d->nearestGraphicsProxyWidget(parent))
- ancestorProxy->d_func()->embedSubWindow(this);
- }
-#endif
-}
-
-/*!
- Scrolls the widget including its children \a dx pixels to the
- right and \a dy downward. Both \a dx and \a dy may be negative.
-
- After scrolling, the widgets will receive paint events for
- the areas that need to be repainted. For widgets that Qt knows to
- be opaque, this is only the newly exposed parts.
- For example, if an opaque widget is scrolled 8 pixels to the left,
- only an 8-pixel wide stripe at the right edge needs updating.
-
- Since widgets propagate the contents of their parents by default,
- you need to set the \l autoFillBackground property, or use
- setAttribute() to set the Qt::WA_OpaquePaintEvent attribute, to make
- a widget opaque.
-
- For widgets that use contents propagation, a scroll will cause an
- update of the entire scroll area.
-
- \sa {Transparency and Double Buffering}
-*/
-
-void QWidget::scroll(int dx, int dy)
-{
- if ((!updatesEnabled() && children().size() == 0) || !isVisible())
- return;
- if (dx == 0 && dy == 0)
- return;
- Q_D(QWidget);
-#ifndef QT_NO_GRAPHICSVIEW
- if (QGraphicsProxyWidget *proxy = QWidgetPrivate::nearestGraphicsProxyWidget(this)) {
- // Graphics View maintains its own dirty region as a list of rects;
- // until we can connect item updates directly to the view, we must
- // separately add a translated dirty region.
- if (!d->dirty.isEmpty()) {
- foreach (const QRect &rect, (d->dirty.translated(dx, dy)).rects())
- proxy->update(rect);
- }
- proxy->scroll(dx, dy, proxy->subWidgetRect(this));
- return;
- }
-#endif
- d->setDirtyOpaqueRegion();
- d->scroll_sys(dx, dy);
-}
-
-/*!
- \overload
-
- This version only scrolls \a r and does not move the children of
- the widget.
-
- If \a r is empty or invalid, the result is undefined.
-
- \sa QScrollArea
-*/
-void QWidget::scroll(int dx, int dy, const QRect &r)
-{
-
- if ((!updatesEnabled() && children().size() == 0) || !isVisible())
- return;
- if (dx == 0 && dy == 0)
- return;
- Q_D(QWidget);
-#ifndef QT_NO_GRAPHICSVIEW
- if (QGraphicsProxyWidget *proxy = QWidgetPrivate::nearestGraphicsProxyWidget(this)) {
- // Graphics View maintains its own dirty region as a list of rects;
- // until we can connect item updates directly to the view, we must
- // separately add a translated dirty region.
- if (!d->dirty.isEmpty()) {
- foreach (const QRect &rect, (d->dirty.translated(dx, dy) & r).rects())
- proxy->update(rect);
- }
- proxy->scroll(dx, dy, r.translated(proxy->subWidgetRect(this).topLeft().toPoint()));
- return;
- }
-#endif
- d->scroll_sys(dx, dy, r);
-}
-
-/*!
- Repaints the widget directly by calling paintEvent() immediately,
- unless updates are disabled or the widget is hidden.
-
- We suggest only using repaint() if you need an immediate repaint,
- for example during animation. In almost all circumstances update()
- is better, as it permits Qt to optimize for speed and minimize
- flicker.
-
- \warning If you call repaint() in a function which may itself be
- called from paintEvent(), you may get infinite recursion. The
- update() function never causes recursion.
-
- \sa update(), paintEvent(), setUpdatesEnabled()
-*/
-
-void QWidget::repaint()
-{
- repaint(rect());
-}
-
-/*! \overload
-
- This version repaints a rectangle (\a x, \a y, \a w, \a h) inside
- the widget.
-
- If \a w is negative, it is replaced with \c{width() - x}, and if
- \a h is negative, it is replaced width \c{height() - y}.
-*/
-void QWidget::repaint(int x, int y, int w, int h)
-{
- if (x > data->crect.width() || y > data->crect.height())
- return;
-
- if (w < 0)
- w = data->crect.width() - x;
- if (h < 0)
- h = data->crect.height() - y;
-
- repaint(QRect(x, y, w, h));
-}
-
-/*! \overload
-
- This version repaints a rectangle \a rect inside the widget.
-*/
-void QWidget::repaint(const QRect &rect)
-{
- Q_D(QWidget);
-
- if (testAttribute(Qt::WA_WState_ConfigPending)) {
- update(rect);
- return;
- }
-
- if (!isVisible() || !updatesEnabled() || rect.isEmpty())
- return;
-
- if (hasBackingStoreSupport()) {
-#ifdef QT_MAC_USE_COCOA
- if (qt_widget_private(this)->isInUnifiedToolbar) {
- qt_widget_private(this)->unifiedSurface->renderToolbar(this, true);
- return;
- }
-#endif // QT_MAC_USE_COCOA
- QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
- if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
- tlwExtra->inRepaint = true;
- tlwExtra->backingStore->markDirty(rect, this, true);
- tlwExtra->inRepaint = false;
- }
- } else {
- d->repaint_sys(rect);
- }
-}
-
-/*!
- \overload
-
- This version repaints a region \a rgn inside the widget.
-*/
-void QWidget::repaint(const QRegion &rgn)
-{
- Q_D(QWidget);
-
- if (testAttribute(Qt::WA_WState_ConfigPending)) {
- update(rgn);
- return;
- }
-
- if (!isVisible() || !updatesEnabled() || rgn.isEmpty())
- return;
-
- if (hasBackingStoreSupport()) {
-#ifdef QT_MAC_USE_COCOA
- if (qt_widget_private(this)->isInUnifiedToolbar) {
- qt_widget_private(this)->unifiedSurface->renderToolbar(this, true);
- return;
- }
-#endif // QT_MAC_USE_COCOA
- QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
- if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
- tlwExtra->inRepaint = true;
- tlwExtra->backingStore->markDirty(rgn, this, true);
- tlwExtra->inRepaint = false;
- }
- } else {
- d->repaint_sys(rgn);
- }
-}
-
-/*!
- Updates the widget unless updates are disabled or the widget is
- hidden.
-
- This function does not cause an immediate repaint; instead it
- schedules a paint event for processing when Qt returns to the main
- event loop. This permits Qt to optimize for more speed and less
- flicker than a call to repaint() does.
-
- Calling update() several times normally results in just one
- paintEvent() call.
-
- Qt normally erases the widget's area before the paintEvent() call.
- If the Qt::WA_OpaquePaintEvent widget attribute is set, the widget is
- responsible for painting all its pixels with an opaque color.
-
- \sa repaint() paintEvent(), setUpdatesEnabled(), {Analog Clock Example}
-*/
-void QWidget::update()
-{
- update(rect());
-}
-
-/*! \fn void QWidget::update(int x, int y, int w, int h)
- \overload
-
- This version updates a rectangle (\a x, \a y, \a w, \a h) inside
- the widget.
-*/
-
-/*!
- \overload
-
- This version updates a rectangle \a rect inside the widget.
-*/
-void QWidget::update(const QRect &rect)
-{
- if (!isVisible() || !updatesEnabled() || rect.isEmpty())
- return;
-
- if (testAttribute(Qt::WA_WState_InPaintEvent)) {
- QApplication::postEvent(this, new QUpdateLaterEvent(rect));
- return;
- }
-
- if (hasBackingStoreSupport()) {
-#ifdef QT_MAC_USE_COCOA
- if (qt_widget_private(this)->isInUnifiedToolbar) {
- qt_widget_private(this)->unifiedSurface->renderToolbar(this, true);
- return;
- }
-#endif // QT_MAC_USE_COCOA
- QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
- if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore)
- tlwExtra->backingStore->markDirty(rect, this);
- } else {
- d_func()->repaint_sys(rect);
- }
-}
-
-/*!
- \overload
-
- This version repaints a region \a rgn inside the widget.
-*/
-void QWidget::update(const QRegion &rgn)
-{
- if (!isVisible() || !updatesEnabled() || rgn.isEmpty())
- return;
-
- if (testAttribute(Qt::WA_WState_InPaintEvent)) {
- QApplication::postEvent(this, new QUpdateLaterEvent(rgn));
- return;
- }
-
- if (hasBackingStoreSupport()) {
-#ifdef QT_MAC_USE_COCOA
- if (qt_widget_private(this)->isInUnifiedToolbar) {
- qt_widget_private(this)->unifiedSurface->renderToolbar(this, true);
- return;
- }
-#endif // QT_MAC_USE_COCOA
- QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
- if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore)
- tlwExtra->backingStore->markDirty(rgn, this);
- } else {
- d_func()->repaint_sys(rgn);
- }
-}
-
-#ifdef QT3_SUPPORT
-/*!
- Clear the rectangle at point (\a x, \a y) of width \a w and height
- \a h.
-
- \warning This is best done in a paintEvent().
-*/
-void QWidget::erase_helper(int x, int y, int w, int h)
-{
- if (testAttribute(Qt::WA_NoSystemBackground) || testAttribute(Qt::WA_UpdatesDisabled) || !testAttribute(Qt::WA_WState_Visible))
- return;
- if (w < 0)
- w = data->crect.width() - x;
- if (h < 0)
- h = data->crect.height() - y;
- if (w != 0 && h != 0) {
- QPainter p(this);
- p.eraseRect(QRect(x, y, w, h));
- }
-}
-
-/*!
- \overload
-
- Clear the given region, \a rgn.
-
- Drawing may only take place in a QPaintEvent. Overload
- paintEvent() to do your erasing and call update() to schedule a
- replaint whenever necessary. See also QPainter.
-*/
-void QWidget::erase(const QRegion& rgn)
-{
- if (testAttribute(Qt::WA_NoSystemBackground) || testAttribute(Qt::WA_UpdatesDisabled) || !testAttribute(Qt::WA_WState_Visible))
- return;
-
- QPainter p(this);
- p.setClipRegion(rgn);
- p.eraseRect(rgn.boundingRect());
-}
-
-void QWidget::drawText_helper(int x, int y, const QString &str)
-{
- if(!testAttribute(Qt::WA_WState_Visible))
- return;
- QPainter paint(this);
- paint.drawText(x, y, str);
-}
-
-
-/*!
- Closes the widget.
-
- Use the no-argument overload instead.
-*/
-bool QWidget::close(bool alsoDelete)
-{
- QPointer<QWidget> that = this;
- bool accepted = close();
- if (alsoDelete && accepted && that)
- deleteLater();
- return accepted;
-}
-
-void QWidget::setIcon(const QPixmap &i)
-{
- setWindowIcon(i);
-}
-
-/*!
- Return's the widget's icon.
-
- Use windowIcon() instead.
-*/
-const QPixmap *QWidget::icon() const
-{
- Q_D(const QWidget);
- return (d->extra && d->extra->topextra) ? d->extra->topextra->iconPixmap : 0;
-}
-
-#endif // QT3_SUPPORT
-
- /*!
- \internal
-
- This just sets the corresponding attribute bit to 1 or 0
- */
-static void setAttribute_internal(Qt::WidgetAttribute attribute, bool on, QWidgetData *data,
- QWidgetPrivate *d)
-{
- if (attribute < int(8*sizeof(uint))) {
- if (on)
- data->widget_attributes |= (1<<attribute);
- else
- data->widget_attributes &= ~(1<<attribute);
- } else {
- const int x = attribute - 8*sizeof(uint);
- const int int_off = x / (8*sizeof(uint));
- if (on)
- d->high_attributes[int_off] |= (1<<(x-(int_off*8*sizeof(uint))));
- else
- d->high_attributes[int_off] &= ~(1<<(x-(int_off*8*sizeof(uint))));
- }
-}
-
-/*!
- Sets the attribute \a attribute on this widget if \a on is true;
- otherwise clears the attribute.
-
- \sa testAttribute()
-*/
-void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
-{
- if (testAttribute(attribute) == on)
- return;
-
- Q_D(QWidget);
- Q_ASSERT_X(sizeof(d->high_attributes)*8 >= (Qt::WA_AttributeCount - sizeof(uint)*8),
- "QWidget::setAttribute(WidgetAttribute, bool)",
- "QWidgetPrivate::high_attributes[] too small to contain all attributes in WidgetAttribute");
-#ifdef Q_WS_WIN
- // ### Don't use PaintOnScreen+paintEngine() to do native painting in 5.0
- if (attribute == Qt::WA_PaintOnScreen && on && !inherits("QGLWidget")) {
- // see qwidget_win.cpp, ::paintEngine for details
- paintEngine();
- if (d->noPaintOnScreen)
- return;
- }
-#endif
-
- setAttribute_internal(attribute, on, data, d);
-
- switch (attribute) {
-
-#ifndef QT_NO_DRAGANDDROP
- case Qt::WA_AcceptDrops: {
- if (on && !testAttribute(Qt::WA_DropSiteRegistered))
- setAttribute(Qt::WA_DropSiteRegistered, true);
- else if (!on && (isWindow() || !parentWidget() || !parentWidget()->testAttribute(Qt::WA_DropSiteRegistered)))
- setAttribute(Qt::WA_DropSiteRegistered, false);
- QEvent e(QEvent::AcceptDropsChange);
- QApplication::sendEvent(this, &e);
- break;
- }
- case Qt::WA_DropSiteRegistered: {
- d->registerDropSite(on);
- for (int i = 0; i < d->children.size(); ++i) {
- QWidget *w = qobject_cast<QWidget *>(d->children.at(i));
- if (w && !w->isWindow() && !w->testAttribute(Qt::WA_AcceptDrops) && w->testAttribute(Qt::WA_DropSiteRegistered) != on)
- w->setAttribute(Qt::WA_DropSiteRegistered, on);
- }
- break;
- }
-#endif
-
- case Qt::WA_NoChildEventsForParent:
- d->sendChildEvents = !on;
- break;
- case Qt::WA_NoChildEventsFromChildren:
- d->receiveChildEvents = !on;
- break;
- case Qt::WA_MacBrushedMetal:
-#ifdef Q_WS_MAC
- d->setStyle_helper(style(), false, true); // Make sure things get unpolished/polished correctly.
- // fall through since changing the metal attribute affects the opaque size grip.
- case Qt::WA_MacOpaqueSizeGrip:
- d->macUpdateOpaqueSizeGrip();
- break;
- case Qt::WA_MacShowFocusRect:
- if (hasFocus()) {
- clearFocus();
- setFocus();
- }
- break;
- case Qt::WA_Hover:
- qt_mac_update_mouseTracking(this);
- break;
-#endif
- case Qt::WA_MacAlwaysShowToolWindow:
-#ifdef Q_WS_MAC
- d->macUpdateHideOnSuspend();
-#endif
- break;
- case Qt::WA_MacNormalSize:
- case Qt::WA_MacSmallSize:
- case Qt::WA_MacMiniSize:
-#ifdef Q_WS_MAC
- {
- // We can only have one of these set at a time
- const Qt::WidgetAttribute MacSizes[] = { Qt::WA_MacNormalSize, Qt::WA_MacSmallSize,
- Qt::WA_MacMiniSize };
- for (int i = 0; i < 3; ++i) {
- if (MacSizes[i] != attribute)
- setAttribute_internal(MacSizes[i], false, data, d);
- }
- d->macUpdateSizeAttribute();
- }
-#endif
- break;
- case Qt::WA_ShowModal:
- if (!on) {
- if (isVisible())
- QApplicationPrivate::leaveModal(this);
- // reset modality type to Modeless when clearing WA_ShowModal
- data->window_modality = Qt::NonModal;
- } else if (data->window_modality == Qt::NonModal) {
- // determine the modality type if it hasn't been set prior
- // to setting WA_ShowModal. set the default to WindowModal
- // if we are the child of a group leader; otherwise use
- // ApplicationModal.
- QWidget *w = parentWidget();
- if (w)
- w = w->window();
- while (w && !w->testAttribute(Qt::WA_GroupLeader)) {
- w = w->parentWidget();
- if (w)
- w = w->window();
- }
- data->window_modality = (w && w->testAttribute(Qt::WA_GroupLeader))
- ? Qt::WindowModal
- : Qt::ApplicationModal;
- // Some window managers does not allow us to enter modal after the
- // window is showing. Therefore, to be consistent, we cannot call
- // QApplicationPrivate::enterModal(this) here. The window must be
- // hidden before changing modality.
- }
- if (testAttribute(Qt::WA_WState_Created)) {
- // don't call setModal_sys() before create_sys()
- d->setModal_sys();
- }
- break;
- case Qt::WA_MouseTracking: {
- QEvent e(QEvent::MouseTrackingChange);
- QApplication::sendEvent(this, &e);
- break; }
- case Qt::WA_NativeWindow: {
-#ifndef QT_NO_IM
- QWidget *focusWidget = d->effectiveFocusWidget();
- QInputContext *ic = 0;
- if (on && !internalWinId() && hasFocus()
- && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
- ic = focusWidget->d_func()->inputContext();
- if (ic) {
- ic->reset();
- ic->setFocusWidget(0);
- }
- }
- if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget()
-#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
- // On Mac, toolbars inside the unified title bar will never overlap with
- // siblings in the content view. So we skip enforce native siblings in that case
- && !d->isInUnifiedToolbar && parentWidget()->isWindow()
-#endif // Q_WS_MAC && QT_MAC_USE_COCOA
- )
- parentWidget()->d_func()->enforceNativeChildren();
- if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created))
- d->createWinId();
- if (ic && isEnabled() && focusWidget->isEnabled()
- && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
- ic->setFocusWidget(focusWidget);
- }
-#endif //QT_NO_IM
- break;
- }
- case Qt::WA_PaintOnScreen:
- d->updateIsOpaque();
-#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN)
- // Recreate the widget if it's already created as an alien widget and
- // WA_PaintOnScreen is enabled. Paint on screen widgets must have win id.
- // So must their children.
- if (on) {
- setAttribute(Qt::WA_NativeWindow);
- d->enforceNativeChildren();
- }
-#endif
- // fall through
- case Qt::WA_OpaquePaintEvent:
- d->updateIsOpaque();
- break;
- case Qt::WA_NoSystemBackground:
- d->updateIsOpaque();
- // fall through...
- case Qt::WA_UpdatesDisabled:
- d->updateSystemBackground();
- break;
- case Qt::WA_TransparentForMouseEvents:
-#ifdef Q_WS_MAC
- d->macUpdateIgnoreMouseEvents();
-#endif
- break;
- case Qt::WA_InputMethodEnabled: {
-#ifndef QT_NO_IM
- QWidget *focusWidget = d->effectiveFocusWidget();
- QInputContext *ic = focusWidget->d_func()->assignedInputContext();
- if (!ic && (!on || hasFocus()))
- ic = focusWidget->d_func()->inputContext();
- if (ic) {
- if (on && hasFocus() && ic->focusWidget() != focusWidget && isEnabled()
- && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
- ic->setFocusWidget(focusWidget);
- } else if (!on && ic->focusWidget() == focusWidget) {
- ic->reset();
- ic->setFocusWidget(0);
- }
- }
-#endif //QT_NO_IM
- break;
- }
- case Qt::WA_WindowPropagation:
- d->resolvePalette();
- d->resolveFont();
- d->resolveLocale();
- break;
-#ifdef Q_WS_X11
- case Qt::WA_NoX11EventCompression:
- if (!d->extra)
- d->createExtra();
- d->extra->compress_events = on;
- break;
- case Qt::WA_X11OpenGLOverlay:
- d->updateIsOpaque();
- break;
- case Qt::WA_X11DoNotAcceptFocus:
- if (testAttribute(Qt::WA_WState_Created))
- d->updateX11AcceptFocus();
- break;
-#endif
- case Qt::WA_DontShowOnScreen: {
- if (on && isVisible()) {
- // Make sure we keep the current state and only hide the widget
- // from the desktop. show_sys will only update platform specific
- // attributes at this point.
- d->hide_sys();
-#ifdef Q_WS_QWS
- // Release the region for this window from qws if the widget has
- // been shown before the attribute was set.
- if (QWSWindowSurface *surface = static_cast<QWSWindowSurface *>(windowSurface())) {
- QWidget::qwsDisplay()->requestRegion(surface->winId(), surface->key(),
- surface->permanentState(), QRegion());
- }
-#endif
- d->show_sys();
- }
- break;
- }
-
-#ifdef Q_WS_X11
- case Qt::WA_X11NetWmWindowTypeDesktop:
- case Qt::WA_X11NetWmWindowTypeDock:
- case Qt::WA_X11NetWmWindowTypeToolBar:
- case Qt::WA_X11NetWmWindowTypeMenu:
- case Qt::WA_X11NetWmWindowTypeUtility:
- case Qt::WA_X11NetWmWindowTypeSplash:
- case Qt::WA_X11NetWmWindowTypeDialog:
- case Qt::WA_X11NetWmWindowTypeDropDownMenu:
- case Qt::WA_X11NetWmWindowTypePopupMenu:
- case Qt::WA_X11NetWmWindowTypeToolTip:
- case Qt::WA_X11NetWmWindowTypeNotification:
- case Qt::WA_X11NetWmWindowTypeCombo:
- case Qt::WA_X11NetWmWindowTypeDND:
- if (testAttribute(Qt::WA_WState_Created))
- d->setNetWmWindowTypes();
- break;
-#endif
-
- case Qt::WA_StaticContents:
- if (QWidgetBackingStore *bs = d->maybeBackingStore()) {
- if (on)
- bs->addStaticWidget(this);
- else
- bs->removeStaticWidget(this);
- }
- break;
- case Qt::WA_TranslucentBackground:
- if (on) {
- setAttribute(Qt::WA_NoSystemBackground);
- d->updateIsTranslucent();
- }
-
- break;
- case Qt::WA_AcceptTouchEvents:
-#if defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN)
- if (on)
- d->registerTouchWindow();
-#endif
- break;
- case Qt::WA_LockPortraitOrientation:
- case Qt::WA_LockLandscapeOrientation:
- case Qt::WA_AutoOrientation: {
- const Qt::WidgetAttribute orientations[3] = {
- Qt::WA_LockPortraitOrientation,
- Qt::WA_LockLandscapeOrientation,
- Qt::WA_AutoOrientation
- };
-
- if (on) {
- // We can only have one of these set at a time
- for (int i = 0; i < 3; ++i) {
- if (orientations[i] != attribute)
- setAttribute_internal(orientations[i], false, data, d);
- }
- }
-
-#ifdef Q_WS_S60
- CAknAppUiBase* appUi = static_cast<CAknAppUiBase*>(CEikonEnv::Static()->EikAppUi());
- const CAknAppUiBase::TAppUiOrientation s60orientations[] = {
- CAknAppUiBase::EAppUiOrientationPortrait,
- CAknAppUiBase::EAppUiOrientationLandscape,
- CAknAppUiBase::EAppUiOrientationAutomatic
- };
- CAknAppUiBase::TAppUiOrientation s60orientation = CAknAppUiBase::EAppUiOrientationUnspecified;
- for (int i = 0; i < 3; ++i) {
- if (testAttribute(orientations[i])) {
- s60orientation = s60orientations[i];
- break;
- }
- }
- QT_TRAP_THROWING(appUi->SetOrientationL(s60orientation));
- S60->orientationSet = true;
- QSymbianControl *window = static_cast<QSymbianControl *>(internalWinId());
- if (window)
- window->ensureFixNativeOrientation();
-#endif
- break;
- }
- default:
- break;
- }
-}
-
-/*! \fn bool QWidget::testAttribute(Qt::WidgetAttribute attribute) const
-
- Returns true if attribute \a attribute is set on this widget;
- otherwise returns false.
-
- \sa setAttribute()
- */
-bool QWidget::testAttribute_helper(Qt::WidgetAttribute attribute) const
-{
- Q_D(const QWidget);
- const int x = attribute - 8*sizeof(uint);
- const int int_off = x / (8*sizeof(uint));
- return (d->high_attributes[int_off] & (1<<(x-(int_off*8*sizeof(uint)))));
-}
-
-/*!
- \property QWidget::windowOpacity
-
- \brief The level of opacity for the window.
-
- The valid range of opacity is from 1.0 (completely opaque) to
- 0.0 (completely transparent).
-
- By default the value of this property is 1.0.
-
- This feature is available on Embedded Linux, Mac OS X, Windows,
- and X11 platforms that support the Composite extension.
-
- This feature is not available on Windows CE.
-
- Note that under X11 you need to have a composite manager running,
- and the X11 specific _NET_WM_WINDOW_OPACITY atom needs to be
- supported by the window manager you are using.
-
- \warning Changing this property from opaque to transparent might issue a
- paint event that needs to be processed before the window is displayed
- correctly. This affects mainly the use of QPixmap::grabWindow(). Also note
- that semi-transparent windows update and resize significantly slower than
- opaque windows.
-
- \sa setMask()
-*/
-qreal QWidget::windowOpacity() const
-{
- Q_D(const QWidget);
- return (isWindow() && d->maybeTopData()) ? d->maybeTopData()->opacity / 255. : 1.0;
-}
-
-void QWidget::setWindowOpacity(qreal opacity)
-{
- Q_D(QWidget);
- if (!isWindow())
- return;
-
- opacity = qBound(qreal(0.0), opacity, qreal(1.0));
- QTLWExtra *extra = d->topData();
- extra->opacity = uint(opacity * 255);
- setAttribute(Qt::WA_WState_WindowOpacitySet);
-
-#ifndef Q_WS_QWS
- if (!testAttribute(Qt::WA_WState_Created))
- return;
-#endif
-
-#ifndef QT_NO_GRAPHICSVIEW
- if (QGraphicsProxyWidget *proxy = graphicsProxyWidget()) {
- // Avoid invalidating the cache if set.
- if (proxy->cacheMode() == QGraphicsItem::NoCache)
- proxy->update();
- else if (QGraphicsScene *scene = proxy->scene())
- scene->update(proxy->sceneBoundingRect());
- return;
- }
-#endif
-
- d->setWindowOpacity_sys(opacity);
-}
-
-/*!
- \property QWidget::windowModified
- \brief whether the document shown in the window has unsaved changes
-
- A modified window is a window whose content has changed but has
- not been saved to disk. This flag will have different effects
- varied by the platform. On Mac OS X the close button will have a
- modified look; on other platforms, the window title will have an
- '*' (asterisk).
-
- The window title must contain a "[*]" placeholder, which
- indicates where the '*' should appear. Normally, it should appear
- right after the file name (e.g., "document1.txt[*] - Text
- Editor"). If the window isn't modified, the placeholder is simply
- removed.
-
- Note that if a widget is set as modified, all its ancestors will
- also be set as modified. However, if you call \c
- {setWindowModified(false)} on a widget, this will not propagate to
- its parent because other children of the parent might have been
- modified.
-
- \sa windowTitle, {Application Example}, {SDI Example}, {MDI Example}
-*/
-bool QWidget::isWindowModified() const
-{
- return testAttribute(Qt::WA_WindowModified);
-}
-
-void QWidget::setWindowModified(bool mod)
-{
- Q_D(QWidget);
- setAttribute(Qt::WA_WindowModified, mod);
-
-#ifndef Q_WS_MAC
- if (!windowTitle().contains(QLatin1String("[*]")) && mod)
- qWarning("QWidget::setWindowModified: The window title does not contain a '[*]' placeholder");
-#endif
- d->setWindowTitle_helper(windowTitle());
- d->setWindowIconText_helper(windowIconText());
-#ifdef Q_WS_MAC
- d->setWindowModified_sys(mod);
-#endif
-
- QEvent e(QEvent::ModifiedChange);
- QApplication::sendEvent(this, &e);
-}
-
-#ifndef QT_NO_TOOLTIP
-/*!
- \property QWidget::toolTip
-
- \brief the widget's tooltip
-
- Note that by default tooltips are only shown for widgets that are
- children of the active window. You can change this behavior by
- setting the attribute Qt::WA_AlwaysShowToolTips on the \e window,
- not on the widget with the tooltip.
-
- If you want to control a tooltip's behavior, you can intercept the
- event() function and catch the QEvent::ToolTip event (e.g., if you
- want to customize the area for which the tooltip should be shown).
-
- By default, this property contains an empty string.
-
- \sa QToolTip statusTip whatsThis
-*/
-void QWidget::setToolTip(const QString &s)
-{
- Q_D(QWidget);
- d->toolTip = s;
-
- QEvent event(QEvent::ToolTipChange);
- QApplication::sendEvent(this, &event);
-}
-
-QString QWidget::toolTip() const
-{
- Q_D(const QWidget);
- return d->toolTip;
-}
-#endif // QT_NO_TOOLTIP
-
-
-#ifndef QT_NO_STATUSTIP
-/*!
- \property QWidget::statusTip
- \brief the widget's status tip
-
- By default, this property contains an empty string.
-
- \sa toolTip whatsThis
-*/
-void QWidget::setStatusTip(const QString &s)
-{
- Q_D(QWidget);
- d->statusTip = s;
-}
-
-QString QWidget::statusTip() const
-{
- Q_D(const QWidget);
- return d->statusTip;
-}
-#endif // QT_NO_STATUSTIP
-
-#ifndef QT_NO_WHATSTHIS
-/*!
- \property QWidget::whatsThis
-
- \brief the widget's What's This help text.
-
- By default, this property contains an empty string.
-
- \sa QWhatsThis QWidget::toolTip QWidget::statusTip
-*/
-void QWidget::setWhatsThis(const QString &s)
-{
- Q_D(QWidget);
- d->whatsThis = s;
-}
-
-QString QWidget::whatsThis() const
-{
- Q_D(const QWidget);
- return d->whatsThis;
-}
-#endif // QT_NO_WHATSTHIS
-
-#ifndef QT_NO_ACCESSIBILITY
-/*!
- \property QWidget::accessibleName
-
- \brief the widget's name as seen by assistive technologies
-
- This property is used by accessible clients to identify, find, or announce
- the widget for accessible clients.
-
- By default, this property contains an empty string.
-
- \sa QAccessibleInterface::text()
-*/
-void QWidget::setAccessibleName(const QString &name)
-{
- Q_D(QWidget);
- d->accessibleName = name;
- QAccessible::updateAccessibility(this, 0, QAccessible::NameChanged);
-}
-
-QString QWidget::accessibleName() const
-{
- Q_D(const QWidget);
- return d->accessibleName;
-}
-
-/*!
- \property QWidget::accessibleDescription
-
- \brief the widget's description as seen by assistive technologies
-
- By default, this property contains an empty string.
-
- \sa QAccessibleInterface::text()
-*/
-void QWidget::setAccessibleDescription(const QString &description)
-{
- Q_D(QWidget);
- d->accessibleDescription = description;
- QAccessible::updateAccessibility(this, 0, QAccessible::DescriptionChanged);
-}
-
-QString QWidget::accessibleDescription() const
-{
- Q_D(const QWidget);
- return d->accessibleDescription;
-}
-#endif // QT_NO_ACCESSIBILITY
-
-#ifndef QT_NO_SHORTCUT
-/*!
- Adds a shortcut to Qt's shortcut system that watches for the given
- \a key sequence in the given \a context. If the \a context is
- Qt::ApplicationShortcut, the shortcut applies to the application as a
- whole. Otherwise, it is either local to this widget, Qt::WidgetShortcut,
- or to the window itself, Qt::WindowShortcut.
-
- If the same \a key sequence has been grabbed by several widgets,
- when the \a key sequence occurs a QEvent::Shortcut event is sent
- to all the widgets to which it applies in a non-deterministic
- order, but with the ``ambiguous'' flag set to true.
-
- \warning You should not normally need to use this function;
- instead create \l{QAction}s with the shortcut key sequences you
- require (if you also want equivalent menu options and toolbar
- buttons), or create \l{QShortcut}s if you just need key sequences.
- Both QAction and QShortcut handle all the event filtering for you,
- and provide signals which are triggered when the user triggers the
- key sequence, so are much easier to use than this low-level
- function.
-
- \sa releaseShortcut() setShortcutEnabled()
-*/
-int QWidget::grabShortcut(const QKeySequence &key, Qt::ShortcutContext context)
-{
- Q_ASSERT(qApp);
- if (key.isEmpty())
- return 0;
- setAttribute(Qt::WA_GrabbedShortcut);
- return qApp->d_func()->shortcutMap.addShortcut(this, key, context);
-}
-
-/*!
- Removes the shortcut with the given \a id from Qt's shortcut
- system. The widget will no longer receive QEvent::Shortcut events
- for the shortcut's key sequence (unless it has other shortcuts
- with the same key sequence).
-
- \warning You should not normally need to use this function since
- Qt's shortcut system removes shortcuts automatically when their
- parent widget is destroyed. It is best to use QAction or
- QShortcut to handle shortcuts, since they are easier to use than
- this low-level function. Note also that this is an expensive
- operation.
-
- \sa grabShortcut() setShortcutEnabled()
-*/
-void QWidget::releaseShortcut(int id)
-{
- Q_ASSERT(qApp);
- if (id)
- qApp->d_func()->shortcutMap.removeShortcut(id, this, 0);
-}
-
-/*!
- If \a enable is true, the shortcut with the given \a id is
- enabled; otherwise the shortcut is disabled.
-
- \warning You should not normally need to use this function since
- Qt's shortcut system enables/disables shortcuts automatically as
- widgets become hidden/visible and gain or lose focus. It is best
- to use QAction or QShortcut to handle shortcuts, since they are
- easier to use than this low-level function.
-
- \sa grabShortcut() releaseShortcut()
-*/
-void QWidget::setShortcutEnabled(int id, bool enable)
-{
- Q_ASSERT(qApp);
- if (id)
- qApp->d_func()->shortcutMap.setShortcutEnabled(enable, id, this, 0);
-}
-
-/*!
- \since 4.2
-
- If \a enable is true, auto repeat of the shortcut with the
- given \a id is enabled; otherwise it is disabled.
-
- \sa grabShortcut() releaseShortcut()
-*/
-void QWidget::setShortcutAutoRepeat(int id, bool enable)
-{
- Q_ASSERT(qApp);
- if (id)
- qApp->d_func()->shortcutMap.setShortcutAutoRepeat(enable, id, this, 0);
-}
-#endif // QT_NO_SHORTCUT
-/*!
- Updates the widget's micro focus.
-
- \sa QInputContext
-*/
-void QWidget::updateMicroFocus()
-{
-#if !defined(QT_NO_IM) && (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN))
- Q_D(QWidget);
- // and optimization to update input context only it has already been created.
- if (d->assignedInputContext() || qApp->d_func()->inputContext) {
- QInputContext *ic = inputContext();
- if (ic)
- ic->update();
- }
-#endif
-#ifndef QT_NO_ACCESSIBILITY
- if (isVisible()) {
- // ##### is this correct
- QAccessible::updateAccessibility(this, 0, QAccessible::StateChanged);
- }
-#endif
-}
-
-
-#if defined (Q_WS_WIN)
-/*!
- Returns the window system handle of the widget, for low-level
- access. Using this function is not portable.
-
- An HDC acquired with getDC() has to be released with releaseDC().
-
- \warning Using this function is not portable.
-*/
-HDC QWidget::getDC() const
-{
- Q_D(const QWidget);
- if (d->hd)
- return (HDC) d->hd;
- return GetDC(winId());
-}
-
-/*!
- Releases the HDC \a hdc acquired by a previous call to getDC().
-
- \warning Using this function is not portable.
-*/
-void QWidget::releaseDC(HDC hdc) const
-{
- Q_D(const QWidget);
- // If its the widgets own dc, it will be released elsewhere. If
- // its a different HDC we release it and issue a warning if it
- // fails.
- if (hdc != d->hd && !ReleaseDC(winId(), hdc))
- qErrnoWarning("QWidget::releaseDC(): failed to release HDC");
-}
-#else
-/*!
- Returns the window system handle of the widget, for low-level
- access. Using this function is not portable.
-
- The HANDLE type varies with platform; see \c qwindowdefs.h for
- details.
-*/
-Qt::HANDLE QWidget::handle() const
-{
- Q_D(const QWidget);
- if (!internalWinId() && testAttribute(Qt::WA_WState_Created))
- (void)winId(); // enforce native window
- return d->hd;
-}
-#endif
-
-
-/*!
- Raises this widget to the top of the parent widget's stack.
-
- After this call the widget will be visually in front of any
- overlapping sibling widgets.
-
- \note When using activateWindow(), you can call this function to
- ensure that the window is stacked on top.
-
- \sa lower(), stackUnder()
-*/
-
-void QWidget::raise()
-{
- Q_D(QWidget);
- if (!isWindow()) {
- QWidget *p = parentWidget();
- const int parentChildCount = p->d_func()->children.size();
- if (parentChildCount < 2)
- return;
- const int from = p->d_func()->children.indexOf(this);
- Q_ASSERT(from >= 0);
- // Do nothing if the widget is already in correct stacking order _and_ created.
- if (from != parentChildCount -1)
- p->d_func()->children.move(from, parentChildCount - 1);
- if (!testAttribute(Qt::WA_WState_Created) && p->testAttribute(Qt::WA_WState_Created))
- create();
- else if (from == parentChildCount - 1)
- return;
-
- QRegion region(rect());
- d->subtractOpaqueSiblings(region);
- d->invalidateBuffer(region);
- }
- if (testAttribute(Qt::WA_WState_Created))
- d->raise_sys();
-
- QEvent e(QEvent::ZOrderChange);
- QApplication::sendEvent(this, &e);
-}
-
-/*!
- Lowers the widget to the bottom of the parent widget's stack.
-
- After this call the widget will be visually behind (and therefore
- obscured by) any overlapping sibling widgets.
-
- \sa raise(), stackUnder()
-*/
-
-void QWidget::lower()
-{
- Q_D(QWidget);
- if (!isWindow()) {
- QWidget *p = parentWidget();
- const int parentChildCount = p->d_func()->children.size();
- if (parentChildCount < 2)
- return;
- const int from = p->d_func()->children.indexOf(this);
- Q_ASSERT(from >= 0);
- // Do nothing if the widget is already in correct stacking order _and_ created.
- if (from != 0)
- p->d_func()->children.move(from, 0);
- if (!testAttribute(Qt::WA_WState_Created) && p->testAttribute(Qt::WA_WState_Created))
- create();
- else if (from == 0)
- return;
- }
- if (testAttribute(Qt::WA_WState_Created))
- d->lower_sys();
-
- QEvent e(QEvent::ZOrderChange);
- QApplication::sendEvent(this, &e);
-}
-
-
-/*!
- Places the widget under \a w in the parent widget's stack.
-
- To make this work, the widget itself and \a w must be siblings.
-
- \sa raise(), lower()
-*/
-void QWidget::stackUnder(QWidget* w)
-{
- Q_D(QWidget);
- QWidget *p = parentWidget();
- if (!w || isWindow() || p != w->parentWidget() || this == w)
- return;
- if (p) {
- int from = p->d_func()->children.indexOf(this);
- int to = p->d_func()->children.indexOf(w);
- Q_ASSERT(from >= 0);
- Q_ASSERT(to >= 0);
- if (from < to)
- --to;
- // Do nothing if the widget is already in correct stacking order _and_ created.
- if (from != to)
- p->d_func()->children.move(from, to);
- if (!testAttribute(Qt::WA_WState_Created) && p->testAttribute(Qt::WA_WState_Created))
- create();
- else if (from == to)
- return;
- }
- if (testAttribute(Qt::WA_WState_Created))
- d->stackUnder_sys(w);
-
- QEvent e(QEvent::ZOrderChange);
- QApplication::sendEvent(this, &e);
-}
-
-void QWidget::styleChange(QStyle&) { }
-void QWidget::enabledChange(bool) { } // compat
-void QWidget::paletteChange(const QPalette &) { } // compat
-void QWidget::fontChange(const QFont &) { } // compat
-void QWidget::windowActivationChange(bool) { } // compat
-void QWidget::languageChange() { } // compat
-
-
-/*!
- \enum QWidget::BackgroundOrigin
-
- \compat
-
- \value WidgetOrigin
- \value ParentOrigin
- \value WindowOrigin
- \value AncestorOrigin
-
-*/
-
-/*!
- \fn bool QWidget::isVisibleToTLW() const
-
- Use isVisible() instead.
-*/
-
-/*!
- \fn void QWidget::iconify()
-
- Use showMinimized() instead.
-*/
-
-/*!
- \fn void QWidget::constPolish() const
-
- Use ensurePolished() instead.
-*/
-
-/*!
- \fn void QWidget::reparent(QWidget *parent, Qt::WindowFlags f, const QPoint &p, bool showIt)
-
- Use setParent() to change the parent or the widget's widget flags;
- use move() to move the widget, and use show() to show the widget.
-*/
-
-/*!
- \fn void QWidget::reparent(QWidget *parent, const QPoint &p, bool showIt)
-
- Use setParent() to change the parent; use move() to move the
- widget, and use show() to show the widget.
-*/
-
-/*!
- \fn void QWidget::recreate(QWidget *parent, Qt::WindowFlags f, const QPoint & p, bool showIt)
-
- Use setParent() to change the parent or the widget's widget flags;
- use move() to move the widget, and use show() to show the widget.
-*/
-
-/*!
- \fn bool QWidget::hasMouse() const
-
- Use testAttribute(Qt::WA_UnderMouse) instead.
-*/
-
-/*!
- \fn bool QWidget::ownCursor() const
-
- Use testAttribute(Qt::WA_SetCursor) instead.
-*/
-
-/*!
- \fn bool QWidget::ownFont() const
-
- Use testAttribute(Qt::WA_SetFont) instead.
-*/
-
-/*!
- \fn void QWidget::unsetFont()
-
- Use setFont(QFont()) instead.
-*/
-
-/*!
- \fn bool QWidget::ownPalette() const
-
- Use testAttribute(Qt::WA_SetPalette) instead.
-*/
-
-/*!
- \fn void QWidget::unsetPalette()
-
- Use setPalette(QPalette()) instead.
-*/
-
-/*!
- \fn void QWidget::setEraseColor(const QColor &color)
-
- Use the palette instead.
-
- \oldcode
- widget->setEraseColor(color);
- \newcode
- QPalette palette;
- palette.setColor(widget->backgroundRole(), color);
- widget->setPalette(palette);
- \endcode
-*/
-
-/*!
- \fn void QWidget::setErasePixmap(const QPixmap &pixmap)
-
- Use the palette instead.
-
- \oldcode
- widget->setErasePixmap(pixmap);
- \newcode
- QPalette palette;
- palette.setBrush(widget->backgroundRole(), QBrush(pixmap));
- widget->setPalette(palette);
- \endcode
-*/
-
-/*!
- \fn void QWidget::setPaletteForegroundColor(const QColor &color)
-
- Use the palette directly.
-
- \oldcode
- widget->setPaletteForegroundColor(color);
- \newcode
- QPalette palette;
- palette.setColor(widget->foregroundRole(), color);
- widget->setPalette(palette);
- \endcode
-*/
-
-/*!
- \fn void QWidget::setPaletteBackgroundColor(const QColor &color)
-
- Use the palette directly.
-
- \oldcode
- widget->setPaletteBackgroundColor(color);
- \newcode
- QPalette palette;
- palette.setColor(widget->backgroundRole(), color);
- widget->setPalette(palette);
- \endcode
-*/
-
-/*!
- \fn void QWidget::setPaletteBackgroundPixmap(const QPixmap &pixmap)
-
- Use the palette directly.
-
- \oldcode
- widget->setPaletteBackgroundPixmap(pixmap);
- \newcode
- QPalette palette;
- palette.setBrush(widget->backgroundRole(), QBrush(pixmap));
- widget->setPalette(palette);
- \endcode
-*/
-
-/*!
- \fn void QWidget::setBackgroundPixmap(const QPixmap &pixmap)
-
- Use the palette instead.
-
- \oldcode
- widget->setBackgroundPixmap(pixmap);
- \newcode
- QPalette palette;
- palette.setBrush(widget->backgroundRole(), QBrush(pixmap));
- widget->setPalette(palette);
- \endcode
-*/
-
-/*!
- \fn void QWidget::setBackgroundColor(const QColor &color)
-
- Use the palette instead.
-
- \oldcode
- widget->setBackgroundColor(color);
- \newcode
- QPalette palette;
- palette.setColor(widget->backgroundRole(), color);
- widget->setPalette(palette);
- \endcode
-*/
-
-/*!
- \fn QColorGroup QWidget::colorGroup() const
-
- Use QColorGroup(palette()) instead.
-*/
-
-/*!
- \fn QWidget *QWidget::parentWidget(bool sameWindow) const
-
- Use the no-argument overload instead.
-*/
-
-/*!
- \fn void QWidget::setKeyCompression(bool b)
-
- Use setAttribute(Qt::WA_KeyCompression, b) instead.
-*/
-
-/*!
- \fn void QWidget::setFont(const QFont &f, bool b)
-
- Use the single-argument overload instead.
-*/
-
-/*!
- \fn void QWidget::setPalette(const QPalette &p, bool b)
-
- Use the single-argument overload instead.
-*/
-
-/*!
- \fn void QWidget::setBackgroundOrigin(BackgroundOrigin background)
-
- \obsolete
-*/
-
-/*!
- \fn BackgroundOrigin QWidget::backgroundOrigin() const
-
- \obsolete
-
- Always returns \c WindowOrigin.
-*/
-
-/*!
- \fn QPoint QWidget::backgroundOffset() const
-
- \obsolete
-
- Always returns QPoint().
-*/
-
-/*!
- \fn void QWidget::repaint(bool b)
-
- The boolean parameter \a b is ignored. Use the no-argument overload instead.
-*/
-
-/*!
- \fn void QWidget::repaint(int x, int y, int w, int h, bool b)
-
- The boolean parameter \a b is ignored. Use the four-argument overload instead.
-*/
-
-/*!
- \fn void QWidget::repaint(const QRect &r, bool b)
-
- The boolean parameter \a b is ignored. Use the single rect-argument overload instead.
-*/
-
-/*!
- \fn void QWidget::repaint(const QRegion &rgn, bool b)
-
- The boolean parameter \a b is ignored. Use the single region-argument overload instead.
-*/
-
-/*!
- \fn void QWidget::erase()
-
- Drawing may only take place in a QPaintEvent. Overload
- paintEvent() to do your erasing and call update() to schedule a
- replaint whenever necessary. See also QPainter.
-*/
-
-/*!
- \fn void QWidget::erase(int x, int y, int w, int h)
-
- Drawing may only take place in a QPaintEvent. Overload
- paintEvent() to do your erasing and call update() to schedule a
- replaint whenever necessary. See also QPainter.
-*/
-
-/*!
- \fn void QWidget::erase(const QRect &rect)
-
- Drawing may only take place in a QPaintEvent. Overload
- paintEvent() to do your erasing and call update() to schedule a
- replaint whenever necessary. See also QPainter.
-*/
-
-/*!
- \fn void QWidget::drawText(const QPoint &p, const QString &s)
-
- Drawing may only take place in a QPaintEvent. Overload
- paintEvent() to do your drawing and call update() to schedule a
- replaint whenever necessary. See also QPainter.
-*/
-
-/*!
- \fn void QWidget::drawText(int x, int y, const QString &s)
-
- Drawing may only take place in a QPaintEvent. Overload
- paintEvent() to do your drawing and call update() to schedule a
- replaint whenever necessary. See also QPainter.
-*/
-
-/*!
- \fn QWidget *QWidget::childAt(const QPoint &p, bool includeThis) const
-
- Use the single point argument overload instead.
-*/
-
-/*!
- \fn void QWidget::setCaption(const QString &c)
-
- Use setWindowTitle() instead.
-*/
-
-/*!
- \fn void QWidget::setIcon(const QPixmap &i)
-
- Use setWindowIcon() instead.
-*/
-
-/*!
- \fn void QWidget::setIconText(const QString &it)
-
- Use setWindowIconText() instead.
-*/
-
-/*!
- \fn QString QWidget::caption() const
-
- Use windowTitle() instead.
-*/
-
-/*!
- \fn QString QWidget::iconText() const
-
- Use windowIconText() instead.
-*/
-
-/*!
- \fn bool QWidget::isTopLevel() const
- \obsolete
-
- Use isWindow() instead.
-*/
-
-/*!
- \fn bool QWidget::isRightToLeft() const
- \internal
-*/
-
-/*!
- \fn bool QWidget::isLeftToRight() const
- \internal
-*/
-
-/*!
- \fn void QWidget::setInputMethodEnabled(bool enabled)
-
- Use setAttribute(Qt::WA_InputMethodEnabled, \a enabled) instead.
-*/
-
-/*!
- \fn bool QWidget::isInputMethodEnabled() const
-
- Use testAttribute(Qt::WA_InputMethodEnabled) instead.
-*/
-
-/*!
- \fn void QWidget::setActiveWindow()
-
- Use activateWindow() instead.
-*/
-
-/*!
- \fn bool QWidget::isShown() const
-
- Use !isHidden() instead (notice the exclamation mark), or use isVisible() to check whether the widget is visible.
-*/
-
-/*!
- \fn bool QWidget::isDialog() const
-
- Use windowType() == Qt::Dialog instead.
-*/
-
-/*!
- \fn bool QWidget::isPopup() const
-
- Use windowType() == Qt::Popup instead.
-*/
-
-/*!
- \fn bool QWidget::isDesktop() const
-
- Use windowType() == Qt::Desktop instead.
-*/
-
-/*!
- \fn void QWidget::polish()
-
- Use ensurePolished() instead.
-*/
-
-/*!
- \fn QWidget *QWidget::childAt(int x, int y, bool includeThis) const
-
- Use the childAt() overload that doesn't have an \a includeThis parameter.
-
- \oldcode
- return widget->childAt(x, y, true);
- \newcode
- QWidget *child = widget->childAt(x, y, true);
- if (child)
- return child;
- if (widget->rect().contains(x, y))
- return widget;
- \endcode
-*/
-
-/*!
- \fn void QWidget::setSizePolicy(QSizePolicy::Policy hor, QSizePolicy::Policy ver, bool hfw)
- \compat
-
- Use the \l sizePolicy property and heightForWidth() function instead.
-*/
-
-/*!
- \fn bool QWidget::isUpdatesEnabled() const
- \compat
-
- Use the \l updatesEnabled property instead.
-*/
-
-/*!
- \macro QWIDGETSIZE_MAX
- \relates QWidget
-
- Defines the maximum size for a QWidget object.
-
- The largest allowed size for a widget is QSize(QWIDGETSIZE_MAX,
- QWIDGETSIZE_MAX), i.e. QSize (16777215,16777215).
-
- \sa QWidget::setMaximumSize()
-*/
-
-/*!
- \fn QWidget::setupUi(QWidget *widget)
-
- Sets up the user interface for the specified \a widget.
-
- \note This function is available with widgets that derive from user
- interface descriptions created using \l{uic}.
-
- \sa {Using a Designer UI File in Your Application}
-*/
-
-QRect QWidgetPrivate::frameStrut() const
-{
- Q_Q(const QWidget);
- if (!q->isWindow() || (q->windowType() == Qt::Desktop) || q->testAttribute(Qt::WA_DontShowOnScreen)) {
- // x2 = x1 + w - 1, so w/h = 1
- return QRect(0, 0, 1, 1);
- }
-
- if (data.fstrut_dirty
-#ifndef Q_WS_WIN
- // ### Fix properly for 4.3
- && q->isVisible()
-#endif
- && q->testAttribute(Qt::WA_WState_Created))
- const_cast<QWidgetPrivate *>(this)->updateFrameStrut();
-
- return maybeTopData() ? maybeTopData()->frameStrut : QRect();
-}
-
-#ifdef QT_KEYPAD_NAVIGATION
-/*!
- \internal
-
- Changes the focus from the current focusWidget to a widget in
- the \a direction.
-
- Returns true, if there was a widget in that direction
-*/
-bool QWidgetPrivate::navigateToDirection(Direction direction)
-{
- QWidget *targetWidget = widgetInNavigationDirection(direction);
- if (targetWidget)
- targetWidget->setFocus();
- return (targetWidget != 0);
-}
-
-/*!
- \internal
-
- Searches for a widget that is positioned in the \a direction, starting
- from the current focusWidget.
-
- Returns the pointer to a found widget or 0, if there was no widget in
- that direction.
-*/
-QWidget *QWidgetPrivate::widgetInNavigationDirection(Direction direction)
-{
- const QWidget *sourceWidget = QApplication::focusWidget();
- if (!sourceWidget)
- return 0;
- const QRect sourceRect = sourceWidget->rect().translated(sourceWidget->mapToGlobal(QPoint()));
- const int sourceX =
- (direction == DirectionNorth || direction == DirectionSouth) ?
- (sourceRect.left() + (sourceRect.right() - sourceRect.left()) / 2)
- :(direction == DirectionEast ? sourceRect.right() : sourceRect.left());
- const int sourceY =
- (direction == DirectionEast || direction == DirectionWest) ?
- (sourceRect.top() + (sourceRect.bottom() - sourceRect.top()) / 2)
- :(direction == DirectionSouth ? sourceRect.bottom() : sourceRect.top());
- const QPoint sourcePoint(sourceX, sourceY);
- const QPoint sourceCenter = sourceRect.center();
- const QWidget *sourceWindow = sourceWidget->window();
-
- QWidget *targetWidget = 0;
- int shortestDistance = INT_MAX;
- foreach(QWidget *targetCandidate, QApplication::allWidgets()) {
-
- const QRect targetCandidateRect = targetCandidate->rect().translated(targetCandidate->mapToGlobal(QPoint()));
-
- // For focus proxies, the child widget handling the focus can have keypad navigation focus,
- // but the owner of the proxy cannot.
- // Additionally, empty widgets should be ignored.
- if (targetCandidate->focusProxy() || targetCandidateRect.isEmpty())
- continue;
-
- // Only navigate to a target widget that...
- if ( targetCandidate != sourceWidget
- // ...takes the focus,
- && targetCandidate->focusPolicy() & Qt::TabFocus
- // ...is above if DirectionNorth,
- && !(direction == DirectionNorth && targetCandidateRect.bottom() > sourceRect.top())
- // ...is on the right if DirectionEast,
- && !(direction == DirectionEast && targetCandidateRect.left() < sourceRect.right())
- // ...is below if DirectionSouth,
- && !(direction == DirectionSouth && targetCandidateRect.top() < sourceRect.bottom())
- // ...is on the left if DirectionWest,
- && !(direction == DirectionWest && targetCandidateRect.right() > sourceRect.left())
- // ...is enabled,
- && targetCandidate->isEnabled()
- // ...is visible,
- && targetCandidate->isVisible()
- // ...is in the same window,
- && targetCandidate->window() == sourceWindow) {
- const int targetCandidateDistance = pointToRect(sourcePoint, targetCandidateRect);
- if (targetCandidateDistance < shortestDistance) {
- shortestDistance = targetCandidateDistance;
- targetWidget = targetCandidate;
- }
- }
- }
- return targetWidget;
-}
-
-/*!
- \internal
-
- Tells us if it there is currently a reachable widget by keypad navigation in
- a certain \a orientation.
- If no navigation is possible, occurring key events in that \a orientation may
- be used to interact with the value in the focused widget, even though it
- currently has not the editFocus.
-
- \sa QWidgetPrivate::widgetInNavigationDirection(), QWidget::hasEditFocus()
-*/
-bool QWidgetPrivate::canKeypadNavigate(Qt::Orientation orientation)
-{
- return orientation == Qt::Horizontal?
- (QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionEast)
- || QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionWest))
- :(QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionNorth)
- || QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionSouth));
-}
-/*!
- \internal
-
- Checks, if the \a widget is inside a QTabWidget. If is is inside
- one, left/right key events will be used to switch between tabs in keypad
- navigation. If there is no QTabWidget, the horizontal key events can be used
-to
- interact with the value in the focused widget, even though it currently has
- not the editFocus.
-
- \sa QWidget::hasEditFocus()
-*/
-bool QWidgetPrivate::inTabWidget(QWidget *widget)
-{
- for (QWidget *tabWidget = widget; tabWidget; tabWidget = tabWidget->parentWidget())
- if (qobject_cast<const QTabWidget*>(tabWidget))
- return true;
- return false;
-}
-#endif
-
-/*!
- \preliminary
- \since 4.2
- \obsolete
-
- Sets the window surface to be the \a surface specified.
- The QWidget takes will ownership of the \a surface.
- widget itself is deleted.
-*/
-void QWidget::setWindowSurface(QWindowSurface *surface)
-{
- // ### createWinId() ??
-
-#ifndef Q_BACKINGSTORE_SUBSURFACES
- if (!isTopLevel())
- return;
-#endif
-
- Q_D(QWidget);
-
- QTLWExtra *topData = d->topData();
- if (topData->windowSurface == surface)
- return;
-
- QWindowSurface *oldSurface = topData->windowSurface;
- delete topData->windowSurface;
- topData->windowSurface = surface;
-
- QWidgetBackingStore *bs = d->maybeBackingStore();
- if (!bs)
- return;
-
- if (isTopLevel()) {
- if (bs->windowSurface != oldSurface && bs->windowSurface != surface)
- delete bs->windowSurface;
- bs->windowSurface = surface;
- }
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- else {
- bs->subSurfaces.append(surface);
- }
- bs->subSurfaces.removeOne(oldSurface);
-#endif
-}
-
-/*!
- \preliminary
- \since 4.2
-
- Returns the QWindowSurface this widget will be drawn into.
-*/
-QWindowSurface *QWidget::windowSurface() const
-{
- Q_D(const QWidget);
- QTLWExtra *extra = d->maybeTopData();
- if (extra && extra->windowSurface)
- return extra->windowSurface;
-
- QWidgetBackingStore *bs = d->maybeBackingStore();
-
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- if (bs && bs->subSurfaces.isEmpty())
- return bs->windowSurface;
-
- if (!isTopLevel()) {
- const QWidget *w = parentWidget();
- while (w) {
- QTLWExtra *extra = w->d_func()->maybeTopData();
- if (extra && extra->windowSurface)
- return extra->windowSurface;
- if (w->isTopLevel())
- break;
- w = w->parentWidget();
- }
- }
-#endif // Q_BACKINGSTORE_SUBSURFACES
-
- return bs ? bs->windowSurface : 0;
-}
-
-void QWidgetPrivate::getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const
-{
- if (left)
- *left = (int)leftLayoutItemMargin;
- if (top)
- *top = (int)topLayoutItemMargin;
- if (right)
- *right = (int)rightLayoutItemMargin;
- if (bottom)
- *bottom = (int)bottomLayoutItemMargin;
-}
-
-void QWidgetPrivate::setLayoutItemMargins(int left, int top, int right, int bottom)
-{
- if (leftLayoutItemMargin == left
- && topLayoutItemMargin == top
- && rightLayoutItemMargin == right
- && bottomLayoutItemMargin == bottom)
- return;
-
- Q_Q(QWidget);
- leftLayoutItemMargin = (signed char)left;
- topLayoutItemMargin = (signed char)top;
- rightLayoutItemMargin = (signed char)right;
- bottomLayoutItemMargin = (signed char)bottom;
- q->updateGeometry();
-}
-
-void QWidgetPrivate::setLayoutItemMargins(QStyle::SubElement element, const QStyleOption *opt)
-{
- Q_Q(QWidget);
- QStyleOption myOpt;
- if (!opt) {
- myOpt.initFrom(q);
- myOpt.rect.setRect(0, 0, 32768, 32768); // arbitrary
- opt = &myOpt;
- }
-
- QRect liRect = q->style()->subElementRect(element, opt, q);
- if (liRect.isValid()) {
- leftLayoutItemMargin = (signed char)(opt->rect.left() - liRect.left());
- topLayoutItemMargin = (signed char)(opt->rect.top() - liRect.top());
- rightLayoutItemMargin = (signed char)(liRect.right() - opt->rect.right());
- bottomLayoutItemMargin = (signed char)(liRect.bottom() - opt->rect.bottom());
- } else {
- leftLayoutItemMargin = 0;
- topLayoutItemMargin = 0;
- rightLayoutItemMargin = 0;
- bottomLayoutItemMargin = 0;
- }
-}
-// resets the Qt::WA_QuitOnClose attribute to the default value for transient widgets.
-void QWidgetPrivate::adjustQuitOnCloseAttribute()
-{
- Q_Q(QWidget);
-
- if (!q->parentWidget()) {
- Qt::WindowType type = q->windowType();
- if (type == Qt::Widget || type == Qt::SubWindow)
- type = Qt::Window;
- if (type != Qt::Widget && type != Qt::Window && type != Qt::Dialog)
- q->setAttribute(Qt::WA_QuitOnClose, false);
- }
-}
-
-
-
-Q_GUI_EXPORT QWidgetData *qt_qwidget_data(QWidget *widget)
-{
- return widget->data;
-}
-
-Q_GUI_EXPORT QWidgetPrivate *qt_widget_private(QWidget *widget)
-{
- return widget->d_func();
-}
-
-
-#ifndef QT_NO_GRAPHICSVIEW
-/*!
- \since 4.5
-
- Returns the proxy widget for the corresponding embedded widget in a graphics
- view; otherwise returns 0.
-
- \sa QGraphicsProxyWidget::createProxyForChildWidget(),
- QGraphicsScene::addWidget()
- */
-QGraphicsProxyWidget *QWidget::graphicsProxyWidget() const
-{
- Q_D(const QWidget);
- if (d->extra) {
- return d->extra->proxyWidget;
- }
- return 0;
-}
-#endif
-
-
-/*!
- \typedef QWidgetList
- \relates QWidget
-
- Synonym for QList<QWidget *>.
-*/
-
-#ifndef QT_NO_GESTURES
-/*!
- Subscribes the widget to a given \a gesture with specific \a flags.
-
- \sa ungrabGesture(), QGestureEvent
- \since 4.6
-*/
-void QWidget::grabGesture(Qt::GestureType gesture, Qt::GestureFlags flags)
-{
- Q_D(QWidget);
- d->gestureContext.insert(gesture, flags);
- (void)QGestureManager::instance(); // create a gesture manager
-}
-
-/*!
- Unsubscribes the widget from a given \a gesture type
-
- \sa grabGesture(), QGestureEvent
- \since 4.6
-*/
-void QWidget::ungrabGesture(Qt::GestureType gesture)
-{
- Q_D(QWidget);
- if (d->gestureContext.remove(gesture)) {
- if (QGestureManager *manager = QGestureManager::instance())
- manager->cleanupCachedGestures(this, gesture);
- }
-}
-#endif // QT_NO_GESTURES
-
-/*!
- \typedef WId
- \relates QWidget
-
- Platform dependent window identifier.
-*/
-
-/*!
- \fn void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
-
- Frees up window system resources. Destroys the widget window if \a
- destroyWindow is true.
-
- destroy() calls itself recursively for all the child widgets,
- passing \a destroySubWindows for the \a destroyWindow parameter.
- To have more control over destruction of subwidgets, destroy
- subwidgets selectively first.
-
- This function is usually called from the QWidget destructor.
-*/
-
-/*!
- \fn QPaintEngine *QWidget::paintEngine() const
-
- Returns the widget's paint engine.
-
- Note that this function should not be called explicitly by the
- user, since it's meant for reimplementation purposes only. The
- function is called by Qt internally, and the default
- implementation may not always return a valid pointer.
-*/
-
-/*!
- \fn QPoint QWidget::mapToGlobal(const QPoint &pos) const
-
- Translates the widget coordinate \a pos to global screen
- coordinates. For example, \c{mapToGlobal(QPoint(0,0))} would give
- the global coordinates of the top-left pixel of the widget.
-
- \sa mapFromGlobal() mapTo() mapToParent()
-*/
-
-/*!
- \fn QPoint QWidget::mapFromGlobal(const QPoint &pos) const
-
- Translates the global screen coordinate \a pos to widget
- coordinates.
-
- \sa mapToGlobal() mapFrom() mapFromParent()
-*/
-
-/*!
- \fn void QWidget::grabMouse()
-
- Grabs the mouse input.
-
- This widget receives all mouse events until releaseMouse() is
- called; other widgets get no mouse events at all. Keyboard
- events are not affected. Use grabKeyboard() if you want to grab
- that.
-
- \warning Bugs in mouse-grabbing applications very often lock the
- terminal. Use this function with extreme caution, and consider
- using the \c -nograb command line option while debugging.
-
- It is almost never necessary to grab the mouse when using Qt, as
- Qt grabs and releases it sensibly. In particular, Qt grabs the
- mouse when a mouse button is pressed and keeps it until the last
- button is released.
-
- \note Only visible widgets can grab mouse input. If isVisible()
- returns false for a widget, that widget cannot call grabMouse().
-
- \note \bold{(Mac OS X developers)} For \e Cocoa, calling
- grabMouse() on a widget only works when the mouse is inside the
- frame of that widget. For \e Carbon, it works outside the widget's
- frame as well, like for Windows and X11.
-
- \sa releaseMouse() grabKeyboard() releaseKeyboard()
-*/
-
-/*!
- \fn void QWidget::grabMouse(const QCursor &cursor)
- \overload grabMouse()
-
- Grabs the mouse input and changes the cursor shape.
-
- The cursor will assume shape \a cursor (for as long as the mouse
- focus is grabbed) and this widget will be the only one to receive
- mouse events until releaseMouse() is called().
-
- \warning Grabbing the mouse might lock the terminal.
-
- \note \bold{(Mac OS X developers)} See the note in QWidget::grabMouse().
-
- \sa releaseMouse(), grabKeyboard(), releaseKeyboard(), setCursor()
-*/
-
-/*!
- \fn void QWidget::releaseMouse()
-
- Releases the mouse grab.
-
- \sa grabMouse(), grabKeyboard(), releaseKeyboard()
-*/
-
-/*!
- \fn void QWidget::grabKeyboard()
-
- Grabs the keyboard input.
-
- This widget receives all keyboard events until releaseKeyboard()
- is called; other widgets get no keyboard events at all. Mouse
- events are not affected. Use grabMouse() if you want to grab that.
-
- The focus widget is not affected, except that it doesn't receive
- any keyboard events. setFocus() moves the focus as usual, but the
- new focus widget receives keyboard events only after
- releaseKeyboard() is called.
-
- If a different widget is currently grabbing keyboard input, that
- widget's grab is released first.
-
- \sa releaseKeyboard() grabMouse() releaseMouse() focusWidget()
-*/
-
-/*!
- \fn void QWidget::releaseKeyboard()
-
- Releases the keyboard grab.
-
- \sa grabKeyboard(), grabMouse(), releaseMouse()
-*/
-
-/*!
- \fn QWidget *QWidget::mouseGrabber()
-
- Returns the widget that is currently grabbing the mouse input.
-
- If no widget in this application is currently grabbing the mouse,
- 0 is returned.
-
- \sa grabMouse(), keyboardGrabber()
-*/
-
-/*!
- \fn QWidget *QWidget::keyboardGrabber()
-
- Returns the widget that is currently grabbing the keyboard input.
-
- If no widget in this application is currently grabbing the
- keyboard, 0 is returned.
-
- \sa grabMouse(), mouseGrabber()
-*/
-
-/*!
- \fn void QWidget::activateWindow()
-
- Sets the top-level widget containing this widget to be the active
- window.
-
- An active window is a visible top-level window that has the
- keyboard input focus.
-
- This function performs the same operation as clicking the mouse on
- the title bar of a top-level window. On X11, the result depends on
- the Window Manager. If you want to ensure that the window is
- stacked on top as well you should also call raise(). Note that the
- window must be visible, otherwise activateWindow() has no effect.
-
- On Windows, if you are calling this when the application is not
- currently the active one then it will not make it the active
- window. It will change the color of the taskbar entry to indicate
- that the window has changed in some way. This is because Microsoft
- does not allow an application to interrupt what the user is currently
- doing in another application.
-
- \sa isActiveWindow(), window(), show()
-*/
-
-/*!
- \fn int QWidget::metric(PaintDeviceMetric m) const
-
- Internal implementation of the virtual QPaintDevice::metric()
- function.
-
- \a m is the metric to get.
-*/
-
-/*!
- \fn void QWidget::setMask(const QRegion &region)
- \overload
-
- Causes only the parts of the widget which overlap \a region to be
- visible. If the region includes pixels outside the rect() of the
- widget, window system controls in that area may or may not be
- visible, depending on the platform.
-
- Note that this effect can be slow if the region is particularly
- complex.
-
- \sa windowOpacity
-*/
-void QWidget::setMask(const QRegion &newMask)
-{
- Q_D(QWidget);
-
- d->createExtra();
- if (newMask == d->extra->mask)
- return;
-
-#ifndef QT_NO_BACKINGSTORE
- const QRegion oldMask(d->extra->mask);
-#endif
-
- d->extra->mask = newMask;
- d->extra->hasMask = !newMask.isEmpty();
-
-#ifndef QT_MAC_USE_COCOA
- if (!testAttribute(Qt::WA_WState_Created))
- return;
-#endif
-
- d->setMask_sys(newMask);
-
-#ifndef QT_NO_BACKINGSTORE
- if (!isVisible())
- return;
-
- if (!d->extra->hasMask) {
- // Mask was cleared; update newly exposed area.
- QRegion expose(rect());
- expose -= oldMask;
- if (!expose.isEmpty()) {
- d->setDirtyOpaqueRegion();
- update(expose);
- }
- return;
- }
-
- if (!isWindow()) {
- // Update newly exposed area on the parent widget.
- QRegion parentExpose(rect());
- parentExpose -= newMask;
- if (!parentExpose.isEmpty()) {
- d->setDirtyOpaqueRegion();
- parentExpose.translate(data->crect.topLeft());
- parentWidget()->update(parentExpose);
- }
-
- // Update newly exposed area on this widget
- if (!oldMask.isEmpty())
- update(newMask - oldMask);
- }
-#endif
-}
-
-/*!
- \fn void QWidget::setMask(const QBitmap &bitmap)
-
- Causes only the pixels of the widget for which \a bitmap has a
- corresponding 1 bit to be visible. If the region includes pixels
- outside the rect() of the widget, window system controls in that
- area may or may not be visible, depending on the platform.
-
- Note that this effect can be slow if the region is particularly
- complex.
-
- The following code shows how an image with an alpha channel can be
- used to generate a mask for a widget:
-
- \snippet doc/src/snippets/widget-mask/main.cpp 0
-
- The label shown by this code is masked using the image it contains,
- giving the appearance that an irregularly-shaped image is being drawn
- directly onto the screen.
-
- Masked widgets receive mouse events only on their visible
- portions.
-
- \sa clearMask(), windowOpacity(), {Shaped Clock Example}
-*/
-void QWidget::setMask(const QBitmap &bitmap)
-{
- setMask(QRegion(bitmap));
-}
-
-/*!
- \fn void QWidget::clearMask()
-
- Removes any mask set by setMask().
-
- \sa setMask()
-*/
-void QWidget::clearMask()
-{
- setMask(QRegion());
-}
-
-/*! \fn const QX11Info &QWidget::x11Info() const
- Returns information about the configuration of the X display used to display
- the widget.
-
- \warning This function is only available on X11.
-*/
-
-/*! \fn Qt::HANDLE QWidget::x11PictureHandle() const
- Returns the X11 Picture handle of the widget for XRender
- support. Use of this function is not portable. This function will
- return 0 if XRender support is not compiled into Qt, if the
- XRender extension is not supported on the X11 display, or if the
- handle could not be created.
-*/
-
-#ifdef Q_OS_SYMBIAN
-void QWidgetPrivate::_q_delayedDestroy(WId winId)
-{
- delete winId;
-}
-#endif
-
-#if QT_MAC_USE_COCOA
-void QWidgetPrivate::syncUnifiedMode() {
- // The whole purpose of this method is to keep the unifiedToolbar in sync.
- // That means making sure we either exchange the drawing methods or we let
- // the toolbar know that it does not require to draw the baseline.
- Q_Q(QWidget);
- // This function makes sense only if this is a top level
- if(!q->isWindow())
- return;
- OSWindowRef window = qt_mac_window_for(q);
- if(changeMethods) {
- // Ok, we are in documentMode.
- if(originalDrawMethod)
- qt_mac_replaceDrawRect(window, this);
- } else {
- if(!originalDrawMethod)
- qt_mac_replaceDrawRectOriginal(window, this);
- }
-}
-
-#endif // QT_MAC_USE_COCOA
-
-QT_END_NAMESPACE
-
-#include "moc_qwidget.cpp"
-
diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h
deleted file mode 100644
index 7d4726ed6d..0000000000
--- a/src/gui/kernel/qwidget.h
+++ /dev/null
@@ -1,1090 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWIDGET_H
-#define QWIDGET_H
-
-#include <QtGui/qwindowdefs.h>
-#include <QtCore/qobject.h>
-#include <QtCore/qmargins.h>
-#include <QtGui/qpaintdevice.h>
-#include <QtGui/qpalette.h>
-#include <QtGui/qfont.h>
-#include <QtGui/qfontmetrics.h>
-#include <QtGui/qfontinfo.h>
-#include <QtGui/qsizepolicy.h>
-#include <QtGui/qregion.h>
-#include <QtGui/qbrush.h>
-#include <QtGui/qcursor.h>
-#include <QtGui/qkeysequence.h>
-
-#ifdef Q_WS_QPA //should this go somewhere else?
-#include <QtGui/qplatformwindowformat_qpa.h>
-#endif
-
-#ifdef QT_INCLUDE_COMPAT
-#include <QtGui/qevent.h>
-#endif
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QLayout;
-class QWSRegionManager;
-class QStyle;
-class QAction;
-class QVariant;
-
-class QActionEvent;
-class QMouseEvent;
-class QWheelEvent;
-class QHoverEvent;
-class QKeyEvent;
-class QFocusEvent;
-class QPaintEvent;
-class QMoveEvent;
-class QResizeEvent;
-class QCloseEvent;
-class QContextMenuEvent;
-class QInputMethodEvent;
-class QTabletEvent;
-class QDragEnterEvent;
-class QDragMoveEvent;
-class QDragLeaveEvent;
-class QDropEvent;
-class QShowEvent;
-class QHideEvent;
-class QInputContext;
-class QIcon;
-class QWindowSurface;
-class QPlatformWindow;
-class QLocale;
-class QGraphicsProxyWidget;
-class QGraphicsEffect;
-class QRasterWindowSurface;
-class QUnifiedToolbarSurface;
-#if defined(Q_WS_X11)
-class QX11Info;
-#endif
-
-class QWidgetData
-{
-public:
- WId winid;
- uint widget_attributes;
- Qt::WindowFlags window_flags;
- uint window_state : 4;
- uint focus_policy : 4;
- uint sizehint_forced :1;
- uint is_closing :1;
- uint in_show : 1;
- uint in_set_window_state : 1;
- mutable uint fstrut_dirty : 1;
- uint context_menu_policy : 3;
- uint window_modality : 2;
- uint in_destructor : 1;
- uint unused : 13;
- QRect crect;
- mutable QPalette pal;
- QFont fnt;
-#if defined(Q_WS_QWS)
-// QRegion req_region; // Requested region
-// mutable QRegion paintable_region; // Paintable region
-// mutable bool paintable_region_dirty;// needs to be recalculated
-// mutable QRegion alloc_region; // Allocated region
-// mutable bool alloc_region_dirty; // needs to be recalculated
-// mutable int overlapping_children; // Handle overlapping children
-
- int alloc_region_index;
-// int alloc_region_revision;
-#endif
- QRect wrect;
-};
-
-class QWidgetPrivate;
-
-class Q_GUI_EXPORT QWidget : public QObject, public QPaintDevice
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QWidget)
-
- Q_PROPERTY(bool modal READ isModal)
- Q_PROPERTY(Qt::WindowModality windowModality READ windowModality WRITE setWindowModality)
- Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
- Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry)
- Q_PROPERTY(QRect frameGeometry READ frameGeometry)
- Q_PROPERTY(QRect normalGeometry READ normalGeometry)
- Q_PROPERTY(int x READ x)
- Q_PROPERTY(int y READ y)
- Q_PROPERTY(QPoint pos READ pos WRITE move DESIGNABLE false STORED false)
- Q_PROPERTY(QSize frameSize READ frameSize)
- Q_PROPERTY(QSize size READ size WRITE resize DESIGNABLE false STORED false)
- Q_PROPERTY(int width READ width)
- Q_PROPERTY(int height READ height)
- Q_PROPERTY(QRect rect READ rect)
- Q_PROPERTY(QRect childrenRect READ childrenRect)
- Q_PROPERTY(QRegion childrenRegion READ childrenRegion)
- Q_PROPERTY(QSizePolicy sizePolicy READ sizePolicy WRITE setSizePolicy)
- Q_PROPERTY(QSize minimumSize READ minimumSize WRITE setMinimumSize)
- Q_PROPERTY(QSize maximumSize READ maximumSize WRITE setMaximumSize)
- Q_PROPERTY(int minimumWidth READ minimumWidth WRITE setMinimumWidth STORED false DESIGNABLE false)
- Q_PROPERTY(int minimumHeight READ minimumHeight WRITE setMinimumHeight STORED false DESIGNABLE false)
- Q_PROPERTY(int maximumWidth READ maximumWidth WRITE setMaximumWidth STORED false DESIGNABLE false)
- Q_PROPERTY(int maximumHeight READ maximumHeight WRITE setMaximumHeight STORED false DESIGNABLE false)
- Q_PROPERTY(QSize sizeIncrement READ sizeIncrement WRITE setSizeIncrement)
- Q_PROPERTY(QSize baseSize READ baseSize WRITE setBaseSize)
- Q_PROPERTY(QPalette palette READ palette WRITE setPalette)
- Q_PROPERTY(QFont font READ font WRITE setFont)
-#ifndef QT_NO_CURSOR
- Q_PROPERTY(QCursor cursor READ cursor WRITE setCursor RESET unsetCursor)
-#endif
- Q_PROPERTY(bool mouseTracking READ hasMouseTracking WRITE setMouseTracking)
- Q_PROPERTY(bool isActiveWindow READ isActiveWindow)
- Q_PROPERTY(Qt::FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy)
- Q_PROPERTY(bool focus READ hasFocus)
- Q_PROPERTY(Qt::ContextMenuPolicy contextMenuPolicy READ contextMenuPolicy WRITE setContextMenuPolicy)
- Q_PROPERTY(bool updatesEnabled READ updatesEnabled WRITE setUpdatesEnabled DESIGNABLE false)
- Q_PROPERTY(bool visible READ isVisible WRITE setVisible DESIGNABLE false)
- Q_PROPERTY(bool minimized READ isMinimized)
- Q_PROPERTY(bool maximized READ isMaximized)
- Q_PROPERTY(bool fullScreen READ isFullScreen)
- Q_PROPERTY(QSize sizeHint READ sizeHint)
- Q_PROPERTY(QSize minimumSizeHint READ minimumSizeHint)
- Q_PROPERTY(bool acceptDrops READ acceptDrops WRITE setAcceptDrops)
- Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle DESIGNABLE isWindow)
- Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon DESIGNABLE isWindow)
- Q_PROPERTY(QString windowIconText READ windowIconText WRITE setWindowIconText DESIGNABLE isWindow)
- Q_PROPERTY(double windowOpacity READ windowOpacity WRITE setWindowOpacity DESIGNABLE isWindow)
- Q_PROPERTY(bool windowModified READ isWindowModified WRITE setWindowModified DESIGNABLE isWindow)
-#ifndef QT_NO_TOOLTIP
- Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip)
-#endif
-#ifndef QT_NO_STATUSTIP
- Q_PROPERTY(QString statusTip READ statusTip WRITE setStatusTip)
-#endif
-#ifndef QT_NO_WHATSTHIS
- Q_PROPERTY(QString whatsThis READ whatsThis WRITE setWhatsThis)
-#endif
-#ifndef QT_NO_ACCESSIBILITY
- Q_PROPERTY(QString accessibleName READ accessibleName WRITE setAccessibleName)
- Q_PROPERTY(QString accessibleDescription READ accessibleDescription WRITE setAccessibleDescription)
-#endif
- Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection RESET unsetLayoutDirection)
- QDOC_PROPERTY(Qt::WindowFlags windowFlags READ windowFlags WRITE setWindowFlags)
- Q_PROPERTY(bool autoFillBackground READ autoFillBackground WRITE setAutoFillBackground)
-#ifndef QT_NO_STYLE_STYLESHEET
- Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
-#endif
- Q_PROPERTY(QLocale locale READ locale WRITE setLocale RESET unsetLocale)
- Q_PROPERTY(QString windowFilePath READ windowFilePath WRITE setWindowFilePath DESIGNABLE isWindow)
- Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints)
-
-public:
- enum RenderFlag {
- DrawWindowBackground = 0x1,
- DrawChildren = 0x2,
- IgnoreMask = 0x4
- };
- Q_DECLARE_FLAGS(RenderFlags, RenderFlag)
-
- explicit QWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QWidget(QWidget* parent, const char *name, Qt::WindowFlags f = 0);
-#endif
- ~QWidget();
-
- int devType() const;
-
- WId winId() const;
- void createWinId(); // internal, going away
- inline WId internalWinId() const { return data->winid; }
- WId effectiveWinId() const;
-
- // GUI style setting
- QStyle *style() const;
- void setStyle(QStyle *);
- // Widget types and states
-
- bool isTopLevel() const;
- bool isWindow() const;
-
- bool isModal() const;
- Qt::WindowModality windowModality() const;
- void setWindowModality(Qt::WindowModality windowModality);
-
- bool isEnabled() const;
- bool isEnabledTo(QWidget*) const;
- bool isEnabledToTLW() const;
-
-public Q_SLOTS:
- void setEnabled(bool);
- void setDisabled(bool);
- void setWindowModified(bool);
-
- // Widget coordinates
-
-public:
- QRect frameGeometry() const;
- const QRect &geometry() const;
- QRect normalGeometry() const;
-
- int x() const;
- int y() const;
- QPoint pos() const;
- QSize frameSize() const;
- QSize size() const;
- inline int width() const;
- inline int height() const;
- inline QRect rect() const;
- QRect childrenRect() const;
- QRegion childrenRegion() const;
-
- QSize minimumSize() const;
- QSize maximumSize() const;
- int minimumWidth() const;
- int minimumHeight() const;
- int maximumWidth() const;
- int maximumHeight() const;
- void setMinimumSize(const QSize &);
- void setMinimumSize(int minw, int minh);
- void setMaximumSize(const QSize &);
- void setMaximumSize(int maxw, int maxh);
- void setMinimumWidth(int minw);
- void setMinimumHeight(int minh);
- void setMaximumWidth(int maxw);
- void setMaximumHeight(int maxh);
-
-#ifdef Q_QDOC
- void setupUi(QWidget *widget);
-#endif
-
- QSize sizeIncrement() const;
- void setSizeIncrement(const QSize &);
- void setSizeIncrement(int w, int h);
- QSize baseSize() const;
- void setBaseSize(const QSize &);
- void setBaseSize(int basew, int baseh);
-
- void setFixedSize(const QSize &);
- void setFixedSize(int w, int h);
- void setFixedWidth(int w);
- void setFixedHeight(int h);
-
- // Widget coordinate mapping
-
- QPoint mapToGlobal(const QPoint &) const;
- QPoint mapFromGlobal(const QPoint &) const;
- QPoint mapToParent(const QPoint &) const;
- QPoint mapFromParent(const QPoint &) const;
- QPoint mapTo(QWidget *, const QPoint &) const;
- QPoint mapFrom(QWidget *, const QPoint &) const;
-
- QWidget *window() const;
- QWidget *nativeParentWidget() const;
- inline QWidget *topLevelWidget() const { return window(); }
-
- // Widget appearance functions
- const QPalette &palette() const;
- void setPalette(const QPalette &);
-
- void setBackgroundRole(QPalette::ColorRole);
- QPalette::ColorRole backgroundRole() const;
-
- void setForegroundRole(QPalette::ColorRole);
- QPalette::ColorRole foregroundRole() const;
-
- const QFont &font() const;
- void setFont(const QFont &);
- QFontMetrics fontMetrics() const;
- QFontInfo fontInfo() const;
-
-#ifndef QT_NO_CURSOR
- QCursor cursor() const;
- void setCursor(const QCursor &);
- void unsetCursor();
-#endif
-
- void setMouseTracking(bool enable);
- bool hasMouseTracking() const;
- bool underMouse() const;
-
- void setMask(const QBitmap &);
- void setMask(const QRegion &);
- QRegion mask() const;
- void clearMask();
-
- void render(QPaintDevice *target, const QPoint &targetOffset = QPoint(),
- const QRegion &sourceRegion = QRegion(),
- RenderFlags renderFlags = RenderFlags(DrawWindowBackground | DrawChildren));
-
- void render(QPainter *painter, const QPoint &targetOffset = QPoint(),
- const QRegion &sourceRegion = QRegion(),
- RenderFlags renderFlags = RenderFlags(DrawWindowBackground | DrawChildren));
-
-#ifndef QT_NO_GRAPHICSEFFECT
- QGraphicsEffect *graphicsEffect() const;
- void setGraphicsEffect(QGraphicsEffect *effect);
-#endif //QT_NO_GRAPHICSEFFECT
-
-#ifndef QT_NO_GESTURES
- void grabGesture(Qt::GestureType type, Qt::GestureFlags flags = Qt::GestureFlags());
- void ungrabGesture(Qt::GestureType type);
-#endif
-
-public Q_SLOTS:
- void setWindowTitle(const QString &);
-#ifndef QT_NO_STYLE_STYLESHEET
- void setStyleSheet(const QString& styleSheet);
-#endif
-public:
-#ifndef QT_NO_STYLE_STYLESHEET
- QString styleSheet() const;
-#endif
- QString windowTitle() const;
- void setWindowIcon(const QIcon &icon);
- QIcon windowIcon() const;
- void setWindowIconText(const QString &);
- QString windowIconText() const;
- void setWindowRole(const QString &);
- QString windowRole() const;
- void setWindowFilePath(const QString &filePath);
- QString windowFilePath() const;
-
- void setWindowOpacity(qreal level);
- qreal windowOpacity() const;
-
- bool isWindowModified() const;
-#ifndef QT_NO_TOOLTIP
- void setToolTip(const QString &);
- QString toolTip() const;
-#endif
-#ifndef QT_NO_STATUSTIP
- void setStatusTip(const QString &);
- QString statusTip() const;
-#endif
-#ifndef QT_NO_WHATSTHIS
- void setWhatsThis(const QString &);
- QString whatsThis() const;
-#endif
-#ifndef QT_NO_ACCESSIBILITY
- QString accessibleName() const;
- void setAccessibleName(const QString &name);
- QString accessibleDescription() const;
- void setAccessibleDescription(const QString &description);
-#endif
-
- void setLayoutDirection(Qt::LayoutDirection direction);
- Qt::LayoutDirection layoutDirection() const;
- void unsetLayoutDirection();
-
- void setLocale(const QLocale &locale);
- QLocale locale() const;
- void unsetLocale();
-
- inline bool isRightToLeft() const { return layoutDirection() == Qt::RightToLeft; }
- inline bool isLeftToRight() const { return layoutDirection() == Qt::LeftToRight; }
-
-public Q_SLOTS:
- inline void setFocus() { setFocus(Qt::OtherFocusReason); }
-
-public:
- bool isActiveWindow() const;
- void activateWindow();
- void clearFocus();
-
- void setFocus(Qt::FocusReason reason);
- Qt::FocusPolicy focusPolicy() const;
- void setFocusPolicy(Qt::FocusPolicy policy);
- bool hasFocus() const;
- static void setTabOrder(QWidget *, QWidget *);
- void setFocusProxy(QWidget *);
- QWidget *focusProxy() const;
- Qt::ContextMenuPolicy contextMenuPolicy() const;
- void setContextMenuPolicy(Qt::ContextMenuPolicy policy);
-
- // Grab functions
- void grabMouse();
-#ifndef QT_NO_CURSOR
- void grabMouse(const QCursor &);
-#endif
- void releaseMouse();
- void grabKeyboard();
- void releaseKeyboard();
-#ifndef QT_NO_SHORTCUT
- int grabShortcut(const QKeySequence &key, Qt::ShortcutContext context = Qt::WindowShortcut);
- void releaseShortcut(int id);
- void setShortcutEnabled(int id, bool enable = true);
- void setShortcutAutoRepeat(int id, bool enable = true);
-#endif
- static QWidget *mouseGrabber();
- static QWidget *keyboardGrabber();
-
- // Update/refresh functions
- inline bool updatesEnabled() const;
- void setUpdatesEnabled(bool enable);
-
-#if 0 //def Q_WS_QWS
- void repaintUnclipped(const QRegion &, bool erase = true);
-#endif
-
-#ifndef QT_NO_GRAPHICSVIEW
- QGraphicsProxyWidget *graphicsProxyWidget() const;
-#endif
-
-public Q_SLOTS:
- void update();
- void repaint();
-
-public:
- inline void update(int x, int y, int w, int h);
- void update(const QRect&);
- void update(const QRegion&);
-
- void repaint(int x, int y, int w, int h);
- void repaint(const QRect &);
- void repaint(const QRegion &);
-
-public Q_SLOTS:
- // Widget management functions
-
- virtual void setVisible(bool visible);
- inline void setHidden(bool hidden) { setVisible(!hidden); }
-#ifndef Q_WS_WINCE
- inline void show() { setVisible(true); }
-#else
- void show();
-#endif
- inline void hide() { setVisible(false); }
- inline QT_MOC_COMPAT void setShown(bool shown) { setVisible(shown); }
-
- void showMinimized();
- void showMaximized();
- void showFullScreen();
- void showNormal();
-
- bool close();
- void raise();
- void lower();
-
-public:
- void stackUnder(QWidget*);
- void move(int x, int y);
- void move(const QPoint &);
- void resize(int w, int h);
- void resize(const QSize &);
- inline void setGeometry(int x, int y, int w, int h);
- void setGeometry(const QRect &);
- QByteArray saveGeometry() const;
- bool restoreGeometry(const QByteArray &geometry);
- void adjustSize();
- bool isVisible() const;
- bool isVisibleTo(QWidget*) const;
- // ### Qt 5: bool isVisibleTo(_const_ QWidget *) const
- inline bool isHidden() const;
-
- bool isMinimized() const;
- bool isMaximized() const;
- bool isFullScreen() const;
-
- Qt::WindowStates windowState() const;
- void setWindowState(Qt::WindowStates state);
- void overrideWindowState(Qt::WindowStates state);
-
- virtual QSize sizeHint() const;
- virtual QSize minimumSizeHint() const;
-
- QSizePolicy sizePolicy() const;
- void setSizePolicy(QSizePolicy);
- inline void setSizePolicy(QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical);
- virtual int heightForWidth(int) const;
-
- QRegion visibleRegion() const;
-
- void setContentsMargins(int left, int top, int right, int bottom);
- void setContentsMargins(const QMargins &margins);
- void getContentsMargins(int *left, int *top, int *right, int *bottom) const;
- QMargins contentsMargins() const;
-
- QRect contentsRect() const;
-
-public:
- QLayout *layout() const;
- void setLayout(QLayout *);
- void updateGeometry();
-
- void setParent(QWidget *parent);
- void setParent(QWidget *parent, Qt::WindowFlags f);
-
- void scroll(int dx, int dy);
- void scroll(int dx, int dy, const QRect&);
-
- // Misc. functions
-
- QWidget *focusWidget() const;
- QWidget *nextInFocusChain() const;
- QWidget *previousInFocusChain() const;
-
- // drag and drop
- bool acceptDrops() const;
- void setAcceptDrops(bool on);
-
-#ifndef QT_NO_ACTION
- //actions
- void addAction(QAction *action);
- void addActions(QList<QAction*> actions);
- void insertAction(QAction *before, QAction *action);
- void insertActions(QAction *before, QList<QAction*> actions);
- void removeAction(QAction *action);
- QList<QAction*> actions() const;
-#endif
-
- QWidget *parentWidget() const;
-
- void setWindowFlags(Qt::WindowFlags type);
- inline Qt::WindowFlags windowFlags() const;
- void overrideWindowFlags(Qt::WindowFlags type);
-
- inline Qt::WindowType windowType() const;
-
- static QWidget *find(WId);
-#ifdef QT3_SUPPORT
- static QT3_SUPPORT QWidgetMapper *wmapper();
-#endif
- inline QWidget *childAt(int x, int y) const;
- QWidget *childAt(const QPoint &p) const;
-
-#if defined(Q_WS_X11)
- const QX11Info &x11Info() const;
- Qt::HANDLE x11PictureHandle() const;
-#endif
-
-#if defined(Q_WS_MAC)
- Qt::HANDLE macQDHandle() const;
- Qt::HANDLE macCGHandle() const;
-#endif
-
-#if defined(Q_WS_WIN)
- HDC getDC() const;
- void releaseDC(HDC) const;
-#else
- Qt::HANDLE handle() const;
-#endif
-
- void setAttribute(Qt::WidgetAttribute, bool on = true);
- inline bool testAttribute(Qt::WidgetAttribute) const;
-
- QPaintEngine *paintEngine() const;
-
- void ensurePolished() const;
-
- QInputContext *inputContext();
- void setInputContext(QInputContext *);
-
- bool isAncestorOf(const QWidget *child) const;
-
-#ifdef QT_KEYPAD_NAVIGATION
- bool hasEditFocus() const;
- void setEditFocus(bool on);
-#endif
-
- bool autoFillBackground() const;
- void setAutoFillBackground(bool enabled);
-
- void setWindowSurface(QWindowSurface *surface);
- QWindowSurface *windowSurface() const;
-
-#if defined(Q_WS_QPA)
- void setPlatformWindow(QPlatformWindow *window);
- QPlatformWindow *platformWindow() const;
-
- void setPlatformWindowFormat(const QPlatformWindowFormat &format);
- QPlatformWindowFormat platformWindowFormat() const;
-
- friend class QDesktopScreenWidget;
-#endif
-
-Q_SIGNALS:
- void customContextMenuRequested(const QPoint &pos);
-
-protected:
- // Event handlers
- bool event(QEvent *);
- virtual void mousePressEvent(QMouseEvent *);
- virtual void mouseReleaseEvent(QMouseEvent *);
- virtual void mouseDoubleClickEvent(QMouseEvent *);
- virtual void mouseMoveEvent(QMouseEvent *);
-#ifndef QT_NO_WHEELEVENT
- virtual void wheelEvent(QWheelEvent *);
-#endif
- virtual void keyPressEvent(QKeyEvent *);
- virtual void keyReleaseEvent(QKeyEvent *);
- virtual void focusInEvent(QFocusEvent *);
- virtual void focusOutEvent(QFocusEvent *);
- virtual void enterEvent(QEvent *);
- virtual void leaveEvent(QEvent *);
- virtual void paintEvent(QPaintEvent *);
- virtual void moveEvent(QMoveEvent *);
- virtual void resizeEvent(QResizeEvent *);
- virtual void closeEvent(QCloseEvent *);
-#ifndef QT_NO_CONTEXTMENU
- virtual void contextMenuEvent(QContextMenuEvent *);
-#endif
-#ifndef QT_NO_TABLETEVENT
- virtual void tabletEvent(QTabletEvent *);
-#endif
-#ifndef QT_NO_ACTION
- virtual void actionEvent(QActionEvent *);
-#endif
-
-#ifndef QT_NO_DRAGANDDROP
- virtual void dragEnterEvent(QDragEnterEvent *);
- virtual void dragMoveEvent(QDragMoveEvent *);
- virtual void dragLeaveEvent(QDragLeaveEvent *);
- virtual void dropEvent(QDropEvent *);
-#endif
-
- virtual void showEvent(QShowEvent *);
- virtual void hideEvent(QHideEvent *);
-
-#if defined(Q_WS_MAC)
- virtual bool macEvent(EventHandlerCallRef, EventRef);
-#endif
-#if defined(Q_WS_WIN)
- virtual bool winEvent(MSG *message, long *result);
-#endif
-#if defined(Q_WS_X11)
- virtual bool x11Event(XEvent *);
-#endif
-#if defined(Q_WS_QWS)
- virtual bool qwsEvent(QWSEvent *);
-#endif
-
- // Misc. protected functions
- virtual void changeEvent(QEvent *);
-
- int metric(PaintDeviceMetric) const;
-
- virtual void inputMethodEvent(QInputMethodEvent *);
-public:
- virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const;
-
- Qt::InputMethodHints inputMethodHints() const;
- void setInputMethodHints(Qt::InputMethodHints hints);
-
-protected:
- void resetInputContext();
-protected Q_SLOTS:
- void updateMicroFocus();
-protected:
-
- void create(WId = 0, bool initializeWindow = true,
- bool destroyOldWindow = true);
- void destroy(bool destroyWindow = true,
- bool destroySubWindows = true);
-
- virtual bool focusNextPrevChild(bool next);
- inline bool focusNextChild() { return focusNextPrevChild(true); }
- inline bool focusPreviousChild() { return focusNextPrevChild(false); }
-
-protected:
- QWidget(QWidgetPrivate &d, QWidget* parent, Qt::WindowFlags f);
-private:
-
- bool testAttribute_helper(Qt::WidgetAttribute) const;
-
- QLayout *takeLayout();
-
- friend class QBackingStoreDevice;
- friend class QWidgetBackingStore;
- friend class QApplication;
- friend class QApplicationPrivate;
- friend class QBaseApplication;
- friend class QPainter;
- friend class QPainterPrivate;
- friend class QPixmap; // for QPixmap::fill()
- friend class QFontMetrics;
- friend class QFontInfo;
- friend class QETWidget;
- friend class QLayout;
- friend class QWidgetItem;
- friend class QWidgetItemV2;
- friend class QGLContext;
- friend class QGLWidget;
- friend class QGLWindowSurface;
- friend class QX11PaintEngine;
- friend class QWin32PaintEngine;
- friend class QShortcutPrivate;
- friend class QShortcutMap;
- friend class QWindowSurface;
- friend class QGraphicsProxyWidget;
- friend class QGraphicsProxyWidgetPrivate;
- friend class QStyleSheetStyle;
- friend struct QWidgetExceptionCleaner;
-#ifndef QT_NO_GESTURES
- friend class QGestureManager;
- friend class QWinNativePanGestureRecognizer;
-#endif // QT_NO_GESTURES
- friend class QWidgetEffectSourcePrivate;
-
-#ifdef Q_WS_MAC
- friend class QCoreGraphicsPaintEnginePrivate;
- friend QPoint qt_mac_posInWindow(const QWidget *w);
- friend OSWindowRef qt_mac_window_for(const QWidget *w);
- friend bool qt_mac_is_metal(const QWidget *w);
- friend OSViewRef qt_mac_nativeview_for(const QWidget *w);
- friend void qt_event_request_window_change(QWidget *widget);
- friend bool qt_mac_sendMacEventToWidget(QWidget *widget, EventRef ref);
- friend class QRasterWindowSurface;
- friend class QUnifiedToolbarSurface;
-#endif
-#ifdef Q_WS_QWS
- friend class QWSBackingStore;
- friend class QWSManager;
- friend class QWSManagerPrivate;
- friend class QDecoration;
- friend class QWSWindowSurface;
- friend class QScreen;
- friend class QVNCScreen;
- friend bool isWidgetOpaque(const QWidget *);
- friend class QGLWidgetPrivate;
-#endif
-#ifdef Q_OS_SYMBIAN
- friend class QSymbianControl;
- friend class QS60WindowSurface;
-#endif
-#ifdef Q_WS_X11
- friend void qt_net_update_user_time(QWidget *tlw, unsigned long timestamp);
- friend void qt_net_remove_user_time(QWidget *tlw);
- friend void qt_set_winid_on_widget(QWidget*, Qt::HANDLE);
-#endif
-
- friend Q_GUI_EXPORT QWidgetData *qt_qwidget_data(QWidget *widget);
- friend Q_GUI_EXPORT QWidgetPrivate *qt_widget_private(QWidget *widget);
-
-private:
- Q_DISABLE_COPY(QWidget)
- Q_PRIVATE_SLOT(d_func(), void _q_showIfNotHidden())
-#ifdef Q_OS_SYMBIAN
- Q_PRIVATE_SLOT(d_func(), void _q_delayedDestroy(WId winId))
-#endif
-
- QWidgetData *data;
-
-#ifdef QT3_SUPPORT
-public:
- inline QT3_SUPPORT bool isUpdatesEnabled() const { return updatesEnabled(); }
- QT3_SUPPORT QStyle *setStyle(const QString&);
- inline QT3_SUPPORT bool isVisibleToTLW() const;
- QT3_SUPPORT QRect visibleRect() const;
- inline QT3_SUPPORT void iconify() { showMinimized(); }
- inline QT3_SUPPORT void constPolish() const { ensurePolished(); }
- inline QT3_SUPPORT void polish() { ensurePolished(); }
- inline QT3_SUPPORT void reparent(QWidget *parent, Qt::WindowFlags f, const QPoint &p, bool showIt=false)
- { setParent(parent, f); setGeometry(p.x(),p.y(),width(),height()); if (showIt) show(); }
- inline QT3_SUPPORT void reparent(QWidget *parent, const QPoint &p, bool showIt=false)
- { setParent(parent, windowFlags() & ~Qt::WindowType_Mask); setGeometry(p.x(),p.y(),width(),height()); if (showIt) show(); }
- inline QT3_SUPPORT void recreate(QWidget *parent, Qt::WindowFlags f, const QPoint & p, bool showIt=false)
- { setParent(parent, f); setGeometry(p.x(),p.y(),width(),height()); if (showIt) show(); }
- inline QT3_SUPPORT void setSizePolicy(QSizePolicy::Policy hor, QSizePolicy::Policy ver, bool hfw)
- { QSizePolicy sp(hor, ver); sp.setHeightForWidth(hfw); setSizePolicy(sp);}
- inline QT3_SUPPORT bool hasMouse() const { return testAttribute(Qt::WA_UnderMouse); }
-#ifndef QT_NO_CURSOR
- inline QT3_SUPPORT bool ownCursor() const { return testAttribute(Qt::WA_SetCursor); }
-#endif
- inline QT3_SUPPORT bool ownFont() const { return testAttribute(Qt::WA_SetFont); }
- inline QT3_SUPPORT void unsetFont() { setFont(QFont()); }
- inline QT3_SUPPORT bool ownPalette() const { return testAttribute(Qt::WA_SetPalette); }
- inline QT3_SUPPORT void unsetPalette() { setPalette(QPalette()); }
- Qt::BackgroundMode QT3_SUPPORT backgroundMode() const;
- void QT3_SUPPORT setBackgroundMode(Qt::BackgroundMode, Qt::BackgroundMode = Qt::PaletteBackground);
- const QT3_SUPPORT QColor &eraseColor() const;
- void QT3_SUPPORT setEraseColor(const QColor &);
- const QT3_SUPPORT QColor &foregroundColor() const;
- const QT3_SUPPORT QPixmap *erasePixmap() const;
- void QT3_SUPPORT setErasePixmap(const QPixmap &);
- const QT3_SUPPORT QColor &paletteForegroundColor() const;
- void QT3_SUPPORT setPaletteForegroundColor(const QColor &);
- const QT3_SUPPORT QColor &paletteBackgroundColor() const;
- void QT3_SUPPORT setPaletteBackgroundColor(const QColor &);
- const QT3_SUPPORT QPixmap *paletteBackgroundPixmap() const;
- void QT3_SUPPORT setPaletteBackgroundPixmap(const QPixmap &);
- const QT3_SUPPORT QBrush& backgroundBrush() const;
- const QT3_SUPPORT QColor &backgroundColor() const;
- const QT3_SUPPORT QPixmap *backgroundPixmap() const;
- void QT3_SUPPORT setBackgroundPixmap(const QPixmap &);
- QT3_SUPPORT void setBackgroundColor(const QColor &);
- QT3_SUPPORT QColorGroup colorGroup() const;
- QT3_SUPPORT QWidget *parentWidget(bool sameWindow) const;
- inline QT3_SUPPORT void setKeyCompression(bool b) { setAttribute(Qt::WA_KeyCompression, b); }
- inline QT3_SUPPORT void setFont(const QFont &f, bool) { setFont(f); }
- inline QT3_SUPPORT void setPalette(const QPalette &p, bool) { setPalette(p); }
- enum BackgroundOrigin { WidgetOrigin, ParentOrigin, WindowOrigin, AncestorOrigin };
- inline QT3_SUPPORT void setBackgroundOrigin(BackgroundOrigin) {}
- inline QT3_SUPPORT BackgroundOrigin backgroundOrigin() const { return WindowOrigin; }
- inline QT3_SUPPORT QPoint backgroundOffset() const { return QPoint(); }
- inline QT3_SUPPORT void repaint(bool) { repaint(); }
- inline QT3_SUPPORT void repaint(int x, int y, int w, int h, bool) { repaint(x,y,w,h); }
- inline QT3_SUPPORT void repaint(const QRect &r, bool) { repaint(r); }
- inline QT3_SUPPORT void repaint(const QRegion &rgn, bool) { repaint(rgn); }
- QT3_SUPPORT void erase();
- inline QT3_SUPPORT void erase(int x, int y, int w, int h) { erase_helper(x, y, w, h); }
- QT3_SUPPORT void erase(const QRect &);
- QT3_SUPPORT void erase(const QRegion &);
- QT3_SUPPORT void drawText(const QPoint &p, const QString &s)
- { drawText_helper(p.x(), p.y(), s); }
- inline QT3_SUPPORT void drawText(int x, int y, const QString &s)
- { drawText_helper(x, y, s); }
- QT3_SUPPORT bool close(bool);
- inline QT3_SUPPORT QWidget *childAt(int x, int y, bool includeThis) const
- {
- QWidget *w = childAt(x, y);
- return w ? w : ((includeThis && rect().contains(x,y))?const_cast<QWidget*>(this):0);
- }
- inline QT3_SUPPORT QWidget *childAt(const QPoint &p, bool includeThis) const
- {
- QWidget *w = childAt(p);
- return w ? w : ((includeThis && rect().contains(p))?const_cast<QWidget*>(this):0);
- }
- inline QT3_SUPPORT void setCaption(const QString &c) { setWindowTitle(c); }
- QT3_SUPPORT void setIcon(const QPixmap &i);
- inline QT3_SUPPORT void setIconText(const QString &it) { setWindowIconText(it); }
- inline QT3_SUPPORT QString caption() const { return windowTitle(); }
- QT3_SUPPORT const QPixmap *icon() const;
- inline QT3_SUPPORT QString iconText() const { return windowIconText(); }
- inline QT3_SUPPORT void setInputMethodEnabled(bool b) { setAttribute(Qt::WA_InputMethodEnabled, b); }
- inline QT3_SUPPORT bool isInputMethodEnabled() const { return testAttribute(Qt::WA_InputMethodEnabled); }
- inline QT3_SUPPORT void setActiveWindow() { activateWindow(); }
- inline QT3_SUPPORT bool isShown() const { return !isHidden(); }
- inline QT3_SUPPORT bool isDialog() const { return windowType() == Qt::Dialog; }
- inline QT3_SUPPORT bool isPopup() const { return windowType() == Qt::Popup; }
- inline QT3_SUPPORT bool isDesktop() const { return windowType() == Qt::Desktop; }
-
-
-private:
- void drawText_helper(int x, int y, const QString &);
- void erase_helper(int x, int y, int w, int h);
-#endif // QT3_SUPPORT
-
-protected:
- virtual void styleChange(QStyle&); // compat
- virtual void enabledChange(bool); // compat
- virtual void paletteChange(const QPalette &); // compat
- virtual void fontChange(const QFont &); // compat
- virtual void windowActivationChange(bool); // compat
- virtual void languageChange(); // compat
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QWidget::RenderFlags)
-
-template <> inline QWidget *qobject_cast<QWidget*>(QObject *o)
-{
- if (!o || !o->isWidgetType()) return 0;
- return static_cast<QWidget*>(o);
-}
-template <> inline const QWidget *qobject_cast<const QWidget*>(const QObject *o)
-{
- if (!o || !o->isWidgetType()) return 0;
- return static_cast<const QWidget*>(o);
-}
-
-inline QWidget *QWidget::childAt(int ax, int ay) const
-{ return childAt(QPoint(ax, ay)); }
-
-inline Qt::WindowType QWidget::windowType() const
-{ return static_cast<Qt::WindowType>(int(data->window_flags & Qt::WindowType_Mask)); }
-inline Qt::WindowFlags QWidget::windowFlags() const
-{ return data->window_flags; }
-
-inline bool QWidget::isTopLevel() const
-{ return (windowType() & Qt::Window); }
-
-inline bool QWidget::isWindow() const
-{ return (windowType() & Qt::Window); }
-
-inline bool QWidget::isEnabled() const
-{ return !testAttribute(Qt::WA_Disabled); }
-
-inline bool QWidget::isModal() const
-{ return data->window_modality != Qt::NonModal; }
-
-inline bool QWidget::isEnabledToTLW() const
-{ return isEnabled(); }
-
-inline int QWidget::minimumWidth() const
-{ return minimumSize().width(); }
-
-inline int QWidget::minimumHeight() const
-{ return minimumSize().height(); }
-
-inline int QWidget::maximumWidth() const
-{ return maximumSize().width(); }
-
-inline int QWidget::maximumHeight() const
-{ return maximumSize().height(); }
-
-inline void QWidget::setMinimumSize(const QSize &s)
-{ setMinimumSize(s.width(),s.height()); }
-
-inline void QWidget::setMaximumSize(const QSize &s)
-{ setMaximumSize(s.width(),s.height()); }
-
-inline void QWidget::setSizeIncrement(const QSize &s)
-{ setSizeIncrement(s.width(),s.height()); }
-
-inline void QWidget::setBaseSize(const QSize &s)
-{ setBaseSize(s.width(),s.height()); }
-
-inline const QFont &QWidget::font() const
-{ return data->fnt; }
-
-inline QFontMetrics QWidget::fontMetrics() const
-{ return QFontMetrics(data->fnt); }
-
-inline QFontInfo QWidget::fontInfo() const
-{ return QFontInfo(data->fnt); }
-
-inline void QWidget::setMouseTracking(bool enable)
-{ setAttribute(Qt::WA_MouseTracking, enable); }
-
-inline bool QWidget::hasMouseTracking() const
-{ return testAttribute(Qt::WA_MouseTracking); }
-
-inline bool QWidget::underMouse() const
-{ return testAttribute(Qt::WA_UnderMouse); }
-
-inline bool QWidget::updatesEnabled() const
-{ return !testAttribute(Qt::WA_UpdatesDisabled); }
-
-inline void QWidget::update(int ax, int ay, int aw, int ah)
-{ update(QRect(ax, ay, aw, ah)); }
-
-inline bool QWidget::isVisible() const
-{ return testAttribute(Qt::WA_WState_Visible); }
-
-inline bool QWidget::isHidden() const
-{ return testAttribute(Qt::WA_WState_Hidden); }
-
-inline void QWidget::move(int ax, int ay)
-{ move(QPoint(ax, ay)); }
-
-inline void QWidget::resize(int w, int h)
-{ resize(QSize(w, h)); }
-
-inline void QWidget::setGeometry(int ax, int ay, int aw, int ah)
-{ setGeometry(QRect(ax, ay, aw, ah)); }
-
-inline QRect QWidget::rect() const
-{ return QRect(0,0,data->crect.width(),data->crect.height()); }
-
-inline const QRect &QWidget::geometry() const
-{ return data->crect; }
-
-inline QSize QWidget::size() const
-{ return data->crect.size(); }
-
-inline int QWidget::width() const
-{ return data->crect.width(); }
-
-inline int QWidget::height() const
-{ return data->crect.height(); }
-
-inline QWidget *QWidget::parentWidget() const
-{ return static_cast<QWidget *>(QObject::parent()); }
-
-inline void QWidget::setSizePolicy(QSizePolicy::Policy hor, QSizePolicy::Policy ver)
-{ setSizePolicy(QSizePolicy(hor, ver)); }
-
-inline bool QWidget::testAttribute(Qt::WidgetAttribute attribute) const
-{
- if (attribute < int(8*sizeof(uint)))
- return data->widget_attributes & (1<<attribute);
- return testAttribute_helper(attribute);
-}
-
-#ifdef QT3_SUPPORT
-inline bool QWidget::isVisibleToTLW() const
-{ return isVisible(); }
-inline QWidget *QWidget::parentWidget(bool sameWindow) const
-{
- if (sameWindow && isWindow())
- return 0;
- return static_cast<QWidget *>(QObject::parent());
-}
-inline QColorGroup QWidget::colorGroup() const
-{ return QColorGroup(palette()); }
-inline void QWidget::setPaletteForegroundColor(const QColor &c)
-{ QPalette p = palette(); p.setColor(foregroundRole(), c); setPalette(p); }
-inline const QBrush& QWidget::backgroundBrush() const { return palette().brush(backgroundRole()); }
-inline void QWidget::setBackgroundPixmap(const QPixmap &pm)
-{ QPalette p = palette(); p.setBrush(backgroundRole(), QBrush(pm)); setPalette(p); }
-inline const QPixmap *QWidget::backgroundPixmap() const { return 0; }
-inline void QWidget::setBackgroundColor(const QColor &c)
-{ QPalette p = palette(); p.setColor(backgroundRole(), c); setPalette(p); }
-inline const QColor & QWidget::backgroundColor() const { return palette().color(backgroundRole()); }
-inline const QColor &QWidget::foregroundColor() const { return palette().color(foregroundRole());}
-inline const QColor &QWidget::eraseColor() const { return palette().color(backgroundRole()); }
-inline void QWidget::setEraseColor(const QColor &c)
-{ QPalette p = palette(); p.setColor(backgroundRole(), c); setPalette(p); }
-inline const QPixmap *QWidget::erasePixmap() const { return 0; }
-inline void QWidget::setErasePixmap(const QPixmap &pm)
-{ QPalette p = palette(); p.setBrush(backgroundRole(), QBrush(pm)); setPalette(p); }
-inline const QColor &QWidget::paletteForegroundColor() const { return palette().color(foregroundRole());}
-inline const QColor &QWidget::paletteBackgroundColor() const { return palette().color(backgroundRole()); }
-inline void QWidget::setPaletteBackgroundColor(const QColor &c)
-{ QPalette p = palette(); p.setColor(backgroundRole(), c); setPalette(p); }
-inline const QPixmap *QWidget::paletteBackgroundPixmap() const
-{ return 0; }
-inline void QWidget::setPaletteBackgroundPixmap(const QPixmap &pm)
-{ QPalette p = palette(); p.setBrush(backgroundRole(), QBrush(pm)); setPalette(p); }
-inline QT3_SUPPORT void QWidget::erase() { erase_helper(0, 0, data->crect.width(), data->crect.height()); }
-inline QT3_SUPPORT void QWidget::erase(const QRect &r) { erase_helper(r.x(), r.y(), r.width(), r.height()); }
-#endif
-
-#define QWIDGETSIZE_MAX ((1<<24)-1)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QWIDGET_H
diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h
deleted file mode 100644
index 919f8bc3da..0000000000
--- a/src/gui/kernel/qwidget_p.h
+++ /dev/null
@@ -1,1035 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWIDGET_P_H
-#define QWIDGET_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header
-// file may change from version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "QtGui/qwidget.h"
-#include "private/qobject_p.h"
-#include "QtCore/qrect.h"
-#include "QtCore/qlocale.h"
-#include "QtCore/qset.h"
-#include "QtGui/qregion.h"
-#include "QtGui/qsizepolicy.h"
-#include "QtGui/qstyle.h"
-#include "QtGui/qapplication.h"
-#include <private/qgraphicseffect_p.h>
-#include "QtGui/qgraphicsproxywidget.h"
-#include "QtGui/qgraphicsscene.h"
-#include "QtGui/qgraphicsview.h"
-#include <private/qgesture_p.h>
-
-#ifdef Q_WS_WIN
-#include "QtCore/qt_windows.h"
-#include <private/qdnd_p.h>
-#endif // Q_WS_WIN
-
-#ifdef Q_WS_X11
-#include "QtGui/qx11info_x11.h"
-#endif
-
-#ifdef Q_WS_MAC
-#include <private/qt_mac_p.h>
-#endif
-
-#if defined(Q_WS_QWS)
-#include "QtGui/qinputcontext.h"
-#include "QtGui/qscreen_qws.h"
-#endif
-
-#if defined(Q_OS_SYMBIAN)
-class RDrawableWindow;
-class CCoeControl;
-#endif
-
-QT_BEGIN_NAMESPACE
-
-// Extra QWidget data
-// - to minimize memory usage for members that are seldom used.
-// - top-level widgets have extra extra data to reduce cost further
-#if defined(Q_WS_QWS)
-class QWSManager;
-#endif
-#if defined(Q_WS_MAC)
-class QCoreGraphicsPaintEnginePrivate;
-#endif
-#if defined(Q_WS_QPA)
-class QPlatformWindow;
-#endif
-class QPaintEngine;
-class QPixmap;
-class QWidgetBackingStore;
-class QGraphicsProxyWidget;
-class QWidgetItemV2;
-
-class QStyle;
-
-class QUnifiedToolbarSurface;
-
-class Q_AUTOTEST_EXPORT QWidgetBackingStoreTracker
-{
-
-public:
- QWidgetBackingStoreTracker();
- ~QWidgetBackingStoreTracker();
-
- void create(QWidget *tlw);
- void destroy();
-
- void registerWidget(QWidget *w);
- void unregisterWidget(QWidget *w);
- void unregisterWidgetSubtree(QWidget *w);
-
- inline QWidgetBackingStore* data()
- {
- return m_ptr;
- }
-
- inline QWidgetBackingStore* operator->()
- {
- return m_ptr;
- }
-
- inline QWidgetBackingStore& operator*()
- {
- return *m_ptr;
- }
-
- inline operator bool() const
- {
- return (0 != m_ptr);
- }
-
-private:
- Q_DISABLE_COPY(QWidgetBackingStoreTracker)
-
-private:
- QWidgetBackingStore* m_ptr;
- QSet<QWidget *> m_widgets;
-};
-
-struct QTLWExtra {
- // *************************** Cross-platform variables *****************************
-
- // Regular pointers (keep them together to avoid gaps on 64 bits architectures).
- QIcon *icon; // widget icon
- QPixmap *iconPixmap;
- QWidgetBackingStoreTracker backingStore;
- QWindowSurface *windowSurface;
- QPainter *sharedPainter;
-
- // Implicit pointers (shared_null).
- QString caption; // widget caption
- QString iconText; // widget icon text
- QString role; // widget role
- QString filePath; // widget file path
-
- // Other variables.
- short incw, inch; // size increments
- short basew, baseh; // base sizes
- // frame strut, don't use these directly, use QWidgetPrivate::frameStrut() instead.
- QRect frameStrut;
- QRect normalGeometry; // used by showMin/maximized/FullScreen
- Qt::WindowFlags savedFlags; // Save widget flags while showing fullscreen
-
- // *************************** Cross-platform bit fields ****************************
- uint opacity : 8;
- uint posFromMove : 1;
- uint sizeAdjusted : 1;
- uint inTopLevelResize : 1;
- uint inRepaint : 1;
- uint embedded : 1;
-
- // *************************** Platform specific values (bit fields first) **********
-#if defined(Q_WS_X11) // <----------------------------------------------------------- X11
- uint spont_unmapped: 1; // window was spontaneously unmapped
- uint dnd : 1; // DND properties installed
- uint validWMState : 1; // is WM_STATE valid?
- uint waitingForMapNotify : 1; // show() has been called, haven't got the MapNotify yet
- WId parentWinId; // parent window Id (valid after reparenting)
- WId userTimeWindow; // window id that contains user-time timestamp when WM supports a _NET_WM_USER_TIME_WINDOW atom
- QPoint fullScreenOffset;
-#ifndef QT_NO_XSYNC
- WId syncUpdateCounter;
- ulong syncRequestTimestamp;
- qint32 newCounterValueHi;
- quint32 newCounterValueLo;
-#endif
-#elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN
- uint hotkeyRegistered: 1; // Hot key from the STARTUPINFO has been registered.
- HICON winIconBig; // internal big Windows icon
- HICON winIconSmall; // internal small Windows icon
-#elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC
- uint resizer : 4;
- uint isSetGeometry : 1;
- uint isMove : 1;
- quint32 wattr;
- quint32 wclass;
- WindowGroupRef group;
- IconRef windowIcon; // the current window icon, if set with setWindowIcon_sys.
- quint32 savedWindowAttributesFromMaximized; // Saved attributes from when the calling updateMaximizeButton_sys()
-#ifdef QT_MAC_USE_COCOA
- // This value is just to make sure we maximize and restore to the right location, yet we allow apps to be maximized and
- // manually resized.
- // The name is misleading, since this is set when maximizing the window. It is a hint to saveGeometry(..) to record the
- // starting position as 0,0 instead of the normal starting position.
- bool wasMaximized;
-#endif // QT_MAC_USE_COCOA
-
-#elif defined(Q_WS_QWS) // <--------------------------------------------------------- QWS
-#ifndef QT_NO_QWS_MANAGER
- QWSManager *qwsManager;
-#endif
-#elif defined(Q_OS_SYMBIAN)
- uint inExpose : 1; // Prevents drawing recursion
- uint nativeWindowTransparencyEnabled : 1; // Tracks native window transparency
-#elif defined(Q_WS_QPA)
- QPlatformWindow *platformWindow;
- QPlatformWindowFormat platformWindowFormat;
- quint32 screenIndex; // index in qplatformscreenlist
-#endif
-};
-
-struct QWExtra {
- // *************************** Cross-platform variables *****************************
-
- // Regular pointers (keep them together to avoid gaps on 64 bits architectures).
- void *glContext; // if the widget is hijacked by QGLWindowSurface
- QTLWExtra *topextra; // only useful for TLWs
-#ifndef QT_NO_GRAPHICSVIEW
- QGraphicsProxyWidget *proxyWidget; // if the widget is embedded
-#endif
-#ifndef QT_NO_CURSOR
- QCursor *curs;
-#endif
- QPointer<QStyle> style;
- QPointer<QWidget> focus_proxy;
-
- // Implicit pointers (shared_empty/shared_null).
- QRegion mask; // widget mask
- QString styleSheet;
-
- // Other variables.
- qint32 minw;
- qint32 minh; // minimum size
- qint32 maxw;
- qint32 maxh; // maximum size
- quint16 customDpiX;
- quint16 customDpiY;
- QSize staticContentsSize;
-
- // *************************** Cross-platform bit fields ****************************
- uint explicitMinSize : 2;
- uint explicitMaxSize : 2;
- uint autoFillBackground : 1;
- uint nativeChildrenForced : 1;
- uint inRenderWithPainter : 1;
- uint hasMask : 1;
-
- // *************************** Platform specific values (bit fields first) **********
-#if defined(Q_WS_WIN) // <----------------------------------------------------------- WIN
-#ifndef QT_NO_DRAGANDDROP
- QOleDropTarget *dropTarget; // drop target
- QList<QPointer<QWidget> > oleDropWidgets;
-#endif
-#elif defined(Q_WS_X11) // <--------------------------------------------------------- X11
- uint compress_events : 1;
- WId xDndProxy; // XDND forwarding to embedded windows
-#elif defined(Q_WS_MAC) // <------------------------------------------------------ MAC
-#ifdef QT_MAC_USE_COCOA
- // Cocoa Mask stuff
- QImage maskBits;
- CGImageRef imageMask;
-#endif
-#elif defined(Q_OS_SYMBIAN) // <----------------------------------------------------- Symbian
- uint activated : 1; // RWindowBase::Activated has been called
-
- /**
- * If this bit is set, each native widget receives the signals from the
- * Symbian control immediately before and immediately after draw ops are
- * sent to the window server for this control:
- * void beginNativePaintEvent(const QRect &paintRect);
- * void endNativePaintEvent(const QRect &paintRect);
- */
- uint receiveNativePaintEvents : 1;
-
- /**
- * Defines the behaviour of QSymbianControl::Draw.
- */
- enum NativePaintMode {
- /**
- * Normal drawing mode: blits the required region of the backing store
- * via WSERV.
- */
- Blit,
-
- /**
- * Disable drawing for this widget.
- */
- Disable,
-
- /**
- * Paint zeros into the WSERV framebuffer, using BitGDI APIs. For windows
- * with an EColor16MU display mode, zero is written only into the R, G and B
- * channels of the pixel.
- */
- ZeroFill,
-
- /**
- * Blit backing store, propagating alpha channel into the framebuffer.
- */
- BlitWriteAlpha,
-
- Default = Blit
- };
-
- NativePaintMode nativePaintMode;
-
-#endif
-};
-
-/*!
- \internal
-
- Returns true if \a p or any of its parents enable the
- Qt::BypassGraphicsProxyWidget window flag. Used in QWidget::show() and
- QWidget::setParent() to determine whether it's necessary to embed the
- widget into a QGraphicsProxyWidget or not.
-*/
-static inline bool bypassGraphicsProxyWidget(const QWidget *p)
-{
- while (p) {
- if (p->windowFlags() & Qt::BypassGraphicsProxyWidget)
- return true;
- p = p->parentWidget();
- }
- return false;
-}
-
-class Q_GUI_EXPORT QWidgetPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QWidget)
-
-public:
- // *************************** Cross-platform ***************************************
- enum DrawWidgetFlags {
- DrawAsRoot = 0x01,
- DrawPaintOnScreen = 0x02,
- DrawRecursive = 0x04,
- DrawInvisible = 0x08,
- DontSubtractOpaqueChildren = 0x10,
- DontSetCompositionMode = 0x20,
- DontDrawOpaqueChildren = 0x40,
- DontDrawNativeChildren = 0x80
- };
-
- enum CloseMode {
- CloseNoEvent,
- CloseWithEvent,
- CloseWithSpontaneousEvent
- };
-
- enum Direction {
- DirectionNorth = 0x01,
- DirectionEast = 0x10,
- DirectionSouth = 0x02,
- DirectionWest = 0x20
- };
-
- // Functions.
- explicit QWidgetPrivate(int version = QObjectPrivateVersion);
- ~QWidgetPrivate();
-
- QWExtra *extraData() const;
- QTLWExtra *topData() const;
- QTLWExtra *maybeTopData() const;
- QPainter *sharedPainter() const;
- void setSharedPainter(QPainter *painter);
- QWidgetBackingStore *maybeBackingStore() const;
- void init(QWidget *desktopWidget, Qt::WindowFlags f);
- void create_sys(WId window, bool initializeWindow, bool destroyOldWindow);
- void createRecursively();
- void createWinId(WId id = 0);
-
- void createTLExtra();
- void createExtra();
- void deleteExtra();
- void createSysExtra();
- void deleteSysExtra();
- void createTLSysExtra();
- void deleteTLSysExtra();
- void updateSystemBackground();
- void propagatePaletteChange();
-
- void setPalette_helper(const QPalette &);
- void resolvePalette();
- QPalette naturalWidgetPalette(uint inheritedMask) const;
-
- void setMask_sys(const QRegion &);
-#ifdef Q_OS_SYMBIAN
- void setSoftKeys_sys(const QList<QAction*> &softkeys);
- void activateSymbianWindow(WId wid = 0);
- void _q_delayedDestroy(WId winId);
-#endif
-
- void raise_sys();
- void lower_sys();
- void stackUnder_sys(QWidget *);
-
- void setFocus_sys();
-
- void updateFont(const QFont &);
- inline void setFont_helper(const QFont &font) {
- if (data.fnt == font && data.fnt.resolve() == font.resolve())
- return;
- updateFont(font);
- }
- void resolveFont();
- QFont naturalWidgetFont(uint inheritedMask) const;
-
- void setLayoutDirection_helper(Qt::LayoutDirection);
- void resolveLayoutDirection();
-
- void setLocale_helper(const QLocale &l, bool forceUpdate = false);
- void resolveLocale();
-
- void setStyle_helper(QStyle *newStyle, bool propagate, bool metalHack = false);
- void inheritStyle();
-
- void setUpdatesEnabled_helper(bool );
-
- void paintBackground(QPainter *, const QRegion &, int flags = DrawAsRoot) const;
- bool isAboutToShow() const;
- QRegion prepareToRender(const QRegion &region, QWidget::RenderFlags renderFlags);
- void render_helper(QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion,
- QWidget::RenderFlags renderFlags);
- void render(QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion,
- QWidget::RenderFlags renderFlags, bool readyToRender);
- void drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags,
- QPainter *sharedPainter = 0, QWidgetBackingStore *backingStore = 0);
-
-
- void paintSiblingsRecursive(QPaintDevice *pdev, const QObjectList& children, int index,
- const QRegion &rgn, const QPoint &offset, int flags
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- , const QWindowSurface *currentSurface
-#endif
- , QPainter *sharedPainter, QWidgetBackingStore *backingStore);
-
-
- QPainter *beginSharedPainter();
- bool endSharedPainter();
-#ifndef QT_NO_GRAPHICSVIEW
- static QGraphicsProxyWidget * nearestGraphicsProxyWidget(const QWidget *origin);
-#endif
- QWindowSurface *createDefaultWindowSurface();
- QWindowSurface *createDefaultWindowSurface_sys();
- void repaint_sys(const QRegion &rgn);
-
- QRect clipRect() const;
- QRegion clipRegion() const;
- void subtractOpaqueChildren(QRegion &rgn, const QRect &clipRect) const;
- void subtractOpaqueSiblings(QRegion &source, bool *hasDirtySiblingsAbove = 0,
- bool alsoNonOpaque = false) const;
- void clipToEffectiveMask(QRegion &region) const;
- void updateIsOpaque();
- void setOpaque(bool opaque);
- void updateIsTranslucent();
- bool paintOnScreen() const;
-#ifndef QT_NO_GRAPHICSEFFECT
- void invalidateGraphicsEffectsRecursively();
-#endif //QT_NO_GRAPHICSEFFECT
-
- const QRegion &getOpaqueChildren() const;
- void setDirtyOpaqueRegion();
-
- bool close_helper(CloseMode mode);
-
- void setWindowIcon_helper();
- void setWindowIcon_sys(bool forceReset = false);
- void setWindowOpacity_sys(qreal opacity);
- void adjustQuitOnCloseAttribute();
-
- void scrollChildren(int dx, int dy);
- void moveRect(const QRect &, int dx, int dy);
- void scrollRect(const QRect &, int dx, int dy);
- void invalidateBuffer_resizeHelper(const QPoint &oldPos, const QSize &oldSize);
- // ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
- void invalidateBuffer(const QRegion &);
- void invalidateBuffer(const QRect &);
- bool isOverlapped(const QRect&) const;
- void syncBackingStore();
- void syncBackingStore(const QRegion &region);
-
- void reparentFocusWidgets(QWidget *oldtlw);
-
- static int pointToRect(const QPoint &p, const QRect &r);
-
- void setWinId(WId);
- void showChildren(bool spontaneous);
- void hideChildren(bool spontaneous);
- void setParent_sys(QWidget *parent, Qt::WindowFlags);
- void scroll_sys(int dx, int dy);
- void scroll_sys(int dx, int dy, const QRect &r);
- void deactivateWidgetCleanup();
- void setGeometry_sys(int, int, int, int, bool);
- void sendPendingMoveAndResizeEvents(bool recursive = false, bool disableUpdates = false);
- void activateChildLayoutsRecursively();
- void show_recursive();
- void show_helper();
- void show_sys();
- void hide_sys();
- void hide_helper();
- void _q_showIfNotHidden();
-
- void setEnabled_helper(bool);
- void registerDropSite(bool);
- static void adjustFlags(Qt::WindowFlags &flags, QWidget *w = 0);
-
- void updateFrameStrut();
- QRect frameStrut() const;
-
-#ifdef QT_KEYPAD_NAVIGATION
- static bool navigateToDirection(Direction direction);
- static QWidget *widgetInNavigationDirection(Direction direction);
- static bool canKeypadNavigate(Qt::Orientation orientation);
- static bool inTabWidget(QWidget *widget);
-#endif
-
- void setWindowIconText_sys(const QString &cap);
- void setWindowIconText_helper(const QString &cap);
- void setWindowTitle_sys(const QString &cap);
-
-#ifndef QT_NO_CURSOR
- void setCursor_sys(const QCursor &cursor);
- void unsetCursor_sys();
-#endif
-
- void setWindowTitle_helper(const QString &cap);
- void setWindowFilePath_helper(const QString &filePath);
-
- bool setMinimumSize_helper(int &minw, int &minh);
- bool setMaximumSize_helper(int &maxw, int &maxh);
- virtual bool hasHeightForWidth() const;
- void setConstraints_sys();
- bool pointInsideRectAndMask(const QPoint &) const;
- QWidget *childAt_helper(const QPoint &, bool) const;
- QWidget *childAtRecursiveHelper(const QPoint &p, bool, bool includeFrame = false) const;
- void updateGeometry_helper(bool forceUpdate);
-
- void getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const;
- void setLayoutItemMargins(int left, int top, int right, int bottom);
- void setLayoutItemMargins(QStyle::SubElement element, const QStyleOption *opt = 0);
-
- // aboutToDestroy() is called just before the contents of
- // QWidget::destroy() is executed. It's used to signal QWidget
- // sub-classes that their internals are about to be released.
- virtual void aboutToDestroy() {}
-
- QInputContext *assignedInputContext() const;
- QInputContext *inputContext() const;
- inline QWidget *effectiveFocusWidget() {
- QWidget *w = q_func();
- while (w->focusProxy())
- w = w->focusProxy();
- return w;
- }
-
- void setModal_sys();
-
- // This is an helper function that return the available geometry for
- // a widget and takes care is this one is in QGraphicsView.
- // If the widget is not embed in a scene then the geometry available is
- // null, we let QDesktopWidget decide for us.
- static QRect screenGeometry(const QWidget *widget)
- {
- QRect screen;
-#ifndef QT_NO_GRAPHICSVIEW
- QGraphicsProxyWidget *ancestorProxy = widget->d_func()->nearestGraphicsProxyWidget(widget);
- //It's embedded if it has an ancestor
- if (ancestorProxy) {
- if (!bypassGraphicsProxyWidget(widget) && ancestorProxy->scene() != 0) {
- // One view, let be smart and return the viewport rect then the popup is aligned
- if (ancestorProxy->scene()->views().size() == 1) {
- QGraphicsView *view = ancestorProxy->scene()->views().at(0);
- screen = view->mapToScene(view->viewport()->rect()).boundingRect().toRect();
- } else {
- screen = ancestorProxy->scene()->sceneRect().toRect();
- }
- }
- }
-#endif
- return screen;
- }
-
- inline void setRedirected(QPaintDevice *replacement, const QPoint &offset)
- {
- Q_ASSERT(q_func()->testAttribute(Qt::WA_WState_InPaintEvent));
- redirectDev = replacement;
- redirectOffset = offset;
- }
-
- inline QPaintDevice *redirected(QPoint *offset) const
- {
- if (offset)
- *offset = redirectDev ? redirectOffset : QPoint();
- return redirectDev;
- }
-
- inline void restoreRedirected()
- { redirectDev = 0; }
-
- inline void enforceNativeChildren()
- {
- if (!extra)
- createExtra();
-
- if (extra->nativeChildrenForced)
- return;
- extra->nativeChildrenForced = 1;
-
- for (int i = 0; i < children.size(); ++i) {
- if (QWidget *child = qobject_cast<QWidget *>(children.at(i)))
- child->setAttribute(Qt::WA_NativeWindow);
- }
- }
-
- inline bool nativeChildrenForced() const
- {
- return extra ? extra->nativeChildrenForced : false;
- }
-
- inline QRect effectiveRectFor(const QRect &rect) const
- {
-#ifndef QT_NO_GRAPHICSEFFECT
- if (graphicsEffect && graphicsEffect->isEnabled())
- return graphicsEffect->boundingRectFor(rect).toAlignedRect();
-#endif //QT_NO_GRAPHICSEFFECT
- return rect;
- }
-
- QSize adjustedSize() const;
-
- inline void handleSoftwareInputPanel(Qt::MouseButton button, bool clickCausedFocus)
- {
- Q_Q(QWidget);
- if (button == Qt::LeftButton && qApp->autoSipEnabled()) {
- QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
- q->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
- if (!clickCausedFocus || behavior == QStyle::RSIP_OnMouseClick) {
- QEvent event(QEvent::RequestSoftwareInputPanel);
- QApplication::sendEvent(q, &event);
- }
- }
- }
-
-#ifndef Q_WS_QWS // Almost cross-platform :-)
- void setWSGeometry(bool dontShow=false, const QRect &oldRect = QRect());
-
- inline QPoint mapToWS(const QPoint &p) const
- { return p - data.wrect.topLeft(); }
-
- inline QPoint mapFromWS(const QPoint &p) const
- { return p + data.wrect.topLeft(); }
-
- inline QRect mapToWS(const QRect &r) const
- { QRect rr(r); rr.translate(-data.wrect.topLeft()); return rr; }
-
- inline QRect mapFromWS(const QRect &r) const
- { QRect rr(r); rr.translate(data.wrect.topLeft()); return rr; }
-#endif
-
- // Variables.
- // Regular pointers (keep them together to avoid gaps on 64 bit architectures).
- QWExtra *extra;
- QWidget *focus_next;
- QWidget *focus_prev;
- QWidget *focus_child;
- QLayout *layout;
- QRegion *needsFlush;
- QPaintDevice *redirectDev;
- QWidgetItemV2 *widgetItem;
- QPaintEngine *extraPaintEngine;
- mutable const QMetaObject *polished;
- QGraphicsEffect *graphicsEffect;
- // All widgets are added into the allWidgets set. Once
- // they receive a window id they are also added to the mapper.
- // This should just ensure that all widgets are deleted by QApplication
- static QWidgetMapper *mapper;
- static QWidgetSet *allWidgets;
-#if !defined(QT_NO_IM)
- QPointer<QInputContext> ic;
- Qt::InputMethodHints imHints;
-#endif
-#ifdef QT_KEYPAD_NAVIGATION
- static QPointer<QWidget> editingWidget;
-#endif
-
- // Implicit pointers (shared_null/shared_empty).
- QRegion opaqueChildren;
- QRegion dirty;
-#ifndef QT_NO_TOOLTIP
- QString toolTip;
-#endif
-#ifndef QT_NO_STATUSTIP
- QString statusTip;
-#endif
-#ifndef QT_NO_WHATSTHIS
- QString whatsThis;
-#endif
-#ifndef QT_NO_ACCESSIBILITY
- QString accessibleName;
- QString accessibleDescription;
-#endif
-
- // Other variables.
- uint inheritedFontResolveMask;
- uint inheritedPaletteResolveMask;
- short leftmargin;
- short topmargin;
- short rightmargin;
- short bottommargin;
- signed char leftLayoutItemMargin;
- signed char topLayoutItemMargin;
- signed char rightLayoutItemMargin;
- signed char bottomLayoutItemMargin;
- static int instanceCounter; // Current number of widget instances
- static int maxInstances; // Maximum number of widget instances
- Qt::HANDLE hd;
- QWidgetData data;
- QSizePolicy size_policy;
- QLocale locale;
- QPoint redirectOffset;
-#ifndef QT_NO_ACTION
- QList<QAction*> actions;
-#endif
-#ifndef QT_NO_GESTURES
- QMap<Qt::GestureType, Qt::GestureFlags> gestureContext;
-#endif
-
- // Bit fields.
- uint high_attributes[4]; // the low ones are in QWidget::widget_attributes
- QPalette::ColorRole fg_role : 8;
- QPalette::ColorRole bg_role : 8;
- uint dirtyOpaqueChildren : 1;
- uint isOpaque : 1;
- uint inDirtyList : 1;
- uint isScrolled : 1;
- uint isMoved : 1;
- uint isGLWidget : 1;
- uint usesDoubleBufferedGLContext : 1;
-#ifndef QT_NO_IM
- uint inheritsInputMethodHints : 1;
-#endif
-
- // *************************** Platform specific ************************************
-#if defined(Q_WS_X11) // <----------------------------------------------------------- X11
- QX11Info xinfo;
- Qt::HANDLE picture;
- static QWidget *mouseGrabber;
- static QWidget *keyboardGrabber;
-
- void setWindowRole();
- void sendStartupMessage(const char *message) const;
- void setNetWmWindowTypes();
- void x11UpdateIsOpaque();
- bool isBackgroundInherited() const;
- void updateX11AcceptFocus();
- QPoint mapToGlobal(const QPoint &pos) const;
- QPoint mapFromGlobal(const QPoint &pos) const;
-#elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN
- uint noPaintOnScreen : 1; // see qwidget_win.cpp ::paintEngine()
-#ifndef QT_NO_GESTURES
- uint nativeGesturePanEnabled : 1;
-#endif
- bool shouldShowMaximizeButton();
- void winUpdateIsOpaque();
- void reparentChildren();
-#ifndef QT_NO_DRAGANDDROP
- QOleDropTarget *registerOleDnd(QWidget *widget);
- void unregisterOleDnd(QWidget *widget, QOleDropTarget *target);
-#endif
- void grabMouseWhileInWindow();
- void registerTouchWindow();
- void winSetupGestures();
-#elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC
- // This is new stuff
- uint needWindowChange : 1;
-
- // Each wiget keeps a list of all its child and grandchild OpenGL widgets.
- // This list is used to update the gl context whenever a parent and a granparent
- // moves, and also to check for intersections with gl widgets within the window
- // when a widget moves.
- struct GlWidgetInfo
- {
- GlWidgetInfo(QWidget *widget) : widget(widget), lastUpdateWidget(0) { }
- bool operator==(const GlWidgetInfo &other) const { return (widget == other.widget); }
- QWidget * widget;
- QWidget * lastUpdateWidget;
- };
-
- // dirtyOnWidget contains the areas in the widget that needs to be repained,
- // in the same way as dirtyOnScreen does for the window. Areas are added in
- // dirtyWidget_sys and cleared in the paint event. In scroll_sys we then use
- // this information repaint invalid areas when widgets are scrolled.
- QRegion dirtyOnWidget;
- EventHandlerRef window_event;
- QList<GlWidgetInfo> glWidgets;
-
- //these are here just for code compat (HIViews)
- Qt::HANDLE qd_hd;
-
- void macUpdateSizeAttribute();
- void macUpdateHideOnSuspend();
- void macUpdateOpaqueSizeGrip();
- void macUpdateIgnoreMouseEvents();
- void macUpdateMetalAttribute();
- void macUpdateIsOpaque();
- void macSetNeedsDisplay(QRegion region);
- void setEnabled_helper_sys(bool enable);
- bool isRealWindow() const;
- void adjustWithinMaxAndMinSize(int &w, int &h);
- void applyMaxAndMinSizeOnWindow();
- void update_sys(const QRect &rect);
- void update_sys(const QRegion &rgn);
- void setGeometry_sys_helper(int, int, int, int, bool);
- void setWindowModified_sys(bool b);
- void updateMaximizeButton_sys();
- void setWindowFilePath_sys(const QString &filePath);
- void createWindow_sys();
- void recreateMacWindow();
-#ifndef QT_MAC_USE_COCOA
- void initWindowPtr();
- void finishCreateWindow_sys_Carbon(OSWindowRef windowRef);
-#else
- void setSubWindowStacking(bool set);
- void setWindowLevel();
- void finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ windowRef);
- void syncCocoaMask();
- void finishCocoaMaskSetup();
- void syncUnifiedMode();
- // Did we add the drawRectOriginal method?
- bool drawRectOriginalAdded;
- // Is the original drawRect method available?
- bool originalDrawMethod;
- // Do we need to change the methods?
- bool changeMethods;
-
- // Unified toolbar variables
- bool isInUnifiedToolbar;
- QUnifiedToolbarSurface *unifiedSurface;
- QPoint toolbar_offset;
- QWidget *toolbar_ancestor;
- bool flushRequested;
- bool touchEventsEnabled;
-#endif // QT_MAC_USE_COCOA
- void determineWindowClass();
- void transferChildren();
- bool qt_mac_dnd_event(uint, DragRef);
- void toggleDrawers(bool);
- //mac event functions
- static bool qt_create_root_win();
- static void qt_clean_root_win();
- static bool qt_mac_update_sizer(QWidget *, int up = 0);
- static OSStatus qt_window_event(EventHandlerCallRef er, EventRef event, void *);
- static OSStatus qt_widget_event(EventHandlerCallRef er, EventRef event, void *);
- static bool qt_widget_rgn(QWidget *, short, RgnHandle, bool);
- void registerTouchWindow(bool enable = true);
-#elif defined(Q_WS_QWS) // <--------------------------------------------------------- QWS
- void setMaxWindowState_helper();
- void setFullScreenSize_helper();
- void moveSurface(QWindowSurface *surface, const QPoint &offset);
- QRegion localRequestedRegion() const;
- QRegion localAllocatedRegion() const;
-
- friend class QWSManager;
- friend class QWSManagerPrivate;
- friend class QDecoration;
-#ifndef QT_NO_CURSOR
- void updateCursor() const;
-#endif
- QScreen* getScreen() const;
-#elif defined(Q_WS_QPA) // <--------------------------------------------------------- QPA
- void setMaxWindowState_helper();
- void setFullScreenSize_helper();
-#ifndef QT_NO_CURSOR
- void updateCursor() const;
-#endif
-#elif defined(Q_OS_SYMBIAN) // <--------------------------------------------------------- SYMBIAN
- static QWidget *mouseGrabber;
- static QWidget *keyboardGrabber;
- int symbianScreenNumber; // only valid for desktop widget and top-levels
- bool fixNativeOrientationCalled;
- void s60UpdateIsOpaque();
- void reparentChildren();
- void registerTouchWindow();
-#endif
-
-};
-
-struct QWidgetPaintContext
-{
- inline QWidgetPaintContext(QPaintDevice *d, const QRegion &r, const QPoint &o, int f,
- QPainter *p, QWidgetBackingStore *b)
- : pdev(d), rgn(r), offset(o), flags(f), sharedPainter(p), backingStore(b), painter(0) {}
-
- QPaintDevice *pdev;
- QRegion rgn;
- QPoint offset;
- int flags;
- QPainter *sharedPainter;
- QWidgetBackingStore *backingStore;
- QPainter *painter;
-};
-
-#ifndef QT_NO_GRAPHICSEFFECT
-class QWidgetEffectSourcePrivate : public QGraphicsEffectSourcePrivate
-{
-public:
- QWidgetEffectSourcePrivate(QWidget *widget)
- : QGraphicsEffectSourcePrivate(), m_widget(widget), context(0), updateDueToGraphicsEffect(false)
- {}
-
- inline void detach()
- { m_widget->d_func()->graphicsEffect = 0; }
-
- inline const QGraphicsItem *graphicsItem() const
- { return 0; }
-
- inline const QWidget *widget() const
- { return m_widget; }
-
- inline void update()
- {
- updateDueToGraphicsEffect = true;
- m_widget->update();
- updateDueToGraphicsEffect = false;
- }
-
- inline bool isPixmap() const
- { return false; }
-
- inline void effectBoundingRectChanged()
- {
- // ### This function should take a rect parameter; then we can avoid
- // updating too much on the parent widget.
- if (QWidget *parent = m_widget->parentWidget())
- parent->update();
- else
- update();
- }
-
- inline const QStyleOption *styleOption() const
- { return 0; }
-
- inline QRect deviceRect() const
- { return m_widget->window()->rect(); }
-
- QRectF boundingRect(Qt::CoordinateSystem system) const;
- void draw(QPainter *p);
- QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset,
- QGraphicsEffect::PixmapPadMode mode) const;
-
- QWidget *m_widget;
- QWidgetPaintContext *context;
- QTransform lastEffectTransform;
- bool updateDueToGraphicsEffect;
-};
-#endif //QT_NO_GRAPHICSEFFECT
-
-inline QWExtra *QWidgetPrivate::extraData() const
-{
- return extra;
-}
-
-inline QTLWExtra *QWidgetPrivate::topData() const
-{
- const_cast<QWidgetPrivate *>(this)->createTLExtra();
- return extra->topextra;
-}
-
-inline QTLWExtra *QWidgetPrivate::maybeTopData() const
-{
- return extra ? extra->topextra : 0;
-}
-
-inline QPainter *QWidgetPrivate::sharedPainter() const
-{
- Q_Q(const QWidget);
- QTLWExtra *x = q->window()->d_func()->maybeTopData();
- return x ? x->sharedPainter : 0;
-}
-
-inline void QWidgetPrivate::setSharedPainter(QPainter *painter)
-{
- Q_Q(QWidget);
- QTLWExtra *x = q->window()->d_func()->topData();
- x->sharedPainter = painter;
-}
-
-inline bool QWidgetPrivate::pointInsideRectAndMask(const QPoint &p) const
-{
- Q_Q(const QWidget);
- return q->rect().contains(p) && (!extra || !extra->hasMask || q->testAttribute(Qt::WA_MouseNoMask)
- || extra->mask.contains(p));
-}
-
-inline QWidgetBackingStore *QWidgetPrivate::maybeBackingStore() const
-{
- Q_Q(const QWidget);
- QTLWExtra *x = q->window()->d_func()->maybeTopData();
- return x ? x->backingStore.data() : 0;
-}
-
-QT_END_NAMESPACE
-
-#endif // QWIDGET_P_H
diff --git a/src/gui/kernel/qwidget_qpa.cpp b/src/gui/kernel/qwidget_qpa.cpp
deleted file mode 100644
index 001810e0f4..0000000000
--- a/src/gui/kernel/qwidget_qpa.cpp
+++ /dev/null
@@ -1,875 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtGui/qwidget.h"
-#include "QtGui/qevent.h"
-#include "QtGui/qapplication.h"
-#include "QtGui/private/qbackingstore_p.h"
-#include "QtGui/private/qwidget_p.h"
-#include "QtGui/private/qgraphicssystem_p.h"
-#include "QtGui/private/qapplication_p.h"
-#include "QtGui/qdesktopwidget.h"
-#include "QtGui/qplatformwindow_qpa.h"
-#include "QtGui/qplatformglcontext_qpa.h"
-
-#include <QtGui/QPlatformCursor>
-
-QT_BEGIN_NAMESPACE
-
-void q_createNativeChildrenAndSetParent(QPlatformWindow *parentWindow, const QWidget *parentWidget)
-{
- QObjectList children = parentWidget->children();
- for (int i = 0; i < children.size(); i++) {
- if (children.at(i)->isWidgetType()) {
- const QWidget *childWidget = qobject_cast<const QWidget *>(children.at(i));
- if (childWidget) { // should not be necessary
- if (childWidget->testAttribute(Qt::WA_NativeWindow)) {
- if (!childWidget->platformWindow())
- childWidget->winId();
- }
- if (childWidget->platformWindow()) {
- childWidget->platformWindow()->setParent(parentWindow);
- } else {
- q_createNativeChildrenAndSetParent(parentWindow,childWidget);
- }
- }
- }
- }
-
-}
-
-void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow)
-{
- Q_Q(QWidget);
-
- Q_UNUSED(window);
- Q_UNUSED(initializeWindow);
- Q_UNUSED(destroyOldWindow);
-
- Qt::WindowFlags flags = data.window_flags;
-
- if ((!q->testAttribute(Qt::WA_NativeWindow) && !q->isWindow()) || q->windowType() == Qt::Desktop )
- return; // we only care about real toplevels
-
- QWindowSurface *surface = q->windowSurface();
- QPlatformWindow *platformWindow = q->platformWindow();
-
- if (!platformWindow) {
- platformWindow = QApplicationPrivate::platformIntegration()->createPlatformWindow(q);
- }
- Q_ASSERT(platformWindow);
-
- if (!surface ) {
- if (platformWindow && q->platformWindowFormat().hasWindowSurface()) {
- surface = QApplicationPrivate::platformIntegration()->createWindowSurface(q,platformWindow->winId());
- } else {
- q->setAttribute(Qt::WA_PaintOnScreen,true);
- }
- }
-
- data.window_flags = q->platformWindow()->setWindowFlags(data.window_flags);
-
- setWinId(q->platformWindow()->winId());
-
- //first check children. and create them if necessary
- q_createNativeChildrenAndSetParent(q->platformWindow(),q);
-
- //if we we have a parent, then set correct parent;
- if (!q->isWindow()) {
- if (QWidget *nativeParent = q->nativeParentWidget()) {
- if (nativeParent->platformWindow()) {
- platformWindow->setParent(nativeParent->platformWindow());
- }
- }
- }
-
- QApplicationPrivate::platformIntegration()->moveToScreen(q, topData()->screenIndex);
-// qDebug() << "create_sys" << q << q->internalWinId();
-}
-
-void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
-{
- Q_D(QWidget);
-
- if ((windowType() == Qt::Popup))
- qApp->d_func()->closePopup(this);
-
- //### we don't have proper focus event handling yet
- if (this == QApplicationPrivate::active_window)
- QApplication::setActiveWindow(0);
-
- if (windowType() != Qt::Desktop) {
- if (destroySubWindows) {
- QObjectList childList(children());
- for (int i = 0; i < childList.size(); i++) {
- QWidget *widget = qobject_cast<QWidget *>(childList.at(i));
- if (widget && widget->testAttribute(Qt::WA_NativeWindow)) {
- if (widget->platformWindow()) {
- widget->destroy();
- }
- }
- }
- }
- if (destroyWindow) {
- d->deleteTLSysExtra();
- } else {
- if (parentWidget() && parentWidget()->testAttribute(Qt::WA_WState_Created)) {
- d->hide_sys();
- }
- }
- }
-}
-
-void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
-{
- Q_Q(QWidget);
-
- Qt::WindowFlags oldFlags = data.window_flags;
-
- int targetScreen = -1;
- // Handle a request to move the widget to a particular screen
- if (newparent && newparent->windowType() == Qt::Desktop) {
- // make sure the widget is created on the same screen as the
- // programmer specified desktop widget
-
- // get the desktop's screen number
- targetScreen = newparent->window()->d_func()->topData()->screenIndex;
- newparent = 0;
- }
-
- if (parent != newparent) {
- QObjectPrivate::setParent_helper(newparent); //### why does this have to be done in the _sys function???
- if (q->platformWindow() && newparent) {
- QWidget * parentWithWindow = newparent->platformWindow()? newparent : newparent->nativeParentWidget();
- if (parentWithWindow && parentWithWindow->platformWindow()) {
- q->platformWindow()->setParent(parentWithWindow->platformWindow());
- }
- }
-
- }
-
- if (!newparent) {
- f |= Qt::Window;
- if (targetScreen == -1) {
- if (parent)
- targetScreen = q->parentWidget()->window()->d_func()->topData()->screenIndex;
- }
- }
-
- bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide);
-
- // Reparenting toplevel to child
- if (!(f&Qt::Window) && (oldFlags&Qt::Window) && !q->testAttribute(Qt::WA_NativeWindow)) {
- //qDebug() << "setParent_sys() change from toplevel";
- q->destroy();
- }
-
- data.window_flags = f;
- q->setAttribute(Qt::WA_WState_Created, false);
- q->setAttribute(Qt::WA_WState_Visible, false);
- q->setAttribute(Qt::WA_WState_Hidden, false);
-
- if (f & Qt::Window) {
- //qDebug() << "setParent_sys" << q << newparent << hex << f;
- if (QPlatformWindow *window = q->platformWindow())
- data.window_flags = window->setWindowFlags(data.window_flags);
- }
-
- if (q->isWindow() || (!newparent || newparent->isVisible()) || explicitlyHidden)
- q->setAttribute(Qt::WA_WState_Hidden);
- q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden);
-
- // move the window to the selected screen
- if (!newparent && targetScreen != -1) {
- if (maybeTopData())
- maybeTopData()->screenIndex = targetScreen;
- // only if it is already created
- if (q->testAttribute(Qt::WA_WState_Created)) {
- QPlatformIntegration *platform = QApplicationPrivate::platformIntegration();
- platform->moveToScreen(q, targetScreen);
- }
- }
-}
-
-QPoint QWidget::mapToGlobal(const QPoint &pos) const
-{
- int x=pos.x(), y=pos.y();
- const QWidget* w = this;
- while (w) {
- x += w->data->crect.x();
- y += w->data->crect.y();
- w = w->isWindow() ? 0 : w->parentWidget();
- }
- return QPoint(x, y);
-}
-
-QPoint QWidget::mapFromGlobal(const QPoint &pos) const
-{
- int x=pos.x(), y=pos.y();
- const QWidget* w = this;
- while (w) {
- x -= w->data->crect.x();
- y -= w->data->crect.y();
- w = w->isWindow() ? 0 : w->parentWidget();
- }
- return QPoint(x, y);
-}
-
-void QWidgetPrivate::updateSystemBackground() {}
-
-#ifndef QT_NO_CURSOR
-void QWidgetPrivate::setCursor_sys(const QCursor &cursor)
-{
- Q_UNUSED(cursor);
- Q_Q(QWidget);
- if (q->isVisible())
- qt_qpa_set_cursor(q, false);
-}
-
-void QWidgetPrivate::unsetCursor_sys()
-{
- Q_Q(QWidget);
- if (q->isVisible())
- qt_qpa_set_cursor(q, false);
-}
-
-void QWidgetPrivate::updateCursor() const
-{
- // XXX
-}
-
-#endif //QT_NO_CURSOR
-
-void QWidgetPrivate::setWindowTitle_sys(const QString &caption)
-{
- Q_Q(QWidget);
- if (!q->isWindow())
- return;
-
- if (QPlatformWindow *window = q->platformWindow())
- window->setWindowTitle(caption);
-
-}
-
-void QWidgetPrivate::setWindowIcon_sys(bool /*forceReset*/)
-{
-}
-
-void QWidgetPrivate::setWindowIconText_sys(const QString &iconText)
-{
- Q_UNUSED(iconText);
-}
-
-QWidget *qt_pressGrab = 0;
-QWidget *qt_mouseGrb = 0;
-static QWidget *keyboardGrb = 0;
-
-void QWidget::grabMouse()
-{
- if (qt_mouseGrb)
- qt_mouseGrb->releaseMouse();
-
- // XXX
- //qwsDisplay()->grabMouse(this,true);
-
- qt_mouseGrb = this;
- qt_pressGrab = 0;
-}
-
-#ifndef QT_NO_CURSOR
-void QWidget::grabMouse(const QCursor &cursor)
-{
- Q_UNUSED(cursor);
-
- if (qt_mouseGrb)
- qt_mouseGrb->releaseMouse();
-
- // XXX
- //qwsDisplay()->grabMouse(this,true);
- //qwsDisplay()->selectCursor(this, cursor.handle());
- qt_mouseGrb = this;
- qt_pressGrab = 0;
-}
-#endif
-
-void QWidget::releaseMouse()
-{
- if (qt_mouseGrb == this) {
- // XXX
- //qwsDisplay()->grabMouse(this,false);
- qt_mouseGrb = 0;
- }
-}
-
-void QWidget::grabKeyboard()
-{
- if (keyboardGrb)
- keyboardGrb->releaseKeyboard();
- // XXX
- //qwsDisplay()->grabKeyboard(this, true);
- keyboardGrb = this;
-}
-
-void QWidget::releaseKeyboard()
-{
- if (keyboardGrb == this) {
- // XXX
- //qwsDisplay()->grabKeyboard(this, false);
- keyboardGrb = 0;
- }
-}
-
-QWidget *QWidget::mouseGrabber()
-{
- if (qt_mouseGrb)
- return qt_mouseGrb;
- return qt_pressGrab;
-}
-
-QWidget *QWidget::keyboardGrabber()
-{
- return keyboardGrb;
-}
-
-void QWidget::activateWindow()
-{
- if (platformWindow())
- platformWindow()->requestActivateWindow();
-}
-
-void QWidgetPrivate::show_sys()
-{
- Q_Q(QWidget);
- q->setAttribute(Qt::WA_Mapped);
- if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
- invalidateBuffer(q->rect());
- return;
- }
-
- QApplication::postEvent(q, new QUpdateLaterEvent(q->rect()));
-
- QPlatformWindow *window = q->platformWindow();
- if (window) {
- QRect geomRect = q->geometry();
- if (!q->isWindow()) {
- QPoint topLeftOfWindow = q->mapTo(q->nativeParentWidget(),QPoint());
- geomRect.moveTopLeft(topLeftOfWindow);
- }
- const QRect windowRect = window->geometry();
- if (windowRect != geomRect) {
- window->setGeometry(geomRect);
- }
- if (QWindowSurface *surface = q->windowSurface()) {
- if (windowRect.size() != geomRect.size()) {
- surface->resize(geomRect.size());
- }
- }
- if (window)
- window->setVisible(true);
- }
-}
-
-
-void QWidgetPrivate::hide_sys()
-{
- Q_Q(QWidget);
- q->setAttribute(Qt::WA_Mapped, false);
- if (!q->isWindow()) {
- QWidget *p = q->parentWidget();
- if (p &&p->isVisible()) {
- invalidateBuffer(q->rect());
- }
- return;
- }
- if (QPlatformWindow *window = q->platformWindow()) {
- window->setVisible(false);
- }
-
- //### we don't yet have proper focus event handling
- if (q == QApplicationPrivate::active_window)
- QApplication::setActiveWindow(0);
-
-}
-
-void QWidgetPrivate::setMaxWindowState_helper()
-{
- setFullScreenSize_helper(); //### decoration size
-}
-
-void QWidgetPrivate::setFullScreenSize_helper()
-{
- Q_Q(QWidget);
-
- const uint old_state = data.in_set_window_state;
- data.in_set_window_state = 1;
-
- const QRect screen = qApp->desktop()->screenGeometry(qApp->desktop()->screenNumber(q));
- q->move(screen.topLeft());
- q->resize(screen.size());
-
- data.in_set_window_state = old_state;
-}
-
-static Qt::WindowStates effectiveState(Qt::WindowStates state)
- {
- if (state & Qt::WindowMinimized)
- return Qt::WindowMinimized;
- else if (state & Qt::WindowFullScreen)
- return Qt::WindowFullScreen;
- else if (state & Qt::WindowMaximized)
- return Qt::WindowMaximized;
- return Qt::WindowNoState;
- }
-
-void QWidget::setWindowState(Qt::WindowStates newstate)
-{
- Q_D(QWidget);
- Qt::WindowStates oldstate = windowState();
- if (oldstate == newstate)
- return;
- if (isWindow() && !testAttribute(Qt::WA_WState_Created))
- create();
-
- data->window_state = newstate;
- data->in_set_window_state = 1;
- bool needShow = false;
- Qt::WindowStates newEffectiveState = effectiveState(newstate);
- Qt::WindowStates oldEffectiveState = effectiveState(oldstate);
- if (isWindow() && newEffectiveState != oldEffectiveState) {
- d->createTLExtra();
- if (oldEffectiveState == Qt::WindowNoState) { //normal
- d->topData()->normalGeometry = geometry();
- } else if (oldEffectiveState == Qt::WindowFullScreen) {
- setParent(0, d->topData()->savedFlags);
- needShow = true;
- } else if (oldEffectiveState == Qt::WindowMinimized) {
- needShow = true;
- }
-
- if (newEffectiveState == Qt::WindowMinimized) {
- //### not ideal...
- hide();
- needShow = false;
- } else if (newEffectiveState == Qt::WindowFullScreen) {
- d->topData()->savedFlags = windowFlags();
- setParent(0, Qt::FramelessWindowHint | (windowFlags() & Qt::WindowStaysOnTopHint));
- d->setFullScreenSize_helper();
- raise();
- needShow = true;
- } else if (newEffectiveState == Qt::WindowMaximized) {
- createWinId();
- d->setMaxWindowState_helper();
- } else { //normal
- QRect r = d->topData()->normalGeometry;
- if (r.width() >= 0) {
- d->topData()->normalGeometry = QRect(0,0,-1,-1);
- setGeometry(r);
- }
- }
- }
- data->in_set_window_state = 0;
-
- if (needShow)
- show();
-
- if (newstate & Qt::WindowActive)
- activateWindow();
-
- QWindowStateChangeEvent e(oldstate);
- QApplication::sendEvent(this, &e);
-}
-
-void QWidgetPrivate::setFocus_sys()
-{
-
-}
-
-void QWidgetPrivate::raise_sys()
-{
- Q_Q(QWidget);
- if (q->isWindow()) {
- q->platformWindow()->raise();
- }
-}
-
-void QWidgetPrivate::lower_sys()
-{
- Q_Q(QWidget);
- if (q->isWindow()) {
- Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
- q->platformWindow()->lower();
- } else if (QWidget *p = q->parentWidget()) {
- setDirtyOpaqueRegion();
- p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry()));
- }
-}
-
-void QWidgetPrivate::stackUnder_sys(QWidget*)
-{
- Q_Q(QWidget);
- if (QWidget *p = q->parentWidget()) {
- setDirtyOpaqueRegion();
- p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry()));
- }
-}
-
-void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
-{
- Q_Q(QWidget);
- if (extra) { // any size restrictions?
- w = qMin(w,extra->maxw);
- h = qMin(h,extra->maxh);
- w = qMax(w,extra->minw);
- h = qMax(h,extra->minh);
- }
-
- QPoint oldp = q->geometry().topLeft();
- QSize olds = q->size();
- QRect r(x, y, w, h);
-
- bool isResize = olds != r.size();
- isMove = oldp != r.topLeft(); //### why do we have isMove as a parameter?
-
-
- // We only care about stuff that changes the geometry, or may
- // cause the window manager to change its state
- if (r.size() == olds && oldp == r.topLeft())
- return;
-
- if (!data.in_set_window_state) {
- q->data->window_state &= ~Qt::WindowMaximized;
- q->data->window_state &= ~Qt::WindowFullScreen;
- if (q->isWindow())
- topData()->normalGeometry = QRect(0, 0, -1, -1);
- }
-
- QPoint oldPos = q->pos();
- data.crect = r;
-
- if (q->isVisible()) {
- if (q->platformWindow()) {
- if (q->isWindow()) {
- q->platformWindow()->setGeometry(q->geometry());
- } else {
- QPoint posInNativeParent = q->mapTo(q->nativeParentWidget(),QPoint());
- q->platformWindow()->setGeometry(QRect(posInNativeParent,r.size()));
- }
- const QWidgetBackingStore *bs = maybeBackingStore();
- if (bs->windowSurface) {
- if (isResize)
- bs->windowSurface->resize(r.size());
- }
- } else {
- if (isMove && !isResize)
- moveRect(QRect(oldPos, olds), x - oldPos.x(), y - oldPos.y());
- else
- invalidateBuffer_resizeHelper(oldPos, olds);
- }
-
- if (isMove) {
- QMoveEvent e(q->pos(), oldPos);
- QApplication::sendEvent(q, &e);
- }
- if (isResize) {
- QResizeEvent e(r.size(), olds);
- QApplication::sendEvent(q, &e);
- if (q->platformWindow())
- q->update();
- }
- } else { // not visible
- if (isMove && q->pos() != oldPos)
- q->setAttribute(Qt::WA_PendingMoveEvent, true);
- if (isResize)
- q->setAttribute(Qt::WA_PendingResizeEvent, true);
- }
-
-}
-
-void QWidgetPrivate::setConstraints_sys()
-{
-}
-
-void QWidgetPrivate::scroll_sys(int dx, int dy)
-{
- Q_Q(QWidget);
- scrollChildren(dx, dy);
- scrollRect(q->rect(), dx, dy);
-}
-
-void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r)
-{
- scrollRect(r, dx, dy);
-}
-
-int QWidget::metric(PaintDeviceMetric m) const
-{
- Q_D(const QWidget);
-
- QPlatformScreen *screen = QPlatformScreen::platformScreenForWidget(this);
- if (!screen) {
- if (m == PdmDpiX || m == PdmDpiY)
- return 72;
- return QPaintDevice::metric(m);
- }
- int val;
- if (m == PdmWidth) {
- val = data->crect.width();
- } else if (m == PdmWidthMM) {
- val = data->crect.width() * screen->physicalSize().width() / screen->geometry().width();
- } else if (m == PdmHeight) {
- val = data->crect.height();
- } else if (m == PdmHeightMM) {
- val = data->crect.height() * screen->physicalSize().height() / screen->geometry().height();
- } else if (m == PdmDepth) {
- return screen->depth();
- } else if (m == PdmDpiX || m == PdmPhysicalDpiX) {
- if (d->extra && d->extra->customDpiX)
- return d->extra->customDpiX;
- else if (d->parent)
- return static_cast<QWidget *>(d->parent)->metric(m);
- return qRound(screen->geometry().width() / double(screen->physicalSize().width() / 25.4));
- } else if (m == PdmDpiY || m == PdmPhysicalDpiY) {
- if (d->extra && d->extra->customDpiY)
- return d->extra->customDpiY;
- else if (d->parent)
- return static_cast<QWidget *>(d->parent)->metric(m);
- return qRound(screen->geometry().height() / double(screen->physicalSize().height() / 25.4));
- } else {
- val = QPaintDevice::metric(m);// XXX
- }
- return val;
-}
-
-/*!
- \preliminary
-
- Sets the window to be the \a window specified.
- The QWidget takes ownership of the \a surface.
-*/
-void QWidget::setPlatformWindow(QPlatformWindow *window)
-{
- Q_D(QWidget);
-
- QTLWExtra *topData = d->topData();
- if (topData->platformWindow == window)
- return;
-
- delete topData->platformWindow;
- topData->platformWindow = window;
-}
-
-/*!
- \preliminary
-
- Returns the QPlatformWindow this widget will be drawn into.
-*/
-QPlatformWindow *QWidget::platformWindow() const
-{
- Q_D(const QWidget);
- QTLWExtra *extra = d->maybeTopData();
- if (extra && extra->platformWindow)
- return extra->platformWindow;
-
- return 0;
-}
-
-void QWidget::setPlatformWindowFormat(const QPlatformWindowFormat &format)
-{
- if (isWindow() || testAttribute(Qt::WA_NativeWindow)) {
- Q_D(QWidget);
- QTLWExtra *topData = d->topData();
- topData->platformWindowFormat = format;
- if (testAttribute(Qt::WA_WState_Created)) {
- bool wasVisible = testAttribute(Qt::WA_WState_Visible);
- destroy();
- d->create_sys(0,true,true);
- if (wasVisible)
- topData->platformWindow->setVisible(true);
- }
- }
-}
-
-QPlatformWindowFormat QWidget::platformWindowFormat() const
-{
- Q_D(const QWidget);
-
- QTLWExtra *extra = d->maybeTopData();
- if (extra){
- return extra->platformWindowFormat;
- } else {
- return QPlatformWindowFormat::defaultFormat();
- }
-}
-
-void QWidgetPrivate::createSysExtra()
-{
-}
-
-void QWidgetPrivate::deleteSysExtra()
-{
-
-}
-
-void QWidgetPrivate::createTLSysExtra()
-{
-}
-
-void QWidgetPrivate::deleteTLSysExtra()
-{
- if (extra && extra->topextra) {
- //the toplevel might have a context with a "qglcontext associated with it. We need to
- //delete the qglcontext before we delete the qplatformglcontext.
- //One unfortunate thing about this is that we potentially create a glContext just to
- //delete it straight afterwards.
- if (extra->topextra->platformWindow) {
- if (QPlatformGLContext *context = extra->topextra->platformWindow->glContext()) {
- context->deleteQGLContext();
- }
- }
- setWinId(0);
- delete extra->topextra->platformWindow;
- extra->topextra->platformWindow = 0;
- }
-}
-
-void QWidgetPrivate::registerDropSite(bool on)
-{
- Q_UNUSED(on);
-}
-
-void QWidgetPrivate::setMask_sys(const QRegion &region)
-{
- Q_UNUSED(region);
- // XXX
-}
-
-void QWidgetPrivate::updateFrameStrut()
-{
- // XXX
-}
-
-void QWidgetPrivate::setWindowOpacity_sys(qreal level)
-{
- Q_Q(QWidget);
- q->platformWindow()->setOpacity(level);
-}
-
-void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
-{
- Q_UNUSED(dontShow);
- Q_UNUSED(oldRect);
- // XXX
-}
-
-QPaintEngine *QWidget::paintEngine() const
-{
- qWarning("QWidget::paintEngine: Should no longer be called");
- return 0; //##### @@@
-}
-
-QWindowSurface *QWidgetPrivate::createDefaultWindowSurface_sys()
-{
- Q_Q(QWidget);
- if (q->platformWindowFormat().hasWindowSurface())
- return QApplicationPrivate::platformIntegration()->createWindowSurface(q,0);
- else
- return 0;
-}
-
-void QWidgetPrivate::setModal_sys()
-{
-}
-
-#ifndef QT_NO_CURSOR
-void qt_qpa_set_cursor(QWidget * w, bool force)
-{
- static QCursor arrowCursor(Qt::ArrowCursor);
- static QPointer<QWidget> lastUnderMouse = 0;
-
- QCursor * override = QApplication::overrideCursor();
-
- if (override && w != 0)
- return;
-
- QWidget *cursorWidget;
- QCursor cursorCursor;
-
- do {
- if (w == 0) {
- if (override) {
- cursorCursor = *override;
- cursorWidget = QApplication::topLevelAt(QCursor::pos());
- break;
- }
- w = QApplication::widgetAt(QCursor::pos());
- if (w == 0) // clear the override cursor while over empty space
- w = QApplication::desktop();
- } else if (force) {
- lastUnderMouse = w;
- } else if (w->testAttribute(Qt::WA_WState_Created) && lastUnderMouse
- && lastUnderMouse->effectiveWinId() == w->effectiveWinId()) {
- w = lastUnderMouse;
- }
- if (w == QApplication::desktop() && !override) {
- cursorCursor = arrowCursor;
- cursorWidget = w;
- break;
- }
-
- QWidget * curWin = QApplication::activeWindow();
- if (!curWin && w && w->internalWinId())
- return;
- QWidget* cW = w && !w->internalWinId() ? w : curWin;
-
- if (!cW || cW->window() != w->window() ||
- !cW->isVisible() || !cW->underMouse() || override)
- return;
-
- cursorCursor = w->cursor();
- cursorWidget = w;
- } while (0);
- foreach (QWeakPointer<QPlatformCursor> cursor, QPlatformCursorPrivate::getInstances())
- if (cursor)
- cursor.data()->changeCursor(&cursorCursor, cursorWidget);
-}
-#endif //QT_NO_CURSOR
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qwidget_qws.cpp b/src/gui/kernel/qwidget_qws.cpp
deleted file mode 100644
index 86ebc04165..0000000000
--- a/src/gui/kernel/qwidget_qws.cpp
+++ /dev/null
@@ -1,1221 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qcursor.h"
-#include "qapplication.h"
-#include "qapplication_p.h"
-#include "qpainter.h"
-#include "qbitmap.h"
-#include "qimage.h"
-#include "qhash.h"
-#include "qstack.h"
-#include "qlayout.h"
-#include "qtextcodec.h"
-#include "qinputcontext.h"
-#include "qdesktopwidget.h"
-
-#include "qwsdisplay_qws.h"
-#include "private/qwsdisplay_qws_p.h"
-#include "qscreen_qws.h"
-#include "qwsmanager_qws.h"
-#include <private/qwsmanager_p.h>
-#include <private/qbackingstore_p.h>
-#include <private/qwindowsurface_qws_p.h>
-#include <private/qwslock_p.h>
-#include "qpaintengine.h"
-
-#include "qdebug.h"
-
-#include "qwidget_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QT_USE_NAMESPACE
-
-extern int *qt_last_x;
-extern int *qt_last_y;
-extern WId qt_last_cursor;
-extern bool qws_overrideCursor;
-extern QWidget *qt_pressGrab;
-extern QWidget *qt_mouseGrb;
-
-static QWidget *keyboardGrb = 0;
-
-static int takeLocalId()
-{
- static int n=-1000;
- return --n;
-}
-
-class QWSServer;
-extern QWSServer *qwsServer;
-
-static inline bool isServerProcess()
-{
- return (qwsServer != 0);
-}
-
-/*****************************************************************************
- QWidget member functions
- *****************************************************************************/
-
-void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool /*destroyOldWindow*/)
-{
- Q_Q(QWidget);
- Qt::WindowType type = q->windowType();
-
- // Make sure the WindowTitleHint is on if any of the title bar hints are set
- // Note: This might be moved to cross-platform QWidgetPrivate::adjustFlags()
- if ( !(data.window_flags & Qt::CustomizeWindowHint) && (
- (data.window_flags & Qt::WindowSystemMenuHint) ||
- (data.window_flags & Qt::WindowContextHelpButtonHint) ||
- (data.window_flags & Qt::WindowMinimizeButtonHint) ||
- (data.window_flags & Qt::WindowMaximizeButtonHint) ||
- (data.window_flags & Qt::WindowCloseButtonHint) ) ) {
- data.window_flags |= Qt::WindowTitleHint;
- }
-
- // Decoration plugins on QWS don't support switching on the close button on its own
- if (data.window_flags & Qt::WindowCloseButtonHint)
- data.window_flags |= Qt::WindowSystemMenuHint;
-
- Qt::WindowFlags flags = data.window_flags;
-
- data.alloc_region_index = -1;
-
- // we don't have a "Drawer" window type
- if (type == Qt::Drawer) {
- type = Qt::Widget;
- flags &= ~Qt::WindowType_Mask;
- }
-
-
- bool topLevel = (flags & Qt::Window);
- bool popup = (type == Qt::Popup);
- bool dialog = (type == Qt::Dialog
- || type == Qt::Sheet
- || (flags & Qt::MSWindowsFixedSizeDialogHint));
- bool desktop = (type == Qt::Desktop);
- bool tool = (type == Qt::Tool || type == Qt::SplashScreen || type == Qt::ToolTip);
-
-
-#ifndef QT_NO_WARNING_OUTPUT
- static bool toolWarningShown = false;
- if (!toolWarningShown && type == Qt::Tool && !(flags & Qt::FramelessWindowHint)) {
- qWarning("Qt for Embedded Linux " QT_VERSION_STR " does not support tool windows with frames.\n"
- "This behavior will change in a later release. To ensure compatibility with\n"
- "future versions, use (Qt::Tool | Qt::FramelessWindowHint).");
- toolWarningShown = true;
- }
-#endif
-
- WId id;
- QWSDisplay* dpy = QWidget::qwsDisplay();
-
- if (!window) // always initialize
- initializeWindow = true;
-
- // use the size of the primary screen to determine the default window size
- QList<QScreen *> screens = qt_screen->subScreens();
- if (screens.isEmpty())
- screens.append(qt_screen);
- int sw = screens[0]->width();
- int sh = screens[0]->height();
-
- if (desktop) { // desktop widget
- dialog = popup = false; // force these flags off
- data.crect.setRect(0, 0, sw, sh);
- } else if (topLevel && !q->testAttribute(Qt::WA_Resized)) {
- int width = sw / 2;
- int height = 4 * sh / 10;
- if (extra) {
- width = qMax(qMin(width, extra->maxw), extra->minw);
- height = qMax(qMin(height, extra->maxh), extra->minh);
- }
- data.crect.setSize(QSize(width, height));
- }
-
- if (window) { // override the old window
- id = window;
- setWinId(window);
- } else if (desktop) { // desktop widget
- id = (WId)-2; // id = root window
-#if 0
- QWidget *otherDesktop = q->find(id); // is there another desktop?
- if (otherDesktop && otherDesktop->testWFlags(Qt::WPaintDesktop)) {
- otherDesktop->d_func()->setWinId(0); // remove id from widget mapper
- setWinId(id); // make sure otherDesktop is
- otherDesktop->d_func()->setWinId(id); // found first
- } else
-#endif
- {
- setWinId(id);
- }
- } else {
- id = topLevel ? dpy->takeId() : takeLocalId();
- setWinId(id); // set widget id/handle + hd
- }
-
-
- bool hasFrame = true;
- if (topLevel) {
- if (desktop || popup || tool || q->testAttribute(Qt::WA_DontShowOnScreen))
- hasFrame = false;
- else
- hasFrame = !(flags & Qt::FramelessWindowHint);
- }
- if (desktop) {
- q->setAttribute(Qt::WA_WState_Visible);
- } else if (topLevel) { // set X cursor
- //QCursor *oc = QApplication::overrideCursor();
- if (initializeWindow) {
- //XXX XDefineCursor(dpy, winid, oc ? oc->handle() : cursor().handle());
- }
- QWidget::qwsDisplay()->nameRegion(q->internalWinId(), q->objectName(), q->windowTitle());
- }
-
- if (topLevel) {
- createTLExtra();
- QTLWExtra *topextra = extra->topextra;
-#ifndef QT_NO_QWS_MANAGER
- if (hasFrame) {
- // get size of wm decoration and make the old crect the new frect
- QRect cr = data.crect;
- QRegion r = QApplication::qwsDecoration().region(q, cr) | cr;
- QRect br(r.boundingRect());
- topextra->frameStrut.setCoords(cr.x() - br.x(),
- cr.y() - br.y(),
- br.right() - cr.right(),
- br.bottom() - cr.bottom());
- if (!q->testAttribute(Qt::WA_Moved) || topextra->posFromMove)
- data.crect.translate(topextra->frameStrut.left(), topextra->frameStrut.top());
- if (!topData()->qwsManager) {
- topData()->qwsManager = new QWSManager(q);
- if((q->data->window_state & ~Qt::WindowActive) == Qt::WindowMaximized)
- topData()->qwsManager->maximize();
- }
-
- } else if (topData()->qwsManager) {
- delete topData()->qwsManager;
- topData()->qwsManager = 0;
- data.crect.translate(-topextra->frameStrut.left(), -topextra->frameStrut.top());
- topextra->frameStrut.setCoords(0, 0, 0, 0);
- }
-#endif
- if (!topextra->caption.isEmpty())
- setWindowTitle_helper(topextra->caption);
-
- //XXX If we are session managed, inform the window manager about it
- } else {
- if (extra && extra->topextra) { // already allocated due to reparent?
- extra->topextra->frameStrut.setCoords(0, 0, 0, 0);
- }
- //updateRequestedRegion(mapToGlobal(QPoint(0,0)));
- }
-}
-
-
-void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
-{
- Q_D(QWidget);
- d->aboutToDestroy();
- if (!isWindow() && parentWidget())
- parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry()));
-
- d->deactivateWidgetCleanup();
- if (testAttribute(Qt::WA_WState_Created)) {
- setAttribute(Qt::WA_WState_Created, false);
- QObjectList childObjects = children();
- for (int i = 0; i < childObjects.size(); ++i) {
- QObject *obj = childObjects.at(i);
- if (obj->isWidgetType())
- static_cast<QWidget*>(obj)->destroy(destroySubWindows,
- destroySubWindows);
- }
- releaseMouse();
- if (qt_pressGrab == this)
- qt_pressGrab = 0;
-
- if (keyboardGrb == this)
- releaseKeyboard();
- if (testAttribute(Qt::WA_ShowModal)) // just be sure we leave modal
- QApplicationPrivate::leaveModal(this);
- else if ((windowType() == Qt::Popup))
- qApp->d_func()->closePopup(this);
-#ifndef QT_NO_IM
- if (d->ic) {
- delete d->ic;
- d->ic =0;
- } else {
- // release previous focus information participating with
- // preedit preservation of qic -- while we still have a winId
- QInputContext *qic = QApplicationPrivate::inputContext;
- if (qic)
- qic->widgetDestroyed(this);
- }
-#endif //QT_NO_IM
-
- if ((windowType() == Qt::Desktop)) {
- } else {
- if (parentWidget() && parentWidget()->testAttribute(Qt::WA_WState_Created)) {
- d->hide_sys();
- }
- if (destroyWindow && isWindow()) {
- if (d->extra && d->extra->topextra && d->extra->topextra->backingStore)
- d->extra->topextra->backingStore->windowSurface->setGeometry(QRect());
- qwsDisplay()->destroyRegion(internalWinId());
- }
- }
- QT_TRY {
- d->setWinId(0);
- } QT_CATCH (const std::bad_alloc &) {
- // swallow - destructors must not throw
- }
- }
-}
-
-
-void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
-{
- Q_Q(QWidget);
- bool wasCreated = q->testAttribute(Qt::WA_WState_Created);
- if (q->isVisible() && q->parentWidget() && parent != q->parentWidget())
- q->parentWidget()->d_func()->invalidateBuffer(effectiveRectFor(q->geometry()));
-#ifndef QT_NO_CURSOR
- QCursor oldcurs;
- bool setcurs=q->testAttribute(Qt::WA_SetCursor);
- if (setcurs) {
- oldcurs = q->cursor();
- q->unsetCursor();
- }
-#endif
-
- WId old_winid = data.winid;
- if ((q->windowType() == Qt::Desktop))
- old_winid = 0;
-
- if (!q->isWindow() && q->parentWidget() && q->parentWidget()->testAttribute(Qt::WA_WState_Created))
- hide_sys();
-
- setWinId(0);
-
- if (parent != newparent) {
- QWidget *oldparent = q->parentWidget();
- QObjectPrivate::setParent_helper(newparent);
- if (oldparent) {
-// oldparent->d_func()->setChildrenAllocatedDirty();
-// oldparent->data->paintable_region_dirty = true;
- }
- if (newparent) {
-// newparent->d_func()->setChildrenAllocatedDirty();
-// newparent->data->paintable_region_dirty = true;
- //@@@@@@@
- }
- }
- Qt::FocusPolicy fp = q->focusPolicy();
- QSize s = q->size();
- //QBrush bgc = background(); // save colors
- bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide);
-
- data.window_flags = f;
- q->setAttribute(Qt::WA_WState_Created, false);
- q->setAttribute(Qt::WA_WState_Visible, false);
- q->setAttribute(Qt::WA_WState_Hidden, false);
- adjustFlags(data.window_flags, q);
- // keep compatibility with previous versions, we need to preserve the created state
- // (but we recreate the winId for the widget being reparented, again for compatibility)
- if (wasCreated || (!q->isWindow() && newparent->testAttribute(Qt::WA_WState_Created)))
- createWinId();
- if (q->isWindow() || (!newparent || newparent->isVisible()) || explicitlyHidden)
- q->setAttribute(Qt::WA_WState_Hidden);
- q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden);
-
- if (q->isWindow()) {
- QRect fs = frameStrut();
- data.crect = QRect(fs.left(), fs.top(), s.width(), s.height());
- if ((data.window_flags & Qt::FramelessWindowHint) && extra && extra->topextra)
- extra->topextra->frameStrut.setCoords(0, 0, 0, 0);
- } else {
- data.crect = QRect(0, 0, s.width(), s.height());
- }
-
- q->setFocusPolicy(fp);
- if (extra && !extra->mask.isEmpty()) {
- QRegion r = extra->mask;
- extra->mask = QRegion();
- q->setMask(r);
- }
- if ((int)old_winid > 0) {
- QWidget::qwsDisplay()->destroyRegion(old_winid);
- extra->topextra->backingStore->windowSurface->setGeometry(QRect());
- }
-#ifndef QT_NO_CURSOR
- if (setcurs) {
- q->setCursor(oldcurs);
- }
-#endif
-}
-
-
-QPoint QWidget::mapToGlobal(const QPoint &pos) const
-{
- int x=pos.x(), y=pos.y();
- const QWidget* w = this;
- while (w) {
- x += w->data->crect.x();
- y += w->data->crect.y();
- w = w->isWindow() ? 0 : w->parentWidget();
- }
- return QPoint(x, y);
-}
-
-QPoint QWidget::mapFromGlobal(const QPoint &pos) const
-{
- int x=pos.x(), y=pos.y();
- const QWidget* w = this;
- while (w) {
- x -= w->data->crect.x();
- y -= w->data->crect.y();
- w = w->isWindow() ? 0 : w->parentWidget();
- }
- return QPoint(x, y);
-}
-
-#if 0 // #####
-void QWidget::setMicroFocusHint(int x, int y, int width, int height,
- bool text, QFont *)
-{
- if (QRect(x, y, width, height) != microFocusHint()) {
- d->createExtra();
- d->extra->micro_focus_hint.setRect(x, y, width, height);
- }
-#ifndef QT_NO_QWS_INPUTMETHODS
- if (text) {
- QWidget *tlw = window();
- int winid = tlw->internalWinId();
- QPoint p(x, y + height);
- QPoint gp = mapToGlobal(p);
-
- QRect r = QRect(mapToGlobal(QPoint(0,0)),
- size());
-
- r.setBottom(tlw->geometry().bottom());
-
- //qDebug("QWidget::setMicroFocusHint %d %d %d %d", r.x(),
- // r.y(), r.width(), r.height());
- QInputContext::setMicroFocusWidget(this);
-
- qwsDisplay()->setIMInfo(winid, gp.x(), gp.y(), r);
-
- //send font info, ###if necessary
- qwsDisplay()->setInputFont(winid, font());
- }
-#endif
-}
-#endif
-
-void QWidgetPrivate::updateSystemBackground() {}
-
-#ifndef QT_NO_CURSOR
-void QWidgetPrivate::setCursor_sys(const QCursor &cursor)
-{
- Q_UNUSED(cursor);
- Q_Q(QWidget);
- if (q->isVisible())
- updateCursor();
-}
-
-void QWidgetPrivate::unsetCursor_sys()
-{
- Q_Q(QWidget);
- if (q->isVisible())
- updateCursor();
-}
-#endif //QT_NO_CURSOR
-
-void QWidgetPrivate::setWindowTitle_sys(const QString &caption)
-{
- Q_Q(QWidget);
- QWidget::qwsDisplay()->setWindowCaption(q, caption);
-}
-
-void QWidgetPrivate::setWindowIcon_sys(bool /*forceReset*/)
-{
-#if 0
- QTLWExtra* x = d->topData();
- delete x->icon;
- x->icon = 0;
- QBitmap mask;
- if (unscaledPixmap.isNull()) {
- } else {
- QImage unscaledIcon = unscaledPixmap.toImage();
- QPixmap pixmap =
- QPixmap::fromImage(unscaledIcon.scale(16, 16, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
- x->icon = new QPixmap(pixmap);
- mask = pixmap.mask() ? *pixmap.mask() : pixmap.createHeuristicMask();
- }
-#endif
-}
-
-void QWidgetPrivate::setWindowIconText_sys(const QString &iconText)
-{
- Q_UNUSED(iconText);
-}
-
-void QWidget::grabMouse()
-{
- if (qt_mouseGrb)
- qt_mouseGrb->releaseMouse();
-
- qwsDisplay()->grabMouse(this,true);
-
- qt_mouseGrb = this;
- qt_pressGrab = 0;
-}
-
-#ifndef QT_NO_CURSOR
-void QWidget::grabMouse(const QCursor &cursor)
-{
- if (qt_mouseGrb)
- qt_mouseGrb->releaseMouse();
-
- qwsDisplay()->grabMouse(this,true);
- qwsDisplay()->selectCursor(this, cursor.handle());
- qt_mouseGrb = this;
- qt_pressGrab = 0;
-}
-#endif
-
-void QWidget::releaseMouse()
-{
- if (qt_mouseGrb == this) {
- qwsDisplay()->grabMouse(this,false);
- qt_mouseGrb = 0;
- }
-}
-
-void QWidget::grabKeyboard()
-{
- if (keyboardGrb)
- keyboardGrb->releaseKeyboard();
- qwsDisplay()->grabKeyboard(this, true);
- keyboardGrb = this;
-}
-
-void QWidget::releaseKeyboard()
-{
- if (keyboardGrb == this) {
- qwsDisplay()->grabKeyboard(this, false);
- keyboardGrb = 0;
- }
-}
-
-
-QWidget *QWidget::mouseGrabber()
-{
- if (qt_mouseGrb)
- return qt_mouseGrb;
- return qt_pressGrab;
-}
-
-
-QWidget *QWidget::keyboardGrabber()
-{
- return keyboardGrb;
-}
-
-void QWidget::activateWindow()
-{
- QWidget *tlw = window();
- if (tlw->isVisible()) {
- Q_ASSERT(tlw->testAttribute(Qt::WA_WState_Created));
- qwsDisplay()->requestFocus(tlw->internalWinId(), true);
- }
-}
-
-void QWidgetPrivate::show_sys()
-{
- Q_Q(QWidget);
- q->setAttribute(Qt::WA_Mapped);
- if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
- invalidateBuffer(q->rect());
- return;
- }
-
- if (q->isWindow()) {
-
-
- if (!q->testAttribute(Qt::WA_ShowWithoutActivating)
- && q->windowType() != Qt::Popup
- && q->windowType() != Qt::Tool
- && q->windowType() != Qt::ToolTip) {
- QWidget::qwsDisplay()->requestFocus(data.winid,true);
- }
-
-
- if (QWindowSurface *surface = q->windowSurface()) {
- const QRect frameRect = q->frameGeometry();
- if (surface->geometry() != frameRect)
- surface->setGeometry(frameRect);
- }
-
- QRegion r = localRequestedRegion();
-#ifndef QT_NO_QWS_MANAGER
- if (extra && extra->topextra && extra->topextra->qwsManager) {
- r.translate(data.crect.topLeft());
- r += extra->topextra->qwsManager->region();
- r.translate(-data.crect.topLeft());
- }
-#endif
- data.fstrut_dirty = true;
- invalidateBuffer(r);
- bool staysontop =
- (q->windowFlags() & Qt::WindowStaysOnTopHint)
- || q->windowType() == Qt::Popup;
- if (!staysontop && q->parentWidget()) { // if our parent stays on top, so must we
- QWidget *ptl = q->parentWidget()->window();
- if (ptl && (ptl->windowFlags() & Qt::WindowStaysOnTopHint))
- staysontop = true;
- }
-
- QWSChangeAltitudeCommand::Altitude altitude;
- altitude = staysontop ? QWSChangeAltitudeCommand::StaysOnTop : QWSChangeAltitudeCommand::Raise;
- QWidget::qwsDisplay()->setAltitude(data.winid, altitude, true);
- if (!q->objectName().isEmpty()) {
- QWidget::qwsDisplay()->setWindowCaption(q, q->windowTitle());
- }
- }
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- else if ( extra && extra->topextra && extra->topextra->windowSurface) {
- QWSWindowSurface *surface;
- surface = static_cast<QWSWindowSurface*>(q->windowSurface());
- const QPoint p = q->mapToGlobal(QPoint());
- surface->setGeometry(QRect(p, q->size()));
- }
-#endif
-
- if (!q->window()->data->in_show) {
- invalidateBuffer(q->rect());
- }
-}
-
-
-void QWidgetPrivate::hide_sys()
-{
- Q_Q(QWidget);
- deactivateWidgetCleanup();
-
- if (q->isWindow()) {
- q->releaseMouse();
-// requestWindowRegion(QRegion());
-
- if (extra->topextra->backingStore)
- extra->topextra->backingStore->releaseBuffer();
-
-
- QWidget::qwsDisplay()->requestFocus(data.winid,false);
- } else {
- QWidget *p = q->parentWidget();
- if (p &&p->isVisible()) {
- invalidateBuffer(q->rect());
- }
- }
-}
-
-
-
-static Qt::WindowStates effectiveState(Qt::WindowStates state)
- {
- if (state & Qt::WindowMinimized)
- return Qt::WindowMinimized;
- else if (state & Qt::WindowFullScreen)
- return Qt::WindowFullScreen;
- else if (state & Qt::WindowMaximized)
- return Qt::WindowMaximized;
- return Qt::WindowNoState;
- }
-
-void QWidgetPrivate::setMaxWindowState_helper()
-{
- // in_set_window_state is usually set in setWindowState(), but this
- // function is used in other functions as well
- // (e.g QApplicationPrivate::setMaxWindowRect())
- const uint old_state = data.in_set_window_state;
- data.in_set_window_state = 1;
-
-#ifndef QT_NO_QWS_MANAGER
- if (extra && extra->topextra && extra->topextra->qwsManager)
- extra->topextra->qwsManager->maximize();
- else
-#endif
- {
- Q_Q(QWidget);
- const QDesktopWidget *desktop = QApplication::desktop();
- const int screen = desktop->screenNumber(q);
- const QRect maxWindowRect = desktop->availableGeometry(screen);
- q->setGeometry(maxWindowRect);
- }
- data.in_set_window_state = old_state;
-}
-
-void QWidgetPrivate::setFullScreenSize_helper()
-{
- Q_Q(QWidget);
-
- const uint old_state = data.in_set_window_state;
- data.in_set_window_state = 1;
-
- const QRect screen = qApp->desktop()->screenGeometry(qApp->desktop()->screenNumber(q));
- q->move(screen.topLeft());
- q->resize(screen.size());
-
- data.in_set_window_state = old_state;
-}
-
-void QWidget::setWindowState(Qt::WindowStates newstate)
-{
- Q_D(QWidget);
- Qt::WindowStates oldstate = windowState();
- if (oldstate == newstate)
- return;
- if (isWindow() && !testAttribute(Qt::WA_WState_Created))
- create();
-
- data->window_state = newstate;
- data->in_set_window_state = 1;
- bool needShow = false;
- Qt::WindowStates newEffectiveState = effectiveState(newstate);
- Qt::WindowStates oldEffectiveState = effectiveState(oldstate);
- if (isWindow() && newEffectiveState != oldEffectiveState) {
- d->createTLExtra();
- if (oldEffectiveState == Qt::WindowNoState) { //normal
- d->topData()->normalGeometry = geometry();
- } else if (oldEffectiveState == Qt::WindowFullScreen) {
- setParent(0, d->topData()->savedFlags);
- needShow = true;
- } else if (oldEffectiveState == Qt::WindowMinimized) {
- needShow = true;
- }
-
- if (newEffectiveState == Qt::WindowMinimized) {
- //### not ideal...
- hide();
- needShow = false;
- } else if (newEffectiveState == Qt::WindowFullScreen) {
- d->topData()->savedFlags = windowFlags();
- setParent(0, Qt::FramelessWindowHint | (windowFlags() & Qt::WindowStaysOnTopHint));
- d->setFullScreenSize_helper();
- raise();
- needShow = true;
- } else if (newEffectiveState == Qt::WindowMaximized) {
- createWinId();
- d->setMaxWindowState_helper();
- } else { //normal
- QRect r = d->topData()->normalGeometry;
- if (r.width() >= 0) {
- d->topData()->normalGeometry = QRect(0,0,-1,-1);
- setGeometry(r);
- }
- }
- }
- data->in_set_window_state = 0;
-
- if (needShow)
- show();
-
- if (newstate & Qt::WindowActive)
- activateWindow();
-
- QWindowStateChangeEvent e(oldstate);
- QApplication::sendEvent(this, &e);
-}
-
-void QWidgetPrivate::setFocus_sys()
-{
-
-}
-
-void QWidgetPrivate::raise_sys()
-{
- Q_Q(QWidget);
- //@@@ transaction
- if (q->isWindow()) {
- Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
- QWidget::qwsDisplay()->setAltitude(q->internalWinId(),
- QWSChangeAltitudeCommand::Raise);
- // XXX: subsurfaces?
-#ifdef QT_NO_WINDOWGROUPHINT
-#else
- QObjectList childObjects = q->children();
- if (!childObjects.isEmpty()) {
- QWidgetList toraise;
- for (int i = 0; i < childObjects.size(); ++i) {
- QObject *obj = childObjects.at(i);
- if (obj->isWidgetType()) {
- QWidget* w = static_cast<QWidget*>(obj);
- if (w->isWindow())
- toraise.append(w);
- }
- }
-
- for (int i = 0; i < toraise.size(); ++i) {
- QWidget *w = toraise.at(i);
- if (w->isVisible())
- w->raise();
- }
- }
-#endif // QT_NO_WINDOWGROUPHINT
- }
-}
-
-void QWidgetPrivate::lower_sys()
-{
- Q_Q(QWidget);
- if (q->isWindow()) {
- Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
- QWidget::qwsDisplay()->setAltitude(data.winid,
- QWSChangeAltitudeCommand::Lower);
- } else if (QWidget *p = q->parentWidget()) {
- setDirtyOpaqueRegion();
- p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry()));
- }
-}
-
-void QWidgetPrivate::stackUnder_sys(QWidget*)
-{
- Q_Q(QWidget);
- if (QWidget *p = q->parentWidget()) {
- setDirtyOpaqueRegion();
- p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry()));
- }
-}
-
-void QWidgetPrivate::moveSurface(QWindowSurface *surface, const QPoint &offset)
-{
- QWSWindowSurface *s = static_cast<QWSWindowSurface*>(surface);
- if (!s->move(offset))
- s->invalidateBuffer();
-
- QWSDisplay::instance()->moveRegion(s->winId(), offset.x(), offset.y());
-}
-
-void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
-{
- Q_Q(QWidget);
- if (extra) { // any size restrictions?
- w = qMin(w,extra->maxw);
- h = qMin(h,extra->maxh);
- w = qMax(w,extra->minw);
- h = qMax(h,extra->minh);
- }
-
- QPoint oldp = q->geometry().topLeft();
- QSize olds = q->size();
- QRect r(x, y, w, h);
-
- bool isResize = olds != r.size();
- isMove = oldp != r.topLeft(); //### why do we have isMove as a parameter?
-
- // We only care about stuff that changes the geometry, or may
- // cause the window manager to change its state
- if (r.size() == olds && oldp == r.topLeft())
- return;
-
- if (!data.in_set_window_state) {
- q->data->window_state &= ~Qt::WindowMaximized;
- q->data->window_state &= ~Qt::WindowFullScreen;
- if (q->isWindow())
- topData()->normalGeometry = QRect(0, 0, -1, -1);
- }
- QPoint oldPos = q->pos();
- data.crect = r;
-
- if ((q->windowType() == Qt::Desktop))
- return;
-
- if (q->isVisible()) {
-
- bool toplevelMove = false;
- QWSWindowSurface *surface = 0;
-
- if (q->isWindow()) {
- //### ConfigPending not implemented, do we need it?
- //setAttribute(Qt::WA_WState_ConfigPending);
- const QWidgetBackingStore *bs = maybeBackingStore();
- if (bs)
- surface = static_cast<QWSWindowSurface*>(bs->windowSurface);
- if (isMove && !isResize && surface) {
- const QPoint offset(x - oldp.x(), y - oldp.y());
- moveSurface(surface, offset);
- toplevelMove = true; //server moves window, but we must send moveEvent, which might trigger painting
-
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- QList<QWindowSurface*> surfaces = bs->subSurfaces;
- for (int i = 0; i < surfaces.size(); ++i)
- moveSurface(surfaces.at(i), offset);
-#endif
- } else {
- updateFrameStrut();
- }
- }
-
- if (!toplevelMove) {
- if (q->isWindow()) {
- if (surface)
- surface->setGeometry(q->frameGeometry());
- else
- invalidateBuffer(q->rect()); //###
-
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- // XXX: should not resize subsurfaces. Children within a layout
- // will be resized automatically while children with a static
- // geometry should get a new clip region instead.
- const QRect clipRect = q->geometry();
- QWidgetBackingStore *bs = maybeBackingStore();
- QList<QWindowSurface*> surfaces = bs->subSurfaces;
- for (int i = 0; i < surfaces.size(); ++i) {
- QWSWindowSurface *s = static_cast<QWSWindowSurface*>(surfaces.at(i));
- QRect srect = s->geometry();
- s->setGeometry(clipRect & srect);
- }
-#endif
- }
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- // XXX: merge this case with the isWindow() case
- else if (maybeTopData() && maybeTopData()->windowSurface) {
- QWSWindowSurface *surface;
- surface = static_cast<QWSWindowSurface*>(q->windowSurface());
- if (isMove && !isResize) {
- moveSurface(surface, QPoint(x - oldp.x(), y - oldp.y()));
- } else {
- const QPoint p = q->mapToGlobal(QPoint());
- surface->setGeometry(QRect(p, QSize(w, h)));
- }
- }
-#endif
- else {
- if (isMove && !isResize)
- moveRect(QRect(oldPos, olds), x - oldPos.x(), y - oldPos.y());
- else
- invalidateBuffer_resizeHelper(oldPos, olds);
- }
- }
-
- //### must have frame geometry correct before sending move/resize events
- if (isMove) {
- QMoveEvent e(q->pos(), oldPos);
- QApplication::sendEvent(q, &e);
- }
- if (isResize) {
- QResizeEvent e(r.size(), olds);
- QApplication::sendEvent(q, &e);
- }
-
- } else { // not visible
- if (isMove && q->pos() != oldPos)
- q->setAttribute(Qt::WA_PendingMoveEvent, true);
- if (isResize)
- q->setAttribute(Qt::WA_PendingResizeEvent, true);
- }
-}
-
-void QWidgetPrivate::setConstraints_sys()
-{
-}
-
-QScreen* QWidgetPrivate::getScreen() const
-{
- Q_Q(const QWidget);
-
- const QList<QScreen*> subScreens = qt_screen->subScreens();
- if (subScreens.isEmpty() || q->windowType() == Qt::Desktop)
- return qt_screen;
-
- const int screen = QApplication::desktop()->screenNumber(q);
-
- return qt_screen->subScreens().at(screen < 0 ? 0 : screen);
-}
-
-void QWidgetPrivate::scroll_sys(int dx, int dy)
-{
- Q_Q(QWidget);
- scrollChildren(dx, dy);
- scrollRect(q->rect(), dx, dy);
-}
-
-void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r)
-{
- scrollRect(r, dx, dy);
-}
-
-int QWidget::metric(PaintDeviceMetric m) const
-{
- Q_D(const QWidget);
-
- int val;
- if (m == PdmWidth) {
- val = data->crect.width();
- } else if (m == PdmWidthMM) {
- const QScreen *screen = d->getScreen();
- val = data->crect.width() * screen->physicalWidth() / screen->width();
- } else if (m == PdmHeight) {
- val = data->crect.height();
- } else if (m == PdmHeightMM) {
- const QScreen *screen = d->getScreen();
- val = data->crect.height() * screen->physicalHeight() / screen->height();
- } else if (m == PdmDepth) {
- return qwsDisplay()->depth();
- } else if (m == PdmDpiX || m == PdmPhysicalDpiX) {
- if (d->extra && d->extra->customDpiX)
- return d->extra->customDpiX;
- else if (d->parent)
- return static_cast<QWidget *>(d->parent)->metric(m);
- const QScreen *screen = d->getScreen();
- return qRound(screen->width() / double(screen->physicalWidth() / 25.4));
- } else if (m == PdmDpiY || m == PdmPhysicalDpiY) {
- if (d->extra && d->extra->customDpiY)
- return d->extra->customDpiY;
- else if (d->parent)
- return static_cast<QWidget *>(d->parent)->metric(m);
- const QScreen *screen = d->getScreen();
- return qRound(screen->height() / double(screen->physicalHeight() / 25.4));
- } else if (m == PdmNumColors) {
- QScreen *screen = d->getScreen();
- int ret = screen->colorCount();
- if (!ret) {
- const int depth = qwsDisplay()->depth();
- switch (depth) {
- case 1:
- ret = 2;
- break;
- case 8:
- ret = 256;
- break;
- case 16:
- ret = 65536;
- break;
- case 24:
- ret = 16777216;
- break;
- case 32:
- ret = 2147483647;
- break;
- }
- }
- return ret;
- } else {
- val = QPaintDevice::metric(m);// XXX
- }
- return val;
-}
-
-void QWidgetPrivate::createSysExtra()
-{
-}
-
-void QWidgetPrivate::deleteSysExtra()
-{
-}
-
-void QWidgetPrivate::createTLSysExtra()
-{
-#ifndef QT_NO_QWS_MANAGER
- extra->topextra->qwsManager = 0;
-#endif
-}
-
-void QWidgetPrivate::deleteTLSysExtra()
-{
-}
-
-void QWidgetPrivate::registerDropSite(bool on)
-{
- Q_UNUSED(on);
-}
-
-QRegion QWidgetPrivate::localRequestedRegion() const
-{
- Q_Q(const QWidget);
- QRegion r(q->rect());
- if (extra && !extra->mask.isEmpty())
- r &= extra->mask;
-
- return r;
-}
-
-QRegion QWidgetPrivate::localAllocatedRegion() const
-{
- Q_Q(const QWidget);
-
- QWidgetBackingStore *wbs = q->window()->d_func()->maybeBackingStore();
-
- QWindowSurface *ws = wbs ? wbs->windowSurface : 0;
- if (!ws)
- return QRegion();
- QRegion r = static_cast<QWSWindowSurface*>(ws)->clipRegion();
- if (!q->isWindow()) {
- QPoint off = q->mapTo(q->window(), QPoint());
- r &= localRequestedRegion().translated(off);
- r.translate(-off);
- }
- return r;
-}
-
-inline bool QRect::intersects(const QRect &r) const
-{
- return (qMax(x1, r.x1) <= qMin(x2, r.x2) &&
- qMax(y1, r.y1) <= qMin(y2, r.y2));
-}
-
-void QWidgetPrivate::setMask_sys(const QRegion &region)
-{
- Q_UNUSED(region);
- Q_Q(QWidget);
-
- if (!q->isVisible() || !q->isWindow())
- return;
-
- data.fstrut_dirty = true;
- invalidateBuffer(q->rect());
- QWindowSurface *surface = extra->topextra->backingStore->windowSurface;
- if (surface) {
- // QWSWindowSurface::setGeometry() returns without doing anything
- // if old geom == new geom. Therefore, we need to reset the old value.
- surface->QWindowSurface::setGeometry(QRect());
- surface->setGeometry(q->frameGeometry());
- }
-}
-
-void QWidgetPrivate::updateFrameStrut()
-{
- Q_Q(QWidget);
-
- if(!q->isVisible() || (q->windowType() == Qt::Desktop)) {
- data.fstrut_dirty = q->isVisible();
- return;
- }
-
-#ifndef QT_NO_QWS_MANAGER
- if (extra && extra->topextra && extra->topextra->qwsManager) {
- QTLWExtra *topextra = extra->topextra;
- const QRect oldFrameStrut = topextra->frameStrut;
- const QRect contents = data.crect;
- QRegion r = localRequestedRegion().translated(contents.topLeft());
- r += extra->topextra->qwsManager->region();
- const QRect frame = r.boundingRect();
-
- topextra->frameStrut.setCoords(contents.left() - frame.left(),
- contents.top() - frame.top(),
- frame.right() - contents.right(),
- frame.bottom() - contents.bottom());
- topextra->qwsManager->repaintRegion(QDecoration::All, QDecoration::Normal);
- }
-#endif
- data.fstrut_dirty = false;
-}
-
-#ifndef QT_NO_CURSOR
-void QWidgetPrivate::updateCursor() const
-{
- Q_Q(const QWidget);
-
- if (QApplication::overrideCursor())
- return;
-
- if (qt_last_x
- && (!QWidget::mouseGrabber() || QWidget::mouseGrabber() == q)
- && qt_last_cursor != (WId)q->cursor().handle())
- {
- const QPoint pos(*qt_last_x, *qt_last_y);
- const QPoint offset = q->mapToGlobal(QPoint());
- if (!localAllocatedRegion().contains(pos - offset))
- return;
-
- const QWidget *w = q->childAt(q->mapFromGlobal(pos));
- if (!w || w->cursor().handle() == q->cursor().handle())
- QWidget::qwsDisplay()->selectCursor(const_cast<QWidget*>(q),
- q->cursor().handle());
- }
-}
-#endif
-
-void QWidgetPrivate::setWindowOpacity_sys(qreal level)
-{
- Q_Q(QWidget);
- Q_UNUSED(level);
- createWinId();
- QWidget::qwsDisplay()->setOpacity(q->data->winid, topData()->opacity);
-}
-
-//static QSingleCleanupHandler<QWSPaintEngine> qt_paintengine_cleanup_handler;
-//static QWSPaintEngine *qt_widget_paintengine = 0;
-QPaintEngine *QWidget::paintEngine() const
-{
- qWarning("QWidget::paintEngine: Should no longer be called");
- return 0; //##### @@@
-// if (!qt_widget_paintengine) {
-// qt_widget_paintengine = new QRasterPaintEngine();
-// qt_paintengine_cleanup_handler.set(&qt_widget_paintengine);
-// }
-// if (qt_widget_paintengine->isActive()) {
-// if (d->extraPaintEngine)
-// return d->extraPaintEngine;
-// const_cast<QWidget *>(this)->d_func()->extraPaintEngine = new QRasterPaintEngine();
-// return d->extraPaintEngine;
-// }
-// return qt_widget_paintengine;
-}
-
-QWindowSurface *QWidgetPrivate::createDefaultWindowSurface_sys()
-{
- Q_Q(QWidget);
- if (q->windowType() == Qt::Desktop)
- return 0;
- q->ensurePolished();
- return qt_screen->createSurface(q);
-}
-
-void QWidgetPrivate::setModal_sys()
-{
-}
-
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qwidgetaction.h b/src/gui/kernel/qwidgetaction.h
deleted file mode 100644
index a32b5d60dd..0000000000
--- a/src/gui/kernel/qwidgetaction.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWIDGETACTION_H
-#define QWIDGETACTION_H
-
-#include <QtGui/qaction.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_ACTION
-
-class QWidgetActionPrivate;
-
-class Q_GUI_EXPORT QWidgetAction : public QAction
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QWidgetAction)
-
-public:
- explicit QWidgetAction(QObject *parent);
- virtual ~QWidgetAction();
-
- void setDefaultWidget(QWidget *w);
- QWidget *defaultWidget() const;
-
- QWidget *requestWidget(QWidget *parent);
- void releaseWidget(QWidget *widget);
-
-protected:
- virtual bool event(QEvent *);
- virtual bool eventFilter(QObject *, QEvent *);
- virtual QWidget *createWidget(QWidget *parent);
- virtual void deleteWidget(QWidget *widget);
- QList<QWidget *> createdWidgets() const;
-
-private:
- Q_DISABLE_COPY(QWidgetAction)
- Q_PRIVATE_SLOT(d_func(), void _q_widgetDestroyed(QObject *))
- friend class QToolBar;
-};
-
-#endif // QT_NO_ACTION
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QWIDGETACTION_H
diff --git a/src/gui/kernel/qwindowdefs.h b/src/gui/kernel/qwindowdefs.h
deleted file mode 100644
index ab8af5fbb2..0000000000
--- a/src/gui/kernel/qwindowdefs.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWDEFS_H
-#define QWINDOWDEFS_H
-
-#include <QtCore/qobjectdefs.h>
-#include <QtCore/qnamespace.h>
-
-QT_BEGIN_HEADER
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-// Class forward definitions
-
-class QPaintDevice;
-class QWidget;
-class QDialog;
-class QColor;
-class QPalette;
-#ifdef QT3_SUPPORT
-class QColorGroup;
-#endif
-class QCursor;
-class QPoint;
-class QSize;
-class QRect;
-class QPolygon;
-class QPainter;
-class QRegion;
-class QFont;
-class QFontMetrics;
-class QFontInfo;
-class QPen;
-class QBrush;
-class QMatrix;
-class QPixmap;
-class QBitmap;
-class QMovie;
-class QImage;
-class QPicture;
-class QPrinter;
-class QTimer;
-class QTime;
-class QClipboard;
-class QString;
-class QByteArray;
-class QApplication;
-
-template<typename T> class QList;
-typedef QList<QWidget *> QWidgetList;
-
-QT_END_NAMESPACE
-QT_END_HEADER
-
-// Window system dependent definitions
-
-#if defined(Q_WS_MAC) && !defined(Q_WS_QWS)
-
-#include <QtGui/qmacdefines_mac.h>
-
-#ifdef Q_WS_MAC32
-typedef int WId;
-#else
-typedef long WId;
-#endif
-
-#endif // Q_WS_MAC
-
-#if defined(Q_WS_WIN)
-#include <QtGui/qwindowdefs_win.h>
-#endif // Q_WS_WIN
-
-#if defined(Q_WS_X11)
-
-typedef struct _XDisplay Display;
-typedef union _XEvent XEvent;
-typedef struct _XGC *GC;
-typedef struct _XRegion *Region;
-typedef unsigned long WId;
-
-#endif // Q_WS_X11
-
-#if defined(Q_WS_QWS)
-
-typedef unsigned long WId;
-QT_BEGIN_HEADER
-QT_BEGIN_NAMESPACE
-struct QWSEvent;
-QT_END_NAMESPACE
-QT_END_HEADER
-
-#endif // Q_WS_QWS
-
-#if defined(Q_WS_QPA)
-
-typedef unsigned long WId;
-
-#endif // Q_WS_QPA
-
-#if defined(Q_OS_SYMBIAN)
-class CCoeControl;
-typedef CCoeControl * WId;
-#endif // Q_OS_SYMBIAN
-
-QT_BEGIN_HEADER
-QT_BEGIN_NAMESPACE
-
-template<class K, class V> class QHash;
-typedef QHash<WId, QWidget *> QWidgetMapper;
-
-template<class V> class QSet;
-typedef QSet<QWidget *> QWidgetSet;
-
-QT_END_NAMESPACE
-QT_END_HEADER
-
-#if defined(QT_NEEDS_QMAIN)
-#define main qMain
-#endif
-
-// Global platform-independent types and functions
-
-#endif // QWINDOWDEFS_H
diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.cpp b/src/gui/kernel/qwindowsysteminterface_qpa.cpp
deleted file mode 100644
index 740bb82ccc..0000000000
--- a/src/gui/kernel/qwindowsysteminterface_qpa.cpp
+++ /dev/null
@@ -1,291 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "qwindowsysteminterface_qpa.h"
-#include "qwindowsysteminterface_qpa_p.h"
-#include "qapplication_p.h"
-#include <QAbstractEventDispatcher>
-
-QT_BEGIN_NAMESPACE
-
-
-QTime QWindowSystemInterfacePrivate::eventTime;
-
-//------------------------------------------------------------
-//
-// Callback functions for plugins:
-//
-
-QList<QWindowSystemInterfacePrivate::WindowSystemEvent *> QWindowSystemInterfacePrivate::windowSystemEventQueue;
-QMutex QWindowSystemInterfacePrivate::queueMutex;
-
-extern QPointer<QWidget> qt_last_mouse_receiver;
-
-
-void QWindowSystemInterface::handleEnterEvent(QWidget *tlw)
-{
- if (tlw) {
- QWidgetData *data = qt_qwidget_data(tlw);
- if (data->in_destructor)
- return;
-
- QWindowSystemInterfacePrivate::EnterEvent *e = new QWindowSystemInterfacePrivate::EnterEvent(tlw);
- QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
- }
-}
-
-void QWindowSystemInterface::handleLeaveEvent(QWidget *tlw)
-{
- if (tlw) {
- QWidgetData *data = qt_qwidget_data(tlw);
- if (data->in_destructor)
- return;
- }
- QWindowSystemInterfacePrivate::LeaveEvent *e = new QWindowSystemInterfacePrivate::LeaveEvent(tlw);
- QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
-}
-
-void QWindowSystemInterface::handleWindowActivated(QWidget *tlw)
-{
- QWindowSystemInterfacePrivate::ActivatedWindowEvent *e = new QWindowSystemInterfacePrivate::ActivatedWindowEvent(tlw);
- QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
-}
-
-void QWindowSystemInterface::handleGeometryChange(QWidget *tlw, const QRect &newRect)
-{
- if (tlw) {
- QWidgetData *data = qt_qwidget_data(tlw);
- if (data->in_destructor)
- return;
- }
- QWindowSystemInterfacePrivate::GeometryChangeEvent *e = new QWindowSystemInterfacePrivate::GeometryChangeEvent(tlw,newRect);
- QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
-}
-
-
-void QWindowSystemInterface::handleCloseEvent(QWidget *tlw)
-{
- if (tlw) {
- QWindowSystemInterfacePrivate::CloseEvent *e =
- new QWindowSystemInterfacePrivate::CloseEvent(tlw);
- QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
- }
-}
-
-/*!
-
-\a tlw == 0 means that \a ev is in global coords only
-
-
-*/
-void QWindowSystemInterface::handleMouseEvent(QWidget *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b) {
- unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
- handleMouseEvent(w, time, local, global, b);
-}
-
-void QWindowSystemInterface::handleMouseEvent(QWidget *tlw, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b)
-{
- if (tlw) {
- QWidgetData *data = qt_qwidget_data(tlw);
- if (data->in_destructor)
- tlw = 0;
- }
- QWindowSystemInterfacePrivate::MouseEvent * e =
- new QWindowSystemInterfacePrivate::MouseEvent(tlw, timestamp, local, global, b);
- QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
-}
-
-void QWindowSystemInterface::handleKeyEvent(QWidget *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count) {
- unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
- handleKeyEvent(w, time, t, k, mods, text, autorep, count);
-}
-
-void QWindowSystemInterface::handleKeyEvent(QWidget *tlw, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count)
-{
- if (tlw) {
- QWidgetData *data = qt_qwidget_data(tlw);
- if (data->in_destructor)
- tlw = 0;
- }
-
- QWindowSystemInterfacePrivate::KeyEvent * e =
- new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, t, k, mods, text, autorep, count);
- QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
-}
-
-void QWindowSystemInterface::handleExtendedKeyEvent(QWidget *w, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
- quint32 nativeScanCode, quint32 nativeVirtualKey,
- quint32 nativeModifiers,
- const QString& text, bool autorep,
- ushort count)
-{
- unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
- handleExtendedKeyEvent(w, time, type, key, modifiers, nativeScanCode, nativeVirtualKey, nativeModifiers,
- text, autorep, count);
-}
-
-void QWindowSystemInterface::handleExtendedKeyEvent(QWidget *tlw, ulong timestamp, QEvent::Type type, int key,
- Qt::KeyboardModifiers modifiers,
- quint32 nativeScanCode, quint32 nativeVirtualKey,
- quint32 nativeModifiers,
- const QString& text, bool autorep,
- ushort count)
-{
- if (tlw) {
- QWidgetData *data = qt_qwidget_data(tlw);
- if (data->in_destructor)
- tlw = 0;
- }
-
- QWindowSystemInterfacePrivate::KeyEvent * e =
- new QWindowSystemInterfacePrivate::KeyEvent(tlw, timestamp, type, key, modifiers,
- nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count);
- QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
-}
-
-void QWindowSystemInterface::handleWheelEvent(QWidget *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o) {
- unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
- handleWheelEvent(w, time, local, global, d, o);
-}
-
-void QWindowSystemInterface::handleWheelEvent(QWidget *tlw, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o)
-{
- if (tlw) {
- QWidgetData *data = qt_qwidget_data(tlw);
- if (data->in_destructor)
- tlw = 0;
- }
-
- QWindowSystemInterfacePrivate::WheelEvent *e =
- new QWindowSystemInterfacePrivate::WheelEvent(tlw, timestamp, local, global, d, o);
- QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
-}
-
-int QWindowSystemInterfacePrivate::windowSystemEventsQueued()
-{
- queueMutex.lock();
- int ret = windowSystemEventQueue.count();
- queueMutex.unlock();
- return ret;
-}
-
-QWindowSystemInterfacePrivate::WindowSystemEvent * QWindowSystemInterfacePrivate::getWindowSystemEvent()
-{
- queueMutex.lock();
- QWindowSystemInterfacePrivate::WindowSystemEvent *ret;
- if (windowSystemEventQueue.isEmpty())
- ret = 0;
- else
- ret = windowSystemEventQueue.takeFirst();
- queueMutex.unlock();
- return ret;
-}
-
-void QWindowSystemInterfacePrivate::queueWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *ev)
-{
- queueMutex.lock();
- windowSystemEventQueue.append(ev);
- queueMutex.unlock();
-
- QAbstractEventDispatcher *dispatcher = QApplicationPrivate::qt_qpa_core_dispatcher();
- if (dispatcher)
- dispatcher->wakeUp();
-}
-
-void QWindowSystemInterface::handleTouchEvent(QWidget *w, QEvent::Type type, QTouchEvent::DeviceType devType, const QList<struct TouchPoint> &points) {
- unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
- handleTouchEvent(w, time, type, devType, points);
-}
-
-void QWindowSystemInterface::handleTouchEvent(QWidget *tlw, ulong timestamp, QEvent::Type type, QTouchEvent::DeviceType devType, const QList<struct TouchPoint> &points)
-{
- if (!points.size()) // Touch events must have at least one point
- return;
-
- QList<QTouchEvent::TouchPoint> touchPoints;
- Qt::TouchPointStates states;
- QTouchEvent::TouchPoint p;
-
- QList<struct TouchPoint>::const_iterator point = points.constBegin();
- QList<struct TouchPoint>::const_iterator end = points.constEnd();
- while (point != end) {
- p.setId(point->id);
- p.setPressure(point->pressure);
- states |= point->state;
- Qt::TouchPointStates state = point->state;
- if (point->isPrimary) {
- state |= Qt::TouchPointPrimary;
- }
- p.setState(state);
- p.setRect(point->area);
- p.setScreenPos(point->area.center());
- p.setNormalizedPos(point->normalPosition);
-
- touchPoints.append(p);
- ++point;
- }
-
- QWindowSystemInterfacePrivate::TouchEvent *e =
- new QWindowSystemInterfacePrivate::TouchEvent(tlw, timestamp, type, devType, touchPoints);
- QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
-}
-
-void QWindowSystemInterface::handleScreenGeometryChange(int screenIndex)
-{
- QWindowSystemInterfacePrivate::ScreenGeometryEvent *e =
- new QWindowSystemInterfacePrivate::ScreenGeometryEvent(screenIndex);
- QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
-}
-
-void QWindowSystemInterface::handleScreenAvailableGeometryChange(int screenIndex)
-{
- QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e =
- new QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent(screenIndex);
- QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
-}
-
-void QWindowSystemInterface::handleScreenCountChange(int count)
-{
- QWindowSystemInterfacePrivate::ScreenCountEvent *e =
- new QWindowSystemInterfacePrivate::ScreenCountEvent(count);
- QWindowSystemInterfacePrivate::queueWindowSystemEvent(e);
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.h b/src/gui/kernel/qwindowsysteminterface_qpa.h
deleted file mode 100644
index a882fc15b6..0000000000
--- a/src/gui/kernel/qwindowsysteminterface_qpa.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QWINDOWSYSTEMINTERFACE_H
-#define QWINDOWSYSTEMINTERFACE_H
-
-#include <QtCore/QTime>
-#include <QtGui/qwindowdefs.h>
-#include <QtCore/QEvent>
-#include <QtGui/QWidget>
-#include <QtCore/QWeakPointer>
-#include <QtCore/QMutex>
-#include <QtGui/QTouchEvent>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class Q_GUI_EXPORT QWindowSystemInterface
-{
-public:
- static void handleMouseEvent(QWidget *w, const QPoint & local, const QPoint & global, Qt::MouseButtons b);
- static void handleMouseEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, Qt::MouseButtons b);
-
- static void handleKeyEvent(QWidget *w, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
- static void handleKeyEvent(QWidget *w, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1);
-
- static void handleExtendedKeyEvent(QWidget *w, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
- quint32 nativeScanCode, quint32 nativeVirtualKey,
- quint32 nativeModifiers,
- const QString& text = QString(), bool autorep = false,
- ushort count = 1);
- static void handleExtendedKeyEvent(QWidget *w, ulong timestamp, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
- quint32 nativeScanCode, quint32 nativeVirtualKey,
- quint32 nativeModifiers,
- const QString& text = QString(), bool autorep = false,
- ushort count = 1);
-
- static void handleWheelEvent(QWidget *w, const QPoint & local, const QPoint & global, int d, Qt::Orientation o);
- static void handleWheelEvent(QWidget *w, ulong timestamp, const QPoint & local, const QPoint & global, int d, Qt::Orientation o);
-
- struct TouchPoint {
- int id; // for application use
- bool isPrimary; // for application use
- QPointF normalPosition; // touch device coordinates, (0 to 1, 0 to 1)
- QRectF area; // the touched area, centered at position in screen coordinates
- qreal pressure; // 0 to 1
- Qt::TouchPointState state; //Qt::TouchPoint{Pressed|Moved|Stationary|Released}
- };
-
- static void handleTouchEvent(QWidget *w, QEvent::Type type, QTouchEvent::DeviceType devType, const QList<struct TouchPoint> &points);
- static void handleTouchEvent(QWidget *w, ulong timestamp, QEvent::Type type, QTouchEvent::DeviceType devType, const QList<struct TouchPoint> &points);
-
- static void handleGeometryChange(QWidget *w, const QRect &newRect);
- static void handleCloseEvent(QWidget *w);
- static void handleEnterEvent(QWidget *w);
- static void handleLeaveEvent(QWidget *w);
- static void handleWindowActivated(QWidget *w);
-
- // Changes to the screen
- static void handleScreenGeometryChange(int screenIndex);
- static void handleScreenAvailableGeometryChange(int screenIndex);
- static void handleScreenCountChange(int count);
-};
-
-QT_END_NAMESPACE
-QT_END_HEADER
-#endif // QWINDOWSYSTEMINTERFACE_H
diff --git a/src/gui/kernel/qwindowsysteminterface_qpa_p.h b/src/gui/kernel/qwindowsysteminterface_qpa_p.h
deleted file mode 100644
index 6be86ad9a5..0000000000
--- a/src/gui/kernel/qwindowsysteminterface_qpa_p.h
+++ /dev/null
@@ -1,208 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QWINDOWSYSTEMINTERFACE_QPA_P_H
-#define QWINDOWSYSTEMINTERFACE_QPA_P_H
-
-#include "qwindowsysteminterface_qpa.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QWindowSystemInterfacePrivate {
-public:
- enum EventType {
- Close,
- GeometryChange,
- Enter,
- Leave,
- ActivatedWindow,
- Mouse,
- Wheel,
- Key,
- Touch,
- ScreenGeometry,
- ScreenAvailableGeometry,
- ScreenCountChange
- };
-
- class WindowSystemEvent {
- public:
- WindowSystemEvent(EventType t)
- : type(t) { }
- EventType type;
- };
-
- class CloseEvent : public WindowSystemEvent {
- public:
- CloseEvent(QWidget *tlw)
- : WindowSystemEvent(Close), topLevel(tlw) { }
- QWeakPointer<QWidget> topLevel;
- };
-
- class GeometryChangeEvent : public WindowSystemEvent {
- public:
- GeometryChangeEvent(QWidget *tlw, const QRect &newGeometry)
- : WindowSystemEvent(GeometryChange), tlw(tlw), newGeometry(newGeometry)
- { }
- QWeakPointer<QWidget> tlw;
- QRect newGeometry;
- };
-
- class EnterEvent : public WindowSystemEvent {
- public:
- EnterEvent(QWidget *enter)
- : WindowSystemEvent(Enter), enter(enter)
- { }
- QWeakPointer<QWidget> enter;
- };
-
- class LeaveEvent : public WindowSystemEvent {
- public:
- LeaveEvent(QWidget *leave)
- : WindowSystemEvent(Leave), leave(leave)
- { }
- QWeakPointer<QWidget> leave;
- };
-
- class ActivatedWindowEvent : public WindowSystemEvent {
- public:
- ActivatedWindowEvent(QWidget *activatedWindow)
- : WindowSystemEvent(ActivatedWindow), activated(activatedWindow)
- { }
- QWeakPointer<QWidget> activated;
- };
-
- class UserEvent : public WindowSystemEvent {
- public:
- UserEvent(QWidget * w, ulong time, EventType t)
- : WindowSystemEvent(t), widget(w), timestamp(time) { }
- QWeakPointer<QWidget> widget;
- unsigned long timestamp;
- };
-
- class MouseEvent : public UserEvent {
- public:
- MouseEvent(QWidget * w, ulong time, const QPoint & local, const QPoint & global, Qt::MouseButtons b)
- : UserEvent(w, time, Mouse), localPos(local), globalPos(global), buttons(b) { }
- QPoint localPos;
- QPoint globalPos;
- Qt::MouseButtons buttons;
- };
-
- class WheelEvent : public UserEvent {
- public:
- WheelEvent(QWidget *w, ulong time, const QPoint & local, const QPoint & global, int d, Qt::Orientation o)
- : UserEvent(w, time, Wheel), delta(d), localPos(local), globalPos(global), orient(o) { }
- int delta;
- QPoint localPos;
- QPoint globalPos;
- Qt::Orientation orient;
- };
-
- class KeyEvent : public UserEvent {
- public:
- KeyEvent(QWidget *w, ulong time, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1)
- :UserEvent(w, time, Key), key(k), unicode(text), repeat(autorep),
- repeatCount(count), modifiers(mods), keyType(t),
- nativeScanCode(0), nativeVirtualKey(0), nativeModifiers(0) { }
- KeyEvent(QWidget *w, ulong time, QEvent::Type t, int k, Qt::KeyboardModifiers mods,
- quint32 nativeSC, quint32 nativeVK, quint32 nativeMods,
- const QString & text = QString(), bool autorep = false, ushort count = 1)
- :UserEvent(w, time, Key), key(k), unicode(text), repeat(autorep),
- repeatCount(count), modifiers(mods), keyType(t),
- nativeScanCode(nativeSC), nativeVirtualKey(nativeVK), nativeModifiers(nativeMods) { }
- int key;
- QString unicode;
- bool repeat;
- ushort repeatCount;
- Qt::KeyboardModifiers modifiers;
- QEvent::Type keyType;
- quint32 nativeScanCode;
- quint32 nativeVirtualKey;
- quint32 nativeModifiers;
- };
-
- class TouchEvent : public UserEvent {
- public:
- TouchEvent(QWidget *w, ulong time, QEvent::Type t, QTouchEvent::DeviceType d, const QList<QTouchEvent::TouchPoint> &p)
- :UserEvent(w, time, Touch), devType(d), points(p), touchType(t) { }
- QTouchEvent::DeviceType devType;
- QList<QTouchEvent::TouchPoint> points;
- QEvent::Type touchType;
-
- };
-
- class ScreenCountEvent : public WindowSystemEvent {
- public:
- ScreenCountEvent (int count)
- : WindowSystemEvent(ScreenCountChange) , count(count) { }
- int count;
- };
-
- class ScreenGeometryEvent : public WindowSystemEvent {
- public:
- ScreenGeometryEvent(int index)
- : WindowSystemEvent(ScreenGeometry), index(index) { }
- int index;
- };
-
- class ScreenAvailableGeometryEvent : public WindowSystemEvent {
- public:
- ScreenAvailableGeometryEvent(int index)
- : WindowSystemEvent(ScreenAvailableGeometry), index(index) { }
- int index;
- };
-
- static QList<WindowSystemEvent *> windowSystemEventQueue;
- static QMutex queueMutex;
-
- static int windowSystemEventsQueued();
- static WindowSystemEvent * getWindowSystemEvent();
- static void queueWindowSystemEvent(WindowSystemEvent *ev);
-
- static QTime eventTime;
-};
-
-QT_END_HEADER
-QT_END_NAMESPACE
-
-#endif // QWINDOWSYSTEMINTERFACE_QPA_P_H
diff --git a/src/gui/kernel/qx11embed_x11.h b/src/gui/kernel/qx11embed_x11.h
deleted file mode 100644
index 30929f7ba9..0000000000
--- a/src/gui/kernel/qx11embed_x11.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QX11EMBED_X11_H
-#define QX11EMBED_X11_H
-
-#include <QtGui/qwidget.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QX11EmbedWidgetPrivate;
-class Q_GUI_EXPORT QX11EmbedWidget : public QWidget
-{
- Q_OBJECT
-public:
- QX11EmbedWidget(QWidget *parent = 0);
- ~QX11EmbedWidget();
-
- void embedInto(WId id);
- WId containerWinId() const;
-
- enum Error {
- Unknown,
- Internal,
- InvalidWindowID
- };
- Error error() const;
-
-Q_SIGNALS:
- void embedded();
- void containerClosed();
- void error(QX11EmbedWidget::Error error);
-
-protected:
- bool x11Event(XEvent *);
- bool eventFilter(QObject *, QEvent *);
- bool event(QEvent *);
- void resizeEvent(QResizeEvent *);
-
-private:
- Q_DECLARE_PRIVATE(QX11EmbedWidget)
- Q_DISABLE_COPY(QX11EmbedWidget)
-};
-
-class QX11EmbedContainerPrivate;
-class Q_GUI_EXPORT QX11EmbedContainer : public QWidget
-{
- Q_OBJECT
-public:
- QX11EmbedContainer(QWidget *parent = 0);
- ~QX11EmbedContainer();
-
- void embedClient(WId id);
- void discardClient();
-
- WId clientWinId() const;
-
- QSize minimumSizeHint() const;
-
- enum Error {
- Unknown,
- Internal,
- InvalidWindowID
- };
- Error error() const;
-
-Q_SIGNALS:
- void clientIsEmbedded();
- void clientClosed();
- void error(QX11EmbedContainer::Error);
-
-protected:
- bool x11Event(XEvent *);
- bool eventFilter(QObject *, QEvent *);
- void paintEvent(QPaintEvent *e);
- void resizeEvent(QResizeEvent *);
- void showEvent(QShowEvent *);
- void hideEvent(QHideEvent *);
- bool event(QEvent *);
-
-private:
- Q_DECLARE_PRIVATE(QX11EmbedContainer)
- Q_DISABLE_COPY(QX11EmbedContainer)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QX11EMBED_X11_H
diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri
index 65e7af4742..07d4b942b1 100644
--- a/src/gui/painting/painting.pri
+++ b/src/gui/painting/painting.pri
@@ -6,9 +6,7 @@ HEADERS += \
painting/qcolor.h \
painting/qcolor_p.h \
painting/qcolormap.h \
- painting/qdrawutil.h \
painting/qemulationpaintengine_p.h \
- painting/qgraphicssystem_p.h \
painting/qmatrix.h \
painting/qmemrotate_p.h \
painting/qoutlinemapper_p.h \
@@ -29,8 +27,6 @@ HEADERS += \
painting/qpolygon.h \
painting/qpolygonclipper_p.h \
painting/qprintengine.h \
- painting/qprintengine_pdf_p.h \
- painting/qprintengine_ps_p.h \
painting/qprinter.h \
painting/qprinter_p.h \
painting/qprinterinfo.h \
@@ -38,12 +34,10 @@ HEADERS += \
painting/qrasterizer_p.h \
painting/qregion.h \
painting/qstroker_p.h \
- painting/qstylepainter.h \
painting/qtessellator_p.h \
painting/qtextureglyphcache_p.h \
painting/qtransform.h \
painting/qwindowsurface_p.h \
- painting/qwmatrix.h \
painting/qpaintbuffer_p.h
@@ -54,9 +48,7 @@ SOURCES += \
painting/qcolor.cpp \
painting/qcolor_p.cpp \
painting/qcssutil.cpp \
- painting/qdrawutil.cpp \
painting/qemulationpaintengine.cpp \
- painting/qgraphicssystem.cpp \
painting/qmatrix.cpp \
painting/qmemrotate.cpp \
painting/qoutlinemapper.cpp \
@@ -72,13 +64,11 @@ SOURCES += \
painting/qpen.cpp \
painting/qpolygon.cpp \
painting/qprintengine_pdf.cpp \
- painting/qprintengine_ps.cpp \
painting/qprinter.cpp \
painting/qprinterinfo.cpp \
painting/qrasterizer.cpp \
painting/qregion.cpp \
painting/qstroker.cpp \
- painting/qstylepainter.cpp \
painting/qtessellator.cpp \
painting/qtextureglyphcache.cpp \
painting/qtransform.cpp \
@@ -114,28 +104,6 @@ win32 {
!win32-borland:!wince*:LIBS += -lmsimg32
}
-embedded {
- HEADERS += \
- painting/qgraphicssystem_qws_p.h \
-
- SOURCES += \
- painting/qgraphicssystem_qws.cpp \
-
-} else: if(!qpa) {
- HEADERS += \
- painting/qgraphicssystem_raster_p.h \
- painting/qgraphicssystem_runtime_p.h \
- painting/qgraphicssystemfactory_p.h \
- painting/qgraphicssystemplugin_p.h \
- painting/qwindowsurface_raster_p.h
-
- SOURCES += \
- painting/qgraphicssystem_raster.cpp \
- painting/qgraphicssystem_runtime.cpp \
- painting/qgraphicssystemfactory.cpp \
- painting/qgraphicssystemplugin.cpp \
- painting/qwindowsurface_raster.cpp
-}
unix:x11 {
HEADERS += \
@@ -147,17 +115,15 @@ unix:x11 {
painting/qpaintengine_x11.cpp
}
-!embedded:!qpa:!x11:mac {
+!qpa:!x11:mac {
HEADERS += \
painting/qpaintengine_mac_p.h \
- painting/qgraphicssystem_mac_p.h \
painting/qprintengine_mac_p.h
SOURCES += \
painting/qcolormap_mac.cpp \
painting/qpaintdevice_mac.cpp \
painting/qpaintengine_mac.cpp \
- painting/qgraphicssystem_mac.cpp \
painting/qprinterinfo_mac.cpp
OBJECTIVE_SOURCES += \
painting/qprintengine_mac.mm \
@@ -170,23 +136,6 @@ unix:!mac:!symbian|qpa {
painting/qprinterinfo_unix.cpp
}
-win32|x11|mac|embedded|qpa|symbian {
- SOURCES += painting/qbackingstore.cpp
- HEADERS += painting/qbackingstore_p.h
-}
-
-embedded {
- contains(QT_CONFIG,qtopia) {
- DEFINES += QTOPIA_PRINTENGINE
- HEADERS += painting/qprintengine_qws_p.h
- SOURCES += painting/qprintengine_qws.cpp
- }
-
- SOURCES += \
- painting/qcolormap_qws.cpp \
- painting/qpaintdevice_qws.cpp
-}
-
qpa {
SOURCES += \
painting/qcolormap_qpa.cpp \
@@ -203,7 +152,7 @@ symbian {
painting/qpaintengine_s60_p.h
}
-x11|embedded|qpa {
+x11|qpa {
contains(QT_CONFIG,qtopia) {
DEFINES += QT_NO_CUPS QT_NO_LPR
} else {
@@ -228,29 +177,8 @@ if(mmx|3dnow|sse|sse2|iwmmxt) {
IWMMXT_SOURCES += painting/qdrawhelper_iwmmxt.cpp
}
-x11 {
- HEADERS += painting/qwindowsurface_x11_p.h
- SOURCES += painting/qwindowsurface_x11.cpp
-}
-
-!embedded:!qpa:mac {
- HEADERS += painting/qwindowsurface_mac_p.h \
- painting/qunifiedtoolbarsurface_mac_p.h
- SOURCES += painting/qwindowsurface_mac.cpp \
- painting/qunifiedtoolbarsurface_mac.cpp
-}
-
-embedded {
- HEADERS += painting/qwindowsurface_qws_p.h
- SOURCES += painting/qwindowsurface_qws.cpp
-}
-
-
-
symbian {
- HEADERS += painting/qwindowsurface_s60_p.h \
- painting/qdrawhelper_arm_simd_p.h
- SOURCES += painting/qwindowsurface_s60.cpp
+ HEADERS += painting/qdrawhelper_arm_simd_p.h
armccIfdefBlock = \
"$${LITERAL_HASH}if defined(ARMV6)" \
"MACRO QT_HAVE_ARM_SIMD" \
diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp
deleted file mode 100644
index 42c1c354b6..0000000000
--- a/src/gui/painting/qbackingstore.cpp
+++ /dev/null
@@ -1,1668 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include "qplatformdefs.h"
-
-#include "qbackingstore_p.h"
-
-#include <QtCore/qglobal.h>
-#include <QtCore/qdebug.h>
-#include <QtCore/qvarlengtharray.h>
-#include <QtGui/qevent.h>
-#include <QtGui/qapplication.h>
-#include <QtGui/qpaintengine.h>
-#include <QtGui/qgraphicsproxywidget.h>
-
-#include <private/qwidget_p.h>
-#include <private/qwindowsurface_raster_p.h>
-#include <private/qapplication_p.h>
-#include <private/qpaintengine_raster_p.h>
-#include <private/qgraphicseffect_p.h>
-
-#include "qgraphicssystem_p.h"
-
-#ifdef Q_WS_QWS
-#include <QtGui/qwsmanager_qws.h>
-#include <private/qwsmanager_p.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-extern QRegion qt_dirtyRegion(QWidget *);
-
-/*
- A version of QRect::intersects() that does not normalize the rects.
-*/
-static inline bool qRectIntersects(const QRect &r1, const QRect &r2)
-{
- return (qMax(r1.left(), r2.left()) <= qMin(r1.right(), r2.right())
- && qMax(r1.top(), r2.top()) <= qMin(r1.bottom(), r2.bottom()));
-}
-
-/**
- * Flushes the contents of the \a windowSurface into the screen area of \a widget.
- * \a tlwOffset is the position of the top level widget relative to the window surface.
- * \a region is the region to be updated in \a widget coordinates.
- */
-static inline void qt_flush(QWidget *widget, const QRegion &region, QWindowSurface *windowSurface,
- QWidget *tlw, const QPoint &tlwOffset)
-{
- Q_ASSERT(widget);
- Q_ASSERT(!region.isEmpty());
- Q_ASSERT(windowSurface);
- Q_ASSERT(tlw);
-
-#if !defined(QT_NO_PAINT_DEBUG) && !defined(Q_WS_QWS)
- // QWS does flush update in QWindowSurface::flush (because it needs to lock the surface etc).
- static int flushUpdate = qgetenv("QT_FLUSH_UPDATE").toInt();
- if (flushUpdate > 0)
- QWidgetBackingStore::showYellowThing(widget, region, flushUpdate * 10, false);
-#endif
-
- //The performance hit by doing this should be negligible. However, be aware that
- //using this FPS when you have > 1 windowsurface can give you inaccurate FPS
- static bool fpsDebug = qgetenv("QT_DEBUG_FPS").toInt();
- if (fpsDebug) {
- static QTime time = QTime::currentTime();
- static int frames = 0;
-
- frames++;
-
- if(time.elapsed() > 5000) {
- double fps = double(frames * 1000) /time.restart();
- fprintf(stderr,"FPS: %.1f\n",fps);
- frames = 0;
- }
- }
- if (widget != tlw)
- windowSurface->flush(widget, region, tlwOffset + widget->mapTo(tlw, QPoint()));
- else
- windowSurface->flush(widget, region, tlwOffset);
-}
-
-#ifndef QT_NO_PAINT_DEBUG
-#ifdef Q_WS_WIN
-static void showYellowThing_win(QWidget *widget, const QRegion &region, int msec)
-{
- HBRUSH brush;
- static int i = 0;
- switch (i) {
- case 0:
- brush = CreateSolidBrush(RGB(255, 255, 0));
- break;
- case 1:
- brush = CreateSolidBrush(RGB(255, 200, 55));
- break;
- case 2:
- brush = CreateSolidBrush(RGB(200, 255, 55));
- break;
- case 3:
- brush = CreateSolidBrush(RGB(200, 200, 0));
- break;
- }
- i = (i + 1) & 3;
-
- HDC hdc = widget->getDC();
-
- const QVector<QRect> &rects = region.rects();
- foreach (QRect rect, rects) {
- RECT winRect;
- SetRect(&winRect, rect.left(), rect.top(), rect.right(), rect.bottom());
- FillRect(hdc, &winRect, brush);
- }
-
- widget->releaseDC(hdc);
- ::Sleep(msec);
-}
-#endif
-
-void QWidgetBackingStore::showYellowThing(QWidget *widget, const QRegion &toBePainted, int msec, bool unclipped)
-{
-#ifdef Q_WS_QWS
- Q_UNUSED(widget);
- Q_UNUSED(unclipped);
- static QWSYellowSurface surface(true);
- surface.setDelay(msec);
- surface.flush(widget, toBePainted, QPoint());
-#else
- QRegion paintRegion = toBePainted;
- QRect widgetRect = widget->rect();
-
- if (!widget->internalWinId()) {
- QWidget *nativeParent = widget->nativeParentWidget();
- const QPoint offset = widget->mapTo(nativeParent, QPoint(0, 0));
- paintRegion.translate(offset);
- widgetRect.translate(offset);
- widget = nativeParent;
- }
-
-#ifdef Q_WS_WIN
- Q_UNUSED(unclipped);
- showYellowThing_win(widget, paintRegion, msec);
-#else
- //flags to fool painter
- bool paintUnclipped = widget->testAttribute(Qt::WA_PaintUnclipped);
- if (unclipped && !widget->d_func()->paintOnScreen())
- widget->setAttribute(Qt::WA_PaintUnclipped);
-
- const bool setFlag = !widget->testAttribute(Qt::WA_WState_InPaintEvent);
- if (setFlag)
- widget->setAttribute(Qt::WA_WState_InPaintEvent);
-
- //setup the engine
- QPaintEngine *pe = widget->paintEngine();
- if (pe) {
- pe->setSystemClip(paintRegion);
- {
- QPainter p(widget);
- p.setClipRegion(paintRegion);
- static int i = 0;
- switch (i) {
- case 0:
- p.fillRect(widgetRect, QColor(255,255,0));
- break;
- case 1:
- p.fillRect(widgetRect, QColor(255,200,55));
- break;
- case 2:
- p.fillRect(widgetRect, QColor(200,255,55));
- break;
- case 3:
- p.fillRect(widgetRect, QColor(200,200,0));
- break;
- }
- i = (i+1) & 3;
- p.end();
- }
- }
-
- if (setFlag)
- widget->setAttribute(Qt::WA_WState_InPaintEvent, false);
-
- //restore
- widget->setAttribute(Qt::WA_PaintUnclipped, paintUnclipped);
-
- if (pe)
- pe->setSystemClip(QRegion());
-
- QApplication::syncX();
-
-#if defined(Q_OS_UNIX)
- ::usleep(1000 * msec);
-#endif
-#endif // Q_WS_WIN
-#endif // Q_WS_QWS
-}
-
-bool QWidgetBackingStore::flushPaint(QWidget *widget, const QRegion &rgn)
-{
- if (!widget)
- return false;
-
- int delay = 0;
- if (widget->testAttribute(Qt::WA_WState_InPaintEvent)) {
- static int flushPaintEvent = qgetenv("QT_FLUSH_PAINT_EVENT").toInt();
- if (!flushPaintEvent)
- return false;
- delay = flushPaintEvent;
- } else {
- static int flushPaint = qgetenv("QT_FLUSH_PAINT").toInt();
- if (!flushPaint)
- return false;
- delay = flushPaint;
- }
-
- QWidgetBackingStore::showYellowThing(widget, rgn, delay * 10, true);
- return true;
-}
-
-void QWidgetBackingStore::unflushPaint(QWidget *widget, const QRegion &rgn)
-{
- if (widget->d_func()->paintOnScreen() || rgn.isEmpty())
- return;
-
- QWidget *tlw = widget->window();
- QTLWExtra *tlwExtra = tlw->d_func()->maybeTopData();
- if (!tlwExtra)
- return;
-
- const QPoint offset = widget->mapTo(tlw, QPoint());
- qt_flush(widget, rgn, tlwExtra->backingStore->windowSurface, tlw, offset);
-}
-#endif // QT_NO_PAINT_DEBUG
-
-/*
- Moves the whole rect by (dx, dy) in widget's coordinate system.
- Doesn't generate any updates.
-*/
-bool QWidgetBackingStore::bltRect(const QRect &rect, int dx, int dy, QWidget *widget)
-{
- const QPoint pos(tlwOffset + widget->mapTo(tlw, rect.topLeft()));
- const QRect tlwRect(QRect(pos, rect.size()));
- if (fullUpdatePending || dirty.intersects(tlwRect))
- return false; // We don't want to scroll junk.
- return windowSurface->scroll(tlwRect, dx, dy);
-}
-
-void QWidgetBackingStore::releaseBuffer()
-{
- if (windowSurface)
-#if defined(Q_WS_QPA)
- windowSurface->resize(QSize());
-#else
- windowSurface->setGeometry(QRect());
-#endif
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- for (int i = 0; i < subSurfaces.size(); ++i)
- subSurfaces.at(i)->setGeometry(QRect());
-#endif
-}
-
-/*!
- Prepares the window surface to paint a\ toClean region of the \a widget and
- updates the BeginPaintInfo struct accordingly.
-
- The \a toClean region might be clipped by the window surface.
-*/
-void QWidgetBackingStore::beginPaint(QRegion &toClean, QWidget *widget, QWindowSurface *windowSurface,
- BeginPaintInfo *returnInfo, bool toCleanIsInTopLevelCoordinates)
-{
-#ifdef Q_WS_QWS
- QWSWindowSurface *surface = static_cast<QWSWindowSurface *>(windowSurface);
- QWidget *surfaceWidget = surface->window();
-
- if (!surface->isValid()) {
- // this looks strange but it really just releases the surface
- surface->releaseSurface();
- // the old window surface is deleted in setWindowSurface, which is
- // called from QWindowSurface constructor.
- windowSurface = tlw->d_func()->createDefaultWindowSurface();
- surface = static_cast<QWSWindowSurface *>(windowSurface);
- // createDefaultWindowSurface() will set topdata->windowSurface on the
- // widget to zero. However, if this is a sub-surface, it should point
- // to the widget's sub windowSurface, so we set that here:
- if (!surfaceWidget->isWindow())
- surfaceWidget->d_func()->topData()->windowSurface = windowSurface;
- surface->setGeometry(topLevelRect());
- returnInfo->windowSurfaceRecreated = true;
- }
-
- const QRegion toCleanUnclipped(toClean);
-
- if (surfaceWidget->isWindow())
- tlwOffset = surface->painterOffset();
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- else if (toCleanIsInTopLevelCoordinates)
- toClean &= surface->clipRegion().translated(surfaceWidget->mapTo(tlw, QPoint()));
- if (!toCleanIsInTopLevelCoordinates && windowSurface == this->windowSurface)
- toClean &= surface->clipRegion().translated(-widget->mapTo(surfaceWidget, QPoint()));
-#else
- toClean &= surface->clipRegion();
-#endif
-
- if (toClean.isEmpty()) {
- if (surfaceWidget->isWindow()) {
- dirtyFromPreviousSync += toCleanUnclipped;
- hasDirtyFromPreviousSync = true;
- }
-
- returnInfo->nothingToPaint = true;
- // Nothing to repaint. However, we might have newly exposed areas on the
- // screen, so we have to make sure those are flushed.
- flush();
- return;
- }
-
- if (surfaceWidget->isWindow()) {
- if (toCleanUnclipped != toClean) {
- dirtyFromPreviousSync += (toCleanUnclipped - surface->clipRegion());
- hasDirtyFromPreviousSync = true;
- }
- if (hasDirtyFromPreviousSync) {
- dirtyFromPreviousSync -= toClean;
- hasDirtyFromPreviousSync = !dirtyFromPreviousSync.isEmpty();
- }
- }
-
-#endif // Q_WS_QWS
-
- Q_UNUSED(widget);
- Q_UNUSED(toCleanIsInTopLevelCoordinates);
-
- // Always flush repainted areas.
- dirtyOnScreen += toClean;
-
-#if defined(Q_WS_QWS) && !defined(Q_BACKINGSTORE_SUBSURFACES)
- toClean.translate(tlwOffset);
-#endif
-
-#ifdef QT_NO_PAINT_DEBUG
- windowSurface->beginPaint(toClean);
-#else
- returnInfo->wasFlushed = QWidgetBackingStore::flushPaint(tlw, toClean);
- // Avoid deadlock with QT_FLUSH_PAINT: the server will wait for
- // the BackingStore lock, so if we hold that, the server will
- // never release the Communication lock that we are waiting for in
- // sendSynchronousCommand
- if (!returnInfo->wasFlushed)
- windowSurface->beginPaint(toClean);
-#endif
-
- Q_UNUSED(returnInfo);
-}
-
-void QWidgetBackingStore::endPaint(const QRegion &cleaned, QWindowSurface *windowSurface,
- BeginPaintInfo *beginPaintInfo)
-{
-#ifndef QT_NO_PAINT_DEBUG
- if (!beginPaintInfo->wasFlushed)
- windowSurface->endPaint(cleaned);
- else
- QWidgetBackingStore::unflushPaint(tlw, cleaned);
-#else
- Q_UNUSED(beginPaintInfo);
- windowSurface->endPaint(cleaned);
-#endif
-
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- flush(static_cast<QWSWindowSurface *>(windowSurface)->window(), windowSurface);
-#else
- flush();
-#endif
-}
-
-/*!
- Returns the region (in top-level coordinates) that needs repaint and/or flush.
-
- If the widget is non-zero, only the dirty region for the widget is returned
- and the region will be in widget coordinates.
-*/
-QRegion QWidgetBackingStore::dirtyRegion(QWidget *widget) const
-{
- const bool widgetDirty = widget && widget != tlw;
- const QRect tlwRect(topLevelRect());
-#if defined(Q_WS_QPA)
- const QRect surfaceGeometry(tlwRect.topLeft(), windowSurface->size());
-#else
- const QRect surfaceGeometry(windowSurface->geometry());
-#endif
- if (fullUpdatePending || (surfaceGeometry != tlwRect && surfaceGeometry.size() != tlwRect.size())) {
- if (widgetDirty) {
- const QRect dirtyTlwRect = QRect(QPoint(), tlwRect.size());
- const QPoint offset(widget->mapTo(tlw, QPoint()));
- const QRect dirtyWidgetRect(dirtyTlwRect & widget->rect().translated(offset));
- return dirtyWidgetRect.translated(-offset);
- }
- return QRect(QPoint(), tlwRect.size());
- }
-
- // Calculate the region that needs repaint.
- QRegion r(dirty);
- for (int i = 0; i < dirtyWidgets.size(); ++i) {
- QWidget *w = dirtyWidgets.at(i);
- if (widgetDirty && w != widget && !widget->isAncestorOf(w))
- continue;
- r += w->d_func()->dirty.translated(w->mapTo(tlw, QPoint()));
- }
-
- // Append the region that needs flush.
- r += dirtyOnScreen;
-
- if (dirtyOnScreenWidgets) { // Only in use with native child widgets.
- for (int i = 0; i < dirtyOnScreenWidgets->size(); ++i) {
- QWidget *w = dirtyOnScreenWidgets->at(i);
- if (widgetDirty && w != widget && !widget->isAncestorOf(w))
- continue;
- QWidgetPrivate *wd = w->d_func();
- Q_ASSERT(wd->needsFlush);
- r += wd->needsFlush->translated(w->mapTo(tlw, QPoint()));
- }
- }
-
- if (widgetDirty) {
- // Intersect with the widget geometry and translate to its coordinates.
- const QPoint offset(widget->mapTo(tlw, QPoint()));
- r &= widget->rect().translated(offset);
- r.translate(-offset);
- }
- return r;
-}
-
-/*!
- Returns the static content inside the \a parent if non-zero; otherwise the static content
- for the entire backing store is returned. The content will be clipped to \a withinClipRect
- if non-empty.
-*/
-QRegion QWidgetBackingStore::staticContents(QWidget *parent, const QRect &withinClipRect) const
-{
- if (!parent && tlw->testAttribute(Qt::WA_StaticContents)) {
-#if defined(Q_WS_QPA)
- const QSize surfaceGeometry(windowSurface->size());
-#else
- const QRect surfaceGeometry(windowSurface->geometry());
-#endif
- QRect surfaceRect(0, 0, surfaceGeometry.width(), surfaceGeometry.height());
- if (!withinClipRect.isEmpty())
- surfaceRect &= withinClipRect;
- return QRegion(surfaceRect);
- }
-
- QRegion region;
- if (parent && parent->d_func()->children.isEmpty())
- return region;
-
- const bool clipToRect = !withinClipRect.isEmpty();
- const int count = staticWidgets.count();
- for (int i = 0; i < count; ++i) {
- QWidget *w = staticWidgets.at(i);
- QWidgetPrivate *wd = w->d_func();
- if (!wd->isOpaque || !wd->extra || wd->extra->staticContentsSize.isEmpty()
- || !w->isVisible() || (parent && !parent->isAncestorOf(w))) {
- continue;
- }
-
- QRect rect(0, 0, wd->extra->staticContentsSize.width(), wd->extra->staticContentsSize.height());
- const QPoint offset = w->mapTo(parent ? parent : tlw, QPoint());
- if (clipToRect)
- rect &= withinClipRect.translated(-offset);
- if (rect.isEmpty())
- continue;
-
- rect &= wd->clipRect();
- if (rect.isEmpty())
- continue;
-
- QRegion visible(rect);
- wd->clipToEffectiveMask(visible);
- if (visible.isEmpty())
- continue;
- wd->subtractOpaqueSiblings(visible, 0, /*alsoNonOpaque=*/true);
-
- visible.translate(offset);
- region += visible;
- }
-
- return region;
-}
-
-static inline void sendUpdateRequest(QWidget *widget, bool updateImmediately)
-{
- if (!widget)
- return;
-
- if (updateImmediately) {
- QEvent event(QEvent::UpdateRequest);
- QApplication::sendEvent(widget, &event);
- } else {
- QApplication::postEvent(widget, new QEvent(QEvent::UpdateRequest), Qt::LowEventPriority);
- }
-}
-
-/*!
- Marks the region of the widget as dirty (if not already marked as dirty) and
- posts an UpdateRequest event to the top-level widget (if not already posted).
-
- If updateImmediately is true, the event is sent immediately instead of posted.
-
- If invalidateBuffer is true, all widgets intersecting with the region will be dirty.
-
- If the widget paints directly on screen, the event is sent to the widget
- instead of the top-level widget, and invalidateBuffer is completely ignored.
-
- ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
-*/
-void QWidgetBackingStore::markDirty(const QRegion &rgn, QWidget *widget, bool updateImmediately,
- bool invalidateBuffer)
-{
- Q_ASSERT(tlw->d_func()->extra);
- Q_ASSERT(tlw->d_func()->extra->topextra);
- Q_ASSERT(!tlw->d_func()->extra->topextra->inTopLevelResize);
- Q_ASSERT(widget->isVisible() && widget->updatesEnabled());
- Q_ASSERT(widget->window() == tlw);
- Q_ASSERT(!rgn.isEmpty());
-
-#ifndef QT_NO_GRAPHICSEFFECT
- widget->d_func()->invalidateGraphicsEffectsRecursively();
-#endif //QT_NO_GRAPHICSEFFECT
-
- if (widget->d_func()->paintOnScreen()) {
- if (widget->d_func()->dirty.isEmpty()) {
- widget->d_func()->dirty = rgn;
- sendUpdateRequest(widget, updateImmediately);
- return;
- } else if (qt_region_strictContains(widget->d_func()->dirty, widget->rect())) {
- if (updateImmediately)
- sendUpdateRequest(widget, updateImmediately);
- return; // Already dirty.
- }
-
- const bool eventAlreadyPosted = !widget->d_func()->dirty.isEmpty();
- widget->d_func()->dirty += rgn;
- if (!eventAlreadyPosted || updateImmediately)
- sendUpdateRequest(widget, updateImmediately);
- return;
- }
-
- if (fullUpdatePending) {
- if (updateImmediately)
- sendUpdateRequest(tlw, updateImmediately);
- return;
- }
-
- if (!windowSurface->hasFeature(QWindowSurface::PartialUpdates)) {
- fullUpdatePending = true;
- sendUpdateRequest(tlw, updateImmediately);
- return;
- }
-
- const QPoint offset = widget->mapTo(tlw, QPoint());
- const QRect widgetRect = widget->d_func()->effectiveRectFor(widget->rect());
- if (qt_region_strictContains(dirty, widgetRect.translated(offset))) {
- if (updateImmediately)
- sendUpdateRequest(tlw, updateImmediately);
- return; // Already dirty.
- }
-
- if (invalidateBuffer) {
- const bool eventAlreadyPosted = !dirty.isEmpty();
-#ifndef QT_NO_GRAPHICSEFFECT
- if (widget->d_func()->graphicsEffect)
- dirty += widget->d_func()->effectiveRectFor(rgn.boundingRect()).translated(offset);
- else
-#endif //QT_NO_GRAPHICSEFFECT
- dirty += rgn.translated(offset);
- if (!eventAlreadyPosted || updateImmediately)
- sendUpdateRequest(tlw, updateImmediately);
- return;
- }
-
- if (dirtyWidgets.isEmpty()) {
- addDirtyWidget(widget, rgn);
- sendUpdateRequest(tlw, updateImmediately);
- return;
- }
-
- if (widget->d_func()->inDirtyList) {
- if (!qt_region_strictContains(widget->d_func()->dirty, widgetRect)) {
-#ifndef QT_NO_GRAPHICSEFFECT
- if (widget->d_func()->graphicsEffect)
- widget->d_func()->dirty += widget->d_func()->effectiveRectFor(rgn.boundingRect());
- else
-#endif //QT_NO_GRAPHICSEFFECT
- widget->d_func()->dirty += rgn;
- }
- } else {
- addDirtyWidget(widget, rgn);
- }
-
- if (updateImmediately)
- sendUpdateRequest(tlw, updateImmediately);
-}
-
-/*!
- This function is equivalent to calling markDirty(QRegion(rect), ...), but
- is more efficient as it eliminates QRegion operations/allocations and can
- use the rect more precisely for additional cut-offs.
-
- ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
-*/
-void QWidgetBackingStore::markDirty(const QRect &rect, QWidget *widget, bool updateImmediately,
- bool invalidateBuffer)
-{
- Q_ASSERT(tlw->d_func()->extra);
- Q_ASSERT(tlw->d_func()->extra->topextra);
- Q_ASSERT(!tlw->d_func()->extra->topextra->inTopLevelResize);
- Q_ASSERT(widget->isVisible() && widget->updatesEnabled());
- Q_ASSERT(widget->window() == tlw);
- Q_ASSERT(!rect.isEmpty());
-
-#ifndef QT_NO_GRAPHICSEFFECT
- widget->d_func()->invalidateGraphicsEffectsRecursively();
-#endif //QT_NO_GRAPHICSEFFECT
-
- if (widget->d_func()->paintOnScreen()) {
- if (widget->d_func()->dirty.isEmpty()) {
- widget->d_func()->dirty = QRegion(rect);
- sendUpdateRequest(widget, updateImmediately);
- return;
- } else if (qt_region_strictContains(widget->d_func()->dirty, rect)) {
- if (updateImmediately)
- sendUpdateRequest(widget, updateImmediately);
- return; // Already dirty.
- }
-
- const bool eventAlreadyPosted = !widget->d_func()->dirty.isEmpty();
- widget->d_func()->dirty += rect;
- if (!eventAlreadyPosted || updateImmediately)
- sendUpdateRequest(widget, updateImmediately);
- return;
- }
-
- if (fullUpdatePending) {
- if (updateImmediately)
- sendUpdateRequest(tlw, updateImmediately);
- return;
- }
-
- if (!windowSurface->hasFeature(QWindowSurface::PartialUpdates)) {
- fullUpdatePending = true;
- sendUpdateRequest(tlw, updateImmediately);
- return;
- }
-
- const QRect widgetRect = widget->d_func()->effectiveRectFor(rect);
- const QRect translatedRect(widgetRect.translated(widget->mapTo(tlw, QPoint())));
- if (qt_region_strictContains(dirty, translatedRect)) {
- if (updateImmediately)
- sendUpdateRequest(tlw, updateImmediately);
- return; // Already dirty
- }
-
- if (invalidateBuffer) {
- const bool eventAlreadyPosted = !dirty.isEmpty();
- dirty += translatedRect;
- if (!eventAlreadyPosted || updateImmediately)
- sendUpdateRequest(tlw, updateImmediately);
- return;
- }
-
- if (dirtyWidgets.isEmpty()) {
- addDirtyWidget(widget, rect);
- sendUpdateRequest(tlw, updateImmediately);
- return;
- }
-
- if (widget->d_func()->inDirtyList) {
- if (!qt_region_strictContains(widget->d_func()->dirty, widgetRect))
- widget->d_func()->dirty += widgetRect;
- } else {
- addDirtyWidget(widget, rect);
- }
-
- if (updateImmediately)
- sendUpdateRequest(tlw, updateImmediately);
-}
-
-/*!
- Marks the \a region of the \a widget as dirty on screen. The \a region will be copied from
- the backing store to the \a widget's native parent next time flush() is called.
-
- Paint on screen widgets are ignored.
-*/
-void QWidgetBackingStore::markDirtyOnScreen(const QRegion &region, QWidget *widget, const QPoint &topLevelOffset)
-{
- if (!widget || widget->d_func()->paintOnScreen() || region.isEmpty())
- return;
-
-#if defined(Q_WS_QWS) || defined(Q_WS_MAC)
- if (!widget->testAttribute(Qt::WA_WState_InPaintEvent))
- dirtyOnScreen += region.translated(topLevelOffset);
- return;
-#endif
-
- // Top-level.
- if (widget == tlw) {
- if (!widget->testAttribute(Qt::WA_WState_InPaintEvent))
- dirtyOnScreen += region;
- return;
- }
-
- // Alien widgets.
- if (!widget->internalWinId() && !widget->isWindow()) {
- QWidget *nativeParent = widget->nativeParentWidget(); // Alien widgets with the top-level as the native parent (common case).
- if (nativeParent == tlw) {
- if (!widget->testAttribute(Qt::WA_WState_InPaintEvent))
- dirtyOnScreen += region.translated(topLevelOffset);
- return;
- }
-
- // Alien widgets with native parent != tlw.
- QWidgetPrivate *nativeParentPrivate = nativeParent->d_func();
- if (!nativeParentPrivate->needsFlush)
- nativeParentPrivate->needsFlush = new QRegion;
- const QPoint nativeParentOffset = widget->mapTo(nativeParent, QPoint());
- *nativeParentPrivate->needsFlush += region.translated(nativeParentOffset);
- appendDirtyOnScreenWidget(nativeParent);
- return;
- }
-
- // Native child widgets.
- QWidgetPrivate *widgetPrivate = widget->d_func();
- if (!widgetPrivate->needsFlush)
- widgetPrivate->needsFlush = new QRegion;
- *widgetPrivate->needsFlush += region;
- appendDirtyOnScreenWidget(widget);
-}
-
-void QWidgetBackingStore::removeDirtyWidget(QWidget *w)
-{
- if (!w)
- return;
-
- dirtyWidgetsRemoveAll(w);
- dirtyOnScreenWidgetsRemoveAll(w);
- resetWidget(w);
-
- QWidgetPrivate *wd = w->d_func();
- const int n = wd->children.count();
- for (int i = 0; i < n; ++i) {
- if (QWidget *child = qobject_cast<QWidget*>(wd->children.at(i)))
- removeDirtyWidget(child);
- }
-}
-
-#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER)
-bool QWidgetBackingStore::hasDirtyWindowDecoration() const
-{
- QTLWExtra *tlwExtra = tlw->d_func()->maybeTopData();
- if (tlwExtra && tlwExtra->qwsManager)
- return !tlwExtra->qwsManager->d_func()->dirtyRegions.isEmpty();
- return false;
-}
-
-void QWidgetBackingStore::paintWindowDecoration()
-{
- if (!hasDirtyWindowDecoration())
- return;
-
- QDecoration &decoration = QApplication::qwsDecoration();
- const QRect decorationRect = tlw->rect();
- QRegion decorationRegion = decoration.region(tlw, decorationRect);
-
- QWSManagerPrivate *managerPrivate = tlw->d_func()->topData()->qwsManager->d_func();
- const bool doClipping = !managerPrivate->entireDecorationNeedsRepaint
- && !managerPrivate->dirtyClip.isEmpty();
-
- if (doClipping) {
- decorationRegion &= static_cast<QWSWindowSurface *>(windowSurface)->clipRegion();
- decorationRegion &= managerPrivate->dirtyClip;
- }
-
- if (decorationRegion.isEmpty())
- return;
-
- //### The QWS decorations do not always paint the pixels they promise to paint.
- // This causes painting problems with QWSMemorySurface. Since none of the other
- // window surfaces actually use the region, passing an empty region is a safe
- // workaround.
-
- windowSurface->beginPaint(QRegion());
-
- QPaintEngine *engine = windowSurface->paintDevice()->paintEngine();
- Q_ASSERT(engine);
- const QRegion oldSystemClip(engine->systemClip());
- engine->setSystemClip(decorationRegion.translated(tlwOffset));
-
- QPainter painter(windowSurface->paintDevice());
- painter.setFont(QApplication::font());
- painter.translate(tlwOffset);
-
- const int numDirty = managerPrivate->dirtyRegions.size();
- for (int i = 0; i < numDirty; ++i) {
- const int area = managerPrivate->dirtyRegions.at(i);
-
- QRegion clipRegion = decoration.region(tlw, decorationRect, area);
- if (!clipRegion.isEmpty()) {
- // Decoration styles changes the clip and assumes the old clip is non-empty,
- // so we have to set it, but in theory it shouldn't be required.
- painter.setClipRegion(clipRegion);
- decoration.paint(&painter, tlw, area, managerPrivate->dirtyStates.at(i));
- }
- }
- markDirtyOnScreen(decorationRegion, tlw, QPoint());
-
- painter.end();
- windowSurface->endPaint(decorationRegion);
- managerPrivate->clearDirtyRegions();
- engine->setSystemClip(oldSystemClip);
-}
-#endif
-
-void QWidgetBackingStore::updateLists(QWidget *cur)
-{
- if (!cur)
- return;
-
- QList<QObject*> children = cur->children();
- for (int i = 0; i < children.size(); ++i) {
- QWidget *child = qobject_cast<QWidget*>(children.at(i));
- if (!child)
- continue;
-
- updateLists(child);
- }
-
- if (cur->testAttribute(Qt::WA_StaticContents))
- addStaticWidget(cur);
-
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- QTLWExtra *extra = cur->d_func()->maybeTopData();
- if (extra && extra->windowSurface && cur != tlw)
- subSurfaces.append(extra->windowSurface);
-#endif
-}
-
-QWidgetBackingStore::QWidgetBackingStore(QWidget *topLevel)
- : tlw(topLevel), dirtyOnScreenWidgets(0), hasDirtyFromPreviousSync(false)
- , fullUpdatePending(0)
-{
- windowSurface = tlw->windowSurface();
- if (!windowSurface)
- windowSurface = topLevel->d_func()->createDefaultWindowSurface();
-
- // The QWindowSurface constructor will call QWidget::setWindowSurface(),
- // but automatically created surfaces should not be added to the topdata.
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- Q_ASSERT(topLevel->d_func()->topData()->windowSurface == windowSurface);
-#endif
- topLevel->d_func()->topData()->windowSurface = 0;
-
- // Ensure all existing subsurfaces and static widgets are added to their respective lists.
- updateLists(topLevel);
-}
-
-QWidgetBackingStore::~QWidgetBackingStore()
-{
- for (int c = 0; c < dirtyWidgets.size(); ++c) {
- resetWidget(dirtyWidgets.at(c));
- }
-
- delete windowSurface;
- windowSurface = 0;
- delete dirtyOnScreenWidgets;
- dirtyOnScreenWidgets = 0;
-}
-
-//parent's coordinates; move whole rect; update parent and widget
-//assume the screen blt has already been done, so we don't need to refresh that part
-void QWidgetPrivate::moveRect(const QRect &rect, int dx, int dy)
-{
- Q_Q(QWidget);
- if (!q->isVisible() || (dx == 0 && dy == 0))
- return;
-
- QWidget *tlw = q->window();
- QTLWExtra* x = tlw->d_func()->topData();
- if (x->inTopLevelResize)
- return;
-
- static int accelEnv = -1;
- if (accelEnv == -1) {
- accelEnv = qgetenv("QT_NO_FAST_MOVE").toInt() == 0;
- }
-
- QWidget *pw = q->parentWidget();
- QPoint toplevelOffset = pw->mapTo(tlw, QPoint());
- QWidgetPrivate *pd = pw->d_func();
- QRect clipR(pd->clipRect());
-#ifdef Q_WS_QWS
- QWidgetBackingStore *wbs = x->backingStore.data();
- QWSWindowSurface *surface = static_cast<QWSWindowSurface*>(wbs->windowSurface);
- clipR = clipR.intersected(surface->clipRegion().translated(-toplevelOffset).boundingRect());
-#endif
- const QRect newRect(rect.translated(dx, dy));
- QRect destRect = rect.intersected(clipR);
- if (destRect.isValid())
- destRect = destRect.translated(dx, dy).intersected(clipR);
- const QRect sourceRect(destRect.translated(-dx, -dy));
- const QRect parentRect(rect & clipR);
-
- bool accelerateMove = accelEnv && isOpaque
-#ifndef QT_NO_GRAPHICSVIEW
- // No accelerate move for proxy widgets.
- && !tlw->d_func()->extra->proxyWidget
-#endif
- && !isOverlapped(sourceRect) && !isOverlapped(destRect);
-
- if (!accelerateMove) {
- QRegion parentR(effectiveRectFor(parentRect));
- if (!extra || !extra->hasMask) {
- parentR -= newRect;
- } else {
- // invalidateBuffer() excludes anything outside the mask
- parentR += newRect & clipR;
- }
- pd->invalidateBuffer(parentR);
- invalidateBuffer((newRect & clipR).translated(-data.crect.topLeft()));
- } else {
-
- QWidgetBackingStore *wbs = x->backingStore.data();
- QRegion childExpose(newRect & clipR);
-
- if (sourceRect.isValid() && wbs->bltRect(sourceRect, dx, dy, pw))
- childExpose -= destRect;
-
- if (!pw->updatesEnabled())
- return;
-
- const bool childUpdatesEnabled = q->updatesEnabled();
- if (childUpdatesEnabled && !childExpose.isEmpty()) {
- childExpose.translate(-data.crect.topLeft());
- wbs->markDirty(childExpose, q);
- isMoved = true;
- }
-
- QRegion parentExpose(parentRect);
- parentExpose -= newRect;
- if (extra && extra->hasMask)
- parentExpose += QRegion(newRect) - extra->mask.translated(data.crect.topLeft());
-
- if (!parentExpose.isEmpty()) {
- wbs->markDirty(parentExpose, pw);
- pd->isMoved = true;
- }
-
- if (childUpdatesEnabled) {
- QRegion needsFlush(sourceRect);
- needsFlush += destRect;
- wbs->markDirtyOnScreen(needsFlush, pw, toplevelOffset);
- }
- }
-}
-
-//widget's coordinates; scroll within rect; only update widget
-void QWidgetPrivate::scrollRect(const QRect &rect, int dx, int dy)
-{
- Q_Q(QWidget);
- QWidget *tlw = q->window();
- QTLWExtra* x = tlw->d_func()->topData();
- if (x->inTopLevelResize)
- return;
-
- QWidgetBackingStore *wbs = x->backingStore.data();
- if (!wbs)
- return;
-
- static int accelEnv = -1;
- if (accelEnv == -1) {
- accelEnv = qgetenv("QT_NO_FAST_SCROLL").toInt() == 0;
- }
-
- QRect scrollRect = rect & clipRect();
- bool overlapped = false;
- bool accelerateScroll = accelEnv && isOpaque
- && !(overlapped = isOverlapped(scrollRect.translated(data.crect.topLeft())));
-
-#if defined(Q_WS_QWS)
- QWSWindowSurface *surface;
- surface = static_cast<QWSWindowSurface*>(wbs->windowSurface);
-
- if (accelerateScroll && !surface->isBuffered()) {
- const QRegion surfaceClip = surface->clipRegion();
- const QRegion outsideClip = QRegion(rect) - surfaceClip;
- if (!outsideClip.isEmpty()) {
- const QVector<QRect> clipped = (surfaceClip & rect).rects();
- if (clipped.size() < 8) {
- for (int i = 0; i < clipped.size(); ++i)
- this->scrollRect(clipped.at(i), dx, dy);
- return;
- } else {
- accelerateScroll = false;
- }
- }
- }
-#endif // Q_WS_QWS
-
- if (!accelerateScroll) {
- if (overlapped) {
- QRegion region(scrollRect);
- subtractOpaqueSiblings(region);
- invalidateBuffer(region);
- }else {
- invalidateBuffer(scrollRect);
- }
- } else {
- const QPoint toplevelOffset = q->mapTo(tlw, QPoint());
-#ifdef Q_WS_QWS
- QWSWindowSurface *surface = static_cast<QWSWindowSurface*>(wbs->windowSurface);
- const QRegion clip = surface->clipRegion().translated(-toplevelOffset) & scrollRect;
- const QRect clipBoundingRect = clip.boundingRect();
- scrollRect &= clipBoundingRect;
-#endif
- const QRect destRect = scrollRect.translated(dx, dy) & scrollRect;
- const QRect sourceRect = destRect.translated(-dx, -dy);
-
- QRegion childExpose(scrollRect);
- if (sourceRect.isValid()) {
- if (wbs->bltRect(sourceRect, dx, dy, q))
- childExpose -= destRect;
- }
-
- if (inDirtyList) {
- if (rect == q->rect()) {
- dirty.translate(dx, dy);
- } else {
- QRegion dirtyScrollRegion = dirty.intersected(scrollRect);
- if (!dirtyScrollRegion.isEmpty()) {
- dirty -= dirtyScrollRegion;
- dirtyScrollRegion.translate(dx, dy);
- dirty += dirtyScrollRegion;
- }
- }
- }
-
- if (!q->updatesEnabled())
- return;
-
- if (!childExpose.isEmpty()) {
- wbs->markDirty(childExpose, q);
- isScrolled = true;
- }
-
- // Instead of using native scroll-on-screen, we copy from
- // backingstore, giving only one screen update for each
- // scroll, and a solid appearance
- wbs->markDirtyOnScreen(destRect, q, toplevelOffset);
- }
-}
-
-static inline bool discardSyncRequest(QWidget *tlw, QTLWExtra *tlwExtra)
-{
- if (!tlw || !tlwExtra)
- return true;
-
-#ifdef Q_WS_X11
- // Delay the sync until we get an Expose event from X11 (initial show).
- // Qt::WA_Mapped is set to true, but the actual mapping has not yet occurred.
- // However, we must repaint immediately regardless of the state if someone calls repaint().
- if (tlwExtra->waitingForMapNotify && !tlwExtra->inRepaint)
- return true;
-#endif
-
- if (!tlw->testAttribute(Qt::WA_Mapped))
- return true;
-
- if (!tlw->isVisible()
-#ifndef Q_WS_X11
- // If we're minimized on X11, WA_Mapped will be false and we
- // will return in the case above. Some window managers on X11
- // sends us the PropertyNotify to change the minimized state
- // *AFTER* we've received the expose event, which is baaad.
- || tlw->isMinimized()
-#endif
- )
- return true;
-
- return false;
-}
-
-/*!
- Synchronizes the \a exposedRegion of the \a exposedWidget with the backing store.
-
- If there's nothing to repaint, the area is flushed and painting does not occur;
- otherwise the area is marked as dirty on screen and will be flushed right after
- we are done with all painting.
-*/
-void QWidgetBackingStore::sync(QWidget *exposedWidget, const QRegion &exposedRegion)
-{
- QTLWExtra *tlwExtra = tlw->d_func()->maybeTopData();
- if (discardSyncRequest(tlw, tlwExtra) || tlwExtra->inTopLevelResize)
- return;
-
- if (!exposedWidget || !exposedWidget->internalWinId() || !exposedWidget->isVisible()
- || !exposedWidget->updatesEnabled() || exposedRegion.isEmpty()) {
- return;
- }
-
- // If there's no preserved contents support we always need
- // to do a full repaint before flushing
- if (!windowSurface->hasFeature(QWindowSurface::PreservedContents))
- fullUpdatePending = true;
-
- // Nothing to repaint.
- if (!isDirty()) {
- qt_flush(exposedWidget, exposedRegion, windowSurface, tlw, tlwOffset);
- return;
- }
-
- if (exposedWidget != tlw)
- markDirtyOnScreen(exposedRegion, exposedWidget, exposedWidget->mapTo(tlw, QPoint()));
- else
- markDirtyOnScreen(exposedRegion, exposedWidget, QPoint());
- sync();
-}
-
-/*!
- Synchronizes the backing store, i.e. dirty areas are repainted and flushed.
-*/
-void QWidgetBackingStore::sync()
-{
- QTLWExtra *tlwExtra = tlw->d_func()->maybeTopData();
- if (discardSyncRequest(tlw, tlwExtra)) {
- // If the top-level is minimized, it's not visible on the screen so we can delay the
- // update until it's shown again. In order to do that we must keep the dirty states.
- // These will be cleared when we receive the first expose after showNormal().
- // However, if the widget is not visible (isVisible() returns false), everything will
- // be invalidated once the widget is shown again, so clear all dirty states.
- if (!tlw->isVisible()) {
- dirty = QRegion();
- for (int i = 0; i < dirtyWidgets.size(); ++i)
- resetWidget(dirtyWidgets.at(i));
- dirtyWidgets.clear();
- fullUpdatePending = false;
- }
- return;
- }
-
- const bool updatesDisabled = !tlw->updatesEnabled();
- bool repaintAllWidgets = false;
-
- const bool inTopLevelResize = tlwExtra->inTopLevelResize;
- const QRect tlwRect(topLevelRect());
-#ifdef Q_WS_QPA
- const QRect surfaceGeometry(tlwRect.topLeft(), windowSurface->size());
-#else
- const QRect surfaceGeometry(windowSurface->geometry());
-#endif
- if ((fullUpdatePending || inTopLevelResize || surfaceGeometry.size() != tlwRect.size()) && !updatesDisabled) {
- if (hasStaticContents()) {
- // Repaint existing dirty area and newly visible area.
- const QRect clipRect(0, 0, surfaceGeometry.width(), surfaceGeometry.height());
- const QRegion staticRegion(staticContents(0, clipRect));
- QRegion newVisible(0, 0, tlwRect.width(), tlwRect.height());
- newVisible -= staticRegion;
- dirty += newVisible;
- windowSurface->setStaticContents(staticRegion);
- } else {
- // Repaint everything.
- dirty = QRegion(0, 0, tlwRect.width(), tlwRect.height());
- for (int i = 0; i < dirtyWidgets.size(); ++i)
- resetWidget(dirtyWidgets.at(i));
- dirtyWidgets.clear();
- repaintAllWidgets = true;
- }
- }
-
-#ifdef Q_WS_QPA
- if (inTopLevelResize || surfaceGeometry.size() != tlwRect.size())
- windowSurface->resize(tlwRect.size());
-#else
- if (inTopLevelResize || surfaceGeometry != tlwRect)
- windowSurface->setGeometry(tlwRect);
-#endif
-
- if (updatesDisabled)
- return;
-
- if (hasDirtyFromPreviousSync)
- dirty += dirtyFromPreviousSync;
-
- // Contains everything that needs repaint.
- QRegion toClean(dirty);
-
- // Loop through all update() widgets and remove them from the list before they are
- // painted (in case someone calls update() in paintEvent). If the widget is opaque
- // and does not have transparent overlapping siblings, append it to the
- // opaqueNonOverlappedWidgets list and paint it directly without composition.
- QVarLengthArray<QWidget *, 32> opaqueNonOverlappedWidgets;
- for (int i = 0; i < dirtyWidgets.size(); ++i) {
- QWidget *w = dirtyWidgets.at(i);
- QWidgetPrivate *wd = w->d_func();
- if (wd->data.in_destructor)
- continue;
-
- // Clip with mask() and clipRect().
- wd->dirty &= wd->clipRect();
- wd->clipToEffectiveMask(wd->dirty);
-
- // Subtract opaque siblings and children.
- bool hasDirtySiblingsAbove = false;
- // We know for sure that the widget isn't overlapped if 'isMoved' is true.
- if (!wd->isMoved)
- wd->subtractOpaqueSiblings(wd->dirty, &hasDirtySiblingsAbove);
- // Scrolled and moved widgets must draw all children.
- if (!wd->isScrolled && !wd->isMoved)
- wd->subtractOpaqueChildren(wd->dirty, w->rect());
-
- if (wd->dirty.isEmpty()) {
- resetWidget(w);
- continue;
- }
-
- const QRegion widgetDirty(w != tlw ? wd->dirty.translated(w->mapTo(tlw, QPoint()))
- : wd->dirty);
- toClean += widgetDirty;
-
-#ifndef QT_NO_GRAPHICSVIEW
- if (tlw->d_func()->extra->proxyWidget) {
- resetWidget(w);
- continue;
- }
-#endif
-
- if (!hasDirtySiblingsAbove && wd->isOpaque && !dirty.intersects(widgetDirty.boundingRect())) {
- opaqueNonOverlappedWidgets.append(w);
- } else {
- resetWidget(w);
- dirty += widgetDirty;
- }
- }
- dirtyWidgets.clear();
-
- fullUpdatePending = false;
-
- if (toClean.isEmpty()) {
- // Nothing to repaint. However, we might have newly exposed areas on the
- // screen if this function was called from sync(QWidget *, QRegion)), so
- // we have to make sure those are flushed.
- flush();
- return;
- }
-
-#ifndef QT_NO_GRAPHICSVIEW
- if (tlw->d_func()->extra->proxyWidget) {
- updateStaticContentsSize();
- dirty = QRegion();
- const QVector<QRect> rects(toClean.rects());
- for (int i = 0; i < rects.size(); ++i)
- tlw->d_func()->extra->proxyWidget->update(rects.at(i));
- return;
- }
-#endif
-
-#ifndef Q_BACKINGSTORE_SUBSURFACES
- BeginPaintInfo beginPaintInfo;
- beginPaint(toClean, tlw, windowSurface, &beginPaintInfo);
- if (beginPaintInfo.nothingToPaint) {
- for (int i = 0; i < opaqueNonOverlappedWidgets.size(); ++i)
- resetWidget(opaqueNonOverlappedWidgets[i]);
- dirty = QRegion();
- return;
- }
-#endif
-
- // Must do this before sending any paint events because
- // the size may change in the paint event.
- updateStaticContentsSize();
- const QRegion dirtyCopy(dirty);
- dirty = QRegion();
-
- // Paint opaque non overlapped widgets.
- for (int i = 0; i < opaqueNonOverlappedWidgets.size(); ++i) {
- QWidget *w = opaqueNonOverlappedWidgets[i];
- QWidgetPrivate *wd = w->d_func();
-
- int flags = QWidgetPrivate::DrawRecursive;
- // Scrolled and moved widgets must draw all children.
- if (!wd->isScrolled && !wd->isMoved)
- flags |= QWidgetPrivate::DontDrawOpaqueChildren;
- if (w == tlw)
- flags |= QWidgetPrivate::DrawAsRoot;
-
- QRegion toBePainted(wd->dirty);
- resetWidget(w);
-
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- QWindowSurface *subSurface = w->windowSurface();
- BeginPaintInfo beginPaintInfo;
-
- QPoint off = w->mapTo(tlw, QPoint());
- toBePainted.translate(off);
- beginPaint(toBePainted, w, subSurface, &beginPaintInfo, true);
- toBePainted.translate(-off);
-
- if (beginPaintInfo.nothingToPaint)
- continue;
-
- if (beginPaintInfo.windowSurfaceRecreated) {
- // Eep the window surface has changed. The old one may have been
- // deleted, in which case we will segfault on the call to
- // painterOffset() below. Use the new window surface instead.
- subSurface = w->windowSurface();
- }
-
- QPoint offset(tlwOffset);
- if (subSurface == windowSurface)
- offset += w->mapTo(tlw, QPoint());
- else
- offset = static_cast<QWSWindowSurface*>(subSurface)->painterOffset();
- wd->drawWidget(subSurface->paintDevice(), toBePainted, offset, flags, 0, this);
-
- endPaint(toBePainted, subSurface, &beginPaintInfo);
-#else
- QPoint offset(tlwOffset);
- if (w != tlw)
- offset += w->mapTo(tlw, QPoint());
- wd->drawWidget(windowSurface->paintDevice(), toBePainted, offset, flags, 0, this);
-#endif
- }
-
- // Paint the rest with composition.
-#ifndef Q_BACKINGSTORE_SUBSURFACES
- if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
- const int flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
- tlw->d_func()->drawWidget(windowSurface->paintDevice(), dirtyCopy, tlwOffset, flags, 0, this);
- }
-
- endPaint(toClean, windowSurface, &beginPaintInfo);
-#else
- if (!repaintAllWidgets && dirtyCopy.isEmpty())
- return; // Nothing more to paint.
-
- QList<QWindowSurface *> surfaceList(subSurfaces);
- surfaceList.prepend(windowSurface);
- const QRect dirtyBoundingRect(dirtyCopy.boundingRect());
-
- // Loop through all window surfaces (incl. the top-level surface) and
- // repaint those intersecting with the bounding rect of the dirty region.
- for (int i = 0; i < surfaceList.size(); ++i) {
- QWindowSurface *subSurface = surfaceList.at(i);
- QWidget *w = subSurface->window();
- QWidgetPrivate *wd = w->d_func();
-
- const QRect clipRect = wd->clipRect().translated(w->mapTo(tlw, QPoint()));
- if (!qRectIntersects(dirtyBoundingRect, clipRect))
- continue;
-
- toClean = dirtyCopy;
- BeginPaintInfo beginPaintInfo;
- beginPaint(toClean, w, subSurface, &beginPaintInfo);
- if (beginPaintInfo.nothingToPaint)
- continue;
-
- if (beginPaintInfo.windowSurfaceRecreated) {
- // Eep the window surface has changed. The old one may have been
- // deleted, in which case we will segfault on the call to
- // painterOffset() below. Use the new window surface instead.
- subSurface = w->windowSurface();
- }
-
- int flags = QWidgetPrivate::DrawRecursive;
- if (w == tlw)
- flags |= QWidgetPrivate::DrawAsRoot;
- const QPoint painterOffset = static_cast<QWSWindowSurface*>(subSurface)->painterOffset();
- wd->drawWidget(subSurface->paintDevice(), toClean, painterOffset, flags, 0, this);
-
- endPaint(toClean, subSurface, &beginPaintInfo);
- }
-#endif
-}
-
-/*!
- Flushes the contents of the backing store into the top-level widget.
- If the \a widget is non-zero, the content is flushed to the \a widget.
- If the \a surface is non-zero, the content of the \a surface is flushed.
-*/
-void QWidgetBackingStore::flush(QWidget *widget, QWindowSurface *surface)
-{
-#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER)
- paintWindowDecoration();
-#endif
-
- if (!dirtyOnScreen.isEmpty()) {
- QWidget *target = widget ? widget : tlw;
- QWindowSurface *source = surface ? surface : windowSurface;
- qt_flush(target, dirtyOnScreen, source, tlw, tlwOffset);
- dirtyOnScreen = QRegion();
- }
-
- if (!dirtyOnScreenWidgets || dirtyOnScreenWidgets->isEmpty())
- return;
-
- for (int i = 0; i < dirtyOnScreenWidgets->size(); ++i) {
- QWidget *w = dirtyOnScreenWidgets->at(i);
- QWidgetPrivate *wd = w->d_func();
- Q_ASSERT(wd->needsFlush);
- qt_flush(w, *wd->needsFlush, windowSurface, tlw, tlwOffset);
- *wd->needsFlush = QRegion();
- }
- dirtyOnScreenWidgets->clear();
-}
-
-static inline bool discardInvalidateBufferRequest(QWidget *widget, QTLWExtra *tlwExtra)
-{
- Q_ASSERT(widget);
- if (QApplication::closingDown())
- return true;
-
- if (!tlwExtra || tlwExtra->inTopLevelResize || !tlwExtra->backingStore)
- return true;
-
- if (!widget->isVisible() || !widget->updatesEnabled())
- return true;
-
- return false;
-}
-
-/*!
- Invalidates the buffer when the widget is resized.
- Static areas are never invalidated unless absolutely needed.
-*/
-void QWidgetPrivate::invalidateBuffer_resizeHelper(const QPoint &oldPos, const QSize &oldSize)
-{
- Q_Q(QWidget);
- Q_ASSERT(!q->isWindow());
- Q_ASSERT(q->parentWidget());
-
- const bool staticContents = q->testAttribute(Qt::WA_StaticContents);
- const bool sizeDecreased = (data.crect.width() < oldSize.width())
- || (data.crect.height() < oldSize.height());
-
- const QPoint offset(data.crect.x() - oldPos.x(), data.crect.y() - oldPos.y());
- const bool parentAreaExposed = !offset.isNull() || sizeDecreased;
- const QRect newWidgetRect(q->rect());
- const QRect oldWidgetRect(0, 0, oldSize.width(), oldSize.height());
-
- if (!staticContents || graphicsEffect) {
- QRegion staticChildren;
- QWidgetBackingStore *bs = 0;
- if (offset.isNull() && (bs = maybeBackingStore()))
- staticChildren = bs->staticContents(q, oldWidgetRect);
- const bool hasStaticChildren = !staticChildren.isEmpty();
-
- if (hasStaticChildren) {
- QRegion dirty(newWidgetRect);
- dirty -= staticChildren;
- invalidateBuffer(dirty);
- } else {
- // Entire widget needs repaint.
- invalidateBuffer(newWidgetRect);
- }
-
- if (!parentAreaExposed)
- return;
-
- // Invalidate newly exposed area of the parent.
- if (!graphicsEffect && extra && extra->hasMask) {
- QRegion parentExpose(extra->mask.translated(oldPos));
- parentExpose &= QRect(oldPos, oldSize);
- if (hasStaticChildren)
- parentExpose -= data.crect; // Offset is unchanged, safe to do this.
- q->parentWidget()->d_func()->invalidateBuffer(parentExpose);
- } else {
- if (hasStaticChildren && !graphicsEffect) {
- QRegion parentExpose(QRect(oldPos, oldSize));
- parentExpose -= data.crect; // Offset is unchanged, safe to do this.
- q->parentWidget()->d_func()->invalidateBuffer(parentExpose);
- } else {
- q->parentWidget()->d_func()->invalidateBuffer(effectiveRectFor(QRect(oldPos, oldSize)));
- }
- }
- return;
- }
-
- // Move static content to its new position.
- if (!offset.isNull()) {
- if (sizeDecreased) {
- const QSize minSize(qMin(oldSize.width(), data.crect.width()),
- qMin(oldSize.height(), data.crect.height()));
- moveRect(QRect(oldPos, minSize), offset.x(), offset.y());
- } else {
- moveRect(QRect(oldPos, oldSize), offset.x(), offset.y());
- }
- }
-
- // Invalidate newly visible area of the widget.
- if (!sizeDecreased || !oldWidgetRect.contains(newWidgetRect)) {
- QRegion newVisible(newWidgetRect);
- newVisible -= oldWidgetRect;
- invalidateBuffer(newVisible);
- }
-
- if (!parentAreaExposed)
- return;
-
- // Invalidate newly exposed area of the parent.
- const QRect oldRect(oldPos, oldSize);
- if (extra && extra->hasMask) {
- QRegion parentExpose(oldRect);
- parentExpose &= extra->mask.translated(oldPos);
- parentExpose -= (extra->mask.translated(data.crect.topLeft()) & data.crect);
- q->parentWidget()->d_func()->invalidateBuffer(parentExpose);
- } else {
- QRegion parentExpose(oldRect);
- parentExpose -= data.crect;
- q->parentWidget()->d_func()->invalidateBuffer(parentExpose);
- }
-}
-
-/*!
- Invalidates the \a rgn (in widget's coordinates) of the backing store, i.e.
- all widgets intersecting with the region will be repainted when the backing store
- is synced.
-
- ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
-*/
-void QWidgetPrivate::invalidateBuffer(const QRegion &rgn)
-{
- Q_Q(QWidget);
-
- QTLWExtra *tlwExtra = q->window()->d_func()->maybeTopData();
- if (discardInvalidateBufferRequest(q, tlwExtra) || rgn.isEmpty())
- return;
-
- QRegion wrgn(rgn);
- wrgn &= clipRect();
- if (!graphicsEffect && extra && extra->hasMask)
- wrgn &= extra->mask;
- if (wrgn.isEmpty())
- return;
-
- tlwExtra->backingStore->markDirty(wrgn, q, false, true);
-}
-
-/*!
- This function is equivalent to calling invalidateBuffer(QRegion(rect), ...), but
- is more efficient as it eliminates QRegion operations/allocations and can
- use the rect more precisely for additional cut-offs.
-
- ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
-*/
-void QWidgetPrivate::invalidateBuffer(const QRect &rect)
-{
- Q_Q(QWidget);
-
- QTLWExtra *tlwExtra = q->window()->d_func()->maybeTopData();
- if (discardInvalidateBufferRequest(q, tlwExtra) || rect.isEmpty())
- return;
-
- QRect wRect(rect);
- wRect &= clipRect();
- if (wRect.isEmpty())
- return;
-
- if (graphicsEffect || !extra || !extra->hasMask) {
- tlwExtra->backingStore->markDirty(wRect, q, false, true);
- return;
- }
-
- QRegion wRgn(extra->mask);
- wRgn &= wRect;
- if (wRgn.isEmpty())
- return;
-
- tlwExtra->backingStore->markDirty(wRgn, q, false, true);
-}
-
-void QWidgetPrivate::repaint_sys(const QRegion &rgn)
-{
- if (data.in_destructor)
- return;
-
- Q_Q(QWidget);
- if (q->testAttribute(Qt::WA_StaticContents)) {
- if (!extra)
- createExtra();
- extra->staticContentsSize = data.crect.size();
- }
-
-#ifdef Q_WS_QPA //Dont even call q->p
- QPaintEngine *engine = 0;
-#else
- QPaintEngine *engine = q->paintEngine();
-#endif
- // QGLWidget does not support partial updates if:
- // 1) The context is double buffered
- // 2) The context is single buffered and auto-fill background is enabled.
- const bool noPartialUpdateSupport = (engine && (engine->type() == QPaintEngine::OpenGL
- || engine->type() == QPaintEngine::OpenGL2))
- && (usesDoubleBufferedGLContext || q->autoFillBackground());
- QRegion toBePainted(noPartialUpdateSupport ? q->rect() : rgn);
-
-#ifdef Q_WS_MAC
- // No difference between update() and repaint() on the Mac.
- update_sys(toBePainted);
- return;
-#endif
-
- toBePainted &= clipRect();
- clipToEffectiveMask(toBePainted);
- if (toBePainted.isEmpty())
- return; // Nothing to repaint.
-
-#ifndef QT_NO_PAINT_DEBUG
- bool flushed = QWidgetBackingStore::flushPaint(q, toBePainted);
-#endif
-
- drawWidget(q, toBePainted, QPoint(), QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawPaintOnScreen, 0);
-
-#ifndef QT_NO_PAINT_DEBUG
- if (flushed)
- QWidgetBackingStore::unflushPaint(q, toBePainted);
-#endif
-
- if (!q->testAttribute(Qt::WA_PaintOutsidePaintEvent) && q->paintingActive())
- qWarning("QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent");
-}
-
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qbackingstore_p.h b/src/gui/painting/qbackingstore_p.h
deleted file mode 100644
index 05f4bfcb6c..0000000000
--- a/src/gui/painting/qbackingstore_p.h
+++ /dev/null
@@ -1,278 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QBACKINGSTORE_P_H
-#define QBACKINGSTORE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QDebug>
-#include <QtGui/qwidget.h>
-#include <private/qwidget_p.h>
-#include <private/qwindowsurface_p.h>
-#ifdef Q_WS_QWS
-#include <private/qwindowsurface_qws_p.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class QWindowSurface;
-
-struct BeginPaintInfo {
- inline BeginPaintInfo() : wasFlushed(0), nothingToPaint(0), windowSurfaceRecreated(0) {}
- uint wasFlushed : 1;
- uint nothingToPaint : 1;
- uint windowSurfaceRecreated : 1;
-};
-
-class Q_AUTOTEST_EXPORT QWidgetBackingStore
-{
-public:
- QWidgetBackingStore(QWidget *t);
- ~QWidgetBackingStore();
-
- static void showYellowThing(QWidget *widget, const QRegion &rgn, int msec, bool);
-
- void sync(QWidget *exposedWidget, const QRegion &exposedRegion);
- void sync();
- void flush(QWidget *widget = 0, QWindowSurface *surface = 0);
-
- inline QPoint topLevelOffset() const { return tlwOffset; }
-
- QWindowSurface *surface() const { return windowSurface; }
-
- inline bool isDirty() const
- {
- return !(dirtyWidgets.isEmpty() && dirty.isEmpty() && !hasDirtyFromPreviousSync
- && !fullUpdatePending
-#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER)
- && !hasDirtyWindowDecoration()
-#endif
- );
- }
-
- // ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
- void markDirty(const QRegion &rgn, QWidget *widget, bool updateImmediately = false,
- bool invalidateBuffer = false);
- void markDirty(const QRect &rect, QWidget *widget, bool updateImmediately = false,
- bool invalidateBuffer = false);
-
-private:
- QWidget *tlw;
- QRegion dirtyOnScreen; // needsFlush
- QRegion dirty; // needsRepaint
- QRegion dirtyFromPreviousSync;
- QVector<QWidget *> dirtyWidgets;
- QVector<QWidget *> *dirtyOnScreenWidgets;
- QList<QWidget *> staticWidgets;
- QWindowSurface *windowSurface;
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- QList<QWindowSurface*> subSurfaces;
-#endif
- uint hasDirtyFromPreviousSync : 1;
- uint fullUpdatePending : 1;
-
- QPoint tlwOffset;
-
- static bool flushPaint(QWidget *widget, const QRegion &rgn);
- static void unflushPaint(QWidget *widget, const QRegion &rgn);
-
- bool bltRect(const QRect &rect, int dx, int dy, QWidget *widget);
- void releaseBuffer();
-
- void beginPaint(QRegion &toClean, QWidget *widget, QWindowSurface *windowSurface,
- BeginPaintInfo *returnInfo, bool toCleanIsInTopLevelCoordinates = true);
- void endPaint(const QRegion &cleaned, QWindowSurface *windowSurface, BeginPaintInfo *beginPaintInfo);
-
- QRegion dirtyRegion(QWidget *widget = 0) const;
- QRegion staticContents(QWidget *widget = 0, const QRect &withinClipRect = QRect()) const;
-
- void markDirtyOnScreen(const QRegion &dirtyOnScreen, QWidget *widget, const QPoint &topLevelOffset);
-
- void removeDirtyWidget(QWidget *w);
-
-#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER)
- bool hasDirtyWindowDecoration() const;
- void paintWindowDecoration();
-#endif
- void updateLists(QWidget *widget);
-
- inline void addDirtyWidget(QWidget *widget, const QRegion &rgn)
- {
- if (widget && !widget->d_func()->inDirtyList && !widget->data->in_destructor) {
- QWidgetPrivate *widgetPrivate = widget->d_func();
-#ifndef QT_NO_GRAPHICSEFFECT
- if (widgetPrivate->graphicsEffect)
- widgetPrivate->dirty = widgetPrivate->effectiveRectFor(rgn.boundingRect());
- else
-#endif //QT_NO_GRAPHICSEFFECT
- widgetPrivate->dirty = rgn;
- dirtyWidgets.append(widget);
- widgetPrivate->inDirtyList = true;
- }
- }
-
- inline void dirtyWidgetsRemoveAll(QWidget *widget)
- {
- int i = 0;
- while (i < dirtyWidgets.size()) {
- if (dirtyWidgets.at(i) == widget)
- dirtyWidgets.remove(i);
- else
- ++i;
- }
- }
-
- inline void addStaticWidget(QWidget *widget)
- {
- if (!widget)
- return;
-
- Q_ASSERT(widget->testAttribute(Qt::WA_StaticContents));
- if (!staticWidgets.contains(widget))
- staticWidgets.append(widget);
- }
-
- inline void removeStaticWidget(QWidget *widget)
- { staticWidgets.removeAll(widget); }
-
- // Move the reparented widget and all its static children from this backing store
- // to the new backing store if reparented into another top-level / backing store.
- inline void moveStaticWidgets(QWidget *reparented)
- {
- Q_ASSERT(reparented);
- QWidgetBackingStore *newBs = reparented->d_func()->maybeBackingStore();
- if (newBs == this)
- return;
-
- int i = 0;
- while (i < staticWidgets.size()) {
- QWidget *w = staticWidgets.at(i);
- if (reparented == w || reparented->isAncestorOf(w)) {
- staticWidgets.removeAt(i);
- if (newBs)
- newBs->addStaticWidget(w);
- } else {
- ++i;
- }
- }
- }
-
- inline QRect topLevelRect() const
- {
-#ifdef Q_WS_QWS
- return tlw->frameGeometry();
-#else
- return tlw->data->crect;
-#endif
- }
-
- inline void appendDirtyOnScreenWidget(QWidget *widget)
- {
- if (!widget)
- return;
-
- if (!dirtyOnScreenWidgets) {
- dirtyOnScreenWidgets = new QVector<QWidget *>;
- dirtyOnScreenWidgets->append(widget);
- } else if (!dirtyOnScreenWidgets->contains(widget)) {
- dirtyOnScreenWidgets->append(widget);
- }
- }
-
- inline void dirtyOnScreenWidgetsRemoveAll(QWidget *widget)
- {
- if (!widget || !dirtyOnScreenWidgets)
- return;
-
- int i = 0;
- while (i < dirtyOnScreenWidgets->size()) {
- if (dirtyOnScreenWidgets->at(i) == widget)
- dirtyOnScreenWidgets->remove(i);
- else
- ++i;
- }
- }
-
- inline void resetWidget(QWidget *widget)
- {
- if (widget) {
- widget->d_func()->inDirtyList = false;
- widget->d_func()->isScrolled = false;
- widget->d_func()->isMoved = false;
- widget->d_func()->dirty = QRegion();
- }
- }
-
- inline void updateStaticContentsSize()
- {
- for (int i = 0; i < staticWidgets.size(); ++i) {
- QWidgetPrivate *wd = staticWidgets.at(i)->d_func();
- if (!wd->extra)
- wd->createExtra();
- wd->extra->staticContentsSize = wd->data.crect.size();
- }
- }
-
- inline bool hasStaticContents() const
- { return !staticWidgets.isEmpty() && windowSurface->hasFeature(QWindowSurface::StaticContents); }
-
- friend QRegion qt_dirtyRegion(QWidget *);
- friend class QWidgetPrivate;
- friend class QWidget;
- friend class QWSManagerPrivate;
- friend class QETWidget;
- friend class QWindowSurface;
- friend class QWSWindowSurface;
-};
-
-QT_END_NAMESPACE
-
-#endif // QBACKINGSTORE_P_H
diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp
index 3ff7eb84d0..b5320dd6cb 100644
--- a/src/gui/painting/qbrush.cpp
+++ b/src/gui/painting/qbrush.cpp
@@ -48,7 +48,7 @@
#include "qline.h"
#include "qdebug.h"
#include <QtCore/qcoreapplication.h>
-#include "private/qstylehelper_p.h"
+#include "private/qhexstring_p.h"
#include <QtCore/qnumeric.h>
QT_BEGIN_NAMESPACE
@@ -712,36 +712,6 @@ void QBrush::setColor(const QColor &c)
Sets the brush color to the given \a color.
*/
-
-#ifdef QT3_SUPPORT
-
-/*!
- \fn void QBrush::setPixmap(const QPixmap &pixmap)
-
- \compat
-
- Sets a custom pattern for this brush.
-
- Use setTexture() instead.
-*/
-
-/*!
- \fn QPixmap *QBrush::pixmap() const
-
- Returns a pointer to the custom brush pattern.
-
- Use texture() instead.
-*/
-QPixmap *QBrush::pixmap() const
-{
- if (d->style != Qt::TexturePattern)
- return 0;
- QTexturedBrushData *data = static_cast<QTexturedBrushData*>(d.data());
- QPixmap &pixmap = data->pixmap();
- return pixmap.isNull() ? 0 : &pixmap;
-}
-#endif
-
/*!
\fn QPixmap QBrush::texture() const
diff --git a/src/gui/painting/qbrush.h b/src/gui/painting/qbrush.h
index d914c8c5b1..e399a4e3ae 100644
--- a/src/gui/painting/qbrush.h
+++ b/src/gui/painting/qbrush.h
@@ -126,12 +126,6 @@ public:
bool operator==(const QBrush &b) const;
inline bool operator!=(const QBrush &b) const { return !(operator==(b)); }
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT operator const QColor&() const;
- QT3_SUPPORT QPixmap *pixmap() const;
- inline QT3_SUPPORT void setPixmap(const QPixmap &pixmap) { setTexture(pixmap); }
-#endif
-
private:
#if defined(Q_WS_X11)
friend class QX11PaintEngine;
@@ -185,10 +179,6 @@ inline const QMatrix &QBrush::matrix() const { return d->transform.toAffine(); }
inline QTransform QBrush::transform() const { return d->transform; }
inline bool QBrush::isDetached() const { return d->ref == 1; }
-#ifdef QT3_SUPPORT
-inline QBrush::operator const QColor&() const { return d->color; }
-#endif
-
/*******************************************************************************
* QGradients
diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp
index ff6c24ee9e..1a6b090f63 100644
--- a/src/gui/painting/qcolor.cpp
+++ b/src/gui/painting/qcolor.cpp
@@ -2463,30 +2463,6 @@ void QColor::invalidate()
ct.argb.pad = 0;
}
-#ifdef QT3_SUPPORT
-
-/*!
- Returns the pixel value used by the underlying window system to refer to a
- color.
-
- Use QColormap::pixel() instead.
-
- \oldcode
- QColor myColor;
- uint pixel = myColor.pixel(screen);
- \newcode
- QColormap cmap = QColormap::instance(screen);
- uint pixel = cmap.pixel(*this);
- \endcode
-*/
-uint QColor::pixel(int screen) const
-{
- QColormap cmap = QColormap::instance(screen);
- return cmap.pixel(*this);
-}
-
-#endif // QT3_SUPPORT
-
/*****************************************************************************
QColor stream functions
*****************************************************************************/
diff --git a/src/gui/painting/qcolor.h b/src/gui/painting/qcolor.h
index af7248ce8c..38fce2500d 100644
--- a/src/gui/painting/qcolor.h
+++ b/src/gui/painting/qcolor.h
@@ -208,30 +208,9 @@ public:
static void setAllowX11ColorNames(bool enabled);
#endif
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT_CONSTRUCTOR QColor(int x, int y, int z, Spec colorSpec)
- { if (colorSpec == Hsv) setHsv(x, y, z); else setRgb(x, y, z); }
-
- inline QT3_SUPPORT void rgb(int *r, int *g, int *b) const
- { getRgb(r, g, b); }
- inline QT3_SUPPORT void hsv(int *h, int *s, int *v) const
- { getHsv(h, s, v); }
-
- inline QT3_SUPPORT void setRgba(int r, int g, int b, int a)
- { setRgb(r, g, b, a); }
- inline QT3_SUPPORT void getRgba(int *r, int *g, int *b, int *a) const
- { getRgb(r, g, b, a); }
-
- QT3_SUPPORT uint pixel(int screen = -1) const;
-#endif
-
static bool isValidColor(const QString &name);
private:
-#ifndef QT3_SUPPORT
- // do not allow a spec to be used as an alpha value
- QColor(int, int, int, Spec);
-#endif
void invalidate();
bool setColorFromString(const QString &name);
diff --git a/src/gui/painting/qcolormap_qpa.cpp b/src/gui/painting/qcolormap_qpa.cpp
index f66607bb05..24015a0497 100644
--- a/src/gui/painting/qcolormap_qpa.cpp
+++ b/src/gui/painting/qcolormap_qpa.cpp
@@ -42,8 +42,7 @@
#include "qcolormap.h"
#include "qcolor.h"
#include "qpaintdevice.h"
-#include "private/qapplication_p.h"
-#include "private/qgraphicssystem_p.h"
+#include "private/qguiapplication_p.h"
QT_BEGIN_NAMESPACE
@@ -67,7 +66,7 @@ void QColormap::initialize()
{
screenMap = new QColormapPrivate;
- QPlatformIntegration *pi = QApplicationPrivate::platformIntegration();
+ QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration();
QList<QPlatformScreen*> screens = pi->screens();
screenMap->depth = screens.at(0)->depth();
diff --git a/src/gui/painting/qcolormap_qws.cpp b/src/gui/painting/qcolormap_qws.cpp
deleted file mode 100644
index 5c0933d6eb..0000000000
--- a/src/gui/painting/qcolormap_qws.cpp
+++ /dev/null
@@ -1,185 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qcolormap.h"
-#include "qcolor.h"
-#include "qpaintdevice.h"
-#include "qscreen_qws.h"
-#include "qwsdisplay_qws.h"
-
-QT_BEGIN_NAMESPACE
-
-class QColormapPrivate
-{
-public:
- inline QColormapPrivate()
- : ref(1), mode(QColormap::Direct), depth(0), numcolors(0)
- { }
-
- QAtomicInt ref;
-
- QColormap::Mode mode;
- int depth;
- int numcolors;
-};
-
-static QColormapPrivate *screenMap = 0;
-
-void QColormap::initialize()
-{
- screenMap = new QColormapPrivate;
-
- screenMap->depth = QPaintDevice::qwsDisplay()->depth();
- if (screenMap->depth < 8) {
- screenMap->mode = QColormap::Indexed;
- screenMap->numcolors = 256;
- } else {
- screenMap->mode = QColormap::Direct;
- screenMap->numcolors = -1;
- }
-}
-
-void QColormap::cleanup()
-{
- delete screenMap;
- screenMap = 0;
-}
-
-QColormap QColormap::instance(int /*screen*/)
-{
- return QColormap();
-}
-
-QColormap::QColormap()
- : d(screenMap)
-{ d->ref.ref(); }
-
-QColormap::QColormap(const QColormap &colormap)
- :d (colormap.d)
-{ d->ref.ref(); }
-
-QColormap::~QColormap()
-{
- if (!d->ref.deref())
- delete d;
-}
-
-QColormap::Mode QColormap::mode() const
-{ return d->mode; }
-
-
-int QColormap::depth() const
-{ return d->depth; }
-
-
-int QColormap::size() const
-{
- return d->numcolors;
-}
-
-uint QColormap::pixel(const QColor &color) const
-{
- QRgb rgb = color.rgba();
- if (d->mode == QColormap::Direct) {
- switch(d->depth) {
- case 16:
- return qt_convRgbTo16(rgb);
- case 24:
- case 32:
- {
- const int r = qRed(rgb);
- const int g = qGreen(rgb);
- const int b = qBlue(rgb);
- const int red_shift = 16;
- const int green_shift = 8;
- const int red_mask = 0xff0000;
- const int green_mask = 0x00ff00;
- const int blue_mask = 0x0000ff;
- const int tg = g << green_shift;
-#ifdef QT_QWS_DEPTH_32_BGR
- if (qt_screen->pixelType() == QScreen::BGRPixel) {
- const int tb = b << red_shift;
- return 0xff000000 | (r & blue_mask) | (tg & green_mask) | (tb & red_mask);
- }
-#endif
- const int tr = r << red_shift;
- return 0xff000000 | (b & blue_mask) | (tg & green_mask) | (tr & red_mask);
- }
- }
- }
- return qt_screen->alloc(qRed(rgb), qGreen(rgb), qBlue(rgb));
-}
-
-const QColor QColormap::colorAt(uint pixel) const
-{
- if (d->mode == Direct) {
- if (d->depth == 16) {
- pixel = qt_conv16ToRgb(pixel);
- }
- const int red_shift = 16;
- const int green_shift = 8;
- const int red_mask = 0xff0000;
- const int green_mask = 0x00ff00;
- const int blue_mask = 0x0000ff;
-#ifdef QT_QWS_DEPTH_32_BGR
- if (qt_screen->pixelType() == QScreen::BGRPixel) {
- return QColor((pixel & blue_mask),
- (pixel & green_mask) >> green_shift,
- (pixel & red_mask) >> red_shift);
- }
-#endif
- return QColor((pixel & red_mask) >> red_shift,
- (pixel & green_mask) >> green_shift,
- (pixel & blue_mask));
- }
- Q_ASSERT_X(int(pixel) < qt_screen->colorCount(), "QColormap::colorAt", "pixel out of bounds of palette");
- return QColor(qt_screen->clut()[pixel]);
-}
-
-const QVector<QColor> QColormap::colormap() const
-{
- return QVector<QColor>();
-}
-
-QColormap &QColormap::operator=(const QColormap &colormap)
-{ qAtomicAssign(d, colormap.d); return *this; }
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qcssutil_p.h b/src/gui/painting/qcssutil_p.h
index 80606b4cb9..ab1abc99cf 100644
--- a/src/gui/painting/qcssutil_p.h
+++ b/src/gui/painting/qcssutil_p.h
@@ -71,10 +71,10 @@ extern void qDrawRoundedCorners(QPainter *p, qreal x1, qreal y1, qreal x2, qreal
const QSizeF& r1, const QSizeF& r2,
QCss::Edge edge, QCss::BorderStyle s, QBrush c);
-extern void qDrawBorder(QPainter *p, const QRect &rect, const QCss::BorderStyle *styles,
+extern void Q_GUI_EXPORT qDrawBorder(QPainter *p, const QRect &rect, const QCss::BorderStyle *styles,
const int *borders, const QBrush *colors, const QSize *radii);
-extern void qNormalizeRadii(const QRect &br, const QSize *radii,
+extern void Q_GUI_EXPORT qNormalizeRadii(const QRect &br, const QSize *radii,
QSize *tlr, QSize *trr, QSize *blr, QSize *brr);
QT_END_NAMESPACE
diff --git a/src/gui/painting/qcups_p.h b/src/gui/painting/qcups_p.h
index bc00c7396e..4b3ea32ac7 100644
--- a/src/gui/painting/qcups_p.h
+++ b/src/gui/painting/qcups_p.h
@@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE
Q_DECLARE_TYPEINFO(cups_option_t, Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE);
-class QCUPSSupport
+class Q_GUI_EXPORT QCUPSSupport
{
public:
QCUPSSupport();
diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp
index 360292c4d7..5e23f5f6fd 100644
--- a/src/gui/painting/qdrawhelper.cpp
+++ b/src/gui/painting/qdrawhelper.cpp
@@ -3285,9 +3285,6 @@ static
void drawBufferSpan(QSpanData *data, const uint *buffer, int bufsize,
int x, int y, int length, uint const_alpha)
{
-#if defined (Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS)
- data->rasterEngine->drawBufferSpan(buffer, bufsize, x, y, length, const_alpha);
-#else
Q_UNUSED(data);
Q_UNUSED(buffer);
Q_UNUSED(bufsize);
@@ -3295,7 +3292,6 @@ void drawBufferSpan(QSpanData *data, const uint *buffer, int bufsize,
Q_UNUSED(y);
Q_UNUSED(length);
Q_UNUSED(const_alpha);
-#endif
}
#if !defined(Q_CC_SUN)
@@ -3323,18 +3319,6 @@ void blend_color_generic(int count, const QSpan *spans, void *userData)
}
}
-#if defined (Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS)
-static void blend_color_generic_callback(int count, const QSpan *spans, void *userData)
-{
- // ### Falcon
- Q_UNUSED(count);
- Q_UNUSED(spans);
- Q_UNUSED(userData);
-// QSpanData *data = reinterpret_cast<QSpanData*>(userData);
-// data->rasterEngine->drawColorSpans(spans, count, data->solid.color);
-}
-#endif // QT_NO_RASTERCALLBACKS
-
static void blend_color_argb(int count, const QSpan *spans, void *userData)
{
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
@@ -4957,65 +4941,30 @@ void QT_FASTCALL blendUntransformed(int count, const QSpan *spans, void *userDat
static void blend_untransformed_rgb888(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_24)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_RGB888)
- blendUntransformed<qrgb888, qrgb888>(count, spans, userData);
- else
-#endif
- blend_untransformed_generic<RegularSpans>(count, spans, userData);
+ blend_untransformed_generic<RegularSpans>(count, spans, userData);
}
static void blend_untransformed_argb6666(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_18)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
- blendUntransformed<qargb6666, qargb6666>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB666)
- blendUntransformed<qargb6666, qrgb666>(count, spans, userData);
- else
-#endif
- blend_untransformed_generic<RegularSpans>(count, spans, userData);
+ blend_untransformed_generic<RegularSpans>(count, spans, userData);
}
static void blend_untransformed_rgb666(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_18)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
- blendUntransformed<qrgb666, qargb6666>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB666)
- blendUntransformed<qrgb666, qrgb666>(count, spans, userData);
- else
-#endif
- blend_untransformed_generic<RegularSpans>(count, spans, userData);
+ blend_untransformed_generic<RegularSpans>(count, spans, userData);
}
static void blend_untransformed_argb8565(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_16)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
- blendUntransformed<qargb8565, qargb8565>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB16)
- blendUntransformed<qargb8565, qrgb565>(count, spans, userData);
- else
-#endif
- blend_untransformed_generic<RegularSpans>(count, spans, userData);
+ blend_untransformed_generic<RegularSpans>(count, spans, userData);
}
static void blend_untransformed_rgb565(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
@@ -5023,68 +4972,31 @@ static void blend_untransformed_rgb565(int count, const QSpan *spans,
else if (data->texture.format == QImage::Format_RGB16)
blendUntransformed<qrgb565, qrgb565>(count, spans, userData);
else
-#endif
blend_untransformed_generic<RegularSpans>(count, spans, userData);
}
static void blend_untransformed_argb8555(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_15)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
- blendUntransformed<qargb8555, qargb8555>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB555)
- blendUntransformed<qargb8555, qrgb555>(count, spans, userData);
- else
-#endif
- blend_untransformed_generic<RegularSpans>(count, spans, userData);
+ blend_untransformed_generic<RegularSpans>(count, spans, userData);
}
static void blend_untransformed_rgb555(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_15)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
- blendUntransformed<qrgb555, qargb8555>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB555)
- blendUntransformed<qrgb555, qrgb555>(count, spans, userData);
- else
-#endif
- blend_untransformed_generic<RegularSpans>(count, spans, userData);
+ blend_untransformed_generic<RegularSpans>(count, spans, userData);
}
static void blend_untransformed_argb4444(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_12)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
- blendUntransformed<qargb4444, qargb4444>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB444)
- blendUntransformed<qargb4444, qrgb444>(count, spans, userData);
- else
-#endif
- blend_untransformed_generic<RegularSpans>(count, spans, userData);
+ blend_untransformed_generic<RegularSpans>(count, spans, userData);
}
static void blend_untransformed_rgb444(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_12)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
- blendUntransformed<qrgb444, qargb4444>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB444)
- blendUntransformed<qrgb444, qrgb444>(count, spans, userData);
- else
-#endif
- blend_untransformed_generic<RegularSpans>(count, spans, userData);
+ blend_untransformed_generic<RegularSpans>(count, spans, userData);
}
template <SpanMethod spanMethod>
@@ -5300,61 +5212,26 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTiled(int count, const QSpan *spans, void *
static void blend_tiled_rgb888(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_24)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_RGB888)
- blendTiled<qrgb888, qrgb888>(count, spans, userData);
- else
-#endif
- blend_tiled_generic<RegularSpans>(count, spans, userData);
+ blend_tiled_generic<RegularSpans>(count, spans, userData);
}
static void blend_tiled_argb6666(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_18)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
- blendTiled<qargb6666, qargb6666>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB666)
- blendTiled<qargb6666, qrgb666>(count, spans, userData);
- else
-#endif
- blend_tiled_generic<RegularSpans>(count, spans, userData);
+ blend_tiled_generic<RegularSpans>(count, spans, userData);
}
static void blend_tiled_rgb666(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_18)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
- blendTiled<qrgb666, qargb6666>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB666)
- blendTiled<qrgb666, qrgb666>(count, spans, userData);
- else
-#endif
- blend_tiled_generic<RegularSpans>(count, spans, userData);
+ blend_tiled_generic<RegularSpans>(count, spans, userData);
}
static void blend_tiled_argb8565(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_16)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
- blendTiled<qargb8565, qargb8565>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB16)
- blendTiled<qargb8565, qrgb565>(count, spans, userData);
- else
-#endif
- blend_tiled_generic<RegularSpans>(count, spans, userData);
+ blend_tiled_generic<RegularSpans>(count, spans, userData);
}
static void blend_tiled_rgb565(int count, const QSpan *spans, void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
@@ -5362,64 +5239,27 @@ static void blend_tiled_rgb565(int count, const QSpan *spans, void *userData)
else if (data->texture.format == QImage::Format_RGB16)
blendTiled<qrgb565, qrgb565>(count, spans, userData);
else
-#endif
blend_tiled_generic<RegularSpans>(count, spans, userData);
}
static void blend_tiled_argb8555(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_15)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
- blendTiled<qargb8555, qargb8555>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB555)
- blendTiled<qargb8555, qrgb555>(count, spans, userData);
- else
-#endif
- blend_tiled_generic<RegularSpans>(count, spans, userData);
+ blend_tiled_generic<RegularSpans>(count, spans, userData);
}
static void blend_tiled_rgb555(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_15)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
- blendTiled<qrgb555, qargb8555>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB555)
- blendTiled<qrgb555, qrgb555>(count, spans, userData);
- else
-#endif
- blend_tiled_generic<RegularSpans>(count, spans, userData);
+ blend_tiled_generic<RegularSpans>(count, spans, userData);
}
static void blend_tiled_argb4444(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_12)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
- blendTiled<qargb4444, qargb4444>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB444)
- blendTiled<qargb4444, qrgb444>(count, spans, userData);
- else
-#endif
- blend_tiled_generic<RegularSpans>(count, spans, userData);
+ blend_tiled_generic<RegularSpans>(count, spans, userData);
}
static void blend_tiled_rgb444(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_12)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
- blendTiled<qrgb444, qargb4444>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB444)
- blendTiled<qrgb444, qrgb444>(count, spans, userData);
- else
-#endif
- blend_tiled_generic<RegularSpans>(count, spans, userData);
+ blend_tiled_generic<RegularSpans>(count, spans, userData);
}
template <class DST, class SRC>
@@ -5647,62 +5487,27 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTransformedBilinear(int count, const QSpan
static void blend_transformed_bilinear_rgb888(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_24)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_RGB888)
- blendTransformedBilinear<qrgb888, qrgb888>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_bilinear_argb6666(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_18)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
- blendTransformedBilinear<qargb6666, qargb6666>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB666)
- blendTransformedBilinear<qargb6666, qrgb666>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_bilinear_rgb666(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_18)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
- blendTransformedBilinear<qrgb666, qargb6666>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB666)
- blendTransformedBilinear<qrgb666, qrgb666>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_bilinear_argb8565(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_16)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
- blendTransformedBilinear<qargb8565, qargb8565>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB16)
- blendTransformedBilinear<qargb8565, qrgb565>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_bilinear_rgb565(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_RGB16)
@@ -5710,64 +5515,27 @@ static void blend_transformed_bilinear_rgb565(int count, const QSpan *spans,
else if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
blendTransformedBilinear<qrgb565, qargb8565>(count, spans, userData);
else
-#endif
blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_bilinear_argb8555(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_15)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
- blendTransformedBilinear<qargb8555, qargb8555>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB555)
- blendTransformedBilinear<qargb8555, qrgb555>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_bilinear_rgb555(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_15)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
- blendTransformedBilinear<qrgb555, qargb8555>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB555)
- blendTransformedBilinear<qrgb555, qrgb555>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_bilinear_argb4444(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_12)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
- blendTransformedBilinear<qargb4444, qargb4444>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB444)
- blendTransformedBilinear<qargb4444, qrgb444>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_bilinear_rgb444(int count, const QSpan *spans, void *userData)
{
-#if defined(QT_QWS_DEPTH_12)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
- blendTransformedBilinear<qrgb444, qargb4444>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB444)
- blendTransformedBilinear<qrgb444, qrgb444>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
template <SpanMethod spanMethod>
@@ -6040,65 +5808,30 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTransformed(int count, const QSpan *spans,
static void blend_transformed_rgb888(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_24)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_RGB888)
- blendTransformed<qrgb888, qrgb888>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_argb6666(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_18)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
- blendTransformed<qargb6666, qargb6666>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB666)
- blendTransformed<qargb6666, qrgb666>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_rgb666(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_18)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
- blendTransformed<qrgb666, qargb6666>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB666)
- blendTransformed<qrgb666, qrgb666>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_argb8565(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_16)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
- blendTransformed<qargb8565, qargb8565>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB16)
- blendTransformed<qargb8565, qrgb565>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_rgb565(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
@@ -6106,68 +5839,31 @@ static void blend_transformed_rgb565(int count, const QSpan *spans,
else if (data->texture.format == QImage::Format_RGB16)
blendTransformed<qrgb565, qrgb565>(count, spans, userData);
else
-#endif
blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_argb8555(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_15)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
- blendTransformed<qargb8555, qargb8555>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB555)
- blendTransformed<qargb8555, qrgb555>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_rgb555(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_15)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
- blendTransformed<qrgb555, qargb8555>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB555)
- blendTransformed<qrgb555, qrgb555>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_argb4444(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_12)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
- blendTransformed<qargb4444, qargb4444>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB444)
- blendTransformed<qargb4444, qrgb444>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_rgb444(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_12)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
- blendTransformed<qrgb444, qargb4444>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB444)
- blendTransformed<qrgb444, qrgb444>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
template <SpanMethod spanMethod>
@@ -6455,65 +6151,30 @@ Q_STATIC_TEMPLATE_FUNCTION void blendTransformedTiled(int count, const QSpan *sp
static void blend_transformed_tiled_rgb888(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_24)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_RGB888)
- blendTransformedTiled<qrgb888, qrgb888>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_tiled_argb6666(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_18)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
- blendTransformedTiled<qargb6666, qargb6666>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB666)
- blendTransformedTiled<qargb6666, qrgb666>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_tiled_rgb666(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_18)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB6666_Premultiplied)
- blendTransformedTiled<qrgb666, qargb6666>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB666)
- blendTransformedTiled<qrgb666, qrgb666>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_tiled_argb8565(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_16)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
- blendTransformedTiled<qargb8565, qargb8565>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB16)
- blendTransformedTiled<qargb8565, qrgb565>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_tiled_rgb565(int count, const QSpan *spans,
void *userData)
{
-#if !defined(Q_WS_QWS) || defined(QT_QWS_DEPTH_16)
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
if (data->texture.format == QImage::Format_ARGB8565_Premultiplied)
@@ -6521,68 +6182,31 @@ static void blend_transformed_tiled_rgb565(int count, const QSpan *spans,
else if (data->texture.format == QImage::Format_RGB16)
blendTransformedTiled<qrgb565, qrgb565>(count, spans, userData);
else
-#endif
blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_tiled_argb8555(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_15)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
- blendTransformedTiled<qargb8555, qargb8555>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB555)
- blendTransformedTiled<qargb8555, qrgb555>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_tiled_rgb555(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_15)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB8555_Premultiplied)
- blendTransformedTiled<qrgb555, qargb8555>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB555)
- blendTransformedTiled<qrgb555, qrgb555>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_tiled_argb4444(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_12)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
- blendTransformedTiled<qargb4444, qargb4444>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB444)
- blendTransformedTiled<qargb4444, qrgb444>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
static void blend_transformed_tiled_rgb444(int count, const QSpan *spans,
void *userData)
{
-#if defined(QT_QWS_DEPTH_12)
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
-
- if (data->texture.format == QImage::Format_ARGB4444_Premultiplied)
- blendTransformedTiled<qrgb444, qargb4444>(count, spans, userData);
- else if (data->texture.format == QImage::Format_RGB444)
- blendTransformedTiled<qrgb444, qrgb444>(count, spans, userData);
- else
-#endif
- blend_src_generic<RegularSpans>(count, spans, userData);
+ blend_src_generic<RegularSpans>(count, spans, userData);
}
# define SPANFUNC_POINTER(Name, Arg) Name<Arg>
@@ -6706,125 +6330,6 @@ static const ProcessSpans processTextureSpans[NBlendTypes][QImage::NImageFormats
}
};
-#if defined (Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS)
-static const ProcessSpans processTextureSpansCallback[NBlendTypes][QImage::NImageFormats] = {
- // Untransformed
- {
- 0, // Invalid
- blend_untransformed_generic<CallbackSpans>, // Mono
- blend_untransformed_generic<CallbackSpans>, // MonoLsb
- blend_untransformed_generic<CallbackSpans>, // Indexed8
- blend_untransformed_generic<CallbackSpans>, // RGB32
- blend_untransformed_generic<CallbackSpans>, // ARGB32
- blend_untransformed_argb<CallbackSpans>, // ARGB32_Premultiplied
- blend_untransformed_generic<CallbackSpans>, // RGB16
- blend_untransformed_generic<CallbackSpans>, // ARGB8565_Premultiplied
- blend_untransformed_generic<CallbackSpans>, // RGB666
- blend_untransformed_generic<CallbackSpans>, // ARGB6666_Premultiplied
- blend_untransformed_generic<CallbackSpans>, // RGB555
- blend_untransformed_generic<CallbackSpans>, // ARGB8555_Premultiplied
- blend_untransformed_generic<CallbackSpans>, // RGB888
- blend_untransformed_generic<CallbackSpans>, // RGB444
- blend_untransformed_generic<CallbackSpans> // ARGB4444_Premultiplied
- },
- // Tiled
- {
- 0, // Invalid
- blend_tiled_generic<CallbackSpans>, // Mono
- blend_tiled_generic<CallbackSpans>, // MonoLsb
- blend_tiled_generic<CallbackSpans>, // Indexed8
- blend_tiled_generic<CallbackSpans>, // RGB32
- blend_tiled_generic<CallbackSpans>, // ARGB32
- blend_tiled_argb<CallbackSpans>, // ARGB32_Premultiplied
- blend_tiled_generic<CallbackSpans>, // RGB16
- blend_tiled_generic<CallbackSpans>, // ARGB8565_Premultiplied
- blend_tiled_generic<CallbackSpans>, // RGB666
- blend_tiled_generic<CallbackSpans>, // ARGB6666_Premultiplied
- blend_tiled_generic<CallbackSpans>, // RGB555
- blend_tiled_generic<CallbackSpans>, // ARGB8555_Premultiplied
- blend_tiled_generic<CallbackSpans>, // RGB888
- blend_tiled_generic<CallbackSpans>, // RGB444
- blend_tiled_generic<CallbackSpans> // ARGB4444_Premultiplied
- },
- // Transformed
- {
- 0, // Invalid
- blend_src_generic<CallbackSpans>, // Mono
- blend_src_generic<CallbackSpans>, // MonoLsb
- blend_src_generic<CallbackSpans>, // Indexed8
- blend_src_generic<CallbackSpans>, // RGB32
- blend_src_generic<CallbackSpans>, // ARGB32
- blend_transformed_argb<CallbackSpans>, // ARGB32_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB16
- blend_src_generic<CallbackSpans>, // ARGB8565_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB666
- blend_src_generic<CallbackSpans>, // ARGB6666_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB555
- blend_src_generic<CallbackSpans>, // ARGB8555_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB888
- blend_src_generic<CallbackSpans>, // RGB444
- blend_src_generic<CallbackSpans>, // ARGB4444_Premultiplied
- },
- // TransformedTiled
- {
- 0,
- blend_src_generic<CallbackSpans>, // Mono
- blend_src_generic<CallbackSpans>, // MonoLsb
- blend_src_generic<CallbackSpans>, // Indexed8
- blend_src_generic<CallbackSpans>, // RGB32
- blend_src_generic<CallbackSpans>, // ARGB32
- blend_transformed_tiled_argb<CallbackSpans>, // ARGB32_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB16
- blend_src_generic<CallbackSpans>, // ARGB8565_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB666
- blend_src_generic<CallbackSpans>, // ARGB6666_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB555
- blend_src_generic<CallbackSpans>, // ARGB8555_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB888
- blend_src_generic<CallbackSpans>, // RGB444
- blend_src_generic<CallbackSpans> // ARGB4444_Premultiplied
- },
- // Bilinear
- {
- 0,
- blend_src_generic<CallbackSpans>, // Mono
- blend_src_generic<CallbackSpans>, // MonoLsb
- blend_src_generic<CallbackSpans>, // Indexed8
- blend_src_generic<CallbackSpans>, // RGB32
- blend_src_generic<CallbackSpans>, // ARGB32
- blend_src_generic<CallbackSpans>, // ARGB32_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB16
- blend_src_generic<CallbackSpans>, // ARGB8565_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB666
- blend_src_generic<CallbackSpans>, // ARGB6666_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB555
- blend_src_generic<CallbackSpans>, // ARGB8555_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB888
- blend_src_generic<CallbackSpans>, // RGB444
- blend_src_generic<CallbackSpans> // ARGB4444_Premultiplied
- },
- // BilinearTiled
- {
- 0,
- blend_src_generic<CallbackSpans>, // Mono
- blend_src_generic<CallbackSpans>, // MonoLsb
- blend_src_generic<CallbackSpans>, // Indexed8
- blend_src_generic<CallbackSpans>, // RGB32
- blend_src_generic<CallbackSpans>, // ARGB32
- blend_src_generic<CallbackSpans>, // ARGB32_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB16
- blend_src_generic<CallbackSpans>, // ARGB8565_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB666
- blend_src_generic<CallbackSpans>, // ARGB6666_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB555
- blend_src_generic<CallbackSpans>, // ARGB8555_Premultiplied
- blend_src_generic<CallbackSpans>, // RGB888
- blend_src_generic<CallbackSpans>, // RGB444
- blend_src_generic<CallbackSpans> // ARGB4444_Premultiplied
- }
-};
-#endif // QT_NO_RASTERCALLBACKS
-
void qBlendTexture(int count, const QSpan *spans, void *userData)
{
QSpanData *data = reinterpret_cast<QSpanData *>(userData);
@@ -6832,15 +6337,6 @@ void qBlendTexture(int count, const QSpan *spans, void *userData)
proc(count, spans, userData);
}
-#if defined (Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS)
-void qBlendTextureCallback(int count, const QSpan *spans, void *userData)
-{
- QSpanData *data = reinterpret_cast<QSpanData *>(userData);
- ProcessSpans proc = processTextureSpansCallback[getBlendType(data)][data->rasterBuffer->format];
- proc(count, spans, userData);
-}
-#endif // QT_NO_RASTERCALLBACKS
-
template <class DST>
inline void qt_bitmapblit_template(QRasterBuffer *rasterBuffer,
int x, int y, quint32 color,
@@ -7490,106 +6986,6 @@ DrawHelper qDrawHelper[QImage::NImageFormats] =
}
};
-#if defined (Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS)
-DrawHelper qDrawHelperCallback[QImage::NImageFormats] =
-{
- // Format_Invalid,
- { 0, 0, 0, 0, 0, 0 },
- // Format_Mono,
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_MonoLSB,
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_Indexed8,
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_RGB32,
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_ARGB32,
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_ARGB32_Premultiplied
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_RGB16
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_ARGB8565_Premultiplied
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_RGB666
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_ARGB6666_Premultiplied
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_RGB555
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_ARGB8555_Premultiplied
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_RGB888
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_RGB444
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- },
- // Format_ARGB4444_Premultiplied
- {
- blend_color_generic_callback,
- blend_src_generic<CallbackSpans>,
- 0, 0, 0, 0
- }
-};
-#endif
-
-
-
#if defined(Q_CC_MSVC) && !defined(_MIPS_)
template <class DST, class SRC>
inline void qt_memfill_template(DST *dest, SRC color, int count)
@@ -7889,64 +7285,4 @@ static void qt_memfill16_setup(quint16 *dest, quint16 value, int count)
qt_memfill16(dest, value, count);
}
-#ifdef QT_QWS_DEPTH_GENERIC
-
-int qrgb::bpp = 0;
-int qrgb::len_red = 0;
-int qrgb::len_green = 0;
-int qrgb::len_blue = 0;
-int qrgb::len_alpha = 0;
-int qrgb::off_red = 0;
-int qrgb::off_green = 0;
-int qrgb::off_blue = 0;
-int qrgb::off_alpha = 0;
-
-template <typename SRC>
-Q_STATIC_TEMPLATE_FUNCTION inline void qt_rectconvert_rgb(qrgb *dest, const SRC *src,
- int x, int y, int width, int height,
- int dstStride, int srcStride)
-{
- quint8 *dest8 = reinterpret_cast<quint8*>(dest)
- + y * dstStride + x * qrgb::bpp;
-
- srcStride = srcStride / sizeof(SRC) - width;
- dstStride -= (width * qrgb::bpp);
-
- for (int j = 0; j < height; ++j) {
- for (int i = 0; i < width; ++i) {
- const quint32 v = qt_convertToRgb<SRC>(*src++);
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- for (int j = qrgb::bpp - 1; j >= 0; --j)
- *dest8++ = (v >> (8 * j)) & 0xff;
-#else
- for (int j = 0; j < qrgb::bpp; ++j)
- *dest8++ = (v >> (8 * j)) & 0xff;
-#endif
- }
-
- dest8 += dstStride;
- src += srcStride;
- }
-}
-
-template <>
-void qt_rectconvert(qrgb *dest, const quint32 *src,
- int x, int y, int width, int height,
- int dstStride, int srcStride)
-{
- qt_rectconvert_rgb<quint32>(dest, src, x, y, width, height,
- dstStride, srcStride);
-}
-
-template <>
-void qt_rectconvert(qrgb *dest, const quint16 *src,
- int x, int y, int width, int height,
- int dstStride, int srcStride)
-{
- qt_rectconvert_rgb<quint16>(dest, src, x, y, width, height,
- dstStride, srcStride);
-}
-
-#endif // QT_QWS_DEPTH_GENERIC
-
QT_END_NAMESPACE
diff --git a/src/gui/painting/qdrawhelper_p.h b/src/gui/painting/qdrawhelper_p.h
index fa6ad0be91..758b0c88cb 100644
--- a/src/gui/painting/qdrawhelper_p.h
+++ b/src/gui/painting/qdrawhelper_p.h
@@ -65,10 +65,6 @@
#include <private/qsimd_p.h>
#include <private/qmath_p.h>
-#ifdef Q_WS_QWS
-#include "QtGui/qscreen_qws.h"
-#endif
-
QT_BEGIN_NAMESPACE
#if defined(Q_CC_MSVC) && _MSCVER <= 1300 && !defined(Q_CC_INTEL)
@@ -171,10 +167,6 @@ extern MemRotateFunc qMemRotateFunctions[QImage::NImageFormats][3];
extern DrawHelper qDrawHelper[QImage::NImageFormats];
void qBlendTexture(int count, const QSpan *spans, void *userData);
-#if defined(Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS)
-extern DrawHelper qDrawHelperCallback[QImage::NImageFormats];
-void qBlendTextureCallback(int count, const QSpan *spans, void *userData);
-#endif
typedef void (QT_FASTCALL *CompositionFunction)(uint *dest, const uint *src, int length, uint const_alpha);
typedef void (QT_FASTCALL *CompositionFunctionSolid)(uint *dest, int length, uint color, uint const_alpha);
@@ -271,13 +263,8 @@ struct QGradientData
QConicalGradientData conical;
};
-#ifdef Q_WS_QWS
-#define GRADIENT_STOPTABLE_SIZE 256
-#define GRADIENT_STOPTABLE_SIZE_SHIFT 8
-#else
#define GRADIENT_STOPTABLE_SIZE 1024
#define GRADIENT_STOPTABLE_SIZE_SHIFT 10
-#endif
uint* colorTable; //[GRADIENT_STOPTABLE_SIZE];
@@ -314,9 +301,6 @@ struct QSpanData
~QSpanData() { delete tempImage; }
QRasterBuffer *rasterBuffer;
-#ifdef Q_WS_QWS
- QRasterPaintEngine *rasterEngine;
-#endif
ProcessSpans blend;
ProcessSpans unclipped_blend;
BitmapBlitFunc bitmapBlit;
@@ -1492,37 +1476,6 @@ inline quint32 qt_colorConvert(qrgb888 color, quint32 dummy)
return quint32(color);
}
-#ifdef QT_QWS_DEPTH_8
-template <>
-inline quint8 qt_colorConvert(quint32 color, quint8 dummy)
-{
- Q_UNUSED(dummy);
-
- uchar r = ((qRed(color) & 0xf8) + 0x19) / 0x33;
- uchar g = ((qGreen(color) &0xf8) + 0x19) / 0x33;
- uchar b = ((qBlue(color) &0xf8) + 0x19) / 0x33;
-
- return r*6*6 + g*6 + b;
-}
-
-template <>
-inline quint8 qt_colorConvert(quint16 color, quint8 dummy)
-{
- Q_UNUSED(dummy);
-
- uchar r = (color & 0xf800) >> (11-3);
- uchar g = (color & 0x07c0) >> (6-3);
- uchar b = (color & 0x001f) << 3;
-
- uchar tr = (r + 0x19) / 0x33;
- uchar tg = (g + 0x19) / 0x33;
- uchar tb = (b + 0x19) / 0x33;
-
- return tr*6*6 + tg*6 + tb;
-}
-
-#endif // QT_QWS_DEPTH_8
-
// hw: endianess??
class quint24
{
@@ -1759,84 +1712,6 @@ qrgb444 qrgb444::byte_mul(quint8 a) const
return result;
}
-#ifdef QT_QWS_DEPTH_GENERIC
-
-struct qrgb
-{
-public:
- static int bpp;
- static int len_red;
- static int len_green;
- static int len_blue;
- static int len_alpha;
- static int off_red;
- static int off_green;
- static int off_blue;
- static int off_alpha;
-} Q_PACKED;
-
-template <typename SRC>
-Q_STATIC_TEMPLATE_FUNCTION inline quint32 qt_convertToRgb(SRC color);
-
-template <>
-inline quint32 qt_convertToRgb(quint32 color)
-{
- const int r = qRed(color) >> (8 - qrgb::len_red);
- const int g = qGreen(color) >> (8 - qrgb::len_green);
- const int b = qBlue(color) >> (8 - qrgb::len_blue);
- const int a = qAlpha(color) >> (8 - qrgb::len_alpha);
- const quint32 v = (r << qrgb::off_red)
- | (g << qrgb::off_green)
- | (b << qrgb::off_blue)
- | (a << qrgb::off_alpha);
-
- return v;
-}
-
-template <>
-inline quint32 qt_convertToRgb(quint16 color)
-{
- return qt_convertToRgb(qt_colorConvert<quint32, quint16>(color, 0));
-}
-
-class qrgb_generic16
-{
-public:
- inline qrgb_generic16(quint32 color)
- {
- const int r = qRed(color) >> (8 - qrgb::len_red);
- const int g = qGreen(color) >> (8 - qrgb::len_green);
- const int b = qBlue(color) >> (8 - qrgb::len_blue);
- const int a = qAlpha(color) >> (8 - qrgb::len_alpha);
- data = (r << qrgb::off_red)
- | (g << qrgb::off_green)
- | (b << qrgb::off_blue)
- | (a << qrgb::off_alpha);
- }
-
- inline operator quint16 () { return data; }
- inline quint32 operator<<(int shift) const { return data << shift; }
-
-private:
- quint16 data;
-} Q_PACKED;
-
-template <>
-inline qrgb_generic16 qt_colorConvert(quint32 color, qrgb_generic16 dummy)
-{
- Q_UNUSED(dummy);
- return qrgb_generic16(color);
-}
-
-template <>
-inline qrgb_generic16 qt_colorConvert(quint16 color, qrgb_generic16 dummy)
-{
- Q_UNUSED(dummy);
- return qrgb_generic16(qt_colorConvert<quint32, quint16>(color, 0));
-}
-
-#endif // QT_QWS_DEPTH_GENERIC
-
template <class T>
void qt_memfill(T *dest, T value, int count);
@@ -2044,16 +1919,6 @@ QT_RECTCONVERT_TRIVIAL_IMPL(qargb4444)
QT_RECTCONVERT_TRIVIAL_IMPL(qrgb444)
#undef QT_RECTCONVERT_TRIVIAL_IMPL
-#ifdef QT_QWS_DEPTH_GENERIC
-template <> void qt_rectconvert(qrgb *dest, const quint32 *src,
- int x, int y, int width, int height,
- int dstStride, int srcStride);
-
-template <> void qt_rectconvert(qrgb *dest, const quint16 *src,
- int x, int y, int width, int height,
- int dstStride, int srcStride);
-#endif // QT_QWS_DEPTH_GENERIC
-
#define QT_MEMFILL_UINT(dest, length, color) \
qt_memfill<quint32>(dest, color, length);
@@ -2116,16 +1981,6 @@ inline ushort qConvertRgb32To16(uint c)
| (((c) >> 8) & 0xf800);
}
-#if defined(Q_WS_QWS) || (QT_VERSION >= 0x040400)
-inline quint32 qConvertRgb32To16x2(quint64 c)
-{
- c = (((c) >> 3) & Q_UINT64_C(0x001f0000001f))
- | (((c) >> 5) & Q_UINT64_C(0x07e0000007e0))
- | (((c) >> 8) & Q_UINT64_C(0xf8000000f800));
- return c | (c >> 16);
-}
-#endif
-
inline QRgb qConvertRgb16To32(uint c)
{
return 0xff000000
diff --git a/src/gui/painting/qdrawutil.cpp b/src/gui/painting/qdrawutil.cpp
deleted file mode 100644
index 89474d9679..0000000000
--- a/src/gui/painting/qdrawutil.cpp
+++ /dev/null
@@ -1,1360 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdrawutil.h"
-#include "qbitmap.h"
-#include "qpixmapcache.h"
-#include "qapplication.h"
-#include "qpainter.h"
-#include "qpalette.h"
-#include <private/qpaintengineex_p.h>
-#include <qvarlengtharray.h>
-#include <qmath.h>
-#include <private/qstylehelper_p.h>
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \headerfile <qdrawutil.h>
- \title Drawing Utility Functions
-
- \sa QPainter
-*/
-
-/*!
- \fn void qDrawShadeLine(QPainter *painter, int x1, int y1, int x2, int y2,
- const QPalette &palette, bool sunken,
- int lineWidth, int midLineWidth)
- \relates <qdrawutil.h>
-
- Draws a horizontal (\a y1 == \a y2) or vertical (\a x1 == \a x2)
- shaded line using the given \a painter. Note that nothing is
- drawn if \a y1 != \a y2 and \a x1 != \a x2 (i.e. the line is
- neither horizontal nor vertical).
-
- The provided \a palette specifies the shading colors (\l
- {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
- {QPalette::mid()}{middle} colors). The given \a lineWidth
- specifies the line width for each of the lines; it is not the
- total line width. The given \a midLineWidth specifies the width of
- a middle line drawn in the QPalette::mid() color.
-
- The line appears sunken if \a sunken is true, otherwise raised.
-
- \warning This function does not look at QWidget::style() or
- QApplication::style(). Use the drawing functions in QStyle to
- make widgets that follow the current GUI style.
-
-
- Alternatively you can use a QFrame widget and apply the
- QFrame::setFrameStyle() function to display a shaded line:
-
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 0
-
- \sa qDrawShadeRect(), qDrawShadePanel(), QStyle
-*/
-
-void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2,
- const QPalette &pal, bool sunken,
- int lineWidth, int midLineWidth)
-{
- if (!(p && lineWidth >= 0 && midLineWidth >= 0)) {
- qWarning("qDrawShadeLine: Invalid parameters");
- return;
- }
- int tlw = lineWidth*2 + midLineWidth; // total line width
- QPen oldPen = p->pen(); // save pen
- if (sunken)
- p->setPen(pal.color(QPalette::Dark));
- else
- p->setPen(pal.light().color());
- QPolygon a;
- int i;
- if (y1 == y2) { // horizontal line
- int y = y1 - tlw/2;
- if (x1 > x2) { // swap x1 and x2
- int t = x1;
- x1 = x2;
- x2 = t;
- }
- x2--;
- for (i=0; i<lineWidth; i++) { // draw top shadow
- a.setPoints(3, x1+i, y+tlw-1-i,
- x1+i, y+i,
- x2-i, y+i);
- p->drawPolyline(a);
- }
- if (midLineWidth > 0) {
- p->setPen(pal.mid().color());
- for (i=0; i<midLineWidth; i++) // draw lines in the middle
- p->drawLine(x1+lineWidth, y+lineWidth+i,
- x2-lineWidth, y+lineWidth+i);
- }
- if (sunken)
- p->setPen(pal.light().color());
- else
- p->setPen(pal.dark().color());
- for (i=0; i<lineWidth; i++) { // draw bottom shadow
- a.setPoints(3, x1+i, y+tlw-i-1,
- x2-i, y+tlw-i-1,
- x2-i, y+i+1);
- p->drawPolyline(a);
- }
- }
- else if (x1 == x2) { // vertical line
- int x = x1 - tlw/2;
- if (y1 > y2) { // swap y1 and y2
- int t = y1;
- y1 = y2;
- y2 = t;
- }
- y2--;
- for (i=0; i<lineWidth; i++) { // draw left shadow
- a.setPoints(3, x+i, y2,
- x+i, y1+i,
- x+tlw-1, y1+i);
- p->drawPolyline(a);
- }
- if (midLineWidth > 0) {
- p->setPen(pal.mid().color());
- for (i=0; i<midLineWidth; i++) // draw lines in the middle
- p->drawLine(x+lineWidth+i, y1+lineWidth, x+lineWidth+i, y2);
- }
- if (sunken)
- p->setPen(pal.light().color());
- else
- p->setPen(pal.dark().color());
- for (i=0; i<lineWidth; i++) { // draw right shadow
- a.setPoints(3, x+lineWidth, y2-i,
- x+tlw-i-1, y2-i,
- x+tlw-i-1, y1+lineWidth);
- p->drawPolyline(a);
- }
- }
- p->setPen(oldPen);
-}
-
-/*!
- \fn void qDrawShadeRect(QPainter *painter, int x, int y, int width, int height,
- const QPalette &palette, bool sunken,
- int lineWidth, int midLineWidth,
- const QBrush *fill)
- \relates <qdrawutil.h>
-
- Draws the shaded rectangle beginning at (\a x, \a y) with the
- given \a width and \a height using the provided \a painter.
-
- The provide \a palette specifies the shading colors (\l
- {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
- {QPalette::mid()}{middle} colors. The given \a lineWidth
- specifies the line width for each of the lines; it is not the
- total line width. The \a midLineWidth specifies the width of a
- middle line drawn in the QPalette::mid() color. The rectangle's
- interior is filled with the \a fill brush unless \a fill is 0.
-
- The rectangle appears sunken if \a sunken is true, otherwise
- raised.
-
- \warning This function does not look at QWidget::style() or
- QApplication::style(). Use the drawing functions in QStyle to make
- widgets that follow the current GUI style.
-
- Alternatively you can use a QFrame widget and apply the
- QFrame::setFrameStyle() function to display a shaded rectangle:
-
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 1
-
- \sa qDrawShadeLine(), qDrawShadePanel(), qDrawPlainRect(), QStyle
-*/
-
-void qDrawShadeRect(QPainter *p, int x, int y, int w, int h,
- const QPalette &pal, bool sunken,
- int lineWidth, int midLineWidth,
- const QBrush *fill)
-{
- if (w == 0 || h == 0)
- return;
- if (! (w > 0 && h > 0 && lineWidth >= 0 && midLineWidth >= 0)) {
- qWarning("qDrawShadeRect: Invalid parameters");
- return;
- }
- QPen oldPen = p->pen();
- if (sunken)
- p->setPen(pal.dark().color());
- else
- p->setPen(pal.light().color());
- int x1=x, y1=y, x2=x+w-1, y2=y+h-1;
-
- if (lineWidth == 1 && midLineWidth == 0) {// standard shade rectangle
- p->drawRect(x1, y1, w-2, h-2);
- if (sunken)
- p->setPen(pal.light().color());
- else
- p->setPen(pal.dark().color());
- QLineF lines[4] = { QLineF(x1+1, y1+1, x2-2, y1+1),
- QLineF(x1+1, y1+2, x1+1, y2-2),
- QLineF(x1, y2, x2, y2),
- QLineF(x2,y1, x2,y2-1) };
- p->drawLines(lines, 4); // draw bottom/right lines
- } else { // more complicated
- int m = lineWidth+midLineWidth;
- int i, j=0, k=m;
- for (i=0; i<lineWidth; i++) { // draw top shadow
- QLineF lines[4] = { QLineF(x1+i, y2-i, x1+i, y1+i),
- QLineF(x1+i, y1+i, x2-i, y1+i),
- QLineF(x1+k, y2-k, x2-k, y2-k),
- QLineF(x2-k, y2-k, x2-k, y1+k) };
- p->drawLines(lines, 4);
- k++;
- }
- p->setPen(pal.mid().color());
- j = lineWidth*2;
- for (i=0; i<midLineWidth; i++) { // draw lines in the middle
- p->drawRect(x1+lineWidth+i, y1+lineWidth+i, w-j-1, h-j-1);
- j += 2;
- }
- if (sunken)
- p->setPen(pal.light().color());
- else
- p->setPen(pal.dark().color());
- k = m;
- for (i=0; i<lineWidth; i++) { // draw bottom shadow
- QLineF lines[4] = { QLineF(x1+1+i, y2-i, x2-i, y2-i),
- QLineF(x2-i, y2-i, x2-i, y1+i+1),
- QLineF(x1+k, y2-k, x1+k, y1+k),
- QLineF(x1+k, y1+k, x2-k, y1+k) };
- p->drawLines(lines, 4);
- k++;
- }
- }
- if (fill) {
- QBrush oldBrush = p->brush();
- int tlw = lineWidth + midLineWidth;
- p->setPen(Qt::NoPen);
- p->setBrush(*fill);
- p->drawRect(x+tlw, y+tlw, w-2*tlw, h-2*tlw);
- p->setBrush(oldBrush);
- }
- p->setPen(oldPen); // restore pen
-}
-
-
-/*!
- \fn void qDrawShadePanel(QPainter *painter, int x, int y, int width, int height,
- const QPalette &palette, bool sunken,
- int lineWidth, const QBrush *fill)
- \relates <qdrawutil.h>
-
- Draws the shaded panel beginning at (\a x, \a y) with the given \a
- width and \a height using the provided \a painter and the given \a
- lineWidth.
-
- The given \a palette specifies the shading colors (\l
- {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
- {QPalette::mid()}{middle} colors). The panel's interior is filled
- with the \a fill brush unless \a fill is 0.
-
- The panel appears sunken if \a sunken is true, otherwise raised.
-
- \warning This function does not look at QWidget::style() or
- QApplication::style(). Use the drawing functions in QStyle to make
- widgets that follow the current GUI style.
-
- Alternatively you can use a QFrame widget and apply the
- QFrame::setFrameStyle() function to display a shaded panel:
-
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 2
-
- \sa qDrawWinPanel(), qDrawShadeLine(), qDrawShadeRect(), QStyle
-*/
-
-void qDrawShadePanel(QPainter *p, int x, int y, int w, int h,
- const QPalette &pal, bool sunken,
- int lineWidth, const QBrush *fill)
-{
- if (w == 0 || h == 0)
- return;
- if (!(w > 0 && h > 0 && lineWidth >= 0)) {
- qWarning("qDrawShadePanel: Invalid parameters");
- }
- QColor shade = pal.dark().color();
- QColor light = pal.light().color();
- if (fill) {
- if (fill->color() == shade)
- shade = pal.shadow().color();
- if (fill->color() == light)
- light = pal.midlight().color();
- }
- QPen oldPen = p->pen(); // save pen
- QVector<QLineF> lines;
- lines.reserve(2*lineWidth);
-
- if (sunken)
- p->setPen(shade);
- else
- p->setPen(light);
- int x1, y1, x2, y2;
- int i;
- x1 = x;
- y1 = y2 = y;
- x2 = x+w-2;
- for (i=0; i<lineWidth; i++) { // top shadow
- lines << QLineF(x1, y1++, x2--, y2++);
- }
- x2 = x1;
- y1 = y+h-2;
- for (i=0; i<lineWidth; i++) { // left shado
- lines << QLineF(x1++, y1, x2++, y2--);
- }
- p->drawLines(lines);
- lines.clear();
- if (sunken)
- p->setPen(light);
- else
- p->setPen(shade);
- x1 = x;
- y1 = y2 = y+h-1;
- x2 = x+w-1;
- for (i=0; i<lineWidth; i++) { // bottom shadow
- lines << QLineF(x1++, y1--, x2, y2--);
- }
- x1 = x2;
- y1 = y;
- y2 = y+h-lineWidth-1;
- for (i=0; i<lineWidth; i++) { // right shadow
- lines << QLineF(x1--, y1++, x2--, y2);
- }
- p->drawLines(lines);
- if (fill) // fill with fill color
- p->fillRect(x+lineWidth, y+lineWidth, w-lineWidth*2, h-lineWidth*2, *fill);
- p->setPen(oldPen); // restore pen
-}
-
-
-/*!
- \internal
- This function draws a rectangle with two pixel line width.
- It is called from qDrawWinButton() and qDrawWinPanel().
-
- c1..c4 and fill are used:
-
- 1 1 1 1 1 2
- 1 3 3 3 4 2
- 1 3 F F 4 2
- 1 3 F F 4 2
- 1 4 4 4 4 2
- 2 2 2 2 2 2
-*/
-
-static void qDrawWinShades(QPainter *p,
- int x, int y, int w, int h,
- const QColor &c1, const QColor &c2,
- const QColor &c3, const QColor &c4,
- const QBrush *fill)
-{
- if (w < 2 || h < 2) // can't do anything with that
- return;
- QPen oldPen = p->pen();
- QPoint a[3] = { QPoint(x, y+h-2), QPoint(x, y), QPoint(x+w-2, y) };
- p->setPen(c1);
- p->drawPolyline(a, 3);
- QPoint b[3] = { QPoint(x, y+h-1), QPoint(x+w-1, y+h-1), QPoint(x+w-1, y) };
- p->setPen(c2);
- p->drawPolyline(b, 3);
- if (w > 4 && h > 4) {
- QPoint c[3] = { QPoint(x+1, y+h-3), QPoint(x+1, y+1), QPoint(x+w-3, y+1) };
- p->setPen(c3);
- p->drawPolyline(c, 3);
- QPoint d[3] = { QPoint(x+1, y+h-2), QPoint(x+w-2, y+h-2), QPoint(x+w-2, y+1) };
- p->setPen(c4);
- p->drawPolyline(d, 3);
- if (fill)
- p->fillRect(QRect(x+2, y+2, w-4, h-4), *fill);
- }
- p->setPen(oldPen);
-}
-
-
-/*!
- \fn void qDrawWinButton(QPainter *painter, int x, int y, int width, int height,
- const QPalette &palette, bool sunken,
- const QBrush *fill)
- \relates <qdrawutil.h>
-
- Draws the Windows-style button specified by the given point (\a x,
- \a y}, \a width and \a height using the provided \a painter with a
- line width of 2 pixels. The button's interior is filled with the
- \a{fill} brush unless \a fill is 0.
-
- The given \a palette specifies the shading colors (\l
- {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
- {QPalette::mid()}{middle} colors).
-
- The button appears sunken if \a sunken is true, otherwise raised.
-
- \warning This function does not look at QWidget::style() or
- QApplication::style()-> Use the drawing functions in QStyle to make
- widgets that follow the current GUI style.
-
- \sa qDrawWinPanel(), QStyle
-*/
-
-void qDrawWinButton(QPainter *p, int x, int y, int w, int h,
- const QPalette &pal, bool sunken,
- const QBrush *fill)
-{
- if (sunken)
- qDrawWinShades(p, x, y, w, h,
- pal.shadow().color(), pal.light().color(), pal.dark().color(),
- pal.button().color(), fill);
- else
- qDrawWinShades(p, x, y, w, h,
- pal.light().color(), pal.shadow().color(), pal.button().color(),
- pal.dark().color(), fill);
-}
-
-/*!
- \fn void qDrawWinPanel(QPainter *painter, int x, int y, int width, int height,
- const QPalette &palette, bool sunken,
- const QBrush *fill)
- \relates <qdrawutil.h>
-
- Draws the Windows-style panel specified by the given point(\a x,
- \a y), \a width and \a height using the provided \a painter with a
- line width of 2 pixels. The button's interior is filled with the
- \a fill brush unless \a fill is 0.
-
- The given \a palette specifies the shading colors. The panel
- appears sunken if \a sunken is true, otherwise raised.
-
- \warning This function does not look at QWidget::style() or
- QApplication::style(). Use the drawing functions in QStyle to make
- widgets that follow the current GUI style.
-
- Alternatively you can use a QFrame widget and apply the
- QFrame::setFrameStyle() function to display a shaded panel:
-
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 3
-
- \sa qDrawShadePanel(), qDrawWinButton(), QStyle
-*/
-
-void qDrawWinPanel(QPainter *p, int x, int y, int w, int h,
- const QPalette &pal, bool sunken,
- const QBrush *fill)
-{
- if (sunken)
- qDrawWinShades(p, x, y, w, h,
- pal.dark().color(), pal.light().color(), pal.shadow().color(),
- pal.midlight().color(), fill);
- else
- qDrawWinShades(p, x, y, w, h,
- pal.light().color(), pal.shadow().color(), pal.midlight().color(),
- pal.dark().color(), fill);
-}
-
-/*!
- \fn void qDrawPlainRect(QPainter *painter, int x, int y, int width, int height, const QColor &lineColor,
- int lineWidth, const QBrush *fill)
- \relates <qdrawutil.h>
-
- Draws the plain rectangle beginning at (\a x, \a y) with the given
- \a width and \a height, using the specified \a painter, \a lineColor
- and \a lineWidth. The rectangle's interior is filled with the \a
- fill brush unless \a fill is 0.
-
- \warning This function does not look at QWidget::style() or
- QApplication::style(). Use the drawing functions in QStyle to make
- widgets that follow the current GUI style.
-
- Alternatively you can use a QFrame widget and apply the
- QFrame::setFrameStyle() function to display a plain rectangle:
-
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 4
-
- \sa qDrawShadeRect(), QStyle
-*/
-
-void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &c,
- int lineWidth, const QBrush *fill)
-{
- if (w == 0 || h == 0)
- return;
- if (!(w > 0 && h > 0 && lineWidth >= 0)) {
- qWarning("qDrawPlainRect: Invalid parameters");
- }
- QPen oldPen = p->pen();
- QBrush oldBrush = p->brush();
- p->setPen(c);
- p->setBrush(Qt::NoBrush);
- for (int i=0; i<lineWidth; i++)
- p->drawRect(x+i, y+i, w-i*2 - 1, h-i*2 - 1);
- if (fill) { // fill with fill color
- p->setPen(Qt::NoPen);
- p->setBrush(*fill);
- p->drawRect(x+lineWidth, y+lineWidth, w-lineWidth*2, h-lineWidth*2);
- }
- p->setPen(oldPen);
- p->setBrush(oldBrush);
-}
-
-/*****************************************************************************
- Overloaded functions.
- *****************************************************************************/
-
-/*!
- \fn void qDrawShadeLine(QPainter *painter, const QPoint &p1, const QPoint &p2,
- const QPalette &palette, bool sunken, int lineWidth, int midLineWidth)
- \relates <qdrawutil.h>
- \overload
-
- Draws a horizontal or vertical shaded line between \a p1 and \a p2
- using the given \a painter. Note that nothing is drawn if the line
- between the points would be neither horizontal nor vertical.
-
- The provided \a palette specifies the shading colors (\l
- {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
- {QPalette::mid()}{middle} colors). The given \a lineWidth
- specifies the line width for each of the lines; it is not the
- total line width. The given \a midLineWidth specifies the width of
- a middle line drawn in the QPalette::mid() color.
-
- The line appears sunken if \a sunken is true, otherwise raised.
-
- \warning This function does not look at QWidget::style() or
- QApplication::style(). Use the drawing functions in QStyle to
- make widgets that follow the current GUI style.
-
-
- Alternatively you can use a QFrame widget and apply the
- QFrame::setFrameStyle() function to display a shaded line:
-
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 5
-
- \sa qDrawShadeRect(), qDrawShadePanel(), QStyle
-*/
-
-void qDrawShadeLine(QPainter *p, const QPoint &p1, const QPoint &p2,
- const QPalette &pal, bool sunken,
- int lineWidth, int midLineWidth)
-{
- qDrawShadeLine(p, p1.x(), p1.y(), p2.x(), p2.y(), pal, sunken,
- lineWidth, midLineWidth);
-}
-
-/*!
- \fn void qDrawShadeRect(QPainter *painter, const QRect &rect, const QPalette &palette,
- bool sunken, int lineWidth, int midLineWidth, const QBrush *fill)
- \relates <qdrawutil.h>
- \overload
-
- Draws the shaded rectangle specified by \a rect using the given \a painter.
-
- The provide \a palette specifies the shading colors (\l
- {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
- {QPalette::mid()}{middle} colors. The given \a lineWidth
- specifies the line width for each of the lines; it is not the
- total line width. The \a midLineWidth specifies the width of a
- middle line drawn in the QPalette::mid() color. The rectangle's
- interior is filled with the \a fill brush unless \a fill is 0.
-
- The rectangle appears sunken if \a sunken is true, otherwise
- raised.
-
- \warning This function does not look at QWidget::style() or
- QApplication::style(). Use the drawing functions in QStyle to make
- widgets that follow the current GUI style.
-
- Alternatively you can use a QFrame widget and apply the
- QFrame::setFrameStyle() function to display a shaded rectangle:
-
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 6
-
- \sa qDrawShadeLine(), qDrawShadePanel(), qDrawPlainRect(), QStyle
-*/
-
-void qDrawShadeRect(QPainter *p, const QRect &r,
- const QPalette &pal, bool sunken,
- int lineWidth, int midLineWidth,
- const QBrush *fill)
-{
- qDrawShadeRect(p, r.x(), r.y(), r.width(), r.height(), pal, sunken,
- lineWidth, midLineWidth, fill);
-}
-
-/*!
- \fn void qDrawShadePanel(QPainter *painter, const QRect &rect, const QPalette &palette,
- bool sunken, int lineWidth, const QBrush *fill)
- \relates <qdrawutil.h>
- \overload
-
- Draws the shaded panel at the rectangle specified by \a rect using the
- given \a painter and the given \a lineWidth.
-
- The given \a palette specifies the shading colors (\l
- {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
- {QPalette::mid()}{middle} colors). The panel's interior is filled
- with the \a fill brush unless \a fill is 0.
-
- The panel appears sunken if \a sunken is true, otherwise raised.
-
- \warning This function does not look at QWidget::style() or
- QApplication::style(). Use the drawing functions in QStyle to make
- widgets that follow the current GUI style.
-
- Alternatively you can use a QFrame widget and apply the
- QFrame::setFrameStyle() function to display a shaded panel:
-
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 7
-
- \sa qDrawWinPanel(), qDrawShadeLine(), qDrawShadeRect(), QStyle
-*/
-
-void qDrawShadePanel(QPainter *p, const QRect &r,
- const QPalette &pal, bool sunken,
- int lineWidth, const QBrush *fill)
-{
- qDrawShadePanel(p, r.x(), r.y(), r.width(), r.height(), pal, sunken,
- lineWidth, fill);
-}
-
-/*!
- \fn void qDrawWinButton(QPainter *painter, const QRect &rect, const QPalette &palette,
- bool sunken, const QBrush *fill)
- \relates <qdrawutil.h>
- \overload
-
- Draws the Windows-style button at the rectangle specified by \a rect using
- the given \a painter with a line width of 2 pixels. The button's interior
- is filled with the \a{fill} brush unless \a fill is 0.
-
- The given \a palette specifies the shading colors (\l
- {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
- {QPalette::mid()}{middle} colors).
-
- The button appears sunken if \a sunken is true, otherwise raised.
-
- \warning This function does not look at QWidget::style() or
- QApplication::style()-> Use the drawing functions in QStyle to make
- widgets that follow the current GUI style.
-
- \sa qDrawWinPanel(), QStyle
-*/
-
-void qDrawWinButton(QPainter *p, const QRect &r,
- const QPalette &pal, bool sunken, const QBrush *fill)
-{
- qDrawWinButton(p, r.x(), r.y(), r.width(), r.height(), pal, sunken, fill);
-}
-
-/*!
- \fn void qDrawWinPanel(QPainter *painter, const QRect &rect, const QPalette &palette,
- bool sunken, const QBrush *fill)
- \overload
-
- Draws the Windows-style panel at the rectangle specified by \a rect using
- the given \a painter with a line width of 2 pixels. The button's interior
- is filled with the \a fill brush unless \a fill is 0.
-
- The given \a palette specifies the shading colors. The panel
- appears sunken if \a sunken is true, otherwise raised.
-
- \warning This function does not look at QWidget::style() or
- QApplication::style(). Use the drawing functions in QStyle to make
- widgets that follow the current GUI style.
-
- Alternatively you can use a QFrame widget and apply the
- QFrame::setFrameStyle() function to display a shaded panel:
-
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 8
-
- \sa qDrawShadePanel(), qDrawWinButton(), QStyle
-*/
-
-void qDrawWinPanel(QPainter *p, const QRect &r,
- const QPalette &pal, bool sunken, const QBrush *fill)
-{
- qDrawWinPanel(p, r.x(), r.y(), r.width(), r.height(), pal, sunken, fill);
-}
-
-/*!
- \fn void qDrawPlainRect(QPainter *painter, const QRect &rect, const QColor &lineColor, int lineWidth, const QBrush *fill)
- \relates <qdrawutil.h>
- \overload
-
- Draws the plain rectangle specified by \a rect using the given \a painter,
- \a lineColor and \a lineWidth. The rectangle's interior is filled with the
- \a fill brush unless \a fill is 0.
-
- \warning This function does not look at QWidget::style() or
- QApplication::style(). Use the drawing functions in QStyle to make
- widgets that follow the current GUI style.
-
- Alternatively you can use a QFrame widget and apply the
- QFrame::setFrameStyle() function to display a plain rectangle:
-
- \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 9
-
- \sa qDrawShadeRect(), QStyle
-*/
-
-void qDrawPlainRect(QPainter *p, const QRect &r, const QColor &c,
- int lineWidth, const QBrush *fill)
-{
- qDrawPlainRect(p, r.x(), r.y(), r.width(), r.height(), c,
- lineWidth, fill);
-}
-
-#ifdef QT3_SUPPORT
-static void qDrawWinArrow(QPainter *p, Qt::ArrowType type, bool down,
- int x, int y, int w, int h,
- const QPalette &pal, bool enabled)
-{
- QPolygon a; // arrow polygon
- switch (type) {
- case Qt::UpArrow:
- a.setPoints(7, -3,1, 3,1, -2,0, 2,0, -1,-1, 1,-1, 0,-2);
- break;
- case Qt::DownArrow:
- a.setPoints(7, -3,-1, 3,-1, -2,0, 2,0, -1,1, 1,1, 0,2);
- break;
- case Qt::LeftArrow:
- a.setPoints(7, 1,-3, 1,3, 0,-2, 0,2, -1,-1, -1,1, -2,0);
- break;
- case Qt::RightArrow:
- a.setPoints(7, -1,-3, -1,3, 0,-2, 0,2, 1,-1, 1,1, 2,0);
- break;
- default:
- break;
- }
- if (a.isEmpty())
- return;
-
- if (down) {
- x++;
- y++;
- }
-
- QPen savePen = p->pen(); // save current pen
- if (down)
- p->setBrushOrigin(p->brushOrigin() + QPoint(1,1));
- p->fillRect(x, y, w, h, pal.brush(QPalette::Button));
- if (down)
- p->setBrushOrigin(p->brushOrigin() - QPoint(1,1));
- if (enabled) {
- a.translate(x+w/2, y+h/2);
- p->setPen(pal.foreground().color());
- p->drawLine(a.at(0), a.at(1));
- p->drawLine(a.at(2), a.at(2));
- p->drawPoint(a[6]);
- } else {
- a.translate(x+w/2+1, y+h/2+1);
- p->setPen(pal.light().color());
- p->drawLine(a.at(0), a.at(1));
- p->drawLine(a.at(2), a.at(2));
- p->drawPoint(a[6]);
- a.translate(-1, -1);
- p->setPen(pal.mid().color());
- p->drawLine(a.at(0), a.at(1));
- p->drawLine(a.at(2), a.at(2));
- p->drawPoint(a[6]);
- }
- p->setPen(savePen); // restore pen
-}
-#endif // QT3_SUPPORT
-
-#if defined(Q_CC_MSVC)
-#pragma warning(disable: 4244)
-#endif
-
-#ifdef QT3_SUPPORT
-#ifndef QT_NO_STYLE_MOTIF
-// motif arrows look the same whether they are used or not
-// is this correct?
-static void qDrawMotifArrow(QPainter *p, Qt::ArrowType type, bool down,
- int x, int y, int w, int h,
- const QPalette &pal, bool)
-{
- QPolygon bFill; // fill polygon
- QPolygon bTop; // top shadow.
- QPolygon bBot; // bottom shadow.
- QPolygon bLeft; // left shadow.
- QTransform matrix; // xform matrix
- bool vertical = type == Qt::UpArrow || type == Qt::DownArrow;
- bool horizontal = !vertical;
- int dim = w < h ? w : h;
- int colspec = 0x0000; // color specification array
-
- if (dim < 2) // too small arrow
- return;
-
- if (dim > 3) {
- if (dim > 6)
- bFill.resize(dim & 1 ? 3 : 4);
- bTop.resize((dim/2)*2);
- bBot.resize(dim & 1 ? dim + 1 : dim);
- bLeft.resize(dim > 4 ? 4 : 2);
- bLeft.putPoints(0, 2, 0,0, 0,dim-1);
- if (dim > 4)
- bLeft.putPoints(2, 2, 1,2, 1,dim-3);
- bTop.putPoints(0, 4, 1,0, 1,1, 2,1, 3,1);
- bBot.putPoints(0, 4, 1,dim-1, 1,dim-2, 2,dim-2, 3,dim-2);
-
- for(int i=0; i<dim/2-2 ; i++) {
- bTop.putPoints(i*2+4, 2, 2+i*2,2+i, 5+i*2, 2+i);
- bBot.putPoints(i*2+4, 2, 2+i*2,dim-3-i, 5+i*2,dim-3-i);
- }
- if (dim & 1) // odd number size: extra line
- bBot.putPoints(dim-1, 2, dim-3,dim/2, dim-1,dim/2);
- if (dim > 6) { // dim>6: must fill interior
- bFill.putPoints(0, 2, 1,dim-3, 1,2);
- if (dim & 1) // if size is an odd number
- bFill.setPoint(2, dim - 3, dim / 2);
- else
- bFill.putPoints(2, 2, dim-4,dim/2-1, dim-4,dim/2);
- }
- }
- else {
- if (dim == 3) { // 3x3 arrow pattern
- bLeft.setPoints(4, 0,0, 0,2, 1,1, 1,1);
- bTop .setPoints(2, 1,0, 1,0);
- bBot .setPoints(2, 1,2, 2,1);
- }
- else { // 2x2 arrow pattern
- bLeft.setPoints(2, 0,0, 0,1);
- bTop .setPoints(2, 1,0, 1,0);
- bBot .setPoints(2, 1,1, 1,1);
- }
- }
-
- if (type == Qt::UpArrow || type == Qt::LeftArrow) {
- matrix.translate(x, y);
- if (vertical) {
- matrix.translate(0, h - 1);
- matrix.rotate(-90);
- } else {
- matrix.translate(w - 1, h - 1);
- matrix.rotate(180);
- }
- if (down)
- colspec = horizontal ? 0x2334 : 0x2343;
- else
- colspec = horizontal ? 0x1443 : 0x1434;
- }
- else if (type == Qt::DownArrow || type == Qt::RightArrow) {
- matrix.translate(x, y);
- if (vertical) {
- matrix.translate(w-1, 0);
- matrix.rotate(90);
- }
- if (down)
- colspec = horizontal ? 0x2443 : 0x2434;
- else
- colspec = horizontal ? 0x1334 : 0x1343;
- }
-
- const QColor *cols[5];
- cols[0] = 0;
- cols[1] = &pal.button().color();
- cols[2] = &pal.mid().color();
- cols[3] = &pal.light().color();
- cols[4] = &pal.dark().color();
-#define CMID *cols[(colspec>>12) & 0xf]
-#define CLEFT *cols[(colspec>>8) & 0xf]
-#define CTOP *cols[(colspec>>4) & 0xf]
-#define CBOT *cols[colspec & 0xf]
-
- QPen savePen = p->pen(); // save current pen
- QBrush saveBrush = p->brush(); // save current brush
- QTransform wxm = p->transform();
- QPen pen(Qt::NoPen);
- const QBrush &brush = pal.brush(QPalette::Button);
-
- p->setPen(pen);
- p->setBrush(brush);
- p->setTransform(matrix, true); // set transformation matrix
- p->drawPolygon(bFill); // fill arrow
- p->setBrush(Qt::NoBrush); // don't fill
-
- p->setPen(CLEFT);
- p->drawLines(bLeft);
- p->setPen(CTOP);
- p->drawLines(bTop);
- p->setPen(CBOT);
- p->drawLines(bBot);
-
- p->setTransform(wxm);
- p->setBrush(saveBrush); // restore brush
- p->setPen(savePen); // restore pen
-
-#undef CMID
-#undef CLEFT
-#undef CTOP
-#undef CBOT
-}
-#endif // QT_NO_STYLE_MOTIF
-
-QRect qItemRect(QPainter *p, Qt::GUIStyle gs,
- int x, int y, int w, int h,
- int flags,
- bool enabled,
- const QPixmap *pixmap,
- const QString& text, int len)
-{
- QRect result;
-
- if (pixmap) {
- if ((flags & Qt::AlignVCenter) == Qt::AlignVCenter)
- y += h/2 - pixmap->height()/2;
- else if ((flags & Qt::AlignBottom) == Qt::AlignBottom)
- y += h - pixmap->height();
- if ((flags & Qt::AlignRight) == Qt::AlignRight)
- x += w - pixmap->width();
- else if ((flags & Qt::AlignHCenter) == Qt::AlignHCenter)
- x += w/2 - pixmap->width()/2;
- else if ((flags & Qt::AlignLeft) != Qt::AlignLeft && QApplication::isRightToLeft())
- x += w - pixmap->width();
- result = QRect(x, y, pixmap->width(), pixmap->height());
- } else if (!text.isNull() && p) {
- result = p->boundingRect(QRect(x, y, w, h), flags, text.left(len));
- if (gs == Qt::WindowsStyle && !enabled) {
- result.setWidth(result.width()+1);
- result.setHeight(result.height()+1);
- }
- } else {
- result = QRect(x, y, w, h);
- }
-
- return result;
-}
-
-void qDrawArrow(QPainter *p, Qt::ArrowType type, Qt::GUIStyle style, bool down,
- int x, int y, int w, int h,
- const QPalette &pal, bool enabled)
-{
- switch (style) {
- case Qt::WindowsStyle:
- qDrawWinArrow(p, type, down, x, y, w, h, pal, enabled);
- break;
-#ifndef QT_NO_STYLE_MOTIF
- case Qt::MotifStyle:
- qDrawMotifArrow(p, type, down, x, y, w, h, pal, enabled);
- break;
-#endif
- default:
- qWarning("qDrawArrow: Requested unsupported GUI style");
- }
-}
-
-void qDrawItem(QPainter *p, Qt::GUIStyle gs,
- int x, int y, int w, int h,
- int flags,
- const QPalette &pal, bool enabled,
- const QPixmap *pixmap,
- const QString& text, int len , const QColor* penColor)
-{
- p->setPen(penColor?*penColor:pal.foreground().color());
- if (pixmap) {
- QPixmap pm(*pixmap);
- bool clip = (flags & Qt::TextDontClip) == 0;
- if (clip) {
- if (pm.width() < w && pm.height() < h)
- clip = false;
- else
- p->setClipRect(x, y, w, h);
- }
- if ((flags & Qt::AlignVCenter) == Qt::AlignVCenter)
- y += h/2 - pm.height()/2;
- else if ((flags & Qt::AlignBottom) == Qt::AlignBottom)
- y += h - pm.height();
- if ((flags & Qt::AlignRight) == Qt::AlignRight)
- x += w - pm.width();
- else if ((flags & Qt::AlignHCenter) == Qt::AlignHCenter)
- x += w/2 - pm.width()/2;
- else if (((flags & Qt::AlignLeft) != Qt::AlignLeft) && QApplication::isRightToLeft()) // Qt::AlignAuto && rightToLeft
- x += w - pm.width();
-
- if (!enabled) {
- if (pm.hasAlphaChannel()) { // pixmap with a mask
- pm = pm.mask();
- } else if (pm.depth() == 1) { // monochrome pixmap, no mask
- ;
-#ifndef QT_NO_IMAGE_HEURISTIC_MASK
- } else { // color pixmap, no mask
- QString k = QLatin1Literal("$qt-drawitem")
- % HexString<qint64>(pm.cacheKey());
-
- if (!QPixmapCache::find(k, pm)) {
- pm = pm.createHeuristicMask();
- pm.setMask((QBitmap&)pm);
- QPixmapCache::insert(k, pm);
- }
-#endif
- }
- if (gs == Qt::WindowsStyle) {
- p->setPen(pal.light().color());
- p->drawPixmap(x+1, y+1, pm);
- p->setPen(pal.text().color());
- }
- }
- p->drawPixmap(x, y, pm);
- if (clip)
- p->setClipping(false);
- } else if (!text.isNull()) {
- if (gs == Qt::WindowsStyle && !enabled) {
- p->setPen(pal.light().color());
- p->drawText(x+1, y+1, w, h, flags, text.left(len));
- p->setPen(pal.text().color());
- }
- p->drawText(x, y, w, h, flags, text.left(len));
- }
-}
-
-#endif
-
-/*!
- \class QTileRules
- \since 4.6
-
- Holds the rules used to draw a pixmap or image split into nine segments,
- similar to \l{http://www.w3.org/TR/css3-background/}{CSS3 border-images}.
-
- \sa Qt::TileRule, QMargins
-*/
-
-/*! \fn QTileRules::QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule)
- Constructs a QTileRules with the given \a horizontalRule and
- \a verticalRule.
- */
-
-/*! \fn QTileRules::QTileRules(Qt::TileRule rule)
- Constructs a QTileRules with the given \a rule used for both
- the horizontal rule and the vertical rule.
- */
-
-/*!
- \fn void qDrawBorderPixmap(QPainter *painter, const QRect &target, const QMargins &margins, const QPixmap &pixmap)
- \relates <qdrawutil.h>
- \since 4.6
- \overload
-
- \brief The qDrawBorderPixmap function is for drawing a pixmap into
- the margins of a rectangle.
-
- Draws the given \a pixmap into the given \a target rectangle, using the
- given \a painter. The pixmap will be split into nine segments and drawn
- according to the \a margins structure.
-*/
-
-typedef QVarLengthArray<QPainter::PixmapFragment, 16> QPixmapFragmentsArray;
-
-/*!
- \since 4.6
-
- Draws the indicated \a sourceRect rectangle from the given \a pixmap into
- the given \a targetRect rectangle, using the given \a painter. The pixmap
- will be split into nine segments according to the given \a targetMargins
- and \a sourceMargins structures. Finally, the pixmap will be drawn
- according to the given \a rules.
-
- This function is used to draw a scaled pixmap, similar to
- \l{http://www.w3.org/TR/css3-background/}{CSS3 border-images}
-
- \sa Qt::TileRule, QTileRules, QMargins
-*/
-
-void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargins &targetMargins,
- const QPixmap &pixmap, const QRect &sourceRect,const QMargins &sourceMargins,
- const QTileRules &rules, QDrawBorderPixmap::DrawingHints hints)
-{
- QPainter::PixmapFragment d;
- d.opacity = 1.0;
- d.rotation = 0.0;
-
- QPixmapFragmentsArray opaqueData;
- QPixmapFragmentsArray translucentData;
-
- // source center
- const int sourceCenterTop = sourceRect.top() + sourceMargins.top();
- const int sourceCenterLeft = sourceRect.left() + sourceMargins.left();
- const int sourceCenterBottom = sourceRect.bottom() - sourceMargins.bottom() + 1;
- const int sourceCenterRight = sourceRect.right() - sourceMargins.right() + 1;
- const int sourceCenterWidth = sourceCenterRight - sourceCenterLeft;
- const int sourceCenterHeight = sourceCenterBottom - sourceCenterTop;
- // target center
- const int targetCenterTop = targetRect.top() + targetMargins.top();
- const int targetCenterLeft = targetRect.left() + targetMargins.left();
- const int targetCenterBottom = targetRect.bottom() - targetMargins.bottom() + 1;
- const int targetCenterRight = targetRect.right() - targetMargins.right() + 1;
- const int targetCenterWidth = targetCenterRight - targetCenterLeft;
- const int targetCenterHeight = targetCenterBottom - targetCenterTop;
-
- QVarLengthArray<qreal, 16> xTarget; // x-coordinates of target rectangles
- QVarLengthArray<qreal, 16> yTarget; // y-coordinates of target rectangles
-
- int columns = 3;
- int rows = 3;
- if (rules.horizontal != Qt::StretchTile && sourceCenterWidth != 0)
- columns = qMax(3, 2 + qCeil(targetCenterWidth / qreal(sourceCenterWidth)));
- if (rules.vertical != Qt::StretchTile && sourceCenterHeight != 0)
- rows = qMax(3, 2 + qCeil(targetCenterHeight / qreal(sourceCenterHeight)));
-
- xTarget.resize(columns + 1);
- yTarget.resize(rows + 1);
-
- bool oldAA = painter->testRenderHint(QPainter::Antialiasing);
- if (painter->paintEngine()->type() != QPaintEngine::OpenGL
- && painter->paintEngine()->type() != QPaintEngine::OpenGL2
- && oldAA && painter->combinedTransform().type() != QTransform::TxNone) {
- painter->setRenderHint(QPainter::Antialiasing, false);
- }
-
- xTarget[0] = targetRect.left();
- xTarget[1] = targetCenterLeft;
- xTarget[columns - 1] = targetCenterRight;
- xTarget[columns] = targetRect.left() + targetRect.width();
-
- yTarget[0] = targetRect.top();
- yTarget[1] = targetCenterTop;
- yTarget[rows - 1] = targetCenterBottom;
- yTarget[rows] = targetRect.top() + targetRect.height();
-
- qreal dx = targetCenterWidth;
- qreal dy = targetCenterHeight;
-
- switch (rules.horizontal) {
- case Qt::StretchTile:
- dx = targetCenterWidth;
- break;
- case Qt::RepeatTile:
- dx = sourceCenterWidth;
- break;
- case Qt::RoundTile:
- dx = targetCenterWidth / qreal(columns - 2);
- break;
- }
-
- for (int i = 2; i < columns - 1; ++i)
- xTarget[i] = xTarget[i - 1] + dx;
-
- switch (rules.vertical) {
- case Qt::StretchTile:
- dy = targetCenterHeight;
- break;
- case Qt::RepeatTile:
- dy = sourceCenterHeight;
- break;
- case Qt::RoundTile:
- dy = targetCenterHeight / qreal(rows - 2);
- break;
- }
-
- for (int i = 2; i < rows - 1; ++i)
- yTarget[i] = yTarget[i - 1] + dy;
-
- // corners
- if (targetMargins.top() > 0 && targetMargins.left() > 0 && sourceMargins.top() > 0 && sourceMargins.left() > 0) { // top left
- d.x = (0.5 * (xTarget[1] + xTarget[0]));
- d.y = (0.5 * (yTarget[1] + yTarget[0]));
- d.sourceLeft = sourceRect.left();
- d.sourceTop = sourceRect.top();
- d.width = sourceMargins.left();
- d.height = sourceMargins.top();
- d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width;
- d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height;
- if (hints & QDrawBorderPixmap::OpaqueTopLeft)
- opaqueData.append(d);
- else
- translucentData.append(d);
- }
- if (targetMargins.top() > 0 && targetMargins.right() > 0 && sourceMargins.top() > 0 && sourceMargins.right() > 0) { // top right
- d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
- d.y = (0.5 * (yTarget[1] + yTarget[0]));
- d.sourceLeft = sourceCenterRight;
- d.sourceTop = sourceRect.top();
- d.width = sourceMargins.right();
- d.height = sourceMargins.top();
- d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width;
- d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height;
- if (hints & QDrawBorderPixmap::OpaqueTopRight)
- opaqueData.append(d);
- else
- translucentData.append(d);
- }
- if (targetMargins.bottom() > 0 && targetMargins.left() > 0 && sourceMargins.bottom() > 0 && sourceMargins.left() > 0) { // bottom left
- d.x = (0.5 * (xTarget[1] + xTarget[0]));
- d.y =(0.5 * (yTarget[rows] + yTarget[rows - 1]));
- d.sourceLeft = sourceRect.left();
- d.sourceTop = sourceCenterBottom;
- d.width = sourceMargins.left();
- d.height = sourceMargins.bottom();
- d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width;
- d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height;
- if (hints & QDrawBorderPixmap::OpaqueBottomLeft)
- opaqueData.append(d);
- else
- translucentData.append(d);
- }
- if (targetMargins.bottom() > 0 && targetMargins.right() > 0 && sourceMargins.bottom() > 0 && sourceMargins.right() > 0) { // bottom right
- d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
- d.y = (0.5 * (yTarget[rows] + yTarget[rows - 1]));
- d.sourceLeft = sourceCenterRight;
- d.sourceTop = sourceCenterBottom;
- d.width = sourceMargins.right();
- d.height = sourceMargins.bottom();
- d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width;
- d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height;
- if (hints & QDrawBorderPixmap::OpaqueBottomRight)
- opaqueData.append(d);
- else
- translucentData.append(d);
- }
-
- // horizontal edges
- if (targetCenterWidth > 0 && sourceCenterWidth > 0) {
- if (targetMargins.top() > 0 && sourceMargins.top() > 0) { // top
- QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueTop ? opaqueData : translucentData;
- d.sourceLeft = sourceCenterLeft;
- d.sourceTop = sourceRect.top();
- d.width = sourceCenterWidth;
- d.height = sourceMargins.top();
- d.y = (0.5 * (yTarget[1] + yTarget[0]));
- d.scaleX = dx / d.width;
- d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height;
- for (int i = 1; i < columns - 1; ++i) {
- d.x = (0.5 * (xTarget[i + 1] + xTarget[i]));
- data.append(d);
- }
- if (rules.horizontal == Qt::RepeatTile)
- data[data.size() - 1].width = ((xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX);
- }
- if (targetMargins.bottom() > 0 && sourceMargins.bottom() > 0) { // bottom
- QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueBottom ? opaqueData : translucentData;
- d.sourceLeft = sourceCenterLeft;
- d.sourceTop = sourceCenterBottom;
- d.width = sourceCenterWidth;
- d.height = sourceMargins.bottom();
- d.y = (0.5 * (yTarget[rows] + yTarget[rows - 1]));
- d.scaleX = dx / d.width;
- d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height;
- for (int i = 1; i < columns - 1; ++i) {
- d.x = (0.5 * (xTarget[i + 1] + xTarget[i]));
- data.append(d);
- }
- if (rules.horizontal == Qt::RepeatTile)
- data[data.size() - 1].width = ((xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX);
- }
- }
-
- // vertical edges
- if (targetCenterHeight > 0 && sourceCenterHeight > 0) {
- if (targetMargins.left() > 0 && sourceMargins.left() > 0) { // left
- QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueLeft ? opaqueData : translucentData;
- d.sourceLeft = sourceRect.left();
- d.sourceTop = sourceCenterTop;
- d.width = sourceMargins.left();
- d.height = sourceCenterHeight;
- d.x = (0.5 * (xTarget[1] + xTarget[0]));
- d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width;
- d.scaleY = dy / d.height;
- for (int i = 1; i < rows - 1; ++i) {
- d.y = (0.5 * (yTarget[i + 1] + yTarget[i]));
- data.append(d);
- }
- if (rules.vertical == Qt::RepeatTile)
- data[data.size() - 1].height = ((yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY);
- }
- if (targetMargins.right() > 0 && sourceMargins.right() > 0) { // right
- QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueRight ? opaqueData : translucentData;
- d.sourceLeft = sourceCenterRight;
- d.sourceTop = sourceCenterTop;
- d.width = sourceMargins.right();
- d.height = sourceCenterHeight;
- d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
- d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width;
- d.scaleY = dy / d.height;
- for (int i = 1; i < rows - 1; ++i) {
- d.y = (0.5 * (yTarget[i + 1] + yTarget[i]));
- data.append(d);
- }
- if (rules.vertical == Qt::RepeatTile)
- data[data.size() - 1].height = ((yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY);
- }
- }
-
- // center
- if (targetCenterWidth > 0 && targetCenterHeight > 0 && sourceCenterWidth > 0 && sourceCenterHeight > 0) {
- QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueCenter ? opaqueData : translucentData;
- d.sourceLeft = sourceCenterLeft;
- d.sourceTop = sourceCenterTop;
- d.width = sourceCenterWidth;
- d.height = sourceCenterHeight;
- d.scaleX = dx / d.width;
- d.scaleY = dy / d.height;
-
- qreal repeatWidth = (xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX;
- qreal repeatHeight = (yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY;
-
- for (int j = 1; j < rows - 1; ++j) {
- d.y = (0.5 * (yTarget[j + 1] + yTarget[j]));
- for (int i = 1; i < columns - 1; ++i) {
- d.x = (0.5 * (xTarget[i + 1] + xTarget[i]));
- data.append(d);
- }
- if (rules.horizontal == Qt::RepeatTile)
- data[data.size() - 1].width = repeatWidth;
- }
- if (rules.vertical == Qt::RepeatTile) {
- for (int i = 1; i < columns - 1; ++i)
- data[data.size() - i].height = repeatHeight;
- }
- }
-
- if (opaqueData.size())
- painter->drawPixmapFragments(opaqueData.data(), opaqueData.size(), pixmap, QPainter::OpaqueHint);
- if (translucentData.size())
- painter->drawPixmapFragments(translucentData.data(), translucentData.size(), pixmap);
-
- if (oldAA)
- painter->setRenderHint(QPainter::Antialiasing, true);
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qdrawutil.h b/src/gui/painting/qdrawutil.h
deleted file mode 100644
index 20b558d411..0000000000
--- a/src/gui/painting/qdrawutil.h
+++ /dev/null
@@ -1,195 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDRAWUTIL_H
-#define QDRAWUTIL_H
-
-#include <QtCore/qnamespace.h>
-#include <QtCore/qstring.h> // char*->QString conversion
-#include <QtCore/qmargins.h>
-#include <QtGui/qpixmap.h>
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QPainter;
-#ifndef QT3_SUPPORT
-class QColorGroup;
-#endif
-class QPalette;
-class QPoint;
-class QColor;
-class QBrush;
-class QRect;
-
-//
-// Standard shade drawing
-//
-
-Q_GUI_EXPORT void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2,
- const QPalette &pal, bool sunken = true,
- int lineWidth = 1, int midLineWidth = 0);
-
-Q_GUI_EXPORT void qDrawShadeLine(QPainter *p, const QPoint &p1, const QPoint &p2,
- const QPalette &pal, bool sunken = true,
- int lineWidth = 1, int midLineWidth = 0);
-
-Q_GUI_EXPORT void qDrawShadeRect(QPainter *p, int x, int y, int w, int h,
- const QPalette &pal, bool sunken = false,
- int lineWidth = 1, int midLineWidth = 0,
- const QBrush *fill = 0);
-
-Q_GUI_EXPORT void qDrawShadeRect(QPainter *p, const QRect &r,
- const QPalette &pal, bool sunken = false,
- int lineWidth = 1, int midLineWidth = 0,
- const QBrush *fill = 0);
-
-Q_GUI_EXPORT void qDrawShadePanel(QPainter *p, int x, int y, int w, int h,
- const QPalette &pal, bool sunken = false,
- int lineWidth = 1, const QBrush *fill = 0);
-
-Q_GUI_EXPORT void qDrawShadePanel(QPainter *p, const QRect &r,
- const QPalette &pal, bool sunken = false,
- int lineWidth = 1, const QBrush *fill = 0);
-
-Q_GUI_EXPORT void qDrawWinButton(QPainter *p, int x, int y, int w, int h,
- const QPalette &pal, bool sunken = false,
- const QBrush *fill = 0);
-
-Q_GUI_EXPORT void qDrawWinButton(QPainter *p, const QRect &r,
- const QPalette &pal, bool sunken = false,
- const QBrush *fill = 0);
-
-Q_GUI_EXPORT void qDrawWinPanel(QPainter *p, int x, int y, int w, int h,
- const QPalette &pal, bool sunken = false,
- const QBrush *fill = 0);
-
-Q_GUI_EXPORT void qDrawWinPanel(QPainter *p, const QRect &r,
- const QPalette &pal, bool sunken = false,
- const QBrush *fill = 0);
-
-Q_GUI_EXPORT void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &,
- int lineWidth = 1, const QBrush *fill = 0);
-
-Q_GUI_EXPORT void qDrawPlainRect(QPainter *p, const QRect &r, const QColor &,
- int lineWidth = 1, const QBrush *fill = 0);
-
-
-#ifdef QT3_SUPPORT
-//
-// Use QStyle::itemRect(), QStyle::drawItem() and QStyle::drawArrow() instead.
-//
-Q_GUI_EXPORT QT3_SUPPORT QRect qItemRect(QPainter *p, Qt::GUIStyle gs, int x, int y, int w, int h,
- int flags, bool enabled,
- const QPixmap *pixmap, const QString& text, int len=-1);
-
-Q_GUI_EXPORT QT3_SUPPORT void qDrawItem(QPainter *p, Qt::GUIStyle gs, int x, int y, int w, int h,
- int flags, const QPalette &pal, bool enabled,
- const QPixmap *pixmap, const QString& text,
- int len=-1, const QColor* penColor = 0);
-
-Q_GUI_EXPORT QT3_SUPPORT void qDrawArrow(QPainter *p, Qt::ArrowType type, Qt::GUIStyle style, bool down,
- int x, int y, int w, int h,
- const QPalette &pal, bool enabled);
-#endif
-
-struct QTileRules
-{
- inline QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule)
- : horizontal(horizontalRule), vertical(verticalRule) {}
- inline QTileRules(Qt::TileRule rule = Qt::StretchTile)
- : horizontal(rule), vertical(rule) {}
- Qt::TileRule horizontal;
- Qt::TileRule vertical;
-};
-
-#ifndef Q_QDOC
-// For internal use only.
-namespace QDrawBorderPixmap
-{
- enum DrawingHint
- {
- OpaqueTopLeft = 0x0001,
- OpaqueTop = 0x0002,
- OpaqueTopRight = 0x0004,
- OpaqueLeft = 0x0008,
- OpaqueCenter = 0x0010,
- OpaqueRight = 0x0020,
- OpaqueBottomLeft = 0x0040,
- OpaqueBottom = 0x0080,
- OpaqueBottomRight = 0x0100,
- OpaqueCorners = OpaqueTopLeft | OpaqueTopRight | OpaqueBottomLeft | OpaqueBottomRight,
- OpaqueEdges = OpaqueTop | OpaqueLeft | OpaqueRight | OpaqueBottom,
- OpaqueFrame = OpaqueCorners | OpaqueEdges,
- OpaqueAll = OpaqueCenter | OpaqueFrame
- };
-
- Q_DECLARE_FLAGS(DrawingHints, DrawingHint)
-}
-#endif
-
-Q_GUI_EXPORT void qDrawBorderPixmap(QPainter *painter,
- const QRect &targetRect,
- const QMargins &targetMargins,
- const QPixmap &pixmap,
- const QRect &sourceRect,
- const QMargins &sourceMargins,
- const QTileRules &rules = QTileRules()
-#ifndef Q_QDOC
- , QDrawBorderPixmap::DrawingHints hints = 0
-#endif
- );
-
-inline void qDrawBorderPixmap(QPainter *painter,
- const QRect &target,
- const QMargins &margins,
- const QPixmap &pixmap)
-{
- qDrawBorderPixmap(painter, target, margins, pixmap, pixmap.rect(), margins);
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDRAWUTIL_H
diff --git a/src/gui/painting/qgraphicssystem.cpp b/src/gui/painting/qgraphicssystem.cpp
deleted file mode 100644
index 171ef46f98..0000000000
--- a/src/gui/painting/qgraphicssystem.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgraphicssystem_p.h"
-
-#ifdef Q_WS_X11
-# include <private/qpixmap_x11_p.h>
-#endif
-#if defined(Q_WS_WIN)
-# include <private/qpixmap_raster_p.h>
-#endif
-#ifdef Q_WS_MAC
-# include <private/qpixmap_mac_p.h>
-#endif
-#ifdef Q_WS_QPA
-# include <QtGui/private/qapplication_p.h>
-#endif
-#ifdef Q_OS_SYMBIAN
-# include <private/qpixmap_s60_p.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-QGraphicsSystem::~QGraphicsSystem()
-{
-}
-
-QPixmapData *QGraphicsSystem::createDefaultPixmapData(QPixmapData::PixelType type)
-{
-#ifdef Q_WS_QWS
- Q_UNUSED(type);
-#endif
-#if defined(Q_WS_X11)
- return new QX11PixmapData(type);
-#elif defined(Q_WS_WIN)
- return new QRasterPixmapData(type);
-#elif defined(Q_WS_MAC)
- return new QMacPixmapData(type);
-#elif defined(Q_WS_QPA)
- return QApplicationPrivate::platformIntegration()->createPixmapData(type);
-#elif defined(Q_OS_SYMBIAN)
- return new QS60PixmapData(type);
-#elif !defined(Q_WS_QWS)
-#error QGraphicsSystem::createDefaultPixmapData() not implemented
-#endif
- return 0;
-}
-
-QPixmapData *QGraphicsSystem::createPixmapData(QPixmapData *origin)
-{
- return createPixmapData(origin->pixelType());
-}
-
-void QGraphicsSystem::releaseCachedResources()
-{
- // Do nothing here
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qgraphicssystem_mac.cpp b/src/gui/painting/qgraphicssystem_mac.cpp
deleted file mode 100644
index 4f0be1f86a..0000000000
--- a/src/gui/painting/qgraphicssystem_mac.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgraphicssystem_mac_p.h"
-
-#include <private/qpixmap_mac_p.h>
-#include <private/qwindowsurface_mac_p.h>
-
-QT_BEGIN_NAMESPACE
-
-QPixmapData *QCoreGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const
-{
- return new QMacPixmapData(type);
-}
-
-QWindowSurface *QCoreGraphicsSystem::createWindowSurface(QWidget *widget) const
-{
- return new QMacWindowSurface(widget);
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qgraphicssystem_mac_p.h b/src/gui/painting/qgraphicssystem_mac_p.h
deleted file mode 100644
index 4d2eae84d7..0000000000
--- a/src/gui/painting/qgraphicssystem_mac_p.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSSYSTEM_MAC_P_H
-#define QGRAPHICSSYSTEM_MAC_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "private/qgraphicssystem_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class Q_GUI_EXPORT QCoreGraphicsSystem : public QGraphicsSystem
-{
-public:
- QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
- QWindowSurface *createWindowSurface(QWidget *widget) const;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/gui/painting/qgraphicssystem_p.h b/src/gui/painting/qgraphicssystem_p.h
deleted file mode 100644
index 0f99a311a6..0000000000
--- a/src/gui/painting/qgraphicssystem_p.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSSYSTEM_P_H
-#define QGRAPHICSSYSTEM_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "private/qpixmapdata_p.h"
-#include "private/qwindowsurface_p.h"
-#include "private/qpaintengine_blitter_p.h"
-
-#include <qdebug.h>
-
-QT_BEGIN_NAMESPACE
-
-class QPixmapFilter;
-class QBlittable;
-
-class Q_GUI_EXPORT QGraphicsSystem
-{
-public:
- virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const = 0;
- virtual QPixmapData *createPixmapData(QPixmapData *origin);
- virtual QWindowSurface *createWindowSurface(QWidget *widget) const = 0;
-
- virtual ~QGraphicsSystem();
-
- //### Remove this & change qpixmap.cpp & qbitmap.cpp once every platform is gaurenteed
- // to have a graphics system.
- static QPixmapData *createDefaultPixmapData(QPixmapData::PixelType type);
-
- virtual void releaseCachedResources();
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/gui/painting/qgraphicssystem_qws.cpp b/src/gui/painting/qgraphicssystem_qws.cpp
deleted file mode 100644
index 40f9ad4839..0000000000
--- a/src/gui/painting/qgraphicssystem_qws.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qscreen_qws.h>
-#include "qgraphicssystem_qws_p.h"
-#include <private/qpixmap_raster_p.h>
-#include <private/qwindowsurface_qws_p.h>
-
-QT_BEGIN_NAMESPACE
-
-QPixmapData *QWSGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const
-{
- if (screen->pixmapDataFactory())
- return screen->pixmapDataFactory()->create(type); //### For 4.4 compatibility
- else
- return new QRasterPixmapData(type);
-}
-
-QWindowSurface *QWSGraphicsSystem::createWindowSurface(QWidget *widget) const
-{
- return screen->createSurface(widget);
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qgraphicssystem_qws_p.h b/src/gui/painting/qgraphicssystem_qws_p.h
deleted file mode 100644
index 92b92628cd..0000000000
--- a/src/gui/painting/qgraphicssystem_qws_p.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSSYSTEM_QWS_P_H
-#define QGRAPHICSSYSTEM_QWS_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qgraphicssystem_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class Q_GUI_EXPORT QWSGraphicsSystem : public QGraphicsSystem
-{
-public:
-
- QWSGraphicsSystem()
- : screen(QScreen::instance()) {}
-
- QWSGraphicsSystem(QScreen* s)
- : screen(s) {}
-
- virtual QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
- QWindowSurface *createWindowSurface(QWidget *widget) const;
-
-private:
- QScreen* screen;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/gui/painting/qgraphicssystem_raster.cpp b/src/gui/painting/qgraphicssystem_raster.cpp
deleted file mode 100644
index 69bf588292..0000000000
--- a/src/gui/painting/qgraphicssystem_raster.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgraphicssystem_raster_p.h"
-
-#ifdef Q_OS_SYMBIAN
-#include "private/qpixmap_s60_p.h"
-#include "private/qwindowsurface_s60_p.h"
-#else
-#include "private/qpixmap_raster_p.h"
-#include "private/qwindowsurface_raster_p.h"
-#endif
-
-QT_BEGIN_NAMESPACE
-
-QPixmapData *QRasterGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const
-{
-#ifdef Q_OS_SYMBIAN
- return new QS60PixmapData(type);
-#else
- return new QRasterPixmapData(type);
-#endif
-}
-
-QWindowSurface *QRasterGraphicsSystem::createWindowSurface(QWidget *widget) const
-{
-#ifdef Q_OS_SYMBIAN
- return new QS60WindowSurface(widget);
-#else
- return new QRasterWindowSurface(widget);
-#endif
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qgraphicssystem_raster_p.h b/src/gui/painting/qgraphicssystem_raster_p.h
deleted file mode 100644
index a66c56903f..0000000000
--- a/src/gui/painting/qgraphicssystem_raster_p.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSSYSTEM_RASTER_P_H
-#define QGRAPHICSSYSTEM_RASTER_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qgraphicssystem_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QRasterGraphicsSystem : public QGraphicsSystem
-{
-public:
- QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
- QWindowSurface *createWindowSurface(QWidget *widget) const;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/gui/painting/qgraphicssystem_runtime.cpp b/src/gui/painting/qgraphicssystem_runtime.cpp
deleted file mode 100644
index d1dd7ef392..0000000000
--- a/src/gui/painting/qgraphicssystem_runtime.cpp
+++ /dev/null
@@ -1,426 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <private/qgraphicssystem_runtime_p.h>
-#include <private/qgraphicssystem_raster_p.h>
-#include <private/qgraphicssystemfactory_p.h>
-#include <private/qapplication_p.h>
-#include <private/qwidget_p.h>
-#include <QtCore/QDebug>
-#include <QtCore/QTimer>
-#include <QtGui/QBitmap>
-
-QT_BEGIN_NAMESPACE
-
-static int qt_pixmap_serial = 0;
-
-#define READBACK(f) \
- f \
- readBackInfo();
-
-
-class QDeferredGraphicsSystemChange : public QObject
-{
- Q_OBJECT
-
-public:
- QDeferredGraphicsSystemChange(QRuntimeGraphicsSystem *gs, const QString& graphicsSystemName)
- : m_graphicsSystem(gs), m_graphicsSystemName(graphicsSystemName)
- {
- }
-
- void launch()
- {
- QTimer::singleShot(0, this, SLOT(doChange()));
- }
-
-private slots:
-
- void doChange()
- {
- m_graphicsSystem->setGraphicsSystem(m_graphicsSystemName);
- deleteLater();
- }
-
-private:
-
- QRuntimeGraphicsSystem *m_graphicsSystem;
- QString m_graphicsSystemName;
-};
-
-QRuntimePixmapData::QRuntimePixmapData(const QRuntimeGraphicsSystem *gs, PixelType type)
- : QPixmapData(type, RuntimeClass), m_graphicsSystem(gs)
-{
- setSerialNumber(++qt_pixmap_serial);
-}
-
-QRuntimePixmapData::~QRuntimePixmapData()
-{
- if (QApplicationPrivate::graphics_system)
- m_graphicsSystem->removePixmapData(this);
- delete m_data;
-}
-
-void QRuntimePixmapData::readBackInfo()
-{
- w = m_data->width();
- h = m_data->height();
- d = m_data->depth();
- is_null = m_data->isNull();
-}
-
-
-QPixmapData *QRuntimePixmapData::createCompatiblePixmapData() const
-{
- QRuntimePixmapData *rtData = new QRuntimePixmapData(m_graphicsSystem, pixelType());
- rtData->m_data = m_data->createCompatiblePixmapData();
- return rtData;
-}
-
-
-void QRuntimePixmapData::resize(int width, int height)
-{
- READBACK(
- m_data->resize(width, height);
- )
-}
-
-
-void QRuntimePixmapData::fromImage(const QImage &image,
- Qt::ImageConversionFlags flags)
-{
- READBACK(
- m_data->fromImage(image, flags);
- )
-}
-
-
-bool QRuntimePixmapData::fromFile(const QString &filename, const char *format,
- Qt::ImageConversionFlags flags)
-{
- bool success(false);
- READBACK(
- success = m_data->fromFile(filename, format, flags);
- )
- return success;
-}
-
-bool QRuntimePixmapData::fromData(const uchar *buffer, uint len, const char *format,
- Qt::ImageConversionFlags flags)
-{
- bool success(false);
- READBACK(
- success = m_data->fromData(buffer, len, format, flags);
- )
- return success;
-}
-
-
-void QRuntimePixmapData::copy(const QPixmapData *data, const QRect &rect)
-{
- if (data->runtimeData()) {
- READBACK(
- m_data->copy(data->runtimeData(), rect);
- )
- } else {
- READBACK(
- m_data->copy(data, rect);
- )
- }
-}
-
-bool QRuntimePixmapData::scroll(int dx, int dy, const QRect &rect)
-{
- return m_data->scroll(dx, dy, rect);
-}
-
-
-int QRuntimePixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const
-{
- return m_data->metric(metric);
-}
-
-void QRuntimePixmapData::fill(const QColor &color)
-{
- return m_data->fill(color);
-}
-
-QBitmap QRuntimePixmapData::mask() const
-{
- return m_data->mask();
-}
-
-void QRuntimePixmapData::setMask(const QBitmap &mask)
-{
- READBACK(
- m_data->setMask(mask);
- )
-}
-
-bool QRuntimePixmapData::hasAlphaChannel() const
-{
- return m_data->hasAlphaChannel();
-}
-
-QPixmap QRuntimePixmapData::transformed(const QTransform &matrix,
- Qt::TransformationMode mode) const
-{
- return m_data->transformed(matrix, mode);
-}
-
-void QRuntimePixmapData::setAlphaChannel(const QPixmap &alphaChannel)
-{
- READBACK(
- m_data->setAlphaChannel(alphaChannel);
- )
-}
-
-QPixmap QRuntimePixmapData::alphaChannel() const
-{
- return m_data->alphaChannel();
-}
-
-QImage QRuntimePixmapData::toImage() const
-{
- return m_data->toImage();
-}
-
-QPaintEngine* QRuntimePixmapData::paintEngine() const
-{
- return m_data->paintEngine();
-}
-
-QImage* QRuntimePixmapData::buffer()
-{
- return m_data->buffer();
-}
-
-#if defined(Q_OS_SYMBIAN)
-void* QRuntimePixmapData::toNativeType(NativeType type)
-{
- return m_data->toNativeType(type);
-}
-
-void QRuntimePixmapData::fromNativeType(void *pixmap, NativeType type)
-{
- m_data->fromNativeType(pixmap, type);
- readBackInfo();
-}
-#endif
-
-QPixmapData* QRuntimePixmapData::runtimeData() const
-{
- return m_data;
-}
-
-QRuntimeWindowSurface::QRuntimeWindowSurface(const QRuntimeGraphicsSystem *gs, QWidget *window)
- : QWindowSurface(window), m_graphicsSystem(gs)
-{
-
-}
-
-QRuntimeWindowSurface::~QRuntimeWindowSurface()
-{
- if (QApplicationPrivate::graphics_system)
- m_graphicsSystem->removeWindowSurface(this);
-}
-
-QPaintDevice *QRuntimeWindowSurface::paintDevice()
-{
- return m_windowSurface->paintDevice();
-}
-
-void QRuntimeWindowSurface::flush(QWidget *widget, const QRegion &region,
- const QPoint &offset)
-{
- m_windowSurface->flush(widget, region, offset);
-
- int destroyPolicy = m_graphicsSystem->windowSurfaceDestroyPolicy();
- if(m_pendingWindowSurface &&
- destroyPolicy == QRuntimeGraphicsSystem::DestroyAfterFirstFlush) {
-#ifdef QT_DEBUG
- qDebug() << "QRuntimeWindowSurface::flush() - destroy pending window surface";
-#endif
- m_pendingWindowSurface.reset();
- }
-}
-
-void QRuntimeWindowSurface::setGeometry(const QRect &rect)
-{
- QWindowSurface::setGeometry(rect);
- m_windowSurface->setGeometry(rect);
-}
-
-bool QRuntimeWindowSurface::scroll(const QRegion &area, int dx, int dy)
-{
- return m_windowSurface->scroll(area, dx, dy);
-}
-
-void QRuntimeWindowSurface::beginPaint(const QRegion &rgn)
-{
- m_windowSurface->beginPaint(rgn);
-}
-
-void QRuntimeWindowSurface::endPaint(const QRegion &rgn)
-{
- m_windowSurface->endPaint(rgn);
-}
-
-QImage* QRuntimeWindowSurface::buffer(const QWidget *widget)
-{
- return m_windowSurface->buffer(widget);
-}
-
-QPixmap QRuntimeWindowSurface::grabWidget(const QWidget *widget, const QRect& rectangle) const
-{
- return m_windowSurface->grabWidget(widget, rectangle);
-}
-
-QPoint QRuntimeWindowSurface::offset(const QWidget *widget) const
-{
- return m_windowSurface->offset(widget);
-}
-
-QWindowSurface::WindowSurfaceFeatures QRuntimeWindowSurface::features() const
-{
- return m_windowSurface->features();
-}
-
-QRuntimeGraphicsSystem::QRuntimeGraphicsSystem()
- : m_windowSurfaceDestroyPolicy(DestroyImmediately),
- m_graphicsSystem(0)
-{
- QApplicationPrivate::runtime_graphics_system = true;
-
-#ifdef QT_DEFAULT_RUNTIME_SYSTEM
- m_graphicsSystemName = QLatin1String(QT_DEFAULT_RUNTIME_SYSTEM);
- if (m_graphicsSystemName.isNull())
-#endif
- m_graphicsSystemName = QLatin1String("raster");
-
-#ifdef Q_OS_SYMBIAN
- m_windowSurfaceDestroyPolicy = DestroyAfterFirstFlush;
-#endif
-
- m_graphicsSystem = QGraphicsSystemFactory::create(m_graphicsSystemName);
-
- QApplicationPrivate::graphics_system_name = QLatin1String("runtime");
-}
-
-
-QPixmapData *QRuntimeGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const
-{
- Q_ASSERT(m_graphicsSystem);
- QPixmapData *data = m_graphicsSystem->createPixmapData(type);
-
- QRuntimePixmapData *rtData = new QRuntimePixmapData(this, type);
- rtData->m_data = data;
- m_pixmapDatas << rtData;
-
- return rtData;
-}
-
-QWindowSurface *QRuntimeGraphicsSystem::createWindowSurface(QWidget *widget) const
-{
- Q_ASSERT(m_graphicsSystem);
- QRuntimeWindowSurface *rtSurface = new QRuntimeWindowSurface(this, widget);
- rtSurface->m_windowSurface.reset(m_graphicsSystem->createWindowSurface(widget));
- widget->setWindowSurface(rtSurface);
- m_windowSurfaces << rtSurface;
- return rtSurface;
-}
-
-void QRuntimeGraphicsSystem::setGraphicsSystem(const QString &name)
-{
- if (m_graphicsSystemName == name)
- return;
-#ifdef QT_DEBUG
- qDebug() << "QRuntimeGraphicsSystem::setGraphicsSystem( " << name << " )";
-#endif
- QGraphicsSystem *oldSystem = m_graphicsSystem;
- m_graphicsSystem = QGraphicsSystemFactory::create(name);
- m_graphicsSystemName = name;
-
- Q_ASSERT(m_graphicsSystem);
-
- m_pendingGraphicsSystemName = QString();
-
- for (int i = 0; i < m_pixmapDatas.size(); ++i) {
- QRuntimePixmapData *proxy = m_pixmapDatas.at(i);
- QPixmapData *newData = m_graphicsSystem->createPixmapData(proxy->m_data);
- newData->fromImage(proxy->m_data->toImage(), Qt::NoOpaqueDetection);
- delete proxy->m_data;
- proxy->m_data = newData;
- proxy->readBackInfo();
- }
-
- for (int i = 0; i < m_windowSurfaces.size(); ++i) {
- QRuntimeWindowSurface *proxy = m_windowSurfaces.at(i);
- QWidget *widget = proxy->m_windowSurface->window();
-
- if(m_windowSurfaceDestroyPolicy == DestroyAfterFirstFlush)
- proxy->m_pendingWindowSurface.reset(proxy->m_windowSurface.take());
-
- QWindowSurface *newWindowSurface = m_graphicsSystem->createWindowSurface(widget);
- newWindowSurface->setGeometry(proxy->geometry());
-
- proxy->m_windowSurface.reset(newWindowSurface);
- qt_widget_private(widget)->invalidateBuffer(widget->rect());
- }
-
- delete oldSystem;
-}
-
-void QRuntimeGraphicsSystem::removePixmapData(QRuntimePixmapData *pixmapData) const
-{
- int index = m_pixmapDatas.lastIndexOf(pixmapData);
- m_pixmapDatas.removeAt(index);
-}
-
-void QRuntimeGraphicsSystem::removeWindowSurface(QRuntimeWindowSurface *windowSurface) const
-{
- int index = m_windowSurfaces.lastIndexOf(windowSurface);
- m_windowSurfaces.removeAt(index);
-}
-
-#include "qgraphicssystem_runtime.moc"
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qgraphicssystem_runtime_p.h b/src/gui/painting/qgraphicssystem_runtime_p.h
deleted file mode 100644
index 26d3777ad9..0000000000
--- a/src/gui/painting/qgraphicssystem_runtime_p.h
+++ /dev/null
@@ -1,187 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSSYSTEM_RUNTIME_P_H
-#define QGRAPHICSSYSTEM_RUNTIME_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qgraphicssystem_p.h"
-
-#include <private/qpixmapdata_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QRuntimeGraphicsSystem;
-
-class Q_GUI_EXPORT QRuntimePixmapData : public QPixmapData {
-public:
- QRuntimePixmapData(const QRuntimeGraphicsSystem *gs, PixelType type);
- ~QRuntimePixmapData();
-
- virtual QPixmapData *createCompatiblePixmapData() const;
- virtual void resize(int width, int height);
- virtual void fromImage(const QImage &image,
- Qt::ImageConversionFlags flags);
-
- virtual bool fromFile(const QString &filename, const char *format,
- Qt::ImageConversionFlags flags);
- virtual bool fromData(const uchar *buffer, uint len, const char *format,
- Qt::ImageConversionFlags flags);
-
- virtual void copy(const QPixmapData *data, const QRect &rect);
- virtual bool scroll(int dx, int dy, const QRect &rect);
-
- virtual int metric(QPaintDevice::PaintDeviceMetric metric) const;
- virtual void fill(const QColor &color);
- virtual QBitmap mask() const;
- virtual void setMask(const QBitmap &mask);
- virtual bool hasAlphaChannel() const;
- virtual QPixmap transformed(const QTransform &matrix,
- Qt::TransformationMode mode) const;
- virtual void setAlphaChannel(const QPixmap &alphaChannel);
- virtual QPixmap alphaChannel() const;
- virtual QImage toImage() const;
- virtual QPaintEngine *paintEngine() const;
-
- virtual QImage *buffer();
-
- void readBackInfo();
-
- QPixmapData *m_data;
-
-#if defined(Q_OS_SYMBIAN)
- void* toNativeType(NativeType type);
- void fromNativeType(void* pixmap, NativeType type);
-#endif
-
- virtual QPixmapData *runtimeData() const;
-
-private:
- const QRuntimeGraphicsSystem *m_graphicsSystem;
-
-};
-
-class QRuntimeWindowSurface : public QWindowSurface {
-public:
- QRuntimeWindowSurface(const QRuntimeGraphicsSystem *gs, QWidget *window);
- ~QRuntimeWindowSurface();
-
- virtual QPaintDevice *paintDevice();
- virtual void flush(QWidget *widget, const QRegion &region,
- const QPoint &offset);
- virtual void setGeometry(const QRect &rect);
-
- virtual bool scroll(const QRegion &area, int dx, int dy);
-
- virtual void beginPaint(const QRegion &);
- virtual void endPaint(const QRegion &);
-
- virtual QImage* buffer(const QWidget *widget);
- virtual QPixmap grabWidget(const QWidget *widget, const QRect& rectangle = QRect()) const;
-
- virtual QPoint offset(const QWidget *widget) const;
-
- virtual WindowSurfaceFeatures features() const;
-
- QScopedPointer<QWindowSurface> m_windowSurface;
- QScopedPointer<QWindowSurface> m_pendingWindowSurface;
-
-private:
- const QRuntimeGraphicsSystem *m_graphicsSystem;
-};
-
-class QRuntimeGraphicsSystem : public QGraphicsSystem
-{
-public:
-
- enum WindowSurfaceDestroyPolicy
- {
- DestroyImmediately,
- DestroyAfterFirstFlush
- };
-
-public:
- QRuntimeGraphicsSystem();
-
- QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
- QWindowSurface *createWindowSurface(QWidget *widget) const;
-
- void removePixmapData(QRuntimePixmapData *pixmapData) const;
- void removeWindowSurface(QRuntimeWindowSurface *windowSurface) const;
-
- void setGraphicsSystem(const QString &name);
- QString graphicsSystemName() const { return m_graphicsSystemName; }
-
- void setWindowSurfaceDestroyPolicy(WindowSurfaceDestroyPolicy policy)
- {
- m_windowSurfaceDestroyPolicy = policy;
- }
-
- int windowSurfaceDestroyPolicy() const { return m_windowSurfaceDestroyPolicy; }
-
-
-private:
- int m_windowSurfaceDestroyPolicy;
- QGraphicsSystem *m_graphicsSystem;
- mutable QList<QRuntimePixmapData *> m_pixmapDatas;
- mutable QList<QRuntimeWindowSurface *> m_windowSurfaces;
- QString m_graphicsSystemName;
-
- QString m_pendingGraphicsSystemName;
-
- friend class QRuntimePixmapData;
- friend class QRuntimeWindowSurface;
- friend class QMeeGoGraphicsSystem;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/gui/painting/qgraphicssystemfactory.cpp b/src/gui/painting/qgraphicssystemfactory.cpp
deleted file mode 100644
index 6212674c77..0000000000
--- a/src/gui/painting/qgraphicssystemfactory.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgraphicssystemfactory_p.h"
-#include "qgraphicssystemplugin_p.h"
-#include "private/qfactoryloader_p.h"
-#include "qmutex.h"
-
-#include "qapplication.h"
-#include <private/qapplication_p.h>
-#include "qgraphicssystem_raster_p.h"
-#include "qgraphicssystem_runtime_p.h"
-#include "qdebug.h"
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_LIBRARY
-Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
- (QGraphicsSystemFactoryInterface_iid, QLatin1String("/graphicssystems"), Qt::CaseInsensitive))
-#endif
-
-QGraphicsSystem *QGraphicsSystemFactory::create(const QString& key)
-{
- QGraphicsSystem *ret = 0;
- QString system = key.toLower();
-
-#if defined (QT_GRAPHICSSYSTEM_OPENGL)
- if (system.isEmpty()) {
- system = QLatin1String("opengl");
- }
-#elif defined (QT_GRAPHICSSYSTEM_OPENVG)
- if (system.isEmpty()) {
- system = QLatin1String("openvg");
- }
-#elif defined (QT_GRAPHICSSYSTEM_RUNTIME)
- if (system.isEmpty()) {
- system = QLatin1String("runtime");
- }
-#elif defined (QT_GRAPHICSSYSTEM_RASTER) && !defined(Q_WS_WIN) && !defined(Q_OS_SYMBIAN) || defined(Q_WS_X11) || (defined (Q_WS_MAC) && defined(QT_MAC_USE_COCOA))
- if (system.isEmpty()) {
- system = QLatin1String("raster");
- }
-#endif
-
- QApplicationPrivate::graphics_system_name = system;
- if (system == QLatin1String("raster"))
- return new QRasterGraphicsSystem;
- else if (system == QLatin1String("runtime"))
- return new QRuntimeGraphicsSystem;
- else if (system.isEmpty() || system == QLatin1String("native"))
- return 0;
-
-#ifndef QT_NO_LIBRARY
- if (!ret) {
- if (QGraphicsSystemFactoryInterface *factory = qobject_cast<QGraphicsSystemFactoryInterface*>(loader()->instance(system)))
- ret = factory->create(system);
- }
-#endif
-
- if (!ret)
- qWarning() << "Unable to load graphicssystem" << system;
-
- return ret;
-}
-
-/*!
- Returns the list of valid keys, i.e. the keys this factory can
- create styles for.
-
- \sa create()
-*/
-QStringList QGraphicsSystemFactory::keys()
-{
-#ifndef QT_NO_LIBRARY
- QStringList list = loader()->keys();
-#else
- QStringList list;
-#endif
- if (!list.contains(QLatin1String("Raster")))
- list << QLatin1String("raster");
- return list;
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/gui/painting/qgraphicssystemfactory_p.h b/src/gui/painting/qgraphicssystemfactory_p.h
deleted file mode 100644
index 8a2e2b14e0..0000000000
--- a/src/gui/painting/qgraphicssystemfactory_p.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSSYSTEMFACTORY_H
-#define QGRAPHICSSYSTEMFACTORY_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qstringlist.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QGraphicsSystem;
-
-class QGraphicsSystemFactory
-{
-public:
- static QStringList keys();
- static QGraphicsSystem *create(const QString&);
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QGRAPHICSSYSTEMFACTORY_H
-
diff --git a/src/gui/painting/qgraphicssystemplugin.cpp b/src/gui/painting/qgraphicssystemplugin.cpp
deleted file mode 100644
index 8eb1278373..0000000000
--- a/src/gui/painting/qgraphicssystemplugin.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgraphicssystemplugin_p.h"
-#include "qgraphicssystem_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QGraphicsSystemPlugin::QGraphicsSystemPlugin(QObject *parent)
- : QObject(parent)
-{
-}
-
-QGraphicsSystemPlugin::~QGraphicsSystemPlugin()
-{
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qgraphicssystemplugin_p.h b/src/gui/painting/qgraphicssystemplugin_p.h
deleted file mode 100644
index 1dafe82243..0000000000
--- a/src/gui/painting/qgraphicssystemplugin_p.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSSYSTEMPLUGIN_H
-#define QGRAPHICSSYSTEMPLUGIN_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qplugin.h>
-#include <QtCore/qfactoryinterface.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QGraphicsSystem;
-
-struct QGraphicsSystemFactoryInterface : public QFactoryInterface
-{
- virtual QGraphicsSystem *create(const QString &key) = 0;
-};
-
-#define QGraphicsSystemFactoryInterface_iid "com.trolltech.Qt.QGraphicsSystemFactoryInterface"
-
-Q_DECLARE_INTERFACE(QGraphicsSystemFactoryInterface, QGraphicsSystemFactoryInterface_iid)
-
-class Q_GUI_EXPORT QGraphicsSystemPlugin : public QObject, public QGraphicsSystemFactoryInterface
-{
- Q_OBJECT
- Q_INTERFACES(QGraphicsSystemFactoryInterface:QFactoryInterface)
-public:
- explicit QGraphicsSystemPlugin(QObject *parent = 0);
- ~QGraphicsSystemPlugin();
-
- virtual QStringList keys() const = 0;
- virtual QGraphicsSystem *create(const QString &key) = 0;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QGRAPHICSSYSTEMEPLUGIN_H
diff --git a/src/gui/painting/qmatrix.cpp b/src/gui/painting/qmatrix.cpp
index 38f78e1a46..a7523fd3cb 100644
--- a/src/gui/painting/qmatrix.cpp
+++ b/src/gui/painting/qmatrix.cpp
@@ -731,42 +731,6 @@ QPainterPath QMatrix::map(const QPainterPath &path) const
}
/*!
- \fn QRegion QMatrix::mapToRegion(const QRect &rectangle) const
-
- Returns the transformed rectangle \a rectangle as a QRegion
- object. A rectangle which has been rotated or sheared may result
- in a non-rectangular region being returned.
-
- Use the mapToPolygon() or map() function instead.
-*/
-#ifdef QT3_SUPPORT
-QRegion QMatrix::mapToRegion(const QRect &rect) const
-{
- QRegion result;
- if (isIdentity()) {
- result = rect;
- } else if (m12() == 0.0F && m21() == 0.0F) {
- int x = qRound(m11()*rect.x() + dx());
- int y = qRound(m22()*rect.y() + dy());
- int w = qRound(m11()*rect.width());
- int h = qRound(m22()*rect.height());
- if (w < 0) {
- w = -w;
- x -= w - 1;
- }
- if (h < 0) {
- h = -h;
- y -= h - 1;
- }
- result = QRect(x, y, w, h);
- } else {
- result = QRegion(mapToPolygon(rect));
- }
- return result;
-
-}
-#endif
-/*!
\fn QPolygon QMatrix::mapToPolygon(const QRect &rectangle) const
Creates and returns a QPolygon representation of the given \a
diff --git a/src/gui/painting/qmatrix.h b/src/gui/painting/qmatrix.h
index 898cfa4cf2..90b641ac91 100644
--- a/src/gui/painting/qmatrix.h
+++ b/src/gui/painting/qmatrix.h
@@ -118,12 +118,6 @@ public:
operator QVariant() const;
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT QMatrix invert(bool *invertible=0) const { return inverted(invertible); }
- inline QT3_SUPPORT QRect map(const QRect &r) const { return mapRect(r); }
- QT3_SUPPORT QRegion mapToRegion(const QRect &r) const;
-#endif
-
private:
inline QMatrix(bool)
: _m11(1.)
@@ -193,12 +187,6 @@ Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QMatrix &);
Q_GUI_EXPORT QDebug operator<<(QDebug, const QMatrix &);
#endif
-#ifdef QT3_SUPPORT
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <QtGui/qwmatrix.h>
-QT_END_INCLUDE_NAMESPACE
-#endif
-
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/gui/painting/qmemrotate.cpp b/src/gui/painting/qmemrotate.cpp
index fe524aff3b..c7002e2162 100644
--- a/src/gui/painting/qmemrotate.cpp
+++ b/src/gui/painting/qmemrotate.cpp
@@ -512,34 +512,34 @@ inline void qt_memrotate90_template<quint18, quint32>(const quint32 *src,
}
#define QT_IMPL_MEMROTATE(srctype, desttype) \
-void qt_memrotate90(const srctype *src, int w, int h, int sstride, \
+Q_GUI_EXPORT void qt_memrotate90(const srctype *src, int w, int h, int sstride, \
desttype *dest, int dstride) \
{ \
qt_memrotate90_template(src, w, h, sstride, dest, dstride); \
} \
-void qt_memrotate180(const srctype *src, int w, int h, int sstride, \
+Q_GUI_EXPORT void qt_memrotate180(const srctype *src, int w, int h, int sstride, \
desttype *dest, int dstride) \
{ \
qt_memrotate180_template(src, w, h, sstride, dest, dstride); \
} \
-void qt_memrotate270(const srctype *src, int w, int h, int sstride, \
+Q_GUI_EXPORT void qt_memrotate270(const srctype *src, int w, int h, int sstride, \
desttype *dest, int dstride) \
{ \
qt_memrotate270_template(src, w, h, sstride, dest, dstride); \
}
#define QT_IMPL_SIMPLE_MEMROTATE(srctype, desttype) \
-void qt_memrotate90(const srctype *src, int w, int h, int sstride, \
+Q_GUI_EXPORT void qt_memrotate90(const srctype *src, int w, int h, int sstride, \
desttype *dest, int dstride) \
{ \
qt_memrotate90_tiled_unpacked<desttype,srctype>(src, w, h, sstride, dest, dstride); \
} \
-void qt_memrotate180(const srctype *src, int w, int h, int sstride, \
+Q_GUI_EXPORT void qt_memrotate180(const srctype *src, int w, int h, int sstride, \
desttype *dest, int dstride) \
{ \
qt_memrotate180_template(src, w, h, sstride, dest, dstride); \
} \
-void qt_memrotate270(const srctype *src, int w, int h, int sstride, \
+Q_GUI_EXPORT void qt_memrotate270(const srctype *src, int w, int h, int sstride, \
desttype *dest, int dstride) \
{ \
qt_memrotate270_tiled_unpacked<desttype,srctype>(src, w, h, sstride, dest, dstride); \
diff --git a/src/gui/painting/qpaintdevice.cpp b/src/gui/painting/qpaintdevice.cpp
index f2ba7f0744..c0fd0e644a 100644
--- a/src/gui/painting/qpaintdevice.cpp
+++ b/src/gui/painting/qpaintdevice.cpp
@@ -43,8 +43,6 @@
QT_BEGIN_NAMESPACE
-extern void qt_painter_removePaintDevice(QPaintDevice *); //qpainter.cpp
-
QPaintDevice::QPaintDevice()
{
painters = 0;
@@ -55,7 +53,6 @@ QPaintDevice::~QPaintDevice()
if (paintingActive())
qWarning("QPaintDevice: Cannot destroy paint device that is being "
"painted");
- qt_painter_removePaintDevice(this);
}
@@ -67,6 +64,20 @@ int QPaintDevice::metric(PaintDeviceMetric) const
}
#endif
+void QPaintDevice::init(QPainter *) const
+{
+}
+
+QPaintDevice *QPaintDevice::redirected(QPoint *) const
+{
+ return 0;
+}
+
+QPainter *QPaintDevice::sharedPainter() const
+{
+ return 0;
+}
+
Q_GUI_EXPORT int qt_paint_device_metric(const QPaintDevice *device, QPaintDevice::PaintDeviceMetric metric)
{
return device->metric(metric);
diff --git a/src/gui/painting/qpaintdevice.h b/src/gui/painting/qpaintdevice.h
index 67db3f653f..0d584bff07 100644
--- a/src/gui/painting/qpaintdevice.h
+++ b/src/gui/painting/qpaintdevice.h
@@ -105,61 +105,22 @@ public:
protected:
QPaintDevice();
virtual int metric(PaintDeviceMetric metric) const;
+ virtual void init(QPainter *painter) const;
+ virtual QPaintDevice *redirected(QPoint *offset) const;
+ virtual QPainter *sharedPainter() const;
ushort painters; // refcount
private:
Q_DISABLE_COPY(QPaintDevice)
-#if defined(Q_WS_X11) && defined(QT3_SUPPORT)
-public:
- QT3_SUPPORT Display *x11Display() const;
- QT3_SUPPORT int x11Screen() const;
- QT3_SUPPORT int x11Depth() const;
- QT3_SUPPORT int x11Cells() const;
- QT3_SUPPORT Qt::HANDLE x11Colormap() const;
- QT3_SUPPORT bool x11DefaultColormap() const;
- QT3_SUPPORT void *x11Visual() const;
- QT3_SUPPORT bool x11DefaultVisual() const;
-
- static QT3_SUPPORT Display *x11AppDisplay();
- static QT3_SUPPORT int x11AppScreen();
- static QT3_SUPPORT int x11AppDepth(int screen = -1);
- static QT3_SUPPORT int x11AppCells(int screen = -1);
- static QT3_SUPPORT Qt::HANDLE x11AppRootWindow(int screen = -1);
- static QT3_SUPPORT Qt::HANDLE x11AppColormap(int screen = -1);
- static QT3_SUPPORT void *x11AppVisual(int screen = -1);
- static QT3_SUPPORT bool x11AppDefaultColormap(int screen =-1);
- static QT3_SUPPORT bool x11AppDefaultVisual(int screen =-1);
- static QT3_SUPPORT int x11AppDpiX(int screen = -1);
- static QT3_SUPPORT int x11AppDpiY(int screen = -1);
- static QT3_SUPPORT void x11SetAppDpiX(int, int);
- static QT3_SUPPORT void x11SetAppDpiY(int, int);
-#endif
-
friend class QPainter;
+ friend class QPainterPrivate;
friend class QFontEngineMac;
friend class QX11PaintEngine;
friend Q_GUI_EXPORT int qt_paint_device_metric(const QPaintDevice *device, PaintDeviceMetric metric);
};
-#ifdef QT3_SUPPORT
-QT3_SUPPORT Q_GUI_EXPORT
-void bitBlt(QPaintDevice *dst, int dx, int dy,
- const QPaintDevice *src, int sx=0, int sy=0, int sw=-1, int sh=-1,
- bool ignoreMask=false);
-
-QT3_SUPPORT Q_GUI_EXPORT
-void bitBlt(QPaintDevice *dst, int dx, int dy,
- const QImage *src, int sx=0, int sy=0, int sw=-1, int sh=-1,
- int conversion_flags=0);
-
-QT3_SUPPORT Q_GUI_EXPORT
-void bitBlt(QPaintDevice *dst, const QPoint &dp,
- const QPaintDevice *src, const QRect &sr=QRect(0,0,-1,-1),
- bool ignoreMask=false);
-#endif
-
/*****************************************************************************
Inline functions
*****************************************************************************/
diff --git a/src/gui/painting/qpaintdevice_qpa.cpp b/src/gui/painting/qpaintdevice_qpa.cpp
index 0d1ca92d45..9d731db4be 100644
--- a/src/gui/painting/qpaintdevice_qpa.cpp
+++ b/src/gui/painting/qpaintdevice_qpa.cpp
@@ -41,14 +41,11 @@
#include "qpaintdevice.h"
#include "qpainter.h"
-#include "qwidget.h"
#include "qbitmap.h"
-#include "qapplication.h"
+#include "qguiapplication.h"
QT_BEGIN_NAMESPACE
-extern void qt_painter_removePaintDevice(QPaintDevice *); //qpainter.cpp
-
int QPaintDevice::metric(PaintDeviceMetric m) const
{
qWarning("QPaintDevice::metrics: Device has no metric information");
diff --git a/src/gui/painting/qpaintdevice_qws.cpp b/src/gui/painting/qpaintdevice_qws.cpp
deleted file mode 100644
index 6f9433ab62..0000000000
--- a/src/gui/painting/qpaintdevice_qws.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qpaintdevice.h"
-#include "qpainter.h"
-#include "qwidget.h"
-#include "qbitmap.h"
-#include "qapplication.h"
-#include "qwsdisplay_qws.h"
-
-QT_BEGIN_NAMESPACE
-
-QWSDisplay *QPaintDevice::qwsDisplay()
-{
- return qt_fbdpy;
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qpaintdevice_x11.cpp b/src/gui/painting/qpaintdevice_x11.cpp
deleted file mode 100644
index b6be0761c5..0000000000
--- a/src/gui/painting/qpaintdevice_x11.cpp
+++ /dev/null
@@ -1,198 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qpaintdevice.h"
-#include "qpainter.h"
-#include "qwidget.h"
-#include "qbitmap.h"
-#include "qapplication.h"
-#include <private/qt_x11_p.h>
-#include "qx11info_x11.h"
-
-QT_BEGIN_NAMESPACE
-
-/*! \internal
-
- Returns the X11 Drawable of the paint device. 0 is returned if it
- can't be obtained.
-*/
-
-Drawable Q_GUI_EXPORT qt_x11Handle(const QPaintDevice *pd)
-{
- if (!pd) return 0;
- if (pd->devType() == QInternal::Widget)
- return static_cast<const QWidget *>(pd)->handle();
- else if (pd->devType() == QInternal::Pixmap)
- return static_cast<const QPixmap *>(pd)->handle();
- return 0;
-}
-
-/*!
- \relates QPaintDevice
-
- Returns the QX11Info structure for the \a pd paint device. 0 is
- returned if it can't be obtained.
-*/
-const Q_GUI_EXPORT QX11Info *qt_x11Info(const QPaintDevice *pd)
-{
- if (!pd) return 0;
- if (pd->devType() == QInternal::Widget)
- return &static_cast<const QWidget *>(pd)->x11Info();
- else if (pd->devType() == QInternal::Pixmap)
- return &static_cast<const QPixmap *>(pd)->x11Info();
- return 0;
-}
-
-
-
-#ifdef QT3_SUPPORT
-
-Display *QPaintDevice::x11Display() const
-{
- return X11->display;
-}
-
-int QPaintDevice::x11Screen() const
-{
- const QX11Info *info = qt_x11Info(this);
- if (info)
- return info->screen();
- return QX11Info::appScreen();
-}
-
-void *QPaintDevice::x11Visual() const
-{
- const QX11Info *info = qt_x11Info(this);
- if (info)
- return info->visual();
- return QX11Info::appVisual();
-}
-
-int QPaintDevice::x11Depth() const
-{
- const QX11Info *info = qt_x11Info(this);
- if (info)
- return info->depth();
- return QX11Info::appDepth();
-}
-
-int QPaintDevice::x11Cells() const
-{
- const QX11Info *info = qt_x11Info(this);
- if (info)
- return info->cells();
- return QX11Info::appCells();
-}
-
-Qt::HANDLE QPaintDevice::x11Colormap() const
-{
- const QX11Info *info = qt_x11Info(this);
- if (info)
- return info->colormap();
- return QX11Info::appColormap();
-}
-
-bool QPaintDevice::x11DefaultColormap() const
-{
- const QX11Info *info = qt_x11Info(this);
- if (info)
- return info->defaultColormap();
- return QX11Info::appDefaultColormap();
-}
-
-bool QPaintDevice::x11DefaultVisual() const
-{
- const QX11Info *info = qt_x11Info(this);
- if (info)
- return info->defaultVisual();
- return QX11Info::appDefaultVisual();
-}
-
-void *QPaintDevice::x11AppVisual(int screen)
-{ return QX11Info::appVisual(screen); }
-
-Qt::HANDLE QPaintDevice::x11AppColormap(int screen)
-{ return QX11Info::appColormap(screen); }
-
-Display *QPaintDevice::x11AppDisplay()
-{ return QX11Info::display(); }
-
-int QPaintDevice::x11AppScreen()
-{ return QX11Info::appScreen(); }
-
-int QPaintDevice::x11AppDepth(int screen)
-{ return QX11Info::appDepth(screen); }
-
-int QPaintDevice::x11AppCells(int screen)
-{ return QX11Info::appCells(screen); }
-
-Qt::HANDLE QPaintDevice::x11AppRootWindow(int screen)
-{ return QX11Info::appRootWindow(screen); }
-
-bool QPaintDevice::x11AppDefaultColormap(int screen)
-{ return QX11Info::appDefaultColormap(screen); }
-
-bool QPaintDevice::x11AppDefaultVisual(int screen)
-{ return QX11Info::appDefaultVisual(screen); }
-
-void QPaintDevice::x11SetAppDpiX(int dpi, int screen)
-{
- QX11Info::setAppDpiX(dpi, screen);
-}
-
-void QPaintDevice::x11SetAppDpiY(int dpi, int screen)
-{
- QX11Info::setAppDpiY(dpi, screen);
-}
-
-int QPaintDevice::x11AppDpiX(int screen)
-{
- return QX11Info::appDpiX(screen);
-}
-
-int QPaintDevice::x11AppDpiY(int screen)
-{
- return QX11Info::appDpiY(screen);
-}
-#endif
-
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qpaintengine.cpp b/src/gui/painting/qpaintengine.cpp
index 6eb09e5966..97736263ed 100644
--- a/src/gui/painting/qpaintengine.cpp
+++ b/src/gui/painting/qpaintengine.cpp
@@ -43,7 +43,6 @@
#include "qpainter_p.h"
#include "qpolygon.h"
#include "qbitmap.h"
-#include "qapplication.h"
#include <qdebug.h>
#include <qmath.h>
#include <private/qtextengine_p.h>
@@ -139,7 +138,7 @@ QString QTextItem::text() const
QFont QTextItem::font() const
{
const QTextItemInt *ti = static_cast<const QTextItemInt *>(this);
- return ti->f ? *ti->f : QApplication::font();
+ return ti->f ? *ti->f : QGuiApplication::font();
}
diff --git a/src/gui/painting/qpaintengine_blitter.cpp b/src/gui/painting/qpaintengine_blitter.cpp
index 500748e159..88028b2137 100644
--- a/src/gui/painting/qpaintengine_blitter.cpp
+++ b/src/gui/painting/qpaintengine_blitter.cpp
@@ -44,7 +44,6 @@
#include "private/qblittable_p.h"
#include "private/qpaintengine_raster_p.h"
#include "private/qpainter_p.h"
-#include "private/qapplication_p.h"
#include "private/qpixmap_blitter_p.h"
#ifndef QT_NO_BLITTABLE
diff --git a/src/gui/painting/qpaintengine_p.h b/src/gui/painting/qpaintengine_p.h
index d6aaffc254..c444663904 100644
--- a/src/gui/painting/qpaintengine_p.h
+++ b/src/gui/painting/qpaintengine_p.h
@@ -66,7 +66,7 @@ class QPaintEnginePrivate
{
Q_DECLARE_PUBLIC(QPaintEngine)
public:
- QPaintEnginePrivate() : pdev(0), q_ptr(0), currentClipWidget(0), hasSystemTransform(0),
+ QPaintEnginePrivate() : pdev(0), q_ptr(0), currentClipDevice(0), hasSystemTransform(0),
hasSystemViewport(0) {}
virtual ~QPaintEnginePrivate() { }
QPaintDevice *pdev;
@@ -75,7 +75,7 @@ public:
QRect systemRect;
QRegion systemViewport;
QTransform systemTransform;
- QWidget *currentClipWidget;
+ QPaintDevice *currentClipDevice;
uint hasSystemTransform : 1;
uint hasSystemViewport : 1;
diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp
index 2119e307d7..8fc2dbab1a 100644
--- a/src/gui/painting/qpaintengine_raster.cpp
+++ b/src/gui/painting/qpaintengine_raster.cpp
@@ -51,7 +51,6 @@
#include <qpainterpath.h>
#include <qdebug.h>
#include <qhash.h>
-#include <qlabel.h>
#include <qbitmap.h>
#include <qmath.h>
@@ -86,14 +85,6 @@
# include <private/qt_mac_p.h>
# include <private/qpixmap_mac_p.h>
# include <private/qpaintengine_mac_p.h>
-#elif defined(Q_WS_QWS)
-# if !defined(QT_NO_FREETYPE)
-# include <private/qfontengine_ft_p.h>
-# endif
-# if !defined(QT_NO_QWS_QPF2)
-# include <private/qfontengine_qpf_p.h>
-# endif
-# include <private/qabstractfontengine_p.h>
#elif defined(Q_OS_SYMBIAN) && defined(QT_NO_FREETYPE)
# include <private/qfontengine_s60_p.h>
#elif defined(Q_WS_QPA)
@@ -384,11 +375,6 @@ void QRasterPaintEngine::init()
case QInternal::Image:
format = d->rasterBuffer->prepare(static_cast<QImage *>(d->device));
break;
-#ifdef Q_WS_QWS
- case QInternal::CustomRaster:
- d->rasterBuffer->prepare(static_cast<QCustomRasterPaintDevice*>(d->device));
- break;
-#endif
default:
qWarning("QRasterPaintEngine: unsupported target device %d\n", d->device->devType());
d->device = 0;
@@ -986,13 +972,6 @@ void QRasterPaintEngine::clipEnabledChanged()
}
}
-#ifdef Q_WS_QWS
-void QRasterPaintEnginePrivate::prepare(QCustomRasterPaintDevice *device)
-{
- rasterBuffer->prepare(device);
-}
-#endif
-
void QRasterPaintEnginePrivate::drawImage(const QPointF &pt,
const QImage &img,
SrcOverBlendFunc func,
@@ -3456,22 +3435,6 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte
QFontEngine *fontEngine = ti.fontEngine;
-#if defined(Q_WS_QWS)
- if (fontEngine->type() == QFontEngine::Box) {
- fontEngine->draw(this, qFloor(p.x()), qFloor(p.y()), ti);
- return;
- }
-
- if (s->matrix.type() < QTransform::TxScale
- && (fontEngine->type() == QFontEngine::QPF1 || fontEngine->type() == QFontEngine::QPF2
- || (fontEngine->type() == QFontEngine::Proxy
- && !(static_cast<QProxyFontEngine *>(fontEngine)->drawAsOutline()))
- )) {
- fontEngine->draw(this, qFloor(p.x()), qFloor(p.y()), ti);
- return;
- }
-#endif // Q_WS_QWS
-
#ifdef Q_WS_QPA
if (s->matrix.type() < QTransform::TxScale) {
@@ -3501,14 +3464,6 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte
#if (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN)) && !defined(QT_NO_FREETYPE)
-#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_QPF2)
- if (fontEngine->type() == QFontEngine::QPF2) {
- QFontEngine *renderingEngine = static_cast<QFontEngineQPF *>(fontEngine)->renderingEngine();
- if (renderingEngine)
- fontEngine = renderingEngine;
- }
-#endif
-
if (fontEngine->type() != QFontEngine::Freetype) {
QPaintEngineEx::drawTextItem(p, ti);
return;
@@ -3878,59 +3833,6 @@ QPoint QRasterPaintEngine::coordinateOffset() const
return QPoint(0, 0);
}
-/*!
- Draws the given color \a spans with the specified \a color. The \a
- count parameter specifies the number of spans.
-
- The default implementation does nothing; reimplement this function
- to draw the given color \a spans with the specified \a color. Note
- that this function \e must be reimplemented if the framebuffer is
- not memory-mapped.
-
- \sa drawBufferSpan()
-*/
-#if defined(Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS)
-void QRasterPaintEngine::drawColorSpans(const QSpan *spans, int count, uint color)
-{
- Q_UNUSED(spans);
- Q_UNUSED(count);
- Q_UNUSED(color);
- qFatal("QRasterPaintEngine::drawColorSpans must be reimplemented on "
- "a non memory-mapped device");
-}
-
-/*!
- \fn void QRasterPaintEngine::drawBufferSpan(const uint *buffer, int size, int x, int y, int length, uint alpha)
-
- Draws the given \a buffer.
-
- The default implementation does nothing; reimplement this function
- to draw a buffer that contains more than one color. Note that this
- function \e must be reimplemented if the framebuffer is not
- memory-mapped.
-
- The \a size parameter specifies the total size of the given \a
- buffer, while the \a length parameter specifies the number of
- pixels to draw. The buffer's position is given by (\a x, \a
- y). The provided \a alpha value is added to each pixel in the
- buffer when drawing.
-
- \sa drawColorSpans()
-*/
-void QRasterPaintEngine::drawBufferSpan(const uint *buffer, int bufsize,
- int x, int y, int length, uint const_alpha)
-{
- Q_UNUSED(buffer);
- Q_UNUSED(bufsize);
- Q_UNUSED(x);
- Q_UNUSED(y);
- Q_UNUSED(length);
- Q_UNUSED(const_alpha);
- qFatal("QRasterPaintEngine::drawBufferSpan must be reimplemented on "
- "a non memory-mapped device");
-}
-#endif // Q_WS_QWS
-
void QRasterPaintEngine::drawBitmap(const QPointF &pos, const QImage &image, QSpanData *fg)
{
Q_ASSERT(fg);
@@ -4378,127 +4280,6 @@ void QRasterBuffer::resetBuffer(int val)
memset(m_buffer, val, m_height*bytes_per_line);
}
-
-#if defined(Q_WS_QWS)
-void QRasterBuffer::prepare(QCustomRasterPaintDevice *device)
-{
- m_buffer = reinterpret_cast<uchar*>(device->memory());
- m_width = qMin(QT_RASTER_COORD_LIMIT, device->width());
- m_height = qMin(QT_RASTER_COORD_LIMIT, device->height());
- bytes_per_pixel = device->depth() / 8;
- bytes_per_line = device->bytesPerLine();
- format = device->format();
-#ifndef QT_NO_RASTERCALLBACKS
- if (!m_buffer)
- drawHelper = qDrawHelperCallback + format;
- else
-#endif
- drawHelper = qDrawHelper + format;
-}
-
-int QCustomRasterPaintDevice::metric(PaintDeviceMetric m) const
-{
- switch (m) {
- case PdmWidth:
- return widget->frameGeometry().width();
- case PdmHeight:
- return widget->frameGeometry().height();
- default:
- break;
- }
-
- return qt_paint_device_metric(widget, m);
-}
-
-int QCustomRasterPaintDevice::bytesPerLine() const
-{
- return (width() * depth() + 7) / 8;
-}
-
-#elif defined(Q_OS_SYMBIAN)
-
-void QRasterBuffer::prepareBuffer(int /* width */, int /* height */)
-{
-}
-
-#endif // Q_OS_SYMBIAN
-
-/*!
- \class QCustomRasterPaintDevice
- \preliminary
- \ingroup qws
- \since 4.2
-
- \brief The QCustomRasterPaintDevice class is provided to activate
- hardware accelerated paint engines in Qt for Embedded Linux.
-
- Note that this class is only available in \l{Qt for Embedded Linux}.
-
- In \l{Qt for Embedded Linux}, painting is a pure software
- implementation. But starting with Qt 4.2, it is
- possible to add an accelerated graphics driver to take advantage
- of available hardware resources.
-
- Hardware acceleration is accomplished by creating a custom screen
- driver, accelerating the copying from memory to the screen, and
- implementing a custom paint engine accelerating the various
- painting operations. Then a custom paint device (derived from the
- QCustomRasterPaintDevice class) and a custom window surface
- (derived from QWSWindowSurface) must be implemented to make
- \l{Qt for Embedded Linux} aware of the accelerated driver.
-
- See the \l {Adding an Accelerated Graphics Driver to Qt for Embedded Linux}
- documentation for details.
-
- \sa QRasterPaintEngine, QPaintDevice
-*/
-
-/*!
- \fn QCustomRasterPaintDevice::QCustomRasterPaintDevice(QWidget *widget)
-
- Constructs a custom raster based paint device for the given
- top-level \a widget.
-*/
-
-/*!
- \fn int QCustomRasterPaintDevice::bytesPerLine() const
-
- Returns the number of bytes per line in the framebuffer. Note that
- this number might be larger than the framebuffer width.
-*/
-
-/*!
- \fn int QCustomRasterPaintDevice::devType() const
- \internal
-*/
-
-/*!
- \fn QImage::Format QCustomRasterPaintDevice::format() const
-
- Returns the format of the device's memory buffet.
-
- The default format is QImage::Format_ARGB32_Premultiplied. The
- only other valid format is QImage::Format_RGB16.
-*/
-
-/*!
- \fn void * QCustomRasterPaintDevice::memory () const
-
- Returns a pointer to the paint device's memory buffer, or 0 if no
- such buffer exists.
-*/
-
-/*!
- \fn int QCustomRasterPaintDevice::metric ( PaintDeviceMetric m ) const
- \reimp
-*/
-
-/*!
- \fn QSize QCustomRasterPaintDevice::size () const
- \internal
-*/
-
-
QClipData::QClipData(int height)
{
clipSpanHeight = height;
@@ -5223,9 +5004,6 @@ Q_GLOBAL_STATIC(QGradientCache, qt_gradient_cache)
void QSpanData::init(QRasterBuffer *rb, const QRasterPaintEngine *pe)
{
rasterBuffer = rb;
-#ifdef Q_WS_QWS
- rasterEngine = const_cast<QRasterPaintEngine *>(pe);
-#endif
type = None;
txop = 0;
bilinear = false;
@@ -5371,16 +5149,7 @@ void QSpanData::adjustSpanMethods()
unclipped_blend = rasterBuffer->drawHelper->blendGradient;
break;
case Texture:
-#ifdef Q_WS_QWS
-#ifndef QT_NO_RASTERCALLBACKS
- if (!rasterBuffer->buffer())
- unclipped_blend = qBlendTextureCallback;
- else
-#endif
- unclipped_blend = qBlendTexture;
-#else
unclipped_blend = qBlendTexture;
-#endif
if (!texture.imageData)
unclipped_blend = 0;
diff --git a/src/gui/painting/qpaintengine_raster_p.h b/src/gui/painting/qpaintengine_raster_p.h
index 52f51fab16..78f5d5b791 100644
--- a/src/gui/painting/qpaintengine_raster_p.h
+++ b/src/gui/painting/qpaintengine_raster_p.h
@@ -72,7 +72,6 @@ class QOutlineMapper;
class QRasterPaintEnginePrivate;
class QRasterBuffer;
class QClipData;
-class QCustomRasterPaintDevice;
class QRasterPaintEngineState : public QPainterState
{
@@ -129,11 +128,7 @@ public:
/*******************************************************************************
* QRasterPaintEngine
*/
-class
-#ifdef Q_WS_QWS
-Q_GUI_EXPORT
-#endif
-QRasterPaintEngine : public QPaintEngineEx
+class Q_GUI_EXPORT QRasterPaintEngine : public QPaintEngineEx
{
Q_DECLARE_PRIVATE(QRasterPaintEngine)
public:
@@ -244,12 +239,6 @@ public:
QPoint coordinateOffset() const;
-#if defined(Q_WS_QWS) && !defined(QT_NO_RASTERCALLBACKS)
- virtual void drawColorSpans(const QSpan *spans, int count, uint color);
- virtual void drawBufferSpan(const uint *buffer, int bufsize,
- int x, int y, int length, uint const_alpha);
-#endif
-
protected:
QRasterPaintEngine(QRasterPaintEnginePrivate &d, QPaintDevice *);
private:
@@ -296,11 +285,7 @@ private:
/*******************************************************************************
* QRasterPaintEnginePrivate
*/
-class
-#ifdef Q_WS_QWS
-Q_GUI_EXPORT
-#endif
-QRasterPaintEnginePrivate : public QPaintEngineExPrivate
+class QRasterPaintEnginePrivate : public QPaintEngineExPrivate
{
Q_DECLARE_PUBLIC(QRasterPaintEngine)
public:
@@ -333,10 +318,6 @@ public:
ProcessSpans getBrushFunc(const QRect &rect, const QSpanData *data) const;
ProcessSpans getBrushFunc(const QRectF &rect, const QSpanData *data) const;
-#ifdef Q_WS_QWS
- void prepare(QCustomRasterPaintDevice *);
-#endif
-
inline const QClipData *clip() const;
void initializeRasterizer(QSpanData *data);
@@ -384,11 +365,7 @@ public:
};
-class
-#ifdef Q_WS_QWS
-Q_GUI_EXPORT
-#endif
-QClipData {
+class QClipData {
public:
QClipData(int height);
~QClipData();
@@ -465,41 +442,10 @@ inline void QClipData::appendSpans(const QSpan *s, int num)
count += num;
}
-#ifdef Q_WS_QWS
-class Q_GUI_EXPORT QCustomRasterPaintDevice : public QPaintDevice
-{
-public:
- QCustomRasterPaintDevice(QWidget *w) : widget(w) {}
-
- int devType() const { return QInternal::CustomRaster; }
-
- virtual int metric(PaintDeviceMetric m) const;
-
- virtual void* memory() const { return 0; }
-
- virtual QImage::Format format() const {
- return QImage::Format_ARGB32_Premultiplied;
- }
-
- virtual int bytesPerLine() const;
-
- virtual QSize size() const {
- return static_cast<QRasterPaintEngine*>(paintEngine())->size();
- }
-
-private:
- QWidget *widget;
-};
-#endif // Q_WS_QWS
-
/*******************************************************************************
* QRasterBuffer
*/
-class
-#ifdef Q_WS_QWS
-Q_GUI_EXPORT
-#endif
-QRasterBuffer
+class QRasterBuffer
{
public:
QRasterBuffer() : m_width(0), m_height(0), m_buffer(0) { init(); }
@@ -510,9 +456,6 @@ public:
QImage::Format prepare(QImage *image);
QImage::Format prepare(QPixmap *pix);
-#ifdef Q_WS_QWS
- void prepare(QCustomRasterPaintDevice *device);
-#endif
void prepare(int w, int h);
void prepareBuffer(int w, int h);
diff --git a/src/gui/painting/qpaintengine_x11.cpp b/src/gui/painting/qpaintengine_x11.cpp
deleted file mode 100644
index 6ba9a99f09..0000000000
--- a/src/gui/painting/qpaintengine_x11.cpp
+++ /dev/null
@@ -1,2504 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qplatformdefs.h"
-
-#include "private/qpixmap_x11_p.h"
-
-#include "qapplication.h"
-#include "qdebug.h"
-#include "qfont.h"
-#include "qwidget.h"
-#include "qbitmap.h"
-#include "qpixmapcache.h"
-#include "qtextcodec.h"
-#include "qcoreevent.h"
-#include "qiodevice.h"
-#include <qmath.h>
-
-#include "qpainter_p.h"
-#include <qtextlayout.h>
-#include <qvarlengtharray.h>
-#include <private/qfont_p.h>
-#include <private/qtextengine_p.h>
-#include <private/qpaintengine_x11_p.h>
-#include <private/qfontengine_x11_p.h>
-#include <private/qwidget_p.h>
-#include <private/qpainterpath_p.h>
-
-#include "qpen.h"
-#include "qcolor.h"
-#include "qcolormap.h"
-
-#include <private/qpaintengine_p.h>
-#include "qpaintengine_x11_p.h"
-
-#include <private/qt_x11_p.h>
-#include <private/qnumeric_p.h>
-#include <limits.h>
-
-#ifndef QT_NO_XRENDER
-#include <private/qtessellator_p.h>
-#endif
-
-#include <private/qstylehelper_p.h>
-
-QT_BEGIN_NAMESPACE
-
-extern Drawable qt_x11Handle(const QPaintDevice *pd);
-extern const QX11Info *qt_x11Info(const QPaintDevice *pd);
-extern QPixmap qt_pixmapForBrush(int brushStyle, bool invert); //in qbrush.cpp
-extern QPixmap qt_toX11Pixmap(const QPixmap &pixmap);
-
-// use the same rounding as in qrasterizer.cpp (6 bit fixed point)
-static const qreal aliasedCoordinateDelta = 0.5 - 0.015625;
-
-#undef X11 // defined in qt_x11_p.h
-/*!
- Returns the X11 specific pen GC for the painter \a p. Note that
- QPainter::begin() must be called before this function returns a
- valid GC.
-*/
-Q_GUI_EXPORT GC qt_x11_get_pen_gc(QPainter *p)
-{
- if (p && p->paintEngine()
- && p->paintEngine()->isActive()
- && p->paintEngine()->type() == QPaintEngine::X11) {
- return static_cast<QX11PaintEngine *>(p->paintEngine())->d_func()->gc;
- }
- return 0;
-}
-
-/*!
- Returns the X11 specific brush GC for the painter \a p. Note that
- QPainter::begin() must be called before this function returns a
- valid GC.
-*/
-Q_GUI_EXPORT GC qt_x11_get_brush_gc(QPainter *p)
-{
- if (p && p->paintEngine()
- && p->paintEngine()->isActive()
- && p->paintEngine()->type() == QPaintEngine::X11) {
- return static_cast<QX11PaintEngine *>(p->paintEngine())->d_func()->gc_brush;
- }
- return 0;
-}
-#define X11 qt_x11Data
-
-#ifndef QT_NO_XRENDER
-static const int compositionModeToRenderOp[QPainter::CompositionMode_Xor + 1] = {
- PictOpOver, //CompositionMode_SourceOver,
- PictOpOverReverse, //CompositionMode_DestinationOver,
- PictOpClear, //CompositionMode_Clear,
- PictOpSrc, //CompositionMode_Source,
- PictOpDst, //CompositionMode_Destination,
- PictOpIn, //CompositionMode_SourceIn,
- PictOpInReverse, //CompositionMode_DestinationIn,
- PictOpOut, //CompositionMode_SourceOut,
- PictOpOutReverse, //CompositionMode_DestinationOut,
- PictOpAtop, //CompositionMode_SourceAtop,
- PictOpAtopReverse, //CompositionMode_DestinationAtop,
- PictOpXor //CompositionMode_Xor
-};
-
-static inline int qpainterOpToXrender(QPainter::CompositionMode mode)
-{
- Q_ASSERT(mode <= QPainter::CompositionMode_Xor);
- return compositionModeToRenderOp[mode];
-}
-#endif
-
-// hack, so we don't have to make QRegion::clipRectangles() public or include
-// X11 headers in qregion.h
-Q_GUI_EXPORT void *qt_getClipRects(const QRegion &r, int &num)
-{
- return r.clipRectangles(num);
-}
-
-static inline void x11SetClipRegion(Display *dpy, GC gc, GC gc2,
-#ifndef QT_NO_XRENDER
- Picture picture,
-#else
- Qt::HANDLE picture,
-#endif
- const QRegion &r)
-{
- int num;
- XRectangle *rects = (XRectangle *)qt_getClipRects(r, num);
-
- if (gc)
- XSetClipRectangles( dpy, gc, 0, 0, rects, num, YXBanded );
- if (gc2)
- XSetClipRectangles( dpy, gc2, 0, 0, rects, num, YXBanded );
-
-#ifndef QT_NO_XRENDER
- if (picture)
- XRenderSetPictureClipRectangles(dpy, picture, 0, 0, rects, num);
-#else
- Q_UNUSED(picture);
-#endif // QT_NO_XRENDER
-}
-
-
-static inline void x11ClearClipRegion(Display *dpy, GC gc, GC gc2,
-#ifndef QT_NO_XRENDER
- Picture picture
-#else
- Qt::HANDLE picture
-#endif
- )
-{
- if (gc)
- XSetClipMask(dpy, gc, XNone);
- if (gc2)
- XSetClipMask(dpy, gc2, XNone);
-
-#ifndef QT_NO_XRENDER
- if (picture) {
- XRenderPictureAttributes attrs;
- attrs.clip_mask = XNone;
- XRenderChangePicture (dpy, picture, CPClipMask, &attrs);
- }
-#else
- Q_UNUSED(picture);
-#endif // QT_NO_XRENDER
-}
-
-
-#define DITHER_SIZE 16
-static const uchar base_dither_matrix[DITHER_SIZE][DITHER_SIZE] = {
- { 0,192, 48,240, 12,204, 60,252, 3,195, 51,243, 15,207, 63,255 },
- { 128, 64,176,112,140, 76,188,124,131, 67,179,115,143, 79,191,127 },
- { 32,224, 16,208, 44,236, 28,220, 35,227, 19,211, 47,239, 31,223 },
- { 160, 96,144, 80,172,108,156, 92,163, 99,147, 83,175,111,159, 95 },
- { 8,200, 56,248, 4,196, 52,244, 11,203, 59,251, 7,199, 55,247 },
- { 136, 72,184,120,132, 68,180,116,139, 75,187,123,135, 71,183,119 },
- { 40,232, 24,216, 36,228, 20,212, 43,235, 27,219, 39,231, 23,215 },
- { 168,104,152, 88,164,100,148, 84,171,107,155, 91,167,103,151, 87 },
- { 2,194, 50,242, 14,206, 62,254, 1,193, 49,241, 13,205, 61,253 },
- { 130, 66,178,114,142, 78,190,126,129, 65,177,113,141, 77,189,125 },
- { 34,226, 18,210, 46,238, 30,222, 33,225, 17,209, 45,237, 29,221 },
- { 162, 98,146, 82,174,110,158, 94,161, 97,145, 81,173,109,157, 93 },
- { 10,202, 58,250, 6,198, 54,246, 9,201, 57,249, 5,197, 53,245 },
- { 138, 74,186,122,134, 70,182,118,137, 73,185,121,133, 69,181,117 },
- { 42,234, 26,218, 38,230, 22,214, 41,233, 25,217, 37,229, 21,213 },
- { 170,106,154, 90,166,102,150, 86,169,105,153, 89,165,101,149, 85 }
-};
-
-static QPixmap qt_patternForAlpha(uchar alpha, int screen)
-{
- QPixmap pm;
- QString key = QLatin1Literal("$qt-alpha-brush$")
- % HexString<uchar>(alpha)
- % HexString<int>(screen);
-
- if (!QPixmapCache::find(key, pm)) {
- // #### why not use a mono image here????
- QImage pattern(DITHER_SIZE, DITHER_SIZE, QImage::Format_ARGB32);
- pattern.fill(0xffffffff);
- for (int y = 0; y < DITHER_SIZE; ++y) {
- for (int x = 0; x < DITHER_SIZE; ++x) {
- if (base_dither_matrix[x][y] <= alpha)
- pattern.setPixel(x, y, 0x00000000);
- }
- }
- pm = QBitmap::fromImage(pattern);
- pm.x11SetScreen(screen);
- QPixmapCache::insert(key, pm);
- }
- return pm;
-}
-
-#if !defined(QT_NO_XRENDER)
-
-class QXRenderTessellator : public QTessellator
-{
-public:
- QXRenderTessellator() : traps(0), allocated(0), size(0) {}
- ~QXRenderTessellator() { free(traps); }
- XTrapezoid *traps;
- int allocated;
- int size;
- void addTrap(const Trapezoid &trap);
- QRect tessellate(const QPointF *points, int nPoints, bool winding) {
- size = 0;
- setWinding(winding);
- return QTessellator::tessellate(points, nPoints).toRect();
- }
- void done() {
- if (allocated > 64) {
- free(traps);
- traps = 0;
- allocated = 0;
- }
- }
-};
-
-void QXRenderTessellator::addTrap(const Trapezoid &trap)
-{
- if (size == allocated) {
- allocated = qMax(2*allocated, 64);
- traps = q_check_ptr((XTrapezoid *)realloc(traps, allocated * sizeof(XTrapezoid)));
- }
- traps[size].top = Q27Dot5ToXFixed(trap.top);
- traps[size].bottom = Q27Dot5ToXFixed(trap.bottom);
- traps[size].left.p1.x = Q27Dot5ToXFixed(trap.topLeft->x);
- traps[size].left.p1.y = Q27Dot5ToXFixed(trap.topLeft->y);
- traps[size].left.p2.x = Q27Dot5ToXFixed(trap.bottomLeft->x);
- traps[size].left.p2.y = Q27Dot5ToXFixed(trap.bottomLeft->y);
- traps[size].right.p1.x = Q27Dot5ToXFixed(trap.topRight->x);
- traps[size].right.p1.y = Q27Dot5ToXFixed(trap.topRight->y);
- traps[size].right.p2.x = Q27Dot5ToXFixed(trap.bottomRight->x);
- traps[size].right.p2.y = Q27Dot5ToXFixed(trap.bottomRight->y);
- ++size;
-}
-
-#endif // !defined(QT_NO_XRENDER)
-
-
-#ifndef QT_NO_XRENDER
-static Picture getPatternFill(int screen, const QBrush &b)
-{
- if (!X11->use_xrender)
- return XNone;
-
- XRenderColor color = X11->preMultiply(b.color());
- XRenderColor bg_color;
-
- bg_color = X11->preMultiply(QColor(0, 0, 0, 0));
-
- for (int i = 0; i < X11->pattern_fill_count; ++i) {
- if (X11->pattern_fills[i].screen == screen
- && X11->pattern_fills[i].opaque == false
- && X11->pattern_fills[i].style == b.style()
- && X11->pattern_fills[i].color.alpha == color.alpha
- && X11->pattern_fills[i].color.red == color.red
- && X11->pattern_fills[i].color.green == color.green
- && X11->pattern_fills[i].color.blue == color.blue
- && X11->pattern_fills[i].bg_color.alpha == bg_color.alpha
- && X11->pattern_fills[i].bg_color.red == bg_color.red
- && X11->pattern_fills[i].bg_color.green == bg_color.green
- && X11->pattern_fills[i].bg_color.blue == bg_color.blue)
- return X11->pattern_fills[i].picture;
- }
- // none found, replace one
- int i = qrand() % 16;
-
- if (X11->pattern_fills[i].screen != screen && X11->pattern_fills[i].picture) {
- XRenderFreePicture (X11->display, X11->pattern_fills[i].picture);
- X11->pattern_fills[i].picture = 0;
- }
-
- if (!X11->pattern_fills[i].picture) {
- Pixmap pixmap = XCreatePixmap (X11->display, RootWindow (X11->display, screen), 8, 8, 32);
- XRenderPictureAttributes attrs;
- attrs.repeat = True;
- X11->pattern_fills[i].picture = XRenderCreatePicture (X11->display, pixmap,
- XRenderFindStandardFormat(X11->display, PictStandardARGB32),
- CPRepeat, &attrs);
- XFreePixmap (X11->display, pixmap);
- }
-
- X11->pattern_fills[i].screen = screen;
- X11->pattern_fills[i].color = color;
- X11->pattern_fills[i].bg_color = bg_color;
- X11->pattern_fills[i].opaque = false;
- X11->pattern_fills[i].style = b.style();
-
- XRenderFillRectangle(X11->display, PictOpSrc, X11->pattern_fills[i].picture, &bg_color, 0, 0, 8, 8);
-
- QPixmap pattern(qt_pixmapForBrush(b.style(), true));
- XRenderPictureAttributes attrs;
- attrs.repeat = true;
- XRenderChangePicture(X11->display, pattern.x11PictureHandle(), CPRepeat, &attrs);
-
- Picture fill_fg = X11->getSolidFill(screen, b.color());
- XRenderComposite(X11->display, PictOpOver, fill_fg, pattern.x11PictureHandle(),
- X11->pattern_fills[i].picture,
- 0, 0, 0, 0, 0, 0, 8, 8);
-
- return X11->pattern_fills[i].picture;
-}
-
-static void qt_render_bitmap(Display *dpy, int scrn, Picture src, Picture dst,
- int sx, int sy, int x, int y, int sw, int sh,
- const QPen &pen)
-{
- Picture fill_fg = X11->getSolidFill(scrn, pen.color());
- XRenderComposite(dpy, PictOpOver,
- fill_fg, src, dst, sx, sy, sx, sy, x, y, sw, sh);
-}
-#endif
-
-void QX11PaintEnginePrivate::init()
-{
- dpy = 0;
- scrn = 0;
- hd = 0;
- picture = 0;
- xinfo = 0;
-#ifndef QT_NO_XRENDER
- current_brush = 0;
- composition_mode = PictOpOver;
- tessellator = new QXRenderTessellator;
-#endif
-}
-
-void QX11PaintEnginePrivate::setupAdaptedOrigin(const QPoint &p)
-{
- if (adapted_pen_origin)
- XSetTSOrigin(dpy, gc, p.x(), p.y());
- if (adapted_brush_origin)
- XSetTSOrigin(dpy, gc_brush, p.x(), p.y());
-}
-
-void QX11PaintEnginePrivate::resetAdaptedOrigin()
-{
- if (adapted_pen_origin)
- XSetTSOrigin(dpy, gc, 0, 0);
- if (adapted_brush_origin)
- XSetTSOrigin(dpy, gc_brush, 0, 0);
-}
-
-void QX11PaintEnginePrivate::clipPolygon_dev(const QPolygonF &poly, QPolygonF *clipped_poly)
-{
- int clipped_count = 0;
- qt_float_point *clipped_points = 0;
- polygonClipper.clipPolygon((qt_float_point *) poly.data(), poly.size(),
- &clipped_points, &clipped_count);
- clipped_poly->resize(clipped_count);
- for (int i=0; i<clipped_count; ++i)
- (*clipped_poly)[i] = *((QPointF *)(&clipped_points[i]));
-}
-
-void QX11PaintEnginePrivate::systemStateChanged()
-{
- Q_Q(QX11PaintEngine);
- QPainter *painter = q->state ? static_cast<QPainterState *>(q->state)->painter : 0;
- if (painter && painter->hasClipping()) {
- if (q->testDirty(QPaintEngine::DirtyTransform))
- q->updateMatrix(q->state->transform());
- QPolygonF clip_poly_dev(matrix.map(painter->clipPath().toFillPolygon()));
- QPolygonF clipped_poly_dev;
- clipPolygon_dev(clip_poly_dev, &clipped_poly_dev);
- q->updateClipRegion_dev(QRegion(clipped_poly_dev.toPolygon()), Qt::ReplaceClip);
- } else {
- q->updateClipRegion_dev(QRegion(), Qt::NoClip);
- }
-}
-
-static QPaintEngine::PaintEngineFeatures qt_decide_features()
-{
- QPaintEngine::PaintEngineFeatures features =
- QPaintEngine::PrimitiveTransform
- | QPaintEngine::PatternBrush
- | QPaintEngine::AlphaBlend
- | QPaintEngine::PainterPaths
- | QPaintEngine::RasterOpModes;
-
- if (X11->use_xrender) {
- features |= QPaintEngine::Antialiasing;
- features |= QPaintEngine::PorterDuff;
- features |= QPaintEngine::MaskedBrush;
-#if 0
- if (X11->xrender_version > 10) {
- features |= QPaintEngine::LinearGradientFill;
- // ###
- }
-#endif
- }
-
- return features;
-}
-
-/*
- * QX11PaintEngine members
- */
-
-QX11PaintEngine::QX11PaintEngine()
- : QPaintEngine(*(new QX11PaintEnginePrivate), qt_decide_features())
-{
- d_func()->init();
-}
-
-QX11PaintEngine::QX11PaintEngine(QX11PaintEnginePrivate &dptr)
- : QPaintEngine(dptr, qt_decide_features())
-{
- d_func()->init();
-}
-
-QX11PaintEngine::~QX11PaintEngine()
-{
-#ifndef QT_NO_XRENDER
- Q_D(QX11PaintEngine);
- delete d->tessellator;
-#endif
-}
-
-bool QX11PaintEngine::begin(QPaintDevice *pdev)
-{
- Q_D(QX11PaintEngine);
- d->xinfo = qt_x11Info(pdev);
- QWidget *w = d->pdev->devType() == QInternal::Widget ? static_cast<QWidget *>(d->pdev) : 0;
- const bool isAlienWidget = w && !w->internalWinId() && w->testAttribute(Qt::WA_WState_Created);
-#ifndef QT_NO_XRENDER
- if (w) {
- if (isAlienWidget)
- d->picture = (::Picture)w->nativeParentWidget()->x11PictureHandle();
- else
- d->picture = (::Picture)w->x11PictureHandle();
- } else if (pdev->devType() == QInternal::Pixmap) {
- const QPixmap *pm = static_cast<const QPixmap *>(pdev);
- QX11PixmapData *data = static_cast<QX11PixmapData*>(pm->data.data());
- if (X11->use_xrender && data->depth() != 32 && data->x11_mask)
- data->convertToARGB32();
- d->picture = (::Picture)static_cast<const QPixmap *>(pdev)->x11PictureHandle();
- }
-#else
- d->picture = 0;
-#endif
- d->hd = !isAlienWidget ? qt_x11Handle(pdev) : qt_x11Handle(w->nativeParentWidget());
-
- Q_ASSERT(d->xinfo != 0);
- d->dpy = d->xinfo->display(); // get display variable
- d->scrn = d->xinfo->screen(); // get screen variable
-
- d->crgn = QRegion();
- d->gc = XCreateGC(d->dpy, d->hd, 0, 0);
- d->gc_brush = XCreateGC(d->dpy, d->hd, 0, 0);
- d->has_alpha_brush = false;
- d->has_alpha_pen = false;
- d->has_clipping = false;
- d->has_complex_xform = false;
- d->has_scaling_xform = false;
- d->has_non_scaling_xform = true;
- d->xform_scale = 1;
- d->has_custom_pen = false;
- d->matrix = QTransform();
- d->pdev_depth = d->pdev->depth();
- d->render_hints = 0;
- d->txop = QTransform::TxNone;
- d->use_path_fallback = false;
-#if !defined(QT_NO_XRENDER)
- d->composition_mode = PictOpOver;
-#endif
- d->xlibMaxLinePoints = 32762; // a safe number used to avoid, call to XMaxRequestSize(d->dpy) - 3;
- d->opacity = 1;
-
- // Set up the polygon clipper. Note: This will only work in
- // polyline mode as long as we have a buffer zone, since a
- // polyline may be clipped into several non-connected polylines.
- const int BUFFERZONE = 1000;
- QRect devClipRect(-BUFFERZONE, -BUFFERZONE,
- pdev->width() + 2*BUFFERZONE, pdev->height() + 2*BUFFERZONE);
- d->polygonClipper.setBoundingRect(devClipRect);
-
- if (isAlienWidget) {
- // Set system clip for alien widgets painting outside the paint event.
- // This is not a problem with native windows since the windowing system
- // will handle the clip.
- QWidgetPrivate *wd = w->d_func();
- QRegion widgetClip(wd->clipRect());
- wd->clipToEffectiveMask(widgetClip);
- wd->subtractOpaqueSiblings(widgetClip);
- widgetClip.translate(w->mapTo(w->nativeParentWidget(), QPoint()));
- setSystemClip(widgetClip);
- }
-
- QPixmap::x11SetDefaultScreen(d->xinfo->screen());
-
- if (w && w->testAttribute(Qt::WA_PaintUnclipped)) { // paint direct on device
- updatePen(QPen(Qt::black));
- updateBrush(QBrush(Qt::white), QPoint());
- XSetSubwindowMode(d->dpy, d->gc, IncludeInferiors);
- XSetSubwindowMode(d->dpy, d->gc_brush, IncludeInferiors);
-#ifndef QT_NO_XRENDER
- XRenderPictureAttributes attrs;
- attrs.subwindow_mode = IncludeInferiors;
- XRenderChangePicture(d->dpy, d->picture, CPSubwindowMode, &attrs);
-#endif
- }
-
- setDirty(QPaintEngine::DirtyClipRegion);
- setDirty(QPaintEngine::DirtyPen);
- setDirty(QPaintEngine::DirtyBrush);
- setDirty(QPaintEngine::DirtyBackground);
-
- return true;
-}
-
-bool QX11PaintEngine::end()
-{
- Q_D(QX11PaintEngine);
-
-#if !defined(QT_NO_XRENDER)
- if (d->picture) {
- // reset clipping/subwindow mode on our render picture
- XRenderPictureAttributes attrs;
- attrs.subwindow_mode = ClipByChildren;
- attrs.clip_mask = XNone;
- XRenderChangePicture(d->dpy, d->picture, CPClipMask|CPSubwindowMode, &attrs);
- }
-#endif
-
- if (d->gc_brush && d->pdev->painters < 2) {
- XFreeGC(d->dpy, d->gc_brush);
- d->gc_brush = 0;
- }
-
- if (d->gc && d->pdev->painters < 2) {
- XFreeGC(d->dpy, d->gc);
- d->gc = 0;
- }
-
- // Restore system clip for alien widgets painting outside the paint event.
- if (d->pdev->devType() == QInternal::Widget && !static_cast<QWidget *>(d->pdev)->internalWinId())
- setSystemClip(QRegion());
-
- return true;
-}
-
-static bool clipLine(QLineF *line, const QRect &rect)
-{
- qreal x1 = line->x1();
- qreal x2 = line->x2();
- qreal y1 = line->y1();
- qreal y2 = line->y2();
-
- qreal left = rect.x();
- qreal right = rect.x() + rect.width() - 1;
- qreal top = rect.y();
- qreal bottom = rect.y() + rect.height() - 1;
-
- enum { Left, Right, Top, Bottom };
- // clip the lines, after cohen-sutherland, see e.g. http://www.nondot.org/~sabre/graphpro/line6.html
- int p1 = ((x1 < left) << Left)
- | ((x1 > right) << Right)
- | ((y1 < top) << Top)
- | ((y1 > bottom) << Bottom);
- int p2 = ((x2 < left) << Left)
- | ((x2 > right) << Right)
- | ((y2 < top) << Top)
- | ((y2 > bottom) << Bottom);
-
- if (p1 & p2)
- // completely outside
- return false;
-
- if (p1 | p2) {
- qreal dx = x2 - x1;
- qreal dy = y2 - y1;
-
- // clip x coordinates
- if (x1 < left) {
- y1 += dy/dx * (left - x1);
- x1 = left;
- } else if (x1 > right) {
- y1 -= dy/dx * (x1 - right);
- x1 = right;
- }
- if (x2 < left) {
- y2 += dy/dx * (left - x2);
- x2 = left;
- } else if (x2 > right) {
- y2 -= dy/dx * (x2 - right);
- x2 = right;
- }
- p1 = ((y1 < top) << Top)
- | ((y1 > bottom) << Bottom);
- p2 = ((y2 < top) << Top)
- | ((y2 > bottom) << Bottom);
- if (p1 & p2)
- return false;
- // clip y coordinates
- if (y1 < top) {
- x1 += dx/dy * (top - y1);
- y1 = top;
- } else if (y1 > bottom) {
- x1 -= dx/dy * (y1 - bottom);
- y1 = bottom;
- }
- if (y2 < top) {
- x2 += dx/dy * (top - y2);
- y2 = top;
- } else if (y2 > bottom) {
- x2 -= dx/dy * (y2 - bottom);
- y2 = bottom;
- }
- *line = QLineF(QPointF(x1, y1), QPointF(x2, y2));
- }
- return true;
-}
-
-void QX11PaintEngine::drawLines(const QLine *lines, int lineCount)
-{
- Q_ASSERT(lines);
- Q_ASSERT(lineCount);
- Q_D(QX11PaintEngine);
- if (d->has_alpha_brush
- || d->has_alpha_pen
- || d->has_custom_pen
- || (d->cpen.widthF() > 0 && d->has_complex_xform
- && !d->has_non_scaling_xform)
- || (d->render_hints & QPainter::Antialiasing)) {
- for (int i = 0; i < lineCount; ++i) {
- QPainterPath path(lines[i].p1());
- path.lineTo(lines[i].p2());
- drawPath(path);
- }
- return;
- }
-
- if (d->has_pen) {
- for (int i = 0; i < lineCount; ++i) {
- QLineF linef;
- if (d->txop == QTransform::TxNone) {
- linef = lines[i];
- } else {
- linef = d->matrix.map(QLineF(lines[i]));
- }
- if (clipLine(&linef, d->polygonClipper.boundingRect())) {
- int x1 = qRound(linef.x1() + aliasedCoordinateDelta);
- int y1 = qRound(linef.y1() + aliasedCoordinateDelta);
- int x2 = qRound(linef.x2() + aliasedCoordinateDelta);
- int y2 = qRound(linef.y2() + aliasedCoordinateDelta);
-
- XDrawLine(d->dpy, d->hd, d->gc, x1, y1, x2, y2);
- }
- }
- }
-}
-
-void QX11PaintEngine::drawLines(const QLineF *lines, int lineCount)
-{
- Q_ASSERT(lines);
- Q_ASSERT(lineCount);
- Q_D(QX11PaintEngine);
- if (d->has_alpha_brush
- || d->has_alpha_pen
- || d->has_custom_pen
- || (d->cpen.widthF() > 0 && d->has_complex_xform
- && !d->has_non_scaling_xform)
- || (d->render_hints & QPainter::Antialiasing)) {
- for (int i = 0; i < lineCount; ++i) {
- QPainterPath path(lines[i].p1());
- path.lineTo(lines[i].p2());
- drawPath(path);
- }
- return;
- }
-
- if (d->has_pen) {
- for (int i = 0; i < lineCount; ++i) {
- QLineF linef = d->matrix.map(lines[i]);
- if (clipLine(&linef, d->polygonClipper.boundingRect())) {
- int x1 = qRound(linef.x1() + aliasedCoordinateDelta);
- int y1 = qRound(linef.y1() + aliasedCoordinateDelta);
- int x2 = qRound(linef.x2() + aliasedCoordinateDelta);
- int y2 = qRound(linef.y2() + aliasedCoordinateDelta);
-
- XDrawLine(d->dpy, d->hd, d->gc, x1, y1, x2, y2);
- }
- }
- }
-}
-
-static inline QLine clipStraightLine(const QRect &clip, const QLine &l)
-{
- if (l.p1().x() == l.p2().x()) {
- int x = qBound(clip.left(), l.p1().x(), clip.right());
- int y1 = qBound(clip.top(), l.p1().y(), clip.bottom());
- int y2 = qBound(clip.top(), l.p2().y(), clip.bottom());
-
- return QLine(x, y1, x, y2);
- } else {
- Q_ASSERT(l.p1().y() == l.p2().y());
-
- int x1 = qBound(clip.left(), l.p1().x(), clip.right());
- int x2 = qBound(clip.left(), l.p2().x(), clip.right());
- int y = qBound(clip.top(), l.p1().y(), clip.bottom());
-
- return QLine(x1, y, x2, y);
- }
-}
-
-void QX11PaintEngine::drawRects(const QRectF *rects, int rectCount)
-{
- Q_D(QX11PaintEngine);
- Q_ASSERT(rects);
- Q_ASSERT(rectCount);
-
- if (rectCount != 1
- || d->has_pen
- || d->has_alpha_brush
- || d->has_complex_xform
- || d->has_custom_pen
- || d->cbrush.style() != Qt::SolidPattern)
- {
- QPaintEngine::drawRects(rects, rectCount);
- return;
- }
-
- QPoint alignedOffset;
- if (d->txop == QTransform::TxTranslate) {
- QPointF offset(d->matrix.dx(), d->matrix.dy());
- alignedOffset = offset.toPoint();
- if (offset != QPointF(alignedOffset)) {
- QPaintEngine::drawRects(rects, rectCount);
- return;
- }
- }
-
- const QRectF& r = rects[0];
- QRect alignedRect = r.toAlignedRect();
- if (r != QRectF(alignedRect)) {
- QPaintEngine::drawRects(rects, rectCount);
- return;
- }
- alignedRect.translate(alignedOffset);
-
- QRect clip(d->polygonClipper.boundingRect());
- alignedRect = alignedRect.intersected(clip);
- if (alignedRect.isEmpty())
- return;
-
- // simple-case:
- // the rectangle is pixel-aligned
- // the fill brush is just a solid non-alpha color
- // the painter transform is only integer translation
- // ignore: antialiasing and just XFillRectangles directly
- XRectangle xrect;
- xrect.x = short(alignedRect.x());
- xrect.y = short(alignedRect.y());
- xrect.width = ushort(alignedRect.width());
- xrect.height = ushort(alignedRect.height());
- XFillRectangles(d->dpy, d->hd, d->gc_brush, &xrect, 1);
-}
-
-void QX11PaintEngine::drawRects(const QRect *rects, int rectCount)
-{
- Q_D(QX11PaintEngine);
- Q_ASSERT(rects);
- Q_ASSERT(rectCount);
-
- if (d->has_alpha_pen
- || d->has_complex_xform
- || d->has_custom_pen
- || (d->render_hints & QPainter::Antialiasing))
- {
- for (int i = 0; i < rectCount; ++i) {
- QPainterPath path;
- path.addRect(rects[i]);
- drawPath(path);
- }
- return;
- }
-
- QRect clip(d->polygonClipper.boundingRect());
- QPoint offset(qRound(d->matrix.dx()), qRound(d->matrix.dy()));
-#if !defined(QT_NO_XRENDER)
- ::Picture pict = d->picture;
-
- if (X11->use_xrender && pict && d->has_brush && d->pdev_depth != 1
- && (d->has_texture || d->has_alpha_brush))
- {
- XRenderColor xc;
- if (!d->has_texture && !d->has_pattern)
- xc = X11->preMultiply(d->cbrush.color());
-
- for (int i = 0; i < rectCount; ++i) {
- QRect r(rects[i]);
- if (d->txop == QTransform::TxTranslate)
- r.translate(offset);
-
- if (r.width() == 0 || r.height() == 0) {
- if (d->has_pen) {
- const QLine l = clipStraightLine(clip, QLine(r.left(), r.top(), r.left() + r.width(), r.top() + r.height()));
- XDrawLine(d->dpy, d->hd, d->gc, l.p1().x(), l.p1().y(), l.p2().x(), l.p2().y());
- }
- continue;
- }
-
- r = r.intersected(clip);
- if (r.isEmpty())
- continue;
- if (d->has_texture || d->has_pattern) {
- XRenderComposite(d->dpy, d->composition_mode, d->current_brush, 0, pict,
- qRound(r.x() - d->bg_origin.x()), qRound(r.y() - d->bg_origin.y()),
- 0, 0, r.x(), r.y(), r.width(), r.height());
- } else {
- XRenderFillRectangle(d->dpy, d->composition_mode, pict, &xc, r.x(), r.y(), r.width(), r.height());
- }
- if (d->has_pen)
- XDrawRectangle(d->dpy, d->hd, d->gc, r.x(), r.y(), r.width(), r.height());
- }
- } else
-#endif // !QT_NO_XRENDER
- {
- if (d->has_brush && d->has_pen) {
- for (int i = 0; i < rectCount; ++i) {
- QRect r(rects[i]);
- if (d->txop == QTransform::TxTranslate)
- r.translate(offset);
-
- if (r.width() == 0 || r.height() == 0) {
- const QLine l = clipStraightLine(clip, QLine(r.left(), r.top(), r.left() + r.width(), r.top() + r.height()));
- XDrawLine(d->dpy, d->hd, d->gc, l.p1().x(), l.p1().y(), l.p2().x(), l.p2().y());
- continue;
- }
-
- r = r.intersected(clip);
- if (r.isEmpty())
- continue;
- d->setupAdaptedOrigin(r.topLeft());
- XFillRectangle(d->dpy, d->hd, d->gc_brush, r.x(), r.y(), r.width(), r.height());
- XDrawRectangle(d->dpy, d->hd, d->gc, r.x(), r.y(), r.width(), r.height());
- }
- d->resetAdaptedOrigin();
- } else {
- QVarLengthArray<XRectangle> xrects(rectCount);
- int numClipped = rectCount;
- for (int i = 0; i < rectCount; ++i) {
- QRect r(rects[i]);
- if (d->txop == QTransform::TxTranslate)
- r.translate(offset);
-
- if (r.width() == 0 || r.height() == 0) {
- --numClipped;
- if (d->has_pen) {
- const QLine l = clipStraightLine(clip, QLine(r.left(), r.top(), r.left() + r.width(), r.top() + r.height()));
- XDrawLine(d->dpy, d->hd, d->gc, l.p1().x(), l.p1().y(), l.p2().x(), l.p2().y());
- }
- continue;
- }
-
- r = r.intersected(clip);
- if (r.isEmpty()) {
- --numClipped;
- continue;
- }
- xrects[i].x = short(r.x());
- xrects[i].y = short(r.y());
- xrects[i].width = ushort(r.width());
- xrects[i].height = ushort(r.height());
- }
- if (numClipped) {
- d->setupAdaptedOrigin(rects[0].topLeft());
- if (d->has_brush)
- XFillRectangles(d->dpy, d->hd, d->gc_brush, xrects.data(), numClipped);
- else if (d->has_pen)
- XDrawRectangles(d->dpy, d->hd, d->gc, xrects.data(), numClipped);
- d->resetAdaptedOrigin();
- }
- }
- }
-}
-
-static inline void setCapStyle(int cap_style, GC gc)
-{
- ulong mask = GCCapStyle;
- XGCValues vals;
- vals.cap_style = cap_style;
- XChangeGC(X11->display, gc, mask, &vals);
-}
-
-void QX11PaintEngine::drawPoints(const QPoint *points, int pointCount)
-{
- Q_ASSERT(points);
- Q_ASSERT(pointCount);
- Q_D(QX11PaintEngine);
-
- if (!d->has_pen)
- return;
-
- // use the same test here as in drawPath to ensure that we don't use the path fallback
- // and end up in XDrawLines for pens with width <= 1
- if (d->cpen.widthF() > 1.0f
- || (X11->use_xrender && (d->has_alpha_pen || (d->render_hints & QPainter::Antialiasing)))
- || (!d->cpen.isCosmetic() && d->txop > QTransform::TxTranslate))
- {
- Qt::PenCapStyle capStyle = d->cpen.capStyle();
- if (capStyle == Qt::FlatCap) {
- setCapStyle(CapProjecting, d->gc);
- d->cpen.setCapStyle(Qt::SquareCap);
- }
- const QPoint *end = points + pointCount;
- while (points < end) {
- QPainterPath path;
- path.moveTo(*points);
- path.lineTo(points->x()+.005, points->y());
- drawPath(path);
- ++points;
- }
-
- if (capStyle == Qt::FlatCap) {
- setCapStyle(CapButt, d->gc);
- d->cpen.setCapStyle(capStyle);
- }
- return;
- }
-
- static const int BUF_SIZE = 1024;
- XPoint xPoints[BUF_SIZE];
- int i = 0, j = 0;
- while (i < pointCount) {
- while (i < pointCount && j < BUF_SIZE) {
- const QPoint &xformed = d->matrix.map(points[i]);
- int x = xformed.x();
- int y = xformed.y();
- if (x >= SHRT_MIN && y >= SHRT_MIN && x < SHRT_MAX && y < SHRT_MAX) {
- xPoints[j].x = x;
- xPoints[j].y = y;
- ++j;
- }
- ++i;
- }
- if (j)
- XDrawPoints(d->dpy, d->hd, d->gc, xPoints, j, CoordModeOrigin);
-
- j = 0;
- }
-}
-
-void QX11PaintEngine::drawPoints(const QPointF *points, int pointCount)
-{
- Q_ASSERT(points);
- Q_ASSERT(pointCount);
- Q_D(QX11PaintEngine);
-
- if (!d->has_pen)
- return;
-
- // use the same test here as in drawPath to ensure that we don't use the path fallback
- // and end up in XDrawLines for pens with width <= 1
- if (d->cpen.widthF() > 1.0f
- || (X11->use_xrender && (d->has_alpha_pen || (d->render_hints & QPainter::Antialiasing)))
- || (!d->cpen.isCosmetic() && d->txop > QTransform::TxTranslate))
- {
- Qt::PenCapStyle capStyle = d->cpen.capStyle();
- if (capStyle == Qt::FlatCap) {
- setCapStyle(CapProjecting, d->gc);
- d->cpen.setCapStyle(Qt::SquareCap);
- }
-
- const QPointF *end = points + pointCount;
- while (points < end) {
- QPainterPath path;
- path.moveTo(*points);
- path.lineTo(points->x() + 0.005, points->y());
- drawPath(path);
- ++points;
- }
- if (capStyle == Qt::FlatCap) {
- setCapStyle(CapButt, d->gc);
- d->cpen.setCapStyle(capStyle);
- }
- return;
- }
-
- static const int BUF_SIZE = 1024;
- XPoint xPoints[BUF_SIZE];
- int i = 0, j = 0;
- while (i < pointCount) {
- while (i < pointCount && j < BUF_SIZE) {
- const QPointF &xformed = d->matrix.map(points[i]);
- int x = qFloor(xformed.x());
- int y = qFloor(xformed.y());
-
- if (x >= SHRT_MIN && y >= SHRT_MIN && x < SHRT_MAX && y < SHRT_MAX) {
- xPoints[j].x = x;
- xPoints[j].y = y;
- ++j;
- }
- ++i;
- }
- if (j)
- XDrawPoints(d->dpy, d->hd, d->gc, xPoints, j, CoordModeOrigin);
-
- j = 0;
- }
-}
-
-QPainter::RenderHints QX11PaintEngine::supportedRenderHints() const
-{
-#if !defined(QT_NO_XRENDER)
- if (X11->use_xrender)
- return QPainter::Antialiasing;
-#endif
- return QFlag(0);
-}
-
-void QX11PaintEngine::updateState(const QPaintEngineState &state)
-{
- Q_D(QX11PaintEngine);
- QPaintEngine::DirtyFlags flags = state.state();
-
-
- if (flags & DirtyOpacity) {
- d->opacity = state.opacity();
- // Force update pen/brush as to get proper alpha colors propagated
- flags |= DirtyPen;
- flags |= DirtyBrush;
- }
-
- if (flags & DirtyTransform) updateMatrix(state.transform());
- if (flags & DirtyPen) updatePen(state.pen());
- if (flags & (DirtyBrush | DirtyBrushOrigin)) updateBrush(state.brush(), state.brushOrigin());
- if (flags & DirtyFont) updateFont(state.font());
-
- if (state.state() & DirtyClipEnabled) {
- if (state.isClipEnabled()) {
- QPolygonF clip_poly_dev(d->matrix.map(painter()->clipPath().toFillPolygon()));
- QPolygonF clipped_poly_dev;
- d->clipPolygon_dev(clip_poly_dev, &clipped_poly_dev);
- updateClipRegion_dev(QRegion(clipped_poly_dev.toPolygon()), Qt::ReplaceClip);
- } else {
- updateClipRegion_dev(QRegion(), Qt::NoClip);
- }
- }
-
- if (flags & DirtyClipPath) {
- QPolygonF clip_poly_dev(d->matrix.map(state.clipPath().toFillPolygon()));
- QPolygonF clipped_poly_dev;
- d->clipPolygon_dev(clip_poly_dev, &clipped_poly_dev);
- updateClipRegion_dev(QRegion(clipped_poly_dev.toPolygon(), state.clipPath().fillRule()),
- state.clipOperation());
- } else if (flags & DirtyClipRegion) {
- extern QPainterPath qt_regionToPath(const QRegion &region);
- QPainterPath clip_path = qt_regionToPath(state.clipRegion());
- QPolygonF clip_poly_dev(d->matrix.map(clip_path.toFillPolygon()));
- QPolygonF clipped_poly_dev;
- d->clipPolygon_dev(clip_poly_dev, &clipped_poly_dev);
- updateClipRegion_dev(QRegion(clipped_poly_dev.toPolygon()), state.clipOperation());
- }
- if (flags & DirtyHints) updateRenderHints(state.renderHints());
- if (flags & DirtyCompositionMode) {
- int function = GXcopy;
- if (state.compositionMode() >= QPainter::RasterOp_SourceOrDestination) {
- switch (state.compositionMode()) {
- case QPainter::RasterOp_SourceOrDestination:
- function = GXor;
- break;
- case QPainter::RasterOp_SourceAndDestination:
- function = GXand;
- break;
- case QPainter::RasterOp_SourceXorDestination:
- function = GXxor;
- break;
- case QPainter::RasterOp_NotSourceAndNotDestination:
- function = GXnor;
- break;
- case QPainter::RasterOp_NotSourceOrNotDestination:
- function = GXnand;
- break;
- case QPainter::RasterOp_NotSourceXorDestination:
- function = GXequiv;
- break;
- case QPainter::RasterOp_NotSource:
- function = GXcopyInverted;
- break;
- case QPainter::RasterOp_SourceAndNotDestination:
- function = GXandReverse;
- break;
- case QPainter::RasterOp_NotSourceAndDestination:
- function = GXandInverted;
- break;
- default:
- function = GXcopy;
- }
- }
-#if !defined(QT_NO_XRENDER)
- else {
- d->composition_mode =
- qpainterOpToXrender(state.compositionMode());
- }
-#endif
- XSetFunction(X11->display, d->gc, function);
- XSetFunction(X11->display, d->gc_brush, function);
- }
- d->decidePathFallback();
- d->decideCoordAdjust();
-}
-
-void QX11PaintEngine::updateRenderHints(QPainter::RenderHints hints)
-{
- Q_D(QX11PaintEngine);
- d->render_hints = hints;
-
-#if !defined(QT_NO_XRENDER)
- if (X11->use_xrender && d->picture) {
- XRenderPictureAttributes attrs;
- attrs.poly_edge = (hints & QPainter::Antialiasing) ? PolyEdgeSmooth : PolyEdgeSharp;
- XRenderChangePicture(d->dpy, d->picture, CPPolyEdge, &attrs);
- }
-#endif
-}
-
-void QX11PaintEngine::updatePen(const QPen &pen)
-{
- Q_D(QX11PaintEngine);
- d->cpen = pen;
- int cp = CapButt;
- int jn = JoinMiter;
- int ps = pen.style();
-
- if (d->opacity < 1.0) {
- QColor c = d->cpen.color();
- c.setAlpha(qRound(c.alpha()*d->opacity));
- d->cpen.setColor(c);
- }
-
- d->has_pen = (ps != Qt::NoPen);
- d->has_alpha_pen = (pen.color().alpha() != 255);
-
- switch (pen.capStyle()) {
- case Qt::SquareCap:
- cp = CapProjecting;
- break;
- case Qt::RoundCap:
- cp = CapRound;
- break;
- case Qt::FlatCap:
- default:
- cp = CapButt;
- break;
- }
- switch (pen.joinStyle()) {
- case Qt::BevelJoin:
- jn = JoinBevel;
- break;
- case Qt::RoundJoin:
- jn = JoinRound;
- break;
- case Qt::MiterJoin:
- default:
- jn = JoinMiter;
- break;
- }
-
- d->adapted_pen_origin = false;
-
- char dashes[10]; // custom pen dashes
- int dash_len = 0; // length of dash list
- int xStyle = LineSolid;
-
- /*
- We are emulating Windows here. Windows treats cpen.width() == 1
- (or 0) as a very special case. The fudge variable unifies this
- case with the general case.
- */
- qreal pen_width = pen.widthF();
- int scale = qRound(pen_width < 1 ? 1 : pen_width);
- int space = (pen_width < 1 && pen_width > 0 ? 1 : (2 * scale));
- int dot = 1 * scale;
- int dash = 4 * scale;
-
- d->has_custom_pen = false;
-
- switch (ps) {
- case Qt::NoPen:
- case Qt::SolidLine:
- xStyle = LineSolid;
- break;
- case Qt::DashLine:
- dashes[0] = dash;
- dashes[1] = space;
- dash_len = 2;
- xStyle = LineOnOffDash;
- break;
- case Qt::DotLine:
- dashes[0] = dot;
- dashes[1] = space;
- dash_len = 2;
- xStyle = LineOnOffDash;
- break;
- case Qt::DashDotLine:
- dashes[0] = dash;
- dashes[1] = space;
- dashes[2] = dot;
- dashes[3] = space;
- dash_len = 4;
- xStyle = LineOnOffDash;
- break;
- case Qt::DashDotDotLine:
- dashes[0] = dash;
- dashes[1] = space;
- dashes[2] = dot;
- dashes[3] = space;
- dashes[4] = dot;
- dashes[5] = space;
- dash_len = 6;
- xStyle = LineOnOffDash;
- break;
- case Qt::CustomDashLine:
- d->has_custom_pen = true;
- break;
- }
-
- ulong mask = GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth
- | GCCapStyle | GCJoinStyle | GCLineStyle;
- XGCValues vals;
- vals.graphics_exposures = false;
- if (d->pdev_depth == 1) {
- vals.foreground = qGray(pen.color().rgb()) > 127 ? 0 : 1;
- vals.background = qGray(QColor(Qt::transparent).rgb()) > 127 ? 0 : 1;
- } else if (d->pdev->devType() == QInternal::Pixmap && d->pdev_depth == 32
- && X11->use_xrender) {
- vals.foreground = pen.color().rgba();
- vals.background = QColor(Qt::transparent).rgba();
- } else {
- QColormap cmap = QColormap::instance(d->scrn);
- vals.foreground = cmap.pixel(pen.color());
- vals.background = cmap.pixel(QColor(Qt::transparent));
- }
-
-
- vals.line_width = qRound(pen.widthF());
- vals.cap_style = cp;
- vals.join_style = jn;
- vals.line_style = xStyle;
-
- XChangeGC(d->dpy, d->gc, mask, &vals);
-
- if (dash_len) { // make dash list
- XSetDashes(d->dpy, d->gc, 0, dashes, dash_len);
- }
-
- if (!d->has_clipping) { // if clipping is set the paintevent clip region is merged with the clip region
- QRegion sysClip = systemClip();
- if (!sysClip.isEmpty())
- x11SetClipRegion(d->dpy, d->gc, 0, d->picture, sysClip);
- else
- x11ClearClipRegion(d->dpy, d->gc, 0, d->picture);
- }
-}
-
-void QX11PaintEngine::updateBrush(const QBrush &brush, const QPointF &origin)
-{
- Q_D(QX11PaintEngine);
- d->cbrush = brush;
- d->bg_origin = origin;
- d->adapted_brush_origin = false;
-#if !defined(QT_NO_XRENDER)
- d->current_brush = 0;
-#endif
- if (d->opacity < 1.0) {
- QColor c = d->cbrush.color();
- c.setAlpha(qRound(c.alpha()*d->opacity));
- d->cbrush.setColor(c);
- }
-
- int s = FillSolid;
- int bs = d->cbrush.style();
- d->has_brush = (bs != Qt::NoBrush);
- d->has_pattern = bs >= Qt::Dense1Pattern && bs <= Qt::DiagCrossPattern;
- d->has_texture = bs == Qt::TexturePattern;
- d->has_alpha_brush = brush.color().alpha() != 255;
- d->has_alpha_texture = d->has_texture && d->cbrush.texture().hasAlphaChannel();
-
- ulong mask = GCForeground | GCBackground | GCGraphicsExposures
- | GCLineStyle | GCCapStyle | GCJoinStyle | GCFillStyle;
- XGCValues vals;
- vals.graphics_exposures = false;
- if (d->pdev_depth == 1) {
- vals.foreground = qGray(d->cbrush.color().rgb()) > 127 ? 0 : 1;
- vals.background = qGray(QColor(Qt::transparent).rgb()) > 127 ? 0 : 1;
- } else if (X11->use_xrender && d->pdev->devType() == QInternal::Pixmap
- && d->pdev_depth == 32) {
- vals.foreground = d->cbrush.color().rgba();
- vals.background = QColor(Qt::transparent).rgba();
- } else {
- QColormap cmap = QColormap::instance(d->scrn);
- vals.foreground = cmap.pixel(d->cbrush.color());
- vals.background = cmap.pixel(QColor(Qt::transparent));
-
- if (!X11->use_xrender && d->has_brush && !d->has_pattern && !brush.isOpaque()) {
- QPixmap pattern = qt_patternForAlpha(brush.color().alpha(), d->scrn);
- mask |= GCStipple;
- vals.stipple = pattern.handle();
- s = FillStippled;
- d->adapted_brush_origin = true;
- }
- }
- vals.cap_style = CapButt;
- vals.join_style = JoinMiter;
- vals.line_style = LineSolid;
-
- if (d->has_pattern || d->has_texture) {
- if (bs == Qt::TexturePattern) {
- d->brush_pm = qt_toX11Pixmap(d->cbrush.texture());
-#if !defined(QT_NO_XRENDER)
- if (X11->use_xrender) {
- XRenderPictureAttributes attrs;
- attrs.repeat = true;
- XRenderChangePicture(d->dpy, d->brush_pm.x11PictureHandle(), CPRepeat, &attrs);
- QX11PixmapData *data = static_cast<QX11PixmapData*>(d->brush_pm.data.data());
- if (data->mask_picture)
- XRenderChangePicture(d->dpy, data->mask_picture, CPRepeat, &attrs);
- }
-#endif
- } else {
- d->brush_pm = qt_toX11Pixmap(qt_pixmapForBrush(bs, true));
- }
- d->brush_pm.x11SetScreen(d->scrn);
- if (d->brush_pm.depth() == 1) {
- mask |= GCStipple;
- vals.stipple = d->brush_pm.handle();
- s = FillStippled;
-#if !defined(QT_NO_XRENDER)
- if (X11->use_xrender) {
- d->bitmap_texture = QPixmap(d->brush_pm.size());
- d->bitmap_texture.fill(Qt::transparent);
- d->bitmap_texture = qt_toX11Pixmap(d->bitmap_texture);
- d->bitmap_texture.x11SetScreen(d->scrn);
-
- ::Picture src = X11->getSolidFill(d->scrn, d->cbrush.color());
- XRenderComposite(d->dpy, PictOpSrc, src, d->brush_pm.x11PictureHandle(),
- d->bitmap_texture.x11PictureHandle(),
- 0, 0, d->brush_pm.width(), d->brush_pm.height(),
- 0, 0, d->brush_pm.width(), d->brush_pm.height());
-
- XRenderPictureAttributes attrs;
- attrs.repeat = true;
- XRenderChangePicture(d->dpy, d->bitmap_texture.x11PictureHandle(), CPRepeat, &attrs);
-
- d->current_brush = d->bitmap_texture.x11PictureHandle();
- }
-#endif
- } else {
- mask |= GCTile;
-#ifndef QT_NO_XRENDER
- if (d->pdev_depth == 32 && d->brush_pm.depth() != 32) {
- d->brush_pm.detach();
- QX11PixmapData *brushData = static_cast<QX11PixmapData*>(d->brush_pm.data.data());
- brushData->convertToARGB32();
- }
-#endif
- vals.tile = (d->brush_pm.depth() == d->pdev_depth
- ? d->brush_pm.handle()
- : static_cast<QX11PixmapData*>(d->brush_pm.data.data())->x11ConvertToDefaultDepth());
- s = FillTiled;
-#if !defined(QT_NO_XRENDER)
- d->current_brush = d->cbrush.texture().x11PictureHandle();
-#endif
- }
-
- mask |= GCTileStipXOrigin | GCTileStipYOrigin;
- vals.ts_x_origin = qRound(origin.x());
- vals.ts_y_origin = qRound(origin.y());
- }
-#if !defined(QT_NO_XRENDER)
- else if (d->has_alpha_brush) {
- d->current_brush = X11->getSolidFill(d->scrn, d->cbrush.color());
- }
-#endif
-
- vals.fill_style = s;
- XChangeGC(d->dpy, d->gc_brush, mask, &vals);
- if (!d->has_clipping) {
- QRegion sysClip = systemClip();
- if (!sysClip.isEmpty())
- x11SetClipRegion(d->dpy, d->gc_brush, 0, d->picture, sysClip);
- else
- x11ClearClipRegion(d->dpy, d->gc_brush, 0, d->picture);
- }
-}
-
-void QX11PaintEngine::drawEllipse(const QRectF &rect)
-{
- QRect aligned = rect.toAlignedRect();
- if (aligned == rect)
- drawEllipse(aligned);
- else
- QPaintEngine::drawEllipse(rect);
-}
-
-void QX11PaintEngine::drawEllipse(const QRect &rect)
-{
- if (rect.isEmpty()) {
- drawRects(&rect, 1);
- return;
- }
-
- Q_D(QX11PaintEngine);
- QRect devclip(SHRT_MIN, SHRT_MIN, SHRT_MAX*2 - 1, SHRT_MAX*2 - 1);
- QRect r(rect);
- if (d->txop < QTransform::TxRotate) {
- r = d->matrix.mapRect(rect);
- } else if (d->txop == QTransform::TxRotate && rect.width() == rect.height()) {
- QPainterPath path;
- path.addEllipse(rect);
- r = d->matrix.map(path).boundingRect().toRect();
- }
-
- if (d->has_alpha_brush || d->has_alpha_pen || d->has_custom_pen || (d->render_hints & QPainter::Antialiasing)
- || d->has_alpha_texture || devclip.intersected(r) != r
- || (d->has_complex_xform
- && !(d->has_non_scaling_xform && rect.width() == rect.height())))
- {
- QPainterPath path;
- path.addEllipse(rect);
- drawPath(path);
- return;
- }
-
- int x = r.x();
- int y = r.y();
- int w = r.width();
- int h = r.height();
- if (w < 1 || h < 1)
- return;
- if (w == 1 && h == 1) {
- XDrawPoint(d->dpy, d->hd, d->has_pen ? d->gc : d->gc_brush, x, y);
- return;
- }
- d->setupAdaptedOrigin(rect.topLeft());
- if (d->has_brush) { // draw filled ellipse
- XFillArc(d->dpy, d->hd, d->gc_brush, x, y, w, h, 0, 360*64);
- if (!d->has_pen) // make smoother outline
- XDrawArc(d->dpy, d->hd, d->gc_brush, x, y, w-1, h-1, 0, 360*64);
- }
- if (d->has_pen) // draw outline
- XDrawArc(d->dpy, d->hd, d->gc, x, y, w, h, 0, 360*64);
- d->resetAdaptedOrigin();
-}
-
-
-
-void QX11PaintEnginePrivate::fillPolygon_translated(const QPointF *polygonPoints, int pointCount,
- QX11PaintEnginePrivate::GCMode gcMode,
- QPaintEngine::PolygonDrawMode mode)
-{
-
- QVarLengthArray<QPointF> translated_points(pointCount);
- QPointF offset(matrix.dx(), matrix.dy());
-
- qreal offs = adjust_coords ? aliasedCoordinateDelta : 0.0;
- if (!X11->use_xrender || !(render_hints & QPainter::Antialiasing))
- offset += QPointF(aliasedCoordinateDelta, aliasedCoordinateDelta);
-
- for (int i = 0; i < pointCount; ++i) {
- translated_points[i] = polygonPoints[i] + offset;
-
- translated_points[i].rx() = qRound(translated_points[i].x()) + offs;
- translated_points[i].ry() = qRound(translated_points[i].y()) + offs;
- }
-
- fillPolygon_dev(translated_points.data(), pointCount, gcMode, mode);
-}
-
-#ifndef QT_NO_XRENDER
-static void qt_XRenderCompositeTrapezoids(Display *dpy,
- int op,
- Picture src,
- Picture dst,
- _Xconst XRenderPictFormat *maskFormat,
- int xSrc,
- int ySrc,
- const XTrapezoid *traps, int size)
-{
- const int MAX_TRAPS = 50000;
- while (size) {
- int to_draw = size;
- if (to_draw > MAX_TRAPS)
- to_draw = MAX_TRAPS;
- XRenderCompositeTrapezoids(dpy, op, src, dst,
- maskFormat,
- xSrc, ySrc,
- traps, to_draw);
- size -= to_draw;
- traps += to_draw;
- }
-}
-#endif
-
-void QX11PaintEnginePrivate::fillPolygon_dev(const QPointF *polygonPoints, int pointCount,
- QX11PaintEnginePrivate::GCMode gcMode,
- QPaintEngine::PolygonDrawMode mode)
-{
- Q_Q(QX11PaintEngine);
-
- int clippedCount = 0;
- qt_float_point *clippedPoints = 0;
-
-#ifndef QT_NO_XRENDER
- //can change if we switch to pen if gcMode != BrushGC
- bool has_fill_texture = has_texture;
- bool has_fill_pattern = has_pattern;
- ::Picture src;
-#endif
- QBrush fill;
- GC fill_gc;
- if (gcMode == BrushGC) {
- fill = cbrush;
- fill_gc = gc_brush;
-#ifndef QT_NO_XRENDER
- if (current_brush)
- src = current_brush;
- else
- src = X11->getSolidFill(scrn, fill.color());
-#endif
- } else {
- fill = QBrush(cpen.brush());
- fill_gc = gc;
-#ifndef QT_NO_XRENDER
- //we use the pens brush
- has_fill_texture = (fill.style() == Qt::TexturePattern);
- has_fill_pattern = (fill.style() >= Qt::Dense1Pattern && fill.style() <= Qt::DiagCrossPattern);
- if (has_fill_texture)
- src = fill.texture().x11PictureHandle();
- else if (has_fill_pattern)
- src = getPatternFill(scrn, fill);
- else
- src = X11->getSolidFill(scrn, fill.color());
-#endif
- }
-
- polygonClipper.clipPolygon((qt_float_point *) polygonPoints, pointCount,
- &clippedPoints, &clippedCount);
-
-#ifndef QT_NO_XRENDER
- bool solid_fill = fill.color().alpha() == 255;
- if (has_fill_texture && fill.texture().depth() == 1 && solid_fill) {
- has_fill_texture = false;
- has_fill_pattern = true;
- }
-
- bool antialias = render_hints & QPainter::Antialiasing;
-
- if (X11->use_xrender
- && picture
- && !has_fill_pattern
- && (clippedCount > 0)
- && (fill.style() != Qt::NoBrush)
- && ((has_fill_texture && fill.texture().hasAlpha()) || antialias || !solid_fill || has_alpha_pen != has_alpha_brush))
- {
- if (tessellator->size > 0) {
- XRenderPictureAttributes attrs;
- attrs.poly_edge = antialias ? PolyEdgeSmooth : PolyEdgeSharp;
- XRenderChangePicture(dpy, picture, CPPolyEdge, &attrs);
- int x_offset = int(XFixedToDouble(tessellator->traps[0].left.p1.x) - bg_origin.x());
- int y_offset = int(XFixedToDouble(tessellator->traps[0].left.p1.y) - bg_origin.y());
- qt_XRenderCompositeTrapezoids(dpy, composition_mode, src, picture,
- antialias
- ? XRenderFindStandardFormat(dpy, PictStandardA8)
- : XRenderFindStandardFormat(dpy, PictStandardA1),
- x_offset, y_offset,
- tessellator->traps, tessellator->size);
- tessellator->done();
- }
- } else
-#endif
- if (fill.style() != Qt::NoBrush) {
- if (clippedCount > 200000) {
- QPolygon poly;
- for (int i = 0; i < clippedCount; ++i)
- poly << QPoint(qFloor(clippedPoints[i].x), qFloor(clippedPoints[i].y));
-
- const QRect bounds = poly.boundingRect();
- const QRect aligned = bounds
- & QRect(QPoint(), QSize(pdev->width(), pdev->height()));
-
- QImage img(aligned.size(), QImage::Format_ARGB32_Premultiplied);
- img.fill(0);
-
- QPainter painter(&img);
- painter.translate(-aligned.x(), -aligned.y());
- painter.setPen(Qt::NoPen);
- painter.setBrush(fill);
- if (gcMode == BrushGC)
- painter.setBrushOrigin(q->painter()->brushOrigin());
- painter.drawPolygon(poly);
- painter.end();
-
- q->drawImage(aligned, img, img.rect(), Qt::AutoColor);
- } else if (clippedCount > 0) {
- QVarLengthArray<XPoint> xpoints(clippedCount);
- for (int i = 0; i < clippedCount; ++i) {
- xpoints[i].x = qFloor(clippedPoints[i].x);
- xpoints[i].y = qFloor(clippedPoints[i].y);
- }
- if (mode == QPaintEngine::WindingMode)
- XSetFillRule(dpy, fill_gc, WindingRule);
- setupAdaptedOrigin(QPoint(xpoints[0].x, xpoints[0].y));
- XFillPolygon(dpy, hd, fill_gc,
- xpoints.data(), clippedCount,
- mode == QPaintEngine::ConvexMode ? Convex : Complex, CoordModeOrigin);
- resetAdaptedOrigin();
- if (mode == QPaintEngine::WindingMode)
- XSetFillRule(dpy, fill_gc, EvenOddRule);
- }
- }
-}
-
-void QX11PaintEnginePrivate::strokePolygon_translated(const QPointF *polygonPoints, int pointCount, bool close)
-{
- QVarLengthArray<QPointF> translated_points(pointCount);
- QPointF offset(matrix.dx(), matrix.dy());
- for (int i = 0; i < pointCount; ++i)
- translated_points[i] = polygonPoints[i] + offset;
- strokePolygon_dev(translated_points.data(), pointCount, close);
-}
-
-void QX11PaintEnginePrivate::strokePolygon_dev(const QPointF *polygonPoints, int pointCount, bool close)
-{
- int clippedCount = 0;
- qt_float_point *clippedPoints = 0;
- polygonClipper.clipPolygon((qt_float_point *) polygonPoints, pointCount,
- &clippedPoints, &clippedCount, close);
-
- if (clippedCount > 0) {
- QVarLengthArray<XPoint> xpoints(clippedCount);
- for (int i = 0; i < clippedCount; ++i) {
- xpoints[i].x = qRound(clippedPoints[i].x + aliasedCoordinateDelta);
- xpoints[i].y = qRound(clippedPoints[i].y + aliasedCoordinateDelta);
- }
- uint numberPoints = qMin(clippedCount, xlibMaxLinePoints);
- XPoint *pts = xpoints.data();
- XDrawLines(dpy, hd, gc, pts, numberPoints, CoordModeOrigin);
- pts += numberPoints;
- clippedCount -= numberPoints;
- numberPoints = qMin(clippedCount, xlibMaxLinePoints-1);
- while (clippedCount) {
- XDrawLines(dpy, hd, gc, pts-1, numberPoints+1, CoordModeOrigin);
- pts += numberPoints;
- clippedCount -= numberPoints;
- numberPoints = qMin(clippedCount, xlibMaxLinePoints-1);
- }
- }
-}
-
-void QX11PaintEngine::drawPolygon(const QPointF *polygonPoints, int pointCount, PolygonDrawMode mode)
-{
- Q_D(QX11PaintEngine);
- if (d->use_path_fallback) {
- QPainterPath path(polygonPoints[0]);
- for (int i = 1; i < pointCount; ++i)
- path.lineTo(polygonPoints[i]);
- if (mode == PolylineMode) {
- QBrush oldBrush = d->cbrush;
- d->cbrush = QBrush(Qt::NoBrush);
- path.setFillRule(Qt::WindingFill);
- drawPath(path);
- d->cbrush = oldBrush;
- } else {
- path.setFillRule(mode == OddEvenMode ? Qt::OddEvenFill : Qt::WindingFill);
- path.closeSubpath();
- drawPath(path);
- }
- return;
- }
- if (mode != PolylineMode && d->has_brush)
- d->fillPolygon_translated(polygonPoints, pointCount, QX11PaintEnginePrivate::BrushGC, mode);
-
- if (d->has_pen)
- d->strokePolygon_translated(polygonPoints, pointCount, mode != PolylineMode);
-}
-
-
-void QX11PaintEnginePrivate::fillPath(const QPainterPath &path, QX11PaintEnginePrivate::GCMode gc_mode, bool transform)
-{
- qreal offs = adjust_coords ? aliasedCoordinateDelta : 0.0;
-
- QPainterPath clippedPath;
- QPainterPath clipPath;
- clipPath.addRect(polygonClipper.boundingRect());
-
- if (transform)
- clippedPath = (path*matrix).intersected(clipPath);
- else
- clippedPath = path.intersected(clipPath);
-
- QList<QPolygonF> polys = clippedPath.toFillPolygons();
- for (int i = 0; i < polys.size(); ++i) {
- QVarLengthArray<QPointF> translated_points(polys.at(i).size());
-
- for (int j = 0; j < polys.at(i).size(); ++j) {
- translated_points[j] = polys.at(i).at(j);
- if (!X11->use_xrender || !(render_hints & QPainter::Antialiasing)) {
- translated_points[j].rx() = qRound(translated_points[j].rx() + aliasedCoordinateDelta) + offs;
- translated_points[j].ry() = qRound(translated_points[j].ry() + aliasedCoordinateDelta) + offs;
- }
- }
-
- fillPolygon_dev(translated_points.data(), polys.at(i).size(), gc_mode,
- path.fillRule() == Qt::OddEvenFill ? QPaintEngine::OddEvenMode : QPaintEngine::WindingMode);
- }
-}
-
-void QX11PaintEngine::drawPath(const QPainterPath &path)
-{
- Q_D(QX11PaintEngine);
- if (path.isEmpty())
- return;
-
- if (d->has_brush)
- d->fillPath(path, QX11PaintEnginePrivate::BrushGC, true);
- if (d->has_pen
- && ((X11->use_xrender && (d->has_alpha_pen || (d->render_hints & QPainter::Antialiasing)))
- || (!d->cpen.isCosmetic() && d->txop > QTransform::TxTranslate
- && !d->has_non_scaling_xform)
- || (d->cpen.style() == Qt::CustomDashLine))) {
- QPainterPathStroker stroker;
- if (d->cpen.style() == Qt::CustomDashLine) {
- stroker.setDashPattern(d->cpen.dashPattern());
- stroker.setDashOffset(d->cpen.dashOffset());
- } else {
- stroker.setDashPattern(d->cpen.style());
- }
- stroker.setCapStyle(d->cpen.capStyle());
- stroker.setJoinStyle(d->cpen.joinStyle());
- QPainterPath stroke;
- qreal width = d->cpen.widthF();
- QPolygonF poly;
- QRectF deviceRect(0, 0, d->pdev->width(), d->pdev->height());
- // necessary to get aliased alphablended primitives to be drawn correctly
- if (d->cpen.isCosmetic() || d->has_scaling_xform) {
- if (d->cpen.isCosmetic())
- stroker.setWidth(width == 0 ? 1 : width);
- else
- stroker.setWidth(width * d->xform_scale);
- stroker.d_ptr->stroker.setClipRect(deviceRect);
- stroke = stroker.createStroke(path * d->matrix);
- if (stroke.isEmpty())
- return;
- stroke.setFillRule(Qt::WindingFill);
- d->fillPath(stroke, QX11PaintEnginePrivate::PenGC, false);
- } else {
- stroker.setWidth(width);
- stroker.d_ptr->stroker.setClipRect(d->matrix.inverted().mapRect(deviceRect));
- stroke = stroker.createStroke(path);
- if (stroke.isEmpty())
- return;
- stroke.setFillRule(Qt::WindingFill);
- d->fillPath(stroke, QX11PaintEnginePrivate::PenGC, true);
- }
- } else if (d->has_pen) {
- // if we have a cosmetic pen - use XDrawLine() for speed
- QList<QPolygonF> polys = path.toSubpathPolygons(d->matrix);
- for (int i = 0; i < polys.size(); ++i)
- d->strokePolygon_dev(polys.at(i).data(), polys.at(i).size(), false);
- }
-}
-
-Q_GUI_EXPORT void qt_x11_drawImage(const QRect &rect, const QPoint &pos, const QImage &image,
- Drawable hd, GC gc, Display *dpy, Visual *visual, int depth)
-{
- Q_ASSERT(image.format() == QImage::Format_RGB32);
- Q_ASSERT(image.depth() == 32);
-
- XImage *xi;
- // Note: this code assumes either RGB or BGR, 8 bpc server layouts
- const uint red_mask = (uint) visual->red_mask;
- bool bgr_layout = (red_mask == 0xff);
-
- const int w = rect.width();
- const int h = rect.height();
-
- QImage im;
- int image_byte_order = ImageByteOrder(X11->display);
- if ((QSysInfo::ByteOrder == QSysInfo::BigEndian && ((image_byte_order == LSBFirst) || bgr_layout))
- || (image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian)
- || (image_byte_order == LSBFirst && bgr_layout))
- {
- im = image.copy(rect);
- const int iw = im.bytesPerLine() / 4;
- uint *data = (uint *)im.bits();
- for (int i=0; i < h; i++) {
- uint *p = data;
- uint *end = p + w;
- if (bgr_layout && image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian) {
- while (p < end) {
- *p = ((*p << 8) & 0xffffff00) | ((*p >> 24) & 0x000000ff);
- p++;
- }
- } else if ((image_byte_order == LSBFirst && QSysInfo::ByteOrder == QSysInfo::BigEndian)
- || (image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian)) {
- while (p < end) {
- *p = ((*p << 24) & 0xff000000) | ((*p << 8) & 0x00ff0000)
- | ((*p >> 8) & 0x0000ff00) | ((*p >> 24) & 0x000000ff);
- p++;
- }
- } else if ((image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::BigEndian)
- || (image_byte_order == LSBFirst && bgr_layout))
- {
- while (p < end) {
- *p = ((*p << 16) & 0x00ff0000) | ((*p >> 16) & 0x000000ff)
- | ((*p ) & 0xff00ff00);
- p++;
- }
- }
- data += iw;
- }
- xi = XCreateImage(dpy, visual, depth, ZPixmap,
- 0, (char *) im.bits(), w, h, 32, im.bytesPerLine());
- } else {
- xi = XCreateImage(dpy, visual, depth, ZPixmap,
- 0, (char *) image.scanLine(rect.y())+rect.x()*sizeof(uint), w, h, 32, image.bytesPerLine());
- }
- XPutImage(dpy, hd, gc, xi, 0, 0, pos.x(), pos.y(), w, h);
- xi->data = 0; // QImage owns these bits
- XDestroyImage(xi);
-}
-
-void QX11PaintEngine::drawImage(const QRectF &r, const QImage &image, const QRectF &sr, Qt::ImageConversionFlags flags)
-{
- Q_D(QX11PaintEngine);
-
- if (image.format() == QImage::Format_RGB32
- && d->pdev_depth >= 24 && image.depth() == 32
- && r.size() == sr.size())
- {
- int sx = qRound(sr.x());
- int sy = qRound(sr.y());
- int x = qRound(r.x());
- int y = qRound(r.y());
- int w = qRound(r.width());
- int h = qRound(r.height());
-
- qt_x11_drawImage(QRect(sx, sy, w, h), QPoint(x, y), image, d->hd, d->gc, d->dpy,
- (Visual *)d->xinfo->visual(), d->pdev_depth);
- } else {
- QPaintEngine::drawImage(r, image, sr, flags);
- }
-}
-
-void QX11PaintEngine::drawPixmap(const QRectF &r, const QPixmap &px, const QRectF &_sr)
-{
- Q_D(QX11PaintEngine);
- QRectF sr = _sr;
- int x = qRound(r.x());
- int y = qRound(r.y());
- int sx = qRound(sr.x());
- int sy = qRound(sr.y());
- int sw = qRound(sr.width());
- int sh = qRound(sr.height());
-
- QPixmap pixmap = qt_toX11Pixmap(px);
- if(pixmap.isNull())
- return;
-
- if ((d->xinfo && d->xinfo->screen() != pixmap.x11Info().screen())
- || (pixmap.x11Info().screen() != DefaultScreen(X11->display))) {
- QPixmap* p = const_cast<QPixmap *>(&pixmap);
- p->x11SetScreen(d->xinfo ? d->xinfo->screen() : DefaultScreen(X11->display));
- }
-
- QPixmap::x11SetDefaultScreen(pixmap.x11Info().screen());
-
-#ifndef QT_NO_XRENDER
- ::Picture src_pict = static_cast<QX11PixmapData*>(pixmap.data.data())->picture;
- if (src_pict && d->picture) {
- const int pDepth = pixmap.depth();
- if (pDepth == 1 && (d->has_alpha_pen)) {
- qt_render_bitmap(d->dpy, d->scrn, src_pict, d->picture,
- sx, sy, x, y, sw, sh, d->cpen);
- return;
- } else if (pDepth != 1 && (pDepth == 32 || pDepth != d->pdev_depth)) {
- XRenderComposite(d->dpy, d->composition_mode,
- src_pict, 0, d->picture, sx, sy, 0, 0, x, y, sw, sh);
- return;
- }
- }
-#endif
-
- bool mono_src = pixmap.depth() == 1;
- bool mono_dst = d->pdev_depth == 1;
- bool restore_clip = false;
-
- if (static_cast<QX11PixmapData*>(pixmap.data.data())->x11_mask) { // pixmap has a mask
- QBitmap comb(sw, sh);
- GC cgc = XCreateGC(d->dpy, comb.handle(), 0, 0);
- XSetForeground(d->dpy, cgc, 0);
- XFillRectangle(d->dpy, comb.handle(), cgc, 0, 0, sw, sh);
- XSetBackground(d->dpy, cgc, 0);
- XSetForeground(d->dpy, cgc, 1);
- if (!d->crgn.isEmpty()) {
- int num;
- XRectangle *rects = (XRectangle *)qt_getClipRects(d->crgn, num);
- XSetClipRectangles(d->dpy, cgc, -x, -y, rects, num, Unsorted);
- } else if (d->has_clipping) {
- XSetClipRectangles(d->dpy, cgc, 0, 0, 0, 0, Unsorted);
- }
- XSetFillStyle(d->dpy, cgc, FillOpaqueStippled);
- XSetTSOrigin(d->dpy, cgc, -sx, -sy);
- XSetStipple(d->dpy, cgc,
- static_cast<QX11PixmapData*>(pixmap.data.data())->x11_mask);
- XFillRectangle(d->dpy, comb.handle(), cgc, 0, 0, sw, sh);
- XFreeGC(d->dpy, cgc);
-
- XSetClipOrigin(d->dpy, d->gc, x, y);
- XSetClipMask(d->dpy, d->gc, comb.handle());
- restore_clip = true;
- }
-
- if (mono_src) {
- if (!d->crgn.isEmpty()) {
- Pixmap comb = XCreatePixmap(d->dpy, d->hd, sw, sh, 1);
- GC cgc = XCreateGC(d->dpy, comb, 0, 0);
- XSetForeground(d->dpy, cgc, 0);
- XFillRectangle(d->dpy, comb, cgc, 0, 0, sw, sh);
- int num;
- XRectangle *rects = (XRectangle *)qt_getClipRects(d->crgn, num);
- XSetClipRectangles(d->dpy, cgc, -x, -y, rects, num, Unsorted);
- XCopyArea(d->dpy, pixmap.handle(), comb, cgc, sx, sy, sw, sh, 0, 0);
- XFreeGC(d->dpy, cgc);
-
- XSetClipMask(d->dpy, d->gc, comb);
- XSetClipOrigin(d->dpy, d->gc, x, y);
- XFreePixmap(d->dpy, comb);
- } else {
- XSetClipMask(d->dpy, d->gc, pixmap.handle());
- XSetClipOrigin(d->dpy, d->gc, x - sx, y - sy);
- }
-
- if (mono_dst) {
- XSetForeground(d->dpy, d->gc, qGray(d->cpen.color().rgb()) > 127 ? 0 : 1);
- } else {
- QColormap cmap = QColormap::instance(d->scrn);
- XSetForeground(d->dpy, d->gc, cmap.pixel(d->cpen.color()));
- }
- XFillRectangle(d->dpy, d->hd, d->gc, x, y, sw, sh);
- restore_clip = true;
- } else if (mono_dst && !mono_src) {
- QBitmap bitmap(pixmap);
- XCopyArea(d->dpy, bitmap.handle(), d->hd, d->gc, sx, sy, sw, sh, x, y);
- } else {
- XCopyArea(d->dpy, pixmap.handle(), d->hd, d->gc, sx, sy, sw, sh, x, y);
- }
-
- if (d->pdev->devType() == QInternal::Pixmap) {
- const QPixmap *px = static_cast<const QPixmap*>(d->pdev);
- Pixmap src_mask = static_cast<QX11PixmapData*>(pixmap.data.data())->x11_mask;
- Pixmap dst_mask = static_cast<QX11PixmapData*>(px->data.data())->x11_mask;
- if (dst_mask) {
- GC cgc = XCreateGC(d->dpy, dst_mask, 0, 0);
- if (src_mask) { // copy src mask into dst mask
- XCopyArea(d->dpy, src_mask, dst_mask, cgc, sx, sy, sw, sh, x, y);
- } else { // no src mask, but make sure the area copied is opaque in dest
- XSetBackground(d->dpy, cgc, 0);
- XSetForeground(d->dpy, cgc, 1);
- XFillRectangle(d->dpy, dst_mask, cgc, x, y, sw, sh);
- }
- XFreeGC(d->dpy, cgc);
- }
- }
-
- if (restore_clip) {
- XSetClipOrigin(d->dpy, d->gc, 0, 0);
- int num;
- XRectangle *rects = (XRectangle *)qt_getClipRects(d->crgn, num);
- if (num == 0)
- XSetClipMask(d->dpy, d->gc, XNone);
- else
- XSetClipRectangles(d->dpy, d->gc, 0, 0, rects, num, Unsorted);
- }
-}
-
-void QX11PaintEngine::updateMatrix(const QTransform &mtx)
-{
- Q_D(QX11PaintEngine);
- d->txop = mtx.type();
- d->matrix = mtx;
-
- d->has_complex_xform = (d->txop > QTransform::TxTranslate);
-
- extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale);
- bool scaling = qt_scaleForTransform(d->matrix, &d->xform_scale);
- d->has_scaling_xform = scaling && d->xform_scale != 1.0;
- d->has_non_scaling_xform = scaling && d->xform_scale == 1.0;
-}
-
-/*
- NB! the clip region is expected to be in dev coordinates
-*/
-void QX11PaintEngine::updateClipRegion_dev(const QRegion &clipRegion, Qt::ClipOperation op)
-{
- Q_D(QX11PaintEngine);
- QRegion sysClip = systemClip();
- if (op == Qt::NoClip) {
- d->has_clipping = false;
- d->crgn = sysClip;
- if (!sysClip.isEmpty()) {
- x11SetClipRegion(d->dpy, d->gc, d->gc_brush, d->picture, sysClip);
- } else {
- x11ClearClipRegion(d->dpy, d->gc, d->gc_brush, d->picture);
- }
- return;
- }
-
- switch (op) {
- case Qt::IntersectClip:
- if (d->has_clipping) {
- d->crgn &= clipRegion;
- break;
- }
- // fall through
- case Qt::ReplaceClip:
- if (!sysClip.isEmpty())
- d->crgn = clipRegion.intersected(sysClip);
- else
- d->crgn = clipRegion;
- break;
- case Qt::UniteClip:
- d->crgn |= clipRegion;
- if (!sysClip.isEmpty())
- d->crgn = d->crgn.intersected(sysClip);
- break;
- default:
- break;
- }
- d->has_clipping = true;
- x11SetClipRegion(d->dpy, d->gc, d->gc_brush, d->picture, d->crgn);
-}
-
-void QX11PaintEngine::updateFont(const QFont &)
-{
-}
-
-Qt::HANDLE QX11PaintEngine::handle() const
-{
- Q_D(const QX11PaintEngine);
- Q_ASSERT(isActive());
- Q_ASSERT(d->hd);
- return d->hd;
-}
-
-extern void qt_draw_tile(QPaintEngine *, qreal, qreal, qreal, qreal, const QPixmap &,
- qreal, qreal);
-
-void QX11PaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &p)
-{
- int x = qRound(r.x());
- int y = qRound(r.y());
- int w = qRound(r.width());
- int h = qRound(r.height());
- int sx = qRound(p.x());
- int sy = qRound(p.y());
-
- bool mono_src = pixmap.depth() == 1;
- Q_D(QX11PaintEngine);
-
- if ((d->xinfo && d->xinfo->screen() != pixmap.x11Info().screen())
- || (pixmap.x11Info().screen() != DefaultScreen(X11->display))) {
- QPixmap* p = const_cast<QPixmap *>(&pixmap);
- p->x11SetScreen(d->xinfo ? d->xinfo->screen() : DefaultScreen(X11->display));
- }
-
- QPixmap::x11SetDefaultScreen(pixmap.x11Info().screen());
-
-#ifndef QT_NO_XRENDER
- if (X11->use_xrender && d->picture && pixmap.x11PictureHandle()) {
-#if 0
- // ### Qt 5: enable this
- XRenderPictureAttributes attrs;
- attrs.repeat = true;
- XRenderChangePicture(d->dpy, pixmap.x11PictureHandle(), CPRepeat, &attrs);
-
- if (mono_src) {
- qt_render_bitmap(d->dpy, d->scrn, pixmap.x11PictureHandle(), d->picture,
- sx, sy, x, y, w, h, d->cpen);
- } else {
- XRenderComposite(d->dpy, d->composition_mode,
- pixmap.x11PictureHandle(), XNone, d->picture,
- sx, sy, 0, 0, x, y, w, h);
- }
-#else
- const int numTiles = (w / pixmap.width()) * (h / pixmap.height());
- if (numTiles < 100) {
- // this is essentially qt_draw_tile(), inlined for
- // the XRenderComposite call
- int yPos, xPos, drawH, drawW, yOff, xOff;
- yPos = y;
- yOff = sy;
- while(yPos < y + h) {
- drawH = pixmap.height() - yOff; // Cropping first row
- if (yPos + drawH > y + h) // Cropping last row
- drawH = y + h - yPos;
- xPos = x;
- xOff = sx;
- while(xPos < x + w) {
- drawW = pixmap.width() - xOff; // Cropping first column
- if (xPos + drawW > x + w) // Cropping last column
- drawW = x + w - xPos;
- if (mono_src) {
- qt_render_bitmap(d->dpy, d->scrn, pixmap.x11PictureHandle(), d->picture,
- xOff, yOff, xPos, yPos, drawW, drawH, d->cpen);
- } else {
- XRenderComposite(d->dpy, d->composition_mode,
- pixmap.x11PictureHandle(), XNone, d->picture,
- xOff, yOff, 0, 0, xPos, yPos, drawW, drawH);
- }
- xPos += drawW;
- xOff = 0;
- }
- yPos += drawH;
- yOff = 0;
- }
- } else {
- w = qMin(w, d->pdev->width() - x);
- h = qMin(h, d->pdev->height() - y);
- if (w <= 0 || h <= 0)
- return;
-
- const int pw = w + sx;
- const int ph = h + sy;
- QPixmap pm(pw, ph);
- if (pixmap.hasAlpha() || mono_src)
- pm.fill(Qt::transparent);
-
- const int mode = pixmap.hasAlpha() ? PictOpOver : PictOpSrc;
- const ::Picture pmPicture = pm.x11PictureHandle();
-
- // first tile
- XRenderComposite(d->dpy, mode,
- pixmap.x11PictureHandle(), XNone, pmPicture,
- 0, 0, 0, 0, 0, 0, qMin(pw, pixmap.width()), qMin(ph, pixmap.height()));
-
- // first row of tiles
- int xPos = pixmap.width();
- const int sh = qMin(ph, pixmap.height());
- while (xPos < pw) {
- const int sw = qMin(xPos, pw - xPos);
- XRenderComposite(d->dpy, mode,
- pmPicture, XNone, pmPicture,
- 0, 0, 0, 0, xPos, 0, sw, sh);
- xPos *= 2;
- }
-
- // remaining rows
- int yPos = pixmap.height();
- const int sw = pw;
- while (yPos < ph) {
- const int sh = qMin(yPos, ph - yPos);
- XRenderComposite(d->dpy, mode,
- pmPicture, XNone, pmPicture,
- 0, 0, 0, 0, 0, yPos, sw, sh);
- yPos *= 2;
- }
-
- // composite
- if (mono_src)
- qt_render_bitmap(d->dpy, d->scrn, pmPicture, d->picture,
- sx, sy, x, y, w, h, d->cpen);
- else
- XRenderComposite(d->dpy, d->composition_mode,
- pmPicture, XNone, d->picture,
- sx, sy, 0, 0, x, y, w, h);
- }
-#endif
- } else
-#endif // !QT_NO_XRENDER
- if (pixmap.depth() > 1 && !static_cast<QX11PixmapData*>(pixmap.data.data())->x11_mask) {
- XSetTile(d->dpy, d->gc, pixmap.handle());
- XSetFillStyle(d->dpy, d->gc, FillTiled);
- XSetTSOrigin(d->dpy, d->gc, x-sx, y-sy);
- XFillRectangle(d->dpy, d->hd, d->gc, x, y, w, h);
- XSetTSOrigin(d->dpy, d->gc, 0, 0);
- XSetFillStyle(d->dpy, d->gc, FillSolid);
- } else {
- qt_draw_tile(this, x, y, w, h, pixmap, sx, sy);
- }
-}
-
-void QX11PaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem)
-{
- const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem);
-
- switch(ti.fontEngine->type()) {
- case QFontEngine::TestFontEngine:
- case QFontEngine::Box:
- d_func()->drawBoxTextItem(p, ti);
- break;
- case QFontEngine::XLFD:
- drawXLFD(p, ti);
- break;
-#ifndef QT_NO_FONTCONFIG
- case QFontEngine::Freetype:
- drawFreetype(p, ti);
- break;
-#endif
- default:
- Q_ASSERT(false);
- }
-}
-
-void QX11PaintEngine::drawXLFD(const QPointF &p, const QTextItemInt &ti)
-{
- Q_D(QX11PaintEngine);
-
- if (d->txop > QTransform::TxTranslate) {
- // XServer or font don't support server side transformations, need to do it by hand
- QPaintEngine::drawTextItem(p, ti);
- return;
- }
-
- if (!ti.glyphs.numGlyphs)
- return;
-
- QVarLengthArray<QFixedPoint> positions;
- QVarLengthArray<glyph_t> glyphs;
- QTransform matrix = d->matrix;
- matrix.translate(p.x(), p.y());
- ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
- if (glyphs.size() == 0)
- return;
-
- QFontEngineXLFD *xlfd = static_cast<QFontEngineXLFD *>(ti.fontEngine);
- Qt::HANDLE font_id = xlfd->fontStruct()->fid;
-
- XSetFont(d->dpy, d->gc, font_id);
-
- const QFixed offs = QFixed::fromReal(aliasedCoordinateDelta);
- for (int i = 0; i < glyphs.size(); i++) {
- int xp = qRound(positions[i].x + offs);
- int yp = qRound(positions[i].y + offs);
- if (xp < SHRT_MAX && xp > SHRT_MIN && yp > SHRT_MIN && yp < SHRT_MAX) {
- XChar2b ch;
- ch.byte1 = glyphs[i] >> 8;
- ch.byte2 = glyphs[i] & 0xff;
- XDrawString16(d->dpy, d->hd, d->gc, xp, yp, &ch, 1);
- }
- }
-}
-
-#ifndef QT_NO_FONTCONFIG
-static QPainterPath path_for_glyphs(const QVarLengthArray<glyph_t> &glyphs,
- const QVarLengthArray<QFixedPoint> &positions,
- const QFontEngineFT *ft)
-{
- QPainterPath path;
- path.setFillRule(Qt::WindingFill);
- ft->lockFace();
- int i = 0;
- while (i < glyphs.size()) {
- QFontEngineFT::Glyph *glyph = ft->loadGlyph(glyphs[i], QFontEngineFT::Format_Mono);
- // #### fix case where we don't get a glyph
- if (!glyph)
- break;
-
- Q_ASSERT(glyph->format == QFontEngineFT::Format_Mono);
- int n = 0;
- int h = glyph->height;
- int xp = qRound(positions[i].x);
- int yp = qRound(positions[i].y);
-
- xp += glyph->x;
- yp += -glyph->y + glyph->height;
- int pitch = ((glyph->width + 31) & ~31) >> 3;
-
- uchar *src = glyph->data;
- while (h--) {
- for (int x = 0; x < glyph->width; ++x) {
- bool set = src[x >> 3] & (0x80 >> (x & 7));
- if (set) {
- QRect r(xp + x, yp - h, 1, 1);
- while (x < glyph->width-1 && src[(x+1) >> 3] & (0x80 >> ((x+1) & 7))) {
- ++x;
- r.setRight(r.right()+1);
- }
-
- path.addRect(r);
- ++n;
- }
- }
- src += pitch;
- }
- ++i;
- }
- ft->unlockFace();
- return path;
-}
-
-void QX11PaintEngine::drawFreetype(const QPointF &p, const QTextItemInt &ti)
-{
- Q_D(QX11PaintEngine);
- if (!ti.glyphs.numGlyphs)
- return;
-
- QFontEngineX11FT *ft = static_cast<QFontEngineX11FT *>(ti.fontEngine);
-
- if (!d->cpen.isSolid()) {
- QPaintEngine::drawTextItem(p, ti);
- return;
- }
-
- const bool xrenderPath = (X11->use_xrender
- && !(d->pdev->devType() == QInternal::Pixmap
- && static_cast<const QPixmap *>(d->pdev)->data->pixelType() == QPixmapData::BitmapType));
-
- QVarLengthArray<QFixedPoint> positions;
- QVarLengthArray<glyph_t> glyphs;
- QTransform matrix;
-
- if (xrenderPath)
- matrix = d->matrix;
- matrix.translate(p.x(), p.y());
- ft->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
- if (glyphs.count() == 0)
- return;
-
-#ifndef QT_NO_XRENDER
- QFontEngineFT::QGlyphSet *set = ft->defaultGlyphs();
- if (d->txop >= QTransform::TxScale && xrenderPath)
- set = ft->loadTransformedGlyphSet(d->matrix);
-
- if (!set || set->outline_drawing
- || !ft->loadGlyphs(set, glyphs.constData(), glyphs.size(), positions.constData(), QFontEngineFT::Format_Render))
- {
- QPaintEngine::drawTextItem(p, ti);
- return;
- }
-
- if (xrenderPath) {
- GlyphSet glyphSet = set->id;
- const QColor &pen = d->cpen.color();
- ::Picture src = X11->getSolidFill(d->scrn, pen);
- XRenderPictFormat *maskFormat = 0;
- if (ft->xglyph_format != PictStandardA1)
- maskFormat = XRenderFindStandardFormat(X11->display, ft->xglyph_format);
-
- enum { t_min = SHRT_MIN, t_max = SHRT_MAX };
-
- int i = 0;
- for (; i < glyphs.size()
- && (positions[i].x < t_min || positions[i].x > t_max
- || positions[i].y < t_min || positions[i].y > t_max);
- ++i)
- ;
-
- if (i >= glyphs.size())
- return;
- ++i;
-
- QFixed xp = positions[i - 1].x;
- QFixed yp = positions[i - 1].y;
- QFixed offs = QFixed::fromReal(aliasedCoordinateDelta);
-
- XGlyphElt32 elt;
- elt.glyphset = glyphSet;
- elt.chars = &glyphs[i - 1];
- elt.nchars = 1;
- elt.xOff = qRound(xp + offs);
- elt.yOff = qRound(yp + offs);
- for (; i < glyphs.size(); ++i) {
- if (positions[i].x < t_min || positions[i].x > t_max
- || positions[i].y < t_min || positions[i].y > t_max) {
- break;
- }
- QFontEngineFT::Glyph *g = ft->cachedGlyph(glyphs[i - 1]);
- if (g
- && positions[i].x == xp + g->advance
- && positions[i].y == yp
- && elt.nchars < 253 // don't draw more than 253 characters as some X servers
- // hang with it
- ) {
- elt.nchars++;
- xp += g->advance;
- } else {
- xp = positions[i].x;
- yp = positions[i].y;
-
- XRenderCompositeText32(X11->display, PictOpOver, src, d->picture,
- maskFormat, 0, 0, 0, 0,
- &elt, 1);
- elt.chars = &glyphs[i];
- elt.nchars = 1;
- elt.xOff = qRound(xp + offs);
- elt.yOff = qRound(yp + offs);
- }
- }
- XRenderCompositeText32(X11->display, PictOpOver, src, d->picture,
- maskFormat, 0, 0, 0, 0,
- &elt, 1);
-
- return;
-
- }
-#endif
-
- QPainterPath path = path_for_glyphs(glyphs, positions, ft);
- if (path.elementCount() <= 1)
- return;
- Q_ASSERT((path.elementCount() % 5) == 0);
- if (d->txop >= QTransform::TxScale) {
- painter()->save();
- painter()->setBrush(d->cpen.brush());
- painter()->setPen(Qt::NoPen);
- painter()->drawPath(path);
- painter()->restore();
- return;
- }
-
- const int rectcount = 256;
- XRectangle rects[rectcount];
- int num_rects = 0;
-
- QPoint delta(qRound(d->matrix.dx()), qRound(d->matrix.dy()));
- QRect clip(d->polygonClipper.boundingRect());
- for (int i=0; i < path.elementCount(); i+=5) {
- int x = qRound(path.elementAt(i).x);
- int y = qRound(path.elementAt(i).y);
- int w = qRound(path.elementAt(i+1).x) - x;
- int h = qRound(path.elementAt(i+2).y) - y;
-
- QRect rect = QRect(x + delta.x(), y + delta.y(), w, h);
- rect = rect.intersected(clip);
- if (rect.isEmpty())
- continue;
-
- rects[num_rects].x = short(rect.x());
- rects[num_rects].y = short(rect.y());
- rects[num_rects].width = ushort(rect.width());
- rects[num_rects].height = ushort(rect.height());
- ++num_rects;
- if (num_rects == rectcount) {
- XFillRectangles(d->dpy, d->hd, d->gc, rects, num_rects);
- num_rects = 0;
- }
- }
- if (num_rects > 0)
- XFillRectangles(d->dpy, d->hd, d->gc, rects, num_rects);
-
-}
-#endif // !QT_NO_XRENDER
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qpaintengineex_p.h b/src/gui/painting/qpaintengineex_p.h
index d12c602372..da469936fc 100644
--- a/src/gui/painting/qpaintengineex_p.h
+++ b/src/gui/painting/qpaintengineex_p.h
@@ -54,7 +54,6 @@
//
#include <QtGui/qpaintengine.h>
-#include <QtGui/qdrawutil.h>
#include <private/qpaintengine_p.h>
#include <private/qstroker_p.h>
@@ -213,6 +212,7 @@ public:
virtual void beginNativePainting() {}
virtual void endNativePainting() {}
+ // ### Qt5: remove, once QtOpenGL is merged into QtGui and QtWidgets
// Return a pixmap filter of "type" that can render the parameters
// in "prototype". The returned filter is owned by the engine and
// will be destroyed when the engine is destroyed. The "prototype"
diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp
index 7130fbf07d..64e84e5310 100644
--- a/src/gui/painting/qpainter.cpp
+++ b/src/gui/painting/qpainter.cpp
@@ -56,9 +56,6 @@
#include "qpixmapcache.h"
#include "qpolygon.h"
#include "qtextlayout.h"
-#include "qwidget.h"
-#include "qapplication.h"
-#include "qstyle.h"
#include "qthread.h"
#include "qvarlengtharray.h"
#include "qstatictext.h"
@@ -69,12 +66,12 @@
#include <private/qemulationpaintengine_p.h>
#include <private/qpainterpath_p.h>
#include <private/qtextengine_p.h>
-#include <private/qwidget_p.h>
#include <private/qpaintengine_raster_p.h>
#include <private/qmath_p.h>
#include <private/qstatictext_p.h>
#include <private/qglyphrun_p.h>
-#include <private/qstylehelper_p.h>
+#include <private/qhexstring_p.h>
+#include <private/qguiapplication_p.h>
#include <private/qrawfont_p.h>
QT_BEGIN_NAMESPACE
@@ -250,34 +247,10 @@ bool QPainterPrivate::attachPainterPrivate(QPainter *q, QPaintDevice *pdev)
Q_ASSERT(q);
Q_ASSERT(pdev);
- if (pdev->devType() != QInternal::Widget)
+ QPainter *sp = pdev->sharedPainter();
+ if (!sp)
return false;
- QWidget *widget = static_cast<QWidget *>(pdev);
- Q_ASSERT(widget);
-
- // Someone either called QPainter::setRedirected in the widget's paint event
- // right before this painter was created (or begin was called) or
- // sent a paint event directly to the widget.
- if (!widget->d_func()->redirectDev)
- return false;
-
- QPainter *sp = widget->d_func()->sharedPainter();
- if (!sp || !sp->isActive())
- return false;
-
- if (sp->paintEngine()->paintDevice() != widget->d_func()->redirectDev)
- return false;
-
- // Check if we're attempting to paint outside a paint event.
- if (!sp->d_ptr->engine->hasFeature(QPaintEngine::PaintOutsidePaintEvent)
- && !widget->testAttribute(Qt::WA_PaintOutsidePaintEvent)
- && !widget->testAttribute(Qt::WA_WState_InPaintEvent)) {
-
- qWarning("QPainter::begin: Widget painting can only begin as a result of a paintEvent");
- return false;
- }
-
// Save the current state of the shared painter and assign
// the current d_ptr to the shared painter's d_ptr.
sp->save();
@@ -301,14 +274,14 @@ bool QPainterPrivate::attachPainterPrivate(QPainter *q, QPaintDevice *pdev)
Q_ASSERT(q->d_ptr->state);
// Now initialize the painter with correct widget properties.
- q->initFrom(widget);
+ q->initFrom(pdev);
QPoint offset;
- widget->d_func()->redirected(&offset);
+ pdev->redirected(&offset);
offset += q->d_ptr->engine->coordinateOffset();
// Update system rect.
- q->d_ptr->state->ww = q->d_ptr->state->vw = widget->width();
- q->d_ptr->state->wh = q->d_ptr->state->vh = widget->height();
+ q->d_ptr->state->ww = q->d_ptr->state->vw = pdev->width();
+ q->d_ptr->state->wh = q->d_ptr->state->vh = pdev->height();
// Update matrix.
if (q->d_ptr->state->WxF) {
@@ -322,13 +295,13 @@ bool QPainterPrivate::attachPainterPrivate(QPainter *q, QPaintDevice *pdev)
q->d_ptr->updateMatrix();
QPaintEnginePrivate *enginePrivate = q->d_ptr->engine->d_func();
- if (enginePrivate->currentClipWidget == widget) {
+ if (enginePrivate->currentClipDevice == pdev) {
enginePrivate->systemStateChanged();
return true;
}
// Update system transform and clip.
- enginePrivate->currentClipWidget = widget;
+ enginePrivate->currentClipDevice = pdev;
enginePrivate->setSystemTransform(q->d_ptr->state->matrix);
return true;
}
@@ -1379,10 +1352,7 @@ void QPainterPrivate::updateState(QPainterState *newState)
only use the format types QImage::Format_ARGB32_Premultiplied,
QImage::Format_RGB32 or QImage::Format_RGB16. Any other format,
including QImage::Format_ARGB32, has significantly worse
- performance. This engine is also used by default on Windows and on
- QWS. It can be used as default graphics system on any
- OS/hardware/software combination by passing \c {-graphicssystem
- raster} on the command line
+ performance. This engine is used by default for QWidget and QPixmap.
\o OpenGL 2.0 (ES) - This backend is the primary backend for
hardware accelerated graphics. It can be run on desktop machines
@@ -1550,8 +1520,8 @@ QPainter::~QPainter()
QPaintDevice *QPainter::device() const
{
Q_D(const QPainter);
- if (isActive() && d->engine->d_func()->currentClipWidget)
- return d->engine->d_func()->currentClipWidget;
+ if (isActive() && d->engine->d_func()->currentClipDevice)
+ return d->engine->d_func()->currentClipDevice;
return d->original_device;
}
@@ -1570,25 +1540,23 @@ bool QPainter::isActive() const
/*!
Initializes the painters pen, background and font to the same as
- the given \a widget. This function is called automatically when the
- painter is opened on a QWidget.
+ the given \a paint device.
+
+ \obsolete
\sa begin(), {QPainter#Settings}{Settings}
*/
-void QPainter::initFrom(const QWidget *widget)
+void QPainter::initFrom(const QPaintDevice *device)
{
- Q_ASSERT_X(widget, "QPainter::initFrom(const QWidget *widget)", "Widget cannot be 0");
+ Q_ASSERT_X(device, "QPainter::initFrom(const QPaintDevice *device)", "QPaintDevice cannot be 0");
Q_D(QPainter);
if (!d->engine) {
qWarning("QPainter::initFrom: Painter not active, aborted");
return;
}
- const QPalette &pal = widget->palette();
- d->state->pen = QPen(pal.brush(widget->foregroundRole()), 0);
- d->state->bgBrush = pal.brush(widget->backgroundRole());
- d->state->deviceFont = QFont(widget->font(), const_cast<QWidget*> (widget));
- d->state->font = d->state->deviceFont;
+ device->init(this);
+
if (d->extended) {
d->extended->penChanged();
} else if (d->engine) {
@@ -1761,22 +1729,9 @@ bool QPainter::begin(QPaintDevice *pd)
d->helper_device = pd;
d->original_device = pd;
- QPaintDevice *rpd = 0;
QPoint redirectionOffset;
- // We know for sure that redirection is broken when the widget is inside
- // its paint event, so it's safe to use our hard-coded redirection. However,
- // there IS one particular case we still need to support, and that's
- // when people call QPainter::setRedirected in the widget's paint event right
- // before any painter is created (or QPainter::begin is called). In that
- // particular case our hard-coded redirection is restored and the redirection
- // is retrieved from QPainter::redirected (as before).
- if (pd->devType() == QInternal::Widget)
- rpd = static_cast<QWidget *>(pd)->d_func()->redirected(&redirectionOffset);
-
- if (!rpd)
- rpd = redirected(pd, &redirectionOffset);
-
+ QPaintDevice *rpd = pd->redirected(&redirectionOffset);
if (rpd)
pd = rpd;
@@ -1819,6 +1774,8 @@ bool QPainter::begin(QPaintDevice *pd)
d->engine->state = d->state;
switch (pd->devType()) {
+#if 0
+ // is this needed any more??
case QInternal::Widget:
{
const QWidget *widget = static_cast<const QWidget *>(pd);
@@ -1826,13 +1783,6 @@ bool QPainter::begin(QPaintDevice *pd)
const bool paintOutsidePaintEvent = widget->testAttribute(Qt::WA_PaintOutsidePaintEvent);
const bool inPaintEvent = widget->testAttribute(Qt::WA_WState_InPaintEvent);
- if(!d->engine->hasFeature(QPaintEngine::PaintOutsidePaintEvent)
- && !paintOutsidePaintEvent && !inPaintEvent) {
- qWarning("QPainter::begin: Widget painting can only begin as a "
- "result of a paintEvent");
- qt_cleanup_painter_state(d);
- return false;
- }
// Adjust offset for alien widgets painting outside the paint event.
if (!inPaintEvent && paintOutsidePaintEvent && !widget->internalWinId()
@@ -1842,6 +1792,7 @@ bool QPainter::begin(QPaintDevice *pd)
}
break;
}
+#endif
case QInternal::Pixmap:
{
QPixmap *pm = static_cast<QPixmap *>(pd);
@@ -1902,8 +1853,7 @@ bool QPainter::begin(QPaintDevice *pd)
// Copy painter properties from original paint device,
// required for QPixmap::grabWidget()
if (d->original_device->devType() == QInternal::Widget) {
- QWidget *widget = static_cast<QWidget *>(d->original_device);
- initFrom(widget);
+ initFrom(d->original_device);
} else {
d->state->layoutDirection = Qt::LayoutDirectionAuto;
// make sure we have a font compatible with the paintdevice
@@ -4616,82 +4566,6 @@ void QPainter::drawChord(const QRectF &r, int a, int alen)
startAngle and \a spanAngle.
*/
-#ifdef QT3_SUPPORT
-/*!
- \fn void QPainter::drawLineSegments(const QPolygon &polygon, int
- index, int count)
-
- Draws \a count separate lines from points defined by the \a
- polygon, starting at \a{polygon}\e{[index]} (\a index defaults to
- 0). If \a count is -1 (the default) all points until the end of
- the array are used.
-
- Use drawLines() combined with QPolygon::constData() instead.
-
- \oldcode
- QPainter painter(this);
- painter.drawLineSegments(polygon, index, count);
- \newcode
- int lineCount = (count == -1) ? (polygon.size() - index) / 2 : count;
-
- QPainter painter(this);
- painter.drawLines(polygon.constData() + index * 2, lineCount);
- \endcode
-*/
-
-void QPainter::drawLineSegments(const QPolygon &a, int index, int nlines)
-{
-#ifdef QT_DEBUG_DRAW
- if (qt_show_painter_debug_output)
- printf("QPainter::drawLineSegments(), count=%d\n", a.size()/2);
-#endif
- Q_D(QPainter);
-
- if (!d->engine)
- return;
-
- if (nlines < 0)
- nlines = a.size()/2 - index/2;
- if (index + nlines*2 > (int)a.size())
- nlines = (a.size() - index)/2;
- if (nlines < 1 || index < 0)
- return;
-
- if (d->extended) {
- // FALCON: Use QVectorPath
- QVector<QLineF> lines;
- for (int i=index; i<index + nlines*2; i+=2)
- lines << QLineF(a.at(i), a.at(i+1));
- d->extended->drawLines(lines.data(), lines.size());
- return;
- }
-
- d->updateState(d->state);
-
- QVector<QLineF> lines;
- if (d->state->emulationSpecifier) {
- if (d->state->emulationSpecifier == QPaintEngine::PrimitiveTransform
- && d->state->matrix.type() == QTransform::TxTranslate) {
- QPointF offset(d->state->matrix.dx(), d->state->matrix.dy());
- for (int i=index; i<index + nlines*2; i+=2)
- lines << QLineF(a.at(i) + offset, a.at(i+1) + offset);
- } else {
- QPainterPath linesPath;
- for (int i=index; i<index + nlines*2; i+=2) {
- linesPath.moveTo(a.at(i));
- linesPath.lineTo(a.at(i+1));
- }
- d->draw_helper(linesPath, QPainterPrivate::StrokeDraw);
- return;
- }
- } else {
- for (int i=index; i<index + nlines*2; i+=2)
- lines << QLineF(a.at(i), a.at(i+1));
- }
-
- d->engine->drawLines(lines.data(), lines.size());
-}
-#endif // QT3_SUPPORT
/*!
Draws the first \a lineCount lines in the array \a lines
@@ -6472,7 +6346,7 @@ static void drawTextItemDecoration(QPainter *painter, const QPointF &pos, const
const qreal underlinePos = pos.y() + qCeil(underlineOffset) - aliasedCoordinateDelta;
if (underlineStyle == QTextCharFormat::SpellCheckUnderline) {
- underlineStyle = QTextCharFormat::UnderlineStyle(QApplication::style()->styleHint(QStyle::SH_SpellCheckUnderlineStyle));
+ underlineStyle = QTextCharFormat::SpellCheckUnderline; // ### Qt5 QTextCharFormat::UnderlineStyle(QApplication::style()->styleHint(QStyle::SH_SpellCheckUnderlineStyle));
}
if (underlineStyle == QTextCharFormat::WaveUnderline) {
@@ -7511,328 +7385,6 @@ void QPainter::setViewTransformEnabled(bool enable)
d->updateMatrix();
}
-#ifdef QT3_SUPPORT
-
-/*!
- \obsolete
-
- Use the worldTransform() combined with QTransform::dx() instead.
-
- \oldcode
- QPainter painter(this);
- qreal x = painter.translationX();
- \newcode
- QPainter painter(this);
- qreal x = painter.worldTransform().dx();
- \endcode
-*/
-qreal QPainter::translationX() const
-{
- Q_D(const QPainter);
- if (!d->engine) {
- qWarning("QPainter::translationX: Painter not active");
- return 0.0;
- }
- return d->state->worldMatrix.dx();
-}
-
-/*!
- \obsolete
-
- Use the worldTransform() combined with QTransform::dy() instead.
-
- \oldcode
- QPainter painter(this);
- qreal y = painter.translationY();
- \newcode
- QPainter painter(this);
- qreal y = painter.worldTransform().dy();
- \endcode
-*/
-qreal QPainter::translationY() const
-{
- Q_D(const QPainter);
- if (!d->engine) {
- qWarning("QPainter::translationY: Painter not active");
- return 0.0;
- }
- return d->state->worldMatrix.dy();
-}
-
-/*!
- \fn void QPainter::map(int x, int y, int *rx, int *ry) const
-
- \internal
-
- Sets (\a{rx}, \a{ry}) to the point that results from applying the
- painter's current transformation on the point (\a{x}, \a{y}).
-*/
-void QPainter::map(int x, int y, int *rx, int *ry) const
-{
- QPoint p(x, y);
- p = p * combinedMatrix();
- *rx = p.x();
- *ry = p.y();
-}
-
-/*!
- \fn QPoint QPainter::xForm(const QPoint &point) const
-
- Use combinedTransform() instead.
-*/
-
-QPoint QPainter::xForm(const QPoint &p) const
-{
- Q_D(const QPainter);
- if (!d->engine) {
- qWarning("QPainter::xForm: Painter not active");
- return QPoint();
- }
- if (d->state->matrix.type() == QTransform::TxNone)
- return p;
- return p * combinedMatrix();
-}
-
-
-/*!
- \fn QRect QPainter::xForm(const QRect &rectangle) const
- \overload
-
- Use combinedTransform() instead of this function and call
- mapRect() on the result to obtain a QRect.
-*/
-
-QRect QPainter::xForm(const QRect &r) const
-{
- Q_D(const QPainter);
- if (!d->engine) {
- qWarning("QPainter::xForm: Painter not active");
- return QRect();
- }
- if (d->state->matrix.type() == QTransform::TxNone)
- return r;
- return combinedMatrix().mapRect(r);
-}
-
-/*!
- \fn QPolygon QPainter::xForm(const QPolygon &polygon) const
- \overload
-
- Use combinedTransform() instead.
-*/
-
-QPolygon QPainter::xForm(const QPolygon &a) const
-{
- Q_D(const QPainter);
- if (!d->engine) {
- qWarning("QPainter::xForm: Painter not active");
- return QPolygon();
- }
- if (d->state->matrix.type() == QTransform::TxNone)
- return a;
- return a * combinedMatrix();
-}
-
-/*!
- \fn QPolygon QPainter::xForm(const QPolygon &polygon, int index, int count) const
- \overload
-
- Use combinedTransform() combined with QPolygon::mid() instead.
-
- \oldcode
- QPainter painter(this);
- QPolygon transformed = painter.xForm(polygon, index, count)
- \newcode
- QPainter painter(this);
- QPolygon transformed = polygon.mid(index, count) * painter.combinedTransform();
- \endcode
-*/
-
-QPolygon QPainter::xForm(const QPolygon &av, int index, int npoints) const
-{
- int lastPoint = npoints < 0 ? av.size() : index+npoints;
- QPolygon a(lastPoint-index);
- memcpy(a.data(), av.data()+index, (lastPoint-index)*sizeof(QPoint));
- return a * combinedMatrix();
-}
-
-/*!
- \fn QPoint QPainter::xFormDev(const QPoint &point) const
- \overload
- \obsolete
-
- Use combinedTransform() combined with QTransform::inverted() instead.
-
- \oldcode
- QPainter painter(this);
- QPoint transformed = painter.xFormDev(point);
- \newcode
- QPainter painter(this);
- QPoint transformed = point * painter.combinedTransform().inverted();
- \endcode
-*/
-
-QPoint QPainter::xFormDev(const QPoint &p) const
-{
- Q_D(const QPainter);
- if (!d->engine) {
- qWarning("QPainter::xFormDev: Painter not active");
- return QPoint();
- }
- if(d->state->matrix.type() == QTransform::TxNone)
- return p;
- return p * combinedMatrix().inverted();
-}
-
-/*!
- \fn QRect QPainter::xFormDev(const QRect &rectangle) const
- \overload
- \obsolete
-
- Use combinedTransform() combined with QTransform::inverted() instead.
-
- \oldcode
- QPainter painter(this);
- QRect transformed = painter.xFormDev(rectangle);
- \newcode
- QPainter painter(this);
- QRegion region = QRegion(rectangle) * painter.combinedTransform().inverted();
- QRect transformed = region.boundingRect();
- \endcode
-*/
-
-QRect QPainter::xFormDev(const QRect &r) const
-{
- Q_D(const QPainter);
- if (!d->engine) {
- qWarning("QPainter::xFormDev: Painter not active");
- return QRect();
- }
- if (d->state->matrix.type() == QTransform::TxNone)
- return r;
- return combinedMatrix().inverted().mapRect(r);
-}
-
-/*!
- \overload
-
- \fn QPoint QPainter::xFormDev(const QPolygon &polygon) const
- \obsolete
-
- Use combinedTransform() combined with QTransform::inverted() instead.
-
- \oldcode
- QPainter painter(this);
- QPolygon transformed = painter.xFormDev(rectangle);
- \newcode
- QPainter painter(this);
- QPolygon transformed = polygon * painter.combinedTransform().inverted();
- \endcode
-*/
-
-QPolygon QPainter::xFormDev(const QPolygon &a) const
-{
- Q_D(const QPainter);
- if (!d->engine) {
- qWarning("QPainter::xFormDev: Painter not active");
- return QPolygon();
- }
- if (d->state->matrix.type() == QTransform::TxNone)
- return a;
- return a * combinedMatrix().inverted();
-}
-
-/*!
- \fn QPolygon QPainter::xFormDev(const QPolygon &polygon, int index, int count) const
- \overload
- \obsolete
-
- Use combinedTransform() combined with QPolygon::mid() and QTransform::inverted() instead.
-
- \oldcode
- QPainter painter(this);
- QPolygon transformed = painter.xFormDev(polygon, index, count);
- \newcode
- QPainter painter(this);
- QPolygon transformed = polygon.mid(index, count) * painter.combinedTransform().inverted();
- \endcode
-*/
-
-QPolygon QPainter::xFormDev(const QPolygon &ad, int index, int npoints) const
-{
- Q_D(const QPainter);
- int lastPoint = npoints < 0 ? ad.size() : index+npoints;
- QPolygon a(lastPoint-index);
- memcpy(a.data(), ad.data()+index, (lastPoint-index)*sizeof(QPoint));
- if (d->state->matrix.type() == QTransform::TxNone)
- return a;
- return a * combinedMatrix().inverted();
-}
-
-/*!
- \fn void QPainter::drawCubicBezier(const QPolygon &controlPoints, int index)
-
- Draws a cubic Bezier curve defined by the \a controlPoints,
- starting at \a{controlPoints}\e{[index]} (\a index defaults to 0).
- Points after \a{controlPoints}\e{[index + 3]} are ignored. Nothing
- happens if there aren't enough control points.
-
- Use strokePath() instead.
-
- \oldcode
- QPainter painter(this);
- painter.drawCubicBezier(controlPoints, index)
- \newcode
- QPainterPath path;
- path.moveTo(controlPoints.at(index));
- path.cubicTo(controlPoints.at(index+1),
- controlPoints.at(index+2),
- controlPoints.at(index+3));
-
- QPainter painter(this);
- painter.strokePath(path, painter.pen());
- \endcode
-*/
-void QPainter::drawCubicBezier(const QPolygon &a, int index)
-{
- Q_D(QPainter);
-
- if (!d->engine)
- return;
-
- if ((int)a.size() - index < 4) {
- qWarning("QPainter::drawCubicBezier: Cubic Bezier needs 4 control "
- "points");
- return;
- }
-
- QPainterPath path;
- path.moveTo(a.at(index));
- path.cubicTo(a.at(index+1), a.at(index+2), a.at(index+3));
- strokePath(path, d->state->pen);
-}
-#endif
-
-struct QPaintDeviceRedirection
-{
- QPaintDeviceRedirection() : device(0), replacement(0), internalWidgetRedirectionIndex(-1) {}
- QPaintDeviceRedirection(const QPaintDevice *device, QPaintDevice *replacement,
- const QPoint& offset, int internalWidgetRedirectionIndex)
- : device(device), replacement(replacement), offset(offset),
- internalWidgetRedirectionIndex(internalWidgetRedirectionIndex) { }
- const QPaintDevice *device;
- QPaintDevice *replacement;
- QPoint offset;
- int internalWidgetRedirectionIndex;
- bool operator==(const QPaintDevice *pdev) const { return device == pdev; }
- Q_DUMMY_COMPARISON_OPERATOR(QPaintDeviceRedirection)
-};
-
-typedef QList<QPaintDeviceRedirection> QPaintDeviceRedirectionList;
-Q_GLOBAL_STATIC(QPaintDeviceRedirectionList, globalRedirections)
-Q_GLOBAL_STATIC(QMutex, globalRedirectionsMutex)
-Q_GLOBAL_STATIC(QAtomicInt, globalRedirectionAtomic)
-
/*!
\threadsafe
@@ -7862,29 +7414,7 @@ void QPainter::setRedirected(const QPaintDevice *device,
{
Q_ASSERT(device != 0);
- bool hadInternalWidgetRedirection = false;
- if (device->devType() == QInternal::Widget) {
- const QWidgetPrivate *widgetPrivate = static_cast<const QWidget *>(device)->d_func();
- // This is the case when the widget is in a paint event.
- if (widgetPrivate->redirectDev) {
- // Remove internal redirection and put it back into the global redirection list.
- QPoint oldOffset;
- QPaintDevice *oldReplacement = widgetPrivate->redirected(&oldOffset);
- const_cast<QWidgetPrivate *>(widgetPrivate)->restoreRedirected();
- setRedirected(device, oldReplacement, oldOffset);
- hadInternalWidgetRedirection = true;
- }
- }
-
- QPoint roffset;
- QPaintDevice *rdev = redirected(replacement, &roffset);
-
- QMutexLocker locker(globalRedirectionsMutex());
- QPaintDeviceRedirectionList *redirections = globalRedirections();
- Q_ASSERT(redirections != 0);
- *redirections += QPaintDeviceRedirection(device, rdev ? rdev : replacement, offset + roffset,
- hadInternalWidgetRedirection ? redirections->size() - 1 : -1);
- globalRedirectionAtomic()->ref();
+ qWarning() << "QPainter::setRedirected(): ignoring call to deprecated function, use QWidget::render() instead";
}
/*!
@@ -7906,29 +7436,7 @@ void QPainter::setRedirected(const QPaintDevice *device,
*/
void QPainter::restoreRedirected(const QPaintDevice *device)
{
- Q_ASSERT(device != 0);
- QMutexLocker locker(globalRedirectionsMutex());
- QPaintDeviceRedirectionList *redirections = globalRedirections();
- Q_ASSERT(redirections != 0);
- for (int i = redirections->size()-1; i >= 0; --i) {
- if (redirections->at(i) == device) {
- globalRedirectionAtomic()->deref();
- const int internalWidgetRedirectionIndex = redirections->at(i).internalWidgetRedirectionIndex;
- redirections->removeAt(i);
- // Restore the internal widget redirection, i.e. remove it from the global
- // redirection list and put it back into QWidgetPrivate. The index is only set when
- // someone call QPainter::setRedirected in a widget's paint event and we internally
- // have a redirection set (typically set in QWidgetPrivate::drawWidget).
- if (internalWidgetRedirectionIndex >= 0) {
- Q_ASSERT(internalWidgetRedirectionIndex < redirections->size());
- const QPaintDeviceRedirection &redirectionDevice = redirections->at(internalWidgetRedirectionIndex);
- QWidget *widget = static_cast<QWidget *>(const_cast<QPaintDevice *>(device));
- widget->d_func()->setRedirected(redirectionDevice.replacement, redirectionDevice.offset);
- redirections->removeAt(internalWidgetRedirectionIndex);
- }
- return;
- }
- }
+ qWarning() << "QPainter::restoreRedirected(): ignoring call to deprecated function, use QWidget::render() instead";
}
/*!
@@ -7950,61 +7458,9 @@ void QPainter::restoreRedirected(const QPaintDevice *device)
*/
QPaintDevice *QPainter::redirected(const QPaintDevice *device, QPoint *offset)
{
- Q_ASSERT(device != 0);
-
- if (device->devType() == QInternal::Widget) {
- const QWidgetPrivate *widgetPrivate = static_cast<const QWidget *>(device)->d_func();
- if (widgetPrivate->redirectDev)
- return widgetPrivate->redirected(offset);
- }
-
- if (!globalRedirectionAtomic() || *globalRedirectionAtomic() == 0)
- return 0;
-
- QMutexLocker locker(globalRedirectionsMutex());
- QPaintDeviceRedirectionList *redirections = globalRedirections();
- Q_ASSERT(redirections != 0);
- for (int i = redirections->size()-1; i >= 0; --i)
- if (redirections->at(i) == device) {
- if (offset)
- *offset = redirections->at(i).offset;
- return redirections->at(i).replacement;
- }
- if (offset)
- *offset = QPoint(0, 0);
return 0;
}
-
-void qt_painter_removePaintDevice(QPaintDevice *dev)
-{
- if (!globalRedirectionAtomic() || *globalRedirectionAtomic() == 0)
- return;
-
- QMutex *mutex = 0;
- QT_TRY {
- mutex = globalRedirectionsMutex();
- } QT_CATCH(...) {
- // ignore the missing mutex, since we could be called from
- // a destructor, and destructors shall not throw
- }
- QMutexLocker locker(mutex);
- QPaintDeviceRedirectionList *redirections = 0;
- QT_TRY {
- redirections = globalRedirections();
- } QT_CATCH(...) {
- // do nothing - code below is safe with redirections being 0.
- }
- if (redirections) {
- for (int i = 0; i < redirections->size(); ) {
- if(redirections->at(i) == dev || redirections->at(i).replacement == dev)
- redirections->removeAt(i);
- else
- ++i;
- }
- }
-}
-
void qt_format_text(const QFont &fnt, const QRectF &_r,
int tf, const QString& str, QRectF *brect,
int tabstops, int *ta, int tabarraylen,
@@ -8056,7 +7512,7 @@ void qt_format_text(const QFont &fnt, const QRectF &_r,
else
layout_direction = Qt::LeftToRight;
- tf = QStyle::visualAlignment(layout_direction, QFlag(tf));
+ tf = QGuiApplicationPrivate::visualAlignment(layout_direction, QFlag(tf));
bool isRightToLeft = layout_direction == Qt::RightToLeft;
bool expandtabs = ((tf & Qt::TextExpandTabs) &&
@@ -8316,7 +7772,7 @@ QPainterState::QPainterState()
wx(0), wy(0), ww(0), wh(0), vx(0), vy(0), vw(0), vh(0),
opacity(1), WxF(false), VxF(false), clipEnabled(true),
bgMode(Qt::TransparentMode), painter(0),
- layoutDirection(QApplication::layoutDirection()),
+ layoutDirection(QGuiApplication::layoutDirection()),
composition_mode(QPainter::CompositionMode_SourceOver),
emulationSpecifier(0), changeFlags(0)
{
@@ -8346,7 +7802,7 @@ void QPainterState::init(QPainter *p) {
clipInfo.clear();
worldMatrix.reset();
matrix.reset();
- layoutDirection = QApplication::layoutDirection();
+ layoutDirection = QGuiApplication::layoutDirection();
composition_mode = QPainter::CompositionMode_SourceOver;
emulationSpecifier = 0;
dirtyFlags = 0;
@@ -8355,45 +7811,6 @@ void QPainterState::init(QPainter *p) {
opacity = 1;
}
-#ifdef QT3_SUPPORT
-static void bitBlt_helper(QPaintDevice *dst, const QPoint &dp,
- const QPaintDevice *src, const QRect &sr, bool)
-{
- Q_ASSERT(dst);
- Q_ASSERT(src);
-
- if (src->devType() == QInternal::Pixmap) {
- const QPixmap *pixmap = static_cast<const QPixmap *>(src);
- QPainter pt(dst);
- pt.drawPixmap(dp, *pixmap, sr);
-
- } else {
- qWarning("QPainter: bitBlt only works when source is of type pixmap");
- }
-}
-
-void bitBlt(QPaintDevice *dst, int dx, int dy,
- const QPaintDevice *src, int sx, int sy, int sw, int sh,
- bool ignoreMask )
-{
- bitBlt_helper(dst, QPoint(dx, dy), src, QRect(sx, sy, sw, sh), ignoreMask);
-}
-
-void bitBlt(QPaintDevice *dst, const QPoint &dp, const QPaintDevice *src, const QRect &sr, bool ignoreMask)
-{
- bitBlt_helper(dst, dp, src, sr, ignoreMask);
-}
-
-void bitBlt(QPaintDevice *dst, int dx, int dy,
- const QImage *src, int sx, int sy, int sw, int sh, int fl)
-{
- Qt::ImageConversionFlags flags(fl);
- QPixmap srcPixmap = QPixmap::fromImage(*src, flags);
- bitBlt_helper(dst, QPoint(dx, dy), &srcPixmap, QRect(sx, sy, sw, sh), false);
-}
-
-#endif // QT3_SUPPORT
-
/*!
\fn void QPainter::setBackgroundColor(const QColor &color)
diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h
index 601c386059..7420801998 100644
--- a/src/gui/painting/qpainter.h
+++ b/src/gui/painting/qpainter.h
@@ -49,7 +49,6 @@
#include <QtGui/qpixmap.h>
#include <QtGui/qimage.h>
#include <QtGui/qtextoption.h>
-#include <QtGui/qdrawutil.h>
#ifndef QT_INCLUDE_COMPAT
#include <QtGui/qpolygon.h>
@@ -133,7 +132,7 @@ public:
bool end();
bool isActive() const;
- void initFrom(const QWidget *widget);
+ void initFrom(const QPaintDevice *device);
enum CompositionMode {
CompositionMode_SourceOver,
@@ -464,85 +463,13 @@ public:
void beginNativePainting();
void endNativePainting();
-#ifdef QT3_SUPPORT
-
- inline QT3_SUPPORT void setBackgroundColor(const QColor &color) { setBackground(color); }
- inline QT3_SUPPORT const QColor &backgroundColor() const { return background().color(); }
-
- inline QT3_SUPPORT void drawText(int x, int y, const QString &s, int pos, int len)
- { drawText(x, y, s.mid(pos, len)); }
- inline QT3_SUPPORT void drawText(const QPoint &p, const QString &s, int pos, int len)
- { drawText(p, s.mid(pos, len)); }
- inline QT3_SUPPORT void drawText(int x, int y, const QString &s, int len)
- { drawText(x, y, s.left(len)); }
- inline QT3_SUPPORT void drawText(const QPoint &p, const QString &s, int len)
- { drawText(p, s.left(len)); }
- inline QT3_SUPPORT void drawText(const QRect &r, int flags, const QString &str, int len, QRect *br=0)
- { drawText(r, flags, str.left(len), br); }
- inline QT3_SUPPORT void drawText(int x, int y, int w, int h, int flags, const QString &text, int len, QRect *br=0)
- { drawText(QRect(x, y, w, h), flags, text.left(len), br); }
- inline QT3_SUPPORT QRect boundingRect(const QRect &rect, int flags, const QString &text, int len)
- { return boundingRect(rect, flags, text.left(len)); }
- inline QT3_SUPPORT QRect boundingRect(int x, int y, int w, int h, int flags, const QString &text, int len)
- { return boundingRect(QRect(x, y, w, h), flags, text.left(len)); }
-
- inline QT3_SUPPORT bool begin(QPaintDevice *pdev, const QWidget *init)
- { bool ret = begin(pdev); initFrom(init); return ret; }
- QT3_SUPPORT void drawPoints(const QPolygon &pa, int index, int npoints = -1)
- { drawPoints(pa.constData() + index, npoints == -1 ? pa.size() - index : npoints); }
-
- QT3_SUPPORT void drawCubicBezier(const QPolygon &pa, int index = 0);
-
- QT3_SUPPORT void drawLineSegments(const QPolygon &points, int index = 0, int nlines = -1);
-
- inline QT3_SUPPORT void drawPolyline(const QPolygon &pa, int index, int npoints = -1)
- { drawPolyline(pa.constData() + index, npoints == -1 ? pa.size() - index : npoints); }
-
- inline QT3_SUPPORT void drawPolygon(const QPolygon &pa, bool winding, int index = 0, int npoints = -1)
- { drawPolygon(pa.constData() + index, npoints == -1 ? pa.size() - index : npoints,
- winding ? Qt::WindingFill : Qt::OddEvenFill); }
-
- inline QT3_SUPPORT void drawPolygon(const QPolygonF &polygon, bool winding, int index = 0,
- int npoints = -1)
- { drawPolygon(polygon.constData() + index, npoints == -1 ? polygon.size() - index : npoints,
- winding ? Qt::WindingFill : Qt::OddEvenFill); }
-
- inline QT3_SUPPORT void drawConvexPolygon(const QPolygonF &polygon, int index, int npoints = -1)
- { drawConvexPolygon(polygon.constData() + index, npoints == -1 ? polygon.size() - index : npoints); }
- inline QT3_SUPPORT void drawConvexPolygon(const QPolygon &pa, int index, int npoints = -1)
- { drawConvexPolygon(pa.constData() + index, npoints == -1 ? pa.size() - index : npoints); }
-
- static inline QT3_SUPPORT void redirect(QPaintDevice *pdev, QPaintDevice *replacement)
- { setRedirected(pdev, replacement); }
- static inline QT3_SUPPORT QPaintDevice *redirect(QPaintDevice *pdev)
- { return const_cast<QPaintDevice*>(redirected(pdev)); }
-
- inline QT3_SUPPORT void setWorldXForm(bool enabled) { setMatrixEnabled(enabled); }
- inline QT3_SUPPORT bool hasWorldXForm() const { return matrixEnabled(); }
- inline QT3_SUPPORT void resetXForm() { resetTransform(); }
-
- inline QT3_SUPPORT void setViewXForm(bool enabled) { setViewTransformEnabled(enabled); }
- inline QT3_SUPPORT bool hasViewXForm() const { return viewTransformEnabled(); }
-
- QT3_SUPPORT void map(int x, int y, int *rx, int *ry) const;
- QT3_SUPPORT QPoint xForm(const QPoint &) const; // map virtual -> deviceb
- QT3_SUPPORT QRect xForm(const QRect &) const;
- QT3_SUPPORT QPolygon xForm(const QPolygon &) const;
- QT3_SUPPORT QPolygon xForm(const QPolygon &, int index, int npoints) const;
- QT3_SUPPORT QPoint xFormDev(const QPoint &) const; // map device -> virtual
- QT3_SUPPORT QRect xFormDev(const QRect &) const;
- QT3_SUPPORT QPolygon xFormDev(const QPolygon &) const;
- QT3_SUPPORT QPolygon xFormDev(const QPolygon &, int index, int npoints) const;
- QT3_SUPPORT qreal translationX() const;
- QT3_SUPPORT qreal translationY() const;
-#endif
-
private:
Q_DISABLE_COPY(QPainter)
friend class Q3Painter;
QScopedPointer<QPainterPrivate> d_ptr;
+ friend class QWidget;
friend class QFontEngine;
friend class QFontEngineBox;
friend class QFontEngineFT;
diff --git a/src/gui/painting/qpdf_p.h b/src/gui/painting/qpdf_p.h
index 39e6c21620..6b2e16f3de 100644
--- a/src/gui/painting/qpdf_p.h
+++ b/src/gui/painting/qpdf_p.h
@@ -153,8 +153,8 @@ namespace QPdf {
struct PaperSize {
int width, height; // in postscript points
};
- PaperSize paperSize(QPrinter::PaperSize paperSize);
- const char *paperSizeToString(QPrinter::PaperSize paperSize);
+ Q_GUI_EXPORT PaperSize paperSize(QPrinter::PaperSize paperSize);
+ Q_GUI_EXPORT const char *paperSizeToString(QPrinter::PaperSize paperSize);
}
diff --git a/src/gui/painting/qprintengine_ps.cpp b/src/gui/painting/qprintengine_ps.cpp
deleted file mode 100644
index d55d532fdb..0000000000
--- a/src/gui/painting/qprintengine_ps.cpp
+++ /dev/null
@@ -1,972 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qplatformdefs.h"
-
-#include <private/qprintengine_ps_p.h>
-#include <private/qpainter_p.h>
-#include <private/qfontengine_p.h>
-#include <private/qpaintengine_p.h>
-#include <private/qpdf_p.h>
-
-#ifndef QT_NO_PRINTER
-
-#include "qprinter.h"
-#include "qpainter.h"
-#include "qapplication.h"
-#include "qpixmap.h"
-#include "qimage.h"
-#include "qdatetime.h"
-#include "qstring.h"
-#include "qbytearray.h"
-#include "qhash.h"
-#include "qbuffer.h"
-#include "qsettings.h"
-#include "qmap.h"
-#include "qbitmap.h"
-#include "qregion.h"
-#include "qimagewriter.h"
-#include <private/qpainterpath_p.h>
-#include <qdebug.h>
-#include <private/qdrawhelper_p.h>
-#include <private/qmutexpool_p.h>
-
-#ifndef Q_OS_WIN
-#include <unistd.h>
-#endif
-#include <stdlib.h>
-#include <limits.h>
-
-QT_BEGIN_NAMESPACE
-
-static bool qt_gen_epsf = false;
-
-void qt_generate_epsf(bool b)
-{
- qt_gen_epsf = b;
-}
-
-static const char *const ps_header =
-"/BD{bind def}bind def/d2{dup dup}BD/ED{exch def}BD/D0{0 ED}BD/F{setfont}BD\n"
-"/RL{rlineto}BD/CM{currentmatrix}BD/SM{setmatrix}BD/TR{translate}BD/SD\n"
-"{setdash}BD/SC{aload pop setrgbcolor}BD/CR{currentfile read pop}BD/i{index}\n"
-"BD/scs{setcolorspace}BD/DB{dict dup begin}BD/DE{end def}BD/ie{ifelse}BD/gs\n"
-"{gsave}BD/gr{grestore}BD/w{setlinewidth}BD/d{setdash}BD/J{setlinecap}BD/j\n"
-"{setlinejoin}BD/scn{3 array astore/BCol exch def}BD/SCN{3 array astore/PCol\n"
-"exch def}BD/cm{6 array astore concat}BD/m{moveto}BD/l{lineto}BD/c{curveto}BD\n"
-"/h{closepath}BD/W{clip}BD/W*{eoclip}BD/n{newpath}BD/q{gsave 10 dict begin}BD\n"
-"/Q{end grestore}BD/re{4 2 roll m dup 0 exch RL exch 0 RL 0 exch neg RL h}BD\n"
-"/S{gs PCol SC stroke gr n}BD/BT{gsave 10 dict begin/_m matrix CM def BCol\n"
-"SC}BD/ET{end grestore}BD/Tf{/_fs ED findfont[_fs 0 0 _fs 0 0]makefont F}BD\n"
-"/Tm{6 array astore concat}BD/Td{translate}BD/Tj{0 0 m show}BD/BDC{pop pop}BD\n"
-"/EMC{}BD/BSt 0 def/WFi false def/BCol[1 1 1]def/PCol[0 0 0]def/BDArr[0.94\n"
-"0.88 0.63 0.50 0.37 0.12 0.06]def/level3{/languagelevel where{pop\n"
-"languagelevel 3 ge}{false}ie}BD/QCIgray D0/QCIcolor D0/QCIindex D0/QCI{\n"
-"/colorimage where{pop false 3 colorimage}{exec/QCIcolor ED/QCIgray QCIcolor\n"
-"length 3 idiv string def 0 1 QCIcolor length 3 idiv 1 sub{/QCIindex ED/_x\n"
-"QCIindex 3 mul def QCIgray QCIindex QCIcolor _x get 0.30 mul QCIcolor _x 1\n"
-"add get 0.59 mul QCIcolor _x 2 add get 0.11 mul add add cvi put}for QCIgray\n"
-"image}ie}BD/di{gs TR 1 i 1 eq{pop pop false 3 1 roll BCol SC imagemask}{dup\n"
-"false ne{level3}{false}ie{/_ma ED 8 eq{/_dc[0 1]def/DeviceGray}{/_dc[0 1 0 1\n"
-"0 1]def/DeviceRGB}ie scs/_im ED/_mt ED/_h ED/_w ED <</ImageType 3/DataDict\n"
-"<</ImageType 1/Width _w/Height _h/ImageMatrix _mt/DataSource _im\n"
-"/BitsPerComponent 8/Decode _dc >>/MaskDict <</ImageType 1/Width _w/Height _h\n"
-"/ImageMatrix _mt/DataSource _ma/BitsPerComponent 1/Decode[0 1]>>\n"
-"/InterleaveType 3 >> image}{pop 8 4 1 roll 8 eq{image}{QCI}ie}ie}ie gr}BD/BF\n"
-"{gs BSt 1 eq{BCol SC WFi{fill}{eofill}ie}if BSt 2 ge BSt 8 le and{BDArr BSt\n"
-"2 sub get/_sc ED BCol{1. exch sub _sc mul 1. exch sub}forall 3 array astore\n"
-"SC WFi{fill}{eofill}ie}if BSt 9 ge BSt 14 le and{WFi{W}{W*}ie pathbbox 3 i 3\n"
-"i TR 4 2 roll 3 2 roll exch sub/_h ED sub/_w ED BCol SC 0.3 w n BSt 9 eq BSt\n"
-"11 eq or{0 4 _h{dup 0 exch m _w exch l}for}if BSt 10 eq BSt 11 eq or{0 4 _w{\n"
-"dup 0 m _h l}for}if BSt 12 eq BSt 14 eq or{_w _h gt{0 6 _w _h add{dup 0 m _h\n"
-"sub _h l}for}{0 6 _w _h add{dup 0 exch m _w sub _w exch l}for}ie}if BSt 13\n"
-"eq BSt 14 eq or{_w _h gt{0 6 _w _h add{dup _h m _h sub 0 l}for}{0 6 _w _h\n"
-"add{dup _w exch m _w sub 0 exch l}for}ie}if stroke}if BSt 15 eq{}if BSt 24\n"
-"eq{}if gr}BD/f{/WFi true def BF n}BD/f*{/WFi false def BF n}BD/B{/WFi true\n"
-"def BF S n}BD/B*{/WFi false def BF S n}BD/QI{/C save def pageinit q n}BD/QP{\n"
-"Q C restore showpage}BD/SPD{/setpagedevice where{<< 3 1 roll >>\n"
-"setpagedevice}{pop pop}ie}BD/T1AddMapping{10 dict begin/glyphs ED/fnt ED\n"
-"/current fnt/NumGlyphs get def/CMap fnt/CMap get def 0 1 glyphs length 1 sub\n"
-"{glyphs exch get/gn ED current dup 256 mod/min ED 256 idiv/maj ED CMap dup\n"
-"maj get dup null eq{pop 256 array 0 1 255{1 i exch/.notdef put}for}if dup\n"
-"min gn put maj exch put/current current 1 add def}for fnt/CMap CMap put fnt\n"
-"/NumGlyphs current put end}def/T1AddGlyphs{10 dict begin/glyphs ED/fnt ED\n"
-"/current fnt/NumGlyphs get def/CMap fnt/CMap get def/CharStrings fnt\n"
-"/CharStrings get def 0 1 glyphs length 2 idiv 1 sub{2 mul dup glyphs exch\n"
-"get/gn ED 1 add glyphs exch get/cs ED current dup 256 mod/min ED 256 idiv\n"
-"/maj ED CMap dup maj get dup null eq{pop 256 array 0 1 255{1 i exch/.notdef\n"
-"put}for}if dup min gn put maj exch put CharStrings gn cs put/current current\n"
-"1 add def}for fnt/CharStrings CharStrings put fnt/CMap CMap put fnt\n"
-"/NumGlyphs current put end}def/StringAdd{1 i length 1 i length add string 3\n"
-"1 roll 2 i 0 3 i putinterval 2 i 2 i length 2 i putinterval pop pop}def\n"
-"/T1Setup{10 dict begin dup/FontName ED (-Base) StringAdd cvx cvn/Font ED\n"
-"/MaxPage Font/NumGlyphs get 1 sub 256 idiv def/FDepVector MaxPage 1 add\n"
-"array def/Encoding MaxPage 1 add array def 0 1 MaxPage{dup Encoding exch dup\n"
-"put dup/Page ED FontName (-) StringAdd exch 20 string cvs StringAdd cvn Font\n"
-"0 dict copy d2/CMap get Page get/Encoding exch put definefont FDepVector\n"
-"exch Page exch put}for FontName cvn <</FontType 0/FMapType 2/FontMatrix[1 0\n"
-"0 1 0 0]/Encoding Encoding/FDepVector FDepVector >> definefont pop end}def\n";
-
-
-
-// ------------------------------End of static data ----------------------------------
-
-// make sure DSC comments are not longer than 255 chars per line.
-static QByteArray wrapDSC(const QByteArray &str)
-{
- QByteArray dsc = str.simplified();
- const int wrapAt = 254;
- QByteArray wrapped;
- if (dsc.length() < wrapAt)
- wrapped = dsc;
- else {
- wrapped = dsc.left(wrapAt);
- QByteArray tmp = dsc.mid(wrapAt);
- while (tmp.length() > wrapAt-3) {
- wrapped += "\n%%+" + tmp.left(wrapAt-3);
- tmp = tmp.mid(wrapAt-3);
- }
- wrapped += "\n%%+" + tmp;
- }
- return wrapped + '\n';
-}
-
-// ----------------------------- Internal class declarations -----------------------------
-
-QPSPrintEnginePrivate::QPSPrintEnginePrivate(QPrinter::PrinterMode m)
- : QPdfBaseEnginePrivate(m),
- printerState(QPrinter::Idle), hugeDocument(false), headerDone(false)
-{
- useAlphaEngine = true;
- postscript = true;
-
- firstPage = true;
-
-#ifndef QT_NO_SETTINGS
- QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
- settings.beginGroup(QLatin1String("Qt"));
- embedFonts = settings.value(QLatin1String("embedFonts"), true).toBool();
-#else
- embedFonts = true;
-#endif
-}
-
-QPSPrintEnginePrivate::~QPSPrintEnginePrivate()
-{
-}
-
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <qdebug.h>
-QT_END_INCLUDE_NAMESPACE
-
-static void ps_r7(QPdf::ByteStream& stream, const char * s, int l)
-{
- int i = 0;
- uchar line[84];
- int col = 0;
-
- while(i < l) {
- line[col++] = s[i++];
- if (i < l - 1 && col >= 76) {
- line[col++] = '\n';
- line[col++] = '\0';
- stream << (const char *)line;
- col = 0;
- }
- }
- if (col > 0) {
- while((col&3) != 0)
- line[col++] = '%'; // use a comment as padding
- line[col++] = '\n';
- line[col++] = '\0';
- stream << (const char *)line;
- }
-}
-
-static QByteArray runlengthEncode(const QByteArray &input)
-{
- if (!input.length())
- return input;
-
- const char *data = input.constData();
-
- QByteArray out;
- int start = 0;
- char last = *data;
-
- enum State {
- Undef,
- Equal,
- Diff
- };
- State state = Undef;
-
- int i = 1;
- int written = 0;
- while (1) {
- bool flush = (i == input.size());
- if (!flush) {
- switch(state) {
- case Undef:
- state = (last == data[i]) ? Equal : Diff;
- break;
- case Equal:
- if (data[i] != last)
- flush = true;
- break;
- case Diff:
- if (data[i] == last) {
- --i;
- flush = true;
- }
- }
- }
- if (flush || i - start == 128) {
- int size = i - start;
- if (state == Equal) {
- out.append((char)(uchar)(257-size));
- out.append(last);
- written += size;
- } else {
- out.append((char)(uchar)size-1);
- while (start < i)
- out.append(data[start++]);
- written += size;
- }
- state = Undef;
- start = i;
- if (i == input.size())
- break;
- }
- last = data[i];
- ++i;
- };
- out.append((char)(uchar)128);
- return out;
-}
-
-enum format {
- Raw,
- Runlength,
- DCT
-};
-static const char *const filters[3] = {
- " ",
- "/RunLengthDecode filter ",
- "/DCTDecode filter "
-};
-
-static QByteArray compressHelper(const QImage &image, bool gray, int *format)
-{
- // we can't use premultiplied here
- QByteArray pixelData;
- int depth = image.depth();
-
- Q_ASSERT(image.format() != QImage::Format_ARGB32_Premultiplied);
-
- if (depth != 1 && !gray && QImageWriter::supportedImageFormats().contains("jpeg")) {
- QBuffer buffer(&pixelData);
- QImageWriter writer(&buffer, "jpeg");
- writer.setQuality(94);
- writer.write(image);
- *format = DCT;
- } else {
- int width = image.width();
- int height = image.height();
- int size = width*height;
-
- if (depth == 1)
- size = (width+7)/8*height;
- else if (!gray)
- size = size*3;
-
- pixelData.resize(size);
- uchar *pixel = (uchar *)pixelData.data();
- int i = 0;
- if (depth == 1) {
- QImage::Format format = image.format();
- memset(pixel, 0xff, size);
- for(int y=0; y < height; y++) {
- const uchar * s = image.scanLine(y);
- for(int x=0; x < width; x++) {
- // need to copy bit for bit...
- bool b = (format == QImage::Format_MonoLSB) ?
- (*(s + (x >> 3)) >> (x & 7)) & 1 :
- (*(s + (x >> 3)) << (x & 7)) & 0x80 ;
- if (b)
- pixel[i >> 3] ^= (0x80 >> (i & 7));
- i++;
- }
- // we need to align to 8 bit here
- i = (i+7) & 0xffffff8;
- }
- } else if (depth == 8) {
- for(int y=0; y < height; y++) {
- const uchar * s = image.scanLine(y);
- for(int x=0; x < width; x++) {
- QRgb rgb = image.color(s[x]);
- if (gray) {
- pixel[i] = (unsigned char) qGray(rgb);
- i++;
- } else {
- pixel[i] = (unsigned char) qRed(rgb);
- pixel[i+1] = (unsigned char) qGreen(rgb);
- pixel[i+2] = (unsigned char) qBlue(rgb);
- i += 3;
- }
- }
- }
- } else {
- for(int y=0; y < height; y++) {
- QRgb * s = (QRgb*)(image.scanLine(y));
- for(int x=0; x < width; x++) {
- QRgb rgb = (*s++);
- if (gray) {
- pixel[i] = (unsigned char) qGray(rgb);
- i++;
- } else {
- pixel[i] = (unsigned char) qRed(rgb);
- pixel[i+1] = (unsigned char) qGreen(rgb);
- pixel[i+2] = (unsigned char) qBlue(rgb);
- i += 3;
- }
- }
- }
- }
- *format = Raw;
- if (depth == 1) {
- pixelData = runlengthEncode(pixelData);
- *format = Runlength;
- }
- }
- QByteArray outarr = QPdf::ascii85Encode(pixelData);
- return outarr;
-}
-
-void QPSPrintEnginePrivate::drawImageHelper(qreal x, qreal y, qreal w, qreal h, const QImage &img,
- const QImage &mask, bool gray, qreal scaleX, qreal scaleY)
-{
- Q_UNUSED(h);
- Q_UNUSED(w);
- int width = img.width();
- int height = img.height();
-
- QByteArray out;
- int size = 0;
- const char *bits;
-
- if (!mask.isNull()) {
- int format;
- out = compressHelper(mask, true, &format);
- size = (width+7)/8*height;
- *currentPage << "/mask currentfile/ASCII85Decode filter"
- << filters[format]
- << size << " string readstring\n";
- ps_r7(*currentPage, out, out.size());
- *currentPage << " pop def\n";
- }
- if (img.depth() == 1) {
- size = (width+7)/8*height;
- bits = "1 ";
- } else if (gray) {
- size = width*height;
- bits = "8 ";
- } else {
- size = width*height*3;
- bits = "24 ";
- }
-
- int format;
- out = compressHelper(img, gray, &format);
- *currentPage << "/sl currentfile/ASCII85Decode filter"
- << filters[format]
- << size << " string readstring\n";
- ps_r7(*currentPage, out, out.size());
- *currentPage << " pop def\n";
- *currentPage << width << ' ' << height << '[' << scaleX << " 0 0 " << scaleY << " 0 0]sl "
- << bits << (!mask.isNull() ? "mask " : "false ")
- << x << ' ' << y << " di\n";
-}
-
-
-void QPSPrintEnginePrivate::drawImage(qreal x, qreal y, qreal w, qreal h,
- const QImage &image, const QImage &msk)
-{
- if (!w || !h || image.isNull()) return;
-
- QImage img(image);
- QImage mask(msk);
-
- if (image.format() == QImage::Format_ARGB32_Premultiplied)
- img = image.convertToFormat(QImage::Format_ARGB32);
-
- if (!msk.isNull() && msk.format() == QImage::Format_ARGB32_Premultiplied)
- mask = msk.convertToFormat(QImage::Format_ARGB32);
-
- int width = img.width();
- int height = img.height();
- qreal scaleX = width/w;
- qreal scaleY = height/h;
-
- bool gray = (colorMode == QPrinter::GrayScale) || img.allGray();
- int splitSize = 21830 * (gray ? 3 : 1);
- if (width * height > splitSize) { // 65535/3, tolerance for broken printers
- int images, subheight;
- images = (width * height + splitSize - 1) / splitSize;
- subheight = (height + images-1) / images;
- while (subheight * width > splitSize) {
- images++;
- subheight = (height + images-1) / images;
- }
- int suby = 0;
- const QImage constImg(img);
- const QImage constMask(mask);
- while(suby < height) {
- qreal subImageHeight = qMin(subheight, height-suby);
- const QImage subImage(constImg.scanLine(suby), width, subImageHeight,
- constImg.bytesPerLine(), constImg.format());
- const QImage subMask = mask.isNull() ? mask : QImage(constMask.scanLine(suby), width, subImageHeight,
- constMask.bytesPerLine(), constMask.format());
- drawImageHelper(x, y + suby/scaleY, w, subImageHeight/scaleY,
- subImage, subMask, gray, scaleX, scaleY);
- suby += subheight;
- }
- } else {
- drawImageHelper(x, y, width, height, img, mask, gray, scaleX, scaleY);
- }
-}
-
-void QPSPrintEnginePrivate::emitHeader(bool finished)
-{
- QPSPrintEngine *q = static_cast<QPSPrintEngine *>(q_ptr);
- QPrinter *printer = static_cast<QPrinter*>(pdev);
-
- if (creator.isEmpty())
- creator = QLatin1String("Qt " QT_VERSION_STR);
-
- QByteArray header;
- QPdf::ByteStream s(&header);
-
- qreal scale = 72. / ((qreal) q->metric(QPaintDevice::PdmDpiY));
- QRect pageRect = this->pageRect();
- QRect paperRect = this->paperRect();
- int mtop = pageRect.top() - paperRect.top();
- int mleft = pageRect.left() - paperRect.left();
- int mbottom = paperRect.bottom() - pageRect.bottom();
- int mright = paperRect.right() - pageRect.right();
- int width = pageRect.width();
- int height = pageRect.height();
- if (finished && pageCount == 1 && copies == 1 &&
- ((fullPage && qt_gen_epsf) || (outputFileName.endsWith(QLatin1String(".eps")))))
- {
- // According to the EPSF 3.0 spec it is required that the PS
- // version is PS-Adobe-3.0
- s << "%!PS-Adobe-3.0";
- if (!boundingBox.isValid())
- boundingBox.setRect(0, 0, width, height);
- if (orientation == QPrinter::Landscape) {
- if (!fullPage)
- boundingBox.translate(-mleft, -mtop);
- s << " EPSF-3.0\n%%BoundingBox: "
- << int((printer->height() - boundingBox.bottom())*scale) // llx
- << int((printer->width() - boundingBox.right())*scale - 1) // lly
- << int((printer->height() - boundingBox.top())*scale + 1) // urx
- << int((printer->width() - boundingBox.left())*scale); // ury
- } else {
- if (!fullPage)
- boundingBox.translate(mleft, -mtop);
- s << " EPSF-3.0\n%%BoundingBox: "
- << int((boundingBox.left())*scale)
- << int((printer->height() - boundingBox.bottom())*scale - 1)
- << int((boundingBox.right())*scale + 1)
- << int((printer->height() - boundingBox.top())*scale);
- }
- } else {
- s << "%!PS-Adobe-1.0";
- int w = width + (fullPage ? 0 : mleft + mright);
- int h = height + (fullPage ? 0 : mtop + mbottom);
- w = (int)(w*scale);
- h = (int)(h*scale);
- // set a bounding box according to the DSC
- if (orientation == QPrinter::Landscape)
- s << "\n%%BoundingBox: 0 0 " << h << w;
- else
- s << "\n%%BoundingBox: 0 0 " << w << h;
- }
- s << '\n' << wrapDSC("%%Creator: " + creator.toUtf8());
- if (!title.isEmpty())
- s << wrapDSC("%%Title: " + title.toUtf8());
-#ifndef QT_NO_DATESTRING
- s << "%%CreationDate: " << QDateTime::currentDateTime().toString().toUtf8();
-#endif
- s << "\n%%Orientation: ";
- if (orientation == QPrinter::Landscape)
- s << "Landscape";
- else
- s << "Portrait";
-
- s << "\n%%Pages: (atend)"
- "\n%%DocumentFonts: (atend)"
- "\n%%EndComments\n"
-
- "%%BeginProlog\n"
- "% Prolog copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).\n"
- "% You may copy this prolog in any way that is directly related to this document.\n"
- "% For other use of this prolog, see your licensing agreement for Qt.\n"
- << ps_header << '\n';
-
-
- s << "/pageinit {\n";
- if (!fullPage) {
- if (orientation == QPrinter::Portrait)
- s << mleft*scale << mbottom*scale << "translate\n";
- else
- s << mtop*scale << mleft*scale << "translate\n";
- }
- if (orientation == QPrinter::Portrait) {
- s << "% " << printer->widthMM() << '*' << printer->heightMM()
- << "mm (portrait)\n0 " << height*scale
- << "translate " << scale << '-' << scale << "scale } def\n";
- } else {
- s << "% " << printer->heightMM() << '*' << printer->widthMM()
- << " mm (landscape)\n 90 rotate " << scale << '-' << scale << "scale } def\n";
- }
- s << "%%EndProlog\n";
-
- outDevice->write(header);
- headerDone = true;
-}
-
-
-void QPSPrintEnginePrivate::emitPages()
-{
- if (!hugeDocument) {
- for (QHash<QFontEngine::FaceId, QFontSubset *>::const_iterator it = fonts.constBegin();
- it != fonts.constEnd(); ++it)
- outDevice->write((*it)->toType1());
- }
-
- QIODevice *content = buffer.stream();
- // Write the page contents in chunks.
- while (!content->atEnd()) {
- QByteArray buf = content->read(currentPage->chunkSize());
- if (!buf.isEmpty())
- outDevice->write(buf);
- }
- content = currentPage->stream();
- // Write the page contents in chunks.
- while (!content->atEnd()) {
- QByteArray buf = content->read(currentPage->chunkSize());
- if (!buf.isEmpty())
- outDevice->write(buf);
- }
- outDevice->write(trailer);
-
- buffer.clear();
- currentPage->clear();
- trailer = QByteArray();
- hugeDocument = true;
-}
-
-
-#ifdef Q_WS_QWS
-static const int max_in_memory_size = 2000000;
-#else
-static const int max_in_memory_size = 32000000;
-#endif
-
-void QPSPrintEnginePrivate::flushPage(bool last)
-{
- if (!last && currentPage->stream()->size() == 0)
- return;
-
- QPdf::ByteStream e(&trailer);
- buffer << "%%Page: "
- << pageCount << pageCount << "\n"
- "%%BeginPageSetup\n"
- "QI\n";
- if (hugeDocument) {
- for (QHash<QFontEngine::FaceId, QFontSubset *>::const_iterator it = fonts.constBegin();
- it != fonts.constEnd(); ++it) {
- if (currentPage->fonts.contains((*it)->object_id)) {
- if ((*it)->downloaded_glyphs == 0) {
- buffer << (*it)->toType1();
- (*it)->downloaded_glyphs = 0;
- } else {
- buffer << (*it)->type1AddedGlyphs();
- }
- }
- }
- }
- for (int i = 0; i < currentPage->fonts.size(); ++i)
- buffer << "(F" << QByteArray::number(currentPage->fonts.at(i)) << ") T1Setup\n";
-
- buffer << "%%EndPageSetup\nq\n";
- e << "\nQ QP\n";
- if (last || hugeDocument
- || buffer.stream()->size() + currentPage->stream()->size() > max_in_memory_size) {
-// qDebug("emiting header at page %d", pageCount);
- if (!headerDone)
- emitHeader(last);
- emitPages();
- } else {
- buffer << *currentPage << e;
- currentPage->clear();
- trailer.clear();
- }
- pageCount++;
-}
-
-// ================ PSPrinter class ========================
-
-QPSPrintEngine::QPSPrintEngine(QPrinter::PrinterMode m)
- : QPdfBaseEngine(*(new QPSPrintEnginePrivate(m)),
- PrimitiveTransform
- | PatternTransform
- | PixmapTransform
- | PainterPaths
- | PatternBrush
- )
-{
-}
-
-static void ignoreSigPipe(bool b)
-{
-#ifndef QT_NO_LPR
- static struct sigaction *users_sigpipe_handler = 0;
- static int lockCount = 0;
-
-#ifndef QT_NO_THREAD
- QMutexLocker locker(QMutexPool::globalInstanceGet(&users_sigpipe_handler));
-#endif
-
- if (b) {
- if (lockCount++ > 0)
- return;
-
- if (users_sigpipe_handler != 0)
- return; // already ignoring sigpipe
-
- users_sigpipe_handler = new struct sigaction;
- struct sigaction tmp_sigpipe_handler;
- tmp_sigpipe_handler.sa_handler = SIG_IGN;
- sigemptyset(&tmp_sigpipe_handler.sa_mask);
- tmp_sigpipe_handler.sa_flags = 0;
-
- if (sigaction(SIGPIPE, &tmp_sigpipe_handler, users_sigpipe_handler) == -1) {
- delete users_sigpipe_handler;
- users_sigpipe_handler = 0;
- }
- }
- else {
- if (--lockCount > 0)
- return;
-
- if (users_sigpipe_handler == 0)
- return; // not ignoring sigpipe
-
- if (sigaction(SIGPIPE, users_sigpipe_handler, 0) == -1)
- qWarning("QPSPrintEngine: Could not restore SIGPIPE handler");
-
- delete users_sigpipe_handler;
- users_sigpipe_handler = 0;
- }
-#else
- Q_UNUSED(b);
-#endif
-}
-QPSPrintEngine::~QPSPrintEngine()
-{
- Q_D(QPSPrintEngine);
- if (d->fd >= 0)
-#if defined(Q_OS_WIN) && defined(_MSC_VER) && _MSC_VER >= 1400
- ::_close(d->fd);
-#else
- ::close(d->fd);
-#endif
-}
-
-bool QPSPrintEngine::begin(QPaintDevice *pdev)
-{
- Q_D(QPSPrintEngine);
-
- if (d->fd >= 0)
- return true;
-
- if (d->useAlphaEngine) {
- QAlphaPaintEngine::begin(pdev);
- if (!continueCall())
- return true;
- }
-
- if(!QPdfBaseEngine::begin(pdev)) {
- d->printerState = QPrinter::Error;
- return false;
- }
-
- d->pageCount = 1; // initialize state
-
- d->pen = QPen(Qt::black);
- d->brush = Qt::NoBrush;
- d->hasPen = true;
- d->hasBrush = false;
- d->clipEnabled = false;
- d->allClipped = false;
- d->boundingBox = QRect();
- d->fontsUsed = "";
- d->hugeDocument = false;
- d->simplePen = false;
-
- setActive(true);
- d->printerState = QPrinter::Active;
-
- newPage();
-
- return true;
-}
-
-bool QPSPrintEngine::end()
-{
- Q_D(QPSPrintEngine);
-
- if (d->useAlphaEngine) {
- QAlphaPaintEngine::end();
- if (!continueCall())
- return true;
- }
-
- // we're writing to lp/lpr through a pipe, we don't want to crash with SIGPIPE
- // if lp/lpr dies
- ignoreSigPipe(true);
- d->flushPage(true);
- QByteArray trailer;
- QPdf::ByteStream s(&trailer);
- s << "%%Trailer\n"
- "%%Pages: " << d->pageCount - 1 << '\n' <<
- wrapDSC("%%DocumentFonts: " + d->fontsUsed);
- s << "%%EOF\n";
- d->outDevice->write(trailer);
-
- QPdfBaseEngine::end();
- ignoreSigPipe(false);
-
- d->firstPage = true;
- d->headerDone = false;
-
- setActive(false);
- d->printerState = QPrinter::Idle;
- d->pdev = 0;
-
- return true;
-}
-
-void QPSPrintEngine::setBrush()
-{
- Q_D(QPSPrintEngine);
-#if 0
- bool specifyColor;
- int gStateObject = 0;
- int patternObject = d->addBrushPattern(brush, d->stroker.matrix, brushOrigin, &specifyColor, &gStateObject);
-
- *d->currentPage << (patternObject ? "/PCSp cs " : "/CSp cs ");
- if (specifyColor) {
- QColor rgba = brush.color();
- *d->currentPage << rgba.redF()
- << rgba.greenF()
- << rgba.blueF();
- }
- if (patternObject)
- *d->currentPage << "/Pat" << patternObject;
- *d->currentPage << "scn\n";
-#endif
- QColor rgba = d->brush.color();
- if (d->colorMode == QPrinter::GrayScale) {
- qreal gray = qGray(rgba.rgba())/255.;
- *d->currentPage << gray << gray << gray;
- } else {
- *d->currentPage << rgba.redF()
- << rgba.greenF()
- << rgba.blueF();
- }
- *d->currentPage << "scn\n"
- << "/BSt " << d->brush.style() << "def\n";
-}
-
-void QPSPrintEngine::drawImageInternal(const QRectF &r, QImage image, bool bitmap)
-{
- Q_D(QPSPrintEngine);
- if (d->clipEnabled && d->allClipped)
- return;
- if (bitmap && image.depth() != 1)
- bitmap = false;
- QImage mask;
- // the below is not necessary since it's handled by the alpha
- // engine
- if (!d->useAlphaEngine && !bitmap) {
- if (image.format() == QImage::Format_Mono || image.format() == QImage::Format_MonoLSB)
- image = image.convertToFormat(QImage::Format_Indexed8);
- if (image.hasAlphaChannel()) {
- // get better alpha dithering
- int xscale = image.width();
- xscale *= xscale <= 800 ? 4 : (xscale <= 1600 ? 2 : 1);
- int yscale = image.height();
- yscale *= yscale <= 800 ? 4 : (yscale <= 1600 ? 2 : 1);
- image = image.scaled(xscale, yscale);
- mask = image.createAlphaMask(Qt::OrderedAlphaDither);
- }
- }
- *d->currentPage << "q\n";
- if(!d->simplePen)
- *d->currentPage << QPdf::generateMatrix(d->stroker.matrix);
- QBrush b = d->brush;
- if (image.depth() == 1) {
- // set current pen as brush
- d->brush = d->pen.brush();
- setBrush();
- }
- d->drawImage(r.x(), r.y(), r.width(), r.height(), image, mask);
- *d->currentPage << "Q\n";
- d->brush = b;
-}
-
-
-void QPSPrintEngine::drawImage(const QRectF &r, const QImage &img, const QRectF &sr,
- Qt::ImageConversionFlags)
-{
- Q_D(QPSPrintEngine);
-
- if (d->useAlphaEngine) {
- QAlphaPaintEngine::drawImage(r, img, sr);
- if (!continueCall())
- return;
- }
- QImage image = img.copy(sr.toRect());
- drawImageInternal(r, image, false);
-}
-
-void QPSPrintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)
-{
- Q_D(QPSPrintEngine);
-
- if (d->useAlphaEngine) {
- QAlphaPaintEngine::drawPixmap(r, pm, sr);
- if (!continueCall())
- return;
- }
-
- QImage img = pm.copy(sr.toRect()).toImage();
- drawImageInternal(r, img, true);
-}
-
-void QPSPrintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &p)
-{
- Q_D(QPSPrintEngine);
-
- if (d->useAlphaEngine) {
- QAlphaPaintEngine::drawTiledPixmap(r, pixmap, p);
- if (!continueCall())
- return;
- }
-
- if (d->clipEnabled && d->allClipped)
- return;
- // ### Optimize implementation!
- qreal yPos = r.y();
- qreal yOff = p.y();
- while(yPos < r.y() + r.height()) {
- qreal drawH = pixmap.height() - yOff; // Cropping first row
- if (yPos + drawH > r.y() + r.height()) // Cropping last row
- drawH = r.y() + r.height() - yPos;
- qreal xPos = r.x();
- qreal xOff = p.x();
- while(xPos < r.x() + r.width()) {
- qreal drawW = pixmap.width() - xOff; // Cropping first column
- if (xPos + drawW > r.x() + r.width()) // Cropping last column
- drawW = r.x() + r.width() - xPos;
- // ########
- painter()->drawPixmap(QPointF(xPos, yPos).toPoint(), pixmap,
- QRectF(xOff, yOff, drawW, drawH).toRect());
- xPos += drawW;
- xOff = 0;
- }
- yPos += drawH;
- yOff = 0;
- }
-
-}
-
-bool QPSPrintEngine::newPage()
-{
- Q_D(QPSPrintEngine);
-
- if (!d->firstPage && d->useAlphaEngine)
- flushAndInit();
-
- // we're writing to lp/lpr through a pipe, we don't want to crash with SIGPIPE
- // if lp/lpr dies
- ignoreSigPipe(true);
- if (!d->firstPage)
- d->flushPage();
- d->firstPage = false;
- ignoreSigPipe(false);
-
- delete d->currentPage;
- d->currentPage = new QPdfPage;
- d->stroker.stream = d->currentPage;
-
- return QPdfBaseEngine::newPage();
-}
-
-bool QPSPrintEngine::abort()
-{
- // ### abort!?!
- return false;
-}
-
-QPrinter::PrinterState QPSPrintEngine::printerState() const
-{
- Q_D(const QPSPrintEngine);
- return d->printerState;
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_PRINTER
diff --git a/src/gui/painting/qprintengine_ps_p.h b/src/gui/painting/qprintengine_ps_p.h
deleted file mode 100644
index a1185d7867..0000000000
--- a/src/gui/painting/qprintengine_ps_p.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPRINTENGINE_PS_P_H
-#define QPRINTENGINE_PS_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of qpsprinter.cpp and qprinter_x11.cpp.
-// This header file may change from version to version without notice,
-// or even be removed.
-//
-// We mean it.
-//
-
-#ifndef QT_NO_PRINTER
-
-#include "private/qpdf_p.h"
-#include "qplatformdefs.h"
-#include "QtCore/qlibrary.h"
-#include "QtCore/qstringlist.h"
-#include "QtCore/qhash.h"
-#include "QtCore/qabstractitemmodel.h"
-
-QT_BEGIN_NAMESPACE
-
-class QPrinter;
-class QPSPrintEnginePrivate;
-
-class QPSPrintEngine : public QPdfBaseEngine
-{
- Q_DECLARE_PRIVATE(QPSPrintEngine)
-public:
- // QPrinter uses these
- explicit QPSPrintEngine(QPrinter::PrinterMode m);
- ~QPSPrintEngine();
-
-
- virtual bool begin(QPaintDevice *pdev);
- virtual bool end();
-
- void setBrush();
-
- virtual void drawImage(const QRectF &r, const QImage &img, const QRectF &sr, Qt::ImageConversionFlags);
- virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr);
- virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
-
- virtual void drawImageInternal(const QRectF &r, QImage img, bool bitmap);
-
- virtual QPaintEngine::Type type() const { return QPaintEngine::PostScript; }
-
- virtual bool newPage();
- virtual bool abort();
-
- virtual QPrinter::PrinterState printerState() const;
-
- virtual Qt::HANDLE handle() const { return 0; }
-
-private:
- Q_DISABLE_COPY(QPSPrintEngine)
-};
-
-class QPSPrintEnginePrivate : public QPdfBaseEnginePrivate {
-public:
- QPSPrintEnginePrivate(QPrinter::PrinterMode m);
- ~QPSPrintEnginePrivate();
-
- void emitHeader(bool finished);
- void emitPages();
- void drawImage(qreal x, qreal y, qreal w, qreal h, const QImage &img, const QImage &mask);
- void flushPage(bool last = false);
- void drawImageHelper(qreal x, qreal y, qreal w, qreal h, const QImage &img, const QImage &mask,
- bool gray, qreal scaleX, qreal scaleY);
-
- int pageCount;
- bool epsf;
- QByteArray fontsUsed;
-
- // stores the descriptions of the n first pages.
- QPdf::ByteStream buffer;
- QByteArray trailer;
-
- bool firstPage;
-
- QRect boundingBox;
-
- QPrinter::PrinterState printerState;
- bool hugeDocument;
- bool headerDone;
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_PRINTER
-
-#endif // QPRINTENGINE_PS_P_H
diff --git a/src/gui/painting/qprintengine_qws.cpp b/src/gui/painting/qprintengine_qws.cpp
deleted file mode 100644
index 1aef2c68cf..0000000000
--- a/src/gui/painting/qprintengine_qws.cpp
+++ /dev/null
@@ -1,886 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <private/qprintengine_qws_p.h>
-
-#ifndef QT_NO_PRINTER
-
-#include <private/qpaintengine_raster_p.h>
-#include <qimage.h>
-#include <qfile.h>
-#include <qdebug.h>
-#include <QCopChannel>
-
-QT_BEGIN_NAMESPACE
-
-#define MM(n) int((n * 720 + 127) / 254)
-#define IN(n) int(n * 72)
-
-extern QSizeF qt_paperSizeToQSizeF(QPrinter::PaperSize size);
-
-QtopiaPrintEngine::QtopiaPrintEngine(QPrinter::PrinterMode mode)
- : QPaintEngine(*(new QtopiaPrintEnginePrivate( mode )))
-{
- d_func()->initialize();
-}
-
-bool QtopiaPrintEngine::begin(QPaintDevice *)
-{
- Q_D(QtopiaPrintEngine);
- Q_ASSERT_X(d->printerState == QPrinter::Idle, "QtopiaPrintEngine", "printer already active");
-
- // Create a new off-screen monochrome image to handle the drawing process.
- QSize size = paperRect().size();
- if ( d->pageImage )
- delete d->pageImage;
- d->pageImage = new QImage( size, QImage::Format_RGB32 );
- if ( !(d->pageImage) )
- return false;
-
- // Recreate the paint engine on the new image.
- delete d->_paintEngine;
- d->_paintEngine = 0;
- d->paintEngine()->state = state;
-
- // Begin the paint process on the image.
- if (!d->paintEngine()->begin(d->pageImage))
- return false;
-
- // Clear the first page to all-white.
- clearPage();
-
- // Clear the print buffer and output the image header.
- d->buffer.clear();
- d->writeG3FaxHeader();
-
- // The print engine is currently active.
- d->printerState = QPrinter::Active;
- return true;
-}
-
-bool QtopiaPrintEngine::end()
-{
- Q_D(QtopiaPrintEngine);
-
- d->paintEngine()->end();
-
- // Flush the last page.
- flushPage();
-
- // Output the fax data to a file (TODO: send to the print queuing daemon).
- QString filename;
- if ( !d->outputFileName.isEmpty() )
- filename = QString::fromLocal8Bit(qgetenv("HOME").constData()) + QLatin1String("/Documents/") + d->outputFileName;
- else
- filename = QString::fromLocal8Bit(qgetenv("HOME").constData()) + QLatin1String("/tmp/qwsfax.tiff");
-
- setProperty(QPrintEngine::PPK_OutputFileName, filename);
- QFile file( filename );
- if ( !file.open( QIODevice::WriteOnly | QIODevice::Truncate ) ) {
- qDebug( "Failed to open %s for printer output",
- filename.toLatin1().constData() );
- } else {
- file.write( d->buffer.data() );
- file.close();
- }
-
- // Free up the memory for the image buffer.
- d->buffer.clear();
-
- // Finalize the print job.
- d->printerState = QPrinter::Idle;
-
- // call qcop service
- QMap<QString, QVariant> map;
- for ( int x = 0; x <= QPrintEngine::PPK_Duplex; x++ )
- map.insert( QString::number(x), property((QPrintEngine::PrintEnginePropertyKey)(x)));
- QVariant variant(map);
-
- QByteArray data;
- QDataStream out(&data, QIODevice::WriteOnly);
- out << variant;
- QCopChannel::send(QLatin1String("QPE/Service/Print"), QLatin1String("print(QVariant)"), data);
-
- return true;
-}
-
-QPaintEngine *QtopiaPrintEngine::paintEngine() const
-{
- return const_cast<QtopiaPrintEnginePrivate *>(d_func())->paintEngine();
-}
-
-void QtopiaPrintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)
-{
- Q_D(QtopiaPrintEngine);
- Q_ASSERT(d->printerState == QPrinter::Active);
- d->paintEngine()->drawPixmap(r, pm, sr);
-}
-
-void QtopiaPrintEngine::drawTextItem(const QPointF &p, const QTextItem &ti)
-{
- Q_D(QtopiaPrintEngine);
- Q_ASSERT(d->printerState == QPrinter::Active);
- d->paintEngine()->drawTextItem(p, ti);
-}
-
-void QtopiaPrintEngine::updateState(const QPaintEngineState &state)
-{
- Q_D(QtopiaPrintEngine);
- d->paintEngine()->updateState(state);
-}
-
-QRect QtopiaPrintEngine::paperRect() const
-{
- QSizeF s = qt_paperSizeToQSizeF(d_func()->paperSize);
- s.rwidth() = MM(s.width());
- s.rheight() = MM(s.height());
- int w = qRound(s.width()*d_func()->resolution/72.);
- int h = qRound(s.height()*d_func()->resolution/72.);
- if (d_func()->orientation == QPrinter::Portrait)
- return QRect(0, 0, w, h);
- else
- return QRect(0, 0, h, w);
-}
-
-QRect QtopiaPrintEngine::pageRect() const
-{
- QRect r = paperRect();
- if (d_func()->fullPage)
- return r;
- // would be nice to get better margins than this.
- return QRect(d_func()->resolution/3, d_func()->resolution/3, r.width()-2*d_func()->resolution/3, r.height()-2*d_func()->resolution/3);
-}
-
-bool QtopiaPrintEngine::newPage()
-{
- flushPage();
- clearPage();
- ++(d_func()->pageNumber);
- return true;
-}
-
-bool QtopiaPrintEngine::abort()
-{
- return false;
-}
-
-QPrinter::PrinterState QtopiaPrintEngine::printerState() const
-{
- return d_func()->printerState;
-}
-
-int QtopiaPrintEngine::metric(QPaintDevice::PaintDeviceMetric metricType) const
-{
- int val;
- QRect r = d_func()->fullPage ? paperRect() : pageRect();
- switch (metricType) {
- case QPaintDevice::PdmWidth:
- val = r.width();
- break;
- case QPaintDevice::PdmHeight:
- val = r.height();
- break;
- case QPaintDevice::PdmDpiX:
- val = d_func()->resolution;
- break;
- case QPaintDevice::PdmDpiY:
- val = d_func()->resolution;
- break;
- case QPaintDevice::PdmPhysicalDpiX:
- case QPaintDevice::PdmPhysicalDpiY:
- val = QT_QWS_PRINTER_DEFAULT_DPI;
- break;
- case QPaintDevice::PdmWidthMM:
- val = qRound(r.width()*25.4/d_func()->resolution);
- break;
- case QPaintDevice::PdmHeightMM:
- val = qRound(r.height()*25.4/d_func()->resolution);
- break;
- case QPaintDevice::PdmNumColors:
- val = 2;
- break;
- case QPaintDevice::PdmDepth:
- val = 1;
- break;
- default:
- qWarning("QtopiaPrintEngine::metric: Invalid metric command");
- return 0;
- }
- return val;
-}
-
-QVariant QtopiaPrintEngine::property(PrintEnginePropertyKey key) const
-{
- Q_D(const QtopiaPrintEngine);
- QVariant ret;
-
- switch (key) {
- case PPK_CollateCopies:
- ret = d->collateCopies;
- break;
- case PPK_ColorMode:
- ret = d->colorMode;
- break;
- case PPK_Creator:
- ret = d->creator;
- break;
- case PPK_DocumentName:
- ret = d->docName;
- break;
- case PPK_FullPage:
- ret = d->fullPage;
- break;
- case PPK_CopyCount: // fallthrough
- case PPK_NumberOfCopies:
- ret = d->numCopies;
- break;
- case PPK_SupportsMultipleCopies:
- ret = false;
- break;
- case PPK_Orientation:
- ret = d->orientation;
- break;
- case PPK_OutputFileName:
- ret = d->outputFileName;
- break;
- case PPK_PageOrder:
- ret = d->pageOrder;
- break;
- case PPK_PageRect:
- ret = pageRect();
- break;
- case PPK_PaperSize:
- ret = d->paperSize;
- break;
- case PPK_PaperRect:
- ret = paperRect();
- break;
- case PPK_PaperSource:
- ret = d->paperSource;
- break;
- case PPK_PrinterName:
- ret = d->printerName;
- break;
- case PPK_PrinterProgram:
- ret = d->printProgram;
- break;
- case PPK_Resolution:
- ret = d->resolution;
- break;
- case PPK_SupportedResolutions:
- ret = QList<QVariant>() << QT_QWS_PRINTER_DEFAULT_DPI;
- break;
- default:
- break;
- }
- return ret;
-}
-
-void QtopiaPrintEngine::setProperty(PrintEnginePropertyKey key, const QVariant &value)
-{
- Q_D(QtopiaPrintEngine);
- switch (key) {
- case PPK_CollateCopies:
- d->collateCopies = value.toBool();
- break;
- case PPK_ColorMode:
- d->colorMode = QPrinter::ColorMode(value.toInt());
- break;
- case PPK_Creator:
- d->creator = value.toString();
- break;
- case PPK_DocumentName:
- d->docName = value.toString();
- break;
- case PPK_FullPage:
- d->fullPage = value.toBool();
- break;
- case PPK_CopyCount: // fallthrough
- case PPK_NumberOfCopies:
- d->numCopies = value.toInt();
- break;
- case PPK_Orientation:
- d->orientation = QPrinter::Orientation(value.toInt());
- break;
- case PPK_OutputFileName:
- d->outputFileName = value.toString();
- break;
- case PPK_PageOrder:
- d->pageOrder = QPrinter::PageOrder(value.toInt());
- break;
- case PPK_PaperSize:
- d->paperSize = QPrinter::PaperSize(value.toInt());
- break;
- case PPK_PaperSource:
- d->paperSource = QPrinter::PaperSource(value.toInt());
- case PPK_PrinterName:
- d->printerName = value.toString();
- break;
- case PPK_PrinterProgram:
- d->printProgram = value.toString();
- break;
- case PPK_Resolution:
- d->resolution = value.toInt();
- break;
- default:
- break;
- }
-}
-
-void QtopiaPrintEngine::clearPage()
-{
- d_func()->pageImage->fill(QColor(255, 255, 255).rgb());
-}
-
-void QtopiaPrintEngine::flushPage()
-{
- d_func()->writeG3FaxPage();
-}
-
-QtopiaPrintEnginePrivate::~QtopiaPrintEnginePrivate()
-{
- if ( pageImage )
- delete pageImage;
-}
-
-void QtopiaPrintEnginePrivate::initialize()
-{
- _paintEngine = 0;
-}
-
-QPaintEngine *QtopiaPrintEnginePrivate::paintEngine()
-{
- if (!_paintEngine)
- _paintEngine = new QRasterPaintEngine(pageImage);
- return _paintEngine;
-}
-
-void QtopiaPrintEnginePrivate::writeG3FaxHeader()
-{
- // Write the TIFF file magic number (little-endian TIFF).
- buffer.append( (char)'I' );
- buffer.append( (char)'I' );
- buffer.append( (char)42 );
- buffer.append( (char)0 );
-
- // Leave a place-holder for the IFD offset of the first page.
- ifdPatch = buffer.size();
- buffer.append( (int)0 );
-}
-
-// Tag values, from RFC 2301.
-#define TIFF_IFD_NEW_SUB_FILE_TYPE 254
-#define TIFF_IFD_IMAGE_WIDTH 256
-#define TIFF_IFD_IMAGE_LENGTH 257
-#define TIFF_IFD_BITS_PER_SAMPLE 258
-#define TIFF_IFD_COMPRESSION 259
-#define TIFF_IFD_PHOTOMETRIC_INTERP 262
-#define TIFF_IFD_FILL_ORDER 266
-#define TIFF_IFD_STRIP_OFFSETS 273
-#define TIFF_IFD_ORIENTATION 274
-#define TIFF_IFD_SAMPLES_PER_PIXEL 277
-#define TIFF_IFD_ROWS_PER_STRIP 278
-#define TIFF_IFD_STRIP_BYTE_COUNTS 279
-#define TIFF_IFD_X_RESOLUTION 282
-#define TIFF_IFD_Y_RESOLUTION 283
-#define TIFF_IFD_PLANAR_CONFIG 284
-#define TIFF_IFD_T4_OPTIONS 292
-#define TIFF_IFD_RESOLUTION_UNIT 296
-#define TIFF_IFD_PAGE_NUMBER 297
-#define TIFF_IFD_CLEAN_FAX_DATA 327
-
-// IFD type values.
-#define TIFF_TYPE_SHORT 3
-#define TIFF_TYPE_LONG 4
-#define TIFF_TYPE_RATIONAL 5
-
-// Construct a SHORT pair from two values.
-#define TIFF_SHORT_PAIR(a,b) (((a) & 0xFFFF) | ((b) << 16))
-
-// Width of a FAX page in pixels, in the baseline specification from RFC 2301.
-// This must be hard-wired, as per the RFC. We truncate any pixels that
-// are beyond this limit, or pad lines to reach this limit.
-#define TIFF_FAX_WIDTH 1728
-
-void QtopiaPrintEnginePrivate::writeG3FaxPage()
-{
- // Pad the image file to a word boundary, just in case.
- buffer.pad();
-
- // Back-patch the IFD link for the previous page.
- buffer.patch( ifdPatch, buffer.size() );
-
- // Output the contents of the IFD for this page (these must be
- // in ascending order of tag value).
- buffer.append( (short)19 ); // Number of IFD entries.
- writeG3IFDEntry( TIFF_IFD_NEW_SUB_FILE_TYPE, TIFF_TYPE_LONG, 1, 2 );
- writeG3IFDEntry( TIFF_IFD_IMAGE_WIDTH, TIFF_TYPE_LONG, 1, TIFF_FAX_WIDTH );
- writeG3IFDEntry
- ( TIFF_IFD_IMAGE_LENGTH, TIFF_TYPE_LONG, 1, pageImage->height() );
- writeG3IFDEntry( TIFF_IFD_BITS_PER_SAMPLE, TIFF_TYPE_SHORT, 1, 1 );
- writeG3IFDEntry( TIFF_IFD_COMPRESSION, TIFF_TYPE_SHORT, 1, 3 );
- writeG3IFDEntry( TIFF_IFD_PHOTOMETRIC_INTERP, TIFF_TYPE_SHORT, 1, 0 );
- writeG3IFDEntry( TIFF_IFD_FILL_ORDER, TIFF_TYPE_SHORT, 1, 1 );
- int stripOffsets =
- writeG3IFDEntry( TIFF_IFD_STRIP_OFFSETS, TIFF_TYPE_LONG, 1, 0 );
- writeG3IFDEntry( TIFF_IFD_ORIENTATION, TIFF_TYPE_SHORT, 1, 1 );
- writeG3IFDEntry( TIFF_IFD_SAMPLES_PER_PIXEL, TIFF_TYPE_SHORT, 1, 1 );
- writeG3IFDEntry
- ( TIFF_IFD_ROWS_PER_STRIP, TIFF_TYPE_LONG, 1, pageImage->height() );
- int stripBytes = writeG3IFDEntry
- ( TIFF_IFD_STRIP_BYTE_COUNTS, TIFF_TYPE_LONG, 1, 0 );
- int xres =
- writeG3IFDEntry( TIFF_IFD_X_RESOLUTION, TIFF_TYPE_RATIONAL, 1, 0 );
- int yres =
- writeG3IFDEntry( TIFF_IFD_Y_RESOLUTION, TIFF_TYPE_RATIONAL, 1, 0 );
- writeG3IFDEntry( TIFF_IFD_PLANAR_CONFIG, TIFF_TYPE_SHORT, 1, 1 );
- writeG3IFDEntry( TIFF_IFD_T4_OPTIONS, TIFF_TYPE_LONG, 1, 2 );
- writeG3IFDEntry( TIFF_IFD_RESOLUTION_UNIT, TIFF_TYPE_SHORT, 1, 2 );
- writeG3IFDEntry( TIFF_IFD_PAGE_NUMBER, TIFF_TYPE_SHORT, 2,
- TIFF_SHORT_PAIR( pageNumber, 0 ) );
- writeG3IFDEntry( TIFF_IFD_CLEAN_FAX_DATA, TIFF_TYPE_SHORT, 1, 0 );
-
- // Leave a place-holder for the IFD offset of the next page.
- ifdPatch = buffer.size();
- buffer.append( (int)0 );
-
- // Output the X and Y resolutions, as rational values (usually 200/1).
- buffer.patch( xres, buffer.size() );
- buffer.append( (int)resolution );
- buffer.append( (int)1 );
- buffer.patch( yres, buffer.size() );
- buffer.append( (int)resolution );
- buffer.append( (int)1 );
-
- // We are now at the start of the image data - set the strip offset.
- int start = buffer.size();
- buffer.patch( stripOffsets, start );
-
- // Output the image data.
- int width = pageImage->width();
- QImage::Format imageFormat = pageImage->format();
- for ( int y = 0; y < pageImage->height(); ++y ) {
- unsigned char *scan = pageImage->scanLine(y);
- int prev, pixel, len;
- writeG3EOL();
- prev = 0;
- len = 0;
-
- uint currentColor = qRgb(255, 255, 255); // start with white
-
- for ( int x = 0; x < width && x < TIFF_FAX_WIDTH; ++x ) {
- if ( imageFormat == QImage::Format_RGB32 ) {
- // read color of the current pixel
- uint *p = (uint *)scan + x;
-
- if ( *p == currentColor ) { // if it is the same color
- len++; // imcrement length
- } else { // otherwise write color into the buffer
- if ( len > 0 ) {
- if ( currentColor == qRgb(0, 0, 0) )
- writeG3BlackRun( len );
- else
- writeG3WhiteRun( len );
- }
- // initialise length and color;
- len = 1;
- currentColor = *p;
- }
- } else if ( imageFormat == QImage::Format_Mono ) {
- pixel = ((scan[x >> 3] & (1 << (x & 7))) != 0);
- if ( pixel != prev ) {
- if ( prev ) {
- writeG3BlackRun( len );
- } else {
- writeG3WhiteRun( len );
- }
- prev = pixel;
- len = 1;
- } else {
- ++len;
- }
- }
- }
-
- if ( imageFormat == QImage::Format_RGB32 ) {
- // Output the last run on the line, and pad to TIFF_FAX_WIDTH.
- if ( len != 0 ) {
- if ( currentColor == qRgb(0, 0, 0) )
- writeG3BlackRun( len );
- else
- writeG3WhiteRun( len );
- }
- if ( width < TIFF_FAX_WIDTH )
- writeG3WhiteRun( TIFF_FAX_WIDTH - width );
- } else if ( imageFormat == QImage::Format_Mono ) {
- if ( len != 0 ) {
- if ( prev ) {
- writeG3BlackRun( len );
- if ( width < TIFF_FAX_WIDTH ) {
- writeG3WhiteRun( TIFF_FAX_WIDTH - width );
- }
- } else {
- if ( width < TIFF_FAX_WIDTH ) {
- writeG3WhiteRun( len + ( TIFF_FAX_WIDTH - width ) );
- } else {
- writeG3WhiteRun( len );
- }
- }
- }
- }
- }
-
- // Flush the last partial byte, which is padded with zero fill bits.
- if ( partialBits > 0 ) {
- buffer.append( (char)( partialByte << ( 8 - partialBits ) ) );
- partialByte = 0;
- partialBits = 0;
- }
-
- // end of page add six EOLs
- for ( int i = 0; i < 6; i++ )
- writeG3EOL();
-
- // Update the byte count for the image data strip.
- buffer.patch( stripBytes, buffer.size() - start );
-}
-
-int QtopiaPrintEnginePrivate::writeG3IFDEntry
- ( int tag, int type, int count, int value )
-{
- buffer.append( (short)tag );
- buffer.append( (short)type );
- buffer.append( count );
- buffer.append( value );
- return buffer.size() - 4; // Offset of the value for back-patching.
-}
-
-void QtopiaPrintEnginePrivate::writeG3Code( int code, int bits )
-{
- partialByte = ( ( partialByte << bits ) | code );
- partialBits += bits;
- while ( partialBits >= 8 ) {
- partialBits -= 8;
- buffer.append( (char)( partialByte >> partialBits ) );
- }
-}
-
-void QtopiaPrintEnginePrivate::writeG3WhiteRun( int len )
-{
- static struct {
- unsigned short code;
- unsigned short bits;
- } whiteCodes[64 + 27] = {
- {0x0035, 8}, // 0
- {0x0007, 6},
- {0x0007, 4},
- {0x0008, 4},
- {0x000B, 4},
- {0x000C, 4},
- {0x000E, 4},
- {0x000F, 4},
- {0x0013, 5}, // 8
- {0x0014, 5},
- {0x0007, 5},
- {0x0008, 5},
- {0x0008, 6},
- {0x0003, 6},
- {0x0034, 6},
- {0x0035, 6},
- {0x002A, 6}, // 16
- {0x002B, 6},
- {0x0027, 7},
- {0x000C, 7},
- {0x0008, 7},
- {0x0017, 7},
- {0x0003, 7},
- {0x0004, 7},
- {0x0028, 7}, // 24
- {0x002B, 7},
- {0x0013, 7},
- {0x0024, 7},
- {0x0018, 7},
- {0x0002, 8},
- {0x0003, 8},
- {0x001A, 8},
- {0x001B, 8}, // 32
- {0x0012, 8},
- {0x0013, 8},
- {0x0014, 8},
- {0x0015, 8},
- {0x0016, 8},
- {0x0017, 8},
- {0x0028, 8},
- {0x0029, 8}, // 40
- {0x002A, 8},
- {0x002B, 8},
- {0x002C, 8},
- {0x002D, 8},
- {0x0004, 8},
- {0x0005, 8},
- {0x000A, 8},
- {0x000B, 8}, // 48
- {0x0052, 8},
- {0x0053, 8},
- {0x0054, 8},
- {0x0055, 8},
- {0x0024, 8},
- {0x0025, 8},
- {0x0058, 8},
- {0x0059, 8}, // 56
- {0x005A, 8},
- {0x005B, 8},
- {0x004A, 8},
- {0x004B, 8},
- {0x0032, 8},
- {0x0033, 8},
- {0x0034, 8},
- {0x001B, 5}, // Make up codes: 64
- {0x0012, 5}, // 128
- {0x0017, 6}, // 192
- {0x0037, 7}, // 256
- {0x0036, 8}, // 320
- {0x0037, 8}, // 384
- {0x0064, 8}, // 448
- {0x0065, 8}, // 512
- {0x0068, 8}, // 576
- {0x0067, 8}, // 640
- {0x00CC, 9}, // 704
- {0x00CD, 9}, // 768
- {0x00D2, 9}, // 832
- {0x00D3, 9}, // 896
- {0x00D4, 9}, // 960
- {0x00D5, 9}, // 1024
- {0x00D6, 9}, // 1088
- {0x00D7, 9}, // 1152
- {0x00D8, 9}, // 1216
- {0x00D9, 9}, // 1280
- {0x00DA, 9}, // 1344
- {0x00DB, 9}, // 1408
- {0x0098, 9}, // 1472
- {0x0099, 9}, // 1536
- {0x009A, 9}, // 1600
- {0x0018, 6}, // 1664
- {0x009B, 9}, // 1728
- };
- if ( len >= 64 ) {
- int index = 63 + (len >> 6);
- writeG3Code( whiteCodes[index].code, whiteCodes[index].bits );
- len &= 63;
- }
- writeG3Code( whiteCodes[len].code, whiteCodes[len].bits );
-}
-
-void QtopiaPrintEnginePrivate::writeG3BlackRun( int len )
-{
- static struct {
- unsigned short code;
- unsigned short bits;
- } blackCodes[64 + 27] = {
- {0x0037, 10}, // 0
- {0x0002, 3},
- {0x0003, 2},
- {0x0002, 2},
- {0x0003, 3},
- {0x0003, 4},
- {0x0002, 4},
- {0x0003, 5},
- {0x0005, 6}, // 8
- {0x0004, 6},
- {0x0004, 7},
- {0x0005, 7},
- {0x0007, 7},
- {0x0004, 8},
- {0x0007, 8},
- {0x0018, 9},
- {0x0017, 10}, // 16
- {0x0018, 10},
- {0x0008, 10},
- {0x0067, 11},
- {0x0068, 11},
- {0x006C, 11},
- {0x0037, 11},
- {0x0028, 11},
- {0x0017, 11}, // 24
- {0x0018, 11},
- {0x00CA, 12},
- {0x00CB, 12},
- {0x00CC, 12},
- {0x00CD, 12},
- {0x0068, 12},
- {0x0069, 12},
- {0x006A, 12}, // 32
- {0x006B, 12},
- {0x00D2, 12},
- {0x00D3, 12},
- {0x00D4, 12},
- {0x00D5, 12},
- {0x00D6, 12},
- {0x00D7, 12},
- {0x006C, 12}, // 40
- {0x006D, 12},
- {0x00DA, 12},
- {0x00DB, 12},
- {0x0054, 12},
- {0x0055, 12},
- {0x0056, 12},
- {0x0057, 12},
- {0x0064, 12}, // 48
- {0x0065, 12},
- {0x0052, 12},
- {0x0053, 12},
- {0x0024, 12},
- {0x0037, 12},
- {0x0038, 12},
- {0x0027, 12},
- {0x0028, 12}, // 56
- {0x0058, 12},
- {0x0059, 12},
- {0x002B, 12},
- {0x002C, 12},
- {0x005A, 12},
- {0x0066, 12},
- {0x0067, 12},
- {0x000F, 10}, // Make up codes: 64
- {0x00C8, 12}, // 128
- {0x00C9, 12}, // 192
- {0x005B, 12}, // 256
- {0x0033, 12}, // 320
- {0x0034, 12}, // 384
- {0x0035, 12}, // 448
- {0x006C, 13}, // 512
- {0x006D, 13}, // 576
- {0x004A, 13}, // 640
- {0x004B, 13}, // 704
- {0x004C, 13}, // 768
- {0x004D, 13}, // 832
- {0x0072, 13}, // 896
- {0x0073, 13}, // 960
- {0x0074, 13}, // 1024
- {0x0075, 13}, // 1088
- {0x0076, 13}, // 1152
- {0x0077, 13}, // 1216
- {0x0052, 13}, // 1280
- {0x0053, 13}, // 1344
- {0x0054, 13}, // 1408
- {0x0055, 13}, // 1472
- {0x005A, 13}, // 1536
- {0x005B, 13}, // 1600
- {0x0064, 13}, // 1664
- {0x0065, 13}, // 1728
- };
- if ( len >= 64 ) {
- int index = 63 + (len >> 6);
- writeG3Code( blackCodes[index].code, blackCodes[index].bits );
- len &= 63;
- }
- writeG3Code( blackCodes[len].code, blackCodes[len].bits );
-}
-
-void QtopiaPrintEnginePrivate::writeG3EOL()
-{
- int bitToPad;
- if ( partialBits <= 4 ) {
- bitToPad = 4 - partialBits;
- } else {
- bitToPad = 8 - partialBits + 4;
- }
-
- partialByte = ((partialByte << (bitToPad + 12)) | 0x0001);
- partialBits += bitToPad + 12;
-
- while ( partialBits >= 8 ) {
- partialBits -= 8;
- buffer.append( (char)(partialByte >> partialBits ) );
- }
-// writeG3Code( 0x0001, 12 );
-}
-
-void QtopiaPrintBuffer::append( short value )
-{
- if ( _bigEndian ) {
- _data.append( (char)(value >> 8) );
- _data.append( (char)value );
- } else {
- _data.append( (char)value );
- _data.append( (char)(value >> 8) );
- }
-}
-
-void QtopiaPrintBuffer::append( int value )
-{
- if ( _bigEndian ) {
- _data.append( (char)(value >> 24) );
- _data.append( (char)(value >> 16) );
- _data.append( (char)(value >> 8) );
- _data.append( (char)value );
- } else {
- _data.append( (char)value );
- _data.append( (char)(value >> 8) );
- _data.append( (char)(value >> 16) );
- _data.append( (char)(value >> 24) );
- }
-}
-
-void QtopiaPrintBuffer::patch( int posn, int value )
-{
- if ( _bigEndian ) {
- _data[posn] = (char)(value >> 24);
- _data[posn + 1] = (char)(value >> 16);
- _data[posn + 2] = (char)(value >> 8);
- _data[posn + 3] = (char)value;
- } else {
- _data[posn] = (char)value;
- _data[posn + 1] = (char)(value >> 8);
- _data[posn + 2] = (char)(value >> 16);
- _data[posn + 3] = (char)(value >> 24);
- }
-}
-
-void QtopiaPrintBuffer::pad()
-{
- while ( ( _data.size() % 4 ) != 0 )
- _data.append( (char)0 );
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_PRINTER
diff --git a/src/gui/painting/qprintengine_qws_p.h b/src/gui/painting/qprintengine_qws_p.h
deleted file mode 100644
index 59cbe3eba8..0000000000
--- a/src/gui/painting/qprintengine_qws_p.h
+++ /dev/null
@@ -1,213 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPRINTENGINE_QWS_P_H
-#define QPRINTENGINE_QWS_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "QtGui/qprinter.h"
-
-#ifndef QT_NO_PRINTER
-
-#include "QtGui/qprintengine.h"
-#include "QtCore/qbytearray.h"
-#include "private/qpaintengine_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QtopiaPrintEnginePrivate;
-class QRasterPaintEngine;
-class QPrinterPrivate;
-class QImage;
-
-class QtopiaPrintEngine : public QPaintEngine, public QPrintEngine
-{
- Q_DECLARE_PRIVATE(QtopiaPrintEngine)
-public:
- QtopiaPrintEngine(QPrinter::PrinterMode mode);
-
- // override QWSPaintEngine
- bool begin(QPaintDevice *dev);
- bool end();
- void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr);
- void drawTextItem(const QPointF &p, const QTextItem &ti);
- QPaintEngine::Type type() const { return QPaintEngine::X11; }
-
- QPaintEngine *paintEngine() const;
-
- void updateState(const QPaintEngineState &state);
-
- QRect paperRect() const;
- QRect pageRect() const;
-
- bool newPage();
- bool abort();
-
- QPrinter::PrinterState printerState() const;
-
- int metric(QPaintDevice::PaintDeviceMetric metricType) const;
-
- QVariant property(PrintEnginePropertyKey key) const;
- void setProperty(PrintEnginePropertyKey key, const QVariant &value);
-
-private:
- friend class QPrintDialog;
- friend class QPageSetupDialog;
-
- void clearPage();
- void flushPage();
-};
-
-class QtopiaPrintBuffer
-{
-public:
- QtopiaPrintBuffer( bool bigEndian=FALSE ) { _bigEndian = bigEndian; }
- ~QtopiaPrintBuffer() {}
-
- const QByteArray& data() const { return _data; }
-
- int size() const { return _data.size(); }
-
- void clear() { _data.clear(); }
-
- void append( char value ) { _data.append( value ); }
- void append( short value );
- void append( int value );
- void append( const QByteArray& array ) { _data.append( array ); }
-
- void patch( int posn, int value );
-
- void pad();
-
-private:
- QByteArray _data;
- bool _bigEndian;
-};
-
-#define QT_QWS_PRINTER_DEFAULT_DPI 200
-
-class QtopiaPrintEnginePrivate : public QPaintEnginePrivate
-{
- Q_DECLARE_PUBLIC(QtopiaPrintEngine)
-public:
- QtopiaPrintEnginePrivate(QPrinter::PrinterMode m) :
- mode(m),
- printerState(QPrinter::Idle),
- orientation(QPrinter::Portrait),
- paperSize(QPrinter::A4),
- pageOrder(QPrinter::FirstPageFirst),
- colorMode(QPrinter::GrayScale),
- paperSource(QPrinter::OnlyOne),
- resolution(QT_QWS_PRINTER_DEFAULT_DPI),
- _paintEngine(0),
- numCopies(1),
- outputToFile(false),
- fullPage(false),
- collateCopies(false),
- pageNumber(0),
- pageImage(0),
- partialByte(0),
- partialBits(0)
- {
- }
- ~QtopiaPrintEnginePrivate();
-
- void initialize();
- QPaintEngine *paintEngine();
-
- QPrinter::PrinterMode mode;
-
- QString printerName;
- QString outputFileName;
- QString printProgram;
- QString docName;
- QString creator;
-
- QPrinter::PrinterState printerState;
-
- QPrinter::Orientation orientation;
- QPrinter::PaperSize paperSize;
- QPrinter::PageOrder pageOrder;
- QPrinter::ColorMode colorMode;
- QPrinter::PaperSource paperSource;
-
- int resolution;
- QPaintEngine *_paintEngine;
- int numCopies;
-
- bool outputToFile;
- bool fullPage;
- bool collateCopies;
-
- int pageNumber;
-
- QImage *pageImage;
-
- QtopiaPrintBuffer buffer;
-
- // Definitions that are only relevant to G3FAX output.
- int ifdPatch;
- int partialByte;
- int partialBits;
- void writeG3FaxHeader();
- void writeG3FaxPage();
- int writeG3IFDEntry( int tag, int type, int count, int value );
- void writeG3Code( int code, int bits );
- void writeG3WhiteRun( int len );
- void writeG3BlackRun( int len );
- void writeG3EOL();
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_PRINTER
-
-#endif // QPRINTENGINE_QWS_P_H
diff --git a/src/gui/painting/qprinter.cpp b/src/gui/painting/qprinter.cpp
index 5111bf4e2d..4a0b8d1d66 100644
--- a/src/gui/painting/qprinter.cpp
+++ b/src/gui/painting/qprinter.cpp
@@ -44,8 +44,7 @@
#include "qprintengine.h"
#include "qprinterinfo.h"
#include "qlist.h"
-#include <qpagesetupdialog.h>
-#include <qapplication.h>
+#include <qcoreapplication.h>
#include <qfileinfo.h>
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
#include "private/qcups_p.h"
@@ -60,7 +59,6 @@
#elif defined (QTOPIA_PRINTENGINE)
#include <private/qprintengine_qws_p.h>
#endif
-#include <private/qprintengine_ps_p.h>
#if defined(Q_WS_X11)
#include <private/qt_x11_p.h>
@@ -73,10 +71,6 @@
#include <qpicture.h>
#include <private/qpaintengine_preview_p.h>
-#if defined(QT3_SUPPORT)
-# include "qprintdialog.h"
-#endif // QT3_SUPPORT
-
QT_BEGIN_NAMESPACE
#define ABORT_IF_ACTIVE(location) \
@@ -120,7 +114,7 @@ static const float qt_paperSizes[][2] = {
};
/// return the multiplier of converting from the unit value to postscript-points.
-double qt_multiplierForUnit(QPrinter::Unit unit, int resolution)
+Q_GUI_EXPORT double qt_multiplierForUnit(QPrinter::Unit unit, int resolution)
{
switch(unit) {
case QPrinter::Millimeter:
@@ -142,7 +136,7 @@ double qt_multiplierForUnit(QPrinter::Unit unit, int resolution)
}
// not static: it's needed in qpagesetupdialog_unix.cpp
-QSizeF qt_printerPaperSize(QPrinter::Orientation orientation,
+Q_GUI_EXPORT QSizeF qt_printerPaperSize(QPrinter::Orientation orientation,
QPrinter::PaperSize paperSize,
QPrinter::Unit unit,
int resolution)
@@ -164,7 +158,7 @@ void QPrinterPrivate::createDefaultEngines()
#if !defined (QTOPIA_PRINTENGINE)
#if defined (Q_OS_UNIX) && ! defined (Q_WS_MAC)
if(outputFormat == QPrinter::NativeFormat) {
- realOutputFormat = QPrinter::PostScriptFormat;
+ realOutputFormat = QPrinter::PdfFormat;
}
#endif
#endif
@@ -194,12 +188,6 @@ void QPrinterPrivate::createDefaultEngines()
printEngine = pdfEngine;
}
break;
- case QPrinter::PostScriptFormat: {
- QPSPrintEngine *psEngine = new QPSPrintEngine(printerMode);
- paintEngine = psEngine;
- printEngine = psEngine;
- }
- break;
}
use_default_engine = true;
had_default_engines = true;
@@ -260,7 +248,7 @@ void QPrinterPrivate::addToManualSetList(QPrintEngine::PrintEnginePropertyKey ke
When printing directly to a printer on Windows or Mac OS X, QPrinter uses
the built-in printer drivers. On X11, QPrinter uses the
\l{Common Unix Printing System (CUPS)} or the standard Unix \l lpr utility
- to send PostScript or PDF output to the printer. As an alternative,
+ to send PDF output to the printer. As an alternative,
the printProgram() function can be used to specify the command or utility
to use instead of the system default.
@@ -347,8 +335,8 @@ void QPrinterPrivate::addToManualSetList(QPrintEngine::PrintEnginePropertyKey ke
printer code.
\value HighResolution On Windows, sets the printer resolution to that
- defined for the printer in use. For PostScript printing, sets the
- resolution of the PostScript driver to 1200 dpi.
+ defined for the printer in use. For PDF printing, sets the
+ resolution of the PDF driver to 1200 dpi.
\note When rendering text on a QPrinter device, it is important
to realize that the size of text, when specified in points, is
@@ -627,9 +615,9 @@ QPrinter::QPrinter(const QPrinterInfo& printer, PrinterMode mode)
void QPrinter::init(PrinterMode mode)
{
#if !defined(Q_WS_X11)
- if (!qApp) {
+ if (!QCoreApplication::instance()) {
#else
- if (!qApp || !X11) {
+ if (!QCoreApplication::instance() || !X11) {
#endif
qFatal("QPrinter: Must construct a QApplication before a QPaintDevice");
return;
@@ -709,9 +697,6 @@ QPrinter::~QPrinter()
\value PdfFormat QPrinter will generate its output as a searchable PDF file.
This mode is the default when printing to a file.
- \value PostScriptFormat QPrinter will generate its output as in the PostScript format.
- (This feature was introduced in Qt 4.2.)
-
\sa outputFormat(), setOutputFormat(), setOutputFileName()
*/
@@ -753,7 +738,7 @@ void QPrinter::setOutputFormat(OutputFormat format)
if (def_engine)
delete oldPrintEngine;
- if (d->outputFormat == QPrinter::PdfFormat || d->outputFormat == QPrinter::PostScriptFormat)
+ if (d->outputFormat == QPrinter::PdfFormat)
d->validPrinter = true;
#else
Q_UNUSED(format);
@@ -803,20 +788,15 @@ void QPrinter::setPrinterName(const QString &name)
ABORT_IF_ACTIVE("QPrinter::setPrinterName");
#if defined(Q_OS_UNIX) && !defined(QT_NO_CUPS)
- if(d->use_default_engine
- && d->outputFormat == QPrinter::NativeFormat) {
- if (QCUPSSupport::cupsVersion() >= 10200
- && QCUPSSupport::printerHasPPD(name.toLocal8Bit().constData()))
- setOutputFormat(QPrinter::PdfFormat);
- else
- setOutputFormat(QPrinter::PostScriptFormat);
+ if(d->use_default_engine && d->outputFormat == QPrinter::NativeFormat) {
+ setOutputFormat(QPrinter::PdfFormat);
d->outputFormat = QPrinter::NativeFormat;
}
#endif
QList<QPrinterInfo> prnList = QPrinterInfo::availablePrinters();
if (name.isEmpty()) {
- d->validPrinter = d->outputFormat == QPrinter::PdfFormat || d->outputFormat == QPrinter::PostScriptFormat;
+ d->validPrinter = d->outputFormat == QPrinter::PdfFormat;
} else {
d->validPrinter = false;
for (int i = 0; i < prnList.size(); ++i) {
@@ -836,7 +816,7 @@ void QPrinter::setPrinterName(const QString &name)
\since 4.4
Returns true if the printer currently selected is a valid printer
- in the system, or a pure PDF/PostScript printer; otherwise returns false.
+ in the system, or a pure PDF printer; otherwise returns false.
To detect other failures check the output of QPainter::begin() or QPrinter::newPage().
@@ -902,13 +882,12 @@ QString QPrinter::outputFileName() const
Setting a null or empty name (0 or "") disables printing to a file.
Setting a non-empty name enables printing to a file.
- This can change the value of outputFormat(). If the file name has the
- suffix ".ps" then PostScript is automatically selected as output format.
+ This can change the value of outputFormat().
If the file name has the ".pdf" suffix PDF is generated. If the file name
- has a suffix other than ".ps" and ".pdf", the output format used is the
+ has a suffix other than ".pdf", the output format used is the
one set with setOutputFormat().
- QPrinter uses Qt's cross-platform PostScript or PDF print engines
+ QPrinter uses Qt's cross-platform PDF print engines
respectively. If you can produce this format natively, for example
Mac OS X can generate PDF's from its print engine, set the output format
back to NativeFormat.
@@ -922,9 +901,7 @@ void QPrinter::setOutputFileName(const QString &fileName)
ABORT_IF_ACTIVE("QPrinter::setOutputFileName");
QFileInfo fi(fileName);
- if (!fi.suffix().compare(QLatin1String("ps"), Qt::CaseInsensitive))
- setOutputFormat(QPrinter::PostScriptFormat);
- else if (!fi.suffix().compare(QLatin1String("pdf"), Qt::CaseInsensitive))
+ if (!fi.suffix().compare(QLatin1String("pdf"), Qt::CaseInsensitive))
setOutputFormat(QPrinter::PdfFormat);
else if (fileName.isEmpty())
setOutputFormat(QPrinter::NativeFormat);
@@ -956,7 +933,7 @@ QString QPrinter::printProgram() const
Sets the name of the program that should do the print job to \a
printProg.
- On X11, this function sets the program to call with the PostScript
+ On X11, this function sets the program to call with the PDF
output. On other platforms, it has no effect.
\sa printProgram()
@@ -1798,9 +1775,9 @@ int QPrinter::winPageSize() const
Returns a list of the resolutions (a list of dots-per-inch
integers) that the printer says it supports.
- For X11 where all printing is directly to postscript, this
+ For X11 where all printing is directly to PDF, this
function will always return a one item list containing only the
- postscript resolution, i.e., 72 (72 dpi -- but see PrinterMode).
+ PDF resolution, i.e., 72 (72 dpi -- but see PrinterMode).
*/
QList<int> QPrinter::supportedResolutions() const
{
@@ -2073,7 +2050,6 @@ void QPrinter::setFromTo(int from, int to)
if (d->minPage == 0 && d->maxPage == 0) {
d->minPage = 1;
d->maxPage = to;
- d->options |= QAbstractPrintDialog::PrintPageRange;
}
}
@@ -2085,7 +2061,7 @@ void QPrinter::setFromTo(int from, int to)
void QPrinter::setPrintRange( PrintRange range )
{
Q_D(QPrinter);
- d->printRange = QAbstractPrintDialog::PrintRange(range);
+ d->printRange = range;
}
/*!
@@ -2100,164 +2076,9 @@ void QPrinter::setPrintRange( PrintRange range )
QPrinter::PrintRange QPrinter::printRange() const
{
Q_D(const QPrinter);
- return PrintRange(d->printRange);
-}
-
-#if defined(QT3_SUPPORT)
-
-void QPrinter::setOutputToFile(bool f)
-{
- if (f) {
- if (outputFileName().isEmpty())
- setOutputFileName(QLatin1String("untitled_printer_document"));
- } else {
- setOutputFileName(QString());
- }
-}
-
-bool qt_compat_QPrinter_printSetup(QPrinter *printer, QPrinterPrivate *pd, QWidget *parent)
-{
- Q_UNUSED(pd);
- QPrintDialog dlg(printer, parent);
- return dlg.exec() != 0;
-}
-
-
-#ifdef Q_WS_MAC
-bool qt_compat_QPrinter_pageSetup(QPrinter *p, QWidget *parent)
-{
- QPageSetupDialog psd(p, parent);
- return psd.exec() != 0;
-}
-
-/*!
- Executes a page setup dialog so that the user can configure the type of
- page used for printing. Returns true if the contents of the dialog are
- accepted; returns false if the dialog is canceled.
-*/
-bool QPrinter::pageSetup(QWidget *parent)
-{
- return qt_compat_QPrinter_pageSetup(this, parent);
-}
-
-/*!
- Executes a print setup dialog so that the user can configure the printing
- process. Returns true if the contents of the dialog are accepted; returns
- false if the dialog is canceled.
-*/
-bool QPrinter::printSetup(QWidget *parent)
-{
- Q_D(QPrinter);
- return qt_compat_QPrinter_printSetup(this, d, parent);
-}
-#endif // Q_WS_MAC
-
-/*!
- Use QPrintDialog instead.
-
- \oldcode
- if (printer->setup(parent))
- ...
- \newcode
- QPrintDialog dialog(printer, parent);
- if (dialog.exec())
- ...
- \endcode
-*/
-bool QPrinter::setup(QWidget *parent)
-{
- Q_D(QPrinter);
- return qt_compat_QPrinter_printSetup(this, d, parent)
-#ifdef Q_WS_MAC
- && qt_compat_QPrinter_pageSetup(this, parent);
-#endif
- ;
-}
-
-/*!
- Use QPrintDialog::minPage() instead.
-*/
-int QPrinter::minPage() const
-{
- Q_D(const QPrinter);
- return d->minPage;
-}
-
-/*!
- Use QPrintDialog::maxPage() instead.
-*/
-int QPrinter::maxPage() const
-{
- Q_D(const QPrinter);
- return d->maxPage;
-}
-
-/*!
- Use QPrintDialog::setMinMax() instead.
-*/
-void QPrinter::setMinMax( int minPage, int maxPage )
-{
- Q_D(QPrinter);
- Q_ASSERT_X(minPage <= maxPage, "QPrinter::setMinMax",
- "'min' must be less than or equal to 'max'");
- d->minPage = minPage;
- d->maxPage = maxPage;
- d->options |= QPrintDialog::PrintPageRange;
-}
-
-/*!
- Returns true if the printer is set up to collate copies of printed documents;
- otherwise returns false.
-
- Use QPrintDialog::isOptionEnabled(QPrintDialog::PrintCollateCopies)
- instead.
-
- \sa collateCopies()
-*/
-bool QPrinter::collateCopiesEnabled() const
-{
- Q_D(const QPrinter);
- return (d->options & QPrintDialog::PrintCollateCopies);
-}
-
-/*!
- Use QPrintDialog::setOption(QPrintDialog::PrintCollateCopies)
- or QPrintDialog::setOptions(QPrintDialog::options()
- & ~QPrintDialog::PrintCollateCopies) instead, depending on \a
- enable.
-*/
-void QPrinter::setCollateCopiesEnabled(bool enable)
-{
- Q_D(QPrinter);
-
- if (enable)
- d->options |= QPrintDialog::PrintCollateCopies;
- else
- d->options &= ~QPrintDialog::PrintCollateCopies;
-}
-
-/*!
- Use QPrintDialog instead.
-*/
-void QPrinter::setOptionEnabled( PrinterOption option, bool enable )
-{
- Q_D(QPrinter);
- if (enable)
- d->options |= QPrintDialog::PrintDialogOption(1 << option);
- else
- d->options &= ~QPrintDialog::PrintDialogOption(1 << option);
-}
-
-/*!
- Use QPrintDialog instead.
-*/
-bool QPrinter::isOptionEnabled( PrinterOption option ) const
-{
- Q_D(const QPrinter);
- return (d->options & QPrintDialog::PrintDialogOption(option));
+ return d->printRange;
}
-#endif // QT3_SUPPORT
/*!
\class QPrintEngine
diff --git a/src/gui/painting/qprinter.h b/src/gui/painting/qprinter.h
index 6a5d0b7566..e7a8d309e3 100644
--- a/src/gui/painting/qprinter.h
+++ b/src/gui/painting/qprinter.h
@@ -121,9 +121,9 @@ public:
Aborted,
Error };
- enum OutputFormat { NativeFormat, PdfFormat, PostScriptFormat };
+ enum OutputFormat { NativeFormat, PdfFormat };
- // ### Qt 5: Merge with QAbstractPrintDialog::PrintRange
+ // Keep in sync with QAbstractPrintDialog::PrintRange
enum PrintRange { AllPages, Selection, PageRange, CurrentPage };
enum Unit {
@@ -143,10 +143,6 @@ public:
DuplexShortSide
};
-#ifdef QT3_SUPPORT
- enum PrinterOption { PrintToFile, PrintSelection, PrintPageRange };
-#endif // QT3_SUPPORT
-
void setOutputFormat(OutputFormat format);
OutputFormat outputFormat() const;
@@ -259,33 +255,6 @@ public:
void setPageMargins(qreal left, qreal top, qreal right, qreal bottom, Unit unit);
void getPageMargins(qreal *left, qreal *top, qreal *right, qreal *bottom, Unit unit) const;
-#ifdef QT3_SUPPORT
-#ifdef Q_WS_MAC
- QT3_SUPPORT bool pageSetup(QWidget *parent = 0);
- QT3_SUPPORT bool printSetup(QWidget *parent = 0);
-#endif
-
- QT3_SUPPORT bool setup(QWidget *parent = 0);
-
- QT3_SUPPORT void setMinMax(int minPage, int maxPage);
- QT3_SUPPORT int minPage() const;
- QT3_SUPPORT int maxPage() const;
-
- QT3_SUPPORT void setCollateCopiesEnabled(bool);
- QT3_SUPPORT bool collateCopiesEnabled() const;
-
- QT3_SUPPORT void setOptionEnabled(PrinterOption, bool enable);
- QT3_SUPPORT bool isOptionEnabled(PrinterOption) const;
-
- inline QT3_SUPPORT QSize margins() const;
- inline QT3_SUPPORT void margins(uint *top, uint *left, uint *bottom, uint *right) const;
-
- inline QT3_SUPPORT bool aborted() { return printerState() == Aborted; }
-
- QT3_SUPPORT void setOutputToFile(bool);
- inline QT3_SUPPORT bool outputToFile() const { return !outputFileName().isEmpty(); }
-#endif
-
protected:
int metric(PaintDeviceMetric) const;
void setEngines(QPrintEngine *printEngine, QPaintEngine *paintEngine);
@@ -305,29 +274,6 @@ private:
friend class QPageSetupWidget;
};
-#ifdef QT3_SUPPORT
-inline QSize QPrinter::margins() const
-{
- QRect page = pageRect();
- QRect paper = paperRect();
- return QSize(page.left() - paper.left(), page.top() - paper.top());
-}
-
-inline void QPrinter::margins(uint *top, uint *left, uint *bottom, uint *right) const
-{
- QRect page = pageRect();
- QRect paper = paperRect();
- if (top)
- *top = page.top() - paper.top();
- if (left)
- *left = page.left() - paper.left();
- if (bottom)
- *bottom = paper.bottom() - page.bottom();
- if (right)
- *right = paper.right() - page.right();
-}
-#endif
-
#endif // QT_NO_PRINTER
QT_END_NAMESPACE
diff --git a/src/gui/painting/qprinter_p.h b/src/gui/painting/qprinter_p.h
index 556f0f06c2..c6e325f38f 100644
--- a/src/gui/painting/qprinter_p.h
+++ b/src/gui/painting/qprinter_p.h
@@ -60,7 +60,6 @@
#include "QtGui/qprinter.h"
#include "QtGui/qprintengine.h"
-#include "QtGui/qprintdialog.h"
#include "QtCore/qpointer.h"
#include <limits.h>
@@ -71,7 +70,7 @@ class QPrintEngine;
class QPreviewPaintEngine;
class QPicture;
-class QPrinterPrivate
+class Q_GUI_EXPORT QPrinterPrivate
{
Q_DECLARE_PUBLIC(QPrinter)
public:
@@ -79,9 +78,7 @@ public:
: printEngine(0)
, paintEngine(0)
, q_ptr(printer)
- , options(QAbstractPrintDialog::PrintToFile | QAbstractPrintDialog::PrintPageRange |
- QAbstractPrintDialog::PrintCollateCopies | QAbstractPrintDialog::PrintShowPageSize)
- , printRange(QAbstractPrintDialog::AllPages)
+ , printRange(QPrinter::AllPages)
, minPage(1)
, maxPage(INT_MAX)
, fromPage(0)
@@ -118,8 +115,7 @@ public:
QPrinter *q_ptr;
- QAbstractPrintDialog::PrintDialogOptions options;
- QAbstractPrintDialog::PrintRange printRange;
+ QPrinter::PrintRange printRange;
int minPage, maxPage, fromPage, toPage;
uint use_default_engine : 1;
diff --git a/src/gui/painting/qprinterinfo_unix.cpp b/src/gui/painting/qprinterinfo_unix.cpp
index 38e9590b1d..488299bd44 100644
--- a/src/gui/painting/qprinterinfo_unix.cpp
+++ b/src/gui/painting/qprinterinfo_unix.cpp
@@ -45,9 +45,9 @@
#include <qfile.h>
#include <qfileinfo.h>
#include <qdir.h>
-#include <qprintdialog.h>
#include <qlibrary.h>
#include <qtextstream.h>
+#include <qcoreapplication.h>
#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
# include <private/qcups_p.h>
@@ -130,10 +130,8 @@ void qt_perhapsAddPrinter(QList<QPrinterDescription> *printers, const QString &n
if (printers->at(i).samePrinter(name))
return;
-#ifndef QT_NO_PRINTDIALOG
if (host.isEmpty())
- host = QPrintDialog::tr("locally connected");
-#endif
+ host = QCoreApplication::translate("QPrinter", "locally connected");
printers->append(QPrinterDescription(name.simplified(), host.simplified(), comment.simplified(), aliases));
}
@@ -153,11 +151,9 @@ void qt_parsePrinterDesc(QString printerDesc, QList<QPrinterDescription> *printe
if (j > 0 && j < i) {
printerName = printerDesc.left(j);
aliases = printerDesc.mid(j + 1, i - j - 1).split(QLatin1Char('|'));
-#ifndef QT_NO_PRINTDIALOG
// try extracting a comment from the aliases
- printerComment = QPrintDialog::tr("Aliases: %1")
+ printerComment = QCoreApplication::translate("QPrinter", "Aliases: %1")
.arg(aliases.join(QLatin1String(", ")));
-#endif
} else {
printerName = printerDesc.left(i);
}
@@ -379,10 +375,8 @@ char *qt_parsePrintersConf(QList<QPrinterDescription> *printers, bool *found)
if (j > 0) {
// try extracting a comment from the aliases
aliases = printerDesc.mid(j + 1, i - j - 1).split(QLatin1Char('|'));
-#ifndef QT_NO_PRINTDIALOG
- printerComment = QPrintDialog::tr("Aliases: %1")
+ printerComment = QCoreApplication::translate("QPrinter", "Aliases: %1")
.arg(aliases.join(QLatin1String(", ")));
-#endif
}
// look for signs of this being a remote printer
i = printerDesc.indexOf(
@@ -593,9 +587,6 @@ void qt_parseEtcLpMember(QList<QPrinterDescription> *printers)
if (dirs.isEmpty())
return;
-#ifdef QT_NO_PRINTDIALOG
- Q_UNUSED(printers);
-#else
QString tmp;
for (int i = 0; i < dirs.size(); ++i) {
QFileInfo printer = dirs.at(i);
@@ -605,10 +596,9 @@ void qt_parseEtcLpMember(QList<QPrinterDescription> *printers)
// decent way to locate aliases and remote printers.
if (printer.isFile())
qt_perhapsAddPrinter(printers, printer.fileName(),
- QPrintDialog::tr("unknown"),
+ QCoreApplication::translate("QPrinter", "unknown"),
QLatin1String(""));
}
-#endif
}
// IRIX 6.x
@@ -751,7 +741,7 @@ void qt_parseQconfig(QList<QPrinterDescription> *printers)
} while (!ts.atEnd());
}
-int qt_getLprPrinters(QList<QPrinterDescription>& printers)
+Q_GUI_EXPORT int qt_getLprPrinters(QList<QPrinterDescription>& printers)
{
QByteArray etcLpDefault;
qt_parsePrintcap(&printers, QLatin1String("/etc/printcap"));
@@ -801,12 +791,10 @@ int qt_getLprPrinters(QList<QPrinterDescription>& printers)
dollarPrinter = QString::fromLocal8Bit(qgetenv("NPRINTER"));
if (dollarPrinter.isEmpty())
dollarPrinter = QString::fromLocal8Bit(qgetenv("NGPRINTER"));
-#ifndef QT_NO_PRINTDIALOG
if (!dollarPrinter.isEmpty())
qt_perhapsAddPrinter(&printers, dollarPrinter,
- QPrintDialog::tr("unknown"),
+ QCoreApplication::translate("QPrinter", "unknown"),
QLatin1String(""));
-#endif
}
QRegExp ps(QLatin1String("[^a-z]ps(?:[^a-z]|$)"));
diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp
index d713346902..ae9dc63a8f 100644
--- a/src/gui/painting/qregion.cpp
+++ b/src/gui/painting/qregion.cpp
@@ -252,17 +252,6 @@ QRegion::QRegion(int x, int y, int w, int h, RegionType t)
d = tmp.d;
}
-#ifdef QT3_SUPPORT
-/*!
- Use the constructor tha takes a Qt::FillRule as the second
- argument instead.
-*/
-QRegion::QRegion(const QPolygon &pa, bool winding)
-{
- new (this) QRegion(pa, winding ? Qt::WindingFill : Qt::OddEvenFill);
-}
-#endif
-
/*!
\fn QRegion::~QRegion()
\internal
diff --git a/src/gui/painting/qregion.h b/src/gui/painting/qregion.h
index 1cd38d41b8..3093dc08c4 100644
--- a/src/gui/painting/qregion.h
+++ b/src/gui/painting/qregion.h
@@ -74,9 +74,6 @@ public:
QRegion(int x, int y, int w, int h, RegionType t = Rectangle);
QRegion(const QRect &r, RegionType t = Rectangle);
QRegion(const QPolygon &pa, Qt::FillRule fillRule = Qt::OddEvenFill);
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QRegion(const QPolygon &pa, bool winding);
-#endif
QRegion(const QRegion &region);
QRegion(const QBitmap &bitmap);
~QRegion();
@@ -86,9 +83,6 @@ public:
{ qSwap(d, other.d); return *this; }
#endif
inline void swap(QRegion &other) { qSwap(d, other.d); }
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT bool isNull() const { return isEmpty(); }
-#endif
bool isEmpty() const;
bool contains(const QPoint &p) const;
diff --git a/src/gui/painting/qregion_qws.cpp b/src/gui/painting/qregion_qws.cpp
deleted file mode 100644
index dca46d3ec0..0000000000
--- a/src/gui/painting/qregion_qws.cpp
+++ /dev/null
@@ -1,3183 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// XXX - add appropriate friendship relationships
-#define private public
-#include "qregion.h"
-#undef private
-#include "qpainterpath.h"
-#include "qpolygon.h"
-#include "qbuffer.h"
-#include "qimage.h"
-#include <qdebug.h>
-#include "qbitmap.h"
-#include <stdlib.h>
-#include <qatomic.h>
-#include <qsemaphore.h>
-
-QT_BEGIN_NAMESPACE
-
-class QFastMutex
-{
- QAtomicInt contenders;
- QSemaphore semaphore;
-public:
- inline QFastMutex()
- : contenders(0), semaphore(0)
- { }
- inline void lock()
- {
- if (contenders.fetchAndAddAcquire(1) != 0) {
- semaphore.acquire();
- contenders.deref();
- }
- }
- inline bool tryLock()
- {
- return contenders.testAndSetAcquire(0, 1);
- }
- inline void unlock()
- {
- if (!contenders.testAndSetRelease(1, 0))
- semaphore.release();
- }
-};
-
-
-/*
- * 1 if r1 contains r2
- * 0 if r1 does not completely contain r2
- */
-#define CONTAINSCHECK(r1, r2) \
- ((r2).left() >= (r1).left() && (r2).right() <= (r1).right() && \
- (r2).top() >= (r1).top() && (r2).bottom() <= (r1).bottom())
-
-/*
- * clip region
- */
-struct QRegionPrivate : public QRegion::QRegionData {
- enum { Single, Vector } mode;
- int numRects;
- QVector<QRect> rects;
- QRect single;
- QRect extents;
- QRect innerRect;
- union {
- int innerArea;
- QRegionPrivate *next;
- };
-
- inline void vector()
- {
- if(mode != Vector && numRects) {
- if(rects.size() < 1) rects.resize(1);
- rects[0] = single;
- }
- mode = Vector;
- }
-
- inline QRegionPrivate() : mode(Single), numRects(0), innerArea(-1) {}
- inline QRegionPrivate(const QRect &r) : mode(Single) {
- numRects = 1;
-// rects[0] = r;
- single = r;
- extents = r;
- innerRect = r;
- innerArea = r.width() * r.height();
- }
-
- inline QRegionPrivate(const QRegionPrivate &r) {
- mode = r.mode;
- rects = r.rects;
- single = r.single;
- numRects = r.numRects;
- extents = r.extents;
- innerRect = r.innerRect;
- innerArea = r.innerArea;
- }
-
- inline QRegionPrivate &operator=(const QRegionPrivate &r) {
- mode = r.mode;
- rects = r.rects;
- single = r.single;
- numRects = r.numRects;
- extents = r.extents;
- innerRect = r.innerRect;
- innerArea = r.innerArea;
- return *this;
- }
-
- /*
- * Returns true if r is guaranteed to be fully contained in this region.
- * A false return value does not guarantee the opposite.
- */
- inline bool contains(const QRegionPrivate &r) const {
- const QRect &r1 = innerRect;
- const QRect &r2 = r.extents;
- return CONTAINSCHECK(r1, r2);
- }
-
- inline void updateInnerRect(const QRect &rect) {
- const int area = rect.width() * rect.height();
- if (area > innerArea) {
- innerArea = area;
- innerRect = rect;
- }
- }
-
- void append(const QRegionPrivate *r);
- void prepend(const QRegionPrivate *r);
- inline bool canAppend(const QRegionPrivate *r) const;
- inline bool canPrepend(const QRegionPrivate *r) const;
-};
-
-static QRegionPrivate *qt_nextRegionPtr = 0;
-static QFastMutex qt_nextRegionLock;
-
-static QRegionPrivate *qt_allocRegionMemory()
-{
- QRegionPrivate *rv = 0;
- qt_nextRegionLock.lock();
-
- if(qt_nextRegionPtr) {
- rv = qt_nextRegionPtr;
- qt_nextRegionPtr = rv->next;
- } else {
- qt_nextRegionPtr =
- (QRegionPrivate *)malloc(256 * sizeof(QRegionPrivate));
- for(int ii = 0; ii < 256; ++ii) {
- if(ii == 255) {
- qt_nextRegionPtr[ii].next = 0;
- } else {
- qt_nextRegionPtr[ii].next = &qt_nextRegionPtr[ii + 1];
- }
- }
-
- rv = qt_nextRegionPtr;
- qt_nextRegionPtr = rv->next;
- }
-
- qt_nextRegionLock.unlock();
- return rv;
-}
-
-static void qt_freeRegionMemory(QRegionPrivate *rp)
-{
- qt_nextRegionLock.lock();
- rp->next = qt_nextRegionPtr;
- qt_nextRegionPtr = rp;
- qt_nextRegionLock.unlock();
-}
-
-static QRegionPrivate *qt_allocRegion()
-{
- QRegionPrivate *mem = qt_allocRegionMemory();
- return new (mem) QRegionPrivate;
-}
-
-static QRegionPrivate *qt_allocRegion(const QRect &r)
-{
- QRegionPrivate *mem = qt_allocRegionMemory();
- return new (mem) QRegionPrivate(r);
-}
-
-static QRegionPrivate *qt_allocRegion(const QRegionPrivate &r)
-{
- QRegionPrivate *mem = qt_allocRegionMemory();
- return new (mem) QRegionPrivate(r);
-}
-
-void qt_freeRegion(QRegionPrivate *rp)
-{
- rp->~QRegionPrivate();
- qt_freeRegionMemory(rp);
-// delete rp;
-}
-
-static inline bool isEmptyHelper(const QRegionPrivate *preg)
-{
- return !preg || preg->numRects == 0;
-}
-
-void QRegionPrivate::append(const QRegionPrivate *r)
-{
- Q_ASSERT(!isEmptyHelper(r));
-
- vector();
- QRect *destRect = rects.data() + numRects;
- const QRect *srcRect = (r->mode==Vector)?r->rects.constData():&r->single;
- int numAppend = r->numRects;
-
- // test for merge in x direction
- {
- const QRect *rFirst = srcRect;
- QRect *myLast = rects.data() + (numRects - 1);
- if (rFirst->top() == myLast->top()
- && rFirst->height() == myLast->height()
- && rFirst->left() == (myLast->right() + 1))
- {
- myLast->setWidth(myLast->width() + rFirst->width());
- updateInnerRect(*myLast);
- ++srcRect;
- --numAppend;
- }
- }
-
- // append rectangles
- const int newNumRects = numRects + numAppend;
- if (newNumRects > rects.size()) {
- rects.resize(newNumRects);
- destRect = rects.data() + numRects;
- }
- memcpy(destRect, srcRect, numAppend * sizeof(QRect));
-
- // update inner rectangle
- if (innerArea < r->innerArea) {
- innerArea = r->innerArea;
- innerRect = r->innerRect;
- }
-
- // update extents
- destRect = &extents;
- srcRect = &r->extents;
- extents.setCoords(qMin(destRect->left(), srcRect->left()),
- qMin(destRect->top(), srcRect->top()),
- qMax(destRect->right(), srcRect->right()),
- qMax(destRect->bottom(), srcRect->bottom()));
-
- numRects = newNumRects;
-}
-
-void QRegionPrivate::prepend(const QRegionPrivate *r)
-{
-#if 1
- Q_UNUSED(r);
-#else
- // XXX ak: does not respect vectorization of region
-
- Q_ASSERT(!isEmpty(r));
-
- // move existing rectangles
- memmove(rects.data() + r->numRects, rects.constData(),
- numRects * sizeof(QRect));
-
- // prepend new rectangles
- memcpy(rects.data(), r->rects.constData(), r->numRects * sizeof(QRect));
-
- // update inner rectangle
- if (innerArea < r->innerArea) {
- innerArea = r->innerArea;
- innerRect = r->innerRect;
- }
-
- // update extents
- destRect = &extents;
- srcRect = &r->extents;
- extents.setCoords(qMin(destRect->left(), srcRect->left()),
- qMin(destRect->top(), srcRect->top()),
- qMax(destRect->right(), srcRect->right()),
- qMax(destRect->bottom(), srcRect->bottom()));
-
- numRects = newNumRects;
-#endif
-}
-
-bool QRegionPrivate::canAppend(const QRegionPrivate *r) const
-{
- Q_ASSERT(!isEmptyHelper(r));
-
- const QRect *rFirst = (r->mode==Vector)?r->rects.constData():&r->single;
- const QRect *myLast = (mode==Vector)?(rects.constData() + (numRects - 1)):&single;
- // XXX: possible improvements:
- // - nFirst->top() == myLast->bottom() + 1, must possibly merge bands
- if (rFirst->top() > (myLast->bottom() + 1)
- || (rFirst->top() == myLast->top()
- && rFirst->height() == myLast->height()
- && rFirst->left() > myLast->right()))
- {
- return true;
- }
-
- return false;
-}
-
-bool QRegionPrivate::canPrepend(const QRegionPrivate *r) const
-{
-#if 1
- Q_UNUSED(r);
- return false;
-#else
- return r->canAppend(this);
-#endif
-}
-
-#if defined(Q_WS_X11)
-QT_BEGIN_INCLUDE_NAMESPACE
-# include "qregion_x11.cpp"
-QT_END_INCLUDE_NAMESPACE
-#elif defined(Q_WS_MAC)
-QT_BEGIN_INCLUDE_NAMESPACE
-# include "qregion_mac.cpp"
-QT_END_INCLUDE_NAMESPACE
-#elif defined(Q_WS_QWS)
-static QRegionPrivate qrp;
-QRegion::QRegionData QRegion::shared_empty = {Q_BASIC_ATOMIC_INITIALIZER(1), &qrp};
-#endif
-
-typedef void (*OverlapFunc)(register QRegionPrivate &dest, register const QRect *r1, const QRect *r1End,
- register const QRect *r2, const QRect *r2End, register int y1, register int y2);
-typedef void (*NonOverlapFunc)(register QRegionPrivate &dest, register const QRect *r, const QRect *rEnd,
- register int y1, register int y2);
-
-static bool EqualRegion(const QRegionPrivate *r1, const QRegionPrivate *r2);
-static void UnionRegion(const QRegionPrivate *reg1, const QRegionPrivate *reg2, QRegionPrivate &dest);
-static void miRegionOp(register QRegionPrivate &dest, const QRegionPrivate *reg1, const QRegionPrivate *reg2,
- OverlapFunc overlapFunc, NonOverlapFunc nonOverlap1Func,
- NonOverlapFunc nonOverlap2Func);
-
-#define RectangleOut 0
-#define RectangleIn 1
-#define RectanglePart 2
-#define EvenOddRule 0
-#define WindingRule 1
-
-// START OF region.h extract
-/* $XConsortium: region.h,v 11.14 94/04/17 20:22:20 rws Exp $ */
-/************************************************************************
-
-Copyright (c) 1987 X Consortium
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of the X Consortium shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from the X Consortium.
-
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
- All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose and without fee is hereby granted,
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
-supporting documentation, and that the name of Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-************************************************************************/
-
-#ifndef _XREGION_H
-#define _XREGION_H
-
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <limits.h>
-QT_END_INCLUDE_NAMESPACE
-
-/* 1 if two BOXs overlap.
- * 0 if two BOXs do not overlap.
- * Remember, x2 and y2 are not in the region
- */
-#define EXTENTCHECK(r1, r2) \
- ((r1)->right() >= (r2)->left() && \
- (r1)->left() <= (r2)->right() && \
- (r1)->bottom() >= (r2)->top() && \
- (r1)->top() <= (r2)->bottom())
-
-/*
- * update region extents
- */
-#define EXTENTS(r,idRect){\
- if((r)->left() < (idRect)->extents.left())\
- (idRect)->extents.setLeft((r)->left());\
- if((r)->top() < (idRect)->extents.top())\
- (idRect)->extents.setTop((r)->top());\
- if((r)->right() > (idRect)->extents.right())\
- (idRect)->extents.setRight((r)->right());\
- if((r)->bottom() > (idRect)->extents.bottom())\
- (idRect)->extents.setBottom((r)->bottom());\
- }
-
-/*
- * Check to see if there is enough memory in the present region.
- */
-#define MEMCHECK(dest, rect, firstrect){\
- if ((dest).numRects >= ((dest).rects.size()-1)){\
- firstrect.resize(firstrect.size() * 2); \
- (rect) = (firstrect).data() + (dest).numRects;\
- }\
- }
-
-
-/*
- * number of points to buffer before sending them off
- * to scanlines(): Must be an even number
- */
-#define NUMPTSTOBUFFER 200
-
-/*
- * used to allocate buffers for points and link
- * the buffers together
- */
-typedef struct _POINTBLOCK {
- QPoint pts[NUMPTSTOBUFFER];
- struct _POINTBLOCK *next;
-} POINTBLOCK;
-
-#endif
-// END OF region.h extract
-
-// START OF Region.c extract
-/* $XConsortium: Region.c /main/30 1996/10/22 14:21:24 kaleb $ */
-/************************************************************************
-
-Copyright (c) 1987, 1988 X Consortium
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of the X Consortium shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from the X Consortium.
-
-
-Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
-
- All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose and without fee is hereby granted,
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
-supporting documentation, and that the name of Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-************************************************************************/
-/*
- * The functions in this file implement the Region abstraction, similar to one
- * used in the X11 sample server. A Region is simply an area, as the name
- * implies, and is implemented as a "y-x-banded" array of rectangles. To
- * explain: Each Region is made up of a certain number of rectangles sorted
- * by y coordinate first, and then by x coordinate.
- *
- * Furthermore, the rectangles are banded such that every rectangle with a
- * given upper-left y coordinate (y1) will have the same lower-right y
- * coordinate (y2) and vice versa. If a rectangle has scanlines in a band, it
- * will span the entire vertical distance of the band. This means that some
- * areas that could be merged into a taller rectangle will be represented as
- * several shorter rectangles to account for shorter rectangles to its left
- * or right but within its "vertical scope".
- *
- * An added constraint on the rectangles is that they must cover as much
- * horizontal area as possible. E.g. no two rectangles in a band are allowed
- * to touch.
- *
- * Whenever possible, bands will be merged together to cover a greater vertical
- * distance (and thus reduce the number of rectangles). Two bands can be merged
- * only if the bottom of one touches the top of the other and they have
- * rectangles in the same places (of the same width, of course). This maintains
- * the y-x-banding that's so nice to have...
- */
-/* $XFree86: xc/lib/X11/Region.c,v 1.1.1.2.2.2 1998/10/04 15:22:50 hohndel Exp $ */
-
-static void UnionRectWithRegion(register const QRect *rect, const QRegionPrivate *source,
- QRegionPrivate &dest)
-{
- if (!rect->width() || !rect->height())
- return;
-
- QRegionPrivate region(*rect);
-
- Q_ASSERT(EqualRegion(source, &dest));
- Q_ASSERT(!isEmptyHelper(&region));
-
- if (dest.numRects == 0)
- dest = region;
- else if (dest.canAppend(&region))
- dest.append(&region);
- else
- UnionRegion(&region, source, dest);
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miSetExtents --
- * Reset the extents and innerRect of a region to what they should be.
- * Called by miSubtract and miIntersect b/c they can't figure it out
- * along the way or do so easily, as miUnion can.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * The region's 'extents' and 'innerRect' structure is overwritten.
- *
- *-----------------------------------------------------------------------
- */
-static void miSetExtents(QRegionPrivate &dest)
-{
- register const QRect *pBox,
- *pBoxEnd;
- register QRect *pExtents;
-
- dest.innerRect.setCoords(0, 0, -1, -1);
- dest.innerArea = -1;
- if (dest.numRects == 0) {
- dest.extents.setCoords(0, 0, 0, 0);
- return;
- }
-
- pExtents = &dest.extents;
- pBox = (dest.mode==QRegionPrivate::Vector)?(dest.rects.constData()):(&dest.single);
- pBoxEnd = (dest.mode==QRegionPrivate::Vector)?(&pBox[dest.numRects - 1]):(&dest.single);
-
- /*
- * Since pBox is the first rectangle in the region, it must have the
- * smallest y1 and since pBoxEnd is the last rectangle in the region,
- * it must have the largest y2, because of banding. Initialize x1 and
- * x2 from pBox and pBoxEnd, resp., as good things to initialize them
- * to...
- */
- pExtents->setLeft(pBox->left());
- pExtents->setTop(pBox->top());
- pExtents->setRight(pBoxEnd->right());
- pExtents->setBottom(pBoxEnd->bottom());
-
- Q_ASSERT(pExtents->top() <= pExtents->bottom());
- while (pBox <= pBoxEnd) {
- if (pBox->left() < pExtents->left())
- pExtents->setLeft(pBox->left());
- if (pBox->right() > pExtents->right())
- pExtents->setRight(pBox->right());
- dest.updateInnerRect(*pBox);
- ++pBox;
- }
- Q_ASSERT(pExtents->left() <= pExtents->right());
-}
-
-/* TranslateRegion(pRegion, x, y)
- translates in place
- added by raymond
-*/
-
-static void OffsetRegion(register QRegionPrivate &region, register int x, register int y)
-{
- register int nbox;
- register QRect *pbox;
-
- if(region.mode == QRegionPrivate::Single) {
- region.single.translate(x, y);
- } else {
- pbox = region.rects.data();
- nbox = region.numRects;
-
- while (nbox--) {
- pbox->translate(x, y);
- ++pbox;
- }
- }
- region.extents.translate(x, y);
- region.innerRect.translate(x, y);
-}
-
-/*======================================================================
- * Region Intersection
- *====================================================================*/
-/*-
- *-----------------------------------------------------------------------
- * miIntersectO --
- * Handle an overlapping band for miIntersect.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * Rectangles may be added to the region.
- *
- *-----------------------------------------------------------------------
- */
-static void miIntersectO(register QRegionPrivate &dest, register const QRect *r1, const QRect *r1End,
- register const QRect *r2, const QRect *r2End, int y1, int y2)
-{
- register int x1;
- register int x2;
- register QRect *pNextRect;
-
- pNextRect = dest.rects.data() + dest.numRects;
-
- while (r1 != r1End && r2 != r2End) {
- x1 = qMax(r1->left(), r2->left());
- x2 = qMin(r1->right(), r2->right());
-
- /*
- * If there's any overlap between the two rectangles, add that
- * overlap to the new region.
- * There's no need to check for subsumption because the only way
- * such a need could arise is if some region has two rectangles
- * right next to each other. Since that should never happen...
- */
- if (x1 <= x2) {
- Q_ASSERT(y1 <= y2);
- MEMCHECK(dest, pNextRect, dest.rects)
- pNextRect->setCoords(x1, y1, x2, y2);
- ++dest.numRects;
- ++pNextRect;
- }
-
- /*
- * Need to advance the pointers. Shift the one that extends
- * to the right the least, since the other still has a chance to
- * overlap with that region's next rectangle, if you see what I mean.
- */
- if (r1->right() < r2->right()) {
- ++r1;
- } else if (r2->right() < r1->right()) {
- ++r2;
- } else {
- ++r1;
- ++r2;
- }
- }
-}
-
-/*======================================================================
- * Generic Region Operator
- *====================================================================*/
-
-/*-
- *-----------------------------------------------------------------------
- * miCoalesce --
- * Attempt to merge the boxes in the current band with those in the
- * previous one. Used only by miRegionOp.
- *
- * Results:
- * The new index for the previous band.
- *
- * Side Effects:
- * If coalescing takes place:
- * - rectangles in the previous band will have their y2 fields
- * altered.
- * - dest.numRects will be decreased.
- *
- *-----------------------------------------------------------------------
- */
-static int miCoalesce(register QRegionPrivate &dest, int prevStart, int curStart)
-{
- register QRect *pPrevBox; /* Current box in previous band */
- register QRect *pCurBox; /* Current box in current band */
- register QRect *pRegEnd; /* End of region */
- int curNumRects; /* Number of rectangles in current band */
- int prevNumRects; /* Number of rectangles in previous band */
- int bandY1; /* Y1 coordinate for current band */
- QRect *rData = dest.rects.data();
-
- pRegEnd = rData + dest.numRects;
-
- pPrevBox = rData + prevStart;
- prevNumRects = curStart - prevStart;
-
- /*
- * Figure out how many rectangles are in the current band. Have to do
- * this because multiple bands could have been added in miRegionOp
- * at the end when one region has been exhausted.
- */
- pCurBox = rData + curStart;
- bandY1 = pCurBox->top();
- for (curNumRects = 0; pCurBox != pRegEnd && pCurBox->top() == bandY1; ++curNumRects) {
- ++pCurBox;
- }
-
- if (pCurBox != pRegEnd) {
- /*
- * If more than one band was added, we have to find the start
- * of the last band added so the next coalescing job can start
- * at the right place... (given when multiple bands are added,
- * this may be pointless -- see above).
- */
- --pRegEnd;
- while ((pRegEnd - 1)->top() == pRegEnd->top())
- --pRegEnd;
- curStart = pRegEnd - rData;
- pRegEnd = rData + dest.numRects;
- }
-
- if (curNumRects == prevNumRects && curNumRects != 0) {
- pCurBox -= curNumRects;
- /*
- * The bands may only be coalesced if the bottom of the previous
- * matches the top scanline of the current.
- */
- if (pPrevBox->bottom() == pCurBox->top() - 1) {
- /*
- * Make sure the bands have boxes in the same places. This
- * assumes that boxes have been added in such a way that they
- * cover the most area possible. I.e. two boxes in a band must
- * have some horizontal space between them.
- */
- do {
- if (pPrevBox->left() != pCurBox->left() || pPrevBox->right() != pCurBox->right()) {
- // The bands don't line up so they can't be coalesced.
- return curStart;
- }
- ++pPrevBox;
- ++pCurBox;
- --prevNumRects;
- } while (prevNumRects != 0);
-
- dest.numRects -= curNumRects;
- pCurBox -= curNumRects;
- pPrevBox -= curNumRects;
-
- /*
- * The bands may be merged, so set the bottom y of each box
- * in the previous band to that of the corresponding box in
- * the current band.
- */
- do {
- pPrevBox->setBottom(pCurBox->bottom());
- dest.updateInnerRect(*pPrevBox);
- ++pPrevBox;
- ++pCurBox;
- curNumRects -= 1;
- } while (curNumRects != 0);
-
- /*
- * If only one band was added to the region, we have to backup
- * curStart to the start of the previous band.
- *
- * If more than one band was added to the region, copy the
- * other bands down. The assumption here is that the other bands
- * came from the same region as the current one and no further
- * coalescing can be done on them since it's all been done
- * already... curStart is already in the right place.
- */
- if (pCurBox == pRegEnd) {
- curStart = prevStart;
- } else {
- do {
- *pPrevBox++ = *pCurBox++;
- dest.updateInnerRect(*pPrevBox);
- } while (pCurBox != pRegEnd);
- }
- }
- }
- return curStart;
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miRegionOp --
- * Apply an operation to two regions. Called by miUnion, miInverse,
- * miSubtract, miIntersect...
- *
- * Results:
- * None.
- *
- * Side Effects:
- * The new region is overwritten.
- *
- * Notes:
- * The idea behind this function is to view the two regions as sets.
- * Together they cover a rectangle of area that this function divides
- * into horizontal bands where points are covered only by one region
- * or by both. For the first case, the nonOverlapFunc is called with
- * each the band and the band's upper and lower extents. For the
- * second, the overlapFunc is called to process the entire band. It
- * is responsible for clipping the rectangles in the band, though
- * this function provides the boundaries.
- * At the end of each band, the new region is coalesced, if possible,
- * to reduce the number of rectangles in the region.
- *
- *-----------------------------------------------------------------------
- */
-static void miRegionOp(register QRegionPrivate &dest, const QRegionPrivate *reg1, const QRegionPrivate *reg2,
- OverlapFunc overlapFunc, NonOverlapFunc nonOverlap1Func,
- NonOverlapFunc nonOverlap2Func)
-{
- register const QRect *r1; // Pointer into first region
- register const QRect *r2; // Pointer into 2d region
- const QRect *r1End; // End of 1st region
- const QRect *r2End; // End of 2d region
- register int ybot; // Bottom of intersection
- register int ytop; // Top of intersection
- int prevBand; // Index of start of previous band in dest
- int curBand; // Index of start of current band in dest
- register const QRect *r1BandEnd; // End of current band in r1
- register const QRect *r2BandEnd; // End of current band in r2
- int top; // Top of non-overlapping band
- int bot; // Bottom of non-overlapping band
-
- /*
- * Initialization:
- * set r1, r2, r1End and r2End appropriately, preserve the important
- * parts of the destination region until the end in case it's one of
- * the two source regions, then mark the "new" region empty, allocating
- * another array of rectangles for it to use.
- */
- r1 = (reg1->mode==QRegionPrivate::Vector)?reg1->rects.data():&reg1->single;
- r2 = (reg2->mode==QRegionPrivate::Vector)?reg2->rects.data():&reg2->single;
- r1End = r1 + reg1->numRects;
- r2End = r2 + reg2->numRects;
-
- dest.vector();
- QVector<QRect> oldRects = dest.rects;
-
- dest.numRects = 0;
-
- /*
- * Allocate a reasonable number of rectangles for the new region. The idea
- * is to allocate enough so the individual functions don't need to
- * reallocate and copy the array, which is time consuming, yet we don't
- * have to worry about using too much memory. I hope to be able to
- * nuke the realloc() at the end of this function eventually.
- */
- dest.rects.resize(qMax(reg1->numRects,reg2->numRects) * 2);
-
- /*
- * Initialize ybot and ytop.
- * In the upcoming loop, ybot and ytop serve different functions depending
- * on whether the band being handled is an overlapping or non-overlapping
- * band.
- * In the case of a non-overlapping band (only one of the regions
- * has points in the band), ybot is the bottom of the most recent
- * intersection and thus clips the top of the rectangles in that band.
- * ytop is the top of the next intersection between the two regions and
- * serves to clip the bottom of the rectangles in the current band.
- * For an overlapping band (where the two regions intersect), ytop clips
- * the top of the rectangles of both regions and ybot clips the bottoms.
- */
- if (reg1->extents.top() < reg2->extents.top())
- ybot = reg1->extents.top() - 1;
- else
- ybot = reg2->extents.top() - 1;
-
- /*
- * prevBand serves to mark the start of the previous band so rectangles
- * can be coalesced into larger rectangles. qv. miCoalesce, above.
- * In the beginning, there is no previous band, so prevBand == curBand
- * (curBand is set later on, of course, but the first band will always
- * start at index 0). prevBand and curBand must be indices because of
- * the possible expansion, and resultant moving, of the new region's
- * array of rectangles.
- */
- prevBand = 0;
-
- do {
- curBand = dest.numRects;
-
- /*
- * This algorithm proceeds one source-band (as opposed to a
- * destination band, which is determined by where the two regions
- * intersect) at a time. r1BandEnd and r2BandEnd serve to mark the
- * rectangle after the last one in the current band for their
- * respective regions.
- */
- r1BandEnd = r1;
- while (r1BandEnd != r1End && r1BandEnd->top() == r1->top())
- ++r1BandEnd;
-
- r2BandEnd = r2;
- while (r2BandEnd != r2End && r2BandEnd->top() == r2->top())
- ++r2BandEnd;
-
- /*
- * First handle the band that doesn't intersect, if any.
- *
- * Note that attention is restricted to one band in the
- * non-intersecting region at once, so if a region has n
- * bands between the current position and the next place it overlaps
- * the other, this entire loop will be passed through n times.
- */
- if (r1->top() < r2->top()) {
- top = qMax(r1->top(), ybot + 1);
- bot = qMin(r1->bottom(), r2->top() - 1);
-
- if (nonOverlap1Func != 0 && bot >= top)
- (*nonOverlap1Func)(dest, r1, r1BandEnd, top, bot);
- ytop = r2->top();
- } else if (r2->top() < r1->top()) {
- top = qMax(r2->top(), ybot + 1);
- bot = qMin(r2->bottom(), r1->top() - 1);
-
- if (nonOverlap2Func != 0 && bot >= top)
- (*nonOverlap2Func)(dest, r2, r2BandEnd, top, bot);
- ytop = r1->top();
- } else {
- ytop = r1->top();
- }
-
- /*
- * If any rectangles got added to the region, try and coalesce them
- * with rectangles from the previous band. Note we could just do
- * this test in miCoalesce, but some machines incur a not
- * inconsiderable cost for function calls, so...
- */
- if (dest.numRects != curBand)
- prevBand = miCoalesce(dest, prevBand, curBand);
-
- /*
- * Now see if we've hit an intersecting band. The two bands only
- * intersect if ybot >= ytop
- */
- ybot = qMin(r1->bottom(), r2->bottom());
- curBand = dest.numRects;
- if (ybot >= ytop)
- (*overlapFunc)(dest, r1, r1BandEnd, r2, r2BandEnd, ytop, ybot);
-
- if (dest.numRects != curBand)
- prevBand = miCoalesce(dest, prevBand, curBand);
-
- /*
- * If we've finished with a band (y2 == ybot) we skip forward
- * in the region to the next band.
- */
- if (r1->bottom() == ybot)
- r1 = r1BandEnd;
- if (r2->bottom() == ybot)
- r2 = r2BandEnd;
- } while (r1 != r1End && r2 != r2End);
-
- /*
- * Deal with whichever region still has rectangles left.
- */
- curBand = dest.numRects;
- if (r1 != r1End) {
- if (nonOverlap1Func != 0) {
- do {
- r1BandEnd = r1;
- while (r1BandEnd < r1End && r1BandEnd->top() == r1->top())
- ++r1BandEnd;
- (*nonOverlap1Func)(dest, r1, r1BandEnd, qMax(r1->top(), ybot + 1), r1->bottom());
- r1 = r1BandEnd;
- } while (r1 != r1End);
- }
- } else if ((r2 != r2End) && (nonOverlap2Func != 0)) {
- do {
- r2BandEnd = r2;
- while (r2BandEnd < r2End && r2BandEnd->top() == r2->top())
- ++r2BandEnd;
- (*nonOverlap2Func)(dest, r2, r2BandEnd, qMax(r2->top(), ybot + 1), r2->bottom());
- r2 = r2BandEnd;
- } while (r2 != r2End);
- }
-
- if (dest.numRects != curBand)
- (void)miCoalesce(dest, prevBand, curBand);
-
- /*
- * A bit of cleanup. To keep regions from growing without bound,
- * we shrink the array of rectangles to match the new number of
- * rectangles in the region.
- *
- * Only do this stuff if the number of rectangles allocated is more than
- * twice the number of rectangles in the region (a simple optimization).
- */
- if (qMax(4, dest.numRects) < (dest.rects.size() >> 1))
- dest.rects.resize(dest.numRects);
-}
-
-/*======================================================================
- * Region Union
- *====================================================================*/
-
-/*-
- *-----------------------------------------------------------------------
- * miUnionNonO --
- * Handle a non-overlapping band for the union operation. Just
- * Adds the rectangles into the region. Doesn't have to check for
- * subsumption or anything.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * dest.numRects is incremented and the final rectangles overwritten
- * with the rectangles we're passed.
- *
- *-----------------------------------------------------------------------
- */
-
-static void miUnionNonO(register QRegionPrivate &dest, register const QRect *r, const QRect *rEnd,
- register int y1, register int y2)
-{
- register QRect *pNextRect;
-
- pNextRect = dest.rects.data() + dest.numRects;
-
- Q_ASSERT(y1 <= y2);
-
- while (r != rEnd) {
- Q_ASSERT(r->left() <= r->right());
- MEMCHECK(dest, pNextRect, dest.rects)
- pNextRect->setCoords(r->left(), y1, r->right(), y2);
- dest.numRects++;
- ++pNextRect;
- ++r;
- }
-}
-
-
-/*-
- *-----------------------------------------------------------------------
- * miUnionO --
- * Handle an overlapping band for the union operation. Picks the
- * left-most rectangle each time and merges it into the region.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * Rectangles are overwritten in dest.rects and dest.numRects will
- * be changed.
- *
- *-----------------------------------------------------------------------
- */
-
-static void miUnionO(register QRegionPrivate &dest, register const QRect *r1, const QRect *r1End,
- register const QRect *r2, const QRect *r2End, register int y1, register int y2)
-{
- register QRect *pNextRect;
-
- pNextRect = dest.rects.data() + dest.numRects;
-
-#define MERGERECT(r) \
- if ((dest.numRects != 0) && \
- (pNextRect[-1].top() == y1) && \
- (pNextRect[-1].bottom() == y2) && \
- (pNextRect[-1].right() >= r->left()-1)) { \
- if (pNextRect[-1].right() < r->right()) { \
- pNextRect[-1].setRight(r->right()); \
- dest.updateInnerRect(pNextRect[-1]); \
- Q_ASSERT(pNextRect[-1].left() <= pNextRect[-1].right()); \
- } \
- } else { \
- MEMCHECK(dest, pNextRect, dest.rects) \
- pNextRect->setCoords(r->left(), y1, r->right(), y2); \
- dest.updateInnerRect(*pNextRect); \
- dest.numRects++; \
- pNextRect++; \
- } \
- r++;
-
- Q_ASSERT(y1 <= y2);
- while (r1 != r1End && r2 != r2End) {
- if (r1->left() < r2->left()) {
- MERGERECT(r1)
- } else {
- MERGERECT(r2)
- }
- }
-
- if (r1 != r1End) {
- do {
- MERGERECT(r1)
- } while (r1 != r1End);
- } else {
- while (r2 != r2End) {
- MERGERECT(r2)
- }
- }
-}
-
-static void UnionRegion(const QRegionPrivate *reg1, const QRegionPrivate *reg2, QRegionPrivate &dest)
-{
- Q_ASSERT(!isEmptyHelper(reg1) && !isEmptyHelper(reg2));
- Q_ASSERT(!reg1->contains(*reg2));
- Q_ASSERT(!reg2->contains(*reg1));
- Q_ASSERT(!EqualRegion(reg1, reg2));
- Q_ASSERT(!reg1->canAppend(reg2));
- Q_ASSERT(!reg2->canAppend(reg1));
-
- if (reg1->innerArea > reg2->innerArea) {
- dest.innerArea = reg1->innerArea;
- dest.innerRect = reg1->innerRect;
- } else {
- dest.innerArea = reg2->innerArea;
- dest.innerRect = reg2->innerRect;
- }
- miRegionOp(dest, reg1, reg2, miUnionO, miUnionNonO, miUnionNonO);
-
- dest.extents.setCoords(qMin(reg1->extents.left(), reg2->extents.left()),
- qMin(reg1->extents.top(), reg2->extents.top()),
- qMax(reg1->extents.right(), reg2->extents.right()),
- qMax(reg1->extents.bottom(), reg2->extents.bottom()));
-}
-
-/*======================================================================
- * Region Subtraction
- *====================================================================*/
-
-/*-
- *-----------------------------------------------------------------------
- * miSubtractNonO --
- * Deal with non-overlapping band for subtraction. Any parts from
- * region 2 we discard. Anything from region 1 we add to the region.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * dest may be affected.
- *
- *-----------------------------------------------------------------------
- */
-
-static void miSubtractNonO1(register QRegionPrivate &dest, register const QRect *r,
- const QRect *rEnd, register int y1, register int y2)
-{
- register QRect *pNextRect;
-
- pNextRect = dest.rects.data() + dest.numRects;
-
- Q_ASSERT(y1<=y2);
-
- while (r != rEnd) {
- Q_ASSERT(r->left() <= r->right());
- MEMCHECK(dest, pNextRect, dest.rects)
- pNextRect->setCoords(r->left(), y1, r->right(), y2);
- ++dest.numRects;
- ++pNextRect;
- ++r;
- }
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miSubtractO --
- * Overlapping band subtraction. x1 is the left-most point not yet
- * checked.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * dest may have rectangles added to it.
- *
- *-----------------------------------------------------------------------
- */
-
-static void miSubtractO(register QRegionPrivate &dest, register const QRect *r1, const QRect *r1End,
- register const QRect *r2, const QRect *r2End, register int y1, register int y2)
-{
- register QRect *pNextRect;
- register int x1;
-
- x1 = r1->left();
-
- Q_ASSERT(y1 <= y2);
- pNextRect = dest.rects.data() + dest.numRects;
-
- while (r1 != r1End && r2 != r2End) {
- if (r2->right() < x1) {
- /*
- * Subtrahend missed the boat: go to next subtrahend.
- */
- ++r2;
- } else if (r2->left() <= x1) {
- /*
- * Subtrahend precedes minuend: nuke left edge of minuend.
- */
- x1 = r2->right() + 1;
- if (x1 > r1->right()) {
- /*
- * Minuend completely covered: advance to next minuend and
- * reset left fence to edge of new minuend.
- */
- ++r1;
- if (r1 != r1End)
- x1 = r1->left();
- } else {
- // Subtrahend now used up since it doesn't extend beyond minuend
- ++r2;
- }
- } else if (r2->left() <= r1->right()) {
- /*
- * Left part of subtrahend covers part of minuend: add uncovered
- * part of minuend to region and skip to next subtrahend.
- */
- Q_ASSERT(x1 < r2->left());
- MEMCHECK(dest, pNextRect, dest.rects)
- pNextRect->setCoords(x1, y1, r2->left() - 1, y2);
- ++dest.numRects;
- ++pNextRect;
-
- x1 = r2->right() + 1;
- if (x1 > r1->right()) {
- /*
- * Minuend used up: advance to new...
- */
- ++r1;
- if (r1 != r1End)
- x1 = r1->left();
- } else {
- // Subtrahend used up
- ++r2;
- }
- } else {
- /*
- * Minuend used up: add any remaining piece before advancing.
- */
- if (r1->right() >= x1) {
- MEMCHECK(dest, pNextRect, dest.rects)
- pNextRect->setCoords(x1, y1, r1->right(), y2);
- ++dest.numRects;
- ++pNextRect;
- }
- ++r1;
- if (r1 != r1End)
- x1 = r1->left();
- }
- }
-
- /*
- * Add remaining minuend rectangles to region.
- */
- while (r1 != r1End) {
- Q_ASSERT(x1 <= r1->right());
- MEMCHECK(dest, pNextRect, dest.rects)
- pNextRect->setCoords(x1, y1, r1->right(), y2);
- ++dest.numRects;
- ++pNextRect;
-
- ++r1;
- if (r1 != r1End)
- x1 = r1->left();
- }
-}
-
-/*-
- *-----------------------------------------------------------------------
- * miSubtract --
- * Subtract regS from regM and leave the result in regD.
- * S stands for subtrahend, M for minuend and D for difference.
- *
- * Side Effects:
- * regD is overwritten.
- *
- *-----------------------------------------------------------------------
- */
-
-static void SubtractRegion(QRegionPrivate *regM, QRegionPrivate *regS,
- register QRegionPrivate &dest)
-{
- Q_ASSERT(!isEmptyHelper(regM));
- Q_ASSERT(!isEmptyHelper(regS));
- Q_ASSERT(EXTENTCHECK(&regM->extents, &regS->extents));
- Q_ASSERT(!regS->contains(*regM));
- Q_ASSERT(!EqualRegion(regM, regS));
-
- miRegionOp(dest, regM, regS, miSubtractO, miSubtractNonO1, 0);
-
- /*
- * Can't alter dest's extents before we call miRegionOp because
- * it might be one of the source regions and miRegionOp depends
- * on the extents of those regions being the unaltered. Besides, this
- * way there's no checking against rectangles that will be nuked
- * due to coalescing, so we have to examine fewer rectangles.
- */
- miSetExtents(dest);
-}
-
-static void XorRegion(QRegionPrivate *sra, QRegionPrivate *srb, QRegionPrivate &dest)
-{
- Q_ASSERT(!isEmptyHelper(sra) && !isEmptyHelper(srb));
- Q_ASSERT(EXTENTCHECK(&sra->extents, &srb->extents));
- Q_ASSERT(!EqualRegion(sra, srb));
-
- QRegionPrivate tra, trb;
-
- if (!srb->contains(*sra))
- SubtractRegion(sra, srb, tra);
- if (!sra->contains(*srb))
- SubtractRegion(srb, sra, trb);
-
- Q_ASSERT(isEmptyHelper(&trb) || !tra.contains(trb));
- Q_ASSERT(isEmptyHelper(&tra) || !trb.contains(tra));
-
- if (isEmptyHelper(&tra)) {
- dest = trb;
- } else if (isEmptyHelper(&trb)) {
- dest = tra;
- } else if (tra.canAppend(&trb)) {
- dest = tra;
- dest.append(&trb);
- } else if (trb.canAppend(&tra)) {
- dest = trb;
- dest.append(&tra);
- } else {
- UnionRegion(&tra, &trb, dest);
- }
-}
-
-/*
- * Check to see if two regions are equal
- */
-static bool EqualRegion(const QRegionPrivate *r1, const QRegionPrivate *r2)
-{
- if (r1->numRects != r2->numRects) {
- return false;
- } else if (r1->numRects == 0) {
- return true;
- } else if (r1->extents != r2->extents) {
- return false;
- } else if (r1->mode == QRegionPrivate::Single && r2->mode == QRegionPrivate::Single) {
- return r1->single == r2->single;
- } else {
- const QRect *rr1 = (r1->mode==QRegionPrivate::Vector)?r1->rects.constData():&r1->single;
- const QRect *rr2 = (r2->mode==QRegionPrivate::Vector)?r2->rects.constData():&r2->single;
- for (int i = 0; i < r1->numRects; ++i, ++rr1, ++rr2) {
- if (*rr1 != *rr2)
- return false;
- }
- }
-
- return true;
-}
-
-static bool PointInRegion(QRegionPrivate *pRegion, int x, int y)
-{
- int i;
-
- if (pRegion->mode == QRegionPrivate::Single)
- return pRegion->single.contains(x, y);
- if (isEmptyHelper(pRegion))
- return false;
- if (!pRegion->extents.contains(x, y))
- return false;
- if (pRegion->innerRect.contains(x, y))
- return true;
- for (i = 0; i < pRegion->numRects; ++i) {
- if (pRegion->rects[i].contains(x, y))
- return true;
- }
- return false;
-}
-
-static bool RectInRegion(register QRegionPrivate *region, int rx, int ry, uint rwidth, uint rheight)
-{
- register const QRect *pbox;
- register const QRect *pboxEnd;
- QRect rect(rx, ry, rwidth, rheight);
- register QRect *prect = &rect;
- int partIn, partOut;
-
- if (!region || region->numRects == 0 || !EXTENTCHECK(&region->extents, prect))
- return RectangleOut;
-
- partOut = false;
- partIn = false;
-
- /* can stop when both partOut and partIn are true, or we reach prect->y2 */
- for (pbox = (region->mode==QRegionPrivate::Vector)?region->rects.constData():&region->single, pboxEnd = pbox + region->numRects;
- pbox < pboxEnd; ++pbox) {
- if (pbox->bottom() < ry)
- continue;
-
- if (pbox->top() > ry) {
- partOut = true;
- if (partIn || pbox->top() > prect->bottom())
- break;
- ry = pbox->top();
- }
-
- if (pbox->right() < rx)
- continue; /* not far enough over yet */
-
- if (pbox->left() > rx) {
- partOut = true; /* missed part of rectangle to left */
- if (partIn)
- break;
- }
-
- if (pbox->left() <= prect->right()) {
- partIn = true; /* definitely overlap */
- if (partOut)
- break;
- }
-
- if (pbox->right() >= prect->right()) {
- ry = pbox->bottom() + 1; /* finished with this band */
- if (ry > prect->bottom())
- break;
- rx = prect->left(); /* reset x out to left again */
- } else {
- /*
- * Because boxes in a band are maximal width, if the first box
- * to overlap the rectangle doesn't completely cover it in that
- * band, the rectangle must be partially out, since some of it
- * will be uncovered in that band. partIn will have been set true
- * by now...
- */
- break;
- }
- }
- return partIn ? ((ry <= prect->bottom()) ? RectanglePart : RectangleIn) : RectangleOut;
-}
-// END OF Region.c extract
-// START OF poly.h extract
-/* $XConsortium: poly.h,v 1.4 94/04/17 20:22:19 rws Exp $ */
-/************************************************************************
-
-Copyright (c) 1987 X Consortium
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of the X Consortium shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from the X Consortium.
-
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
- All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose and without fee is hereby granted,
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
-supporting documentation, and that the name of Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-************************************************************************/
-
-/*
- * This file contains a few macros to help track
- * the edge of a filled object. The object is assumed
- * to be filled in scanline order, and thus the
- * algorithm used is an extension of Bresenham's line
- * drawing algorithm which assumes that y is always the
- * major axis.
- * Since these pieces of code are the same for any filled shape,
- * it is more convenient to gather the library in one
- * place, but since these pieces of code are also in
- * the inner loops of output primitives, procedure call
- * overhead is out of the question.
- * See the author for a derivation if needed.
- */
-
-
-/*
- * In scan converting polygons, we want to choose those pixels
- * which are inside the polygon. Thus, we add .5 to the starting
- * x coordinate for both left and right edges. Now we choose the
- * first pixel which is inside the pgon for the left edge and the
- * first pixel which is outside the pgon for the right edge.
- * Draw the left pixel, but not the right.
- *
- * How to add .5 to the starting x coordinate:
- * If the edge is moving to the right, then subtract dy from the
- * error term from the general form of the algorithm.
- * If the edge is moving to the left, then add dy to the error term.
- *
- * The reason for the difference between edges moving to the left
- * and edges moving to the right is simple: If an edge is moving
- * to the right, then we want the algorithm to flip immediately.
- * If it is moving to the left, then we don't want it to flip until
- * we traverse an entire pixel.
- */
-#define BRESINITPGON(dy, x1, x2, xStart, d, m, m1, incr1, incr2) { \
- int dx; /* local storage */ \
-\
- /* \
- * if the edge is horizontal, then it is ignored \
- * and assumed not to be processed. Otherwise, do this stuff. \
- */ \
- if ((dy) != 0) { \
- xStart = (x1); \
- dx = (x2) - xStart; \
- if (dx < 0) { \
- m = dx / (dy); \
- m1 = m - 1; \
- incr1 = -2 * dx + 2 * (dy) * m1; \
- incr2 = -2 * dx + 2 * (dy) * m; \
- d = 2 * m * (dy) - 2 * dx - 2 * (dy); \
- } else { \
- m = dx / (dy); \
- m1 = m + 1; \
- incr1 = 2 * dx - 2 * (dy) * m1; \
- incr2 = 2 * dx - 2 * (dy) * m; \
- d = -2 * m * (dy) + 2 * dx; \
- } \
- } \
-}
-
-#define BRESINCRPGON(d, minval, m, m1, incr1, incr2) { \
- if (m1 > 0) { \
- if (d > 0) { \
- minval += m1; \
- d += incr1; \
- } \
- else { \
- minval += m; \
- d += incr2; \
- } \
- } else {\
- if (d >= 0) { \
- minval += m1; \
- d += incr1; \
- } \
- else { \
- minval += m; \
- d += incr2; \
- } \
- } \
-}
-
-
-/*
- * This structure contains all of the information needed
- * to run the bresenham algorithm.
- * The variables may be hardcoded into the declarations
- * instead of using this structure to make use of
- * register declarations.
- */
-typedef struct {
- int minor_axis; /* minor axis */
- int d; /* decision variable */
- int m, m1; /* slope and slope+1 */
- int incr1, incr2; /* error increments */
-} BRESINFO;
-
-
-#define BRESINITPGONSTRUCT(dmaj, min1, min2, bres) \
- BRESINITPGON(dmaj, min1, min2, bres.minor_axis, bres.d, \
- bres.m, bres.m1, bres.incr1, bres.incr2)
-
-#define BRESINCRPGONSTRUCT(bres) \
- BRESINCRPGON(bres.d, bres.minor_axis, bres.m, bres.m1, bres.incr1, bres.incr2)
-
-
-
-/*
- * These are the data structures needed to scan
- * convert regions. Two different scan conversion
- * methods are available -- the even-odd method, and
- * the winding number method.
- * The even-odd rule states that a point is inside
- * the polygon if a ray drawn from that point in any
- * direction will pass through an odd number of
- * path segments.
- * By the winding number rule, a point is decided
- * to be inside the polygon if a ray drawn from that
- * point in any direction passes through a different
- * number of clockwise and counter-clockwise path
- * segments.
- *
- * These data structures are adapted somewhat from
- * the algorithm in (Foley/Van Dam) for scan converting
- * polygons.
- * The basic algorithm is to start at the top (smallest y)
- * of the polygon, stepping down to the bottom of
- * the polygon by incrementing the y coordinate. We
- * keep a list of edges which the current scanline crosses,
- * sorted by x. This list is called the Active Edge Table (AET)
- * As we change the y-coordinate, we update each entry in
- * in the active edge table to reflect the edges new xcoord.
- * This list must be sorted at each scanline in case
- * two edges intersect.
- * We also keep a data structure known as the Edge Table (ET),
- * which keeps track of all the edges which the current
- * scanline has not yet reached. The ET is basically a
- * list of ScanLineList structures containing a list of
- * edges which are entered at a given scanline. There is one
- * ScanLineList per scanline at which an edge is entered.
- * When we enter a new edge, we move it from the ET to the AET.
- *
- * From the AET, we can implement the even-odd rule as in
- * (Foley/Van Dam).
- * The winding number rule is a little trickier. We also
- * keep the EdgeTableEntries in the AET linked by the
- * nextWETE (winding EdgeTableEntry) link. This allows
- * the edges to be linked just as before for updating
- * purposes, but only uses the edges linked by the nextWETE
- * link as edges representing spans of the polygon to
- * drawn (as with the even-odd rule).
- */
-
-/*
- * for the winding number rule
- */
-#define CLOCKWISE 1
-#define COUNTERCLOCKWISE -1
-
-typedef struct _EdgeTableEntry {
- int ymax; /* ycoord at which we exit this edge. */
- BRESINFO bres; /* Bresenham info to run the edge */
- struct _EdgeTableEntry *next; /* next in the list */
- struct _EdgeTableEntry *back; /* for insertion sort */
- struct _EdgeTableEntry *nextWETE; /* for winding num rule */
- int ClockWise; /* flag for winding number rule */
-} EdgeTableEntry;
-
-
-typedef struct _ScanLineList{
- int scanline; /* the scanline represented */
- EdgeTableEntry *edgelist; /* header node */
- struct _ScanLineList *next; /* next in the list */
-} ScanLineList;
-
-
-typedef struct {
- int ymax; /* ymax for the polygon */
- int ymin; /* ymin for the polygon */
- ScanLineList scanlines; /* header node */
-} EdgeTable;
-
-
-/*
- * Here is a struct to help with storage allocation
- * so we can allocate a big chunk at a time, and then take
- * pieces from this heap when we need to.
- */
-#define SLLSPERBLOCK 25
-
-typedef struct _ScanLineListBlock {
- ScanLineList SLLs[SLLSPERBLOCK];
- struct _ScanLineListBlock *next;
-} ScanLineListBlock;
-
-
-
-/*
- *
- * a few macros for the inner loops of the fill code where
- * performance considerations don't allow a procedure call.
- *
- * Evaluate the given edge at the given scanline.
- * If the edge has expired, then we leave it and fix up
- * the active edge table; otherwise, we increment the
- * x value to be ready for the next scanline.
- * The winding number rule is in effect, so we must notify
- * the caller when the edge has been removed so he
- * can reorder the Winding Active Edge Table.
- */
-#define EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET) { \
- if (pAET->ymax == y) { /* leaving this edge */ \
- pPrevAET->next = pAET->next; \
- pAET = pPrevAET->next; \
- fixWAET = 1; \
- if (pAET) \
- pAET->back = pPrevAET; \
- } \
- else { \
- BRESINCRPGONSTRUCT(pAET->bres) \
- pPrevAET = pAET; \
- pAET = pAET->next; \
- } \
-}
-
-
-/*
- * Evaluate the given edge at the given scanline.
- * If the edge has expired, then we leave it and fix up
- * the active edge table; otherwise, we increment the
- * x value to be ready for the next scanline.
- * The even-odd rule is in effect.
- */
-#define EVALUATEEDGEEVENODD(pAET, pPrevAET, y) { \
- if (pAET->ymax == y) { /* leaving this edge */ \
- pPrevAET->next = pAET->next; \
- pAET = pPrevAET->next; \
- if (pAET) \
- pAET->back = pPrevAET; \
- } \
- else { \
- BRESINCRPGONSTRUCT(pAET->bres) \
- pPrevAET = pAET; \
- pAET = pAET->next; \
- } \
-}
-// END OF poly.h extract
-// START OF PolyReg.c extract
-/* $XConsortium: PolyReg.c,v 11.23 94/11/17 21:59:37 converse Exp $ */
-/************************************************************************
-
-Copyright (c) 1987 X Consortium
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
-AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of the X Consortium shall not be
-used in advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from the X Consortium.
-
-
-Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
-
- All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its
-documentation for any purpose and without fee is hereby granted,
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in
-supporting documentation, and that the name of Digital not be
-used in advertising or publicity pertaining to distribution of the
-software without specific, written prior permission.
-
-DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
-ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-SOFTWARE.
-
-************************************************************************/
-/* $XFree86: xc/lib/X11/PolyReg.c,v 1.1.1.2.8.2 1998/10/04 15:22:49 hohndel Exp $ */
-
-#define LARGE_COORDINATE 1000000
-#define SMALL_COORDINATE -LARGE_COORDINATE
-
-/*
- * InsertEdgeInET
- *
- * Insert the given edge into the edge table.
- * First we must find the correct bucket in the
- * Edge table, then find the right slot in the
- * bucket. Finally, we can insert it.
- *
- */
-static void InsertEdgeInET(EdgeTable *ET, EdgeTableEntry *ETE, int scanline,
- ScanLineListBlock **SLLBlock, int *iSLLBlock)
-{
- register EdgeTableEntry *start, *prev;
- register ScanLineList *pSLL, *pPrevSLL;
- ScanLineListBlock *tmpSLLBlock;
-
- /*
- * find the right bucket to put the edge into
- */
- pPrevSLL = &ET->scanlines;
- pSLL = pPrevSLL->next;
- while (pSLL && (pSLL->scanline < scanline)) {
- pPrevSLL = pSLL;
- pSLL = pSLL->next;
- }
-
- /*
- * reassign pSLL (pointer to ScanLineList) if necessary
- */
- if ((!pSLL) || (pSLL->scanline > scanline)) {
- if (*iSLLBlock > SLLSPERBLOCK-1)
- {
- tmpSLLBlock =
- (ScanLineListBlock *)malloc(sizeof(ScanLineListBlock));
- (*SLLBlock)->next = tmpSLLBlock;
- tmpSLLBlock->next = (ScanLineListBlock *)NULL;
- *SLLBlock = tmpSLLBlock;
- *iSLLBlock = 0;
- }
- pSLL = &((*SLLBlock)->SLLs[(*iSLLBlock)++]);
-
- pSLL->next = pPrevSLL->next;
- pSLL->edgelist = (EdgeTableEntry *)NULL;
- pPrevSLL->next = pSLL;
- }
- pSLL->scanline = scanline;
-
- /*
- * now insert the edge in the right bucket
- */
- prev = 0;
- start = pSLL->edgelist;
- while (start && (start->bres.minor_axis < ETE->bres.minor_axis)) {
- prev = start;
- start = start->next;
- }
- ETE->next = start;
-
- if (prev)
- prev->next = ETE;
- else
- pSLL->edgelist = ETE;
-}
-
-/*
- * CreateEdgeTable
- *
- * This routine creates the edge table for
- * scan converting polygons.
- * The Edge Table (ET) looks like:
- *
- * EdgeTable
- * --------
- * | ymax | ScanLineLists
- * |scanline|-->------------>-------------->...
- * -------- |scanline| |scanline|
- * |edgelist| |edgelist|
- * --------- ---------
- * | |
- * | |
- * V V
- * list of ETEs list of ETEs
- *
- * where ETE is an EdgeTableEntry data structure,
- * and there is one ScanLineList per scanline at
- * which an edge is initially entered.
- *
- */
-
-static void CreateETandAET(register int count, register const QPoint *pts,
- EdgeTable *ET, EdgeTableEntry *AET, register EdgeTableEntry *pETEs,
- ScanLineListBlock *pSLLBlock)
-{
- register const QPoint *top,
- *bottom,
- *PrevPt,
- *CurrPt;
- int iSLLBlock = 0;
- int dy;
-
- if (count < 2)
- return;
-
- /*
- * initialize the Active Edge Table
- */
- AET->next = 0;
- AET->back = 0;
- AET->nextWETE = 0;
- AET->bres.minor_axis = SMALL_COORDINATE;
-
- /*
- * initialize the Edge Table.
- */
- ET->scanlines.next = 0;
- ET->ymax = SMALL_COORDINATE;
- ET->ymin = LARGE_COORDINATE;
- pSLLBlock->next = 0;
-
- PrevPt = &pts[count - 1];
-
- /*
- * for each vertex in the array of points.
- * In this loop we are dealing with two vertices at
- * a time -- these make up one edge of the polygon.
- */
- while (count--) {
- CurrPt = pts++;
-
- /*
- * find out which point is above and which is below.
- */
- if (PrevPt->y() > CurrPt->y()) {
- bottom = PrevPt;
- top = CurrPt;
- pETEs->ClockWise = 0;
- } else {
- bottom = CurrPt;
- top = PrevPt;
- pETEs->ClockWise = 1;
- }
-
- /*
- * don't add horizontal edges to the Edge table.
- */
- if (bottom->y() != top->y()) {
- pETEs->ymax = bottom->y() - 1; /* -1 so we don't get last scanline */
-
- /*
- * initialize integer edge algorithm
- */
- dy = bottom->y() - top->y();
- BRESINITPGONSTRUCT(dy, top->x(), bottom->x(), pETEs->bres)
-
- InsertEdgeInET(ET, pETEs, top->y(), &pSLLBlock, &iSLLBlock);
-
- if (PrevPt->y() > ET->ymax)
- ET->ymax = PrevPt->y();
- if (PrevPt->y() < ET->ymin)
- ET->ymin = PrevPt->y();
- ++pETEs;
- }
-
- PrevPt = CurrPt;
- }
-}
-
-/*
- * loadAET
- *
- * This routine moves EdgeTableEntries from the
- * EdgeTable into the Active Edge Table,
- * leaving them sorted by smaller x coordinate.
- *
- */
-
-static void loadAET(register EdgeTableEntry *AET, register EdgeTableEntry *ETEs)
-{
- register EdgeTableEntry *pPrevAET;
- register EdgeTableEntry *tmp;
-
- pPrevAET = AET;
- AET = AET->next;
- while (ETEs) {
- while (AET && AET->bres.minor_axis < ETEs->bres.minor_axis) {
- pPrevAET = AET;
- AET = AET->next;
- }
- tmp = ETEs->next;
- ETEs->next = AET;
- if (AET)
- AET->back = ETEs;
- ETEs->back = pPrevAET;
- pPrevAET->next = ETEs;
- pPrevAET = ETEs;
-
- ETEs = tmp;
- }
-}
-
-/*
- * computeWAET
- *
- * This routine links the AET by the
- * nextWETE (winding EdgeTableEntry) link for
- * use by the winding number rule. The final
- * Active Edge Table (AET) might look something
- * like:
- *
- * AET
- * ---------- --------- ---------
- * |ymax | |ymax | |ymax |
- * | ... | |... | |... |
- * |next |->|next |->|next |->...
- * |nextWETE| |nextWETE| |nextWETE|
- * --------- --------- ^--------
- * | | |
- * V-------------------> V---> ...
- *
- */
-static void computeWAET(register EdgeTableEntry *AET)
-{
- register EdgeTableEntry *pWETE;
- register int inside = 1;
- register int isInside = 0;
-
- AET->nextWETE = 0;
- pWETE = AET;
- AET = AET->next;
- while (AET) {
- if (AET->ClockWise)
- ++isInside;
- else
- --isInside;
-
- if (!inside && !isInside || inside && isInside) {
- pWETE->nextWETE = AET;
- pWETE = AET;
- inside = !inside;
- }
- AET = AET->next;
- }
- pWETE->nextWETE = 0;
-}
-
-/*
- * InsertionSort
- *
- * Just a simple insertion sort using
- * pointers and back pointers to sort the Active
- * Edge Table.
- *
- */
-
-static int InsertionSort(register EdgeTableEntry *AET)
-{
- register EdgeTableEntry *pETEchase;
- register EdgeTableEntry *pETEinsert;
- register EdgeTableEntry *pETEchaseBackTMP;
- register int changed = 0;
-
- AET = AET->next;
- while (AET) {
- pETEinsert = AET;
- pETEchase = AET;
- while (pETEchase->back->bres.minor_axis > AET->bres.minor_axis)
- pETEchase = pETEchase->back;
-
- AET = AET->next;
- if (pETEchase != pETEinsert) {
- pETEchaseBackTMP = pETEchase->back;
- pETEinsert->back->next = AET;
- if (AET)
- AET->back = pETEinsert->back;
- pETEinsert->next = pETEchase;
- pETEchase->back->next = pETEinsert;
- pETEchase->back = pETEinsert;
- pETEinsert->back = pETEchaseBackTMP;
- changed = 1;
- }
- }
- return changed;
-}
-
-/*
- * Clean up our act.
- */
-static void FreeStorage(register ScanLineListBlock *pSLLBlock)
-{
- register ScanLineListBlock *tmpSLLBlock;
-
- while (pSLLBlock) {
- tmpSLLBlock = pSLLBlock->next;
- free(pSLLBlock);
- pSLLBlock = tmpSLLBlock;
- }
-}
-
-/*
- * Create an array of rectangles from a list of points.
- * If indeed these things (POINTS, RECTS) are the same,
- * then this proc is still needed, because it allocates
- * storage for the array, which was allocated on the
- * stack by the calling procedure.
- *
- */
-static void PtsToRegion(register int numFullPtBlocks, register int iCurPtBlock,
- POINTBLOCK *FirstPtBlock, QRegionPrivate *reg)
-{
- register QRect *rects;
- register QPoint *pts;
- register POINTBLOCK *CurPtBlock;
- register int i;
- register QRect *extents;
- register int numRects;
-
- extents = &reg->extents;
- numRects = ((numFullPtBlocks * NUMPTSTOBUFFER) + iCurPtBlock) >> 1;
-
- reg->rects.resize(numRects);
-
- CurPtBlock = FirstPtBlock;
- rects = reg->rects.data() - 1;
- numRects = 0;
- extents->setLeft(INT_MAX);
- extents->setRight(INT_MIN);
- reg->innerArea = -1;
-
- for (; numFullPtBlocks >= 0; --numFullPtBlocks) {
- /* the loop uses 2 points per iteration */
- i = NUMPTSTOBUFFER >> 1;
- if (!numFullPtBlocks)
- i = iCurPtBlock >> 1;
- if(i) {
- for (pts = CurPtBlock->pts; i--; pts += 2) {
- if (pts->x() == pts[1].x())
- continue;
- if (numRects && pts->x() == rects->left() && pts->y() == rects->bottom() + 1
- && pts[1].x() == rects->right()+1 && (numRects == 1 || rects[-1].top() != rects->top())
- && (i && pts[2].y() > pts[1].y())) {
- rects->setBottom(pts[1].y());
- reg->updateInnerRect(*rects);
- continue;
- }
- ++numRects;
- ++rects;
- rects->setCoords(pts->x(), pts->y(), pts[1].x() - 1, pts[1].y());
- if (rects->left() < extents->left())
- extents->setLeft(rects->left());
- if (rects->right() > extents->right())
- extents->setRight(rects->right());
- reg->updateInnerRect(*rects);
- }
- }
- CurPtBlock = CurPtBlock->next;
- }
-
- if (numRects) {
- extents->setTop(reg->rects[0].top());
- extents->setBottom(rects->bottom());
- } else {
- extents->setCoords(0, 0, 0, 0);
- }
- reg->numRects = numRects;
-}
-
-/*
- * polytoregion
- *
- * Scan converts a polygon by returning a run-length
- * encoding of the resultant bitmap -- the run-length
- * encoding is in the form of an array of rectangles.
- */
-static QRegionPrivate *PolygonRegion(const QPoint *Pts, int Count, int rule,
- QRegionPrivate *region)
- //Point *Pts; /* the pts */
- //int Count; /* number of pts */
- //int rule; /* winding rule */
-{
- register EdgeTableEntry *pAET; /* Active Edge Table */
- register int y; /* current scanline */
- register int iPts = 0; /* number of pts in buffer */
- register EdgeTableEntry *pWETE; /* Winding Edge Table Entry*/
- register ScanLineList *pSLL; /* current scanLineList */
- register QPoint *pts; /* output buffer */
- EdgeTableEntry *pPrevAET; /* ptr to previous AET */
- EdgeTable ET; /* header node for ET */
- EdgeTableEntry AET; /* header node for AET */
- EdgeTableEntry *pETEs; /* EdgeTableEntries pool */
- ScanLineListBlock SLLBlock; /* header for scanlinelist */
- int fixWAET = false;
- POINTBLOCK FirstPtBlock, *curPtBlock; /* PtBlock buffers */
- POINTBLOCK *tmpPtBlock;
- int numFullPtBlocks = 0;
-
- region->vector();
-
- /* special case a rectangle */
- if (((Count == 4) ||
- ((Count == 5) && (Pts[4].x() == Pts[0].x()) && (Pts[4].y() == Pts[0].y())))
- && (((Pts[0].y() == Pts[1].y()) && (Pts[1].x() == Pts[2].x()) && (Pts[2].y() == Pts[3].y())
- && (Pts[3].x() == Pts[0].x())) || ((Pts[0].x() == Pts[1].x())
- && (Pts[1].y() == Pts[2].y()) && (Pts[2].x() == Pts[3].x())
- && (Pts[3].y() == Pts[0].y())))) {
- int x = qMin(Pts[0].x(), Pts[2].x());
- region->extents.setLeft(x);
- int y = qMin(Pts[0].y(), Pts[2].y());
- region->extents.setTop(y);
- region->extents.setWidth(qMax(Pts[0].x(), Pts[2].x()) - x);
- region->extents.setHeight(qMax(Pts[0].y(), Pts[2].y()) - y);
- if ((region->extents.left() <= region->extents.right()) &&
- (region->extents.top() <= region->extents.bottom())) {
- region->numRects = 1;
- region->rects.resize(1);
- region->rects[0] = region->extents;
- region->innerRect = region->extents;
- region->innerArea = region->innerRect.width() * region->innerRect.height();
- }
- return region;
- }
-
- if (!(pETEs = static_cast<EdgeTableEntry *>(malloc(sizeof(EdgeTableEntry) * Count))))
- return 0;
-
- pts = FirstPtBlock.pts;
- CreateETandAET(Count, Pts, &ET, &AET, pETEs, &SLLBlock);
- pSLL = ET.scanlines.next;
- curPtBlock = &FirstPtBlock;
-
- if (rule == EvenOddRule) {
- /*
- * for each scanline
- */
- for (y = ET.ymin; y < ET.ymax; ++y) {
- /*
- * Add a new edge to the active edge table when we
- * get to the next edge.
- */
- if (pSLL && y == pSLL->scanline) {
- loadAET(&AET, pSLL->edgelist);
- pSLL = pSLL->next;
- }
- pPrevAET = &AET;
- pAET = AET.next;
-
- /*
- * for each active edge
- */
- while (pAET) {
- pts->setX(pAET->bres.minor_axis);
- pts->setY(y);
- ++pts;
- ++iPts;
-
- /*
- * send out the buffer
- */
- if (iPts == NUMPTSTOBUFFER) {
- tmpPtBlock = (POINTBLOCK *)malloc(sizeof(POINTBLOCK));
- curPtBlock->next = tmpPtBlock;
- curPtBlock = tmpPtBlock;
- pts = curPtBlock->pts;
- ++numFullPtBlocks;
- iPts = 0;
- }
- EVALUATEEDGEEVENODD(pAET, pPrevAET, y)
- }
- InsertionSort(&AET);
- }
- } else {
- /*
- * for each scanline
- */
- for (y = ET.ymin; y < ET.ymax; ++y) {
- /*
- * Add a new edge to the active edge table when we
- * get to the next edge.
- */
- if (pSLL && y == pSLL->scanline) {
- loadAET(&AET, pSLL->edgelist);
- computeWAET(&AET);
- pSLL = pSLL->next;
- }
- pPrevAET = &AET;
- pAET = AET.next;
- pWETE = pAET;
-
- /*
- * for each active edge
- */
- while (pAET) {
- /*
- * add to the buffer only those edges that
- * are in the Winding active edge table.
- */
- if (pWETE == pAET) {
- pts->setX(pAET->bres.minor_axis);
- pts->setY(y);
- ++pts;
- ++iPts;
-
- /*
- * send out the buffer
- */
- if (iPts == NUMPTSTOBUFFER) {
- tmpPtBlock = static_cast<POINTBLOCK *>(malloc(sizeof(POINTBLOCK)));
- curPtBlock->next = tmpPtBlock;
- curPtBlock = tmpPtBlock;
- pts = curPtBlock->pts;
- ++numFullPtBlocks;
- iPts = 0;
- }
- pWETE = pWETE->nextWETE;
- }
- EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET)
- }
-
- /*
- * recompute the winding active edge table if
- * we just resorted or have exited an edge.
- */
- if (InsertionSort(&AET) || fixWAET) {
- computeWAET(&AET);
- fixWAET = false;
- }
- }
- }
- FreeStorage(SLLBlock.next);
- PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock, region);
- for (curPtBlock = FirstPtBlock.next; --numFullPtBlocks >= 0;) {
- tmpPtBlock = curPtBlock->next;
- free(curPtBlock);
- curPtBlock = tmpPtBlock;
- }
- free(pETEs);
- return region;
-}
-// END OF PolyReg.c extract
-
-QRegionPrivate *qt_bitmapToRegion(const QBitmap& bitmap, QRegionPrivate *region)
-{
- region->vector();
-
- QImage image = bitmap.toImage();
-
- QRect xr;
-
-#define AddSpan \
- { \
- xr.setCoords(prev1, y, x-1, y); \
- UnionRectWithRegion(&xr, region, *region); \
- }
-
- const uchar zero = 0;
- bool little = image.format() == QImage::Format_MonoLSB;
-
- int x,
- y;
- for (y = 0; y < image.height(); ++y) {
- uchar *line = image.scanLine(y);
- int w = image.width();
- uchar all = zero;
- int prev1 = -1;
- for (x = 0; x < w;) {
- uchar byte = line[x / 8];
- if (x > w - 8 || byte!=all) {
- if (little) {
- for (int b = 8; b > 0 && x < w; --b) {
- if (!(byte & 0x01) == !all) {
- // More of the same
- } else {
- // A change.
- if (all!=zero) {
- AddSpan
- all = zero;
- } else {
- prev1 = x;
- all = ~zero;
- }
- }
- byte >>= 1;
- ++x;
- }
- } else {
- for (int b = 8; b > 0 && x < w; --b) {
- if (!(byte & 0x80) == !all) {
- // More of the same
- } else {
- // A change.
- if (all != zero) {
- AddSpan
- all = zero;
- } else {
- prev1 = x;
- all = ~zero;
- }
- }
- byte <<= 1;
- ++x;
- }
- }
- } else {
- x += 8;
- }
- }
- if (all != zero) {
- AddSpan
- }
- }
-#undef AddSpan
-
- return region;
-}
-
-/*
- Constructs an empty region.
-
- \sa isEmpty()
-*/
-
-QRegion::QRegion()
- : d(&shared_empty)
-{
- d->ref.ref();
-}
-
-/*
- \overload
-
- Create a region based on the rectange \a r with region type \a t.
-
- If the rectangle is invalid a null region will be created.
-
- \sa QRegion::RegionType
-*/
-
-QRegion::QRegion(const QRect &r, RegionType t)
-{
- if (r.isEmpty()) {
- d = &shared_empty;
- d->ref.ref();
- } else {
-// d = new QRegionData;
- QRegionPrivate *rp = 0;
- if (t == Rectangle) {
-// rp = new QRegionPrivate(r);
- rp = qt_allocRegion(r);
- } else if (t == Ellipse) {
- QPainterPath path;
- path.addEllipse(r.x(), r.y(), r.width(), r.height());
- QPolygon a = path.toSubpathPolygons().at(0).toPolygon();
- rp = qt_allocRegion();
-// rp = new QRegionPrivate;
- PolygonRegion(a.constData(), a.size(), EvenOddRule, rp);
- }
- d = rp;
- d->ref = 1;
-#if defined(Q_WS_X11)
- d->rgn = 0;
- d->xrectangles = 0;
-#elif defined(Q_WS_MAC)
- d->rgn = 0;
-#endif
- d->qt_rgn = rp;
- }
-}
-
-/*
- Constructs a polygon region from the point array \a a with the fill rule
- specified by \a fillRule.
-
- If \a fillRule is \l{Qt::WindingFill}, the polygon region is defined
- using the winding algorithm; if it is \l{Qt::OddEvenFill}, the odd-even fill
- algorithm is used.
-
- \warning This constructor can be used to create complex regions that will
- slow down painting when used.
-*/
-
-QRegion::QRegion(const QPolygon &a, Qt::FillRule fillRule)
-{
- if (a.count() > 2) {
- //d = new QRegionData;
- // QRegionPrivate *rp = new QRegionPrivate;
- QRegionPrivate *rp = qt_allocRegion();
- PolygonRegion(a.constData(), a.size(),
- fillRule == Qt::WindingFill ? WindingRule : EvenOddRule, rp);
- d = rp;
- d->ref = 1;
-#if defined(Q_WS_X11)
- d->rgn = 0;
- d->xrectangles = 0;
-#elif defined(Q_WS_MAC)
- d->rgn = 0;
-#endif
- d->qt_rgn = rp;
- } else {
- d = &shared_empty;
- d->ref.ref();
- }
-}
-
-
-/*
- Constructs a new region which is equal to region \a r.
-*/
-
-QRegion::QRegion(const QRegion &r)
-{
- d = r.d;
- d->ref.ref();
-}
-
-
-/*
- Constructs a region from the bitmap \a bm.
-
- The resulting region consists of the pixels in bitmap \a bm that
- are Qt::color1, as if each pixel was a 1 by 1 rectangle.
-
- This constructor may create complex regions that will slow down
- painting when used. Note that drawing masked pixmaps can be done
- much faster using QPixmap::setMask().
-*/
-QRegion::QRegion(const QBitmap &bm)
-{
- if (bm.isNull()) {
- d = &shared_empty;
- d->ref.ref();
- } else {
- // d = new QRegionData;
-// QRegionPrivate *rp = new QRegionPrivate;
- QRegionPrivate *rp = qt_allocRegion();
-
- qt_bitmapToRegion(bm, rp);
- d = rp;
- d->ref = 1;
-#if defined(Q_WS_X11)
- d->rgn = 0;
- d->xrectangles = 0;
-#elif defined(Q_WS_MAC)
- d->rgn = 0;
-#endif
- d->qt_rgn = rp;
- }
-}
-
-void QRegion::cleanUp(QRegion::QRegionData *x)
-{
- // delete x->qt_rgn;
-#if defined(Q_WS_X11)
- if (x->rgn)
- XDestroyRegion(x->rgn);
- if (x->xrectangles)
- free(x->xrectangles);
-#elif defined(Q_WS_MAC)
- if (x->rgn)
- qt_mac_dispose_rgn(x->rgn);
-#endif
- if(x->qt_rgn) {
-// delete x->qt_rgn;
- qt_freeRegion(x->qt_rgn);
- } else {
- delete x;
- }
-}
-
-/*
- Destroys the region.
-*/
-
-QRegion::~QRegion()
-{
- if (!d->ref.deref())
- cleanUp(d);
-}
-
-
-/*
- Assigns \a r to this region and returns a reference to the region.
-*/
-
-QRegion &QRegion::operator=(const QRegion &r)
-{
- r.d->ref.ref();
- if (!d->ref.deref())
- cleanUp(d);
- d = r.d;
- return *this;
-}
-
-
-/*
- \internal
-*/
-
-QRegion QRegion::copy() const
-{
- QRegion r;
- QRegionData *x = 0; // new QRegionData;
- QRegionPrivate *rp = 0;
- if (d->qt_rgn)
-// rp = new QRegionPrivate(*d->qt_rgn);
- rp = qt_allocRegion(*d->qt_rgn);
- else
- rp = qt_allocRegion();
- x = rp;
- x->qt_rgn = rp;
- x->ref = 1;
-#if defined(Q_WS_X11)
- x->rgn = 0;
- x->xrectangles = 0;
-#elif defined(Q_WS_MAC)
- x->rgn = 0;
-#endif
-
- if (!r.d->ref.deref())
- cleanUp(r.d);
- r.d = x;
- return r;
-}
-
-/*
- Returns true if the region is empty; otherwise returns false. An
- empty region is a region that contains no points.
-
- Example:
- \snippet doc/src/snippets/code/src.gui.painting.qregion_qws.cpp 0
-*/
-
-bool QRegion::isEmpty() const
-{
- return d == &shared_empty || d->qt_rgn->numRects == 0;
-}
-
-
-/*
- Returns true if the region contains the point \a p; otherwise
- returns false.
-*/
-
-bool QRegion::contains(const QPoint &p) const
-{
- return PointInRegion(d->qt_rgn, p.x(), p.y());
-}
-
-/*
- \overload
-
- Returns true if the region overlaps the rectangle \a r; otherwise
- returns false.
-*/
-
-bool QRegion::contains(const QRect &r) const
-{
- if(!d->qt_rgn)
- return false;
- if(d->qt_rgn->mode == QRegionPrivate::Single)
- return d->qt_rgn->single.contains(r);
-
- return RectInRegion(d->qt_rgn, r.left(), r.top(), r.width(), r.height()) != RectangleOut;
-}
-
-
-
-/*
- Translates (moves) the region \a dx along the X axis and \a dy
- along the Y axis.
-*/
-
-void QRegion::translate(int dx, int dy)
-{
- if ((dx == 0 && dy == 0) || isEmptyHelper(d->qt_rgn))
- return;
-
- detach();
- OffsetRegion(*d->qt_rgn, dx, dy);
-#if defined(Q_WS_X11)
- if (d->xrectangles) {
- free(d->xrectangles);
- d->xrectangles = 0;
- }
-#elif defined(Q_WS_MAC)
- if(d->rgn) {
- qt_mac_dispose_rgn(d->rgn);
- d->rgn = 0;
- }
-#endif
-}
-
-/*
- \fn QRegion QRegion::unite(const QRegion &r) const
- \obsolete
-
- Use united(\a r) instead.
-*/
-
-/*
- \fn QRegion QRegion::united(const QRegion &r) const
- \since 4.2
-
- Returns a region which is the union of this region and \a r.
-
- \img runion.png Region Union
-
- The figure shows the union of two elliptical regions.
-
- \sa intersected(), subtracted(), xored()
-*/
-
-QRegion QRegion::unite(const QRegion &r) const
-{
- if (isEmptyHelper(d->qt_rgn))
- return r;
- if (isEmptyHelper(r.d->qt_rgn))
- return *this;
-
- if (d->qt_rgn->contains(*r.d->qt_rgn)) {
- return *this;
- } else if (r.d->qt_rgn->contains(*d->qt_rgn)) {
- return r;
- } else if (d->qt_rgn->canAppend(r.d->qt_rgn)) {
- QRegion result(*this);
- result.detach();
- result.d->qt_rgn->append(r.d->qt_rgn);
- return result;
- } else if (r.d->qt_rgn->canAppend(d->qt_rgn)) {
- QRegion result(r);
- result.detach();
- result.d->qt_rgn->append(d->qt_rgn);
- return result;
- } else if (EqualRegion(d->qt_rgn, r.d->qt_rgn)) {
- return *this;
- } else {
- QRegion result;
- result.detach();
- UnionRegion(d->qt_rgn, r.d->qt_rgn, *result.d->qt_rgn);
- return result;
- }
-}
-
-QRegion& QRegion::operator+=(const QRegion &r)
-{
- if (isEmptyHelper(d->qt_rgn))
- return *this = r;
- if (isEmptyHelper(r.d->qt_rgn))
- return *this;
-
- if (d->qt_rgn->contains(*r.d->qt_rgn)) {
- return *this;
- } else if (r.d->qt_rgn->contains(*d->qt_rgn)) {
- return *this = r;
- } else if (d->qt_rgn->canAppend(r.d->qt_rgn)) {
- detach();
- d->qt_rgn->append(r.d->qt_rgn);
- return *this;
- } else if (d->qt_rgn->canPrepend(r.d->qt_rgn)) {
- detach();
- d->qt_rgn->prepend(r.d->qt_rgn);
- return *this;
- } else if (EqualRegion(d->qt_rgn, r.d->qt_rgn)) {
- return *this;
- }
-
- return *this = unite(r);
-}
-
-/*
- \fn QRegion QRegion::intersect(const QRegion &r) const
- \obsolete
-
- Use intersected(\a r) instead.
-*/
-
-/*
- \fn QRegion QRegion::intersected(const QRegion &r) const
- \since 4.2
-
- Returns a region which is the intersection of this region and \a r.
-
- \img rintersect.png Region Intersection
-
- The figure shows the intersection of two elliptical regions.
-*/
-
-QRegion QRegion::intersect(const QRegion &r) const
-{
- if (isEmptyHelper(d->qt_rgn) || isEmptyHelper(r.d->qt_rgn)
- || !EXTENTCHECK(&d->qt_rgn->extents, &r.d->qt_rgn->extents))
- return QRegion();
-
- /* this is fully contained in r */
- if (r.d->qt_rgn->contains(*d->qt_rgn))
- return *this;
-
- /* r is fully contained in this */
- if (d->qt_rgn->contains(*r.d->qt_rgn))
- return r;
-
- if(r.d->qt_rgn->mode == QRegionPrivate::Single &&
- d->qt_rgn->mode == QRegionPrivate::Single)
- return QRegion(r.d->qt_rgn->single.intersected(d->qt_rgn->single));
-#ifdef QT_GREENPHONE_OPT
- else if(r.d->qt_rgn->mode == QRegionPrivate::Single)
- return intersect(r.d->qt_rgn->single);
- else if(d->qt_rgn->mode == QRegionPrivate::Single)
- return r.intersect(d->qt_rgn->single);
-#endif
-
- QRegion result;
- result.detach();
- miRegionOp(*result.d->qt_rgn, d->qt_rgn, r.d->qt_rgn, miIntersectO, 0, 0);
-
- /*
- * Can't alter dest's extents before we call miRegionOp because
- * it might be one of the source regions and miRegionOp depends
- * on the extents of those regions being the same. Besides, this
- * way there's no checking against rectangles that will be nuked
- * due to coalescing, so we have to examine fewer rectangles.
- */
- miSetExtents(*result.d->qt_rgn);
- return result;
-}
-
-#ifdef QT_GREENPHONE_OPT
-/*
- \overload
- */
-QRegion QRegion::intersect(const QRect &r) const
-{
- // No intersection
- if(r.isEmpty() || isEmpty() || !EXTENTCHECK(&r, &d->qt_rgn->extents))
- return QRegion();
-
- // This is fully contained in r
- if(CONTAINSCHECK(r, d->qt_rgn->extents))
- return *this;
-
- // r is fully contained in this
- if(CONTAINSCHECK(d->qt_rgn->innerRect, r))
- return QRegion(r);
-
- if(d->qt_rgn->mode == QRegionPrivate::Single) {
- return QRegion(d->qt_rgn->single & r);
- } else {
- QRegion rv(*this);
- rv.detach();
-
- rv.d->qt_rgn->extents &= r;
- rv.d->qt_rgn->innerRect &= r;
- rv.d->qt_rgn->innerArea = rv.d->qt_rgn->innerRect.height() *
- rv.d->qt_rgn->innerRect.width();
-
- int numRects = 0;
- for(int ii = 0; ii < rv.d->qt_rgn->numRects; ++ii) {
- QRect result = rv.d->qt_rgn->rects[ii] & r;
- if(!result.isEmpty())
- rv.d->qt_rgn->rects[numRects++] = result;
- }
- rv.d->qt_rgn->numRects = numRects;
- return rv;
- }
-}
-
-/*
- \overload
- */
-const QRegion QRegion::operator&(const QRect &r) const
-{
- return intersect(r);
-}
-
-/*
- \overload
- */
-QRegion& QRegion::operator&=(const QRect &r)
-{
- if(isEmpty() || CONTAINSCHECK(r, d->qt_rgn->extents)) {
- // Do nothing
- } else if(r.isEmpty() || !EXTENTCHECK(&r, &d->qt_rgn->extents)) {
- *this = QRegion();
- } else if(CONTAINSCHECK(d->qt_rgn->innerRect, r)) {
- *this = QRegion(r);
- } else {
- detach();
- if(d->qt_rgn->mode == QRegionPrivate::Single) {
- QRect result = d->qt_rgn->single & r;
- d->qt_rgn->single = result;
- d->qt_rgn->extents = result;
- d->qt_rgn->innerRect = result;
- d->qt_rgn->innerArea = result.height() * result.width();
- } else {
- d->qt_rgn->extents &= r;
- d->qt_rgn->innerRect &= r;
- d->qt_rgn->innerArea = d->qt_rgn->innerRect.height() *
- d->qt_rgn->innerRect.width();
-
- int numRects = 0;
- for(int ii = 0; ii < d->qt_rgn->numRects; ++ii) {
- QRect result = d->qt_rgn->rects[ii] & r;
- if(!result.isEmpty())
- d->qt_rgn->rects[numRects++] = result;
- }
- d->qt_rgn->numRects = numRects;
- }
- }
- return *this;
-}
-#endif
-
-/*
- \fn QRegion QRegion::subtract(const QRegion &r) const
- \obsolete
-
- Use subtracted(\a r) instead.
-*/
-
-/*
- \fn QRegion QRegion::subtracted(const QRegion &r) const
- \since 4.2
-
- Returns a region which is \a r subtracted from this region.
-
- \img rsubtract.png Region Subtraction
-
- The figure shows the result when the ellipse on the right is
- subtracted from the ellipse on the left (\c {left - right}).
-
- \sa intersected(), united(), xored()
-*/
-
-QRegion QRegion::subtract(const QRegion &r) const
-{
- if (isEmptyHelper(d->qt_rgn) || isEmptyHelper(r.d->qt_rgn))
- return *this;
- if (r.d->qt_rgn->contains(*d->qt_rgn))
- return QRegion();
- if (!EXTENTCHECK(&d->qt_rgn->extents, &r.d->qt_rgn->extents))
- return *this;
- if (EqualRegion(d->qt_rgn, r.d->qt_rgn))
- return QRegion();
-
- QRegion result;
- result.detach();
- SubtractRegion(d->qt_rgn, r.d->qt_rgn, *result.d->qt_rgn);
- return result;
-}
-
-/*
- \fn QRegion QRegion::eor(const QRegion &r) const
- \obsolete
-
- Use xored(\a r) instead.
-*/
-
-/*
- \fn QRegion QRegion::xored(const QRegion &r) const
- \since 4.2
-
- Returns a region which is the exclusive or (XOR) of this region
- and \a r.
-
- \img rxor.png Region XORed
-
- The figure shows the exclusive or of two elliptical regions.
-
- \sa intersected(), united(), subtracted()
-*/
-
-QRegion QRegion::eor(const QRegion &r) const
-{
- if (isEmptyHelper(d->qt_rgn)) {
- return r;
- } else if (isEmptyHelper(r.d->qt_rgn)) {
- return *this;
- } else if (!EXTENTCHECK(&d->qt_rgn->extents, &r.d->qt_rgn->extents)) {
- return (*this + r);
- } else if (EqualRegion(d->qt_rgn, r.d->qt_rgn)) {
- return QRegion();
- } else {
- QRegion result;
- result.detach();
- XorRegion(d->qt_rgn, r.d->qt_rgn, *result.d->qt_rgn);
- return result;
- }
-}
-
-/*
- Returns the bounding rectangle of this region. An empty region
- gives a rectangle that is QRect::isNull().
-*/
-
-QRect QRegion::boundingRect() const
-{
- if (isEmpty())
- return QRect();
- return d->qt_rgn->extents;
-}
-
-/* \internal
- Returns true if \a rect is guaranteed to be fully contained in \a region.
- A false return value does not guarantee the opposite.
-*/
-bool qt_region_strictContains(const QRegion &region, const QRect &rect)
-{
- if (isEmptyHelper(region.d->qt_rgn) || !rect.isValid())
- return false;
-
-#if 0 // TEST_INNERRECT
- static bool guard = false;
- if (guard)
- return QRect();
- guard = true;
- QRegion inner = region.d->qt_rgn->innerRect;
- Q_ASSERT((inner - region).isEmpty());
- guard = false;
-
- int maxArea = 0;
- for (int i = 0; i < region.d->qt_rgn->numRects; ++i) {
- const QRect r = region.d->qt_rgn->rects.at(i);
- if (r.width() * r.height() > maxArea)
- maxArea = r.width() * r.height();
- }
-
- if (maxArea > region.d->qt_rgn->innerArea) {
- qDebug() << "not largest rectangle" << region << region.d->qt_rgn->innerRect;
- }
- Q_ASSERT(maxArea <= region.d->qt_rgn->innerArea);
-#endif
-
- const QRect r1 = region.d->qt_rgn->innerRect;
- return (rect.left() >= r1.left() && rect.right() <= r1.right()
- && rect.top() >= r1.top() && rect.bottom() <= r1.bottom());
-}
-
-/*
- Returns an array of non-overlapping rectangles that make up the
- region.
-
- The union of all the rectangles is equal to the original region.
-*/
-QVector<QRect> QRegion::rects() const
-{
- if (d->qt_rgn) {
- d->qt_rgn->vector();
- d->qt_rgn->rects.resize(d->qt_rgn->numRects);
- return d->qt_rgn->rects;
- } else {
- return QVector<QRect>();
- }
-}
-
-/*
- \fn void QRegion::setRects(const QRect *rects, int number)
-
- Sets the region using the array of rectangles specified by \a rects and
- \a number.
- The rectangles \e must be optimally Y-X sorted and follow these restrictions:
-
- \list
- \o The rectangles must not intersect.
- \o All rectangles with a given top coordinate must have the same height.
- \o No two rectangles may abut horizontally (they should be combined
- into a single wider rectangle in that case).
- \o The rectangles must be sorted in ascending order, with Y as the major
- sort key and X as the minor sort key.
- \endlist
- \omit
- Only some platforms have these restrictions (Qt for Embedded Linux, X11 and Mac OS X).
- \endomit
-*/
-void QRegion::setRects(const QRect *rects, int num)
-{
- *this = QRegion();
- if (!rects || num == 0 || (num == 1 && rects->isEmpty()))
- return;
-
- detach();
-
- if(num == 1) {
- d->qt_rgn->single = *rects;
- d->qt_rgn->mode = QRegionPrivate::Single;
- d->qt_rgn->numRects = num;
- d->qt_rgn->extents = *rects;
- d->qt_rgn->innerRect = *rects;
- } else {
- d->qt_rgn->mode = QRegionPrivate::Vector;
- d->qt_rgn->rects.resize(num);
- d->qt_rgn->numRects = num;
- int left = INT_MAX,
- right = INT_MIN,
- top = INT_MAX,
- bottom = INT_MIN;
- for (int i = 0; i < num; ++i) {
- const QRect &rect = rects[i];
- d->qt_rgn->rects[i] = rect;
- left = qMin(rect.left(), left);
- right = qMax(rect.right(), right);
- top = qMin(rect.top(), top);
- bottom = qMax(rect.bottom(), bottom);
- d->qt_rgn->updateInnerRect(rect);
- }
- d->qt_rgn->extents = QRect(QPoint(left, top), QPoint(right, bottom));
- }
-}
-
-/*
- Returns true if the region is equal to \a r; otherwise returns
- false.
-*/
-
-bool QRegion::operator==(const QRegion &r) const
-{
- if (!d->qt_rgn || !r.d->qt_rgn)
- return r.d->qt_rgn == d->qt_rgn;
-
- if (d == r.d)
- return true;
- else
- return EqualRegion(d->qt_rgn, r.d->qt_rgn);
-}
-
-#ifdef QT_GREENPHONE_OPT
-bool QRegion::isRect() const
-{
- return d->qt_rgn && d->qt_rgn->mode == QRegionPrivate::Single;
-}
-#endif
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qstylepainter.h b/src/gui/painting/qstylepainter.h
deleted file mode 100644
index 0fc3f2b4b9..0000000000
--- a/src/gui/painting/qstylepainter.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSTYLEPAINTER_H
-#define QSTYLEPAINTER_H
-
-#include <QtGui/qpainter.h>
-#include <QtGui/qstyle.h>
-#include <QtGui/qwidget.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QStylePainter : public QPainter
-{
-public:
- inline QStylePainter() : QPainter(), widget(0), wstyle(0) {}
- inline explicit QStylePainter(QWidget *w) { begin(w, w); }
- inline QStylePainter(QPaintDevice *pd, QWidget *w) { begin(pd, w); }
- inline bool begin(QWidget *w) { return begin(w, w); }
- inline bool begin(QPaintDevice *pd, QWidget *w) {
- Q_ASSERT_X(w, "QStylePainter::QStylePainter", "Widget must be non-zero");
- widget = w;
- wstyle = w->style();
- return QPainter::begin(pd);
- };
- inline void drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption &opt);
- inline void drawControl(QStyle::ControlElement ce, const QStyleOption &opt);
- inline void drawComplexControl(QStyle::ComplexControl cc, const QStyleOptionComplex &opt);
- inline void drawItemText(const QRect &r, int flags, const QPalette &pal, bool enabled,
- const QString &text, QPalette::ColorRole textRole = QPalette::NoRole);
- inline void drawItemPixmap(const QRect &r, int flags, const QPixmap &pixmap);
- inline QStyle *style() const { return wstyle; }
-
-private:
- QWidget *widget;
- QStyle *wstyle;
- Q_DISABLE_COPY(QStylePainter)
-};
-
-void QStylePainter::drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption &opt)
-{
- wstyle->drawPrimitive(pe, &opt, this, widget);
-}
-
-void QStylePainter::drawControl(QStyle::ControlElement ce, const QStyleOption &opt)
-{
- wstyle->drawControl(ce, &opt, this, widget);
-}
-
-void QStylePainter::drawComplexControl(QStyle::ComplexControl cc, const QStyleOptionComplex &opt)
-{
- wstyle->drawComplexControl(cc, &opt, this, widget);
-}
-
-void QStylePainter::drawItemText(const QRect &r, int flags, const QPalette &pal, bool enabled,
- const QString &text, QPalette::ColorRole textRole)
-{
- wstyle->drawItemText(this, r, flags, pal, enabled, text, textRole);
-}
-
-void QStylePainter::drawItemPixmap(const QRect &r, int flags, const QPixmap &pixmap)
-{
- wstyle->drawItemPixmap(this, r, flags, pixmap);
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSTYLEPAINTER_H
diff --git a/src/gui/painting/qunifiedtoolbarsurface_mac.cpp b/src/gui/painting/qunifiedtoolbarsurface_mac.cpp
deleted file mode 100644
index 2fda6b9555..0000000000
--- a/src/gui/painting/qunifiedtoolbarsurface_mac.cpp
+++ /dev/null
@@ -1,265 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qunifiedtoolbarsurface_mac_p.h"
-#include <private/qt_cocoa_helpers_mac_p.h>
-#include <private/qbackingstore_p.h>
-#include <private/qmainwindowlayout_p.h>
-
-#include <QDebug>
-
-#ifdef QT_MAC_USE_COCOA
-
-QT_BEGIN_NAMESPACE
-
-QUnifiedToolbarSurface::QUnifiedToolbarSurface(QWidget *widget)
- : QRasterWindowSurface(widget, false), d_ptr(new QUnifiedToolbarSurfacePrivate)
-{
- d_ptr->image = 0;
- d_ptr->inSetGeometry = false;
-
- setGeometry(QRect(QPoint(0, 0), QSize(widget->width(), 100))); // FIXME: Fix height.
-}
-
-QUnifiedToolbarSurface::~QUnifiedToolbarSurface()
-{
- if (d_ptr->image)
- delete d_ptr->image;
-}
-
-QPaintDevice *QUnifiedToolbarSurface::paintDevice()
-{
- return &d_ptr->image->image;
-}
-
-void QUnifiedToolbarSurface::recursiveRedirect(QObject *object, QWidget *parent_toolbar, const QPoint &offset)
-{
- if (object != 0) {
- if (object->isWidgetType()) {
- QWidget *widget = qobject_cast<QWidget *>(object);
-
- // We redirect the painting only if the widget is in the same window
- // and is not a window in itself.
- if (!(widget->windowType() & Qt::Window)) {
- widget->d_func()->unifiedSurface = this;
- widget->d_func()->isInUnifiedToolbar = true;
- widget->d_func()->toolbar_offset = offset;
- widget->d_func()->toolbar_ancestor = parent_toolbar;
-
- for (int i = 0; i < object->children().size(); ++i) {
- recursiveRedirect(object->children().at(i), parent_toolbar, offset);
- }
- }
- }
- }
-}
-
-void QUnifiedToolbarSurface::insertToolbar(QWidget *toolbar, const QPoint &offset)
-{
- setGeometry(QRect(QPoint(0, 0), QSize(offset.x() + toolbar->width(), 100))); // FIXME
- recursiveRedirect(toolbar, toolbar, offset);
-}
-
-// We basically undo what we set in recursiveRedirect().
-void QUnifiedToolbarSurface::recursiveRemoval(QObject *object)
-{
- if (object != 0) {
- if (object->isWidgetType()) {
- QWidget *widget = qobject_cast<QWidget *>(object);
-
- // If it's a pop-up or something similar, we don't redirect it.
- if (widget->windowType() & Qt::Window)
- return;
-
- widget->d_func()->unifiedSurface = 0;
- widget->d_func()->isInUnifiedToolbar = false;
- widget->d_func()->toolbar_offset = QPoint();
- widget->d_func()->toolbar_ancestor = 0;
- }
-
- for (int i = 0; i < object->children().size(); ++i) {
- recursiveRemoval(object->children().at(i));
- }
- }
-}
-
-void QUnifiedToolbarSurface::removeToolbar(QToolBar *toolbar)
-{
- recursiveRemoval(toolbar);
-}
-
-void QUnifiedToolbarSurface::setGeometry(const QRect &rect)
-{
- QWindowSurface::setGeometry(rect);
- Q_D(QUnifiedToolbarSurface);
- d->inSetGeometry = true;
- if (d->image == 0 || d->image->width() < rect.width() || d->image->height() < rect.height())
- prepareBuffer(QImage::Format_ARGB32_Premultiplied, window());
- d->inSetGeometry = false;
-
- // FIXME: set unified toolbar height.
-}
-
-void QUnifiedToolbarSurface::beginPaint(const QRegion &rgn)
-{
- QPainter p(&d_ptr->image->image);
- p.setCompositionMode(QPainter::CompositionMode_Source);
- const QVector<QRect> rects = rgn.rects();
- const QColor blank = Qt::transparent;
- for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
- p.fillRect(*it, blank);
- }
-}
-
-void QUnifiedToolbarSurface::updateToolbarOffset(QWidget *widget)
-{
- QMainWindowLayout *mlayout = qobject_cast<QMainWindowLayout*> (widget->window()->layout());
- if (mlayout)
- mlayout->updateUnifiedToolbarOffset();
-}
-
-void QUnifiedToolbarSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
-{
- Q_UNUSED(region);
- Q_UNUSED(offset);
-
- this->flush(widget);
-}
-
-void QUnifiedToolbarSurface::flush(QWidget *widget)
-{
- Q_D(QUnifiedToolbarSurface);
-
- if (!d->image)
- return;
-
- if (widget->d_func()->flushRequested) {
- // We call display: directly to avoid flickering in the toolbar.
- qt_mac_display(widget);
- }
-}
-
-void QUnifiedToolbarSurface::prepareBuffer(QImage::Format format, QWidget *widget)
-{
- Q_D(QUnifiedToolbarSurface);
-
- int width = geometry().width();
- int height = 100; // FIXME
- if (d->image) {
- width = qMax(d->image->width(), width);
- height = qMax(d->image->height(), height);
- }
-
- if (width == 0 || height == 0) {
- delete d->image;
- d->image = 0;
- return;
- }
-
- QNativeImage *oldImage = d->image;
-
- d->image = new QNativeImage(width, height, format, false, widget);
-
- if (oldImage && d->inSetGeometry && hasStaticContents()) {
- // Make sure we use the const version of bits() (no detach).
- const uchar *src = const_cast<const QImage &>(oldImage->image).bits();
- uchar *dst = d->image->image.bits();
-
- const int srcBytesPerLine = oldImage->image.bytesPerLine();
- const int dstBytesPerLine = d->image->image.bytesPerLine();
- const int bytesPerPixel = oldImage->image.depth() >> 3;
-
- QRegion staticRegion(staticContents());
- // Make sure we're inside the boundaries of the old image.
- staticRegion &= QRect(0, 0, oldImage->image.width(), oldImage->image.height());
- const QVector<QRect> &rects = staticRegion.rects();
- const QRect *srcRect = rects.constData();
-
- // Copy the static content of the old image into the new one.
- int numRectsLeft = rects.size();
- do {
- const int bytesOffset = srcRect->x() * bytesPerPixel;
- const int dy = srcRect->y();
-
- // Adjust src and dst to point to the right offset.
- const uchar *s = src + dy * srcBytesPerLine + bytesOffset;
- uchar *d = dst + dy * dstBytesPerLine + bytesOffset;
- const int numBytes = srcRect->width() * bytesPerPixel;
-
- int numScanLinesLeft = srcRect->height();
- do {
- ::memcpy(d, s, numBytes);
- d += dstBytesPerLine;
- s += srcBytesPerLine;
- } while (--numScanLinesLeft);
-
- ++srcRect;
- } while (--numRectsLeft);
- }
-
- delete oldImage;
-}
-
-CGContextRef QUnifiedToolbarSurface::imageContext()
-{
- Q_D(QUnifiedToolbarSurface);
- return d->image->cg;
-}
-
-void QUnifiedToolbarSurface::renderToolbar(QWidget *widget, bool forceFlush)
-{
- QWidget *toolbar = widget->d_func()->toolbar_ancestor;
-
- updateToolbarOffset(toolbar);
- QRect beginPaintRect(toolbar->d_func()->toolbar_offset.x(), toolbar->d_func()->toolbar_offset.y(), toolbar->geometry().width(), toolbar->geometry().height());
- QRegion beginPaintRegion(beginPaintRect);
-
- beginPaint(beginPaintRegion);
- toolbar->render(paintDevice(), toolbar->d_func()->toolbar_offset, QRegion(toolbar->geometry()), QWidget::DrawChildren);
- toolbar->d_func()->flushRequested = true;
-
- if (forceFlush)
- flush(toolbar);
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_MAC_USE_COCOA
diff --git a/src/gui/painting/qunifiedtoolbarsurface_mac_p.h b/src/gui/painting/qunifiedtoolbarsurface_mac_p.h
deleted file mode 100644
index 6b1243e790..0000000000
--- a/src/gui/painting/qunifiedtoolbarsurface_mac_p.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QUNIFIEDTOOLBARSURFACE_MAC_P_H
-#define QUNIFIEDTOOLBARSURFACE_MAC_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <private/qwindowsurface_raster_p.h>
-#include <QWidget>
-#include <QToolBar>
-#include <private/qwidget_p.h>
-#include <private/qnativeimage_p.h>
-
-#ifdef QT_MAC_USE_COCOA
-
-QT_BEGIN_NAMESPACE
-
-class QNativeImage;
-
-//
-// This is the implementation of the unified toolbar on Mac OS X
-// with the graphics system raster.
-//
-// General idea:
-// -------------
-// We redirect the painting of widgets inside the unified toolbar
-// to a special window surface, the QUnifiedToolbarSurface.
-// We need a separate window surface because the unified toolbar
-// is out of the content view.
-// The input system is the same as for the unified toolbar with the
-// native (CoreGraphics) engine.
-//
-// Execution flow:
-// ---------------
-// The unified toolbar is triggered by QMainWindow::setUnifiedTitleAndToolBarOnMac().
-// It calls QMainWindowLayout::insertIntoMacToolbar() which will
-// set all the appropriate variables (offsets, redirection, ...).
-// When Qt tells a widget to repaint, QWidgetPrivate::drawWidget()
-// checks if the widget is inside the unified toolbar and exits without
-// painting is that is the case.
-// We trigger the rendering of the unified toolbar in QWidget::repaint()
-// and QWidget::update().
-// We keep track of flush requests via "flushRequested" variable. That
-// allow flush() to be a no-op if no repaint occured for a widget.
-// We rely on the needsDisplay: and drawRect: mecanism for drawing our
-// content into the graphics context.
-//
-// Notes:
-// ------
-// The painting of items inside the unified toolbar is expensive.
-// Too many repaints will drastically slow down the whole application.
-//
-
-class QUnifiedToolbarSurfacePrivate
-{
-public:
- QNativeImage *image;
- uint inSetGeometry : 1;
-};
-
-class Q_GUI_EXPORT QUnifiedToolbarSurface : public QRasterWindowSurface
-{
-public:
- QUnifiedToolbarSurface(QWidget *widget);
- ~QUnifiedToolbarSurface();
-
- void flush(QWidget *widget);
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
- void setGeometry(const QRect &rect);
- void beginPaint(const QRegion &rgn);
- void insertToolbar(QWidget *toolbar, const QPoint &offset);
- void removeToolbar(QToolBar *toolbar);
- void updateToolbarOffset(QWidget *widget);
- void renderToolbar(QWidget *widget, bool forceFlush = false);
- void recursiveRedirect(QObject *widget, QWidget *parent_toolbar, const QPoint &offset);
-
- QPaintDevice *paintDevice();
- CGContextRef imageContext();
-
-private:
- void prepareBuffer(QImage::Format format, QWidget *widget);
- void recursiveRemoval(QObject *object);
-
- Q_DECLARE_PRIVATE(QUnifiedToolbarSurface)
- QScopedPointer<QUnifiedToolbarSurfacePrivate> d_ptr;
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_MAC_USE_COCOA
-
-#endif // QUNIFIEDTOOLBARSURFACE_MAC_P_H
diff --git a/src/gui/painting/qwindowsurface.cpp b/src/gui/painting/qwindowsurface.cpp
index 0fb9bf78a9..13d152175d 100644
--- a/src/gui/painting/qwindowsurface.cpp
+++ b/src/gui/painting/qwindowsurface.cpp
@@ -40,29 +40,26 @@
****************************************************************************/
#include <private/qwindowsurface_p.h>
-#include <qwidget.h>
-#include <private/qwidget_p.h>
-#include <private/qbackingstore_p.h>
-#include <private/qapplication_p.h>
+#include <qwindow.h>
+#include <private/qwindow_p.h>
QT_BEGIN_NAMESPACE
class QWindowSurfacePrivate
{
public:
- QWindowSurfacePrivate(QWidget *w)
+ QWindowSurfacePrivate(QWindow *w)
: window(w)
{
}
- QWidget *window;
+ QWindow *window;
#if !defined(Q_WS_QPA)
QRect geometry;
#else
QSize size;
#endif //Q_WS_QPA
QRegion staticContents;
- QList<QImage*> bufferImages;
};
/*!
@@ -96,10 +93,10 @@ public:
*/
/*!
- \fn void QWindowSurface::flush(QWidget *widget, const QRegion &region,
+ \fn void QWindowSurface::flush(QWindow *window, const QRegion &region,
const QPoint &offset)
- Flushes the given \a region from the specified \a widget onto the
+ Flushes the given \a region from the specified \a window onto the
screen.
Note that the \a offset parameter is currently unused.
@@ -114,13 +111,11 @@ public:
/*!
Constructs an empty surface for the given top-level \a window.
*/
-QWindowSurface::QWindowSurface(QWidget *window, bool setDefaultSurface)
+QWindowSurface::QWindowSurface(QWindow *window, bool /*setDefaultSurface*/)
: d_ptr(new QWindowSurfacePrivate(window))
{
- if (!QApplicationPrivate::runtime_graphics_system) {
- if(setDefaultSurface && window)
- window->setWindowSurface(this);
- }
+ if (window)
+ window->d_func()->surface = this;
}
/*!
@@ -128,8 +123,8 @@ QWindowSurface::QWindowSurface(QWidget *window, bool setDefaultSurface)
*/
QWindowSurface::~QWindowSurface()
{
- if (d_ptr->window)
- d_ptr->window->d_func()->extra->topextra->windowSurface = 0;
+// if (d_ptr->window)
+// d_ptr->window->d_func()->extra->topextra->windowSurface = 0;
delete d_ptr;
}
@@ -137,7 +132,7 @@ QWindowSurface::~QWindowSurface()
Returns a pointer to the top-level window associated with this
surface.
*/
-QWidget* QWindowSurface::window() const
+QWindow* QWindowSurface::window() const
{
return d_ptr->window;
}
@@ -148,9 +143,6 @@ void QWindowSurface::beginPaint(const QRegion &)
void QWindowSurface::endPaint(const QRegion &)
{
-// QApplication::syncX();
- qDeleteAll(d_ptr->bufferImages);
- d_ptr->bufferImages.clear();
}
#if !defined(Q_WS_QPA)
@@ -211,67 +203,35 @@ bool QWindowSurface::scroll(const QRegion &area, int dx, int dy)
}
/*!
- Returns a QImage pointer which represents the actual buffer the \a widget
- is drawn into or 0 if this is unavailable.
-
- You must call beginPaint() before you call this function and the returned
- pointer is only valid until endPaint() is called.
-*/
-QImage* QWindowSurface::buffer(const QWidget *widget)
-{
- if (widget->window() != window())
- return 0;
-
- QPaintDevice *pdev = paintDevice();
- if (!pdev || pdev->devType() != QInternal::Image)
- return 0;
-
- const QPoint off = offset(widget);
- QImage *img = static_cast<QImage*>(pdev);
-
- QRect rect(off, widget->size());
- rect &= QRect(QPoint(), img->size());
-
- if (rect.isEmpty())
- return 0;
-
- img = new QImage(img->scanLine(rect.y()) + rect.x() * img->depth() / 8,
- rect.width(), rect.height(),
- img->bytesPerLine(), img->format());
- d_ptr->bufferImages.append(img);
-
- return img;
-}
-
-/*!
Returns a QPixmap generated from the part of the backing store
- corresponding to \a widget. Returns a null QPixmap if an error
+ corresponding to \a window. Returns a null QPixmap if an error
occurs. The contents of the pixmap are only defined for the regions
- of \a widget that have received paint events since the last resize
+ of \a window that have received paint events since the last resize
of the backing store.
- If \a rectangle is a null rectangle (the default), the entire widget
+ If \a rectangle is a null rectangle (the default), the entire window
is grabbed. Otherwise, the grabbed area is limited to \a rectangle.
The default implementation uses QWindowSurface::buffer().
- \sa QPixmap::grabWidget()
+ \sa QPixmap::grabWindow()
*/
-QPixmap QWindowSurface::grabWidget(const QWidget *widget, const QRect &rectangle) const
+QPixmap QWindowSurface::grabWindow(const QWindow *, const QRect &) const
{
QPixmap result;
- if (widget->window() != window())
+#if 0
+ if (window->window() != window())
return result;
- const QImage *img = const_cast<QWindowSurface *>(this)->buffer(widget->window());
+ const QImage *img = const_cast<QWindowSurface *>(this)->buffer(window->window());
if (!img || img->isNull())
return result;
- QRect rect = rectangle.isEmpty() ? widget->rect() : (widget->rect() & rectangle);
+ QRect rect = rectangle.isEmpty() ? window->rect() : (window->rect() & rectangle);
- rect.translate(offset(widget) - offset(widget->window()));
+ rect.translate(offset(window) - offset(window->window()));
rect &= QRect(QPoint(), img->size());
if (rect.isEmpty())
@@ -283,27 +243,28 @@ QPixmap QWindowSurface::grabWidget(const QWidget *widget, const QRect &rectangle
subimg.detach(); //### expensive -- maybe we should have a real SubImage that shares reference count
result = QPixmap::fromImage(subimg);
+#endif
return result;
}
/*!
- Returns the offset of \a widget in the coordinates of this
+ Returns the offset of \a window in the coordinates of this
window surface.
*/
-QPoint QWindowSurface::offset(const QWidget *widget) const
+QPoint QWindowSurface::offset(const QWindow *) const
{
- QWidget *window = d_ptr->window;
- QPoint offset = widget->mapTo(window, QPoint());
-#ifdef Q_WS_QWS
- offset += window->geometry().topLeft() - window->frameGeometry().topLeft();
+ QPoint offset;
+#if 0
+ QWindow *window = d_ptr->window;
+ QPoint offset = window->mapTo(window, QPoint());
#endif
return offset;
}
/*!
- \fn QRect QWindowSurface::rect(const QWidget *widget) const
+ \fn QRect QWindowSurface::rect(const QWindow *window) const
- Returns the rectangle for \a widget in the coordinates of this
+ Returns the rectangle for \a window in the coordinates of this
window surface.
*/
diff --git a/src/gui/painting/qwindowsurface_mac.cpp b/src/gui/painting/qwindowsurface_mac.cpp
deleted file mode 100644
index 620a50f3ea..0000000000
--- a/src/gui/painting/qwindowsurface_mac.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwindowsurface_mac_p.h"
-
-#include <private/qt_mac_p.h>
-#include <private/qt_cocoa_helpers_mac_p.h>
-#include <QtGui/qwidget.h>
-
-QT_BEGIN_NAMESPACE
-
-struct QMacWindowSurfacePrivate
-{
- QWidget *widget;
- QPixmap device;
-};
-
-QMacWindowSurface::QMacWindowSurface(QWidget *widget)
- : QWindowSurface(widget), d_ptr(new QMacWindowSurfacePrivate)
-{
- d_ptr->widget = widget;
-}
-
-QMacWindowSurface::~QMacWindowSurface()
-{
- delete d_ptr;
-}
-
-QPaintDevice *QMacWindowSurface::paintDevice()
-{
- return &d_ptr->device;
-}
-
-void QMacWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &offset)
-{
- Q_UNUSED(offset);
-
- // Get a context for the widget.
-#ifndef QT_MAC_USE_COCOA
- CGContextRef context;
- CGrafPtr port = GetWindowPort(qt_mac_window_for(widget));
- QDBeginCGContext(port, &context);
-#else
- extern CGContextRef qt_mac_graphicsContextFor(QWidget *);
- CGContextRef context = qt_mac_graphicsContextFor(widget);
-#endif
- CGContextRetain(context);
- CGContextSaveGState(context);
-
- // Flip context.
- CGContextTranslateCTM(context, 0, widget->height());
- CGContextScaleCTM(context, 1, -1);
-
- // Clip to region.
- const QVector<QRect> &rects = rgn.rects();
- for (int i = 0; i < rects.size(); ++i) {
- const QRect &rect = rects.at(i);
- CGContextAddRect(context, CGRectMake(rect.x(), rect.y(), rect.width(), rect.height()));
- }
- CGContextClip(context);
-
- // Draw the image onto the window.
- const CGRect dest = CGRectMake(0, 0, widget->width(), widget->height());
- const CGImageRef image = d_ptr->device.toMacCGImageRef();
- qt_mac_drawCGImage(context, &dest, image);
- CFRelease(image);
-
- // Restore context.
- CGContextRestoreGState(context);
-#ifndef QT_MAC_USE_COCOA
- QDEndCGContext(port, &context);
-#else
- CGContextFlush(context);
-#endif
- CGContextRelease(context);
-}
-
-void QMacWindowSurface::setGeometry(const QRect &rect)
-{
- QWindowSurface::setGeometry(rect);
- const QSize size = rect.size();
- if (d_ptr->device.size() != size)
- d_ptr->device = QPixmap(size);
-}
-
-bool QMacWindowSurface::scroll(const QRegion &area, int dx, int dy)
-{
- if (d_ptr->device.size().isNull())
- return false;
-
- QCFType<CGImageRef> image = d_ptr->device.toMacCGImageRef();
- const QRect rect(area.boundingRect());
- const CGRect dest = CGRectMake(rect.x(), rect.y(), rect.width(), rect.height());
- QCFType<CGImageRef> subimage = CGImageCreateWithImageInRect(image, dest);
- QCFType<CGContextRef> context = qt_mac_cg_context(&d_ptr->device);
- CGContextTranslateCTM(context, dx, dy);
- qt_mac_drawCGImage(context, &dest, subimage);
- return true;
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qwindowsurface_mac_p.h b/src/gui/painting/qwindowsurface_mac_p.h
deleted file mode 100644
index fd68b1fe91..0000000000
--- a/src/gui/painting/qwindowsurface_mac_p.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSURFACE_MAC_P_H
-#define QWINDOWSURFACE_MAC_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <qglobal.h>
-#include "private/qwindowsurface_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QPaintDevice;
-class QPoint;
-class QRegion;
-class QWidget;
-struct QMacWindowSurfacePrivate;
-
-class QMacWindowSurface : public QWindowSurface
-{
-public:
- QMacWindowSurface(QWidget *widget);
- ~QMacWindowSurface();
-
- QPaintDevice *paintDevice();
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
- void setGeometry(const QRect &rect);
- bool scroll(const QRegion &area, int dx, int dy);
-
-private:
- QMacWindowSurfacePrivate *d_ptr;
-};
-
-QT_END_NAMESPACE
-
-#endif // QWINDOWSURFACE_MAC_P_H
diff --git a/src/gui/painting/qwindowsurface_p.h b/src/gui/painting/qwindowsurface_p.h
index a3fea67f24..835aae77d4 100644
--- a/src/gui/painting/qwindowsurface_p.h
+++ b/src/gui/painting/qwindowsurface_p.h
@@ -53,7 +53,7 @@
// We mean it.
//
-#include <QtGui/qwidget.h>
+#include <QtGui/qwindow.h>
QT_BEGIN_NAMESPACE
@@ -76,18 +76,18 @@ public:
};
Q_DECLARE_FLAGS(WindowSurfaceFeatures, WindowSurfaceFeature)
- QWindowSurface(QWidget *window, bool setDefaultSurface = true);
+ QWindowSurface(QWindow *window, bool setDefaultSurface = true);
virtual ~QWindowSurface();
- QWidget *window() const;
+ QWindow *window() const;
virtual QPaintDevice *paintDevice() = 0;
- // 'widget' can be a child widget, in which case 'region' is in child widget coordinates and
- // offset is the (child) widget's offset in relation to the window surface. On QWS, 'offset'
- // can be larger than just the offset from the top-level widget as there may also be window
+ // 'window' can be a child window, in which case 'region' is in child window coordinates and
+ // offset is the (child) window's offset in relation to the window surface. On QWS, 'offset'
+ // can be larger than just the offset from the top-level window as there may also be window
// decorations which are painted into the window surface.
- virtual void flush(QWidget *widget, const QRegion &region, const QPoint &offset) = 0;
+ virtual void flush(QWindow *window, const QRegion &region, const QPoint &offset) = 0;
#if !defined(Q_WS_QPA)
virtual void setGeometry(const QRect &rect);
QRect geometry() const;
@@ -102,11 +102,10 @@ public:
virtual void beginPaint(const QRegion &);
virtual void endPaint(const QRegion &);
- virtual QImage* buffer(const QWidget *widget);
- virtual QPixmap grabWidget(const QWidget *widget, const QRect& rectangle = QRect()) const;
+ virtual QPixmap grabWindow(const QWindow *window, const QRect& rectangle = QRect()) const;
- virtual QPoint offset(const QWidget *widget) const;
- inline QRect rect(const QWidget *widget) const;
+ virtual QPoint offset(const QWindow *window) const;
+ inline QRect rect(const QWindow *window) const;
bool hasFeature(WindowSurfaceFeature feature) const;
virtual WindowSurfaceFeatures features() const;
@@ -123,9 +122,9 @@ private:
Q_DECLARE_OPERATORS_FOR_FLAGS(QWindowSurface::WindowSurfaceFeatures)
-inline QRect QWindowSurface::rect(const QWidget *widget) const
+inline QRect QWindowSurface::rect(const QWindow *window) const
{
- return widget->rect().translated(offset(widget));
+ return window->geometry().translated(offset(window));
}
inline bool QWindowSurface::hasFeature(WindowSurfaceFeature feature) const
diff --git a/src/gui/painting/qwindowsurface_qws.cpp b/src/gui/painting/qwindowsurface_qws.cpp
deleted file mode 100644
index cb293cb135..0000000000
--- a/src/gui/painting/qwindowsurface_qws.cpp
+++ /dev/null
@@ -1,1433 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwindowsurface_qws_p.h"
-#include <qwidget.h>
-#include <qscreen_qws.h>
-#include <qwsmanager_qws.h>
-#include <qapplication.h>
-#include <qwsdisplay_qws.h>
-#include <qrgb.h>
-#include <qpaintengine.h>
-#include <qdesktopwidget.h>
-#include <private/qapplication_p.h>
-#include <private/qwsdisplay_qws_p.h>
-#include <private/qwidget_p.h>
-#include <private/qwsmanager_p.h>
-#include <private/qwslock_p.h>
-#include <private/qbackingstore_p.h>
-#include <stdio.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifdef Q_BACKINGSTORE_SUBSURFACES
-
-typedef QMap<int, QWSWindowSurface*> SurfaceMap;
-Q_GLOBAL_STATIC(SurfaceMap, winIdToSurfaceMap);
-
-QWSWindowSurface* qt_findWindowSurface(int winId)
-{
- return winIdToSurfaceMap()->value(winId);
-}
-
-static void qt_insertWindowSurface(int winId, QWSWindowSurface *surface)
-{
- if (!surface)
- winIdToSurfaceMap()->remove(winId);
- else
- winIdToSurfaceMap()->insert(winId, surface);
-}
-
-#endif // Q_BACKINGSTORE_SUBSURFACES
-
-inline bool isWidgetOpaque(const QWidget *w)
-{
- return w->d_func()->isOpaque && !w->testAttribute(Qt::WA_TranslucentBackground);
-}
-
-static inline QScreen *getScreen(const QWidget *w)
-{
- const QList<QScreen*> subScreens = qt_screen->subScreens();
- if (subScreens.isEmpty())
- return qt_screen;
-
- const int screen = QApplication::desktop()->screenNumber(w);
-
- return qt_screen->subScreens().at(screen < 0 ? 0 : screen);
-}
-
-static int bytesPerPixel(QImage::Format format)
-{
- switch (format) {
- case QImage::Format_Invalid:
- return 0;
-#ifndef QT_NO_DEBUG
- case QImage::Format_Mono:
- case QImage::Format_MonoLSB:
- qFatal("QWSWindowSurface: Invalid backingstore format: %i",
- int(format));
-#endif
- case QImage::Format_Indexed8:
- return 1;
- case QImage::Format_RGB32:
- case QImage::Format_ARGB32:
- case QImage::Format_ARGB32_Premultiplied:
- return 4;
- case QImage::Format_RGB16:
- case QImage::Format_RGB555:
- case QImage::Format_RGB444:
- case QImage::Format_ARGB4444_Premultiplied:
- return 2;
- case QImage::Format_ARGB8565_Premultiplied:
- case QImage::Format_ARGB8555_Premultiplied:
- case QImage::Format_ARGB6666_Premultiplied:
- case QImage::Format_RGB666:
- case QImage::Format_RGB888:
- return 3;
- default:
-#ifndef QT_NO_DEBUG
- qFatal("QWSWindowSurface: Invalid backingstore format: %i",
- int(format));
-#endif
- return 0;
- }
-}
-
-static inline int nextMulOf4(int n)
-{
- return ((n + 3) & 0xfffffffc);
-}
-
-static inline void setImageMetrics(QImage &img, QWidget *window) {
- QScreen *myScreen = getScreen(window);
- if (myScreen) {
- int dpmx = myScreen->width()*1000 / myScreen->physicalWidth();
- int dpmy = myScreen->height()*1000 / myScreen->physicalHeight();
- img.setDotsPerMeterX(dpmx);
- img.setDotsPerMeterY(dpmy);
- }
-}
-
-void QWSWindowSurface::invalidateBuffer()
-{
-
- QWidget *win = window();
- if (win) {
- win->d_func()->invalidateBuffer(win->rect());
-#ifndef QT_NO_QWS_MANAGER
- QTLWExtra *topextra = win->d_func()->extra->topextra;
- QWSManager *manager = topextra->qwsManager;
- if (manager)
- manager->d_func()->dirtyRegion(QDecoration::All,
- QDecoration::Normal);
-#endif
- }
-}
-
-QWSWindowSurfacePrivate::QWSWindowSurfacePrivate()
- : flags(0),
-#ifdef QT_QWS_CLIENTBLIT
- directId(-1),
-#endif
- winId(0)
-{
-}
-
-void QWSWindowSurfacePrivate::setWinId(int id)
-{
- winId = id;
-}
-
-int QWSWindowSurface::winId() const
-{
- // XXX: the widget winId may change during the lifetime of the widget!!!
-
- const QWidget *win = window();
- if (win && win->isWindow())
- return win->internalWinId();
-
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- if (!d_ptr->winId) {
- QWSWindowSurface *that = const_cast<QWSWindowSurface*>(this);
- QWSDisplay *display = QWSDisplay::instance();
- const int id = display->takeId();
- qt_insertWindowSurface(id, that);
- that->d_ptr->winId = id;
-
- if (win)
- display->nameRegion(id, win->objectName(), win->windowTitle());
- else
- display->nameRegion(id, QString(), QString());
-
- display->setAltitude(id, 1, true); // XXX
- }
-#endif
-
- return d_ptr->winId;
-}
-
-void QWSWindowSurface::setWinId(int id)
-{
- d_ptr->winId = id;
-}
-
-/*!
- \class QWSWindowSurface
- \since 4.2
- \ingroup qws
- \preliminary
- \internal
-
- \brief The QWSWindowSurface class provides the drawing area for top-level
- windows in Qt for Embedded Linux.
-
- Note that this class is only available in Qt for Embedded Linux.
-
- In \l{Qt for Embedded Linux}, the default behavior is for each client to
- render its widgets into memory while the server is responsible for
- putting the contents of the memory onto the
- screen. QWSWindowSurface is used by the window system to implement
- the associated memory allocation.
-
- When a screen update is required, the server runs through all the
- top-level windows that intersect with the region that is about to
- be updated, and ensures that the associated clients have updated
- their memory buffer. Then the server uses the screen driver to
- copy the content of the memory to the screen. To locate the
- relevant parts of memory, the driver is provided with the list of
- top-level windows that intersect with the given region. Associated
- with each of the top-level windows there is a window surface
- representing the drawing area of the window.
-
- When deriving from the QWSWindowSurface class, e.g., when adding
- an \l {Adding an Accelerated Graphics Driver to Qt for Embedded Linux}
- {accelerated graphics driver}, there are several pure virtual
- functions that must be implemented. In addition, QWSWindowSurface
- provides several virtual functions that can be reimplemented to
- customize the drawing process.
-
- \tableofcontents
-
- \section1 Pure Virtual Functions
-
- There are in fact two window surface instances for each top-level
- window; one used by the application when drawing a window, and
- another used by the server application to perform window
- compositioning. Implement the attach() to create the server-side
- representation of the surface. The data() function must be
- implemented to provide the required data.
-
- Implement the key() function to uniquely identify the surface
- class, and the isValid() function to determine is a surface
- corresponds to a given widget.
-
- The geometry() function must be implemented to let the window
- system determine the area required by the window surface
- (QWSWindowSurface also provides a corresponding virtual
- setGeometry() function that is called whenever the area necessary
- for the top-level window to be drawn, changes). The image()
- function is called by the window system during window
- compositioning, and must be implemented to return an image of the
- top-level window.
-
- Finally, the paintDevice() function must be implemented to return
- the appropriate paint device, and the scroll() function must be
- implemented to scroll the given region of the surface the given
- number of pixels.
-
- \section1 Virtual Functions
-
- When painting onto the surface, the window system will always call
- the beginPaint() function before any painting operations are
- performed. Likewise the endPaint() function is automatically
- called when the painting is done. Reimplement the painterOffset()
- function to alter the offset that is applied when drawing.
-
- The window system uses the flush() function to put a given region
- of the widget onto the screen, and the release() function to
- deallocate the screen region corresponding to this window surface.
-
- \section1 Other Members
-
- QWSWindowSurface provides the window() function returning a
- pointer to the top-level window the surface is representing. The
- currently visible region of the associated widget can be retrieved
- and set using the clipRegion() and setClipRegion() functions,
- respectively.
-
- When the window system performs the window compositioning, it uses
- the SurfaceFlag enum describing the surface content. The currently
- set surface flags can be retrieved and altered using the
- surfaceFlags() and setSurfaceFlags() functions. In addition,
- QWSWindowSurface provides the isBuffered(), isOpaque() and
- isRegionReserved() convenience functions.
-
- \sa {Qt for Embedded Linux Architecture#Drawing on Screen}{Qt for
- Embedded Linux Architecture}
-*/
-
-/*!
- \enum QWSWindowSurface::SurfaceFlag
-
- This enum is used to describe the window surface's contents. It
- is used by the screen driver to handle region allocation and
- composition.
-
- \value RegionReserved The surface contains a reserved area. Once
- allocated, a reserved area can not not be changed by the window
- system, i.e., no other widgets can be drawn on top of this.
-
- \value Buffered
- The surface is in a memory area which is not part of a framebuffer.
- (A top-level window with QWidget::windowOpacity() other than 1.0 must use
- a buffered surface in order to making blending with the background work.)
-
- \value Opaque
- The surface contains only opaque pixels.
-
- \sa surfaceFlags(), setSurfaceFlags()
-*/
-
-/*!
- \fn bool QWSWindowSurface::isValid() const
- \since 4.3
-
- Implement this function to return true if the surface is a valid
- surface for the given top-level \a window; otherwise return
- false.
-
- \sa window(), key()
-*/
-
-/*!
- \fn QString QWSWindowSurface::key() const
-
- Implement this function to return a string that uniquely
- identifies the class of this surface.
-
- \sa window(), isValid()
-*/
-
-/*!
- \fn QByteArray QWSWindowSurface::permanentState() const
- \since 4.3
-
- Implement this function to return the data required for creating a
- server-side representation of the surface.
-
- \sa attach()
-*/
-
-/*!
- \fn void QWSWindowSurface::setPermanentState(const QByteArray &data)
- \since 4.3
-
- Implement this function to attach a server-side surface instance
- to the corresponding client side instance using the given \a
- data. Return true if successful; otherwise return false.
-
- \sa data()
-*/
-
-/*!
- \fn const QImage QWSWindowSurface::image() const
-
- Implement this function to return an image of the top-level window.
-
- \sa geometry()
-*/
-
-/*!
- \fn bool QWSWindowSurface::isRegionReserved() const
-
- Returns true if the QWSWindowSurface::RegionReserved is set; otherwise
- returns false.
-
- \sa surfaceFlags()
-*/
-
-/*!
- \fn bool QWSWindowSurface::isBuffered() const
-
- Returns true if the QWSWindowSurface::Buffered is set; otherwise returns false.
-
- \sa surfaceFlags()
-*/
-
-/*!
- \fn bool QWSWindowSurface::isOpaque() const
-
- Returns true if the QWSWindowSurface::Opaque is set; otherwise
- returns false.
-
- \sa surfaceFlags()
-*/
-
-
-/*!
- Constructs an empty surface.
-*/
-QWSWindowSurface::QWSWindowSurface()
- : QWindowSurface(0), d_ptr(new QWSWindowSurfacePrivate)
-{
-}
-
-/*!
- Constructs an empty surface for the given top-level \a widget.
-*/
-QWSWindowSurface::QWSWindowSurface(QWidget *widget)
- : QWindowSurface(widget), d_ptr(new QWSWindowSurfacePrivate)
-{
-}
-
-QWSWindowSurface::~QWSWindowSurface()
-{
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- if (d_ptr->winId)
- winIdToSurfaceMap()->remove(d_ptr->winId);
-#endif
-
- delete d_ptr;
-}
-
-/*!
- Returns the offset to be used when painting.
-
- \sa paintDevice()
-*/
-QPoint QWSWindowSurface::painterOffset() const
-{
- const QWidget *w = window();
- if (!w)
- return QPoint();
- return w->geometry().topLeft() - w->frameGeometry().topLeft();
-}
-
-void QWSWindowSurface::beginPaint(const QRegion &)
-{
- lock();
-}
-
-void QWSWindowSurface::endPaint(const QRegion &)
-{
- unlock();
-}
-
-// XXX: documentation!!!
-QByteArray QWSWindowSurface::transientState() const
-{
- return QByteArray();
-}
-
-QByteArray QWSWindowSurface::permanentState() const
-{
- return QByteArray();
-}
-
-void QWSWindowSurface::setTransientState(const QByteArray &state)
-{
- Q_UNUSED(state);
-}
-
-void QWSWindowSurface::setPermanentState(const QByteArray &state)
-{
- Q_UNUSED(state);
-}
-
-bool QWSWindowSurface::lock(int timeout)
-{
- Q_UNUSED(timeout);
- return true;
-}
-
-void QWSWindowSurface::unlock()
-{
-}
-
-#ifdef QT_QWS_CLIENTBLIT
-/*! \internal */
-const QRegion QWSWindowSurface::directRegion() const
-{
- return d_ptr->direct;
-}
-
-/*! \internal */
-int QWSWindowSurface::directRegionId() const
-{
- return d_ptr->directId;
-}
-
-/*! \internal */
-void QWSWindowSurface::setDirectRegion(const QRegion &r, int id)
-{
- d_ptr->direct = r;
- d_ptr->directId = id;
-}
-#endif
-
-/*!
- Returns the region currently visible on the screen.
-
- \sa setClipRegion()
-*/
-const QRegion QWSWindowSurface::clipRegion() const
-{
- return d_ptr->clip;
-}
-
-/*!
- Sets the region currently visible on the screen to be the given \a
- clip region.
-
- \sa clipRegion()
-*/
-void QWSWindowSurface::setClipRegion(const QRegion &clip)
-{
- if (clip == d_ptr->clip)
- return;
-
- QRegion expose = (clip - d_ptr->clip);
- d_ptr->clip = clip;
-
- if (expose.isEmpty() || clip.isEmpty())
- return; // No repaint or flush required.
-
- QWidget *win = window();
- if (!win)
- return;
-
- if (isBuffered()) {
- // No repaint required. Flush exposed area via the backing store.
- win->d_func()->syncBackingStore(expose);
- return;
- }
-
-#ifndef QT_NO_QWS_MANAGER
- // Invalidate exposed decoration area.
- if (win && win->isWindow()) {
- QTLWExtra *topextra = win->d_func()->extra->topextra;
- if (QWSManager *manager = topextra->qwsManager) {
- QRegion decorationExpose(manager->region());
- decorationExpose.translate(-win->geometry().topLeft());
- decorationExpose &= expose;
- if (!decorationExpose.isEmpty()) {
- expose -= decorationExpose;
- manager->d_func()->dirtyRegion(QDecoration::All, QDecoration::Normal, decorationExpose);
- }
- }
- }
-#endif
-
- // Invalidate exposed widget area.
- win->d_func()->invalidateBuffer(expose);
-}
-
-/*!
- Returns the surface flags describing the contents of this surface.
-
- \sa isBuffered(), isOpaque(), isRegionReserved()
-*/
-QWSWindowSurface::SurfaceFlags QWSWindowSurface::surfaceFlags() const
-{
- return d_ptr->flags;
-}
-
-/*!
- Sets the surface flags describing the contents of this surface, to
- be the given \a flags.
-
- \sa surfaceFlags()
-*/
-void QWSWindowSurface::setSurfaceFlags(SurfaceFlags flags)
-{
- d_ptr->flags = flags;
-}
-
-void QWSWindowSurface::setGeometry(const QRect &rect)
-{
- QRegion mask = rect;
-
- const QWidget *win = window();
- if (win) {
-#ifndef QT_NO_QWS_MANAGER
- if (win->isWindow()) {
- QTLWExtra *topextra = win->d_func()->extra->topextra;
- QWSManager *manager = topextra->qwsManager;
-
- if (manager) {
- // The frame geometry is the bounding rect of manager->region,
- // which could be too much, so we need to clip.
- mask &= (manager->region() + win->geometry());
- }
- }
-#endif
-
- const QRegion winMask = win->mask();
- if (!winMask.isEmpty())
- mask &= winMask.translated(win->geometry().topLeft());
- }
-
- setGeometry(rect, mask);
-}
-
-void QWSWindowSurface::setGeometry(const QRect &rect, const QRegion &mask)
-{
- if (rect == geometry()) // XXX: && mask == prevMask
- return;
-
- const bool isResize = rect.size() != geometry().size();
- const bool needsRepaint = isResize || !isBuffered();
-
- QWindowSurface::setGeometry(rect);
-
- const QRegion region = mask & rect;
- QWidget *win = window();
- // Only request regions for widgets visible on the screen.
- // (Added the !win check for compatibility reasons, because
- // there was no "if (win)" check before).
- const bool requestQWSRegion = !win || !win->testAttribute(Qt::WA_DontShowOnScreen);
- if (requestQWSRegion)
- QWidget::qwsDisplay()->requestRegion(winId(), key(), permanentState(), region);
-
- if (needsRepaint)
- invalidateBuffer();
-
- if (!requestQWSRegion) {
- // We didn't request a region, hence we won't get a QWSRegionEvent::Allocation
- // event back from the server so we set the clip directly. We have to
- // do this after the invalidateBuffer() call above, as it might trigger a
- // backing store sync, resulting in too many update requests.
- setClipRegion(region);
- }
-}
-
-static inline void flushUpdate(QWidget *widget, const QRegion &region,
- const QPoint &offset)
-{
-#ifdef QT_NO_PAINT_DEBUG
- Q_UNUSED(widget);
- Q_UNUSED(region);
- Q_UNUSED(offset);
-#else
- static int delay = -1;
-
- if (delay == -1)
- delay = qgetenv("QT_FLUSH_UPDATE").toInt() * 10;
-
- if (delay == 0)
- return;
-
- static QWSYellowSurface surface(true);
- surface.setDelay(delay);
- surface.flush(widget, region, offset);
-#endif // QT_NO_PAINT_DEBUG
-}
-
-void QWSWindowSurface::flush(QWidget *widget, const QRegion &region,
- const QPoint &offset)
-{
- const QWidget *win = window();
- if (!win)
- return;
-
-#ifndef QT_NO_GRAPHICSVIEW
- QWExtra *extra = win->d_func()->extra;
- if (extra && extra->proxyWidget)
- return;
-#endif //QT_NO_GRAPHICSVIEW
-
- Q_UNUSED(offset);
-
- const bool opaque = isOpaque();
-#ifdef QT_QWS_DISABLE_FLUSHCLIPPING
- QRegion toFlush = region;
-#else
- QRegion toFlush = region & d_ptr->clip;
-#endif
-
- if (!toFlush.isEmpty()) {
- flushUpdate(widget, toFlush, QPoint(0, 0));
- QPoint globalZero = win->mapToGlobal(QPoint(0, 0));
- toFlush.translate(globalZero);
-
-#ifdef QT_QWS_CLIENTBLIT
- bool needRepaint = true;
- if (opaque) {
- QScreen* widgetScreen = getScreen(widget);
- if (widgetScreen->supportsBlitInClients()) {
-
- QWSDisplay::grab();
- if(directRegion().intersected(toFlush) == toFlush) {
- QPoint translate = -globalZero + painterOffset() + geometry().topLeft();
- QRegion flushRegion = toFlush.translated(translate);
- widgetScreen->blit(image(), geometry().topLeft(), flushRegion);
- widgetScreen->setDirty(toFlush.boundingRect());
- needRepaint = false;
- }
- QWSDisplay::ungrab();
- }
- }
-
- if(needRepaint)
-#endif
- win->qwsDisplay()->repaintRegion(winId(), win->windowFlags(), opaque, toFlush);
- }
-}
-
-/*!
- Move the surface with the given \a offset.
-
- A subclass may reimplement this function to enable accelerated window move.
- It must return true if the move was successful and no repaint is necessary,
- false otherwise.
-
- The default implementation updates the QWindowSurface geometry and
- returns true if the surface is buffered; false otherwise.
-
- This function is called by the window system on the client instance.
-
- \sa isBuffered()
-*/
-bool QWSWindowSurface::move(const QPoint &offset)
-{
- QWindowSurface::setGeometry(geometry().translated(offset));
- return isBuffered();
-}
-
-/*!
- Move the surface with the given \a offset.
-
- The new visible region after the window move is given by \a newClip
- in screen coordinates.
-
- A subclass may reimplement this function to enable accelerated window move.
- The returned region indicates the area that still needs to be composed
- on the screen.
-
- The default implementation updates the QWindowSurface geometry and
- returns the union of the old and new geometry.
-
- This function is called by the window system on the server instance.
-*/
-QRegion QWSWindowSurface::move(const QPoint &offset, const QRegion &newClip)
-{
- const QRegion oldGeometry = geometry();
- QWindowSurface::setGeometry(geometry().translated(offset));
- return oldGeometry + newClip;
-}
-
-void QWSWindowSurface::releaseSurface()
-{
-}
-
-bool QWSMemorySurface::lock(int timeout)
-{
- Q_UNUSED(timeout);
-#ifndef QT_NO_QWS_MULTIPROCESS
- if (memlock && !memlock->lock(QWSLock::BackingStore))
- return false;
-#endif
-#ifndef QT_NO_THREAD
- threadLock.lock();
-#endif
- return true;
-}
-
-void QWSMemorySurface::unlock()
-{
-#ifndef QT_NO_THREAD
- threadLock.unlock();
-#endif
-#ifndef QT_NO_QWS_MULTIPROCESS
- if (memlock)
- memlock->unlock(QWSLock::BackingStore);
-#endif
-}
-
-QWSMemorySurface::QWSMemorySurface()
- : QWSWindowSurface()
-#ifndef QT_NO_QWS_MULTIPROCESS
- , memlock(0)
-#endif
-{
- setSurfaceFlags(Buffered);
-}
-
-QWSMemorySurface::QWSMemorySurface(QWidget *w)
- : QWSWindowSurface(w)
-{
- SurfaceFlags flags = Buffered;
- if (isWidgetOpaque(w))
- flags |= Opaque;
- setSurfaceFlags(flags);
-
-#ifndef QT_NO_QWS_MULTIPROCESS
- memlock = QWSDisplay::Data::getClientLock();
-#endif
-}
-
-QWSMemorySurface::~QWSMemorySurface()
-{
-}
-
-
-QImage::Format
-QWSMemorySurface::preferredImageFormat(const QWidget *widget) const
-{
- QScreen *screen = getScreen(widget);
- const int depth = screen->depth();
- const bool opaque = isWidgetOpaque(widget);
-
- if (!opaque) {
- if (depth <= 12)
- return QImage::Format_ARGB4444_Premultiplied;
- else if (depth <= 15)
- return QImage::Format_ARGB8555_Premultiplied;
- else if (depth <= 16)
- return QImage::Format_ARGB8565_Premultiplied;
- else if (depth <= 18)
- return QImage::Format_ARGB6666_Premultiplied;
- else
- return QImage::Format_ARGB32_Premultiplied;
- }
-
- QImage::Format format = screen->pixelFormat();
- if (format > QImage::Format_Indexed8) // ### assumes all new image formats supports a QPainter
- return format;
-
- if (depth <= 12)
- return QImage::Format_RGB444;
- else if (depth <= 15)
- return QImage::Format_RGB555;
- else if (depth <= 16)
- return QImage::Format_RGB16;
- else if (depth <= 18)
- return QImage::Format_RGB666;
- else if (depth <= 24)
- return QImage::Format_RGB888;
- else
- return QImage::Format_ARGB32_Premultiplied;
-}
-
-#ifndef QT_NO_QWS_MULTIPROCESS
-void QWSMemorySurface::setLock(int lockId)
-{
- if (memlock && memlock->id() == lockId)
- return;
- delete memlock;
- memlock = (lockId == -1 ? 0 : new QWSLock(lockId));
- return;
-}
-#endif // QT_NO_QWS_MULTIPROCESS
-
-bool QWSMemorySurface::isValid() const
-{
- if (img.isNull())
- return true;
-
- const QWidget *win = window();
- if (preferredImageFormat(win) != img.format())
- return false;
-
- if (isOpaque() != isWidgetOpaque(win)) // XXX: use QWidgetPrivate::isOpaque()
- return false;
-
- return true;
-}
-
-// ### copied from qwindowsurface_raster.cpp -- should be cross-platform
-void QWSMemorySurface::beginPaint(const QRegion &rgn)
-{
- if (!isWidgetOpaque(window())) {
- QPainter p(&img);
- p.setCompositionMode(QPainter::CompositionMode_Source);
- const QVector<QRect> rects = rgn.rects();
- const QColor blank = Qt::transparent;
- for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
- QRect r = *it;
-#ifdef Q_BACKINGSTORE_SUBSURFACES
- r.translate(painterOffset());
-#endif
- p.fillRect(r, blank);
- }
- }
- QWSWindowSurface::beginPaint(rgn);
-}
-
-// from qwindowsurface.cpp
-extern void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset);
-
-bool QWSMemorySurface::scroll(const QRegion &area, int dx, int dy)
-{
- const QVector<QRect> rects = area.rects();
- for (int i = 0; i < rects.size(); ++i)
- qt_scrollRectInImage(img, rects.at(i), QPoint(dx, dy));
-
- return true;
-}
-
-QPoint QWSMemorySurface::painterOffset() const
-{
- const QWidget *w = window();
- if (!w)
- return QPoint();
-
- if (w->mask().isEmpty())
- return QWSWindowSurface::painterOffset();
-
- const QRegion region = w->mask()
- & w->frameGeometry().translated(-w->geometry().topLeft());
- return -region.boundingRect().topLeft();
-}
-
-QWSLocalMemSurface::QWSLocalMemSurface()
- : QWSMemorySurface(), mem(0), memsize(0)
-{
-}
-
-QWSLocalMemSurface::QWSLocalMemSurface(QWidget *w)
- : QWSMemorySurface(w), mem(0), memsize(0)
-{
-}
-
-QWSLocalMemSurface::~QWSLocalMemSurface()
-{
- if (memsize)
- delete[] mem;
-}
-
-void QWSLocalMemSurface::setGeometry(const QRect &rect)
-{
- QSize size = rect.size();
-
- QWidget *win = window();
- if (win && !win->mask().isEmpty()) {
- const QRegion region = win->mask()
- & rect.translated(-win->geometry().topLeft());
- size = region.boundingRect().size();
- }
-
- uchar *deleteLater = 0;
- // In case of a Hide event we need to delete the memory after sending the
- // event to the server in order to let the server animate the event.
- if (size.isEmpty()) {
- deleteLater = mem;
- mem = 0;
- }
-
- if (img.size() != size) {
- delete[] mem;
- if (size.isEmpty()) {
- mem = 0;
- img = QImage();
- } else {
- const QImage::Format format = preferredImageFormat(win);
- const int bpl = nextMulOf4(bytesPerPixel(format) * size.width());
- const int memsize = bpl * size.height();
- mem = new uchar[memsize];
- img = QImage(mem, size.width(), size.height(), bpl, format);
- setImageMetrics(img, win);
- }
- }
-
- QWSWindowSurface::setGeometry(rect);
- delete[] deleteLater;
-}
-
-QByteArray QWSLocalMemSurface::permanentState() const
-{
- QByteArray array;
- array.resize(sizeof(uchar*) + 3 * sizeof(int) +
- sizeof(SurfaceFlags));
-
- char *ptr = array.data();
-
- *reinterpret_cast<uchar**>(ptr) = mem;
- ptr += sizeof(uchar*);
-
- reinterpret_cast<int*>(ptr)[0] = img.width();
- reinterpret_cast<int*>(ptr)[1] = img.height();
- ptr += 2 * sizeof(int);
-
- *reinterpret_cast<int *>(ptr) = img.format();
- ptr += sizeof(int);
-
- *reinterpret_cast<SurfaceFlags*>(ptr) = surfaceFlags();
-
- return array;
-}
-
-void QWSLocalMemSurface::setPermanentState(const QByteArray &data)
-{
- int width;
- int height;
- QImage::Format format;
- SurfaceFlags flags;
-
- const char *ptr = data.constData();
-
- mem = *reinterpret_cast<uchar* const*>(ptr);
- ptr += sizeof(uchar*);
-
- width = reinterpret_cast<const int*>(ptr)[0];
- height = reinterpret_cast<const int*>(ptr)[1];
- ptr += 2 * sizeof(int);
-
- format = QImage::Format(*reinterpret_cast<const int*>(ptr));
- ptr += sizeof(int);
-
- flags = *reinterpret_cast<const SurfaceFlags*>(ptr);
-
- const int bpl = nextMulOf4(bytesPerPixel(format) * width);
- QWSMemorySurface::img = QImage(mem, width, height, bpl, format);
- setSurfaceFlags(flags);
-}
-
-void QWSLocalMemSurface::releaseSurface()
-{
- mem = 0;
- img = QImage();
-}
-
-#ifndef QT_NO_QWS_MULTIPROCESS
-
-QWSSharedMemSurface::QWSSharedMemSurface()
- : QWSMemorySurface()
-{
-}
-
-QWSSharedMemSurface::QWSSharedMemSurface(QWidget *widget)
- : QWSMemorySurface(widget)
-{
-}
-
-QWSSharedMemSurface::~QWSSharedMemSurface()
-{
- // mem.detach() is done automatically by ~QSharedMemory
-}
-
-bool QWSSharedMemSurface::setMemory(int memId)
-{
- if (mem.id() == memId)
- return true;
-
- mem.detach();
- if (!mem.attach(memId)) {
- perror("QWSSharedMemSurface: attaching to shared memory");
- qCritical("QWSSharedMemSurface: Error attaching to"
- " shared memory 0x%x", memId);
- return false;
- }
-
- return true;
-}
-
-#ifdef QT_QWS_CLIENTBLIT
-void QWSSharedMemSurface::setDirectRegion(const QRegion &r, int id)
-{
- QWSMemorySurface::setDirectRegion(r, id);
- if(mem.address())
- *(uint *)mem.address() = id;
-}
-
-const QRegion QWSSharedMemSurface::directRegion() const
-{
- QWSSharedMemory *cmem = const_cast<QWSSharedMemory *>(&mem);
- if (cmem->address() && ((int*)cmem->address())[0] == directRegionId())
- return QWSMemorySurface::directRegion();
- else
- return QRegion();
-}
-#endif
-
-void QWSSharedMemSurface::setPermanentState(const QByteArray &data)
-{
- int memId;
- int width;
- int height;
- int lockId;
- QImage::Format format;
- SurfaceFlags flags;
-
- const int *ptr = reinterpret_cast<const int*>(data.constData());
-
- memId = ptr[0];
- width = ptr[1];
- height = ptr[2];
- lockId = ptr[3];
- format = QImage::Format(ptr[4]);
- flags = SurfaceFlags(ptr[5]);
-
- setSurfaceFlags(flags);
- setMemory(memId);
- setLock(lockId);
-
-#ifdef QT_QWS_CLIENTBLIT
- uchar *base = static_cast<uchar*>(mem.address()) + sizeof(uint);
-#else
- uchar *base = static_cast<uchar*>(mem.address());
-#endif
- const int bpl = nextMulOf4(bytesPerPixel(format) * width);
- QWSMemorySurface::img = QImage(base, width, height, bpl, format);
-}
-
-void QWSSharedMemSurface::setGeometry(const QRect &rect)
-{
- const QSize size = rect.size();
- if (img.size() != size) {
- if (size.isEmpty()) {
- mem.detach();
- img = QImage();
- } else {
- mem.detach();
-
- QWidget *win = window();
- const QImage::Format format = preferredImageFormat(win);
- const int bpl = nextMulOf4(bytesPerPixel(format) * size.width());
-#ifdef QT_QWS_CLIENTBLIT
- const int imagesize = bpl * size.height() + sizeof(uint);
-#else
- const int imagesize = bpl * size.height();
-#endif
- if (!mem.create(imagesize)) {
- perror("QWSSharedMemSurface::setGeometry allocating shared memory");
- qFatal("Error creating shared memory of size %d", imagesize);
- }
-#ifdef QT_QWS_CLIENTBLIT
- *((uint *)mem.address()) = 0;
- uchar *base = static_cast<uchar*>(mem.address()) + sizeof(uint);
-#else
- uchar *base = static_cast<uchar*>(mem.address());
-#endif
- img = QImage(base, size.width(), size.height(), bpl, format);
- setImageMetrics(img, win);
- }
- }
-
- QWSWindowSurface::setGeometry(rect);
-}
-
-QByteArray QWSSharedMemSurface::permanentState() const
-{
- QByteArray array;
- array.resize(6 * sizeof(int));
-
- int *ptr = reinterpret_cast<int*>(array.data());
-
- ptr[0] = mem.id();
- ptr[1] = img.width();
- ptr[2] = img.height();
- ptr[3] = (memlock ? memlock->id() : -1);
- ptr[4] = int(img.format());
- ptr[5] = int(surfaceFlags());
-
- return array;
-}
-
-void QWSSharedMemSurface::releaseSurface()
-{
- mem.detach();
- img = QImage();
-}
-
-#endif // QT_NO_QWS_MULTIPROCESS
-
-#ifndef QT_NO_PAINTONSCREEN
-
-QWSOnScreenSurface::QWSOnScreenSurface(QWidget *w)
- : QWSMemorySurface(w)
-{
- attachToScreen(getScreen(w));
- setSurfaceFlags(Opaque);
-}
-
-QWSOnScreenSurface::QWSOnScreenSurface()
- : QWSMemorySurface()
-{
- setSurfaceFlags(Opaque);
-}
-
-void QWSOnScreenSurface::attachToScreen(const QScreen *s)
-{
- screen = s;
- uchar *base = screen->base();
- QImage::Format format = screen->pixelFormat();
-
- if (format == QImage::Format_Invalid || format == QImage::Format_Indexed8) {
- //### currently we have no paint engine for indexed image formats
- qFatal("QWSOnScreenSurface::attachToScreen(): screen depth %d "
- "not implemented", screen->depth());
- return;
- }
- QWSMemorySurface::img = QImage(base, screen->width(), screen->height(),
- screen->linestep(), format );
-}
-
-QWSOnScreenSurface::~QWSOnScreenSurface()
-{
-}
-
-QPoint QWSOnScreenSurface::painterOffset() const
-{
- return geometry().topLeft() + QWSWindowSurface::painterOffset();
-}
-
-bool QWSOnScreenSurface::isValid() const
-{
- const QWidget *win = window();
- if (screen != getScreen(win))
- return false;
- if (img.isNull())
- return false;
- return QScreen::isWidgetPaintOnScreen(win);
-}
-
-QByteArray QWSOnScreenSurface::permanentState() const
-{
- QByteArray array;
- array.resize(sizeof(int));
- int *ptr = reinterpret_cast<int*>(array.data());
- ptr[0] = QApplication::desktop()->screenNumber(window());
- return array;
-}
-
-void QWSOnScreenSurface::setPermanentState(const QByteArray &data)
-{
- const int *ptr = reinterpret_cast<const int*>(data.constData());
- const int screenNo = ptr[0];
-
- QScreen *screen = qt_screen;
- if (screenNo > 0)
- screen = qt_screen->subScreens().at(screenNo);
- attachToScreen(screen);
-}
-
-#endif // QT_NO_PAINTONSCREEN
-
-#ifndef QT_NO_PAINT_DEBUG
-
-QWSYellowSurface::QWSYellowSurface(bool isClient)
- : QWSWindowSurface(), delay(10)
-{
- if (isClient) {
- setWinId(QWidget::qwsDisplay()->takeId());
- QWidget::qwsDisplay()->nameRegion(winId(),
- QLatin1String("Debug flush paint"),
- QLatin1String("Silly yellow thing"));
- QWidget::qwsDisplay()->setAltitude(winId(), 1, true);
- }
- setSurfaceFlags(Buffered);
-}
-
-QWSYellowSurface::~QWSYellowSurface()
-{
-}
-
-QByteArray QWSYellowSurface::permanentState() const
-{
- QByteArray array;
- array.resize(2 * sizeof(int));
-
- int *ptr = reinterpret_cast<int*>(array.data());
- ptr[0] = surfaceSize.width();
- ptr[1] = surfaceSize.height();
-
- return array;
-}
-
-void QWSYellowSurface::setPermanentState(const QByteArray &data)
-{
- const int *ptr = reinterpret_cast<const int*>(data.constData());
-
- const int width = ptr[0];
- const int height = ptr[1];
-
- img = QImage(width, height, QImage::Format_ARGB32);
- img.fill(qRgba(255,255,31,127));
-}
-
-void QWSYellowSurface::flush(QWidget *widget, const QRegion &region,
- const QPoint &offset)
-{
- Q_UNUSED(offset);
-
- QWSDisplay *display = QWidget::qwsDisplay();
- QRegion rgn = region;
-
- if (widget)
- rgn.translate(widget->mapToGlobal(QPoint(0, 0)));
-
- surfaceSize = region.boundingRect().size();
-
- const int id = winId();
- display->requestRegion(id, key(), permanentState(), rgn);
- display->setAltitude(id, 1, true);
- display->repaintRegion(id, 0, false, rgn);
-
- ::usleep(500 * delay);
- display->requestRegion(id, key(), permanentState(), QRegion());
- ::usleep(500 * delay);
-}
-
-#endif // QT_NO_PAINT_DEBUG
-
-#ifndef QT_NO_DIRECTPAINTER
-
-static inline QScreen *getPrimaryScreen()
-{
- QScreen *screen = QScreen::instance();
- if (!screen->base()) {
- QList<QScreen*> subScreens = screen->subScreens();
- if (subScreens.size() < 1)
- return 0;
- screen = subScreens.at(0);
- }
- return screen;
-}
-
-QWSDirectPainterSurface::QWSDirectPainterSurface(bool isClient,
- QDirectPainter::SurfaceFlag flags)
- : QWSWindowSurface(), flushingRegionEvents(false), doLocking(false)
-{
- setSurfaceFlags(Opaque);
- synchronous = (flags == QDirectPainter::ReservedSynchronous);
-
- if (isClient) {
- setWinId(QWidget::qwsDisplay()->takeId());
- QWidget::qwsDisplay()->nameRegion(winId(),
- QLatin1String("QDirectPainter reserved space"),
- QLatin1String("reserved"));
- } else {
- setWinId(0);
- }
- _screen = QScreen::instance();
- if (!_screen->base()) {
- QList<QScreen*> subScreens = _screen->subScreens();
- if (subScreens.size() < 1)
- _screen = 0;
- else
- _screen = subScreens.at(0);
- }
-}
-
-QWSDirectPainterSurface::~QWSDirectPainterSurface()
-{
- if (winId() && QWSDisplay::instance()) // make sure not in QApplication destructor
- QWidget::qwsDisplay()->destroyRegion(winId());
-}
-
-void QWSDirectPainterSurface::setRegion(const QRegion &region)
-{
- const int id = winId();
- QWidget::qwsDisplay()->requestRegion(id, key(), permanentState(), region);
-#ifndef QT_NO_QWS_MULTIPROCESS
- if (synchronous)
- QWSDisplay::instance()->d->waitForRegionAck(id);
-#endif
-}
-
-void QWSDirectPainterSurface::flush(QWidget *, const QRegion &r, const QPoint &)
-{
- QWSDisplay::instance()->repaintRegion(winId(), 0, true, r);
-}
-
-QByteArray QWSDirectPainterSurface::permanentState() const
-{
- QByteArray res;
- if (isRegionReserved())
- res.append( 'r');
- return res;
-}
-
-void QWSDirectPainterSurface::setPermanentState(const QByteArray &ba)
-{
- if (ba.size() > 0 && ba.at(0) == 'r')
- setReserved();
- setSurfaceFlags(surfaceFlags() | Opaque);
-}
-
-void QWSDirectPainterSurface::beginPaint(const QRegion &region)
-{
- QWSWindowSurface::beginPaint(region);
-#ifndef QT_NO_QWS_MULTIPROCESS
- if (!synchronous) {
- flushingRegionEvents = true;
- QWSDisplay::instance()->d->waitForRegionEvents(winId(), doLocking);
- flushingRegionEvents = false;
- }
-#endif
-}
-
-bool QWSDirectPainterSurface::hasPendingRegionEvents() const
-{
-#ifndef QT_NO_QWS_MULTIPROCESS
- if (synchronous)
- return false;
-
- return QWSDisplay::instance()->d->hasPendingRegionEvents();
-#else
- return false;
-#endif
-}
-
-bool QWSDirectPainterSurface::lock(int timeout)
-{
-#ifndef QT_NO_THREAD
- threadLock.lock();
-#endif
- Q_UNUSED(timeout);
- if (doLocking)
- QWSDisplay::grab(true);
- return true;
-}
-
-void QWSDirectPainterSurface::unlock()
-{
- if (doLocking)
- QWSDisplay::ungrab();
-#ifndef QT_NO_THREAD
- threadLock.unlock();
-#endif
-}
-
-#endif // QT_NO_DIRECTPAINTER
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qwindowsurface_qws_p.h b/src/gui/painting/qwindowsurface_qws_p.h
deleted file mode 100644
index fd56c814a3..0000000000
--- a/src/gui/painting/qwindowsurface_qws_p.h
+++ /dev/null
@@ -1,355 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSURFACE_QWS_P_H
-#define QWINDOWSURFACE_QWS_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qwindowsurface_p.h"
-#include <qregion.h>
-#include <qimage.h>
-#include <qdirectpainter_qws.h>
-#include <qmutex.h>
-#include <private/qwssharedmemory_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QScreen;
-class QWSWindowSurfacePrivate;
-
-class Q_GUI_EXPORT QWSWindowSurface : public QWindowSurface
-{
-public:
- QWSWindowSurface();
- QWSWindowSurface(QWidget *widget);
- ~QWSWindowSurface();
-
- virtual bool isValid() const = 0;
-
- virtual void setGeometry(const QRect &rect);
- virtual void setGeometry(const QRect &rect, const QRegion &mask);
- virtual void flush(QWidget *widget, const QRegion &region,
- const QPoint &offset);
-
- virtual bool move(const QPoint &offset);
- virtual QRegion move(const QPoint &offset, const QRegion &newClip);
-
- virtual QPoint painterOffset() const; // remove!!!
-
- virtual void beginPaint(const QRegion &);
- virtual void endPaint(const QRegion &);
-
- virtual bool lock(int timeout = -1);
- virtual void unlock();
-
- virtual QString key() const = 0;
-
- // XXX: not good enough
- virtual QByteArray transientState() const;
- virtual QByteArray permanentState() const;
- virtual void setTransientState(const QByteArray &state);
- virtual void setPermanentState(const QByteArray &state);
-
- virtual QImage image() const = 0;
- virtual QPaintDevice *paintDevice() = 0;
-
- const QRegion clipRegion() const;
- void setClipRegion(const QRegion &);
-
-#ifdef QT_QWS_CLIENTBLIT
- virtual const QRegion directRegion() const;
- virtual int directRegionId() const;
- virtual void setDirectRegion(const QRegion &, int);
-#endif
-
- enum SurfaceFlag {
- RegionReserved = 0x1,
- Buffered = 0x2,
- Opaque = 0x4
- };
- Q_DECLARE_FLAGS(SurfaceFlags, SurfaceFlag)
-
- SurfaceFlags surfaceFlags() const;
-
- inline bool isRegionReserved() const {
- return surfaceFlags() & RegionReserved;
- }
- inline bool isBuffered() const { return surfaceFlags() & Buffered; }
- inline bool isOpaque() const { return surfaceFlags() & Opaque; }
-
- int winId() const;
- virtual void releaseSurface();
-
-protected:
- void setSurfaceFlags(SurfaceFlags type);
- void setWinId(int id);
-
-private:
- friend class QWidgetPrivate;
-
- void invalidateBuffer();
-
- QWSWindowSurfacePrivate *d_ptr;
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QWSWindowSurface::SurfaceFlags)
-
-class QWSWindowSurfacePrivate
-{
-public:
- QWSWindowSurfacePrivate();
-
- void setWinId(int id);
-
- QWSWindowSurface::SurfaceFlags flags;
- QRegion clip;
-#ifdef QT_QWS_CLIENTBLIT
- QRegion direct;
- int directId;
-#endif
-
- int winId;
-};
-
-class QWSLock;
-
-class Q_GUI_EXPORT QWSMemorySurface : public QWSWindowSurface
-{
-public:
- QWSMemorySurface();
- QWSMemorySurface(QWidget *widget);
- ~QWSMemorySurface();
-
- bool isValid() const;
-
- QPaintDevice *paintDevice() { return &img; }
- bool scroll(const QRegion &area, int dx, int dy);
-
- QImage image() const { return img; }
- QPoint painterOffset() const;
-
- void beginPaint(const QRegion &rgn);
-
- bool lock(int timeout = -1);
- void unlock();
-
-protected:
- QImage::Format preferredImageFormat(const QWidget *widget) const;
-
-#ifndef QT_NO_QWS_MULTIPROCESS
- void setLock(int lockId);
- QWSLock *memlock;
-#endif
-#ifndef QT_NO_THREAD
- QMutex threadLock;
-#endif
-
- QImage img;
-};
-
-class Q_GUI_EXPORT QWSLocalMemSurface : public QWSMemorySurface
-{
-public:
- QWSLocalMemSurface();
- QWSLocalMemSurface(QWidget *widget);
- ~QWSLocalMemSurface();
-
- void setGeometry(const QRect &rect);
-
- QString key() const { return QLatin1String("mem"); }
- QByteArray permanentState() const;
-
- void setPermanentState(const QByteArray &data);
- virtual void releaseSurface();
-protected:
- uchar *mem;
- int memsize;
-};
-
-#ifndef QT_NO_QWS_MULTIPROCESS
-class Q_GUI_EXPORT QWSSharedMemSurface : public QWSMemorySurface
-{
-public:
- QWSSharedMemSurface();
- QWSSharedMemSurface(QWidget *widget);
- ~QWSSharedMemSurface();
-
- void setGeometry(const QRect &rect);
-
- QString key() const { return QLatin1String("shm"); }
- QByteArray permanentState() const;
-
- void setPermanentState(const QByteArray &data);
-
-#ifdef QT_QWS_CLIENTBLIT
- virtual void setDirectRegion(const QRegion &, int);
- virtual const QRegion directRegion() const;
-#endif
- virtual void releaseSurface();
-
-private:
- bool setMemory(int memId);
-
- QWSSharedMemory mem;
-};
-#endif // QT_NO_QWS_MULTIPROCESS
-
-#ifndef QT_NO_PAINTONSCREEN
-class Q_GUI_EXPORT QWSOnScreenSurface : public QWSMemorySurface
-{
-public:
- QWSOnScreenSurface();
- QWSOnScreenSurface(QWidget *widget);
- ~QWSOnScreenSurface();
-
- bool isValid() const;
- QPoint painterOffset() const;
-
- QString key() const { return QLatin1String("OnScreen"); }
- QByteArray permanentState() const;
-
- void setPermanentState(const QByteArray &data);
-
-private:
- void attachToScreen(const QScreen *screen);
-
- const QScreen *screen;
-};
-#endif // QT_NO_PAINTONSCREEN
-
-#ifndef QT_NO_PAINT_DEBUG
-class Q_GUI_EXPORT QWSYellowSurface : public QWSWindowSurface
-{
-public:
- QWSYellowSurface(bool isClient = false);
- ~QWSYellowSurface();
-
- void setDelay(int msec) { delay = msec; }
-
- bool isValid() const { return true; }
-
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
-
- QString key() const { return QLatin1String("Yellow"); }
- QByteArray permanentState() const;
-
- void setPermanentState(const QByteArray &data);
-
- QPaintDevice *paintDevice() { return &img; }
- QImage image() const { return img; }
-
-private:
- int delay;
- QSize surfaceSize; // client side
- QImage img; // server side
-};
-#endif // QT_NO_PAINT_DEBUG
-
-#ifndef QT_NO_DIRECTPAINTER
-
-class QScreen;
-
-class Q_GUI_EXPORT QWSDirectPainterSurface : public QWSWindowSurface
-{
-public:
- QWSDirectPainterSurface(bool isClient = false,
- QDirectPainter::SurfaceFlag flags = QDirectPainter::NonReserved);
- ~QWSDirectPainterSurface();
-
- void setReserved() { setSurfaceFlags(RegionReserved); }
-
- void setGeometry(const QRect &rect) { setRegion(rect); }
-
- void setRegion(const QRegion &region);
- QRegion region() const { return clipRegion(); }
-
- void flush(QWidget*, const QRegion &, const QPoint &);
-
- bool isValid() const { return false; }
-
- QString key() const { return QLatin1String("DirectPainter"); }
- QByteArray permanentState() const;
-
- void setPermanentState(const QByteArray &);
-
- QImage image() const { return QImage(); }
- QPaintDevice *paintDevice() { return 0; }
-
- // hw: get rid of this
- WId windowId() const { return static_cast<WId>(winId()); }
-
- QScreen *screen() const { return _screen; }
-
- void beginPaint(const QRegion &);
- bool lock(int timeout = -1);
- void unlock();
-
- void setLocking(bool b) { doLocking = b; }
-
- bool hasPendingRegionEvents() const;
-
-private:
- QScreen *_screen;
-#ifndef QT_NO_THREAD
- QMutex threadLock;
-#endif
-
- friend void qt_directpainter_region(QDirectPainter*, const QRegion&, int);
- bool flushingRegionEvents;
- bool synchronous;
- bool doLocking;
-};
-
-#endif // QT_NO_DIRECTPAINTER
-
-QT_END_NAMESPACE
-
-#endif // QWINDOWSURFACE_QWS_P_H
diff --git a/src/gui/painting/qwindowsurface_raster.cpp b/src/gui/painting/qwindowsurface_raster.cpp
deleted file mode 100644
index 9860841640..0000000000
--- a/src/gui/painting/qwindowsurface_raster.cpp
+++ /dev/null
@@ -1,487 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qdebug.h>
-
-#include <qglobal.h> // for Q_WS_WIN define (non-PCH)
-#ifdef Q_WS_WIN
-#include <qlibrary.h>
-#include <qt_windows.h>
-#endif
-
-#include <QtGui/qpaintdevice.h>
-#include <QtGui/qwidget.h>
-
-#include "private/qwindowsurface_raster_p.h"
-#include "private/qnativeimage_p.h"
-#include "private/qwidget_p.h"
-
-#ifdef Q_WS_X11
-#include "private/qpixmap_x11_p.h"
-#include "private/qt_x11_p.h"
-#include "private/qwidget_p.h"
-#include "qx11info_x11.h"
-#endif
-#include "private/qdrawhelper_p.h"
-
-#ifdef Q_WS_MAC
-#include <private/qt_cocoa_helpers_mac_p.h>
-#include <QMainWindow>
-#include <private/qmainwindowlayout_p.h>
-#include <QToolBar>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class QRasterWindowSurfacePrivate
-{
-public:
- QNativeImage *image;
-
-#ifdef Q_WS_X11
- GC gc;
-#ifndef QT_NO_MITSHM
- uint needsSync : 1;
-#endif
-#ifndef QT_NO_XRENDER
- uint translucentBackground : 1;
-#endif
-#endif
- uint inSetGeometry : 1;
-};
-
-QRasterWindowSurface::QRasterWindowSurface(QWidget *window, bool setDefaultSurface)
- : QWindowSurface(window, setDefaultSurface), d_ptr(new QRasterWindowSurfacePrivate)
-{
-#ifdef Q_WS_X11
- d_ptr->gc = XCreateGC(X11->display, window->handle(), 0, 0);
-#ifndef QT_NO_XRENDER
- d_ptr->translucentBackground = X11->use_xrender
- && window->x11Info().depth() == 32;
-#endif
-#ifndef QT_NO_MITHSM
- d_ptr->needsSync = false;
-#endif
-#endif
- d_ptr->image = 0;
- d_ptr->inSetGeometry = false;
-
-#ifdef QT_MAC_USE_COCOA
- needsFlush = false;
- regionToFlush = QRegion();
-#endif // QT_MAC_USE_COCOA
-}
-
-
-QRasterWindowSurface::~QRasterWindowSurface()
-{
-#ifdef Q_WS_X11
- XFreeGC(X11->display, d_ptr->gc);
-#endif
- if (d_ptr->image)
- delete d_ptr->image;
-}
-
-
-QPaintDevice *QRasterWindowSurface::paintDevice()
-{
- return &d_ptr->image->image;
-}
-
-#if defined(Q_WS_X11) && !defined(QT_NO_MITSHM)
-void QRasterWindowSurface::syncX()
-{
- // delay writing to the backbuffer until we know for sure X is done reading from it
- if (d_ptr->needsSync) {
- XSync(X11->display, false);
- d_ptr->needsSync = false;
- }
-}
-#endif
-
-void QRasterWindowSurface::beginPaint(const QRegion &rgn)
-{
-#if defined(Q_WS_X11) && !defined(QT_NO_MITSHM)
- syncX();
-#endif
-
-#if (defined(Q_WS_X11) && !defined(QT_NO_XRENDER)) || (defined(Q_WS_WIN) && !defined(Q_WS_WINCE))
- if (!qt_widget_private(window())->isOpaque && window()->testAttribute(Qt::WA_TranslucentBackground)) {
-#if defined(Q_WS_WIN) && !defined(Q_WS_WINCE)
- if (d_ptr->image->image.format() != QImage::Format_ARGB32_Premultiplied)
- prepareBuffer(QImage::Format_ARGB32_Premultiplied, window());
-#endif
- QPainter p(&d_ptr->image->image);
- p.setCompositionMode(QPainter::CompositionMode_Source);
- const QVector<QRect> rects = rgn.rects();
- const QColor blank = Qt::transparent;
- for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
- p.fillRect(*it, blank);
- }
- }
-#else
- Q_UNUSED(rgn);
-#endif
-}
-
-void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &offset)
-{
- Q_D(QRasterWindowSurface);
-
- // Not ready for painting yet, bail out. This can happen in
- // QWidget::create_sys()
- if (!d->image || rgn.rectCount() == 0)
- return;
-
-#ifdef Q_WS_WIN
- QRect br = rgn.boundingRect();
-
-#ifndef Q_WS_WINCE
- if (!qt_widget_private(window())->isOpaque
- && window()->testAttribute(Qt::WA_TranslucentBackground)
- && (qt_widget_private(window())->data.window_flags & Qt::FramelessWindowHint))
- {
- QRect r = window()->frameGeometry();
- QPoint frameOffset = qt_widget_private(window())->frameStrut().topLeft();
- QRect dirtyRect = br.translated(offset + frameOffset);
-
- SIZE size = {r.width(), r.height()};
- POINT ptDst = {r.x(), r.y()};
- POINT ptSrc = {0, 0};
- BLENDFUNCTION blend = {AC_SRC_OVER, 0, (int)(255.0 * window()->windowOpacity()), Q_AC_SRC_ALPHA};
- RECT dirty = {dirtyRect.x(), dirtyRect.y(),
- dirtyRect.x() + dirtyRect.width(), dirtyRect.y() + dirtyRect.height()};
- Q_UPDATELAYEREDWINDOWINFO info = {sizeof(info), NULL, &ptDst, &size, d->image->hdc, &ptSrc, 0, &blend, Q_ULW_ALPHA, &dirty};
- ptrUpdateLayeredWindowIndirect(window()->internalWinId(), &info);
- } else
-#endif
- {
- QPoint wOffset = qt_qwidget_data(widget)->wrect.topLeft();
-
- HDC widget_dc = widget->getDC();
-
- QRect wbr = br.translated(-wOffset);
- BitBlt(widget_dc, wbr.x(), wbr.y(), wbr.width(), wbr.height(),
- d->image->hdc, br.x() + offset.x(), br.y() + offset.y(), SRCCOPY);
- widget->releaseDC(widget_dc);
- }
-
-#ifndef QT_NO_DEBUG
- static bool flush = !qgetenv("QT_FLUSH_WINDOWSURFACE").isEmpty();
- if (flush) {
- SelectObject(qt_win_display_dc(), GetStockObject(BLACK_BRUSH));
- Rectangle(qt_win_display_dc(), 0, 0, d->image->width() + 2, d->image->height() + 2);
- BitBlt(qt_win_display_dc(), 1, 1, d->image->width(), d->image->height(),
- d->image->hdc, 0, 0, SRCCOPY);
- }
-#endif
-
-#endif
-
-#ifdef Q_WS_X11
- extern void *qt_getClipRects(const QRegion &r, int &num); // in qpaintengine_x11.cpp
- extern QWidgetData* qt_widget_data(QWidget *);
- QPoint wOffset = qt_qwidget_data(widget)->wrect.topLeft();
-
- if (widget->window() != window()) {
- XFreeGC(X11->display, d_ptr->gc);
- d_ptr->gc = XCreateGC(X11->display, widget->handle(), 0, 0);
- }
-
- QRegion wrgn(rgn);
- if (!wOffset.isNull())
- wrgn.translate(-wOffset);
- QRect wbr = wrgn.boundingRect();
-
- if (wrgn.rectCount() != 1) {
- int num;
- XRectangle *rects = (XRectangle *)qt_getClipRects(wrgn, num);
- XSetClipRectangles(X11->display, d_ptr->gc, 0, 0, rects, num, YXBanded);
- }
-
- QRect br = rgn.boundingRect().translated(offset);
-#ifndef QT_NO_MITSHM
- if (d_ptr->image->xshmpm) {
- XCopyArea(X11->display, d_ptr->image->xshmpm, widget->handle(), d_ptr->gc,
- br.x(), br.y(), br.width(), br.height(), wbr.x(), wbr.y());
- d_ptr->needsSync = true;
- } else if (d_ptr->image->xshmimg) {
- const QImage &src = d->image->image;
- br = br.intersected(src.rect());
- XShmPutImage(X11->display, widget->handle(), d_ptr->gc, d_ptr->image->xshmimg,
- br.x(), br.y(), wbr.x(), wbr.y(), br.width(), br.height(), False);
- d_ptr->needsSync = true;
- } else
-#endif
- {
- const QImage &src = d->image->image;
- br = br.intersected(src.rect());
- if (src.format() != QImage::Format_RGB32 || widget->x11Info().depth() < 24) {
- Q_ASSERT(src.depth() >= 16);
- const QImage sub_src(src.scanLine(br.y()) + br.x() * (uint(src.depth()) / 8),
- br.width(), br.height(), src.bytesPerLine(), src.format());
- QX11PixmapData *data = new QX11PixmapData(QPixmapData::PixmapType);
- data->xinfo = widget->x11Info();
- data->fromImage(sub_src, Qt::NoOpaqueDetection);
- QPixmap pm = QPixmap(data);
- XCopyArea(X11->display, pm.handle(), widget->handle(), d_ptr->gc, 0 , 0 , br.width(), br.height(), wbr.x(), wbr.y());
- } else {
- // qpaintengine_x11.cpp
- extern void qt_x11_drawImage(const QRect &rect, const QPoint &pos, const QImage &image, Drawable hd, GC gc, Display *dpy, Visual *visual, int depth);
- qt_x11_drawImage(br, wbr.topLeft(), src, widget->handle(), d_ptr->gc, X11->display, (Visual *)widget->x11Info().visual(), widget->x11Info().depth());
- }
- }
-
- if (wrgn.rectCount() != 1)
- XSetClipMask(X11->display, d_ptr->gc, XNone);
-#endif // FALCON
-
-#ifdef Q_WS_MAC
-
- Q_UNUSED(offset);
-
- // This is mainly done for native components like native "open file" dialog.
- if (widget->testAttribute(Qt::WA_DontShowOnScreen)) {
- return;
- }
-
-#ifdef QT_MAC_USE_COCOA
-
- this->needsFlush = true;
- this->regionToFlush += rgn;
-
- // The actual flushing will be processed in [view drawRect:rect]
- qt_mac_setNeedsDisplay(widget);
-
-#else
- // Get a context for the widget.
- CGContextRef context;
- CGrafPtr port = GetWindowPort(qt_mac_window_for(widget));
- QDBeginCGContext(port, &context);
- CGContextRetain(context);
- CGContextSaveGState(context);
-
- // Flip context.
- CGContextTranslateCTM(context, 0, widget->height());
- CGContextScaleCTM(context, 1, -1);
-
- // Clip to region.
- const QVector<QRect> &rects = rgn.rects();
- for (int i = 0; i < rects.size(); ++i) {
- const QRect &rect = rects.at(i);
- CGContextAddRect(context, CGRectMake(rect.x(), rect.y(), rect.width(), rect.height()));
- }
- CGContextClip(context);
-
- QRect r = rgn.boundingRect();
- const CGRect area = CGRectMake(r.x(), r.y(), r.width(), r.height());
- CGImageRef image = CGBitmapContextCreateImage(d->image->cg);
- CGImageRef subImage = CGImageCreateWithImageInRect(image, area);
-
- qt_mac_drawCGImage(context, &area, subImage);
-
- CGImageRelease(subImage);
- CGImageRelease(image);
-
- QDEndCGContext(port, &context);
-
- // Restore context.
- CGContextRestoreGState(context);
- CGContextRelease(context);
-#endif // QT_MAC_USE_COCOA
-
-#endif // Q_WS_MAC
-
-#ifdef Q_OS_SYMBIAN
- Q_UNUSED(widget);
- Q_UNUSED(rgn);
- Q_UNUSED(offset);
-#endif
-}
-
-void QRasterWindowSurface::setGeometry(const QRect &rect)
-{
- QWindowSurface::setGeometry(rect);
- Q_D(QRasterWindowSurface);
- d->inSetGeometry = true;
- if (d->image == 0 || d->image->width() < rect.width() || d->image->height() < rect.height()) {
-#if (defined(Q_WS_X11) && !defined(QT_NO_XRENDER)) || (defined(Q_WS_WIN) && !defined(Q_WS_WINCE))
-#ifndef Q_WS_WIN
- if (d_ptr->translucentBackground)
-#else
- if (!qt_widget_private(window())->isOpaque)
-#endif
- prepareBuffer(QImage::Format_ARGB32_Premultiplied, window());
- else
-#endif
- prepareBuffer(QNativeImage::systemFormat(), window());
- }
- d->inSetGeometry = false;
-
-#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
- QMainWindow* mWindow = qobject_cast<QMainWindow*>(window());
- if (mWindow) {
- QMainWindowLayout *mLayout = qobject_cast<QMainWindowLayout*>(mWindow->layout());
- QList<QToolBar *> toolbarList = mLayout->qtoolbarsInUnifiedToolbarList;
-
- for (int i = 0; i < toolbarList.size(); ++i) {
- QToolBar* toolbar = toolbarList.at(i);
- if (mLayout->toolBarArea(toolbar) == Qt::TopToolBarArea) {
- QWidget* tbWidget = (QWidget*) toolbar;
- if (tbWidget->d_func()->unifiedSurface) {
- tbWidget->d_func()->unifiedSurface->setGeometry(rect);
- }
- }
- }
- }
-#endif // Q_WS_MAC && QT_MAC_USE_COCOA
-
-}
-
-// from qwindowsurface.cpp
-extern void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset);
-
-bool QRasterWindowSurface::scroll(const QRegion &area, int dx, int dy)
-{
-#ifdef Q_WS_WIN
- Q_D(QRasterWindowSurface);
-
- if (!d->image || !d->image->hdc)
- return false;
-
- QRect rect = area.boundingRect();
- BitBlt(d->image->hdc, rect.x()+dx, rect.y()+dy, rect.width(), rect.height(),
- d->image->hdc, rect.x(), rect.y(), SRCCOPY);
-
- return true;
-#else
- Q_D(QRasterWindowSurface);
-
- if (!d->image || d->image->image.isNull())
- return false;
-
-#if defined(Q_WS_X11) && !defined(QT_NO_MITSHM)
- syncX();
-#endif
-
- const QVector<QRect> rects = area.rects();
- for (int i = 0; i < rects.size(); ++i)
- qt_scrollRectInImage(d->image->image, rects.at(i), QPoint(dx, dy));
-
- return true;
-#endif
-}
-
-QWindowSurface::WindowSurfaceFeatures QRasterWindowSurface::features() const
-{
- return QWindowSurface::AllFeatures;
-}
-
-void QRasterWindowSurface::prepareBuffer(QImage::Format format, QWidget *widget)
-{
- Q_D(QRasterWindowSurface);
-
- int width = window()->width();
- int height = window()->height();
- if (d->image) {
- width = qMax(d->image->width(), width);
- height = qMax(d->image->height(), height);
- }
-
- if (width == 0 || height == 0) {
- delete d->image;
- d->image = 0;
- return;
- }
-
- QNativeImage *oldImage = d->image;
-
- d->image = new QNativeImage(width, height, format, false, widget);
-
- if (oldImage && d->inSetGeometry && hasStaticContents()) {
- // Make sure we use the const version of bits() (no detach).
- const uchar *src = const_cast<const QImage &>(oldImage->image).bits();
- uchar *dst = d->image->image.bits();
-
- const int srcBytesPerLine = oldImage->image.bytesPerLine();
- const int dstBytesPerLine = d->image->image.bytesPerLine();
- const int bytesPerPixel = oldImage->image.depth() >> 3;
-
- QRegion staticRegion(staticContents());
- // Make sure we're inside the boundaries of the old image.
- staticRegion &= QRect(0, 0, oldImage->image.width(), oldImage->image.height());
- const QVector<QRect> &rects = staticRegion.rects();
- const QRect *srcRect = rects.constData();
-
- // Copy the static content of the old image into the new one.
- int numRectsLeft = rects.size();
- do {
- const int bytesOffset = srcRect->x() * bytesPerPixel;
- const int dy = srcRect->y();
-
- // Adjust src and dst to point to the right offset.
- const uchar *s = src + dy * srcBytesPerLine + bytesOffset;
- uchar *d = dst + dy * dstBytesPerLine + bytesOffset;
- const int numBytes = srcRect->width() * bytesPerPixel;
-
- int numScanLinesLeft = srcRect->height();
- do {
- ::memcpy(d, s, numBytes);
- d += dstBytesPerLine;
- s += srcBytesPerLine;
- } while (--numScanLinesLeft);
-
- ++srcRect;
- } while (--numRectsLeft);
- }
-
- delete oldImage;
-}
-
-#ifdef QT_MAC_USE_COCOA
-CGContextRef QRasterWindowSurface::imageContext()
-{
- Q_D(QRasterWindowSurface);
- return d->image->cg;
-}
-#endif // QT_MAC_USE_COCOA
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qwindowsurface_raster_p.h b/src/gui/painting/qwindowsurface_raster_p.h
deleted file mode 100644
index 06abcd3a4a..0000000000
--- a/src/gui/painting/qwindowsurface_raster_p.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSURFACE_RASTER_P_H
-#define QWINDOWSURFACE_RASTER_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QLibrary class. This header file may change from
-// version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <qglobal.h>
-#include "private/qwindowsurface_p.h"
-
-#ifdef QT_MAC_USE_COCOA
-# include <private/qt_cocoa_helpers_mac_p.h>
-#endif // QT_MAC_USE_COCOA
-
-QT_BEGIN_NAMESPACE
-
-#ifdef Q_WS_WIN
-#define Q_WS_EX_LAYERED 0x00080000 // copied from WS_EX_LAYERED in winuser.h
-#define Q_LWA_ALPHA 0x00000002 // copied from LWA_ALPHA in winuser.h
-#define Q_ULW_ALPHA 0x00000002 // copied from ULW_ALPHA in winuser.h
-#define Q_AC_SRC_ALPHA 0x00000001 // copied from AC_SRC_ALPHA in winuser.h
-
-struct Q_UPDATELAYEREDWINDOWINFO {
- DWORD cbSize;
- HDC hdcDst;
- const POINT *pptDst;
- const SIZE *psize;
- HDC hdcSrc;
- const POINT *pptSrc;
- COLORREF crKey;
- const BLENDFUNCTION *pblend;
- DWORD dwFlags;
- const RECT *prcDirty;
-};
-
-typedef BOOL (WINAPI *PtrUpdateLayeredWindow)(HWND hwnd, HDC hdcDst, const POINT *pptDst,
- const SIZE *psize, HDC hdcSrc, const POINT *pptSrc, COLORREF crKey,
- const BLENDFUNCTION *pblend, DWORD dwflags);
-typedef BOOL (WINAPI *PtrUpdateLayeredWindowIndirect)(HWND hwnd, const Q_UPDATELAYEREDWINDOWINFO *pULWInfo);
-extern PtrUpdateLayeredWindow ptrUpdateLayeredWindow;
-extern PtrUpdateLayeredWindowIndirect ptrUpdateLayeredWindowIndirect;
-#endif
-
-class QPaintDevice;
-class QPoint;
-class QRegion;
-class QRegion;
-class QSize;
-class QWidget;
-class QRasterWindowSurfacePrivate;
-class QNativeImage;
-
-class Q_GUI_EXPORT QRasterWindowSurface : public QWindowSurface
-{
-public:
- QRasterWindowSurface(QWidget *widget, bool setDefaultSurface = true);
- ~QRasterWindowSurface();
-
- QPaintDevice *paintDevice();
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
- void beginPaint(const QRegion &rgn);
- void setGeometry(const QRect &rect);
- bool scroll(const QRegion &area, int dx, int dy);
- WindowSurfaceFeatures features() const;
-
-#ifdef QT_MAC_USE_COCOA
- CGContextRef imageContext();
-
- bool needsFlush;
- QRegion regionToFlush;
-#endif // QT_MAC_USE_COCOA
-
-private:
-#if defined(Q_WS_X11) && !defined(QT_NO_MITSHM)
- void syncX();
-#endif
- void prepareBuffer(QImage::Format format, QWidget *widget);
- Q_DECLARE_PRIVATE(QRasterWindowSurface)
- QScopedPointer<QRasterWindowSurfacePrivate> d_ptr;
-};
-
-QT_END_NAMESPACE
-
-#endif // QWINDOWSURFACE_RASTER_P_H
diff --git a/src/gui/painting/qwindowsurface_s60.cpp b/src/gui/painting/qwindowsurface_s60.cpp
deleted file mode 100644
index 9fa01edf7d..0000000000
--- a/src/gui/painting/qwindowsurface_s60.cpp
+++ /dev/null
@@ -1,254 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qglobal.h> // for Q_WS_WIN define (non-PCH)
-
-#include <QtGui/qpaintdevice.h>
-#include <private/qwidget_p.h>
-#include <private/qwindowsurface_s60_p.h>
-#include <private/qpixmap_s60_p.h>
-#include <private/qt_s60_p.h>
-#include <private/qapplication_p.h>
-#include <private/qdrawhelper_p.h>
-
-#ifdef QT_GRAPHICSSYSTEM_RUNTIME
-#include <private/qgraphicssystem_runtime_p.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-struct QS60WindowSurfacePrivate
-{
- QPixmap device;
- QList<QImage*> bufferImages;
-};
-
-TDisplayMode displayMode(bool opaque)
-{
- TDisplayMode mode = S60->screenDevice()->DisplayMode();
- if (opaque) {
- mode = EColor16MU;
- } else {
- if (QSysInfo::symbianVersion() >= QSysInfo::SV_SF_3)
- mode = Q_SYMBIAN_ECOLOR16MAP; // Symbian^3 WServ has support for ARGB32_PRE
- else
- mode = EColor16MA; // Symbian prior to Symbian^3 sw accelerates EColor16MA
- }
- return mode;
-}
-
-bool blitWriteAlpha(QWidgetPrivate *widgetPrivate)
-{
- QWExtra *extra = widgetPrivate->extraData();
- return extra ? extra->nativePaintMode == QWExtra::BlitWriteAlpha : false;
-}
-
-QS60WindowSurface::QS60WindowSurface(QWidget* widget)
- : QWindowSurface(widget), d_ptr(new QS60WindowSurfacePrivate)
-{
- QWidgetPrivate *widgetPrivate = qt_widget_private(widget);
- const bool opaque = widgetPrivate->isOpaque && !blitWriteAlpha(widgetPrivate);
- TDisplayMode mode = displayMode(opaque);
- // We create empty CFbsBitmap here -> it will be resized in setGeometry
- CFbsBitmap *bitmap = new CFbsBitmap; // CBase derived object needs check on new
- Q_CHECK_PTR(bitmap);
- qt_symbian_throwIfError( bitmap->Create( TSize(0, 0), mode ) );
-
- QS60PixmapData *data = new QS60PixmapData(QPixmapData::PixmapType);
- if (data) {
- data->fromSymbianBitmap(bitmap, true);
- d_ptr->device = QPixmap(data);
- }
-}
-
-QS60WindowSurface::~QS60WindowSurface()
-{
-#if defined(QT_GRAPHICSSYSTEM_RUNTIME) && defined(Q_SYMBIAN_SUPPORTS_SURFACES)
- if(QApplicationPrivate::runtime_graphics_system) {
- QRuntimeGraphicsSystem *runtimeGraphicsSystem =
- static_cast<QRuntimeGraphicsSystem*>(QApplicationPrivate::graphics_system);
- if(runtimeGraphicsSystem->graphicsSystemName() == QLatin1String("openvg")) {
-
- // Graphics system has been switched from raster to openvg.
- // Issue empty redraw to clear the UI surface
-
- QWidget *w = window();
- if (w->testAttribute(Qt::WA_WState_Created)) {
- RWindow *const window = static_cast<RWindow *>(w->winId()->DrawableWindow());
- window->BeginRedraw();
- window->EndRedraw();
- }
- }
- }
-#endif
-
- delete d_ptr;
-}
-
-void QS60WindowSurface::beginPaint(const QRegion &rgn)
-{
-#ifdef Q_SYMBIAN_SUPPORTS_SURFACES
- S60->wsSession().Finish();
-#endif
-
- QWidgetPrivate *windowPrivate = qt_widget_private(window());
- if (!windowPrivate->isOpaque || blitWriteAlpha(windowPrivate)) {
- QS60PixmapData *pixmapData = static_cast<QS60PixmapData *>(d_ptr->device.data_ptr().data());
-
- TDisplayMode mode = displayMode(false);
- if (pixmapData->cfbsBitmap->DisplayMode() != mode)
- pixmapData->convertToDisplayMode(mode);
-
- pixmapData->beginDataAccess();
-
- if (!windowPrivate->isOpaque) {
- QPainter p(&pixmapData->image);
- p.setCompositionMode(QPainter::CompositionMode_Source);
- const QVector<QRect> rects = rgn.rects();
- const QColor blank = Qt::transparent;
- for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it) {
- p.fillRect(*it, blank);
- }
- }
-
- pixmapData->endDataAccess();
- }
-}
-
-void QS60WindowSurface::endPaint(const QRegion &)
-{
- qDeleteAll(d_ptr->bufferImages);
- d_ptr->bufferImages.clear();
-}
-
-QImage* QS60WindowSurface::buffer(const QWidget *widget)
-{
- if (widget->window() != window())
- return 0;
-
- QPaintDevice *pdev = paintDevice();
- if (!pdev)
- return 0;
-
- const QPoint off = offset(widget);
- QImage *img = &(static_cast<QS60PixmapData *>(d_ptr->device.data_ptr().data())->image);
-
- QRect rect(off, widget->size());
- rect &= QRect(QPoint(), img->size());
-
- if (rect.isEmpty())
- return 0;
-
- img = new QImage(img->scanLine(rect.y()) + rect.x() * img->depth() / 8,
- rect.width(), rect.height(),
- img->bytesPerLine(), img->format());
- d_ptr->bufferImages.append(img);
-
- return img;
-}
-
-void QS60WindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &)
-{
- QWidget *window = widget->window();
- Q_ASSERT(window);
- QTLWExtra *topExtra = window->d_func()->maybeTopData();
- Q_ASSERT(topExtra);
- QRect qr = region.boundingRect();
- if (!topExtra->inExpose) {
- topExtra->inExpose = true; // Prevent DrawNow() from calling syncBackingStore() again
- TRect tr = qt_QRect2TRect(qr);
- widget->winId()->DrawNow(tr);
- topExtra->inExpose = false;
- } else {
- // This handles the case when syncBackingStore updates content outside of the
- // original drawing rectangle. This might happen if there are pending update()
- // events at the same time as we get a Draw() from Symbian.
- QRect drawRect = qt_TRect2QRect(widget->winId()->DrawableWindow()->GetDrawRect());
- if (!drawRect.contains(qr))
- widget->winId()->DrawDeferred();
- }
-}
-
-bool QS60WindowSurface::scroll(const QRegion &area, int dx, int dy)
-{
- QRect rect = area.boundingRect();
-
- if (dx == 0 && dy == 0)
- return false;
-
- if (d_ptr->device.isNull())
- return false;
-
- QS60PixmapData *data = static_cast<QS60PixmapData*>(d_ptr->device.data_ptr().data());
- data->scroll(dx, dy, rect);
-
- return true;
-}
-
-QPaintDevice* QS60WindowSurface::paintDevice()
-{
- return &d_ptr->device;
-}
-
-void QS60WindowSurface::setGeometry(const QRect& rect)
-{
- if (rect == geometry())
- return;
-
- QS60PixmapData *data = static_cast<QS60PixmapData*>(d_ptr->device.data_ptr().data());
- data->resize(rect.width(), rect.height());
-
- QWindowSurface::setGeometry(rect);
-}
-
-QWindowSurface::WindowSurfaceFeatures QS60WindowSurface::features() const
-{
- return QWindowSurface::AllFeatures;
-}
-
-CFbsBitmap* QS60WindowSurface::symbianBitmap() const
-{
- QS60PixmapData *data = static_cast<QS60PixmapData*>(d_ptr->device.data_ptr().data());
- return data->cfbsBitmap;
-}
-
-QT_END_NAMESPACE
-
diff --git a/src/gui/painting/qwindowsurface_s60_p.h b/src/gui/painting/qwindowsurface_s60_p.h
deleted file mode 100644
index 25018d86e2..0000000000
--- a/src/gui/painting/qwindowsurface_s60_p.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSURFACE_S60_P_H
-#define QWINDOWSURFACE_S60_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <qglobal.h>
-#include "private/qwindowsurface_p.h"
-
-class CFbsBitmap;
-
-QT_BEGIN_NAMESPACE
-
-struct QS60WindowSurfacePrivate;
-
-class QS60WindowSurface : public QWindowSurface
-{
-public:
- QS60WindowSurface(QWidget *widget);
- ~QS60WindowSurface();
-
- QPaintDevice *paintDevice();
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
- bool scroll(const QRegion &area, int dx, int dy);
-
- void beginPaint(const QRegion &);
- void endPaint(const QRegion &);
-
- QImage* buffer(const QWidget *widget);
-
- void setGeometry(const QRect &rect);
-
- WindowSurfaceFeatures features() const;
-
- CFbsBitmap *symbianBitmap() const;
-
-private:
- QS60WindowSurfacePrivate* d_ptr;
-
-};
-
-QT_END_NAMESPACE
-
-#endif // QWINDOWSURFACE_S60_P_H
diff --git a/src/gui/painting/qwindowsurface_x11.cpp b/src/gui/painting/qwindowsurface_x11.cpp
deleted file mode 100644
index deb83b452c..0000000000
--- a/src/gui/painting/qwindowsurface_x11.cpp
+++ /dev/null
@@ -1,265 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtGui/QPaintDevice>
-#include <QtGui/QPainter>
-#include <QtGui/QPixmap>
-#include <QtGui/QWidget>
-
-#include "private/qt_x11_p.h"
-#include "private/qpixmap_x11_p.h"
-#include "private/qwidget_p.h"
-#include "qx11info_x11.h"
-#include "qwindowsurface_x11_p.h"
-
-QT_BEGIN_NAMESPACE
-
-extern void *qt_getClipRects(const QRegion &r, int &num); // in qpaintengine_x11.cpp
-
-struct QX11WindowSurfacePrivate
-{
- QWidget *widget;
- QPixmap device;
-#ifndef QT_NO_XRENDER
- bool translucentBackground;
-#endif
-};
-
-QX11WindowSurface::QX11WindowSurface(QWidget *widget)
- : QWindowSurface(widget), d_ptr(new QX11WindowSurfacePrivate), gc(0)
-{
- d_ptr->widget = widget;
-#ifndef QT_NO_XRENDER
- d_ptr->translucentBackground = X11->use_xrender
- && widget->x11Info().depth() == 32;
-#endif
-}
-
-
-QX11WindowSurface::~QX11WindowSurface()
-{
- delete d_ptr;
- if (gc) {
- XFreeGC(X11->display, gc);
- gc = 0;
- }
-}
-
-QPaintDevice *QX11WindowSurface::paintDevice()
-{
- return &d_ptr->device;
-}
-
-void QX11WindowSurface::beginPaint(const QRegion &rgn)
-{
-#ifndef QT_NO_XRENDER
- Q_ASSERT(!d_ptr->device.isNull());
-
- if (d_ptr->translucentBackground) {
- if (d_ptr->device.depth() != 32)
- static_cast<QX11PixmapData *>(d_ptr->device.data_ptr().data())->convertToARGB32();
- ::Picture src = X11->getSolidFill(d_ptr->device.x11Info().screen(), Qt::transparent);
- ::Picture dst = d_ptr->device.x11PictureHandle();
- const QVector<QRect> rects = rgn.rects();
- const int w = d_ptr->device.width();
- const int h = d_ptr->device.height();
- for (QVector<QRect>::const_iterator it = rects.begin(); it != rects.end(); ++it)
- XRenderComposite(X11->display, PictOpSrc, src, 0, dst,
- 0, 0, w, h, it->x(), it->y(),
- it->width(), it->height());
- }
-#endif
-}
-
-void QX11WindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &offset)
-{
- if (d_ptr->device.isNull())
- return;
-
- QPoint wOffset = qt_qwidget_data(widget)->wrect.topLeft();
- QRegion wrgn(rgn);
- QRect br = rgn.boundingRect();
- if (!wOffset.isNull())
- wrgn.translate(-wOffset);
- QRect wbr = wrgn.boundingRect();
-
- int num;
- XRectangle *rects = (XRectangle *)qt_getClipRects(wrgn, num);
- if (num <= 0)
- return;
-// qDebug() << "XSetClipRectangles";
-// for (int i = 0; i < num; ++i)
-// qDebug() << ' ' << i << rects[i].x << rects[i].x << rects[i].y << rects[i].width << rects[i].height;
- if (num != 1)
- XSetClipRectangles(X11->display, gc, 0, 0, rects, num, YXBanded);
- XCopyArea(X11->display, d_ptr->device.handle(), widget->handle(), gc,
- br.x() + offset.x(), br.y() + offset.y(), br.width(), br.height(), wbr.x(), wbr.y());
- if (num != 1)
- XSetClipMask(X11->display, gc, XNone);
-}
-
-void QX11WindowSurface::setGeometry(const QRect &rect)
-{
- QWindowSurface::setGeometry(rect);
-
- const QSize size = rect.size();
-
- if (d_ptr->device.size() == size || size.width() <= 0 || size.height() <= 0)
- return;
-#ifndef QT_NO_XRENDER
- if (d_ptr->translucentBackground) {
- QPixmap::x11SetDefaultScreen(d_ptr->widget->x11Info().screen());
-
- QX11PixmapData *data = new QX11PixmapData(QPixmapData::PixmapType);
- data->xinfo = d_ptr->widget->x11Info();
- data->resize(size.width(), size.height());
- d_ptr->device = QPixmap(data);
- } else
-#endif
- {
- QPixmap::x11SetDefaultScreen(d_ptr->widget->x11Info().screen());
-
- QX11PixmapData *oldData = static_cast<QX11PixmapData *>(d_ptr->device.pixmapData());
-
- if (oldData && !(oldData->flags & QX11PixmapData::Uninitialized) && hasStaticContents()) {
- // Copy the content of the old pixmap into the new one.
- QX11PixmapData *newData = new QX11PixmapData(QPixmapData::PixmapType);
- newData->resize(size.width(), size.height());
- Q_ASSERT(oldData->d == newData->d);
-
- QRegion staticRegion(staticContents());
- // Make sure we're inside the boundaries of the old pixmap.
- staticRegion &= QRect(0, 0, oldData->w, oldData->h);
- const QRect boundingRect(staticRegion.boundingRect());
- const int dx = boundingRect.x();
- const int dy = boundingRect.y();
-
- int num;
- XRectangle *rects = (XRectangle *)qt_getClipRects(staticRegion, num);
- GC tmpGc = XCreateGC(X11->display, oldData->hd, 0, 0);
- XSetClipRectangles(X11->display, tmpGc, 0, 0, rects, num, YXBanded);
- XCopyArea(X11->display, oldData->hd, newData->hd, tmpGc,
- dx, dy, qMin(boundingRect.width(), size.width()),
- qMin(boundingRect.height(), size.height()), dx, dy);
- XFreeGC(X11->display, tmpGc);
- newData->flags &= ~QX11PixmapData::Uninitialized;
-
- d_ptr->device = QPixmap(newData);
- } else {
- d_ptr->device = QPixmap(size);
- }
- }
-
- if (gc) {
- XFreeGC(X11->display, gc);
- gc = 0;
- }
- if (!d_ptr->device.isNull()) {
- gc = XCreateGC(X11->display, d_ptr->device.handle(), 0, 0);
- XSetGraphicsExposures(X11->display, gc, False);
- }
-}
-
-bool QX11WindowSurface::scroll(const QRegion &area, int dx, int dy)
-{
- QRect rect = area.boundingRect();
-
- if (d_ptr->device.isNull())
- return false;
-
- GC gc = XCreateGC(X11->display, d_ptr->device.handle(), 0, 0);
- XCopyArea(X11->display, d_ptr->device.handle(), d_ptr->device.handle(), gc,
- rect.x(), rect.y(), rect.width(), rect.height(),
- rect.x()+dx, rect.y()+dy);
- XFreeGC(X11->display, gc);
-
- return true;
-}
-
-QPixmap QX11WindowSurface::grabWidget(const QWidget *widget,
- const QRect& rect) const
-{
- if (!widget || d_ptr->device.isNull())
- return QPixmap();
-
- QRect srcRect;
-
- // make sure the rect is inside the widget & clip to widget's rect
- if (!rect.isEmpty())
- srcRect = rect & widget->rect();
- else
- srcRect = widget->rect();
-
- if (srcRect.isEmpty())
- return QPixmap();
-
- // If it's a child widget we have to translate the coordinates
- if (widget != window())
- srcRect.translate(widget->mapTo(window(), QPoint(0, 0)));
-
- QPixmap::x11SetDefaultScreen(widget->x11Info().screen());
- QPixmap px(srcRect.width(), srcRect.height());
-
- GC tmpGc = XCreateGC(X11->display, d_ptr->device.handle(), 0, 0);
-
- // Copy srcRect from the backing store to the new pixmap
- XSetGraphicsExposures(X11->display, tmpGc, False);
- XCopyArea(X11->display, d_ptr->device.handle(), px.handle(), tmpGc,
- srcRect.x(), srcRect.y(), srcRect.width(), srcRect.height(), 0, 0);
-
- XFreeGC(X11->display, tmpGc);
-
- return px;
-}
-
-QWindowSurface::WindowSurfaceFeatures QX11WindowSurface::features() const
-{
- WindowSurfaceFeatures features = QWindowSurface::PartialUpdates | QWindowSurface::PreservedContents;
-#ifndef QT_NO_XRENDER
- if (!d_ptr->translucentBackground)
- features |= QWindowSurface::StaticContents;
-#else
- features |= QWindowSurface::StaticContents;
-#endif
- return features;
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/painting/qwindowsurface_x11_p.h b/src/gui/painting/qwindowsurface_x11_p.h
deleted file mode 100644
index df76f986ff..0000000000
--- a/src/gui/painting/qwindowsurface_x11_p.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSURFACE_X11_P_H
-#define QWINDOWSURFACE_X11_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <qglobal.h>
-#include "private/qwindowsurface_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QPaintDevice;
-class QPoint;
-class QRegion;
-class QRegion;
-class QSize;
-class QWidget;
-struct QX11WindowSurfacePrivate;
-
-class QX11WindowSurface : public QWindowSurface
-{
-public:
- QX11WindowSurface(QWidget *widget);
- ~QX11WindowSurface();
-
- QPaintDevice *paintDevice();
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
-
- void beginPaint(const QRegion &rgn);
- void setGeometry(const QRect &rect);
- bool scroll(const QRegion &area, int dx, int dy);
- QPixmap grabWidget(const QWidget *widget,
- const QRect& rectangle = QRect()) const;
- WindowSurfaceFeatures features() const;
-
-private:
- QX11WindowSurfacePrivate *d_ptr;
- GC gc;
-};
-
-QT_END_NAMESPACE
-
-#endif // QWINDOWSURFACE_X11_P_H
diff --git a/src/gui/painting/qwmatrix.h b/src/gui/painting/qwmatrix.h
deleted file mode 100644
index c4f4c75405..0000000000
--- a/src/gui/painting/qwmatrix.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWMATRIX_H
-#define QWMATRIX_H
-
-#include <QtGui/qmatrix.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if defined(QT3_SUPPORT)
-typedef QMatrix QWMatrix;
-#endif
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QWMATRIX_H
diff --git a/src/gui/s60framework/qs60mainappui.cpp b/src/gui/s60framework/qs60mainappui.cpp
deleted file mode 100644
index f591fcba36..0000000000
--- a/src/gui/s60framework/qs60mainappui.cpp
+++ /dev/null
@@ -1,430 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Symbian application wrapper of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// INCLUDE FILES
-#include <exception>
-#include <qglobal.h>
-#ifdef Q_WS_S60
-#include <avkon.hrh>
-#include <eikmenub.h>
-#include <eikmenup.h>
-#include <avkon.rsg>
-#endif
-#include <barsread.h>
-#include <coeutils.h>
-#include <qconfig.h>
-
-#include "qs60mainappui.h"
-#include <QtGui/qapplication.h>
-#include <QtGui/qsymbianevent.h>
-#include <QtGui/qmenu.h>
-#include <private/qmenu_p.h>
-#include <private/qt_s60_p.h>
-#include <qdebug.h>
-
-//Animated wallpapers in Qt applications are not supported.
-const TInt KAknDisableAnimationBackground = 0x02000000;
-const TInt KAknSingleClickCompatible = 0x01000000;
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QS60MainAppUi
- \since 4.6
- \brief The QS60MainAppUi class is a helper class for S60 migration.
-
- \warning This class is provided only to get access to S60 specific
- functionality in the application framework classes. It is not
- portable. We strongly recommend against using it in new applications.
-
- The QS60MainAppUi provides a helper class for use in migrating from
- existing S60 based applications to Qt based applications. It is used
- in the exact same way as the \c CAknAppUi class from Symbian, but
- internally provides extensions used by Qt.
-
- When modifying old S60 applications that rely on implementing
- functions in \c CAknAppUi, the class should be modified to inherit
- from this class instead of \c CAknAppUi. Then the application can
- choose to override only certain functions.
-
- For more information on \c CAknAppUi, please see the S60
- documentation.
-
- Unlike other Qt classes, QS60MainAppUi behaves like an S60 class,
- and can throw Symbian leaves.
-
- \sa QS60MainDocument, QS60MainApplication
- */
-
-/*!
- * \brief Second phase Symbian constructor.
- *
- * Constructs all the elements of the class that can cause a leave to happen.
- *
- * If you override this function, you should call the base class implementation as well.
- */
-void QS60MainAppUi::ConstructL()
-{
- // Cone's heap and handle checks on app destruction are not suitable for Qt apps, as many
- // objects can still exist in static data at that point. Instead we will print relevant information
- // so that comparative checks may be made for memory leaks, using ~SPrintExitInfo in corelib.
- iEikonEnv->DisableExitChecks(ETrue);
-
- // Initialise app UI with standard value.
- // ENoAppResourceFile and ENonStandardResourceFile makes UI to work without
- // resource files in most SDKs. S60 3rd FP1 public seems to require resource file
- // even these flags are defined
- TInt flags = CEikAppUi::ENoScreenFurniture
- | CEikAppUi::ENonStandardResourceFile;
-#ifdef Q_WS_S60
- flags |= CAknAppUi::EAknEnableSkin;
- // After 5th Edition S60, native side supports animated wallpapers.
- // However, there is no support for that feature on Qt side, so indicate to
- // native UI framework that this application will not support background animations.
-
- // Also, add support for single touch for post 5th edition platforms.
- // This has only impact when launching native dialogs/menus from inside QApplication.
- if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0) {
- flags |= (KAknDisableAnimationBackground | KAknSingleClickCompatible);
- }
-#endif
- BaseConstructL(flags);
-}
-
-/*!
- * \brief Contructs an instance of QS60MainAppUi.
- */
-QS60MainAppUi::QS60MainAppUi()
-{
- // No implementation required
-}
-
-/*!
- * \brief Destroys the QS60MainAppUi.
- */
-QS60MainAppUi::~QS60MainAppUi()
-{
-}
-
-/*!
- * \brief Handles commands produced by the S60 framework.
- *
- * \a command holds the ID of the command to handle, and is S60 specific.
- *
- * If you override this function, you should call the base class implementation if you do not
- * handle the command.
- */
-void QS60MainAppUi::HandleCommandL(TInt command)
-{
- if (qApp) {
- QSymbianEvent event(QSymbianEvent::CommandEvent, command);
- QT_TRYCATCH_LEAVING(qApp->symbianProcessEvent(&event));
- }
-}
-
-/*!
- * \brief Handles a resource change in the S60 framework.
- *
- * Resource changes include layout switches. \a type holds the type of resource change that
- * occurred.
- *
- * If you override this function, you should call the base class implementation if you do not
- * handle the resource change.
- */
-void QS60MainAppUi::HandleResourceChangeL(TInt type)
-{
- QS60MainAppUiBase::HandleResourceChangeL(type);
-
- if (qApp) {
- QSymbianEvent event(QSymbianEvent::ResourceChangeEvent, type);
- QT_TRYCATCH_LEAVING(qApp->symbianProcessEvent(&event));
- }
-}
-
-/*!
- * \brief Handles raw window server events.
- *
- * The event type and information is passed in \a wsEvent, while the receiving control is passed in
- * \a destination.
- *
- * If you override this function, you should call the base class implementation if you do not
- * handle the event.
- */
-void QS60MainAppUi::HandleWsEventL(const TWsEvent &wsEvent, CCoeControl *destination)
-{
- int result = 0;
- if (qApp) {
- QSymbianEvent event(&wsEvent);
- QT_TRYCATCH_LEAVING(
- result = qApp->symbianProcessEvent(&event)
- );
- }
-
- if (result <= 0)
- QS60MainAppUiBase::HandleWsEventL(wsEvent, destination);
-}
-
-
-/*!
- * \brief Handles changes to the status pane size.
- *
- * Called by the framework when the application status pane size is changed.
- *
- * If you override this function, you should call the base class implementation if you do not
- * handle the size change.
- */
-void QS60MainAppUi::HandleStatusPaneSizeChange()
-{
- TRAP_IGNORE(HandleResourceChangeL(KInternalStatusPaneChange));
- HandleStackedControlsResourceChange(KInternalStatusPaneChange);
-}
-
-/*!
- * \brief Dynamically initializes a menu bar.
- *
- * The resource associated with the menu is given in \a resourceId, and the actual menu bar is
- * passed in \a menuBar.
- *
- * If you override this function, you should call the base class implementation as well.
- */
-void QS60MainAppUi::DynInitMenuBarL(TInt /* resourceId */, CEikMenuBar * /* menuBar */)
-{
-}
-
-/*!
- * \brief Dynamically initializes a menu pane.
- *
- * The resource associated with the menu is given in \a resourceId, and the actual menu pane is
- * passed in \a menuPane.
- *
- * If you override this function, you should call the base class implementation as well.
- */
-void QS60MainAppUi::DynInitMenuPaneL(TInt resourceId, CEikMenuPane *menuPane)
-{
-#ifdef Q_WS_S60
- if (resourceId == R_AVKON_MENUPANE_EMPTY) {
- if (menuPane->NumberOfItemsInPane() <= 1)
- QT_TRYCATCH_LEAVING(qt_symbian_show_toplevel(menuPane));
-
- } else if (resourceId != R_AVKON_MENUPANE_FEP_DEFAULT
- && resourceId != R_AVKON_MENUPANE_EDITTEXT_DEFAULT
- && resourceId != R_AVKON_MENUPANE_LANGUAGE_DEFAULT) {
- QT_TRYCATCH_LEAVING(qt_symbian_show_submenu(menuPane, resourceId));
- }
-#else
- QS60MainAppUiBase::DynInitMenuPaneL(resourceId, menuPane);
-#endif
-}
-
-/*!
- * \brief Restores a menu window.
- *
- * The menu window to restore is given in \a menuWindow. The resource ID and type of menu is given
- * in \a resourceId and \a menuType, respectively.
- *
- * If you override this function, you should call the base class implementation as well.
- */
-void QS60MainAppUi::RestoreMenuL(CCoeControl *menuWindow, TInt resourceId, TMenuType menuType)
-{
-#ifdef Q_WS_S60
- if (resourceId >= QT_SYMBIAN_FIRST_MENU_ITEM && resourceId <= QT_SYMBIAN_LAST_MENU_ITEM) {
- if (menuType == EMenuPane)
- DynInitMenuPaneL(resourceId, (CEikMenuPane*)menuWindow);
- else
- DynInitMenuBarL(resourceId, (CEikMenuBar*)menuWindow);
- } else if(resourceId == R_AVKON_MENUPANE_EMPTY) {
- CEikMenuBarTitle *title = new(ELeave) CEikMenuBarTitle;
- CleanupStack::PushL(title);
-
- title->iData.iMenuPaneResourceId = R_AVKON_MENUPANE_EMPTY;
- title->iTitleFlags = 0;
-
- S60->menuBar()->TitleArray()->AddTitleL(title);
- CleanupStack::Pop( title );
- }
- else
-#endif
- {
- QS60MainAppUiBase::RestoreMenuL(menuWindow, resourceId, menuType);
- }
-}
-
-/*!
- \internal
-*/
-void QS60MainAppUi::Exit()
-{
- QS60MainAppUiBase::Exit();
-}
-
-/*!
- \internal
-*/
-void QS60MainAppUi::SetFadedL(TBool aFaded)
-{
- QS60MainAppUiBase::SetFadedL(aFaded);
-}
-
-/*!
- \internal
-*/
-TRect QS60MainAppUi::ApplicationRect() const
-{
- return QS60MainAppUiBase::ApplicationRect();
-}
-
-/*!
- \internal
-*/
-void QS60MainAppUi::HandleScreenDeviceChangedL()
-{
- QS60MainAppUiBase::HandleScreenDeviceChangedL();
-}
-
-/*!
- \internal
-*/
-void QS60MainAppUi::HandleApplicationSpecificEventL(TInt aType, const TWsEvent &aEvent)
-{
- QS60MainAppUiBase::HandleApplicationSpecificEventL(aType, aEvent);
-}
-
-/*!
- \internal
-*/
-TTypeUid::Ptr QS60MainAppUi::MopSupplyObject(TTypeUid aId)
-{
- return QS60MainAppUiBase::MopSupplyObject(aId);
-}
-
-/*!
- \internal
-*/
-void QS60MainAppUi::ProcessCommandL(TInt aCommand)
-{
- QS60MainAppUiBase::ProcessCommandL(aCommand);
-}
-
-/*!
- \internal
-*/
-TErrorHandlerResponse QS60MainAppUi::HandleError (TInt aError, const SExtendedError &aExtErr, TDes &aErrorText, TDes &aContextText)
-{
- return QS60MainAppUiBase::HandleError(aError, aExtErr, aErrorText, aContextText);
-}
-
-/*!
- \internal
-*/
-void QS60MainAppUi::HandleViewDeactivation(const TVwsViewId &aViewIdToBeDeactivated, const TVwsViewId &aNewlyActivatedViewId)
-{
- QS60MainAppUiBase::HandleViewDeactivation(aViewIdToBeDeactivated, aNewlyActivatedViewId);
-}
-
-/*!
- \internal
-*/
-void QS60MainAppUi::PrepareToExit()
-{
- QS60MainAppUiBase::PrepareToExit();
-}
-
-/*!
- \internal
-*/
-void QS60MainAppUi::HandleTouchPaneSizeChange()
-{
- QS60MainAppUiBase::HandleTouchPaneSizeChange();
-}
-
-/*!
- \internal
-*/
-void QS60MainAppUi::HandleSystemEventL(const TWsEvent &aEvent)
-{
- QS60MainAppUiBase::HandleSystemEventL(aEvent);
-}
-
-/*!
- \internal
-*/
-void QS60MainAppUi::Reserved_MtsmPosition()
-{
- QS60MainAppUiBase::Reserved_MtsmPosition();
-}
-
-/*!
- \internal
-*/
-void QS60MainAppUi::Reserved_MtsmObject()
-{
- QS60MainAppUiBase::Reserved_MtsmObject();
-}
-
-/*!
- \internal
-*/
-void QS60MainAppUi::HandleForegroundEventL(TBool aForeground)
-{
- QS60MainAppUiBase::HandleForegroundEventL(aForeground);
-}
-
-/*!
- \internal
-*/
-TBool QS60MainAppUi::ProcessCommandParametersL(TApaCommand /*aCommand*/, TFileName &/*aDocumentName*/, const TDesC8 &/*aTail*/)
-{
- // bypass CEikAppUi::ProcessCommandParametersL(..) which modifies aDocumentName, preventing apparc document opening from working.
- // The return value is effectively unused in Qt apps (see QS60MainDocument::OpenFileL)
- return EFalse;
-}
-
-#ifndef Q_WS_S60
-
-void QS60StubAknAppUi::HandleViewDeactivation(const TVwsViewId &, const TVwsViewId &) {}
-void QS60StubAknAppUi::HandleTouchPaneSizeChange() {}
-void QS60StubAknAppUi::HandleStatusPaneSizeChange() {}
-void QS60StubAknAppUi::Reserved_MtsmPosition() {}
-void QS60StubAknAppUi::Reserved_MtsmObject() {}
-
-#endif
-
-QT_END_NAMESPACE
diff --git a/src/gui/statemachine/qguistatemachine.cpp b/src/gui/statemachine/qguistatemachine.cpp
deleted file mode 100644
index 2a0de3c1c7..0000000000
--- a/src/gui/statemachine/qguistatemachine.cpp
+++ /dev/null
@@ -1,523 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore/qstatemachine.h>
-
-#ifndef QT_NO_STATEMACHINE
-
-#include <private/qstatemachine_p.h>
-#include <QtGui/qevent.h>
-#include <QtGui/qgraphicssceneevent.h>
-
-QT_BEGIN_NAMESPACE
-
-Q_CORE_EXPORT const QStateMachinePrivate::Handler *qcoreStateMachineHandler();
-
-static QEvent *cloneEvent(QEvent *e)
-{
- switch (e->type()) {
- case QEvent::MouseButtonPress:
- case QEvent::MouseButtonRelease:
- case QEvent::MouseButtonDblClick:
- case QEvent::MouseMove:
- return new QMouseEvent(*static_cast<QMouseEvent*>(e));
- case QEvent::KeyPress:
- case QEvent::KeyRelease:
- return new QKeyEvent(*static_cast<QKeyEvent*>(e));
- case QEvent::FocusIn:
- case QEvent::FocusOut:
- return new QFocusEvent(*static_cast<QFocusEvent*>(e));
- case QEvent::Enter:
- return new QEvent(*e);
- case QEvent::Leave:
- return new QEvent(*e);
- break;
- case QEvent::Paint:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
- case QEvent::Move:
- return new QMoveEvent(*static_cast<QMoveEvent*>(e));
- case QEvent::Resize:
- return new QResizeEvent(*static_cast<QResizeEvent*>(e));
- case QEvent::Create:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
- case QEvent::Destroy:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
- case QEvent::Show:
- return new QShowEvent(*static_cast<QShowEvent*>(e));
- case QEvent::Hide:
- return new QHideEvent(*static_cast<QHideEvent*>(e));
- case QEvent::Close:
- return new QCloseEvent(*static_cast<QCloseEvent*>(e));
- case QEvent::Quit:
- return new QEvent(*e);
- case QEvent::ParentChange:
- return new QEvent(*e);
- case QEvent::ParentAboutToChange:
- return new QEvent(*e);
- case QEvent::ThreadChange:
- return new QEvent(*e);
-
- case QEvent::WindowActivate:
- case QEvent::WindowDeactivate:
- return new QEvent(*e);
-
- case QEvent::ShowToParent:
- return new QEvent(*e);
- case QEvent::HideToParent:
- return new QEvent(*e);
-#ifndef QT_NO_WHEELEVENT
- case QEvent::Wheel:
- return new QWheelEvent(*static_cast<QWheelEvent*>(e));
-#endif //QT_NO_WHEELEVENT
- case QEvent::WindowTitleChange:
- return new QEvent(*e);
- case QEvent::WindowIconChange:
- return new QEvent(*e);
- case QEvent::ApplicationWindowIconChange:
- return new QEvent(*e);
- case QEvent::ApplicationFontChange:
- return new QEvent(*e);
- case QEvent::ApplicationLayoutDirectionChange:
- return new QEvent(*e);
- case QEvent::ApplicationPaletteChange:
- return new QEvent(*e);
- case QEvent::PaletteChange:
- return new QEvent(*e);
- case QEvent::Clipboard:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
- case QEvent::Speech:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
- case QEvent::MetaCall:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
- case QEvent::SockAct:
- return new QEvent(*e);
- case QEvent::WinEventAct:
- return new QEvent(*e);
- case QEvent::DeferredDelete:
- return new QEvent(*e);
-#ifndef QT_NO_DRAGANDDROP
- case QEvent::DragEnter:
- return new QDragEnterEvent(*static_cast<QDragEnterEvent*>(e));
- case QEvent::DragMove:
- return new QDragMoveEvent(*static_cast<QDragMoveEvent*>(e));
- case QEvent::DragLeave:
- return new QDragLeaveEvent(*static_cast<QDragLeaveEvent*>(e));
- case QEvent::Drop:
- return new QDropEvent(*static_cast<QDragMoveEvent*>(e));
- case QEvent::DragResponse:
- return new QDragResponseEvent(*static_cast<QDragResponseEvent*>(e));
-#endif
- case QEvent::ChildAdded:
- return new QChildEvent(*static_cast<QChildEvent*>(e));
- case QEvent::ChildPolished:
- return new QChildEvent(*static_cast<QChildEvent*>(e));
-#ifdef QT3_SUPPORT
- case QEvent::ChildInsertedRequest:
- return new QEvent(*e);
- case QEvent::ChildInserted:
- return new QChildEvent(*static_cast<QChildEvent*>(e));
- case QEvent::LayoutHint:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
-#endif
- case QEvent::ChildRemoved:
- return new QChildEvent(*static_cast<QChildEvent*>(e));
- case QEvent::ShowWindowRequest:
- return new QEvent(*e);
- case QEvent::PolishRequest:
- return new QEvent(*e);
- case QEvent::Polish:
- return new QEvent(*e);
- case QEvent::LayoutRequest:
- return new QEvent(*e);
- case QEvent::UpdateRequest:
- return new QEvent(*e);
- case QEvent::UpdateLater:
- return new QEvent(*e);
-
- case QEvent::EmbeddingControl:
- return new QEvent(*e);
- case QEvent::ActivateControl:
- return new QEvent(*e);
- case QEvent::DeactivateControl:
- return new QEvent(*e);
-
-#ifndef QT_NO_CONTEXTMENU
- case QEvent::ContextMenu:
- return new QContextMenuEvent(*static_cast<QContextMenuEvent*>(e));
-#endif
- case QEvent::InputMethod:
- return new QInputMethodEvent(*static_cast<QInputMethodEvent*>(e));
- case QEvent::AccessibilityPrepare:
- return new QEvent(*e);
-#ifndef QT_NO_TABLETEVENT
- case QEvent::TabletMove:
- return new QTabletEvent(*static_cast<QTabletEvent*>(e));
-#endif //QT_NO_TABLETEVENT
- case QEvent::LocaleChange:
- return new QEvent(*e);
- case QEvent::LanguageChange:
- return new QEvent(*e);
- case QEvent::LayoutDirectionChange:
- return new QEvent(*e);
- case QEvent::Style:
- return new QEvent(*e);
-#ifndef QT_NO_TABLETEVENT
- case QEvent::TabletPress:
- return new QTabletEvent(*static_cast<QTabletEvent*>(e));
- case QEvent::TabletRelease:
- return new QTabletEvent(*static_cast<QTabletEvent*>(e));
-#endif //QT_NO_TABLETEVENT
- case QEvent::OkRequest:
- return new QEvent(*e);
- case QEvent::HelpRequest:
- return new QEvent(*e);
-
- case QEvent::IconDrag:
- return new QIconDragEvent(*static_cast<QIconDragEvent*>(e));
-
- case QEvent::FontChange:
- return new QEvent(*e);
- case QEvent::EnabledChange:
- return new QEvent(*e);
- case QEvent::ActivationChange:
- return new QEvent(*e);
- case QEvent::StyleChange:
- return new QEvent(*e);
- case QEvent::IconTextChange:
- return new QEvent(*e);
- case QEvent::ModifiedChange:
- return new QEvent(*e);
- case QEvent::MouseTrackingChange:
- return new QEvent(*e);
-
- case QEvent::WindowBlocked:
- return new QEvent(*e);
- case QEvent::WindowUnblocked:
- return new QEvent(*e);
- case QEvent::WindowStateChange:
- return new QWindowStateChangeEvent(*static_cast<QWindowStateChangeEvent*>(e));
-
- case QEvent::ToolTip:
- return new QHelpEvent(*static_cast<QHelpEvent*>(e));
- case QEvent::WhatsThis:
- return new QHelpEvent(*static_cast<QHelpEvent*>(e));
-#ifndef QT_NO_STATUSTIP
- case QEvent::StatusTip:
- return new QStatusTipEvent(*static_cast<QStatusTipEvent*>(e));
-#endif //QT_NO_STATUSTIP
-#ifndef QT_NO_ACTION
- case QEvent::ActionChanged:
- case QEvent::ActionAdded:
- case QEvent::ActionRemoved:
- return new QActionEvent(*static_cast<QActionEvent*>(e));
-#endif
- case QEvent::FileOpen:
- return new QFileOpenEvent(*static_cast<QFileOpenEvent*>(e));
-
-#ifndef QT_NO_SHORTCUT
- case QEvent::Shortcut:
- return new QShortcutEvent(*static_cast<QShortcutEvent*>(e));
-#endif //QT_NO_SHORTCUT
- case QEvent::ShortcutOverride:
- return new QKeyEvent(*static_cast<QKeyEvent*>(e));
-
-#ifdef QT3_SUPPORT
- case QEvent::Accel:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
- case QEvent::AccelAvailable:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
-#endif
-
-#ifndef QT_NO_WHATSTHIS
- case QEvent::WhatsThisClicked:
- return new QWhatsThisClickedEvent(*static_cast<QWhatsThisClickedEvent*>(e));
-#endif //QT_NO_WHATSTHIS
-
-#ifndef QT_NO_TOOLBAR
- case QEvent::ToolBarChange:
- return new QToolBarChangeEvent(*static_cast<QToolBarChangeEvent*>(e));
-#endif //QT_NO_TOOLBAR
-
- case QEvent::ApplicationActivate:
- return new QEvent(*e);
- case QEvent::ApplicationDeactivate:
- return new QEvent(*e);
-
- case QEvent::QueryWhatsThis:
- return new QHelpEvent(*static_cast<QHelpEvent*>(e));
- case QEvent::EnterWhatsThisMode:
- return new QEvent(*e);
- case QEvent::LeaveWhatsThisMode:
- return new QEvent(*e);
-
- case QEvent::ZOrderChange:
- return new QEvent(*e);
-
- case QEvent::HoverEnter:
- case QEvent::HoverLeave:
- case QEvent::HoverMove:
- return new QHoverEvent(*static_cast<QHoverEvent*>(e));
-
- case QEvent::AccessibilityHelp:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
- case QEvent::AccessibilityDescription:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
-
-#ifdef QT_KEYPAD_NAVIGATION
- case QEvent::EnterEditFocus:
- return new QEvent(*e);
- case QEvent::LeaveEditFocus:
- return new QEvent(*e);
-#endif
- case QEvent::AcceptDropsChange:
- return new QEvent(*e);
-
-#ifdef QT3_SUPPORT
- case QEvent::MenubarUpdated:
- return new QMenubarUpdatedEvent(*static_cast<QMenubarUpdatedEvent*>(e));
-#endif
-
- case QEvent::ZeroTimerEvent:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
-#ifndef QT_NO_GRAPHICSVIEW
- case QEvent::GraphicsSceneMouseMove:
- case QEvent::GraphicsSceneMousePress:
- case QEvent::GraphicsSceneMouseRelease:
- case QEvent::GraphicsSceneMouseDoubleClick: {
- QGraphicsSceneMouseEvent *me = static_cast<QGraphicsSceneMouseEvent*>(e);
- QGraphicsSceneMouseEvent *me2 = new QGraphicsSceneMouseEvent(me->type());
- me2->setWidget(me->widget());
- me2->setPos(me->pos());
- me2->setScenePos(me->scenePos());
- me2->setScreenPos(me->screenPos());
-// ### for all buttons
- me2->setButtonDownPos(Qt::LeftButton, me->buttonDownPos(Qt::LeftButton));
- me2->setButtonDownPos(Qt::RightButton, me->buttonDownPos(Qt::RightButton));
- me2->setButtonDownScreenPos(Qt::LeftButton, me->buttonDownScreenPos(Qt::LeftButton));
- me2->setButtonDownScreenPos(Qt::RightButton, me->buttonDownScreenPos(Qt::RightButton));
- me2->setLastPos(me->lastPos());
- me2->setLastScenePos(me->lastScenePos());
- me2->setLastScreenPos(me->lastScreenPos());
- me2->setButtons(me->buttons());
- me2->setButton(me->button());
- me2->setModifiers(me->modifiers());
- return me2;
- }
-
- case QEvent::GraphicsSceneContextMenu: {
- QGraphicsSceneContextMenuEvent *me = static_cast<QGraphicsSceneContextMenuEvent*>(e);
- QGraphicsSceneContextMenuEvent *me2 = new QGraphicsSceneContextMenuEvent(me->type());
- me2->setWidget(me->widget());
- me2->setPos(me->pos());
- me2->setScenePos(me->scenePos());
- me2->setScreenPos(me->screenPos());
- me2->setModifiers(me->modifiers());
- me2->setReason(me->reason());
- return me2;
- }
-
- case QEvent::GraphicsSceneHoverEnter:
- case QEvent::GraphicsSceneHoverMove:
- case QEvent::GraphicsSceneHoverLeave: {
- QGraphicsSceneHoverEvent *he = static_cast<QGraphicsSceneHoverEvent*>(e);
- QGraphicsSceneHoverEvent *he2 = new QGraphicsSceneHoverEvent(he->type());
- he2->setPos(he->pos());
- he2->setScenePos(he->scenePos());
- he2->setScreenPos(he->screenPos());
- he2->setLastPos(he->lastPos());
- he2->setLastScenePos(he->lastScenePos());
- he2->setLastScreenPos(he->lastScreenPos());
- he2->setModifiers(he->modifiers());
- return he2;
- }
- case QEvent::GraphicsSceneHelp:
- return new QHelpEvent(*static_cast<QHelpEvent*>(e));
- case QEvent::GraphicsSceneDragEnter:
- case QEvent::GraphicsSceneDragMove:
- case QEvent::GraphicsSceneDragLeave:
- case QEvent::GraphicsSceneDrop: {
- QGraphicsSceneDragDropEvent *dde = static_cast<QGraphicsSceneDragDropEvent*>(e);
- QGraphicsSceneDragDropEvent *dde2 = new QGraphicsSceneDragDropEvent(dde->type());
- dde2->setPos(dde->pos());
- dde2->setScenePos(dde->scenePos());
- dde2->setScreenPos(dde->screenPos());
- dde2->setButtons(dde->buttons());
- dde2->setModifiers(dde->modifiers());
- return dde2;
- }
- case QEvent::GraphicsSceneWheel: {
- QGraphicsSceneWheelEvent *we = static_cast<QGraphicsSceneWheelEvent*>(e);
- QGraphicsSceneWheelEvent *we2 = new QGraphicsSceneWheelEvent(we->type());
- we2->setPos(we->pos());
- we2->setScenePos(we->scenePos());
- we2->setScreenPos(we->screenPos());
- we2->setButtons(we->buttons());
- we2->setModifiers(we->modifiers());
- we2->setOrientation(we->orientation());
- we2->setDelta(we->delta());
- return we2;
- }
-#endif
- case QEvent::KeyboardLayoutChange:
- return new QEvent(*e);
-
- case QEvent::DynamicPropertyChange:
- return new QDynamicPropertyChangeEvent(*static_cast<QDynamicPropertyChangeEvent*>(e));
-
-#ifndef QT_NO_TABLETEVENT
- case QEvent::TabletEnterProximity:
- case QEvent::TabletLeaveProximity:
- return new QTabletEvent(*static_cast<QTabletEvent*>(e));
-#endif //QT_NO_TABLETEVENT
-
- case QEvent::NonClientAreaMouseMove:
- case QEvent::NonClientAreaMouseButtonPress:
- case QEvent::NonClientAreaMouseButtonRelease:
- case QEvent::NonClientAreaMouseButtonDblClick:
- return new QMouseEvent(*static_cast<QMouseEvent*>(e));
-
- case QEvent::MacSizeChange:
- return new QEvent(*e);
-
- case QEvent::ContentsRectChange:
- return new QEvent(*e);
-
- case QEvent::MacGLWindowChange:
- return new QEvent(*e);
-
- case QEvent::FutureCallOut:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
-#ifndef QT_NO_GRAPHICSVIEW
- case QEvent::GraphicsSceneResize: {
- QGraphicsSceneResizeEvent *re = static_cast<QGraphicsSceneResizeEvent*>(e);
- QGraphicsSceneResizeEvent *re2 = new QGraphicsSceneResizeEvent();
- re2->setOldSize(re->oldSize());
- re2->setNewSize(re->newSize());
- return re2;
- }
- case QEvent::GraphicsSceneMove: {
- QGraphicsSceneMoveEvent *me = static_cast<QGraphicsSceneMoveEvent*>(e);
- QGraphicsSceneMoveEvent *me2 = new QGraphicsSceneMoveEvent();
- me2->setWidget(me->widget());
- me2->setNewPos(me->newPos());
- me2->setOldPos(me->oldPos());
- return me2;
- }
-#endif
- case QEvent::CursorChange:
- return new QEvent(*e);
- case QEvent::ToolTipChange:
- return new QEvent(*e);
-
- case QEvent::NetworkReplyUpdated:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
-
- case QEvent::GrabMouse:
- case QEvent::UngrabMouse:
- case QEvent::GrabKeyboard:
- case QEvent::UngrabKeyboard:
- return new QEvent(*e);
-
- case QEvent::TouchBegin:
- case QEvent::TouchUpdate:
- case QEvent::TouchEnd:
- return new QTouchEvent(*static_cast<QTouchEvent*>(e));
-
-#ifndef QT_NO_GESTURES
- case QEvent::NativeGesture:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
-#endif
-
- case QEvent::RequestSoftwareInputPanel:
- case QEvent::CloseSoftwareInputPanel:
- return new QEvent(*e);
-
- case QEvent::UpdateSoftKeys:
- return new QEvent(*e);
-
- case QEvent::User:
- case QEvent::MaxUser:
- Q_ASSERT_X(false, "cloneEvent()", "not implemented");
- break;
- default:
- ;
- }
- return qcoreStateMachineHandler()->cloneEvent(e);
-}
-
-const QStateMachinePrivate::Handler qt_gui_statemachine_handler = {
- cloneEvent
-};
-
-static const QStateMachinePrivate::Handler *qt_guistatemachine_last_handler = 0;
-int qRegisterGuiStateMachine()
-{
- qt_guistatemachine_last_handler = QStateMachinePrivate::handler;
- QStateMachinePrivate::handler = &qt_gui_statemachine_handler;
- return 1;
-}
-Q_CONSTRUCTOR_FUNCTION(qRegisterGuiStateMachine)
-
-int qUnregisterGuiStateMachine()
-{
- QStateMachinePrivate::handler = qt_guistatemachine_last_handler;
- return 1;
-}
-Q_DESTRUCTOR_FUNCTION(qUnregisterGuiStateMachine)
-
-QT_END_NAMESPACE
-
-#endif //QT_NO_STATEMACHINE
diff --git a/src/gui/styles/qcdestyle.h b/src/gui/styles/qcdestyle.h
deleted file mode 100644
index ca43b6a530..0000000000
--- a/src/gui/styles/qcdestyle.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#ifndef QCDESTYLE_H
-#define QCDESTYLE_H
-
-#include <QtGui/qmotifstyle.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if !defined(QT_NO_STYLE_CDE)
-
-class Q_GUI_EXPORT QCDEStyle : public QMotifStyle
-{
- Q_OBJECT
-public:
- explicit QCDEStyle(bool useHighlightCols = false);
- virtual ~QCDEStyle();
-
- int pixelMetric(PixelMetric metric, const QStyleOption *option = 0,
- const QWidget *widget = 0) const;
- void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
- const QWidget *w = 0) const;
- void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
- const QWidget *w = 0) const;
- QPalette standardPalette() const;
-
-protected Q_SLOTS:
- QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt = 0,
- const QWidget *widget = 0) const;
-};
-
-#endif // QT_NO_STYLE_CDE
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QCDESTYLE_H
diff --git a/src/gui/styles/qcleanlooksstyle.h b/src/gui/styles/qcleanlooksstyle.h
deleted file mode 100644
index 9ffa5789c0..0000000000
--- a/src/gui/styles/qcleanlooksstyle.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QCLEANLOOKSSTYLE_H
-#define QCLEANLOOKSSTYLE_H
-
-#include <QtGui/qwindowsstyle.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if !defined(QT_NO_STYLE_CLEANLOOKS)
-
-class QCleanlooksStylePrivate;
-class Q_GUI_EXPORT QCleanlooksStyle : public QWindowsStyle
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QCleanlooksStyle)
-
-public:
- QCleanlooksStyle();
- ~QCleanlooksStyle();
-
- QPalette standardPalette () const;
- void drawPrimitive(PrimitiveElement elem,
- const QStyleOption *option,
- QPainter *painter, const QWidget *widget = 0) const;
- void drawControl(ControlElement ce, const QStyleOption *option, QPainter *painter,
- const QWidget *widget) const;
- int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
- void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
- QPainter *painter, const QWidget *widget) const;
- QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const;
- QSize sizeFromContents(ContentsType type, const QStyleOption *option,
- const QSize &size, const QWidget *widget) const;
- SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
- const QPoint &pt, const QWidget *w = 0) const;
- QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt,
- SubControl sc, const QWidget *widget) const;
- QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
- const QStyleOption *opt) const;
- int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0,
- QStyleHintReturn *returnData = 0) const;
- QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const;
- QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
- const QWidget *widget = 0) const;
- void drawItemPixmap(QPainter *painter, const QRect &rect,
- int alignment, const QPixmap &pixmap) const;
- void drawItemText(QPainter *painter, const QRect &rect,
- int flags, const QPalette &pal, bool enabled,
- const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const;
- void polish(QWidget *widget);
- void polish(QApplication *app);
- void polish(QPalette &pal);
- void unpolish(QWidget *widget);
- void unpolish(QApplication *app);
-
-protected Q_SLOTS:
- QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option,
- const QWidget *widget = 0) const;
-
-protected:
- QCleanlooksStyle(QCleanlooksStylePrivate &dd);
-
-};
-
-#endif // QT_NO_STYLE_CLEANLOOKS
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QCLEANLOOKSSTYLE_H
diff --git a/src/gui/styles/qcommonstyle.h b/src/gui/styles/qcommonstyle.h
deleted file mode 100644
index 2b42367aac..0000000000
--- a/src/gui/styles/qcommonstyle.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QCOMMONSTYLE_H
-#define QCOMMONSTYLE_H
-
-#include <QtGui/qstyle.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-QT_MODULE(Gui)
-
-class QCommonStylePrivate;
-
-class Q_GUI_EXPORT QCommonStyle: public QStyle
-{
- Q_OBJECT
-
-public:
- QCommonStyle();
- ~QCommonStyle();
-
- void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
- const QWidget *w = 0) const;
- void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
- const QWidget *w = 0) const;
- QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const;
- void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
- const QWidget *w = 0) const;
- SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
- const QPoint &pt, const QWidget *w = 0) const;
- QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc,
- const QWidget *w = 0) const;
- QSize sizeFromContents(ContentsType ct, const QStyleOption *opt,
- const QSize &contentsSize, const QWidget *widget = 0) const;
-
- int pixelMetric(PixelMetric m, const QStyleOption *opt = 0, const QWidget *widget = 0) const;
-
- int styleHint(StyleHint sh, const QStyleOption *opt = 0, const QWidget *w = 0,
- QStyleHintReturn *shret = 0) const;
-
- QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *opt = 0,
- const QWidget *widget = 0) const;
-
- QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
- const QStyleOption *opt) const;
-
- void polish(QPalette &);
- void polish(QApplication *app);
- void polish(QWidget *widget);
- void unpolish(QWidget *widget);
- void unpolish(QApplication *application);
-
-protected Q_SLOTS:
- QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt = 0,
- const QWidget *widget = 0) const;
-
-protected:
- QCommonStyle(QCommonStylePrivate &dd);
-
-private:
- Q_DECLARE_PRIVATE(QCommonStyle)
- Q_DISABLE_COPY(QCommonStyle)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QCOMMONSTYLE_H
diff --git a/src/gui/styles/qgtkpainter.cpp b/src/gui/styles/qgtkpainter.cpp
deleted file mode 100644
index 6258fe4730..0000000000
--- a/src/gui/styles/qgtkpainter.cpp
+++ /dev/null
@@ -1,716 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgtkpainter_p.h"
-
-#include <QtCore/qglobal.h>
-#if !defined(QT_NO_STYLE_GTK)
-
-// This class is primarily a wrapper around the gtk painter functions
-// and takes care of converting all such calls into cached Qt pixmaps.
-
-#include <private/qstylehelper_p.h>
-#include <QtGui/QWidget>
-#include <QtGui/QStyleOption>
-#include <QtGui/QPixmapCache>
-
-QT_BEGIN_NAMESPACE
-
-#undef GTK_OBJECT_FLAGS
-#define GTK_OBJECT_FLAGS(obj)(((GtkObject*)(obj))->flags)
-
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
-# define QT_RED 3
-# define QT_GREEN 2
-# define QT_BLUE 1
-# define QT_ALPHA 0
-#else
-# define QT_RED 0
-# define QT_GREEN 1
-# define QT_BLUE 2
-# define QT_ALPHA 3
-#endif
-# define GTK_RED 2
-# define GTK_GREEN 1
-# define GTK_BLUE 0
-# define GTK_ALPHA 3
-
-// To recover alpha we apply the gtk painting function two times to
-// white, and black window backgrounds. This can be used to
-// recover the premultiplied alpha channel
-QPixmap QGtkPainter::renderTheme(uchar *bdata, uchar *wdata, const QRect &rect)
-{
- const int bytecount = rect.width() * rect.height() * 4;
- for (int index = 0; index < bytecount ; index += 4) {
- uchar val = bdata[index + GTK_BLUE];
- if (m_alpha) {
- int alphaval = qMax(bdata[index + GTK_BLUE] - wdata[index + GTK_BLUE],
- bdata[index + GTK_GREEN] - wdata[index + GTK_GREEN]);
- alphaval = qMax(alphaval, bdata[index + GTK_RED] - wdata[index + GTK_RED]) + 255;
- bdata[index + QT_ALPHA] = alphaval;
- }
- bdata[index + QT_RED] = bdata[index + GTK_RED];
- bdata[index + QT_GREEN] = bdata[index + GTK_GREEN];
- bdata[index + QT_BLUE] = val;
- }
- QImage converted((const uchar*)bdata, rect.width(), rect.height(), m_alpha ?
- QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32);
-
- if (m_hflipped || m_vflipped) {
- return QPixmap::fromImage(converted.mirrored(m_hflipped, m_vflipped));
- } else {
- // on raster graphicssystem we need to do a copy here, because
- // we intend to deallocate the qimage bits shortly after...
- return QPixmap::fromImage(converted.copy());
- }
-}
-
-// This macro is responsible for painting any GtkStyle painting function onto a QPixmap
-#define DRAW_TO_CACHE(draw_func) \
- if (rect.width() > QWIDGETSIZE_MAX || rect.height() > QWIDGETSIZE_MAX) \
- return; \
- QRect pixmapRect(0, 0, rect.width(), rect.height()); \
- { \
- GdkPixmap *pixmap = QGtkStylePrivate::gdk_pixmap_new((GdkDrawable*)(m_window->window), \
- rect.width(), rect.height(), -1); \
- if (!pixmap) \
- return; \
- style = QGtkStylePrivate::gtk_style_attach (style, m_window->window); \
- QGtkStylePrivate::gdk_draw_rectangle(pixmap, m_alpha ? style->black_gc : *style->bg_gc, true, \
- 0, 0, rect.width(), rect.height()); \
- draw_func; \
- GdkPixbuf *imgb = QGtkStylePrivate::gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, rect.width(), rect.height());\
- if (!imgb) \
- return; \
- imgb = QGtkStylePrivate::gdk_pixbuf_get_from_drawable(imgb, pixmap, NULL, 0, 0, 0, 0, \
- rect.width(), rect.height()); \
- uchar* bdata = (uchar*)QGtkStylePrivate::gdk_pixbuf_get_pixels(imgb); \
- if (m_alpha) { \
- QGtkStylePrivate::gdk_draw_rectangle(pixmap, style->white_gc, true, 0, 0, rect.width(), rect.height()); \
- draw_func; \
- GdkPixbuf *imgw = QGtkStylePrivate::gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, rect. \
- width(), rect.height()); \
- if (!imgw) \
- return; \
- imgw = QGtkStylePrivate::gdk_pixbuf_get_from_drawable(imgw, pixmap, NULL, 0, 0, 0, 0, \
- rect.width(), rect.height()); \
- uchar* wdata = (uchar*)QGtkStylePrivate::gdk_pixbuf_get_pixels(imgw); \
- cache = renderTheme(bdata, wdata, rect); \
- QGtkStylePrivate::gdk_pixbuf_unref(imgw); \
- } else { \
- cache = renderTheme(bdata, 0, rect); \
- } \
- QGtkStylePrivate::gdk_drawable_unref(pixmap); \
- QGtkStylePrivate::gdk_pixbuf_unref(imgb); \
- }
-
-QGtkPainter::QGtkPainter(QPainter *_painter)
- : m_window(QGtkStylePrivate::gtkWidget("GtkWindow"))
- , m_painter(_painter)
- , m_alpha(true)
- , m_hflipped(false)
- , m_vflipped(false)
- , m_usePixmapCache(true)
-{}
-
-
-static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow,
- const QSize &size, GtkWidget *widget = 0)
-{
- // Note the widget arg should ideally use the widget path, though would compromise performance
- QString tmp = key
- % HexString<uint>(state)
- % HexString<uint>(shadow)
- % HexString<uint>(size.width())
- % HexString<uint>(size.height())
- % HexString<quint64>(quint64(widget));
- return tmp;
-}
-
-
-GtkStateType QGtkPainter::gtkState(const QStyleOption *option)
-
-{
- GtkStateType state = GTK_STATE_NORMAL;
- if (!(option->state & QStyle::State_Enabled))
- state = GTK_STATE_INSENSITIVE;
- else if (option->state & QStyle::State_MouseOver)
- state = GTK_STATE_PRELIGHT;
-
- return state;
-}
-
-
-GtkStyle* QGtkPainter::getStyle(GtkWidget *gtkWidget)
-
-{
- Q_ASSERT(gtkWidget);
- GtkStyle* style = gtkWidget->style;
- Q_ASSERT(style);
- return style;
-}
-
-QPixmap QGtkPainter::getIcon(const char* iconName, GtkIconSize size)
-{
- GtkStyle *style = QGtkStylePrivate::gtkStyle();
- GtkIconSet* iconSet = QGtkStylePrivate::gtk_icon_factory_lookup_default (iconName);
- GdkPixbuf* icon = QGtkStylePrivate::gtk_icon_set_render_icon(iconSet,
- style,
- GTK_TEXT_DIR_LTR,
- GTK_STATE_NORMAL,
- size,
- NULL,
- "button");
- uchar* data = (uchar*)QGtkStylePrivate::gdk_pixbuf_get_pixels(icon);
- int width = QGtkStylePrivate::gdk_pixbuf_get_width(icon);
- int height = QGtkStylePrivate::gdk_pixbuf_get_height(icon);
- QImage converted(width, height, QImage::Format_ARGB32);
- uchar* tdata = (uchar*)converted.bits();
-
- for ( int index = 0 ; index < height * width*4 ; index +=4 ) {
- //int index = y * rowstride + x;
- tdata[index + QT_RED] = data[index + GTK_RED];
- tdata[index + QT_GREEN] = data[index + GTK_GREEN];
- tdata[index + QT_BLUE] = data[index + GTK_BLUE];
- tdata[index + QT_ALPHA] = data[index + GTK_ALPHA];
- }
-
- QGtkStylePrivate::gdk_pixbuf_unref(icon);
-
- // should we free iconset?
- return QPixmap::fromImage(converted);
-
-}
-
-// Note currently painted without alpha for performance reasons
-void QGtkPainter::paintBoxGap(GtkWidget *gtkWidget, const gchar* part,
- const QRect &paintRect, GtkStateType state,
- GtkShadowType shadow, GtkPositionType gap_side,
- gint x, gint width,
- GtkStyle *style)
-{
- if (!paintRect.isValid())
- return;
-
- QPixmap cache;
- QRect rect = paintRect;
-
- // To avoid exhausting cache on large tabframes we cheat a bit by
- // tiling the center part.
-
- const int maxHeight = 256;
- const int border = 16;
- if (rect.height() > maxHeight && (gap_side == GTK_POS_TOP || gap_side == GTK_POS_BOTTOM))
- rect.setHeight(2 * border + 1);
-
- QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget)
- % HexString<uchar>(gap_side)
- % HexString<gint>(width)
- % HexString<gint>(x);
-
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_box_gap (style,
- pixmap,
- state,
- shadow,
- NULL,
- gtkWidget,
- (gchar*)part,
- 0, 0,
- rect.width(),
- rect.height(),
- gap_side,
- x,
- width));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
- if (rect.size() != paintRect.size()) {
- // We assume we can stretch the middle tab part
- // Note: the side effect of this is that pinstripe patterns will get fuzzy
- const QSize size = cache.size();
- // top part
- m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top(),
- paintRect.width(), border), cache,
- QRect(0, 0, size.width(), border));
-
- // tiled center part
- QPixmap tilePart(cache.width(), 1);
- QPainter scanLinePainter(&tilePart);
- scanLinePainter.drawPixmap(QRect(0, 0, tilePart.width(), tilePart.height()), cache, QRect(0, border, size.width(), 1));
- scanLinePainter.end();
- m_painter->drawTiledPixmap(QRect(paintRect.left(), paintRect.top() + border,
- paintRect.width(), paintRect.height() - 2*border), tilePart);
-
- // bottom part
- m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top() + paintRect.height() - border,
- paintRect.width(), border), cache,
- QRect(0, size.height() - border, size.width(), border));
- } else
- m_painter->drawPixmap(paintRect.topLeft(), cache);
-}
-
-void QGtkPainter::paintBox(GtkWidget *gtkWidget, const gchar* part,
- const QRect &paintRect, GtkStateType state,
- GtkShadowType shadow, GtkStyle *style,
- const QString &pmKey)
-{
- if (!paintRect.isValid())
- return;
-
- QPixmap cache;
- QRect rect = paintRect;
-
- // To avoid exhausting cache on large tabframes we cheat a bit by
- // tiling the center part.
-
- const int maxHeight = 256;
- const int maxArea = 256*512;
- const int border = 32;
- if (rect.height() > maxHeight && (rect.width()*rect.height() > maxArea))
- rect.setHeight(2 * border + 1);
-
- QString pixmapName = uniqueName(QLS(part), state, shadow,
- rect.size(), gtkWidget) % pmKey;
-
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_box (style,
- pixmap,
- state,
- shadow,
- NULL,
- gtkWidget,
- part,
- 0, 0,
- rect.width(),
- rect.height()));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
- if (rect.size() != paintRect.size()) {
- // We assume we can stretch the middle tab part
- // Note: the side effect of this is that pinstripe patterns will get fuzzy
- const QSize size = cache.size();
- // top part
- m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top(),
- paintRect.width(), border), cache,
- QRect(0, 0, size.width(), border));
-
- // tiled center part
- QPixmap tilePart(cache.width(), 1);
- QPainter scanLinePainter(&tilePart);
- scanLinePainter.drawPixmap(QRect(0, 0, tilePart.width(), tilePart.height()), cache, QRect(0, border, size.width(), 1));
- scanLinePainter.end();
- m_painter->drawTiledPixmap(QRect(paintRect.left(), paintRect.top() + border,
- paintRect.width(), paintRect.height() - 2*border), tilePart);
-
- // bottom part
- m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top() + paintRect.height() - border,
- paintRect.width(), border), cache,
- QRect(0, size.height() - border, size.width(), border));
- } else
- m_painter->drawPixmap(paintRect.topLeft(), cache);
-}
-
-void QGtkPainter::paintHline(GtkWidget *gtkWidget, const gchar* part,
- const QRect &rect, GtkStateType state,
- GtkStyle *style, int x1, int x2, int y,
- const QString &pmKey)
-{
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget)
- % HexString<int>(x1)
- % HexString<int>(x2)
- % HexString<int>(y)
- % pmKey;
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_hline (style,
- pixmap,
- state,
- NULL,
- gtkWidget,
- part,
- x1, x2, y));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
-
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-void QGtkPainter::paintVline(GtkWidget *gtkWidget, const gchar* part,
- const QRect &rect, GtkStateType state,
- GtkStyle *style, int y1, int y2, int x,
- const QString &pmKey)
-{
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget)
- % HexString<int>(y1)
- % HexString<int>(y2)
- % HexString<int>(x)
- % pmKey;
-
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_vline (style,
- pixmap,
- state,
- NULL,
- gtkWidget,
- part,
- y1, y2,
- x));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-
-void QGtkPainter::paintExpander(GtkWidget *gtkWidget,
- const gchar* part, const QRect &rect,
- GtkStateType state, GtkExpanderStyle expander_state,
- GtkStyle *style, const QString &pmKey)
-{
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget)
- % HexString<uchar>(expander_state)
- % pmKey;
-
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_expander (style, pixmap,
- state, NULL,
- gtkWidget, part,
- rect.width()/2,
- rect.height()/2,
- expander_state));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
-
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-void QGtkPainter::paintFocus(GtkWidget *gtkWidget, const gchar* part,
- const QRect &rect, GtkStateType state,
- GtkStyle *style, const QString &pmKey)
-{
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget) % pmKey;
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_focus (style, pixmap, state, NULL,
- gtkWidget,
- part,
- 0, 0,
- rect.width(),
- rect.height()));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
-
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-
-void QGtkPainter::paintResizeGrip(GtkWidget *gtkWidget, const gchar* part,
- const QRect &rect, GtkStateType state,
- GtkShadowType shadow, GdkWindowEdge edge,
- GtkStyle *style, const QString &pmKey)
-{
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget) % pmKey;
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_resize_grip (style, pixmap, state,
- NULL, gtkWidget,
- part, edge, 0, 0,
- rect.width(),
- rect.height()));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
-
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-
-void QGtkPainter::paintArrow(GtkWidget *gtkWidget, const gchar* part,
- const QRect &arrowrect, GtkArrowType arrow_type,
- GtkStateType state, GtkShadowType shadow,
- gboolean fill, GtkStyle *style, const QString &pmKey)
-{
- QRect rect = m_cliprect.isValid() ? m_cliprect : arrowrect;
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size())
- % HexString<uchar>(arrow_type)
- % pmKey;
-
- GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()};
- int xOffset = m_cliprect.isValid() ? arrowrect.x() - m_cliprect.x() : 0;
- int yOffset = m_cliprect.isValid() ? arrowrect.y() - m_cliprect.y() : 0;
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_arrow (style, pixmap, state, shadow,
- &gtkCliprect,
- gtkWidget,
- part,
- arrow_type, fill,
- xOffset, yOffset,
- arrowrect.width(),
- arrowrect.height()))
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
-
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-
-void QGtkPainter::paintHandle(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
- GtkStateType state, GtkShadowType shadow,
- GtkOrientation orientation, GtkStyle *style)
-{
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size())
- % HexString<uchar>(orientation);
-
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_handle (style,
- pixmap,
- state,
- shadow,
- NULL,
- gtkWidget,
- part, 0, 0,
- rect.width(),
- rect.height(),
- orientation));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-
-void QGtkPainter::paintSlider(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
- GtkStateType state, GtkShadowType shadow,
- GtkStyle *style, GtkOrientation orientation,
- const QString &pmKey)
-{
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget) % pmKey;
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_slider (style,
- pixmap,
- state,
- shadow,
- NULL,
- gtkWidget,
- part,
- 0, 0,
- rect.width(),
- rect.height(),
- orientation));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-
-void QGtkPainter::paintShadow(GtkWidget *gtkWidget, const gchar* part,
- const QRect &rect, GtkStateType state,
- GtkShadowType shadow, GtkStyle *style,
- const QString &pmKey)
-
-{
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) % pmKey;
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_shadow(style, pixmap, state, shadow, NULL,
- gtkWidget, part, 0, 0, rect.width(), rect.height()));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-void QGtkPainter::paintFlatBox(GtkWidget *gtkWidget, const gchar* part,
- const QRect &rect, GtkStateType state,
- GtkShadowType shadow, GtkStyle *style,
- const QString &pmKey)
-{
- if (!rect.isValid())
- return;
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) % pmKey;
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_flat_box (style,
- pixmap,
- state,
- shadow,
- NULL,
- gtkWidget,
- part, 0, 0,
- rect.width(),
- rect.height()));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-void QGtkPainter::paintExtention(GtkWidget *gtkWidget,
- const gchar *part, const QRect &rect,
- GtkStateType state, GtkShadowType shadow,
- GtkPositionType gap_pos, GtkStyle *style)
-{
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget)
- % HexString<uchar>(gap_pos);
-
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_extension (style, pixmap, state, shadow,
- NULL, gtkWidget,
- (gchar*)part, 0, 0,
- rect.width(),
- rect.height(),
- gap_pos));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
-
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-void QGtkPainter::paintOption(GtkWidget *gtkWidget, const QRect &radiorect,
- GtkStateType state, GtkShadowType shadow,
- GtkStyle *style, const QString &detail)
-
-{
- QRect rect = m_cliprect.isValid() ? m_cliprect : radiorect;
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(detail, state, shadow, rect.size());
- GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()};
- int xOffset = m_cliprect.isValid() ? radiorect.x() - m_cliprect.x() : 0;
- int yOffset = m_cliprect.isValid() ? radiorect.y() - m_cliprect.y() : 0;
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_option(style, pixmap,
- state, shadow,
- &gtkCliprect,
- gtkWidget,
- detail.toLatin1(),
- xOffset, yOffset,
- radiorect.width(),
- radiorect.height()));
-
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
-
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-void QGtkPainter::paintCheckbox(GtkWidget *gtkWidget, const QRect &checkrect,
- GtkStateType state, GtkShadowType shadow,
- GtkStyle *style, const QString &detail)
-
-{
- QRect rect = m_cliprect.isValid() ? m_cliprect : checkrect;
- if (!rect.isValid())
- return;
-
- QPixmap cache;
- QString pixmapName = uniqueName(detail, state, shadow, rect.size());
- GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()};
- int xOffset = m_cliprect.isValid() ? checkrect.x() - m_cliprect.x() : 0;
- int yOffset = m_cliprect.isValid() ? checkrect.y() - m_cliprect.y() : 0;
- if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
- DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_check (style,
- pixmap,
- state,
- shadow,
- &gtkCliprect,
- gtkWidget,
- detail.toLatin1(),
- xOffset, yOffset,
- checkrect.width(),
- checkrect.height()));
- if (m_usePixmapCache)
- QPixmapCache::insert(pixmapName, cache);
- }
-
- m_painter->drawPixmap(rect.topLeft(), cache);
-}
-
-QT_END_NAMESPACE
-
-#endif //!defined(QT_NO_STYLE_GTK)
diff --git a/src/gui/styles/qgtkpainter_p.h b/src/gui/styles/qgtkpainter_p.h
deleted file mode 100644
index 1c253798a8..0000000000
--- a/src/gui/styles/qgtkpainter_p.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGTKPAINTER_H
-#define QGTKPAINTER_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qglobal.h>
-#if !defined(QT_NO_STYLE_GTK)
-
-#include <QtGui/QCleanlooksStyle>
-#include <QtGui/QPainter>
-#include <QtGui/QPalette>
-#include <QtGui/QFont>
-#include <private/qgtkstyle_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QGtkPainter
-{
-
-public:
- QGtkPainter(QPainter *painter);
- GtkStyle *getStyle(GtkWidget *gtkWidget);
- GtkStateType gtkState(const QStyleOption *option);
-
- void setAlphaSupport(bool value) { m_alpha = value; }
- void setClipRect(const QRect &rect) { m_cliprect = rect; }
- void setFlipHorizontal(bool value) { m_hflipped = value; }
- void setFlipVertical(bool value) { m_vflipped = value; }
- void setUsePixmapCache(bool value) { m_usePixmapCache = value; }
-
- void paintBoxGap(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
- GtkStateType state, GtkShadowType shadow, GtkPositionType gap_side, gint x,
- gint width, GtkStyle *style);
- void paintBox(GtkWidget *gtkWidget, const gchar* part,
- const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style,
- const QString &pmKey = QString());
- void paintHline(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
- int x1, int x2, int y, const QString &pmKey = QString());
- void paintVline(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
- int y1, int y2, int x, const QString &pmKey = QString());
- void paintExpander(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state,
- GtkExpanderStyle expander_state, GtkStyle *style, const QString &pmKey = QString());
- void paintFocus(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
- const QString &pmKey = QString());
- void paintResizeGrip(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
- GdkWindowEdge edge, GtkStyle *style, const QString &pmKey = QString());
- void paintArrow(GtkWidget *gtkWidget, const gchar* part, const QRect &arrowrect, GtkArrowType arrow_type, GtkStateType state, GtkShadowType shadow,
- gboolean fill, GtkStyle *style, const QString &pmKey = QString());
- void paintHandle(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
- GtkStateType state, GtkShadowType shadow, GtkOrientation orientation, GtkStyle *style);
- void paintSlider(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
- GtkStyle *style, GtkOrientation orientation, const QString &pmKey = QString());
- void paintShadow(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
- GtkStyle *style, const QString &pmKey = QString());
- void paintFlatBox(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString & = QString());
- void paintExtention(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
- GtkPositionType gap_pos, GtkStyle *style);
- void paintOption(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail);
- void paintCheckbox(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail);
-
- static QPixmap getIcon(const char* iconName, GtkIconSize size = GTK_ICON_SIZE_BUTTON);
-private:
- QPixmap renderTheme(uchar *bdata, uchar *wdata, const QRect&);
-
- GtkWidget *m_window;
- QPainter *m_painter;
- bool m_alpha;
- bool m_hflipped;
- bool m_vflipped;
- bool m_usePixmapCache;
- QRect m_cliprect;
-
-};
-
-QT_END_NAMESPACE
-
-#endif //!defined(QT_NO_STYLE_QGTK)
-
-#endif // QGTKPAINTER_H
diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp
deleted file mode 100644
index d6dd52790f..0000000000
--- a/src/gui/styles/qgtkstyle.cpp
+++ /dev/null
@@ -1,3560 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include "qgtkstyle.h"
-
-#if !defined(QT_NO_STYLE_GTK)
-
-#include <private/qapplication_p.h>
-#include <QtCore/QLibrary>
-#include <QtCore/QSettings>
-#include <QtGui/QDialogButtonBox>
-#include <QtGui/QStatusBar>
-#include <QtGui/QLineEdit>
-#include <QtGui/QWidget>
-#include <QtGui/QListView>
-#include <QtGui/QApplication>
-#include <QtGui/QStyleOption>
-#include <QtGui/QPushButton>
-#include <QtGui/QPainter>
-#include <QtGui/QMainWindow>
-#include <QtGui/QToolBar>
-#include <QtGui/QHeaderView>
-#include <QtGui/QMenuBar>
-#include <QtGui/QComboBox>
-#include <QtGui/QSpinBox>
-#include <QtGui/QScrollBar>
-#include <QtGui/QAbstractButton>
-#include <QtGui/QToolButton>
-#include <QtGui/QGroupBox>
-#include <QtGui/QRadioButton>
-#include <QtGui/QCheckBox>
-#include <QtGui/QTreeView>
-#include <QtGui/QStyledItemDelegate>
-#include <qpixmapcache.h>
-#undef signals // Collides with GTK stymbols
-#include <private/qgtkpainter_p.h>
-#include <private/qstylehelper_p.h>
-#include <private/qgtkstyle_p.h>
-#include <private/qcleanlooksstyle_p.h>
-
-
-QT_BEGIN_NAMESPACE
-
-static const char * const dock_widget_close_xpm[] =
- {
- "11 13 5 1",
- " c None",
- ". c #D5CFCB",
- "+ c #6C6A67",
- "@ c #6C6A67",
- "$ c #B5B0AC",
- " ",
- " @@@@@@@@@ ",
- "@+ +@",
- "@ +@ @+ @",
- "@ @@@ @@@ @",
- "@ @@@@@ @",
- "@ @@@ @",
- "@ @@@@@ @",
- "@ @@@ @@@ @",
- "@ +@ @+ @",
- "@+ +@",
- " @@@@@@@@@ ",
- " "
- };
-
-static const char * const dock_widget_restore_xpm[] =
- {
- "11 13 5 1",
- " c None",
- ". c #D5CFCB",
- "+ c #6C6A67",
- "@ c #6C6A67",
- "# c #6C6A67",
- " ",
- " @@@@@@@@@ ",
- "@+ +@",
- "@ #@@@# @",
- "@ @ @ @",
- "@ #@@@# @ @",
- "@ @ @ @ @",
- "@ @ @@@ @",
- "@ @ @ @",
- "@ #@@@@ @",
- "@+ +@",
- " @@@@@@@@@ ",
- " "
- };
-
-static const int groupBoxBottomMargin = 2; // space below the groupbox
-static const int groupBoxTitleMargin = 6; // space between contents and title
-static const int groupBoxTopMargin = 2;
-
-/*!
- Returns the configuration string for \a value.
- Returns \a fallback if \a value is not found.
- */
-QString QGtkStyle::getGConfString(const QString &value, const QString &fallback)
-{
- return QGtkStylePrivate::getGConfString(value, fallback);
-}
-
-/*!
- Returns the configuration boolean for \a key.
- Returns \a fallback if \a key is not found.
- */
-bool QGtkStyle::getGConfBool(const QString &key, bool fallback)
-{
- return QGtkStylePrivate::getGConfBool(key, fallback);
-}
-
-static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor = 50)
-{
- const int maxFactor = 100;
- QColor tmp = colorA;
- tmp.setRed((tmp.red() * factor) / maxFactor + (colorB.red() * (maxFactor - factor)) / maxFactor);
- tmp.setGreen((tmp.green() * factor) / maxFactor + (colorB.green() * (maxFactor - factor)) / maxFactor);
- tmp.setBlue((tmp.blue() * factor) / maxFactor + (colorB.blue() * (maxFactor - factor)) / maxFactor);
- return tmp;
-}
-
-static GdkColor fromQColor(const QColor &color)
-{
- GdkColor retval;
- retval.red = color.red() * 255;
- retval.green = color.green() * 255;
- retval.blue = color.blue() * 255;
- return retval;
-}
-
-/*!
- \class QGtkStyle
- \brief The QGtkStyle class provides a widget style rendered by GTK+
- \since 4.5
-
- The QGtkStyle style provides a look and feel that integrates well
- into GTK-based desktop environments such as the XFCe and GNOME.
-
- It does this by making use of the GTK+ theme engine, ensuring
- that Qt applications look and feel native on these platforms.
-
- Note: The style requires GTK+ version 2.10 or later.
- The Qt3-based "Qt" GTK+ theme engine will not work with QGtkStyle.
-
- \sa {Cleanlooks Style Widget Gallery}, QWindowsXPStyle, QMacStyle, QWindowsStyle,
- QCDEStyle, QMotifStyle, QPlastiqueStyle, QCleanlooksStyle
-*/
-
-/*!
- Constructs a QGtkStyle object.
-*/
-QGtkStyle::QGtkStyle()
- : QCleanlooksStyle(*new QGtkStylePrivate)
-{
- Q_D(QGtkStyle);
- d->init();
-}
-
-/*!
- \internal
-
- Constructs a QGtkStyle object.
-*/
-QGtkStyle::QGtkStyle(QGtkStylePrivate &dd)
- : QCleanlooksStyle(dd)
-{
- Q_D(QGtkStyle);
- d->init();
-}
-
-
-/*!
- Destroys the QGtkStyle object.
-*/
-QGtkStyle::~QGtkStyle()
-{
-}
-
-/*!
- \reimp
-*/
-QPalette QGtkStyle::standardPalette() const
-{
- Q_D(const QGtkStyle);
-
- QPalette palette = QCleanlooksStyle::standardPalette();
- if (d->isThemeAvailable()) {
- GtkStyle *style = d->gtkStyle();
- GtkWidget *gtkButton = d->gtkWidget("GtkButton");
- GtkWidget *gtkEntry = d->getTextColorWidget();
- GdkColor gdkBg, gdkBase, gdkText, gdkForeground, gdkSbg, gdkSfg, gdkaSbg, gdkaSfg;
- QColor bg, base, text, fg, highlight, highlightText, inactiveHighlight, inactiveHighlightedTExt;
- gdkBg = style->bg[GTK_STATE_NORMAL];
- gdkForeground = gtkButton->style->fg[GTK_STATE_NORMAL];
-
- // Our base and selected color is primarily used for text
- // so we assume a gtkEntry will have the most correct value
- gdkBase = gtkEntry->style->base[GTK_STATE_NORMAL];
- gdkText = gtkEntry->style->text[GTK_STATE_NORMAL];
- gdkSbg = gtkEntry->style->base[GTK_STATE_SELECTED];
- gdkSfg = gtkEntry->style->text[GTK_STATE_SELECTED];
-
- // The ACTIVE base color is really used for inactive windows
- gdkaSbg = gtkEntry->style->base[GTK_STATE_ACTIVE];
- gdkaSfg = gtkEntry->style->text[GTK_STATE_ACTIVE];
-
- bg = QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8);
- text = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
- fg = QColor(gdkForeground.red>>8, gdkForeground.green>>8, gdkForeground.blue>>8);
- base = QColor(gdkBase.red>>8, gdkBase.green>>8, gdkBase.blue>>8);
- highlight = QColor(gdkSbg.red>>8, gdkSbg.green>>8, gdkSbg.blue>>8);
- highlightText = QColor(gdkSfg.red>>8, gdkSfg.green>>8, gdkSfg.blue>>8);
- inactiveHighlight = QColor(gdkaSbg.red>>8, gdkaSbg.green>>8, gdkaSbg.blue>>8);
- inactiveHighlightedTExt = QColor(gdkaSfg.red>>8, gdkaSfg.green>>8, gdkaSfg.blue>>8);
-
- palette.setColor(QPalette::HighlightedText, highlightText);
-
-
- palette.setColor(QPalette::Light, bg.lighter(125));
- palette.setColor(QPalette::Shadow, bg.darker(130));
- palette.setColor(QPalette::Dark, bg.darker(120));
- palette.setColor(QPalette::Text, text);
- palette.setColor(QPalette::WindowText, fg);
- palette.setColor(QPalette::ButtonText, fg);
- palette.setColor(QPalette::Base, base);
-
- QColor alternateRowColor = palette.base().color().lighter(93); // ref gtkstyle.c draw_flat_box
- GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView");
- GdkColor *gtkAltBase = NULL;
- d->gtk_widget_style_get(gtkTreeView, "odd-row-color", &gtkAltBase, NULL);
- if (gtkAltBase) {
- alternateRowColor = QColor(gtkAltBase->red>>8, gtkAltBase->green>>8, gtkAltBase->blue>>8);
- d->gdk_color_free(gtkAltBase);
- }
- palette.setColor(QPalette::AlternateBase, alternateRowColor);
-
- palette.setColor(QPalette::Window, bg);
- palette.setColor(QPalette::Button, bg);
- palette.setColor(QPalette::Background, bg);
- QColor disabled((fg.red() + bg.red()) / 2,
- (fg.green() + bg.green())/ 2,
- (fg.blue() + bg.blue()) / 2);
- palette.setColor(QPalette::Disabled, QPalette::Text, disabled);
- palette.setColor(QPalette::Disabled, QPalette::WindowText, disabled);
- palette.setColor(QPalette::Disabled, QPalette::Foreground, disabled);
- palette.setColor(QPalette::Disabled, QPalette::ButtonText, disabled);
- palette.setColor(QPalette::Highlight, highlight);
- // calculate disabled colors by removing saturation
- highlight.setHsv(highlight.hue(), 0, highlight.value(), highlight.alpha());
- highlightText.setHsv(highlightText.hue(), 0, highlightText.value(), highlightText.alpha());
- palette.setColor(QPalette::Disabled, QPalette::Highlight, highlight);
- palette.setColor(QPalette::Disabled, QPalette::HighlightedText, highlightText);
-
- palette.setColor(QPalette::Inactive, QPalette::HighlightedText, inactiveHighlightedTExt);
- palette.setColor(QPalette::Inactive, QPalette::Highlight, inactiveHighlight);
-
- style = d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(), "gtk-tooltips", "GtkWindow",
- d->gtk_window_get_type());
- if (style) {
- gdkText = style->fg[GTK_STATE_NORMAL];
- text = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
- palette.setColor(QPalette::ToolTipText, text);
- }
- }
- return palette;
-}
-
-/*!
- \reimp
-*/
-void QGtkStyle::polish(QPalette &palette)
-{
- Q_D(QGtkStyle);
-
- // QCleanlooksStyle will alter the palette, hence we do
- // not want to polish the palette unless we are using it as
- // the fallback
- if (!d->isThemeAvailable())
- QCleanlooksStyle::polish(palette);
- else
- palette = palette.resolve(standardPalette());
-}
-
-/*!
- \reimp
-*/
-void QGtkStyle::polish(QApplication *app)
-{
- Q_D(QGtkStyle);
-
- QCleanlooksStyle::polish(app);
- // Custom fonts and palettes with QtConfig are intentionally
- // not supported as these should be entirely determined by
- // current Gtk settings
- if (app->desktopSettingsAware() && d->isThemeAvailable()) {
- QApplicationPrivate::setSystemPalette(standardPalette());
- QApplicationPrivate::setSystemFont(d->getThemeFont());
- d->applyCustomPaletteHash();
- if (!d->isKDE4Session()) {
- qt_filedialog_open_filename_hook = &QGtkStylePrivate::openFilename;
- qt_filedialog_save_filename_hook = &QGtkStylePrivate::saveFilename;
- qt_filedialog_open_filenames_hook = &QGtkStylePrivate::openFilenames;
- qt_filedialog_existing_directory_hook = &QGtkStylePrivate::openDirectory;
- qApp->installEventFilter(&d->filter);
- }
- }
-}
-
-/*!
- \reimp
-*/
-void QGtkStyle::unpolish(QApplication *app)
-{
- Q_D(QGtkStyle);
-
- QCleanlooksStyle::unpolish(app);
- QPixmapCache::clear();
-
- if (app->desktopSettingsAware() && d->isThemeAvailable()
- && !d->isKDE4Session()) {
- qt_filedialog_open_filename_hook = 0;
- qt_filedialog_save_filename_hook = 0;
- qt_filedialog_open_filenames_hook = 0;
- qt_filedialog_existing_directory_hook = 0;
- qApp->removeEventFilter(&d->filter);
- }
-}
-
-/*!
- \reimp
-*/
-
-void QGtkStyle::polish(QWidget *widget)
-{
- Q_D(QGtkStyle);
-
- QCleanlooksStyle::polish(widget);
- if (!d->isThemeAvailable())
- return;
- if (qobject_cast<QAbstractButton*>(widget)
- || qobject_cast<QToolButton*>(widget)
- || qobject_cast<QComboBox*>(widget)
- || qobject_cast<QGroupBox*>(widget)
- || qobject_cast<QScrollBar*>(widget)
- || qobject_cast<QSlider*>(widget)
- || qobject_cast<QAbstractSpinBox*>(widget)
- || qobject_cast<QSpinBox*>(widget)
- || qobject_cast<QHeaderView*>(widget))
- widget->setAttribute(Qt::WA_Hover);
- else if (QTreeView *tree = qobject_cast<QTreeView *> (widget))
- tree->viewport()->setAttribute(Qt::WA_Hover);
-}
-
-/*!
- \reimp
-*/
-void QGtkStyle::unpolish(QWidget *widget)
-{
- QCleanlooksStyle::unpolish(widget);
-}
-
-/*!
- \reimp
-*/
-int QGtkStyle::pixelMetric(PixelMetric metric,
- const QStyleOption *option,
- const QWidget *widget) const
-{
- Q_D(const QGtkStyle);
-
- if (!d->isThemeAvailable())
- return QCleanlooksStyle::pixelMetric(metric, option, widget);
-
- switch (metric) {
- case PM_DefaultFrameWidth:
- if (qobject_cast<const QFrame*>(widget)) {
- if (GtkStyle *style =
- d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(),
- "*.GtkScrolledWindow",
- "*.GtkScrolledWindow",
- d->gtk_window_get_type()))
- return qMax(style->xthickness, style->ythickness);
- }
- return 2;
-
- case PM_MenuButtonIndicator:
- return 20;
-
- case PM_TabBarBaseOverlap:
- return 1;
-
- case PM_ToolBarSeparatorExtent:
- return 11;
-
- case PM_ToolBarFrameWidth:
- return 1;
-
- case PM_ToolBarItemSpacing:
- return 0;
-
- case PM_ButtonShiftHorizontal: {
- GtkWidget *gtkButton = d->gtkWidget("GtkButton");
- guint horizontal_shift;
- d->gtk_widget_style_get(gtkButton, "child-displacement-x", &horizontal_shift, NULL);
- return horizontal_shift;
- }
-
- case PM_ButtonShiftVertical: {
- GtkWidget *gtkButton = d->gtkWidget("GtkButton");
- guint vertical_shift;
- d->gtk_widget_style_get(gtkButton, "child-displacement-y", &vertical_shift, NULL);
- return vertical_shift;
- }
-
- case PM_MenuBarPanelWidth:
- return 0;
-
- case PM_MenuPanelWidth: {
- GtkWidget *gtkMenu = d->gtkWidget("GtkMenu");
- guint horizontal_padding = 0;
- // horizontal-padding is used by Maemo to get thicker borders
- if (!d->gtk_check_version(2, 10, 0))
- d->gtk_widget_style_get(gtkMenu, "horizontal-padding", &horizontal_padding, NULL);
- int padding = qMax<int>(gtkMenu->style->xthickness, horizontal_padding);
- return padding;
- }
-
- case PM_ButtonIconSize: {
- int retVal = 24;
- GtkSettings *settings = d->gtk_settings_get_default();
- gchararray icon_sizes;
- g_object_get(settings, "gtk-icon-sizes", &icon_sizes, NULL);
- QStringList values = QString(QLS(icon_sizes)).split(QLatin1Char(':'));
- g_free(icon_sizes);
- QChar splitChar(QLatin1Char(','));
- foreach (const QString &value, values) {
- if (value.startsWith(QLS("gtk-button="))) {
- QString iconSize = value.right(value.size() - 11);
-
- if (iconSize.contains(splitChar))
- retVal = iconSize.split(splitChar)[0].toInt();
- break;
- }
- }
- return retVal;
- }
-
- case PM_MenuVMargin:
-
- case PM_MenuHMargin:
- return 0;
-
- case PM_DockWidgetTitleMargin:
- return 0;
-
- case PM_DockWidgetTitleBarButtonMargin:
- return 5;
-
- case PM_TabBarTabVSpace:
- return 12;
-
- case PM_TabBarTabHSpace:
- return 14;
-
- case PM_TabBarTabShiftVertical:
- return 2;
-
- case PM_ToolBarHandleExtent:
- return 9;
-
- case PM_SplitterWidth:
- return 6;
-
- case PM_SliderThickness:
- case PM_SliderControlThickness: {
- GtkWidget *gtkScale = d->gtkWidget("GtkHScale");
- gint val;
- d->gtk_widget_style_get(gtkScale, "slider-width", &val, NULL);
- if (metric == PM_SliderControlThickness)
- return val + 2*gtkScale->style->ythickness;
- return val;
- }
-
- case PM_ScrollBarExtent: {
- gint sliderLength;
- gint trough_border;
- GtkWidget *hScrollbar = d->gtkWidget("GtkHScrollbar");
- d->gtk_widget_style_get(hScrollbar,
- "trough-border", &trough_border,
- "slider-width", &sliderLength,
- NULL);
- return sliderLength + trough_border*2;
- }
-
- case PM_ScrollBarSliderMin:
- return 34;
-
- case PM_SliderLength:
- gint val;
- d->gtk_widget_style_get(d->gtkWidget("GtkHScale"), "slider-length", &val, NULL);
- return val;
-
- case PM_ExclusiveIndicatorWidth:
- case PM_ExclusiveIndicatorHeight:
- case PM_IndicatorWidth:
- case PM_IndicatorHeight: {
- GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton");
- gint size, spacing;
- d->gtk_widget_style_get(gtkCheckButton, "indicator-spacing", &spacing, "indicator-size", &size, NULL);
- return size + 2 * spacing;
- }
-
- case PM_MenuBarVMargin: {
- GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar");
- return qMax(0, gtkMenubar->style->ythickness);
- }
- case PM_ScrollView_ScrollBarSpacing:
- {
- gint spacing = 3;
- GtkWidget *gtkScrollWindow = d->gtkWidget("GtkScrolledWindow");
- Q_ASSERT(gtkScrollWindow);
- d->gtk_widget_style_get(gtkScrollWindow, "scrollbar-spacing", &spacing, NULL);
- return spacing;
- }
- case PM_SubMenuOverlap: {
- gint offset = 0;
- GtkWidget *gtkMenu = d->gtkWidget("GtkMenu");
- d->gtk_widget_style_get(gtkMenu, "horizontal-offset", &offset, NULL);
- return offset;
- }
- default:
- return QCleanlooksStyle::pixelMetric(metric, option, widget);
- }
-}
-
-/*!
- \reimp
-*/
-int QGtkStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget,
-
- QStyleHintReturn *returnData = 0) const
-{
- Q_D(const QGtkStyle);
-
- if (!d->isThemeAvailable())
- return QCleanlooksStyle::styleHint(hint, option, widget, returnData);
-
- switch (hint) {
-
- case SH_DialogButtonLayout: {
- int ret = QDialogButtonBox::GnomeLayout;
- gboolean alternateOrder = 0;
- GtkSettings *settings = d->gtk_settings_get_default();
- g_object_get(settings, "gtk-alternative-button-order", &alternateOrder, NULL);
-
- if (alternateOrder)
- ret = QDialogButtonBox::WinLayout;
-
- return ret;
- }
-
- break;
-
- case SH_ToolButtonStyle:
- {
- if (d->isKDE4Session())
- return QCleanlooksStyle::styleHint(hint, option, widget, returnData);
- GtkWidget *gtkToolbar = d->gtkWidget("GtkToolbar");
- GtkToolbarStyle toolbar_style = GTK_TOOLBAR_ICONS;
- g_object_get(gtkToolbar, "toolbar-style", &toolbar_style, NULL);
- switch (toolbar_style) {
- case GTK_TOOLBAR_TEXT:
- return Qt::ToolButtonTextOnly;
- case GTK_TOOLBAR_BOTH:
- return Qt::ToolButtonTextUnderIcon;
- case GTK_TOOLBAR_BOTH_HORIZ:
- return Qt::ToolButtonTextBesideIcon;
- case GTK_TOOLBAR_ICONS:
- default:
- return Qt::ToolButtonIconOnly;
- }
- }
- break;
- case SH_SpinControls_DisableOnBounds:
- return int(true);
-
- case SH_DitherDisabledText:
- return int(false);
-
- case SH_ComboBox_Popup: {
- GtkWidget *gtkComboBox = d->gtkWidget("GtkComboBox");
- gboolean appears_as_list;
- d->gtk_widget_style_get((GtkWidget*)gtkComboBox, "appears-as-list", &appears_as_list, NULL);
- return appears_as_list ? 0 : 1;
- }
-
- case SH_MenuBar_AltKeyNavigation:
- return int(false);
-
- case SH_EtchDisabledText:
- return int(false);
-
- case SH_Menu_SubMenuPopupDelay: {
- gint delay = 225;
- GtkSettings *settings = d->gtk_settings_get_default();
- g_object_get(settings, "gtk-menu-popup-delay", &delay, NULL);
- return delay;
- }
-
- case SH_ScrollView_FrameOnlyAroundContents: {
- gboolean scrollbars_within_bevel = false;
- if (widget && widget->isWindow())
- scrollbars_within_bevel = true;
- else if (!d->gtk_check_version(2, 12, 0)) {
- GtkWidget *gtkScrollWindow = d->gtkWidget("GtkScrolledWindow");
- d->gtk_widget_style_get(gtkScrollWindow, "scrollbars-within-bevel", &scrollbars_within_bevel, NULL);
- }
- return !scrollbars_within_bevel;
- }
-
- case SH_DialogButtonBox_ButtonsHaveIcons: {
- static bool buttonsHaveIcons = d->getGConfBool(QLS("/desktop/gnome/interface/buttons_have_icons"));
- return buttonsHaveIcons;
- }
-
- case SH_UnderlineShortcut: {
- gboolean underlineShortcut = true;
- if (!d->gtk_check_version(2, 12, 0)) {
- GtkSettings *settings = d->gtk_settings_get_default();
- g_object_get(settings, "gtk-enable-mnemonics", &underlineShortcut, NULL);
- }
- return underlineShortcut;
- }
-
- default:
- return QCleanlooksStyle::styleHint(hint, option, widget, returnData);
- }
-}
-
-/*!
- \reimp
-*/
-void QGtkStyle::drawPrimitive(PrimitiveElement element,
- const QStyleOption *option,
- QPainter *painter,
- const QWidget *widget) const
-{
- Q_D(const QGtkStyle);
-
- if (!d->isThemeAvailable()) {
- QCleanlooksStyle::drawPrimitive(element, option, painter, widget);
- return;
- }
-
- GtkStyle* style = d->gtkStyle();
- QGtkPainter gtkPainter(painter);
-
- switch (element) {
- case PE_Frame: {
- if (widget && widget->inherits("QComboBoxPrivateContainer")){
- QStyleOption copy = *option;
- copy.state |= State_Raised;
- proxy()->drawPrimitive(PE_PanelMenu, &copy, painter, widget);
- break;
- }
- // Drawing the entire itemview frame is very expensive, especially on the native X11 engine
- // Instead we cheat a bit and draw a border image without the center part, hence only scaling
- // thin rectangular images
- const int pmSize = 64;
- const int border = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget);
- const QString pmKey = QLatin1Literal("windowframe") % HexString<uint>(option->state);
-
- QPixmap pixmap;
- QRect pmRect(QPoint(0,0), QSize(pmSize, pmSize));
-
- // Only draw through style once
- if (!QPixmapCache::find(pmKey, pixmap)) {
- pixmap = QPixmap(pmSize, pmSize);
- pixmap.fill(Qt::transparent);
- QPainter pmPainter(&pixmap);
- QGtkPainter gtkFramePainter(&pmPainter);
- gtkFramePainter.setUsePixmapCache(false); // Don't cache twice
-
- GtkShadowType shadow_type = GTK_SHADOW_NONE;
- if (option->state & State_Sunken)
- shadow_type = GTK_SHADOW_IN;
- else if (option->state & State_Raised)
- shadow_type = GTK_SHADOW_OUT;
-
- GtkStyle *style = d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(),
- "*.GtkScrolledWindow", "*.GtkScrolledWindow", d->gtk_window_get_type());
- if (style)
- gtkFramePainter.paintShadow(d->gtkWidget("GtkFrame"), "viewport", pmRect,
- option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
- shadow_type, style);
- QPixmapCache::insert(pmKey, pixmap);
- }
-
- QRect rect = option->rect;
- const int rw = rect.width() - border;
- const int rh = rect.height() - border;
- const int pw = pmRect.width() - border;
- const int ph = pmRect.height() - border;
-
- // Sidelines
- painter->drawPixmap(rect.adjusted(border, 0, -border, -rh), pixmap, pmRect.adjusted(border, 0, -border,-ph));
- painter->drawPixmap(rect.adjusted(border, rh, -border, 0), pixmap, pmRect.adjusted(border, ph,-border,0));
- painter->drawPixmap(rect.adjusted(0, border, -rw, -border), pixmap, pmRect.adjusted(0, border, -pw, -border));
- painter->drawPixmap(rect.adjusted(rw, border, 0, -border), pixmap, pmRect.adjusted(pw, border, 0, -border));
-
- // Corners
- painter->drawPixmap(rect.adjusted(0, 0, -rw, -rh), pixmap, pmRect.adjusted(0, 0, -pw,-ph));
- painter->drawPixmap(rect.adjusted(rw, 0, 0, -rh), pixmap, pmRect.adjusted(pw, 0, 0,-ph));
- painter->drawPixmap(rect.adjusted(0, rh, -rw, 0), pixmap, pmRect.adjusted(0, ph, -pw,0));
- painter->drawPixmap(rect.adjusted(rw, rh, 0, 0), pixmap, pmRect.adjusted(pw, ph, 0,0));
- }
- break;
-
- case PE_PanelTipLabel: {
- GtkWidget *gtkWindow = d->gtkWidget("GtkWindow"); // The Murrine Engine currently assumes a widget is passed
- style = d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(), "gtk-tooltips", "GtkWindow",
- d->gtk_window_get_type());
- gtkPainter.paintFlatBox(gtkWindow, "tooltip", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_NONE, style);
- }
- break;
-
- case PE_PanelStatusBar: {
- if (widget && widget->testAttribute(Qt::WA_SetPalette) &&
- option->palette.resolve() & (1 << QPalette::Window)) {
- // Respect custom palette
- painter->fillRect(option->rect, option->palette.window());
- break;
- }
- GtkShadowType shadow_type;
- GtkWidget *gtkStatusbarFrame = d->gtkWidget("GtkStatusbar.GtkFrame");
- d->gtk_widget_style_get(gtkStatusbarFrame->parent, "shadow-type", &shadow_type, NULL);
- gtkPainter.paintShadow(gtkStatusbarFrame, "frame", option->rect, GTK_STATE_NORMAL,
- shadow_type, gtkStatusbarFrame->style);
- }
- break;
-
- case PE_IndicatorHeaderArrow:
- if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
- GtkWidget *gtkTreeHeader = d->gtkWidget("GtkTreeView.GtkButton");
- GtkStateType state = gtkPainter.gtkState(option);
- style = gtkTreeHeader->style;
- GtkArrowType type = GTK_ARROW_UP;
- QImage arrow;
- // This sorting indicator inversion is intentional, and follows the GNOME HIG.
- // See http://library.gnome.org/devel/hig-book/stable/controls-lists.html.en#controls-lists-sortable
- if (header->sortIndicator & QStyleOptionHeader::SortUp)
- type = GTK_ARROW_UP;
- else if (header->sortIndicator & QStyleOptionHeader::SortDown)
- type = GTK_ARROW_DOWN;
-
- gtkPainter.paintArrow(gtkTreeHeader, "button", option->rect.adjusted(1, 1, -1, -1), type, state,
- GTK_SHADOW_NONE, FALSE, style);
- }
- break;
-
- case PE_FrameFocusRect:
- if (!widget || qobject_cast<const QAbstractItemView*>(widget))
- QCleanlooksStyle::drawPrimitive(element, option, painter, widget);
- else {
- // ### this mess should move to subcontrolrect
- QRect frameRect = option->rect.adjusted(1, 1, -1, -2);
-
- if (qobject_cast<const QTabBar*>(widget)) {
- GtkWidget *gtkNotebook = d->gtkWidget("GtkNotebook");
- style = gtkPainter.getStyle(gtkNotebook);
- gtkPainter.paintFocus(gtkNotebook, "tab", frameRect.adjusted(-1, 1, 1, 1), GTK_STATE_ACTIVE, style);
- } else {
- gtkPainter.paintFocus(NULL, "tab", frameRect, GTK_STATE_ACTIVE, style);
- }
- }
- break;
-
- case PE_IndicatorBranch:
- if (option->state & State_Children) {
- QRect rect = option->rect;
- rect = QRect(0, 0, 12, 12);
- rect.moveCenter(option->rect.center());
- rect.translate(2, 0);
- GtkExpanderStyle openState = GTK_EXPANDER_EXPANDED;
- GtkExpanderStyle closedState = GTK_EXPANDER_COLLAPSED;
- GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView");
-
- GtkStateType state = GTK_STATE_NORMAL;
- if (!(option->state & State_Enabled))
- state = GTK_STATE_INSENSITIVE;
- else if (option->state & State_MouseOver)
- state = GTK_STATE_PRELIGHT;
-
- gtkPainter.paintExpander(gtkTreeView, "treeview", rect, state,
- option->state & State_Open ? openState : closedState , gtkTreeView->style);
- }
- break;
-
- case PE_PanelItemViewRow:
- // This primitive is only used to draw selection behind selected expander arrows.
- // We try not to decorate the tree branch background unless you inherit from StyledItemDelegate
- // The reason for this is that a lot of code that relies on custom item delegates will look odd having
- // a gradient on the branch but a flat shaded color on the item itself.
- QCommonStyle::drawPrimitive(element, option, painter, widget);
- if (!option->state & State_Selected) {
- break;
- } else {
- if (const QAbstractItemView *view = qobject_cast<const QAbstractItemView*>(widget)) {
- if (!qobject_cast<QStyledItemDelegate*>(view->itemDelegate()))
- break;
- }
- } // fall through
-
- case PE_PanelItemViewItem:
- if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) {
- uint resolve_mask = vopt->palette.resolve();
- if (vopt->backgroundBrush.style() != Qt::NoBrush
- || (resolve_mask & (1 << QPalette::Base)))
- {
- QPointF oldBO = painter->brushOrigin();
- painter->setBrushOrigin(vopt->rect.topLeft());
- painter->fillRect(vopt->rect, vopt->backgroundBrush);
- painter->setBrushOrigin(oldBO);
- if (!(option->state & State_Selected))
- break;
- }
- if (GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView")) {
- const char *detail = "cell_even_ruled";
- if (vopt && vopt->features & QStyleOptionViewItemV2::Alternate)
- detail = "cell_odd_ruled";
- bool isActive = option->state & State_Active;
- QString key;
- if (isActive ) {
- // Required for active/non-active window appearance
- key = QLS("a");
- GTK_WIDGET_SET_FLAGS(gtkTreeView, GTK_HAS_FOCUS);
- }
- bool isEnabled = (widget ? widget->isEnabled() : (vopt->state & QStyle::State_Enabled));
- gtkPainter.paintFlatBox(gtkTreeView, detail, option->rect,
- option->state & State_Selected ? GTK_STATE_SELECTED :
- isEnabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
- GTK_SHADOW_OUT, gtkTreeView->style, key);
- if (isActive )
- GTK_WIDGET_UNSET_FLAGS(gtkTreeView, GTK_HAS_FOCUS);
- }
- }
- break;
- case PE_IndicatorToolBarSeparator:
- {
- const int margin = 6;
- GtkWidget *gtkSeparator = d->gtkWidget("GtkToolbar.GtkSeparatorToolItem");
- if (option->state & State_Horizontal) {
- const int offset = option->rect.width()/2;
- QRect rect = option->rect.adjusted(offset, margin, 0, -margin);
- painter->setPen(QPen(option->palette.background().color().darker(110)));
- gtkPainter.paintVline( gtkSeparator, "vseparator",
- rect, GTK_STATE_NORMAL, gtkSeparator->style,
- 0, rect.height(), 0);
- } else { //Draw vertical separator
- const int offset = option->rect.height()/2;
- QRect rect = option->rect.adjusted(margin, offset, -margin, 0);
- painter->setPen(QPen(option->palette.background().color().darker(110)));
- gtkPainter.paintHline( gtkSeparator, "hseparator",
- rect, GTK_STATE_NORMAL, gtkSeparator->style,
- 0, rect.width(), 0);
- }
- }
- break;
-
- case PE_IndicatorToolBarHandle: {
- GtkWidget *gtkToolbar = d->gtkWidget("GtkToolbar");
- GtkShadowType shadow_type;
- d->gtk_widget_style_get(gtkToolbar, "shadow-type", &shadow_type, NULL);
- //Note when the toolbar is horizontal, the handle is vertical
- painter->setClipRect(option->rect);
- gtkPainter.paintHandle(gtkToolbar, "toolbar", option->rect.adjusted(-1, -1 ,0 ,1),
- GTK_STATE_NORMAL, shadow_type, !(option->state & State_Horizontal) ?
- GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, gtkToolbar->style);
- }
- break;
-
- case PE_IndicatorArrowUp:
- case PE_IndicatorArrowDown:
- case PE_IndicatorArrowLeft:
- case PE_IndicatorArrowRight: {
-
-
- GtkArrowType type = GTK_ARROW_UP;
-
- switch (element) {
-
- case PE_IndicatorArrowDown:
- type = GTK_ARROW_DOWN;
- break;
-
- case PE_IndicatorArrowLeft:
- type = GTK_ARROW_LEFT;
- break;
-
- case PE_IndicatorArrowRight:
- type = GTK_ARROW_RIGHT;
- break;
-
- default:
- break;
- }
- int size = qMin(option->rect.height(), option->rect.width());
- int border = (size > 9) ? (size/4) : 0; //Allow small arrows to have exact dimensions
- int bsx = 0, bsy = 0;
- if (option->state & State_Sunken) {
- bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal);
- bsy = proxy()->pixelMetric(PM_ButtonShiftVertical);
- }
- QRect arrowRect = option->rect.adjusted(border + bsx, border + bsy, -border + bsx, -border + bsy);
- GtkShadowType shadow = option->state & State_Sunken ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
- GtkStateType state = gtkPainter.gtkState(option);
-
- QColor arrowColor = option->palette.buttonText().color();
- GtkWidget *gtkArrow = d->gtkWidget("GtkArrow");
- GdkColor color = fromQColor(arrowColor);
- d->gtk_widget_modify_fg (gtkArrow, state, &color);
- gtkPainter.paintArrow(gtkArrow, "button", arrowRect,
- type, state, shadow, FALSE, gtkArrow->style,
- QString::number(arrowColor.rgba(), 16));
- // Passing NULL will revert the color change
- d->gtk_widget_modify_fg (gtkArrow, state, NULL);
- }
- break;
-
- case PE_FrameGroupBox:
- // Do nothing here, the GNOME groupboxes are flat
- break;
-
- case PE_PanelMenu: {
- GtkWidget *gtkMenu = d->gtkWidget("GtkMenu");
- gtkPainter.setAlphaSupport(false); // Note, alpha disabled for performance reasons
- gtkPainter.paintBox(gtkMenu, "menu", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, gtkMenu->style, QString());
- }
- break;
-
- case PE_FrameMenu:
- //This is actually done by PE_Widget due to a clipping issue
- //Otherwise Menu items will not be able to span the entire menu width
-
- // This is only used by floating tool bars
- if (qobject_cast<const QToolBar *>(widget)) {
- GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar");
- gtkPainter.paintBox( gtkMenubar, "toolbar", option->rect,
- GTK_STATE_NORMAL, GTK_SHADOW_OUT, style);
- gtkPainter.paintBox( gtkMenubar, "menu", option->rect,
- GTK_STATE_NORMAL, GTK_SHADOW_OUT, style);
- }
- break;
-
- case PE_FrameLineEdit: {
- GtkWidget *gtkEntry = d->gtkWidget("GtkEntry");
-
-
- gboolean interior_focus;
- gint focus_line_width;
- QRect rect = option->rect;
- d->gtk_widget_style_get(gtkEntry,
- "interior-focus", &interior_focus,
- "focus-line-width", &focus_line_width, NULL);
-
- // See https://bugzilla.mozilla.org/show_bug.cgi?id=405421 for info about this hack
- g_object_set_data(G_OBJECT(gtkEntry), "transparent-bg-hint", GINT_TO_POINTER(TRUE));
-
- if (!interior_focus && option->state & State_HasFocus)
- rect.adjust(focus_line_width, focus_line_width, -focus_line_width, -focus_line_width);
-
- if (option->state & State_HasFocus)
- GTK_WIDGET_SET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
- gtkPainter.paintShadow(gtkEntry, "entry", rect, option->state & State_Enabled ?
- GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
- GTK_SHADOW_IN, gtkEntry->style,
- option->state & State_HasFocus ? QLS("focus") : QString());
- if (!interior_focus && option->state & State_HasFocus)
- gtkPainter.paintShadow(gtkEntry, "entry", option->rect, option->state & State_Enabled ?
- GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE,
- GTK_SHADOW_IN, gtkEntry->style, QLS("GtkEntryShadowIn"));
-
- if (option->state & State_HasFocus)
- GTK_WIDGET_UNSET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
- }
- break;
-
- case PE_PanelLineEdit:
- if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
- GtkWidget *gtkEntry = d->gtkWidget("GtkEntry");
- if (panel->lineWidth > 0)
- proxy()->drawPrimitive(PE_FrameLineEdit, option, painter, widget);
- uint resolve_mask = option->palette.resolve();
- QRect textRect = option->rect.adjusted(gtkEntry->style->xthickness, gtkEntry->style->ythickness,
- -gtkEntry->style->xthickness, -gtkEntry->style->ythickness);
-
- if (widget && widget->testAttribute(Qt::WA_SetPalette) &&
- resolve_mask & (1 << QPalette::Base)) // Palette overridden by user
- painter->fillRect(textRect, option->palette.base());
- else
- gtkPainter.paintFlatBox( gtkEntry, "entry_bg", textRect,
- option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, GTK_SHADOW_NONE, gtkEntry->style);
- }
- break;
-
- case PE_FrameTabWidget:
- if (const QStyleOptionTabWidgetFrame *frame = qstyleoption_cast<const QStyleOptionTabWidgetFrame*>(option)) {
- GtkWidget *gtkNotebook = d->gtkWidget("GtkNotebook");
- style = gtkPainter.getStyle(gtkNotebook);
- gtkPainter.setAlphaSupport(false);
- GtkShadowType shadow = GTK_SHADOW_OUT;
- GtkStateType state = GTK_STATE_NORMAL; // Only state supported by gtknotebook
- bool reverse = (option->direction == Qt::RightToLeft);
- QGtkStylePrivate::gtk_widget_set_direction(gtkNotebook, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
- if (const QStyleOptionTabWidgetFrameV2 *tabframe = qstyleoption_cast<const QStyleOptionTabWidgetFrameV2*>(option)) {
- GtkPositionType frameType = GTK_POS_TOP;
- QTabBar::Shape shape = frame->shape;
- int gapStart = 0;
- int gapSize = 0;
- if (shape == QTabBar::RoundedNorth || shape == QTabBar::RoundedSouth) {
- frameType = (shape == QTabBar::RoundedNorth) ? GTK_POS_TOP : GTK_POS_BOTTOM;
- gapStart = tabframe->selectedTabRect.left();
- gapSize = tabframe->selectedTabRect.width();
- } else {
- frameType = (shape == QTabBar::RoundedWest) ? GTK_POS_LEFT : GTK_POS_RIGHT;
- gapStart = tabframe->selectedTabRect.y();
- gapSize = tabframe->selectedTabRect.height();
- }
- gtkPainter.paintBoxGap(gtkNotebook, "notebook", option->rect, state, shadow, frameType,
- gapStart, gapSize, style);
- break; // done
- }
-
- // Note this is only the fallback option
- gtkPainter.paintBox(gtkNotebook, "notebook", option->rect, state, shadow, style);
- }
- break;
-
- case PE_PanelButtonCommand:
- case PE_PanelButtonTool: {
- bool isDefault = false;
- bool isTool = (element == PE_PanelButtonTool);
- if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton*>(option))
- isDefault = btn->features & QStyleOptionButton::DefaultButton;
-
- // don't draw a frame for tool buttons that have the autoRaise flag and are not enabled or on
- if (isTool && !(option->state & State_Enabled || option->state & State_On) && (option->state & State_AutoRaise))
- break;
- // don't draw a frame for dock widget buttons, unless we are hovering
- if (widget && widget->inherits("QDockWidgetTitleButton") && !(option->state & State_MouseOver))
- break;
-
- GtkStateType state = gtkPainter.gtkState(option);
- if (option->state & State_On || option->state & State_Sunken)
- state = GTK_STATE_ACTIVE;
- GtkWidget *gtkButton = isTool ? d->gtkWidget("GtkToolButton.GtkButton") : d->gtkWidget("GtkButton");
- gint focusWidth, focusPad;
- gboolean interiorFocus = false;
- d->gtk_widget_style_get (gtkButton,
- "focus-line-width", &focusWidth,
- "focus-padding", &focusPad,
- "interior-focus", &interiorFocus, NULL);
-
- style = gtkButton->style;
-
- QRect buttonRect = option->rect;
-
- QString key;
- if (isDefault) {
- key += QLS("def");
- GTK_WIDGET_SET_FLAGS(gtkButton, GTK_HAS_DEFAULT);
- gtkPainter.paintBox(gtkButton, "buttondefault", buttonRect, state, GTK_SHADOW_IN,
- style, isDefault ? QLS("d") : QString());
- }
-
- bool hasFocus = option->state & State_HasFocus;
-
- if (hasFocus) {
- key += QLS("def");
- GTK_WIDGET_SET_FLAGS(gtkButton, GTK_HAS_FOCUS);
- }
-
- if (!interiorFocus)
- buttonRect = buttonRect.adjusted(focusWidth, focusWidth, -focusWidth, -focusWidth);
-
- GtkShadowType shadow = (option->state & State_Sunken || option->state & State_On ) ?
- GTK_SHADOW_IN : GTK_SHADOW_OUT;
-
- gtkPainter.paintBox(gtkButton, "button", buttonRect, state, shadow,
- style, key);
- if (isDefault)
- GTK_WIDGET_UNSET_FLAGS(gtkButton, GTK_HAS_DEFAULT);
- if (hasFocus)
- GTK_WIDGET_UNSET_FLAGS(gtkButton, GTK_HAS_FOCUS);
- }
- break;
-
- case PE_IndicatorRadioButton: {
- GtkShadowType shadow = GTK_SHADOW_OUT;
- GtkStateType state = gtkPainter.gtkState(option);
-
- if (option->state & State_Sunken)
- state = GTK_STATE_ACTIVE;
-
- if (option->state & State_NoChange)
- shadow = GTK_SHADOW_ETCHED_IN;
- else if (option->state & State_On)
- shadow = GTK_SHADOW_IN;
- else
- shadow = GTK_SHADOW_OUT;
-
- GtkWidget *gtkRadioButton = d->gtkWidget("GtkRadioButton");
- gint spacing;
- d->gtk_widget_style_get(gtkRadioButton, "indicator-spacing", &spacing, NULL);
- QRect buttonRect = option->rect.adjusted(spacing, spacing, -spacing, -spacing);
- gtkPainter.setClipRect(option->rect);
- // ### Note: Ubuntulooks breaks when the proper widget is passed
- // Murrine engine requires a widget not to get RGBA check - warnings
- GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton");
- QString key(QLS("radiobutton"));
- if (option->state & State_HasFocus) { // Themes such as Nodoka check this flag
- key += QLatin1Char('f');
- GTK_WIDGET_SET_FLAGS(gtkCheckButton, GTK_HAS_FOCUS);
- }
- gtkPainter.paintOption(gtkCheckButton , buttonRect, state, shadow, gtkRadioButton->style, key);
- if (option->state & State_HasFocus)
- GTK_WIDGET_UNSET_FLAGS(gtkCheckButton, GTK_HAS_FOCUS);
- }
- break;
-
- case PE_IndicatorCheckBox: {
- GtkShadowType shadow = GTK_SHADOW_OUT;
- GtkStateType state = gtkPainter.gtkState(option);
-
- if (option->state & State_Sunken)
- state = GTK_STATE_ACTIVE;
-
- if (option->state & State_NoChange)
- shadow = GTK_SHADOW_ETCHED_IN;
- else if (option->state & State_On)
- shadow = GTK_SHADOW_IN;
- else
- shadow = GTK_SHADOW_OUT;
-
- int spacing;
-
- GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton");
- QString key(QLS("checkbutton"));
- if (option->state & State_HasFocus) { // Themes such as Nodoka checks this flag
- key += QLatin1Char('f');
- GTK_WIDGET_SET_FLAGS(gtkCheckButton, GTK_HAS_FOCUS);
- }
-
- // Some styles such as aero-clone assume they can paint in the spacing area
- gtkPainter.setClipRect(option->rect);
-
- d->gtk_widget_style_get(gtkCheckButton, "indicator-spacing", &spacing, NULL);
-
- QRect checkRect = option->rect.adjusted(spacing, spacing, -spacing, -spacing);
-
- gtkPainter.paintCheckbox(gtkCheckButton, checkRect, state, shadow, gtkCheckButton->style,
- key);
- if (option->state & State_HasFocus)
- GTK_WIDGET_UNSET_FLAGS(gtkCheckButton, GTK_HAS_FOCUS);
-
- }
- break;
-
-#ifndef QT_NO_TABBAR
-
- case PE_FrameTabBarBase:
- if (const QStyleOptionTabBarBase *tbb
- = qstyleoption_cast<const QStyleOptionTabBarBase *>(option)) {
- QRect tabRect = tbb->rect;
- painter->save();
- painter->setPen(QPen(option->palette.dark().color().dark(110), 0));
- switch (tbb->shape) {
-
- case QTabBar::RoundedNorth:
- painter->drawLine(tabRect.topLeft(), tabRect.topRight());
- break;
-
- case QTabBar::RoundedWest:
- painter->drawLine(tabRect.left(), tabRect.top(), tabRect.left(), tabRect.bottom());
- break;
-
- case QTabBar::RoundedSouth:
- painter->drawLine(tbb->rect.left(), tbb->rect.bottom(),
- tabRect.right(), tabRect.bottom());
- break;
-
- case QTabBar::RoundedEast:
- painter->drawLine(tabRect.topRight(), tabRect.bottomRight());
- break;
-
- case QTabBar::TriangularNorth:
- case QTabBar::TriangularEast:
- case QTabBar::TriangularWest:
- case QTabBar::TriangularSouth:
- painter->restore();
- QWindowsStyle::drawPrimitive(element, option, painter, widget);
- return;
- }
-
- painter->restore();
- }
- return;
-
-#endif // QT_NO_TABBAR
-
- case PE_Widget:
- break;
-
- default:
- QCleanlooksStyle::drawPrimitive(element, option, painter, widget);
- }
-}
-
-/*!
- \reimp
-*/
-void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
-
- QPainter *painter, const QWidget *widget) const
-{
- Q_D(const QGtkStyle);
-
- if (!d->isThemeAvailable()) {
- QCleanlooksStyle::drawComplexControl(control, option, painter, widget);
- return;
- }
-
- GtkStyle* style = d->gtkStyle();
- QGtkPainter gtkPainter(painter);
- QColor button = option->palette.button().color();
- QColor dark;
- QColor grooveColor;
- QColor darkOutline;
- dark.setHsv(button.hue(),
- qMin(255, (int)(button.saturation()*1.9)),
- qMin(255, (int)(button.value()*0.7)));
- grooveColor.setHsv(button.hue(),
- qMin(255, (int)(button.saturation()*2.6)),
- qMin(255, (int)(button.value()*0.9)));
- darkOutline.setHsv(button.hue(),
- qMin(255, (int)(button.saturation()*3.0)),
- qMin(255, (int)(button.value()*0.6)));
-
- QColor alphaCornerColor;
-
- if (widget)
- alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), darkOutline);
- else
- alphaCornerColor = mergedColors(option->palette.background().color(), darkOutline);
-
- switch (control) {
-
- case CC_TitleBar:
- if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) {
- // Since this is drawn by metacity and not Gtk we
- // have to rely on Cleanlooks for a fallback
- QStyleOptionTitleBar copyOpt = *tb;
- QPalette pal = copyOpt.palette;
- // Bg color is closer to the window selection than
- // the base selection color
- GdkColor gdkBg = style->bg[GTK_STATE_SELECTED];
- QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8);
- pal.setBrush(QPalette::Active, QPalette::Highlight, bgColor);
- copyOpt.palette = pal;
- QCleanlooksStyle::drawComplexControl(control, &copyOpt, painter, widget);
- }
- break;
-
-#ifndef QT_NO_GROUPBOX
-
- case CC_GroupBox:
- painter->save();
-
- if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) {
- QRect textRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxLabel, widget);
- QRect checkBoxRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxCheckBox, widget);
- // Draw title
-
- if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) {
- // Draw prelight background
- GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton");
-
- if (option->state & State_MouseOver) {
- QRect bgRect = textRect | checkBoxRect;
- gtkPainter.paintFlatBox(gtkCheckButton, "checkbutton", bgRect.adjusted(0, 0, 0, -2),
- GTK_STATE_PRELIGHT, GTK_SHADOW_ETCHED_OUT, gtkCheckButton->style);
- }
-
- if (!groupBox->text.isEmpty()) {
- int alignment = int(groupBox->textAlignment);
- if (!proxy()->styleHint(QStyle::SH_UnderlineShortcut, option, widget))
- alignment |= Qt::TextHideMnemonic;
- QColor textColor = groupBox->textColor; // Note: custom textColor is currently ignored
- int labelState = GTK_STATE_INSENSITIVE;
-
- if (option->state & State_Enabled)
- labelState = (option->state & State_MouseOver) ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL;
-
- GdkColor gdkText = gtkCheckButton->style->fg[labelState];
- textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
- painter->setPen(textColor);
- QFont font = painter->font();
- font.setBold(true);
- painter->setFont(font);
- painter->drawText(textRect, Qt::TextShowMnemonic | Qt::AlignLeft| alignment, groupBox->text);
-
- if (option->state & State_HasFocus)
- gtkPainter.paintFocus( NULL, "tab", textRect.adjusted(-4, -1, 0, -3), GTK_STATE_ACTIVE, style);
- }
- }
-
- if (groupBox->subControls & SC_GroupBoxCheckBox) {
- QStyleOptionButton box;
- box.QStyleOption::operator=(*groupBox);
- box.rect = checkBoxRect;
- proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget);
- }
- }
-
- painter->restore();
- break;
-#endif // QT_NO_GROUPBOX
-
-#ifndef QT_NO_COMBOBOX
-
- case CC_ComboBox:
- // See: http://live.gnome.org/GnomeArt/Tutorials/GtkThemes/GtkComboBox
- // and http://live.gnome.org/GnomeArt/Tutorials/GtkThemes/GtkComboBoxEntry
- if (const QStyleOptionComboBox *comboBox = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
- bool sunken = comboBox->state & State_On; // play dead, if combobox has no items
- BEGIN_STYLE_PIXMAPCACHE(QString::fromLatin1("cb-%0-%1").arg(sunken).arg(comboBox->editable));
- QGtkPainter gtkCachedPainter(p);
- gtkCachedPainter.setUsePixmapCache(false); // cached externally
-
- bool isEnabled = (comboBox->state & State_Enabled);
- bool focus = isEnabled && (comboBox->state & State_HasFocus);
- GtkStateType state = gtkPainter.gtkState(option);
- int appears_as_list = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, comboBox, widget);
- QStyleOptionComboBox comboBoxCopy = *comboBox;
- comboBoxCopy.rect = option->rect;
-
- bool reverse = (option->direction == Qt::RightToLeft);
- QRect rect = option->rect;
- QRect arrowButtonRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy,
- SC_ComboBoxArrow, widget);
-
- GtkShadowType shadow = (option->state & State_Sunken || option->state & State_On ) ?
- GTK_SHADOW_IN : GTK_SHADOW_OUT;
- const QHashableLatin1Literal comboBoxPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry") : QHashableLatin1Literal("GtkComboBox");
-
- // We use the gtk widget to position arrows and separators for us
- GtkWidget *gtkCombo = d->gtkWidget(comboBoxPath);
- GtkAllocation geometry = {0, 0, option->rect.width(), option->rect.height()};
- d->gtk_widget_set_direction(gtkCombo, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
- d->gtk_widget_size_allocate(gtkCombo, &geometry);
-
- QHashableLatin1Literal buttonPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton")
- : QHashableLatin1Literal("GtkComboBox.GtkToggleButton");
- GtkWidget *gtkToggleButton = d->gtkWidget(buttonPath);
- d->gtk_widget_set_direction(gtkToggleButton, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
- if (gtkToggleButton && (appears_as_list || comboBox->editable)) {
- if (focus)
- GTK_WIDGET_SET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
- // Draw the combo box as a line edit with a button next to it
- if (comboBox->editable || appears_as_list) {
- GtkStateType frameState = (state == GTK_STATE_PRELIGHT) ? GTK_STATE_NORMAL : state;
- QHashableLatin1Literal entryPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry.GtkEntry") : QHashableLatin1Literal("GtkComboBox.GtkFrame");
- GtkWidget *gtkEntry = d->gtkWidget(entryPath);
- d->gtk_widget_set_direction(gtkEntry, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
- QRect frameRect = option->rect;
-
- if (reverse)
- frameRect.setLeft(arrowButtonRect.right());
- else
- frameRect.setRight(arrowButtonRect.left());
-
- // Fill the line edit background
- // We could have used flat_box with "entry_bg" but that is probably not worth the overhead
- uint resolve_mask = option->palette.resolve();
- int xt = gtkEntry->style->xthickness;
- int yt = gtkEntry->style->ythickness;
- QRect contentRect = frameRect.adjusted(xt, yt, -xt, -yt);
- // Required for inner blue highlight with clearlooks
- if (focus)
- GTK_WIDGET_SET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
-
- if (widget && widget->testAttribute(Qt::WA_SetPalette) &&
- resolve_mask & (1 << QPalette::Base)) // Palette overridden by user
- p->fillRect(contentRect, option->palette.base().color());
- else {
- gtkCachedPainter.paintFlatBox(gtkEntry, "entry_bg", contentRect,
- option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
- GTK_SHADOW_NONE, gtkEntry->style, entryPath.toString() + QString::number(focus));
- }
-
- gtkCachedPainter.paintShadow(gtkEntry, comboBox->editable ? "entry" : "frame", frameRect, frameState,
- GTK_SHADOW_IN, gtkEntry->style, entryPath.toString() +
- QString::number(focus) + QString::number(comboBox->editable) +
- QString::number(option->direction));
- if (focus)
- GTK_WIDGET_UNSET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
- }
-
- GtkStateType buttonState = GTK_STATE_NORMAL;
-
- if (!(option->state & State_Enabled))
- buttonState = GTK_STATE_INSENSITIVE;
- else if (option->state & State_Sunken || option->state & State_On)
- buttonState = GTK_STATE_ACTIVE;
- else if (option->state & State_MouseOver && comboBox->activeSubControls & SC_ComboBoxArrow)
- buttonState = GTK_STATE_PRELIGHT;
-
- Q_ASSERT(gtkToggleButton);
- gtkCachedPainter.paintBox( gtkToggleButton, "button", arrowButtonRect, buttonState,
- shadow, gtkToggleButton->style, buttonPath.toString() +
- QString::number(focus) + QString::number(option->direction));
- if (focus)
- GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
- } else {
- // Draw combo box as a button
- QRect buttonRect = option->rect;
-
- if (focus) // Clearlooks actually check the widget for the default state
- GTK_WIDGET_SET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
- gtkCachedPainter.paintBox(gtkToggleButton, "button",
- buttonRect, state,
- shadow, gtkToggleButton->style,
- buttonPath.toString() + QString::number(focus));
- if (focus)
- GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
-
-
- // Draw the separator between label and arrows
- QHashableLatin1Literal vSeparatorPath = comboBox->editable
- ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkHBox.GtkVSeparator")
- : QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkHBox.GtkVSeparator");
-
- if (GtkWidget *gtkVSeparator = d->gtkWidget(vSeparatorPath)) {
- QRect vLineRect(gtkVSeparator->allocation.x,
- gtkVSeparator->allocation.y,
- gtkVSeparator->allocation.width,
- gtkVSeparator->allocation.height);
-
- gtkCachedPainter.paintVline( gtkVSeparator, "vseparator",
- vLineRect, state, gtkVSeparator->style,
- 0, vLineRect.height(), 0, vSeparatorPath.toString());
-
-
- gint interiorFocus = true;
- d->gtk_widget_style_get(gtkToggleButton, "interior-focus", &interiorFocus, NULL);
- int xt = interiorFocus ? gtkToggleButton->style->xthickness : 0;
- int yt = interiorFocus ? gtkToggleButton->style->ythickness : 0;
- if (focus && ((option->state & State_KeyboardFocusChange) || styleHint(SH_UnderlineShortcut, option, widget)))
- gtkCachedPainter.paintFocus(gtkToggleButton, "button",
- option->rect.adjusted(xt, yt, -xt, -yt),
- option->state & State_Sunken ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL,
- gtkToggleButton->style);
- }
- }
-
- if (comboBox->subControls & SC_ComboBoxArrow) {
- if (!isEnabled)
- state = GTK_STATE_INSENSITIVE;
- else if (sunken)
- state = GTK_STATE_ACTIVE;
- else if (option->state & State_MouseOver)
- state = GTK_STATE_PRELIGHT;
- else
- state = GTK_STATE_NORMAL;
-
- QHashableLatin1Literal arrowPath("");
- if (comboBox->editable) {
- if (appears_as_list)
- arrowPath = QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkArrow");
- else
- arrowPath = QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkHBox.GtkArrow");
- } else {
- if (appears_as_list)
- arrowPath = QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkArrow");
- else
- arrowPath = QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkHBox.GtkArrow");
- }
-
- GtkWidget *gtkArrow = d->gtkWidget(arrowPath);
- gfloat scale = 0.7;
- gint minSize = 15;
- QRect arrowWidgetRect;
-
- if (gtkArrow && !d->gtk_check_version(2, 12, 0)) {
- d->gtk_widget_style_get(gtkArrow, "arrow-scaling", &scale, NULL);
- d->gtk_widget_style_get(gtkCombo, "arrow-size", &minSize, NULL);
- }
- if (gtkArrow) {
- arrowWidgetRect = QRect(gtkArrow->allocation.x, gtkArrow->allocation.y,
- gtkArrow->allocation.width, gtkArrow->allocation.height);
- style = gtkArrow->style;
- }
-
- // Note that for some reason the arrow-size is not properly respected with Hildon
- // Hence we enforce the minimum "arrow-size" ourselves
- int arrowSize = qMax(qMin(rect.height() - gtkCombo->style->ythickness * 2, minSize),
- qMin(arrowWidgetRect.width(), arrowWidgetRect.height()));
- QRect arrowRect(0, 0, static_cast<int>(arrowSize * scale), static_cast<int>(arrowSize * scale));
-
- arrowRect.moveCenter(arrowWidgetRect.center());
-
- if (sunken) {
- int xoff, yoff;
- const QHashableLatin1Literal toggleButtonPath = comboBox->editable
- ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton")
- : QHashableLatin1Literal("GtkComboBox.GtkToggleButton");
-
- GtkWidget *gtkButton = d->gtkWidget(toggleButtonPath);
- d->gtk_widget_style_get(gtkButton, "child-displacement-x", &xoff, NULL);
- d->gtk_widget_style_get(gtkButton, "child-displacement-y", &yoff, NULL);
- arrowRect = arrowRect.adjusted(xoff, yoff, xoff, yoff);
- }
-
- // Some styles such as Nimbus paint outside the arrowRect
- // hence we have provide the whole widget as the cliprect
- if (gtkArrow) {
- gtkCachedPainter.setClipRect(option->rect);
- gtkCachedPainter.paintArrow( gtkArrow, "arrow", arrowRect,
- GTK_ARROW_DOWN, state, GTK_SHADOW_NONE, TRUE,
- style, arrowPath.toString() + QString::number(option->direction));
- }
- }
- END_STYLE_PIXMAPCACHE;
- }
- break;
-#endif // QT_NO_COMBOBOX
-#ifndef QT_NO_TOOLBUTTON
-
- case CC_ToolButton:
- if (const QStyleOptionToolButton *toolbutton
- = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
- QRect button, menuarea;
- button = proxy()->subControlRect(control, toolbutton, SC_ToolButton, widget);
- menuarea = proxy()->subControlRect(control, toolbutton, SC_ToolButtonMenu, widget);
- State bflags = toolbutton->state & ~(State_Sunken | State_MouseOver);
-
- if (bflags & State_AutoRaise)
- if (!(bflags & State_MouseOver))
- bflags &= ~State_Raised;
-
- State mflags = bflags;
-
- if (toolbutton->state & State_Sunken) {
- if (toolbutton->activeSubControls & SC_ToolButton)
- bflags |= State_Sunken;
- if (toolbutton->activeSubControls & SC_ToolButtonMenu)
- mflags |= State_Sunken;
- } else if (toolbutton->state & State_MouseOver) {
- if (toolbutton->activeSubControls & SC_ToolButton)
- bflags |= State_MouseOver;
- if (toolbutton->activeSubControls & SC_ToolButtonMenu)
- mflags |= State_MouseOver;
- }
-
- QStyleOption tool(0);
-
- tool.palette = toolbutton->palette;
-
- if (toolbutton->subControls & SC_ToolButton) {
- if (bflags & (State_Sunken | State_On | State_Raised | State_MouseOver)) {
- tool.rect = button;
- tool.state = bflags;
- proxy()->drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);
- }
- }
-
- bool drawMenuArrow = toolbutton->features & QStyleOptionToolButton::HasMenu &&
- !(toolbutton->features & QStyleOptionToolButton::MenuButtonPopup);
- int popupArrowSize = drawMenuArrow ? 7 : 0;
-
- if (toolbutton->state & State_HasFocus) {
- QStyleOptionFocusRect fr;
- fr.QStyleOption::operator=(*toolbutton);
- fr.rect = proxy()->subControlRect(CC_ToolButton, toolbutton, SC_ToolButton, widget);
- fr.rect.adjust(1, 1, -1, -1);
- proxy()->drawPrimitive(PE_FrameFocusRect, &fr, painter, widget);
- }
-
- QStyleOptionToolButton label = *toolbutton;
- label.state = bflags;
- GtkWidget *gtkButton = d->gtkWidget("GtkToolButton.GtkButton");
- QPalette pal = toolbutton->palette;
- if (option->state & State_Enabled &&
- option->state & State_MouseOver && !(widget && widget->testAttribute(Qt::WA_SetPalette))) {
- GdkColor gdkText = gtkButton->style->fg[GTK_STATE_PRELIGHT];
- QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
- pal.setBrush(QPalette::All, QPalette::ButtonText, textColor);
- label.palette = pal;
- }
- label.rect = button.adjusted(style->xthickness, style->ythickness,
- -style->xthickness - popupArrowSize, -style->ythickness);
- proxy()->drawControl(CE_ToolButtonLabel, &label, painter, widget);
-
- if (toolbutton->subControls & SC_ToolButtonMenu) {
- tool.rect = menuarea;
- tool.state = mflags;
- if ((mflags & State_Enabled && (mflags & (State_Sunken | State_Raised | State_MouseOver))) || !(mflags & State_AutoRaise))
- proxy()->drawPrimitive(PE_IndicatorButtonDropDown, &tool, painter, widget);
-
- proxy()->drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget);
-
- } else if (drawMenuArrow) {
- QRect ir = toolbutton->rect;
- QStyleOptionToolButton newBtn = *toolbutton;
- newBtn.rect = QRect(ir.right() - popupArrowSize - style->xthickness - 3, ir.height()/2 - 1, popupArrowSize, popupArrowSize);
- proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget);
- }
- }
- break;
-
-#endif // QT_NO_TOOLBUTTON
-#ifndef QT_NO_SCROLLBAR
-
- case CC_ScrollBar:
- if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
- GtkWidget *gtkHScrollBar = d->gtkWidget("GtkHScrollbar");
- GtkWidget *gtkVScrollBar = d->gtkWidget("GtkVScrollbar");
-
- // Fill background in case the scrollbar is partially transparent
- painter->fillRect(option->rect, option->palette.background());
-
- QRect rect = scrollBar->rect;
- QRect scrollBarSubLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget);
- QRect scrollBarAddLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget);
- QRect scrollBarSlider = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSlider, widget);
- QRect grooveRect = proxy()->subControlRect(control, scrollBar, SC_ScrollBarGroove, widget);
- bool horizontal = scrollBar->orientation == Qt::Horizontal;
- GtkWidget * scrollbarWidget = horizontal ? gtkHScrollBar : gtkVScrollBar;
- style = scrollbarWidget->style;
- gboolean trough_under_steppers = true;
- gboolean trough_side_details = false;
- gboolean activate_slider = false;
- gboolean stepper_size = 14;
- gint trough_border = 1;
- if (!d->gtk_check_version(2, 10, 0)) {
- d->gtk_widget_style_get((GtkWidget*)(scrollbarWidget),
- "trough-border", &trough_border,
- "trough-side-details", &trough_side_details,
- "trough-under-steppers", &trough_under_steppers,
- "activate-slider", &activate_slider,
- "stepper-size", &stepper_size, NULL);
- }
- if (trough_under_steppers) {
- scrollBarAddLine.adjust(trough_border, trough_border, -trough_border, -trough_border);
- scrollBarSubLine.adjust(trough_border, trough_border, -trough_border, -trough_border);
- scrollBarSlider.adjust(horizontal ? -trough_border : 0, horizontal ? 0 : -trough_border,
- horizontal ? trough_border : 0, horizontal ? 0 : trough_border);
- }
-
- // Some styles check the position of scrollbars in order to determine
- // if lines should be painted when the scrollbar is in max or min positions.
- int maximum = 2;
- int fakePos = 0;
- bool reverse = (option->direction == Qt::RightToLeft);
- if (scrollBar->minimum == scrollBar->maximum)
- maximum = 0;
- if (scrollBar->sliderPosition == scrollBar->maximum)
- fakePos = maximum;
- else if (scrollBar->sliderPosition > scrollBar->minimum)
- fakePos = maximum - 1;
-
-
- GtkRange *range = (GtkRange*)(horizontal ? gtkHScrollBar : gtkVScrollBar);
- GtkAdjustment *adjustment = d->gtk_range_get_adjustment(range);
-
- if (adjustment) {
- d->gtk_adjustment_configure(adjustment, fakePos, 0, maximum, 0, 0, 0);
- } else {
- adjustment = (GtkAdjustment*)d->gtk_adjustment_new(fakePos, 0, maximum, 0, 0, 0);
- d->gtk_range_set_adjustment(range, adjustment);
- }
-
- if (scrollBar->subControls & SC_ScrollBarGroove) {
- GtkStateType state = GTK_STATE_ACTIVE;
-
- if (!(option->state & State_Enabled))
- state = GTK_STATE_INSENSITIVE;
-
- if (trough_under_steppers)
- grooveRect = option->rect;
-
- gtkPainter.paintBox( scrollbarWidget, "trough", grooveRect, state, GTK_SHADOW_IN, style);
- }
-
- //paint slider
- if (scrollBar->subControls & SC_ScrollBarSlider) {
- GtkStateType state = GTK_STATE_NORMAL;
-
- if (!(option->state & State_Enabled))
- state = GTK_STATE_INSENSITIVE;
- else if (activate_slider &&
- option->state & State_Sunken && (scrollBar->activeSubControls & SC_ScrollBarSlider))
- state = GTK_STATE_ACTIVE;
- else if (option->state & State_MouseOver && (scrollBar->activeSubControls & SC_ScrollBarSlider))
- state = GTK_STATE_PRELIGHT;
-
- GtkShadowType shadow = GTK_SHADOW_OUT;
-
- if (trough_under_steppers) {
- if (!horizontal)
- scrollBarSlider.adjust(trough_border, 0, -trough_border, 0);
- else
- scrollBarSlider.adjust(0, trough_border, 0, -trough_border);
- }
-
- gtkPainter.paintSlider( scrollbarWidget, "slider", scrollBarSlider, state, shadow, style,
-
- horizontal ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, QString(QLS("%0%1")).arg(fakePos).arg(maximum));
- }
-
- if (scrollBar->subControls & SC_ScrollBarAddLine) {
- gtkVScrollBar->allocation.y = scrollBarAddLine.top();
- gtkVScrollBar->allocation.height = scrollBarAddLine.height() - rect.height() + 6;
- gtkHScrollBar->allocation.x = scrollBarAddLine.right();
- gtkHScrollBar->allocation.width = scrollBarAddLine.width() - rect.width();
-
- GtkShadowType shadow = GTK_SHADOW_OUT;
- GtkStateType state = GTK_STATE_NORMAL;
-
- if (!(option->state & State_Enabled) || (fakePos == maximum))
- state = GTK_STATE_INSENSITIVE;
- else if (option->state & State_Sunken && (scrollBar->activeSubControls & SC_ScrollBarAddLine)) {
- state = GTK_STATE_ACTIVE;
- shadow = GTK_SHADOW_IN;
-
- } else if (option->state & State_MouseOver && (scrollBar->activeSubControls & SC_ScrollBarAddLine))
- state = GTK_STATE_PRELIGHT;
-
- gtkPainter.paintBox( scrollbarWidget,
- horizontal ? "hscrollbar" : "vscrollbar", scrollBarAddLine,
- state, shadow, style, QLS("add"));
-
- gtkPainter.paintArrow( scrollbarWidget, horizontal ? "hscrollbar" : "vscrollbar", scrollBarAddLine.adjusted(4, 4, -4, -4),
- horizontal ? (reverse ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT) :
- GTK_ARROW_DOWN, state, GTK_SHADOW_NONE, FALSE, style);
- }
-
- if (scrollBar->subControls & SC_ScrollBarSubLine) {
- gtkVScrollBar->allocation.y = 0;
- gtkVScrollBar->allocation.height = scrollBarSubLine.height();
- gtkHScrollBar->allocation.x = 0;
- gtkHScrollBar->allocation.width = scrollBarSubLine.width();
-
- GtkShadowType shadow = GTK_SHADOW_OUT;
- GtkStateType state = GTK_STATE_NORMAL;
-
- if (!(option->state & State_Enabled) || (fakePos == 0))
- state = GTK_STATE_INSENSITIVE;
- else if (option->state & State_Sunken && (scrollBar->activeSubControls & SC_ScrollBarSubLine)) {
- shadow = GTK_SHADOW_IN;
- state = GTK_STATE_ACTIVE;
-
- } else if (option->state & State_MouseOver && (scrollBar->activeSubControls & SC_ScrollBarSubLine))
- state = GTK_STATE_PRELIGHT;
-
- gtkPainter.paintBox(scrollbarWidget, horizontal ? "hscrollbar" : "vscrollbar", scrollBarSubLine,
- state, shadow, style, QLS("sub"));
-
- gtkPainter.paintArrow(scrollbarWidget, horizontal ? "hscrollbar" : "vscrollbar", scrollBarSubLine.adjusted(4, 4, -4, -4),
- horizontal ? (reverse ? GTK_ARROW_RIGHT : GTK_ARROW_LEFT) :
- GTK_ARROW_UP, state, GTK_SHADOW_NONE, FALSE, style);
- }
- }
- break;
-
-#endif //QT_NO_SCROLLBAR
-#ifndef QT_NO_SPINBOX
-
- case CC_SpinBox:
- if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
-
- GtkWidget *gtkSpinButton = spinBox->buttonSymbols == QAbstractSpinBox::NoButtons
- ? d->gtkWidget("GtkEntry")
- : d->gtkWidget("GtkSpinButton");
- bool isEnabled = (spinBox->state & State_Enabled);
- bool hover = isEnabled && (spinBox->state & State_MouseOver);
- bool sunken = (spinBox->state & State_Sunken);
- bool upIsActive = (spinBox->activeSubControls == SC_SpinBoxUp);
- bool downIsActive = (spinBox->activeSubControls == SC_SpinBoxDown);
- bool reverse = (spinBox->direction == Qt::RightToLeft);
-
- QRect editArea = option->rect;
- QRect editRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxEditField, widget);
- QRect upRect, downRect, buttonRect;
- if (spinBox->buttonSymbols != QAbstractSpinBox::NoButtons) {
- upRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget);
- downRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget);
-
- //### Move this to subControlRect
- upRect.setTop(option->rect.top());
-
- if (reverse)
- upRect.setLeft(option->rect.left());
- else
- upRect.setRight(option->rect.right());
-
- downRect.setBottom(option->rect.bottom());
-
- if (reverse)
- downRect.setLeft(option->rect.left());
- else
- downRect.setRight(option->rect.right());
-
- buttonRect = upRect | downRect;
-
- if (reverse)
- editArea.setLeft(upRect.right());
- else
- editArea.setRight(upRect.left());
- }
- if (spinBox->frame) {
- GtkStateType state = gtkPainter.gtkState(option);
-
- if (!(option->state & State_Enabled))
- state = GTK_STATE_INSENSITIVE;
- else if (option->state & State_HasFocus)
- state = GTK_STATE_NORMAL;
- else if (state == GTK_STATE_PRELIGHT)
- state = GTK_STATE_NORMAL;
-
- style = gtkPainter.getStyle(gtkSpinButton);
-
-
- QString key;
-
- if (option->state & State_HasFocus) {
- key += QLatin1Char('f');
- GTK_WIDGET_SET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS);
- }
-
- uint resolve_mask = option->palette.resolve();
-
- if (resolve_mask & (1 << QPalette::Base)) // Palette overridden by user
- painter->fillRect(editRect, option->palette.base().color());
- else
- gtkPainter.paintFlatBox(gtkSpinButton, "entry_bg", editArea.adjusted(style->xthickness, style->ythickness,
- -style->xthickness, -style->ythickness),
- option->state & State_Enabled ?
- GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, GTK_SHADOW_NONE, style, key);
-
- gtkPainter.paintShadow(gtkSpinButton, "entry", editArea, state, GTK_SHADOW_IN, gtkSpinButton->style, key);
- if (spinBox->buttonSymbols != QAbstractSpinBox::NoButtons) {
- gtkPainter.paintBox(gtkSpinButton, "spinbutton", buttonRect, state, GTK_SHADOW_IN, style, key);
-
- upRect.setSize(downRect.size());
- if (!(option->state & State_Enabled))
- gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key);
- else if (upIsActive && sunken)
- gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key);
- else if (upIsActive && hover)
- gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key);
- else
- gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key);
-
- if (!(option->state & State_Enabled))
- gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key);
- else if (downIsActive && sunken)
- gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key);
- else if (downIsActive && hover)
- gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key);
- else
- gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key);
-
- if (option->state & State_HasFocus)
- GTK_WIDGET_UNSET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS);
- }
- }
-
- if (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) {
- int centerX = upRect.center().x();
- int centerY = upRect.center().y();
- // plus/minus
-
- if (spinBox->activeSubControls == SC_SpinBoxUp && sunken) {
- painter->drawLine(1 + centerX - 2, 1 + centerY, 1 + centerX + 2, 1 + centerY);
- painter->drawLine(1 + centerX, 1 + centerY - 2, 1 + centerX, 1 + centerY + 2);
-
- } else {
- painter->drawLine(centerX - 2, centerY, centerX + 2, centerY);
- painter->drawLine(centerX, centerY - 2, centerX, centerY + 2);
- }
- centerX = downRect.center().x();
- centerY = downRect.center().y();
-
- if (spinBox->activeSubControls == SC_SpinBoxDown && sunken) {
- painter->drawLine(1 + centerX - 2, 1 + centerY, 1 + centerX + 2, 1 + centerY);
- } else {
- painter->drawLine(centerX - 2, centerY, centerX + 2, centerY);
- }
-
- } else if (spinBox->buttonSymbols == QAbstractSpinBox::UpDownArrows) {
- int size = d->getSpinboxArrowSize();
- int w = size / 2 - 1;
- w -= w % 2 - 1; // force odd
- int h = (w + 1)/2;
- QRect arrowRect(0, 0, w, h);
- arrowRect.moveCenter(upRect.center());
- // arrows
- GtkStateType state = GTK_STATE_NORMAL;
-
- if (!(option->state & State_Enabled) || !(spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled))
- state = GTK_STATE_INSENSITIVE;
-
- gtkPainter.paintArrow( gtkSpinButton, "spinbutton", arrowRect, GTK_ARROW_UP, state,
- GTK_SHADOW_NONE, FALSE, style);
-
- arrowRect.moveCenter(downRect.center());
-
- if (!(option->state & State_Enabled) || !(spinBox->stepEnabled & QAbstractSpinBox::StepDownEnabled))
- state = GTK_STATE_INSENSITIVE;
-
- gtkPainter.paintArrow( gtkSpinButton, "spinbutton", arrowRect, GTK_ARROW_DOWN, state,
- GTK_SHADOW_NONE, FALSE, style);
- }
- }
- break;
-
-#endif // QT_NO_SPINBOX
-
-#ifndef QT_NO_SLIDER
-
- case CC_Slider:
- if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
- GtkWidget *hScaleWidget = d->gtkWidget("GtkHScale");
- GtkWidget *vScaleWidget = d->gtkWidget("GtkVScale");
-
- QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget);
- QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget);
-
- bool horizontal = slider->orientation == Qt::Horizontal;
- bool ticksAbove = slider->tickPosition & QSlider::TicksAbove;
- bool ticksBelow = slider->tickPosition & QSlider::TicksBelow;
-
- QBrush oldBrush = painter->brush();
- QPen oldPen = painter->pen();
-
- QColor shadowAlpha(Qt::black);
- shadowAlpha.setAlpha(10);
- QColor highlightAlpha(Qt::white);
- highlightAlpha.setAlpha(80);
-
- QGtkStylePrivate::gtk_widget_set_direction(hScaleWidget, slider->upsideDown ?
- GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
- GtkWidget *scaleWidget = horizontal ? hScaleWidget : vScaleWidget;
- style = scaleWidget->style;
-
- if ((option->subControls & SC_SliderGroove) && groove.isValid()) {
-
- GtkRange *range = (GtkRange*)scaleWidget;
- GtkAdjustment *adjustment = d->gtk_range_get_adjustment(range);
- if (adjustment) {
- d->gtk_adjustment_configure(adjustment,
- slider->sliderPosition,
- slider->minimum,
- slider->maximum,
- slider->singleStep,
- slider->singleStep,
- slider->pageStep);
- } else {
- adjustment = (GtkAdjustment*)d->gtk_adjustment_new(slider->sliderPosition,
- slider->minimum,
- slider->maximum,
- slider->singleStep,
- slider->singleStep,
- slider->pageStep);
- d->gtk_range_set_adjustment(range, adjustment);
- }
-
- int outerSize;
- d->gtk_range_set_inverted(range, !horizontal);
- d->gtk_widget_style_get(scaleWidget, "trough-border", &outerSize, NULL);
- outerSize++;
-
- GtkStateType state = gtkPainter.gtkState(option);
- int focusFrameMargin = 2;
- QRect grooveRect = option->rect.adjusted(focusFrameMargin, outerSize + focusFrameMargin,
- -focusFrameMargin, -outerSize - focusFrameMargin);
-
- gboolean trough_side_details = false; // Indicates if the upper or lower scale background differs
- if (!d->gtk_check_version(2, 10, 0))
- d->gtk_widget_style_get((GtkWidget*)(scaleWidget), "trough-side-details", &trough_side_details, NULL);
-
- if (!trough_side_details) {
- gtkPainter.paintBox( scaleWidget, "trough", grooveRect, state,
- GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition));
- } else {
- QRect upperGroove = grooveRect;
- QRect lowerGroove = grooveRect;
-
- if (horizontal) {
- if (slider->upsideDown) {
- lowerGroove.setLeft(handle.center().x());
- upperGroove.setRight(handle.center().x());
- } else {
- upperGroove.setLeft(handle.center().x());
- lowerGroove.setRight(handle.center().x());
- }
- } else {
- if (!slider->upsideDown) {
- lowerGroove.setBottom(handle.center().y());
- upperGroove.setTop(handle.center().y());
- } else {
- upperGroove.setBottom(handle.center().y());
- lowerGroove.setTop(handle.center().y());
- }
- }
-
- gtkPainter.paintBox( scaleWidget, "trough-upper", upperGroove, state,
- GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition));
- gtkPainter.paintBox( scaleWidget, "trough-lower", lowerGroove, state,
- GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition));
- }
- }
-
- if (option->subControls & SC_SliderTickmarks) {
- painter->setPen(darkOutline);
- int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget);
- int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget);
- int interval = slider->tickInterval;
-
- if (interval <= 0) {
- interval = slider->singleStep;
-
- if (QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, interval,
- available)
- - QStyle::sliderPositionFromValue(slider->minimum, slider->maximum,
- 0, available) < 3)
- interval = slider->pageStep;
- }
-
- if (interval <= 0)
- interval = 1;
-
- int v = slider->minimum;
- int len = proxy()->pixelMetric(PM_SliderLength, slider, widget);
- while (v <= slider->maximum + 1) {
- if (v == slider->maximum + 1 && interval == 1)
- break;
- const int v_ = qMin(v, slider->maximum);
- int pos = sliderPositionFromValue(slider->minimum, slider->maximum,
- v_, (horizontal
- ? slider->rect.width()
- : slider->rect.height()) - len,
- slider->upsideDown) + len / 2;
- int extra = 2 - ((v_ == slider->minimum || v_ == slider->maximum) ? 1 : 0);
- if (horizontal) {
- if (ticksAbove)
- painter->drawLine(pos, slider->rect.top() + extra,
- pos, slider->rect.top() + tickSize);
- if (ticksBelow)
- painter->drawLine(pos, slider->rect.bottom() - extra,
- pos, slider->rect.bottom() - tickSize);
-
- } else {
- if (ticksAbove)
- painter->drawLine(slider->rect.left() + extra, pos,
- slider->rect.left() + tickSize, pos);
- if (ticksBelow)
- painter->drawLine(slider->rect.right() - extra, pos,
- slider->rect.right() - tickSize, pos);
- }
-
- // In the case where maximum is max int
- int nextInterval = v + interval;
- if (nextInterval < v)
- break;
- v = nextInterval;
- }
- }
-
- // Draw slider handle
- if (option->subControls & SC_SliderHandle) {
- GtkShadowType shadow = GTK_SHADOW_OUT;
- GtkStateType state = GTK_STATE_NORMAL;
-
- if (!(option->state & State_Enabled))
- state = GTK_STATE_INSENSITIVE;
- else if (option->state & State_MouseOver && option->activeSubControls & SC_SliderHandle)
- state = GTK_STATE_PRELIGHT;
-
- bool horizontal = option->state & State_Horizontal;
-
- if (slider->state & State_HasFocus) {
- QStyleOptionFocusRect fropt;
- fropt.QStyleOption::operator=(*slider);
- fropt.rect = slider->rect.adjusted(-1, -1 ,1, 1);
-
- if (horizontal) {
- fropt.rect.setTop(handle.top() - 3);
- fropt.rect.setBottom(handle.bottom() + 4);
-
- } else {
- fropt.rect.setLeft(handle.left() - 3);
- fropt.rect.setRight(handle.right() + 3);
- }
- proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
- }
- gtkPainter.paintSlider( scaleWidget, horizontal ? "hscale" : "vscale", handle, state, shadow, style,
-
- horizontal ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
- }
- painter->setBrush(oldBrush);
- painter->setPen(oldPen);
- }
- break;
-
-#endif // QT_NO_SLIDER
-
- default:
- QCleanlooksStyle::drawComplexControl(control, option, painter, widget);
-
- break;
- }
-}
-
-
-/*!
- \reimp
-*/
-void QGtkStyle::drawControl(ControlElement element,
- const QStyleOption *option,
- QPainter *painter,
- const QWidget *widget) const
-{
- Q_D(const QGtkStyle);
-
- if (!d->isThemeAvailable()) {
- QCleanlooksStyle::drawControl(element, option, painter, widget);
- return;
- }
-
- GtkStyle* style = d->gtkStyle();
- QGtkPainter gtkPainter(painter);
-
- switch (element) {
- case CE_ProgressBarLabel:
- if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
- GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar");
- if (!gtkProgressBar)
- return;
-
- QRect leftRect;
- QRect rect = bar->rect;
- GdkColor gdkText = gtkProgressBar->style->fg[GTK_STATE_NORMAL];
- QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
- gdkText = gtkProgressBar->style->fg[GTK_STATE_PRELIGHT];
- QColor alternateTextColor= QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
-
- painter->save();
- bool vertical = false, inverted = false;
- if (const QStyleOptionProgressBarV2 *bar2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) {
- vertical = (bar2->orientation == Qt::Vertical);
- inverted = bar2->invertedAppearance;
- }
- if (vertical)
- rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height
- const int progressIndicatorPos = (bar->progress - qreal(bar->minimum)) * rect.width() /
- qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum);
- if (progressIndicatorPos >= 0 && progressIndicatorPos <= rect.width())
- leftRect = QRect(rect.left(), rect.top(), progressIndicatorPos, rect.height());
- if (vertical)
- leftRect.translate(rect.width() - progressIndicatorPos, 0);
-
- bool flip = (!vertical && (((bar->direction == Qt::RightToLeft) && !inverted) ||
- ((bar->direction == Qt::LeftToRight) && inverted)));
-
- QRegion rightRect = rect;
- rightRect = rightRect.subtracted(leftRect);
- painter->setClipRegion(rightRect);
- painter->setPen(flip ? alternateTextColor : textColor);
- painter->drawText(rect, bar->text, QTextOption(Qt::AlignAbsolute | Qt::AlignHCenter | Qt::AlignVCenter));
- if (!leftRect.isNull()) {
- painter->setPen(flip ? textColor : alternateTextColor);
- painter->setClipRect(leftRect);
- painter->drawText(rect, bar->text, QTextOption(Qt::AlignAbsolute | Qt::AlignHCenter | Qt::AlignVCenter));
- }
- painter->restore();
- }
- break;
- case CE_PushButtonLabel:
- if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- QRect ir = button->rect;
- uint tf = Qt::AlignVCenter | Qt::TextShowMnemonic;
- QPoint buttonShift;
-
- if (option->state & State_Sunken)
- buttonShift = QPoint(pixelMetric(PM_ButtonShiftHorizontal, option, widget),
- proxy()->pixelMetric(PM_ButtonShiftVertical, option, widget));
-
- if (proxy()->styleHint(SH_UnderlineShortcut, button, widget))
- tf |= Qt::TextShowMnemonic;
- else
- tf |= Qt::TextHideMnemonic;
-
- if (!button->icon.isNull()) {
- //Center both icon and text
- QPoint point;
-
- QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal : QIcon::Disabled;
- if (mode == QIcon::Normal && button->state & State_HasFocus)
- mode = QIcon::Active;
-
- QIcon::State state = QIcon::Off;
-
- if (button->state & State_On)
- state = QIcon::On;
-
- QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state);
- int w = pixmap.width();
- int h = pixmap.height();
-
- if (!button->text.isEmpty())
- w += button->fontMetrics.boundingRect(option->rect, tf, button->text).width() + 4;
-
- point = QPoint(ir.x() + ir.width() / 2 - w / 2,
- ir.y() + ir.height() / 2 - h / 2);
-
- if (button->direction == Qt::RightToLeft)
- point.rx() += pixmap.width();
-
- painter->drawPixmap(visualPos(button->direction, button->rect, point + buttonShift), pixmap);
-
- if (button->direction == Qt::RightToLeft)
- ir.translate(-point.x() - 2, 0);
- else
- ir.translate(point.x() + pixmap.width() + 2, 0);
-
- // left-align text if there is
- if (!button->text.isEmpty())
- tf |= Qt::AlignLeft;
-
- } else {
- tf |= Qt::AlignHCenter;
- }
-
- ir.translate(buttonShift);
-
- if (button->features & QStyleOptionButton::HasMenu)
- ir = ir.adjusted(0, 0, -pixelMetric(PM_MenuButtonIndicator, button, widget), 0);
-
- GtkWidget *gtkButton = d->gtkWidget("GtkButton");
- QPalette pal = button->palette;
- int labelState = GTK_STATE_INSENSITIVE;
- if (option->state & State_Enabled)
- labelState = (option->state & State_MouseOver && !(option->state & State_Sunken)) ?
- GTK_STATE_PRELIGHT : GTK_STATE_NORMAL;
-
- GdkColor gdkText = gtkButton->style->fg[labelState];
- QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
- pal.setBrush(QPalette::ButtonText, textColor);
- proxy()->drawItemText(painter, ir, tf, pal, (button->state & State_Enabled),
- button->text, QPalette::ButtonText);
- }
- break;
-
- case CE_RadioButton: // Fall through
- case CE_CheckBox:
- if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- bool isRadio = (element == CE_RadioButton);
-
- // Draw prelight background
- GtkWidget *gtkRadioButton = d->gtkWidget("GtkRadioButton");
-
- if (option->state & State_MouseOver) {
- gtkPainter.paintFlatBox(gtkRadioButton, "checkbutton", option->rect,
- GTK_STATE_PRELIGHT, GTK_SHADOW_ETCHED_OUT, gtkRadioButton->style);
- }
-
- QStyleOptionButton subopt = *btn;
- subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator
- : SE_CheckBoxIndicator, btn, widget);
- proxy()->drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox,
- &subopt, painter, widget);
- subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents
- : SE_CheckBoxContents, btn, widget);
- // Get label text color
- QPalette pal = subopt.palette;
- int labelState = GTK_STATE_INSENSITIVE;
- if (option->state & State_Enabled)
- labelState = (option->state & State_MouseOver) ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL;
-
- GdkColor gdkText = gtkRadioButton->style->fg[labelState];
- QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
- pal.setBrush(QPalette::WindowText, textColor);
- subopt.palette = pal;
- proxy()->drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, painter, widget);
-
- if (btn->state & State_HasFocus) {
- QStyleOptionFocusRect fropt;
- fropt.QStyleOption::operator=(*btn);
- fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect
- : SE_CheckBoxFocusRect, btn, widget);
- proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
- }
- }
- break;
-
-#ifndef QT_NO_COMBOBOX
-
- case CE_ComboBoxLabel:
- if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
- QRect editRect = proxy()->subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget);
- bool appearsAsList = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, cb, widget);
- painter->save();
- painter->setClipRect(editRect);
-
- if (!cb->currentIcon.isNull()) {
- QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal
- : QIcon::Disabled;
- QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode);
- QRect iconRect(editRect);
- iconRect.setWidth(cb->iconSize.width() + 4);
-
- iconRect = alignedRect(cb->direction,
- Qt::AlignLeft | Qt::AlignVCenter,
- iconRect.size(), editRect);
-
- if (cb->editable)
- painter->fillRect(iconRect, option->palette.brush(QPalette::Base));
-
- proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap);
-
- if (cb->direction == Qt::RightToLeft)
- editRect.translate(-4 - cb->iconSize.width(), 0);
- else
- editRect.translate(cb->iconSize.width() + 4, 0);
- }
-
- if (!cb->currentText.isEmpty() && !cb->editable) {
- GtkWidget *gtkCombo = d->gtkWidget("GtkComboBox");
- QPalette pal = cb->palette;
- int labelState = GTK_STATE_INSENSITIVE;
-
- if (option->state & State_Enabled)
- labelState = (option->state & State_MouseOver && !appearsAsList) ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL;
-
- GdkColor gdkText = gtkCombo->style->fg[labelState];
-
- QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
-
- pal.setBrush(QPalette::ButtonText, textColor);
-
- proxy()->drawItemText(painter, editRect.adjusted(1, 0, -1, 0),
- visualAlignment(cb->direction, Qt::AlignLeft | Qt::AlignVCenter),
- pal, cb->state & State_Enabled, cb->currentText, QPalette::ButtonText);
- }
-
- painter->restore();
- }
- break;
-
-#endif // QT_NO_COMBOBOX
-
- case CE_DockWidgetTitle:
- painter->save();
- if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option)) {
- const QStyleOptionDockWidgetV2 *v2
- = qstyleoption_cast<const QStyleOptionDockWidgetV2*>(dwOpt);
- bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
-
- QRect rect = dwOpt->rect;
- QRect titleRect = subElementRect(SE_DockWidgetTitleBarText, option, widget).adjusted(-2, 0, -2, 0);
- QRect r = rect.adjusted(0, 0, -1, -1);
- if (verticalTitleBar)
- r.adjust(0, 0, 0, -1);
-
- if (verticalTitleBar) {
- QRect r = rect;
- QSize s = r.size();
- s.transpose();
- r.setSize(s);
-
- titleRect = QRect(r.left() + rect.bottom()
- - titleRect.bottom(),
- r.top() + titleRect.left() - rect.left(),
- titleRect.height(), titleRect.width());
-
- painter->translate(r.left(), r.top() + r.width());
- painter->rotate(-90);
- painter->translate(-r.left(), -r.top());
-
- rect = r;
- }
-
- if (!dwOpt->title.isEmpty()) {
- QString titleText
- = painter->fontMetrics().elidedText(dwOpt->title,
- Qt::ElideRight, titleRect.width());
- proxy()->drawItemText(painter,
- titleRect,
- Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, dwOpt->palette,
- dwOpt->state & State_Enabled, titleText,
- QPalette::WindowText);
- }
- }
- painter->restore();
- break;
-
-
-
- case CE_HeaderSection:
- painter->save();
-
- // Draws the header in tables.
- if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
- Q_UNUSED(header);
- GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView");
- // Get the middle column
- GtkTreeViewColumn *column = d->gtk_tree_view_get_column((GtkTreeView*)gtkTreeView, 1);
- Q_ASSERT(column);
-
- GtkWidget *gtkTreeHeader = column->button;
- GtkStateType state = gtkPainter.gtkState(option);
- GtkShadowType shadow = GTK_SHADOW_OUT;
-
- if (option->state & State_Sunken)
- shadow = GTK_SHADOW_IN;
-
- gtkPainter.paintBox(gtkTreeHeader, "button", option->rect.adjusted(-1, 0, 0, 0), state, shadow, gtkTreeHeader->style);
- }
-
- painter->restore();
- break;
-
-#ifndef QT_NO_SIZEGRIP
-
- case CE_SizeGrip: {
- GtkWidget *gtkStatusbar = d->gtkWidget("GtkStatusbar.GtkFrame");
- QRect gripRect = option->rect.adjusted(0, 0, -gtkStatusbar->style->xthickness, -gtkStatusbar->style->ythickness);
- gtkPainter.paintResizeGrip( gtkStatusbar, "statusbar", gripRect, GTK_STATE_NORMAL,
- GTK_SHADOW_OUT, QApplication::isRightToLeft() ?
- GDK_WINDOW_EDGE_SOUTH_WEST : GDK_WINDOW_EDGE_SOUTH_EAST,
- gtkStatusbar->style);
- }
- break;
-
-#endif // QT_NO_SIZEGRIP
-
- case CE_MenuBarEmptyArea: {
- GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar");
- GdkColor gdkBg = gtkMenubar->style->bg[GTK_STATE_NORMAL]; // Theme can depend on transparency
- painter->fillRect(option->rect, QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8));
- if (widget) { // See CE_MenuBarItem
- QRect menuBarRect = widget->rect();
- QPixmap pixmap(menuBarRect.size());
- pixmap.fill(Qt::transparent);
- QPainter pmPainter(&pixmap);
- QGtkPainter gtkMenuBarPainter(&pmPainter);
- GtkShadowType shadow_type;
- d->gtk_widget_style_get(gtkMenubar, "shadow-type", &shadow_type, NULL);
- gtkMenuBarPainter.paintBox( gtkMenubar, "menubar", menuBarRect,
- GTK_STATE_NORMAL, shadow_type, gtkMenubar->style);
- pmPainter.end();
- painter->drawPixmap(option->rect, pixmap, option->rect);
- }
- }
- break;
-
- case CE_MenuBarItem:
- painter->save();
-
- if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
- GtkWidget *gtkMenubarItem = d->gtkWidget("GtkMenuBar.GtkMenuItem");
- GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar");
-
- style = gtkMenubarItem->style;
-
- if (widget) {
- // Since Qt does not currently allow filling the entire background
- // we use a hack for this by making a complete menubar each time and
- // paint with the correct offset inside it. Pixmap caching should resolve
- // most of the performance penalty.
- QRect menuBarRect = widget->rect();
- QPixmap pixmap(menuBarRect.size());
- pixmap.fill(Qt::transparent);
- QPainter pmPainter(&pixmap);
- QGtkPainter menubarPainter(&pmPainter);
- GtkShadowType shadow_type;
- d->gtk_widget_style_get(gtkMenubar, "shadow-type", &shadow_type, NULL);
- GdkColor gdkBg = gtkMenubar->style->bg[GTK_STATE_NORMAL]; // Theme can depend on transparency
- painter->fillRect(option->rect, QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8));
- menubarPainter.paintBox(gtkMenubar, "menubar", menuBarRect,
- GTK_STATE_NORMAL, shadow_type, gtkMenubar->style);
- pmPainter.end();
- painter->drawPixmap(option->rect, pixmap, option->rect);
- }
-
- QStyleOptionMenuItem item = *mbi;
- bool act = mbi->state & State_Selected && mbi->state & State_Sunken;
- bool dis = !(mbi->state & State_Enabled);
- item.rect = mbi->rect;
- GdkColor gdkText = gtkMenubarItem->style->fg[dis ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL];
- GdkColor gdkHText = gtkMenubarItem->style->fg[GTK_STATE_PRELIGHT];
- QColor normalTextColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
- QColor highlightedTextColor = QColor(gdkHText.red>>8, gdkHText.green>>8, gdkHText.blue>>8);
- item.palette.setBrush(QPalette::HighlightedText, highlightedTextColor);
- item.palette.setBrush(QPalette::Text, normalTextColor);
- item.palette.setBrush(QPalette::ButtonText, normalTextColor);
- QCommonStyle::drawControl(element, &item, painter, widget);
-
- if (act) {
- GtkShadowType shadowType = GTK_SHADOW_NONE;
- d->gtk_widget_style_get (gtkMenubarItem, "selected-shadow-type", &shadowType, NULL);
- gtkPainter.paintBox(gtkMenubarItem, "menuitem", option->rect.adjusted(0, 0, 0, 3),
- GTK_STATE_PRELIGHT, shadowType, gtkMenubarItem->style);
- //draw text
- QPalette::ColorRole textRole = dis ? QPalette::Text : QPalette::HighlightedText;
- uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
-
- if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget))
- alignment |= Qt::TextHideMnemonic;
-
- proxy()->drawItemText(painter, item.rect, alignment, item.palette, mbi->state & State_Enabled, mbi->text, textRole);
- }
- }
- painter->restore();
- break;
-
- case CE_Splitter: {
- GtkWidget *gtkWindow = d->gtkWidget("GtkWindow"); // The Murrine Engine currently assumes a widget is passed
- gtkPainter.paintHandle(gtkWindow, "splitter", option->rect, gtkPainter.gtkState(option), GTK_SHADOW_NONE,
- !(option->state & State_Horizontal) ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL,
- style);
- }
- break;
-
-#ifndef QT_NO_TOOLBAR
-
- case CE_ToolBar:
- if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) {
- // Reserve the beveled appearance only for mainwindow toolbars
- if (!(widget && qobject_cast<const QMainWindow*> (widget->parentWidget())))
- break;
-
- QRect rect = option->rect;
- // There is a 1 pixel gap between toolbar lines in some styles (i.e Human)
- if (toolbar->positionWithinLine != QStyleOptionToolBar::End)
- rect.adjust(0, 0, 1, 0);
-
- GtkWidget *gtkToolbar = d->gtkWidget("GtkToolbar");
- GtkShadowType shadow_type = GTK_SHADOW_NONE;
- d->gtk_widget_style_get(gtkToolbar, "shadow-type", &shadow_type, NULL);
- gtkPainter.paintBox( gtkToolbar, "toolbar", rect,
- GTK_STATE_NORMAL, shadow_type, gtkToolbar->style);
- }
- break;
-
-#endif // QT_NO_TOOLBAR
-
- case CE_MenuItem:
- painter->save();
-
- // Draws one item in a popup menu.
- if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
- const int windowsItemFrame = 2; // menu item frame width
- const int windowsItemHMargin = 3; // menu item hor text margin
- const int windowsItemVMargin = 26; // menu item ver text margin
- const int windowsRightBorder = 15; // right border on windows
- GtkWidget *gtkMenuItem = menuItem->checked ? d->gtkWidget("GtkMenu.GtkCheckMenuItem") :
- d->gtkWidget("GtkMenu.GtkMenuItem");
-
- style = gtkPainter.getStyle(gtkMenuItem);
- QColor shadow = option->palette.dark().color();
-
- if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
- GtkWidget *gtkMenuSeparator = d->gtkWidget("GtkMenu.GtkSeparatorMenuItem");
- painter->setPen(shadow.lighter(106));
- gboolean wide_separators = 0;
- gint separator_height = 0;
- guint horizontal_padding = 3;
- QRect separatorRect = option->rect;
- if (!d->gtk_check_version(2, 10, 0)) {
- d->gtk_widget_style_get(gtkMenuSeparator,
- "wide-separators", &wide_separators,
- "separator-height", &separator_height,
- "horizontal-padding", &horizontal_padding,
- NULL);
- }
- separatorRect.setHeight(option->rect.height() - 2 * gtkMenuSeparator->style->ythickness);
- separatorRect.setWidth(option->rect.width() - 2 * (horizontal_padding + gtkMenuSeparator->style->xthickness));
- separatorRect.moveCenter(option->rect.center());
- if (wide_separators)
- gtkPainter.paintBox( gtkMenuSeparator, "hseparator",
- separatorRect, GTK_STATE_NORMAL, GTK_SHADOW_NONE, gtkMenuSeparator->style);
- else
- gtkPainter.paintHline( gtkMenuSeparator, "hseparator",
- separatorRect, GTK_STATE_NORMAL, gtkMenuSeparator->style,
- 0, option->rect.right() - 1, 1);
- painter->restore();
- break;
- }
-
- bool selected = menuItem->state & State_Selected && menuItem->state & State_Enabled;
-
- if (selected) {
- QRect rect = option->rect;
-#ifndef QT_NO_COMBOBOX
- if (qobject_cast<const QComboBox*>(widget))
- rect = option->rect;
-#endif
- gtkPainter.paintBox( gtkMenuItem, "menuitem", rect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style);
- }
-
- bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable;
- bool checked = menuItem->checked;
- bool enabled = menuItem->state & State_Enabled;
- bool ignoreCheckMark = false;
-
- gint checkSize;
- d->gtk_widget_style_get(d->gtkWidget("GtkMenu.GtkCheckMenuItem"), "indicator-size", &checkSize, NULL);
-
- int checkcol = qMax(menuItem->maxIconWidth, qMax(20, checkSize));
-
-#ifndef QT_NO_COMBOBOX
-
- if (qobject_cast<const QComboBox*>(widget))
- ignoreCheckMark = true; // Ignore the checkmarks provided by the QComboMenuDelegate
-
-#endif
- if (!ignoreCheckMark) {
- // Check
- QRect checkRect(option->rect.left() + 7, option->rect.center().y() - checkSize/2 + 1, checkSize, checkSize);
- checkRect = visualRect(menuItem->direction, menuItem->rect, checkRect);
-
- if (checkable && menuItem->icon.isNull()) {
- // Some themes such as aero-clone draw slightly outside the paint rect
- int spacing = 1; // ### Consider using gtkCheckBox : "indicator-spacing" instead
-
- if (menuItem->checkType & QStyleOptionMenuItem::Exclusive) {
- // Radio button
- GtkShadowType shadow = GTK_SHADOW_OUT;
- GtkStateType state = gtkPainter.gtkState(option);
-
- if (selected)
- state = GTK_STATE_PRELIGHT;
- if (checked)
- shadow = GTK_SHADOW_IN;
-
- gtkPainter.setClipRect(checkRect.adjusted(-spacing, -spacing, spacing, spacing));
- gtkPainter.paintOption(gtkMenuItem, checkRect.translated(-spacing, -spacing), state, shadow,
- gtkMenuItem->style, QLS("option"));
- gtkPainter.setClipRect(QRect());
-
- } else {
- // Check box
- if (menuItem->icon.isNull()) {
- GtkShadowType shadow = GTK_SHADOW_OUT;
- GtkStateType state = gtkPainter.gtkState(option);
-
- if (selected)
- state = GTK_STATE_PRELIGHT;
- if (checked)
- shadow = GTK_SHADOW_IN;
-
- gtkPainter.setClipRect(checkRect.adjusted(-spacing, -spacing, -spacing, -spacing));
- gtkPainter.paintCheckbox(gtkMenuItem, checkRect.translated(-spacing, -spacing), state, shadow,
- gtkMenuItem->style, QLS("check"));
- gtkPainter.setClipRect(QRect());
- }
- }
- }
-
- } else {
- // Ignore checkmark
- if (menuItem->icon.isNull())
- checkcol = 0;
- else
- checkcol = menuItem->maxIconWidth;
- }
-
- bool dis = !(menuItem->state & State_Enabled);
- bool act = menuItem->state & State_Selected;
- const QStyleOption *opt = option;
- const QStyleOptionMenuItem *menuitem = menuItem;
- QPainter *p = painter;
- QRect vCheckRect = visualRect(opt->direction, menuitem->rect,
- QRect(menuitem->rect.x() + 3, menuitem->rect.y(),
- checkcol, menuitem->rect.height()));
-
- if (!menuItem->icon.isNull()) {
- QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
-
- if (act && !dis)
- mode = QIcon::Active;
-
- QPixmap pixmap;
- int smallIconSize = proxy()->pixelMetric(PM_SmallIconSize, option, widget);
- QSize iconSize(smallIconSize, smallIconSize);
-
-#ifndef QT_NO_COMBOBOX
- if (const QComboBox *combo = qobject_cast<const QComboBox*>(widget))
- iconSize = combo->iconSize();
-
-#endif // QT_NO_COMBOBOX
- if (checked)
- pixmap = menuItem->icon.pixmap(iconSize, mode, QIcon::On);
- else
- pixmap = menuItem->icon.pixmap(iconSize, mode);
-
- int pixw = pixmap.width();
- int pixh = pixmap.height();
- QRect pmr(0, 0, pixw, pixh);
- pmr.moveCenter(vCheckRect.center() - QPoint(0, 1));
- painter->setPen(menuItem->palette.text().color());
- if (!ignoreCheckMark && checkable && checked) {
- QStyleOption opt = *option;
-
- if (act) {
- QColor activeColor = mergedColors(option->palette.background().color(),
- option->palette.highlight().color());
- opt.palette.setBrush(QPalette::Button, activeColor);
- }
- opt.state |= State_Sunken;
- opt.rect = vCheckRect;
- proxy()->drawPrimitive(PE_PanelButtonCommand, &opt, painter, widget);
- }
- painter->drawPixmap(pmr.topLeft(), pixmap);
- }
-
- GdkColor gdkText = gtkMenuItem->style->fg[GTK_STATE_NORMAL];
- GdkColor gdkDText = gtkMenuItem->style->fg[GTK_STATE_INSENSITIVE];
- GdkColor gdkHText = gtkMenuItem->style->fg[GTK_STATE_PRELIGHT];
- uint resolve_mask = option->palette.resolve();
- QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
- QColor disabledTextColor = QColor(gdkDText.red>>8, gdkDText.green>>8, gdkDText.blue>>8);
- if (resolve_mask & (1 << QPalette::ButtonText)) {
- textColor = option->palette.buttonText().color();
- disabledTextColor = option->palette.brush(QPalette::Disabled, QPalette::ButtonText).color();
- }
-
- QColor highlightedTextColor = QColor(gdkHText.red>>8, gdkHText.green>>8, gdkHText.blue>>8);
- if (resolve_mask & (1 << QPalette::HighlightedText)) {
- highlightedTextColor = option->palette.highlightedText().color();
- }
-
- if (selected)
- painter->setPen(highlightedTextColor);
- else
- painter->setPen(textColor);
-
- int x, y, w, h;
- menuitem->rect.getRect(&x, &y, &w, &h);
- int tab = menuitem->tabWidth;
- int xm = windowsItemFrame + checkcol + windowsItemHMargin;
- int xpos = menuitem->rect.x() + xm + 1;
- QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin);
- QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect);
- QString s = menuitem->text;
-
- if (!s.isEmpty()) { // Draw text
- p->save();
- int t = s.indexOf(QLatin1Char('\t'));
- int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
-
- if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget))
- text_flags |= Qt::TextHideMnemonic;
-
- // Draw shortcut right aligned
- text_flags |= Qt::AlignRight;
-
- if (t >= 0) {
- int rightMargin = 12; // Hardcode for now
- QRect vShortcutRect = visualRect(opt->direction, menuitem->rect,
- QRect(textRect.topRight(), QPoint(menuitem->rect.right() - rightMargin, textRect.bottom())));
-
- if (dis)
- p->setPen(disabledTextColor);
- p->drawText(vShortcutRect, text_flags , s.mid(t + 1));
- s = s.left(t);
- }
-
- text_flags &= ~Qt::AlignRight;
- text_flags |= Qt::AlignLeft;
- QFont font = menuitem->font;
- if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem)
- font.setBold(true);
- p->setFont(font);
-
- if (dis)
- p->setPen(disabledTextColor);
- p->drawText(vTextRect, text_flags, s.left(t));
- p->restore();
- }
-
- // Arrow
- if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
-
- QFontMetrics fm(menuitem->font);
- int arrow_size = fm.ascent() + fm.descent() - 2 * gtkMenuItem->style->ythickness;
- gfloat arrow_scaling = 0.8;
- int extra = 0;
- if (!d->gtk_check_version(2, 16, 0)) {
- // "arrow-scaling" is actually hardcoded and fails on hardy (see gtk+-2.12/gtkmenuitem.c)
- // though the current documentation states otherwise
- d->gtk_widget_style_get(gtkMenuItem, "arrow-scaling", &arrow_scaling, NULL);
- // in versions < 2.16 ythickness was previously subtracted from the arrow_size
- extra = 2 * gtkMenuItem->style->ythickness;
- }
-
- int horizontal_padding;
- d->gtk_widget_style_get(gtkMenuItem, "horizontal-padding", &horizontal_padding, NULL);
-
- const int dim = static_cast<int>(arrow_size * arrow_scaling) + extra;
- int xpos = menuItem->rect.left() + menuItem->rect.width() - horizontal_padding - dim;
- QRect vSubMenuRect = visualRect(option->direction, menuItem->rect,
- QRect(xpos, menuItem->rect.top() +
- menuItem->rect.height() / 2 - dim / 2, dim, dim));
- GtkStateType state = enabled ? (act ? GTK_STATE_PRELIGHT: GTK_STATE_NORMAL) : GTK_STATE_INSENSITIVE;
- GtkShadowType shadowType = (state == GTK_STATE_PRELIGHT) ? GTK_SHADOW_OUT : GTK_SHADOW_IN;
- gtkPainter.paintArrow(gtkMenuItem, "menuitem", vSubMenuRect, QApplication::isRightToLeft() ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT, state,
- shadowType, FALSE, style);
- }
- }
- painter->restore();
- break;
-
- case CE_PushButton:
- if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- GtkWidget *gtkButton = d->gtkWidget("GtkButton");
- proxy()->drawControl(CE_PushButtonBevel, btn, painter, widget);
- QStyleOptionButton subopt = *btn;
- subopt.rect = subElementRect(SE_PushButtonContents, btn, widget);
- gint interiorFocus = true;
- d->gtk_widget_style_get(gtkButton, "interior-focus", &interiorFocus, NULL);
- int xt = interiorFocus ? gtkButton->style->xthickness : 0;
- int yt = interiorFocus ? gtkButton->style->ythickness : 0;
-
- if (btn->features & QStyleOptionButton::Flat && btn->state & State_HasFocus)
- // The normal button focus rect does not work well for flat buttons in Clearlooks
- proxy()->drawPrimitive(PE_FrameFocusRect, option, painter, widget);
- else if (btn->state & State_HasFocus)
- gtkPainter.paintFocus(gtkButton, "button",
- option->rect.adjusted(xt, yt, -xt, -yt),
- btn->state & State_Sunken ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL,
- gtkButton->style);
-
- proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
- }
- break;
-
-#ifndef QT_NO_TABBAR
-
- case CE_TabBarTabShape:
- if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
- GtkWidget *gtkNotebook = d->gtkWidget("GtkNotebook");
- style = gtkPainter.getStyle(gtkNotebook);
-
- QRect rect = option->rect;
- GtkShadowType shadow = GTK_SHADOW_OUT;
- GtkStateType state = GTK_STATE_ACTIVE;
- if (tab->state & State_Selected)
- state = GTK_STATE_NORMAL;
-
- bool selected = (tab->state & State_Selected);
- bool first = false, last = false;
- if (widget) {
- // This is most accurate and avoids resizing tabs while moving
- first = tab->rect.left() == widget->rect().left();
- last = tab->rect.right() == widget->rect().right();
- } else if (option->direction == Qt::RightToLeft) {
- bool tmp = first;
- first = last;
- last = tmp;
- }
- int topIndent = 3;
- int bottomIndent = 1;
- int tabOverlap = 1;
- painter->save();
-
- switch (tab->shape) {
- case QTabBar::RoundedNorth:
- if (!selected)
- rect.adjust(first ? 0 : -tabOverlap, topIndent, last ? 0 : tabOverlap, -bottomIndent);
- gtkPainter.paintExtention( gtkNotebook, "tab", rect,
- state, shadow, GTK_POS_BOTTOM, style);
- break;
-
- case QTabBar::RoundedSouth:
- if (!selected)
- rect.adjust(first ? 0 : -tabOverlap, 0, last ? 0 : tabOverlap, -topIndent);
- gtkPainter.paintExtention( gtkNotebook, "tab", rect.adjusted(0, 1, 0, 0),
- state, shadow, GTK_POS_TOP, style);
- break;
-
- case QTabBar::RoundedWest:
- if (!selected)
- rect.adjust(topIndent, 0, -bottomIndent, 0);
- gtkPainter.paintExtention( gtkNotebook, "tab", rect, state, shadow, GTK_POS_RIGHT, style);
- break;
-
- case QTabBar::RoundedEast:
- if (!selected)
- rect.adjust(bottomIndent, 0, -topIndent, 0);
- gtkPainter.paintExtention( gtkNotebook, "tab", rect, state, shadow, GTK_POS_LEFT, style);
- break;
-
- default:
- QCleanlooksStyle::drawControl(element, option, painter, widget);
- break;
- }
-
- painter->restore();
- }
-
- break;
-
-#endif //QT_NO_TABBAR
-
- case CE_ProgressBarGroove:
- if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
- Q_UNUSED(bar);
- GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar");
- GtkStateType state = gtkPainter.gtkState(option);
- gtkPainter.paintBox( gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, gtkProgressBar->style);
- }
-
- break;
-
- case CE_ProgressBarContents:
- if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
- GtkStateType state = option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE;
- GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar");
- style = gtkProgressBar->style;
- gtkPainter.paintBox( gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, style);
- int xt = style->xthickness;
- int yt = style->ythickness;
- QRect rect = bar->rect.adjusted(xt, yt, -xt, -yt);
- bool vertical = false;
- bool inverted = false;
- bool indeterminate = (bar->minimum == 0 && bar->maximum == 0);
- // Get extra style options if version 2
-
- if (const QStyleOptionProgressBarV2 *bar2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) {
- vertical = (bar2->orientation == Qt::Vertical);
- inverted = bar2->invertedAppearance;
- }
-
- // If the orientation is vertical, we use a transform to rotate
- // the progress bar 90 degrees clockwise. This way we can use the
- // same rendering code for both orientations.
- if (vertical) {
- rect.translate(xt, -yt * 2);
- rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // Flip width and height
- QTransform m = QTransform::fromTranslate(rect.height(), 0);
- m.rotate(90.0);
- painter->setTransform(m);
- }
-
- int maxWidth = rect.width();
- int minWidth = 4;
-
- qint64 progress = (qint64)qMax(bar->progress, bar->minimum); // Workaround for bug in QProgressBar
- double vc6_workaround = ((progress - qint64(bar->minimum)) / double(qint64(bar->maximum) - qint64(bar->minimum))) * maxWidth;
- int progressBarWidth = (int(vc6_workaround) > minWidth ) ? int(vc6_workaround) : minWidth;
- int width = indeterminate ? maxWidth : progressBarWidth;
- bool reverse = (!vertical && (bar->direction == Qt::RightToLeft)) || vertical;
-
- if (inverted)
- reverse = !reverse;
-
- int maximum = 2;
- int fakePos = 0;
- if (bar->minimum == bar->maximum)
- maximum = 0;
- if (bar->progress == bar->maximum)
- fakePos = maximum;
- else if (bar->progress > bar->minimum)
- fakePos = maximum - 1;
-
- d->gtk_progress_configure((GtkProgress*)gtkProgressBar, fakePos, 0, maximum);
-
- QRect progressBar;
-
- if (!indeterminate) {
- if (!reverse)
- progressBar.setRect(rect.left(), rect.top(), width, rect.height());
- else
- progressBar.setRect(rect.right() - width, rect.top(), width, rect.height());
-
- } else {
- Q_D(const QGtkStyle);
- int slideWidth = ((rect.width() - 4) * 2) / 3;
- int step = ((d->animateStep * slideWidth) / d->animationFps) % slideWidth;
- if ((((d->animateStep * slideWidth) / d->animationFps) % (2 * slideWidth)) >= slideWidth)
- step = slideWidth - step;
- progressBar.setRect(rect.left() + step, rect.top(), slideWidth / 2, rect.height());
- }
-
- QString key = QString(QLS("%0")).arg(fakePos);
- if (inverted) {
- key += QLatin1String("inv");
- gtkPainter.setFlipHorizontal(true);
- }
- gtkPainter.paintBox( gtkProgressBar, "bar", progressBar, GTK_STATE_SELECTED, GTK_SHADOW_OUT, style, key);
- }
-
- break;
-
- default:
- QCleanlooksStyle::drawControl(element, option, painter, widget);
- }
-}
-
-/*!
- \reimp
-*/
-QRect QGtkStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option,
- SubControl subControl, const QWidget *widget) const
-{
- Q_D(const QGtkStyle);
-
- QRect rect = QWindowsStyle::subControlRect(control, option, subControl, widget);
- if (!d->isThemeAvailable())
- return QCleanlooksStyle::subControlRect(control, option, subControl, widget);
-
- switch (control) {
- case CC_TitleBar:
- return QCleanlooksStyle::subControlRect(control, option, subControl, widget);
-
- case CC_Slider:
- if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
- // Reserve space for outside focus rect
- QStyleOptionSlider sliderCopy = *slider;
- sliderCopy.rect = option->rect.adjusted(2, 2, -2, -2);
- return QCleanlooksStyle::subControlRect(control, &sliderCopy, subControl, widget);
- }
-
- break;
-
-#ifndef QT_NO_GROUPBOX
-
- case CC_GroupBox:
- if (qstyleoption_cast<const QStyleOptionGroupBox *>(option)) {
- rect = option->rect.adjusted(0, groupBoxTopMargin, 0, -groupBoxBottomMargin);
- int topMargin = 0;
- int topHeight = 0;
- topHeight = 10;
- QRect frameRect = rect;
- frameRect.setTop(topMargin);
-
- if (subControl == SC_GroupBoxFrame)
- return rect;
- else if (subControl == SC_GroupBoxContents) {
- int margin = 0;
- int leftMarginExtension = 8;
- return frameRect.adjusted(leftMarginExtension + margin, margin + topHeight + groupBoxTitleMargin, -margin, -margin);
- }
-
- if (const QGroupBox *groupBoxWidget = qobject_cast<const QGroupBox *>(widget)) {
- //Prepare metrics for a bold font
- QFont font = widget->font();
- font.setBold(true);
- QFontMetrics fontMetrics(font);
- QSize textRect = fontMetrics.boundingRect(groupBoxWidget->title()).size() + QSize(4, 4);
- int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, option, widget);
- int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, option, widget);
-
- if (subControl == SC_GroupBoxCheckBox) {
- rect.setWidth(indicatorWidth);
- rect.setHeight(indicatorHeight);
- rect.moveTop((textRect.height() - indicatorHeight) / 2);
-
- } else if (subControl == SC_GroupBoxLabel) {
- if (groupBoxWidget->isCheckable())
- rect.adjust(indicatorWidth + 4, 0, 0, 0);
- rect.setSize(textRect);
- }
- rect = visualRect(option->direction, option->rect, rect);
- }
- }
-
- return rect;
-
-#endif
-#ifndef QT_NO_SPINBOX
-
- case CC_SpinBox:
- if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
- GtkWidget *gtkSpinButton = d->gtkWidget("GtkSpinButton");
- int center = spinbox->rect.height() / 2;
- int xt = spinbox->frame ? gtkSpinButton->style->xthickness : 0;
- int yt = spinbox->frame ? gtkSpinButton->style->ythickness : 0;
- int y = yt;
-
- QSize bs;
- bs.setHeight(qMax(8, spinbox->rect.height()/2 - y));
- bs.setWidth(d->getSpinboxArrowSize());
- int x, lx, rx;
- x = spinbox->rect.width() - y - bs.width() + 2;
- lx = xt;
- rx = x - xt;
-
- switch (subControl) {
-
- case SC_SpinBoxUp:
- if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
- return QRect();
- rect = QRect(x, xt, bs.width(), center - yt);
- break;
-
- case SC_SpinBoxDown:
- if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
- return QRect();
- rect = QRect(x, center, bs.width(), spinbox->rect.bottom() - center - yt + 1);
- break;
-
- case SC_SpinBoxEditField:
- if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
- rect = QRect(lx, yt, spinbox->rect.width() - 2*xt, spinbox->rect.height() - 2*yt);
- else
- rect = QRect(lx, yt, rx - qMax(xt - 1, 0), spinbox->rect.height() - 2*yt);
- break;
-
- case SC_SpinBoxFrame:
- rect = spinbox->rect;
-
- default:
- break;
- }
-
- rect = visualRect(spinbox->direction, spinbox->rect, rect);
- }
-
- break;
-
-#endif // Qt_NO_SPINBOX
-#ifndef QT_NO_COMBOBOX
-
- case CC_ComboBox:
- if (const QStyleOptionComboBox *box = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
- // We employ the gtk widget to position arrows and separators for us
- GtkWidget *gtkCombo = box->editable ? d->gtkWidget("GtkComboBoxEntry")
- : d->gtkWidget("GtkComboBox");
- d->gtk_widget_set_direction(gtkCombo, (option->direction == Qt::RightToLeft) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
- GtkAllocation geometry = {0, 0, qMax(0, option->rect.width()), qMax(0, option->rect.height())};
- d->gtk_widget_size_allocate(gtkCombo, &geometry);
- int appears_as_list = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, option, widget);
- QHashableLatin1Literal arrowPath("GtkComboBoxEntry.GtkToggleButton");
- if (!box->editable) {
- if (appears_as_list)
- arrowPath = "GtkComboBox.GtkToggleButton";
- else
- arrowPath = "GtkComboBox.GtkToggleButton.GtkHBox.GtkArrow";
- }
-
- GtkWidget *arrowWidget = d->gtkWidget(arrowPath);
- if (!arrowWidget)
- return QCleanlooksStyle::subControlRect(control, option, subControl, widget);
-
- QRect buttonRect(option->rect.left() + arrowWidget->allocation.x,
- option->rect.top() + arrowWidget->allocation.y,
- arrowWidget->allocation.width, arrowWidget->allocation.height);
-
- switch (subControl) {
-
- case SC_ComboBoxArrow: // Note: this indicates the arrowbutton for editable combos
- rect = buttonRect;
- break;
-
- case SC_ComboBoxEditField: {
- rect = visualRect(option->direction, option->rect, rect);
- int xMargin = box->editable ? 1 : 4, yMargin = 2;
- rect.setRect(option->rect.left() + gtkCombo->style->xthickness + xMargin,
- option->rect.top() + gtkCombo->style->ythickness + yMargin,
- option->rect.width() - buttonRect.width() - 2*(gtkCombo->style->xthickness + xMargin),
- option->rect.height() - 2*(gtkCombo->style->ythickness + yMargin));
- rect = visualRect(option->direction, option->rect, rect);
- break;
- }
-
- default:
- break;
- }
- }
-
- break;
-
-#endif // QT_NO_COMBOBOX
-
- default:
- break;
- }
-
- return rect;
-}
-
-/*!
- \reimp
-*/
-QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
- const QSize &size, const QWidget *widget) const
-{
- Q_D(const QGtkStyle);
-
- QSize newSize = QCleanlooksStyle::sizeFromContents(type, option, size, widget);
- if (!d->isThemeAvailable())
- return newSize;
-
- switch (type) {
-
- case CT_ToolButton:
- if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
- GtkWidget *gtkButton = d->gtkWidget("GtkToolButton.GtkButton");
- newSize = size + QSize(2 * gtkButton->style->xthickness, 2 + 2 * gtkButton->style->ythickness);
- if (widget && qobject_cast<QToolBar *>(widget->parentWidget())) {
- QSize minSize(0, 25);
- if (toolbutton->toolButtonStyle != Qt::ToolButtonTextOnly)
- minSize = toolbutton->iconSize + QSize(12, 12);
- newSize = newSize.expandedTo(minSize);
- }
-
- if (toolbutton->features & QStyleOptionToolButton::HasMenu)
- newSize += QSize(6, 0);
- }
- break;
- case CT_MenuItem:
- if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
- int textMargin = 8;
-
- if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
- GtkWidget *gtkMenuSeparator = d->gtkWidget("GtkMenu.GtkSeparatorMenuItem");
- GtkRequisition sizeReq = {0, 0};
- d->gtk_widget_size_request(gtkMenuSeparator, &sizeReq);
- newSize = QSize(size.width(), sizeReq.height);
- break;
- }
-
- GtkWidget *gtkMenuItem = d->gtkWidget("GtkMenu.GtkCheckMenuItem");
- GtkStyle* style = gtkMenuItem->style;
-
- // Note we get the perfect height for the default font since we
- // set a fake text label on the gtkMenuItem
- // But if custom fonts are used on the widget we need a minimum size
- GtkRequisition sizeReq = {0, 0};
- d->gtk_widget_size_request(gtkMenuItem, &sizeReq);
- newSize.setHeight(qMax(newSize.height() - 4, sizeReq.height));
- newSize += QSize(textMargin + style->xthickness - 1, 0);
-
- // Cleanlooks assumes a check column of 20 pixels so we need to
- // expand it a bit
- gint checkSize;
- d->gtk_widget_style_get(gtkMenuItem, "indicator-size", &checkSize, NULL);
- newSize.setWidth(newSize.width() + qMax(0, checkSize - 20));
- }
-
- break;
-
- case CT_SpinBox:
- // QSpinBox does some nasty things that depends on CT_LineEdit
- newSize = size + QSize(0, -d->gtkWidget("GtkSpinButton")->style->ythickness * 2);
- break;
-
- case CT_PushButton:
- if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
- GtkWidget *gtkButton = d->gtkWidget("GtkButton");
- gint focusPadding, focusWidth;
- d->gtk_widget_style_get(gtkButton, "focus-padding", &focusPadding, NULL);
- d->gtk_widget_style_get(gtkButton, "focus-line-width", &focusWidth, NULL);
- newSize = size;
- newSize += QSize(2*gtkButton->style->xthickness + 4, 2*gtkButton->style->ythickness);
- newSize += QSize(2*(focusWidth + focusPadding + 2), 2*(focusWidth + focusPadding));
-
- GtkWidget *gtkButtonBox = d->gtkWidget("GtkHButtonBox");
- gint minWidth = 85, minHeight = 0;
- d->gtk_widget_style_get(gtkButtonBox, "child-min-width", &minWidth,
- "child-min-height", &minHeight, NULL);
- if (!btn->text.isEmpty() && newSize.width() < minWidth)
- newSize.setWidth(minWidth);
- if (newSize.height() < minHeight)
- newSize.setHeight(minHeight);
- }
-
- break;
-
- case CT_Slider: {
- GtkWidget *gtkSlider = d->gtkWidget("GtkHScale");
- newSize = size + QSize(2*gtkSlider->style->xthickness, 2*gtkSlider->style->ythickness);
- }
- break;
-
- case CT_LineEdit: {
- GtkWidget *gtkEntry = d->gtkWidget("GtkEntry");
- newSize = size + QSize(2*gtkEntry->style->xthickness, 2 + 2*gtkEntry->style->ythickness);
- }
- break;
-
- case CT_ItemViewItem:
- newSize += QSize(0, 2);
- break;
-
- case CT_ComboBox:
- if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
- GtkWidget *gtkCombo = d->gtkWidget("GtkComboBox");
- QRect arrowButtonRect = proxy()->subControlRect(CC_ComboBox, combo, SC_ComboBoxArrow, widget);
- newSize = size + QSize(12 + arrowButtonRect.width() + 2*gtkCombo->style->xthickness, 4 + 2*gtkCombo->style->ythickness);
-
- if (!(widget && qobject_cast<QToolBar *>(widget->parentWidget())))
- newSize += QSize(0, 2);
- }
- break;
-
- case CT_GroupBox:
- newSize += QSize(4, groupBoxBottomMargin + groupBoxTopMargin + groupBoxTitleMargin); // Add some space below the groupbox
- break;
-
- case CT_TabBarTab:
- if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
- if (!tab->icon.isNull())
- newSize += QSize(6, 0);
- }
- newSize += QSize(1, 1);
- break;
-
- default:
- break;
- }
-
- return newSize;
-}
-
-
-/*! \reimp */
-QPixmap QGtkStyle::standardPixmap(StandardPixmap sp, const QStyleOption *option,
- const QWidget *widget) const
-{
- Q_D(const QGtkStyle);
-
- if (!d->isThemeAvailable())
- return QCleanlooksStyle::standardPixmap(sp, option, widget);
-
- QPixmap pixmap;
- switch (sp) {
-
- case SP_TitleBarNormalButton: {
- QImage restoreButton((const char **)dock_widget_restore_xpm);
- QColor alphaCorner = restoreButton.color(2);
- alphaCorner.setAlpha(80);
- restoreButton.setColor(2, alphaCorner.rgba());
- alphaCorner.setAlpha(180);
- restoreButton.setColor(4, alphaCorner.rgba());
- return QPixmap::fromImage(restoreButton);
- }
- break;
-
- case SP_TitleBarCloseButton: // Fall through
- case SP_DockWidgetCloseButton: {
-
- QImage closeButton((const char **)dock_widget_close_xpm);
- QColor alphaCorner = closeButton.color(2);
- alphaCorner.setAlpha(80);
- closeButton.setColor(2, alphaCorner.rgba());
- return QPixmap::fromImage(closeButton);
- }
- break;
-
- case SP_DialogDiscardButton:
- return QGtkPainter::getIcon(GTK_STOCK_DELETE);
- case SP_DialogOkButton:
- return QGtkPainter::getIcon(GTK_STOCK_OK);
- case SP_DialogCancelButton:
- return QGtkPainter::getIcon(GTK_STOCK_CANCEL);
- case SP_DialogYesButton:
- return QGtkPainter::getIcon(GTK_STOCK_YES);
- case SP_DialogNoButton:
- return QGtkPainter::getIcon(GTK_STOCK_NO);
- case SP_DialogOpenButton:
- return QGtkPainter::getIcon(GTK_STOCK_OPEN);
- case SP_DialogCloseButton:
- return QGtkPainter::getIcon(GTK_STOCK_CLOSE);
- case SP_DialogApplyButton:
- return QGtkPainter::getIcon(GTK_STOCK_APPLY);
- case SP_DialogSaveButton:
- return QGtkPainter::getIcon(GTK_STOCK_SAVE);
- case SP_MessageBoxWarning:
- return QGtkPainter::getIcon(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
- case SP_MessageBoxQuestion:
- return QGtkPainter::getIcon(GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
- case SP_MessageBoxInformation:
- return QGtkPainter::getIcon(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
- case SP_MessageBoxCritical:
- return QGtkPainter::getIcon(GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG);
- default:
- return QCleanlooksStyle::standardPixmap(sp, option, widget);
- }
- return pixmap;
-}
-
-/*!
- \internal
-*/
-QIcon QGtkStyle::standardIconImplementation(StandardPixmap standardIcon,
- const QStyleOption *option,
- const QWidget *widget) const
-{
- Q_D(const QGtkStyle);
-
- if (!d->isThemeAvailable())
- return QCleanlooksStyle::standardIconImplementation(standardIcon, option, widget);
- switch (standardIcon) {
- case SP_DialogDiscardButton:
- return QGtkPainter::getIcon(GTK_STOCK_DELETE);
- case SP_DialogOkButton:
- return QGtkPainter::getIcon(GTK_STOCK_OK);
- case SP_DialogCancelButton:
- return QGtkPainter::getIcon(GTK_STOCK_CANCEL);
- case SP_DialogYesButton:
- return QGtkPainter::getIcon(GTK_STOCK_YES);
- case SP_DialogNoButton:
- return QGtkPainter::getIcon(GTK_STOCK_NO);
- case SP_DialogOpenButton:
- return QGtkPainter::getIcon(GTK_STOCK_OPEN);
- case SP_DialogCloseButton:
- return QGtkPainter::getIcon(GTK_STOCK_CLOSE);
- case SP_DialogApplyButton:
- return QGtkPainter::getIcon(GTK_STOCK_APPLY);
- case SP_DialogSaveButton:
- return QGtkPainter::getIcon(GTK_STOCK_SAVE);
- case SP_MessageBoxWarning:
- return QGtkPainter::getIcon(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
- case SP_MessageBoxQuestion:
- return QGtkPainter::getIcon(GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
- case SP_MessageBoxInformation:
- return QGtkPainter::getIcon(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
- case SP_MessageBoxCritical:
- return QGtkPainter::getIcon(GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG);
- default:
- return QCleanlooksStyle::standardIconImplementation(standardIcon, option, widget);
- }
-}
-
-
-/*! \reimp */
-QRect QGtkStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const
-{
- Q_D(const QGtkStyle);
-
- QRect r = QCleanlooksStyle::subElementRect(element, option, widget);
- if (!d->isThemeAvailable())
- return r;
-
- switch (element) {
- case SE_ProgressBarLabel:
- case SE_ProgressBarContents:
- case SE_ProgressBarGroove:
- return option->rect;
- case SE_PushButtonContents:
- if (!d->gtk_check_version(2, 10, 0)) {
- GtkWidget *gtkButton = d->gtkWidget("GtkButton");
- GtkBorder *border = 0;
- d->gtk_widget_style_get(gtkButton, "inner-border", &border, NULL);
- if (border) {
- r = option->rect.adjusted(border->left, border->top, -border->right, -border->bottom);
- d->gtk_border_free(border);
- } else {
- r = option->rect.adjusted(1, 1, -1, -1);
- }
- r = visualRect(option->direction, option->rect, r);
- }
- break;
- default:
- break;
- }
-
- return r;
-}
-
-/*!
- \reimp
-*/
-QRect QGtkStyle::itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const
-{
- return QCleanlooksStyle::itemPixmapRect(r, flags, pixmap);
-}
-
-/*!
- \reimp
-*/
-void QGtkStyle::drawItemPixmap(QPainter *painter, const QRect &rect,
- int alignment, const QPixmap &pixmap) const
-{
- QCleanlooksStyle::drawItemPixmap(painter, rect, alignment, pixmap);
-}
-
-/*!
- \reimp
-*/
-QStyle::SubControl QGtkStyle::hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
- const QPoint &pt, const QWidget *w) const
-{
- return QCleanlooksStyle::hitTestComplexControl(cc, opt, pt, w);
-}
-
-/*!
- \reimp
-*/
-QPixmap QGtkStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
- const QStyleOption *opt) const
-{
- return QCleanlooksStyle::generatedIconPixmap(iconMode, pixmap, opt);
-}
-
-/*!
- \reimp
-*/
-void QGtkStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal,
- bool enabled, const QString& text, QPalette::ColorRole textRole) const
-{
- return QCleanlooksStyle::drawItemText(painter, rect, alignment, pal, enabled, text, textRole);
-}
-
-QT_END_NAMESPACE
-
-#endif //!defined(QT_NO_STYLE_QGTK)
diff --git a/src/gui/styles/qgtkstyle.h b/src/gui/styles/qgtkstyle.h
deleted file mode 100644
index 616ce24509..0000000000
--- a/src/gui/styles/qgtkstyle.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGTKSTYLE_H
-#define QGTKSTYLE_H
-
-#include <QtGui/QCleanlooksStyle>
-#include <QtGui/QPalette>
-#include <QtGui/QFont>
-#include <QtGui/QFileDialog>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if !defined(QT_NO_STYLE_GTK)
-
-class QPainterPath;
-class QGtkStylePrivate;
-
-class Q_GUI_EXPORT QGtkStyle : public QCleanlooksStyle
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QGtkStyle)
-
-public:
- QGtkStyle();
- QGtkStyle(QGtkStylePrivate &dd);
-
- ~QGtkStyle();
-
- QPalette standardPalette() const;
-
- void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
- QPainter *painter, const QWidget *widget) const;
- void drawControl(ControlElement control, const QStyleOption *option,
- QPainter *painter, const QWidget *widget) const;
- void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
- QPainter *painter, const QWidget *widget) const;
- void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
- const QPixmap &pixmap) const;
- void drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal,
- bool enabled, const QString& text, QPalette::ColorRole textRole) const;
-
- int pixelMetric(PixelMetric metric, const QStyleOption *option = 0,
- const QWidget *widget = 0) const;
- int styleHint(StyleHint hint, const QStyleOption *option,
- const QWidget *widget, QStyleHintReturn *returnData) const;
-
- QStyle::SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
- const QPoint &pt, const QWidget *w) const;
-
- QRect subControlRect(ComplexControl control, const QStyleOptionComplex *option,
- SubControl subControl, const QWidget *widget) const;
- QRect subElementRect(SubElement sr, const QStyleOption *opt, const QWidget *w) const;
- QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const;
-
-
- QSize sizeFromContents(ContentsType type, const QStyleOption *option,
- const QSize &size, const QWidget *widget) const;
- QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *option,
- const QWidget *widget) const;
- QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
- const QStyleOption *opt) const;
-
- void polish(QWidget *widget);
- void polish(QApplication *app);
- void polish(QPalette &palette);
-
- void unpolish(QWidget *widget);
- void unpolish(QApplication *app);
-
- static bool getGConfBool(const QString &key, bool fallback = 0);
- static QString getGConfString(const QString &key, const QString &fallback = QString());
-
-
-protected Q_SLOTS:
- QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option,
- const QWidget *widget = 0) const;
-};
-
-#endif //!defined(QT_NO_STYLE_QGTK)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif //QGTKSTYLE_H
diff --git a/src/gui/styles/qgtkstyle_p.cpp b/src/gui/styles/qgtkstyle_p.cpp
deleted file mode 100644
index d7c53c9a91..0000000000
--- a/src/gui/styles/qgtkstyle_p.cpp
+++ /dev/null
@@ -1,1146 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgtkstyle_p.h"
-
-// This file is responsible for resolving all GTK functions we use
-// dynamically. This is done to avoid link-time dependancy on GTK
-// as well as crashes occurring due to usage of the GTK_QT engines
-//
-// Additionally we create a map of common GTK widgets that we can pass
-// to the GTK theme engine as many engines resort to querying the
-// actual widget pointers for details that are not covered by the
-// state flags
-
-#include <QtCore/qglobal.h>
-#if !defined(QT_NO_STYLE_GTK)
-
-#include <QtCore/QEvent>
-#include <QtCore/QFile>
-#include <QtCore/QStringList>
-#include <QtCore/QTextStream>
-#include <QtCore/QHash>
-#include <QtCore/QUrl>
-#include <QtCore/QLibrary>
-#include <QtCore/QDebug>
-
-#include <private/qapplication_p.h>
-#include <private/qiconloader_p.h>
-
-#include <QtGui/QMenu>
-#include <QtGui/QStyle>
-#include <QtGui/QApplication>
-#include <QtGui/QPixmapCache>
-#include <QtGui/QStatusBar>
-#include <QtGui/QMenuBar>
-#include <QtGui/QToolBar>
-#include <QtGui/QToolButton>
-#include <QtGui/QX11Info>
-
-#include <private/qt_x11_p.h>
-
-QT_BEGIN_NAMESPACE
-
-static bool displayDepth = -1;
-Q_GLOBAL_STATIC(QGtkStyleUpdateScheduler, styleScheduler)
-
-Ptr_gtk_container_forall QGtkStylePrivate::gtk_container_forall = 0;
-Ptr_gtk_init QGtkStylePrivate::gtk_init = 0;
-Ptr_gtk_style_attach QGtkStylePrivate::gtk_style_attach = 0;
-Ptr_gtk_window_new QGtkStylePrivate::gtk_window_new = 0;
-Ptr_gtk_widget_destroy QGtkStylePrivate::gtk_widget_destroy = 0;
-Ptr_gtk_widget_realize QGtkStylePrivate::gtk_widget_realize = 0;
-Ptr_gtk_widget_set_default_direction QGtkStylePrivate::gtk_widget_set_default_direction = 0;
-Ptr_gtk_widget_modify_color QGtkStylePrivate::gtk_widget_modify_fg = 0;
-Ptr_gtk_widget_modify_color QGtkStylePrivate::gtk_widget_modify_bg = 0;
-Ptr_gtk_arrow_new QGtkStylePrivate::gtk_arrow_new = 0;
-Ptr_gtk_menu_item_new_with_label QGtkStylePrivate::gtk_menu_item_new_with_label = 0;
-Ptr_gtk_check_menu_item_new_with_label QGtkStylePrivate::gtk_check_menu_item_new_with_label = 0;
-Ptr_gtk_menu_bar_new QGtkStylePrivate::gtk_menu_bar_new = 0;
-Ptr_gtk_menu_new QGtkStylePrivate::gtk_menu_new = 0;
-Ptr_gtk_button_new QGtkStylePrivate::gtk_button_new = 0;
-Ptr_gtk_tool_button_new QGtkStylePrivate::gtk_tool_button_new = 0;
-Ptr_gtk_hbutton_box_new QGtkStylePrivate::gtk_hbutton_box_new = 0;
-Ptr_gtk_check_button_new QGtkStylePrivate::gtk_check_button_new = 0;
-Ptr_gtk_radio_button_new QGtkStylePrivate::gtk_radio_button_new = 0;
-Ptr_gtk_spin_button_new QGtkStylePrivate::gtk_spin_button_new = 0;
-Ptr_gtk_frame_new QGtkStylePrivate::gtk_frame_new = 0;
-Ptr_gtk_expander_new QGtkStylePrivate::gtk_expander_new = 0;
-Ptr_gtk_statusbar_new QGtkStylePrivate::gtk_statusbar_new = 0;
-Ptr_gtk_entry_new QGtkStylePrivate::gtk_entry_new = 0;
-Ptr_gtk_hscale_new QGtkStylePrivate::gtk_hscale_new = 0;
-Ptr_gtk_vscale_new QGtkStylePrivate::gtk_vscale_new = 0;
-Ptr_gtk_hscrollbar_new QGtkStylePrivate::gtk_hscrollbar_new = 0;
-Ptr_gtk_vscrollbar_new QGtkStylePrivate::gtk_vscrollbar_new = 0;
-Ptr_gtk_scrolled_window_new QGtkStylePrivate::gtk_scrolled_window_new = 0;
-Ptr_gtk_notebook_new QGtkStylePrivate::gtk_notebook_new = 0;
-Ptr_gtk_toolbar_new QGtkStylePrivate::gtk_toolbar_new = 0;
-Ptr_gtk_toolbar_insert QGtkStylePrivate::gtk_toolbar_insert = 0;
-Ptr_gtk_separator_tool_item_new QGtkStylePrivate::gtk_separator_tool_item_new = 0;
-Ptr_gtk_tree_view_new QGtkStylePrivate::gtk_tree_view_new = 0;
-Ptr_gtk_combo_box_new QGtkStylePrivate::gtk_combo_box_new = 0;
-Ptr_gtk_combo_box_entry_new QGtkStylePrivate::gtk_combo_box_entry_new = 0;
-Ptr_gtk_progress_bar_new QGtkStylePrivate::gtk_progress_bar_new = 0;
-Ptr_gtk_container_add QGtkStylePrivate::gtk_container_add = 0;
-Ptr_gtk_menu_shell_append QGtkStylePrivate::gtk_menu_shell_append = 0;
-Ptr_gtk_progress_configure QGtkStylePrivate::gtk_progress_configure = 0;
-Ptr_gtk_range_get_adjustment QGtkStylePrivate::gtk_range_get_adjustment = 0;
-Ptr_gtk_range_set_adjustment QGtkStylePrivate::gtk_range_set_adjustment = 0;
-Ptr_gtk_range_set_inverted QGtkStylePrivate::gtk_range_set_inverted = 0;
-Ptr_gtk_icon_factory_lookup_default QGtkStylePrivate::gtk_icon_factory_lookup_default = 0;
-Ptr_gtk_icon_theme_get_default QGtkStylePrivate::gtk_icon_theme_get_default = 0;
-Ptr_gtk_widget_style_get QGtkStylePrivate::gtk_widget_style_get = 0;
-Ptr_gtk_icon_set_render_icon QGtkStylePrivate::gtk_icon_set_render_icon = 0;
-Ptr_gtk_fixed_new QGtkStylePrivate::gtk_fixed_new = 0;
-Ptr_gtk_tree_view_column_new QGtkStylePrivate::gtk_tree_view_column_new = 0;
-Ptr_gtk_tree_view_get_column QGtkStylePrivate::gtk_tree_view_get_column = 0;
-Ptr_gtk_tree_view_append_column QGtkStylePrivate::gtk_tree_view_append_column = 0;
-Ptr_gtk_paint_check QGtkStylePrivate::gtk_paint_check = 0;
-Ptr_gtk_paint_box QGtkStylePrivate::gtk_paint_box = 0;
-Ptr_gtk_paint_box_gap QGtkStylePrivate::gtk_paint_box_gap = 0;
-Ptr_gtk_paint_flat_box QGtkStylePrivate::gtk_paint_flat_box = 0;
-Ptr_gtk_paint_option QGtkStylePrivate::gtk_paint_option = 0;
-Ptr_gtk_paint_extension QGtkStylePrivate::gtk_paint_extension = 0;
-Ptr_gtk_paint_slider QGtkStylePrivate::gtk_paint_slider = 0;
-Ptr_gtk_paint_shadow QGtkStylePrivate::gtk_paint_shadow = 0;
-Ptr_gtk_paint_resize_grip QGtkStylePrivate::gtk_paint_resize_grip = 0;
-Ptr_gtk_paint_focus QGtkStylePrivate::gtk_paint_focus = 0;
-Ptr_gtk_paint_arrow QGtkStylePrivate::gtk_paint_arrow = 0;
-Ptr_gtk_paint_handle QGtkStylePrivate::gtk_paint_handle = 0;
-Ptr_gtk_paint_expander QGtkStylePrivate::gtk_paint_expander = 0;
-Ptr_gtk_adjustment_configure QGtkStylePrivate::gtk_adjustment_configure = 0;
-Ptr_gtk_adjustment_new QGtkStylePrivate::gtk_adjustment_new = 0;
-Ptr_gtk_paint_hline QGtkStylePrivate::gtk_paint_hline = 0;
-Ptr_gtk_paint_vline QGtkStylePrivate::gtk_paint_vline = 0;
-Ptr_gtk_menu_item_set_submenu QGtkStylePrivate::gtk_menu_item_set_submenu = 0;
-Ptr_gtk_settings_get_default QGtkStylePrivate::gtk_settings_get_default = 0;
-Ptr_gtk_separator_menu_item_new QGtkStylePrivate::gtk_separator_menu_item_new = 0;
-Ptr_gtk_widget_size_allocate QGtkStylePrivate::gtk_widget_size_allocate = 0;
-Ptr_gtk_widget_size_request QGtkStylePrivate::gtk_widget_size_request = 0;
-Ptr_gtk_widget_set_direction QGtkStylePrivate::gtk_widget_set_direction = 0;
-Ptr_gtk_widget_path QGtkStylePrivate::gtk_widget_path = 0;
-Ptr_gtk_container_get_type QGtkStylePrivate::gtk_container_get_type = 0;
-Ptr_gtk_window_get_type QGtkStylePrivate::gtk_window_get_type = 0;
-Ptr_gtk_widget_get_type QGtkStylePrivate::gtk_widget_get_type = 0;
-Ptr_gtk_rc_get_style_by_paths QGtkStylePrivate::gtk_rc_get_style_by_paths = 0;
-Ptr_gtk_check_version QGtkStylePrivate::gtk_check_version = 0;
-Ptr_gtk_border_free QGtkStylePrivate::gtk_border_free = 0;
-Ptr_pango_font_description_get_size QGtkStylePrivate::pango_font_description_get_size = 0;
-Ptr_pango_font_description_get_weight QGtkStylePrivate::pango_font_description_get_weight = 0;
-Ptr_pango_font_description_get_family QGtkStylePrivate::pango_font_description_get_family = 0;
-Ptr_pango_font_description_get_style QGtkStylePrivate::pango_font_description_get_style = 0;
-
-Ptr_gtk_file_filter_new QGtkStylePrivate::gtk_file_filter_new = 0;
-Ptr_gtk_file_filter_set_name QGtkStylePrivate::gtk_file_filter_set_name = 0;
-Ptr_gtk_file_filter_add_pattern QGtkStylePrivate::gtk_file_filter_add_pattern = 0;
-Ptr_gtk_file_chooser_add_filter QGtkStylePrivate::gtk_file_chooser_add_filter = 0;
-Ptr_gtk_file_chooser_set_filter QGtkStylePrivate::gtk_file_chooser_set_filter = 0;
-Ptr_gtk_file_chooser_get_filter QGtkStylePrivate::gtk_file_chooser_get_filter = 0;
-Ptr_gtk_file_chooser_dialog_new QGtkStylePrivate::gtk_file_chooser_dialog_new = 0;
-Ptr_gtk_file_chooser_set_current_folder QGtkStylePrivate::gtk_file_chooser_set_current_folder = 0;
-Ptr_gtk_file_chooser_get_filename QGtkStylePrivate::gtk_file_chooser_get_filename = 0;
-Ptr_gtk_file_chooser_get_filenames QGtkStylePrivate::gtk_file_chooser_get_filenames = 0;
-Ptr_gtk_file_chooser_set_current_name QGtkStylePrivate::gtk_file_chooser_set_current_name = 0;
-Ptr_gtk_dialog_run QGtkStylePrivate::gtk_dialog_run = 0;
-Ptr_gtk_file_chooser_set_filename QGtkStylePrivate::gtk_file_chooser_set_filename = 0;
-
-Ptr_gdk_pixbuf_get_pixels QGtkStylePrivate::gdk_pixbuf_get_pixels = 0;
-Ptr_gdk_pixbuf_get_width QGtkStylePrivate::gdk_pixbuf_get_width = 0;
-Ptr_gdk_pixbuf_get_height QGtkStylePrivate::gdk_pixbuf_get_height = 0;
-Ptr_gdk_pixmap_new QGtkStylePrivate::gdk_pixmap_new = 0;
-Ptr_gdk_pixbuf_new QGtkStylePrivate::gdk_pixbuf_new = 0;
-Ptr_gdk_pixbuf_get_from_drawable QGtkStylePrivate::gdk_pixbuf_get_from_drawable = 0;
-Ptr_gdk_draw_rectangle QGtkStylePrivate::gdk_draw_rectangle = 0;
-Ptr_gdk_pixbuf_unref QGtkStylePrivate::gdk_pixbuf_unref = 0;
-Ptr_gdk_drawable_unref QGtkStylePrivate::gdk_drawable_unref = 0;
-Ptr_gdk_drawable_get_depth QGtkStylePrivate::gdk_drawable_get_depth = 0;
-Ptr_gdk_color_free QGtkStylePrivate::gdk_color_free = 0;
-Ptr_gdk_x11_window_set_user_time QGtkStylePrivate::gdk_x11_window_set_user_time = 0;
-Ptr_gdk_x11_drawable_get_xid QGtkStylePrivate::gdk_x11_drawable_get_xid = 0;
-Ptr_gdk_x11_drawable_get_xdisplay QGtkStylePrivate::gdk_x11_drawable_get_xdisplay = 0;
-
-Ptr_gconf_client_get_default QGtkStylePrivate::gconf_client_get_default = 0;
-Ptr_gconf_client_get_string QGtkStylePrivate::gconf_client_get_string = 0;
-Ptr_gconf_client_get_bool QGtkStylePrivate::gconf_client_get_bool = 0;
-
-Ptr_gnome_icon_lookup_sync QGtkStylePrivate::gnome_icon_lookup_sync = 0;
-Ptr_gnome_vfs_init QGtkStylePrivate::gnome_vfs_init = 0;
-
-typedef int (*x11ErrorHandler)(Display*, XErrorEvent*);
-
-QT_END_NAMESPACE
-
-Q_DECLARE_METATYPE(QGtkStylePrivate*);
-
-QT_BEGIN_NAMESPACE
-
-static void gtkStyleSetCallback(GtkWidget*)
-{
- qRegisterMetaType<QGtkStylePrivate *>();
-
- // We have to let this function return and complete the event
- // loop to ensure that all gtk widgets have been styled before
- // updating
- QMetaObject::invokeMethod(styleScheduler(), "updateTheme", Qt::QueuedConnection);
-}
-
-static void update_toolbar_style(GtkWidget *gtkToolBar, GParamSpec *, gpointer)
-{
- GtkToolbarStyle toolbar_style = GTK_TOOLBAR_ICONS;
- g_object_get(gtkToolBar, "toolbar-style", &toolbar_style, NULL);
- QWidgetList widgets = QApplication::allWidgets();
- for (int i = 0; i < widgets.size(); ++i) {
- QWidget *widget = widgets.at(i);
- if (qobject_cast<QToolButton*>(widget)) {
- QEvent event(QEvent::StyleChange);
- QApplication::sendEvent(widget, &event);
- }
- }
-}
-
-static QHashableLatin1Literal classPath(GtkWidget *widget)
-{
- char *class_path;
- QGtkStylePrivate::gtk_widget_path (widget, NULL, &class_path, NULL);
-
- char *copy = class_path;
- if (strncmp(copy, "GtkWindow.", 10) == 0)
- copy += 10;
- if (strncmp(copy, "GtkFixed.", 9) == 0)
- copy += 9;
-
- copy = strdup(copy);
-
- g_free(class_path);
-
- return QHashableLatin1Literal::fromData(copy);
-}
-
-
-
-bool QGtkStyleFilter::eventFilter(QObject *obj, QEvent *e)
-{
- if (e->type() == QEvent::ApplicationPaletteChange) {
- // Only do this the first time since this will also
- // generate applicationPaletteChange events
- if (!qt_app_palettes_hash() || qt_app_palettes_hash()->isEmpty()) {
- stylePrivate->applyCustomPaletteHash();
- }
- }
- return QObject::eventFilter(obj, e);
-}
-
-QList<QGtkStylePrivate *> QGtkStylePrivate::instances;
-QGtkStylePrivate::WidgetMap *QGtkStylePrivate::widgetMap = 0;
-
-QGtkStylePrivate::QGtkStylePrivate()
- : QCleanlooksStylePrivate()
- , filter(this)
-{
- instances.append(this);
-}
-
-QGtkStylePrivate::~QGtkStylePrivate()
-{
- instances.removeOne(this);
-}
-
-void QGtkStylePrivate::init()
-{
- resolveGtk();
- initGtkWidgets();
-}
-
-GtkWidget* QGtkStylePrivate::gtkWidget(const QHashableLatin1Literal &path)
-{
- GtkWidget *widget = gtkWidgetMap()->value(path);
- if (!widget) {
- // Theme might have rearranged widget internals
- widget = gtkWidgetMap()->value(path);
- }
- return widget;
-}
-
-GtkStyle* QGtkStylePrivate::gtkStyle(const QHashableLatin1Literal &path)
-{
- if (GtkWidget *w = gtkWidgetMap()->value(path))
- return w->style;
- return 0;
-}
-
-/*! \internal
- * Get references to gtk functions after we dynamically load the library.
- */
-void QGtkStylePrivate::resolveGtk() const
-{
- // enforce the "0" suffix, so we'll open libgtk-x11-2.0.so.0
- QLibrary libgtk(QLS("gtk-x11-2.0"), 0, 0);
-
- gtk_init = (Ptr_gtk_init)libgtk.resolve("gtk_init");
- gtk_window_new = (Ptr_gtk_window_new)libgtk.resolve("gtk_window_new");
- gtk_style_attach = (Ptr_gtk_style_attach)libgtk.resolve("gtk_style_attach");
- gtk_widget_destroy = (Ptr_gtk_widget_destroy)libgtk.resolve("gtk_widget_destroy");
- gtk_widget_realize = (Ptr_gtk_widget_realize)libgtk.resolve("gtk_widget_realize");
-
- gtk_file_chooser_set_current_folder = (Ptr_gtk_file_chooser_set_current_folder)libgtk.resolve("gtk_file_chooser_set_current_folder");
- gtk_file_filter_new = (Ptr_gtk_file_filter_new)libgtk.resolve("gtk_file_filter_new");
- gtk_file_filter_set_name = (Ptr_gtk_file_filter_set_name)libgtk.resolve("gtk_file_filter_set_name");
- gtk_file_filter_add_pattern = (Ptr_gtk_file_filter_add_pattern)libgtk.resolve("gtk_file_filter_add_pattern");
- gtk_file_chooser_add_filter = (Ptr_gtk_file_chooser_add_filter)libgtk.resolve("gtk_file_chooser_add_filter");
- gtk_file_chooser_set_filter = (Ptr_gtk_file_chooser_set_filter)libgtk.resolve("gtk_file_chooser_set_filter");
- gtk_file_chooser_get_filter = (Ptr_gtk_file_chooser_get_filter)libgtk.resolve("gtk_file_chooser_get_filter");
- gtk_file_chooser_dialog_new = (Ptr_gtk_file_chooser_dialog_new)libgtk.resolve("gtk_file_chooser_dialog_new");
- gtk_file_chooser_set_current_folder = (Ptr_gtk_file_chooser_set_current_folder)libgtk.resolve("gtk_file_chooser_set_current_folder");
- gtk_file_chooser_get_filename = (Ptr_gtk_file_chooser_get_filename)libgtk.resolve("gtk_file_chooser_get_filename");
- gtk_file_chooser_get_filenames = (Ptr_gtk_file_chooser_get_filenames)libgtk.resolve("gtk_file_chooser_get_filenames");
- gtk_file_chooser_set_current_name = (Ptr_gtk_file_chooser_set_current_name)libgtk.resolve("gtk_file_chooser_set_current_name");
- gtk_dialog_run = (Ptr_gtk_dialog_run)libgtk.resolve("gtk_dialog_run");
- gtk_file_chooser_set_filename = (Ptr_gtk_file_chooser_set_filename)libgtk.resolve("gtk_file_chooser_set_filename");
-
- gdk_pixbuf_get_pixels = (Ptr_gdk_pixbuf_get_pixels)libgtk.resolve("gdk_pixbuf_get_pixels");
- gdk_pixbuf_get_width = (Ptr_gdk_pixbuf_get_width)libgtk.resolve("gdk_pixbuf_get_width");
- gdk_pixbuf_get_height = (Ptr_gdk_pixbuf_get_height)libgtk.resolve("gdk_pixbuf_get_height");
- gdk_pixmap_new = (Ptr_gdk_pixmap_new)libgtk.resolve("gdk_pixmap_new");
- gdk_pixbuf_new = (Ptr_gdk_pixbuf_new)libgtk.resolve("gdk_pixbuf_new");
- gdk_pixbuf_get_from_drawable = (Ptr_gdk_pixbuf_get_from_drawable)libgtk.resolve("gdk_pixbuf_get_from_drawable");
- gdk_draw_rectangle = (Ptr_gdk_draw_rectangle)libgtk.resolve("gdk_draw_rectangle");
- gdk_pixbuf_unref = (Ptr_gdk_pixbuf_unref)libgtk.resolve("gdk_pixbuf_unref");
- gdk_drawable_unref = (Ptr_gdk_drawable_unref)libgtk.resolve("gdk_drawable_unref");
- gdk_drawable_get_depth = (Ptr_gdk_drawable_get_depth)libgtk.resolve("gdk_drawable_get_depth");
- gdk_color_free = (Ptr_gdk_color_free)libgtk.resolve("gdk_color_free");
- gdk_x11_window_set_user_time = (Ptr_gdk_x11_window_set_user_time)libgtk.resolve("gdk_x11_window_set_user_time");
- gdk_x11_drawable_get_xid = (Ptr_gdk_x11_drawable_get_xid)libgtk.resolve("gdk_x11_drawable_get_xid");
- gdk_x11_drawable_get_xdisplay = (Ptr_gdk_x11_drawable_get_xdisplay)libgtk.resolve("gdk_x11_drawable_get_xdisplay");
-
- gtk_widget_set_default_direction = (Ptr_gtk_widget_set_default_direction)libgtk.resolve("gtk_widget_set_default_direction");
- gtk_widget_modify_fg = (Ptr_gtk_widget_modify_color)libgtk.resolve("gtk_widget_modify_fg");
- gtk_widget_modify_bg = (Ptr_gtk_widget_modify_color)libgtk.resolve("gtk_widget_modify_bg");
- gtk_arrow_new = (Ptr_gtk_arrow_new)libgtk.resolve("gtk_arrow_new");
- gtk_menu_item_new_with_label = (Ptr_gtk_menu_item_new_with_label)libgtk.resolve("gtk_menu_item_new_with_label");
- gtk_check_menu_item_new_with_label = (Ptr_gtk_check_menu_item_new_with_label)libgtk.resolve("gtk_check_menu_item_new_with_label");
- gtk_menu_bar_new = (Ptr_gtk_menu_bar_new)libgtk.resolve("gtk_menu_bar_new");
- gtk_menu_new = (Ptr_gtk_menu_new)libgtk.resolve("gtk_menu_new");
- gtk_toolbar_new = (Ptr_gtk_toolbar_new)libgtk.resolve("gtk_toolbar_new");
- gtk_separator_tool_item_new = (Ptr_gtk_separator_tool_item_new)libgtk.resolve("gtk_separator_tool_item_new");
- gtk_toolbar_insert = (Ptr_gtk_toolbar_insert)libgtk.resolve("gtk_toolbar_insert");
- gtk_button_new = (Ptr_gtk_button_new)libgtk.resolve("gtk_button_new");
- gtk_tool_button_new = (Ptr_gtk_tool_button_new)libgtk.resolve("gtk_tool_button_new");
- gtk_hbutton_box_new = (Ptr_gtk_hbutton_box_new)libgtk.resolve("gtk_hbutton_box_new");
- gtk_check_button_new = (Ptr_gtk_check_button_new)libgtk.resolve("gtk_check_button_new");
- gtk_radio_button_new = (Ptr_gtk_radio_button_new)libgtk.resolve("gtk_radio_button_new");
- gtk_notebook_new = (Ptr_gtk_notebook_new)libgtk.resolve("gtk_notebook_new");
- gtk_progress_bar_new = (Ptr_gtk_progress_bar_new)libgtk.resolve("gtk_progress_bar_new");
- gtk_spin_button_new = (Ptr_gtk_spin_button_new)libgtk.resolve("gtk_spin_button_new");
- gtk_hscale_new = (Ptr_gtk_hscale_new)libgtk.resolve("gtk_hscale_new");
- gtk_vscale_new = (Ptr_gtk_vscale_new)libgtk.resolve("gtk_vscale_new");
- gtk_hscrollbar_new = (Ptr_gtk_hscrollbar_new)libgtk.resolve("gtk_hscrollbar_new");
- gtk_vscrollbar_new = (Ptr_gtk_vscrollbar_new)libgtk.resolve("gtk_vscrollbar_new");
- gtk_scrolled_window_new = (Ptr_gtk_scrolled_window_new)libgtk.resolve("gtk_scrolled_window_new");
- gtk_menu_shell_append = (Ptr_gtk_menu_shell_append)libgtk.resolve("gtk_menu_shell_append");
- gtk_entry_new = (Ptr_gtk_entry_new)libgtk.resolve("gtk_entry_new");
- gtk_tree_view_new = (Ptr_gtk_tree_view_new)libgtk.resolve("gtk_tree_view_new");
- gtk_combo_box_new = (Ptr_gtk_combo_box_new)libgtk.resolve("gtk_combo_box_new");
- gtk_progress_configure = (Ptr_gtk_progress_configure)libgtk.resolve("gtk_progress_configure");
- gtk_range_get_adjustment = (Ptr_gtk_range_get_adjustment)libgtk.resolve("gtk_range_get_adjustment");
- gtk_range_set_adjustment = (Ptr_gtk_range_set_adjustment)libgtk.resolve("gtk_range_set_adjustment");
- gtk_range_set_inverted = (Ptr_gtk_range_set_inverted)libgtk.resolve("gtk_range_set_inverted");
- gtk_container_add = (Ptr_gtk_container_add)libgtk.resolve("gtk_container_add");
- gtk_icon_factory_lookup_default = (Ptr_gtk_icon_factory_lookup_default)libgtk.resolve("gtk_icon_factory_lookup_default");
- gtk_icon_theme_get_default = (Ptr_gtk_icon_theme_get_default)libgtk.resolve("gtk_icon_theme_get_default");
- gtk_widget_style_get = (Ptr_gtk_widget_style_get)libgtk.resolve("gtk_widget_style_get");
- gtk_icon_set_render_icon = (Ptr_gtk_icon_set_render_icon)libgtk.resolve("gtk_icon_set_render_icon");
- gtk_fixed_new = (Ptr_gtk_fixed_new)libgtk.resolve("gtk_fixed_new");
- gtk_tree_view_column_new = (Ptr_gtk_tree_view_column_new)libgtk.resolve("gtk_tree_view_column_new");
- gtk_tree_view_append_column= (Ptr_gtk_tree_view_append_column )libgtk.resolve("gtk_tree_view_append_column");
- gtk_tree_view_get_column = (Ptr_gtk_tree_view_get_column )libgtk.resolve("gtk_tree_view_get_column");
- gtk_paint_check = (Ptr_gtk_paint_check)libgtk.resolve("gtk_paint_check");
- gtk_paint_box = (Ptr_gtk_paint_box)libgtk.resolve("gtk_paint_box");
- gtk_paint_flat_box = (Ptr_gtk_paint_flat_box)libgtk.resolve("gtk_paint_flat_box");
- gtk_paint_check = (Ptr_gtk_paint_check)libgtk.resolve("gtk_paint_check");
- gtk_paint_box = (Ptr_gtk_paint_box)libgtk.resolve("gtk_paint_box");
- gtk_paint_resize_grip = (Ptr_gtk_paint_resize_grip)libgtk.resolve("gtk_paint_resize_grip");
- gtk_paint_focus = (Ptr_gtk_paint_focus)libgtk.resolve("gtk_paint_focus");
- gtk_paint_shadow = (Ptr_gtk_paint_shadow)libgtk.resolve("gtk_paint_shadow");
- gtk_paint_slider = (Ptr_gtk_paint_slider)libgtk.resolve("gtk_paint_slider");
- gtk_paint_expander = (Ptr_gtk_paint_expander)libgtk.resolve("gtk_paint_expander");
- gtk_paint_handle = (Ptr_gtk_paint_handle)libgtk.resolve("gtk_paint_handle");
- gtk_paint_option = (Ptr_gtk_paint_option)libgtk.resolve("gtk_paint_option");
- gtk_paint_arrow = (Ptr_gtk_paint_arrow)libgtk.resolve("gtk_paint_arrow");
- gtk_paint_box_gap = (Ptr_gtk_paint_box_gap)libgtk.resolve("gtk_paint_box_gap");
- gtk_paint_extension = (Ptr_gtk_paint_extension)libgtk.resolve("gtk_paint_extension");
- gtk_paint_hline = (Ptr_gtk_paint_hline)libgtk.resolve("gtk_paint_hline");
- gtk_paint_vline = (Ptr_gtk_paint_vline)libgtk.resolve("gtk_paint_vline");
- gtk_adjustment_configure = (Ptr_gtk_adjustment_configure)libgtk.resolve("gtk_adjustment_configure");
- gtk_adjustment_new = (Ptr_gtk_adjustment_new)libgtk.resolve("gtk_adjustment_new");
- gtk_menu_item_set_submenu = (Ptr_gtk_menu_item_set_submenu)libgtk.resolve("gtk_menu_item_set_submenu");
- gtk_settings_get_default = (Ptr_gtk_settings_get_default)libgtk.resolve("gtk_settings_get_default");
- gtk_separator_menu_item_new = (Ptr_gtk_separator_menu_item_new)libgtk.resolve("gtk_separator_menu_item_new");
- gtk_frame_new = (Ptr_gtk_frame_new)libgtk.resolve("gtk_frame_new");
- gtk_expander_new = (Ptr_gtk_expander_new)libgtk.resolve("gtk_expander_new");
- gtk_statusbar_new = (Ptr_gtk_statusbar_new)libgtk.resolve("gtk_statusbar_new");
- gtk_combo_box_entry_new = (Ptr_gtk_combo_box_entry_new)libgtk.resolve("gtk_combo_box_entry_new");
- gtk_container_forall = (Ptr_gtk_container_forall)libgtk.resolve("gtk_container_forall");
- gtk_widget_size_allocate =(Ptr_gtk_widget_size_allocate)libgtk.resolve("gtk_widget_size_allocate");
- gtk_widget_size_request =(Ptr_gtk_widget_size_request)libgtk.resolve("gtk_widget_size_request");
- gtk_widget_set_direction =(Ptr_gtk_widget_set_direction)libgtk.resolve("gtk_widget_set_direction");
- gtk_widget_path =(Ptr_gtk_widget_path)libgtk.resolve("gtk_widget_path");
- gtk_container_get_type =(Ptr_gtk_container_get_type)libgtk.resolve("gtk_container_get_type");
- gtk_window_get_type =(Ptr_gtk_window_get_type)libgtk.resolve("gtk_window_get_type");
- gtk_widget_get_type =(Ptr_gtk_widget_get_type)libgtk.resolve("gtk_widget_get_type");
-
- gtk_rc_get_style_by_paths =(Ptr_gtk_rc_get_style_by_paths)libgtk.resolve("gtk_rc_get_style_by_paths");
- gtk_check_version =(Ptr_gtk_check_version)libgtk.resolve("gtk_check_version");
- gtk_border_free =(Ptr_gtk_border_free)libgtk.resolve("gtk_border_free");
- pango_font_description_get_size = (Ptr_pango_font_description_get_size)libgtk.resolve("pango_font_description_get_size");
- pango_font_description_get_weight = (Ptr_pango_font_description_get_weight)libgtk.resolve("pango_font_description_get_weight");
- pango_font_description_get_family = (Ptr_pango_font_description_get_family)libgtk.resolve("pango_font_description_get_family");
- pango_font_description_get_style = (Ptr_pango_font_description_get_style)libgtk.resolve("pango_font_description_get_style");
-
- gnome_icon_lookup_sync = (Ptr_gnome_icon_lookup_sync)QLibrary::resolve(QLS("gnomeui-2"), 0, "gnome_icon_lookup_sync");
- gnome_vfs_init= (Ptr_gnome_vfs_init)QLibrary::resolve(QLS("gnomevfs-2"), 0, "gnome_vfs_init");
-}
-
-/* \internal
- * Initializes a number of gtk menu widgets.
- * The widgets are cached.
- */
-void QGtkStylePrivate::initGtkMenu() const
-{
- // Create menubar
- GtkWidget *gtkMenuBar = QGtkStylePrivate::gtk_menu_bar_new();
- setupGtkWidget(gtkMenuBar);
-
- GtkWidget *gtkMenuBarItem = QGtkStylePrivate::gtk_menu_item_new_with_label("X");
- gtk_menu_shell_append((GtkMenuShell*)(gtkMenuBar), gtkMenuBarItem);
- gtk_widget_realize(gtkMenuBarItem);
-
- // Create menu
- GtkWidget *gtkMenu = QGtkStylePrivate::gtk_menu_new();
- gtk_menu_item_set_submenu((GtkMenuItem*)(gtkMenuBarItem), gtkMenu);
- gtk_widget_realize(gtkMenu);
-
- GtkWidget *gtkMenuItem = QGtkStylePrivate::gtk_menu_item_new_with_label("X");
- gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkMenuItem);
- gtk_widget_realize(gtkMenuItem);
-
- GtkWidget *gtkCheckMenuItem = QGtkStylePrivate::gtk_check_menu_item_new_with_label("X");
- gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkCheckMenuItem);
- gtk_widget_realize(gtkCheckMenuItem);
-
- GtkWidget *gtkMenuSeparator = QGtkStylePrivate::gtk_separator_menu_item_new();
- gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkMenuSeparator);
-
- addAllSubWidgets(gtkMenuBar);
- addAllSubWidgets(gtkMenu);
-}
-
-
-void QGtkStylePrivate::initGtkTreeview() const
-{
- GtkWidget *gtkTreeView = gtk_tree_view_new();
- gtk_tree_view_append_column((GtkTreeView*)gtkTreeView, gtk_tree_view_column_new());
- gtk_tree_view_append_column((GtkTreeView*)gtkTreeView, gtk_tree_view_column_new());
- gtk_tree_view_append_column((GtkTreeView*)gtkTreeView, gtk_tree_view_column_new());
- addWidget(gtkTreeView);
-}
-
-
-/* \internal
- * Initializes a number of gtk widgets that we can later on use to determine some of our styles.
- * The widgets are cached.
- */
-void QGtkStylePrivate::initGtkWidgets() const
-{
- // From gtkmain.c
- uid_t ruid = getuid ();
- uid_t rgid = getgid ();
- uid_t euid = geteuid ();
- uid_t egid = getegid ();
- if (ruid != euid || rgid != egid) {
- qWarning("\nThis process is currently running setuid or setgid.\nGTK+ does not allow this "
- "therefore Qt cannot use the GTK+ integration.\nTry launching your app using \'gksudo\', "
- "\'kdesudo\' or a similar tool.\n\n"
- "See http://www.gtk.org/setuid.html for more information.\n");
- return;
- }
-
- static QString themeName;
- if (!gtkWidgetMap()->contains("GtkWindow") && themeName.isEmpty()) {
- themeName = getThemeName();
-
- if (themeName.isEmpty()) {
- qWarning("QGtkStyle was unable to detect the current GTK+ theme.");
- return;
- } else if (themeName == QLS("Qt") || themeName == QLS("Qt4")) {
- // Due to namespace conflicts with Qt3 and obvious recursion with Qt4,
- // we cannot support the GTK_Qt Gtk engine
- qWarning("QGtkStyle cannot be used together with the GTK_Qt engine.");
- return;
- }
- }
-
- if (QGtkStylePrivate::gtk_init) {
- // Gtk will set the Qt error handler so we have to reset it afterwards
- x11ErrorHandler qt_x_errhandler = XSetErrorHandler(0);
- QGtkStylePrivate::gtk_init (NULL, NULL);
- XSetErrorHandler(qt_x_errhandler);
-
- // make a window
- GtkWidget* gtkWindow = QGtkStylePrivate::gtk_window_new(GTK_WINDOW_POPUP);
- QGtkStylePrivate::gtk_widget_realize(gtkWindow);
- if (displayDepth == -1)
- displayDepth = QGtkStylePrivate::gdk_drawable_get_depth(gtkWindow->window);
- QHashableLatin1Literal widgetPath = QHashableLatin1Literal::fromData(strdup("GtkWindow"));
- removeWidgetFromMap(widgetPath);
- gtkWidgetMap()->insert(widgetPath, gtkWindow);
-
-
- // Make all other widgets. respect the text direction
- if (qApp->layoutDirection() == Qt::RightToLeft)
- QGtkStylePrivate::gtk_widget_set_default_direction(GTK_TEXT_DIR_RTL);
-
- if (!gtkWidgetMap()->contains("GtkButton")) {
- GtkWidget *gtkButton = QGtkStylePrivate::gtk_button_new();
- addWidget(gtkButton);
- g_signal_connect(gtkButton, "style-set", G_CALLBACK(gtkStyleSetCallback), 0);
- addWidget(QGtkStylePrivate::gtk_tool_button_new(NULL, "Qt"));
- addWidget(QGtkStylePrivate::gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE));
- addWidget(QGtkStylePrivate::gtk_hbutton_box_new());
- addWidget(QGtkStylePrivate::gtk_check_button_new());
- addWidget(QGtkStylePrivate::gtk_radio_button_new(NULL));
- addWidget(QGtkStylePrivate::gtk_combo_box_new());
- addWidget(QGtkStylePrivate::gtk_combo_box_entry_new());
- addWidget(QGtkStylePrivate::gtk_entry_new());
- addWidget(QGtkStylePrivate::gtk_frame_new(NULL));
- addWidget(QGtkStylePrivate::gtk_expander_new(""));
- addWidget(QGtkStylePrivate::gtk_statusbar_new());
- addWidget(QGtkStylePrivate::gtk_hscale_new((GtkAdjustment*)(QGtkStylePrivate::gtk_adjustment_new(1, 0, 1, 0, 0, 0))));
- addWidget(QGtkStylePrivate::gtk_hscrollbar_new(NULL));
- addWidget(QGtkStylePrivate::gtk_scrolled_window_new(NULL, NULL));
-
- initGtkMenu();
- addWidget(QGtkStylePrivate::gtk_notebook_new());
- addWidget(QGtkStylePrivate::gtk_progress_bar_new());
- addWidget(QGtkStylePrivate::gtk_spin_button_new((GtkAdjustment*)
- (QGtkStylePrivate::gtk_adjustment_new(1, 0, 1, 0, 0, 0)), 0.1, 3));
- GtkWidget *toolbar = gtk_toolbar_new();
- g_signal_connect (toolbar, "notify::toolbar-style", G_CALLBACK (update_toolbar_style), toolbar);
- gtk_toolbar_insert((GtkToolbar*)toolbar, gtk_separator_tool_item_new(), -1);
- addWidget(toolbar);
- initGtkTreeview();
- addWidget(gtk_vscale_new((GtkAdjustment*)(QGtkStylePrivate::gtk_adjustment_new(1, 0, 1, 0, 0, 0))));
- addWidget(gtk_vscrollbar_new(NULL));
- }
- else // Rebuild map
- {
- // When styles change subwidgets can get rearranged
- // as with the combo box. We need to update the widget map
- // to reflect this;
- QHash<QHashableLatin1Literal, GtkWidget*> oldMap = *gtkWidgetMap();
- gtkWidgetMap()->clear();
- QHashIterator<QHashableLatin1Literal, GtkWidget*> it(oldMap);
- while (it.hasNext()) {
- it.next();
- if (!strchr(it.key().data(), '.')) {
- addAllSubWidgets(it.value());
- }
- free(const_cast<char *>(it.key().data()));
- }
- }
- } else {
- qWarning("QGtkStyle could not resolve GTK. Make sure you have installed the proper libraries.");
- }
-}
-
-/*! \internal
- * destroys all previously buffered widgets.
- */
-void QGtkStylePrivate::cleanupGtkWidgets()
-{
- if (!widgetMap)
- return;
- if (widgetMap->contains("GtkWindow")) // Gtk will destroy all children
- gtk_widget_destroy(widgetMap->value("GtkWindow"));
- for (QHash<QHashableLatin1Literal, GtkWidget *>::const_iterator it = widgetMap->constBegin();
- it != widgetMap->constEnd(); ++it)
- free(const_cast<char *>(it.key().data()));
-}
-
-static bool resolveGConf()
-{
- if (!QGtkStylePrivate::gconf_client_get_default) {
- QGtkStylePrivate::gconf_client_get_default = (Ptr_gconf_client_get_default)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_default");
- QGtkStylePrivate::gconf_client_get_string = (Ptr_gconf_client_get_string)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_string");
- QGtkStylePrivate::gconf_client_get_bool = (Ptr_gconf_client_get_bool)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_bool");
- }
- return (QGtkStylePrivate::gconf_client_get_default !=0);
-}
-
-QString QGtkStylePrivate::getGConfString(const QString &value, const QString &fallback)
-{
- QString retVal = fallback;
- if (resolveGConf()) {
- g_type_init();
- GConfClient* client = gconf_client_get_default();
- GError *err = 0;
- char *str = gconf_client_get_string(client, qPrintable(value), &err);
- if (!err) {
- retVal = QString::fromUtf8(str);
- g_free(str);
- }
- g_object_unref(client);
- if (err)
- g_error_free (err);
- }
- return retVal;
-}
-
-bool QGtkStylePrivate::getGConfBool(const QString &key, bool fallback)
-{
- bool retVal = fallback;
- if (resolveGConf()) {
- g_type_init();
- GConfClient* client = gconf_client_get_default();
- GError *err = 0;
- bool result = gconf_client_get_bool(client, qPrintable(key), &err);
- g_object_unref(client);
- if (!err)
- retVal = result;
- else
- g_error_free (err);
- }
- return retVal;
-}
-
-QString QGtkStylePrivate::getThemeName()
-{
- QString themeName;
- // We try to parse the gtkrc file first
- // primarily to avoid resolving Gtk functions if
- // the KDE 3 "Qt" style is currently in use
- QString rcPaths = QString::fromLocal8Bit(qgetenv("GTK2_RC_FILES"));
- if (!rcPaths.isEmpty()) {
- QStringList paths = rcPaths.split(QLS(":"));
- foreach (const QString &rcPath, paths) {
- if (!rcPath.isEmpty()) {
- QFile rcFile(rcPath);
- if (rcFile.exists() && rcFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
- QTextStream in(&rcFile);
- while(!in.atEnd()) {
- QString line = in.readLine();
- if (line.contains(QLS("gtk-theme-name"))) {
- line = line.right(line.length() - line.indexOf(QLatin1Char('=')) - 1);
- line.remove(QLatin1Char('\"'));
- line = line.trimmed();
- themeName = line;
- break;
- }
- }
- }
- }
- if (!themeName.isEmpty())
- break;
- }
- }
-
- // Fall back to gconf
- if (themeName.isEmpty() && resolveGConf())
- themeName = getGConfString(QLS("/desktop/gnome/interface/gtk_theme"));
-
- return themeName;
-}
-
-// Get size of the arrow controls in a GtkSpinButton
-int QGtkStylePrivate::getSpinboxArrowSize() const
-{
- const int MIN_ARROW_WIDTH = 6;
- GtkWidget *spinButton = gtkWidget("GtkSpinButton");
- GtkStyle *style = spinButton->style;
- gint size = pango_font_description_get_size (style->font_desc);
- gint arrow_size;
- arrow_size = qMax(PANGO_PIXELS (size), MIN_ARROW_WIDTH) + style->xthickness;
- arrow_size += arrow_size%2 + 1;
- return arrow_size;
-}
-
-
-bool QGtkStylePrivate::isKDE4Session()
-{
- static int version = -1;
- if (version == -1)
- version = qgetenv("KDE_SESSION_VERSION").toInt();
- return (version == 4);
-}
-
-void QGtkStylePrivate::applyCustomPaletteHash()
-{
- QPalette menuPal = gtkWidgetPalette("GtkMenu");
- GdkColor gdkBg = gtkWidget("GtkMenu")->style->bg[GTK_STATE_NORMAL];
- QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8);
- menuPal.setBrush(QPalette::Base, bgColor);
- menuPal.setBrush(QPalette::Window, bgColor);
- qApp->setPalette(menuPal, "QMenu");
-
- QPalette toolbarPal = gtkWidgetPalette("GtkToolbar");
- qApp->setPalette(toolbarPal, "QToolBar");
-
- QPalette menuBarPal = gtkWidgetPalette("GtkMenuBar");
- qApp->setPalette(menuBarPal, "QMenuBar");
-}
-
-/*! \internal
- * Returns the gtk Widget that should be used to determine text foreground and background colors.
-*/
-GtkWidget* QGtkStylePrivate::getTextColorWidget() const
-{
- return gtkWidget("GtkEntry");
-}
-
-void QGtkStylePrivate::setupGtkWidget(GtkWidget* widget)
-{
- if (Q_GTK_IS_WIDGET(widget)) {
- static GtkWidget* protoLayout = 0;
- if (!protoLayout) {
- protoLayout = QGtkStylePrivate::gtk_fixed_new();
- QGtkStylePrivate::gtk_container_add((GtkContainer*)(gtkWidgetMap()->value("GtkWindow")), protoLayout);
- }
- Q_ASSERT(protoLayout);
-
- if (!widget->parent && !GTK_WIDGET_TOPLEVEL(widget))
- QGtkStylePrivate::gtk_container_add((GtkContainer*)(protoLayout), widget);
- QGtkStylePrivate::gtk_widget_realize(widget);
- }
-}
-
-void QGtkStylePrivate::removeWidgetFromMap(const QHashableLatin1Literal &path)
-{
- WidgetMap *map = gtkWidgetMap();
- WidgetMap::iterator it = map->find(path);
- if (it != map->end()) {
- free(const_cast<char *>(it.key().data()));
- map->erase(it);
- }
-}
-
-void QGtkStylePrivate::addWidgetToMap(GtkWidget *widget)
-{
- if (Q_GTK_IS_WIDGET(widget)) {
- gtk_widget_realize(widget);
- QHashableLatin1Literal widgetPath = classPath(widget);
-
- removeWidgetFromMap(widgetPath);
- gtkWidgetMap()->insert(widgetPath, widget);
-#ifdef DUMP_GTK_WIDGET_TREE
- qWarning("Inserted Gtk Widget: %s", widgetPath.data());
-#endif
- }
- }
-
-void QGtkStylePrivate::addAllSubWidgets(GtkWidget *widget, gpointer v)
-{
- Q_UNUSED(v);
- addWidgetToMap(widget);
- if (GTK_CHECK_TYPE ((widget), gtk_container_get_type()))
- gtk_container_forall((GtkContainer*)widget, addAllSubWidgets, NULL);
-}
-
-// Updates window/windowtext palette based on the indicated gtk widget
-QPalette QGtkStylePrivate::gtkWidgetPalette(const QHashableLatin1Literal &gtkWidgetName) const
-{
- GtkWidget *gtkWidget = QGtkStylePrivate::gtkWidget(gtkWidgetName);
- Q_ASSERT(gtkWidget);
- QPalette pal = QApplication::palette();
- GdkColor gdkBg = gtkWidget->style->bg[GTK_STATE_NORMAL];
- GdkColor gdkText = gtkWidget->style->fg[GTK_STATE_NORMAL];
- GdkColor gdkDisabledText = gtkWidget->style->fg[GTK_STATE_INSENSITIVE];
- QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8);
- QColor textColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
- QColor disabledTextColor(gdkDisabledText.red>>8, gdkDisabledText.green>>8, gdkDisabledText.blue>>8);
- pal.setBrush(QPalette::Window, bgColor);
- pal.setBrush(QPalette::Button, bgColor);
- pal.setBrush(QPalette::All, QPalette::WindowText, textColor);
- pal.setBrush(QPalette::Disabled, QPalette::WindowText, disabledTextColor);
- pal.setBrush(QPalette::All, QPalette::ButtonText, textColor);
- pal.setBrush(QPalette::Disabled, QPalette::ButtonText, disabledTextColor);
- return pal;
-}
-
-
-void QGtkStyleUpdateScheduler::updateTheme()
-{
- static QString oldTheme(QLS("qt_not_set"));
- QPixmapCache::clear();
-
- QFont font = QGtkStylePrivate::getThemeFont();
- if (QApplication::font() != font)
- qApp->setFont(font);
-
- if (oldTheme != QGtkStylePrivate::getThemeName()) {
- oldTheme = QGtkStylePrivate::getThemeName();
- QPalette newPalette = qApp->style()->standardPalette();
- QApplicationPrivate::setSystemPalette(newPalette);
- QApplication::setPalette(newPalette);
- if (!QGtkStylePrivate::instances.isEmpty()) {
- QGtkStylePrivate::instances.last()->initGtkWidgets();
- QGtkStylePrivate::instances.last()->applyCustomPaletteHash();
- }
- QList<QWidget*> widgets = QApplication::allWidgets();
- // Notify all widgets that size metrics might have changed
- foreach (QWidget *widget, widgets) {
- QEvent e(QEvent::StyleChange);
- QApplication::sendEvent(widget, &e);
- }
- }
- QIconLoader::instance()->updateSystemTheme();
-}
-
-void QGtkStylePrivate::addWidget(GtkWidget *widget)
-{
- if (widget) {
- setupGtkWidget(widget);
- addAllSubWidgets(widget);
- }
-}
-
-
-// Fetch the application font from the pango font description
-// contained in the theme.
-QFont QGtkStylePrivate::getThemeFont()
-{
- QFont font;
- GtkStyle *style = gtkStyle();
- if (style && qApp->desktopSettingsAware())
- {
- PangoFontDescription *gtk_font = style->font_desc;
- font.setPointSizeF((float)(pango_font_description_get_size(gtk_font))/PANGO_SCALE);
-
- QString family = QString::fromLatin1(pango_font_description_get_family(gtk_font));
- if (!family.isEmpty())
- font.setFamily(family);
-
- int weight = pango_font_description_get_weight(gtk_font);
- if (weight >= PANGO_WEIGHT_HEAVY)
- font.setWeight(QFont::Black);
- else if (weight >= PANGO_WEIGHT_BOLD)
- font.setWeight(QFont::Bold);
- else if (weight >= PANGO_WEIGHT_SEMIBOLD)
- font.setWeight(QFont::DemiBold);
- else if (weight >= PANGO_WEIGHT_NORMAL)
- font.setWeight(QFont::Normal);
- else
- font.setWeight(QFont::Light);
-
- PangoStyle fontstyle = pango_font_description_get_style(gtk_font);
- if (fontstyle == PANGO_STYLE_ITALIC)
- font.setStyle(QFont::StyleItalic);
- else if (fontstyle == PANGO_STYLE_OBLIQUE)
- font.setStyle(QFont::StyleOblique);
- else
- font.setStyle(QFont::StyleNormal);
- }
- return font;
-}
-
-
-// ----------- Native file dialogs -----------
-
-// Extract filter list from expressions of type: foo (*.a *.b *.c)"
-QStringList QGtkStylePrivate::extract_filter(const QString &rawFilter)
-{
- QString result = rawFilter;
- QRegExp r(QString::fromLatin1("^([^()]*)\\(([a-zA-Z0-9_.*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$"));
- int index = r.indexIn(result);
- if (index >= 0)
- result = r.cap(2);
- return result.split(QLatin1Char(' '));
-}
-
-extern QStringList qt_make_filter_list(const QString &filter);
-
-void QGtkStylePrivate::setupGtkFileChooser(GtkWidget* gtkFileChooser, QWidget *parent,
- const QString &dir, const QString &filter, QString *selectedFilter,
- QFileDialog::Options options, bool isSaveDialog,
- QMap<GtkFileFilter *, QString> *filterMap)
-{
- g_object_set(gtkFileChooser, "do-overwrite-confirmation", gboolean(!(options & QFileDialog::DontConfirmOverwrite)), NULL);
- g_object_set(gtkFileChooser, "local_only", gboolean(true), NULL);
- if (!filter.isEmpty()) {
- QStringList filters = qt_make_filter_list(filter);
- foreach (const QString &rawfilter, filters) {
- GtkFileFilter *gtkFilter = QGtkStylePrivate::gtk_file_filter_new ();
- QString name = rawfilter.left(rawfilter.indexOf(QLatin1Char('(')));
- QStringList extensions = extract_filter(rawfilter);
- QGtkStylePrivate::gtk_file_filter_set_name(gtkFilter, qPrintable(name.isEmpty() ? extensions.join(QLS(", ")) : name));
-
- foreach (const QString &fileExtension, extensions) {
- // Note Gtk file dialogs are by default case sensitive
- // and only supports basic glob syntax so we
- // rewrite .xyz to .[xX][yY][zZ]
- QString caseInsensitive;
- for (int i = 0 ; i < fileExtension.length() ; ++i) {
- QChar ch = fileExtension.at(i);
- if (ch.isLetter()) {
- caseInsensitive.append(
- QLatin1Char('[') +
- ch.toLower() +
- ch.toUpper() +
- QLatin1Char(']'));
- } else {
- caseInsensitive.append(ch);
- }
- }
- QGtkStylePrivate::gtk_file_filter_add_pattern (gtkFilter, qPrintable(caseInsensitive));
-
- }
- if (filterMap)
- filterMap->insert(gtkFilter, rawfilter);
- QGtkStylePrivate::gtk_file_chooser_add_filter((GtkFileChooser*)gtkFileChooser, gtkFilter);
- if (selectedFilter && (rawfilter == *selectedFilter))
- QGtkStylePrivate::gtk_file_chooser_set_filter((GtkFileChooser*)gtkFileChooser, gtkFilter);
- }
- }
-
- // Using the currently active window is not entirely correct, however
- // it gives more sensible behavior for applications that do not provide a
- // parent
- QWidget *modalFor = parent ? parent->window() : qApp->activeWindow();
- if (modalFor) {
- QGtkStylePrivate::gtk_widget_realize(gtkFileChooser); // Creates X window
- XSetTransientForHint(QGtkStylePrivate::gdk_x11_drawable_get_xdisplay(gtkFileChooser->window),
- QGtkStylePrivate::gdk_x11_drawable_get_xid(gtkFileChooser->window),
- modalFor->winId());
- QGtkStylePrivate::gdk_x11_window_set_user_time (gtkFileChooser->window, QX11Info::appUserTime());
-
- }
-
- QFileInfo fileinfo(dir);
- if (dir.isEmpty())
- fileinfo.setFile(QDir::currentPath());
- fileinfo.makeAbsolute();
- if (fileinfo.isDir()) {
- QGtkStylePrivate::gtk_file_chooser_set_current_folder((GtkFileChooser*)gtkFileChooser, qPrintable(dir));
- } else if (isSaveDialog) {
- QGtkStylePrivate::gtk_file_chooser_set_current_folder((GtkFileChooser*)gtkFileChooser, qPrintable(fileinfo.absolutePath()));
- QGtkStylePrivate::gtk_file_chooser_set_current_name((GtkFileChooser*)gtkFileChooser, qPrintable(fileinfo.fileName()));
- } else {
- QGtkStylePrivate::gtk_file_chooser_set_filename((GtkFileChooser*)gtkFileChooser, qPrintable(dir));
- }
-}
-
-QString QGtkStylePrivate::openFilename(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
- QString *selectedFilter, QFileDialog::Options options)
-{
- QMap<GtkFileFilter *, QString> filterMap;
- GtkWidget *gtkFileChooser = QGtkStylePrivate::gtk_file_chooser_dialog_new (qPrintable(caption),
- NULL,
- GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
- NULL);
-
- setupGtkFileChooser(gtkFileChooser, parent, dir, filter, selectedFilter, options, false, &filterMap);
-
- QWidget modal_widget;
- modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
- modal_widget.setParent(parent, Qt::Window);
- QApplicationPrivate::enterModal(&modal_widget);
-
- QString filename;
- if (QGtkStylePrivate::gtk_dialog_run ((GtkDialog*)gtkFileChooser) == GTK_RESPONSE_ACCEPT) {
- char *gtk_filename = QGtkStylePrivate::gtk_file_chooser_get_filename ((GtkFileChooser*)gtkFileChooser);
- filename = QString::fromUtf8(gtk_filename);
- g_free (gtk_filename);
- if (selectedFilter) {
- GtkFileFilter *gtkFilter = QGtkStylePrivate::gtk_file_chooser_get_filter ((GtkFileChooser*)gtkFileChooser);
- *selectedFilter = filterMap.value(gtkFilter);
- }
- }
-
- QApplicationPrivate::leaveModal(&modal_widget);
- gtk_widget_destroy (gtkFileChooser);
- return filename;
-}
-
-
-QString QGtkStylePrivate::openDirectory(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options)
-{
- QMap<GtkFileFilter *, QString> filterMap;
- GtkWidget *gtkFileChooser = QGtkStylePrivate::gtk_file_chooser_dialog_new (qPrintable(caption),
- NULL,
- GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
- NULL);
-
- setupGtkFileChooser(gtkFileChooser, parent, dir, QString(), 0, options);
- QWidget modal_widget;
- modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
- modal_widget.setParent(parent, Qt::Window);
- QApplicationPrivate::enterModal(&modal_widget);
-
- QString filename;
- if (QGtkStylePrivate::gtk_dialog_run ((GtkDialog*)gtkFileChooser) == GTK_RESPONSE_ACCEPT) {
- char *gtk_filename = QGtkStylePrivate::gtk_file_chooser_get_filename ((GtkFileChooser*)gtkFileChooser);
- filename = QString::fromUtf8(gtk_filename);
- g_free (gtk_filename);
- }
-
- QApplicationPrivate::leaveModal(&modal_widget);
- gtk_widget_destroy (gtkFileChooser);
- return filename;
-}
-
-QStringList QGtkStylePrivate::openFilenames(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
- QString *selectedFilter, QFileDialog::Options options)
-{
- QStringList filenames;
- QMap<GtkFileFilter *, QString> filterMap;
- GtkWidget *gtkFileChooser = QGtkStylePrivate::gtk_file_chooser_dialog_new (qPrintable(caption),
- NULL,
- GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
- NULL);
-
- setupGtkFileChooser(gtkFileChooser, parent, dir, filter, selectedFilter, options, false, &filterMap);
- g_object_set(gtkFileChooser, "select-multiple", gboolean(true), NULL);
-
- QWidget modal_widget;
- modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
- modal_widget.setParent(parent, Qt::Window);
- QApplicationPrivate::enterModal(&modal_widget);
-
- if (gtk_dialog_run ((GtkDialog*)gtkFileChooser) == GTK_RESPONSE_ACCEPT) {
- GSList *gtk_file_names = QGtkStylePrivate::gtk_file_chooser_get_filenames((GtkFileChooser*)gtkFileChooser);
- for (GSList *iterator = gtk_file_names ; iterator; iterator = iterator->next)
- filenames << QString::fromUtf8((const char*)iterator->data);
- g_slist_free(gtk_file_names);
- if (selectedFilter) {
- GtkFileFilter *gtkFilter = QGtkStylePrivate::gtk_file_chooser_get_filter ((GtkFileChooser*)gtkFileChooser);
- *selectedFilter = filterMap.value(gtkFilter);
- }
- }
-
- QApplicationPrivate::leaveModal(&modal_widget);
- gtk_widget_destroy (gtkFileChooser);
- return filenames;
-}
-
-QString QGtkStylePrivate::saveFilename(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
- QString *selectedFilter, QFileDialog::Options options)
-{
- QMap<GtkFileFilter *, QString> filterMap;
- GtkWidget *gtkFileChooser = QGtkStylePrivate::gtk_file_chooser_dialog_new (qPrintable(caption),
- NULL,
- GTK_FILE_CHOOSER_ACTION_SAVE,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
- NULL);
- setupGtkFileChooser(gtkFileChooser, parent, dir, filter, selectedFilter, options, true, &filterMap);
-
- QWidget modal_widget;
- modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
- modal_widget.setParent(parent, Qt::Window);
- QApplicationPrivate::enterModal(&modal_widget);
-
- QString filename;
- if (QGtkStylePrivate::gtk_dialog_run ((GtkDialog*)gtkFileChooser) == GTK_RESPONSE_ACCEPT) {
- char *gtk_filename = QGtkStylePrivate::gtk_file_chooser_get_filename ((GtkFileChooser*)gtkFileChooser);
- filename = QString::fromUtf8(gtk_filename);
- g_free (gtk_filename);
- if (selectedFilter) {
- GtkFileFilter *gtkFilter = QGtkStylePrivate::gtk_file_chooser_get_filter ((GtkFileChooser*)gtkFileChooser);
- *selectedFilter = filterMap.value(gtkFilter);
- }
- }
-
- QApplicationPrivate::leaveModal(&modal_widget);
- gtk_widget_destroy (gtkFileChooser);
- return filename;
-}
-
-QIcon QGtkStylePrivate::getFilesystemIcon(const QFileInfo &info)
-{
- QIcon icon;
- if (gnome_vfs_init && gnome_icon_lookup_sync) {
- gnome_vfs_init();
- GtkIconTheme *theme = gtk_icon_theme_get_default();
- QByteArray fileurl = QUrl::fromLocalFile(info.absoluteFilePath()).toEncoded();
- char * icon_name = gnome_icon_lookup_sync(theme,
- NULL,
- fileurl.data(),
- NULL,
- GNOME_ICON_LOOKUP_FLAGS_NONE,
- NULL);
- QString iconName = QString::fromUtf8(icon_name);
- g_free(icon_name);
- if (iconName.startsWith(QLatin1Char('/')))
- return QIcon(iconName);
- return QIcon::fromTheme(iconName);
- }
- return icon;
-}
-
-bool operator==(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2)
-{
- return l1.size() == l2.size() || qstrcmp(l1.data(), l2.data()) == 0;
-}
-
-// copied from qHash.cpp
-uint qHash(const QHashableLatin1Literal &key)
-{
- int n = key.size();
- const uchar *p = reinterpret_cast<const uchar *>(key.data());
- uint h = 0;
- uint g;
-
- while (n--) {
- h = (h << 4) + *p++;
- if ((g = (h & 0xf0000000)) != 0)
- h ^= g >> 23;
- h &= ~g;
- }
- return h;
-}
-
-QT_END_NAMESPACE
-
-#endif // !defined(QT_NO_STYLE_GTK)
diff --git a/src/gui/styles/qgtkstyle_p.h b/src/gui/styles/qgtkstyle_p.h
deleted file mode 100644
index 15a98c8257..0000000000
--- a/src/gui/styles/qgtkstyle_p.h
+++ /dev/null
@@ -1,531 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGTKSTYLE_P_H
-#define QGTKSTYLE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qglobal.h>
-#if !defined(QT_NO_STYLE_GTK)
-
-#include <QtCore/qstring.h>
-#include <QtCore/qstringbuilder.h>
-#include <QtCore/qcoreapplication.h>
-
-#include <QtGui/QFileDialog>
-
-#include <QtGui/QGtkStyle>
-#include <private/qcleanlooksstyle_p.h>
-
-#undef signals // Collides with GTK stymbols
-#include <gtk/gtk.h>
-
-typedef unsigned long XID;
-
-#undef GTK_OBJECT_FLAGS
-#define GTK_OBJECT_FLAGS(obj)(((GtkObject*)(obj))->flags)
-#define Q_GTK_IS_WIDGET(widget) widget && GTK_CHECK_TYPE ((widget), QGtkStylePrivate::gtk_widget_get_type())
-
-#define QLS(x) QLatin1String(x)
-
-QT_BEGIN_NAMESPACE
-
-// ### Qt 4.7 - merge with QLatin1Literal
-class QHashableLatin1Literal
-{
-public:
- int size() const { return m_size; }
- const char *data() const { return m_data; }
-
-#ifdef __SUNPRO_CC
- QHashableLatin1Literal(const char* str)
- : m_size(strlen(str)), m_data(str) {}
-#else
- template <int N>
- QHashableLatin1Literal(const char (&str)[N])
- : m_size(N - 1), m_data(str) {}
-#endif
-
- QHashableLatin1Literal(const QHashableLatin1Literal &other)
- : m_size(other.m_size), m_data(other.m_data)
- {}
-
- QHashableLatin1Literal &operator=(const QHashableLatin1Literal &other)
- {
- if (this == &other)
- return *this;
- *const_cast<int *>(&m_size) = other.m_size;
- *const_cast<char **>(&m_data) = const_cast<char *>(other.m_data);
- return *this;
- }
-
- QString toString() const { return QString::fromLatin1(m_data, m_size); }
-
- static QHashableLatin1Literal fromData(const char *str)
- {
- return QHashableLatin1Literal(str, qstrlen(str));
- }
-
-private:
- QHashableLatin1Literal(const char *str, int length)
- : m_size(length), m_data(str)
- {}
-
- const int m_size;
- const char *m_data;
-};
-
-bool operator==(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2);
-inline bool operator!=(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2) { return !operator==(l1, l2); }
-uint qHash(const QHashableLatin1Literal &key);
-
-QT_END_NAMESPACE
-
-class GConf;
-class GConfClient;
-
-typedef GConfClient* (*Ptr_gconf_client_get_default)();
-typedef char* (*Ptr_gconf_client_get_string)(GConfClient*, const char*, GError **);
-typedef bool (*Ptr_gconf_client_get_bool)(GConfClient*, const char*, GError **);
-
-typedef void (*Ptr_gtk_init)(int *, char ***);
-typedef GtkWidget* (*Ptr_gtk_window_new) (GtkWindowType);
-typedef GtkStyle* (*Ptr_gtk_style_attach)(GtkStyle *, GdkWindow *);
-typedef void (*Ptr_gtk_widget_destroy) (GtkWidget *);
-typedef void (*Ptr_gtk_widget_realize) (GtkWidget *);
-typedef void (*Ptr_gtk_widget_set_default_direction) (GtkTextDirection);
-typedef void (*Ptr_gtk_widget_modify_color)(GtkWidget *widget, GtkStateType state, const GdkColor *color);
-typedef GtkWidget* (*Ptr_gtk_arrow_new)(GtkArrowType, GtkShadowType);
-typedef GtkWidget* (*Ptr_gtk_menu_item_new_with_label)(const gchar *);
-typedef GtkWidget* (*Ptr_gtk_separator_menu_item_new)(void);
-typedef GtkWidget* (*Ptr_gtk_check_menu_item_new_with_label)(const gchar *);
-typedef GtkWidget* (*Ptr_gtk_menu_bar_new)(void);
-typedef GtkWidget* (*Ptr_gtk_menu_new)(void);
-typedef GtkWidget* (*Ptr_gtk_combo_box_entry_new)(void);
-typedef GtkWidget* (*Ptr_gtk_toolbar_new)(void);
-typedef GtkWidget* (*Ptr_gtk_spin_button_new)(GtkAdjustment*, double, int);
-typedef GtkWidget* (*Ptr_gtk_button_new)(void);
-typedef GtkWidget* (*Ptr_gtk_tool_button_new)(GtkWidget *, const gchar *);
-typedef GtkWidget* (*Ptr_gtk_hbutton_box_new)(void);
-typedef GtkWidget* (*Ptr_gtk_check_button_new)(void);
-typedef GtkWidget* (*Ptr_gtk_radio_button_new)(GSList *);
-typedef GtkWidget* (*Ptr_gtk_notebook_new)(void);
-typedef GtkWidget* (*Ptr_gtk_progress_bar_new)(void);
-typedef GtkWidget* (*Ptr_gtk_hscale_new)(GtkAdjustment*);
-typedef GtkWidget* (*Ptr_gtk_vscale_new)(GtkAdjustment*);
-typedef GtkWidget* (*Ptr_gtk_hscrollbar_new)(GtkAdjustment*);
-typedef GtkWidget* (*Ptr_gtk_vscrollbar_new)(GtkAdjustment*);
-typedef GtkWidget* (*Ptr_gtk_scrolled_window_new)(GtkAdjustment*, GtkAdjustment*);
-typedef gchar* (*Ptr_gtk_check_version)(guint, guint, guint);
-typedef GtkToolItem* (*Ptr_gtk_separator_tool_item_new) (void);
-typedef GtkWidget* (*Ptr_gtk_entry_new)(void);
-typedef GtkWidget* (*Ptr_gtk_tree_view_new)(void);
-typedef GtkTreeViewColumn* (*Ptr_gtk_tree_view_get_column)(GtkTreeView *, gint);
-typedef GtkWidget* (*Ptr_gtk_combo_box_new)(void);
-typedef GtkWidget* (*Ptr_gtk_frame_new)(const gchar *);
-typedef GtkWidget* (*Ptr_gtk_expander_new)(const gchar*);
-typedef GtkWidget* (*Ptr_gtk_statusbar_new)(void);
-typedef GtkSettings* (*Ptr_gtk_settings_get_default)(void);
-typedef GtkAdjustment* (*Ptr_gtk_range_get_adjustment)(GtkRange *);
-typedef void (*Ptr_gtk_range_set_adjustment)(GtkRange *, GtkAdjustment *);
-typedef void (*Ptr_gtk_progress_configure)(GtkProgress *, double, double, double);
-typedef void (*Ptr_gtk_range_set_inverted)(GtkRange*, bool);
-typedef void (*Ptr_gtk_container_add)(GtkContainer *container, GtkWidget *widget);
-typedef GtkIconSet* (*Ptr_gtk_icon_factory_lookup_default) (const gchar*);
-typedef GtkIconTheme* (*Ptr_gtk_icon_theme_get_default) (void);
-typedef void (*Ptr_gtk_widget_style_get)(GtkWidget *, const gchar *first_property_name, ...);
-typedef GtkTreeViewColumn* (*Ptr_gtk_tree_view_column_new)(void);
-typedef GtkWidget* (*Ptr_gtk_fixed_new)(void);
-typedef GdkPixbuf* (*Ptr_gtk_icon_set_render_icon)(GtkIconSet *, GtkStyle *, GtkTextDirection, GtkStateType, GtkIconSize, GtkWidget *,const char *);
-typedef void (*Ptr_gtk_tree_view_append_column) (GtkTreeView*, GtkTreeViewColumn*);
-typedef void (*Ptr_gtk_paint_check) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
-typedef void (*Ptr_gtk_paint_box) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
-typedef void (*Ptr_gtk_paint_box_gap) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint , gint, GtkPositionType, gint gap_x, gint gap_width);
-typedef void (*Ptr_gtk_paint_resize_grip) (GtkStyle*,GdkWindow*, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, GdkWindowEdge, gint , gint , gint , gint);
-typedef void (*Ptr_gtk_paint_focus) (GtkStyle*,GdkWindow*, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
-typedef void (*Ptr_gtk_paint_shadow) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
-typedef void (*Ptr_gtk_paint_slider) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint, GtkOrientation);
-typedef void (*Ptr_gtk_paint_expander) (GtkStyle*,GdkWindow*, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , GtkExpanderStyle );
-typedef void (*Ptr_gtk_paint_handle) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint, GtkOrientation);
-typedef void (*Ptr_gtk_paint_arrow) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, GtkArrowType, gboolean, gint , gint , gint , gint);
-typedef void (*Ptr_gtk_paint_option) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
-typedef void (*Ptr_gtk_paint_flat_box) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
-typedef void (*Ptr_gtk_paint_extension) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint, gint, GtkPositionType);
-typedef void (*Ptr_gtk_adjustment_configure) (GtkAdjustment *, double, double, double, double, double, double);
-typedef GtkObject* (*Ptr_gtk_adjustment_new) (double, double, double, double, double, double);
-typedef void (*Ptr_gtk_paint_hline) (GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint y);
-typedef void (*Ptr_gtk_paint_vline) (GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint);
-typedef void (*Ptr_gtk_menu_item_set_submenu) (GtkMenuItem *, GtkWidget *);
-typedef void (*Ptr_gtk_container_forall) (GtkContainer *, GtkCallback, gpointer);
-typedef void (*Ptr_gtk_widget_size_allocate) (GtkWidget *, GtkAllocation*);
-typedef void (*Ptr_gtk_widget_size_request) (GtkWidget *widget, GtkRequisition *requisition);
-typedef void (*Ptr_gtk_widget_set_direction) (GtkWidget *, GtkTextDirection);
-typedef void (*Ptr_gtk_widget_path) (GtkWidget *, guint *, gchar **, gchar**);
-
-typedef void (*Ptr_gtk_toolbar_insert) (GtkToolbar *toolbar, GtkToolItem *item, int pos);
-typedef void (*Ptr_gtk_menu_shell_append)(GtkMenuShell *, GtkWidget *);
-typedef GtkType (*Ptr_gtk_container_get_type) (void);
-typedef GtkType (*Ptr_gtk_window_get_type) (void);
-typedef GtkType (*Ptr_gtk_widget_get_type) (void);
-typedef GtkStyle* (*Ptr_gtk_rc_get_style_by_paths) (GtkSettings *, const char *, const char *, GType);
-typedef gint (*Ptr_pango_font_description_get_size) (const PangoFontDescription *);
-typedef PangoWeight (*Ptr_pango_font_description_get_weight) (const PangoFontDescription *);
-typedef const char* (*Ptr_pango_font_description_get_family) (const PangoFontDescription *);
-typedef PangoStyle (*Ptr_pango_font_description_get_style) (const PangoFontDescription *desc);
-typedef gboolean (*Ptr_gtk_file_chooser_set_current_folder)(GtkFileChooser *, const gchar *);
-typedef GtkFileFilter* (*Ptr_gtk_file_filter_new)(void);
-typedef void (*Ptr_gtk_file_filter_set_name)(GtkFileFilter *, const gchar *);
-typedef void (*Ptr_gtk_file_filter_add_pattern)(GtkFileFilter *filter, const gchar *pattern);
-typedef void (*Ptr_gtk_file_chooser_add_filter)(GtkFileChooser *chooser, GtkFileFilter *filter);
-typedef void (*Ptr_gtk_file_chooser_set_filter)(GtkFileChooser *chooser, GtkFileFilter *filter);
-typedef GtkFileFilter* (*Ptr_gtk_file_chooser_get_filter)(GtkFileChooser *chooser);
-typedef gchar* (*Ptr_gtk_file_chooser_get_filename)(GtkFileChooser *chooser);
-typedef GSList* (*Ptr_gtk_file_chooser_get_filenames)(GtkFileChooser *chooser);
-typedef GtkWidget* (*Ptr_gtk_file_chooser_dialog_new)(const gchar *title,
- GtkWindow *parent,
- GtkFileChooserAction action,
- const gchar *first_button_text,
- ...);
-typedef void (*Ptr_gtk_file_chooser_set_current_name) (GtkFileChooser *, const gchar *);
-typedef gboolean (*Ptr_gtk_file_chooser_set_filename) (GtkFileChooser *chooser, const gchar *name);
-typedef gint (*Ptr_gtk_dialog_run) (GtkDialog*);
-typedef void (*Ptr_gtk_border_free)(GtkBorder *);
-
-typedef guchar* (*Ptr_gdk_pixbuf_get_pixels) (const GdkPixbuf *pixbuf);
-typedef int (*Ptr_gdk_pixbuf_get_width) (const GdkPixbuf *pixbuf);
-typedef void (*Ptr_gdk_color_free) (const GdkColor *);
-typedef int (*Ptr_gdk_pixbuf_get_height) (const GdkPixbuf *pixbuf);
-typedef GdkPixbuf* (*Ptr_gdk_pixbuf_get_from_drawable) (GdkPixbuf *dest, GdkDrawable *src,
- GdkColormap *cmap, int src_x,
- int src_y, int dest_x, int dest_y,
- int width, int height);
-typedef GdkPixmap* (*Ptr_gdk_pixmap_new) (GdkDrawable *drawable, gint width, gint height, gint depth);
-typedef GdkPixbuf* (*Ptr_gdk_pixbuf_new) (GdkColorspace colorspace, gboolean has_alpha,
- int bits_per_sample, int width, int height);
-typedef void (*Ptr_gdk_draw_rectangle) (GdkDrawable *drawable, GdkGC *gc,
- gboolean filled, gint x, gint y, gint width, gint height);
-typedef void (*Ptr_gdk_pixbuf_unref)(GdkPixbuf *);
-typedef void (*Ptr_gdk_drawable_unref)(GdkDrawable *);
-typedef gint (*Ptr_gdk_drawable_get_depth)(GdkDrawable *);
-typedef void (*Ptr_gdk_x11_window_set_user_time) (GdkWindow *window, guint32);
-typedef XID (*Ptr_gdk_x11_drawable_get_xid) (GdkDrawable *);
-typedef Display* (*Ptr_gdk_x11_drawable_get_xdisplay) ( GdkDrawable *);
-
-
-QT_BEGIN_NAMESPACE
-
-typedef QStringList (*_qt_filedialog_open_filenames_hook)(QWidget * parent, const QString &caption, const QString &dir,
- const QString &filter, QString *selectedFilter, QFileDialog::Options options);
-typedef QString (*_qt_filedialog_open_filename_hook) (QWidget * parent, const QString &caption, const QString &dir,
- const QString &filter, QString *selectedFilter, QFileDialog::Options options);
-typedef QString (*_qt_filedialog_save_filename_hook) (QWidget * parent, const QString &caption, const QString &dir,
- const QString &filter, QString *selectedFilter, QFileDialog::Options options);
-typedef QString (*_qt_filedialog_existing_directory_hook)(QWidget *parent, const QString &caption, const QString &dir,
- QFileDialog::Options options);
-
-extern Q_GUI_EXPORT _qt_filedialog_open_filename_hook qt_filedialog_open_filename_hook;
-extern Q_GUI_EXPORT _qt_filedialog_open_filenames_hook qt_filedialog_open_filenames_hook;
-extern Q_GUI_EXPORT _qt_filedialog_save_filename_hook qt_filedialog_save_filename_hook;
-extern Q_GUI_EXPORT _qt_filedialog_existing_directory_hook qt_filedialog_existing_directory_hook;
-
-class QGtkStylePrivate;
-
-class QGtkStyleFilter : public QObject
-{
-public:
- QGtkStyleFilter(QGtkStylePrivate* sp)
- : stylePrivate(sp)
- {}
-private:
- QGtkStylePrivate* stylePrivate;
- bool eventFilter(QObject *obj, QEvent *e);
-};
-
-typedef enum {
- GNOME_ICON_LOOKUP_FLAGS_NONE = 0,
- GNOME_ICON_LOOKUP_FLAGS_EMBEDDING_TEXT = 1<<0,
- GNOME_ICON_LOOKUP_FLAGS_SHOW_SMALL_IMAGES_AS_THEMSELVES = 1<<1,
- GNOME_ICON_LOOKUP_FLAGS_ALLOW_SVG_AS_THEMSELVES = 1<<2
-} GnomeIconLookupFlags;
-
-typedef enum {
- GNOME_ICON_LOOKUP_RESULT_FLAGS_NONE = 0,
- GNOME_ICON_LOOKUP_RESULT_FLAGS_THUMBNAIL = 1<<0
-} GnomeIconLookupResultFlags;
-
-struct GnomeThumbnailFactory;
-typedef gboolean (*Ptr_gnome_vfs_init) (void);
-typedef char* (*Ptr_gnome_icon_lookup_sync) (
- GtkIconTheme *icon_theme,
- GnomeThumbnailFactory *,
- const char *file_uri,
- const char *custom_icon,
- GnomeIconLookupFlags flags,
- GnomeIconLookupResultFlags *result);
-
-class QGtkStylePrivate : public QCleanlooksStylePrivate
-{
- Q_DECLARE_PUBLIC(QGtkStyle)
-public:
- QGtkStylePrivate();
- ~QGtkStylePrivate();
-
- QGtkStyleFilter filter;
-
- static GtkWidget* gtkWidget(const QHashableLatin1Literal &path);
- static GtkStyle* gtkStyle(const QHashableLatin1Literal &path = QHashableLatin1Literal("GtkWindow"));
-
- virtual void resolveGtk() const;
- virtual void initGtkMenu() const;
- virtual void initGtkTreeview() const;
- virtual void initGtkWidgets() const;
-
- static void cleanupGtkWidgets();
-
- static bool isKDE4Session();
- void applyCustomPaletteHash();
- static QFont getThemeFont();
- static bool isThemeAvailable() { return gtkStyle() != 0; }
-
- static bool getGConfBool(const QString &key, bool fallback = 0);
- static QString getGConfString(const QString &key, const QString &fallback = QString());
-
- static QString getThemeName();
- virtual int getSpinboxArrowSize() const;
-
- static void setupGtkFileChooser(GtkWidget* gtkFileChooser, QWidget *parent,
- const QString &dir, const QString &filter, QString *selectedFilter,
- QFileDialog::Options options, bool isSaveDialog = false,
- QMap<GtkFileFilter *, QString> *filterMap = 0);
-
- static QString openFilename(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
- QString *selectedFilter, QFileDialog::Options options);
- static QString saveFilename(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
- QString *selectedFilter, QFileDialog::Options options);
- static QString openDirectory(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options);
- static QStringList openFilenames(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
- QString *selectedFilter, QFileDialog::Options options);
- static QIcon getFilesystemIcon(const QFileInfo &);
-
- static Ptr_gtk_container_forall gtk_container_forall;
- static Ptr_gtk_init gtk_init;
- static Ptr_gtk_style_attach gtk_style_attach;
- static Ptr_gtk_window_new gtk_window_new;
- static Ptr_gtk_widget_destroy gtk_widget_destroy;
- static Ptr_gtk_widget_realize gtk_widget_realize;
- static Ptr_gtk_widget_set_default_direction gtk_widget_set_default_direction;
- static Ptr_gtk_widget_modify_color gtk_widget_modify_fg;
- static Ptr_gtk_widget_modify_color gtk_widget_modify_bg;
- static Ptr_gtk_menu_item_new_with_label gtk_menu_item_new_with_label;
- static Ptr_gtk_arrow_new gtk_arrow_new;
- static Ptr_gtk_check_menu_item_new_with_label gtk_check_menu_item_new_with_label;
- static Ptr_gtk_menu_bar_new gtk_menu_bar_new;
- static Ptr_gtk_menu_new gtk_menu_new;
- static Ptr_gtk_expander_new gtk_expander_new;
- static Ptr_gtk_button_new gtk_button_new;
- static Ptr_gtk_tool_button_new gtk_tool_button_new;
- static Ptr_gtk_hbutton_box_new gtk_hbutton_box_new;
- static Ptr_gtk_check_button_new gtk_check_button_new;
- static Ptr_gtk_radio_button_new gtk_radio_button_new;
- static Ptr_gtk_spin_button_new gtk_spin_button_new;
- static Ptr_gtk_separator_tool_item_new gtk_separator_tool_item_new;
- static Ptr_gtk_toolbar_insert gtk_toolbar_insert;
- static Ptr_gtk_frame_new gtk_frame_new;
- static Ptr_gtk_statusbar_new gtk_statusbar_new;
- static Ptr_gtk_entry_new gtk_entry_new;
- static Ptr_gtk_hscale_new gtk_hscale_new;
- static Ptr_gtk_vscale_new gtk_vscale_new;
- static Ptr_gtk_hscrollbar_new gtk_hscrollbar_new;
- static Ptr_gtk_vscrollbar_new gtk_vscrollbar_new;
- static Ptr_gtk_scrolled_window_new gtk_scrolled_window_new;
- static Ptr_gtk_notebook_new gtk_notebook_new;
- static Ptr_gtk_toolbar_new gtk_toolbar_new;
- static Ptr_gtk_tree_view_new gtk_tree_view_new;
- static Ptr_gtk_tree_view_get_column gtk_tree_view_get_column;
- static Ptr_gtk_combo_box_new gtk_combo_box_new;
- static Ptr_gtk_combo_box_entry_new gtk_combo_box_entry_new;
- static Ptr_gtk_progress_bar_new gtk_progress_bar_new;
- static Ptr_gtk_container_add gtk_container_add;
- static Ptr_gtk_menu_shell_append gtk_menu_shell_append;
- static Ptr_gtk_progress_configure gtk_progress_configure;
- static Ptr_gtk_range_get_adjustment gtk_range_get_adjustment;
- static Ptr_gtk_range_set_adjustment gtk_range_set_adjustment;
- static Ptr_gtk_range_set_inverted gtk_range_set_inverted;
- static Ptr_gtk_icon_factory_lookup_default gtk_icon_factory_lookup_default;
- static Ptr_gtk_icon_theme_get_default gtk_icon_theme_get_default;
- static Ptr_gtk_widget_style_get gtk_widget_style_get;
- static Ptr_gtk_icon_set_render_icon gtk_icon_set_render_icon;
- static Ptr_gtk_fixed_new gtk_fixed_new;
- static Ptr_gtk_tree_view_column_new gtk_tree_view_column_new;
- static Ptr_gtk_tree_view_append_column gtk_tree_view_append_column;
- static Ptr_gtk_paint_check gtk_paint_check;
- static Ptr_gtk_paint_box gtk_paint_box;
- static Ptr_gtk_paint_box_gap gtk_paint_box_gap;
- static Ptr_gtk_paint_flat_box gtk_paint_flat_box;
- static Ptr_gtk_paint_option gtk_paint_option;
- static Ptr_gtk_paint_extension gtk_paint_extension;
- static Ptr_gtk_paint_slider gtk_paint_slider;
- static Ptr_gtk_paint_shadow gtk_paint_shadow;
- static Ptr_gtk_paint_resize_grip gtk_paint_resize_grip;
- static Ptr_gtk_paint_focus gtk_paint_focus;
- static Ptr_gtk_paint_arrow gtk_paint_arrow;
- static Ptr_gtk_paint_handle gtk_paint_handle;
- static Ptr_gtk_paint_expander gtk_paint_expander;
- static Ptr_gtk_adjustment_configure gtk_adjustment_configure;
- static Ptr_gtk_adjustment_new gtk_adjustment_new;
- static Ptr_gtk_paint_vline gtk_paint_vline;
- static Ptr_gtk_paint_hline gtk_paint_hline;
- static Ptr_gtk_menu_item_set_submenu gtk_menu_item_set_submenu;
- static Ptr_gtk_settings_get_default gtk_settings_get_default;
- static Ptr_gtk_separator_menu_item_new gtk_separator_menu_item_new;
- static Ptr_gtk_widget_size_allocate gtk_widget_size_allocate;
- static Ptr_gtk_widget_size_request gtk_widget_size_request;
- static Ptr_gtk_widget_set_direction gtk_widget_set_direction;
- static Ptr_gtk_widget_path gtk_widget_path;
- static Ptr_gtk_container_get_type gtk_container_get_type;
- static Ptr_gtk_window_get_type gtk_window_get_type;
- static Ptr_gtk_widget_get_type gtk_widget_get_type;
- static Ptr_gtk_rc_get_style_by_paths gtk_rc_get_style_by_paths;
- static Ptr_gtk_check_version gtk_check_version;
- static Ptr_gtk_border_free gtk_border_free;
-
- static Ptr_pango_font_description_get_size pango_font_description_get_size;
- static Ptr_pango_font_description_get_weight pango_font_description_get_weight;
- static Ptr_pango_font_description_get_family pango_font_description_get_family;
- static Ptr_pango_font_description_get_style pango_font_description_get_style;
-
- static Ptr_gtk_file_filter_new gtk_file_filter_new;
- static Ptr_gtk_file_filter_set_name gtk_file_filter_set_name;
- static Ptr_gtk_file_filter_add_pattern gtk_file_filter_add_pattern;
- static Ptr_gtk_file_chooser_add_filter gtk_file_chooser_add_filter;
- static Ptr_gtk_file_chooser_set_filter gtk_file_chooser_set_filter;
- static Ptr_gtk_file_chooser_get_filter gtk_file_chooser_get_filter;
- static Ptr_gtk_file_chooser_dialog_new gtk_file_chooser_dialog_new;
- static Ptr_gtk_file_chooser_set_current_folder gtk_file_chooser_set_current_folder;
- static Ptr_gtk_file_chooser_get_filename gtk_file_chooser_get_filename;
- static Ptr_gtk_file_chooser_get_filenames gtk_file_chooser_get_filenames;
- static Ptr_gtk_file_chooser_set_current_name gtk_file_chooser_set_current_name;
- static Ptr_gtk_dialog_run gtk_dialog_run;
- static Ptr_gtk_file_chooser_set_filename gtk_file_chooser_set_filename;
-
- static Ptr_gdk_pixbuf_get_pixels gdk_pixbuf_get_pixels;
- static Ptr_gdk_pixbuf_get_width gdk_pixbuf_get_width;
- static Ptr_gdk_pixbuf_get_height gdk_pixbuf_get_height;
- static Ptr_gdk_pixmap_new gdk_pixmap_new;
- static Ptr_gdk_pixbuf_new gdk_pixbuf_new;
- static Ptr_gdk_pixbuf_get_from_drawable gdk_pixbuf_get_from_drawable;
- static Ptr_gdk_draw_rectangle gdk_draw_rectangle;
- static Ptr_gdk_pixbuf_unref gdk_pixbuf_unref;
- static Ptr_gdk_drawable_unref gdk_drawable_unref;
- static Ptr_gdk_drawable_get_depth gdk_drawable_get_depth;
- static Ptr_gdk_color_free gdk_color_free;
- static Ptr_gdk_x11_window_set_user_time gdk_x11_window_set_user_time;
- static Ptr_gdk_x11_drawable_get_xid gdk_x11_drawable_get_xid;
- static Ptr_gdk_x11_drawable_get_xdisplay gdk_x11_drawable_get_xdisplay;
-
- static Ptr_gconf_client_get_default gconf_client_get_default;
- static Ptr_gconf_client_get_string gconf_client_get_string;
- static Ptr_gconf_client_get_bool gconf_client_get_bool;
-
- static Ptr_gnome_icon_lookup_sync gnome_icon_lookup_sync;
- static Ptr_gnome_vfs_init gnome_vfs_init;
-
- virtual QPalette gtkWidgetPalette(const QHashableLatin1Literal &gtkWidgetName) const;
-
-protected:
- typedef QHash<QHashableLatin1Literal, GtkWidget*> WidgetMap;
-
- static inline void destroyWidgetMap()
- {
- cleanupGtkWidgets();
- delete widgetMap;
- widgetMap = 0;
- }
-
- static inline WidgetMap *gtkWidgetMap()
- {
- if (!widgetMap) {
- widgetMap = new WidgetMap();
- qAddPostRoutine(destroyWidgetMap);
- }
- return widgetMap;
- }
-
- static QStringList extract_filter(const QString &rawFilter);
-
- virtual GtkWidget* getTextColorWidget() const;
- static void setupGtkWidget(GtkWidget* widget);
- static void addWidgetToMap(GtkWidget* widget);
- static void addAllSubWidgets(GtkWidget *widget, gpointer v = 0);
- static void addWidget(GtkWidget *widget);
- static void removeWidgetFromMap(const QHashableLatin1Literal &path);
-
- virtual void init();
-
-private:
- static QList<QGtkStylePrivate *> instances;
- static WidgetMap *widgetMap;
- friend class QGtkStyleUpdateScheduler;
-};
-
-// Helper to ensure that we have polished all our gtk widgets
-// before updating our own palettes
-class QGtkStyleUpdateScheduler : public QObject
-{
- Q_OBJECT
-public slots:
- void updateTheme();
-};
-
-QT_END_NAMESPACE
-
-#endif // !QT_NO_STYLE_GTK
-#endif // QGTKSTYLE_P_H
diff --git a/src/gui/styles/qmacstyle_mac.h b/src/gui/styles/qmacstyle_mac.h
deleted file mode 100644
index 78a25ce9b2..0000000000
--- a/src/gui/styles/qmacstyle_mac.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMACSTYLE_MAC_H
-#define QMACSTYLE_MAC_H
-
-#include <QtGui/qwindowsstyle.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC)
-
-class QPalette;
-
-#if defined(QT_PLUGIN)
-#define Q_GUI_EXPORT_STYLE_MAC
-#else
-#define Q_GUI_EXPORT_STYLE_MAC Q_GUI_EXPORT
-#endif
-
-class QPushButton;
-class QStyleOptionButton;
-class QMacStylePrivate;
-class Q_GUI_EXPORT_STYLE_MAC QMacStyle : public QWindowsStyle
-{
- Q_OBJECT
-public:
- QMacStyle();
- virtual ~QMacStyle();
-
- void polish(QWidget *w);
- void unpolish(QWidget *w);
-
- void polish(QApplication*);
- void unpolish(QApplication*);
-
- void polish(QPalette &pal);
-
- void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
- const QWidget *w = 0) const;
- void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
- const QWidget *w = 0) const;
- QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const;
- void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
- const QWidget *w = 0) const;
- SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
- const QPoint &pt, const QWidget *w = 0) const;
- QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc,
- const QWidget *w = 0) const;
- QSize sizeFromContents(ContentsType ct, const QStyleOption *opt,
- const QSize &contentsSize, const QWidget *w = 0) const;
-
- int pixelMetric(PixelMetric pm, const QStyleOption *opt = 0, const QWidget *widget = 0) const;
-
- QPalette standardPalette() const;
-
- virtual int styleHint(StyleHint sh, const QStyleOption *opt = 0, const QWidget *w = 0,
- QStyleHintReturn *shret = 0) const;
-
- enum FocusRectPolicy { FocusEnabled, FocusDisabled, FocusDefault };
- static void setFocusRectPolicy(QWidget *w, FocusRectPolicy policy);
- static FocusRectPolicy focusRectPolicy(const QWidget *w);
-
- enum WidgetSizePolicy { SizeSmall, SizeLarge, SizeMini, SizeDefault
-#ifdef QT3_SUPPORT
- , SizeNone = SizeDefault
-#endif
- };
- static void setWidgetSizePolicy(const QWidget *w, WidgetSizePolicy policy);
- static WidgetSizePolicy widgetSizePolicy(const QWidget *w);
-
- QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *opt,
- const QWidget *widget = 0) const;
-
- QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
- const QStyleOption *opt) const;
-
- virtual void drawItemText(QPainter *p, const QRect &r, int flags, const QPalette &pal,
- bool enabled, const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const;
-
- bool event(QEvent *e);
-
-protected Q_SLOTS:
- QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt = 0,
- const QWidget *widget = 0) const;
- int layoutSpacingImplementation(QSizePolicy::ControlType control1,
- QSizePolicy::ControlType control2,
- Qt::Orientation orientation,
- const QStyleOption *option = 0,
- const QWidget *widget = 0) const;
-
-private:
- Q_DISABLE_COPY(QMacStyle)
-
- QMacStylePrivate *d;
-
- friend bool qt_mac_buttonIsRenderedFlat(const QPushButton *pushButton, const QStyleOptionButton *option);
-};
-
-#endif // Q_WS_MAC
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMACSTYLE_H
diff --git a/src/gui/styles/qmacstyle_mac_p.h b/src/gui/styles/qmacstyle_mac_p.h
deleted file mode 100644
index fbd6d57e09..0000000000
--- a/src/gui/styles/qmacstyle_mac_p.h
+++ /dev/null
@@ -1,241 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#ifndef QMACSTYLE_MAC_P_H
-#define QMACSTYLE_MAC_P_H
-
-#include <qmacstyle_mac.h>
-#include <private/qapplication_p.h>
-#include <private/qcombobox_p.h>
-#include <private/qmacstylepixmaps_mac_p.h>
-#include <private/qpaintengine_mac_p.h>
-#include <private/qpainter_p.h>
-#include <private/qprintengine_mac_p.h>
-#include <private/qstylehelper_p.h>
-#include <qapplication.h>
-#include <qbitmap.h>
-#include <qcheckbox.h>
-#include <qcombobox.h>
-#include <qdialogbuttonbox.h>
-#include <qdockwidget.h>
-#include <qevent.h>
-#include <qfocusframe.h>
-#include <qformlayout.h>
-#include <qgroupbox.h>
-#include <qhash.h>
-#include <qheaderview.h>
-#include <qlayout.h>
-#include <qlineedit.h>
-#include <qlistview.h>
-#include <qmainwindow.h>
-#include <qmap.h>
-#include <qmenubar.h>
-#include <qpaintdevice.h>
-#include <qpainter.h>
-#include <qpixmapcache.h>
-#include <qpointer.h>
-#include <qprogressbar.h>
-#include <qpushbutton.h>
-#include <qradiobutton.h>
-#include <qrubberband.h>
-#include <qsizegrip.h>
-#include <qspinbox.h>
-#include <qsplitter.h>
-#include <qstyleoption.h>
-#include <qtextedit.h>
-#include <qtextstream.h>
-#include <qtoolbar.h>
-#include <qtoolbutton.h>
-#include <qtreeview.h>
-#include <qtableview.h>
-#include <qwizard.h>
-#include <qdebug.h>
-#include <qlibrary.h>
-#include <qdatetimeedit.h>
-#include <qmath.h>
-#include <QtGui/qgraphicsproxywidget.h>
-#include <QtGui/qgraphicsview.h>
-#include <private/qt_cocoa_helpers_mac_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.
-//
-
-QT_BEGIN_NAMESPACE
-
-#if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5)
-enum {
- kThemePushButtonTextured = 31,
- kThemePushButtonTexturedSmall = 32,
- kThemePushButtonTexturedMini = 33
-};
-
-/* Search fields */
-enum {
- kHIThemeFrameTextFieldRound = 1000,
- kHIThemeFrameTextFieldRoundSmall = 1001,
- kHIThemeFrameTextFieldRoundMini = 1002
-};
-#endif
-
-/*
- AHIG:
- Apple Human Interface Guidelines
- http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/
-
- Builder:
- Apple Interface Builder v. 3.1.1
-*/
-
-// this works as long as we have at most 16 different control types
-#define CT1(c) CT2(c, c)
-#define CT2(c1, c2) ((uint(c1) << 16) | uint(c2))
-
-enum QAquaWidgetSize { QAquaSizeLarge = 0, QAquaSizeSmall = 1, QAquaSizeMini = 2,
- QAquaSizeUnknown = -1 };
-
-#define SIZE(large, small, mini) \
- (controlSize == QAquaSizeLarge ? (large) : controlSize == QAquaSizeSmall ? (small) : (mini))
-
-// same as return SIZE(...) but optimized
-#define return_SIZE(large, small, mini) \
- do { \
- static const int sizes[] = { (large), (small), (mini) }; \
- return sizes[controlSize]; \
- } while (0)
-
-bool qt_mac_buttonIsRenderedFlat(const QPushButton *pushButton, const QStyleOptionButton *option);
-
-class QMacStylePrivate : public QObject
-{
- Q_OBJECT
-
-public:
- QMacStylePrivate(QMacStyle *style);
-
- // Ideally these wouldn't exist, but since they already exist we need some accessors.
- static const int PushButtonLeftOffset;
- static const int PushButtonTopOffset;
- static const int PushButtonRightOffset;
- static const int PushButtonBottomOffset;
- static const int MiniButtonH;
- static const int SmallButtonH;
- static const int BevelButtonW;
- static const int BevelButtonH;
- static const int PushButtonContentPadding;
-
-
- // Stuff from QAquaAnimate:
- bool addWidget(QWidget *);
- void removeWidget(QWidget *);
-
- enum Animates { AquaPushButton, AquaProgressBar, AquaListViewItemOpen };
- bool animatable(Animates, const QWidget *) const;
- void stopAnimate(Animates, QWidget *);
- void startAnimate(Animates, QWidget *);
- static ThemeDrawState getDrawState(QStyle::State flags);
- QAquaWidgetSize aquaSizeConstrain(const QStyleOption *option, const QWidget *widg,
- QStyle::ContentsType ct = QStyle::CT_CustomBase,
- QSize szHint=QSize(-1, -1), QSize *insz = 0) const;
- void getSliderInfo(QStyle::ComplexControl cc, const QStyleOptionSlider *slider,
- HIThemeTrackDrawInfo *tdi, const QWidget *needToRemoveMe);
- bool doAnimate(Animates);
- inline int animateSpeed(Animates) const { return 33; }
-
- // Utility functions
- void drawColorlessButton(const HIRect &macRect, HIThemeButtonDrawInfo *bdi,
- QPainter *p, const QStyleOption *opt) const;
-
- QSize pushButtonSizeFromContents(const QStyleOptionButton *btn) const;
-
- HIRect pushButtonContentBounds(const QStyleOptionButton *btn,
- const HIThemeButtonDrawInfo *bdi) const;
-
- void initComboboxBdi(const QStyleOptionComboBox *combo, HIThemeButtonDrawInfo *bdi,
- const QWidget *widget, const ThemeDrawState &tds);
-
- static HIRect comboboxInnerBounds(const HIRect &outerBounds, int buttonKind);
-
- static QRect comboboxEditBounds(const QRect &outerBounds, const HIThemeButtonDrawInfo &bdi);
-
- static void drawCombobox(const HIRect &outerBounds, const HIThemeButtonDrawInfo &bdi, QPainter *p);
- static void drawTableHeader(const HIRect &outerBounds, bool drawTopBorder, bool drawLeftBorder,
- const HIThemeButtonDrawInfo &bdi, QPainter *p);
- bool contentFitsInPushButton(const QStyleOptionButton *btn, HIThemeButtonDrawInfo *bdi,
- ThemeButtonKind buttonKindToCheck) const;
- void initHIThemePushButton(const QStyleOptionButton *btn, const QWidget *widget,
- const ThemeDrawState tds,
- HIThemeButtonDrawInfo *bdi) const;
- QPixmap generateBackgroundPattern() const;
-protected:
- bool eventFilter(QObject *, QEvent *);
- void timerEvent(QTimerEvent *);
-
-private slots:
- void startAnimationTimer();
-
-public:
- QPointer<QPushButton> defaultButton; //default push buttons
- int timerID;
- QList<QPointer<QWidget> > progressBars; //existing progress bars that need animation
-
- struct ButtonState {
- int frame;
- enum { ButtonDark, ButtonLight } dir;
- } buttonState;
- UInt8 progressFrame;
- QPointer<QFocusFrame> focusWidget;
- CFAbsoluteTime defaultButtonStart;
- QMacStyle *q;
- bool mouseDown;
-};
-
-QT_END_NAMESPACE
-
-#endif // QMACSTYLE_MAC_P_H
diff --git a/src/gui/styles/qmotifstyle.cpp b/src/gui/styles/qmotifstyle.cpp
deleted file mode 100644
index 3bf8996650..0000000000
--- a/src/gui/styles/qmotifstyle.cpp
+++ /dev/null
@@ -1,2721 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmotifstyle.h"
-#include "qcdestyle.h"
-
-#if !defined(QT_NO_STYLE_MOTIF) || defined(QT_PLUGIN)
-
-#include "qmenu.h"
-#include "qapplication.h"
-#include "qpainter.h"
-#include "qdrawutil.h"
-#include "qpixmap.h"
-#include "qpalette.h"
-#include "qwidget.h"
-#include "qpushbutton.h"
-#include "qscrollbar.h"
-#include "qtabbar.h"
-#include "qtabwidget.h"
-#include "qlistview.h"
-#include "qsplitter.h"
-#include "qslider.h"
-#include "qcombobox.h"
-#include "qlineedit.h"
-#include "qprogressbar.h"
-#include "qimage.h"
-#include "qfocusframe.h"
-#include "qdebug.h"
-#include "qpainterpath.h"
-#include "qmotifstyle_p.h"
-#include "qdialogbuttonbox.h"
-#include "qformlayout.h"
-#include <limits.h>
-#include <QtGui/qgraphicsproxywidget.h>
-#include <QtGui/qgraphicsview.h>
-
-#ifdef Q_WS_X11
-#include "qx11info_x11.h"
-#endif
-
-QT_BEGIN_NAMESPACE
-
-// old constants that might still be useful...
-static const int motifItemFrame = 2; // menu item frame width
-static const int motifSepHeight = 2; // separator item height
-static const int motifItemHMargin = 3; // menu item hor text margin
-static const int motifItemVMargin = 2; // menu item ver text margin
-static const int motifArrowHMargin = 6; // arrow horizontal margin
-static const int motifTabSpacing = 12; // space between text and tab
-static const int motifCheckMarkHMargin = 2; // horiz. margins of check mark
-static const int motifCheckMarkSpace = 16;
-
-
-/*!
- \class QMotifStyle
- \brief The QMotifStyle class provides Motif look and feel.
-
- \ingroup appearance
-
- This class implements the Motif look and feel. It closely
- resembles the original Motif look as defined by the Open Group,
- but with some minor improvements. The Motif style is Qt's default
- GUI style on Unix platforms.
-
- \img qmotifstyle.png
- \sa QWindowsXPStyle, QMacStyle, QWindowsStyle, QPlastiqueStyle, QCDEStyle
-*/
-
-/*!
- \variable QMotifStyle::focus
- \internal
-*/
-
-/*!
- Constructs a QMotifStyle.
-
- If \a useHighlightCols is false (the default), the style will
- polish the application's color palette to emulate the Motif way of
- highlighting, which is a simple inversion between the base and the
- text color.
-*/
-QMotifStyle::QMotifStyle(bool useHighlightCols)
- : QCommonStyle(*new QMotifStylePrivate)
-{
- focus = 0;
- highlightCols = useHighlightCols;
-}
-
-
-/*!
- \internal
-*/
-QMotifStyle::QMotifStyle(QMotifStylePrivate &dd, bool useHighlightColors)
- : QCommonStyle(dd)
-{
- focus = 0;
- highlightCols = useHighlightColors;
-}
-
-
-/*!
- \overload
-
- Destroys the style.
-*/
-QMotifStyle::~QMotifStyle()
-{
- delete focus;
-}
-
-/*!
- \internal
- Animate indeterminate progress bars only when visible
-*/
-bool QMotifStyle::eventFilter(QObject *o, QEvent *e)
-{
-#ifndef QT_NO_PROGRESSBAR
- Q_D(QMotifStyle);
- switch(e->type()) {
- case QEvent::StyleChange:
- case QEvent::Show:
- if (QProgressBar *bar = qobject_cast<QProgressBar *>(o)) {
- d->bars << bar;
- if (d->bars.size() == 1) {
- Q_ASSERT(d->animationFps> 0);
- d->animateTimer = startTimer(1000 / d->animationFps);
- }
- }
- break;
- case QEvent::Destroy:
- case QEvent::Hide:
- // reinterpret_cast because there is no type info when getting
- // the destroy event. We know that it is a QProgressBar.
- if (QProgressBar *bar = reinterpret_cast<QProgressBar *>(o)) {
- d->bars.removeAll(bar);
- if (d->bars.isEmpty() && d->animateTimer) {
- killTimer(d->animateTimer);
- d->animateTimer = 0;
- }
- }
- default:
- break;
- }
-#endif // QT_NO_PROGRESSBAR
- return QStyle::eventFilter(o, e);
-}
-
-/*!
- \internal
-*/
-QIcon QMotifStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt,
- const QWidget *widget) const
-{
- return QCommonStyle::standardIconImplementation(standardIcon, opt, widget);
-}
-
-/*!
- \reimp
-*/
-void QMotifStyle::timerEvent(QTimerEvent *event)
-{
-#ifndef QT_NO_PROGRESSBAR
- Q_D(QMotifStyle);
- if (event->timerId() == d->animateTimer) {
- Q_ASSERT(d->animationFps > 0);
- d->animateStep = d->startTime.elapsed() / (1000 / d->animationFps);
- foreach (QProgressBar *bar, d->bars) {
- if ((bar->minimum() == 0 && bar->maximum() == 0))
- bar->update();
- }
- }
-#endif // QT_NO_PROGRESSBAR
- event->ignore();
-}
-
-
-QMotifStylePrivate::QMotifStylePrivate()
-#ifndef QT_NO_PROGRESSBAR
- : animationFps(25), animateTimer(0), animateStep(0)
-#endif
-{
-}
-
-/*!
- If \a arg is false, the style will polish the application's color
- palette to emulate the Motif way of highlighting, which is a
- simple inversion between the base and the text color.
-
- The effect will show up the next time an application palette is
- set via QApplication::setPalette(). The current color palette of
- the application remains unchanged.
-
- \sa QStyle::polish()
-*/
-void QMotifStyle::setUseHighlightColors(bool arg)
-{
- highlightCols = arg;
-}
-
-/*!
- Returns true if the style treats the highlight colors of the
- palette in a Motif-like manner, which is a simple inversion
- between the base and the text color; otherwise returns false. The
- default is false.
-*/
-bool QMotifStyle::useHighlightColors() const
-{
- return highlightCols;
-}
-
-/*! \reimp */
-
-void QMotifStyle::polish(QPalette& pal)
-{
- if (pal.brush(QPalette::Active, QPalette::Light) == pal.brush(QPalette::Active, QPalette::Base)) {
- QColor nlight = pal.color(QPalette::Active, QPalette::Light).darker(108);
- pal.setColor(QPalette::Active, QPalette::Light, nlight) ;
- pal.setColor(QPalette::Disabled, QPalette::Light, nlight) ;
- pal.setColor(QPalette::Inactive, QPalette::Light, nlight) ;
- }
-
- if (highlightCols)
- return;
-
- // force the ugly motif way of highlighting *sigh*
- pal.setColor(QPalette::Active, QPalette::Highlight,
- pal.color(QPalette::Active, QPalette::Text));
- pal.setColor(QPalette::Active, QPalette::HighlightedText,
- pal.color(QPalette::Active, QPalette::Base));
- pal.setColor(QPalette::Disabled, QPalette::Highlight,
- pal.color(QPalette::Disabled, QPalette::Text));
- pal.setColor(QPalette::Disabled, QPalette::HighlightedText,
- pal.color(QPalette::Disabled, QPalette::Base));
- pal.setColor(QPalette::Inactive, QPalette::Highlight,
- pal.color(QPalette::Active, QPalette::Text));
- pal.setColor(QPalette::Inactive, QPalette::HighlightedText,
- pal.color(QPalette::Active, QPalette::Base));
-}
-
-/*!
- \reimp
- \internal
- Keep QStyle::polish() visible.
-*/
-void QMotifStyle::polish(QWidget* widget)
-{
- QStyle::polish(widget);
-#ifndef QT_NO_PROGRESSBAR
- if (qobject_cast<QProgressBar *>(widget))
- widget->installEventFilter(this);
-#endif
-}
-
-/*!
- \reimp
- \internal
- Keep QStyle::polish() visible.
-*/
-void QMotifStyle::unpolish(QWidget* widget)
-{
- QCommonStyle::unpolish(widget);
-#ifndef QT_NO_PROGRESSBAR
- if (qobject_cast<QProgressBar *>(widget)) {
- Q_D(QMotifStyle);
- widget->removeEventFilter(this);
- d->bars.removeAll(static_cast<QProgressBar*>(widget));
- }
-#endif
-}
-
-
-/*!
- \reimp
- \internal
- Keep QStyle::polish() visible.
-*/
-void QMotifStyle::polish(QApplication* a)
-{
- QCommonStyle::polish(a);
-}
-
-
-/*!
- \reimp
- \internal
- Keep QStyle::polish() visible.
-*/
-void QMotifStyle::unpolish(QApplication* a)
-{
- QCommonStyle::unpolish(a);
-}
-
-static void rot(QPolygon& a, int n)
-{
- QPolygon r(a.size());
- for (int i = 0; i < (int)a.size(); i++) {
- switch (n) {
- case 1: r.setPoint(i,-a[i].y(),a[i].x()); break;
- case 2: r.setPoint(i,-a[i].x(),-a[i].y()); break;
- case 3: r.setPoint(i,a[i].y(),-a[i].x()); break;
- }
- }
- a = r;
-}
-
-
-/*!
- \reimp
-*/
-void QMotifStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
- const QWidget *w) const
-{
- switch(pe) {
- case PE_Q3CheckListExclusiveIndicator:
- if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) {
- if (lv->items.isEmpty())
- return;
-
- if (lv->state & State_Enabled)
- p->setPen(QPen(opt->palette.text().color()));
- else
- p->setPen(QPen(lv->palette.color(QPalette::Disabled, QPalette::Text)));
- QPolygon a;
-
- int cx = opt->rect.width()/2 - 1;
- int cy = opt->rect.height()/2;
- int e = opt->rect.width()/2 - 1;
- for (int i = 0; i < 3; i++) { //penWidth 2 doesn't quite work
- a.setPoints(4, cx-e, cy, cx, cy-e, cx+e, cy, cx, cy+e);
- p->drawPolygon(a);
- e--;
- }
- if (opt->state & State_On) {
- if (lv->state & State_Enabled)
- p->setPen(QPen(opt->palette.text().color()));
- else
- p->setPen(QPen(lv->palette.color(QPalette::Disabled,
- QPalette::Text)));
- QBrush saveBrush = p->brush();
- p->setBrush(opt->palette.text());
- e = e - 2;
- a.setPoints(4, cx-e, cy, cx, cy-e, cx+e, cy, cx, cy+e);
- p->drawPolygon(a);
- p->setBrush(saveBrush);
- }
- }
- break;
-
- case PE_FrameTabWidget:
- case PE_FrameWindow:
- qDrawShadePanel(p, opt->rect, opt->palette, QStyle::State_None, proxy()->pixelMetric(PM_DefaultFrameWidth));
- break;
- case PE_FrameFocusRect:
- if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(opt)) {
- if ((fropt->state & State_HasFocus) && focus && focus->isVisible()
- && !(fropt->state & QStyle::State_Item))
- break;
- QCommonStyle::drawPrimitive(pe, opt, p, w);
- }
- break;
-
- case PE_IndicatorToolBarHandle: {
- p->save();
- p->translate(opt->rect.x(), opt->rect.y());
-
- QColor dark(opt->palette.dark().color());
- QColor light(opt->palette.light().color());
- int i;
- if (opt->state & State_Horizontal) {
- int h = opt->rect.height();
- if (h > 6) {
- if (opt->state & State_On)
- p->fillRect(1, 1, 8, h - 2, opt->palette.highlight());
- QPolygon a(2 * ((h-6)/3));
- int y = 3 + (h%3)/2;
- p->setPen(dark);
- p->drawLine(8, 1, 8, h-2);
- for (i=0; 2*i < a.size(); ++i) {
- a.setPoint(2*i, 5, y+1+3*i);
- a.setPoint(2*i+1, 2, y+2+3*i);
- }
- p->drawPoints(a);
- p->setPen(light);
- p->drawLine(9, 1, 9, h-2);
- for (i=0; 2*i < a.size(); i++) {
- a.setPoint(2*i, 4, y+3*i);
- a.setPoint(2*i+1, 1, y+1+3*i);
- }
- p->drawPoints(a);
- // if (drawBorder) {
- // p->setPen(QPen(Qt::darkGray));
- // p->drawLine(0, opt->rect.height() - 1,
- // tbExtent, opt->rect.height() - 1);
- // }
- }
- } else {
- int w = opt->rect.width();
- if (w > 6) {
- if (opt->state & State_On)
- p->fillRect(1, 1, w - 2, 9, opt->palette.highlight());
- QPolygon a(2 * ((w-6)/3));
-
- int x = 3 + (w%3)/2;
- p->setPen(dark);
- p->drawLine(1, 8, w-2, 8);
- for (i=0; 2*i < a.size(); ++i) {
- a.setPoint(2*i, x+1+3*i, 6);
- a.setPoint(2*i+1, x+2+3*i, 3);
- }
- p->drawPoints(a);
- p->setPen(light);
- p->drawLine(1, 9, w-2, 9);
- for (i=0; 2*i < a.size(); ++i) {
- a.setPoint(2*i, x+3*i, 5);
- a.setPoint(2*i+1, x+1+3*i, 2);
- }
- p->drawPoints(a);
- // if (drawBorder) {
- // p->setPen(QPen(Qt::darkGray));
- // p->drawLine(opt->rect.width() - 1, 0,
- // opt->rect.width() - 1, tbExtent);
- // }
- }
- }
- p->restore();
- break; }
-
- case PE_PanelButtonCommand:
- case PE_PanelButtonBevel:
- case PE_PanelButtonTool: {
- QBrush fill;
- if (opt->state & State_Sunken)
- fill = opt->palette.brush(QPalette::Mid);
- else if ((opt->state & State_On) && (opt->state & State_Enabled))
- fill = QBrush(opt->palette.mid().color(), Qt::Dense4Pattern);
- else
- fill = opt->palette.brush(QPalette::Button);
- if ((opt->state & State_Enabled || opt->state & State_On) || !(opt->state & State_AutoRaise))
- qDrawShadePanel(p, opt->rect, opt->palette, bool(opt->state & (State_Sunken | State_On)),
- proxy()->pixelMetric(PM_DefaultFrameWidth), &fill);
- break; }
-
- case PE_IndicatorCheckBox: {
- bool on = opt->state & State_On;
- bool down = opt->state & State_Sunken;
- bool showUp = !(down ^ on);
- QBrush fill = opt->palette.brush((showUp || opt->state & State_NoChange) ?QPalette::Button : QPalette::Mid);
- if (opt->state & State_NoChange) {
- qDrawPlainRect(p, opt->rect, opt->palette.text().color(),
- 1, &fill);
- p->drawLine(opt->rect.x() + opt->rect.width() - 1, opt->rect.y(),
- opt->rect.x(), opt->rect.y() + opt->rect.height() - 1);
- } else {
- qDrawShadePanel(p, opt->rect, opt->palette, !showUp,
- proxy()->pixelMetric(PM_DefaultFrameWidth), &fill);
- }
- if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText))
- p->fillRect(opt->rect, QBrush(p->background().color(), Qt::Dense5Pattern));
- break; }
-
- case PE_IndicatorRadioButton: {
-#define INTARRLEN(x) sizeof(x)/(sizeof(int)*2)
- int inner_pts[] = { // used for filling diamond
- 2,opt->rect.height()/2,
- opt->rect.width()/2,2,
- opt->rect.width()-3,opt->rect.height()/2,
- opt->rect.width()/2,opt->rect.height()-3
- };
- int top_pts[] = { // top (^) of diamond
- 0,opt->rect.height()/2,
- opt->rect.width()/2,0,
- opt->rect.width()-2,opt->rect.height()/2-1,
- opt->rect.width()-3,opt->rect.height()/2-1,
- opt->rect.width()/2,1,
- 1,opt->rect.height()/2,
- 2,opt->rect.height()/2,
- opt->rect.width()/2,2,
- opt->rect.width()-4,opt->rect.height()/2-1
- };
- int bottom_pts[] = { // bottom (v) of diamond
- 1,opt->rect.height()/2+1,
- opt->rect.width()/2,opt->rect.height()-1,
- opt->rect.width()-1,opt->rect.height()/2,
- opt->rect.width()-2,opt->rect.height()/2,
- opt->rect.width()/2,opt->rect.height()-2,
- 2,opt->rect.height()/2+1,
- 3,opt->rect.height()/2+1,
- opt->rect.width()/2,opt->rect.height()-3,
- opt->rect.width()-3,opt->rect.height()/2
- };
- bool on = opt->state & State_On;
- bool down = opt->state & State_Sunken;
- bool showUp = !(down ^ on);
- QPen oldPen = p->pen();
- QBrush oldBrush = p->brush();
- QPolygon a(INTARRLEN(inner_pts), inner_pts);
- p->setPen(Qt::NoPen);
- p->setBrush(opt->palette.brush(showUp ? QPalette::Button : QPalette::Mid));
- a.translate(opt->rect.x(), opt->rect.y());
- p->drawPolygon(a);
- p->setPen(showUp ? opt->palette.light().color() : opt->palette.dark().color());
- p->setBrush(Qt::NoBrush);
- a.setPoints(INTARRLEN(top_pts), top_pts);
- a.translate(opt->rect.x(), opt->rect.y());
- p->drawPolyline(a);
- p->setPen(showUp ? opt->palette.dark().color() : opt->palette.light().color());
- a.setPoints(INTARRLEN(bottom_pts), bottom_pts);
- a.translate(opt->rect.x(), opt->rect.y());
- p->drawPolyline(a);
- if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText))
- p->fillRect(opt->rect, QBrush(p->background().color(), Qt::Dense5Pattern));
- p->setPen(oldPen);
- p->setBrush(oldBrush);
- break; }
-
- case PE_IndicatorSpinUp:
- case PE_IndicatorSpinPlus:
- case PE_IndicatorSpinDown:
- case PE_IndicatorSpinMinus:
- case PE_IndicatorArrowUp:
- case PE_IndicatorArrowDown:
- case PE_IndicatorArrowRight:
- case PE_IndicatorArrowLeft: {
- QRect rect = opt->rect;
- QPolygon bFill;
- QPolygon bTop;
- QPolygon bBot;
- QPolygon bLeft;
- if (pe == PE_IndicatorSpinPlus || pe == PE_IndicatorSpinUp)
- pe = PE_IndicatorArrowUp;
- else if (pe == PE_IndicatorSpinMinus || pe == PE_IndicatorSpinDown)
- pe = PE_IndicatorArrowDown;
- bool vertical = pe == PE_IndicatorArrowUp || pe == PE_IndicatorArrowDown;
- bool horizontal = !vertical;
- int dim = rect.width() < rect.height() ? rect.width() : rect.height();
- int colspec = 0x0000;
-
- if (!(opt->state & State_Enabled))
- dim -= 2;
- if(dim < 2)
- break;
-
- // adjust size and center (to fix rotation below)
- if (rect.width() > dim) {
- rect.setX(rect.x() + ((rect.width() - dim) / 2));
- rect.setWidth(dim);
- }
- if (rect.height() > dim) {
- rect.setY(rect.y() + ((rect.height() - dim) / 2));
- rect.setHeight(dim);
- }
-
- if (dim > 3) {
- if (pixelMetric(PM_DefaultFrameWidth) < 2) { // thin style
- bFill.resize( dim & 1 ? 3 : 4 );
- bTop.resize( 2 );
- bBot.resize( 2 );
- bLeft.resize( 2 );
- bLeft.putPoints( 0, 2, 0, 0, 0, dim-1 );
- bTop.putPoints( 0, 2, 1, 0, dim-1, dim/2 );
- bBot.putPoints( 0, 2, 1, dim-1, dim-1, dim/2 );
-
- if ( dim > 6 ) { // dim>6: must fill interior
- bFill.putPoints( 0, 2, 0, dim-1, 0, 0 );
- if ( dim & 1 ) // if size is an odd number
- bFill.setPoint( 2, dim - 1, dim / 2 );
- else
- bFill.putPoints( 2, 2, dim-1, dim/2-1, dim-1, dim/2 );
- }
- } else {
- if (dim > 6)
- bFill.resize(dim & 1 ? 3 : 4);
- bTop.resize((dim/2)*2);
- bBot.resize(dim & 1 ? dim + 1 : dim);
- bLeft.resize(dim > 4 ? 4 : 2);
- bLeft.putPoints(0, 2, 0,0, 0,dim-1);
- if (dim > 4)
- bLeft.putPoints(2, 2, 1,2, 1,dim-3);
- bTop.putPoints(0, 4, 1,0, 1,1, 2,1, 3,1);
- bBot.putPoints(0, 4, 1,dim-1, 1,dim-2, 2,dim-2, 3,dim-2);
-
- for(int i=0; i<dim/2-2 ; i++) {
- bTop.putPoints(i*2+4, 2, 2+i*2,2+i, 5+i*2, 2+i);
- bBot.putPoints(i*2+4, 2, 2+i*2,dim-3-i, 5+i*2,dim-3-i);
- }
- if (dim & 1) // odd number size: extra line
- bBot.putPoints(dim-1, 2, dim-3,dim/2, dim-1,dim/2);
- if (dim > 6) { // dim>6: must fill interior
- bFill.putPoints(0, 2, 1,dim-3, 1,2);
- if (dim & 1) // if size is an odd number
- bFill.setPoint(2, dim - 3, dim / 2);
- else
- bFill.putPoints(2, 2, dim-4,dim/2-1, dim-4,dim/2);
- }
- }
- } else {
- if (dim == 3) { // 3x3 arrow pattern
- bLeft.setPoints(4, 0,0, 0,2, 1,1, 1,1);
- bTop .setPoints(2, 1,0, 1,0);
- bBot .setPoints(2, 1,2, 2,1);
- }
- else { // 2x2 arrow pattern
- bLeft.setPoints(2, 0,0, 0,1);
- bTop .setPoints(2, 1,0, 1,0);
- bBot .setPoints(2, 1,1, 1,1);
- }
- }
-
- // We use rot() and translate() as it is more efficient that
- // matrix transformations on the painter, and because it still
- // works with QT_NO_TRANSFORMATIONS defined.
-
- if (pe == PE_IndicatorArrowUp || pe == PE_IndicatorArrowLeft) {
- if (vertical) {
- rot(bFill,3);
- rot(bLeft,3);
- rot(bTop,3);
- rot(bBot,3);
- bFill.translate(0, rect.height() - 1);
- bLeft.translate(0, rect.height() - 1);
- bTop.translate(0, rect.height() - 1);
- bBot.translate(0, rect.height() - 1);
- } else {
- rot(bFill,2);
- rot(bLeft,2);
- rot(bTop,2);
- rot(bBot,2);
- bFill.translate(rect.width() - 1, rect.height() - 1);
- bLeft.translate(rect.width() - 1, rect.height() - 1);
- bTop.translate(rect.width() - 1, rect.height() - 1);
- bBot.translate(rect.width() - 1, rect.height() - 1);
- }
- if (opt->state & State_Sunken)
- colspec = horizontal ? 0x2334 : 0x2343;
- else
- colspec = horizontal ? 0x1443 : 0x1434;
- } else {
- if (vertical) {
- rot(bFill,1);
- rot(bLeft,1);
- rot(bTop,1);
- rot(bBot,1);
- bFill.translate(rect.width() - 1, 0);
- bLeft.translate(rect.width() - 1, 0);
- bTop.translate(rect.width() - 1, 0);
- bBot.translate(rect.width() - 1, 0);
- }
- if (opt->state & State_Sunken)
- colspec = horizontal ? 0x2443 : 0x2434;
- else
- colspec = horizontal ? 0x1334 : 0x1343;
- }
- bFill.translate(rect.x(), rect.y());
- bLeft.translate(rect.x(), rect.y());
- bTop.translate(rect.x(), rect.y());
- bBot.translate(rect.x(), rect.y());
-
- const QColor *cols[5];
- if (opt->state & State_Enabled) {
- cols[0] = 0;
- cols[1] = &opt->palette.button().color();
- cols[2] = &opt->palette.mid().color();
- cols[3] = &opt->palette.light().color();
- cols[4] = &opt->palette.dark().color();
- } else {
- cols[0] = 0;
- cols[1] = &opt->palette.mid().color();
- cols[2] = &opt->palette.mid().color();
- cols[3] = &opt->palette.mid().color();
- cols[4] = &opt->palette.mid().color();
- }
-
-#define CMID *cols[(colspec>>12) & 0xf]
-#define CLEFT *cols[(colspec>>8) & 0xf]
-#define CTOP *cols[(colspec>>4) & 0xf]
-#define CBOT *cols[colspec & 0xf]
-
- QPen savePen = p->pen();
- QBrush saveBrush = p->brush();
- QPen pen(Qt::NoPen);
- QBrush brush = opt->palette.brush((opt->state & State_Enabled) ?
- QPalette::Button : QPalette::Mid);
- p->setPen(pen);
- p->setBrush(brush);
- p->drawPolygon(bFill);
- p->setBrush(Qt::NoBrush);
-
- p->setPen(CLEFT);
- p->drawPolyline(bLeft);
- p->setPen(CTOP);
- p->drawPolyline(bTop);
- p->setPen(CBOT);
- p->drawPolyline(bBot);
-
- p->setBrush(saveBrush);
- p->setPen(savePen);
-#undef CMID
-#undef CLEFT
-#undef CTOP
-#undef CBOT
- if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText))
- p->fillRect(opt->rect, QBrush(p->background().color(), Qt::Dense5Pattern));
- break; }
-
- case PE_IndicatorDockWidgetResizeHandle: {
- const int motifOffset = 10;
- int sw = proxy()->pixelMetric(PM_SplitterWidth);
- if (opt->state & State_Horizontal) {
- int yPos = opt->rect.y() + opt->rect.height() / 2;
- int kPos = opt->rect.right() - motifOffset - sw;
- int kSize = sw - 2;
-
- qDrawShadeLine(p, opt->rect.left(), yPos, kPos, yPos, opt->palette);
- qDrawShadePanel(p, kPos, yPos - sw / 2 + 1, kSize, kSize,
- opt->palette, false, 1, &opt->palette.brush(QPalette::Button));
- qDrawShadeLine(p, kPos + kSize - 1, yPos, opt->rect.right(), yPos, opt->palette);
- } else {
- int xPos = opt->rect.x() + opt->rect.width() / 2;
- int kPos = motifOffset;
- int kSize = sw - 2;
-
- qDrawShadeLine(p, xPos, opt->rect.top() + kPos + kSize - 1, xPos, opt->rect.bottom(), opt->palette);
- qDrawShadePanel(p, xPos - sw / 2 + 1, opt->rect.top() + kPos, kSize, kSize, opt->palette,
- false, 1, &opt->palette.brush(QPalette::Button));
- qDrawShadeLine(p, xPos, opt->rect.top(), xPos, opt->rect.top() + kPos, opt->palette);
- }
- break; }
-
- case PE_IndicatorMenuCheckMark: {
- const int markW = 6;
- const int markH = 6;
- int posX = opt->rect.x() + (opt->rect.width() - markW) / 2 - 1;
- int posY = opt->rect.y() + (opt->rect.height() - markH) / 2;
- int dfw = proxy()->pixelMetric(PM_DefaultFrameWidth);
-
- if (dfw < 2) {
- // Could do with some optimizing/caching...
- QPolygon a(7*2);
- int i, xx, yy;
- xx = posX;
- yy = 3 + posY;
- for (i=0; i<3; i++) {
- a.setPoint(2*i, xx, yy);
- a.setPoint(2*i+1, xx, yy+2);
- xx++; yy++;
- }
- yy -= 2;
- for (i=3; i<7; i++) {
- a.setPoint(2*i, xx, yy);
- a.setPoint(2*i+1, xx, yy+2);
- xx++; yy--;
- }
- if (! (opt->state & State_Enabled) && ! (opt->state & State_On)) {
- int pnt;
- p->setPen(opt->palette.highlightedText().color());
- QPoint offset(1,1);
- for (pnt = 0; pnt < (int)a.size(); pnt++)
- a[pnt] += offset;
- p->drawPolyline(a);
- for (pnt = 0; pnt < (int)a.size(); pnt++)
- a[pnt] -= offset;
- }
- p->setPen(opt->palette.text().color());
- p->drawPolyline(a);
-
- qDrawShadePanel(p, posX-2, posY-2, markW+4, markH+6, opt->palette, true, dfw);
- } else
- qDrawShadePanel(p, posX, posY, markW, markH, opt->palette, true, dfw,
- &opt->palette.brush(QPalette::Mid));
-
- break; }
-
- case PE_IndicatorProgressChunk:
- {
- bool vertical = false;
- if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt))
- vertical = (pb2->orientation == Qt::Vertical);
- if (!vertical) {
- p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width(),
- opt->rect.height(), opt->palette.brush(QPalette::Highlight));
- } else {
- p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width(), opt->rect.height(),
- opt->palette.brush(QPalette::Highlight));
- }
- }
- break;
-
- default:
- QCommonStyle::drawPrimitive(pe, opt, p, w);
- break;
- }
-}
-
-
-/*!
- \reimp
-*/
-void QMotifStyle::drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
- const QWidget *widget) const
-{
- switch(element) {
- case CE_Splitter: {
- QStyleOption handleOpt = *opt;
- if (handleOpt.state & State_Horizontal)
- handleOpt.state &= ~State_Horizontal;
- else
- handleOpt.state |= State_Horizontal;
- proxy()->drawPrimitive(PE_IndicatorDockWidgetResizeHandle, &handleOpt, p, widget);
- break; }
-
- case CE_ScrollBarSubLine:
- case CE_ScrollBarAddLine:{
- PrimitiveElement pe;
- if (element == CE_ScrollBarAddLine)
- pe = (opt->state & State_Horizontal) ? (opt->direction == Qt::LeftToRight ? PE_IndicatorArrowRight : PE_IndicatorArrowLeft) : PE_IndicatorArrowDown;
- else
- pe = (opt->state & State_Horizontal) ? (opt->direction == Qt::LeftToRight ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight) : PE_IndicatorArrowUp;
- QStyleOption arrowOpt = *opt;
- arrowOpt.state |= State_Enabled;
- proxy()->drawPrimitive(pe, &arrowOpt, p, widget);
- if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText)) {
- int fw = proxy()->pixelMetric(PM_DefaultFrameWidth);
- p->fillRect(opt->rect.adjusted(fw, fw, -fw, -fw), QBrush(p->background().color(), Qt::Dense5Pattern));
- }
- }break;
-
- case CE_ScrollBarSubPage:
- case CE_ScrollBarAddPage:
- p->fillRect(opt->rect, opt->palette.brush((opt->state & State_Enabled) ? QPalette::Mid : QPalette::Window));
- break;
-
- case CE_ScrollBarSlider: {
- QStyleOption bevelOpt = *opt;
- bevelOpt.state |= State_Raised;
- bevelOpt.state &= ~(State_Sunken | State_On);
- p->save();
- p->setBrushOrigin(bevelOpt.rect.topLeft());
- proxy()->drawPrimitive(PE_PanelButtonBevel, &bevelOpt, p, widget);
- p->restore();
- if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText))
- p->fillRect(opt->rect, QBrush(p->background().color(), Qt::Dense5Pattern));
- break; }
-
- case CE_RadioButton:
- case CE_CheckBox:
- if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
- bool isRadio = (element == CE_RadioButton);
- QStyleOptionButton subopt = *btn;
- subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator
- : SE_CheckBoxIndicator, btn, widget);
- proxy()->drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox,
- &subopt, p, widget);
- subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents
- : SE_CheckBoxContents, btn, widget);
- proxy()->drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, p, widget);
- if ((btn->state & State_HasFocus) && (!focus || !focus->isVisible())) {
- QStyleOptionFocusRect fropt;
- fropt.QStyleOption::operator=(*btn);
- fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect
- : SE_CheckBoxFocusRect, btn, widget);
- proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
- }
- }
- break;
- case CE_PushButton:
- if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
- proxy()->drawControl(CE_PushButtonBevel, btn, p, widget);
- QStyleOptionButton subopt = *btn;
- subopt.rect = subElementRect(SE_PushButtonContents, btn, widget);
- proxy()->drawControl(CE_PushButtonLabel, &subopt, p, widget);
- if ((btn->state & State_HasFocus) && (!focus || !focus->isVisible())) {
- QStyleOptionFocusRect fropt;
- fropt.QStyleOption::operator=(*btn);
- fropt.rect = subElementRect(SE_PushButtonFocusRect, btn, widget);
- proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
- }
- }
- break;
- case CE_PushButtonBevel:
- if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
- int diw, x1, y1, x2, y2;
- p->setPen(opt->palette.foreground().color());
- p->setBrush(QBrush(opt->palette.button().color(), Qt::NoBrush));
- diw = proxy()->pixelMetric(PM_ButtonDefaultIndicator);
- opt->rect.getCoords(&x1, &y1, &x2, &y2);
- if (btn->features & (QStyleOptionButton::AutoDefaultButton|QStyleOptionButton::DefaultButton)) {
- x1 += diw;
- y1 += diw;
- x2 -= diw;
- y2 -= diw;
- }
- if (btn->features & QStyleOptionButton::DefaultButton) {
- if (diw == 0) {
- QPolygon a;
- a.setPoints(9,
- x1, y1, x2, y1, x2, y2, x1, y2, x1, y1+1,
- x2-1, y1+1, x2-1, y2-1, x1+1, y2-1, x1+1, y1+1);
- p->setPen(opt->palette.shadow().color());
- p->drawPolygon(a);
- x1 += 2;
- y1 += 2;
- x2 -= 2;
- y2 -= 2;
- } else {
- qDrawShadePanel(p, opt->rect.adjusted(1, 1, -1, -1), opt->palette, true);
- }
- }
- if (!(btn->features & QStyleOptionButton::Flat) ||
- (btn->state & (State_Sunken | State_On))) {
- QStyleOptionButton newOpt = *btn;
- newOpt.rect = QRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
- p->setBrushOrigin(p->brushOrigin());
- proxy()->drawPrimitive(PE_PanelButtonCommand, &newOpt, p, widget);
- }
- if (btn->features & QStyleOptionButton::HasMenu) {
- int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, btn, widget);
- QRect ir = btn->rect;
- QStyleOptionButton newBtn = *btn;
- newBtn.rect = QRect(ir.right() - mbi - 3, ir.y() + 4, mbi, ir.height() - 8);
- proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget);
- }
- break;
- }
-
-#ifndef QT_NO_TABBAR
- case CE_TabBarTabShape:
- if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
- const int default_frame = proxy()->pixelMetric(PM_DefaultFrameWidth, tab, widget);
- const int frame_offset = (default_frame > 1) ? 1 : 0;
-
- if (tab->shape == QTabBar::RoundedNorth || tab->shape == QTabBar::RoundedEast ||
- tab->shape == QTabBar::RoundedSouth || tab->shape == QTabBar::RoundedWest) {
- p->save();
- QRect tabRect = opt->rect;
- QColor tabLight = opt->palette.light().color();
- QColor tabDark = opt->palette.dark().color();
-
- p->fillRect(opt->rect.adjusted(default_frame, default_frame,
- -default_frame, -default_frame),
- tab->palette.background());
-
- if(tab->shape == QTabBar::RoundedWest) {
- tabDark = opt->palette.light().color();
- tabLight = opt->palette.dark().color();
- tabRect = QRect(0, 0, tabRect.height(), tabRect.width());
- p->translate(opt->rect.left(), opt->rect.bottom());
- p->rotate(-90);
- } else if(tab->shape == QTabBar::RoundedSouth) {
- tabDark = opt->palette.light().color();
- tabLight = opt->palette.dark().color();
- tabRect = QRect(0, 0, tabRect.width(), tabRect.height());
- p->translate(opt->rect.right(), opt->rect.bottom());
- p->rotate(180);
- } else if(tab->shape == QTabBar::RoundedEast) {
- tabRect = QRect(0, 0, tabRect.height(), tabRect.width());
- p->translate(opt->rect.right(), opt->rect.top());
- p->rotate(90);
- }
-
- if (default_frame > 1) {
- p->setPen(tabLight);
- p->drawLine(tabRect.left(), tabRect.bottom(),
- tabRect.right(), tabRect.bottom());
- p->setPen(tabLight);
- p->drawLine(tabRect.left(), tabRect.bottom()-1,
- tabRect.right(), tabRect.bottom()-1);
- if (tabRect.left() == 0)
- p->drawPoint(tabRect.bottomLeft());
- } else {
- p->setPen(tabLight);
- p->drawLine(tabRect.left(), tabRect.bottom(),
- tabRect.right(), tabRect.bottom());
- }
-
- if (opt->state & State_Selected) {
- p->fillRect(QRect(tabRect.left()+1, tabRect.bottom()-frame_offset,
- tabRect.width()-3, 2),
- tab->palette.brush(QPalette::Active, QPalette::Background));
- p->setPen(tab->palette.background().color());
- p->drawLine(tabRect.left()+1, tabRect.bottom(),
- tabRect.left()+1, tabRect.top()+2);
- p->setPen(tabLight);
- } else {
- p->setPen(tabLight);
- }
- p->drawLine(tabRect.left(), tabRect.bottom()-1,
- tabRect.left(), tabRect.top() + 2);
- p->drawPoint(tabRect.left()+1, tabRect.top() + 1);
- p->drawLine(tabRect.left()+2, tabRect.top(),
- tabRect.right() - 2, tabRect.top());
- p->drawPoint(tabRect.left(), tabRect.bottom());
-
- if (default_frame > 1) {
- p->drawLine(tabRect.left()+1, tabRect.bottom(),
- tabRect.left()+1, tabRect.top() + 2);
- p->drawLine(tabRect.left()+2, tabRect.top()+1,
- tabRect.right() - 2, tabRect.top()+1);
- }
-
- p->setPen(tabDark);
- p->drawLine(tabRect.right() - 1, tabRect.top() + 2,
- tabRect.right() - 1, tabRect.bottom() - 1 +
- ((opt->state & State_Selected) ? frame_offset : -frame_offset));
- if (default_frame > 1) {
- p->drawPoint(tabRect.right() - 1, tabRect.top() + 1);
- p->drawLine(tabRect.right(), tabRect.top() + 2, tabRect.right(),
- tabRect.bottom() -
- ((opt->state & State_Selected) ?
- ((tab->position == QStyleOptionTab::End) ? 0:1):1+frame_offset));
- p->drawPoint(tabRect.right() - 1, tabRect.top() + 1);
- }
- p->restore();
- } else {
- QCommonStyle::drawControl(element, opt, p, widget);
- }
- break; }
-#endif // QT_NO_TABBAR
- case CE_ProgressBarGroove:
- qDrawShadePanel(p, opt->rect, opt->palette, true, 2);
- break;
-
- case CE_ProgressBarLabel:
- if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
- QTransform oldMatrix = p->transform();
- QRect rect = pb->rect;
- bool vertical = false;
- bool invert = false;
- bool bottomToTop = false;
- if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
- vertical = (pb2->orientation == Qt::Vertical);
- invert = pb2->invertedAppearance;
- bottomToTop = pb2->bottomToTop;
- }
- if (vertical) {
- QTransform m;
- rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height
- if (bottomToTop) {
- m.translate(0.0, rect.width());
- m.rotate(-90);
- } else {
- m.translate(rect.height(), 0.0);
- m.rotate(90);
- }
- p->setTransform(m, true);
- }
- const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, opt, widget);
- int u = rect.width() / unit_width;
- int p_v = pb->progress - pb->minimum;
- int t_s = qMax(0, pb->maximum - pb->minimum);
- if (u > 0 && pb->progress >= INT_MAX / u && t_s >= u) {
- // scale down to something usable.
- p_v /= u;
- t_s /= u;
- }
- if (pb->textVisible && t_s) {
- int nu = (u * p_v + t_s/2) / t_s;
- int x = unit_width * nu;
- QRect left(rect.x(), rect.y(), x, rect.height());
- QRect right(rect.x() + x, rect.y(), rect.width() - x, rect.height());
- Qt::LayoutDirection dir;
- dir = vertical ? (bottomToTop ? Qt::LeftToRight : Qt::RightToLeft) : pb->direction;
- if (invert)
- dir = (dir == Qt::LeftToRight) ? Qt::RightToLeft : Qt::LeftToRight;
- const QRect highlighted = visualRect(dir, rect, left);
- const QRect background = visualRect(dir, rect, right);
- p->setPen(opt->palette.highlightedText().color());
- p->setClipRect(highlighted);
- p->drawText(rect, Qt::AlignCenter | Qt::TextSingleLine, pb->text);
-
- if (pb->progress != pb->maximum) {
- p->setClipRect(background);
- p->setPen(opt->palette.highlight().color());
- p->drawText(rect, Qt::AlignCenter | Qt::TextSingleLine, pb->text);
- }
- }
- p->setTransform(oldMatrix, false);
- break;
- }
-
- case CE_MenuTearoff: {
- if(opt->state & State_Selected) {
- if(pixelMetric(PM_MenuPanelWidth, opt, widget) > 1)
- qDrawShadePanel(p, opt->rect.x(), opt->rect.y(), opt->rect.width(),
- opt->rect.height(), opt->palette, false, motifItemFrame,
- &opt->palette.brush(QPalette::Button));
- else
- qDrawShadePanel(p, opt->rect.x()+1, opt->rect.y()+1, opt->rect.width()-2,
- opt->rect.height()-2, opt->palette, true, 1, &opt->palette.brush(QPalette::Button));
- } else {
- p->fillRect(opt->rect, opt->palette.brush(QPalette::Button));
- }
- p->setPen(QPen(opt->palette.dark().color(), 1, Qt::DashLine));
- p->drawLine(opt->rect.x()+2, opt->rect.y()+opt->rect.height()/2-1, opt->rect.x()+opt->rect.width()-4,
- opt->rect.y()+opt->rect.height()/2-1);
- p->setPen(QPen(opt->palette.light().color(), 1, Qt::DashLine));
- p->drawLine(opt->rect.x()+2, opt->rect.y()+opt->rect.height()/2, opt->rect.x()+opt->rect.width()-4,
- opt->rect.y()+opt->rect.height()/2);
- break; }
-
- case CE_MenuItem:
- if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
- int maxpmw = menuitem->maxIconWidth;
- if(menuitem->menuHasCheckableItems)
- maxpmw = qMax(maxpmw, motifCheckMarkSpace);
-
- int x, y, w, h;
- opt->rect.getRect(&x, &y, &w, &h);
-
- if (menuitem->menuItemType == QStyleOptionMenuItem::Separator) { // draw separator
- int textWidth = 0;
- if (!menuitem->text.isEmpty()) {
- QFont oldFont = p->font();
- p->setFont(menuitem->font);
- p->fillRect(x, y, w, h, opt->palette.brush(QPalette::Button));
- proxy()->drawItemText(p, menuitem->rect.adjusted(10, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter,
- menuitem->palette, menuitem->state & State_Enabled, menuitem->text,
- QPalette::Text);
- textWidth = menuitem->fontMetrics.width(menuitem->text) + 10;
- y += menuitem->fontMetrics.height() / 2;
- p->setFont(oldFont);
- }
- p->setPen(opt->palette.dark().color());
- p->drawLine(x, y, x + 5, y);
- p->drawLine(x + 5 + textWidth, y, x+w, y);
- p->setPen(opt->palette.light().color());
- p->drawLine(x, y + 1, x + 5, y + 1);
- p->drawLine(x + 5 + textWidth, y + 1, x+w, y + 1);
- return;
- }
-
- int pw = motifItemFrame;
- if((opt->state & State_Selected) && (opt->state & State_Enabled)) { // active item frame
- if(pixelMetric(PM_MenuPanelWidth, opt) > 1)
- qDrawShadePanel(p, x, y, w, h, opt->palette, false, pw,
- &opt->palette.brush(QPalette::Button));
- else
- qDrawShadePanel(p, x+1, y+1, w-2, h-2, opt->palette, true, 1,
- &opt->palette.brush(QPalette::Button));
- } else { // incognito frame
- p->fillRect(x, y, w, h, opt->palette.brush(QPalette::Button));
- }
-
- QRect vrect = visualRect(opt->direction, opt->rect,
- QRect(x+motifItemFrame, y+motifItemFrame, maxpmw,
- h-2*motifItemFrame));
- int xvis = vrect.x();
- if (menuitem->checked) {
- if(!menuitem->icon.isNull())
- qDrawShadePanel(p, xvis, y+motifItemFrame, maxpmw, h-2*motifItemFrame,
- opt->palette, true, 1, &opt->palette.brush(QPalette::Midlight));
- } else if (!(opt->state & State_Selected)) {
- p->fillRect(xvis, y+motifItemFrame, maxpmw, h-2*motifItemFrame,
- opt->palette.brush(QPalette::Button));
- }
-
- if(!menuitem->icon.isNull()) { // draw icon
- QIcon::Mode mode = QIcon::Normal; // no disabled icons in Motif
- if ((opt->state & State_Selected) && !!(opt->state & State_Enabled))
- mode = QIcon::Active;
- QPixmap pixmap;
- if (menuitem->checkType != QStyleOptionMenuItem::NotCheckable && menuitem->checked)
- pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize, opt, widget), mode, QIcon::On);
- else
- pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize, opt, widget), mode);
-
- int pixw = pixmap.width();
- int pixh = pixmap.height();
- QRect pmr(0, 0, pixw, pixh);
- pmr.moveCenter(vrect.center());
- p->setPen(opt->palette.text().color());
- p->drawPixmap(pmr.topLeft(), pixmap);
-
- } else if (menuitem->checkType != QStyleOptionMenuItem::NotCheckable) { // just "checking"...
- int mh = h - 2*motifItemFrame;
-
- QStyleOptionButton newMenuItem;
- newMenuItem.state = menuitem->checked ? State_On : State_None;
- if (opt->state & State_Enabled) {
- newMenuItem.state |= State_Enabled;
- if (menuitem->state & State_Sunken)
- newMenuItem.state |= State_Sunken;
- }
- if (menuitem->checkType & QStyleOptionMenuItem::Exclusive) {
- newMenuItem.rect.setRect(xvis + 2, y + motifItemFrame + mh / 4, 11, 11);
- proxy()->drawPrimitive(PE_IndicatorRadioButton, &newMenuItem, p, widget);
- } else {
- newMenuItem.rect.setRect(xvis + 5, y + motifItemFrame + mh / 4, 9, 9);
- proxy()->drawPrimitive(PE_IndicatorCheckBox, &newMenuItem, p, widget);
- }
- }
-
- p->setPen(opt->palette.buttonText().color());
-
- QColor discol;
- if (!(opt->state & State_Enabled)) {
- discol = opt->palette.text().color();
- p->setPen(discol);
- }
-
- int xm = motifItemFrame + maxpmw + motifItemHMargin;
-
- vrect = visualRect(opt->direction, opt->rect,
- QRect(x+xm, y+motifItemVMargin, w-xm-menuitem->tabWidth,
- h-2*motifItemVMargin));
- xvis = vrect.x();
-
- QString s = menuitem->text;
- if (!s.isNull()) { // draw text
- int t = s.indexOf(QLatin1Char('\t'));
- int m = motifItemVMargin;
- int text_flags = Qt::AlignVCenter|Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
- text_flags |= Qt::AlignLeft;
- QFont oldFont = p->font();
- p->setFont(menuitem->font);
- if (t >= 0) { // draw tab text
- QRect vr = visualRect(opt->direction, opt->rect,
- QRect(x+w-menuitem->tabWidth-motifItemHMargin-motifItemFrame,
- y+motifItemVMargin, menuitem->tabWidth,
- h-2*motifItemVMargin));
- int xv = vr.x();
- QRect tr(xv, y+m, menuitem->tabWidth, h-2*m);
- p->drawText(tr, text_flags, s.mid(t+1));
- if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText))
- p->fillRect(tr, QBrush(p->background().color(), Qt::Dense5Pattern));
- s = s.left(t);
- }
- QRect tr(xvis, y+m, w - xm - menuitem->tabWidth + 1, h-2*m);
- p->drawText(tr, text_flags, s.left(t));
- p->setFont(oldFont);
- if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText))
- p->fillRect(tr, QBrush(p->background().color(), Qt::Dense5Pattern));
- }
- if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) { // draw sub menu arrow
- int dim = (h-2*motifItemFrame) / 2;
- QStyle::PrimitiveElement arrow = (opt->direction == Qt::RightToLeft ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight);
- QStyleOption arrowOpt = *opt;
- arrowOpt.rect = visualRect(opt->direction, opt->rect,
- QRect(x+w - motifArrowHMargin - motifItemFrame - dim,
- y+h/2-dim/2, dim, dim));
- if ((opt->state & State_Selected))
- arrowOpt.state = (State_Sunken | ((opt->state & State_Enabled) ? State_Enabled : State_None));
- else
- arrowOpt.state = ((opt->state & State_Enabled) ? State_Enabled : State_None);
- proxy()->drawPrimitive(arrow, &arrowOpt, p, widget);
- }
- break; }
-
- case CE_MenuBarItem:
- if (opt->state & State_Selected) // active item
- qDrawShadePanel(p, opt->rect, opt->palette, false, motifItemFrame,
- &opt->palette.brush(QPalette::Button));
- else // other item
- p->fillRect(opt->rect, opt->palette.brush(QPalette::Button));
- QCommonStyle::drawControl(element, opt, p, widget);
- break;
-
- case CE_HeaderSection:
- p->save();
- p->setBrushOrigin(opt->rect.topLeft());
- qDrawShadePanel(p, opt->rect, opt->palette, bool(opt->state & (State_Sunken|State_On)),
- proxy()->pixelMetric(PM_DefaultFrameWidth),
- &opt->palette.brush((opt->state & State_Sunken) ? QPalette::Mid : QPalette::Button));
- p->restore();
- break;
- case CE_RubberBand: {
- QPixmap tiledPixmap(16, 16);
- QPainter pixmapPainter(&tiledPixmap);
- pixmapPainter.setPen(Qt::NoPen);
- pixmapPainter.setBrush(Qt::Dense4Pattern);
- pixmapPainter.setBackground(QBrush(opt->palette.base()));
- pixmapPainter.setBackgroundMode(Qt::OpaqueMode);
- pixmapPainter.drawRect(0, 0, tiledPixmap.width(), tiledPixmap.height());
- pixmapPainter.end();
- // ### workaround for borked XRENDER
- tiledPixmap = QPixmap::fromImage(tiledPixmap.toImage());
-
- p->save();
- QRect r = opt->rect;
- QStyleHintReturnMask mask;
- if (styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask))
- p->setClipRegion(mask.region);
- p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap);
- p->restore();
- }
- break;
-#ifndef QT_NO_PROGRESSBAR
- case CE_ProgressBarContents:
- if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
- QRect rect = pb->rect;
- bool vertical = false;
- bool inverted = false;
-
- // Get extra style options if version 2
- const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt);
- if (pb2) {
- vertical = (pb2->orientation == Qt::Vertical);
- inverted = pb2->invertedAppearance;
- }
-
- QTransform m;
- if (vertical) {
- rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height
- m.rotate(90);
- m.translate(0, -(rect.height() + rect.y()*2));
- }
-
- QPalette pal2 = pb->palette;
- // Correct the highlight color if it is the same as the background
- if (pal2.highlight() == pal2.background())
- pal2.setColor(QPalette::Highlight, pb->palette.color(QPalette::Active,
- QPalette::Highlight));
- bool reverse = ((!vertical && (pb->direction == Qt::RightToLeft)) || vertical);
- if (inverted)
- reverse = !reverse;
- int w = rect.width();
- if (pb->minimum == 0 && pb->maximum == 0) {
- QRect progressBar;
- Q_D(const QMotifStyle);
- // draw busy indicator
- int x = (d->animateStep*8)% (w * 2);
- if (x > w)
- x = 2 * w - x;
- x = reverse ? rect.right() - x : x + rect.x();
- p->setTransform(m, true);
- p->setPen(QPen(pal2.highlight().color(), 4));
- p->drawLine(x, rect.y(), x, rect.height());
-
- } else
- QCommonStyle::drawControl(element, opt, p, widget);
- }
- break;
-#endif // QT_NO_PROGRESSBAR
- default:
- QCommonStyle::drawControl(element, opt, p, widget);
- break; }
-}
-
-static int get_combo_extra_width(int h, int w, int *return_awh=0)
-{
- int awh,
- tmp;
- if (h < 8) {
- awh = 6;
- } else if (h < 14) {
- awh = h - 2;
- } else {
- awh = h/2;
- }
- tmp = (awh * 3) / 2;
- if (tmp > w / 2) {
- awh = w / 2 - 3;
- tmp = w / 2 + 3;
- }
-
- if (return_awh)
- *return_awh = awh;
-
- return tmp;
-}
-
-static void get_combo_parameters(const QRect &r,
- int &ew, int &awh, int &ax,
- int &ay, int &sh, int &dh,
- int &sy)
-{
- ew = get_combo_extra_width(r.height(), r.width(), &awh);
-
- sh = (awh+3)/4;
- if (sh < 3)
- sh = 3;
- dh = sh/2 + 1;
-
- ay = r.y() + (r.height()-awh-sh-dh)/2;
- if (ay < 0) {
- //panic mode
- ay = 0;
- sy = r.height();
- } else {
- sy = ay+awh+dh;
- }
- ax = r.x() + r.width() - ew;
- ax += (ew-awh)/2;
-}
-
-/*!
- \reimp
-*/
-void QMotifStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
- const QWidget *widget) const
-{
- switch (cc) {
- case CC_ToolButton:
- if (const QStyleOptionToolButton *toolbutton
- = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
- QRect button, menuarea;
- button = proxy()->subControlRect(cc, toolbutton, SC_ToolButton, widget);
- menuarea = proxy()->subControlRect(cc, toolbutton, SC_ToolButtonMenu, widget);
-
- State bflags = toolbutton->state & ~State_Sunken;
- if (bflags & State_AutoRaise) {
- if (!(bflags & State_MouseOver) || !(bflags & State_Enabled)) {
- bflags &= ~State_Raised;
- }
- }
- State mflags = bflags;
- if (toolbutton->state & State_Sunken) {
- if (toolbutton->activeSubControls & SC_ToolButton)
- bflags |= State_Sunken;
- mflags |= State_Sunken;
- }
-
- QStyleOption tool(0);
- tool.palette = toolbutton->palette;
- if (toolbutton->subControls & SC_ToolButton) {
- if (bflags & (State_Sunken | State_On | State_Raised)) {
- tool.rect = button;
- tool.state = bflags;
- proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget);
- }
- }
-
- if ((toolbutton->state & State_HasFocus) && (!focus || !focus->isVisible())) {
- QStyleOptionFocusRect fr;
- fr.QStyleOption::operator=(*toolbutton);
- fr.rect = toolbutton->rect.adjusted(3, 3, -3, -3);
- proxy()->drawPrimitive(PE_FrameFocusRect, &fr, p, widget);
- }
- QStyleOptionToolButton label = *toolbutton;
- label.state = bflags;
- int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget);
- label.rect = button.adjusted(fw, fw, -fw, -fw);
- proxy()->drawControl(CE_ToolButtonLabel, &label, p, widget);
-
- if (toolbutton->subControls & SC_ToolButtonMenu) {
- tool.rect = menuarea;
- tool.state = mflags;
- if (mflags & (State_Sunken | State_On | State_Raised))
- proxy()->drawPrimitive(PE_IndicatorButtonDropDown, &tool, p, widget);
- proxy()->drawPrimitive(PE_IndicatorArrowDown, &tool, p, widget);
- } else if (toolbutton->features & QStyleOptionToolButton::HasMenu) {
- int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, toolbutton, widget);
- QRect ir = toolbutton->rect;
- QStyleOptionToolButton newBtn = *toolbutton;
- newBtn.rect = QRect(ir.right() + 5 - mbi, ir.height() - mbi + 4, mbi - 6, mbi - 6);
- proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget);
- }
- }
- break;
-#ifndef QT_NO_SPINBOX
- case CC_SpinBox:
- if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
- QStyleOptionSpinBox copy = *spinbox;
- PrimitiveElement pe;
-
- if (spinbox->frame && (spinbox->subControls & SC_SpinBoxFrame)) {
- QRect r = proxy()->subControlRect(CC_SpinBox, spinbox, SC_SpinBoxFrame, widget);
- qDrawShadePanel(p, r, opt->palette, false, proxy()->pixelMetric(PM_SpinBoxFrameWidth));
-
- int fw = proxy()->pixelMetric(QStyle::PM_DefaultFrameWidth);
- r = proxy()->subControlRect(CC_SpinBox, spinbox, SC_SpinBoxEditField, widget).adjusted(-fw,-fw,fw,fw);
- QStyleOptionFrame lineOpt;
- lineOpt.QStyleOption::operator=(*opt);
- lineOpt.rect = r;
- lineOpt.lineWidth = fw;
- lineOpt.midLineWidth = 0;
- lineOpt.state |= QStyle::State_Sunken;
- proxy()->drawPrimitive(QStyle::PE_FrameLineEdit, &lineOpt, p, widget);
- }
-
- if (spinbox->subControls & SC_SpinBoxUp) {
- copy.subControls = SC_SpinBoxUp;
- QPalette pal2 = spinbox->palette;
- if (!(spinbox->stepEnabled & QAbstractSpinBox::StepUpEnabled)) {
- pal2.setCurrentColorGroup(QPalette::Disabled);
- copy.state &= ~State_Enabled;
- }
-
- copy.palette = pal2;
-
- if (spinbox->activeSubControls == SC_SpinBoxUp && (spinbox->state & State_Sunken)) {
- copy.state |= State_On;
- copy.state |= State_Sunken;
- } else {
- copy.state |= State_Raised;
- copy.state &= ~State_Sunken;
- }
- pe = (spinbox->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus
- : PE_IndicatorSpinUp);
-
- copy.rect = proxy()->subControlRect(CC_SpinBox, spinbox, SC_SpinBoxUp, widget);
- proxy()->drawPrimitive(pe, &copy, p, widget);
- }
-
- if (spinbox->subControls & SC_SpinBoxDown) {
- copy.subControls = SC_SpinBoxDown;
- copy.state = spinbox->state;
- QPalette pal2 = spinbox->palette;
- if (!(spinbox->stepEnabled & QAbstractSpinBox::StepDownEnabled)) {
- pal2.setCurrentColorGroup(QPalette::Disabled);
- copy.state &= ~State_Enabled;
- }
- copy.palette = pal2;
-
- if (spinbox->activeSubControls == SC_SpinBoxDown && (spinbox->state & State_Sunken)) {
- copy.state |= State_On;
- copy.state |= State_Sunken;
- } else {
- copy.state |= State_Raised;
- copy.state &= ~State_Sunken;
- }
- pe = (spinbox->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus
- : PE_IndicatorSpinDown);
-
- copy.rect = proxy()->subControlRect(CC_SpinBox, spinbox, SC_SpinBoxDown, widget);
- proxy()->drawPrimitive(pe, &copy, p, widget);
- }
- }
- break;
-#endif // QT_NO_SPINBOX
-#ifndef QT_NO_SLIDER
- case CC_Slider:
- if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
- QRect groove = proxy()->subControlRect(CC_Slider, opt, SC_SliderGroove, widget),
- handle = proxy()->subControlRect(CC_Slider, opt, SC_SliderHandle, widget);
-
- if ((opt->subControls & SC_SliderGroove) && groove.isValid()) {
- qDrawShadePanel(p, groove, opt->palette, true, proxy()->pixelMetric(PM_DefaultFrameWidth),
- &opt->palette.brush((opt->state & State_Enabled) ? QPalette::Mid : QPalette::Window));
- if ((opt->state & State_HasFocus) && (!focus || !focus->isVisible())) {
- QStyleOption focusOpt = *opt;
- focusOpt.rect = subElementRect(SE_SliderFocusRect, opt, widget);
- proxy()->drawPrimitive(PE_FrameFocusRect, &focusOpt, p, widget);
- }
- }
-
- if ((opt->subControls & SC_SliderHandle) && handle.isValid()) {
- QStyleOption bevelOpt = *opt;
- bevelOpt.state = (opt->state | State_Raised) & ~State_Sunken;
- bevelOpt.rect = handle;
- p->save();
- p->setBrushOrigin(bevelOpt.rect.topLeft());
- proxy()->drawPrimitive(PE_PanelButtonBevel, &bevelOpt, p, widget);
- p->restore();
-
- if (slider->orientation == Qt::Horizontal) {
- int mid = handle.x() + handle.width() / 2;
- qDrawShadeLine(p, mid, handle.y(), mid, handle.y() + handle.height() - 2,
- opt->palette, true, 1);
- } else {
- int mid = handle.y() + handle.height() / 2;
- qDrawShadeLine(p, handle.x(), mid, handle.x() + handle.width() - 2, mid, opt->palette,
- true, 1);
- }
- if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText))
- p->fillRect(handle, QBrush(p->background().color(), Qt::Dense5Pattern));
- }
-
- if (slider->subControls & SC_SliderTickmarks) {
- QStyleOptionSlider tmpSlider = *slider;
- tmpSlider.subControls = SC_SliderTickmarks;
- int frameWidth = proxy()->pixelMetric(PM_DefaultFrameWidth);
- tmpSlider.rect.translate(frameWidth - 1, 0);
- QCommonStyle::drawComplexControl(cc, &tmpSlider, p, widget);
- }
- }
- break;
-#endif // QT_NO_SLIDER
- case CC_ComboBox:
- if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
- if (opt->subControls & SC_ComboBoxArrow) {
- int awh, ax, ay, sh, sy, dh, ew;
- int fw = cb->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth, opt, widget) : 0;
-
- if (cb->frame) {
- QStyleOptionButton btn;
- btn.QStyleOption::operator=(*cb);
- btn.state |= QStyle::State_Raised;
- proxy()->drawPrimitive(PE_PanelButtonCommand, &btn, p, widget);
- } else {
- p->fillRect(opt->rect, opt->palette.brush(QPalette::Button));
- }
-
- QRect tr = opt->rect;
- tr.adjust(fw, fw, -fw, -fw);
- get_combo_parameters(tr, ew, awh, ax, ay, sh, dh, sy);
-
- QRect ar = QStyle::visualRect(opt->direction, opt->rect, QRect(ax,ay,awh,awh));
-
- QStyleOption arrowOpt = *opt;
- arrowOpt.rect = ar;
- arrowOpt.state |= State_Enabled;
- proxy()->drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget);
-
-
- // draws the shaded line under the arrow
- p->setPen(opt->palette.light().color());
- p->drawLine(ar.x(), sy, ar.x()+awh-1, sy);
- p->drawLine(ar.x(), sy, ar.x(), sy+sh-1);
- p->setPen(opt->palette.dark().color());
- p->drawLine(ar.x()+1, sy+sh-1, ar.x()+awh-1, sy+sh-1);
- p->drawLine(ar.x()+awh-1, sy+1, ar.x()+awh-1, sy+sh-1);
-
- if ((cb->state & State_HasFocus) && (!focus || !focus->isVisible())) {
- QStyleOptionFocusRect focus;
- focus.QStyleOption::operator=(*opt);
- focus.rect = subElementRect(SE_ComboBoxFocusRect, opt, widget);
- focus.backgroundColor = opt->palette.button().color();
- proxy()->drawPrimitive(PE_FrameFocusRect, &focus, p, widget);
- }
- }
-
- if (opt->subControls & SC_ComboBoxEditField) {
- if (cb->editable) {
- QRect er = proxy()->subControlRect(CC_ComboBox, opt, SC_ComboBoxEditField, widget);
- er.adjust(-1, -1, 1, 1);
- qDrawShadePanel(p, er, opt->palette, true, 1,
- &opt->palette.brush(QPalette::Base));
- }
- }
- p->setPen(opt->palette.buttonText().color());
- }
- break;
-
-#ifndef QT_NO_SCROLLBAR
- case CC_ScrollBar: {
- if (opt->subControls & SC_ScrollBarGroove)
- qDrawShadePanel(p, opt->rect, opt->palette, true,
- proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget),
- &opt->palette.brush((opt->state & State_Enabled) ? QPalette::Mid : QPalette::Window));
-
- if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
- QStyleOptionSlider newScrollbar = *scrollbar;
- if (scrollbar->minimum == scrollbar->maximum)
- newScrollbar.state |= State_Enabled; // make sure that the slider is drawn.
- QCommonStyle::drawComplexControl(cc, &newScrollbar, p, widget);
- }
- break; }
-#endif
-
- case CC_Q3ListView:
- if (opt->subControls & (SC_Q3ListViewBranch | SC_Q3ListViewExpand)) {
- int i;
- if (opt->subControls & SC_Q3ListView)
- QCommonStyle::drawComplexControl(cc, opt, p, widget);
- if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) {
- QStyleOptionQ3ListViewItem item = lv->items.at(0);
- int y = opt->rect.y();
- int c;
- QPolygon dotlines;
- if ((opt->activeSubControls & SC_All) && (opt->subControls & SC_Q3ListViewExpand)) {
- c = 2;
- dotlines.resize(2);
- dotlines[0] = QPoint(opt->rect.right(), opt->rect.top());
- dotlines[1] = QPoint(opt->rect.right(), opt->rect.bottom());
- } else {
- int linetop = 0, linebot = 0;
- // each branch needs at most two lines, ie. four end points
- dotlines.resize(item.childCount * 4);
- c = 0;
-
- // skip the stuff above the exposed rectangle
- for (i = 1; i < lv->items.size(); ++i) {
- QStyleOptionQ3ListViewItem child = lv->items.at(i);
- if (child.height + y > 0)
- break;
- y += child.totalHeight;
- }
-
- int bx = opt->rect.width() / 2;
-
- // paint stuff in the magical area
- while (i < lv->items.size() && y < lv->rect.height()) {
- QStyleOptionQ3ListViewItem child = lv->items.at(i);
- if (child.features & QStyleOptionQ3ListViewItem::Visible) {
- int lh;
- if (!(item.features & QStyleOptionQ3ListViewItem::MultiLine))
- lh = child.height;
- else
- lh = p->fontMetrics().height() + 2 * lv->itemMargin;
- lh = qMax(lh, QApplication::globalStrut().height());
- if (lh % 2 > 0)
- lh++;
- linebot = y + lh/2;
- if ((child.features & QStyleOptionQ3ListViewItem::Expandable || child.childCount > 0) &&
- child.height > 0) {
- // needs a box
- p->setPen(opt->palette.text().color());
- p->drawRect(bx-4, linebot-4, 9, 9);
- QPolygon a;
- if ((child.state & State_Open))
- a.setPoints(3, bx-2, linebot-2,
- bx, linebot+2,
- bx+2, linebot-2); //Qt::RightArrow
- else
- a.setPoints(3, bx-2, linebot-2,
- bx+2, linebot,
- bx-2, linebot+2); //Qt::DownArrow
- p->setBrush(opt->palette.text());
- p->drawPolygon(a);
- p->setBrush(Qt::NoBrush);
- // dotlinery
- dotlines[c++] = QPoint(bx, linetop);
- dotlines[c++] = QPoint(bx, linebot - 5);
- dotlines[c++] = QPoint(bx + 5, linebot);
- dotlines[c++] = QPoint(opt->rect.width(), linebot);
- linetop = linebot + 5;
- } else {
- // just dotlinery
- dotlines[c++] = QPoint(bx+1, linebot);
- dotlines[c++] = QPoint(opt->rect.width(), linebot);
- }
- y += child.totalHeight;
- }
- ++i;
- }
-
- // Expand line height to edge of rectangle if there's any
- // visible child below
- while (i < lv->items.size() && lv->items.at(i).height <= 0)
- ++i;
- if (i < lv->items.size())
- linebot = opt->rect.height();
-
- if (linetop < linebot) {
- dotlines[c++] = QPoint(bx, linetop);
- dotlines[c++] = QPoint(bx, linebot);
- }
- }
-
- int line; // index into dotlines
- p->setPen(opt->palette.text().color());
- if (opt->subControls & SC_Q3ListViewBranch) for(line = 0; line < c; line += 2) {
- p->drawLine(dotlines[line].x(), dotlines[line].y(),
- dotlines[line+1].x(), dotlines[line+1].y());
- }
- }
- break; }
-
- default:
- QCommonStyle::drawComplexControl(cc, opt, p, widget);
- break;
- }
-}
-
-
-/*! \reimp */
-int QMotifStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt,
- const QWidget *widget) const
-{
- int ret = 0;
-
- switch(pm) {
- case PM_ButtonDefaultIndicator:
- ret = 5;
- break;
-
- case PM_CheckBoxLabelSpacing:
- case PM_RadioButtonLabelSpacing:
- ret = 10;
- break;
-
- case PM_ToolBarFrameWidth:
- ret = proxy()->pixelMetric(PM_DefaultFrameWidth);
- break;
-
- case PM_ToolBarItemMargin:
- ret = 1;
- break;
-
- case PM_ButtonShiftHorizontal:
- case PM_ButtonShiftVertical:
- ret = 0;
- break;
-
- case PM_SplitterWidth:
- ret = qMax(10, QApplication::globalStrut().width());
- break;
-
- case PM_SliderLength:
- ret = 30;
- break;
-
- case PM_SliderThickness:
- ret = 16 + 4 * proxy()->pixelMetric(PM_DefaultFrameWidth);
- break;
-#ifndef QT_NO_SLIDER
- case PM_SliderControlThickness:
- if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
- int space = (sl->orientation == Qt::Horizontal) ? sl->rect.height() : sl->rect.width();
- int ticks = sl->tickPosition;
- int n = 0;
- if (ticks & QSlider::TicksAbove)
- n++;
- if (ticks & QSlider::TicksBelow)
- n++;
- if (!n) {
- ret = space;
- break;
- }
-
- int thick = 6; // Magic constant to get 5 + 16 + 5
-
- space -= thick;
- //### the two sides may be unequal in size
- if (space > 0)
- thick += (space * 2) / (n + 2);
- ret = thick;
- }
- break;
-
- case PM_SliderSpaceAvailable:
- if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
- if (sl->orientation == Qt::Horizontal)
- ret = sl->rect.width() - proxy()->pixelMetric(PM_SliderLength, opt, widget) - 2 * proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget);
- else
- ret = sl->rect.height() - proxy()->pixelMetric(PM_SliderLength, opt, widget) - 2 * proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget);
- }
- break;
-#endif // QT_NO_SLIDER
- case PM_DockWidgetFrameWidth:
- ret = 2;
- break;
-
- case PM_DockWidgetHandleExtent:
- ret = 9;
- break;
-
- case PM_ProgressBarChunkWidth:
- ret = 1;
- break;
-
- case PM_ExclusiveIndicatorWidth:
- case PM_ExclusiveIndicatorHeight:
- ret = 13;
- break;
-
- case PM_MenuBarHMargin:
- ret = 2; // really ugly, but Motif
- break;
-
- case PM_MenuButtonIndicator:
- if (!opt)
- ret = 12;
- else
- ret = qMax(12, (opt->rect.height() - 4) / 3);
- break;
- default:
- ret = QCommonStyle::pixelMetric(pm, opt, widget);
- break;
- }
- return ret;
-}
-
-
-/*!
- \reimp
-*/
-QRect
-QMotifStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt,
- SubControl sc, const QWidget *widget) const
-{
- switch (cc) {
-#ifndef QT_NO_SPINBOX
- case CC_SpinBox:
- if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
- int fw = spinbox->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0;
- QSize bs;
- bs.setHeight(opt->rect.height()/2 - fw);
- bs.setWidth(qMin(bs.height() * 8 / 5, opt->rect.width() / 4)); // 1.6 -approximate golden mean
- bs = bs.expandedTo(QApplication::globalStrut());
- int y = fw + spinbox->rect.y();
- int x, lx, rx;
- x = spinbox->rect.x() + opt->rect.width() - fw - bs.width();
- lx = fw;
- rx = x - fw * 2;
- const int margin = spinbox->frame ? 4 : 0;
- switch (sc) {
- case SC_SpinBoxUp:
- if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
- return QRect();
- return visualRect(spinbox->direction, spinbox->rect,
- QRect(x, y, bs.width(), bs.height() - 1));
- case SC_SpinBoxDown:
- if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
- return QRect();
- return visualRect(spinbox->direction, spinbox->rect,
- QRect(x, y + bs.height() + 1, bs.width(), bs.height() - 1));
- case SC_SpinBoxEditField:
- if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
- return visualRect(spinbox->direction, spinbox->rect,
- QRect(lx + margin, y + margin,
- spinbox->rect.width() - 2*fw - 2*margin,
- spinbox->rect.height() - 2*fw - 2*margin));
-
- return visualRect(spinbox->direction, spinbox->rect,
- QRect(lx + margin, y + margin, rx - margin,
- spinbox->rect.height() - 2*fw - 2 * margin));
- case SC_SpinBoxFrame:
- return visualRect(spinbox->direction, spinbox->rect, spinbox->rect);
- default:
- break;
- }
- break; }
-#endif // QT_NO_SPINBOX
-#ifndef QT_NO_SLIDER
- case CC_Slider:
- if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
- if (sc == SC_SliderHandle) {
- int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, opt, widget);
- int thickness = proxy()->pixelMetric(PM_SliderControlThickness, opt, widget);
- bool horizontal = slider->orientation == Qt::Horizontal;
- int len = proxy()->pixelMetric(PM_SliderLength, opt, widget);
- int motifBorder = proxy()->pixelMetric(PM_DefaultFrameWidth);
- int sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum, slider->sliderPosition,
- horizontal ? slider->rect.width() - len - 2 * motifBorder
- : slider->rect.height() - len - 2 * motifBorder,
- slider->upsideDown);
- if (horizontal)
- return visualRect(slider->direction, slider->rect,
- QRect(sliderPos + motifBorder, tickOffset + motifBorder, len,
- thickness - 2 * motifBorder));
- return visualRect(slider->direction, slider->rect,
- QRect(tickOffset + motifBorder, sliderPos + motifBorder,
- thickness - 2 * motifBorder, len));
- }
- }
- break;
-#endif // QT_NO_SLIDER
-#ifndef QT_NO_SCROLLBAR
- case CC_ScrollBar:
- if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
- int dfw = proxy()->pixelMetric(PM_DefaultFrameWidth);
- QRect rect = visualRect(scrollbar->direction, scrollbar->rect,
- QCommonStyle::subControlRect(cc, scrollbar, sc, widget));
- if (sc == SC_ScrollBarSlider) {
- if (scrollbar->orientation == Qt::Horizontal)
- rect.adjust(-dfw, dfw, dfw, -dfw);
- else
- rect.adjust(dfw, -dfw, -dfw, dfw);
- } else if (sc != SC_ScrollBarGroove) {
- if (scrollbar->orientation == Qt::Horizontal)
- rect.adjust(0, dfw, 0, -dfw);
- else
- rect.adjust(dfw, 0, -dfw, 0);
- }
- return visualRect(scrollbar->direction, scrollbar->rect, rect);
- }
- break;
-#endif // QT_NO_SCROLLBAR
-#ifndef QT_NO_COMBOBOX
- case CC_ComboBox:
- if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
- switch (sc) {
- case SC_ComboBoxArrow: {
- int ew, awh, sh, dh, ax, ay, sy;
- int fw = cb->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth, opt, widget) : 0;
- QRect cr = opt->rect;
- cr.adjust(fw, fw, -fw, -fw);
- get_combo_parameters(cr, ew, awh, ax, ay, sh, dh, sy);
- return visualRect(cb->direction, cb->rect, QRect(QPoint(ax, ay), cr.bottomRight()));
- }
-
- case SC_ComboBoxEditField: {
- int fw = cb->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth, opt, widget) : 0;
- QRect rect = opt->rect;
- rect.adjust(fw, fw, -fw, -fw);
- int ew = get_combo_extra_width(rect.height(), rect.width());
- rect.adjust(1, 1, -1-ew, -1);
- return visualRect(cb->direction, cb->rect, rect);
- }
-
- default:
- break;
- }
- }
- break;
-#endif // QT_NO_SCROLLBAR
- default:
- break;
- }
- return QCommonStyle::subControlRect(cc, opt, sc, widget);
-}
-
-/*!
- \reimp
-*/
-QSize
-QMotifStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
- const QSize &contentsSize, const QWidget *widget) const
-{
- QSize sz(contentsSize);
-
- switch(ct) {
- case CT_RadioButton:
- case CT_CheckBox:
- sz = QCommonStyle::sizeFromContents(ct, opt, contentsSize, widget);
- sz.rwidth() += motifItemFrame;
- break;
-
- case CT_PushButton:
- if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
- sz = QCommonStyle::sizeFromContents(ct, opt, contentsSize, widget);
- if (!btn->text.isEmpty() && (btn->features & (QStyleOptionButton::AutoDefaultButton|QStyleOptionButton::DefaultButton)))
- sz.setWidth(qMax(75, sz.width()));
- sz += QSize(0, 1); // magical extra pixel
- }
- break;
-
- case CT_MenuBarItem: {
- if(!sz.isEmpty())
- sz += QSize(5*motifItemHMargin+1, 2*motifItemVMargin + motifItemFrame);
- break; }
-
- case CT_MenuItem:
- if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
- sz = QCommonStyle::sizeFromContents(ct, opt, sz, widget);
- int w = sz.width(), h = sz.height();
-
- if (mi->menuItemType == QStyleOptionMenuItem::Separator) {
- w = 10;
- h = (mi->text.isEmpty()) ? motifSepHeight : mi->fontMetrics.height();
- }
-
- // a little bit of border can never harm
- w += 2*motifItemHMargin + 2*motifItemFrame;
-
- if (!mi->text.isNull() && mi->text.indexOf(QLatin1Char('\t')) >= 0)
- // string contains tab
- w += motifTabSpacing;
- else if (mi->menuItemType == QStyleOptionMenuItem::SubMenu)
- // submenu indicator needs some room if we don't have a tab column
- w += motifArrowHMargin + 4*motifItemFrame;
-
- int checkColumn = mi->maxIconWidth;
- if (mi->menuHasCheckableItems)
- checkColumn = qMax(checkColumn, motifCheckMarkSpace);
- if (checkColumn > 0)
- w += checkColumn + motifCheckMarkHMargin;
-
- sz = QSize(w, h);
- }
- break;
-
-
- default:
- sz = QCommonStyle::sizeFromContents(ct, opt, contentsSize, widget);
- break;
- }
-
- return sz;
-}
-
-/*!
- \reimp
-*/
-QRect
-QMotifStyle::subElementRect(SubElement sr, const QStyleOption *opt, const QWidget *widget) const
-{
- QRect rect;
-
- switch (sr) {
- case SE_SliderFocusRect:
- rect = QCommonStyle::subElementRect(sr, opt, widget);
- rect.adjust(2, 2, -2, -2);
- break;
-
- case SE_CheckBoxIndicator:
- case SE_RadioButtonIndicator:
- {
- rect = visualRect(opt->direction, opt->rect,
- QCommonStyle::subElementRect(sr, opt, widget));
- rect.adjust(motifItemFrame,0, motifItemFrame,0);
- rect = visualRect(opt->direction, opt->rect, rect);
- }
- break;
-
- case SE_ComboBoxFocusRect:
- {
- int awh, ax, ay, sh, sy, dh, ew;
- int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget);
- QRect tr = opt->rect;
-
- tr.adjust(fw, fw, -fw, -fw);
- get_combo_parameters(tr, ew, awh, ax, ay, sh, dh, sy);
- rect.setRect(ax-2, ay-2, awh+4, awh+sh+dh+4);
- break;
- }
-
- case SE_Q3DockWindowHandleRect:
- if (const QStyleOptionQ3DockWindow *dw = qstyleoption_cast<const QStyleOptionQ3DockWindow *>(opt)) {
- if (!dw->docked || !dw->closeEnabled)
- rect.setRect(0, 0, opt->rect.width(), opt->rect.height());
- else {
- if (dw->state == State_Horizontal)
- rect.setRect(2, 15, opt->rect.width()-2, opt->rect.height() - 15);
- else
- rect.setRect(0, 2, opt->rect.width() - 15, opt->rect.height() - 2);
- }
- rect = visualRect(dw->direction, dw->rect, rect);
- }
- break;
-
- case SE_ProgressBarLabel:
- case SE_ProgressBarGroove:
- case SE_ProgressBarContents:
- if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
- int textw = 0;
- if (pb->textVisible)
- textw = pb->fontMetrics.width(QLatin1String("100%")) + 6;
-
- if (pb->textAlignment == Qt::AlignLeft || pb->textAlignment == Qt::AlignCenter) {
- rect = opt->rect;
- } else {
- if(sr == SE_ProgressBarLabel)
- rect.setCoords(opt->rect.right() - textw, opt->rect.top(),
- opt->rect.right(), opt->rect.bottom());
- else
- rect.setCoords(opt->rect.left(), opt->rect.top(),
- opt->rect.right() - textw, opt->rect.bottom());
- }
- if (sr == SE_ProgressBarContents)
- rect.adjust(2, 2, -2, -2);
- rect = visualRect(pb->direction, pb->rect, rect);
- }
- break;
- case SE_CheckBoxClickRect:
- case SE_RadioButtonClickRect:
- rect = visualRect(opt->direction, opt->rect, opt->rect);
- break;
-
- default:
- rect = QCommonStyle::subElementRect(sr, opt, widget);
- }
- return rect;
-}
-
-#ifndef QT_NO_IMAGEFORMAT_XPM
-static const char * const qt_menu_xpm[] = {
-"16 16 11 1",
-" c #000000",
-", c #336600",
-". c #99CC00",
-"X c #666600",
-"o c #999933",
-"+ c #333300",
-"@ c #669900",
-"# c #999900",
-"$ c #336633",
-"% c #666633",
-"& c #99CC33",
-"................",
-"................",
-".....#,++X#.....",
-"....X X....",
-"...X Xo#% X&..",
-"..# o..&@o o..",
-".., X..#+ @X X..",
-"..+ o.o+ +o# +..",
-"..+ #o+ +## +..",
-".., %@ ++ +, X..",
-"..# o@oo+ #..",
-"...X X##$ o..",
-"....X X..",
-"....&oX++X#oX...",
-"................",
-"................"};
-
-
-static const char * const qt_close_xpm[] = {
- "12 12 2 1",
- " s None c None",
- ". c black",
- " ",
- " ",
- " . . ",
- " ... ... ",
- " ...... ",
- " .... ",
- " .... ",
- " ...... ",
- " ... ... ",
- " . . ",
- " ",
- " "};
-
-static const char * const qt_maximize_xpm[] = {
- "12 12 2 1",
- " s None c None",
- ". c black",
- " ",
- " ",
- " ",
- " . ",
- " ... ",
- " ..... ",
- " ....... ",
- " ......... ",
- " ",
- " ",
- " ",
- " "};
-
-static const char * const qt_minimize_xpm[] = {
- "12 12 2 1",
- " s None c None",
- ". c black",
- " ",
- " ",
- " ",
- " ",
- " ......... ",
- " ....... ",
- " ..... ",
- " ... ",
- " . ",
- " ",
- " ",
- " "};
-
-#if 0 // ### not used???
-static const char * const qt_normalize_xpm[] = {
- "12 12 2 1",
- " s None c None",
- ". c black",
- " ",
- " ",
- " . ",
- " .. ",
- " ... ",
- " .... ",
- " ..... ",
- " ...... ",
- " ....... ",
- " ",
- " ",
- " "};
-#endif
-
-static const char * const qt_normalizeup_xpm[] = {
- "12 12 2 1",
- " s None c None",
- ". c black",
- " ",
- " ",
- " ",
- " ....... ",
- " ...... ",
- " ..... ",
- " .... ",
- " ... ",
- " .. ",
- " . ",
- " ",
- " "};
-
-static const char * const qt_shade_xpm[] = {
- "12 12 2 1", "# c #000000",
- ". c None",
- "............",
- "............",
- ".#########..",
- ".#########..",
- "............",
- "............",
- "............",
- "............",
- "............",
- "............",
- "............",
- "............"};
-
-
-static const char * const qt_unshade_xpm[] = {
- "12 12 2 1",
- "# c #000000",
- ". c None",
- "............",
- "............",
- ".#########..",
- ".#########..",
- ".#.......#..",
- ".#.......#..",
- ".#.......#..",
- ".#.......#..",
- ".#.......#..",
- ".#########..",
- "............",
- "............"};
-
-
-static const char * dock_window_close_xpm[] = {
- "8 8 2 1",
- "# c #000000",
- ". c None",
- "##....##",
- ".##..##.",
- "..####..",
- "...##...",
- "..####..",
- ".##..##.",
- "##....##",
- "........"};
-
-// Message box icons, from page 210 of the Windows style guide.
-
-// Hand-drawn to resemble Microsoft's icons, but in the Mac/Netscape palette.
-// Thanks to TrueColor displays, it is slightly more efficient to have
-// them duplicated.
-/* XPM */
-static const char * const information_xpm[]={
- "32 32 5 1",
- ". c None",
- "c c #000000",
- "* c #999999",
- "a c #ffffff",
- "b c #0000ff",
- "...........********.............",
- "........***aaaaaaaa***..........",
- "......**aaaaaaaaaaaaaa**........",
- ".....*aaaaaaaaaaaaaaaaaa*.......",
- "....*aaaaaaaabbbbaaaaaaaac......",
- "...*aaaaaaaabbbbbbaaaaaaaac.....",
- "..*aaaaaaaaabbbbbbaaaaaaaaac....",
- ".*aaaaaaaaaaabbbbaaaaaaaaaaac...",
- ".*aaaaaaaaaaaaaaaaaaaaaaaaaac*..",
- "*aaaaaaaaaaaaaaaaaaaaaaaaaaaac*.",
- "*aaaaaaaaaabbbbbbbaaaaaaaaaaac*.",
- "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
- "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
- "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
- "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
- "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
- ".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
- ".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
- "..*aaaaaaaaaabbbbbaaaaaaaaac***.",
- "...caaaaaaabbbbbbbbbaaaaaac****.",
- "....caaaaaaaaaaaaaaaaaaaac****..",
- ".....caaaaaaaaaaaaaaaaaac****...",
- "......ccaaaaaaaaaaaaaacc****....",
- ".......*cccaaaaaaaaccc*****.....",
- "........***cccaaaac*******......",
- "..........****caaac*****........",
- ".............*caaac**...........",
- "...............caac**...........",
- "................cac**...........",
- ".................cc**...........",
- "..................***...........",
- "...................**..........."};
-/* XPM */
-static const char* const warning_xpm[]={
- "32 32 4 1",
- ". c None",
- "a c #ffff00",
- "* c #000000",
- "b c #999999",
- ".............***................",
- "............*aaa*...............",
- "...........*aaaaa*b.............",
- "...........*aaaaa*bb............",
- "..........*aaaaaaa*bb...........",
- "..........*aaaaaaa*bb...........",
- ".........*aaaaaaaaa*bb..........",
- ".........*aaaaaaaaa*bb..........",
- "........*aaaaaaaaaaa*bb.........",
- "........*aaaa***aaaa*bb.........",
- ".......*aaaa*****aaaa*bb........",
- ".......*aaaa*****aaaa*bb........",
- "......*aaaaa*****aaaaa*bb.......",
- "......*aaaaa*****aaaaa*bb.......",
- ".....*aaaaaa*****aaaaaa*bb......",
- ".....*aaaaaa*****aaaaaa*bb......",
- "....*aaaaaaaa***aaaaaaaa*bb.....",
- "....*aaaaaaaa***aaaaaaaa*bb.....",
- "...*aaaaaaaaa***aaaaaaaaa*bb....",
- "...*aaaaaaaaaa*aaaaaaaaaa*bb....",
- "..*aaaaaaaaaaa*aaaaaaaaaaa*bb...",
- "..*aaaaaaaaaaaaaaaaaaaaaaa*bb...",
- ".*aaaaaaaaaaaa**aaaaaaaaaaa*bb..",
- ".*aaaaaaaaaaa****aaaaaaaaaa*bb..",
- "*aaaaaaaaaaaa****aaaaaaaaaaa*bb.",
- "*aaaaaaaaaaaaa**aaaaaaaaaaaa*bb.",
- "*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
- "*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
- ".*aaaaaaaaaaaaaaaaaaaaaaaaa*bbbb",
- "..*************************bbbbb",
- "....bbbbbbbbbbbbbbbbbbbbbbbbbbb.",
- ".....bbbbbbbbbbbbbbbbbbbbbbbbb.."};
-/* XPM */
-static const char* const critical_xpm[]={
- "32 32 4 1",
- ". c None",
- "a c #999999",
- "* c #ff0000",
- "b c #ffffff",
- "...........********.............",
- ".........************...........",
- ".......****************.........",
- "......******************........",
- ".....********************a......",
- "....**********************a.....",
- "...************************a....",
- "..*******b**********b*******a...",
- "..******bbb********bbb******a...",
- ".******bbbbb******bbbbb******a..",
- ".*******bbbbb****bbbbb*******a..",
- "*********bbbbb**bbbbb*********a.",
- "**********bbbbbbbbbb**********a.",
- "***********bbbbbbbb***********aa",
- "************bbbbbb************aa",
- "************bbbbbb************aa",
- "***********bbbbbbbb***********aa",
- "**********bbbbbbbbbb**********aa",
- "*********bbbbb**bbbbb*********aa",
- ".*******bbbbb****bbbbb*******aa.",
- ".******bbbbb******bbbbb******aa.",
- "..******bbb********bbb******aaa.",
- "..*******b**********b*******aa..",
- "...************************aaa..",
- "....**********************aaa...",
- "....a********************aaa....",
- ".....a******************aaa.....",
- "......a****************aaa......",
- ".......aa************aaaa.......",
- ".........aa********aaaaa........",
- "...........aaaaaaaaaaa..........",
- ".............aaaaaaa............"};
-/* XPM */
-static const char *const question_xpm[] = {
- "32 32 5 1",
- ". c None",
- "c c #000000",
- "* c #999999",
- "a c #ffffff",
- "b c #0000ff",
- "...........********.............",
- "........***aaaaaaaa***..........",
- "......**aaaaaaaaaaaaaa**........",
- ".....*aaaaaaaaaaaaaaaaaa*.......",
- "....*aaaaaaaaaaaaaaaaaaaac......",
- "...*aaaaaaaabbbbbbaaaaaaaac.....",
- "..*aaaaaaaabaaabbbbaaaaaaaac....",
- ".*aaaaaaaabbaaaabbbbaaaaaaaac...",
- ".*aaaaaaaabbbbaabbbbaaaaaaaac*..",
- "*aaaaaaaaabbbbaabbbbaaaaaaaaac*.",
- "*aaaaaaaaaabbaabbbbaaaaaaaaaac*.",
- "*aaaaaaaaaaaaabbbbaaaaaaaaaaac**",
- "*aaaaaaaaaaaaabbbaaaaaaaaaaaac**",
- "*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
- "*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
- "*aaaaaaaaaaaaaaaaaaaaaaaaaaaac**",
- ".*aaaaaaaaaaaabbaaaaaaaaaaaac***",
- ".*aaaaaaaaaaabbbbaaaaaaaaaaac***",
- "..*aaaaaaaaaabbbbaaaaaaaaaac***.",
- "...caaaaaaaaaabbaaaaaaaaaac****.",
- "....caaaaaaaaaaaaaaaaaaaac****..",
- ".....caaaaaaaaaaaaaaaaaac****...",
- "......ccaaaaaaaaaaaaaacc****....",
- ".......*cccaaaaaaaaccc*****.....",
- "........***cccaaaac*******......",
- "..........****caaac*****........",
- ".............*caaac**...........",
- "...............caac**...........",
- "................cac**...........",
- ".................cc**...........",
- "..................***...........",
- "...................**...........",
-};
-#endif
-
-/*!
- \reimp
-*/
-QPixmap
-QMotifStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
- const QWidget *widget) const
-{
-#ifndef QT_NO_IMAGEFORMAT_XPM
- switch (standardPixmap) {
- case SP_TitleBarMenuButton:
- return QPixmap(qt_menu_xpm);
- case SP_TitleBarShadeButton:
- return QPixmap(qt_shade_xpm);
- case SP_TitleBarUnshadeButton:
- return QPixmap(qt_unshade_xpm);
- case SP_TitleBarNormalButton:
- return QPixmap(qt_normalizeup_xpm);
- case SP_TitleBarMinButton:
- return QPixmap(qt_minimize_xpm);
- case SP_TitleBarMaxButton:
- return QPixmap(qt_maximize_xpm);
- case SP_TitleBarCloseButton:
- return QPixmap(qt_close_xpm);
- case SP_DockWidgetCloseButton:
- return QPixmap(dock_window_close_xpm);
-
- case SP_MessageBoxInformation:
- case SP_MessageBoxWarning:
- case SP_MessageBoxCritical:
- case SP_MessageBoxQuestion:
- {
- const char * const * xpm_data;
- switch (standardPixmap) {
- case SP_MessageBoxInformation:
- xpm_data = information_xpm;
- break;
- case SP_MessageBoxWarning:
- xpm_data = warning_xpm;
- break;
- case SP_MessageBoxCritical:
- xpm_data = critical_xpm;
- break;
- case SP_MessageBoxQuestion:
- xpm_data = question_xpm;
- break;
- default:
- xpm_data = 0;
- break;
- }
- QPixmap pm;
- if (xpm_data) {
- QImage image((const char **) xpm_data);
- // All that color looks ugly in Motif
- const QPalette &pal = QApplication::palette();
- switch (standardPixmap) {
- case SP_MessageBoxInformation:
- case SP_MessageBoxQuestion:
- image.setColor(2, 0xff000000 |
- pal.color(QPalette::Active, QPalette::Dark).rgb());
- image.setColor(3, 0xff000000 |
- pal.color(QPalette::Active, QPalette::Base).rgb());
- image.setColor(4, 0xff000000 |
- pal.color(QPalette::Active, QPalette::Text).rgb());
- break;
- case SP_MessageBoxWarning:
- image.setColor(1, 0xff000000 |
- pal.color(QPalette::Active, QPalette::Base).rgb());
- image.setColor(2, 0xff000000 |
- pal.color(QPalette::Active, QPalette::Text).rgb());
- image.setColor(3, 0xff000000 |
- pal.color(QPalette::Active, QPalette::Dark).rgb());
- break;
- case SP_MessageBoxCritical:
- image.setColor(1, 0xff000000 |
- pal.color(QPalette::Active, QPalette::Dark).rgb());
- image.setColor(2, 0xff000000 |
- pal.color(QPalette::Active, QPalette::Text).rgb());
- image.setColor(3, 0xff000000 |
- pal.color(QPalette::Active, QPalette::Base).rgb());
- break;
- default:
- break;
- }
- pm = QPixmap::fromImage(image);
- }
- return pm;
- }
-
- default:
- break;
- }
-#endif
-
- return QCommonStyle::standardPixmap(standardPixmap, opt, widget);
-}
-
-/*! \reimp */
-bool QMotifStyle::event(QEvent *e)
-{
- if(e->type() == QEvent::FocusIn) {
- if (QWidget *focusWidget = QApplication::focusWidget()) {
-#ifndef QT_NO_GRAPHICSVIEW
- if (QGraphicsView *graphicsView = qobject_cast<QGraphicsView *>(focusWidget)) {
- QGraphicsItem *focusItem = graphicsView->scene() ? graphicsView->scene()->focusItem() : 0;
- if (focusItem && focusItem->type() == QGraphicsProxyWidget::Type) {
- QGraphicsProxyWidget *proxy = static_cast<QGraphicsProxyWidget *>(focusItem);
- if (proxy->widget())
- focusWidget = proxy->widget()->focusWidget();
- }
- }
-#endif
- if(!focus)
- focus = new QFocusFrame(focusWidget);
- focus->setWidget(focusWidget);
- } else {
- if(focus)
- focus->setWidget(0);
- }
- } else if(e->type() == QEvent::FocusOut) {
- if(focus)
- focus->setWidget(0);
- }
- return QCommonStyle::event(e);
-}
-
-
-/*! \reimp */
-int
-QMotifStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWidget *widget,
- QStyleHintReturn *returnData) const
-{
- int ret;
-
- switch (hint) {
-#ifdef QT3_SUPPORT
- case SH_GUIStyle:
- ret = Qt::MotifStyle;
- break;
-#endif
- case SH_DrawMenuBarSeparator:
- ret = true;
- break;
-
- case SH_ScrollBar_MiddleClickAbsolutePosition:
- case SH_Slider_SloppyKeyEvents:
- case SH_ProgressDialog_CenterCancelButton:
- case SH_Menu_SpaceActivatesItem:
- case SH_ScrollView_FrameOnlyAroundContents:
- case SH_DitherDisabledText:
- ret = 1;
- break;
-
- case SH_Menu_SubMenuPopupDelay:
- ret = 96;
- break;
-
- case SH_ProgressDialog_TextLabelAlignment:
- ret = Qt::AlignLeft | Qt::AlignVCenter;
- break;
-
- case SH_ItemView_ChangeHighlightOnFocus:
- ret = 0;
- break;
-
- case SH_MessageBox_UseBorderForButtonSpacing:
- ret = 1;
- break;
-
- case SH_Dial_BackgroundRole:
- ret = QPalette::Mid;
- break;
-
- case SH_DialogButtonLayout:
- ret = QDialogButtonBox::KdeLayout;
- break;
- case SH_LineEdit_PasswordCharacter:
- ret = '*';
- break;
- case SH_DialogButtonBox_ButtonsHaveIcons:
- ret = 0;
- break;
- default:
- ret = QCommonStyle::styleHint(hint, opt, widget, returnData);
- break;
- }
-
- return ret;
-}
-
-/*! \reimp */
-QPalette QMotifStyle::standardPalette() const
-{
-#ifdef Q_WS_X11
- QColor background(0xcf, 0xcf, 0xcf);
- if (QX11Info::appDepth() <= 8)
- background = QColor(0xc0, 0xc0, 0xc0);
-#else
- QColor background = QColor(0xcf, 0xcf, 0xcf);
-#endif
-
- QColor light = background.lighter();
- QColor mid = QColor(0xa6, 0xa6, 0xa6);
- QColor dark = QColor(0x79, 0x7d, 0x79);
- QPalette palette(Qt::black, background, light, dark, mid, Qt::black, Qt::white);
- palette.setBrush(QPalette::Disabled, QPalette::WindowText, dark);
- palette.setBrush(QPalette::Disabled, QPalette::Text, dark);
- palette.setBrush(QPalette::Disabled, QPalette::ButtonText, dark);
- palette.setBrush(QPalette::Disabled, QPalette::Base, background);
- return palette;
-}
-
-QT_END_NAMESPACE
-
-#endif // !defined(QT_NO_STYLE_MOTIF) || defined(QT_PLUGIN)
diff --git a/src/gui/styles/qmotifstyle.h b/src/gui/styles/qmotifstyle.h
deleted file mode 100644
index 5ca0795216..0000000000
--- a/src/gui/styles/qmotifstyle.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMOTIFSTYLE_H
-#define QMOTIFSTYLE_H
-
-#include <QtGui/qcommonstyle.h>
-#include <QtCore/qpointer.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if !defined(QT_NO_STYLE_MOTIF)
-
-class QPalette;
-class QFocusFrame;
-
-class QMotifStylePrivate;
-class Q_GUI_EXPORT QMotifStyle : public QCommonStyle
-{
- Q_OBJECT
-public:
- explicit QMotifStyle(bool useHighlightCols=false);
- virtual ~QMotifStyle();
-
- void setUseHighlightColors(bool);
- bool useHighlightColors() const;
-
- void polish(QPalette&);
- void polish(QWidget*);
- void unpolish(QWidget*);
- void polish(QApplication*);
- void unpolish(QApplication*);
-
- void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
- const QWidget *w = 0) const;
-
- void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
- const QWidget *w = 0) const;
-
- void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
- const QWidget *w = 0) const;
-
- QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt,
- SubControl sc, const QWidget *widget = 0) const;
-
- int pixelMetric(PixelMetric metric, const QStyleOption *option = 0,
- const QWidget *widget = 0) const;
-
- QSize sizeFromContents(ContentsType ct, const QStyleOption *opt,
- const QSize &contentsSize, const QWidget *widget = 0) const;
-
- QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const;
-
- QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
- const QWidget *widget = 0) const;
-
- int styleHint(StyleHint hint, const QStyleOption *opt = 0, const QWidget *widget = 0,
- QStyleHintReturn *returnData = 0) const;
-
- bool event(QEvent *);
- QPalette standardPalette() const;
-
-protected Q_SLOTS:
- QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt = 0,
- const QWidget *widget = 0) const;
-
-protected:
- QPointer<QFocusFrame> focus;
- QMotifStyle(QMotifStylePrivate &dd, bool useHighlightCols = false);
- void timerEvent(QTimerEvent *event);
- bool eventFilter(QObject *o, QEvent *e);
-
-private:
- Q_DECLARE_PRIVATE(QMotifStyle)
- Q_DISABLE_COPY(QMotifStyle)
-
- bool highlightCols;
-};
-
-#endif // QT_NO_STYLE_MOTIF
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMOTIFSTYLE_H
diff --git a/src/gui/styles/qplastiquestyle.h b/src/gui/styles/qplastiquestyle.h
deleted file mode 100644
index 20d2f490a6..0000000000
--- a/src/gui/styles/qplastiquestyle.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPLASTIQUESTYLE_H
-#define QPLASTIQUESTYLE_H
-
-#include <QtGui/qwindowsstyle.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if !defined(QT_NO_STYLE_PLASTIQUE)
-
-class QPlastiqueStylePrivate;
-class Q_GUI_EXPORT QPlastiqueStyle : public QWindowsStyle
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QPlastiqueStyle)
-public:
- QPlastiqueStyle();
- ~QPlastiqueStyle();
-
- 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;
-
- int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0,
- QStyleHintReturn *returnData = 0) const;
- SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option,
- const QPoint &pos, const QWidget *widget = 0) const;
-
- int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
-
- QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
- const QWidget *widget = 0) const;
-
- void polish(QWidget *widget);
- void polish(QApplication *app);
- void polish(QPalette &pal);
- void unpolish(QWidget *widget);
- void unpolish(QApplication *app);
-
- QPalette standardPalette() const;
-
-protected Q_SLOTS:
- QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt = 0,
- const QWidget *widget = 0) const;
- int layoutSpacingImplementation(QSizePolicy::ControlType control1,
- QSizePolicy::ControlType control2,
- Qt::Orientation orientation,
- const QStyleOption *option = 0,
- const QWidget *widget = 0) const;
-
-protected:
- bool eventFilter(QObject *watched, QEvent *event);
- void timerEvent(QTimerEvent *event);
-
-private:
- Q_DISABLE_COPY(QPlastiqueStyle)
- void *reserved;
-};
-
-#endif // QT_NO_STYLE_PLASTIQUE
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QPLASTIQUESTYLE_H
diff --git a/src/gui/styles/qproxystyle.h b/src/gui/styles/qproxystyle.h
deleted file mode 100644
index 9d4a5cc56c..0000000000
--- a/src/gui/styles/qproxystyle.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPROXYSTYLE_H
-#define QPROXYSTYLE_H
-
-#include <QtGui/QCommonStyle>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if !defined(QT_NO_STYLE_PROXY)
-
-class QProxyStylePrivate;
-class Q_GUI_EXPORT QProxyStyle : public QCommonStyle
-{
- Q_OBJECT
-
-public:
- QProxyStyle(QStyle *baseStyle = 0);
- ~QProxyStyle();
-
- QStyle *baseStyle() const;
- void setBaseStyle(QStyle *style);
-
- 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 = 0) const;
- void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = 0) const;
- void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled,
- const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const;
- virtual void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) 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;
- QRect itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const;
- QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const;
-
- SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, const QPoint &pos, const QWidget *widget = 0) const;
- int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const;
- int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
-
- QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget = 0) const;
- QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const;
- QPalette standardPalette() const;
-
- void polish(QWidget *widget);
- void polish(QPalette &pal);
- void polish(QApplication *app);
-
- void unpolish(QWidget *widget);
- void unpolish(QApplication *app);
-
-protected:
- bool event(QEvent *e);
-
-protected Q_SLOTS:
- QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const;
- int layoutSpacingImplementation(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2,
- Qt::Orientation orientation, const QStyleOption *option = 0, const QWidget *widget = 0) const;
-private:
- Q_DISABLE_COPY(QProxyStyle)
- Q_DECLARE_PRIVATE(QProxyStyle)
-};
-
-#endif // QT_NO_STYLE_PROXY
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QPROXYSTYLE_H
diff --git a/src/gui/styles/qs60style.h b/src/gui/styles/qs60style.h
deleted file mode 100644
index 5f44ca7b9b..0000000000
--- a/src/gui/styles/qs60style.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QS60STYLE_H
-#define QS60STYLE_H
-
-#include <QtGui/qcommonstyle.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-//Public custom pixel metrics values.
-//These can be used to fetch custom pixel metric value from outside QS60Style.
-enum {
- PM_FrameCornerWidth = QStyle::PM_CustomBase + 1,
- PM_FrameCornerHeight,
- PM_BoldLineWidth,
- PM_ThinLineWidth,
- PM_MessageBoxHeight
- };
-
-class QS60StylePrivate;
-
-class Q_GUI_EXPORT QS60Style : public QCommonStyle
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QS60Style)
-
-public:
- QS60Style();
- ~QS60Style();
-
- void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = 0) const;
- void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const;
- void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const;
- int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
- QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w = 0) const;
- int styleHint(StyleHint sh, const QStyleOption *opt = 0, const QWidget *w = 0,
- QStyleHintReturn *shret = 0) const;
- QRect subControlRect(ComplexControl control, const QStyleOptionComplex *option, SubControl scontrol, const QWidget *widget = 0) const;
- QRect subElementRect(SubElement element, const QStyleOption *opt, const QWidget *widget = 0) const;
- void polish(QWidget *widget);
- void unpolish(QWidget *widget);
- void polish(QApplication *application);
- void unpolish(QApplication *application);
-#ifndef Q_NO_USING_KEYWORD
- using QCommonStyle::polish;
-#endif
- bool event(QEvent *e);
-
-#ifndef Q_OS_SYMBIAN
- static QStringList partKeys();
- static QStringList colorListKeys();
- void setS60Theme(const QHash<QString, QPicture> &parts,
- const QHash<QPair<QString , int>, QColor> &colors);
- bool loadS60ThemeFromBlob(const QString &blobFile);
- bool saveS60ThemeToBlob(const QString &blobFile) const;
-#endif // !Q_OS_SYMBIAN
-
-protected Q_SLOTS:
- QIcon standardIconImplementation(
- StandardPixmap standardIcon, const QStyleOption * option = 0, const QWidget * widget = 0 ) const;
-
-protected:
- void timerEvent(QTimerEvent *event);
- bool eventFilter(QObject *o, QEvent *e);
-private:
- Q_DISABLE_COPY(QS60Style)
- friend class QStyleFactory;
- friend class QApplicationPrivate;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QS60STYLE_H
diff --git a/src/gui/styles/qstyle.cpp b/src/gui/styles/qstyle.cpp
deleted file mode 100644
index dd816d379c..0000000000
--- a/src/gui/styles/qstyle.cpp
+++ /dev/null
@@ -1,2493 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qstyle.h"
-#include "qapplication.h"
-#include "qpainter.h"
-#include "qwidget.h"
-#include "qbitmap.h"
-#include "qpixmapcache.h"
-#include "qstyleoption.h"
-#include "private/qstyle_p.h"
-#ifndef QT_NO_DEBUG
-#include "qdebug.h"
-#endif
-
-#ifdef Q_WS_X11
-#include <qx11info_x11.h>
-#endif
-
-#include <limits.h>
-
-QT_BEGIN_NAMESPACE
-
-static const int MaxBits = 8 * sizeof(QSizePolicy::ControlType);
-
-static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::ControlType *array)
-{
- if (!controls)
- return 0;
-
- // optimization: exactly one bit is set
- if ((controls & (controls - 1)) == 0) {
- array[0] = QSizePolicy::ControlType(uint(controls));
- return 1;
- }
-
- int count = 0;
- for (int i = 0; i < MaxBits; ++i) {
- if (uint bit = (controls & (0x1 << i)))
- array[count++] = QSizePolicy::ControlType(bit);
- }
- return count;
-}
-
-/*!
- \class QStyle
- \brief The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
-
- \ingroup appearance
-
- Qt contains a set of QStyle subclasses that emulate the styles of
- the different platforms supported by Qt (QWindowsStyle,
- QMacStyle, QMotifStyle, etc.). By default, these styles are built
- into the QtGui library. Styles can also be made available as
- plugins.
-
- Qt's built-in widgets use QStyle to perform nearly all of their
- drawing, ensuring that they look exactly like the equivalent
- native widgets. The diagram below shows a QComboBox in eight
- different styles.
-
- \img qstyle-comboboxes.png Eight combo boxes
-
- Topics:
-
- \tableofcontents
-
- \section1 Setting a Style
-
- The style of the entire application can be set using the
- QApplication::setStyle() function. It can also be specified by the
- user of the application, using the \c -style command-line option:
-
- \snippet doc/src/snippets/code/src_gui_styles_qstyle.cpp 0
-
- If no style is specified, Qt will choose the most appropriate
- style for the user's platform or desktop environment.
-
- A style can also be set on an individual widget using the
- QWidget::setStyle() function.
-
- \section1 Developing Style-Aware Custom Widgets
-
- If you are developing custom widgets and want them to look good on
- all platforms, you can use QStyle functions to perform parts of
- the widget drawing, such as drawItemText(), drawItemPixmap(),
- drawPrimitive(), drawControl(), and drawComplexControl().
-
- Most QStyle draw functions take four arguments:
- \list
- \o an enum value specifying which graphical element to draw
- \o a QStyleOption specifying how and where to render that element
- \o a QPainter that should be used to draw the element
- \o a QWidget on which the drawing is performed (optional)
- \endlist
-
- For example, if you want to draw a focus rectangle on your
- widget, you can write:
-
- \snippet doc/src/snippets/styles/styles.cpp 1
-
- QStyle gets all the information it needs to render the graphical
- element from QStyleOption. The widget is passed as the last
- argument in case the style needs it to perform special effects
- (such as animated default buttons on Mac OS X), but it isn't
- mandatory. In fact, you can use QStyle to draw on any paint
- device, not just widgets, by setting the QPainter properly.
-
- QStyleOption has various subclasses for the various types of
- graphical elements that can be drawn. For example,
- PE_FrameFocusRect expects a QStyleOptionFocusRect argument.
-
- To ensure that drawing operations are as fast as possible,
- QStyleOption and its subclasses have public data members. See the
- QStyleOption class documentation for details on how to use it.
-
- For convenience, Qt provides the QStylePainter class, which
- combines a QStyle, a QPainter, and a QWidget. This makes it
- possible to write
-
- \snippet doc/src/snippets/styles/styles.cpp 5
- \dots
- \snippet doc/src/snippets/styles/styles.cpp 7
-
- instead of
-
- \snippet doc/src/snippets/styles/styles.cpp 2
- \dots
- \snippet doc/src/snippets/styles/styles.cpp 3
-
- \section1 Creating a Custom Style
-
- You can create a custom look and feel for your application by
- creating a custom style. There are two approaches to creating a
- custom style. In the static approach, you either choose an
- existing QStyle class, subclass it, and reimplement virtual
- functions to provide the custom behavior, or you create an entire
- QStyle class from scratch. In the dynamic approach, you modify the
- behavior of your system style at runtime. The static approach is
- described below. The dynamic approach is described in QProxyStyle.
-
- The first step in the static approach is to pick one of the styles
- provided by Qt from which you will build your custom style. Your
- choice of QStyle class will depend on which style resembles your
- desired style the most. The most general class that you can use as
- a base is QCommonStyle (not QStyle). This is because Qt requires
- its styles to be \l{QCommonStyle}s.
-
- Depending on which parts of the base style you want to change,
- you must reimplement the functions that are used to draw those
- parts of the interface. To illustrate this, we will modify the
- look of the spin box arrows drawn by QWindowsStyle. The arrows
- are \e{primitive elements} that are drawn by the drawPrimitive()
- function, so we need to reimplement that function. We need the
- following class declaration:
-
- \snippet doc/src/snippets/customstyle/customstyle.h 0
-
- To draw its up and down arrows, QSpinBox uses the
- PE_IndicatorSpinUp and PE_IndicatorSpinDown primitive elements.
- Here's how to reimplement the drawPrimitive() function to draw
- them differently:
-
- \snippet doc/src/snippets/customstyle/customstyle.cpp 2
- \snippet doc/src/snippets/customstyle/customstyle.cpp 3
- \snippet doc/src/snippets/customstyle/customstyle.cpp 4
-
- Notice that we don't use the \c widget argument, except to pass it
- on to the QWindowStyle::drawPrimitive() function. As mentioned
- earlier, the information about what is to be drawn and how it
- should be drawn is specified by a QStyleOption object, so there is
- no need to ask the widget.
-
- If you need to use the \c widget argument to obtain additional
- information, be careful to ensure that it isn't 0 and that it is
- of the correct type before using it. For example:
-
- \snippet doc/src/snippets/customstyle/customstyle.cpp 0
- \dots
- \snippet doc/src/snippets/customstyle/customstyle.cpp 1
-
- When implementing a custom style, you cannot assume that the
- widget is a QSpinBox just because the enum value is called
- PE_IndicatorSpinUp or PE_IndicatorSpinDown.
-
- The documentation for the \l{widgets/styles}{Styles} example
- covers this topic in more detail.
-
- \warning Qt style sheets are currently not supported for custom QStyle
- subclasses. We plan to address this in some future release.
-
-
- \section1 Using a Custom Style
-
- There are several ways of using a custom style in a Qt
- application. The simplest way is to pass the custom style to the
- QApplication::setStyle() static function before creating the
- QApplication object:
-
- \snippet snippets/customstyle/main.cpp using a custom style
-
- You can call QApplication::setStyle() at any time, but by calling
- it before the constructor, you ensure that the user's preference,
- set using the \c -style command-line option, is respected.
-
- You may want to make your custom style available for use in other
- applications, which may not be yours and hence not available for
- you to recompile. The Qt Plugin system makes it possible to create
- styles as plugins. Styles created as plugins are loaded as shared
- objects at runtime by Qt itself. Please refer to the \link
- plugins-howto.html Qt Plugin\endlink documentation for more
- information on how to go about creating a style plugin.
-
- Compile your plugin and put it into Qt's \c plugins/styles
- directory. We now have a pluggable style that Qt can load
- automatically. To use your new style with existing applications,
- simply start the application with the following argument:
-
- \snippet doc/src/snippets/code/src_gui_styles_qstyle.cpp 1
-
- The application will use the look and feel from the custom style you
- implemented.
-
- \section1 Right-to-Left Desktops
-
- Languages written from right to left (such as Arabic and Hebrew)
- usually also mirror the whole layout of widgets, and require the
- light to come from the screen's top-right corner instead of
- top-left.
-
- If you create a custom style, you should take special care when
- drawing asymmetric elements to make sure that they also look
- correct in a mirrored layout. An easy way to test your styles is
- to run applications with the \c -reverse command-line option or
- to call QApplication::setLayoutDirection() in your \c main()
- function.
-
- Here are some things to keep in mind when making a style work well in a
- right-to-left environment:
-
- \list
- \o subControlRect() and subElementRect() return rectangles in screen coordinates
- \o QStyleOption::direction indicates in which direction the item should be drawn in
- \o If a style is not right-to-left aware it will display items as if it were left-to-right
- \o visualRect(), visualPos(), and visualAlignment() are helpful functions that will
- translate from logical to screen representations.
- \o alignedRect() will return a logical rect aligned for the current direction
- \endlist
-
- \section1 Styles in Item Views
-
- The painting of items in views is performed by a delegate. Qt's
- default delegate, QStyledItemDelegate, is also used for for calculating bounding
- rectangles of items, and their sub-elements for the various kind
- of item \l{Qt::ItemDataRole}{data roles}
- QStyledItemDelegate supports. See the QStyledItemDelegate class
- description to find out which datatypes and roles are supported. You
- can read more about item data roles in \l{Model/View Programming}.
-
- When QStyledItemDelegate paints its items, it draws
- CE_ItemViewItem, and calculates their size with CT_ItemViewItem.
- Note also that it uses SE_ItemViewItemText to set the size of
- editors. When implementing a style to customize drawing of item
- views, you need to check the implementation of QCommonStyle (and
- any other subclasses from which your style
- inherits). This way, you find out which and how
- other style elements are painted, and you can then reimplement the
- painting of elements that should be drawn differently.
-
- We include a small example where we customize the drawing of item
- backgrounds.
-
- \snippet doc/src/snippets/customviewstyle.cpp 0
-
- The primitive element PE_PanelItemViewItem is responsible for
- painting the background of items, and is called from
- \l{QCommonStyle}'s implementation of CE_ItemViewItem.
-
- To add support for drawing of new datatypes and item data roles,
- it is necessary to create a custom delegate. But if you only
- need to support the datatypes implemented by the default
- delegate, a custom style does not need an accompanying
- delegate. The QStyledItemDelegate class description gives more
- information on custom delegates.
-
- The drawing of item view headers is also done by the style, giving
- control over size of header items and row and column sizes.
-
- \sa QStyleOption, QStylePainter, {Styles Example},
- {Styles and Style Aware Widgets}, QStyledItemDelegate
-*/
-
-/*!
- Constructs a style object.
-*/
-QStyle::QStyle()
- : QObject(*new QStylePrivate)
-{
- Q_D(QStyle);
- d->proxyStyle = this;
-}
-
-/*!
- \internal
-
- Constructs a style object.
-*/
-QStyle::QStyle(QStylePrivate &dd)
- : QObject(dd)
-{
- Q_D(QStyle);
- d->proxyStyle = this;
-}
-
-/*!
- Destroys the style object.
-*/
-QStyle::~QStyle()
-{
-}
-
-/*!
- Initializes the appearance of the given \a widget.
-
- This function is called for every widget at some point after it
- has been fully created but just \e before it is shown for the very
- first time.
-
- Note that the default implementation does nothing. Reasonable
- actions in this function might be to call the
- QWidget::setBackgroundMode() function for the widget. Do not use
- the function to set, for example, the geometry. Reimplementing
- this function provides a back-door through which the appearance
- of a widget can be changed, but with Qt's style engine it is
- rarely necessary to implement this function; reimplement
- drawItemPixmap(), drawItemText(), drawPrimitive(), etc. instead.
-
- The QWidget::inherits() function may provide enough information to
- allow class-specific customizations. But because new QStyle
- subclasses are expected to work reasonably with all current and \e
- future widgets, limited use of hard-coded customization is
- recommended.
-
- \sa unpolish()
-*/
-void QStyle::polish(QWidget * /* widget */)
-{
-}
-
-/*!
- Uninitialize the given \a{widget}'s appearance.
-
- This function is the counterpart to polish(). It is called for
- every polished widget whenever the style is dynamically changed;
- the former style has to unpolish its settings before the new style
- can polish them again.
-
- Note that unpolish() will only be called if the widget is
- destroyed. This can cause problems in some cases, e.g, if you
- remove a widget from the UI, cache it, and then reinsert it after
- the style has changed; some of Qt's classes cache their widgets.
-
- \sa polish()
-*/
-void QStyle::unpolish(QWidget * /* widget */)
-{
-}
-
-/*!
- \fn void QStyle::polish(QApplication * application)
- \overload
-
- Late initialization of the given \a application object.
-*/
-void QStyle::polish(QApplication * /* app */)
-{
-}
-
-/*!
- \fn void QStyle::unpolish(QApplication * application)
- \overload
-
- Uninitialize the given \a application.
-*/
-void QStyle::unpolish(QApplication * /* app */)
-{
-}
-
-/*!
- \fn void QStyle::polish(QPalette & palette)
- \overload
-
- Changes the \a palette according to style specific requirements
- for color palettes (if any).
-
- \sa QPalette, QApplication::setPalette()
-*/
-void QStyle::polish(QPalette & /* pal */)
-{
-}
-
-/*!
- \fn QRect QStyle::itemTextRect(const QFontMetrics &metrics, const QRect &rectangle, int alignment, bool enabled, const QString &text) const
-
- Returns the area within the given \a rectangle in which to draw
- the provided \a text according to the specified font \a metrics
- and \a alignment. The \a enabled parameter indicates whether or
- not the associated item is enabled.
-
- If the given \a rectangle is larger than the area needed to render
- the \a text, the rectangle that is returned will be offset within
- \a rectangle according to the specified \a alignment. For
- example, if \a alignment is Qt::AlignCenter, the returned
- rectangle will be centered within \a rectangle. If the given \a
- rectangle is smaller than the area needed, the returned rectangle
- will be the smallest rectangle large enough to render the \a text.
-
- \sa Qt::Alignment
-*/
-QRect QStyle::itemTextRect(const QFontMetrics &metrics, const QRect &rect, int alignment, bool enabled,
- const QString &text) const
-{
- QRect result;
- int x, y, w, h;
- rect.getRect(&x, &y, &w, &h);
- if (!text.isEmpty()) {
- result = metrics.boundingRect(x, y, w, h, alignment, text);
- if (!enabled && proxy()->styleHint(SH_EtchDisabledText)) {
- result.setWidth(result.width()+1);
- result.setHeight(result.height()+1);
- }
- } else {
- result = QRect(x, y, w, h);
- }
- return result;
-}
-
-/*!
- \fn QRect QStyle::itemPixmapRect(const QRect &rectangle, int alignment, const QPixmap &pixmap) const
-
- Returns the area within the given \a rectangle in which to draw
- the specified \a pixmap according to the defined \a alignment.
-*/
-QRect QStyle::itemPixmapRect(const QRect &rect, int alignment, const QPixmap &pixmap) const
-{
- QRect result;
- int x, y, w, h;
- rect.getRect(&x, &y, &w, &h);
- if ((alignment & Qt::AlignVCenter) == Qt::AlignVCenter)
- y += h/2 - pixmap.height()/2;
- else if ((alignment & Qt::AlignBottom) == Qt::AlignBottom)
- y += h - pixmap.height();
- if ((alignment & Qt::AlignRight) == Qt::AlignRight)
- x += w - pixmap.width();
- else if ((alignment & Qt::AlignHCenter) == Qt::AlignHCenter)
- x += w/2 - pixmap.width()/2;
- else if ((alignment & Qt::AlignLeft) != Qt::AlignLeft && QApplication::isRightToLeft())
- x += w - pixmap.width();
- result = QRect(x, y, pixmap.width(), pixmap.height());
- return result;
-}
-
-/*!
- \fn void QStyle::drawItemText(QPainter *painter, const QRect &rectangle, int alignment, const QPalette &palette, bool enabled, const QString& text, QPalette::ColorRole textRole) const
-
- Draws the given \a text in the specified \a rectangle using the
- provided \a painter and \a palette.
-
- The text is drawn using the painter's pen, and aligned and wrapped
- according to the specified \a alignment. If an explicit \a
- textRole is specified, the text is drawn using the \a palette's
- color for the given role. The \a enabled parameter indicates
- whether or not the item is enabled; when reimplementing this
- function, the \a enabled parameter should influence how the item is
- drawn.
-
- \sa Qt::Alignment, drawItemPixmap()
-*/
-void QStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal,
- bool enabled, const QString& text, QPalette::ColorRole textRole) const
-{
- if (text.isEmpty())
- return;
- QPen savedPen;
- if (textRole != QPalette::NoRole) {
- savedPen = painter->pen();
- painter->setPen(QPen(pal.brush(textRole), savedPen.widthF()));
- }
- if (!enabled) {
- if (proxy()->styleHint(SH_DitherDisabledText)) {
- QRect br;
- painter->drawText(rect, alignment, text, &br);
- painter->fillRect(br, QBrush(painter->background().color(), Qt::Dense5Pattern));
- return;
- } else if (proxy()->styleHint(SH_EtchDisabledText)) {
- QPen pen = painter->pen();
- painter->setPen(pal.light().color());
- painter->drawText(rect.adjusted(1, 1, 1, 1), alignment, text);
- painter->setPen(pen);
- }
- }
- painter->drawText(rect, alignment, text);
- if (textRole != QPalette::NoRole)
- painter->setPen(savedPen);
-}
-
-/*!
- \fn void QStyle::drawItemPixmap(QPainter *painter, const QRect &rectangle, int alignment,
- const QPixmap &pixmap) const
-
- Draws the given \a pixmap in the specified \a rectangle, according
- to the specified \a alignment, using the provided \a painter.
-
- \sa drawItemText()
-*/
-
-void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
- const QPixmap &pixmap) const
-{
- QRect aligned = alignedRect(QApplication::layoutDirection(), QFlag(alignment), pixmap.size(), rect);
- QRect inter = aligned.intersected(rect);
-
- painter->drawPixmap(inter.x(), inter.y(), pixmap, inter.x() - aligned.x(), inter.y() - aligned.y(), inter.width(), inter.height());
-}
-
-/*!
- \enum QStyle::PrimitiveElement
-
- This enum describes the various primitive elements. A
- primitive element is a common GUI element, such as a checkbox
- indicator or button bevel.
-
- \omitvalue PE_IndicatorViewItemCheck
- \value PE_FrameStatusBar Frame
-
- \value PE_PanelButtonCommand Button used to initiate an action, for
- example, a QPushButton.
-
- \value PE_FrameDefaultButton This frame around a default button, e.g. in a dialog.
- \value PE_PanelButtonBevel Generic panel with a button bevel.
- \value PE_PanelButtonTool Panel for a Tool button, used with QToolButton.
- \value PE_PanelLineEdit Panel for a QLineEdit.
- \value PE_IndicatorButtonDropDown Indicator for a drop down button, for example, a tool
- button that displays a menu.
-
- \value PE_FrameFocusRect Generic focus indicator.
-
- \value PE_IndicatorArrowUp Generic Up arrow.
- \value PE_IndicatorArrowDown Generic Down arrow.
- \value PE_IndicatorArrowRight Generic Right arrow.
- \value PE_IndicatorArrowLeft Generic Left arrow.
-
- \value PE_IndicatorSpinUp Up symbol for a spin widget, for example a QSpinBox.
- \value PE_IndicatorSpinDown Down symbol for a spin widget.
- \value PE_IndicatorSpinPlus Increase symbol for a spin widget.
- \value PE_IndicatorSpinMinus Decrease symbol for a spin widget.
-
- \value PE_IndicatorItemViewItemCheck On/off indicator for a view item.
-
- \value PE_IndicatorCheckBox On/off indicator, for example, a QCheckBox.
- \value PE_IndicatorRadioButton Exclusive on/off indicator, for example, a QRadioButton.
-
- \value PE_Q3DockWindowSeparator Item separator for Qt 3 compatible dock window
- and toolbar contents.
- \value PE_IndicatorDockWidgetResizeHandle Resize handle for dock windows.
-
- \value PE_Frame Generic frame
- \value PE_FrameMenu Frame for popup windows/menus; see also QMenu.
- \value PE_PanelMenuBar Panel for menu bars.
- \value PE_PanelScrollAreaCorner Panel at the bottom-right (or
- bottom-left) corner of a scroll area.
-
- \value PE_FrameDockWidget Panel frame for dock windows and toolbars.
- \value PE_FrameTabWidget Frame for tab widgets.
- \value PE_FrameLineEdit Panel frame for line edits.
- \value PE_FrameGroupBox Panel frame around group boxes.
- \value PE_FrameButtonBevel Panel frame for a button bevel.
- \value PE_FrameButtonTool Panel frame for a tool button.
-
- \value PE_IndicatorHeaderArrow Arrow used to indicate sorting on a list or table
- header.
- \value PE_FrameStatusBarItem Frame for an item of a status bar; see also QStatusBar.
-
- \value PE_FrameWindow Frame around a MDI window or a docking window.
-
- \value PE_Q3Separator Qt 3 compatible generic separator.
-
- \value PE_IndicatorMenuCheckMark Check mark used in a menu.
-
- \value PE_IndicatorProgressChunk Section of a progress bar indicator; see also QProgressBar.
-
- \value PE_Q3CheckListController Qt 3 compatible controller part of a list view item.
- \value PE_Q3CheckListIndicator Qt 3 compatible checkbox part of a list view item.
- \value PE_Q3CheckListExclusiveIndicator Qt 3 compatible radio button part of a list view item.
-
- \value PE_IndicatorBranch Lines used to represent the branch of a tree in a tree view.
- \value PE_IndicatorToolBarHandle The handle of a toolbar.
- \value PE_IndicatorToolBarSeparator The separator in a toolbar.
- \value PE_PanelToolBar The panel for a toolbar.
- \value PE_PanelTipLabel The panel for a tip label.
- \value PE_FrameTabBarBase The frame that is drawn for a tab bar, ususally drawn for a tab bar that isn't part of a tab widget.
- \value PE_IndicatorTabTear An indicator that a tab is partially scrolled out of the visible tab bar when there are many tabs.
- \value PE_IndicatorColumnViewArrow An arrow in a QColumnView.
-
- \value PE_Widget A plain QWidget.
-
- \value PE_CustomBase Base value for custom primitive elements.
- All values above this are reserved for custom use. Custom values
- must be greater than this value.
-
- \value PE_IndicatorItemViewItemDrop An indicator that is drawn to show where an item in an item view is about to be dropped
- during a drag-and-drop operation in an item view.
- \value PE_PanelItemViewItem The background for an item in an item view.
- \value PE_PanelItemViewRow The background of a row in an item view.
-
- \value PE_PanelStatusBar The panel for a status bar.
-
- \value PE_IndicatorTabClose The close button on a tab bar.
- \value PE_PanelMenu The panel for a menu.
-
- \sa drawPrimitive()
-*/
-
-/*!
- \typedef QStyle::SFlags
- \internal
-*/
-
-/*!
- \typedef QStyle::SCFlags
- \internal
-*/
-
-/*!
- \enum QStyle::StateFlag
-
- This enum describes flags that are used when drawing primitive
- elements.
-
- Note that not all primitives use all of these flags, and that the
- flags may mean different things to different items.
-
- \value State_None Indicates that the widget does not have a state.
- \value State_Active Indicates that the widget is active.
- \value State_AutoRaise Used to indicate if auto-raise appearance should be usd on a tool button.
- \value State_Children Used to indicate if an item view branch has children.
- \value State_DownArrow Used to indicate if a down arrow should be visible on the widget.
- \value State_Editing Used to indicate if an editor is opened on the widget.
- \value State_Enabled Used to indicate if the widget is enabled.
- \value State_HasEditFocus Used to indicate if the widget currently has edit focus.
- \value State_HasFocus Used to indicate if the widget has focus.
- \value State_Horizontal Used to indicate if the widget is laid out horizontally, for example. a tool bar.
- \value State_KeyboardFocusChange Used to indicate if the focus was changed with the keyboard, e.g., tab, backtab or shortcut.
- \value State_MouseOver Used to indicate if the widget is under the mouse.
- \value State_NoChange Used to indicate a tri-state checkbox.
- \value State_Off Used to indicate if the widget is not checked.
- \value State_On Used to indicate if the widget is checked.
- \value State_Raised Used to indicate if a button is raised.
- \value State_ReadOnly Used to indicate if a widget is read-only.
- \value State_Selected Used to indicate if a widget is selected.
- \value State_Item Used by item views to indicate if a horizontal branch should be drawn.
- \value State_Open Used by item views to indicate if the tree branch is open.
- \value State_Sibling Used by item views to indicate if a vertical line needs to be drawn (for siblings).
- \value State_Sunken Used to indicate if the widget is sunken or pressed.
- \value State_UpArrow Used to indicate if an up arrow should be visible on the widget.
- \value State_Mini Used to indicate a mini style Mac widget or button.
- \value State_Small Used to indicate a small style Mac widget or button.
- \omitvalue State_Window
- \omitvalue State_Bottom
- \omitvalue State_Default
- \omitvalue State_FocusAtBorder
- \omitvalue State_Top
-
- \sa drawPrimitive()
-*/
-
-/*!
- \fn void QStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, \
- QPainter *painter, const QWidget *widget) const
-
- Draws the given primitive \a element with the provided \a painter using the style
- options specified by \a option.
-
- The \a widget argument is optional and may contain a widget that may
- aid in drawing the primitive element.
-
- The table below is listing the primitive elements and their
- associated style option subclasses. The style options contain all
- the parameters required to draw the elements, including
- QStyleOption::state which holds the style flags that are used when
- drawing. The table also describes which flags that are set when
- casting the given option to the appropriate subclass.
-
- Note that if a primitive element is not listed here, it is because
- it uses a plain QStyleOption object.
-
- \table
- \header \o Primitive Element \o QStyleOption Subclass \o Style Flag \o Remark
- \row \o \l PE_FrameFocusRect \o \l QStyleOptionFocusRect
- \o \l State_FocusAtBorder
- \o Whether the focus is is at the border or inside the widget.
- \row \o{1,2} \l PE_IndicatorCheckBox \o{1,2} \l QStyleOptionButton
- \o \l State_NoChange \o Indicates a "tri-state" checkbox.
- \row \o \l State_On \o Indicates the indicator is checked.
- \row \o \l PE_IndicatorRadioButton \o \l QStyleOptionButton
- \o \l State_On \o Indicates that a radio button is selected.
- \row \o{1,3} \l PE_Q3CheckListExclusiveIndicator, \l PE_Q3CheckListIndicator
- \o{1,3} \l QStyleOptionQ3ListView \o \l State_On
- \o Indicates whether or not the controller is selected.
- \row \o \l State_NoChange \o Indicates a "tri-state" controller.
- \row \o \l State_Enabled \o Indicates the controller is enabled.
- \row \o{1,4} \l PE_IndicatorBranch \o{1,4} \l QStyleOption
- \o \l State_Children \o Indicates that the control for expanding the tree to show child items, should be drawn.
- \row \o \l State_Item \o Indicates that a horizontal branch (to show a child item), should be drawn.
- \row \o \l State_Open \o Indicates that the tree branch is expanded.
- \row \o \l State_Sibling \o Indicates that a vertical line (to show a sibling item), should be drawn.
- \row \o \l PE_IndicatorHeaderArrow \o \l QStyleOptionHeader
- \o \l State_UpArrow \o Indicates that the arrow should be drawn up;
- otherwise it should be down.
- \row \o \l PE_FrameGroupBox, \l PE_Frame, \l PE_FrameLineEdit,
- \l PE_FrameMenu, \l PE_FrameDockWidget, \l PE_FrameWindow
- \o \l QStyleOptionFrame \o \l State_Sunken
- \o Indicates that the Frame should be sunken.
- \row \o \l PE_IndicatorToolBarHandle \o \l QStyleOption
- \o \l State_Horizontal \o Indicates that the window handle is horizontal
- instead of vertical.
- \row \o \l PE_Q3DockWindowSeparator \o \l QStyleOption
- \o \l State_Horizontal \o Indicates that the separator is horizontal
- instead of vertical.
- \row \o \l PE_IndicatorSpinPlus, \l PE_IndicatorSpinMinus, \l PE_IndicatorSpinUp,
- \l PE_IndicatorSpinDown,
- \o \l QStyleOptionSpinBox
- \o \l State_Sunken \o Indicates that the button is pressed.
- \row \o{1,5} \l PE_PanelButtonCommand
- \o{1,5} \l QStyleOptionButton
- \o \l State_Enabled \o Set if the button is enabled.
- \row \o \l State_HasFocus \o Set if the button has input focus.
- \row \o \l State_Raised \o Set if the button is not down, not on and not flat.
- \row \o \l State_On \o Set if the button is a toggle button and is toggled on.
- \row \o \l State_Sunken
- \o Set if the button is down (i.e., the mouse button or the
- space bar is pressed on the button).
- \endtable
-
- \sa drawComplexControl(), drawControl()
-*/
-
-/*!
- \enum QStyle::ControlElement
-
- This enum represents a control element. A control element is a
- part of a widget that performs some action or displays information
- to the user.
-
- \value CE_PushButton A QPushButton, draws CE_PushButtonBevel, CE_PushButtonLabel and PE_FrameFocusRect.
- \value CE_PushButtonBevel The bevel and default indicator of a QPushButton.
- \value CE_PushButtonLabel The label (an icon with text or pixmap) of a QPushButton.
-
- \value CE_DockWidgetTitle Dock window title.
- \value CE_Splitter Splitter handle; see also QSplitter.
-
-
- \value CE_CheckBox A QCheckBox, draws a PE_IndicatorCheckBox, a CE_CheckBoxLabel and a PE_FrameFocusRect.
- \value CE_CheckBoxLabel The label (text or pixmap) of a QCheckBox.
-
- \value CE_RadioButton A QRadioButton, draws a PE_IndicatorRadioButton, a CE_RadioButtonLabel and a PE_FrameFocusRect.
- \value CE_RadioButtonLabel The label (text or pixmap) of a QRadioButton.
-
- \value CE_TabBarTab The tab and label within a QTabBar.
- \value CE_TabBarTabShape The tab shape within a tab bar.
- \value CE_TabBarTabLabel The label within a tab.
-
- \value CE_ProgressBar A QProgressBar, draws CE_ProgressBarGroove, CE_ProgressBarContents and CE_ProgressBarLabel.
- \value CE_ProgressBarGroove The groove where the progress
- indicator is drawn in a QProgressBar.
- \value CE_ProgressBarContents The progress indicator of a QProgressBar.
- \value CE_ProgressBarLabel The text label of a QProgressBar.
-
- \value CE_ToolButtonLabel A tool button's label.
-
- \value CE_MenuBarItem A menu item in a QMenuBar.
- \value CE_MenuBarEmptyArea The empty area of a QMenuBar.
-
- \value CE_MenuItem A menu item in a QMenu.
- \value CE_MenuScroller Scrolling areas in a QMenu when the
- style supports scrolling.
- \value CE_MenuTearoff A menu item representing the tear off section of
- a QMenu.
- \value CE_MenuEmptyArea The area in a menu without menu items.
- \value CE_MenuHMargin The horizontal extra space on the left/right of a menu.
- \value CE_MenuVMargin The vertical extra space on the top/bottom of a menu.
-
- \value CE_Q3DockWindowEmptyArea The empty area of a QDockWidget.
-
- \value CE_ToolBoxTab The toolbox's tab and label within a QToolBox.
- \value CE_SizeGrip Window resize handle; see also QSizeGrip.
-
- \value CE_Header A header.
- \value CE_HeaderSection A header section.
- \value CE_HeaderLabel The header's label.
-
- \value CE_ScrollBarAddLine Scroll bar line increase indicator.
- (i.e., scroll down); see also QScrollBar.
- \value CE_ScrollBarSubLine Scroll bar line decrease indicator (i.e., scroll up).
- \value CE_ScrollBarAddPage Scolllbar page increase indicator (i.e., page down).
- \value CE_ScrollBarSubPage Scroll bar page decrease indicator (i.e., page up).
- \value CE_ScrollBarSlider Scroll bar slider.
- \value CE_ScrollBarFirst Scroll bar first line indicator (i.e., home).
- \value CE_ScrollBarLast Scroll bar last line indicator (i.e., end).
-
- \value CE_RubberBand Rubber band used in for example an icon view.
-
- \value CE_FocusFrame Focus frame that is style controlled.
-
- \value CE_ItemViewItem An item inside an item view.
-
- \value CE_CustomBase Base value for custom control elements;
- custom values must be greater than this value.
- \value CE_ComboBoxLabel The label of a non-editable QComboBox.
- \value CE_ToolBar A toolbar like QToolBar.
- \value CE_ToolBoxTabShape The toolbox's tab shape.
- \value CE_ToolBoxTabLabel The toolbox's tab label.
- \value CE_HeaderEmptyArea The area of a header view where there are no header sections.
-
- \value CE_ShapedFrame The frame with the shape specified in the QStyleOptionFrameV3; see QFrame.
-
- \omitvalue CE_ColumnViewGrip
-
- \sa drawControl()
-*/
-
-/*!
- \fn void QStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
-
- Draws the given \a element with the provided \a painter with the
- style options specified by \a option.
-
- The \a widget argument is optional and can be used as aid in
- drawing the control. The \a option parameter is a pointer to a
- QStyleOption object that can be cast to the correct subclass
- using the qstyleoption_cast() function.
-
- The table below is listing the control elements and their
- associated style option subclass. The style options contain all
- the parameters required to draw the controls, including
- QStyleOption::state which holds the style flags that are used when
- drawing. The table also describes which flags that are set when
- casting the given option to the appropriate subclass.
-
- Note that if a control element is not listed here, it is because
- it uses a plain QStyleOption object.
-
- \table
- \header \o Control Element \o QStyleOption Subclass \o Style Flag \o Remark
- \row \o{1,5} \l CE_MenuItem, \l CE_MenuBarItem
- \o{1,5} \l QStyleOptionMenuItem
- \o \l State_Selected \o The menu item is currently selected item.
- \row \o \l State_Enabled \o The item is enabled.
- \row \o \l State_DownArrow \o Indicates that a scroll down arrow should be drawn.
- \row \o \l State_UpArrow \o Indicates that a scroll up arrow should be drawn
- \row \o \l State_HasFocus \o Set if the menu bar has input focus.
-
- \row \o{1,5} \l CE_PushButton, \l CE_PushButtonBevel, \l CE_PushButtonLabel
- \o{1,5} \l QStyleOptionButton
- \o \l State_Enabled \o Set if the button is enabled.
- \row \o \l State_HasFocus \o Set if the button has input focus.
- \row \o \l State_Raised \o Set if the button is not down, not on and not flat.
- \row \o \l State_On \o Set if the button is a toggle button and is toggled on.
- \row \o \l State_Sunken
- \o Set if the button is down (i.e., the mouse button or the
- space bar is pressed on the button).
-
- \row \o{1,6} \l CE_RadioButton, \l CE_RadioButtonLabel,
- \l CE_CheckBox, \l CE_CheckBoxLabel
- \o{1,6} \l QStyleOptionButton
- \o \l State_Enabled \o Set if the button is enabled.
- \row \o \l State_HasFocus \o Set if the button has input focus.
- \row \o \l State_On \o Set if the button is checked.
- \row \o \l State_Off \o Set if the button is not checked.
- \row \o \l State_NoChange \o Set if the button is in the NoChange state.
- \row \o \l State_Sunken
- \o Set if the button is down (i.e., the mouse button or
- the space bar is pressed on the button).
-
- \row \o{1,2} \l CE_ProgressBarContents, \l CE_ProgressBarLabel,
- \l CE_ProgressBarGroove
- \o{1,2} \l QStyleOptionProgressBar
- \o \l State_Enabled \o Set if the progress bar is enabled.
- \row \o \l State_HasFocus \o Set if the progress bar has input focus.
-
- \row \o \l CE_Header, \l CE_HeaderSection, \l CE_HeaderLabel \o \l QStyleOptionHeader \o \o
-
- \row \o{1,3} \l CE_TabBarTab, CE_TabBarTabShape, CE_TabBarTabLabel
- \o{1,3} \l QStyleOptionTab
- \o \l State_Enabled \o Set if the tab bar is enabled.
- \row \o \l State_Selected \o The tab bar is the currently selected tab bar.
- \row \o \l State_HasFocus \o Set if the tab bar tab has input focus.
-
- \row \o{1,7} \l CE_ToolButtonLabel
- \o{1,7} \l QStyleOptionToolButton
- \o \l State_Enabled \o Set if the tool button is enabled.
- \row \o \l State_HasFocus \o Set if the tool button has input focus.
- \row \o \l State_Sunken
- \o Set if the tool button is down (i.e., a mouse button or
- the space bar is pressed).
- \row \o \l State_On \o Set if the tool button is a toggle button and is toggled on.
- \row \o \l State_AutoRaise \o Set if the tool button has auto-raise enabled.
- \row \o \l State_MouseOver \o Set if the mouse pointer is over the tool button.
- \row \o \l State_Raised \o Set if the button is not down and is not on.
-
- \row \o \l CE_ToolBoxTab \o \l QStyleOptionToolBox
- \o \l State_Selected \o The tab is the currently selected tab.
- \row \o{1,3} \l CE_HeaderSection \o{1,3} \l QStyleOptionHeader
- \o \l State_Sunken \o Indicates that the section is pressed.
- \row \o \l State_UpArrow \o Indicates that the sort indicator should be pointing up.
- \row \o \l State_DownArrow \o Indicates that the sort indicator should be pointing down.
- \endtable
-
- \sa drawPrimitive(), drawComplexControl()
-*/
-
-/*!
- \enum QStyle::SubElement
-
- This enum represents a sub-area of a widget. Style implementations
- use these areas to draw the different parts of a widget.
-
- \value SE_PushButtonContents Area containing the label (icon
- with text or pixmap).
- \value SE_PushButtonFocusRect Area for the focus rect (usually
- larger than the contents rect).
- \value SE_PushButtonLayoutItem Area that counts for the parent layout.
-
- \value SE_CheckBoxIndicator Area for the state indicator (e.g., check mark).
- \value SE_CheckBoxContents Area for the label (text or pixmap).
- \value SE_CheckBoxFocusRect Area for the focus indicator.
- \value SE_CheckBoxClickRect Clickable area, defaults to SE_CheckBoxFocusRect.
- \value SE_CheckBoxLayoutItem Area that counts for the parent layout.
-
- \value SE_DateTimeEditLayoutItem Area that counts for the parent layout.
-
- \value SE_RadioButtonIndicator Area for the state indicator.
- \value SE_RadioButtonContents Area for the label.
- \value SE_RadioButtonFocusRect Area for the focus indicator.
- \value SE_RadioButtonClickRect Clickable area, defaults to SE_RadioButtonFocusRect.
- \value SE_RadioButtonLayoutItem Area that counts for the parent layout.
-
- \value SE_ComboBoxFocusRect Area for the focus indicator.
-
- \value SE_SliderFocusRect Area for the focus indicator.
- \value SE_SliderLayoutItem Area that counts for the parent layout.
-
- \value SE_SpinBoxLayoutItem Area that counts for the parent layout.
-
- \value SE_Q3DockWindowHandleRect Area for the tear-off handle.
-
- \value SE_ProgressBarGroove Area for the groove.
- \value SE_ProgressBarContents Area for the progress indicator.
- \value SE_ProgressBarLabel Area for the text label.
- \value SE_ProgressBarLayoutItem Area that counts for the parent layout.
-
- \omitvalue SE_DialogButtonAccept
- \omitvalue SE_DialogButtonReject
- \omitvalue SE_DialogButtonApply
- \omitvalue SE_DialogButtonHelp
- \omitvalue SE_DialogButtonAll
- \omitvalue SE_DialogButtonRetry
- \omitvalue SE_DialogButtonAbort
- \omitvalue SE_DialogButtonIgnore
- \omitvalue SE_DialogButtonCustom
- \omitvalue SE_ViewItemCheckIndicator
-
- \value SE_FrameContents Area for a frame's contents.
- \value SE_ShapedFrameContents Area for a frame's contents using the shape in QStyleOptionFrameV3; see QFrame
- \value SE_FrameLayoutItem Area that counts for the parent layout.
-
- \value SE_HeaderArrow Area for the sort indicator for a header.
- \value SE_HeaderLabel Area for the label in a header.
-
- \value SE_LabelLayoutItem Area that counts for the parent layout.
-
- \value SE_LineEditContents Area for a line edit's contents.
-
- \value SE_TabWidgetLeftCorner Area for the left corner widget in a tab widget.
- \value SE_TabWidgetRightCorner Area for the right corner widget in a tab widget.
- \value SE_TabWidgetTabBar Area for the tab bar widget in a tab widget.
- \value SE_TabWidgetTabContents Area for the contents of the tab widget.
- \value SE_TabWidgetTabPane Area for the pane of a tab widget.
- \value SE_TabWidgetLayoutItem Area that counts for the parent layout.
-
- \value SE_ToolBoxTabContents Area for a toolbox tab's icon and label.
-
- \value SE_ToolButtonLayoutItem Area that counts for the parent layout.
-
- \value SE_ItemViewItemCheckIndicator Area for a view item's check mark.
-
- \value SE_TabBarTearIndicator Area for the tear indicator on a tab bar with scroll arrows.
-
- \value SE_TreeViewDisclosureItem Area for the actual disclosure item in a tree branch.
-
- \value SE_DialogButtonBoxLayoutItem Area that counts for the parent layout.
-
- \value SE_GroupBoxLayoutItem Area that counts for the parent layout.
-
- \value SE_CustomBase Base value for custom sub-elements.
- Custom values must be greater than this value.
-
- \value SE_DockWidgetFloatButton The float button of a dock
- widget.
- \value SE_DockWidgetTitleBarText The text bounds of the dock
- widgets title.
- \value SE_DockWidgetCloseButton The close button of a dock
- widget.
- \value SE_DockWidgetIcon The icon of a dock widget.
- \value SE_ComboBoxLayoutItem Area that counts for the parent layout.
-
-
- \value SE_ItemViewItemDecoration Area for a view item's decoration (icon).
- \value SE_ItemViewItemText Area for a view item's text.
- \value SE_ItemViewItemFocusRect Area for a view item's focus rect.
-
- \value SE_TabBarTabLeftButton Area for a widget on the left side of a tab in a tab bar.
- \value SE_TabBarTabRightButton Area for a widget on the right side of a tab in a tab bar.
- \value SE_TabBarTabText Area for the text on a tab in a tab bar.
-
- \value SE_ToolBarHandle Area for the handle of a tool bar.
-
- \sa subElementRect()
-*/
-
-/*!
- \fn QRect QStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const
-
- Returns the sub-area for the given \a element as described in the
- provided style \a option. The returned rectangle is defined in
- screen coordinates.
-
- The \a widget argument is optional and can be used to aid
- determining the area. The QStyleOption object can be cast to the
- appropriate type using the qstyleoption_cast() function. See the
- table below for the appropriate \a option casts:
-
- \table
- \header \o Sub Element \o QStyleOption Subclass
- \row \o \l SE_PushButtonContents \o \l QStyleOptionButton
- \row \o \l SE_PushButtonFocusRect \o \l QStyleOptionButton
- \row \o \l SE_CheckBoxIndicator \o \l QStyleOptionButton
- \row \o \l SE_CheckBoxContents \o \l QStyleOptionButton
- \row \o \l SE_CheckBoxFocusRect \o \l QStyleOptionButton
- \row \o \l SE_RadioButtonIndicator \o \l QStyleOptionButton
- \row \o \l SE_RadioButtonContents \o \l QStyleOptionButton
- \row \o \l SE_RadioButtonFocusRect \o \l QStyleOptionButton
- \row \o \l SE_ComboBoxFocusRect \o \l QStyleOptionComboBox
- \row \o \l SE_Q3DockWindowHandleRect \o \l QStyleOptionQ3DockWindow
- \row \o \l SE_ProgressBarGroove \o \l QStyleOptionProgressBar
- \row \o \l SE_ProgressBarContents \o \l QStyleOptionProgressBar
- \row \o \l SE_ProgressBarLabel \o \l QStyleOptionProgressBar
- \endtable
-*/
-
-/*!
- \enum QStyle::ComplexControl
-
- This enum describes the available complex controls. Complex
- controls have different behavior depending upon where the user
- clicks on them or which keys are pressed.
-
- \value CC_SpinBox A spinbox, like QSpinBox.
- \value CC_ComboBox A combobox, like QComboBox.
- \value CC_ScrollBar A scroll bar, like QScrollBar.
- \value CC_Slider A slider, like QSlider.
- \value CC_ToolButton A tool button, like QToolButton.
- \value CC_TitleBar A Title bar, like those used in QMdiSubWindow.
- \value CC_Q3ListView Used for drawing the Q3ListView class.
- \value CC_GroupBox A group box, like QGroupBox.
- \value CC_Dial A dial, like QDial.
- \value CC_MdiControls The minimize, close, and normal
- button in the menu bar for a
- maximized MDI subwindow.
-
- \value CC_CustomBase Base value for custom complex controls. Custom
- values must be greater than this value.
-
- \sa SubControl drawComplexControl()
-*/
-
-/*!
- \enum QStyle::SubControl
-
- This enum describes the available sub controls. A subcontrol is a
- control element within a complex control (ComplexControl).
-
- \value SC_None Special value that matches no other sub control.
-
- \value SC_ScrollBarAddLine Scroll bar add line (i.e., down/right
- arrow); see also QScrollBar.
- \value SC_ScrollBarSubLine Scroll bar sub line (i.e., up/left arrow).
- \value SC_ScrollBarAddPage Scroll bar add page (i.e., page down).
- \value SC_ScrollBarSubPage Scroll bar sub page (i.e., page up).
- \value SC_ScrollBarFirst Scroll bar first line (i.e., home).
- \value SC_ScrollBarLast Scroll bar last line (i.e., end).
- \value SC_ScrollBarSlider Scroll bar slider handle.
- \value SC_ScrollBarGroove Special sub-control which contains the
- area in which the slider handle may move.
-
- \value SC_SpinBoxUp Spin widget up/increase; see also QSpinBox.
- \value SC_SpinBoxDown Spin widget down/decrease.
- \value SC_SpinBoxFrame Spin widget frame.
- \value SC_SpinBoxEditField Spin widget edit field.
-
- \value SC_ComboBoxEditField Combobox edit field; see also QComboBox.
- \value SC_ComboBoxArrow Combobox arrow button.
- \value SC_ComboBoxFrame Combobox frame.
- \value SC_ComboBoxListBoxPopup The reference rectangle for the combobox popup.
- Used to calculate the position of the popup.
-
- \value SC_SliderGroove Special sub-control which contains the area
- in which the slider handle may move.
- \value SC_SliderHandle Slider handle.
- \value SC_SliderTickmarks Slider tickmarks.
-
- \value SC_ToolButton Tool button (see also QToolButton).
- \value SC_ToolButtonMenu Sub-control for opening a popup menu in a
- tool button; see also Q3PopupMenu.
-
- \value SC_TitleBarSysMenu System menu button (i.e., restore, close, etc.).
- \value SC_TitleBarMinButton Minimize button.
- \value SC_TitleBarMaxButton Maximize button.
- \value SC_TitleBarCloseButton Close button.
- \value SC_TitleBarLabel Window title label.
- \value SC_TitleBarNormalButton Normal (restore) button.
- \value SC_TitleBarShadeButton Shade button.
- \value SC_TitleBarUnshadeButton Unshade button.
- \value SC_TitleBarContextHelpButton Context Help button.
-
- \value SC_Q3ListView The list view area.
- \value SC_Q3ListViewExpand Expand item (i.e., show/hide child items).
-
- \value SC_DialHandle The handle of the dial (i.e. what you use to control the dial).
- \value SC_DialGroove The groove for the dial.
- \value SC_DialTickmarks The tickmarks for the dial.
-
- \value SC_GroupBoxFrame The frame of a group box.
- \value SC_GroupBoxLabel The title of a group box.
- \value SC_GroupBoxCheckBox The optional check box of a group box.
- \value SC_GroupBoxContents The group box contents.
-
- \value SC_MdiNormalButton The normal button for a MDI
- subwindow in the menu bar.
- \value SC_MdiMinButton The minimize button for a MDI
- subwindow in the menu bar.
- \value SC_MdiCloseButton The close button for a MDI subwindow
- in the menu bar.
-
- \value SC_All Special value that matches all sub-controls.
- \omitvalue SC_Q3ListViewBranch
- \omitvalue SC_CustomBase
-
- \sa ComplexControl
-*/
-
-/*!
- \fn void QStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const
-
- Draws the given \a control using the provided \a painter with the
- style options specified by \a option.
-
- The \a widget argument is optional and can be used as aid in
- drawing the control.
-
- The \a option parameter is a pointer to a QStyleOptionComplex
- object that can be cast to the correct subclass using the
- qstyleoption_cast() function. Note that the \c rect member of the
- specified \a option must be in logical
- coordinates. Reimplementations of this function should use
- visualRect() to change the logical coordinates into screen
- coordinates before calling the drawPrimitive() or drawControl()
- function.
-
- The table below is listing the complex control elements and their
- associated style option subclass. The style options contain all
- the parameters required to draw the controls, including
- QStyleOption::state which holds the \l {QStyle::StateFlag}{style
- flags} that are used when drawing. The table also describes which
- flags that are set when casting the given \a option to the
- appropriate subclass.
-
- \table
- \header \o Complex Control \o QStyleOptionComplex Subclass \o Style Flag \o Remark
- \row \o{1,2} \l{CC_SpinBox} \o{1,2} \l QStyleOptionSpinBox
- \o \l State_Enabled \o Set if the spin box is enabled.
- \row \o \l State_HasFocus \o Set if the spin box has input focus.
-
- \row \o{1,2} \l {CC_ComboBox} \o{1,2} \l QStyleOptionComboBox
- \o \l State_Enabled \o Set if the combobox is enabled.
- \row \o \l State_HasFocus \o Set if the combobox has input focus.
-
- \row \o{1,2} \l {CC_ScrollBar} \o{1,2} \l QStyleOptionSlider
- \o \l State_Enabled \o Set if the scroll bar is enabled.
- \row \o \l State_HasFocus \o Set if the scroll bar has input focus.
-
- \row \o{1,2} \l {CC_Slider} \o{1,2} \l QStyleOptionSlider
- \o \l State_Enabled \o Set if the slider is enabled.
- \row \o \l State_HasFocus \o Set if the slider has input focus.
-
- \row \o{1,2} \l {CC_Dial} \o{1,2} \l QStyleOptionSlider
- \o \l State_Enabled \o Set if the dial is enabled.
- \row \o \l State_HasFocus \o Set if the dial has input focus.
-
- \row \o{1,6} \l {CC_ToolButton} \o{1,6} \l QStyleOptionToolButton
- \o \l State_Enabled \o Set if the tool button is enabled.
- \row \o \l State_HasFocus \o Set if the tool button has input focus.
- \row \o \l State_DownArrow \o Set if the tool button is down (i.e., a mouse
- button or the space bar is pressed).
- \row \o \l State_On \o Set if the tool button is a toggle button
- and is toggled on.
- \row \o \l State_AutoRaise \o Set if the tool button has auto-raise enabled.
- \row \o \l State_Raised \o Set if the button is not down, not on, and doesn't
- contain the mouse when auto-raise is enabled.
-
- \row \o \l{CC_TitleBar} \o \l QStyleOptionTitleBar
- \o \l State_Enabled \o Set if the title bar is enabled.
-
- \row \o \l{CC_Q3ListView} \o \l QStyleOptionQ3ListView
- \o \l State_Enabled \o Set if the list view is enabled.
-
- \endtable
-
- \sa drawPrimitive(), drawControl()
-*/
-
-
-/*!
- \fn QRect QStyle::subControlRect(ComplexControl control,
- const QStyleOptionComplex *option, SubControl subControl,
- const QWidget *widget) const = 0
-
- Returns the rectangle containing the specified \a subControl of
- the given complex \a control (with the style specified by \a
- option). The rectangle is defined in screen coordinates.
-
- The \a option argument is a pointer to QStyleOptionComplex or
- one of its subclasses, and can be cast to the appropriate type
- using the qstyleoption_cast() function. See drawComplexControl()
- for details. The \a widget is optional and can contain additional
- information for the function.
-
- \sa drawComplexControl()
-*/
-
-/*!
- \fn QStyle::SubControl QStyle::hitTestComplexControl(ComplexControl control,
- const QStyleOptionComplex *option, const QPoint &position,
- const QWidget *widget) const = 0
-
- Returns the sub control at the given \a position in the given
- complex \a control (with the style options specified by \a
- option).
-
- Note that the \a position is expressed in screen coordinates.
-
- The \a option argument is a pointer to a QStyleOptionComplex
- object (or one of its subclasses). The object can be cast to the
- appropriate type using the qstyleoption_cast() function. See
- drawComplexControl() for details. The \a widget argument is
- optional and can contain additional information for the function.
-
- \sa drawComplexControl(), subControlRect()
-*/
-
-/*!
- \enum QStyle::PixelMetric
-
- This enum describes the various available pixel metrics. A pixel
- metric is a style dependent size represented by a single pixel
- value.
-
- \value PM_ButtonMargin Amount of whitespace between push button
- labels and the frame.
- \value PM_DockWidgetTitleBarButtonMargin Amount of whitespace between dock widget's
- title bar button labels and the frame.
- \value PM_ButtonDefaultIndicator Width of the default-button indicator frame.
- \value PM_MenuButtonIndicator Width of the menu button indicator
- proportional to the widget height.
- \value PM_ButtonShiftHorizontal Horizontal contents shift of a
- button when the button is down.
- \value PM_ButtonShiftVertical Vertical contents shift of a button when the
- button is down.
-
- \value PM_DefaultFrameWidth Default frame width (usually 2).
- \value PM_SpinBoxFrameWidth Frame width of a spin box, defaults to PM_DefaultFrameWidth.
- \value PM_ComboBoxFrameWidth Frame width of a combo box, defaults to PM_DefaultFrameWidth.
-
- \value PM_MDIFrameWidth Obsolete. Use PM_MdiSubWindowFrameWidth instead.
- \value PM_MdiSubWindowFrameWidth Frame width of an MDI window.
- \value PM_MDIMinimizedWidth Obsolete. Use PM_MdiSubWindowMinimizedWidth instead.
- \value PM_MdiSubWindowMinimizedWidth Width of a minimized MDI window.
-
- \value PM_LayoutLeftMargin Default \l{QLayout::setContentsMargins()}{left margin} for a
- QLayout.
- \value PM_LayoutTopMargin Default \l{QLayout::setContentsMargins()}{top margin} for a QLayout.
- \value PM_LayoutRightMargin Default \l{QLayout::setContentsMargins()}{right margin} for a
- QLayout.
- \value PM_LayoutBottomMargin Default \l{QLayout::setContentsMargins()}{bottom margin} for a
- QLayout.
- \value PM_LayoutHorizontalSpacing Default \l{QLayout::spacing}{horizontal spacing} for a
- QLayout.
- \value PM_LayoutVerticalSpacing Default \l{QLayout::spacing}{vertical spacing} for a QLayout.
-
- \value PM_MaximumDragDistance The maximum allowed distance between
- the mouse and a scrollbar when dragging. Exceeding the specified
- distance will cause the slider to jump back to the original
- position; a value of -1 disables this behavior.
-
- \value PM_ScrollBarExtent Width of a vertical scroll bar and the
- height of a horizontal scroll bar.
- \value PM_ScrollBarSliderMin The minimum height of a vertical
- scroll bar's slider and the minimum width of a horizontal
- scroll bar's slider.
-
- \value PM_SliderThickness Total slider thickness.
- \value PM_SliderControlThickness Thickness of the slider handle.
- \value PM_SliderLength Length of the slider.
- \value PM_SliderTickmarkOffset The offset between the tickmarks
- and the slider.
- \value PM_SliderSpaceAvailable The available space for the slider to move.
-
- \value PM_DockWidgetSeparatorExtent Width of a separator in a
- horizontal dock window and the height of a separator in a
- vertical dock window.
- \value PM_DockWidgetHandleExtent Width of the handle in a
- horizontal dock window and the height of the handle in a
- vertical dock window.
- \value PM_DockWidgetFrameWidth Frame width of a dock window.
- \value PM_DockWidgetTitleMargin Margin of the dock window title.
-
- \value PM_MenuBarPanelWidth Frame width of a menu bar, defaults to PM_DefaultFrameWidth.
- \value PM_MenuBarItemSpacing Spacing between menu bar items.
- \value PM_MenuBarHMargin Spacing between menu bar items and left/right of bar.
- \value PM_MenuBarVMargin Spacing between menu bar items and top/bottom of bar.
-
- \value PM_ToolBarFrameWidth Width of the frame around toolbars.
- \value PM_ToolBarHandleExtent Width of a toolbar handle in a
- horizontal toolbar and the height of the handle in a vertical toolbar.
- \value PM_ToolBarItemMargin Spacing between the toolbar frame and the items.
- \value PM_ToolBarItemSpacing Spacing between toolbar items.
- \value PM_ToolBarSeparatorExtent Width of a toolbar separator in a
- horizontal toolbar and the height of a separator in a vertical toolbar.
- \value PM_ToolBarExtensionExtent Width of a toolbar extension
- button in a horizontal toolbar and the height of the button in a
- vertical toolbar.
-
- \value PM_TabBarTabOverlap Number of pixels the tabs should overlap.
- (Currently only used in styles, not inside of QTabBar)
- \value PM_TabBarTabHSpace Extra space added to the tab width.
- \value PM_TabBarTabVSpace Extra space added to the tab height.
- \value PM_TabBarBaseHeight Height of the area between the tab bar
- and the tab pages.
- \value PM_TabBarBaseOverlap Number of pixels the tab bar overlaps
- the tab bar base.
- \value PM_TabBarScrollButtonWidth
- \value PM_TabBarTabShiftHorizontal Horizontal pixel shift when a
- tab is selected.
- \value PM_TabBarTabShiftVertical Vertical pixel shift when a
- tab is selected.
-
- \value PM_ProgressBarChunkWidth Width of a chunk in a progress bar indicator.
-
- \value PM_SplitterWidth Width of a splitter.
-
- \value PM_TitleBarHeight Height of the title bar.
-
- \value PM_IndicatorWidth Width of a check box indicator.
- \value PM_IndicatorHeight Height of a checkbox indicator.
- \value PM_ExclusiveIndicatorWidth Width of a radio button indicator.
- \value PM_ExclusiveIndicatorHeight Height of a radio button indicator.
-
- \value PM_MenuPanelWidth Border width (applied on all sides) for a QMenu.
- \value PM_MenuHMargin Additional border (used on left and right) for a QMenu.
- \value PM_MenuVMargin Additional border (used for bottom and top) for a QMenu.
- \value PM_MenuScrollerHeight Height of the scroller area in a QMenu.
- \value PM_MenuTearoffHeight Height of a tear off area in a QMenu.
- \value PM_MenuDesktopFrameWidth The frame width for the menu on the desktop.
-
- \value PM_CheckListButtonSize Area (width/height) of the
- checkbox/radio button in a Q3CheckListItem.
- \value PM_CheckListControllerSize Area (width/height) of the
- controller in a Q3CheckListItem.
-
- \omitvalue PM_DialogButtonsSeparator
- \omitvalue PM_DialogButtonsButtonWidth
- \omitvalue PM_DialogButtonsButtonHeight
-
- \value PM_HeaderMarkSize The size of the sort indicator in a header.
- \value PM_HeaderGripMargin The size of the resize grip in a header.
- \value PM_HeaderMargin The size of the margin between the sort indicator and the text.
- \value PM_SpinBoxSliderHeight The height of the optional spin box slider.
-
- \value PM_ToolBarIconSize Default tool bar icon size
- \value PM_SmallIconSize Default small icon size
- \value PM_LargeIconSize Default large icon size
-
- \value PM_FocusFrameHMargin Horizontal margin that the focus frame will outset the widget by.
- \value PM_FocusFrameVMargin Vertical margin that the focus frame will outset the widget by.
- \value PM_IconViewIconSize The default size for icons in an icon view.
- \value PM_ListViewIconSize The default size for icons in a list view.
-
- \value PM_ToolTipLabelFrameWidth The frame width for a tool tip label.
- \value PM_CheckBoxLabelSpacing The spacing between a check box indicator and its label.
- \value PM_RadioButtonLabelSpacing The spacing between a radio button indicator and its label.
- \value PM_TabBarIconSize The default icon size for a tab bar.
- \value PM_SizeGripSize The size of a size grip.
- \value PM_MessageBoxIconSize The size of the standard icons in a message box
- \value PM_ButtonIconSize The default size of button icons
- \value PM_TextCursorWidth The width of the cursor in a line edit or text edit
- \value PM_TabBar_ScrollButtonOverlap The distance between the left and right buttons in a tab bar.
-
- \value PM_TabCloseIndicatorWidth The default width of a close button on a tab in a tab bar.
- \value PM_TabCloseIndicatorHeight The default height of a close button on a tab in a tab bar.
-
- \value PM_CustomBase Base value for custom pixel metrics. Custom
- values must be greater than this value.
-
- The following values are obsolete:
-
- \value PM_DefaultTopLevelMargin Use PM_LayoutLeftMargin,
- PM_LayoutTopMargin,
- PM_LayoutRightMargin, and
- PM_LayoutBottomMargin instead.
- \value PM_DefaultChildMargin Use PM_LayoutLeftMargin,
- PM_LayoutTopMargin,
- PM_LayoutRightMargin, and
- PM_LayoutBottomMargin instead.
- \value PM_DefaultLayoutSpacing Use PM_LayoutHorizontalSpacing
- and PM_LayoutVerticalSpacing
- instead.
-
- \value PM_ScrollView_ScrollBarSpacing Distance between frame and scrollbar
- with SH_ScrollView_FrameOnlyAroundContents set.
- \value PM_SubMenuOverlap The horizontal overlap between a submenu and its parent.
-
-
- \sa pixelMetric()
-*/
-
-/*!
- \fn int QStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const;
-
- Returns the value of the given pixel \a metric.
-
- The specified \a option and \a widget can be used for calculating
- the metric. In general, the \a widget argument is not used. The \a
- option can be cast to the appropriate type using the
- qstyleoption_cast() function. Note that the \a option may be zero
- even for PixelMetrics that can make use of it. See the table below
- for the appropriate \a option casts:
-
- \table
- \header \o Pixel Metric \o QStyleOption Subclass
- \row \o \l PM_SliderControlThickness \o \l QStyleOptionSlider
- \row \o \l PM_SliderLength \o \l QStyleOptionSlider
- \row \o \l PM_SliderTickmarkOffset \o \l QStyleOptionSlider
- \row \o \l PM_SliderSpaceAvailable \o \l QStyleOptionSlider
- \row \o \l PM_ScrollBarExtent \o \l QStyleOptionSlider
- \row \o \l PM_TabBarTabOverlap \o \l QStyleOptionTab
- \row \o \l PM_TabBarTabHSpace \o \l QStyleOptionTab
- \row \o \l PM_TabBarTabVSpace \o \l QStyleOptionTab
- \row \o \l PM_TabBarBaseHeight \o \l QStyleOptionTab
- \row \o \l PM_TabBarBaseOverlap \o \l QStyleOptionTab
- \endtable
-
- Some pixel metrics are called from widgets and some are only called
- internally by the style. If the metric is not called by a widget, it is the
- discretion of the style author to make use of it. For some styles, this
- may not be appropriate.
-*/
-
-/*!
- \enum QStyle::ContentsType
-
- This enum describes the available contents types. These are used to
- calculate sizes for the contents of various widgets.
-
- \value CT_CheckBox A check box, like QCheckBox.
- \value CT_ComboBox A combo box, like QComboBox.
- \omitvalue CT_DialogButtons
- \value CT_Q3DockWindow A Q3DockWindow.
- \value CT_HeaderSection A header section, like QHeader.
- \value CT_LineEdit A line edit, like QLineEdit.
- \value CT_Menu A menu, like QMenu.
- \value CT_Q3Header A Qt 3 header section, like Q3Header.
- \value CT_MenuBar A menu bar, like QMenuBar.
- \value CT_MenuBarItem A menu bar item, like the buttons in a QMenuBar.
- \value CT_MenuItem A menu item, like QMenuItem.
- \value CT_ProgressBar A progress bar, like QProgressBar.
- \value CT_PushButton A push button, like QPushButton.
- \value CT_RadioButton A radio button, like QRadioButton.
- \value CT_SizeGrip A size grip, like QSizeGrip.
- \value CT_Slider A slider, like QSlider.
- \value CT_ScrollBar A scroll bar, like QScrollBar.
- \value CT_SpinBox A spin box, like QSpinBox.
- \value CT_Splitter A splitter, like QSplitter.
- \value CT_TabBarTab A tab on a tab bar, like QTabBar.
- \value CT_TabWidget A tab widget, like QTabWidget.
- \value CT_ToolButton A tool button, like QToolButton.
- \value CT_GroupBox A group box, like QGroupBox.
- \value CT_ItemViewItem An item inside an item view.
-
- \value CT_CustomBase Base value for custom contents types.
- Custom values must be greater than this value.
-
- \value CT_MdiControls The minimize, normal, and close button
- in the menu bar for a maximized MDI
- subwindow.
-
- \sa sizeFromContents()
-*/
-
-/*!
- \fn QSize QStyle::sizeFromContents(ContentsType type, const QStyleOption *option, \
- const QSize &contentsSize, const QWidget *widget) const
-
- Returns the size of the element described by the specified
- \a option and \a type, based on the provided \a contentsSize.
-
- The \a option argument is a pointer to a QStyleOption or one of
- its subclasses. The \a option can be cast to the appropriate type
- using the qstyleoption_cast() function. The \a widget is an
- optional argument and can contain extra information used for
- calculating the size.
-
- See the table below for the appropriate \a option casts:
-
- \table
- \header \o Contents Type \o QStyleOption Subclass
- \row \o \l CT_PushButton \o \l QStyleOptionButton
- \row \o \l CT_CheckBox \o \l QStyleOptionButton
- \row \o \l CT_RadioButton \o \l QStyleOptionButton
- \row \o \l CT_ToolButton \o \l QStyleOptionToolButton
- \row \o \l CT_ComboBox \o \l QStyleOptionComboBox
- \row \o \l CT_Splitter \o \l QStyleOption
- \row \o \l CT_Q3DockWindow \o \l QStyleOptionQ3DockWindow
- \row \o \l CT_ProgressBar \o \l QStyleOptionProgressBar
- \row \o \l CT_MenuItem \o \l QStyleOptionMenuItem
- \endtable
-
- \sa ContentsType QStyleOption
-*/
-
-/*!
- \enum QStyle::RequestSoftwareInputPanel
-
- This enum describes under what circumstances a software input panel will be
- requested by input capable widgets.
-
- \value RSIP_OnMouseClickAndAlreadyFocused Requests an input panel if the user
- clicks on the widget, but only if it is already focused.
- \value RSIP_OnMouseClick Requests an input panel if the user clicks on the
- widget.
-
- \sa QEvent::RequestSoftwareInputPanel, QInputContext
-*/
-
-/*!
- \enum QStyle::StyleHint
-
- This enum describes the available style hints. A style hint is a general look
- and/or feel hint.
-
- \value SH_EtchDisabledText Disabled text is "etched" as it is on Windows.
-
- \value SH_DitherDisabledText Disabled text is dithered as it is on Motif.
-
- \value SH_GUIStyle The GUI style to use.
-
- \value SH_ScrollBar_ContextMenu Whether or not a scroll bar has a context menu.
-
- \value SH_ScrollBar_MiddleClickAbsolutePosition A boolean value.
- If true, middle clicking on a scroll bar causes the slider to
- jump to that position. If false, middle clicking is
- ignored.
-
- \value SH_ScrollBar_LeftClickAbsolutePosition A boolean value.
- If true, left clicking on a scroll bar causes the slider to
- jump to that position. If false, left clicking will
- behave as appropriate for each control.
-
- \value SH_ScrollBar_ScrollWhenPointerLeavesControl A boolean
- value. If true, when clicking a scroll bar SubControl, holding
- the mouse button down and moving the pointer outside the
- SubControl, the scroll bar continues to scroll. If false, the
- scollbar stops scrolling when the pointer leaves the
- SubControl.
-
- \value SH_ScrollBar_RollBetweenButtons A boolean value.
- If true, when clicking a scroll bar button (SC_ScrollBarAddLine or
- SC_ScrollBarSubLine) and dragging over to the opposite button (rolling)
- will press the new button and release the old one. When it is false, the
- original button is released and nothing happens (like a push button).
-
- \value SH_TabBar_Alignment The alignment for tabs in a
- QTabWidget. Possible values are Qt::AlignLeft,
- Qt::AlignCenter and Qt::AlignRight.
-
- \value SH_Header_ArrowAlignment The placement of the sorting
- indicator may appear in list or table headers. Possible values
- are Qt::Left or Qt::Right.
-
- \value SH_Slider_SnapToValue Sliders snap to values while moving,
- as they do on Windows.
-
- \value SH_Slider_SloppyKeyEvents Key presses handled in a sloppy
- manner, i.e., left on a vertical slider subtracts a line.
-
- \value SH_ProgressDialog_CenterCancelButton Center button on
- progress dialogs, like Motif, otherwise right aligned.
-
- \value SH_ProgressDialog_TextLabelAlignment The alignment for text
- labels in progress dialogs; Qt::AlignCenter on Windows,
- Qt::AlignVCenter otherwise.
-
- \value SH_PrintDialog_RightAlignButtons Right align buttons in
- the print dialog, as done on Windows.
-
- \value SH_MainWindow_SpaceBelowMenuBar One or two pixel space between
- the menu bar and the dockarea, as done on Windows.
-
- \value SH_FontDialog_SelectAssociatedText Select the text in the
- line edit, or when selecting an item from the listbox, or when
- the line edit receives focus, as done on Windows.
-
- \value SH_Menu_KeyboardSearch Typing causes a menu to be search
- for relevant items, otherwise only mnemnonic is considered.
-
- \value SH_Menu_AllowActiveAndDisabled Allows disabled menu
- items to be active.
-
- \value SH_Menu_SpaceActivatesItem Pressing the space bar activates
- the item, as done on Motif.
-
- \value SH_Menu_SubMenuPopupDelay The number of milliseconds
- to wait before opening a submenu (256 on Windows, 96 on Motif).
-
- \value SH_Menu_Scrollable Whether popup menus must support scrolling.
-
- \value SH_Menu_SloppySubMenus Whether popupmenu's must support
- sloppy submenu; as implemented on Mac OS.
-
- \value SH_ScrollView_FrameOnlyAroundContents Whether scrollviews
- draw their frame only around contents (like Motif), or around
- contents, scroll bars and corner widgets (like Windows).
-
- \value SH_MenuBar_AltKeyNavigation Menu bars items are navigable
- by pressing Alt, followed by using the arrow keys to select
- the desired item.
-
- \value SH_ComboBox_ListMouseTracking Mouse tracking in combobox
- drop-down lists.
-
- \value SH_Menu_MouseTracking Mouse tracking in popup menus.
-
- \value SH_MenuBar_MouseTracking Mouse tracking in menu bars.
-
- \value SH_Menu_FillScreenWithScroll Whether scrolling popups
- should fill the screen as they are scrolled.
-
- \value SH_Menu_SelectionWrap Whether popups should allow the selections
- to wrap, that is when selection should the next item be the first item.
-
- \value SH_ItemView_ChangeHighlightOnFocus Gray out selected items
- when losing focus.
-
- \value SH_Widget_ShareActivation Turn on sharing activation with
- floating modeless dialogs.
-
- \value SH_TabBar_SelectMouseType Which type of mouse event should
- cause a tab to be selected.
-
- \value SH_Q3ListViewExpand_SelectMouseType Which type of mouse event should
- cause a list view expansion to be selected.
-
- \value SH_TabBar_PreferNoArrows Whether a tab bar should suggest a size
- to prevent scoll arrows.
-
- \value SH_ComboBox_Popup Allows popups as a combobox drop-down
- menu.
-
- \value SH_Workspace_FillSpaceOnMaximize The workspace should
- maximize the client area.
-
- \value SH_TitleBar_NoBorder The title bar has no border.
-
- \value SH_ScrollBar_StopMouseOverSlider Obsolete. Use
- SH_Slider_StopMouseOverSlider instead.
-
- \value SH_Slider_StopMouseOverSlider Stops auto-repeat when
- the slider reaches the mouse position.
-
- \value SH_BlinkCursorWhenTextSelected Whether cursor should blink
- when text is selected.
-
- \value SH_RichText_FullWidthSelection Whether richtext selections
- should extend to the full width of the document.
-
- \value SH_GroupBox_TextLabelVerticalAlignment How to vertically align a
- group box's text label.
-
- \value SH_GroupBox_TextLabelColor How to paint a group box's text label.
-
- \value SH_DialogButtons_DefaultButton Which button gets the
- default status in a dialog's button widget.
-
- \value SH_ToolBox_SelectedPageTitleBold Boldness of the selected
- page title in a QToolBox.
-
- \value SH_LineEdit_PasswordCharacter The Unicode character to be
- used for passwords.
-
- \value SH_Table_GridLineColor The RGB value of the grid for a table.
-
- \value SH_UnderlineShortcut Whether shortcuts are underlined.
-
- \value SH_SpellCheckUnderlineStyle A
- QTextCharFormat::UnderlineStyle value that specifies the way
- misspelled words should be underlined.
-
- \value SH_SpinBox_AnimateButton Animate a click when up or down is
- pressed in a spin box.
- \value SH_SpinBox_KeyPressAutoRepeatRate Auto-repeat interval for
- spinbox key presses.
- \value SH_SpinBox_ClickAutoRepeatRate Auto-repeat interval for
- spinbox mouse clicks.
- \value SH_SpinBox_ClickAutoRepeatThreshold Auto-repeat threshold for
- spinbox mouse clicks.
- \value SH_ToolTipLabel_Opacity An integer indicating the opacity for
- the tip label, 0 is completely transparent, 255 is completely
- opaque.
- \value SH_DrawMenuBarSeparator Indicates whether or not the menu bar draws separators.
- \value SH_TitleBar_ModifyNotification Indicates if the title bar should show
- a '*' for windows that are modified.
-
- \value SH_Button_FocusPolicy The default focus policy for buttons.
-
- \value SH_CustomBase Base value for custom style hints.
- Custom values must be greater than this value.
-
- \value SH_MenuBar_DismissOnSecondClick A boolean indicating if a menu in
- the menu bar should be dismissed when it is clicked on a second time. (Example:
- Clicking and releasing on the File Menu in a menu bar and then
- immediately clicking on the File Menu again.)
-
- \value SH_MessageBox_UseBorderForButtonSpacing A boolean indicating what the to
- use the border of the buttons (computed as half the button height) for the spacing
- of the button in a message box.
-
- \value SH_MessageBox_CenterButtons A boolean indicating whether the buttons in the
- message box should be centered or not (see QDialogButtonBox::setCentered()).
-
- \value SH_MessageBox_TextInteractionFlags A boolean indicating if
- the text in a message box should allow user interfactions (e.g.
- selection) or not.
-
- \value SH_TitleBar_AutoRaise A boolean indicating whether
- controls on a title bar ought to update when the mouse is over them.
-
- \value SH_ToolButton_PopupDelay An int indicating the popup delay in milliseconds
- for menus attached to tool buttons.
-
- \value SH_FocusFrame_Mask The mask of the focus frame.
-
- \value SH_RubberBand_Mask The mask of the rubber band.
-
- \value SH_WindowFrame_Mask The mask of the window frame.
-
- \value SH_SpinControls_DisableOnBounds Determines if the spin controls will shown
- as disabled when reaching the spin range boundary.
-
- \value SH_Dial_BackgroundRole Defines the style's preferred
- background role (as QPalette::ColorRole) for a dial widget.
-
- \value SH_ScrollBar_BackgroundMode The background mode for a scroll bar.
-
- \value SH_ComboBox_LayoutDirection The layout direction for the
- combo box. By default it should be the same as indicated by the
- QStyleOption::direction variable.
-
- \value SH_ItemView_EllipsisLocation The location where ellipses should be
- added for item text that is too long to fit in an view item.
-
- \value SH_ItemView_ShowDecorationSelected When an item in an item
- view is selected, also highlight the branch or other decoration.
-
- \value SH_ItemView_ActivateItemOnSingleClick Emit the activated signal
- when the user single clicks on an item in an item in an item view.
- Otherwise the signal is emitted when the user double clicks on an item.
-
- \value SH_Slider_AbsoluteSetButtons Which mouse buttons cause a slider
- to set the value to the position clicked on.
-
- \value SH_Slider_PageSetButtons Which mouse buttons cause a slider
- to page step the value.
-
- \value SH_TabBar_ElideMode The default eliding style for a tab bar.
-
- \value SH_DialogButtonLayout Controls how buttons are laid out in a QDialogButtonBox, returns a QDialogButtonBox::ButtonLayout enum.
-
- \value SH_WizardStyle Controls the look and feel of a QWizard. Returns a QWizard::WizardStyle enum.
-
- \value SH_FormLayoutWrapPolicy Provides a default for how rows are wrapped in a QFormLayout. Returns a QFormLayout::RowWrapPolicy enum.
- \value SH_FormLayoutFieldGrowthPolicy Provides a default for how fields can grow in a QFormLayout. Returns a QFormLayout::FieldGrowthPolicy enum.
- \value SH_FormLayoutFormAlignment Provides a default for how a QFormLayout aligns its contents within the available space. Returns a Qt::Alignment enum.
- \value SH_FormLayoutLabelAlignment Provides a default for how a QFormLayout aligns labels within the available space. Returns a Qt::Alignment enum.
-
- \value SH_ItemView_ArrowKeysNavigateIntoChildren Controls whether the tree view will select the first child when it is exapanded and the right arrow key is pressed.
- \value SH_ComboBox_PopupFrameStyle The frame style used when drawing a combobox popup menu.
-
- \value SH_DialogButtonBox_ButtonsHaveIcons Indicates whether or not StandardButtons in QDialogButtonBox should have icons or not.
- \value SH_ItemView_MovementWithoutUpdatingSelection The item view is able to indicate a current item without changing the selection.
- \value SH_ToolTip_Mask The mask of a tool tip.
-
- \value SH_FocusFrame_AboveWidget The FocusFrame is stacked above the widget that it is "focusing on".
-
- \value SH_TextControl_FocusIndicatorTextCharFormat Specifies the text format used to highlight focused anchors in rich text
- documents displayed for example in QTextBrowser. The format has to be a QTextCharFormat returned in the variant of the
- QStyleHintReturnVariant return value. The QTextFormat::OutlinePen property is used for the outline and QTextFormat::BackgroundBrush
- for the background of the highlighted area.
-
- \value SH_Menu_FlashTriggeredItem Flash triggered item.
- \value SH_Menu_FadeOutOnHide Fade out the menu instead of hiding it immediately.
-
- \value SH_TabWidget_DefaultTabPosition Default position of the tab bar in a tab widget.
-
- \value SH_ToolBar_Movable Determines if the tool bar is movable by default.
-
- \value SH_ItemView_PaintAlternatingRowColorsForEmptyArea Whether QTreeView paints alternating row colors for the area that does not have any items.
-
- \value SH_Menu_Mask The mask for a popup menu.
-
- \value SH_ItemView_DrawDelegateFrame Determines if there should be a frame for a delegate widget.
-
- \value SH_TabBar_CloseButtonPosition Determines the position of the close button on a tab in a tab bar.
-
- \value SH_DockWidget_ButtonsHaveFrame Determines if dockwidget buttons should have frames. Default is true.
-
- \value SH_ToolButtonStyle Determines the default system style for tool buttons that uses Qt::ToolButtonFollowStyle.
-
- \value SH_RequestSoftwareInputPanel Determines when a software input panel should
- be requested by input widgets. Returns an enum of type QStyle::RequestSoftwareInputPanel.
-
- \omitvalue SH_UnderlineAccelerator
-
- \sa styleHint()
-*/
-
-/*!
- \fn int QStyle::styleHint(StyleHint hint, const QStyleOption *option, \
- const QWidget *widget, QStyleHintReturn *returnData) const
-
- Returns an integer representing the specified style \a hint for
- the given \a widget described by the provided style \a option.
-
- \a returnData is used when the querying widget needs more detailed data than
- the integer that styleHint() returns. See the QStyleHintReturn class
- description for details.
-*/
-
-/*!
- \enum QStyle::StandardPixmap
-
- This enum describes the available standard pixmaps. A standard pixmap is a pixmap that
- can follow some existing GUI style or guideline.
-
- \value SP_TitleBarMinButton Minimize button on title bars (e.g.,
- in QMdiSubWindow).
- \value SP_TitleBarMenuButton Menu button on a title bar.
- \value SP_TitleBarMaxButton Maximize button on title bars.
- \value SP_TitleBarCloseButton Close button on title bars.
- \value SP_TitleBarNormalButton Normal (restore) button on title bars.
- \value SP_TitleBarShadeButton Shade button on title bars.
- \value SP_TitleBarUnshadeButton Unshade button on title bars.
- \value SP_TitleBarContextHelpButton The Context help button on title bars.
- \value SP_MessageBoxInformation The "information" icon.
- \value SP_MessageBoxWarning The "warning" icon.
- \value SP_MessageBoxCritical The "critical" icon.
- \value SP_MessageBoxQuestion The "question" icon.
- \value SP_DesktopIcon The "desktop" icon.
- \value SP_TrashIcon The "trash" icon.
- \value SP_ComputerIcon The "My computer" icon.
- \value SP_DriveFDIcon The floppy icon.
- \value SP_DriveHDIcon The harddrive icon.
- \value SP_DriveCDIcon The CD icon.
- \value SP_DriveDVDIcon The DVD icon.
- \value SP_DriveNetIcon The network icon.
- \value SP_DirHomeIcon The home directory icon.
- \value SP_DirOpenIcon The open directory icon.
- \value SP_DirClosedIcon The closed directory icon.
- \value SP_DirIcon The directory icon.
- \value SP_DirLinkIcon The link to directory icon.
- \value SP_FileIcon The file icon.
- \value SP_FileLinkIcon The link to file icon.
- \value SP_FileDialogStart The "start" icon in a file dialog.
- \value SP_FileDialogEnd The "end" icon in a file dialog.
- \value SP_FileDialogToParent The "parent directory" icon in a file dialog.
- \value SP_FileDialogNewFolder The "create new folder" icon in a file dialog.
- \value SP_FileDialogDetailedView The detailed view icon in a file dialog.
- \value SP_FileDialogInfoView The file info icon in a file dialog.
- \value SP_FileDialogContentsView The contents view icon in a file dialog.
- \value SP_FileDialogListView The list view icon in a file dialog.
- \value SP_FileDialogBack The back arrow in a file dialog.
- \value SP_DockWidgetCloseButton Close button on dock windows (see also QDockWidget).
- \value SP_ToolBarHorizontalExtensionButton Extension button for horizontal toolbars.
- \value SP_ToolBarVerticalExtensionButton Extension button for vertical toolbars.
- \value SP_DialogOkButton Icon for a standard OK button in a QDialogButtonBox.
- \value SP_DialogCancelButton Icon for a standard Cancel button in a QDialogButtonBox.
- \value SP_DialogHelpButton Icon for a standard Help button in a QDialogButtonBox.
- \value SP_DialogOpenButton Icon for a standard Open button in a QDialogButtonBox.
- \value SP_DialogSaveButton Icon for a standard Save button in a QDialogButtonBox.
- \value SP_DialogCloseButton Icon for a standard Close button in a QDialogButtonBox.
- \value SP_DialogApplyButton Icon for a standard Apply button in a QDialogButtonBox.
- \value SP_DialogResetButton Icon for a standard Reset button in a QDialogButtonBox.
- \value SP_DialogDiscardButton Icon for a standard Discard button in a QDialogButtonBox.
- \value SP_DialogYesButton Icon for a standard Yes button in a QDialogButtonBox.
- \value SP_DialogNoButton Icon for a standard No button in a QDialogButtonBox.
- \value SP_ArrowUp Icon arrow pointing up.
- \value SP_ArrowDown Icon arrow pointing down.
- \value SP_ArrowLeft Icon arrow pointing left.
- \value SP_ArrowRight Icon arrow pointing right.
- \value SP_ArrowBack Equivalent to SP_ArrowLeft when the current layout direction is Qt::LeftToRight, otherwise SP_ArrowRight.
- \value SP_ArrowForward Equivalent to SP_ArrowRight when the current layout direction is Qt::LeftToRight, otherwise SP_ArrowLeft.
- \value SP_CommandLink Icon used to indicate a Vista style command link glyph.
- \value SP_VistaShield Icon used to indicate UAC prompts on Windows Vista. This will return a null pixmap or icon on all other platforms.
- \value SP_BrowserReload Icon indicating that the current page should be reloaded.
- \value SP_BrowserStop Icon indicating that the page loading should stop.
- \value SP_MediaPlay Icon indicating that media should begin playback.
- \value SP_MediaStop Icon indicating that media should stop playback.
- \value SP_MediaPause Icon indicating that media should pause playback.
- \value SP_MediaSkipForward Icon indicating that media should skip forward.
- \value SP_MediaSkipBackward Icon indicating that media should skip backward.
- \value SP_MediaSeekForward Icon indicating that media should seek forward.
- \value SP_MediaSeekBackward Icon indicating that media should seek backward.
- \value SP_MediaVolume Icon indicating a volume control.
- \value SP_MediaVolumeMuted Icon indicating a muted volume control.
- \value SP_CustomBase Base value for custom standard pixmaps;
- custom values must be greater than this value.
-
- \sa standardIcon()
-*/
-
-/*!
- \fn QPixmap QStyle::generatedIconPixmap(QIcon::Mode iconMode,
- const QPixmap &pixmap, const QStyleOption *option) const
-
- Returns a copy of the given \a pixmap, styled to conform to the
- specified \a iconMode and taking into account the palette
- specified by \a option.
-
- The \a option parameter can pass extra information, but
- it must contain a palette.
-
- Note that not all pixmaps will conform, in which case the returned
- pixmap is a plain copy.
-
- \sa QIcon
-*/
-
-/*!
- \fn QPixmap QStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option, \
- const QWidget *widget) const
-
- \obsolete
- Returns a pixmap for the given \a standardPixmap.
-
- A standard pixmap is a pixmap that can follow some existing GUI
- style or guideline. The \a option argument can be used to pass
- extra information required when defining the appropriate
- pixmap. The \a widget argument is optional and can also be used to
- aid the determination of the pixmap.
-
- Developers calling standardPixmap() should instead call standardIcon()
- Developers who re-implemented standardPixmap() should instead re-implement
- the slot standardIconImplementation().
-
- \sa standardIcon()
-*/
-
-
-/*!
- \fn QRect QStyle::visualRect(Qt::LayoutDirection direction, const QRect &boundingRectangle, const QRect &logicalRectangle)
-
- Returns the given \a logicalRectangle converted to screen
- coordinates based on the specified \a direction. The \a
- boundingRectangle is used when performing the translation.
-
- This function is provided to support right-to-left desktops, and
- is typically used in implementations of the subControlRect()
- function.
-
- \sa QWidget::layoutDirection
-*/
-QRect QStyle::visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
-{
- if (direction == Qt::LeftToRight)
- return logicalRect;
- QRect rect = logicalRect;
- rect.translate(2 * (boundingRect.right() - logicalRect.right()) +
- logicalRect.width() - boundingRect.width(), 0);
- return rect;
-}
-
-/*!
- \fn QPoint QStyle::visualPos(Qt::LayoutDirection direction, const QRect &boundingRectangle, const QPoint &logicalPosition)
-
- Returns the given \a logicalPosition converted to screen
- coordinates based on the specified \a direction. The \a
- boundingRectangle is used when performing the translation.
-
- \sa QWidget::layoutDirection
-*/
-QPoint QStyle::visualPos(Qt::LayoutDirection direction, const QRect &boundingRect, const QPoint &logicalPos)
-{
- if (direction == Qt::LeftToRight)
- return logicalPos;
- return QPoint(boundingRect.right() - logicalPos.x(), logicalPos.y());
-}
-
-/*!
- Returns a new rectangle of the specified \a size that is aligned to the given \a
- rectangle according to the specified \a alignment and \a direction.
- */
-QRect QStyle::alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment, const QSize &size, const QRect &rectangle)
-{
- alignment = visualAlignment(direction, alignment);
- int x = rectangle.x();
- int y = rectangle.y();
- int w = size.width();
- int h = size.height();
- if ((alignment & Qt::AlignVCenter) == Qt::AlignVCenter)
- y += rectangle.size().height()/2 - h/2;
- else if ((alignment & Qt::AlignBottom) == Qt::AlignBottom)
- y += rectangle.size().height() - h;
- if ((alignment & Qt::AlignRight) == Qt::AlignRight)
- x += rectangle.size().width() - w;
- else if ((alignment & Qt::AlignHCenter) == Qt::AlignHCenter)
- x += rectangle.size().width()/2 - w/2;
- return QRect(x, y, w, h);
-}
-
-/*!
- Transforms an \a alignment of Qt::AlignLeft or Qt::AlignRight
- without Qt::AlignAbsolute into Qt::AlignLeft or Qt::AlignRight with
- Qt::AlignAbsolute according to the layout \a direction. The other
- alignment flags are left untouched.
-
- If no horizontal alignment was specified, the function returns the
- default alignment for the given layout \a direction.
-
- QWidget::layoutDirection
-*/
-Qt::Alignment QStyle::visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
-{
- if (!(alignment & Qt::AlignHorizontal_Mask))
- alignment |= Qt::AlignLeft;
- if ((alignment & Qt::AlignAbsolute) == 0 && (alignment & (Qt::AlignLeft | Qt::AlignRight))) {
- if (direction == Qt::RightToLeft)
- alignment ^= (Qt::AlignLeft | Qt::AlignRight);
- alignment |= Qt::AlignAbsolute;
- }
- return alignment;
-}
-
-/*!
- Converts the given \a logicalValue to a pixel position. The \a min
- parameter maps to 0, \a max maps to \a span and other values are
- distributed evenly in-between.
-
- This function can handle the entire integer range without
- overflow, providing that \a span is less than 4096.
-
- By default, this function assumes that the maximum value is on the
- right for horizontal items and on the bottom for vertical items.
- Set the \a upsideDown parameter to true to reverse this behavior.
-
- \sa sliderValueFromPosition()
-*/
-
-int QStyle::sliderPositionFromValue(int min, int max, int logicalValue, int span, bool upsideDown)
-{
- if (span <= 0 || logicalValue < min || max <= min)
- return 0;
- if (logicalValue > max)
- return upsideDown ? span : min;
-
- uint range = max - min;
- uint p = upsideDown ? max - logicalValue : logicalValue - min;
-
- if (range > (uint)INT_MAX/4096) {
- double dpos = (double(p))/(double(range)/span);
- return int(dpos);
- } else if (range > (uint)span) {
- return (2 * p * span + range) / (2*range);
- } else {
- uint div = span / range;
- uint mod = span % range;
- return p * div + (2 * p * mod + range) / (2 * range);
- }
- // equiv. to (p * span) / range + 0.5
- // no overflow because of this implicit assumption:
- // span <= 4096
-}
-
-/*!
- \fn int QStyle::sliderValueFromPosition(int min, int max, int position, int span, bool upsideDown)
-
- Converts the given pixel \a position to a logical value. 0 maps to
- the \a min parameter, \a span maps to \a max and other values are
- distributed evenly in-between.
-
- This function can handle the entire integer range without
- overflow.
-
- By default, this function assumes that the maximum value is on the
- right for horizontal items and on the bottom for vertical
- items. Set the \a upsideDown parameter to true to reverse this
- behavior.
-
- \sa sliderPositionFromValue()
-*/
-
-int QStyle::sliderValueFromPosition(int min, int max, int pos, int span, bool upsideDown)
-{
- if (span <= 0 || pos <= 0)
- return upsideDown ? max : min;
- if (pos >= span)
- return upsideDown ? min : max;
-
- uint range = max - min;
-
- if ((uint)span > range) {
- int tmp = (2 * pos * range + span) / (2 * span);
- return upsideDown ? max - tmp : tmp + min;
- } else {
- uint div = range / span;
- uint mod = range % span;
- int tmp = pos * div + (2 * pos * mod + span) / (2 * span);
- return upsideDown ? max - tmp : tmp + min;
- }
- // equiv. to min + (pos*range)/span + 0.5
- // no overflow because of this implicit assumption:
- // pos <= span < sqrt(INT_MAX+0.0625)+0.25 ~ sqrt(INT_MAX)
-}
-
-/*### \fn void QStyle::drawItem(QPainter *p, const QRect &r,
- int flags, const QColorGroup &colorgroup, bool enabled,
- const QString &text, int len = -1,
- const QColor *penColor = 0) const
-
- Use one of the drawItem() overloads that takes a QPalette instead
- of a QColorGroup.
-*/
-
-/*### \fn void QStyle::drawItem(QPainter *p, const QRect &r,
- int flags, const QColorGroup colorgroup, bool enabled,
- const QPixmap &pixmap,
- const QColor *penColor = 0) const
-
- Use one of the drawItem() overloads that takes a QPalette instead
- of a QColorGroup.
-*/
-
-/*### \fn void QStyle::drawItem(QPainter *p, const QRect &r,
- int flags, const QColorGroup colorgroup, bool enabled,
- const QPixmap *pixmap,
- const QString &text, int len = -1,
- const QColor *penColor = 0) const
-
- Use one of the drawItem() overloads that takes a QPalette instead
- of a QColorGroup.
-*/
-
-/*!
- Returns the style's standard palette.
-
- Note that on systems that support system colors, the style's
- standard palette is not used. In particular, the Windows XP,
- Vista, and Mac styles do not use the standard palette, but make
- use of native theme engines. With these styles, you should not set
- the palette with QApplication::setStandardPalette().
-
- */
-QPalette QStyle::standardPalette() const
-{
-#ifdef Q_WS_X11
- QColor background;
- if (QX11Info::appDepth() > 8)
- background = QColor(0xd4, 0xd0, 0xc8); // win 2000 grey
- else
- background = QColor(192, 192, 192);
-#else
- QColor background(0xd4, 0xd0, 0xc8); // win 2000 grey
-#endif
- QColor light(background.lighter());
- QColor dark(background.darker());
- QColor mid(Qt::gray);
- QPalette palette(Qt::black, background, light, dark, mid, Qt::black, Qt::white);
- palette.setBrush(QPalette::Disabled, QPalette::WindowText, dark);
- palette.setBrush(QPalette::Disabled, QPalette::Text, dark);
- palette.setBrush(QPalette::Disabled, QPalette::ButtonText, dark);
- palette.setBrush(QPalette::Disabled, QPalette::Base, background);
- return palette;
-}
-
-/*!
- \since 4.1
-
- Returns an icon for the given \a standardIcon.
-
- The \a standardIcon is a standard pixmap which can follow some
- existing GUI style or guideline. The \a option argument can be
- used to pass extra information required when defining the
- appropriate icon. The \a widget argument is optional and can also
- be used to aid the determination of the icon.
-
- \warning Because of binary compatibility constraints, this
- function is not virtual. If you want to provide your own icons in
- a QStyle subclass, reimplement the standardIconImplementation()
- slot in your subclass instead. The standardIcon() function will
- dynamically detect the slot and call it.
-
- \sa standardIconImplementation()
-*/
-QIcon QStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption *option,
- const QWidget *widget) const
-{
- QIcon result;
- // ### Qt 4.1: invokeMethod should accept const functions, to avoid this dirty cast
- QMetaObject::invokeMethod(const_cast<QStyle*>(this),
- "standardIconImplementation", Qt::DirectConnection,
- Q_RETURN_ARG(QIcon, result),
- Q_ARG(StandardPixmap, standardIcon),
- Q_ARG(const QStyleOption*, option),
- Q_ARG(const QWidget*, widget));
- return result;
-}
-
-/*!
- \since 4.1
-
- Returns an icon for the given \a standardIcon.
-
- Reimplement this slot to provide your own icons in a QStyle
- subclass; because of binary compatibility constraints, the
- standardIcon() function (introduced in Qt 4.1) is not
- virtual. Instead, standardIcon() will dynamically detect and call
- \e this slot.
-
- The \a standardIcon is a standard pixmap which can follow some
- existing GUI style or guideline. The \a option argument can be
- used to pass extra information required when defining the
- appropriate icon. The \a widget argument is optional and can also
- be used to aid the determination of the icon.
-
- \sa standardIcon()
-*/
-QIcon QStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option,
- const QWidget *widget) const
-{
- return QIcon(standardPixmap(standardIcon, option, widget));
-}
-
-/*!
- \since 4.3
-
- Returns the spacing that should be used between \a control1 and
- \a control2 in a layout. \a orientation specifies whether the
- controls are laid out side by side or stacked vertically. The \a
- option parameter can be used to pass extra information about the
- parent widget. The \a widget parameter is optional and can also
- be used if \a option is 0.
-
- This function is called by the layout system. It is used only if
- PM_LayoutHorizontalSpacing or PM_LayoutVerticalSpacing returns a
- negative value.
-
- For binary compatibility reasons, this function is not virtual.
- If you want to specify custom layout spacings in a QStyle
- subclass, implement a slot called layoutSpacingImplementation().
- QStyle will discover the slot at run-time (using Qt's
- \l{meta-object system}) and direct all calls to layoutSpacing()
- to layoutSpacingImplementation().
-
- \sa combinedLayoutSpacing(), layoutSpacingImplementation()
-*/
-int QStyle::layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2,
- Qt::Orientation orientation, const QStyleOption *option,
- const QWidget *widget) const
-{
- Q_D(const QStyle);
- if (d->layoutSpacingIndex == -1) {
- d->layoutSpacingIndex = metaObject()->indexOfMethod(
- "layoutSpacingImplementation(QSizePolicy::ControlType,QSizePolicy::ControlType,"
- "Qt::Orientation,const QStyleOption*,const QWidget*)"
- );
- }
- if (d->layoutSpacingIndex < 0)
- return -1;
- int result = -1;
- void *param[] = {&result, &control1, &control2, &orientation, &option, &widget};
-
- const_cast<QStyle *>(this)->qt_metacall(QMetaObject::InvokeMetaMethod,
- d->layoutSpacingIndex, param);
- return result;
-}
-
-/*!
- \since 4.3
-
- Returns the spacing that should be used between \a controls1 and
- \a controls2 in a layout. \a orientation specifies whether the
- controls are laid out side by side or stacked vertically. The \a
- option parameter can be used to pass extra information about the
- parent widget. The \a widget parameter is optional and can also
- be used if \a option is 0.
-
- \a controls1 and \a controls2 are OR-combination of zero or more
- \l{QSizePolicy::ControlTypes}{control types}.
-
- This function is called by the layout system. It is used only if
- PM_LayoutHorizontalSpacing or PM_LayoutVerticalSpacing returns a
- negative value.
-
- \sa layoutSpacing(), layoutSpacingImplementation()
-*/
-int QStyle::combinedLayoutSpacing(QSizePolicy::ControlTypes controls1,
- QSizePolicy::ControlTypes controls2, Qt::Orientation orientation,
- QStyleOption *option, QWidget *widget) const
-{
- QSizePolicy::ControlType array1[MaxBits];
- QSizePolicy::ControlType array2[MaxBits];
- int count1 = unpackControlTypes(controls1, array1);
- int count2 = unpackControlTypes(controls2, array2);
- int result = -1;
-
- for (int i = 0; i < count1; ++i) {
- for (int j = 0; j < count2; ++j) {
- int spacing = layoutSpacing(array1[i], array2[j], orientation, option, widget);
- result = qMax(spacing, result);
- }
- }
- return result;
-}
-
-/*!
- \since 4.3
-
- This slot is called by layoutSpacing() to determine the spacing
- that should be used between \a control1 and \a control2 in a
- layout. \a orientation specifies whether the controls are laid
- out side by side or stacked vertically. The \a option parameter
- can be used to pass extra information about the parent widget.
- The \a widget parameter is optional and can also be used if \a
- option is 0.
-
- If you want to provide custom layout spacings in a QStyle
- subclass, implement a slot called layoutSpacingImplementation()
- in your subclass. Be aware that this slot will only be called if
- PM_LayoutHorizontalSpacing or PM_LayoutVerticalSpacing returns a
- negative value.
-
- The default implementation returns -1.
-
- \sa layoutSpacing(), combinedLayoutSpacing()
-*/
-int QStyle::layoutSpacingImplementation(QSizePolicy::ControlType /* control1 */,
- QSizePolicy::ControlType /* control2 */,
- Qt::Orientation /*orientation*/,
- const QStyleOption * /* option */,
- const QWidget * /* widget */) const
-{
- return -1;
-}
-
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <QDebug>
-QT_END_INCLUDE_NAMESPACE
-
-#if !defined(QT_NO_DEBUG_STREAM)
-QDebug operator<<(QDebug debug, QStyle::State state)
-{
-#if !defined(QT_NO_DEBUG)
- debug << "QStyle::State(";
-
- QStringList states;
- if (state & QStyle::State_Active) states << QLatin1String("Active");
- if (state & QStyle::State_AutoRaise) states << QLatin1String("AutoRaise");
- if (state & QStyle::State_Bottom) states << QLatin1String("Bottom");
- if (state & QStyle::State_Children) states << QLatin1String("Children");
- if (state & QStyle::State_DownArrow) states << QLatin1String("DownArrow");
- if (state & QStyle::State_Editing) states << QLatin1String("Editing");
- if (state & QStyle::State_Enabled) states << QLatin1String("Enabled");
- if (state & QStyle::State_FocusAtBorder) states << QLatin1String("FocusAtBorder");
- if (state & QStyle::State_HasFocus) states << QLatin1String("HasFocus");
- if (state & QStyle::State_Horizontal) states << QLatin1String("Horizontal");
- if (state & QStyle::State_Item) states << QLatin1String("Item");
- if (state & QStyle::State_KeyboardFocusChange) states << QLatin1String("KeyboardFocusChange");
- if (state & QStyle::State_MouseOver) states << QLatin1String("MouseOver");
- if (state & QStyle::State_NoChange) states << QLatin1String("NoChange");
- if (state & QStyle::State_Off) states << QLatin1String("Off");
- if (state & QStyle::State_On) states << QLatin1String("On");
- if (state & QStyle::State_Open) states << QLatin1String("Open");
- if (state & QStyle::State_Raised) states << QLatin1String("Raised");
- if (state & QStyle::State_ReadOnly) states << QLatin1String("ReadOnly");
- if (state & QStyle::State_Selected) states << QLatin1String("Selected");
- if (state & QStyle::State_Sibling) states << QLatin1String("Sibling");
- if (state & QStyle::State_Sunken) states << QLatin1String("Sunken");
- if (state & QStyle::State_Top) states << QLatin1String("Top");
- if (state & QStyle::State_UpArrow) states << QLatin1String("UpArrow");
-
- qSort(states);
- debug << states.join(QLatin1String(" | "));
- debug << ')';
-#else
- Q_UNUSED(state);
-#endif
- return debug;
-}
-#endif
-
-/*!
- \since 4.6
-
- \fn const QStyle *QStyle::proxy() const
-
- This function returns the current proxy for this style.
- By default most styles will return themselves. However
- when a proxy style is in use, it will allow the style to
- call back into its proxy.
-*/
-const QStyle * QStyle::proxy() const
-{
- Q_D(const QStyle);
- return d->proxyStyle;
-}
-
-/* \internal
-
- This function sets the base style that style calls will be
- redirected to. Note that ownership is not transferred.
-*/
-void QStyle::setProxy(QStyle *style)
-{
- Q_D(QStyle);
- d->proxyStyle = style;
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/styles/qstyle.h b/src/gui/styles/qstyle.h
deleted file mode 100644
index 94f2ce102f..0000000000
--- a/src/gui/styles/qstyle.h
+++ /dev/null
@@ -1,889 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSTYLE_H
-#define QSTYLE_H
-
-#include <QtCore/qobject.h>
-#include <QtCore/qrect.h>
-#include <QtCore/qsize.h>
-#include <QtGui/qicon.h>
-#include <QtGui/qpixmap.h>
-#include <QtGui/qpalette.h>
-#include <QtGui/qsizepolicy.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QAction;
-class QDebug;
-class QTab;
-class QFontMetrics;
-class QStyleHintReturn;
-class QStyleOption;
-class QStyleOptionComplex;
-class QStylePrivate;
-
-class Q_GUI_EXPORT QStyle : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QStyle)
-
-protected:
- QStyle(QStylePrivate &dd);
-
-public:
- QStyle();
- virtual ~QStyle();
-
- virtual void polish(QWidget *);
- virtual void unpolish(QWidget *);
-
- virtual void polish(QApplication *);
- virtual void unpolish(QApplication *);
-
- virtual void polish(QPalette &);
-
- virtual QRect itemTextRect(const QFontMetrics &fm, const QRect &r,
- int flags, bool enabled,
- const QString &text) const;
-
- virtual QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const;
-
- virtual void drawItemText(QPainter *painter, const QRect &rect,
- int flags, const QPalette &pal, bool enabled,
- const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const;
-
- virtual void drawItemPixmap(QPainter *painter, const QRect &rect,
- int alignment, const QPixmap &pixmap) const;
-
- virtual QPalette standardPalette() const;
-
- enum StateFlag {
- State_None = 0x00000000,
-#ifdef QT3_SUPPORT
- State_Default = State_None,
-#endif
- State_Enabled = 0x00000001,
- State_Raised = 0x00000002,
- State_Sunken = 0x00000004,
- State_Off = 0x00000008,
- State_NoChange = 0x00000010,
- State_On = 0x00000020,
- State_DownArrow = 0x00000040,
- State_Horizontal = 0x00000080,
- State_HasFocus = 0x00000100,
- State_Top = 0x00000200,
- State_Bottom = 0x00000400,
- State_FocusAtBorder = 0x00000800,
- State_AutoRaise = 0x00001000,
- State_MouseOver = 0x00002000,
- State_UpArrow = 0x00004000,
- State_Selected = 0x00008000,
- State_Active = 0x00010000,
- State_Window = 0x00020000,
- State_Open = 0x00040000,
- State_Children = 0x00080000,
- State_Item = 0x00100000,
- State_Sibling = 0x00200000,
- State_Editing = 0x00400000,
- State_KeyboardFocusChange = 0x00800000,
-#ifdef QT_KEYPAD_NAVIGATION
- State_HasEditFocus = 0x01000000,
-#endif
- State_ReadOnly = 0x02000000,
- State_Small = 0x04000000,
- State_Mini = 0x08000000
- };
- Q_DECLARE_FLAGS(State, StateFlag)
-
-#ifdef QT3_SUPPORT
- typedef State SFlags;
-#endif
-
- enum PrimitiveElement {
- PE_Q3CheckListController,
- PE_Q3CheckListExclusiveIndicator,
- PE_Q3CheckListIndicator,
- PE_Q3DockWindowSeparator,
- PE_Q3Separator,
-
- PE_Frame,
- PE_FrameDefaultButton,
- PE_FrameDockWidget,
- PE_FrameFocusRect,
- PE_FrameGroupBox,
- PE_FrameLineEdit,
- PE_FrameMenu,
- PE_FrameStatusBar, // obsolete
- PE_FrameStatusBarItem = PE_FrameStatusBar,
- PE_FrameTabWidget,
- PE_FrameWindow,
- PE_FrameButtonBevel,
- PE_FrameButtonTool,
- PE_FrameTabBarBase,
-
- PE_PanelButtonCommand,
- PE_PanelButtonBevel,
- PE_PanelButtonTool,
- PE_PanelMenuBar,
- PE_PanelToolBar,
- PE_PanelLineEdit,
-
- PE_IndicatorArrowDown,
- PE_IndicatorArrowLeft,
- PE_IndicatorArrowRight,
- PE_IndicatorArrowUp,
- PE_IndicatorBranch,
- PE_IndicatorButtonDropDown,
- PE_IndicatorViewItemCheck,
- PE_IndicatorItemViewItemCheck = PE_IndicatorViewItemCheck,
- PE_IndicatorCheckBox,
- PE_IndicatorDockWidgetResizeHandle,
- PE_IndicatorHeaderArrow,
- PE_IndicatorMenuCheckMark,
- PE_IndicatorProgressChunk,
- PE_IndicatorRadioButton,
- PE_IndicatorSpinDown,
- PE_IndicatorSpinMinus,
- PE_IndicatorSpinPlus,
- PE_IndicatorSpinUp,
- PE_IndicatorToolBarHandle,
- PE_IndicatorToolBarSeparator,
- PE_PanelTipLabel,
- PE_IndicatorTabTear,
- PE_PanelScrollAreaCorner,
-
- PE_Widget,
-
- PE_IndicatorColumnViewArrow,
- PE_IndicatorItemViewItemDrop,
-
- PE_PanelItemViewItem,
- PE_PanelItemViewRow, // ### Qt 5: remove
-
- PE_PanelStatusBar,
-
- PE_IndicatorTabClose,
- PE_PanelMenu,
-
- // do not add any values below/greater this
- PE_CustomBase = 0xf000000
- };
-
- virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
- const QWidget *w = 0) const = 0;
- enum ControlElement {
- CE_PushButton,
- CE_PushButtonBevel,
- CE_PushButtonLabel,
-
- CE_CheckBox,
- CE_CheckBoxLabel,
-
- CE_RadioButton,
- CE_RadioButtonLabel,
-
- CE_TabBarTab,
- CE_TabBarTabShape,
- CE_TabBarTabLabel,
-
- CE_ProgressBar,
- CE_ProgressBarGroove,
- CE_ProgressBarContents,
- CE_ProgressBarLabel,
-
- CE_MenuItem,
- CE_MenuScroller,
- CE_MenuVMargin,
- CE_MenuHMargin,
- CE_MenuTearoff,
- CE_MenuEmptyArea,
-
- CE_MenuBarItem,
- CE_MenuBarEmptyArea,
-
- CE_ToolButtonLabel,
-
- CE_Header,
- CE_HeaderSection,
- CE_HeaderLabel,
-
- CE_Q3DockWindowEmptyArea,
- CE_ToolBoxTab,
- CE_SizeGrip,
- CE_Splitter,
- CE_RubberBand,
- CE_DockWidgetTitle,
-
- CE_ScrollBarAddLine,
- CE_ScrollBarSubLine,
- CE_ScrollBarAddPage,
- CE_ScrollBarSubPage,
- CE_ScrollBarSlider,
- CE_ScrollBarFirst,
- CE_ScrollBarLast,
-
- CE_FocusFrame,
- CE_ComboBoxLabel,
-
- CE_ToolBar,
- CE_ToolBoxTabShape,
- CE_ToolBoxTabLabel,
- CE_HeaderEmptyArea,
-
- CE_ColumnViewGrip,
-
- CE_ItemViewItem,
-
- CE_ShapedFrame,
-
- // do not add any values below/greater than this
- CE_CustomBase = 0xf0000000
- };
-
- virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
- const QWidget *w = 0) const = 0;
-
- enum SubElement {
- SE_PushButtonContents,
- SE_PushButtonFocusRect,
-
- SE_CheckBoxIndicator,
- SE_CheckBoxContents,
- SE_CheckBoxFocusRect,
- SE_CheckBoxClickRect,
-
- SE_RadioButtonIndicator,
- SE_RadioButtonContents,
- SE_RadioButtonFocusRect,
- SE_RadioButtonClickRect,
-
- SE_ComboBoxFocusRect,
-
- SE_SliderFocusRect,
-
- SE_Q3DockWindowHandleRect,
-
- SE_ProgressBarGroove,
- SE_ProgressBarContents,
- SE_ProgressBarLabel,
-
- // ### Qt 5: These values are unused; eliminate them
- SE_DialogButtonAccept,
- SE_DialogButtonReject,
- SE_DialogButtonApply,
- SE_DialogButtonHelp,
- SE_DialogButtonAll,
- SE_DialogButtonAbort,
- SE_DialogButtonIgnore,
- SE_DialogButtonRetry,
- SE_DialogButtonCustom,
-
- SE_ToolBoxTabContents,
-
- SE_HeaderLabel,
- SE_HeaderArrow,
-
- SE_TabWidgetTabBar,
- SE_TabWidgetTabPane,
- SE_TabWidgetTabContents,
- SE_TabWidgetLeftCorner,
- SE_TabWidgetRightCorner,
-
- SE_ViewItemCheckIndicator,
- SE_ItemViewItemCheckIndicator = SE_ViewItemCheckIndicator,
-
- SE_TabBarTearIndicator,
-
- SE_TreeViewDisclosureItem,
-
- SE_LineEditContents,
- SE_FrameContents,
-
- SE_DockWidgetCloseButton,
- SE_DockWidgetFloatButton,
- SE_DockWidgetTitleBarText,
- SE_DockWidgetIcon,
-
- SE_CheckBoxLayoutItem,
- SE_ComboBoxLayoutItem,
- SE_DateTimeEditLayoutItem,
- SE_DialogButtonBoxLayoutItem, // ### remove
- SE_LabelLayoutItem,
- SE_ProgressBarLayoutItem,
- SE_PushButtonLayoutItem,
- SE_RadioButtonLayoutItem,
- SE_SliderLayoutItem,
- SE_SpinBoxLayoutItem,
- SE_ToolButtonLayoutItem,
-
- SE_FrameLayoutItem,
- SE_GroupBoxLayoutItem,
- SE_TabWidgetLayoutItem,
-
- SE_ItemViewItemDecoration,
- SE_ItemViewItemText,
- SE_ItemViewItemFocusRect,
-
- SE_TabBarTabLeftButton,
- SE_TabBarTabRightButton,
- SE_TabBarTabText,
-
- SE_ShapedFrameContents,
-
- SE_ToolBarHandle,
-
- // do not add any values below/greater than this
- SE_CustomBase = 0xf0000000
- };
-
- virtual QRect subElementRect(SubElement subElement, const QStyleOption *option,
- const QWidget *widget = 0) const = 0;
-
-
- enum ComplexControl {
- CC_SpinBox,
- CC_ComboBox,
- CC_ScrollBar,
- CC_Slider,
- CC_ToolButton,
- CC_TitleBar,
- CC_Q3ListView,
- CC_Dial,
- CC_GroupBox,
- CC_MdiControls,
-
- // do not add any values below/greater than this
- CC_CustomBase = 0xf0000000
- };
-
- enum SubControl {
- SC_None = 0x00000000,
-
- SC_ScrollBarAddLine = 0x00000001,
- SC_ScrollBarSubLine = 0x00000002,
- SC_ScrollBarAddPage = 0x00000004,
- SC_ScrollBarSubPage = 0x00000008,
- SC_ScrollBarFirst = 0x00000010,
- SC_ScrollBarLast = 0x00000020,
- SC_ScrollBarSlider = 0x00000040,
- SC_ScrollBarGroove = 0x00000080,
-
- SC_SpinBoxUp = 0x00000001,
- SC_SpinBoxDown = 0x00000002,
- SC_SpinBoxFrame = 0x00000004,
- SC_SpinBoxEditField = 0x00000008,
-
- SC_ComboBoxFrame = 0x00000001,
- SC_ComboBoxEditField = 0x00000002,
- SC_ComboBoxArrow = 0x00000004,
- SC_ComboBoxListBoxPopup = 0x00000008,
-
- SC_SliderGroove = 0x00000001,
- SC_SliderHandle = 0x00000002,
- SC_SliderTickmarks = 0x00000004,
-
- SC_ToolButton = 0x00000001,
- SC_ToolButtonMenu = 0x00000002,
-
- SC_TitleBarSysMenu = 0x00000001,
- SC_TitleBarMinButton = 0x00000002,
- SC_TitleBarMaxButton = 0x00000004,
- SC_TitleBarCloseButton = 0x00000008,
- SC_TitleBarNormalButton = 0x00000010,
- SC_TitleBarShadeButton = 0x00000020,
- SC_TitleBarUnshadeButton = 0x00000040,
- SC_TitleBarContextHelpButton = 0x00000080,
- SC_TitleBarLabel = 0x00000100,
-
- SC_Q3ListView = 0x00000001,
- SC_Q3ListViewBranch = 0x00000002,
- SC_Q3ListViewExpand = 0x00000004,
-
- SC_DialGroove = 0x00000001,
- SC_DialHandle = 0x00000002,
- SC_DialTickmarks = 0x00000004,
-
- SC_GroupBoxCheckBox = 0x00000001,
- SC_GroupBoxLabel = 0x00000002,
- SC_GroupBoxContents = 0x00000004,
- SC_GroupBoxFrame = 0x00000008,
-
- SC_MdiMinButton = 0x00000001,
- SC_MdiNormalButton = 0x00000002,
- SC_MdiCloseButton = 0x00000004,
-
- SC_CustomBase = 0xf0000000,
- SC_All = 0xffffffff
- };
- Q_DECLARE_FLAGS(SubControls, SubControl)
-
-#ifdef QT3_SUPPORT
- typedef SubControls SCFlags;
-#endif
-
- virtual void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
- const QWidget *widget = 0) const = 0;
- virtual SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
- const QPoint &pt, const QWidget *widget = 0) const = 0;
- virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt,
- SubControl sc, const QWidget *widget = 0) const = 0;
-
- enum PixelMetric {
- PM_ButtonMargin,
- PM_ButtonDefaultIndicator,
- PM_MenuButtonIndicator,
- PM_ButtonShiftHorizontal,
- PM_ButtonShiftVertical,
-
- PM_DefaultFrameWidth,
- PM_SpinBoxFrameWidth,
- PM_ComboBoxFrameWidth,
-
- PM_MaximumDragDistance,
-
- PM_ScrollBarExtent,
- PM_ScrollBarSliderMin,
-
- PM_SliderThickness, // total slider thickness
- PM_SliderControlThickness, // thickness of the business part
- PM_SliderLength, // total length of slider
- PM_SliderTickmarkOffset, //
- PM_SliderSpaceAvailable, // available space for slider to move
-
- PM_DockWidgetSeparatorExtent,
- PM_DockWidgetHandleExtent,
- PM_DockWidgetFrameWidth,
-
- PM_TabBarTabOverlap,
- PM_TabBarTabHSpace,
- PM_TabBarTabVSpace,
- PM_TabBarBaseHeight,
- PM_TabBarBaseOverlap,
-
- PM_ProgressBarChunkWidth,
-
- PM_SplitterWidth,
- PM_TitleBarHeight,
-
- PM_MenuScrollerHeight,
- PM_MenuHMargin,
- PM_MenuVMargin,
- PM_MenuPanelWidth,
- PM_MenuTearoffHeight,
- PM_MenuDesktopFrameWidth,
-
- PM_MenuBarPanelWidth,
- PM_MenuBarItemSpacing,
- PM_MenuBarVMargin,
- PM_MenuBarHMargin,
-
- PM_IndicatorWidth,
- PM_IndicatorHeight,
- PM_ExclusiveIndicatorWidth,
- PM_ExclusiveIndicatorHeight,
- PM_CheckListButtonSize,
- PM_CheckListControllerSize,
-
- PM_DialogButtonsSeparator,
- PM_DialogButtonsButtonWidth,
- PM_DialogButtonsButtonHeight,
-
- PM_MdiSubWindowFrameWidth,
- PM_MDIFrameWidth = PM_MdiSubWindowFrameWidth, //obsolete
- PM_MdiSubWindowMinimizedWidth,
- PM_MDIMinimizedWidth = PM_MdiSubWindowMinimizedWidth, //obsolete
-
- PM_HeaderMargin,
- PM_HeaderMarkSize,
- PM_HeaderGripMargin,
- PM_TabBarTabShiftHorizontal,
- PM_TabBarTabShiftVertical,
- PM_TabBarScrollButtonWidth,
-
- PM_ToolBarFrameWidth,
- PM_ToolBarHandleExtent,
- PM_ToolBarItemSpacing,
- PM_ToolBarItemMargin,
- PM_ToolBarSeparatorExtent,
- PM_ToolBarExtensionExtent,
-
- PM_SpinBoxSliderHeight,
-
- PM_DefaultTopLevelMargin,
- PM_DefaultChildMargin,
- PM_DefaultLayoutSpacing,
-
- PM_ToolBarIconSize,
- PM_ListViewIconSize,
- PM_IconViewIconSize,
- PM_SmallIconSize,
- PM_LargeIconSize,
-
- PM_FocusFrameVMargin,
- PM_FocusFrameHMargin,
-
- PM_ToolTipLabelFrameWidth,
- PM_CheckBoxLabelSpacing,
- PM_TabBarIconSize,
- PM_SizeGripSize,
- PM_DockWidgetTitleMargin,
- PM_MessageBoxIconSize,
- PM_ButtonIconSize,
-
- PM_DockWidgetTitleBarButtonMargin,
-
- PM_RadioButtonLabelSpacing,
- PM_LayoutLeftMargin,
- PM_LayoutTopMargin,
- PM_LayoutRightMargin,
- PM_LayoutBottomMargin,
- PM_LayoutHorizontalSpacing,
- PM_LayoutVerticalSpacing,
- PM_TabBar_ScrollButtonOverlap,
-
- PM_TextCursorWidth,
-
- PM_TabCloseIndicatorWidth,
- PM_TabCloseIndicatorHeight,
-
- PM_ScrollView_ScrollBarSpacing,
- PM_SubMenuOverlap,
-
- // do not add any values below/greater than this
- PM_CustomBase = 0xf0000000
- };
-
- virtual int pixelMetric(PixelMetric metric, const QStyleOption *option = 0,
- const QWidget *widget = 0) const = 0;
-
- enum ContentsType {
- CT_PushButton,
- CT_CheckBox,
- CT_RadioButton,
- CT_ToolButton,
- CT_ComboBox,
- CT_Splitter,
- CT_Q3DockWindow,
- CT_ProgressBar,
- CT_MenuItem,
- CT_MenuBarItem,
- CT_MenuBar,
- CT_Menu,
- CT_TabBarTab,
- CT_Slider,
- CT_ScrollBar,
- CT_Q3Header,
- CT_LineEdit,
- CT_SpinBox,
- CT_SizeGrip,
- CT_TabWidget,
- CT_DialogButtons,
- CT_HeaderSection,
- CT_GroupBox,
- CT_MdiControls,
- CT_ItemViewItem,
- // do not add any values below/greater than this
- CT_CustomBase = 0xf0000000
- };
-
- virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt,
- const QSize &contentsSize, const QWidget *w = 0) const = 0;
-
- enum RequestSoftwareInputPanel {
- RSIP_OnMouseClickAndAlreadyFocused,
- RSIP_OnMouseClick
- };
-
- enum StyleHint {
- SH_EtchDisabledText,
- SH_DitherDisabledText,
- SH_ScrollBar_MiddleClickAbsolutePosition,
- SH_ScrollBar_ScrollWhenPointerLeavesControl,
- SH_TabBar_SelectMouseType,
- SH_TabBar_Alignment,
- SH_Header_ArrowAlignment,
- SH_Slider_SnapToValue,
- SH_Slider_SloppyKeyEvents,
- SH_ProgressDialog_CenterCancelButton,
- SH_ProgressDialog_TextLabelAlignment,
- SH_PrintDialog_RightAlignButtons,
- SH_MainWindow_SpaceBelowMenuBar,
- SH_FontDialog_SelectAssociatedText,
- SH_Menu_AllowActiveAndDisabled,
- SH_Menu_SpaceActivatesItem,
- SH_Menu_SubMenuPopupDelay,
- SH_ScrollView_FrameOnlyAroundContents,
- SH_MenuBar_AltKeyNavigation,
- SH_ComboBox_ListMouseTracking,
- SH_Menu_MouseTracking,
- SH_MenuBar_MouseTracking,
- SH_ItemView_ChangeHighlightOnFocus,
- SH_Widget_ShareActivation,
- SH_Workspace_FillSpaceOnMaximize,
- SH_ComboBox_Popup,
- SH_TitleBar_NoBorder,
- SH_Slider_StopMouseOverSlider,
- SH_ScrollBar_StopMouseOverSlider = SH_Slider_StopMouseOverSlider, // obsolete
- SH_BlinkCursorWhenTextSelected,
- SH_RichText_FullWidthSelection,
- SH_Menu_Scrollable,
- SH_GroupBox_TextLabelVerticalAlignment,
- SH_GroupBox_TextLabelColor,
- SH_Menu_SloppySubMenus,
- SH_Table_GridLineColor,
- SH_LineEdit_PasswordCharacter,
- SH_DialogButtons_DefaultButton,
- SH_ToolBox_SelectedPageTitleBold,
- SH_TabBar_PreferNoArrows,
- SH_ScrollBar_LeftClickAbsolutePosition,
- SH_Q3ListViewExpand_SelectMouseType,
- SH_UnderlineShortcut,
- SH_SpinBox_AnimateButton,
- SH_SpinBox_KeyPressAutoRepeatRate,
- SH_SpinBox_ClickAutoRepeatRate,
- SH_Menu_FillScreenWithScroll,
- SH_ToolTipLabel_Opacity,
- SH_DrawMenuBarSeparator,
- SH_TitleBar_ModifyNotification,
- SH_Button_FocusPolicy,
- SH_MenuBar_DismissOnSecondClick,
- SH_MessageBox_UseBorderForButtonSpacing,
- SH_TitleBar_AutoRaise,
- SH_ToolButton_PopupDelay,
- SH_FocusFrame_Mask,
- SH_RubberBand_Mask,
- SH_WindowFrame_Mask,
- SH_SpinControls_DisableOnBounds,
- SH_Dial_BackgroundRole,
- SH_ComboBox_LayoutDirection,
- SH_ItemView_EllipsisLocation,
- SH_ItemView_ShowDecorationSelected,
- SH_ItemView_ActivateItemOnSingleClick,
- SH_ScrollBar_ContextMenu,
- SH_ScrollBar_RollBetweenButtons,
- SH_Slider_AbsoluteSetButtons,
- SH_Slider_PageSetButtons,
- SH_Menu_KeyboardSearch,
- SH_TabBar_ElideMode,
- SH_DialogButtonLayout,
- SH_ComboBox_PopupFrameStyle,
- SH_MessageBox_TextInteractionFlags,
- SH_DialogButtonBox_ButtonsHaveIcons,
- SH_SpellCheckUnderlineStyle,
- SH_MessageBox_CenterButtons,
- SH_Menu_SelectionWrap,
- SH_ItemView_MovementWithoutUpdatingSelection,
- SH_ToolTip_Mask,
- SH_FocusFrame_AboveWidget,
- SH_TextControl_FocusIndicatorTextCharFormat,
- SH_WizardStyle,
- SH_ItemView_ArrowKeysNavigateIntoChildren,
- SH_Menu_Mask,
- SH_Menu_FlashTriggeredItem,
- SH_Menu_FadeOutOnHide,
- SH_SpinBox_ClickAutoRepeatThreshold,
- SH_ItemView_PaintAlternatingRowColorsForEmptyArea,
- SH_FormLayoutWrapPolicy,
- SH_TabWidget_DefaultTabPosition,
- SH_ToolBar_Movable,
- SH_FormLayoutFieldGrowthPolicy,
- SH_FormLayoutFormAlignment,
- SH_FormLayoutLabelAlignment,
- SH_ItemView_DrawDelegateFrame,
- SH_TabBar_CloseButtonPosition,
- SH_DockWidget_ButtonsHaveFrame,
- SH_ToolButtonStyle,
- SH_RequestSoftwareInputPanel,
- // Add new style hint values here
-
-#ifdef QT3_SUPPORT
- SH_GUIStyle = 0x00000100,
- SH_ScrollBar_BackgroundMode,
- // Add other compat values here
-
- SH_UnderlineAccelerator = SH_UnderlineShortcut,
-#endif
- SH_CustomBase = 0xf0000000
- };
-
- virtual int styleHint(StyleHint stylehint, const QStyleOption *opt = 0,
- const QWidget *widget = 0, QStyleHintReturn* returnData = 0) const = 0;
-
- enum StandardPixmap {
- SP_TitleBarMenuButton,
- SP_TitleBarMinButton,
- SP_TitleBarMaxButton,
- SP_TitleBarCloseButton,
- SP_TitleBarNormalButton,
- SP_TitleBarShadeButton,
- SP_TitleBarUnshadeButton,
- SP_TitleBarContextHelpButton,
- SP_DockWidgetCloseButton,
- SP_MessageBoxInformation,
- SP_MessageBoxWarning,
- SP_MessageBoxCritical,
- SP_MessageBoxQuestion,
- SP_DesktopIcon,
- SP_TrashIcon,
- SP_ComputerIcon,
- SP_DriveFDIcon,
- SP_DriveHDIcon,
- SP_DriveCDIcon,
- SP_DriveDVDIcon,
- SP_DriveNetIcon,
- SP_DirOpenIcon,
- SP_DirClosedIcon,
- SP_DirLinkIcon,
- SP_FileIcon,
- SP_FileLinkIcon,
- SP_ToolBarHorizontalExtensionButton,
- SP_ToolBarVerticalExtensionButton,
- SP_FileDialogStart,
- SP_FileDialogEnd,
- SP_FileDialogToParent,
- SP_FileDialogNewFolder,
- SP_FileDialogDetailedView,
- SP_FileDialogInfoView,
- SP_FileDialogContentsView,
- SP_FileDialogListView,
- SP_FileDialogBack,
- SP_DirIcon,
- SP_DialogOkButton,
- SP_DialogCancelButton,
- SP_DialogHelpButton,
- SP_DialogOpenButton,
- SP_DialogSaveButton,
- SP_DialogCloseButton,
- SP_DialogApplyButton,
- SP_DialogResetButton,
- SP_DialogDiscardButton,
- SP_DialogYesButton,
- SP_DialogNoButton,
- SP_ArrowUp,
- SP_ArrowDown,
- SP_ArrowLeft,
- SP_ArrowRight,
- SP_ArrowBack,
- SP_ArrowForward,
- SP_DirHomeIcon,
- SP_CommandLink,
- SP_VistaShield,
- SP_BrowserReload,
- SP_BrowserStop,
- SP_MediaPlay,
- SP_MediaStop,
- SP_MediaPause,
- SP_MediaSkipForward,
- SP_MediaSkipBackward,
- SP_MediaSeekForward,
- SP_MediaSeekBackward,
- SP_MediaVolume,
- SP_MediaVolumeMuted,
- // do not add any values below/greater than this
- SP_CustomBase = 0xf0000000
- };
-
- virtual QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt = 0,
- const QWidget *widget = 0) const = 0;
-
- QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = 0,
- const QWidget *widget = 0) const;
-
- virtual QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
- const QStyleOption *opt) const = 0;
-
- static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect,
- const QRect &logicalRect);
- static QPoint visualPos(Qt::LayoutDirection direction, const QRect &boundingRect,
- const QPoint &logicalPos);
- static int sliderPositionFromValue(int min, int max, int val, int space,
- bool upsideDown = false);
- static int sliderValueFromPosition(int min, int max, int pos, int space,
- bool upsideDown = false);
- static Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment);
- static QRect alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment,
- const QSize &size, const QRect &rectangle);
-
- int layoutSpacing(QSizePolicy::ControlType control1,
- QSizePolicy::ControlType control2, Qt::Orientation orientation,
- const QStyleOption *option = 0, const QWidget *widget = 0) const;
- int combinedLayoutSpacing(QSizePolicy::ControlTypes controls1,
- QSizePolicy::ControlTypes controls2, Qt::Orientation orientation,
- QStyleOption *option = 0, QWidget *widget = 0) const;
-
- const QStyle * proxy() const;
-
-protected Q_SLOTS:
- QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt = 0,
- const QWidget *widget = 0) const;
- int layoutSpacingImplementation(QSizePolicy::ControlType control1,
- QSizePolicy::ControlType control2,
- Qt::Orientation orientation,
- const QStyleOption *option = 0,
- const QWidget *widget = 0) const;
-
-private:
- Q_DISABLE_COPY(QStyle)
- friend class QWidget;
- friend class QWidgetPrivate;
- friend class QApplication;
- friend class QProxyStyle;
- friend class QProxyStylePrivate;
- void setProxy(QStyle *style);
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QStyle::State)
-Q_DECLARE_OPERATORS_FOR_FLAGS(QStyle::SubControls)
-
-#if !defined(QT_NO_DEBUG_STREAM)
-Q_GUI_EXPORT QDebug operator<<(QDebug debug, QStyle::State state);
-#endif
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSTYLE_H
diff --git a/src/gui/styles/qstyle_p.h b/src/gui/styles/qstyle_p.h
deleted file mode 100644
index 1fcd2eaf2a..0000000000
--- a/src/gui/styles/qstyle_p.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSTYLE_P_H
-#define QSTYLE_P_H
-
-#include "private/qobject_p.h"
-#include <QtGui/qstyle.h>
-
-QT_BEGIN_NAMESPACE
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of qstyle_*.cpp. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-//
-
-// Private class
-
-class QStyle;
-
-class QStylePrivate: public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QStyle)
-public:
- inline QStylePrivate()
- : layoutSpacingIndex(-1), proxyStyle(0) {}
- mutable int layoutSpacingIndex;
- QStyle *proxyStyle;
-};
-
-
-#define BEGIN_STYLE_PIXMAPCACHE(a) \
- QRect rect = option->rect; \
- QPixmap internalPixmapCache; \
- QImage imageCache; \
- QPainter *p = painter; \
- QString unique = QStyleHelper::uniqueName((a), option, option->rect.size()); \
- int txType = painter->deviceTransform().type() | painter->worldTransform().type(); \
- bool doPixmapCache = txType <= QTransform::TxTranslate; \
- if (doPixmapCache && QPixmapCache::find(unique, internalPixmapCache)) { \
- painter->drawPixmap(option->rect.topLeft(), internalPixmapCache); \
- } else { \
- if (doPixmapCache) { \
- rect.setRect(0, 0, option->rect.width(), option->rect.height()); \
- imageCache = QImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); \
- imageCache.fill(0); \
- p = new QPainter(&imageCache); \
- }
-
-
-
-#define END_STYLE_PIXMAPCACHE \
- if (doPixmapCache) { \
- p->end(); \
- delete p; \
- internalPixmapCache = QPixmap::fromImage(imageCache); \
- painter->drawPixmap(option->rect.topLeft(), internalPixmapCache); \
- QPixmapCache::insert(unique, internalPixmapCache); \
- } \
- }
-
-QT_END_NAMESPACE
-
-#endif //QSTYLE_P_H
diff --git a/src/gui/styles/qstylehelper_p.h b/src/gui/styles/qstylehelper_p.h
deleted file mode 100644
index 27587e30ac..0000000000
--- a/src/gui/styles/qstylehelper_p.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore/qglobal.h>
-#include <QtCore/qpoint.h>
-#include <QtCore/qstring.h>
-#include <QtGui/qpolygon.h>
-#include <QtCore/qstringbuilder.h>
-
-#ifndef QSTYLEHELPER_P_H
-#define QSTYLEHELPER_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.
-//
-
-QT_BEGIN_NAMESPACE
-
-class QPainter;
-class QPixmap;
-class QStyleOptionSlider;
-class QStyleOption;
-
-namespace QStyleHelper
-{
- QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size);
- qreal dpiScaled(qreal value);
-#ifndef QT_NO_DIAL
- qreal angle(const QPointF &p1, const QPointF &p2);
- QPolygonF calcLines(const QStyleOptionSlider *dial);
- int calcBigLineSize(int radius);
- void drawDial(const QStyleOptionSlider *dial, QPainter *painter);
-#endif //QT_NO_DIAL
- void drawBorderPixmap(const QPixmap &pixmap, QPainter *painter, const QRect &rect,
- int left = 0, int top = 0, int right = 0,
- int bottom = 0);
-}
-
-// internal helper. Converts an integer value to an unique string token
-template <typename T>
- struct HexString
-{
- inline HexString(const T t)
- : val(t)
- {}
-
- inline void write(QChar *&dest) const
- {
- const ushort hexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
- const char *c = reinterpret_cast<const char *>(&val);
- for (uint i = 0; i < sizeof(T); ++i) {
- *dest++ = hexChars[*c & 0xf];
- *dest++ = hexChars[(*c & 0xf0) >> 4];
- ++c;
- }
- }
- const T val;
-};
-
-// specialization to enable fast concatenating of our string tokens to a string
-template <typename T>
- struct QConcatenable<HexString<T> >
-{
- typedef HexString<T> type;
- enum { ExactSize = true };
- static int size(const HexString<T> &) { return sizeof(T) * 2; }
- static inline void appendTo(const HexString<T> &str, QChar *&out) { str.write(out); }
- typedef QString ConvertTo;
-};
-
-QT_END_NAMESPACE
-
-#endif // QSTYLEHELPER_P_H
diff --git a/src/gui/styles/qstyleoption.h b/src/gui/styles/qstyleoption.h
deleted file mode 100644
index 1b1de9cdf2..0000000000
--- a/src/gui/styles/qstyleoption.h
+++ /dev/null
@@ -1,970 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSTYLEOPTION_H
-#define QSTYLEOPTION_H
-
-#include <QtCore/qvariant.h>
-#include <QtGui/qabstractspinbox.h>
-#include <QtGui/qicon.h>
-#include <QtGui/qmatrix.h>
-#include <QtGui/qslider.h>
-#include <QtGui/qstyle.h>
-#include <QtGui/qtabbar.h>
-#include <QtGui/qtabwidget.h>
-#include <QtGui/qrubberband.h>
-#include <QtGui/qframe.h>
-#ifndef QT_NO_ITEMVIEWS
-# include <QtCore/qabstractitemmodel.h>
-#endif
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QDebug;
-
-class Q_GUI_EXPORT QStyleOption
-{
-public:
- enum OptionType {
- SO_Default, SO_FocusRect, SO_Button, SO_Tab, SO_MenuItem,
- SO_Frame, SO_ProgressBar, SO_ToolBox, SO_Header, SO_Q3DockWindow,
- SO_DockWidget, SO_Q3ListViewItem, SO_ViewItem, SO_TabWidgetFrame,
- SO_TabBarBase, SO_RubberBand, SO_ToolBar, SO_GraphicsItem,
-
- SO_Complex = 0xf0000, SO_Slider, SO_SpinBox, SO_ToolButton, SO_ComboBox,
- SO_Q3ListView, SO_TitleBar, SO_GroupBox, SO_SizeGrip,
-
- SO_CustomBase = 0xf00,
- SO_ComplexCustomBase = 0xf000000
- };
-
- enum StyleOptionType { Type = SO_Default };
- enum StyleOptionVersion { Version = 1 };
-
- int version;
- int type;
- QStyle::State state;
- Qt::LayoutDirection direction;
- QRect rect;
- QFontMetrics fontMetrics;
- QPalette palette;
-
- QStyleOption(int version = QStyleOption::Version, int type = SO_Default);
- QStyleOption(const QStyleOption &other);
- ~QStyleOption();
-
- void init(const QWidget *w);
- inline void initFrom(const QWidget *w) { init(w); }
- QStyleOption &operator=(const QStyleOption &other);
-};
-
-class Q_GUI_EXPORT QStyleOptionFocusRect : public QStyleOption
-{
-public:
- enum StyleOptionType { Type = SO_FocusRect };
- enum StyleOptionVersion { Version = 1 };
-
- QColor backgroundColor;
-
- QStyleOptionFocusRect();
- QStyleOptionFocusRect(const QStyleOptionFocusRect &other) : QStyleOption(Version, Type) { *this = other; }
-
-protected:
- QStyleOptionFocusRect(int version);
-};
-
-class Q_GUI_EXPORT QStyleOptionFrame : public QStyleOption
-{
-public:
- enum StyleOptionType { Type = SO_Frame };
- enum StyleOptionVersion { Version = 1 };
-
- int lineWidth;
- int midLineWidth;
-
- QStyleOptionFrame();
- QStyleOptionFrame(const QStyleOptionFrame &other) : QStyleOption(Version, Type) { *this = other; }
-
-protected:
- QStyleOptionFrame(int version);
-};
-
-class Q_GUI_EXPORT QStyleOptionFrameV2 : public QStyleOptionFrame
-{
-public:
- enum StyleOptionVersion { Version = 2 };
- enum FrameFeature {
- None = 0x00,
- Flat = 0x01
- };
- Q_DECLARE_FLAGS(FrameFeatures, FrameFeature)
- FrameFeatures features;
-
- QStyleOptionFrameV2();
- QStyleOptionFrameV2(const QStyleOptionFrameV2 &other) : QStyleOptionFrame(Version) { *this = other; }
- QStyleOptionFrameV2(const QStyleOptionFrame &other);
- QStyleOptionFrameV2 &operator=(const QStyleOptionFrame &other);
-
-protected:
- QStyleOptionFrameV2(int version);
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionFrameV2::FrameFeatures)
-
-
-class Q_GUI_EXPORT QStyleOptionFrameV3 : public QStyleOptionFrameV2
-{
-public:
- enum StyleOptionVersion { Version = 3 };
- QFrame::Shape frameShape : 4;
- uint unused : 28;
-
- QStyleOptionFrameV3();
- QStyleOptionFrameV3(const QStyleOptionFrameV3 &other) : QStyleOptionFrameV2(Version) { *this = other; }
- QStyleOptionFrameV3(const QStyleOptionFrame &other);
- QStyleOptionFrameV3 &operator=(const QStyleOptionFrame &other);
-
-protected:
- QStyleOptionFrameV3(int version);
-};
-
-
-#ifndef QT_NO_TABWIDGET
-class Q_GUI_EXPORT QStyleOptionTabWidgetFrame : public QStyleOption
-{
-public:
- enum StyleOptionType { Type = SO_TabWidgetFrame };
- enum StyleOptionVersion { Version = 1 };
-
- int lineWidth;
- int midLineWidth;
- QTabBar::Shape shape;
- QSize tabBarSize;
- QSize rightCornerWidgetSize;
- QSize leftCornerWidgetSize;
-
- QStyleOptionTabWidgetFrame();
- inline QStyleOptionTabWidgetFrame(const QStyleOptionTabWidgetFrame &other)
- : QStyleOption(Version, Type) { *this = other; }
-
-protected:
- QStyleOptionTabWidgetFrame(int version);
-};
-
-class Q_GUI_EXPORT QStyleOptionTabWidgetFrameV2 : public QStyleOptionTabWidgetFrame
-{
-public:
- enum StyleOptionVersion { Version = 2 };
-
- QRect tabBarRect;
- QRect selectedTabRect;
-
- QStyleOptionTabWidgetFrameV2();
- QStyleOptionTabWidgetFrameV2(const QStyleOptionTabWidgetFrameV2 &other) :
- QStyleOptionTabWidgetFrame(Version) { *this = other; }
- QStyleOptionTabWidgetFrameV2(const QStyleOptionTabWidgetFrame &other);
- QStyleOptionTabWidgetFrameV2 &operator=(const QStyleOptionTabWidgetFrame &other);
-
-protected:
- QStyleOptionTabWidgetFrameV2(int version);
-};
-
-#endif
-
-
-#ifndef QT_NO_TABBAR
-class Q_GUI_EXPORT QStyleOptionTabBarBase : public QStyleOption
-{
-public:
- enum StyleOptionType { Type = SO_TabBarBase };
- enum StyleOptionVersion { Version = 1 };
-
- QTabBar::Shape shape;
- QRect tabBarRect;
- QRect selectedTabRect;
-
- QStyleOptionTabBarBase();
- QStyleOptionTabBarBase(const QStyleOptionTabBarBase &other) : QStyleOption(Version, Type) { *this = other; }
-
-protected:
- QStyleOptionTabBarBase(int version);
-};
-
-class Q_GUI_EXPORT QStyleOptionTabBarBaseV2 : public QStyleOptionTabBarBase
-{
-public:
- enum StyleOptionVersion { Version = 2 };
- bool documentMode;
- QStyleOptionTabBarBaseV2();
- QStyleOptionTabBarBaseV2(const QStyleOptionTabBarBaseV2 &other) : QStyleOptionTabBarBase(Version) { *this = other; }
- QStyleOptionTabBarBaseV2(const QStyleOptionTabBarBase &other);
- QStyleOptionTabBarBaseV2 &operator=(const QStyleOptionTabBarBase &other);
-
-protected:
- QStyleOptionTabBarBaseV2(int version);
-};
-
-#endif
-
-class Q_GUI_EXPORT QStyleOptionHeader : public QStyleOption
-{
-public:
- enum StyleOptionType { Type = SO_Header };
- enum StyleOptionVersion { Version = 1 };
-
- enum SectionPosition { Beginning, Middle, End, OnlyOneSection };
- enum SelectedPosition { NotAdjacent, NextIsSelected, PreviousIsSelected,
- NextAndPreviousAreSelected };
- enum SortIndicator { None, SortUp, SortDown };
-
- int section;
- QString text;
- Qt::Alignment textAlignment;
- QIcon icon;
- Qt::Alignment iconAlignment;
- SectionPosition position;
- SelectedPosition selectedPosition;
- SortIndicator sortIndicator;
- Qt::Orientation orientation;
-
- QStyleOptionHeader();
- QStyleOptionHeader(const QStyleOptionHeader &other) : QStyleOption(Version, Type) { *this = other; }
-
-protected:
- QStyleOptionHeader(int version);
-};
-
-class Q_GUI_EXPORT QStyleOptionButton : public QStyleOption
-{
-public:
- enum StyleOptionType { Type = SO_Button };
- enum StyleOptionVersion { Version = 1 };
-
- enum ButtonFeature { None = 0x00, Flat = 0x01, HasMenu = 0x02, DefaultButton = 0x04,
- AutoDefaultButton = 0x08, CommandLinkButton = 0x10 };
- Q_DECLARE_FLAGS(ButtonFeatures, ButtonFeature)
-
- ButtonFeatures features;
- QString text;
- QIcon icon;
- QSize iconSize;
-
- QStyleOptionButton();
- QStyleOptionButton(const QStyleOptionButton &other) : QStyleOption(Version, Type) { *this = other; }
-
-protected:
- QStyleOptionButton(int version);
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionButton::ButtonFeatures)
-
-#ifndef QT_NO_TABBAR
-class Q_GUI_EXPORT QStyleOptionTab : public QStyleOption
-{
-public:
- enum StyleOptionType { Type = SO_Tab };
- enum StyleOptionVersion { Version = 1 };
-
- enum TabPosition { Beginning, Middle, End, OnlyOneTab };
- enum SelectedPosition { NotAdjacent, NextIsSelected, PreviousIsSelected };
- enum CornerWidget { NoCornerWidgets = 0x00, LeftCornerWidget = 0x01,
- RightCornerWidget = 0x02 };
- Q_DECLARE_FLAGS(CornerWidgets, CornerWidget)
-
- QTabBar::Shape shape;
- QString text;
- QIcon icon;
- int row;
- TabPosition position;
- SelectedPosition selectedPosition;
- CornerWidgets cornerWidgets;
-
- QStyleOptionTab();
- QStyleOptionTab(const QStyleOptionTab &other) : QStyleOption(Version, Type) { *this = other; }
-
-protected:
- QStyleOptionTab(int version);
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionTab::CornerWidgets)
-
-class Q_GUI_EXPORT QStyleOptionTabV2 : public QStyleOptionTab
-{
-public:
- enum StyleOptionVersion { Version = 2 };
- QSize iconSize;
- QStyleOptionTabV2();
- QStyleOptionTabV2(const QStyleOptionTabV2 &other) : QStyleOptionTab(Version) { *this = other; }
- QStyleOptionTabV2(const QStyleOptionTab &other);
- QStyleOptionTabV2 &operator=(const QStyleOptionTab &other);
-
-protected:
- QStyleOptionTabV2(int version);
-};
-
-class Q_GUI_EXPORT QStyleOptionTabV3 : public QStyleOptionTabV2
-{
-public:
- enum StyleOptionVersion { Version = 3 };
- bool documentMode;
- QSize leftButtonSize;
- QSize rightButtonSize;
- QStyleOptionTabV3();
- QStyleOptionTabV3(const QStyleOptionTabV3 &other) : QStyleOptionTabV2(Version) { *this = other; }
- QStyleOptionTabV3(const QStyleOptionTabV2 &other) : QStyleOptionTabV2(Version) { *this = other; }
- QStyleOptionTabV3(const QStyleOptionTab &other);
- QStyleOptionTabV3 &operator=(const QStyleOptionTab &other);
-
-protected:
- QStyleOptionTabV3(int version);
-};
-
-#endif
-
-
-#ifndef QT_NO_TOOLBAR
-
-class Q_GUI_EXPORT QStyleOptionToolBar : public QStyleOption
-{
-public:
- enum StyleOptionType { Type = SO_ToolBar };
- enum StyleOptionVersion { Version = 1 };
- enum ToolBarPosition { Beginning, Middle, End, OnlyOne };
- enum ToolBarFeature { None = 0x0, Movable = 0x1 };
- Q_DECLARE_FLAGS(ToolBarFeatures, ToolBarFeature)
- ToolBarPosition positionOfLine; // The toolbar line position
- ToolBarPosition positionWithinLine; // The position within a toolbar
- Qt::ToolBarArea toolBarArea; // The toolbar docking area
- ToolBarFeatures features;
- int lineWidth;
- int midLineWidth;
- QStyleOptionToolBar();
- QStyleOptionToolBar(const QStyleOptionToolBar &other) : QStyleOption(Version, Type) { *this = other; }
-
-protected:
- QStyleOptionToolBar(int version);
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionToolBar::ToolBarFeatures)
-
-#endif
-
-
-
-class Q_GUI_EXPORT QStyleOptionProgressBar : public QStyleOption
-{
-public:
- enum StyleOptionType { Type = SO_ProgressBar };
- enum StyleOptionVersion { Version = 1 };
-
- int minimum;
- int maximum;
- int progress;
- QString text;
- Qt::Alignment textAlignment;
- bool textVisible;
-
- QStyleOptionProgressBar();
- QStyleOptionProgressBar(const QStyleOptionProgressBar &other) : QStyleOption(Version, Type) { *this = other; }
-
-protected:
- QStyleOptionProgressBar(int version);
-};
-
-// Adds style info for vertical progress bars
-class Q_GUI_EXPORT QStyleOptionProgressBarV2 : public QStyleOptionProgressBar
-{
-public:
- enum StyleOptionType { Type = SO_ProgressBar };
- enum StyleOptionVersion { Version = 2 };
- Qt::Orientation orientation;
- bool invertedAppearance;
- bool bottomToTop;
-
- QStyleOptionProgressBarV2();
- QStyleOptionProgressBarV2(const QStyleOptionProgressBar &other);
- QStyleOptionProgressBarV2(const QStyleOptionProgressBarV2 &other);
- QStyleOptionProgressBarV2 &operator=(const QStyleOptionProgressBar &other);
-
-protected:
- QStyleOptionProgressBarV2(int version);
-};
-
-class Q_GUI_EXPORT QStyleOptionMenuItem : public QStyleOption
-{
-public:
- enum StyleOptionType { Type = SO_MenuItem };
- enum StyleOptionVersion { Version = 1 };
-
- enum MenuItemType { Normal, DefaultItem, Separator, SubMenu, Scroller, TearOff, Margin,
- EmptyArea };
- enum CheckType { NotCheckable, Exclusive, NonExclusive };
-
- MenuItemType menuItemType;
- CheckType checkType;
- bool checked;
- bool menuHasCheckableItems;
- QRect menuRect;
- QString text;
- QIcon icon;
- int maxIconWidth;
- int tabWidth;
- QFont font;
-
- QStyleOptionMenuItem();
- QStyleOptionMenuItem(const QStyleOptionMenuItem &other) : QStyleOption(Version, Type) { *this = other; }
-
-protected:
- QStyleOptionMenuItem(int version);
-};
-
-class Q_GUI_EXPORT QStyleOptionQ3ListViewItem : public QStyleOption
-{
-public:
- enum StyleOptionType { Type = SO_Q3ListViewItem };
- enum StyleOptionVersion { Version = 1 };
-
- enum Q3ListViewItemFeature { None = 0x00, Expandable = 0x01, MultiLine = 0x02, Visible = 0x04,
- ParentControl = 0x08 };
- Q_DECLARE_FLAGS(Q3ListViewItemFeatures, Q3ListViewItemFeature)
-
- Q3ListViewItemFeatures features;
- int height;
- int totalHeight;
- int itemY;
- int childCount;
-
- QStyleOptionQ3ListViewItem();
- QStyleOptionQ3ListViewItem(const QStyleOptionQ3ListViewItem &other) : QStyleOption(Version, Type) { *this = other; }
-
-protected:
- QStyleOptionQ3ListViewItem(int version);
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionQ3ListViewItem::Q3ListViewItemFeatures)
-
-class Q_GUI_EXPORT QStyleOptionQ3DockWindow : public QStyleOption
-{
-public:
- enum StyleOptionType { Type = SO_Q3DockWindow };
- enum StyleOptionVersion { Version = 1 };
-
- bool docked;
- bool closeEnabled;
-
- QStyleOptionQ3DockWindow();
- QStyleOptionQ3DockWindow(const QStyleOptionQ3DockWindow &other) : QStyleOption(Version, Type) { *this = other; }
-
-protected:
- QStyleOptionQ3DockWindow(int version);
-};
-
-class Q_GUI_EXPORT QStyleOptionDockWidget : public QStyleOption
-{
-public:
- enum StyleOptionType { Type = SO_DockWidget };
- enum StyleOptionVersion { Version = 1 };
-
- QString title;
- bool closable;
- bool movable;
- bool floatable;
-
- QStyleOptionDockWidget();
- QStyleOptionDockWidget(const QStyleOptionDockWidget &other) : QStyleOption(Version, Type) { *this = other; }
-
-protected:
- QStyleOptionDockWidget(int version);
-};
-
-class Q_GUI_EXPORT QStyleOptionDockWidgetV2 : public QStyleOptionDockWidget
-{
-public:
- enum StyleOptionVersion { Version = 2 };
-
- bool verticalTitleBar;
-
- QStyleOptionDockWidgetV2();
- QStyleOptionDockWidgetV2(const QStyleOptionDockWidgetV2 &other)
- : QStyleOptionDockWidget(Version) { *this = other; }
- QStyleOptionDockWidgetV2(const QStyleOptionDockWidget &other);
- QStyleOptionDockWidgetV2 &operator = (const QStyleOptionDockWidget &other);
-
-protected:
- QStyleOptionDockWidgetV2(int version);
-};
-
-class Q_GUI_EXPORT QStyleOptionViewItem : public QStyleOption
-{
-public:
- enum StyleOptionType { Type = SO_ViewItem };
- enum StyleOptionVersion { Version = 1 };
-
- enum Position { Left, Right, Top, Bottom };
-
- Qt::Alignment displayAlignment;
- Qt::Alignment decorationAlignment;
- Qt::TextElideMode textElideMode;
- Position decorationPosition;
- QSize decorationSize;
- QFont font;
- bool showDecorationSelected;
-
- QStyleOptionViewItem();
- QStyleOptionViewItem(const QStyleOptionViewItem &other) : QStyleOption(Version, Type) { *this = other; }
-
-protected:
- QStyleOptionViewItem(int version);
-};
-
-class Q_GUI_EXPORT QStyleOptionViewItemV2 : public QStyleOptionViewItem
-{
-public:
- enum StyleOptionVersion { Version = 2 };
-
- enum ViewItemFeature {
- None = 0x00,
- WrapText = 0x01,
- Alternate = 0x02,
- HasCheckIndicator = 0x04,
- HasDisplay = 0x08,
- HasDecoration = 0x10
- };
- Q_DECLARE_FLAGS(ViewItemFeatures, ViewItemFeature)
-
- ViewItemFeatures features;
-
- QStyleOptionViewItemV2();
- QStyleOptionViewItemV2(const QStyleOptionViewItemV2 &other) : QStyleOptionViewItem(Version) { *this = other; }
- QStyleOptionViewItemV2(const QStyleOptionViewItem &other);
- QStyleOptionViewItemV2 &operator=(const QStyleOptionViewItem &other);
-
-protected:
- QStyleOptionViewItemV2(int version);
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionViewItemV2::ViewItemFeatures)
-
-class Q_GUI_EXPORT QStyleOptionViewItemV3 : public QStyleOptionViewItemV2
-{
-public:
- enum StyleOptionVersion { Version = 3 };
-
- QLocale locale;
- const QWidget *widget;
-
- QStyleOptionViewItemV3();
- QStyleOptionViewItemV3(const QStyleOptionViewItemV3 &other)
- : QStyleOptionViewItemV2(Version) { *this = other; }
- QStyleOptionViewItemV3(const QStyleOptionViewItem &other);
- QStyleOptionViewItemV3 &operator = (const QStyleOptionViewItem &other);
-
-protected:
- QStyleOptionViewItemV3(int version);
-};
-
-#ifndef QT_NO_ITEMVIEWS
-class Q_GUI_EXPORT QStyleOptionViewItemV4 : public QStyleOptionViewItemV3
-{
-public:
- enum StyleOptionVersion { Version = 4 };
- enum ViewItemPosition { Invalid, Beginning, Middle, End, OnlyOne };
-
- QModelIndex index;
- Qt::CheckState checkState;
- QIcon icon;
- QString text;
- ViewItemPosition viewItemPosition;
- QBrush backgroundBrush;
-
- QStyleOptionViewItemV4();
- QStyleOptionViewItemV4(const QStyleOptionViewItemV4 &other)
- : QStyleOptionViewItemV3(Version) { *this = other; }
- QStyleOptionViewItemV4(const QStyleOptionViewItem &other);
- QStyleOptionViewItemV4 &operator = (const QStyleOptionViewItem &other);
-
-protected:
- QStyleOptionViewItemV4(int version);
-};
-#endif
-
-class Q_GUI_EXPORT QStyleOptionToolBox : public QStyleOption
-{
-public:
- enum StyleOptionType { Type = SO_ToolBox };
- enum StyleOptionVersion { Version = 1 };
-
- QString text;
- QIcon icon;
-
- QStyleOptionToolBox();
- QStyleOptionToolBox(const QStyleOptionToolBox &other) : QStyleOption(Version, Type) { *this = other; }
-
-protected:
- QStyleOptionToolBox(int version);
-};
-
-class Q_GUI_EXPORT QStyleOptionToolBoxV2 : public QStyleOptionToolBox
-{
-public:
- enum StyleOptionVersion { Version = 2 };
- enum TabPosition { Beginning, Middle, End, OnlyOneTab };
- enum SelectedPosition { NotAdjacent, NextIsSelected, PreviousIsSelected };
-
- TabPosition position;
- SelectedPosition selectedPosition;
-
- QStyleOptionToolBoxV2();
- QStyleOptionToolBoxV2(const QStyleOptionToolBoxV2 &other) : QStyleOptionToolBox(Version) { *this = other; }
- QStyleOptionToolBoxV2(const QStyleOptionToolBox &other);
- QStyleOptionToolBoxV2 &operator=(const QStyleOptionToolBox &other);
-
-protected:
- QStyleOptionToolBoxV2(int version);
-};
-
-#ifndef QT_NO_RUBBERBAND
-class Q_GUI_EXPORT QStyleOptionRubberBand : public QStyleOption
-{
-public:
- enum StyleOptionType { Type = SO_RubberBand };
- enum StyleOptionVersion { Version = 1 };
-
- QRubberBand::Shape shape;
- bool opaque;
-
- QStyleOptionRubberBand();
- QStyleOptionRubberBand(const QStyleOptionRubberBand &other) : QStyleOption(Version, Type) { *this = other; }
-
-protected:
- QStyleOptionRubberBand(int version);
-};
-#endif // QT_NO_RUBBERBAND
-
-// -------------------------- Complex style options -------------------------------
-class Q_GUI_EXPORT QStyleOptionComplex : public QStyleOption
-{
-public:
- enum StyleOptionType { Type = SO_Complex };
- enum StyleOptionVersion { Version = 1 };
-
- QStyle::SubControls subControls;
- QStyle::SubControls activeSubControls;
-
- QStyleOptionComplex(int version = QStyleOptionComplex::Version, int type = SO_Complex);
- QStyleOptionComplex(const QStyleOptionComplex &other) : QStyleOption(Version, Type) { *this = other; }
-};
-
-#ifndef QT_NO_SLIDER
-class Q_GUI_EXPORT QStyleOptionSlider : public QStyleOptionComplex
-{
-public:
- enum StyleOptionType { Type = SO_Slider };
- enum StyleOptionVersion { Version = 1 };
-
- Qt::Orientation orientation;
- int minimum;
- int maximum;
- QSlider::TickPosition tickPosition;
- int tickInterval;
- bool upsideDown;
- int sliderPosition;
- int sliderValue;
- int singleStep;
- int pageStep;
- qreal notchTarget;
- bool dialWrapping;
-
- QStyleOptionSlider();
- QStyleOptionSlider(const QStyleOptionSlider &other) : QStyleOptionComplex(Version, Type) { *this = other; }
-
-protected:
- QStyleOptionSlider(int version);
-};
-#endif // QT_NO_SLIDER
-
-#ifndef QT_NO_SPINBOX
-class Q_GUI_EXPORT QStyleOptionSpinBox : public QStyleOptionComplex
-{
-public:
- enum StyleOptionType { Type = SO_SpinBox };
- enum StyleOptionVersion { Version = 1 };
-
- QAbstractSpinBox::ButtonSymbols buttonSymbols;
- QAbstractSpinBox::StepEnabled stepEnabled;
- bool frame;
-
- QStyleOptionSpinBox();
- QStyleOptionSpinBox(const QStyleOptionSpinBox &other) : QStyleOptionComplex(Version, Type) { *this = other; }
-
-protected:
- QStyleOptionSpinBox(int version);
-};
-#endif // QT_NO_SPINBOX
-
-class Q_GUI_EXPORT QStyleOptionQ3ListView : public QStyleOptionComplex
-{
-public:
- enum StyleOptionType { Type = SO_Q3ListView };
- enum StyleOptionVersion { Version = 1 };
-
- QList<QStyleOptionQ3ListViewItem> items;
- QPalette viewportPalette;
- QPalette::ColorRole viewportBGRole;
- int sortColumn;
- int itemMargin;
- int treeStepSize;
- bool rootIsDecorated;
-
- QStyleOptionQ3ListView();
- QStyleOptionQ3ListView(const QStyleOptionQ3ListView &other) : QStyleOptionComplex(Version, Type) { *this = other; }
-
-protected:
- QStyleOptionQ3ListView(int version);
-};
-
-class Q_GUI_EXPORT QStyleOptionToolButton : public QStyleOptionComplex
-{
-public:
- enum StyleOptionType { Type = SO_ToolButton };
- enum StyleOptionVersion { Version = 1 };
-
- enum ToolButtonFeature { None = 0x00, Arrow = 0x01, Menu = 0x04, MenuButtonPopup = Menu, PopupDelay = 0x08,
- HasMenu = 0x10 };
- Q_DECLARE_FLAGS(ToolButtonFeatures, ToolButtonFeature)
-
- ToolButtonFeatures features;
- QIcon icon;
- QSize iconSize;
- QString text;
- Qt::ArrowType arrowType;
- Qt::ToolButtonStyle toolButtonStyle;
- QPoint pos;
- QFont font;
-
- QStyleOptionToolButton();
- QStyleOptionToolButton(const QStyleOptionToolButton &other) : QStyleOptionComplex(Version, Type) { *this = other; }
-
-protected:
- QStyleOptionToolButton(int version);
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionToolButton::ToolButtonFeatures)
-
-class Q_GUI_EXPORT QStyleOptionComboBox : public QStyleOptionComplex
-{
-public:
- enum StyleOptionType { Type = SO_ComboBox };
- enum StyleOptionVersion { Version = 1 };
-
- bool editable;
- QRect popupRect;
- bool frame;
- QString currentText;
- QIcon currentIcon;
- QSize iconSize;
-
- QStyleOptionComboBox();
- QStyleOptionComboBox(const QStyleOptionComboBox &other) : QStyleOptionComplex(Version, Type) { *this = other; }
-
-protected:
- QStyleOptionComboBox(int version);
-};
-
-class Q_GUI_EXPORT QStyleOptionTitleBar : public QStyleOptionComplex
-{
-public:
- enum StyleOptionType { Type = SO_TitleBar };
- enum StyleOptionVersion { Version = 1 };
-
- QString text;
- QIcon icon;
- int titleBarState;
- Qt::WindowFlags titleBarFlags;
-
- QStyleOptionTitleBar();
- QStyleOptionTitleBar(const QStyleOptionTitleBar &other) : QStyleOptionComplex(Version, Type) { *this = other; }
-
-protected:
- QStyleOptionTitleBar(int version);
-};
-
-class Q_GUI_EXPORT QStyleOptionGroupBox : public QStyleOptionComplex
-{
-public:
- enum StyleOptionType { Type = SO_GroupBox };
- enum StyleOptionVersion { Version = 1 };
-
- QStyleOptionFrameV2::FrameFeatures features;
- QString text;
- Qt::Alignment textAlignment;
- QColor textColor;
- int lineWidth;
- int midLineWidth;
-
- QStyleOptionGroupBox();
- QStyleOptionGroupBox(const QStyleOptionGroupBox &other) : QStyleOptionComplex(Version, Type) { *this = other; }
-protected:
- QStyleOptionGroupBox(int version);
-};
-
-class Q_GUI_EXPORT QStyleOptionSizeGrip : public QStyleOptionComplex
-{
-public:
- enum StyleOptionType { Type = SO_SizeGrip };
- enum StyleOptionVersion { Version = 1 };
-
- Qt::Corner corner;
-
- QStyleOptionSizeGrip();
- QStyleOptionSizeGrip(const QStyleOptionSizeGrip &other) : QStyleOptionComplex(Version, Type) { *this = other; }
-protected:
- QStyleOptionSizeGrip(int version);
-};
-
-class Q_GUI_EXPORT QStyleOptionGraphicsItem : public QStyleOption
-{
-public:
- enum StyleOptionType { Type = SO_GraphicsItem };
- enum StyleOptionVersion { Version = 1 };
-
- QRectF exposedRect;
- QMatrix matrix;
- qreal levelOfDetail;
-
- QStyleOptionGraphicsItem();
- QStyleOptionGraphicsItem(const QStyleOptionGraphicsItem &other) : QStyleOption(Version, Type) { *this = other; }
- static qreal levelOfDetailFromTransform(const QTransform &worldTransform);
-protected:
- QStyleOptionGraphicsItem(int version);
-};
-
-template <typename T>
-T qstyleoption_cast(const QStyleOption *opt)
-{
- if (opt && opt->version >= static_cast<T>(0)->Version && (opt->type == static_cast<T>(0)->Type
- || int(static_cast<T>(0)->Type) == QStyleOption::SO_Default
- || (int(static_cast<T>(0)->Type) == QStyleOption::SO_Complex
- && opt->type > QStyleOption::SO_Complex)))
- return static_cast<T>(opt);
- return 0;
-}
-
-template <typename T>
-T qstyleoption_cast(QStyleOption *opt)
-{
- if (opt && opt->version >= static_cast<T>(0)->Version && (opt->type == static_cast<T>(0)->Type
- || int(static_cast<T>(0)->Type) == QStyleOption::SO_Default
- || (int(static_cast<T>(0)->Type) == QStyleOption::SO_Complex
- && opt->type > QStyleOption::SO_Complex)))
- return static_cast<T>(opt);
- return 0;
-}
-
-// -------------------------- QStyleHintReturn -------------------------------
-class Q_GUI_EXPORT QStyleHintReturn {
-public:
- enum HintReturnType {
- SH_Default=0xf000, SH_Mask, SH_Variant
- };
-
- enum StyleOptionType { Type = SH_Default };
- enum StyleOptionVersion { Version = 1 };
-
- QStyleHintReturn(int version = QStyleOption::Version, int type = SH_Default);
- ~QStyleHintReturn();
-
- int version;
- int type;
-};
-
-class Q_GUI_EXPORT QStyleHintReturnMask : public QStyleHintReturn {
-public:
- enum StyleOptionType { Type = SH_Mask };
- enum StyleOptionVersion { Version = 1 };
-
- QStyleHintReturnMask();
-
- QRegion region;
-};
-
-class Q_GUI_EXPORT QStyleHintReturnVariant : public QStyleHintReturn {
-public:
- enum StyleOptionType { Type = SH_Variant };
- enum StyleOptionVersion { Version = 1 };
-
- QStyleHintReturnVariant();
-
- QVariant variant;
-};
-
-template <typename T>
-T qstyleoption_cast(const QStyleHintReturn *hint)
-{
- if (hint && hint->version <= static_cast<T>(0)->Version &&
- (hint->type == static_cast<T>(0)->Type || int(static_cast<T>(0)->Type) == QStyleHintReturn::SH_Default))
- return static_cast<T>(hint);
- return 0;
-}
-
-template <typename T>
-T qstyleoption_cast(QStyleHintReturn *hint)
-{
- if (hint && hint->version <= static_cast<T>(0)->Version &&
- (hint->type == static_cast<T>(0)->Type || int(static_cast<T>(0)->Type) == QStyleHintReturn::SH_Default))
- return static_cast<T>(hint);
- return 0;
-}
-
-#if !defined(QT_NO_DEBUG_STREAM)
-Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType);
-Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QStyleOption &option);
-#endif
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSTYLEOPTION_H
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
deleted file mode 100644
index faa929ebea..0000000000
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ /dev/null
@@ -1,5898 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qglobal.h>
-
-#ifndef QT_NO_STYLE_STYLESHEET
-
-#include "qstylesheetstyle_p.h"
-#include "private/qcssutil_p.h"
-#include <qdebug.h>
-#include <qapplication.h>
-#include <qmenu.h>
-#include <qmenubar.h>
-#include <qpainter.h>
-#include <qstyleoption.h>
-#include <qlineedit.h>
-#include <qwindowsstyle.h>
-#include <qcombobox.h>
-#include <qwindowsstyle.h>
-#include <qplastiquestyle.h>
-#include "private/qcssparser_p.h"
-#include "private/qmath_p.h"
-#include <qabstractscrollarea.h>
-#include "private/qabstractscrollarea_p.h"
-#include <qtooltip.h>
-#include <qshareddata.h>
-#include <qradiobutton.h>
-#include <qtoolbutton.h>
-#include <qscrollbar.h>
-#include <qstring.h>
-#include <qfile.h>
-#include <qcheckbox.h>
-#include <qstatusbar.h>
-#include <qheaderview.h>
-#include <qprogressbar.h>
-#include <private/qwindowsstyle_p.h>
-#include <qtabbar.h>
-#include <QMetaProperty>
-#include <qmainwindow.h>
-#include <qdockwidget.h>
-#include <qmdisubwindow.h>
-#include <qdialog.h>
-#include <private/qwidget_p.h>
-#include <QAbstractSpinBox>
-#include <QLabel>
-#include "qdrawutil.h"
-
-#include <limits.h>
-#include <QtGui/qtoolbar.h>
-
-QT_BEGIN_NAMESPACE
-
-using namespace QCss;
-
-
-class QStyleSheetStylePrivate : public QWindowsStylePrivate
-{
- Q_DECLARE_PUBLIC(QStyleSheetStyle)
-public:
- QStyleSheetStylePrivate() { }
-};
-
-
-static QStyleSheetStyleCaches *styleSheetCaches = 0;
-
-/* RECURSION_GUARD:
- * the QStyleSheetStyle is a proxy. If used with others proxy style, we may end up with something like:
- * QStyleSheetStyle -> ProxyStyle -> QStyleSheetStyle -> OriginalStyle
- * Recursion may happen if the style call the widget()->style() again.
- * Not to mention the performence penalty of having two lookup of rules.
- *
- * The first instance of QStyleSheetStyle will set globalStyleSheetStyle to itself. The second one
- * will notice the globalStyleSheetStyle is not istelf and call its base style directly.
- */
-static const QStyleSheetStyle *globalStyleSheetStyle = 0;
-class QStyleSheetStyleRecursionGuard
-{
- public:
- QStyleSheetStyleRecursionGuard(const QStyleSheetStyle *that)
- : guarded(globalStyleSheetStyle == 0)
- {
- if (guarded) globalStyleSheetStyle = that;
- }
- ~QStyleSheetStyleRecursionGuard() { if (guarded) globalStyleSheetStyle = 0; }
- bool guarded;
-};
-#define RECURSION_GUARD(RETURN) \
- if (globalStyleSheetStyle != 0 && globalStyleSheetStyle != this) { RETURN; } \
- QStyleSheetStyleRecursionGuard recursion_guard(this);
-
-#define ceil(x) ((int)(x) + ((x) > 0 && (x) != (int)(x)))
-
-enum PseudoElement {
- PseudoElement_None,
- PseudoElement_DownArrow,
- PseudoElement_UpArrow,
- PseudoElement_LeftArrow,
- PseudoElement_RightArrow,
- PseudoElement_Indicator,
- PseudoElement_ExclusiveIndicator,
- PseudoElement_PushButtonMenuIndicator,
- PseudoElement_ComboBoxDropDown,
- PseudoElement_ComboBoxArrow,
- PseudoElement_Item,
- PseudoElement_SpinBoxUpButton,
- PseudoElement_SpinBoxUpArrow,
- PseudoElement_SpinBoxDownButton,
- PseudoElement_SpinBoxDownArrow,
- PseudoElement_GroupBoxTitle,
- PseudoElement_GroupBoxIndicator,
- PseudoElement_ToolButtonMenu,
- PseudoElement_ToolButtonMenuArrow,
- PseudoElement_ToolButtonDownArrow,
- PseudoElement_ToolBoxTab,
- PseudoElement_ScrollBarSlider,
- PseudoElement_ScrollBarAddPage,
- PseudoElement_ScrollBarSubPage,
- PseudoElement_ScrollBarAddLine,
- PseudoElement_ScrollBarSubLine,
- PseudoElement_ScrollBarFirst,
- PseudoElement_ScrollBarLast,
- PseudoElement_ScrollBarUpArrow,
- PseudoElement_ScrollBarDownArrow,
- PseudoElement_ScrollBarLeftArrow,
- PseudoElement_ScrollBarRightArrow,
- PseudoElement_SplitterHandle,
- PseudoElement_ToolBarHandle,
- PseudoElement_ToolBarSeparator,
- PseudoElement_MenuScroller,
- PseudoElement_MenuTearoff,
- PseudoElement_MenuCheckMark,
- PseudoElement_MenuSeparator,
- PseudoElement_MenuIcon,
- PseudoElement_MenuRightArrow,
- PseudoElement_TreeViewBranch,
- PseudoElement_HeaderViewSection,
- PseudoElement_HeaderViewUpArrow,
- PseudoElement_HeaderViewDownArrow,
- PseudoElement_ProgressBarChunk,
- PseudoElement_TabBarTab,
- PseudoElement_TabBarScroller,
- PseudoElement_TabBarTear,
- PseudoElement_SliderGroove,
- PseudoElement_SliderHandle,
- PseudoElement_SliderAddPage,
- PseudoElement_SliderSubPage,
- PseudoElement_SliderTickmark,
- PseudoElement_TabWidgetPane,
- PseudoElement_TabWidgetTabBar,
- PseudoElement_TabWidgetLeftCorner,
- PseudoElement_TabWidgetRightCorner,
- PseudoElement_DockWidgetTitle,
- PseudoElement_DockWidgetCloseButton,
- PseudoElement_DockWidgetFloatButton,
- PseudoElement_DockWidgetSeparator,
- PseudoElement_MdiCloseButton,
- PseudoElement_MdiMinButton,
- PseudoElement_MdiNormalButton,
- PseudoElement_TitleBar,
- PseudoElement_TitleBarCloseButton,
- PseudoElement_TitleBarMinButton,
- PseudoElement_TitleBarMaxButton,
- PseudoElement_TitleBarShadeButton,
- PseudoElement_TitleBarUnshadeButton,
- PseudoElement_TitleBarNormalButton,
- PseudoElement_TitleBarContextHelpButton,
- PseudoElement_TitleBarSysMenu,
- PseudoElement_ViewItem,
- PseudoElement_ViewItemIcon,
- PseudoElement_ViewItemText,
- PseudoElement_ViewItemIndicator,
- PseudoElement_ScrollAreaCorner,
- PseudoElement_TabBarTabCloseButton,
- NumPseudoElements
-};
-
-struct PseudoElementInfo {
- QStyle::SubControl subControl;
- const char *name;
-};
-
-static const PseudoElementInfo knownPseudoElements[NumPseudoElements] = {
- { QStyle::SC_None, "" },
- { QStyle::SC_None, "down-arrow" },
- { QStyle::SC_None, "up-arrow" },
- { QStyle::SC_None, "left-arrow" },
- { QStyle::SC_None, "right-arrow" },
- { QStyle::SC_None, "indicator" },
- { QStyle::SC_None, "indicator" },
- { QStyle::SC_None, "menu-indicator" },
- { QStyle::SC_ComboBoxArrow, "drop-down" },
- { QStyle::SC_ComboBoxArrow, "down-arrow" },
- { QStyle::SC_None, "item" },
- { QStyle::SC_SpinBoxUp, "up-button" },
- { QStyle::SC_SpinBoxUp, "up-arrow" },
- { QStyle::SC_SpinBoxDown, "down-button" },
- { QStyle::SC_SpinBoxDown, "down-arrow" },
- { QStyle::SC_GroupBoxLabel, "title" },
- { QStyle::SC_GroupBoxCheckBox, "indicator" },
- { QStyle::SC_ToolButtonMenu, "menu-button" },
- { QStyle::SC_ToolButtonMenu, "menu-arrow" },
- { QStyle::SC_None, "menu-indicator" },
- { QStyle::SC_None, "tab" },
- { QStyle::SC_ScrollBarSlider, "handle" },
- { QStyle::SC_ScrollBarAddPage, "add-page" },
- { QStyle::SC_ScrollBarSubPage, "sub-page" },
- { QStyle::SC_ScrollBarAddLine, "add-line" },
- { QStyle::SC_ScrollBarSubLine, "sub-line" },
- { QStyle::SC_ScrollBarFirst, "first" },
- { QStyle::SC_ScrollBarLast, "last" },
- { QStyle::SC_ScrollBarSubLine, "up-arrow" },
- { QStyle::SC_ScrollBarAddLine, "down-arrow" },
- { QStyle::SC_ScrollBarSubLine, "left-arrow" },
- { QStyle::SC_ScrollBarAddLine, "right-arrow" },
- { QStyle::SC_None, "handle" },
- { QStyle::SC_None, "handle" },
- { QStyle::SC_None, "separator" },
- { QStyle::SC_None, "scroller" },
- { QStyle::SC_None, "tearoff" },
- { QStyle::SC_None, "indicator" },
- { QStyle::SC_None, "separator" },
- { QStyle::SC_None, "icon" },
- { QStyle::SC_None, "right-arrow" },
- { QStyle::SC_None, "branch" },
- { QStyle::SC_None, "section" },
- { QStyle::SC_None, "down-arrow" },
- { QStyle::SC_None, "up-arrow" },
- { QStyle::SC_None, "chunk" },
- { QStyle::SC_None, "tab" },
- { QStyle::SC_None, "scroller" },
- { QStyle::SC_None, "tear" },
- { QStyle::SC_SliderGroove, "groove" },
- { QStyle::SC_SliderHandle, "handle" },
- { QStyle::SC_None, "add-page" },
- { QStyle::SC_None, "sub-page"},
- { QStyle::SC_SliderTickmarks, "tick-mark" },
- { QStyle::SC_None, "pane" },
- { QStyle::SC_None, "tab-bar" },
- { QStyle::SC_None, "left-corner" },
- { QStyle::SC_None, "right-corner" },
- { QStyle::SC_None, "title" },
- { QStyle::SC_None, "close-button" },
- { QStyle::SC_None, "float-button" },
- { QStyle::SC_None, "separator" },
- { QStyle::SC_MdiCloseButton, "close-button" },
- { QStyle::SC_MdiMinButton, "minimize-button" },
- { QStyle::SC_MdiNormalButton, "normal-button" },
- { QStyle::SC_TitleBarLabel, "title" },
- { QStyle::SC_TitleBarCloseButton, "close-button" },
- { QStyle::SC_TitleBarMinButton, "minimize-button" },
- { QStyle::SC_TitleBarMaxButton, "maximize-button" },
- { QStyle::SC_TitleBarShadeButton, "shade-button" },
- { QStyle::SC_TitleBarUnshadeButton, "unshade-button" },
- { QStyle::SC_TitleBarNormalButton, "normal-button" },
- { QStyle::SC_TitleBarContextHelpButton, "contexthelp-button" },
- { QStyle::SC_TitleBarSysMenu, "sys-menu" },
- { QStyle::SC_None, "item" },
- { QStyle::SC_None, "icon" },
- { QStyle::SC_None, "text" },
- { QStyle::SC_None, "indicator" },
- { QStyle::SC_None, "corner" },
- { QStyle::SC_None, "close-button" },
-};
-
-
-struct QStyleSheetBorderImageData : public QSharedData
-{
- QStyleSheetBorderImageData()
- : horizStretch(QCss::TileMode_Unknown), vertStretch(QCss::TileMode_Unknown)
- {
- for (int i = 0; i < 4; i++)
- cuts[i] = -1;
- }
- int cuts[4];
- QPixmap pixmap;
- QImage image;
- QCss::TileMode horizStretch, vertStretch;
-};
-
-struct QStyleSheetBackgroundData : public QSharedData
-{
- QStyleSheetBackgroundData(const QBrush& b, const QPixmap& p, QCss::Repeat r,
- Qt::Alignment a, QCss::Origin o, Attachment t, QCss::Origin c)
- : brush(b), pixmap(p), repeat(r), position(a), origin(o), attachment(t), clip(c) { }
-
- bool isTransparent() const {
- if (brush.style() != Qt::NoBrush)
- return !brush.isOpaque();
- return pixmap.isNull() ? false : pixmap.hasAlpha();
- }
- QBrush brush;
- QPixmap pixmap;
- QCss::Repeat repeat;
- Qt::Alignment position;
- QCss::Origin origin;
- QCss::Attachment attachment;
- QCss::Origin clip;
-};
-
-struct QStyleSheetBorderData : public QSharedData
-{
- QStyleSheetBorderData() : bi(0)
- {
- for (int i = 0; i < 4; i++) {
- borders[i] = 0;
- styles[i] = QCss::BorderStyle_None;
- }
- }
-
- QStyleSheetBorderData(int *b, QBrush *c, QCss::BorderStyle *s, QSize *r) : bi(0)
- {
- for (int i = 0; i < 4; i++) {
- borders[i] = b[i];
- styles[i] = s[i];
- colors[i] = c[i];
- radii[i] = r[i];
- }
- }
-
- int borders[4];
- QBrush colors[4];
- QCss::BorderStyle styles[4];
- QSize radii[4]; // topleft, topright, bottomleft, bottomright
-
- const QStyleSheetBorderImageData *borderImage() const
- { return bi; }
- bool hasBorderImage() const { return bi!=0; }
-
- QSharedDataPointer<QStyleSheetBorderImageData> bi;
-
- bool isOpaque() const
- {
- for (int i = 0; i < 4; i++) {
- if (styles[i] == QCss::BorderStyle_Native || styles[i] == QCss::BorderStyle_None)
- continue;
- if (styles[i] >= QCss::BorderStyle_Dotted && styles[i] <= QCss::BorderStyle_DotDotDash
- && styles[i] != BorderStyle_Solid)
- return false;
- if (!colors[i].isOpaque())
- return false;
- if (!radii[i].isEmpty())
- return false;
- }
- if (bi != 0 && bi->pixmap.hasAlpha())
- return false;
- return true;
- }
-};
-
-
-struct QStyleSheetOutlineData : public QStyleSheetBorderData
-{
- QStyleSheetOutlineData()
- {
- for (int i = 0; i < 4; i++) {
- offsets[i] = 0;
- }
- }
-
- QStyleSheetOutlineData(int *b, QBrush *c, QCss::BorderStyle *s, QSize *r, int *o)
- : QStyleSheetBorderData(b, c, s, r)
- {
- for (int i = 0; i < 4; i++) {
- offsets[i] = o[i];
- }
- }
-
- int offsets[4];
-};
-
-struct QStyleSheetBoxData : public QSharedData
-{
- QStyleSheetBoxData(int *m, int *p, int s) : spacing(s)
- {
- for (int i = 0; i < 4; i++) {
- margins[i] = m[i];
- paddings[i] = p[i];
- }
- }
-
- int margins[4];
- int paddings[4];
-
- int spacing;
-};
-
-struct QStyleSheetPaletteData : public QSharedData
-{
- QStyleSheetPaletteData(const QBrush &fg, const QBrush &sfg, const QBrush &sbg,
- const QBrush &abg)
- : foreground(fg), selectionForeground(sfg), selectionBackground(sbg),
- alternateBackground(abg) { }
-
- QBrush foreground;
- QBrush selectionForeground;
- QBrush selectionBackground;
- QBrush alternateBackground;
-};
-
-struct QStyleSheetGeometryData : public QSharedData
-{
- QStyleSheetGeometryData(int w, int h, int minw, int minh, int maxw, int maxh)
- : minWidth(minw), minHeight(minh), width(w), height(h), maxWidth(maxw), maxHeight(maxh) { }
-
- int minWidth, minHeight, width, height, maxWidth, maxHeight;
-};
-
-struct QStyleSheetPositionData : public QSharedData
-{
- QStyleSheetPositionData(int l, int t, int r, int b, Origin o, Qt::Alignment p, QCss::PositionMode m, Qt::Alignment a = 0)
- : left(l), top(t), bottom(b), right(r), origin(o), position(p), mode(m), textAlignment(a) { }
-
- int left, top, bottom, right;
- Origin origin;
- Qt::Alignment position;
- QCss::PositionMode mode;
- Qt::Alignment textAlignment;
-};
-
-struct QStyleSheetImageData : public QSharedData
-{
- QStyleSheetImageData(const QIcon &i, Qt::Alignment a, const QSize &sz)
- : icon(i), alignment(a), size(sz) { }
-
- QIcon icon;
- Qt::Alignment alignment;
- QSize size;
-};
-
-class QRenderRule
-{
-public:
- QRenderRule() : features(0), hasFont(false), pal(0), b(0), bg(0), bd(0), ou(0), geo(0), p(0), img(0), clipset(0) { }
- QRenderRule(const QVector<QCss::Declaration> &, const QWidget *);
- ~QRenderRule() { }
-
- QRect borderRect(const QRect &r) const;
- QRect outlineRect(const QRect &r) const;
- QRect paddingRect(const QRect &r) const;
- QRect contentsRect(const QRect &r) const;
-
- enum { Margin = 1, Border = 2, Padding = 4, All=Margin|Border|Padding };
- QRect boxRect(const QRect &r, int flags = All) const;
- QSize boxSize(const QSize &s, int flags = All) const;
- QRect originRect(const QRect &rect, Origin origin) const;
-
- QPainterPath borderClip(QRect rect);
- void drawBorder(QPainter *, const QRect&);
- void drawOutline(QPainter *, const QRect&);
- void drawBorderImage(QPainter *, const QRect&);
- void drawBackground(QPainter *, const QRect&, const QPoint& = QPoint(0, 0));
- void drawBackgroundImage(QPainter *, const QRect&, QPoint = QPoint(0, 0));
- void drawFrame(QPainter *, const QRect&);
- void drawImage(QPainter *p, const QRect &rect);
- void drawRule(QPainter *, const QRect&);
- void configurePalette(QPalette *, QPalette::ColorGroup, const QWidget *, bool);
- void configurePalette(QPalette *p, QPalette::ColorRole fr, QPalette::ColorRole br);
-
- const QStyleSheetPaletteData *palette() const { return pal; }
- const QStyleSheetBoxData *box() const { return b; }
- const QStyleSheetBackgroundData *background() const { return bg; }
- const QStyleSheetBorderData *border() const { return bd; }
- const QStyleSheetOutlineData *outline() const { return ou; }
- const QStyleSheetGeometryData *geometry() const { return geo; }
- const QStyleSheetPositionData *position() const { return p; }
-
- bool hasPalette() const { return pal != 0; }
- bool hasBackground() const { return bg != 0 && (!bg->pixmap.isNull() || bg->brush.style() != Qt::NoBrush); }
- bool hasGradientBackground() const { return bg && bg->brush.style() >= Qt::LinearGradientPattern
- && bg->brush.style() <= Qt::ConicalGradientPattern; }
-
- bool hasNativeBorder() const {
- return bd == 0
- || (!bd->hasBorderImage() && bd->styles[0] == BorderStyle_Native);
- }
-
- bool hasNativeOutline() const {
- return (ou == 0
- || (!ou->hasBorderImage() && ou->styles[0] == BorderStyle_Native));
- }
-
- bool baseStyleCanDraw() const {
- if (!hasBackground() || (background()->brush.style() == Qt::NoBrush && bg->pixmap.isNull()))
- return true;
- if (bg && !bg->pixmap.isNull())
- return false;
- if (hasGradientBackground())
- return features & StyleFeature_BackgroundGradient;
- return features & StyleFeature_BackgroundColor;
- }
-
- bool hasBox() const { return b != 0; }
- bool hasBorder() const { return bd != 0; }
- bool hasOutline() const { return ou != 0; }
- bool hasPosition() const { return p != 0; }
- bool hasGeometry() const { return geo != 0; }
- bool hasDrawable() const { return !hasNativeBorder() || hasBackground() || hasImage(); }
- bool hasImage() const { return img != 0; }
-
- QSize minimumContentsSize() const
- { return geo ? QSize(geo->minWidth, geo->minHeight) : QSize(0, 0); }
- QSize minimumSize() const
- { return boxSize(minimumContentsSize()); }
-
- QSize contentsSize() const
- { return geo ? QSize(geo->width, geo->height)
- : ((img && img->size.isValid()) ? img->size : QSize()); }
- QSize contentsSize(const QSize &sz) const
- {
- QSize csz = contentsSize();
- if (csz.width() == -1) csz.setWidth(sz.width());
- if (csz.height() == -1) csz.setHeight(sz.height());
- return csz;
- }
- bool hasContentsSize() const
- { return (geo && (geo->width != -1 || geo->height != -1)) || (img && img->size.isValid()); }
-
- QSize size() const { return boxSize(contentsSize()); }
- QSize size(const QSize &sz) const { return boxSize(contentsSize(sz)); }
- QSize adjustSize(const QSize &sz)
- {
- if (!geo)
- return sz;
- QSize csz = contentsSize();
- if (csz.width() == -1) csz.setWidth(sz.width());
- if (csz.height() == -1) csz.setHeight(sz.height());
- if (geo->maxWidth != -1 && csz.width() > geo->maxWidth) csz.setWidth(geo->maxWidth);
- if (geo->maxHeight != -1 && csz.height() > geo->maxHeight) csz.setHeight(geo->maxHeight);
- csz=csz.expandedTo(QSize(geo->minWidth, geo->minHeight));
- return csz;
- }
-
- int features;
- QBrush defaultBackground;
- QFont font;
- bool hasFont;
-
- QHash<QString, QVariant> styleHints;
- bool hasStyleHint(const QString& sh) const { return styleHints.contains(sh); }
- QVariant styleHint(const QString& sh) const { return styleHints.value(sh); }
-
- void fixupBorder(int);
-
- QSharedDataPointer<QStyleSheetPaletteData> pal;
- QSharedDataPointer<QStyleSheetBoxData> b;
- QSharedDataPointer<QStyleSheetBackgroundData> bg;
- QSharedDataPointer<QStyleSheetBorderData> bd;
- QSharedDataPointer<QStyleSheetOutlineData> ou;
- QSharedDataPointer<QStyleSheetGeometryData> geo;
- QSharedDataPointer<QStyleSheetPositionData> p;
- QSharedDataPointer<QStyleSheetImageData> img;
-
- // Shouldn't be here
- void setClip(QPainter *p, const QRect &rect);
- void unsetClip(QPainter *);
- int clipset;
- QPainterPath clipPath;
-};
-
-///////////////////////////////////////////////////////////////////////////////////////////
-static const char *knownStyleHints[] = {
- "activate-on-singleclick",
- "alignment",
- "arrow-keys-navigate-into-children",
- "backward-icon",
- "button-layout",
- "cd-icon",
- "combobox-list-mousetracking",
- "combobox-popup",
- "computer-icon",
- "desktop-icon",
- "dialog-apply-icon",
- "dialog-cancel-icon",
- "dialog-close-icon",
- "dialog-discard-icon",
- "dialog-help-icon",
- "dialog-no-icon",
- "dialog-ok-icon",
- "dialog-open-icon",
- "dialog-reset-icon",
- "dialog-save-icon",
- "dialog-yes-icon",
- "dialogbuttonbox-buttons-have-icons",
- "directory-closed-icon",
- "directory-icon",
- "directory-link-icon",
- "directory-open-icon",
- "dither-disable-text",
- "dockwidget-close-icon",
- "downarrow-icon",
- "dvd-icon",
- "etch-disabled-text",
- "file-icon",
- "file-link-icon",
- "filedialog-backward-icon", // unused
- "filedialog-contentsview-icon",
- "filedialog-detailedview-icon",
- "filedialog-end-icon",
- "filedialog-infoview-icon",
- "filedialog-listview-icon",
- "filedialog-new-directory-icon",
- "filedialog-parent-directory-icon",
- "filedialog-start-icon",
- "floppy-icon",
- "forward-icon",
- "gridline-color",
- "harddisk-icon",
- "home-icon",
- "icon-size",
- "leftarrow-icon",
- "lineedit-password-character",
- "mdi-fill-space-on-maximize",
- "menu-scrollable",
- "menubar-altkey-navigation",
- "menubar-separator",
- "messagebox-critical-icon",
- "messagebox-information-icon",
- "messagebox-question-icon",
- "messagebox-text-interaction-flags",
- "messagebox-warning-icon",
- "mouse-tracking",
- "network-icon",
- "opacity",
- "paint-alternating-row-colors-for-empty-area",
- "rightarrow-icon",
- "scrollbar-contextmenu",
- "scrollbar-leftclick-absolute-position",
- "scrollbar-middleclick-absolute-position",
- "scrollbar-roll-between-buttons",
- "scrollbar-scroll-when-pointer-leaves-control",
- "scrollview-frame-around-contents",
- "show-decoration-selected",
- "spinbox-click-autorepeat-rate",
- "spincontrol-disable-on-bounds",
- "tabbar-elide-mode",
- "tabbar-prefer-no-arrows",
- "titlebar-close-icon",
- "titlebar-contexthelp-icon",
- "titlebar-maximize-icon",
- "titlebar-menu-icon",
- "titlebar-minimize-icon",
- "titlebar-normal-icon",
- "titlebar-shade-icon",
- "titlebar-unshade-icon",
- "toolbutton-popup-delay",
- "trash-icon",
- "uparrow-icon"
-};
-
-static const int numKnownStyleHints = sizeof(knownStyleHints)/sizeof(knownStyleHints[0]);
-
-static QList<QVariant> subControlLayout(const QString& layout)
-{
- QList<QVariant> buttons;
- for (int i = 0; i < layout.count(); i++) {
- int button = layout[i].toAscii();
- switch (button) {
- case 'm':
- buttons.append(PseudoElement_MdiMinButton);
- buttons.append(PseudoElement_TitleBarMinButton);
- break;
- case 'M':
- buttons.append(PseudoElement_TitleBarMaxButton);
- break;
- case 'X':
- buttons.append(PseudoElement_MdiCloseButton);
- buttons.append(PseudoElement_TitleBarCloseButton);
- break;
- case 'N':
- buttons.append(PseudoElement_MdiNormalButton);
- buttons.append(PseudoElement_TitleBarNormalButton);
- break;
- case 'I':
- buttons.append(PseudoElement_TitleBarSysMenu);
- break;
- case 'T':
- buttons.append(PseudoElement_TitleBar);
- break;
- case 'H':
- buttons.append(PseudoElement_TitleBarContextHelpButton);
- break;
- case 'S':
- buttons.append(PseudoElement_TitleBarShadeButton);
- break;
- default:
- buttons.append(button);
- break;
- }
- }
- return buttons;
-}
-
-namespace {
- struct ButtonInfo {
- QRenderRule rule;
- int element;
- int offset;
- int where;
- int width;
- };
-}
-
-QHash<QStyle::SubControl, QRect> QStyleSheetStyle::titleBarLayout(const QWidget *w, const QStyleOptionTitleBar *tb) const
-{
- QHash<QStyle::SubControl, QRect> layoutRects;
- const bool isMinimized = tb->titleBarState & Qt::WindowMinimized;
- const bool isMaximized = tb->titleBarState & Qt::WindowMaximized;
- QRenderRule subRule = renderRule(w, tb);
- QRect cr = subRule.contentsRect(tb->rect);
- QList<QVariant> layout = subRule.styleHint(QLatin1String("button-layout")).toList();
- if (layout.isEmpty())
- layout = subControlLayout(QLatin1String("I(T)HSmMX"));
-
- int offsets[3] = { 0, 0, 0 };
- enum Where { Left, Right, Center, NoWhere } where = Left;
- QList<ButtonInfo> infos;
- for (int i = 0; i < layout.count(); i++) {
- ButtonInfo info;
- info.element = layout[i].toInt();
- if (info.element == '(') {
- where = Center;
- } else if (info.element == ')') {
- where = Right;
- } else {
- switch (info.element) {
- case PseudoElement_TitleBar:
- if (!(tb->titleBarFlags & (Qt::WindowTitleHint | Qt::WindowSystemMenuHint)))
- continue;
- break;
- case PseudoElement_TitleBarContextHelpButton:
- if (!(tb->titleBarFlags & Qt::WindowContextHelpButtonHint))
- continue;
- break;
- case PseudoElement_TitleBarMinButton:
- if (!(tb->titleBarFlags & Qt::WindowMinimizeButtonHint))
- continue;
- if (isMinimized)
- info.element = PseudoElement_TitleBarNormalButton;
- break;
- case PseudoElement_TitleBarMaxButton:
- if (!(tb->titleBarFlags & Qt::WindowMaximizeButtonHint))
- continue;
- if (isMaximized)
- info.element = PseudoElement_TitleBarNormalButton;
- break;
- case PseudoElement_TitleBarShadeButton:
- if (!(tb->titleBarFlags & Qt::WindowShadeButtonHint))
- continue;
- if (isMinimized)
- info.element = PseudoElement_TitleBarUnshadeButton;
- break;
- case PseudoElement_TitleBarCloseButton:
- case PseudoElement_TitleBarSysMenu:
- if (!(tb->titleBarFlags & Qt::WindowSystemMenuHint))
- continue;
- break;
- default:
- continue;
- }
- if (info.element == PseudoElement_TitleBar) {
- info.width = tb->fontMetrics.width(tb->text) + 6;
- subRule.geo = new QStyleSheetGeometryData(info.width, tb->fontMetrics.height(), -1, -1, -1, -1);
- } else {
- subRule = renderRule(w, tb, info.element);
- info.width = subRule.size().width();
- }
- info.rule = subRule;
- info.offset = offsets[where];
- info.where = where;
- infos.append(info);
-
- offsets[where] += info.width;
- }
- }
-
- for (int i = 0; i < infos.count(); i++) {
- ButtonInfo info = infos[i];
- QRect lr = cr;
- switch (info.where) {
- case Center: {
- lr.setLeft(cr.left() + offsets[Left]);
- lr.setRight(cr.right() - offsets[Right]);
- QRect r(0, 0, offsets[Center], lr.height());
- r.moveCenter(lr.center());
- r.setLeft(r.left()+info.offset);
- r.setWidth(info.width);
- lr = r;
- break; }
- case Left:
- lr.translate(info.offset, 0);
- lr.setWidth(info.width);
- break;
- case Right:
- lr.moveLeft(cr.right() + 1 - offsets[Right] + info.offset);
- lr.setWidth(info.width);
- break;
- default:
- break;
- }
- QStyle::SubControl control = knownPseudoElements[info.element].subControl;
- layoutRects[control] = positionRect(w, info.rule, info.element, lr, tb->direction);
- }
-
- return layoutRects;
-}
-
-static QStyle::StandardPixmap subControlIcon(int pe)
-{
- switch (pe) {
- case PseudoElement_MdiCloseButton: return QStyle::SP_TitleBarCloseButton;
- case PseudoElement_MdiMinButton: return QStyle::SP_TitleBarMinButton;
- case PseudoElement_MdiNormalButton: return QStyle::SP_TitleBarNormalButton;
- case PseudoElement_TitleBarCloseButton: return QStyle::SP_TitleBarCloseButton;
- case PseudoElement_TitleBarMinButton: return QStyle::SP_TitleBarMinButton;
- case PseudoElement_TitleBarMaxButton: return QStyle::SP_TitleBarMaxButton;
- case PseudoElement_TitleBarShadeButton: return QStyle::SP_TitleBarShadeButton;
- case PseudoElement_TitleBarUnshadeButton: return QStyle::SP_TitleBarUnshadeButton;
- case PseudoElement_TitleBarNormalButton: return QStyle::SP_TitleBarNormalButton;
- case PseudoElement_TitleBarContextHelpButton: return QStyle::SP_TitleBarContextHelpButton;
- default: break;
- }
- return QStyle::SP_CustomBase;
-}
-
-QRenderRule::QRenderRule(const QVector<Declaration> &declarations, const QWidget *widget)
-: features(0), hasFont(false), pal(0), b(0), bg(0), bd(0), ou(0), geo(0), p(0), img(0), clipset(0)
-{
- QPalette palette = QApplication::palette(); // ###: ideally widget's palette
- ValueExtractor v(declarations, palette);
- features = v.extractStyleFeatures();
-
- int w = -1, h = -1, minw = -1, minh = -1, maxw = -1, maxh = -1;
- if (v.extractGeometry(&w, &h, &minw, &minh, &maxw, &maxh))
- geo = new QStyleSheetGeometryData(w, h, minw, minh, maxw, maxh);
-
- int left = 0, top = 0, right = 0, bottom = 0;
- Origin origin = Origin_Unknown;
- Qt::Alignment position = 0;
- QCss::PositionMode mode = PositionMode_Unknown;
- Qt::Alignment textAlignment = 0;
- if (v.extractPosition(&left, &top, &right, &bottom, &origin, &position, &mode, &textAlignment))
- p = new QStyleSheetPositionData(left, top, right, bottom, origin, position, mode, textAlignment);
-
- int margins[4], paddings[4], spacing = -1;
- for (int i = 0; i < 4; i++)
- margins[i] = paddings[i] = 0;
- if (v.extractBox(margins, paddings, &spacing))
- b = new QStyleSheetBoxData(margins, paddings, spacing);
-
- int borders[4];
- QBrush colors[4];
- QCss::BorderStyle styles[4];
- QSize radii[4];
- for (int i = 0; i < 4; i++) {
- borders[i] = 0;
- styles[i] = BorderStyle_None;
- }
- if (v.extractBorder(borders, colors, styles, radii))
- bd = new QStyleSheetBorderData(borders, colors, styles, radii);
-
- int offsets[4];
- for (int i = 0; i < 4; i++) {
- borders[i] = offsets[i] = 0;
- styles[i] = BorderStyle_None;
- }
- if (v.extractOutline(borders, colors, styles, radii, offsets))
- ou = new QStyleSheetOutlineData(borders, colors, styles, radii, offsets);
-
- QBrush brush;
- QString uri;
- Repeat repeat = Repeat_XY;
- Qt::Alignment alignment = Qt::AlignTop | Qt::AlignLeft;
- Attachment attachment = Attachment_Scroll;
- origin = Origin_Padding;
- Origin clip = Origin_Border;
- if (v.extractBackground(&brush, &uri, &repeat, &alignment, &origin, &attachment, &clip))
- bg = new QStyleSheetBackgroundData(brush, QPixmap(uri), repeat, alignment, origin, attachment, clip);
-
- QBrush sfg, fg;
- QBrush sbg, abg;
- if (v.extractPalette(&fg, &sfg, &sbg, &abg))
- pal = new QStyleSheetPaletteData(fg, sfg, sbg, abg);
-
- QIcon icon;
- alignment = Qt::AlignCenter;
- QSize size;
- if (v.extractImage(&icon, &alignment, &size))
- img = new QStyleSheetImageData(icon, alignment, size);
-
- int adj = -255;
- hasFont = v.extractFont(&font, &adj);
-
-#ifndef QT_NO_TOOLTIP
- if (widget && qstrcmp(widget->metaObject()->className(), "QTipLabel") == 0)
- palette = QToolTip::palette();
-#endif
-
- for (int i = 0; i < declarations.count(); i++) {
- const Declaration& decl = declarations.at(i);
- if (decl.d->propertyId == BorderImage) {
- QString uri;
- QCss::TileMode horizStretch, vertStretch;
- int cuts[4];
-
- decl.borderImageValue(&uri, cuts, &horizStretch, &vertStretch);
- if (uri.isEmpty() || uri == QLatin1String("none")) {
- if (bd && bd->bi)
- bd->bi->pixmap = QPixmap();
- } else {
- if (!bd)
- bd = new QStyleSheetBorderData;
- if (!bd->bi)
- bd->bi = new QStyleSheetBorderImageData;
-
- QStyleSheetBorderImageData *bi = bd->bi;
- bi->pixmap = QPixmap(uri);
- for (int i = 0; i < 4; i++)
- bi->cuts[i] = cuts[i];
- bi->horizStretch = horizStretch;
- bi->vertStretch = vertStretch;
- }
- } else if (decl.d->propertyId == QtBackgroundRole) {
- if (bg && bg->brush.style() != Qt::NoBrush)
- continue;
- int role = decl.d->values.at(0).variant.toInt();
- if (role >= Value_FirstColorRole && role <= Value_LastColorRole)
- defaultBackground = palette.color((QPalette::ColorRole)(role-Value_FirstColorRole));
- } else if (decl.d->property.startsWith(QLatin1String("qproperty-"), Qt::CaseInsensitive)) {
- // intentionally left blank...
- } else if (decl.d->propertyId == UnknownProperty) {
- bool knownStyleHint = false;
- for (int i = 0; i < numKnownStyleHints; i++) {
- QLatin1String styleHint(knownStyleHints[i]);
- if (decl.d->property.compare(styleHint) == 0) {
- QString hintName = QString(styleHint);
- QVariant hintValue;
- if (hintName.endsWith(QLatin1String("alignment"))) {
- hintValue = (int) decl.alignmentValue();
- } else if (hintName.endsWith(QLatin1String("color"))) {
- hintValue = (int) decl.colorValue().rgba();
- } else if (hintName.endsWith(QLatin1String("size"))) {
- hintValue = decl.sizeValue();
- } else if (hintName.endsWith(QLatin1String("icon"))) {
- hintValue = decl.iconValue();
- } else if (hintName == QLatin1String("button-layout")
- && decl.d->values.count() != 0 && decl.d->values.at(0).type == Value::String) {
- hintValue = subControlLayout(decl.d->values.at(0).variant.toString());
- } else {
- int integer;
- decl.intValue(&integer);
- hintValue = integer;
- }
- styleHints[decl.d->property] = hintValue;
- knownStyleHint = true;
- break;
- }
- }
- if (!knownStyleHint)
- qDebug("Unknown property %s", qPrintable(decl.d->property));
- }
- }
-
- if (widget) {
- QStyleSheetStyle *style = const_cast<QStyleSheetStyle *>(globalStyleSheetStyle);
- if (!style)
- style = qobject_cast<QStyleSheetStyle *>(widget->style());
- if (style)
- fixupBorder(style->nativeFrameWidth(widget));
-
- }
- if (hasBorder() && border()->hasBorderImage())
- defaultBackground = QBrush();
-}
-
-QRect QRenderRule::borderRect(const QRect& r) const
-{
- if (!hasBox())
- return r;
- const int* m = box()->margins;
- return r.adjusted(m[LeftEdge], m[TopEdge], -m[RightEdge], -m[BottomEdge]);
-}
-
-QRect QRenderRule::outlineRect(const QRect& r) const
-{
- QRect br = borderRect(r);
- if (!hasOutline())
- return br;
- const int *b = outline()->borders;
- return r.adjusted(b[LeftEdge], b[TopEdge], -b[RightEdge], -b[BottomEdge]);
-}
-
-QRect QRenderRule::paddingRect(const QRect& r) const
-{
- QRect br = borderRect(r);
- if (!hasBorder())
- return br;
- const int *b = border()->borders;
- return br.adjusted(b[LeftEdge], b[TopEdge], -b[RightEdge], -b[BottomEdge]);
-}
-
-QRect QRenderRule::contentsRect(const QRect& r) const
-{
- QRect pr = paddingRect(r);
- if (!hasBox())
- return pr;
- const int *p = box()->paddings;
- return pr.adjusted(p[LeftEdge], p[TopEdge], -p[RightEdge], -p[BottomEdge]);
-}
-
-QRect QRenderRule::boxRect(const QRect& cr, int flags) const
-{
- QRect r = cr;
- if (hasBox()) {
- if (flags & Margin) {
- const int *m = box()->margins;
- r.adjust(-m[LeftEdge], -m[TopEdge], m[RightEdge], m[BottomEdge]);
- }
- if (flags & Padding) {
- const int *p = box()->paddings;
- r.adjust(-p[LeftEdge], -p[TopEdge], p[RightEdge], p[BottomEdge]);
- }
- }
- if (hasBorder() && (flags & Border)) {
- const int *b = border()->borders;
- r.adjust(-b[LeftEdge], -b[TopEdge], b[RightEdge], b[BottomEdge]);
- }
- return r;
-}
-
-QSize QRenderRule::boxSize(const QSize &cs, int flags) const
-{
- QSize bs = boxRect(QRect(QPoint(0, 0), cs), flags).size();
- if (cs.width() < 0) bs.setWidth(-1);
- if (cs.height() < 0) bs.setHeight(-1);
- return bs;
-}
-
-void QRenderRule::fixupBorder(int nativeWidth)
-{
- if (bd == 0)
- return;
-
- if (!bd->hasBorderImage() || bd->bi->pixmap.isNull()) {
- bd->bi = 0;
- // ignore the color, border of edges that have none border-style
- QBrush color = pal ? pal->foreground : QBrush();
- const bool hasRadius = bd->radii[0].isValid() || bd->radii[1].isValid()
- || bd->radii[2].isValid() || bd->radii[3].isValid();
- for (int i = 0; i < 4; i++) {
- if ((bd->styles[i] == BorderStyle_Native) && hasRadius)
- bd->styles[i] = BorderStyle_None;
-
- switch (bd->styles[i]) {
- case BorderStyle_None:
- // border-style: none forces width to be 0
- bd->colors[i] = QBrush();
- bd->borders[i] = 0;
- break;
- case BorderStyle_Native:
- if (bd->borders[i] == 0)
- bd->borders[i] = nativeWidth;
- // intentional fall through
- default:
- if (!bd->colors[i].style() != Qt::NoBrush) // auto-acquire 'color'
- bd->colors[i] = color;
- break;
- }
- }
-
- return;
- }
-
- // inspect the border image
- QStyleSheetBorderImageData *bi = bd->bi;
- if (bi->cuts[0] == -1) {
- for (int i = 0; i < 4; i++) // assume, cut = border
- bi->cuts[i] = int(border()->borders[i]);
- }
-}
-
-void QRenderRule::drawBorderImage(QPainter *p, const QRect& rect)
-{
- setClip(p, rect);
- static const Qt::TileRule tileMode2TileRule[] = {
- Qt::StretchTile, Qt::RoundTile, Qt::StretchTile, Qt::RepeatTile, Qt::StretchTile };
-
- const QStyleSheetBorderImageData *borderImageData = border()->borderImage();
- const int *targetBorders = border()->borders;
- const int *sourceBorders = borderImageData->cuts;
- QMargins sourceMargins(sourceBorders[LeftEdge], sourceBorders[TopEdge],
- sourceBorders[RightEdge], sourceBorders[BottomEdge]);
- QMargins targetMargins(targetBorders[LeftEdge], targetBorders[TopEdge],
- targetBorders[RightEdge], targetBorders[BottomEdge]);
-
- bool wasSmoothPixmapTransform = p->renderHints() & QPainter::SmoothPixmapTransform;
- p->setRenderHint(QPainter::SmoothPixmapTransform);
- qDrawBorderPixmap(p, rect, targetMargins, borderImageData->pixmap,
- QRect(QPoint(), borderImageData->pixmap.size()), sourceMargins,
- QTileRules(tileMode2TileRule[borderImageData->horizStretch], tileMode2TileRule[borderImageData->vertStretch]));
- p->setRenderHint(QPainter::SmoothPixmapTransform, wasSmoothPixmapTransform);
- unsetClip(p);
-}
-
-QRect QRenderRule::originRect(const QRect &rect, Origin origin) const
-{
- switch (origin) {
- case Origin_Padding:
- return paddingRect(rect);
- case Origin_Border:
- return borderRect(rect);
- case Origin_Content:
- return contentsRect(rect);
- case Origin_Margin:
- default:
- return rect;
- }
-}
-
-void QRenderRule::drawBackgroundImage(QPainter *p, const QRect &rect, QPoint off)
-{
- if (!hasBackground())
- return;
-
- const QPixmap& bgp = background()->pixmap;
- if (bgp.isNull())
- return;
-
- setClip(p, borderRect(rect));
-
- if (background()->origin != background()->clip) {
- p->save();
- p->setClipRect(originRect(rect, background()->clip), Qt::IntersectClip);
- }
-
- if (background()->attachment == Attachment_Fixed)
- off = QPoint(0, 0);
-
- QRect r = originRect(rect, background()->origin);
- QRect aligned = QStyle::alignedRect(Qt::LeftToRight, background()->position, bgp.size(), r);
- QRect inter = aligned.translated(-off).intersected(r);
-
- switch (background()->repeat) {
- case Repeat_Y:
- p->drawTiledPixmap(inter.x(), r.y(), inter.width(), r.height(), bgp,
- inter.x() - aligned.x() + off.x(),
- bgp.height() - int(aligned.y() - r.y()) % bgp.height() + off.y());
- break;
- case Repeat_X:
- p->drawTiledPixmap(r.x(), inter.y(), r.width(), inter.height(), bgp,
- bgp.width() - int(aligned.x() - r.x())%bgp.width() + off.x(),
- inter.y() - aligned.y() + off.y());
- break;
- case Repeat_XY:
- p->drawTiledPixmap(r, bgp,
- QPoint(bgp.width() - int(aligned.x() - r.x())% bgp.width() + off.x(),
- bgp.height() - int(aligned.y() - r.y())%bgp.height() + off.y()));
- break;
- case Repeat_None:
- default:
- p->drawPixmap(inter.x(), inter.y(), bgp, inter.x() - aligned.x() + off.x(),
- inter.y() - aligned.y() + off.y(), inter.width(), inter.height());
- break;
- }
-
-
- if (background()->origin != background()->clip)
- p->restore();
-
- unsetClip(p);
-}
-
-void QRenderRule::drawOutline(QPainter *p, const QRect &rect)
-{
- if (!hasOutline())
- return;
-
- bool wasAntialiased = p->renderHints() & QPainter::Antialiasing;
- p->setRenderHint(QPainter::Antialiasing);
- qDrawBorder(p, rect, ou->styles, ou->borders, ou->colors, ou->radii);
- p->setRenderHint(QPainter::Antialiasing, wasAntialiased);
-}
-
-void QRenderRule::drawBorder(QPainter *p, const QRect& rect)
-{
- if (!hasBorder())
- return;
-
- if (border()->hasBorderImage()) {
- drawBorderImage(p, rect);
- return;
- }
-
- bool wasAntialiased = p->renderHints() & QPainter::Antialiasing;
- p->setRenderHint(QPainter::Antialiasing);
- qDrawBorder(p, rect, bd->styles, bd->borders, bd->colors, bd->radii);
- p->setRenderHint(QPainter::Antialiasing, wasAntialiased);
-}
-
-QPainterPath QRenderRule::borderClip(QRect r)
-{
- if (!hasBorder())
- return QPainterPath();
-
- QSize tlr, trr, blr, brr;
- qNormalizeRadii(r, bd->radii, &tlr, &trr, &blr, &brr);
- if (tlr.isNull() && trr.isNull() && blr.isNull() && brr.isNull())
- return QPainterPath();
-
- const QRectF rect(r);
- const int *borders = border()->borders;
- QPainterPath path;
- qreal curY = rect.y() + borders[TopEdge]/2.0;
- path.moveTo(rect.x() + tlr.width(), curY);
- path.lineTo(rect.right() - trr.width(), curY);
- qreal curX = rect.right() - borders[RightEdge]/2.0;
- path.arcTo(curX - 2*trr.width() + borders[RightEdge], curY,
- trr.width()*2 - borders[RightEdge], trr.height()*2 - borders[TopEdge], 90, -90);
-
- path.lineTo(curX, rect.bottom() - brr.height());
- curY = rect.bottom() - borders[BottomEdge]/2.0;
- path.arcTo(curX - 2*brr.width() + borders[RightEdge], curY - 2*brr.height() + borders[BottomEdge],
- brr.width()*2 - borders[RightEdge], brr.height()*2 - borders[BottomEdge], 0, -90);
-
- path.lineTo(rect.x() + blr.width(), curY);
- curX = rect.left() + borders[LeftEdge]/2.0;
- path.arcTo(curX, rect.bottom() - 2*blr.height() + borders[BottomEdge]/2,
- blr.width()*2 - borders[LeftEdge], blr.height()*2 - borders[BottomEdge], 270, -90);
-
- path.lineTo(curX, rect.top() + tlr.height());
- path.arcTo(curX, rect.top() + borders[TopEdge]/2,
- tlr.width()*2 - borders[LeftEdge], tlr.height()*2 - borders[TopEdge], 180, -90);
-
- path.closeSubpath();
- return path;
-}
-
-/*! \internal
- Clip the painter to the border (in case we are using radius border)
- */
-void QRenderRule::setClip(QPainter *p, const QRect &rect)
-{
- if (clipset++)
- return;
- clipPath = borderClip(rect);
- if (!clipPath.isEmpty()) {
- p->save();
- p->setClipPath(clipPath, Qt::IntersectClip);
- }
-}
-
-void QRenderRule::unsetClip(QPainter *p)
-{
- if (--clipset)
- return;
- if (!clipPath.isEmpty())
- p->restore();
-}
-
-void QRenderRule::drawBackground(QPainter *p, const QRect& rect, const QPoint& off)
-{
- QBrush brush = hasBackground() ? background()->brush : QBrush();
- if (brush.style() == Qt::NoBrush)
- brush = defaultBackground;
-
- if (brush.style() != Qt::NoBrush) {
- Origin origin = hasBackground() ? background()->clip : Origin_Border;
- // ### fix for gradients
- const QPainterPath &borderPath = borderClip(originRect(rect, origin));
- if (!borderPath.isEmpty()) {
- // Drawn intead of being used as clipping path for better visual quality
- bool wasAntialiased = p->renderHints() & QPainter::Antialiasing;
- p->setRenderHint(QPainter::Antialiasing);
- p->fillPath(borderPath, brush);
- p->setRenderHint(QPainter::Antialiasing, wasAntialiased);
- } else {
- p->fillRect(originRect(rect, origin), brush);
- }
- }
-
- drawBackgroundImage(p, rect, off);
-}
-
-void QRenderRule::drawFrame(QPainter *p, const QRect& rect)
-{
- drawBackground(p, rect);
- if (hasBorder())
- drawBorder(p, borderRect(rect));
-}
-
-void QRenderRule::drawImage(QPainter *p, const QRect &rect)
-{
- if (!hasImage())
- return;
- img->icon.paint(p, rect, img->alignment);
-}
-
-void QRenderRule::drawRule(QPainter *p, const QRect& rect)
-{
- drawFrame(p, rect);
- drawImage(p, contentsRect(rect));
-}
-
-// *shudder* , *horror*, *whoa* <-- what you might feel when you see the functions below
-void QRenderRule::configurePalette(QPalette *p, QPalette::ColorRole fr, QPalette::ColorRole br)
-{
- if (bg && bg->brush.style() != Qt::NoBrush) {
- if (br != QPalette::NoRole)
- p->setBrush(br, bg->brush);
- p->setBrush(QPalette::Window, bg->brush);
- if (bg->brush.style() == Qt::SolidPattern) {
- p->setBrush(QPalette::Light, bg->brush.color().lighter(115));
- p->setBrush(QPalette::Midlight, bg->brush.color().lighter(107));
- p->setBrush(QPalette::Dark, bg->brush.color().darker(150));
- p->setBrush(QPalette::Shadow, bg->brush.color().darker(300));
- }
- }
-
- if (!hasPalette())
- return;
-
- if (pal->foreground.style() != Qt::NoBrush) {
- if (fr != QPalette::NoRole)
- p->setBrush(fr, pal->foreground);
- p->setBrush(QPalette::WindowText, pal->foreground);
- p->setBrush(QPalette::Text, pal->foreground);
- }
- if (pal->selectionBackground.style() != Qt::NoBrush)
- p->setBrush(QPalette::Highlight, pal->selectionBackground);
- if (pal->selectionForeground.style() != Qt::NoBrush)
- p->setBrush(QPalette::HighlightedText, pal->selectionForeground);
- if (pal->alternateBackground.style() != Qt::NoBrush)
- p->setBrush(QPalette::AlternateBase, pal->alternateBackground);
-}
-
-void QRenderRule::configurePalette(QPalette *p, QPalette::ColorGroup cg, const QWidget *w, bool embedded)
-{
- if (bg && bg->brush.style() != Qt::NoBrush) {
- p->setBrush(cg, QPalette::Base, bg->brush); // for windows, windowxp
- p->setBrush(cg, QPalette::Button, bg->brush); // for plastique
- p->setBrush(cg, w->backgroundRole(), bg->brush);
- p->setBrush(cg, QPalette::Window, bg->brush);
- }
-
- if (embedded) {
- /* For embedded widgets (ComboBox, SpinBox and ScrollArea) we want the embedded widget
- * to be transparent when we have a transparent background or border image */
- if ((hasBackground() && background()->isTransparent())
- || (hasBorder() && border()->hasBorderImage() && !border()->borderImage()->pixmap.isNull()))
- p->setBrush(cg, w->backgroundRole(), Qt::NoBrush);
- }
-
- if (!hasPalette())
- return;
-
- if (pal->foreground.style() != Qt::NoBrush) {
- p->setBrush(cg, QPalette::ButtonText, pal->foreground);
- p->setBrush(cg, w->foregroundRole(), pal->foreground);
- p->setBrush(cg, QPalette::WindowText, pal->foreground);
- p->setBrush(cg, QPalette::Text, pal->foreground);
- }
- if (pal->selectionBackground.style() != Qt::NoBrush)
- p->setBrush(cg, QPalette::Highlight, pal->selectionBackground);
- if (pal->selectionForeground.style() != Qt::NoBrush)
- p->setBrush(cg, QPalette::HighlightedText, pal->selectionForeground);
- if (pal->alternateBackground.style() != Qt::NoBrush)
- p->setBrush(cg, QPalette::AlternateBase, pal->alternateBackground);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// Style rules
-#define WIDGET(x) (static_cast<QWidget *>(x.ptr))
-
-static inline QWidget *parentWidget(const QWidget *w)
-{
- if(qobject_cast<const QLabel *>(w) && qstrcmp(w->metaObject()->className(), "QTipLabel") == 0) {
- QWidget *p = qvariant_cast<QWidget *>(w->property("_q_stylesheet_parent"));
- if (p)
- return p;
- }
- return w->parentWidget();
-}
-
-class QStyleSheetStyleSelector : public StyleSelector
-{
-public:
- QStyleSheetStyleSelector() { }
-
- QStringList nodeNames(NodePtr node) const
- {
- if (isNullNode(node))
- return QStringList();
- const QMetaObject *metaObject = WIDGET(node)->metaObject();
-#ifndef QT_NO_TOOLTIP
- if (qstrcmp(metaObject->className(), "QTipLabel") == 0)
- return QStringList(QLatin1String("QToolTip"));
-#endif
- QStringList result;
- do {
- result += QString::fromLatin1(metaObject->className()).replace(QLatin1Char(':'), QLatin1Char('-'));
- metaObject = metaObject->superClass();
- } while (metaObject != 0);
- return result;
- }
- QString attribute(NodePtr node, const QString& name) const
- {
- if (isNullNode(node))
- return QString();
-
- QHash<QString, QString> &cache = m_attributeCache[WIDGET(node)];
- QHash<QString, QString>::const_iterator cacheIt = cache.constFind(name);
- if (cacheIt != cache.constEnd())
- return cacheIt.value();
-
- QVariant value = WIDGET(node)->property(name.toLatin1());
- if (!value.isValid()) {
- if (name == QLatin1String("class")) {
- QString className = QString::fromLatin1(WIDGET(node)->metaObject()->className());
- if (className.contains(QLatin1Char(':')))
- className.replace(QLatin1Char(':'), QLatin1Char('-'));
- cache[name] = className;
- return className;
- } else if (name == QLatin1String("style")) {
- QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(WIDGET(node)->style());
- if (proxy) {
- QString styleName = QString::fromLatin1(proxy->baseStyle()->metaObject()->className());
- cache[name] = styleName;
- return styleName;
- }
- }
- }
- QString valueStr;
- if(value.type() == QVariant::StringList || value.type() == QVariant::List)
- valueStr = value.toStringList().join(QLatin1String(" "));
- else
- valueStr = value.toString();
- cache[name] = valueStr;
- return valueStr;
- }
- bool nodeNameEquals(NodePtr node, const QString& nodeName) const
- {
- if (isNullNode(node))
- return false;
- const QMetaObject *metaObject = WIDGET(node)->metaObject();
-#ifndef QT_NO_TOOLTIP
- if (qstrcmp(metaObject->className(), "QTipLabel") == 0)
- return nodeName == QLatin1String("QToolTip");
-#endif
- do {
- const ushort *uc = (const ushort *)nodeName.constData();
- const ushort *e = uc + nodeName.length();
- const uchar *c = (uchar *)metaObject->className();
- while (*c && uc != e && (*uc == *c || (*c == ':' && *uc == '-'))) {
- ++uc;
- ++c;
- }
- if (uc == e && !*c)
- return true;
- metaObject = metaObject->superClass();
- } while (metaObject != 0);
- return false;
- }
- bool hasAttributes(NodePtr) const
- { return true; }
- QStringList nodeIds(NodePtr node) const
- { return isNullNode(node) ? QStringList() : QStringList(WIDGET(node)->objectName()); }
- bool isNullNode(NodePtr node) const
- { return node.ptr == 0; }
- NodePtr parentNode(NodePtr node) const
- { NodePtr n; n.ptr = isNullNode(node) ? 0 : parentWidget(WIDGET(node)); return n; }
- NodePtr previousSiblingNode(NodePtr) const
- { NodePtr n; n.ptr = 0; return n; }
- NodePtr duplicateNode(NodePtr node) const
- { return node; }
- void freeNode(NodePtr) const
- { }
-
-private:
- mutable QHash<const QWidget *, QHash<QString, QString> > m_attributeCache;
-};
-
-QVector<QCss::StyleRule> QStyleSheetStyle::styleRules(const QWidget *w) const
-{
- QHash<const QWidget *, QVector<StyleRule> >::const_iterator cacheIt = styleSheetCaches->styleRulesCache.constFind(w);
- if (cacheIt != styleSheetCaches->styleRulesCache.constEnd())
- return cacheIt.value();
-
- if (!initWidget(w)) {
- return QVector<StyleRule>();
- }
-
- QStyleSheetStyleSelector styleSelector;
-
- StyleSheet defaultSs;
- QHash<const void *, StyleSheet>::const_iterator defaultCacheIt = styleSheetCaches->styleSheetCache.constFind(baseStyle());
- if (defaultCacheIt == styleSheetCaches->styleSheetCache.constEnd()) {
- defaultSs = getDefaultStyleSheet();
- QStyle *bs = baseStyle();
- styleSheetCaches->styleSheetCache.insert(bs, defaultSs);
- QObject::connect(bs, SIGNAL(destroyed(QObject*)), styleSheetCaches, SLOT(styleDestroyed(QObject*)), Qt::UniqueConnection);
- } else {
- defaultSs = defaultCacheIt.value();
- }
- styleSelector.styleSheets += defaultSs;
-
- if (!qApp->styleSheet().isEmpty()) {
- StyleSheet appSs;
- QHash<const void *, StyleSheet>::const_iterator appCacheIt = styleSheetCaches->styleSheetCache.constFind(qApp);
- if (appCacheIt == styleSheetCaches->styleSheetCache.constEnd()) {
- QString ss = qApp->styleSheet();
- if (ss.startsWith(QLatin1String("file:///")))
- ss.remove(0, 8);
- parser.init(ss, qApp->styleSheet() != ss);
- if (!parser.parse(&appSs))
- qWarning("Could not parse application stylesheet");
- appSs.origin = StyleSheetOrigin_Inline;
- appSs.depth = 1;
- styleSheetCaches->styleSheetCache.insert(qApp, appSs);
- } else {
- appSs = appCacheIt.value();
- }
- styleSelector.styleSheets += appSs;
- }
-
- QVector<QCss::StyleSheet> widgetSs;
- for (const QWidget *wid = w; wid; wid = parentWidget(wid)) {
- if (wid->styleSheet().isEmpty())
- continue;
- StyleSheet ss;
- QHash<const void *, StyleSheet>::const_iterator widCacheIt = styleSheetCaches->styleSheetCache.constFind(wid);
- if (widCacheIt == styleSheetCaches->styleSheetCache.constEnd()) {
- parser.init(wid->styleSheet());
- if (!parser.parse(&ss)) {
- parser.init(QLatin1String("* {") + wid->styleSheet() + QLatin1Char('}'));
- if (!parser.parse(&ss))
- qWarning("Could not parse stylesheet of widget %p", wid);
- }
- ss.origin = StyleSheetOrigin_Inline;
- styleSheetCaches->styleSheetCache.insert(wid, ss);
- } else {
- ss = widCacheIt.value();
- }
- widgetSs.append(ss);
- }
-
- for (int i = 0; i < widgetSs.count(); i++)
- widgetSs[i].depth = widgetSs.count() - i + 2;
-
- styleSelector.styleSheets += widgetSs;
-
- StyleSelector::NodePtr n;
- n.ptr = (void *)w;
- QVector<QCss::StyleRule> rules = styleSelector.styleRulesForNode(n);
- styleSheetCaches->styleRulesCache.insert(w, rules);
- return rules;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Rendering rules
-static QVector<Declaration> declarations(const QVector<StyleRule> &styleRules, const QString &part, quint64 pseudoClass = PseudoClass_Unspecified)
-{
- QVector<Declaration> decls;
- for (int i = 0; i < styleRules.count(); i++) {
- const Selector& selector = styleRules.at(i).selectors.at(0);
- // Rules with pseudo elements don't cascade. This is an intentional
- // diversion for CSS
- if (part.compare(selector.pseudoElement(), Qt::CaseInsensitive) != 0)
- continue;
- quint64 negated = 0;
- quint64 cssClass = selector.pseudoClass(&negated);
- if ((pseudoClass == PseudoClass_Any) || (cssClass == PseudoClass_Unspecified)
- || ((((cssClass & pseudoClass) == cssClass)) && ((negated & pseudoClass) == 0)))
- decls += styleRules.at(i).declarations;
- }
- return decls;
-}
-
-int QStyleSheetStyle::nativeFrameWidth(const QWidget *w)
-{
- QStyle *base = baseStyle();
-
-#ifndef QT_NO_SPINBOX
- if (qobject_cast<const QAbstractSpinBox *>(w))
- return base->pixelMetric(QStyle::PM_SpinBoxFrameWidth, 0, w);
-#endif
-
-#ifndef QT_NO_COMBOBOX
- if (qobject_cast<const QComboBox *>(w))
- return base->pixelMetric(QStyle::PM_ComboBoxFrameWidth, 0, w);
-#endif
-
-#ifndef QT_NO_MENU
- if (qobject_cast<const QMenu *>(w))
- return base->pixelMetric(QStyle::PM_MenuPanelWidth, 0, w);
-#endif
-
-#ifndef QT_NO_MENUBAR
- if (qobject_cast<const QMenuBar *>(w))
- return base->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, w);
-#endif
-#ifndef QT_NO_FRAME
- if (const QFrame *frame = qobject_cast<const QFrame *>(w)) {
- if (frame->frameShape() == QFrame::NoFrame)
- return 0;
- }
-#endif
-
- if (qstrcmp(w->metaObject()->className(), "QTipLabel") == 0)
- return base->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0, w);
-
- return base->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, w);
-}
-
-static quint64 pseudoClass(QStyle::State state)
-{
- quint64 pc = 0;
- if (state & QStyle::State_Enabled) {
- pc |= PseudoClass_Enabled;
- if (state & QStyle::State_MouseOver)
- pc |= PseudoClass_Hover;
- } else {
- pc |= PseudoClass_Disabled;
- }
- if (state & QStyle::State_Active)
- pc |= PseudoClass_Active;
- if (state & QStyle::State_Window)
- pc |= PseudoClass_Window;
- if (state & QStyle::State_Sunken)
- pc |= PseudoClass_Pressed;
- if (state & QStyle::State_HasFocus)
- pc |= PseudoClass_Focus;
- if (state & QStyle::State_On)
- pc |= (PseudoClass_On | PseudoClass_Checked);
- if (state & QStyle::State_Off)
- pc |= (PseudoClass_Off | PseudoClass_Unchecked);
- if (state & QStyle::State_NoChange)
- pc |= PseudoClass_Indeterminate;
- if (state & QStyle::State_Selected)
- pc |= PseudoClass_Selected;
- if (state & QStyle::State_Horizontal)
- pc |= PseudoClass_Horizontal;
- else
- pc |= PseudoClass_Vertical;
- if (state & (QStyle::State_Open | QStyle::State_On | QStyle::State_Sunken))
- pc |= PseudoClass_Open;
- else
- pc |= PseudoClass_Closed;
- if (state & QStyle::State_Children)
- pc |= PseudoClass_Children;
- if (state & QStyle::State_Sibling)
- pc |= PseudoClass_Sibling;
- if (state & QStyle::State_ReadOnly)
- pc |= PseudoClass_ReadOnly;
- if (state & QStyle::State_Item)
- pc |= PseudoClass_Item;
-#ifdef QT_KEYPAD_NAVIGATION
- if (state & QStyle::State_HasEditFocus)
- pc |= PseudoClass_EditFocus;
-#endif
- return pc;
-}
-
-static void qt_check_if_internal_widget(const QWidget **w, int *element)
-{
-#ifdef QT_NO_DOCKWIDGET
- Q_UNUSED(w);
- Q_UNUSED(element);
-#else
- if (*w && qstrcmp((*w)->metaObject()->className(), "QDockWidgetTitleButton") == 0) {
- if ((*w)->objectName() == QLatin1String("qt_dockwidget_closebutton")) {
- *element = PseudoElement_DockWidgetCloseButton;
- } else if ((*w)->objectName() == QLatin1String("qt_dockwidget_floatbutton")) {
- *element = PseudoElement_DockWidgetFloatButton;
- }
- *w = (*w)->parentWidget();
- }
-#endif
-}
-
-QRenderRule QStyleSheetStyle::renderRule(const QWidget *w, int element, quint64 state) const
-{
- qt_check_if_internal_widget(&w, &element);
- QHash<quint64, QRenderRule> &cache = styleSheetCaches->renderRulesCache[w][element];
- QHash<quint64, QRenderRule>::const_iterator cacheIt = cache.constFind(state);
- if (cacheIt != cache.constEnd())
- return cacheIt.value();
-
- if (!initWidget(w))
- return QRenderRule();
-
- quint64 stateMask = 0;
- const QVector<StyleRule> rules = styleRules(w);
- for (int i = 0; i < rules.count(); i++) {
- const Selector& selector = rules.at(i).selectors.at(0);
- quint64 negated = 0;
- stateMask |= selector.pseudoClass(&negated);
- stateMask |= negated;
- }
-
- cacheIt = cache.constFind(state & stateMask);
- if (cacheIt != cache.constEnd()) {
- const QRenderRule &newRule = cacheIt.value();
- cache[state] = newRule;
- return newRule;
- }
-
-
- const QString part = QLatin1String(knownPseudoElements[element].name);
- QVector<Declaration> decls = declarations(rules, part, state);
- QRenderRule newRule(decls, w);
- cache[state] = newRule;
- if ((state & stateMask) != state)
- cache[state&stateMask] = newRule;
- return newRule;
-}
-
-QRenderRule QStyleSheetStyle::renderRule(const QWidget *w, const QStyleOption *opt, int pseudoElement) const
-{
- quint64 extraClass = 0;
- QStyle::State state = opt ? opt->state : QStyle::State(QStyle::State_None);
-
- if (const QStyleOptionComplex *complex = qstyleoption_cast<const QStyleOptionComplex *>(opt)) {
- if (pseudoElement != PseudoElement_None) {
- // if not an active subcontrol, just pass enabled/disabled
- QStyle::SubControl subControl = knownPseudoElements[pseudoElement].subControl;
-
- if (!(complex->activeSubControls & subControl))
- state &= (QStyle::State_Enabled | QStyle::State_Horizontal | QStyle::State_HasFocus);
- }
-
- switch (pseudoElement) {
- case PseudoElement_ComboBoxDropDown:
- case PseudoElement_ComboBoxArrow:
- state |= (complex->state & (QStyle::State_On|QStyle::State_ReadOnly));
- break;
- case PseudoElement_SpinBoxUpButton:
- case PseudoElement_SpinBoxDownButton:
- case PseudoElement_SpinBoxUpArrow:
- case PseudoElement_SpinBoxDownArrow:
-#ifndef QT_NO_SPINBOX
- if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
- bool on = false;
- bool up = pseudoElement == PseudoElement_SpinBoxUpButton
- || pseudoElement == PseudoElement_SpinBoxUpArrow;
- if ((sb->stepEnabled & QAbstractSpinBox::StepUpEnabled) && up)
- on = true;
- else if ((sb->stepEnabled & QAbstractSpinBox::StepDownEnabled) && !up)
- on = true;
- state |= (on ? QStyle::State_On : QStyle::State_Off);
- }
-#endif // QT_NO_SPINBOX
- break;
- case PseudoElement_GroupBoxTitle:
- state |= (complex->state & (QStyle::State_MouseOver | QStyle::State_Sunken));
- break;
- case PseudoElement_ToolButtonMenu:
- case PseudoElement_ToolButtonMenuArrow:
- case PseudoElement_ToolButtonDownArrow:
- state |= complex->state & QStyle::State_MouseOver;
- if (complex->state & QStyle::State_Sunken ||
- complex->activeSubControls & QStyle::SC_ToolButtonMenu)
- state |= QStyle::State_Sunken;
- break;
- case PseudoElement_SliderGroove:
- state |= complex->state & QStyle::State_MouseOver;
- break;
- default:
- break;
- }
-
- if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
- // QStyle::State_On is set when the popup is being shown
- // Propagate EditField Pressed state
- if (pseudoElement == PseudoElement_None
- && (complex->activeSubControls & QStyle::SC_ComboBoxEditField)
- && (!(state & QStyle::State_MouseOver))) {
- state |= QStyle::State_Sunken;
- }
-
- if (!combo->frame)
- extraClass |= PseudoClass_Frameless;
- if (!combo->editable)
- extraClass |= PseudoClass_ReadOnly;
- else
- extraClass |= PseudoClass_Editable;
-#ifndef QT_NO_SPINBOX
- } else if (const QStyleOptionSpinBox *spin = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
- if (!spin->frame)
- extraClass |= PseudoClass_Frameless;
-#endif // QT_NO_SPINBOX
- } else if (const QStyleOptionGroupBox *gb = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
- if (gb->features & QStyleOptionFrameV2::Flat)
- extraClass |= PseudoClass_Flat;
- if (gb->lineWidth == 0)
- extraClass |= PseudoClass_Frameless;
- } else if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
- if (tb->titleBarState & Qt::WindowMinimized) {
- extraClass |= PseudoClass_Minimized;
- }
- else if (tb->titleBarState & Qt::WindowMaximized)
- extraClass |= PseudoClass_Maximized;
- }
- } else {
- // handle simple style options
- if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
- if (mi->menuItemType == QStyleOptionMenuItem::DefaultItem)
- extraClass |= PseudoClass_Default;
- if (mi->checkType == QStyleOptionMenuItem::Exclusive)
- extraClass |= PseudoClass_Exclusive;
- else if (mi->checkType == QStyleOptionMenuItem::NonExclusive)
- extraClass |= PseudoClass_NonExclusive;
- if (mi->checkType != QStyleOptionMenuItem::NotCheckable)
- extraClass |= (mi->checked) ? (PseudoClass_On|PseudoClass_Checked)
- : (PseudoClass_Off|PseudoClass_Unchecked);
- } else if (const QStyleOptionHeader *hdr = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
- if (hdr->position == QStyleOptionHeader::OnlyOneSection)
- extraClass |= PseudoClass_OnlyOne;
- else if (hdr->position == QStyleOptionHeader::Beginning)
- extraClass |= PseudoClass_First;
- else if (hdr->position == QStyleOptionHeader::End)
- extraClass |= PseudoClass_Last;
- else if (hdr->position == QStyleOptionHeader::Middle)
- extraClass |= PseudoClass_Middle;
-
- if (hdr->selectedPosition == QStyleOptionHeader::NextAndPreviousAreSelected)
- extraClass |= (PseudoClass_NextSelected | PseudoClass_PreviousSelected);
- else if (hdr->selectedPosition == QStyleOptionHeader::NextIsSelected)
- extraClass |= PseudoClass_NextSelected;
- else if (hdr->selectedPosition == QStyleOptionHeader::PreviousIsSelected)
- extraClass |= PseudoClass_PreviousSelected;
-#ifndef QT_NO_TABWIDGET
- } else if (const QStyleOptionTabWidgetFrame *tab = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
- switch (tab->shape) {
- case QTabBar::RoundedNorth:
- case QTabBar::TriangularNorth:
- extraClass |= PseudoClass_Top;
- break;
- case QTabBar::RoundedSouth:
- case QTabBar::TriangularSouth:
- extraClass |= PseudoClass_Bottom;
- break;
- case QTabBar::RoundedEast:
- case QTabBar::TriangularEast:
- extraClass |= PseudoClass_Left;
- break;
- case QTabBar::RoundedWest:
- case QTabBar::TriangularWest:
- extraClass |= PseudoClass_Right;
- break;
- default:
- break;
- }
-#endif
-#ifndef QT_NO_TABBAR
- } else if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
- if (tab->position == QStyleOptionTab::OnlyOneTab)
- extraClass |= PseudoClass_OnlyOne;
- else if (tab->position == QStyleOptionTab::Beginning)
- extraClass |= PseudoClass_First;
- else if (tab->position == QStyleOptionTab::End)
- extraClass |= PseudoClass_Last;
- else if (tab->position == QStyleOptionTab::Middle)
- extraClass |= PseudoClass_Middle;
-
- if (tab->selectedPosition == QStyleOptionTab::NextIsSelected)
- extraClass |= PseudoClass_NextSelected;
- else if (tab->selectedPosition == QStyleOptionTab::PreviousIsSelected)
- extraClass |= PseudoClass_PreviousSelected;
-
- switch (tab->shape) {
- case QTabBar::RoundedNorth:
- case QTabBar::TriangularNorth:
- extraClass |= PseudoClass_Top;
- break;
- case QTabBar::RoundedSouth:
- case QTabBar::TriangularSouth:
- extraClass |= PseudoClass_Bottom;
- break;
- case QTabBar::RoundedEast:
- case QTabBar::TriangularEast:
- extraClass |= PseudoClass_Left;
- break;
- case QTabBar::RoundedWest:
- case QTabBar::TriangularWest:
- extraClass |= PseudoClass_Right;
- break;
- default:
- break;
- }
-#endif // QT_NO_TABBAR
- } else if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
- if (btn->features & QStyleOptionButton::Flat)
- extraClass |= PseudoClass_Flat;
- if (btn->features & QStyleOptionButton::DefaultButton)
- extraClass |= PseudoClass_Default;
- } else if (const QStyleOptionFrame *frm = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
- if (frm->lineWidth == 0)
- extraClass |= PseudoClass_Frameless;
- if (const QStyleOptionFrameV2 *frame2 = qstyleoption_cast<const QStyleOptionFrameV2 *>(opt)) {
- if (frame2->features & QStyleOptionFrameV2::Flat)
- extraClass |= PseudoClass_Flat;
- }
- }
-#ifndef QT_NO_TOOLBAR
- else if (const QStyleOptionToolBar *tb = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
- if (tb->toolBarArea == Qt::LeftToolBarArea)
- extraClass |= PseudoClass_Left;
- else if (tb->toolBarArea == Qt::RightToolBarArea)
- extraClass |= PseudoClass_Right;
- else if (tb->toolBarArea == Qt::TopToolBarArea)
- extraClass |= PseudoClass_Top;
- else if (tb->toolBarArea == Qt::BottomToolBarArea)
- extraClass |= PseudoClass_Bottom;
-
- if (tb->positionWithinLine == QStyleOptionToolBar::Beginning)
- extraClass |= PseudoClass_First;
- else if (tb->positionWithinLine == QStyleOptionToolBar::Middle)
- extraClass |= PseudoClass_Middle;
- else if (tb->positionWithinLine == QStyleOptionToolBar::End)
- extraClass |= PseudoClass_Last;
- else if (tb->positionWithinLine == QStyleOptionToolBar::OnlyOne)
- extraClass |= PseudoClass_OnlyOne;
- }
-#endif // QT_NO_TOOLBAR
-#ifndef QT_NO_TOOLBOX
- else if (const QStyleOptionToolBoxV2 *tab = qstyleoption_cast<const QStyleOptionToolBoxV2 *>(opt)) {
- if (tab->position == QStyleOptionToolBoxV2::OnlyOneTab)
- extraClass |= PseudoClass_OnlyOne;
- else if (tab->position == QStyleOptionToolBoxV2::Beginning)
- extraClass |= PseudoClass_First;
- else if (tab->position == QStyleOptionToolBoxV2::End)
- extraClass |= PseudoClass_Last;
- else if (tab->position == QStyleOptionToolBoxV2::Middle)
- extraClass |= PseudoClass_Middle;
-
- if (tab->selectedPosition == QStyleOptionToolBoxV2::NextIsSelected)
- extraClass |= PseudoClass_NextSelected;
- else if (tab->selectedPosition == QStyleOptionToolBoxV2::PreviousIsSelected)
- extraClass |= PseudoClass_PreviousSelected;
- }
-#endif // QT_NO_TOOLBOX
-#ifndef QT_NO_DOCKWIDGET
- else if (const QStyleOptionDockWidgetV2 *dw = qstyleoption_cast<const QStyleOptionDockWidgetV2 *>(opt)) {
- if (dw->verticalTitleBar)
- extraClass |= PseudoClass_Vertical;
- else
- extraClass |= PseudoClass_Horizontal;
- if (dw->closable)
- extraClass |= PseudoClass_Closable;
- if (dw->floatable)
- extraClass |= PseudoClass_Floatable;
- if (dw->movable)
- extraClass |= PseudoClass_Movable;
- }
-#endif // QT_NO_DOCKWIDGET
-#ifndef QT_NO_ITEMVIEWS
- else if (const QStyleOptionViewItemV2 *v2 = qstyleoption_cast<const QStyleOptionViewItemV2 *>(opt)) {
- if (v2->features & QStyleOptionViewItemV2::Alternate)
- extraClass |= PseudoClass_Alternate;
- if (const QStyleOptionViewItemV4 *v4 = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
- if (v4->viewItemPosition == QStyleOptionViewItemV4::OnlyOne)
- extraClass |= PseudoClass_OnlyOne;
- else if (v4->viewItemPosition == QStyleOptionViewItemV4::Beginning)
- extraClass |= PseudoClass_First;
- else if (v4->viewItemPosition == QStyleOptionViewItemV4::End)
- extraClass |= PseudoClass_Last;
- else if (v4->viewItemPosition == QStyleOptionViewItemV4::Middle)
- extraClass |= PseudoClass_Middle;
- }
- }
-#endif
-#ifndef QT_NO_LINEEDIT
- // LineEdit sets Sunken flag to indicate Sunken frame (argh)
- if (const QLineEdit *lineEdit = qobject_cast<const QLineEdit *>(w)) {
- state &= ~QStyle::State_Sunken;
- if (lineEdit->hasFrame()) {
- extraClass &= ~PseudoClass_Frameless;
- } else {
- extraClass |= PseudoClass_Frameless;
- }
- } else
-#endif
- if (const QFrame *frm = qobject_cast<const QFrame *>(w)) {
- if (frm->lineWidth() == 0)
- extraClass |= PseudoClass_Frameless;
- }
- }
-
- return renderRule(w, pseudoElement, pseudoClass(state) | extraClass);
-}
-
-bool QStyleSheetStyle::hasStyleRule(const QWidget *w, int part) const
-{
- QHash<int, bool> &cache = styleSheetCaches->hasStyleRuleCache[w];
- QHash<int, bool>::const_iterator cacheIt = cache.constFind(part);
- if (cacheIt != cache.constEnd())
- return cacheIt.value();
-
- if (!initWidget(w))
- return false;
-
-
- const QVector<StyleRule> &rules = styleRules(w);
- if (part == PseudoElement_None) {
- bool result = w && !rules.isEmpty();
- cache[part] = result;
- return result;
- }
-
- QString pseudoElement = QLatin1String(knownPseudoElements[part].name);
- QVector<Declaration> declarations;
- for (int i = 0; i < rules.count(); i++) {
- const Selector& selector = rules.at(i).selectors.at(0);
- if (pseudoElement.compare(selector.pseudoElement(), Qt::CaseInsensitive) == 0) {
- cache[part] = true;
- return true;
- }
- }
-
- cache[part] = false;
- return false;
-}
-
-static Origin defaultOrigin(int pe)
-{
- switch (pe) {
- case PseudoElement_ScrollBarAddPage:
- case PseudoElement_ScrollBarSubPage:
- case PseudoElement_ScrollBarAddLine:
- case PseudoElement_ScrollBarSubLine:
- case PseudoElement_ScrollBarFirst:
- case PseudoElement_ScrollBarLast:
- case PseudoElement_GroupBoxTitle:
- case PseudoElement_GroupBoxIndicator: // never used
- case PseudoElement_ToolButtonMenu:
- case PseudoElement_SliderAddPage:
- case PseudoElement_SliderSubPage:
- return Origin_Border;
-
- case PseudoElement_SpinBoxUpButton:
- case PseudoElement_SpinBoxDownButton:
- case PseudoElement_PushButtonMenuIndicator:
- case PseudoElement_ComboBoxDropDown:
- case PseudoElement_ToolButtonDownArrow:
- case PseudoElement_MenuCheckMark:
- case PseudoElement_MenuIcon:
- case PseudoElement_MenuRightArrow:
- return Origin_Padding;
-
- case PseudoElement_Indicator:
- case PseudoElement_ExclusiveIndicator:
- case PseudoElement_ComboBoxArrow:
- case PseudoElement_ScrollBarSlider:
- case PseudoElement_ScrollBarUpArrow:
- case PseudoElement_ScrollBarDownArrow:
- case PseudoElement_ScrollBarLeftArrow:
- case PseudoElement_ScrollBarRightArrow:
- case PseudoElement_SpinBoxUpArrow:
- case PseudoElement_SpinBoxDownArrow:
- case PseudoElement_ToolButtonMenuArrow:
- case PseudoElement_HeaderViewUpArrow:
- case PseudoElement_HeaderViewDownArrow:
- case PseudoElement_SliderGroove:
- case PseudoElement_SliderHandle:
- return Origin_Content;
-
- default:
- return Origin_Margin;
- }
-}
-
-static Qt::Alignment defaultPosition(int pe)
-{
- switch (pe) {
- case PseudoElement_Indicator:
- case PseudoElement_ExclusiveIndicator:
- case PseudoElement_MenuCheckMark:
- case PseudoElement_MenuIcon:
- return Qt::AlignLeft | Qt::AlignVCenter;
-
- case PseudoElement_ScrollBarAddLine:
- case PseudoElement_ScrollBarLast:
- case PseudoElement_SpinBoxDownButton:
- case PseudoElement_PushButtonMenuIndicator:
- case PseudoElement_ToolButtonDownArrow:
- return Qt::AlignRight | Qt::AlignBottom;
-
- case PseudoElement_ScrollBarSubLine:
- case PseudoElement_ScrollBarFirst:
- case PseudoElement_SpinBoxUpButton:
- case PseudoElement_ComboBoxDropDown:
- case PseudoElement_ToolButtonMenu:
- case PseudoElement_DockWidgetCloseButton:
- case PseudoElement_DockWidgetFloatButton:
- return Qt::AlignRight | Qt::AlignTop;
-
- case PseudoElement_ScrollBarUpArrow:
- case PseudoElement_ScrollBarDownArrow:
- case PseudoElement_ScrollBarLeftArrow:
- case PseudoElement_ScrollBarRightArrow:
- case PseudoElement_SpinBoxUpArrow:
- case PseudoElement_SpinBoxDownArrow:
- case PseudoElement_ComboBoxArrow:
- case PseudoElement_DownArrow:
- case PseudoElement_ToolButtonMenuArrow:
- case PseudoElement_SliderGroove:
- return Qt::AlignCenter;
-
- case PseudoElement_GroupBoxTitle:
- case PseudoElement_GroupBoxIndicator: // never used
- return Qt::AlignLeft | Qt::AlignTop;
-
- case PseudoElement_HeaderViewUpArrow:
- case PseudoElement_HeaderViewDownArrow:
- case PseudoElement_MenuRightArrow:
- return Qt::AlignRight | Qt::AlignVCenter;
-
- default:
- return 0;
- }
-}
-
-QSize QStyleSheetStyle::defaultSize(const QWidget *w, QSize sz, const QRect& rect, int pe) const
-{
- QStyle *base = baseStyle();
-
- switch (pe) {
- case PseudoElement_Indicator:
- case PseudoElement_MenuCheckMark:
- if (sz.width() == -1)
- sz.setWidth(base->pixelMetric(PM_IndicatorWidth, 0, w));
- if (sz.height() == -1)
- sz.setHeight(base->pixelMetric(PM_IndicatorHeight, 0, w));
- break;
-
- case PseudoElement_ExclusiveIndicator:
- case PseudoElement_GroupBoxIndicator:
- if (sz.width() == -1)
- sz.setWidth(base->pixelMetric(PM_ExclusiveIndicatorWidth, 0, w));
- if (sz.height() == -1)
- sz.setHeight(base->pixelMetric(PM_ExclusiveIndicatorHeight, 0, w));
- break;
-
- case PseudoElement_PushButtonMenuIndicator: {
- int pm = base->pixelMetric(PM_MenuButtonIndicator, 0, w);
- if (sz.width() == -1)
- sz.setWidth(pm);
- if (sz.height() == -1)
- sz.setHeight(pm);
- }
- break;
-
- case PseudoElement_ComboBoxDropDown:
- if (sz.width() == -1)
- sz.setWidth(16);
- break;
-
- case PseudoElement_ComboBoxArrow:
- case PseudoElement_DownArrow:
- case PseudoElement_ToolButtonMenuArrow:
- case PseudoElement_ToolButtonDownArrow:
- case PseudoElement_MenuRightArrow:
- if (sz.width() == -1)
- sz.setWidth(13);
- if (sz.height() == -1)
- sz.setHeight(13);
- break;
-
- case PseudoElement_SpinBoxUpButton:
- case PseudoElement_SpinBoxDownButton:
- if (sz.width() == -1)
- sz.setWidth(16);
- if (sz.height() == -1)
- sz.setHeight(rect.height()/2);
- break;
-
- case PseudoElement_ToolButtonMenu:
- if (sz.width() == -1)
- sz.setWidth(base->pixelMetric(PM_MenuButtonIndicator, 0, w));
- break;
-
- case PseudoElement_HeaderViewUpArrow:
- case PseudoElement_HeaderViewDownArrow: {
- int pm = base->pixelMetric(PM_HeaderMargin, 0, w);
- if (sz.width() == -1)
- sz.setWidth(pm);
- if (sz.height() == 1)
- sz.setHeight(pm);
- break;
- }
-
- case PseudoElement_ScrollBarFirst:
- case PseudoElement_ScrollBarLast:
- case PseudoElement_ScrollBarAddLine:
- case PseudoElement_ScrollBarSubLine:
- case PseudoElement_ScrollBarSlider: {
- int pm = pixelMetric(QStyle::PM_ScrollBarExtent, 0, w);
- if (sz.width() == -1)
- sz.setWidth(pm);
- if (sz.height() == -1)
- sz.setHeight(pm);
- break;
- }
-
- case PseudoElement_DockWidgetCloseButton:
- case PseudoElement_DockWidgetFloatButton: {
- int iconSize = pixelMetric(PM_SmallIconSize, 0, w);
- return QSize(iconSize, iconSize);
- }
-
- default:
- break;
- }
-
- // expand to rectangle
- if (sz.height() == -1)
- sz.setHeight(rect.height());
- if (sz.width() == -1)
- sz.setWidth(rect.width());
-
- return sz;
-}
-
-static PositionMode defaultPositionMode(int pe)
-{
- switch (pe) {
- case PseudoElement_ScrollBarFirst:
- case PseudoElement_ScrollBarLast:
- case PseudoElement_ScrollBarAddLine:
- case PseudoElement_ScrollBarSubLine:
- case PseudoElement_ScrollBarAddPage:
- case PseudoElement_ScrollBarSubPage:
- case PseudoElement_ScrollBarSlider:
- case PseudoElement_SliderGroove:
- case PseudoElement_SliderHandle:
- case PseudoElement_TabWidgetPane:
- return PositionMode_Absolute;
- default:
- return PositionMode_Static;
- }
-}
-
-QRect QStyleSheetStyle::positionRect(const QWidget *w, const QRenderRule &rule2, int pe,
- const QRect &originRect, Qt::LayoutDirection dir) const
-{
- const QStyleSheetPositionData *p = rule2.position();
- PositionMode mode = (p && p->mode != PositionMode_Unknown) ? p->mode : defaultPositionMode(pe);
- Qt::Alignment position = (p && p->position != 0) ? p->position : defaultPosition(pe);
- QRect r;
-
- if (mode != PositionMode_Absolute) {
- QSize sz = defaultSize(w, rule2.size(), originRect, pe);
- sz = sz.expandedTo(rule2.minimumContentsSize());
- r = QStyle::alignedRect(dir, position, sz, originRect);
- if (p) {
- int left = p->left ? p->left : -p->right;
- int top = p->top ? p->top : -p->bottom;
- r.translate(dir == Qt::LeftToRight ? left : -left, top);
- }
- } else {
- r = p ? originRect.adjusted(dir == Qt::LeftToRight ? p->left : p->right, p->top,
- dir == Qt::LeftToRight ? -p->right : -p->left, -p->bottom)
- : originRect;
- if (rule2.hasContentsSize()) {
- QSize sz = rule2.size().expandedTo(rule2.minimumContentsSize());
- if (sz.width() == -1) sz.setWidth(r.width());
- if (sz.height() == -1) sz.setHeight(r.height());
- r = QStyle::alignedRect(dir, position, sz, r);
- }
- }
- return r;
-}
-
-QRect QStyleSheetStyle::positionRect(const QWidget *w, const QRenderRule& rule1, const QRenderRule& rule2, int pe,
- const QRect& rect, Qt::LayoutDirection dir) const
-{
- const QStyleSheetPositionData *p = rule2.position();
- Origin origin = (p && p->origin != Origin_Unknown) ? p->origin : defaultOrigin(pe);
- QRect originRect = rule1.originRect(rect, origin);
- return positionRect(w, rule2, pe, originRect, dir);
-}
-
-
-/** \internal
- For widget that have an embedded widget (such as combobox) return that embedded widget.
- otherwise return the widget itself
- */
-static QWidget *embeddedWidget(QWidget *w)
-{
-#ifndef QT_NO_COMBOBOX
- if (QComboBox *cmb = qobject_cast<QComboBox *>(w)) {
- if (cmb->isEditable())
- return cmb->lineEdit();
- else
- return cmb;
- }
-#endif
-
-#ifndef QT_NO_SPINBOX
- if (QAbstractSpinBox *sb = qobject_cast<QAbstractSpinBox *>(w))
- return sb->findChild<QLineEdit *>();
-#endif
-
-#ifndef QT_NO_SCROLLAREA
- if (QAbstractScrollArea *sa = qobject_cast<QAbstractScrollArea *>(w))
- return sa->viewport();
-#endif
-
- return w;
-}
-
-/** \internal
- in case w is an embedded widget, return the container widget
- (i.e, the widget for which the rules actualy apply)
- (exemple, if w is a lineedit embedded in a combobox, return the combobox)
-
- if w is not embedded, return w itself
-*/
-static QWidget *containerWidget(const QWidget *w)
-{
-#ifndef QT_NO_LINEEDIT
- if (qobject_cast<const QLineEdit *>(w)) {
- //if the QLineEdit is an embeddedWidget, we need the rule of the real widget
-#ifndef QT_NO_COMBOBOX
- if (qobject_cast<const QComboBox *>(w->parentWidget()))
- return w->parentWidget();
-#endif
-#ifndef QT_NO_SPINBOX
- if (qobject_cast<const QAbstractSpinBox *>(w->parentWidget()))
- return w->parentWidget();
-#endif
- }
-#endif // QT_NO_LINEEDIT
-
-#ifndef QT_NO_SCROLLAREA
- if (const QAbstractScrollArea *sa = qobject_cast<const QAbstractScrollArea *>(w->parentWidget())) {
- if (sa->viewport() == w)
- return w->parentWidget();
- }
-#endif
-
- return const_cast<QWidget *>(w);
-}
-
-/** \internal
- returns true if the widget can NOT be styled directly
- */
-static bool unstylable(const QWidget *w)
-{
- if (w->windowType() == Qt::Desktop)
- return true;
-
- if (!w->styleSheet().isEmpty())
- return false;
-
- if (containerWidget(w) != w)
- return true;
-
-#ifndef QT_NO_FRAME
- // detect QComboBoxPrivateContainer
- else if (qobject_cast<const QFrame *>(w)) {
- if (0
-#ifndef QT_NO_COMBOBOX
- || qobject_cast<const QComboBox *>(w->parentWidget())
-#endif
- )
- return true;
- }
-#endif
- return false;
-}
-
-static quint64 extendedPseudoClass(const QWidget *w)
-{
- quint64 pc = w->isWindow() ? quint64(PseudoClass_Window) : 0;
- if (const QAbstractSlider *slider = qobject_cast<const QAbstractSlider *>(w)) {
- pc |= ((slider->orientation() == Qt::Vertical) ? PseudoClass_Vertical : PseudoClass_Horizontal);
- } else
-#ifndef QT_NO_COMBOBOX
- if (const QComboBox *combo = qobject_cast<const QComboBox *>(w)) {
- if (combo->isEditable())
- pc |= (combo->isEditable() ? PseudoClass_Editable : PseudoClass_ReadOnly);
- } else
-#endif
-#ifndef QT_NO_LINEEDIT
- if (const QLineEdit *edit = qobject_cast<const QLineEdit *>(w)) {
- pc |= (edit->isReadOnly() ? PseudoClass_ReadOnly : PseudoClass_Editable);
- } else
-#endif
- { } // required for the above ifdef'ery to work
- return pc;
-}
-
-// sets up the geometry of the widget. We set a dynamic property when
-// we modify the min/max size of the widget. The min/max size is restored
-// to their original value when a new stylesheet that does not contain
-// the CSS properties is set and when the widget has this dynamic property set.
-// This way we don't trample on users who had setup a min/max size in code and
-// don't use stylesheets at all.
-void QStyleSheetStyle::setGeometry(QWidget *w)
-{
- QRenderRule rule = renderRule(w, PseudoElement_None, PseudoClass_Enabled | extendedPseudoClass(w));
- const QStyleSheetGeometryData *geo = rule.geometry();
- if (w->property("_q_stylesheet_minw").toBool()
- && ((!rule.hasGeometry() || geo->minWidth == -1))) {
- w->setMinimumWidth(0);
- w->setProperty("_q_stylesheet_minw", QVariant());
- }
- if (w->property("_q_stylesheet_minh").toBool()
- && ((!rule.hasGeometry() || geo->minHeight == -1))) {
- w->setMinimumHeight(0);
- w->setProperty("_q_stylesheet_minh", QVariant());
- }
- if (w->property("_q_stylesheet_maxw").toBool()
- && ((!rule.hasGeometry() || geo->maxWidth == -1))) {
- w->setMaximumWidth(QWIDGETSIZE_MAX);
- w->setProperty("_q_stylesheet_maxw", QVariant());
- }
- if (w->property("_q_stylesheet_maxh").toBool()
- && ((!rule.hasGeometry() || geo->maxHeight == -1))) {
- w->setMaximumHeight(QWIDGETSIZE_MAX);
- w->setProperty("_q_stylesheet_maxh", QVariant());
- }
-
-
- if (rule.hasGeometry()) {
- if (geo->minWidth != -1) {
- w->setProperty("_q_stylesheet_minw", true);
- w->setMinimumWidth(rule.boxSize(QSize(qMax(geo->width, geo->minWidth), 0)).width());
- }
- if (geo->minHeight != -1) {
- w->setProperty("_q_stylesheet_minh", true);
- w->setMinimumHeight(rule.boxSize(QSize(0, qMax(geo->height, geo->minHeight))).height());
- }
- if (geo->maxWidth != -1) {
- w->setProperty("_q_stylesheet_maxw", true);
- w->setMaximumWidth(rule.boxSize(QSize(qMin(geo->width == -1 ? QWIDGETSIZE_MAX : geo->width,
- geo->maxWidth == -1 ? QWIDGETSIZE_MAX : geo->maxWidth), 0)).width());
- }
- if (geo->maxHeight != -1) {
- w->setProperty("_q_stylesheet_maxh", true);
- w->setMaximumHeight(rule.boxSize(QSize(0, qMin(geo->height == -1 ? QWIDGETSIZE_MAX : geo->height,
- geo->maxHeight == -1 ? QWIDGETSIZE_MAX : geo->maxHeight))).height());
- }
- }
-}
-
-void QStyleSheetStyle::setProperties(QWidget *w)
-{
- QHash<QString, QVariant> propertyHash;
- QVector<Declaration> decls = declarations(styleRules(w), QString());
-
- // run through the declarations in order
- for (int i = 0; i < decls.count(); i++) {
- const Declaration &decl = decls.at(i);
- QString property = decl.d->property;
- if (!property.startsWith(QLatin1String("qproperty-"), Qt::CaseInsensitive))
- continue;
- property.remove(0, 10); // strip "qproperty-"
- const QVariant value = w->property(property.toLatin1());
- const QMetaObject *metaObject = w->metaObject();
- int index = metaObject->indexOfProperty(property.toLatin1());
- if (index == -1) {
- qWarning() << w << " does not have a property named " << property;
- continue;
- }
- QMetaProperty metaProperty = metaObject->property(index);
- if (!metaProperty.isWritable() || !metaProperty.isDesignable()) {
- qWarning() << w << " cannot design property named " << property;
- continue;
- }
- QVariant v;
- switch (value.type()) {
- case QVariant::Icon: v = decl.iconValue(); break;
- case QVariant::Image: v = QImage(decl.uriValue()); break;
- case QVariant::Pixmap: v = QPixmap(decl.uriValue()); break;
- case QVariant::Rect: v = decl.rectValue(); break;
- case QVariant::Size: v = decl.sizeValue(); break;
- case QVariant::Color: v = decl.colorValue(); break;
- case QVariant::Brush: v = decl.brushValue(); break;
-#ifndef QT_NO_SHORTCUT
- case QVariant::KeySequence: v = QKeySequence(decl.d->values.at(0).variant.toString()); break;
-#endif
- default: v = decl.d->values.at(0).variant; break;
- }
- propertyHash[property] = v;
- }
- // apply the values
- const QList<QString> properties = propertyHash.keys();
- for (int i = 0; i < properties.count(); i++) {
- const QString &property = properties.at(i);
- w->setProperty(property.toLatin1(), propertyHash[property]);
- }
-}
-
-void QStyleSheetStyle::setPalette(QWidget *w)
-{
- struct RuleRoleMap {
- int state;
- QPalette::ColorGroup group;
- } map[3] = {
- { int(PseudoClass_Active | PseudoClass_Enabled), QPalette::Active },
- { PseudoClass_Disabled, QPalette::Disabled },
- { PseudoClass_Enabled, QPalette::Inactive }
- };
-
- QPalette p = w->palette();
- QWidget *ew = embeddedWidget(w);
-
- for (int i = 0; i < 3; i++) {
- QRenderRule rule = renderRule(w, PseudoElement_None, map[i].state | extendedPseudoClass(w));
- if (i == 0) {
- if (!w->property("_q_styleSheetWidgetFont").isValid()) {
- saveWidgetFont(w, w->font());
- }
- updateStyleSheetFont(w);
- if (ew != w)
- updateStyleSheetFont(ew);
- }
-
- rule.configurePalette(&p, map[i].group, ew, ew != w);
- }
-
- styleSheetCaches->customPaletteWidgets.insert(w, w->palette());
- w->setPalette(p);
- if (ew != w)
- ew->setPalette(p);
-}
-
-void QStyleSheetStyle::unsetPalette(QWidget *w)
-{
- if (styleSheetCaches->customPaletteWidgets.contains(w)) {
- QPalette p = styleSheetCaches->customPaletteWidgets.value(w);
- w->setPalette(p);
- QWidget *ew = embeddedWidget(w);
- if (ew != w)
- ew->setPalette(p);
- styleSheetCaches->customPaletteWidgets.remove(w);
- }
- QVariant oldFont = w->property("_q_styleSheetWidgetFont");
- if (oldFont.isValid()) {
- w->setFont(qvariant_cast<QFont>(oldFont));
- }
- if (styleSheetCaches->autoFillDisabledWidgets.contains(w)) {
- embeddedWidget(w)->setAutoFillBackground(true);
- styleSheetCaches->autoFillDisabledWidgets.remove(w);
- }
-}
-
-static void updateWidgets(const QList<const QWidget *>& widgets)
-{
- if (!styleSheetCaches->styleRulesCache.isEmpty() || !styleSheetCaches->hasStyleRuleCache.isEmpty() || !styleSheetCaches->renderRulesCache.isEmpty()) {
- for (int i = 0; i < widgets.size(); ++i) {
- const QWidget *widget = widgets.at(i);
- styleSheetCaches->styleRulesCache.remove(widget);
- styleSheetCaches->hasStyleRuleCache.remove(widget);
- styleSheetCaches->renderRulesCache.remove(widget);
- }
- }
- for (int i = 0; i < widgets.size(); ++i) {
- QWidget *widget = const_cast<QWidget *>(widgets.at(i));
- if (widget == 0)
- continue;
- widget->style()->polish(widget);
- QEvent event(QEvent::StyleChange);
- QApplication::sendEvent(widget, &event);
- widget->update();
- widget->updateGeometry();
- }
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// The stylesheet style
-int QStyleSheetStyle::numinstances = 0;
-
-QStyleSheetStyle::QStyleSheetStyle(QStyle *base)
- : QWindowsStyle(*new QStyleSheetStylePrivate), base(base), refcount(1)
-{
- ++numinstances;
- if (numinstances == 1) {
- styleSheetCaches = new QStyleSheetStyleCaches;
- }
-}
-
-QStyleSheetStyle::~QStyleSheetStyle()
-{
- --numinstances;
- if (numinstances == 0) {
- delete styleSheetCaches;
- }
-}
-QStyle *QStyleSheetStyle::baseStyle() const
-{
- if (base)
- return base;
- if (QStyleSheetStyle *me = qobject_cast<QStyleSheetStyle *>(QApplication::style()))
- return me->base;
- return QApplication::style();
-}
-
-void QStyleSheetStyleCaches::widgetDestroyed(QObject *o)
-{
- styleRulesCache.remove((const QWidget *)o);
- hasStyleRuleCache.remove((const QWidget *)o);
- renderRulesCache.remove((const QWidget *)o);
- customPaletteWidgets.remove((const QWidget *)o);
- styleSheetCache.remove((const QWidget *)o);
- autoFillDisabledWidgets.remove((const QWidget *)o);
-}
-
-void QStyleSheetStyleCaches::styleDestroyed(QObject *o)
-{
- styleSheetCache.remove(o);
-}
-
-/*!
- * Make sure that the cache will be clean by connecting destroyed if needed.
- * return false if the widget is not stylable;
- */
-bool QStyleSheetStyle::initWidget(const QWidget *w) const
-{
- if (!w)
- return false;
- if(w->testAttribute(Qt::WA_StyleSheet))
- return true;
-
- if(unstylable(w))
- return false;
-
- const_cast<QWidget *>(w)->setAttribute(Qt::WA_StyleSheet, true);
- QObject::connect(w, SIGNAL(destroyed(QObject*)), styleSheetCaches, SLOT(widgetDestroyed(QObject*)), Qt::UniqueConnection);
- return true;
-}
-
-void QStyleSheetStyle::polish(QWidget *w)
-{
- baseStyle()->polish(w);
- RECURSION_GUARD(return)
-
- if (!initWidget(w))
- return;
-
- if (styleSheetCaches->styleRulesCache.contains(w)) {
- // the widget accessed its style pointer before polish (or repolish)
- // (exemple: the QAbstractSpinBox constructor ask for the stylehint)
- styleSheetCaches->styleRulesCache.remove(w);
- styleSheetCaches->hasStyleRuleCache.remove(w);
- styleSheetCaches->renderRulesCache.remove(w);
- }
- setGeometry(w);
- setProperties(w);
- unsetPalette(w);
- setPalette(w);
-
- //set the WA_Hover attribute if one of the selector depends of the hover state
- QVector<StyleRule> rules = styleRules(w);
- for (int i = 0; i < rules.count(); i++) {
- const Selector& selector = rules.at(i).selectors.at(0);
- quint64 negated = 0;
- quint64 cssClass = selector.pseudoClass(&negated);
- if ( cssClass & PseudoClass_Hover || negated & PseudoClass_Hover) {
- w->setAttribute(Qt::WA_Hover);
- embeddedWidget(w)->setAttribute(Qt::WA_Hover);
- }
- }
-
-
-#ifndef QT_NO_SCROLLAREA
- if (QAbstractScrollArea *sa = qobject_cast<QAbstractScrollArea *>(w)) {
- QRenderRule rule = renderRule(sa, PseudoElement_None, PseudoClass_Enabled);
- if ((rule.hasBorder() && rule.border()->hasBorderImage())
- || (rule.hasBackground() && !rule.background()->pixmap.isNull())) {
- QObject::connect(sa->horizontalScrollBar(), SIGNAL(valueChanged(int)),
- sa, SLOT(update()), Qt::UniqueConnection);
- QObject::connect(sa->verticalScrollBar(), SIGNAL(valueChanged(int)),
- sa, SLOT(update()), Qt::UniqueConnection);
- }
- }
-#endif
-
-#ifndef QT_NO_PROGRESSBAR
- if (QProgressBar *pb = qobject_cast<QProgressBar *>(w)) {
- QWindowsStyle::polish(pb);
- }
-#endif
-
- QRenderRule rule = renderRule(w, PseudoElement_None, PseudoClass_Any);
- if (rule.hasDrawable() || rule.hasBox()) {
- if (w->metaObject() == &QWidget::staticMetaObject
-#ifndef QT_NO_ITEMVIEWS
- || qobject_cast<QHeaderView *>(w)
-#endif
-#ifndef QT_NO_TABBAR
- || qobject_cast<QTabBar *>(w)
-#endif
-#ifndef QT_NO_FRAME
- || qobject_cast<QFrame *>(w)
-#endif
-#ifndef QT_NO_MAINWINDOW
- || qobject_cast<QMainWindow *>(w)
-#endif
-#ifndef QT_NO_MDIAREA
- || qobject_cast<QMdiSubWindow *>(w)
-#endif
-#ifndef QT_NO_MENUBAR
- || qobject_cast<QMenuBar *>(w)
-#endif
- || qobject_cast<QDialog *>(w)) {
- w->setAttribute(Qt::WA_StyledBackground, true);
- }
- QWidget *ew = embeddedWidget(w);
- if (ew->autoFillBackground()) {
- ew->setAutoFillBackground(false);
- styleSheetCaches->autoFillDisabledWidgets.insert(w);
- if (ew != w) { //eg. viewport of a scrollarea
- //(in order to draw the background anyway in case we don't.)
- ew->setAttribute(Qt::WA_StyledBackground, true);
- }
- }
- if (!rule.hasBackground() || rule.background()->isTransparent() || rule.hasBox()
- || (!rule.hasNativeBorder() && !rule.border()->isOpaque()))
- w->setAttribute(Qt::WA_OpaquePaintEvent, false);
- }
-}
-
-void QStyleSheetStyle::polish(QApplication *app)
-{
- baseStyle()->polish(app);
-}
-
-void QStyleSheetStyle::polish(QPalette &pal)
-{
- baseStyle()->polish(pal);
-}
-
-void QStyleSheetStyle::repolish(QWidget *w)
-{
- QList<const QWidget *> children = w->findChildren<const QWidget *>(QString());
- children.append(w);
- styleSheetCaches->styleSheetCache.remove(w);
- updateWidgets(children);
-}
-
-void QStyleSheetStyle::repolish(QApplication *app)
-{
- Q_UNUSED(app);
- const QList<const QWidget*> allWidgets = styleSheetCaches->styleRulesCache.keys();
- styleSheetCaches->styleSheetCache.remove(qApp);
- styleSheetCaches->styleRulesCache.clear();
- styleSheetCaches->hasStyleRuleCache.clear();
- styleSheetCaches->renderRulesCache.clear();
- updateWidgets(allWidgets);
-}
-
-void QStyleSheetStyle::unpolish(QWidget *w)
-{
- if (!w || !w->testAttribute(Qt::WA_StyleSheet)) {
- baseStyle()->unpolish(w);
- return;
- }
-
- styleSheetCaches->styleRulesCache.remove(w);
- styleSheetCaches->hasStyleRuleCache.remove(w);
- styleSheetCaches->renderRulesCache.remove(w);
- styleSheetCaches->styleSheetCache.remove(w);
- unsetPalette(w);
- w->setProperty("_q_stylesheet_minw", QVariant());
- w->setProperty("_q_stylesheet_minh", QVariant());
- w->setProperty("_q_stylesheet_maxw", QVariant());
- w->setProperty("_q_stylesheet_maxh", QVariant());
- w->setAttribute(Qt::WA_StyleSheet, false);
- QObject::disconnect(w, 0, this, 0);
-#ifndef QT_NO_SCROLLAREA
- if (QAbstractScrollArea *sa = qobject_cast<QAbstractScrollArea *>(w)) {
- QObject::disconnect(sa->horizontalScrollBar(), SIGNAL(valueChanged(int)),
- sa, SLOT(update()));
- QObject::disconnect(sa->verticalScrollBar(), SIGNAL(valueChanged(int)),
- sa, SLOT(update()));
- }
-#endif
-#ifndef QT_NO_PROGRESSBAR
- if (QProgressBar *pb = qobject_cast<QProgressBar *>(w))
- QWindowsStyle::unpolish(pb);
-#endif
- baseStyle()->unpolish(w);
-}
-
-void QStyleSheetStyle::unpolish(QApplication *app)
-{
- baseStyle()->unpolish(app);
- RECURSION_GUARD(return)
- styleSheetCaches->styleRulesCache.clear();
- styleSheetCaches->hasStyleRuleCache.clear();
- styleSheetCaches->renderRulesCache.clear();
- styleSheetCaches->styleSheetCache.remove(qApp);
-}
-
-#ifndef QT_NO_TABBAR
-inline static bool verticalTabs(QTabBar::Shape shape)
-{
- return shape == QTabBar::RoundedWest
- || shape == QTabBar::RoundedEast
- || shape == QTabBar::TriangularWest
- || shape == QTabBar::TriangularEast;
-}
-#endif // QT_NO_TABBAR
-
-void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
- const QWidget *w) const
-{
- RECURSION_GUARD(baseStyle()->drawComplexControl(cc, opt, p, w); return)
-
- QRenderRule rule = renderRule(w, opt);
-
- switch (cc) {
- case CC_ComboBox:
- if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
- QStyleOptionComboBox cmbOpt(*cmb);
- cmbOpt.rect = rule.borderRect(opt->rect);
- if (rule.hasNativeBorder()) {
- rule.drawBackgroundImage(p, cmbOpt.rect);
- rule.configurePalette(&cmbOpt.palette, QPalette::ButtonText, QPalette::Button);
- bool customDropDown = (opt->subControls & QStyle::SC_ComboBoxArrow)
- && (hasStyleRule(w, PseudoElement_ComboBoxDropDown) || hasStyleRule(w, PseudoElement_ComboBoxArrow));
- if (customDropDown)
- cmbOpt.subControls &= ~QStyle::SC_ComboBoxArrow;
- if (rule.baseStyleCanDraw()) {
- baseStyle()->drawComplexControl(cc, &cmbOpt, p, w);
- } else {
- QWindowsStyle::drawComplexControl(cc, &cmbOpt, p, w);
- }
- if (!customDropDown)
- return;
- } else {
- rule.drawRule(p, opt->rect);
- }
-
- if (opt->subControls & QStyle::SC_ComboBoxArrow) {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_ComboBoxDropDown);
- if (subRule.hasDrawable()) {
- QRect r = subControlRect(CC_ComboBox, opt, SC_ComboBoxArrow, w);
- subRule.drawRule(p, r);
- QRenderRule subRule2 = renderRule(w, opt, PseudoElement_ComboBoxArrow);
- r = positionRect(w, subRule, subRule2, PseudoElement_ComboBoxArrow, r, opt->direction);
- subRule2.drawRule(p, r);
- } else {
- cmbOpt.subControls = QStyle::SC_ComboBoxArrow;
- QWindowsStyle::drawComplexControl(cc, &cmbOpt, p, w);
- }
- }
-
- return;
- }
- break;
-
-#ifndef QT_NO_SPINBOX
- case CC_SpinBox:
- if (const QStyleOptionSpinBox *spin = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
- QStyleOptionSpinBox spinOpt(*spin);
- rule.configurePalette(&spinOpt.palette, QPalette::ButtonText, QPalette::Button);
- rule.configurePalette(&spinOpt.palette, QPalette::Text, QPalette::Base);
- spinOpt.rect = rule.borderRect(opt->rect);
- bool customUp = true, customDown = true;
- QRenderRule upRule = renderRule(w, opt, PseudoElement_SpinBoxUpButton);
- QRenderRule downRule = renderRule(w, opt, PseudoElement_SpinBoxDownButton);
- bool upRuleMatch = upRule.hasGeometry() || upRule.hasPosition();
- bool downRuleMatch = downRule.hasGeometry() || downRule.hasPosition();
- if (rule.hasNativeBorder() && !upRuleMatch && !downRuleMatch) {
- rule.drawBackgroundImage(p, spinOpt.rect);
- customUp = (opt->subControls & QStyle::SC_SpinBoxUp)
- && (hasStyleRule(w, PseudoElement_SpinBoxUpButton) || hasStyleRule(w, PseudoElement_UpArrow));
- if (customUp)
- spinOpt.subControls &= ~QStyle::SC_SpinBoxUp;
- customDown = (opt->subControls & QStyle::SC_SpinBoxDown)
- && (hasStyleRule(w, PseudoElement_SpinBoxDownButton) || hasStyleRule(w, PseudoElement_DownArrow));
- if (customDown)
- spinOpt.subControls &= ~QStyle::SC_SpinBoxDown;
- if (rule.baseStyleCanDraw()) {
- baseStyle()->drawComplexControl(cc, &spinOpt, p, w);
- } else {
- QWindowsStyle::drawComplexControl(cc, &spinOpt, p, w);
- }
- if (!customUp && !customDown)
- return;
- } else {
- rule.drawRule(p, opt->rect);
- }
-
- if ((opt->subControls & QStyle::SC_SpinBoxUp) && customUp) {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_SpinBoxUpButton);
- if (subRule.hasDrawable()) {
- QRect r = subControlRect(CC_SpinBox, opt, SC_SpinBoxUp, w);
- subRule.drawRule(p, r);
- QRenderRule subRule2 = renderRule(w, opt, PseudoElement_SpinBoxUpArrow);
- r = positionRect(w, subRule, subRule2, PseudoElement_SpinBoxUpArrow, r, opt->direction);
- subRule2.drawRule(p, r);
- } else {
- spinOpt.subControls = QStyle::SC_SpinBoxUp;
- QWindowsStyle::drawComplexControl(cc, &spinOpt, p, w);
- }
- }
-
- if ((opt->subControls & QStyle::SC_SpinBoxDown) && customDown) {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_SpinBoxDownButton);
- if (subRule.hasDrawable()) {
- QRect r = subControlRect(CC_SpinBox, opt, SC_SpinBoxDown, w);
- subRule.drawRule(p, r);
- QRenderRule subRule2 = renderRule(w, opt, PseudoElement_SpinBoxDownArrow);
- r = positionRect(w, subRule, subRule2, PseudoElement_SpinBoxDownArrow, r, opt->direction);
- subRule2.drawRule(p, r);
- } else {
- spinOpt.subControls = QStyle::SC_SpinBoxDown;
- QWindowsStyle::drawComplexControl(cc, &spinOpt, p, w);
- }
- }
- return;
- }
- break;
-#endif // QT_NO_SPINBOX
-
- case CC_GroupBox:
- if (const QStyleOptionGroupBox *gb = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
-
- QRect labelRect, checkBoxRect, titleRect, frameRect;
- bool hasTitle = (gb->subControls & QStyle::SC_GroupBoxCheckBox) || !gb->text.isEmpty();
-
- if (!rule.hasDrawable() && (!hasTitle || !hasStyleRule(w, PseudoElement_GroupBoxTitle))
- && !hasStyleRule(w, PseudoElement_Indicator) && !rule.hasBox() && !rule.hasFont && !rule.hasPalette()) {
- // let the native style draw the combobox if there is no style for it.
- break;
- }
- rule.drawBackground(p, opt->rect);
-
- QRenderRule titleRule = renderRule(w, opt, PseudoElement_GroupBoxTitle);
- bool clipSet = false;
-
- if (hasTitle) {
- labelRect = subControlRect(CC_GroupBox, opt, SC_GroupBoxLabel, w);
- //Some native style (such as mac) may return a too small rectangle (because they use smaller fonts), so we may need to expand it a little bit.
- labelRect.setSize(labelRect.size().expandedTo(ParentStyle::subControlRect(CC_GroupBox, opt, SC_GroupBoxLabel, w).size()));
- if (gb->subControls & QStyle::SC_GroupBoxCheckBox) {
- checkBoxRect = subControlRect(CC_GroupBox, opt, SC_GroupBoxCheckBox, w);
- titleRect = titleRule.boxRect(checkBoxRect.united(labelRect));
- } else {
- titleRect = titleRule.boxRect(labelRect);
- }
- if (!titleRule.hasBackground() || !titleRule.background()->isTransparent()) {
- clipSet = true;
- p->save();
- p->setClipRegion(QRegion(opt->rect) - titleRect);
- }
- }
-
- frameRect = subControlRect(CC_GroupBox, opt, SC_GroupBoxFrame, w);
- QStyleOptionFrameV2 frame;
- frame.QStyleOption::operator=(*gb);
- frame.features = gb->features;
- frame.lineWidth = gb->lineWidth;
- frame.midLineWidth = gb->midLineWidth;
- frame.rect = frameRect;
- drawPrimitive(PE_FrameGroupBox, &frame, p, w);
-
- if (clipSet)
- p->restore();
-
- // draw background and frame of the title
- if (hasTitle)
- titleRule.drawRule(p, titleRect);
-
- // draw the indicator
- if (gb->subControls & QStyle::SC_GroupBoxCheckBox) {
- QStyleOptionButton box;
- box.QStyleOption::operator=(*gb);
- box.rect = checkBoxRect;
- drawPrimitive(PE_IndicatorCheckBox, &box, p, w);
- }
-
- // draw the text
- if (!gb->text.isEmpty()) {
- int alignment = int(Qt::AlignCenter | Qt::TextShowMnemonic);
- if (!styleHint(QStyle::SH_UnderlineShortcut, opt, w)) {
- alignment |= Qt::TextHideMnemonic;
- }
-
- QPalette pal = gb->palette;
- if (gb->textColor.isValid())
- pal.setColor(QPalette::WindowText, gb->textColor);
- titleRule.configurePalette(&pal, QPalette::WindowText, QPalette::Window);
- drawItemText(p, labelRect, alignment, pal, gb->state & State_Enabled,
- gb->text, QPalette::WindowText);
-
- if (gb->state & State_HasFocus) {
- QStyleOptionFocusRect fropt;
- fropt.QStyleOption::operator=(*gb);
- fropt.rect = labelRect;
- drawPrimitive(PE_FrameFocusRect, &fropt, p, w);
- }
- }
-
- return;
- }
- break;
-
- case CC_ToolButton:
- if (const QStyleOptionToolButton *tool = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
- QStyleOptionToolButton toolOpt(*tool);
- rule.configurePalette(&toolOpt.palette, QPalette::ButtonText, QPalette::Button);
- toolOpt.font = rule.font.resolve(toolOpt.font);
- toolOpt.rect = rule.borderRect(opt->rect);
- bool customArrow = (tool->features & (QStyleOptionToolButton::HasMenu | QStyleOptionToolButton::MenuButtonPopup));
- bool customDropDown = tool->features & QStyleOptionToolButton::MenuButtonPopup;
- if (rule.hasNativeBorder()) {
- if (tool->subControls & SC_ToolButton) {
- //in some case (eg. the button is "auto raised") the style doesn't draw the background
- //so we need to draw the background.
- // use the same condition as in QCommonStyle
- State bflags = tool->state & ~State_Sunken;
- if (bflags & State_AutoRaise && (!(bflags & State_MouseOver) || !(bflags & State_Enabled)))
- bflags &= ~State_Raised;
- if (tool->state & State_Sunken && tool->activeSubControls & SC_ToolButton)
- bflags |= State_Sunken;
- if (!(bflags & (State_Sunken | State_On | State_Raised)))
- rule.drawBackground(p, toolOpt.rect);
- }
- customArrow = customArrow && hasStyleRule(w, PseudoElement_ToolButtonDownArrow);
- if (customArrow)
- toolOpt.features &= ~QStyleOptionToolButton::HasMenu;
- customDropDown = customDropDown && hasStyleRule(w, PseudoElement_ToolButtonMenu);
- if (customDropDown)
- toolOpt.subControls &= ~QStyle::SC_ToolButtonMenu;
-
- if (rule.baseStyleCanDraw() && !(tool->features & QStyleOptionToolButton::Arrow)) {
- baseStyle()->drawComplexControl(cc, &toolOpt, p, w);
- } else {
- QWindowsStyle::drawComplexControl(cc, &toolOpt, p, w);
- }
-
- if (!customArrow && !customDropDown)
- return;
- } else {
- rule.drawRule(p, opt->rect);
- toolOpt.rect = rule.contentsRect(opt->rect);
- if (rule.hasFont)
- toolOpt.font = rule.font;
- drawControl(CE_ToolButtonLabel, &toolOpt, p, w);
- }
-
- QRenderRule subRule = renderRule(w, opt, PseudoElement_ToolButtonMenu);
- QRect r = subControlRect(CC_ToolButton, opt, QStyle::SC_ToolButtonMenu, w);
- if (customDropDown) {
- if (opt->subControls & QStyle::SC_ToolButtonMenu) {
- if (subRule.hasDrawable()) {
- subRule.drawRule(p, r);
- } else {
- toolOpt.rect = r;
- baseStyle()->drawPrimitive(PE_IndicatorButtonDropDown, &toolOpt, p, w);
- }
- }
- }
-
- if (customArrow) {
- QRenderRule subRule2 = customDropDown ? renderRule(w, opt, PseudoElement_ToolButtonMenuArrow)
- : renderRule(w, opt, PseudoElement_ToolButtonDownArrow);
- QRect r2 = customDropDown
- ? positionRect(w, subRule, subRule2, PseudoElement_ToolButtonMenuArrow, r, opt->direction)
- : positionRect(w, rule, subRule2, PseudoElement_ToolButtonDownArrow, opt->rect, opt->direction);
- if (subRule2.hasDrawable()) {
- subRule2.drawRule(p, r2);
- } else {
- toolOpt.rect = r2;
- baseStyle()->drawPrimitive(QStyle::PE_IndicatorArrowDown, &toolOpt, p, w);
- }
- }
-
- return;
- }
- break;
-
-#ifndef QT_NO_SCROLLBAR
- case CC_ScrollBar:
- if (const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
- QStyleOptionSlider sbOpt(*sb);
- if (!rule.hasDrawable()) {
- sbOpt.rect = rule.borderRect(opt->rect);
- rule.drawBackgroundImage(p, opt->rect);
- baseStyle()->drawComplexControl(cc, &sbOpt, p, w);
- } else {
- rule.drawRule(p, opt->rect);
- QWindowsStyle::drawComplexControl(cc, opt, p, w);
- }
- return;
- }
- break;
-#endif // QT_NO_SCROLLBAR
-
-#ifndef QT_NO_SLIDER
- case CC_Slider:
- if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
- rule.drawRule(p, opt->rect);
-
- QRenderRule grooveSubRule = renderRule(w, opt, PseudoElement_SliderGroove);
- QRenderRule handleSubRule = renderRule(w, opt, PseudoElement_SliderHandle);
- if (!grooveSubRule.hasDrawable()) {
- QStyleOptionSlider slOpt(*slider);
- bool handleHasRule = handleSubRule.hasDrawable();
- // If the style specifies a different handler rule, draw the groove without the handler.
- if (handleHasRule)
- slOpt.subControls &= ~SC_SliderHandle;
- baseStyle()->drawComplexControl(cc, &slOpt, p, w);
- if (!handleHasRule)
- return;
- }
-
- QRect gr = subControlRect(cc, opt, SC_SliderGroove, w);
- if (slider->subControls & SC_SliderGroove) {
- grooveSubRule.drawRule(p, gr);
- }
-
- if (slider->subControls & SC_SliderHandle) {
- QRect hr = subControlRect(cc, opt, SC_SliderHandle, w);
-
- QRenderRule subRule1 = renderRule(w, opt, PseudoElement_SliderSubPage);
- if (subRule1.hasDrawable()) {
- QRect r(gr.topLeft(),
- slider->orientation == Qt::Horizontal
- ? QPoint(hr.x()+hr.width()/2, gr.y()+gr.height() - 1)
- : QPoint(gr.x()+gr.width() - 1, hr.y()+hr.height()/2));
- subRule1.drawRule(p, r);
- }
-
- QRenderRule subRule2 = renderRule(w, opt, PseudoElement_SliderAddPage);
- if (subRule2.hasDrawable()) {
- QRect r(slider->orientation == Qt::Horizontal
- ? QPoint(hr.x()+hr.width()/2+1, gr.y())
- : QPoint(gr.x(), hr.y()+hr.height()/2+1),
- gr.bottomRight());
- subRule2.drawRule(p, r);
- }
-
- handleSubRule.drawRule(p, handleSubRule.boxRect(hr, Margin));
- }
-
- if (slider->subControls & SC_SliderTickmarks) {
- // TODO...
- }
-
- return;
- }
- break;
-#endif // QT_NO_SLIDER
-
- case CC_MdiControls:
- if (hasStyleRule(w, PseudoElement_MdiCloseButton)
- || hasStyleRule(w, PseudoElement_MdiNormalButton)
- || hasStyleRule(w, PseudoElement_MdiMinButton)) {
- QList<QVariant> layout = rule.styleHint(QLatin1String("button-layout")).toList();
- if (layout.isEmpty())
- layout = subControlLayout(QLatin1String("mNX"));
-
- QStyleOptionComplex optCopy(*opt);
- optCopy.subControls = 0;
- for (int i = 0; i < layout.count(); i++) {
- int layoutButton = layout[i].toInt();
- if (layoutButton < PseudoElement_MdiCloseButton
- || layoutButton > PseudoElement_MdiNormalButton)
- continue;
- QStyle::SubControl control = knownPseudoElements[layoutButton].subControl;
- if (!(opt->subControls & control))
- continue;
- QRenderRule subRule = renderRule(w, opt, layoutButton);
- if (subRule.hasDrawable()) {
- QRect rect = subRule.boxRect(subControlRect(CC_MdiControls, opt, control, w), Margin);
- subRule.drawRule(p, rect);
- QIcon icon = standardIcon(subControlIcon(layoutButton), opt);
- icon.paint(p, subRule.contentsRect(rect), Qt::AlignCenter);
- } else {
- optCopy.subControls |= control;
- }
- }
-
- if (optCopy.subControls)
- baseStyle()->drawComplexControl(CC_MdiControls, &optCopy, p, w);
- return;
- }
- break;
-
- case CC_TitleBar:
- if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_TitleBar);
- if (!subRule.hasDrawable() && !subRule.hasBox() && !subRule.hasBorder())
- break;
- subRule.drawRule(p, opt->rect);
- QHash<QStyle::SubControl, QRect> layout = titleBarLayout(w, tb);
-
- QRect ir;
- ir = layout[SC_TitleBarLabel];
- if (ir.isValid()) {
- if (subRule.hasPalette())
- p->setPen(subRule.palette()->foreground.color());
- p->fillRect(ir, Qt::white);
- p->drawText(ir.x(), ir.y(), ir.width(), ir.height(), Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine, tb->text);
- }
-
- QPixmap pm;
-
- ir = layout[SC_TitleBarSysMenu];
- if (ir.isValid()) {
- QRenderRule subSubRule = renderRule(w, opt, PseudoElement_TitleBarSysMenu);
- subSubRule.drawRule(p, ir);
- ir = subSubRule.contentsRect(ir);
- if (!tb->icon.isNull()) {
- tb->icon.paint(p, ir);
- } else {
- int iconSize = pixelMetric(PM_SmallIconSize, tb, w);
- pm = standardIcon(SP_TitleBarMenuButton, 0, w).pixmap(iconSize, iconSize);
- drawItemPixmap(p, ir, Qt::AlignCenter, pm);
- }
- }
-
- ir = layout[SC_TitleBarCloseButton];
- if (ir.isValid()) {
- QRenderRule subSubRule = renderRule(w, opt, PseudoElement_TitleBarCloseButton);
- subSubRule.drawRule(p, ir);
-
- QSize sz = subSubRule.contentsRect(ir).size();
- if ((tb->titleBarFlags & Qt::WindowType_Mask) == Qt::Tool)
- pm = standardIcon(SP_DockWidgetCloseButton, 0, w).pixmap(sz);
- else
- pm = standardIcon(SP_TitleBarCloseButton, 0, w).pixmap(sz);
- drawItemPixmap(p, ir, Qt::AlignCenter, pm);
- }
-
- int pes[] = {
- PseudoElement_TitleBarMaxButton,
- PseudoElement_TitleBarMinButton,
- PseudoElement_TitleBarNormalButton,
- PseudoElement_TitleBarShadeButton,
- PseudoElement_TitleBarUnshadeButton,
- PseudoElement_TitleBarContextHelpButton
- };
-
- for (unsigned int i = 0; i < sizeof(pes)/sizeof(int); i++) {
- int pe = pes[i];
- QStyle::SubControl sc = knownPseudoElements[pe].subControl;
- ir = layout[sc];
- if (!ir.isValid())
- continue;
- QRenderRule subSubRule = renderRule(w, opt, pe);
- subSubRule.drawRule(p, ir);
- pm = standardIcon(subControlIcon(pe), 0, w).pixmap(subSubRule.contentsRect(ir).size());
- drawItemPixmap(p, ir, Qt::AlignCenter, pm);
- }
-
- return;
- }
- break;
-
-
- default:
- break;
- }
-
- baseStyle()->drawComplexControl(cc, opt, p, w);
-}
-
-void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter *p,
- const QWidget *w) const
-{
- RECURSION_GUARD(baseStyle()->drawControl(ce, opt, p, w); return)
-
- QRenderRule rule = renderRule(w, opt);
- int pe1 = PseudoElement_None, pe2 = PseudoElement_None;
- bool fallback = false;
-
- switch (ce) {
- case CE_ToolButtonLabel:
- if (const QStyleOptionToolButton *btn = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
- if (rule.hasBox() || btn->features & QStyleOptionToolButton::Arrow) {
- QCommonStyle::drawControl(ce, opt, p, w);
- } else {
- QStyleOptionToolButton butOpt(*btn);
- rule.configurePalette(&butOpt.palette, QPalette::ButtonText, QPalette::Button);
- baseStyle()->drawControl(ce, &butOpt, p, w);
- }
- return;
- }
- break;
-
- case CE_FocusFrame:
- if (!rule.hasNativeBorder()) {
- rule.drawBorder(p, opt->rect);
- return;
- }
- break;
-
- case CE_PushButton:
- if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
- if (rule.hasDrawable() || rule.hasBox() || rule.hasPosition() || rule.hasPalette() ||
- ((btn->features & QStyleOptionButton::HasMenu) && hasStyleRule(w, PseudoElement_PushButtonMenuIndicator))) {
- ParentStyle::drawControl(ce, opt, p, w);
- return;
- }
- }
- break;
- case CE_PushButtonBevel:
- if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
- QStyleOptionButton btnOpt(*btn);
- btnOpt.rect = rule.borderRect(opt->rect);
- if (rule.hasNativeBorder()) {
- rule.drawBackgroundImage(p, btnOpt.rect);
- rule.configurePalette(&btnOpt.palette, QPalette::ButtonText, QPalette::Button);
- bool customMenu = (btn->features & QStyleOptionButton::HasMenu
- && hasStyleRule(w, PseudoElement_PushButtonMenuIndicator));
- if (customMenu)
- btnOpt.features &= ~QStyleOptionButton::HasMenu;
- if (rule.baseStyleCanDraw()) {
- baseStyle()->drawControl(ce, &btnOpt, p, w);
- } else {
- QWindowsStyle::drawControl(ce, &btnOpt, p, w);
- }
- if (!customMenu)
- return;
- } else {
- rule.drawRule(p, opt->rect);
- }
-
- if (btn->features & QStyleOptionButton::HasMenu) {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_PushButtonMenuIndicator);
- QRect ir = positionRect(w, rule, subRule, PseudoElement_PushButtonMenuIndicator, opt->rect, opt->direction);
- if (subRule.hasDrawable()) {
- subRule.drawRule(p, ir);
- } else {
- btnOpt.rect = ir;
- baseStyle()->drawPrimitive(PE_IndicatorArrowDown, &btnOpt, p, w);
- }
- }
- }
- return;
-
- case CE_PushButtonLabel:
- if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
- QStyleOptionButton butOpt(*button);
- rule.configurePalette(&butOpt.palette, QPalette::ButtonText, QPalette::Button);
- if (rule.hasPosition() && rule.position()->textAlignment != 0) {
- Qt::Alignment textAlignment = rule.position()->textAlignment;
- QRect textRect = button->rect;
- uint tf = Qt::TextShowMnemonic;
- const uint verticalAlignMask = Qt::AlignVCenter | Qt::AlignTop | Qt::AlignLeft;
- tf |= (textAlignment & verticalAlignMask) ? (textAlignment & verticalAlignMask) : Qt::AlignVCenter;
- if (!styleHint(SH_UnderlineShortcut, button, w))
- tf |= Qt::TextHideMnemonic;
- if (!button->icon.isNull()) {
- //Group both icon and text
- QRect iconRect;
- QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal : QIcon::Disabled;
- if (mode == QIcon::Normal && button->state & State_HasFocus)
- mode = QIcon::Active;
- QIcon::State state = QIcon::Off;
- if (button->state & State_On)
- state = QIcon::On;
-
- QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state);
- int labelWidth = pixmap.width();
- int labelHeight = pixmap.height();
- int iconSpacing = 4;//### 4 is currently hardcoded in QPushButton::sizeHint()
- int textWidth = button->fontMetrics.boundingRect(opt->rect, tf, button->text).width();
- if (!button->text.isEmpty())
- labelWidth += (textWidth + iconSpacing);
-
- //Determine label alignment:
- if (textAlignment & Qt::AlignLeft) { /*left*/
- iconRect = QRect(textRect.x(), textRect.y() + (textRect.height() - labelHeight) / 2,
- pixmap.width(), pixmap.height());
- } else if (textAlignment & Qt::AlignHCenter) { /* center */
- iconRect = QRect(textRect.x() + (textRect.width() - labelWidth) / 2,
- textRect.y() + (textRect.height() - labelHeight) / 2,
- pixmap.width(), pixmap.height());
- } else { /*right*/
- iconRect = QRect(textRect.x() + textRect.width() - labelWidth,
- textRect.y() + (textRect.height() - labelHeight) / 2,
- pixmap.width(), pixmap.height());
- }
-
- iconRect = visualRect(button->direction, textRect, iconRect);
-
- tf |= Qt::AlignLeft; //left align, we adjust the text-rect instead
-
- if (button->direction == Qt::RightToLeft)
- textRect.setRight(iconRect.left() - iconSpacing);
- else
- textRect.setLeft(iconRect.left() + iconRect.width() + iconSpacing);
-
- if (button->state & (State_On | State_Sunken))
- iconRect.translate(pixelMetric(PM_ButtonShiftHorizontal, opt, w),
- pixelMetric(PM_ButtonShiftVertical, opt, w));
- p->drawPixmap(iconRect, pixmap);
- } else {
- tf |= textAlignment;
- }
- if (button->state & (State_On | State_Sunken))
- textRect.translate(pixelMetric(PM_ButtonShiftHorizontal, opt, w),
- pixelMetric(PM_ButtonShiftVertical, opt, w));
-
- if (button->features & QStyleOptionButton::HasMenu) {
- int indicatorSize = pixelMetric(PM_MenuButtonIndicator, button, w);
- if (button->direction == Qt::LeftToRight)
- textRect = textRect.adjusted(0, 0, -indicatorSize, 0);
- else
- textRect = textRect.adjusted(indicatorSize, 0, 0, 0);
- }
- drawItemText(p, textRect, tf, butOpt.palette, (button->state & State_Enabled),
- button->text, QPalette::ButtonText);
- } else {
- ParentStyle::drawControl(ce, &butOpt, p, w);
- }
- }
- return;
-
- case CE_RadioButton:
- case CE_CheckBox:
- if (rule.hasBox() || !rule.hasNativeBorder() || rule.hasDrawable() || hasStyleRule(w, PseudoElement_Indicator)) {
- rule.drawRule(p, opt->rect);
- ParentStyle::drawControl(ce, opt, p, w);
- return;
- } else if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
- QStyleOptionButton butOpt(*btn);
- rule.configurePalette(&butOpt.palette, QPalette::ButtonText, QPalette::Button);
- baseStyle()->drawControl(ce, &butOpt, p, w);
- return;
- }
- break;
- case CE_RadioButtonLabel:
- case CE_CheckBoxLabel:
- if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
- QStyleOptionButton butOpt(*btn);
- rule.configurePalette(&butOpt.palette, QPalette::ButtonText, QPalette::Button);
- ParentStyle::drawControl(ce, &butOpt, p, w);
- }
- return;
-
- case CE_Splitter:
- pe1 = PseudoElement_SplitterHandle;
- break;
-
- case CE_ToolBar:
- if (rule.hasBackground()) {
- rule.drawBackground(p, opt->rect);
- }
- if (rule.hasBorder()) {
- rule.drawBorder(p, rule.borderRect(opt->rect));
- } else {
-#ifndef QT_NO_TOOLBAR
- if (const QStyleOptionToolBar *tb = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
- QStyleOptionToolBar newTb(*tb);
- newTb.rect = rule.borderRect(opt->rect);
- baseStyle()->drawControl(ce, &newTb, p, w);
- }
-#endif // QT_NO_TOOLBAR
- }
- return;
-
- case CE_MenuEmptyArea:
- case CE_MenuBarEmptyArea:
- if (rule.hasDrawable()) {
- // Drawn by PE_Widget
- return;
- }
- break;
-
- case CE_MenuTearoff:
- case CE_MenuScroller:
- if (const QStyleOptionMenuItem *m = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
- QStyleOptionMenuItem mi(*m);
- int pe = ce == CE_MenuTearoff ? PseudoElement_MenuTearoff : PseudoElement_MenuScroller;
- QRenderRule subRule = renderRule(w, opt, pe);
- mi.rect = subRule.contentsRect(opt->rect);
- rule.configurePalette(&mi.palette, QPalette::ButtonText, QPalette::Button);
- subRule.configurePalette(&mi.palette, QPalette::ButtonText, QPalette::Button);
-
- if (subRule.hasDrawable()) {
- subRule.drawRule(p, opt->rect);
- } else {
- baseStyle()->drawControl(ce, &mi, p, w);
- }
- }
- return;
-
- case CE_MenuItem:
- if (const QStyleOptionMenuItem *m = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
- QStyleOptionMenuItem mi(*m);
-
- int pseudo = (mi.menuItemType == QStyleOptionMenuItem::Separator) ? PseudoElement_MenuSeparator : PseudoElement_Item;
- QRenderRule subRule = renderRule(w, opt, pseudo);
- mi.rect = subRule.contentsRect(opt->rect);
- rule.configurePalette(&mi.palette, QPalette::ButtonText, QPalette::Button);
- rule.configurePalette(&mi.palette, QPalette::HighlightedText, QPalette::Highlight);
- subRule.configurePalette(&mi.palette, QPalette::ButtonText, QPalette::Button);
- subRule.configurePalette(&mi.palette, QPalette::HighlightedText, QPalette::Highlight);
- QFont oldFont = p->font();
- if (subRule.hasFont)
- p->setFont(subRule.font.resolve(p->font()));
-
- // We fall back to drawing with the style sheet code whenever at least one of the
- // items are styled in an incompatible way, such as having a background image.
- QRenderRule allRules = renderRule(w, PseudoElement_Item, PseudoClass_Any);
-
- if ((pseudo == PseudoElement_MenuSeparator) && subRule.hasDrawable()) {
- subRule.drawRule(p, opt->rect);
- } else if ((pseudo == PseudoElement_Item)
- && (allRules.hasBox() || allRules.hasBorder()
- || (allRules.background() && !allRules.background()->pixmap.isNull()))) {
- subRule.drawRule(p, opt->rect);
- if (subRule.hasBackground()) {
- mi.palette.setBrush(QPalette::Highlight, Qt::NoBrush);
- mi.palette.setBrush(QPalette::Button, Qt::NoBrush);
- } else {
- mi.palette.setBrush(QPalette::Highlight, mi.palette.brush(QPalette::Button));
- }
- mi.palette.setBrush(QPalette::HighlightedText, mi.palette.brush(QPalette::ButtonText));
-
- bool checkable = mi.checkType != QStyleOptionMenuItem::NotCheckable;
- bool checked = checkable ? mi.checked : false;
-
- bool dis = !(opt->state & QStyle::State_Enabled),
- act = opt->state & QStyle::State_Selected;
-
- if (!mi.icon.isNull()) {
- QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
- if (act && !dis)
- mode = QIcon::Active;
- QPixmap pixmap;
- if (checked)
- pixmap = mi.icon.pixmap(pixelMetric(PM_SmallIconSize), mode, QIcon::On);
- else
- pixmap = mi.icon.pixmap(pixelMetric(PM_SmallIconSize), mode);
- int pixw = pixmap.width();
- int pixh = pixmap.height();
- QRenderRule iconRule = renderRule(w, opt, PseudoElement_MenuIcon);
- if (!iconRule.hasGeometry()) {
- iconRule.geo = new QStyleSheetGeometryData(pixw, pixh, pixw, pixh, -1, -1);
- } else {
- iconRule.geo->width = pixw;
- iconRule.geo->height = pixh;
- }
- QRect iconRect = positionRect(w, subRule, iconRule, PseudoElement_MenuIcon, opt->rect, opt->direction);
- iconRule.drawRule(p, iconRect);
- QRect pmr(0, 0, pixw, pixh);
- pmr.moveCenter(iconRect.center());
- p->drawPixmap(pmr.topLeft(), pixmap);
- } else if (checkable) {
- QRenderRule subSubRule = renderRule(w, opt, PseudoElement_MenuCheckMark);
- if (subSubRule.hasDrawable() || checked) {
- QStyleOptionMenuItem newMi = mi;
- newMi.rect = positionRect(w, subRule, subSubRule, PseudoElement_MenuCheckMark, opt->rect, opt->direction);
- drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, w);
- }
- }
-
- QRect textRect = subRule.contentsRect(opt->rect);
- textRect.setWidth(textRect.width() - mi.tabWidth);
- QString s = mi.text;
- p->setPen(mi.palette.buttonText().color());
- if (!s.isEmpty()) {
- int text_flags = Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
- if (!styleHint(SH_UnderlineShortcut, &mi, w))
- text_flags |= Qt::TextHideMnemonic;
- int t = s.indexOf(QLatin1Char('\t'));
- if (t >= 0) {
- QRect vShortcutRect = visualRect(opt->direction, mi.rect,
- QRect(textRect.topRight(), QPoint(mi.rect.right(), textRect.bottom())));
- p->drawText(vShortcutRect, text_flags, s.mid(t + 1));
- s = s.left(t);
- }
- p->drawText(textRect, text_flags, s.left(t));
- }
-
- if (mi.menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
- PrimitiveElement arrow = (opt->direction == Qt::RightToLeft) ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
- QRenderRule subRule2 = renderRule(w, opt, PseudoElement_MenuRightArrow);
- mi.rect = positionRect(w, subRule, subRule2, PseudoElement_MenuRightArrow, opt->rect, mi.direction);
- drawPrimitive(arrow, &mi, p, w);
- }
- } else if (hasStyleRule(w, PseudoElement_MenuCheckMark) || hasStyleRule(w, PseudoElement_MenuRightArrow)) {
- QWindowsStyle::drawControl(ce, &mi, p, w);
- if (mi.checkType != QStyleOptionMenuItem::NotCheckable && !mi.checked) {
- // We have a style defined, but QWindowsStyle won't draw anything if not checked.
- // So we mimick what QWindowsStyle would do.
- int checkcol = qMax<int>(mi.maxIconWidth, QWindowsStylePrivate::windowsCheckMarkWidth);
- QRect vCheckRect = visualRect(opt->direction, mi.rect, QRect(mi.rect.x(), mi.rect.y(), checkcol, mi.rect.height()));
- if (mi.state.testFlag(State_Enabled) && mi.state.testFlag(State_Selected)) {
- qDrawShadePanel(p, vCheckRect, mi.palette, true, 1, &mi.palette.brush(QPalette::Button));
- } else {
- QBrush fill(mi.palette.light().color(), Qt::Dense4Pattern);
- qDrawShadePanel(p, vCheckRect, mi.palette, true, 1, &fill);
- }
- QRenderRule subSubRule = renderRule(w, opt, PseudoElement_MenuCheckMark);
- if (subSubRule.hasDrawable()) {
- QStyleOptionMenuItem newMi(mi);
- newMi.rect = visualRect(opt->direction, mi.rect, QRect(mi.rect.x() + QWindowsStylePrivate::windowsItemFrame,
- mi.rect.y() + QWindowsStylePrivate::windowsItemFrame,
- checkcol - 2 * QWindowsStylePrivate::windowsItemFrame,
- mi.rect.height() - 2 * QWindowsStylePrivate::windowsItemFrame));
- drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, w);
- }
- }
- } else {
- if (rule.hasDrawable() && !subRule.hasDrawable() && !(opt->state & QStyle::State_Selected)) {
- mi.palette.setColor(QPalette::Window, Qt::transparent);
- mi.palette.setColor(QPalette::Button, Qt::transparent);
- }
- if (rule.baseStyleCanDraw() && subRule.baseStyleCanDraw()) {
- baseStyle()->drawControl(ce, &mi, p, w);
- } else {
- ParentStyle::drawControl(ce, &mi, p, w);
- }
- }
-
- if (subRule.hasFont)
- p->setFont(oldFont);
-
- return;
- }
- return;
-
- case CE_MenuBarItem:
- if (const QStyleOptionMenuItem *m = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
- QStyleOptionMenuItem mi(*m);
- QRenderRule subRule = renderRule(w, opt, PseudoElement_Item);
- mi.rect = subRule.contentsRect(opt->rect);
- rule.configurePalette(&mi.palette, QPalette::ButtonText, QPalette::Button);
- subRule.configurePalette(&mi.palette, QPalette::ButtonText, QPalette::Button);
-
- if (subRule.hasDrawable()) {
- subRule.drawRule(p, opt->rect);
- QCommonStyle::drawControl(ce, &mi, p, w);
- } else {
- if (rule.hasDrawable() && !(opt->state & QStyle::State_Selected)) {
- // So that the menu bar background is not hidden by the items
- mi.palette.setColor(QPalette::Window, Qt::transparent);
- mi.palette.setColor(QPalette::Button, Qt::transparent);
- }
- baseStyle()->drawControl(ce, &mi, p, w);
- }
- }
- return;
-
-#ifndef QT_NO_COMBOBOX
- case CE_ComboBoxLabel:
- if (!rule.hasBox())
- break;
- if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
- QRect editRect = subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, w);
- p->save();
- p->setClipRect(editRect);
- if (!cb->currentIcon.isNull()) {
- int spacing = rule.hasBox() ? rule.box()->spacing : -1;
- if (spacing == -1)
- spacing = 6;
- QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal : QIcon::Disabled;
- QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode);
- QRect iconRect(editRect);
- iconRect.setWidth(cb->iconSize.width());
- iconRect = alignedRect(cb->direction,
- Qt::AlignLeft | Qt::AlignVCenter,
- iconRect.size(), editRect);
- drawItemPixmap(p, iconRect, Qt::AlignCenter, pixmap);
-
- if (cb->direction == Qt::RightToLeft)
- editRect.translate(-spacing - cb->iconSize.width(), 0);
- else
- editRect.translate(cb->iconSize.width() + spacing, 0);
- }
- if (!cb->currentText.isEmpty() && !cb->editable) {
- QPalette styledPalette(cb->palette);
- rule.configurePalette(&styledPalette, QPalette::Text, QPalette::Base);
- drawItemText(p, editRect.adjusted(0, 0, 0, 0), Qt::AlignLeft | Qt::AlignVCenter, styledPalette,
- cb->state & State_Enabled, cb->currentText, QPalette::Text);
- }
- p->restore();
- return;
- }
- break;
-#endif // QT_NO_COMBOBOX
-
- case CE_Header:
- if (hasStyleRule(w, PseudoElement_HeaderViewUpArrow)
- || hasStyleRule(w, PseudoElement_HeaderViewDownArrow)) {
- ParentStyle::drawControl(ce, opt, p, w);
- return;
- }
- if(hasStyleRule(w, PseudoElement_HeaderViewSection)) {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewSection);
- if (!subRule.hasNativeBorder() || !subRule.baseStyleCanDraw()
- || subRule.hasBackground() || subRule.hasPalette()) {
- ParentStyle::drawControl(ce, opt, p, w);
- return;
- }
- }
- break;
- case CE_HeaderSection:
- if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewSection);
- if (subRule.hasNativeBorder()) {
- QStyleOptionHeader hdr(*header);
- subRule.configurePalette(&hdr.palette, QPalette::ButtonText, QPalette::Button);
-
- if (subRule.baseStyleCanDraw()) {
- baseStyle()->drawControl(CE_HeaderSection, &hdr, p, w);
- } else {
- QWindowsStyle::drawControl(CE_HeaderSection, &hdr, p, w);
- }
- } else {
- subRule.drawRule(p, opt->rect);
- }
- return;
- }
- break;
-
- case CE_HeaderLabel:
- if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
- QStyleOptionHeader hdr(*header);
- QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewSection);
- subRule.configurePalette(&hdr.palette, QPalette::ButtonText, QPalette::Button);
- QFont oldFont = p->font();
- if (subRule.hasFont)
- p->setFont(subRule.font.resolve(p->font()));
- baseStyle()->drawControl(ce, &hdr, p, w);
- if (subRule.hasFont)
- p->setFont(oldFont);
- return;
- }
- break;
-
- case CE_HeaderEmptyArea:
- if (rule.hasDrawable()) {
- return;
- }
- break;
-
- case CE_ProgressBar:
- QWindowsStyle::drawControl(ce, opt, p, w);
- return;
-
- case CE_ProgressBarGroove:
- if (!rule.hasNativeBorder()) {
- rule.drawRule(p, rule.boxRect(opt->rect, Margin));
- return;
- }
- break;
-
- case CE_ProgressBarContents: {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_ProgressBarChunk);
- if (subRule.hasDrawable()) {
- if (const QStyleOptionProgressBarV2 *pb = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
- p->save();
- p->setClipRect(pb->rect);
-
- qint64 minimum = qint64(pb->minimum);
- qint64 maximum = qint64(pb->maximum);
- qint64 progress = qint64(pb->progress);
- bool vertical = (pb->orientation == Qt::Vertical);
- bool inverted = pb->invertedAppearance;
-
- QTransform m;
- QRect rect = pb->rect;
- if (vertical) {
- rect = QRect(rect.y(), rect.x(), rect.height(), rect.width());
- m.rotate(90);
- m.translate(0, -(rect.height() + rect.y()*2));
- }
-
- bool reverse = ((!vertical && (pb->direction == Qt::RightToLeft)) || vertical);
- if (inverted)
- reverse = !reverse;
- const bool indeterminate = pb->minimum == pb->maximum;
- qreal fillRatio = indeterminate ? 0.50 : qreal(progress - minimum)/(maximum - minimum);
- int fillWidth = int(rect.width() * fillRatio);
- int chunkWidth = fillWidth;
- if (subRule.hasContentsSize()) {
- QSize sz = subRule.size();
- chunkWidth = (opt->state & QStyle::State_Horizontal) ? sz.width() : sz.height();
- }
-
- QRect r = rect;
- if (pb->minimum == 0 && pb->maximum == 0) {
- Q_D(const QWindowsStyle);
- int chunkCount = fillWidth/chunkWidth;
- int offset = (d->animateStep*8%rect.width());
- int x = reverse ? r.left() + r.width() - offset - chunkWidth : r.x() + offset;
- while (chunkCount > 0) {
- r.setRect(x, rect.y(), chunkWidth, rect.height());
- r = m.mapRect(QRectF(r)).toRect();
- subRule.drawRule(p, r);
- x += reverse ? -chunkWidth : chunkWidth;
- if (reverse ? x < rect.left() : x > rect.right())
- break;
- --chunkCount;
- }
-
- r = rect;
- x = reverse ? r.right() - (r.left() - x - chunkWidth)
- : r.left() + (x - r.right() - chunkWidth);
- while (chunkCount > 0) {
- r.setRect(x, rect.y(), chunkWidth, rect.height());
- r = m.mapRect(QRectF(r)).toRect();
- subRule.drawRule(p, r);
- x += reverse ? -chunkWidth : chunkWidth;
- --chunkCount;
- };
- } else {
- int x = reverse ? r.left() + r.width() - chunkWidth : r.x();
-
- for (int i = 0; i < ceil(qreal(fillWidth)/chunkWidth); ++i) {
- r.setRect(x, rect.y(), chunkWidth, rect.height());
- r = m.mapRect(QRectF(r)).toRect();
- subRule.drawRule(p, r);
- x += reverse ? -chunkWidth : chunkWidth;
- }
- }
-
- p->restore();
- return;
- }
- }
- }
- break;
-
- case CE_ProgressBarLabel:
- if (const QStyleOptionProgressBarV2 *pb = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
- if (rule.hasBox() || rule.hasBorder() || hasStyleRule(w, PseudoElement_ProgressBarChunk)) {
- drawItemText(p, pb->rect, pb->textAlignment | Qt::TextSingleLine, pb->palette,
- pb->state & State_Enabled, pb->text, QPalette::Text);
- } else {
- QStyleOptionProgressBarV2 pbCopy(*pb);
- rule.configurePalette(&pbCopy.palette, QPalette::HighlightedText, QPalette::Highlight);
- baseStyle()->drawControl(ce, &pbCopy, p, w);
- }
- return;
- }
- break;
-
- case CE_SizeGrip:
- if (const QStyleOptionSizeGrip *sgOpt = qstyleoption_cast<const QStyleOptionSizeGrip *>(opt)) {
- if (rule.hasDrawable()) {
- rule.drawFrame(p, opt->rect);
- p->save();
- switch (sgOpt->corner) {
- case Qt::BottomRightCorner: break;
- case Qt::BottomLeftCorner: p->rotate(90); break;
- case Qt::TopLeftCorner: p->rotate(180); break;
- case Qt::TopRightCorner: p->rotate(270); break;
- default: break;
- }
- rule.drawImage(p, opt->rect);
- p->restore();
- } else {
- QStyleOptionSizeGrip sg(*sgOpt);
- sg.rect = rule.contentsRect(opt->rect);
- baseStyle()->drawControl(CE_SizeGrip, &sg, p, w);
- }
- return;
- }
- break;
-
- case CE_ToolBoxTab:
- QWindowsStyle::drawControl(ce, opt, p, w);
- return;
-
- case CE_ToolBoxTabShape: {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_ToolBoxTab);
- if (subRule.hasDrawable()) {
- subRule.drawRule(p, opt->rect);
- return;
- }
- }
- break;
-
- case CE_ToolBoxTabLabel:
- if (const QStyleOptionToolBox *box = qstyleoption_cast<const QStyleOptionToolBox *>(opt)) {
- QStyleOptionToolBox boxCopy(*box);
- QRenderRule subRule = renderRule(w, opt, PseudoElement_ToolBoxTab);
- subRule.configurePalette(&boxCopy.palette, QPalette::ButtonText, QPalette::Button);
- QFont oldFont = p->font();
- if (subRule.hasFont)
- p->setFont(subRule.font);
- boxCopy.rect = subRule.contentsRect(opt->rect);
- QWindowsStyle::drawControl(ce, &boxCopy, p , w);
- if (subRule.hasFont)
- p->setFont(oldFont);
- return;
- }
- break;
-
- case CE_ScrollBarAddPage:
- pe1 = PseudoElement_ScrollBarAddPage;
- break;
-
- case CE_ScrollBarSubPage:
- pe1 = PseudoElement_ScrollBarSubPage;
- break;
-
- case CE_ScrollBarAddLine:
- pe1 = PseudoElement_ScrollBarAddLine;
- pe2 = (opt->state & QStyle::State_Horizontal) ? PseudoElement_ScrollBarRightArrow : PseudoElement_ScrollBarDownArrow;
- fallback = true;
- break;
-
- case CE_ScrollBarSubLine:
- pe1 = PseudoElement_ScrollBarSubLine;
- pe2 = (opt->state & QStyle::State_Horizontal) ? PseudoElement_ScrollBarLeftArrow : PseudoElement_ScrollBarUpArrow;
- fallback = true;
- break;
-
- case CE_ScrollBarFirst:
- pe1 = PseudoElement_ScrollBarFirst;
- break;
-
- case CE_ScrollBarLast:
- pe1 = PseudoElement_ScrollBarLast;
- break;
-
- case CE_ScrollBarSlider:
- pe1 = PseudoElement_ScrollBarSlider;
- fallback = true;
- break;
-
-#ifndef QT_NO_ITEMVIEWS
- case CE_ItemViewItem:
- if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_ViewItem);
- if (subRule.hasDrawable() || hasStyleRule(w, PseudoElement_Indicator)) {
- QStyleOptionViewItemV4 optCopy(*vopt);
- subRule.configurePalette(&optCopy.palette, vopt->state & QStyle::State_Selected ? QPalette::HighlightedText : QPalette::Text,
- vopt->state & QStyle::State_Selected ? QPalette::Highlight : QPalette::Base);
- QWindowsStyle::drawControl(ce, &optCopy, p, w);
- } else {
- QStyleOptionViewItemV4 voptCopy(*vopt);
- subRule.configurePalette(&voptCopy.palette, QPalette::Text, QPalette::NoRole);
- baseStyle()->drawControl(ce, &voptCopy, p, w);
- }
- return;
- }
- break;
-#endif // QT_NO_ITEMVIEWS
-
-#ifndef QT_NO_TABBAR
- case CE_TabBarTab:
- if (hasStyleRule(w, PseudoElement_TabBarTab)) {
- QWindowsStyle::drawControl(ce, opt, p, w);
- return;
- }
- break;
-
- case CE_TabBarTabLabel:
- case CE_TabBarTabShape:
- if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
- QStyleOptionTabV3 tabCopy(*tab);
- QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTab);
- QRect r = positionRect(w, subRule, PseudoElement_TabBarTab, opt->rect, opt->direction);
- if (ce == CE_TabBarTabShape && subRule.hasDrawable()) {
- subRule.drawRule(p, r);
- return;
- }
- subRule.configurePalette(&tabCopy.palette, QPalette::WindowText, QPalette::Window);
- QFont oldFont = p->font();
- if (subRule.hasFont)
- p->setFont(subRule.font);
- if (subRule.hasBox() || !subRule.hasNativeBorder()) {
- tabCopy.rect = ce == CE_TabBarTabShape ? subRule.borderRect(r)
- : subRule.contentsRect(r);
- QWindowsStyle::drawControl(ce, &tabCopy, p, w);
- } else {
- baseStyle()->drawControl(ce, &tabCopy, p, w);
- }
- if (subRule.hasFont)
- p->setFont(oldFont);
-
- return;
- }
- break;
-#endif // QT_NO_TABBAR
-
- case CE_ColumnViewGrip:
- if (rule.hasDrawable()) {
- rule.drawRule(p, opt->rect);
- return;
- }
- break;
-
- case CE_DockWidgetTitle:
- if (const QStyleOptionDockWidgetV2 *dwOpt = qstyleoption_cast<const QStyleOptionDockWidgetV2 *>(opt)) {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_DockWidgetTitle);
- if (!subRule.hasDrawable() && !subRule.hasPosition())
- break;
- if (subRule.hasDrawable()) {
- subRule.drawRule(p, opt->rect);
- } else {
- QStyleOptionDockWidgetV2 dwCopy(*dwOpt);
- dwCopy.title = QString();
- baseStyle()->drawControl(ce, &dwCopy, p, w);
- }
-
- if (!dwOpt->title.isEmpty()) {
- QRect r = opt->rect;
- if (dwOpt->verticalTitleBar) {
- QSize s = r.size();
- s.transpose();
- r.setSize(s);
-
- p->save();
- p->translate(r.left(), r.top() + r.width());
- p->rotate(-90);
- p->translate(-r.left(), -r.top());
- }
-
- Qt::Alignment alignment = 0;
- if (subRule.hasPosition())
- alignment = subRule.position()->textAlignment;
- if (alignment == 0)
- alignment = Qt::AlignLeft;
- drawItemText(p, subRule.contentsRect(opt->rect),
- alignment | Qt::TextShowMnemonic, dwOpt->palette,
- dwOpt->state & State_Enabled, dwOpt->title,
- QPalette::WindowText);
-
- if (dwOpt->verticalTitleBar)
- p->restore();
- }
-
- return;
- }
- break;
- case CE_ShapedFrame:
- if (const QStyleOptionFrame *frm = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
- if (rule.hasNativeBorder()) {
- QStyleOptionFrameV3 frmOpt(*frm);
- rule.configurePalette(&frmOpt.palette, QPalette::Text, QPalette::Base);
- frmOpt.rect = rule.borderRect(frmOpt.rect);
- baseStyle()->drawControl(ce, &frmOpt, p, w);
- }
- // else, borders are already drawn in PE_Widget
- }
- return;
-
-
- default:
- break;
- }
-
- if (pe1 != PseudoElement_None) {
- QRenderRule subRule = renderRule(w, opt, pe1);
- if (subRule.bg != 0 || subRule.hasDrawable()) {
- //We test subRule.bg directly because hasBackground() would return false for background:none.
- //But we still don't want the default drawning in that case (example for QScrollBar::add-page) (task 198926)
- subRule.drawRule(p, opt->rect);
- } else if (fallback) {
- QWindowsStyle::drawControl(ce, opt, p, w);
- pe2 = PseudoElement_None;
- } else {
- baseStyle()->drawControl(ce, opt, p, w);
- }
- if (pe2 != PseudoElement_None) {
- QRenderRule subSubRule = renderRule(w, opt, pe2);
- QRect r = positionRect(w, subRule, subSubRule, pe2, opt->rect, opt->direction);
- subSubRule.drawRule(p, r);
- }
- return;
- }
-
- baseStyle()->drawControl(ce, opt, p, w);
-}
-
-void QStyleSheetStyle::drawItemPixmap(QPainter *p, const QRect &rect, int alignment, const
- QPixmap &pixmap) const
-{
- baseStyle()->drawItemPixmap(p, rect, alignment, pixmap);
-}
-
-void QStyleSheetStyle::drawItemText(QPainter *painter, const QRect& rect, int alignment, const QPalette &pal,
- bool enabled, const QString& text, QPalette::ColorRole textRole) const
-{
- baseStyle()->drawItemText(painter, rect, alignment, pal, enabled, text, textRole);
-}
-
-void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
- const QWidget *w) const
-{
- RECURSION_GUARD(baseStyle()->drawPrimitive(pe, opt, p, w); return)
-
- int pseudoElement = PseudoElement_None;
- QRenderRule rule = renderRule(w, opt);
- QRect rect = opt->rect;
-
- switch (pe) {
-
- case PE_FrameStatusBar: {
- QRenderRule subRule = renderRule(w->parentWidget(), opt, PseudoElement_Item);
- if (subRule.hasDrawable()) {
- subRule.drawRule(p, opt->rect);
- return;
- }
- break;
- }
-
- case PE_IndicatorArrowDown:
- pseudoElement = PseudoElement_DownArrow;
- break;
-
- case PE_IndicatorArrowUp:
- pseudoElement = PseudoElement_UpArrow;
- break;
-
- case PE_IndicatorRadioButton:
- pseudoElement = PseudoElement_ExclusiveIndicator;
- break;
-
- case PE_IndicatorViewItemCheck:
- pseudoElement = PseudoElement_ViewItemIndicator;
- break;
-
- case PE_IndicatorCheckBox:
- pseudoElement = PseudoElement_Indicator;
- break;
-
- case PE_IndicatorHeaderArrow:
- if (const QStyleOptionHeader *hdr = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
- pseudoElement = hdr->sortIndicator == QStyleOptionHeader::SortUp
- ? PseudoElement_HeaderViewUpArrow
- : PseudoElement_HeaderViewDownArrow;
- }
- break;
-
- case PE_PanelButtonTool:
- case PE_PanelButtonCommand:
- if (qobject_cast<const QAbstractButton *>(w) && rule.hasBackground() && rule.hasNativeBorder()) {
- //the window style will draw the borders
- ParentStyle::drawPrimitive(pe, opt, p, w);
- if (!rule.background()->pixmap.isNull() || rule.hasImage()) {
- rule.drawRule(p, rule.boxRect(opt->rect, QRenderRule::Margin).adjusted(1,1,-1,-1));
- }
- return;
- }
- if (!rule.hasNativeBorder()) {
- rule.drawRule(p, rule.boxRect(opt->rect, QRenderRule::Margin));
- return;
- }
- break;
-
- case PE_IndicatorButtonDropDown: {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_ToolButtonMenu);
- if (!subRule.hasNativeBorder()) {
- rule.drawBorder(p, opt->rect);
- return;
- }
- break;
- }
-
- case PE_FrameDefaultButton:
- if (rule.hasNativeBorder()) {
- if (rule.baseStyleCanDraw())
- break;
- QWindowsStyle::drawPrimitive(pe, opt, p, w);
- }
- return;
-
- case PE_FrameWindow:
- case PE_FrameDockWidget:
- case PE_Frame:
- if (const QStyleOptionFrame *frm = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
- if (rule.hasNativeBorder()) {
- QStyleOptionFrameV2 frmOpt(*frm);
- rule.configurePalette(&frmOpt.palette, QPalette::Text, QPalette::Base);
- if (!qstyleoption_cast<const QStyleOptionFrameV3 *>(opt)) //if it comes from CE_ShapedFrame, the margins are already sustracted
- frmOpt.rect = rule.borderRect(frmOpt.rect);
- baseStyle()->drawPrimitive(pe, &frmOpt, p, w);
- } else {
- rule.drawBorder(p, rule.borderRect(opt->rect));
- }
- }
- return;
-
- case PE_PanelLineEdit:
- if (const QStyleOptionFrame *frm = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
-#ifndef QT_NO_SPINBOX
- if (w && qobject_cast<const QAbstractSpinBox *>(w->parentWidget())) {
- QRenderRule spinboxRule = renderRule(w->parentWidget(), opt);
- if (!spinboxRule.hasNativeBorder() || !spinboxRule.baseStyleCanDraw())
- return;
- rule = spinboxRule;
- }
-#endif
- if (rule.hasNativeBorder()) {
- QStyleOptionFrame frmOpt(*frm);
- rule.configurePalette(&frmOpt.palette, QPalette::Text, QPalette::Base);
- frmOpt.rect = rule.borderRect(frmOpt.rect);
- if (rule.baseStyleCanDraw()) {
- rule.drawBackgroundImage(p, opt->rect);
- baseStyle()->drawPrimitive(pe, &frmOpt, p, w);
- } else {
- rule.drawBackground(p, opt->rect);
- if (frmOpt.lineWidth > 0)
- baseStyle()->drawPrimitive(PE_FrameLineEdit, &frmOpt, p, w);
- }
- } else {
- rule.drawRule(p, opt->rect);
- }
- }
- return;
-
- case PE_Widget:
- if (w && !rule.hasDrawable()) {
- QWidget *container = containerWidget(w);
- if (styleSheetCaches->autoFillDisabledWidgets.contains(container)
- && (container == w || !renderRule(container, opt).hasBackground())) {
- //we do not have a background, but we disabled the autofillbackground anyway. so fill the background now.
- // (this may happen if we have rules like :focus)
- p->fillRect(opt->rect, opt->palette.brush(w->backgroundRole()));
- }
- break;
- }
-#ifndef QT_NO_SCROLLAREA
- if (const QAbstractScrollArea *sa = qobject_cast<const QAbstractScrollArea *>(w)) {
- const QAbstractScrollAreaPrivate *sap = sa->d_func();
- rule.drawBackground(p, opt->rect, sap->contentsOffset());
- if (rule.hasBorder()) {
- QRect brect = rule.borderRect(opt->rect);
- if (styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, opt, w)) {
- QRect r = brect.adjusted(0, 0, sa->verticalScrollBar()->isVisible() ? -sa->verticalScrollBar()->width() : 0,
- sa->horizontalScrollBar()->isVisible() ? -sa->horizontalScrollBar()->height() : 0);
- brect = QStyle::visualRect(opt->direction, brect, r);
- }
- rule.drawBorder(p, brect);
- }
- break;
- }
-#endif
- //fall tghought
- case PE_PanelMenu:
- case PE_PanelStatusBar:
- if(rule.hasDrawable()) {
- rule.drawRule(p, opt->rect);
- return;
- }
- break;
-
- case PE_FrameMenu:
- if (rule.hasDrawable()) {
- // Drawn by PE_PanelMenu
- return;
- }
- break;
-
- case PE_PanelMenuBar:
- if (rule.hasDrawable()) {
- // Drawn by PE_Widget
- return;
- }
- break;
-
- case PE_IndicatorToolBarSeparator:
- case PE_IndicatorToolBarHandle: {
- PseudoElement ps = pe == PE_IndicatorToolBarHandle ? PseudoElement_ToolBarHandle : PseudoElement_ToolBarSeparator;
- QRenderRule subRule = renderRule(w, opt, ps);
- if (subRule.hasDrawable()) {
- subRule.drawRule(p, opt->rect);
- return;
- }
- }
- break;
-
- case PE_IndicatorMenuCheckMark:
- pseudoElement = PseudoElement_MenuCheckMark;
- break;
-
- case PE_IndicatorArrowLeft:
- pseudoElement = PseudoElement_LeftArrow;
- break;
-
- case PE_IndicatorArrowRight:
- pseudoElement = PseudoElement_RightArrow;
- break;
-
- case PE_IndicatorColumnViewArrow:
- if (const QStyleOptionViewItem *viewOpt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
- bool reverse = (viewOpt->direction == Qt::RightToLeft);
- pseudoElement = reverse ? PseudoElement_LeftArrow : PseudoElement_RightArrow;
- } else {
- pseudoElement = PseudoElement_RightArrow;
- }
- break;
-
- case PE_IndicatorBranch:
- if (const QStyleOptionViewItemV2 *v2 = qstyleoption_cast<const QStyleOptionViewItemV2 *>(opt)) {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_TreeViewBranch);
- if (subRule.hasDrawable()) {
- if ((v2->state & QStyle::State_Selected) && v2->showDecorationSelected)
- p->fillRect(v2->rect, v2->palette.highlight());
- else if (v2->features & QStyleOptionViewItemV2::Alternate)
- p->fillRect(v2->rect, v2->palette.alternateBase());
- subRule.drawRule(p, opt->rect);
- } else {
- baseStyle()->drawPrimitive(pe, v2, p, w);
- }
- }
- return;
-
- case PE_PanelTipLabel:
- if (!rule.hasDrawable())
- break;
-
- if (const QStyleOptionFrame *frmOpt = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
- if (rule.hasNativeBorder()) {
- rule.drawBackground(p, opt->rect);
- QStyleOptionFrame optCopy(*frmOpt);
- optCopy.rect = rule.borderRect(opt->rect);
- optCopy.palette.setBrush(QPalette::Window, Qt::NoBrush); // oh dear
- baseStyle()->drawPrimitive(pe, &optCopy, p, w);
- } else {
- rule.drawRule(p, opt->rect);
- }
- }
- return;
-
- case PE_FrameGroupBox:
- if (rule.hasNativeBorder())
- break;
- rule.drawBorder(p, opt->rect);
- return;
-
-#ifndef QT_NO_TABWIDGET
- case PE_FrameTabWidget:
- if (const QStyleOptionTabWidgetFrame *frm = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_TabWidgetPane);
- if (subRule.hasNativeBorder()) {
- subRule.drawBackground(p, opt->rect);
- QStyleOptionTabWidgetFrameV2 frmCopy(*frm);
- subRule.configurePalette(&frmCopy.palette, QPalette::WindowText, QPalette::Window);
- baseStyle()->drawPrimitive(pe, &frmCopy, p, w);
- } else {
- subRule.drawRule(p, opt->rect);
- }
- return;
- }
- break;
-#endif // QT_NO_TABWIDGET
-
- case PE_IndicatorProgressChunk:
- pseudoElement = PseudoElement_ProgressBarChunk;
- break;
-
- case PE_IndicatorTabTear:
- pseudoElement = PseudoElement_TabBarTear;
- break;
-
- case PE_FrameFocusRect:
- if (!rule.hasNativeOutline()) {
- rule.drawOutline(p, opt->rect);
- return;
- }
- break;
-
- case PE_IndicatorDockWidgetResizeHandle:
- pseudoElement = PseudoElement_DockWidgetSeparator;
- break;
-
- case PE_PanelItemViewItem:
- pseudoElement = PseudoElement_ViewItem;
- break;
-
- case PE_PanelScrollAreaCorner:
- pseudoElement = PseudoElement_ScrollAreaCorner;
- break;
-
- case PE_IndicatorSpinDown:
- case PE_IndicatorSpinMinus:
- pseudoElement = PseudoElement_SpinBoxDownArrow;
- break;
-
- case PE_IndicatorSpinUp:
- case PE_IndicatorSpinPlus:
- pseudoElement = PseudoElement_SpinBoxUpArrow;
- break;
-#ifndef QT_NO_TABBAR
- case PE_IndicatorTabClose:
- if (w)
- w = w->parentWidget(); //match on the QTabBar instead of the CloseButton
- pseudoElement = PseudoElement_TabBarTabCloseButton;
-#endif
-
- default:
- break;
- }
-
- if (pseudoElement != PseudoElement_None) {
- QRenderRule subRule = renderRule(w, opt, pseudoElement);
- if (subRule.hasDrawable()) {
- subRule.drawRule(p, rect);
- } else {
- baseStyle()->drawPrimitive(pe, opt, p, w);
- }
- } else {
- baseStyle()->drawPrimitive(pe, opt, p, w);
- }
-}
-
-QPixmap QStyleSheetStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap& pixmap,
- const QStyleOption *option) const
-{
- return baseStyle()->generatedIconPixmap(iconMode, pixmap, option);
-}
-
-QStyle::SubControl QStyleSheetStyle::hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
- const QPoint &pt, const QWidget *w) const
-{
- RECURSION_GUARD(return baseStyle()->hitTestComplexControl(cc, opt, pt, w))
- switch (cc) {
- case CC_TitleBar:
- if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
- QRenderRule rule = renderRule(w, opt, PseudoElement_TitleBar);
- if (rule.hasDrawable() || rule.hasBox() || rule.hasBorder()) {
- QHash<QStyle::SubControl, QRect> layout = titleBarLayout(w, tb);
- QRect r;
- QStyle::SubControl sc = QStyle::SC_None;
- uint ctrl = SC_TitleBarSysMenu;
- while (ctrl <= SC_TitleBarLabel) {
- r = layout[QStyle::SubControl(ctrl)];
- if (r.isValid() && r.contains(pt)) {
- sc = QStyle::SubControl(ctrl);
- break;
- }
- ctrl <<= 1;
- }
- return sc;
- }
- }
- break;
-
- case CC_MdiControls:
- if (hasStyleRule(w, PseudoElement_MdiCloseButton)
- || hasStyleRule(w, PseudoElement_MdiNormalButton)
- || hasStyleRule(w, PseudoElement_MdiMinButton))
- return QWindowsStyle::hitTestComplexControl(cc, opt, pt, w);
- break;
-
- case CC_ScrollBar: {
- QRenderRule rule = renderRule(w, opt);
- if (!rule.hasDrawable() && !rule.hasBox())
- break;
- }
- // intentionally falls through
- case CC_SpinBox:
- case CC_GroupBox:
- case CC_ComboBox:
- case CC_Slider:
- case CC_ToolButton:
- return QWindowsStyle::hitTestComplexControl(cc, opt, pt, w);
- default:
- break;
- }
-
- return baseStyle()->hitTestComplexControl(cc, opt, pt, w);
-}
-
-QRect QStyleSheetStyle::itemPixmapRect(const QRect &rect, int alignment, const QPixmap &pixmap) const
-{
- return baseStyle()->itemPixmapRect(rect, alignment, pixmap);
-}
-
-QRect QStyleSheetStyle::itemTextRect(const QFontMetrics &metrics, const QRect& rect, int alignment,
- bool enabled, const QString& text) const
-{
- return baseStyle()->itemTextRect(metrics, rect, alignment, enabled, text);
-}
-
-int QStyleSheetStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWidget *w) const
-{
- RECURSION_GUARD(return baseStyle()->pixelMetric(m, opt, w))
-
- QRenderRule rule = renderRule(w, opt);
- QRenderRule subRule;
-
- switch (m) {
- case PM_MenuButtonIndicator:
-#ifndef QT_NO_TOOLBUTTON
- // QToolButton adds this directly to the width
- if (qobject_cast<const QToolButton *>(w) && (rule.hasBox() || !rule.hasNativeBorder()))
- return 0;
-#endif
- subRule = renderRule(w, opt, PseudoElement_PushButtonMenuIndicator);
- if (subRule.hasContentsSize())
- return subRule.size().width();
- break;
-
- case PM_ButtonShiftHorizontal:
- case PM_ButtonShiftVertical:
- case PM_ButtonMargin:
- case PM_ButtonDefaultIndicator:
- if (rule.hasBox())
- return 0;
- break;
-
- case PM_DefaultFrameWidth:
- if (!rule.hasNativeBorder())
- return rule.border()->borders[LeftEdge];
- break;
-
- case PM_ExclusiveIndicatorWidth:
- case PM_IndicatorWidth:
- case PM_ExclusiveIndicatorHeight:
- case PM_IndicatorHeight:
- subRule = renderRule(w, opt, PseudoElement_Indicator);
- if (subRule.hasContentsSize()) {
- return (m == PM_ExclusiveIndicatorWidth) || (m == PM_IndicatorWidth)
- ? subRule.size().width() : subRule.size().height();
- }
- break;
-
- case PM_DockWidgetFrameWidth:
- case PM_ToolTipLabelFrameWidth: // border + margin + padding (support only one width)
- if (!rule.hasDrawable())
- break;
-
- return (rule.border() ? rule.border()->borders[LeftEdge] : 0)
- + (rule.hasBox() ? rule.box()->margins[LeftEdge] + rule.box()->paddings[LeftEdge]: 0);
-
- case PM_ToolBarFrameWidth:
- if (rule.hasBorder() || rule.hasBox())
- return (rule.border() ? rule.border()->borders[LeftEdge] : 0)
- + (rule.hasBox() ? rule.box()->paddings[LeftEdge]: 0);
- break;
-
- case PM_MenuPanelWidth:
- case PM_MenuBarPanelWidth:
- if (rule.hasBorder() || rule.hasBox())
- return (rule.border() ? rule.border()->borders[LeftEdge] : 0)
- + (rule.hasBox() ? rule.box()->margins[LeftEdge]: 0);
- break;
-
-
- case PM_MenuHMargin:
- case PM_MenuBarHMargin:
- if (rule.hasBox())
- return rule.box()->paddings[LeftEdge];
- break;
-
- case PM_MenuVMargin:
- case PM_MenuBarVMargin:
- if (rule.hasBox())
- return rule.box()->paddings[TopEdge];
- break;
-
- case PM_DockWidgetTitleBarButtonMargin:
- case PM_ToolBarItemMargin:
- if (rule.hasBox())
- return rule.box()->margins[TopEdge];
- break;
-
- case PM_ToolBarItemSpacing:
- case PM_MenuBarItemSpacing:
- if (rule.hasBox() && rule.box()->spacing != -1)
- return rule.box()->spacing;
- break;
-
- case PM_MenuTearoffHeight:
- case PM_MenuScrollerHeight: {
- PseudoElement ps = m == PM_MenuTearoffHeight ? PseudoElement_MenuTearoff : PseudoElement_MenuScroller;
- subRule = renderRule(w, opt, ps);
- if (subRule.hasContentsSize())
- return subRule.size().height();
- break;
- }
-
- case PM_ToolBarExtensionExtent:
- break;
-
- case PM_SplitterWidth:
- case PM_ToolBarSeparatorExtent:
- case PM_ToolBarHandleExtent: {
- PseudoElement ps;
- if (m == PM_ToolBarHandleExtent) ps = PseudoElement_ToolBarHandle;
- else if (m == PM_SplitterWidth) ps = PseudoElement_SplitterHandle;
- else ps = PseudoElement_ToolBarSeparator;
- subRule = renderRule(w, opt, ps);
- if (subRule.hasContentsSize()) {
- QSize sz = subRule.size();
- return (opt && opt->state & QStyle::State_Horizontal) ? sz.width() : sz.height();
- }
- break;
- }
-
- case PM_RadioButtonLabelSpacing:
- if (rule.hasBox() && rule.box()->spacing != -1)
- return rule.box()->spacing;
- break;
- case PM_CheckBoxLabelSpacing:
- if (qobject_cast<const QCheckBox *>(w)) {
- if (rule.hasBox() && rule.box()->spacing != -1)
- return rule.box()->spacing;
- }
- // assume group box
- subRule = renderRule(w, opt, PseudoElement_GroupBoxTitle);
- if (subRule.hasBox() && subRule.box()->spacing != -1)
- return subRule.box()->spacing;
- break;
-
-#ifndef QT_NO_SCROLLBAR
- case PM_ScrollBarExtent:
- if (rule.hasContentsSize()) {
- QSize sz = rule.size();
- if (const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(opt))
- return sb->orientation == Qt::Horizontal ? sz.height() : sz.width();
- return sz.width() == -1 ? sz.height() : sz.width();
- }
- break;
-
- case PM_ScrollBarSliderMin:
- if (hasStyleRule(w, PseudoElement_ScrollBarSlider)) {
- subRule = renderRule(w, opt, PseudoElement_ScrollBarSlider);
- QSize msz = subRule.minimumSize();
- if (const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(opt))
- return sb->orientation == Qt::Horizontal ? msz.width() : msz.height();
- return msz.width() == -1 ? msz.height() : msz.width();
- }
- break;
-
- case PM_ScrollView_ScrollBarSpacing:
- if(!rule.hasNativeBorder() || rule.hasBox())
- return 0;
- break;
-#endif // QT_NO_SCROLLBAR
-
- case PM_ProgressBarChunkWidth:
- subRule = renderRule(w, opt, PseudoElement_ProgressBarChunk);
- if (subRule.hasContentsSize()) {
- QSize sz = subRule.size();
- return (opt->state & QStyle::State_Horizontal)
- ? sz.width() : sz.height();
- }
- break;
-
-#ifndef QT_NO_TABWIDGET
- case PM_TabBarTabHSpace:
- case PM_TabBarTabVSpace:
- subRule = renderRule(w, opt, PseudoElement_TabBarTab);
- if (subRule.hasBox() || subRule.hasBorder())
- return 0;
- break;
-
- case PM_TabBarScrollButtonWidth: {
- subRule = renderRule(w, opt, PseudoElement_TabBarScroller);
- if (subRule.hasContentsSize()) {
- QSize sz = subRule.size();
- return sz.width() != -1 ? sz.width() : sz.height();
- }
- }
- break;
-
- case PM_TabBarTabShiftHorizontal:
- case PM_TabBarTabShiftVertical:
- subRule = renderRule(w, opt, PseudoElement_TabBarTab);
- if (subRule.hasBox())
- return 0;
- break;
-
- case PM_TabBarBaseOverlap: {
- const QWidget *tabWidget = qobject_cast<const QTabWidget *>(w) ? w : w->parentWidget();
- if (hasStyleRule(tabWidget, PseudoElement_TabWidgetPane)) {
- return 0;
- }
- break;
- }
-#endif // QT_NO_TABWIDGET
-
- case PM_SliderThickness: // horizontal slider's height (sizeHint)
- case PM_SliderLength: // minimum length of slider
- if (rule.hasContentsSize()) {
- bool horizontal = opt->state & QStyle::State_Horizontal;
- if (m == PM_SliderThickness) {
- QSize sz = rule.size();
- return horizontal ? sz.height() : sz.width();
- } else {
- QSize msz = rule.minimumContentsSize();
- return horizontal ? msz.width() : msz.height();
- }
- }
- break;
-
- case PM_SliderControlThickness: {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_SliderHandle);
- if (!subRule.hasContentsSize())
- break;
- QSize size = subRule.size();
- return (opt->state & QStyle::State_Horizontal) ? size.height() : size.width();
- }
-
- case PM_ToolBarIconSize:
- case PM_ListViewIconSize:
- case PM_IconViewIconSize:
- case PM_TabBarIconSize:
- case PM_MessageBoxIconSize:
- case PM_ButtonIconSize:
- case PM_SmallIconSize:
- if (rule.hasStyleHint(QLatin1String("icon-size"))) {
- return rule.styleHint(QLatin1String("icon-size")).toSize().width();
- }
- break;
-
- case PM_DockWidgetTitleMargin: {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_DockWidgetTitle);
- if (!subRule.hasBox())
- break;
- return (subRule.border() ? subRule.border()->borders[TopEdge] : 0)
- + (subRule.hasBox() ? subRule.box()->margins[TopEdge] + subRule.box()->paddings[TopEdge]: 0);
- }
-
- case PM_DockWidgetSeparatorExtent: {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_DockWidgetSeparator);
- if (!subRule.hasContentsSize())
- break;
- QSize sz = subRule.size();
- return qMax(sz.width(), sz.height());
- }
-
- case PM_TitleBarHeight: {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_TitleBar);
- if (subRule.hasContentsSize())
- return subRule.size().height();
- else if (subRule.hasBox() || subRule.hasBorder()) {
- QFontMetrics fm = opt ? opt->fontMetrics : w->fontMetrics();
- return subRule.size(QSize(0, fm.height())).height();
- }
- break;
- }
-
- case PM_MdiSubWindowFrameWidth:
- if (rule.hasBox() || rule.hasBorder()) {
- return (rule.border() ? rule.border()->borders[LeftEdge] : 0)
- + (rule.hasBox() ? rule.box()->paddings[LeftEdge]+rule.box()->margins[LeftEdge]: 0);
- }
- break;
-
- case PM_MdiSubWindowMinimizedWidth: {
- QRenderRule subRule = renderRule(w, PseudoElement_None, PseudoClass_Minimized);
- int width = subRule.size().width();
- if (width != -1)
- return width;
- break;
- }
- default:
- break;
- }
-
- return baseStyle()->pixelMetric(m, opt, w);
-}
-
-QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
- const QSize &csz, const QWidget *w) const
-{
- RECURSION_GUARD(return baseStyle()->sizeFromContents(ct, opt, csz, w))
-
- QRenderRule rule = renderRule(w, opt);
- QSize sz = rule.adjustSize(csz);
-
- switch (ct) {
- case CT_SpinBox: // ### hopelessly broken QAbstractSpinBox (part 1)
- if (rule.hasBox() || !rule.hasNativeBorder())
- return csz;
- return rule.baseStyleCanDraw() ? baseStyle()->sizeFromContents(ct, opt, sz, w)
- : QWindowsStyle::sizeFromContents(ct, opt, sz, w);
- case CT_ToolButton:
- if (rule.hasBox() || !rule.hasNativeBorder() || !rule.baseStyleCanDraw())
- sz += QSize(3, 3); // ### broken QToolButton
- //fall thought
- case CT_ComboBox:
- case CT_PushButton:
- if (rule.hasBox() || !rule.hasNativeBorder()) {
- if(ct == CT_ComboBox) {
- //add some space for the drop down.
- QRenderRule subRule = renderRule(w, opt, PseudoElement_ComboBoxDropDown);
- QRect comboRect = positionRect(w, rule, subRule, PseudoElement_ComboBoxDropDown, opt->rect, opt->direction);
- //+2 because there is hardcoded margins in QCommonStyle::drawControl(CE_ComboBoxLabel)
- sz += QSize(comboRect.width() + 2, 0);
- }
- return rule.boxSize(sz);
- }
- sz = rule.baseStyleCanDraw() ? baseStyle()->sizeFromContents(ct, opt, sz, w)
- : QWindowsStyle::sizeFromContents(ct, opt, sz, w);
- return rule.boxSize(sz, Margin);
-
- case CT_HeaderSection: {
- if (const QStyleOptionHeader *hdr = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewSection);
- if (subRule.hasGeometry() || subRule.hasBox() || !subRule.hasNativeBorder()) {
- sz = subRule.adjustSize(csz);
- if (!subRule.hasGeometry()) {
- QSize nativeContentsSize;
- bool nullIcon = hdr->icon.isNull();
- int iconSize = nullIcon ? 0 : pixelMetric(QStyle::PM_SmallIconSize, hdr, w);
- QSize txt = hdr->fontMetrics.size(0, hdr->text);
- nativeContentsSize.setHeight(qMax(iconSize, txt.height()));
- nativeContentsSize.setWidth(iconSize + txt.width());
- sz = sz.expandedTo(nativeContentsSize);
- }
- return subRule.size(sz);
- }
- return subRule.baseStyleCanDraw() ? baseStyle()->sizeFromContents(ct, opt, sz, w)
- : QWindowsStyle::sizeFromContents(ct, opt, sz, w);
- }
- }
- break;
- case CT_GroupBox:
- case CT_LineEdit:
-#ifndef QT_NO_SPINBOX
- // ### hopelessly broken QAbstractSpinBox (part 2)
- if (QAbstractSpinBox *spinBox = qobject_cast<QAbstractSpinBox *>(w ? w->parentWidget() : 0)) {
- QRenderRule rule = renderRule(spinBox, opt);
- if (rule.hasBox() || !rule.hasNativeBorder())
- return csz;
- return rule.baseStyleCanDraw() ? baseStyle()->sizeFromContents(ct, opt, sz, w)
- : QWindowsStyle::sizeFromContents(ct, opt, sz, w);
- }
-#endif
- if (rule.hasBox() || !rule.hasNativeBorder()) {
- return rule.boxSize(sz);
- }
- break;
-
- case CT_CheckBox:
- case CT_RadioButton:
- if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
- if (rule.hasBox() || rule.hasBorder() || hasStyleRule(w, PseudoElement_Indicator)) {
- bool isRadio = (ct == CT_RadioButton);
- int iw = pixelMetric(isRadio ? PM_ExclusiveIndicatorWidth
- : PM_IndicatorWidth, btn, w);
- int ih = pixelMetric(isRadio ? PM_ExclusiveIndicatorHeight
- : PM_IndicatorHeight, btn, w);
-
- int spacing = pixelMetric(isRadio ? PM_RadioButtonLabelSpacing
- : PM_CheckBoxLabelSpacing, btn, w);
- sz.setWidth(sz.width() + iw + spacing);
- sz.setHeight(qMax(sz.height(), ih));
- return rule.boxSize(sz);
- }
- }
- break;
-
- case CT_Menu:
- case CT_MenuBar: // already has everything!
- case CT_ScrollBar:
- if (rule.hasBox() || rule.hasBorder())
- return sz;
- break;
-
- case CT_MenuItem:
- if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
- PseudoElement pe = (mi->menuItemType == QStyleOptionMenuItem::Separator)
- ? PseudoElement_MenuSeparator : PseudoElement_Item;
- QRenderRule subRule = renderRule(w, opt, pe);
- if ((pe == PseudoElement_MenuSeparator) && subRule.hasContentsSize()) {
- return QSize(sz.width(), subRule.size().height());
- } else if ((pe == PseudoElement_Item) && (subRule.hasBox() || subRule.hasBorder())) {
- int width = csz.width();
- if (mi->text.contains(QLatin1Char('\t')))
- width += 12; //as in QCommonStyle
- return subRule.boxSize(subRule.adjustSize(QSize(width, csz.height())));
- }
- }
- break;
-
- case CT_Splitter:
- case CT_MenuBarItem: {
- PseudoElement pe = (ct == CT_Splitter) ? PseudoElement_SplitterHandle : PseudoElement_Item;
- QRenderRule subRule = renderRule(w, opt, pe);
- if (subRule.hasBox() || subRule.hasBorder())
- return subRule.boxSize(sz);
- break;
- }
-
- case CT_ProgressBar:
- case CT_SizeGrip:
- return (rule.hasContentsSize())
- ? rule.size(sz)
- : rule.boxSize(baseStyle()->sizeFromContents(ct, opt, sz, w));
- break;
-
- case CT_Slider:
- if (rule.hasBorder() || rule.hasBox() || rule.hasGeometry())
- return rule.boxSize(sz);
- break;
-
-#ifndef QT_NO_TABBAR
- case CT_TabBarTab: {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTab);
- if (subRule.hasBox() || !subRule.hasNativeBorder()) {
- int spaceForIcon = 0;
- bool vertical = false;
- if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
- if (!tab->icon.isNull())
- spaceForIcon = 6 /* icon offset */ + 4 /* spacing */ + 2 /* magic */; // ###: hardcoded to match with common style
- vertical = verticalTabs(tab->shape);
- }
- sz = csz + QSize(vertical ? 0 : spaceForIcon, vertical ? spaceForIcon : 0);
- return subRule.boxSize(subRule.adjustSize(sz));
- }
-#ifdef Q_WS_MAC
- if (baseStyle()->inherits("QMacStyle")) {
- //adjust the size after the call to the style because the mac style ignore the size arguments anyway.
- //this might cause the (max-){width,height} property to include the native style border while they should not.
- return subRule.adjustSize(baseStyle()->sizeFromContents(ct, opt, csz, w));
- }
-#endif
- sz = subRule.adjustSize(csz);
- break;
- }
-#endif // QT_NO_TABBAR
-
- case CT_MdiControls:
- if (const QStyleOptionComplex *ccOpt = qstyleoption_cast<const QStyleOptionComplex *>(opt)) {
- if (!hasStyleRule(w, PseudoElement_MdiCloseButton)
- && !hasStyleRule(w, PseudoElement_MdiNormalButton)
- && !hasStyleRule(w, PseudoElement_MdiMinButton))
- break;
-
- QList<QVariant> layout = rule.styleHint(QLatin1String("button-layout")).toList();
- if (layout.isEmpty())
- layout = subControlLayout(QLatin1String("mNX"));
-
- int width = 0, height = 0;
- for (int i = 0; i < layout.count(); i++) {
- int layoutButton = layout[i].toInt();
- if (layoutButton < PseudoElement_MdiCloseButton
- || layoutButton > PseudoElement_MdiNormalButton)
- continue;
- QStyle::SubControl sc = knownPseudoElements[layoutButton].subControl;
- if (!(ccOpt->subControls & sc))
- continue;
- QRenderRule subRule = renderRule(w, opt, layoutButton);
- QSize sz = subRule.size();
- width += sz.width();
- height = qMax(height, sz.height());
- }
-
- return QSize(width, height);
- }
- break;
-
-#ifndef QT_NO_ITEMVIEWS
- case CT_ItemViewItem: {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_ViewItem);
- sz = baseStyle()->sizeFromContents(ct, opt, csz, w);
- sz = subRule.adjustSize(sz);
- if (subRule.hasBox() || subRule.hasBorder())
- sz = subRule.boxSize(sz);
- return sz;
- }
-#endif // QT_NO_ITEMVIEWS
-
- default:
- break;
- }
-
- return baseStyle()->sizeFromContents(ct, opt, sz, w);
-}
-
-/*!
- \internal
-*/
-static QLatin1String propertyNameForStandardPixmap(QStyle::StandardPixmap sp)
-{
- switch (sp) {
- case QStyle::SP_TitleBarMenuButton: return QLatin1String("titlebar-menu-icon");
- case QStyle::SP_TitleBarMinButton: return QLatin1String("titlebar-minimize-icon");
- case QStyle::SP_TitleBarMaxButton: return QLatin1String("titlebar-maximize-icon");
- case QStyle::SP_TitleBarCloseButton: return QLatin1String("titlebar-close-icon");
- case QStyle::SP_TitleBarNormalButton: return QLatin1String("titlebar-normal-icon");
- case QStyle::SP_TitleBarShadeButton: return QLatin1String("titlebar-shade-icon");
- case QStyle::SP_TitleBarUnshadeButton: return QLatin1String("titlebar-unshade-icon");
- case QStyle::SP_TitleBarContextHelpButton: return QLatin1String("titlebar-contexthelp-icon");
- case QStyle::SP_DockWidgetCloseButton: return QLatin1String("dockwidget-close-icon");
- case QStyle::SP_MessageBoxInformation: return QLatin1String("messagebox-information-icon");
- case QStyle::SP_MessageBoxWarning: return QLatin1String("messagebox-warning-icon");
- case QStyle::SP_MessageBoxCritical: return QLatin1String("messagebox-critical-icon");
- case QStyle::SP_MessageBoxQuestion: return QLatin1String("messagebox-question-icon");
- case QStyle::SP_DesktopIcon: return QLatin1String("desktop-icon");
- case QStyle::SP_TrashIcon: return QLatin1String("trash-icon");
- case QStyle::SP_ComputerIcon: return QLatin1String("computer-icon");
- case QStyle::SP_DriveFDIcon: return QLatin1String("floppy-icon");
- case QStyle::SP_DriveHDIcon: return QLatin1String("harddisk-icon");
- case QStyle::SP_DriveCDIcon: return QLatin1String("cd-icon");
- case QStyle::SP_DriveDVDIcon: return QLatin1String("dvd-icon");
- case QStyle::SP_DriveNetIcon: return QLatin1String("network-icon");
- case QStyle::SP_DirOpenIcon: return QLatin1String("directory-open-icon");
- case QStyle::SP_DirClosedIcon: return QLatin1String("directory-closed-icon");
- case QStyle::SP_DirLinkIcon: return QLatin1String("directory-link-icon");
- case QStyle::SP_FileIcon: return QLatin1String("file-icon");
- case QStyle::SP_FileLinkIcon: return QLatin1String("file-link-icon");
- case QStyle::SP_FileDialogStart: return QLatin1String("filedialog-start-icon");
- case QStyle::SP_FileDialogEnd: return QLatin1String("filedialog-end-icon");
- case QStyle::SP_FileDialogToParent: return QLatin1String("filedialog-parent-directory-icon");
- case QStyle::SP_FileDialogNewFolder: return QLatin1String("filedialog-new-directory-icon");
- case QStyle::SP_FileDialogDetailedView: return QLatin1String("filedialog-detailedview-icon");
- case QStyle::SP_FileDialogInfoView: return QLatin1String("filedialog-infoview-icon");
- case QStyle::SP_FileDialogContentsView: return QLatin1String("filedialog-contentsview-icon");
- case QStyle::SP_FileDialogListView: return QLatin1String("filedialog-listview-icon");
- case QStyle::SP_FileDialogBack: return QLatin1String("filedialog-backward-icon");
- case QStyle::SP_DirIcon: return QLatin1String("directory-icon");
- case QStyle::SP_DialogOkButton: return QLatin1String("dialog-ok-icon");
- case QStyle::SP_DialogCancelButton: return QLatin1String("dialog-cancel-icon");
- case QStyle::SP_DialogHelpButton: return QLatin1String("dialog-help-icon");
- case QStyle::SP_DialogOpenButton: return QLatin1String("dialog-open-icon");
- case QStyle::SP_DialogSaveButton: return QLatin1String("dialog-save-icon");
- case QStyle::SP_DialogCloseButton: return QLatin1String("dialog-close-icon");
- case QStyle::SP_DialogApplyButton: return QLatin1String("dialog-apply-icon");
- case QStyle::SP_DialogResetButton: return QLatin1String("dialog-reset-icon");
- case QStyle::SP_DialogDiscardButton: return QLatin1String("discard-icon");
- case QStyle::SP_DialogYesButton: return QLatin1String("dialog-yes-icon");
- case QStyle::SP_DialogNoButton: return QLatin1String("dialog-no-icon");
- case QStyle::SP_ArrowUp: return QLatin1String("uparrow-icon");
- case QStyle::SP_ArrowDown: return QLatin1String("downarrow-icon");
- case QStyle::SP_ArrowLeft: return QLatin1String("leftarrow-icon");
- case QStyle::SP_ArrowRight: return QLatin1String("rightarrow-icon");
- case QStyle::SP_ArrowBack: return QLatin1String("backward-icon");
- case QStyle::SP_ArrowForward: return QLatin1String("forward-icon");
- case QStyle::SP_DirHomeIcon: return QLatin1String("home-icon");
- default: return QLatin1String("");
- }
-}
-
-QIcon QStyleSheetStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt,
- const QWidget *w) const
-{
- RECURSION_GUARD(return baseStyle()->standardIcon(standardIcon, opt, w))
- QString s = propertyNameForStandardPixmap(standardIcon);
- if (!s.isEmpty()) {
- QRenderRule rule = renderRule(w, opt);
- if (rule.hasStyleHint(s))
- return qvariant_cast<QIcon>(rule.styleHint(s));
- }
- return baseStyle()->standardIcon(standardIcon, opt, w);
-}
-
-QPalette QStyleSheetStyle::standardPalette() const
-{
- return baseStyle()->standardPalette();
-}
-
-QPixmap QStyleSheetStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
- const QWidget *w) const
-{
- RECURSION_GUARD(return baseStyle()->standardPixmap(standardPixmap, opt, w))
- QString s = propertyNameForStandardPixmap(standardPixmap);
- if (!s.isEmpty()) {
- QRenderRule rule = renderRule(w, opt);
- if (rule.hasStyleHint(s)) {
- QIcon icon = qvariant_cast<QIcon>(rule.styleHint(s));
- return icon.pixmap(16, 16); // ###: unhard-code this if someone complains
- }
- }
- return baseStyle()->standardPixmap(standardPixmap, opt, w);
-}
-
-int QStyleSheetStyle::layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2,
- Qt::Orientation orientation, const QStyleOption *option,
- const QWidget *widget) const
-{
- return baseStyle()->layoutSpacing(control1, control2, orientation, option, widget);
-}
-
-int QStyleSheetStyle::layoutSpacingImplementation(QSizePolicy::ControlType control1 ,
- QSizePolicy::ControlType control2,
- Qt::Orientation orientation,
- const QStyleOption * option ,
- const QWidget * widget) const
-{
- return baseStyle()->layoutSpacing(control1, control2, orientation, option, widget);
-}
-
-int QStyleSheetStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w,
- QStyleHintReturn *shret) const
-{
- RECURSION_GUARD(return baseStyle()->styleHint(sh, opt, w, shret))
- // Prevent endless loop if somebody use isActiveWindow property as selector.
- // QWidget::isActiveWindow uses this styleHint to determine if the window is active or not
- if (sh == SH_Widget_ShareActivation)
- return baseStyle()->styleHint(sh, opt, w, shret);
-
- QRenderRule rule = renderRule(w, opt);
- QString s;
- switch (sh) {
- case SH_LineEdit_PasswordCharacter: s = QLatin1String("lineedit-password-character"); break;
- case SH_DitherDisabledText: s = QLatin1String("dither-disabled-text"); break;
- case SH_EtchDisabledText: s = QLatin1String("etch-disabled-text"); break;
- case SH_ItemView_ActivateItemOnSingleClick: s = QLatin1String("activate-on-singleclick"); break;
- case SH_ItemView_ShowDecorationSelected: s = QLatin1String("show-decoration-selected"); break;
- case SH_Table_GridLineColor: s = QLatin1String("gridline-color"); break;
- case SH_DialogButtonLayout: s = QLatin1String("button-layout"); break;
- case SH_ToolTipLabel_Opacity: s = QLatin1String("opacity"); break;
- case SH_ComboBox_Popup: s = QLatin1String("combobox-popup"); break;
- case SH_ComboBox_ListMouseTracking: s = QLatin1String("combobox-list-mousetracking"); break;
- case SH_MenuBar_AltKeyNavigation: s = QLatin1String("menubar-altkey-navigation"); break;
- case SH_Menu_Scrollable: s = QLatin1String("menu-scrollable"); break;
- case SH_DrawMenuBarSeparator: s = QLatin1String("menubar-separator"); break;
- case SH_MenuBar_MouseTracking: s = QLatin1String("mouse-tracking"); break;
- case SH_SpinBox_ClickAutoRepeatRate: s = QLatin1String("spinbox-click-autorepeat-rate"); break;
- case SH_SpinControls_DisableOnBounds: s = QLatin1String("spincontrol-disable-on-bounds"); break;
- case SH_MessageBox_TextInteractionFlags: s = QLatin1String("messagebox-text-interaction-flags"); break;
- case SH_ToolButton_PopupDelay: s = QLatin1String("toolbutton-popup-delay"); break;
- case SH_ToolBox_SelectedPageTitleBold:
- if (renderRule(w, opt, PseudoElement_ToolBoxTab).hasFont)
- return 0;
- break;
- case SH_GroupBox_TextLabelColor:
- if (rule.hasPalette() && rule.palette()->foreground.style() != Qt::NoBrush)
- return rule.palette()->foreground.color().rgba();
- break;
- case SH_ScrollView_FrameOnlyAroundContents: s = QLatin1String("scrollview-frame-around-contents"); break;
- case SH_ScrollBar_ContextMenu: s = QLatin1String("scrollbar-contextmenu"); break;
- case SH_ScrollBar_LeftClickAbsolutePosition: s = QLatin1String("scrollbar-leftclick-absolute-position"); break;
- case SH_ScrollBar_MiddleClickAbsolutePosition: s = QLatin1String("scrollbar-middleclick-absolute-position"); break;
- case SH_ScrollBar_RollBetweenButtons: s = QLatin1String("scrollbar-roll-between-buttons"); break;
- case SH_ScrollBar_ScrollWhenPointerLeavesControl: s = QLatin1String("scrollbar-scroll-when-pointer-leaves-control"); break;
- case SH_TabBar_Alignment:
-#ifndef QT_NO_TABWIDGET
- if (qobject_cast<const QTabWidget *>(w)) {
- rule = renderRule(w, opt, PseudoElement_TabWidgetTabBar);
- if (rule.hasPosition())
- return rule.position()->position;
- }
-#endif // QT_NO_TABWIDGET
- s = QLatin1String("alignment");
- break;
-#ifndef QT_NO_TABBAR
- case SH_TabBar_CloseButtonPosition:
- rule = renderRule(w, opt, PseudoElement_TabBarTabCloseButton);
- if (rule.hasPosition()) {
- Qt::Alignment align = rule.position()->position;
- if (align & Qt::AlignLeft || align & Qt::AlignTop)
- return QTabBar::LeftSide;
- if (align & Qt::AlignRight || align & Qt::AlignBottom)
- return QTabBar::RightSide;
- }
- break;
-#endif
- case SH_TabBar_ElideMode: s = QLatin1String("tabbar-elide-mode"); break;
- case SH_TabBar_PreferNoArrows: s = QLatin1String("tabbar-prefer-no-arrows"); break;
- case SH_ComboBox_PopupFrameStyle:
-#ifndef QT_NO_COMBOBOX
- if (qobject_cast<const QComboBox *>(w)) {
- QAbstractItemView *view = w->findChild<QAbstractItemView *>();
- if (view) {
- view->ensurePolished();
- QRenderRule subRule = renderRule(view, PseudoElement_None);
- if (subRule.hasBox() || !subRule.hasNativeBorder())
- return QFrame::NoFrame;
- }
- }
-#endif // QT_NO_COMBOBOX
- break;
- case SH_DialogButtonBox_ButtonsHaveIcons: s = QLatin1String("dialogbuttonbox-buttons-have-icons"); break;
- case SH_Workspace_FillSpaceOnMaximize: s = QLatin1String("mdi-fill-space-on-maximize"); break;
- case SH_TitleBar_NoBorder:
- if (rule.hasBorder())
- return !rule.border()->borders[LeftEdge];
- break;
- case SH_TitleBar_AutoRaise: { // plain absurd
- QRenderRule subRule = renderRule(w, opt, PseudoElement_TitleBar);
- if (subRule.hasDrawable())
- return 1;
- break;
- }
- case SH_ItemView_ArrowKeysNavigateIntoChildren: s = QLatin1String("arrow-keys-navigate-into-children"); break;
- case SH_ItemView_PaintAlternatingRowColorsForEmptyArea: s = QLatin1String("paint-alternating-row-colors-for-empty-area"); break;
- default: break;
- }
- if (!s.isEmpty() && rule.hasStyleHint(s)) {
- return rule.styleHint(s).toInt();
- }
-
- return baseStyle()->styleHint(sh, opt, w, shret);
-}
-
-QRect QStyleSheetStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc,
- const QWidget *w) const
-{
- RECURSION_GUARD(return baseStyle()->subControlRect(cc, opt, sc, w))
-
- QRenderRule rule = renderRule(w, opt);
- switch (cc) {
- case CC_ComboBox:
- if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
- if (rule.hasBox() || !rule.hasNativeBorder()) {
- switch (sc) {
- case SC_ComboBoxFrame: return rule.borderRect(opt->rect);
- case SC_ComboBoxEditField:
- {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_ComboBoxDropDown);
- QRect r = rule.contentsRect(opt->rect);
- QRect r2 = positionRect(w, rule, subRule, PseudoElement_ComboBoxDropDown,
- opt->rect, opt->direction);
- if (subRule.hasPosition() && subRule.position()->position & Qt::AlignLeft) {
- return visualRect(opt->direction, r, r.adjusted(r2.width(),0,0,0));
- } else {
- return visualRect(opt->direction, r, r.adjusted(0,0,-r2.width(),0));
- }
- }
- case SC_ComboBoxArrow: {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_ComboBoxDropDown);
- return positionRect(w, rule, subRule, PseudoElement_ComboBoxDropDown, opt->rect, opt->direction);
- }
- case SC_ComboBoxListBoxPopup:
- default:
- return baseStyle()->subControlRect(cc, opt, sc, w);
- }
- }
-
- QStyleOptionComboBox comboBox(*cb);
- comboBox.rect = rule.borderRect(opt->rect);
- return rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, &comboBox, sc, w)
- : QWindowsStyle::subControlRect(cc, &comboBox, sc, w);
- }
- break;
-
-#ifndef QT_NO_SPINBOX
- case CC_SpinBox:
- if (const QStyleOptionSpinBox *spin = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
- QRenderRule upRule = renderRule(w, opt, PseudoElement_SpinBoxUpButton);
- QRenderRule downRule = renderRule(w, opt, PseudoElement_SpinBoxDownButton);
- bool ruleMatch = rule.hasBox() || !rule.hasNativeBorder();
- bool upRuleMatch = upRule.hasGeometry() || upRule.hasPosition();
- bool downRuleMatch = downRule.hasGeometry() || upRule.hasPosition();
- if (ruleMatch || upRuleMatch || downRuleMatch) {
- switch (sc) {
- case SC_SpinBoxFrame:
- return rule.borderRect(opt->rect);
- case SC_SpinBoxEditField:
- {
- QRect r = rule.contentsRect(opt->rect);
- // Use the widest button on each side to determine edit field size.
- Qt::Alignment upAlign, downAlign;
-
- upAlign = upRule.hasPosition() ? upRule.position()->position
- : Qt::Alignment(Qt::AlignRight);
- upAlign = resolveAlignment(opt->direction, upAlign);
-
- downAlign = downRule.hasPosition() ? downRule.position()->position
- : Qt::Alignment(Qt::AlignRight);
- downAlign = resolveAlignment(opt->direction, downAlign);
-
- int upSize = subControlRect(CC_SpinBox, opt, SC_SpinBoxUp, w).width();
- int downSize = subControlRect(CC_SpinBox, opt, SC_SpinBoxDown, w).width();
- int widestL = qMax((upAlign & Qt::AlignLeft) ? upSize : 0,
- (downAlign & Qt::AlignLeft) ? downSize : 0);
- int widestR = qMax((upAlign & Qt::AlignRight) ? upSize : 0,
- (downAlign & Qt::AlignRight) ? downSize : 0);
- r.setRight(r.right() - widestR);
- r.setLeft(r.left() + widestL);
- return r;
- }
- case SC_SpinBoxDown:
- if (downRuleMatch)
- return positionRect(w, rule, downRule, PseudoElement_SpinBoxDownButton,
- opt->rect, opt->direction);
- break;
- case SC_SpinBoxUp:
- if (upRuleMatch)
- return positionRect(w, rule, upRule, PseudoElement_SpinBoxUpButton,
- opt->rect, opt->direction);
- break;
- default:
- break;
- }
-
- return baseStyle()->subControlRect(cc, opt, sc, w);
- }
-
- QStyleOptionSpinBox spinBox(*spin);
- spinBox.rect = rule.borderRect(opt->rect);
- return rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, &spinBox, sc, w)
- : QWindowsStyle::subControlRect(cc, &spinBox, sc, w);
- }
- break;
-#endif // QT_NO_SPINBOX
-
- case CC_GroupBox:
- if (const QStyleOptionGroupBox *gb = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
- switch (sc) {
- case SC_GroupBoxFrame:
- case SC_GroupBoxContents: {
- if (rule.hasBox() || !rule.hasNativeBorder()) {
- return sc == SC_GroupBoxFrame ? rule.borderRect(opt->rect)
- : rule.contentsRect(opt->rect);
- }
- QStyleOptionGroupBox groupBox(*gb);
- groupBox.rect = rule.borderRect(opt->rect);
- return baseStyle()->subControlRect(cc, &groupBox, sc, w);
- }
- default:
- case SC_GroupBoxLabel:
- case SC_GroupBoxCheckBox: {
- QRenderRule indRule = renderRule(w, opt, PseudoElement_GroupBoxIndicator);
- QRenderRule labelRule = renderRule(w, opt, PseudoElement_GroupBoxTitle);
- if (!labelRule.hasPosition() && !labelRule.hasGeometry() && !labelRule.hasBox()
- && !labelRule.hasBorder() && !indRule.hasContentsSize()) {
- QStyleOptionGroupBox groupBox(*gb);
- groupBox.rect = rule.borderRect(opt->rect);
- return baseStyle()->subControlRect(cc, &groupBox, sc, w);
- }
- int tw = opt->fontMetrics.width(gb->text);
- int th = opt->fontMetrics.height();
- int spacing = pixelMetric(QStyle::PM_CheckBoxLabelSpacing, opt, w);
- int iw = pixelMetric(QStyle::PM_IndicatorWidth, opt, w);
- int ih = pixelMetric(QStyle::PM_IndicatorHeight, opt, w);
-
- if (gb->subControls & QStyle::SC_GroupBoxCheckBox) {
- tw = tw + iw + spacing;
- th = qMax(th, ih);
- }
- if (!labelRule.hasGeometry()) {
- labelRule.geo = new QStyleSheetGeometryData(tw, th, tw, th, -1, -1);
- } else {
- labelRule.geo->width = tw;
- labelRule.geo->height = th;
- }
- if (!labelRule.hasPosition()) {
- labelRule.p = new QStyleSheetPositionData(0, 0, 0, 0, defaultOrigin(PseudoElement_GroupBoxTitle),
- gb->textAlignment, PositionMode_Static);
- }
- QRect r = positionRect(w, rule, labelRule, PseudoElement_GroupBoxTitle,
- opt->rect, opt->direction);
- if (gb->subControls & SC_GroupBoxCheckBox) {
- r = labelRule.contentsRect(r);
- if (sc == SC_GroupBoxLabel) {
- r.setLeft(r.left() + iw + spacing);
- r.setTop(r.center().y() - th/2);
- } else {
- r = QRect(r.left(), r.center().y() - ih/2, iw, ih);
- }
- return r;
- } else {
- return labelRule.contentsRect(r);
- }
- }
- } // switch
- }
- break;
-
- case CC_ToolButton:
- if (const QStyleOptionToolButton *tb = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
- if (rule.hasBox() || !rule.hasNativeBorder()) {
- switch (sc) {
- case SC_ToolButton: return rule.borderRect(opt->rect);
- case SC_ToolButtonMenu: {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_ToolButtonMenu);
- return positionRect(w, rule, subRule, PseudoElement_ToolButtonMenu, opt->rect, opt->direction);
- }
- default:
- break;
- }
- }
-
- QStyleOptionToolButton tool(*tb);
- tool.rect = rule.borderRect(opt->rect);
- return rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, &tool, sc, w)
- : QWindowsStyle::subControlRect(cc, &tool, sc, w);
- }
- break;
-
-#ifndef QT_NO_SCROLLBAR
- case CC_ScrollBar:
- if (const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
- QStyleOptionSlider styleOptionSlider(*sb);
- styleOptionSlider.rect = rule.borderRect(opt->rect);
- if (rule.hasDrawable() || rule.hasBox()) {
- QRect grooveRect;
- if (!rule.hasBox()) {
- grooveRect = rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, sb, SC_ScrollBarGroove, w)
- : QWindowsStyle::subControlRect(cc, sb, SC_ScrollBarGroove, w);
- } else {
- grooveRect = rule.contentsRect(opt->rect);
- }
-
- PseudoElement pe = PseudoElement_None;
-
- switch (sc) {
- case SC_ScrollBarGroove:
- return grooveRect;
- case SC_ScrollBarAddPage:
- case SC_ScrollBarSubPage:
- case SC_ScrollBarSlider: {
- QRect contentRect = grooveRect;
- if (hasStyleRule(w, PseudoElement_ScrollBarSlider)) {
- QRenderRule sliderRule = renderRule(w, opt, PseudoElement_ScrollBarSlider);
- Origin origin = sliderRule.hasPosition() ? sliderRule.position()->origin : defaultOrigin(PseudoElement_ScrollBarSlider);
- contentRect = rule.originRect(opt->rect, origin);
- }
- int maxlen = (styleOptionSlider.orientation == Qt::Horizontal) ? contentRect.width() : contentRect.height();
- int sliderlen;
- if (sb->maximum != sb->minimum) {
- uint range = sb->maximum - sb->minimum;
- sliderlen = (qint64(sb->pageStep) * maxlen) / (range + sb->pageStep);
-
- int slidermin = pixelMetric(PM_ScrollBarSliderMin, sb, w);
- if (sliderlen < slidermin || range > INT_MAX / 2)
- sliderlen = slidermin;
- if (sliderlen > maxlen)
- sliderlen = maxlen;
- } else {
- sliderlen = maxlen;
- }
-
- int sliderstart = (styleOptionSlider.orientation == Qt::Horizontal ? contentRect.left() : contentRect.top())
- + sliderPositionFromValue(sb->minimum, sb->maximum, sb->sliderPosition,
- maxlen - sliderlen, sb->upsideDown);
-
- QRect sr = (sb->orientation == Qt::Horizontal)
- ? QRect(sliderstart, contentRect.top(), sliderlen, contentRect.height())
- : QRect(contentRect.left(), sliderstart, contentRect.width(), sliderlen);
- if (sc == SC_ScrollBarSlider) {
- return sr;
- } else if (sc == SC_ScrollBarSubPage) {
- return QRect(contentRect.topLeft(), sb->orientation == Qt::Horizontal ? sr.bottomLeft() : sr.topRight());
- } else { // SC_ScrollBarAddPage
- return QRect(sb->orientation == Qt::Horizontal ? sr.topRight() : sr.bottomLeft(), contentRect.bottomRight());
- }
- break;
- }
- case SC_ScrollBarAddLine: pe = PseudoElement_ScrollBarAddLine; break;
- case SC_ScrollBarSubLine: pe = PseudoElement_ScrollBarSubLine; break;
- case SC_ScrollBarFirst: pe = PseudoElement_ScrollBarFirst; break;
- case SC_ScrollBarLast: pe = PseudoElement_ScrollBarLast; break;
- default: break;
- }
- if (hasStyleRule(w,pe)) {
- QRenderRule subRule = renderRule(w, opt, pe);
- if (subRule.hasPosition() || subRule.hasGeometry() || subRule.hasBox()) {
- const QStyleSheetPositionData *pos = subRule.position();
- QRect originRect = grooveRect;
- if (rule.hasBox()) {
- Origin origin = (pos && pos->origin != Origin_Unknown) ? pos->origin : defaultOrigin(pe);
- originRect = rule.originRect(opt->rect, origin);
- }
- return positionRect(w, subRule, pe, originRect, styleOptionSlider.direction);
- }
- }
- }
- return rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, &styleOptionSlider, sc, w)
- : QWindowsStyle::subControlRect(cc, &styleOptionSlider, sc, w);
- }
- break;
-#endif // QT_NO_SCROLLBAR
-
-#ifndef QT_NO_SLIDER
- case CC_Slider:
- if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_SliderGroove);
- if (!subRule.hasDrawable())
- break;
- subRule.img = 0;
- QRect gr = positionRect(w, rule, subRule, PseudoElement_SliderGroove, opt->rect, opt->direction);
- switch (sc) {
- case SC_SliderGroove:
- return gr;
- case SC_SliderHandle: {
- bool horizontal = slider->orientation & Qt::Horizontal;
- QRect cr = subRule.contentsRect(gr);
- QRenderRule subRule2 = renderRule(w, opt, PseudoElement_SliderHandle);
- int len = horizontal ? subRule2.size().width() : subRule2.size().height();
- subRule2.img = 0;
- subRule2.geo = 0;
- cr = positionRect(w, subRule2, PseudoElement_SliderHandle, cr, opt->direction);
- int thickness = horizontal ? cr.height() : cr.width();
- int sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum, slider->sliderPosition,
- (horizontal ? cr.width() : cr.height()) - len, slider->upsideDown);
- cr = horizontal ? QRect(cr.x() + sliderPos, cr.y(), len, thickness)
- : QRect(cr.x(), cr.y() + sliderPos, thickness, len);
- return subRule2.borderRect(cr);
- break; }
- case SC_SliderTickmarks:
- // TODO...
- default:
- break;
- }
- }
- break;
-#endif // QT_NO_SLIDER
-
- case CC_MdiControls:
- if (hasStyleRule(w, PseudoElement_MdiCloseButton)
- || hasStyleRule(w, PseudoElement_MdiNormalButton)
- || hasStyleRule(w, PseudoElement_MdiMinButton)) {
- QList<QVariant> layout = rule.styleHint(QLatin1String("button-layout")).toList();
- if (layout.isEmpty())
- layout = subControlLayout(QLatin1String("mNX"));
-
- int x = 0, width = 0;
- QRenderRule subRule;
- for (int i = 0; i < layout.count(); i++) {
- int layoutButton = layout[i].toInt();
- if (layoutButton < PseudoElement_MdiCloseButton
- || layoutButton > PseudoElement_MdiNormalButton)
- continue;
- QStyle::SubControl control = knownPseudoElements[layoutButton].subControl;
- if (!(opt->subControls & control))
- continue;
- subRule = renderRule(w, opt, layoutButton);
- width = subRule.size().width();
- if (sc == control)
- break;
- x += width;
- }
-
- return subRule.borderRect(QRect(x, opt->rect.top(), width, opt->rect.height()));
- }
- break;
-
- case CC_TitleBar:
- if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_TitleBar);
- if (!subRule.hasDrawable() && !subRule.hasBox() && !subRule.hasBorder())
- break;
- QHash<QStyle::SubControl, QRect> layoutRects = titleBarLayout(w, tb);
- return layoutRects.value(sc);
- }
- break;
-
- default:
- break;
- }
-
- return baseStyle()->subControlRect(cc, opt, sc, w);
-}
-
-QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, const QWidget *w) const
-{
- RECURSION_GUARD(return baseStyle()->subElementRect(se, opt, w))
-
- QRenderRule rule = renderRule(w, opt);
-#ifndef QT_NO_TABBAR
- int pe = PseudoElement_None;
-#endif
-
- switch (se) {
- case SE_PushButtonContents:
- case SE_PushButtonFocusRect:
- if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
- QStyleOptionButton btnOpt(*btn);
- if (rule.hasBox() || !rule.hasNativeBorder())
- return visualRect(opt->direction, opt->rect, rule.contentsRect(opt->rect));
- return rule.baseStyleCanDraw() ? baseStyle()->subElementRect(se, &btnOpt, w)
- : QWindowsStyle::subElementRect(se, &btnOpt, w);
- }
- break;
-
- case SE_LineEditContents:
- case SE_FrameContents:
- case SE_ShapedFrameContents:
- if (rule.hasBox() || !rule.hasNativeBorder()) {
- return visualRect(opt->direction, opt->rect, rule.contentsRect(opt->rect));
- }
- break;
-
- case SE_CheckBoxIndicator:
- case SE_RadioButtonIndicator:
- if (rule.hasBox() || rule.hasBorder() || hasStyleRule(w, PseudoElement_Indicator)) {
- PseudoElement pe = se == SE_CheckBoxIndicator ? PseudoElement_Indicator : PseudoElement_ExclusiveIndicator;
- QRenderRule subRule = renderRule(w, opt, pe);
- return positionRect(w, rule, subRule, pe, opt->rect, opt->direction);
- }
- break;
-
- case SE_CheckBoxContents:
- case SE_RadioButtonContents:
- if (rule.hasBox() || rule.hasBorder() || hasStyleRule(w, PseudoElement_Indicator)) {
- bool isRadio = se == SE_RadioButtonContents;
- QRect ir = subElementRect(isRadio ? SE_RadioButtonIndicator : SE_CheckBoxIndicator,
- opt, w);
- ir = visualRect(opt->direction, opt->rect, ir);
- int spacing = pixelMetric(isRadio ? PM_RadioButtonLabelSpacing : PM_CheckBoxLabelSpacing, 0, w);
- QRect cr = rule.contentsRect(opt->rect);
- ir.setRect(ir.left() + ir.width() + spacing, cr.y(),
- cr.width() - ir.width() - spacing, cr.height());
- return visualRect(opt->direction, opt->rect, ir);
- }
- break;
-
- case SE_ToolBoxTabContents:
- if (w && hasStyleRule(w->parentWidget(), PseudoElement_ToolBoxTab)) {
- QRenderRule subRule = renderRule(w->parentWidget(), opt, PseudoElement_ToolBoxTab);
- return visualRect(opt->direction, opt->rect, subRule.contentsRect(opt->rect));
- }
- break;
-
- case SE_RadioButtonFocusRect:
- case SE_RadioButtonClickRect: // focusrect | indicator
- if (rule.hasBox() || rule.hasBorder() || hasStyleRule(w, PseudoElement_Indicator)) {
- return opt->rect;
- }
- break;
-
- case SE_CheckBoxFocusRect:
- case SE_CheckBoxClickRect: // relies on indicator and contents
- return ParentStyle::subElementRect(se, opt, w);
-
-#ifndef QT_NO_ITEMVIEWS
- case SE_ViewItemCheckIndicator:
- if (!qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
- return subElementRect(SE_CheckBoxIndicator, opt, w);
- }
- // intentionally falls through
- case SE_ItemViewItemText:
- case SE_ItemViewItemDecoration:
- case SE_ItemViewItemFocusRect:
- if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_ViewItem);
- PseudoElement pe = PseudoElement_None;
- if (se == SE_ItemViewItemText || se == SE_ItemViewItemFocusRect)
- pe = PseudoElement_ViewItemText;
- else if (se == SE_ItemViewItemDecoration && vopt->features & QStyleOptionViewItemV2::HasDecoration)
- pe = PseudoElement_ViewItemIcon;
- else if (se == SE_ItemViewItemCheckIndicator && vopt->features & QStyleOptionViewItemV2::HasCheckIndicator)
- pe = PseudoElement_ViewItemIndicator;
- else
- break;
- if (subRule.hasGeometry() || subRule.hasBox() || !subRule.hasNativeBorder() || hasStyleRule(w, pe)) {
- QRenderRule subRule2 = renderRule(w, opt, pe);
- QStyleOptionViewItemV4 optCopy(*vopt);
- optCopy.rect = subRule.contentsRect(vopt->rect);
- QRect rect = ParentStyle::subElementRect(se, &optCopy, w);
- return positionRect(w, subRule2, pe, rect, opt->direction);
- }
- }
- break;
-#endif // QT_NO_ITEMVIEWS
-
- case SE_HeaderArrow: {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewUpArrow);
- if (subRule.hasPosition() || subRule.hasGeometry())
- return positionRect(w, rule, subRule, PseudoElement_HeaderViewUpArrow, opt->rect, opt->direction);
- }
- break;
-
- case SE_HeaderLabel: {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewSection);
- if (subRule.hasBox() || !subRule.hasNativeBorder())
- return subRule.contentsRect(opt->rect);
- }
- break;
-
- case SE_ProgressBarGroove:
- case SE_ProgressBarContents:
- case SE_ProgressBarLabel:
- if (const QStyleOptionProgressBarV2 *pb = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
- if (rule.hasBox() || !rule.hasNativeBorder() || rule.hasPosition() || hasStyleRule(w, PseudoElement_ProgressBarChunk)) {
- if (se == SE_ProgressBarGroove)
- return rule.borderRect(pb->rect);
- else if (se == SE_ProgressBarContents)
- return rule.contentsRect(pb->rect);
-
- QSize sz = pb->fontMetrics.size(0, pb->text);
- return QStyle::alignedRect(Qt::LeftToRight, rule.hasPosition() ? rule.position()->textAlignment : pb->textAlignment,
- sz, pb->rect);
- }
- }
- break;
-
-#ifndef QT_NO_TABBAR
- case SE_TabWidgetLeftCorner:
- pe = PseudoElement_TabWidgetLeftCorner;
- // intentionally falls through
- case SE_TabWidgetRightCorner:
- if (pe == PseudoElement_None)
- pe = PseudoElement_TabWidgetRightCorner;
- // intentionally falls through
- case SE_TabWidgetTabBar:
- if (pe == PseudoElement_None)
- pe = PseudoElement_TabWidgetTabBar;
- // intentionally falls through
- case SE_TabWidgetTabPane:
- case SE_TabWidgetTabContents:
- if (pe == PseudoElement_None)
- pe = PseudoElement_TabWidgetPane;
-
- if (hasStyleRule(w, pe)) {
- QRect r = QWindowsStyle::subElementRect(pe == PseudoElement_TabWidgetPane ? SE_TabWidgetTabPane : se, opt, w);
- QRenderRule subRule = renderRule(w, opt, pe);
- r = positionRect(w, subRule, pe, r, opt->direction);
- if (pe == PseudoElement_TabWidgetTabBar) {
- Q_ASSERT(opt);
- r = opt->rect.intersected(r);
- }
- if (se == SE_TabWidgetTabContents)
- r = subRule.contentsRect(r);
- return r;
- }
- break;
-
- case SE_TabBarTearIndicator: {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTear);
- if (subRule.hasContentsSize()) {
- QRect r;
- if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
- switch (tab->shape) {
- case QTabBar::RoundedNorth:
- case QTabBar::TriangularNorth:
- case QTabBar::RoundedSouth:
- case QTabBar::TriangularSouth:
- r.setRect(tab->rect.left(), tab->rect.top(), subRule.size().width(), opt->rect.height());
- break;
- case QTabBar::RoundedWest:
- case QTabBar::TriangularWest:
- case QTabBar::RoundedEast:
- case QTabBar::TriangularEast:
- r.setRect(tab->rect.left(), tab->rect.top(), opt->rect.width(), subRule.size().height());
- break;
- default:
- break;
- }
- r = visualRect(opt->direction, opt->rect, r);
- }
- return r;
- }
- break;
- }
- case SE_TabBarTabText:
- case SE_TabBarTabLeftButton:
- case SE_TabBarTabRightButton: {
- QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTab);
- if (subRule.hasBox() || !subRule.hasNativeBorder()) {
- return ParentStyle::subElementRect(se, opt, w);
- }
- break;
- }
-#endif // QT_NO_TABBAR
-
- case SE_DockWidgetCloseButton:
- case SE_DockWidgetFloatButton: {
- PseudoElement pe = (se == SE_DockWidgetCloseButton) ? PseudoElement_DockWidgetCloseButton : PseudoElement_DockWidgetFloatButton;
- QRenderRule subRule2 = renderRule(w, opt, pe);
- if (!subRule2.hasPosition())
- break;
- QRenderRule subRule = renderRule(w, opt, PseudoElement_DockWidgetTitle);
- return positionRect(w, subRule, subRule2, pe, opt->rect, opt->direction);
- }
-
-#ifndef QT_NO_TOOLBAR
- case SE_ToolBarHandle:
- if (hasStyleRule(w, PseudoElement_ToolBarHandle))
- return ParentStyle::subElementRect(se, opt, w);
- break;
-#endif //QT_NO_TOOLBAR
-
- default:
- break;
- }
-
- return baseStyle()->subElementRect(se, opt, w);
-}
-
-bool QStyleSheetStyle::event(QEvent *e)
-{
- return (baseStyle()->event(e) && e->isAccepted()) || ParentStyle::event(e);
-}
-
-void QStyleSheetStyle::updateStyleSheetFont(QWidget* w) const
-{
- QWidget *container = containerWidget(w);
- QRenderRule rule = renderRule(container, PseudoElement_None,
- PseudoClass_Active | PseudoClass_Enabled | extendedPseudoClass(container));
- QFont font = rule.font.resolve(w->font());
-
- if ((!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))
- && isNaturalChild(w) && qobject_cast<QWidget *>(w->parent())) {
-
- font = font.resolve(static_cast<QWidget *>(w->parent())->font());
- }
-
- if (w->data->fnt == font)
- return;
-
-#ifdef QT3_SUPPORT
- QFont old = w->data->fnt;
-#endif
- w->data->fnt = font;
-#if defined(Q_WS_X11)
- // make sure the font set on this widget is associated with the correct screen
- //w->data->fnt.x11SetScreen(w->d_func()->xinfo.screen());
-#endif
-
- QEvent e(QEvent::FontChange);
- QApplication::sendEvent(w, &e);
-#ifdef QT3_SUPPORT
- w->fontChange(old);
-#endif
-}
-
-void QStyleSheetStyle::saveWidgetFont(QWidget* w, const QFont& font) const
-{
- w->setProperty("_q_styleSheetWidgetFont", font);
-}
-
-void QStyleSheetStyle::clearWidgetFont(QWidget* w) const
-{
- w->setProperty("_q_styleSheetWidgetFont", QVariant(QVariant::Invalid));
-}
-
-// Polish palette that should be used for a particular widget, with particular states
-// (eg. :focus, :hover, ...)
-// this is called by widgets that paint themself in their paint event
-// Returns true if there is a new palette in pal.
-bool QStyleSheetStyle::styleSheetPalette(const QWidget* w, const QStyleOption* opt, QPalette* pal)
-{
- if (!w || !opt || !pal)
- return false;
-
- RECURSION_GUARD(return false)
-
- w = containerWidget(w);
-
- QRenderRule rule = renderRule(w, PseudoElement_None, pseudoClass(opt->state) | extendedPseudoClass(w));
- if (!rule.hasPalette())
- return false;
-
- rule.configurePalette(pal, QPalette::NoRole, QPalette::NoRole);
- return true;
-}
-
-Qt::Alignment QStyleSheetStyle::resolveAlignment(Qt::LayoutDirection layDir, Qt::Alignment src)
-{
- if (layDir == Qt::LeftToRight || src & Qt::AlignAbsolute)
- return src;
-
- if (src & Qt::AlignLeft) {
- src &= ~Qt::AlignLeft;
- src |= Qt::AlignRight;
- } else if (src & Qt::AlignRight) {
- src &= ~Qt::AlignRight;
- src |= Qt::AlignLeft;
- }
- src |= Qt::AlignAbsolute;
- return src;
-}
-
-// Returns whether the given QWidget has a "natural" parent, meaning that
-// the parent contains this child as part of its normal operation.
-// An example is the QTabBar inside a QTabWidget.
-// This does not mean that any QTabBar which is a child of QTabWidget will
-// match, only the one that was created by the QTabWidget initialization
-// (and hence has the correct object name).
-bool QStyleSheetStyle::isNaturalChild(const QWidget *w)
-{
- if (w->objectName().startsWith(QLatin1String("qt_")))
- return true;
-
- return false;
-}
-
-QT_END_NAMESPACE
-
-#include "moc_qstylesheetstyle_p.cpp"
-
-#endif // QT_NO_STYLE_STYLESHEET
diff --git a/src/gui/styles/qstylesheetstyle_p.h b/src/gui/styles/qstylesheetstyle_p.h
deleted file mode 100644
index 1f331b2642..0000000000
--- a/src/gui/styles/qstylesheetstyle_p.h
+++ /dev/null
@@ -1,204 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSTYLESHEETSTYLE_P_H
-#define QSTYLESHEETSTYLE_P_H
-
-#include "QtGui/qwindowsstyle.h"
-
-#ifndef QT_NO_STYLE_STYLESHEET
-
-#include "QtGui/qstyleoption.h"
-#include "QtCore/qhash.h"
-#include "QtGui/qevent.h"
-#include "QtCore/qvector.h"
-#include "QtGui/qapplication.h"
-#include "private/qcssparser_p.h"
-#include "QtGui/qbrush.h"
-
-QT_BEGIN_NAMESPACE
-
-//
-// 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.
-//
-
-class QRenderRule;
-class QAbstractScrollArea;
-class QStyleSheetStylePrivate;
-class QStyleOptionTitleBar;
-
-class Q_AUTOTEST_EXPORT QStyleSheetStyle : public QWindowsStyle
-{
- typedef QWindowsStyle ParentStyle;
-
- Q_OBJECT
-public:
- QStyleSheetStyle(QStyle *baseStyle);
- ~QStyleSheetStyle();
-
- void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
- const QWidget *w = 0) const;
- void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
- const QWidget *w = 0) const;
- void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const;
- void drawItemText(QPainter *painter, const QRect& rect, int alignment, const QPalette &pal,
- bool enabled, const QString& text, QPalette::ColorRole textRole = QPalette::NoRole) const;
- void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
- const QWidget *w = 0) const;
- QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
- const QStyleOption *option) const;
- SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
- const QPoint &pt, const QWidget *w = 0) const;
- QRect itemPixmapRect(const QRect &rect, int alignment, const QPixmap &pixmap) const;
- QRect itemTextRect(const QFontMetrics &metrics, const QRect &rect, int alignment, bool enabled,
- const QString &text) const;
- int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
- void polish(QWidget *widget);
- void polish(QApplication *app);
- void polish(QPalette &pal);
- QSize sizeFromContents(ContentsType ct, const QStyleOption *opt,
- const QSize &contentsSize, const QWidget *widget = 0) const;
- QPalette standardPalette() const;
- QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option = 0,
- const QWidget *w = 0 ) const;
- int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2,
- Qt::Orientation orientation, const QStyleOption *option = 0,
- const QWidget *widget = 0) const;
- int styleHint(StyleHint sh, const QStyleOption *opt = 0, const QWidget *w = 0,
- QStyleHintReturn *shret = 0) const;
- QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const;
- QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc,
- const QWidget *w = 0) const;
-
- // These functions are called from QApplication/QWidget. Be careful.
- QStyle *baseStyle() const;
- void repolish(QWidget *widget);
- void repolish(QApplication *app);
-
- void unpolish(QWidget *widget);
- void unpolish(QApplication *app);
-
- QStyle *base;
- void ref() { ++refcount; }
- void deref() { Q_ASSERT(refcount > 0); if (!--refcount) delete this; }
-
- void updateStyleSheetFont(QWidget* w) const;
- void saveWidgetFont(QWidget* w, const QFont& font) const;
- void clearWidgetFont(QWidget* w) const;
-
- bool styleSheetPalette(const QWidget* w, const QStyleOption* opt, QPalette* pal);
-
-protected Q_SLOTS:
- QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt = 0,
- const QWidget *widget = 0) const;
- int layoutSpacingImplementation(QSizePolicy::ControlType control1,
- QSizePolicy::ControlType control2,
- Qt::Orientation orientation,
- const QStyleOption *option = 0,
- const QWidget *widget = 0) const;
-
-protected:
- bool event(QEvent *e);
-
-private:
- int refcount;
-
- friend class QRenderRule;
- int nativeFrameWidth(const QWidget *);
- QRenderRule renderRule(const QWidget *, int, quint64 = 0) const;
- QRenderRule renderRule(const QWidget *, const QStyleOption *, int = 0) const;
- QSize defaultSize(const QWidget *, QSize, const QRect&, int) const;
- QRect positionRect(const QWidget *, const QRenderRule&, const QRenderRule&, int,
- const QRect&, Qt::LayoutDirection) const;
- QRect positionRect(const QWidget *w, const QRenderRule &rule2, int pe,
- const QRect &originRect, Qt::LayoutDirection dir) const;
-
- mutable QCss::Parser parser;
-
- void setPalette(QWidget *);
- void unsetPalette(QWidget *);
- void setProperties(QWidget *);
- void setGeometry(QWidget *);
- QVector<QCss::StyleRule> styleRules(const QWidget *w) const;
- bool hasStyleRule(const QWidget *w, int part) const;
-
- QHash<QStyle::SubControl, QRect> titleBarLayout(const QWidget *w, const QStyleOptionTitleBar *tb) const;
-
- QCss::StyleSheet getDefaultStyleSheet() const;
-
- static Qt::Alignment resolveAlignment(Qt::LayoutDirection, Qt::Alignment);
- static bool isNaturalChild(const QWidget *w);
- bool initWidget(const QWidget *w) const;
-public:
- static int numinstances;
-
-private:
- Q_DISABLE_COPY(QStyleSheetStyle)
- Q_DECLARE_PRIVATE(QStyleSheetStyle)
-};
-
-class QStyleSheetStyleCaches : public QObject
-{
- Q_OBJECT
-public Q_SLOTS:
- void widgetDestroyed(QObject *);
- void styleDestroyed(QObject *);
-public:
- QHash<const QWidget *, QVector<QCss::StyleRule> > styleRulesCache;
- QHash<const QWidget *, QHash<int, bool> > hasStyleRuleCache;
- typedef QHash<int, QHash<quint64, QRenderRule> > QRenderRules;
- QHash<const QWidget *, QRenderRules> renderRulesCache;
- QHash<const QWidget *, QPalette> customPaletteWidgets; // widgets whose palette we tampered
- QHash<const void *, QCss::StyleSheet> styleSheetCache; // parsed style sheets
- QSet<const QWidget *> autoFillDisabledWidgets;
-};
-
-
-QT_END_NAMESPACE
-#endif // QT_NO_STYLE_STYLESHEET
-#endif // QSTYLESHEETSTYLE_P_H
diff --git a/src/gui/styles/qwindowscestyle.h b/src/gui/styles/qwindowscestyle.h
deleted file mode 100644
index 3fd83bc764..0000000000
--- a/src/gui/styles/qwindowscestyle.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSCESTYLE_H
-#define QWINDOWSCESTYLE_H
-
-#include <QtGui/qwindowsstyle.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if !defined(QT_NO_STYLE_WINDOWSCE)
-
-class Q_GUI_EXPORT QWindowsCEStyle : public QWindowsStyle
-{
- Q_OBJECT
-public:
- QWindowsCEStyle();
-
- 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;
-
- virtual void drawItemText(QPainter *painter, const QRect &rect,
- int flags, const QPalette &pal, bool enabled,
- const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) 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;
-
- QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
- const QWidget *widget = 0) const;
- int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
-
- int styleHint(StyleHint hint, const QStyleOption *opt = 0, const QWidget *widget = 0,
- QStyleHintReturn *returnData = 0) const;
-
- void polish(QWidget *widget);
- void polish(QPalette &palette);
- void polish(QApplication *app);
- QPalette standardPalette() const;
-};
-
-#endif // QT_NO_STYLE_WINDOWSCE
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QWINDOWSCESTYLE_H
diff --git a/src/gui/styles/qwindowsmobilestyle.h b/src/gui/styles/qwindowsmobilestyle.h
deleted file mode 100644
index 6ac1af1c35..0000000000
--- a/src/gui/styles/qwindowsmobilestyle.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSMOBILESTYLE_H
-#define QWINDOWSMOBILESTYLE_H
-
-#include <QtGui/qwindowsstyle.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if !defined(QT_NO_STYLE_WINDOWSMOBILE)
-
-class QWindowsMobileStylePrivate;
-
-class Q_GUI_EXPORT QWindowsMobileStyle : public QWindowsStyle
-{
- Q_OBJECT
-public:
- QWindowsMobileStyle();
-
- 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;
-
- QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
- const QStyleOption *option) const;
-
- QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *option,
- const QWidget *widget) const;
-
- int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
-
- int styleHint(StyleHint hint, const QStyleOption *opt = 0, const QWidget *widget = 0,
- QStyleHintReturn *returnData = 0) const;
-
- void polish(QApplication*);
- void unpolish(QApplication*);
- void polish(QWidget *widget);
- void unpolish(QWidget *widget);
- void polish(QPalette &);
-
- QPalette standardPalette() const;
-
- bool doubleControls() const;
-
- void setDoubleControls(bool);
-
-protected:
- QWindowsMobileStyle(QWindowsMobileStylePrivate &dd);
-
-private:
- Q_DECLARE_PRIVATE(QWindowsMobileStyle)
-};
-
-#endif // QT_NO_STYLE_WINDOWSMOBILE
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif //QWINDOWSMOBILESTYLE_H
diff --git a/src/gui/styles/qwindowsstyle.h b/src/gui/styles/qwindowsstyle.h
deleted file mode 100644
index 99f64fcb05..0000000000
--- a/src/gui/styles/qwindowsstyle.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSSTYLE_H
-#define QWINDOWSSTYLE_H
-
-#include <QtGui/qcommonstyle.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if !defined(QT_NO_STYLE_WINDOWS)
-
-class QWindowsStylePrivate;
-
-class Q_GUI_EXPORT QWindowsStyle : public QCommonStyle
-{
- Q_OBJECT
-public:
- QWindowsStyle();
- ~QWindowsStyle();
-
- void polish(QApplication*);
- void unpolish(QApplication*);
-
- void polish(QWidget*);
- void unpolish(QWidget*);
-
- void polish(QPalette &);
-
- void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
- const QWidget *w = 0) const;
- void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
- const QWidget *w = 0) const;
- QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const;
- void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
- const QWidget *w = 0) const;
- QSize sizeFromContents(ContentsType ct, const QStyleOption *opt,
- const QSize &contentsSize, const QWidget *widget = 0) const;
-
- int pixelMetric(PixelMetric pm, const QStyleOption *option = 0, const QWidget *widget = 0) const;
-
- int styleHint(StyleHint hint, const QStyleOption *opt = 0, const QWidget *widget = 0,
- QStyleHintReturn *returnData = 0) const;
-
- QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
- const QWidget *widget = 0) const;
-
-protected Q_SLOTS:
- QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option,
- const QWidget *widget = 0) const;
-
-protected:
- bool eventFilter(QObject *o, QEvent *e);
- void timerEvent(QTimerEvent *event);
- QWindowsStyle(QWindowsStylePrivate &dd);
-
-private:
- Q_DISABLE_COPY(QWindowsStyle)
- Q_DECLARE_PRIVATE(QWindowsStyle)
- void *reserved;
-};
-
-#endif // QT_NO_STYLE_WINDOWS
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QWINDOWSSTYLE_H
diff --git a/src/gui/styles/qwindowsvistastyle.h b/src/gui/styles/qwindowsvistastyle.h
deleted file mode 100644
index c13dccf28b..0000000000
--- a/src/gui/styles/qwindowsvistastyle.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSVISTASTYLE_H
-#define QWINDOWSVISTASTYLE_H
-
-#include <QtGui/qwindowsxpstyle.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if !defined(QT_NO_STYLE_WINDOWSVISTA)
-
-class QWindowsVistaStylePrivate;
-class Q_GUI_EXPORT QWindowsVistaStyle : public QWindowsXPStyle
-{
- Q_OBJECT
-public:
- QWindowsVistaStyle();
-
- 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;
-
- QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
- const QWidget *widget = 0) const;
- int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
- int styleHint(StyleHint hint, const QStyleOption *opt = 0, const QWidget *widget = 0,
- QStyleHintReturn *returnData = 0) const;
-
-
- void polish(QWidget *widget);
- void unpolish(QWidget *widget);
- void polish(QPalette &pal);
- void polish(QApplication *app);
- void unpolish(QApplication *app);
- bool event(QEvent *event);
- QPalette standardPalette() const;
-
-protected Q_SLOTS:
- QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option,
- const QWidget *widget = 0) const;
-
-private:
- Q_DISABLE_COPY(QWindowsVistaStyle)
- Q_DECLARE_PRIVATE(QWindowsVistaStyle)
- friend class QStyleFactory;
-};
-#endif //QT_NO_STYLE_WINDOWSVISTA
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif //QWINDOWSVISTASTYLE_H
diff --git a/src/gui/styles/qwindowsxpstyle.h b/src/gui/styles/qwindowsxpstyle.h
deleted file mode 100644
index 08582d13a1..0000000000
--- a/src/gui/styles/qwindowsxpstyle.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSXPSTYLE_H
-#define QWINDOWSXPSTYLE_H
-
-#include <QtGui/qwindowsstyle.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if !defined(QT_NO_STYLE_WINDOWSXP)
-
-class QWindowsXPStylePrivate;
-class Q_GUI_EXPORT QWindowsXPStyle : public QWindowsStyle
-{
- Q_OBJECT
-public:
- QWindowsXPStyle();
- QWindowsXPStyle(QWindowsXPStylePrivate &dd);
- ~QWindowsXPStyle();
-
- void unpolish(QApplication*);
- void polish(QApplication*);
- void polish(QWidget*);
- void polish(QPalette&);
- void unpolish(QWidget*);
-
- void drawPrimitive(PrimitiveElement pe, const QStyleOption *option, QPainter *p,
- const QWidget *widget = 0) const;
- void drawControl(ControlElement element, const QStyleOption *option, QPainter *p,
- const QWidget *wwidget = 0) const;
- QRect subElementRect(SubElement r, const QStyleOption *option, const QWidget *widget = 0) const;
- QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *option, SubControl sc,
- const QWidget *widget = 0) const;
- void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *option, QPainter *p,
- const QWidget *widget = 0) const;
- QSize sizeFromContents(ContentsType ct, const QStyleOption *option, const QSize &contentsSize,
- const QWidget *widget = 0) const;
- int pixelMetric(PixelMetric pm, const QStyleOption *option = 0,
- const QWidget *widget = 0) const;
- int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0,
- QStyleHintReturn *returnData = 0) const;
-
- QPalette standardPalette() const;
- QPixmap standardPixmap(StandardPixmap standardIcon, const QStyleOption *option,
- const QWidget *widget = 0) const;
-
-protected Q_SLOTS:
- QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option,
- const QWidget *widget = 0) const;
-
-private:
- Q_DISABLE_COPY(QWindowsXPStyle)
- Q_DECLARE_PRIVATE(QWindowsXPStyle)
- friend class QStyleFactory;
- void *reserved;
-};
-
-#endif // QT_NO_STYLE_WINDOWSXP
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QWINDOWSXPSTYLE_H
diff --git a/src/gui/styles/styles.pri b/src/gui/styles/styles.pri
deleted file mode 100644
index b6eeec9af8..0000000000
--- a/src/gui/styles/styles.pri
+++ /dev/null
@@ -1,190 +0,0 @@
-# Qt styles module
-
-HEADERS += \
- styles/qstyle.h \
- styles/qstylefactory.h \
- styles/qstyleoption.h \
- styles/qstyleplugin.h \
- styles/qcommonstylepixmaps_p.h \
- styles/qcommonstyle.h \
- styles/qstylehelper_p.h \
- styles/qproxystyle.h \
- styles/qproxystyle_p.h \
- styles/qstylesheetstyle_p.h
-
-SOURCES += \
- styles/qstyle.cpp \
- styles/qstylefactory.cpp \
- styles/qstyleoption.cpp \
- styles/qstyleplugin.cpp \
- styles/qstylehelper.cpp \
- styles/qcommonstyle.cpp \
- styles/qproxystyle.cpp \
- styles/qstylesheetstyle.cpp \
- styles/qstylesheetstyle_default.cpp
-
-wince* {
- RESOURCES += styles/qstyle_wince.qrc
-} else:symbian {
- RESOURCES += styles/qstyle_s60.qrc
-} else {
- RESOURCES += styles/qstyle.qrc
-}
-
-contains( styles, all ) {
- styles = mac windows windowsxp windowsvista
-}
-
-x11|embedded|qpa|!macx-*:styles -= mac
-
-x11{
- QMAKE_CXXFLAGS += $$QT_CFLAGS_QGTKSTYLE
- LIBS_PRIVATE += $$QT_LIBS_QGTKSTYLE
- styles += gtk
-}
-
-contains( styles, mac ) {
- HEADERS += \
- styles/qmacstyle_mac.h \
- styles/qmacstylepixmaps_mac_p.h \
- styles/qmacstyle_mac_p.h
- OBJECTIVE_SOURCES += styles/qmacstyle_mac.mm
-
- !contains( styles, windows ) {
- message( mac requires windows )
- styles += windows
- DEFINES+= QT_STYLE_WINDOWS
- }
-} else {
- DEFINES += QT_NO_STYLE_MAC
-}
-
-contains( styles, cde ) {
- HEADERS += styles/qcdestyle.h
- SOURCES += styles/qcdestyle.cpp
-
- !contains( styles, motif ) {
- message( cde requires motif )
- styles += motif
- DEFINES+= QT_STYLE_MOTIF
- }
-} else {
- DEFINES += QT_NO_STYLE_CDE
-}
-
-contains( styles, windowsvista ) {
- HEADERS += styles/qwindowsvistastyle.h
- HEADERS += styles/qwindowsvistastyle_p.h
- SOURCES += styles/qwindowsvistastyle.cpp
- !contains( styles, windowsxp ) {
- message( windowsvista requires windowsxp )
- styles += windowsxp
- DEFINES+= QT_STYLE_WINDOWSXP
- }
-} else {
- DEFINES += QT_NO_STYLE_WINDOWSVISTA
-}
-
-contains( styles, windowsxp ) {
- HEADERS += styles/qwindowsxpstyle.h
- SOURCES += styles/qwindowsxpstyle.cpp
- !contains( styles, windows ) {
- message( windowsxp requires windows )
- styles += windows
- DEFINES+= QT_STYLE_WINDOWS
- }
-} else {
- DEFINES += QT_NO_STYLE_WINDOWSXP
-}
-
-contains( styles, plastique ) {
- HEADERS += styles/qplastiquestyle.h
- SOURCES += styles/qplastiquestyle.cpp
- !contains( styles, windows ) {
- message( plastique requires windows )
- styles += windows
- DEFINES+= QT_STYLE_WINDOWS
- }
-} else {
- DEFINES += QT_NO_STYLE_PLASTIQUE
-}
-
-contains( styles, gtk ) {
- HEADERS += styles/qgtkstyle.h
- HEADERS += styles/qgtkpainter_p.h
- HEADERS += styles/qgtkstyle_p.h
- SOURCES += styles/qgtkstyle.cpp
- SOURCES += styles/qgtkpainter.cpp
- SOURCES += styles/qgtkstyle_p.cpp
- !contains( styles, cleanlooks ) {
- styles += cleanlooks
- DEFINES+= QT_STYLE_CLEANLOOKS
- }
-} else {
- DEFINES += QT_NO_STYLE_GTK
-}
-
-contains( styles, cleanlooks ) {
- HEADERS += styles/qcleanlooksstyle.h
- HEADERS += styles/qcleanlooksstyle_p.h
- SOURCES += styles/qcleanlooksstyle.cpp
- !contains( styles, windows ) {
- styles += windows
- DEFINES+= QT_STYLE_WINDOWS
- }
-} else {
- DEFINES += QT_NO_STYLE_CLEANLOOKS
-}
-
-contains( styles, windows ) {
- HEADERS += styles/qwindowsstyle.h
- SOURCES += styles/qwindowsstyle.cpp
-} else {
- DEFINES += QT_NO_STYLE_WINDOWS
-}
-
-contains( styles, motif ) {
- HEADERS += styles/qmotifstyle.h
- SOURCES += styles/qmotifstyle.cpp
-} else {
- DEFINES += QT_NO_STYLE_MOTIF
-}
-
-contains( styles, windowsce ) {
- HEADERS += styles/qwindowscestyle.h
- SOURCES += styles/qwindowscestyle.cpp
-} else {
- DEFINES += QT_NO_STYLE_WINDOWSCE
-}
-
-contains( styles, windowsmobile ) {
- HEADERS += styles/qwindowsmobilestyle.h
- SOURCES += styles/qwindowsmobilestyle.cpp
-} else {
- DEFINES += QT_NO_STYLE_WINDOWSMOBILE
-}
-
-contains( styles, s60 ):contains(QT_CONFIG, s60) {
- HEADERS += \
- styles/qs60style.h \
- styles/qs60style_p.h
- SOURCES += styles/qs60style.cpp
- symbian {
- SOURCES += styles/qs60style_s60.cpp
- LIBS += -legul -lbmpanim
- contains(CONFIG, is_using_gnupoc) {
- LIBS += -laknicon -laknskins -laknskinsrv -lfontutils
- } else {
- LIBS += -lAknIcon -lAKNSKINS -lAKNSKINSRV -lFontUtils
- }
- } else {
- SOURCES += styles/qs60style_simulated.cpp
- RESOURCES += styles/qstyle_s60_simulated.qrc
- }
-} else {
- symbian {
- HEADERS += styles/qs60style.h
- SOURCES += styles/qs60style_stub.cpp
- }
- DEFINES += QT_NO_STYLE_S60
-}
diff --git a/src/gui/text/qabstractfontengine_qws.cpp b/src/gui/text/qabstractfontengine_qws.cpp
deleted file mode 100644
index 7cb868f655..0000000000
--- a/src/gui/text/qabstractfontengine_qws.cpp
+++ /dev/null
@@ -1,776 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qabstractfontengine_qws.h"
-#include "qabstractfontengine_p.h"
-
-#include <private/qtextengine_p.h>
-#include <private/qpaintengine_raster_p.h>
-
-#include <qmath.h>
-
-QT_BEGIN_NAMESPACE
-
-class QFontEngineInfoPrivate
-{
-public:
- inline QFontEngineInfoPrivate()
- : pixelSize(0), weight(QFont::Normal), style(QFont::StyleNormal)
- {}
-
- QString family;
- qreal pixelSize;
- int weight;
- QFont::Style style;
- QList<QFontDatabase::WritingSystem> writingSystems;
-};
-
-/*!
- \class QFontEngineInfo
- \preliminary
- \brief The QFontEngineInfo class describes a specific font provided by a font engine plugin.
- \since 4.3
- \ingroup qws
-
- \tableofcontents
-
- QFontEngineInfo is used to describe a request of a font to a font engine plugin as well as to
- describe the actual fonts a plugin provides.
-
- \sa QAbstractFontEngine, QFontEnginePlugin
-*/
-
-/*!
- Constructs a new empty QFontEngineInfo.
-*/
-QFontEngineInfo::QFontEngineInfo()
-{
- d = new QFontEngineInfoPrivate;
-}
-
-/*!
- Constructs a new QFontEngineInfo with the specified \a family.
- The resulting object represents a freely scalable font with normal
- weight and style.
-*/
-QFontEngineInfo::QFontEngineInfo(const QString &family)
-{
- d = new QFontEngineInfoPrivate;
- d->family = family;
-}
-
-/*!
- Creates a new font engine info object with the same attributes as \a other.
-*/
-QFontEngineInfo::QFontEngineInfo(const QFontEngineInfo &other)
- : d(new QFontEngineInfoPrivate(*other.d))
-{
-}
-
-/*!
- Assigns \a other to this font engine info object, and returns a reference
- to this.
-*/
-QFontEngineInfo &QFontEngineInfo::operator=(const QFontEngineInfo &other)
-{
- *d = *other.d;
- return *this;
-}
-
-/*!
- Destroys this QFontEngineInfo object.
-*/
-QFontEngineInfo::~QFontEngineInfo()
-{
- delete d;
-}
-
-/*!
- \property QFontEngineInfo::family
- the family name of the font
-*/
-
-void QFontEngineInfo::setFamily(const QString &family)
-{
- d->family = family;
-}
-
-QString QFontEngineInfo::family() const
-{
- return d->family;
-}
-
-/*!
- \property QFontEngineInfo::pixelSize
- the pixel size of the font
-
- A pixel size of 0 represents a freely scalable font.
-*/
-
-void QFontEngineInfo::setPixelSize(qreal size)
-{
- d->pixelSize = size;
-}
-
-qreal QFontEngineInfo::pixelSize() const
-{
- return d->pixelSize;
-}
-
-/*!
- \property QFontEngineInfo::weight
- the weight of the font
-
- The value should be from the \l{QFont::Weight} enumeration.
-*/
-
-void QFontEngineInfo::setWeight(int weight)
-{
- d->weight = weight;
-}
-
-int QFontEngineInfo::weight() const
-{
- return d->weight;
-}
-
-/*!
- \property QFontEngineInfo::style
- the style of the font
-*/
-
-void QFontEngineInfo::setStyle(QFont::Style style)
-{
- d->style = style;
-}
-
-QFont::Style QFontEngineInfo::style() const
-{
- return d->style;
-}
-
-/*!
- \property QFontEngineInfo::writingSystems
- the writing systems supported by the font
-
- An empty list means that any writing system is supported.
-*/
-
-QList<QFontDatabase::WritingSystem> QFontEngineInfo::writingSystems() const
-{
- return d->writingSystems;
-}
-
-void QFontEngineInfo::setWritingSystems(const QList<QFontDatabase::WritingSystem> &writingSystems)
-{
- d->writingSystems = writingSystems;
-}
-
-class QFontEnginePluginPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QFontEnginePlugin)
-
- QString foundry;
-};
-
-/*!
- \class QFontEnginePlugin
- \preliminary
- \brief The QFontEnginePlugin class is the base class for font engine factory plugins in Qt for Embedded Linux.
- \since 4.3
- \ingroup qws
- \ingroup plugins
-
- \tableofcontents
-
- QFontEnginePlugin is provided by font engine plugins to create
- instances of subclasses of QAbstractFontEngine.
-
- The member functions create() and availableFontEngines() must be
- implemented.
-
- \sa QAbstractFontEngine, QFontEngineInfo
-*/
-
-/*!
- Creates a font engine plugin that creates font engines with the
- specified \a foundry and \a parent.
-*/
-QFontEnginePlugin::QFontEnginePlugin(const QString &foundry, QObject *parent)
- : QObject(*new QFontEnginePluginPrivate, parent)
-{
- Q_D(QFontEnginePlugin);
- d->foundry = foundry;
-}
-
-/*!
- Destroys this font engine plugin.
-*/
-QFontEnginePlugin::~QFontEnginePlugin()
-{
-}
-
-/*!
- Returns a list of foundries the font engine plugin provides.
- The default implementation returns the foundry specified with the constructor.
-*/
-QStringList QFontEnginePlugin::keys() const
-{
- Q_D(const QFontEnginePlugin);
- return QStringList(d->foundry);
-}
-
-/*!
- \fn QAbstractFontEngine *QFontEnginePlugin::create(const QFontEngineInfo &info)
-
- Implemented in subclasses to create a new font engine that provides a font that
- matches \a info.
-*/
-
-/*!
- \fn QList<QFontEngineInfo> QFontEnginePlugin::availableFontEngines() const
-
- Implemented in subclasses to return a list of QFontEngineInfo objects that represents all font
- engines the plugin can create.
-*/
-
-class QAbstractFontEnginePrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QAbstractFontEngine)
-public:
-};
-
-//The <classname> class is|provides|contains|specifies...
-/*!
- \class QAbstractFontEngine
- \preliminary
- \brief The QAbstractFontEngine class is the base class for font engine plugins in Qt for Embedded Linux.
- \since 4.3
- \ingroup qws
-
- \tableofcontents
-
- QAbstractFontEngine is implemented by font engine plugins through QFontEnginePlugin.
-
- \sa QFontEnginePlugin, QFontEngineInfo
-*/
-
-/*!
- \enum QAbstractFontEngine::Capability
-
- This enum describes the capabilities of a font engine.
-
- \value CanRenderGlyphs_Gray The font engine can render individual glyphs into 8 bpp images.
- \value CanRenderGlyphs_Mono The font engine can render individual glyphs into 1 bpp images.
- \value CanRenderGlyphs The font engine can render individual glyphs into images.
- \value CanOutlineGlyphs The font engine can convert glyphs to painter paths.
-*/
-
-/*!
- \enum QAbstractFontEngine::FontProperty
-
- This enum describes the properties of a font provided by a font engine.
-
- \value Ascent The ascent of the font, specified as a 26.6 fixed point value.
- \value Descent The descent of the font, specified as a 26.6 fixed point value.
- \value Leading The leading of the font, specified as a 26.6 fixed point value.
- \value XHeight The 'x' height of the font, specified as a 26.6 fixed point value.
- \value AverageCharWidth The average character width of the font, specified as a 26.6 fixed point value.
- \value LineThickness The thickness of the underline and strikeout lines for the font, specified as a 26.6 fixed point value.
- \value UnderlinePosition The distance from the base line to the underline position for the font, specified as a 26.6 fixed point value.
- \value MaxCharWidth The width of the widest character in the font, specified as a 26.6 fixed point value.
- \value MinLeftBearing The minimum left bearing of the font, specified as a 26.6 fixed point value.
- \value MinRightBearing The maximum right bearing of the font, specified as a 26.6 fixed point value.
- \value GlyphCount The number of glyphs in the font, specified as an integer value.
- \value CacheGlyphsHint A boolean value specifying whether rendered glyphs should be cached by Qt.
- \value OutlineGlyphsHint A boolean value specifying whether the font engine prefers outline drawing over image rendering for uncached glyphs.
-*/
-
-/*!
- \enum QAbstractFontEngine::TextShapingFlag
-
- This enum describes flags controlling conversion of characters to glyphs and their metrics.
-
- \value RightToLeft The text is used in a right-to-left context.
- \value ReturnDesignMetrics Return font design metrics instead of pixel metrics.
-*/
-
-/*!
- \typedef QAbstractFontEngine::Fixed
-
- This type is \c int, interpreted as a 26.6 fixed point value.
-*/
-
-/*!
- \class QAbstractFontEngine::GlyphMetrics
- \brief QAbstractFontEngine::GlyphMetrics defines the metrics of a single glyph.
- \preliminary
- \since 4.3
-*/
-
-/*!
- \variable QAbstractFontEngine::GlyphMetrics::x
-
- The horizontal offset from the origin.
-*/
-
-/*!
- \fn QAbstractFontEngine::GlyphMetrics::GlyphMetrics()
-
- Constructs an empty glyph metrics object with all values
- set to zero.
-*/
-
-/*!
- \variable QAbstractFontEngine::GlyphMetrics::y
-
- The vertical offset from the origin (baseline).
-*/
-
-/*!
- \variable QAbstractFontEngine::GlyphMetrics::width
-
- The width of the glyph.
-*/
-
-/*!
- \variable QAbstractFontEngine::GlyphMetrics::height
-
- The height of the glyph.
-*/
-
-/*!
- \variable QAbstractFontEngine::GlyphMetrics::advance
-
- The advance of the glyph.
-*/
-
-/*!
- \class QAbstractFontEngine::FixedPoint
- \brief QAbstractFontEngine::FixedPoint defines a point in the place using 26.6 fixed point precision.
- \preliminary
- \since 4.3
-*/
-
-/*!
- \variable QAbstractFontEngine::FixedPoint::x
-
- The x coordinate of this point.
-*/
-
-/*!
- \variable QAbstractFontEngine::FixedPoint::y
-
- The y coordinate of this point.
-*/
-
-/*!
- Constructs a new QAbstractFontEngine with the given \a parent.
-*/
-QAbstractFontEngine::QAbstractFontEngine(QObject *parent)
- : QObject(*new QAbstractFontEnginePrivate, parent)
-{
-}
-
-/*!
- Destroys this QAbstractFontEngine object.
-*/
-QAbstractFontEngine::~QAbstractFontEngine()
-{
-}
-
-/*!
- \fn QAbstractFontEngine::Capabilities QAbstractFontEngine::capabilities() const
-
- Implemented in subclasses to specify the font engine's capabilities. The return value
- may be cached by the caller and is expected not to change during the lifetime of the
- font engine.
-*/
-
-/*!
- \fn QVariant QAbstractFontEngine::fontProperty(FontProperty property) const
-
- Implemented in subclasses to return the value of the font attribute \a property. The return
- value may be cached by the caller and is expected not to change during the lifetime of the font
- engine.
-*/
-
-/*!
- \fn bool QAbstractFontEngine::convertStringToGlyphIndices(const QChar *string, int length, uint *glyphs, int *numGlyphs, TextShapingFlags flags) const
-
- Implemented in subclasses to convert the characters specified by \a string and \a length to
- glyph indicies, using \a flags. The glyph indicies should be returned in the \a glyphs array
- provided by the caller. The maximum size of \a glyphs is specified by the value pointed to by \a
- numGlyphs. If successful, the subclass implementation sets the value pointed to by \a numGlyphs
- to the actual number of glyph indices generated, and returns true. Otherwise, e.g. if there is
- not enough space in the provided \a glyphs array, it should set \a numGlyphs to the number of
- glyphs needed for the conversion and return false.
-*/
-
-/*!
- \fn void QAbstractFontEngine::getGlyphAdvances(const uint *glyphs, int numGlyphs, Fixed *advances, TextShapingFlags flags) const
-
- Implemented in subclasses to retrieve the advances of the array specified by \a glyphs and \a
- numGlyphs, using \a flags. The result is returned in \a advances, which is allocated by the
- caller and contains \a numGlyphs elements.
-*/
-
-/*!
- \fn QAbstractFontEngine::GlyphMetrics QAbstractFontEngine::glyphMetrics(uint glyph) const
-
- Implemented in subclass to return the metrics for \a glyph.
-*/
-
-/*!
- Implemented in subclasses to render the specified \a glyph into a \a buffer with the given \a depth ,
- \a bytesPerLine and \a height.
-
- Returns true if rendering succeeded, false otherwise.
-*/
-bool QAbstractFontEngine::renderGlyph(uint glyph, int depth, int bytesPerLine, int height, uchar *buffer)
-{
- Q_UNUSED(glyph)
- Q_UNUSED(depth)
- Q_UNUSED(bytesPerLine)
- Q_UNUSED(height)
- Q_UNUSED(buffer)
- qWarning("QAbstractFontEngine: renderGlyph is not implemented in font plugin!");
- return false;
-}
-
-/*!
- Implemented in subclasses to add the outline of the glyphs specified by \a glyphs and \a
- numGlyphs at the specified \a positions to the painter path \a path.
-*/
-void QAbstractFontEngine::addGlyphOutlinesToPath(uint *glyphs, int numGlyphs, FixedPoint *positions, QPainterPath *path)
-{
- Q_UNUSED(glyphs)
- Q_UNUSED(numGlyphs)
- Q_UNUSED(positions)
- Q_UNUSED(path)
- qWarning("QAbstractFontEngine: addGlyphOutlinesToPath is not implemented in font plugin!");
-}
-
-/*
-bool QAbstractFontEngine::supportsExtension(Extension extension) const
-{
- Q_UNUSED(extension)
- return false;
-}
-
-QVariant QAbstractFontEngine::extension(Extension extension, const QVariant &argument)
-{
- Q_UNUSED(argument)
- Q_UNUSED(extension)
- return QVariant();
-}
-*/
-
-QProxyFontEngine::QProxyFontEngine(QAbstractFontEngine *customEngine, const QFontDef &def)
- : engine(customEngine)
-{
- fontDef = def;
- engineCapabilities = engine->capabilities();
-}
-
-QProxyFontEngine::~QProxyFontEngine()
-{
- delete engine;
-}
-
-bool QProxyFontEngine::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const
-{
- if (*nglyphs < len) {
- *nglyphs = len;
- return false;
- }
-
- QVarLengthArray<uint> glyphIndicies(*nglyphs);
- if (!engine->convertStringToGlyphIndices(str, len, glyphIndicies.data(), nglyphs, QAbstractFontEngine::TextShapingFlags(int(flags))))
- return false;
-
- // ### use memcopy instead
- for (int i = 0; i < *nglyphs; ++i) {
- glyphs->glyphs[i] = glyphIndicies[i];
- }
- glyphs->numGlyphs = *nglyphs;
-
- recalcAdvances(glyphs, flags);
- return true;
-}
-
-void QProxyFontEngine::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const
-{
- const int nglyphs = glyphs->numGlyphs;
-
- QVarLengthArray<QAbstractFontEngine::Fixed> advances(nglyphs);
- engine->getGlyphAdvances(glyphs->glyphs, nglyphs, advances.data(), QAbstractFontEngine::TextShapingFlags(int(flags)));
-
-
- // ### use memcopy instead
- for (int i = 0; i < nglyphs; ++i) {
- glyphs->advances_x[i] = QFixed::fromFixed(advances[i]);
- glyphs->advances_y[i] = 0;
- }
-}
-
-
-static QImage alphaMapFromPath(QFontEngine *fe, glyph_t glyph)
-{
- glyph_metrics_t gm = fe->boundingBox(glyph);
- int glyph_x = qFloor(gm.x.toReal());
- int glyph_y = qFloor(gm.y.toReal());
- int glyph_width = qCeil((gm.x + gm.width).toReal()) - glyph_x;
- int glyph_height = qCeil((gm.y + gm.height).toReal()) - glyph_y;
-
- if (glyph_width <= 0 || glyph_height <= 0)
- return QImage();
- QFixedPoint pt;
- pt.x = 0;
- pt.y = -glyph_y; // the baseline
- QPainterPath path;
- QImage im(glyph_width + qAbs(glyph_x) + 4, glyph_height, QImage::Format_ARGB32_Premultiplied);
- im.fill(Qt::transparent);
- QPainter p(&im);
- p.setRenderHint(QPainter::Antialiasing);
- fe->addGlyphsToPath(&glyph, &pt, 1, &path, 0);
- p.setPen(Qt::NoPen);
- p.setBrush(Qt::black);
- p.drawPath(path);
- p.end();
-
- QImage indexed(im.width(), im.height(), QImage::Format_Indexed8);
- QVector<QRgb> colors(256);
- for (int i=0; i<256; ++i)
- colors[i] = qRgba(0, 0, 0, i);
- indexed.setColorTable(colors);
-
- for (int y=0; y<im.height(); ++y) {
- uchar *dst = (uchar *) indexed.scanLine(y);
- uint *src = (uint *) im.scanLine(y);
- for (int x=0; x<im.width(); ++x)
- dst[x] = qAlpha(src[x]);
- }
-
- return indexed;
-}
-
-
-QImage QProxyFontEngine::alphaMapForGlyph(glyph_t glyph)
-{
- if (!(engineCapabilities & QAbstractFontEngine::CanRenderGlyphs_Gray))
- return alphaMapFromPath(this, glyph);
-
- QAbstractFontEngine::GlyphMetrics metrics = engine->glyphMetrics(glyph);
- if (metrics.width <= 0 || metrics.height <= 0)
- return QImage();
-
- QImage img(metrics.width >> 6, metrics.height >> 6, QImage::Format_Indexed8);
-
- // ### we should have QImage::Format_GrayScale8
- static QVector<QRgb> colorMap;
- if (colorMap.isEmpty()) {
- colorMap.resize(256);
- for (int i=0; i<256; ++i)
- colorMap[i] = qRgba(0, 0, 0, i);
- }
-
- img.setColorTable(colorMap);
-
- engine->renderGlyph(glyph, /*depth*/8, img.bytesPerLine(), img.height(), img.bits());
-
- return img;
-}
-
-void QProxyFontEngine::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs, QPainterPath *path, QTextItem::RenderFlags flags)
-{
- if (engineCapabilities & QAbstractFontEngine::CanOutlineGlyphs)
- engine->addGlyphOutlinesToPath(glyphs, nglyphs, reinterpret_cast<QAbstractFontEngine::FixedPoint *>(positions), path);
- else
- QFontEngine::addGlyphsToPath(glyphs, positions, nglyphs, path, flags);
-}
-
-glyph_metrics_t QProxyFontEngine::boundingBox(const QGlyphLayout &glyphs)
-{
- if (glyphs.numGlyphs == 0)
- return glyph_metrics_t();
-
- QFixed w = 0;
- for (int i = 0; i < glyphs.numGlyphs; ++i)
- w += glyphs.effectiveAdvance(i);
-
- return glyph_metrics_t(0, -ascent(), w, ascent() + descent(), w, 0);
-}
-
-glyph_metrics_t QProxyFontEngine::boundingBox(glyph_t glyph)
-{
- glyph_metrics_t m;
-
- QAbstractFontEngine::GlyphMetrics metrics = engine->glyphMetrics(glyph);
- m.x = QFixed::fromFixed(metrics.x);
- m.y = QFixed::fromFixed(metrics.y);
- m.width = QFixed::fromFixed(metrics.width);
- m.height = QFixed::fromFixed(metrics.height);
- m.xoff = QFixed::fromFixed(metrics.advance);
-
- return m;
-}
-
-QFixed QProxyFontEngine::ascent() const
-{
- return QFixed::fromFixed(engine->fontProperty(QAbstractFontEngine::Ascent).toInt());
-}
-
-QFixed QProxyFontEngine::descent() const
-{
- return QFixed::fromFixed(engine->fontProperty(QAbstractFontEngine::Descent).toInt());
-}
-
-QFixed QProxyFontEngine::leading() const
-{
- return QFixed::fromFixed(engine->fontProperty(QAbstractFontEngine::Leading).toInt());
-}
-
-QFixed QProxyFontEngine::xHeight() const
-{
- return QFixed::fromFixed(engine->fontProperty(QAbstractFontEngine::XHeight).toInt());
-}
-
-QFixed QProxyFontEngine::averageCharWidth() const
-{
- return QFixed::fromFixed(engine->fontProperty(QAbstractFontEngine::AverageCharWidth).toInt());
-}
-
-QFixed QProxyFontEngine::lineThickness() const
-{
- return QFixed::fromFixed(engine->fontProperty(QAbstractFontEngine::LineThickness).toInt());
-}
-
-QFixed QProxyFontEngine::underlinePosition() const
-{
- return QFixed::fromFixed(engine->fontProperty(QAbstractFontEngine::UnderlinePosition).toInt());
-}
-
-qreal QProxyFontEngine::maxCharWidth() const
-{
- return QFixed::fromFixed(engine->fontProperty(QAbstractFontEngine::MaxCharWidth).toInt()).toReal();
-}
-
-qreal QProxyFontEngine::minLeftBearing() const
-{
- return QFixed::fromFixed(engine->fontProperty(QAbstractFontEngine::MinLeftBearing).toInt()).toReal();
-}
-
-qreal QProxyFontEngine::minRightBearing() const
-{
- return QFixed::fromFixed(engine->fontProperty(QAbstractFontEngine::MinRightBearing).toInt()).toReal();
-}
-
-int QProxyFontEngine::glyphCount() const
-{
- return engine->fontProperty(QAbstractFontEngine::GlyphCount).toInt();
-}
-
-bool QProxyFontEngine::canRender(const QChar *string, int len)
-{
- QVarLengthArray<uint> glyphs(len);
- int numGlyphs = len;
-
- if (!engine->convertStringToGlyphIndices(string, len, glyphs.data(), &numGlyphs, /*flags*/0))
- return false;
-
- for (int i = 0; i < numGlyphs; ++i)
- if (!glyphs[i])
- return false;
-
- return true;
-}
-
-void QProxyFontEngine::draw(QPaintEngine *p, qreal _x, qreal _y, const QTextItemInt &si)
-{
- QPaintEngineState *pState = p->state;
- QRasterPaintEngine *paintEngine = static_cast<QRasterPaintEngine*>(p);
-
- QTransform matrix = pState->transform();
- matrix.translate(_x, _y);
- QFixed x = QFixed::fromReal(matrix.dx());
- QFixed y = QFixed::fromReal(matrix.dy());
-
- QVarLengthArray<QFixedPoint> positions;
- QVarLengthArray<glyph_t> glyphs;
- getGlyphPositions(si.glyphs, matrix, si.flags, glyphs, positions);
- if (glyphs.size() == 0)
- return;
-
- for(int i = 0; i < glyphs.size(); i++) {
- QImage glyph = alphaMapForGlyph(glyphs[i]);
- if (glyph.isNull())
- continue;
-
- if (glyph.format() != QImage::Format_Indexed8
- && glyph.format() != QImage::Format_Mono)
- continue;
-
- QAbstractFontEngine::GlyphMetrics metrics = engine->glyphMetrics(glyphs[i]);
-
- int depth = glyph.format() == QImage::Format_Mono ? 1 : 8;
- paintEngine->alphaPenBlt(glyph.bits(), glyph.bytesPerLine(), depth,
- qRound(positions[i].x + QFixed::fromFixed(metrics.x)),
- qRound(positions[i].y + QFixed::fromFixed(metrics.y)),
- glyph.width(), glyph.height());
- }
-}
-
-/*
- * This is only called when we use the proxy fontengine directly (without sharing the rendered
- * glyphs). So we prefer outline rendering over rendering of unshared glyphs. That decision is
- * done in qfontdatabase_qws.cpp by looking at the ShareGlyphsHint and the pixel size of the font.
- */
-bool QProxyFontEngine::drawAsOutline() const
-{
- if (!(engineCapabilities & QAbstractFontEngine::CanOutlineGlyphs))
- return false;
-
- QVariant outlineHint = engine->fontProperty(QAbstractFontEngine::OutlineGlyphsHint);
- return !outlineHint.isValid() || outlineHint.toBool();
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/text/qabstractfontengine_qws.h b/src/gui/text/qabstractfontengine_qws.h
deleted file mode 100644
index dfc15dcf5d..0000000000
--- a/src/gui/text/qabstractfontengine_qws.h
+++ /dev/null
@@ -1,221 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QABSTRACTFONTENGINE_QWS_H
-#define QABSTRACTFONTENGINE_QWS_H
-
-#include <QtCore/qobject.h>
-#include <QtCore/qhash.h>
-#include <QtCore/qvariant.h>
-#include <QtCore/qfactoryinterface.h>
-#include <QtGui/qpaintengine.h>
-#include <QtGui/qfontdatabase.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QFontEngineInfoPrivate;
-
-class Q_GUI_EXPORT QFontEngineInfo
-{
-public:
- QDOC_PROPERTY(QString family READ family WRITE setFamily)
- QDOC_PROPERTY(qreal pixelSize READ pixelSize WRITE setPixelSize)
- QDOC_PROPERTY(int weight READ weight WRITE setWeight)
- QDOC_PROPERTY(QFont::Style style READ style WRITE setStyle)
- QDOC_PROPERTY(QList<QFontDatabase::WritingSystem> writingSystems READ writingSystems WRITE setWritingSystems)
-
- QFontEngineInfo();
- explicit QFontEngineInfo(const QString &family);
- QFontEngineInfo(const QFontEngineInfo &other);
- QFontEngineInfo &operator=(const QFontEngineInfo &other);
- ~QFontEngineInfo();
-
- void setFamily(const QString &name);
- QString family() const;
-
- void setPixelSize(qreal size);
- qreal pixelSize() const;
-
- void setWeight(int weight);
- int weight() const;
-
- void setStyle(QFont::Style style);
- QFont::Style style() const;
-
- QList<QFontDatabase::WritingSystem> writingSystems() const;
- void setWritingSystems(const QList<QFontDatabase::WritingSystem> &writingSystems);
-
-private:
- QFontEngineInfoPrivate *d;
-};
-
-class QAbstractFontEngine;
-
-struct Q_GUI_EXPORT QFontEngineFactoryInterface : public QFactoryInterface
-{
- virtual QAbstractFontEngine *create(const QFontEngineInfo &info) = 0;
- virtual QList<QFontEngineInfo> availableFontEngines() const = 0;
-};
-
-#define QFontEngineFactoryInterface_iid "com.trolltech.Qt.QFontEngineFactoryInterface"
-Q_DECLARE_INTERFACE(QFontEngineFactoryInterface, QFontEngineFactoryInterface_iid)
-
-class QFontEnginePluginPrivate;
-
-class Q_GUI_EXPORT QFontEnginePlugin : public QObject, public QFontEngineFactoryInterface
-{
- Q_OBJECT
- Q_INTERFACES(QFontEngineFactoryInterface:QFactoryInterface)
-public:
- QFontEnginePlugin(const QString &foundry, QObject *parent = 0);
- ~QFontEnginePlugin();
-
- virtual QStringList keys() const;
-
- virtual QAbstractFontEngine *create(const QFontEngineInfo &info) = 0;
- virtual QList<QFontEngineInfo> availableFontEngines() const = 0;
-
-private:
- Q_DECLARE_PRIVATE(QFontEnginePlugin)
- Q_DISABLE_COPY(QFontEnginePlugin)
-};
-
-class QAbstractFontEnginePrivate;
-
-class Q_GUI_EXPORT QAbstractFontEngine : public QObject
-{
- Q_OBJECT
-public:
- enum Capability {
- CanOutlineGlyphs = 1,
- CanRenderGlyphs_Mono = 2,
- CanRenderGlyphs_Gray = 4,
- CanRenderGlyphs = CanRenderGlyphs_Mono | CanRenderGlyphs_Gray
- };
- Q_DECLARE_FLAGS(Capabilities, Capability)
-
- explicit QAbstractFontEngine(QObject *parent = 0);
- ~QAbstractFontEngine();
-
- typedef int Fixed; // 26.6
-
- struct FixedPoint
- {
- Fixed x;
- Fixed y;
- };
-
- struct GlyphMetrics
- {
- inline GlyphMetrics()
- : x(0), y(0), width(0), height(0),
- advance(0) {}
- Fixed x;
- Fixed y;
- Fixed width;
- Fixed height;
- Fixed advance;
- };
-
- enum FontProperty {
- Ascent,
- Descent,
- Leading,
- XHeight,
- AverageCharWidth,
- LineThickness,
- UnderlinePosition,
- MaxCharWidth,
- MinLeftBearing,
- MinRightBearing,
- GlyphCount,
-
- // hints
- CacheGlyphsHint,
- OutlineGlyphsHint
- };
-
- // keep in sync with QTextEngine::ShaperFlag!!
- enum TextShapingFlag {
- RightToLeft = 0x0001,
- ReturnDesignMetrics = 0x0002
- };
- Q_DECLARE_FLAGS(TextShapingFlags, TextShapingFlag)
-
- virtual Capabilities capabilities() const = 0;
- virtual QVariant fontProperty(FontProperty property) const = 0;
-
- virtual bool convertStringToGlyphIndices(const QChar *string, int length, uint *glyphs, int *numGlyphs, TextShapingFlags flags) const = 0;
-
- virtual void getGlyphAdvances(const uint *glyphs, int numGlyphs, Fixed *advances, TextShapingFlags flags) const = 0;
-
- virtual GlyphMetrics glyphMetrics(uint glyph) const = 0;
-
- virtual bool renderGlyph(uint glyph, int depth, int bytesPerLine, int height, uchar *buffer);
-
- virtual void addGlyphOutlinesToPath(uint *glyphs, int numGlyphs, FixedPoint *positions, QPainterPath *path);
-
- /*
- enum Extension {
- GetTrueTypeTable
- };
-
- virtual bool supportsExtension(Extension extension) const;
- virtual QVariant extension(Extension extension, const QVariant &argument = QVariant());
- */
-
-private:
- Q_DECLARE_PRIVATE(QAbstractFontEngine)
- Q_DISABLE_COPY(QAbstractFontEngine)
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractFontEngine::Capabilities)
-Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractFontEngine::TextShapingFlags)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/gui/text/qcssparser.cpp b/src/gui/text/qcssparser.cpp
index 052dc72b63..8eb68be207 100644
--- a/src/gui/text/qcssparser.cpp
+++ b/src/gui/text/qcssparser.cpp
@@ -1275,6 +1275,8 @@ void ValueExtractor::extractFont()
bool ValueExtractor::extractImage(QIcon *icon, Qt::Alignment *a, QSize *size)
{
bool hit = false;
+#if 0
+ // ### Qt5
for (int i = 0; i < declarations.count(); ++i) {
const Declaration &decl = declarations.at(i);
switch (decl.d->propertyId) {
@@ -1295,6 +1297,7 @@ bool ValueExtractor::extractImage(QIcon *icon, Qt::Alignment *a, QSize *size)
}
hit = true;
}
+#endif
return hit;
}
@@ -1643,6 +1646,8 @@ void Declaration::borderImageValue(QString *image, int *cuts,
*h = *v;
}
+#if 0
+// ### Qt 5
QIcon Declaration::iconValue() const
{
if (d->parsed.isValid())
@@ -1689,6 +1694,7 @@ QIcon Declaration::iconValue() const
d->parsed = QVariant::fromValue<QIcon>(icon);
return icon;
}
+#endif
///////////////////////////////////////////////////////////////////////////////
// Selector
diff --git a/src/gui/text/qcssparser_p.h b/src/gui/text/qcssparser_p.h
index 86bafc9215..4fc720fcef 100644
--- a/src/gui/text/qcssparser_p.h
+++ b/src/gui/text/qcssparser_p.h
@@ -61,9 +61,9 @@
#include <QtCore/QMultiHash>
#include <QtGui/QFont>
#include <QtGui/QPalette>
-#include <QtGui/QIcon>
#include <QtCore/QSharedData>
+class QIcon;
#ifndef QT_NO_CSSPARSER
@@ -453,7 +453,7 @@ struct Q_AUTOTEST_EXPORT Declaration
QSize sizeValue() const;
QRect rectValue() const;
QString uriValue() const;
- QIcon iconValue() const;
+// QIcon iconValue() const;
void borderImageValue(QString *image, int *cuts, TileMode *h, TileMode *v) const;
};
@@ -633,7 +633,7 @@ enum StyleSheetOrigin {
StyleSheetOrigin_Inline
};
-struct StyleSheet
+struct Q_GUI_EXPORT StyleSheet
{
StyleSheet() : origin(StyleSheetOrigin_Unspecified), depth(0) { }
QVector<StyleRule> styleRules; //only contains rules that are not indexed
diff --git a/src/gui/text/qfont.cpp b/src/gui/text/qfont.cpp
index b8cfb1f902..503263345c 100644
--- a/src/gui/text/qfont.cpp
+++ b/src/gui/text/qfont.cpp
@@ -48,7 +48,7 @@
#include "qpainter.h"
#include "qhash.h"
#include "qdatastream.h"
-#include "qapplication.h"
+#include "qguiapplication.h"
#include "qstringlist.h"
#include "qthread.h"
@@ -65,19 +65,12 @@
#include "qx11info_x11.h"
#include <private/qt_x11_p.h>
#endif
-#ifdef Q_WS_QWS
-#include "qscreen_qws.h"
-#if !defined(QT_NO_QWS_QPF2)
-#include <qfile.h>
-#include "qfontengine_qpf_p.h"
-#endif
-#endif
#ifdef Q_OS_SYMBIAN
#include <private/qt_s60_p.h>
#endif
#ifdef Q_WS_QPA
#include <QtGui/qplatformscreen_qpa.h>
-#include <QtGui/private/qapplication_p.h>
+#include <QtGui/private/qguiapplication_p.h>
#endif
#include <QMutexLocker>
@@ -171,18 +164,10 @@ Q_GUI_EXPORT int qt_defaultDpiX()
#elif defined(Q_WS_MAC)
extern float qt_mac_defaultDpi_x(); //qpaintdevice_mac.cpp
dpi = qt_mac_defaultDpi_x();
-#elif defined(Q_WS_QWS)
- if (!qt_screen)
- return 72;
- QScreen *screen = qt_screen;
- const QList<QScreen*> subScreens = qt_screen->subScreens();
- if (!subScreens.isEmpty())
- screen = subScreens.at(0);
- dpi = qRound(screen->width() / (screen->physicalWidth() / qreal(25.4)));
#elif defined(Q_WS_QPA)
- QPlatformIntegration *pi = QApplicationPrivate::platformIntegration();
+ QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration();
if (pi) {
- QPlatformScreen *screen = QApplicationPrivate::platformIntegration()->screens().at(0);
+ QPlatformScreen *screen = pi->screens().at(0);
const QSize screenSize = screen->geometry().size();
const QSize physicalSize = screen->physicalSize();
dpi = qRound(screenSize.width() / (physicalSize.width() / qreal(25.4)));
@@ -210,18 +195,10 @@ Q_GUI_EXPORT int qt_defaultDpiY()
#elif defined(Q_WS_MAC)
extern float qt_mac_defaultDpi_y(); //qpaintdevice_mac.cpp
dpi = qt_mac_defaultDpi_y();
-#elif defined(Q_WS_QWS)
- if (!qt_screen)
- return 72;
- QScreen *screen = qt_screen;
- const QList<QScreen*> subScreens = qt_screen->subScreens();
- if (!subScreens.isEmpty())
- screen = subScreens.at(0);
- dpi = qRound(screen->height() / (screen->physicalHeight() / qreal(25.4)));
#elif defined(Q_WS_QPA)
- QPlatformIntegration *pi = QApplicationPrivate::platformIntegration();
+ QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration();
if (pi) {
- QPlatformScreen *screen = QApplicationPrivate::platformIntegration()->screens().at(0);
+ QPlatformScreen *screen = pi->screens().at(0);
const QSize screenSize = screen->geometry().size();
const QSize physicalSize = screen->physicalSize();
dpi = qRound(screenSize.height() / (physicalSize.height() / qreal(25.4)));
@@ -448,9 +425,9 @@ QFontEngineData::~QFontEngineData()
Use QFontMetrics to get measurements, e.g. the pixel length of a
string using QFontMetrics::width().
- Note that a QApplication instance must exist before a QFont can be
+ Note that a QGuiApplication instance must exist before a QFont can be
used. You can set the application's default font with
- QApplication::setFont().
+ QGuiApplication::setFont().
If a chosen font does not include all the characters that
need to be displayed, QFont will try to find the characters in the
@@ -781,10 +758,10 @@ void QFont::detach()
/*!
Constructs a font object that uses the application's default font.
- \sa QApplication::setFont(), QApplication::font()
+ \sa QGuiApplication::setFont(), QGuiApplication::font()
*/
QFont::QFont()
- : d(QApplication::font().d.data()), resolve_mask(0)
+ : d(QGuiApplication::font().d.data()), resolve_mask(0)
{
}
@@ -804,7 +781,7 @@ QFont::QFont()
algorithm.
\sa Weight, setFamily(), setPointSize(), setWeight(), setItalic(),
- setStyleHint() QApplication::font()
+ setStyleHint() QGuiApplication::font()
*/
QFont::QFont(const QString &family, int pointSize, int weight, bool italic)
: d(new QFontPrivate()), resolve_mask(QFont::FamilyResolved)
@@ -1096,18 +1073,6 @@ int QFont::pixelSize() const
return d->request.pixelSize;
}
-#ifdef QT3_SUPPORT
-/*! \obsolete
-
- Sets the logical pixel height of font characters when shown on
- the screen to \a pixelSize.
-*/
-void QFont::setPixelSizeFloat(qreal pixelSize)
-{
- setPixelSize((int)pixelSize);
-}
-#endif
-
/*!
\fn bool QFont::italic() const
@@ -1875,43 +1840,6 @@ QFont QFont::resolve(const QFont &other) const
\internal
*/
-#ifdef QT3_SUPPORT
-
-/*! \obsolete
-
- Please use QApplication::font() instead.
-*/
-QFont QFont::defaultFont()
-{
- return QApplication::font();
-}
-
-/*! \obsolete
-
- Please use QApplication::setFont() instead.
-*/
-void QFont::setDefaultFont(const QFont &f)
-{
- QApplication::setFont(f);
-}
-
-/*!
- \fn qreal QFont::pointSizeFloat() const
- \compat
-
- Use pointSizeF() instead.
-*/
-
-/*!
- \fn void QFont::setPointSizeFloat(qreal size)
- \compat
-
- Use setPointSizeF() instead.
-*/
-#endif
-
-
-
/*****************************************************************************
QFont substitution management
diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h
index 0c7b6f8de8..194e3ad34a 100644
--- a/src/gui/text/qfont.h
+++ b/src/gui/text/qfont.h
@@ -283,14 +283,6 @@ public:
inline uint resolve() const { return resolve_mask; }
inline void resolve(uint mask) { resolve_mask = mask; }
-#ifdef QT3_SUPPORT
- static QT3_SUPPORT QFont defaultFont();
- static QT3_SUPPORT void setDefaultFont(const QFont &);
- QT3_SUPPORT void setPixelSizeFloat(qreal);
- QT3_SUPPORT qreal pointSizeFloat() const { return pointSizeF(); }
- QT3_SUPPORT void setPointSizeFloat(qreal size) { setPointSizeF(size); }
-#endif
-
private:
QFont(QFontPrivate *);
diff --git a/src/gui/text/qfont_qpa.cpp b/src/gui/text/qfont_qpa.cpp
index ff12da8d97..981c313201 100644
--- a/src/gui/text/qfont_qpa.cpp
+++ b/src/gui/text/qfont_qpa.cpp
@@ -39,14 +39,14 @@
**
****************************************************************************/
-#include <QtGui/private/qapplication_p.h>
+#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/QPlatformFontDatabase>
QT_BEGIN_NAMESPACE
void QFont::initialize()
{
- QApplicationPrivate::platformIntegration()->fontDatabase()->populateFontDatabase();
+ QGuiApplicationPrivate::platformIntegration()->fontDatabase()->populateFontDatabase();
}
void QFont::cleanup()
@@ -90,7 +90,7 @@ QString QFont::defaultFamily() const
familyName = QString::fromLatin1("helvetica");
}
- QStringList list = QApplicationPrivate::platformIntegration()->fontDatabase()->fallbacksForFamily(familyName,QFont::StyleNormal,QFont::StyleHint(d->request.styleHint),QUnicodeTables::Common);
+ QStringList list = QGuiApplicationPrivate::platformIntegration()->fontDatabase()->fallbacksForFamily(familyName,QFont::StyleNormal,QFont::StyleHint(d->request.styleHint),QUnicodeTables::Common);
if (list.size()) {
familyName = list.at(0);
}
diff --git a/src/gui/text/qfont_qws.cpp b/src/gui/text/qfont_qws.cpp
deleted file mode 100644
index ea2a944432..0000000000
--- a/src/gui/text/qfont_qws.cpp
+++ /dev/null
@@ -1,135 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwidget.h"
-#include "qpainter.h"
-#include "qfont_p.h"
-#include <private/qunicodetables_p.h>
-#include "qfontdatabase.h"
-#include "qtextcodec.h"
-#include "qapplication.h"
-#include "qfile.h"
-#include "qtextstream.h"
-#include "qmap.h"
-//#include "qmemorymanager_qws.h"
-#include "qtextengine_p.h"
-#include "qfontengine_p.h"
-#if !defined(QT_NO_FREETYPE)
-#include "qfontengine_ft_p.h"
-#endif
-
-QT_BEGIN_NAMESPACE
-
-void QFont::initialize()
-{ }
-
-void QFont::cleanup()
-{
- QFontCache::cleanup();
-}
-
-
-/*****************************************************************************
- QFont member functions
- *****************************************************************************/
-
-Qt::HANDLE QFont::handle() const
-{
-#ifndef QT_NO_FREETYPE
- return freetypeFace();
-#endif
- return 0;
-}
-
-FT_Face QFont::freetypeFace() const
-{
-#ifndef QT_NO_FREETYPE
- QFontEngine *engine = d->engineForScript(QUnicodeTables::Common);
- if (engine->type() == QFontEngine::Multi)
- engine = static_cast<QFontEngineMulti *>(engine)->engine(0);
- if (engine->type() == QFontEngine::Freetype) {
- const QFontEngineFT *ft = static_cast<const QFontEngineFT *>(engine);
- return ft->non_locked_face();
- }
-#endif
- return 0;
-}
-
-QString QFont::rawName() const
-{
- return QLatin1String("unknown");
-}
-
-void QFont::setRawName(const QString &)
-{
-}
-
-QString QFont::defaultFamily() const
-{
- switch(d->request.styleHint) {
- case QFont::Times:
- return QString::fromLatin1("times");
- case QFont::Courier:
- case QFont::Monospace:
- return QString::fromLatin1("courier");
- case QFont::Decorative:
- return QString::fromLatin1("old english");
- case QFont::Helvetica:
- case QFont::System:
- default:
- return QString::fromLatin1("helvetica");
- }
-}
-
-QString QFont::lastResortFamily() const
-{
- return QString::fromLatin1("helvetica");
-}
-
-QString QFont::lastResortFont() const
-{
- qFatal("QFont::lastResortFont: Cannot find any reasonable font");
- // Shut compiler up
- return QString();
-}
-
-
-QT_END_NAMESPACE
diff --git a/src/gui/text/qfontdatabase.cpp b/src/gui/text/qfontdatabase.cpp
index 36b0ea9b68..0381286f10 100644
--- a/src/gui/text/qfontdatabase.cpp
+++ b/src/gui/text/qfontdatabase.cpp
@@ -43,7 +43,7 @@
#include "qfontdatabase.h"
#include "qdebug.h"
#include "qalgorithms.h"
-#include "qapplication.h"
+#include "qguiapplication.h"
#include "qvarlengtharray.h" // here or earlier - workaround for VC++6
#include "qthread.h"
#include "qmutex.h"
@@ -51,7 +51,7 @@
#include "qfontengine_p.h"
#ifdef Q_WS_QPA
-#include <QtGui/private/qapplication_p.h>
+#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/qplatformfontdatabase_qpa.h>
#include "qabstractfileengine.h"
#endif
@@ -103,34 +103,34 @@ static int getFontWeight(const QString &weightString)
// Test in decreasing order of commonness
if (s == QLatin1String("medium") ||
s == QLatin1String("normal")
- || s.compare(QApplication::translate("QFontDatabase", "Normal"), Qt::CaseInsensitive) == 0)
+ || s.compare(QCoreApplication::translate("QFontDatabase", "Normal"), Qt::CaseInsensitive) == 0)
return QFont::Normal;
if (s == QLatin1String("bold")
- || s.compare(QApplication::translate("QFontDatabase", "Bold"), Qt::CaseInsensitive) == 0)
+ || s.compare(QCoreApplication::translate("QFontDatabase", "Bold"), Qt::CaseInsensitive) == 0)
return QFont::Bold;
if (s == QLatin1String("demibold") || s == QLatin1String("demi bold")
- || s.compare(QApplication::translate("QFontDatabase", "Demi Bold"), Qt::CaseInsensitive) == 0)
+ || s.compare(QCoreApplication::translate("QFontDatabase", "Demi Bold"), Qt::CaseInsensitive) == 0)
return QFont::DemiBold;
if (s == QLatin1String("black")
- || s.compare(QApplication::translate("QFontDatabase", "Black"), Qt::CaseInsensitive) == 0)
+ || s.compare(QCoreApplication::translate("QFontDatabase", "Black"), Qt::CaseInsensitive) == 0)
return QFont::Black;
if (s == QLatin1String("light"))
return QFont::Light;
if (s.contains(QLatin1String("bold"))
- || s.contains(QApplication::translate("QFontDatabase", "Bold"), Qt::CaseInsensitive)) {
+ || s.contains(QCoreApplication::translate("QFontDatabase", "Bold"), Qt::CaseInsensitive)) {
if (s.contains(QLatin1String("demi"))
- || s.compare(QApplication::translate("QFontDatabase", "Demi"), Qt::CaseInsensitive) == 0)
+ || s.compare(QCoreApplication::translate("QFontDatabase", "Demi"), Qt::CaseInsensitive) == 0)
return (int) QFont::DemiBold;
return (int) QFont::Bold;
}
if (s.contains(QLatin1String("light"))
- || s.compare(QApplication::translate("QFontDatabase", "Light"), Qt::CaseInsensitive) == 0)
+ || s.compare(QCoreApplication::translate("QFontDatabase", "Light"), Qt::CaseInsensitive) == 0)
return (int) QFont::Light;
if (s.contains(QLatin1String("black"))
- || s.compare(QApplication::translate("QFontDatabase", "Black"), Qt::CaseInsensitive) == 0)
+ || s.compare(QCoreApplication::translate("QFontDatabase", "Black"), Qt::CaseInsensitive) == 0)
return (int) QFont::Black;
return (int) QFont::Normal;
@@ -264,7 +264,7 @@ struct QtFontStyle
pixelSizes[count].fileName.~QByteArray();
#endif
#if defined (Q_WS_QPA)
- QPlatformIntegration *integration = QApplicationPrivate::platformIntegration();
+ QPlatformIntegration *integration = QGuiApplicationPrivate::platformIntegration();
if (integration) { //on shut down there will be some that we don't release.
integration->fontDatabase()->releaseHandle(pixelSizes[count].handle);
}
@@ -297,10 +297,10 @@ QtFontStyle::Key::Key(const QString &styleString)
weight = getFontWeight(styleString);
if (styleString.contains(QLatin1String("Italic"))
- || styleString.contains(QApplication::translate("QFontDatabase", "Italic")))
+ || styleString.contains(QCoreApplication::translate("QFontDatabase", "Italic")))
style = QFont::StyleItalic;
else if (styleString.contains(QLatin1String("Oblique"))
- || styleString.contains(QApplication::translate("QFontDatabase", "Oblique")))
+ || styleString.contains(QCoreApplication::translate("QFontDatabase", "Oblique")))
style = QFont::StyleOblique;
}
@@ -748,7 +748,7 @@ void QFontDatabasePrivate::invalidate()
{
QFontCache::instance()->clear();
free();
- emit static_cast<QApplication *>(QApplication::instance())->fontDatabaseChanged();
+ emit static_cast<QGuiApplication *>(QCoreApplication::instance())->fontDatabaseChanged();
}
QtFontFamily *QFontDatabasePrivate::family(const QString &f, bool create)
@@ -1506,21 +1506,21 @@ static QString styleStringHelper(int weight, QFont::Style style)
{
QString result;
if (weight >= QFont::Black)
- result = QApplication::translate("QFontDatabase", "Black");
+ result = QCoreApplication::translate("QFontDatabase", "Black");
else if (weight >= QFont::Bold)
- result = QApplication::translate("QFontDatabase", "Bold");
+ result = QCoreApplication::translate("QFontDatabase", "Bold");
else if (weight >= QFont::DemiBold)
- result = QApplication::translate("QFontDatabase", "Demi Bold");
+ result = QCoreApplication::translate("QFontDatabase", "Demi Bold");
else if (weight < QFont::Normal)
- result = QApplication::translate("QFontDatabase", "Light");
+ result = QCoreApplication::translate("QFontDatabase", "Light");
if (style == QFont::StyleItalic)
- result += QLatin1Char(' ') + QApplication::translate("QFontDatabase", "Italic");
+ result += QLatin1Char(' ') + QCoreApplication::translate("QFontDatabase", "Italic");
else if (style == QFont::StyleOblique)
- result += QLatin1Char(' ') + QApplication::translate("QFontDatabase", "Oblique");
+ result += QLatin1Char(' ') + QCoreApplication::translate("QFontDatabase", "Oblique");
if (result.isEmpty())
- result = QApplication::translate("QFontDatabase", "Normal");
+ result = QCoreApplication::translate("QFontDatabase", "Normal");
return result.simplified();
}
@@ -2002,7 +2002,7 @@ QFont QFontDatabase::font(const QString &family, const QString &style,
QtFontFoundry allStyles(foundryName);
QtFontFamily *f = d->family(familyName);
- if (!f) return QApplication::font();
+ if (!f) return QGuiApplication::font();
for (int j = 0; j < f->count; j++) {
QtFontFoundry *foundry = f->foundries[j];
@@ -2016,7 +2016,7 @@ QFont QFontDatabase::font(const QString &family, const QString &style,
QtFontStyle *s = bestStyle(&allStyles, styleKey);
if (!s) // no styles found?
- return QApplication::font();
+ return QGuiApplication::font();
QFont fnt(family, pointSize, s->key.weight);
fnt.setStyle((QFont::Style)s->key.style);
return fnt;
@@ -2326,7 +2326,7 @@ QString QFontDatabase::writingSystemName(WritingSystem writingSystem)
Q_ASSERT_X(false, "QFontDatabase::writingSystemName", "invalid 'writingSystem' parameter");
break;
}
- return QApplication::translate("QFontDatabase", name);
+ return QCoreApplication::translate("QFontDatabase", name);
}
diff --git a/src/gui/text/qfontdatabase.h b/src/gui/text/qfontdatabase.h
index ae1130eadc..c9ca5dcb60 100644
--- a/src/gui/text/qfontdatabase.h
+++ b/src/gui/text/qfontdatabase.h
@@ -45,10 +45,6 @@
#include <QtGui/qwindowdefs.h>
#include <QtCore/qstring.h>
#include <QtGui/qfont.h>
-#ifdef QT3_SUPPORT
-#include <QtCore/qstringlist.h>
-#include <QtCore/qlist.h>
-#endif
QT_BEGIN_HEADER
diff --git a/src/gui/text/qfontdatabase_qpa.cpp b/src/gui/text/qfontdatabase_qpa.cpp
index 7bcce56ac8..fcf87f6379 100644
--- a/src/gui/text/qfontdatabase_qpa.cpp
+++ b/src/gui/text/qfontdatabase_qpa.cpp
@@ -45,7 +45,7 @@
#include "qfontengine_qpa_p.h"
#include "qplatformdefs.h"
-#include <QtGui/private/qapplication_p.h>
+#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/qplatformfontdatabase_qpa.h>
#include <QtCore/qmath.h>
@@ -82,7 +82,7 @@ Q_GUI_EXPORT void qt_registerFont(const QString &familyName, const QString &fou
static QStringList fallbackFamilies(const QString &family, const QFont::Style &style, const QFont::StyleHint &styleHint, const QUnicodeTables::Script &script)
{
- QStringList retList = QApplicationPrivate::platformIntegration()->fontDatabase()->fallbacksForFamily(family,style,styleHint,script);
+ QStringList retList = QGuiApplicationPrivate::platformIntegration()->fontDatabase()->fallbacksForFamily(family,style,styleHint,script);
QFontDatabasePrivate *db = privateDb();
QStringList::iterator i;
@@ -109,28 +109,11 @@ static void initializeDb()
if (!initialized) {
//init by asking for the platformfontdb for the first time :)
- QApplicationPrivate::platformIntegration()->fontDatabase()->populateFontDatabase();
+ QGuiApplicationPrivate::platformIntegration()->fontDatabase()->populateFontDatabase();
initialized = true;
}
}
-#ifndef QT_NO_SETTINGS
-// called from qapplication_qws.cpp
-void qt_applyFontDatabaseSettings(const QSettings &settings)
-{
- initializeDb();
- QFontDatabasePrivate *db = privateDb();
- for (int i = 0; i < db->count; ++i) {
- QtFontFamily *family = db->families[i];
- if (settings.contains(family->name))
- family->fallbackFamilies = settings.value(family->name).toStringList();
- }
-
- if (settings.contains(QLatin1String("Global Fallbacks")))
- db->fallbackFamilies = settings.value(QLatin1String("Global Fallbacks")).toStringList();
-}
-#endif // QT_NO_SETTINGS
-
static inline void load(const QString & = QString(), int = -1)
{
initializeDb();
@@ -155,7 +138,7 @@ QFontEngine *loadSingleEngine(int script,
QFontCache::Key key(def,script);
QFontEngine *engine = QFontCache::instance()->findEngine(key);
if (!engine) {
- QPlatformFontDatabase *pfdb = QApplicationPrivate::platformIntegration()->fontDatabase();
+ QPlatformFontDatabase *pfdb = QGuiApplicationPrivate::platformIntegration()->fontDatabase();
engine = pfdb->fontEngine(def,QUnicodeTables::Script(script),size->handle);
if (engine) {
QFontCache::Key key(def,script);
@@ -200,7 +183,7 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
{
QFontDatabasePrivate *db = privateDb();
- fnt->families = QApplicationPrivate::platformIntegration()->fontDatabase()->addApplicationFont(fnt->data,fnt->fileName);
+ fnt->families = QGuiApplicationPrivate::platformIntegration()->fontDatabase()->addApplicationFont(fnt->data,fnt->fileName);
db->reregisterAppFonts = true;
}
@@ -360,7 +343,7 @@ void QFontDatabase::load(const QFontPrivate *d, int script)
family_list = familyList(req);
// add the default family
- QString defaultFamily = QApplication::font().family();
+ QString defaultFamily = QGuiApplication::font().family();
if (! family_list.contains(defaultFamily))
family_list << defaultFamily;
diff --git a/src/gui/text/qfontdatabase_qws.cpp b/src/gui/text/qfontdatabase_qws.cpp
deleted file mode 100644
index d076de05d3..0000000000
--- a/src/gui/text/qfontdatabase_qws.cpp
+++ /dev/null
@@ -1,975 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdir.h"
-#if defined(Q_WS_QWS)
-#include "qscreen_qws.h" //so we can check for rotation
-#include "qwindowsystem_qws.h"
-#endif
-#include "qlibraryinfo.h"
-#include "qabstractfileengine.h"
-#include <QtCore/qsettings.h>
-#if !defined(QT_NO_FREETYPE)
-#include "qfontengine_ft_p.h"
-
-#include <ft2build.h>
-#include FT_FREETYPE_H
-
-#endif
-#include "qfontengine_qpf_p.h"
-#include "private/qfactoryloader_p.h"
-#include "private/qcore_unix_p.h" // overrides QT_OPEN
-#include "qabstractfontengine_qws.h"
-#include "qabstractfontengine_p.h"
-#include <qdatetime.h>
-#include "qplatformdefs.h"
-
-// for mmap
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-#include <errno.h>
-
-#ifdef QT_FONTS_ARE_RESOURCES
-#include <qresource.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_LIBRARY
-Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
- (QFontEngineFactoryInterface_iid, QLatin1String("/fontengines"), Qt::CaseInsensitive))
-#endif
-
-const quint8 DatabaseVersion = 4;
-
-// QFontDatabasePrivate::addFont() went into qfontdatabase.cpp
-
-#ifndef QT_NO_QWS_QPF2
-void QFontDatabasePrivate::addQPF2File(const QByteArray &file)
-{
-#ifndef QT_FONTS_ARE_RESOURCES
- struct stat st;
- if (stat(file.constData(), &st))
- return;
- int f = QT_OPEN(file, O_RDONLY, 0);
- if (f < 0)
- return;
- const uchar *data = (const uchar *)mmap(0, st.st_size, PROT_READ, MAP_SHARED, f, 0);
- const int dataSize = st.st_size;
-#else
- QResource res(QLatin1String(file.constData()));
- const uchar *data = res.data();
- const int dataSize = res.size();
- //qDebug() << "addQPF2File" << file << data;
-#endif
- if (data && data != (const uchar *)MAP_FAILED) {
- if (QFontEngineQPF::verifyHeader(data, dataSize)) {
- QString fontName = QFontEngineQPF::extractHeaderField(data, QFontEngineQPF::Tag_FontName).toString();
- int pixelSize = QFontEngineQPF::extractHeaderField(data, QFontEngineQPF::Tag_PixelSize).toInt();
- QVariant weight = QFontEngineQPF::extractHeaderField(data, QFontEngineQPF::Tag_Weight);
- QVariant style = QFontEngineQPF::extractHeaderField(data, QFontEngineQPF::Tag_Style);
- QByteArray writingSystemBits = QFontEngineQPF::extractHeaderField(data, QFontEngineQPF::Tag_WritingSystems).toByteArray();
-
- if (!fontName.isEmpty() && pixelSize) {
- int fontWeight = 50;
- if (weight.type() == QVariant::Int || weight.type() == QVariant::UInt)
- fontWeight = weight.toInt();
-
- bool italic = static_cast<QFont::Style>(style.toInt()) & QFont::StyleItalic;
-
- QList<QFontDatabase::WritingSystem> writingSystems;
- for (int i = 0; i < writingSystemBits.count(); ++i) {
- uchar currentByte = writingSystemBits.at(i);
- for (int j = 0; j < 8; ++j) {
- if (currentByte & 1)
- writingSystems << QFontDatabase::WritingSystem(i * 8 + j);
- currentByte >>= 1;
- }
- }
-
- addFont(fontName, /*foundry*/ "prerendered", fontWeight, italic,
- pixelSize, file, /*fileIndex*/ 0,
- /*antialiased*/ true, writingSystems);
- }
- } else {
- qDebug() << "header verification of QPF2 font" << file << "failed. maybe it is corrupt?";
- }
-#ifndef QT_FONTS_ARE_RESOURCES
- munmap((void *)data, st.st_size);
-#endif
- }
-#ifndef QT_FONTS_ARE_RESOURCES
- QT_CLOSE(f);
-#endif
-}
-#endif // QT_NO_QWS_QPF2
-
-// QFontDatabasePrivate::addTTFile() went into qfontdatabase.cpp
-
-static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt);
-
-extern QString qws_fontCacheDir();
-
-#ifndef QT_FONTS_ARE_RESOURCES
-bool QFontDatabasePrivate::loadFromCache(const QString &fontPath)
-{
-#ifdef Q_WS_QWS
- const bool weAreTheServer = QWSServer::instance();
-#else
- const bool weAreTheServer = true; // assume single-process
-#endif
-
- QString fontDirFile = fontPath + QLatin1String("/fontdir");
-
- QFile binaryDb(qws_fontCacheDir() + QLatin1String("/fontdb"));
-
- if (weAreTheServer) {
- QDateTime dbTimeStamp = QFileInfo(binaryDb.fileName()).lastModified();
-
- QDateTime fontPathTimeStamp = QFileInfo(fontPath).lastModified();
- if (dbTimeStamp < fontPathTimeStamp)
- return false; // let the caller create the cache
-
- if (QFile::exists(fontDirFile)) {
- QDateTime fontDirTimeStamp = QFileInfo(fontDirFile).lastModified();
- if (dbTimeStamp < fontDirTimeStamp)
- return false;
- }
- }
-
- if (!binaryDb.open(QIODevice::ReadOnly)) {
- if (weAreTheServer)
- return false; // let the caller create the cache
- qFatal("QFontDatabase::loadFromCache: Could not open font database cache!");
- }
-
- QDataStream stream(&binaryDb);
- quint8 version = 0;
- quint8 dataStreamVersion = 0;
- stream >> version >> dataStreamVersion;
- if (version != DatabaseVersion || dataStreamVersion != stream.version()) {
- if (weAreTheServer)
- return false; // let the caller create the cache
- qFatal("QFontDatabase::loadFromCache: Wrong version of the font database cache detected. Found %d/%d expected %d/%d",
- version, dataStreamVersion, DatabaseVersion, stream.version());
- }
-
- QString originalFontPath;
- stream >> originalFontPath;
- if (originalFontPath != fontPath) {
- if (weAreTheServer)
- return false; // let the caller create the cache
- qFatal("QFontDatabase::loadFromCache: Font path doesn't match. Found %s in database, expected %s", qPrintable(originalFontPath), qPrintable(fontPath));
- }
-
- QString familyname;
- stream >> familyname;
- //qDebug() << "populating database from" << binaryDb.fileName();
- while (!familyname.isEmpty() && !stream.atEnd()) {
- QString foundryname;
- int weight;
- quint8 italic;
- int pixelSize;
- QByteArray file;
- int fileIndex;
- quint8 antialiased;
- quint8 writingSystemCount;
-
- QList<QFontDatabase::WritingSystem> writingSystems;
-
- stream >> foundryname >> weight >> italic >> pixelSize
- >> file >> fileIndex >> antialiased >> writingSystemCount;
-
- for (quint8 i = 0; i < writingSystemCount; ++i) {
- quint8 ws;
- stream >> ws;
- writingSystems.append(QFontDatabase::WritingSystem(ws));
- }
-
- addFont(familyname, foundryname.toLatin1().constData(), weight, italic, pixelSize, file, fileIndex, antialiased,
- writingSystems);
-
- stream >> familyname;
- }
-
- stream >> fallbackFamilies;
- //qDebug() << "fallback families from cache:" << fallbackFamilies;
- return true;
-}
-#endif // QT_FONTS_ARE_RESOURCES
-
-/*!
- \internal
-*/
-
-static QString qwsFontPath()
-{
- QString fontpath = QString::fromLocal8Bit(qgetenv("QT_QWS_FONTDIR"));
- if (fontpath.isEmpty()) {
-#ifdef QT_FONTS_ARE_RESOURCES
- fontpath = QLatin1String(":/qt/fonts");
-#else
-#ifndef QT_NO_SETTINGS
- fontpath = QLibraryInfo::location(QLibraryInfo::LibrariesPath);
- fontpath += QLatin1String("/fonts");
-#else
- fontpath = QLatin1String("/lib/fonts");
-#endif
-#endif //QT_FONTS_ARE_RESOURCES
- }
-
- return fontpath;
-}
-
-#if defined(QFONTDATABASE_DEBUG) && defined(QT_FONTS_ARE_RESOURCES)
-class FriendlyResource : public QResource
-{
-public:
- bool isDir () const { return QResource::isDir(); }
- bool isFile () const { return QResource::isFile(); }
- QStringList children () const { return QResource::children(); }
-};
-#endif
-/*!
- \internal
-*/
-static void initializeDb()
-{
- QFontDatabasePrivate *db = privateDb();
- if (!db || db->count)
- return;
-
- QString fontpath = qwsFontPath();
-#ifndef QT_FONTS_ARE_RESOURCES
- QString fontDirFile = fontpath + QLatin1String("/fontdir");
-
- if(!QFile::exists(fontpath)) {
- qFatal("QFontDatabase: Cannot find font directory %s - is Qt installed correctly?",
- fontpath.toLocal8Bit().constData());
- }
-
- const bool loaded = db->loadFromCache(fontpath);
-
- if (db->reregisterAppFonts) {
- db->reregisterAppFonts = false;
- for (int i = 0; i < db->applicationFonts.count(); ++i)
- if (!db->applicationFonts.at(i).families.isEmpty()) {
- registerFont(&db->applicationFonts[i]);
- }
- }
-
- if (loaded)
- return;
-
- QString dbFileName = qws_fontCacheDir() + QLatin1String("/fontdb");
-
- QFile binaryDb(dbFileName + QLatin1String(".tmp"));
- binaryDb.open(QIODevice::WriteOnly | QIODevice::Truncate);
- db->stream = new QDataStream(&binaryDb);
- *db->stream << DatabaseVersion << quint8(db->stream->version()) << fontpath;
-// qDebug() << "creating binary database at" << binaryDb.fileName();
-
- // Load in font definition file
- FILE* fontdef=fopen(fontDirFile.toLocal8Bit().constData(),"r");
- if (fontdef) {
- char buf[200]="";
- char name[200]="";
- char render[200]="";
- char file[200]="";
- char isitalic[10]="";
- char flags[10]="";
- do {
- fgets(buf,200,fontdef);
- if (buf[0] != '#') {
- int weight=50;
- int size=0;
- sscanf(buf,"%s %s %s %s %d %d %s",name,file,render,isitalic,&weight,&size,flags);
- QString filename;
- if (file[0] != '/')
- filename.append(fontpath).append(QLatin1Char('/'));
- filename += QLatin1String(file);
- bool italic = isitalic[0] == 'y';
- bool smooth = QByteArray(flags).contains('s');
- if (file[0] && QFile::exists(filename))
- db->addFont(QString::fromUtf8(name), /*foundry*/"", weight, italic, size/10, QFile::encodeName(filename), /*fileIndex*/ 0, smooth);
- }
- } while (!feof(fontdef));
- fclose(fontdef);
- }
-
-
- QDir dir(fontpath, QLatin1String("*.qpf"));
- for (int i=0; i<int(dir.count()); i++) {
- int u0 = dir[i].indexOf(QLatin1Char('_'));
- int u1 = dir[i].indexOf(QLatin1Char('_'), u0+1);
- int u2 = dir[i].indexOf(QLatin1Char('_'), u1+1);
- int u3 = dir[i].indexOf(QLatin1Char('.'), u1+1);
- if (u2 < 0) u2 = u3;
-
- QString familyname = dir[i].left(u0);
- int pixelSize = dir[i].mid(u0+1,u1-u0-1).toInt()/10;
- bool italic = dir[i].mid(u2-1,1) == QLatin1String("i");
- int weight = dir[i].mid(u1+1,u2-u1-1-(italic?1:0)).toInt();
-
- db->addFont(familyname, /*foundry*/ "qt", weight, italic, pixelSize, QFile::encodeName(dir.absoluteFilePath(dir[i])),
- /*fileIndex*/ 0, /*antialiased*/ true);
- }
-
-#ifndef QT_NO_FREETYPE
- dir.setNameFilters(QStringList() << QLatin1String("*.ttf")
- << QLatin1String("*.ttc") << QLatin1String("*.pfa")
- << QLatin1String("*.pfb"));
- dir.refresh();
- for (int i = 0; i < int(dir.count()); ++i) {
- const QByteArray file = QFile::encodeName(dir.absoluteFilePath(dir[i]));
-// qDebug() << "looking at" << file;
- db->addTTFile(file);
- }
-#endif
-
-#ifndef QT_NO_QWS_QPF2
- dir.setNameFilters(QStringList() << QLatin1String("*.qpf2"));
- dir.refresh();
- for (int i = 0; i < int(dir.count()); ++i) {
- const QByteArray file = QFile::encodeName(dir.absoluteFilePath(dir[i]));
-// qDebug() << "looking at" << file;
- db->addQPF2File(file);
- }
-#endif
-
-#else //QT_FONTS_ARE_RESOURCES
-#ifdef QFONTDATABASE_DEBUG
- {
- QResource fontdir(fontpath);
- FriendlyResource *fr = static_cast<FriendlyResource*>(&fontdir);
- qDebug() << "fontdir" << fr->isValid() << fr->isDir() << fr->children();
-
- }
-#endif
-#ifndef QT_NO_QWS_QPF2
- QDir dir(fontpath, QLatin1String("*.qpf2"));
- for (int i = 0; i < int(dir.count()); ++i) {
- const QByteArray file = QFile::encodeName(dir.absoluteFilePath(dir[i]));
- //qDebug() << "looking at" << file;
- db->addQPF2File(file);
- }
-#endif
-#endif //QT_FONTS_ARE_RESOURCES
-
-
-#ifdef QFONTDATABASE_DEBUG
- // print the database
- for (int f = 0; f < db->count; f++) {
- QtFontFamily *family = db->families[f];
- FD_DEBUG("'%s' %s", qPrintable(family->name), (family->fixedPitch ? "fixed" : ""));
-#if 0
- for (int i = 0; i < QFont::LastPrivateScript; ++i) {
- FD_DEBUG("\t%s: %s", qPrintable(QFontDatabase::scriptName((QFont::Script) i)),
- ((family->scripts[i] & QtFontFamily::Supported) ? "Supported" :
- (family->scripts[i] & QtFontFamily::UnSupported) == QtFontFamily::UnSupported ?
- "UnSupported" : "Unknown"));
- }
-#endif
-
- for (int fd = 0; fd < family->count; fd++) {
- QtFontFoundry *foundry = family->foundries[fd];
- FD_DEBUG("\t\t'%s'", qPrintable(foundry->name));
- for (int s = 0; s < foundry->count; s++) {
- QtFontStyle *style = foundry->styles[s];
- FD_DEBUG("\t\t\tstyle: style=%d weight=%d\n"
- "\t\t\tstretch=%d",
- style->key.style, style->key.weight,
- style->key.stretch);
- if (style->smoothScalable)
- FD_DEBUG("\t\t\t\tsmooth scalable");
- else if (style->bitmapScalable)
- FD_DEBUG("\t\t\t\tbitmap scalable");
- if (style->pixelSizes) {
- FD_DEBUG("\t\t\t\t%d pixel sizes", style->count);
- for (int z = 0; z < style->count; ++z) {
- QtFontSize *size = style->pixelSizes + z;
- FD_DEBUG("\t\t\t\t size %5d",
- size->pixelSize);
- }
- }
- }
- }
- }
-#endif // QFONTDATABASE_DEBUG
-
-#ifndef QT_NO_LIBRARY
- QStringList pluginFoundries = loader()->keys();
-// qDebug() << "plugin foundries:" << pluginFoundries;
- for (int i = 0; i < pluginFoundries.count(); ++i) {
- const QString foundry(pluginFoundries.at(i));
-
- QFontEngineFactoryInterface *factory = qobject_cast<QFontEngineFactoryInterface *>(loader()->instance(foundry));
- if (!factory) {
- qDebug() << "Could not load plugin for foundry" << foundry;
- continue;
- }
-
- QList<QFontEngineInfo> fonts = factory->availableFontEngines();
- for (int i = 0; i < fonts.count(); ++i) {
- QFontEngineInfo info = fonts.at(i);
-
- int weight = info.weight();
- if (weight <= 0)
- weight = QFont::Normal;
-
- db->addFont(info.family(), foundry.toLatin1().constData(),
- weight, info.style() != QFont::StyleNormal,
- qRound(info.pixelSize()), /*file*/QByteArray(),
- /*fileIndex*/0, /*antiAliased*/true,
- info.writingSystems());
- }
- }
-#endif
-
-#ifndef QT_FONTS_ARE_RESOURCES
- // the empty string/familyname signifies the end of the font list.
- *db->stream << QString();
-#endif
- {
- bool coveredWritingSystems[QFontDatabase::WritingSystemsCount] = { 0 };
-
- db->fallbackFamilies.clear();
-
- for (int i = 0; i < db->count; ++i) {
- QtFontFamily *family = db->families[i];
- bool add = false;
- if (family->count == 0)
- continue;
- if (family->bogusWritingSystems)
- continue;
- for (int ws = 1; ws < QFontDatabase::WritingSystemsCount; ++ws) {
- if (coveredWritingSystems[ws])
- continue;
- if (family->writingSystems[ws] & QtFontFamily::Supported) {
- coveredWritingSystems[ws] = true;
- add = true;
- }
- }
- if (add)
- db->fallbackFamilies << family->name;
- }
- //qDebug() << "fallbacks on the server:" << db->fallbackFamilies;
-#ifndef QT_FONTS_ARE_RESOURCES
- *db->stream << db->fallbackFamilies;
-#endif
- }
-#ifndef QT_FONTS_ARE_RESOURCES
- delete db->stream;
- db->stream = 0;
- QFile::remove(dbFileName);
- binaryDb.rename(dbFileName);
-#endif
-}
-
-// called from qwindowsystem_qws.cpp
-void qt_qws_init_fontdb()
-{
- initializeDb();
-}
-
-#ifndef QT_NO_SETTINGS
-// called from qapplication_qws.cpp
-void qt_applyFontDatabaseSettings(const QSettings &settings)
-{
- initializeDb();
- QFontDatabasePrivate *db = privateDb();
- for (int i = 0; i < db->count; ++i) {
- QtFontFamily *family = db->families[i];
- if (settings.contains(family->name))
- family->fallbackFamilies = settings.value(family->name).toStringList();
- }
-
- if (settings.contains(QLatin1String("Global Fallbacks")))
- db->fallbackFamilies = settings.value(QLatin1String("Global Fallbacks")).toStringList();
-}
-#endif // QT_NO_SETTINGS
-
-static inline void load(const QString & = QString(), int = -1)
-{
- initializeDb();
-}
-
-#ifndef QT_NO_FREETYPE
-
-#if (FREETYPE_MAJOR*10000+FREETYPE_MINOR*100+FREETYPE_PATCH) >= 20105
-#define X_SIZE(face,i) ((face)->available_sizes[i].x_ppem)
-#define Y_SIZE(face,i) ((face)->available_sizes[i].y_ppem)
-#else
-#define X_SIZE(face,i) ((face)->available_sizes[i].width << 6)
-#define Y_SIZE(face,i) ((face)->available_sizes[i].height << 6)
-#endif
-
-#endif // QT_NO_FREETYPE
-
-static
-QFontEngine *loadSingleEngine(int script, const QFontPrivate *fp,
- const QFontDef &request,
- QtFontFamily *family, QtFontFoundry *foundry,
- QtFontStyle *style, QtFontSize *size)
-{
- Q_UNUSED(script);
- Q_UNUSED(fp);
-#ifdef QT_NO_FREETYPE
- Q_UNUSED(foundry);
-#endif
-#ifdef QT_NO_QWS_QPF
- Q_UNUSED(family);
-#endif
- Q_ASSERT(size);
-
- int pixelSize = size->pixelSize;
- if (!pixelSize || (style->smoothScalable && pixelSize == SMOOTH_SCALABLE))
- pixelSize = request.pixelSize;
-
-#ifndef QT_NO_QWS_QPF2
- if (foundry->name == QLatin1String("prerendered")) {
-#ifdef QT_FONTS_ARE_RESOURCES
- QResource res(QLatin1String(size->fileName.constData()));
- if (res.isValid()) {
- QFontEngineQPF *fe = new QFontEngineQPF(request, res.data(), res.size());
- if (fe->isValid())
- return fe;
- delete fe;
- qDebug() << "fontengine is not valid! " << size->fileName;
- } else {
- qDebug() << "Resource not valid" << size->fileName;
- }
-#else
- int f = ::open(size->fileName, O_RDONLY, 0);
- if (f >= 0) {
- QFontEngineQPF *fe = new QFontEngineQPF(request, f);
- if (fe->isValid())
- return fe;
- delete fe; // will close f
- qDebug() << "fontengine is not valid!";
- }
-#endif
- } else
-#endif
- if ( foundry->name != QLatin1String("qt") ) { ///#### is this the best way????
- QString file = QFile::decodeName(size->fileName);
-
- QFontDef def = request;
- def.pixelSize = pixelSize;
-
-#ifdef QT_NO_QWS_SHARE_FONTS
- bool shareFonts = false;
-#else
- static bool dontShareFonts = !qgetenv("QWS_NO_SHARE_FONTS").isEmpty();
- bool shareFonts = !dontShareFonts;
-#endif
-
- QScopedPointer<QFontEngine> engine;
-
-#ifndef QT_NO_LIBRARY
- QFontEngineFactoryInterface *factory = qobject_cast<QFontEngineFactoryInterface *>(loader()->instance(foundry->name));
- if (factory) {
- QFontEngineInfo info;
- info.setFamily(request.family);
- info.setPixelSize(request.pixelSize);
- info.setStyle(QFont::Style(request.style));
- info.setWeight(request.weight);
- // #### antialiased
-
- QAbstractFontEngine *customEngine = factory->create(info);
- if (customEngine) {
- engine.reset(new QProxyFontEngine(customEngine, def));
-
- if (shareFonts) {
- QVariant hint = customEngine->fontProperty(QAbstractFontEngine::CacheGlyphsHint);
- if (hint.isValid())
- shareFonts = hint.toBool();
- else
- shareFonts = (pixelSize < 64);
- }
- }
- }
-#endif // QT_NO_LIBRARY
- if ((engine.isNull() && !file.isEmpty() && QFile::exists(file)) || privateDb()->isApplicationFont(file)) {
- QFontEngine::FaceId faceId;
- faceId.filename = file.toLocal8Bit();
- faceId.index = size->fileIndex;
-
-#ifndef QT_NO_FREETYPE
-
- QScopedPointer<QFontEngineFT> fte(new QFontEngineFT(def));
- bool antialias = style->antialiased && !(request.styleStrategy & QFont::NoAntialias);
- if (fte->init(faceId, antialias,
- antialias ? QFontEngineFT::Format_A8 : QFontEngineFT::Format_Mono)) {
-#ifdef QT_NO_QWS_QPF2
- return fte.take();
-#else
- // try to distinguish between bdf and ttf fonts we can pre-render
- // and don't try to share outline fonts
- shareFonts = shareFonts
- && !fte->defaultGlyphs()->outline_drawing
- && !fte->getSfntTable(MAKE_TAG('h', 'e', 'a', 'd')).isEmpty();
- engine.reset(fte.take());
-#endif
- }
-#endif // QT_NO_FREETYPE
- }
- if (!engine.isNull()) {
-#if !defined(QT_NO_QWS_QPF2) && !defined(QT_FONTS_ARE_RESOURCES)
- if (shareFonts) {
- QScopedPointer<QFontEngineQPF> fe(new QFontEngineQPF(def, -1, engine.data()));
- engine.take();
- if (fe->isValid())
- return fe.take();
- qWarning("Initializing QFontEngineQPF failed for %s", qPrintable(file));
- engine.reset(fe->takeRenderingEngine());
- }
-#endif
- return engine.take();
- }
- } else
- {
-#ifndef QT_NO_QWS_QPF
- QString fn = qwsFontPath();
- fn += QLatin1Char('/');
- fn += family->name.toLower()
- + QLatin1Char('_') + QString::number(pixelSize*10)
- + QLatin1Char('_') + QString::number(style->key.weight)
- + (style->key.style == QFont::StyleItalic ?
- QLatin1String("i.qpf") : QLatin1String(".qpf"));
- //###rotation ###
-
- QFontEngine *fe = new QFontEngineQPF1(request, fn);
- return fe;
-#endif // QT_NO_QWS_QPF
- }
- return new QFontEngineBox(pixelSize);
-}
-
-static
-QFontEngine *loadEngine(int script, const QFontPrivate *fp,
- const QFontDef &request,
- QtFontFamily *family, QtFontFoundry *foundry,
- QtFontStyle *style, QtFontSize *size)
-{
- QScopedPointer<QFontEngine> engine(loadSingleEngine(script, fp, request, family, foundry,
- style, size));
-#ifndef QT_NO_QWS_QPF
- if (!engine.isNull()
- && script == QUnicodeTables::Common
- && !(request.styleStrategy & QFont::NoFontMerging) && !engine->symbol) {
-
- QStringList fallbacks = privateDb()->fallbackFamilies;
-
- if (family && !family->fallbackFamilies.isEmpty())
- fallbacks = family->fallbackFamilies;
-
- QFontEngine *fe = new QFontEngineMultiQWS(engine.data(), script, fallbacks);
- engine.take();
- engine.reset(fe);
- }
-#endif
- return engine.take();
-}
-
-static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
-{
- QFontDatabasePrivate *db = privateDb();
-#ifdef QT_NO_FREETYPE
- Q_UNUSED(fnt);
-#else
- fnt->families = db->addTTFile(QFile::encodeName(fnt->fileName), fnt->data);
- db->fallbackFamilies += fnt->families;
-#endif
- db->reregisterAppFonts = true;
-}
-
-bool QFontDatabase::removeApplicationFont(int handle)
-{
- QMutexLocker locker(fontDatabaseMutex());
-
- QFontDatabasePrivate *db = privateDb();
- if (handle < 0 || handle >= db->applicationFonts.count())
- return false;
-
- db->applicationFonts[handle] = QFontDatabasePrivate::ApplicationFont();
-
- db->reregisterAppFonts = true;
- db->invalidate();
- return true;
-}
-
-bool QFontDatabase::removeAllApplicationFonts()
-{
- QMutexLocker locker(fontDatabaseMutex());
-
- QFontDatabasePrivate *db = privateDb();
- if (db->applicationFonts.isEmpty())
- return false;
-
- db->applicationFonts.clear();
- db->invalidate();
- return true;
-}
-
-bool QFontDatabase::supportsThreadedFontRendering()
-{
- return true;
-}
-
-/*!
- \internal
-*/
-QFontEngine *
-QFontDatabase::findFont(int script, const QFontPrivate *fp,
- const QFontDef &request)
-{
- QMutexLocker locker(fontDatabaseMutex());
-
- const int force_encoding_id = -1;
-
- if (!privateDb()->count)
- initializeDb();
-
- QScopedPointer<QFontEngine> fe;
- if (fp) {
- if (fp->rawMode) {
- fe.reset(loadEngine(script, fp, request, 0, 0, 0, 0));
-
- // if we fail to load the rawmode font, use a 12pixel box engine instead
- if (fe.isNull())
- fe.reset(new QFontEngineBox(12));
- return fe.take();
- }
-
- QFontCache::Key key(request, script);
- fe.reset(QFontCache::instance()->findEngine(key));
- if (! fe.isNull())
- return fe.take();
- }
-
- QString family_name, foundry_name;
- QtFontStyle::Key styleKey;
- styleKey.style = request.style;
- styleKey.weight = request.weight;
- styleKey.stretch = request.stretch;
- char pitch = request.ignorePitch ? '*' : request.fixedPitch ? 'm' : 'p';
-
- parseFontName(request.family, foundry_name, family_name);
-
- FM_DEBUG("QFontDatabase::findFont\n"
- " request:\n"
- " family: %s [%s], script: %d\n"
- " weight: %d, style: %d\n"
- " stretch: %d\n"
- " pixelSize: %g\n"
- " pitch: %c",
- family_name.isEmpty() ? "-- first in script --" : family_name.toLatin1().constData(),
- foundry_name.isEmpty() ? "-- any --" : foundry_name.toLatin1().constData(),
- script, request.weight, request.style, request.stretch, request.pixelSize, pitch);
-
- if (qt_enable_test_font && request.family == QLatin1String("__Qt__Box__Engine__")) {
- fe.reset(new QTestFontEngine(request.pixelSize));
- fe->fontDef = request;
- }
-
- if (fe.isNull())
- {
- QtFontDesc desc;
- match(script, request, family_name, foundry_name, force_encoding_id, &desc);
-
- if (desc.family != 0 && desc.foundry != 0 && desc.style != 0
- ) {
- FM_DEBUG(" BEST:\n"
- " family: %s [%s]\n"
- " weight: %d, style: %d\n"
- " stretch: %d\n"
- " pixelSize: %d\n"
- " pitch: %c\n"
- " encoding: %d\n",
- desc.family->name.toLatin1().constData(),
- desc.foundry->name.isEmpty() ? "-- none --" : desc.foundry->name.toLatin1().constData(),
- desc.style->key.weight, desc.style->key.style,
- desc.style->key.stretch, desc.size ? desc.size->pixelSize : 0xffff,
- 'p', 0
- );
-
- fe.reset(loadEngine(script, fp, request, desc.family, desc.foundry, desc.style, desc.size
- ));
- } else {
- FM_DEBUG(" NO MATCH FOUND\n");
- }
- if (! fe.isNull())
- initFontDef(desc, request, &fe->fontDef);
- }
-
-#ifndef QT_NO_FREETYPE
- if (! fe.isNull()) {
- if (scriptRequiresOpenType(script) && fe->type() == QFontEngine::Freetype) {
- HB_Face hbFace = static_cast<QFontEngineFT *>(fe.data())->harfbuzzFace();
- if (!hbFace || !hbFace->supported_scripts[script]) {
- FM_DEBUG(" OpenType support missing for script\n");
- fe.reset(0);
- }
- }
- }
-#endif
-
- if (! fe.isNull()) {
- if (fp) {
- QFontDef def = request;
- if (def.family.isEmpty()) {
- def.family = fp->request.family;
- def.family = def.family.left(def.family.indexOf(QLatin1Char(',')));
- }
- QFontCache::Key key(def, script);
- QFontCache::instance()->insertEngine(key, fe.data());
- }
- }
-
- if (fe.isNull()) {
- if (!request.family.isEmpty())
- return 0;
-
- FM_DEBUG("returning box engine");
-
- fe.reset(new QFontEngineBox(request.pixelSize));
-
- if (fp) {
- QFontCache::Key key(request, script);
- QFontCache::instance()->insertEngine(key, fe.data());
- }
- }
-
- if (fp && fp->dpi > 0) {
- fe->fontDef.pointSize = qreal(double((fe->fontDef.pixelSize * 72) / fp->dpi));
- } else {
- fe->fontDef.pointSize = request.pointSize;
- }
-
- return fe.take();
-}
-
-void QFontDatabase::load(const QFontPrivate *d, int script)
-{
- QFontDef req = d->request;
-
- if (req.pixelSize == -1)
- req.pixelSize = qRound(req.pointSize*d->dpi/72);
- if (req.pointSize < 0)
- req.pointSize = req.pixelSize*72.0/d->dpi;
-
- if (!d->engineData) {
- QFontCache::Key key(req, script);
-
- // look for the requested font in the engine data cache
- d->engineData = QFontCache::instance()->findEngineData(key);
-
- if (!d->engineData) {
- // create a new one
- d->engineData = new QFontEngineData;
- QT_TRY {
- QFontCache::instance()->insertEngineData(key, d->engineData);
- } QT_CATCH(...) {
- delete d->engineData;
- d->engineData = 0;
- QT_RETHROW;
- }
- } else {
- d->engineData->ref.ref();
- }
- }
-
- // the cached engineData could have already loaded the engine we want
- if (d->engineData->engines[script]) return;
-
- // double scale = 1.0; // ### TODO: fix the scale calculations
-
- // list of families to try
- QStringList family_list;
-
- if (!req.family.isEmpty()) {
- family_list = req.family.split(QLatin1Char(','));
-
- // append the substitute list for each family in family_list
- QStringList subs_list;
- QStringList::ConstIterator it = family_list.constBegin(), end = family_list.constEnd();
- for (; it != end; ++it)
- subs_list += QFont::substitutes(*it);
- family_list += subs_list;
-
- // append the default fallback font for the specified script
- // family_list << ... ; ###########
-
- // add the default family
- QString defaultFamily = QApplication::font().family();
- if (! family_list.contains(defaultFamily))
- family_list << defaultFamily;
-
- // add QFont::defaultFamily() to the list, for compatibility with
- // previous versions
- family_list << QApplication::font().defaultFamily();
- }
-
- // null family means find the first font matching the specified script
- family_list << QString();
-
- // load the font
- QFontEngine *engine = 0;
- QStringList::ConstIterator it = family_list.constBegin(), end = family_list.constEnd();
- for (; !engine && it != end; ++it) {
- req.family = *it;
-
- engine = QFontDatabase::findFont(script, d, req);
- if (engine && (engine->type()==QFontEngine::Box) && !req.family.isEmpty())
- engine = 0;
- }
-
- engine->ref.ref();
- d->engineData->engines[script] = engine;
-}
-
-
-QT_END_NAMESPACE
diff --git a/src/gui/text/qfontengine_qpa.cpp b/src/gui/text/qfontengine_qpa.cpp
index 851bb5964c..b1d25b7d0f 100644
--- a/src/gui/text/qfontengine_qpa.cpp
+++ b/src/gui/text/qfontengine_qpa.cpp
@@ -46,7 +46,6 @@
#include <QtCore/QDir>
#include <QtCore/QBuffer>
-#include <QtGui/private/qapplication_p.h>
#include <QtGui/QPlatformFontDatabase>
#include <QtGui/private/qpaintengine_raster_p.h>
diff --git a/src/gui/text/qfontengine_qws.cpp b/src/gui/text/qfontengine_qws.cpp
deleted file mode 100644
index b71c4a7aba..0000000000
--- a/src/gui/text/qfontengine_qws.cpp
+++ /dev/null
@@ -1,665 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qfontengine_p.h"
-#include <private/qunicodetables_p.h>
-#include <qwsdisplay_qws.h>
-#include <qvarlengtharray.h>
-#include <private/qpainter_p.h>
-#include <private/qpaintengine_raster_p.h>
-#include <private/qpdf_p.h>
-#include "qtextengine_p.h"
-#include "private/qcore_unix_p.h" // overrides QT_OPEN
-
-#include <qdebug.h>
-
-
-#ifndef QT_NO_QWS_QPF
-
-#include "qfile.h"
-#include "qdir.h"
-
-#define QT_USE_MMAP
-#include <stdlib.h>
-
-#ifdef QT_USE_MMAP
-// for mmap
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <fcntl.h>
-#include <errno.h>
-
-# if defined(QT_LINUXBASE) && !defined(MAP_FILE)
- // LSB 3.2 does not define MAP_FILE
-# define MAP_FILE 0
-# endif
-
-#endif
-
-#endif // QT_NO_QWS_QPF
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_QWS_QPF
-QT_BEGIN_INCLUDE_NAMESPACE
-#include "qplatformdefs.h"
-QT_END_INCLUDE_NAMESPACE
-
-static inline unsigned int getChar(const QChar *str, int &i, const int len)
-{
- unsigned int uc = str[i].unicode();
- if (uc >= 0xd800 && uc < 0xdc00 && i < len-1) {
- uint low = str[i+1].unicode();
- if (low >= 0xdc00 && low < 0xe000) {
- uc = (uc - 0xd800)*0x400 + (low - 0xdc00) + 0x10000;
- ++i;
- }
- }
- return uc;
-}
-
-#define FM_SMOOTH 1
-
-
-class Q_PACKED QPFGlyphMetrics {
-
-public:
- quint8 linestep;
- quint8 width;
- quint8 height;
- quint8 flags;
-
- qint8 bearingx; // Difference from pen position to glyph's left bbox
- quint8 advance; // Difference between pen positions
- qint8 bearingy; // Used for putting characters on baseline
-
- qint8 reserved; // Do not use
-
- // Flags:
- // RendererOwnsData - the renderer is responsible for glyph data
- // memory deletion otherwise QPFGlyphTree must
- // delete [] the data when the glyph is deleted.
- enum Flags { RendererOwnsData=0x01 };
-};
-
-class QPFGlyph {
-public:
- QPFGlyph() { metrics=0; data=0; }
- QPFGlyph(QPFGlyphMetrics* m, uchar* d) :
- metrics(m), data(d) { }
- ~QPFGlyph() {}
-
- QPFGlyphMetrics* metrics;
- uchar* data;
-};
-
-struct Q_PACKED QPFFontMetrics{
- qint8 ascent,descent;
- qint8 leftbearing,rightbearing;
- quint8 maxwidth;
- qint8 leading;
- quint8 flags;
- quint8 underlinepos;
- quint8 underlinewidth;
- quint8 reserved3;
-};
-
-
-class QPFGlyphTree {
-public:
- /* reads in a tree like this:
-
- A-Z
- / \
- 0-9 a-z
-
- etc.
-
- */
- glyph_t min,max;
- QPFGlyphTree* less;
- QPFGlyphTree* more;
- QPFGlyph* glyph;
-public:
-#ifdef QT_USE_MMAP
- QPFGlyphTree(uchar*& data)
- {
- read(data);
- }
-#else
- QPFGlyphTree(QIODevice& f)
- {
- read(f);
- }
-#endif
-
- ~QPFGlyphTree()
- {
- // NOTE: does not delete glyph[*].metrics or .data.
- // the caller does this (only they know who owns
- // the data). See clear().
- delete less;
- delete more;
- delete [] glyph;
- }
-
- bool inFont(glyph_t g) const
- {
- if ( g < min ) {
- if ( !less )
- return false;
- return less->inFont(g);
- } else if ( g > max ) {
- if ( !more )
- return false;
- return more->inFont(g);
- }
- return true;
- }
-
- QPFGlyph* get(glyph_t g)
- {
- if ( g < min ) {
- if ( !less )
- return 0;
- return less->get(g);
- } else if ( g > max ) {
- if ( !more )
- return 0;
- return more->get(g);
- }
- return &glyph[g - min];
- }
- int totalChars() const
- {
- if ( !this ) return 0;
- return max-min+1 + less->totalChars() + more->totalChars();
- }
- int weight() const
- {
- if ( !this ) return 0;
- return 1 + less->weight() + more->weight();
- }
-
- void dump(int indent=0)
- {
- for (int i=0; i<indent; i++) printf(" ");
- printf("%d..%d",min,max);
- //if ( indent == 0 )
- printf(" (total %d)",totalChars());
- printf("\n");
- if ( less ) less->dump(indent+1);
- if ( more ) more->dump(indent+1);
- }
-
-private:
- QPFGlyphTree()
- {
- }
-
-#ifdef QT_USE_MMAP
- void read(uchar*& data)
- {
- // All node data first
- readNode(data);
- // Then all non-video data
- readMetrics(data);
- // Then all video data
- readData(data);
- }
-#else
- void read(QIODevice& f)
- {
- // All node data first
- readNode(f);
- // Then all non-video data
- readMetrics(f);
- // Then all video data
- readData(f);
- }
-#endif
-
-#ifdef QT_USE_MMAP
- void readNode(uchar*& data)
- {
- uchar rw = *data++;
- uchar cl = *data++;
- min = (rw << 8) | cl;
- rw = *data++;
- cl = *data++;
- max = (rw << 8) | cl;
- int flags = *data++;
- if ( flags & 1 )
- less = new QPFGlyphTree;
- else
- less = 0;
- if ( flags & 2 )
- more = new QPFGlyphTree;
- else
- more = 0;
- int n = max-min+1;
- glyph = new QPFGlyph[n];
-
- if ( less )
- less->readNode(data);
- if ( more )
- more->readNode(data);
- }
-#else
- void readNode(QIODevice& f)
- {
- char rw;
- char cl;
- f.getChar(&rw);
- f.getChar(&cl);
- min = (rw << 8) | cl;
- f.getChar(&rw);
- f.getChar(&cl);
- max = (rw << 8) | cl;
- char flags;
- f.getChar(&flags);
- if ( flags & 1 )
- less = new QPFGlyphTree;
- else
- less = 0;
- if ( flags & 2 )
- more = new QPFGlyphTree;
- else
- more = 0;
- int n = max-min+1;
- glyph = new QPFGlyph[n];
-
- if ( less )
- less->readNode(f);
- if ( more )
- more->readNode(f);
- }
-#endif
-
-#ifdef QT_USE_MMAP
- void readMetrics(uchar*& data)
- {
- int n = max-min+1;
- for (int i=0; i<n; i++) {
- glyph[i].metrics = (QPFGlyphMetrics*)data;
- data += sizeof(QPFGlyphMetrics);
- }
- if ( less )
- less->readMetrics(data);
- if ( more )
- more->readMetrics(data);
- }
-#else
- void readMetrics(QIODevice& f)
- {
- int n = max-min+1;
- for (int i=0; i<n; i++) {
- glyph[i].metrics = new QPFGlyphMetrics;
- f.read((char*)glyph[i].metrics, sizeof(QPFGlyphMetrics));
- }
- if ( less )
- less->readMetrics(f);
- if ( more )
- more->readMetrics(f);
- }
-#endif
-
-#ifdef QT_USE_MMAP
- void readData(uchar*& data)
- {
- int n = max-min+1;
- for (int i=0; i<n; i++) {
- QSize s( glyph[i].metrics->width, glyph[i].metrics->height );
- //######### s = qt_screen->mapToDevice( s );
- uint datasize = glyph[i].metrics->linestep * s.height();
- glyph[i].data = data; data += datasize;
- }
- if ( less )
- less->readData(data);
- if ( more )
- more->readData(data);
- }
-#else
- void readData(QIODevice& f)
- {
- int n = max-min+1;
- for (int i=0; i<n; i++) {
- QSize s( glyph[i].metrics->width, glyph[i].metrics->height );
- //############### s = qt_screen->mapToDevice( s );
- uint datasize = glyph[i].metrics->linestep * s.height();
- glyph[i].data = new uchar[datasize]; // ### deleted?
- f.read((char*)glyph[i].data, datasize);
- }
- if ( less )
- less->readData(f);
- if ( more )
- more->readData(f);
- }
-#endif
-
-};
-
-class QFontEngineQPF1Data
-{
-public:
- QPFFontMetrics fm;
- QPFGlyphTree *tree;
- void *mmapStart;
- size_t mmapLength;
-};
-
-#if defined(Q_OS_INTEGRITY)
-static void *qt_mmap(void *start, size_t length, int /*prot*/, int /*flags*/, int fd, off_t offset)
-{
- // INTEGRITY cannot mmap local files - load it into a local buffer
- if (::lseek(fd, offset, SEEK_SET) == -1) {
-# if defined(DEBUG_FONTENGINE)
- perror("lseek failed");
-# endif
- }
- void *buf = malloc(length);
- if (::read(fd, buf, length) != (ssize_t)length) {
-# if defined(DEBUG_FONTENGINE)
- perror("read failed");
-# endif
- }
-
- return buf;
-}
-#else
-static inline void *qt_mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset)
-{
- return mmap(start, length, prot, flags, fd, offset);
-}
-#endif
-
-
-
-QFontEngineQPF1::QFontEngineQPF1(const QFontDef&, const QString &fn)
-{
- cache_cost = 1;
-
- int f = QT_OPEN( QFile::encodeName(fn), O_RDONLY, 0);
- Q_ASSERT(f>=0);
- QT_STATBUF st;
- if ( QT_FSTAT( f, &st ) )
- qFatal("Failed to stat %s",QFile::encodeName(fn).data());
- uchar* data = (uchar*)qt_mmap( 0, // any address
- st.st_size, // whole file
- PROT_READ, // read-only memory
-#if defined(Q_OS_INTEGRITY)
- 0,
-#elif !defined(Q_OS_SOLARIS) && !defined(Q_OS_QNX4) && !defined(Q_OS_VXWORKS)
- MAP_FILE | MAP_PRIVATE, // swap-backed map from file
-#else
- MAP_PRIVATE,
-#endif
- f, 0 ); // from offset 0 of f
-#if !defined(MAP_FAILED) && (defined(Q_OS_QNX4) || defined(Q_OS_INTEGRITY))
-#define MAP_FAILED ((void *)-1)
-#endif
- if ( !data || data == (uchar*)MAP_FAILED )
- qFatal("Failed to mmap %s",QFile::encodeName(fn).data());
- QT_CLOSE(f);
-
- d = new QFontEngineQPF1Data;
- d->mmapStart = data;
- d->mmapLength = st.st_size;
- memcpy(reinterpret_cast<char*>(&d->fm),data,sizeof(d->fm));
-
- data += sizeof(d->fm);
- d->tree = new QPFGlyphTree(data);
- glyphFormat = (d->fm.flags & FM_SMOOTH) ? QFontEngineGlyphCache::Raster_A8
- : QFontEngineGlyphCache::Raster_Mono;
-#if 0
- qDebug() << "font file" << fn
- << "ascent" << d->fm.ascent << "descent" << d->fm.descent
- << "leftbearing" << d->fm.leftbearing
- << "rightbearing" << d->fm.rightbearing
- << "maxwidth" << d->fm.maxwidth
- << "leading" << d->fm.leading
- << "flags" << d->fm.flags
- << "underlinepos" << d->fm.underlinepos
- << "underlinewidth" << d->fm.underlinewidth;
-#endif
-}
-
-QFontEngineQPF1::~QFontEngineQPF1()
-{
- if (d->mmapStart)
- munmap(d->mmapStart, d->mmapLength);
- delete d->tree;
- delete d;
-}
-
-
-bool QFontEngineQPF1::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const
-{
- if(*nglyphs < len) {
- *nglyphs = len;
- return false;
- }
- *nglyphs = 0;
-
- bool mirrored = flags & QTextEngine::RightToLeft;
- for(int i = 0; i < len; i++) {
- unsigned int uc = getChar(str, i, len);
- if (mirrored)
- uc = QChar::mirroredChar(uc);
- glyphs->glyphs[*nglyphs] = uc < 0x10000 ? uc : 0;
- ++*nglyphs;
- }
-
- glyphs->numGlyphs = *nglyphs;
-
- if (flags & QTextEngine::GlyphIndicesOnly)
- return true;
-
- recalcAdvances(glyphs, flags);
-
- return true;
-}
-
-void QFontEngineQPF1::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags) const
-{
- for(int i = 0; i < glyphs->numGlyphs; i++) {
- QPFGlyph *glyph = d->tree->get(glyphs->glyphs[i]);
-
- glyphs->advances_x[i] = glyph ? glyph->metrics->advance : 0;
- glyphs->advances_y[i] = 0;
-
- if (!glyph)
- glyphs->glyphs[i] = 0;
- }
-}
-
-void QFontEngineQPF1::draw(QPaintEngine *p, qreal _x, qreal _y, const QTextItemInt &si)
-{
- QPaintEngineState *pState = p->state;
- QRasterPaintEngine *paintEngine = static_cast<QRasterPaintEngine*>(p);
-
- QTransform matrix = pState->transform();
- matrix.translate(_x, _y);
- QFixed x = QFixed::fromReal(matrix.dx());
- QFixed y = QFixed::fromReal(matrix.dy());
-
- QVarLengthArray<QFixedPoint> positions;
- QVarLengthArray<glyph_t> glyphs;
- getGlyphPositions(si.glyphs, matrix, si.flags, glyphs, positions);
- if (glyphs.size() == 0)
- return;
-
- int depth = (d->fm.flags & FM_SMOOTH) ? 8 : 1;
- for(int i = 0; i < glyphs.size(); i++) {
- const QPFGlyph *glyph = d->tree->get(glyphs[i]);
- if (!glyph)
- continue;
-
- int bpl = glyph->metrics->linestep;
-
- if(glyph->data)
- paintEngine->alphaPenBlt(glyph->data, bpl, depth,
- qRound(positions[i].x) + glyph->metrics->bearingx,
- qRound(positions[i].y) - glyph->metrics->bearingy,
- glyph->metrics->width,glyph->metrics->height);
- }
-}
-
-
-QImage QFontEngineQPF1::alphaMapForGlyph(glyph_t g)
-{
- const QPFGlyph *glyph = d->tree->get(g);
- if (!glyph)
- return QImage();
-
- int mono = !(d->fm.flags & FM_SMOOTH);
-
- const uchar *bits = glyph->data;//((const uchar *) glyph);
-
- QImage image;
- if (mono) {
- image = QImage((glyph->metrics->width+7)&~7, glyph->metrics->height, QImage::Format_Mono);
- image.setColor(0, qRgba(0, 0, 0, 0));
- image.setColor(1, qRgba(0, 0, 0, 255));
- } else {
- image = QImage(glyph->metrics->width, glyph->metrics->height, QImage::Format_Indexed8);
- for (int j=0; j<256; ++j)
- image.setColor(j, qRgba(0, 0, 0, j));
- }
- for (int i=0; i<glyph->metrics->height; ++i) {
- memcpy(image.scanLine(i), bits, glyph->metrics->linestep);
- bits += glyph->metrics->linestep;
- }
- return image;
-}
-
-
-
-void QFontEngineQPF1::addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags flags)
-{
- addBitmapFontToPath(x, y, glyphs, path, flags);
-}
-
-glyph_metrics_t QFontEngineQPF1::boundingBox(const QGlyphLayout &glyphs)
-{
- if (glyphs.numGlyphs == 0)
- return glyph_metrics_t();
-
- QFixed w = 0;
- for (int i = 0; i < glyphs.numGlyphs; ++i)
- w += glyphs.effectiveAdvance(i);
- return glyph_metrics_t(0, -ascent(), w - lastRightBearing(glyphs), ascent()+descent()+1, w, 0);
-}
-
-glyph_metrics_t QFontEngineQPF1::boundingBox(glyph_t glyph)
-{
- const QPFGlyph *g = d->tree->get(glyph);
- if (!g)
- return glyph_metrics_t();
- Q_ASSERT(g);
- return glyph_metrics_t(g->metrics->bearingx, -g->metrics->bearingy,
- g->metrics->width, g->metrics->height,
- g->metrics->advance, 0);
-}
-
-QFixed QFontEngineQPF1::ascent() const
-{
- return d->fm.ascent;
-}
-
-QFixed QFontEngineQPF1::descent() const
-{
- return d->fm.descent;
-}
-
-QFixed QFontEngineQPF1::leading() const
-{
- return d->fm.leading;
-}
-
-qreal QFontEngineQPF1::maxCharWidth() const
-{
- return d->fm.maxwidth;
-}
-/*
-const char *QFontEngineQPF1::name() const
-{
- return "qt";
-}
-*/
-bool QFontEngineQPF1::canRender(const QChar *str, int len)
-{
- for(int i = 0; i < len; i++)
- if (!d->tree->inFont(str[i].unicode()))
- return false;
- return true;
-}
-
-QFontEngine::Type QFontEngineQPF1::type() const
-{
- return QPF1;
-}
-
-qreal QFontEngineQPF1::minLeftBearing() const
-{
- return d->fm.leftbearing;
-}
-
-qreal QFontEngineQPF1::minRightBearing() const
-{
- return d->fm.rightbearing;
-}
-
-QFixed QFontEngineQPF1::underlinePosition() const
-{
- return d->fm.underlinepos;
-}
-
-QFixed QFontEngineQPF1::lineThickness() const
-{
- return d->fm.underlinewidth;
-}
-
-#endif //QT_NO_QWS_QPF
-
-QT_END_NAMESPACE
diff --git a/src/gui/text/qfontmetrics.h b/src/gui/text/qfontmetrics.h
index 5fe8676993..56e5a5c6bb 100644
--- a/src/gui/text/qfontmetrics.h
+++ b/src/gui/text/qfontmetrics.h
@@ -122,15 +122,6 @@ public:
inline bool operator !=(const QFontMetrics &other) { return !operator==(other); } // 5.0 - remove me
inline bool operator !=(const QFontMetrics &other) const { return !operator==(other); }
-#ifdef QT3_SUPPORT
- inline QRect boundingRect(const QString &text, int len) const
- { return boundingRect(text.left(len)); }
- inline QRect boundingRect(int x, int y, int w, int h, int flags, const QString& str, int len,
- int tabstops=0, int *tabarray=0) const
- { return boundingRect(QRect(x, y, w, h), flags, str.left(len), tabstops, tabarray); }
- inline QSize size(int flags, const QString& str, int len, int tabstops=0, int *tabarray=0) const
- { return size(flags, str.left(len), tabstops, tabarray); }
-#endif
private:
#if defined(Q_WS_MAC)
friend class QFontPrivate;
diff --git a/src/gui/text/qrawfont_qpa.cpp b/src/gui/text/qrawfont_qpa.cpp
index 103619c37d..6c8befec60 100644
--- a/src/gui/text/qrawfont_qpa.cpp
+++ b/src/gui/text/qrawfont_qpa.cpp
@@ -45,7 +45,7 @@
#include "qrawfont_p.h"
#include <QtGui/qplatformfontdatabase_qpa.h>
-#include <private/qapplication_p.h>
+#include <private/qguiapplication_p.h>
QT_BEGIN_NAMESPACE
@@ -58,7 +58,7 @@ void QRawFontPrivate::platformLoadFromData(const QByteArray &fontData, int pixel
{
Q_ASSERT(fontEngine == 0);
- QPlatformFontDatabase *pfdb = QApplicationPrivate::platformIntegration()->fontDatabase();
+ QPlatformFontDatabase *pfdb = QGuiApplicationPrivate::platformIntegration()->fontDatabase();
fontEngine = pfdb->fontEngine(fontData, pixelSize, hintingPreference);
if (fontEngine != 0)
fontEngine->ref.ref();
diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp
index 5bee497a3e..397180cb2a 100644
--- a/src/gui/text/qstatictext.cpp
+++ b/src/gui/text/qstatictext.cpp
@@ -45,8 +45,6 @@
#include <private/qfontengine_p.h>
#include <qabstracttextdocumentlayout.h>
-#include <QtGui/qapplication.h>
-
QT_BEGIN_NAMESPACE
/*!
diff --git a/src/gui/text/qsyntaxhighlighter.cpp b/src/gui/text/qsyntaxhighlighter.cpp
index 6a3355b90d..5edd6375c9 100644
--- a/src/gui/text/qsyntaxhighlighter.cpp
+++ b/src/gui/text/qsyntaxhighlighter.cpp
@@ -50,7 +50,6 @@
#include <qtextobject.h>
#include <qtextcursor.h>
#include <qdebug.h>
-#include <qtextedit.h>
#include <qtimer.h>
QT_BEGIN_NAMESPACE
@@ -311,10 +310,19 @@ void QSyntaxHighlighterPrivate::reformatBlock(const QTextBlock &block)
/*!
Constructs a QSyntaxHighlighter with the given \a parent.
+
+ If the parent is a QTextEdit, it installs the syntaxhighlighter on the
+ parents document. The specified QTextEdit also becomes the owner of
+ the QSyntaxHighlighter.
*/
QSyntaxHighlighter::QSyntaxHighlighter(QObject *parent)
: QObject(*new QSyntaxHighlighterPrivate, parent)
{
+ if (parent->inherits("QTextEdit")) {
+ QTextDocument *doc = qobject_cast<QTextDocument *>(parent->property("document").value<QObject *>());
+ if (doc)
+ setDocument(doc);
+ }
}
/*!
@@ -329,17 +337,6 @@ QSyntaxHighlighter::QSyntaxHighlighter(QTextDocument *parent)
}
/*!
- Constructs a QSyntaxHighlighter and installs it on \a parent 's
- QTextDocument. The specified QTextEdit also becomes the owner of
- the QSyntaxHighlighter.
-*/
-QSyntaxHighlighter::QSyntaxHighlighter(QTextEdit *parent)
- : QObject(*new QSyntaxHighlighterPrivate, parent)
-{
- setDocument(parent->document());
-}
-
-/*!
Destructor. Uninstalls this syntax highlighter from the text document.
*/
QSyntaxHighlighter::~QSyntaxHighlighter()
diff --git a/src/gui/text/qsyntaxhighlighter.h b/src/gui/text/qsyntaxhighlighter.h
index 9cd5778074..33006cdd9e 100644
--- a/src/gui/text/qsyntaxhighlighter.h
+++ b/src/gui/text/qsyntaxhighlighter.h
@@ -61,7 +61,6 @@ class QTextCharFormat;
class QFont;
class QColor;
class QTextBlockUserData;
-class QTextEdit;
class Q_GUI_EXPORT QSyntaxHighlighter : public QObject
{
@@ -70,7 +69,6 @@ class Q_GUI_EXPORT QSyntaxHighlighter : public QObject
public:
QSyntaxHighlighter(QObject *parent);
QSyntaxHighlighter(QTextDocument *parent);
- QSyntaxHighlighter(QTextEdit *parent);
virtual ~QSyntaxHighlighter();
void setDocument(QTextDocument *doc);
diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp
deleted file mode 100644
index 43967307bc..0000000000
--- a/src/gui/text/qtextcontrol.cpp
+++ /dev/null
@@ -1,3148 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qtextcontrol_p.h"
-#include "qtextcontrol_p_p.h"
-
-#ifndef QT_NO_TEXTCONTROL
-
-#include <qfont.h>
-#include <qpainter.h>
-#include <qevent.h>
-#include <qdebug.h>
-#include <qmime.h>
-#include <qdrag.h>
-#include <qclipboard.h>
-#include <qmenu.h>
-#include <qstyle.h>
-#include <qtimer.h>
-#include "private/qtextdocumentlayout_p.h"
-#include "private/qabstracttextdocumentlayout_p.h"
-#include "private/qtextedit_p.h"
-#include "qtextdocument.h"
-#include "private/qtextdocument_p.h"
-#include "qtextlist.h"
-#include "private/qtextcontrol_p.h"
-#include "qgraphicssceneevent.h"
-#include "qprinter.h"
-#include "qtextdocumentwriter.h"
-#include "private/qtextcursor_p.h"
-
-#include <qtextformat.h>
-#include <qdatetime.h>
-#include <qbuffer.h>
-#include <qapplication.h>
-#include <limits.h>
-#include <qtexttable.h>
-#include <qvariant.h>
-#include <qurl.h>
-#include <qdesktopservices.h>
-#include <qinputcontext.h>
-#include <qtooltip.h>
-#include <qstyleoption.h>
-#include <QtGui/qlineedit.h>
-
-#ifndef QT_NO_SHORTCUT
-#include "private/qapplication_p.h"
-#include "private/qshortcutmap_p.h"
-#include <qkeysequence.h>
-#define ACCEL_KEY(k) (!qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? QLatin1Char('\t') + QString(QKeySequence(k)) : QString())
-#else
-#define ACCEL_KEY(k) QString()
-#endif
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_CONTEXTMENU
-#if defined(Q_WS_WIN) || defined(Q_WS_X11)
-extern bool qt_use_rtl_extensions;
-#endif
-#endif
-
-// could go into QTextCursor...
-static QTextLine currentTextLine(const QTextCursor &cursor)
-{
- const QTextBlock block = cursor.block();
- if (!block.isValid())
- return QTextLine();
-
- const QTextLayout *layout = block.layout();
- if (!layout)
- return QTextLine();
-
- const int relativePos = cursor.position() - block.position();
- return layout->lineForTextPosition(relativePos);
-}
-
-QTextControlPrivate::QTextControlPrivate()
- : doc(0), cursorOn(false), cursorIsFocusIndicator(false),
- interactionFlags(Qt::TextEditorInteraction),
- dragEnabled(true),
-#ifndef QT_NO_DRAGANDDROP
- mousePressed(false), mightStartDrag(false),
-#endif
- lastSelectionState(false), ignoreAutomaticScrollbarAdjustement(false),
- overwriteMode(false),
- acceptRichText(true),
- preeditCursor(0), hideCursor(false),
- hasFocus(false),
-#ifdef QT_KEYPAD_NAVIGATION
- hasEditFocus(false),
-#endif
- isEnabled(true),
- hadSelectionOnMousePress(false),
- ignoreUnusedNavigationEvents(false),
- openExternalLinks(false),
- wordSelectionEnabled(false)
-{}
-
-bool QTextControlPrivate::cursorMoveKeyEvent(QKeyEvent *e)
-{
-#ifdef QT_NO_SHORTCUT
- Q_UNUSED(e);
-#endif
-
- Q_Q(QTextControl);
- if (cursor.isNull())
- return false;
-
- const QTextCursor oldSelection = cursor;
- const int oldCursorPos = cursor.position();
-
- QTextCursor::MoveMode mode = QTextCursor::MoveAnchor;
- QTextCursor::MoveOperation op = QTextCursor::NoMove;
-
- if (false) {
- }
-#ifndef QT_NO_SHORTCUT
- if (e == QKeySequence::MoveToNextChar) {
- op = QTextCursor::Right;
- }
- else if (e == QKeySequence::MoveToPreviousChar) {
- op = QTextCursor::Left;
- }
- else if (e == QKeySequence::SelectNextChar) {
- op = QTextCursor::Right;
- mode = QTextCursor::KeepAnchor;
- }
- else if (e == QKeySequence::SelectPreviousChar) {
- op = QTextCursor::Left;
- mode = QTextCursor::KeepAnchor;
- }
- else if (e == QKeySequence::SelectNextWord) {
- op = QTextCursor::WordRight;
- mode = QTextCursor::KeepAnchor;
- }
- else if (e == QKeySequence::SelectPreviousWord) {
- op = QTextCursor::WordLeft;
- mode = QTextCursor::KeepAnchor;
- }
- else if (e == QKeySequence::SelectStartOfLine) {
- op = QTextCursor::StartOfLine;
- mode = QTextCursor::KeepAnchor;
- }
- else if (e == QKeySequence::SelectEndOfLine) {
- op = QTextCursor::EndOfLine;
- mode = QTextCursor::KeepAnchor;
- }
- else if (e == QKeySequence::SelectStartOfBlock) {
- op = QTextCursor::StartOfBlock;
- mode = QTextCursor::KeepAnchor;
- }
- else if (e == QKeySequence::SelectEndOfBlock) {
- op = QTextCursor::EndOfBlock;
- mode = QTextCursor::KeepAnchor;
- }
- else if (e == QKeySequence::SelectStartOfDocument) {
- op = QTextCursor::Start;
- mode = QTextCursor::KeepAnchor;
- }
- else if (e == QKeySequence::SelectEndOfDocument) {
- op = QTextCursor::End;
- mode = QTextCursor::KeepAnchor;
- }
- else if (e == QKeySequence::SelectPreviousLine) {
- op = QTextCursor::Up;
- mode = QTextCursor::KeepAnchor;
- }
- else if (e == QKeySequence::SelectNextLine) {
- op = QTextCursor::Down;
- mode = QTextCursor::KeepAnchor;
- {
- QTextBlock block = cursor.block();
- QTextLine line = currentTextLine(cursor);
- if (!block.next().isValid()
- && line.isValid()
- && line.lineNumber() == block.layout()->lineCount() - 1)
- op = QTextCursor::End;
- }
- }
- else if (e == QKeySequence::MoveToNextWord) {
- op = QTextCursor::WordRight;
- }
- else if (e == QKeySequence::MoveToPreviousWord) {
- op = QTextCursor::WordLeft;
- }
- else if (e == QKeySequence::MoveToEndOfBlock) {
- op = QTextCursor::EndOfBlock;
- }
- else if (e == QKeySequence::MoveToStartOfBlock) {
- op = QTextCursor::StartOfBlock;
- }
- else if (e == QKeySequence::MoveToNextLine) {
- op = QTextCursor::Down;
- }
- else if (e == QKeySequence::MoveToPreviousLine) {
- op = QTextCursor::Up;
- }
- else if (e == QKeySequence::MoveToPreviousLine) {
- op = QTextCursor::Up;
- }
- else if (e == QKeySequence::MoveToStartOfLine) {
- op = QTextCursor::StartOfLine;
- }
- else if (e == QKeySequence::MoveToEndOfLine) {
- op = QTextCursor::EndOfLine;
- }
- else if (e == QKeySequence::MoveToStartOfDocument) {
- op = QTextCursor::Start;
- }
- else if (e == QKeySequence::MoveToEndOfDocument) {
- op = QTextCursor::End;
- }
-#endif // QT_NO_SHORTCUT
- else {
- return false;
- }
-
-// Except for pageup and pagedown, Mac OS X has very different behavior, we don't do it all, but
-// here's the breakdown:
-// Shift still works as an anchor, but only one of the other keys can be down Ctrl (Command),
-// Alt (Option), or Meta (Control).
-// Command/Control + Left/Right -- Move to left or right of the line
-// + Up/Down -- Move to top bottom of the file. (Control doesn't move the cursor)
-// Option + Left/Right -- Move one word Left/right.
-// + Up/Down -- Begin/End of Paragraph.
-// Home/End Top/Bottom of file. (usually don't move the cursor, but will select)
-
- bool visualNavigation = cursor.visualNavigation();
- cursor.setVisualNavigation(true);
- const bool moved = cursor.movePosition(op, mode);
- cursor.setVisualNavigation(visualNavigation);
- q->ensureCursorVisible();
-
- bool ignoreNavigationEvents = ignoreUnusedNavigationEvents;
- bool isNavigationEvent = e->key() == Qt::Key_Up || e->key() == Qt::Key_Down;
-
-#ifdef QT_KEYPAD_NAVIGATION
- ignoreNavigationEvents = ignoreNavigationEvents || QApplication::keypadNavigationEnabled();
- isNavigationEvent = isNavigationEvent ||
- (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional
- && (e->key() == Qt::Key_Left || e->key() == Qt::Key_Right));
-#else
- isNavigationEvent = isNavigationEvent || e->key() == Qt::Key_Left || e->key() == Qt::Key_Right;
-#endif
-
- if (moved) {
- if (cursor.position() != oldCursorPos)
- emit q->cursorPositionChanged();
- emit q->microFocusChanged();
- } else if (ignoreNavigationEvents && isNavigationEvent && oldSelection.anchor() == cursor.anchor()) {
- return false;
- }
-
- selectionChanged(/*forceEmitSelectionChanged =*/(mode == QTextCursor::KeepAnchor));
-
- repaintOldAndNewSelection(oldSelection);
-
- return true;
-}
-
-void QTextControlPrivate::updateCurrentCharFormat()
-{
- Q_Q(QTextControl);
-
- QTextCharFormat fmt = cursor.charFormat();
- if (fmt == lastCharFormat)
- return;
- lastCharFormat = fmt;
-
- emit q->currentCharFormatChanged(fmt);
- emit q->microFocusChanged();
-}
-
-void QTextControlPrivate::indent()
-{
- QTextBlockFormat blockFmt = cursor.blockFormat();
-
- QTextList *list = cursor.currentList();
- if (!list) {
- QTextBlockFormat modifier;
- modifier.setIndent(blockFmt.indent() + 1);
- cursor.mergeBlockFormat(modifier);
- } else {
- QTextListFormat format = list->format();
- format.setIndent(format.indent() + 1);
-
- if (list->itemNumber(cursor.block()) == 1)
- list->setFormat(format);
- else
- cursor.createList(format);
- }
-}
-
-void QTextControlPrivate::outdent()
-{
- QTextBlockFormat blockFmt = cursor.blockFormat();
-
- QTextList *list = cursor.currentList();
-
- if (!list) {
- QTextBlockFormat modifier;
- modifier.setIndent(blockFmt.indent() - 1);
- cursor.mergeBlockFormat(modifier);
- } else {
- QTextListFormat listFmt = list->format();
- listFmt.setIndent(listFmt.indent() - 1);
- list->setFormat(listFmt);
- }
-}
-
-void QTextControlPrivate::gotoNextTableCell()
-{
- QTextTable *table = cursor.currentTable();
- QTextTableCell cell = table->cellAt(cursor);
-
- int newColumn = cell.column() + cell.columnSpan();
- int newRow = cell.row();
-
- if (newColumn >= table->columns()) {
- newColumn = 0;
- ++newRow;
- if (newRow >= table->rows())
- table->insertRows(table->rows(), 1);
- }
-
- cell = table->cellAt(newRow, newColumn);
- cursor = cell.firstCursorPosition();
-}
-
-void QTextControlPrivate::gotoPreviousTableCell()
-{
- QTextTable *table = cursor.currentTable();
- QTextTableCell cell = table->cellAt(cursor);
-
- int newColumn = cell.column() - 1;
- int newRow = cell.row();
-
- if (newColumn < 0) {
- newColumn = table->columns() - 1;
- --newRow;
- if (newRow < 0)
- return;
- }
-
- cell = table->cellAt(newRow, newColumn);
- cursor = cell.firstCursorPosition();
-}
-
-void QTextControlPrivate::createAutoBulletList()
-{
- cursor.beginEditBlock();
-
- QTextBlockFormat blockFmt = cursor.blockFormat();
-
- QTextListFormat listFmt;
- listFmt.setStyle(QTextListFormat::ListDisc);
- listFmt.setIndent(blockFmt.indent() + 1);
-
- blockFmt.setIndent(0);
- cursor.setBlockFormat(blockFmt);
-
- cursor.createList(listFmt);
-
- cursor.endEditBlock();
-}
-
-void QTextControlPrivate::init(Qt::TextFormat format, const QString &text, QTextDocument *document)
-{
- Q_Q(QTextControl);
- setContent(format, text, document);
-
- doc->setUndoRedoEnabled(interactionFlags & Qt::TextEditable);
- q->setCursorWidth(-1);
-}
-
-void QTextControlPrivate::setContent(Qt::TextFormat format, const QString &text, QTextDocument *document)
-{
- Q_Q(QTextControl);
-
- // for use when called from setPlainText. we may want to re-use the currently
- // set char format then.
- const QTextCharFormat charFormatForInsertion = cursor.charFormat();
-
- bool clearDocument = true;
- if (!doc) {
- if (document) {
- doc = document;
- clearDocument = false;
- } else {
- palette = QApplication::palette("QTextControl");
- doc = new QTextDocument(q);
- }
- _q_documentLayoutChanged();
- cursor = QTextCursor(doc);
-
-// #### doc->documentLayout()->setPaintDevice(viewport);
-
- QObject::connect(doc, SIGNAL(contentsChanged()), q, SLOT(_q_updateCurrentCharFormatAndSelection()));
- QObject::connect(doc, SIGNAL(cursorPositionChanged(QTextCursor)), q, SLOT(_q_emitCursorPosChanged(QTextCursor)));
- QObject::connect(doc, SIGNAL(documentLayoutChanged()), q, SLOT(_q_documentLayoutChanged()));
-
- // convenience signal forwards
- QObject::connect(doc, SIGNAL(undoAvailable(bool)), q, SIGNAL(undoAvailable(bool)));
- QObject::connect(doc, SIGNAL(redoAvailable(bool)), q, SIGNAL(redoAvailable(bool)));
- QObject::connect(doc, SIGNAL(modificationChanged(bool)), q, SIGNAL(modificationChanged(bool)));
- QObject::connect(doc, SIGNAL(blockCountChanged(int)), q, SIGNAL(blockCountChanged(int)));
- }
-
- bool previousUndoRedoState = doc->isUndoRedoEnabled();
- if (!document)
- doc->setUndoRedoEnabled(false);
-
- //Saving the index save some time.
- static int contentsChangedIndex = QTextDocument::staticMetaObject.indexOfSignal("contentsChanged()");
- static int textChangedIndex = QTextControl::staticMetaObject.indexOfSignal("textChanged()");
- // avoid multiple textChanged() signals being emitted
- QMetaObject::disconnect(doc, contentsChangedIndex, q, textChangedIndex);
-
- if (!text.isEmpty()) {
- // clear 'our' cursor for insertion to prevent
- // the emission of the cursorPositionChanged() signal.
- // instead we emit it only once at the end instead of
- // at the end of the document after loading and when
- // positioning the cursor again to the start of the
- // document.
- cursor = QTextCursor();
- if (format == Qt::PlainText) {
- QTextCursor formatCursor(doc);
- // put the setPlainText and the setCharFormat into one edit block,
- // so that the syntax highlight triggers only /once/ for the entire
- // document, not twice.
- formatCursor.beginEditBlock();
- doc->setPlainText(text);
- doc->setUndoRedoEnabled(false);
- formatCursor.select(QTextCursor::Document);
- formatCursor.setCharFormat(charFormatForInsertion);
- formatCursor.endEditBlock();
- } else {
-#ifndef QT_NO_TEXTHTMLPARSER
- doc->setHtml(text);
-#else
- doc->setPlainText(text);
-#endif
- doc->setUndoRedoEnabled(false);
- }
- cursor = QTextCursor(doc);
- } else if (clearDocument) {
- doc->clear();
- }
- cursor.setCharFormat(charFormatForInsertion);
-
- QMetaObject::connect(doc, contentsChangedIndex, q, textChangedIndex);
- emit q->textChanged();
- if (!document)
- doc->setUndoRedoEnabled(previousUndoRedoState);
- _q_updateCurrentCharFormatAndSelection();
- if (!document)
- doc->setModified(false);
-
- q->ensureCursorVisible();
- emit q->cursorPositionChanged();
-}
-
-void QTextControlPrivate::startDrag()
-{
-#ifndef QT_NO_DRAGANDDROP
- Q_Q(QTextControl);
- mousePressed = false;
- if (!contextWidget)
- return;
- QMimeData *data = q->createMimeDataFromSelection();
-
- QDrag *drag = new QDrag(contextWidget);
- drag->setMimeData(data);
-
- Qt::DropActions actions = Qt::CopyAction;
- Qt::DropAction action;
- if (interactionFlags & Qt::TextEditable) {
- actions |= Qt::MoveAction;
- action = drag->exec(actions, Qt::MoveAction);
- } else {
- action = drag->exec(actions, Qt::CopyAction);
- }
-
- if (action == Qt::MoveAction && drag->target() != contextWidget)
- cursor.removeSelectedText();
-#endif
-}
-
-void QTextControlPrivate::setCursorPosition(const QPointF &pos)
-{
- Q_Q(QTextControl);
- const int cursorPos = q->hitTest(pos, Qt::FuzzyHit);
- if (cursorPos == -1)
- return;
- cursor.setPosition(cursorPos);
-}
-
-void QTextControlPrivate::setCursorPosition(int pos, QTextCursor::MoveMode mode)
-{
- cursor.setPosition(pos, mode);
-
- if (mode != QTextCursor::KeepAnchor) {
- selectedWordOnDoubleClick = QTextCursor();
- selectedBlockOnTrippleClick = QTextCursor();
- }
-}
-
-void QTextControlPrivate::repaintCursor()
-{
- Q_Q(QTextControl);
- emit q->updateRequest(cursorRectPlusUnicodeDirectionMarkers(cursor));
-}
-
-void QTextControlPrivate::repaintOldAndNewSelection(const QTextCursor &oldSelection)
-{
- Q_Q(QTextControl);
- if (cursor.hasSelection()
- && oldSelection.hasSelection()
- && cursor.currentFrame() == oldSelection.currentFrame()
- && !cursor.hasComplexSelection()
- && !oldSelection.hasComplexSelection()
- && cursor.anchor() == oldSelection.anchor()
- ) {
- QTextCursor differenceSelection(doc);
- differenceSelection.setPosition(oldSelection.position());
- differenceSelection.setPosition(cursor.position(), QTextCursor::KeepAnchor);
- emit q->updateRequest(q->selectionRect(differenceSelection));
- } else {
- if (!oldSelection.isNull())
- emit q->updateRequest(q->selectionRect(oldSelection) | cursorRectPlusUnicodeDirectionMarkers(oldSelection));
- emit q->updateRequest(q->selectionRect() | cursorRectPlusUnicodeDirectionMarkers(cursor));
- }
-}
-
-void QTextControlPrivate::selectionChanged(bool forceEmitSelectionChanged /*=false*/)
-{
- Q_Q(QTextControl);
- if (forceEmitSelectionChanged)
- emit q->selectionChanged();
-
- bool current = cursor.hasSelection();
- if (current == lastSelectionState)
- return;
-
- lastSelectionState = current;
- emit q->copyAvailable(current);
- if (!forceEmitSelectionChanged)
- emit q->selectionChanged();
- emit q->microFocusChanged();
-}
-
-void QTextControlPrivate::_q_updateCurrentCharFormatAndSelection()
-{
- updateCurrentCharFormat();
- selectionChanged();
-}
-
-#ifndef QT_NO_CLIPBOARD
-void QTextControlPrivate::setClipboardSelection()
-{
- QClipboard *clipboard = QApplication::clipboard();
- if (!cursor.hasSelection() || !clipboard->supportsSelection())
- return;
- Q_Q(QTextControl);
- QMimeData *data = q->createMimeDataFromSelection();
- clipboard->setMimeData(data, QClipboard::Selection);
-}
-#endif
-
-void QTextControlPrivate::_q_emitCursorPosChanged(const QTextCursor &someCursor)
-{
- Q_Q(QTextControl);
- if (someCursor.isCopyOf(cursor)) {
- emit q->cursorPositionChanged();
- emit q->microFocusChanged();
- }
-}
-
-void QTextControlPrivate::_q_documentLayoutChanged()
-{
- Q_Q(QTextControl);
- QAbstractTextDocumentLayout *layout = doc->documentLayout();
- QObject::connect(layout, SIGNAL(update(QRectF)), q, SIGNAL(updateRequest(QRectF)));
- QObject::connect(layout, SIGNAL(updateBlock(QTextBlock)), q, SLOT(_q_updateBlock(QTextBlock)));
- QObject::connect(layout, SIGNAL(documentSizeChanged(QSizeF)), q, SIGNAL(documentSizeChanged(QSizeF)));
-
-}
-
-void QTextControlPrivate::setBlinkingCursorEnabled(bool enable)
-{
- Q_Q(QTextControl);
-
- if (enable && QApplication::cursorFlashTime() > 0)
- cursorBlinkTimer.start(QApplication::cursorFlashTime() / 2, q);
- else
- cursorBlinkTimer.stop();
-
- cursorOn = enable;
-
- repaintCursor();
-}
-
-void QTextControlPrivate::extendWordwiseSelection(int suggestedNewPosition, qreal mouseXPosition)
-{
- Q_Q(QTextControl);
-
- // if inside the initial selected word keep that
- if (suggestedNewPosition >= selectedWordOnDoubleClick.selectionStart()
- && suggestedNewPosition <= selectedWordOnDoubleClick.selectionEnd()) {
- q->setTextCursor(selectedWordOnDoubleClick);
- return;
- }
-
- QTextCursor curs = selectedWordOnDoubleClick;
- curs.setPosition(suggestedNewPosition, QTextCursor::KeepAnchor);
-
- if (!curs.movePosition(QTextCursor::StartOfWord))
- return;
- const int wordStartPos = curs.position();
-
- const int blockPos = curs.block().position();
- const QPointF blockCoordinates = q->blockBoundingRect(curs.block()).topLeft();
-
- QTextLine line = currentTextLine(curs);
- if (!line.isValid())
- return;
-
- const qreal wordStartX = line.cursorToX(curs.position() - blockPos) + blockCoordinates.x();
-
- if (!curs.movePosition(QTextCursor::EndOfWord))
- return;
- const int wordEndPos = curs.position();
-
- const QTextLine otherLine = currentTextLine(curs);
- if (otherLine.textStart() != line.textStart()
- || wordEndPos == wordStartPos)
- return;
-
- const qreal wordEndX = line.cursorToX(curs.position() - blockPos) + blockCoordinates.x();
-
- if (mouseXPosition < wordStartX || mouseXPosition > wordEndX)
- return;
-
- // keep the already selected word even when moving to the left
- // (#39164)
- if (suggestedNewPosition < selectedWordOnDoubleClick.position())
- cursor.setPosition(selectedWordOnDoubleClick.selectionEnd());
- else
- cursor.setPosition(selectedWordOnDoubleClick.selectionStart());
-
- const qreal differenceToStart = mouseXPosition - wordStartX;
- const qreal differenceToEnd = wordEndX - mouseXPosition;
-
- if (differenceToStart < differenceToEnd)
- setCursorPosition(wordStartPos, QTextCursor::KeepAnchor);
- else
- setCursorPosition(wordEndPos, QTextCursor::KeepAnchor);
-
- if (interactionFlags & Qt::TextSelectableByMouse) {
-#ifndef QT_NO_CLIPBOARD
- setClipboardSelection();
-#endif
- selectionChanged(true);
- }
-}
-
-void QTextControlPrivate::extendBlockwiseSelection(int suggestedNewPosition)
-{
- Q_Q(QTextControl);
-
- // if inside the initial selected line keep that
- if (suggestedNewPosition >= selectedBlockOnTrippleClick.selectionStart()
- && suggestedNewPosition <= selectedBlockOnTrippleClick.selectionEnd()) {
- q->setTextCursor(selectedBlockOnTrippleClick);
- return;
- }
-
- if (suggestedNewPosition < selectedBlockOnTrippleClick.position()) {
- cursor.setPosition(selectedBlockOnTrippleClick.selectionEnd());
- cursor.setPosition(suggestedNewPosition, QTextCursor::KeepAnchor);
- cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::KeepAnchor);
- } else {
- cursor.setPosition(selectedBlockOnTrippleClick.selectionStart());
- cursor.setPosition(suggestedNewPosition, QTextCursor::KeepAnchor);
- cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
- cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
- }
-
- if (interactionFlags & Qt::TextSelectableByMouse) {
-#ifndef QT_NO_CLIPBOARD
- setClipboardSelection();
-#endif
- selectionChanged(true);
- }
-}
-
-void QTextControlPrivate::_q_deleteSelected()
-{
- if (!(interactionFlags & Qt::TextEditable) || !cursor.hasSelection())
- return;
- cursor.removeSelectedText();
-}
-
-void QTextControl::undo()
-{
- Q_D(QTextControl);
- d->repaintSelection();
- const int oldCursorPos = d->cursor.position();
- d->doc->undo(&d->cursor);
- if (d->cursor.position() != oldCursorPos)
- emit cursorPositionChanged();
- emit microFocusChanged();
- ensureCursorVisible();
-}
-
-void QTextControl::redo()
-{
- Q_D(QTextControl);
- d->repaintSelection();
- const int oldCursorPos = d->cursor.position();
- d->doc->redo(&d->cursor);
- if (d->cursor.position() != oldCursorPos)
- emit cursorPositionChanged();
- emit microFocusChanged();
- ensureCursorVisible();
-}
-
-QTextControl::QTextControl(QObject *parent)
- : QObject(*new QTextControlPrivate, parent)
-{
- Q_D(QTextControl);
- d->init();
-}
-
-QTextControl::QTextControl(const QString &text, QObject *parent)
- : QObject(*new QTextControlPrivate, parent)
-{
- Q_D(QTextControl);
- d->init(Qt::RichText, text);
-}
-
-QTextControl::QTextControl(QTextDocument *doc, QObject *parent)
- : QObject(*new QTextControlPrivate, parent)
-{
- Q_D(QTextControl);
- d->init(Qt::RichText, QString(), doc);
-}
-
-QTextControl::~QTextControl()
-{
-}
-
-void QTextControl::setDocument(QTextDocument *document)
-{
- Q_D(QTextControl);
- if (d->doc == document)
- return;
-
- d->doc->disconnect(this);
- d->doc->documentLayout()->disconnect(this);
- d->doc->documentLayout()->setPaintDevice(0);
-
- if (d->doc->parent() == this)
- delete d->doc;
-
- d->doc = 0;
- d->setContent(Qt::RichText, QString(), document);
-}
-
-QTextDocument *QTextControl::document() const
-{
- Q_D(const QTextControl);
- return d->doc;
-}
-
-void QTextControl::setTextCursor(const QTextCursor &cursor)
-{
- Q_D(QTextControl);
- d->cursorIsFocusIndicator = false;
- const bool posChanged = cursor.position() != d->cursor.position();
- const QTextCursor oldSelection = d->cursor;
- d->cursor = cursor;
- d->cursorOn = d->hasFocus && (d->interactionFlags & Qt::TextEditable);
- d->_q_updateCurrentCharFormatAndSelection();
- ensureCursorVisible();
- d->repaintOldAndNewSelection(oldSelection);
- if (posChanged)
- emit cursorPositionChanged();
-}
-
-QTextCursor QTextControl::textCursor() const
-{
- Q_D(const QTextControl);
- return d->cursor;
-}
-
-#ifndef QT_NO_CLIPBOARD
-
-void QTextControl::cut()
-{
- Q_D(QTextControl);
- if (!(d->interactionFlags & Qt::TextEditable) || !d->cursor.hasSelection())
- return;
- copy();
- d->cursor.removeSelectedText();
-}
-
-void QTextControl::copy()
-{
- Q_D(QTextControl);
- if (!d->cursor.hasSelection())
- return;
- QMimeData *data = createMimeDataFromSelection();
- QApplication::clipboard()->setMimeData(data);
-}
-
-void QTextControl::paste(QClipboard::Mode mode)
-{
- const QMimeData *md = QApplication::clipboard()->mimeData(mode);
- if (md)
- insertFromMimeData(md);
-}
-#endif
-
-void QTextControl::clear()
-{
- Q_D(QTextControl);
- // clears and sets empty content
- d->extraSelections.clear();
- d->setContent();
-}
-
-
-void QTextControl::selectAll()
-{
- Q_D(QTextControl);
- const int selectionLength = qAbs(d->cursor.position() - d->cursor.anchor());
- d->cursor.select(QTextCursor::Document);
- d->selectionChanged(selectionLength != qAbs(d->cursor.position() - d->cursor.anchor()));
- d->cursorIsFocusIndicator = false;
- emit updateRequest();
-}
-
-void QTextControl::processEvent(QEvent *e, const QPointF &coordinateOffset, QWidget *contextWidget)
-{
- QMatrix m;
- m.translate(coordinateOffset.x(), coordinateOffset.y());
- processEvent(e, m, contextWidget);
-}
-
-void QTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget *contextWidget)
-{
- Q_D(QTextControl);
- if (d->interactionFlags == Qt::NoTextInteraction) {
- e->ignore();
- return;
- }
-
- d->contextWidget = contextWidget;
-
- if (!d->contextWidget) {
- switch (e->type()) {
-#ifndef QT_NO_GRAPHICSVIEW
- case QEvent::GraphicsSceneMouseMove:
- case QEvent::GraphicsSceneMousePress:
- case QEvent::GraphicsSceneMouseRelease:
- case QEvent::GraphicsSceneMouseDoubleClick:
- case QEvent::GraphicsSceneContextMenu:
- case QEvent::GraphicsSceneHoverEnter:
- case QEvent::GraphicsSceneHoverMove:
- case QEvent::GraphicsSceneHoverLeave:
- case QEvent::GraphicsSceneHelp:
- case QEvent::GraphicsSceneDragEnter:
- case QEvent::GraphicsSceneDragMove:
- case QEvent::GraphicsSceneDragLeave:
- case QEvent::GraphicsSceneDrop: {
- QGraphicsSceneEvent *ev = static_cast<QGraphicsSceneEvent *>(e);
- d->contextWidget = ev->widget();
- break;
- }
-#endif // QT_NO_GRAPHICSVIEW
- default: break;
- };
- }
-
- switch (e->type()) {
- case QEvent::KeyPress:
- d->keyPressEvent(static_cast<QKeyEvent *>(e));
- break;
- case QEvent::MouseButtonPress: {
- QMouseEvent *ev = static_cast<QMouseEvent *>(e);
- d->mousePressEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(),
- ev->buttons(), ev->globalPos());
- break; }
- case QEvent::MouseMove: {
- QMouseEvent *ev = static_cast<QMouseEvent *>(e);
- d->mouseMoveEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(),
- ev->buttons(), ev->globalPos());
- break; }
- case QEvent::MouseButtonRelease: {
- QMouseEvent *ev = static_cast<QMouseEvent *>(e);
- d->mouseReleaseEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(),
- ev->buttons(), ev->globalPos());
- break; }
- case QEvent::MouseButtonDblClick: {
- QMouseEvent *ev = static_cast<QMouseEvent *>(e);
- d->mouseDoubleClickEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(),
- ev->buttons(), ev->globalPos());
- break; }
- case QEvent::InputMethod:
- d->inputMethodEvent(static_cast<QInputMethodEvent *>(e));
- break;
-#ifndef QT_NO_CONTEXTMENU
- case QEvent::ContextMenu: {
- QContextMenuEvent *ev = static_cast<QContextMenuEvent *>(e);
- d->contextMenuEvent(ev->globalPos(), matrix.map(ev->pos()), contextWidget);
- break; }
-#endif // QT_NO_CONTEXTMENU
- case QEvent::FocusIn:
- case QEvent::FocusOut:
- d->focusEvent(static_cast<QFocusEvent *>(e));
- break;
-
- case QEvent::EnabledChange:
- d->isEnabled = e->isAccepted();
- break;
-
-#ifndef QT_NO_TOOLTIP
- case QEvent::ToolTip: {
- QHelpEvent *ev = static_cast<QHelpEvent *>(e);
- d->showToolTip(ev->globalPos(), matrix.map(ev->pos()), contextWidget);
- break;
- }
-#endif // QT_NO_TOOLTIP
-
-#ifndef QT_NO_DRAGANDDROP
- case QEvent::DragEnter: {
- QDragEnterEvent *ev = static_cast<QDragEnterEvent *>(e);
- if (d->dragEnterEvent(e, ev->mimeData()))
- ev->acceptProposedAction();
- break;
- }
- case QEvent::DragLeave:
- d->dragLeaveEvent();
- break;
- case QEvent::DragMove: {
- QDragMoveEvent *ev = static_cast<QDragMoveEvent *>(e);
- if (d->dragMoveEvent(e, ev->mimeData(), matrix.map(ev->pos())))
- ev->acceptProposedAction();
- break;
- }
- case QEvent::Drop: {
- QDropEvent *ev = static_cast<QDropEvent *>(e);
- if (d->dropEvent(ev->mimeData(), matrix.map(ev->pos()), ev->dropAction(), ev->source()))
- ev->acceptProposedAction();
- break;
- }
-#endif
-
-#ifndef QT_NO_GRAPHICSVIEW
- case QEvent::GraphicsSceneMousePress: {
- QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e);
- d->mousePressEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(),
- ev->screenPos());
- break; }
- case QEvent::GraphicsSceneMouseMove: {
- QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e);
- d->mouseMoveEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(),
- ev->screenPos());
- break; }
- case QEvent::GraphicsSceneMouseRelease: {
- QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e);
- d->mouseReleaseEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(),
- ev->screenPos());
- break; }
- case QEvent::GraphicsSceneMouseDoubleClick: {
- QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e);
- d->mouseDoubleClickEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(),
- ev->screenPos());
- break; }
- case QEvent::GraphicsSceneContextMenu: {
- QGraphicsSceneContextMenuEvent *ev = static_cast<QGraphicsSceneContextMenuEvent *>(e);
- d->contextMenuEvent(ev->screenPos(), matrix.map(ev->pos()), contextWidget);
- break; }
-
- case QEvent::GraphicsSceneHoverMove: {
- QGraphicsSceneHoverEvent *ev = static_cast<QGraphicsSceneHoverEvent *>(e);
- d->mouseMoveEvent(ev, Qt::NoButton, matrix.map(ev->pos()), ev->modifiers(),Qt::NoButton,
- ev->screenPos());
- break; }
-
- case QEvent::GraphicsSceneDragEnter: {
- QGraphicsSceneDragDropEvent *ev = static_cast<QGraphicsSceneDragDropEvent *>(e);
- if (d->dragEnterEvent(e, ev->mimeData()))
- ev->acceptProposedAction();
- break; }
- case QEvent::GraphicsSceneDragLeave:
- d->dragLeaveEvent();
- break;
- case QEvent::GraphicsSceneDragMove: {
- QGraphicsSceneDragDropEvent *ev = static_cast<QGraphicsSceneDragDropEvent *>(e);
- if (d->dragMoveEvent(e, ev->mimeData(), matrix.map(ev->pos())))
- ev->acceptProposedAction();
- break; }
- case QEvent::GraphicsSceneDrop: {
- QGraphicsSceneDragDropEvent *ev = static_cast<QGraphicsSceneDragDropEvent *>(e);
- if (d->dropEvent(ev->mimeData(), matrix.map(ev->pos()), ev->dropAction(), ev->source()))
- ev->accept();
- break; }
-#endif // QT_NO_GRAPHICSVIEW
-#ifdef QT_KEYPAD_NAVIGATION
- case QEvent::EnterEditFocus:
- case QEvent::LeaveEditFocus:
- if (QApplication::keypadNavigationEnabled())
- d->editFocusEvent(e);
- break;
-#endif
- case QEvent::ShortcutOverride:
- if (d->interactionFlags & Qt::TextEditable) {
- QKeyEvent* ke = static_cast<QKeyEvent *>(e);
- if (ke->modifiers() == Qt::NoModifier
- || ke->modifiers() == Qt::ShiftModifier
- || ke->modifiers() == Qt::KeypadModifier) {
- if (ke->key() < Qt::Key_Escape) {
- ke->accept();
- } else {
- switch (ke->key()) {
- case Qt::Key_Return:
- case Qt::Key_Enter:
- case Qt::Key_Delete:
- case Qt::Key_Home:
- case Qt::Key_End:
- case Qt::Key_Backspace:
- case Qt::Key_Left:
- case Qt::Key_Right:
- case Qt::Key_Up:
- case Qt::Key_Down:
- case Qt::Key_Tab:
- ke->accept();
- default:
- break;
- }
- }
-#ifndef QT_NO_SHORTCUT
- } else if (ke == QKeySequence::Copy
- || ke == QKeySequence::Paste
- || ke == QKeySequence::Cut
- || ke == QKeySequence::Redo
- || ke == QKeySequence::Undo
- || ke == QKeySequence::MoveToNextWord
- || ke == QKeySequence::MoveToPreviousWord
- || ke == QKeySequence::MoveToStartOfDocument
- || ke == QKeySequence::MoveToEndOfDocument
- || ke == QKeySequence::SelectNextWord
- || ke == QKeySequence::SelectPreviousWord
- || ke == QKeySequence::SelectStartOfLine
- || ke == QKeySequence::SelectEndOfLine
- || ke == QKeySequence::SelectStartOfBlock
- || ke == QKeySequence::SelectEndOfBlock
- || ke == QKeySequence::SelectStartOfDocument
- || ke == QKeySequence::SelectEndOfDocument
- || ke == QKeySequence::SelectAll
- ) {
- ke->accept();
-#endif
- }
- }
- break;
- default:
- break;
- }
-}
-
-bool QTextControl::event(QEvent *e)
-{
- return QObject::event(e);
-}
-
-void QTextControl::timerEvent(QTimerEvent *e)
-{
- Q_D(QTextControl);
- if (e->timerId() == d->cursorBlinkTimer.timerId()) {
- d->cursorOn = !d->cursorOn;
-
- if (d->cursor.hasSelection())
- d->cursorOn &= (QApplication::style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected)
- != 0);
-
- d->repaintCursor();
- } else if (e->timerId() == d->trippleClickTimer.timerId()) {
- d->trippleClickTimer.stop();
- }
-}
-
-void QTextControl::setPlainText(const QString &text)
-{
- Q_D(QTextControl);
- d->setContent(Qt::PlainText, text);
-}
-
-void QTextControl::setHtml(const QString &text)
-{
- Q_D(QTextControl);
- d->setContent(Qt::RichText, text);
-}
-
-void QTextControlPrivate::keyPressEvent(QKeyEvent *e)
-{
- Q_Q(QTextControl);
-#ifndef QT_NO_SHORTCUT
- if (e == QKeySequence::SelectAll) {
- e->accept();
- q->selectAll();
- return;
- }
-#ifndef QT_NO_CLIPBOARD
- else if (e == QKeySequence::Copy) {
- e->accept();
- q->copy();
- return;
- }
-#endif
-#endif // QT_NO_SHORTCUT
-
- if (interactionFlags & Qt::TextSelectableByKeyboard
- && cursorMoveKeyEvent(e))
- goto accept;
-
- if (interactionFlags & Qt::LinksAccessibleByKeyboard) {
- if ((e->key() == Qt::Key_Return
- || e->key() == Qt::Key_Enter
-#ifdef QT_KEYPAD_NAVIGATION
- || e->key() == Qt::Key_Select
-#endif
- )
- && cursor.hasSelection()) {
-
- e->accept();
- activateLinkUnderCursor();
- return;
- }
- }
-
- if (!(interactionFlags & Qt::TextEditable)) {
- e->ignore();
- return;
- }
-
- if (e->key() == Qt::Key_Direction_L || e->key() == Qt::Key_Direction_R) {
- QTextBlockFormat fmt;
- fmt.setLayoutDirection((e->key() == Qt::Key_Direction_L) ? Qt::LeftToRight : Qt::RightToLeft);
- cursor.mergeBlockFormat(fmt);
- goto accept;
- }
-
- // schedule a repaint of the region of the cursor, as when we move it we
- // want to make sure the old cursor disappears (not noticeable when moving
- // only a few pixels but noticeable when jumping between cells in tables for
- // example)
- repaintSelection();
-
- if (e->key() == Qt::Key_Backspace && !(e->modifiers() & ~Qt::ShiftModifier)) {
- QTextBlockFormat blockFmt = cursor.blockFormat();
- QTextList *list = cursor.currentList();
- if (list && cursor.atBlockStart() && !cursor.hasSelection()) {
- list->remove(cursor.block());
- } else if (cursor.atBlockStart() && blockFmt.indent() > 0) {
- blockFmt.setIndent(blockFmt.indent() - 1);
- cursor.setBlockFormat(blockFmt);
- } else {
- QTextCursor localCursor = cursor;
- localCursor.deletePreviousChar();
- }
- goto accept;
- }
-#ifndef QT_NO_SHORTCUT
- else if (e == QKeySequence::InsertParagraphSeparator) {
- cursor.insertBlock();
- e->accept();
- goto accept;
- } else if (e == QKeySequence::InsertLineSeparator) {
- cursor.insertText(QString(QChar::LineSeparator));
- e->accept();
- goto accept;
- }
-#endif
- if (false) {
- }
-#ifndef QT_NO_SHORTCUT
- else if (e == QKeySequence::Undo) {
- q->undo();
- }
- else if (e == QKeySequence::Redo) {
- q->redo();
- }
-#ifndef QT_NO_CLIPBOARD
- else if (e == QKeySequence::Cut) {
- q->cut();
- }
- else if (e == QKeySequence::Paste) {
- QClipboard::Mode mode = QClipboard::Clipboard;
-#ifdef Q_WS_X11
- if (e->modifiers() == (Qt::CTRL | Qt::SHIFT) && e->key() == Qt::Key_Insert)
- mode = QClipboard::Selection;
-#endif
- q->paste(mode);
- }
-#endif
- else if (e == QKeySequence::Delete) {
- QTextCursor localCursor = cursor;
- localCursor.deleteChar();
- }
- else if (e == QKeySequence::DeleteEndOfWord) {
- if (!cursor.hasSelection())
- cursor.movePosition(QTextCursor::NextWord, QTextCursor::KeepAnchor);
- cursor.removeSelectedText();
- }
- else if (e == QKeySequence::DeleteStartOfWord) {
- if (!cursor.hasSelection())
- cursor.movePosition(QTextCursor::PreviousWord, QTextCursor::KeepAnchor);
- cursor.removeSelectedText();
- }
- else if (e == QKeySequence::DeleteEndOfLine) {
- QTextBlock block = cursor.block();
- if (cursor.position() == block.position() + block.length() - 2)
- cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
- else
- cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
- cursor.removeSelectedText();
- }
-#endif // QT_NO_SHORTCUT
- else {
- goto process;
- }
- goto accept;
-
-process:
- {
- QString text = e->text();
- if (!text.isEmpty() && (text.at(0).isPrint() || text.at(0) == QLatin1Char('\t'))) {
- if (overwriteMode
- // no need to call deleteChar() if we have a selection, insertText
- // does it already
- && !cursor.hasSelection()
- && !cursor.atBlockEnd())
- cursor.deleteChar();
-
- cursor.insertText(text);
- selectionChanged();
- } else {
- e->ignore();
- return;
- }
- }
-
- accept:
-
- e->accept();
- cursorOn = true;
-
- q->ensureCursorVisible();
-
- updateCurrentCharFormat();
-}
-
-QVariant QTextControl::loadResource(int type, const QUrl &name)
-{
-#ifdef QT_NO_TEXTEDIT
- Q_UNUSED(type);
- Q_UNUSED(name);
-#else
- if (QTextEdit *textEdit = qobject_cast<QTextEdit *>(parent())) {
- QUrl resolvedName = textEdit->d_func()->resolveUrl(name);
- return textEdit->loadResource(type, resolvedName);
- }
-#endif
- return QVariant();
-}
-
-void QTextControlPrivate::_q_updateBlock(const QTextBlock &block)
-{
- Q_Q(QTextControl);
- QRectF br = q->blockBoundingRect(block);
- br.setRight(qreal(INT_MAX)); // the block might have shrunk
- emit q->updateRequest(br);
-}
-
-QRectF QTextControlPrivate::rectForPosition(int position) const
-{
- Q_Q(const QTextControl);
- const QTextBlock block = doc->findBlock(position);
- if (!block.isValid())
- return QRectF();
- const QAbstractTextDocumentLayout *docLayout = doc->documentLayout();
- const QTextLayout *layout = block.layout();
- const QPointF layoutPos = q->blockBoundingRect(block).topLeft();
- int relativePos = position - block.position();
- if (preeditCursor != 0) {
- int preeditPos = layout->preeditAreaPosition();
- if (relativePos == preeditPos)
- relativePos += preeditCursor;
- else if (relativePos > preeditPos)
- relativePos += layout->preeditAreaText().length();
- }
- QTextLine line = layout->lineForTextPosition(relativePos);
-
- int cursorWidth;
- {
- bool ok = false;
-#ifndef QT_NO_PROPERTIES
- cursorWidth = docLayout->property("cursorWidth").toInt(&ok);
-#endif
- if (!ok)
- cursorWidth = 1;
- }
-
- QRectF r;
-
- if (line.isValid()) {
- qreal x = line.cursorToX(relativePos);
- qreal w = 0;
- if (overwriteMode) {
- if (relativePos < line.textLength() - line.textStart())
- w = line.cursorToX(relativePos + 1) - x;
- else
- w = QFontMetrics(block.layout()->font()).width(QLatin1Char(' ')); // in sync with QTextLine::draw()
- }
- r = QRectF(layoutPos.x() + x, layoutPos.y() + line.y(),
- cursorWidth + w, line.height());
- } else {
- r = QRectF(layoutPos.x(), layoutPos.y(), cursorWidth, 10); // #### correct height
- }
-
- return r;
-}
-
-static inline bool firstFramePosLessThanCursorPos(QTextFrame *frame, int position)
-{
- return frame->firstPosition() < position;
-}
-
-static inline bool cursorPosLessThanLastFramePos(int position, QTextFrame *frame)
-{
- return position < frame->lastPosition();
-}
-
-static QRectF boundingRectOfFloatsInSelection(const QTextCursor &cursor)
-{
- QRectF r;
- QTextFrame *frame = cursor.currentFrame();
- const QList<QTextFrame *> children = frame->childFrames();
-
- const QList<QTextFrame *>::ConstIterator firstFrame = qLowerBound(children.constBegin(), children.constEnd(),
- cursor.selectionStart(), firstFramePosLessThanCursorPos);
- const QList<QTextFrame *>::ConstIterator lastFrame = qUpperBound(children.constBegin(), children.constEnd(),
- cursor.selectionEnd(), cursorPosLessThanLastFramePos);
- for (QList<QTextFrame *>::ConstIterator it = firstFrame; it != lastFrame; ++it) {
- if ((*it)->frameFormat().position() != QTextFrameFormat::InFlow)
- r |= frame->document()->documentLayout()->frameBoundingRect(*it);
- }
- return r;
-}
-
-QRectF QTextControl::selectionRect(const QTextCursor &cursor) const
-{
- Q_D(const QTextControl);
-
- QRectF r = d->rectForPosition(cursor.selectionStart());
-
- if (cursor.hasComplexSelection() && cursor.currentTable()) {
- QTextTable *table = cursor.currentTable();
-
- r = d->doc->documentLayout()->frameBoundingRect(table);
- /*
- int firstRow, numRows, firstColumn, numColumns;
- cursor.selectedTableCells(&firstRow, &numRows, &firstColumn, &numColumns);
-
- const QTextTableCell firstCell = table->cellAt(firstRow, firstColumn);
- const QTextTableCell lastCell = table->cellAt(firstRow + numRows - 1, firstColumn + numColumns - 1);
-
- const QAbstractTextDocumentLayout * const layout = doc->documentLayout();
-
- QRectF tableSelRect = layout->blockBoundingRect(firstCell.firstCursorPosition().block());
-
- for (int col = firstColumn; col < firstColumn + numColumns; ++col) {
- const QTextTableCell cell = table->cellAt(firstRow, col);
- const qreal y = layout->blockBoundingRect(cell.firstCursorPosition().block()).top();
-
- tableSelRect.setTop(qMin(tableSelRect.top(), y));
- }
-
- for (int row = firstRow; row < firstRow + numRows; ++row) {
- const QTextTableCell cell = table->cellAt(row, firstColumn);
- const qreal x = layout->blockBoundingRect(cell.firstCursorPosition().block()).left();
-
- tableSelRect.setLeft(qMin(tableSelRect.left(), x));
- }
-
- for (int col = firstColumn; col < firstColumn + numColumns; ++col) {
- const QTextTableCell cell = table->cellAt(firstRow + numRows - 1, col);
- const qreal y = layout->blockBoundingRect(cell.lastCursorPosition().block()).bottom();
-
- tableSelRect.setBottom(qMax(tableSelRect.bottom(), y));
- }
-
- for (int row = firstRow; row < firstRow + numRows; ++row) {
- const QTextTableCell cell = table->cellAt(row, firstColumn + numColumns - 1);
- const qreal x = layout->blockBoundingRect(cell.lastCursorPosition().block()).right();
-
- tableSelRect.setRight(qMax(tableSelRect.right(), x));
- }
-
- r = tableSelRect.toRect();
- */
- } else if (cursor.hasSelection()) {
- const int position = cursor.selectionStart();
- const int anchor = cursor.selectionEnd();
- const QTextBlock posBlock = d->doc->findBlock(position);
- const QTextBlock anchorBlock = d->doc->findBlock(anchor);
- if (posBlock == anchorBlock && posBlock.isValid() && posBlock.layout()->lineCount()) {
- const QTextLine posLine = posBlock.layout()->lineForTextPosition(position - posBlock.position());
- const QTextLine anchorLine = anchorBlock.layout()->lineForTextPosition(anchor - anchorBlock.position());
-
- const int firstLine = qMin(posLine.lineNumber(), anchorLine.lineNumber());
- const int lastLine = qMax(posLine.lineNumber(), anchorLine.lineNumber());
- const QTextLayout *layout = posBlock.layout();
- r = QRectF();
- for (int i = firstLine; i <= lastLine; ++i) {
- r |= layout->lineAt(i).rect();
- r |= layout->lineAt(i).naturalTextRect(); // might be bigger in the case of wrap not enabled
- }
- r.translate(blockBoundingRect(posBlock).topLeft());
- } else {
- QRectF anchorRect = d->rectForPosition(cursor.selectionEnd());
- r |= anchorRect;
- r |= boundingRectOfFloatsInSelection(cursor);
- QRectF frameRect(d->doc->documentLayout()->frameBoundingRect(cursor.currentFrame()));
- r.setLeft(frameRect.left());
- r.setRight(frameRect.right());
- }
- if (r.isValid())
- r.adjust(-1, -1, 1, 1);
- }
-
- return r;
-}
-
-QRectF QTextControl::selectionRect() const
-{
- Q_D(const QTextControl);
- return selectionRect(d->cursor);
-}
-
-void QTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos, Qt::KeyboardModifiers modifiers,
- Qt::MouseButtons buttons, const QPoint &globalPos)
-{
- Q_Q(QTextControl);
-
- if (sendMouseEventToInputContext(
- e, QEvent::MouseButtonPress, button, pos, modifiers, buttons, globalPos)) {
- return;
- }
-
- if (interactionFlags & Qt::LinksAccessibleByMouse) {
- anchorOnMousePress = q->anchorAt(pos);
-
- if (cursorIsFocusIndicator) {
- cursorIsFocusIndicator = false;
- repaintSelection();
- cursor.clearSelection();
- }
- }
- if (!(button & Qt::LeftButton) ||
- !((interactionFlags & Qt::TextSelectableByMouse) || (interactionFlags & Qt::TextEditable))) {
- e->ignore();
- return;
- }
-
- cursorIsFocusIndicator = false;
- const QTextCursor oldSelection = cursor;
- const int oldCursorPos = cursor.position();
-
- mousePressed = (interactionFlags & Qt::TextSelectableByMouse);
-#ifndef QT_NO_DRAGANDDROP
- mightStartDrag = false;
-#endif
-
- if (trippleClickTimer.isActive()
- && ((pos - trippleClickPoint).toPoint().manhattanLength() < QApplication::startDragDistance())) {
-
- cursor.movePosition(QTextCursor::StartOfBlock);
- cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
- cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
- selectedBlockOnTrippleClick = cursor;
-
- anchorOnMousePress = QString();
-
- trippleClickTimer.stop();
- } else {
- int cursorPos = q->hitTest(pos, Qt::FuzzyHit);
- if (cursorPos == -1) {
- e->ignore();
- return;
- }
-
- if (modifiers == Qt::ShiftModifier && (interactionFlags & Qt::TextSelectableByMouse)) {
- if (wordSelectionEnabled && !selectedWordOnDoubleClick.hasSelection()) {
- selectedWordOnDoubleClick = cursor;
- selectedWordOnDoubleClick.select(QTextCursor::WordUnderCursor);
- }
-
- if (selectedBlockOnTrippleClick.hasSelection())
- extendBlockwiseSelection(cursorPos);
- else if (selectedWordOnDoubleClick.hasSelection())
- extendWordwiseSelection(cursorPos, pos.x());
- else if (!wordSelectionEnabled)
- setCursorPosition(cursorPos, QTextCursor::KeepAnchor);
- } else {
-
- if (dragEnabled
- && cursor.hasSelection()
- && !cursorIsFocusIndicator
- && cursorPos >= cursor.selectionStart()
- && cursorPos <= cursor.selectionEnd()
- && q->hitTest(pos, Qt::ExactHit) != -1) {
-#ifndef QT_NO_DRAGANDDROP
- mightStartDrag = true;
- dragStartPos = pos.toPoint();
-#endif
- return;
- }
-
- setCursorPosition(cursorPos);
- }
- }
-
- if (interactionFlags & Qt::TextEditable) {
- q->ensureCursorVisible();
- if (cursor.position() != oldCursorPos)
- emit q->cursorPositionChanged();
- _q_updateCurrentCharFormatAndSelection();
- } else {
- if (cursor.position() != oldCursorPos)
- emit q->cursorPositionChanged();
- selectionChanged();
- }
- repaintOldAndNewSelection(oldSelection);
- hadSelectionOnMousePress = cursor.hasSelection();
-}
-
-void QTextControlPrivate::mouseMoveEvent(QEvent *e, Qt::MouseButton button, const QPointF &mousePos, Qt::KeyboardModifiers modifiers,
- Qt::MouseButtons buttons, const QPoint &globalPos)
-{
- Q_Q(QTextControl);
-
- if (sendMouseEventToInputContext(
- e, QEvent::MouseMove, button, mousePos, modifiers, buttons, globalPos)) {
- return;
- }
-
- if (interactionFlags & Qt::LinksAccessibleByMouse) {
- QString anchor = q->anchorAt(mousePos);
- if (anchor != highlightedAnchor) {
- highlightedAnchor = anchor;
- emit q->linkHovered(anchor);
- }
- }
-
- if (!(buttons & Qt::LeftButton))
- return;
-
- const bool editable = interactionFlags & Qt::TextEditable;
-
- if (!(mousePressed
- || editable
- || mightStartDrag
- || selectedWordOnDoubleClick.hasSelection()
- || selectedBlockOnTrippleClick.hasSelection()))
- return;
-
- const QTextCursor oldSelection = cursor;
- const int oldCursorPos = cursor.position();
-
- if (mightStartDrag) {
- if ((mousePos.toPoint() - dragStartPos).manhattanLength() > QApplication::startDragDistance())
- startDrag();
- return;
- }
-
- if (!mousePressed)
- return;
-
- const qreal mouseX = qreal(mousePos.x());
-
- int newCursorPos = q->hitTest(mousePos, Qt::FuzzyHit);
- if (newCursorPos == -1)
- return;
-
- if (wordSelectionEnabled && !selectedWordOnDoubleClick.hasSelection()) {
- selectedWordOnDoubleClick = cursor;
- selectedWordOnDoubleClick.select(QTextCursor::WordUnderCursor);
- }
-
- if (selectedBlockOnTrippleClick.hasSelection())
- extendBlockwiseSelection(newCursorPos);
- else if (selectedWordOnDoubleClick.hasSelection())
- extendWordwiseSelection(newCursorPos, mouseX);
- else
- setCursorPosition(newCursorPos, QTextCursor::KeepAnchor);
-
- if (interactionFlags & Qt::TextEditable) {
- // don't call ensureVisible for the visible cursor to avoid jumping
- // scrollbars. the autoscrolling ensures smooth scrolling if necessary.
- //q->ensureCursorVisible();
- if (cursor.position() != oldCursorPos)
- emit q->cursorPositionChanged();
- _q_updateCurrentCharFormatAndSelection();
-#ifndef QT_NO_IM
- if (contextWidget) {
- if (QInputContext *ic = inputContext()) {
- ic->update();
- }
- }
-#endif //QT_NO_IM
- } else {
- //emit q->visibilityRequest(QRectF(mousePos, QSizeF(1, 1)));
- if (cursor.position() != oldCursorPos)
- emit q->cursorPositionChanged();
- }
- selectionChanged(true);
- repaintOldAndNewSelection(oldSelection);
-}
-
-void QTextControlPrivate::mouseReleaseEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos, Qt::KeyboardModifiers modifiers,
- Qt::MouseButtons buttons, const QPoint &globalPos)
-{
- Q_Q(QTextControl);
-
- if (sendMouseEventToInputContext(
- e, QEvent::MouseButtonRelease, button, pos, modifiers, buttons, globalPos)) {
- return;
- }
-
- const QTextCursor oldSelection = cursor;
- const int oldCursorPos = cursor.position();
-
-#ifndef QT_NO_DRAGANDDROP
- if (mightStartDrag && (button & Qt::LeftButton)) {
- mousePressed = false;
- setCursorPosition(pos);
- cursor.clearSelection();
- selectionChanged();
- }
-#endif
- if (mousePressed) {
- mousePressed = false;
-#ifndef QT_NO_CLIPBOARD
- setClipboardSelection();
- selectionChanged(true);
- } else if (button == Qt::MidButton
- && (interactionFlags & Qt::TextEditable)
- && QApplication::clipboard()->supportsSelection()) {
- setCursorPosition(pos);
- const QMimeData *md = QApplication::clipboard()->mimeData(QClipboard::Selection);
- if (md)
- q->insertFromMimeData(md);
-#endif
- }
-
- repaintOldAndNewSelection(oldSelection);
-
- if (cursor.position() != oldCursorPos)
- emit q->cursorPositionChanged();
-
- if (interactionFlags & Qt::LinksAccessibleByMouse) {
- if (!(button & Qt::LeftButton))
- return;
-
- const QString anchor = q->anchorAt(pos);
-
- if (anchor.isEmpty())
- return;
-
- if (!cursor.hasSelection()
- || (anchor == anchorOnMousePress && hadSelectionOnMousePress)) {
-
- const int anchorPos = q->hitTest(pos, Qt::ExactHit);
- if (anchorPos != -1) {
- cursor.setPosition(anchorPos);
-
- QString anchor = anchorOnMousePress;
- anchorOnMousePress = QString();
- activateLinkUnderCursor(anchor);
- }
- }
- }
-}
-
-void QTextControlPrivate::mouseDoubleClickEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos, Qt::KeyboardModifiers modifiers,
- Qt::MouseButtons buttons, const QPoint &globalPos)
-{
- Q_Q(QTextControl);
-
- if (sendMouseEventToInputContext(
- e, QEvent::MouseButtonDblClick, button, pos, modifiers, buttons, globalPos)) {
- return;
- }
-
- if (button != Qt::LeftButton
- || !(interactionFlags & Qt::TextSelectableByMouse)) {
- e->ignore();
- return;
- }
-
-#ifndef QT_NO_DRAGANDDROP
- mightStartDrag = false;
-#endif
- const QTextCursor oldSelection = cursor;
- setCursorPosition(pos);
- QTextLine line = currentTextLine(cursor);
- bool doEmit = false;
- if (line.isValid() && line.textLength()) {
- cursor.select(QTextCursor::WordUnderCursor);
- doEmit = true;
- }
- repaintOldAndNewSelection(oldSelection);
-
- cursorIsFocusIndicator = false;
- selectedWordOnDoubleClick = cursor;
-
- trippleClickPoint = pos;
- trippleClickTimer.start(QApplication::doubleClickInterval(), q);
- if (doEmit) {
- selectionChanged();
-#ifndef QT_NO_CLIPBOARD
- setClipboardSelection();
-#endif
- emit q->cursorPositionChanged();
- }
-}
-
-bool QTextControlPrivate::sendMouseEventToInputContext(
- QEvent *e, QEvent::Type eventType, Qt::MouseButton button, const QPointF &pos,
- Qt::KeyboardModifiers modifiers, Qt::MouseButtons buttons, const QPoint &globalPos)
-{
-#if !defined(QT_NO_IM)
- Q_Q(QTextControl);
-
- QTextLayout *layout = cursor.block().layout();
- if (contextWidget && layout && !layout->preeditAreaText().isEmpty()) {
- QInputContext *ctx = inputContext();
- int cursorPos = q->hitTest(pos, Qt::FuzzyHit) - cursor.position();
-
- if (cursorPos < 0 || cursorPos > layout->preeditAreaText().length()) {
- cursorPos = -1;
- // don't send move events outside the preedit area
- if (eventType == QEvent::MouseMove)
- return true;
- }
- if (ctx) {
- QMouseEvent ev(eventType, contextWidget->mapFromGlobal(globalPos), globalPos,
- button, buttons, modifiers);
- ctx->mouseHandler(cursorPos, &ev);
- e->setAccepted(ev.isAccepted());
- }
- if (!layout->preeditAreaText().isEmpty())
- return true;
- }
-#else
- Q_UNUSED(e);
- Q_UNUSED(eventType);
- Q_UNUSED(button);
- Q_UNUSED(pos);
- Q_UNUSED(modifiers);
- Q_UNUSED(buttons);
- Q_UNUSED(globalPos);
-#endif
- return false;
-}
-
-void QTextControlPrivate::contextMenuEvent(const QPoint &screenPos, const QPointF &docPos, QWidget *contextWidget)
-{
-#ifdef QT_NO_CONTEXTMENU
- Q_UNUSED(screenPos);
- Q_UNUSED(docPos);
- Q_UNUSED(contextWidget);
-#else
- Q_Q(QTextControl);
- if (!hasFocus)
- return;
- QMenu *menu = q->createStandardContextMenu(docPos, contextWidget);
- if (!menu)
- return;
- menu->setAttribute(Qt::WA_DeleteOnClose);
- menu->popup(screenPos);
-#endif
-}
-
-bool QTextControlPrivate::dragEnterEvent(QEvent *e, const QMimeData *mimeData)
-{
- Q_Q(QTextControl);
- if (!(interactionFlags & Qt::TextEditable) || !q->canInsertFromMimeData(mimeData)) {
- e->ignore();
- return false;
- }
-
- dndFeedbackCursor = QTextCursor();
-
- return true; // accept proposed action
-}
-
-void QTextControlPrivate::dragLeaveEvent()
-{
- Q_Q(QTextControl);
-
- const QRectF crect = q->cursorRect(dndFeedbackCursor);
- dndFeedbackCursor = QTextCursor();
-
- if (crect.isValid())
- emit q->updateRequest(crect);
-}
-
-bool QTextControlPrivate::dragMoveEvent(QEvent *e, const QMimeData *mimeData, const QPointF &pos)
-{
- Q_Q(QTextControl);
- if (!(interactionFlags & Qt::TextEditable) || !q->canInsertFromMimeData(mimeData)) {
- e->ignore();
- return false;
- }
-
- const int cursorPos = q->hitTest(pos, Qt::FuzzyHit);
- if (cursorPos != -1) {
- QRectF crect = q->cursorRect(dndFeedbackCursor);
- if (crect.isValid())
- emit q->updateRequest(crect);
-
- dndFeedbackCursor = cursor;
- dndFeedbackCursor.setPosition(cursorPos);
-
- crect = q->cursorRect(dndFeedbackCursor);
- emit q->updateRequest(crect);
- }
-
- return true; // accept proposed action
-}
-
-bool QTextControlPrivate::dropEvent(const QMimeData *mimeData, const QPointF &pos, Qt::DropAction dropAction, QWidget *source)
-{
- Q_Q(QTextControl);
- dndFeedbackCursor = QTextCursor();
-
- if (!(interactionFlags & Qt::TextEditable) || !q->canInsertFromMimeData(mimeData))
- return false;
-
- repaintSelection();
-
- QTextCursor insertionCursor = q->cursorForPosition(pos);
- insertionCursor.beginEditBlock();
-
- if (dropAction == Qt::MoveAction && source == contextWidget)
- cursor.removeSelectedText();
-
- cursor = insertionCursor;
- q->insertFromMimeData(mimeData);
- insertionCursor.endEditBlock();
- q->ensureCursorVisible();
- return true; // accept proposed action
-}
-
-void QTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
-{
- Q_Q(QTextControl);
- if (!(interactionFlags & Qt::TextEditable) || cursor.isNull()) {
- e->ignore();
- return;
- }
- bool isGettingInput = !e->commitString().isEmpty()
- || e->preeditString() != cursor.block().layout()->preeditAreaText()
- || e->replacementLength() > 0;
-
- cursor.beginEditBlock();
- if (isGettingInput) {
- cursor.removeSelectedText();
- }
-
- // insert commit string
- if (!e->commitString().isEmpty() || e->replacementLength()) {
- QTextCursor c = cursor;
- c.setPosition(c.position() + e->replacementStart());
- c.setPosition(c.position() + e->replacementLength(), QTextCursor::KeepAnchor);
- c.insertText(e->commitString());
- }
-
- for (int i = 0; i < e->attributes().size(); ++i) {
- const QInputMethodEvent::Attribute &a = e->attributes().at(i);
- if (a.type == QInputMethodEvent::Selection) {
- QTextCursor oldCursor = cursor;
- int blockStart = a.start + cursor.block().position();
- cursor.setPosition(blockStart, QTextCursor::MoveAnchor);
- cursor.setPosition(blockStart + a.length, QTextCursor::KeepAnchor);
- q->ensureCursorVisible();
- repaintOldAndNewSelection(oldCursor);
- }
- }
-
- QTextBlock block = cursor.block();
- QTextLayout *layout = block.layout();
- if (isGettingInput)
- layout->setPreeditArea(cursor.position() - block.position(), e->preeditString());
- QList<QTextLayout::FormatRange> overrides;
- const int oldPreeditCursor = preeditCursor;
- preeditCursor = e->preeditString().length();
- hideCursor = false;
- for (int i = 0; i < e->attributes().size(); ++i) {
- const QInputMethodEvent::Attribute &a = e->attributes().at(i);
- if (a.type == QInputMethodEvent::Cursor) {
- preeditCursor = a.start;
- hideCursor = !a.length;
- } else if (a.type == QInputMethodEvent::TextFormat) {
- QTextCharFormat f = qvariant_cast<QTextFormat>(a.value).toCharFormat();
- if (f.isValid()) {
- QTextLayout::FormatRange o;
- o.start = a.start + cursor.position() - block.position();
- o.length = a.length;
- o.format = f;
- overrides.append(o);
- }
- }
- }
- layout->setAdditionalFormats(overrides);
- cursor.endEditBlock();
- if (cursor.d)
- cursor.d->setX();
- if (oldPreeditCursor != preeditCursor)
- emit q->microFocusChanged();
-}
-
-QVariant QTextControl::inputMethodQuery(Qt::InputMethodQuery property) const
-{
- Q_D(const QTextControl);
- QTextBlock block = d->cursor.block();
- switch(property) {
- case Qt::ImMicroFocus:
- return cursorRect();
- case Qt::ImFont:
- return QVariant(d->cursor.charFormat().font());
- case Qt::ImCursorPosition:
- return QVariant(d->cursor.position() - block.position());
- case Qt::ImSurroundingText:
- return QVariant(block.text());
- case Qt::ImCurrentSelection:
- return QVariant(d->cursor.selectedText());
- case Qt::ImMaximumTextLength:
- return QVariant(); // No limit.
- case Qt::ImAnchorPosition:
- return QVariant(qBound(0, d->cursor.anchor() - block.position(), block.length()));
- default:
- return QVariant();
- }
-}
-
-void QTextControl::setFocus(bool focus, Qt::FocusReason reason)
-{
- QFocusEvent ev(focus ? QEvent::FocusIn : QEvent::FocusOut,
- reason);
- processEvent(&ev);
-}
-
-void QTextControlPrivate::focusEvent(QFocusEvent *e)
-{
- Q_Q(QTextControl);
- emit q->updateRequest(q->selectionRect());
- if (e->gotFocus()) {
-#ifdef QT_KEYPAD_NAVIGATION
- if (!QApplication::keypadNavigationEnabled() || (hasEditFocus && (e->reason() == Qt::PopupFocusReason
-#ifdef Q_OS_SYMBIAN
- || e->reason() == Qt::ActiveWindowFocusReason
-#endif
- ))) {
-#endif
- cursorOn = (interactionFlags & Qt::TextSelectableByKeyboard);
- if (interactionFlags & Qt::TextEditable) {
- setBlinkingCursorEnabled(true);
- }
-#ifdef QT_KEYPAD_NAVIGATION
- }
-#endif
- } else {
- setBlinkingCursorEnabled(false);
-
- if (cursorIsFocusIndicator
- && e->reason() != Qt::ActiveWindowFocusReason
- && e->reason() != Qt::PopupFocusReason
- && cursor.hasSelection()) {
- cursor.clearSelection();
- }
- }
- hasFocus = e->gotFocus();
-}
-
-QString QTextControlPrivate::anchorForCursor(const QTextCursor &anchorCursor) const
-{
- if (anchorCursor.hasSelection()) {
- QTextCursor cursor = anchorCursor;
- if (cursor.selectionStart() != cursor.position())
- cursor.setPosition(cursor.selectionStart());
- cursor.movePosition(QTextCursor::NextCharacter);
- QTextCharFormat fmt = cursor.charFormat();
- if (fmt.isAnchor() && fmt.hasProperty(QTextFormat::AnchorHref))
- return fmt.stringProperty(QTextFormat::AnchorHref);
- }
- return QString();
-}
-
-#ifdef QT_KEYPAD_NAVIGATION
-void QTextControlPrivate::editFocusEvent(QEvent *e)
-{
- Q_Q(QTextControl);
-
- if (QApplication::keypadNavigationEnabled()) {
- if (e->type() == QEvent::EnterEditFocus && interactionFlags & Qt::TextEditable) {
- const QTextCursor oldSelection = cursor;
- const int oldCursorPos = cursor.position();
- const bool moved = cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
- q->ensureCursorVisible();
- if (moved) {
- if (cursor.position() != oldCursorPos)
- emit q->cursorPositionChanged();
- emit q->microFocusChanged();
- }
- selectionChanged();
- repaintOldAndNewSelection(oldSelection);
-
- setBlinkingCursorEnabled(true);
- } else
- setBlinkingCursorEnabled(false);
- }
-
- hasEditFocus = e->type() == QEvent::EnterEditFocus ? true : false;
-}
-#endif
-
-#ifndef QT_NO_CONTEXTMENU
-QMenu *QTextControl::createStandardContextMenu(const QPointF &pos, QWidget *parent)
-{
- Q_D(QTextControl);
-
- const bool showTextSelectionActions = d->interactionFlags & (Qt::TextEditable | Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse);
-
- d->linkToCopy = QString();
- if (!pos.isNull())
- d->linkToCopy = anchorAt(pos);
-
- if (d->linkToCopy.isEmpty() && !showTextSelectionActions)
- return 0;
-
- QMenu *menu = new QMenu(parent);
- QAction *a;
-
- if (d->interactionFlags & Qt::TextEditable) {
- a = menu->addAction(tr("&Undo") + ACCEL_KEY(QKeySequence::Undo), this, SLOT(undo()));
- a->setEnabled(d->doc->isUndoAvailable());
- a = menu->addAction(tr("&Redo") + ACCEL_KEY(QKeySequence::Redo), this, SLOT(redo()));
- a->setEnabled(d->doc->isRedoAvailable());
- menu->addSeparator();
-
- a = menu->addAction(tr("Cu&t") + ACCEL_KEY(QKeySequence::Cut), this, SLOT(cut()));
- a->setEnabled(d->cursor.hasSelection());
- }
-
- if (showTextSelectionActions) {
- a = menu->addAction(tr("&Copy") + ACCEL_KEY(QKeySequence::Copy), this, SLOT(copy()));
- a->setEnabled(d->cursor.hasSelection());
- }
-
- if ((d->interactionFlags & Qt::LinksAccessibleByKeyboard)
- || (d->interactionFlags & Qt::LinksAccessibleByMouse)) {
-
- a = menu->addAction(tr("Copy &Link Location"), this, SLOT(_q_copyLink()));
- a->setEnabled(!d->linkToCopy.isEmpty());
- }
-
- if (d->interactionFlags & Qt::TextEditable) {
-#if !defined(QT_NO_CLIPBOARD)
- a = menu->addAction(tr("&Paste") + ACCEL_KEY(QKeySequence::Paste), this, SLOT(paste()));
- a->setEnabled(canPaste());
-#endif
- a = menu->addAction(tr("Delete"), this, SLOT(_q_deleteSelected()));
- a->setEnabled(d->cursor.hasSelection());
- }
-
-
- if (showTextSelectionActions) {
- menu->addSeparator();
- a = menu->addAction(tr("Select All") + ACCEL_KEY(QKeySequence::SelectAll), this, SLOT(selectAll()));
- a->setEnabled(!d->doc->isEmpty());
- }
-
-#if !defined(QT_NO_IM)
- if (d->contextWidget) {
- QInputContext *qic = d->inputContext();
- if (qic) {
- QList<QAction *> imActions = qic->actions();
- for (int i = 0; i < imActions.size(); ++i)
- menu->addAction(imActions.at(i));
- }
- }
-#endif
-
-#if defined(Q_WS_WIN) || defined(Q_WS_X11)
- if ((d->interactionFlags & Qt::TextEditable) && qt_use_rtl_extensions) {
-#else
- if (d->interactionFlags & Qt::TextEditable) {
-#endif
- menu->addSeparator();
- QUnicodeControlCharacterMenu *ctrlCharacterMenu = new QUnicodeControlCharacterMenu(this, menu);
- menu->addMenu(ctrlCharacterMenu);
- }
-
- return menu;
-}
-#endif // QT_NO_CONTEXTMENU
-
-QTextCursor QTextControl::cursorForPosition(const QPointF &pos) const
-{
- Q_D(const QTextControl);
- int cursorPos = hitTest(pos, Qt::FuzzyHit);
- if (cursorPos == -1)
- cursorPos = 0;
- QTextCursor c(d->doc);
- c.setPosition(cursorPos);
- return c;
-}
-
-QRectF QTextControl::cursorRect(const QTextCursor &cursor) const
-{
- Q_D(const QTextControl);
- if (cursor.isNull())
- return QRectF();
-
- return d->rectForPosition(cursor.position());
-}
-
-QRectF QTextControl::cursorRect() const
-{
- Q_D(const QTextControl);
- return cursorRect(d->cursor);
-}
-
-QRectF QTextControlPrivate::cursorRectPlusUnicodeDirectionMarkers(const QTextCursor &cursor) const
-{
- if (cursor.isNull())
- return QRectF();
-
- return rectForPosition(cursor.position()).adjusted(-4, 0, 4, 0);
-}
-
-QString QTextControl::anchorAt(const QPointF &pos) const
-{
- Q_D(const QTextControl);
- return d->doc->documentLayout()->anchorAt(pos);
-}
-
-QString QTextControl::anchorAtCursor() const
-{
- Q_D(const QTextControl);
-
- return d->anchorForCursor(d->cursor);
-}
-
-bool QTextControl::overwriteMode() const
-{
- Q_D(const QTextControl);
- return d->overwriteMode;
-}
-
-void QTextControl::setOverwriteMode(bool overwrite)
-{
- Q_D(QTextControl);
- d->overwriteMode = overwrite;
-}
-
-int QTextControl::cursorWidth() const
-{
-#ifndef QT_NO_PROPERTIES
- Q_D(const QTextControl);
- return d->doc->documentLayout()->property("cursorWidth").toInt();
-#else
- return 1;
-#endif
-}
-
-void QTextControl::setCursorWidth(int width)
-{
- Q_D(QTextControl);
-#ifdef QT_NO_PROPERTIES
- Q_UNUSED(width);
-#else
- if (width == -1)
- width = QApplication::style()->pixelMetric(QStyle::PM_TextCursorWidth);
- d->doc->documentLayout()->setProperty("cursorWidth", width);
-#endif
- d->repaintCursor();
-}
-
-bool QTextControl::acceptRichText() const
-{
- Q_D(const QTextControl);
- return d->acceptRichText;
-}
-
-void QTextControl::setAcceptRichText(bool accept)
-{
- Q_D(QTextControl);
- d->acceptRichText = accept;
-}
-
-#ifndef QT_NO_TEXTEDIT
-
-void QTextControl::setExtraSelections(const QList<QTextEdit::ExtraSelection> &selections)
-{
- Q_D(QTextControl);
-
- QHash<int, int> hash;
- for (int i = 0; i < d->extraSelections.count(); ++i) {
- const QAbstractTextDocumentLayout::Selection &esel = d->extraSelections.at(i);
- hash.insertMulti(esel.cursor.anchor(), i);
- }
-
- for (int i = 0; i < selections.count(); ++i) {
- const QTextEdit::ExtraSelection &sel = selections.at(i);
- QHash<int, int>::iterator it = hash.find(sel.cursor.anchor());
- if (it != hash.end()) {
- const QAbstractTextDocumentLayout::Selection &esel = d->extraSelections.at(it.value());
- if (esel.cursor.position() == sel.cursor.position()
- && esel.format == sel.format) {
- hash.erase(it);
- continue;
- }
- }
- QRectF r = selectionRect(sel.cursor);
- if (sel.format.boolProperty(QTextFormat::FullWidthSelection)) {
- r.setLeft(0);
- r.setWidth(qreal(INT_MAX));
- }
- emit updateRequest(r);
- }
-
- for (QHash<int, int>::iterator it = hash.begin(); it != hash.end(); ++it) {
- const QAbstractTextDocumentLayout::Selection &esel = d->extraSelections.at(it.value());
- QRectF r = selectionRect(esel.cursor);
- if (esel.format.boolProperty(QTextFormat::FullWidthSelection)) {
- r.setLeft(0);
- r.setWidth(qreal(INT_MAX));
- }
- emit updateRequest(r);
- }
-
- d->extraSelections.resize(selections.count());
- for (int i = 0; i < selections.count(); ++i) {
- d->extraSelections[i].cursor = selections.at(i).cursor;
- d->extraSelections[i].format = selections.at(i).format;
- }
-}
-
-QList<QTextEdit::ExtraSelection> QTextControl::extraSelections() const
-{
- Q_D(const QTextControl);
- QList<QTextEdit::ExtraSelection> selections;
- for (int i = 0; i < d->extraSelections.count(); ++i) {
- QTextEdit::ExtraSelection sel;
- sel.cursor = d->extraSelections.at(i).cursor;
- sel.format = d->extraSelections.at(i).format;
- selections.append(sel);
- }
- return selections;
-}
-
-#endif // QT_NO_TEXTEDIT
-
-void QTextControl::setTextWidth(qreal width)
-{
- Q_D(QTextControl);
- d->doc->setTextWidth(width);
-}
-
-qreal QTextControl::textWidth() const
-{
- Q_D(const QTextControl);
- return d->doc->textWidth();
-}
-
-QSizeF QTextControl::size() const
-{
- Q_D(const QTextControl);
- return d->doc->size();
-}
-
-void QTextControl::setOpenExternalLinks(bool open)
-{
- Q_D(QTextControl);
- d->openExternalLinks = open;
-}
-
-bool QTextControl::openExternalLinks() const
-{
- Q_D(const QTextControl);
- return d->openExternalLinks;
-}
-
-bool QTextControl::ignoreUnusedNavigationEvents() const
-{
- Q_D(const QTextControl);
- return d->ignoreUnusedNavigationEvents;
-}
-
-void QTextControl::setIgnoreUnusedNavigationEvents(bool ignore)
-{
- Q_D(QTextControl);
- d->ignoreUnusedNavigationEvents = ignore;
-}
-
-void QTextControl::moveCursor(QTextCursor::MoveOperation op, QTextCursor::MoveMode mode)
-{
- Q_D(QTextControl);
- const QTextCursor oldSelection = d->cursor;
- const bool moved = d->cursor.movePosition(op, mode);
- d->_q_updateCurrentCharFormatAndSelection();
- ensureCursorVisible();
- d->repaintOldAndNewSelection(oldSelection);
- if (moved)
- emit cursorPositionChanged();
-}
-
-bool QTextControl::canPaste() const
-{
-#ifndef QT_NO_CLIPBOARD
- Q_D(const QTextControl);
- if (d->interactionFlags & Qt::TextEditable) {
- const QMimeData *md = QApplication::clipboard()->mimeData();
- return md && canInsertFromMimeData(md);
- }
-#endif
- return false;
-}
-
-void QTextControl::setCursorIsFocusIndicator(bool b)
-{
- Q_D(QTextControl);
- d->cursorIsFocusIndicator = b;
- d->repaintCursor();
-}
-
-bool QTextControl::cursorIsFocusIndicator() const
-{
- Q_D(const QTextControl);
- return d->cursorIsFocusIndicator;
-}
-
-
-void QTextControl::setDragEnabled(bool enabled)
-{
- Q_D(QTextControl);
- d->dragEnabled = enabled;
-}
-
-bool QTextControl::isDragEnabled() const
-{
- Q_D(const QTextControl);
- return d->dragEnabled;
-}
-
-void QTextControl::setWordSelectionEnabled(bool enabled)
-{
- Q_D(QTextControl);
- d->wordSelectionEnabled = enabled;
-}
-
-bool QTextControl::isWordSelectionEnabled() const
-{
- Q_D(const QTextControl);
- return d->wordSelectionEnabled;
-}
-
-#ifndef QT_NO_PRINTER
-void QTextControl::print(QPrinter *printer) const
-{
-#ifndef QT_NO_PRINTER
- Q_D(const QTextControl);
- if (!printer || !printer->isValid())
- return;
- QTextDocument *tempDoc = 0;
- const QTextDocument *doc = d->doc;
- if (printer->printRange() == QPrinter::Selection) {
- if (!d->cursor.hasSelection())
- return;
- tempDoc = new QTextDocument(const_cast<QTextDocument *>(doc));
- tempDoc->setMetaInformation(QTextDocument::DocumentTitle, doc->metaInformation(QTextDocument::DocumentTitle));
- tempDoc->setPageSize(doc->pageSize());
- tempDoc->setDefaultFont(doc->defaultFont());
- tempDoc->setUseDesignMetrics(doc->useDesignMetrics());
- QTextCursor(tempDoc).insertFragment(d->cursor.selection());
- doc = tempDoc;
-
- // copy the custom object handlers
- doc->documentLayout()->d_func()->handlers = d->doc->documentLayout()->d_func()->handlers;
- }
- doc->print(printer);
- delete tempDoc;
-#endif
-}
-#endif // QT_NO_PRINTER
-
-QMimeData *QTextControl::createMimeDataFromSelection() const
-{
- Q_D(const QTextControl);
- const QTextDocumentFragment fragment(d->cursor);
- return new QTextEditMimeData(fragment);
-}
-
-bool QTextControl::canInsertFromMimeData(const QMimeData *source) const
-{
- Q_D(const QTextControl);
- if (d->acceptRichText)
- return (source->hasText() && !source->text().isEmpty())
- || source->hasHtml()
- || source->hasFormat(QLatin1String("application/x-qrichtext"))
- || source->hasFormat(QLatin1String("application/x-qt-richtext"));
- else
- return source->hasText() && !source->text().isEmpty();
-}
-
-void QTextControl::insertFromMimeData(const QMimeData *source)
-{
- Q_D(QTextControl);
- if (!(d->interactionFlags & Qt::TextEditable) || !source)
- return;
-
- bool hasData = false;
- QTextDocumentFragment fragment;
-#ifndef QT_NO_TEXTHTMLPARSER
- if (source->hasFormat(QLatin1String("application/x-qrichtext")) && d->acceptRichText) {
- // x-qrichtext is always UTF-8 (taken from Qt3 since we don't use it anymore).
- QString richtext = QString::fromUtf8(source->data(QLatin1String("application/x-qrichtext")));
- richtext.prepend(QLatin1String("<meta name=\"qrichtext\" content=\"1\" />"));
- fragment = QTextDocumentFragment::fromHtml(richtext, d->doc);
- hasData = true;
- } else if (source->hasHtml() && d->acceptRichText) {
- fragment = QTextDocumentFragment::fromHtml(source->html(), d->doc);
- hasData = true;
- } else {
- QString text = source->text();
- if (!text.isNull()) {
- fragment = QTextDocumentFragment::fromPlainText(text);
- hasData = true;
- }
- }
-#else
- fragment = QTextDocumentFragment::fromPlainText(source->text());
-#endif // QT_NO_TEXTHTMLPARSER
-
- if (hasData)
- d->cursor.insertFragment(fragment);
- ensureCursorVisible();
-}
-
-bool QTextControl::findNextPrevAnchor(const QTextCursor &startCursor, bool next, QTextCursor &newAnchor)
-{
- Q_D(QTextControl);
-
- int anchorStart = -1;
- QString anchorHref;
- int anchorEnd = -1;
-
- if (next) {
- const int startPos = startCursor.selectionEnd();
-
- QTextBlock block = d->doc->findBlock(startPos);
- QTextBlock::Iterator it = block.begin();
-
- while (!it.atEnd() && it.fragment().position() < startPos)
- ++it;
-
- while (block.isValid()) {
- anchorStart = -1;
-
- // find next anchor
- for (; !it.atEnd(); ++it) {
- const QTextFragment fragment = it.fragment();
- const QTextCharFormat fmt = fragment.charFormat();
-
- if (fmt.isAnchor() && fmt.hasProperty(QTextFormat::AnchorHref)) {
- anchorStart = fragment.position();
- anchorHref = fmt.anchorHref();
- break;
- }
- }
-
- if (anchorStart != -1) {
- anchorEnd = -1;
-
- // find next non-anchor fragment
- for (; !it.atEnd(); ++it) {
- const QTextFragment fragment = it.fragment();
- const QTextCharFormat fmt = fragment.charFormat();
-
- if (!fmt.isAnchor() || fmt.anchorHref() != anchorHref) {
- anchorEnd = fragment.position();
- break;
- }
- }
-
- if (anchorEnd == -1)
- anchorEnd = block.position() + block.length() - 1;
-
- // make found selection
- break;
- }
-
- block = block.next();
- it = block.begin();
- }
- } else {
- int startPos = startCursor.selectionStart();
- if (startPos > 0)
- --startPos;
-
- QTextBlock block = d->doc->findBlock(startPos);
- QTextBlock::Iterator blockStart = block.begin();
- QTextBlock::Iterator it = block.end();
-
- if (startPos == block.position()) {
- it = block.begin();
- } else {
- do {
- if (it == blockStart) {
- it = QTextBlock::Iterator();
- block = QTextBlock();
- } else {
- --it;
- }
- } while (!it.atEnd() && it.fragment().position() + it.fragment().length() - 1 > startPos);
- }
-
- while (block.isValid()) {
- anchorStart = -1;
-
- if (!it.atEnd()) {
- do {
- const QTextFragment fragment = it.fragment();
- const QTextCharFormat fmt = fragment.charFormat();
-
- if (fmt.isAnchor() && fmt.hasProperty(QTextFormat::AnchorHref)) {
- anchorStart = fragment.position() + fragment.length();
- anchorHref = fmt.anchorHref();
- break;
- }
-
- if (it == blockStart)
- it = QTextBlock::Iterator();
- else
- --it;
- } while (!it.atEnd());
- }
-
- if (anchorStart != -1 && !it.atEnd()) {
- anchorEnd = -1;
-
- do {
- const QTextFragment fragment = it.fragment();
- const QTextCharFormat fmt = fragment.charFormat();
-
- if (!fmt.isAnchor() || fmt.anchorHref() != anchorHref) {
- anchorEnd = fragment.position() + fragment.length();
- break;
- }
-
- if (it == blockStart)
- it = QTextBlock::Iterator();
- else
- --it;
- } while (!it.atEnd());
-
- if (anchorEnd == -1)
- anchorEnd = qMax(0, block.position());
-
- break;
- }
-
- block = block.previous();
- it = block.end();
- if (it != block.begin())
- --it;
- blockStart = block.begin();
- }
-
- }
-
- if (anchorStart != -1 && anchorEnd != -1) {
- newAnchor = d->cursor;
- newAnchor.setPosition(anchorStart);
- newAnchor.setPosition(anchorEnd, QTextCursor::KeepAnchor);
- return true;
- }
-
- return false;
-}
-
-void QTextControlPrivate::activateLinkUnderCursor(QString href)
-{
- QTextCursor oldCursor = cursor;
-
- if (href.isEmpty()) {
- QTextCursor tmp = cursor;
- if (tmp.selectionStart() != tmp.position())
- tmp.setPosition(tmp.selectionStart());
- tmp.movePosition(QTextCursor::NextCharacter);
- href = tmp.charFormat().anchorHref();
- }
- if (href.isEmpty())
- return;
-
- if (!cursor.hasSelection()) {
- QTextBlock block = cursor.block();
- const int cursorPos = cursor.position();
-
- QTextBlock::Iterator it = block.begin();
- QTextBlock::Iterator linkFragment;
-
- for (; !it.atEnd(); ++it) {
- QTextFragment fragment = it.fragment();
- const int fragmentPos = fragment.position();
- if (fragmentPos <= cursorPos &&
- fragmentPos + fragment.length() > cursorPos) {
- linkFragment = it;
- break;
- }
- }
-
- if (!linkFragment.atEnd()) {
- it = linkFragment;
- cursor.setPosition(it.fragment().position());
- if (it != block.begin()) {
- do {
- --it;
- QTextFragment fragment = it.fragment();
- if (fragment.charFormat().anchorHref() != href)
- break;
- cursor.setPosition(fragment.position());
- } while (it != block.begin());
- }
-
- for (it = linkFragment; !it.atEnd(); ++it) {
- QTextFragment fragment = it.fragment();
- if (fragment.charFormat().anchorHref() != href)
- break;
- cursor.setPosition(fragment.position() + fragment.length(), QTextCursor::KeepAnchor);
- }
- }
- }
-
- if (hasFocus) {
- cursorIsFocusIndicator = true;
- } else {
- cursorIsFocusIndicator = false;
- cursor.clearSelection();
- }
- repaintOldAndNewSelection(oldCursor);
-
-#ifndef QT_NO_DESKTOPSERVICES
- if (openExternalLinks)
- QDesktopServices::openUrl(href);
- else
-#endif
- emit q_func()->linkActivated(href);
-}
-
-#ifndef QT_NO_TOOLTIP
-void QTextControlPrivate::showToolTip(const QPoint &globalPos, const QPointF &pos, QWidget *contextWidget)
-{
- const QString toolTip = q_func()->cursorForPosition(pos).charFormat().toolTip();
- if (toolTip.isEmpty())
- return;
- QToolTip::showText(globalPos, toolTip, contextWidget);
-}
-#endif // QT_NO_TOOLTIP
-
-bool QTextControl::setFocusToNextOrPreviousAnchor(bool next)
-{
- Q_D(QTextControl);
-
- if (!(d->interactionFlags & Qt::LinksAccessibleByKeyboard))
- return false;
-
- QRectF crect = selectionRect();
- emit updateRequest(crect);
-
- // If we don't have a current anchor, we start from the start/end
- if (!d->cursor.hasSelection()) {
- d->cursor = QTextCursor(d->doc);
- if (next)
- d->cursor.movePosition(QTextCursor::Start);
- else
- d->cursor.movePosition(QTextCursor::End);
- }
-
- QTextCursor newAnchor;
- if (findNextPrevAnchor(d->cursor, next, newAnchor)) {
- d->cursor = newAnchor;
- d->cursorIsFocusIndicator = true;
- } else {
- d->cursor.clearSelection();
- }
-
- if (d->cursor.hasSelection()) {
- crect = selectionRect();
- emit updateRequest(crect);
- emit visibilityRequest(crect);
- return true;
- } else {
- return false;
- }
-}
-
-bool QTextControl::setFocusToAnchor(const QTextCursor &newCursor)
-{
- Q_D(QTextControl);
-
- if (!(d->interactionFlags & Qt::LinksAccessibleByKeyboard))
- return false;
-
- // Verify that this is an anchor.
- const QString anchorHref = d->anchorForCursor(newCursor);
- if (anchorHref.isEmpty())
- return false;
-
- // and process it
- QRectF crect = selectionRect();
- emit updateRequest(crect);
-
- d->cursor.setPosition(newCursor.selectionStart());
- d->cursor.setPosition(newCursor.selectionEnd(), QTextCursor::KeepAnchor);
- d->cursorIsFocusIndicator = true;
-
- crect = selectionRect();
- emit updateRequest(crect);
- emit visibilityRequest(crect);
- return true;
-}
-
-void QTextControl::setTextInteractionFlags(Qt::TextInteractionFlags flags)
-{
- Q_D(QTextControl);
- if (flags == d->interactionFlags)
- return;
- d->interactionFlags = flags;
-
- if (d->hasFocus)
- d->setBlinkingCursorEnabled(flags & Qt::TextEditable);
-}
-
-Qt::TextInteractionFlags QTextControl::textInteractionFlags() const
-{
- Q_D(const QTextControl);
- return d->interactionFlags;
-}
-
-void QTextControl::mergeCurrentCharFormat(const QTextCharFormat &modifier)
-{
- Q_D(QTextControl);
- d->cursor.mergeCharFormat(modifier);
- d->updateCurrentCharFormat();
-}
-
-void QTextControl::setCurrentCharFormat(const QTextCharFormat &format)
-{
- Q_D(QTextControl);
- d->cursor.setCharFormat(format);
- d->updateCurrentCharFormat();
-}
-
-QTextCharFormat QTextControl::currentCharFormat() const
-{
- Q_D(const QTextControl);
- return d->cursor.charFormat();
-}
-
-void QTextControl::insertPlainText(const QString &text)
-{
- Q_D(QTextControl);
- d->cursor.insertText(text);
-}
-
-#ifndef QT_NO_TEXTHTMLPARSER
-void QTextControl::insertHtml(const QString &text)
-{
- Q_D(QTextControl);
- d->cursor.insertHtml(text);
-}
-#endif // QT_NO_TEXTHTMLPARSER
-
-QPointF QTextControl::anchorPosition(const QString &name) const
-{
- Q_D(const QTextControl);
- if (name.isEmpty())
- return QPointF();
-
- QRectF r;
- for (QTextBlock block = d->doc->begin(); block.isValid(); block = block.next()) {
- QTextCharFormat format = block.charFormat();
- if (format.isAnchor() && format.anchorNames().contains(name)) {
- r = d->rectForPosition(block.position());
- break;
- }
-
- for (QTextBlock::Iterator it = block.begin(); !it.atEnd(); ++it) {
- QTextFragment fragment = it.fragment();
- format = fragment.charFormat();
- if (format.isAnchor() && format.anchorNames().contains(name)) {
- r = d->rectForPosition(fragment.position());
- block = QTextBlock();
- break;
- }
- }
- }
- if (!r.isValid())
- return QPointF();
- return QPointF(0, r.top());
-}
-
-void QTextControl::adjustSize()
-{
- Q_D(QTextControl);
- d->doc->adjustSize();
-}
-
-bool QTextControl::find(const QString &exp, QTextDocument::FindFlags options)
-{
- Q_D(QTextControl);
- QTextCursor search = d->doc->find(exp, d->cursor, options);
- if (search.isNull())
- return false;
-
- setTextCursor(search);
- return true;
-}
-
-
-
-void QTextControlPrivate::append(const QString &text, Qt::TextFormat format)
-{
- QTextCursor tmp(doc);
- tmp.beginEditBlock();
- tmp.movePosition(QTextCursor::End);
-
- if (!doc->isEmpty())
- tmp.insertBlock(cursor.blockFormat(), cursor.charFormat());
- else
- tmp.setCharFormat(cursor.charFormat());
-
- // preserve the char format
- QTextCharFormat oldCharFormat = cursor.charFormat();
-
-#ifndef QT_NO_TEXTHTMLPARSER
- if (format == Qt::RichText || (format == Qt::AutoText && Qt::mightBeRichText(text))) {
- tmp.insertHtml(text);
- } else {
- tmp.insertText(text);
- }
-#else
- tmp.insertText(text);
-#endif // QT_NO_TEXTHTMLPARSER
- if (!cursor.hasSelection())
- cursor.setCharFormat(oldCharFormat);
-
- tmp.endEditBlock();
-}
-
-void QTextControl::append(const QString &text)
-{
- Q_D(QTextControl);
- d->append(text, Qt::AutoText);
-}
-
-void QTextControl::appendHtml(const QString &html)
-{
- Q_D(QTextControl);
- d->append(html, Qt::RichText);
-}
-
-void QTextControl::appendPlainText(const QString &text)
-{
- Q_D(QTextControl);
- d->append(text, Qt::PlainText);
-}
-
-
-void QTextControl::ensureCursorVisible()
-{
- Q_D(QTextControl);
- QRectF crect = d->rectForPosition(d->cursor.position()).adjusted(-5, 0, 5, 0);
- emit visibilityRequest(crect);
- emit microFocusChanged();
-}
-
-QPalette QTextControl::palette() const
-{
- Q_D(const QTextControl);
- return d->palette;
-}
-
-void QTextControl::setPalette(const QPalette &pal)
-{
- Q_D(QTextControl);
- d->palette = pal;
-}
-
-QAbstractTextDocumentLayout::PaintContext QTextControl::getPaintContext(QWidget *widget) const
-{
- Q_D(const QTextControl);
-
- QAbstractTextDocumentLayout::PaintContext ctx;
-
- ctx.selections = d->extraSelections;
- ctx.palette = d->palette;
- if (d->cursorOn && d->isEnabled) {
- if (d->hideCursor)
- ctx.cursorPosition = -1;
- else if (d->preeditCursor != 0)
- ctx.cursorPosition = - (d->preeditCursor + 2);
- else
- ctx.cursorPosition = d->cursor.position();
- }
-
- if (!d->dndFeedbackCursor.isNull())
- ctx.cursorPosition = d->dndFeedbackCursor.position();
-#ifdef QT_KEYPAD_NAVIGATION
- if (!QApplication::keypadNavigationEnabled() || d->hasEditFocus)
-#endif
- if (d->cursor.hasSelection()) {
- QAbstractTextDocumentLayout::Selection selection;
- selection.cursor = d->cursor;
- if (d->cursorIsFocusIndicator) {
- QStyleOption opt;
- opt.palette = ctx.palette;
- QStyleHintReturnVariant ret;
- QStyle *style = QApplication::style();
- if (widget)
- style = widget->style();
- style->styleHint(QStyle::SH_TextControl_FocusIndicatorTextCharFormat, &opt, widget, &ret);
- selection.format = qvariant_cast<QTextFormat>(ret.variant).toCharFormat();
- } else {
- QPalette::ColorGroup cg = d->hasFocus ? QPalette::Active : QPalette::Inactive;
- selection.format.setBackground(ctx.palette.brush(cg, QPalette::Highlight));
- selection.format.setForeground(ctx.palette.brush(cg, QPalette::HighlightedText));
- QStyleOption opt;
- QStyle *style = QApplication::style();
- if (widget) {
- opt.initFrom(widget);
- style = widget->style();
- }
- if (style->styleHint(QStyle::SH_RichText_FullWidthSelection, &opt, widget))
- selection.format.setProperty(QTextFormat::FullWidthSelection, true);
- }
- ctx.selections.append(selection);
- }
-
- return ctx;
-}
-
-void QTextControl::drawContents(QPainter *p, const QRectF &rect, QWidget *widget)
-{
- Q_D(QTextControl);
- p->save();
- QAbstractTextDocumentLayout::PaintContext ctx = getPaintContext(widget);
- if (rect.isValid())
- p->setClipRect(rect, Qt::IntersectClip);
- ctx.clip = rect;
-
- d->doc->documentLayout()->draw(p, ctx);
- p->restore();
-}
-
-void QTextControlPrivate::_q_copyLink()
-{
-#ifndef QT_NO_CLIPBOARD
- QMimeData *md = new QMimeData;
- md->setText(linkToCopy);
- QApplication::clipboard()->setMimeData(md);
-#endif
-}
-
-QInputContext *QTextControlPrivate::inputContext()
-{
- QInputContext *ctx = contextWidget->inputContext();
- if (!ctx && contextWidget->parentWidget())
- ctx = contextWidget->parentWidget()->inputContext();
- return ctx;
-}
-
-int QTextControl::hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const
-{
- Q_D(const QTextControl);
- return d->doc->documentLayout()->hitTest(point, accuracy);
-}
-
-QRectF QTextControl::blockBoundingRect(const QTextBlock &block) const
-{
- Q_D(const QTextControl);
- return d->doc->documentLayout()->blockBoundingRect(block);
-}
-
-#ifndef QT_NO_CONTEXTMENU
-#define NUM_CONTROL_CHARACTERS 10
-const struct QUnicodeControlCharacter {
- const char *text;
- ushort character;
-} qt_controlCharacters[NUM_CONTROL_CHARACTERS] = {
- { QT_TRANSLATE_NOOP("QUnicodeControlCharacterMenu", "LRM Left-to-right mark"), 0x200e },
- { QT_TRANSLATE_NOOP("QUnicodeControlCharacterMenu", "RLM Right-to-left mark"), 0x200f },
- { QT_TRANSLATE_NOOP("QUnicodeControlCharacterMenu", "ZWJ Zero width joiner"), 0x200d },
- { QT_TRANSLATE_NOOP("QUnicodeControlCharacterMenu", "ZWNJ Zero width non-joiner"), 0x200c },
- { QT_TRANSLATE_NOOP("QUnicodeControlCharacterMenu", "ZWSP Zero width space"), 0x200b },
- { QT_TRANSLATE_NOOP("QUnicodeControlCharacterMenu", "LRE Start of left-to-right embedding"), 0x202a },
- { QT_TRANSLATE_NOOP("QUnicodeControlCharacterMenu", "RLE Start of right-to-left embedding"), 0x202b },
- { QT_TRANSLATE_NOOP("QUnicodeControlCharacterMenu", "LRO Start of left-to-right override"), 0x202d },
- { QT_TRANSLATE_NOOP("QUnicodeControlCharacterMenu", "RLO Start of right-to-left override"), 0x202e },
- { QT_TRANSLATE_NOOP("QUnicodeControlCharacterMenu", "PDF Pop directional formatting"), 0x202c },
-};
-
-QUnicodeControlCharacterMenu::QUnicodeControlCharacterMenu(QObject *_editWidget, QWidget *parent)
- : QMenu(parent), editWidget(_editWidget)
-{
- setTitle(tr("Insert Unicode control character"));
- for (int i = 0; i < NUM_CONTROL_CHARACTERS; ++i) {
- addAction(tr(qt_controlCharacters[i].text), this, SLOT(menuActionTriggered()));
- }
-}
-
-void QUnicodeControlCharacterMenu::menuActionTriggered()
-{
- QAction *a = qobject_cast<QAction *>(sender());
- int idx = actions().indexOf(a);
- if (idx < 0 || idx >= NUM_CONTROL_CHARACTERS)
- return;
- QChar c(qt_controlCharacters[idx].character);
- QString str(c);
-
-#ifndef QT_NO_TEXTEDIT
- if (QTextEdit *edit = qobject_cast<QTextEdit *>(editWidget)) {
- edit->insertPlainText(str);
- return;
- }
-#endif
- if (QTextControl *control = qobject_cast<QTextControl *>(editWidget)) {
- control->insertPlainText(str);
- }
-#ifndef QT_NO_LINEEDIT
- if (QLineEdit *edit = qobject_cast<QLineEdit *>(editWidget)) {
- edit->insert(str);
- return;
- }
-#endif
-}
-#endif // QT_NO_CONTEXTMENU
-
-QStringList QTextEditMimeData::formats() const
-{
- if (!fragment.isEmpty())
- return QStringList() << QString::fromLatin1("text/plain") << QString::fromLatin1("text/html")
-#ifndef QT_NO_TEXTODFWRITER
- << QString::fromLatin1("application/vnd.oasis.opendocument.text")
-#endif
- ;
- else
- return QMimeData::formats();
-}
-
-QVariant QTextEditMimeData::retrieveData(const QString &mimeType, QVariant::Type type) const
-{
- if (!fragment.isEmpty())
- setup();
- return QMimeData::retrieveData(mimeType, type);
-}
-
-void QTextEditMimeData::setup() const
-{
- QTextEditMimeData *that = const_cast<QTextEditMimeData *>(this);
-#ifndef QT_NO_TEXTHTMLPARSER
- that->setData(QLatin1String("text/html"), fragment.toHtml("utf-8").toUtf8());
-#endif
-#ifndef QT_NO_TEXTODFWRITER
- {
- QBuffer buffer;
- QTextDocumentWriter writer(&buffer, "ODF");
- writer.write(fragment);
- buffer.close();
- that->setData(QLatin1String("application/vnd.oasis.opendocument.text"), buffer.data());
- }
-#endif
- that->setText(fragment.toPlainText());
- fragment = QTextDocumentFragment();
-}
-
-QT_END_NAMESPACE
-
-#include "moc_qtextcontrol_p.cpp"
-
-#endif // QT_NO_TEXTCONTROL
diff --git a/src/gui/text/qtextcontrol_p.h b/src/gui/text/qtextcontrol_p.h
deleted file mode 100644
index 31fa843a3a..0000000000
--- a/src/gui/text/qtextcontrol_p.h
+++ /dev/null
@@ -1,312 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTEXTCONTROL_P_H
-#define QTEXTCONTROL_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtGui/qtextdocument.h>
-#include <QtGui/qtextoption.h>
-#include <QtGui/qtextcursor.h>
-#include <QtGui/qtextformat.h>
-#include <QtGui/qtextedit.h>
-#include <QtGui/qmenu.h>
-#include <QtCore/qrect.h>
-#include <QtGui/qabstracttextdocumentlayout.h>
-#include <QtGui/qtextdocumentfragment.h>
-#include <QtGui/qclipboard.h>
-
-#ifdef QT3_SUPPORT
-#include <QtGui/qtextobject.h>
-#include <QtGui/qtextlayout.h>
-#endif
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QStyleSheet;
-class QTextDocument;
-class QMenu;
-class QTextControlPrivate;
-class QMimeData;
-class QAbstractScrollArea;
-class QEvent;
-class QTimerEvent;
-
-class Q_GUI_EXPORT QTextControl : public QObject
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QTextControl)
-#ifndef QT_NO_TEXTHTMLPARSER
- Q_PROPERTY(QString html READ toHtml WRITE setHtml NOTIFY textChanged USER true)
-#endif
- Q_PROPERTY(bool overwriteMode READ overwriteMode WRITE setOverwriteMode)
- Q_PROPERTY(bool acceptRichText READ acceptRichText WRITE setAcceptRichText)
- Q_PROPERTY(int cursorWidth READ cursorWidth WRITE setCursorWidth)
- Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
- Q_PROPERTY(bool openExternalLinks READ openExternalLinks WRITE setOpenExternalLinks)
- Q_PROPERTY(bool ignoreUnusedNavigationEvents READ ignoreUnusedNavigationEvents WRITE setIgnoreUnusedNavigationEvents)
-public:
- explicit QTextControl(QObject *parent = 0);
- explicit QTextControl(const QString &text, QObject *parent = 0);
- explicit QTextControl(QTextDocument *doc, QObject *parent = 0);
- virtual ~QTextControl();
-
- void setDocument(QTextDocument *document);
- QTextDocument *document() const;
-
- void setTextCursor(const QTextCursor &cursor);
- QTextCursor textCursor() const;
-
- void setTextInteractionFlags(Qt::TextInteractionFlags flags);
- Qt::TextInteractionFlags textInteractionFlags() const;
-
- void mergeCurrentCharFormat(const QTextCharFormat &modifier);
-
- void setCurrentCharFormat(const QTextCharFormat &format);
- QTextCharFormat currentCharFormat() const;
-
- bool find(const QString &exp, QTextDocument::FindFlags options = 0);
-
- inline QString toPlainText() const
- { return document()->toPlainText(); }
-#ifndef QT_NO_TEXTHTMLPARSER
- inline QString toHtml() const
- { return document()->toHtml(); }
-#endif
-
- virtual void ensureCursorVisible();
-
- virtual QVariant loadResource(int type, const QUrl &name);
-#ifndef QT_NO_CONTEXTMENU
- QMenu *createStandardContextMenu(const QPointF &pos, QWidget *parent);
-#endif
-
- QTextCursor cursorForPosition(const QPointF &pos) const;
- QRectF cursorRect(const QTextCursor &cursor) const;
- QRectF cursorRect() const;
- QRectF selectionRect(const QTextCursor &cursor) const;
- QRectF selectionRect() const;
-
- QString anchorAt(const QPointF &pos) const;
- QPointF anchorPosition(const QString &name) const;
-
- QString anchorAtCursor() const;
-
- bool overwriteMode() const;
- void setOverwriteMode(bool overwrite);
-
- int cursorWidth() const;
- void setCursorWidth(int width);
-
- bool acceptRichText() const;
- void setAcceptRichText(bool accept);
-
-#ifndef QT_NO_TEXTEDIT
- void setExtraSelections(const QList<QTextEdit::ExtraSelection> &selections);
- QList<QTextEdit::ExtraSelection> extraSelections() const;
-#endif
-
- void setTextWidth(qreal width);
- qreal textWidth() const;
- QSizeF size() const;
-
- void setOpenExternalLinks(bool open);
- bool openExternalLinks() const;
-
- void setIgnoreUnusedNavigationEvents(bool ignore);
- bool ignoreUnusedNavigationEvents() const;
-
- void moveCursor(QTextCursor::MoveOperation op, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor);
-
- bool canPaste() const;
-
- void setCursorIsFocusIndicator(bool b);
- bool cursorIsFocusIndicator() const;
-
- void setDragEnabled(bool enabled);
- bool isDragEnabled() const;
-
- bool isWordSelectionEnabled() const;
- void setWordSelectionEnabled(bool enabled);
-
-#ifndef QT_NO_PRINTER
- void print(QPrinter *printer) const;
-#endif
-
- virtual int hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const;
- virtual QRectF blockBoundingRect(const QTextBlock &block) const;
- QAbstractTextDocumentLayout::PaintContext getPaintContext(QWidget *widget) const;
-
-public Q_SLOTS:
- void setPlainText(const QString &text);
- void setHtml(const QString &text);
-
-#ifndef QT_NO_CLIPBOARD
- void cut();
- void copy();
- void paste(QClipboard::Mode mode = QClipboard::Clipboard);
-#endif
-
- void undo();
- void redo();
-
- void clear();
- void selectAll();
-
- void insertPlainText(const QString &text);
-#ifndef QT_NO_TEXTHTMLPARSER
- void insertHtml(const QString &text);
-#endif
-
- void append(const QString &text);
- void appendHtml(const QString &html);
- void appendPlainText(const QString &text);
-
- void adjustSize();
-
-Q_SIGNALS:
- void textChanged();
- void undoAvailable(bool b);
- void redoAvailable(bool b);
- void currentCharFormatChanged(const QTextCharFormat &format);
- void copyAvailable(bool b);
- void selectionChanged();
- void cursorPositionChanged();
-
- // control signals
- void updateRequest(const QRectF &rect = QRectF());
- void documentSizeChanged(const QSizeF &);
- void blockCountChanged(int newBlockCount);
- void visibilityRequest(const QRectF &rect);
- void microFocusChanged();
- void linkActivated(const QString &link);
- void linkHovered(const QString &);
- void modificationChanged(bool m);
-
-public:
- // control properties
- QPalette palette() const;
- void setPalette(const QPalette &pal);
-
- virtual void processEvent(QEvent *e, const QMatrix &matrix, QWidget *contextWidget = 0);
- void processEvent(QEvent *e, const QPointF &coordinateOffset = QPointF(), QWidget *contextWidget = 0);
-
- // control methods
- void drawContents(QPainter *painter, const QRectF &rect = QRectF(), QWidget *widget = 0);
-
- void setFocus(bool focus, Qt::FocusReason = Qt::OtherFocusReason);
-
- virtual QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
-
- virtual QMimeData *createMimeDataFromSelection() const;
- virtual bool canInsertFromMimeData(const QMimeData *source) const;
- virtual void insertFromMimeData(const QMimeData *source);
-
- bool setFocusToAnchor(const QTextCursor &newCursor);
- bool setFocusToNextOrPreviousAnchor(bool next);
- bool findNextPrevAnchor(const QTextCursor& from, bool next, QTextCursor& newAnchor);
-
-protected:
- virtual void timerEvent(QTimerEvent *e);
-
- virtual bool event(QEvent *e);
-
-private:
- Q_DISABLE_COPY(QTextControl)
- Q_PRIVATE_SLOT(d_func(), void _q_updateCurrentCharFormatAndSelection())
- Q_PRIVATE_SLOT(d_func(), void _q_emitCursorPosChanged(const QTextCursor &))
- Q_PRIVATE_SLOT(d_func(), void _q_deleteSelected())
- Q_PRIVATE_SLOT(d_func(), void _q_copyLink())
- Q_PRIVATE_SLOT(d_func(), void _q_updateBlock(const QTextBlock &))
- Q_PRIVATE_SLOT(d_func(), void _q_documentLayoutChanged())
-};
-
-
-#ifndef QT_NO_CONTEXTMENU
-class QUnicodeControlCharacterMenu : public QMenu
-{
- Q_OBJECT
-public:
- QUnicodeControlCharacterMenu(QObject *editWidget, QWidget *parent);
-
-private Q_SLOTS:
- void menuActionTriggered();
-
-private:
- QObject *editWidget;
-};
-#endif // QT_NO_CONTEXTMENU
-
-
-// also used by QLabel
-class QTextEditMimeData : public QMimeData
-{
-public:
- inline QTextEditMimeData(const QTextDocumentFragment &aFragment) : fragment(aFragment) {}
-
- virtual QStringList formats() const;
-protected:
- virtual QVariant retrieveData(const QString &mimeType, QVariant::Type type) const;
-private:
- void setup() const;
-
- mutable QTextDocumentFragment fragment;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QTEXTCONTROL_H
diff --git a/src/gui/text/qtextcontrol_p_p.h b/src/gui/text/qtextcontrol_p_p.h
deleted file mode 100644
index 94670e225e..0000000000
--- a/src/gui/text/qtextcontrol_p_p.h
+++ /dev/null
@@ -1,238 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTEXTCONTROL_P_P_H
-#define QTEXTCONTROL_P_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "QtGui/qtextdocumentfragment.h"
-#include "QtGui/qscrollbar.h"
-#include "QtGui/qtextcursor.h"
-#include "QtGui/qtextformat.h"
-#include "QtGui/qmenu.h"
-#include "QtGui/qabstracttextdocumentlayout.h"
-#include "QtCore/qbasictimer.h"
-#include "QtCore/qpointer.h"
-#include "private/qobject_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QMimeData;
-class QAbstractScrollArea;
-class QInputContext;
-
-class QTextControlPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QTextControl)
-public:
- QTextControlPrivate();
-
- bool cursorMoveKeyEvent(QKeyEvent *e);
-
- void updateCurrentCharFormat();
-
- void indent();
- void outdent();
-
- void gotoNextTableCell();
- void gotoPreviousTableCell();
-
- void createAutoBulletList();
-
- void init(Qt::TextFormat format = Qt::RichText, const QString &text = QString(),
- QTextDocument *document = 0);
- void setContent(Qt::TextFormat format = Qt::RichText, const QString &text = QString(),
- QTextDocument *document = 0);
- void startDrag();
-
- void paste(const QMimeData *source);
-
- void setCursorPosition(const QPointF &pos);
- void setCursorPosition(int pos, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor);
-
- void repaintCursor();
- inline void repaintSelection()
- { repaintOldAndNewSelection(QTextCursor()); }
- void repaintOldAndNewSelection(const QTextCursor &oldSelection);
-
- void selectionChanged(bool forceEmitSelectionChanged = false);
-
- void _q_updateCurrentCharFormatAndSelection();
-
-#ifndef QT_NO_CLIPBOARD
- void setClipboardSelection();
-#endif
-
- void _q_emitCursorPosChanged(const QTextCursor &someCursor);
-
- void setBlinkingCursorEnabled(bool enable);
-
- void extendWordwiseSelection(int suggestedNewPosition, qreal mouseXPosition);
- void extendBlockwiseSelection(int suggestedNewPosition);
-
- void _q_deleteSelected();
-
- void _q_setCursorAfterUndoRedo(int undoPosition, int charsAdded, int charsRemoved);
-
- QRectF cursorRectPlusUnicodeDirectionMarkers(const QTextCursor &cursor) const;
- QRectF rectForPosition(int position) const;
- QRectF selectionRect(const QTextCursor &cursor) const;
- inline QRectF selectionRect() const
- { return selectionRect(this->cursor); }
-
- QString anchorForCursor(const QTextCursor &anchor) const;
-
- void keyPressEvent(QKeyEvent *e);
- void mousePressEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos,
- Qt::KeyboardModifiers modifiers,
- Qt::MouseButtons buttons,
- const QPoint &globalPos);
- void mouseMoveEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos,
- Qt::KeyboardModifiers modifiers,
- Qt::MouseButtons buttons,
- const QPoint &globalPos);
- void mouseReleaseEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos,
- Qt::KeyboardModifiers modifiers,
- Qt::MouseButtons buttons,
- const QPoint &globalPos);
- void mouseDoubleClickEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos,
- Qt::KeyboardModifiers modifiers,
- Qt::MouseButtons buttons,
- const QPoint &globalPos);
- bool sendMouseEventToInputContext(QEvent *e, QEvent::Type eventType, Qt::MouseButton button,
- const QPointF &pos,
- Qt::KeyboardModifiers modifiers,
- Qt::MouseButtons buttons,
- const QPoint &globalPos);
- void contextMenuEvent(const QPoint &screenPos, const QPointF &docPos, QWidget *contextWidget);
- void focusEvent(QFocusEvent *e);
-#ifdef QT_KEYPAD_NAVIGATION
- void editFocusEvent(QEvent *e);
-#endif
- bool dragEnterEvent(QEvent *e, const QMimeData *mimeData);
- void dragLeaveEvent();
- bool dragMoveEvent(QEvent *e, const QMimeData *mimeData, const QPointF &pos);
- bool dropEvent(const QMimeData *mimeData, const QPointF &pos, Qt::DropAction dropAction, QWidget *source);
-
- void inputMethodEvent(QInputMethodEvent *);
-
- void activateLinkUnderCursor(QString href = QString());
-
-#ifndef QT_NO_TOOLTIP
- void showToolTip(const QPoint &globalPos, const QPointF &pos, QWidget *contextWidget);
-#endif
-
- void append(const QString &text, Qt::TextFormat format = Qt::AutoText);
-
- QInputContext *inputContext();
-
- QTextDocument *doc;
- bool cursorOn;
- QTextCursor cursor;
- bool cursorIsFocusIndicator;
- QTextCharFormat lastCharFormat;
-
- QTextCursor dndFeedbackCursor;
-
- Qt::TextInteractionFlags interactionFlags;
-
- QBasicTimer cursorBlinkTimer;
- QBasicTimer trippleClickTimer;
- QPointF trippleClickPoint;
-
- bool dragEnabled;
-
- bool mousePressed;
-
- bool mightStartDrag;
- QPoint dragStartPos;
- QPointer<QWidget> contextWidget;
-
- bool lastSelectionState;
-
- bool ignoreAutomaticScrollbarAdjustement;
-
- QTextCursor selectedWordOnDoubleClick;
- QTextCursor selectedBlockOnTrippleClick;
-
- bool overwriteMode;
- bool acceptRichText;
-
- int preeditCursor;
- bool hideCursor; // used to hide the cursor in the preedit area
-
- QVector<QAbstractTextDocumentLayout::Selection> extraSelections;
-
- QPalette palette;
- bool hasFocus;
-#ifdef QT_KEYPAD_NAVIGATION
- bool hasEditFocus;
-#endif
- bool isEnabled;
-
- QString highlightedAnchor; // Anchor below cursor
- QString anchorOnMousePress;
- bool hadSelectionOnMousePress;
-
- bool ignoreUnusedNavigationEvents;
- bool openExternalLinks;
-
- bool wordSelectionEnabled;
-
- QString linkToCopy;
- void _q_copyLink();
- void _q_updateBlock(const QTextBlock &);
- void _q_documentLayoutChanged();
-};
-
-QT_END_NAMESPACE
-
-#endif // QTEXTCONTROL_P_H
diff --git a/src/gui/text/qtextcursor_p.h b/src/gui/text/qtextcursor_p.h
index 566495e1a3..9d9d79ff5d 100644
--- a/src/gui/text/qtextcursor_p.h
+++ b/src/gui/text/qtextcursor_p.h
@@ -61,7 +61,7 @@
QT_BEGIN_NAMESPACE
-class QTextCursorPrivate : public QSharedData
+class Q_GUI_EXPORT QTextCursorPrivate : public QSharedData
{
public:
QTextCursorPrivate(QTextDocumentPrivate *p);
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index 9169955617..83b875c149 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -54,14 +54,10 @@
#include "qtexthtmlparser_p.h"
#include "qpainter.h"
#include "qprinter.h"
-#include "qtextedit.h"
#include <qfile.h>
#include <qfileinfo.h>
#include <qdir.h>
-#include <qapplication.h>
-#include "qtextcontrol_p.h"
#include "qfont_p.h"
-#include "private/qtextedit_p.h"
#include "private/qdataurl_p.h"
#include "qtextdocument_p.h"
@@ -1971,6 +1967,8 @@ QVariant QTextDocument::loadResource(int type, const QUrl &name)
if (doc) {
r = doc->loadResource(type, name);
}
+#if 0
+ // ### Qt5: reenable
#ifndef QT_NO_TEXTEDIT
else if (QTextEdit *edit = qobject_cast<QTextEdit *>(parent())) {
QUrl resolvedName = edit->d_func()->resolveUrl(name);
@@ -1982,6 +1980,7 @@ QVariant QTextDocument::loadResource(int type, const QUrl &name)
r = control->loadResource(type, name);
}
#endif
+#endif
// handle data: URLs
if (r.isNull() && name.scheme().compare(QLatin1String("data"), Qt::CaseInsensitive) == 0)
diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp
index f3dc975259..e6d5070340 100644
--- a/src/gui/text/qtextdocumentlayout.cpp
+++ b/src/gui/text/qtextdocumentlayout.cpp
@@ -46,6 +46,7 @@
#include "qtextlist.h"
#include "qtextengine_p.h"
#include "private/qcssutil_p.h"
+#include "private/qguiapplication_p.h"
#include "qabstracttextdocumentlayout_p.h"
#include "qcssparser_p.h"
@@ -57,7 +58,6 @@
#include <qdebug.h>
#include <qvarlengtharray.h>
#include <limits.h>
-#include <qstyle.h>
#include <qbasictimer.h>
#include "private/qfunctions_p.h"
@@ -2572,7 +2572,7 @@ void QTextDocumentLayoutPrivate::layoutBlock(const QTextBlock &bl, int blockPosi
Qt::Alignment align = docPrivate->defaultTextOption.alignment();
if (blockFormat.hasProperty(QTextFormat::BlockAlignment))
align = blockFormat.alignment();
- option.setAlignment(QStyle::visualAlignment(dir, align)); // for paragraph that are RTL, alignment is auto-reversed;
+ option.setAlignment(QGuiApplicationPrivate::visualAlignment(dir, align)); // for paragraph that are RTL, alignment is auto-reversed;
if (blockFormat.nonBreakableLines() || document->pageSize().width() < 0) {
option.setWrapMode(QTextOption::ManualWrap);
diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp
index ff27bc673f..b0713bb0e4 100644
--- a/src/gui/text/qtextengine.cpp
+++ b/src/gui/text/qtextengine.cpp
@@ -53,7 +53,7 @@
#include "qstring.h"
#include <private/qunicodetables_p.h>
#include "qtextdocument_p.h"
-#include <qapplication.h>
+#include <qguiapplication.h>
#include <stdlib.h>
@@ -1606,7 +1606,7 @@ bool QTextEngine::isRightToLeft() const
itemize();
// this places the cursor in the right position depending on the keyboard layout
if (layoutData->string.isEmpty())
- return QApplication::keyboardInputDirection() == Qt::RightToLeft;
+ return QGuiApplication::keyboardInputDirection() == Qt::RightToLeft;
return layoutData->string.isRightToLeft();
}
diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h
index c476485c1d..bea39e55c5 100644
--- a/src/gui/text/qtextengine_p.h
+++ b/src/gui/text/qtextengine_p.h
@@ -644,7 +644,7 @@ private:
int beginningOfLine(int lineNum);
};
-class QStackTextEngine : public QTextEngine {
+class Q_GUI_EXPORT QStackTextEngine : public QTextEngine {
public:
enum { MemSize = 256*40/sizeof(void *) };
QStackTextEngine(const QString &string, const QFont &f);
diff --git a/src/gui/text/qtexthtmlparser.cpp b/src/gui/text/qtexthtmlparser.cpp
index 3513a280c6..0eb0673c69 100644
--- a/src/gui/text/qtexthtmlparser.cpp
+++ b/src/gui/text/qtexthtmlparser.cpp
@@ -43,7 +43,6 @@
#include <qbytearray.h>
#include <qtextcodec.h>
-#include <qapplication.h>
#include <qstack.h>
#include <qdebug.h>
#include <qthread.h>
@@ -1055,7 +1054,7 @@ void QTextHtmlParserNode::initializeProperties(const QTextHtmlParserNode *parent
&& !attributes.at(i + 1).isEmpty()) {
hasHref = true;
charFormat.setUnderlineStyle(QTextCharFormat::SingleUnderline);
- charFormat.setForeground(QApplication::palette().link());
+ charFormat.setForeground(Qt::blue); // ### Qt5: QApplication::palette().link());
}
}
@@ -1406,7 +1405,7 @@ void QTextHtmlParserNode::applyBackgroundImage(const QString &url, const QTextDo
if (!url.isEmpty() && resourceProvider) {
QVariant val = resourceProvider->resource(QTextDocument::ImageResource, url);
- if (qApp->thread() != QThread::currentThread()) {
+ if (QCoreApplication::instance()->thread() != QThread::currentThread()) {
// must use images in non-GUI threads
if (val.type() == QVariant::Image) {
QImage image = qvariant_cast<QImage>(val);
diff --git a/src/gui/text/qtextimagehandler.cpp b/src/gui/text/qtextimagehandler.cpp
index bbff79cbc6..d04b758bc9 100644
--- a/src/gui/text/qtextimagehandler.cpp
+++ b/src/gui/text/qtextimagehandler.cpp
@@ -42,13 +42,12 @@
#include "qtextimagehandler_p.h"
-#include <qapplication.h>
+#include <qcoreapplication.h>
#include <qtextformat.h>
#include <qpainter.h>
#include <qdebug.h>
#include <private/qtextengine_p.h>
#include <qpalette.h>
-#include <qtextbrowser.h>
#include <qthread.h>
QT_BEGIN_NAMESPACE
@@ -73,7 +72,8 @@ static QPixmap getPixmap(QTextDocument *doc, const QTextImageFormat &format)
if (pm.isNull()) {
QString context;
-#ifndef QT_NO_TEXTBROWSER
+#if 0
+ // ### Qt5
QTextBrowser *browser = qobject_cast<QTextBrowser *>(doc->parent());
if (browser)
context = browser->source().toString();
@@ -150,7 +150,9 @@ static QImage getImage(QTextDocument *doc, const QTextImageFormat &format)
if (image.isNull()) {
QString context;
-#ifndef QT_NO_TEXTBROWSER
+
+#if 0
+ // ### Qt5
QTextBrowser *browser = qobject_cast<QTextBrowser *>(doc->parent());
if (browser)
context = browser->source().toString();
@@ -210,7 +212,7 @@ QSizeF QTextImageHandler::intrinsicSize(QTextDocument *doc, int posInDocument, c
Q_UNUSED(posInDocument)
const QTextImageFormat imageFormat = format.toImageFormat();
- if (qApp->thread() != QThread::currentThread())
+ if (QCoreApplication::instance()->thread() != QThread::currentThread())
return getImageSize(doc, imageFormat);
return getPixmapSize(doc, imageFormat);
}
@@ -220,7 +222,7 @@ void QTextImageHandler::drawObject(QPainter *p, const QRectF &rect, QTextDocumen
Q_UNUSED(posInDocument)
const QTextImageFormat imageFormat = format.toImageFormat();
- if (qApp->thread() != QThread::currentThread()) {
+ if (QCoreApplication::instance()->thread() != QThread::currentThread()) {
const QImage image = getImage(doc, imageFormat);
p->drawImage(rect, image, image.rect());
} else {
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 1280b4650b..271af7ae82 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -43,14 +43,12 @@
#include "qtextengine_p.h"
#include <qfont.h>
-#include <qapplication.h>
#include <qpainter.h>
#include <qvarlengtharray.h>
#include <qtextformat.h>
#include <qabstracttextdocumentlayout.h>
#include "qtextdocument_p.h"
#include "qtextformat_p.h"
-#include "qstyleoption.h"
#include "qpainterpath.h"
#include "qglyphrun.h"
#include "qglyphrun_p.h"
diff --git a/src/gui/text/qtextoption.cpp b/src/gui/text/qtextoption.cpp
index 2b8e735305..b3358fa7b0 100644
--- a/src/gui/text/qtextoption.cpp
+++ b/src/gui/text/qtextoption.cpp
@@ -40,7 +40,7 @@
****************************************************************************/
#include "qtextoption.h"
-#include "qapplication.h"
+#include "qguiapplication.h"
#include "qlist.h"
QT_BEGIN_NAMESPACE
@@ -82,7 +82,7 @@ QTextOption::QTextOption(Qt::Alignment alignment)
tab(-1),
d(0)
{
- direction = QApplication::layoutDirection();
+ direction = QGuiApplication::layoutDirection();
}
/*!
diff --git a/src/gui/text/text.pri b/src/gui/text/text.pri
index b6cdc52e10..6357dec1d2 100644
--- a/src/gui/text/text.pri
+++ b/src/gui/text/text.pri
@@ -9,9 +9,7 @@ HEADERS += \
text/qfontmetrics.h \
text/qfont_p.h \
text/qfontsubset_p.h \
- text/qtextcontrol_p.h \
- text/qtextcontrol_p_p.h \
- text/qtextengine_p.h \
+ text/qtextengine_p.h \
text/qtextlayout.h \
text/qtextformat.h \
text/qtextformat_p.h \
@@ -51,8 +49,7 @@ SOURCES += \
text/qfontsubset.cpp \
text/qfontmetrics.cpp \
text/qfontdatabase.cpp \
- text/qtextcontrol.cpp \
- text/qtextengine.cpp \
+ text/qtextengine.cpp \
text/qtextlayout.cpp \
text/qtextformat.cpp \
text/qtextobject.cpp \
@@ -103,7 +100,7 @@ unix:x11 {
text/qrawfont_ft.cpp
}
-!embedded:!qpa:!x11:mac {
+!qpa:!x11:mac {
HEADERS += \
text/qfontengine_mac_p.h
OBJECTIVE_HEADERS += \
@@ -119,22 +116,6 @@ unix:x11 {
}
}
-embedded {
- SOURCES += \
- text/qfont_qws.cpp \
- text/qfontengine_qws.cpp \
- text/qfontengine_ft.cpp \
- text/qfontengine_qpf.cpp \
- text/qabstractfontengine_qws.cpp \
- text/qrawfont_ft.cpp
- HEADERS += \
- text/qfontengine_ft_p.h \
- text/qfontengine_qpf_p.h \
- text/qabstractfontengine_qws.h \
- text/qabstractfontengine_p.h
- DEFINES += QT_NO_FONTCONFIG
-}
-
qpa {
SOURCES += \
text/qfont_qpa.cpp \
@@ -232,9 +213,7 @@ contains(QT_CONFIG, freetype) {
DEFINES += FT2_BUILD_LIBRARY FT_CONFIG_OPTION_SYSTEM_ZLIB
- embedded:CONFIG += opentype
} else:contains(QT_CONFIG, system-freetype) {
- embedded:CONFIG += opentype
# pull in the proper freetype2 include directory
include($$QT_SOURCE_TREE/config.tests/unix/freetype/freetype.pri)
LIBS_PRIVATE += -lfreetype
diff --git a/src/gui/util/qcompleter.cpp b/src/gui/util/qcompleter.cpp
deleted file mode 100644
index 0cb3bbdf8c..0000000000
--- a/src/gui/util/qcompleter.cpp
+++ /dev/null
@@ -1,1833 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \class QCompleter
- \brief The QCompleter class provides completions based on an item model.
- \since 4.2
-
- You can use QCompleter to provide auto completions in any Qt
- widget, such as QLineEdit and QComboBox.
- When the user starts typing a word, QCompleter suggests possible ways of
- completing the word, based on a word list. The word list is
- provided as a QAbstractItemModel. (For simple applications, where
- the word list is static, you can pass a QStringList to
- QCompleter's constructor.)
-
- \tableofcontents
-
- \section1 Basic Usage
-
- A QCompleter is used typically with a QLineEdit or QComboBox.
- For example, here's how to provide auto completions from a simple
- word list in a QLineEdit:
-
- \snippet doc/src/snippets/code/src_gui_util_qcompleter.cpp 0
-
- A QFileSystemModel can be used to provide auto completion of file names.
- For example:
-
- \snippet doc/src/snippets/code/src_gui_util_qcompleter.cpp 1
-
- To set the model on which QCompleter should operate, call
- setModel(). By default, QCompleter will attempt to match the \l
- {completionPrefix}{completion prefix} (i.e., the word that the
- user has started typing) against the Qt::EditRole data stored in
- column 0 in the model case sensitively. This can be changed
- using setCompletionRole(), setCompletionColumn(), and
- setCaseSensitivity().
-
- If the model is sorted on the column and role that are used for completion,
- you can call setModelSorting() with either
- QCompleter::CaseSensitivelySortedModel or
- QCompleter::CaseInsensitivelySortedModel as the argument. On large models,
- this can lead to significant performance improvements, because QCompleter
- can then use binary search instead of linear search.
-
- The model can be a \l{QAbstractListModel}{list model},
- a \l{QAbstractTableModel}{table model}, or a
- \l{QAbstractItemModel}{tree model}. Completion on tree models
- is slightly more involved and is covered in the \l{Handling
- Tree Models} section below.
-
- The completionMode() determines the mode used to provide completions to
- the user.
-
- \section1 Iterating Through Completions
-
- To retrieve a single candidate string, call setCompletionPrefix()
- with the text that needs to be completed and call
- currentCompletion(). You can iterate through the list of
- completions as below:
-
- \snippet doc/src/snippets/code/src_gui_util_qcompleter.cpp 2
-
- completionCount() returns the total number of completions for the
- current prefix. completionCount() should be avoided when possible,
- since it requires a scan of the entire model.
-
- \section1 The Completion Model
-
- completionModel() return a list model that contains all possible
- completions for the current completion prefix, in the order in which
- they appear in the model. This model can be used to display the current
- completions in a custom view. Calling setCompletionPrefix() automatically
- refreshes the completion model.
-
- \section1 Handling Tree Models
-
- QCompleter can look for completions in tree models, assuming
- that any item (or sub-item or sub-sub-item) can be unambiguously
- represented as a string by specifying the path to the item. The
- completion is then performed one level at a time.
-
- Let's take the example of a user typing in a file system path.
- The model is a (hierarchical) QFileSystemModel. The completion
- occurs for every element in the path. For example, if the current
- text is \c C:\Wind, QCompleter might suggest \c Windows to
- complete the current path element. Similarly, if the current text
- is \c C:\Windows\Sy, QCompleter might suggest \c System.
-
- For this kind of completion to work, QCompleter needs to be able to
- split the path into a list of strings that are matched at each level.
- For \c C:\Windows\Sy, it needs to be split as "C:", "Windows" and "Sy".
- The default implementation of splitPath(), splits the completionPrefix
- using QDir::separator() if the model is a QFileSystemModel.
-
- To provide completions, QCompleter needs to know the path from an index.
- This is provided by pathFromIndex(). The default implementation of
- pathFromIndex(), returns the data for the \l{Qt::EditRole}{edit role}
- for list models and the absolute file path if the mode is a QFileSystemModel.
-
- \sa QAbstractItemModel, QLineEdit, QComboBox, {Completer Example}
-*/
-
-#include "qcompleter_p.h"
-
-#ifndef QT_NO_COMPLETER
-
-#include "QtGui/qscrollbar.h"
-#include "QtGui/qstringlistmodel.h"
-#include "QtGui/qdirmodel.h"
-#include "QtGui/qfilesystemmodel.h"
-#include "QtGui/qheaderview.h"
-#include "QtGui/qlistview.h"
-#include "QtGui/qapplication.h"
-#include "QtGui/qevent.h"
-#include "QtGui/qheaderview.h"
-#include "QtGui/qdesktopwidget.h"
-#include "QtGui/qlineedit.h"
-
-QT_BEGIN_NAMESPACE
-
-QCompletionModel::QCompletionModel(QCompleterPrivate *c, QObject *parent)
- : QAbstractProxyModel(*new QCompletionModelPrivate, parent),
- c(c), showAll(false)
-{
- createEngine();
-}
-
-int QCompletionModel::columnCount(const QModelIndex &) const
-{
- Q_D(const QCompletionModel);
- return d->model->columnCount();
-}
-
-void QCompletionModel::setSourceModel(QAbstractItemModel *source)
-{
- bool hadModel = (sourceModel() != 0);
-
- if (hadModel)
- QObject::disconnect(sourceModel(), 0, this, 0);
-
- QAbstractProxyModel::setSourceModel(source);
-
- if (source) {
- // TODO: Optimize updates in the source model
- connect(source, SIGNAL(modelReset()), this, SLOT(invalidate()));
- connect(source, SIGNAL(destroyed()), this, SLOT(modelDestroyed()));
- connect(source, SIGNAL(layoutChanged()), this, SLOT(invalidate()));
- connect(source, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(rowsInserted()));
- connect(source, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(invalidate()));
- connect(source, SIGNAL(columnsInserted(QModelIndex,int,int)), this, SLOT(invalidate()));
- connect(source, SIGNAL(columnsRemoved(QModelIndex,int,int)), this, SLOT(invalidate()));
- connect(source, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(invalidate()));
- }
-
- invalidate();
-}
-
-void QCompletionModel::createEngine()
-{
- bool sortedEngine = false;
- switch (c->sorting) {
- case QCompleter::UnsortedModel:
- sortedEngine = false;
- break;
- case QCompleter::CaseSensitivelySortedModel:
- sortedEngine = c->cs == Qt::CaseSensitive;
- break;
- case QCompleter::CaseInsensitivelySortedModel:
- sortedEngine = c->cs == Qt::CaseInsensitive;
- break;
- }
-
- if (sortedEngine)
- engine.reset(new QSortedModelEngine(c));
- else
- engine.reset(new QUnsortedModelEngine(c));
-}
-
-QModelIndex QCompletionModel::mapToSource(const QModelIndex& index) const
-{
- Q_D(const QCompletionModel);
- if (!index.isValid())
- return engine->curParent;
-
- int row;
- QModelIndex parent = engine->curParent;
- if (!showAll) {
- if (!engine->matchCount())
- return QModelIndex();
- Q_ASSERT(index.row() < engine->matchCount());
- QIndexMapper& rootIndices = engine->historyMatch.indices;
- if (index.row() < rootIndices.count()) {
- row = rootIndices[index.row()];
- parent = QModelIndex();
- } else {
- row = engine->curMatch.indices[index.row() - rootIndices.count()];
- }
- } else {
- row = index.row();
- }
-
- return d->model->index(row, index.column(), parent);
-}
-
-QModelIndex QCompletionModel::mapFromSource(const QModelIndex& idx) const
-{
- if (!idx.isValid())
- return QModelIndex();
-
- int row = -1;
- if (!showAll) {
- if (!engine->matchCount())
- return QModelIndex();
-
- QIndexMapper& rootIndices = engine->historyMatch.indices;
- if (idx.parent().isValid()) {
- if (idx.parent() != engine->curParent)
- return QModelIndex();
- } else {
- row = rootIndices.indexOf(idx.row());
- if (row == -1 && engine->curParent.isValid())
- return QModelIndex(); // source parent and our parent don't match
- }
-
- if (row == -1) {
- QIndexMapper& indices = engine->curMatch.indices;
- engine->filterOnDemand(idx.row() - indices.last());
- row = indices.indexOf(idx.row()) + rootIndices.count();
- }
-
- if (row == -1)
- return QModelIndex();
- } else {
- if (idx.parent() != engine->curParent)
- return QModelIndex();
- row = idx.row();
- }
-
- return createIndex(row, idx.column());
-}
-
-bool QCompletionModel::setCurrentRow(int row)
-{
- if (row < 0 || !engine->matchCount())
- return false;
-
- if (row >= engine->matchCount())
- engine->filterOnDemand(row + 1 - engine->matchCount());
-
- if (row >= engine->matchCount()) // invalid row
- return false;
-
- engine->curRow = row;
- return true;
-}
-
-QModelIndex QCompletionModel::currentIndex(bool sourceIndex) const
-{
- if (!engine->matchCount())
- return QModelIndex();
-
- int row = engine->curRow;
- if (showAll)
- row = engine->curMatch.indices[engine->curRow];
-
- QModelIndex idx = createIndex(row, c->column);
- if (!sourceIndex)
- return idx;
- return mapToSource(idx);
-}
-
-QModelIndex QCompletionModel::index(int row, int column, const QModelIndex& parent) const
-{
- Q_D(const QCompletionModel);
- if (row < 0 || column < 0 || column >= columnCount(parent) || parent.isValid())
- return QModelIndex();
-
- if (!showAll) {
- if (!engine->matchCount())
- return QModelIndex();
- if (row >= engine->historyMatch.indices.count()) {
- int want = row + 1 - engine->matchCount();
- if (want > 0)
- engine->filterOnDemand(want);
- if (row >= engine->matchCount())
- return QModelIndex();
- }
- } else {
- if (row >= d->model->rowCount(engine->curParent))
- return QModelIndex();
- }
-
- return createIndex(row, column);
-}
-
-int QCompletionModel::completionCount() const
-{
- if (!engine->matchCount())
- return 0;
-
- engine->filterOnDemand(INT_MAX);
- return engine->matchCount();
-}
-
-int QCompletionModel::rowCount(const QModelIndex &parent) const
-{
- Q_D(const QCompletionModel);
- if (parent.isValid())
- return 0;
-
- if (showAll) {
- // Show all items below current parent, even if we have no valid matches
- if (engine->curParts.count() != 1 && !engine->matchCount()
- && !engine->curParent.isValid())
- return 0;
- return d->model->rowCount(engine->curParent);
- }
-
- return completionCount();
-}
-
-void QCompletionModel::setFiltered(bool filtered)
-{
- if (showAll == !filtered)
- return;
- showAll = !filtered;
- resetModel();
-}
-
-bool QCompletionModel::hasChildren(const QModelIndex &parent) const
-{
- Q_D(const QCompletionModel);
- if (parent.isValid())
- return false;
-
- if (showAll)
- return d->model->hasChildren(mapToSource(parent));
-
- if (!engine->matchCount())
- return false;
-
- return true;
-}
-
-QVariant QCompletionModel::data(const QModelIndex& index, int role) const
-{
- Q_D(const QCompletionModel);
- return d->model->data(mapToSource(index), role);
-}
-
-void QCompletionModel::modelDestroyed()
-{
- QAbstractProxyModel::setSourceModel(0); // switch to static empty model
- invalidate();
-}
-
-void QCompletionModel::rowsInserted()
-{
- invalidate();
- emit rowsAdded();
-}
-
-void QCompletionModel::invalidate()
-{
- engine->cache.clear();
- filter(engine->curParts);
-}
-
-void QCompletionModel::filter(const QStringList& parts)
-{
- Q_D(QCompletionModel);
- engine->filter(parts);
- resetModel();
-
- if (d->model->canFetchMore(engine->curParent))
- d->model->fetchMore(engine->curParent);
-}
-
-void QCompletionModel::resetModel()
-{
- if (rowCount() == 0) {
- reset();
- return;
- }
-
- emit layoutAboutToBeChanged();
- QModelIndexList piList = persistentIndexList();
- QModelIndexList empty;
- for (int i = 0; i < piList.size(); i++)
- empty.append(QModelIndex());
- changePersistentIndexList(piList, empty);
- emit layoutChanged();
-}
-
-//////////////////////////////////////////////////////////////////////////////
-void QCompletionEngine::filter(const QStringList& parts)
-{
- const QAbstractItemModel *model = c->proxy->sourceModel();
- curParts = parts;
- if (curParts.isEmpty())
- curParts.append(QString());
-
- curRow = -1;
- curParent = QModelIndex();
- curMatch = QMatchData();
- historyMatch = filterHistory();
-
- if (!model)
- return;
-
- QModelIndex parent;
- for (int i = 0; i < curParts.count() - 1; i++) {
- QString part = curParts[i];
- int emi = filter(part, parent, -1).exactMatchIndex;
- if (emi == -1)
- return;
- parent = model->index(emi, c->column, parent);
- }
-
- // Note that we set the curParent to a valid parent, even if we have no matches
- // When filtering is disabled, we show all the items under this parent
- curParent = parent;
- if (curParts.last().isEmpty())
- curMatch = QMatchData(QIndexMapper(0, model->rowCount(curParent) - 1), -1, false);
- else
- curMatch = filter(curParts.last(), curParent, 1); // build at least one
- curRow = curMatch.isValid() ? 0 : -1;
-}
-
-QMatchData QCompletionEngine::filterHistory()
-{
- QAbstractItemModel *source = c->proxy->sourceModel();
- if (curParts.count() <= 1 || c->proxy->showAll || !source)
- return QMatchData();
- bool isDirModel = false;
- bool isFsModel = false;
-#ifndef QT_NO_DIRMODEL
- isDirModel = (qobject_cast<QDirModel *>(source) != 0);
-#endif
-#ifndef QT_NO_FILESYSTEMMODEL
- isFsModel = (qobject_cast<QFileSystemModel *>(source) != 0);
-#endif
- QVector<int> v;
- QIndexMapper im(v);
- QMatchData m(im, -1, true);
-
- for (int i = 0; i < source->rowCount(); i++) {
- QString str = source->index(i, c->column).data().toString();
- if (str.startsWith(c->prefix, c->cs)
-#if (!defined(Q_OS_WIN) || defined(Q_OS_WINCE)) && !defined(Q_OS_SYMBIAN)
- && ((!isFsModel && !isDirModel) || QDir::toNativeSeparators(str) != QDir::separator())
-#endif
- )
- m.indices.append(i);
- }
- return m;
-}
-
-// Returns a match hint from the cache by chopping the search string
-bool QCompletionEngine::matchHint(QString part, const QModelIndex& parent, QMatchData *hint)
-{
- if (c->cs == Qt::CaseInsensitive)
- part = part.toLower();
-
- const CacheItem& map = cache[parent];
-
- QString key = part;
- while (!key.isEmpty()) {
- key.chop(1);
- if (map.contains(key)) {
- *hint = map[key];
- return true;
- }
- }
-
- return false;
-}
-
-bool QCompletionEngine::lookupCache(QString part, const QModelIndex& parent, QMatchData *m)
-{
- if (c->cs == Qt::CaseInsensitive)
- part = part.toLower();
- const CacheItem& map = cache[parent];
- if (!map.contains(part))
- return false;
- *m = map[part];
- return true;
-}
-
-// When the cache size exceeds 1MB, it clears out about 1/2 of the cache.
-void QCompletionEngine::saveInCache(QString part, const QModelIndex& parent, const QMatchData& m)
-{
- QMatchData old = cache[parent].take(part);
- cost = cost + m.indices.cost() - old.indices.cost();
- if (cost * sizeof(int) > 1024 * 1024) {
- QMap<QModelIndex, CacheItem>::iterator it1 = cache.begin();
- while (it1 != cache.end()) {
- CacheItem& ci = it1.value();
- int sz = ci.count()/2;
- QMap<QString, QMatchData>::iterator it2 = ci.begin();
- int i = 0;
- while (it2 != ci.end() && i < sz) {
- cost -= it2.value().indices.cost();
- it2 = ci.erase(it2);
- i++;
- }
- if (ci.count() == 0) {
- it1 = cache.erase(it1);
- } else {
- ++it1;
- }
- }
- }
-
- if (c->cs == Qt::CaseInsensitive)
- part = part.toLower();
- cache[parent][part] = m;
-}
-
-///////////////////////////////////////////////////////////////////////////////////
-QIndexMapper QSortedModelEngine::indexHint(QString part, const QModelIndex& parent, Qt::SortOrder order)
-{
- const QAbstractItemModel *model = c->proxy->sourceModel();
-
- if (c->cs == Qt::CaseInsensitive)
- part = part.toLower();
-
- const CacheItem& map = cache[parent];
-
- // Try to find a lower and upper bound for the search from previous results
- int to = model->rowCount(parent) - 1;
- int from = 0;
- const CacheItem::const_iterator it = map.lowerBound(part);
-
- // look backward for first valid hint
- for(CacheItem::const_iterator it1 = it; it1-- != map.constBegin();) {
- const QMatchData& value = it1.value();
- if (value.isValid()) {
- if (order == Qt::AscendingOrder) {
- from = value.indices.last() + 1;
- } else {
- to = value.indices.first() - 1;
- }
- break;
- }
- }
-
- // look forward for first valid hint
- for(CacheItem::const_iterator it2 = it; it2 != map.constEnd(); ++it2) {
- const QMatchData& value = it2.value();
- if (value.isValid() && !it2.key().startsWith(part)) {
- if (order == Qt::AscendingOrder) {
- to = value.indices.first() - 1;
- } else {
- from = value.indices.first() + 1;
- }
- break;
- }
- }
-
- return QIndexMapper(from, to);
-}
-
-Qt::SortOrder QSortedModelEngine::sortOrder(const QModelIndex &parent) const
-{
- const QAbstractItemModel *model = c->proxy->sourceModel();
-
- int rowCount = model->rowCount(parent);
- if (rowCount < 2)
- return Qt::AscendingOrder;
- QString first = model->data(model->index(0, c->column, parent), c->role).toString();
- QString last = model->data(model->index(rowCount - 1, c->column, parent), c->role).toString();
- return QString::compare(first, last, c->cs) <= 0 ? Qt::AscendingOrder : Qt::DescendingOrder;
-}
-
-QMatchData QSortedModelEngine::filter(const QString& part, const QModelIndex& parent, int)
-{
- const QAbstractItemModel *model = c->proxy->sourceModel();
-
- QMatchData hint;
- if (lookupCache(part, parent, &hint))
- return hint;
-
- QIndexMapper indices;
- Qt::SortOrder order = sortOrder(parent);
-
- if (matchHint(part, parent, &hint)) {
- if (!hint.isValid())
- return QMatchData();
- indices = hint.indices;
- } else {
- indices = indexHint(part, parent, order);
- }
-
- // binary search the model within 'indices' for 'part' under 'parent'
- int high = indices.to() + 1;
- int low = indices.from() - 1;
- int probe;
- QModelIndex probeIndex;
- QString probeData;
-
- while (high - low > 1)
- {
- probe = (high + low) / 2;
- probeIndex = model->index(probe, c->column, parent);
- probeData = model->data(probeIndex, c->role).toString();
- const int cmp = QString::compare(probeData, part, c->cs);
- if ((order == Qt::AscendingOrder && cmp >= 0)
- || (order == Qt::DescendingOrder && cmp < 0)) {
- high = probe;
- } else {
- low = probe;
- }
- }
-
- if ((order == Qt::AscendingOrder && low == indices.to())
- || (order == Qt::DescendingOrder && high == indices.from())) { // not found
- saveInCache(part, parent, QMatchData());
- return QMatchData();
- }
-
- probeIndex = model->index(order == Qt::AscendingOrder ? low+1 : high-1, c->column, parent);
- probeData = model->data(probeIndex, c->role).toString();
- if (!probeData.startsWith(part, c->cs)) {
- saveInCache(part, parent, QMatchData());
- return QMatchData();
- }
-
- const bool exactMatch = QString::compare(probeData, part, c->cs) == 0;
- int emi = exactMatch ? (order == Qt::AscendingOrder ? low+1 : high-1) : -1;
-
- int from = 0;
- int to = 0;
- if (order == Qt::AscendingOrder) {
- from = low + 1;
- high = indices.to() + 1;
- low = from;
- } else {
- to = high - 1;
- low = indices.from() - 1;
- high = to;
- }
-
- while (high - low > 1)
- {
- probe = (high + low) / 2;
- probeIndex = model->index(probe, c->column, parent);
- probeData = model->data(probeIndex, c->role).toString();
- const bool startsWith = probeData.startsWith(part, c->cs);
- if ((order == Qt::AscendingOrder && startsWith)
- || (order == Qt::DescendingOrder && !startsWith)) {
- low = probe;
- } else {
- high = probe;
- }
- }
-
- QMatchData m(order == Qt::AscendingOrder ? QIndexMapper(from, high - 1) : QIndexMapper(low+1, to), emi, false);
- saveInCache(part, parent, m);
- return m;
-}
-
-////////////////////////////////////////////////////////////////////////////////////////
-int QUnsortedModelEngine::buildIndices(const QString& str, const QModelIndex& parent, int n,
- const QIndexMapper& indices, QMatchData* m)
-{
- Q_ASSERT(m->partial);
- Q_ASSERT(n != -1 || m->exactMatchIndex == -1);
- const QAbstractItemModel *model = c->proxy->sourceModel();
- int i, count = 0;
-
- for (i = 0; i < indices.count() && count != n; ++i) {
- QModelIndex idx = model->index(indices[i], c->column, parent);
- QString data = model->data(idx, c->role).toString();
- if (!data.startsWith(str, c->cs) || !(model->flags(idx) & Qt::ItemIsSelectable))
- continue;
- m->indices.append(indices[i]);
- ++count;
- if (m->exactMatchIndex == -1 && QString::compare(data, str, c->cs) == 0) {
- m->exactMatchIndex = indices[i];
- if (n == -1)
- return indices[i];
- }
- }
- return indices[i-1];
-}
-
-void QUnsortedModelEngine::filterOnDemand(int n)
-{
- Q_ASSERT(matchCount());
- if (!curMatch.partial)
- return;
- Q_ASSERT(n >= -1);
- const QAbstractItemModel *model = c->proxy->sourceModel();
- int lastRow = model->rowCount(curParent) - 1;
- QIndexMapper im(curMatch.indices.last() + 1, lastRow);
- int lastIndex = buildIndices(curParts.last(), curParent, n, im, &curMatch);
- curMatch.partial = (lastRow != lastIndex);
- saveInCache(curParts.last(), curParent, curMatch);
-}
-
-QMatchData QUnsortedModelEngine::filter(const QString& part, const QModelIndex& parent, int n)
-{
- QMatchData hint;
-
- QVector<int> v;
- QIndexMapper im(v);
- QMatchData m(im, -1, true);
-
- const QAbstractItemModel *model = c->proxy->sourceModel();
- bool foundInCache = lookupCache(part, parent, &m);
-
- if (!foundInCache) {
- if (matchHint(part, parent, &hint) && !hint.isValid())
- return QMatchData();
- }
-
- if (!foundInCache && !hint.isValid()) {
- const int lastRow = model->rowCount(parent) - 1;
- QIndexMapper all(0, lastRow);
- int lastIndex = buildIndices(part, parent, n, all, &m);
- m.partial = (lastIndex != lastRow);
- } else {
- if (!foundInCache) { // build from hint as much as we can
- buildIndices(part, parent, INT_MAX, hint.indices, &m);
- m.partial = hint.partial;
- }
- if (m.partial && ((n == -1 && m.exactMatchIndex == -1) || (m.indices.count() < n))) {
- // need more and have more
- const int lastRow = model->rowCount(parent) - 1;
- QIndexMapper rest(hint.indices.last() + 1, lastRow);
- int want = n == -1 ? -1 : n - m.indices.count();
- int lastIndex = buildIndices(part, parent, want, rest, &m);
- m.partial = (lastRow != lastIndex);
- }
- }
-
- saveInCache(part, parent, m);
- return m;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-QCompleterPrivate::QCompleterPrivate()
-: widget(0), proxy(0), popup(0), cs(Qt::CaseSensitive), role(Qt::EditRole), column(0),
- maxVisibleItems(7), sorting(QCompleter::UnsortedModel), wrap(true), eatFocusOut(true),
- hiddenBecauseNoMatch(false)
-{
-}
-
-void QCompleterPrivate::init(QAbstractItemModel *m)
-{
- Q_Q(QCompleter);
- proxy = new QCompletionModel(this, q);
- QObject::connect(proxy, SIGNAL(rowsAdded()), q, SLOT(_q_autoResizePopup()));
- q->setModel(m);
-#ifdef QT_NO_LISTVIEW
- q->setCompletionMode(QCompleter::InlineCompletion);
-#else
- q->setCompletionMode(QCompleter::PopupCompletion);
-#endif // QT_NO_LISTVIEW
-}
-
-void QCompleterPrivate::setCurrentIndex(QModelIndex index, bool select)
-{
- Q_Q(QCompleter);
- if (!q->popup())
- return;
- if (!select) {
- popup->selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
- } else {
- if (!index.isValid())
- popup->selectionModel()->clear();
- else
- popup->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Select
- | QItemSelectionModel::Rows);
- }
- index = popup->selectionModel()->currentIndex();
- if (!index.isValid())
- popup->scrollToTop();
- else
- popup->scrollTo(index, QAbstractItemView::PositionAtTop);
-}
-
-void QCompleterPrivate::_q_completionSelected(const QItemSelection& selection)
-{
- QModelIndex index;
- if (!selection.indexes().isEmpty())
- index = selection.indexes().first();
-
- _q_complete(index, true);
-}
-
-void QCompleterPrivate::_q_complete(QModelIndex index, bool highlighted)
-{
- Q_Q(QCompleter);
- QString completion;
-
- if (!index.isValid() || (!proxy->showAll && (index.row() >= proxy->engine->matchCount()))) {
- completion = prefix;
- } else {
- if (!(index.flags() & Qt::ItemIsEnabled))
- return;
- QModelIndex si = proxy->mapToSource(index);
- si = si.sibling(si.row(), column); // for clicked()
- completion = q->pathFromIndex(si);
-#ifndef QT_NO_DIRMODEL
- // add a trailing separator in inline
- if (mode == QCompleter::InlineCompletion) {
- if (qobject_cast<QDirModel *>(proxy->sourceModel()) && QFileInfo(completion).isDir())
- completion += QDir::separator();
- }
-#endif
-#ifndef QT_NO_FILESYSTEMMODEL
- // add a trailing separator in inline
- if (mode == QCompleter::InlineCompletion) {
- if (qobject_cast<QFileSystemModel *>(proxy->sourceModel()) && QFileInfo(completion).isDir())
- completion += QDir::separator();
- }
-#endif
- }
-
- if (highlighted) {
- emit q->highlighted(index);
- emit q->highlighted(completion);
- } else {
- emit q->activated(index);
- emit q->activated(completion);
- }
-}
-
-void QCompleterPrivate::_q_autoResizePopup()
-{
- if (!popup || !popup->isVisible())
- return;
- showPopup(popupRect);
-}
-
-void QCompleterPrivate::showPopup(const QRect& rect)
-{
- const QRect screen = QApplication::desktop()->availableGeometry(widget);
- Qt::LayoutDirection dir = widget->layoutDirection();
- QPoint pos;
- int rh, w;
- int h = (popup->sizeHintForRow(0) * qMin(maxVisibleItems, popup->model()->rowCount()) + 3) + 3;
- QScrollBar *hsb = popup->horizontalScrollBar();
- if (hsb && hsb->isVisible())
- h += popup->horizontalScrollBar()->sizeHint().height();
-
- if (rect.isValid()) {
- rh = rect.height();
- w = rect.width();
- pos = widget->mapToGlobal(dir == Qt::RightToLeft ? rect.bottomRight() : rect.bottomLeft());
- } else {
- rh = widget->height();
- pos = widget->mapToGlobal(QPoint(0, widget->height() - 2));
- w = widget->width();
- }
-
- if (w > screen.width())
- w = screen.width();
- if ((pos.x() + w) > (screen.x() + screen.width()))
- pos.setX(screen.x() + screen.width() - w);
- if (pos.x() < screen.x())
- pos.setX(screen.x());
-
- int top = pos.y() - rh - screen.top() + 2;
- int bottom = screen.bottom() - pos.y();
- h = qMax(h, popup->minimumHeight());
- if (h > bottom) {
- h = qMin(qMax(top, bottom), h);
-
- if (top > bottom)
- pos.setY(pos.y() - h - rh + 2);
- }
-
- popup->setGeometry(pos.x(), pos.y(), w, h);
-
- if (!popup->isVisible())
- popup->show();
-}
-
-void QCompleterPrivate::_q_fileSystemModelDirectoryLoaded(const QString &path)
-{
- Q_Q(QCompleter);
- // Slot called when QFileSystemModel has finished loading.
- // If we hide the popup because there was no match because the model was not loaded yet,
- // we re-start the completion when we get the results
- if (hiddenBecauseNoMatch
- && prefix.startsWith(path) && prefix != (path + QLatin1Char('/'))
- && widget) {
- q->complete();
- }
-}
-
-/*!
- Constructs a completer object with the given \a parent.
-*/
-QCompleter::QCompleter(QObject *parent)
-: QObject(*new QCompleterPrivate(), parent)
-{
- Q_D(QCompleter);
- d->init();
-}
-
-/*!
- Constructs a completer object with the given \a parent that provides completions
- from the specified \a model.
-*/
-QCompleter::QCompleter(QAbstractItemModel *model, QObject *parent)
- : QObject(*new QCompleterPrivate(), parent)
-{
- Q_D(QCompleter);
- d->init(model);
-}
-
-#ifndef QT_NO_STRINGLISTMODEL
-/*!
- Constructs a QCompleter object with the given \a parent that uses the specified
- \a list as a source of possible completions.
-*/
-QCompleter::QCompleter(const QStringList& list, QObject *parent)
-: QObject(*new QCompleterPrivate(), parent)
-{
- Q_D(QCompleter);
- d->init(new QStringListModel(list, this));
-}
-#endif // QT_NO_STRINGLISTMODEL
-
-/*!
- Destroys the completer object.
-*/
-QCompleter::~QCompleter()
-{
-}
-
-/*!
- Sets the widget for which completion are provided for to \a widget. This
- function is automatically called when a QCompleter is set on a QLineEdit
- using QLineEdit::setCompleter() or on a QComboBox using
- QComboBox::setCompleter(). The widget needs to be set explicitly when
- providing completions for custom widgets.
-
- \sa widget(), setModel(), setPopup()
- */
-void QCompleter::setWidget(QWidget *widget)
-{
- Q_D(QCompleter);
- if (d->widget)
- d->widget->removeEventFilter(this);
- d->widget = widget;
- if (d->widget)
- d->widget->installEventFilter(this);
- if (d->popup) {
- d->popup->hide();
- d->popup->setFocusProxy(d->widget);
- }
-}
-
-/*!
- Returns the widget for which the completer object is providing completions.
-
- \sa setWidget()
- */
-QWidget *QCompleter::widget() const
-{
- Q_D(const QCompleter);
- return d->widget;
-}
-
-/*!
- Sets the model which provides completions to \a model. The \a model can
- be list model or a tree model. If a model has been already previously set
- and it has the QCompleter as its parent, it is deleted.
-
- For convenience, if \a model is a QFileSystemModel, QCompleter switches its
- caseSensitivity to Qt::CaseInsensitive on Windows and Qt::CaseSensitive
- on other platforms.
-
- \sa completionModel(), modelSorting, {Handling Tree Models}
-*/
-void QCompleter::setModel(QAbstractItemModel *model)
-{
- Q_D(QCompleter);
- QAbstractItemModel *oldModel = d->proxy->sourceModel();
- d->proxy->setSourceModel(model);
- if (d->popup)
- setPopup(d->popup); // set the model and make new connections
- if (oldModel && oldModel->QObject::parent() == this)
- delete oldModel;
-#ifndef QT_NO_DIRMODEL
- if (qobject_cast<QDirModel *>(model)) {
-#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN)
- setCaseSensitivity(Qt::CaseInsensitive);
-#else
- setCaseSensitivity(Qt::CaseSensitive);
-#endif
- }
-#endif // QT_NO_DIRMODEL
-#ifndef QT_NO_FILESYSTEMMODEL
- QFileSystemModel *fsModel = qobject_cast<QFileSystemModel *>(model);
- if (fsModel) {
-#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN)
- setCaseSensitivity(Qt::CaseInsensitive);
-#else
- setCaseSensitivity(Qt::CaseSensitive);
-#endif
- setCompletionRole(QFileSystemModel::FileNameRole);
- connect(fsModel, SIGNAL(directoryLoaded(QString)), this, SLOT(_q_fileSystemModelDirectoryLoaded(QString)));
- }
-#endif // QT_NO_FILESYSTEMMODEL
-}
-
-/*!
- Returns the model that provides completion strings.
-
- \sa completionModel()
-*/
-QAbstractItemModel *QCompleter::model() const
-{
- Q_D(const QCompleter);
- return d->proxy->sourceModel();
-}
-
-/*!
- \enum QCompleter::CompletionMode
-
- This enum specifies how completions are provided to the user.
-
- \value PopupCompletion Current completions are displayed in a popup window.
- \value InlineCompletion Completions appear inline (as selected text).
- \value UnfilteredPopupCompletion All possible completions are displayed in a popup window with the most likely suggestion indicated as current.
-
- \sa setCompletionMode()
-*/
-
-/*!
- \property QCompleter::completionMode
- \brief how the completions are provided to the user
-
- The default value is QCompleter::PopupCompletion.
-*/
-void QCompleter::setCompletionMode(QCompleter::CompletionMode mode)
-{
- Q_D(QCompleter);
- d->mode = mode;
- d->proxy->setFiltered(mode != QCompleter::UnfilteredPopupCompletion);
-
- if (mode == QCompleter::InlineCompletion) {
- if (d->widget)
- d->widget->removeEventFilter(this);
- if (d->popup) {
- d->popup->deleteLater();
- d->popup = 0;
- }
- } else {
- if (d->widget)
- d->widget->installEventFilter(this);
- }
-}
-
-QCompleter::CompletionMode QCompleter::completionMode() const
-{
- Q_D(const QCompleter);
- return d->mode;
-}
-
-/*!
- Sets the popup used to display completions to \a popup. QCompleter takes
- ownership of the view.
-
- A QListView is automatically created when the completionMode() is set to
- QCompleter::PopupCompletion or QCompleter::UnfilteredPopupCompletion. The
- default popup displays the completionColumn().
-
- Ensure that this function is called before the view settings are modified.
- This is required since view's properties may require that a model has been
- set on the view (for example, hiding columns in the view requires a model
- to be set on the view).
-
- \sa popup()
-*/
-void QCompleter::setPopup(QAbstractItemView *popup)
-{
- Q_D(QCompleter);
- Q_ASSERT(popup != 0);
- if (d->popup) {
- QObject::disconnect(d->popup->selectionModel(), 0, this, 0);
- QObject::disconnect(d->popup, 0, this, 0);
- }
- if (d->popup != popup)
- delete d->popup;
- if (popup->model() != d->proxy)
- popup->setModel(d->proxy);
-#if defined(Q_OS_MAC) && !defined(QT_MAC_USE_COCOA)
- popup->show();
-#else
- popup->hide();
-#endif
-
- Qt::FocusPolicy origPolicy = Qt::NoFocus;
- if (d->widget)
- origPolicy = d->widget->focusPolicy();
- popup->setParent(0, Qt::Popup);
- popup->setFocusPolicy(Qt::NoFocus);
- if (d->widget)
- d->widget->setFocusPolicy(origPolicy);
-
- popup->setFocusProxy(d->widget);
- popup->installEventFilter(this);
- popup->setItemDelegate(new QCompleterItemDelegate(popup));
-#ifndef QT_NO_LISTVIEW
- if (QListView *listView = qobject_cast<QListView *>(popup)) {
- listView->setModelColumn(d->column);
- }
-#endif
-
- QObject::connect(popup, SIGNAL(clicked(QModelIndex)),
- this, SLOT(_q_complete(QModelIndex)));
- QObject::connect(this, SIGNAL(activated(QModelIndex)),
- popup, SLOT(hide()));
-
- QObject::connect(popup->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
- this, SLOT(_q_completionSelected(QItemSelection)));
- d->popup = popup;
-}
-
-/*!
- Returns the popup used to display completions.
-
- \sa setPopup()
-*/
-QAbstractItemView *QCompleter::popup() const
-{
- Q_D(const QCompleter);
-#ifndef QT_NO_LISTVIEW
- if (!d->popup && completionMode() != QCompleter::InlineCompletion) {
- QListView *listView = new QListView;
- listView->setEditTriggers(QAbstractItemView::NoEditTriggers);
- listView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- listView->setSelectionBehavior(QAbstractItemView::SelectRows);
- listView->setSelectionMode(QAbstractItemView::SingleSelection);
- listView->setModelColumn(d->column);
- QCompleter *that = const_cast<QCompleter*>(this);
- that->setPopup(listView);
- }
-#endif // QT_NO_LISTVIEW
- return d->popup;
-}
-
-/*!
- \reimp
-*/
-bool QCompleter::event(QEvent *ev)
-{
- return QObject::event(ev);
-}
-
-/*!
- \reimp
-*/
-bool QCompleter::eventFilter(QObject *o, QEvent *e)
-{
- Q_D(QCompleter);
-
- if (d->eatFocusOut && o == d->widget && e->type() == QEvent::FocusOut) {
- d->hiddenBecauseNoMatch = false;
- if (d->popup && d->popup->isVisible())
- return true;
- }
-
- if (o != d->popup)
- return QObject::eventFilter(o, e);
-
- switch (e->type()) {
- case QEvent::KeyPress: {
- QKeyEvent *ke = static_cast<QKeyEvent *>(e);
-
- QModelIndex curIndex = d->popup->currentIndex();
- QModelIndexList selList = d->popup->selectionModel()->selectedIndexes();
-
- const int key = ke->key();
- // In UnFilteredPopup mode, select the current item
- if ((key == Qt::Key_Up || key == Qt::Key_Down) && selList.isEmpty() && curIndex.isValid()
- && d->mode == QCompleter::UnfilteredPopupCompletion) {
- d->setCurrentIndex(curIndex);
- return true;
- }
-
- // Handle popup navigation keys. These are hardcoded because up/down might make the
- // widget do something else (lineedit cursor moves to home/end on mac, for instance)
- switch (key) {
- case Qt::Key_End:
- case Qt::Key_Home:
- if (ke->modifiers() & Qt::ControlModifier)
- return false;
- break;
-
- case Qt::Key_Up:
- if (!curIndex.isValid()) {
- int rowCount = d->proxy->rowCount();
- QModelIndex lastIndex = d->proxy->index(rowCount - 1, d->column);
- d->setCurrentIndex(lastIndex);
- return true;
- } else if (curIndex.row() == 0) {
- if (d->wrap)
- d->setCurrentIndex(QModelIndex());
- return true;
- }
- return false;
-
- case Qt::Key_Down:
- if (!curIndex.isValid()) {
- QModelIndex firstIndex = d->proxy->index(0, d->column);
- d->setCurrentIndex(firstIndex);
- return true;
- } else if (curIndex.row() == d->proxy->rowCount() - 1) {
- if (d->wrap)
- d->setCurrentIndex(QModelIndex());
- return true;
- }
- return false;
-
- case Qt::Key_PageUp:
- case Qt::Key_PageDown:
- return false;
- }
-
- // Send the event to the widget. If the widget accepted the event, do nothing
- // If the widget did not accept the event, provide a default implementation
- d->eatFocusOut = false;
- (static_cast<QObject *>(d->widget))->event(ke);
- d->eatFocusOut = true;
- if (!d->widget || e->isAccepted() || !d->popup->isVisible()) {
- // widget lost focus, hide the popup
- if (d->widget && (!d->widget->hasFocus()
-#ifdef QT_KEYPAD_NAVIGATION
- || (QApplication::keypadNavigationEnabled() && !d->widget->hasEditFocus())
-#endif
- ))
- d->popup->hide();
- if (e->isAccepted())
- return true;
- }
-
- // default implementation for keys not handled by the widget when popup is open
- switch (key) {
-#ifdef QT_KEYPAD_NAVIGATION
- case Qt::Key_Select:
- if (!QApplication::keypadNavigationEnabled())
- break;
-#endif
- case Qt::Key_Return:
- case Qt::Key_Enter:
- case Qt::Key_Tab:
- d->popup->hide();
- if (curIndex.isValid())
- d->_q_complete(curIndex);
- break;
-
- case Qt::Key_F4:
- if (ke->modifiers() & Qt::AltModifier)
- d->popup->hide();
- break;
-
- case Qt::Key_Backtab:
- case Qt::Key_Escape:
- d->popup->hide();
- break;
-
- default:
- break;
- }
-
- return true;
- }
-
-#ifdef QT_KEYPAD_NAVIGATION
- case QEvent::KeyRelease: {
- QKeyEvent *ke = static_cast<QKeyEvent *>(e);
- if (QApplication::keypadNavigationEnabled() && ke->key() == Qt::Key_Back) {
- // Send the event to the 'widget'. This is what we did for KeyPress, so we need
- // to do the same for KeyRelease, in case the widget's KeyPress event set
- // up something (such as a timer) that is relying on also receiving the
- // key release. I see this as a bug in Qt, and should really set it up for all
- // the affected keys. However, it is difficult to tell how this will affect
- // existing code, and I can't test for every combination!
- d->eatFocusOut = false;
- static_cast<QObject *>(d->widget)->event(ke);
- d->eatFocusOut = true;
- }
- break;
- }
-#endif
-
- case QEvent::MouseButtonPress: {
-#ifdef QT_KEYPAD_NAVIGATION
- if (QApplication::keypadNavigationEnabled()) {
- // if we've clicked in the widget (or its descendant), let it handle the click
- QWidget *source = qobject_cast<QWidget *>(o);
- if (source) {
- QPoint pos = source->mapToGlobal((static_cast<QMouseEvent *>(e))->pos());
- QWidget *target = QApplication::widgetAt(pos);
- if (target && (d->widget->isAncestorOf(target) ||
- target == d->widget)) {
- d->eatFocusOut = false;
- static_cast<QObject *>(target)->event(e);
- d->eatFocusOut = true;
- return true;
- }
- }
- }
-#endif
- if (!d->popup->underMouse()) {
- d->popup->hide();
- return true;
- }
- }
- return false;
-
- case QEvent::InputMethod:
- case QEvent::ShortcutOverride:
- QApplication::sendEvent(d->widget, e);
- break;
-
- default:
- return false;
- }
- return false;
-}
-
-/*!
- For QCompleter::PopupCompletion and QCompletion::UnfilteredPopupCompletion
- modes, calling this function displays the popup displaying the current
- completions. By default, if \a rect is not specified, the popup is displayed
- on the bottom of the widget(). If \a rect is specified the popup is
- displayed on the left edge of the rectangle.
-
- For QCompleter::InlineCompletion mode, the highlighted() signal is fired
- with the current completion.
-*/
-void QCompleter::complete(const QRect& rect)
-{
- Q_D(QCompleter);
- QModelIndex idx = d->proxy->currentIndex(false);
- d->hiddenBecauseNoMatch = false;
- if (d->mode == QCompleter::InlineCompletion) {
- if (idx.isValid())
- d->_q_complete(idx, true);
- return;
- }
-
- Q_ASSERT(d->widget != 0);
- if ((d->mode == QCompleter::PopupCompletion && !idx.isValid())
- || (d->mode == QCompleter::UnfilteredPopupCompletion && d->proxy->rowCount() == 0)) {
- if (d->popup)
- d->popup->hide(); // no suggestion, hide
- d->hiddenBecauseNoMatch = true;
- return;
- }
-
- popup();
- if (d->mode == QCompleter::UnfilteredPopupCompletion)
- d->setCurrentIndex(idx, false);
-
- d->showPopup(rect);
- d->popupRect = rect;
-}
-
-/*!
- Sets the current row to the \a row specified. Returns true if successful;
- otherwise returns false.
-
- This function may be used along with currentCompletion() to iterate
- through all the possible completions.
-
- \sa currentCompletion(), completionCount()
-*/
-bool QCompleter::setCurrentRow(int row)
-{
- Q_D(QCompleter);
- return d->proxy->setCurrentRow(row);
-}
-
-/*!
- Returns the current row.
-
- \sa setCurrentRow()
-*/
-int QCompleter::currentRow() const
-{
- Q_D(const QCompleter);
- return d->proxy->currentRow();
-}
-
-/*!
- Returns the number of completions for the current prefix. For an unsorted
- model with a large number of items this can be expensive. Use setCurrentRow()
- and currentCompletion() to iterate through all the completions.
-*/
-int QCompleter::completionCount() const
-{
- Q_D(const QCompleter);
- return d->proxy->completionCount();
-}
-
-/*!
- \enum QCompleter::ModelSorting
-
- This enum specifies how the items in the model are sorted.
-
- \value UnsortedModel The model is unsorted.
- \value CaseSensitivelySortedModel The model is sorted case sensitively.
- \value CaseInsensitivelySortedModel The model is sorted case insensitively.
-
- \sa setModelSorting()
-*/
-
-/*!
- \property QCompleter::modelSorting
- \brief the way the model is sorted
-
- By default, no assumptions are made about the order of the items
- in the model that provides the completions.
-
- If the model's data for the completionColumn() and completionRole() is sorted in
- ascending order, you can set this property to \l CaseSensitivelySortedModel
- or \l CaseInsensitivelySortedModel. On large models, this can lead to
- significant performance improvements because the completer object can
- then use a binary search algorithm instead of linear search algorithm.
-
- The sort order (i.e ascending or descending order) of the model is determined
- dynamically by inspecting the contents of the model.
-
- \bold{Note:} The performance improvements described above cannot take place
- when the completer's \l caseSensitivity is different to the case sensitivity
- used by the model's when sorting.
-
- \sa setCaseSensitivity(), QCompleter::ModelSorting
-*/
-void QCompleter::setModelSorting(QCompleter::ModelSorting sorting)
-{
- Q_D(QCompleter);
- if (d->sorting == sorting)
- return;
- d->sorting = sorting;
- d->proxy->createEngine();
- d->proxy->invalidate();
-}
-
-QCompleter::ModelSorting QCompleter::modelSorting() const
-{
- Q_D(const QCompleter);
- return d->sorting;
-}
-
-/*!
- \property QCompleter::completionColumn
- \brief the column in the model in which completions are searched for.
-
- If the popup() is a QListView, it is automatically setup to display
- this column.
-
- By default, the match column is 0.
-
- \sa completionRole, caseSensitivity
-*/
-void QCompleter::setCompletionColumn(int column)
-{
- Q_D(QCompleter);
- if (d->column == column)
- return;
-#ifndef QT_NO_LISTVIEW
- if (QListView *listView = qobject_cast<QListView *>(d->popup))
- listView->setModelColumn(column);
-#endif
- d->column = column;
- d->proxy->invalidate();
-}
-
-int QCompleter::completionColumn() const
-{
- Q_D(const QCompleter);
- return d->column;
-}
-
-/*!
- \property QCompleter::completionRole
- \brief the item role to be used to query the contents of items for matching.
-
- The default role is Qt::EditRole.
-
- \sa completionColumn, caseSensitivity
-*/
-void QCompleter::setCompletionRole(int role)
-{
- Q_D(QCompleter);
- if (d->role == role)
- return;
- d->role = role;
- d->proxy->invalidate();
-}
-
-int QCompleter::completionRole() const
-{
- Q_D(const QCompleter);
- return d->role;
-}
-
-/*!
- \property QCompleter::wrapAround
- \brief the completions wrap around when navigating through items
- \since 4.3
-
- The default is true.
-*/
-void QCompleter::setWrapAround(bool wrap)
-{
- Q_D(QCompleter);
- if (d->wrap == wrap)
- return;
- d->wrap = wrap;
-}
-
-bool QCompleter::wrapAround() const
-{
- Q_D(const QCompleter);
- return d->wrap;
-}
-
-/*!
- \property QCompleter::maxVisibleItems
- \brief the maximum allowed size on screen of the completer, measured in items
- \since 4.6
-
- By default, this property has a value of 7.
-*/
-int QCompleter::maxVisibleItems() const
-{
- Q_D(const QCompleter);
- return d->maxVisibleItems;
-}
-
-void QCompleter::setMaxVisibleItems(int maxItems)
-{
- Q_D(QCompleter);
- if (maxItems < 0) {
- qWarning("QCompleter::setMaxVisibleItems: "
- "Invalid max visible items (%d) must be >= 0", maxItems);
- return;
- }
- d->maxVisibleItems = maxItems;
-}
-
-/*!
- \property QCompleter::caseSensitivity
- \brief the case sensitivity of the matching
-
- The default is Qt::CaseSensitive.
-
- \sa completionColumn, completionRole, modelSorting
-*/
-void QCompleter::setCaseSensitivity(Qt::CaseSensitivity cs)
-{
- Q_D(QCompleter);
- if (d->cs == cs)
- return;
- d->cs = cs;
- d->proxy->createEngine();
- d->proxy->invalidate();
-}
-
-Qt::CaseSensitivity QCompleter::caseSensitivity() const
-{
- Q_D(const QCompleter);
- return d->cs;
-}
-
-/*!
- \property QCompleter::completionPrefix
- \brief the completion prefix used to provide completions.
-
- The completionModel() is updated to reflect the list of possible
- matches for \a prefix.
-*/
-void QCompleter::setCompletionPrefix(const QString &prefix)
-{
- Q_D(QCompleter);
- d->prefix = prefix;
- d->proxy->filter(splitPath(prefix));
-}
-
-QString QCompleter::completionPrefix() const
-{
- Q_D(const QCompleter);
- return d->prefix;
-}
-
-/*!
- Returns the model index of the current completion in the completionModel().
-
- \sa setCurrentRow(), currentCompletion(), model()
-*/
-QModelIndex QCompleter::currentIndex() const
-{
- Q_D(const QCompleter);
- return d->proxy->currentIndex(false);
-}
-
-/*!
- Returns the current completion string. This includes the \l completionPrefix.
- When used alongside setCurrentRow(), it can be used to iterate through
- all the matches.
-
- \sa setCurrentRow(), currentIndex()
-*/
-QString QCompleter::currentCompletion() const
-{
- Q_D(const QCompleter);
- return pathFromIndex(d->proxy->currentIndex(true));
-}
-
-/*!
- Returns the completion model. The completion model is a read-only list model
- that contains all the possible matches for the current completion prefix.
- The completion model is auto-updated to reflect the current completions.
-
- \note The return value of this function is defined to be an QAbstractItemModel
- purely for generality. This actual kind of model returned is an instance of an
- QAbstractProxyModel subclass.
-
- \sa completionPrefix, model()
-*/
-QAbstractItemModel *QCompleter::completionModel() const
-{
- Q_D(const QCompleter);
- return d->proxy;
-}
-
-/*!
- Returns the path for the given \a index. The completer object uses this to
- obtain the completion text from the underlying model.
-
- The default implementation returns the \l{Qt::EditRole}{edit role} of the
- item for list models. It returns the absolute file path if the model is a
- QFileSystemModel.
-
- \sa splitPath()
-*/
-
-QString QCompleter::pathFromIndex(const QModelIndex& index) const
-{
- Q_D(const QCompleter);
- if (!index.isValid())
- return QString();
-
- QAbstractItemModel *sourceModel = d->proxy->sourceModel();
- if (!sourceModel)
- return QString();
- bool isDirModel = false;
- bool isFsModel = false;
-#ifndef QT_NO_DIRMODEL
- isDirModel = qobject_cast<QDirModel *>(d->proxy->sourceModel()) != 0;
-#endif
-#ifndef QT_NO_FILESYSTEMMODEL
- isFsModel = qobject_cast<QFileSystemModel *>(d->proxy->sourceModel()) != 0;
-#endif
- if (!isDirModel && !isFsModel)
- return sourceModel->data(index, d->role).toString();
-
- QModelIndex idx = index;
- QStringList list;
- do {
- QString t;
- if (isDirModel)
- t = sourceModel->data(idx, Qt::EditRole).toString();
-#ifndef QT_NO_FILESYSTEMMODEL
- else
- t = sourceModel->data(idx, QFileSystemModel::FileNameRole).toString();
-#endif
- list.prepend(t);
- QModelIndex parent = idx.parent();
- idx = parent.sibling(parent.row(), index.column());
- } while (idx.isValid());
-
-#if (!defined(Q_OS_WIN) || defined(Q_OS_WINCE)) && !defined(Q_OS_SYMBIAN)
- if (list.count() == 1) // only the separator or some other text
- return list[0];
- list[0].clear() ; // the join below will provide the separator
-#endif
-
- return list.join(QDir::separator());
-}
-
-/*!
- Splits the given \a path into strings that are used to match at each level
- in the model().
-
- The default implementation of splitPath() splits a file system path based on
- QDir::separator() when the sourceModel() is a QFileSystemModel.
-
- When used with list models, the first item in the returned list is used for
- matching.
-
- \sa pathFromIndex(), {Handling Tree Models}
-*/
-QStringList QCompleter::splitPath(const QString& path) const
-{
- bool isDirModel = false;
- bool isFsModel = false;
-#ifndef QT_NO_DIRMODEL
- Q_D(const QCompleter);
- isDirModel = qobject_cast<QDirModel *>(d->proxy->sourceModel()) != 0;
-#endif
-#ifndef QT_NO_FILESYSTEMMODEL
-#ifdef QT_NO_DIRMODEL
- Q_D(const QCompleter);
-#endif
- isFsModel = qobject_cast<QFileSystemModel *>(d->proxy->sourceModel()) != 0;
-#endif
-
- if ((!isDirModel && !isFsModel) || path.isEmpty())
- return QStringList(completionPrefix());
-
- QString pathCopy = QDir::toNativeSeparators(path);
- QString sep = QDir::separator();
-#if defined(Q_OS_SYMBIAN)
- if (pathCopy == QLatin1String("\\"))
- return QStringList(pathCopy);
-#elif defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
- if (pathCopy == QLatin1String("\\") || pathCopy == QLatin1String("\\\\"))
- return QStringList(pathCopy);
- QString doubleSlash(QLatin1String("\\\\"));
- if (pathCopy.startsWith(doubleSlash))
- pathCopy = pathCopy.mid(2);
- else
- doubleSlash.clear();
-#endif
-
- QRegExp re(QLatin1Char('[') + QRegExp::escape(sep) + QLatin1Char(']'));
- QStringList parts = pathCopy.split(re);
-
-#if defined(Q_OS_SYMBIAN)
- // Do nothing
-#elif defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
- if (!doubleSlash.isEmpty())
- parts[0].prepend(doubleSlash);
-#else
- if (pathCopy[0] == sep[0]) // readd the "/" at the beginning as the split removed it
- parts[0] = QDir::fromNativeSeparators(QString(sep[0]));
-#endif
-
- return parts;
-}
-
-/*!
- \fn void QCompleter::activated(const QModelIndex& index)
-
- This signal is sent when an item in the popup() is activated by the user.
- (by clicking or pressing return). The item's \a index in the completionModel()
- is given.
-
-*/
-
-/*!
- \fn void QCompleter::activated(const QString &text)
-
- This signal is sent when an item in the popup() is activated by the user (by
- clicking or pressing return). The item's \a text is given.
-
-*/
-
-/*!
- \fn void QCompleter::highlighted(const QModelIndex& index)
-
- This signal is sent when an item in the popup() is highlighted by
- the user. It is also sent if complete() is called with the completionMode()
- set to QCompleter::InlineCompletion. The item's \a index in the completionModel()
- is given.
-*/
-
-/*!
- \fn void QCompleter::highlighted(const QString &text)
-
- This signal is sent when an item in the popup() is highlighted by
- the user. It is also sent if complete() is called with the completionMode()
- set to QCompleter::InlineCompletion. The item's \a text is given.
-*/
-
-QT_END_NAMESPACE
-
-#include "moc_qcompleter.cpp"
-
-#endif // QT_NO_COMPLETER
diff --git a/src/gui/util/qcompleter_p.h b/src/gui/util/qcompleter_p.h
deleted file mode 100644
index 83e7a27636..0000000000
--- a/src/gui/util/qcompleter_p.h
+++ /dev/null
@@ -1,264 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QCOMPLETER_P_H
-#define QCOMPLETER_P_H
-
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "private/qobject_p.h"
-
-#ifndef QT_NO_COMPLETER
-
-#include "QtGui/qtreeview.h"
-#include "QtGui/qabstractproxymodel.h"
-#include "qcompleter.h"
-#include "QtGui/qitemdelegate.h"
-#include "QtGui/qpainter.h"
-#include "private/qabstractproxymodel_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QCompletionModel;
-
-class QCompleterPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QCompleter)
-
-public:
- QCompleterPrivate();
- ~QCompleterPrivate() { delete popup; }
- void init(QAbstractItemModel *model = 0);
-
- QPointer<QWidget> widget;
- QCompletionModel *proxy;
- QAbstractItemView *popup;
- QCompleter::CompletionMode mode;
-
- QString prefix;
- Qt::CaseSensitivity cs;
- int role;
- int column;
- int maxVisibleItems;
- QCompleter::ModelSorting sorting;
- bool wrap;
-
- bool eatFocusOut;
- QRect popupRect;
- bool hiddenBecauseNoMatch;
-
- void showPopup(const QRect&);
- void _q_complete(QModelIndex, bool = false);
- void _q_completionSelected(const QItemSelection&);
- void _q_autoResizePopup();
- void _q_fileSystemModelDirectoryLoaded(const QString &path);
- void setCurrentIndex(QModelIndex, bool = true);
-};
-
-class QIndexMapper
-{
-public:
- QIndexMapper() : v(false), f(0), t(-1) { }
- QIndexMapper(int f, int t) : v(false), f(f), t(t) { }
- QIndexMapper(QVector<int> vec) : v(true), vector(vec), f(-1), t(-1) { }
-
- inline int count() const { return v ? vector.count() : t - f + 1; }
- inline int operator[] (int index) const { return v ? vector[index] : f + index; }
- inline int indexOf(int x) const { return v ? vector.indexOf(x) : ((t < f) ? -1 : x - f); }
- inline bool isValid() const { return !isEmpty(); }
- inline bool isEmpty() const { return v ? vector.isEmpty() : (t < f); }
- inline void append(int x) { Q_ASSERT(v); vector.append(x); }
- inline int first() const { return v ? vector.first() : f; }
- inline int last() const { return v ? vector.last() : t; }
- inline int from() const { Q_ASSERT(!v); return f; }
- inline int to() const { Q_ASSERT(!v); return t; }
- inline int cost() const { return vector.count()+2; }
-
-private:
- bool v;
- QVector<int> vector;
- int f, t;
-};
-
-struct QMatchData {
- QMatchData() : exactMatchIndex(-1) { }
- QMatchData(const QIndexMapper& indices, int em, bool p) :
- indices(indices), exactMatchIndex(em), partial(p) { }
- QIndexMapper indices;
- inline bool isValid() const { return indices.isValid(); }
- int exactMatchIndex;
- bool partial;
-};
-
-class QCompletionEngine
-{
-public:
- typedef QMap<QString, QMatchData> CacheItem;
- typedef QMap<QModelIndex, CacheItem> Cache;
-
- QCompletionEngine(QCompleterPrivate *c) : c(c), curRow(-1), cost(0) { }
- virtual ~QCompletionEngine() { }
-
- void filter(const QStringList &parts);
-
- QMatchData filterHistory();
- bool matchHint(QString, const QModelIndex&, QMatchData*);
-
- void saveInCache(QString, const QModelIndex&, const QMatchData&);
- bool lookupCache(QString part, const QModelIndex& parent, QMatchData *m);
-
- virtual void filterOnDemand(int) { }
- virtual QMatchData filter(const QString&, const QModelIndex&, int) = 0;
-
- int matchCount() const { return curMatch.indices.count() + historyMatch.indices.count(); }
-
- QMatchData curMatch, historyMatch;
- QCompleterPrivate *c;
- QStringList curParts;
- QModelIndex curParent;
- int curRow;
-
- Cache cache;
- int cost;
-};
-
-class QSortedModelEngine : public QCompletionEngine
-{
-public:
- QSortedModelEngine(QCompleterPrivate *c) : QCompletionEngine(c) { }
- QMatchData filter(const QString&, const QModelIndex&, int);
- QIndexMapper indexHint(QString, const QModelIndex&, Qt::SortOrder);
- Qt::SortOrder sortOrder(const QModelIndex&) const;
-};
-
-class QUnsortedModelEngine : public QCompletionEngine
-{
-public:
- QUnsortedModelEngine(QCompleterPrivate *c) : QCompletionEngine(c) { }
-
- void filterOnDemand(int);
- QMatchData filter(const QString&, const QModelIndex&, int);
-private:
- int buildIndices(const QString& str, const QModelIndex& parent, int n,
- const QIndexMapper& iv, QMatchData* m);
-};
-
-class QCompleterItemDelegate : public QItemDelegate
-{
-public:
- QCompleterItemDelegate(QAbstractItemView *view)
- : QItemDelegate(view), view(view) { }
- void paint(QPainter *p, const QStyleOptionViewItem& opt, const QModelIndex& idx) const {
- QStyleOptionViewItem optCopy = opt;
- optCopy.showDecorationSelected = true;
- if (view->currentIndex() == idx)
- optCopy.state |= QStyle::State_HasFocus;
- QItemDelegate::paint(p, optCopy, idx);
- }
-
-private:
- QAbstractItemView *view;
-};
-
-class QCompletionModelPrivate;
-
-class QCompletionModel : public QAbstractProxyModel
-{
- Q_OBJECT
-
-public:
- QCompletionModel(QCompleterPrivate *c, QObject *parent);
-
- void createEngine();
- void setFiltered(bool);
- void filter(const QStringList& parts);
- int completionCount() const;
- int currentRow() const { return engine->curRow; }
- bool setCurrentRow(int row);
- QModelIndex currentIndex(bool) const;
- void resetModel();
-
- QModelIndex index(int row, int column, const QModelIndex & = QModelIndex()) const;
- int rowCount(const QModelIndex &index = QModelIndex()) const;
- int columnCount(const QModelIndex &index = QModelIndex()) const;
- bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
- QModelIndex parent(const QModelIndex & = QModelIndex()) const { return QModelIndex(); }
- QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
-
- void setSourceModel(QAbstractItemModel *sourceModel);
- QModelIndex mapToSource(const QModelIndex& proxyIndex) const;
- QModelIndex mapFromSource(const QModelIndex& sourceIndex) const;
-
- QCompleterPrivate *c;
- QScopedPointer<QCompletionEngine> engine;
- bool showAll;
-
- Q_DECLARE_PRIVATE(QCompletionModel)
-
-signals:
- void rowsAdded();
-
-public Q_SLOTS:
- void invalidate();
- void rowsInserted();
- void modelDestroyed();
-};
-
-class QCompletionModelPrivate : public QAbstractProxyModelPrivate
-{
- Q_DECLARE_PUBLIC(QCompletionModel)
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_COMPLETER
-
-#endif // QCOMPLETER_P_H
diff --git a/src/gui/util/qdesktopservices.cpp b/src/gui/util/qdesktopservices.cpp
deleted file mode 100644
index cb5a3ef560..0000000000
--- a/src/gui/util/qdesktopservices.cpp
+++ /dev/null
@@ -1,309 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdesktopservices.h"
-
-#ifndef QT_NO_DESKTOPSERVICES
-
-#include <qdebug.h>
-
-#if defined(Q_WS_QWS) || defined(Q_WS_QPA)
-#include "qdesktopservices_qws.cpp"
-#elif defined(Q_WS_X11)
-#include "qdesktopservices_x11.cpp"
-#elif defined(Q_WS_WIN)
-#include "qdesktopservices_win.cpp"
-#elif defined(Q_WS_MAC)
-#include "qdesktopservices_mac.cpp"
-#elif defined(Q_OS_SYMBIAN)
-#include "qdesktopservices_s60.cpp"
-#endif
-
-#include <qhash.h>
-#include <qobject.h>
-#include <qcoreapplication.h>
-#include <qurl.h>
-#include <qmutex.h>
-
-QT_BEGIN_NAMESPACE
-
-class QOpenUrlHandlerRegistry : public QObject
-{
- Q_OBJECT
-public:
- inline QOpenUrlHandlerRegistry() : mutex(QMutex::Recursive) {}
-
- QMutex mutex;
-
- struct Handler
- {
- QObject *receiver;
- QByteArray name;
- };
- typedef QHash<QString, Handler> HandlerHash;
- HandlerHash handlers;
-
-public Q_SLOTS:
- void handlerDestroyed(QObject *handler);
-
-};
-
-Q_GLOBAL_STATIC(QOpenUrlHandlerRegistry, handlerRegistry)
-
-void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
-{
- HandlerHash::Iterator it = handlers.begin();
- while (it != handlers.end()) {
- if (it->receiver == handler) {
- it = handlers.erase(it);
- } else {
- ++it;
- }
- }
-}
-
-/*!
- \class QDesktopServices
- \brief The QDesktopServices class provides methods for accessing common desktop services.
- \since 4.2
- \ingroup desktop
-
- Many desktop environments provide services that can be used by applications to
- perform common tasks, such as opening a web page, in a way that is both consistent
- and takes into account the user's application preferences.
-
- This class contains functions that provide simple interfaces to these services
- that indicate whether they succeeded or failed.
-
- The openUrl() function is used to open files located at arbitrary URLs in external
- applications. For URLs that correspond to resources on the local filing system
- (where the URL scheme is "file"), a suitable application will be used to open the
- file; otherwise, a web browser will be used to fetch and display the file.
-
- The user's desktop settings control whether certain executable file types are
- opened for browsing, or if they are executed instead. Some desktop environments
- are configured to prevent users from executing files obtained from non-local URLs,
- or to ask the user's permission before doing so.
-
- \section1 URL Handlers
-
- The behavior of the openUrl() function can be customized for individual URL
- schemes to allow applications to override the default handling behavior for
- certain types of URLs.
-
- The dispatch mechanism allows only one custom handler to be used for each URL
- scheme; this is set using the setUrlHandler() function. Each handler is
- implemented as a slot which accepts only a single QUrl argument.
-
- The existing handlers for each scheme can be removed with the
- unsetUrlHandler() function. This returns the handling behavior for the given
- scheme to the default behavior.
-
- This system makes it easy to implement a help system, for example. Help could be
- provided in labels and text browsers using \gui{help://myapplication/mytopic}
- URLs, and by registering a handler it becomes possible to display the help text
- inside the application:
-
- \snippet doc/src/snippets/code/src_gui_util_qdesktopservices.cpp 0
-
- If inside the handler you decide that you can't open the requested
- URL, you can just call QDesktopServices::openUrl() again with the
- same argument, and it will try to open the URL using the
- appropriate mechanism for the user's desktop environment.
-
- \sa QSystemTrayIcon, QProcess
-*/
-
-/*!
- Opens the given \a url in the appropriate Web browser for the user's desktop
- environment, and returns true if successful; otherwise returns false.
-
- If the URL is a reference to a local file (i.e., the URL scheme is "file") then
- it will be opened with a suitable application instead of a Web browser.
-
- The following example opens a file on the Windows file system residing on a path
- that contains spaces:
-
- \snippet doc/src/snippets/code/src_gui_util_qdesktopservices.cpp 2
-
- If a \c mailto URL is specified, the user's e-mail client will be used to open a
- composer window containing the options specified in the URL, similar to the way
- \c mailto links are handled by a Web browser.
-
- For example, the following URL contains a recipient (\c{user@foo.com}), a
- subject (\c{Test}), and a message body (\c{Just a test}):
-
- \snippet doc/src/snippets/code/src_gui_util_qdesktopservices.cpp 1
-
- \warning Although many e-mail clients can send attachments and are
- Unicode-aware, the user may have configured their client without these features.
- Also, certain e-mail clients (e.g., Lotus Notes) have problems with long URLs.
-
- \sa setUrlHandler()
-*/
-bool QDesktopServices::openUrl(const QUrl &url)
-{
- QOpenUrlHandlerRegistry *registry = handlerRegistry();
- QMutexLocker locker(&registry->mutex);
- static bool insideOpenUrlHandler = false;
-
- if (!insideOpenUrlHandler) {
- QOpenUrlHandlerRegistry::HandlerHash::ConstIterator handler = registry->handlers.constFind(url.scheme());
- if (handler != registry->handlers.constEnd()) {
- insideOpenUrlHandler = true;
- bool result = QMetaObject::invokeMethod(handler->receiver, handler->name.constData(), Qt::DirectConnection, Q_ARG(QUrl, url));
- insideOpenUrlHandler = false;
- return result; // ### support bool slot return type
- }
- }
-
- bool result;
- if (url.scheme() == QLatin1String("file"))
- result = openDocument(url);
- else
- result = launchWebBrowser(url);
-
- return result;
-}
-
-/*!
- Sets the handler for the given \a scheme to be the handler \a method provided by
- the \a receiver object.
-
- This function provides a way to customize the behavior of openUrl(). If openUrl()
- is called with a URL with the specified \a scheme then the given \a method on the
- \a receiver object is called instead of QDesktopServices launching an external
- application.
-
- The provided method must be implemented as a slot that only accepts a single QUrl
- argument.
-
- If setUrlHandler() is used to set a new handler for a scheme which already
- has a handler, the existing handler is simply replaced with the new one.
- Since QDesktopServices does not take ownership of handlers, no objects are
- deleted when a handler is replaced.
-
- Note that the handler will always be called from within the same thread that
- calls QDesktopServices::openUrl().
-
- \sa openUrl(), unsetUrlHandler()
-*/
-void QDesktopServices::setUrlHandler(const QString &scheme, QObject *receiver, const char *method)
-{
- QOpenUrlHandlerRegistry *registry = handlerRegistry();
- QMutexLocker locker(&registry->mutex);
- if (!receiver) {
- registry->handlers.remove(scheme);
- return;
- }
- QOpenUrlHandlerRegistry::Handler h;
- h.receiver = receiver;
- h.name = method;
- registry->handlers.insert(scheme, h);
- QObject::connect(receiver, SIGNAL(destroyed(QObject*)),
- registry, SLOT(handlerDestroyed(QObject*)));
-}
-
-/*!
- Removes a previously set URL handler for the specified \a scheme.
-
- \sa setUrlHandler()
-*/
-void QDesktopServices::unsetUrlHandler(const QString &scheme)
-{
- setUrlHandler(scheme, 0, 0);
-}
-
-/*!
- \enum QDesktopServices::StandardLocation
- \since 4.4
-
- This enum describes the different locations that can be queried by
- QDesktopServices::storageLocation and QDesktopServices::displayName.
-
- \value DesktopLocation Returns the user's desktop directory.
- \value DocumentsLocation Returns the user's document.
- \value FontsLocation Returns the user's fonts.
- \value ApplicationsLocation Returns the user's applications.
- \value MusicLocation Returns the users music.
- \value MoviesLocation Returns the user's movies.
- \value PicturesLocation Returns the user's pictures.
- \value TempLocation Returns the system's temporary directory.
- \value HomeLocation Returns the user's home directory.
- \value DataLocation Returns a directory location where persistent
- application data can be stored. QCoreApplication::applicationName
- and QCoreApplication::organizationName should work on all
- platforms.
- \value CacheLocation Returns a directory location where user-specific
- non-essential (cached) data should be written.
-
- \sa storageLocation() displayName()
-*/
-
-/*!
- \fn QString QDesktopServices::storageLocation(StandardLocation type)
- \since 4.4
-
- Returns the default system directory where files of \a type belong, or an empty string
- if the location cannot be determined.
-
- \note The storage location returned can be a directory that does not exist; i.e., it
- may need to be created by the system or the user.
-
- \note On Symbian OS, ApplicationsLocation always point /sys/bin folder on the same drive
- with executable. FontsLocation always points to folder on ROM drive. Symbian OS does not
- have desktop concept, DesktopLocation returns same path as DocumentsLocation.
- Rest of the standard locations point to folder on same drive with executable, except
- that if executable is in ROM the folder from C drive is returned.
-*/
-
-/*!
- \fn QString QDesktopServices::displayName(StandardLocation type)
-
- Returns a localized display name for the given location \a type or
- an empty QString if no relevant location can be found.
-*/
-
-QT_END_NAMESPACE
-
-#include "qdesktopservices.moc"
-
-#endif // QT_NO_DESKTOPSERVICES
diff --git a/src/gui/util/qscroller.h b/src/gui/util/qscroller.h
deleted file mode 100644
index 1599c7dcdf..0000000000
--- a/src/gui/util/qscroller.h
+++ /dev/null
@@ -1,155 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSCROLLER_H
-#define QSCROLLER_H
-
-#include <QtCore/QObject>
-#include <QtCore/QPointF>
-#include <QtGui/QScrollerProperties>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QWidget;
-class QScrollerPrivate;
-class QScrollerProperties;
-#ifndef QT_NO_GESTURES
-class QFlickGestureRecognizer;
-class QMouseFlickGestureRecognizer;
-#endif
-
-class Q_GUI_EXPORT QScroller : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(State state READ state NOTIFY stateChanged)
- Q_PROPERTY(QScrollerProperties scrollerProperties READ scrollerProperties WRITE setScrollerProperties NOTIFY scrollerPropertiesChanged)
- Q_ENUMS(State)
-
-public:
- enum State
- {
- Inactive,
- Pressed,
- Dragging,
- Scrolling
- };
-
- enum ScrollerGestureType
- {
- TouchGesture,
- LeftMouseButtonGesture,
- RightMouseButtonGesture,
- MiddleMouseButtonGesture
- };
-
- enum Input
- {
- InputPress = 1,
- InputMove,
- InputRelease
- };
-
- static bool hasScroller(QObject *target);
-
- static QScroller *scroller(QObject *target);
- static const QScroller *scroller(const QObject *target);
-
-#ifndef QT_NO_GESTURES
- static Qt::GestureType grabGesture(QObject *target, ScrollerGestureType gestureType = TouchGesture);
- static Qt::GestureType grabbedGesture(QObject *target);
- static void ungrabGesture(QObject *target);
-#endif
-
- static QList<QScroller *> activeScrollers();
-
- QObject *target() const;
-
- State state() const;
-
- bool handleInput(Input input, const QPointF &position, qint64 timestamp = 0);
-
- void stop();
- QPointF velocity() const;
- QPointF finalPosition() const;
- QPointF pixelPerMeter() const;
-
- QScrollerProperties scrollerProperties() const;
-
- void setSnapPositionsX( const QList<qreal> &positions );
- void setSnapPositionsX( qreal first, qreal interval );
- void setSnapPositionsY( const QList<qreal> &positions );
- void setSnapPositionsY( qreal first, qreal interval );
-
-public Q_SLOTS:
- void setScrollerProperties(const QScrollerProperties &prop);
- void scrollTo(const QPointF &pos);
- void scrollTo(const QPointF &pos, int scrollTime);
- void ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin);
- void ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin, int scrollTime);
- void resendPrepareEvent();
-
-Q_SIGNALS:
- void stateChanged(QScroller::State newstate);
- void scrollerPropertiesChanged(const QScrollerProperties &);
-
-private:
- QScrollerPrivate *d_ptr;
-
- QScroller(QObject *target);
- virtual ~QScroller();
-
- Q_DISABLE_COPY(QScroller)
- Q_DECLARE_PRIVATE(QScroller)
-
-#ifndef QT_NO_GESTURES
- friend class QFlickGestureRecognizer;
-#endif
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSCROLLER_H
diff --git a/src/gui/util/qsystemtrayicon.h b/src/gui/util/qsystemtrayicon.h
deleted file mode 100644
index 1f0dab5393..0000000000
--- a/src/gui/util/qsystemtrayicon.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSYSTEMTRAYICON_H
-#define QSYSTEMTRAYICON_H
-
-#include <QtCore/qobject.h>
-
-#ifndef QT_NO_SYSTEMTRAYICON
-
-#include <QtGui/qicon.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QSystemTrayIconPrivate;
-
-class QMenu;
-class QEvent;
-class QWheelEvent;
-class QMouseEvent;
-class QPoint;
-
-class Q_GUI_EXPORT QSystemTrayIcon : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip)
- Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
- Q_PROPERTY(bool visible READ isVisible WRITE setVisible DESIGNABLE false)
-
-public:
- QSystemTrayIcon(QObject *parent = 0);
- QSystemTrayIcon(const QIcon &icon, QObject *parent = 0);
- ~QSystemTrayIcon();
-
- enum ActivationReason {
- Unknown,
- Context,
- DoubleClick,
- Trigger,
- MiddleClick
- };
-
-#ifndef QT_NO_MENU
- void setContextMenu(QMenu *menu);
- QMenu *contextMenu() const;
-#endif
-
- QIcon icon() const;
- void setIcon(const QIcon &icon);
-
- QString toolTip() const;
- void setToolTip(const QString &tip);
-
- static bool isSystemTrayAvailable();
- static bool supportsMessages();
-
- enum MessageIcon { NoIcon, Information, Warning, Critical };
- void showMessage(const QString &title, const QString &msg,
- MessageIcon icon = Information, int msecs = 10000);
-
- QRect geometry() const;
- bool isVisible() const;
-
-public Q_SLOTS:
- void setVisible(bool visible);
- inline void show() { setVisible(true); }
- inline void hide() { setVisible(false); }
-
-Q_SIGNALS:
- void activated(QSystemTrayIcon::ActivationReason reason);
- void messageClicked();
-
-protected:
- bool event(QEvent *event);
-
-private:
- Q_DISABLE_COPY(QSystemTrayIcon)
- Q_DECLARE_PRIVATE(QSystemTrayIcon)
-
- friend class QSystemTrayIconSys;
- friend class QBalloonTip;
- friend void qtsystray_sendActivated(QSystemTrayIcon *, int);
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_SYSTEMTRAYICON
-#endif // QSYSTEMTRAYICON_H
diff --git a/src/gui/util/qsystemtrayicon_p.h b/src/gui/util/qsystemtrayicon_p.h
deleted file mode 100644
index cc7bd47092..0000000000
--- a/src/gui/util/qsystemtrayicon_p.h
+++ /dev/null
@@ -1,186 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSYSTEMTRAYICON_P_H
-#define QSYSTEMTRAYICON_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of a number of Qt sources files. This header file may change from
-// version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qsystemtrayicon.h"
-#include "private/qobject_p.h"
-
-#ifndef QT_NO_SYSTEMTRAYICON
-
-#include "QtGui/qmenu.h"
-#include "QtGui/qpixmap.h"
-#include "QtCore/qstring.h"
-#include "QtCore/qpointer.h"
-
-QT_BEGIN_NAMESPACE
-
-class QSystemTrayIconSys;
-class QToolButton;
-class QLabel;
-
-class QSystemTrayIconPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QSystemTrayIcon)
-
-public:
- QSystemTrayIconPrivate() : sys(0), visible(false) { }
-
- void install_sys();
- void remove_sys();
- void updateIcon_sys();
- void updateToolTip_sys();
- void updateMenu_sys();
- QRect geometry_sys() const;
- void showMessage_sys(const QString &msg, const QString &title, QSystemTrayIcon::MessageIcon icon, int secs);
-
- static bool isSystemTrayAvailable_sys();
- static bool supportsMessages_sys();
-
- QPointer<QMenu> menu;
- QIcon icon;
- QString toolTip;
- QSystemTrayIconSys *sys;
- bool visible;
-};
-
-class QBalloonTip : public QWidget
-{
- Q_OBJECT
-public:
- static void showBalloon(QSystemTrayIcon::MessageIcon icon, const QString& title,
- const QString& msg, QSystemTrayIcon *trayIcon,
- const QPoint& pos, int timeout, bool showArrow = true);
- static void hideBalloon();
- static bool isBalloonVisible();
-
-private:
- QBalloonTip(QSystemTrayIcon::MessageIcon icon, const QString& title,
- const QString& msg, QSystemTrayIcon *trayIcon);
- ~QBalloonTip();
- void balloon(const QPoint&, int, bool);
-
-protected:
- void paintEvent(QPaintEvent *);
- void resizeEvent(QResizeEvent *);
- void mousePressEvent(QMouseEvent *e);
- void timerEvent(QTimerEvent *e);
-
-private:
- QSystemTrayIcon *trayIcon;
- QPixmap pixmap;
- int timerId;
-};
-
-#if defined(Q_WS_X11)
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <QtCore/qcoreapplication.h>
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-#include <X11/Xutil.h>
-QT_END_INCLUDE_NAMESPACE
-
-class QSystemTrayIconSys : public QWidget
-{
- friend class QSystemTrayIconPrivate;
-
-public:
- QSystemTrayIconSys(QSystemTrayIcon *q);
- ~QSystemTrayIconSys();
- enum {
- SYSTEM_TRAY_REQUEST_DOCK = 0,
- SYSTEM_TRAY_BEGIN_MESSAGE = 1,
- SYSTEM_TRAY_CANCEL_MESSAGE =2
- };
-
- void addToTray();
- void updateIcon();
- XVisualInfo* getSysTrayVisualInfo();
-
- // QObject::event is public but QWidget's ::event() re-implementation
- // is protected ;(
- inline bool deliverToolTipEvent(QEvent *e)
- { return QWidget::event(e); }
-
- static Window sysTrayWindow;
- static QList<QSystemTrayIconSys *> trayIcons;
- static QCoreApplication::EventFilter oldEventFilter;
- static bool sysTrayTracker(void *message, long *result);
- static Window locateSystemTray();
- static Atom sysTraySelection;
- static XVisualInfo sysTrayVisual;
-
-protected:
- void paintEvent(QPaintEvent *pe);
- void resizeEvent(QResizeEvent *re);
- bool x11Event(XEvent *event);
- void mousePressEvent(QMouseEvent *event);
- void mouseDoubleClickEvent(QMouseEvent *event);
-#ifndef QT_NO_WHEELEVENT
- void wheelEvent(QWheelEvent *event);
-#endif
- bool event(QEvent *e);
-
-private:
- QPixmap background;
- QSystemTrayIcon *q;
- Colormap colormap;
-};
-#endif // Q_WS_X11
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_SYSTEMTRAYICON
-
-#endif // QSYSTEMTRAYICON_P_H
-
diff --git a/src/gui/util/qundostack_p.h b/src/gui/util/qundostack_p.h
deleted file mode 100644
index a10076366a..0000000000
--- a/src/gui/util/qundostack_p.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QUNDOSTACK_P_H
-#define QUNDOSTACK_P_H
-
-#include <private/qobject_p.h>
-#include <QtCore/qlist.h>
-#include <QtCore/qstring.h>
-#include <QtGui/qaction.h>
-
-#include "qundostack.h"
-
-QT_BEGIN_NAMESPACE
-class QUndoCommand;
-class QUndoGroup;
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header
-// file may change from version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-class QUndoCommandPrivate
-{
-public:
- QUndoCommandPrivate() : id(-1) {}
- QList<QUndoCommand*> child_list;
- QString text;
- QString actionText;
- int id;
-};
-
-#ifndef QT_NO_UNDOSTACK
-
-class QUndoStackPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QUndoStack)
-public:
- QUndoStackPrivate() : index(0), clean_index(0), group(0), undo_limit(0) {}
-
- QList<QUndoCommand*> command_list;
- QList<QUndoCommand*> macro_stack;
- int index;
- int clean_index;
- QUndoGroup *group;
- int undo_limit;
-
- void setIndex(int idx, bool clean);
- bool checkUndoLimit();
-};
-
-#ifndef QT_NO_ACTION
-class QUndoAction : public QAction
-{
- Q_OBJECT
-public:
- QUndoAction(const QString &prefix, QObject *parent = 0);
- void setTextFormat(const QString &textFormat, const QString &defaultText);
-public Q_SLOTS:
- void setPrefixedText(const QString &text);
-private:
- QString m_prefix;
- QString m_defaultText;
-};
-#endif // QT_NO_ACTION
-
-
-QT_END_NAMESPACE
-#endif // QT_NO_UNDOSTACK
-#endif // QUNDOSTACK_P_H
diff --git a/src/gui/util/qundoview.cpp b/src/gui/util/qundoview.cpp
deleted file mode 100644
index 43c1774b25..0000000000
--- a/src/gui/util/qundoview.cpp
+++ /dev/null
@@ -1,476 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qundostack.h"
-#include "qundoview.h"
-
-#ifndef QT_NO_UNDOVIEW
-
-#include "qundogroup.h"
-#include <QtCore/qabstractitemmodel.h>
-#include <QtCore/qpointer.h>
-#include <QtGui/qicon.h>
-#include <private/qlistview_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QUndoModel : public QAbstractItemModel
-{
- Q_OBJECT
-public:
- QUndoModel(QObject *parent = 0);
-
- QUndoStack *stack() const;
-
- virtual QModelIndex index(int row, int column,
- const QModelIndex &parent = QModelIndex()) const;
- virtual QModelIndex parent(const QModelIndex &child) const;
- virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
- virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
- virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
-
- QModelIndex selectedIndex() const;
- QItemSelectionModel *selectionModel() const;
-
- QString emptyLabel() const;
- void setEmptyLabel(const QString &label);
-
- void setCleanIcon(const QIcon &icon);
- QIcon cleanIcon() const;
-
-public slots:
- void setStack(QUndoStack *stack);
-
-private slots:
- void stackChanged();
- void stackDestroyed(QObject *obj);
- void setStackCurrentIndex(const QModelIndex &index);
-
-private:
- QUndoStack *m_stack;
- QItemSelectionModel *m_sel_model;
- QString m_emty_label;
- QIcon m_clean_icon;
-};
-
-QUndoModel::QUndoModel(QObject *parent)
- : QAbstractItemModel(parent)
-{
- m_stack = 0;
- m_sel_model = new QItemSelectionModel(this, this);
- connect(m_sel_model, SIGNAL(currentChanged(QModelIndex,QModelIndex)),
- this, SLOT(setStackCurrentIndex(QModelIndex)));
- m_emty_label = tr("<empty>");
-}
-
-QItemSelectionModel *QUndoModel::selectionModel() const
-{
- return m_sel_model;
-}
-
-QUndoStack *QUndoModel::stack() const
-{
- return m_stack;
-}
-
-void QUndoModel::setStack(QUndoStack *stack)
-{
- if (m_stack == stack)
- return;
-
- if (m_stack != 0) {
- disconnect(m_stack, SIGNAL(cleanChanged(bool)), this, SLOT(stackChanged()));
- disconnect(m_stack, SIGNAL(indexChanged(int)), this, SLOT(stackChanged()));
- disconnect(m_stack, SIGNAL(destroyed(QObject*)), this, SLOT(stackDestroyed(QObject*)));
- }
- m_stack = stack;
- if (m_stack != 0) {
- connect(m_stack, SIGNAL(cleanChanged(bool)), this, SLOT(stackChanged()));
- connect(m_stack, SIGNAL(indexChanged(int)), this, SLOT(stackChanged()));
- connect(m_stack, SIGNAL(destroyed(QObject*)), this, SLOT(stackDestroyed(QObject*)));
- }
-
- stackChanged();
-}
-
-void QUndoModel::stackDestroyed(QObject *obj)
-{
- if (obj != m_stack)
- return;
- m_stack = 0;
-
- stackChanged();
-}
-
-void QUndoModel::stackChanged()
-{
- reset();
- m_sel_model->setCurrentIndex(selectedIndex(), QItemSelectionModel::ClearAndSelect);
-}
-
-void QUndoModel::setStackCurrentIndex(const QModelIndex &index)
-{
- if (m_stack == 0)
- return;
-
- if (index == selectedIndex())
- return;
-
- if (index.column() != 0)
- return;
-
- m_stack->setIndex(index.row());
-}
-
-QModelIndex QUndoModel::selectedIndex() const
-{
- return m_stack == 0 ? QModelIndex() : createIndex(m_stack->index(), 0);
-}
-
-QModelIndex QUndoModel::index(int row, int column, const QModelIndex &parent) const
-{
- if (m_stack == 0)
- return QModelIndex();
-
- if (parent.isValid())
- return QModelIndex();
-
- if (column != 0)
- return QModelIndex();
-
- if (row < 0 || row > m_stack->count())
- return QModelIndex();
-
- return createIndex(row, column);
-}
-
-QModelIndex QUndoModel::parent(const QModelIndex&) const
-{
- return QModelIndex();
-}
-
-int QUndoModel::rowCount(const QModelIndex &parent) const
-{
- if (m_stack == 0)
- return 0;
-
- if (parent.isValid())
- return 0;
-
- return m_stack->count() + 1;
-}
-
-int QUndoModel::columnCount(const QModelIndex&) const
-{
- return 1;
-}
-
-QVariant QUndoModel::data(const QModelIndex &index, int role) const
-{
- if (m_stack == 0)
- return QVariant();
-
- if (index.column() != 0)
- return QVariant();
-
- if (index.row() < 0 || index.row() > m_stack->count())
- return QVariant();
-
- if (role == Qt::DisplayRole) {
- if (index.row() == 0)
- return m_emty_label;
- return m_stack->text(index.row() - 1);
- } else if (role == Qt::DecorationRole) {
- if (index.row() == m_stack->cleanIndex() && !m_clean_icon.isNull())
- return m_clean_icon;
- return QVariant();
- }
-
- return QVariant();
-}
-
-QString QUndoModel::emptyLabel() const
-{
- return m_emty_label;
-}
-
-void QUndoModel::setEmptyLabel(const QString &label)
-{
- m_emty_label = label;
- stackChanged();
-}
-
-void QUndoModel::setCleanIcon(const QIcon &icon)
-{
- m_clean_icon = icon;
- stackChanged();
-}
-
-QIcon QUndoModel::cleanIcon() const
-{
- return m_clean_icon;
-}
-
-/*!
- \class QUndoView
- \brief The QUndoView class displays the contents of a QUndoStack.
- \since 4.2
-
- \ingroup advanced
-
- QUndoView is a QListView which displays the list of commands pushed on an undo stack.
- The most recently executed command is always selected. Selecting a different command
- results in a call to QUndoStack::setIndex(), rolling the state of the document
- backwards or forward to the new command.
-
- The stack can be set explicitly with setStack(). Alternatively, a QUndoGroup object can
- be set with setGroup(). The view will then update itself automatically whenever the
- active stack of the group changes.
-
- \image qundoview.png
-*/
-
-class QUndoViewPrivate : public QListViewPrivate
-{
- Q_DECLARE_PUBLIC(QUndoView)
-public:
- QUndoViewPrivate() :
-#ifndef QT_NO_UNDOGROUP
- group(0),
-#endif
- model(0) {}
-
-#ifndef QT_NO_UNDOGROUP
- QPointer<QUndoGroup> group;
-#endif
- QUndoModel *model;
-
- void init();
-};
-
-void QUndoViewPrivate::init()
-{
- Q_Q(QUndoView);
-
- model = new QUndoModel(q);
- q->setModel(model);
- q->setSelectionModel(model->selectionModel());
-}
-
-/*!
- Constructs a new view with parent \a parent.
-*/
-
-QUndoView::QUndoView(QWidget *parent)
- : QListView(*new QUndoViewPrivate(), parent)
-{
- Q_D(QUndoView);
- d->init();
-}
-
-/*!
- Constructs a new view with parent \a parent and sets the observed stack to \a stack.
-*/
-
-QUndoView::QUndoView(QUndoStack *stack, QWidget *parent)
- : QListView(*new QUndoViewPrivate(), parent)
-{
- Q_D(QUndoView);
- d->init();
- setStack(stack);
-}
-
-#ifndef QT_NO_UNDOGROUP
-
-/*!
- Constructs a new view with parent \a parent and sets the observed group to \a group.
-
- The view will update itself autmiatically whenever the active stack of the group changes.
-*/
-
-QUndoView::QUndoView(QUndoGroup *group, QWidget *parent)
- : QListView(*new QUndoViewPrivate(), parent)
-{
- Q_D(QUndoView);
- d->init();
- setGroup(group);
-}
-
-#endif // QT_NO_UNDOGROUP
-
-/*!
- Destroys this view.
-*/
-
-QUndoView::~QUndoView()
-{
-}
-
-/*!
- Returns the stack currently displayed by this view. If the view is looking at a
- QUndoGroup, this the group's active stack.
-
- \sa setStack() setGroup()
-*/
-
-QUndoStack *QUndoView::stack() const
-{
- Q_D(const QUndoView);
- return d->model->stack();
-}
-
-/*!
- Sets the stack displayed by this view to \a stack. If \a stack is 0, the view
- will be empty.
-
- If the view was previously looking at a QUndoGroup, the group is set to 0.
-
- \sa stack() setGroup()
-*/
-
-void QUndoView::setStack(QUndoStack *stack)
-{
- Q_D(QUndoView);
-#ifndef QT_NO_UNDOGROUP
- setGroup(0);
-#endif
- d->model->setStack(stack);
-}
-
-#ifndef QT_NO_UNDOGROUP
-
-/*!
- Sets the group displayed by this view to \a group. If \a group is 0, the view will
- be empty.
-
- The view will update itself autmiatically whenever the active stack of the group changes.
-
- \sa group() setStack()
-*/
-
-void QUndoView::setGroup(QUndoGroup *group)
-{
- Q_D(QUndoView);
-
- if (d->group == group)
- return;
-
- if (d->group != 0) {
- disconnect(d->group, SIGNAL(activeStackChanged(QUndoStack*)),
- d->model, SLOT(setStack(QUndoStack*)));
- }
-
- d->group = group;
-
- if (d->group != 0) {
- connect(d->group, SIGNAL(activeStackChanged(QUndoStack*)),
- d->model, SLOT(setStack(QUndoStack*)));
- d->model->setStack(d->group->activeStack());
- } else {
- d->model->setStack(0);
- }
-}
-
-/*!
- Returns the group displayed by this view.
-
- If the view is not looking at group, this function returns 0.
-
- \sa setGroup() setStack()
-*/
-
-QUndoGroup *QUndoView::group() const
-{
- Q_D(const QUndoView);
- return d->group;
-}
-
-#endif // QT_NO_UNDOGROUP
-
-/*!
- \property QUndoView::emptyLabel
- \brief the label used for the empty state.
-
- The empty label is the topmost element in the list of commands, which represents
- the state of the document before any commands were pushed on the stack. The default
- is the string "<empty>".
-*/
-
-void QUndoView::setEmptyLabel(const QString &label)
-{
- Q_D(QUndoView);
- d->model->setEmptyLabel(label);
-}
-
-QString QUndoView::emptyLabel() const
-{
- Q_D(const QUndoView);
- return d->model->emptyLabel();
-}
-
-/*!
- \property QUndoView::cleanIcon
- \brief the icon used to represent the clean state.
-
- A stack may have a clean state set with QUndoStack::setClean(). This is usually
- the state of the document at the point it was saved. QUndoView can display an
- icon in the list of commands to show the clean state. If this property is
- a null icon, no icon is shown. The default value is the null icon.
-*/
-
-void QUndoView::setCleanIcon(const QIcon &icon)
-{
- Q_D(const QUndoView);
- d->model->setCleanIcon(icon);
-
-}
-
-QIcon QUndoView::cleanIcon() const
-{
- Q_D(const QUndoView);
- return d->model->cleanIcon();
-}
-
-QT_END_NAMESPACE
-
-#include "qundoview.moc"
-
-#endif // QT_NO_UNDOVIEW
diff --git a/src/gui/util/qundoview.h b/src/gui/util/qundoview.h
deleted file mode 100644
index de32a39c54..0000000000
--- a/src/gui/util/qundoview.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QUNDOVIEW_H
-#define QUNDOVIEW_H
-
-#include <QtGui/qlistview.h>
-#include <QtCore/qstring.h>
-
-#ifndef QT_NO_UNDOVIEW
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-class QUndoViewPrivate;
-class QUndoStack;
-class QUndoGroup;
-class QIcon;
-
-QT_MODULE(Gui)
-
-class Q_GUI_EXPORT QUndoView : public QListView
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QUndoView)
- Q_PROPERTY(QString emptyLabel READ emptyLabel WRITE setEmptyLabel)
- Q_PROPERTY(QIcon cleanIcon READ cleanIcon WRITE setCleanIcon)
-
-public:
- explicit QUndoView(QWidget *parent = 0);
- explicit QUndoView(QUndoStack *stack, QWidget *parent = 0);
-#ifndef QT_NO_UNDOGROUP
- explicit QUndoView(QUndoGroup *group, QWidget *parent = 0);
-#endif
- ~QUndoView();
-
- QUndoStack *stack() const;
-#ifndef QT_NO_UNDOGROUP
- QUndoGroup *group() const;
-#endif
-
- void setEmptyLabel(const QString &label);
- QString emptyLabel() const;
-
- void setCleanIcon(const QIcon &icon);
- QIcon cleanIcon() const;
-
-public Q_SLOTS:
- void setStack(QUndoStack *stack);
-#ifndef QT_NO_UNDOGROUP
- void setGroup(QUndoGroup *group);
-#endif
-
-private:
- Q_DISABLE_COPY(QUndoView)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_UNDOVIEW
-#endif // QUNDOVIEW_H
diff --git a/src/gui/util/util.pri b/src/gui/util/util.pri
deleted file mode 100644
index 2814a2d30a..0000000000
--- a/src/gui/util/util.pri
+++ /dev/null
@@ -1,71 +0,0 @@
-# Qt util module
-
-HEADERS += \
- util/qsystemtrayicon.h \
- util/qcompleter.h \
- util/qcompleter_p.h \
- util/qdesktopservices.h \
- util/qsystemtrayicon_p.h \
- util/qscroller.h \
- util/qscroller_p.h \
- util/qscrollerproperties.h \
- util/qscrollerproperties_p.h \
- util/qflickgesture_p.h \
- util/qundogroup.h \
- util/qundostack.h \
- util/qundostack_p.h \
- util/qundoview.h
-
-SOURCES += \
- util/qsystemtrayicon.cpp \
- util/qcompleter.cpp \
- util/qdesktopservices.cpp \
- util/qscroller.cpp \
- util/qscrollerproperties.cpp \
- util/qflickgesture.cpp \
- util/qundogroup.cpp \
- util/qundostack.cpp \
- util/qundoview.cpp
-
-
-wince* {
- SOURCES += \
- util/qsystemtrayicon_wince.cpp
-} else:win32 {
- SOURCES += \
- util/qsystemtrayicon_win.cpp
-}
-
-unix:x11 {
- SOURCES += \
- util/qsystemtrayicon_x11.cpp
-}
-
-embedded|qpa {
- SOURCES += \
- util/qsystemtrayicon_qws.cpp
-}
-
-!embedded:!qpa:!x11:mac {
- OBJECTIVE_SOURCES += util/qsystemtrayicon_mac.mm
-}
-
-symbian {
- LIBS += -letext -lplatformenv
- contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
- LIBS += -lsendas2 -lapmime
- contains(QT_CONFIG, s60) {
- contains(CONFIG, is_using_gnupoc) {
- LIBS += -lcommonui
- } else {
- LIBS += -lCommonUI
- }
- }
- } else {
- DEFINES += USE_SCHEMEHANDLER
- }
-}
-
-macx {
- OBJECTIVE_SOURCES += util/qscroller_mac.mm
-}
diff --git a/src/gui/widgets/qabstractbutton.h b/src/gui/widgets/qabstractbutton.h
deleted file mode 100644
index abdc11012c..0000000000
--- a/src/gui/widgets/qabstractbutton.h
+++ /dev/null
@@ -1,180 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QABSTRACTBUTTON_H
-#define QABSTRACTBUTTON_H
-
-#include <QtGui/qicon.h>
-#include <QtGui/qkeysequence.h>
-#include <QtGui/qwidget.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QButtonGroup;
-class QAbstractButtonPrivate;
-
-class Q_GUI_EXPORT QAbstractButton : public QWidget
-{
- Q_OBJECT
-
- Q_PROPERTY(QString text READ text WRITE setText)
- Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
- Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
-#ifndef QT_NO_SHORTCUT
- Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut)
-#endif
- Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable)
- Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled USER true)
- Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat)
- Q_PROPERTY(bool autoExclusive READ autoExclusive WRITE setAutoExclusive)
- Q_PROPERTY(int autoRepeatDelay READ autoRepeatDelay WRITE setAutoRepeatDelay)
- Q_PROPERTY(int autoRepeatInterval READ autoRepeatInterval WRITE setAutoRepeatInterval)
- Q_PROPERTY(bool down READ isDown WRITE setDown DESIGNABLE false)
-
-public:
- explicit QAbstractButton(QWidget* parent=0);
- ~QAbstractButton();
-
- void setText(const QString &text);
- QString text() const;
-
- void setIcon(const QIcon &icon);
- QIcon icon() const;
-
- QSize iconSize() const;
-
-#ifndef QT_NO_SHORTCUT
- void setShortcut(const QKeySequence &key);
- QKeySequence shortcut() const;
-#endif
-
- void setCheckable(bool);
- bool isCheckable() const;
-
- bool isChecked() const;
-
- void setDown(bool);
- bool isDown() const;
-
- void setAutoRepeat(bool);
- bool autoRepeat() const;
-
- void setAutoRepeatDelay(int);
- int autoRepeatDelay() const;
-
- void setAutoRepeatInterval(int);
- int autoRepeatInterval() const;
-
- void setAutoExclusive(bool);
- bool autoExclusive() const;
-
-#ifndef QT_NO_BUTTONGROUP
- QButtonGroup *group() const;
-#endif
-
-public Q_SLOTS:
- void setIconSize(const QSize &size);
- void animateClick(int msec = 100);
- void click();
- void toggle();
- void setChecked(bool);
-
-Q_SIGNALS:
- void pressed();
- void released();
- void clicked(bool checked = false);
- void toggled(bool checked);
-
-protected:
- virtual void paintEvent(QPaintEvent *e) = 0;
- virtual bool hitButton(const QPoint &pos) const;
- virtual void checkStateSet();
- virtual void nextCheckState();
-
- bool event(QEvent *e);
- void keyPressEvent(QKeyEvent *e);
- void keyReleaseEvent(QKeyEvent *e);
- void mousePressEvent(QMouseEvent *e);
- void mouseReleaseEvent(QMouseEvent *e);
- void mouseMoveEvent(QMouseEvent *e);
- void focusInEvent(QFocusEvent *e);
- void focusOutEvent(QFocusEvent *e);
- void changeEvent(QEvent *e);
- void timerEvent(QTimerEvent *e);
-
-#ifdef QT3_SUPPORT
-public:
- QT3_SUPPORT_CONSTRUCTOR QAbstractButton(QWidget *parent, const char *name, Qt::WindowFlags f=0);
- inline QT3_SUPPORT bool isOn() const { return isChecked(); }
- inline QT3_SUPPORT const QPixmap *pixmap() const { return 0; } // help styles compile
- inline QT3_SUPPORT void setPixmap( const QPixmap &p ) {
- setIcon(QIcon(p));
- setIconSize(p.size());
- }
- QT3_SUPPORT QIcon *iconSet() const;
- inline QT3_SUPPORT void setIconSet(const QIcon &icon) { setIcon(icon); }
- inline QT3_SUPPORT bool isToggleButton() const { return isCheckable(); }
- inline QT3_SUPPORT void setToggleButton(bool b) { setCheckable(b); }
- inline QT3_SUPPORT void setAccel(const QKeySequence &key) { setShortcut(key); }
- inline QT3_SUPPORT QKeySequence accel() const { return shortcut(); }
-
-public Q_SLOTS:
- inline QT_MOC_COMPAT void setOn(bool b) { setChecked(b); }
-#endif
-
-protected:
- QAbstractButton(QAbstractButtonPrivate &dd, QWidget* parent = 0);
-
-private:
- Q_DECLARE_PRIVATE(QAbstractButton)
- Q_DISABLE_COPY(QAbstractButton)
- friend class QButtonGroup;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QABSTRACTBUTTON_H
diff --git a/src/gui/widgets/qabstractscrollarea.h b/src/gui/widgets/qabstractscrollarea.h
deleted file mode 100644
index 34b7837284..0000000000
--- a/src/gui/widgets/qabstractscrollarea.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QABSTRACTSCROLLAREA_H
-#define QABSTRACTSCROLLAREA_H
-
-#include <QtGui/qframe.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_SCROLLAREA
-
-class QMargins;
-class QScrollBar;
-class QAbstractScrollAreaPrivate;
-
-class Q_GUI_EXPORT QAbstractScrollArea : public QFrame
-{
- Q_OBJECT
- Q_PROPERTY(Qt::ScrollBarPolicy verticalScrollBarPolicy READ verticalScrollBarPolicy WRITE setVerticalScrollBarPolicy)
- Q_PROPERTY(Qt::ScrollBarPolicy horizontalScrollBarPolicy READ horizontalScrollBarPolicy WRITE setHorizontalScrollBarPolicy)
-
-public:
- explicit QAbstractScrollArea(QWidget* parent=0);
- ~QAbstractScrollArea();
-
- Qt::ScrollBarPolicy verticalScrollBarPolicy() const;
- void setVerticalScrollBarPolicy(Qt::ScrollBarPolicy);
- QScrollBar *verticalScrollBar() const;
- void setVerticalScrollBar(QScrollBar *scrollbar);
-
- Qt::ScrollBarPolicy horizontalScrollBarPolicy() const;
- void setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy);
- QScrollBar *horizontalScrollBar() const;
- void setHorizontalScrollBar(QScrollBar *scrollbar);
-
- QWidget *cornerWidget() const;
- void setCornerWidget(QWidget *widget);
-
- void addScrollBarWidget(QWidget *widget, Qt::Alignment alignment);
- QWidgetList scrollBarWidgets(Qt::Alignment alignment);
-
- QWidget *viewport() const;
- void setViewport(QWidget *widget);
- QSize maximumViewportSize() const;
-
- QSize minimumSizeHint() const;
-
- QSize sizeHint() const;
-
-protected Q_SLOTS:
- void setupViewport(QWidget *viewport);
-
-protected:
- QAbstractScrollArea(QAbstractScrollAreaPrivate &dd, QWidget *parent = 0);
- void setViewportMargins(int left, int top, int right, int bottom);
- void setViewportMargins(const QMargins &margins);
-
- bool event(QEvent *);
- virtual bool viewportEvent(QEvent *);
-
- void resizeEvent(QResizeEvent *);
- void paintEvent(QPaintEvent *);
- void mousePressEvent(QMouseEvent *);
- void mouseReleaseEvent(QMouseEvent *);
- void mouseDoubleClickEvent(QMouseEvent *);
- void mouseMoveEvent(QMouseEvent *);
-#ifndef QT_NO_WHEELEVENT
- void wheelEvent(QWheelEvent *);
-#endif
-#ifndef QT_NO_CONTEXTMENU
- void contextMenuEvent(QContextMenuEvent *);
-#endif
-#ifndef QT_NO_DRAGANDDROP
- void dragEnterEvent(QDragEnterEvent *);
- void dragMoveEvent(QDragMoveEvent *);
- void dragLeaveEvent(QDragLeaveEvent *);
- void dropEvent(QDropEvent *);
-#endif
-
- void keyPressEvent(QKeyEvent *);
-
- virtual void scrollContentsBy(int dx, int dy);
-
-private:
- Q_DECLARE_PRIVATE(QAbstractScrollArea)
- Q_DISABLE_COPY(QAbstractScrollArea)
- Q_PRIVATE_SLOT(d_func(), void _q_hslide(int))
- Q_PRIVATE_SLOT(d_func(), void _q_vslide(int))
- Q_PRIVATE_SLOT(d_func(), void _q_showOrHideScrollBars())
-
- friend class QStyleSheetStyle;
- friend class QWidgetPrivate;
-};
-
-#endif // QT_NO_SCROLLAREA
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QABSTRACTSCROLLAREA_H
diff --git a/src/gui/widgets/qabstractslider.h b/src/gui/widgets/qabstractslider.h
deleted file mode 100644
index bdcfe0ecc9..0000000000
--- a/src/gui/widgets/qabstractslider.h
+++ /dev/null
@@ -1,184 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QABSTRACTSLIDER_H
-#define QABSTRACTSLIDER_H
-
-#include <QtGui/qwidget.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QAbstractSliderPrivate;
-
-class Q_GUI_EXPORT QAbstractSlider : public QWidget
-{
- Q_OBJECT
-
- Q_PROPERTY(int minimum READ minimum WRITE setMinimum)
- Q_PROPERTY(int maximum READ maximum WRITE setMaximum)
- Q_PROPERTY(int singleStep READ singleStep WRITE setSingleStep)
- Q_PROPERTY(int pageStep READ pageStep WRITE setPageStep)
- Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged USER true)
- Q_PROPERTY(int sliderPosition READ sliderPosition WRITE setSliderPosition NOTIFY sliderMoved)
- Q_PROPERTY(bool tracking READ hasTracking WRITE setTracking)
- Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
- Q_PROPERTY(bool invertedAppearance READ invertedAppearance WRITE setInvertedAppearance)
- Q_PROPERTY(bool invertedControls READ invertedControls WRITE setInvertedControls)
- Q_PROPERTY(bool sliderDown READ isSliderDown WRITE setSliderDown DESIGNABLE false)
-
-public:
- explicit QAbstractSlider(QWidget *parent=0);
- ~QAbstractSlider();
-
- Qt::Orientation orientation() const;
-
- void setMinimum(int);
- int minimum() const;
-
- void setMaximum(int);
- int maximum() const;
-
- void setRange(int min, int max);
-
- void setSingleStep(int);
- int singleStep() const;
-
- void setPageStep(int);
- int pageStep() const;
-
- void setTracking(bool enable);
- bool hasTracking() const;
-
- void setSliderDown(bool);
- bool isSliderDown() const;
-
- void setSliderPosition(int);
- int sliderPosition() const;
-
- void setInvertedAppearance(bool);
- bool invertedAppearance() const;
-
- void setInvertedControls(bool);
- bool invertedControls() const;
-
- enum SliderAction {
- SliderNoAction,
- SliderSingleStepAdd,
- SliderSingleStepSub,
- SliderPageStepAdd,
- SliderPageStepSub,
- SliderToMinimum,
- SliderToMaximum,
- SliderMove
- };
-
- int value() const;
-
- void triggerAction(SliderAction action);
-
-public Q_SLOTS:
- void setValue(int);
- void setOrientation(Qt::Orientation);
-
-Q_SIGNALS:
- void valueChanged(int value);
-
- void sliderPressed();
- void sliderMoved(int position);
- void sliderReleased();
-
- void rangeChanged(int min, int max);
-
- void actionTriggered(int action);
-
-protected:
- bool event(QEvent *e);
-
- void setRepeatAction(SliderAction action, int thresholdTime = 500, int repeatTime = 50);
- SliderAction repeatAction() const;
-
- enum SliderChange {
- SliderRangeChange,
- SliderOrientationChange,
- SliderStepsChange,
- SliderValueChange
- };
- virtual void sliderChange(SliderChange change);
-
- void keyPressEvent(QKeyEvent *ev);
- void timerEvent(QTimerEvent *);
-#ifndef QT_NO_WHEELEVENT
- void wheelEvent(QWheelEvent *e);
-#endif
- void changeEvent(QEvent *e);
-
-#ifdef QT3_SUPPORT
-public:
- inline QT3_SUPPORT int minValue() const { return minimum(); }
- inline QT3_SUPPORT int maxValue() const { return maximum(); }
- inline QT3_SUPPORT int lineStep() const { return singleStep(); }
- inline QT3_SUPPORT void setMinValue(int v) { setMinimum(v); }
- inline QT3_SUPPORT void setMaxValue(int v) { setMaximum(v); }
- inline QT3_SUPPORT void setLineStep(int v) { setSingleStep(v); }
- inline QT3_SUPPORT void setSteps(int single, int page) { setSingleStep(single); setPageStep(page); }
- inline QT3_SUPPORT void addPage() { triggerAction(SliderPageStepAdd); }
- inline QT3_SUPPORT void subtractPage() { triggerAction(SliderPageStepSub); }
- inline QT3_SUPPORT void addLine() { triggerAction(SliderSingleStepAdd); }
- inline QT3_SUPPORT void subtractLine() { triggerAction(SliderSingleStepSub); }
-#endif
-
-protected:
- QAbstractSlider(QAbstractSliderPrivate &dd, QWidget *parent=0);
-
-private:
- Q_DISABLE_COPY(QAbstractSlider)
- Q_DECLARE_PRIVATE(QAbstractSlider)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QABSTRACTSLIDER_H
diff --git a/src/gui/widgets/qabstractspinbox.h b/src/gui/widgets/qabstractspinbox.h
deleted file mode 100644
index bb1307cca5..0000000000
--- a/src/gui/widgets/qabstractspinbox.h
+++ /dev/null
@@ -1,181 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QABSTRACTSPINBOX_H
-#define QABSTRACTSPINBOX_H
-
-#include <QtGui/qwidget.h>
-#include <QtGui/qvalidator.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_SPINBOX
-
-class QLineEdit;
-
-class QAbstractSpinBoxPrivate;
-class QStyleOptionSpinBox;
-
-class Q_GUI_EXPORT QAbstractSpinBox : public QWidget
-{
- Q_OBJECT
-
- Q_ENUMS(ButtonSymbols)
- Q_ENUMS(CorrectionMode)
- Q_PROPERTY(bool wrapping READ wrapping WRITE setWrapping)
- Q_PROPERTY(bool frame READ hasFrame WRITE setFrame)
- Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
- Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
- Q_PROPERTY(ButtonSymbols buttonSymbols READ buttonSymbols WRITE setButtonSymbols)
- Q_PROPERTY(QString specialValueText READ specialValueText WRITE setSpecialValueText)
- Q_PROPERTY(QString text READ text)
- Q_PROPERTY(bool accelerated READ isAccelerated WRITE setAccelerated)
- Q_PROPERTY(CorrectionMode correctionMode READ correctionMode WRITE setCorrectionMode)
- Q_PROPERTY(bool acceptableInput READ hasAcceptableInput)
- Q_PROPERTY(bool keyboardTracking READ keyboardTracking WRITE setKeyboardTracking)
-public:
- explicit QAbstractSpinBox(QWidget *parent = 0);
- ~QAbstractSpinBox();
-
- enum StepEnabledFlag { StepNone = 0x00, StepUpEnabled = 0x01,
- StepDownEnabled = 0x02 };
- Q_DECLARE_FLAGS(StepEnabled, StepEnabledFlag)
-
- enum ButtonSymbols { UpDownArrows, PlusMinus, NoButtons };
-
- ButtonSymbols buttonSymbols() const;
- void setButtonSymbols(ButtonSymbols bs);
-
- enum CorrectionMode { CorrectToPreviousValue, CorrectToNearestValue };
-
- void setCorrectionMode(CorrectionMode cm);
- CorrectionMode correctionMode() const;
-
- bool hasAcceptableInput() const;
- QString text() const;
-
- QString specialValueText() const;
- void setSpecialValueText(const QString &txt);
-
- bool wrapping() const;
- void setWrapping(bool w);
-
- void setReadOnly(bool r);
- bool isReadOnly() const;
-
- void setKeyboardTracking(bool kt);
- bool keyboardTracking() const;
-
- void setAlignment(Qt::Alignment flag);
- Qt::Alignment alignment() const;
-
- void setFrame(bool);
- bool hasFrame() const;
-
- void setAccelerated(bool on);
- bool isAccelerated() const;
-
- QSize sizeHint() const;
- QSize minimumSizeHint() const;
- void interpretText();
- bool event(QEvent *event);
-
- QVariant inputMethodQuery(Qt::InputMethodQuery) const;
-
- virtual QValidator::State validate(QString &input, int &pos) const;
- virtual void fixup(QString &input) const;
-
- virtual void stepBy(int steps);
-public Q_SLOTS:
- void stepUp();
- void stepDown();
- void selectAll();
- virtual void clear();
-protected:
- void resizeEvent(QResizeEvent *event);
- void keyPressEvent(QKeyEvent *event);
- void keyReleaseEvent(QKeyEvent *event);
-#ifndef QT_NO_WHEELEVENT
- void wheelEvent(QWheelEvent *event);
-#endif
- void focusInEvent(QFocusEvent *event);
- void focusOutEvent(QFocusEvent *event);
- void contextMenuEvent(QContextMenuEvent *event);
- void changeEvent(QEvent *event);
- void closeEvent(QCloseEvent *event);
- void hideEvent(QHideEvent *event);
- void mousePressEvent(QMouseEvent *event);
- void mouseReleaseEvent(QMouseEvent *event);
- void mouseMoveEvent(QMouseEvent *event);
- void timerEvent(QTimerEvent *event);
- void paintEvent(QPaintEvent *event);
- void showEvent(QShowEvent *event);
- void initStyleOption(QStyleOptionSpinBox *option) const;
-
- QLineEdit *lineEdit() const;
- void setLineEdit(QLineEdit *edit);
-
- virtual StepEnabled stepEnabled() const;
-Q_SIGNALS:
- void editingFinished();
-protected:
- QAbstractSpinBox(QAbstractSpinBoxPrivate &dd, QWidget *parent = 0);
-
-private:
- Q_PRIVATE_SLOT(d_func(), void _q_editorTextChanged(const QString &))
- Q_PRIVATE_SLOT(d_func(), void _q_editorCursorPositionChanged(int, int))
-
- Q_DECLARE_PRIVATE(QAbstractSpinBox)
- Q_DISABLE_COPY(QAbstractSpinBox)
-};
-Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractSpinBox::StepEnabled)
-
-#endif // QT_NO_SPINBOX
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QABSTRACTSPINBOX_H
diff --git a/src/gui/widgets/qabstractspinbox_p.h b/src/gui/widgets/qabstractspinbox_p.h
deleted file mode 100644
index 38270c4e95..0000000000
--- a/src/gui/widgets/qabstractspinbox_p.h
+++ /dev/null
@@ -1,170 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QABSTRACTSPINBOX_P_H
-#define QABSTRACTSPINBOX_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "QtGui/qabstractspinbox.h"
-
-#ifndef QT_NO_SPINBOX
-
-#include "QtGui/qlineedit.h"
-#include "QtGui/qstyleoption.h"
-#include "QtGui/qvalidator.h"
-#include "QtCore/qdatetime.h"
-#include "QtCore/qvariant.h"
-#include "private/qwidget_p.h"
-#include "private/qdatetime_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QVariant operator+(const QVariant &arg1, const QVariant &arg2);
-QVariant operator-(const QVariant &arg1, const QVariant &arg2);
-QVariant operator*(const QVariant &arg1, double multiplier);
-double operator/(const QVariant &arg1, const QVariant &arg2);
-
-enum EmitPolicy {
- EmitIfChanged,
- AlwaysEmit,
- NeverEmit
-};
-
-enum Button {
- None = 0x000,
- Keyboard = 0x001,
- Mouse = 0x002,
- Wheel = 0x004,
- ButtonMask = 0x008,
- Up = 0x010,
- Down = 0x020,
- DirectionMask = 0x040
-};
-class QSpinBoxValidator;
-class QAbstractSpinBoxPrivate : public QWidgetPrivate
-{
- Q_DECLARE_PUBLIC(QAbstractSpinBox)
-public:
- QAbstractSpinBoxPrivate();
- ~QAbstractSpinBoxPrivate();
-
- void init();
- void reset();
- void updateState(bool up, bool fromKeyboard = false);
- QString stripped(const QString &text, int *pos = 0) const;
- bool specialValue() const;
- virtual QVariant getZeroVariant() const;
- virtual void setRange(const QVariant &min, const QVariant &max);
- void setValue(const QVariant &val, EmitPolicy ep, bool updateEdit = true);
- virtual QVariant bound(const QVariant &val, const QVariant &old = QVariant(), int steps = 0) const;
- virtual void updateEdit();
-
- virtual void emitSignals(EmitPolicy ep, const QVariant &old);
- virtual void interpret(EmitPolicy ep);
- virtual QString textFromValue(const QVariant &n) const;
- virtual QVariant valueFromText(const QString &input) const;
-
- void _q_editorTextChanged(const QString &);
- virtual void _q_editorCursorPositionChanged(int oldpos, int newpos);
-
- virtual QStyle::SubControl newHoverControl(const QPoint &pos);
- bool updateHoverControl(const QPoint &pos);
-
- virtual void clearCache() const;
- virtual void updateEditFieldGeometry();
-
- static int variantCompare(const QVariant &arg1, const QVariant &arg2);
- static QVariant variantBound(const QVariant &min, const QVariant &value, const QVariant &max);
-
- QLineEdit *edit;
- QString prefix, suffix, specialValueText;
- QVariant value, minimum, maximum, singleStep;
- QVariant::Type type;
- int spinClickTimerId, spinClickTimerInterval, spinClickThresholdTimerId, spinClickThresholdTimerInterval;
- int effectiveSpinRepeatRate;
- uint buttonState;
- mutable QString cachedText;
- mutable QVariant cachedValue;
- mutable QValidator::State cachedState;
- mutable QSize cachedSizeHint, cachedMinimumSizeHint;
- uint pendingEmit : 1;
- uint readOnly : 1;
- uint wrapping : 1;
- uint ignoreCursorPositionChanged : 1;
- uint frame : 1;
- uint accelerate : 1;
- uint keyboardTracking : 1;
- uint cleared : 1;
- uint ignoreUpdateEdit : 1;
- QAbstractSpinBox::CorrectionMode correctionMode;
- int acceleration;
- QStyle::SubControl hoverControl;
- QRect hoverRect;
- QAbstractSpinBox::ButtonSymbols buttonSymbols;
- QSpinBoxValidator *validator;
-};
-
-class QSpinBoxValidator : public QValidator
-{
-public:
- QSpinBoxValidator(QAbstractSpinBox *qptr, QAbstractSpinBoxPrivate *dptr);
- QValidator::State validate(QString &input, int &) const;
- void fixup(QString &) const;
-private:
- QAbstractSpinBox *qptr;
- QAbstractSpinBoxPrivate *dptr;
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_SPINBOX
-
-#endif // QABSTRACTSPINBOX_P_H
diff --git a/src/gui/widgets/qcalendarwidget.h b/src/gui/widgets/qcalendarwidget.h
deleted file mode 100644
index 08d2ca0a21..0000000000
--- a/src/gui/widgets/qcalendarwidget.h
+++ /dev/null
@@ -1,204 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QCALENDARWIDGET_H
-#define QCALENDARWIDGET_H
-
-#include <QtGui/qwidget.h>
-#include <QtCore/qdatetime.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_CALENDARWIDGET
-
-class QDate;
-class QTextCharFormat;
-class QCalendarWidgetPrivate;
-
-class Q_GUI_EXPORT QCalendarWidget : public QWidget
-{
- Q_OBJECT
- Q_ENUMS(Qt::DayOfWeek)
- Q_ENUMS(HorizontalHeaderFormat)
- Q_ENUMS(VerticalHeaderFormat)
- Q_ENUMS(SelectionMode)
- Q_PROPERTY(QDate selectedDate READ selectedDate WRITE setSelectedDate)
- Q_PROPERTY(QDate minimumDate READ minimumDate WRITE setMinimumDate)
- Q_PROPERTY(QDate maximumDate READ maximumDate WRITE setMaximumDate)
- Q_PROPERTY(Qt::DayOfWeek firstDayOfWeek READ firstDayOfWeek WRITE setFirstDayOfWeek)
- Q_PROPERTY(bool gridVisible READ isGridVisible WRITE setGridVisible)
- Q_PROPERTY(SelectionMode selectionMode READ selectionMode WRITE setSelectionMode)
- Q_PROPERTY(HorizontalHeaderFormat horizontalHeaderFormat READ horizontalHeaderFormat WRITE setHorizontalHeaderFormat)
- Q_PROPERTY(VerticalHeaderFormat verticalHeaderFormat READ verticalHeaderFormat WRITE setVerticalHeaderFormat)
- Q_PROPERTY(bool headerVisible READ isHeaderVisible WRITE setHeaderVisible STORED false DESIGNABLE false) // obsolete
- Q_PROPERTY(bool navigationBarVisible READ isNavigationBarVisible WRITE setNavigationBarVisible)
- Q_PROPERTY(bool dateEditEnabled READ isDateEditEnabled WRITE setDateEditEnabled)
- Q_PROPERTY(int dateEditAcceptDelay READ dateEditAcceptDelay WRITE setDateEditAcceptDelay)
-
-public:
- enum HorizontalHeaderFormat {
- NoHorizontalHeader,
- SingleLetterDayNames,
- ShortDayNames,
- LongDayNames
- };
-
- enum VerticalHeaderFormat {
- NoVerticalHeader,
- ISOWeekNumbers
- };
-
- enum SelectionMode {
- NoSelection,
- SingleSelection
- };
-
- explicit QCalendarWidget(QWidget *parent = 0);
- ~QCalendarWidget();
-
- virtual QSize sizeHint() const;
- virtual QSize minimumSizeHint() const;
-
- QDate selectedDate() const;
-
- int yearShown() const;
- int monthShown() const;
-
- QDate minimumDate() const;
- void setMinimumDate(const QDate &date);
-
- QDate maximumDate() const;
- void setMaximumDate(const QDate &date);
-
- Qt::DayOfWeek firstDayOfWeek() const;
- void setFirstDayOfWeek(Qt::DayOfWeek dayOfWeek);
-
- // ### Qt 5: eliminate these two
- bool isHeaderVisible() const;
- void setHeaderVisible(bool show);
-
- inline bool isNavigationBarVisible() const { return isHeaderVisible(); }
-
- bool isGridVisible() const;
-
- SelectionMode selectionMode() const;
- void setSelectionMode(SelectionMode mode);
-
- HorizontalHeaderFormat horizontalHeaderFormat() const;
- void setHorizontalHeaderFormat(HorizontalHeaderFormat format);
-
- VerticalHeaderFormat verticalHeaderFormat() const;
- void setVerticalHeaderFormat(VerticalHeaderFormat format);
-
- QTextCharFormat headerTextFormat() const;
- void setHeaderTextFormat(const QTextCharFormat &format);
-
- QTextCharFormat weekdayTextFormat(Qt::DayOfWeek dayOfWeek) const;
- void setWeekdayTextFormat(Qt::DayOfWeek dayOfWeek, const QTextCharFormat &format);
-
- QMap<QDate, QTextCharFormat> dateTextFormat() const;
- QTextCharFormat dateTextFormat(const QDate &date) const;
- void setDateTextFormat(const QDate &date, const QTextCharFormat &format);
-
- bool isDateEditEnabled() const;
- void setDateEditEnabled(bool enable);
-
- int dateEditAcceptDelay() const;
- void setDateEditAcceptDelay(int delay);
-
-protected:
- bool event(QEvent *event);
- bool eventFilter(QObject *watched, QEvent *event);
- void mousePressEvent(QMouseEvent *event);
- void resizeEvent(QResizeEvent * event);
- void keyPressEvent(QKeyEvent * event);
-
- virtual void paintCell(QPainter *painter, const QRect &rect, const QDate &date) const;
- void updateCell(const QDate &date);
- void updateCells();
-
-public Q_SLOTS:
- void setSelectedDate(const QDate &date);
- void setDateRange(const QDate &min, const QDate &max);
- void setCurrentPage(int year, int month);
- void setGridVisible(bool show);
- void setNavigationBarVisible(bool visible);
- void showNextMonth();
- void showPreviousMonth();
- void showNextYear();
- void showPreviousYear();
- void showSelectedDate();
- void showToday();
-
-Q_SIGNALS:
- void selectionChanged();
- void clicked(const QDate &date);
- void activated(const QDate &date);
- void currentPageChanged(int year, int month);
-
-private:
- Q_DECLARE_PRIVATE(QCalendarWidget)
- Q_DISABLE_COPY(QCalendarWidget)
-
- Q_PRIVATE_SLOT(d_func(), void _q_slotShowDate(const QDate &date))
- Q_PRIVATE_SLOT(d_func(), void _q_slotChangeDate(const QDate &date))
- Q_PRIVATE_SLOT(d_func(), void _q_slotChangeDate(const QDate &date, bool changeMonth))
- Q_PRIVATE_SLOT(d_func(), void _q_editingFinished())
- Q_PRIVATE_SLOT(d_func(), void _q_prevMonthClicked())
- Q_PRIVATE_SLOT(d_func(), void _q_nextMonthClicked())
- Q_PRIVATE_SLOT(d_func(), void _q_yearEditingFinished())
- Q_PRIVATE_SLOT(d_func(), void _q_yearClicked())
- Q_PRIVATE_SLOT(d_func(), void _q_monthChanged(QAction *act))
-
-};
-
-#endif // QT_NO_CALENDARWIDGET
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QCALENDARWIDGET_H
-
diff --git a/src/gui/widgets/qcheckbox.h b/src/gui/widgets/qcheckbox.h
deleted file mode 100644
index ae2e93291f..0000000000
--- a/src/gui/widgets/qcheckbox.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QCHECKBOX_H
-#define QCHECKBOX_H
-
-#include <QtGui/qabstractbutton.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QCheckBoxPrivate;
-class QStyleOptionButton;
-
-class Q_GUI_EXPORT QCheckBox : public QAbstractButton
-{
- Q_OBJECT
-
- Q_PROPERTY(bool tristate READ isTristate WRITE setTristate)
-
-public:
- explicit QCheckBox(QWidget *parent=0);
- explicit QCheckBox(const QString &text, QWidget *parent=0);
-
-
- QSize sizeHint() const;
- QSize minimumSizeHint() const;
-
- void setTristate(bool y = true);
- bool isTristate() const;
-
- Qt::CheckState checkState() const;
- void setCheckState(Qt::CheckState state);
-
-Q_SIGNALS:
- void stateChanged(int);
-
-protected:
- bool event(QEvent *e);
- bool hitButton(const QPoint &pos) const;
- void checkStateSet();
- void nextCheckState();
- void paintEvent(QPaintEvent *);
- void mouseMoveEvent(QMouseEvent *);
- void initStyleOption(QStyleOptionButton *option) const;
-
-#ifdef QT3_SUPPORT
-public:
- enum ToggleState {
- Off = Qt::Unchecked,
- NoChange = Qt::PartiallyChecked,
- On = Qt::Checked
- };
- inline QT3_SUPPORT ToggleState state() const
- { return static_cast<QCheckBox::ToggleState>(static_cast<int>(checkState())); }
- inline QT3_SUPPORT void setState(ToggleState state)
- { setCheckState(static_cast<Qt::CheckState>(static_cast<int>(state))); }
- inline QT3_SUPPORT void setNoChange()
- { setCheckState(Qt::PartiallyChecked); }
- QT3_SUPPORT_CONSTRUCTOR QCheckBox(QWidget *parent, const char* name);
- QT3_SUPPORT_CONSTRUCTOR QCheckBox(const QString &text, QWidget *parent, const char* name);
-#endif
-
-private:
- Q_DECLARE_PRIVATE(QCheckBox)
- Q_DISABLE_COPY(QCheckBox)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QCHECKBOX_H
diff --git a/src/gui/widgets/qcombobox.h b/src/gui/widgets/qcombobox.h
deleted file mode 100644
index fd6f68af2d..0000000000
--- a/src/gui/widgets/qcombobox.h
+++ /dev/null
@@ -1,339 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QCOMBOBOX_H
-#define QCOMBOBOX_H
-
-#include <QtGui/qwidget.h>
-#include <QtGui/qabstractitemdelegate.h>
-#include <QtCore/qabstractitemmodel.h>
-#include <QtCore/qvariant.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-#ifndef QT_NO_COMBOBOX
-
-class QAbstractItemView;
-class QLineEdit;
-class QComboBoxPrivate;
-class QCompleter;
-
-class Q_GUI_EXPORT QComboBox : public QWidget
-{
- Q_OBJECT
-
- Q_ENUMS(InsertPolicy)
- Q_ENUMS(SizeAdjustPolicy)
- Q_PROPERTY(bool editable READ isEditable WRITE setEditable)
- Q_PROPERTY(int count READ count)
- Q_PROPERTY(QString currentText READ currentText)
- Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged USER true)
- Q_PROPERTY(int maxVisibleItems READ maxVisibleItems WRITE setMaxVisibleItems)
- Q_PROPERTY(int maxCount READ maxCount WRITE setMaxCount)
- Q_PROPERTY(InsertPolicy insertPolicy READ insertPolicy WRITE setInsertPolicy)
- Q_PROPERTY(SizeAdjustPolicy sizeAdjustPolicy READ sizeAdjustPolicy WRITE setSizeAdjustPolicy)
- Q_PROPERTY(int minimumContentsLength READ minimumContentsLength WRITE setMinimumContentsLength)
- Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
-
-#ifndef QT_NO_COMPLETER
- Q_PROPERTY(bool autoCompletion READ autoCompletion WRITE setAutoCompletion DESIGNABLE false)
- Q_PROPERTY(Qt::CaseSensitivity autoCompletionCaseSensitivity READ autoCompletionCaseSensitivity WRITE setAutoCompletionCaseSensitivity DESIGNABLE false)
-#endif // QT_NO_COMPLETER
-
- Q_PROPERTY(bool duplicatesEnabled READ duplicatesEnabled WRITE setDuplicatesEnabled)
- Q_PROPERTY(bool frame READ hasFrame WRITE setFrame)
- Q_PROPERTY(int modelColumn READ modelColumn WRITE setModelColumn)
-
-public:
- explicit QComboBox(QWidget *parent = 0);
- ~QComboBox();
-
- int maxVisibleItems() const;
- void setMaxVisibleItems(int maxItems);
-
- int count() const;
- void setMaxCount(int max);
- int maxCount() const;
-
-#ifndef QT_NO_COMPLETER
- bool autoCompletion() const;
- void setAutoCompletion(bool enable);
-
- Qt::CaseSensitivity autoCompletionCaseSensitivity() const;
- void setAutoCompletionCaseSensitivity(Qt::CaseSensitivity sensitivity);
-#endif
-
- bool duplicatesEnabled() const;
- void setDuplicatesEnabled(bool enable);
-
- void setFrame(bool);
- bool hasFrame() const;
-
- inline int findText(const QString &text,
- Qt::MatchFlags flags = static_cast<Qt::MatchFlags>(Qt::MatchExactly|Qt::MatchCaseSensitive)) const
- { return findData(text, Qt::DisplayRole, flags); }
- int findData(const QVariant &data, int role = Qt::UserRole,
- Qt::MatchFlags flags = static_cast<Qt::MatchFlags>(Qt::MatchExactly|Qt::MatchCaseSensitive)) const;
-
- enum InsertPolicy {
- NoInsert,
- InsertAtTop,
- InsertAtCurrent,
- InsertAtBottom,
- InsertAfterCurrent,
- InsertBeforeCurrent,
- InsertAlphabetically
-#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
- ,
- NoInsertion = NoInsert,
- AtTop = InsertAtTop,
- AtCurrent = InsertAtCurrent,
- AtBottom = InsertAtBottom,
- AfterCurrent = InsertAfterCurrent,
- BeforeCurrent = InsertBeforeCurrent
-#endif
- };
-#ifdef QT3_SUPPORT
- typedef InsertPolicy Policy;
-#endif
-
- InsertPolicy insertPolicy() const;
- void setInsertPolicy(InsertPolicy policy);
-
- enum SizeAdjustPolicy {
- AdjustToContents,
- AdjustToContentsOnFirstShow,
- AdjustToMinimumContentsLength, // ### Qt 5: remove
- AdjustToMinimumContentsLengthWithIcon
- };
-
- SizeAdjustPolicy sizeAdjustPolicy() const;
- void setSizeAdjustPolicy(SizeAdjustPolicy policy);
- int minimumContentsLength() const;
- void setMinimumContentsLength(int characters);
- QSize iconSize() const;
- void setIconSize(const QSize &size);
-
- bool isEditable() const;
- void setEditable(bool editable);
- void setLineEdit(QLineEdit *edit);
- QLineEdit *lineEdit() const;
-#ifndef QT_NO_VALIDATOR
- void setValidator(const QValidator *v);
- const QValidator *validator() const;
-#endif
-
-#ifndef QT_NO_COMPLETER
- void setCompleter(QCompleter *c);
- QCompleter *completer() const;
-#endif
-
- QAbstractItemDelegate *itemDelegate() const;
- void setItemDelegate(QAbstractItemDelegate *delegate);
-
- QAbstractItemModel *model() const;
- void setModel(QAbstractItemModel *model);
-
- QModelIndex rootModelIndex() const;
- void setRootModelIndex(const QModelIndex &index);
-
- int modelColumn() const;
- void setModelColumn(int visibleColumn);
-
- int currentIndex() const;
-
- QString currentText() const;
-
- QString itemText(int index) const;
- QIcon itemIcon(int index) const;
- QVariant itemData(int index, int role = Qt::UserRole) const;
-
- inline void addItem(const QString &text, const QVariant &userData = QVariant());
- inline void addItem(const QIcon &icon, const QString &text,
- const QVariant &userData = QVariant());
- inline void addItems(const QStringList &texts)
- { insertItems(count(), texts); }
-
- inline void insertItem(int index, const QString &text, const QVariant &userData = QVariant());
- void insertItem(int index, const QIcon &icon, const QString &text,
- const QVariant &userData = QVariant());
- void insertItems(int index, const QStringList &texts);
- void insertSeparator(int index);
-
- void removeItem(int index);
-
- void setItemText(int index, const QString &text);
- void setItemIcon(int index, const QIcon &icon);
- void setItemData(int index, const QVariant &value, int role = Qt::UserRole);
-
- QAbstractItemView *view() const;
- void setView(QAbstractItemView *itemView);
-
- QSize sizeHint() const;
- QSize minimumSizeHint() const;
-
- virtual void showPopup();
- virtual void hidePopup();
-
- bool event(QEvent *event);
-
-public Q_SLOTS:
- void clear();
- void clearEditText();
- void setEditText(const QString &text);
- void setCurrentIndex(int index);
-
-Q_SIGNALS:
- void editTextChanged(const QString &);
- void activated(int index);
- void activated(const QString &);
- void highlighted(int index);
- void highlighted(const QString &);
- void currentIndexChanged(int index);
- void currentIndexChanged(const QString &);
-
-protected:
- void focusInEvent(QFocusEvent *e);
- void focusOutEvent(QFocusEvent *e);
- void changeEvent(QEvent *e);
- void resizeEvent(QResizeEvent *e);
- void paintEvent(QPaintEvent *e);
- void showEvent(QShowEvent *e);
- void hideEvent(QHideEvent *e);
- void mousePressEvent(QMouseEvent *e);
- void mouseReleaseEvent(QMouseEvent *e);
- void keyPressEvent(QKeyEvent *e);
- void keyReleaseEvent(QKeyEvent *e);
-#ifndef QT_NO_WHEELEVENT
- void wheelEvent(QWheelEvent *e);
-#endif
- void contextMenuEvent(QContextMenuEvent *e);
- void inputMethodEvent(QInputMethodEvent *);
- QVariant inputMethodQuery(Qt::InputMethodQuery) const;
- void initStyleOption(QStyleOptionComboBox *option) const;
-
-#ifdef QT3_SUPPORT
-public:
- QT3_SUPPORT_CONSTRUCTOR QComboBox(QWidget *parent, const char *name);
- QT3_SUPPORT_CONSTRUCTOR QComboBox(bool rw, QWidget *parent, const char *name = 0);
- inline QT3_SUPPORT int currentItem() const { return currentIndex(); }
- inline QT3_SUPPORT void setCurrentItem(int index) { setCurrentIndex(index); }
- inline QT3_SUPPORT InsertPolicy insertionPolicy() const { return insertPolicy(); }
- inline QT3_SUPPORT void setInsertionPolicy(InsertPolicy policy) { setInsertPolicy(policy); }
- inline QT3_SUPPORT bool editable() const { return isEditable(); }
- inline QT3_SUPPORT void popup() { showPopup(); }
- inline QT3_SUPPORT void setCurrentText(const QString& text) {
- int i = findText(text);
- if (i != -1)
- setCurrentIndex(i);
- else if (isEditable())
- setEditText(text);
- else
- setItemText(currentIndex(), text);
- }
- inline QT3_SUPPORT QString text(int index) const { return itemText(index); }
-
- inline QT3_SUPPORT QPixmap pixmap(int index) const
- { return itemIcon(index).pixmap(iconSize(), isEnabled() ? QIcon::Normal : QIcon::Disabled); }
- inline QT3_SUPPORT void insertStringList(const QStringList &list, int index = -1)
- { insertItems((index < 0 ? count() : index), list); }
- inline QT3_SUPPORT void insertItem(const QString &text, int index = -1)
- { insertItem((index < 0 ? count() : index), text); }
- inline QT3_SUPPORT void insertItem(const QPixmap &pix, int index = -1)
- { insertItem((index < 0 ? count() : index), QIcon(pix), QString()); }
- inline QT3_SUPPORT void insertItem(const QPixmap &pix, const QString &text, int index = -1)
- { insertItem((index < 0 ? count() : index), QIcon(pix), text); }
- inline QT3_SUPPORT void changeItem(const QString &text, int index)
- { setItemText(index, text); }
- inline QT3_SUPPORT void changeItem(const QPixmap &pix, int index)
- { setItemIcon(index, QIcon(pix)); }
- inline QT3_SUPPORT void changeItem(const QPixmap &pix, const QString &text, int index)
- { setItemIcon(index, QIcon(pix)); setItemText(index, text); }
- inline QT3_SUPPORT void clearValidator() { setValidator(0); }
- inline QT3_SUPPORT void clearEdit() { clearEditText(); }
-
-Q_SIGNALS:
- QT_MOC_COMPAT void textChanged(const QString &);
-#endif
-
-protected:
- QComboBox(QComboBoxPrivate &, QWidget *);
-
-private:
- Q_DECLARE_PRIVATE(QComboBox)
- Q_DISABLE_COPY(QComboBox)
- Q_PRIVATE_SLOT(d_func(), void _q_itemSelected(const QModelIndex &item))
- Q_PRIVATE_SLOT(d_func(), void _q_emitHighlighted(const QModelIndex &))
- Q_PRIVATE_SLOT(d_func(), void _q_emitCurrentIndexChanged(const QModelIndex &index))
- Q_PRIVATE_SLOT(d_func(), void _q_editingFinished())
- Q_PRIVATE_SLOT(d_func(), void _q_returnPressed())
- Q_PRIVATE_SLOT(d_func(), void _q_resetButton())
- Q_PRIVATE_SLOT(d_func(), void _q_dataChanged(const QModelIndex &, const QModelIndex &))
- Q_PRIVATE_SLOT(d_func(), void _q_updateIndexBeforeChange())
- Q_PRIVATE_SLOT(d_func(), void _q_rowsInserted(const QModelIndex & parent, int start, int end))
- Q_PRIVATE_SLOT(d_func(), void _q_rowsRemoved(const QModelIndex & parent, int start, int end))
- Q_PRIVATE_SLOT(d_func(), void _q_modelDestroyed())
- Q_PRIVATE_SLOT(d_func(), void _q_modelReset())
-#ifdef QT_KEYPAD_NAVIGATION
- Q_PRIVATE_SLOT(d_func(), void _q_completerActivated())
-#endif
-};
-
-inline void QComboBox::addItem(const QString &atext, const QVariant &auserData)
-{ insertItem(count(), atext, auserData); }
-inline void QComboBox::addItem(const QIcon &aicon, const QString &atext,
- const QVariant &auserData)
-{ insertItem(count(), aicon, atext, auserData); }
-
-inline void QComboBox::insertItem(int aindex, const QString &atext,
- const QVariant &auserData)
-{ insertItem(aindex, QIcon(), atext, auserData); }
-
-#endif // QT_NO_COMBOBOX
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QCOMBOBOX_H
diff --git a/src/gui/widgets/qcombobox_p.h b/src/gui/widgets/qcombobox_p.h
deleted file mode 100644
index cd84b87564..0000000000
--- a/src/gui/widgets/qcombobox_p.h
+++ /dev/null
@@ -1,421 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QCOMBOBOX_P_H
-#define QCOMBOBOX_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "QtGui/qcombobox.h"
-
-#ifndef QT_NO_COMBOBOX
-#include "QtGui/qabstractslider.h"
-#include "QtGui/qapplication.h"
-#include "QtGui/qitemdelegate.h"
-#include "QtGui/qstandarditemmodel.h"
-#include "QtGui/qlineedit.h"
-#include "QtGui/qlistview.h"
-#include "QtGui/qpainter.h"
-#include "QtGui/qstyle.h"
-#include "QtGui/qstyleoption.h"
-#include "QtCore/qhash.h"
-#include "QtCore/qpair.h"
-#include "QtCore/qtimer.h"
-#include "private/qwidget_p.h"
-#include "QtCore/qpointer.h"
-#include "QtGui/qcompleter.h"
-#include "QtGui/qevent.h"
-#include "QtCore/qdebug.h"
-
-#include <limits.h>
-
-QT_BEGIN_NAMESPACE
-
-class QAction;
-
-class QComboBoxListView : public QListView
-{
- Q_OBJECT
-public:
- QComboBoxListView(QComboBox *cmb = 0) : combo(cmb) {}
-
-protected:
- void resizeEvent(QResizeEvent *event)
- {
- resizeContents(viewport()->width(), contentsSize().height());
- QListView::resizeEvent(event);
- }
-
- QStyleOptionViewItem viewOptions() const
- {
- QStyleOptionViewItem option = QListView::viewOptions();
- option.showDecorationSelected = true;
- if (combo)
- option.font = combo->font();
- return option;
- }
-
- void paintEvent(QPaintEvent *e)
- {
- if (combo) {
- QStyleOptionComboBox opt;
- opt.initFrom(combo);
- opt.editable = combo->isEditable();
- if (combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo)) {
- //we paint the empty menu area to avoid having blank space that can happen when scrolling
- QStyleOptionMenuItem menuOpt;
- menuOpt.initFrom(this);
- menuOpt.palette = palette();
- menuOpt.state = QStyle::State_None;
- menuOpt.checkType = QStyleOptionMenuItem::NotCheckable;
- menuOpt.menuRect = e->rect();
- menuOpt.maxIconWidth = 0;
- menuOpt.tabWidth = 0;
- QPainter p(viewport());
- combo->style()->drawControl(QStyle::CE_MenuEmptyArea, &menuOpt, &p, this);
- }
- }
- QListView::paintEvent(e);
- }
-
-private:
- QComboBox *combo;
-};
-
-
-class QStandardItemModel;
-
-class Q_AUTOTEST_EXPORT QComboBoxPrivateScroller : public QWidget
-{
- Q_OBJECT
-
-public:
- QComboBoxPrivateScroller(QAbstractSlider::SliderAction action, QWidget *parent)
- : QWidget(parent), sliderAction(action)
- {
- setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
- setAttribute(Qt::WA_NoMousePropagation);
- }
- QSize sizeHint() const {
- return QSize(20, style()->pixelMetric(QStyle::PM_MenuScrollerHeight));
- }
-
-protected:
- inline void stopTimer() {
- timer.stop();
- }
-
- inline void startTimer() {
- timer.start(100, this);
- fast = false;
- }
-
- void enterEvent(QEvent *) {
- startTimer();
- }
-
- void leaveEvent(QEvent *) {
- stopTimer();
- }
- void timerEvent(QTimerEvent *e) {
- if (e->timerId() == timer.timerId()) {
- emit doScroll(sliderAction);
- if (fast) {
- emit doScroll(sliderAction);
- emit doScroll(sliderAction);
- }
- }
- }
- void hideEvent(QHideEvent *) {
- stopTimer();
- }
-
- void mouseMoveEvent(QMouseEvent *e)
- {
- // Enable fast scrolling if the cursor is directly above or below the popup.
- const int mouseX = e->pos().x();
- const int mouseY = e->pos().y();
- const bool horizontallyInside = pos().x() < mouseX && mouseX < rect().right() + 1;
- const bool verticallyOutside = (sliderAction == QAbstractSlider::SliderSingleStepAdd) ?
- rect().bottom() + 1 < mouseY : mouseY < pos().y();
-
- fast = horizontallyInside && verticallyOutside;
- }
-
- void paintEvent(QPaintEvent *) {
- QPainter p(this);
- QStyleOptionMenuItem menuOpt;
- menuOpt.init(this);
- menuOpt.checkType = QStyleOptionMenuItem::NotCheckable;
- menuOpt.menuRect = rect();
- menuOpt.maxIconWidth = 0;
- menuOpt.tabWidth = 0;
- menuOpt.menuItemType = QStyleOptionMenuItem::Scroller;
- if (sliderAction == QAbstractSlider::SliderSingleStepAdd)
- menuOpt.state |= QStyle::State_DownArrow;
-#ifndef Q_WS_S60
- p.eraseRect(rect());
-#endif
- style()->drawControl(QStyle::CE_MenuScroller, &menuOpt, &p);
- }
-
-Q_SIGNALS:
- void doScroll(int action);
-
-private:
- QAbstractSlider::SliderAction sliderAction;
- QBasicTimer timer;
- bool fast;
-};
-
-class Q_AUTOTEST_EXPORT QComboBoxPrivateContainer : public QFrame
-{
- Q_OBJECT
-
-public:
- QComboBoxPrivateContainer(QAbstractItemView *itemView, QComboBox *parent);
- QAbstractItemView *itemView() const;
- void setItemView(QAbstractItemView *itemView);
- int spacing() const;
- void updateTopBottomMargin();
-
- QTimer blockMouseReleaseTimer;
- QBasicTimer adjustSizeTimer;
- QPoint initialClickPosition;
-
-public Q_SLOTS:
- void scrollItemView(int action);
- void updateScrollers();
- void viewDestroyed();
-
-protected:
- void changeEvent(QEvent *e);
- bool eventFilter(QObject *o, QEvent *e);
- void mousePressEvent(QMouseEvent *e);
- void mouseReleaseEvent(QMouseEvent *e);
- void showEvent(QShowEvent *e);
- void hideEvent(QHideEvent *e);
- void timerEvent(QTimerEvent *timerEvent);
- void leaveEvent(QEvent *e);
- void resizeEvent(QResizeEvent *e);
- QStyleOptionComboBox comboStyleOption() const;
-
-Q_SIGNALS:
- void itemSelected(const QModelIndex &);
- void resetButton();
-
-private:
- QComboBox *combo;
- QAbstractItemView *view;
- QComboBoxPrivateScroller *top;
- QComboBoxPrivateScroller *bottom;
-#ifdef QT_SOFTKEYS_ENABLED
- QAction *selectAction;
- QAction *cancelAction;
-#endif
-};
-
-class QComboMenuDelegate : public QAbstractItemDelegate
-{ Q_OBJECT
-public:
- QComboMenuDelegate(QObject *parent, QComboBox *cmb) : QAbstractItemDelegate(parent), mCombo(cmb) {}
-
-protected:
- void paint(QPainter *painter,
- const QStyleOptionViewItem &option,
- const QModelIndex &index) const {
- QStyleOptionMenuItem opt = getStyleOption(option, index);
-#ifndef Q_WS_S60
- painter->fillRect(option.rect, opt.palette.background());
-#endif
- mCombo->style()->drawControl(QStyle::CE_MenuItem, &opt, painter, mCombo);
- }
- QSize sizeHint(const QStyleOptionViewItem &option,
- const QModelIndex &index) const {
- QStyleOptionMenuItem opt = getStyleOption(option, index);
- return mCombo->style()->sizeFromContents(
- QStyle::CT_MenuItem, &opt, option.rect.size(), mCombo);
- }
-
-private:
- QStyleOptionMenuItem getStyleOption(const QStyleOptionViewItem &option,
- const QModelIndex &index) const;
- QComboBox *mCombo;
-};
-
-// Note that this class is intentionally not using QStyledItemDelegate
-// Vista does not use the new theme for combo boxes and there might
-// be other side effects from using the new class
-class QComboBoxDelegate : public QItemDelegate
-{ Q_OBJECT
-public:
- QComboBoxDelegate(QObject *parent, QComboBox *cmb) : QItemDelegate(parent), mCombo(cmb) {}
-
- static bool isSeparator(const QModelIndex &index) {
- return index.data(Qt::AccessibleDescriptionRole).toString() == QLatin1String("separator");
- }
- static void setSeparator(QAbstractItemModel *model, const QModelIndex &index) {
- model->setData(index, QString::fromLatin1("separator"), Qt::AccessibleDescriptionRole);
- if (QStandardItemModel *m = qobject_cast<QStandardItemModel*>(model))
- if (QStandardItem *item = m->itemFromIndex(index))
- item->setFlags(item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled));
- }
-
-protected:
- void paint(QPainter *painter,
- const QStyleOptionViewItem &option,
- const QModelIndex &index) const {
- if (isSeparator(index)) {
- QRect rect = option.rect;
- if (const QStyleOptionViewItemV3 *v3 = qstyleoption_cast<const QStyleOptionViewItemV3*>(&option))
- if (const QAbstractItemView *view = qobject_cast<const QAbstractItemView*>(v3->widget))
- rect.setWidth(view->viewport()->width());
- QStyleOption opt;
- opt.rect = rect;
- mCombo->style()->drawPrimitive(QStyle::PE_IndicatorToolBarSeparator, &opt, painter, mCombo);
- } else {
- QItemDelegate::paint(painter, option, index);
- }
- }
-
- QSize sizeHint(const QStyleOptionViewItem &option,
- const QModelIndex &index) const {
- if (isSeparator(index)) {
- int pm = mCombo->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, mCombo);
- return QSize(pm, pm);
- }
- return QItemDelegate::sizeHint(option, index);
- }
-private:
- QComboBox *mCombo;
-};
-
-class Q_AUTOTEST_EXPORT QComboBoxPrivate : public QWidgetPrivate
-{
- Q_DECLARE_PUBLIC(QComboBox)
-public:
- QComboBoxPrivate();
- ~QComboBoxPrivate() {}
- void init();
- QComboBoxPrivateContainer* viewContainer();
- void updateLineEditGeometry();
- Qt::MatchFlags matchFlags() const;
- void _q_editingFinished();
- void _q_returnPressed();
- void _q_complete();
- void _q_itemSelected(const QModelIndex &item);
- bool contains(const QString &text, int role);
- void emitActivated(const QModelIndex&);
- void _q_emitHighlighted(const QModelIndex&);
- void _q_emitCurrentIndexChanged(const QModelIndex &index);
- void _q_modelDestroyed();
- void _q_modelReset();
-#ifdef QT_KEYPAD_NAVIGATION
- void _q_completerActivated();
-#endif
- void _q_resetButton();
- void _q_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
- void _q_updateIndexBeforeChange();
- void _q_rowsInserted(const QModelIndex & parent, int start, int end);
- void _q_rowsRemoved(const QModelIndex & parent, int start, int end);
- void updateArrow(QStyle::StateFlag state);
- bool updateHoverControl(const QPoint &pos);
- QRect popupGeometry(int screen = -1) const;
- QStyle::SubControl newHoverControl(const QPoint &pos);
- int computeWidthHint() const;
- QSize recomputeSizeHint(QSize &sh) const;
- void adjustComboBoxSize();
- QString itemText(const QModelIndex &index) const;
- QIcon itemIcon(const QModelIndex &index) const;
- int itemRole() const;
- void updateLayoutDirection();
- void setCurrentIndex(const QModelIndex &index);
- void updateDelegate(bool force = false);
- void keyboardSearchString(const QString &text);
- void modelChanged();
- void updateViewContainerPaletteAndOpacity();
-
- QAbstractItemModel *model;
- QLineEdit *lineEdit;
- QComboBoxPrivateContainer *container;
- QComboBox::InsertPolicy insertPolicy;
- QComboBox::SizeAdjustPolicy sizeAdjustPolicy;
- int minimumContentsLength;
- QSize iconSize;
- uint shownOnce : 1;
- uint autoCompletion : 1;
- uint duplicatesEnabled : 1;
- uint frame : 1;
- uint padding : 26;
- int maxVisibleItems;
- int maxCount;
- int modelColumn;
- bool inserting;
- mutable QSize minimumSizeHint;
- mutable QSize sizeHint;
- QStyle::StateFlag arrowState;
- QStyle::SubControl hoverControl;
- QRect hoverRect;
- QPersistentModelIndex currentIndex;
- QPersistentModelIndex root;
- Qt::CaseSensitivity autoCompletionCaseSensitivity;
- int indexBeforeChange;
-#ifndef QT_NO_COMPLETER
- QPointer<QCompleter> completer;
-#endif
- static QPalette viewContainerPalette(QComboBox *cmb)
- { return cmb->d_func()->viewContainer()->palette(); }
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_COMBOBOX
-
-#endif // QCOMBOBOX_P_H
diff --git a/src/gui/widgets/qcommandlinkbutton.h b/src/gui/widgets/qcommandlinkbutton.h
deleted file mode 100644
index 0dc5dfc58d..0000000000
--- a/src/gui/widgets/qcommandlinkbutton.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QCOMMANDLINKBUTTON_H
-#define QCOMMANDLINKBUTTON_H
-
-#include <QtGui/qpushbutton.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QCommandLinkButtonPrivate;
-
-class Q_GUI_EXPORT QCommandLinkButton: public QPushButton
-{
- Q_OBJECT
-
- Q_PROPERTY(QString description READ description WRITE setDescription)
- Q_PROPERTY(bool flat READ isFlat WRITE setFlat DESIGNABLE false)
-
-public:
- explicit QCommandLinkButton(QWidget *parent=0);
- explicit QCommandLinkButton(const QString &text, QWidget *parent=0);
- QCommandLinkButton(const QString &text, const QString &description, QWidget *parent=0);
- QString description() const;
- void setDescription(const QString &description);
-
-protected:
- QSize sizeHint() const;
- int heightForWidth(int) const;
- QSize minimumSizeHint() const;
- bool event(QEvent *e);
- void paintEvent(QPaintEvent *);
-
-private:
- Q_DISABLE_COPY(QCommandLinkButton)
- Q_DECLARE_PRIVATE(QCommandLinkButton)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QCOMMANDLINKBUTTON
diff --git a/src/gui/widgets/qdatetimeedit.h b/src/gui/widgets/qdatetimeedit.h
deleted file mode 100644
index d174a41fc7..0000000000
--- a/src/gui/widgets/qdatetimeedit.h
+++ /dev/null
@@ -1,230 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDATETIMEEDIT_H
-#define QDATETIMEEDIT_H
-
-#include <QtCore/qdatetime.h>
-#include <QtCore/qvariant.h>
-#include <QtGui/qabstractspinbox.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_DATETIMEEDIT
-
-class QDateTimeEditPrivate;
-class QStyleOptionSpinBox;
-class QCalendarWidget;
-
-class Q_GUI_EXPORT QDateTimeEdit : public QAbstractSpinBox
-{
- Q_OBJECT
-
- Q_ENUMS(Section)
- Q_FLAGS(Sections)
- Q_PROPERTY(QDateTime dateTime READ dateTime WRITE setDateTime NOTIFY dateTimeChanged USER true)
- Q_PROPERTY(QDate date READ date WRITE setDate NOTIFY dateChanged)
- Q_PROPERTY(QTime time READ time WRITE setTime NOTIFY timeChanged)
- Q_PROPERTY(QDateTime maximumDateTime READ maximumDateTime WRITE setMaximumDateTime RESET clearMaximumDateTime)
- Q_PROPERTY(QDateTime minimumDateTime READ minimumDateTime WRITE setMinimumDateTime RESET clearMinimumDateTime)
- Q_PROPERTY(QDate maximumDate READ maximumDate WRITE setMaximumDate RESET clearMaximumDate)
- Q_PROPERTY(QDate minimumDate READ minimumDate WRITE setMinimumDate RESET clearMinimumDate)
- Q_PROPERTY(QTime maximumTime READ maximumTime WRITE setMaximumTime RESET clearMaximumTime)
- Q_PROPERTY(QTime minimumTime READ minimumTime WRITE setMinimumTime RESET clearMinimumTime)
- Q_PROPERTY(Section currentSection READ currentSection WRITE setCurrentSection)
- Q_PROPERTY(Sections displayedSections READ displayedSections)
- Q_PROPERTY(QString displayFormat READ displayFormat WRITE setDisplayFormat)
- Q_PROPERTY(bool calendarPopup READ calendarPopup WRITE setCalendarPopup)
- Q_PROPERTY(int currentSectionIndex READ currentSectionIndex WRITE setCurrentSectionIndex)
- Q_PROPERTY(int sectionCount READ sectionCount)
- Q_PROPERTY(Qt::TimeSpec timeSpec READ timeSpec WRITE setTimeSpec)
-public:
- enum Section {
- NoSection = 0x0000,
- AmPmSection = 0x0001,
- MSecSection = 0x0002,
- SecondSection = 0x0004,
- MinuteSection = 0x0008,
- HourSection = 0x0010,
- DaySection = 0x0100,
- MonthSection = 0x0200,
- YearSection = 0x0400,
- TimeSections_Mask = AmPmSection|MSecSection|SecondSection|MinuteSection|HourSection,
- DateSections_Mask = DaySection|MonthSection|YearSection
- };
-
- Q_DECLARE_FLAGS(Sections, Section)
-
- explicit QDateTimeEdit(QWidget *parent = 0);
- explicit QDateTimeEdit(const QDateTime &dt, QWidget *parent = 0);
- explicit QDateTimeEdit(const QDate &d, QWidget *parent = 0);
- explicit QDateTimeEdit(const QTime &t, QWidget *parent = 0);
-
- QDateTime dateTime() const;
- QDate date() const;
- QTime time() const;
-
- QDateTime minimumDateTime() const;
- void clearMinimumDateTime();
- void setMinimumDateTime(const QDateTime &dt);
-
- QDateTime maximumDateTime() const;
- void clearMaximumDateTime();
- void setMaximumDateTime(const QDateTime &dt);
-
- void setDateTimeRange(const QDateTime &min, const QDateTime &max);
-
- QDate minimumDate() const;
- void setMinimumDate(const QDate &min);
- void clearMinimumDate();
-
- QDate maximumDate() const;
- void setMaximumDate(const QDate &max);
- void clearMaximumDate();
-
- void setDateRange(const QDate &min, const QDate &max);
-
- QTime minimumTime() const;
- void setMinimumTime(const QTime &min);
- void clearMinimumTime();
-
- QTime maximumTime() const;
- void setMaximumTime(const QTime &max);
- void clearMaximumTime();
-
- void setTimeRange(const QTime &min, const QTime &max);
-
- Sections displayedSections() const;
- Section currentSection() const;
- Section sectionAt(int index) const;
- void setCurrentSection(Section section);
-
- int currentSectionIndex() const;
- void setCurrentSectionIndex(int index);
-
- QCalendarWidget *calendarWidget() const;
- void setCalendarWidget(QCalendarWidget *calendarWidget);
-
- int sectionCount() const;
-
- void setSelectedSection(Section section);
-
- QString sectionText(Section section) const;
-
- QString displayFormat() const;
- void setDisplayFormat(const QString &format);
-
- bool calendarPopup() const;
- void setCalendarPopup(bool enable);
-
- Qt::TimeSpec timeSpec() const;
- void setTimeSpec(Qt::TimeSpec spec);
-
- QSize sizeHint() const;
-
- virtual void clear();
- virtual void stepBy(int steps);
-
- bool event(QEvent *event);
-Q_SIGNALS:
- void dateTimeChanged(const QDateTime &date);
- void timeChanged(const QTime &date);
- void dateChanged(const QDate &date);
-
-public Q_SLOTS:
- void setDateTime(const QDateTime &dateTime);
- void setDate(const QDate &date);
- void setTime(const QTime &time);
-
-protected:
- virtual void keyPressEvent(QKeyEvent *event);
-#ifndef QT_NO_WHEELEVENT
- virtual void wheelEvent(QWheelEvent *event);
-#endif
- virtual void focusInEvent(QFocusEvent *event);
- virtual bool focusNextPrevChild(bool next);
- virtual QValidator::State validate(QString &input, int &pos) const;
- virtual void fixup(QString &input) const;
-
- virtual QDateTime dateTimeFromText(const QString &text) const;
- virtual QString textFromDateTime(const QDateTime &dt) const;
- virtual StepEnabled stepEnabled() const;
- virtual void mousePressEvent(QMouseEvent *event);
- virtual void paintEvent(QPaintEvent *event);
- void initStyleOption(QStyleOptionSpinBox *option) const;
-
- QDateTimeEdit(const QVariant &val, QVariant::Type parserType, QWidget *parent = 0);
-private:
- Q_DECLARE_PRIVATE(QDateTimeEdit)
- Q_DISABLE_COPY(QDateTimeEdit)
-
- Q_PRIVATE_SLOT(d_func(), void _q_resetButton())
-};
-
-class Q_GUI_EXPORT QTimeEdit : public QDateTimeEdit
-{
- Q_OBJECT
-public:
- QTimeEdit(QWidget *parent = 0);
- QTimeEdit(const QTime &time, QWidget *parent = 0);
-};
-
-class Q_GUI_EXPORT QDateEdit : public QDateTimeEdit
-{
- Q_OBJECT
-public:
- QDateEdit(QWidget *parent = 0);
- QDateEdit(const QDate &date, QWidget *parent = 0);
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QDateTimeEdit::Sections)
-
-#endif // QT_NO_DATETIMEEDIT
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDATETIMEEDIT_H
diff --git a/src/gui/widgets/qdatetimeedit_p.h b/src/gui/widgets/qdatetimeedit_p.h
deleted file mode 100644
index c85c0fba68..0000000000
--- a/src/gui/widgets/qdatetimeedit_p.h
+++ /dev/null
@@ -1,185 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDATETIMEEDIT_P_H
-#define QDATETIMEEDIT_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "QtGui/qcombobox.h"
-#include "QtGui/qcalendarwidget.h"
-#include "QtGui/qspinbox.h"
-#include "QtGui/qtoolbutton.h"
-#include "QtGui/qmenu.h"
-#include "QtGui/qlabel.h"
-#include "QtGui/qdatetimeedit.h"
-#include "QtGui/private/qabstractspinbox_p.h"
-#include "QtCore/private/qdatetime_p.h"
-
-#include "qdebug.h"
-
-#ifndef QT_NO_DATETIMEEDIT
-
-QT_BEGIN_NAMESPACE
-
-class QCalendarPopup;
-class QDateTimeEditPrivate : public QAbstractSpinBoxPrivate, public QDateTimeParser
-{
- Q_DECLARE_PUBLIC(QDateTimeEdit)
-public:
- QDateTimeEditPrivate();
-
- void init(const QVariant &var);
- void readLocaleSettings();
-
- void emitSignals(EmitPolicy ep, const QVariant &old);
- QString textFromValue(const QVariant &f) const;
- QVariant valueFromText(const QString &f) const;
- virtual void _q_editorCursorPositionChanged(int oldpos, int newpos);
- virtual void interpret(EmitPolicy ep);
- virtual void clearCache() const;
-
- QDateTime validateAndInterpret(QString &input, int &, QValidator::State &state,
- bool fixup = false) const;
- void clearSection(int index);
- virtual QString displayText() const { return edit->text(); } // this is from QDateTimeParser
-
- int absoluteIndex(QDateTimeEdit::Section s, int index) const;
- int absoluteIndex(const SectionNode &s) const;
- void updateEdit();
- QDateTime stepBy(int index, int steps, bool test = false) const;
- int sectionAt(int pos) const;
- int closestSection(int index, bool forward) const;
- int nextPrevSection(int index, bool forward) const;
- void setSelected(int index, bool forward = false);
-
- void updateCache(const QVariant &val, const QString &str) const;
-
- void updateTimeSpec();
- virtual QDateTime getMinimum() const { return minimum.toDateTime(); }
- virtual QDateTime getMaximum() const { return maximum.toDateTime(); }
- virtual QLocale locale() const { return q_func()->locale(); }
- QString valueToText(const QVariant &var) const { return textFromValue(var); }
- QString getAmPmText(AmPm ap, Case cs) const;
- int cursorPosition() const { return edit ? edit->cursorPosition() : -1; }
-
- virtual QStyle::SubControl newHoverControl(const QPoint &pos);
- virtual void updateEditFieldGeometry();
- virtual QVariant getZeroVariant() const;
- virtual void setRange(const QVariant &min, const QVariant &max);
-
- void _q_resetButton();
- void updateArrow(QStyle::StateFlag state);
- bool calendarPopupEnabled() const;
- void syncCalendarWidget();
-
- bool isSeparatorKey(const QKeyEvent *k) const;
-
- static QDateTimeEdit::Sections convertSections(QDateTimeParser::Sections s);
- static QDateTimeEdit::Section convertToPublic(QDateTimeParser::Section s);
-
- void initCalendarPopup(QCalendarWidget *cw = 0);
- void positionCalendarPopup();
-
- QDateTimeEdit::Sections sections;
- mutable bool cacheGuard;
-
- QString defaultDateFormat, defaultTimeFormat, defaultDateTimeFormat, unreversedFormat;
- mutable QVariant conflictGuard;
- bool hasHadFocus, formatExplicitlySet, calendarPopup;
- QStyle::StateFlag arrowState;
- QCalendarPopup *monthCalendar;
-
-#ifdef QT_KEYPAD_NAVIGATION
- bool focusOnButton;
-#endif
-};
-
-
-class QCalendarPopup : public QWidget
-{
- Q_OBJECT
-public:
- QCalendarPopup(QWidget *parent = 0, QCalendarWidget *cw = 0);
- QDate selectedDate() { return verifyCalendarInstance()->selectedDate(); }
- void setDate(const QDate &date);
- void setDateRange(const QDate &min, const QDate &max);
- void setFirstDayOfWeek(Qt::DayOfWeek dow) { verifyCalendarInstance()->setFirstDayOfWeek(dow); }
- QCalendarWidget *calendarWidget() const { return const_cast<QCalendarPopup*>(this)->verifyCalendarInstance(); }
- void setCalendarWidget(QCalendarWidget *cw);
-Q_SIGNALS:
- void activated(const QDate &date);
- void newDateSelected(const QDate &newDate);
- void hidingCalendar(const QDate &oldDate);
- void resetButton();
-
-private Q_SLOTS:
- void dateSelected(const QDate &date);
- void dateSelectionChanged();
-
-protected:
- void hideEvent(QHideEvent *);
- void mousePressEvent(QMouseEvent *e);
- void mouseReleaseEvent(QMouseEvent *);
- bool event(QEvent *e);
-
-private:
- QCalendarWidget *verifyCalendarInstance();
-
- QWeakPointer<QCalendarWidget> calendar;
- QDate oldDate;
- bool dateChanged;
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_DATETIMEEDIT
-
-#endif // QDATETIMEEDIT_P_H
diff --git a/src/gui/widgets/qdial.h b/src/gui/widgets/qdial.h
deleted file mode 100644
index 6786358969..0000000000
--- a/src/gui/widgets/qdial.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#ifndef QDIAL_H
-#define QDIAL_H
-
-#include <QtGui/qabstractslider.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_DIAL
-
-class QDialPrivate;
-class QStyleOptionSlider;
-
-class Q_GUI_EXPORT QDial: public QAbstractSlider
-{
- Q_OBJECT
-
- Q_PROPERTY(bool wrapping READ wrapping WRITE setWrapping)
- Q_PROPERTY(int notchSize READ notchSize)
- Q_PROPERTY(qreal notchTarget READ notchTarget WRITE setNotchTarget)
- Q_PROPERTY(bool notchesVisible READ notchesVisible WRITE setNotchesVisible)
-public:
- explicit QDial(QWidget *parent = 0);
-
- ~QDial();
-
- bool wrapping() const;
-
- int notchSize() const;
-
- void setNotchTarget(double target);
- qreal notchTarget() const;
- bool notchesVisible() const;
-
- QSize sizeHint() const;
- QSize minimumSizeHint() const;
-
-public Q_SLOTS:
- void setNotchesVisible(bool visible);
- void setWrapping(bool on);
-
-protected:
- bool event(QEvent *e);
- void resizeEvent(QResizeEvent *re);
- void paintEvent(QPaintEvent *pe);
-
- void mousePressEvent(QMouseEvent *me);
- void mouseReleaseEvent(QMouseEvent *me);
- void mouseMoveEvent(QMouseEvent *me);
-
- void sliderChange(SliderChange change);
- void initStyleOption(QStyleOptionSlider *option) const;
-
-#ifdef QT3_SUPPORT
-public:
- QT3_SUPPORT_CONSTRUCTOR QDial(int minValue, int maxValue, int pageStep, int value,
- QWidget* parent = 0, const char* name = 0);
- QT3_SUPPORT_CONSTRUCTOR QDial(QWidget *parent, const char *name);
-
-Q_SIGNALS:
- QT_MOC_COMPAT void dialPressed();
- QT_MOC_COMPAT void dialMoved(int value);
- QT_MOC_COMPAT void dialReleased();
-#endif
-
-private:
- Q_DECLARE_PRIVATE(QDial)
- Q_DISABLE_COPY(QDial)
-};
-
-#endif // QT_NO_DIAL
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDIAL_H
diff --git a/src/gui/widgets/qdialogbuttonbox.cpp b/src/gui/widgets/qdialogbuttonbox.cpp
deleted file mode 100644
index 6fe87b6ac8..0000000000
--- a/src/gui/widgets/qdialogbuttonbox.cpp
+++ /dev/null
@@ -1,1285 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore/qhash.h>
-#include <QtGui/qpushbutton.h>
-#include <QtGui/qstyle.h>
-#include <QtGui/qlayout.h>
-#include <QtGui/qdialog.h>
-#include <QtGui/qapplication.h>
-#include <QtGui/private/qwidget_p.h>
-#include <QtGui/qaction.h>
-
-#include "qdialogbuttonbox.h"
-
-#ifdef QT_SOFTKEYS_ENABLED
-#include <QtGui/qaction.h>
-#endif
-
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QDialogButtonBox
- \since 4.2
- \brief The QDialogButtonBox class is a widget that presents buttons in a
- layout that is appropriate to the current widget style.
-
- \ingroup dialog-classes
-
-
- Dialogs and message boxes typically present buttons in a layout that
- conforms to the interface guidelines for that platform. Invariably,
- different platforms have different layouts for their dialogs.
- QDialogButtonBox allows a developer to add buttons to it and will
- automatically use the appropriate layout for the user's desktop
- environment.
-
- Most buttons for a dialog follow certain roles. Such roles include:
-
- \list
- \o Accepting or rejecting the dialog.
- \o Asking for help.
- \o Performing actions on the dialog itself (such as resetting fields or
- applying changes).
- \endlist
-
- There can also be alternate ways of dismissing the dialog which may cause
- destructive results.
-
- Most dialogs have buttons that can almost be considered standard (e.g.
- \gui OK and \gui Cancel buttons). It is sometimes convenient to create these
- buttons in a standard way.
-
- There are a couple ways of using QDialogButtonBox. One ways is to create
- the buttons (or button texts) yourself and add them to the button box,
- specifying their role.
-
- \snippet examples/dialogs/extension/finddialog.cpp 1
-
- Alternatively, QDialogButtonBox provides several standard buttons (e.g. OK, Cancel, Save)
- that you can use. They exist as flags so you can OR them together in the constructor.
-
- \snippet examples/dialogs/tabdialog/tabdialog.cpp 2
-
- You can mix and match normal buttons and standard buttons.
-
- Currently the buttons are laid out in the following way if the button box is horizontal:
- \table
- \row \o \inlineimage buttonbox-gnomelayout-horizontal.png GnomeLayout Horizontal
- \o Button box laid out in horizontal GnomeLayout
- \row \o \inlineimage buttonbox-kdelayout-horizontal.png KdeLayout Horizontal
- \o Button box laid out in horizontal KdeLayout
- \row \o \inlineimage buttonbox-maclayout-horizontal.png MacLayout Horizontal
- \o Button box laid out in horizontal MacLayout
- \row \o \inlineimage buttonbox-winlayout-horizontal.png WinLayout Horizontal
- \o Button box laid out in horizontal WinLayout
- \endtable
-
- The buttons are laid out the following way if the button box is vertical:
-
- \table
- \row \o GnomeLayout
- \o KdeLayout
- \o MacLayout
- \o WinLayout
- \row \o \inlineimage buttonbox-gnomelayout-vertical.png GnomeLayout Vertical
- \o \inlineimage buttonbox-kdelayout-vertical.png KdeLayout Vertical
- \o \inlineimage buttonbox-maclayout-vertical.png MacLayout Vertical
- \o \inlineimage buttonbox-winlayout-vertical.png WinLayout Vertical
- \endtable
-
- Additionally, button boxes that contain only buttons with ActionRole or
- HelpRole can be considered modeless and have an alternate look on Mac OS X:
-
- \table
- \row \o modeless horizontal MacLayout
- \o \inlineimage buttonbox-mac-modeless-horizontal.png Screenshot of modeless horizontal MacLayout
- \endtable
-
- When a button is clicked in the button box, the clicked() signal is emitted
- for the actual button is that is pressed. For convenience, if the button
- has an AcceptRole, RejectRole, or HelpRole, the accepted(), rejected(), or
- helpRequested() signals are emitted respectively.
-
- If you want a specific button to be default you need to call
- QPushButton::setDefault() on it yourself. However, if there is no default
- button set and to preserve which button is the default button across
- platforms when using the QPushButton::autoDefault property, the first push
- button with the accept role is made the default button when the
- QDialogButtonBox is shown,
-
- \sa QMessageBox, QPushButton, QDialog
-*/
-
-enum {
- AcceptRole = QDialogButtonBox::AcceptRole,
- RejectRole = QDialogButtonBox::RejectRole,
- DestructiveRole = QDialogButtonBox::DestructiveRole,
- ActionRole = QDialogButtonBox::ActionRole,
- HelpRole = QDialogButtonBox::HelpRole,
- YesRole = QDialogButtonBox::YesRole,
- NoRole = QDialogButtonBox::NoRole,
- ApplyRole = QDialogButtonBox::ApplyRole,
- ResetRole = QDialogButtonBox::ResetRole,
-
- AlternateRole = 0x10000000,
- Stretch = 0x20000000,
- EOL = 0x40000000,
- Reverse = 0x80000000
-};
-
-static QDialogButtonBox::ButtonRole roleFor(QDialogButtonBox::StandardButton button)
-{
- switch (button) {
- case QDialogButtonBox::Ok:
- case QDialogButtonBox::Save:
- case QDialogButtonBox::Open:
- case QDialogButtonBox::SaveAll:
- case QDialogButtonBox::Retry:
- case QDialogButtonBox::Ignore:
- return QDialogButtonBox::AcceptRole;
-
- case QDialogButtonBox::Cancel:
- case QDialogButtonBox::Close:
- case QDialogButtonBox::Abort:
- return QDialogButtonBox::RejectRole;
-
- case QDialogButtonBox::Discard:
- return QDialogButtonBox::DestructiveRole;
-
- case QDialogButtonBox::Help:
- return QDialogButtonBox::HelpRole;
-
- case QDialogButtonBox::Apply:
- return QDialogButtonBox::ApplyRole;
-
- case QDialogButtonBox::Yes:
- case QDialogButtonBox::YesToAll:
- return QDialogButtonBox::YesRole;
-
- case QDialogButtonBox::No:
- case QDialogButtonBox::NoToAll:
- return QDialogButtonBox::NoRole;
-
- case QDialogButtonBox::RestoreDefaults:
- case QDialogButtonBox::Reset:
- return QDialogButtonBox::ResetRole;
-
- case QDialogButtonBox::NoButton: // NoButton means zero buttons, not "No" button
- ;
- }
-
- return QDialogButtonBox::InvalidRole;
-}
-
-static const int layouts[2][5][14] =
-{
- // Qt::Horizontal
- {
- // WinLayout
- { ResetRole, Stretch, YesRole, AcceptRole, AlternateRole, DestructiveRole, NoRole, ActionRole, RejectRole, ApplyRole,
- HelpRole, EOL, EOL, EOL },
-
- // MacLayout
- { HelpRole, ResetRole, ApplyRole, ActionRole, Stretch, DestructiveRole | Reverse,
- AlternateRole | Reverse, RejectRole | Reverse, AcceptRole | Reverse, NoRole | Reverse, YesRole | Reverse, EOL, EOL },
-
- // KdeLayout
- { HelpRole, ResetRole, Stretch, YesRole, NoRole, ActionRole, AcceptRole, AlternateRole,
- ApplyRole, DestructiveRole, RejectRole, EOL },
-
- // GnomeLayout
- { HelpRole, ResetRole, Stretch, ActionRole, ApplyRole | Reverse, DestructiveRole | Reverse,
- AlternateRole | Reverse, RejectRole | Reverse, AcceptRole | Reverse, NoRole | Reverse, YesRole | Reverse, EOL },
-
- // Mac modeless
- { ResetRole, ApplyRole, ActionRole, Stretch, HelpRole, EOL, EOL, EOL, EOL, EOL, EOL, EOL, EOL, EOL }
- },
-
- // Qt::Vertical
- {
- // WinLayout
- { ActionRole, YesRole, AcceptRole, AlternateRole, DestructiveRole, NoRole, RejectRole, ApplyRole, ResetRole,
- HelpRole, Stretch, EOL, EOL, EOL },
-
- // MacLayout
- { YesRole, NoRole, AcceptRole, RejectRole, AlternateRole, DestructiveRole, Stretch, ActionRole, ApplyRole,
- ResetRole, HelpRole, EOL, EOL },
-
- // KdeLayout
- { AcceptRole, AlternateRole, ApplyRole, ActionRole, YesRole, NoRole, Stretch, ResetRole,
- DestructiveRole, RejectRole, HelpRole, EOL },
-
- // GnomeLayout
- { YesRole, NoRole, AcceptRole, RejectRole, AlternateRole, DestructiveRole, ApplyRole, ActionRole, Stretch,
- ResetRole, HelpRole, EOL, EOL, EOL },
-
- // Mac modeless
- { ActionRole, ApplyRole, ResetRole, Stretch, HelpRole, EOL, EOL, EOL, EOL, EOL, EOL, EOL, EOL, EOL }
- }
-};
-
-#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION)
-class QDialogButtonEnabledProxy : public QObject
-{
-public:
- QDialogButtonEnabledProxy(QObject *parent, QWidget *src, QAction *trg) : QObject(parent), source(src), target(trg)
- {
- source->installEventFilter(this);
- target->setEnabled(source->isEnabled());
- }
- ~QDialogButtonEnabledProxy()
- {
- source->removeEventFilter(this);
- }
- bool eventFilter(QObject *object, QEvent *event)
- {
- if (object == source && event->type() == QEvent::EnabledChange) {
- target->setEnabled(source->isEnabled());
- }
- return false;
- };
-private:
- QWidget *source;
- QAction *target;
-};
-#endif
-
-class QDialogButtonBoxPrivate : public QWidgetPrivate
-{
- Q_DECLARE_PUBLIC(QDialogButtonBox)
-
-public:
- QDialogButtonBoxPrivate(Qt::Orientation orient);
-
- QList<QAbstractButton *> buttonLists[QDialogButtonBox::NRoles];
- QHash<QPushButton *, QDialogButtonBox::StandardButton> standardButtonHash;
-#ifdef QT_SOFTKEYS_ENABLED
- QHash<QAbstractButton *, QAction *> softKeyActions;
-#endif
-
- Qt::Orientation orientation;
- QDialogButtonBox::ButtonLayout layoutPolicy;
- QBoxLayout *buttonLayout;
- bool internalRemove;
- bool center;
-
- void createStandardButtons(QDialogButtonBox::StandardButtons buttons);
-
- void layoutButtons();
- void initLayout();
- void resetLayout();
- QPushButton *createButton(QDialogButtonBox::StandardButton button, bool doLayout = true);
- void addButton(QAbstractButton *button, QDialogButtonBox::ButtonRole role, bool doLayout = true);
- void _q_handleButtonDestroyed();
- void _q_handleButtonClicked();
- void addButtonsToLayout(const QList<QAbstractButton *> &buttonList, bool reverse);
- void retranslateStrings();
- const char *standardButtonText(QDialogButtonBox::StandardButton sbutton) const;
-#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION)
- QAction *createSoftKey(QAbstractButton *button, QDialogButtonBox::ButtonRole role);
-#endif
-};
-
-QDialogButtonBoxPrivate::QDialogButtonBoxPrivate(Qt::Orientation orient)
- : orientation(orient), buttonLayout(0), internalRemove(false), center(false)
-{
-}
-
-void QDialogButtonBoxPrivate::initLayout()
-{
- Q_Q(QDialogButtonBox);
- layoutPolicy = QDialogButtonBox::ButtonLayout(q->style()->styleHint(QStyle::SH_DialogButtonLayout, 0, q));
- bool createNewLayout = buttonLayout == 0
- || (orientation == Qt::Horizontal && qobject_cast<QVBoxLayout *>(buttonLayout) != 0)
- || (orientation == Qt::Vertical && qobject_cast<QHBoxLayout *>(buttonLayout) != 0);
- if (createNewLayout) {
- delete buttonLayout;
- if (orientation == Qt::Horizontal)
- buttonLayout = new QHBoxLayout(q);
- else
- buttonLayout = new QVBoxLayout(q);
- }
-
- int left, top, right, bottom;
- setLayoutItemMargins(QStyle::SE_PushButtonLayoutItem);
- getLayoutItemMargins(&left, &top, &right, &bottom);
- buttonLayout->setContentsMargins(-left, -top, -right, -bottom);
-
- if (!q->testAttribute(Qt::WA_WState_OwnSizePolicy)) {
- QSizePolicy sp(QSizePolicy::Expanding, QSizePolicy::Fixed, QSizePolicy::ButtonBox);
- if (orientation == Qt::Vertical)
- sp.transpose();
- q->setSizePolicy(sp);
- q->setAttribute(Qt::WA_WState_OwnSizePolicy, false);
- }
-
- // ### move to a real init() function
- q->setFocusPolicy(Qt::TabFocus);
-}
-
-void QDialogButtonBoxPrivate::resetLayout()
-{
- //delete buttonLayout;
- initLayout();
- layoutButtons();
-}
-
-void QDialogButtonBoxPrivate::addButtonsToLayout(const QList<QAbstractButton *> &buttonList,
- bool reverse)
-{
- int start = reverse ? buttonList.count() - 1 : 0;
- int end = reverse ? -1 : buttonList.count();
- int step = reverse ? -1 : 1;
-
- for (int i = start; i != end; i += step) {
- QAbstractButton *button = buttonList.at(i);
- buttonLayout->addWidget(button);
- button->show();
- }
-}
-
-void QDialogButtonBoxPrivate::layoutButtons()
-{
- Q_Q(QDialogButtonBox);
- const int MacGap = 36 - 8; // 8 is the default gap between a widget and a spacer item
-
- for (int i = buttonLayout->count() - 1; i >= 0; --i) {
- QLayoutItem *item = buttonLayout->takeAt(i);
- if (QWidget *widget = item->widget())
- widget->hide();
- delete item;
- }
-
- int tmpPolicy = layoutPolicy;
-
- static const int M = 5;
- static const int ModalRoles[M] = { AcceptRole, RejectRole, DestructiveRole, YesRole, NoRole };
- if (tmpPolicy == QDialogButtonBox::MacLayout) {
- bool hasModalButton = false;
- for (int i = 0; i < M; ++i) {
- if (!buttonLists[ModalRoles[i]].isEmpty()) {
- hasModalButton = true;
- break;
- }
- }
- if (!hasModalButton)
- tmpPolicy = 4; // Mac modeless
- }
-
- const int *currentLayout = layouts[orientation == Qt::Vertical][tmpPolicy];
-
- if (center)
- buttonLayout->addStretch();
-
- QList<QAbstractButton *> acceptRoleList = buttonLists[AcceptRole];
-
- while (*currentLayout != EOL) {
- int role = (*currentLayout & ~Reverse);
- bool reverse = (*currentLayout & Reverse);
-
- switch (role) {
- case Stretch:
- if (!center)
- buttonLayout->addStretch();
- break;
- case AcceptRole: {
- if (acceptRoleList.isEmpty())
- break;
- // Only the first one
- QAbstractButton *button = acceptRoleList.first();
- buttonLayout->addWidget(button);
- button->show();
- }
- break;
- case AlternateRole:
- {
- if (acceptRoleList.size() < 2)
- break;
- QList<QAbstractButton *> list = acceptRoleList;
- list.removeFirst();
- addButtonsToLayout(list, reverse);
- }
- break;
- case DestructiveRole:
- {
- const QList<QAbstractButton *> &list = buttonLists[role];
-
- /*
- Mac: Insert a gap on the left of the destructive
- buttons to ensure that they don't get too close to
- the help and action buttons (but only if there are
- some buttons to the left of the destructive buttons
- (and the stretch, whence buttonLayout->count() > 1
- and not 0)).
- */
- if (tmpPolicy == QDialogButtonBox::MacLayout
- && !list.isEmpty() && buttonLayout->count() > 1)
- buttonLayout->addSpacing(MacGap);
-
- addButtonsToLayout(list, reverse);
-
- /*
- Insert a gap between the destructive buttons and the
- accept and reject buttons.
- */
- if (tmpPolicy == QDialogButtonBox::MacLayout && !list.isEmpty())
- buttonLayout->addSpacing(MacGap);
- }
- break;
- case RejectRole:
- case ActionRole:
- case HelpRole:
- case YesRole:
- case NoRole:
- case ApplyRole:
- case ResetRole:
- addButtonsToLayout(buttonLists[role], reverse);
- }
- ++currentLayout;
- }
-
- QWidget *lastWidget = 0;
- q->setFocusProxy(0);
- for (int i = 0; i < buttonLayout->count(); ++i) {
- QLayoutItem *item = buttonLayout->itemAt(i);
- if (QWidget *widget = item->widget()) {
- if (lastWidget)
- QWidget::setTabOrder(lastWidget, widget);
- else
- q->setFocusProxy(widget);
- lastWidget = widget;
- }
- }
-
- if (center)
- buttonLayout->addStretch();
-}
-
-QPushButton *QDialogButtonBoxPrivate::createButton(QDialogButtonBox::StandardButton sbutton,
- bool doLayout)
-{
- Q_Q(QDialogButtonBox);
- const char *buttonText = 0;
- int icon = 0;
-
- switch (sbutton) {
- case QDialogButtonBox::Ok:
- icon = QStyle::SP_DialogOkButton;
- break;
- case QDialogButtonBox::Save:
- icon = QStyle::SP_DialogSaveButton;
- break;
- case QDialogButtonBox::Open:
- icon = QStyle::SP_DialogOpenButton;
- break;
- case QDialogButtonBox::Cancel:
- icon = QStyle::SP_DialogCancelButton;
- break;
- case QDialogButtonBox::Close:
- icon = QStyle::SP_DialogCloseButton;
- break;
- case QDialogButtonBox::Apply:
- icon = QStyle::SP_DialogApplyButton;
- break;
- case QDialogButtonBox::Reset:
- icon = QStyle::SP_DialogResetButton;
- break;
- case QDialogButtonBox::Help:
- icon = QStyle::SP_DialogHelpButton;
- break;
- case QDialogButtonBox::Discard:
- icon = QStyle::SP_DialogDiscardButton;
- break;
- case QDialogButtonBox::Yes:
- icon = QStyle::SP_DialogYesButton;
- break;
- case QDialogButtonBox::No:
- icon = QStyle::SP_DialogNoButton;
- break;
- case QDialogButtonBox::YesToAll:
- case QDialogButtonBox::NoToAll:
- case QDialogButtonBox::SaveAll:
- case QDialogButtonBox::Abort:
- case QDialogButtonBox::Retry:
- case QDialogButtonBox::Ignore:
- case QDialogButtonBox::RestoreDefaults:
- break;
- case QDialogButtonBox::NoButton:
- return 0;
- ;
- }
- buttonText = standardButtonText(sbutton);
-
- QPushButton *button = new QPushButton(QDialogButtonBox::tr(buttonText), q);
- QStyle *style = q->style();
- if (style->styleHint(QStyle::SH_DialogButtonBox_ButtonsHaveIcons, 0, q) && icon != 0)
- button->setIcon(style->standardIcon(QStyle::StandardPixmap(icon), 0, q));
- if (style != QApplication::style()) // Propagate style
- button->setStyle(style);
- standardButtonHash.insert(button, sbutton);
- if (roleFor(sbutton) != QDialogButtonBox::InvalidRole) {
- addButton(button, roleFor(sbutton), doLayout);
- } else {
- qWarning("QDialogButtonBox::createButton: Invalid ButtonRole, button not added");
- }
-
-#ifdef Q_WS_MAC
- // Since mnemonics is off by default on Mac, we add a Cmd-D
- // shortcut here to e.g. make the "Don't Save" button work nativly:
- if (sbutton == QDialogButtonBox::Discard)
- button->setShortcut(QKeySequence(QLatin1String("Ctrl+D")));
-#endif
-
- return button;
-}
-
-void QDialogButtonBoxPrivate::addButton(QAbstractButton *button, QDialogButtonBox::ButtonRole role,
- bool doLayout)
-{
- Q_Q(QDialogButtonBox);
- QObject::connect(button, SIGNAL(clicked()), q, SLOT(_q_handleButtonClicked()));
- QObject::connect(button, SIGNAL(destroyed()), q, SLOT(_q_handleButtonDestroyed()));
- buttonLists[role].append(button);
-#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION)
- QAction *action = createSoftKey(button, role);
- softKeyActions.insert(button, action);
- new QDialogButtonEnabledProxy(action, button, action);
-#endif
- if (doLayout)
- layoutButtons();
-}
-
-#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION)
-QAction* QDialogButtonBoxPrivate::createSoftKey(QAbstractButton *button, QDialogButtonBox::ButtonRole role)
-{
- Q_Q(QDialogButtonBox);
- QAction::SoftKeyRole softkeyRole;
-
- QAction *action = new QAction(button->text(), button);
-
- switch (role) {
- case ApplyRole:
- case AcceptRole:
- case YesRole:
- case ActionRole:
- case HelpRole:
- softkeyRole = QAction::PositiveSoftKey;
- break;
- case RejectRole:
- case DestructiveRole:
- case NoRole:
- case ResetRole:
- softkeyRole = QAction::NegativeSoftKey;
- break;
- default:
- break;
- }
- QObject::connect(action, SIGNAL(triggered()), button, SIGNAL(clicked()));
- action->setSoftKeyRole(softkeyRole);
-
-
- QWidget *dialog = 0;
- QWidget *p = q;
- while (p && !p->isWindow()) {
- p = p->parentWidget();
- if ((dialog = qobject_cast<QDialog *>(p)))
- break;
- }
-
- if (dialog) {
- dialog->addAction(action);
- } else {
- q->addAction(action);
- }
-
- return action;
-}
-#endif
-
-void QDialogButtonBoxPrivate::createStandardButtons(QDialogButtonBox::StandardButtons buttons)
-{
- uint i = QDialogButtonBox::FirstButton;
- while (i <= QDialogButtonBox::LastButton) {
- if (i & buttons) {
- createButton(QDialogButtonBox::StandardButton(i), false);
- }
- i = i << 1;
- }
- layoutButtons();
-}
-
-const char *QDialogButtonBoxPrivate::standardButtonText(QDialogButtonBox::StandardButton sbutton) const
-{
- const char *buttonText = 0;
- bool gnomeLayout = (layoutPolicy == QDialogButtonBox::GnomeLayout);
- switch (sbutton) {
- case QDialogButtonBox::Ok:
- buttonText = gnomeLayout ? QT_TRANSLATE_NOOP("QDialogButtonBox", "&OK") : QT_TRANSLATE_NOOP("QDialogButtonBox", "OK");
- break;
- case QDialogButtonBox::Save:
- buttonText = gnomeLayout ? QT_TRANSLATE_NOOP("QDialogButtonBox", "&Save") : QT_TRANSLATE_NOOP("QDialogButtonBox", "Save");
- break;
- case QDialogButtonBox::Open:
- buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Open");
- break;
- case QDialogButtonBox::Cancel:
- buttonText = gnomeLayout ? QT_TRANSLATE_NOOP("QDialogButtonBox", "&Cancel") : QT_TRANSLATE_NOOP("QDialogButtonBox", "Cancel");
- break;
- case QDialogButtonBox::Close:
- buttonText = gnomeLayout ? QT_TRANSLATE_NOOP("QDialogButtonBox", "&Close") : QT_TRANSLATE_NOOP("QDialogButtonBox", "Close");
- break;
- case QDialogButtonBox::Apply:
- buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Apply");
- break;
- case QDialogButtonBox::Reset:
- buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Reset");
- break;
- case QDialogButtonBox::Help:
- buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Help");
- break;
- case QDialogButtonBox::Discard:
- if (layoutPolicy == QDialogButtonBox::MacLayout)
- buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Don't Save");
- else if (layoutPolicy == QDialogButtonBox::GnomeLayout)
- buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Close without Saving");
- else
- buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Discard");
- break;
- case QDialogButtonBox::Yes:
- buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "&Yes");
- break;
- case QDialogButtonBox::YesToAll:
- buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Yes to &All");
- break;
- case QDialogButtonBox::No:
- buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "&No");
- break;
- case QDialogButtonBox::NoToAll:
- buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "N&o to All");
- break;
- case QDialogButtonBox::SaveAll:
- buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Save All");
- break;
- case QDialogButtonBox::Abort:
- buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Abort");
- break;
- case QDialogButtonBox::Retry:
- buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Retry");
- break;
- case QDialogButtonBox::Ignore:
- buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Ignore");
- break;
- case QDialogButtonBox::RestoreDefaults:
- buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Restore Defaults");
- break;
- case QDialogButtonBox::NoButton:
- ;
- } // switch
- return buttonText;
-}
-
-void QDialogButtonBoxPrivate::retranslateStrings()
-{
- const char *buttonText = 0;
- QHash<QPushButton *, QDialogButtonBox::StandardButton>::iterator it = standardButtonHash.begin();
- while (it != standardButtonHash.end()) {
- buttonText = standardButtonText(it.value());
- if (buttonText) {
- QPushButton *button = it.key();
- button->setText(QDialogButtonBox::tr(buttonText));
-#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION)
- QAction *action = softKeyActions.value(button, 0);
- if (action)
- action->setText(button->text());
-#endif
- }
- ++it;
- }
-}
-
-/*!
- Constructs an empty, horizontal button box with the given \a parent.
-
- \sa orientation, addButton()
-*/
-QDialogButtonBox::QDialogButtonBox(QWidget *parent)
- : QWidget(*new QDialogButtonBoxPrivate(Qt::Horizontal), parent, 0)
-{
- d_func()->initLayout();
-}
-
-/*!
- Constructs an empty button box with the given \a orientation and \a parent.
-
- \sa orientation, addButton()
-*/
-QDialogButtonBox::QDialogButtonBox(Qt::Orientation orientation, QWidget *parent)
- : QWidget(*new QDialogButtonBoxPrivate(orientation), parent, 0)
-{
- d_func()->initLayout();
-}
-
-/*!
- Constructs a button box with the given \a orientation and \a parent, containing
- the standard buttons specified by \a buttons.
-
- \sa orientation, addButton()
-*/
-QDialogButtonBox::QDialogButtonBox(StandardButtons buttons, Qt::Orientation orientation,
- QWidget *parent)
- : QWidget(*new QDialogButtonBoxPrivate(orientation), parent, 0)
-{
- d_func()->initLayout();
- d_func()->createStandardButtons(buttons);
-}
-
-/*!
- Destroys the button box.
-*/
-QDialogButtonBox::~QDialogButtonBox()
-{
-}
-
-/*!
- \enum QDialogButtonBox::ButtonRole
- \enum QMessageBox::ButtonRole
-
- This enum describes the roles that can be used to describe buttons in
- the button box. Combinations of these roles are as flags used to
- describe different aspects of their behavior.
-
- \value InvalidRole The button is invalid.
- \value AcceptRole Clicking the button causes the dialog to be accepted
- (e.g. OK).
- \value RejectRole Clicking the button causes the dialog to be rejected
- (e.g. Cancel).
- \value DestructiveRole Clicking the button causes a destructive change
- (e.g. for Discarding Changes) and closes the dialog.
- \value ActionRole Clicking the button causes changes to the elements within
- the dialog.
- \value HelpRole The button can be clicked to request help.
- \value YesRole The button is a "Yes"-like button.
- \value NoRole The button is a "No"-like button.
- \value ApplyRole The button applies current changes.
- \value ResetRole The button resets the dialog's fields to default values.
-
- \omitvalue NRoles
-
- \sa StandardButton
-*/
-
-/*!
- \enum QDialogButtonBox::StandardButton
-
- These enums describe flags for standard buttons. Each button has a
- defined \l ButtonRole.
-
- \value Ok An "OK" button defined with the \l AcceptRole.
- \value Open A "Open" button defined with the \l AcceptRole.
- \value Save A "Save" button defined with the \l AcceptRole.
- \value Cancel A "Cancel" button defined with the \l RejectRole.
- \value Close A "Close" button defined with the \l RejectRole.
- \value Discard A "Discard" or "Don't Save" button, depending on the platform,
- defined with the \l DestructiveRole.
- \value Apply An "Apply" button defined with the \l ApplyRole.
- \value Reset A "Reset" button defined with the \l ResetRole.
- \value RestoreDefaults A "Restore Defaults" button defined with the \l ResetRole.
- \value Help A "Help" button defined with the \l HelpRole.
- \value SaveAll A "Save All" button defined with the \l AcceptRole.
- \value Yes A "Yes" button defined with the \l YesRole.
- \value YesToAll A "Yes to All" button defined with the \l YesRole.
- \value No A "No" button defined with the \l NoRole.
- \value NoToAll A "No to All" button defined with the \l NoRole.
- \value Abort An "Abort" button defined with the \l RejectRole.
- \value Retry A "Retry" button defined with the \l AcceptRole.
- \value Ignore An "Ignore" button defined with the \l AcceptRole.
-
- \value NoButton An invalid button.
-
- \omitvalue FirstButton
- \omitvalue LastButton
-
- \sa ButtonRole, standardButtons
-*/
-
-/*!
- \enum QDialogButtonBox::ButtonLayout
-
- This enum describes the layout policy to be used when arranging the buttons
- contained in the button box.
-
- \value WinLayout Use a policy appropriate for applications on Windows.
- \value MacLayout Use a policy appropriate for applications on Mac OS X.
- \value KdeLayout Use a policy appropriate for applications on KDE.
- \value GnomeLayout Use a policy appropriate for applications on GNOME.
-
- The button layout is specified by the \l{style()}{current style}. However,
- on the X11 platform, it may be influenced by the desktop environment.
-*/
-
-/*!
- \fn void QDialogButtonBox::clicked(QAbstractButton *button)
-
- This signal is emitted when a button inside the button box is clicked. The
- specific button that was pressed is specified by \a button.
-
- \sa accepted(), rejected(), helpRequested()
-*/
-
-/*!
- \fn void QDialogButtonBox::accepted()
-
- This signal is emitted when a button inside the button box is clicked, as long
- as it was defined with the \l AcceptRole or \l YesRole.
-
- \sa rejected(), clicked() helpRequested()
-*/
-
-/*!
- \fn void QDialogButtonBox::rejected()
-
- This signal is emitted when a button inside the button box is clicked, as long
- as it was defined with the \l RejectRole or \l NoRole.
-
- \sa accepted() helpRequested() clicked()
-*/
-
-/*!
- \fn void QDialogButtonBox::helpRequested()
-
- This signal is emitted when a button inside the button box is clicked, as long
- as it was defined with the \l HelpRole.
-
- \sa accepted() rejected() clicked()
-*/
-
-/*!
- \property QDialogButtonBox::orientation
- \brief the orientation of the button box
-
- By default, the orientation is horizontal (i.e. the buttons are laid out
- side by side). The possible orientations are Qt::Horizontal and
- Qt::Vertical.
-*/
-Qt::Orientation QDialogButtonBox::orientation() const
-{
- return d_func()->orientation;
-}
-
-void QDialogButtonBox::setOrientation(Qt::Orientation orientation)
-{
- Q_D(QDialogButtonBox);
- if (orientation == d->orientation)
- return;
-
- d->orientation = orientation;
- d->resetLayout();
-}
-
-/*!
- Clears the button box, deleting all buttons within it.
-
- \sa removeButton(), addButton()
-*/
-void QDialogButtonBox::clear()
-{
- Q_D(QDialogButtonBox);
-#ifdef QT_SOFTKEYS_ENABLED
- // Delete softkey actions as they have the buttons as parents
- qDeleteAll(d->softKeyActions.values());
- d->softKeyActions.clear();
-#endif
- // Remove the created standard buttons, they should be in the other lists, which will
- // do the deletion
- d->standardButtonHash.clear();
- for (int i = 0; i < NRoles; ++i) {
- QList<QAbstractButton *> &list = d->buttonLists[i];
- while (list.count()) {
- QAbstractButton *button = list.takeAt(0);
- QObject::disconnect(button, SIGNAL(destroyed()), this, SLOT(_q_handleButtonDestroyed()));
- delete button;
- }
- }
-}
-
-/*!
- Returns a list of all the buttons that have been added to the button box.
-
- \sa buttonRole(), addButton(), removeButton()
-*/
-QList<QAbstractButton *> QDialogButtonBox::buttons() const
-{
- Q_D(const QDialogButtonBox);
- QList<QAbstractButton *> finalList;
- for (int i = 0; i < NRoles; ++i) {
- const QList<QAbstractButton *> &list = d->buttonLists[i];
- for (int j = 0; j < list.count(); ++j)
- finalList.append(list.at(j));
- }
- return finalList;
-}
-
-/*!
- Returns the button role for the specified \a button. This function returns
- \l InvalidRole if \a button is 0 or has not been added to the button box.
-
- \sa buttons(), addButton()
-*/
-QDialogButtonBox::ButtonRole QDialogButtonBox::buttonRole(QAbstractButton *button) const
-{
- Q_D(const QDialogButtonBox);
- for (int i = 0; i < NRoles; ++i) {
- const QList<QAbstractButton *> &list = d->buttonLists[i];
- for (int j = 0; j < list.count(); ++j) {
- if (list.at(j) == button)
- return ButtonRole(i);
- }
- }
- return InvalidRole;
-}
-
-/*!
- Removes \a button from the button box without deleting it and sets its parent to zero.
-
- \sa clear(), buttons(), addButton()
-*/
-void QDialogButtonBox::removeButton(QAbstractButton *button)
-{
- Q_D(QDialogButtonBox);
-
- if (!button)
- return;
-
- // Remove it from the standard button hash first and then from the roles
- if (QPushButton *pushButton = qobject_cast<QPushButton *>(button))
- d->standardButtonHash.remove(pushButton);
- for (int i = 0; i < NRoles; ++i) {
- QList<QAbstractButton *> &list = d->buttonLists[i];
- for (int j = 0; j < list.count(); ++j) {
- if (list.at(j) == button) {
- list.takeAt(j);
- if (!d->internalRemove) {
- disconnect(button, SIGNAL(clicked()), this, SLOT(_q_handleButtonClicked()));
- disconnect(button, SIGNAL(destroyed()), this, SLOT(_q_handleButtonDestroyed()));
- }
- break;
- }
- }
- }
-#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION)
- QAction *action = d->softKeyActions.value(button, 0);
- if (action) {
- d->softKeyActions.remove(button);
- delete action;
- }
-#endif
- if (!d->internalRemove)
- button->setParent(0);
-}
-
-/*!
- Adds the given \a button to the button box with the specified \a role.
- If the role is invalid, the button is not added.
-
- If the button has already been added, it is removed and added again with the
- new role.
-
- \note The button box takes ownership of the button.
-
- \sa removeButton(), clear()
-*/
-void QDialogButtonBox::addButton(QAbstractButton *button, ButtonRole role)
-{
- Q_D(QDialogButtonBox);
- if (role <= InvalidRole || role >= NRoles) {
- qWarning("QDialogButtonBox::addButton: Invalid ButtonRole, button not added");
- return;
- }
- removeButton(button);
- button->setParent(this);
- d->addButton(button, role);
-}
-
-/*!
- Creates a push button with the given \a text, adds it to the button box for the
- specified \a role, and returns the corresponding push button. If \a role is
- invalid, no button is created, and zero is returned.
-
- \sa removeButton(), clear()
-*/
-QPushButton *QDialogButtonBox::addButton(const QString &text, ButtonRole role)
-{
- Q_D(QDialogButtonBox);
- if (role <= InvalidRole || role >= NRoles) {
- qWarning("QDialogButtonBox::addButton: Invalid ButtonRole, button not added");
- return 0;
- }
- QPushButton *button = new QPushButton(text, this);
- d->addButton(button, role);
- return button;
-}
-
-/*!
- Adds a standard \a button to the button box if it is valid to do so, and returns
- a push button. If \a button is invalid, it is not added to the button box, and
- zero is returned.
-
- \sa removeButton(), clear()
-*/
-QPushButton *QDialogButtonBox::addButton(StandardButton button)
-{
- Q_D(QDialogButtonBox);
- return d->createButton(button);
-}
-
-/*!
- \property QDialogButtonBox::standardButtons
- \brief collection of standard buttons in the button box
-
- This property controls which standard buttons are used by the button box.
-
- \sa addButton()
-*/
-void QDialogButtonBox::setStandardButtons(StandardButtons buttons)
-{
- Q_D(QDialogButtonBox);
-#ifdef QT_SOFTKEYS_ENABLED
- // Delete softkey actions since they have the buttons as parents
- qDeleteAll(d->softKeyActions.values());
- d->softKeyActions.clear();
-#endif
- // Clear out all the old standard buttons, then recreate them.
- qDeleteAll(d->standardButtonHash.keys());
- d->standardButtonHash.clear();
-
- d->createStandardButtons(buttons);
-}
-
-QDialogButtonBox::StandardButtons QDialogButtonBox::standardButtons() const
-{
- Q_D(const QDialogButtonBox);
- StandardButtons standardButtons = NoButton;
- QHash<QPushButton *, StandardButton>::const_iterator it = d->standardButtonHash.constBegin();
- while (it != d->standardButtonHash.constEnd()) {
- standardButtons |= it.value();
- ++it;
- }
- return standardButtons;
-}
-
-/*!
- Returns the QPushButton corresponding to the standard button \a which,
- or 0 if the standard button doesn't exist in this button box.
-
- \sa standardButton(), standardButtons(), buttons()
-*/
-QPushButton *QDialogButtonBox::button(StandardButton which) const
-{
- Q_D(const QDialogButtonBox);
- return d->standardButtonHash.key(which);
-}
-
-/*!
- Returns the standard button enum value corresponding to the given \a button,
- or NoButton if the given \a button isn't a standard button.
-
- \sa button(), buttons(), standardButtons()
-*/
-QDialogButtonBox::StandardButton QDialogButtonBox::standardButton(QAbstractButton *button) const
-{
- Q_D(const QDialogButtonBox);
- return d->standardButtonHash.value(static_cast<QPushButton *>(button));
-}
-
-void QDialogButtonBoxPrivate::_q_handleButtonClicked()
-{
- Q_Q(QDialogButtonBox);
- if (QAbstractButton *button = qobject_cast<QAbstractButton *>(q->sender())) {
- emit q->clicked(button);
-
- switch (q->buttonRole(button)) {
- case AcceptRole:
- case YesRole:
- emit q->accepted();
- break;
- case RejectRole:
- case NoRole:
- emit q->rejected();
- break;
- case HelpRole:
- emit q->helpRequested();
- break;
- default:
- break;
- }
- }
-}
-
-void QDialogButtonBoxPrivate::_q_handleButtonDestroyed()
-{
- Q_Q(QDialogButtonBox);
- if (QObject *object = q->sender()) {
- QBoolBlocker skippy(internalRemove);
- q->removeButton(static_cast<QAbstractButton *>(object));
- }
-}
-
-/*!
- \property QDialogButtonBox::centerButtons
- \brief whether the buttons in the button box are centered
-
- By default, this property is false. This behavior is appopriate
- for most types of dialogs. A notable exception is message boxes
- on most platforms (e.g. Windows), where the button box is
- centered horizontally.
-
- \sa QMessageBox
-*/
-void QDialogButtonBox::setCenterButtons(bool center)
-{
- Q_D(QDialogButtonBox);
- if (d->center != center) {
- d->center = center;
- d->resetLayout();
- }
-}
-
-bool QDialogButtonBox::centerButtons() const
-{
- Q_D(const QDialogButtonBox);
- return d->center;
-}
-
-/*!
- \reimp
-*/
-void QDialogButtonBox::changeEvent(QEvent *event)
-{
- typedef QHash<QPushButton *, QDialogButtonBox::StandardButton> StandardButtonHash;
-
- Q_D(QDialogButtonBox);
- switch (event->type()) {
- case QEvent::StyleChange: // Propagate style
- if (!d->standardButtonHash.empty()) {
- QStyle *newStyle = style();
- const StandardButtonHash::iterator end = d->standardButtonHash.end();
- for (StandardButtonHash::iterator it = d->standardButtonHash.begin(); it != end; ++it)
- it.key()->setStyle(newStyle);
- }
- // fallthrough intended
-#ifdef Q_WS_MAC
- case QEvent::MacSizeChange:
-#endif
- d->resetLayout();
- QWidget::changeEvent(event);
- break;
- default:
- QWidget::changeEvent(event);
- break;
- }
-}
-
-/*!
- \reimp
-*/
-bool QDialogButtonBox::event(QEvent *event)
-{
- Q_D(QDialogButtonBox);
- if (event->type() == QEvent::Show) {
- QList<QAbstractButton *> acceptRoleList = d->buttonLists[AcceptRole];
- QPushButton *firstAcceptButton = acceptRoleList.isEmpty() ? 0 : qobject_cast<QPushButton *>(acceptRoleList.at(0));
- bool hasDefault = false;
- QWidget *dialog = 0;
- QWidget *p = this;
- while (p && !p->isWindow()) {
- p = p->parentWidget();
- if ((dialog = qobject_cast<QDialog *>(p)))
- break;
- }
-
- foreach (QPushButton *pb, (dialog ? dialog : this)->findChildren<QPushButton *>()) {
- if (pb->isDefault() && pb != firstAcceptButton) {
- hasDefault = true;
- break;
- }
- }
- if (!hasDefault && firstAcceptButton)
- firstAcceptButton->setDefault(true);
-#ifdef QT_SOFTKEYS_ENABLED
- if (dialog)
- setFixedSize(0,0);
-#endif
- }else if (event->type() == QEvent::LanguageChange) {
- d->retranslateStrings();
- }
-#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION)
- else if (event->type() == QEvent::ParentChange) {
- QWidget *dialog = 0;
- QWidget *p = this;
- while (p && !p->isWindow()) {
- p = p->parentWidget();
- if ((dialog = qobject_cast<QDialog *>(p)))
- break;
- }
-
- // If the parent changes, then move the softkeys
- for (QHash<QAbstractButton *, QAction *>::const_iterator it = d->softKeyActions.constBegin();
- it != d->softKeyActions.constEnd(); ++it) {
- QAction *current = it.value();
- QList<QWidget *> widgets = current->associatedWidgets();
- foreach (QWidget *w, widgets)
- w->removeAction(current);
- if (dialog)
- dialog->addAction(current);
- else
- addAction(current);
- }
- }
-#endif
-
- return QWidget::event(event);
-}
-
-QT_END_NAMESPACE
-
-#include "moc_qdialogbuttonbox.cpp"
diff --git a/src/gui/widgets/qdialogbuttonbox.h b/src/gui/widgets/qdialogbuttonbox.h
deleted file mode 100644
index 4e390134c4..0000000000
--- a/src/gui/widgets/qdialogbuttonbox.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDIALOGBUTTONBOX_H
-#define QDIALOGBUTTONBOX_H
-
-#include <QtGui/qwidget.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QAbstractButton;
-class QPushButton;
-class QDialogButtonBoxPrivate;
-
-class Q_GUI_EXPORT QDialogButtonBox : public QWidget
-{
- Q_OBJECT
- Q_FLAGS(StandardButtons)
- Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
- Q_PROPERTY(StandardButtons standardButtons READ standardButtons WRITE setStandardButtons)
- Q_PROPERTY(bool centerButtons READ centerButtons WRITE setCenterButtons)
-
-public:
- enum ButtonRole {
- // keep this in sync with QMessageBox::ButtonRole
- InvalidRole = -1,
- AcceptRole,
- RejectRole,
- DestructiveRole,
- ActionRole,
- HelpRole,
- YesRole,
- NoRole,
- ResetRole,
- ApplyRole,
-
- NRoles
- };
-
- enum StandardButton {
- // keep this in sync with QMessageBox::StandardButton
- NoButton = 0x00000000,
- Ok = 0x00000400,
- Save = 0x00000800,
- SaveAll = 0x00001000,
- Open = 0x00002000,
- Yes = 0x00004000,
- YesToAll = 0x00008000,
- No = 0x00010000,
- NoToAll = 0x00020000,
- Abort = 0x00040000,
- Retry = 0x00080000,
- Ignore = 0x00100000,
- Close = 0x00200000,
- Cancel = 0x00400000,
- Discard = 0x00800000,
- Help = 0x01000000,
- Apply = 0x02000000,
- Reset = 0x04000000,
- RestoreDefaults = 0x08000000,
-
-#ifndef Q_MOC_RUN
- FirstButton = Ok,
- LastButton = RestoreDefaults
-#endif
- };
-
- Q_DECLARE_FLAGS(StandardButtons, StandardButton)
-
- enum ButtonLayout {
- WinLayout,
- MacLayout,
- KdeLayout,
- GnomeLayout
- };
-
- QDialogButtonBox(QWidget *parent = 0);
- QDialogButtonBox(Qt::Orientation orientation, QWidget *parent = 0);
- QDialogButtonBox(StandardButtons buttons, Qt::Orientation orientation = Qt::Horizontal,
- QWidget *parent = 0);
- ~QDialogButtonBox();
-
- void setOrientation(Qt::Orientation orientation);
- Qt::Orientation orientation() const;
-
- void addButton(QAbstractButton *button, ButtonRole role);
- QPushButton *addButton(const QString &text, ButtonRole role);
- QPushButton *addButton(StandardButton button);
- void removeButton(QAbstractButton *button);
- void clear();
-
- QList<QAbstractButton *> buttons() const;
- ButtonRole buttonRole(QAbstractButton *button) const;
-
- void setStandardButtons(StandardButtons buttons);
- StandardButtons standardButtons() const;
- StandardButton standardButton(QAbstractButton *button) const;
- QPushButton *button(StandardButton which) const;
-
- void setCenterButtons(bool center);
- bool centerButtons() const;
-
-Q_SIGNALS:
- void clicked(QAbstractButton *button);
- void accepted();
- void helpRequested();
- void rejected();
-
-protected:
- void changeEvent(QEvent *event);
- bool event(QEvent *event);
-
-private:
- Q_DISABLE_COPY(QDialogButtonBox)
- Q_DECLARE_PRIVATE(QDialogButtonBox)
- Q_PRIVATE_SLOT(d_func(), void _q_handleButtonClicked())
- Q_PRIVATE_SLOT(d_func(), void _q_handleButtonDestroyed())
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QDialogButtonBox::StandardButtons)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDIALOGBUTTONBOX_H
diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp
deleted file mode 100644
index 28c0388078..0000000000
--- a/src/gui/widgets/qdockarealayout.cpp
+++ /dev/null
@@ -1,3329 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "QtGui/qapplication.h"
-#include "QtGui/qwidget.h"
-#include "QtGui/qtabbar.h"
-#include "QtGui/qstyle.h"
-#include "QtGui/qdesktopwidget.h"
-#include "QtCore/qvariant.h"
-#include "qdockarealayout_p.h"
-#include "qdockwidget.h"
-#include "qmainwindow.h"
-#include "qwidgetanimator_p.h"
-#include "qmainwindowlayout_p.h"
-#include "qdockwidget_p.h"
-#include <private/qlayoutengine_p.h>
-
-#include <qpainter.h>
-#include <qstyleoption.h>
-
-#ifndef QT_NO_DOCKWIDGET
-
-QT_BEGIN_NAMESPACE
-
-// qmainwindow.cpp
-extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window);
-
-enum { StateFlagVisible = 1, StateFlagFloating = 2 };
-
-/******************************************************************************
-** QPlaceHolderItem
-*/
-
-QPlaceHolderItem::QPlaceHolderItem(QWidget *w)
-{
- objectName = w->objectName();
- hidden = w->isHidden();
- window = w->isWindow();
- if (window)
- topLevelRect = w->geometry();
-}
-
-/******************************************************************************
-** QDockAreaLayoutItem
-*/
-
-QDockAreaLayoutItem::QDockAreaLayoutItem(QLayoutItem *_widgetItem)
- : widgetItem(_widgetItem), subinfo(0), placeHolderItem(0), pos(0), size(-1), flags(NoFlags)
-{
-}
-
-QDockAreaLayoutItem::QDockAreaLayoutItem(QDockAreaLayoutInfo *_subinfo)
- : widgetItem(0), subinfo(_subinfo), placeHolderItem(0), pos(0), size(-1), flags(NoFlags)
-{
-}
-
-QDockAreaLayoutItem::QDockAreaLayoutItem(QPlaceHolderItem *_placeHolderItem)
- : widgetItem(0), subinfo(0), placeHolderItem(_placeHolderItem), pos(0), size(-1), flags(NoFlags)
-{
-}
-
-QDockAreaLayoutItem::QDockAreaLayoutItem(const QDockAreaLayoutItem &other)
- : widgetItem(other.widgetItem), subinfo(0), placeHolderItem(0), pos(other.pos),
- size(other.size), flags(other.flags)
-{
- if (other.subinfo != 0)
- subinfo = new QDockAreaLayoutInfo(*other.subinfo);
- else if (other.placeHolderItem != 0)
- placeHolderItem = new QPlaceHolderItem(*other.placeHolderItem);
-}
-
-QDockAreaLayoutItem::~QDockAreaLayoutItem()
-{
- delete subinfo;
- delete placeHolderItem;
-}
-
-bool QDockAreaLayoutItem::skip() const
-{
- if (placeHolderItem != 0)
- return true;
-
- if (flags & GapItem)
- return false;
-
- if (widgetItem != 0)
- return widgetItem->isEmpty();
-
- if (subinfo != 0) {
- for (int i = 0; i < subinfo->item_list.count(); ++i) {
- if (!subinfo->item_list.at(i).skip())
- return false;
- }
- }
-
- return true;
-}
-
-QSize QDockAreaLayoutItem::minimumSize() const
-{
- if (widgetItem != 0) {
- int left, top, right, bottom;
- widgetItem->widget()->getContentsMargins(&left, &top, &right, &bottom);
- return widgetItem->minimumSize() + QSize(left+right, top+bottom);
- }
- if (subinfo != 0)
- return subinfo->minimumSize();
- return QSize(0, 0);
-}
-
-QSize QDockAreaLayoutItem::maximumSize() const
-{
- if (widgetItem != 0) {
- int left, top, right, bottom;
- widgetItem->widget()->getContentsMargins(&left, &top, &right, &bottom);
- return widgetItem->maximumSize()+ QSize(left+right, top+bottom);
- }
- if (subinfo != 0)
- return subinfo->maximumSize();
- return QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
-}
-
-bool QDockAreaLayoutItem::hasFixedSize(Qt::Orientation o) const
-{
- return perp(o, minimumSize()) == perp(o, maximumSize());
-}
-
-bool QDockAreaLayoutItem::expansive(Qt::Orientation o) const
-{
- if ((flags & GapItem) || placeHolderItem != 0)
- return false;
- if (widgetItem != 0)
- return ((widgetItem->expandingDirections() & o) == o);
- if (subinfo != 0)
- return subinfo->expansive(o);
- return false;
-}
-
-QSize QDockAreaLayoutItem::sizeHint() const
-{
- if (placeHolderItem != 0)
- return QSize(0, 0);
- if (widgetItem != 0) {
- int left, top, right, bottom;
- widgetItem->widget()->getContentsMargins(&left, &top, &right, &bottom);
- return widgetItem->sizeHint() + QSize(left+right, top+bottom);
- }
- if (subinfo != 0)
- return subinfo->sizeHint();
- return QSize(-1, -1);
-}
-
-QDockAreaLayoutItem
- &QDockAreaLayoutItem::operator = (const QDockAreaLayoutItem &other)
-{
- widgetItem = other.widgetItem;
- if (other.subinfo == 0)
- subinfo = 0;
- else
- subinfo = new QDockAreaLayoutInfo(*other.subinfo);
-
- delete placeHolderItem;
- if (other.placeHolderItem == 0)
- placeHolderItem = 0;
- else
- placeHolderItem = new QPlaceHolderItem(*other.placeHolderItem);
-
- pos = other.pos;
- size = other.size;
- flags = other.flags;
-
- return *this;
-}
-
-/******************************************************************************
-** QDockAreaLayoutInfo
-*/
-
-#ifndef QT_NO_TABBAR
-static quintptr tabId(const QDockAreaLayoutItem &item)
-{
- if (item.widgetItem == 0)
- return 0;
- return reinterpret_cast<quintptr>(item.widgetItem->widget());
-}
-#endif
-
-static const int zero = 0;
-
-QDockAreaLayoutInfo::QDockAreaLayoutInfo()
- : sep(&zero), dockPos(QInternal::LeftDock), o(Qt::Horizontal), mainWindow(0)
-#ifndef QT_NO_TABBAR
- , tabbed(false), tabBar(0), tabBarShape(QTabBar::RoundedSouth)
-#endif
-{
-}
-
-QDockAreaLayoutInfo::QDockAreaLayoutInfo(const int *_sep, QInternal::DockPosition _dockPos,
- Qt::Orientation _o, int tbshape,
- QMainWindow *window)
- : sep(_sep), dockPos(_dockPos), o(_o), mainWindow(window)
-#ifndef QT_NO_TABBAR
- , tabbed(false), tabBar(0), tabBarShape(static_cast<QTabBar::Shape>(tbshape))
-#endif
-{
-#ifdef QT_NO_TABBAR
- Q_UNUSED(tbshape);
-#endif
-}
-
-QSize QDockAreaLayoutInfo::size() const
-{
- return isEmpty() ? QSize(0, 0) : rect.size();
-}
-
-void QDockAreaLayoutInfo::clear()
-{
- item_list.clear();
- rect = QRect();
-#ifndef QT_NO_TABBAR
- tabbed = false;
- tabBar = 0;
-#endif
-}
-
-bool QDockAreaLayoutInfo::isEmpty() const
-{
- return next(-1) == -1;
-}
-
-QSize QDockAreaLayoutInfo::minimumSize() const
-{
- if (isEmpty())
- return QSize(0, 0);
-
- int a = 0, b = 0;
- bool first = true;
- for (int i = 0; i < item_list.size(); ++i) {
- const QDockAreaLayoutItem &item = item_list.at(i);
- if (item.skip())
- continue;
-
- QSize min_size = item.minimumSize();
-#ifndef QT_NO_TABBAR
- if (tabbed) {
- a = qMax(a, pick(o, min_size));
- } else
-#endif
- {
- if (!first)
- a += *sep;
- a += pick(o, min_size);
- }
- b = qMax(b, perp(o, min_size));
-
- first = false;
- }
-
- QSize result;
- rpick(o, result) = a;
- rperp(o, result) = b;
-
-#ifndef QT_NO_TABBAR
- QSize tbm = tabBarMinimumSize();
- if (!tbm.isNull()) {
- switch (tabBarShape) {
- case QTabBar::RoundedNorth:
- case QTabBar::RoundedSouth:
- case QTabBar::TriangularNorth:
- case QTabBar::TriangularSouth:
- result.rheight() += tbm.height();
- result.rwidth() = qMax(tbm.width(), result.width());
- break;
- case QTabBar::RoundedEast:
- case QTabBar::RoundedWest:
- case QTabBar::TriangularEast:
- case QTabBar::TriangularWest:
- result.rheight() = qMax(tbm.height(), result.height());
- result.rwidth() += tbm.width();
- break;
- default:
- break;
- }
- }
-#endif // QT_NO_TABBAR
-
- return result;
-}
-
-QSize QDockAreaLayoutInfo::maximumSize() const
-{
- if (isEmpty())
- return QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
-
- int a = 0, b = QWIDGETSIZE_MAX;
-#ifndef QT_NO_TABBAR
- if (tabbed)
- a = QWIDGETSIZE_MAX;
-#endif
-
- int min_perp = 0;
-
- bool first = true;
- for (int i = 0; i < item_list.size(); ++i) {
- const QDockAreaLayoutItem &item = item_list.at(i);
- if (item.skip())
- continue;
-
- QSize max_size = item.maximumSize();
- min_perp = qMax(min_perp, perp(o, item.minimumSize()));
-
-#ifndef QT_NO_TABBAR
- if (tabbed) {
- a = qMin(a, pick(o, max_size));
- } else
-#endif
- {
- if (!first)
- a += *sep;
- a += pick(o, max_size);
- }
- b = qMin(b, perp(o, max_size));
-
- a = qMin(a, int(QWIDGETSIZE_MAX));
- b = qMin(b, int(QWIDGETSIZE_MAX));
-
- first = false;
- }
-
- b = qMax(b, min_perp);
-
- QSize result;
- rpick(o, result) = a;
- rperp(o, result) = b;
-
-#ifndef QT_NO_TABBAR
- QSize tbh = tabBarSizeHint();
- if (!tbh.isNull()) {
- switch (tabBarShape) {
- case QTabBar::RoundedNorth:
- case QTabBar::RoundedSouth:
- result.rheight() += tbh.height();
- break;
- case QTabBar::RoundedEast:
- case QTabBar::RoundedWest:
- result.rwidth() += tbh.width();
- break;
- default:
- break;
- }
- }
-#endif // QT_NO_TABBAR
-
- return result;
-}
-
-QSize QDockAreaLayoutInfo::sizeHint() const
-{
- if (isEmpty())
- return QSize(0, 0);
-
- int a = 0, b = 0;
- int min_perp = 0;
- int max_perp = QWIDGETSIZE_MAX;
- const QDockAreaLayoutItem *previous = 0;
- for (int i = 0; i < item_list.size(); ++i) {
- const QDockAreaLayoutItem &item = item_list.at(i);
- if (item.skip())
- continue;
-
- bool gap = item.flags & QDockAreaLayoutItem::GapItem;
-
- QSize size_hint = item.sizeHint();
- min_perp = qMax(min_perp, perp(o, item.minimumSize()));
- max_perp = qMin(max_perp, perp(o, item.maximumSize()));
-
-#ifndef QT_NO_TABBAR
- if (tabbed) {
- a = qMax(a, gap ? item.size : pick(o, size_hint));
- } else
-#endif
- {
- if (previous && !gap && !(previous->flags & QDockAreaLayoutItem::GapItem)
- && !previous->hasFixedSize(o)) {
- a += *sep;
- }
- a += gap ? item.size : pick(o, size_hint);
- }
- b = qMax(b, perp(o, size_hint));
-
- previous = &item;
- }
-
- max_perp = qMax(max_perp, min_perp);
- b = qMax(b, min_perp);
- b = qMin(b, max_perp);
-
- QSize result;
- rpick(o, result) = a;
- rperp(o, result) = b;
-
-#ifndef QT_NO_TABBAR
- if (tabbed) {
- QSize tbh = tabBarSizeHint();
- switch (tabBarShape) {
- case QTabBar::RoundedNorth:
- case QTabBar::RoundedSouth:
- case QTabBar::TriangularNorth:
- case QTabBar::TriangularSouth:
- result.rheight() += tbh.height();
- result.rwidth() = qMax(tbh.width(), result.width());
- break;
- case QTabBar::RoundedEast:
- case QTabBar::RoundedWest:
- case QTabBar::TriangularEast:
- case QTabBar::TriangularWest:
- result.rheight() = qMax(tbh.height(), result.height());
- result.rwidth() += tbh.width();
- break;
- default:
- break;
- }
- }
-#endif // QT_NO_TABBAR
-
- return result;
-}
-
-bool QDockAreaLayoutInfo::expansive(Qt::Orientation o) const
-{
- for (int i = 0; i < item_list.size(); ++i) {
- if (item_list.at(i).expansive(o))
- return true;
- }
- return false;
-}
-
-/* QDockAreaLayoutInfo::maximumSize() doesn't return the real max size. For example,
- if the layout is empty, it returns QWIDGETSIZE_MAX. This is so that empty dock areas
- don't constrain the size of the QMainWindow, but sometimes we really need to know the
- maximum size. Also, these functions take into account widgets that want to keep their
- size (f.ex. when they are hidden and then shown, they should not change size).
-*/
-
-static int realMinSize(const QDockAreaLayoutInfo &info)
-{
- int result = 0;
- bool first = true;
- for (int i = 0; i < info.item_list.size(); ++i) {
- const QDockAreaLayoutItem &item = info.item_list.at(i);
- if (item.skip())
- continue;
-
- int min = 0;
- if ((item.flags & QDockAreaLayoutItem::KeepSize) && item.size != -1)
- min = item.size;
- else
- min = pick(info.o, item.minimumSize());
-
- if (!first)
- result += *info.sep;
- result += min;
-
- first = false;
- }
-
- return result;
-}
-
-static int realMaxSize(const QDockAreaLayoutInfo &info)
-{
- int result = 0;
- bool first = true;
- for (int i = 0; i < info.item_list.size(); ++i) {
- const QDockAreaLayoutItem &item = info.item_list.at(i);
- if (item.skip())
- continue;
-
- int max = 0;
- if ((item.flags & QDockAreaLayoutItem::KeepSize) && item.size != -1)
- max = item.size;
- else
- max = pick(info.o, item.maximumSize());
-
- if (!first)
- result += *info.sep;
- result += max;
-
- if (result >= QWIDGETSIZE_MAX)
- return QWIDGETSIZE_MAX;
-
- first = false;
- }
-
- return result;
-}
-
-void QDockAreaLayoutInfo::fitItems()
-{
-#ifndef QT_NO_TABBAR
- if (tabbed) {
- return;
- }
-#endif
-
- QVector<QLayoutStruct> layout_struct_list(item_list.size()*2);
- int j = 0;
-
- int size = pick(o, rect.size());
- int min_size = realMinSize(*this);
- int max_size = realMaxSize(*this);
- int last_index = -1;
-
- const QDockAreaLayoutItem *previous = 0;
- for (int i = 0; i < item_list.size(); ++i) {
- QDockAreaLayoutItem &item = item_list[i];
- if (item.skip())
- continue;
-
- bool gap = item.flags & QDockAreaLayoutItem::GapItem;
- if (previous && !gap) {
- if (!(previous->flags & QDockAreaLayoutItem::GapItem)) {
- QLayoutStruct &ls = layout_struct_list[j++];
- ls.init();
- ls.minimumSize = ls.maximumSize = ls.sizeHint = previous->hasFixedSize(o) ? 0 : *sep;
- ls.empty = false;
- }
- }
-
- if (item.flags & QDockAreaLayoutItem::KeepSize) {
- // Check if the item can keep its size, without violating size constraints
- // of other items.
-
- if (size < min_size) {
- // There is too little space to keep this widget's size
- item.flags &= ~QDockAreaLayoutItem::KeepSize;
- min_size -= item.size;
- min_size += pick(o, item.minimumSize());
- min_size = qMax(0, min_size);
- } else if (size > max_size) {
- // There is too much space to keep this widget's size
- item.flags &= ~QDockAreaLayoutItem::KeepSize;
- max_size -= item.size;
- max_size += pick(o, item.maximumSize());
- max_size = qMin<int>(QWIDGETSIZE_MAX, max_size);
- }
- }
-
- last_index = j;
- QLayoutStruct &ls = layout_struct_list[j++];
- ls.init();
- ls.empty = false;
- if (item.flags & QDockAreaLayoutItem::KeepSize) {
- ls.minimumSize = ls.maximumSize = ls.sizeHint = item.size;
- ls.expansive = false;
- ls.stretch = 0;
- } else {
- ls.maximumSize = pick(o, item.maximumSize());
- ls.expansive = item.expansive(o);
- ls.minimumSize = pick(o, item.minimumSize());
- ls.sizeHint = item.size == -1 ? pick(o, item.sizeHint()) : item.size;
- ls.stretch = ls.expansive ? ls.sizeHint : 0;
- }
-
- item.flags &= ~QDockAreaLayoutItem::KeepSize;
- previous = &item;
- }
- layout_struct_list.resize(j);
-
- // If there is more space than the widgets can take (due to maximum size constraints),
- // we detect it here and stretch the last widget to take up the rest of the space.
- if (size > max_size && last_index != -1) {
- layout_struct_list[last_index].maximumSize = QWIDGETSIZE_MAX;
- layout_struct_list[last_index].expansive = true;
- }
-
- qGeomCalc(layout_struct_list, 0, j, pick(o, rect.topLeft()), size, 0);
-
- j = 0;
- bool prev_gap = false;
- bool first = true;
- for (int i = 0; i < item_list.size(); ++i) {
- QDockAreaLayoutItem &item = item_list[i];
- if (item.skip())
- continue;
-
- bool gap = item.flags & QDockAreaLayoutItem::GapItem;
- if (!first && !gap && !prev_gap)
- ++j;
-
- const QLayoutStruct &ls = layout_struct_list.at(j++);
- item.size = ls.size;
- item.pos = ls.pos;
-
- if (item.subinfo != 0) {
- item.subinfo->rect = itemRect(i);
- item.subinfo->fitItems();
- }
-
- prev_gap = gap;
- first = false;
- }
-}
-
-static QInternal::DockPosition dockPosHelper(const QRect &rect, const QPoint &_pos,
- Qt::Orientation o,
- bool nestingEnabled,
- QDockAreaLayoutInfo::TabMode tabMode)
-{
- if (tabMode == QDockAreaLayoutInfo::ForceTabs)
- return QInternal::DockCount;
-
- QPoint pos = _pos - rect.topLeft();
-
- int x = pos.x();
- int y = pos.y();
- int w = rect.width();
- int h = rect.height();
-
- if (tabMode != QDockAreaLayoutInfo::NoTabs) {
- // is it in the center?
- if (nestingEnabled) {
- /* 2/3
- +--------------+
- | |
- | CCCCCCCC |
- 2/3 | CCCCCCCC |
- | CCCCCCCC |
- | |
- +--------------+ */
-
- QRect center(w/6, h/6, 2*w/3, 2*h/3);
- if (center.contains(pos))
- return QInternal::DockCount;
- } else if (o == Qt::Horizontal) {
- /* 2/3
- +--------------+
- | CCCCCCCC |
- | CCCCCCCC |
- | CCCCCCCC |
- | CCCCCCCC |
- | CCCCCCCC |
- +--------------+ */
-
- if (x > w/6 && x < w*5/6)
- return QInternal::DockCount;
- } else {
- /*
- +--------------+
- | |
- 2/3 |CCCCCCCCCCCCCC|
- |CCCCCCCCCCCCCC|
- | |
- +--------------+ */
- if (y > h/6 && y < 5*h/6)
- return QInternal::DockCount;
- }
- }
-
- // not in the center. which edge?
- if (nestingEnabled) {
- if (o == Qt::Horizontal) {
- /* 1/3 1/3 1/3
- +------------+ (we've already ruled out the center)
- |LLLLTTTTRRRR|
- |LLLLTTTTRRRR|
- |LLLLBBBBRRRR|
- |LLLLBBBBRRRR|
- +------------+ */
-
- if (x < w/3)
- return QInternal::LeftDock;
- if (x > 2*w/3)
- return QInternal::RightDock;
- if (y < h/2)
- return QInternal::TopDock;
- return QInternal::BottomDock;
- } else {
- /* +------------+ (we've already ruled out the center)
- 1/3 |TTTTTTTTTTTT|
- |LLLLLLRRRRRR|
- 1/3 |LLLLLLRRRRRR|
- 1/3 |BBBBBBBBBBBB|
- +------------+ */
-
- if (y < h/3)
- return QInternal::TopDock;
- if (y > 2*h/3)
- return QInternal::BottomDock;
- if (x < w/2)
- return QInternal::LeftDock;
- return QInternal::RightDock;
- }
- } else {
- if (o == Qt::Horizontal) {
- return x < w/2
- ? QInternal::LeftDock
- : QInternal::RightDock;
- } else {
- return y < h/2
- ? QInternal::TopDock
- : QInternal::BottomDock;
- }
- }
-}
-
-QList<int> QDockAreaLayoutInfo::gapIndex(const QPoint& _pos,
- bool nestingEnabled, TabMode tabMode) const
-{
- QList<int> result;
- QRect item_rect;
- int item_index = 0;
-
-#ifndef QT_NO_TABBAR
- if (tabbed) {
- item_rect = tabContentRect();
- } else
-#endif
- {
- int pos = pick(o, _pos);
-
- int last = -1;
- for (int i = 0; i < item_list.size(); ++i) {
- const QDockAreaLayoutItem &item = item_list.at(i);
- if (item.skip())
- continue;
-
- last = i;
-
- if (item.pos + item.size < pos)
- continue;
-
- if (item.subinfo != 0
-#ifndef QT_NO_TABBAR
- && !item.subinfo->tabbed
-#endif
- ) {
- result = item.subinfo->gapIndex(_pos, nestingEnabled,
- tabMode);
- result.prepend(i);
- return result;
- }
-
- item_rect = itemRect(i);
- item_index = i;
- break;
- }
-
- if (item_rect.isNull()) {
- result.append(last + 1);
- return result;
- }
- }
-
- Q_ASSERT(!item_rect.isNull());
-
- QInternal::DockPosition dock_pos
- = dockPosHelper(item_rect, _pos, o, nestingEnabled, tabMode);
-
- switch (dock_pos) {
- case QInternal::LeftDock:
- if (o == Qt::Horizontal)
- result << item_index;
- else
- result << item_index << 0; // this subinfo doesn't exist yet, but insertGap()
- // handles this by inserting it
- break;
- case QInternal::RightDock:
- if (o == Qt::Horizontal)
- result << item_index + 1;
- else
- result << item_index << 1;
- break;
- case QInternal::TopDock:
- if (o == Qt::Horizontal)
- result << item_index << 0;
- else
- result << item_index;
- break;
- case QInternal::BottomDock:
- if (o == Qt::Horizontal)
- result << item_index << 1;
- else
- result << item_index + 1;
- break;
- case QInternal::DockCount:
- result << (-item_index - 1) << 0; // negative item_index means "on top of"
- // -item_index - 1, insertGap()
- // will insert a tabbed subinfo
- break;
- default:
- break;
- }
-
- return result;
-}
-
-static inline int shrink(QLayoutStruct &ls, int delta)
-{
- if (ls.empty)
- return 0;
- int old_size = ls.size;
- ls.size = qMax(ls.size - delta, ls.minimumSize);
- return old_size - ls.size;
-}
-
-static inline int grow(QLayoutStruct &ls, int delta)
-{
- if (ls.empty)
- return 0;
- int old_size = ls.size;
- ls.size = qMin(ls.size + delta, ls.maximumSize);
- return ls.size - old_size;
-}
-
-static int separatorMoveHelper(QVector<QLayoutStruct> &list, int index, int delta, int sep)
-{
- // adjust sizes
- int pos = -1;
- for (int i = 0; i < list.size(); ++i) {
- const QLayoutStruct &ls = list.at(i);
- if (!ls.empty) {
- pos = ls.pos;
- break;
- }
- }
- if (pos == -1)
- return 0;
-
- if (delta > 0) {
- int growlimit = 0;
- for (int i = 0; i<=index; ++i) {
- const QLayoutStruct &ls = list.at(i);
- if (ls.empty)
- continue;
- if (ls.maximumSize == QLAYOUTSIZE_MAX) {
- growlimit = QLAYOUTSIZE_MAX;
- break;
- }
- growlimit += ls.maximumSize - ls.size;
- }
- if (delta > growlimit)
- delta = growlimit;
-
- int d = 0;
- for (int i = index + 1; d < delta && i < list.count(); ++i)
- d += shrink(list[i], delta - d);
- delta = d;
- d = 0;
- for (int i = index; d < delta && i >= 0; --i)
- d += grow(list[i], delta - d);
- } else if (delta < 0) {
- int growlimit = 0;
- for (int i = index + 1; i < list.count(); ++i) {
- const QLayoutStruct &ls = list.at(i);
- if (ls.empty)
- continue;
- if (ls.maximumSize == QLAYOUTSIZE_MAX) {
- growlimit = QLAYOUTSIZE_MAX;
- break;
- }
- growlimit += ls.maximumSize - ls.size;
- }
- if (-delta > growlimit)
- delta = -growlimit;
-
- int d = 0;
- for (int i = index; d < -delta && i >= 0; --i)
- d += shrink(list[i], -delta - d);
- delta = -d;
- d = 0;
- for (int i = index + 1; d < -delta && i < list.count(); ++i)
- d += grow(list[i], -delta - d);
- }
-
- // adjust positions
- bool first = true;
- for (int i = 0; i < list.size(); ++i) {
- QLayoutStruct &ls = list[i];
- if (ls.empty) {
- ls.pos = pos + (first ? 0 : sep);
- continue;
- }
- if (!first)
- pos += sep;
- ls.pos = pos;
- pos += ls.size;
- first = false;
- }
-
- return delta;
-}
-
-int QDockAreaLayoutInfo::separatorMove(int index, int delta)
-{
-#ifndef QT_NO_TABBAR
- Q_ASSERT(!tabbed);
-#endif
-
- QVector<QLayoutStruct> list(item_list.size());
- for (int i = 0; i < list.size(); ++i) {
- const QDockAreaLayoutItem &item = item_list.at(i);
- QLayoutStruct &ls = list[i];
- Q_ASSERT(!(item.flags & QDockAreaLayoutItem::GapItem));
- if (item.skip()) {
- ls.empty = true;
- } else {
- const int separatorSpace = item.hasFixedSize(o) ? 0 : *sep;
- ls.empty = false;
- ls.pos = item.pos;
- ls.size = item.size + separatorSpace;
- ls.minimumSize = pick(o, item.minimumSize()) + separatorSpace;
- ls.maximumSize = pick(o, item.maximumSize()) + separatorSpace;
-
- }
- }
-
- //the separator space has been added to the size, so we pass 0 as a parameter
- delta = separatorMoveHelper(list, index, delta, 0 /*separator*/);
-
- for (int i = 0; i < list.size(); ++i) {
- QDockAreaLayoutItem &item = item_list[i];
- if (item.skip())
- continue;
- QLayoutStruct &ls = list[i];
- const int separatorSpace = item.hasFixedSize(o) ? 0 : *sep;
- item.size = ls.size - separatorSpace;
- item.pos = ls.pos;
- if (item.subinfo != 0) {
- item.subinfo->rect = itemRect(i);
- item.subinfo->fitItems();
- }
- }
-
- return delta;
-}
-
-void QDockAreaLayoutInfo::unnest(int index)
-{
- QDockAreaLayoutItem &item = item_list[index];
- if (item.subinfo == 0)
- return;
- if (item.subinfo->item_list.count() > 1)
- return;
-
- if (item.subinfo->item_list.count() == 0) {
- item_list.removeAt(index);
- } else if (item.subinfo->item_list.count() == 1) {
- QDockAreaLayoutItem &child = item.subinfo->item_list.first();
- if (child.widgetItem != 0) {
- item.widgetItem = child.widgetItem;
- delete item.subinfo;
- item.subinfo = 0;
- } else if (child.subinfo != 0) {
- QDockAreaLayoutInfo *tmp = item.subinfo;
- item.subinfo = child.subinfo;
- child.subinfo = 0;
- tmp->item_list.clear();
- delete tmp;
- }
- }
-}
-
-void QDockAreaLayoutInfo::remove(const QList<int> &path)
-{
- Q_ASSERT(!path.isEmpty());
-
- if (path.count() > 1) {
- const int index = path.first();
- QDockAreaLayoutItem &item = item_list[index];
- Q_ASSERT(item.subinfo != 0);
- item.subinfo->remove(path.mid(1));
- unnest(index);
- } else {
- int index = path.first();
- item_list.removeAt(index);
- }
-}
-
-QLayoutItem *QDockAreaLayoutInfo::plug(const QList<int> &path)
-{
- Q_ASSERT(!path.isEmpty());
-
- int index = path.first();
- if (index < 0)
- index = -index - 1;
-
- if (path.count() > 1) {
- const QDockAreaLayoutItem &item = item_list.at(index);
- Q_ASSERT(item.subinfo != 0);
- return item.subinfo->plug(path.mid(1));
- }
-
- QDockAreaLayoutItem &item = item_list[index];
-
- Q_ASSERT(item.widgetItem != 0);
- Q_ASSERT(item.flags & QDockAreaLayoutItem::GapItem);
- item.flags &= ~QDockAreaLayoutItem::GapItem;
-
- QRect result;
-
-#ifndef QT_NO_TABBAR
- if (tabbed) {
- } else
-#endif
- {
- int prev = this->prev(index);
- int next = this->next(index);
-
- if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) {
- item.pos += *sep;
- item.size -= *sep;
- }
- if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
- item.size -= *sep;
-
- QPoint pos;
- rpick(o, pos) = item.pos;
- rperp(o, pos) = perp(o, rect.topLeft());
- QSize s;
- rpick(o, s) = item.size;
- rperp(o, s) = perp(o, rect.size());
- result = QRect(pos, s);
- }
-
- return item.widgetItem;
-}
-
-QLayoutItem *QDockAreaLayoutInfo::unplug(const QList<int> &path)
-{
- Q_ASSERT(!path.isEmpty());
-
- const int index = path.first();
- if (path.count() > 1) {
- const QDockAreaLayoutItem &item = item_list.at(index);
- Q_ASSERT(item.subinfo != 0);
- return item.subinfo->unplug(path.mid(1));
- }
-
- QDockAreaLayoutItem &item = item_list[index];
- int prev = this->prev(index);
- int next = this->next(index);
-
- Q_ASSERT(!(item.flags & QDockAreaLayoutItem::GapItem));
- item.flags |= QDockAreaLayoutItem::GapItem;
-
-#ifndef QT_NO_TABBAR
- if (tabbed) {
- } else
-#endif
- {
- if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) {
- item.pos -= *sep;
- item.size += *sep;
- }
- if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
- item.size += *sep;
- }
-
- return item.widgetItem;
-}
-
-#ifndef QT_NO_TABBAR
-
-quintptr QDockAreaLayoutInfo::currentTabId() const
-{
- if (!tabbed || tabBar == 0)
- return 0;
-
- int index = tabBar->currentIndex();
- if (index == -1)
- return 0;
-
- return qvariant_cast<quintptr>(tabBar->tabData(index));
-}
-
-void QDockAreaLayoutInfo::setCurrentTab(QWidget *widget)
-{
- setCurrentTabId(reinterpret_cast<quintptr>(widget));
-}
-
-void QDockAreaLayoutInfo::setCurrentTabId(quintptr id)
-{
- if (!tabbed || tabBar == 0)
- return;
-
- for (int i = 0; i < tabBar->count(); ++i) {
- if (qvariant_cast<quintptr>(tabBar->tabData(i)) == id) {
- tabBar->setCurrentIndex(i);
- return;
- }
- }
-}
-
-#endif // QT_NO_TABBAR
-
-static QRect dockedGeometry(QWidget *widget)
-{
- int titleHeight = 0;
-
- QDockWidgetLayout *layout
- = qobject_cast<QDockWidgetLayout*>(widget->layout());
- if(layout != 0 && layout->nativeWindowDeco())
- titleHeight = layout->titleHeight();
-
- QRect result = widget->geometry();
- result.adjust(0, -titleHeight, 0, 0);
- return result;
-}
-
-bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWidgetItem)
-{
- Q_ASSERT(!path.isEmpty());
-
- bool insert_tabbed = false;
- int index = path.first();
- if (index < 0) {
- insert_tabbed = true;
- index = -index - 1;
- }
-
-// dump(qDebug() << "insertGap() before:" << index << tabIndex, *this, QString());
-
- if (path.count() > 1) {
- QDockAreaLayoutItem &item = item_list[index];
-
- if (item.subinfo == 0
-#ifndef QT_NO_TABBAR
- || (item.subinfo->tabbed && !insert_tabbed)
-#endif
- ) {
-
- // this is not yet a nested layout - make it
-
- QDockAreaLayoutInfo *subinfo = item.subinfo;
- QLayoutItem *widgetItem = item.widgetItem;
- QPlaceHolderItem *placeHolderItem = item.placeHolderItem;
- QRect r = subinfo == 0 ? widgetItem ? dockedGeometry(widgetItem->widget()) : placeHolderItem->topLevelRect : subinfo->rect;
-
- Qt::Orientation opposite = o == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal;
-#ifdef QT_NO_TABBAR
- const int tabBarShape = 0;
-#endif
- QDockAreaLayoutInfo *new_info
- = new QDockAreaLayoutInfo(sep, dockPos, opposite, tabBarShape, mainWindow);
-
- //item become a new top-level
- item.subinfo = new_info;
- item.widgetItem = 0;
- item.placeHolderItem = 0;
-
- QDockAreaLayoutItem new_item
- = widgetItem == 0
- ? QDockAreaLayoutItem(subinfo)
- : widgetItem ? QDockAreaLayoutItem(widgetItem) : QDockAreaLayoutItem(placeHolderItem);
- new_item.size = pick(opposite, r.size());
- new_item.pos = pick(opposite, r.topLeft());
- new_info->item_list.append(new_item);
-#ifndef QT_NO_TABBAR
- if (insert_tabbed) {
- new_info->tabbed = true;
- }
-#endif
- }
-
- return item.subinfo->insertGap(path.mid(1), dockWidgetItem);
- }
-
- // create the gap item
- QDockAreaLayoutItem gap_item;
- gap_item.flags |= QDockAreaLayoutItem::GapItem;
- gap_item.widgetItem = dockWidgetItem; // so minimumSize(), maximumSize() and
- // sizeHint() will work
-#ifndef QT_NO_TABBAR
- if (!tabbed)
-#endif
- {
- int prev = this->prev(index);
- int next = this->next(index - 1);
- // find out how much space we have in the layout
- int space = 0;
- if (isEmpty()) {
- // I am an empty dock area, therefore I am a top-level dock area.
- switch (dockPos) {
- case QInternal::LeftDock:
- case QInternal::RightDock:
- if (o == Qt::Vertical) {
- // the "size" is the height of the dock area (remember we are empty)
- space = pick(Qt::Vertical, rect.size());
- } else {
- space = pick(Qt::Horizontal, dockWidgetItem->widget()->size());
- }
- break;
- case QInternal::TopDock:
- case QInternal::BottomDock:
- default:
- if (o == Qt::Horizontal) {
- // the "size" is width of the dock area
- space = pick(Qt::Horizontal, rect.size());
- } else {
- space = pick(Qt::Vertical, dockWidgetItem->widget()->size());
- }
- break;
- }
- } else {
- for (int i = 0; i < item_list.count(); ++i) {
- const QDockAreaLayoutItem &item = item_list.at(i);
- if (item.skip())
- continue;
- Q_ASSERT(!(item.flags & QDockAreaLayoutItem::GapItem));
- space += item.size - pick(o, item.minimumSize());
- }
- }
-
- // find the actual size of the gap
- int gap_size = 0;
- int sep_size = 0;
- if (isEmpty()) {
- gap_size = space;
- sep_size = 0;
- } else {
- QRect r = dockedGeometry(dockWidgetItem->widget());
- gap_size = pick(o, r.size());
- if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem))
- sep_size += *sep;
- if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
- sep_size += *sep;
- }
- if (gap_size + sep_size > space)
- gap_size = pick(o, gap_item.minimumSize());
- gap_item.size = gap_size + sep_size;
- }
-
- // finally, insert the gap
- item_list.insert(index, gap_item);
-
-// dump(qDebug() << "insertGap() after:" << index << tabIndex, *this, QString());
-
- return true;
-}
-
-QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(QWidget *widget)
-{
- for (int i = 0; i < item_list.count(); ++i) {
- const QDockAreaLayoutItem &item = item_list.at(i);
- if (item.skip())
- continue;
-
-#ifndef QT_NO_TABBAR
- if (tabbed && widget == tabBar)
- return this;
-#endif
-
- if (item.widgetItem != 0 && item.widgetItem->widget() == widget)
- return this;
-
- if (item.subinfo != 0) {
- if (QDockAreaLayoutInfo *result = item.subinfo->info(widget))
- return result;
- }
- }
-
- return 0;
-}
-
-QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(const QList<int> &path)
-{
- int index = path.first();
- if (index < 0)
- index = -index - 1;
- if (index >= item_list.count())
- return this;
- if (path.count() == 1 || item_list[index].subinfo == 0)
- return this;
- return item_list[index].subinfo->info(path.mid(1));
-}
-
-QRect QDockAreaLayoutInfo::itemRect(int index) const
-{
- const QDockAreaLayoutItem &item = item_list.at(index);
-
- if (item.skip())
- return QRect();
-
- QRect result;
-
-#ifndef QT_NO_TABBAR
- if (tabbed) {
- if (tabId(item) == currentTabId())
- result = tabContentRect();
- } else
-#endif
- {
- QPoint pos;
- rpick(o, pos) = item.pos;
- rperp(o, pos) = perp(o, rect.topLeft());
- QSize s;
- rpick(o, s) = item.size;
- rperp(o, s) = perp(o, rect.size());
- result = QRect(pos, s);
- }
-
- return result;
-}
-
-QRect QDockAreaLayoutInfo::itemRect(const QList<int> &path) const
-{
- Q_ASSERT(!path.isEmpty());
-
- const int index = path.first();
- if (path.count() > 1) {
- const QDockAreaLayoutItem &item = item_list.at(index);
- Q_ASSERT(item.subinfo != 0);
- return item.subinfo->itemRect(path.mid(1));
- }
-
- return itemRect(index);
-}
-
-QRect QDockAreaLayoutInfo::separatorRect(int index) const
-{
-#ifndef QT_NO_TABBAR
- if (tabbed)
- return QRect();
-#endif
-
- const QDockAreaLayoutItem &item = item_list.at(index);
- if (item.skip())
- return QRect();
-
- QPoint pos = rect.topLeft();
- rpick(o, pos) = item.pos + item.size;
- QSize s = rect.size();
- rpick(o, s) = *sep;
-
- return QRect(pos, s);
-}
-
-QRect QDockAreaLayoutInfo::separatorRect(const QList<int> &path) const
-{
- Q_ASSERT(!path.isEmpty());
-
- const int index = path.first();
- if (path.count() > 1) {
- const QDockAreaLayoutItem &item = item_list.at(index);
- Q_ASSERT(item.subinfo != 0);
- return item.subinfo->separatorRect(path.mid(1));
- }
- return separatorRect(index);
-}
-
-QList<int> QDockAreaLayoutInfo::findSeparator(const QPoint &_pos) const
-{
-#ifndef QT_NO_TABBAR
- if (tabbed)
- return QList<int>();
-#endif
-
- int pos = pick(o, _pos);
-
- for (int i = 0; i < item_list.size(); ++i) {
- const QDockAreaLayoutItem &item = item_list.at(i);
- if (item.skip() || (item.flags & QDockAreaLayoutItem::GapItem))
- continue;
-
- if (item.pos + item.size > pos) {
- if (item.subinfo != 0) {
- QList<int> result = item.subinfo->findSeparator(_pos);
- if (!result.isEmpty()) {
- result.prepend(i);
- return result;
- } else {
- return QList<int>();
- }
- }
- }
-
- int next = this->next(i);
- if (next == -1 || (item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
- continue;
-
- QRect sepRect = separatorRect(i);
- if (!sepRect.isNull() && *sep == 1)
- sepRect.adjust(-2, -2, 2, 2);
- //we also make sure we don't find a separator that's not there
- if (sepRect.contains(_pos) && !item.hasFixedSize(o)) {
- return QList<int>() << i;
- }
-
- }
-
- return QList<int>();
-}
-
-QList<int> QDockAreaLayoutInfo::indexOfPlaceHolder(const QString &objectName) const
-{
- for (int i = 0; i < item_list.size(); ++i) {
- const QDockAreaLayoutItem &item = item_list.at(i);
-
- if (item.subinfo != 0) {
- QList<int> result = item.subinfo->indexOfPlaceHolder(objectName);
- if (!result.isEmpty()) {
- result.prepend(i);
- return result;
- }
- continue;
- }
-
- if (item.placeHolderItem != 0 && item.placeHolderItem->objectName == objectName) {
- QList<int> result;
- result << i;
- return result;
- }
- }
-
- return QList<int>();
-}
-
-QList<int> QDockAreaLayoutInfo::indexOf(QWidget *widget) const
-{
- for (int i = 0; i < item_list.size(); ++i) {
- const QDockAreaLayoutItem &item = item_list.at(i);
-
- if (item.placeHolderItem != 0)
- continue;
-
- if (item.subinfo != 0) {
- QList<int> result = item.subinfo->indexOf(widget);
- if (!result.isEmpty()) {
- result.prepend(i);
- return result;
- }
- continue;
- }
-
- if (!(item.flags & QDockAreaLayoutItem::GapItem) && item.widgetItem->widget() == widget) {
- QList<int> result;
- result << i;
- return result;
- }
- }
-
- return QList<int>();
-}
-
-QMainWindowLayout *QDockAreaLayoutInfo::mainWindowLayout() const
-{
- QMainWindowLayout *result = qt_mainwindow_layout(mainWindow);
- Q_ASSERT(result != 0);
- return result;
-}
-
-bool QDockAreaLayoutInfo::hasFixedSize() const
-{
- return perp(o, minimumSize()) == perp(o, maximumSize());
-}
-
-
-void QDockAreaLayoutInfo::apply(bool animate)
-{
- QWidgetAnimator &widgetAnimator = mainWindowLayout()->widgetAnimator;
-
-#ifndef QT_NO_TABBAR
- if (tabbed) {
- QRect tab_rect;
- QSize tbh = tabBarSizeHint();
-
- if (!tbh.isNull()) {
- switch (tabBarShape) {
- case QTabBar::RoundedNorth:
- case QTabBar::TriangularNorth:
- tab_rect = QRect(rect.left(), rect.top(), rect.width(), tbh.height());
- break;
- case QTabBar::RoundedSouth:
- case QTabBar::TriangularSouth:
- tab_rect = QRect(rect.left(), rect.bottom() - tbh.height() + 1,
- rect.width(), tbh.height());
- break;
- case QTabBar::RoundedEast:
- case QTabBar::TriangularEast:
- tab_rect = QRect(rect.right() - tbh.width() + 1, rect.top(),
- tbh.width(), rect.height());
- break;
- case QTabBar::RoundedWest:
- case QTabBar::TriangularWest:
- tab_rect = QRect(rect.left(), rect.top(),
- tbh.width(), rect.height());
- break;
- default:
- break;
- }
- }
-
- widgetAnimator.animate(tabBar, tab_rect, animate);
- }
-#endif // QT_NO_TABBAR
-
- for (int i = 0; i < item_list.size(); ++i) {
- QDockAreaLayoutItem &item = item_list[i];
-
- if (item.flags & QDockAreaLayoutItem::GapItem)
- continue;
-
- if (item.subinfo != 0) {
- item.subinfo->apply(animate);
- continue;
- }
-
- if (item.skip())
- continue;
-
- Q_ASSERT(item.widgetItem);
- QRect r = itemRect(i);
- QWidget *w = item.widgetItem->widget();
-
- QRect geo = w->geometry();
- widgetAnimator.animate(w, r, animate);
- if (!w->isHidden() && w->window()->isVisible()) {
- QDockWidget *dw = qobject_cast<QDockWidget*>(w);
- if (!r.isValid() && geo.right() >= 0 && geo.bottom() >= 0) {
- dw->lower();
- emit dw->visibilityChanged(false);
- } else if (r.isValid()
- && (geo.right() < 0 || geo.bottom() < 0)) {
- emit dw->visibilityChanged(true);
- }
- }
- }
-#ifndef QT_NO_TABBAR
- if (*sep == 1)
- updateSeparatorWidgets();
-#endif //QT_NO_TABBAR
-}
-
-static void paintSep(QPainter *p, QWidget *w, const QRect &r, Qt::Orientation o, bool mouse_over)
-{
- QStyleOption opt(0);
- opt.state = QStyle::State_None;
- if (w->isEnabled())
- opt.state |= QStyle::State_Enabled;
- if (o != Qt::Horizontal)
- opt.state |= QStyle::State_Horizontal;
- if (mouse_over)
- opt.state |= QStyle::State_MouseOver;
- opt.rect = r;
- opt.palette = w->palette();
-
- w->style()->drawPrimitive(QStyle::PE_IndicatorDockWidgetResizeHandle, &opt, p, w);
-}
-
-QRegion QDockAreaLayoutInfo::separatorRegion() const
-{
- QRegion result;
-
- if (isEmpty())
- return result;
-#ifndef QT_NO_TABBAR
- if (tabbed)
- return result;
-#endif
-
- for (int i = 0; i < item_list.count(); ++i) {
- const QDockAreaLayoutItem &item = item_list.at(i);
-
- if (item.skip())
- continue;
-
- int next = this->next(i);
-
- if (item.subinfo)
- result |= item.subinfo->separatorRegion();
-
- if (next == -1)
- break;
- result |= separatorRect(i);
- }
-
- return result;
-}
-
-void QDockAreaLayoutInfo::paintSeparators(QPainter *p, QWidget *widget,
- const QRegion &clip,
- const QPoint &mouse) const
-{
- if (isEmpty())
- return;
-#ifndef QT_NO_TABBAR
- if (tabbed)
- return;
-#endif
-
- for (int i = 0; i < item_list.count(); ++i) {
- const QDockAreaLayoutItem &item = item_list.at(i);
-
- if (item.skip())
- continue;
-
- int next = this->next(i);
- if ((item.flags & QDockAreaLayoutItem::GapItem)
- || (next != -1 && (item_list.at(next).flags & QDockAreaLayoutItem::GapItem)))
- continue;
-
- if (item.subinfo) {
- if (clip.contains(item.subinfo->rect))
- item.subinfo->paintSeparators(p, widget, clip, mouse);
- }
-
- if (next == -1)
- break;
- QRect r = separatorRect(i);
- if (clip.contains(r) && !item.hasFixedSize(o))
- paintSep(p, widget, r, o, r.contains(mouse));
- }
-}
-
-int QDockAreaLayoutInfo::next(int index) const
-{
- for (int i = index + 1; i < item_list.size(); ++i) {
- if (!item_list.at(i).skip())
- return i;
- }
- return -1;
-}
-
-int QDockAreaLayoutInfo::prev(int index) const
-{
- for (int i = index - 1; i >= 0; --i) {
- if (!item_list.at(i).skip())
- return i;
- }
- return -1;
-}
-
-void QDockAreaLayoutInfo::tab(int index, QLayoutItem *dockWidgetItem)
-{
-#ifdef QT_NO_TABBAR
- Q_UNUSED(index);
- Q_UNUSED(dockWidgetItem);
-#else
- if (tabbed) {
- item_list.append(QDockAreaLayoutItem(dockWidgetItem));
- updateTabBar();
- setCurrentTab(dockWidgetItem->widget());
- } else {
- QDockAreaLayoutInfo *new_info
- = new QDockAreaLayoutInfo(sep, dockPos, o, tabBarShape, mainWindow);
- item_list[index].subinfo = new_info;
- new_info->item_list.append(item_list.at(index).widgetItem);
- item_list[index].widgetItem = 0;
- new_info->item_list.append(dockWidgetItem);
- new_info->tabbed = true;
- new_info->updateTabBar();
- new_info->setCurrentTab(dockWidgetItem->widget());
- }
-#endif // QT_NO_TABBAR
-}
-
-void QDockAreaLayoutInfo::split(int index, Qt::Orientation orientation,
- QLayoutItem *dockWidgetItem)
-{
- if (orientation == o) {
- item_list.insert(index + 1, QDockAreaLayoutItem(dockWidgetItem));
- } else {
-#ifdef QT_NO_TABBAR
- const int tabBarShape = 0;
-#endif
- QDockAreaLayoutInfo *new_info
- = new QDockAreaLayoutInfo(sep, dockPos, orientation, tabBarShape, mainWindow);
- item_list[index].subinfo = new_info;
- new_info->item_list.append(item_list.at(index).widgetItem);
- item_list[index].widgetItem = 0;
- new_info->item_list.append(dockWidgetItem);
- }
-}
-
-QDockAreaLayoutItem &QDockAreaLayoutInfo::item(const QList<int> &path)
-{
- Q_ASSERT(!path.isEmpty());
- const int index = path.first();
- if (path.count() > 1) {
- const QDockAreaLayoutItem &item = item_list[index];
- Q_ASSERT(item.subinfo != 0);
- return item.subinfo->item(path.mid(1));
- }
- return item_list[index];
-}
-
-QLayoutItem *QDockAreaLayoutInfo::itemAt(int *x, int index) const
-{
- for (int i = 0; i < item_list.count(); ++i) {
- const QDockAreaLayoutItem &item = item_list.at(i);
- if (item.placeHolderItem != 0)
- continue;
- if (item.subinfo) {
- if (QLayoutItem *ret = item.subinfo->itemAt(x, index))
- return ret;
- } else if (item.widgetItem) {
- if ((*x)++ == index)
- return item.widgetItem;
- }
- }
- return 0;
-}
-
-QLayoutItem *QDockAreaLayoutInfo::takeAt(int *x, int index)
-{
- for (int i = 0; i < item_list.count(); ++i) {
- QDockAreaLayoutItem &item = item_list[i];
- if (item.placeHolderItem != 0)
- continue;
- else if (item.subinfo) {
- if (QLayoutItem *ret = item.subinfo->takeAt(x, index)) {
- unnest(i);
- return ret;
- }
- } else if (item.widgetItem) {
- if ((*x)++ == index) {
- item.placeHolderItem = new QPlaceHolderItem(item.widgetItem->widget());
- QLayoutItem *ret = item.widgetItem;
- item.widgetItem = 0;
- if (item.size != -1)
- item.flags |= QDockAreaLayoutItem::KeepSize;
- return ret;
- }
- }
- }
- return 0;
-}
-
-void QDockAreaLayoutInfo::deleteAllLayoutItems()
-{
- for (int i = 0; i < item_list.count(); ++i) {
- QDockAreaLayoutItem &item= item_list[i];
- if (item.subinfo) {
- item.subinfo->deleteAllLayoutItems();
- } else {
- delete item.widgetItem;
- item.widgetItem = 0;
- }
- }
-}
-
-void QDockAreaLayoutInfo::saveState(QDataStream &stream) const
-{
-#ifndef QT_NO_TABBAR
- if (tabbed) {
- stream << (uchar) TabMarker;
-
- // write the index in item_list of the widget that's currently on top.
- quintptr id = currentTabId();
- int index = -1;
- for (int i = 0; i < item_list.count(); ++i) {
- if (tabId(item_list.at(i)) == id) {
- index = i;
- break;
- }
- }
- stream << index;
- } else
-#endif // QT_NO_TABBAR
- {
- stream << (uchar) SequenceMarker;
- }
-
- stream << (uchar) o << item_list.count();
-
- for (int i = 0; i < item_list.count(); ++i) {
- const QDockAreaLayoutItem &item = item_list.at(i);
- if (item.widgetItem != 0) {
- stream << (uchar) WidgetMarker;
- QWidget *w = item.widgetItem->widget();
- QString name = w->objectName();
- if (name.isEmpty()) {
- qWarning("QMainWindow::saveState(): 'objectName' not set for QDockWidget %p '%s;",
- w, qPrintable(w->windowTitle()));
- }
- stream << name;
-
- uchar flags = 0;
- if (!w->isHidden())
- flags |= StateFlagVisible;
- if (w->isWindow())
- flags |= StateFlagFloating;
- stream << flags;
-
- if (w->isWindow()) {
- stream << w->x() << w->y() << w->width() << w->height();
- } else {
- stream << item.pos << item.size << pick(o, item.minimumSize())
- << pick(o, item.maximumSize());
- }
- } else if (item.placeHolderItem != 0) {
- stream << (uchar) WidgetMarker;
- stream << item.placeHolderItem->objectName;
- uchar flags = 0;
- if (!item.placeHolderItem->hidden)
- flags |= StateFlagVisible;
- if (item.placeHolderItem->window)
- flags |= StateFlagFloating;
- stream << flags;
- if (item.placeHolderItem->window) {
- QRect r = item.placeHolderItem->topLevelRect;
- stream << r.x() << r.y() << r.width() << r.height();
- } else {
- stream << item.pos << item.size << (int)0 << (int)0;
- }
- } else if (item.subinfo != 0) {
- stream << (uchar) SequenceMarker << item.pos << item.size << pick(o, item.minimumSize()) << pick(o, item.maximumSize());
- item.subinfo->saveState(stream);
- }
- }
-}
-
-static Qt::DockWidgetArea toDockWidgetArea(QInternal::DockPosition pos)
-{
- switch (pos) {
- case QInternal::LeftDock: return Qt::LeftDockWidgetArea;
- case QInternal::RightDock: return Qt::RightDockWidgetArea;
- case QInternal::TopDock: return Qt::TopDockWidgetArea;
- case QInternal::BottomDock: return Qt::BottomDockWidgetArea;
- default: break;
- }
- return Qt::NoDockWidgetArea;
-}
-
-static QRect constrainedRect(QRect rect, const QRect &desktop)
-{
- if (desktop.isValid()) {
- rect.setWidth(qMin(rect.width(), desktop.width()));
- rect.setHeight(qMin(rect.height(), desktop.height()));
- rect.moveLeft(qMax(rect.left(), desktop.left()));
- rect.moveTop(qMax(rect.top(), desktop.top()));
- rect.moveRight(qMin(rect.right(), desktop.right()));
- rect.moveBottom(qMin(rect.bottom(), desktop.bottom()));
- }
-
- return rect;
-}
-
-bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*> &widgets, bool testing)
-{
- uchar marker;
- stream >> marker;
- if (marker != TabMarker && marker != SequenceMarker)
- return false;
-
-#ifndef QT_NO_TABBAR
- tabbed = marker == TabMarker;
-
- int index = -1;
- if (tabbed)
- stream >> index;
-#endif
-
- uchar orientation;
- stream >> orientation;
- o = static_cast<Qt::Orientation>(orientation);
-
- int cnt;
- stream >> cnt;
-
- for (int i = 0; i < cnt; ++i) {
- uchar nextMarker;
- stream >> nextMarker;
- if (nextMarker == WidgetMarker) {
- QString name;
- uchar flags;
- stream >> name >> flags;
- if (name.isEmpty()) {
- int dummy;
- stream >> dummy >> dummy >> dummy >> dummy;
- continue;
- }
-
- QDockWidget *widget = 0;
- for (int j = 0; j < widgets.count(); ++j) {
- if (widgets.at(j)->objectName() == name) {
- widget = widgets.takeAt(j);
- break;
- }
- }
-
- if (widget == 0) {
- QPlaceHolderItem *placeHolder = new QPlaceHolderItem;
- QDockAreaLayoutItem item(placeHolder);
-
- placeHolder->objectName = name;
- placeHolder->window = flags & StateFlagFloating;
- placeHolder->hidden = !(flags & StateFlagVisible);
- if (placeHolder->window) {
- int x, y, w, h;
- stream >> x >> y >> w >> h;
- placeHolder->topLevelRect = QRect(x, y, w, h);
- } else {
- int dummy;
- stream >> item.pos >> item.size >> dummy >> dummy;
- }
- if (item.size != -1)
- item.flags |= QDockAreaLayoutItem::KeepSize;
- if (!testing)
- item_list.append(item);
- } else {
- QDockAreaLayoutItem item(new QDockWidgetItem(widget));
- if (flags & StateFlagFloating) {
- bool drawer = false;
-#ifdef Q_WS_MAC // drawer support
- extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp
- extern bool qt_mac_set_drawer_preferred_edge(QWidget *, Qt::DockWidgetArea); //qwidget_mac.cpp
- drawer = qt_mac_is_macdrawer(widget);
-#endif
-
- if (!testing) {
- widget->hide();
- if (!drawer)
- widget->setFloating(true);
- }
-
- int x, y, w, h;
- stream >> x >> y >> w >> h;
-
-#ifdef Q_WS_MAC // drawer support
- if (drawer) {
- mainWindow->window()->createWinId();
- widget->window()->createWinId();
- qt_mac_set_drawer_preferred_edge(widget, toDockWidgetArea(dockPos));
- } else
-#endif
- if (!testing) {
- QRect r(x, y, w, h);
- QDesktopWidget *desktop = QApplication::desktop();
- if (desktop->isVirtualDesktop())
- r = constrainedRect(r, desktop->screenGeometry(desktop->screenNumber(r.topLeft())));
- else
- r = constrainedRect(r, desktop->screenGeometry(widget));
- widget->move(r.topLeft());
- widget->resize(r.size());
- }
-
- if (!testing) {
- widget->setVisible(flags & StateFlagVisible);
- item_list.append(item);
- }
- } else {
- int dummy;
- stream >> item.pos >> item.size >> dummy >> dummy;
- if (!testing) {
- item_list.append(item);
- widget->setFloating(false);
- widget->setVisible(flags & StateFlagVisible);
- emit widget->dockLocationChanged(toDockWidgetArea(dockPos));
- }
- }
- if (testing) {
- //was it is not really added to the layout, we need to delete the object here
- delete item.widgetItem;
- }
- }
- } else if (nextMarker == SequenceMarker) {
- int dummy;
-#ifdef QT_NO_TABBAR
- const int tabBarShape = 0;
-#endif
- QDockAreaLayoutItem item(new QDockAreaLayoutInfo(sep, dockPos, o,
- tabBarShape, mainWindow));
- stream >> item.pos >> item.size >> dummy >> dummy;
- //we need to make sure the element is in the list so the dock widget can eventually be docked correctly
- if (!testing)
- item_list.append(item);
-
- //here we need to make sure we change the item in the item_list
- QDockAreaLayoutItem &lastItem = testing ? item : item_list.last();
-
- if (!lastItem.subinfo->restoreState(stream, widgets, testing))
- return false;
-
- } else {
- return false;
- }
- }
-
-#ifndef QT_NO_TABBAR
- if (!testing && tabbed && index >= 0 && index < item_list.count()) {
- updateTabBar();
- setCurrentTabId(tabId(item_list.at(index)));
- }
- if (!testing && *sep == 1)
- updateSeparatorWidgets();
-#endif
-
- return true;
-}
-
-#ifndef QT_NO_TABBAR
-void QDockAreaLayoutInfo::updateSeparatorWidgets() const
-{
- if (tabbed) {
- separatorWidgets.clear();
- return;
- }
-
- int j = 0;
- for (int i = 0; i < item_list.count(); ++i) {
- const QDockAreaLayoutItem &item = item_list.at(i);
-
- if (item.skip())
- continue;
-
- int next = this->next(i);
- if ((item.flags & QDockAreaLayoutItem::GapItem)
- || (next != -1 && (item_list.at(next).flags & QDockAreaLayoutItem::GapItem)))
- continue;
-
- if (item.subinfo) {
- item.subinfo->updateSeparatorWidgets();
- }
-
- if (next == -1)
- break;
-
- QWidget *sepWidget;
- if (j < separatorWidgets.size() && separatorWidgets.at(j)) {
- sepWidget = separatorWidgets.at(j);
- } else {
- sepWidget = mainWindowLayout()->getSeparatorWidget();
- separatorWidgets.append(sepWidget);
- }
- j++;
-
-#ifndef QT_MAC_USE_COCOA
- sepWidget->raise();
-#endif
- QRect sepRect = separatorRect(i).adjusted(-2, -2, 2, 2);
- sepWidget->setGeometry(sepRect);
- sepWidget->setMask( QRegion(separatorRect(i).translated( - sepRect.topLeft())));
- sepWidget->show();
- }
-
- for (int k = j; k < separatorWidgets.size(); ++k) {
- separatorWidgets[k]->hide();
- }
- separatorWidgets.resize(j);
- Q_ASSERT(separatorWidgets.size() == j);
-}
-#endif //QT_NO_TABBAR
-
-#ifndef QT_NO_TABBAR
-//returns whether the tabbar is visible or not
-bool QDockAreaLayoutInfo::updateTabBar() const
-{
- if (!tabbed)
- return false;
-
- QDockAreaLayoutInfo *that = const_cast<QDockAreaLayoutInfo*>(this);
-
- if (that->tabBar == 0) {
- that->tabBar = mainWindowLayout()->getTabBar();
- that->tabBar->setShape(static_cast<QTabBar::Shape>(tabBarShape));
- that->tabBar->setDrawBase(true);
- }
-
- bool blocked = tabBar->blockSignals(true);
- bool gap = false;
-
- int tab_idx = 0;
- for (int i = 0; i < item_list.count(); ++i) {
- const QDockAreaLayoutItem &item = item_list.at(i);
- if (item.skip())
- continue;
- if (item.flags & QDockAreaLayoutItem::GapItem) {
- gap = true;
- continue;
- }
- if (item.widgetItem == 0)
- continue;
-
- QDockWidget *dw = qobject_cast<QDockWidget*>(item.widgetItem->widget());
- QString title = dw->d_func()->fixedWindowTitle;
- quintptr id = tabId(item);
- if (tab_idx == tabBar->count()) {
- tabBar->insertTab(tab_idx, title);
-#ifndef QT_NO_TOOLTIP
- tabBar->setTabToolTip(tab_idx, title);
-#endif
- tabBar->setTabData(tab_idx, id);
- } else if (qvariant_cast<quintptr>(tabBar->tabData(tab_idx)) != id) {
- if (tab_idx + 1 < tabBar->count()
- && qvariant_cast<quintptr>(tabBar->tabData(tab_idx + 1)) == id)
- tabBar->removeTab(tab_idx);
- else {
- tabBar->insertTab(tab_idx, title);
-#ifndef QT_NO_TOOLTIP
- tabBar->setTabToolTip(tab_idx, title);
-#endif
- tabBar->setTabData(tab_idx, id);
- }
- }
-
- if (title != tabBar->tabText(tab_idx)) {
- tabBar->setTabText(tab_idx, title);
-#ifndef QT_NO_TOOLTIP
- tabBar->setTabToolTip(tab_idx, title);
-#endif
- }
-
- ++tab_idx;
- }
-
- while (tab_idx < tabBar->count()) {
- tabBar->removeTab(tab_idx);
- }
-
- tabBar->blockSignals(blocked);
-
- //returns if the tabbar is visible or not
- return ( (gap ? 1 : 0) + tabBar->count()) > 1;
-}
-
-void QDockAreaLayoutInfo::setTabBarShape(int shape)
-{
- if (shape == tabBarShape)
- return;
- tabBarShape = shape;
- if (tabBar != 0)
- tabBar->setShape(static_cast<QTabBar::Shape>(shape));
-
- for (int i = 0; i < item_list.count(); ++i) {
- QDockAreaLayoutItem &item = item_list[i];
- if (item.subinfo != 0)
- item.subinfo->setTabBarShape(shape);
- }
-}
-
-QSize QDockAreaLayoutInfo::tabBarMinimumSize() const
-{
- if (!updateTabBar())
- return QSize(0, 0);
-
- return tabBar->minimumSizeHint();
-}
-
-QSize QDockAreaLayoutInfo::tabBarSizeHint() const
-{
- if (!updateTabBar())
- return QSize(0, 0);
-
- return tabBar->sizeHint();
-}
-
-QSet<QTabBar*> QDockAreaLayoutInfo::usedTabBars() const
-{
- QSet<QTabBar*> result;
-
- if (tabbed) {
- updateTabBar();
- result.insert(tabBar);
- }
-
- for (int i = 0; i < item_list.count(); ++i) {
- const QDockAreaLayoutItem &item = item_list.at(i);
- if (item.subinfo != 0)
- result += item.subinfo->usedTabBars();
- }
-
- return result;
-}
-
-// returns a set of all used separator widgets for this dockarelayout info
-// and all subinfos
-QSet<QWidget*> QDockAreaLayoutInfo::usedSeparatorWidgets() const
-{
- QSet<QWidget*> result;
-
- for (int i = 0; i < separatorWidgets.count(); ++i)
- result << separatorWidgets.at(i);
-
- for (int i = 0; i < item_list.count(); ++i) {
- const QDockAreaLayoutItem &item = item_list.at(i);
- if (item.subinfo != 0)
- result += item.subinfo->usedSeparatorWidgets();
- }
-
- return result;
-}
-
-QRect QDockAreaLayoutInfo::tabContentRect() const
-{
- if (!tabbed)
- return QRect();
-
- QRect result = rect;
- QSize tbh = tabBarSizeHint();
-
- if (!tbh.isNull()) {
- switch (tabBarShape) {
- case QTabBar::RoundedNorth:
- case QTabBar::TriangularNorth:
- result.adjust(0, tbh.height(), 0, 0);
- break;
- case QTabBar::RoundedSouth:
- case QTabBar::TriangularSouth:
- result.adjust(0, 0, 0, -tbh.height());
- break;
- case QTabBar::RoundedEast:
- case QTabBar::TriangularEast:
- result.adjust(0, 0, -tbh.width(), 0);
- break;
- case QTabBar::RoundedWest:
- case QTabBar::TriangularWest:
- result.adjust(tbh.width(), 0, 0, 0);
- break;
- default:
- break;
- }
- }
-
- return result;
-}
-#endif // QT_NO_TABBAR
-
-/******************************************************************************
-** QDockAreaLayout
-*/
-
-QDockAreaLayout::QDockAreaLayout(QMainWindow *win) : fallbackToSizeHints(true)
-{
- mainWindow = win;
- sep = win->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, win);
-#ifndef QT_NO_TABBAR
- const int tabShape = QTabBar::RoundedSouth;
-#else
- const int tabShape = 0;
-#endif
- docks[QInternal::LeftDock]
- = QDockAreaLayoutInfo(&sep, QInternal::LeftDock, Qt::Vertical, tabShape, win);
- docks[QInternal::RightDock]
- = QDockAreaLayoutInfo(&sep, QInternal::RightDock, Qt::Vertical, tabShape, win);
- docks[QInternal::TopDock]
- = QDockAreaLayoutInfo(&sep, QInternal::TopDock, Qt::Horizontal, tabShape, win);
- docks[QInternal::BottomDock]
- = QDockAreaLayoutInfo(&sep, QInternal::BottomDock, Qt::Horizontal, tabShape, win);
- centralWidgetItem = 0;
-
-
- corners[Qt::TopLeftCorner] = Qt::TopDockWidgetArea;
- corners[Qt::TopRightCorner] = Qt::TopDockWidgetArea;
- corners[Qt::BottomLeftCorner] = Qt::BottomDockWidgetArea;
- corners[Qt::BottomRightCorner] = Qt::BottomDockWidgetArea;
-}
-
-bool QDockAreaLayout::isValid() const
-{
- return rect.isValid();
-}
-
-void QDockAreaLayout::saveState(QDataStream &stream) const
-{
- stream << (uchar) DockWidgetStateMarker;
- int cnt = 0;
- for (int i = 0; i < QInternal::DockCount; ++i) {
- if (!docks[i].item_list.isEmpty())
- ++cnt;
- }
- stream << cnt;
- for (int i = 0; i < QInternal::DockCount; ++i) {
- if (docks[i].item_list.isEmpty())
- continue;
- stream << i << docks[i].rect.size();
- docks[i].saveState(stream);
- }
-
- stream << centralWidgetRect.size();
-
- for (int i = 0; i < 4; ++i)
- stream << static_cast<int>(corners[i]);
-}
-
-bool QDockAreaLayout::restoreState(QDataStream &stream, const QList<QDockWidget*> &_dockwidgets, bool testing)
-{
- QList<QDockWidget*> dockwidgets = _dockwidgets;
-
- int cnt;
- stream >> cnt;
- for (int i = 0; i < cnt; ++i) {
- int pos;
- stream >> pos;
- QSize size;
- stream >> size;
- if (!testing) {
- docks[pos].rect = QRect(QPoint(0, 0), size);
- }
- if (!docks[pos].restoreState(stream, dockwidgets, testing)) {
- stream.setStatus(QDataStream::ReadCorruptData);
- return false;
- }
- }
-
- QSize size;
- stream >> size;
- centralWidgetRect = QRect(QPoint(0, 0), size);
-
- bool ok = stream.status() == QDataStream::Ok;
-
- if (ok) {
- int cornerData[4];
- for (int i = 0; i < 4; ++i)
- stream >> cornerData[i];
- if (stream.status() == QDataStream::Ok) {
- for (int i = 0; i < 4; ++i)
- corners[i] = static_cast<Qt::DockWidgetArea>(cornerData[i]);
- }
-
- if (!testing)
- fallbackToSizeHints = false;
- }
-
- return ok;
-}
-
-QList<int> QDockAreaLayout::indexOfPlaceHolder(const QString &objectName) const
-{
- for (int i = 0; i < QInternal::DockCount; ++i) {
- QList<int> result = docks[i].indexOfPlaceHolder(objectName);
- if (!result.isEmpty()) {
- result.prepend(i);
- return result;
- }
- }
- return QList<int>();
-}
-
-QList<int> QDockAreaLayout::indexOf(QWidget *dockWidget) const
-{
- for (int i = 0; i < QInternal::DockCount; ++i) {
- QList<int> result = docks[i].indexOf(dockWidget);
- if (!result.isEmpty()) {
- result.prepend(i);
- return result;
- }
- }
- return QList<int>();
-}
-
-QList<int> QDockAreaLayout::gapIndex(const QPoint &pos) const
-{
- QMainWindow::DockOptions opts = mainWindow->dockOptions();
- bool nestingEnabled = opts & QMainWindow::AllowNestedDocks;
- QDockAreaLayoutInfo::TabMode tabMode = QDockAreaLayoutInfo::NoTabs;
-#ifndef QT_NO_TABBAR
- if (opts & QMainWindow::AllowTabbedDocks
- || opts & QMainWindow::VerticalTabs)
- tabMode = QDockAreaLayoutInfo::AllowTabs;
- if (opts & QMainWindow::ForceTabbedDocks)
- tabMode = QDockAreaLayoutInfo::ForceTabs;
-
- if (tabMode == QDockAreaLayoutInfo::ForceTabs)
- nestingEnabled = false;
-#endif
-
-
- for (int i = 0; i < QInternal::DockCount; ++i) {
- const QDockAreaLayoutInfo &info = docks[i];
-
- if (!info.isEmpty() && info.rect.contains(pos)) {
- QList<int> result
- = docks[i].gapIndex(pos, nestingEnabled, tabMode);
- if (!result.isEmpty())
- result.prepend(i);
- return result;
- }
- }
-
- for (int i = 0; i < QInternal::DockCount; ++i) {
- const QDockAreaLayoutInfo &info = docks[i];
-
- if (info.isEmpty()) {
- QRect r;
- switch (i) {
- case QInternal::LeftDock:
- r = QRect(rect.left(), rect.top(), EmptyDropAreaSize, rect.height());
- break;
- case QInternal::RightDock:
- r = QRect(rect.right() - EmptyDropAreaSize, rect.top(),
- EmptyDropAreaSize, rect.height());
- break;
- case QInternal::TopDock:
- r = QRect(rect.left(), rect.top(), rect.width(), EmptyDropAreaSize);
- break;
- case QInternal::BottomDock:
- r = QRect(rect.left(), rect.bottom() - EmptyDropAreaSize,
- rect.width(), EmptyDropAreaSize);
- break;
- }
- if (r.contains(pos)) {
- if (opts & QMainWindow::ForceTabbedDocks && !info.item_list.isEmpty()) {
- //in case of ForceTabbedDocks, we pass -1 in order to force the gap to be tabbed
- //it mustn't be completely empty otherwise it won't work
- return QList<int>() << i << -1 << 0;
- } else {
- return QList<int>() << i << 0;
- }
- }
- }
- }
-
- return QList<int>();
-}
-
-QList<int> QDockAreaLayout::findSeparator(const QPoint &pos) const
-{
- QList<int> result;
- for (int i = 0; i < QInternal::DockCount; ++i) {
- const QDockAreaLayoutInfo &info = docks[i];
- if (info.isEmpty())
- continue;
- QRect rect = separatorRect(i);
- if (!rect.isNull() && sep == 1)
- rect.adjust(-2, -2, 2, 2);
- if (rect.contains(pos) && !info.hasFixedSize()) {
- result << i;
- break;
- } else if (info.rect.contains(pos)) {
- result = docks[i].findSeparator(pos);
- if (!result.isEmpty()) {
- result.prepend(i);
- break;
- }
- }
- }
-
- return result;
-}
-
-QDockAreaLayoutInfo *QDockAreaLayout::info(QWidget *widget)
-{
- for (int i = 0; i < QInternal::DockCount; ++i) {
- if (QDockAreaLayoutInfo *result = docks[i].info(widget))
- return result;
- }
-
- return 0;
-}
-
-QDockAreaLayoutInfo *QDockAreaLayout::info(const QList<int> &path)
-{
- Q_ASSERT(!path.isEmpty());
- const int index = path.first();
- Q_ASSERT(index >= 0 && index < QInternal::DockCount);
-
- if (path.count() == 1)
- return &docks[index];
-
- return docks[index].info(path.mid(1));
-}
-
-const QDockAreaLayoutInfo *QDockAreaLayout::info(const QList<int> &path) const
-{
- return const_cast<QDockAreaLayout*>(this)->info(path);
-}
-
-QDockAreaLayoutItem &QDockAreaLayout::item(const QList<int> &path)
-{
- Q_ASSERT(!path.isEmpty());
- const int index = path.first();
- Q_ASSERT(index >= 0 && index < QInternal::DockCount);
- return docks[index].item(path.mid(1));
-}
-
-QRect QDockAreaLayout::itemRect(const QList<int> &path) const
-{
- Q_ASSERT(!path.isEmpty());
- const int index = path.first();
- Q_ASSERT(index >= 0 && index < QInternal::DockCount);
- return docks[index].itemRect(path.mid(1));
-}
-
-QRect QDockAreaLayout::separatorRect(int index) const
-{
- const QDockAreaLayoutInfo &dock = docks[index];
- if (dock.isEmpty())
- return QRect();
- QRect r = dock.rect;
- switch (index) {
- case QInternal::LeftDock:
- return QRect(r.right() + 1, r.top(), sep, r.height());
- case QInternal::RightDock:
- return QRect(r.left() - sep, r.top(), sep, r.height());
- case QInternal::TopDock:
- return QRect(r.left(), r.bottom() + 1, r.width(), sep);
- case QInternal::BottomDock:
- return QRect(r.left(), r.top() - sep, r.width(), sep);
- default:
- break;
- }
- return QRect();
-}
-
-QRect QDockAreaLayout::separatorRect(const QList<int> &path) const
-{
- Q_ASSERT(!path.isEmpty());
-
- const int index = path.first();
- Q_ASSERT(index >= 0 && index < QInternal::DockCount);
-
- if (path.count() == 1)
- return separatorRect(index);
- else
- return docks[index].separatorRect(path.mid(1));
-}
-
-bool QDockAreaLayout::insertGap(const QList<int> &path, QLayoutItem *dockWidgetItem)
-{
- Q_ASSERT(!path.isEmpty());
- const int index = path.first();
- Q_ASSERT(index >= 0 && index < QInternal::DockCount);
- return docks[index].insertGap(path.mid(1), dockWidgetItem);
-}
-
-QLayoutItem *QDockAreaLayout::plug(const QList<int> &path)
-{
- Q_ASSERT(!path.isEmpty());
- const int index = path.first();
- Q_ASSERT(index >= 0 && index < QInternal::DockCount);
- return docks[index].plug(path.mid(1));
-}
-
-QLayoutItem *QDockAreaLayout::unplug(const QList<int> &path)
-{
- Q_ASSERT(!path.isEmpty());
- const int index = path.first();
- Q_ASSERT(index >= 0 && index < QInternal::DockCount);
- return docks[index].unplug(path.mid(1));
-}
-
-void QDockAreaLayout::remove(const QList<int> &path)
-{
- Q_ASSERT(!path.isEmpty());
- const int index = path.first();
- Q_ASSERT(index >= 0 && index < QInternal::DockCount);
- docks[index].remove(path.mid(1));
-}
-
-static inline int qMin(int i1, int i2, int i3) { return qMin(i1, qMin(i2, i3)); }
-static inline int qMax(int i1, int i2, int i3) { return qMax(i1, qMax(i2, i3)); }
-
-void QDockAreaLayout::getGrid(QVector<QLayoutStruct> *_ver_struct_list,
- QVector<QLayoutStruct> *_hor_struct_list)
-{
- QSize center_hint(0, 0);
- QSize center_min(0, 0);
- const bool have_central = centralWidgetItem != 0 && !centralWidgetItem->isEmpty();
- if (have_central) {
- center_hint = centralWidgetRect.size();
- if (!center_hint.isValid())
- center_hint = centralWidgetItem->sizeHint();
- center_min = centralWidgetItem->minimumSize();
- }
-
- QRect center_rect = rect;
- if (!docks[QInternal::LeftDock].isEmpty())
- center_rect.setLeft(rect.left() + docks[QInternal::LeftDock].rect.width() + sep);
- if (!docks[QInternal::TopDock].isEmpty())
- center_rect.setTop(rect.top() + docks[QInternal::TopDock].rect.height() + sep);
- if (!docks[QInternal::RightDock].isEmpty())
- center_rect.setRight(rect.right() - docks[QInternal::RightDock].rect.width() - sep);
- if (!docks[QInternal::BottomDock].isEmpty())
- center_rect.setBottom(rect.bottom() - docks[QInternal::BottomDock].rect.height() - sep);
-
- QSize left_hint = docks[QInternal::LeftDock].size();
- if (left_hint.isNull() || fallbackToSizeHints)
- left_hint = docks[QInternal::LeftDock].sizeHint();
- QSize left_min = docks[QInternal::LeftDock].minimumSize();
- QSize left_max = docks[QInternal::LeftDock].maximumSize();
- left_hint = left_hint.boundedTo(left_max).expandedTo(left_min);
-
- QSize right_hint = docks[QInternal::RightDock].size();
- if (right_hint.isNull() || fallbackToSizeHints)
- right_hint = docks[QInternal::RightDock].sizeHint();
- QSize right_min = docks[QInternal::RightDock].minimumSize();
- QSize right_max = docks[QInternal::RightDock].maximumSize();
- right_hint = right_hint.boundedTo(right_max).expandedTo(right_min);
-
- QSize top_hint = docks[QInternal::TopDock].size();
- if (top_hint.isNull() || fallbackToSizeHints)
- top_hint = docks[QInternal::TopDock].sizeHint();
- QSize top_min = docks[QInternal::TopDock].minimumSize();
- QSize top_max = docks[QInternal::TopDock].maximumSize();
- top_hint = top_hint.boundedTo(top_max).expandedTo(top_min);
-
- QSize bottom_hint = docks[QInternal::BottomDock].size();
- if (bottom_hint.isNull() || fallbackToSizeHints)
- bottom_hint = docks[QInternal::BottomDock].sizeHint();
- QSize bottom_min = docks[QInternal::BottomDock].minimumSize();
- QSize bottom_max = docks[QInternal::BottomDock].maximumSize();
- bottom_hint = bottom_hint.boundedTo(bottom_max).expandedTo(bottom_min);
-
- fallbackToSizeHints = false;
-
- if (_ver_struct_list != 0) {
- QVector<QLayoutStruct> &ver_struct_list = *_ver_struct_list;
- ver_struct_list.resize(3);
-
- // top --------------------------------------------------
- ver_struct_list[0].init();
- ver_struct_list[0].stretch = 0;
- ver_struct_list[0].sizeHint = top_hint.height();
- ver_struct_list[0].minimumSize = top_min.height();
- ver_struct_list[0].maximumSize = top_max.height();
- ver_struct_list[0].expansive = false;
- ver_struct_list[0].empty = docks[QInternal::TopDock].isEmpty();
- ver_struct_list[0].pos = docks[QInternal::TopDock].rect.top();
- ver_struct_list[0].size = docks[QInternal::TopDock].rect.height();
-
- // center --------------------------------------------------
- ver_struct_list[1].init();
- ver_struct_list[1].stretch = center_hint.height();
-
- bool tl_significant = corners[Qt::TopLeftCorner] == Qt::TopDockWidgetArea
- || docks[QInternal::TopDock].isEmpty();
- bool bl_significant = corners[Qt::BottomLeftCorner] == Qt::BottomDockWidgetArea
- || docks[QInternal::BottomDock].isEmpty();
- bool tr_significant = corners[Qt::TopRightCorner] == Qt::TopDockWidgetArea
- || docks[QInternal::TopDock].isEmpty();
- bool br_significant = corners[Qt::BottomRightCorner] == Qt::BottomDockWidgetArea
- || docks[QInternal::BottomDock].isEmpty();
-
- int left = (tl_significant && bl_significant) ? left_hint.height() : 0;
- int right = (tr_significant && br_significant) ? right_hint.height() : 0;
- ver_struct_list[1].sizeHint = qMax(left, center_hint.height(), right);
-
- left = (tl_significant && bl_significant) ? left_min.height() : 0;
- right = (tr_significant && br_significant) ? right_min.height() : 0;
- ver_struct_list[1].minimumSize = qMax(left, center_min.height(), right);
- ver_struct_list[1].maximumSize = have_central ? QWIDGETSIZE_MAX : 0;
- ver_struct_list[1].expansive = have_central;
- ver_struct_list[1].empty = docks[QInternal::LeftDock].isEmpty()
- && !have_central
- && docks[QInternal::RightDock].isEmpty();
- ver_struct_list[1].pos = center_rect.top();
- ver_struct_list[1].size = center_rect.height();
-
- // bottom --------------------------------------------------
- ver_struct_list[2].init();
- ver_struct_list[2].stretch = 0;
- ver_struct_list[2].sizeHint = bottom_hint.height();
- ver_struct_list[2].minimumSize = bottom_min.height();
- ver_struct_list[2].maximumSize = bottom_max.height();
- ver_struct_list[2].expansive = false;
- ver_struct_list[2].empty = docks[QInternal::BottomDock].isEmpty();
- ver_struct_list[2].pos = docks[QInternal::BottomDock].rect.top();
- ver_struct_list[2].size = docks[QInternal::BottomDock].rect.height();
-
- for (int i = 0; i < 3; ++i) {
- ver_struct_list[i].sizeHint
- = qMax(ver_struct_list[i].sizeHint, ver_struct_list[i].minimumSize);
- }
- }
-
- if (_hor_struct_list != 0) {
- QVector<QLayoutStruct> &hor_struct_list = *_hor_struct_list;
- hor_struct_list.resize(3);
-
- // left --------------------------------------------------
- hor_struct_list[0].init();
- hor_struct_list[0].stretch = 0;
- hor_struct_list[0].sizeHint = left_hint.width();
- hor_struct_list[0].minimumSize = left_min.width();
- hor_struct_list[0].maximumSize = left_max.width();
- hor_struct_list[0].expansive = false;
- hor_struct_list[0].empty = docks[QInternal::LeftDock].isEmpty();
- hor_struct_list[0].pos = docks[QInternal::LeftDock].rect.left();
- hor_struct_list[0].size = docks[QInternal::LeftDock].rect.width();
-
- // center --------------------------------------------------
- hor_struct_list[1].init();
- hor_struct_list[1].stretch = center_hint.width();
-
- bool tl_significant = corners[Qt::TopLeftCorner] == Qt::LeftDockWidgetArea
- || docks[QInternal::LeftDock].isEmpty();
- bool tr_significant = corners[Qt::TopRightCorner] == Qt::RightDockWidgetArea
- || docks[QInternal::RightDock].isEmpty();
- bool bl_significant = corners[Qt::BottomLeftCorner] == Qt::LeftDockWidgetArea
- || docks[QInternal::LeftDock].isEmpty();
- bool br_significant = corners[Qt::BottomRightCorner] == Qt::RightDockWidgetArea
- || docks[QInternal::RightDock].isEmpty();
-
- int top = (tl_significant && tr_significant) ? top_hint.width() : 0;
- int bottom = (bl_significant && br_significant) ? bottom_hint.width() : 0;
- hor_struct_list[1].sizeHint = qMax(top, center_hint.width(), bottom);
-
- top = (tl_significant && tr_significant) ? top_min.width() : 0;
- bottom = (bl_significant && br_significant) ? bottom_min.width() : 0;
- hor_struct_list[1].minimumSize = qMax(top, center_min.width(), bottom);
-
- hor_struct_list[1].maximumSize = have_central ? QWIDGETSIZE_MAX : 0;
- hor_struct_list[1].expansive = have_central;
- hor_struct_list[1].empty = !have_central;
- hor_struct_list[1].pos = center_rect.left();
- hor_struct_list[1].size = center_rect.width();
-
- // right --------------------------------------------------
- hor_struct_list[2].init();
- hor_struct_list[2].stretch = 0;
- hor_struct_list[2].sizeHint = right_hint.width();
- hor_struct_list[2].minimumSize = right_min.width();
- hor_struct_list[2].maximumSize = right_max.width();
- hor_struct_list[2].expansive = false;
- hor_struct_list[2].empty = docks[QInternal::RightDock].isEmpty();
- hor_struct_list[2].pos = docks[QInternal::RightDock].rect.left();
- hor_struct_list[2].size = docks[QInternal::RightDock].rect.width();
-
- for (int i = 0; i < 3; ++i) {
- hor_struct_list[i].sizeHint
- = qMax(hor_struct_list[i].sizeHint, hor_struct_list[i].minimumSize);
- }
- }
-}
-
-void QDockAreaLayout::setGrid(QVector<QLayoutStruct> *ver_struct_list,
- QVector<QLayoutStruct> *hor_struct_list)
-{
-
- // top ---------------------------------------------------
-
- if (!docks[QInternal::TopDock].isEmpty()) {
- QRect r = docks[QInternal::TopDock].rect;
- if (hor_struct_list != 0) {
- r.setLeft(corners[Qt::TopLeftCorner] == Qt::TopDockWidgetArea
- || docks[QInternal::LeftDock].isEmpty()
- ? rect.left() : hor_struct_list->at(1).pos);
- r.setRight(corners[Qt::TopRightCorner] == Qt::TopDockWidgetArea
- || docks[QInternal::RightDock].isEmpty()
- ? rect.right() : hor_struct_list->at(2).pos - sep - 1);
- }
- if (ver_struct_list != 0) {
- r.setTop(rect.top());
- r.setBottom(ver_struct_list->at(1).pos - sep - 1);
- }
- docks[QInternal::TopDock].rect = r;
- docks[QInternal::TopDock].fitItems();
- }
-
- // bottom ---------------------------------------------------
-
- if (!docks[QInternal::BottomDock].isEmpty()) {
- QRect r = docks[QInternal::BottomDock].rect;
- if (hor_struct_list != 0) {
- r.setLeft(corners[Qt::BottomLeftCorner] == Qt::BottomDockWidgetArea
- || docks[QInternal::LeftDock].isEmpty()
- ? rect.left() : hor_struct_list->at(1).pos);
- r.setRight(corners[Qt::BottomRightCorner] == Qt::BottomDockWidgetArea
- || docks[QInternal::RightDock].isEmpty()
- ? rect.right() : hor_struct_list->at(2).pos - sep - 1);
- }
- if (ver_struct_list != 0) {
- r.setTop(ver_struct_list->at(2).pos);
- r.setBottom(rect.bottom());
- }
- docks[QInternal::BottomDock].rect = r;
- docks[QInternal::BottomDock].fitItems();
- }
-
- // left ---------------------------------------------------
-
- if (!docks[QInternal::LeftDock].isEmpty()) {
- QRect r = docks[QInternal::LeftDock].rect;
- if (hor_struct_list != 0) {
- r.setLeft(rect.left());
- r.setRight(hor_struct_list->at(1).pos - sep - 1);
- }
- if (ver_struct_list != 0) {
- r.setTop(corners[Qt::TopLeftCorner] == Qt::LeftDockWidgetArea
- || docks[QInternal::TopDock].isEmpty()
- ? rect.top() : ver_struct_list->at(1).pos);
- r.setBottom(corners[Qt::BottomLeftCorner] == Qt::LeftDockWidgetArea
- || docks[QInternal::BottomDock].isEmpty()
- ? rect.bottom() : ver_struct_list->at(2).pos - sep - 1);
- }
- docks[QInternal::LeftDock].rect = r;
- docks[QInternal::LeftDock].fitItems();
- }
-
- // right ---------------------------------------------------
-
- if (!docks[QInternal::RightDock].isEmpty()) {
- QRect r = docks[QInternal::RightDock].rect;
- if (hor_struct_list != 0) {
- r.setLeft(hor_struct_list->at(2).pos);
- r.setRight(rect.right());
- }
- if (ver_struct_list != 0) {
- r.setTop(corners[Qt::TopRightCorner] == Qt::RightDockWidgetArea
- || docks[QInternal::TopDock].isEmpty()
- ? rect.top() : ver_struct_list->at(1).pos);
- r.setBottom(corners[Qt::BottomRightCorner] == Qt::RightDockWidgetArea
- || docks[QInternal::BottomDock].isEmpty()
- ? rect.bottom() : ver_struct_list->at(2).pos - sep - 1);
- }
- docks[QInternal::RightDock].rect = r;
- docks[QInternal::RightDock].fitItems();
- }
-
- // center ---------------------------------------------------
-
- if (hor_struct_list != 0) {
- centralWidgetRect.setLeft(hor_struct_list->at(1).pos);
- centralWidgetRect.setWidth(hor_struct_list->at(1).size);
- }
- if (ver_struct_list != 0) {
- centralWidgetRect.setTop(ver_struct_list->at(1).pos);
- centralWidgetRect.setHeight(ver_struct_list->at(1).size);
- }
-}
-
-void QDockAreaLayout::fitLayout()
-{
- QVector<QLayoutStruct> ver_struct_list(3);
- QVector<QLayoutStruct> hor_struct_list(3);
- getGrid(&ver_struct_list, &hor_struct_list);
-
- qGeomCalc(ver_struct_list, 0, 3, rect.top(), rect.height(), sep);
- qGeomCalc(hor_struct_list, 0, 3, rect.left(), rect.width(), sep);
-
- setGrid(&ver_struct_list, &hor_struct_list);
-}
-
-void QDockAreaLayout::clear()
-{
- for (int i = 0; i < QInternal::DockCount; ++i)
- docks[i].clear();
-
- rect = QRect();
- centralWidgetRect = QRect();
-}
-
-QSize QDockAreaLayout::sizeHint() const
-{
- int left_sep = 0;
- int right_sep = 0;
- int top_sep = 0;
- int bottom_sep = 0;
-
- if (centralWidgetItem != 0) {
- left_sep = docks[QInternal::LeftDock].isEmpty() ? 0 : sep;
- right_sep = docks[QInternal::RightDock].isEmpty() ? 0 : sep;
- top_sep = docks[QInternal::TopDock].isEmpty() ? 0 : sep;
- bottom_sep = docks[QInternal::BottomDock].isEmpty() ? 0 : sep;
- }
-
- QSize left = docks[QInternal::LeftDock].sizeHint() + QSize(left_sep, 0);
- QSize right = docks[QInternal::RightDock].sizeHint() + QSize(right_sep, 0);
- QSize top = docks[QInternal::TopDock].sizeHint() + QSize(0, top_sep);
- QSize bottom = docks[QInternal::BottomDock].sizeHint() + QSize(0, bottom_sep);
- QSize center = centralWidgetItem == 0 ? QSize(0, 0) : centralWidgetItem->sizeHint();
-
- int row1 = top.width();
- int row2 = left.width() + center.width() + right.width();
- int row3 = bottom.width();
- int col1 = left.height();
- int col2 = top.height() + center.height() + bottom.height();
- int col3 = right.height();
-
- if (corners[Qt::TopLeftCorner] == Qt::LeftDockWidgetArea)
- row1 += left.width();
- else
- col1 += top.height();
-
- if (corners[Qt::TopRightCorner] == Qt::RightDockWidgetArea)
- row1 += right.width();
- else
- col3 += top.height();
-
- if (corners[Qt::BottomLeftCorner] == Qt::LeftDockWidgetArea)
- row3 += left.width();
- else
- col1 += bottom.height();
-
- if (corners[Qt::BottomRightCorner] == Qt::RightDockWidgetArea)
- row3 += right.width();
- else
- col3 += bottom.height();
-
- return QSize(qMax(row1, row2, row3), qMax(col1, col2, col3));
-}
-
-QSize QDockAreaLayout::minimumSize() const
-{
- int left_sep = 0;
- int right_sep = 0;
- int top_sep = 0;
- int bottom_sep = 0;
-
- if (centralWidgetItem != 0) {
- left_sep = docks[QInternal::LeftDock].isEmpty() ? 0 : sep;
- right_sep = docks[QInternal::RightDock].isEmpty() ? 0 : sep;
- top_sep = docks[QInternal::TopDock].isEmpty() ? 0 : sep;
- bottom_sep = docks[QInternal::BottomDock].isEmpty() ? 0 : sep;
- }
-
- QSize left = docks[QInternal::LeftDock].minimumSize() + QSize(left_sep, 0);
- QSize right = docks[QInternal::RightDock].minimumSize() + QSize(right_sep, 0);
- QSize top = docks[QInternal::TopDock].minimumSize() + QSize(0, top_sep);
- QSize bottom = docks[QInternal::BottomDock].minimumSize() + QSize(0, bottom_sep);
- QSize center = centralWidgetItem == 0 ? QSize(0, 0) : centralWidgetItem->minimumSize();
-
- int row1 = top.width();
- int row2 = left.width() + center.width() + right.width();
- int row3 = bottom.width();
- int col1 = left.height();
- int col2 = top.height() + center.height() + bottom.height();
- int col3 = right.height();
-
- if (corners[Qt::TopLeftCorner] == Qt::LeftDockWidgetArea)
- row1 += left.width();
- else
- col1 += top.height();
-
- if (corners[Qt::TopRightCorner] == Qt::RightDockWidgetArea)
- row1 += right.width();
- else
- col3 += top.height();
-
- if (corners[Qt::BottomLeftCorner] == Qt::LeftDockWidgetArea)
- row3 += left.width();
- else
- col1 += bottom.height();
-
- if (corners[Qt::BottomRightCorner] == Qt::RightDockWidgetArea)
- row3 += right.width();
- else
- col3 += bottom.height();
-
- return QSize(qMax(row1, row2, row3), qMax(col1, col2, col3));
-}
-
-bool QDockAreaLayout::restoreDockWidget(QDockWidget *dockWidget)
-{
- QList<int> index = indexOfPlaceHolder(dockWidget->objectName());
- if (index.isEmpty())
- return false;
-
- QDockAreaLayoutItem &item = this->item(index);
- QPlaceHolderItem *placeHolder = item.placeHolderItem;
- Q_ASSERT(placeHolder != 0);
-
- item.widgetItem = new QDockWidgetItem(dockWidget);
-
- if (placeHolder->window) {
- QDesktopWidget desktop;
- QRect r = constrainedRect(placeHolder->topLevelRect, desktop.screenGeometry(dockWidget));
- dockWidget->d_func()->setWindowState(true, true, r);
- }
- dockWidget->setVisible(!placeHolder->hidden);
-#ifdef Q_WS_X11
- if (placeHolder->window) // gets rid of the X11BypassWindowManager window flag
- dockWidget->d_func()->setWindowState(true);
-#endif
-
- item.placeHolderItem = 0;
- delete placeHolder;
-
- return true;
-}
-
-void QDockAreaLayout::addDockWidget(QInternal::DockPosition pos, QDockWidget *dockWidget,
- Qt::Orientation orientation)
-{
- QLayoutItem *dockWidgetItem = new QDockWidgetItem(dockWidget);
- QDockAreaLayoutInfo &info = docks[pos];
- if (orientation == info.o || info.item_list.count() <= 1) {
- // empty dock areas, or dock areas containing exactly one widget can have their orientation
- // switched.
- info.o = orientation;
-
- QDockAreaLayoutItem new_item(dockWidgetItem);
- info.item_list.append(new_item);
-#ifndef QT_NO_TABBAR
- if (info.tabbed && !new_item.skip()) {
- info.updateTabBar();
- info.setCurrentTabId(tabId(new_item));
- }
-#endif
- } else {
-#ifndef QT_NO_TABBAR
- int tbshape = info.tabBarShape;
-#else
- int tbshape = 0;
-#endif
- QDockAreaLayoutInfo new_info(&sep, pos, orientation, tbshape, mainWindow);
- new_info.item_list.append(new QDockAreaLayoutInfo(info));
- new_info.item_list.append(dockWidgetItem);
- info = new_info;
- }
-
- QList<int> index = indexOfPlaceHolder(dockWidget->objectName());
- if (!index.isEmpty())
- remove(index);
-}
-
-void QDockAreaLayout::tabifyDockWidget(QDockWidget *first, QDockWidget *second)
-{
- QList<int> path = indexOf(first);
- if (path.isEmpty())
- return;
-
- QDockAreaLayoutInfo *info = this->info(path);
- Q_ASSERT(info != 0);
- info->tab(path.last(), new QDockWidgetItem(second));
-
- QList<int> index = indexOfPlaceHolder(second->objectName());
- if (!index.isEmpty())
- remove(index);
-}
-
-void QDockAreaLayout::splitDockWidget(QDockWidget *after,
- QDockWidget *dockWidget,
- Qt::Orientation orientation)
-{
- QList<int> path = indexOf(after);
- if (path.isEmpty())
- return;
-
- QDockAreaLayoutInfo *info = this->info(path);
- Q_ASSERT(info != 0);
- info->split(path.last(), orientation, new QDockWidgetItem(dockWidget));
-
- QList<int> index = indexOfPlaceHolder(dockWidget->objectName());
- if (!index.isEmpty())
- remove(index);
-}
-
-void QDockAreaLayout::apply(bool animate)
-{
- QWidgetAnimator &widgetAnimator = qt_mainwindow_layout(mainWindow)->widgetAnimator;
-
- for (int i = 0; i < QInternal::DockCount; ++i)
- docks[i].apply(animate);
- if (centralWidgetItem != 0 && !centralWidgetItem->isEmpty()) {
- widgetAnimator.animate(centralWidgetItem->widget(), centralWidgetRect,
- animate);
- }
-#ifndef QT_NO_TABBAR
- if (sep == 1)
- updateSeparatorWidgets();
-#endif //QT_NO_TABBAR
-}
-
-void QDockAreaLayout::paintSeparators(QPainter *p, QWidget *widget,
- const QRegion &clip,
- const QPoint &mouse) const
-{
- for (int i = 0; i < QInternal::DockCount; ++i) {
- const QDockAreaLayoutInfo &dock = docks[i];
- if (dock.isEmpty())
- continue;
- QRect r = separatorRect(i);
- if (clip.contains(r) && !dock.hasFixedSize()) {
- Qt::Orientation opposite = dock.o == Qt::Horizontal
- ? Qt::Vertical : Qt::Horizontal;
- paintSep(p, widget, r, opposite, r.contains(mouse));
- }
- if (clip.contains(dock.rect))
- dock.paintSeparators(p, widget, clip, mouse);
- }
-}
-
-QRegion QDockAreaLayout::separatorRegion() const
-{
- QRegion result;
-
- for (int i = 0; i < QInternal::DockCount; ++i) {
- const QDockAreaLayoutInfo &dock = docks[i];
- if (dock.isEmpty())
- continue;
- result |= separatorRect(i);
- result |= dock.separatorRegion();
- }
-
- return result;
-}
-
-int QDockAreaLayout::separatorMove(const QList<int> &separator, const QPoint &origin,
- const QPoint &dest)
-{
- int delta = 0;
- int index = separator.last();
-
- if (separator.count() > 1) {
- QDockAreaLayoutInfo *info = this->info(separator);
- delta = pick(info->o, dest - origin);
- if (delta != 0)
- delta = info->separatorMove(index, delta);
- info->apply(false);
- return delta;
- }
-
- QVector<QLayoutStruct> list;
-
- if (index == QInternal::LeftDock || index == QInternal::RightDock)
- getGrid(0, &list);
- else
- getGrid(&list, 0);
-
- int sep_index = index == QInternal::LeftDock || index == QInternal::TopDock
- ? 0 : 1;
- Qt::Orientation o = index == QInternal::LeftDock || index == QInternal::RightDock
- ? Qt::Horizontal
- : Qt::Vertical;
-
- delta = pick(o, dest - origin);
- delta = separatorMoveHelper(list, sep_index, delta, sep);
-
- if (index == QInternal::LeftDock || index == QInternal::RightDock)
- setGrid(0, &list);
- else
- setGrid(&list, 0);
-
- apply(false);
-
- return delta;
-}
-
-#ifndef QT_NO_TABBAR
-// Sets the correct positions for the separator widgets
-// Allocates new sepearator widgets with getSeparatorWidget
-void QDockAreaLayout::updateSeparatorWidgets() const
-{
- int j = 0;
-
- for (int i = 0; i < QInternal::DockCount; ++i) {
- const QDockAreaLayoutInfo &dock = docks[i];
- if (dock.isEmpty())
- continue;
-
- QWidget *sepWidget;
- if (j < separatorWidgets.size()) {
- sepWidget = separatorWidgets.at(j);
- } else {
- sepWidget = qt_mainwindow_layout(mainWindow)->getSeparatorWidget();
- separatorWidgets.append(sepWidget);
- }
- j++;
-
-#ifndef QT_MAC_USE_COCOA
- sepWidget->raise();
-#endif
- QRect sepRect = separatorRect(i).adjusted(-2, -2, 2, 2);
- sepWidget->setGeometry(sepRect);
- sepWidget->setMask( QRegion(separatorRect(i).translated( - sepRect.topLeft())));
- sepWidget->show();
- }
- for (int i = j; i < separatorWidgets.size(); ++i)
- separatorWidgets.at(i)->hide();
-
- separatorWidgets.resize(j);
-}
-#endif //QT_NO_TABBAR
-
-QLayoutItem *QDockAreaLayout::itemAt(int *x, int index) const
-{
- Q_ASSERT(x != 0);
-
- for (int i = 0; i < QInternal::DockCount; ++i) {
- const QDockAreaLayoutInfo &dock = docks[i];
- if (QLayoutItem *ret = dock.itemAt(x, index))
- return ret;
- }
-
- if (centralWidgetItem && (*x)++ == index)
- return centralWidgetItem;
-
- return 0;
-}
-
-QLayoutItem *QDockAreaLayout::takeAt(int *x, int index)
-{
- Q_ASSERT(x != 0);
-
- for (int i = 0; i < QInternal::DockCount; ++i) {
- QDockAreaLayoutInfo &dock = docks[i];
- if (QLayoutItem *ret = dock.takeAt(x, index))
- return ret;
- }
-
- if (centralWidgetItem && (*x)++ == index) {
- QLayoutItem *ret = centralWidgetItem;
- centralWidgetItem = 0;
- return ret;
- }
-
- return 0;
-}
-
-void QDockAreaLayout::deleteAllLayoutItems()
-{
- for (int i = 0; i < QInternal::DockCount; ++i)
- docks[i].deleteAllLayoutItems();
-}
-
-#ifndef QT_NO_TABBAR
-QSet<QTabBar*> QDockAreaLayout::usedTabBars() const
-{
- QSet<QTabBar*> result;
- for (int i = 0; i < QInternal::DockCount; ++i) {
- const QDockAreaLayoutInfo &dock = docks[i];
- result += dock.usedTabBars();
- }
- return result;
-}
-
-// Returns the set of all used separator widgets
-QSet<QWidget*> QDockAreaLayout::usedSeparatorWidgets() const
-{
- QSet<QWidget*> result;
-
- for (int i = 0; i < separatorWidgets.count(); ++i)
- result << separatorWidgets.at(i);
- for (int i = 0; i < QInternal::DockCount; ++i) {
- const QDockAreaLayoutInfo &dock = docks[i];
- result += dock.usedSeparatorWidgets();
- }
- return result;
-}
-#endif
-
-QRect QDockAreaLayout::gapRect(const QList<int> &path) const
-{
- const QDockAreaLayoutInfo *info = this->info(path);
- if (info == 0)
- return QRect();
- const QList<QDockAreaLayoutItem> &item_list = info->item_list;
- Qt::Orientation o = info->o;
- int index = path.last();
- if (index < 0 || index >= item_list.count())
- return QRect();
- const QDockAreaLayoutItem &item = item_list.at(index);
- if (!(item.flags & QDockAreaLayoutItem::GapItem))
- return QRect();
-
- QRect result;
-
-#ifndef QT_NO_TABBAR
- if (info->tabbed) {
- result = info->tabContentRect();
- } else
-#endif
- {
- int pos = item.pos;
- int size = item.size;
-
- int prev = info->prev(index);
- int next = info->next(index);
-
- if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) {
- pos += sep;
- size -= sep;
- }
- if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
- size -= sep;
-
- QPoint p;
- rpick(o, p) = pos;
- rperp(o, p) = perp(o, info->rect.topLeft());
- QSize s;
- rpick(o, s) = size;
- rperp(o, s) = perp(o, info->rect.size());
-
- result = QRect(p, s);
- }
-
- return result;
-}
-
-void QDockAreaLayout::keepSize(QDockWidget *w)
-{
- QList<int> path = indexOf(w);
- if (path.isEmpty())
- return;
- QDockAreaLayoutItem &item = this->item(path);
- if (item.size != -1)
- item.flags |= QDockAreaLayoutItem::KeepSize;
-}
-
-void QDockAreaLayout::styleChangedEvent()
-{
- sep = mainWindow->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, mainWindow);
- fitLayout();
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_DOCKWIDGET
diff --git a/src/gui/widgets/qdockarealayout_p.h b/src/gui/widgets/qdockarealayout_p.h
deleted file mode 100644
index c1c8445b3d..0000000000
--- a/src/gui/widgets/qdockarealayout_p.h
+++ /dev/null
@@ -1,308 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDOCKAREALAYOUT_P_H
-#define QDOCKAREALAYOUT_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "QtCore/qrect.h"
-#include "QtCore/qpair.h"
-#include "QtCore/qlist.h"
-#include "QtCore/qvector.h"
-#include "QtGui/qlayout.h"
-
-#ifndef QT_NO_DOCKWIDGET
-
-QT_BEGIN_NAMESPACE
-
-class QLayoutItem;
-class QWidget;
-class QLayoutItem;
-class QDockAreaLayoutInfo;
-class QPlaceHolderItem;
-class QDockWidget;
-class QMainWindow;
-class QWidgetAnimator;
-class QMainWindowLayout;
-struct QLayoutStruct;
-class QTabBar;
-
-// The classes in this file represent the tree structure that represents all the docks
-// Also see the wiki internal documentation
-// At the root of the tree is: QDockAreaLayout, which handles all 4 sides, so there is only one.
-// For each side it has one QDockAreaLayoutInfo child. (See QDockAreaLayout::docks.)
-// The QDockAreaLayoutInfo have QDockAreaLayoutItems as children (See QDockAreaLayoutInfo::item_list),
-// which then has one QDockAreaLayoutInfo as a child. (QDockAreaLayoutItem::subInfo) or
-// a widgetItem if this is a node of the tree (QDockAreaLayoutItem::widgetItem)
-//
-// A path indetifies uniquely one object in this tree, the first number being the side and all the following
-// indexes into the QDockAreaLayoutInfo::item_list.
-
-struct QDockAreaLayoutItem
-{
- enum ItemFlags { NoFlags = 0, GapItem = 1, KeepSize = 2 };
-
- QDockAreaLayoutItem(QLayoutItem *_widgetItem = 0);
- QDockAreaLayoutItem(QDockAreaLayoutInfo *_subinfo);
- QDockAreaLayoutItem(QPlaceHolderItem *_placeHolderItem);
- QDockAreaLayoutItem(const QDockAreaLayoutItem &other);
- ~QDockAreaLayoutItem();
-
- QDockAreaLayoutItem &operator = (const QDockAreaLayoutItem &other);
-
- bool skip() const;
- QSize minimumSize() const;
- QSize maximumSize() const;
- QSize sizeHint() const;
- bool expansive(Qt::Orientation o) const;
- bool hasFixedSize(Qt::Orientation o) const;
-
- QLayoutItem *widgetItem;
- QDockAreaLayoutInfo *subinfo;
- QPlaceHolderItem *placeHolderItem;
- int pos;
- int size;
- uint flags;
-};
-
-class Q_AUTOTEST_EXPORT QPlaceHolderItem
-{
-public:
- QPlaceHolderItem() : hidden(false), window(false) {}
- QPlaceHolderItem(QWidget *w);
-
- QString objectName;
- bool hidden, window;
- QRect topLevelRect;
-};
-
-class Q_AUTOTEST_EXPORT QDockAreaLayoutInfo
-{
-public:
- QDockAreaLayoutInfo();
- QDockAreaLayoutInfo(const int *_sep, QInternal::DockPosition _dockPos, Qt::Orientation _o,
- int tbhape, QMainWindow *window);
-
- QSize minimumSize() const;
- QSize maximumSize() const;
- QSize sizeHint() const;
- QSize size() const;
-
- bool insertGap(const QList<int> &path, QLayoutItem *dockWidgetItem);
- QLayoutItem *plug(const QList<int> &path);
- QLayoutItem *unplug(const QList<int> &path);
- enum TabMode { NoTabs, AllowTabs, ForceTabs };
- QList<int> gapIndex(const QPoint &pos, bool nestingEnabled,
- TabMode tabMode) const;
- void remove(const QList<int> &path);
- void unnest(int index);
- void split(int index, Qt::Orientation orientation, QLayoutItem *dockWidgetItem);
- void tab(int index, QLayoutItem *dockWidgetItem);
- QDockAreaLayoutItem &item(const QList<int> &path);
- QDockAreaLayoutInfo *info(const QList<int> &path);
- QDockAreaLayoutInfo *info(QWidget *widget);
-
- enum { // sentinel values used to validate state data
- SequenceMarker = 0xfc,
- TabMarker = 0xfa,
- WidgetMarker = 0xfb
- };
- void saveState(QDataStream &stream) const;
- bool restoreState(QDataStream &stream, QList<QDockWidget*> &widgets, bool testing);
-
- void fitItems();
- bool expansive(Qt::Orientation o) const;
- int changeSize(int index, int size, bool below);
- QRect itemRect(int index) const;
- QRect itemRect(const QList<int> &path) const;
- QRect separatorRect(int index) const;
- QRect separatorRect(const QList<int> &path) const;
-
- void clear();
- bool isEmpty() const;
- bool hasFixedSize() const;
- QList<int> findSeparator(const QPoint &pos) const;
- int next(int idx) const;
- int prev(int idx) const;
-
- QList<int> indexOf(QWidget *widget) const;
- QList<int> indexOfPlaceHolder(const QString &objectName) const;
-
- void apply(bool animate);
-
- void paintSeparators(QPainter *p, QWidget *widget, const QRegion &clip,
- const QPoint &mouse) const;
- QRegion separatorRegion() const;
- int separatorMove(int index, int delta);
-
- QLayoutItem *itemAt(int *x, int index) const;
- QLayoutItem *takeAt(int *x, int index);
- void deleteAllLayoutItems();
-
- QMainWindowLayout *mainWindowLayout() const;
-
- const int *sep;
- mutable QVector<QWidget*> separatorWidgets;
- QInternal::DockPosition dockPos;
- Qt::Orientation o;
- QRect rect;
- QMainWindow *mainWindow;
- QList<QDockAreaLayoutItem> item_list;
-#ifndef QT_NO_TABBAR
- void updateSeparatorWidgets() const;
- QSet<QWidget*> usedSeparatorWidgets() const;
-#endif //QT_NO_TABBAR
-
-#ifndef QT_NO_TABBAR
- quintptr currentTabId() const;
- void setCurrentTab(QWidget *widget);
- void setCurrentTabId(quintptr id);
- QRect tabContentRect() const;
- bool tabbed;
- QTabBar *tabBar;
- int tabBarShape;
-
- bool updateTabBar() const;
- void setTabBarShape(int shape);
- QSize tabBarMinimumSize() const;
- QSize tabBarSizeHint() const;
-
- QSet<QTabBar*> usedTabBars() const;
-#endif // QT_NO_TABBAR
-};
-
-class Q_AUTOTEST_EXPORT QDockAreaLayout
-{
-public:
- enum { EmptyDropAreaSize = 80 }; // when a dock area is empty, how "wide" is it?
-
- Qt::DockWidgetArea corners[4]; // use a Qt::Corner for indexing
- QRect rect;
- QLayoutItem *centralWidgetItem;
- QMainWindow *mainWindow;
- QRect centralWidgetRect;
- QDockAreaLayout(QMainWindow *win);
- QDockAreaLayoutInfo docks[4];
- int sep; // separator extent
- bool fallbackToSizeHints; //determines if we should use the sizehint for the dock areas (true until the layout is restored or the central widget is set)
- mutable QVector<QWidget*> separatorWidgets;
-
- bool isValid() const;
-
- enum { DockWidgetStateMarker = 0xfd };
- void saveState(QDataStream &stream) const;
- bool restoreState(QDataStream &stream, const QList<QDockWidget*> &widgets, bool testing = false);
-
- QList<int> indexOfPlaceHolder(const QString &objectName) const;
- QList<int> indexOf(QWidget *dockWidget) const;
- QList<int> gapIndex(const QPoint &pos) const;
- QList<int> findSeparator(const QPoint &pos) const;
-
- QDockAreaLayoutItem &item(const QList<int> &path);
- QDockAreaLayoutInfo *info(const QList<int> &path);
- const QDockAreaLayoutInfo *info(const QList<int> &path) const;
- QDockAreaLayoutInfo *info(QWidget *widget);
- QRect itemRect(const QList<int> &path) const;
- QRect separatorRect(int index) const;
- QRect separatorRect(const QList<int> &path) const;
-
- bool insertGap(const QList<int> &path, QLayoutItem *dockWidgetItem);
- QLayoutItem *plug(const QList<int> &path);
- QLayoutItem *unplug(const QList<int> &path);
- void remove(const QList<int> &path);
-
- void fitLayout();
-
- void clear();
-
- QSize sizeHint() const;
- QSize minimumSize() const;
-
- void addDockWidget(QInternal::DockPosition pos, QDockWidget *dockWidget, Qt::Orientation orientation);
- bool restoreDockWidget(QDockWidget *dockWidget);
- void splitDockWidget(QDockWidget *after, QDockWidget *dockWidget,
- Qt::Orientation orientation);
- void tabifyDockWidget(QDockWidget *first, QDockWidget *second);
-
- void apply(bool animate);
-
- void paintSeparators(QPainter *p, QWidget *widget, const QRegion &clip,
- const QPoint &mouse) const;
- QRegion separatorRegion() const;
- int separatorMove(const QList<int> &separator, const QPoint &origin, const QPoint &dest);
-#ifndef QT_NO_TABBAR
- void updateSeparatorWidgets() const;
-#endif //QT_NO_TABBAR
-
- QLayoutItem *itemAt(int *x, int index) const;
- QLayoutItem *takeAt(int *x, int index);
- void deleteAllLayoutItems();
-
- void getGrid(QVector<QLayoutStruct> *ver_struct_list,
- QVector<QLayoutStruct> *hor_struct_list);
- void setGrid(QVector<QLayoutStruct> *ver_struct_list,
- QVector<QLayoutStruct> *hor_struct_list);
-
- QRect gapRect(const QList<int> &path) const;
-
- void keepSize(QDockWidget *w);
-#ifndef QT_NO_TABBAR
- QSet<QTabBar*> usedTabBars() const;
- QSet<QWidget*> usedSeparatorWidgets() const;
-#endif //QT_NO_TABBAR
- void styleChangedEvent();
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QDOCKWIDGET
-
-#endif // QDOCKAREALAYOUT_P_H
diff --git a/src/gui/widgets/qdockwidget.h b/src/gui/widgets/qdockwidget.h
deleted file mode 100644
index d26528bcb1..0000000000
--- a/src/gui/widgets/qdockwidget.h
+++ /dev/null
@@ -1,146 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDYNAMICDOCKWIDGET_H
-#define QDYNAMICDOCKWIDGET_H
-
-#include <QtGui/qwidget.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_DOCKWIDGET
-
-class QDockAreaLayout;
-class QDockWidgetPrivate;
-class QMainWindow;
-class QStyleOptionDockWidget;
-
-class Q_GUI_EXPORT QDockWidget : public QWidget
-{
- Q_OBJECT
-
- Q_FLAGS(DockWidgetFeatures)
- Q_PROPERTY(bool floating READ isFloating WRITE setFloating)
- Q_PROPERTY(DockWidgetFeatures features READ features WRITE setFeatures NOTIFY featuresChanged)
- Q_PROPERTY(Qt::DockWidgetAreas allowedAreas READ allowedAreas
- WRITE setAllowedAreas NOTIFY allowedAreasChanged)
- Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle DESIGNABLE true)
-
-public:
- explicit QDockWidget(const QString &title, QWidget *parent = 0, Qt::WindowFlags flags = 0);
- explicit QDockWidget(QWidget *parent = 0, Qt::WindowFlags flags = 0);
- ~QDockWidget();
-
- QWidget *widget() const;
- void setWidget(QWidget *widget);
-
- enum DockWidgetFeature {
- DockWidgetClosable = 0x01,
- DockWidgetMovable = 0x02,
- DockWidgetFloatable = 0x04,
- DockWidgetVerticalTitleBar = 0x08,
-
- DockWidgetFeatureMask = 0x0f,
- AllDockWidgetFeatures = DockWidgetClosable|DockWidgetMovable|DockWidgetFloatable, // ### remove in 5.0
- NoDockWidgetFeatures = 0x00,
-
- Reserved = 0xff
- };
- Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature)
-
- void setFeatures(DockWidgetFeatures features);
- DockWidgetFeatures features() const;
-
- void setFloating(bool floating);
- inline bool isFloating() const { return isWindow(); }
-
- void setAllowedAreas(Qt::DockWidgetAreas areas);
- Qt::DockWidgetAreas allowedAreas() const;
-
- void setTitleBarWidget(QWidget *widget);
- QWidget *titleBarWidget() const;
-
- inline bool isAreaAllowed(Qt::DockWidgetArea area) const
- { return (allowedAreas() & area) == area; }
-
-#ifndef QT_NO_ACTION
- QAction *toggleViewAction() const;
-#endif
-
-Q_SIGNALS:
- void featuresChanged(QDockWidget::DockWidgetFeatures features);
- void topLevelChanged(bool topLevel);
- void allowedAreasChanged(Qt::DockWidgetAreas allowedAreas);
- void visibilityChanged(bool visible);
- void dockLocationChanged(Qt::DockWidgetArea area);
-
-protected:
- void changeEvent(QEvent *event);
- void closeEvent(QCloseEvent *event);
- void paintEvent(QPaintEvent *event);
- bool event(QEvent *event);
- void initStyleOption(QStyleOptionDockWidget *option) const;
-
-private:
- Q_DECLARE_PRIVATE(QDockWidget)
- Q_DISABLE_COPY(QDockWidget)
- Q_PRIVATE_SLOT(d_func(), void _q_toggleView(bool))
- Q_PRIVATE_SLOT(d_func(), void _q_toggleTopLevel())
- friend class QDockAreaLayout;
- friend class QDockWidgetItem;
- friend class QMainWindowLayout;
- friend class QDockWidgetLayout;
- friend class QDockAreaLayoutInfo;
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QDockWidget::DockWidgetFeatures)
-
-#endif // QT_NO_DOCKWIDGET
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDYNAMICDOCKWIDGET_H
diff --git a/src/gui/widgets/qdockwidget_p.h b/src/gui/widgets/qdockwidget_p.h
deleted file mode 100644
index f71a276003..0000000000
--- a/src/gui/widgets/qdockwidget_p.h
+++ /dev/null
@@ -1,207 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDYNAMICDOCKWIDGET_P_H
-#define QDYNAMICDOCKWIDGET_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "QtGui/qstyleoption.h"
-#include "private/qwidget_p.h"
-#include "QtGui/qboxlayout.h"
-#include "QtGui/qdockwidget.h"
-
-#ifndef QT_NO_DOCKWIDGET
-
-QT_BEGIN_NAMESPACE
-
-class QGridLayout;
-class QWidgetResizeHandler;
-class QRubberBand;
-class QDockWidgetTitleButton;
-class QSpacerItem;
-class QDockWidgetItem;
-
-class QDockWidgetPrivate : public QWidgetPrivate
-{
- Q_DECLARE_PUBLIC(QDockWidget)
-
- struct DragState {
- QPoint pressPos;
- bool dragging;
- QLayoutItem *widgetItem;
- bool ownWidgetItem;
- bool nca;
- bool ctrlDrag;
- };
-
-public:
- inline QDockWidgetPrivate()
- : QWidgetPrivate(), state(0),
- features(QDockWidget::DockWidgetClosable
- | QDockWidget::DockWidgetMovable
- | QDockWidget::DockWidgetFloatable),
- allowedAreas(Qt::AllDockWidgetAreas)
- { }
-
- void init();
- void _q_toggleView(bool); // private slot
- void _q_toggleTopLevel(); // private slot
-
- void updateButtons();
- DragState *state;
-
- QDockWidget::DockWidgetFeatures features;
- Qt::DockWidgetAreas allowedAreas;
-
- QWidgetResizeHandler *resizer;
-
-#ifndef QT_NO_ACTION
- QAction *toggleViewAction;
-#endif
-
-// QMainWindow *findMainWindow(QWidget *widget) const;
- QRect undockedGeometry;
- QString fixedWindowTitle;
-
- bool mousePressEvent(QMouseEvent *event);
- bool mouseDoubleClickEvent(QMouseEvent *event);
- bool mouseMoveEvent(QMouseEvent *event);
- bool mouseReleaseEvent(QMouseEvent *event);
- void setWindowState(bool floating, bool unplug = false, const QRect &rect = QRect());
- void nonClientAreaMouseEvent(QMouseEvent *event);
- void initDrag(const QPoint &pos, bool nca);
- void startDrag();
- void endDrag(bool abort = false);
- void moveEvent(QMoveEvent *event);
-
- void unplug(const QRect &rect);
- void plug(const QRect &rect);
-
- bool isAnimating() const;
-};
-
-class Q_GUI_EXPORT QDockWidgetLayout : public QLayout
-{
- Q_OBJECT
-public:
- QDockWidgetLayout(QWidget *parent = 0);
- ~QDockWidgetLayout();
- void addItem(QLayoutItem *item);
- QLayoutItem *itemAt(int index) const;
- QLayoutItem *takeAt(int index);
- int count() const;
-
- QSize maximumSize() const;
- QSize minimumSize() const;
- QSize sizeHint() const;
-
- QSize sizeFromContent(const QSize &content, bool floating) const;
-
- void setGeometry(const QRect &r);
-
- enum Role { Content, CloseButton, FloatButton, TitleBar, RoleCount };
- QWidget *widgetForRole(Role r) const;
- void setWidgetForRole(Role r, QWidget *w);
- QLayoutItem *itemForRole(Role r) const;
-
- QRect titleArea() const { return _titleArea; }
-
- int minimumTitleWidth() const;
- int titleHeight() const;
- void updateMaxSize();
- bool nativeWindowDeco() const;
- bool nativeWindowDeco(bool floating) const;
-
- void setVerticalTitleBar(bool b);
-
- bool verticalTitleBar;
-
-private:
- QVector<QLayoutItem*> item_list;
- QRect _titleArea;
-};
-
-/* The size hints of a QDockWidget will depend on whether it is docked or not.
- This layout item always returns the size hints as if the dock widget was docked. */
-
-class QDockWidgetItem : public QWidgetItem
-{
-public:
- QDockWidgetItem(QDockWidget *dockWidget);
- QSize minimumSize() const;
- QSize maximumSize() const;
- QSize sizeHint() const;
-
-private:
- inline QLayoutItem *dockWidgetChildItem() const;
- inline QDockWidgetLayout *dockWidgetLayout() const;
-};
-
-inline QLayoutItem *QDockWidgetItem::dockWidgetChildItem() const
-{
- if (QDockWidgetLayout *layout = dockWidgetLayout())
- return layout->itemForRole(QDockWidgetLayout::Content);
- return 0;
-}
-
-inline QDockWidgetLayout *QDockWidgetItem::dockWidgetLayout() const
-{
- QWidget *w = const_cast<QDockWidgetItem*>(this)->widget();
- if (w != 0)
- return qobject_cast<QDockWidgetLayout*>(w->layout());
- return 0;
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_DOCKWIDGET
-
-#endif // QDYNAMICDOCKWIDGET_P_H
diff --git a/src/gui/widgets/qfocusframe.h b/src/gui/widgets/qfocusframe.h
deleted file mode 100644
index 3ed411d558..0000000000
--- a/src/gui/widgets/qfocusframe.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFOCUSFRAME_H
-#define QFOCUSFRAME_H
-
-#include <QtGui/qwidget.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QFocusFramePrivate;
-class QStyleOption;
-
-class Q_GUI_EXPORT QFocusFrame : public QWidget
-{
- Q_OBJECT
-public:
- QFocusFrame(QWidget *parent=0);
- ~QFocusFrame();
-
- void setWidget(QWidget *widget);
- QWidget *widget() const;
-
-protected:
- bool event(QEvent *e);
-
- bool eventFilter(QObject *, QEvent *);
- void paintEvent(QPaintEvent *);
- void initStyleOption(QStyleOption *option) const;
-
-private:
- Q_DECLARE_PRIVATE(QFocusFrame)
- Q_DISABLE_COPY(QFocusFrame)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QFOCUSFRAME_H
diff --git a/src/gui/widgets/qfontcombobox.h b/src/gui/widgets/qfontcombobox.h
deleted file mode 100644
index 1eb647a855..0000000000
--- a/src/gui/widgets/qfontcombobox.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFONTCOMBOBOX_H
-#define QFONTCOMBOBOX_H
-
-#include <QtGui/qcombobox.h>
-#include <QtGui/qfontdatabase.h>
-
-#ifndef QT_NO_FONTCOMBOBOX
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QFontComboBoxPrivate;
-
-class Q_GUI_EXPORT QFontComboBox : public QComboBox
-{
- Q_OBJECT
- Q_FLAGS(FontFilters)
- Q_PROPERTY(QFontDatabase::WritingSystem writingSystem READ writingSystem WRITE setWritingSystem)
- Q_PROPERTY(FontFilters fontFilters READ fontFilters WRITE setFontFilters)
- Q_PROPERTY(QFont currentFont READ currentFont WRITE setCurrentFont NOTIFY currentFontChanged)
- Q_ENUMS(FontSelection)
-
-public:
- explicit QFontComboBox(QWidget *parent = 0);
- ~QFontComboBox();
-
- void setWritingSystem(QFontDatabase::WritingSystem);
- QFontDatabase::WritingSystem writingSystem() const;
-
- enum FontFilter {
- AllFonts = 0,
- ScalableFonts = 0x1,
- NonScalableFonts = 0x2,
- MonospacedFonts = 0x4,
- ProportionalFonts = 0x8
- };
- Q_DECLARE_FLAGS(FontFilters, FontFilter)
-
- void setFontFilters(FontFilters filters);
- FontFilters fontFilters() const;
-
- QFont currentFont() const;
- QSize sizeHint() const;
-
-public Q_SLOTS:
- void setCurrentFont(const QFont &f);
-
-Q_SIGNALS:
- void currentFontChanged(const QFont &f);
-
-protected:
- bool event(QEvent *e);
-
-private:
- Q_DISABLE_COPY(QFontComboBox)
- Q_DECLARE_PRIVATE(QFontComboBox)
- Q_PRIVATE_SLOT(d_func(), void _q_currentChanged(const QString &))
- Q_PRIVATE_SLOT(d_func(), void _q_updateModel())
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QFontComboBox::FontFilters)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_FONTCOMBOBOX
-#endif
diff --git a/src/gui/widgets/qframe.h b/src/gui/widgets/qframe.h
deleted file mode 100644
index 8596961e62..0000000000
--- a/src/gui/widgets/qframe.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QFRAME_H
-#define QFRAME_H
-
-#include <QtGui/qwidget.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QFramePrivate;
-
-class Q_GUI_EXPORT QFrame : public QWidget
-{
- Q_OBJECT
-
- Q_ENUMS(Shape Shadow)
- Q_PROPERTY(Shape frameShape READ frameShape WRITE setFrameShape)
- Q_PROPERTY(Shadow frameShadow READ frameShadow WRITE setFrameShadow)
- Q_PROPERTY(int lineWidth READ lineWidth WRITE setLineWidth)
- Q_PROPERTY(int midLineWidth READ midLineWidth WRITE setMidLineWidth)
- Q_PROPERTY(int frameWidth READ frameWidth)
- Q_PROPERTY(QRect frameRect READ frameRect WRITE setFrameRect DESIGNABLE false)
-
-public:
- explicit QFrame(QWidget* parent = 0, Qt::WindowFlags f = 0);
- ~QFrame();
-
- int frameStyle() const;
- void setFrameStyle(int);
-
- int frameWidth() const;
-
- QSize sizeHint() const;
-
- enum Shape {
- NoFrame = 0, // no frame
- Box = 0x0001, // rectangular box
- Panel = 0x0002, // rectangular panel
- WinPanel = 0x0003, // rectangular panel (Windows)
- HLine = 0x0004, // horizontal line
- VLine = 0x0005, // vertical line
- StyledPanel = 0x0006 // rectangular panel depending on the GUI style
-
-#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
- ,PopupPanel = StyledPanel, // rectangular panel depending on the GUI style
- MenuBarPanel = StyledPanel,
- ToolBarPanel = StyledPanel,
- LineEditPanel = StyledPanel,
- TabWidgetPanel = StyledPanel,
- GroupBoxPanel = StyledPanel
-#endif
- };
- enum Shadow {
- Plain = 0x0010, // plain line
- Raised = 0x0020, // raised shadow effect
- Sunken = 0x0030 // sunken shadow effect
- };
-
- enum StyleMask {
- Shadow_Mask = 0x00f0, // mask for the shadow
- Shape_Mask = 0x000f // mask for the shape
-#if defined(QT3_SUPPORT)
- ,MShadow = Shadow_Mask,
- MShape = Shape_Mask
-#endif
- };
-
- Shape frameShape() const;
- void setFrameShape(Shape);
- Shadow frameShadow() const;
- void setFrameShadow(Shadow);
-
- int lineWidth() const;
- void setLineWidth(int);
-
- int midLineWidth() const;
- void setMidLineWidth(int);
-
- QRect frameRect() const;
- void setFrameRect(const QRect &);
-
-protected:
- bool event(QEvent *e);
- void paintEvent(QPaintEvent *);
- void changeEvent(QEvent *);
- void drawFrame(QPainter *);
-
-#ifdef QT3_SUPPORT
-public:
- QT3_SUPPORT_CONSTRUCTOR QFrame(QWidget* parent, const char* name, Qt::WindowFlags f = 0);
-#endif
-
-protected:
- QFrame(QFramePrivate &dd, QWidget* parent = 0, Qt::WindowFlags f = 0);
-
-private:
- Q_DISABLE_COPY(QFrame)
- Q_DECLARE_PRIVATE(QFrame)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QFRAME_H
diff --git a/src/gui/widgets/qgroupbox.h b/src/gui/widgets/qgroupbox.h
deleted file mode 100644
index 84dc886bb9..0000000000
--- a/src/gui/widgets/qgroupbox.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGROUPBOX_H
-#define QGROUPBOX_H
-
-#include <QtGui/qframe.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_GROUPBOX
-
-class QGroupBoxPrivate;
-class QStyleOptionGroupBox;
-class Q_GUI_EXPORT QGroupBox : public QWidget
-{
- Q_OBJECT
-
- Q_PROPERTY(QString title READ title WRITE setTitle)
- Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
- Q_PROPERTY(bool flat READ isFlat WRITE setFlat)
- Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable)
- Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled USER true)
-public:
- explicit QGroupBox(QWidget* parent=0);
- explicit QGroupBox(const QString &title, QWidget* parent=0);
- ~QGroupBox();
-
- QString title() const;
- void setTitle(const QString &title);
-
- Qt::Alignment alignment() const;
- void setAlignment(int alignment);
-
- QSize minimumSizeHint() const;
-
- bool isFlat() const;
- void setFlat(bool flat);
- bool isCheckable() const;
- void setCheckable(bool checkable);
- bool isChecked() const;
-
-public Q_SLOTS:
- void setChecked(bool checked);
-
-Q_SIGNALS:
- void clicked(bool checked = false);
- void toggled(bool);
-
-protected:
- bool event(QEvent *event);
- void childEvent(QChildEvent *event);
- void resizeEvent(QResizeEvent *event);
- void paintEvent(QPaintEvent *event);
- void focusInEvent(QFocusEvent *event);
- void changeEvent(QEvent *event);
- void mousePressEvent(QMouseEvent *event);
- void mouseMoveEvent(QMouseEvent *event);
- void mouseReleaseEvent(QMouseEvent *event);
- void initStyleOption(QStyleOptionGroupBox *option) const;
-
-#ifdef QT3_SUPPORT
-public:
- QT3_SUPPORT_CONSTRUCTOR QGroupBox(QWidget* parent, const char* name);
- QT3_SUPPORT_CONSTRUCTOR QGroupBox(const QString &title, QWidget* parent, const char* name);
-#endif
-
-private:
- Q_DISABLE_COPY(QGroupBox)
- Q_DECLARE_PRIVATE(QGroupBox)
- Q_PRIVATE_SLOT(d_func(), void _q_setChildrenEnabled(bool b))
-};
-
-#endif // QT_NO_GROUPBOX
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QGROUPBOX_H
diff --git a/src/gui/widgets/qlabel.h b/src/gui/widgets/qlabel.h
deleted file mode 100644
index 27ab164dc6..0000000000
--- a/src/gui/widgets/qlabel.h
+++ /dev/null
@@ -1,182 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QLABEL_H
-#define QLABEL_H
-
-#include <QtGui/qframe.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QLabelPrivate;
-
-class Q_GUI_EXPORT QLabel : public QFrame
-{
- Q_OBJECT
- Q_PROPERTY(QString text READ text WRITE setText)
- Q_PROPERTY(Qt::TextFormat textFormat READ textFormat WRITE setTextFormat)
- Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)
- Q_PROPERTY(bool scaledContents READ hasScaledContents WRITE setScaledContents)
- Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
- Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
- Q_PROPERTY(int margin READ margin WRITE setMargin)
- Q_PROPERTY(int indent READ indent WRITE setIndent)
- Q_PROPERTY(bool openExternalLinks READ openExternalLinks WRITE setOpenExternalLinks)
- Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
- Q_PROPERTY(bool hasSelectedText READ hasSelectedText)
- Q_PROPERTY(QString selectedText READ selectedText)
-
-public:
- explicit QLabel(QWidget *parent=0, Qt::WindowFlags f=0);
- explicit QLabel(const QString &text, QWidget *parent=0, Qt::WindowFlags f=0);
- ~QLabel();
-
- QString text() const;
- const QPixmap *pixmap() const;
-#ifndef QT_NO_PICTURE
- const QPicture *picture() const;
-#endif
-#ifndef QT_NO_MOVIE
- QMovie *movie() const;
-#endif
-
- Qt::TextFormat textFormat() const;
- void setTextFormat(Qt::TextFormat);
-
- Qt::Alignment alignment() const;
- void setAlignment(Qt::Alignment);
-
- void setWordWrap(bool on);
- bool wordWrap() const;
-
- int indent() const;
- void setIndent(int);
-
- int margin() const;
- void setMargin(int);
-
- bool hasScaledContents() const;
- void setScaledContents(bool);
- QSize sizeHint() const;
- QSize minimumSizeHint() const;
-#ifndef QT_NO_SHORTCUT
- void setBuddy(QWidget *);
- QWidget *buddy() const;
-#endif
- int heightForWidth(int) const;
-
- bool openExternalLinks() const;
- void setOpenExternalLinks(bool open);
-
- void setTextInteractionFlags(Qt::TextInteractionFlags flags);
- Qt::TextInteractionFlags textInteractionFlags() const;
-
- void setSelection(int, int);
- bool hasSelectedText() const;
- QString selectedText() const;
- int selectionStart() const;
-
-public Q_SLOTS:
- void setText(const QString &);
- void setPixmap(const QPixmap &);
-#ifndef QT_NO_PICTURE
- void setPicture(const QPicture &);
-#endif
-#ifndef QT_NO_MOVIE
- void setMovie(QMovie *movie);
-#endif
- void setNum(int);
- void setNum(double);
- void clear();
-
-Q_SIGNALS:
- void linkActivated(const QString& link);
- void linkHovered(const QString& link);
-
-protected:
- bool event(QEvent *e);
- void keyPressEvent(QKeyEvent *ev);
- void paintEvent(QPaintEvent *);
- void changeEvent(QEvent *);
- void mousePressEvent(QMouseEvent *ev);
- void mouseMoveEvent(QMouseEvent *ev);
- void mouseReleaseEvent(QMouseEvent *ev);
- void contextMenuEvent(QContextMenuEvent *ev);
- void focusInEvent(QFocusEvent *ev);
- void focusOutEvent(QFocusEvent *ev);
- bool focusNextPrevChild(bool next);
-
-#ifdef QT3_SUPPORT
-public:
- QT3_SUPPORT_CONSTRUCTOR QLabel(QWidget *parent, const char* name, Qt::WindowFlags f=0);
- QT3_SUPPORT_CONSTRUCTOR QLabel(const QString &text, QWidget *parent, const char* name,
- Qt::WindowFlags f=0);
- QT3_SUPPORT_CONSTRUCTOR QLabel(QWidget *buddy, const QString &,
- QWidget *parent=0, const char* name=0, Qt::WindowFlags f=0);
- QT3_SUPPORT void setAlignment(int alignment);
-
- // don't mark the next function with QT3_SUPPORT
- inline void setAlignment(Qt::AlignmentFlag flag) { setAlignment((Qt::Alignment)flag); }
-#endif
-
-private:
- Q_DISABLE_COPY(QLabel)
- Q_DECLARE_PRIVATE(QLabel)
-#ifndef QT_NO_MOVIE
- Q_PRIVATE_SLOT(d_func(), void _q_movieUpdated(const QRect&))
- Q_PRIVATE_SLOT(d_func(), void _q_movieResized(const QSize&))
-#endif
- Q_PRIVATE_SLOT(d_func(), void _q_linkHovered(const QString &))
-
- friend class QTipLabel;
- friend class QMessageBoxPrivate;
- friend class QBalloonTip;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QLABEL_H
diff --git a/src/gui/widgets/qlcdnumber.h b/src/gui/widgets/qlcdnumber.h
deleted file mode 100644
index b1719881bd..0000000000
--- a/src/gui/widgets/qlcdnumber.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QLCDNUMBER_H
-#define QLCDNUMBER_H
-
-#include <QtGui/qframe.h>
-#include <QtCore/qbitarray.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_LCDNUMBER
-
-class QLCDNumberPrivate;
-class Q_GUI_EXPORT QLCDNumber : public QFrame // LCD number widget
-{
- Q_OBJECT
- Q_ENUMS(Mode SegmentStyle)
- Q_PROPERTY(bool smallDecimalPoint READ smallDecimalPoint WRITE setSmallDecimalPoint)
- Q_PROPERTY(int numDigits READ numDigits WRITE setNumDigits)
- Q_PROPERTY(int digitCount READ digitCount WRITE setDigitCount)
- Q_PROPERTY(Mode mode READ mode WRITE setMode)
- Q_PROPERTY(SegmentStyle segmentStyle READ segmentStyle WRITE setSegmentStyle)
- Q_PROPERTY(double value READ value WRITE display)
- Q_PROPERTY(int intValue READ intValue WRITE display)
-
-public:
- explicit QLCDNumber(QWidget* parent = 0);
- explicit QLCDNumber(uint numDigits, QWidget* parent = 0);
- ~QLCDNumber();
-
- enum Mode {
- Hex, Dec, Oct, Bin
-#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
- , HEX = Hex, DEC = Dec, OCT = Oct, BIN = Bin
-#endif
- };
- enum SegmentStyle {
- Outline, Filled, Flat
- };
-
- bool smallDecimalPoint() const;
-#ifdef QT_DEPRECATED
- QT_DEPRECATED int numDigits() const;
- QT_DEPRECATED void setNumDigits(int nDigits);
-#endif
- int digitCount() const;
- void setDigitCount(int nDigits);
-
- bool checkOverflow(double num) const;
- bool checkOverflow(int num) const;
-
- Mode mode() const;
- void setMode(Mode);
-
- SegmentStyle segmentStyle() const;
- void setSegmentStyle(SegmentStyle);
-
- double value() const;
- int intValue() const;
-
- QSize sizeHint() const;
-
-public Q_SLOTS:
- void display(const QString &str);
- void display(int num);
- void display(double num);
- void setHexMode();
- void setDecMode();
- void setOctMode();
- void setBinMode();
- void setSmallDecimalPoint(bool);
-
-Q_SIGNALS:
- void overflow();
-
-protected:
- bool event(QEvent *e);
- void paintEvent(QPaintEvent *);
-
-public:
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QLCDNumber(QWidget* parent, const char* name);
- QT3_SUPPORT_CONSTRUCTOR QLCDNumber(uint numDigits, QWidget* parent, const char* name);
-
- QT3_SUPPORT void setMargin(int margin) { setContentsMargins(margin, margin, margin, margin); }
- QT3_SUPPORT int margin() const
- { int margin; int dummy; getContentsMargins(&margin, &dummy, &dummy, &dummy); return margin; }
-#endif
-
-private:
- Q_DISABLE_COPY(QLCDNumber)
- Q_DECLARE_PRIVATE(QLCDNumber)
-};
-
-#endif // QT_NO_LCDNUMBER
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QLCDNUMBER_H
diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h
deleted file mode 100644
index 0042f17261..0000000000
--- a/src/gui/widgets/qlinecontrol_p.h
+++ /dev/null
@@ -1,456 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QLINECONTROL_P_H
-#define QLINECONTROL_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "QtCore/qglobal.h"
-
-#ifndef QT_NO_LINEEDIT
-#include "private/qwidget_p.h"
-#include "QtGui/qlineedit.h"
-#include "QtGui/qtextlayout.h"
-#include "QtGui/qstyleoption.h"
-#include "QtCore/qpointer.h"
-#include "QtGui/qlineedit.h"
-#include "QtGui/qclipboard.h"
-#include "QtCore/qpoint.h"
-#include "QtGui/qcompleter.h"
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class Q_GUI_EXPORT QLineControl : public QObject
-{
- Q_OBJECT
-
-public:
- QLineControl(const QString &txt = QString())
- : m_cursor(0), m_preeditCursor(0), m_cursorWidth(0), m_layoutDirection(Qt::LayoutDirectionAuto),
- m_hideCursor(false), m_separator(0), m_readOnly(0),
- m_dragEnabled(0), m_echoMode(0), m_textDirty(0), m_selDirty(0),
- m_validInput(1), m_blinkStatus(0), m_blinkPeriod(0), m_blinkTimer(0), m_deleteAllTimer(0),
- m_ascent(0), m_maxLength(32767), m_lastCursorPos(-1),
- m_tripleClickTimer(0), m_maskData(0), m_modifiedState(0), m_undoState(0),
- m_selstart(0), m_selend(0), m_passwordEchoEditing(false)
- {
- init(txt);
- }
-
- ~QLineControl()
- {
- delete [] m_maskData;
- }
-
- int nextMaskBlank(int pos)
- {
- int c = findInMask(pos, true, false);
- m_separator |= (c != pos);
- return (c != -1 ? c : m_maxLength);
- }
-
- int prevMaskBlank(int pos)
- {
- int c = findInMask(pos, false, false);
- m_separator |= (c != pos);
- return (c != -1 ? c : 0);
- }
-
- bool isUndoAvailable() const { return !m_readOnly && m_undoState; }
- bool isRedoAvailable() const { return !m_readOnly && m_undoState < (int)m_history.size(); }
- void clearUndo() { m_history.clear(); m_modifiedState = m_undoState = 0; }
-
- bool isModified() const { return m_modifiedState != m_undoState; }
- void setModified(bool modified) { m_modifiedState = modified ? -1 : m_undoState; }
-
- bool allSelected() const { return !m_text.isEmpty() && m_selstart == 0 && m_selend == (int)m_text.length(); }
- bool hasSelectedText() const { return !m_text.isEmpty() && m_selend > m_selstart; }
-
- int width() const { return qRound(m_textLayout.lineAt(0).width()) + 1; }
- int height() const { return qRound(m_textLayout.lineAt(0).height()) + 1; }
- int ascent() const { return m_ascent; }
- qreal naturalTextWidth() const { return m_textLayout.lineAt(0).naturalTextWidth(); }
-
- void setSelection(int start, int length);
-
- inline QString selectedText() const { return hasSelectedText() ? m_text.mid(m_selstart, m_selend - m_selstart) : QString(); }
- QString textBeforeSelection() const { return hasSelectedText() ? m_text.left(m_selstart) : QString(); }
- QString textAfterSelection() const { return hasSelectedText() ? m_text.mid(m_selend) : QString(); }
-
- int selectionStart() const { return hasSelectedText() ? m_selstart : -1; }
- int selectionEnd() const { return hasSelectedText() ? m_selend : -1; }
- bool inSelection(int x) const
- {
- if (m_selstart >= m_selend)
- return false;
- int pos = xToPos(x, QTextLine::CursorOnCharacter);
- return pos >= m_selstart && pos < m_selend;
- }
-
- void removeSelection()
- {
- int priorState = m_undoState;
- removeSelectedText();
- finishChange(priorState);
- }
-
- int start() const { return 0; }
- int end() const { return m_text.length(); }
-
-#ifndef QT_NO_CLIPBOARD
- void copy(QClipboard::Mode mode = QClipboard::Clipboard) const;
- void paste(QClipboard::Mode mode = QClipboard::Clipboard);
-#endif
-
- int cursor() const{ return m_cursor; }
- int preeditCursor() const { return m_preeditCursor; }
-
- int cursorWidth() const { return m_cursorWidth; }
- void setCursorWidth(int value) { m_cursorWidth = value; }
-
- QTextCursor::MoveStyle cursorMoveStyle() const { return m_textLayout.cursorMoveStyle(); }
- void setCursorMoveStyle(QTextCursor::MoveStyle style) { m_textLayout.setCursorMoveStyle(style); }
-
- void moveCursor(int pos, bool mark = false);
- void cursorForward(bool mark, int steps)
- {
- int c = m_cursor;
- if (steps > 0) {
- while (steps--)
- c = cursorMoveStyle() == QTextCursor::Visual ? m_textLayout.rightCursorPosition(c)
- : m_textLayout.nextCursorPosition(c);
- } else if (steps < 0) {
- while (steps++)
- c = cursorMoveStyle() == QTextCursor::Visual ? m_textLayout.leftCursorPosition(c)
- : m_textLayout.previousCursorPosition(c);
- }
- moveCursor(c, mark);
- }
-
- void cursorWordForward(bool mark) { moveCursor(m_textLayout.nextCursorPosition(m_cursor, QTextLayout::SkipWords), mark); }
- void cursorWordBackward(bool mark) { moveCursor(m_textLayout.previousCursorPosition(m_cursor, QTextLayout::SkipWords), mark); }
-
- void home(bool mark) { moveCursor(0, mark); }
- void end(bool mark) { moveCursor(text().length(), mark); }
-
- int xToPos(int x, QTextLine::CursorPosition = QTextLine::CursorBetweenCharacters) const;
- QRect cursorRect() const;
-
- qreal cursorToX(int cursor) const { return m_textLayout.lineAt(0).cursorToX(cursor); }
- qreal cursorToX() const
- {
- int cursor = m_cursor;
- if (m_preeditCursor != -1)
- cursor += m_preeditCursor;
- return cursorToX(cursor);
- }
-
- bool isReadOnly() const { return m_readOnly; }
- void setReadOnly(bool enable) { m_readOnly = enable; }
-
- QString text() const
- {
- QString res = m_maskData ? stripString(m_text) : m_text;
- return (res.isNull() ? QString::fromLatin1("") : res);
- }
- void setText(const QString &txt) { internalSetText(txt, -1, false); }
- QString displayText() const { return m_textLayout.text(); }
-
- void backspace();
- void del();
- void deselect() { internalDeselect(); finishChange(); }
- void selectAll() { m_selstart = m_selend = m_cursor = 0; moveCursor(m_text.length(), true); }
-
- void insert(const QString &);
- void clear();
- void undo() { internalUndo(); finishChange(-1, true); }
- void redo() { internalRedo(); finishChange(); }
- void selectWordAtPos(int);
-
- uint echoMode() const { return m_echoMode; }
- void setEchoMode(uint mode)
- {
- m_echoMode = mode;
- m_passwordEchoEditing = false;
- updateDisplayText();
- }
-
- int maxLength() const { return m_maxLength; }
- void setMaxLength(int maxLength)
- {
- if (m_maskData)
- return;
- m_maxLength = maxLength;
- setText(m_text);
- }
-
-#ifndef QT_NO_VALIDATOR
- const QValidator *validator() const { return m_validator; }
- void setValidator(const QValidator *v) { m_validator = const_cast<QValidator*>(v); }
-#endif
-
-#ifndef QT_NO_COMPLETER
- QCompleter *completer() const { return m_completer; }
- /* Note that you must set the widget for the completer separately */
- void setCompleter(const QCompleter *c) { m_completer = const_cast<QCompleter*>(c); }
- void complete(int key);
-#endif
-
- int cursorPosition() const { return m_cursor; }
- void setCursorPosition(int pos) { if (pos <= m_text.length()) moveCursor(qMax(0, pos)); }
-
- bool hasAcceptableInput() const { return hasAcceptableInput(m_text); }
- bool fixup();
-
- QString inputMask() const { return m_maskData ? m_inputMask + QLatin1Char(';') + m_blank : QString(); }
- void setInputMask(const QString &mask)
- {
- parseInputMask(mask);
- if (m_maskData)
- moveCursor(nextMaskBlank(0));
- }
-
- // input methods
-#ifndef QT_NO_IM
- bool composeMode() const { return !m_textLayout.preeditAreaText().isEmpty(); }
- void setPreeditArea(int cursor, const QString &text) { m_textLayout.setPreeditArea(cursor, text); }
-#endif
-
- QString preeditAreaText() const { return m_textLayout.preeditAreaText(); }
-
- void updatePasswordEchoEditing(bool editing);
- bool passwordEchoEditing() const { return m_passwordEchoEditing; }
-
- QChar passwordCharacter() const { return m_passwordCharacter; }
- void setPasswordCharacter(const QChar &character) { m_passwordCharacter = character; updateDisplayText(); }
-
- Qt::LayoutDirection layoutDirection() const {
- if (m_layoutDirection == Qt::LayoutDirectionAuto) {
- if (m_text.isEmpty())
- return QApplication::keyboardInputDirection();
- return m_text.isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight;
- }
- return m_layoutDirection;
- }
- void setLayoutDirection(Qt::LayoutDirection direction)
- {
- if (direction != m_layoutDirection) {
- m_layoutDirection = direction;
- updateDisplayText();
- }
- }
-
- void setFont(const QFont &font) { m_textLayout.setFont(font); updateDisplayText(); }
-
- void processInputMethodEvent(QInputMethodEvent *event);
- void processMouseEvent(QMouseEvent* ev);
- void processKeyEvent(QKeyEvent* ev);
-
- int cursorBlinkPeriod() const { return m_blinkPeriod; }
- void setCursorBlinkPeriod(int msec);
- void resetCursorBlinkTimer();
-
- QString cancelText() const { return m_cancelText; }
- void setCancelText(const QString &text) { m_cancelText = text; }
-
- const QPalette &palette() const { return m_palette; }
- void setPalette(const QPalette &p) { m_palette = p; }
-
- enum DrawFlags {
- DrawText = 0x01,
- DrawSelections = 0x02,
- DrawCursor = 0x04,
- DrawAll = DrawText | DrawSelections | DrawCursor
- };
- void draw(QPainter *, const QPoint &, const QRect &, int flags = DrawAll);
-
- bool processEvent(QEvent *ev);
-
-private:
- void init(const QString &txt);
- void removeSelectedText();
- void internalSetText(const QString &txt, int pos = -1, bool edited = true);
- void updateDisplayText(bool forceUpdate = false);
-
- void internalInsert(const QString &s);
- void internalDelete(bool wasBackspace = false);
- void internalRemove(int pos);
-
- inline void internalDeselect()
- {
- m_selDirty |= (m_selend > m_selstart);
- m_selstart = m_selend = 0;
- }
-
- void internalUndo(int until = -1);
- void internalRedo();
-
- QString m_text;
- QPalette m_palette;
- int m_cursor;
- int m_preeditCursor;
- int m_cursorWidth;
- Qt::LayoutDirection m_layoutDirection;
- uint m_hideCursor : 1; // used to hide the m_cursor inside preedit areas
- uint m_separator : 1;
- uint m_readOnly : 1;
- uint m_dragEnabled : 1;
- uint m_echoMode : 2;
- uint m_textDirty : 1;
- uint m_selDirty : 1;
- uint m_validInput : 1;
- uint m_blinkStatus : 1;
- int m_blinkPeriod; // 0 for non-blinking cursor
- int m_blinkTimer;
- int m_deleteAllTimer;
- int m_ascent;
- int m_maxLength;
- int m_lastCursorPos;
- QList<int> m_transactions;
- QPoint m_tripleClick;
- int m_tripleClickTimer;
- QString m_cancelText;
-
- void emitCursorPositionChanged();
-
- bool finishChange(int validateFromState = -1, bool update = false, bool edited = true);
-
-#ifndef QT_NO_VALIDATOR
- QPointer<QValidator> m_validator;
-#endif
- QPointer<QCompleter> m_completer;
-#ifndef QT_NO_COMPLETER
- bool advanceToEnabledItem(int dir);
-#endif
-
- struct MaskInputData {
- enum Casemode { NoCaseMode, Upper, Lower };
- QChar maskChar; // either the separator char or the inputmask
- bool separator;
- Casemode caseMode;
- };
- QString m_inputMask;
- QChar m_blank;
- MaskInputData *m_maskData;
-
- // undo/redo handling
- enum CommandType { Separator, Insert, Remove, Delete, RemoveSelection, DeleteSelection, SetSelection };
- struct Command {
- inline Command() {}
- inline Command(CommandType t, int p, QChar c, int ss, int se) : type(t),uc(c),pos(p),selStart(ss),selEnd(se) {}
- uint type : 4;
- QChar uc;
- int pos, selStart, selEnd;
- };
- int m_modifiedState;
- int m_undoState;
- QVector<Command> m_history;
- void addCommand(const Command& cmd);
-
- inline void separate() { m_separator = true; }
-
- // selection
- int m_selstart;
- int m_selend;
-
- // masking
- void parseInputMask(const QString &maskFields);
- bool isValidInput(QChar key, QChar mask) const;
- bool hasAcceptableInput(const QString &text) const;
- QString maskString(uint pos, const QString &str, bool clear = false) const;
- QString clearString(uint pos, uint len) const;
- QString stripString(const QString &str) const;
- int findInMask(int pos, bool forward, bool findSeparator, QChar searchChar = QChar()) const;
-
- // complex text layout
- QTextLayout m_textLayout;
-
- bool m_passwordEchoEditing;
- QChar m_passwordCharacter;
-
-Q_SIGNALS:
- void cursorPositionChanged(int, int);
- void selectionChanged();
-
- void displayTextChanged(const QString &);
- void textChanged(const QString &);
- void textEdited(const QString &);
-
- void resetInputContext();
- void updateMicroFocus();
-
- void accepted();
- void editingFinished();
- void updateNeeded(const QRect &);
-
-#ifdef QT_KEYPAD_NAVIGATION
- void editFocusChange(bool);
-#endif
-protected:
- virtual void timerEvent(QTimerEvent *event);
-
-private Q_SLOTS:
- void _q_clipboardChanged();
- void _q_deleteSelected();
-
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_LINEEDIT
-
-#endif // QLINECONTROL_P_H
diff --git a/src/gui/widgets/qlineedit.h b/src/gui/widgets/qlineedit.h
deleted file mode 100644
index 73a736c690..0000000000
--- a/src/gui/widgets/qlineedit.h
+++ /dev/null
@@ -1,299 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QLINEEDIT_H
-#define QLINEEDIT_H
-
-#include <QtGui/qframe.h>
-#include <QtGui/qtextcursor.h>
-#include <QtCore/qstring.h>
-#include <QtCore/qmargins.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_LINEEDIT
-
-class QValidator;
-class QMenu;
-class QLineEditPrivate;
-class QCompleter;
-class QStyleOptionFrame;
-class QAbstractSpinBox;
-class QDateTimeEdit;
-
-class Q_GUI_EXPORT QLineEdit : public QWidget
-{
- Q_OBJECT
-
- Q_ENUMS(EchoMode)
- Q_PROPERTY(QString inputMask READ inputMask WRITE setInputMask)
- Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged USER true)
- Q_PROPERTY(int maxLength READ maxLength WRITE setMaxLength)
- Q_PROPERTY(bool frame READ hasFrame WRITE setFrame)
- Q_PROPERTY(EchoMode echoMode READ echoMode WRITE setEchoMode)
- Q_PROPERTY(QString displayText READ displayText)
- Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition)
- Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
- Q_PROPERTY(bool modified READ isModified WRITE setModified DESIGNABLE false)
- Q_PROPERTY(bool hasSelectedText READ hasSelectedText)
- Q_PROPERTY(QString selectedText READ selectedText)
- Q_PROPERTY(bool dragEnabled READ dragEnabled WRITE setDragEnabled)
- Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
- Q_PROPERTY(bool undoAvailable READ isUndoAvailable)
- Q_PROPERTY(bool redoAvailable READ isRedoAvailable)
- Q_PROPERTY(bool acceptableInput READ hasAcceptableInput)
- Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText)
-
-public:
- explicit QLineEdit(QWidget* parent=0);
- explicit QLineEdit(const QString &, QWidget* parent=0);
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QLineEdit(QWidget* parent, const char* name);
- QT3_SUPPORT_CONSTRUCTOR QLineEdit(const QString &, QWidget* parent, const char* name);
- QT3_SUPPORT_CONSTRUCTOR QLineEdit(const QString &, const QString &, QWidget* parent=0, const char* name=0);
-#endif
- ~QLineEdit();
-
- QString text() const;
-
- QString displayText() const;
-
- QString placeholderText() const;
- void setPlaceholderText(const QString &);
-
- int maxLength() const;
- void setMaxLength(int);
-
- void setFrame(bool);
- bool hasFrame() const;
-
- enum EchoMode { Normal, NoEcho, Password, PasswordEchoOnEdit };
- EchoMode echoMode() const;
- void setEchoMode(EchoMode);
-
- bool isReadOnly() const;
- void setReadOnly(bool);
-
-#ifndef QT_NO_VALIDATOR
- void setValidator(const QValidator *);
- const QValidator * validator() const;
-#endif
-
-#ifndef QT_NO_COMPLETER
- void setCompleter(QCompleter *completer);
- QCompleter *completer() const;
-#endif
-
- QSize sizeHint() const;
- QSize minimumSizeHint() const;
-
- int cursorPosition() const;
- void setCursorPosition(int);
- int cursorPositionAt(const QPoint &pos);
-
- void setAlignment(Qt::Alignment flag);
- Qt::Alignment alignment() const;
-
- void cursorForward(bool mark, int steps = 1);
- void cursorBackward(bool mark, int steps = 1);
- void cursorWordForward(bool mark);
- void cursorWordBackward(bool mark);
- void backspace();
- void del();
- void home(bool mark);
- void end(bool mark);
-
- bool isModified() const;
- void setModified(bool);
-
- void setSelection(int, int);
- bool hasSelectedText() const;
- QString selectedText() const;
- int selectionStart() const;
-
- bool isUndoAvailable() const;
- bool isRedoAvailable() const;
-
- void setDragEnabled(bool b);
- bool dragEnabled() const;
-
- void setCursorMoveStyle(QTextCursor::MoveStyle style);
- QTextCursor::MoveStyle cursorMoveStyle() const;
-
- QString inputMask() const;
- void setInputMask(const QString &inputMask);
- bool hasAcceptableInput() const;
-
- void setTextMargins(int left, int top, int right, int bottom);
- void setTextMargins(const QMargins &margins);
- void getTextMargins(int *left, int *top, int *right, int *bottom) const;
- QMargins textMargins() const;
-
-public Q_SLOTS:
- void setText(const QString &);
- void clear();
- void selectAll();
- void undo();
- void redo();
-#ifndef QT_NO_CLIPBOARD
- void cut();
- void copy() const;
- void paste();
-#endif
-
-public:
- void deselect();
- void insert(const QString &);
-#ifndef QT_NO_CONTEXTMENU
- QMenu *createStandardContextMenu();
-#endif
-
-Q_SIGNALS:
- void textChanged(const QString &);
- void textEdited(const QString &);
- void cursorPositionChanged(int, int);
- void returnPressed();
- void editingFinished();
- void selectionChanged();
-
-protected:
- void mousePressEvent(QMouseEvent *);
- void mouseMoveEvent(QMouseEvent *);
- void mouseReleaseEvent(QMouseEvent *);
- void mouseDoubleClickEvent(QMouseEvent *);
- void keyPressEvent(QKeyEvent *);
- void focusInEvent(QFocusEvent *);
- void focusOutEvent(QFocusEvent *);
- void paintEvent(QPaintEvent *);
-#ifndef QT_NO_DRAGANDDROP
- void dragEnterEvent(QDragEnterEvent *);
- void dragMoveEvent(QDragMoveEvent *e);
- void dragLeaveEvent(QDragLeaveEvent *e);
- void dropEvent(QDropEvent *);
-#endif
- void changeEvent(QEvent *);
-#ifndef QT_NO_CONTEXTMENU
- void contextMenuEvent(QContextMenuEvent *);
-#endif
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT void repaintArea(int, int) { update(); }
-#endif
-
- void inputMethodEvent(QInputMethodEvent *);
- void initStyleOption(QStyleOptionFrame *option) const;
-public:
- QVariant inputMethodQuery(Qt::InputMethodQuery) const;
- bool event(QEvent *);
-protected:
- QRect cursorRect() const;
-
-public:
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT void clearModified() { setModified(false); }
- inline QT3_SUPPORT void cursorLeft(bool mark, int steps = 1) { cursorForward(mark, -steps); }
- inline QT3_SUPPORT void cursorRight(bool mark, int steps = 1) { cursorForward(mark, steps); }
- QT3_SUPPORT bool validateAndSet(const QString &, int, int, int);
- inline QT3_SUPPORT bool frame() const { return hasFrame(); }
-#ifndef QT_NO_VALIDATOR
- inline QT3_SUPPORT void clearValidator() { setValidator(0); }
-#endif
- inline QT3_SUPPORT bool hasMarkedText() const { return hasSelectedText(); }
- inline QT3_SUPPORT QString markedText() const { return selectedText(); }
- QT3_SUPPORT bool edited() const;
- QT3_SUPPORT void setEdited(bool);
- QT3_SUPPORT int characterAt(int, QChar*) const;
- QT3_SUPPORT bool getSelection(int *, int *);
-
- QT3_SUPPORT void setFrameRect(QRect) {}
- QT3_SUPPORT QRect frameRect() const { return QRect(); }
- enum DummyFrame { Box, Sunken, Plain, Raised, MShadow, NoFrame, Panel, StyledPanel,
- HLine, VLine, GroupBoxPanel, WinPanel, ToolBarPanel, MenuBarPanel,
- PopupPanel, LineEditPanel, TabWidgetPanel, MShape };
- QT3_SUPPORT void setFrameShadow(DummyFrame) {}
- QT3_SUPPORT DummyFrame frameShadow() const { return Plain; }
- QT3_SUPPORT void setFrameShape(DummyFrame) {}
- QT3_SUPPORT DummyFrame frameShape() const { return NoFrame; }
- QT3_SUPPORT void setFrameStyle(int) {}
- QT3_SUPPORT int frameStyle() const { return 0; }
- QT3_SUPPORT int frameWidth() const { return 0; }
- QT3_SUPPORT void setLineWidth(int) {}
- QT3_SUPPORT int lineWidth() const { return 0; }
- QT3_SUPPORT void setMargin(int margin) { setContentsMargins(margin, margin, margin, margin); }
- QT3_SUPPORT int margin() const
- { int margin; int dummy; getContentsMargins(&margin, &dummy, &dummy, &dummy); return margin; }
- QT3_SUPPORT void setMidLineWidth(int) {}
- QT3_SUPPORT int midLineWidth() const { return 0; }
-
-Q_SIGNALS:
- QT_MOC_COMPAT void lostFocus();
-#endif
-
-private:
- friend class QAbstractSpinBox;
-#ifdef QT_KEYPAD_NAVIGATION
- friend class QDateTimeEdit;
-#endif
- Q_DISABLE_COPY(QLineEdit)
- Q_DECLARE_PRIVATE(QLineEdit)
- Q_PRIVATE_SLOT(d_func(), void _q_handleWindowActivate())
- Q_PRIVATE_SLOT(d_func(), void _q_textEdited(const QString &))
- Q_PRIVATE_SLOT(d_func(), void _q_cursorPositionChanged(int, int))
-#ifndef QT_NO_COMPLETER
- Q_PRIVATE_SLOT(d_func(), void _q_completionHighlighted(QString))
-#endif
-#ifdef QT_KEYPAD_NAVIGATION
- Q_PRIVATE_SLOT(d_func(), void _q_editFocusChange(bool))
-#endif
- Q_PRIVATE_SLOT(d_func(), void _q_selectionChanged())
- Q_PRIVATE_SLOT(d_func(), void _q_updateNeeded(const QRect &))
-};
-
-#endif // QT_NO_LINEEDIT
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QLINEEDIT_H
diff --git a/src/gui/widgets/qlineedit_p.cpp b/src/gui/widgets/qlineedit_p.cpp
deleted file mode 100644
index 23ac61384f..0000000000
--- a/src/gui/widgets/qlineedit_p.cpp
+++ /dev/null
@@ -1,291 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qlineedit.h"
-#include "qlineedit_p.h"
-
-#ifndef QT_NO_LINEEDIT
-
-#include "qabstractitemview.h"
-#include "qclipboard.h"
-#ifndef QT_NO_ACCESSIBILITY
-#include "qaccessible.h"
-#endif
-#ifndef QT_NO_IM
-#include "qinputcontext.h"
-#include "qlist.h"
-#endif
-
-QT_BEGIN_NAMESPACE
-
-const int QLineEditPrivate::verticalMargin(1);
-const int QLineEditPrivate::horizontalMargin(2);
-
-QRect QLineEditPrivate::adjustedControlRect(const QRect &rect) const
-{
- QRect cr = adjustedContentsRect();
- int cix = cr.x() - hscroll + horizontalMargin;
- return rect.translated(QPoint(cix, vscroll));
-}
-
-int QLineEditPrivate::xToPos(int x, QTextLine::CursorPosition betweenOrOn) const
-{
- QRect cr = adjustedContentsRect();
- x-= cr.x() - hscroll + horizontalMargin;
- return control->xToPos(x, betweenOrOn);
-}
-
-QRect QLineEditPrivate::cursorRect() const
-{
- return adjustedControlRect(control->cursorRect());
-}
-
-#ifndef QT_NO_COMPLETER
-
-void QLineEditPrivate::_q_completionHighlighted(QString newText)
-{
- Q_Q(QLineEdit);
- if (control->completer()->completionMode() != QCompleter::InlineCompletion) {
- q->setText(newText);
- } else {
- int c = control->cursor();
- QString text = control->text();
- q->setText(text.left(c) + newText.mid(c));
- control->moveCursor(control->end(), false);
- control->moveCursor(c, true);
- }
-}
-
-#endif // QT_NO_COMPLETER
-
-void QLineEditPrivate::_q_handleWindowActivate()
-{
- Q_Q(QLineEdit);
- if (!q->hasFocus() && control->hasSelectedText())
- control->deselect();
-}
-
-void QLineEditPrivate::_q_textEdited(const QString &text)
-{
- Q_Q(QLineEdit);
- emit q->textEdited(text);
-#ifndef QT_NO_COMPLETER
- if (control->completer()
- && control->completer()->completionMode() != QCompleter::InlineCompletion)
- control->complete(-1); // update the popup on cut/paste/del
-#endif
-}
-
-void QLineEditPrivate::_q_cursorPositionChanged(int from, int to)
-{
- Q_Q(QLineEdit);
- q->update();
- emit q->cursorPositionChanged(from, to);
-}
-
-#ifdef QT_KEYPAD_NAVIGATION
-void QLineEditPrivate::_q_editFocusChange(bool e)
-{
- Q_Q(QLineEdit);
- q->setEditFocus(e);
-}
-#endif
-
-void QLineEditPrivate::_q_selectionChanged()
-{
- Q_Q(QLineEdit);
- if (!control->text().isEmpty() && control->preeditAreaText().isEmpty()) {
- QStyleOptionFrameV2 opt;
- q->initStyleOption(&opt);
- bool showCursor = control->hasSelectedText() ?
- q->style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, q):
- q->hasFocus();
- setCursorVisible(showCursor);
- }
-
- emit q->selectionChanged();
-}
-
-void QLineEditPrivate::_q_updateNeeded(const QRect &rect)
-{
- q_func()->update(adjustedControlRect(rect));
-}
-
-void QLineEditPrivate::init(const QString& txt)
-{
- Q_Q(QLineEdit);
- control = new QLineControl(txt);
- control->setFont(q->font());
- QObject::connect(control, SIGNAL(textChanged(QString)),
- q, SIGNAL(textChanged(QString)));
- QObject::connect(control, SIGNAL(textEdited(QString)),
- q, SLOT(_q_textEdited(QString)));
- QObject::connect(control, SIGNAL(cursorPositionChanged(int,int)),
- q, SLOT(_q_cursorPositionChanged(int,int)));
- QObject::connect(control, SIGNAL(selectionChanged()),
- q, SLOT(_q_selectionChanged()));
- QObject::connect(control, SIGNAL(accepted()),
- q, SIGNAL(returnPressed()));
- QObject::connect(control, SIGNAL(editingFinished()),
- q, SIGNAL(editingFinished()));
-#ifdef QT_KEYPAD_NAVIGATION
- QObject::connect(control, SIGNAL(editFocusChange(bool)),
- q, SLOT(_q_editFocusChange(bool)));
-#endif
- QObject::connect(control, SIGNAL(cursorPositionChanged(int,int)),
- q, SLOT(updateMicroFocus()));
-
- QObject::connect(control, SIGNAL(textChanged(const QString &)),
- q, SLOT(updateMicroFocus()));
-
- // for now, going completely overboard with updates.
- QObject::connect(control, SIGNAL(selectionChanged()),
- q, SLOT(update()));
-
- QObject::connect(control, SIGNAL(displayTextChanged(QString)),
- q, SLOT(update()));
-
- QObject::connect(control, SIGNAL(updateNeeded(QRect)),
- q, SLOT(_q_updateNeeded(QRect)));
-
- QStyleOptionFrameV2 opt;
- q->initStyleOption(&opt);
- control->setPasswordCharacter(q->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, q));
-#ifndef QT_NO_CURSOR
- q->setCursor(Qt::IBeamCursor);
-#endif
- q->setFocusPolicy(Qt::StrongFocus);
- q->setAttribute(Qt::WA_InputMethodEnabled);
- // Specifies that this widget can use more, but is able to survive on
- // less, horizontal space; and is fixed vertically.
- q->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed, QSizePolicy::LineEdit));
- q->setBackgroundRole(QPalette::Base);
- q->setAttribute(Qt::WA_KeyCompression);
- q->setMouseTracking(true);
- q->setAcceptDrops(true);
-
- q->setAttribute(Qt::WA_MacShowFocusRect);
-}
-
-QRect QLineEditPrivate::adjustedContentsRect() const
-{
- Q_Q(const QLineEdit);
- QStyleOptionFrameV2 opt;
- q->initStyleOption(&opt);
- QRect r = q->style()->subElementRect(QStyle::SE_LineEditContents, &opt, q);
- r.setX(r.x() + leftTextMargin);
- r.setY(r.y() + topTextMargin);
- r.setRight(r.right() - rightTextMargin);
- r.setBottom(r.bottom() - bottomTextMargin);
- return r;
-}
-
-void QLineEditPrivate::setCursorVisible(bool visible)
-{
- Q_Q(QLineEdit);
- if ((bool)cursorVisible == visible)
- return;
- cursorVisible = visible;
- if (control->inputMask().isEmpty())
- q->update(cursorRect());
- else
- q->update();
-}
-
-void QLineEditPrivate::updatePasswordEchoEditing(bool editing)
-{
- Q_Q(QLineEdit);
- control->updatePasswordEchoEditing(editing);
- q->setAttribute(Qt::WA_InputMethodEnabled, shouldEnableInputMethod());
-}
-
-/*!
- This function is not intended as polymorphic usage. Just a shared code
- fragment that calls QInputContext::mouseHandler for this
- class.
-*/
-bool QLineEditPrivate::sendMouseEventToInputContext( QMouseEvent *e )
-{
-#if !defined QT_NO_IM
- Q_Q(QLineEdit);
- if ( control->composeMode() ) {
- int tmp_cursor = xToPos(e->pos().x());
- int mousePos = tmp_cursor - control->cursor();
- if ( mousePos < 0 || mousePos > control->preeditAreaText().length() ) {
- mousePos = -1;
- // don't send move events outside the preedit area
- if ( e->type() == QEvent::MouseMove )
- return true;
- }
-
- QInputContext *qic = q->inputContext();
- if ( qic )
- // may be causing reset() in some input methods
- qic->mouseHandler(mousePos, e);
- if (!control->preeditAreaText().isEmpty())
- return true;
- }
-#else
- Q_UNUSED(e);
-#endif
-
- return false;
-}
-
-#ifndef QT_NO_DRAGANDDROP
-void QLineEditPrivate::drag()
-{
- Q_Q(QLineEdit);
- dndTimer.stop();
- QMimeData *data = new QMimeData;
- data->setText(control->selectedText());
- QDrag *drag = new QDrag(q);
- drag->setMimeData(data);
- Qt::DropAction action = drag->start();
- if (action == Qt::MoveAction && !control->isReadOnly() && drag->target() != q)
- control->removeSelection();
-}
-
-#endif // QT_NO_DRAGANDDROP
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/gui/widgets/qlineedit_p.h b/src/gui/widgets/qlineedit_p.h
deleted file mode 100644
index 32f6077438..0000000000
--- a/src/gui/widgets/qlineedit_p.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QLINEEDIT_P_H
-#define QLINEEDIT_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "QtCore/qglobal.h"
-
-#ifndef QT_NO_LINEEDIT
-#include "private/qwidget_p.h"
-#include "QtGui/qlineedit.h"
-#include "QtGui/qtextlayout.h"
-#include "QtGui/qstyleoption.h"
-#include "QtCore/qbasictimer.h"
-#include "QtGui/qcompleter.h"
-#include "QtCore/qpointer.h"
-#include "QtGui/qlineedit.h"
-
-#include "private/qlinecontrol_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QLineEditPrivate : public QWidgetPrivate
-{
- Q_DECLARE_PUBLIC(QLineEdit)
-public:
-
- QLineEditPrivate()
- : control(0), frame(1), contextMenuEnabled(1), cursorVisible(0),
- dragEnabled(0), clickCausedFocus(0), hscroll(0), vscroll(0),
- alignment(Qt::AlignLeading | Qt::AlignVCenter),
- leftTextMargin(0), topTextMargin(0), rightTextMargin(0), bottomTextMargin(0)
- {
- }
-
- ~QLineEditPrivate()
- {
- delete control;
- }
-
- QLineControl *control;
-
-#ifndef QT_NO_CONTEXTMENU
- QPointer<QAction> selectAllAction;
-#endif
- void init(const QString&);
-
- QRect adjustedControlRect(const QRect &) const;
-
- int xToPos(int x, QTextLine::CursorPosition = QTextLine::CursorBetweenCharacters) const;
- QRect cursorRect() const;
- void setCursorVisible(bool visible);
-
- void updatePasswordEchoEditing(bool);
-
- inline bool shouldEnableInputMethod() const
- {
- return !control->isReadOnly();
- }
-
- QPoint tripleClick;
- QBasicTimer tripleClickTimer;
- uint frame : 1;
- uint contextMenuEnabled : 1;
- uint cursorVisible : 1;
- uint dragEnabled : 1;
- uint clickCausedFocus : 1;
- int hscroll;
- int vscroll;
- uint alignment;
- static const int verticalMargin;
- static const int horizontalMargin;
-
- bool sendMouseEventToInputContext(QMouseEvent *e);
-
- QRect adjustedContentsRect() const;
-
- void _q_handleWindowActivate();
- void _q_textEdited(const QString &);
- void _q_cursorPositionChanged(int, int);
-#ifdef QT_KEYPAD_NAVIGATION
- void _q_editFocusChange(bool);
-#endif
- void _q_selectionChanged();
- void _q_updateNeeded(const QRect &);
-#ifndef QT_NO_COMPLETER
- void _q_completionHighlighted(QString);
-#endif
-#ifndef QT_NO_DRAGANDDROP
- QPoint dndPos;
- QBasicTimer dndTimer;
- void drag();
-#endif
-
- int leftTextMargin;
- int topTextMargin;
- int rightTextMargin;
- int bottomTextMargin;
-
- QString placeholderText;
-};
-
-#endif // QT_NO_LINEEDIT
-
-QT_END_NAMESPACE
-
-#endif // QLINEEDIT_P_H
diff --git a/src/gui/widgets/qmaccocoaviewcontainer_mac.h b/src/gui/widgets/qmaccocoaviewcontainer_mac.h
deleted file mode 100644
index 9b5befb40f..0000000000
--- a/src/gui/widgets/qmaccocoaviewcontainer_mac.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QCOCOAVIEWCONTAINER_H
-#define QCOCOAVIEWCONTAINER_H
-
-#include <QtGui/QWidget>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QMacCocoaViewContainerPrivate;
-
-class Q_GUI_EXPORT QMacCocoaViewContainer : public QWidget
-{
- Q_OBJECT
-public:
- QMacCocoaViewContainer(void *cocoaViewToWrap, QWidget *parent = 0);
- virtual ~QMacCocoaViewContainer();
-
- void setCocoaView(void *cocoaViewToWrap);
- void *cocoaView() const;
-
-private:
- Q_DECLARE_PRIVATE(QMacCocoaViewContainer)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QCOCOAVIEWCONTAINER_H
diff --git a/src/gui/widgets/qmacnativewidget_mac.h b/src/gui/widgets/qmacnativewidget_mac.h
deleted file mode 100644
index 98c618d1ad..0000000000
--- a/src/gui/widgets/qmacnativewidget_mac.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMACNATIVEWIDGET_H
-#define QMACNATIVEWIDGET_H
-
-#include <QtGui/QWidget>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QMacNativeWidgetPrivate;
-class Q_GUI_EXPORT QMacNativeWidget : public QWidget
-{
- Q_OBJECT
-public:
- QMacNativeWidget(void *parentRef = 0);
- ~QMacNativeWidget();
-
- QSize sizeHint() const;
-
-protected:
- bool event(QEvent *ev);
-
-private:
- Q_DECLARE_PRIVATE(QMacNativeWidget)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMACNATIVEWIDGET_H
diff --git a/src/gui/widgets/qmainwindow.h b/src/gui/widgets/qmainwindow.h
deleted file mode 100644
index 051ee57cf2..0000000000
--- a/src/gui/widgets/qmainwindow.h
+++ /dev/null
@@ -1,219 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDYNAMICMAINWINDOW_H
-#define QDYNAMICMAINWINDOW_H
-
-#include <QtGui/qwidget.h>
-#include <QtGui/qtabwidget.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_MAINWINDOW
-
-class QDockWidget;
-class QMainWindowPrivate;
-class QMenuBar;
-class QStatusBar;
-class QToolBar;
-class QMenu;
-
-class Q_GUI_EXPORT QMainWindow : public QWidget
-{
- Q_OBJECT
-
- Q_ENUMS(DockOption)
- Q_FLAGS(DockOptions)
- Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
- Q_PROPERTY(Qt::ToolButtonStyle toolButtonStyle READ toolButtonStyle WRITE setToolButtonStyle)
-#ifndef QT_NO_DOCKWIDGET
- Q_PROPERTY(bool animated READ isAnimated WRITE setAnimated)
-#ifndef QT_NO_TABBAR
- Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode)
-#endif // QT_NO_TABBAR
-#ifndef QT_NO_TABWIDGET
- Q_PROPERTY(QTabWidget::TabShape tabShape READ tabShape WRITE setTabShape)
-#endif // QT_NO_TABWIDGET
- Q_PROPERTY(bool dockNestingEnabled READ isDockNestingEnabled WRITE setDockNestingEnabled)
-#endif // QT_NO_DOCKWIDGET
- Q_PROPERTY(DockOptions dockOptions READ dockOptions WRITE setDockOptions)
-#ifndef QT_NO_TOOLBAR
- Q_PROPERTY(bool unifiedTitleAndToolBarOnMac READ unifiedTitleAndToolBarOnMac WRITE setUnifiedTitleAndToolBarOnMac)
-#endif
-
-public:
- enum DockOption {
- AnimatedDocks = 0x01,
- AllowNestedDocks = 0x02,
- AllowTabbedDocks = 0x04,
- ForceTabbedDocks = 0x08, // implies AllowTabbedDocks, !AllowNestedDocks
- VerticalTabs = 0x10 // implies AllowTabbedDocks
- };
- Q_DECLARE_FLAGS(DockOptions, DockOption)
-
- explicit QMainWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0);
- ~QMainWindow();
-
- QSize iconSize() const;
- void setIconSize(const QSize &iconSize);
-
- Qt::ToolButtonStyle toolButtonStyle() const;
- void setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle);
-
-#ifndef QT_NO_DOCKWIDGET
- bool isAnimated() const;
- bool isDockNestingEnabled() const;
-#endif
-
-#ifndef QT_NO_TABBAR
- bool documentMode() const;
- void setDocumentMode(bool enabled);
-#endif
-
-#ifndef QT_NO_TABWIDGET
- QTabWidget::TabShape tabShape() const;
- void setTabShape(QTabWidget::TabShape tabShape);
- QTabWidget::TabPosition tabPosition(Qt::DockWidgetArea area) const;
- void setTabPosition(Qt::DockWidgetAreas areas, QTabWidget::TabPosition tabPosition);
-#endif // QT_NO_TABWIDGET
-
- void setDockOptions(DockOptions options);
- DockOptions dockOptions() const;
-
- bool isSeparator(const QPoint &pos) const;
-
-#ifndef QT_NO_MENUBAR
- QMenuBar *menuBar() const;
- void setMenuBar(QMenuBar *menubar);
-
- QWidget *menuWidget() const;
- void setMenuWidget(QWidget *menubar);
-#endif
-
-#ifndef QT_NO_STATUSBAR
- QStatusBar *statusBar() const;
- void setStatusBar(QStatusBar *statusbar);
-#endif
-
- QWidget *centralWidget() const;
- void setCentralWidget(QWidget *widget);
-
-#ifndef QT_NO_DOCKWIDGET
- void setCorner(Qt::Corner corner, Qt::DockWidgetArea area);
- Qt::DockWidgetArea corner(Qt::Corner corner) const;
-#endif
-
-#ifndef QT_NO_TOOLBAR
- void addToolBarBreak(Qt::ToolBarArea area = Qt::TopToolBarArea);
- void insertToolBarBreak(QToolBar *before);
-
- void addToolBar(Qt::ToolBarArea area, QToolBar *toolbar);
- void addToolBar(QToolBar *toolbar);
- QToolBar *addToolBar(const QString &title);
- void insertToolBar(QToolBar *before, QToolBar *toolbar);
- void removeToolBar(QToolBar *toolbar);
- void removeToolBarBreak(QToolBar *before);
-
- void setUnifiedTitleAndToolBarOnMac(bool set);
- bool unifiedTitleAndToolBarOnMac() const;
-
- Qt::ToolBarArea toolBarArea(QToolBar *toolbar) const;
- bool toolBarBreak(QToolBar *toolbar) const;
-#endif
-#ifndef QT_NO_DOCKWIDGET
- void addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget);
- void addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget,
- Qt::Orientation orientation);
- void splitDockWidget(QDockWidget *after, QDockWidget *dockwidget,
- Qt::Orientation orientation);
- void tabifyDockWidget(QDockWidget *first, QDockWidget *second);
- QList<QDockWidget*> tabifiedDockWidgets(QDockWidget *dockwidget) const;
- void removeDockWidget(QDockWidget *dockwidget);
- bool restoreDockWidget(QDockWidget *dockwidget);
-
- Qt::DockWidgetArea dockWidgetArea(QDockWidget *dockwidget) const;
-#endif // QT_NO_DOCKWIDGET
-
- QByteArray saveState(int version = 0) const;
- bool restoreState(const QByteArray &state, int version = 0);
-
-#ifndef QT_NO_MENU
- virtual QMenu *createPopupMenu();
-#endif
-
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QMainWindow(QWidget *parent, const char *name, Qt::WindowFlags flags = 0);
-#endif
-
-#ifndef QT_NO_DOCKWIDGET
-public Q_SLOTS:
- void setAnimated(bool enabled);
- void setDockNestingEnabled(bool enabled);
-#endif
-
-Q_SIGNALS:
- void iconSizeChanged(const QSize &iconSize);
- void toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle);
-
-protected:
-#ifndef QT_NO_CONTEXTMENU
- void contextMenuEvent(QContextMenuEvent *event);
-#endif
- bool event(QEvent *event);
-
-private:
- Q_DECLARE_PRIVATE(QMainWindow)
- Q_DISABLE_COPY(QMainWindow)
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QMainWindow::DockOptions)
-
-#endif // QT_NO_MAINWINDOW
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDYNAMICMAINWINDOW_H
diff --git a/src/gui/widgets/qmainwindowlayout_p.h b/src/gui/widgets/qmainwindowlayout_p.h
deleted file mode 100644
index 20aca61deb..0000000000
--- a/src/gui/widgets/qmainwindowlayout_p.h
+++ /dev/null
@@ -1,357 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDYNAMICMAINWINDOWLAYOUT_P_H
-#define QDYNAMICMAINWINDOWLAYOUT_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qmainwindow.h"
-
-#ifndef QT_NO_MAINWINDOW
-
-#include "QtGui/qlayout.h"
-#include "QtGui/qtabbar.h"
-#include "QtCore/qvector.h"
-#include "QtCore/qset.h"
-#include "QtCore/qbasictimer.h"
-#include "private/qlayoutengine_p.h"
-#include "private/qwidgetanimator_p.h"
-
-#include "qdockarealayout_p.h"
-#include "qtoolbararealayout_p.h"
-
-//#define Q_DEBUG_MAINWINDOW_LAYOUT
-
-#if defined(Q_DEBUG_MAINWINDOW_LAYOUT) && !defined(QT_NO_DOCKWIDGET)
-QT_BEGIN_NAMESPACE
-class QTextStream;
-Q_GUI_EXPORT void qt_dumpLayout(QTextStream &qout, QMainWindow *window);
-QT_END_NAMESPACE
-#endif // Q_DEBUG_MAINWINDOW_LAYOUT && !QT_NO_DOCKWIDGET
-
-#ifdef Q_WS_MAC
-// Forward defs to make avoid including Carbon.h (faster compile you know ;).
-struct OpaqueHIObjectRef;
-typedef struct OpaqueHIObjectRef* HIObjectRef;
-typedef HIObjectRef HIToolbarItemRef;
-typedef const void * CFTypeRef;
-typedef const struct __CFString * CFStringRef;
-
-# ifdef QT_MAC_USE_COCOA
-#include <private/qunifiedtoolbarsurface_mac_p.h>
-# endif // QT_MAC_USE_COCOA
-
-#endif // Q_WS_MAC
-
-QT_BEGIN_NAMESPACE
-
-class QToolBar;
-class QRubberBand;
-
-/* This data structure represents the state of all the tool-bars and dock-widgets. It's value based
- so it can be easilly copied into a temporary variable. All operations are performed without moving
- any widgets. Only when we are sure we have the desired state, we call apply(), which moves the
- widgets.
-*/
-
-class QMainWindowLayoutState
-{
-public:
- QRect rect;
- QMainWindow *mainWindow;
-
- QMainWindowLayoutState(QMainWindow *win);
-
-#ifndef QT_NO_TOOLBAR
- QToolBarAreaLayout toolBarAreaLayout;
-#endif
-
-#ifndef QT_NO_DOCKWIDGET
- QDockAreaLayout dockAreaLayout;
-#else
- QLayoutItem *centralWidgetItem;
- QRect centralWidgetRect;
-#endif
-
- void apply(bool animated);
- void deleteAllLayoutItems();
- void deleteCentralWidgetItem();
-
- QSize sizeHint() const;
- QSize minimumSize() const;
- void fitLayout();
-
- QLayoutItem *itemAt(int index, int *x) const;
- QLayoutItem *takeAt(int index, int *x);
- QList<int> indexOf(QWidget *widget) const;
- QLayoutItem *item(const QList<int> &path);
- QRect itemRect(const QList<int> &path) const;
- QRect gapRect(const QList<int> &path) const; // ### get rid of this, use itemRect() instead
-
- bool contains(QWidget *widget) const;
-
- void setCentralWidget(QWidget *widget);
- QWidget *centralWidget() const;
-
- QList<int> gapIndex(QWidget *widget, const QPoint &pos) const;
- bool insertGap(const QList<int> &path, QLayoutItem *item);
- void remove(const QList<int> &path);
- void remove(QLayoutItem *item);
- void clear();
- bool isValid() const;
-
- QLayoutItem *plug(const QList<int> &path);
- QLayoutItem *unplug(const QList<int> &path, QMainWindowLayoutState *savedState = 0);
-
- void saveState(QDataStream &stream) const;
- bool checkFormat(QDataStream &stream, bool pre43);
- bool restoreState(QDataStream &stream, const QMainWindowLayoutState &oldState);
-};
-
-class Q_AUTOTEST_EXPORT QMainWindowLayout : public QLayout
-{
- Q_OBJECT
-
-public:
- QMainWindowLayoutState layoutState, savedState;
-
- QMainWindowLayout(QMainWindow *mainwindow, QLayout *parentLayout);
- ~QMainWindowLayout();
-
- QMainWindow::DockOptions dockOptions;
- void setDockOptions(QMainWindow::DockOptions opts);
- bool usesHIToolBar(QToolBar *toolbar) const;
-
- void timerEvent(QTimerEvent *e);
-
- // status bar
-
- QLayoutItem *statusbar;
-
-#ifndef QT_NO_STATUSBAR
- QStatusBar *statusBar() const;
- void setStatusBar(QStatusBar *sb);
-#endif
-
- // central widget
-
- QWidget *centralWidget() const;
- void setCentralWidget(QWidget *cw);
-
- // toolbars
-
-#ifndef QT_NO_TOOLBAR
- void addToolBarBreak(Qt::ToolBarArea area);
- void insertToolBarBreak(QToolBar *before);
- void removeToolBarBreak(QToolBar *before);
-
- void addToolBar(Qt::ToolBarArea area, QToolBar *toolbar, bool needAddChildWidget = true);
- void insertToolBar(QToolBar *before, QToolBar *toolbar);
- Qt::ToolBarArea toolBarArea(QToolBar *toolbar) const;
- bool toolBarBreak(QToolBar *toolBar) const;
- void getStyleOptionInfo(QStyleOptionToolBar *option, QToolBar *toolBar) const;
- void removeToolBar(QToolBar *toolbar);
- void toggleToolBarsVisible();
- void moveToolBar(QToolBar *toolbar, int pos);
-#endif
-
- // dock widgets
-
-#ifndef QT_NO_DOCKWIDGET
- void setCorner(Qt::Corner corner, Qt::DockWidgetArea area);
- Qt::DockWidgetArea corner(Qt::Corner corner) const;
- void addDockWidget(Qt::DockWidgetArea area,
- QDockWidget *dockwidget,
- Qt::Orientation orientation);
- void splitDockWidget(QDockWidget *after,
- QDockWidget *dockwidget,
- Qt::Orientation orientation);
- void tabifyDockWidget(QDockWidget *first, QDockWidget *second);
- Qt::DockWidgetArea dockWidgetArea(QDockWidget *dockwidget) const;
- void raise(QDockWidget *widget);
- void setVerticalTabsEnabled(bool enabled);
- bool restoreDockWidget(QDockWidget *dockwidget);
-
-#ifndef QT_NO_TABBAR
- bool _documentMode;
- bool documentMode() const;
- void setDocumentMode(bool enabled);
-
- QTabBar *getTabBar();
- QSet<QTabBar*> usedTabBars;
- QList<QTabBar*> unusedTabBars;
- bool verticalTabsEnabled;
-
- QWidget *getSeparatorWidget();
- QSet<QWidget*> usedSeparatorWidgets;
- QList<QWidget*> unusedSeparatorWidgets;
- int sep; // separator extent
-
-#ifndef QT_NO_TABWIDGET
- QTabWidget::TabPosition tabPositions[4];
- QTabWidget::TabShape _tabShape;
-
- QTabWidget::TabShape tabShape() const;
- void setTabShape(QTabWidget::TabShape tabShape);
- QTabWidget::TabPosition tabPosition(Qt::DockWidgetArea area) const;
- void setTabPosition(Qt::DockWidgetAreas areas, QTabWidget::TabPosition tabPosition);
-#endif // QT_NO_TABWIDGET
-#endif // QT_NO_TABBAR
-
- // separators
-
- QList<int> movingSeparator;
- QPoint movingSeparatorOrigin, movingSeparatorPos;
- QBasicTimer separatorMoveTimer;
-
- bool startSeparatorMove(const QPoint &pos);
- bool separatorMove(const QPoint &pos);
- bool endSeparatorMove(const QPoint &pos);
- void keepSize(QDockWidget *w);
-#endif // QT_NO_DOCKWIDGET
-
- // save/restore
-
- enum { // sentinel values used to validate state data
- VersionMarker = 0xff
- };
- void saveState(QDataStream &stream) const;
- bool restoreState(QDataStream &stream);
-
- // QLayout interface
-
- void addItem(QLayoutItem *item);
- void setGeometry(const QRect &r);
- QLayoutItem *itemAt(int index) const;
- QLayoutItem *takeAt(int index);
- int count() const;
-
- QSize sizeHint() const;
- QSize minimumSize() const;
- mutable QSize szHint;
- mutable QSize minSize;
- void invalidate();
-
- // animations
-
- QWidgetAnimator widgetAnimator;
- QList<int> currentGapPos;
- QRect currentGapRect;
- QWidget *pluggingWidget;
-#ifndef QT_NO_RUBBERBAND
- QRubberBand *gapIndicator;
-#endif
-
- QList<int> hover(QLayoutItem *widgetItem, const QPoint &mousePos);
- bool plug(QLayoutItem *widgetItem);
- QLayoutItem *unplug(QWidget *widget);
- void revert(QLayoutItem *widgetItem);
- void updateGapIndicator();
- void paintDropIndicator(QPainter *p, QWidget *widget, const QRegion &clip);
- void applyState(QMainWindowLayoutState &newState, bool animate = true);
- void restore(bool keepSavedState = false);
- void updateHIToolBarStatus();
- void animationFinished(QWidget *widget);
-
-private Q_SLOTS:
-#ifndef QT_NO_DOCKWIDGET
-#ifndef QT_NO_TABBAR
- void tabChanged();
-#endif
-#endif
-private:
-#ifndef QT_NO_TABBAR
- void updateTabBarShapes();
-#endif
-#ifdef Q_WS_MAC
-# ifndef QT_MAC_USE_COCOA
- static OSStatus qtmacToolbarDelegate(EventHandlerCallRef, EventRef , void *);
- static OSStatus qtoolbarInHIToolbarHandler(EventHandlerCallRef inCallRef, EventRef event,
- void *data);
- static void qtMacHIToolbarRegisterQToolBarInHIToolborItemClass();
- static HIToolbarItemRef CreateToolbarItemForIdentifier(CFStringRef identifier, CFTypeRef data);
- static HIToolbarItemRef createQToolBarInHIToolbarItem(QToolBar *toolbar,
- QMainWindowLayout *layout);
-# endif
-public:
- struct ToolBarSaveState {
- ToolBarSaveState() : movable(false) { }
- ToolBarSaveState(bool newMovable, const QSize &newMax)
- : movable(newMovable), maximumSize(newMax) { }
- bool movable;
- QSize maximumSize;
- };
- QList<QToolBar *> qtoolbarsInUnifiedToolbarList;
- QList<void *> toolbarItemsCopy;
- QHash<void *, QToolBar *> unifiedToolbarHash;
- QHash<QToolBar *, ToolBarSaveState> toolbarSaveState;
- QHash<QString, QToolBar *> cocoaItemIDToToolbarHash;
- void insertIntoMacToolbar(QToolBar *before, QToolBar *after);
- void removeFromMacToolbar(QToolBar *toolbar);
- void cleanUpMacToolbarItems();
- void fixSizeInUnifiedToolbar(QToolBar *tb) const;
- bool useHIToolBar;
- bool activateUnifiedToolbarAfterFullScreen;
- void syncUnifiedToolbarVisibility();
- bool blockVisiblityCheck;
-
-#ifdef QT_MAC_USE_COCOA
- QUnifiedToolbarSurface *unifiedSurface;
- void updateUnifiedToolbarOffset();
-#endif // QT_MAC_USE_COCOA
-
-#endif // Q_WS_MAC
-};
-QT_END_NAMESPACE
-
-#endif // QT_NO_MAINWINDOW
-
-#endif // QDYNAMICMAINWINDOWLAYOUT_P_H
diff --git a/src/gui/widgets/qmdiarea.h b/src/gui/widgets/qmdiarea.h
deleted file mode 100644
index a4b357c667..0000000000
--- a/src/gui/widgets/qmdiarea.h
+++ /dev/null
@@ -1,179 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMDIAREA_H
-#define QMDIAREA_H
-
-#include <QtGui/qabstractscrollarea.h>
-#include <QtGui/qtabwidget.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_MDIAREA
-
-class QMdiSubWindow;
-
-class QMdiAreaPrivate;
-class Q_GUI_EXPORT QMdiArea : public QAbstractScrollArea
-{
- Q_OBJECT
- Q_ENUMS(ViewMode)
- Q_PROPERTY(QBrush background READ background WRITE setBackground)
- Q_PROPERTY(WindowOrder activationOrder READ activationOrder WRITE setActivationOrder)
- Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode)
-#ifndef QT_NO_TABBAR
- Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode)
- Q_PROPERTY(bool tabsClosable READ tabsClosable WRITE setTabsClosable)
- Q_PROPERTY(bool tabsMovable READ tabsMovable WRITE setTabsMovable)
-#endif
-#ifndef QT_NO_TABWIDGET
- Q_PROPERTY(QTabWidget::TabShape tabShape READ tabShape WRITE setTabShape)
- Q_PROPERTY(QTabWidget::TabPosition tabPosition READ tabPosition WRITE setTabPosition)
-#endif
- Q_ENUMS(WindowOrder)
-public:
- enum AreaOption {
- DontMaximizeSubWindowOnActivation = 0x1
- };
- Q_DECLARE_FLAGS(AreaOptions, AreaOption)
-
- enum WindowOrder {
- CreationOrder,
- StackingOrder,
- ActivationHistoryOrder
- };
-
- enum ViewMode {
- SubWindowView,
- TabbedView
- };
-
- QMdiArea(QWidget *parent = 0);
- ~QMdiArea();
-
- QSize sizeHint() const;
- QSize minimumSizeHint() const;
-
- QMdiSubWindow *currentSubWindow() const;
- QMdiSubWindow *activeSubWindow() const;
- QList<QMdiSubWindow *> subWindowList(WindowOrder order = CreationOrder) const;
-
- QMdiSubWindow *addSubWindow(QWidget *widget, Qt::WindowFlags flags = 0);
- void removeSubWindow(QWidget *widget);
-
- QBrush background() const;
- void setBackground(const QBrush &background);
-
- WindowOrder activationOrder() const;
- void setActivationOrder(WindowOrder order);
-
- void setOption(AreaOption option, bool on = true);
- bool testOption(AreaOption opton) const;
-
- void setViewMode(ViewMode mode);
- ViewMode viewMode() const;
-
-#ifndef QT_NO_TABBAR
- bool documentMode() const;
- void setDocumentMode(bool enabled);
-
- void setTabsClosable(bool closable);
- bool tabsClosable() const;
-
- void setTabsMovable(bool movable);
- bool tabsMovable() const;
-#endif
-#ifndef QT_NO_TABWIDGET
- void setTabShape(QTabWidget::TabShape shape);
- QTabWidget::TabShape tabShape() const;
-
- void setTabPosition(QTabWidget::TabPosition position);
- QTabWidget::TabPosition tabPosition() const;
-#endif
-
-Q_SIGNALS:
- void subWindowActivated(QMdiSubWindow *);
-
-public Q_SLOTS:
- void setActiveSubWindow(QMdiSubWindow *window);
- void tileSubWindows();
- void cascadeSubWindows();
- void closeActiveSubWindow();
- void closeAllSubWindows();
- void activateNextSubWindow();
- void activatePreviousSubWindow();
-
-protected Q_SLOTS:
- void setupViewport(QWidget *viewport);
-
-protected:
- bool event(QEvent *event);
- bool eventFilter(QObject *object, QEvent *event);
- void paintEvent(QPaintEvent *paintEvent);
- void childEvent(QChildEvent *childEvent);
- void resizeEvent(QResizeEvent *resizeEvent);
- void timerEvent(QTimerEvent *timerEvent);
- void showEvent(QShowEvent *showEvent);
- bool viewportEvent(QEvent *event);
- void scrollContentsBy(int dx, int dy);
-
-private:
- Q_DISABLE_COPY(QMdiArea)
- Q_DECLARE_PRIVATE(QMdiArea)
- Q_PRIVATE_SLOT(d_func(), void _q_deactivateAllWindows())
- Q_PRIVATE_SLOT(d_func(), void _q_processWindowStateChanged(Qt::WindowStates, Qt::WindowStates))
- Q_PRIVATE_SLOT(d_func(), void _q_currentTabChanged(int))
- Q_PRIVATE_SLOT(d_func(), void _q_closeTab(int))
- Q_PRIVATE_SLOT(d_func(), void _q_moveTab(int, int))
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QMdiArea::AreaOptions)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_MDIAREA
-#endif // QMDIAREA_H
diff --git a/src/gui/widgets/qmdiarea_p.h b/src/gui/widgets/qmdiarea_p.h
deleted file mode 100644
index e5e20570d1..0000000000
--- a/src/gui/widgets/qmdiarea_p.h
+++ /dev/null
@@ -1,285 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMDIAREA_P_H
-#define QMDIAREA_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qmdiarea.h"
-#include "qmdisubwindow.h"
-
-#ifndef QT_NO_MDIAREA
-
-#include <QList>
-#include <QRect>
-#include <QPoint>
-#include <QtGui/qapplication.h>
-#include <private/qmdisubwindow_p.h>
-#include <private/qabstractscrollarea_p.h>
-
-QT_BEGIN_NAMESPACE
-
-namespace QMdi {
-class Rearranger
-{
-public:
- enum Type {
- RegularTiler,
- SimpleCascader,
- IconTiler
- };
-
- // Rearranges widgets relative to domain.
- virtual void rearrange(QList<QWidget *> &widgets, const QRect &domain) const = 0;
- virtual Type type() const = 0;
- virtual ~Rearranger() {}
-};
-
-class RegularTiler : public Rearranger
-{
- // Rearranges widgets according to a regular tiling pattern
- // covering the entire domain.
- // Both positions and sizes may change.
- void rearrange(QList<QWidget *> &widgets, const QRect &domain) const;
- inline Type type() const { return Rearranger::RegularTiler; }
-};
-
-class SimpleCascader : public Rearranger
-{
- // Rearranges widgets according to a simple, regular cascading pattern.
- // Widgets are resized to minimumSize.
- // Both positions and sizes may change.
- void rearrange(QList<QWidget *> &widgets, const QRect &domain) const;
- inline Type type() const { return Rearranger::SimpleCascader; }
-};
-
-class IconTiler : public Rearranger
-{
- // Rearranges icons (assumed to be the same size) according to a regular
- // tiling pattern filling up the domain from the bottom.
- // Only positions may change.
- void rearrange(QList<QWidget *> &widgets, const QRect &domain) const;
- inline Type type() const { return Rearranger::IconTiler; }
-};
-
-class Placer
-{
-public:
- // Places the rectangle defined by 'size' relative to 'rects' and 'domain'.
- // Returns the position of the resulting rectangle.
- virtual QPoint place(
- const QSize &size, const QList<QRect> &rects, const QRect &domain) const = 0;
- virtual ~Placer() {}
-};
-
-class MinOverlapPlacer : public Placer
-{
- QPoint place(const QSize &size, const QList<QRect> &rects, const QRect &domain) const;
- static int accumulatedOverlap(const QRect &source, const QList<QRect> &rects);
- static QRect findMinOverlapRect(const QList<QRect> &source, const QList<QRect> &rects);
- static void getCandidatePlacements(
- const QSize &size, const QList<QRect> &rects, const QRect &domain,
- QList<QRect> &candidates);
- static QPoint findBestPlacement(
- const QRect &domain, const QList<QRect> &rects, QList<QRect> &source);
- static void findNonInsiders(
- const QRect &domain, QList<QRect> &source, QList<QRect> &result);
- static void findMaxOverlappers(
- const QRect &domain, const QList<QRect> &source, QList<QRect> &result);
-};
-} // namespace QMdi
-
-class QMdiAreaTabBar;
-class QMdiAreaPrivate : public QAbstractScrollAreaPrivate
-{
- Q_DECLARE_PUBLIC(QMdiArea)
-public:
- QMdiAreaPrivate();
-
- // Variables.
- QMdi::Rearranger *cascader;
- QMdi::Rearranger *regularTiler;
- QMdi::Rearranger *iconTiler;
- QMdi::Placer *placer;
-#ifndef QT_NO_RUBBERBAND
- QRubberBand *rubberBand;
-#endif
- QMdiAreaTabBar *tabBar;
- QList<QMdi::Rearranger *> pendingRearrangements;
- QList< QPointer<QMdiSubWindow> > pendingPlacements;
- QList< QPointer<QMdiSubWindow> > childWindows;
- QList<int> indicesToActivatedChildren;
- QPointer<QMdiSubWindow> active;
- QPointer<QMdiSubWindow> aboutToBecomeActive;
- QBrush background;
- QMdiArea::WindowOrder activationOrder;
- QMdiArea::AreaOptions options;
- QMdiArea::ViewMode viewMode;
-#ifndef QT_NO_TABBAR
- bool documentMode;
- bool tabsClosable;
- bool tabsMovable;
-#endif
-#ifndef QT_NO_TABWIDGET
- QTabWidget::TabShape tabShape;
- QTabWidget::TabPosition tabPosition;
-#endif
- bool ignoreGeometryChange;
- bool ignoreWindowStateChange;
- bool isActivated;
- bool isSubWindowsTiled;
- bool showActiveWindowMaximized;
- bool tileCalledFromResizeEvent;
- bool updatesDisabledByUs;
- bool inViewModeChange;
- int indexToNextWindow;
- int indexToPreviousWindow;
- int indexToHighlighted;
- int indexToLastActiveTab;
- int resizeTimerId;
- int tabToPreviousTimerId;
-
- // Slots.
- void _q_deactivateAllWindows(QMdiSubWindow *aboutToActivate = 0);
- void _q_processWindowStateChanged(Qt::WindowStates oldState, Qt::WindowStates newState);
- void _q_currentTabChanged(int index);
- void _q_closeTab(int index);
- void _q_moveTab(int from, int to);
-
- // Functions.
- void appendChild(QMdiSubWindow *child);
- void place(QMdi::Placer *placer, QMdiSubWindow *child);
- void rearrange(QMdi::Rearranger *rearranger);
- void arrangeMinimizedSubWindows();
- void activateWindow(QMdiSubWindow *child);
- void activateCurrentWindow();
- void activateHighlightedWindow();
- void emitWindowActivated(QMdiSubWindow *child);
- void resetActiveWindow(QMdiSubWindow *child = 0);
- void updateActiveWindow(int removedIndex, bool activeRemoved);
- void updateScrollBars();
- void internalRaise(QMdiSubWindow *child) const;
- bool scrollBarsEnabled() const;
- bool lastWindowAboutToBeDestroyed() const;
- void setChildActivationEnabled(bool enable = true, bool onlyNextActivationEvent = false) const;
- QRect resizeToMinimumTileSize(const QSize &minSubWindowSize, int subWindowCount);
- void scrollBarPolicyChanged(Qt::Orientation, Qt::ScrollBarPolicy); // reimp
- QMdiSubWindow *nextVisibleSubWindow(int increaseFactor, QMdiArea::WindowOrder,
- int removed = -1, int fromIndex = -1) const;
- void highlightNextSubWindow(int increaseFactor);
- QList<QMdiSubWindow *> subWindowList(QMdiArea::WindowOrder, bool reversed = false) const;
- void disconnectSubWindow(QObject *subWindow);
- void setViewMode(QMdiArea::ViewMode mode);
-#ifndef QT_NO_TABBAR
- void updateTabBarGeometry();
- void refreshTabBar();
-#endif
-
- inline void startResizeTimer()
- {
- Q_Q(QMdiArea);
- if (resizeTimerId > 0)
- q->killTimer(resizeTimerId);
- resizeTimerId = q->startTimer(200);
- }
-
- inline void startTabToPreviousTimer()
- {
- Q_Q(QMdiArea);
- if (tabToPreviousTimerId > 0)
- q->killTimer(tabToPreviousTimerId);
- tabToPreviousTimerId = q->startTimer(QApplication::keyboardInputInterval());
- }
-
- inline bool windowStaysOnTop(QMdiSubWindow *subWindow) const
- {
- if (!subWindow)
- return false;
- return subWindow->windowFlags() & Qt::WindowStaysOnTopHint;
- }
-
- inline bool isExplicitlyDeactivated(QMdiSubWindow *subWindow) const
- {
- if (!subWindow)
- return true;
- return subWindow->d_func()->isExplicitlyDeactivated;
- }
-
- inline void setActive(QMdiSubWindow *subWindow, bool active = true, bool changeFocus = true) const
- {
- if (subWindow)
- subWindow->d_func()->setActive(active, changeFocus);
- }
-
-#ifndef QT_NO_RUBBERBAND
- inline void showRubberBandFor(QMdiSubWindow *subWindow)
- {
- if (!subWindow || !rubberBand)
- return;
- rubberBand->setGeometry(subWindow->geometry());
- rubberBand->raise();
- rubberBand->show();
- }
-
- inline void hideRubberBand()
- {
- if (rubberBand && rubberBand->isVisible())
- rubberBand->hide();
- indexToHighlighted = -1;
- }
-#endif // QT_NO_RUBBERBAND
-};
-
-#endif // QT_NO_MDIAREA
-
-QT_END_NAMESPACE
-
-#endif // QMDIAREA_P_H
diff --git a/src/gui/widgets/qmdisubwindow.h b/src/gui/widgets/qmdisubwindow.h
deleted file mode 100644
index 98c7b4c9c4..0000000000
--- a/src/gui/widgets/qmdisubwindow.h
+++ /dev/null
@@ -1,159 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMDISUBWINDOW_H
-#define QMDISUBWINDOW_H
-
-#include <QtGui/qwidget.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_MDIAREA
-
-class QMenu;
-class QMdiArea;
-
-namespace QMdi { class ControlContainer; }
-class QMdiSubWindowPrivate;
-class Q_GUI_EXPORT QMdiSubWindow : public QWidget
-{
- Q_OBJECT
- Q_PROPERTY(int keyboardSingleStep READ keyboardSingleStep WRITE setKeyboardSingleStep)
- Q_PROPERTY(int keyboardPageStep READ keyboardPageStep WRITE setKeyboardPageStep)
-public:
- enum SubWindowOption {
- AllowOutsideAreaHorizontally = 0x1, // internal
- AllowOutsideAreaVertically = 0x2, // internal
- RubberBandResize = 0x4,
- RubberBandMove = 0x8
- };
- Q_DECLARE_FLAGS(SubWindowOptions, SubWindowOption)
-
- QMdiSubWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0);
- ~QMdiSubWindow();
-
- QSize sizeHint() const;
- QSize minimumSizeHint() const;
-
- void setWidget(QWidget *widget);
- QWidget *widget() const;
-
- QWidget *maximizedButtonsWidget() const; // internal
- QWidget *maximizedSystemMenuIconWidget() const; // internal
-
- bool isShaded() const;
-
- void setOption(SubWindowOption option, bool on = true);
- bool testOption(SubWindowOption) const;
-
- void setKeyboardSingleStep(int step);
- int keyboardSingleStep() const;
-
- void setKeyboardPageStep(int step);
- int keyboardPageStep() const;
-
-#ifndef QT_NO_MENU
- void setSystemMenu(QMenu *systemMenu);
- QMenu *systemMenu() const;
-#endif
-
- QMdiArea *mdiArea() const;
-
-Q_SIGNALS:
- void windowStateChanged(Qt::WindowStates oldState, Qt::WindowStates newState);
- void aboutToActivate();
-
-public Q_SLOTS:
-#ifndef QT_NO_MENU
- void showSystemMenu();
-#endif
- void showShaded();
-
-protected:
- bool eventFilter(QObject *object, QEvent *event);
- bool event(QEvent *event);
- void showEvent(QShowEvent *showEvent);
- void hideEvent(QHideEvent *hideEvent);
- void changeEvent(QEvent *changeEvent);
- void closeEvent(QCloseEvent *closeEvent);
- void leaveEvent(QEvent *leaveEvent);
- void resizeEvent(QResizeEvent *resizeEvent);
- void timerEvent(QTimerEvent *timerEvent);
- void moveEvent(QMoveEvent *moveEvent);
- void paintEvent(QPaintEvent *paintEvent);
- void mousePressEvent(QMouseEvent *mouseEvent);
- void mouseDoubleClickEvent(QMouseEvent *mouseEvent);
- void mouseReleaseEvent(QMouseEvent *mouseEvent);
- void mouseMoveEvent(QMouseEvent *mouseEvent);
- void keyPressEvent(QKeyEvent *keyEvent);
-#ifndef QT_NO_CONTEXTMENU
- void contextMenuEvent(QContextMenuEvent *contextMenuEvent);
-#endif
- void focusInEvent(QFocusEvent *focusInEvent);
- void focusOutEvent(QFocusEvent *focusOutEvent);
- void childEvent(QChildEvent *childEvent);
-
-private:
- Q_DISABLE_COPY(QMdiSubWindow)
- Q_DECLARE_PRIVATE(QMdiSubWindow)
- Q_PRIVATE_SLOT(d_func(), void _q_updateStaysOnTopHint())
- Q_PRIVATE_SLOT(d_func(), void _q_enterInteractiveMode())
- Q_PRIVATE_SLOT(d_func(), void _q_processFocusChanged(QWidget *, QWidget *))
- friend class QMdiAreaPrivate;
-#ifndef QT_NO_TABBAR
- friend class QMdiAreaTabBar;
-#endif
- friend class QMdi::ControlContainer;
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QMdiSubWindow::SubWindowOptions)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_MDIAREA
-
-#endif // QMDISUBWINDOW_H
diff --git a/src/gui/widgets/qmenu.h b/src/gui/widgets/qmenu.h
deleted file mode 100644
index daac91632a..0000000000
--- a/src/gui/widgets/qmenu.h
+++ /dev/null
@@ -1,434 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMENU_H
-#define QMENU_H
-
-#include <QtGui/qwidget.h>
-#include <QtCore/qstring.h>
-#include <QtGui/qicon.h>
-#include <QtGui/qaction.h>
-
-#ifdef QT3_SUPPORT
-#include <QtGui/qpixmap.h>
-#endif
-
-#ifdef Q_WS_WINCE
-#include <windef.h> // for HMENU
-#endif
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_MENU
-
-class QMenuPrivate;
-class QStyleOptionMenuItem;
-#ifdef QT3_SUPPORT
-class QMenuItem;
-#endif
-
-class Q_GUI_EXPORT QMenu : public QWidget
-{
-private:
- Q_OBJECT
- Q_DECLARE_PRIVATE(QMenu)
-
- Q_PROPERTY(bool tearOffEnabled READ isTearOffEnabled WRITE setTearOffEnabled)
- Q_PROPERTY(QString title READ title WRITE setTitle)
- Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
- Q_PROPERTY(bool separatorsCollapsible READ separatorsCollapsible WRITE setSeparatorsCollapsible)
-
-public:
- explicit QMenu(QWidget *parent = 0);
- explicit QMenu(const QString &title, QWidget *parent = 0);
- ~QMenu();
-
-#ifdef Q_NO_USING_KEYWORD
- inline void addAction(QAction *action) { QWidget::addAction(action); }
-#else
- using QWidget::addAction;
-#endif
- QAction *addAction(const QString &text);
- QAction *addAction(const QIcon &icon, const QString &text);
- QAction *addAction(const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut = 0);
- QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut = 0);
-
- QAction *addMenu(QMenu *menu);
- QMenu *addMenu(const QString &title);
- QMenu *addMenu(const QIcon &icon, const QString &title);
-
- QAction *addSeparator();
-
- QAction *insertMenu(QAction *before, QMenu *menu);
- QAction *insertSeparator(QAction *before);
-
- bool isEmpty() const;
- void clear();
-
- void setTearOffEnabled(bool);
- bool isTearOffEnabled() const;
-
- bool isTearOffMenuVisible() const;
- void hideTearOffMenu();
-
- void setDefaultAction(QAction *);
- QAction *defaultAction() const;
-
- void setActiveAction(QAction *act);
- QAction *activeAction() const;
-
- void popup(const QPoint &pos, QAction *at=0);
- QAction *exec();
- QAction *exec(const QPoint &pos, QAction *at=0);
-
- // ### Qt 5: merge
- static QAction *exec(QList<QAction*> actions, const QPoint &pos, QAction *at=0);
- static QAction *exec(QList<QAction*> actions, const QPoint &pos, QAction *at, QWidget *parent);
-
- QSize sizeHint() const;
-
- QRect actionGeometry(QAction *) const;
- QAction *actionAt(const QPoint &) const;
-
- QAction *menuAction() const;
-
- QString title() const;
- void setTitle(const QString &title);
-
- QIcon icon() const;
- void setIcon(const QIcon &icon);
-
- void setNoReplayFor(QWidget *widget);
-#ifdef Q_WS_MAC
- OSMenuRef macMenu(OSMenuRef merge=0);
-#endif
-
-#ifdef Q_WS_WINCE
- HMENU wceMenu();
-#endif
-
- bool separatorsCollapsible() const;
- void setSeparatorsCollapsible(bool collapse);
-
-Q_SIGNALS:
- void aboutToShow();
- void aboutToHide();
- void triggered(QAction *action);
- void hovered(QAction *action);
-
-protected:
- int columnCount() const;
-
- void changeEvent(QEvent *);
- void keyPressEvent(QKeyEvent *);
- void mouseReleaseEvent(QMouseEvent *);
- void mousePressEvent(QMouseEvent *);
- void mouseMoveEvent(QMouseEvent *);
-#ifndef QT_NO_WHEELEVENT
- void wheelEvent(QWheelEvent *);
-#endif
- void enterEvent(QEvent *);
- void leaveEvent(QEvent *);
- void hideEvent(QHideEvent *);
- void paintEvent(QPaintEvent *);
- void actionEvent(QActionEvent *);
- void timerEvent(QTimerEvent *);
- bool event(QEvent *);
- bool focusNextPrevChild(bool next);
- void initStyleOption(QStyleOptionMenuItem *option, const QAction *action) const;
-
-#ifdef Q_WS_WINCE
- QAction* wceCommands(uint command);
-#endif
-
-private Q_SLOTS:
- void internalSetSloppyAction();
- void internalDelayedPopup();
-
-private:
- Q_PRIVATE_SLOT(d_func(), void _q_actionTriggered())
- Q_PRIVATE_SLOT(d_func(), void _q_actionHovered())
- Q_PRIVATE_SLOT(d_func(), void _q_overrideMenuActionDestroyed())
-
-#ifdef QT3_SUPPORT
-public:
- //menudata
- inline QT3_SUPPORT uint count() const { return actions().count(); }
- inline QT3_SUPPORT int insertItem(const QString &text, const QObject *receiver, const char* member,
- const QKeySequence& shortcut = 0, int id = -1, int index = -1) {
- return insertAny(0, &text, receiver, member, &shortcut, 0, id, index);
- }
- inline QT3_SUPPORT int insertItem(const QIcon& icon, const QString &text,
- const QObject *receiver, const char* member,
- const QKeySequence& shortcut = 0, int id = -1, int index = -1) {
- return insertAny(&icon, &text, receiver, member, &shortcut, 0, id, index);
- }
- inline QT3_SUPPORT int insertItem(const QPixmap &pixmap, const QObject *receiver, const char* member,
- const QKeySequence& shortcut = 0, int id = -1, int index = -1) {
- QIcon icon(pixmap);
- return insertAny(&icon, 0, receiver, member, &shortcut, 0, id, index);
- }
- inline QT3_SUPPORT int insertItem(const QString &text, int id=-1, int index=-1) {
- return insertAny(0, &text, 0, 0, 0, 0, id, index);
- }
- inline QT3_SUPPORT int insertItem(const QIcon& icon, const QString &text, int id=-1, int index=-1) {
- return insertAny(&icon, &text, 0, 0, 0, 0, id, index);
- }
- inline QT3_SUPPORT int insertItem(const QString &text, QMenu *popup, int id=-1, int index=-1) {
- return insertAny(0, &text, 0, 0, 0, popup, id, index);
- }
- inline QT3_SUPPORT int insertItem(const QIcon& icon, const QString &text, QMenu *popup, int id=-1, int index=-1) {
- return insertAny(&icon, &text, 0, 0, 0, popup, id, index);
- }
- inline QT3_SUPPORT int insertItem(const QPixmap &pixmap, int id=-1, int index=-1) {
- QIcon icon(pixmap);
- return insertAny(&icon, 0, 0, 0, 0, 0, id, index);
- }
- inline QT3_SUPPORT int insertItem(const QPixmap &pixmap, QMenu *popup, int id=-1, int index=-1) {
- QIcon icon(pixmap);
- return insertAny(&icon, 0, 0, 0, 0, popup, id, index);
- }
- QT3_SUPPORT int insertItem(QMenuItem *item, int id=-1, int index=-1);
- QT3_SUPPORT int insertSeparator(int index=-1);
- inline QT3_SUPPORT void removeItem(int id) {
- if(QAction *act = findActionForId(id))
- removeAction(act); }
- inline QT3_SUPPORT void removeItemAt(int index) {
- if(QAction *act = actions().value(index))
- removeAction(act); }
-#ifndef QT_NO_SHORTCUT
- inline QT3_SUPPORT QKeySequence accel(int id) const {
- if(QAction *act = findActionForId(id))
- return act->shortcut();
- return QKeySequence(); }
- inline QT3_SUPPORT void setAccel(const QKeySequence& key, int id) {
- if(QAction *act = findActionForId(id))
- act->setShortcut(key);
- }
-#endif
- inline QT3_SUPPORT QIcon iconSet(int id) const {
- if(QAction *act = findActionForId(id))
- return act->icon();
- return QIcon(); }
- inline QT3_SUPPORT QString text(int id) const {
- if(QAction *act = findActionForId(id))
- return act->text();
- return QString(); }
- inline QT3_SUPPORT QPixmap pixmap(int id) const {
- if(QAction *act = findActionForId(id))
- return act->icon().pixmap(QSize(22, 22));
- return QPixmap(); }
- inline QT3_SUPPORT void setWhatsThis(int id, const QString &w) {
- if(QAction *act = findActionForId(id))
- act->setWhatsThis(w); }
- inline QT3_SUPPORT QString whatsThis(int id) const {
- if(QAction *act = findActionForId(id))
- return act->whatsThis();
- return QString(); }
-
- inline QT3_SUPPORT void changeItem(int id, const QString &text) {
- if(QAction *act = findActionForId(id))
- act->setText(text); }
- inline QT3_SUPPORT void changeItem(int id, const QPixmap &pixmap) {
- if(QAction *act = findActionForId(id))
- act->setIcon(QIcon(pixmap)); }
- inline QT3_SUPPORT void changeItem(int id, const QIcon &icon, const QString &text) {
- if(QAction *act = findActionForId(id)) {
- act->setIcon(icon);
- act->setText(text);
- }
- }
- inline QT3_SUPPORT void setActiveItem(int id) {
- setActiveAction(findActionForId(id));
- }
- inline QT3_SUPPORT bool isItemActive(int id) const {
- return findActionForId(id) == activeAction();
- }
- inline QT3_SUPPORT bool isItemEnabled(int id) const {
- if(QAction *act = findActionForId(id))
- return act->isEnabled();
- return false; }
- inline QT3_SUPPORT void setItemEnabled(int id, bool enable) {
- if(QAction *act = findActionForId(id))
- act->setEnabled(enable);
- }
- inline QT3_SUPPORT bool isItemChecked(int id) const {
- if(QAction *act = findActionForId(id))
- return act->isChecked();
- return false;
- }
- inline QT3_SUPPORT void setItemChecked(int id, bool check) {
- if(QAction *act = findActionForId(id)) {
- act->setCheckable(true);
- act->setChecked(check);
- }
- }
- inline QT3_SUPPORT bool isItemVisible(int id) const {
- if(QAction *act = findActionForId(id))
- return act->isVisible();
- return false;
- }
- inline QT3_SUPPORT void setItemVisible(int id, bool visible) {
- if(QAction *act = findActionForId(id))
- act->setVisible(visible);
- }
- inline QT3_SUPPORT QRect itemGeometry(int index) {
- if(QAction *act = actions().value(index))
- return actionGeometry(act);
- return QRect();
- }
- inline QT3_SUPPORT QFont itemFont(int id) const {
- if(QAction *act = findActionForId(id))
- return act->font();
- return QFont();
- }
- inline QT3_SUPPORT void setItemFont(int id, const QFont &font) {
- if(QAction *act = findActionForId(id))
- act->setFont(font);
- }
- inline QT3_SUPPORT int indexOf(int id) const {
- return actions().indexOf(findActionForId(id));
- }
- inline QT3_SUPPORT int idAt(int index) const {
- return findIdForAction(actions().value(index));
- }
- QT3_SUPPORT void setId (int index, int id);
- inline QT3_SUPPORT void activateItemAt(int index) {
- if(QAction *ret = actions().value(index))
- ret->activate(QAction::Trigger);
- }
- inline QT3_SUPPORT bool connectItem(int id, const QObject *receiver, const char* member) {
- if(QAction *act = findActionForId(id)) {
- QObject::connect(act, SIGNAL(activated(int)), receiver, member);
- return true;
- }
- return false;
- }
- inline QT3_SUPPORT bool disconnectItem(int id,const QObject *receiver, const char* member) {
- if(QAction *act = findActionForId(id)) {
- QObject::disconnect(act, SIGNAL(triggered()), receiver, member);
- return true;
- }
- return false;
- }
- inline QT3_SUPPORT QMenuItem *findItem(int id) const {
- return reinterpret_cast<QMenuItem*>(findActionForId(id));
- }
-
- inline QT3_SUPPORT void setCheckable(bool){}
- inline QT3_SUPPORT bool isCheckable() const {return true;}
-
- QT3_SUPPORT QMenuItem *findPopup( QMenu *popup, int *index );
-
- QT3_SUPPORT bool setItemParameter(int id, int param);
- QT3_SUPPORT int itemParameter(int id) const;
-
- //frame
- QT3_SUPPORT int frameWidth() const;
-
- //popupmenu
- inline QT3_SUPPORT void popup(const QPoint & pos, int indexAtPoint) { popup(pos, actions().value(indexAtPoint)); }
- inline QT3_SUPPORT int insertTearOffHandle(int = 0, int = 0) {
- setTearOffEnabled(true);
- return -1;
- }
-
-protected:
- inline QT3_SUPPORT int itemAtPos(const QPoint &p, bool ignoreSeparator = true) {
- QAction *ret = actionAt(p);
- if(ignoreSeparator && ret && ret->isSeparator())
- return -1;
- return findIdForAction(ret);
- }
- inline QT3_SUPPORT int columns() const { return columnCount(); }
- inline QT3_SUPPORT int itemHeight(int index) {
- return actionGeometry(actions().value(index)).height();
- }
- inline QT3_SUPPORT int itemHeight(QMenuItem *mi) {
- return actionGeometry(reinterpret_cast<QAction *>(mi)).height();
- }
-
-Q_SIGNALS:
- QT_MOC_COMPAT void activated(int itemId);
- QT_MOC_COMPAT void highlighted(int itemId);
-
-private:
- int insertAny(const QIcon *icon, const QString *text, const QObject *receiver, const char *member,
- const QKeySequence *shorcut, const QMenu *popup, int id, int index);
- QAction *findActionForId(int id) const;
- int findIdForAction(QAction*) const;
-#endif
-
-protected:
- QMenu(QMenuPrivate &dd, QWidget* parent = 0);
-
-private:
- Q_DISABLE_COPY(QMenu)
-
- friend class QMenuBar;
- friend class QMenuBarPrivate;
- friend class QTornOffMenu;
- friend class Q3PopupMenu;
- friend class QComboBox;
- friend class QAction;
- friend class QToolButtonPrivate;
-
-#ifdef Q_WS_MAC
- friend void qt_mac_trayicon_activate_action(QMenu *, QAction *action);
- friend bool qt_mac_watchingAboutToShow(QMenu *);
- friend OSStatus qt_mac_menu_event(EventHandlerCallRef, EventRef, void *);
- friend bool qt_mac_activate_action(OSMenuRef, uint, QAction::ActionEvent, bool);
- friend void qt_mac_emit_menuSignals(QMenu *, bool);
- friend void qt_mac_menu_emit_hovered(QMenu *menu, QAction *action);
-#endif
-};
-
-#endif // QT_NO_MENU
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMENU_H
diff --git a/src/gui/widgets/qmenu_p.h b/src/gui/widgets/qmenu_p.h
deleted file mode 100644
index 005ce1d6ee..0000000000
--- a/src/gui/widgets/qmenu_p.h
+++ /dev/null
@@ -1,395 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMENU_P_H
-#define QMENU_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "QtGui/qmenubar.h"
-#include "QtGui/qstyleoption.h"
-#include "QtCore/qdatetime.h"
-#include "QtCore/qmap.h"
-#include "QtCore/qhash.h"
-#include "QtCore/qbasictimer.h"
-#include "private/qwidget_p.h"
-
-#ifdef Q_WS_S60
-class CEikMenuPane;
-#define QT_SYMBIAN_FIRST_MENU_ITEM 32000
-#define QT_SYMBIAN_LAST_MENU_ITEM 41999 // 10000 items ought to be enough for anybody...
-#endif
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_MENU
-
-#ifdef Q_WS_S60
-void qt_symbian_next_menu_from_action(QWidget* actionContainer);
-void qt_symbian_show_toplevel(CEikMenuPane* menuPane);
-void qt_symbian_show_submenu(CEikMenuPane* menuPane, int id);
-#endif // Q_WS_S60
-
-class QTornOffMenu;
-class QEventLoop;
-
-#ifdef Q_WS_MAC
-# ifdef __OBJC__
-QT_END_NAMESPACE
-@class NSMenuItem;
-QT_BEGIN_NAMESPACE
-# else
-typedef void NSMenuItem;
-# endif //__OBJC__
-struct QMacMenuAction {
- QMacMenuAction()
-#ifndef QT_MAC_USE_COCOA
- : command(0)
-#else
- : menuItem(0)
-#endif
- , ignore_accel(0), merged(0), menu(0)
- {
- }
- ~QMacMenuAction();
-#ifndef QT_MAC_USE_COCOA
- uint command;
-#else
- NSMenuItem *menuItem;
-#endif
- uchar ignore_accel : 1;
- uchar merged : 1;
- QPointer<QAction> action;
- OSMenuRef menu;
-};
-
-struct QMenuMergeItem
-{
-#ifndef QT_MAC_USE_COCOA
- inline QMenuMergeItem(MenuCommand c, QMacMenuAction *a) : command(c), action(a) { }
- MenuCommand command;
-#else
- inline QMenuMergeItem(NSMenuItem *c, QMacMenuAction *a) : menuItem(c), action(a) { }
- NSMenuItem *menuItem;
-#endif
- QMacMenuAction *action;
-};
-typedef QList<QMenuMergeItem> QMenuMergeList;
-#endif
-
-#ifdef Q_WS_WINCE
-struct QWceMenuAction {
- uint command;
- QPointer<QAction> action;
- HMENU menuHandle;
- QWceMenuAction() : menuHandle(0), command(0) {}
-};
-#endif
-#ifdef Q_WS_S60
-struct QSymbianMenuAction {
- uint command;
- int parent;
- CEikMenuPane* menuPane;
- QPointer<QAction> action;
- QSymbianMenuAction() : command(0) {}
-};
-#endif
-
-class QMenuPrivate : public QWidgetPrivate
-{
- Q_DECLARE_PUBLIC(QMenu)
-public:
- QMenuPrivate() : itemsDirty(0), maxIconWidth(0), tabWidth(0), ncols(0),
- collapsibleSeparators(true), activationRecursionGuard(false), hasHadMouse(0), aboutToHide(0), motions(0),
- currentAction(0),
-#ifdef QT_KEYPAD_NAVIGATION
- selectAction(0),
- cancelAction(0),
-#endif
- scroll(0), eventLoop(0), tearoff(0), tornoff(0), tearoffHighlighted(0),
- hasCheckableItems(0), sloppyAction(0), doChildEffects(false)
-#ifdef Q_WS_MAC
- ,mac_menu(0)
-#endif
-#if defined(Q_WS_WINCE) && !defined(QT_NO_MENUBAR)
- ,wce_menu(0)
-#endif
-#ifdef Q_WS_S60
- ,symbian_menu(0)
-#endif
-#ifdef QT3_SUPPORT
- ,emitHighlighted(false)
-#endif
- { }
- ~QMenuPrivate()
- {
- delete scroll;
-#ifdef Q_WS_MAC
- delete mac_menu;
-#endif
-#if defined(Q_WS_WINCE) && !defined(QT_NO_MENUBAR)
- delete wce_menu;
-#endif
-#ifdef Q_WS_S60
- delete symbian_menu;
-#endif
-
- }
- void init();
-
- static QMenuPrivate *get(QMenu *m) { return m->d_func(); }
- int scrollerHeight() const;
-
- //item calculations
- mutable uint itemsDirty : 1;
- mutable uint maxIconWidth, tabWidth;
- QRect actionRect(QAction *) const;
-
- mutable QVector<QRect> actionRects;
- mutable QHash<QAction *, QWidget *> widgetItems;
- void updateActionRects() const;
- void updateActionRects(const QRect &screen) const;
- QRect popupGeometry(const QWidget *widget) const;
- QRect popupGeometry(int screen = -1) const;
- mutable uint ncols : 4; //4 bits is probably plenty
- uint collapsibleSeparators : 1;
- QSize adjustMenuSizeForScreen(const QRect & screen);
- int getLastVisibleAction() const;
-
- bool activationRecursionGuard;
-
- //selection
- static QMenu *mouseDown;
- QPoint mousePopupPos;
- uint hasHadMouse : 1;
- uint aboutToHide : 1;
- int motions;
- QAction *currentAction;
-#ifdef QT_KEYPAD_NAVIGATION
- QAction *selectAction;
- QAction *cancelAction;
-#endif
- QBasicTimer menuDelayTimer;
- enum SelectionReason {
- SelectedFromKeyboard,
- SelectedFromElsewhere
- };
- QWidget *topCausedWidget() const;
- QAction *actionAt(QPoint p) const;
- void setFirstActionActive();
- void setCurrentAction(QAction *, int popup = -1, SelectionReason reason = SelectedFromElsewhere, bool activateFirst = false);
- void popupAction(QAction *, int, bool);
- void setSyncAction();
-
- //scrolling support
- struct QMenuScroller {
- enum ScrollLocation { ScrollStay, ScrollBottom, ScrollTop, ScrollCenter };
- enum ScrollDirection { ScrollNone=0, ScrollUp=0x01, ScrollDown=0x02 };
- uint scrollFlags : 2, scrollDirection : 2;
- int scrollOffset;
- QBasicTimer scrollTimer;
-
- QMenuScroller() : scrollFlags(ScrollNone), scrollDirection(ScrollNone), scrollOffset(0) { }
- ~QMenuScroller() { }
- } *scroll;
- void scrollMenu(QMenuScroller::ScrollLocation location, bool active=false);
- void scrollMenu(QMenuScroller::ScrollDirection direction, bool page=false, bool active=false);
- void scrollMenu(QAction *action, QMenuScroller::ScrollLocation location, bool active=false);
-
- //synchronous operation (ie exec())
- QEventLoop *eventLoop;
- QPointer<QAction> syncAction;
-
- //search buffer
- QString searchBuffer;
- QBasicTimer searchBufferTimer;
-
- //passing of mouse events up the parent hierarchy
- QPointer<QMenu> activeMenu;
- bool mouseEventTaken(QMouseEvent *);
-
- //used to walk up the popup list
- struct QMenuCaused {
- QPointer<QWidget> widget;
- QPointer<QAction> action;
- };
- virtual QList<QPointer<QWidget> > calcCausedStack() const;
- QMenuCaused causedPopup;
- void hideUpToMenuBar();
- void hideMenu(QMenu *menu, bool justRegister = false);
-
- //index mappings
- inline QAction *actionAt(int i) const { return q_func()->actions().at(i); }
- inline int indexOf(QAction *act) const { return q_func()->actions().indexOf(act); }
-
- //tear off support
- uint tearoff : 1, tornoff : 1, tearoffHighlighted : 1;
- QPointer<QTornOffMenu> tornPopup;
-
- mutable bool hasCheckableItems;
-
- //sloppy selection
- static int sloppyDelayTimer;
- mutable QAction *sloppyAction;
- QRegion sloppyRegion;
-
- //default action
- QPointer<QAction> defaultAction;
-
- QAction *menuAction;
- QAction *defaultMenuAction;
-
- void setOverrideMenuAction(QAction *);
- void _q_overrideMenuActionDestroyed();
-
- //firing of events
- void activateAction(QAction *, QAction::ActionEvent, bool self=true);
- void activateCausedStack(const QList<QPointer<QWidget> > &, QAction *, QAction::ActionEvent, bool);
-
- void _q_actionTriggered();
- void _q_actionHovered();
-
- bool hasMouseMoved(const QPoint &globalPos);
-
- void updateLayoutDirection();
-
- //menu fading/scrolling effects
- bool doChildEffects;
-
-#ifdef Q_WS_MAC
- //mac menu binding
- struct QMacMenuPrivate {
- QList<QMacMenuAction*> actionItems;
- OSMenuRef menu;
- QMacMenuPrivate();
- ~QMacMenuPrivate();
-
- bool merged(const QAction *action) const;
- void addAction(QAction *, QMacMenuAction* =0, QMenuPrivate *qmenu = 0);
- void addAction(QMacMenuAction *, QMacMenuAction* =0, QMenuPrivate *qmenu = 0);
- void syncAction(QMacMenuAction *);
- inline void syncAction(QAction *a) { syncAction(findAction(a)); }
- void removeAction(QMacMenuAction *);
- inline void removeAction(QAction *a) { removeAction(findAction(a)); }
- inline QMacMenuAction *findAction(QAction *a) {
- for(int i = 0; i < actionItems.size(); i++) {
- QMacMenuAction *act = actionItems[i];
- if(a == act->action)
- return act;
- }
- return 0;
- }
- } *mac_menu;
- OSMenuRef macMenu(OSMenuRef merge);
- void setMacMenuEnabled(bool enable = true);
- void syncSeparatorsCollapsible(bool collapsible);
- static QHash<OSMenuRef, OSMenuRef> mergeMenuHash;
- static QHash<OSMenuRef, QMenuMergeList*> mergeMenuItemsHash;
-#endif
-
- QPointer<QAction> actionAboutToTrigger;
-#ifdef QT3_SUPPORT
- bool emitHighlighted;
-#endif
-
-#if defined(Q_WS_WINCE) && !defined(QT_NO_MENUBAR)
- struct QWceMenuPrivate {
- QList<QWceMenuAction*> actionItems;
- HMENU menuHandle;
- QWceMenuPrivate();
- ~QWceMenuPrivate();
- void addAction(QAction *, QWceMenuAction* =0);
- void addAction(QWceMenuAction *, QWceMenuAction* =0);
- void syncAction(QWceMenuAction *);
- inline void syncAction(QAction *a) { syncAction(findAction(a)); }
- void removeAction(QWceMenuAction *);
- void rebuild();
- inline void removeAction(QAction *a) { removeAction(findAction(a)); }
- inline QWceMenuAction *findAction(QAction *a) {
- for(int i = 0; i < actionItems.size(); i++) {
- QWceMenuAction *act = actionItems[i];
- if(a == act->action)
- return act;
- }
- return 0;
- }
- } *wce_menu;
- HMENU wceMenu();
- QAction* wceCommands(uint command);
-#endif
-#if defined(Q_WS_S60)
- struct QSymbianMenuPrivate {
- QList<QSymbianMenuAction*> actionItems;
- QSymbianMenuPrivate();
- ~QSymbianMenuPrivate();
- void addAction(QAction *, QSymbianMenuAction* =0);
- void addAction(QSymbianMenuAction *, QSymbianMenuAction* =0);
- void syncAction(QSymbianMenuAction *);
- inline void syncAction(QAction *a) { syncAction(findAction(a)); }
- void removeAction(QSymbianMenuAction *);
- void rebuild(bool reCreate = false);
- inline void removeAction(QAction *a) { removeAction(findAction(a)); }
- inline QSymbianMenuAction *findAction(QAction *a) {
- for(int i = 0; i < actionItems.size(); i++) {
- QSymbianMenuAction *act = actionItems[i];
- if(a == act->action)
- return act;
- }
- return 0;
- }
- } *symbian_menu;
-#endif
- QPointer<QWidget> noReplayFor;
-};
-
-#endif // QT_NO_MENU
-
-QT_END_NAMESPACE
-
-#endif // QMENU_P_H
diff --git a/src/gui/widgets/qmenubar.h b/src/gui/widgets/qmenubar.h
deleted file mode 100644
index c22fceb8c2..0000000000
--- a/src/gui/widgets/qmenubar.h
+++ /dev/null
@@ -1,367 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMENUBAR_H
-#define QMENUBAR_H
-
-#include <QtGui/qmenu.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_MENUBAR
-
-class QMenuBarPrivate;
-class QStyleOptionMenuItem;
-class QWindowsStyle;
-#ifdef QT3_SUPPORT
-class QMenuItem;
-#endif
-
-class Q_GUI_EXPORT QMenuBar : public QWidget
-{
- Q_OBJECT
-
- Q_PROPERTY(bool defaultUp READ isDefaultUp WRITE setDefaultUp)
- Q_PROPERTY(bool nativeMenuBar READ isNativeMenuBar WRITE setNativeMenuBar)
-
-public:
- explicit QMenuBar(QWidget *parent = 0);
- ~QMenuBar();
-
-#ifdef Q_NO_USING_KEYWORD
- void addAction(QAction *action) { QWidget::addAction(action); }
-#else
- using QWidget::addAction;
-#endif
- QAction *addAction(const QString &text);
- QAction *addAction(const QString &text, const QObject *receiver, const char* member);
-
- QAction *addMenu(QMenu *menu);
- QMenu *addMenu(const QString &title);
- QMenu *addMenu(const QIcon &icon, const QString &title);
-
-
- QAction *addSeparator();
- QAction *insertSeparator(QAction *before);
-
- QAction *insertMenu(QAction *before, QMenu *menu);
-
- void clear();
-
- QAction *activeAction() const;
- void setActiveAction(QAction *action);
-
- void setDefaultUp(bool);
- bool isDefaultUp() const;
-
- QSize sizeHint() const;
- QSize minimumSizeHint() const;
- int heightForWidth(int) const;
-
- QRect actionGeometry(QAction *) const;
- QAction *actionAt(const QPoint &) const;
-
- void setCornerWidget(QWidget *w, Qt::Corner corner = Qt::TopRightCorner);
- QWidget *cornerWidget(Qt::Corner corner = Qt::TopRightCorner) const;
-
-#ifdef Q_WS_MAC
- OSMenuRef macMenu();
- static bool macUpdateMenuBar();
-#endif
-
-#ifdef Q_WS_WINCE
- void setDefaultAction(QAction *);
- QAction *defaultAction() const;
-
- static void wceCommands(uint command);
- static void wceRefresh();
-#endif
-
- bool isNativeMenuBar() const;
- void setNativeMenuBar(bool nativeMenuBar);
-
-public Q_SLOTS:
- virtual void setVisible(bool visible);
-
-Q_SIGNALS:
- void triggered(QAction *action);
- void hovered(QAction *action);
-
-protected:
- void changeEvent(QEvent *);
- void keyPressEvent(QKeyEvent *);
- void mouseReleaseEvent(QMouseEvent *);
- void mousePressEvent(QMouseEvent *);
- void mouseMoveEvent(QMouseEvent *);
- void leaveEvent(QEvent *);
- void paintEvent(QPaintEvent *);
- void resizeEvent(QResizeEvent *);
- void actionEvent(QActionEvent *);
- void focusOutEvent(QFocusEvent *);
- void focusInEvent(QFocusEvent *);
- void timerEvent(QTimerEvent *);
- bool eventFilter(QObject *, QEvent *);
- bool event(QEvent *);
- void initStyleOption(QStyleOptionMenuItem *option, const QAction *action) const;
-
-#ifdef QT3_SUPPORT
-public:
- QT3_SUPPORT_CONSTRUCTOR QMenuBar(QWidget *parent, const char *name);
- inline QT3_SUPPORT uint count() const { return actions().count(); }
- inline QT3_SUPPORT int insertItem(const QString &text, const QObject *receiver, const char* member,
- const QKeySequence& shortcut = 0, int id = -1, int index = -1) {
- return insertAny(0, &text, receiver, member, &shortcut, 0, id, index);
- }
- inline QT3_SUPPORT int insertItem(const QIcon& icon, const QString &text,
- const QObject *receiver, const char* member,
- const QKeySequence& shortcut = 0, int id = -1, int index = -1) {
- return insertAny(&icon, &text, receiver, member, &shortcut, 0, id, index);
- }
- inline QT3_SUPPORT int insertItem(const QPixmap &pixmap, const QObject *receiver, const char* member,
- const QKeySequence& shortcut = 0, int id = -1, int index = -1) {
- QIcon icon(pixmap);
- return insertAny(&icon, 0, receiver, member, &shortcut, 0, id, index);
- }
- inline QT3_SUPPORT int insertItem(const QString &text, int id=-1, int index=-1) {
- return insertAny(0, &text, 0, 0, 0, 0, id, index);
- }
- inline QT3_SUPPORT int insertItem(const QIcon& icon, const QString &text, int id=-1, int index=-1) {
- return insertAny(&icon, &text, 0, 0, 0, 0, id, index);
- }
- inline QT3_SUPPORT int insertItem(const QString &text, QMenu *popup, int id=-1, int index=-1) {
- return insertAny(0, &text, 0, 0, 0, popup, id, index);
- }
- inline QT3_SUPPORT int insertItem(const QIcon& icon, const QString &text, QMenu *popup, int id=-1, int index=-1) {
- return insertAny(&icon, &text, 0, 0, 0, popup, id, index);
- }
- inline QT3_SUPPORT int insertItem(const QPixmap &pixmap, int id=-1, int index=-1) {
- QIcon icon(pixmap);
- return insertAny(&icon, 0, 0, 0, 0, 0, id, index);
- }
- inline QT3_SUPPORT int insertItem(const QPixmap &pixmap, QMenu *popup, int id=-1, int index=-1) {
- QIcon icon(pixmap);
- return insertAny(&icon, 0, 0, 0, 0, popup, id, index);
- }
- QT3_SUPPORT int insertSeparator(int index=-1);
- inline QT3_SUPPORT void removeItem(int id) {
- if(QAction *act = findActionForId(id))
- removeAction(act); }
- inline QT3_SUPPORT void removeItemAt(int index) {
- if(QAction *act = actions().value(index))
- removeAction(act); }
-#ifndef QT_NO_SHORTCUT
- inline QT3_SUPPORT QKeySequence accel(int id) const {
- if(QAction *act = findActionForId(id))
- return act->shortcut();
- return QKeySequence(); }
- inline QT3_SUPPORT void setAccel(const QKeySequence& key, int id) {
- if(QAction *act = findActionForId(id))
- act->setShortcut(key);
- }
-#endif
- inline QT3_SUPPORT QIcon iconSet(int id) const {
- if(QAction *act = findActionForId(id))
- return act->icon();
- return QIcon(); }
- inline QT3_SUPPORT QString text(int id) const {
- if(QAction *act = findActionForId(id))
- return act->text();
- return QString(); }
- inline QT3_SUPPORT QPixmap pixmap(int id) const {
- if(QAction *act = findActionForId(id))
- return act->icon().pixmap(QSize(22,22));
- return QPixmap(); }
- inline QT3_SUPPORT void setWhatsThis(int id, const QString &w) {
- if(QAction *act = findActionForId(id))
- act->setWhatsThis(w); }
- inline QT3_SUPPORT QString whatsThis(int id) const {
- if(QAction *act = findActionForId(id))
- return act->whatsThis();
- return QString(); }
-
- inline QT3_SUPPORT void changeItem(int id, const QString &text) {
- if(QAction *act = findActionForId(id))
- act->setText(text); }
- inline QT3_SUPPORT void changeItem(int id, const QPixmap &pixmap) {
- if(QAction *act = findActionForId(id))
- act->setIcon(QIcon(pixmap)); }
- inline QT3_SUPPORT void changeItem(int id, const QIcon &icon, const QString &text) {
- if(QAction *act = findActionForId(id)) {
- act->setIcon(icon);
- act->setText(text);
- }
- }
- inline QT3_SUPPORT bool isItemActive(int id) const { return findActionForId(id) == activeAction(); }
- inline QT3_SUPPORT bool isItemEnabled(int id) const {
- if(QAction *act = findActionForId(id))
- return act->isEnabled();
- return false; }
- inline QT3_SUPPORT void setItemEnabled(int id, bool enable) {
- if(QAction *act = findActionForId(id))
- act->setEnabled(enable); }
- inline QT3_SUPPORT bool isItemChecked(int id) const {
- if(QAction *act = findActionForId(id))
- return act->isChecked();
- return false; }
- inline QT3_SUPPORT void setItemChecked(int id, bool check) {
- if(QAction *act = findActionForId(id))
- act->setChecked(check); }
- inline QT3_SUPPORT bool isItemVisible(int id) const {
- if(QAction *act = findActionForId(id))
- return act->isVisible();
- return false; }
- inline QT3_SUPPORT void setItemVisible(int id, bool visible) {
- if(QAction *act = findActionForId(id))
- act->setVisible(visible); }
- inline QT3_SUPPORT int indexOf(int id) const { return actions().indexOf(findActionForId(id)); }
- inline QT3_SUPPORT int idAt(int index) const {
- return index >= 0 && index < actions().size()
- ? findIdForAction(actions().at(index))
- : -1;
- }
- inline QT3_SUPPORT void activateItemAt(int index) {
- if(QAction *ret = actions().value(index))
- setActiveAction(ret);
- }
- inline QT3_SUPPORT bool connectItem(int id, const QObject *receiver, const char* member) {
- if(QAction *act = findActionForId(id)) {
- QObject::connect(act, SIGNAL(triggered()), receiver, member);
- return true;
- }
- return false;
- }
- inline QT3_SUPPORT bool disconnectItem(int id,const QObject *receiver, const char* member) {
- if(QAction *act = findActionForId(id)) {
- QObject::disconnect(act, SIGNAL(triggered()), receiver, member);
- return true;
- }
- return false;
- }
- inline QT3_SUPPORT QMenuItem *findItem(int id) const {
- return (QMenuItem*)findActionForId(id);
- }
- QT3_SUPPORT bool setItemParameter(int id, int param);
- QT3_SUPPORT int itemParameter(int id) const;
-
- //frame
- QT3_SUPPORT int frameWidth() const;
-
- QT3_SUPPORT void setFrameRect(QRect) {}
- QT3_SUPPORT QRect frameRect() const { return QRect(); }
- enum DummyFrame { Box, Sunken, Plain, Raised, MShadow, NoFrame, Panel, StyledPanel,
- HLine, VLine, GroupBoxPanel, WinPanel, ToolBarPanel, MenuBarPanel,
- PopupPanel, LineEditPanel, TabWidgetPanel, MShape };
- QT3_SUPPORT void setFrameShadow(DummyFrame) {}
- QT3_SUPPORT DummyFrame frameShadow() const { return Plain; }
- QT3_SUPPORT void setFrameShape(DummyFrame) {}
- QT3_SUPPORT DummyFrame frameShape() const { return NoFrame; }
- QT3_SUPPORT void setFrameStyle(int) {}
- QT3_SUPPORT int frameStyle() const { return 0; }
- QT3_SUPPORT void setLineWidth(int) {}
- QT3_SUPPORT int lineWidth() const { return 0; }
- QT3_SUPPORT void setMargin(int margin) { setContentsMargins(margin, margin, margin, margin); }
- QT3_SUPPORT int margin() const
- { int margin; int dummy; getContentsMargins(&margin, &dummy, &dummy, &dummy); return margin; }
- QT3_SUPPORT void setMidLineWidth(int) {}
- QT3_SUPPORT int midLineWidth() const { return 0; }
-
- //menubar
- enum Separator { Never=0, InWindowsStyle=1 };
- inline QT3_SUPPORT Separator separator() const { return InWindowsStyle; }
- inline QT3_SUPPORT void setSeparator(Separator) { }
-
- QT3_SUPPORT void setAutoGeometry(bool);
- QT3_SUPPORT bool autoGeometry() const;
-
-Q_SIGNALS:
- QT_MOC_COMPAT void activated(int itemId);
- QT_MOC_COMPAT void highlighted(int itemId);
-
-protected:
- inline QT3_SUPPORT QRect itemRect(int index) {
- if(QAction *act = actions().value(index))
- return actionGeometry(act);
- return QRect();
- }
- inline QT3_SUPPORT int itemAtPos(const QPoint &p) {
- return findIdForAction(actionAt(p));
- }
-private:
- QAction *findActionForId(int id) const;
- int insertAny(const QIcon *icon, const QString *text, const QObject *receiver, const char *member,
- const QKeySequence *shorcut, const QMenu *popup, int id, int index);
- int findIdForAction(QAction*) const;
-#endif
-
-private:
- Q_DECLARE_PRIVATE(QMenuBar)
- Q_DISABLE_COPY(QMenuBar)
- Q_PRIVATE_SLOT(d_func(), void _q_actionTriggered())
- Q_PRIVATE_SLOT(d_func(), void _q_actionHovered())
- Q_PRIVATE_SLOT(d_func(), void _q_internalShortcutActivated(int))
- Q_PRIVATE_SLOT(d_func(), void _q_updateLayout())
-
-#ifdef Q_WS_WINCE
- Q_PRIVATE_SLOT(d_func(), void _q_updateDefaultAction())
-#endif
-
- friend class QMenu;
- friend class QMenuPrivate;
- friend class QWindowsStyle;
-
-#ifdef Q_WS_MAC
- friend class QApplicationPrivate;
- friend class QWidgetPrivate;
- friend bool qt_mac_activate_action(MenuRef, uint, QAction::ActionEvent, bool);
-#endif
-};
-
-#endif // QT_NO_MENUBAR
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QMENUBAR_H
diff --git a/src/gui/widgets/qmenubar_p.h b/src/gui/widgets/qmenubar_p.h
deleted file mode 100644
index 5afe71376d..0000000000
--- a/src/gui/widgets/qmenubar_p.h
+++ /dev/null
@@ -1,283 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMENUBAR_P_H
-#define QMENUBAR_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.
-//
-
-#ifndef QMAC_Q3MENUBAR_CPP_FILE
-#include "QtGui/qstyleoption.h"
-#include <private/qmenu_p.h> // Mac needs what in this file!
-
-#ifdef Q_WS_WINCE
-#include "qguifunctions_wince.h"
-#endif
-
-#ifndef QT_NO_MENUBAR
-#ifdef Q_WS_S60
-class CCoeControl;
-class CEikMenuBar;
-#endif
-#endif
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_MENUBAR
-class QMenuBarExtension;
-class QMenuBarPrivate : public QWidgetPrivate
-{
- Q_DECLARE_PUBLIC(QMenuBar)
-public:
- QMenuBarPrivate() : itemsDirty(0), currentAction(0), mouseDown(0),
- closePopupMode(0), defaultPopDown(1), popupState(0), keyboardState(0), altPressed(0),
- nativeMenuBar(-1), doChildEffects(false)
-#ifdef QT3_SUPPORT
- , doAutoResize(false)
-#endif
-#ifdef Q_WS_MAC
- , mac_menubar(0)
-#endif
-
-#ifdef Q_WS_WINCE
- , wce_menubar(0), wceClassicMenu(false)
-#endif
-#ifdef Q_WS_S60
- , symbian_menubar(0)
-#endif
-
- { }
- ~QMenuBarPrivate()
- {
-#ifdef Q_WS_MAC
- delete mac_menubar;
-#endif
-#ifdef Q_WS_WINCE
- delete wce_menubar;
-#endif
-#ifdef Q_WS_S60
- delete symbian_menubar;
-#endif
- }
-
- void init();
- QAction *getNextAction(const int start, const int increment) const;
-
- //item calculations
- uint itemsDirty : 1;
-
- QVector<int> shortcutIndexMap;
- mutable QVector<QRect> actionRects;
- void calcActionRects(int max_width, int start) const;
- QRect actionRect(QAction *) const;
- void updateGeometries();
-
- //selection
- QPointer<QAction>currentAction;
- uint mouseDown : 1, closePopupMode : 1, defaultPopDown;
- QAction *actionAt(QPoint p) const;
- void setCurrentAction(QAction *, bool =false, bool =false);
- void popupAction(QAction *, bool);
-
- //active popup state
- uint popupState : 1;
- QPointer<QMenu> activeMenu;
-
- //keyboard mode for keyboard navigation
- void focusFirstAction();
- void setKeyboardMode(bool);
- uint keyboardState : 1, altPressed : 1;
- QPointer<QWidget> keyboardFocusWidget;
-
-
- int nativeMenuBar : 3; // Only has values -1, 0, and 1
- //firing of events
- void activateAction(QAction *, QAction::ActionEvent);
-
- void _q_actionTriggered();
- void _q_actionHovered();
- void _q_internalShortcutActivated(int);
- void _q_updateLayout();
-
-#ifdef Q_WS_WINCE
- void _q_updateDefaultAction();
-#endif
-
- //extra widgets in the menubar
- QPointer<QWidget> leftWidget, rightWidget;
- QMenuBarExtension *extension;
- bool isVisible(QAction *action);
-
- //menu fading/scrolling effects
- bool doChildEffects;
-
- QRect menuRect(bool) const;
-
- // reparenting
- void handleReparent();
- QWidget *oldParent;
- QWidget *oldWindow;
-
- QList<QAction*> hiddenActions;
- //default action
- QPointer<QAction> defaultAction;
-
- QBasicTimer autoReleaseTimer;
-#ifdef QT3_SUPPORT
- bool doAutoResize;
-#endif
-#ifdef Q_WS_MAC
- //mac menubar binding
- struct QMacMenuBarPrivate {
- QList<QMacMenuAction*> actionItems;
- OSMenuRef menu, apple_menu;
- QMacMenuBarPrivate();
- ~QMacMenuBarPrivate();
-
- void addAction(QAction *, QMacMenuAction* =0);
- void addAction(QMacMenuAction *, QMacMenuAction* =0);
- void syncAction(QMacMenuAction *);
- inline void syncAction(QAction *a) { syncAction(findAction(a)); }
- void removeAction(QMacMenuAction *);
- inline void removeAction(QAction *a) { removeAction(findAction(a)); }
- inline QMacMenuAction *findAction(QAction *a) {
- for(int i = 0; i < actionItems.size(); i++) {
- QMacMenuAction *act = actionItems[i];
- if(a == act->action)
- return act;
- }
- return 0;
- }
- } *mac_menubar;
- static bool macUpdateMenuBarImmediatly();
- bool macWidgetHasNativeMenubar(QWidget *widget);
- void macCreateMenuBar(QWidget *);
- void macDestroyMenuBar();
- OSMenuRef macMenu();
-#endif
-#ifdef Q_WS_WINCE
- void wceCreateMenuBar(QWidget *);
- void wceDestroyMenuBar();
- struct QWceMenuBarPrivate {
- QList<QWceMenuAction*> actionItems;
- QList<QWceMenuAction*> actionItemsLeftButton;
- QList<QList<QWceMenuAction*>> actionItemsClassic;
- HMENU menuHandle;
- HMENU leftButtonMenuHandle;
- HWND menubarHandle;
- HWND parentWindowHandle;
- bool leftButtonIsMenu;
- QPointer<QAction> leftButtonAction;
- QMenuBarPrivate *d;
- int leftButtonCommand;
-
- QWceMenuBarPrivate(QMenuBarPrivate *menubar);
- ~QWceMenuBarPrivate();
- void addAction(QAction *, QWceMenuAction* =0);
- void addAction(QWceMenuAction *, QWceMenuAction* =0);
- void syncAction(QWceMenuAction *);
- inline void syncAction(QAction *a) { syncAction(findAction(a)); }
- void removeAction(QWceMenuAction *);
- void rebuild();
- inline void removeAction(QAction *a) { removeAction(findAction(a)); }
- inline QWceMenuAction *findAction(QAction *a) {
- for(int i = 0; i < actionItems.size(); i++) {
- QWceMenuAction *act = actionItems[i];
- if(a == act->action)
- return act;
- }
- return 0;
- }
- } *wce_menubar;
- bool wceClassicMenu;
- void wceCommands(uint command);
- void wceRefresh();
- bool wceEmitSignals(QList<QWceMenuAction*> actions, uint command);
-#endif
-#ifdef Q_WS_S60
- void symbianCreateMenuBar(QWidget *);
- void symbianDestroyMenuBar();
- void reparentMenuBar(QWidget *oldParent, QWidget *newParent);
- struct QSymbianMenuBarPrivate {
- QList<QSymbianMenuAction*> actionItems;
- QMenuBarPrivate *d;
- QSymbianMenuBarPrivate(QMenuBarPrivate *menubar);
- ~QSymbianMenuBarPrivate();
- void addAction(QAction *, QSymbianMenuAction* =0);
- void addAction(QSymbianMenuAction *, QSymbianMenuAction* =0);
- void syncAction(QSymbianMenuAction *);
- inline void syncAction(QAction *a) { syncAction(findAction(a)); }
- void removeAction(QSymbianMenuAction *);
- void rebuild();
- inline void removeAction(QAction *a) { removeAction(findAction(a)); }
- inline QSymbianMenuAction *findAction(QAction *a) {
- for(int i = 0; i < actionItems.size(); i++) {
- QSymbianMenuAction *act = actionItems[i];
- if(a == act->action)
- return act;
- }
- return 0;
- }
- void insertNativeMenuItems(const QList<QAction*> &actions);
-
- } *symbian_menubar;
- static int symbianCommands(int command);
-#endif
-#ifdef QT_SOFTKEYS_ENABLED
- QAction *menuBarAction;
-#endif
-};
-#endif
-
-#endif // QT_NO_MENUBAR
-
-QT_END_NAMESPACE
-
-#endif // QMENUBAR_P_H
diff --git a/src/gui/widgets/qmenudata.h b/src/gui/widgets/qmenudata.h
deleted file mode 100644
index b303f41394..0000000000
--- a/src/gui/widgets/qmenudata.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMENUDATA_H
-#define QMENUDATA_H
-
-#include <QtCore/qglobal.h>
-
-#ifdef QT3_SUPPORT
-#include <QtGui/qaction.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class Q_GUI_EXPORT QMenuItem : public QAction
-{
- Q_OBJECT
-
-public:
- QMenuItem();
-
- QT3_SUPPORT int id() const;
- QT3_SUPPORT int signalValue() const;
-private:
- friend class QMenu;
- friend class QMenuBar;
- void setId(int);
- void setSignalValue(int);
-
- Q_DISABLE_COPY(QMenuItem)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
-
-#endif // QMENUDATA_H
diff --git a/src/gui/widgets/qplaintextedit.h b/src/gui/widgets/qplaintextedit.h
deleted file mode 100644
index 737bcb80b0..0000000000
--- a/src/gui/widgets/qplaintextedit.h
+++ /dev/null
@@ -1,329 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPLAINTEXTEDIT_H
-#define QPLAINTEXTEDIT_H
-
-#include <QtGui/qtextedit.h>
-
-#include <QtGui/qabstractscrollarea.h>
-#include <QtGui/qtextdocument.h>
-#include <QtGui/qtextoption.h>
-#include <QtGui/qtextcursor.h>
-#include <QtGui/qtextformat.h>
-#include <QtGui/qabstracttextdocumentlayout.h>
-
-#ifndef QT_NO_TEXTEDIT
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QStyleSheet;
-class QTextDocument;
-class QMenu;
-class QPlainTextEditPrivate;
-class QMimeData;
-
-
-class Q_GUI_EXPORT QPlainTextEdit : public QAbstractScrollArea
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QPlainTextEdit)
- Q_ENUMS(LineWrapMode)
- Q_PROPERTY(bool tabChangesFocus READ tabChangesFocus WRITE setTabChangesFocus)
- Q_PROPERTY(QString documentTitle READ documentTitle WRITE setDocumentTitle)
- Q_PROPERTY(bool undoRedoEnabled READ isUndoRedoEnabled WRITE setUndoRedoEnabled)
- Q_PROPERTY(LineWrapMode lineWrapMode READ lineWrapMode WRITE setLineWrapMode)
- QDOC_PROPERTY(QTextOption::WrapMode wordWrapMode READ wordWrapMode WRITE setWordWrapMode)
- Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
- Q_PROPERTY(QString plainText READ toPlainText WRITE setPlainText NOTIFY textChanged USER true)
- Q_PROPERTY(bool overwriteMode READ overwriteMode WRITE setOverwriteMode)
- Q_PROPERTY(int tabStopWidth READ tabStopWidth WRITE setTabStopWidth)
- Q_PROPERTY(int cursorWidth READ cursorWidth WRITE setCursorWidth)
- Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
- Q_PROPERTY(int blockCount READ blockCount)
- Q_PROPERTY(int maximumBlockCount READ maximumBlockCount WRITE setMaximumBlockCount)
- Q_PROPERTY(bool backgroundVisible READ backgroundVisible WRITE setBackgroundVisible)
- Q_PROPERTY(bool centerOnScroll READ centerOnScroll WRITE setCenterOnScroll)
-public:
- enum LineWrapMode {
- NoWrap,
- WidgetWidth
- };
-
- explicit QPlainTextEdit(QWidget *parent = 0);
- explicit QPlainTextEdit(const QString &text, QWidget *parent = 0);
- virtual ~QPlainTextEdit();
-
- void setDocument(QTextDocument *document);
- QTextDocument *document() const;
-
- void setTextCursor(const QTextCursor &cursor);
- QTextCursor textCursor() const;
-
- bool isReadOnly() const;
- void setReadOnly(bool ro);
-
- void setTextInteractionFlags(Qt::TextInteractionFlags flags);
- Qt::TextInteractionFlags textInteractionFlags() const;
-
- void mergeCurrentCharFormat(const QTextCharFormat &modifier);
- void setCurrentCharFormat(const QTextCharFormat &format);
- QTextCharFormat currentCharFormat() const;
-
- bool tabChangesFocus() const;
- void setTabChangesFocus(bool b);
-
- inline void setDocumentTitle(const QString &title)
- { document()->setMetaInformation(QTextDocument::DocumentTitle, title); }
- inline QString documentTitle() const
- { return document()->metaInformation(QTextDocument::DocumentTitle); }
-
- inline bool isUndoRedoEnabled() const
- { return document()->isUndoRedoEnabled(); }
- inline void setUndoRedoEnabled(bool enable)
- { document()->setUndoRedoEnabled(enable); }
-
- inline void setMaximumBlockCount(int maximum)
- { document()->setMaximumBlockCount(maximum); }
- inline int maximumBlockCount() const
- { return document()->maximumBlockCount(); }
-
-
- LineWrapMode lineWrapMode() const;
- void setLineWrapMode(LineWrapMode mode);
-
- QTextOption::WrapMode wordWrapMode() const;
- void setWordWrapMode(QTextOption::WrapMode policy);
-
- void setBackgroundVisible(bool visible);
- bool backgroundVisible() const;
-
- void setCenterOnScroll(bool enabled);
- bool centerOnScroll() const;
-
- bool find(const QString &exp, QTextDocument::FindFlags options = 0);
-
- inline QString toPlainText() const
- { return document()->toPlainText(); }
-
- void ensureCursorVisible();
-
- virtual QVariant loadResource(int type, const QUrl &name);
-#ifndef QT_NO_CONTEXTMENU
- QMenu *createStandardContextMenu();
-#endif
-
- QTextCursor cursorForPosition(const QPoint &pos) const;
- QRect cursorRect(const QTextCursor &cursor) const;
- QRect cursorRect() const;
-
- QString anchorAt(const QPoint &pos) const;
-
- bool overwriteMode() const;
- void setOverwriteMode(bool overwrite);
-
- int tabStopWidth() const;
- void setTabStopWidth(int width);
-
- int cursorWidth() const;
- void setCursorWidth(int width);
-
- void setExtraSelections(const QList<QTextEdit::ExtraSelection> &selections);
- QList<QTextEdit::ExtraSelection> extraSelections() const;
-
- void moveCursor(QTextCursor::MoveOperation operation, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor);
-
- bool canPaste() const;
-
-#ifndef QT_NO_PRINTER
- void print(QPrinter *printer) const;
-#endif
-
- int blockCount() const;
-
-public Q_SLOTS:
-
- void setPlainText(const QString &text);
-
-#ifndef QT_NO_CLIPBOARD
- void cut();
- void copy();
- void paste();
-#endif
-
- void undo();
- void redo();
-
- void clear();
- void selectAll();
-
- void insertPlainText(const QString &text);
-
- void appendPlainText(const QString &text);
- void appendHtml(const QString &html);
-
- void centerCursor();
-
-Q_SIGNALS:
- void textChanged();
- void undoAvailable(bool b);
- void redoAvailable(bool b);
- void copyAvailable(bool b);
- void selectionChanged();
- void cursorPositionChanged();
-
- void updateRequest(const QRect &rect, int dy);
- void blockCountChanged(int newBlockCount);
- void modificationChanged(bool);
-
-protected:
- virtual bool event(QEvent *e);
- virtual void timerEvent(QTimerEvent *e);
- virtual void keyPressEvent(QKeyEvent *e);
- virtual void keyReleaseEvent(QKeyEvent *e);
- virtual void resizeEvent(QResizeEvent *e);
- virtual void paintEvent(QPaintEvent *e);
- virtual void mousePressEvent(QMouseEvent *e);
- virtual void mouseMoveEvent(QMouseEvent *e);
- virtual void mouseReleaseEvent(QMouseEvent *e);
- virtual void mouseDoubleClickEvent(QMouseEvent *e);
- virtual bool focusNextPrevChild(bool next);
-#ifndef QT_NO_CONTEXTMENU
- virtual void contextMenuEvent(QContextMenuEvent *e);
-#endif
-#ifndef QT_NO_DRAGANDDROP
- virtual void dragEnterEvent(QDragEnterEvent *e);
- virtual void dragLeaveEvent(QDragLeaveEvent *e);
- virtual void dragMoveEvent(QDragMoveEvent *e);
- virtual void dropEvent(QDropEvent *e);
-#endif
- virtual void focusInEvent(QFocusEvent *e);
- virtual void focusOutEvent(QFocusEvent *e);
- virtual void showEvent(QShowEvent *);
- virtual void changeEvent(QEvent *e);
-#ifndef QT_NO_WHEELEVENT
- virtual void wheelEvent(QWheelEvent *e);
-#endif
-
- virtual QMimeData *createMimeDataFromSelection() const;
- virtual bool canInsertFromMimeData(const QMimeData *source) const;
- virtual void insertFromMimeData(const QMimeData *source);
-
- virtual void inputMethodEvent(QInputMethodEvent *);
- QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
-
- QPlainTextEdit(QPlainTextEditPrivate &dd, QWidget *parent);
-
- virtual void scrollContentsBy(int dx, int dy);
-
- QTextBlock firstVisibleBlock() const;
- QPointF contentOffset() const;
- QRectF blockBoundingRect(const QTextBlock &block) const;
- QRectF blockBoundingGeometry(const QTextBlock &block) const;
- QAbstractTextDocumentLayout::PaintContext getPaintContext() const;
-
-
-private:
- Q_DISABLE_COPY(QPlainTextEdit)
- Q_PRIVATE_SLOT(d_func(), void _q_repaintContents(const QRectF &r))
- Q_PRIVATE_SLOT(d_func(), void _q_adjustScrollbars())
- Q_PRIVATE_SLOT(d_func(), void _q_verticalScrollbarActionTriggered(int))
- Q_PRIVATE_SLOT(d_func(), void _q_cursorPositionChanged())
-
- friend class QPlainTextEditControl;
-};
-
-
-class QPlainTextDocumentLayoutPrivate;
-class Q_GUI_EXPORT QPlainTextDocumentLayout : public QAbstractTextDocumentLayout
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QPlainTextDocumentLayout)
- Q_PROPERTY(int cursorWidth READ cursorWidth WRITE setCursorWidth)
-
-public:
- QPlainTextDocumentLayout(QTextDocument *document);
- ~QPlainTextDocumentLayout();
-
- void draw(QPainter *, const PaintContext &);
- int hitTest(const QPointF &, Qt::HitTestAccuracy ) const;
-
- int pageCount() const;
- QSizeF documentSize() const;
-
- QRectF frameBoundingRect(QTextFrame *) const;
- QRectF blockBoundingRect(const QTextBlock &block) const;
-
- void ensureBlockLayout(const QTextBlock &block) const;
-
- void setCursorWidth(int width);
- int cursorWidth() const;
-
- void requestUpdate();
-
-protected:
- void documentChanged(int from, int /*charsRemoved*/, int charsAdded);
-
-
-private:
- void setTextWidth(qreal newWidth);
- qreal textWidth() const;
- void layoutBlock(const QTextBlock &block);
- qreal blockWidth(const QTextBlock &block);
-
- QPlainTextDocumentLayoutPrivate *priv() const;
-
- friend class QPlainTextEdit;
- friend class QPlainTextEditPrivate;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-
-#endif // QT_NO_TEXTEDIT
-
-#endif // QPLAINTEXTEDIT_H
diff --git a/src/gui/widgets/qplaintextedit_p.h b/src/gui/widgets/qplaintextedit_p.h
deleted file mode 100644
index 7988ad8772..0000000000
--- a/src/gui/widgets/qplaintextedit_p.h
+++ /dev/null
@@ -1,187 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPLAINTEXTEDIT_P_H
-#define QPLAINTEXTEDIT_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "private/qabstractscrollarea_p.h"
-#include "QtGui/qtextdocumentfragment.h"
-#include "QtGui/qscrollbar.h"
-#include "QtGui/qtextcursor.h"
-#include "QtGui/qtextformat.h"
-#include "QtGui/qmenu.h"
-#include "QtGui/qabstracttextdocumentlayout.h"
-#include "QtCore/qbasictimer.h"
-#include "private/qtextcontrol_p.h"
-#include "qplaintextedit.h"
-
-#ifndef QT_NO_TEXTEDIT
-
-QT_BEGIN_NAMESPACE
-
-class QMimeData;
-
-class QPlainTextEdit;
-class ExtraArea;
-
-class QPlainTextEditControl : public QTextControl
-{
- Q_OBJECT
-public:
- QPlainTextEditControl(QPlainTextEdit *parent);
-
-
- QMimeData *createMimeDataFromSelection() const;
- bool canInsertFromMimeData(const QMimeData *source) const;
- void insertFromMimeData(const QMimeData *source);
- int hitTest(const QPointF &point, Qt::HitTestAccuracy = Qt::FuzzyHit) const;
- QRectF blockBoundingRect(const QTextBlock &block) const;
- inline QRectF cursorRect(const QTextCursor &cursor) const {
- QRectF r = QTextControl::cursorRect(cursor);
- r.setLeft(qMax(r.left(), (qreal) 0.));
- return r;
- }
- inline QRectF cursorRect() { return cursorRect(textCursor()); }
- void ensureCursorVisible() {
- textEdit->ensureCursorVisible();
- emit microFocusChanged();
- }
-
-
- QPlainTextEdit *textEdit;
- int topBlock;
- QTextBlock firstVisibleBlock() const;
-
- QVariant loadResource(int type, const QUrl &name) {
- return textEdit->loadResource(type, name);
- }
-
-};
-
-
-class QPlainTextEditPrivate : public QAbstractScrollAreaPrivate
-{
- Q_DECLARE_PUBLIC(QPlainTextEdit)
-public:
- QPlainTextEditPrivate();
-
- void init(const QString &txt = QString());
- void _q_repaintContents(const QRectF &contentsRect);
-
- inline QPoint mapToContents(const QPoint &point) const
- { return QPoint(point.x() + horizontalOffset(), point.y() + verticalOffset()); }
-
- void _q_adjustScrollbars();
- void _q_verticalScrollbarActionTriggered(int action);
- void ensureViewportLayouted();
- void relayoutDocument();
-
- void pageUpDown(QTextCursor::MoveOperation op, QTextCursor::MoveMode moveMode, bool moveCursor = true);
-
- inline int horizontalOffset() const
- { return (q_func()->isRightToLeft() ? (hbar->maximum() - hbar->value()) : hbar->value()); }
- int verticalOffset(int topBlock, int topLine) const;
- int verticalOffset() const;
-
- inline void sendControlEvent(QEvent *e)
- { control->processEvent(e, QPointF(horizontalOffset(), verticalOffset()), viewport); }
-
- void updateDefaultTextOption();
-
- QPlainTextEditControl *control;
-
- bool tabChangesFocus;
-
- QBasicTimer autoScrollTimer;
- QPoint autoScrollDragPos;
-
- QPlainTextEdit::LineWrapMode lineWrap;
- QTextOption::WrapMode wordWrap;
-
- uint showCursorOnInitialShow : 1;
- uint backgroundVisible : 1;
- uint centerOnScroll : 1;
- uint inDrag : 1;
- uint clickCausedFocus : 1;
-
- int topLine;
-
- void setTopLine(int visualTopLine, int dx = 0);
- void setTopBlock(int newTopBlock, int newTopLine, int dx = 0);
-
- void ensureVisible(int position, bool center, bool forceCenter = false);
- void ensureCursorVisible(bool center = false);
- void updateViewport();
-
- QPointer<QPlainTextDocumentLayout> documentLayoutPtr;
-
- void append(const QString &text, Qt::TextFormat format = Qt::AutoText);
-
- qreal pageUpDownLastCursorY;
- bool pageUpDownLastCursorYIsValid;
-
-
-#ifdef QT_KEYPAD_NAVIGATION
- QBasicTimer deleteAllTimer;
-#endif
-
- void _q_cursorPositionChanged();
- void _q_modificationChanged(bool);
-
- int originalOffsetY;
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_TEXTEDIT
-
-#endif // QPLAINTEXTEDIT_P_H
diff --git a/src/gui/widgets/qprintpreviewwidget.cpp b/src/gui/widgets/qprintpreviewwidget.cpp
deleted file mode 100644
index 9da3e47698..0000000000
--- a/src/gui/widgets/qprintpreviewwidget.cpp
+++ /dev/null
@@ -1,844 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qprintpreviewwidget.h"
-#include "private/qwidget_p.h"
-#include <private/qprinter_p.h>
-
-#include <QtCore/qmath.h>
-#include <QtGui/qboxlayout.h>
-#include <QtGui/qgraphicsitem.h>
-#include <QtGui/qgraphicsview.h>
-#include <QtGui/qscrollbar.h>
-#include <QtGui/qstyleoption.h>
-
-#ifndef QT_NO_PRINTPREVIEWWIDGET
-
-QT_BEGIN_NAMESPACE
-
-namespace {
-class PageItem : public QGraphicsItem
-{
-public:
- PageItem(int _pageNum, const QPicture* _pagePicture, QSize _paperSize, QRect _pageRect)
- : pageNum(_pageNum), pagePicture(_pagePicture),
- paperSize(_paperSize), pageRect(_pageRect)
- {
- qreal border = qMax(paperSize.height(), paperSize.width()) / 25;
- brect = QRectF(QPointF(-border, -border),
- QSizeF(paperSize)+QSizeF(2*border, 2*border));
- setCacheMode(DeviceCoordinateCache);
- }
-
- inline QRectF boundingRect() const
- { return brect; }
-
- inline int pageNumber() const
- { return pageNum; }
-
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget);
-
-private:
- int pageNum;
- const QPicture* pagePicture;
- QSize paperSize;
- QRect pageRect;
- QRectF brect;
-};
-
-void PageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
-{
- Q_UNUSED(widget);
-
-#if 0
- // Draw item bounding rect, for debugging
- painter->save();
- painter->setPen(QPen(Qt::red, 0));
- painter->setBrush(Qt::NoBrush);
- painter->drawRect(QRectF(-border()+1.0, -border()+1.0, boundingRect().width()-2, boundingRect().height()-2));
- painter->restore();
-#endif
-
- QRectF paperRect(0,0, paperSize.width(), paperSize.height());
-
- // Draw shadow
- painter->setClipRect(option->exposedRect);
- qreal shWidth = paperRect.width()/100;
- QRectF rshadow(paperRect.topRight() + QPointF(0, shWidth),
- paperRect.bottomRight() + QPointF(shWidth, 0));
- QLinearGradient rgrad(rshadow.topLeft(), rshadow.topRight());
- rgrad.setColorAt(0.0, QColor(0,0,0,255));
- rgrad.setColorAt(1.0, QColor(0,0,0,0));
- painter->fillRect(rshadow, QBrush(rgrad));
- QRectF bshadow(paperRect.bottomLeft() + QPointF(shWidth, 0),
- paperRect.bottomRight() + QPointF(0, shWidth));
- QLinearGradient bgrad(bshadow.topLeft(), bshadow.bottomLeft());
- bgrad.setColorAt(0.0, QColor(0,0,0,255));
- bgrad.setColorAt(1.0, QColor(0,0,0,0));
- painter->fillRect(bshadow, QBrush(bgrad));
- QRectF cshadow(paperRect.bottomRight(),
- paperRect.bottomRight() + QPointF(shWidth, shWidth));
- QRadialGradient cgrad(cshadow.topLeft(), shWidth, cshadow.topLeft());
- cgrad.setColorAt(0.0, QColor(0,0,0,255));
- cgrad.setColorAt(1.0, QColor(0,0,0,0));
- painter->fillRect(cshadow, QBrush(cgrad));
-
- painter->setClipRect(paperRect & option->exposedRect);
- painter->fillRect(paperRect, Qt::white);
- if (!pagePicture)
- return;
- painter->drawPicture(pageRect.topLeft(), *pagePicture);
-
- // Effect: make anything drawn in the margins look washed out.
- QPainterPath path;
- path.addRect(paperRect);
- path.addRect(pageRect);
- painter->setPen(QPen(Qt::NoPen));
- painter->setBrush(QColor(255, 255, 255, 180));
- painter->drawPath(path);
-
-#if 0
- // Draw frame around paper.
- painter->setPen(QPen(Qt::black, 0));
- painter->setBrush(Qt::NoBrush);
- painter->drawRect(paperRect);
-#endif
-
- // todo: drawtext "Page N" below paper
-}
-
-class GraphicsView : public QGraphicsView
-{
- Q_OBJECT
-public:
- GraphicsView(QWidget* parent = 0)
- : QGraphicsView(parent)
- {
-#ifdef Q_WS_MAC
- setFrameStyle(QFrame::NoFrame);
-#endif
- }
-signals:
- void resized();
-
-protected:
- void resizeEvent(QResizeEvent* e)
- {
- QGraphicsView::resizeEvent(e);
- emit resized();
- }
-
- void showEvent(QShowEvent* e)
- {
- QGraphicsView::showEvent(e);
- emit resized();
- }
-};
-
-} // anonymous namespace
-
-class QPrintPreviewWidgetPrivate : public QWidgetPrivate
-{
- Q_DECLARE_PUBLIC(QPrintPreviewWidget)
-public:
- QPrintPreviewWidgetPrivate()
- : scene(0), curPage(1),
- viewMode(QPrintPreviewWidget::SinglePageView),
- zoomMode(QPrintPreviewWidget::FitInView),
- zoomFactor(1), initialized(false), fitting(true)
- {}
-
- // private slots
- void _q_fit(bool doFitting = false);
- void _q_updateCurrentPage();
-
- void init();
- void populateScene();
- void layoutPages();
- void generatePreview();
- void setCurrentPage(int pageNumber);
- void zoom(qreal zoom);
- void setZoomFactor(qreal zoomFactor);
- int calcCurrentPage();
-
- GraphicsView *graphicsView;
- QGraphicsScene *scene;
-
- int curPage;
- QList<const QPicture *> pictures;
- QList<QGraphicsItem *> pages;
-
- QPrintPreviewWidget::ViewMode viewMode;
- QPrintPreviewWidget::ZoomMode zoomMode;
- qreal zoomFactor;
- bool ownPrinter;
- QPrinter* printer;
- bool initialized;
- bool fitting;
-};
-
-void QPrintPreviewWidgetPrivate::_q_fit(bool doFitting)
-{
- Q_Q(QPrintPreviewWidget);
-
- if (curPage < 1 || curPage > pages.count())
- return;
-
- if (!doFitting && !fitting)
- return;
-
- if (doFitting && fitting) {
- QRect viewRect = graphicsView->viewport()->rect();
- if (zoomMode == QPrintPreviewWidget::FitInView) {
- QList<QGraphicsItem*> containedItems = graphicsView->items(viewRect, Qt::ContainsItemBoundingRect);
- foreach(QGraphicsItem* item, containedItems) {
- PageItem* pg = static_cast<PageItem*>(item);
- if (pg->pageNumber() == curPage)
- return;
- }
- }
-
- int newPage = calcCurrentPage();
- if (newPage != curPage)
- curPage = newPage;
- }
-
- QRectF target = pages.at(curPage-1)->sceneBoundingRect();
- if (viewMode == QPrintPreviewWidget::FacingPagesView) {
- // fit two pages
- if (curPage % 2)
- target.setLeft(target.left() - target.width());
- else
- target.setRight(target.right() + target.width());
- } else if (viewMode == QPrintPreviewWidget::AllPagesView) {
- target = scene->itemsBoundingRect();
- }
-
- if (zoomMode == QPrintPreviewWidget::FitToWidth) {
- QTransform t;
- qreal scale = graphicsView->viewport()->width() / target.width();
- t.scale(scale, scale);
- graphicsView->setTransform(t);
- if (doFitting && fitting) {
- QRectF viewSceneRect = graphicsView->viewportTransform().mapRect(graphicsView->viewport()->rect());
- viewSceneRect.moveTop(target.top());
- graphicsView->ensureVisible(viewSceneRect); // Nah...
- }
- } else {
- graphicsView->fitInView(target, Qt::KeepAspectRatio);
- if (zoomMode == QPrintPreviewWidget::FitInView) {
- int step = qRound(graphicsView->matrix().mapRect(target).height());
- graphicsView->verticalScrollBar()->setSingleStep(step);
- graphicsView->verticalScrollBar()->setPageStep(step);
- }
- }
-
- zoomFactor = graphicsView->transform().m11() * (float(printer->logicalDpiY()) / q->logicalDpiY());
- emit q->previewChanged();
-}
-
-void QPrintPreviewWidgetPrivate::_q_updateCurrentPage()
-{
- Q_Q(QPrintPreviewWidget);
-
- if (viewMode == QPrintPreviewWidget::AllPagesView)
- return;
-
- int newPage = calcCurrentPage();
- if (newPage != curPage) {
- curPage = newPage;
- emit q->previewChanged();
- }
-}
-
-int QPrintPreviewWidgetPrivate::calcCurrentPage()
-{
- int maxArea = 0;
- int newPage = curPage;
- QRect viewRect = graphicsView->viewport()->rect();
- QList<QGraphicsItem*> items = graphicsView->items(viewRect);
- for (int i=0; i<items.size(); ++i) {
- PageItem* pg = static_cast<PageItem*>(items.at(i));
- QRect overlap = graphicsView->mapFromScene(pg->sceneBoundingRect()).boundingRect() & viewRect;
- int area = overlap.width() * overlap.height();
- if (area > maxArea) {
- maxArea = area;
- newPage = pg->pageNumber();
- } else if (area == maxArea && pg->pageNumber() < newPage) {
- newPage = pg->pageNumber();
- }
- }
- return newPage;
-}
-
-void QPrintPreviewWidgetPrivate::init()
-{
- Q_Q(QPrintPreviewWidget);
-
- graphicsView = new GraphicsView;
- graphicsView->setInteractive(false);
- graphicsView->setDragMode(QGraphicsView::ScrollHandDrag);
- graphicsView->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
- QObject::connect(graphicsView->verticalScrollBar(), SIGNAL(valueChanged(int)),
- q, SLOT(_q_updateCurrentPage()));
- QObject::connect(graphicsView, SIGNAL(resized()), q, SLOT(_q_fit()));
-
- scene = new QGraphicsScene(graphicsView);
- scene->setBackgroundBrush(Qt::gray);
- graphicsView->setScene(scene);
-
- QVBoxLayout *layout = new QVBoxLayout;
- q->setLayout(layout);
- layout->setContentsMargins(0, 0, 0, 0);
- layout->addWidget(graphicsView);
-}
-
-void QPrintPreviewWidgetPrivate::populateScene()
-{
- // remove old pages
- for (int i = 0; i < pages.size(); i++)
- scene->removeItem(pages.at(i));
- qDeleteAll(pages);
- pages.clear();
-
- int numPages = pictures.count();
- QSize paperSize = printer->paperRect().size();
- QRect pageRect = printer->pageRect();
-
- for (int i = 0; i < numPages; i++) {
- PageItem* item = new PageItem(i+1, pictures.at(i), paperSize, pageRect);
- scene->addItem(item);
- pages.append(item);
- }
-}
-
-void QPrintPreviewWidgetPrivate::layoutPages()
-{
- int numPages = pages.count();
- if (numPages < 1)
- return;
-
- int numPagePlaces = numPages;
- int cols = 1; // singleMode and default
- if (viewMode == QPrintPreviewWidget::AllPagesView) {
- if (printer->orientation() == QPrinter::Portrait)
- cols = qCeil(qSqrt((float) numPages));
- else
- cols = qFloor(qSqrt((float) numPages));
- cols += cols % 2; // Nicer with an even number of cols
- }
- else if (viewMode == QPrintPreviewWidget::FacingPagesView) {
- cols = 2;
- numPagePlaces += 1;
- }
- int rows = qCeil(qreal(numPagePlaces) / cols);
-
- qreal itemWidth = pages.at(0)->boundingRect().width();
- qreal itemHeight = pages.at(0)->boundingRect().height();
- int pageNum = 1;
- for (int i = 0; i < rows && pageNum <= numPages; i++) {
- for (int j = 0; j < cols && pageNum <= numPages; j++) {
- if (!i && !j && viewMode == QPrintPreviewWidget::FacingPagesView) {
- // Front page doesn't have a facing page
- continue;
- } else {
- pages.at(pageNum-1)->setPos(QPointF(j*itemWidth, i*itemHeight));
- pageNum++;
- }
- }
- }
- scene->setSceneRect(scene->itemsBoundingRect());
-}
-
-void QPrintPreviewWidgetPrivate::generatePreview()
-{
- //### If QPrinter::setPreviewMode() becomes public, handle the
- //### case that we have been constructed with a printer that
- //### _already_ has been preview-painted to, so we should
- //### initially just show the pages it already contains, and not
- //### emit paintRequested() until the user changes some parameter
-
- Q_Q(QPrintPreviewWidget);
- printer->d_func()->setPreviewMode(true);
- emit q->paintRequested(printer);
- printer->d_func()->setPreviewMode(false);
- pictures = printer->d_func()->previewPages();
- populateScene(); // i.e. setPreviewPrintedPictures() e.l.
- layoutPages();
- curPage = qBound(1, curPage, pages.count());
- if (fitting)
- _q_fit();
- emit q->previewChanged();
-}
-
-void QPrintPreviewWidgetPrivate::setCurrentPage(int pageNumber)
-{
- if (pageNumber < 1 || pageNumber > pages.count())
- return;
-
- int lastPage = curPage;
- curPage = pageNumber;
-
- if (lastPage != curPage && lastPage > 0 && lastPage <= pages.count()) {
- if (zoomMode != QPrintPreviewWidget::FitInView) {
- QScrollBar *hsc = graphicsView->horizontalScrollBar();
- QScrollBar *vsc = graphicsView->verticalScrollBar();
- QPointF pt = graphicsView->transform().map(pages.at(curPage-1)->pos());
- vsc->setValue(int(pt.y()) - 10);
- hsc->setValue(int(pt.x()) - 10);
- } else {
- graphicsView->centerOn(pages.at(curPage-1));
- }
- }
-}
-
-void QPrintPreviewWidgetPrivate::zoom(qreal zoom)
-{
- zoomFactor *= zoom;
- graphicsView->scale(zoom, zoom);
-}
-
-void QPrintPreviewWidgetPrivate::setZoomFactor(qreal _zoomFactor)
-{
- Q_Q(QPrintPreviewWidget);
- zoomFactor = _zoomFactor;
- graphicsView->resetTransform();
- int dpi_y = q->logicalDpiY();
- int printer_dpi_y = printer->logicalDpiY();
- graphicsView->scale(zoomFactor*(dpi_y/float(printer_dpi_y)),
- zoomFactor*(dpi_y/float(printer_dpi_y)));
-}
-
-///////////////////////////////////////
-
-/*!
- \class QPrintPreviewWidget
- \since 4.4
-
- \brief The QPrintPreviewWidget class provides a widget for
- previewing page layouts for printer output.
-
- \ingroup printing
-
- QPrintPreviewDialog uses a QPrintPreviewWidget internally, and the
- purpose of QPrintPreviewWidget is to make it possible to embed the
- preview into other widgets. It also makes it possible to build a different
- user interface around it than the default one provided with QPrintPreviewDialog.
-
- Using QPrintPreviewWidget is straightforward:
-
- \list 1
- \o Create the QPrintPreviewWidget
-
- Construct the QPrintPreviewWidget either by passing in an
- existing QPrinter object, or have QPrintPreviewWidget create a
- default constructed QPrinter object for you.
-
- \o Connect the paintRequested() signal to a slot.
-
- When the widget needs to generate a set of preview pages, a
- paintRequested() signal will be emitted from the widget. Connect a
- slot to this signal, and draw onto the QPrinter passed in as a
- signal parameter. Call QPrinter::newPage(), to start a new
- page in the preview.
-
- \endlist
-
- \sa QPrinter, QPrintDialog, QPageSetupDialog, QPrintPreviewDialog
-*/
-
-
-/*!
- \enum QPrintPreviewWidget::ViewMode
-
- This enum is used to describe the view mode of the preview widget.
-
- \value SinglePageView A mode where single pages in the preview
- is viewed.
-
- \value FacingPagesView A mode where the facing pages in the preview
- is viewed.
-
- \value AllPagesView A view mode where all the pages in the preview
- is viewed.
-*/
-
-/*!
- \enum QPrintPreviewWidget::ZoomMode
-
- This enum is used to describe zoom mode of the preview widget.
-
- \value CustomZoom The zoom is set to a custom zoom value.
-
- \value FitToWidth This mode fits the current page to the width of the view.
-
- \value FitInView This mode fits the current page inside the view.
-
-*/
-
-/*!
- Constructs a QPrintPreviewWidget based on \a printer and with \a
- parent as the parent widget. The widget flags \a flags are passed on
- to the QWidget constructor.
-
- \sa QWidget::setWindowFlags()
-*/
-QPrintPreviewWidget::QPrintPreviewWidget(QPrinter *printer, QWidget *parent, Qt::WindowFlags flags)
- : QWidget(*new QPrintPreviewWidgetPrivate, parent, flags)
-{
- Q_D(QPrintPreviewWidget);
- d->printer = printer;
- d->ownPrinter = false;
- d->init();
-}
-
-/*!
- \overload
-
- This will cause QPrintPreviewWidget to create an internal, default
- constructed QPrinter object, which will be used to generate the
- preview.
-*/
-QPrintPreviewWidget::QPrintPreviewWidget(QWidget *parent, Qt::WindowFlags flags)
- : QWidget(*new QPrintPreviewWidgetPrivate, parent, flags)
-{
- Q_D(QPrintPreviewWidget);
- d->printer = new QPrinter;
- d->ownPrinter = true;
- d->init();
-}
-
-
-/*!
- Destroys the QPrintPreviewWidget.
-*/
-QPrintPreviewWidget::~QPrintPreviewWidget()
-{
- Q_D(QPrintPreviewWidget);
- if (d->ownPrinter)
- delete d->printer;
-}
-
-/*!
- Returns the current view mode. The default view mode is SinglePageView.
-*/
-QPrintPreviewWidget::ViewMode QPrintPreviewWidget::viewMode() const
-{
- Q_D(const QPrintPreviewWidget);
- return d->viewMode;
-}
-
-/*!
- Sets the view mode to \a mode. The default view mode is
- SinglePageView.
-*/
-void QPrintPreviewWidget::setViewMode(ViewMode mode)
-{
- Q_D(QPrintPreviewWidget);
- d->viewMode = mode;
- d->layoutPages();
- if (d->viewMode == AllPagesView) {
- d->graphicsView->fitInView(d->scene->itemsBoundingRect(), Qt::KeepAspectRatio);
- d->fitting = false;
- d->zoomMode = QPrintPreviewWidget::CustomZoom;
- d->zoomFactor = d->graphicsView->transform().m11() * (float(d->printer->logicalDpiY()) / logicalDpiY());
- emit previewChanged();
- } else {
- d->fitting = true;
- d->_q_fit();
- }
-}
-
-/*!
- Returns the current orientation of the preview. This value is
- obtained from the QPrinter object associated with the preview.
-*/
-QPrinter::Orientation QPrintPreviewWidget::orientation() const
-{
- Q_D(const QPrintPreviewWidget);
- return d->printer->orientation();
-}
-
-/*!
- Sets the current orientation to \a orientation. This value will be
- set on the QPrinter object associated with the preview.
-*/
-void QPrintPreviewWidget::setOrientation(QPrinter::Orientation orientation)
-{
- Q_D(QPrintPreviewWidget);
- d->printer->setOrientation(orientation);
- d->generatePreview();
-}
-
-/*!
- Prints the preview to the printer associated with the preview.
-*/
-void QPrintPreviewWidget::print()
-{
- Q_D(QPrintPreviewWidget);
- // ### make use of the generated pages
- emit paintRequested(d->printer);
-}
-
-/*!
- Zooms the current view in by \a factor. The default value for \a
- factor is 1.1, which means the view will be scaled up by 10%.
-*/
-void QPrintPreviewWidget::zoomIn(qreal factor)
-{
- Q_D(QPrintPreviewWidget);
- d->fitting = false;
- d->zoomMode = QPrintPreviewWidget::CustomZoom;
- d->zoom(factor);
-}
-
-/*!
- Zooms the current view out by \a factor. The default value for \a
- factor is 1.1, which means the view will be scaled down by 10%.
-*/
-void QPrintPreviewWidget::zoomOut(qreal factor)
-{
- Q_D(QPrintPreviewWidget);
- d->fitting = false;
- d->zoomMode = QPrintPreviewWidget::CustomZoom;
- d->zoom(1/factor);
-}
-
-/*!
- Returns the zoom factor of the view.
-*/
-qreal QPrintPreviewWidget::zoomFactor() const
-{
- Q_D(const QPrintPreviewWidget);
- return d->zoomFactor;
-}
-
-/*!
- Sets the zoom factor of the view to \a factor. For example, a
- value of 1.0 indicates an unscaled view, which is approximately
- the size the view will have on paper. A value of 0.5 will halve
- the size of the view, while a value of 2.0 will double the size of
- the view.
-*/
-void QPrintPreviewWidget::setZoomFactor(qreal factor)
-{
- Q_D(QPrintPreviewWidget);
- d->fitting = false;
- d->zoomMode = QPrintPreviewWidget::CustomZoom;
- d->setZoomFactor(factor);
-}
-
-/*!
- \obsolete
- Returns the number of pages in the preview.
- \sa pageCount()
-*/
-int QPrintPreviewWidget::numPages() const
-{
- Q_D(const QPrintPreviewWidget);
- return d->pages.size();
-}
-
-/*!
- \since 4.6
- Returns the number of pages in the preview.
-*/
-int QPrintPreviewWidget::pageCount() const
-{
- Q_D(const QPrintPreviewWidget);
- return d->pages.size();
-}
-
-/*!
- Returns the currently viewed page in the preview.
-*/
-int QPrintPreviewWidget::currentPage() const
-{
- Q_D(const QPrintPreviewWidget);
- return d->curPage;
-}
-
-/*!
- Sets the current page in the preview. This will cause the view to
- skip to the beginning of \a page.
-*/
-void QPrintPreviewWidget::setCurrentPage(int page)
-{
- Q_D(QPrintPreviewWidget);
- d->setCurrentPage(page);
-}
-
-/*!
- This is a convenience function and is the same as calling \c
- {setZoomMode(QPrintPreviewWidget::FitToWidth)}.
-*/
-void QPrintPreviewWidget::fitToWidth()
-{
- setZoomMode(FitToWidth);
-}
-
-/*!
- This is a convenience function and is the same as calling \c
- {setZoomMode(QPrintPreviewWidget::FitInView)}.
-*/
-void QPrintPreviewWidget::fitInView()
-{
- setZoomMode(FitInView);
-}
-
-/*!
- Sets the zoom mode to \a zoomMode. The default zoom mode is FitInView.
-
- \sa zoomMode(), viewMode(), setViewMode()
-*/
-void QPrintPreviewWidget::setZoomMode(QPrintPreviewWidget::ZoomMode zoomMode)
-{
- Q_D(QPrintPreviewWidget);
- d->zoomMode = zoomMode;
- if (d->zoomMode == FitInView || d->zoomMode == FitToWidth) {
- d->fitting = true;
- d->_q_fit(true);
- } else {
- d->fitting = false;
- }
-}
-
-/*!
- Returns the current zoom mode.
-
- \sa setZoomMode(), viewMode(), setViewMode()
-*/
-QPrintPreviewWidget::ZoomMode QPrintPreviewWidget::zoomMode() const
-{
- Q_D(const QPrintPreviewWidget);
- return d->zoomMode;
-}
-
-/*!
- This is a convenience function and is the same as calling \c
- {setOrientation(QPrinter::Landscape)}.
-*/
-void QPrintPreviewWidget::setLandscapeOrientation()
-{
- setOrientation(QPrinter::Landscape);
-}
-
-/*!
- This is a convenience function and is the same as calling \c
- {setOrientation(QPrinter::Portrait)}.
-*/
-void QPrintPreviewWidget::setPortraitOrientation()
-{
- setOrientation(QPrinter::Portrait);
-}
-
-/*!
- This is a convenience function and is the same as calling \c
- {setViewMode(QPrintPreviewWidget::SinglePageView)}.
-*/
-void QPrintPreviewWidget::setSinglePageViewMode()
-{
- setViewMode(SinglePageView);
-}
-
-/*!
- This is a convenience function and is the same as calling \c
- {setViewMode(QPrintPreviewWidget::FacingPagesView)}.
-*/
-void QPrintPreviewWidget::setFacingPagesViewMode()
-{
- setViewMode(FacingPagesView);
-}
-
-/*!
- This is a convenience function and is the same as calling \c
- {setViewMode(QPrintPreviewWidget::AllPagesView)}.
-*/
-void QPrintPreviewWidget::setAllPagesViewMode()
-{
- setViewMode(AllPagesView);
-}
-
-
-/*!
- This function updates the preview, which causes the
- paintRequested() signal to be emitted.
-*/
-void QPrintPreviewWidget::updatePreview()
-{
- Q_D(QPrintPreviewWidget);
- d->initialized = true;
- d->generatePreview();
- d->graphicsView->updateGeometry();
-}
-
-/*! \reimp
-*/
-void QPrintPreviewWidget::setVisible(bool visible)
-{
- Q_D(QPrintPreviewWidget);
- if (visible && !d->initialized)
- updatePreview();
- QWidget::setVisible(visible);
-}
-
-/*!
- \fn void QPrintPreviewWidget::paintRequested(QPrinter *printer)
-
- This signal is emitted when the preview widget needs to generate a
- set of preview pages. \a printer is the printer associated with
- this preview widget.
-*/
-
-/*!
- \fn void QPrintPreviewWidget::previewChanged()
-
- This signal is emitted whenever the preview widget has changed
- some internal state, such as the orientation.
-*/
-
-
-QT_END_NAMESPACE
-
-#include "moc_qprintpreviewwidget.cpp"
-#include "qprintpreviewwidget.moc"
-
-#endif // QT_NO_PRINTPREVIEWWIDGET
diff --git a/src/gui/widgets/qprintpreviewwidget.h b/src/gui/widgets/qprintpreviewwidget.h
deleted file mode 100644
index a5d8fc6bc2..0000000000
--- a/src/gui/widgets/qprintpreviewwidget.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPRINTPREVIEWWIDGET_H
-#define QPRINTPREVIEWWIDGET_H
-
-#include <QtGui/qwidget.h>
-#include <QtGui/qprinter.h>
-
-#ifndef QT_NO_PRINTPREVIEWWIDGET
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QPrintPreviewWidgetPrivate;
-
-class Q_GUI_EXPORT QPrintPreviewWidget : public QWidget
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QPrintPreviewWidget)
-public:
-
- enum ViewMode {
- SinglePageView,
- FacingPagesView,
- AllPagesView
- };
-
- enum ZoomMode {
- CustomZoom,
- FitToWidth,
- FitInView
- };
-
- explicit QPrintPreviewWidget(QPrinter *printer, QWidget *parent = 0, Qt::WindowFlags flags = 0);
- explicit QPrintPreviewWidget(QWidget *parent = 0, Qt::WindowFlags flags = 0);
- ~QPrintPreviewWidget();
-
- qreal zoomFactor() const;
- QPrinter::Orientation orientation() const;
- ViewMode viewMode() const;
- ZoomMode zoomMode() const;
- int currentPage() const;
-#ifdef QT_DEPRECATED
- QT_DEPRECATED int numPages() const;
-#endif
- int pageCount() const;
- void setVisible(bool visible);
-
-public Q_SLOTS:
- void print();
-
- void zoomIn(qreal zoom = 1.1);
- void zoomOut(qreal zoom = 1.1);
- void setZoomFactor(qreal zoomFactor);
- void setOrientation(QPrinter::Orientation orientation);
- void setViewMode(ViewMode viewMode);
- void setZoomMode(ZoomMode zoomMode);
- void setCurrentPage(int pageNumber);
-
- void fitToWidth();
- void fitInView();
- void setLandscapeOrientation();
- void setPortraitOrientation();
- void setSinglePageViewMode();
- void setFacingPagesViewMode();
- void setAllPagesViewMode();
-
- void updatePreview();
-
-Q_SIGNALS:
- void paintRequested(QPrinter *printer);
- void previewChanged();
-
-private:
- void *dummy; // ### remove in Qt 5.0
- Q_PRIVATE_SLOT(d_func(), void _q_fit())
- Q_PRIVATE_SLOT(d_func(), void _q_updateCurrentPage())
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_PRINTPREVIEWWIDGET
-#endif // QPRINTPREVIEWWIDGET_H
diff --git a/src/gui/widgets/qprogressbar.h b/src/gui/widgets/qprogressbar.h
deleted file mode 100644
index 23bc26dc1e..0000000000
--- a/src/gui/widgets/qprogressbar.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPROGRESSBAR_H
-#define QPROGRESSBAR_H
-
-#include <QtGui/qframe.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_PROGRESSBAR
-
-class QProgressBarPrivate;
-class QStyleOptionProgressBar;
-
-class Q_GUI_EXPORT QProgressBar : public QWidget
-{
- Q_OBJECT
- Q_ENUMS(Direction)
- Q_PROPERTY(int minimum READ minimum WRITE setMinimum)
- Q_PROPERTY(int maximum READ maximum WRITE setMaximum)
- Q_PROPERTY(QString text READ text)
- Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
- Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
- Q_PROPERTY(bool textVisible READ isTextVisible WRITE setTextVisible)
- Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
- Q_PROPERTY(bool invertedAppearance READ invertedAppearance WRITE setInvertedAppearance)
- Q_PROPERTY(Direction textDirection READ textDirection WRITE setTextDirection)
- Q_PROPERTY(QString format READ format WRITE setFormat)
-
-public:
- enum Direction { TopToBottom, BottomToTop };
-
- explicit QProgressBar(QWidget *parent = 0);
-
- int minimum() const;
- int maximum() const;
-
- int value() const;
-
- virtual QString text() const;
- void setTextVisible(bool visible);
- bool isTextVisible() const;
-
- Qt::Alignment alignment() const;
- void setAlignment(Qt::Alignment alignment);
-
- QSize sizeHint() const;
- QSize minimumSizeHint() const;
-
- Qt::Orientation orientation() const;
-
- void setInvertedAppearance(bool invert);
- bool invertedAppearance(); //### Qt5 make const
- bool invertedAppearance() const { return const_cast<QProgressBar *>(this)->invertedAppearance(); }
- void setTextDirection(QProgressBar::Direction textDirection);
- QProgressBar::Direction textDirection(); //### Qt5 make const
- QProgressBar::Direction textDirection() const { return const_cast<QProgressBar *>(this)->textDirection(); }
-
- void setFormat(const QString &format);
- QString format() const;
-
-public Q_SLOTS:
- void reset();
- void setRange(int minimum, int maximum);
- void setMinimum(int minimum);
- void setMaximum(int maximum);
- void setValue(int value);
- void setOrientation(Qt::Orientation);
-
-Q_SIGNALS:
- void valueChanged(int value);
-
-protected:
- bool event(QEvent *e);
- void paintEvent(QPaintEvent *);
- void initStyleOption(QStyleOptionProgressBar *option) const;
-
-private:
- Q_DECLARE_PRIVATE(QProgressBar)
- Q_DISABLE_COPY(QProgressBar)
-};
-
-#endif // QT_NO_PROGRESSBAR
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QPROGRESSBAR_H
diff --git a/src/gui/widgets/qpushbutton.h b/src/gui/widgets/qpushbutton.h
deleted file mode 100644
index 59d04055f7..0000000000
--- a/src/gui/widgets/qpushbutton.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPUSHBUTTON_H
-#define QPUSHBUTTON_H
-
-#include <QtGui/qabstractbutton.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QPushButtonPrivate;
-class QMenu;
-class QStyleOptionButton;
-
-class Q_GUI_EXPORT QPushButton : public QAbstractButton
-{
- Q_OBJECT
-
- Q_PROPERTY(bool autoDefault READ autoDefault WRITE setAutoDefault)
- Q_PROPERTY(bool default READ isDefault WRITE setDefault)
- Q_PROPERTY(bool flat READ isFlat WRITE setFlat)
-
-public:
- explicit QPushButton(QWidget *parent=0);
- explicit QPushButton(const QString &text, QWidget *parent=0);
- QPushButton(const QIcon& icon, const QString &text, QWidget *parent=0);
- ~QPushButton();
-
- QSize sizeHint() const;
- QSize minimumSizeHint() const;
-
- bool autoDefault() const;
- void setAutoDefault(bool);
- bool isDefault() const;
- void setDefault(bool);
-
-#ifndef QT_NO_MENU
- void setMenu(QMenu* menu);
- QMenu* menu() const;
-#endif
-
- void setFlat(bool);
- bool isFlat() const;
-
-public Q_SLOTS:
-#ifndef QT_NO_MENU
- void showMenu();
-#endif
-
-protected:
- bool event(QEvent *e);
-#ifdef Q_WS_MAC
- bool hitButton(const QPoint &pos) const;
-#endif // Q_WS_MAC
- void paintEvent(QPaintEvent *);
- void keyPressEvent(QKeyEvent *);
- void focusInEvent(QFocusEvent *);
- void focusOutEvent(QFocusEvent *);
- void initStyleOption(QStyleOptionButton *option) const;
- QPushButton(QPushButtonPrivate &dd, QWidget* parent = 0);
-
-public:
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QPushButton(QWidget *parent, const char* name);
- QT3_SUPPORT_CONSTRUCTOR QPushButton(const QString &text, QWidget *parent, const char* name);
- QT3_SUPPORT_CONSTRUCTOR QPushButton(const QIcon& icon, const QString &text, QWidget *parent, const char* name);
- inline QT3_SUPPORT void openPopup() { showMenu(); }
- inline QT3_SUPPORT bool isMenuButton() const { return menu() != 0; }
- inline QT3_SUPPORT void setPopup(QMenu* popup) {setMenu(popup); }
- inline QT3_SUPPORT QMenu* popup() const { return menu(); }
-#endif
-
-private:
- Q_DISABLE_COPY(QPushButton)
- Q_DECLARE_PRIVATE(QPushButton)
-#ifndef QT_NO_MENU
- Q_PRIVATE_SLOT(d_func(), void _q_popupPressed())
-#endif
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QPUSHBUTTON_H
diff --git a/src/gui/widgets/qradiobutton.h b/src/gui/widgets/qradiobutton.h
deleted file mode 100644
index b720498897..0000000000
--- a/src/gui/widgets/qradiobutton.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QRADIOBUTTON_H
-#define QRADIOBUTTON_H
-
-#include <QtGui/qabstractbutton.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QRadioButtonPrivate;
-class QStyleOptionButton;
-
-class Q_GUI_EXPORT QRadioButton : public QAbstractButton
-{
- Q_OBJECT
-
-public:
- explicit QRadioButton(QWidget *parent=0);
- explicit QRadioButton(const QString &text, QWidget *parent=0);
-
- QSize sizeHint() const;
- QSize minimumSizeHint() const;
-
-protected:
- bool event(QEvent *e);
- bool hitButton(const QPoint &) const;
- void paintEvent(QPaintEvent *);
- void mouseMoveEvent(QMouseEvent *);
- void initStyleOption(QStyleOptionButton *button) const;
-
-#ifdef QT3_SUPPORT
-public:
- QT3_SUPPORT_CONSTRUCTOR QRadioButton(QWidget *parent, const char* name);
- QT3_SUPPORT_CONSTRUCTOR QRadioButton(const QString &text, QWidget *parent, const char* name);
-#endif
-
-private:
- Q_DECLARE_PRIVATE(QRadioButton)
- Q_DISABLE_COPY(QRadioButton)
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QRADIOBUTTON_H
diff --git a/src/gui/widgets/qrubberband.h b/src/gui/widgets/qrubberband.h
deleted file mode 100644
index 85fc17fc32..0000000000
--- a/src/gui/widgets/qrubberband.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QRUBBERBAND_H
-#define QRUBBERBAND_H
-
-#include <QtGui/qwidget.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_RUBBERBAND
-
-class QRubberBandPrivate;
-class QStyleOptionRubberBand;
-
-class Q_GUI_EXPORT QRubberBand : public QWidget
-{
- Q_OBJECT
-
-public:
- enum Shape { Line, Rectangle };
- explicit QRubberBand(Shape, QWidget * =0);
- ~QRubberBand();
-
- Shape shape() const;
-
- void setGeometry(const QRect &r);
-
- inline void setGeometry(int x, int y, int w, int h);
- inline void move(int x, int y);
- inline void move(const QPoint &p)
- { move(p.x(), p.y()); }
- inline void resize(int w, int h)
- { setGeometry(geometry().x(), geometry().y(), w, h); }
- inline void resize(const QSize &s)
- { resize(s.width(), s.height()); }
-
-protected:
- bool event(QEvent *e);
- void paintEvent(QPaintEvent *);
- void changeEvent(QEvent *);
- void showEvent(QShowEvent *);
- void resizeEvent(QResizeEvent *);
- void moveEvent(QMoveEvent *);
- void initStyleOption(QStyleOptionRubberBand *option) const;
-
-private:
- Q_DECLARE_PRIVATE(QRubberBand)
-};
-
-inline void QRubberBand::setGeometry(int ax, int ay, int aw, int ah)
-{ setGeometry(QRect(ax, ay, aw, ah)); }
-inline void QRubberBand::move(int ax, int ay)
-{ setGeometry(ax, ay, width(), height()); }
-
-#endif // QT_NO_RUBBERBAND
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QRUBBERBAND_H
diff --git a/src/gui/widgets/qscrollarea.h b/src/gui/widgets/qscrollarea.h
deleted file mode 100644
index 0c1ef8750c..0000000000
--- a/src/gui/widgets/qscrollarea.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSCROLLAREA_H
-#define QSCROLLAREA_H
-
-#include <QtGui/qabstractscrollarea.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_SCROLLAREA
-
-class QScrollAreaPrivate;
-
-class Q_GUI_EXPORT QScrollArea : public QAbstractScrollArea
-{
- Q_OBJECT
- Q_PROPERTY(bool widgetResizable READ widgetResizable WRITE setWidgetResizable)
- Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
-
-public:
- explicit QScrollArea(QWidget* parent=0);
- ~QScrollArea();
-
- QWidget *widget() const;
- void setWidget(QWidget *widget);
- QWidget *takeWidget();
-
- bool widgetResizable() const;
- void setWidgetResizable(bool resizable);
-
- QSize sizeHint() const;
- bool focusNextPrevChild(bool next);
-
- Qt::Alignment alignment() const;
- void setAlignment(Qt::Alignment);
-
- void ensureVisible(int x, int y, int xmargin = 50, int ymargin = 50);
- void ensureWidgetVisible(QWidget *childWidget, int xmargin = 50, int ymargin = 50);
-
-protected:
- QScrollArea(QScrollAreaPrivate &dd, QWidget *parent = 0);
- bool event(QEvent *);
- bool eventFilter(QObject *, QEvent *);
- void resizeEvent(QResizeEvent *);
- void scrollContentsBy(int dx, int dy);
-
-private:
- Q_DECLARE_PRIVATE(QScrollArea)
- Q_DISABLE_COPY(QScrollArea)
-};
-
-#endif // QT_NO_SCROLLAREA
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSCROLLAREA_H
diff --git a/src/gui/widgets/qscrollarea_p.h b/src/gui/widgets/qscrollarea_p.h
deleted file mode 100644
index cff39ea452..0000000000
--- a/src/gui/widgets/qscrollarea_p.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSCROLLAREA_P_H
-#define QSCROLLAREA_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.
-//
-
-#ifndef QT_NO_SCROLLAREA
-
-#include "private/qabstractscrollarea_p.h"
-#include <QtGui/qscrollbar.h>
-
-QT_BEGIN_NAMESPACE
-
-class QScrollAreaPrivate: public QAbstractScrollAreaPrivate
-{
- Q_DECLARE_PUBLIC(QScrollArea)
-
-public:
- QScrollAreaPrivate(): resizable(false), alignment(0){}
- void updateScrollBars();
- void updateWidgetPosition();
- QPointer<QWidget> widget;
- mutable QSize widgetSize;
- bool resizable;
- Qt::Alignment alignment;
-};
-
-#endif
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/gui/widgets/qscrollbar.h b/src/gui/widgets/qscrollbar.h
deleted file mode 100644
index e407f575f5..0000000000
--- a/src/gui/widgets/qscrollbar.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSCROLLBAR_H
-#define QSCROLLBAR_H
-
-#include <QtGui/qwidget.h>
-#include <QtGui/qabstractslider.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_SCROLLBAR
-
-class QScrollBarPrivate;
-class QStyleOptionSlider;
-
-class Q_GUI_EXPORT QScrollBar : public QAbstractSlider
-{
- Q_OBJECT
-public:
- explicit QScrollBar(QWidget *parent=0);
- explicit QScrollBar(Qt::Orientation, QWidget *parent=0);
- ~QScrollBar();
-
- QSize sizeHint() const;
- bool event(QEvent *event);
-
-protected:
- void paintEvent(QPaintEvent *);
- void mousePressEvent(QMouseEvent *);
- void mouseReleaseEvent(QMouseEvent *);
- void mouseMoveEvent(QMouseEvent *);
- void hideEvent(QHideEvent*);
- void sliderChange(SliderChange change);
-#ifndef QT_NO_CONTEXTMENU
- void contextMenuEvent(QContextMenuEvent *);
-#endif
- void initStyleOption(QStyleOptionSlider *option) const;
-
-#ifdef QT3_SUPPORT
-public:
- QT3_SUPPORT_CONSTRUCTOR QScrollBar(QWidget *parent, const char* name);
- QT3_SUPPORT_CONSTRUCTOR QScrollBar(Qt::Orientation, QWidget *parent, const char* name);
- QT3_SUPPORT_CONSTRUCTOR QScrollBar(int minValue, int maxValue, int lineStep, int pageStep,
- int value, Qt::Orientation, QWidget *parent=0, const char* name = 0);
- inline QT3_SUPPORT bool draggingSlider() { return isSliderDown(); }
-#endif
-
-private:
- friend Q_GUI_EXPORT QStyleOptionSlider qt_qscrollbarStyleOption(QScrollBar *scrollBar);
-
- Q_DISABLE_COPY(QScrollBar)
- Q_DECLARE_PRIVATE(QScrollBar)
-};
-
-#endif // QT_NO_SCROLLBAR
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSCROLLBAR_H
diff --git a/src/gui/widgets/qsizegrip.cpp b/src/gui/widgets/qsizegrip.cpp
deleted file mode 100644
index 630aecfc09..0000000000
--- a/src/gui/widgets/qsizegrip.cpp
+++ /dev/null
@@ -1,570 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qsizegrip.h"
-
-#ifndef QT_NO_SIZEGRIP
-
-#include "qapplication.h"
-#include "qevent.h"
-#include "qpainter.h"
-#include "qstyle.h"
-#include "qstyleoption.h"
-#include "qlayout.h"
-#include "qdebug.h"
-#include <QDesktopWidget>
-
-#if defined(Q_WS_X11)
-#include <private/qt_x11_p.h>
-#elif defined (Q_WS_WIN)
-#include "qt_windows.h"
-#endif
-#ifdef Q_WS_MAC
-#include <private/qt_mac_p.h>
-#endif
-
-#include <private/qwidget_p.h>
-#include <QtGui/qabstractscrollarea.h>
-
-#define SZ_SIZEBOTTOMRIGHT 0xf008
-#define SZ_SIZEBOTTOMLEFT 0xf007
-#define SZ_SIZETOPLEFT 0xf004
-#define SZ_SIZETOPRIGHT 0xf005
-
-QT_BEGIN_NAMESPACE
-
-static QWidget *qt_sizegrip_topLevelWidget(QWidget* w)
-{
- while (w && !w->isWindow() && w->windowType() != Qt::SubWindow)
- w = w->parentWidget();
- return w;
-}
-
-class QSizeGripPrivate : public QWidgetPrivate
-{
- Q_DECLARE_PUBLIC(QSizeGrip)
-public:
- void init();
- QPoint p;
- QRect r;
- int d;
- int dxMax;
- int dyMax;
- Qt::Corner m_corner;
- bool gotMousePress;
- QWidget *tlw;
-#ifdef Q_WS_MAC
- void updateMacSizer(bool hide) const;
-#endif
- Qt::Corner corner() const;
- inline bool atBottom() const
- {
- return m_corner == Qt::BottomRightCorner || m_corner == Qt::BottomLeftCorner;
- }
-
- inline bool atLeft() const
- {
- return m_corner == Qt::BottomLeftCorner || m_corner == Qt::TopLeftCorner;
- }
-
- void updateTopLevelWidget()
- {
- Q_Q(QSizeGrip);
- QWidget *w = qt_sizegrip_topLevelWidget(q);
- if (tlw == w)
- return;
- if (tlw)
- tlw->removeEventFilter(q);
- tlw = w;
- if (tlw)
- tlw->installEventFilter(q);
- }
-
- // This slot is invoked by QLayout when the size grip is added to
- // a layout or reparented after the tlw is shown. This re-implementation is basically
- // the same as QWidgetPrivate::_q_showIfNotHidden except that it checks
- // for Qt::WindowFullScreen and Qt::WindowMaximized as well.
- void _q_showIfNotHidden()
- {
- Q_Q(QSizeGrip);
- bool showSizeGrip = !(q->isHidden() && q->testAttribute(Qt::WA_WState_ExplicitShowHide));
- updateTopLevelWidget();
- if (tlw && showSizeGrip) {
- Qt::WindowStates sizeGripNotVisibleState = Qt::WindowFullScreen;
-#ifndef Q_WS_MAC
- sizeGripNotVisibleState |= Qt::WindowMaximized;
-#endif
- // Don't show the size grip if the tlw is maximized or in full screen mode.
- showSizeGrip = !(tlw->windowState() & sizeGripNotVisibleState);
- }
- if (showSizeGrip)
- q->setVisible(true);
- }
-};
-
-#ifdef Q_WS_MAC
-void QSizeGripPrivate::updateMacSizer(bool hide) const
-{
- Q_Q(const QSizeGrip);
- if (QApplication::closingDown() || !parent)
- return;
- QWidget *topLevelWindow = qt_sizegrip_topLevelWidget(const_cast<QSizeGrip *>(q));
- if(topLevelWindow && topLevelWindow->isWindow())
- QWidgetPrivate::qt_mac_update_sizer(topLevelWindow, hide ? -1 : 1);
-}
-#endif
-
-Qt::Corner QSizeGripPrivate::corner() const
-{
- Q_Q(const QSizeGrip);
- QWidget *tlw = qt_sizegrip_topLevelWidget(const_cast<QSizeGrip *>(q));
- const QPoint sizeGripPos = q->mapTo(tlw, QPoint(0, 0));
- bool isAtBottom = sizeGripPos.y() >= tlw->height() / 2;
- bool isAtLeft = sizeGripPos.x() <= tlw->width() / 2;
- if (isAtLeft)
- return isAtBottom ? Qt::BottomLeftCorner : Qt::TopLeftCorner;
- else
- return isAtBottom ? Qt::BottomRightCorner : Qt::TopRightCorner;
-}
-
-/*!
- \class QSizeGrip
-
- \brief The QSizeGrip class provides a resize handle for resizing top-level windows.
-
- \ingroup mainwindow-classes
- \ingroup basicwidgets
-
- This widget works like the standard Windows resize handle. In the
- X11 version this resize handle generally works differently from
- the one provided by the system if the X11 window manager does not
- support necessary modern post-ICCCM specifications.
-
- Put this widget anywhere in a widget tree and the user can use it
- to resize the top-level window or any widget with the Qt::SubWindow
- flag set. Generally, this should be in the lower right-hand corner.
- Note that QStatusBar already uses this widget, so if you have a
- status bar (e.g., you are using QMainWindow), then you don't need
- to use this widget explicitly.
-
- On some platforms the size grip automatically hides itself when the
- window is shown full screen or maximised.
-
- \table 50%
- \row \o \inlineimage plastique-sizegrip.png Screenshot of a Plastique style size grip
- \o A size grip widget at the bottom-right corner of a main window, shown in the
- \l{Plastique Style Widget Gallery}{Plastique widget style}.
- \endtable
-
- The QSizeGrip class inherits QWidget and reimplements the \l
- {QWidget::mousePressEvent()}{mousePressEvent()} and \l
- {QWidget::mouseMoveEvent()}{mouseMoveEvent()} functions to feature
- the resize functionality, and the \l
- {QWidget::paintEvent()}{paintEvent()} function to render the
- size grip widget.
-
- \sa QStatusBar QWidget::windowState()
-*/
-
-
-/*!
- Constructs a resize corner as a child widget of the given \a
- parent.
-*/
-QSizeGrip::QSizeGrip(QWidget * parent)
- : QWidget(*new QSizeGripPrivate, parent, 0)
-{
- Q_D(QSizeGrip);
- d->init();
-}
-
-#ifdef QT3_SUPPORT
-/*!
- \obsolete
-
- Constructs a resize corner with the given \a name, as a child
- widget of the given \a parent.
-*/
-QSizeGrip::QSizeGrip(QWidget * parent, const char* name)
- : QWidget(*new QSizeGripPrivate, parent, 0)
-{
- Q_D(QSizeGrip);
- setObjectName(QString::fromAscii(name));
- d->init();
-}
-#endif
-
-void QSizeGripPrivate::init()
-{
- Q_Q(QSizeGrip);
- dxMax = 0;
- dyMax = 0;
- tlw = 0;
- m_corner = q->isLeftToRight() ? Qt::BottomRightCorner : Qt::BottomLeftCorner;
- gotMousePress = false;
-
-#if !defined(QT_NO_CURSOR) && !defined(Q_WS_MAC)
- q->setCursor(m_corner == Qt::TopLeftCorner || m_corner == Qt::BottomRightCorner
- ? Qt::SizeFDiagCursor : Qt::SizeBDiagCursor);
-#endif
- q->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
- updateTopLevelWidget();
-}
-
-
-/*!
- Destroys this size grip.
-*/
-QSizeGrip::~QSizeGrip()
-{
-}
-
-/*!
- \reimp
-*/
-QSize QSizeGrip::sizeHint() const
-{
- QStyleOption opt(0);
- opt.init(this);
- return (style()->sizeFromContents(QStyle::CT_SizeGrip, &opt, QSize(13, 13), this).
- expandedTo(QApplication::globalStrut()));
-}
-
-/*!
- Paints the resize grip.
-
- Resize grips are usually rendered as small diagonal textured lines
- in the lower-right corner. The paint event is passed in the \a
- event parameter.
-*/
-void QSizeGrip::paintEvent(QPaintEvent *event)
-{
- Q_UNUSED(event);
- Q_D(QSizeGrip);
- QPainter painter(this);
- QStyleOptionSizeGrip opt;
- opt.init(this);
- opt.corner = d->m_corner;
- style()->drawControl(QStyle::CE_SizeGrip, &opt, &painter, this);
-}
-
-/*!
- \fn void QSizeGrip::mousePressEvent(QMouseEvent * event)
-
- Receives the mouse press events for the widget, and primes the
- resize operation. The mouse press event is passed in the \a event
- parameter.
-*/
-void QSizeGrip::mousePressEvent(QMouseEvent * e)
-{
- if (e->button() != Qt::LeftButton) {
- QWidget::mousePressEvent(e);
- return;
- }
-
- Q_D(QSizeGrip);
- QWidget *tlw = qt_sizegrip_topLevelWidget(this);
- d->p = e->globalPos();
- d->gotMousePress = true;
- d->r = tlw->geometry();
-
-#ifdef Q_WS_X11
- // Use a native X11 sizegrip for "real" top-level windows if supported.
- if (tlw->isWindow() && X11->isSupportedByWM(ATOM(_NET_WM_MOVERESIZE))
- && !(tlw->windowFlags() & Qt::X11BypassWindowManagerHint)
- && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) {
- XEvent xev;
- xev.xclient.type = ClientMessage;
- xev.xclient.message_type = ATOM(_NET_WM_MOVERESIZE);
- xev.xclient.display = X11->display;
- xev.xclient.window = tlw->winId();
- xev.xclient.format = 32;
- xev.xclient.data.l[0] = e->globalPos().x();
- xev.xclient.data.l[1] = e->globalPos().y();
- if (d->atBottom())
- xev.xclient.data.l[2] = d->atLeft() ? 6 : 4; // bottomleft/bottomright
- else
- xev.xclient.data.l[2] = d->atLeft() ? 0 : 2; // topleft/topright
- xev.xclient.data.l[3] = Button1;
- xev.xclient.data.l[4] = 0;
- XUngrabPointer(X11->display, X11->time);
- XSendEvent(X11->display, QX11Info::appRootWindow(x11Info().screen()), False,
- SubstructureRedirectMask | SubstructureNotifyMask, &xev);
- return;
- }
-#endif // Q_WS_X11
-#ifdef Q_WS_WIN
- if (tlw->isWindow() && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) {
- uint orientation = 0;
- if (d->atBottom())
- orientation = d->atLeft() ? SZ_SIZEBOTTOMLEFT : SZ_SIZEBOTTOMRIGHT;
- else
- orientation = d->atLeft() ? SZ_SIZETOPLEFT : SZ_SIZETOPRIGHT;
-
- ReleaseCapture();
- PostMessage(tlw->winId(), WM_SYSCOMMAND, orientation, 0);
- return;
- }
-#endif // Q_WS_WIN
-
- // Find available desktop/workspace geometry.
- QRect availableGeometry;
- bool hasVerticalSizeConstraint = true;
- bool hasHorizontalSizeConstraint = true;
- if (tlw->isWindow())
- availableGeometry = QApplication::desktop()->availableGeometry(tlw);
- else {
- const QWidget *tlwParent = tlw->parentWidget();
- // Check if tlw is inside QAbstractScrollArea/QScrollArea.
- // If that's the case tlw->parentWidget() will return the viewport
- // and tlw->parentWidget()->parentWidget() will return the scroll area.
-#ifndef QT_NO_SCROLLAREA
- QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(tlwParent->parentWidget());
- if (scrollArea) {
- hasHorizontalSizeConstraint = scrollArea->horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOff;
- hasVerticalSizeConstraint = scrollArea->verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff;
- }
-#endif // QT_NO_SCROLLAREA
- availableGeometry = tlwParent->contentsRect();
- }
-
- // Find frame geometries, title bar height, and decoration sizes.
- const QRect frameGeometry = tlw->frameGeometry();
- const int titleBarHeight = qMax(tlw->geometry().y() - frameGeometry.y(), 0);
- const int bottomDecoration = qMax(frameGeometry.height() - tlw->height() - titleBarHeight, 0);
- const int leftRightDecoration = qMax((frameGeometry.width() - tlw->width()) / 2, 0);
-
- // Determine dyMax depending on whether the sizegrip is at the bottom
- // of the widget or not.
- if (d->atBottom()) {
- if (hasVerticalSizeConstraint)
- d->dyMax = availableGeometry.bottom() - d->r.bottom() - bottomDecoration;
- else
- d->dyMax = INT_MAX;
- } else {
- if (hasVerticalSizeConstraint)
- d->dyMax = availableGeometry.y() - d->r.y() + titleBarHeight;
- else
- d->dyMax = -INT_MAX;
- }
-
- // In RTL mode, the size grip is to the left; find dxMax from the desktop/workspace
- // geometry, the size grip geometry and the width of the decoration.
- if (d->atLeft()) {
- if (hasHorizontalSizeConstraint)
- d->dxMax = availableGeometry.x() - d->r.x() + leftRightDecoration;
- else
- d->dxMax = -INT_MAX;
- } else {
- if (hasHorizontalSizeConstraint)
- d->dxMax = availableGeometry.right() - d->r.right() - leftRightDecoration;
- else
- d->dxMax = INT_MAX;
- }
-}
-
-
-/*!
- \fn void QSizeGrip::mouseMoveEvent(QMouseEvent * event)
- Resizes the top-level widget containing this widget. The mouse
- move event is passed in the \a event parameter.
-*/
-void QSizeGrip::mouseMoveEvent(QMouseEvent * e)
-{
- if (e->buttons() != Qt::LeftButton) {
- QWidget::mouseMoveEvent(e);
- return;
- }
-
- Q_D(QSizeGrip);
- QWidget* tlw = qt_sizegrip_topLevelWidget(this);
- if (!d->gotMousePress || tlw->testAttribute(Qt::WA_WState_ConfigPending))
- return;
-
-#ifdef Q_WS_X11
- if (tlw->isWindow() && X11->isSupportedByWM(ATOM(_NET_WM_MOVERESIZE))
- && tlw->isTopLevel() && !(tlw->windowFlags() & Qt::X11BypassWindowManagerHint)
- && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth())
- return;
-#endif
-#ifdef Q_WS_WIN
- if (tlw->isWindow() && GetSystemMenu(tlw->winId(), FALSE) != 0 && internalWinId()
- && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) {
- MSG msg;
- while(PeekMessage(&msg, winId(), WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE));
- return;
- }
-#endif
-
- QPoint np(e->globalPos());
-
- // Don't extend beyond the available geometry; bound to dyMax and dxMax.
- QSize ns;
- if (d->atBottom())
- ns.rheight() = d->r.height() + qMin(np.y() - d->p.y(), d->dyMax);
- else
- ns.rheight() = d->r.height() - qMax(np.y() - d->p.y(), d->dyMax);
-
- if (d->atLeft())
- ns.rwidth() = d->r.width() - qMax(np.x() - d->p.x(), d->dxMax);
- else
- ns.rwidth() = d->r.width() + qMin(np.x() - d->p.x(), d->dxMax);
-
- ns = QLayout::closestAcceptableSize(tlw, ns);
-
- QPoint p;
- QRect nr(p, ns);
- if (d->atBottom()) {
- if (d->atLeft())
- nr.moveTopRight(d->r.topRight());
- else
- nr.moveTopLeft(d->r.topLeft());
- } else {
- if (d->atLeft())
- nr.moveBottomRight(d->r.bottomRight());
- else
- nr.moveBottomLeft(d->r.bottomLeft());
- }
-
- tlw->setGeometry(nr);
-}
-
-/*!
- \reimp
-*/
-void QSizeGrip::mouseReleaseEvent(QMouseEvent *mouseEvent)
-{
- if (mouseEvent->button() == Qt::LeftButton) {
- Q_D(QSizeGrip);
- d->gotMousePress = false;
- d->p = QPoint();
- } else {
- QWidget::mouseReleaseEvent(mouseEvent);
- }
-}
-
-/*!
- \reimp
-*/
-void QSizeGrip::moveEvent(QMoveEvent * /*moveEvent*/)
-{
- Q_D(QSizeGrip);
- // We're inside a resize operation; no update necessary.
- if (!d->p.isNull())
- return;
-
- d->m_corner = d->corner();
-#if !defined(QT_NO_CURSOR) && !defined(Q_WS_MAC)
- setCursor(d->m_corner == Qt::TopLeftCorner || d->m_corner == Qt::BottomRightCorner
- ? Qt::SizeFDiagCursor : Qt::SizeBDiagCursor);
-#endif
-}
-
-/*!
- \reimp
-*/
-void QSizeGrip::showEvent(QShowEvent *showEvent)
-{
-#ifdef Q_WS_MAC
- d_func()->updateMacSizer(false);
-#endif
- QWidget::showEvent(showEvent);
-}
-
-/*!
- \reimp
-*/
-void QSizeGrip::hideEvent(QHideEvent *hideEvent)
-{
-#ifdef Q_WS_MAC
- d_func()->updateMacSizer(true);
-#endif
- QWidget::hideEvent(hideEvent);
-}
-
-/*!
- \reimp
-*/
-void QSizeGrip::setVisible(bool visible)
-{
- QWidget::setVisible(visible);
-}
-
-/*! \reimp */
-bool QSizeGrip::eventFilter(QObject *o, QEvent *e)
-{
- Q_D(QSizeGrip);
- if ((isHidden() && testAttribute(Qt::WA_WState_ExplicitShowHide))
- || e->type() != QEvent::WindowStateChange
- || o != d->tlw) {
- return QWidget::eventFilter(o, e);
- }
- Qt::WindowStates sizeGripNotVisibleState = Qt::WindowFullScreen;
-#ifndef Q_WS_MAC
- sizeGripNotVisibleState |= Qt::WindowMaximized;
-#endif
- // Don't show the size grip if the tlw is maximized or in full screen mode.
- setVisible(!(d->tlw->windowState() & sizeGripNotVisibleState));
- setAttribute(Qt::WA_WState_ExplicitShowHide, false);
- return QWidget::eventFilter(o, e);
-}
-
-/*!
- \reimp
-*/
-bool QSizeGrip::event(QEvent *event)
-{
- return QWidget::event(event);
-}
-
-#ifdef Q_WS_WIN
-/*! \reimp */
-bool QSizeGrip::winEvent( MSG *m, long *result )
-{
- return QWidget::winEvent(m, result);
-}
-#endif
-
-QT_END_NAMESPACE
-
-#include "moc_qsizegrip.cpp"
-
-#endif //QT_NO_SIZEGRIP
diff --git a/src/gui/widgets/qsizegrip.h b/src/gui/widgets/qsizegrip.h
deleted file mode 100644
index 7ec0818129..0000000000
--- a/src/gui/widgets/qsizegrip.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSIZEGRIP_H
-#define QSIZEGRIP_H
-
-#include <QtGui/qwidget.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_SIZEGRIP
-class QSizeGripPrivate;
-class Q_GUI_EXPORT QSizeGrip : public QWidget
-{
- Q_OBJECT
-public:
- explicit QSizeGrip(QWidget *parent);
- ~QSizeGrip();
-
- QSize sizeHint() const;
- void setVisible(bool);
-
-protected:
- void paintEvent(QPaintEvent *);
- void mousePressEvent(QMouseEvent *);
- void mouseMoveEvent(QMouseEvent *);
- void mouseReleaseEvent(QMouseEvent *mouseEvent);
- void moveEvent(QMoveEvent *moveEvent);
- void showEvent(QShowEvent *showEvent);
- void hideEvent(QHideEvent *hideEvent);
- bool eventFilter(QObject *, QEvent *);
- bool event(QEvent *);
-#ifdef Q_WS_WIN
- bool winEvent(MSG *m, long *result);
-#endif
-
-public:
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QSizeGrip(QWidget *parent, const char *name);
-#endif
-
-private:
- Q_DECLARE_PRIVATE(QSizeGrip)
- Q_DISABLE_COPY(QSizeGrip)
- Q_PRIVATE_SLOT(d_func(), void _q_showIfNotHidden())
-};
-#endif // QT_NO_SIZEGRIP
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSIZEGRIP_H
diff --git a/src/gui/widgets/qslider.h b/src/gui/widgets/qslider.h
deleted file mode 100644
index a2201da9a2..0000000000
--- a/src/gui/widgets/qslider.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSLIDER_H
-#define QSLIDER_H
-
-#include <QtGui/qabstractslider.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_SLIDER
-
-class QSliderPrivate;
-class QStyleOptionSlider;
-class Q_GUI_EXPORT QSlider : public QAbstractSlider
-{
- Q_OBJECT
-
- Q_ENUMS(TickPosition)
- Q_PROPERTY(TickPosition tickPosition READ tickPosition WRITE setTickPosition)
- Q_PROPERTY(int tickInterval READ tickInterval WRITE setTickInterval)
-
-public:
- enum TickPosition {
- NoTicks = 0,
- TicksAbove = 1,
- TicksLeft = TicksAbove,
- TicksBelow = 2,
- TicksRight = TicksBelow,
- TicksBothSides = 3
-
-#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
- ,NoMarks = NoTicks,
- Above = TicksAbove,
- Left = TicksAbove,
- Below = TicksBelow,
- Right = TicksRight,
- Both = TicksBothSides
-#endif
- };
-
- explicit QSlider(QWidget *parent = 0);
- explicit QSlider(Qt::Orientation orientation, QWidget *parent = 0);
-
- ~QSlider();
-
- QSize sizeHint() const;
- QSize minimumSizeHint() const;
-
- void setTickPosition(TickPosition position);
- TickPosition tickPosition() const;
-
- void setTickInterval(int ti);
- int tickInterval() const;
-
- bool event(QEvent *event);
-
-protected:
- void paintEvent(QPaintEvent *ev);
- void mousePressEvent(QMouseEvent *ev);
- void mouseReleaseEvent(QMouseEvent *ev);
- void mouseMoveEvent(QMouseEvent *ev);
- void initStyleOption(QStyleOptionSlider *option) const;
-
-#ifdef QT3_SUPPORT
-public:
- QT3_SUPPORT_CONSTRUCTOR QSlider(QWidget *parent, const char *name);
- QT3_SUPPORT_CONSTRUCTOR QSlider(Qt::Orientation, QWidget *parent, const char *name);
- QT3_SUPPORT_CONSTRUCTOR QSlider(int minValue, int maxValue, int pageStep, int value,
- Qt::Orientation orientation,
- QWidget *parent = 0, const char *name = 0);
- inline QT3_SUPPORT void setTickmarks(TickPosition position) { setTickPosition(position); }
- inline QT3_SUPPORT TickPosition tickmarks() const { return tickPosition(); }
-public Q_SLOTS:
- inline QT_MOC_COMPAT void addStep() { triggerAction(SliderSingleStepAdd); }
- inline QT_MOC_COMPAT void subtractStep() { triggerAction(SliderSingleStepSub); }
-#endif
-
-private:
- friend Q_GUI_EXPORT QStyleOptionSlider qt_qsliderStyleOption(QSlider *slider);
-
- Q_DISABLE_COPY(QSlider)
- Q_DECLARE_PRIVATE(QSlider)
-};
-
-#endif // QT_NO_SLIDER
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSLIDER_H
diff --git a/src/gui/widgets/qspinbox.h b/src/gui/widgets/qspinbox.h
deleted file mode 100644
index 8c9f67b29c..0000000000
--- a/src/gui/widgets/qspinbox.h
+++ /dev/null
@@ -1,188 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSPINBOX_H
-#define QSPINBOX_H
-
-#include <QtGui/qabstractspinbox.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_SPINBOX
-
-class QSpinBoxPrivate;
-class Q_GUI_EXPORT QSpinBox : public QAbstractSpinBox
-{
- Q_OBJECT
-
- Q_PROPERTY(QString suffix READ suffix WRITE setSuffix)
- Q_PROPERTY(QString prefix READ prefix WRITE setPrefix)
- Q_PROPERTY(QString cleanText READ cleanText)
- Q_PROPERTY(int minimum READ minimum WRITE setMinimum)
- Q_PROPERTY(int maximum READ maximum WRITE setMaximum)
- Q_PROPERTY(int singleStep READ singleStep WRITE setSingleStep)
- Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged USER true)
-
-public:
- explicit QSpinBox(QWidget *parent = 0);
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QSpinBox(QWidget *parent, const char *name);
- QT3_SUPPORT_CONSTRUCTOR QSpinBox(int min, int max, int step, QWidget *parent,
- const char *name = 0);
-#endif
-
- int value() const;
-
- QString prefix() const;
- void setPrefix(const QString &prefix);
-
- QString suffix() const;
- void setSuffix(const QString &suffix);
-
- QString cleanText() const;
-
- int singleStep() const;
- void setSingleStep(int val);
-
- int minimum() const;
- void setMinimum(int min);
-
- int maximum() const;
- void setMaximum(int max);
-
- void setRange(int min, int max);
-
-#ifdef QT3_SUPPORT
- inline QT3_SUPPORT void setLineStep(int step) { setSingleStep(step); }
- inline QT3_SUPPORT void setMaxValue(int val) { setMaximum(val); }
- inline QT3_SUPPORT void setMinValue(int val) { setMinimum(val); }
- inline QT3_SUPPORT int maxValue() const { return maximum(); }
- inline QT3_SUPPORT int minValue() const { return minimum(); }
-#endif
-
-protected:
- bool event(QEvent *event);
- virtual QValidator::State validate(QString &input, int &pos) const;
- virtual int valueFromText(const QString &text) const;
- virtual QString textFromValue(int val) const;
- virtual void fixup(QString &str) const;
-
-
-public Q_SLOTS:
- void setValue(int val);
-
-Q_SIGNALS:
- void valueChanged(int);
- void valueChanged(const QString &);
-
-private:
- Q_DISABLE_COPY(QSpinBox)
- Q_DECLARE_PRIVATE(QSpinBox)
-};
-
-class QDoubleSpinBoxPrivate;
-class Q_GUI_EXPORT QDoubleSpinBox : public QAbstractSpinBox
-{
- Q_OBJECT
-
- Q_PROPERTY(QString prefix READ prefix WRITE setPrefix)
- Q_PROPERTY(QString suffix READ suffix WRITE setSuffix)
- Q_PROPERTY(QString cleanText READ cleanText)
- Q_PROPERTY(int decimals READ decimals WRITE setDecimals)
- Q_PROPERTY(double minimum READ minimum WRITE setMinimum)
- Q_PROPERTY(double maximum READ maximum WRITE setMaximum)
- Q_PROPERTY(double singleStep READ singleStep WRITE setSingleStep)
- Q_PROPERTY(double value READ value WRITE setValue NOTIFY valueChanged USER true)
-public:
- explicit QDoubleSpinBox(QWidget *parent = 0);
-
- double value() const;
-
- QString prefix() const;
- void setPrefix(const QString &prefix);
-
- QString suffix() const;
- void setSuffix(const QString &suffix);
-
- QString cleanText() const;
-
- double singleStep() const;
- void setSingleStep(double val);
-
- double minimum() const;
- void setMinimum(double min);
-
- double maximum() const;
- void setMaximum(double max);
-
- void setRange(double min, double max);
-
- int decimals() const;
- void setDecimals(int prec);
-
- virtual QValidator::State validate(QString &input, int &pos) const;
- virtual double valueFromText(const QString &text) const;
- virtual QString textFromValue(double val) const;
- virtual void fixup(QString &str) const;
-
-public Q_SLOTS:
- void setValue(double val);
-
-Q_SIGNALS:
- void valueChanged(double);
- void valueChanged(const QString &);
-
-private:
- Q_DISABLE_COPY(QDoubleSpinBox)
- Q_DECLARE_PRIVATE(QDoubleSpinBox)
-};
-
-#endif // QT_NO_SPINBOX
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSPINBOX_H
diff --git a/src/gui/widgets/qsplashscreen.h b/src/gui/widgets/qsplashscreen.h
deleted file mode 100644
index 588054f196..0000000000
--- a/src/gui/widgets/qsplashscreen.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSPLASHSCREEN_H
-#define QSPLASHSCREEN_H
-
-#include <QtGui/qpixmap.h>
-#include <QtGui/qwidget.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_SPLASHSCREEN
-class QSplashScreenPrivate;
-
-class Q_GUI_EXPORT QSplashScreen : public QWidget
-{
- Q_OBJECT
-public:
- explicit QSplashScreen(const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = 0);
- QSplashScreen(QWidget *parent, const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = 0);
- virtual ~QSplashScreen();
-
- void setPixmap(const QPixmap &pixmap);
- const QPixmap pixmap() const;
- void finish(QWidget *w);
- void repaint();
-
-public Q_SLOTS:
- void showMessage(const QString &message, int alignment = Qt::AlignLeft,
- const QColor &color = Qt::black);
- void clearMessage();
-#ifdef QT3_SUPPORT
- inline QT_MOC_COMPAT void message(const QString &str, int alignment = Qt::AlignLeft,
- const QColor &color = Qt::black) { showMessage(str, alignment, color); }
- inline QT_MOC_COMPAT void clear() { clearMessage(); }
-#endif
-
-Q_SIGNALS:
- void messageChanged(const QString &message);
-
-protected:
- bool event(QEvent *e);
- virtual void drawContents(QPainter *painter);
- void mousePressEvent(QMouseEvent *);
-
-private:
- Q_DISABLE_COPY(QSplashScreen)
- Q_DECLARE_PRIVATE(QSplashScreen)
-};
-
-#endif // QT_NO_SPLASHSCREEN
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSPLASHSCREEN_H
diff --git a/src/gui/widgets/qsplitter.h b/src/gui/widgets/qsplitter.h
deleted file mode 100644
index a3758eabe9..0000000000
--- a/src/gui/widgets/qsplitter.h
+++ /dev/null
@@ -1,192 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSPLITTER_H
-#define QSPLITTER_H
-
-#include <QtGui/qframe.h>
-#include <QtGui/qsizepolicy.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_SPLITTER
-
-class QSplitterPrivate;
-class QTextStream;
-template <typename T> class QList;
-
-class QSplitterHandle;
-
-class Q_GUI_EXPORT QSplitter : public QFrame
-{
- Q_OBJECT
-
- Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
- Q_PROPERTY(bool opaqueResize READ opaqueResize WRITE setOpaqueResize)
- Q_PROPERTY(int handleWidth READ handleWidth WRITE setHandleWidth)
- Q_PROPERTY(bool childrenCollapsible READ childrenCollapsible WRITE setChildrenCollapsible)
-
-public:
- explicit QSplitter(QWidget* parent = 0);
- explicit QSplitter(Qt::Orientation, QWidget* parent = 0);
- ~QSplitter();
-
- void addWidget(QWidget *widget);
- void insertWidget(int index, QWidget *widget);
-
- void setOrientation(Qt::Orientation);
- Qt::Orientation orientation() const;
-
- void setChildrenCollapsible(bool);
- bool childrenCollapsible() const;
-
- void setCollapsible(int index, bool);
- bool isCollapsible(int index) const;
- void setOpaqueResize(bool opaque = true);
- bool opaqueResize() const;
- void refresh();
-
- QSize sizeHint() const;
- QSize minimumSizeHint() const;
-
- QList<int> sizes() const;
- void setSizes(const QList<int> &list);
-
- QByteArray saveState() const;
- bool restoreState(const QByteArray &state);
-
- int handleWidth() const;
- void setHandleWidth(int);
-
- int indexOf(QWidget *w) const;
- QWidget *widget(int index) const;
- int count() const;
-
- void getRange(int index, int *, int *) const;
- QSplitterHandle *handle(int index) const;
-
- void setStretchFactor(int index, int stretch);
-
-Q_SIGNALS:
- void splitterMoved(int pos, int index);
-
-protected:
- virtual QSplitterHandle *createHandle();
-
- void childEvent(QChildEvent *);
-
- bool event(QEvent *);
- void resizeEvent(QResizeEvent *);
-
- void changeEvent(QEvent *);
- void moveSplitter(int pos, int index);
- void setRubberBand(int position);
- int closestLegalPosition(int, int);
-
-#ifdef QT3_SUPPORT
-public:
- QT3_SUPPORT_CONSTRUCTOR QSplitter(QWidget* parent, const char* name);
- QT3_SUPPORT_CONSTRUCTOR QSplitter(Qt::Orientation, QWidget* parent, const char* name);
- enum ResizeMode { Stretch, KeepSize, FollowSizeHint, Auto };
- QT3_SUPPORT void setResizeMode(QWidget *w, ResizeMode mode);
- inline QT3_SUPPORT void moveToFirst(QWidget *w) { insertWidget(0,w); }
- inline QT3_SUPPORT void moveToLast(QWidget *w) { addWidget(w); }
- inline QT3_SUPPORT void setCollapsible(QWidget *w, bool collapse)
- { setCollapsible(indexOf(w), collapse); }
- QT3_SUPPORT void setMargin(int margin) { setContentsMargins(margin, margin, margin, margin); }
- QT3_SUPPORT int margin() const
- { int margin; int dummy; getContentsMargins(&margin, &dummy, &dummy, &dummy); return margin; }
-#endif
-
-private:
- Q_DISABLE_COPY(QSplitter)
- Q_DECLARE_PRIVATE(QSplitter)
-private:
- friend class QSplitterHandle;
-};
-
-//#ifdef QT3_SUPPORT
-#ifndef QT_NO_TEXTSTREAM
-Q_GUI_EXPORT QTextStream& operator<<(QTextStream&, const QSplitter&);
-Q_GUI_EXPORT QTextStream& operator>>(QTextStream&, QSplitter&);
-#endif
-//#endif
-
-class QSplitterHandlePrivate;
-class Q_GUI_EXPORT QSplitterHandle : public QWidget
-{
- Q_OBJECT
-public:
- QSplitterHandle(Qt::Orientation o, QSplitter *parent);
- void setOrientation(Qt::Orientation o);
- Qt::Orientation orientation() const;
- bool opaqueResize() const;
- QSplitter *splitter() const;
-
- QSize sizeHint() const;
-
-protected:
- void paintEvent(QPaintEvent *);
- void mouseMoveEvent(QMouseEvent *);
- void mousePressEvent(QMouseEvent *);
- void mouseReleaseEvent(QMouseEvent *);
- void resizeEvent(QResizeEvent *);
- bool event(QEvent *);
-
- void moveSplitter(int p);
- int closestLegalPosition(int p);
-
-private:
- Q_DISABLE_COPY(QSplitterHandle)
- Q_DECLARE_PRIVATE(QSplitterHandle)
-};
-
-#endif // QT_NO_SPLITTER
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSPLITTER_H
diff --git a/src/gui/widgets/qstackedwidget.h b/src/gui/widgets/qstackedwidget.h
deleted file mode 100644
index 7919674aa7..0000000000
--- a/src/gui/widgets/qstackedwidget.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSTACKEDWIDGET_H
-#define QSTACKEDWIDGET_H
-
-#include <QtGui/qframe.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_STACKEDWIDGET
-
-class QStackedWidgetPrivate;
-
-class Q_GUI_EXPORT QStackedWidget : public QFrame
-{
- Q_OBJECT
-
- Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
- Q_PROPERTY(int count READ count)
-public:
- explicit QStackedWidget(QWidget *parent=0);
- ~QStackedWidget();
-
- int addWidget(QWidget *w);
- int insertWidget(int index, QWidget *w);
- void removeWidget(QWidget *w);
-
- QWidget *currentWidget() const;
- int currentIndex() const;
-
- int indexOf(QWidget *) const;
- QWidget *widget(int) const;
- int count() const;
-
-public Q_SLOTS:
- void setCurrentIndex(int index);
- void setCurrentWidget(QWidget *w);
-
-Q_SIGNALS:
- void currentChanged(int);
- void widgetRemoved(int index);
-
-protected:
- bool event(QEvent *e);
-
-private:
- Q_DISABLE_COPY(QStackedWidget)
- Q_DECLARE_PRIVATE(QStackedWidget)
-};
-
-#endif // QT_NO_STACKEDWIDGET
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSTACKEDWIDGET_H
diff --git a/src/gui/widgets/qstatusbar.h b/src/gui/widgets/qstatusbar.h
deleted file mode 100644
index 598aa4b890..0000000000
--- a/src/gui/widgets/qstatusbar.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSTATUSBAR_H
-#define QSTATUSBAR_H
-
-#include <QtGui/qwidget.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_STATUSBAR
-
-class QStatusBarPrivate;
-
-class Q_GUI_EXPORT QStatusBar: public QWidget
-{
- Q_OBJECT
-
- Q_PROPERTY(bool sizeGripEnabled READ isSizeGripEnabled WRITE setSizeGripEnabled)
-
-public:
- explicit QStatusBar(QWidget* parent=0);
- virtual ~QStatusBar();
-
- void addWidget(QWidget *widget, int stretch = 0);
- int insertWidget(int index, QWidget *widget, int stretch = 0);
- void addPermanentWidget(QWidget *widget, int stretch = 0);
- int insertPermanentWidget(int index, QWidget *widget, int stretch = 0);
- void removeWidget(QWidget *widget);
-
- void setSizeGripEnabled(bool);
- bool isSizeGripEnabled() const;
-
- QString currentMessage() const;
-
-public Q_SLOTS:
- void showMessage(const QString &text, int timeout = 0);
- void clearMessage();
-
-#ifdef QT3_SUPPORT
-public:
- QT3_SUPPORT_CONSTRUCTOR QStatusBar(QWidget* parent, const char* name);
- QT3_SUPPORT void addWidget(QWidget *w, int stretch, bool permanent)
- { if (permanent) addPermanentWidget(w, stretch); else addWidget(w, stretch); }
-public Q_SLOTS:
- inline QT_MOC_COMPAT void message(const QString &text, int timeout = 0) { showMessage(text, timeout); }
- inline QT_MOC_COMPAT void clear() { clearMessage(); }
-#endif
-
-Q_SIGNALS:
- void messageChanged(const QString &text);
-
-protected:
- void showEvent(QShowEvent *);
- void paintEvent(QPaintEvent *);
- void resizeEvent(QResizeEvent *);
-
- // ### Qt 5: consider making reformat() and hideOrShow() private
- void reformat();
- void hideOrShow();
- bool event(QEvent *);
-
-private:
- Q_DISABLE_COPY(QStatusBar)
- Q_DECLARE_PRIVATE(QStatusBar)
-};
-
-#endif // QT_NO_STATUSBAR
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSTATUSBAR_H
diff --git a/src/gui/widgets/qtabbar.h b/src/gui/widgets/qtabbar.h
deleted file mode 100644
index b558445fc9..0000000000
--- a/src/gui/widgets/qtabbar.h
+++ /dev/null
@@ -1,226 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTABBAR_H
-#define QTABBAR_H
-
-#include <QtGui/qwidget.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_TABBAR
-
-class QIcon;
-class QTabBarPrivate;
-class QStyleOptionTab;
-
-class Q_GUI_EXPORT QTabBar: public QWidget
-{
- Q_OBJECT
-
- Q_ENUMS(Shape)
- Q_PROPERTY(Shape shape READ shape WRITE setShape)
- Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
- Q_PROPERTY(int count READ count)
- Q_PROPERTY(bool drawBase READ drawBase WRITE setDrawBase)
- Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
- Q_PROPERTY(Qt::TextElideMode elideMode READ elideMode WRITE setElideMode)
- Q_PROPERTY(bool usesScrollButtons READ usesScrollButtons WRITE setUsesScrollButtons)
- Q_PROPERTY(bool tabsClosable READ tabsClosable WRITE setTabsClosable)
- Q_PROPERTY(SelectionBehavior selectionBehaviorOnRemove READ selectionBehaviorOnRemove WRITE setSelectionBehaviorOnRemove)
- Q_PROPERTY(bool expanding READ expanding WRITE setExpanding)
- Q_PROPERTY(bool movable READ isMovable WRITE setMovable)
- Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode)
-
-public:
- explicit QTabBar(QWidget* parent=0);
- ~QTabBar();
-
- enum Shape { RoundedNorth, RoundedSouth, RoundedWest, RoundedEast,
- TriangularNorth, TriangularSouth, TriangularWest, TriangularEast
-#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
- , RoundedAbove = RoundedNorth, RoundedBelow = RoundedSouth,
- TriangularAbove = TriangularNorth, TriangularBelow = TriangularSouth
-#endif
- };
-
- enum ButtonPosition {
- LeftSide,
- RightSide
- };
-
- enum SelectionBehavior {
- SelectLeftTab,
- SelectRightTab,
- SelectPreviousTab
- };
-
- Shape shape() const;
- void setShape(Shape shape);
-
- int addTab(const QString &text);
- int addTab(const QIcon &icon, const QString &text);
-
- int insertTab(int index, const QString &text);
- int insertTab(int index, const QIcon&icon, const QString &text);
-
- void removeTab(int index);
- void moveTab(int from, int to);
-
- bool isTabEnabled(int index) const;
- void setTabEnabled(int index, bool);
-
- QString tabText(int index) const;
- void setTabText(int index, const QString &text);
-
- QColor tabTextColor(int index) const;
- void setTabTextColor(int index, const QColor &color);
-
- QIcon tabIcon(int index) const;
- void setTabIcon(int index, const QIcon &icon);
-
- Qt::TextElideMode elideMode() const;
- void setElideMode(Qt::TextElideMode);
-
-#ifndef QT_NO_TOOLTIP
- void setTabToolTip(int index, const QString &tip);
- QString tabToolTip(int index) const;
-#endif
-
-#ifndef QT_NO_WHATSTHIS
- void setTabWhatsThis(int index, const QString &text);
- QString tabWhatsThis(int index) const;
-#endif
-
- void setTabData(int index, const QVariant &data);
- QVariant tabData(int index) const;
-
- QRect tabRect(int index) const;
- int tabAt(const QPoint &pos) const;
-
- int currentIndex() const;
- int count() const;
-
- QSize sizeHint() const;
- QSize minimumSizeHint() const;
-
- void setDrawBase(bool drawTheBase);
- bool drawBase() const;
-
- QSize iconSize() const;
- void setIconSize(const QSize &size);
-
- bool usesScrollButtons() const;
- void setUsesScrollButtons(bool useButtons);
-
- bool tabsClosable() const;
- void setTabsClosable(bool closable);
-
- void setTabButton(int index, ButtonPosition position, QWidget *widget);
- QWidget *tabButton(int index, ButtonPosition position) const;
-
- SelectionBehavior selectionBehaviorOnRemove() const;
- void setSelectionBehaviorOnRemove(SelectionBehavior behavior);
-
- bool expanding() const;
- void setExpanding(bool enabled);
-
- bool isMovable() const;
- void setMovable(bool movable);
-
- bool documentMode() const;
- void setDocumentMode(bool set);
-
-public Q_SLOTS:
- void setCurrentIndex(int index);
-
-Q_SIGNALS:
- void currentChanged(int index);
- void tabCloseRequested(int index);
- void tabMoved(int from, int to);
-
-protected:
- virtual QSize tabSizeHint(int index) const;
- virtual void tabInserted(int index);
- virtual void tabRemoved(int index);
- virtual void tabLayoutChange();
-
- bool event(QEvent *);
- void resizeEvent(QResizeEvent *);
- void showEvent(QShowEvent *);
- void hideEvent(QHideEvent *);
- void paintEvent(QPaintEvent *);
- void mousePressEvent (QMouseEvent *);
- void mouseMoveEvent (QMouseEvent *);
- void mouseReleaseEvent (QMouseEvent *);
-#ifndef QT_NO_WHEELEVENT
- void wheelEvent(QWheelEvent *event);
-#endif
- void keyPressEvent(QKeyEvent *);
- void changeEvent(QEvent *);
- void initStyleOption(QStyleOptionTab *option, int tabIndex) const;
-
-#ifdef QT3_SUPPORT
-public Q_SLOTS:
- QT_MOC_COMPAT void setCurrentTab(int index) { setCurrentIndex(index); }
-Q_SIGNALS:
- QT_MOC_COMPAT void selected(int);
-#endif
-
- friend class QAccessibleTabBar;
-private:
- Q_DISABLE_COPY(QTabBar)
- Q_DECLARE_PRIVATE(QTabBar)
- Q_PRIVATE_SLOT(d_func(), void _q_scrollTabs())
- Q_PRIVATE_SLOT(d_func(), void _q_closeTab())
-};
-
-#endif // QT_NO_TABBAR
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QTABBAR_H
diff --git a/src/gui/widgets/qtabwidget.h b/src/gui/widgets/qtabwidget.h
deleted file mode 100644
index b0e6fb3891..0000000000
--- a/src/gui/widgets/qtabwidget.h
+++ /dev/null
@@ -1,253 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTABWIDGET_H
-#define QTABWIDGET_H
-
-#include <QtGui/qwidget.h>
-#include <QtGui/qicon.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_TABWIDGET
-
-class QTabBar;
-class QTabWidgetPrivate;
-class QStyleOptionTabWidgetFrame;
-
-class Q_GUI_EXPORT QTabWidget : public QWidget
-{
- Q_OBJECT
- Q_ENUMS(TabPosition TabShape)
- Q_PROPERTY(TabPosition tabPosition READ tabPosition WRITE setTabPosition)
- Q_PROPERTY(TabShape tabShape READ tabShape WRITE setTabShape)
- Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
- Q_PROPERTY(int count READ count)
- Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
- Q_PROPERTY(Qt::TextElideMode elideMode READ elideMode WRITE setElideMode)
- Q_PROPERTY(bool usesScrollButtons READ usesScrollButtons WRITE setUsesScrollButtons)
- Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode)
- Q_PROPERTY(bool tabsClosable READ tabsClosable WRITE setTabsClosable)
- Q_PROPERTY(bool movable READ isMovable WRITE setMovable)
-
-public:
- explicit QTabWidget(QWidget *parent = 0);
- ~QTabWidget();
-
- int addTab(QWidget *widget, const QString &);
- int addTab(QWidget *widget, const QIcon& icon, const QString &label);
-
- int insertTab(int index, QWidget *widget, const QString &);
- int insertTab(int index, QWidget *widget, const QIcon& icon, const QString &label);
-
- void removeTab(int index);
-
- bool isTabEnabled(int index) const;
- void setTabEnabled(int index, bool);
-
- QString tabText(int index) const;
- void setTabText(int index, const QString &);
-
- QIcon tabIcon(int index) const;
- void setTabIcon(int index, const QIcon & icon);
-
-#ifndef QT_NO_TOOLTIP
- void setTabToolTip(int index, const QString & tip);
- QString tabToolTip(int index) const;
-#endif
-
-#ifndef QT_NO_WHATSTHIS
- void setTabWhatsThis(int index, const QString &text);
- QString tabWhatsThis(int index) const;
-#endif
-
- int currentIndex() const;
- QWidget *currentWidget() const;
- QWidget *widget(int index) const;
- int indexOf(QWidget *widget) const;
- int count() const;
-
- enum TabPosition { North, South, West, East
-#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
- , Top = North, Bottom = South
-#endif
- };
- TabPosition tabPosition() const;
- void setTabPosition(TabPosition);
-
- bool tabsClosable() const;
- void setTabsClosable(bool closeable);
-
- bool isMovable() const;
- void setMovable(bool movable);
-
- enum TabShape { Rounded, Triangular };
- TabShape tabShape() const;
- void setTabShape(TabShape s);
-
- QSize sizeHint() const;
- QSize minimumSizeHint() const;
- int heightForWidth(int width) const;
-
- void setCornerWidget(QWidget * w, Qt::Corner corner = Qt::TopRightCorner);
- QWidget * cornerWidget(Qt::Corner corner = Qt::TopRightCorner) const;
-
- Qt::TextElideMode elideMode() const;
- void setElideMode(Qt::TextElideMode);
-
- QSize iconSize() const;
- void setIconSize(const QSize &size);
-
- bool usesScrollButtons() const;
- void setUsesScrollButtons(bool useButtons);
-
- bool documentMode() const;
- void setDocumentMode(bool set);
-
- void clear();
-
-public Q_SLOTS:
- void setCurrentIndex(int index);
- void setCurrentWidget(QWidget *widget);
-
-Q_SIGNALS:
- void currentChanged(int index);
- void tabCloseRequested(int index);
-
-protected:
- virtual void tabInserted(int index);
- virtual void tabRemoved(int index);
-
- void showEvent(QShowEvent *);
- void resizeEvent(QResizeEvent *);
- void keyPressEvent(QKeyEvent *);
- void paintEvent(QPaintEvent *);
- void setTabBar(QTabBar *);
- QTabBar* tabBar() const;
- void changeEvent(QEvent *);
- bool event(QEvent *);
- void initStyleOption(QStyleOptionTabWidgetFrame *option) const;
-
-#ifdef QT3_SUPPORT
-public:
- QT3_SUPPORT_CONSTRUCTOR QTabWidget(QWidget *parent, const char *name, Qt::WindowFlags f = 0);
-
- inline QT3_SUPPORT void insertTab(QWidget * w, const QString &s, int index = -1) { insertTab(index, w, s); }
- inline QT3_SUPPORT void insertTab(QWidget *child, const QIcon& icon,
- const QString &label, int index = -1) { insertTab(index, child, icon, label); }
-
- inline QT3_SUPPORT void changeTab(QWidget *w, const QString &s) {setTabText(indexOf(w), s); }
- inline QT3_SUPPORT void changeTab(QWidget *w, const QIcon& icon,
- const QString &label) { int idx = indexOf(w); setTabText(idx, label); setTabIcon(idx, icon); }
-
- inline QT3_SUPPORT bool isTabEnabled( QWidget *w) const {return isTabEnabled(indexOf(w)); }
- inline QT3_SUPPORT void setTabEnabled(QWidget *w, bool b) { setTabEnabled(indexOf(w), b); }
-
- inline QT3_SUPPORT QString tabLabel(QWidget *w) const {return tabText(indexOf(w)); }
- inline QT3_SUPPORT void setTabLabel(QWidget *w, const QString &l) { setTabText(indexOf(w), l); }
-
- inline QT3_SUPPORT QIcon tabIconSet(QWidget * w) const {return tabIcon(indexOf(w)); }
- inline QT3_SUPPORT void setTabIconSet(QWidget * w, const QIcon & icon) { setTabIcon(indexOf(w), icon); }
-
- inline QT3_SUPPORT void removeTabToolTip(QWidget * w) {
-#ifndef QT_NO_TOOLTIP
- setTabToolTip(indexOf(w), QString());
-#else
- Q_UNUSED(w);
-#endif
- }
- inline QT3_SUPPORT void setTabToolTip(QWidget * w, const QString & tip) {
-#ifndef QT_NO_TOOLTIP
- setTabToolTip(indexOf(w), tip);
-#else
- Q_UNUSED(w);
- Q_UNUSED(tip);
-#endif
- }
-
- inline QT3_SUPPORT QString tabToolTip(QWidget * w) const {
-#ifndef QT_NO_TOOLTIP
- return tabToolTip(indexOf(w));
-#else
- Q_UNUSED(w);
- return QString();
-#endif
- }
-
- inline QT3_SUPPORT QWidget * currentPage() const { return currentWidget(); }
- inline QT3_SUPPORT QWidget *page(int index) const { return widget(index); }
- inline QT3_SUPPORT QString label(int index) const { return tabText(index); }
- inline QT3_SUPPORT int currentPageIndex() const { return currentIndex(); }
-
- inline QT3_SUPPORT int margin() const { return 0; }
- inline QT3_SUPPORT void setMargin(int) {}
-
-public Q_SLOTS:
- inline QT_MOC_COMPAT void setCurrentPage(int index) { setCurrentIndex(index); }
- inline QT_MOC_COMPAT void showPage(QWidget *w) { setCurrentIndex(indexOf(w)); }
- inline QT_MOC_COMPAT void removePage(QWidget *w) { removeTab(indexOf(w)); }
-
-Q_SIGNALS:
- QT_MOC_COMPAT void currentChanged(QWidget *);
- QT_MOC_COMPAT void selected(const QString&);
-#endif // QT3_SUPPORT
-
-private:
- Q_DECLARE_PRIVATE(QTabWidget)
- Q_DISABLE_COPY(QTabWidget)
- Q_PRIVATE_SLOT(d_func(), void _q_showTab(int))
- Q_PRIVATE_SLOT(d_func(), void _q_removeTab(int))
- Q_PRIVATE_SLOT(d_func(), void _q_tabMoved(int, int))
- void setUpLayout(bool = false);
- friend class Q3TabDialog;
-};
-
-#endif // QT_NO_TABWIDGET
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QTABWIDGET_H
diff --git a/src/gui/widgets/qtextbrowser.h b/src/gui/widgets/qtextbrowser.h
deleted file mode 100644
index a30ce4d705..0000000000
--- a/src/gui/widgets/qtextbrowser.h
+++ /dev/null
@@ -1,140 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTEXTBROWSER_H
-#define QTEXTBROWSER_H
-
-#include <QtGui/qtextedit.h>
-#include <QtCore/qurl.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_TEXTBROWSER
-
-class QTextBrowserPrivate;
-
-class Q_GUI_EXPORT QTextBrowser : public QTextEdit
-{
- Q_OBJECT
-
- Q_PROPERTY(QUrl source READ source WRITE setSource)
- Q_OVERRIDE(bool modified SCRIPTABLE false)
- Q_OVERRIDE(bool readOnly DESIGNABLE false SCRIPTABLE false)
- Q_OVERRIDE(bool undoRedoEnabled DESIGNABLE false SCRIPTABLE false)
- Q_PROPERTY(QStringList searchPaths READ searchPaths WRITE setSearchPaths)
- Q_PROPERTY(bool openExternalLinks READ openExternalLinks WRITE setOpenExternalLinks)
- Q_PROPERTY(bool openLinks READ openLinks WRITE setOpenLinks)
-
-public:
- explicit QTextBrowser(QWidget* parent = 0);
- virtual ~QTextBrowser();
-
- QUrl source() const;
-
- QStringList searchPaths() const;
- void setSearchPaths(const QStringList &paths);
-
- virtual QVariant loadResource(int type, const QUrl &name);
-
- bool isBackwardAvailable() const;
- bool isForwardAvailable() const;
- void clearHistory();
- QString historyTitle(int) const;
- QUrl historyUrl(int) const;
- int backwardHistoryCount() const;
- int forwardHistoryCount() const;
-
- bool openExternalLinks() const;
- void setOpenExternalLinks(bool open);
-
- bool openLinks() const;
- void setOpenLinks(bool open);
-
-public Q_SLOTS:
- virtual void setSource(const QUrl &name);
- virtual void backward();
- virtual void forward();
- virtual void home();
- virtual void reload();
-
-Q_SIGNALS:
- void backwardAvailable(bool);
- void forwardAvailable(bool);
- void historyChanged();
- void sourceChanged(const QUrl &);
- void highlighted(const QUrl &);
- void highlighted(const QString &);
- void anchorClicked(const QUrl &);
-
-protected:
- bool event(QEvent *e);
- virtual void keyPressEvent(QKeyEvent *ev);
- virtual void mouseMoveEvent(QMouseEvent *ev);
- virtual void mousePressEvent(QMouseEvent *ev);
- virtual void mouseReleaseEvent(QMouseEvent *ev);
- virtual void focusOutEvent(QFocusEvent *ev);
- virtual bool focusNextPrevChild(bool next);
- virtual void paintEvent(QPaintEvent *e);
-
-#if defined(QT3_SUPPORT)
-public:
- QT3_SUPPORT_CONSTRUCTOR QTextBrowser(QWidget *parent, const char *name);
-#endif
-
-private:
- Q_DISABLE_COPY(QTextBrowser)
- Q_DECLARE_PRIVATE(QTextBrowser)
- Q_PRIVATE_SLOT(d_func(), void _q_documentModified())
- Q_PRIVATE_SLOT(d_func(), void _q_activateAnchor(const QString &))
- Q_PRIVATE_SLOT(d_func(), void _q_highlightLink(const QString &))
-};
-
-#endif // QT_NO_TEXTBROWSER
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QTEXTBROWSER_H
diff --git a/src/gui/widgets/qtextedit.h b/src/gui/widgets/qtextedit.h
deleted file mode 100644
index d2d86d5ed7..0000000000
--- a/src/gui/widgets/qtextedit.h
+++ /dev/null
@@ -1,430 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTEXTEDIT_H
-#define QTEXTEDIT_H
-
-#include <QtGui/qabstractscrollarea.h>
-#include <QtGui/qtextdocument.h>
-#include <QtGui/qtextoption.h>
-#include <QtGui/qtextcursor.h>
-#include <QtGui/qtextformat.h>
-
-#ifndef QT_NO_TEXTEDIT
-
-#ifdef QT3_SUPPORT
-#include <QtGui/qtextobject.h>
-#include <QtGui/qtextlayout.h>
-#endif
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QStyleSheet;
-class QTextDocument;
-class QMenu;
-class QTextEditPrivate;
-class QMimeData;
-
-class Q_GUI_EXPORT QTextEdit : public QAbstractScrollArea
-{
- Q_OBJECT
- Q_DECLARE_PRIVATE(QTextEdit)
- Q_FLAGS(AutoFormatting)
- Q_ENUMS(LineWrapMode)
- Q_PROPERTY(AutoFormatting autoFormatting READ autoFormatting WRITE setAutoFormatting)
- Q_PROPERTY(bool tabChangesFocus READ tabChangesFocus WRITE setTabChangesFocus)
- Q_PROPERTY(QString documentTitle READ documentTitle WRITE setDocumentTitle)
- Q_PROPERTY(bool undoRedoEnabled READ isUndoRedoEnabled WRITE setUndoRedoEnabled)
- Q_PROPERTY(LineWrapMode lineWrapMode READ lineWrapMode WRITE setLineWrapMode)
- QDOC_PROPERTY(QTextOption::WrapMode wordWrapMode READ wordWrapMode WRITE setWordWrapMode)
- Q_PROPERTY(int lineWrapColumnOrWidth READ lineWrapColumnOrWidth WRITE setLineWrapColumnOrWidth)
- Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
-#ifndef QT_NO_TEXTHTMLPARSER
- Q_PROPERTY(QString html READ toHtml WRITE setHtml NOTIFY textChanged USER true)
-#endif
- Q_PROPERTY(QString plainText READ toPlainText WRITE setPlainText DESIGNABLE false)
- Q_PROPERTY(bool overwriteMode READ overwriteMode WRITE setOverwriteMode)
- Q_PROPERTY(int tabStopWidth READ tabStopWidth WRITE setTabStopWidth)
- Q_PROPERTY(bool acceptRichText READ acceptRichText WRITE setAcceptRichText)
- Q_PROPERTY(int cursorWidth READ cursorWidth WRITE setCursorWidth)
- Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
-public:
- enum LineWrapMode {
- NoWrap,
- WidgetWidth,
- FixedPixelWidth,
- FixedColumnWidth
- };
-
- enum AutoFormattingFlag {
- AutoNone = 0,
- AutoBulletList = 0x00000001,
- AutoAll = 0xffffffff
- };
-
- Q_DECLARE_FLAGS(AutoFormatting, AutoFormattingFlag)
-
-#if defined(QT3_SUPPORT)
- enum CursorAction {
- MoveBackward,
- MoveForward,
- MoveWordBackward,
- MoveWordForward,
- MoveUp,
- MoveDown,
- MoveLineStart,
- MoveLineEnd,
- MoveHome,
- MoveEnd,
- MovePageUp,
- MovePageDown
-#if !defined(Q_MOC_RUN)
- ,
- MovePgUp = MovePageUp,
- MovePgDown = MovePageDown
-#endif
- };
-#endif
-
- explicit QTextEdit(QWidget *parent = 0);
- explicit QTextEdit(const QString &text, QWidget *parent = 0);
- virtual ~QTextEdit();
-
- void setDocument(QTextDocument *document);
- QTextDocument *document() const;
-
- void setTextCursor(const QTextCursor &cursor);
- QTextCursor textCursor() const;
-
- bool isReadOnly() const;
- void setReadOnly(bool ro);
-
- void setTextInteractionFlags(Qt::TextInteractionFlags flags);
- Qt::TextInteractionFlags textInteractionFlags() const;
-
- qreal fontPointSize() const;
- QString fontFamily() const;
- int fontWeight() const;
- bool fontUnderline() const;
- bool fontItalic() const;
- QColor textColor() const;
- QColor textBackgroundColor() const;
- QFont currentFont() const;
- Qt::Alignment alignment() const;
-
- void mergeCurrentCharFormat(const QTextCharFormat &modifier);
-
- void setCurrentCharFormat(const QTextCharFormat &format);
- QTextCharFormat currentCharFormat() const;
-
- AutoFormatting autoFormatting() const;
- void setAutoFormatting(AutoFormatting features);
-
- bool tabChangesFocus() const;
- void setTabChangesFocus(bool b);
-
- inline void setDocumentTitle(const QString &title)
- { document()->setMetaInformation(QTextDocument::DocumentTitle, title); }
- inline QString documentTitle() const
- { return document()->metaInformation(QTextDocument::DocumentTitle); }
-
- inline bool isUndoRedoEnabled() const
- { return document()->isUndoRedoEnabled(); }
- inline void setUndoRedoEnabled(bool enable)
- { document()->setUndoRedoEnabled(enable); }
-
- LineWrapMode lineWrapMode() const;
- void setLineWrapMode(LineWrapMode mode);
-
- int lineWrapColumnOrWidth() const;
- void setLineWrapColumnOrWidth(int w);
-
- QTextOption::WrapMode wordWrapMode() const;
- void setWordWrapMode(QTextOption::WrapMode policy);
-
- bool find(const QString &exp, QTextDocument::FindFlags options = 0);
-
- inline QString toPlainText() const
- { return document()->toPlainText(); }
-#ifndef QT_NO_TEXTHTMLPARSER
- inline QString toHtml() const
- { return document()->toHtml(); }
-#endif
-
- void ensureCursorVisible();
-
- virtual QVariant loadResource(int type, const QUrl &name);
-#ifndef QT_NO_CONTEXTMENU
- QMenu *createStandardContextMenu();
- QMenu *createStandardContextMenu(const QPoint &position);
-#endif
-
- QTextCursor cursorForPosition(const QPoint &pos) const;
- QRect cursorRect(const QTextCursor &cursor) const;
- QRect cursorRect() const;
-
- QString anchorAt(const QPoint& pos) const;
-
- bool overwriteMode() const;
- void setOverwriteMode(bool overwrite);
-
- int tabStopWidth() const;
- void setTabStopWidth(int width);
-
- int cursorWidth() const;
- void setCursorWidth(int width);
-
- bool acceptRichText() const;
- void setAcceptRichText(bool accept);
-
- struct ExtraSelection
- {
- QTextCursor cursor;
- QTextCharFormat format;
- };
- void setExtraSelections(const QList<ExtraSelection> &selections);
- QList<ExtraSelection> extraSelections() const;
-
- void moveCursor(QTextCursor::MoveOperation operation, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor);
-
- bool canPaste() const;
-
-#ifndef QT_NO_PRINTER
- void print(QPrinter *printer) const;
-#endif
-
-public Q_SLOTS:
- void setFontPointSize(qreal s);
- void setFontFamily(const QString &fontFamily);
- void setFontWeight(int w);
- void setFontUnderline(bool b);
- void setFontItalic(bool b);
- void setTextColor(const QColor &c);
- void setTextBackgroundColor(const QColor &c);
- void setCurrentFont(const QFont &f);
- void setAlignment(Qt::Alignment a);
-
- void setPlainText(const QString &text);
-#ifndef QT_NO_TEXTHTMLPARSER
- void setHtml(const QString &text);
-#endif
- void setText(const QString &text);
-
-#ifndef QT_NO_CLIPBOARD
- void cut();
- void copy();
- void paste();
-#endif
-
- void undo();
- void redo();
-
- void clear();
- void selectAll();
-
- void insertPlainText(const QString &text);
-#ifndef QT_NO_TEXTHTMLPARSER
- void insertHtml(const QString &text);
-#endif // QT_NO_TEXTHTMLPARSER
-
- void append(const QString &text);
-
- void scrollToAnchor(const QString &name);
-
- void zoomIn(int range = 1);
- void zoomOut(int range = 1);
-
-Q_SIGNALS:
- void textChanged();
- void undoAvailable(bool b);
- void redoAvailable(bool b);
- void currentCharFormatChanged(const QTextCharFormat &format);
- void copyAvailable(bool b);
- void selectionChanged();
- void cursorPositionChanged();
-
-protected:
- virtual bool event(QEvent *e);
- virtual void timerEvent(QTimerEvent *e);
- virtual void keyPressEvent(QKeyEvent *e);
- virtual void keyReleaseEvent(QKeyEvent *e);
- virtual void resizeEvent(QResizeEvent *e);
- virtual void paintEvent(QPaintEvent *e);
- virtual void mousePressEvent(QMouseEvent *e);
- virtual void mouseMoveEvent(QMouseEvent *e);
- virtual void mouseReleaseEvent(QMouseEvent *e);
- virtual void mouseDoubleClickEvent(QMouseEvent *e);
- virtual bool focusNextPrevChild(bool next);
-#ifndef QT_NO_CONTEXTMENU
- virtual void contextMenuEvent(QContextMenuEvent *e);
-#endif
-#ifndef QT_NO_DRAGANDDROP
- virtual void dragEnterEvent(QDragEnterEvent *e);
- virtual void dragLeaveEvent(QDragLeaveEvent *e);
- virtual void dragMoveEvent(QDragMoveEvent *e);
- virtual void dropEvent(QDropEvent *e);
-#endif
- virtual void focusInEvent(QFocusEvent *e);
- virtual void focusOutEvent(QFocusEvent *e);
- virtual void showEvent(QShowEvent *);
- virtual void changeEvent(QEvent *e);
-#ifndef QT_NO_WHEELEVENT
- virtual void wheelEvent(QWheelEvent *e);
-#endif
-
- virtual QMimeData *createMimeDataFromSelection() const;
- virtual bool canInsertFromMimeData(const QMimeData *source) const;
- virtual void insertFromMimeData(const QMimeData *source);
-
- virtual void inputMethodEvent(QInputMethodEvent *);
- QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
-
- QTextEdit(QTextEditPrivate &dd, QWidget *parent);
-
- virtual void scrollContentsBy(int dx, int dy);
-
-#ifdef QT3_SUPPORT
-Q_SIGNALS:
- QT_MOC_COMPAT void currentFontChanged(const QFont &f);
- QT_MOC_COMPAT void currentColorChanged(const QColor &c);
-
-public:
- QT3_SUPPORT_CONSTRUCTOR QTextEdit(QWidget *parent, const char *name);
- inline QT3_SUPPORT bool find(const QString &exp, bool cs, bool wo)
- {
- QTextDocument::FindFlags flags = 0;
- if (cs)
- flags |= QTextDocument::FindCaseSensitively;
- if (wo)
- flags |= QTextDocument::FindWholeWords;
- return find(exp, flags);
- }
-
- inline QT3_SUPPORT void sync() {}
-
- QT3_SUPPORT void moveCursor(CursorAction action, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor);
- QT3_SUPPORT void moveCursor(CursorAction action, bool select);
-
- enum KeyboardAction {
- ActionBackspace,
- ActionDelete,
- ActionReturn,
- ActionKill,
- ActionWordBackspace,
- ActionWordDelete
- };
-
- QT3_SUPPORT void doKeyboardAction(KeyboardAction action);
-
- QT3_SUPPORT QString text() const;
- QT3_SUPPORT void setTextFormat(Qt::TextFormat);
- QT3_SUPPORT Qt::TextFormat textFormat() const;
-
- inline QT3_SUPPORT void setBold(bool b) { setFontWeight(b ? QFont::Bold : QFont::Normal); }
- inline QT3_SUPPORT void setUnderline(bool b) { setFontUnderline(b); }
- inline QT3_SUPPORT void setItalic(bool i) { setFontItalic(i); }
- inline QT3_SUPPORT void setFamily(const QString &family) { setFontFamily(family); }
- inline QT3_SUPPORT void setPointSize(int size) { setFontPointSize(size); }
-
- inline QT3_SUPPORT bool italic() const { return fontItalic(); }
- inline QT3_SUPPORT bool bold() const { return fontWeight() >= QFont::Bold; }
- inline QT3_SUPPORT bool underline() const { return fontUnderline(); }
- inline QT3_SUPPORT QString family() const { return fontFamily(); }
- inline QT3_SUPPORT int pointSize() const { return (int)(fontPointSize()+0.5); }
-
- inline QT3_SUPPORT bool hasSelectedText() const
- { return textCursor().hasSelection(); }
- inline QT3_SUPPORT QString selectedText() const
- { return textCursor().selectedText(); }
-
- inline QT3_SUPPORT bool isUndoAvailable() const
- { return document()->isUndoAvailable(); }
- inline QT3_SUPPORT bool isRedoAvailable() const
- { return document()->isRedoAvailable(); }
-
- inline QT3_SUPPORT void insert(const QString &text)
- { insertPlainText(text); }
-
- inline QT3_SUPPORT bool isModified() const
- { return document()->isModified(); }
-
- inline QT3_SUPPORT QColor color() const
- { return textColor(); }
-
-public Q_SLOTS:
- inline QT_MOC_COMPAT void setModified(bool m = true)
- { document()->setModified(m); }
-public:
- inline QT3_SUPPORT void undo() const
- { document()->undo(); }
- inline QT3_SUPPORT void redo() const
- { document()->redo(); }
-
-public Q_SLOTS:
- inline QT_MOC_COMPAT void setColor(const QColor &c)
- { setTextColor(c); }
-
-#endif
-
-private:
- Q_DISABLE_COPY(QTextEdit)
- Q_PRIVATE_SLOT(d_func(), void _q_repaintContents(const QRectF &r))
- Q_PRIVATE_SLOT(d_func(), void _q_currentCharFormatChanged(const QTextCharFormat &))
- Q_PRIVATE_SLOT(d_func(), void _q_adjustScrollbars())
- Q_PRIVATE_SLOT(d_func(), void _q_ensureVisible(const QRectF &))
- friend class QTextEditControl;
- friend class QTextDocument;
- friend class QTextControl;
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QTextEdit::AutoFormatting)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_TEXTEDIT
-
-#endif // QTEXTEDIT_H
diff --git a/src/gui/widgets/qtextedit_p.h b/src/gui/widgets/qtextedit_p.h
deleted file mode 100644
index 63941142a2..0000000000
--- a/src/gui/widgets/qtextedit_p.h
+++ /dev/null
@@ -1,141 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTEXTEDIT_P_H
-#define QTEXTEDIT_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "private/qabstractscrollarea_p.h"
-#include "QtGui/qtextdocumentfragment.h"
-#include "QtGui/qscrollbar.h"
-#include "QtGui/qtextcursor.h"
-#include "QtGui/qtextformat.h"
-#include "QtGui/qmenu.h"
-#include "QtGui/qabstracttextdocumentlayout.h"
-#include "QtCore/qbasictimer.h"
-#include "QtCore/qurl.h"
-#include "private/qtextcontrol_p.h"
-#include "qtextedit.h"
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_TEXTEDIT
-
-class QMimeData;
-class QTextEditPrivate : public QAbstractScrollAreaPrivate
-{
- Q_DECLARE_PUBLIC(QTextEdit)
-public:
- QTextEditPrivate();
-
- void init(const QString &html = QString());
- void paint(QPainter *p, QPaintEvent *e);
- void _q_repaintContents(const QRectF &contentsRect);
-
- inline QPoint mapToContents(const QPoint &point) const
- { return QPoint(point.x() + horizontalOffset(), point.y() + verticalOffset()); }
-
- void _q_adjustScrollbars();
- void _q_ensureVisible(const QRectF &rect);
- void relayoutDocument();
-
- void createAutoBulletList();
- void pageUpDown(QTextCursor::MoveOperation op, QTextCursor::MoveMode moveMode);
-
- inline int horizontalOffset() const
- { return q_func()->isRightToLeft() ? (hbar->maximum() - hbar->value()) : hbar->value(); }
- inline int verticalOffset() const
- { return vbar->value(); }
-
- inline void sendControlEvent(QEvent *e)
- { control->processEvent(e, QPointF(horizontalOffset(), verticalOffset()), viewport); }
-
- void _q_currentCharFormatChanged(const QTextCharFormat &format);
-
- void updateDefaultTextOption();
-
- // re-implemented by QTextBrowser, called by QTextDocument::loadResource
- virtual QUrl resolveUrl(const QUrl &url) const
- { return url; }
-
- QTextControl *control;
-
- QTextEdit::AutoFormatting autoFormatting;
- bool tabChangesFocus;
-
- QBasicTimer autoScrollTimer;
- QPoint autoScrollDragPos;
-
- QTextEdit::LineWrapMode lineWrap;
- int lineWrapColumnOrWidth;
- QTextOption::WrapMode wordWrap;
-
- uint ignoreAutomaticScrollbarAdjustment : 1;
- uint preferRichText : 1;
- uint showCursorOnInitialShow : 1;
- uint inDrag : 1;
- uint clickCausedFocus : 1;
-
- // Qt3 COMPAT only, for setText
- Qt::TextFormat textFormat;
-
- QString anchorToScrollToWhenVisible;
-
-#ifdef QT_KEYPAD_NAVIGATION
- QBasicTimer deleteAllTimer;
-#endif
-};
-#endif // QT_NO_TEXTEDIT
-
-
-QT_END_NAMESPACE
-
-#endif // QTEXTEDIT_P_H
diff --git a/src/gui/widgets/qtoolbar.h b/src/gui/widgets/qtoolbar.h
deleted file mode 100644
index 116086ae7a..0000000000
--- a/src/gui/widgets/qtoolbar.h
+++ /dev/null
@@ -1,188 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDYNAMICTOOLBAR_H
-#define QDYNAMICTOOLBAR_H
-
-#include <QtGui/qwidget.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_TOOLBAR
-
-class QToolBarPrivate;
-
-class QAction;
-class QIcon;
-class QMainWindow;
-class QStyleOptionToolBar;
-
-class Q_GUI_EXPORT QToolBar : public QWidget
-{
- Q_OBJECT
-
- Q_PROPERTY(bool movable READ isMovable WRITE setMovable
- DESIGNABLE (qobject_cast<QMainWindow *>(parentWidget()) != 0)
- NOTIFY movableChanged)
- Q_PROPERTY(Qt::ToolBarAreas allowedAreas READ allowedAreas WRITE setAllowedAreas
- DESIGNABLE (qobject_cast<QMainWindow *>(parentWidget()) != 0)
- NOTIFY allowedAreasChanged)
- Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation
- DESIGNABLE (qobject_cast<QMainWindow *>(parentWidget()) == 0)
- NOTIFY orientationChanged)
- Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize NOTIFY iconSizeChanged)
- Q_PROPERTY(Qt::ToolButtonStyle toolButtonStyle READ toolButtonStyle WRITE setToolButtonStyle
- NOTIFY toolButtonStyleChanged)
- Q_PROPERTY(bool floating READ isFloating)
- Q_PROPERTY(bool floatable READ isFloatable WRITE setFloatable)
-
-public:
- explicit QToolBar(const QString &title, QWidget *parent = 0);
- explicit QToolBar(QWidget *parent = 0);
- ~QToolBar();
-
- void setMovable(bool movable);
- bool isMovable() const;
-
- void setAllowedAreas(Qt::ToolBarAreas areas);
- Qt::ToolBarAreas allowedAreas() const;
-
- inline bool isAreaAllowed(Qt::ToolBarArea area) const
- { return (allowedAreas() & area) == area; }
-
- void setOrientation(Qt::Orientation orientation);
- Qt::Orientation orientation() const;
-
- void clear();
-
-#ifdef Q_NO_USING_KEYWORD
- inline void addAction(QAction *action)
- { QWidget::addAction(action); }
-#else
- using QWidget::addAction;
-#endif
-
- QAction *addAction(const QString &text);
- QAction *addAction(const QIcon &icon, const QString &text);
- QAction *addAction(const QString &text, const QObject *receiver, const char* member);
- QAction *addAction(const QIcon &icon, const QString &text,
- const QObject *receiver, const char* member);
-
- QAction *addSeparator();
- QAction *insertSeparator(QAction *before);
-
- QAction *addWidget(QWidget *widget);
- QAction *insertWidget(QAction *before, QWidget *widget);
-
- QRect actionGeometry(QAction *action) const;
- QAction *actionAt(const QPoint &p) const;
- inline QAction *actionAt(int x, int y) const;
-
- QAction *toggleViewAction() const;
-
- QSize iconSize() const;
- Qt::ToolButtonStyle toolButtonStyle() const;
-
- QWidget *widgetForAction(QAction *action) const;
-
- bool isFloatable() const;
- void setFloatable(bool floatable);
- bool isFloating() const;
-
-public Q_SLOTS:
- void setIconSize(const QSize &iconSize);
- void setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle);
-
-Q_SIGNALS:
- void actionTriggered(QAction *action);
- void movableChanged(bool movable);
- void allowedAreasChanged(Qt::ToolBarAreas allowedAreas);
- void orientationChanged(Qt::Orientation orientation);
- void iconSizeChanged(const QSize &iconSize);
- void toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle);
- void topLevelChanged(bool topLevel);
- void visibilityChanged(bool visible);
-
-protected:
- void actionEvent(QActionEvent *event);
- void changeEvent(QEvent *event);
- void childEvent(QChildEvent *event);
- void paintEvent(QPaintEvent *event);
- void resizeEvent(QResizeEvent *event);
- bool event(QEvent *event);
- void initStyleOption(QStyleOptionToolBar *option) const;
-
-#ifdef QT3_SUPPORT
-public:
- QT3_SUPPORT_CONSTRUCTOR QToolBar(QWidget *parent, const char *name);
- inline QT3_SUPPORT void setLabel(const QString &label)
- { setWindowTitle(label); }
- inline QT3_SUPPORT QString label() const
- { return windowTitle(); }
-#endif
-
-private:
- Q_DECLARE_PRIVATE(QToolBar)
- Q_DISABLE_COPY(QToolBar)
- Q_PRIVATE_SLOT(d_func(), void _q_toggleView(bool))
- Q_PRIVATE_SLOT(d_func(), void _q_updateIconSize(const QSize &))
- Q_PRIVATE_SLOT(d_func(), void _q_updateToolButtonStyle(Qt::ToolButtonStyle))
-
- friend class QMainWindow;
- friend class QMainWindowLayout;
- friend class QToolBarLayout;
- friend class QToolBarAreaLayout;
-};
-
-inline QAction *QToolBar::actionAt(int ax, int ay) const
-{ return actionAt(QPoint(ax, ay)); }
-
-#endif // QT_NO_TOOLBAR
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QDYNAMICTOOLBAR_H
diff --git a/src/gui/widgets/qtoolbar_p.h b/src/gui/widgets/qtoolbar_p.h
deleted file mode 100644
index 3970c359e1..0000000000
--- a/src/gui/widgets/qtoolbar_p.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDYNAMICTOOLBAR_P_H
-#define QDYNAMICTOOLBAR_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qtoolbar.h"
-#include "QtGui/qaction.h"
-#include "private/qwidget_p.h"
-#include <QtCore/qbasictimer.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_TOOLBAR
-
-class QToolBarLayout;
-class QTimer;
-
-class QToolBarPrivate : public QWidgetPrivate
-{
- Q_DECLARE_PUBLIC(QToolBar)
-
-public:
- inline QToolBarPrivate()
- : explicitIconSize(false), explicitToolButtonStyle(false), movable(true), floatable(true),
- allowedAreas(Qt::AllToolBarAreas), orientation(Qt::Horizontal),
- toolButtonStyle(Qt::ToolButtonIconOnly),
- layout(0), state(0)
-#ifdef Q_WS_MAC
- , macWindowDragging(false)
-#endif
- { }
-
- void init();
- void actionTriggered();
- void _q_toggleView(bool b);
- void _q_updateIconSize(const QSize &sz);
- void _q_updateToolButtonStyle(Qt::ToolButtonStyle style);
-
- bool explicitIconSize;
- bool explicitToolButtonStyle;
- bool movable;
- bool floatable;
- Qt::ToolBarAreas allowedAreas;
- Qt::Orientation orientation;
- Qt::ToolButtonStyle toolButtonStyle;
- QSize iconSize;
-
- QAction *toggleViewAction;
-
- QToolBarLayout *layout;
-
- struct DragState {
- QPoint pressPos;
- bool dragging;
- bool moving;
- QLayoutItem *widgetItem;
- };
- DragState *state;
-
-#ifdef Q_WS_MAC
- bool macWindowDragging;
- QPoint macWindowDragPressPosition;
-#endif
-
- bool mousePressEvent(QMouseEvent *e);
- bool mouseReleaseEvent(QMouseEvent *e);
- bool mouseMoveEvent(QMouseEvent *e);
-
- void updateWindowFlags(bool floating, bool unplug = false);
- void setWindowState(bool floating, bool unplug = false, const QRect &rect = QRect());
- void initDrag(const QPoint &pos);
- void startDrag(bool moving = false);
- void endDrag();
-
- void unplug(const QRect &r);
- void plug(const QRect &r);
-
- QBasicTimer waitForPopupTimer;
-};
-
-#endif // QT_NO_TOOLBAR
-
-QT_END_NAMESPACE
-
-#endif // QDYNAMICTOOLBAR_P_H
diff --git a/src/gui/widgets/qtoolbarextension_p.h b/src/gui/widgets/qtoolbarextension_p.h
deleted file mode 100644
index 533adf1c4f..0000000000
--- a/src/gui/widgets/qtoolbarextension_p.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDYNAMICTOOLBAREXTENSION_P_H
-#define QDYNAMICTOOLBAREXTENSION_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "QtGui/qtoolbutton.h"
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_TOOLBUTTON
-
-class Q_AUTOTEST_EXPORT QToolBarExtension : public QToolButton
-{
- Q_OBJECT
- Qt::Orientation orientation;
-
-public:
- explicit QToolBarExtension(QWidget *parent);
- void paintEvent(QPaintEvent *);
- QSize sizeHint() const;
-
-public Q_SLOTS:
- void setOrientation(Qt::Orientation o);
-};
-
-#endif // QT_NO_TOOLBUTTON
-
-QT_END_NAMESPACE
-
-#endif // QDYNAMICTOOLBAREXTENSION_P_H
diff --git a/src/gui/widgets/qtoolbarlayout_p.h b/src/gui/widgets/qtoolbarlayout_p.h
deleted file mode 100644
index 5b234d69ad..0000000000
--- a/src/gui/widgets/qtoolbarlayout_p.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTOOLBARLAYOUT_P_H
-#define QTOOLBARLAYOUT_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtGui/qlayout.h>
-#include <private/qlayoutengine_p.h>
-#include <QVector>
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_TOOLBAR
-
-class QAction;
-class QToolBarExtension;
-class QMenu;
-
-class QToolBarItem : public QWidgetItem
-{
-public:
- QToolBarItem(QWidget *widget);
- bool isEmpty() const;
-
- QAction *action;
- bool customWidget;
-};
-
-class QToolBarLayout : public QLayout
-{
- Q_OBJECT
-
-public:
- QToolBarLayout(QWidget *parent = 0);
- ~QToolBarLayout();
-
- void addItem(QLayoutItem *item);
- QLayoutItem *itemAt(int index) const;
- QLayoutItem *takeAt(int index);
- int count() const;
-
- bool isEmpty() const;
- void invalidate();
- Qt::Orientations expandingDirections() const;
-
- void setGeometry(const QRect &r);
- QSize minimumSize() const;
- QSize sizeHint() const;
-
- void insertAction(int index, QAction *action);
- int indexOf(QAction *action) const;
- int indexOf(QWidget *widget) const { return QLayout::indexOf(widget); }
-
- bool layoutActions(const QSize &size);
- QSize expandedSize(const QSize &size) const;
- bool expanded, animating;
-
- void setUsePopupMenu(bool set); // Yeah, there's no getter, but it's internal.
- void checkUsePopupMenu();
-
- bool movable() const;
- void updateMarginAndSpacing();
- bool hasExpandFlag() const;
-
-public Q_SLOTS:
- void setExpanded(bool b);
-
-private:
- QList<QToolBarItem*> items;
- QSize hint, minSize;
- bool dirty, expanding, empty, expandFlag;
- QVector<QLayoutStruct> geomArray;
- QRect handRect;
- QToolBarExtension *extension;
-
- void updateGeomArray() const;
- QToolBarItem *createItem(QAction *action);
- QMenu *popupMenu;
-};
-
-#endif // QT_NO_TOOLBAR
-
-QT_END_NAMESPACE
-
-#endif // QTOOLBARLAYOUT_P_H
diff --git a/src/gui/widgets/qtoolbarseparator_p.h b/src/gui/widgets/qtoolbarseparator_p.h
deleted file mode 100644
index b2029fa53d..0000000000
--- a/src/gui/widgets/qtoolbarseparator_p.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDYNAMICTOOLBARSEPARATOR_P_H
-#define QDYNAMICTOOLBARSEPARATOR_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "QtGui/qwidget.h"
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_NO_TOOLBAR
-
-class QStyleOption;
-class QToolBar;
-
-class QToolBarSeparator : public QWidget
-{
- Q_OBJECT
- Qt::Orientation orient;
-
-public:
- explicit QToolBarSeparator(QToolBar *parent);
-
- Qt::Orientation orientation() const;
-
- QSize sizeHint() const;
-
- void paintEvent(QPaintEvent *);
- void initStyleOption(QStyleOption *option) const;
-
-public Q_SLOTS:
- void setOrientation(Qt::Orientation orientation);
-};
-
-#endif // QT_NO_TOOLBAR
-
-QT_END_NAMESPACE
-
-#endif // QDYNAMICTOOLBARSEPARATOR_P_H
diff --git a/src/gui/widgets/qtoolbox.h b/src/gui/widgets/qtoolbox.h
deleted file mode 100644
index f004ee7b04..0000000000
--- a/src/gui/widgets/qtoolbox.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTOOLBOX_H
-#define QTOOLBOX_H
-
-#include <QtGui/qframe.h>
-#include <QtGui/qicon.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_TOOLBOX
-
-class QToolBoxPrivate;
-
-class Q_GUI_EXPORT QToolBox : public QFrame
-{
- Q_OBJECT
- Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
- Q_PROPERTY(int count READ count)
-
-public:
- explicit QToolBox(QWidget *parent = 0, Qt::WindowFlags f = 0);
- ~QToolBox();
-
- int addItem(QWidget *widget, const QString &text);
- int addItem(QWidget *widget, const QIcon &icon, const QString &text);
- int insertItem(int index, QWidget *widget, const QString &text);
- int insertItem(int index, QWidget *widget, const QIcon &icon, const QString &text);
-
- void removeItem(int index);
-
- void setItemEnabled(int index, bool enabled);
- bool isItemEnabled(int index) const;
-
- void setItemText(int index, const QString &text);
- QString itemText(int index) const;
-
- void setItemIcon(int index, const QIcon &icon);
- QIcon itemIcon(int index) const;
-
-#ifndef QT_NO_TOOLTIP
- void setItemToolTip(int index, const QString &toolTip);
- QString itemToolTip(int index) const;
-#endif
-
- int currentIndex() const;
- QWidget *currentWidget() const;
- QWidget *widget(int index) const;
- int indexOf(QWidget *widget) const;
- int count() const;
-
-public Q_SLOTS:
- void setCurrentIndex(int index);
- void setCurrentWidget(QWidget *widget);
-
-Q_SIGNALS:
- void currentChanged(int index);
-
-protected:
- bool event(QEvent *e);
- virtual void itemInserted(int index);
- virtual void itemRemoved(int index);
- void showEvent(QShowEvent *e);
- void changeEvent(QEvent *);
-
-#ifdef QT3_SUPPORT
-public:
- QT3_SUPPORT_CONSTRUCTOR QToolBox(QWidget *parent, const char *name, Qt::WindowFlags f = 0);
- inline QT3_SUPPORT void setItemLabel(int index, const QString &text) { setItemText(index, text); }
- inline QT3_SUPPORT QString itemLabel(int index) const { return itemText(index); }
- inline QT3_SUPPORT QWidget *currentItem() const { return widget(currentIndex()); }
- inline QT3_SUPPORT void setCurrentItem(QWidget *item) { setCurrentIndex(indexOf(item)); }
- inline QT3_SUPPORT void setItemIconSet(int index, const QIcon &icon) { setItemIcon(index, icon); }
- inline QT3_SUPPORT QIcon itemIconSet(int index) const { return itemIcon(index); }
- inline QT3_SUPPORT int removeItem(QWidget *item)
- { int i = indexOf(item); removeItem(i); return i; }
- inline QT3_SUPPORT QWidget *item(int index) const { return widget(index); }
- QT3_SUPPORT void setMargin(int margin) { setContentsMargins(margin, margin, margin, margin); }
- QT3_SUPPORT int margin() const
- { int margin; int dummy; getContentsMargins(&margin, &dummy, &dummy, &dummy); return margin; }
-#endif
-
-private:
- Q_DECLARE_PRIVATE(QToolBox)
- Q_DISABLE_COPY(QToolBox)
- Q_PRIVATE_SLOT(d_func(), void _q_buttonClicked())
- Q_PRIVATE_SLOT(d_func(), void _q_widgetDestroyed(QObject*))
-};
-
-
-inline int QToolBox::addItem(QWidget *item, const QString &text)
-{ return insertItem(-1, item, QIcon(), text); }
-inline int QToolBox::addItem(QWidget *item, const QIcon &iconSet,
- const QString &text)
-{ return insertItem(-1, item, iconSet, text); }
-inline int QToolBox::insertItem(int index, QWidget *item, const QString &text)
-{ return insertItem(index, item, QIcon(), text); }
-
-#endif // QT_NO_TOOLBOX
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QTOOLBOX_H
diff --git a/src/gui/widgets/qtoolbutton.h b/src/gui/widgets/qtoolbutton.h
deleted file mode 100644
index 6b5f70210e..0000000000
--- a/src/gui/widgets/qtoolbutton.h
+++ /dev/null
@@ -1,199 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTOOLBUTTON_H
-#define QTOOLBUTTON_H
-
-#include <QtGui/qabstractbutton.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_TOOLBUTTON
-
-class QToolButtonPrivate;
-class QMenu;
-class QStyleOptionToolButton;
-
-class Q_GUI_EXPORT QToolButton : public QAbstractButton
-{
- Q_OBJECT
- Q_ENUMS(Qt::ToolButtonStyle Qt::ArrowType ToolButtonPopupMode)
-#ifndef QT_NO_MENU
- Q_PROPERTY(ToolButtonPopupMode popupMode READ popupMode WRITE setPopupMode)
-#endif
- Q_PROPERTY(Qt::ToolButtonStyle toolButtonStyle READ toolButtonStyle WRITE setToolButtonStyle)
- Q_PROPERTY(bool autoRaise READ autoRaise WRITE setAutoRaise)
- Q_PROPERTY(Qt::ArrowType arrowType READ arrowType WRITE setArrowType)
-
-public:
- enum ToolButtonPopupMode {
- DelayedPopup,
- MenuButtonPopup,
- InstantPopup
- };
-
- explicit QToolButton(QWidget * parent=0);
- ~QToolButton();
-
- QSize sizeHint() const;
- QSize minimumSizeHint() const;
-
- Qt::ToolButtonStyle toolButtonStyle() const;
-
- Qt::ArrowType arrowType() const;
- void setArrowType(Qt::ArrowType type);
-
-#ifndef QT_NO_MENU
- void setMenu(QMenu* menu);
- QMenu* menu() const;
-
- void setPopupMode(ToolButtonPopupMode mode);
- ToolButtonPopupMode popupMode() const;
-#endif
-
- QAction *defaultAction() const;
-
- void setAutoRaise(bool enable);
- bool autoRaise() const;
-
-public Q_SLOTS:
-#ifndef QT_NO_MENU
- void showMenu();
-#endif
- void setToolButtonStyle(Qt::ToolButtonStyle style);
- void setDefaultAction(QAction *);
-
-Q_SIGNALS:
- void triggered(QAction *);
-
-protected:
- QToolButton(QToolButtonPrivate &, QWidget* parent);
- bool event(QEvent *e);
- void mousePressEvent(QMouseEvent *);
- void mouseReleaseEvent(QMouseEvent *);
- void paintEvent(QPaintEvent *);
- void actionEvent(QActionEvent *);
-
- void enterEvent(QEvent *);
- void leaveEvent(QEvent *);
- void timerEvent(QTimerEvent *);
- void changeEvent(QEvent *);
-
- bool hitButton(const QPoint &pos) const;
- void nextCheckState();
- void initStyleOption(QStyleOptionToolButton *option) const;
-
-private:
- Q_DISABLE_COPY(QToolButton)
- Q_DECLARE_PRIVATE(QToolButton)
-#ifndef QT_NO_MENU
- Q_PRIVATE_SLOT(d_func(), void _q_buttonPressed())
- Q_PRIVATE_SLOT(d_func(), void _q_updateButtonDown())
- Q_PRIVATE_SLOT(d_func(), void _q_menuTriggered(QAction*))
-#endif
- Q_PRIVATE_SLOT(d_func(), void _q_actionTriggered())
-
-#ifdef QT3_SUPPORT
-public:
- enum TextPosition {
- BesideIcon,
- BelowIcon
- , Right = BesideIcon,
- Under = BelowIcon
- };
-
- QT3_SUPPORT_CONSTRUCTOR QToolButton(QWidget * parent, const char* name);
- QT3_SUPPORT_CONSTRUCTOR QToolButton(Qt::ArrowType type, QWidget *parent, const char* name);
- QT3_SUPPORT_CONSTRUCTOR QToolButton( const QIcon& s, const QString &textLabel,
- const QString& grouptext,
- QObject * receiver, const char* slot,
- QWidget * parent, const char* name=0 );
- inline QT3_SUPPORT void setPixmap(const QPixmap &pixmap) { setIcon(static_cast<QIcon>(pixmap)); }
- QT3_SUPPORT void setOnIconSet(const QIcon&);
- QT3_SUPPORT void setOffIconSet(const QIcon&);
- inline QT3_SUPPORT void setIconSet(const QIcon &icon){setIcon(icon);}
- QT3_SUPPORT void setIconSet(const QIcon &, bool on);
- inline QT3_SUPPORT void setTextLabel(const QString &text, bool tooltip = true) {
- setText(text);
-#ifndef QT_NO_TOOLTIP
- if (tooltip)
- setToolTip(text);
-#else
- Q_UNUSED(tooltip);
-#endif
- }
- inline QT3_SUPPORT QString textLabel() const { return text(); }
- QT3_SUPPORT QIcon onIconSet() const;
- QT3_SUPPORT QIcon offIconSet() const;
- QT3_SUPPORT QIcon iconSet(bool on) const;
- inline QT3_SUPPORT QIcon iconSet() const { return icon(); }
- inline QT3_SUPPORT void openPopup() { showMenu(); }
- inline QT3_SUPPORT void setPopup(QMenu* popup) {setMenu(popup); }
- inline QT3_SUPPORT QMenu* popup() const { return menu(); }
- inline QT3_SUPPORT bool usesBigPixmap() const { return iconSize().height() > 22; }
- inline QT3_SUPPORT bool usesTextLabel() const { return toolButtonStyle() != Qt::ToolButtonIconOnly; }
- inline QT3_SUPPORT TextPosition textPosition() const
- { return toolButtonStyle() == Qt::ToolButtonTextUnderIcon ? BelowIcon : BesideIcon; }
- QT3_SUPPORT void setPopupDelay(int delay);
- QT3_SUPPORT int popupDelay() const;
-
-public Q_SLOTS:
- QT_MOC_COMPAT void setUsesBigPixmap(bool enable)
- { setIconSize(enable?QSize(32,32):QSize(22,22)); }
- QT_MOC_COMPAT void setUsesTextLabel(bool enable)
- { setToolButtonStyle(enable?Qt::ToolButtonTextUnderIcon : Qt::ToolButtonIconOnly); }
- QT_MOC_COMPAT void setTextPosition(QToolButton::TextPosition pos)
- { setToolButtonStyle(pos == BesideIcon ? Qt::ToolButtonTextBesideIcon : Qt::ToolButtonTextUnderIcon); }
-
-#endif
-};
-
-#endif // QT_NO_TOOLBUTTON
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QTOOLBUTTON_H
diff --git a/src/gui/widgets/qwidgetanimator.cpp b/src/gui/widgets/qwidgetanimator.cpp
deleted file mode 100644
index 7530412c09..0000000000
--- a/src/gui/widgets/qwidgetanimator.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore/qpropertyanimation.h>
-#include <QtGui/qwidget.h>
-#include <QtGui/private/qmainwindowlayout_p.h>
-
-#include "qwidgetanimator_p.h"
-
-QT_BEGIN_NAMESPACE
-
-QWidgetAnimator::QWidgetAnimator(QMainWindowLayout *layout) : m_mainWindowLayout(layout)
-{
-}
-
-void QWidgetAnimator::abort(QWidget *w)
-{
-#ifndef QT_NO_ANIMATION
- AnimationMap::iterator it = m_animation_map.find(w);
- if (it == m_animation_map.end())
- return;
- QPropertyAnimation *anim = *it;
- m_animation_map.erase(it);
- anim->stop();
-#ifndef QT_NO_MAINWINDOW
- m_mainWindowLayout->animationFinished(w);
-#endif
-#else
- Q_UNUSED(w); //there is no animation to abort
-#endif //QT_NO_ANIMATION
-}
-
-#ifndef QT_NO_ANIMATION
-void QWidgetAnimator::animationFinished()
-{
- QPropertyAnimation *anim = qobject_cast<QPropertyAnimation*>(sender());
- abort(static_cast<QWidget*>(anim->targetObject()));
-}
-#endif //QT_NO_ANIMATION
-
-void QWidgetAnimator::animate(QWidget *widget, const QRect &_final_geometry, bool animate)
-{
- QRect r = widget->geometry();
- if (r.right() < 0 || r.bottom() < 0)
- r = QRect();
-
- animate = animate && !r.isNull() && !_final_geometry.isNull();
-
- // might make the wigdet go away by sending it to negative space
- const QRect final_geometry = _final_geometry.isValid() || widget->isWindow() ? _final_geometry :
- QRect(QPoint(-500 - widget->width(), -500 - widget->height()), widget->size());
-
-#ifndef QT_NO_ANIMATION
- AnimationMap::const_iterator it = m_animation_map.constFind(widget);
- if (it != m_animation_map.constEnd() && (*it)->endValue().toRect() == final_geometry)
- return;
-
- QPropertyAnimation *anim = new QPropertyAnimation(widget, "geometry", widget);
- anim->setDuration(animate ? 200 : 0);
- anim->setEasingCurve(QEasingCurve::InOutQuad);
- anim->setEndValue(final_geometry);
- m_animation_map[widget] = anim;
- connect(anim, SIGNAL(finished()), SLOT(animationFinished()));
- anim->start(QPropertyAnimation::DeleteWhenStopped);
-#else
- //we do it in one shot
- widget->setGeometry(final_geometry);
-#ifndef QT_NO_MAINWINDOW
- m_mainWindowLayout->animationFinished(widget);
-#endif //QT_NO_MAINWINDOW
-#endif //QT_NO_ANIMATION
-}
-
-bool QWidgetAnimator::animating() const
-{
- return !m_animation_map.isEmpty();
-}
-
-QT_END_NAMESPACE
diff --git a/src/gui/widgets/qworkspace.h b/src/gui/widgets/qworkspace.h
deleted file mode 100644
index f0b7c26867..0000000000
--- a/src/gui/widgets/qworkspace.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWORKSPACE_H
-#define QWORKSPACE_H
-
-#include <QtGui/qwidget.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#ifndef QT_NO_WORKSPACE
-
-class QAction;
-class QWorkspaceChild;
-class QShowEvent;
-class QWorkspacePrivate;
-
-class Q_GUI_EXPORT QWorkspace : public QWidget
-{
- Q_OBJECT
- Q_PROPERTY(bool scrollBarsEnabled READ scrollBarsEnabled WRITE setScrollBarsEnabled)
- Q_PROPERTY(QBrush background READ background WRITE setBackground)
-
-public:
- explicit QWorkspace(QWidget* parent=0);
- ~QWorkspace();
-
- enum WindowOrder { CreationOrder, StackingOrder };
-
- QWidget* activeWindow() const;
- QWidgetList windowList(WindowOrder order = CreationOrder) const;
-
- QWidget * addWindow(QWidget *w, Qt::WindowFlags flags = 0);
-
- QSize sizeHint() const;
-
- bool scrollBarsEnabled() const;
- void setScrollBarsEnabled(bool enable);
-
-#ifdef QT3_SUPPORT
- QT3_SUPPORT_CONSTRUCTOR QWorkspace(QWidget* parent, const char* name);
- QT3_SUPPORT void setPaletteBackgroundColor(const QColor &);
- QT3_SUPPORT void setPaletteBackgroundPixmap(const QPixmap &);
-#endif
-
- void setBackground(const QBrush &background);
- QBrush background() const;
-
-Q_SIGNALS:
- void windowActivated(QWidget* w);
-
-public Q_SLOTS:
- void setActiveWindow(QWidget *w);
- void cascade();
- void tile();
- void arrangeIcons();
- void closeActiveWindow();
- void closeAllWindows();
- void activateNextWindow();
- void activatePreviousWindow();
-
-protected:
- bool event(QEvent *e);
- void paintEvent(QPaintEvent *e);
- void changeEvent(QEvent *);
- void childEvent(QChildEvent *);
- void resizeEvent(QResizeEvent *);
- bool eventFilter(QObject *, QEvent *);
- void showEvent(QShowEvent *e);
- void hideEvent(QHideEvent *e);
-#ifndef QT_NO_WHEELEVENT
- void wheelEvent(QWheelEvent *e);
-#endif
-
-private:
- Q_DECLARE_PRIVATE(QWorkspace)
- Q_DISABLE_COPY(QWorkspace)
- Q_PRIVATE_SLOT(d_func(), void _q_normalizeActiveWindow())
- Q_PRIVATE_SLOT(d_func(), void _q_minimizeActiveWindow())
- Q_PRIVATE_SLOT(d_func(), void _q_showOperationMenu())
- Q_PRIVATE_SLOT(d_func(), void _q_popupOperationMenu(const QPoint&))
- Q_PRIVATE_SLOT(d_func(), void _q_operationMenuActivated(QAction *))
- Q_PRIVATE_SLOT(d_func(), void _q_updateActions())
- Q_PRIVATE_SLOT(d_func(), void _q_scrollBarChanged())
-
- friend class QWorkspaceChild;
-};
-
-#endif // QT_NO_WORKSPACE
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QWORKSPACE_H
diff --git a/src/gui/widgets/widgets.pri b/src/gui/widgets/widgets.pri
deleted file mode 100644
index 669b83830f..0000000000
--- a/src/gui/widgets/widgets.pri
+++ /dev/null
@@ -1,169 +0,0 @@
-# Qt widgets module
-
-HEADERS += \
- widgets/qbuttongroup.h \
- widgets/qabstractbutton.h \
- widgets/qabstractbutton_p.h \
- widgets/qabstractslider.h \
- widgets/qabstractslider_p.h \
- widgets/qabstractspinbox.h \
- widgets/qabstractspinbox_p.h \
- widgets/qcalendartextnavigator_p.h \
- widgets/qcalendarwidget.h \
- widgets/qcheckbox.h \
- widgets/qcombobox.h \
- widgets/qcombobox_p.h \
- widgets/qcommandlinkbutton.h \
- widgets/qdatetimeedit.h \
- widgets/qdatetimeedit_p.h \
- widgets/qdial.h \
- widgets/qdialogbuttonbox.h \
- widgets/qdockwidget.h \
- widgets/qdockwidget_p.h \
- widgets/qdockarealayout_p.h \
- widgets/qfontcombobox.h \
- widgets/qframe.h \
- widgets/qframe_p.h \
- widgets/qgroupbox.h \
- widgets/qlabel.h \
- widgets/qlabel_p.h \
- widgets/qlcdnumber.h \
- widgets/qlineedit.h \
- widgets/qlineedit_p.h \
- widgets/qlinecontrol_p.h \
- widgets/qmainwindow.h \
- widgets/qmainwindowlayout_p.h \
- widgets/qmdiarea.h \
- widgets/qmdiarea_p.h \
- widgets/qmdisubwindow.h \
- widgets/qmdisubwindow_p.h \
- widgets/qmenu.h \
- widgets/qmenu_p.h \
- widgets/qmenubar.h \
- widgets/qmenubar_p.h \
- widgets/qmenudata.h \
- widgets/qprogressbar.h \
- widgets/qpushbutton.h \
- widgets/qpushbutton_p.h \
- widgets/qradiobutton.h \
- widgets/qrubberband.h \
- widgets/qscrollbar.h \
- widgets/qscrollarea_p.h \
- widgets/qsizegrip.h \
- widgets/qslider.h \
- widgets/qspinbox.h \
- widgets/qsplashscreen.h \
- widgets/qsplitter.h \
- widgets/qsplitter_p.h \
- widgets/qstackedwidget.h \
- widgets/qstatusbar.h \
- widgets/qtabbar.h \
- widgets/qtabbar_p.h \
- widgets/qtabwidget.h \
- widgets/qtextedit.h \
- widgets/qtextedit_p.h \
- widgets/qtextbrowser.h \
- widgets/qtoolbar.h \
- widgets/qtoolbar_p.h \
- widgets/qtoolbarlayout_p.h \
- widgets/qtoolbarextension_p.h \
- widgets/qtoolbarseparator_p.h \
- widgets/qtoolbox.h \
- widgets/qtoolbutton.h \
- widgets/qvalidator.h \
- widgets/qabstractscrollarea.h \
- widgets/qabstractscrollarea_p.h \
- widgets/qwidgetresizehandler_p.h \
- widgets/qfocusframe.h \
- widgets/qscrollarea.h \
- widgets/qworkspace.h \
- widgets/qwidgetanimator_p.h \
- widgets/qtoolbararealayout_p.h \
- widgets/qplaintextedit.h \
- widgets/qplaintextedit_p.h \
- widgets/qprintpreviewwidget.h
-SOURCES += \
- widgets/qabstractbutton.cpp \
- widgets/qabstractslider.cpp \
- widgets/qabstractspinbox.cpp \
- widgets/qcalendarwidget.cpp \
- widgets/qcheckbox.cpp \
- widgets/qcombobox.cpp \
- widgets/qcommandlinkbutton.cpp \
- widgets/qdatetimeedit.cpp \
- widgets/qdial.cpp \
- widgets/qdialogbuttonbox.cpp \
- widgets/qdockwidget.cpp \
- widgets/qdockarealayout.cpp \
- widgets/qeffects.cpp \
- widgets/qfontcombobox.cpp \
- widgets/qframe.cpp \
- widgets/qgroupbox.cpp \
- widgets/qlabel.cpp \
- widgets/qlcdnumber.cpp \
- widgets/qlineedit_p.cpp \
- widgets/qlineedit.cpp \
- widgets/qlinecontrol.cpp \
- widgets/qmainwindow.cpp \
- widgets/qmainwindowlayout.cpp \
- widgets/qmdiarea.cpp \
- widgets/qmdisubwindow.cpp \
- widgets/qmenu.cpp \
- widgets/qmenubar.cpp \
- widgets/qmenudata.cpp \
- widgets/qprogressbar.cpp \
- widgets/qpushbutton.cpp \
- widgets/qradiobutton.cpp \
- widgets/qrubberband.cpp \
- widgets/qscrollbar.cpp \
- widgets/qsizegrip.cpp \
- widgets/qslider.cpp \
- widgets/qspinbox.cpp \
- widgets/qsplashscreen.cpp \
- widgets/qsplitter.cpp \
- widgets/qstackedwidget.cpp \
- widgets/qstatusbar.cpp \
- widgets/qtabbar.cpp \
- widgets/qtabwidget.cpp \
- widgets/qtextedit.cpp \
- widgets/qtextbrowser.cpp \
- widgets/qtoolbar.cpp \
- widgets/qtoolbarlayout.cpp \
- widgets/qtoolbarextension.cpp \
- widgets/qtoolbarseparator.cpp \
- widgets/qtoolbox.cpp \
- widgets/qtoolbutton.cpp \
- widgets/qvalidator.cpp \
- widgets/qabstractscrollarea.cpp \
- widgets/qwidgetresizehandler.cpp \
- widgets/qfocusframe.cpp \
- widgets/qscrollarea.cpp \
- widgets/qworkspace.cpp \
- widgets/qwidgetanimator.cpp \
- widgets/qtoolbararealayout.cpp \
- widgets/qplaintextedit.cpp \
- widgets/qprintpreviewwidget.cpp
-
-!embedded:!qpa:mac {
- HEADERS += widgets/qmacnativewidget_mac.h \
- widgets/qmaccocoaviewcontainer_mac.h
- OBJECTIVE_HEADERS += widgets/qcocoatoolbardelegate_mac_p.h \
- widgets/qcocoamenu_mac_p.h
- OBJECTIVE_SOURCES += widgets/qmenu_mac.mm \
- widgets/qmaccocoaviewcontainer_mac.mm \
- widgets/qcocoatoolbardelegate_mac.mm \
- widgets/qmainwindowlayout_mac.mm \
- widgets/qmacnativewidget_mac.mm \
- widgets/qcocoamenu_mac.mm
-}
-
-wince*: {
- SOURCES += widgets/qmenu_wince.cpp
- HEADERS += widgets/qmenu_wince_resource_p.h
- RC_FILE = widgets/qmenu_wince.rc
- !static: QMAKE_WRITE_DEFAULT_RC = 1
-}
-
-symbian: {
- SOURCES += widgets/qmenu_symbian.cpp
-}
diff --git a/src/modules/qt_opengl.pri b/src/modules/qt_opengl.pri
index b767a3ce12..a1080cb5a5 100644
--- a/src/modules/qt_opengl.pri
+++ b/src/modules/qt_opengl.pri
@@ -11,6 +11,6 @@ QT.opengl.sources = $$QT_MODULE_BASE/src/opengl
QT.opengl.libs = $$QT_MODULE_LIB_BASE
QT.opengl.plugins = $$QT_MODULE_PLUGIN_BASE
QT.opengl.imports = $$QT_MODULE_IMPORT_BASE
-QT.opengl.depends = core gui
+QT.opengl.depends = core gui widgets
QT.opengl.CONFIG = opengl
QT.opengl.DEFINES = QT_OPENGL_LIB
diff --git a/src/modules/qt_openvg.pri b/src/modules/qt_openvg.pri
deleted file mode 100644
index 2ff477c013..0000000000
--- a/src/modules/qt_openvg.pri
+++ /dev/null
@@ -1,16 +0,0 @@
-QT.openvg.VERSION = 4.8.0
-QT.openvg.MAJOR_VERSION = 4
-QT.openvg.MINOR_VERSION = 8
-QT.openvg.PATCH_VERSION = 0
-
-QT.openvg.name = QtOpenVG
-QT.openvg.bins = $$QT_MODULE_BIN_BASE
-QT.openvg.includes = $$QT_MODULE_INCLUDE_BASE/QtOpenVG
-QT.openvg.private_includes = $$QT_MODULE_INCLUDE_BASE/QtOpenVG/$$QT.openvg.VERSION
-QT.openvg.sources = $$QT_MODULE_BASE/src/openvg
-QT.openvg.libs = $$QT_MODULE_LIB_BASE
-QT.openvg.plugins = $$QT_MODULE_PLUGIN_BASE
-QT.openvg.imports = $$QT_MODULE_IMPORT_BASE
-QT.openvg.depends = core gui
-QT.openvg.CONFIG = openvg
-QT.openvg.DEFINES = QT_OPENVG_LIB
diff --git a/src/modules/qt_widgets.pri b/src/modules/qt_widgets.pri
new file mode 100644
index 0000000000..c86bc12021
--- /dev/null
+++ b/src/modules/qt_widgets.pri
@@ -0,0 +1,14 @@
+QT.widgets.VERSION = 4.8.0
+QT.widgets.MAJOR_VERSION = 4
+QT.widgets.MINOR_VERSION = 8
+QT.widgets.PATCH_VERSION = 0
+
+QT.widgets.name = QtWidgets
+QT.widgets.includes = $$QT_MODULE_INCLUDE_BASE/QtWidgets
+QT.widgets.private_includes = $$QT_MODULE_INCLUDE_BASE/QtWidgets/$$QT.widgets.VERSION
+QT.widgets.sources = $$QT_MODULE_BASE/src/widgets
+QT.widgets.libs = $$QT_MODULE_LIB_BASE
+QT.widgets.plugins = $$QT_MODULE_PLUGIN_BASE
+QT.widgets.imports = $$QT_MODULE_IMPORT_BASE
+QT.widgets.depends = core network gui
+QT.widgets.DEFINES = QT_GUI_LIB
diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
index 38bd58d91c..f702f13359 100644
--- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
+++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp
@@ -2363,8 +2363,8 @@ void QGL2PaintEngineExPrivate::systemStateChanged()
if (systemClip.isEmpty()) {
useSystemClip = false;
} else {
- if (q->paintDevice()->devType() == QInternal::Widget && currentClipWidget) {
- QWidgetPrivate *widgetPrivate = qt_widget_private(currentClipWidget->window());
+ if (q->paintDevice()->devType() == QInternal::Widget && currentClipDevice) {
+ QWidgetPrivate *widgetPrivate = qt_widget_private(static_cast<QWidget *>(currentClipDevice)->window());
useSystemClip = widgetPrivate->extra && widgetPrivate->extra->inRenderWithPainter;
} else {
useSystemClip = true;
diff --git a/src/opengl/gl2paintengineex/qtriangulator.cpp b/src/opengl/gl2paintengineex/qtriangulator.cpp
index a5faa36b4a..ab0cfd2d58 100644
--- a/src/opengl/gl2paintengineex/qtriangulator.cpp
+++ b/src/opengl/gl2paintengineex/qtriangulator.cpp
@@ -41,7 +41,7 @@
#include "qtriangulator_p.h"
-#include <QtGui/qdialog.h>
+#include <QtWidgets/qdialog.h>
#include <QtGui/qevent.h>
#include <QtGui/qpainter.h>
#include <QtGui/qpainterpath.h>
diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro
index 849bd9ebc7..2612368fb3 100644
--- a/src/opengl/opengl.pro
+++ b/src/opengl/opengl.pro
@@ -1,6 +1,6 @@
TARGET = QtOpenGL
QPRO_PWD = $$PWD
-QT = core-private gui-private
+QT = core-private gui-private widgets-private
CONFIG += module
MODULE_PRI = ../modules/qt_opengl.pri
@@ -15,7 +15,7 @@ unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui
include(../qbase.pri)
-!win32:!embedded:!mac:!symbian:!qpa:CONFIG += x11
+!win32:!mac:!symbian:!qpa:CONFIG += x11
contains(QT_CONFIG, opengl):CONFIG += opengl
contains(QT_CONFIG, opengles1):CONFIG += opengles1
contains(QT_CONFIG, opengles2):CONFIG += opengles2
@@ -53,7 +53,6 @@ SOURCES += qgl.cpp \
HEADERS += qglshaderprogram.h \
qglpixmapfilter_p.h \
qgraphicsshadereffect_p.h \
- qgraphicssystem_gl_p.h \
qwindowsurface_gl_p.h \
qpixmapdata_gl_p.h \
gl2paintengineex/qglgradientcache_p.h \
@@ -71,7 +70,6 @@ SOURCES += qgl.cpp \
SOURCES += qglshaderprogram.cpp \
qglpixmapfilter.cpp \
qgraphicsshadereffect.cpp \
- qgraphicssystem_gl.cpp \
qwindowsurface_gl.cpp \
qpixmapdata_gl.cpp \
gl2paintengineex/qglgradientcache.cpp \
@@ -109,7 +107,6 @@ x11 {
contains(QT_CONFIG, fontconfig) {
contains(QT_CONFIG, system-freetype) {
- embedded:CONFIG += opentype
# pull in the proper freetype2 include directory
include($$QT_SOURCE_TREE/config.tests/unix/freetype/freetype.pri)
LIBS_PRIVATE += -lfreetype
@@ -142,24 +139,6 @@ wince*: {
HEADERS += qgl_egl_p.h
}
-embedded {
- SOURCES += qgl_qws.cpp \
- qglpixelbuffer_egl.cpp \
- qglscreen_qws.cpp \
- qglwindowsurface_qws.cpp \
- qgl_egl.cpp
-
- HEADERS += qglscreen_qws.h \
- qglwindowsurface_qws_p.h \
- qgl_egl_p.h
-
- contains(QT_CONFIG, fontconfig) {
- include($$QT_SOURCE_TREE/config.tests/unix/freetype/freetype.pri)
- } else {
- DEFINES *= QT_NO_FREETYPE
- }
-}
-
symbian {
DEFINES += QGL_USE_TEXTURE_POOL QGL_NO_PRESERVED_SWAP
SOURCES -= qpixmapdata_gl.cpp
diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp
index 4cb976f3c2..f64c24b503 100644
--- a/src/opengl/qgl.cpp
+++ b/src/opengl/qgl.cpp
@@ -1711,7 +1711,7 @@ void QGLContextPrivate::init(QPaintDevice *dev, const QGLFormat &format)
vi = 0;
#endif
#if defined(Q_WS_QPA)
- platformContext = 0;
+ windowContext = 0;
#endif
#if !defined(QT_NO_EGL)
ownsEglContext = false;
@@ -3330,7 +3330,7 @@ bool QGLContext::create(const QGLContext* shareContext)
{
Q_D(QGLContext);
#ifdef Q_WS_QPA
- if (!d->paintDevice && !d->platformContext)
+ if (!d->paintDevice && !d->windowContext)
#else
if (!d->paintDevice)
#endif
@@ -3420,8 +3420,8 @@ void QGLContext::setInitialized(bool on)
const QGLContext* QGLContext::currentContext()
{
#ifdef Q_WS_QPA
- if (const QPlatformGLContext *threadContext = QPlatformGLContext::currentContext()) {
- return QGLContext::fromPlatformGLContext(const_cast<QPlatformGLContext *>(threadContext));
+ if (const QWindowContext *threadContext = QWindowContext::currentContext()) {
+ return QGLContext::fromWindowContext(const_cast<QWindowContext *>(threadContext));
}
return 0;
#else
diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h
index dfd1ae1824..30a8a32cfe 100644
--- a/src/opengl/qgl.h
+++ b/src/opengl/qgl.h
@@ -42,14 +42,14 @@
#ifndef QGL_H
#define QGL_H
-#include <QtGui/qwidget.h>
+#include <QtWidgets/qwidget.h>
#include <QtGui/qpaintengine.h>
#include <QtOpenGL/qglcolormap.h>
#include <QtCore/qmap.h>
#include <QtCore/qscopedpointer.h>
#ifdef Q_WS_QPA
-#include <QtGui/QPlatformWindowFormat>
+#include <QtGui/QWindowFormat>
#endif
QT_BEGIN_HEADER
@@ -283,8 +283,8 @@ public:
static OpenGLVersionFlags openGLVersionFlags();
#if defined(Q_WS_QPA)
- static QGLFormat fromPlatformWindowFormat(const QPlatformWindowFormat &format);
- static QPlatformWindowFormat toPlatformWindowFormat(const QGLFormat &format);
+ static QGLFormat fromWindowFormat(const QWindowFormat &format);
+ static QWindowFormat toWindowFormat(const QGLFormat &format);
#endif
private:
QGLFormatPrivate *d;
@@ -397,7 +397,7 @@ public:
static const QGLContext* currentContext();
#ifdef Q_WS_QPA
- static QGLContext *fromPlatformGLContext(QPlatformGLContext *platformContext);
+ static QGLContext *fromWindowContext(QWindowContext *platformContext);
#endif
protected:
virtual bool chooseContext(const QGLContext* shareContext = 0);
@@ -429,7 +429,7 @@ protected:
private:
#ifdef Q_WS_QPA
- QGLContext(QPlatformGLContext *platformContext);
+ QGLContext(QWindowContext *windowContext);
#endif
QScopedPointer<QGLContextPrivate> d_ptr;
diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h
index 46683c742e..7f2873b478 100644
--- a/src/opengl/qgl_p.h
+++ b/src/opengl/qgl_p.h
@@ -60,7 +60,7 @@
#include "QtCore/qthreadstorage.h"
#include "QtCore/qhash.h"
#include "QtCore/qatomic.h"
-#include "private/qwidget_p.h"
+#include "QtWidgets/private/qwidget_p.h"
#include "qcache.h"
#include "qglpaintdevice_p.h"
@@ -69,7 +69,7 @@
#endif
#if defined(Q_WS_QPA)
-#include <QtGui/QPlatformGLContext>
+#include <QtGui/QWindowContext>
#endif
QT_BEGIN_NAMESPACE
@@ -375,7 +375,7 @@ public:
#endif
#if defined(Q_WS_QPA)
- QPlatformGLContext *platformContext;
+ QWindowContext *windowContext;
void setupSharing();
#elif defined(Q_WS_X11) || defined(Q_WS_MAC)
diff --git a/src/opengl/qgl_qpa.cpp b/src/opengl/qgl_qpa.cpp
index 994344c6eb..5eaaee9702 100644
--- a/src/opengl/qgl_qpa.cpp
+++ b/src/opengl/qgl_qpa.cpp
@@ -40,86 +40,73 @@
****************************************************************************/
#include <QApplication>
-#include <QtGui/private/qapplication_p.h>
+#include <private/qapplication_p.h>
#include <QPixmap>
#include <QDebug>
-#include <QtGui/private/qapplication_p.h>
+#include <private/qapplication_p.h>
+#include <QtGui/QPlatformGLContext>
#include <QtGui/QPlatformWindow>
+#include <QtGui/QWindowContext>
#include "qgl.h"
#include "qgl_p.h"
QT_BEGIN_NAMESPACE
-QGLFormat QGLFormat::fromPlatformWindowFormat(const QPlatformWindowFormat &format)
+QGLFormat QGLFormat::fromWindowFormat(const QWindowFormat &format)
{
QGLFormat retFormat;
- retFormat.setAccum(format.accum());
- if (format.accumBufferSize() >= 0)
- retFormat.setAccumBufferSize(format.accumBufferSize());
- retFormat.setAlpha(format.alpha());
if (format.alphaBufferSize() >= 0)
retFormat.setAlphaBufferSize(format.alphaBufferSize());
if (format.blueBufferSize() >= 0)
retFormat.setBlueBufferSize(format.blueBufferSize());
- retFormat.setDepth(format.depth());
- if (format.depthBufferSize() >= 0)
- retFormat.setDepthBufferSize(format.depthBufferSize());
- retFormat.setDirectRendering(format.directRendering());
- retFormat.setDoubleBuffer(format.doubleBuffer());
if (format.greenBufferSize() >= 0)
retFormat.setGreenBufferSize(format.greenBufferSize());
if (format.redBufferSize() >= 0)
retFormat.setRedBufferSize(format.redBufferSize());
- retFormat.setRgba(format.rgba());
- retFormat.setSampleBuffers(format.sampleBuffers());
- retFormat.setSamples(format.sampleBuffers());
- retFormat.setStencil(format.stencil());
- if (format.stencilBufferSize() >= 0)
+ if (format.depthBufferSize() >= 0)
+ retFormat.setDepthBufferSize(format.depthBufferSize());
+ if (format.samples() > 1) {
+ retFormat.setSampleBuffers(format.samples());
+ retFormat.setSamples(true);
+ }
+ if (format.stencilBufferSize() > 0) {
+ retFormat.setStencil(true);
retFormat.setStencilBufferSize(format.stencilBufferSize());
+ }
+ retFormat.setDoubleBuffer(format.swapBehavior() != QWindowFormat::SingleBuffer);
retFormat.setStereo(format.stereo());
- retFormat.setSwapInterval(format.swapInterval());
return retFormat;
}
-QPlatformWindowFormat QGLFormat::toPlatformWindowFormat(const QGLFormat &format)
+QWindowFormat QGLFormat::toWindowFormat(const QGLFormat &format)
{
- QPlatformWindowFormat retFormat;
- retFormat.setAccum(format.accum());
- if (format.accumBufferSize() >= 0)
- retFormat.setAccumBufferSize(format.accumBufferSize());
- retFormat.setAlpha(format.alpha());
+ QWindowFormat retFormat;
if (format.alphaBufferSize() >= 0)
retFormat.setAlphaBufferSize(format.alphaBufferSize());
if (format.blueBufferSize() >= 0)
retFormat.setBlueBufferSize(format.blueBufferSize());
- retFormat.setDepth(format.depth());
- if (format.depthBufferSize() >= 0)
- retFormat.setDepthBufferSize(format.depthBufferSize());
- retFormat.setDirectRendering(format.directRendering());
- retFormat.setDoubleBuffer(format.doubleBuffer());
if (format.greenBufferSize() >= 0)
retFormat.setGreenBufferSize(format.greenBufferSize());
if (format.redBufferSize() >= 0)
retFormat.setRedBufferSize(format.redBufferSize());
- retFormat.setRgba(format.rgba());
- retFormat.setSampleBuffers(format.sampleBuffers());
- if (format.samples() >= 0)
+ if (format.depthBufferSize() >= 0)
+ retFormat.setDepthBufferSize(format.depthBufferSize());
+ retFormat.setSwapBehavior(format.doubleBuffer() ? QWindowFormat::DoubleBuffer : QWindowFormat::DefaultSwapBehavior);
+ if (format.sampleBuffers() && format.samples() > 1)
retFormat.setSamples(format.samples());
- retFormat.setStencil(format.stencil());
- if (format.stencilBufferSize() >= 0)
+ if (format.stencil() && format.stencilBufferSize() > 0)
retFormat.setStencilBufferSize(format.stencilBufferSize());
retFormat.setStereo(format.stereo());
- retFormat.setSwapInterval(format.swapInterval());
return retFormat;
}
void QGLContextPrivate::setupSharing() {
Q_Q(QGLContext);
- QPlatformGLContext *sharedPlatformGLContext = platformContext->platformWindowFormat().sharedGLContext();
- if (sharedPlatformGLContext) {
- QGLContext *actualSharedContext = QGLContext::fromPlatformGLContext(sharedPlatformGLContext);
+ QWindowContext *sharedContext = windowContext->handle()->windowFormat().sharedContext();
+ if (sharedContext) {
+ QGLContext *actualSharedContext = QGLContext::fromWindowContext(sharedContext);
sharing = true;
QGLContextGroup::addShare(q,actualSharedContext);
}
@@ -144,23 +131,23 @@ bool QGLContext::chooseContext(const QGLContext* shareContext)
d->valid = false;
}else {
QWidget *widget = static_cast<QWidget *>(d->paintDevice);
- if (!widget->platformWindow()){
+ if (!widget->windowHandle()->handle()) {
QGLFormat glformat = format();
- QPlatformWindowFormat winFormat = QGLFormat::toPlatformWindowFormat(glformat);
+ QWindowFormat winFormat = QGLFormat::toWindowFormat(glformat);
if (shareContext) {
- winFormat.setSharedContext(shareContext->d_func()->platformContext);
+ winFormat.setSharedContext(shareContext->d_func()->windowContext);
}
- winFormat.setWindowApi(QPlatformWindowFormat::OpenGL);
+ widget->windowHandle()->setSurfaceType(QWindow::OpenGLSurface);
winFormat.setWindowSurface(false);
- widget->setPlatformWindowFormat(winFormat);
+ widget->windowHandle()->setWindowFormat(winFormat);
widget->winId();//make window
}
- d->platformContext = widget->platformWindow()->glContext();
- Q_ASSERT(d->platformContext);
- d->glFormat = QGLFormat::fromPlatformWindowFormat(d->platformContext->platformWindowFormat());
- d->valid =(bool) d->platformContext;
+ d->windowContext = widget->windowHandle()->glContext();
+ Q_ASSERT(d->windowContext);
+ d->glFormat = QGLFormat::fromWindowFormat(d->windowContext->handle()->windowFormat());
+ d->valid =(bool) d->windowContext;
if (d->valid) {
- d->platformContext->setQGLContextHandle(this,qDeleteQGLContext);
+ d->windowContext->setQGLContextHandle(this,qDeleteQGLContext);
}
d->setupSharing();
}
@@ -182,15 +169,15 @@ void QGLContext::reset()
d->transpColor = QColor();
d->initDone = false;
QGLContextGroup::removeShare(this);
- if (d->platformContext) {
- d->platformContext->setQGLContextHandle(0,0);
+ if (d->windowContext) {
+ d->windowContext->setQGLContextHandle(0,0);
}
}
void QGLContext::makeCurrent()
{
Q_D(QGLContext);
- d->platformContext->makeCurrent();
+ d->windowContext->makeCurrent();
if (!d->workaroundsCached) {
d->workaroundsCached = true;
@@ -205,19 +192,19 @@ void QGLContext::makeCurrent()
void QGLContext::doneCurrent()
{
Q_D(QGLContext);
- d->platformContext->doneCurrent();
+ d->windowContext->doneCurrent();
}
void QGLContext::swapBuffers() const
{
Q_D(const QGLContext);
- d->platformContext->swapBuffers();
+ d->windowContext->swapBuffers();
}
void *QGLContext::getProcAddress(const QString &procName) const
{
Q_D(const QGLContext);
- return d->platformContext->getProcAddress(procName);
+ return (void *)d->windowContext->getProcAddress(procName.toAscii());
}
void QGLWidget::setContext(QGLContext *context,
@@ -275,33 +262,32 @@ void QGLContext::generateFontDisplayLists(const QFont & fnt, int listBase)
class QGLTemporaryContextPrivate
{
public:
- QWidget *widget;
- QPlatformGLContext *context;
+ QWindow *window;
+ QWindowContext *context;
};
QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *)
: d(new QGLTemporaryContextPrivate)
{
- d->context = const_cast<QPlatformGLContext *>(QPlatformGLContext::currentContext());
+ d->context = const_cast<QWindowContext *>(QWindowContext::currentContext());
if (d->context)
d->context->doneCurrent();
- d->widget = new QWidget;
- d->widget->setGeometry(0,0,3,3);
- QPlatformWindowFormat format = d->widget->platformWindowFormat();
- format.setWindowApi(QPlatformWindowFormat::OpenGL);
- format.setWindowSurface(false);
- d->widget->setPlatformWindowFormat(format);
- d->widget->winId();
-
- d->widget->platformWindow()->glContext()->makeCurrent();
+
+ d->window = new QWindow;
+ d->window->setGeometry(QRect(0, 0, 3, 3));
+ d->window->setSurfaceType(QWindow::OpenGLSurface);
+ d->window->create();
+
+ d->window->glContext()->makeCurrent();
}
QGLTemporaryContext::~QGLTemporaryContext()
{
- d->widget->platformWindow()->glContext()->doneCurrent();
if (d->context)
d->context->makeCurrent();
- delete d->widget;
+ else
+ d->window->glContext()->doneCurrent();
+ delete d->window;
}
@@ -367,25 +353,25 @@ void QGLWidget::setColormap(const QGLColormap & c)
Q_UNUSED(c);
}
-QGLContext::QGLContext(QPlatformGLContext *platformContext)
+QGLContext::QGLContext(QWindowContext *windowContext)
: d_ptr(new QGLContextPrivate(this))
{
Q_D(QGLContext);
- d->init(0,QGLFormat::fromPlatformWindowFormat(platformContext->platformWindowFormat()));
- d->platformContext = platformContext;
- d->platformContext->setQGLContextHandle(this,qDeleteQGLContext);
+ d->init(0,QGLFormat::fromWindowFormat(windowContext->handle()->windowFormat()));
+ d->windowContext = windowContext;
+ d->windowContext->setQGLContextHandle(this,qDeleteQGLContext);
d->valid = true;
d->setupSharing();
}
-QGLContext *QGLContext::fromPlatformGLContext(QPlatformGLContext *platformContext)
+QGLContext *QGLContext::fromWindowContext(QWindowContext *windowContext)
{
- if (!platformContext)
+ if (!windowContext)
return 0;
- if (platformContext->qGLContextHandle()) {
- return reinterpret_cast<QGLContext *>(platformContext->qGLContextHandle());
+ if (windowContext->qGLContextHandle()) {
+ return reinterpret_cast<QGLContext *>(windowContext->qGLContextHandle());
}
- QGLContext *glContext = new QGLContext(platformContext);
+ QGLContext *glContext = new QGLContext(windowContext);
//Dont call create on context. This can cause the platformFormat to be set on the widget, which
//will cause the platformWindow to be recreated.
return glContext;
diff --git a/src/opengl/qgl_qws.cpp b/src/opengl/qgl_qws.cpp
deleted file mode 100644
index 6ad2774eaf..0000000000
--- a/src/opengl/qgl_qws.cpp
+++ /dev/null
@@ -1,318 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenGL module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgl.h"
-#include "qgl_egl_p.h"
-#include "qglpixelbuffer.h"
-
-#include <qglscreen_qws.h>
-#include <qscreenproxy_qws.h>
-#include <private/qglwindowsurface_qws_p.h>
-
-#include <private/qbackingstore_p.h>
-#include <private/qfont_p.h>
-#include <private/qfontengine_p.h>
-#include <private/qgl_p.h>
-#include <private/qpaintengine_opengl_p.h>
-#include <qpixmap.h>
-#include <qtimer.h>
-#include <qapplication.h>
-#include <qstack.h>
-#include <qdesktopwidget.h>
-#include <qdebug.h>
-#include <qvarlengtharray.h>
-
-QT_BEGIN_NAMESPACE
-
-static QGLScreen *glScreenForDevice(QPaintDevice *device)
-{
- QScreen *screen = qt_screen;
- if (screen->classId() == QScreen::MultiClass) {
- int screenNumber;
- if (device && device->devType() == QInternal::Widget)
- screenNumber = qApp->desktop()->screenNumber(static_cast<QWidget *>(device));
- else
- screenNumber = 0;
- screen = screen->subScreens()[screenNumber];
- }
- while (screen->classId() == QScreen::ProxyClass ||
- screen->classId() == QScreen::TransformedClass) {
- screen = static_cast<QProxyScreen *>(screen)->screen();
- }
- if (screen->classId() == QScreen::GLClass)
- return static_cast<QGLScreen *>(screen);
- else
- return 0;
-}
-
-/*
- QGLTemporaryContext implementation
-*/
-
-class QGLTemporaryContextPrivate
-{
-public:
- QGLWidget *widget;
-};
-
-QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *)
- : d(new QGLTemporaryContextPrivate)
-{
- d->widget = new QGLWidget;
- d->widget->makeCurrent();
-}
-
-QGLTemporaryContext::~QGLTemporaryContext()
-{
- delete d->widget;
-}
-
-/*****************************************************************************
- QOpenGL debug facilities
- *****************************************************************************/
-//#define DEBUG_OPENGL_REGION_UPDATE
-
-bool QGLFormat::hasOpenGLOverlays()
-{
- QGLScreen *glScreen = glScreenForDevice(0);
- if (glScreen)
- return (glScreen->options() & QGLScreen::Overlays);
- else
- return false;
-}
-
-static EGLSurface qt_egl_create_surface
- (QEglContext *context, QPaintDevice *device,
- const QEglProperties *properties = 0)
-{
- // Get the screen surface functions, which are used to create native ids.
- QGLScreen *glScreen = glScreenForDevice(device);
- if (!glScreen)
- return EGL_NO_SURFACE;
- QGLScreenSurfaceFunctions *funcs = glScreen->surfaceFunctions();
- if (!funcs)
- return EGL_NO_SURFACE;
-
- // Create the native drawable for the paint device.
- int devType = device->devType();
- EGLNativePixmapType pixmapDrawable = 0;
- EGLNativeWindowType windowDrawable = 0;
- bool ok;
- if (devType == QInternal::Pixmap) {
- ok = funcs->createNativePixmap(static_cast<QPixmap *>(device), &pixmapDrawable);
- } else if (devType == QInternal::Image) {
- ok = funcs->createNativeImage(static_cast<QImage *>(device), &pixmapDrawable);
- } else {
- ok = funcs->createNativeWindow(static_cast<QWidget *>(device), &windowDrawable);
- }
- if (!ok) {
- qWarning("QEglContext::createSurface(): Cannot create the native EGL drawable");
- return EGL_NO_SURFACE;
- }
-
- // Create the EGL surface to draw into, based on the native drawable.
- const int *props;
- if (properties)
- props = properties->properties();
- else
- props = 0;
- EGLSurface surf;
- if (devType == QInternal::Widget) {
- surf = eglCreateWindowSurface
- (context->display(), context->config(), windowDrawable, props);
- } else {
- surf = eglCreatePixmapSurface
- (context->display(), context->config(), pixmapDrawable, props);
- }
- if (surf == EGL_NO_SURFACE)
- qWarning("QEglContext::createSurface(): Unable to create EGL surface, error = 0x%x", eglGetError());
- return surf;
-}
-
-bool QGLContext::chooseContext(const QGLContext* shareContext)
-{
- Q_D(QGLContext);
-
- // Validate the device.
- if (!device())
- return false;
- int devType = device()->devType();
- if (devType != QInternal::Pixmap && devType != QInternal::Image && devType != QInternal::Widget) {
- qWarning("QGLContext::chooseContext(): Cannot create QGLContext's for paint device type %d", devType);
- return false;
- }
-
- // Get the display and initialize it.
- d->eglContext = new QEglContext();
- d->ownsEglContext = true;
- d->eglContext->setApi(QEgl::OpenGL);
-
- // Construct the configuration we need for this surface.
- QEglProperties configProps;
- qt_eglproperties_set_glformat(configProps, d->glFormat);
- configProps.setDeviceType(devType);
- configProps.setPaintDeviceFormat(device());
- configProps.setRenderableType(QEgl::OpenGL);
-
- // Search for a matching configuration, reducing the complexity
- // each time until we get something that matches.
- if (!d->eglContext->chooseConfig(configProps)) {
- delete d->eglContext;
- d->eglContext = 0;
- return false;
- }
-
- // Inform the higher layers about the actual format properties.
- qt_glformat_from_eglconfig(d->glFormat, d->eglContext->config());
-
- // Create a new context for the configuration.
- if (!d->eglContext->createContext
- (shareContext ? shareContext->d_func()->eglContext : 0)) {
- delete d->eglContext;
- d->eglContext = 0;
- return false;
- }
- d->sharing = d->eglContext->isSharing();
- if (d->sharing && shareContext)
- const_cast<QGLContext *>(shareContext)->d_func()->sharing = true;
-
-#if defined(EGL_VERSION_1_1)
- if (d->glFormat.swapInterval() != -1 && devType == QInternal::Widget)
- eglSwapInterval(d->eglContext->display(), d->glFormat.swapInterval());
-#endif
-
- // Create the EGL surface to draw into. We cannot use
- // QEglContext::createSurface() because it does not have
- // access to the QGLScreen.
- d->eglSurface = qt_egl_create_surface(d->eglContext, device());
- if (d->eglSurface == EGL_NO_SURFACE) {
- delete d->eglContext;
- d->eglContext = 0;
- return false;
- }
-
- return true;
-}
-
-
-bool QGLWidget::event(QEvent *e)
-{
- return QWidget::event(e);
-}
-
-
-void QGLWidget::resizeEvent(QResizeEvent *)
-{
- Q_D(QGLWidget);
- if (!isValid())
- return;
- makeCurrent();
- if (!d->glcx->initialized())
- glInit();
- resizeGL(width(), height());
- //handle overlay
-}
-
-const QGLContext* QGLWidget::overlayContext() const
-{
- return 0;
-}
-
-void QGLWidget::makeOverlayCurrent()
-{
- //handle overlay
-}
-
-void QGLWidget::updateOverlayGL()
-{
- //handle overlay
-}
-
-void QGLWidget::setContext(QGLContext *context, const QGLContext* shareContext, bool deleteOldContext)
-{
- Q_D(QGLWidget);
- if(context == 0) {
- qWarning("QGLWidget::setContext: Cannot set null context");
- return;
- }
-
- if(d->glcx)
- d->glcx->doneCurrent();
- QGLContext* oldcx = d->glcx;
- d->glcx = context;
- if(!d->glcx->isValid())
- d->glcx->create(shareContext ? shareContext : oldcx);
- if(deleteOldContext)
- delete oldcx;
-}
-
-void QGLWidgetPrivate::init(QGLContext *context, const QGLWidget* shareWidget)
-{
- Q_Q(QGLWidget);
-
- QGLScreen *glScreen = glScreenForDevice(q);
- if (glScreen) {
- wsurf = static_cast<QWSGLWindowSurface*>(glScreen->createSurface(q));
- q->setWindowSurface(wsurf);
- }
-
- initContext(context, shareWidget);
-
- if(q->isValid() && glcx->format().hasOverlay()) {
- //no overlay
- qWarning("QtOpenGL ES doesn't currently support overlays");
- }
-}
-
-void QGLWidgetPrivate::cleanupColormaps()
-{
-}
-
-const QGLColormap & QGLWidget::colormap() const
-{
- return d_func()->cmap;
-}
-
-void QGLWidget::setColormap(const QGLColormap &)
-{
-}
-
-QT_END_NAMESPACE
diff --git a/src/opengl/qglpixmapfilter.cpp b/src/opengl/qglpixmapfilter.cpp
index aa075617bb..ed0d82a49a 100644
--- a/src/opengl/qglpixmapfilter.cpp
+++ b/src/opengl/qglpixmapfilter.cpp
@@ -46,7 +46,6 @@
#include "private/qpixmapdata_p.h"
#include "private/qimagepixmapcleanuphooks_p.h"
#include "qglpixmapfilter_p.h"
-#include "qgraphicssystem_gl_p.h"
#include "qpaintengine_opengl_p.h"
#include "qcache.h"
diff --git a/src/opengl/qglscreen_qws.cpp b/src/opengl/qglscreen_qws.cpp
deleted file mode 100644
index badb581844..0000000000
--- a/src/opengl/qglscreen_qws.cpp
+++ /dev/null
@@ -1,242 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenGL module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QGLScreen>
-#include <QGLContext>
-#include <QGLWidget>
-#include "private/qglwindowsurface_qws_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QGLScreenPrivate
-{
-public:
- QGLScreen::Options options;
- QGLScreenSurfaceFunctions *functions;
-};
-
-/*!
- \internal
- \preliminary
- \class QGLScreen
-
- \brief This class encapsulates an OpenGL screen driver.
-*/
-
-QGLScreen::QGLScreen(int displayId)
- : QScreen(displayId, GLClass), d_ptr(new QGLScreenPrivate)
-{
- d_ptr->options = NoOptions;
- d_ptr->functions = new QGLScreenSurfaceFunctions();
-}
-
-QGLScreen::~QGLScreen()
-{
- delete d_ptr->functions;
- delete d_ptr;
-}
-
-/*!
- \since 4.3
- \obsolete
-
- Initializes the \a context and sets up the QGLWindowSurface of the
- QWidget of \a context based on the parameters of \a context and
- based on its own requirements. The format() of \a context needs
- to be updated with the actual parameters of the OpenGLES drawable
- that was set up.
-
- \a shareContext is used in the same way as for QGLContext. It is
- the context with which \a context shares display lists and texture
- ids etc. The window surface must be set up so that this sharing
- works.
-
- Returns true in case of success and false if it is not possible to
- create the necessary OpenGLES drawable/context.
-
- Since 4.4.2, this function will be not be called if options()
- indicates that a native window or pixmap drawable can be created
- via the functions in the surfaceFunctions() object.
-
- This function is obsolete in Qt 4.5 and higher. Use surfaceFunctions()
- instead.
-
- \sa options(), surfaceFunctions()
-*/
-bool
-QGLScreen::chooseContext(QGLContext *context, const QGLContext *shareContext)
-{
- Q_UNUSED(context);
- Q_UNUSED(shareContext);
- return false;
-}
-
-/*!
- \enum QGLScreen::Option
- This enum defines options that can be set on QGLScreen instances.
-
- \value NoOptions There are no special options on the screen. This is the default.
- \value NativeWindows Native windows can be created with QGLScreenSurfaceFunctions::createNativeWindow().
- \value NativePixmaps Native pixmaps can be created with QGLScreenSurfaceFunctions::createNativePixmap().
- \value NativeImages Native images can be created with QGLScreenSurfaceFunctions::createNativeImage().
- \value Overlays The screen supports GL overlays.
-*/
-
-/*!
- \since 4.4.2
-
- Returns the options associated with this QGLScreen.
-
- \sa setOptions()
-*/
-QGLScreen::Options QGLScreen::options() const
-{
- return d_ptr->options;
-}
-
-/*!
- \since 4.4.2
-
- Sets the options associated with this QGLScreen to \a value.
-
- \sa options()
-*/
-void QGLScreen::setOptions(QGLScreen::Options value)
-{
- d_ptr->options = value;
-}
-
-/*!
- \since 4.4.2
-
- Returns the surface functions object for this QGLScreen.
-
- \sa setSurfaceFunctions()
-*/
-QGLScreenSurfaceFunctions *QGLScreen::surfaceFunctions() const
-{
- return d_ptr->functions;
-}
-
-/*!
- \since 4.4.2
-
- Sets the surface functions object for this QGLScreen to \a functions.
- The QGLScreen will take over ownership of \a functions and delete
- it when the QGLScreen is deleted.
-
- \sa setSurfaceFunctions()
-*/
-void QGLScreen::setSurfaceFunctions(QGLScreenSurfaceFunctions *functions)
-{
- if (functions && functions != d_ptr->functions) {
- delete d_ptr->functions;
- d_ptr->functions = functions;
- }
-}
-
-/*!
- \internal
- \preliminary
- \class QGLScreenSurfaceFunctions
- \brief The QGLScreenSurfaceFunctions class encapsulates the functions for creating native windows and pixmaps for OpenGL ES.
-*/
-
-/*!
- \since 4.4.2
-
- Creates a native OpenGLES drawable for the surface of \a widget and
- returns it in \a native. Returns true if the OpenGLES drawable could
- be created, or false if windows are not supported.
-
- This function will be called if the NativeWindows option is set on
- the screen.
-
- \sa createNativePixmap(), createNativeImage(), QGLScreen::options()
-*/
-bool QGLScreenSurfaceFunctions::createNativeWindow(QWidget *widget, EGLNativeWindowType *native)
-{
- Q_UNUSED(widget);
- Q_UNUSED(native);
- return false;
-}
-
-/*!
- \since 4.4.2
-
- Creates a native OpenGLES drawable for directly rendering into
- \a pixmap and returns it in \a native. Returns true if the OpenGLES
- drawable could be created, or false if direct rendering into pixmaps
- is not supported.
-
- This function will be called if the NativePixmaps option is set on
- the screen.
-
- \sa createNativeWindow(), createNativeImage(), QGLScreen::options()
-*/
-bool QGLScreenSurfaceFunctions::createNativePixmap(QPixmap *pixmap, EGLNativePixmapType *native)
-{
- Q_UNUSED(pixmap);
- Q_UNUSED(native);
- return false;
-}
-
-/*!
- \since 4.4.2
-
- Creates a native OpenGLES drawable for directly rendering into
- \a image and returns it in \a native. Returns true if the OpenGLES
- drawable could be created, or false if direct rendering into images
- is not supported.
-
- This function will be called if the NativeImages option is set on
- the screen.
-
- \sa createNativeWindow(), createNativePixmap(), QGLScreen::options()
-*/
-bool QGLScreenSurfaceFunctions::createNativeImage(QImage *image, EGLNativePixmapType *native)
-{
- Q_UNUSED(image);
- Q_UNUSED(native);
- return false;
-}
-
-QT_END_NAMESPACE
diff --git a/src/opengl/qglscreen_qws.h b/src/opengl/qglscreen_qws.h
deleted file mode 100644
index 1fefc1ce6e..0000000000
--- a/src/opengl/qglscreen_qws.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenGL module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSCREENEGL_P_H
-#define QSCREENEGL_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QScreenEGL class. This header file may change from
-// version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtGui/QScreen>
-#include <QtOpenGL/qgl.h>
-#if defined(QT_OPENGL_ES_2)
-#include <EGL/egl.h>
-#else
-#include <GLES/egl.h>
-#endif
-#if !defined(EGL_VERSION_1_3) && !defined(QEGL_NATIVE_TYPES_DEFINED)
-#undef EGLNativeWindowType
-#undef EGLNativePixmapType
-#undef EGLNativeDisplayType
-typedef NativeWindowType EGLNativeWindowType;
-typedef NativePixmapType EGLNativePixmapType;
-typedef NativeDisplayType EGLNativeDisplayType;
-#define QEGL_NATIVE_TYPES_DEFINED 1
-#endif
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(OpenGL)
-
-class QGLScreenPrivate;
-
-class Q_OPENGL_EXPORT QGLScreenSurfaceFunctions
-{
-public:
- virtual bool createNativeWindow(QWidget *widget, EGLNativeWindowType *native);
- virtual bool createNativePixmap(QPixmap *pixmap, EGLNativePixmapType *native);
- virtual bool createNativeImage(QImage *image, EGLNativePixmapType *native);
-};
-
-class Q_OPENGL_EXPORT QGLScreen : public QScreen
-{
- Q_DECLARE_PRIVATE(QGLScreen)
-public:
- QGLScreen(int displayId);
- virtual ~QGLScreen();
-
- enum Option
- {
- NoOptions = 0,
- NativeWindows = 1,
- NativePixmaps = 2,
- NativeImages = 4,
- Overlays = 8
- };
- Q_DECLARE_FLAGS(Options, Option)
-
- QGLScreen::Options options() const;
-
- virtual bool chooseContext(QGLContext *context, const QGLContext *shareContext);
- virtual bool hasOpenGL() = 0;
-
- QGLScreenSurfaceFunctions *surfaceFunctions() const;
-
-protected:
- void setOptions(QGLScreen::Options value);
- void setSurfaceFunctions(QGLScreenSurfaceFunctions *functions);
-
-private:
- QGLScreenPrivate *d_ptr;
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QGLScreen::Options)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QSCREENEGL_P_H
diff --git a/src/opengl/qglwindowsurface_qws.cpp b/src/opengl/qglwindowsurface_qws.cpp
deleted file mode 100644
index 8d1d733d79..0000000000
--- a/src/opengl/qglwindowsurface_qws.cpp
+++ /dev/null
@@ -1,133 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenGL module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtGui/QPaintDevice>
-#include <QtGui/QWidget>
-#include <QtOpenGL/QGLWidget>
-#include "private/qglwindowsurface_qws_p.h"
-#include "private/qpaintengine_opengl_p.h"
-
-QT_BEGIN_NAMESPACE
-
-/*!
- \class QWSGLWindowSurface
- \since 4.3
- \ingroup qws
- \preliminary
-
- \brief The QWSGLWindowSurface class provides the drawing area for top-level
- windows with Qt for Embedded Linux on EGL/OpenGL ES. It also provides the
- drawing area for \l{QGLWidget}s whether they are top-level windows or
- children of another QWidget.
-
- Note that this class is only available in Qt for Embedded Linux and only
- available if Qt is configured with OpenGL support.
-*/
-
-class QWSGLWindowSurfacePrivate
-{
-public:
- QWSGLWindowSurfacePrivate() :
- qglContext(0), ownsContext(false) {}
-
- QGLContext *qglContext;
- bool ownsContext;
-};
-
-/*!
- Constructs an empty QWSGLWindowSurface for the given top-level \a window.
- The window surface is later initialized from chooseContext() and resources for it
- is typically allocated in setGeometry().
-*/
-QWSGLWindowSurface::QWSGLWindowSurface(QWidget *window)
- : QWSWindowSurface(window),
- d_ptr(new QWSGLWindowSurfacePrivate)
-{
-}
-
-/*!
- Constructs an empty QWSGLWindowSurface.
-*/
-QWSGLWindowSurface::QWSGLWindowSurface()
- : d_ptr(new QWSGLWindowSurfacePrivate)
-{
-}
-
-/*!
- Destroys the QWSGLWindowSurface object and frees any
- allocated resources.
- */
-QWSGLWindowSurface::~QWSGLWindowSurface()
-{
- Q_D(QWSGLWindowSurface);
- if (d->ownsContext)
- delete d->qglContext;
- delete d;
-}
-
-/*!
- Returns the QGLContext of the window surface.
-*/
-QGLContext *QWSGLWindowSurface::context() const
-{
- Q_D(const QWSGLWindowSurface);
- if (!d->qglContext) {
- QWSGLWindowSurface *that = const_cast<QWSGLWindowSurface*>(this);
- that->setContext(new QGLContext(QGLFormat::defaultFormat()));
- that->d_func()->ownsContext = true;
- }
- return d->qglContext;
-}
-
-/*!
- Sets the QGLContext for this window surface to \a context.
-*/
-void QWSGLWindowSurface::setContext(QGLContext *context)
-{
- Q_D(QWSGLWindowSurface);
- if (d->ownsContext) {
- delete d->qglContext;
- d->ownsContext = false;
- }
- d->qglContext = context;
-}
-
-QT_END_NAMESPACE
diff --git a/src/opengl/qglwindowsurface_qws_p.h b/src/opengl/qglwindowsurface_qws_p.h
deleted file mode 100644
index 41d77e8e2d..0000000000
--- a/src/opengl/qglwindowsurface_qws_p.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenGL module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGLWINDOWSURFACE_QWS_P_H
-#define QGLWINDOWSURFACE_QWS_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QWSGLWindowSurface class. This header file may change from
-// version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qglobal.h>
-#include <QPaintDevice>
-#include "private/qwindowsurface_qws_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QPaintDevice;
-class QPoint;
-class QRegion;
-class QSize;
-class QWidget;
-class QGLContext;
-
-class QWSGLWindowSurfacePrivate;
-
-class Q_OPENGL_EXPORT QWSGLWindowSurface : public QWSWindowSurface
-{
- Q_DECLARE_PRIVATE(QWSGLWindowSurface)
-
-public:
- QWSGLWindowSurface(QWidget *widget);
- QWSGLWindowSurface();
- ~QWSGLWindowSurface();
-
- QGLContext *context() const;
- void setContext(QGLContext *context);
-
-private:
- QWSGLWindowSurfacePrivate *d_ptr;
-};
-
-
-QT_END_NAMESPACE
-
-#endif // QGLWINDOWSURFACE_QWS_P_H
diff --git a/src/opengl/qgraphicsshadereffect.cpp b/src/opengl/qgraphicsshadereffect.cpp
index 6983d9057e..859af2045f 100644
--- a/src/opengl/qgraphicsshadereffect.cpp
+++ b/src/opengl/qgraphicsshadereffect.cpp
@@ -46,8 +46,8 @@
#define QGL_HAVE_CUSTOM_SHADERS 1
#endif
#include <QtGui/qpainter.h>
-#include <QtGui/qgraphicsitem.h>
-#include <QtGui/private/qgraphicseffect_p.h>
+#include <QtWidgets/qgraphicsitem.h>
+#include <private/qgraphicseffect_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/opengl/qgraphicsshadereffect_p.h b/src/opengl/qgraphicsshadereffect_p.h
index 3b319fdbf0..cf82a36b00 100644
--- a/src/opengl/qgraphicsshadereffect_p.h
+++ b/src/opengl/qgraphicsshadereffect_p.h
@@ -53,7 +53,7 @@
// We mean it.
//
-#include <QtGui/qgraphicseffect.h>
+#include <QtWidgets/qgraphicseffect.h>
QT_BEGIN_HEADER
diff --git a/src/opengl/qgraphicssystem_gl.cpp b/src/opengl/qgraphicssystem_gl.cpp
deleted file mode 100644
index 0aa3c2e6c7..0000000000
--- a/src/opengl/qgraphicssystem_gl.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenGL module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgraphicssystem_gl_p.h"
-#include <QGraphicsView>
-
-#include "private/qpixmap_raster_p.h"
-#include "private/qpixmapdata_gl_p.h"
-#include "private/qwindowsurface_gl_p.h"
-#include "private/qgl_p.h"
-#include <private/qwindowsurface_raster_p.h>
-
-#if defined(Q_WS_X11) && !defined(QT_NO_EGL)
-#include "private/qpixmapdata_x11gl_p.h"
-#include "private/qwindowsurface_x11gl_p.h"
-#endif
-
-#if defined(Q_OS_SYMBIAN)
-#include <QtGui/private/qapplication_p.h>
-#endif
-
-#ifdef QGL_USE_TEXTURE_POOL
-#include "private/qgltexturepool_p.h"
-#endif
-
-QT_BEGIN_NAMESPACE
-
-extern QGLWidget *qt_gl_getShareWidget();
-
-QPixmapData *QGLGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const
-{
- return new QGLPixmapData(type);
-}
-
-QWindowSurface *QGLGraphicsSystem::createWindowSurface(QWidget *widget) const
-{
-#ifdef Q_WS_WIN
- // On Windows the QGLWindowSurface class can't handle
- // drop shadows and native effects, e.g. fading a menu in/out using
- // top level window opacity.
- if (widget->windowType() == Qt::Popup)
- return new QRasterWindowSurface(widget);
-#endif
-
-#if defined(Q_WS_X11) && !defined(QT_NO_EGL)
- if (m_useX11GL && QX11GLPixmapData::hasX11GLPixmaps()) {
- // If the widget is a QGraphicsView which will be re-drawing the entire
- // scene each frame anyway, we should use QGLWindowSurface as this may
- // provide proper buffer flipping, which should be faster than QX11GL's
- // blitting approach:
- QGraphicsView* qgv = qobject_cast<QGraphicsView*>(widget);
- if (qgv && qgv->viewportUpdateMode() == QGraphicsView::FullViewportUpdate)
- return new QGLWindowSurface(widget);
- else
- return new QX11GLWindowSurface(widget);
- }
-#endif
-
-#if defined(Q_OS_SYMBIAN)
- if (!QApplicationPrivate::instance()->useTranslucentEGLSurfaces) {
- QWidgetPrivate *d = qt_widget_private(widget);
- if (!d->isOpaque && widget->testAttribute(Qt::WA_TranslucentBackground))
- return d->createDefaultWindowSurface_sys();
- }
-#endif
-
- return new QGLWindowSurface(widget);
-}
-#ifdef QGL_USE_TEXTURE_POOL
-void QGLGraphicsSystem::releaseCachedResources()
-{
- QGLTexturePool::instance()->hibernate();
-}
-#endif
-QT_END_NAMESPACE
-
diff --git a/src/opengl/qgraphicssystem_gl_p.h b/src/opengl/qgraphicssystem_gl_p.h
deleted file mode 100644
index 5829dccea9..0000000000
--- a/src/opengl/qgraphicssystem_gl_p.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenGL module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSSYSTEM_RASTER_P_H
-#define QGRAPHICSSYSTEM_RASTER_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "private/qgraphicssystem_p.h"
-
-#include <QMap>
-
-QT_BEGIN_NAMESPACE
-
-class Q_OPENGL_EXPORT QGLGraphicsSystem : public QGraphicsSystem
-{
-public:
- QGLGraphicsSystem(bool useX11GL);
-
- QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
- QWindowSurface *createWindowSurface(QWidget *widget) const;
-
-#ifdef QGL_USE_TEXTURE_POOL
- void releaseCachedResources();
-#endif
-private:
- bool m_useX11GL;
-};
-
-QT_END_NAMESPACE
-
-#endif
-
diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp
index 5fa9f32c8c..53f838c641 100644
--- a/src/opengl/qpaintengine_opengl.cpp
+++ b/src/opengl/qpaintengine_opengl.cpp
@@ -2361,8 +2361,8 @@ void QOpenGLPaintEngine::updateClipRegion(const QRegion &clipRegion, Qt::ClipOpe
} else {
#ifndef Q_WS_QWS
// Only use the system clip if we're currently rendering a widget with a GL painter.
- if (d->currentClipWidget) {
- QWidgetPrivate *widgetPrivate = qt_widget_private(d->currentClipWidget->window());
+ if (d->currentClipDevice) {
+ QWidgetPrivate *widgetPrivate = qt_widget_private(static_cast<QWidget *>(d->currentClipDevice)->window());
d->use_system_clip = widgetPrivate->extra && widgetPrivate->extra->inRenderWithPainter;
}
#endif
diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp
index 49b3dc2dae..62a631855f 100644
--- a/src/opengl/qwindowsurface_gl.cpp
+++ b/src/opengl/qwindowsurface_gl.cpp
@@ -39,11 +39,11 @@
**
****************************************************************************/
-#include <QtGui/QApplication>
+#include <QtWidgets/QApplication>
#include <QtGui/QColormap>
-#include <QtGui/QDesktopWidget>
+#include <QtWidgets/QDesktopWidget>
#include <QtGui/QPaintDevice>
-#include <QtGui/QWidget>
+#include <QtWidgets/QWidget>
#include <qglframebufferobject.h>
#include <qglpixelbuffer.h>
@@ -68,7 +68,6 @@
#include <private/qgl_p.h>
#include <private/qglpixelbuffer_p.h>
-#include <private/qgraphicssystem_gl_p.h>
#include <private/qpaintengineex_opengl2_p.h>
#include <private/qpixmapdata_gl_p.h>
@@ -86,97 +85,11 @@
#include <private/qeglcontext_p.h>
#endif
-QT_BEGIN_NAMESPACE
-
-//
-// QGLGraphicsSystem
-//
-#ifdef Q_WS_WIN
-extern Q_GUI_EXPORT bool qt_win_owndc_required;
+#ifdef Q_WS_QPA
+#include <qplatformscreen_qpa.h>
#endif
-QGLGraphicsSystem::QGLGraphicsSystem(bool useX11GL)
- : QGraphicsSystem(), m_useX11GL(useX11GL)
-{
-#if defined(Q_WS_X11) && !defined(QT_OPENGL_ES)
- // only override the system defaults if the user hasn't already
- // picked a visual
- if (X11->visual == 0 && X11->visual_id == -1 && X11->visual_class == -1) {
- // find a double buffered, RGBA visual that supports OpenGL
- // and set that as the default visual for windows in Qt
- int i = 0;
- int spec[16];
- spec[i++] = GLX_RGBA;
- spec[i++] = GLX_DOUBLEBUFFER;
-
- if (!qgetenv("QT_GL_SWAPBUFFER_PRESERVE").isNull()) {
- spec[i++] = GLX_DEPTH_SIZE;
- spec[i++] = 8;
- spec[i++] = GLX_STENCIL_SIZE;
- spec[i++] = 8;
- spec[i++] = GLX_SAMPLE_BUFFERS_ARB;
- spec[i++] = 1;
- spec[i++] = GLX_SAMPLES_ARB;
- spec[i++] = 4;
- }
- spec[i++] = XNone;
-
- XVisualInfo *vi = glXChooseVisual(X11->display, X11->defaultScreen, spec);
- if (vi) {
- X11->visual_id = vi->visualid;
- X11->visual_class = vi->c_class;
-
- QGLFormat format;
- int res;
- glXGetConfig(X11->display, vi, GLX_LEVEL, &res);
- format.setPlane(res);
- glXGetConfig(X11->display, vi, GLX_DOUBLEBUFFER, &res);
- format.setDoubleBuffer(res);
- glXGetConfig(X11->display, vi, GLX_DEPTH_SIZE, &res);
- format.setDepth(res);
- if (format.depth())
- format.setDepthBufferSize(res);
- glXGetConfig(X11->display, vi, GLX_RGBA, &res);
- format.setRgba(res);
- glXGetConfig(X11->display, vi, GLX_RED_SIZE, &res);
- format.setRedBufferSize(res);
- glXGetConfig(X11->display, vi, GLX_GREEN_SIZE, &res);
- format.setGreenBufferSize(res);
- glXGetConfig(X11->display, vi, GLX_BLUE_SIZE, &res);
- format.setBlueBufferSize(res);
- glXGetConfig(X11->display, vi, GLX_ALPHA_SIZE, &res);
- format.setAlpha(res);
- if (format.alpha())
- format.setAlphaBufferSize(res);
- glXGetConfig(X11->display, vi, GLX_ACCUM_RED_SIZE, &res);
- format.setAccum(res);
- if (format.accum())
- format.setAccumBufferSize(res);
- glXGetConfig(X11->display, vi, GLX_STENCIL_SIZE, &res);
- format.setStencil(res);
- if (format.stencil())
- format.setStencilBufferSize(res);
- glXGetConfig(X11->display, vi, GLX_STEREO, &res);
- format.setStereo(res);
- glXGetConfig(X11->display, vi, GLX_SAMPLE_BUFFERS_ARB, &res);
- format.setSampleBuffers(res);
- if (format.sampleBuffers()) {
- glXGetConfig(X11->display, vi, GLX_SAMPLES_ARB, &res);
- format.setSamples(res);
- }
-
- QGLWindowSurface::surfaceFormat = format;
- XFree(vi);
-
- printf("using visual class %x, id %x\n", X11->visual_class, X11->visual_id);
- }
- }
-#elif defined(Q_WS_WIN)
- QGLWindowSurface::surfaceFormat.setDoubleBuffer(true);
-
- qt_win_owndc_required = true;
-#endif
-}
+QT_BEGIN_NAMESPACE
//
// QGLWindowSurface
@@ -359,7 +272,31 @@ QGLContext* QGLWindowSurfaceGLPaintDevice::context() const
int QGLWindowSurfaceGLPaintDevice::metric(PaintDeviceMetric m) const
{
- return qt_paint_device_metric(d->q_ptr->window(), m);
+ QWindow *window = d->q_ptr->window();
+ QPlatformScreen *screen = QPlatformScreen::platformScreenForWindow(window);
+ if (!screen) {
+ if (m == PdmDpiX || m == PdmDpiY)
+ return 72;
+ }
+ int val;
+ if (m == PdmWidth) {
+ val = window->geometry().width();
+ } else if (m == PdmWidthMM) {
+ val = window->geometry().width() * screen->physicalSize().width() / screen->geometry().width();
+ } else if (m == PdmHeight) {
+ val = window->geometry().height();
+ } else if (m == PdmHeightMM) {
+ val = window->geometry().height() * screen->physicalSize().height() / screen->geometry().height();
+ } else if (m == PdmDepth) {
+ val = screen->depth();
+ } else if (m == PdmDpiX || m == PdmPhysicalDpiX) {
+ val = qRound(screen->geometry().width() / double(screen->physicalSize().width() / 25.4));
+ } else if (m == PdmDpiY || m == PdmPhysicalDpiY) {
+ val = qRound(screen->geometry().height() / double(screen->physicalSize().height() / 25.4));
+ } else {
+ val = 1 << qMax(24, screen->depth());
+ }
+ return val;
}
QPaintEngine *QGLWindowSurfaceGLPaintDevice::paintEngine() const
@@ -367,7 +304,7 @@ QPaintEngine *QGLWindowSurfaceGLPaintDevice::paintEngine() const
return qt_qgl_paint_engine();
}
-QGLWindowSurface::QGLWindowSurface(QWidget *window)
+QGLWindowSurface::QGLWindowSurface(QWindow *window)
: QWindowSurface(window), d_ptr(new QGLWindowSurfacePrivate)
{
// Q_ASSERT(window->isTopLevel());
@@ -428,6 +365,7 @@ QGLWindowSurface::~QGLWindowSurface()
void QGLWindowSurface::deleted(QObject *object)
{
+#if 0
QWidget *widget = qobject_cast<QWidget *>(object);
if (widget) {
if (widget == window()) {
@@ -450,10 +388,12 @@ void QGLWindowSurface::deleted(QObject *object)
}
#endif
}
+#endif
}
-void QGLWindowSurface::hijackWindow(QWidget *widget)
+void QGLWindowSurface::hijackWindow(QWindow *window)
{
+#if 0
QWidgetPrivate *widgetPrivate = widget->d_func();
widgetPrivate->createExtra();
if (widgetPrivate->extraData()->glContext)
@@ -511,6 +451,7 @@ void QGLWindowSurface::hijackWindow(QWidget *widget)
#ifndef Q_OS_SYMBIAN
qDebug() << "hijackWindow() context created for" << widget << d_ptr->contexts.size();
#endif
+#endif
}
QGLContext *QGLWindowSurface::context() const
@@ -528,8 +469,10 @@ QPaintDevice *QGLWindowSurface::paintDevice()
if (d_ptr->ctx)
return &d_ptr->glDevice;
+#if 0
QGLContext *ctx = reinterpret_cast<QGLContext *>(window()->d_func()->extraData()->glContext);
ctx->makeCurrent();
+#endif
Q_ASSERT(d_ptr->fbo);
return d_ptr->fbo;
@@ -600,8 +543,9 @@ static void blitTexture(QGLContext *ctx, GLuint texture, const QSize &viewport,
}
-void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &offset)
+void QGLWindowSurface::flush(QWindow *window, const QRegion &rgn, const QPoint &offset)
{
+#if 0
//### Find out why d_ptr->geometry_updated isn't always false.
// flush() should not be called when d_ptr->geometry_updated is true. It assumes that either
// d_ptr->fbo or d_ptr->pb is allocated and has the correct size.
@@ -864,7 +808,7 @@ void QGLWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint &
ctx->swapBuffers();
else
glFlush();
-
+#endif
d_ptr->did_paint = false;
}
@@ -884,6 +828,7 @@ void QGLWindowSurface::resize(const QSize &size)
#endif
void QGLWindowSurface::updateGeometry() {
+#if 0
if (!d_ptr->geometry_updated)
return;
d_ptr->geometry_updated = false;
@@ -1018,6 +963,7 @@ void QGLWindowSurface::updateGeometry() {
#endif
d_ptr->ctx = ctx;
d_ptr->ctx->d_ptr->internal_context = true;
+#endif
}
bool QGLWindowSurface::initializeOffscreenTexture(const QSize &size)
@@ -1039,6 +985,7 @@ bool QGLWindowSurface::initializeOffscreenTexture(const QSize &size)
bool QGLWindowSurface::scroll(const QRegion &area, int dx, int dy)
{
+#if 0
// this code randomly fails currently for unknown reasons
return false;
@@ -1067,7 +1014,7 @@ bool QGLWindowSurface::scroll(const QRegion &area, int dx, int dy)
glBindTexture(target, 0);
drawTexture(br.translated(dx, dy), d_ptr->tex_id, window()->size());
-
+#endif
return true;
}
@@ -1132,26 +1079,6 @@ static void drawTexture(const QRectF &rect, GLuint tex_id, const QSize &texSize,
#endif
}
-QImage *QGLWindowSurface::buffer(const QWidget *widget)
-{
- QImage image;
-
- if (d_ptr->pb)
- image = d_ptr->pb->toImage();
- else if (d_ptr->fbo)
- image = d_ptr->fbo->toImage();
-
- if (image.isNull())
- return 0;
-
- QRect rect = widget->rect();
- rect.translate(widget->mapTo(widget->window(), QPoint()));
-
- QImage subImage = image.copy(rect);
- d_ptr->buffers << subImage;
- return &d_ptr->buffers.last();
-}
-
QWindowSurface::WindowSurfaceFeatures QGLWindowSurface::features() const
{
WindowSurfaceFeatures features = 0;
diff --git a/src/opengl/qwindowsurface_gl_p.h b/src/opengl/qwindowsurface_gl_p.h
index c71ce59c4d..8dc3a4583a 100644
--- a/src/opengl/qwindowsurface_gl_p.h
+++ b/src/opengl/qwindowsurface_gl_p.h
@@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE
class QPaintDevice;
class QPoint;
class QRegion;
-class QWidget;
+class QWindow;
struct QGLWindowSurfacePrivate;
Q_OPENGL_EXPORT QGLWidget* qt_gl_share_widget();
@@ -84,11 +84,11 @@ class Q_OPENGL_EXPORT QGLWindowSurface : public QObject, public QWindowSurface /
{
Q_OBJECT
public:
- QGLWindowSurface(QWidget *window);
+ QGLWindowSurface(QWindow *window);
~QGLWindowSurface();
QPaintDevice *paintDevice();
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+ void flush(QWindow *window, const QRegion &region, const QPoint &offset);
#if !defined(Q_WS_QPA)
void setGeometry(const QRect &rect);
@@ -102,8 +102,6 @@ public:
void beginPaint(const QRegion &region);
void endPaint(const QRegion &region);
- QImage *buffer(const QWidget *widget);
-
WindowSurfaceFeatures features() const;
QGLContext *context() const;
@@ -117,7 +115,7 @@ private slots:
void deleted(QObject *object);
private:
- void hijackWindow(QWidget *widget);
+ void hijackWindow(QWindow *window);
bool initializeOffscreenTexture(const QSize &size);
QGLWindowSurfacePrivate *d_ptr;
diff --git a/src/openvg/openvg.pro b/src/openvg/openvg.pro
deleted file mode 100644
index dbe1620f80..0000000000
--- a/src/openvg/openvg.pro
+++ /dev/null
@@ -1,74 +0,0 @@
-TARGET = QtOpenVG
-QT += core-private \
- gui-private
-
-CONFIG += module
-MODULE_PRI = ../modules/qt_openvg.pri
-
-DEFINES+=QT_BUILD_OPENVG_LIB
-
-contains(QT_CONFIG, shivavg) {
- DEFINES += QVG_NO_DRAW_GLYPHS
- DEFINES += QVG_NO_RENDER_TO_MASK
- DEFINES += QVG_SCISSOR_CLIP
-}
-
-HEADERS += \
- qvg.h \
- qvg_p.h \
- qpaintengine_vg_p.h \
- qpixmapdata_vg_p.h \
- qpixmapfilter_vg_p.h \
- qvgcompositionhelper_p.h \
- qvgimagepool_p.h \
- qvgfontglyphcache_p.h
-SOURCES += \
- qpaintengine_vg.cpp \
- qpixmapdata_vg.cpp \
- qpixmapfilter_vg.cpp \
- qvgimagepool.cpp
-
-contains(QT_CONFIG, egl) {
- HEADERS += \
- qwindowsurface_vgegl_p.h \
- qwindowsurface_vg_p.h
- SOURCES += \
- qwindowsurface_vg.cpp \
- qwindowsurface_vgegl.cpp
-}
-
-symbian {
- DEFINES += QVG_RECREATE_ON_SIZE_CHANGE QVG_BUFFER_SCROLLING QVG_SCISSOR_CLIP
- SOURCES += \
- qvg_symbian.cpp
-
- contains(QT_CONFIG, freetype) {
- DEFINES += QT_NO_FONTCONFIG
- INCLUDEPATH += \
- ../3rdparty/freetype/src \
- ../3rdparty/freetype/include
- }
-}
-
-include(../qbase.pri)
-
-unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES = QtCore QtGui
-symbian:TARGET.UID3 = 0x2001E62F
-
-!isEmpty(QMAKE_INCDIR_OPENVG): INCLUDEPATH += $$QMAKE_INCDIR_OPENVG
-!isEmpty(QMAKE_LIBDIR_OPENVG): LIBS_PRIVATE += -L$$QMAKE_LIBDIR_OPENVG
-!isEmpty(QMAKE_LIBS_OPENVG): LIBS_PRIVATE += $$QMAKE_LIBS_OPENVG
-
-contains(QT_CONFIG, egl) {
- !isEmpty(QMAKE_INCDIR_EGL): INCLUDEPATH += $$QMAKE_INCDIR_EGL
- !isEmpty(QMAKE_LIBDIR_EGL): LIBS_PRIVATE += -L$$QMAKE_LIBDIR_EGL
- !isEmpty(QMAKE_LIBS_EGL): LIBS_PRIVATE += $$QMAKE_LIBS_EGL
-}
-
-contains(QT_CONFIG, openvg_on_opengl) {
- !isEmpty(QMAKE_INCDIR_OPENGL): INCLUDEPATH += $$QMAKE_INCDIR_OPENGL
- !isEmpty(QMAKE_LIBDIR_OPENGL): LIBS_PRIVATE += -L$$QMAKE_LIBDIR_OPENGL
- !isEmpty(QMAKE_LIBS_OPENGL): LIBS_PRIVATE += $$QMAKE_LIBS_OPENGL
-}
-
-INCLUDEPATH += ../3rdparty/harfbuzz/src
diff --git a/src/openvg/qpaintengine_vg.cpp b/src/openvg/qpaintengine_vg.cpp
deleted file mode 100644
index 68a6a0b6bd..0000000000
--- a/src/openvg/qpaintengine_vg.cpp
+++ /dev/null
@@ -1,4269 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qpaintengine_vg_p.h"
-#include "qpixmapdata_vg_p.h"
-#include "qpixmapfilter_vg_p.h"
-#include "qvgcompositionhelper_p.h"
-#include "qvgimagepool_p.h"
-#include "qvgfontglyphcache_p.h"
-#if !defined(QT_NO_EGL)
-#include <QtGui/private/qeglcontext_p.h>
-#include "qwindowsurface_vgegl_p.h"
-#endif
-#include <QtCore/qvarlengtharray.h>
-#include <QtGui/private/qdrawhelper_p.h>
-#include <QtGui/private/qtextengine_p.h>
-#include <QtGui/private/qfontengine_p.h>
-#include <QtGui/private/qpainterpath_p.h>
-#include <QtGui/private/qstatictext_p.h>
-#include <QtGui/QApplication>
-#include <QtGui/QDesktopWidget>
-#include <QtCore/qmath.h>
-#include <QDebug>
-#include <QSet>
-
-QT_BEGIN_NAMESPACE
-
-// vgRenderToMask() only exists in OpenVG 1.1 and higher.
-// Also, disable masking completely if we are using the scissor to clip.
-#if !defined(OPENVG_VERSION_1_1) && !defined(QVG_NO_RENDER_TO_MASK)
-#define QVG_NO_RENDER_TO_MASK 1
-#endif
-#if defined(QVG_SCISSOR_CLIP) && !defined(QVG_NO_RENDER_TO_MASK)
-#define QVG_NO_RENDER_TO_MASK 1
-#endif
-
-// use the same rounding as in qrasterizer.cpp (6 bit fixed point)
-static const qreal aliasedCoordinateDelta = 0.5 - 0.015625;
-
-#if !defined(QVG_NO_DRAW_GLYPHS)
-
-class QVGPaintEnginePrivate;
-
-typedef QHash<QFontEngine*, QVGFontGlyphCache*> QVGFontCache;
-
-#endif
-
-class QVGFontEngineCleaner : public QObject
-{
- Q_OBJECT
-public:
- QVGFontEngineCleaner(QVGPaintEnginePrivate *d);
- ~QVGFontEngineCleaner();
-
-public slots:
- void fontEngineDestroyed();
-
-private:
- QVGPaintEnginePrivate *d_ptr;
-};
-
-class QVGPaintEnginePrivate : public QPaintEngineExPrivate
-{
- Q_DECLARE_PUBLIC(QVGPaintEngine)
-public:
- // Extra blending modes from VG_KHR_advanced_blending extension.
- // Use the QT_VG prefix to avoid conflicts with any definitions
- // that may come in via <VG/vgext.h>.
- enum AdvancedBlending {
- QT_VG_BLEND_OVERLAY_KHR = 0x2010,
- QT_VG_BLEND_HARDLIGHT_KHR = 0x2011,
- QT_VG_BLEND_SOFTLIGHT_SVG_KHR = 0x2012,
- QT_VG_BLEND_SOFTLIGHT_KHR = 0x2013,
- QT_VG_BLEND_COLORDODGE_KHR = 0x2014,
- QT_VG_BLEND_COLORBURN_KHR = 0x2015,
- QT_VG_BLEND_DIFFERENCE_KHR = 0x2016,
- QT_VG_BLEND_SUBTRACT_KHR = 0x2017,
- QT_VG_BLEND_INVERT_KHR = 0x2018,
- QT_VG_BLEND_EXCLUSION_KHR = 0x2019,
- QT_VG_BLEND_LINEARDODGE_KHR = 0x201a,
- QT_VG_BLEND_LINEARBURN_KHR = 0x201b,
- QT_VG_BLEND_VIVIDLIGHT_KHR = 0x201c,
- QT_VG_BLEND_LINEARLIGHT_KHR = 0x201d,
- QT_VG_BLEND_PINLIGHT_KHR = 0x201e,
- QT_VG_BLEND_HARDMIX_KHR = 0x201f,
- QT_VG_BLEND_CLEAR_KHR = 0x2020,
- QT_VG_BLEND_DST_KHR = 0x2021,
- QT_VG_BLEND_SRC_OUT_KHR = 0x2022,
- QT_VG_BLEND_DST_OUT_KHR = 0x2023,
- QT_VG_BLEND_SRC_ATOP_KHR = 0x2024,
- QT_VG_BLEND_DST_ATOP_KHR = 0x2025,
- QT_VG_BLEND_XOR_KHR = 0x2026
- };
-
- QVGPaintEnginePrivate(QVGPaintEngine *q_ptr);
- ~QVGPaintEnginePrivate();
-
- void init();
- void initObjects();
- void destroy();
- void setTransform(VGMatrixMode mode, const QTransform& transform);
- void updateTransform(QPaintDevice *pdev);
- void draw(VGPath path, const QPen& pen, const QBrush& brush, VGint rule = VG_EVEN_ODD);
- void stroke(VGPath path, const QPen& pen);
- void fill(VGPath path, const QBrush& brush, VGint rule = VG_EVEN_ODD);
- VGPath vectorPathToVGPath(const QVectorPath& path);
- VGPath painterPathToVGPath(const QPainterPath& path);
- VGPath roundedRectPath(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode);
- VGPaintType setBrush
- (VGPaint paint, const QBrush& brush, VGMatrixMode mode,
- VGPaintType prevPaintType);
- void setPenParams(const QPen& pen);
- void setBrushTransform(const QBrush& brush, VGMatrixMode mode);
- void setupColorRamp(const QGradient *grad, VGPaint paint);
- void setImageOptions();
- void systemStateChanged();
-#if !defined(QVG_SCISSOR_CLIP)
- void ensureMask(QVGPaintEngine *engine, int width, int height);
- void modifyMask
- (QVGPaintEngine *engine, VGMaskOperation op, const QRegion& region);
- void modifyMask
- (QVGPaintEngine *engine, VGMaskOperation op, const QRect& rect);
-#endif
-
- VGint maxScissorRects; // Maximum scissor rectangles for clipping.
-
- VGPaint penPaint; // Paint for currently active pen.
- VGPaint brushPaint; // Paint for currently active brush.
- VGPaint opacityPaint; // Paint for drawing images with opacity.
- VGPaint fillPaint; // Current fill paint that is active.
-
- QPen currentPen; // Current pen set in "penPaint".
- QBrush currentBrush; // Current brush set in "brushPaint".
-
- bool forcePenChange; // Force a pen change, even if the same.
- bool forceBrushChange; // Force a brush change, even if the same.
-
- bool hasExtendedRadialGradientPen; // Current pen's brush is extended radial gradient.
- bool hasExtendedRadialGradientBrush; // Current brush is extended radial gradient.
-
- VGPaintType penType; // Type of the last pen that was set.
- VGPaintType brushType; // Type of the last brush that was set.
-
- QPointF brushOrigin; // Current brush origin.
-
- VGint fillRule; // Last fill rule that was set.
-
- qreal opacity; // Current drawing opacity.
- qreal paintOpacity; // Opacity in opacityPaint.
-
-#if !defined(QVG_NO_MODIFY_PATH)
- VGPath rectPath; // Cached path for quick drawing of rectangles.
- VGPath linePath; // Cached path for quick drawing of lines.
- VGPath roundRectPath; // Cached path for quick drawing of rounded rects.
-#endif
-
- QTransform transform; // Currently active transform.
- bool simpleTransform; // True if the transform is simple (non-projective).
- qreal penScale; // Pen scaling factor from "transform".
-
- QTransform pathTransform; // Calculated VG path transformation.
- QTransform imageTransform; // Calculated VG image transformation.
- bool pathTransformSet; // True if path transform set in the VG context.
-
- bool maskValid; // True if vgMask() contains valid data.
- bool maskIsSet; // True if mask would be fully set if it was valid.
- bool scissorMask; // True if scissor is used in place of the mask.
- bool rawVG; // True if processing a raw VG escape.
-
- QRect maskRect; // Rectangle version of mask if it is simple.
-
- QTransform penTransform; // Transform for the pen.
- QTransform brushTransform; // Transform for the brush.
-
- VGMatrixMode matrixMode; // Last matrix mode that was set.
- VGImageMode imageMode; // Last image mode that was set.
-
- QRegion scissorRegion; // Currently active scissor region.
- bool scissorActive; // True if scissor region is active.
- bool scissorDirty; // True if scissor is dirty after native painting.
-
- QPaintEngine::DirtyFlags dirty;
-
- QColor clearColor; // Last clear color that was set.
- VGfloat clearOpacity; // Opacity during the last clear.
-
- VGBlendMode blendMode; // Active blend mode.
- VGRenderingQuality renderingQuality; // Active rendering quality.
- VGImageQuality imageQuality; // Active image quality.
-
-#if !defined(QVG_NO_DRAW_GLYPHS)
- QVGFontCache fontCache;
- QVGFontEngineCleaner *fontEngineCleaner;
-#endif
-
- bool hasAdvancedBlending;
-
- QScopedPointer<QPixmapFilter> convolutionFilter;
- QScopedPointer<QPixmapFilter> colorizeFilter;
- QScopedPointer<QPixmapFilter> dropShadowFilter;
- QScopedPointer<QPixmapFilter> blurFilter;
-
- // Ensure that the path transform is properly set in the VG context
- // before we perform a vgDrawPath() operation.
- inline void ensurePathTransform()
- {
- if (!pathTransformSet) {
- QTransform aliasedTransform = pathTransform;
- if (renderingQuality == VG_RENDERING_QUALITY_NONANTIALIASED && currentPen != Qt::NoPen)
- aliasedTransform = aliasedTransform
- * QTransform::fromTranslate(aliasedCoordinateDelta, -aliasedCoordinateDelta);
- setTransform(VG_MATRIX_PATH_USER_TO_SURFACE, aliasedTransform);
- pathTransformSet = true;
- }
- }
-
- // Ensure that a specific pen has been set into penPaint.
- inline void ensurePen(const QPen& pen) {
- if (forcePenChange || pen != currentPen) {
- currentPen = pen;
- forcePenChange = false;
- penType = setBrush
- (penPaint, pen.brush(),
- VG_MATRIX_STROKE_PAINT_TO_USER, penType);
- setPenParams(pen);
- }
- }
-
- // Ensure that a specific brush has been set into brushPaint.
- inline void ensureBrush(const QBrush& brush) {
- if (forceBrushChange || brush != currentBrush) {
- currentBrush = brush;
- forceBrushChange = false;
- brushType = setBrush
- (brushPaint, brush, VG_MATRIX_FILL_PAINT_TO_USER, brushType);
- }
- if (fillPaint != brushPaint) {
- vgSetPaint(brushPaint, VG_FILL_PATH);
- fillPaint = brushPaint;
- }
- }
-
- inline bool needsEmulation(const QBrush &brush) const
- {
- extern bool qt_isExtendedRadialGradient(const QBrush &brush);
- return qt_isExtendedRadialGradient(brush);
- }
-
- inline bool needsEmulation() const
- {
- return hasExtendedRadialGradientPen || hasExtendedRadialGradientBrush;
- }
-
- inline bool needsPenEmulation() const
- {
- return hasExtendedRadialGradientPen;
- }
-
- inline bool needsBrushEmulation() const
- {
- return hasExtendedRadialGradientBrush;
- }
-
- // Set various modes, but only if different.
- inline void setImageMode(VGImageMode mode);
- inline void setRenderingQuality(VGRenderingQuality mode);
- inline void setImageQuality(VGImageQuality mode);
- inline void setBlendMode(VGBlendMode mode);
- inline void setFillRule(VGint mode);
-
- // Clear all lazily-set modes.
- void clearModes();
-
-private:
- QVGPaintEngine *q;
-};
-
-inline void QVGPaintEnginePrivate::setImageMode(VGImageMode mode)
-{
- if (imageMode != mode) {
- imageMode = mode;
- vgSeti(VG_IMAGE_MODE, mode);
- }
-}
-
-inline void QVGPaintEnginePrivate::setRenderingQuality(VGRenderingQuality mode)
-{
- if (renderingQuality != mode) {
- vgSeti(VG_RENDERING_QUALITY, mode);
- renderingQuality = mode;
- pathTransformSet = false; // need to tweak transform for aliased stroking
- }
-}
-
-inline void QVGPaintEnginePrivate::setImageQuality(VGImageQuality mode)
-{
- if (imageQuality != mode) {
- vgSeti(VG_IMAGE_QUALITY, mode);
- imageQuality = mode;
- }
-}
-
-inline void QVGPaintEnginePrivate::setBlendMode(VGBlendMode mode)
-{
- if (blendMode != mode) {
- vgSeti(VG_BLEND_MODE, mode);
- blendMode = mode;
- }
-}
-
-inline void QVGPaintEnginePrivate::setFillRule(VGint mode)
-{
- if (fillRule != mode) {
- fillRule = mode;
- vgSeti(VG_FILL_RULE, mode);
- }
-}
-
-void QVGPaintEnginePrivate::clearModes()
-{
- matrixMode = (VGMatrixMode)0;
- imageMode = (VGImageMode)0;
- blendMode = (VGBlendMode)0;
- renderingQuality = (VGRenderingQuality)0;
- imageQuality = (VGImageQuality)0;
-}
-
-QVGPaintEnginePrivate::QVGPaintEnginePrivate(QVGPaintEngine *q_ptr) : q(q_ptr)
-{
- init();
-}
-
-void QVGPaintEnginePrivate::init()
-{
- maxScissorRects = 0;
-
- penPaint = 0;
- brushPaint = 0;
- opacityPaint = 0;
- fillPaint = 0;
-
- forcePenChange = true;
- forceBrushChange = true;
-
- hasExtendedRadialGradientPen = false;
- hasExtendedRadialGradientBrush = false;
-
- penType = (VGPaintType)0;
- brushType = (VGPaintType)0;
-
- brushOrigin = QPointF(0.0f, 0.0f);
-
- fillRule = 0;
-
- opacity = 1.0;
- paintOpacity = 1.0f;
-
-#if !defined(QVG_NO_MODIFY_PATH)
- rectPath = 0;
- linePath = 0;
- roundRectPath = 0;
-#endif
-
- simpleTransform = true;
- pathTransformSet = false;
- penScale = 1.0;
-
- maskValid = false;
- maskIsSet = false;
- scissorMask = false;
- rawVG = false;
-
- scissorActive = false;
- scissorDirty = false;
-
- dirty = 0;
-
- clearOpacity = 1.0f;
-
-#if !defined(QVG_NO_DRAW_GLYPHS)
- fontEngineCleaner = 0;
-#endif
-
- hasAdvancedBlending = false;
-
- clearModes();
-}
-
-QVGPaintEnginePrivate::~QVGPaintEnginePrivate()
-{
- destroy();
-}
-
-void QVGPaintEnginePrivate::initObjects()
-{
- maxScissorRects = vgGeti(VG_MAX_SCISSOR_RECTS);
-
- penPaint = vgCreatePaint();
- vgSetParameteri(penPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
- vgSetPaint(penPaint, VG_STROKE_PATH);
-
- vgSeti(VG_MATRIX_MODE, VG_MATRIX_STROKE_PAINT_TO_USER);
- vgLoadIdentity();
-
- brushPaint = vgCreatePaint();
- vgSetParameteri(brushPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
- vgSetPaint(brushPaint, VG_FILL_PATH);
- fillPaint = brushPaint;
-
- vgSeti(VG_MATRIX_MODE, VG_MATRIX_FILL_PAINT_TO_USER);
- vgLoadIdentity();
- matrixMode = VG_MATRIX_FILL_PAINT_TO_USER;
-
- opacityPaint = vgCreatePaint();
- vgSetParameteri(opacityPaint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
- VGfloat values[4];
- values[0] = 1.0f;
- values[1] = 1.0f;
- values[2] = 1.0f;
- values[3] = paintOpacity;
- vgSetParameterfv(opacityPaint, VG_PAINT_COLOR, 4, values);
-
-#if !defined(QVG_NO_MODIFY_PATH)
- // Create a dummy path for rectangle drawing, which we can
- // modify later with vgModifyPathCoords(). This should be
- // faster than constantly creating and destroying paths.
- rectPath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- 5, // segmentCapacityHint
- 8, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
- static VGubyte const segments[5] = {
- VG_MOVE_TO_ABS,
- VG_LINE_TO_ABS,
- VG_LINE_TO_ABS,
- VG_LINE_TO_ABS,
- VG_CLOSE_PATH
- };
- VGfloat coords[8];
- coords[0] = 0.0f;
- coords[1] = 0.0f;
- coords[2] = 100.0f;
- coords[3] = coords[1];
- coords[4] = coords[2];
- coords[5] = 100.0f;
- coords[6] = coords[0];
- coords[7] = coords[5];
- vgAppendPathData(rectPath, 5, segments, coords);
-
- // Create a dummy line drawing path as well.
- linePath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- 2, // segmentCapacityHint
- 4, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
- vgAppendPathData(linePath, 2, segments, coords);
-#endif
-
- const char *extensions = reinterpret_cast<const char *>(vgGetString(VG_EXTENSIONS));
- if (extensions)
- hasAdvancedBlending = strstr(extensions, "VG_KHR_advanced_blending") != 0;
-}
-
-void QVGPaintEnginePrivate::destroy()
-{
- if (penPaint)
- vgDestroyPaint(penPaint);
- if (brushPaint)
- vgDestroyPaint(brushPaint);
- if (opacityPaint)
- vgDestroyPaint(opacityPaint);
-
-#if !defined(QVG_NO_MODIFY_PATH)
- if (rectPath)
- vgDestroyPath(rectPath);
- if (linePath)
- vgDestroyPath(linePath);
- if (roundRectPath)
- vgDestroyPath(roundRectPath);
-#endif
-
-#if !defined(QVG_NO_DRAW_GLYPHS)
- QVGFontCache::Iterator it;
- for (it = fontCache.begin(); it != fontCache.end(); ++it)
- delete it.value();
- fontCache.clear();
- delete fontEngineCleaner;
-#endif
-}
-
-// Set a specific VG transformation matrix in the current VG context.
-void QVGPaintEnginePrivate::setTransform
- (VGMatrixMode mode, const QTransform& transform)
-{
- VGfloat mat[9];
- if (mode != matrixMode) {
- vgSeti(VG_MATRIX_MODE, mode);
- matrixMode = mode;
- }
- mat[0] = transform.m11();
- mat[1] = transform.m12();
- mat[2] = transform.m13();
- mat[3] = transform.m21();
- mat[4] = transform.m22();
- mat[5] = transform.m23();
- mat[6] = transform.m31();
- mat[7] = transform.m32();
- mat[8] = transform.m33();
- vgLoadMatrix(mat);
-}
-
-Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale);
-
-void QVGPaintEnginePrivate::updateTransform(QPaintDevice *pdev)
-{
- VGfloat devh = pdev->height();
-
- // Construct the VG transform by combining the Qt transform with
- // the following viewport transformation:
- // | 1 0 0 |
- // | 0 -1 devh |
- // | 0 0 1 |
- // The full VG transform is effectively:
- // 1. Apply the user's transformation matrix.
- // 2. Flip the co-ordinate system upside down.
- QTransform viewport(1.0f, 0.0f, 0.0f,
- 0.0f, -1.0f, 0.0f,
- 0.0f, devh, 1.0f);
-
- // Compute the path transform and determine if it is projective.
- pathTransform = transform * viewport;
- bool projective = (pathTransform.m13() != 0.0f ||
- pathTransform.m23() != 0.0f ||
- pathTransform.m33() != 1.0f);
- if (projective) {
- // The engine cannot do projective path transforms for us,
- // so we will have to convert the co-ordinates ourselves.
- // Change the matrix to just the viewport transformation.
- pathTransform = viewport;
- simpleTransform = false;
- } else {
- simpleTransform = true;
- }
- pathTransformSet = false;
-
- // The image transform is always the full transformation,
- imageTransform = transform * viewport;
-
- // Calculate the scaling factor to use for turning cosmetic pens
- // into ordinary non-cosmetic pens.
- qt_scaleForTransform(transform, &penScale);
-}
-
-VGPath QVGPaintEnginePrivate::vectorPathToVGPath(const QVectorPath& path)
-{
- int count = path.elementCount();
- const qreal *points = path.points();
- const QPainterPath::ElementType *elements = path.elements();
-
- VGPath vgpath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- count + 1, // segmentCapacityHint
- count * 2, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
-
- // Size is sufficient segments for drawRoundedRect() paths.
- QVarLengthArray<VGubyte, 20> segments;
-
- if (sizeof(qreal) == sizeof(VGfloat) && elements && simpleTransform) {
- // If Qt was compiled with qreal the same size as VGfloat,
- // then convert the segment types and use the incoming
- // points array directly.
- for (int i = 0; i < count; ++i) {
- switch (elements[i]) {
-
- case QPainterPath::MoveToElement:
- segments.append(VG_MOVE_TO_ABS); break;
-
- case QPainterPath::LineToElement:
- segments.append(VG_LINE_TO_ABS); break;
-
- case QPainterPath::CurveToElement:
- segments.append(VG_CUBIC_TO_ABS); break;
-
- case QPainterPath::CurveToDataElement: break;
-
- }
- }
- if (path.hasImplicitClose())
- segments.append(VG_CLOSE_PATH);
-
- vgAppendPathData(vgpath, segments.count(), segments.constData(),
- reinterpret_cast<const VGfloat *>(points));
-
- return vgpath;
- }
-
- // Sizes chosen so that drawRoundedRect() paths fit in these arrays.
- QVarLengthArray<VGfloat, 48> coords;
-
- int curvePos = 0;
- QPointF temp;
-
- if (elements && simpleTransform) {
- // Convert the members of the element array.
- for (int i = 0; i < count; ++i) {
- switch (elements[i]) {
-
- case QPainterPath::MoveToElement:
- {
- coords.append(points[0]);
- coords.append(points[1]);
- segments.append(VG_MOVE_TO_ABS);
- }
- break;
-
- case QPainterPath::LineToElement:
- {
- coords.append(points[0]);
- coords.append(points[1]);
- segments.append(VG_LINE_TO_ABS);
- }
- break;
-
- case QPainterPath::CurveToElement:
- {
- coords.append(points[0]);
- coords.append(points[1]);
- curvePos = 2;
- }
- break;
-
- case QPainterPath::CurveToDataElement:
- {
- coords.append(points[0]);
- coords.append(points[1]);
- curvePos += 2;
- if (curvePos == 6) {
- curvePos = 0;
- segments.append(VG_CUBIC_TO_ABS);
- }
- }
- break;
-
- }
- points += 2;
- }
- } else if (elements && !simpleTransform) {
- // Convert the members of the element array after applying the
- // current transform to the path locally.
- for (int i = 0; i < count; ++i) {
- switch (elements[i]) {
-
- case QPainterPath::MoveToElement:
- {
- temp = transform.map(QPointF(points[0], points[1]));
- coords.append(temp.x());
- coords.append(temp.y());
- segments.append(VG_MOVE_TO_ABS);
- }
- break;
-
- case QPainterPath::LineToElement:
- {
- temp = transform.map(QPointF(points[0], points[1]));
- coords.append(temp.x());
- coords.append(temp.y());
- segments.append(VG_LINE_TO_ABS);
- }
- break;
-
- case QPainterPath::CurveToElement:
- {
- temp = transform.map(QPointF(points[0], points[1]));
- coords.append(temp.x());
- coords.append(temp.y());
- curvePos = 2;
- }
- break;
-
- case QPainterPath::CurveToDataElement:
- {
- temp = transform.map(QPointF(points[0], points[1]));
- coords.append(temp.x());
- coords.append(temp.y());
- curvePos += 2;
- if (curvePos == 6) {
- curvePos = 0;
- segments.append(VG_CUBIC_TO_ABS);
- }
- }
- break;
-
- }
- points += 2;
- }
- } else if (count > 0 && simpleTransform) {
- // If there is no element array, then the path is assumed
- // to be a MoveTo followed by several LineTo's.
- coords.append(points[0]);
- coords.append(points[1]);
- segments.append(VG_MOVE_TO_ABS);
- while (count > 1) {
- points += 2;
- coords.append(points[0]);
- coords.append(points[1]);
- segments.append(VG_LINE_TO_ABS);
- --count;
- }
- } else if (count > 0 && !simpleTransform) {
- // Convert a simple path, and apply the transform locally.
- temp = transform.map(QPointF(points[0], points[1]));
- coords.append(temp.x());
- coords.append(temp.y());
- segments.append(VG_MOVE_TO_ABS);
- while (count > 1) {
- points += 2;
- temp = transform.map(QPointF(points[0], points[1]));
- coords.append(temp.x());
- coords.append(temp.y());
- segments.append(VG_LINE_TO_ABS);
- --count;
- }
- }
-
- // Close the path if specified.
- if (path.hasImplicitClose())
- segments.append(VG_CLOSE_PATH);
-
- vgAppendPathData(vgpath, segments.count(),
- segments.constData(), coords.constData());
-
- return vgpath;
-}
-
-VGPath QVGPaintEnginePrivate::painterPathToVGPath(const QPainterPath& path)
-{
- int count = path.elementCount();
-
- VGPath vgpath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- count + 1, // segmentCapacityHint
- count * 2, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
-
- if (count == 0)
- return vgpath;
-
- const QPainterPath::Element *elements = &(path.elementAt(0));
-
- // Sizes chosen so that drawRoundedRect() paths fit in these arrays.
- QVarLengthArray<VGfloat, 48> coords;
- QVarLengthArray<VGubyte, 20> segments;
-
- int curvePos = 0;
- QPointF temp;
-
- // Keep track of the start and end of each sub-path. QPainterPath
- // does not have an "implicit close" flag like QVectorPath does.
- // We therefore have to detect closed paths by looking for a LineTo
- // element that connects back to the initial MoveTo element.
- qreal startx = 0.0;
- qreal starty = 0.0;
- qreal endx = 0.0;
- qreal endy = 0.0;
- bool haveStart = false;
- bool haveEnd = false;
-
- if (simpleTransform) {
- // Convert the members of the element array.
- for (int i = 0; i < count; ++i) {
- switch (elements[i].type) {
-
- case QPainterPath::MoveToElement:
- {
- if (haveStart && haveEnd && startx == endx && starty == endy) {
- // Implicitly close the previous sub-path.
- segments.append(VG_CLOSE_PATH);
- }
- startx = elements[i].x;
- starty = elements[i].y;
- coords.append(startx);
- coords.append(starty);
- haveStart = true;
- haveEnd = false;
- segments.append(VG_MOVE_TO_ABS);
- }
- break;
-
- case QPainterPath::LineToElement:
- {
- endx = elements[i].x;
- endy = elements[i].y;
- coords.append(endx);
- coords.append(endy);
- haveEnd = true;
- segments.append(VG_LINE_TO_ABS);
- }
- break;
-
- case QPainterPath::CurveToElement:
- {
- coords.append(elements[i].x);
- coords.append(elements[i].y);
- haveEnd = false;
- curvePos = 2;
- }
- break;
-
- case QPainterPath::CurveToDataElement:
- {
- coords.append(elements[i].x);
- coords.append(elements[i].y);
- haveEnd = false;
- curvePos += 2;
- if (curvePos == 6) {
- curvePos = 0;
- segments.append(VG_CUBIC_TO_ABS);
- }
- }
- break;
-
- }
- }
- } else {
- // Convert the members of the element array after applying the
- // current transform to the path locally.
- for (int i = 0; i < count; ++i) {
- switch (elements[i].type) {
-
- case QPainterPath::MoveToElement:
- {
- if (haveStart && haveEnd && startx == endx && starty == endy) {
- // Implicitly close the previous sub-path.
- segments.append(VG_CLOSE_PATH);
- }
- temp = transform.map(QPointF(elements[i].x, elements[i].y));
- startx = temp.x();
- starty = temp.y();
- coords.append(startx);
- coords.append(starty);
- haveStart = true;
- haveEnd = false;
- segments.append(VG_MOVE_TO_ABS);
- }
- break;
-
- case QPainterPath::LineToElement:
- {
- temp = transform.map(QPointF(elements[i].x, elements[i].y));
- endx = temp.x();
- endy = temp.y();
- coords.append(endx);
- coords.append(endy);
- haveEnd = true;
- segments.append(VG_LINE_TO_ABS);
- }
- break;
-
- case QPainterPath::CurveToElement:
- {
- temp = transform.map(QPointF(elements[i].x, elements[i].y));
- coords.append(temp.x());
- coords.append(temp.y());
- haveEnd = false;
- curvePos = 2;
- }
- break;
-
- case QPainterPath::CurveToDataElement:
- {
- temp = transform.map(QPointF(elements[i].x, elements[i].y));
- coords.append(temp.x());
- coords.append(temp.y());
- haveEnd = false;
- curvePos += 2;
- if (curvePos == 6) {
- curvePos = 0;
- segments.append(VG_CUBIC_TO_ABS);
- }
- }
- break;
-
- }
- }
- }
-
- if (haveStart && haveEnd && startx == endx && starty == endy) {
- // Implicitly close the last sub-path.
- segments.append(VG_CLOSE_PATH);
- }
-
- vgAppendPathData(vgpath, segments.count(),
- segments.constData(), coords.constData());
-
- return vgpath;
-}
-
-VGPath QVGPaintEnginePrivate::roundedRectPath(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode)
-{
- static VGubyte roundedrect_types[] = {
- VG_MOVE_TO_ABS,
- VG_LINE_TO_ABS,
- VG_CUBIC_TO_ABS,
- VG_LINE_TO_ABS,
- VG_CUBIC_TO_ABS,
- VG_LINE_TO_ABS,
- VG_CUBIC_TO_ABS,
- VG_LINE_TO_ABS,
- VG_CUBIC_TO_ABS,
- VG_CLOSE_PATH
- };
-
- qreal x1 = rect.left();
- qreal x2 = rect.right();
- qreal y1 = rect.top();
- qreal y2 = rect.bottom();
-
- if (mode == Qt::RelativeSize) {
- xRadius = xRadius * rect.width() / 200.;
- yRadius = yRadius * rect.height() / 200.;
- }
-
- xRadius = qMin(xRadius, rect.width() / 2);
- yRadius = qMin(yRadius, rect.height() / 2);
-
- VGfloat pts[] = {
- x1 + xRadius, y1, // MoveTo
- x2 - xRadius, y1, // LineTo
- x2 - (1 - KAPPA) * xRadius, y1, // CurveTo
- x2, y1 + (1 - KAPPA) * yRadius,
- x2, y1 + yRadius,
- x2, y2 - yRadius, // LineTo
- x2, y2 - (1 - KAPPA) * yRadius, // CurveTo
- x2 - (1 - KAPPA) * xRadius, y2,
- x2 - xRadius, y2,
- x1 + xRadius, y2, // LineTo
- x1 + (1 - KAPPA) * xRadius, y2, // CurveTo
- x1, y2 - (1 - KAPPA) * yRadius,
- x1, y2 - yRadius,
- x1, y1 + yRadius, // LineTo
- x1, y1 + (1 - KAPPA) * yRadius, // CurveTo
- x1 + (1 - KAPPA) * xRadius, y1,
- x1 + xRadius, y1
- };
-
-#if !defined(QVG_NO_MODIFY_PATH)
- VGPath vgpath = roundRectPath;
- if (!vgpath) {
- vgpath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- 10, // segmentCapacityHint
- 17 * 2, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
- vgAppendPathData(vgpath, 10, roundedrect_types, pts);
- roundRectPath = vgpath;
- } else {
- vgModifyPathCoords(vgpath, 0, 9, pts);
- }
-#else
- VGPath vgpath = vgCreatePath(VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- 10, // segmentCapacityHint
- 17 * 2, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
- vgAppendPathData(vgpath, 10, roundedrect_types, pts);
-#endif
-
- return vgpath;
-}
-
-Q_GUI_EXPORT QImage qt_imageForBrush(int style, bool invert);
-
-static QImage colorizeBitmap(const QImage &image, const QColor &color)
-{
- QImage sourceImage = image.convertToFormat(QImage::Format_MonoLSB);
- QImage dest = QImage(sourceImage.size(), QImage::Format_ARGB32_Premultiplied);
-
- QRgb fg = PREMUL(color.rgba());
- QRgb bg = 0;
-
- int height = sourceImage.height();
- int width = sourceImage.width();
- for (int y=0; y<height; ++y) {
- const uchar *source = sourceImage.constScanLine(y);
- QRgb *target = reinterpret_cast<QRgb *>(dest.scanLine(y));
- for (int x=0; x < width; ++x)
- target[x] = (source[x>>3] >> (x&7)) & 1 ? fg : bg;
- }
- return dest;
-}
-
-static VGImage toVGImage
- (const QImage & image, Qt::ImageConversionFlags flags = Qt::AutoColor)
-{
- QImage img(image);
-
- VGImageFormat format;
- switch (img.format()) {
- case QImage::Format_Mono:
- img = image.convertToFormat(QImage::Format_MonoLSB, flags);
- img.invertPixels();
- format = VG_BW_1;
- break;
- case QImage::Format_MonoLSB:
- img.invertPixels();
- format = VG_BW_1;
- break;
- case QImage::Format_RGB32:
- format = VG_sXRGB_8888;
- break;
- case QImage::Format_ARGB32:
- format = VG_sARGB_8888;
- break;
- case QImage::Format_ARGB32_Premultiplied:
- format = VG_sARGB_8888_PRE;
- break;
- case QImage::Format_RGB16:
- format = VG_sRGB_565;
- break;
- default:
- // Convert everything else into ARGB32_Premultiplied.
- img = image.convertToFormat(QImage::Format_ARGB32_Premultiplied, flags);
- format = VG_sARGB_8888_PRE;
- break;
- }
-
- const uchar *pixels = img.constBits();
-
- VGImage vgImg = QVGImagePool::instance()->createPermanentImage
- (format, img.width(), img.height(), VG_IMAGE_QUALITY_FASTER);
- vgImageSubData
- (vgImg, pixels, img.bytesPerLine(), format, 0, 0,
- img.width(), img.height());
-
- return vgImg;
-}
-
-static VGImage toVGImageSubRect
- (const QImage & image, const QRect& sr,
- Qt::ImageConversionFlags flags = Qt::AutoColor)
-{
- QImage img(image);
-
- VGImageFormat format;
- int bpp = 4;
-
- switch (img.format()) {
- case QImage::Format_Mono:
- case QImage::Format_MonoLSB:
- return VG_INVALID_HANDLE;
- case QImage::Format_RGB32:
- format = VG_sXRGB_8888;
- break;
- case QImage::Format_ARGB32:
- format = VG_sARGB_8888;
- break;
- case QImage::Format_ARGB32_Premultiplied:
- format = VG_sARGB_8888_PRE;
- break;
- case QImage::Format_RGB16:
- format = VG_sRGB_565;
- bpp = 2;
- break;
- default:
- // Convert everything else into ARGB32_Premultiplied.
- img = image.convertToFormat(QImage::Format_ARGB32_Premultiplied, flags);
- format = VG_sARGB_8888_PRE;
- break;
- }
-
- const uchar *pixels = img.constBits() + bpp * sr.x() +
- img.bytesPerLine() * sr.y();
-
- VGImage vgImg = QVGImagePool::instance()->createPermanentImage
- (format, sr.width(), sr.height(), VG_IMAGE_QUALITY_FASTER);
- vgImageSubData
- (vgImg, pixels, img.bytesPerLine(), format, 0, 0,
- sr.width(), sr.height());
-
- return vgImg;
-}
-
-static VGImage toVGImageWithOpacity(const QImage & image, qreal opacity)
-{
- QImage img(image.size(), QImage::Format_ARGB32_Premultiplied);
- img.fill(0);
- QPainter painter;
- painter.begin(&img);
- painter.setOpacity(opacity);
- painter.drawImage(0, 0, image);
- painter.end();
-
- const uchar *pixels = img.constBits();
-
- VGImage vgImg = QVGImagePool::instance()->createPermanentImage
- (VG_sARGB_8888_PRE, img.width(), img.height(), VG_IMAGE_QUALITY_FASTER);
- vgImageSubData
- (vgImg, pixels, img.bytesPerLine(), VG_sARGB_8888_PRE, 0, 0,
- img.width(), img.height());
-
- return vgImg;
-}
-
-static VGImage toVGImageWithOpacitySubRect
- (const QImage & image, qreal opacity, const QRect& sr)
-{
- QImage img(sr.size(), QImage::Format_ARGB32_Premultiplied);
- img.fill(0);
- QPainter painter;
- painter.begin(&img);
- painter.setOpacity(opacity);
- painter.drawImage(QPoint(0, 0), image, sr);
- painter.end();
-
- const uchar *pixels = img.constBits();
-
- VGImage vgImg = QVGImagePool::instance()->createPermanentImage
- (VG_sARGB_8888_PRE, img.width(), img.height(), VG_IMAGE_QUALITY_FASTER);
- vgImageSubData
- (vgImg, pixels, img.bytesPerLine(), VG_sARGB_8888_PRE, 0, 0,
- img.width(), img.height());
-
- return vgImg;
-}
-
-VGPaintType QVGPaintEnginePrivate::setBrush
- (VGPaint paint, const QBrush& brush, VGMatrixMode mode,
- VGPaintType prevType)
-{
- VGfloat values[5];
- setBrushTransform(brush, mode);
-
- // Reset the paint pattern on the brush, which will discard
- // the previous VGImage if one was set.
- if (prevType == VG_PAINT_TYPE_PATTERN || prevType == (VGPaintType)0)
- vgPaintPattern(paint, VG_INVALID_HANDLE);
-
- switch (brush.style()) {
-
- case Qt::SolidPattern: {
- // The brush is a solid color.
- QColor color(brush.color());
- values[0] = color.redF();
- values[1] = color.greenF();
- values[2] = color.blueF();
- values[3] = color.alphaF() * opacity;
- if (prevType != VG_PAINT_TYPE_COLOR)
- vgSetParameteri(paint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
- vgSetParameterfv(paint, VG_PAINT_COLOR, 4, values);
- return VG_PAINT_TYPE_COLOR;
- }
-
- case Qt::LinearGradientPattern: {
- // The brush is a linear gradient.
- Q_ASSERT(brush.gradient()->type() == QGradient::LinearGradient);
- const QLinearGradient *grad =
- static_cast<const QLinearGradient*>(brush.gradient());
- values[0] = grad->start().x();
- values[1] = grad->start().y();
- values[2] = grad->finalStop().x();
- values[3] = grad->finalStop().y();
- if (prevType != VG_PAINT_TYPE_LINEAR_GRADIENT)
- vgSetParameteri(paint, VG_PAINT_TYPE, VG_PAINT_TYPE_LINEAR_GRADIENT);
- vgSetParameterfv(paint, VG_PAINT_LINEAR_GRADIENT, 4, values);
- setupColorRamp(grad, paint);
- return VG_PAINT_TYPE_LINEAR_GRADIENT;
- }
-
- case Qt::RadialGradientPattern: {
- // The brush is a radial gradient.
- Q_ASSERT(brush.gradient()->type() == QGradient::RadialGradient);
- const QRadialGradient *grad =
- static_cast<const QRadialGradient*>(brush.gradient());
- values[0] = grad->center().x();
- values[1] = grad->center().y();
- values[2] = grad->focalPoint().x();
- values[3] = grad->focalPoint().y();
- values[4] = grad->radius();
- if (prevType != VG_PAINT_TYPE_RADIAL_GRADIENT)
- vgSetParameteri(paint, VG_PAINT_TYPE, VG_PAINT_TYPE_RADIAL_GRADIENT);
- vgSetParameterfv(paint, VG_PAINT_RADIAL_GRADIENT, 5, values);
- setupColorRamp(grad, paint);
- return VG_PAINT_TYPE_RADIAL_GRADIENT;
- }
-
- case Qt::TexturePattern: {
- // The brush is a texture specified by a QPixmap/QImage.
- QPixmapData *pd = brush.texture().pixmapData();
- if (!pd)
- break; // null QPixmap
- VGImage vgImg;
- bool deref = false;
- if (pd->pixelType() == QPixmapData::BitmapType) {
- // Colorize bitmaps using the brush color and opacity.
- QColor color = brush.color();
- if (opacity != 1.0)
- color.setAlphaF(color.alphaF() * opacity);
- QImage image = colorizeBitmap(*(pd->buffer()), color);
- vgImg = toVGImage(image);
- deref = true;
- } else if (opacity == 1.0) {
- if (pd->classId() == QPixmapData::OpenVGClass) {
- QVGPixmapData *vgpd = static_cast<QVGPixmapData *>(pd);
- vgImg = vgpd->toVGImage();
-
- // We don't want the pool to reclaim this image
- // because we cannot predict when the paint object
- // will stop using it. Replacing the image with
- // new data will make the paint object invalid.
- vgpd->detachImageFromPool();
- } else {
- vgImg = toVGImage(*(pd->buffer()));
- deref = true;
- }
- } else if (pd->classId() == QPixmapData::OpenVGClass) {
- QVGPixmapData *vgpd = static_cast<QVGPixmapData *>(pd);
- vgImg = vgpd->toVGImage(opacity);
- vgpd->detachImageFromPool();
- } else {
- vgImg = toVGImageWithOpacity(*(pd->buffer()), opacity);
- deref = true;
- }
- if (vgImg == VG_INVALID_HANDLE)
- break;
- if (prevType != VG_PAINT_TYPE_PATTERN)
- vgSetParameteri(paint, VG_PAINT_TYPE, VG_PAINT_TYPE_PATTERN);
- vgSetParameteri(paint, VG_PAINT_PATTERN_TILING_MODE, VG_TILE_REPEAT);
- vgPaintPattern(paint, vgImg);
- if (deref)
- vgDestroyImage(vgImg); // Will be valid until pattern is destroyed.
- return VG_PAINT_TYPE_PATTERN;
- }
-
- case Qt::ConicalGradientPattern: {
- // Convert conical gradients into the first stop color.
- qWarning() << "QVGPaintEnginePrivate::setBrush: conical gradients are not supported by OpenVG";
- Q_ASSERT(brush.gradient()->type() == QGradient::ConicalGradient);
- const QConicalGradient *grad =
- static_cast<const QConicalGradient*>(brush.gradient());
- const QGradientStops stops = grad->stops();
- QColor color;
- if (stops.size() > 0)
- color = stops[0].second;
- values[0] = color.redF();
- values[1] = color.greenF();
- values[2] = color.blueF();
- values[3] = color.alphaF() * opacity;
- if (prevType != VG_PAINT_TYPE_COLOR)
- vgSetParameteri(paint, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
- vgSetParameterfv(paint, VG_PAINT_COLOR, 4, values);
- return VG_PAINT_TYPE_COLOR;
- }
-
- case Qt::Dense1Pattern:
- case Qt::Dense2Pattern:
- case Qt::Dense3Pattern:
- case Qt::Dense4Pattern:
- case Qt::Dense5Pattern:
- case Qt::Dense6Pattern:
- case Qt::Dense7Pattern:
- case Qt::HorPattern:
- case Qt::VerPattern:
- case Qt::CrossPattern:
- case Qt::BDiagPattern:
- case Qt::FDiagPattern:
- case Qt::DiagCrossPattern: {
- // The brush is a traditional dotted or cross-hatched pattern brush.
- QColor color = brush.color();
- if (opacity != 1.0)
- color.setAlphaF(color.alphaF() * opacity);
- QImage image = colorizeBitmap
- (qt_imageForBrush(brush.style(), true), color);
- VGImage vgImg = toVGImage(image);
- if (prevType != VG_PAINT_TYPE_PATTERN)
- vgSetParameteri(paint, VG_PAINT_TYPE, VG_PAINT_TYPE_PATTERN);
- vgSetParameteri(paint, VG_PAINT_PATTERN_TILING_MODE, VG_TILE_REPEAT);
- vgPaintPattern(paint, vgImg);
- vgDestroyImage(vgImg); // Will stay valid until pattern is destroyed.
- return VG_PAINT_TYPE_PATTERN;
- }
-
- default: break;
- }
- return (VGPaintType)0;
-}
-
-void QVGPaintEnginePrivate::setPenParams(const QPen& pen)
-{
- // Note: OpenVG does not support zero-width or cosmetic pens,
- // so we have to simulate cosmetic pens by reversing the scale.
- VGfloat width = pen.widthF();
- if (width <= 0.0f)
- width = 1.0f;
- if (pen.isCosmetic()) {
- if (penScale != 1.0 && penScale != 0.0)
- width /= penScale;
- }
- vgSetf(VG_STROKE_LINE_WIDTH, width);
-
- if (pen.capStyle() == Qt::FlatCap)
- vgSetf(VG_STROKE_CAP_STYLE, VG_CAP_BUTT);
- else if (pen.capStyle() == Qt::SquareCap)
- vgSetf(VG_STROKE_CAP_STYLE, VG_CAP_SQUARE);
- else
- vgSetf(VG_STROKE_CAP_STYLE, VG_CAP_ROUND);
-
- if (pen.joinStyle() == Qt::MiterJoin) {
- vgSetf(VG_STROKE_JOIN_STYLE, VG_JOIN_MITER);
- vgSetf(VG_STROKE_MITER_LIMIT, pen.miterLimit());
- } else if (pen.joinStyle() == Qt::BevelJoin) {
- vgSetf(VG_STROKE_JOIN_STYLE, VG_JOIN_BEVEL);
- } else {
- vgSetf(VG_STROKE_JOIN_STYLE, VG_JOIN_ROUND);
- }
-
- if (pen.style() == Qt::SolidLine) {
- vgSetfv(VG_STROKE_DASH_PATTERN, 0, NULL);
- } else {
- const QVector<qreal> dashPattern = pen.dashPattern();
- QVector<VGfloat> currentDashPattern(dashPattern.count());
- for (int i = 0; i < dashPattern.count(); ++i)
- currentDashPattern[i] = dashPattern[i] * width;
- vgSetfv(VG_STROKE_DASH_PATTERN, currentDashPattern.count(), currentDashPattern.data());
- vgSetf(VG_STROKE_DASH_PHASE, pen.dashOffset());
- vgSetf(VG_STROKE_DASH_PHASE_RESET, VG_FALSE);
- }
-}
-
-void QVGPaintEnginePrivate::setBrushTransform
- (const QBrush& brush, VGMatrixMode mode)
-{
- // Compute the new brush transformation matrix.
- QTransform transform(brush.transform());
- if (brushOrigin.x() != 0.0f || brushOrigin.y() != 0.0f)
- transform.translate(brushOrigin.x(), brushOrigin.y());
-
- // Bail out if the matrix is the same as last time, to avoid
- // updating the VG context state unless absolutely necessary.
- // Most applications won't have a brush transformation set,
- // which will leave the VG setting at its default of identity.
- // Always change the transform if coming out of raw VG mode.
- if (mode == VG_MATRIX_FILL_PAINT_TO_USER) {
- if (!rawVG && transform == brushTransform)
- return;
- brushTransform = transform;
- } else {
- if (!rawVG && transform == penTransform)
- return;
- penTransform = transform;
- }
-
- // Set the brush transformation matrix.
- if (mode != matrixMode) {
- vgSeti(VG_MATRIX_MODE, mode);
- matrixMode = mode;
- }
- if (transform.isIdentity()) {
- vgLoadIdentity();
- } else {
- VGfloat mat[9];
- mat[0] = transform.m11();
- mat[1] = transform.m12();
- mat[2] = transform.m13();
- mat[3] = transform.m21();
- mat[4] = transform.m22();
- mat[5] = transform.m23();
- mat[6] = transform.m31();
- mat[7] = transform.m32();
- mat[8] = transform.m33();
- vgLoadMatrix(mat);
- }
-}
-
-void QVGPaintEnginePrivate::setupColorRamp(const QGradient *grad, VGPaint paint)
-{
- QGradient::Spread spread = grad->spread();
- VGColorRampSpreadMode spreadMode;
- if (spread == QGradient::ReflectSpread)
- spreadMode = VG_COLOR_RAMP_SPREAD_REFLECT;
- else if (spread == QGradient::RepeatSpread)
- spreadMode = VG_COLOR_RAMP_SPREAD_REPEAT;
- else
- spreadMode = VG_COLOR_RAMP_SPREAD_PAD;
-
- const QGradientStops stops = grad->stops();
- int n = 5*stops.size();
- QVector<VGfloat> fill_stops(n);
-
- for (int i = 0; i < stops.size(); ++i ) {
- QColor col = stops[i].second;
- fill_stops[i*5] = stops[i].first;
- fill_stops[i*5 + 1] = col.redF();
- fill_stops[i*5 + 2] = col.greenF();
- fill_stops[i*5 + 3] = col.blueF();
- fill_stops[i*5 + 4] = col.alphaF() * opacity;
- }
-
- vgSetParameteri(paint, VG_PAINT_COLOR_RAMP_SPREAD_MODE, spreadMode);
- vgSetParameteri(paint, VG_PAINT_COLOR_RAMP_PREMULTIPLIED, VG_FALSE);
- vgSetParameterfv(paint, VG_PAINT_COLOR_RAMP_STOPS, n, fill_stops.data());
-}
-
-QVGPainterState::QVGPainterState(QVGPainterState& other)
- : QPainterState(other),
- isNew(true), clipRegion(other.clipRegion),
- savedDirty(0)
-{
-}
-
-QVGPainterState::QVGPainterState()
- : isNew(true), savedDirty(0)
-{
-}
-
-QVGPainterState::~QVGPainterState()
-{
-}
-
-QVGPaintEngine::QVGPaintEngine()
- : QPaintEngineEx(*new QVGPaintEnginePrivate(this))
-{
-}
-
-QVGPaintEngine::QVGPaintEngine(QVGPaintEnginePrivate &data)
- : QPaintEngineEx(data)
-{
-}
-
-QVGPaintEngine::~QVGPaintEngine()
-{
-}
-
-QPainterState *QVGPaintEngine::createState(QPainterState *orig) const
-{
- if (!orig) {
- return new QVGPainterState();
- } else {
- Q_D(const QVGPaintEngine);
- QVGPaintEnginePrivate *d2 = const_cast<QVGPaintEnginePrivate*>(d);
- QVGPainterState *origState = static_cast<QVGPainterState *>(orig);
- origState->savedDirty = d2->dirty;
- d2->dirty = 0;
- return new QVGPainterState(*origState);
- }
-}
-
-void QVGPaintEnginePrivate::draw
- (VGPath path, const QPen& pen, const QBrush& brush, VGint rule)
-{
- VGbitfield mode = 0;
- if (qpen_style(pen) != Qt::NoPen && qbrush_style(qpen_brush(pen)) != Qt::NoBrush) {
- ensurePen(pen);
- mode |= VG_STROKE_PATH;
- }
- if (brush.style() != Qt::NoBrush) {
- ensureBrush(brush);
- setFillRule(rule);
- mode |= VG_FILL_PATH;
- }
- if (mode != 0) {
- ensurePathTransform();
- vgDrawPath(path, mode);
- }
-}
-
-void QVGPaintEnginePrivate::stroke(VGPath path, const QPen& pen)
-{
- if (pen.style() == Qt::NoPen)
- return;
- ensurePen(pen);
- ensurePathTransform();
- vgDrawPath(path, VG_STROKE_PATH);
-}
-
-void QVGPaintEnginePrivate::fill(VGPath path, const QBrush& brush, VGint rule)
-{
- if (brush.style() == Qt::NoBrush)
- return;
- ensureBrush(brush);
- setFillRule(rule);
- QPen savedPen = currentPen;
- currentPen = Qt::NoPen;
- ensurePathTransform();
- currentPen = savedPen;
- vgDrawPath(path, VG_FILL_PATH);
-}
-
-bool QVGPaintEngine::begin(QPaintDevice *pdev)
-{
- Q_UNUSED(pdev);
- Q_D(QVGPaintEngine);
-
- // Initialize the VG painting objects if we haven't done it yet.
- if (!d->penPaint)
- d->initObjects();
-
- // The initial clip region is the entire device area.
- QVGPainterState *s = state();
- s->clipRegion = defaultClipRegion();
-
- // Initialize the VG state for this paint operation.
- restoreState(QPaintEngine::AllDirty);
- d->dirty = 0;
- d->rawVG = false;
- return true;
-}
-
-bool QVGPaintEngine::end()
-{
- vgSeti(VG_SCISSORING, VG_FALSE);
- vgSeti(VG_MASKING, VG_FALSE);
- return true;
-}
-
-void QVGPaintEngine::draw(const QVectorPath &path)
-{
- Q_D(QVGPaintEngine);
- if (d->needsEmulation()) {
- QPaintEngineEx::draw(path);
- return;
- }
- QVGPainterState *s = state();
- VGPath vgpath = d->vectorPathToVGPath(path);
- if (!path.hasWindingFill())
- d->draw(vgpath, s->pen, s->brush, VG_EVEN_ODD);
- else
- d->draw(vgpath, s->pen, s->brush, VG_NON_ZERO);
- vgDestroyPath(vgpath);
-}
-
-extern QPainterPath qt_painterPathFromVectorPath(const QVectorPath &path);
-
-void QVGPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
-{
- Q_D(QVGPaintEngine);
- if (d->needsEmulation(brush)) {
- QPainter *p = painter();
- QBrush oldBrush = p->brush();
- p->setBrush(brush);
- qt_draw_helper(p->d_ptr.data(), qt_painterPathFromVectorPath(path), QPainterPrivate::FillDraw);
- p->setBrush(oldBrush);
- return;
- }
- VGPath vgpath = d->vectorPathToVGPath(path);
- if (!path.hasWindingFill())
- d->fill(vgpath, brush, VG_EVEN_ODD);
- else
- d->fill(vgpath, brush, VG_NON_ZERO);
- vgDestroyPath(vgpath);
-}
-
-void QVGPaintEngine::stroke(const QVectorPath &path, const QPen &pen)
-{
- Q_D(QVGPaintEngine);
- if (d->needsEmulation(pen.brush())) {
- QPaintEngineEx::stroke(path, pen);
- return;
- }
- VGPath vgpath = d->vectorPathToVGPath(path);
- d->stroke(vgpath, pen);
- vgDestroyPath(vgpath);
-}
-
-// Determine if a co-ordinate transform is simple enough to allow
-// rectangle-based clipping with vgMask(). Simple transforms most
-// often result from origin translations.
-static inline bool clipTransformIsSimple(const QTransform& transform)
-{
- QTransform::TransformationType type = transform.type();
- if (type == QTransform::TxNone || type == QTransform::TxTranslate)
- return true;
- if (type == QTransform::TxRotate) {
- // Check for 0, 90, 180, and 270 degree rotations.
- // (0 might happen after 4 rotations of 90 degrees).
- qreal m11 = transform.m11();
- qreal m12 = transform.m12();
- qreal m21 = transform.m21();
- qreal m22 = transform.m22();
- if (m11 == 0.0f && m22 == 0.0f) {
- if (m12 == 1.0f && m21 == -1.0f)
- return true; // 90 degrees.
- else if (m12 == -1.0f && m21 == 1.0f)
- return true; // 270 degrees.
- } else if (m12 == 0.0f && m21 == 0.0f) {
- if (m11 == -1.0f && m22 == -1.0f)
- return true; // 180 degrees.
- else if (m11 == 1.0f && m22 == 1.0f)
- return true; // 0 degrees.
- }
- }
- return false;
-}
-
-#if defined(QVG_SCISSOR_CLIP)
-
-void QVGPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op)
-{
- Q_D(QVGPaintEngine);
- QVGPainterState *s = state();
-
- d->dirty |= QPaintEngine::DirtyClipRegion;
-
- if (op == Qt::NoClip) {
- s->clipRegion = defaultClipRegion();
- updateScissor();
- return;
- }
-
- // We aren't using masking, so handle simple QRectF's only.
- if (path.shape() == QVectorPath::RectangleHint &&
- path.elementCount() == 4 && clipTransformIsSimple(d->transform)) {
- // Clipping region that resulted from QPainter::setClipRect(QRectF).
- // Convert it into a QRect and apply.
- const qreal *points = path.points();
- QRectF rect(points[0], points[1], points[2] - points[0],
- points[5] - points[1]);
- clip(rect.toRect(), op);
- return;
- }
-
- // Try converting the path into a QRegion that tightly follows
- // the outline of the path we want to clip with.
- QRegion region;
- if (!path.isEmpty())
- region = QRegion(path.convertToPainterPath().toFillPolygon(QTransform()).toPolygon());
-
- switch (op) {
- case Qt::NoClip:
- {
- region = defaultClipRegion();
- }
- break;
-
- case Qt::ReplaceClip:
- {
- region = d->transform.map(region);
- }
- break;
-
- case Qt::IntersectClip:
- {
- region = s->clipRegion.intersect(d->transform.map(region));
- }
- break;
-
- case Qt::UniteClip:
- {
- region = s->clipRegion.unite(d->transform.map(region));
- }
- break;
- }
- if (region.numRects() <= d->maxScissorRects) {
- // We haven't reached the maximum scissor count yet, so we can
- // still make use of this region.
- s->clipRegion = region;
- updateScissor();
- return;
- }
-
- // The best we can do is clip to the bounding rectangle
- // of all control points.
- clip(path.controlPointRect().toRect(), op);
-}
-
-void QVGPaintEngine::clip(const QRect &rect, Qt::ClipOperation op)
-{
- Q_D(QVGPaintEngine);
- QVGPainterState *s = state();
-
- d->dirty |= QPaintEngine::DirtyClipRegion;
-
- switch (op) {
- case Qt::NoClip:
- {
- s->clipRegion = defaultClipRegion();
- }
- break;
-
- case Qt::ReplaceClip:
- {
- s->clipRegion = d->transform.map(QRegion(rect));
- }
- break;
-
- case Qt::IntersectClip:
- {
- s->clipRegion = s->clipRegion.intersect(d->transform.map(QRegion(rect)));
- }
- break;
-
- case Qt::UniteClip:
- {
- s->clipRegion = s->clipRegion.unite(d->transform.map(QRegion(rect)));
- }
- break;
- }
-
- updateScissor();
-}
-
-void QVGPaintEngine::clip(const QRegion &region, Qt::ClipOperation op)
-{
- Q_D(QVGPaintEngine);
- QVGPainterState *s = state();
-
- d->dirty |= QPaintEngine::DirtyClipRegion;
-
- switch (op) {
- case Qt::NoClip:
- {
- s->clipRegion = defaultClipRegion();
- }
- break;
-
- case Qt::ReplaceClip:
- {
- s->clipRegion = d->transform.map(region);
- }
- break;
-
- case Qt::IntersectClip:
- {
- s->clipRegion = s->clipRegion.intersect(d->transform.map(region));
- }
- break;
-
- case Qt::UniteClip:
- {
- s->clipRegion = s->clipRegion.unite(d->transform.map(region));
- }
- break;
- }
-
- updateScissor();
-}
-
-void QVGPaintEngine::clip(const QPainterPath &path, Qt::ClipOperation op)
-{
- QPaintEngineEx::clip(path, op);
-}
-
-#else // !QVG_SCISSOR_CLIP
-
-void QVGPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op)
-{
- Q_D(QVGPaintEngine);
-
- d->dirty |= QPaintEngine::DirtyClipRegion;
-
- if (op == Qt::NoClip) {
- d->maskValid = false;
- d->maskIsSet = true;
- d->scissorMask = false;
- d->maskRect = QRect();
- vgSeti(VG_MASKING, VG_FALSE);
- return;
- }
-
- // We don't have vgRenderToMask(), so handle simple QRectF's only.
- if (path.shape() == QVectorPath::RectangleHint &&
- path.elementCount() == 4 && clipTransformIsSimple(d->transform)) {
- // Clipping region that resulted from QPainter::setClipRect(QRectF).
- // Convert it into a QRect and apply.
- const qreal *points = path.points();
- QRectF rect(points[0], points[1], points[2] - points[0],
- points[5] - points[1]);
- clip(rect.toRect(), op);
- return;
- }
-
-#if !defined(QVG_NO_RENDER_TO_MASK)
- QPaintDevice *pdev = paintDevice();
- int width = pdev->width();
- int height = pdev->height();
-
- if (op == Qt::ReplaceClip) {
- vgMask(VG_INVALID_HANDLE, VG_CLEAR_MASK, 0, 0, width, height);
- d->maskRect = QRect();
- } else if (!d->maskValid) {
- d->ensureMask(this, width, height);
- }
-
- d->ensurePathTransform();
- VGPath vgpath = d->vectorPathToVGPath(path);
- switch (op) {
- case Qt::ReplaceClip:
- case Qt::UniteClip:
- vgRenderToMask(vgpath, VG_FILL_PATH, VG_UNION_MASK);
- break;
-
- case Qt::IntersectClip:
- vgRenderToMask(vgpath, VG_FILL_PATH, VG_INTERSECT_MASK);
- break;
-
- default: break;
- }
- vgDestroyPath(vgpath);
-
- vgSeti(VG_MASKING, VG_TRUE);
- d->maskValid = true;
- d->maskIsSet = false;
- d->scissorMask = false;
-#endif
-}
-
-void QVGPaintEngine::clip(const QRect &rect, Qt::ClipOperation op)
-{
- Q_D(QVGPaintEngine);
-
- d->dirty |= QPaintEngine::DirtyClipRegion;
-
- // If we have a non-simple transform, then use path-based clipping.
- if (op != Qt::NoClip && !clipTransformIsSimple(d->transform)) {
- QPaintEngineEx::clip(rect, op);
- return;
- }
-
- switch (op) {
- case Qt::NoClip:
- {
- d->maskValid = false;
- d->maskIsSet = true;
- d->scissorMask = false;
- d->maskRect = QRect();
- vgSeti(VG_MASKING, VG_FALSE);
- }
- break;
-
- case Qt::ReplaceClip:
- {
- QRect r = d->transform.mapRect(rect);
- if (isDefaultClipRect(r)) {
- // Replacing the clip with a full-window region is the
- // same as turning off clipping.
- if (d->maskValid)
- vgSeti(VG_MASKING, VG_FALSE);
- d->maskValid = false;
- d->maskIsSet = true;
- d->scissorMask = false;
- d->maskRect = QRect();
- } else {
- // Special case: if the intersection of the system
- // clip and "r" is a single rectangle, then use the
- // scissor for clipping. We try to avoid allocating a
- // QRegion copy on the heap for the test if we can.
- QRegion clip = d->systemClip; // Reference-counted, no alloc.
- QRect clipRect;
- if (clip.rectCount() == 1) {
- clipRect = clip.boundingRect().intersected(r);
- } else if (clip.isEmpty()) {
- clipRect = r;
- } else {
- clip = clip.intersect(r);
- if (clip.rectCount() != 1) {
- d->maskValid = false;
- d->maskIsSet = false;
- d->scissorMask = false;
- d->maskRect = QRect();
- d->modifyMask(this, VG_FILL_MASK, r);
- break;
- }
- clipRect = clip.boundingRect();
- }
- d->maskValid = false;
- d->maskIsSet = false;
- d->scissorMask = true;
- d->maskRect = clipRect;
- vgSeti(VG_MASKING, VG_FALSE);
- updateScissor();
- }
- }
- break;
-
- case Qt::IntersectClip:
- {
- QRect r = d->transform.mapRect(rect);
- if (!d->maskValid) {
- // Mask has not been used yet, so intersect with
- // the previous scissor-based region in maskRect.
- if (d->scissorMask)
- r = r.intersect(d->maskRect);
- if (isDefaultClipRect(r)) {
- // The clip is the full window, so turn off clipping.
- d->maskIsSet = true;
- d->maskRect = QRect();
- } else {
- // Activate the scissor on a smaller maskRect.
- d->maskIsSet = false;
- d->maskRect = r;
- }
- d->scissorMask = true;
- updateScissor();
- } else if (d->maskIsSet && isDefaultClipRect(r)) {
- // Intersecting a full-window clip with a full-window
- // region is the same as turning off clipping.
- if (d->maskValid)
- vgSeti(VG_MASKING, VG_FALSE);
- d->maskValid = false;
- d->maskIsSet = true;
- d->scissorMask = false;
- d->maskRect = QRect();
- } else {
- d->modifyMask(this, VG_INTERSECT_MASK, r);
- }
- }
- break;
-
- case Qt::UniteClip:
- {
- // If we already have a full-window clip, then uniting a
- // region with it will do nothing. Otherwise union.
- if (!(d->maskIsSet))
- d->modifyMask(this, VG_UNION_MASK, d->transform.mapRect(rect));
- }
- break;
- }
-}
-
-void QVGPaintEngine::clip(const QRegion &region, Qt::ClipOperation op)
-{
- Q_D(QVGPaintEngine);
-
- // Use the QRect case if the region consists of a single rectangle.
- if (region.rectCount() == 1) {
- clip(region.boundingRect(), op);
- return;
- }
-
- d->dirty |= QPaintEngine::DirtyClipRegion;
-
- // If we have a non-simple transform, then use path-based clipping.
- if (op != Qt::NoClip && !clipTransformIsSimple(d->transform)) {
- QPaintEngineEx::clip(region, op);
- return;
- }
-
- switch (op) {
- case Qt::NoClip:
- {
- d->maskValid = false;
- d->maskIsSet = true;
- d->scissorMask = false;
- d->maskRect = QRect();
- vgSeti(VG_MASKING, VG_FALSE);
- }
- break;
-
- case Qt::ReplaceClip:
- {
- QRegion r = d->transform.map(region);
- if (isDefaultClipRegion(r)) {
- // Replacing the clip with a full-window region is the
- // same as turning off clipping.
- if (d->maskValid)
- vgSeti(VG_MASKING, VG_FALSE);
- d->maskValid = false;
- d->maskIsSet = true;
- d->scissorMask = false;
- d->maskRect = QRect();
- } else {
- // Special case: if the intersection of the system
- // clip and the region is a single rectangle, then
- // use the scissor for clipping.
- QRegion clip = d->systemClip;
- if (clip.isEmpty())
- clip = r;
- else
- clip = clip.intersect(r);
- if (clip.rectCount() == 1) {
- d->maskValid = false;
- d->maskIsSet = false;
- d->scissorMask = true;
- d->maskRect = clip.boundingRect();
- vgSeti(VG_MASKING, VG_FALSE);
- updateScissor();
- } else {
- d->maskValid = false;
- d->maskIsSet = false;
- d->scissorMask = false;
- d->maskRect = QRect();
- d->modifyMask(this, VG_FILL_MASK, r);
- }
- }
- }
- break;
-
- case Qt::IntersectClip:
- {
- if (region.rectCount() != 1) {
- // If there is more than one rectangle, then intersecting
- // the rectangles one by one in modifyMask() will not give
- // the desired result. So fall back to path-based clipping.
- QPaintEngineEx::clip(region, op);
- return;
- }
- QRegion r = d->transform.map(region);
- if (d->maskIsSet && isDefaultClipRegion(r)) {
- // Intersecting a full-window clip with a full-window
- // region is the same as turning off clipping.
- if (d->maskValid)
- vgSeti(VG_MASKING, VG_FALSE);
- d->maskValid = false;
- d->maskIsSet = true;
- d->scissorMask = false;
- d->maskRect = QRect();
- } else {
- d->modifyMask(this, VG_INTERSECT_MASK, r);
- }
- }
- break;
-
- case Qt::UniteClip:
- {
- // If we already have a full-window clip, then uniting a
- // region with it will do nothing. Otherwise union.
- if (!(d->maskIsSet))
- d->modifyMask(this, VG_UNION_MASK, d->transform.map(region));
- }
- break;
- }
-}
-
-#if !defined(QVG_NO_RENDER_TO_MASK)
-
-// Copied from qpathclipper.cpp.
-static bool qt_vg_pathToRect(const QPainterPath &path, QRectF *rect)
-{
- if (path.elementCount() != 5)
- return false;
-
- const bool mightBeRect = path.elementAt(0).isMoveTo()
- && path.elementAt(1).isLineTo()
- && path.elementAt(2).isLineTo()
- && path.elementAt(3).isLineTo()
- && path.elementAt(4).isLineTo();
-
- if (!mightBeRect)
- return false;
-
- const qreal x1 = path.elementAt(0).x;
- const qreal y1 = path.elementAt(0).y;
-
- const qreal x2 = path.elementAt(1).x;
- const qreal y2 = path.elementAt(2).y;
-
- if (path.elementAt(1).y != y1)
- return false;
-
- if (path.elementAt(2).x != x2)
- return false;
-
- if (path.elementAt(3).x != x1 || path.elementAt(3).y != y2)
- return false;
-
- if (path.elementAt(4).x != x1 || path.elementAt(4).y != y1)
- return false;
-
- if (rect)
- *rect = QRectF(QPointF(x1, y1), QPointF(x2, y2));
-
- return true;
-}
-
-#endif
-
-void QVGPaintEngine::clip(const QPainterPath &path, Qt::ClipOperation op)
-{
-#if !defined(QVG_NO_RENDER_TO_MASK)
- Q_D(QVGPaintEngine);
-
- // If the path is a simple rectangle, then use clip(QRect) instead.
- QRectF simpleRect;
- if (qt_vg_pathToRect(path, &simpleRect)) {
- clip(simpleRect.toRect(), op);
- return;
- }
-
- d->dirty |= QPaintEngine::DirtyClipRegion;
-
- if (op == Qt::NoClip) {
- d->maskValid = false;
- d->maskIsSet = true;
- d->scissorMask = false;
- d->maskRect = QRect();
- vgSeti(VG_MASKING, VG_FALSE);
- return;
- }
-
- QPaintDevice *pdev = paintDevice();
- int width = pdev->width();
- int height = pdev->height();
-
- if (op == Qt::ReplaceClip) {
- vgMask(VG_INVALID_HANDLE, VG_CLEAR_MASK, 0, 0, width, height);
- d->maskRect = QRect();
- } else if (!d->maskValid) {
- d->ensureMask(this, width, height);
- }
-
- d->ensurePathTransform();
- VGPath vgpath = d->painterPathToVGPath(path);
- switch (op) {
- case Qt::ReplaceClip:
- case Qt::UniteClip:
- vgRenderToMask(vgpath, VG_FILL_PATH, VG_UNION_MASK);
- break;
-
- case Qt::IntersectClip:
- vgRenderToMask(vgpath, VG_FILL_PATH, VG_INTERSECT_MASK);
- break;
-
- default: break;
- }
- vgDestroyPath(vgpath);
-
- vgSeti(VG_MASKING, VG_TRUE);
- d->maskValid = true;
- d->maskIsSet = false;
- d->scissorMask = false;
-#else
- QPaintEngineEx::clip(path, op);
-#endif
-}
-
-void QVGPaintEnginePrivate::ensureMask
- (QVGPaintEngine *engine, int width, int height)
-{
- scissorMask = false;
- if (maskIsSet) {
- vgMask(VG_INVALID_HANDLE, VG_FILL_MASK, 0, 0, width, height);
- maskRect = QRect();
- } else {
- vgMask(VG_INVALID_HANDLE, VG_CLEAR_MASK, 0, 0, width, height);
- if (maskRect.isValid()) {
- vgMask(VG_INVALID_HANDLE, VG_FILL_MASK,
- maskRect.x(), height - maskRect.y() - maskRect.height(),
- maskRect.width(), maskRect.height());
- maskRect = QRect();
- engine->updateScissor();
- }
- }
-}
-
-void QVGPaintEnginePrivate::modifyMask
- (QVGPaintEngine *engine, VGMaskOperation op, const QRegion& region)
-{
- QPaintDevice *pdev = engine->paintDevice();
- int width = pdev->width();
- int height = pdev->height();
-
- if (!maskValid)
- ensureMask(engine, width, height);
-
- QVector<QRect> rects = region.rects();
- for (int i = 0; i < rects.size(); ++i) {
- vgMask(VG_INVALID_HANDLE, op,
- rects[i].x(), height - rects[i].y() - rects[i].height(),
- rects[i].width(), rects[i].height());
- }
-
- vgSeti(VG_MASKING, VG_TRUE);
- maskValid = true;
- maskIsSet = false;
- scissorMask = false;
-}
-
-void QVGPaintEnginePrivate::modifyMask
- (QVGPaintEngine *engine, VGMaskOperation op, const QRect& rect)
-{
- QPaintDevice *pdev = engine->paintDevice();
- int width = pdev->width();
- int height = pdev->height();
-
- if (!maskValid)
- ensureMask(engine, width, height);
-
- if (rect.isValid()) {
- vgMask(VG_INVALID_HANDLE, op,
- rect.x(), height - rect.y() - rect.height(),
- rect.width(), rect.height());
- }
-
- vgSeti(VG_MASKING, VG_TRUE);
- maskValid = true;
- maskIsSet = false;
- scissorMask = false;
-}
-
-#endif // !QVG_SCISSOR_CLIP
-
-void QVGPaintEngine::updateScissor()
-{
- Q_D(QVGPaintEngine);
-
- QRegion region = d->systemClip;
-
-#if defined(QVG_SCISSOR_CLIP)
- // Using the scissor to do clipping, so combine the systemClip
- // with the current painting clipRegion.
-
- if (d->maskValid) {
- vgSeti(VG_MASKING, VG_FALSE);
- d->maskValid = false;
- }
-
- QVGPainterState *s = state();
- if (s->clipEnabled) {
- if (region.isEmpty())
- region = s->clipRegion;
- else
- region = region.intersect(s->clipRegion);
- if (isDefaultClipRegion(region)) {
- // The scissor region is the entire drawing surface,
- // so there is no point doing any scissoring.
- vgSeti(VG_SCISSORING, VG_FALSE);
- d->scissorActive = false;
- d->scissorDirty = false;
- return;
- }
- } else
-#endif
- {
-#if !defined(QVG_SCISSOR_CLIP)
- // Combine the system clip with the simple mask rectangle.
- if (d->scissorMask) {
- if (region.isEmpty())
- region = d->maskRect;
- else
- region = region.intersect(d->maskRect);
- if (isDefaultClipRegion(region)) {
- // The scissor region is the entire drawing surface,
- // so there is no point doing any scissoring.
- vgSeti(VG_SCISSORING, VG_FALSE);
- d->scissorActive = false;
- d->scissorDirty = false;
- return;
- }
- } else
-#endif
-
- // Disable the scissor completely if the system clip is empty.
- if (region.isEmpty()) {
- vgSeti(VG_SCISSORING, VG_FALSE);
- d->scissorActive = false;
- d->scissorDirty = false;
- return;
- }
- }
-
- if (d->scissorActive && region == d->scissorRegion && !d->scissorDirty)
- return;
-
- QVector<QRect> rects = region.rects();
- int count = rects.count();
- if (count > d->maxScissorRects) {
-#if !defined(QVG_SCISSOR_CLIP)
- count = d->maxScissorRects;
-#else
- // Use masking
- int width = paintDevice()->width();
- int height = paintDevice()->height();
- vgMask(VG_INVALID_HANDLE, VG_CLEAR_MASK,
- 0, 0, width, height);
- for (int i = 0; i < rects.size(); ++i) {
- vgMask(VG_INVALID_HANDLE, VG_FILL_MASK,
- rects[i].x(), height - rects[i].y() - rects[i].height(),
- rects[i].width(), rects[i].height());
- }
-
- vgSeti(VG_SCISSORING, VG_FALSE);
- vgSeti(VG_MASKING, VG_TRUE);
- d->maskValid = true;
- d->maskIsSet = false;
- d->scissorMask = false;
- d->scissorActive = false;
- d->scissorDirty = false;
- d->scissorRegion = region;
- return;
-#endif
- }
-
- QVarLengthArray<VGint> params(count * 4);
- int height = paintDevice()->height();
- for (int i = 0; i < count; ++i) {
- params[i * 4 + 0] = rects[i].x();
- params[i * 4 + 1] = height - rects[i].y() - rects[i].height();
- params[i * 4 + 2] = rects[i].width();
- params[i * 4 + 3] = rects[i].height();
- }
-
- vgSetiv(VG_SCISSOR_RECTS, count * 4, params.data());
- vgSeti(VG_SCISSORING, VG_TRUE);
- d->scissorDirty = false;
- d->scissorActive = true;
- d->scissorRegion = region;
-}
-
-QRegion QVGPaintEngine::defaultClipRegion()
-{
- // The default clip region for a paint device is the whole drawing area.
- QPaintDevice *pdev = paintDevice();
- return QRegion(0, 0, pdev->width(), pdev->height());
-}
-
-bool QVGPaintEngine::isDefaultClipRegion(const QRegion& region)
-{
- if (region.rectCount() != 1)
- return false;
-
- QPaintDevice *pdev = paintDevice();
- int width = pdev->width();
- int height = pdev->height();
-
- QRect rect = region.boundingRect();
- return (rect.x() == 0 && rect.y() == 0 &&
- rect.width() == width && rect.height() == height);
-}
-
-bool QVGPaintEngine::isDefaultClipRect(const QRect& rect)
-{
- QPaintDevice *pdev = paintDevice();
- int width = pdev->width();
- int height = pdev->height();
-
- return (rect.x() == 0 && rect.y() == 0 &&
- rect.width() == width && rect.height() == height);
-}
-
-void QVGPaintEngine::clipEnabledChanged()
-{
-#if defined(QVG_SCISSOR_CLIP)
- vgSeti(VG_MASKING, VG_FALSE); // disable mask fallback
- updateScissor();
-#else
- Q_D(QVGPaintEngine);
- QVGPainterState *s = state();
- d->dirty |= QPaintEngine::DirtyClipEnabled;
- if (s->clipEnabled && s->clipOperation != Qt::NoClip) {
- // Replay the entire clip stack to put the mask into the right state.
- d->maskValid = false;
- d->maskIsSet = true;
- d->scissorMask = false;
- d->maskRect = QRect();
- s->clipRegion = defaultClipRegion();
- d->replayClipOperations();
- d->transform = s->transform();
- d->updateTransform(paintDevice());
- } else {
- vgSeti(VG_MASKING, VG_FALSE);
- d->maskValid = false;
- d->maskIsSet = false;
- d->scissorMask = false;
- d->maskRect = QRect();
- }
-#endif
-}
-
-void QVGPaintEngine::penChanged()
-{
- Q_D(QVGPaintEngine);
- d->dirty |= QPaintEngine::DirtyPen;
-
- d->hasExtendedRadialGradientPen =
- state()->pen.style() != Qt::NoPen && d->needsEmulation(state()->pen.brush());
-}
-
-void QVGPaintEngine::brushChanged()
-{
- Q_D(QVGPaintEngine);
- d->dirty |= QPaintEngine::DirtyBrush;
-
- d->hasExtendedRadialGradientPen = d->needsEmulation(state()->brush);
-}
-
-void QVGPaintEngine::brushOriginChanged()
-{
- Q_D(QVGPaintEngine);
- d->dirty |= QPaintEngine::DirtyBrushOrigin;
- d->brushOrigin = state()->brushOrigin;
- d->forcePenChange = true;
- d->forceBrushChange = true;
-}
-
-void QVGPaintEngine::opacityChanged()
-{
- Q_D(QVGPaintEngine);
- d->dirty |= QPaintEngine::DirtyOpacity;
- d->opacity = state()->opacity;
- d->forcePenChange = true;
- d->forceBrushChange = true;
-}
-
-void QVGPaintEngine::compositionModeChanged()
-{
- Q_D(QVGPaintEngine);
- d->dirty |= QPaintEngine::DirtyCompositionMode;
-
- VGint vgMode = VG_BLEND_SRC_OVER;
-
- switch (state()->composition_mode) {
- case QPainter::CompositionMode_SourceOver:
- vgMode = VG_BLEND_SRC_OVER;
- break;
- case QPainter::CompositionMode_DestinationOver:
- vgMode = VG_BLEND_DST_OVER;
- break;
- case QPainter::CompositionMode_Source:
- vgMode = VG_BLEND_SRC;
- break;
- case QPainter::CompositionMode_SourceIn:
- vgMode = VG_BLEND_SRC_IN;
- break;
- case QPainter::CompositionMode_DestinationIn:
- vgMode = VG_BLEND_DST_IN;
- break;
- case QPainter::CompositionMode_Plus:
- vgMode = VG_BLEND_ADDITIVE;
- break;
- case QPainter::CompositionMode_Multiply:
- vgMode = VG_BLEND_MULTIPLY;
- break;
- case QPainter::CompositionMode_Screen:
- vgMode = VG_BLEND_SCREEN;
- break;
- case QPainter::CompositionMode_Darken:
- vgMode = VG_BLEND_DARKEN;
- break;
- case QPainter::CompositionMode_Lighten:
- vgMode = VG_BLEND_LIGHTEN;
- break;
- default:
- if (d->hasAdvancedBlending) {
- switch (state()->composition_mode) {
- case QPainter::CompositionMode_Overlay:
- vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_OVERLAY_KHR;
- break;
- case QPainter::CompositionMode_ColorDodge:
- vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_COLORDODGE_KHR;
- break;
- case QPainter::CompositionMode_ColorBurn:
- vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_COLORBURN_KHR;
- break;
- case QPainter::CompositionMode_HardLight:
- vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_HARDLIGHT_KHR;
- break;
- case QPainter::CompositionMode_SoftLight:
- vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_SOFTLIGHT_KHR;
- break;
- case QPainter::CompositionMode_Difference:
- vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_DIFFERENCE_KHR;
- break;
- case QPainter::CompositionMode_Exclusion:
- vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_EXCLUSION_KHR;
- break;
- case QPainter::CompositionMode_SourceOut:
- vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_SRC_OUT_KHR;
- break;
- case QPainter::CompositionMode_DestinationOut:
- vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_DST_OUT_KHR;
- break;
- case QPainter::CompositionMode_SourceAtop:
- vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_SRC_ATOP_KHR;
- break;
- case QPainter::CompositionMode_DestinationAtop:
- vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_DST_ATOP_KHR;
- break;
- case QPainter::CompositionMode_Xor:
- vgMode = QVGPaintEnginePrivate::QT_VG_BLEND_XOR_KHR;
- break;
- default: break; // Fall back to VG_BLEND_SRC_OVER.
- }
- }
- if (vgMode == VG_BLEND_SRC_OVER)
- qWarning() << "QVGPaintEngine::compositionModeChanged unsupported mode" << state()->composition_mode;
- break;
- }
-
- d->setBlendMode(VGBlendMode(vgMode));
-}
-
-void QVGPaintEngine::renderHintsChanged()
-{
- Q_D(QVGPaintEngine);
- d->dirty |= QPaintEngine::DirtyHints;
-
- QPainter::RenderHints hints = state()->renderHints;
-
- VGRenderingQuality rq =
- (hints & QPainter::Antialiasing)
- ? VG_RENDERING_QUALITY_BETTER
- : VG_RENDERING_QUALITY_NONANTIALIASED;
- VGImageQuality iq =
- (hints & QPainter::SmoothPixmapTransform)
- ? VG_IMAGE_QUALITY_BETTER
- : VG_IMAGE_QUALITY_NONANTIALIASED;
-
- d->setRenderingQuality(rq);
- d->setImageQuality(iq);
-}
-
-void QVGPaintEngine::transformChanged()
-{
- Q_D(QVGPaintEngine);
- QVGPainterState *s = state();
- d->dirty |= QPaintEngine::DirtyTransform;
- d->transform = s->transform();
- qreal oldPenScale = d->penScale;
- d->updateTransform(paintDevice());
- if (d->penScale != oldPenScale)
- d->forcePenChange = true;
-}
-
-bool QVGPaintEngine::clearRect(const QRectF &rect, const QColor &color)
-{
- Q_D(QVGPaintEngine);
- QVGPainterState *s = state();
- if (!s->clipEnabled || s->clipOperation == Qt::NoClip) {
- QRect r = d->transform.mapRect(rect).toRect();
- int height = paintDevice()->height();
- if (d->clearColor != color || d->clearOpacity != s->opacity) {
- VGfloat values[4];
- values[0] = color.redF();
- values[1] = color.greenF();
- values[2] = color.blueF();
- values[3] = color.alphaF() * s->opacity;
- vgSetfv(VG_CLEAR_COLOR, 4, values);
- d->clearColor = color;
- d->clearOpacity = s->opacity;
- }
- vgClear(r.x(), height - r.y() - r.height(),
- r.width(), r.height());
- return true;
- }
- return false;
-}
-
-void QVGPaintEngine::fillRect(const QRectF &rect, const QBrush &brush)
-{
- Q_D(QVGPaintEngine);
-
- if (brush.style() == Qt::NoBrush)
- return;
-
- // Check to see if we can use vgClear() for faster filling.
- if (brush.style() == Qt::SolidPattern && brush.isOpaque() &&
- clipTransformIsSimple(d->transform) && d->opacity == 1.0f &&
- clearRect(rect, brush.color())) {
- return;
- }
-
- if (d->needsEmulation(brush)) {
- QPaintEngineEx::fillRect(rect, brush);
- return;
- }
-
-#if !defined(QVG_NO_MODIFY_PATH)
- VGfloat coords[8];
- if (d->simpleTransform) {
- coords[0] = rect.x();
- coords[1] = rect.y();
- coords[2] = rect.x() + rect.width();
- coords[3] = coords[1];
- coords[4] = coords[2];
- coords[5] = rect.y() + rect.height();
- coords[6] = coords[0];
- coords[7] = coords[5];
- } else {
- QPointF tl = d->transform.map(rect.topLeft());
- QPointF tr = d->transform.map(rect.topRight());
- QPointF bl = d->transform.map(rect.bottomLeft());
- QPointF br = d->transform.map(rect.bottomRight());
- coords[0] = tl.x();
- coords[1] = tl.y();
- coords[2] = tr.x();
- coords[3] = tr.y();
- coords[4] = br.x();
- coords[5] = br.y();
- coords[6] = bl.x();
- coords[7] = bl.y();
- }
- vgModifyPathCoords(d->rectPath, 0, 4, coords);
- d->fill(d->rectPath, brush);
-#else
- QPaintEngineEx::fillRect(rect, brush);
-#endif
-}
-
-void QVGPaintEngine::fillRect(const QRectF &rect, const QColor &color)
-{
- Q_D(QVGPaintEngine);
-
- // Check to see if we can use vgClear() for faster filling.
- if (clipTransformIsSimple(d->transform) && d->opacity == 1.0f && color.alpha() == 255 &&
- clearRect(rect, color)) {
- return;
- }
-
-#if !defined(QVG_NO_MODIFY_PATH)
- VGfloat coords[8];
- if (d->simpleTransform) {
- coords[0] = rect.x();
- coords[1] = rect.y();
- coords[2] = rect.x() + rect.width();
- coords[3] = coords[1];
- coords[4] = coords[2];
- coords[5] = rect.y() + rect.height();
- coords[6] = coords[0];
- coords[7] = coords[5];
- } else {
- QPointF tl = d->transform.map(rect.topLeft());
- QPointF tr = d->transform.map(rect.topRight());
- QPointF bl = d->transform.map(rect.bottomLeft());
- QPointF br = d->transform.map(rect.bottomRight());
- coords[0] = tl.x();
- coords[1] = tl.y();
- coords[2] = tr.x();
- coords[3] = tr.y();
- coords[4] = br.x();
- coords[5] = br.y();
- coords[6] = bl.x();
- coords[7] = bl.y();
- }
- vgModifyPathCoords(d->rectPath, 0, 4, coords);
- d->fill(d->rectPath, QBrush(color));
-#else
- QPaintEngineEx::fillRect(rect, QBrush(color));
-#endif
-}
-
-void QVGPaintEngine::drawRoundedRect(const QRectF &rect, qreal xrad, qreal yrad, Qt::SizeMode mode)
-{
- Q_D(QVGPaintEngine);
- if (d->needsEmulation()) {
- QPaintEngineEx::drawRoundedRect(rect, xrad, yrad, mode);
- return;
- }
- if (d->simpleTransform) {
- QVGPainterState *s = state();
- VGPath vgpath = d->roundedRectPath(rect, xrad, yrad, mode);
- d->draw(vgpath, s->pen, s->brush);
-#if defined(QVG_NO_MODIFY_PATH)
- vgDestroyPath(vgpath);
-#endif
- } else {
- QPaintEngineEx::drawRoundedRect(rect, xrad, yrad, mode);
- }
-}
-
-void QVGPaintEngine::drawRects(const QRect *rects, int rectCount)
-{
-#if !defined(QVG_NO_MODIFY_PATH)
- Q_D(QVGPaintEngine);
- if (d->needsEmulation()) {
- QPaintEngineEx::drawRects(rects, rectCount);
- return;
- }
- QVGPainterState *s = state();
- for (int i = 0; i < rectCount; ++i, ++rects) {
- VGfloat coords[8];
- if (d->simpleTransform) {
- coords[0] = rects->x();
- coords[1] = rects->y();
- coords[2] = rects->x() + rects->width();
- coords[3] = coords[1];
- coords[4] = coords[2];
- coords[5] = rects->y() + rects->height();
- coords[6] = coords[0];
- coords[7] = coords[5];
- } else {
- QPointF tl = d->transform.map(QPointF(rects->x(), rects->y()));
- QPointF tr = d->transform.map(QPointF(rects->x() + rects->width(),
- rects->y()));
- QPointF bl = d->transform.map(QPointF(rects->x(),
- rects->y() + rects->height()));
- QPointF br = d->transform.map(QPointF(rects->x() + rects->width(),
- rects->y() + rects->height()));
- coords[0] = tl.x();
- coords[1] = tl.y();
- coords[2] = tr.x();
- coords[3] = tr.y();
- coords[4] = br.x();
- coords[5] = br.y();
- coords[6] = bl.x();
- coords[7] = bl.y();
- }
- vgModifyPathCoords(d->rectPath, 0, 4, coords);
- d->draw(d->rectPath, s->pen, s->brush);
- }
-#else
- QPaintEngineEx::drawRects(rects, rectCount);
-#endif
-}
-
-void QVGPaintEngine::drawRects(const QRectF *rects, int rectCount)
-{
-#if !defined(QVG_NO_MODIFY_PATH)
- Q_D(QVGPaintEngine);
- if (d->needsEmulation()) {
- QPaintEngineEx::drawRects(rects, rectCount);
- return;
- }
- QVGPainterState *s = state();
- for (int i = 0; i < rectCount; ++i, ++rects) {
- VGfloat coords[8];
- if (d->simpleTransform) {
- coords[0] = rects->x();
- coords[1] = rects->y();
- coords[2] = rects->x() + rects->width();
- coords[3] = coords[1];
- coords[4] = coords[2];
- coords[5] = rects->y() + rects->height();
- coords[6] = coords[0];
- coords[7] = coords[5];
- } else {
- QPointF tl = d->transform.map(rects->topLeft());
- QPointF tr = d->transform.map(rects->topRight());
- QPointF bl = d->transform.map(rects->bottomLeft());
- QPointF br = d->transform.map(rects->bottomRight());
- coords[0] = tl.x();
- coords[1] = tl.y();
- coords[2] = tr.x();
- coords[3] = tr.y();
- coords[4] = br.x();
- coords[5] = br.y();
- coords[6] = bl.x();
- coords[7] = bl.y();
- }
- vgModifyPathCoords(d->rectPath, 0, 4, coords);
- d->draw(d->rectPath, s->pen, s->brush);
- }
-#else
- QPaintEngineEx::drawRects(rects, rectCount);
-#endif
-}
-
-void QVGPaintEngine::drawLines(const QLine *lines, int lineCount)
-{
-#if !defined(QVG_NO_MODIFY_PATH)
- Q_D(QVGPaintEngine);
- if (d->needsEmulation()) {
- QPaintEngineEx::drawLines(lines, lineCount);
- return;
- }
- QVGPainterState *s = state();
- for (int i = 0; i < lineCount; ++i, ++lines) {
- VGfloat coords[4];
- if (d->simpleTransform) {
- coords[0] = lines->x1();
- coords[1] = lines->y1();
- coords[2] = lines->x2();
- coords[3] = lines->y2();
- } else {
- QPointF p1 = d->transform.map(QPointF(lines->x1(), lines->y1()));
- QPointF p2 = d->transform.map(QPointF(lines->x2(), lines->y2()));
- coords[0] = p1.x();
- coords[1] = p1.y();
- coords[2] = p2.x();
- coords[3] = p2.y();
- }
- vgModifyPathCoords(d->linePath, 0, 2, coords);
- d->stroke(d->linePath, s->pen);
- }
-#else
- QPaintEngineEx::drawLines(lines, lineCount);
-#endif
-}
-
-void QVGPaintEngine::drawLines(const QLineF *lines, int lineCount)
-{
-#if !defined(QVG_NO_MODIFY_PATH)
- Q_D(QVGPaintEngine);
- if (d->needsEmulation()) {
- QPaintEngineEx::drawLines(lines, lineCount);
- return;
- }
- QVGPainterState *s = state();
- for (int i = 0; i < lineCount; ++i, ++lines) {
- VGfloat coords[4];
- if (d->simpleTransform) {
- coords[0] = lines->x1();
- coords[1] = lines->y1();
- coords[2] = lines->x2();
- coords[3] = lines->y2();
- } else {
- QPointF p1 = d->transform.map(lines->p1());
- QPointF p2 = d->transform.map(lines->p2());
- coords[0] = p1.x();
- coords[1] = p1.y();
- coords[2] = p2.x();
- coords[3] = p2.y();
- }
- vgModifyPathCoords(d->linePath, 0, 2, coords);
- d->stroke(d->linePath, s->pen);
- }
-#else
- QPaintEngineEx::drawLines(lines, lineCount);
-#endif
-}
-
-void QVGPaintEngine::drawEllipse(const QRectF &r)
-{
- // Based on the description of vguEllipse() in the OpenVG specification.
- // We don't use vguEllipse(), to avoid unnecessary library dependencies.
- Q_D(QVGPaintEngine);
- if (d->needsEmulation()) {
- QPaintEngineEx::drawEllipse(r);
- return;
- }
- if (d->simpleTransform) {
- QVGPainterState *s = state();
- VGPath path = vgCreatePath(VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- 4, // segmentCapacityHint
- 12, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
- static VGubyte segments[4] = {
- VG_MOVE_TO_ABS,
- VG_SCCWARC_TO_REL,
- VG_SCCWARC_TO_REL,
- VG_CLOSE_PATH
- };
- VGfloat coords[12];
- VGfloat halfwid = r.width() / 2;
- VGfloat halfht = r.height() / 2;
- coords[0] = r.x() + r.width();
- coords[1] = r.y() + halfht;
- coords[2] = halfwid;
- coords[3] = halfht;
- coords[4] = 0.0f;
- coords[5] = -r.width();
- coords[6] = 0.0f;
- coords[7] = halfwid;
- coords[8] = halfht;
- coords[9] = 0.0f;
- coords[10] = r.width();
- coords[11] = 0.0f;
- vgAppendPathData(path, 4, segments, coords);
- d->draw(path, s->pen, s->brush);
- vgDestroyPath(path);
- } else {
- // The projective transform version of an ellipse is difficult.
- // Generate a QVectorPath containing cubic curves and transform that.
- QPaintEngineEx::drawEllipse(r);
- }
-}
-
-void QVGPaintEngine::drawEllipse(const QRect &r)
-{
- drawEllipse(QRectF(r));
-}
-
-void QVGPaintEngine::drawPath(const QPainterPath &path)
-{
- // Shortcut past the QPainterPath -> QVectorPath conversion,
- // converting the QPainterPath directly into a VGPath.
- Q_D(QVGPaintEngine);
- if (d->needsEmulation()) {
- QPaintEngineEx::drawPath(path);
- return;
- }
- QVGPainterState *s = state();
- VGPath vgpath = d->painterPathToVGPath(path);
- if (path.fillRule() == Qt::OddEvenFill)
- d->draw(vgpath, s->pen, s->brush, VG_EVEN_ODD);
- else
- d->draw(vgpath, s->pen, s->brush, VG_NON_ZERO);
- vgDestroyPath(vgpath);
-}
-
-void QVGPaintEngine::drawPoints(const QPointF *points, int pointCount)
-{
-#if !defined(QVG_NO_MODIFY_PATH)
- Q_D(QVGPaintEngine);
-
- if (d->needsPenEmulation()) {
- QPaintEngineEx::drawPoints(points, pointCount);
- return;
- }
-
- // Set up a new pen if necessary.
- QPen pen = state()->pen;
- if (pen.style() == Qt::NoPen)
- return;
- if (pen.capStyle() == Qt::FlatCap)
- pen.setCapStyle(Qt::SquareCap);
-
- for (int i = 0; i < pointCount; ++i, ++points) {
- VGfloat coords[4];
- if (d->simpleTransform) {
- coords[0] = points->x();
- coords[1] = points->y();
- coords[2] = coords[0];
- coords[3] = coords[1];
- } else {
- QPointF p = d->transform.map(*points);
- coords[0] = p.x();
- coords[1] = p.y();
- coords[2] = coords[0];
- coords[3] = coords[1];
- }
- vgModifyPathCoords(d->linePath, 0, 2, coords);
- d->stroke(d->linePath, pen);
- }
-#else
- QPaintEngineEx::drawPoints(points, pointCount);
-#endif
-}
-
-void QVGPaintEngine::drawPoints(const QPoint *points, int pointCount)
-{
-#if !defined(QVG_NO_MODIFY_PATH)
- Q_D(QVGPaintEngine);
-
- if (d->needsEmulation()) {
- QPaintEngineEx::drawPoints(points, pointCount);
- return;
- }
-
- // Set up a new pen if necessary.
- QPen pen = state()->pen;
- if (pen.style() == Qt::NoPen)
- return;
- if (pen.capStyle() == Qt::FlatCap)
- pen.setCapStyle(Qt::SquareCap);
-
- for (int i = 0; i < pointCount; ++i, ++points) {
- VGfloat coords[4];
- if (d->simpleTransform) {
- coords[0] = points->x();
- coords[1] = points->y();
- coords[2] = coords[0];
- coords[3] = coords[1];
- } else {
- QPointF p = d->transform.map(QPointF(*points));
- coords[0] = p.x();
- coords[1] = p.y();
- coords[2] = coords[0];
- coords[3] = coords[1];
- }
- vgModifyPathCoords(d->linePath, 0, 2, coords);
- d->stroke(d->linePath, pen);
- }
-#else
- QPaintEngineEx::drawPoints(points, pointCount);
-#endif
-}
-
-void QVGPaintEngine::drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode)
-{
- Q_D(QVGPaintEngine);
-
- if (d->needsEmulation()) {
- QPaintEngineEx::drawPolygon(points, pointCount, mode);
- return;
- }
-
- QVGPainterState *s = state();
- VGPath path = vgCreatePath(VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- pointCount + 1, // segmentCapacityHint
- pointCount * 2, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
- QVarLengthArray<VGfloat, 16> coords;
- QVarLengthArray<VGubyte, 10> segments;
- for (int i = 0; i < pointCount; ++i, ++points) {
- if (d->simpleTransform) {
- coords.append(points->x());
- coords.append(points->y());
- } else {
- QPointF temp = d->transform.map(*points);
- coords.append(temp.x());
- coords.append(temp.y());
- }
- if (i == 0)
- segments.append(VG_MOVE_TO_ABS);
- else
- segments.append(VG_LINE_TO_ABS);
- }
- if (mode != QPaintEngine::PolylineMode)
- segments.append(VG_CLOSE_PATH);
- vgAppendPathData(path, segments.count(),
- segments.constData(), coords.constData());
- switch (mode) {
- case QPaintEngine::WindingMode:
- d->draw(path, s->pen, s->brush, VG_NON_ZERO);
- break;
-
- case QPaintEngine::PolylineMode:
- d->stroke(path, s->pen);
- break;
-
- default:
- d->draw(path, s->pen, s->brush, VG_EVEN_ODD);
- break;
- }
- vgDestroyPath(path);
-}
-
-void QVGPaintEngine::drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode)
-{
- Q_D(QVGPaintEngine);
-
- if (d->needsEmulation()) {
- QPaintEngineEx::drawPolygon(points, pointCount, mode);
- return;
- }
-
- QVGPainterState *s = state();
- VGPath path = vgCreatePath(VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- pointCount + 1, // segmentCapacityHint
- pointCount * 2, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
- QVarLengthArray<VGfloat, 16> coords;
- QVarLengthArray<VGubyte, 10> segments;
- for (int i = 0; i < pointCount; ++i, ++points) {
- if (d->simpleTransform) {
- coords.append(points->x());
- coords.append(points->y());
- } else {
- QPointF temp = d->transform.map(QPointF(*points));
- coords.append(temp.x());
- coords.append(temp.y());
- }
- if (i == 0)
- segments.append(VG_MOVE_TO_ABS);
- else
- segments.append(VG_LINE_TO_ABS);
- }
- if (mode != QPaintEngine::PolylineMode)
- segments.append(VG_CLOSE_PATH);
- vgAppendPathData(path, segments.count(),
- segments.constData(), coords.constData());
- switch (mode) {
- case QPaintEngine::WindingMode:
- d->draw(path, s->pen, s->brush, VG_NON_ZERO);
- break;
-
- case QPaintEngine::PolylineMode:
- d->stroke(path, s->pen);
- break;
-
- default:
- d->draw(path, s->pen, s->brush, VG_EVEN_ODD);
- break;
- }
- vgDestroyPath(path);
-}
-
-void QVGPaintEnginePrivate::setImageOptions()
-{
- if (opacity != 1.0f && simpleTransform) {
- if (opacity != paintOpacity) {
- VGfloat values[4];
- values[0] = 1.0f;
- values[1] = 1.0f;
- values[2] = 1.0f;
- values[3] = opacity;
- vgSetParameterfv(opacityPaint, VG_PAINT_COLOR, 4, values);
- paintOpacity = opacity;
- }
- if (fillPaint != opacityPaint) {
- vgSetPaint(opacityPaint, VG_FILL_PATH);
- fillPaint = opacityPaint;
- }
- setImageMode(VG_DRAW_IMAGE_MULTIPLY);
- } else {
- setImageMode(VG_DRAW_IMAGE_NORMAL);
- }
-}
-
-void QVGPaintEnginePrivate::systemStateChanged()
-{
- q->updateScissor();
-}
-
-static void drawVGImage(QVGPaintEnginePrivate *d,
- const QRectF& r, VGImage vgImg,
- const QSize& imageSize, const QRectF& sr)
-{
- if (vgImg == VG_INVALID_HANDLE)
- return;
- VGImage child = VG_INVALID_HANDLE;
-
- if (sr.topLeft().isNull() && sr.size() == imageSize) {
- child = vgImg;
- } else {
- QRect src = sr.toRect();
-#if !defined(QT_SHIVAVG)
- child = vgChildImage(vgImg, src.x(), src.y(), src.width(), src.height());
-#else
- child = vgImg; // XXX: ShivaVG doesn't have vgChildImage().
-#endif
- }
-
- QTransform transform(d->imageTransform);
- VGfloat scaleX = sr.width() == 0.0f ? 0.0f : r.width() / sr.width();
- VGfloat scaleY = sr.height() == 0.0f ? 0.0f : r.height() / sr.height();
- transform.translate(r.x(), r.y());
- transform.scale(scaleX, scaleY);
- d->setTransform(VG_MATRIX_IMAGE_USER_TO_SURFACE, transform);
-
- d->setImageOptions();
- vgDrawImage(child);
-
- if(child != vgImg)
- vgDestroyImage(child);
-}
-
-static void drawVGImage(QVGPaintEnginePrivate *d,
- const QPointF& pos, VGImage vgImg)
-{
- if (vgImg == VG_INVALID_HANDLE)
- return;
-
- QTransform transform(d->imageTransform);
- transform.translate(pos.x(), pos.y());
- d->setTransform(VG_MATRIX_IMAGE_USER_TO_SURFACE, transform);
-
- d->setImageOptions();
- vgDrawImage(vgImg);
-}
-
-static void drawImageTiled(QVGPaintEnginePrivate *d,
- const QRectF &r,
- const QImage &image,
- const QRectF &sr = QRectF())
-{
- const int minTileSize = 16;
- int tileWidth = 512;
- int tileHeight = tileWidth;
-
- VGImageFormat tileFormat = qt_vg_image_to_vg_format(image.format());
- VGImage tile = VG_INVALID_HANDLE;
- QVGImagePool *pool = QVGImagePool::instance();
- while (tile == VG_INVALID_HANDLE && tileWidth >= minTileSize) {
- tile = pool->createPermanentImage(tileFormat, tileWidth, tileHeight,
- VG_IMAGE_QUALITY_FASTER);
- if (tile == VG_INVALID_HANDLE) {
- tileWidth /= 2;
- tileHeight /= 2;
- }
- }
- if (tile == VG_INVALID_HANDLE) {
- qWarning("drawImageTiled: Failed to create %dx%d tile, giving up", tileWidth, tileHeight);
- return;
- }
-
- VGfloat opacityMatrix[20] = {
- 1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, d->opacity,
- 0.0f, 0.0f, 0.0f, 0.0f
- };
- VGImage tileWithOpacity = VG_INVALID_HANDLE;
- if (d->opacity != 1) {
- tileWithOpacity = pool->createPermanentImage(VG_sARGB_8888_PRE,
- tileWidth, tileHeight, VG_IMAGE_QUALITY_FASTER);
- if (tileWithOpacity == VG_INVALID_HANDLE)
- qWarning("drawImageTiled: Failed to create extra tile, ignoring opacity");
- }
-
- QRect sourceRect = sr.toRect();
- if (sourceRect.isNull())
- sourceRect = QRect(0, 0, image.width(), image.height());
-
- VGfloat scaleX = r.width() / sourceRect.width();
- VGfloat scaleY = r.height() / sourceRect.height();
-
- d->setImageOptions();
-
- for (int y = sourceRect.y(); y < sourceRect.height(); y += tileHeight) {
- int h = qMin(tileHeight, sourceRect.height() - y);
- if (h < 1)
- break;
- for (int x = sourceRect.x(); x < sourceRect.width(); x += tileWidth) {
- int w = qMin(tileWidth, sourceRect.width() - x);
- if (w < 1)
- break;
-
- int bytesPerPixel = image.depth() / 8;
- const uchar *sptr = image.constBits() + x * bytesPerPixel + y * image.bytesPerLine();
- vgImageSubData(tile, sptr, image.bytesPerLine(), tileFormat, 0, 0, w, h);
-
- QTransform transform(d->imageTransform);
- transform.translate(r.x() + x, r.y() + y);
- transform.scale(scaleX, scaleY);
- d->setTransform(VG_MATRIX_IMAGE_USER_TO_SURFACE, transform);
-
- VGImage actualTile = tile;
- if (tileWithOpacity != VG_INVALID_HANDLE) {
- vgColorMatrix(tileWithOpacity, actualTile, opacityMatrix);
- if (w < tileWidth || h < tileHeight)
- actualTile = vgChildImage(tileWithOpacity, 0, 0, w, h);
- else
- actualTile = tileWithOpacity;
- } else if (w < tileWidth || h < tileHeight) {
- actualTile = vgChildImage(tile, 0, 0, w, h);
- }
- vgDrawImage(actualTile);
-
- if (actualTile != tile && actualTile != tileWithOpacity)
- vgDestroyImage(actualTile);
- }
- }
-
- vgDestroyImage(tile);
- if (tileWithOpacity != VG_INVALID_HANDLE)
- vgDestroyImage(tileWithOpacity);
-}
-
-// Used by qpixmapfilter_vg.cpp to draw filtered VGImage's.
-void qt_vg_drawVGImage(QPainter *painter, const QPointF& pos, VGImage vgImg)
-{
- QVGPaintEngine *engine =
- static_cast<QVGPaintEngine *>(painter->paintEngine());
- drawVGImage(engine->vgPrivate(), pos, vgImg);
-}
-
-// Used by qpixmapfilter_vg.cpp to draw filtered VGImage's as a stencil.
-void qt_vg_drawVGImageStencil
- (QPainter *painter, const QPointF& pos, VGImage vgImg, const QBrush& brush)
-{
- QVGPaintEngine *engine =
- static_cast<QVGPaintEngine *>(painter->paintEngine());
-
- QVGPaintEnginePrivate *d = engine->vgPrivate();
-
- QTransform transform(d->imageTransform);
- transform.translate(pos.x(), pos.y());
- d->setTransform(VG_MATRIX_IMAGE_USER_TO_SURFACE, transform);
-
- d->ensureBrush(brush);
- d->setImageMode(VG_DRAW_IMAGE_STENCIL);
- vgDrawImage(vgImg);
-}
-
-bool QVGPaintEngine::canVgWritePixels(const QImage &image) const
-{
- Q_D(const QVGPaintEngine);
-
- // qt_vg_image_to_vg_format returns VG_sARGB_8888 as
- // fallback case if no matching VG format is found.
- // If given image format is not Format_ARGB32 and returned
- // format is VG_sARGB_8888, it means that no match was
- // found. In that case vgWritePixels cannot be used.
- // Also 1-bit formats cannot be used directly either.
- if ((image.format() != QImage::Format_ARGB32
- && qt_vg_image_to_vg_format(image.format()) == VG_sARGB_8888)
- || image.depth() == 1) {
- return false;
- }
-
- // vgWritePixels ignores masking, blending and xforms so we can only use it if
- // ALL of the following conditions are true:
- // - It is a simple translate, or a scale of -1 on the y-axis (inverted)
- // - The opacity is totally opaque
- // - The composition mode is "source" OR "source over" provided the image is opaque
- return ( d->imageTransform.type() <= QTransform::TxScale
- && d->imageTransform.m11() == 1.0 && qAbs(d->imageTransform.m22()) == 1.0)
- && d->opacity == 1.0f
- && (d->blendMode == VG_BLEND_SRC || (d->blendMode == VG_BLEND_SRC_OVER &&
- !image.hasAlphaChannel()));
-}
-
-void QVGPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr)
-{
- QPixmapData *pd = pm.pixmapData();
- if (!pd)
- return; // null QPixmap
- if (pd->classId() == QPixmapData::OpenVGClass) {
- Q_D(QVGPaintEngine);
- QVGPixmapData *vgpd = static_cast<QVGPixmapData *>(pd);
- if (!vgpd->isValid())
- return;
- if (d->simpleTransform)
- drawVGImage(d, r, vgpd->toVGImage(), vgpd->size(), sr);
- else
- drawVGImage(d, r, vgpd->toVGImage(d->opacity), vgpd->size(), sr);
-
- if(!vgpd->failedToAlloc)
- return;
-
- // try to reallocate next time if reasonable small pixmap
- QSize screenSize = QApplication::desktop()->screenGeometry().size();
- if (pm.size().width() <= screenSize.width()
- && pm.size().height() <= screenSize.height())
- vgpd->failedToAlloc = false;
-
- vgpd->source.beginDataAccess();
- drawImage(r, vgpd->source.imageRef(), sr, Qt::AutoColor);
- vgpd->source.endDataAccess(true);
- } else {
- drawImage(r, *(pd->buffer()), sr, Qt::AutoColor);
- }
-}
-
-void QVGPaintEngine::drawPixmap(const QPointF &pos, const QPixmap &pm)
-{
- QPixmapData *pd = pm.pixmapData();
- if (!pd)
- return; // null QPixmap
- if (pd->classId() == QPixmapData::OpenVGClass) {
- Q_D(QVGPaintEngine);
- QVGPixmapData *vgpd = static_cast<QVGPixmapData *>(pd);
- if (!vgpd->isValid())
- return;
- if (d->simpleTransform)
- drawVGImage(d, pos, vgpd->toVGImage());
- else
- drawVGImage(d, pos, vgpd->toVGImage(d->opacity));
-
- if (!vgpd->failedToAlloc)
- return;
-
- // try to reallocate next time if reasonable small pixmap
- QSize screenSize = QApplication::desktop()->screenGeometry().size();
- if (pm.size().width() <= screenSize.width()
- && pm.size().height() <= screenSize.height())
- vgpd->failedToAlloc = false;
-
- vgpd->source.beginDataAccess();
- drawImage(pos, vgpd->source.imageRef());
- vgpd->source.endDataAccess(true);
- } else {
- drawImage(pos, *(pd->buffer()));
- }
-}
-
-void QVGPaintEngine::drawImage
- (const QRectF &r, const QImage &image, const QRectF &sr,
- Qt::ImageConversionFlags flags)
-{
- Q_D(QVGPaintEngine);
- if (image.isNull())
- return;
- VGImage vgImg;
- if (d->simpleTransform || d->opacity == 1.0f)
- vgImg = toVGImageSubRect(image, sr.toRect(), flags);
- else
- vgImg = toVGImageWithOpacitySubRect(image, d->opacity, sr.toRect());
- if (vgImg != VG_INVALID_HANDLE) {
- if (r.size() == sr.size()) {
- drawVGImage(d, r.topLeft(), vgImg);
- } else {
- drawVGImage(d, r, vgImg, sr.size().toSize(),
- QRectF(QPointF(0, 0), sr.size()));
- }
- } else {
- if (canVgWritePixels(image) && (r.size() == sr.size()) && !flags) {
- // Optimization for straight blits, no blending
- int x = sr.x();
- int y = sr.y();
- int bpp = image.depth() >> 3; // bytes
- int offset = 0;
- int bpl = image.bytesPerLine();
- if (d->imageTransform.m22() < 0) {
- // inverted
- offset = ((y + sr.height()) * bpl) - ((image.width() - x) * bpp);
- bpl = -bpl;
- } else {
- offset = (y * bpl) + (x * bpp);
- }
- const uchar *bits = image.constBits() + offset;
-
- QPointF mapped = d->imageTransform.map(r.topLeft());
- vgWritePixels(bits, bpl, qt_vg_image_to_vg_format(image.format()),
- mapped.x(), mapped.y() - sr.height(), r.width(), r.height());
- return;
- } else {
- // Monochrome images need to use the vgChildImage() path.
- vgImg = toVGImage(image, flags);
- if (vgImg == VG_INVALID_HANDLE)
- drawImageTiled(d, r, image, sr);
- else
- drawVGImage(d, r, vgImg, image.size(), sr);
- }
- }
- vgDestroyImage(vgImg);
-}
-
-void QVGPaintEngine::drawImage(const QPointF &pos, const QImage &image)
-{
- Q_D(QVGPaintEngine);
- if (image.isNull())
- return;
- VGImage vgImg;
- if (canVgWritePixels(image)) {
- // Optimization for straight blits, no blending
- bool inverted = (d->imageTransform.m22() < 0);
- const uchar *bits = inverted ? image.constBits() + image.byteCount() : image.constBits();
- int bpl = inverted ? -image.bytesPerLine() : image.bytesPerLine();
-
- QPointF mapped = d->imageTransform.map(pos);
- vgWritePixels(bits, bpl, qt_vg_image_to_vg_format(image.format()),
- mapped.x(), mapped.y() - image.height(), image.width(), image.height());
- return;
- } else if (d->simpleTransform || d->opacity == 1.0f) {
- vgImg = toVGImage(image);
- } else {
- vgImg = toVGImageWithOpacity(image, d->opacity);
- }
- if (vgImg == VG_INVALID_HANDLE)
- drawImageTiled(d, QRectF(pos, image.size()), image);
- else
- drawVGImage(d, pos, vgImg);
- vgDestroyImage(vgImg);
-}
-
-void QVGPaintEngine::drawTiledPixmap
- (const QRectF &r, const QPixmap &pixmap, const QPointF &s)
-{
- QBrush brush(state()->pen.color(), pixmap);
- QTransform xform = QTransform::fromTranslate(r.x() - s.x(), r.y() - s.y());
- brush.setTransform(xform);
- fillRect(r, brush);
-}
-
-// Best performance will be achieved with QDrawPixmaps::OpaqueHint
-// (i.e. no opacity), no rotation or scaling, and drawing the full
-// pixmap rather than parts of the pixmap. Even having just one of
-// these conditions will improve performance.
-void QVGPaintEngine::drawPixmapFragments(const QPainter::PixmapFragment *drawingData, int dataCount,
- const QPixmap &pixmap, QFlags<QPainter::PixmapFragmentHint> hints)
-{
-#if !defined(QT_SHIVAVG)
- Q_D(QVGPaintEngine);
-
- // If the pixmap is not VG, or the transformation is projective,
- // then fall back to the default implementation.
- QPixmapData *pd = pixmap.pixmapData();
- if (!pd)
- return; // null QPixmap
- if (pd->classId() != QPixmapData::OpenVGClass || !d->simpleTransform) {
- QPaintEngineEx::drawPixmapFragments(drawingData, dataCount, pixmap, hints);
- return;
- }
-
- // Bail out if nothing to do.
- if (dataCount <= 0)
- return;
-
- // Bail out if we don't have a usable VGImage for the pixmap.
- QVGPixmapData *vgpd = static_cast<QVGPixmapData *>(pd);
- if (!vgpd->isValid())
- return;
- VGImage vgImg = vgpd->toVGImage();
- if (vgImg == VG_INVALID_HANDLE)
- return;
-
- // We cache the results of any vgChildImage() calls because the
- // same child is very likely to be used over and over in particle
- // systems. However, performance is even better if vgChildImage()
- // isn't needed at all, so use full source rects where possible.
- QVarLengthArray<VGImage> cachedImages;
- QVarLengthArray<QRect> cachedSources;
-
- // Select the opacity paint object.
- if ((hints & QPainter::OpaqueHint) != 0 && d->opacity == 1.0f) {
- d->setImageMode(VG_DRAW_IMAGE_NORMAL);
- } else {
- hints = 0;
- if (d->fillPaint != d->opacityPaint) {
- vgSetPaint(d->opacityPaint, VG_FILL_PATH);
- d->fillPaint = d->opacityPaint;
- }
- }
-
- for (int i = 0; i < dataCount; ++i) {
- QTransform transform(d->imageTransform);
- transform.translate(drawingData[i].x, drawingData[i].y);
- transform.rotate(drawingData[i].rotation);
-
- VGImage child;
- QSize imageSize = vgpd->size();
- QRectF sr(drawingData[i].sourceLeft, drawingData[i].sourceTop,
- drawingData[i].width, drawingData[i].height);
- if (sr.topLeft().isNull() && sr.size() == imageSize) {
- child = vgImg;
- } else {
- // Look for a previous child with the same source rectangle
- // to avoid constantly calling vgChildImage()/vgDestroyImage().
- QRect src = sr.toRect();
- int j;
- for (j = 0; j < cachedSources.size(); ++j) {
- if (cachedSources[j] == src)
- break;
- }
- if (j < cachedSources.size()) {
- child = cachedImages[j];
- } else {
- child = vgChildImage
- (vgImg, src.x(), src.y(), src.width(), src.height());
- cachedImages.append(child);
- cachedSources.append(src);
- }
- }
-
- VGfloat scaleX = drawingData[i].scaleX;
- VGfloat scaleY = drawingData[i].scaleY;
- transform.translate(-0.5 * scaleX * sr.width(),
- -0.5 * scaleY * sr.height());
- transform.scale(scaleX, scaleY);
- d->setTransform(VG_MATRIX_IMAGE_USER_TO_SURFACE, transform);
-
- if ((hints & QPainter::OpaqueHint) == 0) {
- qreal opacity = d->opacity * drawingData[i].opacity;
- if (opacity != 1.0f) {
- if (d->paintOpacity != opacity) {
- VGfloat values[4];
- values[0] = 1.0f;
- values[1] = 1.0f;
- values[2] = 1.0f;
- values[3] = opacity;
- d->paintOpacity = opacity;
- vgSetParameterfv
- (d->opacityPaint, VG_PAINT_COLOR, 4, values);
- }
- d->setImageMode(VG_DRAW_IMAGE_MULTIPLY);
- } else {
- d->setImageMode(VG_DRAW_IMAGE_NORMAL);
- }
- }
-
- vgDrawImage(child);
- }
-
- // Destroy the cached child sub-images.
- for (int i = 0; i < cachedImages.size(); ++i)
- vgDestroyImage(cachedImages[i]);
-#else
- QPaintEngineEx::drawPixmapFragments(drawingData, dataCount, pixmap, hints);
-#endif
-}
-
-QVGFontEngineCleaner::QVGFontEngineCleaner(QVGPaintEnginePrivate *d)
- : QObject(), d_ptr(d)
-{
-}
-
-QVGFontEngineCleaner::~QVGFontEngineCleaner()
-{
-}
-
-void QVGFontEngineCleaner::fontEngineDestroyed()
-{
-#if !defined(QVG_NO_DRAW_GLYPHS)
- QFontEngine *engine = static_cast<QFontEngine *>(sender());
- QVGFontCache::Iterator it = d_ptr->fontCache.find(engine);
- if (it != d_ptr->fontCache.end()) {
- delete it.value();
- d_ptr->fontCache.erase(it);
- }
-#endif
-}
-
-#if !defined(QVG_NO_DRAW_GLYPHS)
-
-QVGFontGlyphCache::QVGFontGlyphCache()
-{
- font = vgCreateFont(0);
- scaleX = scaleY = 0.0;
- invertedGlyphs = false;
- memset(cachedGlyphsMask, 0, sizeof(cachedGlyphsMask));
-}
-
-QVGFontGlyphCache::~QVGFontGlyphCache()
-{
- if (font != VG_INVALID_HANDLE)
- vgDestroyFont(font);
-}
-
-void QVGFontGlyphCache::setScaleFromText(const QFont &font, QFontEngine *fontEngine)
-{
- QFontInfo fi(font);
- qreal pixelSize = fi.pixelSize();
- qreal emSquare = fontEngine->properties().emSquare.toReal();
- scaleX = scaleY = static_cast<VGfloat>(pixelSize / emSquare);
-}
-
-void QVGFontGlyphCache::cacheGlyphs(QVGPaintEnginePrivate *d,
- QFontEngine *fontEngine,
- const glyph_t *g, int count)
-{
- VGfloat origin[2];
- VGfloat escapement[2];
- glyph_metrics_t metrics;
- // Some Qt font engines don't set yoff in getUnscaledGlyph().
- // Zero the metric structure so that everything has a default value.
- memset(&metrics, 0, sizeof(metrics));
- while (count-- > 0) {
- // Skip this glyph if we have already cached it before.
- glyph_t glyph = *g++;
- if (glyph < 256) {
- if ((cachedGlyphsMask[glyph / 32] & (1 << (glyph % 32))) != 0)
- continue;
- cachedGlyphsMask[glyph / 32] |= (1 << (glyph % 32));
- } else if (cachedGlyphs.contains(glyph)) {
- continue;
- } else {
- cachedGlyphs.insert(glyph);
- }
-#if !defined(QVG_NO_IMAGE_GLYPHS)
- Q_UNUSED(d);
- QImage scaledImage = fontEngine->alphaMapForGlyph(glyph);
- VGImage vgImage = VG_INVALID_HANDLE;
- metrics = fontEngine->boundingBox(glyph);
- if (!scaledImage.isNull()) { // Not a space character
- if (scaledImage.format() == QImage::Format_Indexed8) {
- vgImage = vgCreateImage(VG_A_8, scaledImage.width(), scaledImage.height(), VG_IMAGE_QUALITY_FASTER);
- vgImageSubData(vgImage, scaledImage.constBits(), scaledImage.bytesPerLine(), VG_A_8, 0, 0, scaledImage.width(), scaledImage.height());
- } else if (scaledImage.format() == QImage::Format_Mono) {
- QImage img = scaledImage.convertToFormat(QImage::Format_Indexed8);
- vgImage = vgCreateImage(VG_A_8, img.width(), img.height(), VG_IMAGE_QUALITY_FASTER);
- vgImageSubData(vgImage, img.constBits(), img.bytesPerLine(), VG_A_8, 0, 0, img.width(), img.height());
- } else {
- QImage img = scaledImage.convertToFormat(QImage::Format_ARGB32_Premultiplied);
- vgImage = vgCreateImage(VG_sARGB_8888_PRE, img.width(), img.height(), VG_IMAGE_QUALITY_FASTER);
- vgImageSubData(vgImage, img.constBits(), img.bytesPerLine(), VG_sARGB_8888_PRE, 0, 0, img.width(), img.height());
- }
- }
- origin[0] = -metrics.x.toReal();
- origin[1] = -metrics.y.toReal();
- escapement[0] = 0;
- escapement[1] = 0;
- vgSetGlyphToImage(font, glyph, vgImage, origin, escapement);
- vgDestroyImage(vgImage); // Reduce reference count.
-#else
- // Calculate the path for the glyph and cache it.
- QPainterPath path;
- fontEngine->getUnscaledGlyph(glyph, &path, &metrics);
- VGPath vgPath;
- if (!path.isEmpty()) {
- vgPath = d->painterPathToVGPath(path);
- } else {
- // Probably a "space" character with no visible outline.
- vgPath = VG_INVALID_HANDLE;
- }
- origin[0] = 0;
- origin[1] = 0;
- escapement[0] = 0;
- escapement[1] = 0;
- vgSetGlyphToPath(font, glyph, vgPath, VG_FALSE, origin, escapement);
- vgDestroyPath(vgPath); // Reduce reference count.
-#endif // !defined(QVG_NO_IMAGE_GLYPHS)
- }
-}
-
-#endif // !defined(QVG_NO_DRAW_GLYPHS)
-
-void QVGPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem)
-{
-#if !defined(QVG_NO_DRAW_GLYPHS)
- Q_D(QVGPaintEngine);
- const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem);
-
- // If we are not using a simple transform, then fall back
- // to the default Qt path stroking algorithm.
- if (!d->simpleTransform) {
- QPaintEngineEx::drawTextItem(p, textItem);
- return;
- }
-
- if (d->needsPenEmulation()) {
- QPaintEngineEx::drawTextItem(p, textItem);
- return;
- }
-
- // Get the glyphs and positions associated with the text item.
- QVarLengthArray<QFixedPoint> positions;
- QVarLengthArray<glyph_t> glyphs;
- QTransform matrix;
- ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
-
- if (!drawCachedGlyphs(glyphs.size(), glyphs.data(), ti.font(), ti.fontEngine, p, positions.data()))
- QPaintEngineEx::drawTextItem(p, textItem);
-#else
- // OpenGL 1.0 does not have support for VGFont and glyphs,
- // so fall back to the default Qt path stroking algorithm.
- QPaintEngineEx::drawTextItem(p, textItem);
-#endif
-}
-
-void QVGPaintEngine::drawStaticTextItem(QStaticTextItem *textItem)
-{
- drawCachedGlyphs(textItem->numGlyphs, textItem->glyphs, textItem->font, textItem->fontEngine(),
- QPointF(0, 0), textItem->glyphPositions);
-}
-
- bool QVGPaintEngine::drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, const QFont &font,
- QFontEngine *fontEngine, const QPointF &p,
- const QFixedPoint *positions)
- {
-#if !defined(QVG_NO_DRAW_GLYPHS)
- Q_D(QVGPaintEngine);
-
- // Find the glyph cache for this font.
- QVGFontCache::ConstIterator it = d->fontCache.constFind(fontEngine);
- QVGFontGlyphCache *glyphCache;
- if (it != d->fontCache.constEnd()) {
- glyphCache = it.value();
- } else {
-#ifdef Q_OS_SYMBIAN
- glyphCache = new QSymbianVGFontGlyphCache();
-#else
- glyphCache = new QVGFontGlyphCache();
-#endif
- if (glyphCache->font == VG_INVALID_HANDLE) {
- qWarning("QVGPaintEngine::drawTextItem: OpenVG fonts are not supported by the OpenVG engine");
- delete glyphCache;
- return false;
- }
- glyphCache->setScaleFromText(font, fontEngine);
- d->fontCache.insert(fontEngine, glyphCache);
- if (!d->fontEngineCleaner)
- d->fontEngineCleaner = new QVGFontEngineCleaner(d);
- QObject::connect(fontEngine, SIGNAL(destroyed()),
- d->fontEngineCleaner, SLOT(fontEngineDestroyed()));
- }
-
- // Set the transformation to use for drawing the current glyphs.
- QTransform glyphTransform(d->pathTransform);
- if (d->transform.type() <= QTransform::TxTranslate) {
- // Prevent blurriness of unscaled, unrotated text by forcing integer coordinates.
- glyphTransform.translate(
- floor(p.x() + glyphTransform.dx() + aliasedCoordinateDelta) - glyphTransform.dx(),
- floor(p.y() - glyphTransform.dy() + aliasedCoordinateDelta) + glyphTransform.dy());
- } else {
- glyphTransform.translate(p.x(), p.y());
- }
-#if defined(QVG_NO_IMAGE_GLYPHS)
- glyphTransform.scale(glyphCache->scaleX, glyphCache->scaleY);
-#endif
-
- // Some glyph caches can create the VGImage upright
- if (glyphCache->invertedGlyphs)
- glyphTransform.scale(1, -1);
-
- d->setTransform(VG_MATRIX_GLYPH_USER_TO_SURFACE, glyphTransform);
-
- // Add the glyphs from the text item into the glyph cache.
- glyphCache->cacheGlyphs(d, fontEngine, glyphs, numGlyphs);
-
- // Create the array of adjustments between glyphs
- QVarLengthArray<VGfloat> adjustments_x(numGlyphs);
- QVarLengthArray<VGfloat> adjustments_y(numGlyphs);
- for (int i = 1; i < numGlyphs; ++i) {
- adjustments_x[i-1] = (positions[i].x - positions[i-1].x).round().toReal();
- adjustments_y[i-1] = (positions[i].y - positions[i-1].y).round().toReal();
- }
-
- // Set the glyph drawing origin.
- VGfloat origin[2];
- origin[0] = positions[0].x.round().toReal();
- origin[1] = positions[0].y.round().toReal();
- vgSetfv(VG_GLYPH_ORIGIN, 2, origin);
-
- // Fast anti-aliasing for paths, better for images.
-#if !defined(QVG_NO_IMAGE_GLYPHS)
- d->setImageQuality(VG_IMAGE_QUALITY_BETTER);
- d->setImageMode(VG_DRAW_IMAGE_STENCIL);
-#else
- d->setRenderingQuality(VG_RENDERING_QUALITY_FASTER);
-#endif
-
- // Draw the glyphs. We need to fill with the brush associated with
- // the Qt pen, not the Qt brush.
- d->ensureBrush(state()->pen.brush());
- vgDrawGlyphs(glyphCache->font, numGlyphs, (VGuint*)glyphs,
- adjustments_x.data(), adjustments_y.data(), VG_FILL_PATH, VG_TRUE);
- return true;
-#else
- Q_UNUSED(numGlyphs);
- Q_UNUSED(glyphs);
- Q_UNUSED(font);
- Q_UNUSED(fontEngine);
- Q_UNUSED(p);
- Q_UNUSED(positions);
- return false;
-#endif
-}
-
-void QVGPaintEngine::setState(QPainterState *s)
-{
- Q_D(QVGPaintEngine);
- QPaintEngineEx::setState(s);
- QVGPainterState *ps = static_cast<QVGPainterState *>(s);
- if (ps->isNew) {
- // Newly created state object. The call to setState()
- // will either be followed by a call to begin(), or we are
- // setting the state as part of a save().
- ps->isNew = false;
- } else {
- // This state object was set as part of a restore().
- restoreState(d->dirty);
- d->dirty = ps->savedDirty;
- }
-}
-
-void QVGPaintEngine::beginNativePainting()
-{
- Q_D(QVGPaintEngine);
-
- // About to enter raw VG mode: flush pending changes and make
- // sure that all matrices are set to the current transformation.
- QVGPainterState *s = this->state();
- d->ensurePen(s->pen);
- d->ensureBrush(s->brush);
- d->ensurePathTransform();
- d->setTransform(VG_MATRIX_IMAGE_USER_TO_SURFACE, d->imageTransform);
-#if !defined(QVG_NO_DRAW_GLYPHS)
- d->setTransform(VG_MATRIX_GLYPH_USER_TO_SURFACE, d->pathTransform);
-#endif
- vgSeti(VG_SCISSORING, VG_FALSE);
- vgSeti(VG_MASKING, VG_FALSE);
- d->rawVG = true;
-}
-
-void QVGPaintEngine::endNativePainting()
-{
- Q_D(QVGPaintEngine);
- // Exiting raw VG mode: force all state values to be
- // explicitly set on the VG engine to undo any changes
- // that were made by the raw VG function calls.
- QPaintEngine::DirtyFlags dirty = d->dirty;
- d->clearModes();
- d->forcePenChange = true;
- d->forceBrushChange = true;
- d->penType = (VGPaintType)0;
- d->brushType = (VGPaintType)0;
- d->clearColor = QColor();
- d->fillPaint = d->brushPaint;
- d->scissorDirty = true;
- restoreState(QPaintEngine::AllDirty);
- d->dirty = dirty;
- d->rawVG = false;
- vgSetPaint(d->penPaint, VG_STROKE_PATH);
- vgSetPaint(d->brushPaint, VG_FILL_PATH);
-}
-
-QPixmapFilter *QVGPaintEngine::pixmapFilter(int type, const QPixmapFilter *prototype)
-{
-#if !defined(QT_SHIVAVG)
- Q_D(QVGPaintEngine);
- switch (type) {
- case QPixmapFilter::ConvolutionFilter:
- if (!d->convolutionFilter)
- d->convolutionFilter.reset(new QVGPixmapConvolutionFilter);
- return d->convolutionFilter.data();
- case QPixmapFilter::ColorizeFilter:
- if (!d->colorizeFilter)
- d->colorizeFilter.reset(new QVGPixmapColorizeFilter);
- return d->colorizeFilter.data();
- case QPixmapFilter::DropShadowFilter:
- if (!d->dropShadowFilter)
- d->dropShadowFilter.reset(new QVGPixmapDropShadowFilter);
- return d->dropShadowFilter.data();
- case QPixmapFilter::BlurFilter:
- if (!d->blurFilter)
- d->blurFilter.reset(new QVGPixmapBlurFilter);
- return d->blurFilter.data();
- default: break;
- }
-#endif
- return QPaintEngineEx::pixmapFilter(type, prototype);
-}
-
-void QVGPaintEngine::restoreState(QPaintEngine::DirtyFlags dirty)
-{
- Q_D(QVGPaintEngine);
-
- // Restore the pen, brush, and other settings.
- if ((dirty & QPaintEngine::DirtyBrushOrigin) != 0)
- brushOriginChanged();
- d->fillRule = 0;
- d->clearColor = QColor();
- if ((dirty & QPaintEngine::DirtyOpacity) != 0)
- opacityChanged();
- if ((dirty & QPaintEngine::DirtyTransform) != 0)
- transformChanged();
- if ((dirty & QPaintEngine::DirtyCompositionMode) != 0)
- compositionModeChanged();
- if ((dirty & QPaintEngine::DirtyHints) != 0)
- renderHintsChanged();
- if ((dirty & (QPaintEngine::DirtyClipRegion |
- QPaintEngine::DirtyClipPath |
- QPaintEngine::DirtyClipEnabled)) != 0) {
- d->maskValid = false;
- d->maskIsSet = false;
- d->scissorMask = false;
- d->maskRect = QRect();
- d->scissorDirty = true;
- clipEnabledChanged();
- }
-
-#if defined(QVG_SCISSOR_CLIP)
- if ((dirty & (QPaintEngine::DirtyClipRegion |
- QPaintEngine::DirtyClipPath |
- QPaintEngine::DirtyClipEnabled)) == 0) {
- updateScissor();
- }
-#else
- updateScissor();
-#endif
-}
-
-void QVGPaintEngine::fillRegion
- (const QRegion& region, const QColor& color, const QSize& surfaceSize)
-{
- Q_D(QVGPaintEngine);
- if (d->clearColor != color || d->clearOpacity != 1.0f) {
- VGfloat values[4];
- values[0] = color.redF();
- values[1] = color.greenF();
- values[2] = color.blueF();
- values[3] = color.alphaF();
- vgSetfv(VG_CLEAR_COLOR, 4, values);
- d->clearColor = color;
- d->clearOpacity = 1.0f;
- }
- if (region.rectCount() == 1) {
- QRect r = region.boundingRect();
- vgClear(r.x(), surfaceSize.height() - r.y() - r.height(),
- r.width(), r.height());
- } else {
- const QVector<QRect> rects = region.rects();
- for (int i = 0; i < rects.size(); ++i) {
- QRect r = rects.at(i);
- vgClear(r.x(), surfaceSize.height() - r.y() - r.height(),
- r.width(), r.height());
- }
- }
-}
-
-#if !defined(QVG_NO_SINGLE_CONTEXT) && !defined(QT_NO_EGL)
-
-QVGCompositionHelper::QVGCompositionHelper()
-{
- d = qt_vg_create_paint_engine()->vgPrivate();
-}
-
-QVGCompositionHelper::~QVGCompositionHelper()
-{
-}
-
-void QVGCompositionHelper::startCompositing(const QSize& screenSize)
-{
- this->screenSize = screenSize;
- clearScissor();
- d->setBlendMode(VG_BLEND_SRC_OVER);
-}
-
-void QVGCompositionHelper::endCompositing()
-{
- clearScissor();
-}
-
-void QVGCompositionHelper::blitWindow
- (VGImage image, const QSize& imageSize,
- const QRect& rect, const QPoint& topLeft, int opacity)
-{
- if (image == VG_INVALID_HANDLE)
- return;
-
- // Determine which sub rectangle of the window to draw.
- QRect sr = rect.translated(-topLeft);
-
- if (opacity >= 255) {
- // Fully opaque: use vgSetPixels() to directly copy the sub-region.
- int y = screenSize.height() - (rect.bottom() + 1);
- vgSetPixels(rect.x(), y, image, sr.x(),
- imageSize.height() - (sr.y() + sr.height()),
- sr.width(), sr.height());
- } else {
- // Extract the child image that we want to draw.
- VGImage child;
- if (sr.topLeft().isNull() && sr.size() == imageSize)
- child = image;
- else {
- child = vgChildImage
- (image, sr.x(), imageSize.height() - (sr.y() + sr.height()),
- sr.width(), sr.height());
- }
-
- // Set the image transform.
- QTransform transform;
- int y = screenSize.height() - (rect.bottom() + 1);
- transform.translate(rect.x() - 0.5f, y - 0.5f);
- d->setTransform(VG_MATRIX_IMAGE_USER_TO_SURFACE, transform);
-
- // Enable opacity for image drawing if necessary.
- if (opacity != d->paintOpacity) {
- VGfloat values[4];
- values[0] = 1.0f;
- values[1] = 1.0f;
- values[2] = 1.0f;
- values[3] = ((VGfloat)opacity) / 255.0f;
- vgSetParameterfv(d->opacityPaint, VG_PAINT_COLOR, 4, values);
- d->paintOpacity = values[3];
- }
- if (d->fillPaint != d->opacityPaint) {
- vgSetPaint(d->opacityPaint, VG_FILL_PATH);
- d->fillPaint = d->opacityPaint;
- }
- d->setImageMode(VG_DRAW_IMAGE_MULTIPLY);
-
- // Draw the child image.
- vgDrawImage(child);
-
- // Destroy the child image.
- if(child != image)
- vgDestroyImage(child);
- }
-}
-
-static void fillBackgroundRect(const QRect& rect, QVGPaintEnginePrivate *d)
-{
- VGfloat coords[8];
- coords[0] = rect.x();
- coords[1] = rect.y();
- coords[2] = rect.x() + rect.width();
- coords[3] = coords[1];
- coords[4] = coords[2];
- coords[5] = rect.y() + rect.height();
- coords[6] = coords[0];
- coords[7] = coords[5];
-#if !defined(QVG_NO_MODIFY_PATH)
- vgModifyPathCoords(d->rectPath, 0, 4, coords);
- vgDrawPath(d->rectPath, VG_FILL_PATH);
-#else
- Q_UNUSED(d);
- VGPath rectPath = vgCreatePath
- (VG_PATH_FORMAT_STANDARD,
- VG_PATH_DATATYPE_F,
- 1.0f, // scale
- 0.0f, // bias
- 5, // segmentCapacityHint
- 8, // coordCapacityHint
- VG_PATH_CAPABILITY_ALL);
- static VGubyte const segments[5] = {
- VG_MOVE_TO_ABS,
- VG_LINE_TO_ABS,
- VG_LINE_TO_ABS,
- VG_LINE_TO_ABS,
- VG_CLOSE_PATH
- };
- vgAppendPathData(rectPath, 5, segments, coords);
- vgDrawPath(rectPath, VG_FILL_PATH);
- vgDestroyPath(rectPath);
-#endif
-}
-
-void QVGCompositionHelper::fillBackground
- (const QRegion& region, const QBrush& brush)
-{
- if (brush.style() == Qt::SolidPattern) {
- // Use vgClear() to quickly fill the background.
- QColor color = brush.color();
- if (d->clearColor != color || d->clearOpacity != 1.0f) {
- VGfloat values[4];
- values[0] = color.redF();
- values[1] = color.greenF();
- values[2] = color.blueF();
- values[3] = color.alphaF();
- vgSetfv(VG_CLEAR_COLOR, 4, values);
- d->clearColor = color;
- d->clearOpacity = 1.0f;
- }
- if (region.rectCount() == 1) {
- QRect r = region.boundingRect();
- vgClear(r.x(), screenSize.height() - r.y() - r.height(),
- r.width(), r.height());
- } else {
- const QVector<QRect> rects = region.rects();
- for (int i = 0; i < rects.size(); ++i) {
- QRect r = rects.at(i);
- vgClear(r.x(), screenSize.height() - r.y() - r.height(),
- r.width(), r.height());
- }
- }
-
- } else {
- // Set the path transform to the default viewport transformation.
- VGfloat devh = screenSize.height();
- QTransform viewport(1.0f, 0.0f, 0.0f,
- 0.0f, -1.0f, 0.0f,
- 0.0f, devh, 1.0f);
- d->setTransform(VG_MATRIX_PATH_USER_TO_SURFACE, viewport);
-
- // Set the brush to use to fill the background.
- d->ensureBrush(brush);
- d->setFillRule(VG_EVEN_ODD);
-
- if (region.rectCount() == 1) {
- fillBackgroundRect(region.boundingRect(), d);
- } else {
- const QVector<QRect> rects = region.rects();
- for (int i = 0; i < rects.size(); ++i)
- fillBackgroundRect(rects.at(i), d);
- }
-
- // We will need to reset the path transform during the next paint.
- d->pathTransformSet = false;
- }
-}
-
-void QVGCompositionHelper::drawCursorPixmap
- (const QPixmap& pixmap, const QPoint& offset)
-{
- VGImage vgImage = VG_INVALID_HANDLE;
-
- // Fetch the VGImage from the pixmap if possible.
- QPixmapData *pd = pixmap.pixmapData();
- if (!pd)
- return; // null QPixmap
- if (pd->classId() == QPixmapData::OpenVGClass) {
- QVGPixmapData *vgpd = static_cast<QVGPixmapData *>(pd);
- if (vgpd->isValid())
- vgImage = vgpd->toVGImage();
- }
-
- // Set the image transformation and modes.
- VGfloat devh = screenSize.height();
- QTransform transform(1.0f, 0.0f, 0.0f,
- 0.0f, -1.0f, 0.0f,
- 0.0f, devh, 1.0f);
- transform.translate(offset.x(), offset.y());
- d->setTransform(VG_MATRIX_IMAGE_USER_TO_SURFACE, transform);
- d->setImageMode(VG_DRAW_IMAGE_NORMAL);
-
- // Draw the VGImage.
- if (vgImage != VG_INVALID_HANDLE) {
- vgDrawImage(vgImage);
- } else {
- QImage img = pixmap.toImage().convertToFormat
- (QImage::Format_ARGB32_Premultiplied);
-
- vgImage = vgCreateImage
- (VG_sARGB_8888_PRE, img.width(), img.height(),
- VG_IMAGE_QUALITY_FASTER);
- if (vgImage == VG_INVALID_HANDLE)
- return;
- vgImageSubData
- (vgImage, img.constBits() + img.bytesPerLine() * (img.height() - 1),
- -(img.bytesPerLine()), VG_sARGB_8888_PRE, 0, 0,
- img.width(), img.height());
-
- vgDrawImage(vgImage);
- vgDestroyImage(vgImage);
- }
-}
-
-void QVGCompositionHelper::setScissor(const QRegion& region)
-{
- QVector<QRect> rects = region.rects();
- int count = rects.count();
- if (count > d->maxScissorRects)
- count = d->maxScissorRects;
- QVarLengthArray<VGint> params(count * 4);
- int height = screenSize.height();
- for (int i = 0; i < count; ++i) {
- params[i * 4 + 0] = rects[i].x();
- params[i * 4 + 1] = height - rects[i].y() - rects[i].height();
- params[i * 4 + 2] = rects[i].width();
- params[i * 4 + 3] = rects[i].height();
- }
-
- vgSetiv(VG_SCISSOR_RECTS, count * 4, params.data());
- vgSeti(VG_SCISSORING, VG_TRUE);
- d->scissorDirty = false;
- d->scissorActive = true;
- d->scissorRegion = region;
-}
-
-void QVGCompositionHelper::clearScissor()
-{
- if (d->scissorActive || d->scissorDirty) {
- vgSeti(VG_SCISSORING, VG_FALSE);
- d->scissorActive = false;
- d->scissorDirty = false;
- }
-}
-
-#endif // !QVG_NO_SINGLE_CONTEXT && !QT_NO_EGL
-
-VGImageFormat qt_vg_image_to_vg_format(QImage::Format format)
-{
- switch (format) {
- case QImage::Format_MonoLSB:
- return VG_BW_1;
- case QImage::Format_Indexed8:
- return VG_sL_8;
- case QImage::Format_ARGB32_Premultiplied:
- return VG_sARGB_8888_PRE;
- case QImage::Format_RGB32:
- return VG_sXRGB_8888;
- case QImage::Format_ARGB32:
- return VG_sARGB_8888;
- case QImage::Format_RGB16:
- return VG_sRGB_565;
- case QImage::Format_ARGB4444_Premultiplied:
- return VG_sARGB_4444;
- default:
- break;
- }
- return VG_sARGB_8888; // XXX
-}
-
-QT_END_NAMESPACE
-
-#include "qpaintengine_vg.moc"
diff --git a/src/openvg/qpaintengine_vg_p.h b/src/openvg/qpaintengine_vg_p.h
deleted file mode 100644
index 1e9103bc81..0000000000
--- a/src/openvg/qpaintengine_vg_p.h
+++ /dev/null
@@ -1,178 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPAINTENGINE_VG_P_H
-#define QPAINTENGINE_VG_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtGui/private/qpaintengineex_p.h>
-#include <QtGui/private/qtextureglyphcache_p.h>
-
-QT_BEGIN_NAMESPACE
-
-struct QFixedPoint;
-class QVGPaintEnginePrivate;
-class QPixmapData;
-class QVGEGLWindowSurfacePrivate;
-
-class Q_OPENVG_EXPORT QVGPainterState : public QPainterState
-{
-public:
- QVGPainterState(QVGPainterState& other);
- QVGPainterState();
- ~QVGPainterState();
-
- bool isNew;
- QRegion clipRegion;
- QPaintEngine::DirtyFlags savedDirty;
-};
-
-class Q_OPENVG_EXPORT QVGPaintEngine : public QPaintEngineEx
-{
- Q_DECLARE_PRIVATE(QVGPaintEngine)
-public:
- QVGPaintEngine();
- ~QVGPaintEngine();
-
- Type type() const { return OpenVG; }
-
- QPainterState *createState(QPainterState *orig) const;
-
- bool begin(QPaintDevice *pdev);
- bool end();
-
- void draw(const QVectorPath &path);
- void fill(const QVectorPath &path, const QBrush &brush);
- void stroke(const QVectorPath &path, const QPen &pen);
-
- void clip(const QVectorPath &path, Qt::ClipOperation op);
- void clip(const QRect &rect, Qt::ClipOperation op);
- void clip(const QRegion &region, Qt::ClipOperation op);
- void clip(const QPainterPath &path, Qt::ClipOperation op);
-
- void clipEnabledChanged();
- void penChanged();
- void brushChanged();
- void brushOriginChanged();
- void opacityChanged();
- void compositionModeChanged();
- void renderHintsChanged();
- void transformChanged();
-
- void fillRect(const QRectF &rect, const QBrush &brush);
- void fillRect(const QRectF &rect, const QColor &color);
-
- void drawRoundedRect(const QRectF &rect, qreal xrad, qreal yrad, Qt::SizeMode mode);
-
- void drawRects(const QRect *rects, int rectCount);
- void drawRects(const QRectF *rects, int rectCount);
-
- void drawLines(const QLine *lines, int lineCount);
- void drawLines(const QLineF *lines, int lineCount);
-
- void drawEllipse(const QRectF &r);
- void drawEllipse(const QRect &r);
-
- void drawPath(const QPainterPath &path);
-
- void drawPoints(const QPointF *points, int pointCount);
- void drawPoints(const QPoint *points, int pointCount);
-
- void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode);
- void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode);
-
- void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr);
- void drawPixmap(const QPointF &pos, const QPixmap &pm);
-
- void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr,
- Qt::ImageConversionFlags flags = Qt::AutoColor);
- void drawImage(const QPointF &pos, const QImage &image);
-
- void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
-
- void drawPixmapFragments(const QPainter::PixmapFragment *drawingData, int dataCount, const QPixmap &pixmap,
- QFlags<QPainter::PixmapFragmentHint> hints);
-
- void drawTextItem(const QPointF &p, const QTextItem &textItem);
- void drawStaticTextItem(QStaticTextItem *staticTextItem);
- bool drawCachedGlyphs(int numGlyphs, const glyph_t *glyphs, const QFont &font,
- QFontEngine *fontEngine, const QPointF &p,
- const QFixedPoint *positions);
-
- void setState(QPainterState *s);
- QVGPainterState *state() { return static_cast<QVGPainterState *>(QPaintEngineEx::state()); }
- const QVGPainterState *state() const { return static_cast<const QVGPainterState *>(QPaintEngineEx::state()); }
-
- void beginNativePainting();
- void endNativePainting();
-
- QPixmapFilter *pixmapFilter(int type, const QPixmapFilter *prototype);
-
- QVGPaintEnginePrivate *vgPrivate() { Q_D(QVGPaintEngine); return d; }
-
- void fillRegion(const QRegion& region, const QColor& color, const QSize& surfaceSize);
-
-protected:
- QVGPaintEngine(QVGPaintEnginePrivate &data);
-
-private:
- void restoreState(QPaintEngine::DirtyFlags dirty);
- void updateScissor();
- QRegion defaultClipRegion();
- bool isDefaultClipRegion(const QRegion& region);
- bool isDefaultClipRect(const QRect& rect);
- bool clearRect(const QRectF &rect, const QColor &color);
- bool canVgWritePixels(const QImage &image) const;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp
deleted file mode 100644
index ea93748685..0000000000
--- a/src/openvg/qpixmapdata_vg.cpp
+++ /dev/null
@@ -1,575 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qpixmapdata_vg_p.h"
-#include "qpaintengine_vg_p.h"
-#include <QtGui/private/qdrawhelper_p.h>
-#if !defined(QT_NO_EGL)
-#include <QtGui/private/qegl_p.h>
-#endif
-#include "qvg_p.h"
-#include "qvgimagepool_p.h"
-#include <QBuffer>
-#include <QImageReader>
-#include <QtGui/private/qimage_p.h>
-#include <QtGui/private/qnativeimagehandleprovider_p.h>
-#include <QtGui/private/qfont_p.h>
-
-QT_BEGIN_NAMESPACE
-
-static int qt_vg_pixmap_serial = 0;
-
-QVGPixmapData::QVGPixmapData(PixelType type)
- : QPixmapData(type, OpenVGClass)
-{
- Q_ASSERT(type == QPixmapData::PixmapType);
- vgImage = VG_INVALID_HANDLE;
- vgImageOpacity = VG_INVALID_HANDLE;
- cachedOpacity = 1.0f;
- recreate = true;
- inImagePool = false;
- inLRU = false;
- failedToAlloc = false;
-#if defined(Q_OS_SYMBIAN)
- nativeImageHandleProvider = 0;
- nativeImageHandle = 0;
-#endif
-#if !defined(QT_NO_EGL)
- context = 0;
- qt_vg_register_pixmap(this);
-#endif
- updateSerial();
-}
-
-QVGPixmapData::~QVGPixmapData()
-{
- destroyImageAndContext();
-#if !defined(QT_NO_EGL)
- qt_vg_unregister_pixmap(this);
-#endif
-}
-
-void QVGPixmapData::destroyImages()
-{
- if (inImagePool) {
- QVGImagePool *pool = QVGImagePool::instance();
- if (vgImage != VG_INVALID_HANDLE)
- pool->releaseImage(this, vgImage);
- if (vgImageOpacity != VG_INVALID_HANDLE)
- pool->releaseImage(this, vgImageOpacity);
- } else {
- if (vgImage != VG_INVALID_HANDLE)
- vgDestroyImage(vgImage);
- if (vgImageOpacity != VG_INVALID_HANDLE)
- vgDestroyImage(vgImageOpacity);
- }
- vgImage = VG_INVALID_HANDLE;
- vgImageOpacity = VG_INVALID_HANDLE;
- inImagePool = false;
-
-#if defined(Q_OS_SYMBIAN)
- releaseNativeImageHandle();
-#endif
-}
-
-void QVGPixmapData::destroyImageAndContext()
-{
- if (vgImage != VG_INVALID_HANDLE) {
- // We need to have a context current to destroy the image.
-#if !defined(QT_NO_EGL)
- if (!context)
- context = qt_vg_create_context(0, QInternal::Pixmap);
- if (context->isCurrent()) {
- destroyImages();
- } else {
- // We don't currently have a widget surface active, but we
- // need a surface to make the context current. So use the
- // shared pbuffer surface instead.
- context->makeCurrent(qt_vg_shared_surface());
- destroyImages();
- context->lazyDoneCurrent();
- }
-#else
- destroyImages();
-#endif
- } else {
-#if defined(Q_OS_SYMBIAN)
- releaseNativeImageHandle();
-#endif
- }
-#if !defined(QT_NO_EGL)
- if (context) {
- qt_vg_destroy_context(context, QInternal::Pixmap);
- context = 0;
- }
-#endif
- recreate = true;
-}
-
-QPixmapData *QVGPixmapData::createCompatiblePixmapData() const
-{
- return new QVGPixmapData(pixelType());
-}
-
-bool QVGPixmapData::isValid() const
-{
- return (w > 0 && h > 0);
-}
-
-void QVGPixmapData::updateSerial()
-{
- setSerialNumber(++qt_vg_pixmap_serial);
-}
-
-void QVGPixmapData::resize(int wid, int ht)
-{
- if (w == wid && h == ht) {
- updateSerial();
- return;
- }
-
- w = wid;
- h = ht;
- d = 32; // We always use ARGB_Premultiplied for VG pixmaps.
- is_null = (w <= 0 || h <= 0);
- source = QVolatileImage();
- recreate = true;
-
- updateSerial();
-}
-
-void QVGPixmapData::fromImage(const QImage &image, Qt::ImageConversionFlags flags)
-{
- if (image.isNull())
- return;
-
- QImage img = image;
- createPixmapForImage(img, flags, false);
-}
-
-void QVGPixmapData::fromImageReader(QImageReader *imageReader,
- Qt::ImageConversionFlags flags)
-{
- QImage image = imageReader->read();
- if (image.isNull())
- return;
-
- createPixmapForImage(image, flags, true);
-}
-
-bool QVGPixmapData::fromFile(const QString &filename, const char *format,
- Qt::ImageConversionFlags flags)
-{
- QImage image = QImageReader(filename, format).read();
- if (image.isNull())
- return false;
-
- createPixmapForImage(image, flags, true);
-
- return !isNull();
-}
-
-bool QVGPixmapData::fromData(const uchar *buffer, uint len, const char *format,
- Qt::ImageConversionFlags flags)
-{
- QByteArray a = QByteArray::fromRawData(reinterpret_cast<const char *>(buffer), len);
- QBuffer b(&a);
- b.open(QIODevice::ReadOnly);
- QImage image = QImageReader(&b, format).read();
- if (image.isNull())
- return false;
-
- createPixmapForImage(image, flags, true);
-
- return !isNull();
-}
-
-QImage::Format QVGPixmapData::idealFormat(QImage *image, Qt::ImageConversionFlags flags) const
-{
- QImage::Format format = sourceFormat();
- int d = image->depth();
- if (d == 1 || d == 16 || d == 24 || (d == 32 && !image->hasAlphaChannel()))
- format = QImage::Format_RGB32;
- else if (!(flags & Qt::NoOpaqueDetection) && image->data_ptr()->checkForAlphaPixels())
- format = sourceFormat();
- else
- format = image->hasAlphaChannel() ? sourceFormat() : QImage::Format_RGB32;
- return format;
-}
-
-void QVGPixmapData::createPixmapForImage(QImage &image, Qt::ImageConversionFlags flags, bool inPlace)
-{
- resize(image.width(), image.height());
-
- QImage::Format format = idealFormat(&image, flags);
-
- if (inPlace && image.data_ptr()->convertInPlace(format, flags)) {
- source = QVolatileImage(image);
- } else {
- QImage convertedImage = image.convertToFormat(format);
- // convertToFormat won't detach the image if format stays the
- // same. Detaching is needed to prevent issues with painting
- // onto this QPixmap later on.
- convertedImage.detach();
- source = QVolatileImage(convertedImage);
- }
-
- recreate = true;
-}
-
-void QVGPixmapData::fill(const QColor &color)
-{
- if (!isValid())
- return;
- forceToImage();
- if (source.depth() == 1) {
- // Pick the best approximate color in the image's colortable.
- int gray = qGray(color.rgba());
- if (qAbs(qGray(source.imageRef().color(0)) - gray)
- < qAbs(qGray(source.imageRef().color(1)) - gray))
- source.fill(0);
- else
- source.fill(1);
- } else {
- source.fill(PREMUL(color.rgba()));
- }
-}
-
-bool QVGPixmapData::hasAlphaChannel() const
-{
- ensureReadback(true);
- if (!source.isNull())
- return source.hasAlphaChannel();
- else
- return isValid();
-}
-
-void QVGPixmapData::setAlphaChannel(const QPixmap &alphaChannel)
-{
- if (!isValid())
- return;
- forceToImage();
- source.setAlphaChannel(alphaChannel);
-}
-
-QImage QVGPixmapData::toImage() const
-{
- if (!isValid())
- return QImage();
- ensureReadback(true);
- if (source.isNull()) {
- source = QVolatileImage(w, h, sourceFormat());
- recreate = true;
- }
- return source.toImage();
-}
-
-void QVGPixmapData::copy(const QPixmapData *data, const QRect &rect)
-{
- // toImage() is potentially expensive with QVolatileImage so provide a
- // more efficient implementation of copy() that does not rely on it.
- if (!data) {
- return;
- }
- if (data->classId() != OpenVGClass) {
- fromImage(data->toImage(rect), Qt::NoOpaqueDetection);
- return;
- }
- const QVGPixmapData *pd = static_cast<const QVGPixmapData *>(data);
- QRect r = rect;
- if (r.isNull() || r.contains(QRect(0, 0, pd->w, pd->h))) {
- r = QRect(0, 0, pd->w, pd->h);
- }
- resize(r.width(), r.height());
- recreate = true;
- if (!pd->source.isNull()) {
- source = QVolatileImage(r.width(), r.height(), pd->source.format());
- source.copyFrom(&pd->source, r);
- }
-}
-
-QImage *QVGPixmapData::buffer()
-{
- // Cannot be safely implemented and QVGPixmapData is not (must not be) RasterClass anyway.
- return 0;
-}
-
-QPaintEngine* QVGPixmapData::paintEngine() const
-{
- // If the application wants to paint into the QPixmap, we first
- // force it to QImage format and then paint into that.
- // This is simpler than juggling multiple VG contexts.
- const_cast<QVGPixmapData *>(this)->forceToImage();
- return source.paintEngine();
-}
-
-VGImage QVGPixmapData::toVGImage()
-{
- if (!isValid() || failedToAlloc)
- return VG_INVALID_HANDLE;
-
-#if !defined(QT_NO_EGL)
- // Increase the reference count on the shared context.
- if (!context)
- context = qt_vg_create_context(0, QInternal::Pixmap);
-#endif
-
- if (recreate && prevSize != QSize(w, h))
- destroyImages();
- else if (recreate)
- cachedOpacity = -1.0f; // Force opacity image to be refreshed later.
-
-#if defined(Q_OS_SYMBIAN)
- if (recreate && nativeImageHandleProvider && !nativeImageHandle) {
- createFromNativeImageHandleProvider();
- }
-#endif
-
- if (vgImage == VG_INVALID_HANDLE) {
- vgImage = QVGImagePool::instance()->createImageForPixmap
- (qt_vg_image_to_vg_format(source.format()), w, h, VG_IMAGE_QUALITY_FASTER, this);
-
- // Bail out if we run out of GPU memory - try again next time.
- if (vgImage == VG_INVALID_HANDLE) {
- failedToAlloc = true;
- return VG_INVALID_HANDLE;
- }
-
- inImagePool = true;
- } else if (inImagePool) {
- QVGImagePool::instance()->useImage(this);
- }
-
- if (!source.isNull() && recreate) {
- source.beginDataAccess();
- vgImageSubData
- (vgImage,
- source.constBits(), source.bytesPerLine(),
- qt_vg_image_to_vg_format(source.format()), 0, 0, w, h);
- source.endDataAccess(true);
- }
-
- recreate = false;
- prevSize = QSize(w, h);
-
- return vgImage;
-}
-
-VGImage QVGPixmapData::toVGImage(qreal opacity)
-{
-#if !defined(QT_SHIVAVG)
- // Force the primary VG image to be recreated if necessary.
- if (toVGImage() == VG_INVALID_HANDLE)
- return VG_INVALID_HANDLE;
-
- if (opacity == 1.0f)
- return vgImage;
-
- // Create an alternative image for the selected opacity.
- if (vgImageOpacity == VG_INVALID_HANDLE || cachedOpacity != opacity) {
- if (vgImageOpacity == VG_INVALID_HANDLE) {
- if (inImagePool) {
- vgImageOpacity = QVGImagePool::instance()->createImageForPixmap
- (VG_sARGB_8888_PRE, w, h, VG_IMAGE_QUALITY_FASTER, this);
- } else {
- vgImageOpacity = vgCreateImage
- (VG_sARGB_8888_PRE, w, h, VG_IMAGE_QUALITY_FASTER);
- }
-
- // Bail out if we run out of GPU memory - try again next time.
- if (vgImageOpacity == VG_INVALID_HANDLE)
- return VG_INVALID_HANDLE;
- }
- VGfloat matrix[20] = {
- 1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, opacity,
- 0.0f, 0.0f, 0.0f, 0.0f
- };
- vgColorMatrix(vgImageOpacity, vgImage, matrix);
- cachedOpacity = opacity;
- }
-
- return vgImageOpacity;
-#else
- // vgColorMatrix() doesn't work with ShivaVG, so ignore the opacity.
- Q_UNUSED(opacity);
- return toVGImage();
-#endif
-}
-
-void QVGPixmapData::detachImageFromPool()
-{
- if (inImagePool) {
- QVGImagePool::instance()->detachImage(this);
- inImagePool = false;
- }
-}
-
-void QVGPixmapData::hibernate()
-{
- // If the image was imported (e.g, from an SgImage under Symbian), then
- // skip the hibernation, there is no sense in copying it back to main
- // memory because the data is most likely shared between several processes.
- bool skipHibernate = (vgImage != VG_INVALID_HANDLE && source.isNull());
-#if defined(Q_OS_SYMBIAN)
- // However we have to proceed normally if the image was retrieved via
- // a handle provider.
- skipHibernate &= !nativeImageHandleProvider;
-#endif
- if (skipHibernate)
- return;
-
- forceToImage(false); // no readback allowed here
- destroyImageAndContext();
-}
-
-void QVGPixmapData::reclaimImages()
-{
- if (!inImagePool)
- return;
- forceToImage();
- destroyImages();
-}
-
-int QVGPixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const
-{
- switch (metric) {
- case QPaintDevice::PdmWidth:
- return w;
- case QPaintDevice::PdmHeight:
- return h;
- case QPaintDevice::PdmNumColors:
- return 0;
- case QPaintDevice::PdmDepth:
- return d;
- case QPaintDevice::PdmWidthMM:
- return qRound(w * 25.4 / qt_defaultDpiX());
- case QPaintDevice::PdmHeightMM:
- return qRound(h * 25.4 / qt_defaultDpiY());
- case QPaintDevice::PdmDpiX:
- case QPaintDevice::PdmPhysicalDpiX:
- return qt_defaultDpiX();
- case QPaintDevice::PdmDpiY:
- case QPaintDevice::PdmPhysicalDpiY:
- return qt_defaultDpiY();
- default:
- qWarning("QVGPixmapData::metric(): Invalid metric");
- return 0;
- }
-}
-
-// Ensures that the pixmap is backed by some valid data and forces the data to
-// be re-uploaded to the VGImage when toVGImage() is called next time.
-void QVGPixmapData::forceToImage(bool allowReadback)
-{
- if (!isValid())
- return;
-
- if (allowReadback)
- ensureReadback(false);
-
- if (source.isNull())
- source = QVolatileImage(w, h, sourceFormat());
-
- recreate = true;
-}
-
-void QVGPixmapData::ensureReadback(bool readOnly) const
-{
- if (vgImage != VG_INVALID_HANDLE && source.isNull()) {
- source = QVolatileImage(w, h, sourceFormat());
- source.beginDataAccess();
- vgGetImageSubData(vgImage, source.bits(), source.bytesPerLine(),
- qt_vg_image_to_vg_format(source.format()),
- 0, 0, w, h);
- source.endDataAccess();
- if (readOnly) {
- recreate = false;
- } else {
- // Once we did a readback, the original VGImage must be destroyed
- // because it may be shared (e.g. created via SgImage) and a subsequent
- // upload of the image data may produce unexpected results.
- const_cast<QVGPixmapData *>(this)->destroyImages();
-#if defined(Q_OS_SYMBIAN)
- // There is now an own copy of the data so drop the handle provider,
- // otherwise toVGImage() would request the handle again, which is wrong.
- nativeImageHandleProvider = 0;
-#endif
- recreate = true;
- }
- }
-}
-
-QImage::Format QVGPixmapData::sourceFormat() const
-{
- return QImage::Format_ARGB32_Premultiplied;
-}
-
-/*
- \internal
-
- Returns the VGImage that is storing the contents of \a pixmap.
- Returns VG_INVALID_HANDLE if \a pixmap is not owned by the OpenVG
- graphics system or \a pixmap is invalid.
-
- This function is typically used to access the backing store
- for a pixmap when executing raw OpenVG calls. It must only
- be used when a QPainter is active and the OpenVG paint engine
- is in use by the QPainter.
-
- \sa {QtOpenVG Module}
-*/
-Q_OPENVG_EXPORT VGImage qPixmapToVGImage(const QPixmap& pixmap)
-{
- QPixmapData *pd = pixmap.pixmapData();
- if (!pd)
- return VG_INVALID_HANDLE; // null QPixmap
- if (pd->classId() == QPixmapData::OpenVGClass) {
- QVGPixmapData *vgpd = static_cast<QVGPixmapData *>(pd);
- if (vgpd->isValid())
- return vgpd->toVGImage();
- }
- return VG_INVALID_HANDLE;
-}
-
-QT_END_NAMESPACE
diff --git a/src/openvg/qpixmapdata_vg_p.h b/src/openvg/qpixmapdata_vg_p.h
deleted file mode 100644
index c28459674d..0000000000
--- a/src/openvg/qpixmapdata_vg_p.h
+++ /dev/null
@@ -1,202 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPIXMAPDATA_VG_P_H
-#define QPIXMAPDATA_VG_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtGui/private/qpixmap_raster_p.h>
-#include <QtGui/private/qvolatileimage_p.h>
-#include "qvg_p.h"
-
-#if defined(Q_OS_SYMBIAN)
-class RSGImage;
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class QEglContext;
-class QVGImagePool;
-class QImageReader;
-
-#if !defined(QT_NO_EGL)
-class QVGPixmapData;
-class QVGSharedContext;
-
-void qt_vg_register_pixmap(QVGPixmapData *pd);
-void qt_vg_unregister_pixmap(QVGPixmapData *pd);
-void qt_vg_hibernate_pixmaps(QVGSharedContext *context);
-#endif
-
-class QNativeImageHandleProvider;
-
-class Q_OPENVG_EXPORT QVGPixmapData : public QPixmapData
-{
-public:
- QVGPixmapData(PixelType type);
- ~QVGPixmapData();
-
- QPixmapData *createCompatiblePixmapData() const;
-
- // Is this pixmap valid (i.e. non-zero in size)?
- bool isValid() const;
-
- void resize(int width, int height);
- void fromImage(const QImage &image, Qt::ImageConversionFlags flags);
- void fromImageReader(QImageReader *imageReader,
- Qt::ImageConversionFlags flags);
- bool fromFile(const QString &filename, const char *format,
- Qt::ImageConversionFlags flags);
- bool fromData(const uchar *buffer, uint len, const char *format,
- Qt::ImageConversionFlags flags);
-
- void fill(const QColor &color);
- bool hasAlphaChannel() const;
- void setAlphaChannel(const QPixmap &alphaChannel);
- QImage toImage() const;
- void copy(const QPixmapData *data, const QRect &rect);
- QImage *buffer();
- QPaintEngine* paintEngine() const;
-
- // Return the VGImage form of this pixmap, creating it if necessary.
- // This assumes that there is a VG context current.
- virtual VGImage toVGImage();
-
- // Return the VGImage form for a specific opacity setting.
- virtual VGImage toVGImage(qreal opacity);
-
- // Detach this image from the image pool.
- virtual void detachImageFromPool();
-
- // Release the VG resources associated with this pixmap and copy
- // the pixmap's contents out of the GPU back into main memory.
- // The VG resource will be automatically recreated the next time
- // toVGImage() is called. Does nothing if the pixmap cannot be
- // hibernated for some reason (e.g. VGImage is shared with another
- // process via a SgImage).
- virtual void hibernate();
-
- // Called when the QVGImagePool wants to reclaim this pixmap's
- // VGImage objects to reuse storage.
- virtual void reclaimImages();
-
- // If vgImage is valid but source is null, copies pixel data from GPU back
- // into main memory and destroys vgImage. For a normal pixmap this function
- // does nothing, however if the pixmap was created directly from a VGImage
- // (e.g. via SgImage on Symbian) then by doing the readback this ensures
- // that QImage-based functions can operate too.
- virtual void ensureReadback(bool readOnly) const;
-
- QSize size() const { return QSize(w, h); }
-
-#if defined(Q_OS_SYMBIAN)
- void* toNativeType(NativeType type);
- void fromNativeType(void* pixmap, NativeType type);
- bool initFromNativeImageHandle(void *handle, const QString &type);
- void createFromNativeImageHandleProvider();
- void releaseNativeImageHandle();
-#endif
-
-protected:
- int metric(QPaintDevice::PaintDeviceMetric metric) const;
- void createPixmapForImage(QImage &image, Qt::ImageConversionFlags flags, bool inPlace);
-
-#if defined(Q_OS_SYMBIAN)
- void cleanup();
-#endif
-
-private:
- QVGPixmapData *nextLRU;
- QVGPixmapData *prevLRU;
- bool inLRU;
- bool failedToAlloc;
- friend class QVGImagePool;
- friend class QVGPaintEngine;
-
-#if !defined(QT_NO_EGL)
- QVGPixmapData *next;
- QVGPixmapData *prev;
-
- friend void qt_vg_register_pixmap(QVGPixmapData *pd);
- friend void qt_vg_unregister_pixmap(QVGPixmapData *pd);
- friend void qt_vg_hibernate_pixmaps(QVGSharedContext *context);
-#endif
-
-protected:
- QSize prevSize;
- VGImage vgImage;
- VGImage vgImageOpacity;
- qreal cachedOpacity;
- mutable QVolatileImage source;
- mutable bool recreate;
- bool inImagePool;
-#if !defined(QT_NO_EGL)
- mutable QEglContext *context;
-#endif
-
-#if defined(Q_OS_SYMBIAN)
- mutable QNativeImageHandleProvider *nativeImageHandleProvider;
- void *nativeImageHandle;
- QString nativeImageType;
-#endif
-
- void forceToImage(bool allowReadback = true);
- QImage::Format sourceFormat() const;
- QImage::Format idealFormat(QImage *image, Qt::ImageConversionFlags flags) const;
- void updateSerial();
-
- void destroyImageAndContext();
- void destroyImages();
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/openvg/qpixmapfilter_vg.cpp b/src/openvg/qpixmapfilter_vg.cpp
deleted file mode 100644
index 7d323f2a86..0000000000
--- a/src/openvg/qpixmapfilter_vg.cpp
+++ /dev/null
@@ -1,356 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qpixmapfilter_vg_p.h"
-#include "qvgimagepool_p.h"
-#include <QtCore/qvarlengtharray.h>
-#include <QtGui/qpainter.h>
-
-QT_BEGIN_NAMESPACE
-
-#if !defined(QT_SHIVAVG)
-
-QVGPixmapConvolutionFilter::QVGPixmapConvolutionFilter()
- : QPixmapConvolutionFilter()
-{
-}
-
-QVGPixmapConvolutionFilter::~QVGPixmapConvolutionFilter()
-{
-}
-
-extern void qt_vg_drawVGImage
- (QPainter *painter, const QPointF& pos, VGImage vgImg);
-extern void qt_vg_drawVGImageStencil
- (QPainter *painter, const QPointF& pos, VGImage vgImg, const QBrush& brush);
-
-void QVGPixmapConvolutionFilter::draw
- (QPainter *painter, const QPointF &dest,
- const QPixmap &src, const QRectF &srcRect) const
-{
- if (src.isNull())
- return;
-
- if (src.pixmapData()->classId() != QPixmapData::OpenVGClass) {
- // The pixmap data is not an instance of QVGPixmapData, so fall
- // back to the default convolution filter implementation.
- QPixmapConvolutionFilter::draw(painter, dest, src, srcRect);
- return;
- }
-
- QVGPixmapData *pd = static_cast<QVGPixmapData *>(src.pixmapData());
-
- VGImage srcImage = pd->toVGImage();
- if (srcImage == VG_INVALID_HANDLE)
- return;
-
- QSize size = pd->size();
- VGImage dstImage = QVGImagePool::instance()->createTemporaryImage
- (VG_sARGB_8888_PRE, size.width(), size.height(),
- VG_IMAGE_QUALITY_FASTER, pd);
- if (dstImage == VG_INVALID_HANDLE)
- return;
-
- int kernelWidth = rows();
- int kernelHeight = columns();
- const qreal *kern = convolutionKernel();
- QVarLengthArray<VGshort> kernel;
- for (int i = 0; i < kernelWidth; ++i) {
- for (int j = 0; j < kernelHeight; ++j) {
- kernel.append((VGshort)(kern[j * kernelWidth + i] * 1024.0f));
- }
- }
-
- VGfloat values[4];
- values[0] = 0.0f;
- values[1] = 0.0f;
- values[2] = 0.0f;
- values[3] = 0.0f;
- vgSetfv(VG_TILE_FILL_COLOR, 4, values);
-
- vgConvolve(dstImage, srcImage,
- kernelWidth, kernelHeight, 0, 0,
- kernel.constData(), 1.0f / 1024.0f, 0.0f,
- VG_TILE_FILL);
-
- VGImage child = VG_INVALID_HANDLE;
-
- if (srcRect.isNull() ||
- (srcRect.topLeft().isNull() && srcRect.size() == size)) {
- child = dstImage;
- } else {
- QRect src = srcRect.toRect();
- child = vgChildImage(dstImage, src.x(), src.y(), src.width(), src.height());
- }
-
- qt_vg_drawVGImage(painter, dest, child);
-
- if(child != dstImage)
- vgDestroyImage(child);
- QVGImagePool::instance()->releaseImage(0, dstImage);
-}
-
-QVGPixmapColorizeFilter::QVGPixmapColorizeFilter()
- : QPixmapColorizeFilter()
-{
-}
-
-QVGPixmapColorizeFilter::~QVGPixmapColorizeFilter()
-{
-}
-
-void QVGPixmapColorizeFilter::draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect) const
-{
- if (src.isNull())
- return;
-
- if (src.pixmapData()->classId() != QPixmapData::OpenVGClass) {
- // The pixmap data is not an instance of QVGPixmapData, so fall
- // back to the default colorize filter implementation.
- QPixmapColorizeFilter::draw(painter, dest, src, srcRect);
- return;
- }
-
- QVGPixmapData *pd = static_cast<QVGPixmapData *>(src.pixmapData());
-
- VGImage srcImage = pd->toVGImage();
- if (srcImage == VG_INVALID_HANDLE)
- return;
-
- QSize size = pd->size();
- VGImage dstImage = QVGImagePool::instance()->createTemporaryImage
- (VG_sARGB_8888_PRE, size.width(), size.height(),
- VG_IMAGE_QUALITY_FASTER, pd);
- if (dstImage == VG_INVALID_HANDLE)
- return;
-
- // Determine the weights for the matrix from the color and strength.
- QColor c = color();
- VGfloat strength = this->strength();
- VGfloat weights[3];
- VGfloat invweights[3];
- VGfloat alpha = c.alphaF();
- weights[0] = c.redF() * alpha;
- weights[1] = c.greenF() * alpha;
- weights[2] = c.blueF() * alpha;
- invweights[0] = (1.0f - weights[0]) * strength;
- invweights[1] = (1.0f - weights[1]) * strength;
- invweights[2] = (1.0f - weights[2]) * strength;
-
- // Grayscale weights.
- static const VGfloat redGray = 11.0f / 32.0f;
- static const VGfloat greenGray = 16.0f / 32.0f;
- static const VGfloat blueGray = 1.0f - (redGray + greenGray);
-
- VGfloat matrix[5][4];
- matrix[0][0] = redGray * invweights[0] + (1.0f - strength);
- matrix[0][1] = redGray * invweights[1];
- matrix[0][2] = redGray * invweights[2];
- matrix[0][3] = 0.0f;
- matrix[1][0] = greenGray * invweights[0];
- matrix[1][1] = greenGray * invweights[1] + (1.0f - strength);
- matrix[1][2] = greenGray * invweights[2];
- matrix[1][3] = 0.0f;
- matrix[2][0] = blueGray * invweights[0];
- matrix[2][1] = blueGray * invweights[1];
- matrix[2][2] = blueGray * invweights[2] + (1.0f - strength);
- matrix[2][3] = 0.0f;
- matrix[3][0] = 0.0f;
- matrix[3][1] = 0.0f;
- matrix[3][2] = 0.0f;
- matrix[3][3] = 1.0f;
- matrix[4][0] = weights[0] * strength;
- matrix[4][1] = weights[1] * strength;
- matrix[4][2] = weights[2] * strength;
- matrix[4][3] = 0.0f;
-
- vgColorMatrix(dstImage, srcImage, matrix[0]);
-
- VGImage child = VG_INVALID_HANDLE;
-
- if (srcRect.isNull() ||
- (srcRect.topLeft().isNull() && srcRect.size() == size)) {
- child = dstImage;
- } else {
- QRect src = srcRect.toRect();
- child = vgChildImage(dstImage, src.x(), src.y(), src.width(), src.height());
- }
-
- qt_vg_drawVGImage(painter, dest, child);
-
- if(child != dstImage)
- vgDestroyImage(child);
- QVGImagePool::instance()->releaseImage(0, dstImage);
-}
-
-QVGPixmapDropShadowFilter::QVGPixmapDropShadowFilter()
- : QPixmapDropShadowFilter()
-{
-}
-
-QVGPixmapDropShadowFilter::~QVGPixmapDropShadowFilter()
-{
-}
-
-void QVGPixmapDropShadowFilter::draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect) const
-{
- if (src.isNull())
- return;
-
- if (src.pixmapData()->classId() != QPixmapData::OpenVGClass) {
- // The pixmap data is not an instance of QVGPixmapData, so fall
- // back to the default drop shadow filter implementation.
- QPixmapDropShadowFilter::draw(painter, dest, src, srcRect);
- return;
- }
-
- QVGPixmapData *pd = static_cast<QVGPixmapData *>(src.pixmapData());
-
- VGImage srcImage = pd->toVGImage();
- if (srcImage == VG_INVALID_HANDLE)
- return;
-
- QSize size = pd->size();
- VGImage dstImage = QVGImagePool::instance()->createTemporaryImage
- (VG_A_8, size.width(), size.height(),
- VG_IMAGE_QUALITY_FASTER, pd);
- if (dstImage == VG_INVALID_HANDLE)
- return;
-
- // Clamp the radius range. We divide by 2 because the OpenVG blur
- // is "too blurry" compared to the default raster implementation.
- VGfloat maxRadius = VGfloat(vgGeti(VG_MAX_GAUSSIAN_STD_DEVIATION));
- VGfloat radiusF = VGfloat(blurRadius()) / 2.0f;
- if (radiusF < 0.001f)
- radiusF = 0.001f;
- else if (radiusF > maxRadius)
- radiusF = maxRadius;
-
- // Blur the blackened source image.
- vgGaussianBlur(dstImage, srcImage, radiusF, radiusF, VG_TILE_PAD);
-
- VGImage child = VG_INVALID_HANDLE;
-
- QRect srect;
- if (srcRect.isNull() ||
- (srcRect.topLeft().isNull() && srcRect.size() == size)) {
- child = dstImage;
- srect = QRect(0, 0, size.width(), size.height());
- } else {
- srect = srcRect.toRect();
- child = vgChildImage(dstImage, srect.x(), srect.y(), srect.width(), srect.height());
- }
-
- qt_vg_drawVGImageStencil(painter, dest + offset(), child, color());
-
- if(child != dstImage)
- vgDestroyImage(child);
- QVGImagePool::instance()->releaseImage(0, dstImage);
-
- // Now draw the actual pixmap over the top.
- painter->drawPixmap(dest, src, srect);
-}
-
-QVGPixmapBlurFilter::QVGPixmapBlurFilter(QObject *parent)
- : QPixmapBlurFilter(parent)
-{
-}
-
-QVGPixmapBlurFilter::~QVGPixmapBlurFilter()
-{
-}
-
-void QVGPixmapBlurFilter::draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect) const
-{
- if (src.isNull())
- return;
-
- if (src.pixmapData()->classId() != QPixmapData::OpenVGClass) {
- // The pixmap data is not an instance of QVGPixmapData, so fall
- // back to the default blur filter implementation.
- QPixmapBlurFilter::draw(painter, dest, src, srcRect);
- return;
- }
-
- QVGPixmapData *pd = static_cast<QVGPixmapData *>(src.pixmapData());
-
- VGImage srcImage = pd->toVGImage();
- if (srcImage == VG_INVALID_HANDLE)
- return;
-
- QSize size = pd->size();
- VGImage dstImage = QVGImagePool::instance()->createTemporaryImage
- (VG_sARGB_8888_PRE, size.width(), size.height(),
- VG_IMAGE_QUALITY_FASTER, pd);
- if (dstImage == VG_INVALID_HANDLE)
- return;
-
- // Clamp the radius range. We divide by 2 because the OpenVG blur
- // is "too blurry" compared to the default raster implementation.
- VGfloat maxRadius = VGfloat(vgGeti(VG_MAX_GAUSSIAN_STD_DEVIATION));
- VGfloat radiusF = VGfloat(radius()) / 2.0f;
- if (radiusF < 0.001f)
- radiusF = 0.001f;
- else if (radiusF > maxRadius)
- radiusF = maxRadius;
-
- vgGaussianBlur(dstImage, srcImage, radiusF, radiusF, VG_TILE_PAD);
-
- VGImage child = VG_INVALID_HANDLE;
-
- if (srcRect.isNull() ||
- (srcRect.topLeft().isNull() && srcRect.size() == size)) {
- child = dstImage;
- } else {
- QRect src = srcRect.toRect();
- child = vgChildImage(dstImage, src.x(), src.y(), src.width(), src.height());
- }
-
- qt_vg_drawVGImage(painter, dest, child);
-
- if(child != dstImage)
- vgDestroyImage(child);
- QVGImagePool::instance()->releaseImage(0, dstImage);
-}
-
-#endif
-
-QT_END_NAMESPACE
diff --git a/src/openvg/qpixmapfilter_vg_p.h b/src/openvg/qpixmapfilter_vg_p.h
deleted file mode 100644
index 867f9a5c54..0000000000
--- a/src/openvg/qpixmapfilter_vg_p.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPIXMAPFILTER_VG_P_H
-#define QPIXMAPFILTER_VG_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qpixmapdata_vg_p.h"
-#include <QtGui/private/qpixmapfilter_p.h>
-#include <QtCore/qvarlengtharray.h>
-
-QT_BEGIN_NAMESPACE
-
-#if !defined(QT_SHIVAVG)
-
-class QVGPixmapConvolutionFilter : public QPixmapConvolutionFilter
-{
- Q_OBJECT
-public:
- QVGPixmapConvolutionFilter();
- ~QVGPixmapConvolutionFilter();
-
- void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect) const;
-};
-
-class QVGPixmapColorizeFilter : public QPixmapColorizeFilter
-{
- Q_OBJECT
-public:
- QVGPixmapColorizeFilter();
- ~QVGPixmapColorizeFilter();
-
- void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect) const;
-};
-
-class QVGPixmapDropShadowFilter : public QPixmapDropShadowFilter
-{
- Q_OBJECT
-public:
- QVGPixmapDropShadowFilter();
- ~QVGPixmapDropShadowFilter();
-
- void draw(QPainter *p, const QPointF &pos, const QPixmap &px, const QRectF &src) const;
-};
-
-class QVGPixmapBlurFilter : public QPixmapBlurFilter
-{
- Q_OBJECT
-public:
- QVGPixmapBlurFilter(QObject *parent = 0);
- ~QVGPixmapBlurFilter();
-
- void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect = QRectF()) const;
-};
-
-#endif
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/openvg/qvg.h b/src/openvg/qvg.h
deleted file mode 100644
index da2eb9674a..0000000000
--- a/src/openvg/qvg.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QVG_H
-#define QVG_H
-
-#include <QtCore/qglobal.h>
-
-// Include the OpenVG headers for use in applications that
-// issue raw OpenVG function calls.
-#if defined(QT_LOWER_CASE_VG_INCLUDES)
-#include <vg/openvg.h>
-#else
-#include <VG/openvg.h>
-#endif
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(OpenVG)
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif
diff --git a/src/openvg/qvg_p.h b/src/openvg/qvg_p.h
deleted file mode 100644
index cb03166011..0000000000
--- a/src/openvg/qvg_p.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QVG_P_H
-#define QVG_P_H
-
-#include "qvg.h"
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-// vgDrawGlyphs() only exists in OpenVG 1.1 and higher.
-#if !defined(OPENVG_VERSION_1_1) && !defined(QVG_NO_DRAW_GLYPHS)
-#define QVG_NO_DRAW_GLYPHS 1
-#endif
-
-#include <QtGui/qimage.h>
-
-#if !defined(QT_NO_EGL)
-#include <QtGui/private/qeglcontext_p.h>
-#endif
-
-QT_BEGIN_NAMESPACE
-
-class QVGPaintEngine;
-
-#if !defined(QT_NO_EGL)
-
-class QEglContext;
-
-// Create an EGL context, but don't bind it to a surface. If single-context
-// mode is enabled, this will return the previously-created context.
-// "devType" indicates the type of device using the context, usually
-// QInternal::Widget or QInternal::Pixmap.
-Q_OPENVG_EXPORT QEglContext *qt_vg_create_context
- (QPaintDevice *device, int devType);
-
-// Destroy an EGL context that was created by qt_vg_create_context().
-// If single-context mode is enabled, this will decrease the reference count.
-// "devType" indicates the type of device destroying the context, usually
-// QInternal::Widget or QInternal::Pixmap.
-Q_OPENVG_EXPORT void qt_vg_destroy_context
- (QEglContext *context, int devType);
-
-// Return the shared pbuffer surface that can be made current to
-// destroy VGImage objects when there is no other surface available.
-Q_OPENVG_EXPORT EGLSurface qt_vg_shared_surface(void);
-
-// Convert the configuration format in a context to a VG or QImage format.
-Q_OPENVG_EXPORT VGImageFormat qt_vg_config_to_vg_format(QEglContext *context);
-Q_OPENVG_EXPORT QImage::Format qt_vg_config_to_image_format(QEglContext *context);
-
-#endif
-
-// Create a paint engine. Returns the common engine in single-context mode.
-Q_OPENVG_EXPORT QVGPaintEngine *qt_vg_create_paint_engine(void);
-
-// Destroy a paint engine. Does nothing in single-context mode.
-Q_OPENVG_EXPORT void qt_vg_destroy_paint_engine(QVGPaintEngine *engine);
-
-// Convert between QImage and VGImage format values.
-Q_OPENVG_EXPORT VGImageFormat qt_vg_image_to_vg_format(QImage::Format format);
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/openvg/qvg_symbian.cpp b/src/openvg/qvg_symbian.cpp
deleted file mode 100644
index 0d2ed9e6d2..0000000000
--- a/src/openvg/qvg_symbian.cpp
+++ /dev/null
@@ -1,366 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtGui module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qpixmapdata_vg_p.h"
-#include "qvgfontglyphcache_p.h"
-#include <QtGui/private/qnativeimagehandleprovider_p.h>
-#include <private/qt_s60_p.h>
-
-#include <fbs.h>
-
-#ifdef QT_SYMBIAN_SUPPORTS_SGIMAGE
-# include <sgresource/sgimage.h>
-# ifdef SYMBIAN_FBSERV_GLYPHDATA // defined in fbs.h
-# define QT_SYMBIAN_HARDWARE_GLYPH_CACHE
-# include <graphics/fbsglyphdataiterator.h>
-# include <private/qfontengine_s60_p.h>
-# endif
-#endif
-
-QT_BEGIN_NAMESPACE
-
-typedef VGImage (*_vgCreateEGLImageTargetKHR)(VGeglImageKHR);
-static _vgCreateEGLImageTargetKHR qt_vgCreateEGLImageTargetKHR = 0;
-
-namespace QVG
-{
- VGImage vgCreateEGLImageTargetKHR(VGeglImageKHR eglImage);
-}
-
-VGImage QVG::vgCreateEGLImageTargetKHR(VGeglImageKHR eglImage)
-{
- if (!qt_vgCreateEGLImageTargetKHR && QEgl::hasExtension("EGL_KHR_image"))
- qt_vgCreateEGLImageTargetKHR = (_vgCreateEGLImageTargetKHR) eglGetProcAddress("vgCreateEGLImageTargetKHR");
-
- return qt_vgCreateEGLImageTargetKHR ? qt_vgCreateEGLImageTargetKHR(eglImage) : 0;
-}
-
-extern int qt_vg_pixmap_serial;
-
-#ifdef QT_SYMBIAN_SUPPORTS_SGIMAGE
-static VGImage sgImageToVGImage(QEglContext *context, const RSgImage &sgImage)
-{
- // when "0" used as argument then
- // default display, context are used
- if (!context)
- context = qt_vg_create_context(0, QInternal::Pixmap);
-
- VGImage vgImage = VG_INVALID_HANDLE;
-
- if (sgImage.IsNull())
- return vgImage;
-
- const EGLint KEglImageAttribs[] = {EGL_IMAGE_PRESERVED_SYMBIAN, EGL_TRUE, EGL_NONE};
- EGLImageKHR eglImage = QEgl::eglCreateImageKHR(QEgl::display(),
- EGL_NO_CONTEXT,
- EGL_NATIVE_PIXMAP_KHR,
- (EGLClientBuffer)&sgImage,
- (EGLint*)KEglImageAttribs);
-
- if (!eglImage)
- return vgImage;
-
- vgImage = QVG::vgCreateEGLImageTargetKHR(eglImage);
-
- QEgl::eglDestroyImageKHR(QEgl::display(), eglImage);
- return vgImage;
-}
-#endif
-
-void QVGPixmapData::cleanup()
-{
- is_null = w = h = 0;
- recreate = false;
- source = QVolatileImage();
-}
-
-bool QVGPixmapData::initFromNativeImageHandle(void *handle, const QString &type)
-{
- if (type == QLatin1String("RSgImage")) {
- fromNativeType(handle, QPixmapData::SgImage);
- return true;
- } else if (type == QLatin1String("CFbsBitmap")) {
- fromNativeType(handle, QPixmapData::FbsBitmap);
- return true;
- }
- return false;
-}
-
-void QVGPixmapData::createFromNativeImageHandleProvider()
-{
- void *handle = 0;
- QString type;
- nativeImageHandleProvider->get(&handle, &type);
- if (handle) {
- if (initFromNativeImageHandle(handle, type)) {
- nativeImageHandle = handle;
- nativeImageType = type;
- } else {
- qWarning("QVGPixmapData: Unknown native image type '%s'", qPrintable(type));
- }
- } else {
- qWarning("QVGPixmapData: Native handle is null");
- }
-}
-
-void QVGPixmapData::releaseNativeImageHandle()
-{
- if (nativeImageHandleProvider && nativeImageHandle) {
- nativeImageHandleProvider->release(nativeImageHandle, nativeImageType);
- nativeImageHandle = 0;
- nativeImageType = QString();
- }
-}
-
-static inline bool conversionLessFormat(QImage::Format format)
-{
- switch (format) {
- case QImage::Format_RGB16: // EColor64K
- case QImage::Format_RGB32: // EColor16MU
- case QImage::Format_ARGB32: // EColor16MA
- case QImage::Format_ARGB32_Premultiplied: // EColor16MAP
- case QImage::Format_Indexed8: // EGray256, EColor256
- return true;
- default:
- return false;
- }
-}
-
-void QVGPixmapData::fromNativeType(void* pixmap, NativeType type)
-{
- if (type == QPixmapData::SgImage && pixmap) {
-#if defined(QT_SYMBIAN_SUPPORTS_SGIMAGE) && !defined(QT_NO_EGL)
- RSgImage *sgImage = reinterpret_cast<RSgImage*>(pixmap);
- destroyImages();
- prevSize = QSize();
-
- vgImage = sgImageToVGImage(context, *sgImage);
- if (vgImage != VG_INVALID_HANDLE) {
- w = vgGetParameteri(vgImage, VG_IMAGE_WIDTH);
- h = vgGetParameteri(vgImage, VG_IMAGE_HEIGHT);
- d = 32; // We always use ARGB_Premultiplied for VG pixmaps.
- }
-
- is_null = (w <= 0 || h <= 0);
- source = QVolatileImage(); // readback will be done later, only when needed
- recreate = false;
- prevSize = QSize(w, h);
- updateSerial();
-#endif
- } else if (type == QPixmapData::FbsBitmap && pixmap) {
- CFbsBitmap *bitmap = reinterpret_cast<CFbsBitmap *>(pixmap);
- QSize size(bitmap->SizeInPixels().iWidth, bitmap->SizeInPixels().iHeight);
- resize(size.width(), size.height());
- source = QVolatileImage(bitmap); // duplicates only, if possible
- if (source.isNull())
- return;
- if (!conversionLessFormat(source.format())) {
- // Here we may need to copy if the formats do not match.
- // (e.g. for display modes other than EColor16MAP and EColor16MU)
- source.beginDataAccess();
- QImage::Format format = idealFormat(&source.imageRef(), Qt::AutoColor);
- source.endDataAccess(true);
- source.ensureFormat(format);
- }
- recreate = true;
- } else if (type == QPixmapData::VolatileImage && pixmap) {
- QVolatileImage *img = static_cast<QVolatileImage *>(pixmap);
- resize(img->width(), img->height());
- source = *img;
- recreate = true;
- } else if (type == QPixmapData::NativeImageHandleProvider && pixmap) {
- destroyImages();
- nativeImageHandleProvider = static_cast<QNativeImageHandleProvider *>(pixmap);
- // Cannot defer the retrieval, we need at least the size right away.
- createFromNativeImageHandleProvider();
- }
-}
-
-void* QVGPixmapData::toNativeType(NativeType type)
-{
- if (type == QPixmapData::SgImage) {
-#if defined(QT_SYMBIAN_SUPPORTS_SGIMAGE) && !defined(QT_NO_EGL)
- toVGImage();
-
- if (!isValid() || vgImage == VG_INVALID_HANDLE)
- return 0;
-
- TInt err = 0;
-
- RSgDriver driver;
- err = driver.Open();
- if (err != KErrNone)
- return 0;
-
- TSgImageInfo sgInfo;
- sgInfo.iPixelFormat = EUidPixelFormatARGB_8888_PRE;
- sgInfo.iSizeInPixels.SetSize(w, h);
- sgInfo.iUsage = ESgUsageBitOpenVgImage | ESgUsageBitOpenVgSurface;
-
- QScopedPointer<RSgImage> sgImage(new RSgImage());
- err = sgImage->Create(sgInfo, NULL, NULL);
- if (err != KErrNone) {
- driver.Close();
- return 0;
- }
-
- const EGLint KEglImageAttribs[] = {EGL_IMAGE_PRESERVED_SYMBIAN, EGL_TRUE, EGL_NONE};
- EGLImageKHR eglImage = QEgl::eglCreateImageKHR(QEgl::display(),
- EGL_NO_CONTEXT,
- EGL_NATIVE_PIXMAP_KHR,
- (EGLClientBuffer)sgImage.data(),
- (EGLint*)KEglImageAttribs);
- if (!eglImage || eglGetError() != EGL_SUCCESS) {
- sgImage->Close();
- driver.Close();
- return 0;
- }
-
- VGImage dstVgImage = QVG::vgCreateEGLImageTargetKHR(eglImage);
- if (!dstVgImage || vgGetError() != VG_NO_ERROR) {
- QEgl::eglDestroyImageKHR(QEgl::display(), eglImage);
- sgImage->Close();
- driver.Close();
- return 0;
- }
-
- vgCopyImage(dstVgImage, 0, 0,
- vgImage, 0, 0,
- w, h, VG_FALSE);
-
- if (vgGetError() != VG_NO_ERROR) {
- sgImage->Close();
- sgImage.reset();
- }
-
- // release stuff
- vgDestroyImage(dstVgImage);
- QEgl::eglDestroyImageKHR(QEgl::display(), eglImage);
- driver.Close();
- return reinterpret_cast<void*>(sgImage.take());
-#endif
- } else if (type == QPixmapData::FbsBitmap && isValid()) {
- ensureReadback(true);
- if (source.isNull()) {
- source = QVolatileImage(w, h, sourceFormat());
- }
- // Just duplicate the bitmap handle, no data copying happens.
- return source.duplicateNativeImage();
- }
- return 0;
-}
-
-QSymbianVGFontGlyphCache::QSymbianVGFontGlyphCache() : QVGFontGlyphCache()
-{
-#ifdef QT_SYMBIAN_HARDWARE_GLYPH_CACHE
- invertedGlyphs = true;
-#endif
-}
-
-void QSymbianVGFontGlyphCache::cacheGlyphs(QVGPaintEnginePrivate *d,
- QFontEngine *fontEngine,
- const glyph_t *g, int count)
-{
-#ifdef QT_SYMBIAN_HARDWARE_GLYPH_CACHE
- QFontEngineS60 *s60fontEngine = static_cast<QFontEngineS60*>(fontEngine);
- if (s60fontEngine->m_activeFont->TypeUid() != KCFbsFontUid)
- return QVGFontGlyphCache::cacheGlyphs(d, fontEngine, g, count);
-
- QVector<glyph_t> uncachedGlyphs;
- while (count-- > 0) {
- // Skip this glyph if we have already cached it before.
- glyph_t glyph = *g++;
- if (((glyph < 256) && ((cachedGlyphsMask[glyph / 32] & (1 << (glyph % 32))) != 0))
- || cachedGlyphs.contains(glyph))
- continue;
- if (!uncachedGlyphs.contains(glyph))
- uncachedGlyphs.append(glyph);
- }
-
- if (!uncachedGlyphs.isEmpty()) {
- CFbsFont *cfbsFont = static_cast<CFbsFont *>(s60fontEngine->m_activeFont);
- RFbsGlyphDataIterator iter;
-
- int err = iter.Open(*cfbsFont, (const unsigned int*)uncachedGlyphs.constData(), uncachedGlyphs.count());
-
- if (err == KErrNotSupported || err == KErrInUse) { // Fallback in possibly supported error cases
- iter.Close();
- qWarning("Falling back to default QVGFontGlyphCache");
- return QVGFontGlyphCache::cacheGlyphs(d, fontEngine, g, count);
- }
-
- for (; err == KErrNone; err = iter.Next()) {
- const unsigned int glyph = iter.GlyphCode();
-
- const RSgImage& image = iter.Image();
- const TOpenFontCharMetrics& metrics = iter.Metrics();
-
- TRect glyphBounds;
- metrics.GetHorizBounds(glyphBounds);
- VGImage vgImage = sgImageToVGImage(0, image);
- VGfloat origin[2];
- VGfloat escapement[2];
- origin[0] = -glyphBounds.iTl.iX;
- origin[1] = glyphBounds.iBr.iY;
- escapement[0] = 0;
- escapement[1] = 0;
- vgSetGlyphToImage(font, glyph, vgImage, origin, escapement);
- vgDestroyImage(vgImage);
-
- // Add to cache
- if (glyph < 256)
- cachedGlyphsMask[glyph / 32] |= (1 << (glyph % 32));
- else
- cachedGlyphs.insert(glyph);
- }
- iter.Close();
-
- if (err == KErrNoMemory || err == KErrNoGraphicsMemory)
- qWarning("Not enough memory to cache glyph");
- else if (err != KErrNotFound)
- qWarning("Received error %d from glyph cache", err);
- }
-#else
- QVGFontGlyphCache::cacheGlyphs(d, fontEngine, g, count);
-#endif
-}
-
-QT_END_NAMESPACE
diff --git a/src/openvg/qvgcompositionhelper_p.h b/src/openvg/qvgcompositionhelper_p.h
deleted file mode 100644
index c3a8bed6a5..0000000000
--- a/src/openvg/qvgcompositionhelper_p.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QVGCOMPOSITIONHELPER_H
-#define QVGCOMPOSITIONHELPER_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qwindowsurface_vgegl_p.h"
-
-QT_BEGIN_NAMESPACE
-
-#if !defined(QVG_NO_SINGLE_CONTEXT) && !defined(QT_NO_EGL)
-
-class QVGPaintEnginePrivate;
-class QVGEGLWindowSurfacePrivate;
-
-class Q_OPENVG_EXPORT QVGCompositionHelper
-{
-public:
- QVGCompositionHelper();
- virtual ~QVGCompositionHelper();
-
- void startCompositing(const QSize& screenSize);
- void endCompositing();
-
- void blitWindow(VGImage image, const QSize& imageSize,
- const QRect& rect, const QPoint& topLeft, int opacity);
- void fillBackground(const QRegion& region, const QBrush& brush);
- void drawCursorPixmap(const QPixmap& pixmap, const QPoint& offset);
- void setScissor(const QRegion& region);
- void clearScissor();
-
-private:
- QVGPaintEnginePrivate *d;
- QSize screenSize;
-};
-
-#endif
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/openvg/qvgfontglyphcache_p.h b/src/openvg/qvgfontglyphcache_p.h
deleted file mode 100644
index ce12301645..0000000000
--- a/src/openvg/qvgfontglyphcache_p.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QVGFONTGLYPHCACHE_H
-#define QVGFONTGLYPHCACHE_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qvarlengtharray.h>
-#include <QtGui/private/qfontengine_p.h>
-
-#include "qvg_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QVGPaintEnginePrivate;
-
-#ifndef QVG_NO_DRAW_GLYPHS
-
-class QVGFontGlyphCache
-{
-public:
- QVGFontGlyphCache();
- virtual ~QVGFontGlyphCache();
-
- virtual void cacheGlyphs(QVGPaintEnginePrivate *d,
- QFontEngine *fontEngine,
- const glyph_t *g, int count);
- void setScaleFromText(const QFont &font, QFontEngine *fontEngine);
-
- VGFont font;
- VGfloat scaleX;
- VGfloat scaleY;
- bool invertedGlyphs;
- uint cachedGlyphsMask[256 / 32];
- QSet<glyph_t> cachedGlyphs;
-};
-
-#if defined(Q_OS_SYMBIAN)
-class QSymbianVGFontGlyphCache : public QVGFontGlyphCache
-{
-public:
- QSymbianVGFontGlyphCache();
- void cacheGlyphs(QVGPaintEnginePrivate *d,
- QFontEngine *fontEngine,
- const glyph_t *g, int count);
-};
-#endif
-
-#endif
-
-QT_END_NAMESPACE
-
-#endif // QVGFONTGLYPHCACHE_H
diff --git a/src/openvg/qvgimagepool.cpp b/src/openvg/qvgimagepool.cpp
deleted file mode 100644
index 7a7ec78fe3..0000000000
--- a/src/openvg/qvgimagepool.cpp
+++ /dev/null
@@ -1,233 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qvgimagepool_p.h"
-#include "qpixmapdata_vg_p.h"
-
-QT_BEGIN_NAMESPACE
-
-static QVGImagePool *qt_vg_image_pool = 0;
-
-class QVGImagePoolPrivate
-{
-public:
- QVGImagePoolPrivate() : lruFirst(0), lruLast(0) {}
-
- QVGPixmapData *lruFirst;
- QVGPixmapData *lruLast;
-};
-
-QVGImagePool::QVGImagePool()
- : d_ptr(new QVGImagePoolPrivate())
-{
-}
-
-QVGImagePool::~QVGImagePool()
-{
-}
-
-QVGImagePool *QVGImagePool::instance()
-{
- if (!qt_vg_image_pool)
- qt_vg_image_pool = new QVGImagePool();
- return qt_vg_image_pool;
-}
-
-void QVGImagePool::setImagePool(QVGImagePool *pool)
-{
- if (qt_vg_image_pool != pool)
- delete qt_vg_image_pool;
- qt_vg_image_pool = pool;
-}
-
-VGImage QVGImagePool::createTemporaryImage(VGImageFormat format,
- VGint width, VGint height,
- VGbitfield allowedQuality,
- QVGPixmapData *keepData)
-{
- VGImage image;
- do {
- image = vgCreateImage(format, width, height, allowedQuality);
- if (image != VG_INVALID_HANDLE)
- return image;
- } while (reclaimSpace(format, width, height, keepData));
- qWarning("QVGImagePool: cannot reclaim sufficient space for a %dx%d temporary image",
- width, height);
- return VG_INVALID_HANDLE;
-}
-
-VGImage QVGImagePool::createImageForPixmap(VGImageFormat format,
- VGint width, VGint height,
- VGbitfield allowedQuality,
- QVGPixmapData *data)
-{
- VGImage image;
- do {
- image = vgCreateImage(format, width, height, allowedQuality);
- if (image != VG_INVALID_HANDLE) {
- if (data)
- moveToHeadOfLRU(data);
- return image;
- }
- } while (reclaimSpace(format, width, height, data));
- qWarning("QVGImagePool: cannot reclaim sufficient space for a %dx%d pixmap",
- width, height);
- return VG_INVALID_HANDLE;
-}
-
-VGImage QVGImagePool::createPermanentImage(VGImageFormat format,
- VGint width, VGint height,
- VGbitfield allowedQuality)
-{
- VGImage image;
- do {
- image = vgCreateImage(format, width, height, allowedQuality);
- if (image != VG_INVALID_HANDLE)
- return image;
- } while (reclaimSpace(format, width, height, 0));
- qWarning("QVGImagePool: cannot reclaim sufficient space for a %dx%d image",
- width, height);
- return VG_INVALID_HANDLE;
-}
-
-void QVGImagePool::releaseImage(QVGPixmapData *data, VGImage image)
-{
- // Very simple strategy at the moment: just destroy the image.
- if (data)
- removeFromLRU(data);
- vgDestroyImage(image);
-}
-
-void QVGImagePool::useImage(QVGPixmapData *data)
-{
- moveToHeadOfLRU(data);
-}
-
-void QVGImagePool::detachImage(QVGPixmapData *data)
-{
- removeFromLRU(data);
-}
-
-bool QVGImagePool::reclaimSpace(VGImageFormat format,
- VGint width, VGint height,
- QVGPixmapData *data)
-{
- Q_UNUSED(format); // For future use in picking the best image to eject.
- Q_UNUSED(width);
- Q_UNUSED(height);
-
- bool succeeded = false;
- bool wasInLRU = false;
- if (data) {
- wasInLRU = data->inLRU;
- moveToHeadOfLRU(data);
- }
-
- QVGPixmapData *lrudata = pixmapLRU();
- if (lrudata && lrudata != data) {
- lrudata->reclaimImages();
- succeeded = true;
- }
-
- if (data && !wasInLRU)
- removeFromLRU(data);
-
- return succeeded;
-}
-
-void QVGImagePool::hibernate()
-{
- Q_D(QVGImagePool);
- QVGPixmapData *pd = d->lruLast;
- while (pd) {
- QVGPixmapData *prevLRU = pd->prevLRU;
- pd->inImagePool = false;
- pd->inLRU = false;
- pd->nextLRU = 0;
- pd->prevLRU = 0;
- pd->hibernate();
- pd = prevLRU;
- }
- d->lruFirst = 0;
- d->lruLast = 0;
-}
-
-void QVGImagePool::moveToHeadOfLRU(QVGPixmapData *data)
-{
- Q_D(QVGImagePool);
- if (data->inLRU) {
- if (!data->prevLRU)
- return; // Already at the head of the list.
- removeFromLRU(data);
- }
- data->inLRU = true;
- data->nextLRU = d->lruFirst;
- data->prevLRU = 0;
- if (d->lruFirst)
- d->lruFirst->prevLRU = data;
- else
- d->lruLast = data;
- d->lruFirst = data;
-}
-
-void QVGImagePool::removeFromLRU(QVGPixmapData *data)
-{
- Q_D(QVGImagePool);
- if (!data->inLRU)
- return;
- if (data->nextLRU)
- data->nextLRU->prevLRU = data->prevLRU;
- else
- d->lruLast = data->prevLRU;
- if (data->prevLRU)
- data->prevLRU->nextLRU = data->nextLRU;
- else
- d->lruFirst = data->nextLRU;
- data->inLRU = false;
-}
-
-QVGPixmapData *QVGImagePool::pixmapLRU()
-{
- Q_D(QVGImagePool);
- return d->lruLast;
-}
-
-QT_END_NAMESPACE
diff --git a/src/openvg/qvgimagepool_p.h b/src/openvg/qvgimagepool_p.h
deleted file mode 100644
index 3510cfab26..0000000000
--- a/src/openvg/qvgimagepool_p.h
+++ /dev/null
@@ -1,157 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QVGIMAGEPOOL_P_H
-#define QVGIMAGEPOOL_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qvg.h"
-#include <QtCore/qscopedpointer.h>
-
-QT_BEGIN_NAMESPACE
-
-class QVGPixmapData;
-class QVGImagePoolPrivate;
-
-class Q_OPENVG_EXPORT QVGImagePool
-{
-public:
- QVGImagePool();
- virtual ~QVGImagePool();
-
- static QVGImagePool *instance();
-
- // This function can be used from system-specific graphics system
- // plugins to alter the image allocation strategy.
- static void setImagePool(QVGImagePool *pool);
-
- // Create a new VGImage from the pool with the specified parameters
- // that is not associated with a pixmap. The VGImage is returned to
- // the pool when releaseImage() is called.
- //
- // This function will call reclaimSpace() when vgCreateImage() fails.
- //
- // This function is typically called when allocating temporary
- // VGImage's for pixmap filters. The "keepData" object will not
- // be reclaimed if reclaimSpace() needs to be called.
- virtual VGImage createTemporaryImage(VGImageFormat format,
- VGint width, VGint height,
- VGbitfield allowedQuality,
- QVGPixmapData *keepData = 0);
-
- // Create a new VGImage with the specified parameters and associate
- // it with "data". The QVGPixmapData will be notified when the
- // VGImage needs to be reclaimed by the pool.
- //
- // This function will call reclaimSpace() when vgCreateImage() fails.
- virtual VGImage createImageForPixmap(VGImageFormat format,
- VGint width, VGint height,
- VGbitfield allowedQuality,
- QVGPixmapData *data);
-
- // Create a permanent VGImage with the specified parameters.
- // If there is insufficient space for the vgCreateImage call,
- // then this function will call reclaimSpace() and try again.
- //
- // The caller is responsible for calling vgDestroyImage()
- // when it no longer needs the VGImage, as the image is not
- // recorded in the image pool.
- //
- // This function is typically used for pattern brushes where
- // the OpenVG engine is responsible for managing the lifetime
- // of the VGImage, destroying it automatically when the brush
- // is no longer in use.
- virtual VGImage createPermanentImage(VGImageFormat format,
- VGint width, VGint height,
- VGbitfield allowedQuality);
-
- // Release a VGImage that is no longer required.
- virtual void releaseImage(QVGPixmapData *data, VGImage image);
-
- // Notify the pool that a QVGPixmapData object is using
- // an image again. This allows the pool to move the image
- // within a least-recently-used list of QVGPixmapData objects.
- virtual void useImage(QVGPixmapData *data);
-
- // Notify the pool that the VGImage's associated with a
- // QVGPixmapData are being detached from the pool. The caller
- // will become responsible for calling vgDestroyImage().
- virtual void detachImage(QVGPixmapData *data);
-
- // Reclaim space for an image allocation with the specified parameters.
- // Returns true if space was reclaimed, or false if there is no
- // further space that can be reclaimed. The "data" parameter
- // indicates the pixmap that is trying to obtain space which should
- // not itself be reclaimed.
- virtual bool reclaimSpace(VGImageFormat format,
- VGint width, VGint height,
- QVGPixmapData *data);
-
- // Hibernate the image pool because the context is about to be
- // destroyed. All VGImage's left in the pool should be released.
- virtual void hibernate();
-
-protected:
- // Helper functions for managing the LRU list of QVGPixmapData objects.
- void moveToHeadOfLRU(QVGPixmapData *data);
- void removeFromLRU(QVGPixmapData *data);
- QVGPixmapData *pixmapLRU();
-
-private:
- QScopedPointer<QVGImagePoolPrivate> d_ptr;
-
- Q_DECLARE_PRIVATE(QVGImagePool)
- Q_DISABLE_COPY(QVGImagePool)
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/openvg/qwindowsurface_vg.cpp b/src/openvg/qwindowsurface_vg.cpp
deleted file mode 100644
index dcc5d6a6d6..0000000000
--- a/src/openvg/qwindowsurface_vg.cpp
+++ /dev/null
@@ -1,148 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwindowsurface_vg_p.h"
-#include "qwindowsurface_vgegl_p.h"
-#include "qpaintengine_vg_p.h"
-#include "qpixmapdata_vg_p.h"
-#include "qvg_p.h"
-
-#if !defined(QT_NO_EGL)
-
-#include <QtGui/private/qeglcontext_p.h>
-#include <QtGui/private/qwidget_p.h>
-
-QT_BEGIN_NAMESPACE
-
-QVGWindowSurface::QVGWindowSurface(QWidget *window)
- : QWindowSurface(window)
-{
- // Create the default type of EGL window surface for windows.
- d_ptr = new QVGEGLWindowSurfaceDirect(this);
-}
-
-QVGWindowSurface::QVGWindowSurface
- (QWidget *window, QVGEGLWindowSurfacePrivate *d)
- : QWindowSurface(window), d_ptr(d)
-{
-}
-
-QVGWindowSurface::~QVGWindowSurface()
-{
- delete d_ptr;
-}
-
-QPaintDevice *QVGWindowSurface::paintDevice()
-{
- return this;
-}
-
-void QVGWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
-{
- Q_UNUSED(offset);
-
-#ifdef Q_OS_SYMBIAN
- if (window() != widget) {
- // For performance reasons we don't support
- // flushing native child widgets on Symbian.
- // It breaks overlapping native child widget
- // rendering in some cases but we prefer performance.
- return;
- }
-#endif
-
- QWidget *parent = widget->internalWinId() ? widget : widget->nativeParentWidget();
- d_ptr->endPaint(parent, region);
-}
-
-void QVGWindowSurface::setGeometry(const QRect &rect)
-{
- QWindowSurface::setGeometry(rect);
-}
-
-bool QVGWindowSurface::scroll(const QRegion &area, int dx, int dy)
-{
- if (!d_ptr->scroll(window(), area, dx, dy))
- return QWindowSurface::scroll(area, dx, dy);
- return true;
-}
-
-void QVGWindowSurface::beginPaint(const QRegion &region)
-{
- d_ptr->beginPaint(window());
-
- // If the window is not opaque, then fill the region we are about
- // to paint with the transparent color.
- if (!qt_widget_private(window())->isOpaque &&
- window()->testAttribute(Qt::WA_TranslucentBackground)) {
- QVGPaintEngine *engine = static_cast<QVGPaintEngine *>
- (d_ptr->paintEngine());
- engine->fillRegion(region, Qt::transparent, d_ptr->surfaceSize());
- }
-}
-
-void QVGWindowSurface::endPaint(const QRegion &region)
-{
- // Nothing to do here.
- Q_UNUSED(region);
-}
-
-QPaintEngine *QVGWindowSurface::paintEngine() const
-{
- return d_ptr->paintEngine();
-}
-
-QWindowSurface::WindowSurfaceFeatures QVGWindowSurface::features() const
-{
- WindowSurfaceFeatures features = PartialUpdates | PreservedContents;
- if (d_ptr->supportsStaticContents())
- features |= StaticContents;
- return features;
-}
-
-int QVGWindowSurface::metric(PaintDeviceMetric met) const
-{
- return qt_paint_device_metric(window(), met);
-}
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/openvg/qwindowsurface_vg_p.h b/src/openvg/qwindowsurface_vg_p.h
deleted file mode 100644
index d63d077237..0000000000
--- a/src/openvg/qwindowsurface_vg_p.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSURFACE_VG_P_H
-#define QWINDOWSURFACE_VG_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtGui/private/qwindowsurface_p.h>
-
-QT_BEGIN_NAMESPACE
-
-#if !defined(QT_NO_EGL)
-
-class QVGEGLWindowSurfacePrivate;
-
-class Q_OPENVG_EXPORT QVGWindowSurface : public QWindowSurface, public QPaintDevice
-{
-public:
- QVGWindowSurface(QWidget *window);
- QVGWindowSurface(QWidget *window, QVGEGLWindowSurfacePrivate *d);
- ~QVGWindowSurface();
-
- QPaintDevice *paintDevice();
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
- void setGeometry(const QRect &rect);
- bool scroll(const QRegion &area, int dx, int dy);
-
- void beginPaint(const QRegion &region);
- void endPaint(const QRegion &region);
-
- QPaintEngine *paintEngine() const;
-
- WindowSurfaceFeatures features() const;
-
-protected:
- int metric(PaintDeviceMetric metric) const;
-
-private:
- QVGEGLWindowSurfacePrivate *d_ptr;
-};
-
-#endif
-
-QT_END_NAMESPACE
-
-#endif // QWINDOWSURFACE_VG_P_H
diff --git a/src/openvg/qwindowsurface_vgegl.cpp b/src/openvg/qwindowsurface_vgegl.cpp
deleted file mode 100644
index 3205a1104b..0000000000
--- a/src/openvg/qwindowsurface_vgegl.cpp
+++ /dev/null
@@ -1,783 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwindowsurface_vgegl_p.h"
-#include "qpaintengine_vg_p.h"
-#include "qpixmapdata_vg_p.h"
-#include "qvgimagepool_p.h"
-#include "qvg_p.h"
-
-#if !defined(QT_NO_EGL)
-
-QT_BEGIN_NAMESPACE
-
-// Turn off "direct to window" rendering if EGL cannot support it.
-#if !defined(EGL_RENDER_BUFFER) || !defined(EGL_SINGLE_BUFFER)
-#if defined(QVG_DIRECT_TO_WINDOW)
-#undef QVG_DIRECT_TO_WINDOW
-#endif
-#endif
-
-// Determine if preserved window contents should be used.
-#if !defined(EGL_SWAP_BEHAVIOR) || !defined(EGL_BUFFER_PRESERVED)
-#if !defined(QVG_NO_PRESERVED_SWAP)
-#define QVG_NO_PRESERVED_SWAP 1
-#endif
-#endif
-
-VGImageFormat qt_vg_config_to_vg_format(QEglContext *context)
-{
- return qt_vg_image_to_vg_format
- (qt_vg_config_to_image_format(context));
-}
-
-QImage::Format qt_vg_config_to_image_format(QEglContext *context)
-{
- EGLint red = context->configAttrib(EGL_RED_SIZE);
- EGLint green = context->configAttrib(EGL_GREEN_SIZE);
- EGLint blue = context->configAttrib(EGL_BLUE_SIZE);
- EGLint alpha = context->configAttrib(EGL_ALPHA_SIZE);
- QImage::Format argbFormat;
-#ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT
- EGLint type = context->configAttrib(EGL_SURFACE_TYPE);
- if ((type & EGL_VG_ALPHA_FORMAT_PRE_BIT) != 0)
- argbFormat = QImage::Format_ARGB32_Premultiplied;
- else
- argbFormat = QImage::Format_ARGB32;
-#else
- argbFormat = QImage::Format_ARGB32;
-#endif
- if (red == 8 && green == 8 && blue == 8 && alpha == 8)
- return argbFormat;
- else if (red == 8 && green == 8 && blue == 8 && alpha == 0)
- return QImage::Format_RGB32;
- else if (red == 5 && green == 6 && blue == 5 && alpha == 0)
- return QImage::Format_RGB16;
- else if (red == 4 && green == 4 && blue == 4 && alpha == 4)
- return QImage::Format_ARGB4444_Premultiplied;
- else
- return argbFormat; // XXX
-}
-
-#if !defined(QVG_NO_SINGLE_CONTEXT)
-
-class QVGSharedContext
-{
-public:
- QVGSharedContext();
- ~QVGSharedContext();
-
- QEglContext *context;
- int refCount;
- int widgetRefCount;
- QVGPaintEngine *engine;
- EGLSurface surface;
- QVGPixmapData *firstPixmap;
-};
-
-QVGSharedContext::QVGSharedContext()
- : context(0)
- , refCount(0)
- , widgetRefCount(0)
- , engine(0)
- , surface(EGL_NO_SURFACE)
- , firstPixmap(0)
-{
-}
-
-QVGSharedContext::~QVGSharedContext()
-{
- // Don't accidentally destroy the QEglContext if the reference
- // count falls to zero while deleting the paint engine.
- ++refCount;
-
- if (context)
- context->makeCurrent(qt_vg_shared_surface());
- delete engine;
- if (context)
- context->doneCurrent();
- if (context && surface != EGL_NO_SURFACE)
- context->destroySurface(surface);
- delete context;
-}
-
-Q_GLOBAL_STATIC(QVGSharedContext, sharedContext);
-
-QVGPaintEngine *qt_vg_create_paint_engine(void)
-{
- QVGSharedContext *shared = sharedContext();
- if (!shared->engine)
- shared->engine = new QVGPaintEngine();
- return shared->engine;
-}
-
-void qt_vg_destroy_paint_engine(QVGPaintEngine *engine)
-{
- Q_UNUSED(engine);
-}
-
-void qt_vg_register_pixmap(QVGPixmapData *pd)
-{
- QVGSharedContext *shared = sharedContext();
- pd->next = shared->firstPixmap;
- pd->prev = 0;
- if (shared->firstPixmap)
- shared->firstPixmap->prev = pd;
- shared->firstPixmap = pd;
-}
-
-void qt_vg_unregister_pixmap(QVGPixmapData *pd)
-{
- if (pd->next)
- pd->next->prev = pd->prev;
- if (pd->prev) {
- pd->prev->next = pd->next;
- } else {
- QVGSharedContext *shared = sharedContext();
- if (shared)
- shared->firstPixmap = pd->next;
- }
-}
-
-#else
-
-QVGPaintEngine *qt_vg_create_paint_engine(void)
-{
- return new QVGPaintEngine();
-}
-
-void qt_vg_destroy_paint_engine(QVGPaintEngine *engine)
-{
- delete engine;
-}
-
-void qt_vg_register_pixmap(QVGPixmapData *pd)
-{
- Q_UNUSED(pd);
-}
-
-void qt_vg_unregister_pixmap(QVGPixmapData *pd)
-{
- Q_UNUSED(pd);
-}
-
-#endif
-
-#ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT
-
-static bool isPremultipliedContext(const QEglContext *context)
-{
- return context->configAttrib(EGL_SURFACE_TYPE) & EGL_VG_ALPHA_FORMAT_PRE_BIT;
-}
-
-#endif
-
-static QEglContext *createContext(QPaintDevice *device)
-{
- QEglContext *context;
-
- // Create the context object and open the display.
- context = new QEglContext();
- context->setApi(QEgl::OpenVG);
-
- // Set the swap interval for the display.
- QByteArray interval = qgetenv("QT_VG_SWAP_INTERVAL");
- if (!interval.isEmpty())
- eglSwapInterval(QEgl::display(), interval.toInt());
- else
- eglSwapInterval(QEgl::display(), 1);
-
-#ifdef EGL_RENDERABLE_TYPE
- // Has the user specified an explicit EGL configuration to use?
- QByteArray configId = qgetenv("QT_VG_EGL_CONFIG");
- if (!configId.isEmpty()) {
- EGLint cfgId = configId.toInt();
- EGLint properties[] = {
- EGL_CONFIG_ID, cfgId,
- EGL_NONE
- };
- EGLint matching = 0;
- EGLConfig cfg;
- if (eglChooseConfig
- (QEgl::display(), properties, &cfg, 1, &matching) &&
- matching > 0) {
- // Check that the selected configuration actually supports OpenVG
- // and then create the context with it.
- EGLint id = 0;
- EGLint type = 0;
- eglGetConfigAttrib
- (QEgl::display(), cfg, EGL_CONFIG_ID, &id);
- eglGetConfigAttrib
- (QEgl::display(), cfg, EGL_RENDERABLE_TYPE, &type);
- if (cfgId == id && (type & EGL_OPENVG_BIT) != 0) {
- context->setConfig(cfg);
- if (!context->createContext()) {
- delete context;
- return 0;
- }
- return context;
- } else {
- qWarning("QT_VG_EGL_CONFIG: %d is not a valid OpenVG configuration", int(cfgId));
- }
- }
- }
-#endif
-
- // Choose an appropriate configuration for rendering into the device.
- QEglProperties configProps;
- configProps.setPaintDeviceFormat(device);
- int redSize = configProps.value(EGL_RED_SIZE);
- if (redSize == EGL_DONT_CARE || redSize == 0)
- configProps.setPixelFormat(QImage::Format_ARGB32); // XXX
- configProps.setValue(EGL_ALPHA_MASK_SIZE, 1);
-#ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT
- configProps.setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT
- | EGL_SWAP_BEHAVIOR_PRESERVED_BIT
- | EGL_VG_ALPHA_FORMAT_PRE_BIT);
- configProps.setRenderableType(QEgl::OpenVG);
- if (!context->chooseConfig(configProps)) {
- // Try again without the "pre" bit.
- configProps.setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT);
- if (!context->chooseConfig(configProps)) {
- delete context;
- return 0;
- }
- }
-#else
- configProps.setValue(EGL_SURFACE_TYPE, EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT);
- configProps.setRenderableType(QEgl::OpenVG);
- if (!context->chooseConfig(configProps)) {
- delete context;
- return 0;
- }
-#endif
-
- // Construct a new EGL context for the selected configuration.
- if (!context->createContext()) {
- delete context;
- return 0;
- }
-
- return context;
-}
-
-#if !defined(QVG_NO_SINGLE_CONTEXT)
-
-QEglContext *qt_vg_create_context(QPaintDevice *device, int devType)
-{
- QVGSharedContext *shared = sharedContext();
- if (devType == QInternal::Widget)
- ++(shared->widgetRefCount);
- if (shared->context) {
- ++(shared->refCount);
- return shared->context;
- } else {
- shared->context = createContext(device);
- shared->refCount = 1;
- return shared->context;
- }
-}
-
-static void qt_vg_destroy_shared_context(QVGSharedContext *shared)
-{
- shared->context->makeCurrent(qt_vg_shared_surface());
- delete shared->engine;
- shared->engine = 0;
- shared->context->doneCurrent();
- if (shared->surface != EGL_NO_SURFACE) {
- eglDestroySurface(QEgl::display(), shared->surface);
- shared->surface = EGL_NO_SURFACE;
- }
- delete shared->context;
- shared->context = 0;
-}
-
-void qt_vg_hibernate_pixmaps(QVGSharedContext *shared)
-{
- // Artificially increase the reference count to prevent the
- // context from being destroyed until after we have finished
- // the hibernation process.
- ++(shared->refCount);
-
- // We need a context current to hibernate the VGImage objects.
- shared->context->makeCurrent(qt_vg_shared_surface());
-
- // Scan all QVGPixmapData objects in the system and hibernate them.
- QVGPixmapData *pd = shared->firstPixmap;
- while (pd != 0) {
- pd->hibernate();
- pd = pd->next;
- }
-
- // Hibernate any remaining VGImage's in the image pool.
- QVGImagePool::instance()->hibernate();
-
- // Don't need the current context any more.
- shared->context->lazyDoneCurrent();
-
- // Decrease the reference count and destroy the context if necessary.
- if (--(shared->refCount) <= 0)
- qt_vg_destroy_shared_context(shared);
-}
-
-void qt_vg_destroy_context(QEglContext *context, int devType)
-{
- QVGSharedContext *shared = sharedContext();
- if (shared->context != context) {
- // This is not the shared context. Shouldn't happen!
- delete context;
- return;
- }
- if (devType == QInternal::Widget)
- --(shared->widgetRefCount);
- if (--(shared->refCount) <= 0) {
- qt_vg_destroy_shared_context(shared);
- } else if (shared->widgetRefCount <= 0 && devType == QInternal::Widget) {
- // All of the widget window surfaces have been destroyed
- // but we still have VG pixmaps active. Ask them to hibernate
- // to free up GPU resources until a widget is shown again.
- // This may eventually cause the EGLContext to be destroyed
- // because nothing in the system needs a context, which will
- // free up even more GPU resources.
- qt_vg_hibernate_pixmaps(shared);
- }
-}
-
-EGLSurface qt_vg_shared_surface(void)
-{
- QVGSharedContext *shared = sharedContext();
- if (shared->surface == EGL_NO_SURFACE) {
- EGLint attribs[7];
- attribs[0] = EGL_WIDTH;
- attribs[1] = 16;
- attribs[2] = EGL_HEIGHT;
- attribs[3] = 16;
-#ifdef EGL_VG_ALPHA_FORMAT_PRE_BIT
- if (isPremultipliedContext(shared->context)) {
- attribs[4] = EGL_VG_ALPHA_FORMAT;
- attribs[5] = EGL_VG_ALPHA_FORMAT_PRE;
- attribs[6] = EGL_NONE;
- } else
-#endif
- {
- attribs[4] = EGL_NONE;
- }
- shared->surface = eglCreatePbufferSurface
- (QEgl::display(), shared->context->config(), attribs);
- }
- return shared->surface;
-}
-
-#else
-
-QEglContext *qt_vg_create_context(QPaintDevice *device, int devType)
-{
- Q_UNUSED(devType);
- return createContext(device);
-}
-
-void qt_vg_destroy_context(QEglContext *context, int devType)
-{
- Q_UNUSED(devType);
- delete context;
-}
-
-EGLSurface qt_vg_shared_surface(void)
-{
- return EGL_NO_SURFACE;
-}
-
-#endif
-
-QVGEGLWindowSurfacePrivate::QVGEGLWindowSurfacePrivate(QWindowSurface *win)
-{
- winSurface = win;
- engine = 0;
-}
-
-QVGEGLWindowSurfacePrivate::~QVGEGLWindowSurfacePrivate()
-{
- // Destroy the paint engine if it hasn't been destroyed already.
- destroyPaintEngine();
-}
-
-QVGPaintEngine *QVGEGLWindowSurfacePrivate::paintEngine()
-{
- if (!engine)
- engine = qt_vg_create_paint_engine();
- return engine;
-}
-
-VGImage QVGEGLWindowSurfacePrivate::surfaceImage() const
-{
- return VG_INVALID_HANDLE;
-}
-
-void QVGEGLWindowSurfacePrivate::destroyPaintEngine()
-{
- if (engine) {
- qt_vg_destroy_paint_engine(engine);
- engine = 0;
- }
-}
-
-QSize QVGEGLWindowSurfacePrivate::windowSurfaceSize(QWidget *widget) const
-{
- Q_UNUSED(widget);
-
- QRect rect = winSurface->geometry();
- QSize newSize = rect.size();
-
-#if defined(Q_WS_QWS)
- // Account for the widget mask, if any.
- if (widget && !widget->mask().isEmpty()) {
- const QRegion region = widget->mask()
- & rect.translated(-widget->geometry().topLeft());
- newSize = region.boundingRect().size();
- }
-#endif
-
- return newSize;
-}
-
-#if defined(QVG_VGIMAGE_BACKBUFFERS)
-
-QVGEGLWindowSurfaceVGImage::QVGEGLWindowSurfaceVGImage(QWindowSurface *win)
- : QVGEGLWindowSurfacePrivate(win)
- , context(0)
- , backBuffer(VG_INVALID_HANDLE)
- , backBufferSurface(EGL_NO_SURFACE)
- , recreateBackBuffer(false)
- , isPaintingActive(false)
- , windowSurface(EGL_NO_SURFACE)
-{
-}
-
-QVGEGLWindowSurfaceVGImage::~QVGEGLWindowSurfaceVGImage()
-{
- destroyPaintEngine();
- if (context) {
- if (backBufferSurface != EGL_NO_SURFACE) {
- // We need a current context to be able to destroy the image.
- // We use the shared surface because the native window handle
- // associated with "windowSurface" may have been destroyed already.
- context->makeCurrent(qt_vg_shared_surface());
- context->destroySurface(backBufferSurface);
- vgDestroyImage(backBuffer);
- context->doneCurrent();
- }
- if (windowSurface != EGL_NO_SURFACE)
- context->destroySurface(windowSurface);
- qt_vg_destroy_context(context, QInternal::Widget);
- }
-}
-
-QEglContext *QVGEGLWindowSurfaceVGImage::ensureContext(QWidget *widget)
-{
- QSize newSize = windowSurfaceSize(widget);
- if (context && size != newSize) {
- // The surface size has changed, so we need to recreate
- // the back buffer. Keep the same context and paint engine.
- size = newSize;
- if (isPaintingActive)
- context->doneCurrent();
- isPaintingActive = false;
- recreateBackBuffer = true;
- }
- if (!context) {
- // Create a new EGL context. We create the surface in beginPaint().
- size = newSize;
- context = qt_vg_create_context(widget, QInternal::Widget);
- if (!context)
- return 0;
- isPaintingActive = false;
- }
- return context;
-}
-
-void QVGEGLWindowSurfaceVGImage::beginPaint(QWidget *widget)
-{
- QEglContext *context = ensureContext(widget);
- if (context) {
- if (recreateBackBuffer || backBufferSurface == EGL_NO_SURFACE) {
- // Create a VGImage object to act as the back buffer
- // for this window. We have to create the VGImage with a
- // current context, so activate the main surface for the window.
- context->makeCurrent(mainSurface());
- recreateBackBuffer = false;
- if (backBufferSurface != EGL_NO_SURFACE) {
- eglDestroySurface(QEgl::display(), backBufferSurface);
- backBufferSurface = EGL_NO_SURFACE;
- }
- if (backBuffer != VG_INVALID_HANDLE) {
- vgDestroyImage(backBuffer);
- }
- VGImageFormat format = qt_vg_config_to_vg_format(context);
- backBuffer = vgCreateImage
- (format, size.width(), size.height(),
- VG_IMAGE_QUALITY_FASTER);
- if (backBuffer != VG_INVALID_HANDLE) {
- // Create an EGL surface for rendering into the VGImage.
- backBufferSurface = eglCreatePbufferFromClientBuffer
- (QEgl::display(), EGL_OPENVG_IMAGE,
- (EGLClientBuffer)(backBuffer),
- context->config(), NULL);
- if (backBufferSurface == EGL_NO_SURFACE) {
- vgDestroyImage(backBuffer);
- backBuffer = VG_INVALID_HANDLE;
- }
- }
- }
- if (backBufferSurface != EGL_NO_SURFACE)
- context->makeCurrent(backBufferSurface);
- else
- context->makeCurrent(mainSurface());
- isPaintingActive = true;
- }
-}
-
-void QVGEGLWindowSurfaceVGImage::endPaint
- (QWidget *widget, const QRegion& region, QImage *image)
-{
- Q_UNUSED(region);
- Q_UNUSED(image);
- QEglContext *context = ensureContext(widget);
- if (context) {
- if (backBufferSurface != EGL_NO_SURFACE) {
- if (isPaintingActive)
- vgFlush();
- context->lazyDoneCurrent();
- }
- isPaintingActive = false;
- }
-}
-
-VGImage QVGEGLWindowSurfaceVGImage::surfaceImage() const
-{
- return backBuffer;
-}
-
-EGLSurface QVGEGLWindowSurfaceVGImage::mainSurface() const
-{
- if (windowSurface != EGL_NO_SURFACE)
- return windowSurface;
- else
- return qt_vg_shared_surface();
-}
-
-#endif // QVG_VGIMAGE_BACKBUFFERS
-
-QVGEGLWindowSurfaceDirect::QVGEGLWindowSurfaceDirect(QWindowSurface *win)
- : QVGEGLWindowSurfacePrivate(win)
- , context(0)
- , isPaintingActive(false)
- , needToSwap(false)
- , windowSurface(EGL_NO_SURFACE)
-{
-}
-
-QVGEGLWindowSurfaceDirect::~QVGEGLWindowSurfaceDirect()
-{
- destroyPaintEngine();
- if (context) {
- if (windowSurface != EGL_NO_SURFACE)
- context->destroySurface(windowSurface);
- qt_vg_destroy_context(context, QInternal::Widget);
- }
-}
-
-QEglContext *QVGEGLWindowSurfaceDirect::ensureContext(QWidget *widget)
-{
- QSize newSize = windowSurfaceSize(widget);
- QEglProperties surfaceProps;
-
-#if defined(QVG_RECREATE_ON_SIZE_CHANGE)
-#if !defined(QVG_NO_SINGLE_CONTEXT)
- if (context && size != newSize) {
- // The surface size has changed, so we need to recreate it.
- // We can keep the same context and paint engine.
- size = newSize;
- if (isPaintingActive)
- context->doneCurrent();
- context->destroySurface(windowSurface);
-#if defined(EGL_VG_ALPHA_FORMAT_PRE_BIT)
- if (isPremultipliedContext(context)) {
- surfaceProps.setValue
- (EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE);
- } else {
- surfaceProps.removeValue(EGL_VG_ALPHA_FORMAT);
- }
-#endif
- windowSurface = context->createSurface(widget, &surfaceProps);
- isPaintingActive = false;
- needToSwap = true;
- }
-#else
- if (context && size != newSize) {
- // The surface size has changed, so we need to recreate
- // the EGL context for the widget. We also need to recreate
- // the surface's paint engine if context sharing is not
- // enabled because we cannot reuse the existing paint objects
- // in the new context.
- qt_vg_destroy_paint_engine(engine);
- engine = 0;
- context->destroySurface(windowSurface);
- qt_vg_destroy_context(context, QInternal::Widget);
- context = 0;
- windowSurface = EGL_NO_SURFACE;
- }
-#endif
-#endif
- if (!context) {
- // Create a new EGL context and bind it to the widget surface.
- size = newSize;
- context = qt_vg_create_context(widget, QInternal::Widget);
- if (!context)
- return 0;
- // We want a direct to window rendering surface if possible.
-#if defined(QVG_DIRECT_TO_WINDOW)
- surfaceProps.setValue(EGL_RENDER_BUFFER, EGL_SINGLE_BUFFER);
-#endif
-#if defined(EGL_VG_ALPHA_FORMAT_PRE_BIT)
- if (isPremultipliedContext(context)) {
- surfaceProps.setValue
- (EGL_VG_ALPHA_FORMAT, EGL_VG_ALPHA_FORMAT_PRE);
- } else {
- surfaceProps.removeValue(EGL_VG_ALPHA_FORMAT);
- }
-#endif
- EGLSurface surface = context->createSurface(widget, &surfaceProps);
- if (surface == EGL_NO_SURFACE) {
- qt_vg_destroy_context(context, QInternal::Widget);
- context = 0;
- return 0;
- }
- needToSwap = true;
-#if defined(QVG_DIRECT_TO_WINDOW)
- // Did we get a direct to window rendering surface?
- EGLint buffer = 0;
- if (eglQueryContext(QEgl::display(), context->context(),
- EGL_RENDER_BUFFER, &buffer) &&
- buffer == EGL_SINGLE_BUFFER) {
- needToSwap = false;
- }
-#endif
- windowSurface = surface;
- isPaintingActive = false;
- }
-
-#if !defined(QVG_NO_PRESERVED_SWAP)
- // Try to force the surface back buffer to preserve its contents.
- if (needToSwap) {
- bool succeeded = eglSurfaceAttrib(QEgl::display(), windowSurface,
- EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED);
- if (!succeeded && eglGetError() != EGL_SUCCESS) {
- qWarning("QVG: could not enable preserved swap");
- }
- }
-#endif
- return context;
-}
-
-void QVGEGLWindowSurfaceDirect::beginPaint(QWidget *widget)
-{
- QEglContext *context = ensureContext(widget);
- if (context) {
- context->makeCurrent(windowSurface);
- isPaintingActive = true;
- }
-}
-
-void QVGEGLWindowSurfaceDirect::endPaint
- (QWidget *widget, const QRegion& region, QImage *image)
-{
- Q_UNUSED(region);
- Q_UNUSED(image);
- QEglContext *context = ensureContext(widget);
- if (context) {
- if (needToSwap) {
- if (!isPaintingActive)
- context->makeCurrent(windowSurface);
- context->swapBuffers(windowSurface);
- context->lazyDoneCurrent();
- } else if (isPaintingActive) {
- vgFlush();
- context->lazyDoneCurrent();
- }
- isPaintingActive = false;
- }
-}
-
-bool QVGEGLWindowSurfaceDirect::supportsStaticContents() const
-{
-#if defined(QVG_BUFFER_SCROLLING) && !defined(QVG_NO_PRESERVED_SWAP)
- return true;
-#else
- return QVGEGLWindowSurfacePrivate::supportsStaticContents();
-#endif
-}
-
-bool QVGEGLWindowSurfaceDirect::scroll(QWidget *widget, const QRegion& area, int dx, int dy)
-{
-#ifdef QVG_BUFFER_SCROLLING
- QEglContext *context = ensureContext(widget);
- if (context) {
- context->makeCurrent(windowSurface);
- QRect scrollRect = area.boundingRect();
- int sx = scrollRect.x();
- int sy = size.height() - scrollRect.y() - scrollRect.height();
- vgSeti(VG_SCISSORING, VG_FALSE);
- vgCopyPixels(sx + dx, sy - dy, sx, sy, scrollRect.width(), scrollRect.height());
- context->lazyDoneCurrent();
- return true;
- }
-#else
- Q_UNUSED(widget);
- Q_UNUSED(area);
- Q_UNUSED(dx);
- Q_UNUSED(dy);
-#endif
- return false;
-}
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/openvg/qwindowsurface_vgegl_p.h b/src/openvg/qwindowsurface_vgegl_p.h
deleted file mode 100644
index f3f3af49bd..0000000000
--- a/src/openvg/qwindowsurface_vgegl_p.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtOpenVG module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWINDOWSURFACE_VGEGL_P_H
-#define QWINDOWSURFACE_VGEGL_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QLibrary class. This header file may change from
-// version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtGui/private/qwindowsurface_p.h>
-#include "qvg_p.h"
-
-#if !defined(QT_NO_EGL)
-
-#include <QtGui/private/qeglcontext_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QWindowSurface;
-
-class Q_OPENVG_EXPORT QVGEGLWindowSurfacePrivate
-{
-public:
- QVGEGLWindowSurfacePrivate(QWindowSurface *win);
- virtual ~QVGEGLWindowSurfacePrivate();
-
- QVGPaintEngine *paintEngine();
- virtual QEglContext *ensureContext(QWidget *widget) = 0;
- virtual void beginPaint(QWidget *widget) = 0;
- virtual void endPaint
- (QWidget *widget, const QRegion& region, QImage *image = 0) = 0;
- virtual VGImage surfaceImage() const;
- virtual QSize surfaceSize() const = 0;
- virtual bool supportsStaticContents() const { return false; }
- virtual bool scroll(QWidget *, const QRegion&, int, int) { return false; }
-
-private:
- QVGPaintEngine *engine;
-
-protected:
- QWindowSurface *winSurface;
-
- void destroyPaintEngine();
- QSize windowSurfaceSize(QWidget *widget) const;
-};
-
-#if defined(EGL_OPENVG_IMAGE) && !defined(QVG_NO_SINGLE_CONTEXT)
-
-#define QVG_VGIMAGE_BACKBUFFERS 1
-
-class Q_OPENVG_EXPORT QVGEGLWindowSurfaceVGImage : public QVGEGLWindowSurfacePrivate
-{
-public:
- QVGEGLWindowSurfaceVGImage(QWindowSurface *win);
- virtual ~QVGEGLWindowSurfaceVGImage();
-
- QEglContext *ensureContext(QWidget *widget);
- void beginPaint(QWidget *widget);
- void endPaint(QWidget *widget, const QRegion& region, QImage *image);
- VGImage surfaceImage() const;
- QSize surfaceSize() const { return size; }
-
-protected:
- QEglContext *context;
- VGImage backBuffer;
- EGLSurface backBufferSurface;
- bool recreateBackBuffer;
- bool isPaintingActive;
- QSize size;
- EGLSurface windowSurface;
-
- EGLSurface mainSurface() const;
-};
-
-#endif // EGL_OPENVG_IMAGE
-
-class Q_OPENVG_EXPORT QVGEGLWindowSurfaceDirect : public QVGEGLWindowSurfacePrivate
-{
-public:
- QVGEGLWindowSurfaceDirect(QWindowSurface *win);
- virtual ~QVGEGLWindowSurfaceDirect();
-
- QEglContext *ensureContext(QWidget *widget);
- void beginPaint(QWidget *widget);
- void endPaint(QWidget *widget, const QRegion& region, QImage *image);
- QSize surfaceSize() const { return size; }
- bool supportsStaticContents() const;
- bool scroll(QWidget *widget, const QRegion& area, int dx, int dy);
-
-protected:
- QEglContext *context;
- QSize size;
- bool isPaintingActive;
- bool needToSwap;
- EGLSurface windowSurface;
-};
-
-QT_END_NAMESPACE
-
-#endif // !QT_NO_EGL
-
-#endif // QWINDOWSURFACE_VGEGL_P_H
diff --git a/src/plugins/accessible/widgets/complexwidgets.h b/src/plugins/accessible/widgets/complexwidgets.h
index b5ba13941d..235f6cacc8 100644
--- a/src/plugins/accessible/widgets/complexwidgets.h
+++ b/src/plugins/accessible/widgets/complexwidgets.h
@@ -43,9 +43,9 @@
#define COMPLEXWIDGETS_H
#include <QtCore/qpointer.h>
-#include <QtGui/qaccessiblewidget.h>
-#include <QtGui/qabstractitemview.h>
-#include <QtGui/qaccessible2.h>
+#include <QtWidgets/qaccessiblewidget.h>
+#include <QtWidgets/qabstractitemview.h>
+#include <QtWidgets/qaccessible2.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/accessible/widgets/qaccessiblemenu.cpp b/src/plugins/accessible/widgets/qaccessiblemenu.cpp
index 6d8a358d5c..337b4860bc 100644
--- a/src/plugins/accessible/widgets/qaccessiblemenu.cpp
+++ b/src/plugins/accessible/widgets/qaccessiblemenu.cpp
@@ -43,7 +43,7 @@
#include <qmenu.h>
#include <qmenubar.h>
-#include <QtGui/QAction>
+#include <QtWidgets/QAction>
#include <qstyle.h>
#ifndef QT_NO_ACCESSIBILITY
diff --git a/src/plugins/accessible/widgets/qaccessiblemenu.h b/src/plugins/accessible/widgets/qaccessiblemenu.h
index 7decca02c7..8db96671a8 100644
--- a/src/plugins/accessible/widgets/qaccessiblemenu.h
+++ b/src/plugins/accessible/widgets/qaccessiblemenu.h
@@ -42,7 +42,7 @@
#ifndef QACCESSIBLEMENU_H
#define QACCESSIBLEMENU_H
-#include <QtGui/qaccessiblewidget.h>
+#include <QtWidgets/qaccessiblewidget.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/accessible/widgets/qaccessiblewidgets.cpp b/src/plugins/accessible/widgets/qaccessiblewidgets.cpp
index 4402932a29..c15232b368 100644
--- a/src/plugins/accessible/widgets/qaccessiblewidgets.cpp
+++ b/src/plugins/accessible/widgets/qaccessiblewidgets.cpp
@@ -65,7 +65,7 @@
#include <QMainWindow>
#include <QAbstractButton>
#include <private/qdockwidget_p.h>
-#include <QtGui/QFocusFrame>
+#include <QFocusFrame>
#ifndef QT_NO_ACCESSIBILITY
diff --git a/src/plugins/accessible/widgets/qaccessiblewidgets.h b/src/plugins/accessible/widgets/qaccessiblewidgets.h
index 64c2bde188..b6cbd03d47 100644
--- a/src/plugins/accessible/widgets/qaccessiblewidgets.h
+++ b/src/plugins/accessible/widgets/qaccessiblewidgets.h
@@ -42,8 +42,8 @@
#ifndef QACCESSIBLEWIDGETS_H
#define QACCESSIBLEWIDGETS_H
-#include <QtGui/qaccessible2.h>
-#include <QtGui/qaccessiblewidget.h>
+#include <QtWidgets/qaccessible2.h>
+#include <QtWidgets/qaccessiblewidget.h>
#ifndef QT_NO_ACCESSIBILITY
diff --git a/src/plugins/accessible/widgets/rangecontrols.h b/src/plugins/accessible/widgets/rangecontrols.h
index f565d8e888..5185773751 100644
--- a/src/plugins/accessible/widgets/rangecontrols.h
+++ b/src/plugins/accessible/widgets/rangecontrols.h
@@ -42,8 +42,8 @@
#ifndef RANGECONTROLS_H
#define RANGECONTROLS_H
-#include <QtGui/qaccessiblewidget.h>
-#include <QtGui/qaccessible2.h>
+#include <QtWidgets/qaccessiblewidget.h>
+#include <QtWidgets/qaccessible2.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/accessible/widgets/simplewidgets.h b/src/plugins/accessible/widgets/simplewidgets.h
index ca1f24bfc2..432cb30672 100644
--- a/src/plugins/accessible/widgets/simplewidgets.h
+++ b/src/plugins/accessible/widgets/simplewidgets.h
@@ -43,8 +43,8 @@
#define SIMPLEWIDGETS_H
#include <QtCore/qcoreapplication.h>
-#include <QtGui/qaccessible2.h>
-#include <QtGui/qaccessiblewidget.h>
+#include <QtWidgets/qaccessible2.h>
+#include <QtWidgets/qaccessiblewidget.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/accessible/widgets/widgets.pro b/src/plugins/accessible/widgets/widgets.pro
index 8329bce963..8fb42fbb03 100644
--- a/src/plugins/accessible/widgets/widgets.pro
+++ b/src/plugins/accessible/widgets/widgets.pro
@@ -2,7 +2,7 @@ TARGET = qtaccessiblewidgets
include(../../qpluginbase.pri)
include (../qaccessiblebase.pri)
-QT += core-private gui-private
+QT += core-private gui-private widgets-private
DESTDIR = $$QT.gui.plugins/accessible
QTDIR_build:REQUIRES += "contains(QT_CONFIG, accessibility)"
diff --git a/src/plugins/decorations/decorations.pro b/src/plugins/decorations/decorations.pro
deleted file mode 100644
index 3d6912e77c..0000000000
--- a/src/plugins/decorations/decorations.pro
+++ /dev/null
@@ -1,4 +0,0 @@
-TEMPLATE = subdirs
-contains(decoration-plugins, default) :SUBDIRS += default
-contains(decoration-plugins, styled) :SUBDIRS += styled
-contains(decoration-plugins, windows) :SUBDIRS += windows
diff --git a/src/plugins/decorations/default/default.pro b/src/plugins/decorations/default/default.pro
deleted file mode 100644
index a30899a62b..0000000000
--- a/src/plugins/decorations/default/default.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-TARGET = qdecorationdefault
-include(../../qpluginbase.pri)
-
-HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qdecorationdefault_qws.h
-SOURCES = main.cpp \
- $$QT_SOURCE_TREE/src/gui/embedded/qdecorationdefault_qws.cpp
-
-DESTDIR = $$QT.gui.plugins/decorations
-target.path += $$[QT_INSTALL_PLUGINS]/decorations
-INSTALLS += target
diff --git a/src/plugins/decorations/default/main.cpp b/src/plugins/decorations/default/main.cpp
deleted file mode 100644
index fda6004eaa..0000000000
--- a/src/plugins/decorations/default/main.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qdecorationplugin_qws.h>
-#include <qdecorationdefault_qws.h>
-
-QT_BEGIN_NAMESPACE
-
-class DecorationDefault : public QDecorationPlugin
-{
-public:
- DecorationDefault();
-
- QStringList keys() const;
- QDecoration *create(const QString&);
-};
-
-DecorationDefault::DecorationDefault()
- : QDecorationPlugin()
-{
-}
-
-QStringList DecorationDefault::keys() const
-{
- return (QStringList() << QLatin1String("Default"));
-}
-
-QDecoration* DecorationDefault::create(const QString& s)
-{
- if (s.toLower() == QLatin1String("default"))
- return new QDecorationDefault();
-
- return 0;
-}
-
-Q_EXPORT_PLUGIN2(qdecorationdefault, DecorationDefault)
-
-QT_END_NAMESPACE
diff --git a/src/plugins/decorations/styled/main.cpp b/src/plugins/decorations/styled/main.cpp
deleted file mode 100644
index da00adc971..0000000000
--- a/src/plugins/decorations/styled/main.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qdecorationplugin_qws.h>
-#include <qdecorationstyled_qws.h>
-
-QT_BEGIN_NAMESPACE
-
-class DecorationStyled : public QDecorationPlugin
-{
-public:
- DecorationStyled();
-
- QStringList keys() const;
- QDecoration *create(const QString&);
-};
-
-DecorationStyled::DecorationStyled() : QDecorationPlugin()
-{
-}
-
-QStringList DecorationStyled::keys() const
-{
- return (QStringList() << QLatin1String("Styled"));
-}
-
-QDecoration* DecorationStyled::create(const QString& s)
-{
- if (s.toLower() != QLatin1String("styled"))
- return 0;
-
- qDebug("creatign styled decoration");
-
- return new QDecorationStyled;
-}
-
-Q_EXPORT_PLUGIN2(qdecorationstyled, DecorationStyled)
-
-QT_END_NAMESPACE
diff --git a/src/plugins/decorations/styled/styled.pro b/src/plugins/decorations/styled/styled.pro
deleted file mode 100644
index 151ef88178..0000000000
--- a/src/plugins/decorations/styled/styled.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TARGET = qdecorationstyled
-include(../../qpluginbase.pri)
-
-DESTDIR = $$QT.gui.plugins/decorations
-target.path += $$[QT_INSTALL_PLUGINS]/decorations
-INSTALLS += target
-
-DEFINES += QT_QWS_DECORATION_STYLED
-
-HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qdecorationstyled_qws.h
-SOURCES = main.cpp \
- $$QT_SOURCE_TREE/src/gui/embedded/qdecorationstyled_qws.cpp
-
diff --git a/src/plugins/decorations/windows/main.cpp b/src/plugins/decorations/windows/main.cpp
deleted file mode 100644
index 0c7fd4b125..0000000000
--- a/src/plugins/decorations/windows/main.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qdecorationplugin_qws.h>
-#include <qdecorationwindows_qws.h>
-
-QT_BEGIN_NAMESPACE
-
-class DecorationWindows : public QDecorationPlugin
-{
-public:
- DecorationWindows();
-
- QStringList keys() const;
- QDecoration *create(const QString&);
-};
-
-DecorationWindows::DecorationWindows()
- : QDecorationPlugin()
-{
-}
-
-QStringList DecorationWindows::keys() const
-{
- return (QStringList() << QLatin1String("Windows"));
-}
-
-QDecoration* DecorationWindows::create(const QString& s)
-{
- if (s.toLower() == QLatin1String("windows"))
- return new QDecorationWindows();
-
- return 0;
-}
-
-Q_EXPORT_PLUGIN2(qdecorationwindows, DecorationWindows)
-
-QT_END_NAMESPACE
diff --git a/src/plugins/decorations/windows/windows.pro b/src/plugins/decorations/windows/windows.pro
deleted file mode 100644
index 7f788a3d7e..0000000000
--- a/src/plugins/decorations/windows/windows.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-TARGET = qdecorationwindows
-include(../../qpluginbase.pri)
-
-HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qdecorationwindows_qws.h
-SOURCES = main.cpp \
- $$QT_SOURCE_TREE/src/gui/embedded/qdecorationwindows_qws.cpp
-
-DESTDIR = $$QT.gui.plugins/decorations
-target.path += $$[QT_INSTALL_PLUGINS]/decorations
-INSTALLS += target
diff --git a/src/plugins/gfxdrivers/ahi/ahi.pro b/src/plugins/gfxdrivers/ahi/ahi.pro
deleted file mode 100644
index 3abe2a76cc..0000000000
--- a/src/plugins/gfxdrivers/ahi/ahi.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-TARGET = qahiscreen
-include(../../qpluginbase.pri)
-
-DESTDIR = $$QT.gui.plugins/gfxdrivers
-
-target.path = $$[QT_INSTALL_PLUGINS]/gfxdrivers
-INSTALLS += target
-
-HEADERS = qscreenahi_qws.h
-
-SOURCES = qscreenahi_qws.cpp \
- qscreenahiplugin.cpp
-
-LIBS += -lahi
diff --git a/src/plugins/gfxdrivers/ahi/qscreenahi_qws.cpp b/src/plugins/gfxdrivers/ahi/qscreenahi_qws.cpp
deleted file mode 100644
index aa28b0eeec..0000000000
--- a/src/plugins/gfxdrivers/ahi/qscreenahi_qws.cpp
+++ /dev/null
@@ -1,598 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qscreenahi_qws.h"
-
-#ifndef QT_NO_QWS_AHI
-
-#include <QtGui/qcolor.h>
-#include <QtGui/qapplication.h>
-#include <QtCore/qvector.h>
-#include <QtCore/qvarlengtharray.h>
-#include <private/qwssignalhandler_p.h>
-
-#include <ahi.h>
-
-//#define QAHISCREEN_DEBUG
-
-static int depthForPixelFormat(const AhiPixelFormat_t format)
-{
- switch (format) {
- case AhiPix1bpp:
- return 1;
- case AhiPix2bpp:
- return 2;
- case AhiPix4bpp:
- return 4;
- case AhiPix8bpp_332RGB:
- case AhiPix8bpp:
- return 8;
- case AhiPix16bpp_444RGB:
- return 12;
- case AhiPix16bpp_555RGB:
- return 15;
- case AhiPix16bpp_565RGB:
- return 16;
- case AhiPix32bpp_8888ARGB:
- case AhiPix32bpp_8888BGRA:
- return 32;
- default:
- return 0;
- }
-}
-
-static AhiPixelFormat_t pixelFormatForImageFormat(const QImage::Format format)
-{
- switch (format) {
- case QImage::Format_Mono:
- case QImage::Format_MonoLSB:
- return AhiPix1bpp;
- case QImage::Format_Indexed8:
- return AhiPix8bpp;
- case QImage::Format_RGB32:
- case QImage::Format_ARGB32:
- case QImage::Format_ARGB32_Premultiplied:
- return AhiPix32bpp_8888ARGB;
- case QImage::Format_RGB16:
- return AhiPix16bpp_565RGB;
- case QImage::Format_RGB555:
- return AhiPix16bpp_555RGB;
- case QImage::Format_ARGB4444_Premultiplied:
- case QImage::Format_RGB444:
- return AhiPix16bpp_444RGB;
- default:
- return AhiPixelFormatMax;
- }
-}
-
-class QAhiScreenCursor : public QScreenCursor
-{
-public:
- QAhiScreenCursor(QScreen *screen, AhiDevCtx_t context);
-
- void set(const QImage &image, int hotx, int hoty);
- void move(int x, int y);
- void show();
- void hide();
-
-private:
- QScreen *screen;
- AhiDevCtx_t context;
-};
-
-QAhiScreenCursor::QAhiScreenCursor(QScreen *s, AhiDevCtx_t c)
- : QScreenCursor(), screen(s), context(c)
-{
- hwaccel = true;
- supportsAlpha = true;
-
- if (enable)
- show();
- else
- hide();
-}
-
-void QAhiScreenCursor::set(const QImage &image, int hotx, int hoty)
-{
- if (image.isNull()) {
- QScreenCursor::set(image, hotx, hoty);
- return;
- }
-
- if (image.format() != QImage::Format_MonoLSB) {
- set(image.convertToFormat(QImage::Format_MonoLSB), hotx, hoty);
- return;
- }
-
- AhiPixelFormat_t pixFmt = pixelFormatForImageFormat(image.format());
-
- if (pixFmt >= AhiPixelFormatMax) { // generic fallback
- QImage::Format toFormat = screen->pixelFormat();
- if (toFormat == QImage::Format_Invalid)
- toFormat = QImage::Format_ARGB32;
- set(image.convertToFormat(toFormat), hotx, hoty);
- return;
- }
-
- AhiPoint_t hotSpot = { hotx, hoty };
- AhiSize_t bitmapSize = { image.width(), image.height() };
- AhiBitmap_t bitmap = { bitmapSize, (void*)(image.bits()),
- image.bytesPerLine(), pixFmt };
-
- AhiSts_t status;
- status = AhiDispCursorSet(context, AhiCursor1, &bitmap, &hotSpot,
- image.serialNumber(), 0);
- if (status != AhiStsOk)
- qWarning("QAhiScreenCursor::set(): AhiDispCursorSet failed: %x",
- status);
-
- QScreenCursor::set(image, hotx, hoty);
-}
-
-void QAhiScreenCursor::move(int x, int y)
-{
- AhiPoint_t pos = { x, y };
- AhiSts_t status = AhiDispCursorPos(context, AhiCursor1, &pos, 0);
- if (status != AhiStsOk)
- qWarning("QAhiScreenCursor::move(): error setting mouse position: %x",
- status);
- QScreenCursor::move(x, y);
-}
-
-void QAhiScreenCursor::show()
-{
- AhiSts_t status;
- status = AhiDispCursorState(context, AhiCursor1, AhiCursorStateOn, 0);
- if (status != AhiStsOk)
- qWarning("QAhiScreenCursor::show(): error setting state: %x", status);
- QScreenCursor::show();
-}
-
-void QAhiScreenCursor::hide()
-{
- AhiDispCursorState(context, AhiCursor1, AhiCursorStateOff, 0);
- QScreenCursor::hide();
-}
-
-class QAhiScreenPrivate : public QObject
-{
-public:
- QAhiScreenPrivate();
- ~QAhiScreenPrivate();
-
- bool setMode(AhiDispMode_t mode);
-
- AhiDevCtx_t context;
- AhiSurf_t surface;
- QAhiScreenCursor *cursor;
-};
-
-QT_BEGIN_NAMESPACE
-
-QAhiScreenPrivate::QAhiScreenPrivate()
- : context(0), surface(0), cursor(0)
-{
-#ifndef QT_NO_QWS_SIGNALHANDLER
- QWSSignalHandler::instance()->addObject(this);
-#endif
-}
-
-QAhiScreenPrivate::~QAhiScreenPrivate()
-{
- delete cursor;
-
- if (surface) {
- AhiSurfFree(context, surface);
- surface = 0;
- }
- if (context) {
- AhiDevClose(context);
- context = 0;
- }
- AhiTerm();
-}
-
-bool QAhiScreenPrivate::setMode(AhiDispMode_t mode)
-{
- AhiSts_t status;
-
- status = AhiDispModeSet(context, &mode, 0);
- if (status != AhiStsOk) {
- qCritical("QAhiScreenPrivate::setMode(): AhiDispModeSet failed: %x",
- status);
- return false;
- }
-
- if (surface) {
- AhiSurfFree(context, surface);
- surface = 0;
- }
- status = AhiSurfAlloc(context, &surface, &mode.size, mode.pixFmt,
- AHIFLAG_SURFFIXED);
- if (status != AhiStsOk) {
- qCritical("QAhiScreenPrivate::setMode(): AhisurfAlloc failed: %x",
- status);
- return false;
- }
-
- status = AhiDispSurfSet(context, surface, 0);
- if (status != AhiStsOk) {
- qCritical("QAhiScreenPrivate::setMode(): AhiDispSurfSet failed: %x",
- status);
- return false;
- }
-
- return true;
-}
-
-QAhiScreen::QAhiScreen(int displayId)
- : QScreen(displayId), d_ptr(new QAhiScreenPrivate)
-{
-}
-
-QAhiScreen::~QAhiScreen()
-{
- delete d_ptr;
-}
-
-bool QAhiScreen::configure()
-{
- AhiSurfInfo_t surfaceInfo;
- AhiSts_t status;
-
- status = AhiSurfInfo(d_ptr->context, d_ptr->surface, &surfaceInfo);
- if (status != AhiStsOk) {
- qCritical("QAhiScreen::configure(): AhiSurfInfo failed: %x", status);
- return false;
- }
-
- QScreen::data = 0;
- QScreen::w = QScreen::dw = surfaceInfo.size.cx;
- QScreen::h = QScreen::dh = surfaceInfo.size.cy;
- QScreen::lstep = surfaceInfo.stride;
- QScreen::size = surfaceInfo.sizeInBytes;
-
- switch (surfaceInfo.pixFmt) {
- case AhiPix1bpp:
- setPixelFormat(QImage::Format_Mono);
- QScreen::d = 1;
- break;
- case AhiPix4bpp:
- QScreen::d = 4;
- break;
- case AhiPix8bpp_332RGB:
- case AhiPix8bpp:
- QScreen::d = 8;
- break;
- case AhiPix16bpp_444RGB:
- setPixelFormat(QImage::Format_RGB444);
- QScreen::d = 12;
- break;
- case AhiPix16bpp_555RGB:
- setPixelFormat(QImage::Format_RGB555);
- QScreen::d = 15;
- break;
- case AhiPix16bpp_565RGB:
- setPixelFormat(QImage::Format_RGB16);
- QScreen::d = 16;
- break;
- case AhiPix2bpp:
- QScreen::d = 2;
- break;
- case AhiPix32bpp_8888ARGB:
- setPixelFormat(QImage::Format_ARGB32);
- // fallthrough
- case AhiPix32bpp_8888BGRA:
- QScreen::d = 32;
- break;
- default:
- qCritical("QAhiScreen::configure(): Unknown pixel format: %x",
- surfaceInfo.pixFmt);
- return false;
- }
-
- const int dpi = 72;
- QScreen::physWidth = qRound(QScreen::dw * 25.4 / dpi);
- QScreen::physHeight = qRound(QScreen::dh * 25.4 / dpi);
-
- return true;
-}
-
-bool QAhiScreen::connect(const QString &displaySpec)
-{
- Q_UNUSED(displaySpec);
-
- AhiSts_t status;
-
- status = AhiInit(0);
- if (status != AhiStsOk) {
- qCritical("QAhiScreen::connect(): AhiInit failed: %x", status);
- return false;
- }
-
- AhiDev_t device;
- AhiDevInfo_t info;
-
- status = AhiDevEnum(&device, &info, 0);
- if (status != AhiStsOk) {
- qCritical("QAhiScreen::connect(): AhiDevEnum failed: %x", status);
- return false;
- }
-#ifdef QAHISCREEN_DEBUG
- {
- int displayNo = 0;
- AhiDevInfo_t dispInfo = info;
- qDebug("AHI supported devices:");
- do {
- qDebug(" %2i: %s, sw version: %s (rev %u)\n"
- " chip: 0x%x (rev %u), mem: %i (%i/%i), bus: 0x%x",
- displayNo, dispInfo.name,
- dispInfo.swVersion, uint(dispInfo.swRevision),
- uint(dispInfo.chipId), uint(dispInfo.revisionId),
- uint(dispInfo.totalMemory),
- uint(dispInfo.internalMemSize),
- uint(dispInfo.externalMemSize),
- uint(dispInfo.cpuBusInterfaceMode));
- status = AhiDevEnum(&device, &info, ++displayNo);
- } while (status == AhiStsOk);
- }
-#endif
-
- status = AhiDevOpen(&d_ptr->context, device, "qscreenahi",
- AHIFLAG_USERLEVEL);
- if (status != AhiStsOk) {
- qCritical("QAhiScreen::connect(): AhiDevOpen failed: %x", status);
- return false;
- }
-
- AhiDispMode_t mode;
-
- status = AhiDispModeEnum(d_ptr->context, &mode, 0);
- if (status != AhiStsOk) {
- qCritical("QAhiScreen::connect(): AhiDispModeEnum failed: %x", status);
- return false;
- }
-
-#ifdef QAHISCREEN_DEBUG
- {
- int modeNo = 0;
- AhiDispMode_t modeInfo = mode;
- qDebug("AHI supported modes:");
- do {
- qDebug(" %2i: %ux%u, fmt: %i, %u Hz, rot: %i, mirror: %i",
- modeNo, uint(modeInfo.size.cx), uint(modeInfo.size.cy),
- modeInfo.pixFmt, uint(modeInfo.frequency),
- modeInfo.rotation, modeInfo.mirror);
- status = AhiDispModeEnum(d_ptr->context, &modeInfo, ++modeNo);
- } while (status == AhiStsOk);
- }
-#endif
-
- if (QApplication::type() == QApplication::GuiServer) {
- if (!d_ptr->setMode(mode))
- return false;
- } else {
- status = AhiDispSurfGet(d_ptr->context, &d_ptr->surface);
- if (status != AhiStsOk) {
- qCritical("QAhiScreen::connect(): AhiDispSurfGet failed: %x",
- status);
- return false;
- }
-
- status = AhiDispModeGet(d_ptr->context, &mode);
- if (status != AhiStsOk) {
- qCritical("QAhiScreen::context(): AhiDispModeGet failed: %x",
- status);
- return false;
- }
- }
-
- return configure();
-}
-
-void QAhiScreen::disconnect()
-{
- AhiSurfFree(d_ptr->context, d_ptr->surface);
- d_ptr->surface = 0;
- AhiDevClose(d_ptr->context);
- d_ptr->context = 0;
- AhiTerm();
-}
-
-bool QAhiScreen::initDevice()
-{
- QScreenCursor::initSoftwareCursor();
-
- AhiSts_t status = AhiDispState(d_ptr->context, AhiDispStateOn, 0);
- if (status != AhiStsOk) {
- qCritical("QAhiScreen::connect(): AhiDispState failed: %x", status);
- return false;
- }
-
- return true;
-}
-
-void QAhiScreen::shutdownDevice()
-{
- AhiDispState(d_ptr->context, AhiDispStateOff, 0);
-}
-
-void QAhiScreen::setMode(int width, int height, int depth)
-{
- int modeNo = 0;
- AhiDispMode_t mode;
- AhiSts_t status = AhiStsOk;
-
- while (status == AhiStsOk) {
- status = AhiDispModeEnum(d_ptr->context, &mode, modeNo);
- if (mode.size.cx == uint(width) &&
- mode.size.cy == uint(height) &&
- depthForPixelFormat(mode.pixFmt) == depth)
- {
- d_ptr->setMode(mode);
- configure();
- return;
- }
- }
-}
-
-void QAhiScreen::blit(const QImage &image, const QPoint &topLeft,
- const QRegion &reg)
-{
- AhiPixelFormat_t pixFmt = pixelFormatForImageFormat(image.format());
-
- if (pixFmt >= AhiPixelFormatMax) { // generic fallback
- QImage::Format toFormat = pixelFormat();
- if (toFormat == QImage::Format_Invalid)
- toFormat = QImage::Format_ARGB32;
- blit(image.convertToFormat(toFormat), topLeft, reg);
- return;
- }
-
- AhiSts_t status;
-
- status = AhiDrawSurfDstSet(d_ptr->context, d_ptr->surface, 0);
- if (status != AhiStsOk) {
- qWarning("QAhiScreen::blit(): AhiDrawSurfDstSet failed: %x", status);
- return;
- }
-
- const QVector<QRect> rects = (reg & region()).rects();
- const int numRects = rects.size();
- QVarLengthArray<AhiPoint_t, 8> src(numRects);
- QVarLengthArray<AhiRect_t, 8> dest(numRects);
-
- for (int i = 0; i < numRects; ++i) {
- const QRect rect = rects.at(i);
-
- src[i].x = rect.x() - topLeft.x();
- src[i].y = rect.y() - topLeft.y();
- dest[i].left = rect.left();
- dest[i].top = rect.top();
- dest[i].right = rect.x() + rect.width();
- dest[i].bottom = rect.y() + rect.height();
- }
-
- AhiSize_t bitmapSize = { image.width(), image.height() };
- AhiBitmap_t bitmap = { bitmapSize, (void*)(image.bits()),
- image.bytesPerLine(), pixFmt };
-
- status = AhiDrawRopSet(d_ptr->context, AHIMAKEROP3(AHIROPSRCCOPY));
- if (status != AhiStsOk) {
- qWarning("QAhiScreen::blit(): AhiDrawRopSet failed: %x", status);
- return;
- }
-
- for (int i = 0; i < numRects; ++i) {
- status = AhiDrawBitmapBlt(d_ptr->context, &dest[i], &src[i],
- &bitmap, 0, 0);
- if (status != AhiStsOk) {
- qWarning("QAhiScreen::blit(): AhiDrawBitmapBlt failed: %x",
- status);
- break;
- }
- }
-}
-
-void QAhiScreen::solidFill(const QColor &color, const QRegion &reg)
-{
- AhiSts_t status = AhiStsOk;
-
- switch (pixelFormat()) {
- case QImage::Format_ARGB32_Premultiplied:
- case QImage::Format_ARGB32:
- case QImage::Format_RGB32:
- status = AhiDrawBrushFgColorSet(d_ptr->context, color.rgba());
- break;
- case QImage::Format_RGB16:
- status = AhiDrawBrushFgColorSet(d_ptr->context, qt_convRgbTo16(color.rgb()));
- break;
- default:
- qFatal("QAhiScreen::solidFill(): Not implemented for pixel format %d",
- int(pixelFormat()));
- break;
- }
-
- if (status != AhiStsOk) {
- qWarning("QAhiScreen::solidFill(): AhiDrawBrushFgColorSet failed: %x",
- status);
- return;
- }
-
- status = AhiDrawBrushSet(d_ptr->context, 0, 0, 0, AHIFLAG_BRUSHSOLID);
- if (status != AhiStsOk) {
- qWarning("QAhiScreen::solidFill(): AhiDrawBrushSet failed: %x",
- status);
- return;
- }
-
- status = AhiDrawRopSet(d_ptr->context, AHIMAKEROP3(AHIROPPATCOPY));
- if (status != AhiStsOk) {
- qWarning("QAhiScreen::solidFill(): AhiDrawRopSet failed: %x", status);
- return;
- }
-
- status = AhiDrawSurfDstSet(d_ptr->context, d_ptr->surface, 0);
- if (status != AhiStsOk) {
- qWarning("QAhiScreen::solidFill(): AhiDrawSurfDst failed: %x", status);
- return;
- }
-
- const QVector<QRect> rects = (reg & region()).rects();
- QVarLengthArray<AhiRect_t> ahiRects(rects.size());
-
- for (int i = 0; i < rects.size(); ++i) {
- const QRect rect = rects.at(i);
- ahiRects[i].left = rect.left();
- ahiRects[i].top = rect.top();
- ahiRects[i].right = rect.x() + rect.width();
- ahiRects[i].bottom = rect.y() + rect.height();
- }
-
- status = AhiDrawBitBltMulti(d_ptr->context, ahiRects.data(),
- 0, ahiRects.size());
- if (status != AhiStsOk)
- qWarning("QAhiScreen::solidFill(): AhiDrawBitBlt failed: %x", status);
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_AHI
diff --git a/src/plugins/gfxdrivers/ahi/qscreenahi_qws.h b/src/plugins/gfxdrivers/ahi/qscreenahi_qws.h
deleted file mode 100644
index ec947f4dc6..0000000000
--- a/src/plugins/gfxdrivers/ahi/qscreenahi_qws.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QAHISCREEN_H
-#define QAHISCREEN_H
-
-#include <QtGui/qscreenlinuxfb_qws.h>
-
-#ifndef QT_NO_QWS_AHI
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QAhiScreenPrivate;
-
-class QAhiScreen : public QScreen
-{
-public:
- QAhiScreen(int displayId);
- ~QAhiScreen();
-
- bool connect(const QString &displaySpec);
- void disconnect();
- bool initDevice();
- void shutdownDevice();
- void setMode(int width, int height, int depth);
-
- void blit(const QImage &image, const QPoint &topLeft,
- const QRegion &region);
- void solidFill(const QColor &color, const QRegion &region);
-
-private:
- bool configure();
-
- QAhiScreenPrivate *d_ptr;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_QWS_AHI
-#endif // QAHISCREEN_H
diff --git a/src/plugins/gfxdrivers/ahi/qscreenahiplugin.cpp b/src/plugins/gfxdrivers/ahi/qscreenahiplugin.cpp
deleted file mode 100644
index 7fdb7789b8..0000000000
--- a/src/plugins/gfxdrivers/ahi/qscreenahiplugin.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qscreenahi_qws.h"
-
-#include <QScreenDriverPlugin>
-#include <QStringList>
-
-class QAhiScreenPlugin : public QScreenDriverPlugin
-{
-public:
- QAhiScreenPlugin();
-
- QStringList keys() const;
- QScreen *create(const QString&, int displayId);
-};
-
-QAhiScreenPlugin::QAhiScreenPlugin()
- : QScreenDriverPlugin()
-{
-}
-
-QStringList QAhiScreenPlugin::keys() const
-{
- return (QStringList() << "ahi");
-}
-
-QScreen* QAhiScreenPlugin::create(const QString& driver, int displayId)
-{
- if (driver.toLower() != "ahi")
- return 0;
-
- return new QAhiScreen(displayId);
-}
-
-Q_EXPORT_PLUGIN2(qahiscreen, QAhiScreenPlugin)
diff --git a/src/plugins/gfxdrivers/directfb/directfb.pro b/src/plugins/gfxdrivers/directfb/directfb.pro
deleted file mode 100644
index 54d11ca159..0000000000
--- a/src/plugins/gfxdrivers/directfb/directfb.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-TARGET = qdirectfbscreen
-include(../../qpluginbase.pri)
-include($$QT_SOURCE_TREE/src/gui/embedded/directfb.pri)
-
-DESTDIR = $$QT.gui.plugins/gfxdrivers
-
-target.path = $$[QT_INSTALL_PLUGINS]/gfxdrivers
-INSTALLS += target
-
-SOURCES += qdirectfbscreenplugin.cpp
-
-QMAKE_CXXFLAGS += $$QT_CFLAGS_DIRECTFB
-LIBS += $$QT_LIBS_DIRECTFB
-DEFINES += $$QT_DEFINES_DIRECTFB
-contains(gfx-plugins, directfb):DEFINES += QT_QWS_DIRECTFB
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp
deleted file mode 100644
index 5c6842edca..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.cpp
+++ /dev/null
@@ -1,436 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdirectfbkeyboard.h"
-
-#ifndef QT_NO_QWS_DIRECTFB
-
-#include "qdirectfbscreen.h"
-#include <qobject.h>
-#include <qsocketnotifier.h>
-#include <qhash.h>
-
-#include <directfb.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-
-QT_BEGIN_NAMESPACE
-
-class KeyMap : public QHash<DFBInputDeviceKeySymbol, Qt::Key>
-{
-public:
- KeyMap();
-};
-
-Q_GLOBAL_STATIC(KeyMap, keymap);
-
-class QDirectFBKeyboardHandlerPrivate : public QObject
-{
- Q_OBJECT
-public:
- QDirectFBKeyboardHandlerPrivate(QDirectFBKeyboardHandler *handler);
- ~QDirectFBKeyboardHandlerPrivate();
-
- void suspend();
- void resume();
-
-private:
- QDirectFBKeyboardHandler *handler;
- IDirectFBEventBuffer *eventBuffer;
- QSocketNotifier *keyboardNotifier;
- DFBEvent event;
- int bytesRead;
- int lastUnicode, lastKeycode;
- Qt::KeyboardModifiers lastModifiers;
-private Q_SLOTS:
- void readKeyboardData();
-};
-
-QDirectFBKeyboardHandlerPrivate::QDirectFBKeyboardHandlerPrivate(QDirectFBKeyboardHandler *h)
- : handler(h), eventBuffer(0), keyboardNotifier(0), bytesRead(0),
- lastUnicode(0), lastKeycode(0), lastModifiers(0)
-{
- Q_ASSERT(qt_screen);
-
- IDirectFB *fb = QDirectFBScreen::instance()->dfb();
- if (!fb) {
- qCritical("QDirectFBKeyboardHandler: DirectFB not initialized");
- return;
- }
-
- DFBResult result;
- result = fb->CreateInputEventBuffer(fb, DICAPS_KEYS, DFB_TRUE,
- &eventBuffer);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBKeyboardHandler: "
- "Unable to create input event buffer", result);
- return;
- }
-
- int fd;
- result = eventBuffer->CreateFileDescriptor(eventBuffer, &fd);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBKeyboardHandler: "
- "Unable to create file descriptor", result);
- return;
- }
-
- int flags = ::fcntl(fd, F_GETFL, 0);
- ::fcntl(fd, F_SETFL, flags | O_NONBLOCK);
-
- memset(&event, 0, sizeof(event));
-
- keyboardNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this);
- connect(keyboardNotifier, SIGNAL(activated(int)),
- this, SLOT(readKeyboardData()));
- resume();
-}
-
-void QDirectFBKeyboardHandlerPrivate::suspend()
-{
- keyboardNotifier->setEnabled(false);
-}
-
-void QDirectFBKeyboardHandlerPrivate::resume()
-{
- eventBuffer->Reset(eventBuffer);
- keyboardNotifier->setEnabled(true);
-}
-
-QDirectFBKeyboardHandlerPrivate::~QDirectFBKeyboardHandlerPrivate()
-{
- if (eventBuffer)
- eventBuffer->Release(eventBuffer);
-}
-
-void QDirectFBKeyboardHandlerPrivate::readKeyboardData()
-{
- if(!qt_screen)
- return;
-
- for (;;) {
- // GetEvent returns DFB_UNSUPPORTED after CreateFileDescriptor().
- // This seems stupid and I really hope it's a bug which will be fixed.
-
- // DFBResult ret = eventBuffer->GetEvent(eventBuffer, &event);
-
- char *buf = reinterpret_cast<char*>(&event);
- int ret = ::read(keyboardNotifier->socket(),
- buf + bytesRead, sizeof(DFBEvent) - bytesRead);
- if (ret == -1) {
- if (errno != EAGAIN)
- qWarning("QDirectFBKeyboardHandlerPrivate::readKeyboardData(): %s",
- strerror(errno));
- return;
- }
-
- Q_ASSERT(ret >= 0);
- bytesRead += ret;
- if (bytesRead < int(sizeof(DFBEvent)))
- break;
- bytesRead = 0;
-
- Q_ASSERT(event.clazz == DFEC_INPUT);
-
- const DFBInputEvent input = event.input;
-
- Qt::KeyboardModifiers modifiers = Qt::NoModifier;
-
- // Not implemented:
- // if (input.modifiers & DIMM_SUPER)
- // if (input.modifiers & DIMM_HYPER)
-
- if (!(input.flags & DIEF_KEYSYMBOL) ||
- !(input.flags & DIEF_KEYID) ||
- !(input.type & (DIET_KEYPRESS|DIET_KEYRELEASE)))
- {
- static bool first = true;
- if (first) {
- qWarning("QDirectFBKeyboardHandler - Getting unexpected non-keyboard related events");
- first = false;
- }
- break;
- }
-
- if (input.flags & DIEF_MODIFIERS) {
- if (input.modifiers & DIMM_SHIFT)
- modifiers |= Qt::ShiftModifier;
- if (input.modifiers & DIMM_CONTROL)
- modifiers |= Qt::ControlModifier;
- if (input.modifiers & DIMM_ALT)
- modifiers |= Qt::AltModifier;
- if (input.modifiers & DIMM_ALTGR)
- modifiers |= Qt::AltModifier;
- if (input.modifiers & DIMM_META)
- modifiers |= Qt::MetaModifier;
- }
-
-
- const bool press = input.type & DIET_KEYPRESS;
- DFBInputDeviceKeySymbol symbol = input.key_symbol;
- int unicode = -1;
- int keycode = 0;
-
- keycode = keymap()->value(symbol);
- if (DFB_KEY_TYPE(symbol) == DIKT_UNICODE)
- unicode = symbol;
-
- if (unicode != -1 || keycode != 0) {
- bool autoRepeat = false;
- if (press) {
- if (unicode == lastUnicode && keycode == lastKeycode && modifiers == lastModifiers) {
- autoRepeat = true;
- } else {
- lastUnicode = unicode;
- lastKeycode = keycode;
- lastModifiers = modifiers;
- }
- } else {
- lastUnicode = lastKeycode = -1;
- lastModifiers = 0;
- }
- if (autoRepeat) {
- handler->processKeyEvent(unicode, keycode,
- modifiers, false, autoRepeat);
-
- }
-
- handler->processKeyEvent(unicode, keycode,
- modifiers, press, autoRepeat);
- }
- }
-}
-
-QDirectFBKeyboardHandler::QDirectFBKeyboardHandler(const QString &device)
- : QWSKeyboardHandler()
-{
- Q_UNUSED(device);
- d = new QDirectFBKeyboardHandlerPrivate(this);
-}
-
-QDirectFBKeyboardHandler::~QDirectFBKeyboardHandler()
-{
- delete d;
-}
-
-KeyMap::KeyMap()
-{
- insert(DIKS_BACKSPACE , Qt::Key_Backspace);
- insert(DIKS_TAB , Qt::Key_Tab);
- insert(DIKS_RETURN , Qt::Key_Return);
- insert(DIKS_ESCAPE , Qt::Key_Escape);
- insert(DIKS_DELETE , Qt::Key_Delete);
-
- insert(DIKS_CURSOR_LEFT , Qt::Key_Left);
- insert(DIKS_CURSOR_RIGHT , Qt::Key_Right);
- insert(DIKS_CURSOR_UP , Qt::Key_Up);
- insert(DIKS_CURSOR_DOWN , Qt::Key_Down);
- insert(DIKS_INSERT , Qt::Key_Insert);
- insert(DIKS_HOME , Qt::Key_Home);
- insert(DIKS_END , Qt::Key_End);
- insert(DIKS_PAGE_UP , Qt::Key_PageUp);
- insert(DIKS_PAGE_DOWN , Qt::Key_PageDown);
- insert(DIKS_PRINT , Qt::Key_Print);
- insert(DIKS_PAUSE , Qt::Key_Pause);
- insert(DIKS_SELECT , Qt::Key_Select);
- insert(DIKS_GOTO , Qt::Key_OpenUrl);
- insert(DIKS_CLEAR , Qt::Key_Clear);
- insert(DIKS_MENU , Qt::Key_Menu);
- insert(DIKS_HELP , Qt::Key_Help);
-
- insert(DIKS_INTERNET , Qt::Key_HomePage);
- insert(DIKS_MAIL , Qt::Key_LaunchMail);
- insert(DIKS_FAVORITES , Qt::Key_Favorites);
-
- insert(DIKS_BACK , Qt::Key_Back);
- insert(DIKS_FORWARD , Qt::Key_Forward);
- insert(DIKS_VOLUME_UP , Qt::Key_VolumeUp);
- insert(DIKS_VOLUME_DOWN , Qt::Key_VolumeDown);
- insert(DIKS_MUTE , Qt::Key_VolumeMute);
- insert(DIKS_PLAYPAUSE , Qt::Key_Pause);
- insert(DIKS_PLAY , Qt::Key_MediaPlay);
- insert(DIKS_STOP , Qt::Key_MediaStop);
- insert(DIKS_RECORD , Qt::Key_MediaRecord);
- insert(DIKS_PREVIOUS , Qt::Key_MediaPrevious);
- insert(DIKS_NEXT , Qt::Key_MediaNext);
-
- insert(DIKS_F1 , Qt::Key_F1);
- insert(DIKS_F2 , Qt::Key_F2);
- insert(DIKS_F3 , Qt::Key_F3);
- insert(DIKS_F4 , Qt::Key_F4);
- insert(DIKS_F5 , Qt::Key_F5);
- insert(DIKS_F6 , Qt::Key_F6);
- insert(DIKS_F7 , Qt::Key_F7);
- insert(DIKS_F8 , Qt::Key_F8);
- insert(DIKS_F9 , Qt::Key_F9);
- insert(DIKS_F10 , Qt::Key_F10);
- insert(DIKS_F11 , Qt::Key_F11);
- insert(DIKS_F12 , Qt::Key_F12);
-
- insert(DIKS_SHIFT , Qt::Key_Shift);
- insert(DIKS_CONTROL , Qt::Key_Control);
- insert(DIKS_ALT , Qt::Key_Alt);
- insert(DIKS_ALTGR , Qt::Key_AltGr);
-
- insert(DIKS_META , Qt::Key_Meta);
- insert(DIKS_SUPER , Qt::Key_Super_L); // ???
- insert(DIKS_HYPER , Qt::Key_Hyper_L); // ???
-
- insert(DIKS_CAPS_LOCK , Qt::Key_CapsLock);
- insert(DIKS_NUM_LOCK , Qt::Key_NumLock);
- insert(DIKS_SCROLL_LOCK , Qt::Key_ScrollLock);
-
- insert(DIKS_DEAD_ABOVEDOT , Qt::Key_Dead_Abovedot);
- insert(DIKS_DEAD_ABOVERING , Qt::Key_Dead_Abovering);
- insert(DIKS_DEAD_ACUTE , Qt::Key_Dead_Acute);
- insert(DIKS_DEAD_BREVE , Qt::Key_Dead_Breve);
- insert(DIKS_DEAD_CARON , Qt::Key_Dead_Caron);
- insert(DIKS_DEAD_CEDILLA , Qt::Key_Dead_Cedilla);
- insert(DIKS_DEAD_CIRCUMFLEX , Qt::Key_Dead_Circumflex);
- insert(DIKS_DEAD_DIAERESIS , Qt::Key_Dead_Diaeresis);
- insert(DIKS_DEAD_DOUBLEACUTE , Qt::Key_Dead_Doubleacute);
- insert(DIKS_DEAD_GRAVE , Qt::Key_Dead_Grave);
- insert(DIKS_DEAD_IOTA , Qt::Key_Dead_Iota);
- insert(DIKS_DEAD_MACRON , Qt::Key_Dead_Macron);
- insert(DIKS_DEAD_OGONEK , Qt::Key_Dead_Ogonek);
- insert(DIKS_DEAD_SEMIVOICED_SOUND , Qt::Key_Dead_Semivoiced_Sound);
- insert(DIKS_DEAD_TILDE , Qt::Key_Dead_Tilde);
- insert(DIKS_DEAD_VOICED_SOUND , Qt::Key_Dead_Voiced_Sound);
- insert(DIKS_SPACE , Qt::Key_Space);
- insert(DIKS_EXCLAMATION_MARK , Qt::Key_Exclam);
- insert(DIKS_QUOTATION , Qt::Key_QuoteDbl);
- insert(DIKS_NUMBER_SIGN , Qt::Key_NumberSign);
- insert(DIKS_DOLLAR_SIGN , Qt::Key_Dollar);
- insert(DIKS_PERCENT_SIGN , Qt::Key_Percent);
- insert(DIKS_AMPERSAND , Qt::Key_Ampersand);
- insert(DIKS_APOSTROPHE , Qt::Key_Apostrophe);
- insert(DIKS_PARENTHESIS_LEFT , Qt::Key_ParenLeft);
- insert(DIKS_PARENTHESIS_RIGHT , Qt::Key_ParenRight);
- insert(DIKS_ASTERISK , Qt::Key_Asterisk);
- insert(DIKS_PLUS_SIGN , Qt::Key_Plus);
- insert(DIKS_COMMA , Qt::Key_Comma);
- insert(DIKS_MINUS_SIGN , Qt::Key_Minus);
- insert(DIKS_PERIOD , Qt::Key_Period);
- insert(DIKS_SLASH , Qt::Key_Slash);
- insert(DIKS_0 , Qt::Key_0);
- insert(DIKS_1 , Qt::Key_1);
- insert(DIKS_2 , Qt::Key_2);
- insert(DIKS_3 , Qt::Key_3);
- insert(DIKS_4 , Qt::Key_4);
- insert(DIKS_5 , Qt::Key_5);
- insert(DIKS_6 , Qt::Key_6);
- insert(DIKS_7 , Qt::Key_7);
- insert(DIKS_8 , Qt::Key_8);
- insert(DIKS_9 , Qt::Key_9);
- insert(DIKS_COLON , Qt::Key_Colon);
- insert(DIKS_SEMICOLON , Qt::Key_Semicolon);
- insert(DIKS_LESS_THAN_SIGN , Qt::Key_Less);
- insert(DIKS_EQUALS_SIGN , Qt::Key_Equal);
- insert(DIKS_GREATER_THAN_SIGN , Qt::Key_Greater);
- insert(DIKS_QUESTION_MARK , Qt::Key_Question);
- insert(DIKS_AT , Qt::Key_At);
- insert(DIKS_CAPITAL_A , Qt::Key_A);
- insert(DIKS_CAPITAL_B , Qt::Key_B);
- insert(DIKS_CAPITAL_C , Qt::Key_C);
- insert(DIKS_CAPITAL_D , Qt::Key_D);
- insert(DIKS_CAPITAL_E , Qt::Key_E);
- insert(DIKS_CAPITAL_F , Qt::Key_F);
- insert(DIKS_CAPITAL_G , Qt::Key_G);
- insert(DIKS_CAPITAL_H , Qt::Key_H);
- insert(DIKS_CAPITAL_I , Qt::Key_I);
- insert(DIKS_CAPITAL_J , Qt::Key_J);
- insert(DIKS_CAPITAL_K , Qt::Key_K);
- insert(DIKS_CAPITAL_L , Qt::Key_L);
- insert(DIKS_CAPITAL_M , Qt::Key_M);
- insert(DIKS_CAPITAL_N , Qt::Key_N);
- insert(DIKS_CAPITAL_O , Qt::Key_O);
- insert(DIKS_CAPITAL_P , Qt::Key_P);
- insert(DIKS_CAPITAL_Q , Qt::Key_Q);
- insert(DIKS_CAPITAL_R , Qt::Key_R);
- insert(DIKS_CAPITAL_S , Qt::Key_S);
- insert(DIKS_CAPITAL_T , Qt::Key_T);
- insert(DIKS_CAPITAL_U , Qt::Key_U);
- insert(DIKS_CAPITAL_V , Qt::Key_V);
- insert(DIKS_CAPITAL_W , Qt::Key_W);
- insert(DIKS_CAPITAL_X , Qt::Key_X);
- insert(DIKS_CAPITAL_Y , Qt::Key_Y);
- insert(DIKS_CAPITAL_Z , Qt::Key_Z);
- insert(DIKS_SQUARE_BRACKET_LEFT , Qt::Key_BracketLeft);
- insert(DIKS_BACKSLASH , Qt::Key_Backslash);
- insert(DIKS_SQUARE_BRACKET_RIGHT , Qt::Key_BracketRight);
- insert(DIKS_CIRCUMFLEX_ACCENT , Qt::Key_AsciiCircum);
- insert(DIKS_UNDERSCORE , Qt::Key_Underscore);
- insert(DIKS_SMALL_A , Qt::Key_A);
- insert(DIKS_SMALL_B , Qt::Key_B);
- insert(DIKS_SMALL_C , Qt::Key_C);
- insert(DIKS_SMALL_D , Qt::Key_D);
- insert(DIKS_SMALL_E , Qt::Key_E);
- insert(DIKS_SMALL_F , Qt::Key_F);
- insert(DIKS_SMALL_G , Qt::Key_G);
- insert(DIKS_SMALL_H , Qt::Key_H);
- insert(DIKS_SMALL_I , Qt::Key_I);
- insert(DIKS_SMALL_J , Qt::Key_J);
- insert(DIKS_SMALL_K , Qt::Key_K);
- insert(DIKS_SMALL_L , Qt::Key_L);
- insert(DIKS_SMALL_M , Qt::Key_M);
- insert(DIKS_SMALL_N , Qt::Key_N);
- insert(DIKS_SMALL_O , Qt::Key_O);
- insert(DIKS_SMALL_P , Qt::Key_P);
- insert(DIKS_SMALL_Q , Qt::Key_Q);
- insert(DIKS_SMALL_R , Qt::Key_R);
- insert(DIKS_SMALL_S , Qt::Key_S);
- insert(DIKS_SMALL_T , Qt::Key_T);
- insert(DIKS_SMALL_U , Qt::Key_U);
- insert(DIKS_SMALL_V , Qt::Key_V);
- insert(DIKS_SMALL_W , Qt::Key_W);
- insert(DIKS_SMALL_X , Qt::Key_X);
- insert(DIKS_SMALL_Y , Qt::Key_Y);
- insert(DIKS_SMALL_Z , Qt::Key_Z);
- insert(DIKS_CURLY_BRACKET_LEFT , Qt::Key_BraceLeft);
- insert(DIKS_VERTICAL_BAR , Qt::Key_Bar);
- insert(DIKS_CURLY_BRACKET_RIGHT , Qt::Key_BraceRight);
- insert(DIKS_TILDE , Qt::Key_AsciiTilde);
-}
-
-QT_END_NAMESPACE
-#include "qdirectfbkeyboard.moc"
-#endif // QT_NO_QWS_DIRECTFB
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h b/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h
deleted file mode 100644
index 49c1c18b22..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbkeyboard.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDIRECTFBKEYBOARD_H
-#define QDIRECTFBKEYBOARD_H
-
-#include <qglobal.h>
-#include <QtGui/qkbd_qws.h>
-
-#ifndef QT_NO_QWS_DIRECTFB
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QDirectFBKeyboardHandlerPrivate;
-
-class QDirectFBKeyboardHandler : public QWSKeyboardHandler
-{
-public:
- QDirectFBKeyboardHandler(const QString &device);
- ~QDirectFBKeyboardHandler();
-
-private:
- QDirectFBKeyboardHandlerPrivate *d;
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_DIRECTFB
-
-QT_END_HEADER
-
-#endif // QDIRECTFBKEYBOARD_H
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp
deleted file mode 100644
index 3999b85afb..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.cpp
+++ /dev/null
@@ -1,294 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdirectfbmouse.h"
-
-#ifndef QT_NO_QWS_DIRECTFB
-
-#include "qdirectfbscreen.h"
-#include <qsocketnotifier.h>
-
-#include <directfb.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <errno.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDirectFBMouseHandlerPrivate : public QObject
-{
- Q_OBJECT
-public:
- QDirectFBMouseHandlerPrivate(QDirectFBMouseHandler *h);
- ~QDirectFBMouseHandlerPrivate();
-
- void setEnabled(bool on);
-private:
- QDirectFBMouseHandler *handler;
- IDirectFBEventBuffer *eventBuffer;
-#ifndef QT_NO_DIRECTFB_LAYER
- IDirectFBDisplayLayer *layer;
-#endif
- QSocketNotifier *mouseNotifier;
-
- QPoint prevPoint;
- Qt::MouseButtons prevbuttons;
-
- DFBEvent event;
- uint bytesRead;
-
-private Q_SLOTS:
- void readMouseData();
-};
-
-QDirectFBMouseHandlerPrivate::QDirectFBMouseHandlerPrivate(QDirectFBMouseHandler *h)
- : handler(h), eventBuffer(0)
-{
- DFBResult result;
-
- QScreen *screen = QScreen::instance();
- if (!screen) {
- qCritical("QDirectFBMouseHandler: no screen instance found");
- return;
- }
-
- IDirectFB *fb = QDirectFBScreen::instance()->dfb();
- if (!fb) {
- qCritical("QDirectFBMouseHandler: DirectFB not initialized");
- return;
- }
-
-#ifndef QT_NO_DIRECTFB_LAYER
- layer = QDirectFBScreen::instance()->dfbDisplayLayer();
- if (!layer) {
- qCritical("QDirectFBMouseHandler: Unable to get primary display layer");
- return;
- }
-#endif
-
- DFBInputDeviceCapabilities caps;
- caps = DICAPS_BUTTONS | DICAPS_AXES;
- result = fb->CreateInputEventBuffer(fb, caps, DFB_TRUE, &eventBuffer);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBMouseHandler: "
- "Unable to create input event buffer", result);
- return;
- }
-
- int fd;
- result = eventBuffer->CreateFileDescriptor(eventBuffer, &fd);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBMouseHandler: "
- "Unable to create file descriptor", result);
- return;
- }
-
- int flags = fcntl(fd, F_GETFL, 0);
- fcntl(fd, F_SETFL, flags | O_NONBLOCK);
-
- // DirectFB seems to assume that the mouse always starts centered
- prevPoint = QPoint(screen->deviceWidth() / 2, screen->deviceHeight() / 2);
- prevbuttons = Qt::NoButton;
- memset(&event, 0, sizeof(event));
- bytesRead = 0;
-
- mouseNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this);
- connect(mouseNotifier, SIGNAL(activated(int)),this, SLOT(readMouseData()));
- setEnabled(true);
-}
-
-QDirectFBMouseHandlerPrivate::~QDirectFBMouseHandlerPrivate()
-{
- if (eventBuffer)
- eventBuffer->Release(eventBuffer);
-}
-
-void QDirectFBMouseHandlerPrivate::setEnabled(bool on)
-{
- if (mouseNotifier->isEnabled() != on) {
-#ifndef QT_NO_DIRECTFB_LAYER
- DFBResult result;
- result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::QDirectFBScreenCursor: "
- "Unable to set cooperative level", result);
- }
- result = layer->EnableCursor(layer, on ? 1 : 0);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::QDirectFBScreenCursor: "
- "Unable to enable cursor", result);
- }
-
- result = layer->SetCooperativeLevel(layer, DLSCL_SHARED);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::show: "
- "Unable to set cooperative level", result);
- }
-
- layer->SetCooperativeLevel(layer, DLSCL_SHARED);
-#endif
- mouseNotifier->setEnabled(on);
- }
-}
-
-void QDirectFBMouseHandlerPrivate::readMouseData()
-{
- if (!QScreen::instance())
- return;
-
- for (;;) {
- // GetEvent returns DFB_UNSUPPORTED after CreateFileDescriptor().
- // This seems stupid and I really hope it's a bug which will be fixed.
-
- // DFBResult ret = eventBuffer->GetEvent(eventBuffer, &event);
-
- char *buf = reinterpret_cast<char*>(&event);
- int ret = ::read(mouseNotifier->socket(),
- buf + bytesRead, sizeof(DFBEvent) - bytesRead);
- if (ret == -1) {
- if (errno == EINTR)
- continue;
- if (errno == EAGAIN)
- return;
- qWarning("QDirectFBMouseHandlerPrivate::readMouseData(): %s",
- strerror(errno));
- return;
- }
-
- Q_ASSERT(ret >= 0);
- bytesRead += ret;
- if (bytesRead < sizeof(DFBEvent))
- break;
- bytesRead = 0;
-
- Q_ASSERT(event.clazz == DFEC_INPUT);
-
- const DFBInputEvent input = event.input;
- int x = prevPoint.x();
- int y = prevPoint.y();
- int wheel = 0;
-
- if (input.type == DIET_AXISMOTION) {
-#if defined(QT_NO_DIRECTFB_LAYER) || defined(QT_DIRECTFB_WINDOW_AS_CURSOR)
- if (input.flags & DIEF_AXISABS) {
- switch (input.axis) {
- case DIAI_X: x = input.axisabs; break;
- case DIAI_Y: y = input.axisabs; break;
- default:
- qWarning("QDirectFBMouseHandlerPrivate::readMouseData: "
- "unknown axis (absolute) %d", input.axis);
- break;
- }
- } else if (input.flags & DIEF_AXISREL) {
- switch (input.axis) {
- case DIAI_X: x += input.axisrel; break;
- case DIAI_Y: y += input.axisrel; break;
- case DIAI_Z: wheel = -120 * input.axisrel; break;
- default:
- qWarning("QDirectFBMouseHandlerPrivate::readMouseData: "
- "unknown axis (releative) %d", input.axis);
- }
- }
-#else
- if (input.axis == DIAI_X || input.axis == DIAI_Y) {
- DFBResult result = layer->GetCursorPosition(layer, &x, &y);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBMouseHandler::readMouseData",
- result);
- }
- } else if (input.axis == DIAI_Z) {
- Q_ASSERT(input.flags & DIEF_AXISREL);
- wheel = input.axisrel;
- wheel *= -120;
- }
-#endif
- }
-
- Qt::MouseButtons buttons = Qt::NoButton;
- if (input.flags & DIEF_BUTTONS) {
- if (input.buttons & DIBM_LEFT)
- buttons |= Qt::LeftButton;
- if (input.buttons & DIBM_MIDDLE)
- buttons |= Qt::MidButton;
- if (input.buttons & DIBM_RIGHT)
- buttons |= Qt::RightButton;
- }
-
- QPoint p = QPoint(x, y);
- handler->limitToScreen(p);
-
- if (p == prevPoint && wheel == 0 && buttons == prevbuttons)
- continue;
-
- prevPoint = p;
- prevbuttons = buttons;
-
- handler->mouseChanged(p, buttons, wheel);
- }
-}
-
-QDirectFBMouseHandler::QDirectFBMouseHandler(const QString &driver,
- const QString &device)
- : QWSMouseHandler(driver, device)
-{
- d = new QDirectFBMouseHandlerPrivate(this);
-}
-
-QDirectFBMouseHandler::~QDirectFBMouseHandler()
-{
- delete d;
-}
-
-void QDirectFBMouseHandler::suspend()
-{
- d->setEnabled(false);
-}
-
-void QDirectFBMouseHandler::resume()
-{
- d->setEnabled(true);
-}
-
-QT_END_NAMESPACE
-#include "qdirectfbmouse.moc"
-#endif // QT_NO_QWS_DIRECTFB
-
-
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h b/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h
deleted file mode 100644
index ac0fcadfaa..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbmouse.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDIRECTFBMOUSE_H
-#define QDIRECTFBMOUSE_H
-
-#include <qglobal.h>
-#include <QtGui/qmouse_qws.h>
-
-#ifndef QT_NO_QWS_DIRECTFB
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QDirectFBMouseHandlerPrivate;
-
-class QDirectFBMouseHandler : public QWSMouseHandler
-{
-public:
- explicit QDirectFBMouseHandler(const QString &driver = QString(),
- const QString &device = QString());
- ~QDirectFBMouseHandler();
-
- void suspend();
- void resume();
-protected:
- QDirectFBMouseHandlerPrivate *d;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-#endif // QT_NO_QWS_DIRECTFB
-#endif // QDIRECTFBMOUSE_H
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
deleted file mode 100644
index 10f1bb3f46..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.cpp
+++ /dev/null
@@ -1,221 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdirectfbscreen.h"
-#include "qdirectfbpaintdevice.h"
-#include "qdirectfbpaintengine.h"
-
-#ifndef QT_NO_QWS_DIRECTFB
-
-QT_BEGIN_NAMESPACE
-
-QDirectFBPaintDevice::QDirectFBPaintDevice(QDirectFBScreen *scr)
- : QCustomRasterPaintDevice(0), dfbSurface(0), screen(scr),
- bpl(-1), lockFlgs(DFBSurfaceLockFlags(0)), mem(0), engine(0), imageFormat(QImage::Format_Invalid)
-{
-#ifdef QT_DIRECTFB_SUBSURFACE
- subSurface = 0;
- syncPending = false;
-#endif
-}
-
-QDirectFBPaintDevice::~QDirectFBPaintDevice()
-{
- if (QDirectFBScreen::instance()) {
- unlockSurface();
-#ifdef QT_DIRECTFB_SUBSURFACE
- releaseSubSurface();
-#endif
- if (dfbSurface) {
- screen->releaseDFBSurface(dfbSurface);
- }
- }
- delete engine;
-}
-
-IDirectFBSurface *QDirectFBPaintDevice::directFBSurface() const
-{
- return dfbSurface;
-}
-
-bool QDirectFBPaintDevice::lockSurface(DFBSurfaceLockFlags lockFlags)
-{
- if (lockFlgs && (lockFlags & ~lockFlgs))
- unlockSurface();
- if (!mem) {
- Q_ASSERT(dfbSurface);
-#ifdef QT_DIRECTFB_SUBSURFACE
- if (!subSurface) {
- DFBResult result;
- subSurface = screen->getSubSurface(dfbSurface, QRect(), QDirectFBScreen::TrackSurface, &result);
- if (result != DFB_OK || !subSurface) {
- DirectFBError("Couldn't create sub surface", result);
- return false;
- }
- }
- IDirectFBSurface *surface = subSurface;
-#else
- IDirectFBSurface *surface = dfbSurface;
-#endif
- Q_ASSERT(surface);
- mem = QDirectFBScreen::lockSurface(surface, lockFlags, &bpl);
- lockFlgs = lockFlags;
- Q_ASSERT(mem);
- Q_ASSERT(bpl > 0);
- const QSize s = size();
- lockedImage = QImage(mem, s.width(), s.height(), bpl,
- QDirectFBScreen::getImageFormat(dfbSurface));
- return true;
- }
-#ifdef QT_DIRECTFB_SUBSURFACE
- if (syncPending) {
- syncPending = false;
- screen->waitIdle();
- }
-#endif
- return false;
-}
-
-void QDirectFBPaintDevice::unlockSurface()
-{
- if (QDirectFBScreen::instance() && lockFlgs) {
-#ifdef QT_DIRECTFB_SUBSURFACE
- IDirectFBSurface *surface = subSurface;
-#else
- IDirectFBSurface *surface = dfbSurface;
-#endif
- if (surface) {
- surface->Unlock(surface);
- lockFlgs = static_cast<DFBSurfaceLockFlags>(0);
- mem = 0;
- }
- }
-}
-
-void *QDirectFBPaintDevice::memory() const
-{
- return mem;
-}
-
-QImage::Format QDirectFBPaintDevice::format() const
-{
- return imageFormat;
-}
-
-int QDirectFBPaintDevice::bytesPerLine() const
-{
- Q_ASSERT(!mem || bpl != -1);
- return bpl;
-}
-
-QSize QDirectFBPaintDevice::size() const
-{
- int w, h;
- dfbSurface->GetSize(dfbSurface, &w, &h);
- return QSize(w, h);
-}
-
-int QDirectFBPaintDevice::metric(QPaintDevice::PaintDeviceMetric metric) const
-{
- if (!dfbSurface)
- return 0;
-
- switch (metric) {
- case QPaintDevice::PdmWidth:
- case QPaintDevice::PdmHeight:
- return (metric == PdmWidth ? size().width() : size().height());
- case QPaintDevice::PdmWidthMM:
- return (size().width() * 1000) / dotsPerMeterX();
- case QPaintDevice::PdmHeightMM:
- return (size().height() * 1000) / dotsPerMeterY();
- case QPaintDevice::PdmPhysicalDpiX:
- case QPaintDevice::PdmDpiX:
- return (dotsPerMeterX() * 254) / 10000; // 0.0254 meters-per-inch
- case QPaintDevice::PdmPhysicalDpiY:
- case QPaintDevice::PdmDpiY:
- return (dotsPerMeterY() * 254) / 10000; // 0.0254 meters-per-inch
- case QPaintDevice::PdmDepth:
- return QDirectFBScreen::depth(imageFormat);
- case QPaintDevice::PdmNumColors: {
- if (!lockedImage.isNull())
- return lockedImage.colorCount();
-
- DFBResult result;
- IDirectFBPalette *palette = 0;
- unsigned int numColors = 0;
-
- result = dfbSurface->GetPalette(dfbSurface, &palette);
- if ((result != DFB_OK) || !palette)
- return 0;
-
- result = palette->GetSize(palette, &numColors);
- palette->Release(palette);
- if (result != DFB_OK)
- return 0;
-
- return numColors;
- }
- default:
- qCritical("QDirectFBPaintDevice::metric(): Unhandled metric!");
- return 0;
- }
-}
-
-QPaintEngine *QDirectFBPaintDevice::paintEngine() const
-{
- return engine;
-}
-
-#ifdef QT_DIRECTFB_SUBSURFACE
-void QDirectFBPaintDevice::releaseSubSurface()
-{
- Q_ASSERT(QDirectFBScreen::instance());
- if (subSurface) {
- unlockSurface();
- screen->releaseDFBSurface(subSurface);
- subSurface = 0;
- }
-}
-#endif
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_DIRECTFB
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h
deleted file mode 100644
index 71a7a8e104..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintdevice.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDIRECTFBPAINTDEVICE_H
-#define QDIRECTFBPAINTDEVICE_H
-
-#include <private/qpaintengine_raster_p.h>
-#include "qdirectfbscreen.h"
-
-#ifndef QT_NO_QWS_DIRECTFB
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-// Inherited by both window surface and pixmap
-class QDirectFBPaintEngine;
-class QDirectFBPaintDevice : public QCustomRasterPaintDevice
-{
-public:
- ~QDirectFBPaintDevice();
-
- virtual IDirectFBSurface *directFBSurface() const;
-
- bool lockSurface(DFBSurfaceLockFlags lockFlags);
- void unlockSurface();
-
- // Reimplemented from QCustomRasterPaintDevice:
- void *memory() const;
- QImage::Format format() const;
- int bytesPerLine() const;
- QSize size() const;
- int metric(QPaintDevice::PaintDeviceMetric metric) const;
- DFBSurfaceLockFlags lockFlags() const { return lockFlgs; }
- QPaintEngine *paintEngine() const;
-protected:
- QDirectFBPaintDevice(QDirectFBScreen *scr);
- inline int dotsPerMeterX() const
- {
- return (screen->deviceWidth() * 1000) / screen->physicalWidth();
- }
- inline int dotsPerMeterY() const
- {
- return (screen->deviceHeight() * 1000) / screen->physicalHeight();
- }
-
- IDirectFBSurface *dfbSurface;
-#ifdef QT_DIRECTFB_SUBSURFACE
- void releaseSubSurface();
- IDirectFBSurface *subSurface;
- friend class QDirectFBPaintEnginePrivate;
- bool syncPending;
-#endif
- QImage lockedImage;
- QDirectFBScreen *screen;
- int bpl;
- DFBSurfaceLockFlags lockFlgs;
- uchar *mem;
- QDirectFBPaintEngine *engine;
- QImage::Format imageFormat;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_QWS_DIRECTFB
-#endif //QDIRECTFBPAINTDEVICE_H
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
deleted file mode 100644
index 6d6fb02a68..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.cpp
+++ /dev/null
@@ -1,1430 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdirectfbpaintengine.h"
-
-#ifndef QT_NO_QWS_DIRECTFB
-
-#include "qdirectfbwindowsurface.h"
-#include "qdirectfbscreen.h"
-#include "qdirectfbpixmap.h"
-#include <directfb.h>
-#include <qtransform.h>
-#include <qvarlengtharray.h>
-#include <qcache.h>
-#include <qmath.h>
-#include <private/qpixmapdata_p.h>
-#include <private/qpixmap_raster_p.h>
-#include <private/qimagepixmapcleanuphooks_p.h>
-
-
-QT_BEGIN_NAMESPACE
-
-class SurfaceCache;
-class QDirectFBPaintEnginePrivate : public QRasterPaintEnginePrivate
-{
-public:
- enum TransformationTypeFlags {
- Matrix_NegativeScale = 0x100,
- Matrix_RectsUnsupported = (QTransform::TxRotate|QTransform::TxShear|QTransform::TxProject),
- Matrix_BlitsUnsupported = (Matrix_NegativeScale|Matrix_RectsUnsupported)
- };
-
- inline static uint getTransformationType(const QTransform &transform)
- {
- int ret = transform.type();
- if (qMin(transform.m11(), transform.m22()) < 0) {
- ret |= QDirectFBPaintEnginePrivate::Matrix_NegativeScale;
- }
- return ret;
- }
-
- enum CompositionModeStatus {
- PorterDuff_None = 0x0,
- PorterDuff_Supported = 0x1,
- PorterDuff_PremultiplyColors = 0x2,
- PorterDuff_AlwaysBlend = 0x4
- };
-
- enum ClipType {
- ClipUnset,
- NoClip,
- RectClip,
- RegionClip,
- ComplexClip
- };
-
- QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p);
- ~QDirectFBPaintEnginePrivate();
-
- inline void setTransform(const QTransform &transforma);
- inline void setPen(const QPen &pen);
- inline void setCompositionMode(QPainter::CompositionMode mode);
- inline void setRenderHints(QPainter::RenderHints hints);
-
- inline void setDFBColor(const QColor &color);
-
- inline void lock();
- inline void unlock();
- static inline void unlock(QDirectFBPaintDevice *device);
-
- inline bool isSimpleBrush(const QBrush &brush) const;
-
- void drawTiledPixmap(const QRectF &dest, const QPixmap &pixmap, const QPointF &pos, const QTransform &pixmapTransform);
- void blit(const QRectF &dest, IDirectFBSurface *surface, const QRectF &src);
-
- inline bool supportsStretchBlit() const;
-
- inline void updateClip();
- virtual void systemStateChanged();
-
- static IDirectFBSurface *getSurface(const QImage &img, bool *release);
-
-#ifdef QT_DIRECTFB_IMAGECACHE
- static inline int cacheCost(const QImage &img) { return img.width() * img.height() * img.depth() / 8; }
-#endif
-
- enum BlitFlag {
- HasAlpha = 0x1,
- Premultiplied = 0x2
- };
- void prepareForBlit(uint blitFlags);
-
- IDirectFBSurface *surface;
-
- bool antialiased;
- bool simplePen;
-
- uint transformationType; // this is QTransform::type() + Matrix_NegativeScale if qMin(transform.m11(), transform.m22()) < 0
-
- SurfaceCache *surfaceCache;
- IDirectFB *fb;
- quint8 opacity;
-
- ClipType clipType;
- QDirectFBPaintDevice *dfbDevice;
- uint compositionModeStatus;
- bool isPremultiplied;
-
- bool inClip;
- QRect currentClip;
-
- QDirectFBPaintEngine *q;
-};
-
-class SurfaceCache
-{
-public:
- SurfaceCache() : surface(0), buffer(0), bufsize(0) {}
- ~SurfaceCache() { clear(); }
- IDirectFBSurface *getSurface(const uint *buf, int size);
- void clear();
-private:
- IDirectFBSurface *surface;
- uint *buffer;
- int bufsize;
-};
-
-
-#ifdef QT_DIRECTFB_IMAGECACHE
-QT_BEGIN_INCLUDE_NAMESPACE
-#include <private/qimage_p.h>
-QT_END_INCLUDE_NAMESPACE
-struct CachedImage
-{
- IDirectFBSurface *surface;
- ~CachedImage()
- {
- if (surface && QDirectFBScreen::instance()) {
- QDirectFBScreen::instance()->releaseDFBSurface(surface);
- }
- }
-};
-static QCache<qint64, CachedImage> imageCache(4*1024*1024); // 4 MB
-#endif
-
-#define VOID_ARG() static_cast<bool>(false)
-enum PaintOperation {
- DRAW_RECTS = 0x0001, DRAW_LINES = 0x0002, DRAW_IMAGE = 0x0004,
- DRAW_PIXMAP = 0x0008, DRAW_TILED_PIXMAP = 0x0010, STROKE_PATH = 0x0020,
- DRAW_PATH = 0x0040, DRAW_POINTS = 0x0080, DRAW_ELLIPSE = 0x0100,
- DRAW_POLYGON = 0x0200, DRAW_TEXT = 0x0400, FILL_PATH = 0x0800,
- FILL_RECT = 0x1000, DRAW_COLORSPANS = 0x2000, DRAW_ROUNDED_RECT = 0x4000,
- DRAW_STATICTEXT = 0x8000, ALL = 0xffff
-};
-
-enum { RasterWarn = 1, RasterDisable = 2 };
-static inline uint rasterFallbacksMask(PaintOperation op)
-{
- uint ret = 0;
-#ifdef QT_DIRECTFB_WARN_ON_RASTERFALLBACKS
- if (op & QT_DIRECTFB_WARN_ON_RASTERFALLBACKS)
- ret |= RasterWarn;
-#endif
-#ifdef QT_DIRECTFB_DISABLE_RASTERFALLBACKS
- if (op & QT_DIRECTFB_DISABLE_RASTERFALLBACKS)
- ret |= RasterDisable;
-#endif
- static int warningMask = -1;
- static int disableMask = -1;
- if (warningMask < 0) {
- struct {
- const char *name;
- PaintOperation operation;
- } const operations[] = {
- { "DRAW_RECTS", DRAW_RECTS },
- { "DRAW_LINES", DRAW_LINES },
- { "DRAW_IMAGE", DRAW_IMAGE },
- { "DRAW_PIXMAP", DRAW_PIXMAP },
- { "DRAW_TILED_PIXMAP", DRAW_TILED_PIXMAP },
- { "STROKE_PATH", STROKE_PATH },
- { "DRAW_PATH", DRAW_PATH },
- { "DRAW_POINTS", DRAW_POINTS },
- { "DRAW_ELLIPSE", DRAW_ELLIPSE },
- { "DRAW_POLYGON", DRAW_POLYGON },
- { "DRAW_TEXT", DRAW_TEXT },
- { "FILL_PATH", FILL_PATH },
- { "FILL_RECT", FILL_RECT },
- { "DRAW_COLORSPANS", DRAW_COLORSPANS },
- { "DRAW_ROUNDED_RECT", DRAW_ROUNDED_RECT },
- { "ALL", ALL },
- { 0, ALL }
- };
-
- QStringList warning = QString::fromLatin1(qgetenv("QT_DIRECTFB_WARN_ON_RASTERFALLBACKS")).toUpper().split(QLatin1Char('|'),
- QString::SkipEmptyParts);
- QStringList disable = QString::fromLatin1(qgetenv("QT_DIRECTFB_DISABLE_RASTERFALLBACKS")).toUpper().split(QLatin1Char('|'),
- QString::SkipEmptyParts);
- warningMask = 0;
- disableMask = 0;
- if (!warning.isEmpty() || !disable.isEmpty()) {
- for (int i=0; operations[i].name; ++i) {
- const QString name = QString::fromLatin1(operations[i].name);
- int idx = warning.indexOf(name);
- if (idx != -1) {
- warningMask |= operations[i].operation;
- warning.erase(warning.begin() + idx);
- }
- idx = disable.indexOf(name);
- if (idx != -1) {
- disableMask |= operations[i].operation;
- disable.erase(disable.begin() + idx);
- }
- }
- }
- if (!warning.isEmpty()) {
- qWarning("QDirectFBPaintEngine QT_DIRECTFB_WARN_ON_RASTERFALLBACKS Unknown operation(s): %s",
- qPrintable(warning.join(QLatin1String("|"))));
- }
- if (!disable.isEmpty()) {
- qWarning("QDirectFBPaintEngine QT_DIRECTFB_DISABLE_RASTERFALLBACKS Unknown operation(s): %s",
- qPrintable(disable.join(QLatin1String("|"))));
- }
- }
- if (op & warningMask)
- ret |= RasterWarn;
- if (op & disableMask)
- ret |= RasterDisable;
- return ret;
-}
-
-template <typename device, typename T1, typename T2, typename T3>
-static void rasterFallbackWarn(const char *msg, const char *func, const device *dev,
- uint transformationType, bool simplePen,
- uint clipType, uint compositionModeStatus,
- const char *nameOne, const T1 &one,
- const char *nameTwo, const T2 &two,
- const char *nameThree, const T3 &three);
-
-#define RASTERFALLBACK(op, one, two, three) \
- { \
- static const uint rasterFallbacks = rasterFallbacksMask(op); \
- switch (rasterFallbacks) { \
- case 0: break; \
- case RasterWarn: \
- rasterFallbackWarn("Falling back to raster engine for", \
- __FUNCTION__, \
- state()->painter->device(), \
- d_func()->transformationType, \
- d_func()->simplePen, \
- d_func()->clipType, \
- d_func()->compositionModeStatus, \
- #one, one, #two, two, #three, three); \
- break; \
- case RasterDisable|RasterWarn: \
- rasterFallbackWarn("Disabled raster engine operation", \
- __FUNCTION__, \
- state()->painter->device(), \
- d_func()->transformationType, \
- d_func()->simplePen, \
- d_func()->clipType, \
- d_func()->compositionModeStatus, \
- #one, one, #two, two, #three, three); \
- case RasterDisable: \
- return; \
- } \
- }
-
-template <class T>
-static inline void drawLines(const T *lines, int n, const QTransform &transform, IDirectFBSurface *surface);
-template <class T>
-static inline void fillRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface);
-template <class T>
-static inline void drawRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface);
-
-#define CLIPPED_PAINT(operation) { \
- d->unlock(); \
- DFBRegion clipRegion; \
- switch (d->clipType) { \
- case QDirectFBPaintEnginePrivate::NoClip: \
- case QDirectFBPaintEnginePrivate::RectClip: \
- operation; \
- break; \
- case QDirectFBPaintEnginePrivate::RegionClip: { \
- Q_ASSERT(d->clip()); \
- const QVector<QRect> cr = d->clip()->clipRegion.rects(); \
- const int size = cr.size(); \
- for (int i=0; i<size; ++i) { \
- d->currentClip = cr.at(i); \
- clipRegion.x1 = d->currentClip.x(); \
- clipRegion.y1 = d->currentClip.y(); \
- clipRegion.x2 = d->currentClip.right(); \
- clipRegion.y2 = d->currentClip.bottom(); \
- d->surface->SetClip(d->surface, &clipRegion); \
- operation; \
- } \
- d->updateClip(); \
- break; } \
- case QDirectFBPaintEnginePrivate::ComplexClip: \
- case QDirectFBPaintEnginePrivate::ClipUnset: \
- qFatal("CLIPPED_PAINT internal error %d", d->clipType); \
- break; \
- } \
- }
-
-
-QDirectFBPaintEngine::QDirectFBPaintEngine(QPaintDevice *device)
- : QRasterPaintEngine(*(new QDirectFBPaintEnginePrivate(this)), device)
-{
-}
-
-QDirectFBPaintEngine::~QDirectFBPaintEngine()
-{
-}
-
-bool QDirectFBPaintEngine::begin(QPaintDevice *device)
-{
- Q_D(QDirectFBPaintEngine);
- if (device->devType() == QInternal::CustomRaster) {
- d->dfbDevice = static_cast<QDirectFBPaintDevice*>(device);
- } else if (device->devType() == QInternal::Pixmap) {
- QPixmapData *data = static_cast<QPixmap*>(device)->pixmapData();
- Q_ASSERT(data->classId() == QPixmapData::DirectFBClass);
- QDirectFBPixmapData *dfbPixmapData = static_cast<QDirectFBPixmapData*>(data);
- QDirectFBPaintEnginePrivate::unlock(dfbPixmapData);
- d->dfbDevice = static_cast<QDirectFBPaintDevice*>(dfbPixmapData);
- }
-
- if (d->dfbDevice)
- d->surface = d->dfbDevice->directFBSurface();
-
- if (!d->surface) {
- qFatal("QDirectFBPaintEngine used on an invalid device: 0x%x",
- device->devType());
- }
- d->isPremultiplied = QDirectFBScreen::isPremultiplied(d->dfbDevice->format());
-
- d->prepare(d->dfbDevice);
- gccaps = AllFeatures;
- d->setCompositionMode(state()->composition_mode);
-
- return QRasterPaintEngine::begin(device);
-}
-
-bool QDirectFBPaintEngine::end()
-{
- Q_D(QDirectFBPaintEngine);
- d->unlock();
- d->dfbDevice = 0;
-#if (Q_DIRECTFB_VERSION >= 0x010000)
- d->surface->ReleaseSource(d->surface);
-#endif
- d->currentClip = QRect();
- d->surface->SetClip(d->surface, NULL);
- d->surface = 0;
- return QRasterPaintEngine::end();
-}
-
-void QDirectFBPaintEngine::clipEnabledChanged()
-{
- Q_D(QDirectFBPaintEngine);
- QRasterPaintEngine::clipEnabledChanged();
- d->updateClip();
-}
-
-void QDirectFBPaintEngine::penChanged()
-{
- Q_D(QDirectFBPaintEngine);
- d->setPen(state()->pen);
-
- QRasterPaintEngine::penChanged();
-}
-
-void QDirectFBPaintEngine::opacityChanged()
-{
- Q_D(QDirectFBPaintEngine);
- d->opacity = quint8(state()->opacity * 255);
- QRasterPaintEngine::opacityChanged();
-}
-
-void QDirectFBPaintEngine::compositionModeChanged()
-{
- Q_D(QDirectFBPaintEngine);
- d->setCompositionMode(state()->compositionMode());
- QRasterPaintEngine::compositionModeChanged();
-}
-
-void QDirectFBPaintEngine::renderHintsChanged()
-{
- Q_D(QDirectFBPaintEngine);
- d->setRenderHints(state()->renderHints);
- QRasterPaintEngine::renderHintsChanged();
-}
-
-void QDirectFBPaintEngine::transformChanged()
-{
- Q_D(QDirectFBPaintEngine);
- d->setTransform(state()->matrix);
- QRasterPaintEngine::transformChanged();
-}
-
-void QDirectFBPaintEngine::setState(QPainterState *state)
-{
- Q_D(QDirectFBPaintEngine);
- QRasterPaintEngine::setState(state);
- d->setPen(state->pen);
- d->opacity = quint8(state->opacity * 255);
- d->setCompositionMode(state->compositionMode());
- d->setTransform(state->transform());
- d->setRenderHints(state->renderHints);
- if (d->surface)
- d->updateClip();
-}
-
-void QDirectFBPaintEngine::clip(const QVectorPath &path, Qt::ClipOperation op)
-{
- Q_D(QDirectFBPaintEngine);
- const bool wasInClip = d->inClip;
- d->inClip = true;
- QRasterPaintEngine::clip(path, op);
- if (!wasInClip) {
- d->inClip = false;
- d->updateClip();
- }
-}
-
-void QDirectFBPaintEngine::clip(const QRegion &region, Qt::ClipOperation op)
-{
- Q_D(QDirectFBPaintEngine);
- const bool wasInClip = d->inClip;
- d->inClip = true;
- QRasterPaintEngine::clip(region, op);
- if (!wasInClip) {
- d->inClip = false;
- d->updateClip();
- }
-}
-
-void QDirectFBPaintEngine::clip(const QRect &rect, Qt::ClipOperation op)
-{
- Q_D(QDirectFBPaintEngine);
- const bool wasInClip = d->inClip;
- d->inClip = true;
- QRasterPaintEngine::clip(rect, op);
- if (!wasInClip) {
- d->inClip = false;
- d->updateClip();
- }
-}
-
-void QDirectFBPaintEngine::drawRects(const QRect *rects, int rectCount)
-{
- Q_D(QDirectFBPaintEngine);
- const QPen &pen = state()->pen;
- const QBrush &brush = state()->brush;
- if (brush.style() == Qt::NoBrush && pen.style() == Qt::NoPen)
- return;
-
- if ((d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported)
- || !d->simplePen
- || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip
- || !d->isSimpleBrush(brush)
- || !(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)) {
- RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG());
- d->lock();
- QRasterPaintEngine::drawRects(rects, rectCount);
- return;
- }
-
- if (brush.style() != Qt::NoBrush) {
- d->setDFBColor(brush.color());
- CLIPPED_PAINT(QT_PREPEND_NAMESPACE(fillRects<QRect>)(rects, rectCount, state()->matrix, d->surface));
- }
-
- if (pen.style() != Qt::NoPen) {
- d->setDFBColor(pen.color());
- CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawRects<QRect>)(rects, rectCount, state()->matrix, d->surface));
- }
-}
-
-void QDirectFBPaintEngine::drawRects(const QRectF *rects, int rectCount)
-{
- Q_D(QDirectFBPaintEngine);
- const QPen &pen = state()->pen;
- const QBrush &brush = state()->brush;
- if (brush.style() == Qt::NoBrush && pen.style() == Qt::NoPen)
- return;
-
- if ((d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported)
- || !d->simplePen
- || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip
- || !d->isSimpleBrush(brush)
- || !(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)) {
- RASTERFALLBACK(DRAW_RECTS, rectCount, VOID_ARG(), VOID_ARG());
- d->lock();
- QRasterPaintEngine::drawRects(rects, rectCount);
- return;
- }
-
- if (brush.style() != Qt::NoBrush) {
- d->setDFBColor(brush.color());
- CLIPPED_PAINT(fillRects<QRectF>(rects, rectCount, state()->matrix, d->surface));
- }
-
- if (pen.style() != Qt::NoPen) {
- d->setDFBColor(pen.color());
- CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawRects<QRectF>)(rects, rectCount, state()->matrix, d->surface));
- }
-}
-
-void QDirectFBPaintEngine::drawLines(const QLine *lines, int lineCount)
-{
- Q_D(QDirectFBPaintEngine);
-
- const QPen &pen = state()->pen;
- if (!d->simplePen
- || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip
- || !(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)) {
- RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG());
- d->lock();
- QRasterPaintEngine::drawLines(lines, lineCount);
- return;
- }
-
- if (pen.style() != Qt::NoPen) {
- d->setDFBColor(pen.color());
- CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawLines<QLine>)(lines, lineCount, state()->matrix, d->surface));
- }
-}
-
-void QDirectFBPaintEngine::drawLines(const QLineF *lines, int lineCount)
-{
- Q_D(QDirectFBPaintEngine);
-
- const QPen &pen = state()->pen;
- if (!d->simplePen
- || d->clipType == QDirectFBPaintEnginePrivate::ComplexClip
- || !(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)) {
- RASTERFALLBACK(DRAW_LINES, lineCount, VOID_ARG(), VOID_ARG());
- d->lock();
- QRasterPaintEngine::drawLines(lines, lineCount);
- return;
- }
-
- if (pen.style() != Qt::NoPen) {
- d->setDFBColor(pen.color());
- CLIPPED_PAINT(QT_PREPEND_NAMESPACE(drawLines<QLineF>)(lines, lineCount, state()->matrix, d->surface));
- }
-}
-
-void QDirectFBPaintEngine::drawImage(const QRectF &r, const QImage &image,
- const QRectF &sr,
- Qt::ImageConversionFlags flags)
-{
- Q_D(QDirectFBPaintEngine);
- Q_UNUSED(flags);
-
- /* This is hard to read. The way it works is like this:
-
- - If you do not have support for preallocated surfaces and do not use an
- image cache we always fall back to raster engine.
-
- - If it's rotated/sheared/mirrored (negative scale) or we can't
- clip it we fall back to raster engine.
-
- - If we don't cache the image, but we do have support for
- preallocated surfaces we fall back to the raster engine if the
- image is in a format DirectFB can't handle.
-
- - If we do cache the image but don't have support for preallocated
- images and the cost of caching the image (bytes used) is higher
- than the max image cache size we fall back to raster engine.
- */
-
-#if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE
- if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)
- || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported)
- || (d->clipType == QDirectFBPaintEnginePrivate::ComplexClip)
- || (!d->supportsStretchBlit() && state()->matrix.mapRect(r).size() != sr.size())
-#ifndef QT_DIRECTFB_IMAGECACHE
- || (QDirectFBScreen::getSurfacePixelFormat(image.format()) == DSPF_UNKNOWN)
-#elif defined QT_NO_DIRECTFB_PREALLOCATED
- || (QDirectFBPaintEnginePrivate::cacheCost(image) > imageCache.maxCost())
-#endif
- )
-#endif
- {
- RASTERFALLBACK(DRAW_IMAGE, r, image.size(), sr);
- d->lock();
- QRasterPaintEngine::drawImage(r, image, sr, flags);
- return;
- }
-#if !defined QT_NO_DIRECTFB_PREALLOCATED || defined QT_DIRECTFB_IMAGECACHE
- bool release;
- IDirectFBSurface *imgSurface = d->getSurface(image, &release);
- uint blitFlags = 0;
- if (image.hasAlphaChannel())
- blitFlags |= QDirectFBPaintEnginePrivate::HasAlpha;
- if (QDirectFBScreen::isPremultiplied(image.format()))
- blitFlags |= QDirectFBPaintEnginePrivate::Premultiplied;
- d->prepareForBlit(blitFlags);
- CLIPPED_PAINT(d->blit(r, imgSurface, sr));
- if (release) {
-#if (Q_DIRECTFB_VERSION >= 0x010000)
- d->surface->ReleaseSource(d->surface);
-#endif
- imgSurface->Release(imgSurface);
- }
-#endif
-}
-
-void QDirectFBPaintEngine::drawImage(const QPointF &p, const QImage &img)
-{
- drawImage(QRectF(p, img.size()), img, img.rect());
-}
-
-void QDirectFBPaintEngine::drawPixmap(const QRectF &r, const QPixmap &pixmap,
- const QRectF &sr)
-{
- Q_D(QDirectFBPaintEngine);
-
- if (pixmap.pixmapData()->classId() != QPixmapData::DirectFBClass) {
- RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr);
- d->lock();
- QRasterPaintEngine::drawPixmap(r, pixmap, sr);
- } else {
- QPixmapData *data = pixmap.pixmapData();
- Q_ASSERT(data->classId() == QPixmapData::DirectFBClass);
- QDirectFBPixmapData *dfbData = static_cast<QDirectFBPixmapData*>(data);
- if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)
- || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported)
- || (d->clipType == QDirectFBPaintEnginePrivate::ComplexClip)
- || (!d->supportsStretchBlit() && state()->matrix.mapRect(r).size() != sr.size())) {
- RASTERFALLBACK(DRAW_PIXMAP, r, pixmap.size(), sr);
- const QImage *img = dfbData->buffer();
- d->lock();
- QRasterPaintEngine::drawImage(r, *img, sr);
- } else {
- QDirectFBPaintEnginePrivate::unlock(dfbData);
- IDirectFBSurface *s = dfbData->directFBSurface();
- uint blitFlags = 0;
- if (pixmap.hasAlphaChannel())
- blitFlags |= QDirectFBPaintEnginePrivate::HasAlpha;
- if (QDirectFBScreen::isPremultiplied(dfbData->pixelFormat()))
- blitFlags |= QDirectFBPaintEnginePrivate::Premultiplied;
-
- d->prepareForBlit(blitFlags);
- CLIPPED_PAINT(d->blit(r, s, sr));
- }
- }
-}
-
-void QDirectFBPaintEngine::drawPixmap(const QPointF &p, const QPixmap &pm)
-{
- drawPixmap(QRectF(p, pm.size()), pm, pm.rect());
-}
-
-void QDirectFBPaintEngine::drawTiledPixmap(const QRectF &r,
- const QPixmap &pixmap,
- const QPointF &offset)
-{
- Q_D(QDirectFBPaintEngine);
- if (pixmap.pixmapData()->classId() != QPixmapData::DirectFBClass) {
- RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), offset);
- d->lock();
- QRasterPaintEngine::drawTiledPixmap(r, pixmap, offset);
- } else if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)
- || (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported)
- || (d->clipType == QDirectFBPaintEnginePrivate::ComplexClip)
- || (!d->supportsStretchBlit() && state()->matrix.isScaling())) {
- RASTERFALLBACK(DRAW_TILED_PIXMAP, r, pixmap.size(), offset);
- QPixmapData *pixmapData = pixmap.pixmapData();
- Q_ASSERT(pixmapData->classId() == QPixmapData::DirectFBClass);
- QDirectFBPixmapData *dfbData = static_cast<QDirectFBPixmapData*>(pixmapData);
- const QImage *img = dfbData->buffer();
- d->lock();
- QRasterPixmapData *data = new QRasterPixmapData(QPixmapData::PixmapType);
- data->fromImage(*img, Qt::AutoColor);
- const QPixmap pix(data);
- QRasterPaintEngine::drawTiledPixmap(r, pix, offset);
- } else {
- QTransform transform(state()->matrix);
- CLIPPED_PAINT(d->drawTiledPixmap(r, pixmap, offset, transform));
- }
-}
-
-
-void QDirectFBPaintEngine::stroke(const QVectorPath &path, const QPen &pen)
-{
- RASTERFALLBACK(STROKE_PATH, path, VOID_ARG(), VOID_ARG());
- Q_D(QDirectFBPaintEngine);
- d->lock();
- QRasterPaintEngine::stroke(path, pen);
-}
-
-void QDirectFBPaintEngine::drawPath(const QPainterPath &path)
-{
- RASTERFALLBACK(DRAW_PATH, path, VOID_ARG(), VOID_ARG());
- Q_D(QDirectFBPaintEngine);
- d->lock();
- QRasterPaintEngine::drawPath(path);
-}
-
-void QDirectFBPaintEngine::drawPoints(const QPointF *points, int pointCount)
-{
- RASTERFALLBACK(DRAW_POINTS, pointCount, VOID_ARG(), VOID_ARG());
- Q_D(QDirectFBPaintEngine);
- d->lock();
- QRasterPaintEngine::drawPoints(points, pointCount);
-}
-
-void QDirectFBPaintEngine::drawPoints(const QPoint *points, int pointCount)
-{
- RASTERFALLBACK(DRAW_POINTS, pointCount, VOID_ARG(), VOID_ARG());
- Q_D(QDirectFBPaintEngine);
- d->lock();
- QRasterPaintEngine::drawPoints(points, pointCount);
-}
-
-void QDirectFBPaintEngine::drawEllipse(const QRectF &rect)
-{
- RASTERFALLBACK(DRAW_ELLIPSE, rect, VOID_ARG(), VOID_ARG());
- Q_D(QDirectFBPaintEngine);
- d->lock();
- QRasterPaintEngine::drawEllipse(rect);
-}
-
-void QDirectFBPaintEngine::drawPolygon(const QPointF *points, int pointCount,
- PolygonDrawMode mode)
-{
- RASTERFALLBACK(DRAW_POLYGON, pointCount, mode, VOID_ARG());
- Q_D(QDirectFBPaintEngine);
- d->lock();
- QRasterPaintEngine::drawPolygon(points, pointCount, mode);
-}
-
-void QDirectFBPaintEngine::drawPolygon(const QPoint *points, int pointCount,
- PolygonDrawMode mode)
-{
- RASTERFALLBACK(DRAW_POLYGON, pointCount, mode, VOID_ARG());
- Q_D(QDirectFBPaintEngine);
- d->lock();
- QRasterPaintEngine::drawPolygon(points, pointCount, mode);
-}
-
-void QDirectFBPaintEngine::drawTextItem(const QPointF &p,
- const QTextItem &textItem)
-{
- RASTERFALLBACK(DRAW_TEXT, p, textItem.text(), VOID_ARG());
- Q_D(QDirectFBPaintEngine);
- d->lock();
- QRasterPaintEngine::drawTextItem(p, textItem);
-}
-
-void QDirectFBPaintEngine::fill(const QVectorPath &path, const QBrush &brush)
-{
- if (brush.style() == Qt::NoBrush)
- return;
- RASTERFALLBACK(FILL_PATH, path, brush, VOID_ARG());
- Q_D(QDirectFBPaintEngine);
- d->lock();
- QRasterPaintEngine::fill(path, brush);
-}
-
-void QDirectFBPaintEngine::drawRoundedRect(const QRectF &rect, qreal xrad, qreal yrad, Qt::SizeMode mode)
-{
- RASTERFALLBACK(DRAW_ROUNDED_RECT, rect, xrad, yrad);
- Q_D(QDirectFBPaintEngine);
- d->lock();
- QRasterPaintEngine::drawRoundedRect(rect, xrad, yrad, mode);
-}
-
-void QDirectFBPaintEngine::drawStaticTextItem(QStaticTextItem *item)
-{
- RASTERFALLBACK(DRAW_STATICTEXT, item, VOID_ARG(), VOID_ARG());
- Q_D(QDirectFBPaintEngine);
- d->lock();
- QRasterPaintEngine::drawStaticTextItem(item);
-}
-
-void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QBrush &brush)
-{
- Q_D(QDirectFBPaintEngine);
- if (brush.style() == Qt::NoBrush)
- return;
- if (d->clipType != QDirectFBPaintEnginePrivate::ComplexClip) {
- switch (brush.style()) {
- case Qt::SolidPattern: {
- const QColor color = brush.color();
- if (!color.isValid())
- return;
-
- if (d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported
- || !(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)) {
- break;
- }
- d->setDFBColor(color);
- const QRect r = state()->matrix.mapRect(rect).toRect();
- CLIPPED_PAINT(d->surface->FillRectangle(d->surface, r.x(), r.y(), r.width(), r.height()));
- return; }
-
- case Qt::TexturePattern: {
- const QPointF &brushOrigin = state()->brushOrigin;
- const QTransform stateTransform = state()->matrix;
- QTransform transform(stateTransform);
- transform.translate(brushOrigin.x(), brushOrigin.y());
- transform = brush.transform() * transform;
- if (!(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)
- || (QDirectFBPaintEnginePrivate::getTransformationType(transform) & QDirectFBPaintEnginePrivate::Matrix_BlitsUnsupported)
- || (!d->supportsStretchBlit() && transform.isScaling())) {
- break;
- }
-
- const QPixmap texture = brush.texture();
- if (texture.pixmapData()->classId() != QPixmapData::DirectFBClass)
- break;
-
- CLIPPED_PAINT(d->drawTiledPixmap(stateTransform.mapRect(rect), texture, rect.topLeft() - brushOrigin, transform));
- return; }
- default:
- break;
- }
- }
- RASTERFALLBACK(FILL_RECT, rect, brush, VOID_ARG());
- d->lock();
- QRasterPaintEngine::fillRect(rect, brush);
-}
-
-void QDirectFBPaintEngine::fillRect(const QRectF &rect, const QColor &color)
-{
- if (!color.isValid())
- return;
- Q_D(QDirectFBPaintEngine);
- if ((d->transformationType & QDirectFBPaintEnginePrivate::Matrix_RectsUnsupported)
- || (d->clipType == QDirectFBPaintEnginePrivate::ComplexClip)
- || !(d->compositionModeStatus & QDirectFBPaintEnginePrivate::PorterDuff_Supported)) {
- RASTERFALLBACK(FILL_RECT, rect, color, VOID_ARG());
- d->lock();
- QRasterPaintEngine::fillRect(rect, color);
- } else {
- d->setDFBColor(color);
- const QRect r = state()->matrix.mapRect(rect).toRect();
- CLIPPED_PAINT(d->surface->FillRectangle(d->surface, r.x(), r.y(), r.width(), r.height()));
- }
-}
-
-void QDirectFBPaintEngine::drawBufferSpan(const uint *buffer, int bufsize,
- int x, int y, int length,
- uint const_alpha)
-{
- Q_D(QDirectFBPaintEngine);
- IDirectFBSurface *src = d->surfaceCache->getSurface(buffer, bufsize);
- // ### how does this play with setDFBColor
- src->SetColor(src, 0, 0, 0, const_alpha);
- const DFBRectangle rect = { 0, 0, length, 1 };
- d->surface->Blit(d->surface, src, &rect, x, y);
-}
-
-#ifdef QT_DIRECTFB_IMAGECACHE
-static void cachedImageCleanupHook(qint64 key)
-{
- delete imageCache.take(key);
-}
-void QDirectFBPaintEngine::initImageCache(int size)
-{
- Q_ASSERT(size >= 0);
- imageCache.setMaxCost(size);
- QImagePixmapCleanupHooks::instance()->addImageHook(cachedImageCleanupHook);
-}
-
-#endif // QT_DIRECTFB_IMAGECACHE
-
-// ---- QDirectFBPaintEnginePrivate ----
-
-
-QDirectFBPaintEnginePrivate::QDirectFBPaintEnginePrivate(QDirectFBPaintEngine *p)
- : surface(0), antialiased(false), simplePen(false),
- transformationType(0), opacity(255),
- clipType(ClipUnset), dfbDevice(0),
- compositionModeStatus(0), isPremultiplied(false), inClip(false), q(p)
-{
- fb = QDirectFBScreen::instance()->dfb();
- surfaceCache = new SurfaceCache;
-}
-
-QDirectFBPaintEnginePrivate::~QDirectFBPaintEnginePrivate()
-{
- delete surfaceCache;
-}
-
-bool QDirectFBPaintEnginePrivate::isSimpleBrush(const QBrush &brush) const
-{
- return (brush.style() == Qt::NoBrush) || (brush.style() == Qt::SolidPattern && !antialiased);
-}
-
-void QDirectFBPaintEnginePrivate::lock()
-{
- // We will potentially get a new pointer to the buffer after a
- // lock so we need to call the base implementation of prepare so
- // it updates its rasterBuffer to point to the new buffer address.
- Q_ASSERT(dfbDevice);
- if (dfbDevice->lockSurface(DSLF_READ|DSLF_WRITE)) {
- prepare(dfbDevice);
- }
-}
-
-void QDirectFBPaintEnginePrivate::unlock()
-{
- Q_ASSERT(dfbDevice);
-#ifdef QT_DIRECTFB_SUBSURFACE
- dfbDevice->syncPending = true;
-#else
- QDirectFBPaintEnginePrivate::unlock(dfbDevice);
-#endif
-}
-
-void QDirectFBPaintEnginePrivate::unlock(QDirectFBPaintDevice *device)
-{
-#ifdef QT_NO_DIRECTFB_SUBSURFACE
- Q_ASSERT(device);
- device->unlockSurface();
-#else
- Q_UNUSED(device);
-#endif
-}
-
-void QDirectFBPaintEnginePrivate::setTransform(const QTransform &transform)
-{
- transformationType = getTransformationType(transform);
- setPen(q->state()->pen);
-}
-
-void QDirectFBPaintEnginePrivate::setPen(const QPen &pen)
-{
- if (pen.style() == Qt::NoPen) {
- simplePen = true;
- } else if (pen.style() == Qt::SolidLine
- && !antialiased
- && pen.brush().style() == Qt::SolidPattern
- && pen.widthF() <= 1.0
- && (transformationType < QTransform::TxScale || pen.isCosmetic())) {
- simplePen = true;
- } else {
- simplePen = false;
- }
-}
-
-void QDirectFBPaintEnginePrivate::setCompositionMode(QPainter::CompositionMode mode)
-{
- if (!surface)
- return;
-
- static const bool forceRasterFallBack = qgetenv("QT_DIRECTFB_FORCE_RASTER").toInt() > 0;
- if (forceRasterFallBack) {
- compositionModeStatus = PorterDuff_None;
- return;
- }
-
- compositionModeStatus = PorterDuff_Supported|PorterDuff_PremultiplyColors|PorterDuff_AlwaysBlend;
- switch (mode) {
- case QPainter::CompositionMode_Clear:
- surface->SetPorterDuff(surface, DSPD_CLEAR);
- break;
- case QPainter::CompositionMode_Source:
- surface->SetPorterDuff(surface, DSPD_SRC);
- compositionModeStatus &= ~PorterDuff_AlwaysBlend;
- if (!isPremultiplied)
- compositionModeStatus &= ~PorterDuff_PremultiplyColors;
- break;
- case QPainter::CompositionMode_SourceOver:
- compositionModeStatus &= ~PorterDuff_AlwaysBlend;
- surface->SetPorterDuff(surface, DSPD_SRC_OVER);
- break;
- case QPainter::CompositionMode_DestinationOver:
- surface->SetPorterDuff(surface, DSPD_DST_OVER);
- break;
- case QPainter::CompositionMode_SourceIn:
- surface->SetPorterDuff(surface, DSPD_SRC_IN);
- if (!isPremultiplied)
- compositionModeStatus &= ~PorterDuff_PremultiplyColors;
- break;
- case QPainter::CompositionMode_DestinationIn:
- surface->SetPorterDuff(surface, DSPD_DST_IN);
- break;
- case QPainter::CompositionMode_SourceOut:
- surface->SetPorterDuff(surface, DSPD_SRC_OUT);
- break;
- case QPainter::CompositionMode_DestinationOut:
- surface->SetPorterDuff(surface, DSPD_DST_OUT);
- break;
- case QPainter::CompositionMode_Destination:
- surface->SetSrcBlendFunction(surface, DSBF_ZERO);
- surface->SetDstBlendFunction(surface, DSBF_ONE);
- break;
-#if (Q_DIRECTFB_VERSION >= 0x010000)
- case QPainter::CompositionMode_SourceAtop:
- surface->SetPorterDuff(surface, DSPD_SRC_ATOP);
- break;
- case QPainter::CompositionMode_DestinationAtop:
- surface->SetPorterDuff(surface, DSPD_DST_ATOP);
- break;
- case QPainter::CompositionMode_Plus:
- surface->SetPorterDuff(surface, DSPD_ADD);
- break;
- case QPainter::CompositionMode_Xor:
- surface->SetPorterDuff(surface, DSPD_XOR);
- break;
-#endif
- default:
- compositionModeStatus = PorterDuff_None;
- break;
- }
-}
-
-void QDirectFBPaintEnginePrivate::setRenderHints(QPainter::RenderHints hints)
-{
- const bool old = antialiased;
- antialiased = bool(hints & QPainter::Antialiasing);
- if (old != antialiased) {
- setPen(q->state()->pen);
- }
-}
-
-void QDirectFBPaintEnginePrivate::prepareForBlit(uint flags)
-{
- DFBSurfaceBlittingFlags blittingFlags = DSBLIT_NOFX;
- if (flags & Premultiplied)
- blittingFlags |= DSBLIT_SRC_PREMULTIPLY;
- if (flags & HasAlpha)
- blittingFlags |= DSBLIT_BLEND_ALPHACHANNEL;
- if (opacity != 255) {
- blittingFlags |= DSBLIT_BLEND_COLORALPHA;
- surface->SetColor(surface, 0xff, 0xff, 0xff, opacity);
- }
-
- surface->SetBlittingFlags(surface, blittingFlags);
-}
-
-static inline uint ALPHA_MUL(uint x, uint a)
-{
- uint t = x * a;
- t = ((t + (t >> 8) + 0x80) >> 8) & 0xff;
- return t;
-}
-
-void QDirectFBPaintEnginePrivate::setDFBColor(const QColor &color)
-{
- Q_ASSERT(surface);
- Q_ASSERT(compositionModeStatus & PorterDuff_Supported);
- const quint8 alpha = (opacity == 255 ?
- color.alpha() : ALPHA_MUL(color.alpha(), opacity));
- QColor col;
- if (compositionModeStatus & PorterDuff_PremultiplyColors) {
- col = QColor(ALPHA_MUL(color.red(), alpha),
- ALPHA_MUL(color.green(), alpha),
- ALPHA_MUL(color.blue(), alpha),
- alpha);
- } else {
- col = QColor(color.red(), color.green(), color.blue(), alpha);
- }
- surface->SetColor(surface, col.red(), col.green(), col.blue(), col.alpha());
- surface->SetDrawingFlags(surface, alpha == 255 && !(compositionModeStatus & PorterDuff_AlwaysBlend) ? DSDRAW_NOFX : DSDRAW_BLEND);
-}
-
-IDirectFBSurface *QDirectFBPaintEnginePrivate::getSurface(const QImage &img, bool *release)
-{
-#ifdef QT_NO_DIRECTFB_IMAGECACHE
- *release = true;
- return QDirectFBScreen::instance()->createDFBSurface(img, img.format(), QDirectFBScreen::DontTrackSurface);
-#else
- const qint64 key = img.cacheKey();
- *release = false;
- if (imageCache.contains(key)) {
- return imageCache[key]->surface;
- }
-
- const int cost = cacheCost(img);
- const bool cache = cost <= imageCache.maxCost();
- QDirectFBScreen *screen = QDirectFBScreen::instance();
- const QImage::Format format = (img.format() == screen->alphaPixmapFormat() || QDirectFBPixmapData::hasAlphaChannel(img)
- ? screen->alphaPixmapFormat() : screen->pixelFormat());
-
- IDirectFBSurface *surface = screen->createDFBSurface(img, format,
- cache
- ? QDirectFBScreen::TrackSurface
- : QDirectFBScreen::DontTrackSurface);
- if (cache) {
- CachedImage *cachedImage = new CachedImage;
- const_cast<QImage&>(img).data_ptr()->is_cached = true;
- cachedImage->surface = surface;
- imageCache.insert(key, cachedImage, cost);
- } else {
- *release = true;
- }
- return surface;
-#endif
-}
-
-
-void QDirectFBPaintEnginePrivate::blit(const QRectF &dest, IDirectFBSurface *s, const QRectF &src)
-{
- const QRect sr = src.toRect();
- const QRect dr = q->state()->matrix.mapRect(dest).toRect();
- if (dr.isEmpty())
- return;
- const DFBRectangle sRect = { sr.x(), sr.y(), sr.width(), sr.height() };
- DFBResult result;
-
- if (dr.size() == sr.size()) {
- result = surface->Blit(surface, s, &sRect, dr.x(), dr.y());
- } else {
- Q_ASSERT(supportsStretchBlit());
- const DFBRectangle dRect = { dr.x(), dr.y(), dr.width(), dr.height() };
- result = surface->StretchBlit(surface, s, &sRect, &dRect);
- }
- if (result != DFB_OK)
- DirectFBError("QDirectFBPaintEngine::drawPixmap()", result);
-}
-
-static inline qreal fixCoord(qreal rect_pos, qreal pixmapSize, qreal offset)
-{
- qreal pos = rect_pos - offset;
- while (pos > rect_pos)
- pos -= pixmapSize;
- while (pos + pixmapSize < rect_pos)
- pos += pixmapSize;
- return pos;
-}
-
-void QDirectFBPaintEnginePrivate::drawTiledPixmap(const QRectF &dest, const QPixmap &pixmap,
- const QPointF &off, const QTransform &pixmapTransform)
-{
- const QTransform &transform = q->state()->matrix;
- Q_ASSERT(!(getTransformationType(transform) & Matrix_BlitsUnsupported) &&
- !(getTransformationType(pixmapTransform) & Matrix_BlitsUnsupported));
- const QRect destinationRect = transform.mapRect(dest).toRect().normalized();
- QRect newClip = destinationRect;
- if (!currentClip.isEmpty())
- newClip &= currentClip;
-
- if (newClip.isNull())
- return;
-
- const DFBRegion clip = {
- newClip.x(),
- newClip.y(),
- newClip.right(),
- newClip.bottom()
- };
- surface->SetClip(surface, &clip);
-
- QPointF offset = pixmapTransform.inverted().map(off);
- Q_ASSERT(transform.type() <= QTransform::TxScale);
- QPixmapData *data = pixmap.pixmapData();
- Q_ASSERT(data->classId() == QPixmapData::DirectFBClass);
- QDirectFBPixmapData *dfbData = static_cast<QDirectFBPixmapData*>(data);
- IDirectFBSurface *sourceSurface = dfbData->directFBSurface();
- uint blitFlags = 0;
- if (dfbData->hasAlphaChannel())
- blitFlags |= HasAlpha;
- if (QDirectFBScreen::isPremultiplied(dfbData->pixelFormat()))
- blitFlags |= Premultiplied;
- prepareForBlit(blitFlags);
- QDirectFBPaintEnginePrivate::unlock(dfbData);
- const QSize pixmapSize = dfbData->size();
- if (transform.isScaling() || pixmapTransform.isScaling()) {
- Q_ASSERT(supportsStretchBlit());
- Q_ASSERT(qMin(transform.m11(), transform.m22()) >= 0);
- offset.rx() *= transform.m11();
- offset.ry() *= transform.m22();
-
- const QSizeF mappedSize(pixmapSize.width() * pixmapTransform.m11(), pixmapSize.height() * pixmapTransform.m22());
- qreal y = fixCoord(destinationRect.y(), mappedSize.height(), offset.y());
- const qreal startX = fixCoord(destinationRect.x(), mappedSize.width(), offset.x());
- while (y <= destinationRect.bottom()) {
- qreal x = startX;
- while (x <= destinationRect.right()) {
- const DFBRectangle destination = { qRound(x), qRound(y), mappedSize.width(), mappedSize.height() };
- surface->StretchBlit(surface, sourceSurface, 0, &destination);
- x += mappedSize.width();
- }
- y += mappedSize.height();
- }
- } else {
- qreal y = fixCoord(destinationRect.y(), pixmapSize.height(), offset.y());
- const qreal startX = fixCoord(destinationRect.x(), pixmapSize.width(), offset.x());
- int horizontal = qMax(1, destinationRect.width() / pixmapSize.width()) + 1;
- if (startX != destinationRect.x())
- ++horizontal;
- int vertical = qMax(1, destinationRect.height() / pixmapSize.height()) + 1;
- if (y != destinationRect.y())
- ++vertical;
-
- const int maxCount = (vertical * horizontal);
- QVarLengthArray<DFBRectangle, 16> sourceRects(maxCount);
- QVarLengthArray<DFBPoint, 16> points(maxCount);
-
- int i = 0;
- while (y <= destinationRect.bottom()) {
- Q_ASSERT(i < maxCount);
- qreal x = startX;
- while (x <= destinationRect.right()) {
- points[i].x = qRound(x);
- points[i].y = qRound(y);
- sourceRects[i].x = 0;
- sourceRects[i].y = 0;
- sourceRects[i].w = int(pixmapSize.width());
- sourceRects[i].h = int(pixmapSize.height());
- x += pixmapSize.width();
- ++i;
- }
- y += pixmapSize.height();
- }
- surface->BatchBlit(surface, sourceSurface, sourceRects.constData(), points.constData(), i);
- }
-
- if (currentClip.isEmpty()) {
- surface->SetClip(surface, 0);
- } else {
- const DFBRegion clip = {
- currentClip.x(),
- currentClip.y(),
- currentClip.right(),
- currentClip.bottom()
- };
- surface->SetClip(surface, &clip);
- }
-}
-
-void QDirectFBPaintEnginePrivate::updateClip()
-{
- Q_ASSERT(surface);
- currentClip = QRect();
- const QClipData *clipData = clip();
- if (!clipData || !clipData->enabled) {
- surface->SetClip(surface, NULL);
- clipType = NoClip;
- } else if (clipData->hasRectClip) {
- const DFBRegion r = {
- clipData->clipRect.x(),
- clipData->clipRect.y(),
- clipData->clipRect.right(),
- clipData->clipRect.bottom()
- };
- surface->SetClip(surface, &r);
- currentClip = clipData->clipRect.normalized();
- // ### is this guaranteed to always be normalized?
- clipType = RectClip;
- } else if (clipData->hasRegionClip) {
- clipType = RegionClip;
- } else {
- clipType = ComplexClip;
- }
-}
-
-bool QDirectFBPaintEnginePrivate::supportsStretchBlit() const
-{
-#ifdef QT_DIRECTFB_STRETCHBLIT
- return !(q->state()->renderHints & QPainter::SmoothPixmapTransform);
-#else
- return false;
-#endif
-}
-
-
-void QDirectFBPaintEnginePrivate::systemStateChanged()
-{
- QRasterPaintEnginePrivate::systemStateChanged();
- updateClip();
-}
-
-IDirectFBSurface *SurfaceCache::getSurface(const uint *buf, int size)
-{
- if (buffer == buf && bufsize == size)
- return surface;
-
- clear();
-
- const DFBSurfaceDescription description = QDirectFBScreen::getSurfaceDescription(buf, size);
- surface = QDirectFBScreen::instance()->createDFBSurface(description, QDirectFBScreen::TrackSurface, 0);
- if (!surface)
- qWarning("QDirectFBPaintEngine: SurfaceCache: Unable to create surface");
-
- buffer = const_cast<uint*>(buf);
- bufsize = size;
-
- return surface;
-}
-
-void SurfaceCache::clear()
-{
- if (surface && QDirectFBScreen::instance())
- QDirectFBScreen::instance()->releaseDFBSurface(surface);
- surface = 0;
- buffer = 0;
- bufsize = 0;
-}
-
-
-static inline QRect mapRect(const QTransform &transform, const QRect &rect) { return transform.mapRect(rect); }
-static inline QRect mapRect(const QTransform &transform, const QRectF &rect) { return transform.mapRect(rect).toRect(); }
-static inline QLine map(const QTransform &transform, const QLine &line) { return transform.map(line); }
-static inline QLine map(const QTransform &transform, const QLineF &line) { return transform.map(line).toLine(); }
-template <class T>
-static inline void drawLines(const T *lines, int n, const QTransform &transform, IDirectFBSurface *surface)
-{
- if (n == 1) {
- const QLine l = map(transform, lines[0]);
- surface->DrawLine(surface, l.x1(), l.y1(), l.x2(), l.y2());
- } else {
- QVarLengthArray<DFBRegion, 32> lineArray(n);
- for (int i=0; i<n; ++i) {
- const QLine l = map(transform, lines[i]);
- lineArray[i].x1 = l.x1();
- lineArray[i].y1 = l.y1();
- lineArray[i].x2 = l.x2();
- lineArray[i].y2 = l.y2();
- }
- surface->DrawLines(surface, lineArray.constData(), n);
- }
-}
-
-template <class T>
-static inline void fillRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface)
-{
- if (n == 1) {
- const QRect r = mapRect(transform, rects[0]);
- surface->FillRectangle(surface, r.x(), r.y(), r.width(), r.height());
- } else {
- QVarLengthArray<DFBRectangle, 32> rectArray(n);
- for (int i=0; i<n; ++i) {
- const QRect r = mapRect(transform, rects[i]);
- rectArray[i].x = r.x();
- rectArray[i].y = r.y();
- rectArray[i].w = r.width();
- rectArray[i].h = r.height();
- }
- surface->FillRectangles(surface, rectArray.constData(), n);
- }
-}
-
-template <class T>
-static inline void drawRects(const T *rects, int n, const QTransform &transform, IDirectFBSurface *surface)
-{
- for (int i=0; i<n; ++i) {
- const QRect r = mapRect(transform, rects[i]);
- surface->DrawRectangle(surface, r.x(), r.y(), r.width(), r.height());
- }
-}
-
-template <typename T> inline const T *ptr(const T &t) { return &t; }
-template <> inline const bool* ptr<bool>(const bool &) { return 0; }
-template <typename device, typename T1, typename T2, typename T3>
-static void rasterFallbackWarn(const char *msg, const char *func, const device *dev,
- uint transformationType, bool simplePen,
- uint clipType, uint compositionModeStatus,
- const char *nameOne, const T1 &one,
- const char *nameTwo, const T2 &two,
- const char *nameThree, const T3 &three)
-{
- QString out;
- QDebug dbg(&out);
- dbg << msg << (QByteArray(func) + "()") << "painting on";
- if (dev->devType() == QInternal::Widget) {
- dbg << static_cast<const QWidget*>(dev);
- } else {
- dbg << dev << "of type" << dev->devType();
- }
-
- dbg << QString::fromLatin1("transformationType 0x%1").arg(transformationType, 3, 16, QLatin1Char('0'))
- << "simplePen" << simplePen
- << "clipType" << clipType
- << "compositionModeStatus" << compositionModeStatus;
-
- const T1 *t1 = ptr(one);
- const T2 *t2 = ptr(two);
- const T3 *t3 = ptr(three);
-
- if (t1) {
- dbg << nameOne << *t1;
- if (t2) {
- dbg << nameTwo << *t2;
- if (t3) {
- dbg << nameThree << *t3;
- }
- }
- }
- qWarning("%s", qPrintable(out));
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_DIRECTFB
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h b/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h
deleted file mode 100644
index 1908f3ad32..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpaintengine.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QPAINTENGINE_DIRECTFB_P_H
-#define QPAINTENGINE_DIRECTFB_P_H
-
-#include <QtGui/qpaintengine.h>
-#include <private/qpaintengine_raster_p.h>
-
-#ifndef QT_NO_QWS_DIRECTFB
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QDirectFBPaintEnginePrivate;
-
-class QDirectFBPaintEngine : public QRasterPaintEngine
-{
- Q_DECLARE_PRIVATE(QDirectFBPaintEngine)
-public:
- QDirectFBPaintEngine(QPaintDevice *device);
- virtual ~QDirectFBPaintEngine();
-
- virtual bool begin(QPaintDevice *device);
- virtual bool end();
-
- virtual void drawRects(const QRect *rects, int rectCount);
- virtual void drawRects(const QRectF *rects, int rectCount);
-
- virtual void fillRect(const QRectF &r, const QBrush &brush);
- virtual void fillRect(const QRectF &r, const QColor &color);
-
- virtual void drawLines(const QLine *line, int lineCount);
- virtual void drawLines(const QLineF *line, int lineCount);
-
- virtual void drawImage(const QPointF &p, const QImage &img);
- virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr,
- Qt::ImageConversionFlags falgs = Qt::AutoColor);
-
- virtual void drawPixmap(const QPointF &p, const QPixmap &pm);
- virtual void drawPixmap(const QRectF &r, const QPixmap &pixmap, const QRectF &sr);
- virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pm, const QPointF &sr);
-
- virtual void drawBufferSpan(const uint *buffer, int bufsize,
- int x, int y, int length, uint const_alpha);
-
- virtual void stroke(const QVectorPath &path, const QPen &pen);
- virtual void drawPath(const QPainterPath &path);
- virtual void drawPoints(const QPointF *points, int pointCount);
- virtual void drawPoints(const QPoint *points, int pointCount);
- virtual void drawEllipse(const QRectF &rect);
- virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode);
- virtual void drawPolygon(const QPoint *points, int pointCount, PolygonDrawMode mode);
- virtual void drawTextItem(const QPointF &p, const QTextItem &textItem);
- virtual void fill(const QVectorPath &path, const QBrush &brush);
- virtual void drawRoundedRect(const QRectF &rect, qreal xrad, qreal yrad, Qt::SizeMode mode);
-
- virtual void clipEnabledChanged();
- virtual void penChanged();
- virtual void opacityChanged();
- virtual void compositionModeChanged();
- virtual void renderHintsChanged();
- virtual void transformChanged();
-
- virtual void setState(QPainterState *state);
-
- virtual void clip(const QVectorPath &path, Qt::ClipOperation op);
- virtual void clip(const QRegion &region, Qt::ClipOperation op);
- virtual void clip(const QRect &rect, Qt::ClipOperation op);
-
- virtual void drawStaticTextItem(QStaticTextItem *item);
-
- static void initImageCache(int size);
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_QWS_DIRECTFB
-
-#endif // QPAINTENGINE_DIRECTFB_P_H
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
deleted file mode 100644
index eaff74a41c..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.cpp
+++ /dev/null
@@ -1,588 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdirectfbpixmap.h"
-
-#ifndef QT_NO_QWS_DIRECTFB
-
-#include "qdirectfbscreen.h"
-#include "qdirectfbpaintengine.h"
-
-#include <QtGui/qbitmap.h>
-#include <QtCore/qfile.h>
-#include <directfb.h>
-
-
-QT_BEGIN_NAMESPACE
-
-static int global_ser_no = 0;
-
-QDirectFBPixmapData::QDirectFBPixmapData(QDirectFBScreen *screen, PixelType pixelType)
- : QPixmapData(pixelType, DirectFBClass), QDirectFBPaintDevice(screen),
- alpha(false)
-{
- setSerialNumber(0);
-}
-
-QDirectFBPixmapData::~QDirectFBPixmapData()
-{
-}
-
-void QDirectFBPixmapData::resize(int width, int height)
-{
- if (width <= 0 || height <= 0) {
- invalidate();
- return;
- }
-
- imageFormat = screen->pixelFormat();
- dfbSurface = screen->createDFBSurface(QSize(width, height),
- imageFormat,
- QDirectFBScreen::TrackSurface);
- d = QDirectFBScreen::depth(imageFormat);
- alpha = false;
- if (!dfbSurface) {
- invalidate();
- qWarning("QDirectFBPixmapData::resize(): Unable to allocate surface");
- return;
- }
-
- w = width;
- h = height;
- is_null = (w <= 0 || h <= 0);
- setSerialNumber(++global_ser_no);
-}
-
-#ifdef QT_DIRECTFB_OPAQUE_DETECTION
-// mostly duplicated from qimage.cpp (QImageData::checkForAlphaPixels)
-static bool checkForAlphaPixels(const QImage &img)
-{
- const uchar *bits = img.bits();
- const int bytes_per_line = img.bytesPerLine();
- const uchar *end_bits = bits + bytes_per_line;
- const int width = img.width();
- const int height = img.height();
- switch (img.format()) {
- case QImage::Format_Indexed8:
- return img.hasAlphaChannel();
- case QImage::Format_ARGB32:
- case QImage::Format_ARGB32_Premultiplied:
- for (int y=0; y<height; ++y) {
- for (int x=0; x<width; ++x) {
- if ((((uint *)bits)[x] & 0xff000000) != 0xff000000) {
- return true;
- }
- }
- bits += bytes_per_line;
- }
- break;
-
- case QImage::Format_ARGB8555_Premultiplied:
- case QImage::Format_ARGB8565_Premultiplied:
- for (int y=0; y<height; ++y) {
- while (bits < end_bits) {
- if (bits[0] != 0) {
- return true;
- }
- bits += 3;
- }
- bits = end_bits;
- end_bits += bytes_per_line;
- }
- break;
-
- case QImage::Format_ARGB6666_Premultiplied:
- for (int y=0; y<height; ++y) {
- while (bits < end_bits) {
- if ((bits[0] & 0xfc) != 0) {
- return true;
- }
- bits += 3;
- }
- bits = end_bits;
- end_bits += bytes_per_line;
- }
- break;
-
- case QImage::Format_ARGB4444_Premultiplied:
- for (int y=0; y<height; ++y) {
- while (bits < end_bits) {
- if ((bits[0] & 0xf0) != 0) {
- return true;
- }
- bits += 2;
- }
- bits = end_bits;
- end_bits += bytes_per_line;
- }
- break;
-
- default:
- break;
- }
-
- return false;
-}
-#endif // QT_DIRECTFB_OPAQUE_DETECTION
-
-bool QDirectFBPixmapData::hasAlphaChannel(const QImage &img, Qt::ImageConversionFlags flags)
-{
- if (img.depth() == 1)
- return true;
-#ifdef QT_DIRECTFB_OPAQUE_DETECTION
- return ((flags & Qt::NoOpaqueDetection) ? img.hasAlphaChannel() : checkForAlphaPixels(img));
-#else
- Q_UNUSED(flags);
- return img.hasAlphaChannel();
-#endif
-}
-
-#ifdef QT_DIRECTFB_IMAGEPROVIDER
-bool QDirectFBPixmapData::fromFile(const QString &filename, const char *format,
- Qt::ImageConversionFlags flags)
-{
- if (!QFile::exists(filename))
- return false;
- if (flags == Qt::AutoColor) {
- if (filename.startsWith(QLatin1Char(':'))) { // resource
- QFile file(filename);
- if (!file.open(QIODevice::ReadOnly))
- return false;
- const QByteArray data = file.readAll();
- file.close();
- return fromData(reinterpret_cast<const uchar*>(data.constData()), data.size(), format, flags);
- } else {
- DFBDataBufferDescription description;
- description.flags = DBDESC_FILE;
- const QByteArray fileNameData = filename.toLocal8Bit();
- description.file = fileNameData.constData();
- if (fromDataBufferDescription(description)) {
- return true;
- }
- // fall back to Qt
- }
- }
- return QPixmapData::fromFile(filename, format, flags);
-}
-
-bool QDirectFBPixmapData::fromData(const uchar *buffer, uint len, const char *format,
- Qt::ImageConversionFlags flags)
-{
- if (flags == Qt::AutoColor) {
- DFBDataBufferDescription description;
- description.flags = DBDESC_MEMORY;
- description.memory.data = buffer;
- description.memory.length = len;
- if (fromDataBufferDescription(description))
- return true;
- // fall back to Qt
- }
- return QPixmapData::fromData(buffer, len, format, flags);
-}
-
-template <typename T> struct QDirectFBInterfaceCleanupHandler
-{
- static void cleanup(T *t) { if (t) t->Release(t); }
-};
-
-template <typename T>
-class QDirectFBPointer : public QScopedPointer<T, QDirectFBInterfaceCleanupHandler<T> >
-{
-public:
- QDirectFBPointer(T *t = 0)
- : QScopedPointer<T, QDirectFBInterfaceCleanupHandler<T> >(t)
- {}
-};
-
-bool QDirectFBPixmapData::fromDataBufferDescription(const DFBDataBufferDescription &dataBufferDescription)
-{
- IDirectFB *dfb = screen->dfb();
- Q_ASSERT(dfb);
- DFBResult result = DFB_OK;
- IDirectFBDataBuffer *dataBufferPtr;
- if ((result = dfb->CreateDataBuffer(dfb, &dataBufferDescription, &dataBufferPtr)) != DFB_OK) {
- DirectFBError("QDirectFBPixmapData::fromDataBufferDescription()", result);
- return false;
- }
- QDirectFBPointer<IDirectFBDataBuffer> dataBuffer(dataBufferPtr);
-
- IDirectFBImageProvider *providerPtr;
- if ((result = dataBuffer->CreateImageProvider(dataBuffer.data(), &providerPtr)) != DFB_OK)
- return false;
-
- QDirectFBPointer<IDirectFBImageProvider> provider(providerPtr);
-
- DFBImageDescription imageDescription;
- result = provider->GetImageDescription(provider.data(), &imageDescription);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBPixmapData::fromSurfaceDescription(): Can't get image description", result);
- return false;
- }
-
- if (imageDescription.caps & DICAPS_COLORKEY) {
- return false;
- }
-
- DFBSurfaceDescription surfaceDescription;
- if ((result = provider->GetSurfaceDescription(provider.data(), &surfaceDescription)) != DFB_OK) {
- DirectFBError("QDirectFBPixmapData::fromDataBufferDescription(): Can't get surface description", result);
- return false;
- }
-
- alpha = imageDescription.caps & DICAPS_ALPHACHANNEL;
- imageFormat = alpha ? screen->alphaPixmapFormat() : screen->pixelFormat();
-
- dfbSurface = screen->createDFBSurface(QSize(surfaceDescription.width, surfaceDescription.height),
- imageFormat, QDirectFBScreen::TrackSurface);
-
- result = provider->RenderTo(provider.data(), dfbSurface, 0);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBPixmapData::fromSurfaceDescription(): Can't render to surface", result);
- return false;
- }
-
- w = surfaceDescription.width;
- h = surfaceDescription.height;
- is_null = (w <= 0 || h <= 0);
- d = QDirectFBScreen::depth(imageFormat);
- setSerialNumber(++global_ser_no);
-
-#if defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE
- screen->setDirectFBImageProvider(providerPtr);
- provider.take();
-#endif
-
- return true;
-}
-
-#endif
-
-void QDirectFBPixmapData::fromImage(const QImage &img, Qt::ImageConversionFlags flags)
-{
- alpha = QDirectFBPixmapData::hasAlphaChannel(img, flags);
- imageFormat = alpha ? screen->alphaPixmapFormat() : screen->pixelFormat();
-
- QImage image;
- if ((flags & ~Qt::NoOpaqueDetection) != Qt::AutoColor) {
- image = img.convertToFormat(imageFormat, flags);
- flags = Qt::AutoColor;
- } else if (img.format() == QImage::Format_RGB32 || img.depth() == 1) {
- image = img.convertToFormat(imageFormat, flags);
- } else if (img.format() != imageFormat) {
- image = img.convertToFormat(imageFormat, flags);
- } else {
- image = img;
- }
-
- dfbSurface = screen->createDFBSurface(image, image.format(), QDirectFBScreen::NoPreallocated | QDirectFBScreen::TrackSurface);
- if (!dfbSurface) {
- qWarning("QDirectFBPixmapData::fromImage()");
- invalidate();
- return;
- }
-
- w = image.width();
- h = image.height();
- is_null = (w <= 0 || h <= 0);
- d = QDirectFBScreen::depth(imageFormat);
- setSerialNumber(++global_ser_no);
-#ifdef QT_NO_DIRECTFB_OPAQUE_DETECTION
- Q_UNUSED(flags);
-#endif
-}
-
-void QDirectFBPixmapData::copy(const QPixmapData *data, const QRect &rect)
-{
- if (data->classId() != DirectFBClass) {
- QPixmapData::copy(data, rect);
- return;
- }
-
- const QDirectFBPixmapData *otherData = static_cast<const QDirectFBPixmapData*>(data);
-#ifdef QT_NO_DIRECTFB_SUBSURFACE
- if (otherData->lockFlags()) {
- const_cast<QDirectFBPixmapData*>(otherData)->unlockSurface();
- }
-#endif
- IDirectFBSurface *src = otherData->directFBSurface();
- alpha = data->hasAlphaChannel();
- imageFormat = (alpha
- ? QDirectFBScreen::instance()->alphaPixmapFormat()
- : QDirectFBScreen::instance()->pixelFormat());
-
-
- dfbSurface = screen->createDFBSurface(rect.size(), imageFormat,
- QDirectFBScreen::TrackSurface);
- if (!dfbSurface) {
- qWarning("QDirectFBPixmapData::copy()");
- invalidate();
- return;
- }
-
- if (alpha) {
- dfbSurface->Clear(dfbSurface, 0, 0, 0, 0);
- dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_BLEND_ALPHACHANNEL);
- } else {
- dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX);
- }
- const DFBRectangle blitRect = { rect.x(), rect.y(),
- rect.width(), rect.height() };
- w = rect.width();
- h = rect.height();
- d = otherData->d;
- is_null = (w <= 0 || h <= 0);
- unlockSurface();
- DFBResult result = dfbSurface->Blit(dfbSurface, src, &blitRect, 0, 0);
-#if (Q_DIRECTFB_VERSION >= 0x010000)
- dfbSurface->ReleaseSource(dfbSurface);
-#endif
- if (result != DFB_OK) {
- DirectFBError("QDirectFBPixmapData::copy()", result);
- invalidate();
- return;
- }
-
- setSerialNumber(++global_ser_no);
-}
-
-static inline bool isOpaqueFormat(QImage::Format format)
-{
- switch (format) {
- case QImage::Format_RGB32:
- case QImage::Format_RGB16:
- case QImage::Format_RGB666:
- case QImage::Format_RGB555:
- case QImage::Format_RGB888:
- case QImage::Format_RGB444:
- return true;
- default:
- break;
- }
- return false;
-}
-
-void QDirectFBPixmapData::fill(const QColor &color)
-{
- if (!serialNumber())
- return;
-
- Q_ASSERT(dfbSurface);
-
- alpha |= (color.alpha() < 255);
-
- if (alpha && isOpaqueFormat(imageFormat)) {
- QSize size;
- dfbSurface->GetSize(dfbSurface, &size.rwidth(), &size.rheight());
- screen->releaseDFBSurface(dfbSurface);
- imageFormat = screen->alphaPixmapFormat();
- d = QDirectFBScreen::depth(imageFormat);
- dfbSurface = screen->createDFBSurface(size, screen->alphaPixmapFormat(), QDirectFBScreen::TrackSurface);
- setSerialNumber(++global_ser_no);
- if (!dfbSurface) {
- qWarning("QDirectFBPixmapData::fill()");
- invalidate();
- return;
- }
- }
-
- dfbSurface->Clear(dfbSurface, color.red(), color.green(), color.blue(), color.alpha());
-}
-
-QPixmap QDirectFBPixmapData::transformed(const QTransform &transform,
- Qt::TransformationMode mode) const
-{
- QDirectFBPixmapData *that = const_cast<QDirectFBPixmapData*>(this);
-#ifdef QT_NO_DIRECTFB_SUBSURFACE
- if (lockFlags())
- that->unlockSurface();
-#endif
-
- if (!dfbSurface || transform.type() != QTransform::TxScale
- || mode != Qt::FastTransformation)
- {
- const QImage *image = that->buffer();
- Q_ASSERT(image);
- const QImage transformed = image->transformed(transform, mode);
- QDirectFBPixmapData *data = new QDirectFBPixmapData(screen, QPixmapData::PixmapType);
- data->fromImage(transformed, Qt::AutoColor);
- return QPixmap(data);
- }
-
- const QSize size = transform.mapRect(QRect(0, 0, w, h)).size();
- if (size.isEmpty())
- return QPixmap();
-
- QDirectFBPixmapData *data = new QDirectFBPixmapData(screen, QPixmapData::PixmapType);
- data->setSerialNumber(++global_ser_no);
- DFBSurfaceBlittingFlags flags = DSBLIT_NOFX;
- data->alpha = alpha;
- if (alpha) {
- flags = DSBLIT_BLEND_ALPHACHANNEL;
- }
- data->dfbSurface = screen->createDFBSurface(size,
- imageFormat,
- QDirectFBScreen::TrackSurface);
- if (flags & DSBLIT_BLEND_ALPHACHANNEL) {
- data->dfbSurface->Clear(data->dfbSurface, 0, 0, 0, 0);
- }
- data->dfbSurface->SetBlittingFlags(data->dfbSurface, flags);
-
- const DFBRectangle destRect = { 0, 0, size.width(), size.height() };
- data->dfbSurface->StretchBlit(data->dfbSurface, dfbSurface, 0, &destRect);
- data->w = size.width();
- data->h = size.height();
- data->is_null = (data->w <= 0 || data->h <= 0);
-
-#if (Q_DIRECTFB_VERSION >= 0x010000)
- data->dfbSurface->ReleaseSource(data->dfbSurface);
-#endif
- return QPixmap(data);
-}
-
-QImage QDirectFBPixmapData::toImage() const
-{
- if (!dfbSurface)
- return QImage();
-
-#if 0
- // In later versions of DirectFB one can set a flag to tell
- // DirectFB not to move the surface to videomemory. When that
- // happens we can use this (hopefully faster) codepath
-#ifndef QT_NO_DIRECTFB_PREALLOCATED
- QImage ret(w, h, QDirectFBScreen::getImageFormat(dfbSurface));
- if (IDirectFBSurface *imgSurface = screen->createDFBSurface(ret, QDirectFBScreen::DontTrackSurface)) {
- if (hasAlphaChannel()) {
- imgSurface->SetBlittingFlags(imgSurface, DSBLIT_BLEND_ALPHACHANNEL);
- imgSurface->Clear(imgSurface, 0, 0, 0, 0);
- } else {
- imgSurface->SetBlittingFlags(imgSurface, DSBLIT_NOFX);
- }
- imgSurface->Blit(imgSurface, dfbSurface, 0, 0, 0);
-#if (Q_DIRECTFB_VERSION >= 0x010000)
- imgSurface->ReleaseSource(imgSurface);
-#endif
- imgSurface->Release(imgSurface);
- return ret;
- }
-#endif
-#endif
-
- QDirectFBPixmapData *that = const_cast<QDirectFBPixmapData*>(this);
- const QImage *img = that->buffer();
- return img->copy();
-}
-
-/* This is QPixmapData::paintEngine(), not QPaintDevice::paintEngine() */
-
-QPaintEngine *QDirectFBPixmapData::paintEngine() const
-{
- if (!engine) {
- // QDirectFBPixmapData is also a QCustomRasterPaintDevice, so pass
- // that to the paint engine:
- QDirectFBPixmapData *that = const_cast<QDirectFBPixmapData*>(this);
- that->engine = new QDirectFBPaintEngine(that);
- }
- return engine;
-}
-
-QImage *QDirectFBPixmapData::buffer()
-{
- if (!lockFlgs) {
- lockSurface(DSLF_READ|DSLF_WRITE);
- }
- Q_ASSERT(lockFlgs);
- Q_ASSERT(!lockedImage.isNull());
- return &lockedImage;
-}
-
-
-bool QDirectFBPixmapData::scroll(int dx, int dy, const QRect &rect)
-{
- if (!dfbSurface) {
- return false;
- }
- unlockSurface();
- DFBResult result = dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBPixmapData::scroll", result);
- return false;
- }
- result = dfbSurface->SetPorterDuff(dfbSurface, DSPD_NONE);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBPixmapData::scroll", result);
- return false;
- }
-
- const DFBRectangle source = { rect.x(), rect.y(), rect.width(), rect.height() };
- result = dfbSurface->Blit(dfbSurface, dfbSurface, &source, source.x + dx, source.y + dy);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBPixmapData::scroll", result);
- return false;
- }
-
- return true;
-}
-
-void QDirectFBPixmapData::invalidate()
-{
- if (dfbSurface) {
- screen->releaseDFBSurface(dfbSurface);
- dfbSurface = 0;
- }
- setSerialNumber(0);
- alpha = false;
- d = w = h = 0;
- is_null = true;
- imageFormat = QImage::Format_Invalid;
-}
-
-Q_GUI_EXPORT IDirectFBSurface *qt_directfb_surface_for_pixmap(const QPixmap &pixmap)
-{
- const QPixmapData *data = pixmap.pixmapData();
- if (!data || data->classId() != QPixmapData::DirectFBClass)
- return 0;
- const QDirectFBPixmapData *dfbData = static_cast<const QDirectFBPixmapData*>(data);
- return dfbData->directFBSurface();
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_DIRECTFB
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h b/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h
deleted file mode 100644
index f8e3fa1d84..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbpixmap.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDIRECTFBPIXMAP_H
-#define QDIRECTFBPIXMAP_H
-
-#include <qglobal.h>
-
-#ifndef QT_NO_QWS_DIRECTFB
-
-#include <QtGui/private/qpixmapdata_p.h>
-#include <QtGui/private/qpaintengine_raster_p.h>
-#include "qdirectfbpaintdevice.h"
-#include <directfb.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QDirectFBPaintEngine;
-
-class QDirectFBPixmapData : public QPixmapData, public QDirectFBPaintDevice
-{
-public:
- QDirectFBPixmapData(QDirectFBScreen *screen, PixelType pixelType);
- ~QDirectFBPixmapData();
-
- // Re-implemented from QPixmapData:
- virtual void resize(int width, int height);
- virtual void fromImage(const QImage &image, Qt::ImageConversionFlags flags);
-#ifdef QT_DIRECTFB_IMAGEPROVIDER
- virtual bool fromFile(const QString &filename, const char *format,
- Qt::ImageConversionFlags flags);
- virtual bool fromData(const uchar *buffer, uint len, const char *format,
- Qt::ImageConversionFlags flags);
-#endif
- virtual void copy(const QPixmapData *data, const QRect &rect);
- virtual void fill(const QColor &color);
- virtual QPixmap transformed(const QTransform &matrix,
- Qt::TransformationMode mode) const;
- virtual QImage toImage() const;
- virtual QPaintEngine *paintEngine() const;
- virtual QImage *buffer();
- virtual bool scroll(int dx, int dy, const QRect &rect);
- // Pure virtual in QPixmapData, so re-implement here and delegate to QDirectFBPaintDevice
- virtual int metric(QPaintDevice::PaintDeviceMetric m) const { return QDirectFBPaintDevice::metric(m); }
-
- inline QImage::Format pixelFormat() const { return imageFormat; }
- inline bool hasAlphaChannel() const { return alpha; }
- static bool hasAlphaChannel(const QImage &img, Qt::ImageConversionFlags flags = Qt::AutoColor);
-private:
-#ifdef QT_DIRECTFB_IMAGEPROVIDER
- bool fromDataBufferDescription(const DFBDataBufferDescription &dataBuffer);
-#endif
- void invalidate();
- bool alpha;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_QWS_DIRECTFB
-
-#endif // QDIRECTFBPIXMAP_H
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
deleted file mode 100644
index ff15078ee4..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.cpp
+++ /dev/null
@@ -1,1819 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdirectfbscreen.h"
-#include "qdirectfbwindowsurface.h"
-#include "qdirectfbpixmap.h"
-#include "qdirectfbmouse.h"
-#include "qdirectfbkeyboard.h"
-#include <QtGui/qwsdisplay_qws.h>
-#include <QtGui/qcolor.h>
-#include <QtGui/qapplication.h>
-#include <QtGui/qwindowsystem_qws.h>
-#include <QtGui/private/qgraphicssystem_qws_p.h>
-#include <QtGui/private/qwssignalhandler_p.h>
-#include <QtCore/qvarlengtharray.h>
-#include <QtCore/qvector.h>
-#include <QtCore/qrect.h>
-
-#ifndef QT_NO_QWS_DIRECTFB
-
-QT_BEGIN_NAMESPACE
-
-class QDirectFBScreenPrivate : public QObject, public QWSGraphicsSystem
-{
- Q_OBJECT
-public:
- QDirectFBScreenPrivate(QDirectFBScreen *qptr);
- ~QDirectFBScreenPrivate();
-
- void setFlipFlags(const QStringList &args);
- QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
-public slots:
-#ifdef QT_DIRECTFB_WM
- void onWindowEvent(QWSWindow *window, QWSServer::WindowEvent event);
-#endif
-public:
- IDirectFB *dfb;
- DFBSurfaceFlipFlags flipFlags;
- QDirectFBScreen::DirectFBFlags directFBFlags;
- QImage::Format alphaPixmapFormat;
- IDirectFBScreen *dfbScreen;
-#ifdef QT_NO_DIRECTFB_WM
- IDirectFBSurface *primarySurface;
- QColor backgroundColor;
-#endif
-#ifndef QT_NO_DIRECTFB_LAYER
- IDirectFBDisplayLayer *dfbLayer;
-#endif
- QSet<IDirectFBSurface*> allocatedSurfaces;
-
-#ifndef QT_NO_DIRECTFB_MOUSE
- QDirectFBMouseHandler *mouse;
-#endif
-#ifndef QT_NO_DIRECTFB_KEYBOARD
- QDirectFBKeyboardHandler *keyboard;
-#endif
-#if defined QT_DIRECTFB_IMAGEPROVIDER && defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE
- IDirectFBImageProvider *imageProvider;
-#endif
- IDirectFBSurface *cursorSurface;
- qint64 cursorImageKey;
-
- QDirectFBScreen *q;
- static QDirectFBScreen *instance;
-};
-
-QDirectFBScreen *QDirectFBScreenPrivate::instance = 0;
-
-QDirectFBScreenPrivate::QDirectFBScreenPrivate(QDirectFBScreen *qptr)
- : QWSGraphicsSystem(qptr), dfb(0), flipFlags(DSFLIP_NONE),
- directFBFlags(QDirectFBScreen::NoFlags), alphaPixmapFormat(QImage::Format_Invalid),
- dfbScreen(0)
-#ifdef QT_NO_DIRECTFB_WM
- , primarySurface(0)
-#endif
-#ifndef QT_NO_DIRECTFB_LAYER
- , dfbLayer(0)
-#endif
-#ifndef QT_NO_DIRECTFB_MOUSE
- , mouse(0)
-#endif
-#ifndef QT_NO_DIRECTFB_KEYBOARD
- , keyboard(0)
-#endif
-#if defined QT_DIRECTFB_IMAGEPROVIDER && defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE
- , imageProvider(0)
-#endif
- , cursorSurface(0)
- , cursorImageKey(0)
- , q(qptr)
-{
-#ifndef QT_NO_QWS_SIGNALHANDLER
- QWSSignalHandler::instance()->addObject(this);
-#endif
-#ifdef QT_DIRECTFB_WM
- connect(QWSServer::instance(), SIGNAL(windowEvent(QWSWindow*,QWSServer::WindowEvent)),
- this, SLOT(onWindowEvent(QWSWindow*,QWSServer::WindowEvent)));
-#endif
-}
-
-QDirectFBScreenPrivate::~QDirectFBScreenPrivate()
-{
-#ifndef QT_NO_DIRECTFB_MOUSE
- delete mouse;
-#endif
-#ifndef QT_NO_DIRECTFB_KEYBOARD
- delete keyboard;
-#endif
-#if defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE
- if (imageProvider)
- imageProvider->Release(imageProvider);
-#endif
-
- for (QSet<IDirectFBSurface*>::const_iterator it = allocatedSurfaces.begin(); it != allocatedSurfaces.end(); ++it) {
- (*it)->Release(*it);
- }
-
-#ifdef QT_NO_DIRECTFB_WM
- if (primarySurface)
- primarySurface->Release(primarySurface);
-#endif
-
-#ifndef QT_NO_DIRECTFB_LAYER
- if (dfbLayer)
- dfbLayer->Release(dfbLayer);
-#endif
-
- if (dfbScreen)
- dfbScreen->Release(dfbScreen);
-
- if (dfb)
- dfb->Release(dfb);
-}
-
-IDirectFBSurface *QDirectFBScreen::createDFBSurface(const QImage &image, QImage::Format format, SurfaceCreationOptions options, DFBResult *resultPtr)
-{
- if (image.isNull()) // assert?
- return 0;
-
- if (QDirectFBScreen::getSurfacePixelFormat(format) == DSPF_UNKNOWN) {
- format = QDirectFBPixmapData::hasAlphaChannel(image) ? d_ptr->alphaPixmapFormat : pixelFormat();
- }
- if (image.format() != format) {
- return createDFBSurface(image.convertToFormat(format), format, options | NoPreallocated, resultPtr);
- }
-
- DFBSurfaceDescription description;
- memset(&description, 0, sizeof(DFBSurfaceDescription));
- description.width = image.width();
- description.height = image.height();
- description.flags = DSDESC_WIDTH|DSDESC_HEIGHT|DSDESC_PIXELFORMAT;
- initSurfaceDescriptionPixelFormat(&description, format);
- bool doMemCopy = true;
-#ifdef QT_DIRECTFB_PREALLOCATED
- if (!(options & NoPreallocated)) {
- doMemCopy = false;
- description.flags |= DSDESC_PREALLOCATED;
- description.preallocated[0].data = const_cast<uchar*>(image.bits());
- description.preallocated[0].pitch = image.bytesPerLine();
- description.preallocated[1].data = 0;
- description.preallocated[1].pitch = 0;
- }
-#endif
- DFBResult result;
- IDirectFBSurface *surface = createDFBSurface(description, options, &result);
- if (resultPtr)
- *resultPtr = result;
- if (!surface) {
- DirectFBError("Couldn't create surface createDFBSurface(QImage, QImage::Format, SurfaceCreationOptions)", result);
- return 0;
- }
- if (doMemCopy) {
- int bplDFB;
- uchar *mem = QDirectFBScreen::lockSurface(surface, DSLF_WRITE, &bplDFB);
- if (mem) {
- const int height = image.height();
- const int bplQt = image.bytesPerLine();
- if (bplQt == bplDFB && bplQt == (image.width() * image.depth() / 8)) {
- memcpy(mem, image.bits(), image.byteCount());
- } else {
- for (int i=0; i<height; ++i) {
- memcpy(mem, image.scanLine(i), bplQt);
- mem += bplDFB;
- }
- }
- surface->Unlock(surface);
- }
- }
-#ifdef QT_DIRECTFB_PALETTE
- if (image.colorCount() != 0 && surface)
- QDirectFBScreen::setSurfaceColorTable(surface, image);
-#endif
- return surface;
-}
-
-IDirectFBSurface *QDirectFBScreen::copyDFBSurface(IDirectFBSurface *src,
- QImage::Format format,
- SurfaceCreationOptions options,
- DFBResult *result)
-{
- Q_ASSERT(src);
- QSize size;
- src->GetSize(src, &size.rwidth(), &size.rheight());
- IDirectFBSurface *surface = createDFBSurface(size, format, options, result);
- DFBSurfaceBlittingFlags flags = QDirectFBScreen::hasAlphaChannel(surface)
- ? DSBLIT_BLEND_ALPHACHANNEL
- : DSBLIT_NOFX;
- if (flags & DSBLIT_BLEND_ALPHACHANNEL)
- surface->Clear(surface, 0, 0, 0, 0);
-
- surface->SetBlittingFlags(surface, flags);
- surface->Blit(surface, src, 0, 0, 0);
-#if (Q_DIRECTFB_VERSION >= 0x010000)
- surface->ReleaseSource(surface);
-#endif
- return surface;
-}
-
-IDirectFBSurface *QDirectFBScreen::createDFBSurface(const QSize &size,
- QImage::Format format,
- SurfaceCreationOptions options,
- DFBResult *result)
-{
- DFBSurfaceDescription desc;
- memset(&desc, 0, sizeof(DFBSurfaceDescription));
- desc.flags |= DSDESC_WIDTH|DSDESC_HEIGHT;
- if (!QDirectFBScreen::initSurfaceDescriptionPixelFormat(&desc, format))
- return 0;
- desc.width = size.width();
- desc.height = size.height();
- return createDFBSurface(desc, options, result);
-}
-
-IDirectFBSurface *QDirectFBScreen::createDFBSurface(DFBSurfaceDescription desc, SurfaceCreationOptions options, DFBResult *resultPtr)
-{
- DFBResult tmp;
- DFBResult &result = (resultPtr ? *resultPtr : tmp);
- result = DFB_OK;
- IDirectFBSurface *newSurface = 0;
-
- if (!d_ptr->dfb) {
- qWarning("QDirectFBScreen::createDFBSurface() - not connected");
- return 0;
- }
-
- if (d_ptr->directFBFlags & VideoOnly
- && !(desc.flags & DSDESC_PREALLOCATED)
- && (!(desc.flags & DSDESC_CAPS) || !(desc.caps & DSCAPS_SYSTEMONLY))) {
- // Add the video only capability. This means the surface will be created in video ram
- if (!(desc.flags & DSDESC_CAPS)) {
- desc.caps = DSCAPS_VIDEOONLY;
- desc.flags |= DSDESC_CAPS;
- } else {
- desc.caps |= DSCAPS_VIDEOONLY;
- }
- result = d_ptr->dfb->CreateSurface(d_ptr->dfb, &desc, &newSurface);
- if (result != DFB_OK
-#ifdef QT_NO_DEBUG
- && (desc.flags & DSDESC_CAPS) && (desc.caps & DSCAPS_PRIMARY)
-#endif
- ) {
- qWarning("QDirectFBScreen::createDFBSurface() Failed to create surface in video memory!\n"
- " Flags %0x Caps %0x width %d height %d pixelformat %0x %d preallocated %p %d\n%s",
- desc.flags, desc.caps, desc.width, desc.height,
- desc.pixelformat, DFB_PIXELFORMAT_INDEX(desc.pixelformat),
- desc.preallocated[0].data, desc.preallocated[0].pitch,
- DirectFBErrorString(result));
- }
- desc.caps &= ~DSCAPS_VIDEOONLY;
- }
-
- if (d_ptr->directFBFlags & SystemOnly)
- desc.caps |= DSCAPS_SYSTEMONLY;
-
- if (!newSurface)
- result = d_ptr->dfb->CreateSurface(d_ptr->dfb, &desc, &newSurface);
-
- if (result != DFB_OK) {
- qWarning("QDirectFBScreen::createDFBSurface() Failed!\n"
- " Flags %0x Caps %0x width %d height %d pixelformat %0x %d preallocated %p %d\n%s",
- desc.flags, desc.caps, desc.width, desc.height,
- desc.pixelformat, DFB_PIXELFORMAT_INDEX(desc.pixelformat),
- desc.preallocated[0].data, desc.preallocated[0].pitch,
- DirectFBErrorString(result));
- return 0;
- }
-
- Q_ASSERT(newSurface);
-
- if (options & TrackSurface) {
- d_ptr->allocatedSurfaces.insert(newSurface);
- }
-
- return newSurface;
-}
-
-#ifdef QT_DIRECTFB_SUBSURFACE
-IDirectFBSurface *QDirectFBScreen::getSubSurface(IDirectFBSurface *surface,
- const QRect &rect,
- SurfaceCreationOptions options,
- DFBResult *resultPtr)
-{
- Q_ASSERT(!(options & NoPreallocated));
- Q_ASSERT(surface);
- DFBResult res;
- DFBResult &result = (resultPtr ? *resultPtr : res);
- IDirectFBSurface *subSurface = 0;
- if (rect.isNull()) {
- result = surface->GetSubSurface(surface, 0, &subSurface);
- } else {
- const DFBRectangle subRect = { rect.x(), rect.y(), rect.width(), rect.height() };
- result = surface->GetSubSurface(surface, &subRect, &subSurface);
- }
- if (result != DFB_OK) {
- DirectFBError("Can't get sub surface", result);
- } else if (options & TrackSurface) {
- d_ptr->allocatedSurfaces.insert(subSurface);
- }
- return subSurface;
-}
-#endif
-
-
-void QDirectFBScreen::releaseDFBSurface(IDirectFBSurface *surface)
-{
- Q_ASSERT(QDirectFBScreen::instance());
- Q_ASSERT(surface);
- surface->Release(surface);
- if (!d_ptr->allocatedSurfaces.remove(surface))
- qWarning("QDirectFBScreen::releaseDFBSurface() - %p not in list", surface);
-
- //qDebug("Released surface at %p. New count = %d", surface, d_ptr->allocatedSurfaces.count());
-}
-
-QDirectFBScreen::DirectFBFlags QDirectFBScreen::directFBFlags() const
-{
- return d_ptr->directFBFlags;
-}
-
-IDirectFB *QDirectFBScreen::dfb()
-{
- return d_ptr->dfb;
-}
-
-#ifdef QT_NO_DIRECTFB_WM
-IDirectFBSurface *QDirectFBScreen::primarySurface()
-{
- return d_ptr->primarySurface;
-}
-#endif
-
-#ifndef QT_NO_DIRECTFB_LAYER
-IDirectFBDisplayLayer *QDirectFBScreen::dfbDisplayLayer()
-{
- return d_ptr->dfbLayer;
-}
-#endif
-
-DFBSurfacePixelFormat QDirectFBScreen::getSurfacePixelFormat(QImage::Format format)
-{
- switch (format) {
-#ifndef QT_NO_DIRECTFB_PALETTE
- case QImage::Format_Indexed8:
- return DSPF_LUT8;
-#endif
- case QImage::Format_RGB888:
- return DSPF_RGB24;
- case QImage::Format_ARGB4444_Premultiplied:
- return DSPF_ARGB4444;
-#if (Q_DIRECTFB_VERSION >= 0x010100)
- case QImage::Format_RGB444:
- return DSPF_RGB444;
- case QImage::Format_RGB555:
- return DSPF_RGB555;
-#endif
- case QImage::Format_RGB16:
- return DSPF_RGB16;
-#if (Q_DIRECTFB_VERSION >= 0x010000)
- case QImage::Format_ARGB6666_Premultiplied:
- return DSPF_ARGB6666;
- case QImage::Format_RGB666:
- return DSPF_RGB18;
-#endif
- case QImage::Format_RGB32:
- return DSPF_RGB32;
- case QImage::Format_ARGB32_Premultiplied:
- case QImage::Format_ARGB32:
- return DSPF_ARGB;
- default:
- return DSPF_UNKNOWN;
- };
-}
-
-QImage::Format QDirectFBScreen::getImageFormat(IDirectFBSurface *surface)
-{
- DFBSurfacePixelFormat format;
- surface->GetPixelFormat(surface, &format);
-
- switch (format) {
- case DSPF_LUT8:
- return QImage::Format_Indexed8;
- case DSPF_RGB24:
- return QImage::Format_RGB888;
- case DSPF_ARGB4444:
- return QImage::Format_ARGB4444_Premultiplied;
-#if (Q_DIRECTFB_VERSION >= 0x010100)
- case DSPF_RGB444:
- return QImage::Format_RGB444;
- case DSPF_RGB555:
-#endif
- case DSPF_ARGB1555:
- return QImage::Format_RGB555;
- case DSPF_RGB16:
- return QImage::Format_RGB16;
-#if (Q_DIRECTFB_VERSION >= 0x010000)
- case DSPF_ARGB6666:
- return QImage::Format_ARGB6666_Premultiplied;
- case DSPF_RGB18:
- return QImage::Format_RGB666;
-#endif
- case DSPF_RGB32:
- return QImage::Format_RGB32;
- case DSPF_ARGB: {
- DFBSurfaceCapabilities caps;
- const DFBResult result = surface->GetCapabilities(surface, &caps);
- Q_ASSERT(result == DFB_OK);
- Q_UNUSED(result);
- return (caps & DSCAPS_PREMULTIPLIED
- ? QImage::Format_ARGB32_Premultiplied
- : QImage::Format_ARGB32); }
- default:
- break;
- }
- return QImage::Format_Invalid;
-}
-
-DFBSurfaceDescription QDirectFBScreen::getSurfaceDescription(const uint *buffer,
- int length)
-{
- DFBSurfaceDescription description;
- memset(&description, 0, sizeof(DFBSurfaceDescription));
-
- description.flags = DSDESC_CAPS|DSDESC_WIDTH|DSDESC_HEIGHT|DSDESC_PIXELFORMAT|DSDESC_PREALLOCATED;
- description.caps = DSCAPS_PREMULTIPLIED;
- description.width = length;
- description.height = 1;
- description.pixelformat = DSPF_ARGB;
- description.preallocated[0].data = (void*)buffer;
- description.preallocated[0].pitch = length * sizeof(uint);
- description.preallocated[1].data = 0;
- description.preallocated[1].pitch = 0;
- return description;
-}
-
-#ifndef QT_NO_DIRECTFB_PALETTE
-void QDirectFBScreen::setSurfaceColorTable(IDirectFBSurface *surface,
- const QImage &image)
-{
- if (!surface)
- return;
-
- const int numColors = image.colorCount();
- if (numColors == 0)
- return;
-
- QVarLengthArray<DFBColor, 256> colors(numColors);
- for (int i = 0; i < numColors; ++i) {
- QRgb c = image.color(i);
- colors[i].a = qAlpha(c);
- colors[i].r = qRed(c);
- colors[i].g = qGreen(c);
- colors[i].b = qBlue(c);
- }
-
- IDirectFBPalette *palette;
- DFBResult result;
- result = surface->GetPalette(surface, &palette);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreen::setSurfaceColorTable GetPalette",
- result);
- return;
- }
- result = palette->SetEntries(palette, colors.data(), numColors, 0);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreen::setSurfaceColorTable SetEntries",
- result);
- }
- palette->Release(palette);
-}
-
-#endif // QT_NO_DIRECTFB_PALETTE
-
-#if defined QT_DIRECTFB_CURSOR
-class Q_GUI_EXPORT QDirectFBScreenCursor : public QScreenCursor
-{
-public:
- QDirectFBScreenCursor();
- virtual void set(const QImage &image, int hotx, int hoty);
- virtual void move(int x, int y);
- virtual void show();
- virtual void hide();
-private:
-#ifdef QT_DIRECTFB_WINDOW_AS_CURSOR
- ~QDirectFBScreenCursor();
- bool createWindow();
- IDirectFBWindow *window;
-#endif
- IDirectFBDisplayLayer *layer;
-};
-
-QDirectFBScreenCursor::QDirectFBScreenCursor()
-{
- IDirectFB *fb = QDirectFBScreen::instance()->dfb();
- if (!fb)
- qFatal("QDirectFBScreenCursor: DirectFB not initialized");
-
- layer = QDirectFBScreen::instance()->dfbDisplayLayer();
- Q_ASSERT(layer);
-
- enable = false;
- hwaccel = true;
- supportsAlpha = true;
-#ifdef QT_DIRECTFB_WINDOW_AS_CURSOR
- window = 0;
- DFBResult result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::hide: "
- "Unable to set cooperative level", result);
- }
- result = layer->SetCursorOpacity(layer, 0);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::hide: "
- "Unable to set cursor opacity", result);
- }
-
- result = layer->SetCooperativeLevel(layer, DLSCL_SHARED);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::hide: "
- "Unable to set cooperative level", result);
- }
-#endif
-}
-
-#ifdef QT_DIRECTFB_WINDOW_AS_CURSOR
-QDirectFBScreenCursor::~QDirectFBScreenCursor()
-{
- if (window) {
- window->Release(window);
- window = 0;
- }
-}
-
-bool QDirectFBScreenCursor::createWindow()
-{
- Q_ASSERT(!window);
- Q_ASSERT(!cursor.isNull());
- DFBWindowDescription description;
- memset(&description, 0, sizeof(DFBWindowDescription));
- description.flags = DWDESC_POSX|DWDESC_POSY|DWDESC_WIDTH|DWDESC_HEIGHT|DWDESC_CAPS|DWDESC_PIXELFORMAT|DWDESC_SURFACE_CAPS;
- description.width = cursor.width();
- description.height = cursor.height();
- description.posx = pos.x() - hotspot.x();
- description.posy = pos.y() - hotspot.y();
-#if (Q_DIRECTFB_VERSION >= 0x010100)
- description.flags |= DWDESC_OPTIONS;
- description.options = DWOP_GHOST|DWOP_ALPHACHANNEL;
-#endif
- description.caps = DWCAPS_NODECORATION|DWCAPS_DOUBLEBUFFER;
- const QImage::Format format = QDirectFBScreen::instance()->alphaPixmapFormat();
- description.pixelformat = QDirectFBScreen::getSurfacePixelFormat(format);
- if (QDirectFBScreen::isPremultiplied(format))
- description.surface_caps = DSCAPS_PREMULTIPLIED;
-
- DFBResult result = layer->CreateWindow(layer, &description, &window);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::createWindow: Unable to create window", result);
- return false;
- }
- result = window->SetOpacity(window, 255);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::createWindow: Unable to set opacity ", result);
- return false;
- }
-
- result = window->SetStackingClass(window, DWSC_UPPER);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::createWindow: Unable to set stacking class ", result);
- return false;
- }
-
- result = window->RaiseToTop(window);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::createWindow: Unable to raise window ", result);
- return false;
- }
-
- return true;
-}
-#endif
-
-void QDirectFBScreenCursor::move(int x, int y)
-{
- pos = QPoint(x, y);
-#ifdef QT_DIRECTFB_WINDOW_AS_CURSOR
- if (window) {
- const QPoint p = pos - hotspot;
- DFBResult result = window->MoveTo(window, p.x(), p.y());
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::move: Unable to move window", result);
- }
- }
-#else
- layer->WarpCursor(layer, x, y);
-#endif
-}
-
-void QDirectFBScreenCursor::hide()
-{
- if (enable) {
- enable = false;
- DFBResult result;
-#ifndef QT_DIRECTFB_WINDOW_AS_CURSOR
- result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::hide: "
- "Unable to set cooperative level", result);
- }
- result = layer->SetCursorOpacity(layer, 0);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::hide: "
- "Unable to set cursor opacity", result);
- }
- result = layer->SetCooperativeLevel(layer, DLSCL_SHARED);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::hide: "
- "Unable to set cooperative level", result);
- }
-#else
- if (window) {
- result = window->SetOpacity(window, 0);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::hide: "
- "Unable to set window opacity", result);
- }
- }
-#endif
- }
-}
-
-void QDirectFBScreenCursor::show()
-{
- if (!enable) {
- enable = true;
- DFBResult result;
- result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::show: "
- "Unable to set cooperative level", result);
- }
- result = layer->SetCursorOpacity(layer,
-#ifdef QT_DIRECTFB_WINDOW_AS_CURSOR
- 0
-#else
- 255
-#endif
- );
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::show: "
- "Unable to set cursor shape", result);
- }
- result = layer->SetCooperativeLevel(layer, DLSCL_SHARED);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::show: "
- "Unable to set cooperative level", result);
- }
-#ifdef QT_DIRECTFB_WINDOW_AS_CURSOR
- if (window) {
- DFBResult result = window->SetOpacity(window, 255);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::show: "
- "Unable to set window opacity", result);
- }
- }
-#endif
- }
-}
-
-void QDirectFBScreenCursor::set(const QImage &image, int hotx, int hoty)
-{
- QDirectFBScreen *screen = QDirectFBScreen::instance();
- if (!screen)
- return;
-
- if (image.isNull()) {
- cursor = QImage();
- hide();
- } else {
- cursor = image.convertToFormat(screen->alphaPixmapFormat());
- size = cursor.size();
- hotspot = QPoint(hotx, hoty);
- DFBResult result = DFB_OK;
- IDirectFBSurface *surface = screen->createDFBSurface(cursor, screen->alphaPixmapFormat(),
- QDirectFBScreen::DontTrackSurface, &result);
- if (!surface) {
- DirectFBError("QDirectFBScreenCursor::set: Unable to create surface", result);
- return;
- }
-#ifndef QT_DIRECTFB_WINDOW_AS_CURSOR
- result = layer->SetCooperativeLevel(layer, DLSCL_ADMINISTRATIVE);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::show: "
- "Unable to set cooperative level", result);
- }
- result = layer->SetCursorShape(layer, surface, hotx, hoty);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::show: "
- "Unable to set cursor shape", result);
- }
- result = layer->SetCooperativeLevel(layer, DLSCL_SHARED);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::show: "
- "Unable to set cooperative level", result);
- }
-#else
- if (window || createWindow()) {
- QSize windowSize;
- result = window->GetSize(window, &windowSize.rwidth(), &windowSize.rheight());
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::set: "
- "Unable to get window size", result);
- }
- result = window->Resize(window, size.width(), size.height());
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::set: Unable to resize window", result);
- }
-
- IDirectFBSurface *windowSurface;
- result = window->GetSurface(window, &windowSurface);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::set: Unable to get window surface", result);
- } else {
- result = windowSurface->Clear(windowSurface, 0, 0, 0, 0);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::set: Unable to clear surface", result);
- }
-
- result = windowSurface->Blit(windowSurface, surface, 0, 0, 0);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::set: Unable to blit to surface", result);
- }
- }
- result = windowSurface->Flip(windowSurface, 0, DSFLIP_NONE);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::set: Unable to flip window", result);
- }
-
- windowSurface->Release(windowSurface);
- }
-#endif
- surface->Release(surface);
- show();
- }
-
-}
-#endif // QT_DIRECTFB_CURSOR
-
-QDirectFBScreen::QDirectFBScreen(int display_id)
- : QScreen(display_id, DirectFBClass), d_ptr(new QDirectFBScreenPrivate(this))
-{
- QDirectFBScreenPrivate::instance = this;
-}
-
-QDirectFBScreen::~QDirectFBScreen()
-{
- if (QDirectFBScreenPrivate::instance == this)
- QDirectFBScreenPrivate::instance = 0;
- delete d_ptr;
-}
-
-QDirectFBScreen *QDirectFBScreen::instance()
-{
- return QDirectFBScreenPrivate::instance;
-}
-
-int QDirectFBScreen::depth(DFBSurfacePixelFormat format)
-{
- switch (format) {
- case DSPF_A1:
- return 1;
- case DSPF_A8:
- case DSPF_RGB332:
- case DSPF_LUT8:
- case DSPF_ALUT44:
- return 8;
- case DSPF_I420:
- case DSPF_YV12:
- case DSPF_NV12:
- case DSPF_NV21:
-#if (Q_DIRECTFB_VERSION >= 0x010100)
- case DSPF_RGB444:
-#endif
- return 12;
-#if (Q_DIRECTFB_VERSION >= 0x010100)
- case DSPF_RGB555:
- return 15;
-#endif
- case DSPF_ARGB1555:
- case DSPF_RGB16:
- case DSPF_YUY2:
- case DSPF_UYVY:
- case DSPF_NV16:
- case DSPF_ARGB2554:
- case DSPF_ARGB4444:
- return 16;
- case DSPF_RGB24:
- return 24;
- case DSPF_RGB32:
- case DSPF_ARGB:
- case DSPF_AiRGB:
- return 32;
- case DSPF_UNKNOWN:
- default:
- return 0;
- };
- return 0;
-}
-
-int QDirectFBScreen::depth(QImage::Format format)
-{
- int depth = 0;
- switch(format) {
- case QImage::Format_Invalid:
- case QImage::NImageFormats:
- Q_ASSERT(false);
- case QImage::Format_Mono:
- case QImage::Format_MonoLSB:
- depth = 1;
- break;
- case QImage::Format_Indexed8:
- depth = 8;
- break;
- case QImage::Format_RGB32:
- case QImage::Format_ARGB32:
- case QImage::Format_ARGB32_Premultiplied:
- depth = 32;
- break;
- case QImage::Format_RGB555:
- case QImage::Format_RGB16:
- case QImage::Format_RGB444:
- case QImage::Format_ARGB4444_Premultiplied:
- depth = 16;
- break;
- case QImage::Format_RGB666:
- case QImage::Format_ARGB6666_Premultiplied:
- case QImage::Format_ARGB8565_Premultiplied:
- case QImage::Format_ARGB8555_Premultiplied:
- case QImage::Format_RGB888:
- depth = 24;
- break;
- }
- return depth;
-}
-
-void QDirectFBScreenPrivate::setFlipFlags(const QStringList &args)
-{
- QRegExp flipRegexp(QLatin1String("^flip=([\\w,]*)$"));
- int index = args.indexOf(flipRegexp);
- if (index >= 0) {
- const QStringList flips = flipRegexp.cap(1).split(QLatin1Char(','),
- QString::SkipEmptyParts);
- flipFlags = DSFLIP_NONE;
- foreach(const QString &flip, flips) {
- if (flip == QLatin1String("wait"))
- flipFlags |= DSFLIP_WAIT;
- else if (flip == QLatin1String("blit"))
- flipFlags |= DSFLIP_BLIT;
- else if (flip == QLatin1String("onsync"))
- flipFlags |= DSFLIP_ONSYNC;
- else if (flip == QLatin1String("pipeline"))
- flipFlags |= DSFLIP_PIPELINE;
- else
- qWarning("QDirectFBScreen: Unknown flip argument: %s",
- qPrintable(flip));
- }
- } else {
- flipFlags = DSFLIP_BLIT|DSFLIP_ONSYNC;
- }
-}
-
-#ifdef QT_DIRECTFB_WM
-void QDirectFBScreenPrivate::onWindowEvent(QWSWindow *window, QWSServer::WindowEvent event)
-{
- if (event == QWSServer::Raise) {
- QWSWindowSurface *windowSurface = window->windowSurface();
- if (windowSurface && windowSurface->key() == QLatin1String("directfb")) {
- static_cast<QDirectFBWindowSurface*>(windowSurface)->raise();
- }
- }
-}
-#endif
-
-QPixmapData *QDirectFBScreenPrivate::createPixmapData(QPixmapData::PixelType type) const
-{
- if (type == QPixmapData::BitmapType)
- return QWSGraphicsSystem::createPixmapData(type);
-
- return new QDirectFBPixmapData(q, type);
-}
-
-#if (Q_DIRECTFB_VERSION >= 0x000923)
-#ifdef QT_NO_DEBUG
-struct FlagDescription;
-static const FlagDescription *accelerationDescriptions = 0;
-static const FlagDescription *blitDescriptions = 0;
-static const FlagDescription *drawDescriptions = 0;
-#else
-struct FlagDescription {
- const char *name;
- uint flag;
-};
-
-static const FlagDescription accelerationDescriptions[] = {
- { "DFXL_NONE", DFXL_NONE },
- { "DFXL_FILLRECTANGLE", DFXL_FILLRECTANGLE },
- { "DFXL_DRAWRECTANGLE", DFXL_DRAWRECTANGLE },
- { "DFXL_DRAWLINE", DFXL_DRAWLINE },
- { "DFXL_FILLTRIANGLE", DFXL_FILLTRIANGLE },
- { "DFXL_BLIT", DFXL_BLIT },
- { "DFXL_STRETCHBLIT", DFXL_STRETCHBLIT },
- { "DFXL_TEXTRIANGLES", DFXL_TEXTRIANGLES },
- { "DFXL_DRAWSTRING", DFXL_DRAWSTRING },
- { 0, 0 }
-};
-
-static const FlagDescription blitDescriptions[] = {
- { "DSBLIT_NOFX", DSBLIT_NOFX },
- { "DSBLIT_BLEND_ALPHACHANNEL", DSBLIT_BLEND_ALPHACHANNEL },
- { "DSBLIT_BLEND_COLORALPHA", DSBLIT_BLEND_COLORALPHA },
- { "DSBLIT_COLORIZE", DSBLIT_COLORIZE },
- { "DSBLIT_SRC_COLORKEY", DSBLIT_SRC_COLORKEY },
- { "DSBLIT_DST_COLORKEY", DSBLIT_DST_COLORKEY },
- { "DSBLIT_SRC_PREMULTIPLY", DSBLIT_SRC_PREMULTIPLY },
- { "DSBLIT_DST_PREMULTIPLY", DSBLIT_DST_PREMULTIPLY },
- { "DSBLIT_DEMULTIPLY", DSBLIT_DEMULTIPLY },
- { "DSBLIT_DEINTERLACE", DSBLIT_DEINTERLACE },
-#if (Q_DIRECTFB_VERSION >= 0x000923)
- { "DSBLIT_SRC_PREMULTCOLOR", DSBLIT_SRC_PREMULTCOLOR },
- { "DSBLIT_XOR", DSBLIT_XOR },
-#endif
-#if (Q_DIRECTFB_VERSION >= 0x010000)
- { "DSBLIT_INDEX_TRANSLATION", DSBLIT_INDEX_TRANSLATION },
-#endif
- { 0, 0 }
-};
-
-static const FlagDescription drawDescriptions[] = {
- { "DSDRAW_NOFX", DSDRAW_NOFX },
- { "DSDRAW_BLEND", DSDRAW_BLEND },
- { "DSDRAW_DST_COLORKEY", DSDRAW_DST_COLORKEY },
- { "DSDRAW_SRC_PREMULTIPLY", DSDRAW_SRC_PREMULTIPLY },
- { "DSDRAW_DST_PREMULTIPLY", DSDRAW_DST_PREMULTIPLY },
- { "DSDRAW_DEMULTIPLY", DSDRAW_DEMULTIPLY },
- { "DSDRAW_XOR", DSDRAW_XOR },
- { 0, 0 }
-};
-#endif
-
-static const QByteArray flagDescriptions(uint mask, const FlagDescription *flags)
-{
-#ifdef QT_NO_DEBUG
- Q_UNUSED(mask);
- Q_UNUSED(flags);
- return QByteArray("");
-#else
- if (!mask)
- return flags[0].name;
-
- QStringList list;
- for (int i=1; flags[i].name; ++i) {
- if (mask & flags[i].flag) {
- list.append(QString::fromLatin1(flags[i].name));
- }
- }
- Q_ASSERT(!list.isEmpty());
- return (QLatin1Char(' ') + list.join(QLatin1String("|"))).toLatin1();
-#endif
-}
-static void printDirectFBInfo(IDirectFB *fb, IDirectFBSurface *primarySurface)
-{
- DFBResult result;
- DFBGraphicsDeviceDescription dev;
-
- result = fb->GetDeviceDescription(fb, &dev);
- if (result != DFB_OK) {
- DirectFBError("Error reading graphics device description", result);
- return;
- }
-
- DFBSurfacePixelFormat pixelFormat;
- primarySurface->GetPixelFormat(primarySurface, &pixelFormat);
-
- qDebug("Device: %s (%s), Driver: %s v%i.%i (%s) Pixelformat: %d (%d)\n"
- "acceleration: 0x%x%s\nblit: 0x%x%s\ndraw: 0x%0x%s\nvideo: %iKB\n",
- dev.name, dev.vendor, dev.driver.name, dev.driver.major,
- dev.driver.minor, dev.driver.vendor, DFB_PIXELFORMAT_INDEX(pixelFormat),
- QDirectFBScreen::getImageFormat(primarySurface), dev.acceleration_mask,
- flagDescriptions(dev.acceleration_mask, accelerationDescriptions).constData(),
- dev.blitting_flags, flagDescriptions(dev.blitting_flags, blitDescriptions).constData(),
- dev.drawing_flags, flagDescriptions(dev.drawing_flags, drawDescriptions).constData(),
- (dev.video_memory >> 10));
-}
-#endif
-
-static inline bool setIntOption(const QStringList &arguments, const QString &variable, int *value)
-{
- Q_ASSERT(value);
- QRegExp rx(QString::fromLatin1("%1=?(\\d+)").arg(variable));
- rx.setCaseSensitivity(Qt::CaseInsensitive);
- if (arguments.indexOf(rx) != -1) {
- *value = rx.cap(1).toInt();
- return true;
- }
- return false;
-}
-
-static inline QColor colorFromName(const QString &name)
-{
- QRegExp rx(QLatin1String("#([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])"));
- rx.setCaseSensitivity(Qt::CaseInsensitive);
- if (rx.exactMatch(name)) {
- Q_ASSERT(rx.captureCount() == 4);
- int ints[4];
- int i;
- for (i=0; i<4; ++i) {
- bool ok;
- ints[i] = rx.cap(i + 1).toUInt(&ok, 16);
- if (!ok || ints[i] > 255)
- break;
- }
- if (i == 4)
- return QColor(ints[0], ints[1], ints[2], ints[3]);
- }
- return QColor(name);
-}
-
-bool QDirectFBScreen::connect(const QString &displaySpec)
-{
- DFBResult result = DFB_OK;
-
- { // pass command line arguments to DirectFB
- const QStringList args = QCoreApplication::arguments();
- int argc = args.size();
- char **argv = new char*[argc];
-
- for (int i = 0; i < argc; ++i)
- argv[i] = qstrdup(args.at(i).toLocal8Bit().constData());
-
- result = DirectFBInit(&argc, &argv);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreen: error initializing DirectFB",
- result);
- }
- delete[] argv;
- }
-
- const QStringList displayArgs = displaySpec.split(QLatin1Char(':'),
- QString::SkipEmptyParts);
-
- d_ptr->setFlipFlags(displayArgs);
-
- result = DirectFBCreate(&d_ptr->dfb);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreen: error creating DirectFB interface",
- result);
- return false;
- }
-
- if (displayArgs.contains(QLatin1String("videoonly"), Qt::CaseInsensitive))
- d_ptr->directFBFlags |= VideoOnly;
-
- if (displayArgs.contains(QLatin1String("systemonly"), Qt::CaseInsensitive)) {
- if (d_ptr->directFBFlags & VideoOnly) {
- qWarning("QDirectFBScreen: error. videoonly and systemonly are mutually exclusive");
- } else {
- d_ptr->directFBFlags |= SystemOnly;
- }
- }
-
- if (displayArgs.contains(QLatin1String("boundingrectflip"), Qt::CaseInsensitive)) {
- d_ptr->directFBFlags |= BoundingRectFlip;
- } else if (displayArgs.contains(QLatin1String("nopartialflip"), Qt::CaseInsensitive)) {
- d_ptr->directFBFlags |= NoPartialFlip;
- }
-
-#ifdef QT_DIRECTFB_IMAGECACHE
- int imageCacheSize = 4 * 1024 * 1024; // 4 MB
- setIntOption(displayArgs, QLatin1String("imagecachesize"), &imageCacheSize);
- QDirectFBPaintEngine::initImageCache(imageCacheSize);
-#endif
-
-#ifndef QT_NO_DIRECTFB_WM
- if (displayArgs.contains(QLatin1String("fullscreen")))
-#endif
- d_ptr->dfb->SetCooperativeLevel(d_ptr->dfb, DFSCL_FULLSCREEN);
-
- const bool forcePremultiplied = displayArgs.contains(QLatin1String("forcepremultiplied"), Qt::CaseInsensitive);
-
- DFBSurfaceDescription description;
- memset(&description, 0, sizeof(DFBSurfaceDescription));
- IDirectFBSurface *surface;
-
-#ifdef QT_NO_DIRECTFB_WM
- description.flags = DSDESC_CAPS;
- if (::setIntOption(displayArgs, QLatin1String("width"), &description.width))
- description.flags |= DSDESC_WIDTH;
- if (::setIntOption(displayArgs, QLatin1String("height"), &description.height))
- description.flags |= DSDESC_HEIGHT;
-
- description.caps = DSCAPS_PRIMARY|DSCAPS_DOUBLE;
- struct {
- const char *name;
- const DFBSurfaceCapabilities cap;
- } const capabilities[] = {
- { "static_alloc", DSCAPS_STATIC_ALLOC },
- { "triplebuffer", DSCAPS_TRIPLE },
- { "interlaced", DSCAPS_INTERLACED },
- { "separated", DSCAPS_SEPARATED },
-// { "depthbuffer", DSCAPS_DEPTH }, // only makes sense with TextureTriangles which are not supported
- { 0, DSCAPS_NONE }
- };
- for (int i=0; capabilities[i].name; ++i) {
- if (displayArgs.contains(QString::fromLatin1(capabilities[i].name), Qt::CaseInsensitive))
- description.caps |= capabilities[i].cap;
- }
-
- if (forcePremultiplied) {
- description.caps |= DSCAPS_PREMULTIPLIED;
- }
-
- // We don't track the primary surface as it's released in disconnect
- d_ptr->primarySurface = createDFBSurface(description, DontTrackSurface, &result);
- if (!d_ptr->primarySurface) {
- DirectFBError("QDirectFBScreen: error creating primary surface",
- result);
- return false;
- }
-
- surface = d_ptr->primarySurface;
-#else
- description.flags = DSDESC_WIDTH|DSDESC_HEIGHT;
- description.width = description.height = 1;
- surface = createDFBSurface(description, DontTrackSurface, &result);
- if (!surface) {
- DirectFBError("QDirectFBScreen: error creating surface", result);
- return false;
- }
-#endif
- // Work out what format we're going to use for surfaces with an alpha channel
- QImage::Format pixelFormat = QDirectFBScreen::getImageFormat(surface);
- d_ptr->alphaPixmapFormat = pixelFormat;
-
- switch (pixelFormat) {
- case QImage::Format_RGB666:
- d_ptr->alphaPixmapFormat = QImage::Format_ARGB6666_Premultiplied;
- break;
- case QImage::Format_RGB444:
- d_ptr->alphaPixmapFormat = QImage::Format_ARGB4444_Premultiplied;
- break;
- case QImage::Format_RGB32:
- pixelFormat = d_ptr->alphaPixmapFormat = QImage::Format_ARGB32_Premultiplied;
- // ### Format_RGB32 doesn't work so well with Qt. Force ARGB32 for windows/pixmaps
- break;
- case QImage::Format_Indexed8:
- qWarning("QDirectFBScreen::connect(). Qt/DirectFB does not work with the LUT8 pixelformat.");
- return false;
- case QImage::NImageFormats:
- case QImage::Format_Invalid:
- case QImage::Format_Mono:
- case QImage::Format_MonoLSB:
- case QImage::Format_RGB888:
- case QImage::Format_RGB16:
- case QImage::Format_RGB555:
- d_ptr->alphaPixmapFormat = QImage::Format_ARGB32_Premultiplied;
- break;
- case QImage::Format_ARGB32:
- if (forcePremultiplied)
- d_ptr->alphaPixmapFormat = pixelFormat = QImage::Format_ARGB32_Premultiplied;
- case QImage::Format_ARGB32_Premultiplied:
- case QImage::Format_ARGB4444_Premultiplied:
- case QImage::Format_ARGB8555_Premultiplied:
- case QImage::Format_ARGB8565_Premultiplied:
- case QImage::Format_ARGB6666_Premultiplied:
- // works already
- break;
- }
- setPixelFormat(pixelFormat);
- QScreen::d = QDirectFBScreen::depth(pixelFormat);
- data = 0;
- lstep = 0;
- size = 0;
-
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreen::connect: "
- "Unable to get screen!", result);
- return false;
- }
- const QString qws_size = QString::fromLatin1(qgetenv("QWS_SIZE"));
- if (!qws_size.isEmpty()) {
- QRegExp rx(QLatin1String("(\\d+)x(\\d+)"));
- if (!rx.exactMatch(qws_size)) {
- qWarning("QDirectFBScreen::connect: Can't parse QWS_SIZE=\"%s\"", qPrintable(qws_size));
- } else {
- int *ints[2] = { &w, &h };
- for (int i=0; i<2; ++i) {
- *ints[i] = rx.cap(i + 1).toInt();
- if (*ints[i] <= 0) {
- qWarning("QDirectFBScreen::connect: %s is not a positive integer",
- qPrintable(rx.cap(i + 1)));
- w = h = 0;
- break;
- }
- }
- }
- }
-
- setIntOption(displayArgs, QLatin1String("width"), &w);
- setIntOption(displayArgs, QLatin1String("height"), &h);
-
-#ifndef QT_NO_DIRECTFB_LAYER
- int layerId = DLID_PRIMARY;
- setIntOption(displayArgs, QLatin1String("layerid"), &layerId);
-
- result = d_ptr->dfb->GetDisplayLayer(d_ptr->dfb, static_cast<DFBDisplayLayerID>(layerId),
- &d_ptr->dfbLayer);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreen::connect: "
- "Unable to get display layer!", result);
- return false;
- }
- result = d_ptr->dfbLayer->GetScreen(d_ptr->dfbLayer, &d_ptr->dfbScreen);
-#else
- result = d_ptr->dfb->GetScreen(d_ptr->dfb, 0, &d_ptr->dfbScreen);
-#endif
-
- if (w <= 0 || h <= 0) {
-#ifdef QT_NO_DIRECTFB_WM
- result = d_ptr->primarySurface->GetSize(d_ptr->primarySurface, &w, &h);
-#elif (Q_DIRECTFB_VERSION >= 0x010000)
- IDirectFBSurface *layerSurface;
- if (d_ptr->dfbLayer->GetSurface(d_ptr->dfbLayer, &layerSurface) == DFB_OK) {
- result = layerSurface->GetSize(layerSurface, &w, &h);
- layerSurface->Release(layerSurface);
- }
- if (w <= 0 || h <= 0) {
- result = d_ptr->dfbScreen->GetSize(d_ptr->dfbScreen, &w, &h);
- }
-#else
- qWarning("QDirectFBScreen::connect: DirectFB versions prior to 1.0 do not offer a way\n"
- "query the size of the primary surface in windowed mode. You have to specify\n"
- "the size of the display using QWS_SIZE=[0-9]x[0-9] or\n"
- "QWS_DISPLAY=directfb:width=[0-9]:height=[0-9]");
- return false;
-#endif
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreen::connect: "
- "Unable to get screen size!", result);
- return false;
- }
- }
-
-
- dw = w;
- dh = h;
-
- Q_ASSERT(dw != 0 && dh != 0);
-
- physWidth = physHeight = -1;
- setIntOption(displayArgs, QLatin1String("mmWidth"), &physWidth);
- setIntOption(displayArgs, QLatin1String("mmHeight"), &physHeight);
- const int dpi = 72;
- if (physWidth < 0)
- physWidth = qRound(dw * 25.4 / dpi);
- if (physHeight < 0)
- physHeight = qRound(dh * 25.4 / dpi);
-
- setGraphicsSystem(d_ptr);
-
-#if (Q_DIRECTFB_VERSION >= 0x000923)
- if (displayArgs.contains(QLatin1String("debug"), Qt::CaseInsensitive))
- printDirectFBInfo(d_ptr->dfb, surface);
-#endif
-#ifdef QT_DIRECTFB_WM
- surface->Release(surface);
- QColor backgroundColor;
-#else
- QColor &backgroundColor = d_ptr->backgroundColor;
-#endif
-
- QRegExp backgroundColorRegExp(QLatin1String("bgcolor=(.+)"));
- backgroundColorRegExp.setCaseSensitivity(Qt::CaseInsensitive);
- if (displayArgs.indexOf(backgroundColorRegExp) != -1) {
- backgroundColor = colorFromName(backgroundColorRegExp.cap(1));
- }
-#ifdef QT_NO_DIRECTFB_WM
- if (!backgroundColor.isValid())
- backgroundColor = Qt::green;
- d_ptr->primarySurface->Clear(d_ptr->primarySurface, backgroundColor.red(),
- backgroundColor.green(), backgroundColor.blue(),
- backgroundColor.alpha());
- d_ptr->primarySurface->Flip(d_ptr->primarySurface, 0, d_ptr->flipFlags);
-#else
- if (backgroundColor.isValid()) {
- DFBResult result = d_ptr->dfbLayer->SetCooperativeLevel(d_ptr->dfbLayer, DLSCL_ADMINISTRATIVE);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreen::connect "
- "Unable to set cooperative level", result);
- }
- result = d_ptr->dfbLayer->SetBackgroundColor(d_ptr->dfbLayer, backgroundColor.red(), backgroundColor.green(),
- backgroundColor.blue(), backgroundColor.alpha());
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::connect: "
- "Unable to set background color", result);
- }
-
- result = d_ptr->dfbLayer->SetBackgroundMode(d_ptr->dfbLayer, DLBM_COLOR);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreenCursor::connect: "
- "Unable to set background mode", result);
- }
-
- result = d_ptr->dfbLayer->SetCooperativeLevel(d_ptr->dfbLayer, DLSCL_SHARED);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreen::connect "
- "Unable to set cooperative level", result);
- }
-
- }
-#endif
-
- return true;
-}
-
-void QDirectFBScreen::disconnect()
-{
-#if defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE
- if (d_ptr->imageProvider)
- d_ptr->imageProvider->Release(d_ptr->imageProvider);
-#endif
-#ifdef QT_NO_DIRECTFB_WM
- d_ptr->primarySurface->Release(d_ptr->primarySurface);
- d_ptr->primarySurface = 0;
-#endif
-
- foreach (IDirectFBSurface *surf, d_ptr->allocatedSurfaces)
- surf->Release(surf);
- d_ptr->allocatedSurfaces.clear();
-
-#ifndef QT_NO_DIRECTFB_LAYER
- d_ptr->dfbLayer->Release(d_ptr->dfbLayer);
- d_ptr->dfbLayer = 0;
-#endif
-
- d_ptr->dfbScreen->Release(d_ptr->dfbScreen);
- d_ptr->dfbScreen = 0;
-
- d_ptr->dfb->Release(d_ptr->dfb);
- d_ptr->dfb = 0;
-}
-
-bool QDirectFBScreen::initDevice()
-{
-#ifndef QT_NO_DIRECTFB_MOUSE
- if (qgetenv("QWS_MOUSE_PROTO").isEmpty()) {
- QWSServer::instance()->setDefaultMouse("None");
- d_ptr->mouse = new QDirectFBMouseHandler;
- }
-#endif
-#ifndef QT_NO_DIRECTFB_KEYBOARD
- if (qgetenv("QWS_KEYBOARD").isEmpty()) {
- QWSServer::instance()->setDefaultKeyboard("None");
- d_ptr->keyboard = new QDirectFBKeyboardHandler(QString());
- }
-#endif
-
-#ifdef QT_DIRECTFB_CURSOR
- qt_screencursor = new QDirectFBScreenCursor;
-#elif !defined QT_NO_QWS_CURSOR
- QScreenCursor::initSoftwareCursor();
-#endif
- return true;
-}
-
-void QDirectFBScreen::shutdownDevice()
-{
-#ifndef QT_NO_DIRECTFB_MOUSE
- delete d_ptr->mouse;
- d_ptr->mouse = 0;
-#endif
-#ifndef QT_NO_DIRECTFB_KEYBOARD
- delete d_ptr->keyboard;
- d_ptr->keyboard = 0;
-#endif
-
-#ifndef QT_NO_QWS_CURSOR
- delete qt_screencursor;
- qt_screencursor = 0;
-#endif
-}
-
-void QDirectFBScreen::setMode(int width, int height, int depth)
-{
- d_ptr->dfb->SetVideoMode(d_ptr->dfb, width, height, depth);
-}
-
-void QDirectFBScreen::blank(bool on)
-{
- d_ptr->dfbScreen->SetPowerMode(d_ptr->dfbScreen,
- (on ? DSPM_ON : DSPM_SUSPEND));
-}
-
-QWSWindowSurface *QDirectFBScreen::createSurface(QWidget *widget) const
-{
-#ifdef QT_NO_DIRECTFB_WM
- if (QApplication::type() == QApplication::GuiServer) {
- return new QDirectFBWindowSurface(d_ptr->flipFlags, const_cast<QDirectFBScreen*>(this), widget);
- } else {
- return QScreen::createSurface(widget);
- }
-#else
- return new QDirectFBWindowSurface(d_ptr->flipFlags, const_cast<QDirectFBScreen*>(this), widget);
-#endif
-}
-
-QWSWindowSurface *QDirectFBScreen::createSurface(const QString &key) const
-{
- if (key == QLatin1String("directfb")) {
- return new QDirectFBWindowSurface(d_ptr->flipFlags, const_cast<QDirectFBScreen*>(this));
- }
- return QScreen::createSurface(key);
-}
-
-#if defined QT_NO_DIRECTFB_WM
-struct PaintCommand {
- PaintCommand() : dfbSurface(0), windowOpacity(255), blittingFlags(DSBLIT_NOFX) {}
- IDirectFBSurface *dfbSurface;
- QImage image;
- QPoint windowPosition;
- QRegion source;
- quint8 windowOpacity;
- DFBSurfaceBlittingFlags blittingFlags;
-};
-
-static inline void initParameters(DFBRectangle &source, const QRect &sourceGlobal, const QPoint &pos)
-{
- source.x = sourceGlobal.x() - pos.x();
- source.y = sourceGlobal.y() - pos.y();
- source.w = sourceGlobal.width();
- source.h = sourceGlobal.height();
-}
-#endif
-
-void QDirectFBScreen::exposeRegion(QRegion r, int)
-{
- Q_UNUSED(r);
-#if defined QT_NO_DIRECTFB_WM
-
- r &= region();
- if (r.isEmpty()) {
- return;
- }
- r = r.boundingRect();
-
- IDirectFBSurface *primary = d_ptr->primarySurface;
- const QList<QWSWindow*> windows = QWSServer::instance()->clientWindows();
- QVarLengthArray<PaintCommand, 4> commands(windows.size());
- QRegion region = r;
- int idx = 0;
- for (int i=0; i<windows.size(); ++i) {
- QWSWindowSurface *surface = windows.at(i)->windowSurface();
- if (!surface)
- continue;
-
- const QRect windowGeometry = surface->geometry();
- const QRegion intersection = region & windowGeometry;
- if (intersection.isEmpty()) {
- continue;
- }
-
- PaintCommand &cmd = commands[idx];
-
- if (surface->key() == QLatin1String("directfb")) {
- const QDirectFBWindowSurface *ws = static_cast<QDirectFBWindowSurface*>(surface);
- cmd.dfbSurface = ws->directFBSurface();
-
- if (!cmd.dfbSurface) {
- continue;
- }
- } else {
- cmd.image = surface->image();
- if (cmd.image.isNull()) {
- continue;
- }
- }
- ++idx;
-
- cmd.windowPosition = windowGeometry.topLeft();
- cmd.source = intersection;
- if (windows.at(i)->isOpaque()) {
- region -= intersection;
- if (region.isEmpty())
- break;
- } else {
- cmd.windowOpacity = windows.at(i)->opacity();
- cmd.blittingFlags = cmd.windowOpacity == 255
- ? DSBLIT_BLEND_ALPHACHANNEL
- : (DSBLIT_BLEND_ALPHACHANNEL|DSBLIT_BLEND_COLORALPHA);
- }
- }
-
- solidFill(d_ptr->backgroundColor, region);
-
- while (idx > 0) {
- const PaintCommand &cmd = commands[--idx];
- Q_ASSERT(cmd.dfbSurface || !cmd.image.isNull());
- IDirectFBSurface *surface;
- if (cmd.dfbSurface) {
- surface = cmd.dfbSurface;
- } else {
- Q_ASSERT(!cmd.image.isNull());
- DFBResult result;
- surface = createDFBSurface(cmd.image, cmd.image.format(), DontTrackSurface, &result);
- Q_ASSERT((result != DFB_OK) == !surface);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreen::exposeRegion: Can't create surface from image", result);
- continue;
- }
- }
-
- primary->SetBlittingFlags(primary, cmd.blittingFlags);
- if (cmd.blittingFlags & DSBLIT_BLEND_COLORALPHA) {
- primary->SetColor(primary, 0xff, 0xff, 0xff, cmd.windowOpacity);
- }
- const QRegion &region = cmd.source;
- const int rectCount = region.rectCount();
- DFBRectangle source;
- if (rectCount == 1) {
- ::initParameters(source, region.boundingRect(), cmd.windowPosition);
- primary->Blit(primary, surface, &source, cmd.windowPosition.x() + source.x, cmd.windowPosition.y() + source.y);
- } else {
- const QVector<QRect> rects = region.rects();
- for (int i=0; i<rectCount; ++i) {
- ::initParameters(source, rects.at(i), cmd.windowPosition);
- primary->Blit(primary, surface, &source, cmd.windowPosition.x() + source.x, cmd.windowPosition.y() + source.y);
- }
- }
- if (surface != cmd.dfbSurface) {
- surface->Release(surface);
- }
- }
-
- primary->SetColor(primary, 0xff, 0xff, 0xff, 0xff);
-
-#if defined QT_NO_DIRECTFB_CURSOR and !defined QT_NO_QWS_CURSOR
- if (QScreenCursor *cursor = QScreenCursor::instance()) {
- const QRect cursorRectangle = cursor->boundingRect();
- if (cursor->isVisible() && !cursor->isAccelerated() && r.intersects(cursorRectangle)) {
- const QImage image = cursor->image();
- if (image.cacheKey() != d_ptr->cursorImageKey) {
- if (d_ptr->cursorSurface) {
- releaseDFBSurface(d_ptr->cursorSurface);
- }
- d_ptr->cursorSurface = createDFBSurface(image, image.format(), QDirectFBScreen::TrackSurface);
- d_ptr->cursorImageKey = image.cacheKey();
- }
-
- Q_ASSERT(d_ptr->cursorSurface);
- primary->SetBlittingFlags(primary, DSBLIT_BLEND_ALPHACHANNEL);
- primary->Blit(primary, d_ptr->cursorSurface, 0, cursorRectangle.x(), cursorRectangle.y());
- }
- }
-#endif
- flipSurface(primary, d_ptr->flipFlags, r, QPoint());
- primary->SetBlittingFlags(primary, DSBLIT_NOFX);
-#endif
-}
-
-void QDirectFBScreen::solidFill(const QColor &color, const QRegion &region)
-{
-#ifdef QT_DIRECTFB_WM
- Q_UNUSED(color);
- Q_UNUSED(region);
-#else
- QDirectFBScreen::solidFill(d_ptr->primarySurface, color, region);
-#endif
-}
-
-static inline void clearRect(IDirectFBSurface *surface, const QColor &color, const QRect &rect)
-{
- Q_ASSERT(surface);
- const DFBRegion region = { rect.left(), rect.top(), rect.right(), rect.bottom() };
- // could just reinterpret_cast this to a DFBRegion
- surface->SetClip(surface, &region);
- surface->Clear(surface, color.red(), color.green(), color.blue(), color.alpha());
-}
-
-void QDirectFBScreen::solidFill(IDirectFBSurface *surface, const QColor &color, const QRegion &region)
-{
- if (region.isEmpty())
- return;
-
- const int n = region.rectCount();
- if (n == 1) {
- clearRect(surface, color, region.boundingRect());
- } else {
- const QVector<QRect> rects = region.rects();
- for (int i=0; i<n; ++i) {
- clearRect(surface, color, rects.at(i));
- }
- }
- surface->SetClip(surface, 0);
-}
-
-QImage::Format QDirectFBScreen::alphaPixmapFormat() const
-{
- return d_ptr->alphaPixmapFormat;
-}
-
-bool QDirectFBScreen::initSurfaceDescriptionPixelFormat(DFBSurfaceDescription *description,
- QImage::Format format)
-{
- const DFBSurfacePixelFormat pixelformat = QDirectFBScreen::getSurfacePixelFormat(format);
- if (pixelformat == DSPF_UNKNOWN)
- return false;
- description->flags |= DSDESC_PIXELFORMAT;
- description->pixelformat = pixelformat;
- if (QDirectFBScreen::isPremultiplied(format)) {
- if (!(description->flags & DSDESC_CAPS)) {
- description->caps = DSCAPS_PREMULTIPLIED;
- description->flags |= DSDESC_CAPS;
- } else {
- description->caps |= DSCAPS_PREMULTIPLIED;
- }
- }
- return true;
-}
-
-uchar *QDirectFBScreen::lockSurface(IDirectFBSurface *surface, DFBSurfaceLockFlags flags, int *bpl)
-{
- void *mem = 0;
- const DFBResult result = surface->Lock(surface, flags, &mem, bpl);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreen::lockSurface()", result);
- }
-
- return reinterpret_cast<uchar*>(mem);
-}
-
-static inline bool isFullUpdate(IDirectFBSurface *surface, const QRegion &region, const QPoint &offset)
-{
- if (offset == QPoint(0, 0) && region.rectCount() == 1) {
- QSize size;
- surface->GetSize(surface, &size.rwidth(), &size.rheight());
- if (region.boundingRect().size() == size)
- return true;
- }
- return false;
-}
-
-void QDirectFBScreen::flipSurface(IDirectFBSurface *surface, DFBSurfaceFlipFlags flipFlags,
- const QRegion &region, const QPoint &offset)
-{
- if (d_ptr->directFBFlags & NoPartialFlip
- || (!(flipFlags & DSFLIP_BLIT) && QT_PREPEND_NAMESPACE(isFullUpdate(surface, region, offset)))) {
- surface->Flip(surface, 0, flipFlags);
- } else {
- if (!(d_ptr->directFBFlags & BoundingRectFlip) && region.rectCount() > 1) {
- const QVector<QRect> rects = region.rects();
- const DFBSurfaceFlipFlags nonWaitFlags = flipFlags & ~DSFLIP_WAIT;
- for (int i=0; i<rects.size(); ++i) {
- const QRect &r = rects.at(i);
- const DFBRegion dfbReg = { r.x() + offset.x(), r.y() + offset.y(),
- r.right() + offset.x(),
- r.bottom() + offset.y() };
- surface->Flip(surface, &dfbReg, i + 1 < rects.size() ? nonWaitFlags : flipFlags);
- }
- } else {
- const QRect r = region.boundingRect();
- const DFBRegion dfbReg = { r.x() + offset.x(), r.y() + offset.y(),
- r.right() + offset.x(),
- r.bottom() + offset.y() };
- surface->Flip(surface, &dfbReg, flipFlags);
- }
- }
-}
-
-#if defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE
-void QDirectFBScreen::setDirectFBImageProvider(IDirectFBImageProvider *provider)
-{
- Q_ASSERT(provider);
- if (d_ptr->imageProvider)
- d_ptr->imageProvider->Release(d_ptr->imageProvider);
- d_ptr->imageProvider = provider;
-}
-#endif
-
-void QDirectFBScreen::waitIdle()
-{
- d_ptr->dfb->WaitIdle(d_ptr->dfb);
-}
-
-#ifdef QT_DIRECTFB_WM
-IDirectFBWindow *QDirectFBScreen::windowForWidget(const QWidget *widget) const
-{
- if (widget) {
- const QWSWindowSurface *surface = static_cast<const QWSWindowSurface*>(widget->windowSurface());
- if (surface && surface->key() == QLatin1String("directfb")) {
- return static_cast<const QDirectFBWindowSurface*>(surface)->directFBWindow();
- }
- }
- return 0;
-}
-#endif
-
-IDirectFBSurface * QDirectFBScreen::surfaceForWidget(const QWidget *widget, QRect *rect) const
-{
- Q_ASSERT(widget);
- if (!widget->isVisible() || widget->size().isNull())
- return 0;
-
- const QWSWindowSurface *surface = static_cast<const QWSWindowSurface*>(widget->windowSurface());
- if (surface && surface->key() == QLatin1String("directfb")) {
- return static_cast<const QDirectFBWindowSurface*>(surface)->surfaceForWidget(widget, rect);
- }
- return 0;
-}
-
-#ifdef QT_DIRECTFB_SUBSURFACE
-IDirectFBSurface *QDirectFBScreen::subSurfaceForWidget(const QWidget *widget, const QRect &area) const
-{
- Q_ASSERT(widget);
- QRect rect;
- IDirectFBSurface *surface = surfaceForWidget(widget, &rect);
- IDirectFBSurface *subSurface = 0;
- if (surface) {
- if (!area.isNull())
- rect &= area.translated(widget->mapTo(widget->window(), QPoint(0, 0)));
- if (!rect.isNull()) {
- const DFBRectangle subRect = { rect.x(), rect.y(), rect.width(), rect.height() };
- const DFBResult result = surface->GetSubSurface(surface, &subRect, &subSurface);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBScreen::subSurface(): Can't get sub surface", result);
- }
- }
- }
- return subSurface;
-}
-#endif
-
-Q_GUI_EXPORT IDirectFBSurface *qt_directfb_surface_for_widget(const QWidget *widget, QRect *rect)
-{
- return QDirectFBScreen::instance() ? QDirectFBScreen::instance()->surfaceForWidget(widget, rect) : 0;
-}
-#ifdef QT_DIRECTFB_SUBSURFACE
-Q_GUI_EXPORT IDirectFBSurface *qt_directfb_subsurface_for_widget(const QWidget *widget, const QRect &area)
-{
- return QDirectFBScreen::instance() ? QDirectFBScreen::instance()->subSurfaceForWidget(widget, area) : 0;
-}
-#endif
-#ifdef QT_DIRECTFB_WM
-Q_GUI_EXPORT IDirectFBWindow *qt_directfb_window_for_widget(const QWidget *widget)
-{
- return QDirectFBScreen::instance() ? QDirectFBScreen::instance()->windowForWidget(widget) : 0;
-}
-
-#endif
-
-QT_END_NAMESPACE
-
-#include "qdirectfbscreen.moc"
-#endif // QT_NO_QWS_DIRECTFB
-
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
deleted file mode 100644
index 0e9098df3b..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h
+++ /dev/null
@@ -1,303 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDIRECTFBSCREEN_H
-#define QDIRECTFBSCREEN_H
-
-#include <qglobal.h>
-#ifndef QT_NO_QWS_DIRECTFB
-#include <QtGui/qscreen_qws.h>
-#include <directfb.h>
-#include <directfb_version.h>
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-#if !defined QT_DIRECTFB_SUBSURFACE && !defined QT_NO_DIRECTFB_SUBSURFACE
-#define QT_NO_DIRECTFB_SUBSURFACE
-#endif
-#if !defined QT_NO_DIRECTFB_LAYER && !defined QT_DIRECTFB_LAYER
-#define QT_DIRECTFB_LAYER
-#endif
-#if !defined QT_NO_DIRECTFB_WM && !defined QT_DIRECTFB_WM
-#define QT_DIRECTFB_WM
-#endif
-#if !defined QT_DIRECTFB_IMAGECACHE && !defined QT_NO_DIRECTFB_IMAGECACHE
-#define QT_NO_DIRECTFB_IMAGECACHE
-#endif
-#if !defined QT_NO_DIRECTFB_IMAGEPROVIDER && !defined QT_DIRECTFB_IMAGEPROVIDER
-#define QT_DIRECTFB_IMAGEPROVIDER
-#endif
-#if !defined QT_NO_DIRECTFB_STRETCHBLIT && !defined QT_DIRECTFB_STRETCHBLIT
-#define QT_DIRECTFB_STRETCHBLIT
-#endif
-#if !defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE && !defined QT_NO_DIRECTFB_IMAGEPROVIDER_KEEPALIVE
-#define QT_NO_DIRECTFB_IMAGEPROVIDER_KEEPALIVE
-#endif
-#if !defined QT_DIRECTFB_WINDOW_AS_CURSOR && !defined QT_NO_DIRECTFB_WINDOW_AS_CURSOR
-#define QT_NO_DIRECTFB_WINDOW_AS_CURSOR
-#endif
-#if !defined QT_DIRECTFB_PALETTE && !defined QT_NO_DIRECTFB_PALETTE
-#define QT_NO_DIRECTFB_PALETTE
-#endif
-#if !defined QT_NO_DIRECTFB_PREALLOCATED && !defined QT_DIRECTFB_PREALLOCATED
-#define QT_DIRECTFB_PREALLOCATED
-#endif
-#if !defined QT_NO_DIRECTFB_MOUSE && !defined QT_DIRECTFB_MOUSE
-#define QT_DIRECTFB_MOUSE
-#endif
-#if !defined QT_NO_DIRECTFB_KEYBOARD && !defined QT_DIRECTFB_KEYBOARD
-#define QT_DIRECTFB_KEYBOARD
-#endif
-#if !defined QT_NO_DIRECTFB_OPAQUE_DETECTION && !defined QT_DIRECTFB_OPAQUE_DETECTION
-#define QT_DIRECTFB_OPAQUE_DETECTION
-#endif
-#ifndef QT_NO_QWS_CURSOR
-#if defined QT_DIRECTFB_WM && defined QT_DIRECTFB_WINDOW_AS_CURSOR
-#define QT_DIRECTFB_CURSOR
-#elif defined QT_DIRECTFB_LAYER
-#define QT_DIRECTFB_CURSOR
-#endif
-#endif
-#ifndef QT_DIRECTFB_CURSOR
-#define QT_NO_DIRECTFB_CURSOR
-#endif
-#if defined QT_NO_DIRECTFB_LAYER && defined QT_DIRECTFB_WM
-#error QT_NO_DIRECTFB_LAYER requires QT_NO_DIRECTFB_WM
-#endif
-#if defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE && defined QT_NO_DIRECTFB_IMAGEPROVIDER
-#error QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE requires QT_DIRECTFB_IMAGEPROVIDER to be defined
-#endif
-#if defined QT_DIRECTFB_WINDOW_AS_CURSOR && defined QT_NO_DIRECTFB_WM
-#error QT_DIRECTFB_WINDOW_AS_CURSOR requires QT_DIRECTFB_WM to be defined
-#endif
-
-#define Q_DIRECTFB_VERSION ((DIRECTFB_MAJOR_VERSION << 16) | (DIRECTFB_MINOR_VERSION << 8) | DIRECTFB_MICRO_VERSION)
-
-#define DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(F) \
- static inline F operator~(F f) { return F(~int(f)); } \
- static inline F operator&(F left, F right) { return F(int(left) & int(right)); } \
- static inline F operator|(F left, F right) { return F(int(left) | int(right)); } \
- static inline F &operator|=(F &left, F right) { left = (left | right); return left; } \
- static inline F &operator&=(F &left, F right) { left = (left & right); return left; }
-
-DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBInputDeviceCapabilities);
-DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBWindowDescriptionFlags);
-DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBWindowCapabilities);
-DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBWindowOptions);
-DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceDescriptionFlags);
-DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceCapabilities);
-DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceLockFlags);
-DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceBlittingFlags);
-DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceDrawingFlags);
-DIRECTFB_DECLARE_OPERATORS_FOR_FLAGS(DFBSurfaceFlipFlags);
-
-class QDirectFBScreenPrivate;
-class Q_GUI_EXPORT QDirectFBScreen : public QScreen
-{
-public:
- QDirectFBScreen(int display_id);
- ~QDirectFBScreen();
-
- enum DirectFBFlag {
- NoFlags = 0x00,
- VideoOnly = 0x01,
- SystemOnly = 0x02,
- BoundingRectFlip = 0x04,
- NoPartialFlip = 0x08
- };
-
- Q_DECLARE_FLAGS(DirectFBFlags, DirectFBFlag);
-
- DirectFBFlags directFBFlags() const;
-
- bool connect(const QString &displaySpec);
- void disconnect();
- bool initDevice();
- void shutdownDevice();
-
- void exposeRegion(QRegion r, int changing);
- void solidFill(const QColor &color, const QRegion &region);
- static void solidFill(IDirectFBSurface *surface, const QColor &color, const QRegion &region);
-
- void setMode(int width, int height, int depth);
- void blank(bool on);
-
- QWSWindowSurface *createSurface(QWidget *widget) const;
- QWSWindowSurface *createSurface(const QString &key) const;
-
- static QDirectFBScreen *instance();
- void waitIdle();
- IDirectFBSurface *surfaceForWidget(const QWidget *widget, QRect *rect) const;
-#ifdef QT_DIRECTFB_SUBSURFACE
- IDirectFBSurface *subSurfaceForWidget(const QWidget *widget, const QRect &area = QRect()) const;
-#endif
- IDirectFB *dfb();
-#ifdef QT_DIRECTFB_WM
- IDirectFBWindow *windowForWidget(const QWidget *widget) const;
-#else
- IDirectFBSurface *primarySurface();
-#endif
-#ifndef QT_NO_DIRECTFB_LAYER
- IDirectFBDisplayLayer *dfbDisplayLayer();
-#endif
-
- // Track surface creation/release so we can release all on exit
- enum SurfaceCreationOption {
- DontTrackSurface = 0x1,
- TrackSurface = 0x2,
- NoPreallocated = 0x4
- };
- Q_DECLARE_FLAGS(SurfaceCreationOptions, SurfaceCreationOption);
- IDirectFBSurface *createDFBSurface(const QImage &image,
- QImage::Format format,
- SurfaceCreationOptions options,
- DFBResult *result = 0);
- IDirectFBSurface *createDFBSurface(const QSize &size,
- QImage::Format format,
- SurfaceCreationOptions options,
- DFBResult *result = 0);
- IDirectFBSurface *copyDFBSurface(IDirectFBSurface *src,
- QImage::Format format,
- SurfaceCreationOptions options,
- DFBResult *result = 0);
- IDirectFBSurface *createDFBSurface(DFBSurfaceDescription desc,
- SurfaceCreationOptions options,
- DFBResult *result);
-#ifdef QT_DIRECTFB_SUBSURFACE
- IDirectFBSurface *getSubSurface(IDirectFBSurface *surface,
- const QRect &rect,
- SurfaceCreationOptions options,
- DFBResult *result);
-#endif
-
- void flipSurface(IDirectFBSurface *surface, DFBSurfaceFlipFlags flipFlags,
- const QRegion &region, const QPoint &offset);
- void releaseDFBSurface(IDirectFBSurface *surface);
-
- using QScreen::depth;
- static int depth(DFBSurfacePixelFormat format);
- static int depth(QImage::Format format);
-
- static DFBSurfacePixelFormat getSurfacePixelFormat(QImage::Format format);
- static DFBSurfaceDescription getSurfaceDescription(const uint *buffer,
- int length);
- static QImage::Format getImageFormat(IDirectFBSurface *surface);
- static bool initSurfaceDescriptionPixelFormat(DFBSurfaceDescription *description, QImage::Format format);
- static inline bool isPremultiplied(QImage::Format format);
- static inline bool hasAlphaChannel(DFBSurfacePixelFormat format);
- static inline bool hasAlphaChannel(IDirectFBSurface *surface);
- QImage::Format alphaPixmapFormat() const;
-
-#ifndef QT_NO_DIRECTFB_PALETTE
- static void setSurfaceColorTable(IDirectFBSurface *surface,
- const QImage &image);
-#endif
-
- static uchar *lockSurface(IDirectFBSurface *surface, DFBSurfaceLockFlags flags, int *bpl = 0);
-#if defined QT_DIRECTFB_IMAGEPROVIDER && defined QT_DIRECTFB_IMAGEPROVIDER_KEEPALIVE
- void setDirectFBImageProvider(IDirectFBImageProvider *provider);
-#endif
-private:
- QDirectFBScreenPrivate *d_ptr;
-};
-
-Q_DECLARE_OPERATORS_FOR_FLAGS(QDirectFBScreen::SurfaceCreationOptions);
-Q_DECLARE_OPERATORS_FOR_FLAGS(QDirectFBScreen::DirectFBFlags);
-
-inline bool QDirectFBScreen::isPremultiplied(QImage::Format format)
-{
- switch (format) {
- case QImage::Format_ARGB32_Premultiplied:
- case QImage::Format_ARGB8565_Premultiplied:
- case QImage::Format_ARGB6666_Premultiplied:
- case QImage::Format_ARGB8555_Premultiplied:
- case QImage::Format_ARGB4444_Premultiplied:
- return true;
- default:
- break;
- }
- return false;
-}
-
-inline bool QDirectFBScreen::hasAlphaChannel(DFBSurfacePixelFormat format)
-{
- switch (format) {
- case DSPF_ARGB1555:
- case DSPF_ARGB:
- case DSPF_LUT8:
- case DSPF_AiRGB:
- case DSPF_A1:
- case DSPF_ARGB2554:
- case DSPF_ARGB4444:
-#if (Q_DIRECTFB_VERSION >= 0x000923)
- case DSPF_AYUV:
-#endif
-#if (Q_DIRECTFB_VERSION >= 0x010000)
- case DSPF_A4:
- case DSPF_ARGB1666:
- case DSPF_ARGB6666:
- case DSPF_LUT2:
-#endif
- return true;
- default:
- return false;
- }
-}
-
-inline bool QDirectFBScreen::hasAlphaChannel(IDirectFBSurface *surface)
-{
- Q_ASSERT(surface);
- DFBSurfacePixelFormat format;
- surface->GetPixelFormat(surface, &format);
- return QDirectFBScreen::hasAlphaChannel(format);
-}
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_QWS_DIRECTFB
-#endif // QDIRECTFBSCREEN_H
-
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreenplugin.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbscreenplugin.cpp
deleted file mode 100644
index 742c857e9e..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbscreenplugin.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdirectfbscreen.h"
-
-#include <QtGui/qscreendriverplugin_qws.h>
-#include <QtCore/qstringlist.h>
-#ifndef QT_NO_QWS_DIRECTFB
-
-class DirectFBScreenDriverPlugin : public QScreenDriverPlugin
-{
-public:
- DirectFBScreenDriverPlugin();
-
- QStringList keys() const;
- QScreen *create(const QString&, int displayId);
-};
-
-DirectFBScreenDriverPlugin::DirectFBScreenDriverPlugin()
- : QScreenDriverPlugin()
-{
-}
-
-QStringList DirectFBScreenDriverPlugin::keys() const
-{
- return (QStringList() << "directfb");
-}
-
-QScreen* DirectFBScreenDriverPlugin::create(const QString& driver,
- int displayId)
-{
- if (driver.toLower() != "directfb")
- return 0;
-
- return new QDirectFBScreen(displayId);
-}
-
-Q_EXPORT_PLUGIN2(qdirectfbscreen, DirectFBScreenDriverPlugin)
-
-#endif
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
deleted file mode 100644
index 9a94c30d8c..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.cpp
+++ /dev/null
@@ -1,506 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qdirectfbwindowsurface.h"
-#include "qdirectfbscreen.h"
-#include "qdirectfbpaintengine.h"
-
-#include <private/qwidget_p.h>
-#include <qwidget.h>
-#include <qwindowsystem_qws.h>
-#include <qpaintdevice.h>
-#include <qvarlengtharray.h>
-
-#ifndef QT_NO_QWS_DIRECTFB
-
-QT_BEGIN_NAMESPACE
-
-QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *scr)
- : QDirectFBPaintDevice(scr)
-#ifndef QT_NO_DIRECTFB_WM
- , dfbWindow(0)
-#endif
- , flipFlags(flip)
- , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip)
- , flushPending(false)
-{
-#ifdef QT_NO_DIRECTFB_WM
- mode = Offscreen;
-#endif
- setSurfaceFlags(Opaque | Buffered);
-#ifdef QT_DIRECTFB_TIMING
- frames = 0;
- timer.start();
-#endif
-}
-
-QDirectFBWindowSurface::QDirectFBWindowSurface(DFBSurfaceFlipFlags flip, QDirectFBScreen *scr, QWidget *widget)
- : QWSWindowSurface(widget), QDirectFBPaintDevice(scr)
-#ifndef QT_NO_DIRECTFB_WM
- , dfbWindow(0)
-#endif
- , flipFlags(flip)
- , boundingRectFlip(scr->directFBFlags() & QDirectFBScreen::BoundingRectFlip)
- , flushPending(false)
-{
- SurfaceFlags flags = 0;
- if (!widget || widget->window()->windowOpacity() == 0xff)
- flags |= Opaque;
-#ifdef QT_NO_DIRECTFB_WM
- if (widget && widget->testAttribute(Qt::WA_PaintOnScreen)) {
- flags = RegionReserved;
- mode = Primary;
- } else {
- mode = Offscreen;
- flags = Buffered;
- }
-#endif
- setSurfaceFlags(flags);
-#ifdef QT_DIRECTFB_TIMING
- frames = 0;
- timer.start();
-#endif
-}
-
-QDirectFBWindowSurface::~QDirectFBWindowSurface()
-{
- releaseSurface();
- // these are not tracked by QDirectFBScreen so we don't want QDirectFBPaintDevice to release it
-}
-
-bool QDirectFBWindowSurface::isValid() const
-{
- return true;
-}
-
-#ifdef QT_DIRECTFB_WM
-void QDirectFBWindowSurface::raise()
-{
- if (IDirectFBWindow *window = directFBWindow()) {
- window->RaiseToTop(window);
- }
-}
-
-IDirectFBWindow *QDirectFBWindowSurface::directFBWindow() const
-{
- return dfbWindow;
-}
-
-void QDirectFBWindowSurface::createWindow(const QRect &rect)
-{
- IDirectFBDisplayLayer *layer = screen->dfbDisplayLayer();
- if (!layer)
- qFatal("QDirectFBWindowSurface: Unable to get primary display layer!");
-
- updateIsOpaque();
-
- DFBWindowDescription description;
- memset(&description, 0, sizeof(DFBWindowDescription));
-
- description.flags = DWDESC_CAPS|DWDESC_HEIGHT|DWDESC_WIDTH|DWDESC_POSX|DWDESC_POSY|DWDESC_SURFACE_CAPS|DWDESC_PIXELFORMAT;
- description.caps = DWCAPS_NODECORATION;
- description.surface_caps = DSCAPS_NONE;
- imageFormat = screen->pixelFormat();
-
- if (!(surfaceFlags() & Opaque)) {
- imageFormat = screen->alphaPixmapFormat();
- description.caps |= DWCAPS_ALPHACHANNEL;
-#if (Q_DIRECTFB_VERSION >= 0x010200)
- description.flags |= DWDESC_OPTIONS;
- description.options |= DWOP_ALPHACHANNEL;
-#endif
- }
- description.pixelformat = QDirectFBScreen::getSurfacePixelFormat(imageFormat);
- description.posx = rect.x();
- description.posy = rect.y();
- description.width = rect.width();
- description.height = rect.height();
-
- if (QDirectFBScreen::isPremultiplied(imageFormat))
- description.surface_caps = DSCAPS_PREMULTIPLIED;
-
- if (screen->directFBFlags() & QDirectFBScreen::VideoOnly)
- description.surface_caps |= DSCAPS_VIDEOONLY;
-
- DFBResult result = layer->CreateWindow(layer, &description, &dfbWindow);
-
- if (result != DFB_OK)
- DirectFBErrorFatal("QDirectFBWindowSurface::createWindow", result);
-
- if (window()) {
- if (window()->windowFlags() & Qt::WindowStaysOnTopHint) {
- dfbWindow->SetStackingClass(dfbWindow, DWSC_UPPER);
- }
- DFBWindowID winid;
- result = dfbWindow->GetID(dfbWindow, &winid);
- if (result != DFB_OK) {
- DirectFBError("QDirectFBWindowSurface::createWindow. Can't get ID", result);
- } else {
- window()->setProperty("_q_DirectFBWindowID", winid);
- }
- }
-
- Q_ASSERT(!dfbSurface);
- dfbWindow->GetSurface(dfbWindow, &dfbSurface);
-}
-
-static DFBResult setWindowGeometry(IDirectFBWindow *dfbWindow, const QRect &old, const QRect &rect)
-{
- DFBResult result = DFB_OK;
- const bool isMove = old.isEmpty() || rect.topLeft() != old.topLeft();
- const bool isResize = rect.size() != old.size();
-
-#if (Q_DIRECTFB_VERSION >= 0x010000)
- if (isResize && isMove) {
- result = dfbWindow->SetBounds(dfbWindow, rect.x(), rect.y(),
- rect.width(), rect.height());
- } else if (isResize) {
- result = dfbWindow->Resize(dfbWindow,
- rect.width(), rect.height());
- } else if (isMove) {
- result = dfbWindow->MoveTo(dfbWindow, rect.x(), rect.y());
- }
-#else
- if (isResize) {
- result = dfbWindow->Resize(dfbWindow,
- rect.width(), rect.height());
- }
- if (isMove) {
- result = dfbWindow->MoveTo(dfbWindow, rect.x(), rect.y());
- }
-#endif
- return result;
-}
-#endif // QT_NO_DIRECTFB_WM
-
-void QDirectFBWindowSurface::setGeometry(const QRect &rect)
-{
- const QRect oldRect = geometry();
- if (oldRect == rect)
- return;
-
- IDirectFBSurface *oldSurface = dfbSurface;
- const bool sizeChanged = oldRect.size() != rect.size();
- if (sizeChanged) {
- delete engine;
- engine = 0;
- releaseSurface();
- Q_ASSERT(!dfbSurface);
- }
-
- if (rect.isNull()) {
-#ifndef QT_NO_DIRECTFB_WM
- if (dfbWindow) {
- if (window())
- window()->setProperty("_q_DirectFBWindowID", QVariant());
-
- dfbWindow->Release(dfbWindow);
- dfbWindow = 0;
- }
-#endif
- Q_ASSERT(!dfbSurface);
-#ifdef QT_DIRECTFB_SUBSURFACE
- Q_ASSERT(!subSurface);
-#endif
- } else {
-#ifdef QT_DIRECTFB_WM
- if (!dfbWindow) {
- createWindow(rect);
- } else {
- setWindowGeometry(dfbWindow, oldRect, rect);
- Q_ASSERT(!sizeChanged || !dfbSurface);
- if (sizeChanged)
- dfbWindow->GetSurface(dfbWindow, &dfbSurface);
- }
-#else
- IDirectFBSurface *primarySurface = screen->primarySurface();
- DFBResult result = DFB_OK;
- if (mode == Primary) {
- Q_ASSERT(primarySurface);
- if (rect == screen->region().boundingRect()) {
- dfbSurface = primarySurface;
- } else {
- const DFBRectangle r = { rect.x(), rect.y(),
- rect.width(), rect.height() };
- result = primarySurface->GetSubSurface(primarySurface, &r, &dfbSurface);
- }
- } else { // mode == Offscreen
- if (!dfbSurface) {
- dfbSurface = screen->createDFBSurface(rect.size(), surfaceFlags() & Opaque ? screen->pixelFormat() : screen->alphaPixmapFormat(),
- QDirectFBScreen::DontTrackSurface);
- }
- }
- if (result != DFB_OK)
- DirectFBErrorFatal("QDirectFBWindowSurface::setGeometry()", result);
-#endif
- }
- if (oldSurface != dfbSurface) {
- imageFormat = dfbSurface ? QDirectFBScreen::getImageFormat(dfbSurface) : QImage::Format_Invalid;
- }
-
- if (oldRect.size() != rect.size()) {
- QWSWindowSurface::setGeometry(rect);
- } else {
- QWindowSurface::setGeometry(rect);
- }
-}
-
-QByteArray QDirectFBWindowSurface::permanentState() const
-{
- QByteArray state(sizeof(SurfaceFlags) + sizeof(DFBWindowID), 0);
- char *ptr = state.data();
- SurfaceFlags flags = surfaceFlags();
- memcpy(ptr, &flags, sizeof(SurfaceFlags));
- ptr += sizeof(SurfaceFlags);
- DFBWindowID did = (DFBWindowID)(-1);
- if (dfbWindow)
- dfbWindow->GetID(dfbWindow, &did);
- memcpy(ptr, &did, sizeof(DFBWindowID));
- return state;
-}
-
-void QDirectFBWindowSurface::setPermanentState(const QByteArray &state)
-{
- const char *ptr = state.constData();
- IDirectFBDisplayLayer *layer = screen->dfbDisplayLayer();
- SurfaceFlags flags;
- memcpy(&flags, ptr, sizeof(SurfaceFlags));
-
- setSurfaceFlags(flags);
- ptr += sizeof(SurfaceFlags);
- DFBWindowID id;
- memcpy(&id, ptr, sizeof(DFBWindowID));
- if (dfbSurface)
- dfbSurface->Release(dfbSurface);
- if (id != (DFBWindowID)-1) {
- IDirectFBWindow *dw;
- layer->GetWindow(layer, id, &dw);
- if (dw->GetSurface(dw, &dfbSurface) != DFB_OK)
- dfbSurface = 0;
- dw->Release(dw);
- }
- else {
- dfbSurface = 0;
- }
-}
-
-bool QDirectFBWindowSurface::scroll(const QRegion &region, int dx, int dy)
-{
- if (!dfbSurface || !(flipFlags & DSFLIP_BLIT) || region.rectCount() != 1)
- return false;
- if (flushPending) {
- dfbSurface->Flip(dfbSurface, 0, DSFLIP_BLIT);
- } else {
- flushPending = true;
- }
- dfbSurface->SetBlittingFlags(dfbSurface, DSBLIT_NOFX);
- const QRect r = region.boundingRect();
- const DFBRectangle rect = { r.x(), r.y(), r.width(), r.height() };
- dfbSurface->Blit(dfbSurface, dfbSurface, &rect, r.x() + dx, r.y() + dy);
- return true;
-}
-
-bool QDirectFBWindowSurface::move(const QPoint &moveBy)
-{
- setGeometry(geometry().translated(moveBy));
- return true;
-}
-
-void QDirectFBWindowSurface::setOpaque(bool opaque)
-{
- SurfaceFlags flags = surfaceFlags();
- if (opaque != (flags & Opaque)) {
- if (opaque) {
- flags |= Opaque;
- } else {
- flags &= ~Opaque;
- }
- setSurfaceFlags(flags);
- }
-}
-
-
-void QDirectFBWindowSurface::flush(QWidget *widget, const QRegion &region,
- const QPoint &offset)
-{
- QWidget *win = window();
- if (!win)
- return;
-
-#if !defined(QT_NO_QWS_PROXYSCREEN) && !defined(QT_NO_GRAPHICSVIEW)
- QWExtra *extra = qt_widget_private(widget)->extraData();
- if (extra && extra->proxyWidget)
- return;
-#else
- Q_UNUSED(widget);
-#endif
-
- const quint8 windowOpacity = quint8(win->windowOpacity() * 0xff);
- const QRect windowGeometry = geometry();
-#ifdef QT_DIRECTFB_WM
- quint8 currentOpacity;
- Q_ASSERT(dfbWindow);
- dfbWindow->GetOpacity(dfbWindow, &currentOpacity);
- if (currentOpacity != windowOpacity) {
- dfbWindow->SetOpacity(dfbWindow, windowOpacity);
- }
-
- screen->flipSurface(dfbSurface, flipFlags, region, offset);
-#else
- setOpaque(windowOpacity == 0xff);
- if (mode == Offscreen) {
- screen->exposeRegion(region.translated(offset + geometry().topLeft()), 0);
- } else {
- screen->flipSurface(dfbSurface, flipFlags, region, offset);
- }
-#endif
-
-#ifdef QT_DIRECTFB_TIMING
- enum { Secs = 3 };
- ++frames;
- if (timer.elapsed() >= Secs * 1000) {
- qDebug("%d fps", int(double(frames) / double(Secs)));
- frames = 0;
- timer.restart();
- }
-#endif
- flushPending = false;
-}
-
-void QDirectFBWindowSurface::beginPaint(const QRegion &region)
-{
- if (!engine) {
- engine = new QDirectFBPaintEngine(this);
- }
-
- if (dfbSurface) {
- const QWidget *win = window();
- if (win && win->testAttribute(Qt::WA_NoSystemBackground)) {
- QDirectFBScreen::solidFill(dfbSurface, Qt::transparent, region);
- }
- }
- flushPending = true;
-}
-
-void QDirectFBWindowSurface::endPaint(const QRegion &)
-{
-#ifdef QT_NO_DIRECTFB_SUBSURFACE
- unlockSurface();
-#endif
-}
-
-IDirectFBSurface *QDirectFBWindowSurface::directFBSurface() const
-{
- return dfbSurface;
-}
-
-
-IDirectFBSurface *QDirectFBWindowSurface::surfaceForWidget(const QWidget *widget, QRect *rect) const
-{
- Q_ASSERT(widget);
- if (!dfbSurface)
- return 0;
- QWidget *win = window();
- Q_ASSERT(win);
- if (rect) {
- if (win == widget) {
- *rect = widget->rect();
- } else {
- *rect = QRect(widget->mapTo(win, QPoint(0, 0)), widget->size());
- }
- }
-
- Q_ASSERT(win == widget || win->isAncestorOf(widget));
- return dfbSurface;
-}
-
-void QDirectFBWindowSurface::releaseSurface()
-{
- if (dfbSurface) {
-#ifdef QT_DIRECTFB_SUBSURFACE
- releaseSubSurface();
-#else
- unlockSurface();
-#endif
-#ifdef QT_NO_DIRECTFB_WM
- Q_ASSERT(screen->primarySurface());
- if (dfbSurface != screen->primarySurface())
-#endif
-
- dfbSurface->Release(dfbSurface);
- dfbSurface = 0;
- }
-}
-
-void QDirectFBWindowSurface::updateIsOpaque()
-{
- const QWidget *win = window();
- Q_ASSERT(win);
- if (win->testAttribute(Qt::WA_OpaquePaintEvent) || win->testAttribute(Qt::WA_PaintOnScreen)) {
- setOpaque(true);
- return;
- }
-
- if (qFuzzyCompare(static_cast<float>(win->windowOpacity()), 1.0f)) {
- const QPalette &pal = win->palette();
-
- if (win->autoFillBackground()) {
- const QBrush &autoFillBrush = pal.brush(win->backgroundRole());
- if (autoFillBrush.style() != Qt::NoBrush && autoFillBrush.isOpaque()) {
- setOpaque(true);
- return;
- }
- }
-
- if (win->isWindow() && !win->testAttribute(Qt::WA_NoSystemBackground)) {
- const QBrush &windowBrush = win->palette().brush(QPalette::Window);
- if (windowBrush.style() != Qt::NoBrush && windowBrush.isOpaque()) {
- setOpaque(true);
- return;
- }
- }
- }
- setOpaque(false);
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_DIRECTFB
diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h b/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h
deleted file mode 100644
index 75d462b523..0000000000
--- a/src/plugins/gfxdrivers/directfb/qdirectfbwindowsurface.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QDIRECFBWINDOWSURFACE_H
-#define QDIRECFBWINDOWSURFACE_H
-
-#include "qdirectfbpaintengine.h"
-#include "qdirectfbpaintdevice.h"
-#include "qdirectfbscreen.h"
-
-#ifndef QT_NO_QWS_DIRECTFB
-
-#include <private/qpaintengine_raster_p.h>
-#include <private/qwindowsurface_qws_p.h>
-
-#ifdef QT_DIRECTFB_TIMING
-#include <qdatetime.h>
-#endif
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QDirectFBWindowSurface : public QWSWindowSurface, public QDirectFBPaintDevice
-{
-public:
- QDirectFBWindowSurface(DFBSurfaceFlipFlags flipFlags, QDirectFBScreen *scr);
- QDirectFBWindowSurface(DFBSurfaceFlipFlags flipFlags, QDirectFBScreen *scr, QWidget *widget);
- ~QDirectFBWindowSurface();
-
-#ifdef QT_DIRECTFB_WM
- void raise();
-#endif
- bool isValid() const;
-
- void setGeometry(const QRect &rect);
-
- QString key() const { return QLatin1String("directfb"); }
- QByteArray permanentState() const;
- void setPermanentState(const QByteArray &state);
-
- bool scroll(const QRegion &area, int dx, int dy);
-
- bool move(const QPoint &offset);
-
- QImage image() const { return QImage(); }
- QPaintDevice *paintDevice() { return this; }
-
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
-
- void beginPaint(const QRegion &);
- void endPaint(const QRegion &);
-
- IDirectFBSurface *surfaceForWidget(const QWidget *widget, QRect *rect) const;
- IDirectFBSurface *directFBSurface() const;
-#ifdef QT_DIRECTFB_WM
- IDirectFBWindow *directFBWindow() const;
-#endif
-private:
- void updateIsOpaque();
- void setOpaque(bool opaque);
- void releaseSurface();
-
-#ifdef QT_DIRECTFB_WM
- void createWindow(const QRect &rect);
- IDirectFBWindow *dfbWindow;
-#else
- enum Mode {
- Primary,
- Offscreen
- } mode;
-#endif
-
- DFBSurfaceFlipFlags flipFlags;
- bool boundingRectFlip;
- bool flushPending;
-#ifdef QT_DIRECTFB_TIMING
- int frames;
- QTime timer;
-#endif
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_QWS_DIRECTFB
-
-#endif // QDIRECFBWINDOWSURFACE_H
diff --git a/src/plugins/gfxdrivers/eglnullws/README b/src/plugins/gfxdrivers/eglnullws/README
deleted file mode 100644
index 80b88c7e01..0000000000
--- a/src/plugins/gfxdrivers/eglnullws/README
+++ /dev/null
@@ -1,48 +0,0 @@
-EGL NullWS QScreen Driver
-=========================
-
-If your application draws everything within a single full-screen QGLWidget then
-you may wish to use this QScreen plugin driver. This driver simply returns 0
-(as a EGLNativeWindowType value) when asked by the QtOpenGl module to create a
-native window. Some OpenGL ES implementations (including PowerVR) interpret this
-to mean that a full-screen OpenGL context is desired without any windowing
-support (NullWS).
-
-To tell a Qt/Embedded application to use this driver use the -display command
-line option or the QWS_DISPLAY environment variable. The following driver
-options are supported:
-
-size=WIDTHxHEIGHT Screen size reported by the driver
-format=FORMAT Screen format
-
-Run with '-display eglnullws:help' to get a full list of options (including a
-list of supported format strings).
-
-If you choose a screen format that is not supported by the hardware then the
-QtOpenGl module will write out a list of supported EGL configurations. Use
-one of the supported screen formats from this list.
-
-Using this driver with PowerVR hardware
----------------------------------------
-
-Using this plugin with PowerVR hardware should give a significant speedup
-compared to running with the Qt powervr driver (with a full-screen QGLWidget).
-This is because sacrificing the window system allows less work to be done in
-order to get graphics on the screen. Using this driver also avoids the memory
-fragmentation issues present in the powervr driver and avoids any direct
-dependencies on the deprecated PVR2D API from Imagination Technologies.
-
-To use this driver ensure you have /etc/powervr.ini with contents similar to
-this:
-
-[default]
-WindowSystem=libpvrPVR2D_FLIPWSEGL.so
-
-This driver will also function with libpvrPVR2D_FRONTWSEGL.so, but that draws
-straight into the framebuffer and will therefore cause flickering (it can be
-useful for performance testing though). The flip plugin uses triple buffering,
-so you will need to set the virtual vertical resolution of your framebuffer to
-be three times the physical vertical resolution of your screen. This can be
-done with 'fbset -vyres'. Failure to do this can cause system crashes. You
-should also ensure that the plugin you choose in powervr.ini is in your library
-path (it may just silently default to the flip plugin if not).
diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullws.pro b/src/plugins/gfxdrivers/eglnullws/eglnullws.pro
deleted file mode 100644
index 30cebab41a..0000000000
--- a/src/plugins/gfxdrivers/eglnullws/eglnullws.pro
+++ /dev/null
@@ -1,18 +0,0 @@
-TARGET = qeglnullws
-include(../../qpluginbase.pri)
-
-CONFIG += warn_on
-QT += opengl
-
-DESTDIR = $$QT.gui.plugins/gfxdrivers
-
-target.path = $$[QT_INSTALL_PLUGINS]/gfxdrivers
-INSTALLS += target
-
-HEADERS = eglnullwsscreen.h \
- eglnullwsscreenplugin.h \
- eglnullwswindowsurface.h
-
-SOURCES = eglnullwsscreen.cpp \
- eglnullwsscreenplugin.cpp \
- eglnullwswindowsurface.cpp
diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp
deleted file mode 100644
index d090e857ad..0000000000
--- a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.cpp
+++ /dev/null
@@ -1,181 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "eglnullwsscreen.h"
-#include "eglnullwswindowsurface.h"
-#include "eglnullwsscreenplugin.h"
-
-#include <QHash>
-#include <QDebug>
-
-namespace
-{
- class EGLNullWSScreenSurfaceFunctions : public QGLScreenSurfaceFunctions
- {
- public:
- virtual bool createNativeWindow(QWidget *, EGLNativeWindowType *native)
- { *native = 0; return true; }
- };
-}
-
-EGLNullWSScreen::EGLNullWSScreen(int displayId) : QGLScreen(displayId) {}
-
-EGLNullWSScreen::~EGLNullWSScreen() {}
-
-bool EGLNullWSScreen::initDevice()
-{
- setSurfaceFunctions(new EGLNullWSScreenSurfaceFunctions);
- return true;
-}
-
-static const QHash<QString, QImage::Format> formatDictionary()
-{
- QHash<QString, QImage::Format> dictionary;
- dictionary["rgb32"] = QImage::Format_RGB32;
- dictionary["argb32"] = QImage::Format_ARGB32;
- dictionary["rgb16"] = QImage::Format_RGB16;
- dictionary["rgb666"] = QImage::Format_RGB666;
- dictionary["rgb555"] = QImage::Format_RGB555;
- dictionary["rgb888"] = QImage::Format_RGB888;
- dictionary["rgb444"] = QImage::Format_RGB444;
- return dictionary;
-}
-
-static int depthForFormat(QImage::Format format)
-{
- switch (format) {
- case QImage::Format_RGB32: return 32;
- case QImage::Format_ARGB32: return 32;
- case QImage::Format_RGB16: return 16;
- case QImage::Format_RGB666: return 24;
- case QImage::Format_RGB555: return 16;
- case QImage::Format_RGB888: return 24;
- case QImage::Format_RGB444: return 16;
- default:
- Q_ASSERT_X(false, "EGLNullWSScreen", "Unknown format");
- return -1;
- }
-}
-
-static void printHelp(const QHash<QString, QImage::Format> &formatDictionary)
-{
- QByteArray formatsBuf;
- QTextStream(&formatsBuf) << QStringList(formatDictionary.keys()).join(", ");
- qWarning(
- "%s: Valid options are:\n"
- "size=WIDTHxHEIGHT Screen size reported by this driver\n"
- "format=FORMAT Screen format, where FORMAT is one of the following:\n"
- " %s\n",
- PluginName,
- formatsBuf.constData());
-}
-
-bool EGLNullWSScreen::connect(const QString &displaySpec)
-{
- const QStringList args = displaySpec.section(':', 1).split(':', QString::SkipEmptyParts);
- const QHash<QString, QImage::Format> formatDict = formatDictionary();
- Q_FOREACH(const QString arg, args) {
- const QString optionName = arg.section('=', 0, 0);
- const QString optionArg = arg.section('=', 1);
- if (optionName == QLatin1String("size")) {
- w = optionArg.section('x', 0, 0).toInt();
- h = optionArg.section('x', 1, 1).toInt();
- } else if (optionName == QLatin1String("format")) {
- if (formatDict.contains(optionArg))
- setPixelFormat(formatDict.value(optionArg));
- else
- printHelp(formatDict);
- } else {
- printHelp(formatDict);
- }
- }
-
- if (w == 0 || h == 0) {
- w = 640;
- h = 480;
- qWarning("%s: Using default screen size %dx%d", PluginName, w, h);
- }
- dw = w;
- dh = h;
-
- if (pixelFormat() == QImage::Format_Invalid) {
- qWarning("%s: Using default screen format argb32", PluginName);
- setPixelFormat(QImage::Format_ARGB32);
- }
- d = depthForFormat(pixelFormat());
-
- static const int Dpi = 120;
- static const qreal ScalingFactor = static_cast<qreal>(25.4) / Dpi;
- physWidth = qRound(dw * ScalingFactor);
- physHeight = qRound(dh * ScalingFactor);
-
- return true;
-}
-
-void EGLNullWSScreen::disconnect() {}
-
-void EGLNullWSScreen::shutdownDevice() {}
-
-void EGLNullWSScreen::setMode(int /*width*/, int /*height*/, int /*depth*/) {}
-
-void EGLNullWSScreen::blank(bool /*on*/) {}
-
-void EGLNullWSScreen::exposeRegion(QRegion /*r*/, int /*changing*/) {}
-
-QWSWindowSurface* EGLNullWSScreen::createSurface(QWidget *widget) const
-{
- if (qobject_cast<QGLWidget*>(widget)) {
- return new EGLNullWSWindowSurface(widget);
- } else {
- qWarning("%s: Creating non-GL surface", PluginName);
- return QScreen::createSurface(widget);
- }
-}
-
-QWSWindowSurface* EGLNullWSScreen::createSurface(const QString &key) const
-{
- if (key == QLatin1String("eglnullws")) {
- return new EGLNullWSWindowSurface;
- } else {
- qWarning("%s: Creating non-GL surface", PluginName);
- return QScreen::createSurface(key);
- }
-}
diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.h b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.h
deleted file mode 100644
index 08ba2fa0cc..0000000000
--- a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreen.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef EGLNULLWSSCREEN
-#define EGLNULLWSSCREEN
-
-#include <QGLScreen>
-
-class EGLNullWSScreen : public QGLScreen
-{
-public:
- EGLNullWSScreen(int displayId);
- ~EGLNullWSScreen();
-
- bool initDevice();
- bool connect(const QString &displaySpec);
- void disconnect();
- void shutdownDevice();
-
- void setMode(int width, int height, int depth);
- void blank(bool on);
-
- void exposeRegion(QRegion r, int changing);
-
- QWSWindowSurface* createSurface(QWidget *widget) const;
- QWSWindowSurface* createSurface(const QString &key) const;
-
- bool hasOpenGL() { return true; }
-};
-
-#endif // EGLNULLWSSCREEN
diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.cpp b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.cpp
deleted file mode 100644
index f7080333f8..0000000000
--- a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.cpp
+++ /dev/null
@@ -1,66 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "eglnullwsscreenplugin.h"
-#include "eglnullwsscreen.h"
-
-#include <QScreenDriverPlugin>
-#include <QStringList>
-
-class EGLNullWSScreenPlugin : public QScreenDriverPlugin
-{
-public:
- virtual QStringList keys() const;
- virtual QScreen *create(const QString& driver, int displayId);
-};
-
-QStringList EGLNullWSScreenPlugin::keys() const
-{
- return QStringList() << QLatin1String(PluginName);
-}
-
-QScreen *EGLNullWSScreenPlugin::create(const QString& driver, int displayId)
-{
- return (driver.toLower() == QLatin1String(PluginName) ?
- new EGLNullWSScreen(displayId) : 0);
-}
-
-Q_EXPORT_PLUGIN2(qeglnullws, EGLNullWSScreenPlugin)
diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.h b/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.h
deleted file mode 100644
index 64a362374d..0000000000
--- a/src/plugins/gfxdrivers/eglnullws/eglnullwsscreenplugin.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef EGLNULLWSSCREENPLUGIN_H
-#define EGLNULLWSSCREENPLUGIN_H
-
-const char *const PluginName = "eglnullws";
-
-#endif // EGLNULLWSSCREENPLUGIN_H
diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.cpp b/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.cpp
deleted file mode 100644
index 8af4d406a5..0000000000
--- a/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "eglnullwswindowsurface.h"
-#include "eglnullwsscreenplugin.h"
-
-#include <QGLWidget>
-
-static const QWSWindowSurface::SurfaceFlags Flags
- = QWSWindowSurface::RegionReserved | QWSWindowSurface::RegionReserved;
-
-EGLNullWSWindowSurface::EGLNullWSWindowSurface(QWidget *w)
- :
- QWSGLWindowSurface(w),
- widget(w)
-{
- setSurfaceFlags(Flags);
-}
-
-EGLNullWSWindowSurface::EGLNullWSWindowSurface()
- : widget(0)
-{
- setSurfaceFlags(Flags);
-}
-
-EGLNullWSWindowSurface::~EGLNullWSWindowSurface() {}
-
-QString EGLNullWSWindowSurface::key() const
-{
- return QLatin1String(PluginName);
-}
-
-QPaintDevice *EGLNullWSWindowSurface::paintDevice()
-{
- return widget;
-}
-
-bool EGLNullWSWindowSurface::isValid() const
-{
- return qobject_cast<QGLWidget *>(window());
-}
-
-QImage EGLNullWSWindowSurface::image() const
-{
- return QImage();
-}
diff --git a/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.h b/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.h
deleted file mode 100644
index 793d3256d6..0000000000
--- a/src/plugins/gfxdrivers/eglnullws/eglnullwswindowsurface.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef EGLNULLWSWINDOWSURFACE_H
-#define EGLNULLWSWINDOWSURFACE_H
-
-#include <private/qglwindowsurface_qws_p.h>
-
-class EGLNullWSWindowSurface : public QWSGLWindowSurface
-{
-public:
- EGLNullWSWindowSurface(QWidget *widget);
- EGLNullWSWindowSurface();
- virtual ~EGLNullWSWindowSurface();
-
- virtual QString key() const;
- virtual QPaintDevice *paintDevice();
- virtual bool isValid() const;
- virtual QImage image() const;
-
-private:
- QWidget *widget;
-};
-
-#endif // EGLNULLWSWINDOWSURFACE_H
diff --git a/src/plugins/gfxdrivers/gfxdrivers.pro b/src/plugins/gfxdrivers/gfxdrivers.pro
deleted file mode 100644
index 1f38942a50..0000000000
--- a/src/plugins/gfxdrivers/gfxdrivers.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-TEMPLATE = subdirs
-contains(gfx-plugins, ahi) :SUBDIRS += ahi
-contains(gfx-plugins, directfb) :SUBDIRS += directfb
-contains(gfx-plugins, linuxfb) :SUBDIRS += linuxfb
-contains(gfx-plugins, qvfb) :SUBDIRS += qvfb
-contains(gfx-plugins, vnc) :SUBDIRS += vnc
-contains(gfx-plugins, transformed) :SUBDIRS += transformed
-contains(gfx-plugins, svgalib) :SUBDIRS += svgalib
-contains(gfx-plugins, powervr) :SUBDIRS += powervr
-contains(gfx-plugins, eglnullws) :SUBDIRS += eglnullws
diff --git a/src/plugins/gfxdrivers/linuxfb/linuxfb.pro b/src/plugins/gfxdrivers/linuxfb/linuxfb.pro
deleted file mode 100644
index c1cdc0eda7..0000000000
--- a/src/plugins/gfxdrivers/linuxfb/linuxfb.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-TARGET = qscreenlinuxfb
-include(../../qpluginbase.pri)
-
-DESTDIR = $$QT.gui.plugins/gfxdrivers
-
-target.path = $$[QT_INSTALL_PLUGINS]/gfxdrivers
-INSTALLS += target
-
-DEFINES += QT_QWS_LINUXFB
-
-HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qscreenlinuxfb_qws.h
-
-SOURCES = main.cpp \
- $$QT_SOURCE_TREE/src/gui/embedded/qscreenlinuxfb_qws.cpp
diff --git a/src/plugins/gfxdrivers/linuxfb/main.cpp b/src/plugins/gfxdrivers/linuxfb/main.cpp
deleted file mode 100644
index 6ea7b9ca24..0000000000
--- a/src/plugins/gfxdrivers/linuxfb/main.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qscreendriverplugin_qws.h>
-#include <qscreenlinuxfb_qws.h>
-#include <qstringlist.h>
-
-QT_BEGIN_NAMESPACE
-
-class QScreenLinuxFbPlugin : public QScreenDriverPlugin
-{
-public:
- QScreenLinuxFbPlugin();
-
- QStringList keys() const;
- QScreen *create(const QString&, int displayId);
-};
-
-QScreenLinuxFbPlugin::QScreenLinuxFbPlugin()
- : QScreenDriverPlugin()
-{
-}
-
-QStringList QScreenLinuxFbPlugin::keys() const
-{
- QStringList list;
- list << QLatin1String("LinuxFb");
- return list;
-}
-
-QScreen* QScreenLinuxFbPlugin::create(const QString& driver, int displayId)
-{
- if (driver.toLower() == QLatin1String("linuxfb"))
- return new QLinuxFbScreen(displayId);
-
- return 0;
-}
-
-Q_EXPORT_PLUGIN2(qscreenlinuxfb, QScreenLinuxFbPlugin)
-
-QT_END_NAMESPACE
diff --git a/src/plugins/gfxdrivers/powervr/QWSWSEGL/QWSWSEGL.pro b/src/plugins/gfxdrivers/powervr/QWSWSEGL/QWSWSEGL.pro
deleted file mode 100644
index 595cf45301..0000000000
--- a/src/plugins/gfxdrivers/powervr/QWSWSEGL/QWSWSEGL.pro
+++ /dev/null
@@ -1,26 +0,0 @@
-TEMPLATE = lib
-TARGET = pvrQWSWSEGL
-CONFIG += dll warn_on
-CONFIG -= qt
-
-HEADERS+=\
- pvrqwsdrawable.h \
- pvrqwsdrawable_p.h
-
-SOURCES+=\
- pvrqwsdrawable.c \
- pvrqwswsegl.c
-
-INCLUDEPATH += $$QMAKE_INCDIR_EGL
-
-for(p, QMAKE_LIBDIR_EGL) {
- exists($$p):LIBS += -L$$p
-}
-
-LIBS += -lpvr2d
-
-DESTDIR = $$QMAKE_LIBDIR_QT
-target.path = $$[QT_INSTALL_LIBS]
-INSTALLS += target
-
-include(../powervr.pri) \ No newline at end of file
diff --git a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c
deleted file mode 100644
index 8dc0120fe1..0000000000
--- a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.c
+++ /dev/null
@@ -1,830 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "pvrqwsdrawable_p.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <sys/ioctl.h>
-#include <linux/fb.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-PvrQwsDisplay pvrQwsDisplay;
-
-static void pvrQwsDestroyDrawableForced(PvrQwsDrawable *drawable);
-
-/* Initialize the /dev/fbN device for a specific screen */
-static int pvrQwsInitFbScreen(int screen)
-{
- struct fb_var_screeninfo var;
- struct fb_fix_screeninfo fix;
- unsigned long start;
- unsigned long length;
- int width, height, stride;
- PVR2DFORMAT format;
- void *mapped;
- int fd, bytesPerPixel;
- char name[64];
- PVR2DMEMINFO *memInfo;
- unsigned long pageAddresses[2];
-
- /* Bail out if already initialized, or the number is incorrect */
- if (screen < 0 || screen >= PVRQWS_MAX_SCREENS)
- return 0;
- if (pvrQwsDisplay.screens[screen].initialized)
- return 1;
-
- /* Open the framebuffer and fetch its properties */
- sprintf(name, "/dev/fb%d", screen);
- fd = open(name, O_RDWR, 0);
- if (fd < 0) {
- perror(name);
- return 0;
- }
- if (ioctl(fd, FBIOGET_VSCREENINFO, &var) < 0) {
- perror("FBIOGET_VSCREENINFO");
- close(fd);
- return 0;
- }
- if (ioctl(fd, FBIOGET_FSCREENINFO, &fix) < 0) {
- perror("FBIOGET_FSCREENINFO");
- close(fd);
- return 0;
- }
- width = var.xres;
- height = var.yres;
- bytesPerPixel = var.bits_per_pixel / 8;
- stride = fix.line_length;
- format = PVR2D_1BPP;
- if (var.bits_per_pixel == 16) {
- if (var.red.length == 5 && var.green.length == 6 &&
- var.blue.length == 5 && var.red.offset == 11 &&
- var.green.offset == 5 && var.blue.offset == 0) {
- format = PVR2D_RGB565;
- }
- if (var.red.length == 4 && var.green.length == 4 &&
- var.blue.length == 4 && var.transp.length == 4 &&
- var.red.offset == 8 && var.green.offset == 4 &&
- var.blue.offset == 0 && var.transp.offset == 12) {
- format = PVR2D_ARGB4444;
- }
- } else if (var.bits_per_pixel == 32) {
- if (var.red.length == 8 && var.green.length == 8 &&
- var.blue.length == 8 && var.transp.length == 8 &&
- var.red.offset == 16 && var.green.offset == 8 &&
- var.blue.offset == 0 && var.transp.offset == 24) {
- format = PVR2D_ARGB8888;
- }
- }
- if (format == PVR2D_1BPP) {
- fprintf(stderr, "%s: could not find a suitable PVR2D pixel format\n", name);
- close(fd);
- return 0;
- }
- start = fix.smem_start;
- length = var.xres_virtual * var.yres_virtual * bytesPerPixel;
-
- if (screen == 0) {
- /* We use PVR2DGetFrameBuffer to map the first screen.
- On some chipsets it is more reliable than using PVR2DMemWrap */
- mapped = 0;
- memInfo = 0;
- } else {
- /* Other screens: map the framebuffer region into memory */
- mapped = mmap(0, length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
- if (!mapped || mapped == (void *)(-1)) {
- perror("mmap");
- close(fd);
- return 0;
- }
-
- /* Allocate a PVR2D memory region for the framebuffer */
- memInfo = 0;
- if (pvrQwsDisplay.context) {
- pageAddresses[0] = start & 0xFFFFF000;
- pageAddresses[1] = 0;
- if (PVR2DMemWrap
- (pvrQwsDisplay.context, mapped, PVR2D_WRAPFLAG_CONTIGUOUS,
- length, pageAddresses, &memInfo) != PVR2D_OK) {
- munmap(mapped, length);
- close(fd);
- return 0;
- }
- }
- }
-
- /* We don't need the file descriptor any more */
- close(fd);
-
- /* The framebuffer is ready, so initialize the PvrQwsScreenInfo */
- pvrQwsDisplay.screens[screen].screenRect.x = 0;
- pvrQwsDisplay.screens[screen].screenRect.y = 0;
- pvrQwsDisplay.screens[screen].screenRect.width = width;
- pvrQwsDisplay.screens[screen].screenRect.height = height;
- pvrQwsDisplay.screens[screen].screenStride = stride;
- pvrQwsDisplay.screens[screen].pixelFormat = format;
- pvrQwsDisplay.screens[screen].bytesPerPixel = bytesPerPixel;
- pvrQwsDisplay.screens[screen].screenDrawable = 0;
- if (mapped) {
- /* Don't set these fields if mapped is 0, because PVR2DGetFrameBuffer
- may have already been called and set them */
- pvrQwsDisplay.screens[screen].frameBuffer = memInfo;
- pvrQwsDisplay.screens[screen].mapped = mapped;
- }
- pvrQwsDisplay.screens[screen].mappedLength = length;
- pvrQwsDisplay.screens[screen].screenStart = start;
- pvrQwsDisplay.screens[screen].needsUnmap = (mapped != 0);
- pvrQwsDisplay.screens[screen].initialized = 1;
- return 1;
-}
-
-/* Called when a new drawable is added to ensure that we have a
- PVR2D context and framebuffer PVR2DMEMINFO blocks */
-static int pvrQwsAddDrawable(void)
-{
- int numDevs, screen;
- PVR2DDEVICEINFO *devs;
- unsigned long devId;
- unsigned long pageAddresses[2];
- PVR2DMEMINFO *memInfo;
- PVR2DDISPLAYINFO displayInfo;
-
- /* Bail out early if this is not the first drawable */
- if (pvrQwsDisplay.numDrawables > 0) {
- ++(pvrQwsDisplay.numDrawables);
- return 1;
- }
-
- /* Find the first PVR2D device in the system and open it */
- numDevs = PVR2DEnumerateDevices(0);
- if (numDevs <= 0)
- return 0;
- devs = (PVR2DDEVICEINFO *)malloc(sizeof(PVR2DDEVICEINFO) * numDevs);
- if (!devs)
- return 0;
- if (PVR2DEnumerateDevices(devs) != PVR2D_OK) {
- free(devs);
- return 0;
- }
- devId = devs[0].ulDevID;
- free(devs);
- if (PVR2DCreateDeviceContext(devId, &pvrQwsDisplay.context, 0) != PVR2D_OK)
- return 0;
- pvrQwsDisplay.numFlipBuffers = 0;
- pvrQwsDisplay.flipChain = 0;
- if (PVR2DGetDeviceInfo(pvrQwsDisplay.context, &displayInfo) == PVR2D_OK) {
- if (displayInfo.ulMaxFlipChains > 0 && displayInfo.ulMaxBuffersInChain > 0)
- pvrQwsDisplay.numFlipBuffers = displayInfo.ulMaxBuffersInChain;
- if (pvrQwsDisplay.numFlipBuffers > PVRQWS_MAX_FLIP_BUFFERS)
- pvrQwsDisplay.numFlipBuffers = PVRQWS_MAX_FLIP_BUFFERS;
- }
-
- /* Create the PVR2DMEMINFO blocks for the active framebuffers */
- for (screen = 0; screen < PVRQWS_MAX_SCREENS; ++screen) {
- if (screen != 0 && pvrQwsDisplay.screens[screen].mapped) {
- pageAddresses[0]
- = pvrQwsDisplay.screens[screen].screenStart & 0xFFFFF000;
- pageAddresses[1] = 0;
- if (PVR2DMemWrap
- (pvrQwsDisplay.context,
- pvrQwsDisplay.screens[screen].mapped,
- PVR2D_WRAPFLAG_CONTIGUOUS,
- pvrQwsDisplay.screens[screen].mappedLength,
- pageAddresses, &memInfo) != PVR2D_OK) {
- PVR2DDestroyDeviceContext(pvrQwsDisplay.context);
- pvrQwsDisplay.context = 0;
- return 0;
- }
- pvrQwsDisplay.screens[screen].frameBuffer = memInfo;
- } else if (screen == 0) {
- if (PVR2DGetFrameBuffer
- (pvrQwsDisplay.context,
- PVR2D_FB_PRIMARY_SURFACE, &memInfo) != PVR2D_OK) {
- fprintf(stderr, "QWSWSEGL: could not get the primary framebuffer surface\n");
- PVR2DDestroyDeviceContext(pvrQwsDisplay.context);
- pvrQwsDisplay.context = 0;
- return 0;
- }
- pvrQwsDisplay.screens[screen].frameBuffer = memInfo;
- pvrQwsDisplay.screens[screen].mapped = memInfo->pBase;
- }
- }
-
- /* Create a flip chain for the screen if supported by the hardware */
- pvrQwsDisplay.usePresentBlit = 0;
- if (pvrQwsDisplay.numFlipBuffers > 0) {
- long stride = 0;
- unsigned long flipId = 0;
- unsigned long numBuffers;
- if (PVR2DCreateFlipChain(pvrQwsDisplay.context, 0,
- //PVR2D_CREATE_FLIPCHAIN_SHARED |
- //PVR2D_CREATE_FLIPCHAIN_QUERY,
- pvrQwsDisplay.numFlipBuffers,
- pvrQwsDisplay.screens[0].screenRect.width,
- pvrQwsDisplay.screens[0].screenRect.height,
- pvrQwsDisplay.screens[0].pixelFormat,
- &stride, &flipId, &(pvrQwsDisplay.flipChain))
- == PVR2D_OK) {
- pvrQwsDisplay.screens[0].screenStride = stride;
- PVR2DGetFlipChainBuffers(pvrQwsDisplay.context,
- pvrQwsDisplay.flipChain,
- &numBuffers,
- pvrQwsDisplay.flipBuffers);
- } else {
- pvrQwsDisplay.flipChain = 0;
- pvrQwsDisplay.numFlipBuffers = 0;
- }
-
- /* PVR2DPresentBlt is a little more reliable than PVR2DBlt
- when flip chains are present, even if we cannot create a
- flip chain at the moment */
- pvrQwsDisplay.usePresentBlit = 1;
- }
-
- /* The context is ready to go */
- ++(pvrQwsDisplay.numDrawables);
- return 1;
-}
-
-/* Called when the last drawable is destroyed. The PVR2D context
- will be destroyed but the raw framebuffer memory will stay mapped */
-static void pvrQwsDestroyContext(void)
-{
- int screen;
- for (screen = 0; screen < PVRQWS_MAX_SCREENS; ++screen) {
- if (pvrQwsDisplay.screens[screen].frameBuffer) {
- PVR2DMemFree
- (pvrQwsDisplay.context,
- pvrQwsDisplay.screens[screen].frameBuffer);
- pvrQwsDisplay.screens[screen].frameBuffer = 0;
- }
- }
-
- if (pvrQwsDisplay.numFlipBuffers > 0)
- PVR2DDestroyFlipChain(pvrQwsDisplay.context, pvrQwsDisplay.flipChain);
- PVR2DDestroyDeviceContext(pvrQwsDisplay.context);
- pvrQwsDisplay.context = 0;
- pvrQwsDisplay.flipChain = 0;
- pvrQwsDisplay.numFlipBuffers = 0;
- pvrQwsDisplay.usePresentBlit = 0;
-}
-
-int pvrQwsDisplayOpen(void)
-{
- int screen;
-
- /* If the display is already open, increase reference count and return */
- if (pvrQwsDisplay.refCount > 0) {
- ++(pvrQwsDisplay.refCount);
- return 1;
- }
-
- /* Open the framebuffer and map it directly */
- if (!pvrQwsInitFbScreen(0)) {
- --(pvrQwsDisplay.refCount);
- return 0;
- }
-
- /* Clear the other screens. We will create them if they are referenced */
- for (screen = 1; screen < PVRQWS_MAX_SCREENS; ++screen)
- memset(&(pvrQwsDisplay.screens[screen]), 0, sizeof(PvrQwsScreenInfo));
-
- /* The display is open and ready */
- ++(pvrQwsDisplay.refCount);
- return 1;
-}
-
-void pvrQwsDisplayClose(void)
-{
- int screen;
-
- if (pvrQwsDisplay.refCount == 0)
- return;
- if (--(pvrQwsDisplay.refCount) > 0)
- return;
-
- /* Prevent pvrQwsDestroyContext from being called for the time being */
- ++pvrQwsDisplay.numDrawables;
-
- /* Free the screens */
- for (screen = 0; screen < PVRQWS_MAX_SCREENS; ++screen) {
- PvrQwsScreenInfo *info = &(pvrQwsDisplay.screens[screen]);
- if (info->screenDrawable)
- pvrQwsDestroyDrawableForced(info->screenDrawable);
- if (info->frameBuffer)
- PVR2DMemFree(pvrQwsDisplay.context, info->frameBuffer);
- if (info->mapped && info->needsUnmap)
- munmap(info->mapped, info->mappedLength);
- }
-
- /* Now it is safe to destroy the PVR2D context */
- --pvrQwsDisplay.numDrawables;
- if (pvrQwsDisplay.context)
- PVR2DDestroyDeviceContext(pvrQwsDisplay.context);
-
- memset(&pvrQwsDisplay, 0, sizeof(pvrQwsDisplay));
-}
-
-int pvrQwsDisplayIsOpen(void)
-{
- return (pvrQwsDisplay.refCount > 0);
-}
-
-/* Ensure that a specific screen has been initialized */
-static int pvrQwsEnsureScreen(int screen)
-{
- if (screen < 0 || screen >= PVRQWS_MAX_SCREENS)
- return 0;
- if (!screen)
- return 1;
- return pvrQwsInitFbScreen(screen);
-}
-
-PvrQwsDrawable *pvrQwsScreenWindow(int screen)
-{
- PvrQwsDrawable *drawable;
-
- if (!pvrQwsEnsureScreen(screen))
- return 0;
-
- drawable = pvrQwsDisplay.screens[screen].screenDrawable;
- if (drawable)
- return drawable;
-
- drawable = (PvrQwsDrawable *)calloc(1, sizeof(PvrQwsDrawable));
- if (!drawable)
- return 0;
-
- drawable->type = PvrQwsScreen;
- drawable->screen = screen;
- drawable->pixelFormat = pvrQwsDisplay.screens[screen].pixelFormat;
- drawable->rect = pvrQwsDisplay.screens[screen].screenRect;
- drawable->visibleRects[0] = drawable->rect;
- drawable->numVisibleRects = 1;
- drawable->isFullScreen = 1;
-
- if (!pvrQwsAddDrawable()) {
- free(drawable);
- return 0;
- }
-
- pvrQwsDisplay.screens[screen].screenDrawable = drawable;
-
- return drawable;
-}
-
-PvrQwsDrawable *pvrQwsCreateWindow(int screen, long winId, const PvrQwsRect *rect)
-{
- PvrQwsDrawable *drawable;
-
- if (!pvrQwsEnsureScreen(screen))
- return 0;
-
- drawable = (PvrQwsDrawable *)calloc(1, sizeof(PvrQwsDrawable));
- if (!drawable)
- return 0;
-
- drawable->type = PvrQwsWindow;
- drawable->winId = winId;
- drawable->refCount = 1;
- drawable->screen = screen;
- drawable->pixelFormat = pvrQwsDisplay.screens[screen].pixelFormat;
- drawable->rect = *rect;
-
- if (!pvrQwsAddDrawable()) {
- free(drawable);
- return 0;
- }
-
- drawable->nextWinId = pvrQwsDisplay.firstWinId;
- pvrQwsDisplay.firstWinId = drawable;
-
- return drawable;
-}
-
-PvrQwsDrawable *pvrQwsFetchWindow(long winId)
-{
- PvrQwsDrawable *drawable = pvrQwsDisplay.firstWinId;
- while (drawable != 0 && drawable->winId != winId)
- drawable = drawable->nextWinId;
-
- if (drawable)
- ++(drawable->refCount);
- return drawable;
-}
-
-int pvrQwsReleaseWindow(PvrQwsDrawable *drawable)
-{
- if (drawable->type == PvrQwsWindow)
- return (--(drawable->refCount) <= 0);
- else
- return 0;
-}
-
-PvrQwsDrawable *pvrQwsCreatePixmap(int width, int height, int screen)
-{
- PvrQwsDrawable *drawable;
-
- if (!pvrQwsEnsureScreen(screen))
- return 0;
-
- drawable = (PvrQwsDrawable *)calloc(1, sizeof(PvrQwsDrawable));
- if (!drawable)
- return 0;
-
- drawable->type = PvrQwsPixmap;
- drawable->screen = screen;
- drawable->pixelFormat = pvrQwsDisplay.screens[screen].pixelFormat;
- drawable->rect.x = 0;
- drawable->rect.y = 0;
- drawable->rect.width = width;
- drawable->rect.height = height;
-
- if (!pvrQwsAddDrawable()) {
- free(drawable);
- return 0;
- }
-
- return drawable;
-}
-
-static void pvrQwsDestroyDrawableForced(PvrQwsDrawable *drawable)
-{
- /* Remove the drawable from the display's winId list */
- PvrQwsDrawable *current = pvrQwsDisplay.firstWinId;
- PvrQwsDrawable *prev = 0;
- while (current != 0 && current != drawable) {
- prev = current;
- current = current->nextWinId;
- }
- if (current != 0) {
- if (prev)
- prev->nextWinId = current->nextWinId;
- else
- pvrQwsDisplay.firstWinId = current->nextWinId;
- }
-
- pvrQwsFreeBuffers(drawable);
- free(drawable);
-
- --pvrQwsDisplay.numDrawables;
- if (pvrQwsDisplay.numDrawables == 0)
- pvrQwsDestroyContext();
-}
-
-void pvrQwsDestroyDrawable(PvrQwsDrawable *drawable)
-{
- if (drawable && drawable->type != PvrQwsScreen)
- pvrQwsDestroyDrawableForced(drawable);
-}
-
-PvrQwsDrawableType pvrQwsGetDrawableType(PvrQwsDrawable *drawable)
-{
- return drawable->type;
-}
-
-void pvrQwsSetVisibleRegion
- (PvrQwsDrawable *drawable, const PvrQwsRect *rects, int numRects)
-{
- int index, indexOut;
- PvrQwsRect *rect;
- PvrQwsRect *screenRect;
-
- /* Visible regions don't make sense for pixmaps */
- if (drawable->type == PvrQwsPixmap)
- return;
-
- /* Restrict the number of rectangles to prevent buffer overflow */
- if (numRects > PVRQWS_MAX_VISIBLE_RECTS)
- numRects = PVRQWS_MAX_VISIBLE_RECTS;
- if (numRects > 0)
- memcpy(drawable->visibleRects, rects, numRects * sizeof(PvrQwsRect));
-
- /* Convert the rectangles into screen-relative co-ordinates and
- then clamp them to the screen boundaries. If any of the
- clamped rectangles are empty, remove them from the list */
- screenRect = &(pvrQwsDisplay.screens[drawable->screen].screenRect);
- indexOut = 0;
- for (index = 0, rect = drawable->visibleRects; index < numRects; ++index, ++rect) {
- if (rect->x < 0) {
- rect->width += rect->x;
- rect->x = 0;
- if (rect->width < 0)
- rect->width = 0;
- } else if (rect->x >= screenRect->width) {
- rect->x = screenRect->width;
- rect->width = 0;
- }
- if ((rect->x + rect->width) > screenRect->width) {
- rect->width = screenRect->width - rect->x;
- }
- if (rect->y < 0) {
- rect->height += rect->y;
- rect->y = 0;
- if (rect->height < 0)
- rect->height = 0;
- } else if (rect->y >= screenRect->height) {
- rect->y = screenRect->height;
- rect->height = 0;
- }
- if ((rect->y + rect->height) > screenRect->height) {
- rect->height = screenRect->height - rect->y;
- }
- if (rect->width > 0 && rect->height > 0) {
- if (index != indexOut)
- drawable->visibleRects[indexOut] = *rect;
- ++indexOut;
- }
- }
- drawable->numVisibleRects = indexOut;
-}
-
-void pvrQwsClearVisibleRegion(PvrQwsDrawable *drawable)
-{
- if (drawable->type != PvrQwsPixmap)
- drawable->numVisibleRects = 0;
-}
-
-void pvrQwsSetGeometry(PvrQwsDrawable *drawable, const PvrQwsRect *rect)
-{
- /* We can only change the geometry of window drawables */
- if (drawable->type != PvrQwsWindow)
- return;
-
- /* If the position has changed, then clear the visible region */
- if (drawable->rect.x != rect->x || drawable->rect.y != rect->y) {
- drawable->rect.x = rect->x;
- drawable->rect.y = rect->y;
- drawable->numVisibleRects = 0;
- }
-
- /* If the size has changed, then clear the visible region and
- invalidate the drawable's buffers. Invalidating the buffers
- will force EGL to recreate the drawable, which will then
- allocate new buffers for the new size */
- if (drawable->rect.width != rect->width ||
- drawable->rect.height != rect->height) {
- drawable->rect.width = rect->width;
- drawable->rect.height = rect->height;
- drawable->numVisibleRects = 0;
- pvrQwsInvalidateBuffers(drawable);
- }
-}
-
-void pvrQwsGetGeometry(PvrQwsDrawable *drawable, PvrQwsRect *rect)
-{
- *rect = drawable->rect;
-}
-
-void pvrQwsSetRotation(PvrQwsDrawable *drawable, int angle)
-{
- if (drawable->rotationAngle != angle) {
- drawable->rotationAngle = angle;
-
- /* Force the buffers to be recreated if the rotation angle changes */
- pvrQwsInvalidateBuffers(drawable);
- }
-}
-
-int pvrQwsGetStride(PvrQwsDrawable *drawable)
-{
- if (drawable->backBuffersValid)
- return drawable->strideBytes;
- else
- return 0;
-}
-
-PvrQwsPixelFormat pvrQwsGetPixelFormat(PvrQwsDrawable *drawable)
-{
- return (PvrQwsPixelFormat)(drawable->pixelFormat);
-}
-
-void *pvrQwsGetRenderBuffer(PvrQwsDrawable *drawable)
-{
- if (drawable->backBuffersValid)
- return drawable->backBuffers[drawable->currentBackBuffer]->pBase;
- else
- return 0;
-}
-
-int pvrQwsAllocBuffers(PvrQwsDrawable *drawable)
-{
- int index;
- int numBuffers = PVRQWS_MAX_BACK_BUFFERS;
- if (drawable->type == PvrQwsPixmap)
- numBuffers = 1;
- if (drawable->backBuffers[0]) {
- if (drawable->backBuffersValid)
- return 1;
- if (!drawable->usingFlipBuffers) {
- for (index = 0; index < numBuffers; ++index)
- PVR2DMemFree(pvrQwsDisplay.context, drawable->backBuffers[index]);
- }
- }
- drawable->stridePixels = (drawable->rect.width + 31) & ~31;
- drawable->strideBytes =
- drawable->stridePixels *
- pvrQwsDisplay.screens[drawable->screen].bytesPerPixel;
- drawable->usingFlipBuffers =
- (pvrQwsDisplay.numFlipBuffers > 0 && drawable->isFullScreen);
- if (drawable->usingFlipBuffers) {
- if (numBuffers > (int)(pvrQwsDisplay.numFlipBuffers))
- numBuffers = pvrQwsDisplay.numFlipBuffers;
- for (index = 0; index < numBuffers; ++index)
- drawable->backBuffers[index] = pvrQwsDisplay.flipBuffers[index];
- } else {
- for (index = 0; index < numBuffers; ++index) {
- if (PVR2DMemAlloc(pvrQwsDisplay.context,
- drawable->strideBytes * drawable->rect.height,
- 128, 0,
- &(drawable->backBuffers[index])) != PVR2D_OK) {
- while (--index >= 0)
- PVR2DMemFree(pvrQwsDisplay.context, drawable->backBuffers[index]);
- memset(drawable->backBuffers, 0, sizeof(drawable->backBuffers));
- drawable->backBuffersValid = 0;
- return 0;
- }
- }
- }
- for (index = numBuffers; index < PVRQWS_MAX_BACK_BUFFERS; ++index) {
- drawable->backBuffers[index] = drawable->backBuffers[0];
- }
- drawable->backBuffersValid = 1;
- drawable->currentBackBuffer = 0;
- return 1;
-}
-
-void pvrQwsFreeBuffers(PvrQwsDrawable *drawable)
-{
- int index;
- int numBuffers = PVRQWS_MAX_BACK_BUFFERS;
- if (drawable->type == PvrQwsPixmap)
- numBuffers = 1;
- if (!drawable->usingFlipBuffers) {
- for (index = 0; index < numBuffers; ++index) {
- if (drawable->backBuffers[index])
- PVR2DMemFree(pvrQwsDisplay.context, drawable->backBuffers[index]);
- }
- }
- memset(drawable->backBuffers, 0, sizeof(drawable->backBuffers));
- drawable->backBuffersValid = 0;
- drawable->usingFlipBuffers = 0;
-}
-
-void pvrQwsInvalidateBuffers(PvrQwsDrawable *drawable)
-{
- drawable->backBuffersValid = 0;
-}
-
-int pvrQwsGetBuffers
- (PvrQwsDrawable *drawable, PVR2DMEMINFO **source, PVR2DMEMINFO **render)
-{
- if (!drawable->backBuffersValid)
- return 0;
- *render = drawable->backBuffers[drawable->currentBackBuffer];
- *source = drawable->backBuffers
- [(drawable->currentBackBuffer + PVRQWS_MAX_BACK_BUFFERS - 1) %
- PVRQWS_MAX_BACK_BUFFERS];
- return 1;
-}
-
-int pvrQwsSwapBuffers(PvrQwsDrawable *drawable, int repaintOnly)
-{
- PVR2DMEMINFO *buffer;
- PvrQwsRect *rect;
- int index;
-
- /* Bail out if the back buffers have been invalidated */
- if (!drawable->backBuffersValid)
- return 0;
-
- /* If there is a swap function, then use that instead */
- if (drawable->swapFunction) {
- (*(drawable->swapFunction))(drawable, drawable->userData, repaintOnly);
- if (!repaintOnly) {
- drawable->currentBackBuffer
- = (drawable->currentBackBuffer + 1) % PVRQWS_MAX_BACK_BUFFERS;
- }
- return 1;
- }
-
- /* Iterate through the visible rectangles and blit them to the screen */
- if (!repaintOnly) {
- index = drawable->currentBackBuffer;
- } else {
- index = (drawable->currentBackBuffer + PVRQWS_MAX_BACK_BUFFERS - 1)
- % PVRQWS_MAX_BACK_BUFFERS;
- }
- buffer = drawable->backBuffers[index];
- rect = drawable->visibleRects;
- if (drawable->usingFlipBuffers) {
- PVR2DPresentFlip(pvrQwsDisplay.context, pvrQwsDisplay.flipChain, buffer, 0);
- } else if (pvrQwsDisplay.usePresentBlit && drawable->numVisibleRects > 0) {
- PVR2DRECT pvrRects[PVRQWS_MAX_VISIBLE_RECTS];
- for (index = 0; index < drawable->numVisibleRects; ++index, ++rect) {
- pvrRects[index].left = rect->x;
- pvrRects[index].top = rect->y;
- pvrRects[index].right = rect->x + rect->width;
- pvrRects[index].bottom = rect->y + rect->height;
- }
- for (index = 0; index < drawable->numVisibleRects; index += 4) {
- int numClip = drawable->numVisibleRects - index;
- if (numClip > 4) /* No more than 4 clip rects at a time */
- numClip = 4;
- PVR2DSetPresentBltProperties
- (pvrQwsDisplay.context,
- PVR2D_PRESENT_PROPERTY_SRCSTRIDE |
- PVR2D_PRESENT_PROPERTY_DSTSIZE |
- PVR2D_PRESENT_PROPERTY_DSTPOS |
- PVR2D_PRESENT_PROPERTY_CLIPRECTS,
- drawable->strideBytes,
- drawable->rect.width, drawable->rect.height,
- drawable->rect.x, drawable->rect.y,
- numClip, pvrRects + index, 0);
- PVR2DPresentBlt(pvrQwsDisplay.context, buffer, 0);
- }
- PVR2DQueryBlitsComplete(pvrQwsDisplay.context, buffer, 1);
- } else {
- /* TODO: use PVR2DBltClipped for faster transfers of clipped windows */
- PVR2DBLTINFO blit;
- for (index = 0; index < drawable->numVisibleRects; ++index, ++rect) {
- memset(&blit, 0, sizeof(blit));
-
- blit.CopyCode = PVR2DROPcopy;
- blit.BlitFlags = PVR2D_BLIT_DISABLE_ALL;
-
- blit.pSrcMemInfo = buffer;
- blit.SrcStride = drawable->strideBytes;
- blit.SrcX = rect->x - drawable->rect.x;
- blit.SrcY = rect->y - drawable->rect.y;
- blit.SizeX = rect->width;
- blit.SizeY = rect->height;
- blit.SrcFormat = drawable->pixelFormat;
-
- blit.pDstMemInfo = pvrQwsDisplay.screens[drawable->screen].frameBuffer;
- blit.DstStride = pvrQwsDisplay.screens[drawable->screen].screenStride;
- blit.DstX = rect->x;
- blit.DstY = rect->y;
- blit.DSizeX = rect->width;
- blit.DSizeY = rect->height;
- blit.DstFormat = pvrQwsDisplay.screens[drawable->screen].pixelFormat;
-
- PVR2DBlt(pvrQwsDisplay.context, &blit);
- }
- }
-
- /* Swap the buffers */
- if (!repaintOnly) {
- drawable->currentBackBuffer
- = (drawable->currentBackBuffer + 1) % PVRQWS_MAX_BACK_BUFFERS;
- }
- return 1;
-}
-
-void pvrQwsSetSwapFunction
- (PvrQwsDrawable *drawable, PvrQwsSwapFunction func, void *userData)
-{
- drawable->swapFunction = func;
- drawable->userData = userData;
-}
diff --git a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.h b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.h
deleted file mode 100644
index 8c8cc27018..0000000000
--- a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable.h
+++ /dev/null
@@ -1,169 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef PVRQWSDRAWABLE_H
-#define PVRQWSDRAWABLE_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef struct {
- int x, y, width, height;
-} PvrQwsRect;
-
-typedef enum
-{
- PvrQwsScreen,
- PvrQwsWindow,
- PvrQwsPixmap
-
-} PvrQwsDrawableType;
-
-typedef enum
-{
- PvrQws_1BPP = 0,
- PvrQws_RGB565,
- PvrQws_ARGB4444,
- PvrQws_RGB888,
- PvrQws_ARGB8888,
- PvrQws_VGAEMU
-
-} PvrQwsPixelFormat;
-
-typedef struct _PvrQwsDrawable PvrQwsDrawable;
-
-typedef void (*PvrQwsSwapFunction)
- (PvrQwsDrawable *drawable, void *userData, int repaintOnly);
-
-/* Open the display and prepare for window operations. The display
- can be opened multiple times and each time is reference counted.
- The display will be finally closed when the same number of
- calls to pvrQwsDisplayClose() have been encountered */
-int pvrQwsDisplayOpen(void);
-
-/* Close the display */
-void pvrQwsDisplayClose(void);
-
-/* Determine if the display is already open */
-int pvrQwsDisplayIsOpen(void);
-
-/* Create a window that represents a particular framebuffer screen.
- Initially the visible region will be the whole screen. If the screen
- window has already been created, then will return the same value */
-PvrQwsDrawable *pvrQwsScreenWindow(int screen);
-
-/* Create a top-level window on a particular framebuffer screen.
- Initially the window will not have a visible region */
-PvrQwsDrawable *pvrQwsCreateWindow(int screen, long winId, const PvrQwsRect *rect);
-
-/* Fetch an existing window for a window id and increase its refcount */
-PvrQwsDrawable *pvrQwsFetchWindow(long winId);
-
-/* Release the refcount on a window. Returns 1 if refcount is zero */
-int pvrQwsReleaseWindow(PvrQwsDrawable *drawable);
-
-/* Create an off-screen pixmap */
-PvrQwsDrawable *pvrQwsCreatePixmap(int width, int height, int screen);
-
-/* Destroy a previously-created drawable. Will not destroy screens. */
-void pvrQwsDestroyDrawable(PvrQwsDrawable *drawable);
-
-/* Get a drawable's type */
-PvrQwsDrawableType pvrQwsGetDrawableType(PvrQwsDrawable *drawable);
-
-/* Sets the visible region for a window or screen drawable. Pixels within
- the specified rectangles will be copied to the framebuffer when the window
- or screen is swapped. The rectangles should be in global co-ordinates */
-void pvrQwsSetVisibleRegion
- (PvrQwsDrawable *drawable, const PvrQwsRect *rects, int numRects);
-
-/* Clear the visible region for a window or screen drawable,
- effectively removing it from the screen */
-void pvrQwsClearVisibleRegion(PvrQwsDrawable *drawable);
-
-/* Set the geometry for a drawable. This can only be used on windows */
-void pvrQwsSetGeometry(PvrQwsDrawable *drawable, const PvrQwsRect *rect);
-
-/* Get the current geometry for a drawable */
-void pvrQwsGetGeometry(PvrQwsDrawable *drawable, PvrQwsRect *rect);
-
-/* Set the rotation angle in degrees */
-void pvrQwsSetRotation(PvrQwsDrawable *drawable, int angle);
-
-/* Get the line stride for a drawable. Returns zero if the buffers
- are not allocated or have been invalidated */
-int pvrQwsGetStride(PvrQwsDrawable *drawable);
-
-/* Get the pixel format for a drawable */
-PvrQwsPixelFormat pvrQwsGetPixelFormat(PvrQwsDrawable *drawable);
-
-/* Get a pointer to the beginning of a drawable's current render buffer.
- Returns null if the buffers are not allocated or have been invalidated */
-void *pvrQwsGetRenderBuffer(PvrQwsDrawable *drawable);
-
-/* Allocate the buffers associated with a drawable. We allocate one buffer
- for pixmaps, and several for windows and screens */
-int pvrQwsAllocBuffers(PvrQwsDrawable *drawable);
-
-/* Free the buffers associated with a drawable */
-void pvrQwsFreeBuffers(PvrQwsDrawable *drawable);
-
-/* Invalidate the buffers associated with a drawable. The buffers will
- still be allocated but the next attempt to swap the buffers will fail */
-void pvrQwsInvalidateBuffers(PvrQwsDrawable *drawable);
-
-/* Swap the back buffers for a window or screen and copy to the framebuffer */
-int pvrQwsSwapBuffers(PvrQwsDrawable *drawable, int repaintOnly);
-
-/* Set the swap function for a drawable. When pvrQwsSwapBuffers()
- is called on the drawable, the supplied function will be called
- instead of copying the drawable contents to the screen. This allows
- higher-level compositors to know when a drawable has changed.
- The swap function can be set to null to return to normal processing */
-void pvrQwsSetSwapFunction
- (PvrQwsDrawable *drawable, PvrQwsSwapFunction func, void *userData);
-
-#ifdef __cplusplus
-};
-#endif
-
-#endif
diff --git a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable_p.h b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable_p.h
deleted file mode 100644
index 3ad0693e02..0000000000
--- a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwsdrawable_p.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef PVRQWSDRAWABLE_P_H
-#define PVRQWSDRAWABLE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// reasons. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <pvr2d.h>
-#include "pvrqwsdrawable.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define PVRQWS_MAX_VISIBLE_RECTS 32
-#define PVRQWS_MAX_SCREENS 1
-#define PVRQWS_MAX_BACK_BUFFERS 2
-#define PVRQWS_MAX_FLIP_BUFFERS 2
-
-typedef struct {
-
- PvrQwsRect screenRect;
- int screenStride;
- PVR2DFORMAT pixelFormat;
- int bytesPerPixel;
- PVR2DMEMINFO *frameBuffer;
- PvrQwsDrawable *screenDrawable;
- void *mapped;
- int mappedLength;
- unsigned long screenStart;
- int needsUnmap;
- int initialized;
-
-} PvrQwsScreenInfo;
-
-typedef struct {
-
- int refCount;
- PvrQwsScreenInfo screens[PVRQWS_MAX_SCREENS];
- PVR2DCONTEXTHANDLE context;
- int numDrawables;
- unsigned long numFlipBuffers;
- PVR2DFLIPCHAINHANDLE flipChain;
- PVR2DMEMINFO *flipBuffers[PVRQWS_MAX_FLIP_BUFFERS];
- int usePresentBlit;
- PvrQwsDrawable *firstWinId;
-
-} PvrQwsDisplay;
-
-extern PvrQwsDisplay pvrQwsDisplay;
-
-struct _PvrQwsDrawable
-{
- PvrQwsDrawableType type;
- long winId;
- int refCount;
- PvrQwsRect rect;
- int screen;
- PVR2DFORMAT pixelFormat;
- PvrQwsRect visibleRects[PVRQWS_MAX_VISIBLE_RECTS];
- int numVisibleRects;
- PVR2DMEMINFO *backBuffers[PVRQWS_MAX_BACK_BUFFERS];
- int currentBackBuffer;
- int backBuffersValid;
- int usingFlipBuffers;
- int isFullScreen;
- int strideBytes;
- int stridePixels;
- int rotationAngle;
- PvrQwsSwapFunction swapFunction;
- void *userData;
- PvrQwsDrawable *nextWinId;
-
-};
-
-/* Get the current source and render buffers for a drawable */
-int pvrQwsGetBuffers
- (PvrQwsDrawable *drawable, PVR2DMEMINFO **source, PVR2DMEMINFO **render);
-
-#ifdef __cplusplus
-};
-#endif
-
-#endif
diff --git a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwswsegl.c b/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwswsegl.c
deleted file mode 100644
index f861838e90..0000000000
--- a/src/plugins/gfxdrivers/powervr/QWSWSEGL/pvrqwswsegl.c
+++ /dev/null
@@ -1,402 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <GLES/eglplatform.h>
-#include <wsegl.h>
-#include <pvr2d.h>
-#include <string.h>
-#include <sys/mman.h>
-#include "pvrqwsdrawable_p.h"
-
-#define WSEGL_UNUSED(x) (void)x;
-
-// If the PVR2D version is not specified, then assume MBX-style headers.
-// If the version is defined, then we assume that we have SGX-style headers.
-#if !defined(PVR2D_REV_MAJOR)
-#define WSEGL_CAP_WINDOWS_USE_HW_SYNC WSEGL_CAP_WINDOWS_USE_MBX_SYNC
-#define WSEGL_CAP_PIXMAPS_USE_HW_SYNC WSEGL_CAP_PIXMAPS_USE_MBX_SYNC
-#endif
-
-/* Capability information for the display */
-static WSEGLCaps const wseglDisplayCaps[] = {
- {WSEGL_CAP_WINDOWS_USE_HW_SYNC, 1},
- {WSEGL_CAP_PIXMAPS_USE_HW_SYNC, 1},
- {WSEGL_NO_CAPS, 0}
-};
-
-/* Configuration information for the display */
-static WSEGLConfig wseglDisplayConfigs[] = {
- {WSEGL_DRAWABLE_WINDOW, WSEGL_PIXELFORMAT_565, WSEGL_FALSE,
- 0, 0, 0, WSEGL_OPAQUE, 0},
- {WSEGL_DRAWABLE_PIXMAP, WSEGL_PIXELFORMAT_565, WSEGL_FALSE,
- 0, 0, 0, WSEGL_OPAQUE, 0},
- {WSEGL_NO_DRAWABLE, 0, 0, 0, 0, 0, 0, 0}
-};
-
-/* Determine if nativeDisplay is a valid display handle */
-static WSEGLError wseglIsDisplayValid(NativeDisplayType nativeDisplay)
-{
- /* We only have the default display in this system */
- if (nativeDisplay == WSEGL_DEFAULT_DISPLAY)
- return WSEGL_SUCCESS;
- else
- return WSEGL_BAD_NATIVE_DISPLAY;
-}
-
-/* Initialize a native display for use with WSEGL */
-static WSEGLError wseglInitializeDisplay
- (NativeDisplayType nativeDisplay, WSEGLDisplayHandle *display,
- const WSEGLCaps **caps, WSEGLConfig **configs)
-{
- WSEGLPixelFormat pixelFormat;
-
- /* Bail out if the native display is incorrect */
- if (nativeDisplay != WSEGL_DEFAULT_DISPLAY)
- return WSEGL_CANNOT_INITIALISE;
-
- /* Open the PVR/QWS display, which will initialize the framebuffer */
- if (!pvrQwsDisplayOpen())
- return WSEGL_CANNOT_INITIALISE;
-
- /* Convert the PVR2D pixel format into a WSEGL pixel format */
- switch (pvrQwsDisplay.screens[0].pixelFormat) {
- case PVR2D_RGB565:
- pixelFormat = WSEGL_PIXELFORMAT_565;
- break;
-
- case PVR2D_ARGB4444:
- pixelFormat = WSEGL_PIXELFORMAT_4444;
- break;
-
- case PVR2D_ARGB8888:
- pixelFormat = WSEGL_PIXELFORMAT_8888;
- break;
-
- default:
- pvrQwsDisplayClose();
- return WSEGL_CANNOT_INITIALISE;
- }
- wseglDisplayConfigs[0].ePixelFormat = pixelFormat;
- wseglDisplayConfigs[1].ePixelFormat = pixelFormat;
-
- /* The display has been initialized */
- *display = (WSEGLDisplayHandle)&pvrQwsDisplay;
- *caps = wseglDisplayCaps;
- *configs = wseglDisplayConfigs;
- return WSEGL_SUCCESS;
-}
-
-/* Close the WSEGL display */
-static WSEGLError wseglCloseDisplay(WSEGLDisplayHandle display)
-{
- if (display == (WSEGLDisplayHandle)&pvrQwsDisplay)
- pvrQwsDisplayClose();
- return WSEGL_SUCCESS;
-}
-
-static WSEGLRotationAngle wseglRotationValue(int degrees)
-{
- switch (degrees) {
- case 90: return WSEGL_ROTATE_90;
- case 180: return WSEGL_ROTATE_180;
- case 270: return WSEGL_ROTATE_270;
- default: return WSEGL_ROTATE_0;
- }
-}
-
-/* Create the WSEGL drawable version of a native window */
-static WSEGLError wseglCreateWindowDrawable
- (WSEGLDisplayHandle display, WSEGLConfig *config,
- WSEGLDrawableHandle *drawable, NativeWindowType nativeWindow,
- WSEGLRotationAngle *rotationAngle)
-{
- PvrQwsDrawable *draw;
-
- WSEGL_UNUSED(display);
- WSEGL_UNUSED(config);
-
- /* Check for special handles that indicate framebuffer screens */
- if (nativeWindow >= (NativeWindowType)0 &&
- nativeWindow < (NativeWindowType)PVRQWS_MAX_SCREENS) {
- PvrQwsDrawable *screen = pvrQwsScreenWindow((int)nativeWindow);
- if (!screen)
- return WSEGL_OUT_OF_MEMORY;
- *drawable = (WSEGLDrawableHandle)screen;
- if (!pvrQwsAllocBuffers(screen))
- return WSEGL_OUT_OF_MEMORY;
- *rotationAngle = wseglRotationValue(screen->rotationAngle);
- return WSEGL_SUCCESS;
- }
-
- /* The native window is the winId - fetch the underlying drawable */
- draw = pvrQwsFetchWindow((long)nativeWindow);
- if (!draw)
- return WSEGL_BAD_DRAWABLE;
-
- /* The drawable is ready to go */
- *drawable = (WSEGLDrawableHandle)draw;
- *rotationAngle = wseglRotationValue(draw->rotationAngle);
- if (!pvrQwsAllocBuffers(draw))
- return WSEGL_OUT_OF_MEMORY;
- return WSEGL_SUCCESS;
-}
-
-/* Create the WSEGL drawable version of a native pixmap */
-static WSEGLError wseglCreatePixmapDrawable
- (WSEGLDisplayHandle display, WSEGLConfig *config,
- WSEGLDrawableHandle *drawable, NativePixmapType nativePixmap,
- WSEGLRotationAngle *rotationAngle)
-{
- WSEGL_UNUSED(display);
- WSEGL_UNUSED(config);
- if (!nativePixmap)
- return WSEGL_BAD_NATIVE_PIXMAP;
- if (!pvrQwsAllocBuffers((PvrQwsDrawable *)nativePixmap))
- return WSEGL_OUT_OF_MEMORY;
- *drawable = (WSEGLDrawableHandle)nativePixmap;
- *rotationAngle = WSEGL_ROTATE_0;
- return WSEGL_SUCCESS;
-}
-
-/* Delete a specific drawable */
-static WSEGLError wseglDeleteDrawable(WSEGLDrawableHandle _drawable)
-{
- PvrQwsDrawable *drawable = (PvrQwsDrawable *)_drawable;
- if (!drawable || drawable->type == PvrQwsScreen)
- return WSEGL_SUCCESS;
- if (pvrQwsDisplay.numFlipBuffers == 0)
- pvrQwsFreeBuffers(drawable);
- if (pvrQwsReleaseWindow(drawable))
- pvrQwsDestroyDrawable(drawable);
- return WSEGL_SUCCESS;
-}
-
-/* Swap the contents of a drawable to the screen */
-static WSEGLError wseglSwapDrawable
- (WSEGLDrawableHandle _drawable, unsigned long data)
-{
- WSEGL_UNUSED(data);
- PvrQwsDrawable *drawable = (PvrQwsDrawable *)_drawable;
- if (drawable->type != PvrQwsPixmap && !pvrQwsSwapBuffers(drawable, 0))
- return WSEGL_BAD_DRAWABLE;
- else
- return WSEGL_SUCCESS;
-}
-
-/* Set the swap interval of a window drawable */
-static WSEGLError wseglSwapControlInterval
- (WSEGLDrawableHandle drawable, unsigned long interval)
-{
- WSEGL_UNUSED(drawable);
- if (pvrQwsDisplay.flipChain) {
- PVR2DSetPresentFlipProperties
- (pvrQwsDisplay.context, pvrQwsDisplay.flipChain,
- PVR2D_PRESENT_PROPERTY_INTERVAL, 0, 0, 0, NULL, interval);
- }
- return WSEGL_SUCCESS;
-}
-
-/* Flush native rendering requests on a drawable */
-static WSEGLError wseglWaitNative
- (WSEGLDrawableHandle drawable, unsigned long engine)
-{
- WSEGL_UNUSED(drawable);
- if (engine == WSEGL_DEFAULT_NATIVE_ENGINE)
- return WSEGL_SUCCESS;
- else
- return WSEGL_BAD_NATIVE_ENGINE;
-}
-
-/* Copy color data from a drawable to a native pixmap */
-static WSEGLError wseglCopyFromDrawable
- (WSEGLDrawableHandle _drawable, NativePixmapType nativePixmap)
-{
- PvrQwsDrawable *drawable = (PvrQwsDrawable *)_drawable;
- PvrQwsDrawable *pixmap = (PvrQwsDrawable *)nativePixmap;
- PVR2DBLTINFO blit;
-
- if (!drawable || !drawable->backBuffersValid)
- return WSEGL_BAD_NATIVE_WINDOW;
- if (!pixmap || !pixmap->backBuffersValid)
- return WSEGL_BAD_NATIVE_PIXMAP;
-
- memset(&blit, 0, sizeof(blit));
-
- blit.CopyCode = PVR2DROPcopy;
- blit.BlitFlags = PVR2D_BLIT_DISABLE_ALL;
-
- blit.pSrcMemInfo = drawable->backBuffers[drawable->currentBackBuffer];
- blit.SrcStride = drawable->strideBytes;
- blit.SrcX = 0;
- blit.SrcY = 0;
- blit.SizeX = drawable->rect.width;
- blit.SizeY = drawable->rect.height;
- blit.SrcFormat = drawable->pixelFormat;
-
- blit.pDstMemInfo = pixmap->backBuffers[pixmap->currentBackBuffer];
- blit.DstStride = pixmap->strideBytes;
- blit.DstX = 0;
- blit.DstY = 0;
- blit.DSizeX = pixmap->rect.width;
- blit.DSizeY = pixmap->rect.height;
- blit.DstFormat = pixmap->pixelFormat;
-
- PVR2DBlt(pvrQwsDisplay.context, &blit);
- PVR2DQueryBlitsComplete
- (pvrQwsDisplay.context, pixmap->backBuffers[pixmap->currentBackBuffer], 1);
-
- return WSEGL_SUCCESS;
-}
-
-/* Copy color data from a PBuffer to a native pixmap */
-static WSEGLError wseglCopyFromPBuffer
- (void *address, unsigned long width, unsigned long height,
- unsigned long stride, WSEGLPixelFormat format,
- NativePixmapType nativePixmap)
-{
- PvrQwsDrawable *pixmap = (PvrQwsDrawable *)nativePixmap;
- PVR2DFORMAT pixelFormat;
-
- if (!pixmap)
- return WSEGL_BAD_NATIVE_PIXMAP;
-
- /* We can only copy under certain conditions */
- switch (format) {
- case WSEGL_PIXELFORMAT_565:
- pixelFormat = PVR2D_RGB565; break;
- case WSEGL_PIXELFORMAT_4444:
- pixelFormat = PVR2D_ARGB4444; break;
- case WSEGL_PIXELFORMAT_8888:
- pixelFormat = PVR2D_ARGB8888; break;
- default:
- return WSEGL_BAD_CONFIG;
- }
- if (width > (unsigned long)(pixmap->rect.width) ||
- height > (unsigned long)(pixmap->rect.height) ||
- pixelFormat != pixmap->pixelFormat) {
- return WSEGL_BAD_CONFIG;
- }
-
- /* We'd like to use PVR2DBlt to do this, but there is no easy way
- to map the virtual "address" into physical space to be able
- to use the hardware assist. Use memcpy to do the work instead.
- Note: PBuffer's are upside down, so we copy from the bottom up */
- char *srcaddr = (char *)address;
- char *dstaddr = (char *)(pixmap->backBuffers[pixmap->currentBackBuffer]->pBase);
- int dststride = pixmap->strideBytes;
- int srcwidth = ((int)width) * pvrQwsDisplay.screens[0].bytesPerPixel;
- srcaddr += height * stride;
- while (height > 0) {
- srcaddr -= (int)stride;
- memcpy(dstaddr, srcaddr, srcwidth);
- dstaddr += dststride;
- --height;
- }
- return WSEGL_SUCCESS;
-}
-
-/* Return the parameters of a drawable that are needed by the EGL layer */
-static WSEGLError wseglGetDrawableParameters
- (WSEGLDrawableHandle _drawable, WSEGLDrawableParams *sourceParams,
- WSEGLDrawableParams *renderParams)
-{
- PvrQwsDrawable *drawable = (PvrQwsDrawable *)_drawable;
- PVR2DMEMINFO *source, *render;
- WSEGLPixelFormat pixelFormat;
-
- if (!pvrQwsGetBuffers(drawable, &source, &render))
- return WSEGL_BAD_DRAWABLE;
-
- switch (drawable->pixelFormat) {
- case PVR2D_RGB565:
- default:
- pixelFormat = WSEGL_PIXELFORMAT_565;
- break;
-
- case PVR2D_ARGB4444:
- pixelFormat = WSEGL_PIXELFORMAT_4444;
- break;
-
- case PVR2D_ARGB8888:
- pixelFormat = WSEGL_PIXELFORMAT_8888;
- break;
- }
-
- sourceParams->ui32Width = drawable->rect.width;
- sourceParams->ui32Height = drawable->rect.height;
- sourceParams->ui32Stride = drawable->stridePixels;
- sourceParams->ePixelFormat = pixelFormat;
- sourceParams->pvLinearAddress = source->pBase;
- sourceParams->ui32HWAddress = source->ui32DevAddr;
- sourceParams->hPrivateData = source->hPrivateData;
-
- renderParams->ui32Width = drawable->rect.width;
- renderParams->ui32Height = drawable->rect.height;
- renderParams->ui32Stride = drawable->stridePixels;
- renderParams->ePixelFormat = pixelFormat;
- renderParams->pvLinearAddress = render->pBase;
- renderParams->ui32HWAddress = render->ui32DevAddr;
- renderParams->hPrivateData = render->hPrivateData;
-
- return WSEGL_SUCCESS;
-}
-
-static WSEGL_FunctionTable const wseglFunctions = {
- WSEGL_VERSION,
- wseglIsDisplayValid,
- wseglInitializeDisplay,
- wseglCloseDisplay,
- wseglCreateWindowDrawable,
- wseglCreatePixmapDrawable,
- wseglDeleteDrawable,
- wseglSwapDrawable,
- wseglSwapControlInterval,
- wseglWaitNative,
- wseglCopyFromDrawable,
- wseglCopyFromPBuffer,
- wseglGetDrawableParameters
-};
-
-/* Return the table of WSEGL functions to the EGL implementation */
-const WSEGL_FunctionTable *WSEGL_GetFunctionTablePointer(void)
-{
- return &wseglFunctions;
-}
diff --git a/src/plugins/gfxdrivers/powervr/README b/src/plugins/gfxdrivers/powervr/README
deleted file mode 100644
index 513e7f5e9e..0000000000
--- a/src/plugins/gfxdrivers/powervr/README
+++ /dev/null
@@ -1,66 +0,0 @@
-PowerVR QScreen Driver
-======================
-
-This QScreen plugin driver allows the QtOpenGl module to integrate with PowerVR
-hardware from Imagination Technologies. Using this plugin, applications may use
-QGLWidget & QGLPixelBuffer with OpenGL ES. The integration with PowerVR drivers
-is built as two libraries: The actual QScreen plugin used by Qt (in the
-pvreglscreen directory) and a WSEGL plugin for the PowerVR drivers (in the
-QWSWSEGL directory).
-
-Qt/Embedded needs to be configured with the QT_QWS_CLIENTBLIT and
-QT_NO_QWS_CURSOR defines.
-
-The PowerVR drivers provide the WSEGL plugin API to allow window systems such as
-QWS to integrate correctly. In order to use the integration, the WSEGL plugin
-(libpvrQWSWSEGL.so, usually installed into the Qt library directory) must be in
-the LD library path. The PowerVR driver also needs to be told which WSEGL library
-to use. This is done by creating/modifying /etc/powervr.ini:
-
-[default]
-WindowSystem=libpvrQWSWSEGL.so
-
-Note: It is important that the /etc/powervr.ini file not contain ^M (Ctrl-M) DOS
-end of line markers at the end of its lines. If ^M markers are present, then the
-libpvrQWSWSEGL.so driver will not be loaded and the default null Linux driver
-will be loaded silently instead. Make sure that the end of line markers are
-strictly Unix-style markers.
-
-
-***************************************************************************
-* IMPORTANT: To build the QScreen plugin and the WSEGL library it depends *
-* on, the pvr2d.h, wsegl.h headers for your platform are required. You *
-* can find a copy of these headers in src/3rdparty/powervr for SGX based *
-* platforms like the TI OMAP3xxx. They probably will not work on MBX *
-* because of differences in the layout of certain PVR2D structures. *
-* You can tell Qt where to find the actual headers for your system by *
-* setting QMAKE_INCDIR_POWERVR in the mkspec. *
-***************************************************************************
-
-When you start a Qt/Embedded application, you should modify the QWS_DISPLAY
-environment variable to use the "powervr" driver instead of "LinuxFb". For
-example, if your original QWS_DISPLAY variable was:
-
- LinuxFb:mmWidth40:mmHeight54:0
-
-then it should be changed to:
-
- powervr:mmWidth40:mmHeight54:0
-
-To test the OpenGL ES integration, you can use the hellogl_es example and run it
-on the device with:
-
- hellogl_es -qws
-
-The driver also supports screen rotation if Qt is configured with the
--qt-gfx-transformed option and the QWS_DISPLAY variable is wrapped in a
-"Transformed" declaration:
-
- Transformed:powervr:mmWidth40:mmHeight54:Rot90:0
-
-Know Issues:
- * A QGLWidget may not have window decorations if it is a top-level window.
- * On some platforms, starting a QWS application after the system has been up
- for a long time may cause the driver to fail. This is due to fragmentation
- of main memory prevening older PowerVR drivers from allocating a contiguous
- region of phyical RAM for the GL surface.
diff --git a/src/plugins/gfxdrivers/powervr/powervr.pri b/src/plugins/gfxdrivers/powervr/powervr.pri
deleted file mode 100644
index 9df8c0ed5b..0000000000
--- a/src/plugins/gfxdrivers/powervr/powervr.pri
+++ /dev/null
@@ -1,2 +0,0 @@
-
-INCLUDEPATH += $$QMAKE_INCDIR_POWERVR
diff --git a/src/plugins/gfxdrivers/powervr/powervr.pro b/src/plugins/gfxdrivers/powervr/powervr.pro
deleted file mode 100644
index f31ad042d8..0000000000
--- a/src/plugins/gfxdrivers/powervr/powervr.pro
+++ /dev/null
@@ -1,3 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS = QWSWSEGL pvreglscreen
-CONFIG += ordered
diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp
deleted file mode 100644
index c981e0d300..0000000000
--- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp
+++ /dev/null
@@ -1,351 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "pvreglscreen.h"
-#include "pvreglwindowsurface.h"
-#include "pvrqwsdrawable_p.h"
-#include <QRegExp>
-#include <qwindowsystem_qws.h>
-#ifndef QT_NO_QWS_TRANSFORMED
-#include <qscreentransformed_qws.h>
-#endif
-#include <sys/stat.h>
-#include <sys/ioctl.h>
-#include <sys/kd.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-//![0]
-PvrEglScreen::PvrEglScreen(int displayId)
- : QGLScreen(displayId)
-{
- setOptions(NativeWindows);
- setSupportsBlitInClients(true);
- setSurfaceFunctions(new PvrEglScreenSurfaceFunctions(this, displayId));
-//![0]
- fd = -1;
- ttyfd = -1;
- doGraphicsMode = true;
- oldKdMode = KD_TEXT;
- parent = 0;
-
- // Make sure that the EGL layer is initialized and the drivers loaded.
- EGLDisplay dpy = eglGetDisplay((EGLNativeDisplayType)EGL_DEFAULT_DISPLAY);
- if (!eglInitialize(dpy, 0, 0))
- qWarning("Could not initialize EGL display - are the drivers loaded?");
-
- // Make sure that screen 0 is initialized.
- pvrQwsScreenWindow(0);
-}
-
-PvrEglScreen::~PvrEglScreen()
-{
- if (fd >= 0)
- ::close(fd);
-}
-
-bool PvrEglScreen::initDevice()
-{
- openTty();
- return true;
-}
-
-bool PvrEglScreen::connect(const QString &displaySpec)
-{
- if (!pvrQwsDisplayOpen())
- return false;
-
- // Initialize the QScreen properties.
- data = (uchar *)(pvrQwsDisplay.screens[0].mapped);
- w = pvrQwsDisplay.screens[0].screenRect.width;
- h = pvrQwsDisplay.screens[0].screenRect.height;
- lstep = pvrQwsDisplay.screens[0].screenStride;
- dw = w;
- dh = h;
- size = h * lstep;
- mapsize = size;
- switch (pvrQwsDisplay.screens[0].pixelFormat) {
- case PVR2D_RGB565:
- d = 16;
- setPixelFormat(QImage::Format_RGB16);
- break;
- case PVR2D_ARGB4444:
- d = 16;
- setPixelFormat(QImage::Format_ARGB4444_Premultiplied);
- break;
- case PVR2D_ARGB8888:
- d = 32;
- setPixelFormat(QImage::Format_ARGB32_Premultiplied);
- break;
- default:
- pvrQwsDisplayClose();
- qWarning("PvrEglScreen::connect: unsupported pixel format %d", (int)(pvrQwsDisplay.screens[0].pixelFormat));
- return false;
- }
-
- // Handle display physical size spec.
- QStringList displayArgs = displaySpec.split(QLatin1Char(':'));
- QRegExp mmWidthRx(QLatin1String("mmWidth=?(\\d+)"));
- int dimIdxW = displayArgs.indexOf(mmWidthRx);
- QRegExp mmHeightRx(QLatin1String("mmHeight=?(\\d+)"));
- int dimIdxH = displayArgs.indexOf(mmHeightRx);
- if (dimIdxW >= 0) {
- mmWidthRx.exactMatch(displayArgs.at(dimIdxW));
- physWidth = mmWidthRx.cap(1).toInt();
- if (dimIdxH < 0)
- physHeight = dh*physWidth/dw;
- }
- if (dimIdxH >= 0) {
- mmHeightRx.exactMatch(displayArgs.at(dimIdxH));
- physHeight = mmHeightRx.cap(1).toInt();
- if (dimIdxW < 0)
- physWidth = dw*physHeight/dh;
- }
- if (dimIdxW < 0 && dimIdxH < 0) {
- const int dpi = 72;
- physWidth = qRound(dw * 25.4 / dpi);
- physHeight = qRound(dh * 25.4 / dpi);
- }
-
- // Find the name of the tty device to use.
- QRegExp ttyRegExp(QLatin1String("tty=(.*)"));
- if (displayArgs.indexOf(ttyRegExp) != -1)
- ttyDevice = ttyRegExp.cap(1);
- if (displayArgs.contains(QLatin1String("nographicsmodeswitch")))
- doGraphicsMode = false;
-
- // The screen is ready.
- return true;
-}
-
-void PvrEglScreen::disconnect()
-{
- pvrQwsDisplayClose();
-}
-
-void PvrEglScreen::shutdownDevice()
-{
- closeTty();
-}
-
-void PvrEglScreen::blit(const QImage &img, const QPoint &topLeft, const QRegion &region)
-{
- QGLScreen::blit(img, topLeft, region);
- sync();
-}
-
-void PvrEglScreen::solidFill(const QColor &color, const QRegion &region)
-{
- QGLScreen::solidFill(color, region);
- sync();
-}
-
-bool PvrEglScreen::chooseContext
- (QGLContext *context, const QGLContext *shareContext)
-{
- // We use PvrEglScreenSurfaceFunctions instead.
- Q_UNUSED(context);
- Q_UNUSED(shareContext);
- return false;
-}
-
-bool PvrEglScreen::hasOpenGL()
-{
- return true;
-}
-
-//![1]
-QWSWindowSurface* PvrEglScreen::createSurface(QWidget *widget) const
-{
- if (qobject_cast<QGLWidget*>(widget))
- return new PvrEglWindowSurface(widget, (PvrEglScreen *)this, displayId);
-
- return QScreen::createSurface(widget);
-}
-
-QWSWindowSurface* PvrEglScreen::createSurface(const QString &key) const
-{
- if (key == QLatin1String("PvrEgl"))
- return new PvrEglWindowSurface();
-
- return QScreen::createSurface(key);
-}
-//![1]
-
-#ifndef QT_NO_QWS_TRANSFORMED
-
-static const QScreen *parentScreen
- (const QScreen *current, const QScreen *lookingFor)
-{
- if (!current)
- return 0;
- switch (current->classId()) {
- case QScreen::ProxyClass:
- case QScreen::TransformedClass: {
- const QScreen *child =
- static_cast<const QProxyScreen *>(current)->screen();
- if (child == lookingFor)
- return current;
- else
- return parentScreen(child, lookingFor);
- }
- // Not reached.
-
- case QScreen::MultiClass: {
- QList<QScreen *> screens = current->subScreens();
- foreach (QScreen *screen, screens) {
- if (screen == lookingFor)
- return current;
- const QScreen *parent = parentScreen(screen, lookingFor);
- if (parent)
- return parent;
- }
- }
- break;
-
- default: break;
- }
- return 0;
-}
-
-int PvrEglScreen::transformation() const
-{
- // We need to search for our parent screen, which is assumed to be
- // "Transformed". If it isn't, then there is no transformation.
- // There is no direct method to get the parent screen so we need
- // to search every screen until we find ourselves.
- if (!parent && qt_screen != this)
- parent = parentScreen(qt_screen, this);
- if (!parent)
- return 0;
- if (parent->classId() != QScreen::TransformedClass)
- return 0;
- return 90 * static_cast<const QTransformedScreen *>(parent)
- ->transformOrientation();
-}
-
-#else
-
-int PvrEglScreen::transformation() const
-{
- return 0;
-}
-
-#endif
-
-void PvrEglScreen::sync()
-{
- // Put code here to synchronize 2D and 3D operations if necessary.
-}
-
-void PvrEglScreen::openTty()
-{
- const char *const devs[] = {"/dev/tty0", "/dev/tty", "/dev/console", 0};
-
- if (ttyDevice.isEmpty()) {
- for (const char * const *dev = devs; *dev; ++dev) {
- ttyfd = ::open(*dev, O_RDWR);
- if (ttyfd != -1)
- break;
- }
- } else {
- ttyfd = ::open(ttyDevice.toAscii().constData(), O_RDWR);
- }
-
- if (ttyfd == -1)
- return;
-
- ::fcntl(ttyfd, F_SETFD, FD_CLOEXEC);
-
- if (doGraphicsMode) {
- ioctl(ttyfd, KDGETMODE, &oldKdMode);
- if (oldKdMode != KD_GRAPHICS) {
- int ret = ioctl(ttyfd, KDSETMODE, KD_GRAPHICS);
- if (ret == -1)
- doGraphicsMode = false;
- }
- }
-
- // No blankin' screen, no blinkin' cursor!, no cursor!
- const char termctl[] = "\033[9;0]\033[?33l\033[?25l\033[?1c";
- ::write(ttyfd, termctl, sizeof(termctl));
-}
-
-void PvrEglScreen::closeTty()
-{
- if (ttyfd == -1)
- return;
-
- if (doGraphicsMode)
- ioctl(ttyfd, KDSETMODE, oldKdMode);
-
- // Blankin' screen, blinkin' cursor!
- const char termctl[] = "\033[9;15]\033[?33h\033[?25h\033[?0c";
- ::write(ttyfd, termctl, sizeof(termctl));
-
- ::close(ttyfd);
- ttyfd = -1;
-}
-
-//![2]
-bool PvrEglScreenSurfaceFunctions::createNativeWindow(QWidget *widget, EGLNativeWindowType *native)
-{
-//![2]
- QWSWindowSurface *surface =
- static_cast<QWSWindowSurface *>(widget->windowSurface());
- if (!surface) {
- // The widget does not have a surface yet, so give it one.
- surface = new PvrEglWindowSurface(widget, screen, displayId);
- widget->setWindowSurface(surface);
- } else if (surface->key() != QLatin1String("PvrEgl")) {
- // The application has attached a QGLContext to an ordinary QWidget.
- // Replace the widget's window surface with a new one that can do GL.
- QRect geometry = widget->frameGeometry();
- geometry.moveTo(widget->mapToGlobal(QPoint(0, 0)));
- surface = new PvrEglWindowSurface(widget, screen, displayId);
- surface->setGeometry(geometry);
- widget->setWindowSurface(surface);
- widget->setAttribute(Qt::WA_NoSystemBackground, true);
- }
- PvrEglWindowSurface *nsurface = static_cast<PvrEglWindowSurface*>(surface);
- *native = (EGLNativeWindowType)(nsurface->nativeDrawable());
- return true;
-}
diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.h b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.h
deleted file mode 100644
index efb2406771..0000000000
--- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef PVREGLSCREEN_H
-#define PVREGLSCREEN_H
-
-#include <QScreen>
-#include <QGLScreen>
-#include "pvrqwsdrawable.h"
-
-class PvrEglScreen;
-
-class PvrEglScreenSurfaceFunctions : public QGLScreenSurfaceFunctions
-{
-public:
- PvrEglScreenSurfaceFunctions(PvrEglScreen *s, int screenNum)
- : screen(s), displayId(screenNum) {}
-
- bool createNativeWindow(QWidget *widget, EGLNativeWindowType *native);
-
-private:
- PvrEglScreen *screen;
- int displayId;
-};
-
-class PvrEglScreen : public QGLScreen
-{
-public:
- PvrEglScreen(int displayId);
- ~PvrEglScreen();
-
- bool initDevice();
- bool connect(const QString &displaySpec);
- void disconnect();
- void shutdownDevice();
- void setMode(int, int, int) {}
-
- void blit(const QImage &img, const QPoint &topLeft, const QRegion &region);
- void solidFill(const QColor &color, const QRegion &region);
-
- bool chooseContext(QGLContext *context, const QGLContext *shareContext);
- bool hasOpenGL();
-
- QWSWindowSurface* createSurface(QWidget *widget) const;
- QWSWindowSurface* createSurface(const QString &key) const;
-
- int transformation() const;
-
-private:
- void sync();
- void openTty();
- void closeTty();
-
- int fd;
- int ttyfd, oldKdMode;
- QString ttyDevice;
- bool doGraphicsMode;
- mutable const QScreen *parent;
-};
-
-#endif
diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.pro b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.pro
deleted file mode 100644
index 2b5212a6b3..0000000000
--- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.pro
+++ /dev/null
@@ -1,27 +0,0 @@
-TEMPLATE = lib
-TARGET = qgfxpvregl
-CONFIG += qt plugin warn_on
-QT += opengl
-
-LIBS += -lpvrQWSWSEGL
-
-DEFINES += QT_QWS_CLIENTBLIT
-
-INCLUDEPATH += ../QWSWSEGL
-
-
-HEADERS = \
- pvreglscreen.h \
- pvreglwindowsurface.h
-
-SOURCES = \
- pvreglscreenplugin.cpp \
- pvreglscreen.cpp \
- pvreglwindowsurface.cpp
-
-DESTDIR = $$QT.gui.plugins/gfxdrivers
-
-target.path = $$[QT_INSTALL_PLUGINS]/gfxdrivers
-INSTALLS += target
-
-include(../powervr.pri) \ No newline at end of file
diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreenplugin.cpp b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreenplugin.cpp
deleted file mode 100644
index 872285e818..0000000000
--- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreenplugin.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "pvreglscreen.h"
-
-#include <QScreenDriverPlugin>
-#include <QStringList>
-
-class PvrEglScreenPlugin : public QScreenDriverPlugin
-{
-public:
- PvrEglScreenPlugin();
-
- QStringList keys() const;
- QScreen *create(const QString&, int displayId);
-};
-
-PvrEglScreenPlugin::PvrEglScreenPlugin()
- : QScreenDriverPlugin()
-{
-}
-
-QStringList PvrEglScreenPlugin::keys() const
-{
- return (QStringList() << "powervr");
-}
-
-QScreen* PvrEglScreenPlugin::create(const QString& driver, int displayId)
-{
- if (driver.toLower() != "powervr")
- return 0;
-
- return new PvrEglScreen(displayId);
-}
-
-Q_EXPORT_PLUGIN2(qgfxpvregl, PvrEglScreenPlugin)
diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp
deleted file mode 100644
index 43648159c8..0000000000
--- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.cpp
+++ /dev/null
@@ -1,273 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "pvreglwindowsurface.h"
-#include "pvreglscreen.h"
-#include <QScreen>
-#include <QDebug>
-#include <QWSDisplay>
-
-PvrEglWindowSurface::PvrEglWindowSurface
- (QWidget *widget, PvrEglScreen *screen, int screenNum)
- : QWSGLWindowSurface(widget)
-{
- setSurfaceFlags(QWSWindowSurface::Opaque);
-
- this->widget = widget;
- this->screen = screen;
- this->pdevice = 0;
-
- QPoint pos = offset(widget);
- QSize size = widget->size();
-
- PvrQwsRect pvrRect;
- pvrRect.x = pos.x();
- pvrRect.y = pos.y();
- pvrRect.width = size.width();
- pvrRect.height = size.height();
- transformRects(&pvrRect, 1);
-
- // Try to recover a previous PvrQwsDrawable object for the widget
- // if there is one. This can happen when a PvrEglWindowSurface
- // is created for a widget, bound to a EGLSurface, and then destroyed.
- // When a new PvrEglWindowSurface is created for the widget, it will
- // pick up the previous PvrQwsDrawable if the EGLSurface has not been
- // destroyed in the meantime.
- drawable = pvrQwsFetchWindow((long)widget);
- if (drawable)
- pvrQwsSetGeometry(drawable, &pvrRect);
- else
- drawable = pvrQwsCreateWindow(screenNum, (long)widget, &pvrRect);
- pvrQwsSetRotation(drawable, screen->transformation());
-}
-
-PvrEglWindowSurface::PvrEglWindowSurface()
- : QWSGLWindowSurface()
-{
- setSurfaceFlags(QWSWindowSurface::Opaque);
- drawable = 0;
- widget = 0;
- screen = 0;
- pdevice = 0;
-}
-
-PvrEglWindowSurface::~PvrEglWindowSurface()
-{
- // Release the PvrQwsDrawable. If it is bound to an EGLSurface,
- // then it will stay around until a new PvrEglWindowSurface is
- // created for the widget. If it is not bound to an EGLSurface,
- // it will be destroyed immediately.
- if (drawable && pvrQwsReleaseWindow(drawable))
- pvrQwsDestroyDrawable(drawable);
-
- delete pdevice;
-}
-
-bool PvrEglWindowSurface::isValid() const
-{
- return (widget != 0);
-}
-
-void PvrEglWindowSurface::setGeometry(const QRect &rect)
-{
- if (drawable) {
- // XXX: adjust for the screen offset.
- PvrQwsRect pvrRect;
- pvrRect.x = rect.x();
- pvrRect.y = rect.y();
- pvrRect.width = rect.width();
- pvrRect.height = rect.height();
- transformRects(&pvrRect, 1);
- pvrQwsSetGeometry(drawable, &pvrRect);
- pvrQwsSetRotation(drawable, screen->transformation());
- }
- QWSGLWindowSurface::setGeometry(rect);
-}
-
-bool PvrEglWindowSurface::move(const QPoint &offset)
-{
- QRect rect = geometry().translated(offset);
- if (drawable) {
- PvrQwsRect pvrRect;
- pvrRect.x = rect.x();
- pvrRect.y = rect.y();
- pvrRect.width = rect.width();
- pvrRect.height = rect.height();
- transformRects(&pvrRect, 1);
- pvrQwsSetGeometry(drawable, &pvrRect);
- pvrQwsSetRotation(drawable, screen->transformation());
- }
- return QWSGLWindowSurface::move(offset);
-}
-
-QByteArray PvrEglWindowSurface::permanentState() const
-{
- // Nothing interesting to pass to the server just yet.
- return QByteArray();
-}
-
-void PvrEglWindowSurface::setPermanentState(const QByteArray &state)
-{
- Q_UNUSED(state);
-}
-
-void PvrEglWindowSurface::flush
- (QWidget *widget, const QRegion &region, const QPoint &offset)
-{
- // The GL paint engine is responsible for the swapBuffers() call.
- // If we were to call the base class's implementation of flush()
- // then it would fetch the image() and manually blit it to the
- // screeen instead of using the fast PVR2D blit.
- Q_UNUSED(widget);
- Q_UNUSED(region);
- Q_UNUSED(offset);
-}
-
-QImage PvrEglWindowSurface::image() const
-{
- if (drawable) {
- PvrQwsRect pvrRect;
- pvrQwsGetGeometry(drawable, &pvrRect);
- void *data = pvrQwsGetRenderBuffer(drawable);
- if (data) {
- return QImage((uchar *)data, pvrRect.width, pvrRect.height,
- pvrQwsGetStride(drawable), screen->pixelFormat());
- }
- }
- return QImage(16, 16, screen->pixelFormat());
-}
-
-QPaintDevice *PvrEglWindowSurface::paintDevice()
-{
- return widget;
-}
-
-void PvrEglWindowSurface::setDirectRegion(const QRegion &r, int id)
-{
- QWSGLWindowSurface::setDirectRegion(r, id);
-
- if (!drawable)
- return;
-
- // Clip the region to the window boundaries in case the child
- // is partially outside the geometry of the parent.
- QWidget *window = widget->window();
- QRegion region = r;
- if (widget != window) {
- QRect rect = window->geometry();
- rect.moveTo(window->mapToGlobal(QPoint(0, 0)));
- region = region.intersect(rect);
- }
-
- if (region.isEmpty()) {
- pvrQwsClearVisibleRegion(drawable);
- } else if (region.rectCount() == 1) {
- QRect rect = region.boundingRect();
- PvrQwsRect pvrRect;
- pvrRect.x = rect.x();
- pvrRect.y = rect.y();
- pvrRect.width = rect.width();
- pvrRect.height = rect.height();
- transformRects(&pvrRect, 1);
- pvrQwsSetVisibleRegion(drawable, &pvrRect, 1);
- pvrQwsSetRotation(drawable, screen->transformation());
- if (!pvrQwsSwapBuffers(drawable, 1))
- screen->solidFill(QColor(0, 0, 0), region);
- } else {
- QVector<QRect> rects = region.rects();
- PvrQwsRect *pvrRects = new PvrQwsRect [rects.size()];
- for (int index = 0; index < rects.size(); ++index) {
- QRect rect = rects[index];
- pvrRects[index].x = rect.x();
- pvrRects[index].y = rect.y();
- pvrRects[index].width = rect.width();
- pvrRects[index].height = rect.height();
- }
- transformRects(pvrRects, rects.size());
- pvrQwsSetVisibleRegion(drawable, pvrRects, rects.size());
- pvrQwsSetRotation(drawable, screen->transformation());
- if (!pvrQwsSwapBuffers(drawable, 1))
- screen->solidFill(QColor(0, 0, 0), region);
- delete [] pvrRects;
- }
-}
-
-void PvrEglWindowSurface::transformRects(PvrQwsRect *rects, int count) const
-{
- switch (screen->transformation()) {
- case 0: break;
-
- case 90:
- {
- for (int index = 0; index < count; ++index) {
- int x = rects[index].y;
- int y = screen->height() - (rects[index].x + rects[index].width);
- rects[index].x = x;
- rects[index].y = y;
- qSwap(rects[index].width, rects[index].height);
- }
- }
- break;
-
- case 180:
- {
- for (int index = 0; index < count; ++index) {
- int x = screen->width() - (rects[index].x + rects[index].width);
- int y = screen->height() - (rects[index].y + rects[index].height);
- rects[index].x = x;
- rects[index].y = y;
- }
- }
- break;
-
- case 270:
- {
- for (int index = 0; index < count; ++index) {
- int x = screen->width() - (rects[index].y + rects[index].height);
- int y = rects[index].x;
- rects[index].x = x;
- rects[index].y = y;
- qSwap(rects[index].width, rects[index].height);
- }
- }
- break;
- }
-}
diff --git a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.h b/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.h
deleted file mode 100644
index 9f5600c136..0000000000
--- a/src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglwindowsurface.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef PVREGLWINDOWSURFACE_H
-#define PVREGLWINDOWSURFACE_H
-
-#include <private/qglwindowsurface_qws_p.h>
-#include "pvrqwsdrawable.h"
-
-class PvrEglScreen;
-
-class PvrEglWindowSurface : public QWSGLWindowSurface
-{
-public:
- PvrEglWindowSurface(QWidget *widget, PvrEglScreen *screen, int screenNum);
- PvrEglWindowSurface();
- ~PvrEglWindowSurface();
-
- QString key() const { return QLatin1String("PvrEgl"); }
-
- bool isValid() const;
-
- void setGeometry(const QRect &rect);
- bool move(const QPoint &offset);
-
- QByteArray permanentState() const;
- void setPermanentState(const QByteArray &state);
-
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
-
- QImage image() const;
- QPaintDevice *paintDevice();
-
- void setDirectRegion(const QRegion &region, int id);
-
- long nativeDrawable() const { return (long)widget; }
-
-private:
- QWidget *widget;
- PvrQwsDrawable *drawable;
- PvrEglScreen *screen;
- QPaintDevice *pdevice;
-
- void transformRects(PvrQwsRect *rects, int count) const;
-};
-
-#endif
diff --git a/src/plugins/gfxdrivers/qvfb/main.cpp b/src/plugins/gfxdrivers/qvfb/main.cpp
deleted file mode 100644
index fb275818b9..0000000000
--- a/src/plugins/gfxdrivers/qvfb/main.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qscreendriverplugin_qws.h>
-#include <qscreenvfb_qws.h>
-#include <qstringlist.h>
-
-#ifndef QT_NO_LIBRARY
-QT_BEGIN_NAMESPACE
-
-class ScreenVfbDriver : public QScreenDriverPlugin
-{
-public:
- ScreenVfbDriver();
-
- QStringList keys() const;
- QScreen *create(const QString&, int displayId);
-};
-
-ScreenVfbDriver::ScreenVfbDriver()
-: QScreenDriverPlugin()
-{
-}
-
-QStringList ScreenVfbDriver::keys() const
-{
- QStringList list;
- list << "QVFb";
- return list;
-}
-
-QScreen* ScreenVfbDriver::create(const QString& driver, int displayId)
-{
- if (driver.toLower() == "qvfb")
- return new QVFbScreen(displayId);
-
- return 0;
-}
-
-Q_EXPORT_STATIC_PLUGIN(ScreenVfbDriver)
-Q_EXPORT_PLUGIN2(qscreenvfb, ScreenVfbDriver)
-
-QT_END_NAMESPACE
-#endif //QT_NO_LIBRARY
diff --git a/src/plugins/gfxdrivers/qvfb/qvfb.pro b/src/plugins/gfxdrivers/qvfb/qvfb.pro
deleted file mode 100644
index e45319db87..0000000000
--- a/src/plugins/gfxdrivers/qvfb/qvfb.pro
+++ /dev/null
@@ -1,19 +0,0 @@
-TARGET = qscreenvfb
-include(../../qpluginbase.pri)
-
-DEFINES += QT_QWS_QVFB QT_QWS_MOUSE_QVFB QT_QWS_KBD_QVFB
-
-DESTDIR = $$QT.gui.plugins/gfxdrivers
-
-HEADERS = \
- $$QT_SOURCE_TREE/src/gui/embedded/qscreenvfb_qws.h \
- $$QT_SOURCE_TREE/src/gui/embedded/qkbdvfb_qws.h \
- $$QT_SOURCE_TREE/src/gui/embedded/qmousevfb_qws.h
-
-SOURCES = main.cpp \
- $$QT_SOURCE_TREE/src/gui/embedded/qscreenvfb_qws.cpp \
- $$QT_SOURCE_TREE/src/gui/embedded/qkbdvfb_qws.cpp \
- $$QT_SOURCE_TREE/src/gui/embedded/qmousevfb_qws.cpp
-
-target.path += $$[QT_INSTALL_PLUGINS]/gfxdrivers
-INSTALLS += target
diff --git a/src/plugins/gfxdrivers/transformed/main.cpp b/src/plugins/gfxdrivers/transformed/main.cpp
deleted file mode 100644
index da619bb3e5..0000000000
--- a/src/plugins/gfxdrivers/transformed/main.cpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qscreendriverplugin_qws.h>
-#include <qscreentransformed_qws.h>
-#include <qstringlist.h>
-#ifndef QT_NO_LIBRARY
-QT_BEGIN_NAMESPACE
-
-class GfxTransformedDriver : public QScreenDriverPlugin
-{
-public:
- GfxTransformedDriver();
-
- QStringList keys() const;
- QScreen *create(const QString&, int displayId);
-};
-
-GfxTransformedDriver::GfxTransformedDriver()
-: QScreenDriverPlugin()
-{
-}
-
-QStringList GfxTransformedDriver::keys() const
-{
- QStringList list;
- list << "Transformed";
- return list;
-}
-
-QScreen* GfxTransformedDriver::create(const QString& driver, int displayId)
-{
-#ifndef QT_NO_QWS_TRANSFORMED
- if (driver.toLower() == "transformed")
- return new QTransformedScreen(displayId);
-#else //QT_NO_QWS_TRANSFORMED
- printf("QT buildt with QT_NO_QWS_TRANSFORMED. No screen driver returned\n");
-#endif //QT_NO_QWS_TRANSFORMED
- return 0;
-}
-
-Q_EXPORT_STATIC_PLUGIN(GfxTransformedDriver)
-Q_EXPORT_PLUGIN2(qgfxtransformed, GfxTransformedDriver)
-
-QT_END_NAMESPACE
-#endif //QT_NO_LIBRARY
diff --git a/src/plugins/gfxdrivers/transformed/transformed.pro b/src/plugins/gfxdrivers/transformed/transformed.pro
deleted file mode 100644
index f6e07704b3..0000000000
--- a/src/plugins/gfxdrivers/transformed/transformed.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TARGET = qgfxtransformed
-include(../../qpluginbase.pri)
-
-DEFINES += QT_QWS_TRANSFORMED
-
-DESTDIR = $$QT.gui.plugins/gfxdrivers
-
-HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qscreentransformed_qws.h
-SOURCES = main.cpp \
- $$QT_SOURCE_TREE/src/gui/embedded/qscreentransformed_qws.cpp
-
-target.path=$$[QT_INSTALL_PLUGINS]/gfxdrivers
-INSTALLS += target
diff --git a/src/plugins/gfxdrivers/vnc/main.cpp b/src/plugins/gfxdrivers/vnc/main.cpp
deleted file mode 100644
index 65c6cf25c6..0000000000
--- a/src/plugins/gfxdrivers/vnc/main.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qscreendriverplugin_qws.h>
-#include <qscreenvnc_qws.h>
-#include <qstringlist.h>
-
-#ifndef QT_NO_LIBRARY
-QT_BEGIN_NAMESPACE
-
-class GfxVncDriver : public QScreenDriverPlugin
-{
-public:
- GfxVncDriver();
-
- QStringList keys() const;
- QScreen *create(const QString&, int displayId);
-};
-
-GfxVncDriver::GfxVncDriver()
-: QScreenDriverPlugin()
-{
-}
-
-QStringList GfxVncDriver::keys() const
-{
- QStringList list;
- list << "VNC";
- return list;
-}
-
-QScreen* GfxVncDriver::create(const QString& driver, int displayId)
-{
-#ifndef QT_NO_QWS_VNC
- if (driver.toLower() == "vnc")
- return new QVNCScreen(displayId);
-#else //QT_NO_QWS_VNC
- printf("QT buildt with QT_NO_QWS_VNC. No screen driver returned\n");
-#endif //QT_NO_QWS_VNC
- return 0;
-}
-
-Q_EXPORT_STATIC_PLUGIN(GfxVncDriver)
-Q_EXPORT_PLUGIN2(qgfxvnc, GfxVncDriver)
-
-QT_END_NAMESPACE
-
-#endif //QT_NO_LIBRARY
diff --git a/src/plugins/gfxdrivers/vnc/qscreenvnc_p.h b/src/plugins/gfxdrivers/vnc/qscreenvnc_p.h
deleted file mode 100644
index 9a02072815..0000000000
--- a/src/plugins/gfxdrivers/vnc/qscreenvnc_p.h
+++ /dev/null
@@ -1,524 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSCREENVNC_P_H
-#define QSCREENVNC_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QLibrary class. This header file may change from version to version
-// without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include "qscreenvnc_qws.h"
-
-#ifndef QT_NO_QWS_VNC
-
-#include <QtCore/qvarlengtharray.h>
-#include <QtCore/qsharedmemory.h>
-#include <QtNetwork/qtcpsocket.h>
-#include <QtNetwork/qtcpserver.h>
-
-QT_BEGIN_NAMESPACE
-
-class QVNCServer;
-
-#ifndef QT_NO_QWS_CURSOR
-class QVNCCursor : public QProxyScreenCursor
-{
-public:
- QVNCCursor(QVNCScreen *s);
- ~QVNCCursor();
-
- void hide();
- void show();
- void set(const QImage &image, int hotx, int hoty);
- void move(int x, int y);
-
-private:
- void setDirty(const QRect &r) const;
- QVNCScreen *screen;
-};
-
-class QVNCClientCursor : public QProxyScreenCursor
-{
-public:
- QVNCClientCursor(QVNCServer *s);
- ~QVNCClientCursor();
-
- void set(const QImage &image, int hotx, int hoty);
- void write() const;
-
-private:
- QVNCServer *server;
-};
-#endif // QT_NO_QWS_CURSOR
-
-#define MAP_TILE_SIZE 16
-#define MAP_WIDTH 1280 / MAP_TILE_SIZE
-#define MAP_HEIGHT 1024 / MAP_TILE_SIZE
-
-class QVNCDirtyMap
-{
-public:
- QVNCDirtyMap(QScreen *screen);
- virtual ~QVNCDirtyMap();
-
- void reset();
- bool dirty(int x, int y) const;
- virtual void setDirty(int x, int y, bool force = false) = 0;
- void setClean(int x, int y);
-
- int bytesPerPixel;
-
- int numDirty;
- int mapWidth;
- int mapHeight;
-
-protected:
- uchar *map;
- QScreen *screen;
- uchar *buffer;
- int bufferWidth;
- int bufferHeight;
- int bufferStride;
- int numTiles;
-};
-
-template <class T>
-class QVNCDirtyMapOptimized : public QVNCDirtyMap
-{
-public:
- QVNCDirtyMapOptimized(QScreen *screen) : QVNCDirtyMap(screen) {}
- ~QVNCDirtyMapOptimized() {}
-
- void setDirty(int x, int y, bool force = false);
-};
-
-class QRfbRect
-{
-public:
- QRfbRect() {}
- QRfbRect(quint16 _x, quint16 _y, quint16 _w, quint16 _h) {
- x = _x; y = _y; w = _w; h = _h;
- }
-
- void read(QTcpSocket *s);
- void write(QTcpSocket *s) const;
-
- quint16 x;
- quint16 y;
- quint16 w;
- quint16 h;
-};
-
-class QRfbPixelFormat
-{
-public:
- static int size() { return 16; }
-
- void read(QTcpSocket *s);
- void write(QTcpSocket *s);
-
- int bitsPerPixel;
- int depth;
- bool bigEndian;
- bool trueColor;
- int redBits;
- int greenBits;
- int blueBits;
- int redShift;
- int greenShift;
- int blueShift;
-};
-
-class QRfbServerInit
-{
-public:
- QRfbServerInit() { name = 0; }
- ~QRfbServerInit() { delete[] name; }
-
- int size() const { return QRfbPixelFormat::size() + 8 + strlen(name); }
- void setName(const char *n);
-
- void read(QTcpSocket *s);
- void write(QTcpSocket *s);
-
- quint16 width;
- quint16 height;
- QRfbPixelFormat format;
- char *name;
-};
-
-class QRfbSetEncodings
-{
-public:
- bool read(QTcpSocket *s);
-
- quint16 count;
-};
-
-class QRfbFrameBufferUpdateRequest
-{
-public:
- bool read(QTcpSocket *s);
-
- char incremental;
- QRfbRect rect;
-};
-
-class QRfbKeyEvent
-{
-public:
- bool read(QTcpSocket *s);
-
- char down;
- int keycode;
- int unicode;
-};
-
-class QRfbPointerEvent
-{
-public:
- bool read(QTcpSocket *s);
-
- uint buttons;
- quint16 x;
- quint16 y;
-};
-
-class QRfbClientCutText
-{
-public:
- bool read(QTcpSocket *s);
-
- quint32 length;
-};
-
-class QVNCScreenPrivate : public QObject
-{
-public:
- QVNCScreenPrivate(QVNCScreen *parent);
- ~QVNCScreenPrivate();
-
- void setDirty(const QRect &rect, bool force = false);
- void configure();
-
- qreal dpiX;
- qreal dpiY;
- bool doOnScreenSurface;
- QVNCDirtyMap *dirty;
- int refreshRate;
- QVNCServer *vncServer;
-
-#if !defined(QT_NO_QWS_MULTIPROCESS) && !defined(QT_NO_SHAREDMEMORY)
- QSharedMemory shm;
-#endif
-
- QVNCScreen *q_ptr;
-
- bool noDisablePainting;
-};
-
-class QRfbEncoder
-{
-public:
- QRfbEncoder(QVNCServer *s) : server(s) {}
- virtual ~QRfbEncoder() {}
-
- virtual void write() = 0;
-
-protected:
- QVNCServer *server;
-};
-
-class QRfbRawEncoder : public QRfbEncoder
-{
-public:
- QRfbRawEncoder(QVNCServer *s) : QRfbEncoder(s) {}
-
- void write();
-
-private:
- QByteArray buffer;
-};
-
-template <class SRC> class QRfbHextileEncoder;
-
-template <class SRC>
-class QRfbSingleColorHextile
-{
-public:
- QRfbSingleColorHextile(QRfbHextileEncoder<SRC> *e) : encoder(e) {}
- bool read(const uchar *data, int width, int height, int stride);
- void write(QTcpSocket *socket) const;
-
-private:
- QRfbHextileEncoder<SRC> *encoder;
-};
-
-template <class SRC>
-class QRfbDualColorHextile
-{
-public:
- QRfbDualColorHextile(QRfbHextileEncoder<SRC> *e) : encoder(e) {}
- bool read(const uchar *data, int width, int height, int stride);
- void write(QTcpSocket *socket) const;
-
-private:
- struct Rect {
- quint8 xy;
- quint8 wh;
- } Q_PACKED rects[8 * 16];
-
- quint8 numRects;
- QRfbHextileEncoder<SRC> *encoder;
-
-private:
- inline int lastx() const { return rectx(numRects); }
- inline int lasty() const { return recty(numRects); }
- inline int rectx(int r) const { return rects[r].xy >> 4; }
- inline int recty(int r) const { return rects[r].xy & 0x0f; }
- inline int width(int r) const { return (rects[r].wh >> 4) + 1; }
- inline int height(int r) const { return (rects[r].wh & 0x0f) + 1; }
-
- inline void setX(int r, int x) {
- rects[r].xy = (x << 4) | (rects[r].xy & 0x0f);
- }
- inline void setY(int r, int y) {
- rects[r].xy = (rects[r].xy & 0xf0) | y;
- }
- inline void setWidth(int r, int width) {
- rects[r].wh = ((width - 1) << 4) | (rects[r].wh & 0x0f);
- }
- inline void setHeight(int r, int height) {
- rects[r].wh = (rects[r].wh & 0xf0) | (height - 1);
- }
-
- inline void setWidth(int width) { setWidth(numRects, width); }
- inline void setHeight(int height) { setHeight(numRects, height); }
- inline void setX(int x) { setX(numRects, x); }
- inline void setY(int y) { setY(numRects, y); }
- void next();
-};
-
-template <class SRC>
-class QRfbMultiColorHextile
-{
-public:
- QRfbMultiColorHextile(QRfbHextileEncoder<SRC> *e) : encoder(e) {}
- bool read(const uchar *data, int width, int height, int stride);
- void write(QTcpSocket *socket) const;
-
-private:
- inline quint8* rect(int r) {
- return rects.data() + r * (bpp + 2);
- }
- inline const quint8* rect(int r) const {
- return rects.constData() + r * (bpp + 2);
- }
- inline void setX(int r, int x) {
- quint8 *ptr = rect(r) + bpp;
- *ptr = (x << 4) | (*ptr & 0x0f);
- }
- inline void setY(int r, int y) {
- quint8 *ptr = rect(r) + bpp;
- *ptr = (*ptr & 0xf0) | y;
- }
- void setColor(SRC color);
- inline int rectx(int r) const {
- const quint8 *ptr = rect(r) + bpp;
- return *ptr >> 4;
- }
- inline int recty(int r) const {
- const quint8 *ptr = rect(r) + bpp;
- return *ptr & 0x0f;
- }
- inline void setWidth(int r, int width) {
- quint8 *ptr = rect(r) + bpp + 1;
- *ptr = ((width - 1) << 4) | (*ptr & 0x0f);
- }
- inline void setHeight(int r, int height) {
- quint8 *ptr = rect(r) + bpp + 1;
- *ptr = (*ptr & 0xf0) | (height - 1);
- }
-
- bool beginRect();
- void endRect();
-
- static const int maxRectsSize = 16 * 16;
- QVarLengthArray<quint8, maxRectsSize> rects;
-
- quint8 bpp;
- quint8 numRects;
- QRfbHextileEncoder<SRC> *encoder;
-};
-
-template <class SRC>
-class QRfbHextileEncoder : public QRfbEncoder
-{
-public:
- QRfbHextileEncoder(QVNCServer *s);
- void write();
-
-private:
- enum SubEncoding {
- Raw = 1,
- BackgroundSpecified = 2,
- ForegroundSpecified = 4,
- AnySubrects = 8,
- SubrectsColoured = 16
- };
-
- QByteArray buffer;
- QRfbSingleColorHextile<SRC> singleColorHextile;
- QRfbDualColorHextile<SRC> dualColorHextile;
- QRfbMultiColorHextile<SRC> multiColorHextile;
-
- SRC bg;
- SRC fg;
- bool newBg;
- bool newFg;
-
- friend class QRfbSingleColorHextile<SRC>;
- friend class QRfbDualColorHextile<SRC>;
- friend class QRfbMultiColorHextile<SRC>;
-};
-
-class QVNCServer : public QObject
-{
- Q_OBJECT
-public:
- QVNCServer(QVNCScreen *screen);
- QVNCServer(QVNCScreen *screen, int id);
- ~QVNCServer();
-
- void setDirty();
- void setDirtyCursor() { dirtyCursor = true; setDirty(); }
- inline bool isConnected() const { return state == Connected; }
- inline void setRefreshRate(int rate) { refreshRate = rate; }
-
- enum ClientMsg { SetPixelFormat = 0,
- FixColourMapEntries = 1,
- SetEncodings = 2,
- FramebufferUpdateRequest = 3,
- KeyEvent = 4,
- PointerEvent = 5,
- ClientCutText = 6 };
-
- enum ServerMsg { FramebufferUpdate = 0,
- SetColourMapEntries = 1 };
-
- void convertPixels(char *dst, const char *src, int count) const;
-
- inline int clientBytesPerPixel() const {
- return pixelFormat.bitsPerPixel / 8;
- }
-
- inline QVNCScreen* screen() const { return qvnc_screen; }
- inline QVNCDirtyMap* dirtyMap() const { return qvnc_screen->d_ptr->dirty; }
- inline QTcpSocket* clientSocket() const { return client; }
- QImage screenImage() const;
- inline bool doPixelConversion() const { return needConversion; }
-#ifndef QT_NO_QWS_CURSOR
- inline bool hasClientCursor() const { return qvnc_cursor != 0; }
-#endif
-
-private:
- void setPixelFormat();
- void setEncodings();
- void frameBufferUpdateRequest();
- void pointerEvent();
- void keyEvent();
- void clientCutText();
- bool pixelConversionNeeded() const;
-
-private slots:
- void newConnection();
- void readClient();
- void checkUpdate();
- void discardClient();
-
-private:
- void init(uint port);
- enum ClientState { Unconnected, Protocol, Init, Connected };
- QTimer *timer;
- QTcpServer *serverSocket;
- QTcpSocket *client;
- ClientState state;
- quint8 msgType;
- bool handleMsg;
- QRfbPixelFormat pixelFormat;
- Qt::KeyboardModifiers keymod;
- int encodingsPending;
- int cutTextPending;
- uint supportCopyRect : 1;
- uint supportRRE : 1;
- uint supportCoRRE : 1;
- uint supportHextile : 1;
- uint supportZRLE : 1;
- uint supportCursor : 1;
- uint supportDesktopSize : 1;
- bool wantUpdate;
- bool sameEndian;
- bool needConversion;
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- bool swapBytes;
-#endif
- bool dirtyCursor;
- int refreshRate;
- QVNCScreen *qvnc_screen;
-#ifndef QT_NO_QWS_CURSOR
- QVNCClientCursor *qvnc_cursor;
-#endif
-
- QRfbEncoder *encoder;
-};
-
-
-QT_END_NAMESPACE
-#endif // QT_NO_QWS_VNC
-#endif // QSCREENVNC_P_H
diff --git a/src/plugins/gfxdrivers/vnc/qscreenvnc_qws.cpp b/src/plugins/gfxdrivers/vnc/qscreenvnc_qws.cpp
deleted file mode 100644
index 63e06659aa..0000000000
--- a/src/plugins/gfxdrivers/vnc/qscreenvnc_qws.cpp
+++ /dev/null
@@ -1,2338 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qscreenvnc_qws.h"
-
-#ifndef QT_NO_QWS_VNC
-
-#include "qscreenvnc_p.h"
-#include "qwindowsystem_qws.h"
-#include "qwsdisplay_qws.h"
-#include "qscreendriverfactory_qws.h"
-#include <QtCore/qtimer.h>
-#include <QtCore/qregexp.h>
-#include <QtGui/qwidget.h>
-#include <QtGui/qpolygon.h>
-#include <QtGui/qpainter.h>
-#include <qdebug.h>
-#include <private/qwindowsurface_qws_p.h>
-#include <private/qwssignalhandler_p.h>
-#include <private/qwidget_p.h>
-#include <private/qdrawhelper_p.h>
-
-#include <stdlib.h>
-
-QT_BEGIN_NAMESPACE
-
-//#define QT_QWS_VNC_DEBUG
-
-extern QString qws_qtePipeFilename();
-
-#ifndef QT_NO_QWS_CURSOR
-
-QVNCCursor::QVNCCursor(QVNCScreen *s)
- : screen(s)
-{
- if (qt_screencursor)
- setScreenCursor(qt_screencursor);
- else
- hwaccel = true;
-}
-
-QVNCCursor::~QVNCCursor()
-{
- if (screenCursor())
- qt_screencursor = screenCursor();
-}
-
-void QVNCCursor::setDirty(const QRect &r) const
-{
- screen->d_ptr->setDirty(r, true);
-}
-
-void QVNCCursor::hide()
-{
- QProxyScreenCursor::hide();
- if (enable)
- setDirty(boundingRect());
-}
-
-void QVNCCursor::show()
-{
- QProxyScreenCursor::show();
- if (enable)
- setDirty(boundingRect());
-}
-
-void QVNCCursor::set(const QImage &image, int hotx, int hoty)
-{
- QRegion dirty = boundingRect();
- QProxyScreenCursor::set(image, hotx, hoty);
- dirty |= boundingRect();
- if (enable && hwaccel && !screen->d_ptr->vncServer->hasClientCursor()) {
- const QVector<QRect> rects = dirty.rects();
- for (int i = 0; i < rects.size(); ++i)
- setDirty(rects.at(i));
- }
-}
-
-void QVNCCursor::move(int x, int y)
-{
- if (enable && hwaccel && !screen->d_ptr->vncServer->hasClientCursor()) {
- QRegion dirty = boundingRect();
- QProxyScreenCursor::move(x, y);
- dirty |= boundingRect();
- if (enable) {
- const QVector<QRect> rects = dirty.rects();
- for (int i = 0; i < rects.size(); ++i)
- setDirty(rects.at(i));
- }
- } else {
- QProxyScreenCursor::move(x, y);
- }
-}
-
-QVNCClientCursor::QVNCClientCursor(QVNCServer *s)
- : server(s)
-{
- setScreenCursor(qt_screencursor);
- Q_ASSERT(hwaccel);
- qt_screencursor = this; // hw: XXX
-
- set(image(), hotspot.x(), hotspot.y());
-}
-
-QVNCClientCursor::~QVNCClientCursor()
-{
- qt_screencursor = screenCursor();
-}
-
-void QVNCClientCursor::set(const QImage &image, int hotx, int hoty)
-{
- QScreenCursor::set(image, hotx, hoty);
- server->setDirtyCursor();
-}
-
-void QVNCClientCursor::write() const
-{
- QTcpSocket *socket = server->clientSocket();
-
- // FramebufferUpdate header
- {
- const quint16 tmp[6] = { htons(0),
- htons(1),
- htons(hotspot.x()), htons(hotspot.y()),
- htons(cursor.width()),
- htons(cursor.height()) };
- socket->write((char*)tmp, sizeof(tmp));
-
- const quint32 encoding = htonl(-239);
- socket->write((char*)(&encoding), sizeof(encoding));
- }
-
- if (cursor.isNull())
- return;
-
- // write pixels
- Q_ASSERT(cursor.hasAlphaChannel());
- const QImage img = cursor.convertToFormat(server->screen()->pixelFormat());
- const int n = server->clientBytesPerPixel() * img.width();
- char *buffer = new char[n];
- for (int i = 0; i < img.height(); ++i) {
- server->convertPixels(buffer, (const char*)img.scanLine(i), img.width());
- socket->write(buffer, n);
- }
- delete[] buffer;
-
- // write mask
- const QImage bitmap = cursor.createAlphaMask().convertToFormat(QImage::Format_Mono);
- Q_ASSERT(bitmap.depth() == 1);
- Q_ASSERT(bitmap.size() == img.size());
- const int width = (bitmap.width() + 7) / 8;
- for (int i = 0; i < bitmap.height(); ++i)
- socket->write((const char*)bitmap.scanLine(i), width);
-}
-
-#endif // QT_NO_QWS_CURSOR
-
-QVNCScreenPrivate::QVNCScreenPrivate(QVNCScreen *parent)
- : dpiX(72), dpiY(72), doOnScreenSurface(false), refreshRate(25),
- vncServer(0), q_ptr(parent), noDisablePainting(false)
-{
-#ifdef QT_BUILD_INTERNAL
- noDisablePainting = (qgetenv("QT_VNC_NO_DISABLEPAINTING").toInt() > 0);
-#endif
-#ifndef QT_NO_QWS_SIGNALHANDLER
- QWSSignalHandler::instance()->addObject(this);
-#endif
-}
-
-QVNCScreenPrivate::~QVNCScreenPrivate()
-{
-#if defined(QT_NO_QWS_MULTIPROCESS) || defined(QT_NO_SHAREDMEMORY)
- if (q_ptr->screen())
- return;
-
- delete[] q_ptr->data;
- q_ptr->data = 0;
-#else
- shm.detach();
-#endif
-}
-
-void QVNCScreenPrivate::configure()
-{
- if (q_ptr->screen())
- return;
-
- q_ptr->lstep = q_ptr->dw * ((q_ptr->d + 7) / 8);
- q_ptr->size = q_ptr->h * q_ptr->lstep;
- q_ptr->mapsize = q_ptr->size;
- q_ptr->physWidth = qRound(q_ptr->dw * qreal(25.4) / dpiX);
- q_ptr->physHeight = qRound(q_ptr->dh * qreal(25.4) / dpiY);
-
- switch (q_ptr->d) {
- case 1:
- q_ptr->setPixelFormat(QImage::Format_Mono); //### LSB???
- break;
- case 8:
- q_ptr->setPixelFormat(QImage::Format_Indexed8);
- break;
- case 12:
- q_ptr->setPixelFormat(QImage::Format_RGB444);
- break;
- case 15:
- q_ptr->setPixelFormat(QImage::Format_RGB555);
- break;
- case 16:
- q_ptr->setPixelFormat(QImage::Format_RGB16);
- break;
- case 18:
- q_ptr->setPixelFormat(QImage::Format_RGB666);
- break;
- case 24:
- q_ptr->setPixelFormat(QImage::Format_RGB888);
- break;
- case 32:
- q_ptr->setPixelFormat(QImage::Format_ARGB32_Premultiplied);
- break;
- }
-
-#if !defined(QT_NO_QWS_MULTIPROCESS) && !defined(QT_NO_SHAREDMEMORY)
- if (q_ptr->size != shm.size()) {
- shm.detach();
- const QString key = qws_qtePipeFilename() +
- QString().sprintf("_vnc_%d_%d",
- q_ptr->displayId, q_ptr->size);
- shm.setKey(key);
- if (QApplication::type() == QApplication::GuiServer) {
- if (!shm.create(q_ptr->size)) {
- qWarning() << "QVNCScreen could not create shared memory:"
- << shm.errorString();
- if (!shm.attach()) {
- qWarning() << "QVNCScreen could not attach to shared memory:"
- << shm.errorString();
- }
- }
- } else if (!shm.attach()) {
- qWarning() << "QVNCScreen could not attach to shared memory:"
- << shm.errorString();
- }
- q_ptr->data = reinterpret_cast<uchar*>(shm.data());
- }
-#else
- if (q_ptr->data)
- delete[] q_ptr->data;
- q_ptr->data = new uchar[q_ptr->size];
-#endif
-}
-
-//===========================================================================
-
-static const struct {
- int keysym;
- int keycode;
-} keyMap[] = {
- { 0xff08, Qt::Key_Backspace },
- { 0xff09, Qt::Key_Tab },
- { 0xff0d, Qt::Key_Return },
- { 0xff1b, Qt::Key_Escape },
- { 0xff63, Qt::Key_Insert },
- { 0xffff, Qt::Key_Delete },
- { 0xff50, Qt::Key_Home },
- { 0xff57, Qt::Key_End },
- { 0xff55, Qt::Key_PageUp },
- { 0xff56, Qt::Key_PageDown },
- { 0xff51, Qt::Key_Left },
- { 0xff52, Qt::Key_Up },
- { 0xff53, Qt::Key_Right },
- { 0xff54, Qt::Key_Down },
- { 0xffbe, Qt::Key_F1 },
- { 0xffbf, Qt::Key_F2 },
- { 0xffc0, Qt::Key_F3 },
- { 0xffc1, Qt::Key_F4 },
- { 0xffc2, Qt::Key_F5 },
- { 0xffc3, Qt::Key_F6 },
- { 0xffc4, Qt::Key_F7 },
- { 0xffc5, Qt::Key_F8 },
- { 0xffc6, Qt::Key_F9 },
- { 0xffc7, Qt::Key_F10 },
- { 0xffc8, Qt::Key_F11 },
- { 0xffc9, Qt::Key_F12 },
- { 0xffe1, Qt::Key_Shift },
- { 0xffe2, Qt::Key_Shift },
- { 0xffe3, Qt::Key_Control },
- { 0xffe4, Qt::Key_Control },
- { 0xffe7, Qt::Key_Meta },
- { 0xffe8, Qt::Key_Meta },
- { 0xffe9, Qt::Key_Alt },
- { 0xffea, Qt::Key_Alt },
-
- { 0xffb0, Qt::Key_0 },
- { 0xffb1, Qt::Key_1 },
- { 0xffb2, Qt::Key_2 },
- { 0xffb3, Qt::Key_3 },
- { 0xffb4, Qt::Key_4 },
- { 0xffb5, Qt::Key_5 },
- { 0xffb6, Qt::Key_6 },
- { 0xffb7, Qt::Key_7 },
- { 0xffb8, Qt::Key_8 },
- { 0xffb9, Qt::Key_9 },
-
- { 0xff8d, Qt::Key_Return },
- { 0xffaa, Qt::Key_Asterisk },
- { 0xffab, Qt::Key_Plus },
- { 0xffad, Qt::Key_Minus },
- { 0xffae, Qt::Key_Period },
- { 0xffaf, Qt::Key_Slash },
-
- { 0xff95, Qt::Key_Home },
- { 0xff96, Qt::Key_Left },
- { 0xff97, Qt::Key_Up },
- { 0xff98, Qt::Key_Right },
- { 0xff99, Qt::Key_Down },
- { 0xff9a, Qt::Key_PageUp },
- { 0xff9b, Qt::Key_PageDown },
- { 0xff9c, Qt::Key_End },
- { 0xff9e, Qt::Key_Insert },
- { 0xff9f, Qt::Key_Delete },
-
- { 0, 0 }
-};
-
-void QRfbRect::read(QTcpSocket *s)
-{
- quint16 buf[4];
- s->read((char*)buf, 8);
- x = ntohs(buf[0]);
- y = ntohs(buf[1]);
- w = ntohs(buf[2]);
- h = ntohs(buf[3]);
-}
-
-void QRfbRect::write(QTcpSocket *s) const
-{
- quint16 buf[4];
- buf[0] = htons(x);
- buf[1] = htons(y);
- buf[2] = htons(w);
- buf[3] = htons(h);
- s->write((char*)buf, 8);
-}
-
-void QRfbPixelFormat::read(QTcpSocket *s)
-{
- char buf[16];
- s->read(buf, 16);
- bitsPerPixel = buf[0];
- depth = buf[1];
- bigEndian = buf[2];
- trueColor = buf[3];
-
- quint16 a = ntohs(*(quint16 *)(buf + 4));
- redBits = 0;
- while (a) { a >>= 1; redBits++; }
-
- a = ntohs(*(quint16 *)(buf + 6));
- greenBits = 0;
- while (a) { a >>= 1; greenBits++; }
-
- a = ntohs(*(quint16 *)(buf + 8));
- blueBits = 0;
- while (a) { a >>= 1; blueBits++; }
-
- redShift = buf[10];
- greenShift = buf[11];
- blueShift = buf[12];
-}
-
-void QRfbPixelFormat::write(QTcpSocket *s)
-{
- char buf[16];
- buf[0] = bitsPerPixel;
- buf[1] = depth;
- buf[2] = bigEndian;
- buf[3] = trueColor;
-
- quint16 a = 0;
- for (int i = 0; i < redBits; i++) a = (a << 1) | 1;
- *(quint16 *)(buf + 4) = htons(a);
-
- a = 0;
- for (int i = 0; i < greenBits; i++) a = (a << 1) | 1;
- *(quint16 *)(buf + 6) = htons(a);
-
- a = 0;
- for (int i = 0; i < blueBits; i++) a = (a << 1) | 1;
- *(quint16 *)(buf + 8) = htons(a);
-
- buf[10] = redShift;
- buf[11] = greenShift;
- buf[12] = blueShift;
- s->write(buf, 16);
-}
-
-
-void QRfbServerInit::setName(const char *n)
-{
- delete[] name;
- name = new char [strlen(n) + 1];
- strcpy(name, n);
-}
-
-void QRfbServerInit::read(QTcpSocket *s)
-{
- s->read((char *)&width, 2);
- width = ntohs(width);
- s->read((char *)&height, 2);
- height = ntohs(height);
- format.read(s);
-
- quint32 len;
- s->read((char *)&len, 4);
- len = ntohl(len);
-
- name = new char [len + 1];
- s->read(name, len);
- name[len] = '\0';
-}
-
-void QRfbServerInit::write(QTcpSocket *s)
-{
- quint16 t = htons(width);
- s->write((char *)&t, 2);
- t = htons(height);
- s->write((char *)&t, 2);
- format.write(s);
- quint32 len = strlen(name);
- len = htonl(len);
- s->write((char *)&len, 4);
- s->write(name, strlen(name));
-}
-
-bool QRfbSetEncodings::read(QTcpSocket *s)
-{
- if (s->bytesAvailable() < 3)
- return false;
-
- char tmp;
- s->read(&tmp, 1); // padding
- s->read((char *)&count, 2);
- count = ntohs(count);
-
- return true;
-}
-
-bool QRfbFrameBufferUpdateRequest::read(QTcpSocket *s)
-{
- if (s->bytesAvailable() < 9)
- return false;
-
- s->read(&incremental, 1);
- rect.read(s);
-
- return true;
-}
-
-bool QRfbKeyEvent::read(QTcpSocket *s)
-{
- if (s->bytesAvailable() < 7)
- return false;
-
- s->read(&down, 1);
- quint16 tmp;
- s->read((char *)&tmp, 2); // padding
-
- quint32 key;
- s->read((char *)&key, 4);
- key = ntohl(key);
-
- unicode = 0;
- keycode = 0;
- int i = 0;
- while (keyMap[i].keysym && !keycode) {
- if (keyMap[i].keysym == (int)key)
- keycode = keyMap[i].keycode;
- i++;
- }
-
- if (keycode >= ' ' && keycode <= '~')
- unicode = keycode;
-
- if (!keycode) {
- if (key <= 0xff) {
- unicode = key;
- if (key >= 'a' && key <= 'z')
- keycode = Qt::Key_A + key - 'a';
- else if (key >= ' ' && key <= '~')
- keycode = Qt::Key_Space + key - ' ';
- }
- }
-
- return true;
-}
-
-bool QRfbPointerEvent::read(QTcpSocket *s)
-{
- if (s->bytesAvailable() < 5)
- return false;
-
- char buttonMask;
- s->read(&buttonMask, 1);
- buttons = 0;
- if (buttonMask & 1)
- buttons |= Qt::LeftButton;
- if (buttonMask & 2)
- buttons |= Qt::MidButton;
- if (buttonMask & 4)
- buttons |= Qt::RightButton;
-
- quint16 tmp;
- s->read((char *)&tmp, 2);
- x = ntohs(tmp);
- s->read((char *)&tmp, 2);
- y = ntohs(tmp);
-
- return true;
-}
-
-bool QRfbClientCutText::read(QTcpSocket *s)
-{
- if (s->bytesAvailable() < 7)
- return false;
-
- char tmp[3];
- s->read(tmp, 3); // padding
- s->read((char *)&length, 4);
- length = ntohl(length);
-
- return true;
-}
-
-//===========================================================================
-
-QVNCServer::QVNCServer(QVNCScreen *screen)
- : qvnc_screen(screen)
-{
- init(5900);
-}
-
-QVNCServer::QVNCServer(QVNCScreen *screen, int id)
- : qvnc_screen(screen)
-{
- init(5900 + id);
-}
-
-void QVNCServer::init(uint port)
-{
- handleMsg = false;
- client = 0;
- encodingsPending = 0;
- cutTextPending = 0;
- keymod = 0;
- state = Unconnected;
- dirtyCursor = false;
-
- refreshRate = 25;
- timer = new QTimer(this);
- timer->setSingleShot(true);
- connect(timer, SIGNAL(timeout()), this, SLOT(checkUpdate()));
-
- serverSocket = new QTcpServer(this);
- if (!serverSocket->listen(QHostAddress::Any, port))
- qDebug() << "QVNCServer could not connect:" << serverSocket->errorString();
- else
- qDebug("QVNCServer created on port %d", port);
-
- connect(serverSocket, SIGNAL(newConnection()), this, SLOT(newConnection()));
-
-#ifndef QT_NO_QWS_CURSOR
- qvnc_cursor = 0;
-#endif
- encoder = 0;
-}
-
-QVNCServer::~QVNCServer()
-{
- delete encoder;
- encoder = 0;
- delete client;
- client = 0;
-#ifndef QT_NO_QWS_CURSOR
- delete qvnc_cursor;
- qvnc_cursor = 0;
-#endif
-}
-
-void QVNCServer::setDirty()
-{
- if (state == Connected && !timer->isActive() &&
- ((dirtyMap()->numDirty > 0) || dirtyCursor)) {
- timer->start();
- }
-}
-
-void QVNCServer::newConnection()
-{
- if (client)
- delete client;
-
- client = serverSocket->nextPendingConnection();
- connect(client,SIGNAL(readyRead()),this,SLOT(readClient()));
- connect(client,SIGNAL(disconnected()),this,SLOT(discardClient()));
- handleMsg = false;
- encodingsPending = 0;
- cutTextPending = 0;
- supportHextile = false;
- wantUpdate = false;
-
- timer->start(1000 / refreshRate);
- dirtyMap()->reset();
-
- // send protocol version
- const char *proto = "RFB 003.003\n";
- client->write(proto, 12);
- state = Protocol;
-
- if (!qvnc_screen->screen() && !qvnc_screen->d_ptr->noDisablePainting)
- QWSServer::instance()->enablePainting(true);
-}
-
-void QVNCServer::readClient()
-{
- switch (state) {
- case Protocol:
- if (client->bytesAvailable() >= 12) {
- char proto[13];
- client->read(proto, 12);
- proto[12] = '\0';
- qDebug("Client protocol version %s", proto);
- // No authentication
- quint32 auth = htonl(1);
- client->write((char *) &auth, sizeof(auth));
- state = Init;
- }
- break;
-
- case Init:
- if (client->bytesAvailable() >= 1) {
- quint8 shared;
- client->read((char *) &shared, 1);
-
- // Server Init msg
- QRfbServerInit sim;
- QRfbPixelFormat &format = sim.format;
- switch (qvnc_screen->depth()) {
- case 32:
- format.bitsPerPixel = 32;
- format.depth = 32;
- format.bigEndian = 0;
- format.trueColor = true;
- format.redBits = 8;
- format.greenBits = 8;
- format.blueBits = 8;
- format.redShift = 16;
- format.greenShift = 8;
- format.blueShift = 0;
- break;
-
- case 24:
- format.bitsPerPixel = 24;
- format.depth = 24;
- format.bigEndian = 0;
- format.trueColor = true;
- format.redBits = 8;
- format.greenBits = 8;
- format.blueBits = 8;
- format.redShift = 16;
- format.greenShift = 8;
- format.blueShift = 0;
- break;
-
- case 18:
- format.bitsPerPixel = 24;
- format.depth = 18;
- format.bigEndian = 0;
- format.trueColor = true;
- format.redBits = 6;
- format.greenBits = 6;
- format.blueBits = 6;
- format.redShift = 12;
- format.greenShift = 6;
- format.blueShift = 0;
- break;
-
- case 16:
- format.bitsPerPixel = 16;
- format.depth = 16;
- format.bigEndian = 0;
- format.trueColor = true;
- format.redBits = 5;
- format.greenBits = 6;
- format.blueBits = 5;
- format.redShift = 11;
- format.greenShift = 5;
- format.blueShift = 0;
- break;
-
- case 15:
- format.bitsPerPixel = 16;
- format.depth = 15;
- format.bigEndian = 0;
- format.trueColor = true;
- format.redBits = 5;
- format.greenBits = 5;
- format.blueBits = 5;
- format.redShift = 10;
- format.greenShift = 5;
- format.blueShift = 0;
- break;
-
- case 12:
- format.bitsPerPixel = 16;
- format.depth = 12;
- format.bigEndian = 0;
- format.trueColor = true;
- format.redBits = 4;
- format.greenBits = 4;
- format.blueBits = 4;
- format.redShift = 8;
- format.greenShift = 4;
- format.blueShift = 0;
- break;
-
- case 8:
- case 4:
- format.bitsPerPixel = 8;
- format.depth = 8;
- format.bigEndian = 0;
- format.trueColor = false;
- format.redBits = 0;
- format.greenBits = 0;
- format.blueBits = 0;
- format.redShift = 0;
- format.greenShift = 0;
- format.blueShift = 0;
- break;
-
- default:
- qDebug("QVNC cannot drive depth %d", qvnc_screen->depth());
- discardClient();
- return;
- }
- sim.width = qvnc_screen->deviceWidth();
- sim.height = qvnc_screen->deviceHeight();
- sim.setName("Qt for Embedded Linux VNC Server");
- sim.write(client);
- state = Connected;
- }
- break;
-
- case Connected:
- do {
- if (!handleMsg) {
- client->read((char *)&msgType, 1);
- handleMsg = true;
- }
- if (handleMsg) {
- switch (msgType ) {
- case SetPixelFormat:
- setPixelFormat();
- break;
- case FixColourMapEntries:
- qDebug("Not supported: FixColourMapEntries");
- handleMsg = false;
- break;
- case SetEncodings:
- setEncodings();
- break;
- case FramebufferUpdateRequest:
- frameBufferUpdateRequest();
- break;
- case KeyEvent:
- keyEvent();
- break;
- case PointerEvent:
- pointerEvent();
- break;
- case ClientCutText:
- clientCutText();
- break;
- default:
- qDebug("Unknown message type: %d", (int)msgType);
- handleMsg = false;
- }
- }
- } while (!handleMsg && client->bytesAvailable());
- break;
- default:
- break;
- }
-}
-
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
-bool QVNCScreen::swapBytes() const
-{
- if (depth() != 16)
- return false;
-
- if (screen())
- return screen()->frameBufferLittleEndian();
- return frameBufferLittleEndian();
-}
-#endif
-
-void QVNCServer::setPixelFormat()
-{
- if (client->bytesAvailable() >= 19) {
- char buf[3];
- client->read(buf, 3); // just padding
- pixelFormat.read(client);
-#ifdef QT_QWS_VNC_DEBUG
- qDebug("Want format: %d %d %d %d %d %d %d %d %d %d",
- int(pixelFormat.bitsPerPixel),
- int(pixelFormat.depth),
- int(pixelFormat.bigEndian),
- int(pixelFormat.trueColor),
- int(pixelFormat.redBits),
- int(pixelFormat.greenBits),
- int(pixelFormat.blueBits),
- int(pixelFormat.redShift),
- int(pixelFormat.greenShift),
- int(pixelFormat.blueShift));
-#endif
- if (!pixelFormat.trueColor) {
- qDebug("Can only handle true color clients");
- discardClient();
- }
- handleMsg = false;
- sameEndian = (QSysInfo::ByteOrder == QSysInfo::BigEndian) == !!pixelFormat.bigEndian;
- needConversion = pixelConversionNeeded();
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- swapBytes = qvnc_screen->swapBytes();
-#endif
- }
-}
-
-void QVNCServer::setEncodings()
-{
- QRfbSetEncodings enc;
-
- if (!encodingsPending && enc.read(client)) {
- encodingsPending = enc.count;
- if (!encodingsPending)
- handleMsg = false;
- }
-
- if (encoder) {
- delete encoder;
- encoder = 0;
- }
-
- enum Encodings {
- Raw = 0,
- CopyRect = 1,
- RRE = 2,
- CoRRE = 4,
- Hextile = 5,
- ZRLE = 16,
- Cursor = -239,
- DesktopSize = -223
- };
-
- if (encodingsPending && (unsigned)client->bytesAvailable() >=
- encodingsPending * sizeof(quint32)) {
- for (int i = 0; i < encodingsPending; ++i) {
- qint32 enc;
- client->read((char *)&enc, sizeof(qint32));
- enc = ntohl(enc);
-#ifdef QT_QWS_VNC_DEBUG
- qDebug("QVNCServer::setEncodings: %d", enc);
-#endif
- switch (enc) {
- case Raw:
- if (!encoder) {
- encoder = new QRfbRawEncoder(this);
-#ifdef QT_QWS_VNC_DEBUG
- qDebug("QVNCServer::setEncodings: using raw");
-#endif
- }
- break;
- case CopyRect:
- supportCopyRect = true;
- break;
- case RRE:
- supportRRE = true;
- break;
- case CoRRE:
- supportCoRRE = true;
- break;
- case Hextile:
- supportHextile = true;
- if (encoder)
- break;
- switch (qvnc_screen->depth()) {
-#ifdef QT_QWS_DEPTH_8
- case 8:
- encoder = new QRfbHextileEncoder<quint8>(this);
- break;
-#endif
-#ifdef QT_QWS_DEPTH_12
- case 12:
- encoder = new QRfbHextileEncoder<qrgb444>(this);
- break;
-#endif
-#ifdef QT_QWS_DEPTH_15
- case 15:
- encoder = new QRfbHextileEncoder<qrgb555>(this);
- break;
-#endif
-#ifdef QT_QWS_DEPTH_16
- case 16:
- encoder = new QRfbHextileEncoder<quint16>(this);
- break;
-#endif
-#ifdef QT_QWS_DEPTH_18
- case 18:
- encoder = new QRfbHextileEncoder<qrgb666>(this);
- break;
-#endif
-#ifdef QT_QWS_DEPTH_24
- case 24:
- encoder = new QRfbHextileEncoder<qrgb888>(this);
- break;
-#endif
-#ifdef QT_QWS_DEPTH_32
- case 32:
- encoder = new QRfbHextileEncoder<quint32>(this);
- break;
-#endif
- default:
- break;
- }
-#ifdef QT_QWS_VNC_DEBUG
- qDebug("QVNCServer::setEncodings: using hextile");
-#endif
- break;
- case ZRLE:
- supportZRLE = true;
- break;
- case Cursor:
- supportCursor = true;
-#ifndef QT_NO_QWS_CURSOR
- if (!qvnc_screen->screen() || qt_screencursor->isAccelerated()) {
- delete qvnc_cursor;
- qvnc_cursor = new QVNCClientCursor(this);
- }
-#endif
- break;
- case DesktopSize:
- supportDesktopSize = true;
- break;
- default:
- break;
- }
- }
- handleMsg = false;
- encodingsPending = 0;
- }
-
- if (!encoder) {
- encoder = new QRfbRawEncoder(this);
-#ifdef QT_QWS_VNC_DEBUG
- qDebug("QVNCServer::setEncodings: fallback using raw");
-#endif
- }
-}
-
-void QVNCServer::frameBufferUpdateRequest()
-{
- QRfbFrameBufferUpdateRequest ev;
-
- if (ev.read(client)) {
- if (!ev.incremental) {
- QRect r(ev.rect.x, ev.rect.y, ev.rect.w, ev.rect.h);
- r.translate(qvnc_screen->offset());
- qvnc_screen->d_ptr->setDirty(r, true);
- }
- wantUpdate = true;
- checkUpdate();
- handleMsg = false;
- }
-}
-
-void QVNCServer::pointerEvent()
-{
- QRfbPointerEvent ev;
- if (ev.read(client)) {
- const QPoint offset = qvnc_screen->offset();
- QWSServer::sendMouseEvent(offset + QPoint(ev.x, ev.y), ev.buttons);
- handleMsg = false;
- }
-}
-
-void QVNCServer::keyEvent()
-{
- QRfbKeyEvent ev;
-
- if (ev.read(client)) {
- if (ev.keycode == Qt::Key_Shift)
- keymod = ev.down ? keymod | Qt::ShiftModifier :
- keymod & ~Qt::ShiftModifier;
- else if (ev.keycode == Qt::Key_Control)
- keymod = ev.down ? keymod | Qt::ControlModifier :
- keymod & ~Qt::ControlModifier;
- else if (ev.keycode == Qt::Key_Alt)
- keymod = ev.down ? keymod | Qt::AltModifier :
- keymod & ~Qt::AltModifier;
- if (ev.unicode || ev.keycode)
- QWSServer::sendKeyEvent(ev.unicode, ev.keycode, keymod, ev.down, false);
- handleMsg = false;
- }
-}
-
-void QVNCServer::clientCutText()
-{
- QRfbClientCutText ev;
-
- if (cutTextPending == 0 && ev.read(client)) {
- cutTextPending = ev.length;
- if (!cutTextPending)
- handleMsg = false;
- }
-
- if (cutTextPending && client->bytesAvailable() >= cutTextPending) {
- char *text = new char [cutTextPending+1];
- client->read(text, cutTextPending);
- delete [] text;
- cutTextPending = 0;
- handleMsg = false;
- }
-}
-
-// stride in bytes
-template <class SRC>
-bool QRfbSingleColorHextile<SRC>::read(const uchar *data,
- int width, int height, int stride)
-{
- const int depth = encoder->server->screen()->depth();
- if (width % (depth / 8)) // hw: should rather fallback to simple loop
- return false;
-
- static int alwaysFalse = qgetenv("QT_VNC_NOCHECKFILL").toInt();
- if (alwaysFalse)
- return false;
-
- switch (depth) {
- case 4: {
- const quint8 *data8 = reinterpret_cast<const quint8*>(data);
- if ((data8[0] & 0xf) != (data8[0] >> 4))
- return false;
- width /= 2;
- } // fallthrough
- case 8: {
- const quint8 *data8 = reinterpret_cast<const quint8*>(data);
- if (data8[0] != data8[1])
- return false;
- width /= 2;
- } // fallthrough
- case 12:
- case 15:
- case 16: {
- const quint16 *data16 = reinterpret_cast<const quint16*>(data);
- if (data16[0] != data16[1])
- return false;
- width /= 2;
- } // fallthrough
- case 18:
- case 24:
- case 32: {
- const quint32 *data32 = reinterpret_cast<const quint32*>(data);
- const quint32 first = data32[0];
- const int linestep = (stride / sizeof(quint32)) - width;
- for (int y = 0; y < height; ++y) {
- for (int x = 0; x < width; ++x) {
- if (*(data32++) != first)
- return false;
- }
- data32 += linestep;
- }
- break;
- }
- default:
- return false;
- }
-
- SRC color = reinterpret_cast<const SRC*>(data)[0];
- encoder->newBg |= (color != encoder->bg);
- encoder->bg = color;
- return true;
-}
-
-template <class SRC>
-void QRfbSingleColorHextile<SRC>::write(QTcpSocket *socket) const
-{
- if (true || encoder->newBg) {
- const int bpp = encoder->server->clientBytesPerPixel();
- const int padding = 3;
- QVarLengthArray<char> buffer(padding + 1 + bpp);
- buffer[padding] = 2; // BackgroundSpecified
- encoder->server->convertPixels(buffer.data() + padding + 1,
- reinterpret_cast<char*>(&encoder->bg),
- 1);
- socket->write(buffer.data() + padding, bpp + 1);
-// encoder->newBg = false;
- } else {
- char subenc = 0;
- socket->write(&subenc, 1);
- }
-}
-
-template <class SRC>
-bool QRfbDualColorHextile<SRC>::read(const uchar *data,
- int width, int height, int stride)
-{
- const SRC *ptr = reinterpret_cast<const SRC*>(data);
- const int linestep = (stride / sizeof(SRC)) - width;
-
- SRC c1;
- SRC c2 = 0;
- int n1 = 0;
- int n2 = 0;
- int x = 0;
- int y = 0;
-
- c1 = *ptr;
-
- // find second color
- while (y < height) {
- while (x < width) {
- if (*ptr == c1) {
- ++n1;
- } else {
- c2 = *ptr;
- goto found_second_color;
- }
- ++ptr;
- ++x;
- }
- x = 0;
- ptr += linestep;
- ++y;
- }
-
-found_second_color:
- // finish counting
- while (y < height) {
- while (x < width) {
- if (*ptr == c1) {
- ++n1;
- } else if (*ptr == c2) {
- ++n2;
- } else {
- return false;
- }
- ++ptr;
- ++x;
- }
- x = 0;
- ptr += linestep;
- ++y;
- }
-
- if (n2 > n1) {
- const quint32 tmpC = c1;
- c1 = c2;
- c2 = tmpC;
- }
-
- encoder->newBg |= (c1 != encoder->bg);
- encoder->newFg |= (c2 != encoder->fg);
-
- encoder->bg = c1;
- encoder->fg = c2;
-
- // create map
- bool inRect = false;
- numRects = 0;
- ptr = reinterpret_cast<const SRC*>(data);
- for (y = 0; y < height; ++y) {
- for (x = 0; x < width; ++x) {
- if (inRect && *ptr == encoder->bg) {
- // rect finished
- setWidth(x - lastx());
- next();
- inRect = false;
- } else if (!inRect && *ptr == encoder->fg) {
- // rect start
- setX(x);
- setY(y);
- setHeight(1);
- inRect = true;
- }
- ++ptr;
- }
- if (inRect) {
- // finish rect
- setWidth(width - lastx());
- next();
- inRect = false;
- }
- ptr += linestep;
- }
-
- return true;
-}
-
-template <class SRC>
-void QRfbDualColorHextile<SRC>::write(QTcpSocket *socket) const
-{
- const int bpp = encoder->server->clientBytesPerPixel();
- const int padding = 3;
- QVarLengthArray<char> buffer(padding + 2 * bpp + sizeof(char) + sizeof(numRects));
- char &subenc = buffer[padding];
- int n = padding + sizeof(subenc);
-
- subenc = 0x8; // AnySubrects
-
- if (encoder->newBg) {
- subenc |= 0x2; // Background
- encoder->server->convertPixels(buffer.data() + n, (char*)&encoder->bg, 1);
- n += bpp;
-// encoder->newBg = false;
- }
-
- if (encoder->newFg) {
- subenc |= 0x4; // Foreground
- encoder->server->convertPixels(buffer.data() + n, (char*)&encoder->fg, 1);
- n += bpp;
-// encoder->newFg = false;
- }
- buffer[n] = numRects;
- n += sizeof(numRects);
-
- socket->write(buffer.data() + padding, n - padding);
- socket->write((char*)rects, numRects * sizeof(Rect));
-}
-
-template <class SRC>
-void QRfbDualColorHextile<SRC>::next()
-{
- for (int r = numRects - 1; r >= 0; --r) {
- if (recty(r) == lasty())
- continue;
- if (recty(r) < lasty() - 1) // only search previous scanline
- break;
- if (rectx(r) == lastx() && width(r) == width(numRects)) {
- ++rects[r].wh;
- return;
- }
- }
- ++numRects;
-}
-
-template <class SRC>
-inline void QRfbMultiColorHextile<SRC>::setColor(SRC color)
-{
- encoder->server->convertPixels(reinterpret_cast<char*>(rect(numRects)),
- (const char*)&color, 1);
-}
-
-template <class SRC>
-inline bool QRfbMultiColorHextile<SRC>::beginRect()
-{
- if ((rects.size() + bpp + 2) > maxRectsSize)
- return false;
- rects.resize(rects.size() + bpp + 2);
- return true;
-}
-
-template <class SRC>
-inline void QRfbMultiColorHextile<SRC>::endRect()
-{
- setHeight(numRects, 1);
- ++numRects;
-}
-
-template <class SRC>
-bool QRfbMultiColorHextile<SRC>::read(const uchar *data,
- int width, int height, int stride)
-{
- const SRC *ptr = reinterpret_cast<const SRC*>(data);
- const int linestep = (stride / sizeof(SRC)) - width;
-
- bpp = encoder->server->clientBytesPerPixel();
-
- if (encoder->newBg)
- encoder->bg = ptr[0];
-
- const SRC bg = encoder->bg;
- SRC color = bg;
- bool inRect = false;
-
- numRects = 0;
- rects.clear();
-
- for (int y = 0; y < height; ++y) {
- for (int x = 0; x < width; ++x) {
- if (inRect && *ptr != color) { // end rect
- setWidth(numRects, x - rectx(numRects));
- endRect();
- inRect = false;
- }
-
- if (!inRect && *ptr != bg) { // begin rect
- if (!beginRect())
- return false;
- inRect = true;
- color = *ptr;
- setColor(color);
- setX(numRects, x);
- setY(numRects, y);
- }
- ++ptr;
- }
- if (inRect) { // end rect
- setWidth(numRects, width - rectx(numRects));
- endRect();
- inRect = false;
- }
- ptr += linestep;
- }
-
- return true;
-}
-
-template <class SRC>
-void QRfbMultiColorHextile<SRC>::write(QTcpSocket *socket) const
-{
- const int padding = 3;
- QVarLengthArray<quint8> buffer(bpp + padding + sizeof(quint8) + sizeof(numRects));
-
- quint8 &subenc = buffer[padding];
- int n = padding + sizeof(quint8);
-
- subenc = 8 | 16; // AnySubrects | SubrectsColoured
-
- if (encoder->newBg) {
- subenc |= 0x2; // Background
- encoder->server->convertPixels(reinterpret_cast<char*>(buffer.data() + n),
- reinterpret_cast<const char*>(&encoder->bg),
- 1);
- n += bpp;
-// encoder->newBg = false;
- }
-
- buffer[n] = numRects;
- n += sizeof(numRects);
-
- socket->write(reinterpret_cast<const char*>(buffer.data() + padding),
- n - padding);
- socket->write(reinterpret_cast<const char*>(rects.constData()),
- rects.size());
-}
-
-bool QVNCServer::pixelConversionNeeded() const
-{
- if (!sameEndian)
- return true;
-
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- if (qvnc_screen->swapBytes())
- return true;
-#endif
-
- const int screendepth = qvnc_screen->depth();
- if (screendepth != pixelFormat.bitsPerPixel)
- return true;
-
- switch (screendepth) {
- case 32:
- case 24:
- return false;
- case 18:
- return (pixelFormat.redBits == 6
- && pixelFormat.greenBits == 6
- && pixelFormat.blueBits == 6);
- case 16:
- return (pixelFormat.redBits == 5
- && pixelFormat.greenBits == 6
- && pixelFormat.blueBits == 5);
- case 15:
- return (pixelFormat.redBits == 5
- && pixelFormat.greenBits == 5
- && pixelFormat.blueBits == 5);
- case 12:
- return (pixelFormat.redBits == 4
- && pixelFormat.greenBits == 4
- && pixelFormat.blueBits == 4);
- }
- return true;
-}
-
-// count: number of pixels
-void QVNCServer::convertPixels(char *dst, const char *src, int count) const
-{
- const int screendepth = qvnc_screen->depth();
- const bool isBgr = qvnc_screen->pixelType() == QScreen::BGRPixel;
-
- // cutoffs
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- if (!swapBytes)
-#endif
- if (sameEndian) {
- if (screendepth == pixelFormat.bitsPerPixel) { // memcpy cutoffs
-
- switch (screendepth) {
- case 32:
- memcpy(dst, src, count * sizeof(quint32));
- return;
- case 16:
- if (pixelFormat.redBits == 5
- && pixelFormat.greenBits == 6
- && pixelFormat.blueBits == 5)
- {
- memcpy(dst, src, count * sizeof(quint16));
- return;
- }
- }
- } else if (screendepth == 16 && pixelFormat.bitsPerPixel == 32) {
-#if defined(__i386__) // Currently fails on ARM if dst is not 4 byte aligned
- const quint32 *src32 = reinterpret_cast<const quint32*>(src);
- quint32 *dst32 = reinterpret_cast<quint32*>(dst);
- int count32 = count * sizeof(quint16) / sizeof(quint32);
- while (count32--) {
- const quint32 s = *src32++;
- quint32 result1;
- quint32 result2;
-
- // red
- result1 = ((s & 0xf8000000) | ((s & 0xe0000000) >> 5)) >> 8;
- result2 = ((s & 0x0000f800) | ((s & 0x0000e000) >> 5)) << 8;
-
- // green
- result1 |= ((s & 0x07e00000) | ((s & 0x06000000) >> 6)) >> 11;
- result2 |= ((s & 0x000007e0) | ((s & 0x00000600) >> 6)) << 5;
-
- // blue
- result1 |= ((s & 0x001f0000) | ((s & 0x001c0000) >> 5)) >> 13;
- result2 |= ((s & 0x0000001f) | ((s & 0x0000001c) >> 5)) << 3;
-
- *dst32++ = result2;
- *dst32++ = result1;
- }
- if (count & 0x1) {
- const quint16 *src16 = reinterpret_cast<const quint16*>(src);
- *dst32 = qt_conv16ToRgb(src16[count - 1]);
- }
- return;
-#endif
- }
- }
-
- const int bytesPerPixel = (pixelFormat.bitsPerPixel + 7) / 8;
-
-// nibble = 0;
-
- for (int i = 0; i < count; ++i) {
- int r, g, b;
-
- switch (screendepth) {
-#if 0
- case 4: {
- if (!nibble) {
- r = ((*src) & 0x0f) << 4;
- } else {
- r = (*src) & 0xf0;
- src++;
- }
- nibble = !nibble;
- g = b = r;
- break;
- }
-#endif
- case 8: {
- QRgb rgb = qvnc_screen->clut()[int(*src)];
- r = qRed(rgb);
- g = qGreen(rgb);
- b = qBlue(rgb);
- src++;
- break;
- }
-#ifdef QT_QWS_DEPTH_12
- case 12: {
- quint32 p = quint32(*reinterpret_cast<const qrgb444*>(src));
- r = qRed(p);
- g = qGreen(p);
- b = qBlue(p);
- src += sizeof(qrgb444);
- break;
- }
-#endif
-#ifdef QT_QWS_DEPTH_15
- case 15: {
- quint32 p = quint32(*reinterpret_cast<const qrgb555*>(src));
- r = qRed(p);
- g = qGreen(p);
- b = qBlue(p);
- src += sizeof(qrgb555);
- break;
- }
-#endif
- case 16: {
- quint16 p = *reinterpret_cast<const quint16*>(src);
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- if (swapBytes)
- p = ((p & 0xff) << 8) | ((p & 0xff00) >> 8);
-#endif
- r = (p >> 11) & 0x1f;
- g = (p >> 5) & 0x3f;
- b = p & 0x1f;
- r <<= 3;
- g <<= 2;
- b <<= 3;
- src += sizeof(quint16);
- break;
- }
-#ifdef QT_QWS_DEPTH_18
- case 18: {
- quint32 p = quint32(*reinterpret_cast<const qrgb666*>(src));
- r = qRed(p);
- g = qGreen(p);
- b = qBlue(p);
- src += sizeof(qrgb666);
- break;
- }
-#endif
-#ifdef QT_QWS_DEPTH_24
- case 24: {
- quint32 p = quint32(*reinterpret_cast<const qrgb888*>(src));
- r = qRed(p);
- g = qGreen(p);
- b = qBlue(p);
- src += sizeof(qrgb888);
- break;
- }
-#endif
- case 32: {
- quint32 p = *reinterpret_cast<const quint32*>(src);
- r = (p >> 16) & 0xff;
- g = (p >> 8) & 0xff;
- b = p & 0xff;
- src += sizeof(quint32);
- break;
- }
- default: {
- r = g = b = 0;
- qDebug("QVNCServer: don't support %dbpp display", screendepth);
- return;
- }
- }
-
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- if (swapBytes ^ isBgr)
-#else
- if (isBgr)
-#endif
- qSwap(r, b);
-
- r >>= (8 - pixelFormat.redBits);
- g >>= (8 - pixelFormat.greenBits);
- b >>= (8 - pixelFormat.blueBits);
-
- int pixel = (r << pixelFormat.redShift) |
- (g << pixelFormat.greenShift) |
- (b << pixelFormat.blueShift);
-
- if (sameEndian || pixelFormat.bitsPerPixel == 8) {
- memcpy(dst, &pixel, bytesPerPixel); // XXX: do a simple for-loop instead?
- dst += bytesPerPixel;
- continue;
- }
-
-
- if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
- switch (pixelFormat.bitsPerPixel) {
- case 16:
- pixel = (((pixel & 0x0000ff00) << 8) |
- ((pixel & 0x000000ff) << 24));
- break;
- case 32:
- pixel = (((pixel & 0xff000000) >> 24) |
- ((pixel & 0x00ff0000) >> 8) |
- ((pixel & 0x0000ff00) << 8) |
- ((pixel & 0x000000ff) << 24));
- break;
- default:
- qDebug("Cannot handle %d bpp client", pixelFormat.bitsPerPixel);
- }
- } else { // QSysInfo::ByteOrder == QSysInfo::LittleEndian
- switch (pixelFormat.bitsPerPixel) {
- case 16:
- pixel = (((pixel & 0xff000000) >> 8) |
- ((pixel & 0x00ff0000) << 8));
- break;
- case 32:
- pixel = (((pixel & 0xff000000) >> 24) |
- ((pixel & 0x00ff0000) >> 8) |
- ((pixel & 0x0000ff00) << 8) |
- ((pixel & 0x000000ff) << 24));
- break;
- default:
- qDebug("Cannot handle %d bpp client",
- pixelFormat.bitsPerPixel);
- break;
- }
- }
- memcpy(dst, &pixel, bytesPerPixel); // XXX: simple for-loop instead?
- dst += bytesPerPixel;
- }
-}
-
-#ifndef QT_NO_QWS_CURSOR
-static void blendCursor(QImage &image, const QRect &imageRect)
-{
- const QRect cursorRect = qt_screencursor->boundingRect();
- const QRect intersection = (cursorRect & imageRect);
- const QRect destRect = intersection.translated(-imageRect.topLeft());
- const QRect srcRect = intersection.translated(-cursorRect.topLeft());
-
- QPainter painter(&image);
- painter.drawImage(destRect, qt_screencursor->image(), srcRect);
- painter.end();
-}
-#endif // QT_NO_QWS_CURSOR
-
-QVNCDirtyMap::QVNCDirtyMap(QScreen *s)
- : bytesPerPixel(0), numDirty(0), screen(s)
-{
- bytesPerPixel = (screen->depth() + 7) / 8;
- bufferWidth = screen->deviceWidth();
- bufferHeight = screen->deviceHeight();
- bufferStride = bufferWidth * bytesPerPixel;
- buffer = new uchar[bufferHeight * bufferStride];
-
- mapWidth = (bufferWidth + MAP_TILE_SIZE - 1) / MAP_TILE_SIZE;
- mapHeight = (bufferHeight + MAP_TILE_SIZE - 1) / MAP_TILE_SIZE;
- numTiles = mapWidth * mapHeight;
- map = new uchar[numTiles];
-}
-
-QVNCDirtyMap::~QVNCDirtyMap()
-{
- delete[] map;
- delete[] buffer;
-}
-
-void QVNCDirtyMap::reset()
-{
- memset(map, 1, numTiles);
- memset(buffer, 0, bufferHeight * bufferStride);
- numDirty = numTiles;
-}
-
-inline bool QVNCDirtyMap::dirty(int x, int y) const
-{
- return map[y * mapWidth + x];
-}
-
-inline void QVNCDirtyMap::setClean(int x, int y)
-{
- map[y * mapWidth + x] = 0;
- --numDirty;
-}
-
-template <class T>
-void QVNCDirtyMapOptimized<T>::setDirty(int tileX, int tileY, bool force)
-{
- static bool alwaysForce = qgetenv("QT_VNC_NO_COMPAREBUFFER").toInt();
- if (alwaysForce)
- force = true;
-
- bool changed = false;
-
- if (!force) {
- const int lstep = screen->linestep();
- const int startX = tileX * MAP_TILE_SIZE;
- const int startY = tileY * MAP_TILE_SIZE;
- const uchar *scrn = screen->base()
- + startY * lstep + startX * bytesPerPixel;
- uchar *old = buffer + startY * bufferStride + startX * sizeof(T);
-
- const int tileHeight = (startY + MAP_TILE_SIZE > bufferHeight ?
- bufferHeight - startY : MAP_TILE_SIZE);
- const int tileWidth = (startX + MAP_TILE_SIZE > bufferWidth ?
- bufferWidth - startX : MAP_TILE_SIZE);
- const bool doInlines = (tileWidth == MAP_TILE_SIZE);
-
- int y = tileHeight;
-
- if (doInlines) { // hw: memcmp/memcpy is inlined when using constants
- while (y) {
- if (memcmp(old, scrn, sizeof(T) * MAP_TILE_SIZE)) {
- changed = true;
- break;
- }
- scrn += lstep;
- old += bufferStride;
- --y;
- }
-
- while (y) {
- memcpy(old, scrn, sizeof(T) * MAP_TILE_SIZE);
- scrn += lstep;
- old += bufferStride;
- --y;
- }
- } else {
- while (y) {
- if (memcmp(old, scrn, sizeof(T) * tileWidth)) {
- changed = true;
- break;
- }
- scrn += lstep;
- old += bufferStride;
- --y;
- }
-
- while (y) {
- memcpy(old, scrn, sizeof(T) * tileWidth);
- scrn += lstep;
- old += bufferStride;
- --y;
- }
- }
- }
-
- const int mapIndex = tileY * mapWidth + tileX;
- if ((force || changed) && !map[mapIndex]) {
- map[mapIndex] = 1;
- ++numDirty;
- }
-}
-
-template <class SRC>
-QRfbHextileEncoder<SRC>::QRfbHextileEncoder(QVNCServer *s)
- : QRfbEncoder(s),
- singleColorHextile(this), dualColorHextile(this), multiColorHextile(this)
-{
-}
-
-/*
- \internal
- Send dirty rects using hextile encoding.
-*/
-template <class SRC>
-void QRfbHextileEncoder<SRC>::write()
-{
- QWSDisplay::grab(true);
-
- QVNCDirtyMap *map = server->dirtyMap();
- QTcpSocket *socket = server->clientSocket();
-
- const quint32 encoding = htonl(5); // hextile encoding
- const int bytesPerPixel = server->clientBytesPerPixel();
-
- {
- const char tmp[2] = { 0, 0 }; // msg type, padding
- socket->write(tmp, sizeof(tmp));
- }
- {
- const quint16 count = htons(map->numDirty);
- socket->write((char *)&count, sizeof(count));
- }
-
- if (map->numDirty <= 0) {
- QWSDisplay::ungrab();
- return;
- }
-
- newBg = true;
- newFg = true;
-
- const QImage screenImage = server->screenImage();
- QRfbRect rect(0, 0, MAP_TILE_SIZE, MAP_TILE_SIZE);
-
- for (int y = 0; y < map->mapHeight; ++y) {
- if (rect.y + MAP_TILE_SIZE > server->screen()->height())
- rect.h = server->screen()->height() - rect.y;
- rect.w = MAP_TILE_SIZE;
- for (int x = 0; x < map->mapWidth; ++x) {
- if (!map->dirty(x, y))
- continue;
- map->setClean(x, y);
-
- rect.x = x * MAP_TILE_SIZE;
- if (rect.x + MAP_TILE_SIZE > server->screen()->deviceWidth())
- rect.w = server->screen()->deviceWidth() - rect.x;
- rect.write(socket);
-
- socket->write((char *)&encoding, sizeof(encoding));
-
- const uchar *screendata = screenImage.scanLine(rect.y)
- + rect.x * screenImage.depth() / 8;
- int linestep = screenImage.bytesPerLine();
-
-#ifndef QT_NO_QWS_CURSOR
- // hardware cursors must be blended with the screen memory
- const bool doBlendCursor = qt_screencursor
- && !server->hasClientCursor()
- && qt_screencursor->isAccelerated();
- QImage tileImage;
- if (doBlendCursor) {
- const QRect tileRect(rect.x, rect.y, rect.w, rect.h);
- const QRect cursorRect = qt_screencursor->boundingRect()
- .translated(-server->screen()->offset());
- if (tileRect.intersects(cursorRect)) {
- tileImage = screenImage.copy(tileRect);
- blendCursor(tileImage,
- tileRect.translated(server->screen()->offset()));
- screendata = tileImage.bits();
- linestep = tileImage.bytesPerLine();
- }
- }
-#endif // QT_NO_QWS_CURSOR
-
- if (singleColorHextile.read(screendata, rect.w, rect.h, linestep)) {
- singleColorHextile.write(socket);
- } else if (dualColorHextile.read(screendata, rect.w, rect.h, linestep)) {
- dualColorHextile.write(socket);
- } else if (multiColorHextile.read(screendata, rect.w, rect.h, linestep)) {
- multiColorHextile.write(socket);
- } else if (server->doPixelConversion()) {
- const int bufferSize = rect.w * rect.h * bytesPerPixel + 1;
- const int padding = sizeof(quint32) - sizeof(char);
- buffer.resize(bufferSize + padding);
-
- buffer[padding] = 1; // Raw subencoding
-
- // convert pixels
- char *b = buffer.data() + padding + 1;
- const int bstep = rect.w * bytesPerPixel;
- for (int i = 0; i < rect.h; ++i) {
- server->convertPixels(b, (const char*)screendata, rect.w);
- screendata += linestep;
- b += bstep;
- }
- socket->write(buffer.constData() + padding, bufferSize);
- } else {
- quint8 subenc = 1; // Raw subencoding
- socket->write((char *)&subenc, 1);
-
- // send pixels
- for (int i = 0; i < rect.h; ++i) {
- socket->write((const char*)screendata,
- rect.w * bytesPerPixel);
- screendata += linestep;
- }
- }
- }
- if (socket->state() == QAbstractSocket::UnconnectedState)
- break;
- rect.y += MAP_TILE_SIZE;
- }
- socket->flush();
- Q_ASSERT(map->numDirty == 0);
-
- QWSDisplay::ungrab();
-}
-
-void QRfbRawEncoder::write()
-{
- QWSDisplay::grab(false);
-
- QVNCDirtyMap *map = server->dirtyMap();
- QTcpSocket *socket = server->clientSocket();
-
- const int bytesPerPixel = server->clientBytesPerPixel();
-
- // create a region from the dirty rects and send the region's merged rects.
- QRegion rgn;
- if (map) {
- for (int y = 0; y < map->mapHeight; ++y) {
- for (int x = 0; x < map->mapWidth; ++x) {
- if (!map->dirty(x, y))
- continue;
- rgn += QRect(x * MAP_TILE_SIZE, y * MAP_TILE_SIZE,
- MAP_TILE_SIZE, MAP_TILE_SIZE);
- map->setClean(x, y);
- }
- }
-
- rgn &= QRect(0, 0, server->screen()->deviceWidth(),
- server->screen()->deviceHeight());
- }
- const QVector<QRect> rects = rgn.rects();
-
- {
- const char tmp[2] = { 0, 0 }; // msg type, padding
- socket->write(tmp, sizeof(tmp));
- }
-
- {
- const quint16 count = htons(rects.size());
- socket->write((char *)&count, sizeof(count));
- }
-
- if (rects.size() <= 0) {
- QWSDisplay::ungrab();
- return;
- }
-
- const QImage screenImage = server->screenImage();
-
- for (int i = 0; i < rects.size(); ++i) {
- const QRect tileRect = rects.at(i);
- const QRfbRect rect(tileRect.x(), tileRect.y(),
- tileRect.width(), tileRect.height());
- rect.write(socket);
-
- const quint32 encoding = htonl(0); // raw encoding
- socket->write((char *)&encoding, sizeof(encoding));
-
- int linestep = screenImage.bytesPerLine();
- const uchar *screendata = screenImage.scanLine(rect.y)
- + rect.x * screenImage.depth() / 8;
-
-#ifndef QT_NO_QWS_CURSOR
- // hardware cursors must be blended with the screen memory
- const bool doBlendCursor = qt_screencursor
- && !server->hasClientCursor()
- && qt_screencursor->isAccelerated();
- QImage tileImage;
- if (doBlendCursor) {
- const QRect cursorRect = qt_screencursor->boundingRect()
- .translated(-server->screen()->offset());
- if (tileRect.intersects(cursorRect)) {
- tileImage = screenImage.copy(tileRect);
- blendCursor(tileImage,
- tileRect.translated(server->screen()->offset()));
- screendata = tileImage.bits();
- linestep = tileImage.bytesPerLine();
- }
- }
-#endif // QT_NO_QWS_CURSOR
-
- if (server->doPixelConversion()) {
- const int bufferSize = rect.w * rect.h * bytesPerPixel;
- if (bufferSize > buffer.size())
- buffer.resize(bufferSize);
-
- // convert pixels
- char *b = buffer.data();
- const int bstep = rect.w * bytesPerPixel;
- for (int i = 0; i < rect.h; ++i) {
- server->convertPixels(b, (const char*)screendata, rect.w);
- screendata += linestep;
- b += bstep;
- }
- socket->write(buffer.constData(), bufferSize);
- } else {
- for (int i = 0; i < rect.h; ++i) {
- socket->write((const char*)screendata, rect.w * bytesPerPixel);
- screendata += linestep;
- }
- }
- if (socket->state() == QAbstractSocket::UnconnectedState)
- break;
- }
- socket->flush();
-
- QWSDisplay::ungrab();
-}
-
-inline QImage QVNCServer::screenImage() const
-{
- return QImage(qvnc_screen->base(), qvnc_screen->deviceWidth(),
- qvnc_screen->deviceHeight(), qvnc_screen->linestep(),
- qvnc_screen->pixelFormat());
-}
-
-void QVNCServer::checkUpdate()
-{
- if (!wantUpdate)
- return;
-
- if (dirtyCursor) {
-#ifndef QT_NO_QWS_CURSOR
- Q_ASSERT(qvnc_cursor);
- qvnc_cursor->write();
-#endif
- dirtyCursor = false;
- wantUpdate = false;
- return;
- }
-
- if (dirtyMap()->numDirty > 0) {
- if (encoder)
- encoder->write();
- wantUpdate = false;
- }
-}
-
-void QVNCServer::discardClient()
-{
- timer->stop();
- state = Unconnected;
- delete encoder;
- encoder = 0;
-#ifndef QT_NO_QWS_CURSOR
- delete qvnc_cursor;
- qvnc_cursor = 0;
-#endif
- if (!qvnc_screen->screen() && !qvnc_screen->d_ptr->noDisablePainting && QWSServer::instance())
- QWSServer::instance()->enablePainting(false);
-}
-
-
-//===========================================================================
-
-/*!
- \class QVNCScreen
- \internal
- \ingroup qws
-
- \brief The QVNCScreen class implements a screen driver for VNC
- servers.
-
- Note that this class is only available in \l{Qt for Embedded Linux}.
- Custom screen drivers can be added by subclassing the QScreen
- class, using the QScreenDriverFactory class to dynamically load
- the driver into the application.
-
- The VNC protocol allows you to view and interact with the
- computer's display from anywhere on the network. See the
- \l{The VNC Protocol and Qt for Embedded Linux}{VNC protocol}
- documentation for more details.
-
- The default implementation of QVNCScreen inherits QLinuxFbScreen,
- but any QScreen subclass, or QScreen itself, can serve as its base
- class. This is easily achieved by manipulating the \c
- VNCSCREEN_BASE definition in the header file.
-
- \sa QScreen, {Running Applications}
-*/
-
-/*!
- \fn QVNCScreen::QVNCScreen(int displayId)
-
- Constructs a QVNCScreen object. The \a displayId argument
- identifies the Qt for Embedded Linux server to connect to.
-*/
-QVNCScreen::QVNCScreen(int display_id)
- : QProxyScreen(display_id, VNCClass)
-{
- d_ptr = new QVNCScreenPrivate(this);
-}
-
-/*!
- Destroys this QVNCScreen object.
-*/
-QVNCScreen::~QVNCScreen()
-{
- delete d_ptr;
-}
-
-/*!
- \reimp
-*/
-void QVNCScreen::setDirty(const QRect &rect)
-{
- d_ptr->setDirty(rect);
-}
-
-void QVNCScreenPrivate::setDirty(const QRect& rect, bool force)
-{
- if (rect.isEmpty())
- return;
-
- if (q_ptr->screen())
- q_ptr->screen()->setDirty(rect);
-
- if (!vncServer || !vncServer->isConnected())
- return;
-
- const QRect r = rect.translated(-q_ptr->offset());
- const int x1 = r.x() / MAP_TILE_SIZE;
- int y = r.y() / MAP_TILE_SIZE;
- for (; (y <= r.bottom() / MAP_TILE_SIZE) && y < dirty->mapHeight; y++)
- for (int x = x1; (x <= r.right() / MAP_TILE_SIZE) && x < dirty->mapWidth; x++)
- dirty->setDirty(x, y, force);
-
- vncServer->setDirty();
-}
-
-static int getDisplayId(const QString &spec)
-{
- QRegExp regexp(QLatin1String(":(\\d+)\\b"));
- if (regexp.lastIndexIn(spec) != -1) {
- const QString capture = regexp.cap(1);
- return capture.toInt();
- }
- return 0;
-}
-
-/*!
- \reimp
-*/
-bool QVNCScreen::connect(const QString &displaySpec)
-{
- QString dspec = displaySpec;
- if (dspec.startsWith(QLatin1String("vnc:"), Qt::CaseInsensitive))
- dspec = dspec.mid(QString::fromLatin1("vnc:").size());
- else if (dspec.compare(QLatin1String("vnc"), Qt::CaseInsensitive) == 0)
- dspec = QString();
-
- const QString displayIdSpec = QString::fromLatin1(" :%1").arg(displayId);
- if (dspec.endsWith(displayIdSpec))
- dspec = dspec.left(dspec.size() - displayIdSpec.size());
-
- QStringList args = dspec.split(QLatin1Char(':'),
- QString::SkipEmptyParts);
- QRegExp refreshRegexp(QLatin1String("^refreshrate=(\\d+)$"));
- int index = args.indexOf(refreshRegexp);
- if (index >= 0) {
- d_ptr->refreshRate = refreshRegexp.cap(1).toInt();
- args.removeAt(index);
- dspec = args.join(QLatin1String(":"));
- }
-
- QString driver = dspec;
- int colon = driver.indexOf(QLatin1Char(':'));
- if (colon >= 0)
- driver.truncate(colon);
-
- if (QScreenDriverFactory::keys().contains(driver, Qt::CaseInsensitive)) {
- const int id = getDisplayId(dspec);
- QScreen *s = qt_get_screen(id, dspec.toLatin1().constData());
- if (s->pixelFormat() == QImage::Format_Indexed8
- || s->pixelFormat() == QImage::Format_Invalid && s->depth() == 8)
- qFatal("QVNCScreen: unsupported screen format");
- setScreen(s);
- } else { // create virtual screen
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- QScreen::setFrameBufferLittleEndian(false);
-#endif
-
- d = qgetenv("QWS_DEPTH").toInt();
- if (!d)
- d = 16;
-
- QByteArray str = qgetenv("QWS_SIZE");
- if(!str.isEmpty()) {
- sscanf(str.constData(), "%dx%d", &w, &h);
- dw = w;
- dh = h;
- } else {
- dw = w = 640;
- dh = h = 480;
- }
-
- const QStringList args = displaySpec.split(QLatin1Char(':'),
- QString::SkipEmptyParts);
-
- if (args.contains(QLatin1String("paintonscreen"), Qt::CaseInsensitive))
- d_ptr->doOnScreenSurface = true;
-
- QRegExp depthRegexp(QLatin1String("^depth=(\\d+)$"));
- if (args.indexOf(depthRegexp) != -1)
- d = depthRegexp.cap(1).toInt();
-
- QRegExp sizeRegexp(QLatin1String("^size=(\\d+)x(\\d+)$"));
- if (args.indexOf(sizeRegexp) != -1) {
- dw = w = sizeRegexp.cap(1).toInt();
- dh = h = sizeRegexp.cap(2).toInt();
- }
-
- // Handle display physical size spec.
- QRegExp mmWidthRegexp(QLatin1String("^mmWidth=?(\\d+)$"));
- if (args.indexOf(mmWidthRegexp) != -1) {
- const int mmWidth = mmWidthRegexp.cap(1).toInt();
- if (mmWidth > 0)
- d_ptr->dpiX = dw * 25.4 / mmWidth;
- }
- QRegExp mmHeightRegexp(QLatin1String("^mmHeight=?(\\d+)$"));
- if (args.indexOf(mmHeightRegexp) != -1) {
- const int mmHeight = mmHeightRegexp.cap(1).toInt();
- if (mmHeight > 0)
- d_ptr->dpiY = dh * 25.4 / mmHeight;
- }
- QRegExp dpiRegexp(QLatin1String("^dpi=(\\d+)(?:,(\\d+))?$"));
- if (args.indexOf(dpiRegexp) != -1) {
- const qreal dpiX = dpiRegexp.cap(1).toFloat();
- const qreal dpiY = dpiRegexp.cap(2).toFloat();
- if (dpiX > 0)
- d_ptr->dpiX = dpiX;
- d_ptr->dpiY = (dpiY > 0 ? dpiY : dpiX);
- }
-
- if (args.contains(QLatin1String("noDisablePainting")))
- d_ptr->noDisablePainting = true;
-
- QWSServer::setDefaultMouse("None");
- QWSServer::setDefaultKeyboard("None");
-
- d_ptr->configure();
- }
-
- // XXX
- qt_screen = this;
-
- return true;
-}
-
-/*!
- \reimp
-*/
-void QVNCScreen::disconnect()
-{
- QProxyScreen::disconnect();
-#if !defined(QT_NO_QWS_MULTIPROCESS) && !defined(QT_NO_SHAREDMEMORY)
- d_ptr->shm.detach();
-#endif
-}
-
-/*!
- \reimp
-*/
-bool QVNCScreen::initDevice()
-{
- if (!QProxyScreen::screen() && d == 4) {
- screencols = 16;
- int val = 0;
- for (int idx = 0; idx < 16; idx++, val += 17) {
- screenclut[idx] = qRgb(val, val, val);
- }
- }
- d_ptr->vncServer = new QVNCServer(this, displayId);
- d_ptr->vncServer->setRefreshRate(d_ptr->refreshRate);
-
- switch (depth()) {
-#ifdef QT_QWS_DEPTH_32
- case 32:
- d_ptr->dirty = new QVNCDirtyMapOptimized<quint32>(this);
- break;
-#endif
-#ifdef QT_QWS_DEPTH_24
- case 24:
- d_ptr->dirty = new QVNCDirtyMapOptimized<qrgb888>(this);
- break;
-#endif
-#ifdef QT_QWS_DEPTH_18
- case 18:
- d_ptr->dirty = new QVNCDirtyMapOptimized<qrgb666>(this);
- break;
-#endif
-#ifdef QT_QWS_DEPTH_16
- case 16:
- d_ptr->dirty = new QVNCDirtyMapOptimized<quint16>(this);
- break;
-#endif
-#ifdef QT_QWS_DEPTH_15
- case 15:
- d_ptr->dirty = new QVNCDirtyMapOptimized<qrgb555>(this);
- break;
-#endif
-#ifdef QT_QWS_DEPTH_12
- case 12:
- d_ptr->dirty = new QVNCDirtyMapOptimized<qrgb444>(this);
- break;
-#endif
-#ifdef QT_QWS_DEPTH_8
- case 8:
- d_ptr->dirty = new QVNCDirtyMapOptimized<quint8>(this);
- break;
-#endif
- default:
- qWarning("QVNCScreen::initDevice: No support for screen depth %d",
- depth());
- d_ptr->dirty = 0;
- return false;
- }
-
-
- const bool ok = QProxyScreen::initDevice();
-#ifndef QT_NO_QWS_CURSOR
- qt_screencursor = new QVNCCursor(this);
-#endif
- if (QProxyScreen::screen())
- return ok;
-
- // Disable painting if there is only 1 display and nothing is attached to the VNC server
- if (!d_ptr->noDisablePainting)
- QWSServer::instance()->enablePainting(false);
-
- return true;
-}
-
-/*!
- \reimp
-*/
-void QVNCScreen::shutdownDevice()
-{
- QProxyScreen::shutdownDevice();
- delete d_ptr->vncServer;
- delete d_ptr->dirty;
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_QWS_VNC
diff --git a/src/plugins/gfxdrivers/vnc/qscreenvnc_qws.h b/src/plugins/gfxdrivers/vnc/qscreenvnc_qws.h
deleted file mode 100644
index 646109f5ef..0000000000
--- a/src/plugins/gfxdrivers/vnc/qscreenvnc_qws.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QSCREENVNC_QWS_H
-#define QSCREENVNC_QWS_H
-
-#include <QtGui/qscreenproxy_qws.h>
-
-#ifndef QT_NO_QWS_VNC
-
-QT_BEGIN_HEADER
-
-QT_BEGIN_NAMESPACE
-
-QT_MODULE(Gui)
-
-class QVNCScreenPrivate;
-
-class QVNCScreen : public QProxyScreen
-{
-public:
- explicit QVNCScreen(int display_id);
- virtual ~QVNCScreen();
-
- bool initDevice();
- bool connect(const QString &displaySpec);
- void disconnect();
- void shutdownDevice();
-
- void setDirty(const QRect&);
-
-private:
- friend class QVNCCursor;
- friend class QVNCClientCursor;
- friend class QVNCServer;
- friend class QVNCScreenPrivate;
-
-#if Q_BYTE_ORDER == Q_BIG_ENDIAN
- bool swapBytes() const;
-#endif
-
- QVNCScreenPrivate *d_ptr;
-};
-
-QT_END_NAMESPACE
-
-QT_END_HEADER
-
-#endif // QT_NO_QWS_VNC
-#endif // QSCREENVNC_QWS_H
diff --git a/src/plugins/gfxdrivers/vnc/vnc.pro b/src/plugins/gfxdrivers/vnc/vnc.pro
deleted file mode 100644
index 48bad8c6e3..0000000000
--- a/src/plugins/gfxdrivers/vnc/vnc.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TARGET = qgfxvnc
-include(../../qpluginbase.pri)
-
-DEFINES += QT_QWS_VNC
-
-DESTDIR = $$QT.gui.plugins/gfxdrivers
-
-HEADERS = \
- qscreenvnc_qws.h \
- qscreenvnc_p.h
-
-SOURCES = main.cpp \
- qscreenvnc_qws.cpp
-
-target.path += $$[QT_INSTALL_PLUGINS]/gfxdrivers
-INSTALLS += target
diff --git a/src/plugins/graphicssystems/graphicssystems.pro b/src/plugins/graphicssystems/graphicssystems.pro
deleted file mode 100644
index 5c99291047..0000000000
--- a/src/plugins/graphicssystems/graphicssystems.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS += trace
-!wince*:contains(QT_CONFIG, opengl):SUBDIRS += opengl
-contains(QT_CONFIG, openvg):contains(QT_CONFIG, egl) {
- SUBDIRS += openvg
-}
-
-contains(QT_CONFIG, shivavg) {
- # Only works under X11 at present
- !win32:!embedded:!mac:SUBDIRS += shivavg
-}
-
-!win32:!embedded:!mac:!symbian:CONFIG += x11
-
-x11:contains(QT_CONFIG, opengles2):contains(QT_CONFIG, egl):SUBDIRS += meego
diff --git a/src/plugins/graphicssystems/meego/dithering.cpp b/src/plugins/graphicssystems/meego/dithering.cpp
deleted file mode 100644
index 2561c22ff6..0000000000
--- a/src/plugins/graphicssystems/meego/dithering.cpp
+++ /dev/null
@@ -1,266 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// Implements two dithering methods:
-//
-// * convertRGBA32_to_RGB565
-//
-// This is implemented using Ordered Bayer Dithering. The code has been adapted
-// from QX11PixmapData::fromImage. This method was originally implemented using
-// Floyd-Steinberg dithering but was later changed to Ordered Dithering because
-// of the better quality of the results.
-//
-// * convertRGBA32_to_RGBA4444
-//
-// This is implemented using Floyd-Steinberg dithering.
-//
-// The alghorithm used here is not the fastest possible but it's prolly fast enough:
-// uses look-up tables, integer-only arthmetics and works in one pass on two lines
-// at a time. It's a high-quality dithering using 1/8 diffusion precission.
-// Each channel (RGBA) is diffused independently and alpha is dithered too.
-
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <QVarLengthArray>
-
-// Gets a component (red = 1, green = 2...) from a RGBA data structure.
-// data is unsigned char. stride is the number of bytes per line.
-#define GET_RGBA_COMPONENT(data, x, y, stride, c) (data[(y * stride) + (x << 2) + c])
-
-// Writes a new pixel with r, g, b to data in 565 16bit format. Data is a short.
-#define PUT_565(data, x, y, width, r, g, b) (data[(y * width) + x] = (r << 11) | (g << 5) | b)
-
-// Writes a new pixel with r, g, b, a to data in 4444 RGBA 16bit format. Data is a short.
-#define PUT_4444(data, x, y, width, r, g, b, a) (data[(y * width) + x] = (r << 12) | (g << 8) | (b << 4) | a)
-
-// Writes(ads) a new value to the diffusion accumulator. accumulator is a short.
-// x, y is a position in the accumulation buffer. y can be 0 or 1 -- we operate on two lines at time.
-#define ACCUMULATE(accumulator, x, y, width, v) if (x < width && x >= 0) accumulator[(y * width) + x] += v
-
-// Clamps a value to be in 0..255 range.
-#define CLAMP_256(v) if (v > 255) v = 255; if (v < 0) v = 0;
-
-// Converts incoming RGB32 (QImage::Format_RGB32) to RGB565. Returns the newly allocated data.
-unsigned short* convertRGB32_to_RGB565(const unsigned char *in, int width, int height, int stride)
-{
- static bool thresholdMapInitialized = false;
- static int thresholdMap[16][16];
-
- if (!thresholdMapInitialized) {
- int i;
- int j;
- int n;
-
- thresholdMap[0][0] = 0;
- thresholdMap[1][0] = 2;
- thresholdMap[0][1] = 3;
- thresholdMap[1][1] = 1;
-
- for (n=2; n<16; n*=2) {
- for (i=0; i<n; i++) {
- for (j=0; j<n; j++) {
- thresholdMap[i][j] *= 4;
- thresholdMap[i+n][j] = thresholdMap[i][j] + 2;
- thresholdMap[i][j+n] = thresholdMap[i][j] + 3;
- thresholdMap[i+n][j+n] = thresholdMap[i][j] + 1;
- }
- }
- }
-
- thresholdMapInitialized = true;
- }
-
- // Output line stride. Aligned to 4 bytes.
- int alignedWidth = width;
- if (alignedWidth % 2 > 0)
- alignedWidth++;
-
- // Will store output
- unsigned short *out = (unsigned short *)malloc (alignedWidth * height * 2);
-
- int x;
- int y;
- int threshold;
-
- // For each line...
- for (y = 0; y < height; y++) {
-
- // For each column....
- for (x = 0; x < width; x++) {
-
- int r = GET_RGBA_COMPONENT(in, x, y, stride, 0);
- int g = GET_RGBA_COMPONENT(in, x, y, stride, 1);
- int b = GET_RGBA_COMPONENT(in, x, y, stride, 2);
-
- threshold = thresholdMap[x%16][y%16];
-
- if (r <= (255-(1<<3)) && ((r<<5) & 255) > threshold) r += (1<<3);
- if (g <= (255-(1<<2)) && ((g<<6) & 255) > threshold) g += (1<<2);
- if (b <= (255-(1<<3)) && ((b<<5) & 255) > threshold) b += (1<<3);
-
- // Write the newly produced pixel
- PUT_565(out, x, y, alignedWidth, ((b >> 3) & 0x1f), ((g >> 2) & 0x3f), ((r >> 3) & 0x1f));
- }
- }
-
- return out;
-}
-
-// Converts incoming RGBA32 (QImage::Format_ARGB32_Premultiplied) to RGB565. Returns the newly allocated data.
-// This function is similar (yet different) to the _565 variant but it makes sense to duplicate it here for simplicity.
-// The output has each scan line aligned to 4 bytes (as expected by GL by default).
-unsigned short* convertARGB32_to_RGBA4444(const unsigned char *in, int width, int height, int stride)
-{
- // Output line stride. Aligned to 4 bytes.
- int alignedWidth = width;
- if (alignedWidth % 2 > 0)
- alignedWidth++;
-
- // Will store output
- unsigned short *out = (unsigned short *) malloc(alignedWidth * 2 * height);
-
- // Lookup tables for the 8bit => 4bit conversion
- unsigned char lookup_8bit_to_4bit[256];
- short lookup_8bit_to_4bit_diff[256];
-
- // Macros for the conversion using the lookup table.
- #define CONVERT_8BIT_TO_4BIT(v) (lookup_8bit_to_4bit[v])
- #define DIFF_8BIT_TO_4BIT(v) (lookup_8bit_to_4bit_diff[v])
-
- int i;
- int x, y, c; // Pixel we're processing. c is component number (0, 1, 2, 3 for r, b, b, a)
- short component[4]; // Stores the new components (r, g, b, a) for pixel produced during conversion
- short diff; // The difference between the converted value and the original one. To be accumulated.
- QVarLengthArray <short> accumulatorData(4 * width * 2); // Data for three acumulators for r, g, b. Each accumulator is two lines.
- short *accumulator[4]; // Helper for accessing the accumulator on a per-channel basis more easily.
- accumulator[0] = accumulatorData.data();
- accumulator[1] = accumulatorData.data() + width;
- accumulator[2] = accumulatorData.data() + (width * 2);
- accumulator[3] = accumulatorData.data() + (width * 3);
-
- // Produce the conversion lookup tables.
- for (i = 0; i < 256; i++) {
- lookup_8bit_to_4bit[i] = round(i / 16.0);
- // Before bitshifts: (i * 8) - (... * 16 * 8)
- lookup_8bit_to_4bit_diff[i] = (i << 3) - (lookup_8bit_to_4bit[i] << 7);
-
- if (lookup_8bit_to_4bit[i] > 15)
- lookup_8bit_to_4bit[i] = 15;
- }
-
- // Clear the accumulators
- memset(accumulator[0], 0, width * 4);
- memset(accumulator[1], 0, width * 4);
- memset(accumulator[2], 0, width * 4);
- memset(accumulator[3], 0, width * 4);
-
- // For each line...
- for (y = 0; y < height; y++) {
-
- // For each component (r, g, b, a)...
- memcpy(accumulator[0], accumulator[0] + width, width * 2);
- memset(accumulator[0] + width, 0, width * 2);
-
- memcpy(accumulator[1], accumulator[1] + width, width * 2);
- memset(accumulator[1] + width, 0, width * 2);
-
- memcpy(accumulator[2], accumulator[2] + width, width * 2);
- memset(accumulator[2] + width, 0, width * 2);
-
- memcpy(accumulator[3], accumulator[3] + width, width * 2);
- memset(accumulator[3] + width, 0, width * 2);
-
- // For each column....
- for (x = 0; x < width; x++) {
-
- // For each component (r, g, b, a)...
- for (c = 0; c < 4; c++) {
-
- // Get the 8bit value from the original image
- component[c] = GET_RGBA_COMPONENT(in, x, y, stride, c);
-
- // Add the diffusion for this pixel we stored in the accumulator.
- // >> 7 because the values in accumulator are stored * 128
- component[c] += accumulator[c][x] >> 7;
-
- // Make sure we're not over the boundaries.
- CLAMP_256(component[c]);
-
- // Store the difference from converting 8bit => 4bit and the orig pixel.
- // Convert 8bit => 4bit.
- diff = DIFF_8BIT_TO_4BIT(component[c]);
- component[c] = CONVERT_8BIT_TO_4BIT(component[c]);
-
- // Distribute the difference according to the matrix in the
- // accumulation bufffer.
- ACCUMULATE(accumulator[c], x + 1, 0, width, diff * 7);
- ACCUMULATE(accumulator[c], x - 1, 1, width, diff * 3);
- ACCUMULATE(accumulator[c], x, 1, width, diff * 5);
- ACCUMULATE(accumulator[c], x + 1, 1, width, diff * 1);
- }
-
- // Write the newly produced pixel
- PUT_4444(out, x, y, alignedWidth, component[0], component[1], component[2], component[3]);
- }
- }
-
- return out;
-}
-
-unsigned char* convertBGRA32_to_RGBA32(const unsigned char *in, int width, int height, int stride)
-{
- unsigned char *out = (unsigned char *) malloc(stride * height);
-
- // For each line...
- for (int y = 0; y < height; y++) {
- // For each column
- for (int x = 0; x < width; x++) {
- out[(stride * y) + (x * 4) + 0] = in[(stride * y) + (x * 4) + 2];
- out[(stride * y) + (x * 4) + 1] = in[(stride * y) + (x * 4) + 1];
- out[(stride * y) + (x * 4) + 2] = in[(stride * y) + (x * 4) + 0];
- out[(stride * y) + (x * 4) + 3] = in[(stride * y) + (x * 4) + 3];
- }
- }
-
- return out;
-}
diff --git a/src/plugins/graphicssystems/meego/meego.pro b/src/plugins/graphicssystems/meego/meego.pro
deleted file mode 100644
index c497ba2eb6..0000000000
--- a/src/plugins/graphicssystems/meego/meego.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TARGET = qmeegographicssystem
-include(../../qpluginbase.pri)
-
-QT += gui opengl
-
-DESTDIR = $$QT.gui.plugins/graphicssystems
-
-HEADERS = qmeegographicssystem.h qmeegopixmapdata.h qmeegoextensions.h qmeegorasterpixmapdata.h qmeegolivepixmapdata.h
-SOURCES = qmeegographicssystem.cpp qmeegographicssystem.h qmeegographicssystemplugin.h qmeegographicssystemplugin.cpp qmeegopixmapdata.h qmeegopixmapdata.cpp qmeegoextensions.h qmeegoextensions.cpp qmeegorasterpixmapdata.h qmeegorasterpixmapdata.cpp qmeegolivepixmapdata.cpp qmeegolivepixmapdata.h dithering.cpp
-
-target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems
-INSTALLS += target
-
diff --git a/src/plugins/graphicssystems/meego/qmeegoextensions.cpp b/src/plugins/graphicssystems/meego/qmeegoextensions.cpp
deleted file mode 100644
index fb82747062..0000000000
--- a/src/plugins/graphicssystems/meego/qmeegoextensions.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmeegoextensions.h"
-#include <private/qeglcontext_p.h>
-#include <private/qpixmapdata_gl_p.h>
-
-bool QMeeGoExtensions::initialized = false;
-bool QMeeGoExtensions::hasImageShared = false;
-bool QMeeGoExtensions::hasSurfaceScaling = false;
-bool QMeeGoExtensions::hasLockSurface = false;
-bool QMeeGoExtensions::hasFenceSync = false;
-
-/* Extension funcs */
-
-typedef EGLBoolean (EGLAPIENTRY *eglQueryImageNOKFunc)(EGLDisplay, EGLImageKHR, EGLint, EGLint*);
-typedef EGLNativeSharedImageTypeNOK (EGLAPIENTRY *eglCreateSharedImageNOKFunc)(EGLDisplay, EGLImageKHR, EGLint*);
-typedef EGLBoolean (EGLAPIENTRY *eglDestroySharedImageNOKFunc)(EGLDisplay, EGLNativeSharedImageTypeNOK);
-typedef EGLBoolean (EGLAPIENTRY *eglSetSurfaceScalingNOKFunc)(EGLDisplay, EGLSurface, EGLint, EGLint, EGLint, EGLint);
-typedef EGLBoolean (EGLAPIENTRY *eglLockSurfaceKHRFunc)(EGLDisplay, EGLSurface, const EGLint*);
-typedef EGLBoolean (EGLAPIENTRY *eglUnlockSurfaceKHRFunc)(EGLDisplay, EGLSurface);
-typedef EGLSyncKHR (EGLAPIENTRY *eglCreateSyncKHRFunc)(EGLDisplay, EGLenum, const EGLint*);
-typedef EGLBoolean (EGLAPIENTRY *eglDestroySyncKHRFunc)(EGLDisplay, EGLSyncKHR);
-typedef EGLint (EGLAPIENTRY *eglClientWaitSyncKHRFunc)(EGLDisplay, EGLSyncKHR, EGLint, EGLTimeKHR);
-typedef EGLBoolean (EGLAPIENTRY *eglGetSyncAttribKHRFunc)(EGLDisplay, EGLSyncKHR, EGLint, EGLint*);
-
-static eglQueryImageNOKFunc _eglQueryImageNOK = 0;
-static eglCreateSharedImageNOKFunc _eglCreateSharedImageNOK = 0;
-static eglDestroySharedImageNOKFunc _eglDestroySharedImageNOK = 0;
-static eglSetSurfaceScalingNOKFunc _eglSetSurfaceScalingNOK = 0;
-static eglLockSurfaceKHRFunc _eglLockSurfaceKHR = 0;
-static eglUnlockSurfaceKHRFunc _eglUnlockSurfaceKHR = 0;
-static eglCreateSyncKHRFunc _eglCreateSyncKHR = 0;
-static eglDestroySyncKHRFunc _eglDestroySyncKHR = 0;
-static eglClientWaitSyncKHRFunc _eglClientWaitSyncKHR = 0;
-static eglGetSyncAttribKHRFunc _eglGetSyncAttribKHR = 0;
-
-/* Public */
-
-void QMeeGoExtensions::ensureInitialized()
-{
- if (!initialized)
- initialize();
-
- initialized = true;
-}
-
-EGLNativeSharedImageTypeNOK QMeeGoExtensions::eglCreateSharedImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint *props)
-{
- if (!hasImageShared)
- qFatal("EGL_NOK_image_shared not found but trying to use capability!");
-
- return _eglCreateSharedImageNOK(dpy, image, props);
-}
-
-bool QMeeGoExtensions::eglQueryImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint prop, EGLint *v)
-{
- if (!hasImageShared)
- qFatal("EGL_NOK_image_shared not found but trying to use capability!");
-
- return _eglQueryImageNOK(dpy, image, prop, v);
-}
-
-bool QMeeGoExtensions::eglDestroySharedImageNOK(EGLDisplay dpy, EGLNativeSharedImageTypeNOK img)
-{
- if (!hasImageShared)
- qFatal("EGL_NOK_image_shared not found but trying to use capability!");
-
- return _eglDestroySharedImageNOK(dpy, img);
-}
-
-bool QMeeGoExtensions::eglSetSurfaceScalingNOK(EGLDisplay dpy, EGLSurface surface, int x, int y, int width, int height)
-{
- if (!hasSurfaceScaling)
- qFatal("EGL_NOK_surface_scaling not found but trying to use capability!");
-
- return _eglSetSurfaceScalingNOK(dpy, surface, x, y, width, height);
-}
-
-bool QMeeGoExtensions::eglLockSurfaceKHR(EGLDisplay display, EGLSurface surface, const EGLint *attrib_list)
-{
- if (!hasLockSurface)
- qFatal("EGL_KHR_lock_surface2 not found but trying to use capability!");
-
- return _eglLockSurfaceKHR(display, surface, attrib_list);
-}
-
-bool QMeeGoExtensions::eglUnlockSurfaceKHR(EGLDisplay display, EGLSurface surface)
-{
- if (!hasLockSurface)
- qFatal("EGL_KHR_lock_surface2 not found but trying to use capability!");
-
- return _eglUnlockSurfaceKHR(display, surface);
-}
-
-EGLSyncKHR QMeeGoExtensions::eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list)
-{
- if (!hasFenceSync)
- qFatal("EGL_KHR_fence_sync not found but trying to use capability!");
-
- return _eglCreateSyncKHR(dpy, type, attrib_list);
-}
-
-bool QMeeGoExtensions::eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync)
-{
- if (!hasFenceSync)
- qFatal("EGL_KHR_fence_sync not found but trying to use capability!");
-
- return _eglDestroySyncKHR(dpy, sync);
-}
-
-EGLint QMeeGoExtensions::eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout)
-{
- if (!hasFenceSync)
- qFatal("EGL_KHR_fence_sync not found but trying to use capability!");
-
- return _eglClientWaitSyncKHR(dpy, sync, flags, timeout);
-}
-
-EGLBoolean QMeeGoExtensions::eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value)
-{
- if (!hasFenceSync)
- qFatal("EGL_KHR_fence_sync not found but trying to use capability!");
-
- return _eglGetSyncAttribKHR(dpy, sync, attribute, value);
-}
-
-/* Private */
-
-void QMeeGoExtensions::initialize()
-{
- QGLContext *ctx = (QGLContext *) QGLContext::currentContext();
- qt_resolve_eglimage_gl_extensions(ctx);
-
- if (QEgl::hasExtension("EGL_NOK_image_shared")) {
- qDebug("MeegoGraphics: found EGL_NOK_image_shared");
- _eglQueryImageNOK = (eglQueryImageNOKFunc) eglGetProcAddress("eglQueryImageNOK");
- _eglCreateSharedImageNOK = (eglCreateSharedImageNOKFunc) eglGetProcAddress("eglCreateSharedImageNOK");
- _eglDestroySharedImageNOK = (eglDestroySharedImageNOKFunc) eglGetProcAddress("eglDestroySharedImageNOK");
- _eglLockSurfaceKHR = (eglLockSurfaceKHRFunc) eglGetProcAddress("eglLockSurfaceKHR");
- _eglUnlockSurfaceKHR = (eglUnlockSurfaceKHRFunc) eglGetProcAddress("eglUnlockSurfaceKHR");
-
- Q_ASSERT(_eglQueryImageNOK && _eglCreateSharedImageNOK && _eglDestroySharedImageNOK);
- hasImageShared = true;
- }
-
- if (QEgl::hasExtension("EGL_NOK_surface_scaling")) {
- qDebug("MeegoGraphics: found EGL_NOK_surface_scaling");
- _eglSetSurfaceScalingNOK = (eglSetSurfaceScalingNOKFunc) eglGetProcAddress("eglSetSurfaceScalingNOK");
-
- Q_ASSERT(_eglSetSurfaceScalingNOK);
- hasSurfaceScaling = true;
- }
-
- if (QEgl::hasExtension("EGL_KHR_lock_surface2")) {
- qDebug("MeegoGraphics: found EGL_KHR_lock_surface2");
- _eglLockSurfaceKHR = (eglLockSurfaceKHRFunc) eglGetProcAddress("eglLockSurfaceKHR");
- _eglUnlockSurfaceKHR = (eglUnlockSurfaceKHRFunc) eglGetProcAddress("eglUnlockSurfaceKHR");
-
- Q_ASSERT(_eglLockSurfaceKHR && _eglUnlockSurfaceKHR);
- hasLockSurface = true;
- }
-
- if (QEgl::hasExtension("EGL_KHR_fence_sync")) {
- qDebug("MeegoGraphics: found EGL_KHR_fence_sync");
- _eglCreateSyncKHR = (eglCreateSyncKHRFunc) eglGetProcAddress("eglCreateSyncKHR");
- _eglDestroySyncKHR = (eglDestroySyncKHRFunc) eglGetProcAddress("eglDestroySyncKHR");
- _eglClientWaitSyncKHR = (eglClientWaitSyncKHRFunc) eglGetProcAddress("eglClientWaitSyncKHR");
- _eglGetSyncAttribKHR = (eglGetSyncAttribKHRFunc) eglGetProcAddress("eglGetSyncAttribKHR");
-
- Q_ASSERT(_eglCreateSyncKHR && _eglDestroySyncKHR && _eglClientWaitSyncKHR && _eglGetSyncAttribKHR);
- hasFenceSync = true;
- }
-}
-
diff --git a/src/plugins/graphicssystems/meego/qmeegoextensions.h b/src/plugins/graphicssystems/meego/qmeegoextensions.h
deleted file mode 100644
index 76d3fec4cf..0000000000
--- a/src/plugins/graphicssystems/meego/qmeegoextensions.h
+++ /dev/null
@@ -1,125 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MEXTENSIONS_H
-#define MEXTENSIONS_H
-
-#include <private/qgl_p.h>
-#include <private/qeglcontext_p.h>
-#include <private/qpixmapdata_gl_p.h>
-#include <EGL/egl.h>
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-
-/* Extensions decls */
-
-#ifndef EGL_SHARED_IMAGE_NOK
-#define EGL_SHARED_IMAGE_NOK 0x30DA
-typedef void* EGLNativeSharedImageTypeNOK;
-#endif
-
-#ifndef EGL_GL_TEXTURE_2D_KHR
-#define EGL_GL_TEXTURE_2D_KHR 0x30B1
-#endif
-
-#ifndef EGL_FIXED_WIDTH_NOK
-#define EGL_FIXED_WIDTH_NOK 0x30DB
-#define EGL_FIXED_HEIGHT_NOK 0x30DC
-#endif
-
-#ifndef EGL_BITMAP_POINTER_KHR
-#define EGL_BITMAP_POINTER_KHR 0x30C6
-#define EGL_BITMAP_PITCH_KHR 0x30C7
-#endif
-
-#ifndef EGL_MAP_PRESERVE_PIXELS_KHR
-#define EGL_MAP_PRESERVE_PIXELS_KHR 0x30C4
-#define EGL_LOCK_USAGE_HINT_KHR 0x30C5
-#define EGL_READ_SURFACE_BIT_KHR 0x0001
-#define EGL_WRITE_SURFACE_BIT_KHR 0x0002
-#endif
-
-#ifndef EGL_SYNC_FENCE_KHR
-#define EGL_SYNC_FENCE_KHR 0x30F9
-#define EGL_SYNC_TYPE_KHR 0x30F7
-#define EGL_SYNC_STATUS_KHR 0x30F1
-#define EGL_SYNC_CONDITION_KHR 0x30F8
-#define EGL_SIGNALED_KHR 0x30F2
-#define EGL_UNSIGNALED_KHR 0x30F3
-#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0
-#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001
-#define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull
-#define EGL_TIMEOUT_EXPIRED_KHR 0x30F5
-#define EGL_CONDITION_SATISFIED_KHR 0x30F6
-#define EGL_NO_SYNC_KHR ((EGLSyncKHR)0)
-typedef void* EGLSyncKHR;
-typedef khronos_utime_nanoseconds_t EGLTimeKHR;
-#endif
-
-/* Class */
-
-class QMeeGoExtensions
-{
-public:
- static void ensureInitialized();
-
- static EGLNativeSharedImageTypeNOK eglCreateSharedImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint *props);
- static bool eglQueryImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint prop, EGLint *v);
- static bool eglDestroySharedImageNOK(EGLDisplay dpy, EGLNativeSharedImageTypeNOK img);
- static bool eglSetSurfaceScalingNOK(EGLDisplay dpy, EGLSurface surface, int x, int y, int width, int height);
- static bool eglLockSurfaceKHR(EGLDisplay display, EGLSurface surface, const EGLint *attrib_list);
- static bool eglUnlockSurfaceKHR(EGLDisplay display, EGLSurface surface);
- static EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list);
- static bool eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync);
- static EGLint eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout);
- static EGLBoolean eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value);
-
-private:
- static void initialize();
-
- static bool initialized;
- static bool hasImageShared;
- static bool hasSurfaceScaling;
- static bool hasLockSurface;
- static bool hasFenceSync;
-};
-
-#endif
diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp
deleted file mode 100644
index fdb72de648..0000000000
--- a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp
+++ /dev/null
@@ -1,534 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QDebug>
-#include <private/qpixmap_raster_p.h>
-#include <private/qwindowsurface_gl_p.h>
-#include <private/qwindowsurface_raster_p.h>
-#include <private/qegl_p.h>
-#include <private/qglextensions_p.h>
-#include <private/qgl_p.h>
-#include <private/qimagepixmapcleanuphooks_p.h>
-#include <private/qapplication_p.h>
-#include <private/qgraphicssystem_runtime_p.h>
-#include <private/qimage_p.h>
-#include <private/qeglproperties_p.h>
-#include <private/qeglcontext_p.h>
-#include <private/qpixmap_x11_p.h>
-
-#include "qmeegopixmapdata.h"
-#include "qmeegolivepixmapdata.h"
-#include "qmeegographicssystem.h"
-#include "qmeegoextensions.h"
-
-#include <QTimer>
-
-bool QMeeGoGraphicsSystem::surfaceWasCreated = false;
-
-QHash <Qt::HANDLE, QPixmap*> QMeeGoGraphicsSystem::liveTexturePixmaps;
-
-QList<QMeeGoSwitchCallback> QMeeGoGraphicsSystem::switchCallbacks;
-
-QMeeGoGraphicsSystem::SwitchPolicy QMeeGoGraphicsSystem::switchPolicy = QMeeGoGraphicsSystem::AutomaticSwitch;
-
-QMeeGoGraphicsSystem::QMeeGoGraphicsSystem()
-{
- qDebug("Using the meego graphics system");
-}
-
-QMeeGoGraphicsSystem::~QMeeGoGraphicsSystem()
-{
- qDebug("Meego graphics system destroyed");
- qt_destroy_gl_share_widget();
-}
-
-class QMeeGoGraphicsSystemSwitchHandler : public QObject
-{
- Q_OBJECT
-public:
- QMeeGoGraphicsSystemSwitchHandler();
-
- void addWidget(QWidget *widget);
- bool eventFilter(QObject *, QEvent *);
-
- void handleMapNotify();
-
-private slots:
- void removeWidget(QObject *object);
- void switchToRaster();
- void switchToMeeGo();
-
-private:
- int visibleWidgets() const;
-
-private:
- QList<QWidget *> m_widgets;
-};
-
-typedef bool(*QX11FilterFunction)(XEvent *event);
-Q_GUI_EXPORT void qt_installX11EventFilter(QX11FilterFunction func);
-
-static bool x11EventFilter(XEvent *event);
-
-QMeeGoGraphicsSystemSwitchHandler::QMeeGoGraphicsSystemSwitchHandler()
-{
- qt_installX11EventFilter(x11EventFilter);
-}
-
-void QMeeGoGraphicsSystemSwitchHandler::addWidget(QWidget *widget)
-{
- if (widget != qt_gl_share_widget() && !m_widgets.contains(widget)) {
- widget->installEventFilter(this);
- connect(widget, SIGNAL(destroyed(QObject *)), this, SLOT(removeWidget(QObject *)));
- m_widgets << widget;
- }
-}
-
-void QMeeGoGraphicsSystemSwitchHandler::handleMapNotify()
-{
- if (m_widgets.isEmpty() && QMeeGoGraphicsSystem::switchPolicy == QMeeGoGraphicsSystem::AutomaticSwitch)
- QTimer::singleShot(0, this, SLOT(switchToMeeGo()));
-}
-
-void QMeeGoGraphicsSystemSwitchHandler::removeWidget(QObject *object)
-{
- m_widgets.removeOne(static_cast<QWidget *>(object));
- if (m_widgets.isEmpty() && QMeeGoGraphicsSystem::switchPolicy == QMeeGoGraphicsSystem::AutomaticSwitch)
- QTimer::singleShot(0, this, SLOT(switchToRaster()));
-}
-
-void QMeeGoGraphicsSystemSwitchHandler::switchToRaster()
-{
- QMeeGoGraphicsSystem::switchToRaster();
-}
-
-void QMeeGoGraphicsSystemSwitchHandler::switchToMeeGo()
-{
- QMeeGoGraphicsSystem::switchToMeeGo();
-}
-
-int QMeeGoGraphicsSystemSwitchHandler::visibleWidgets() const
-{
- int count = 0;
- for (int i = 0; i < m_widgets.size(); ++i)
- count += m_widgets.at(i)->isVisible() && !(m_widgets.at(i)->windowState() & Qt::WindowMinimized);
- return count;
-}
-
-bool QMeeGoGraphicsSystemSwitchHandler::eventFilter(QObject *object, QEvent *event)
-{
- if (event->type() == QEvent::WindowStateChange
- && QMeeGoGraphicsSystem::switchPolicy == QMeeGoGraphicsSystem::AutomaticSwitch)
- {
- QWindowStateChangeEvent *change = static_cast<QWindowStateChangeEvent *>(event);
- QWidget *widget = static_cast<QWidget *>(object);
-
- Qt::WindowStates current = widget->windowState();
- Qt::WindowStates old = change->oldState();
-
- // did minimized flag change?
- if ((current ^ old) & Qt::WindowMinimized) {
- if (current & Qt::WindowMinimized) {
- if (visibleWidgets() == 0)
- QMeeGoGraphicsSystem::switchToRaster();
- } else {
- if (visibleWidgets() > 0)
- QMeeGoGraphicsSystem::switchToMeeGo();
- }
- }
- }
-
- // resume processing of event
- return false;
-}
-
-Q_GLOBAL_STATIC(QMeeGoGraphicsSystemSwitchHandler, switch_handler)
-
-bool x11EventFilter(XEvent *event)
-{
- if (event->type == MapNotify)
- switch_handler()->handleMapNotify();
- return false;
-}
-
-QWindowSurface* QMeeGoGraphicsSystem::createWindowSurface(QWidget *widget) const
-{
- QGLWidget *shareWidget = qt_gl_share_widget();
-
- if (!shareWidget)
- return new QRasterWindowSurface(widget);
-
- QGLShareContextScope ctx(shareWidget->context());
-
- if (QApplicationPrivate::instance()->graphics_system_name == QLatin1String("runtime"))
- switch_handler()->addWidget(widget);
-
- QMeeGoGraphicsSystem::surfaceWasCreated = true;
- QWindowSurface *surface = new QGLWindowSurface(widget);
- return surface;
-}
-
-QPixmapData *QMeeGoGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const
-{
- return new QRasterPixmapData(type);
-}
-
-QPixmapData *QMeeGoGraphicsSystem::createPixmapData(QPixmapData *origin)
-{
- // If the pixmap is a raster type...
- // and if the pixmap pointer matches our mapping...
- // create a shared image instead with the given handle.
-
- if (!origin->isNull() && origin->classId() == QPixmapData::RasterClass) {
- QRasterPixmapData *rasterClass = static_cast <QRasterPixmapData *> (origin);
- void *rawResource = static_cast <void *> (rasterClass->buffer()->data_ptr()->data);
-
- if (QMeeGoPixmapData::sharedImagesMap.contains(rawResource))
- return new QMeeGoPixmapData();
- }
-
- return new QRasterPixmapData(origin->pixelType());
-}
-
-QPixmapData* QMeeGoGraphicsSystem::wrapPixmapData(QPixmapData *pmd)
-{
- QString name = QApplicationPrivate::instance()->graphics_system_name;
- if (name == "runtime") {
- QRuntimeGraphicsSystem *rsystem = (QRuntimeGraphicsSystem *) QApplicationPrivate::instance()->graphics_system;
- QRuntimePixmapData *rt = new QRuntimePixmapData(rsystem, pmd->pixelType());;
- rt->m_data = pmd;
- rt->readBackInfo();
- rsystem->m_pixmapDatas << rt;
- return rt;
- } else
- return pmd;
-}
-
-void QMeeGoGraphicsSystem::setSurfaceFixedSize(int /*width*/, int /*height*/)
-{
- if (QMeeGoGraphicsSystem::surfaceWasCreated) {
- qWarning("Trying to set surface fixed size but surface already created!");
- return;
- }
-
-#ifdef QT_WAS_PATCHED
- QEglProperties *properties = new QEglProperties();
- properties->setValue(EGL_FIXED_WIDTH_NOK, width);
- properties->setValue(EGL_FIXED_HEIGHT_NOK, height);
- QGLContextPrivate::setExtraWindowSurfaceCreationProps(properties);
-#endif
-}
-
-void QMeeGoGraphicsSystem::setSurfaceScaling(int x, int y, int width, int height)
-{
- QMeeGoExtensions::ensureInitialized();
- QMeeGoExtensions::eglSetSurfaceScalingNOK(QEgl::display(), QEglContext::currentContext(QEgl::OpenGL)->currentSurface, x, y, width, height);
-}
-
-void QMeeGoGraphicsSystem::setTranslucent(bool translucent)
-{
- if (QMeeGoGraphicsSystem::surfaceWasCreated) {
- qWarning("Trying to set translucency but surface already created!");
- return;
- }
-
- QGLWindowSurface::surfaceFormat.setSampleBuffers(false);
- QGLWindowSurface::surfaceFormat.setSamples(0);
- QGLWindowSurface::surfaceFormat.setAlpha(translucent);
-}
-
-QPixmapData *QMeeGoGraphicsSystem::pixmapDataFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage)
-{
- if (softImage.format() != QImage::Format_ARGB32_Premultiplied &&
- softImage.format() != QImage::Format_RGB32) {
- qFatal("For egl shared images, the soft image has to be ARGB32_Premultiplied or RGB32");
- return NULL;
- }
-
- if (QMeeGoGraphicsSystem::meeGoRunning()) {
- QMeeGoPixmapData *pmd = new QMeeGoPixmapData;
- pmd->fromEGLSharedImage(handle, softImage);
- return QMeeGoGraphicsSystem::wrapPixmapData(pmd);
- } else {
- QRasterPixmapData *pmd = new QRasterPixmapData(QPixmapData::PixmapType);
- pmd->fromImage(softImage, Qt::NoFormatConversion);
-
- // Make sure that the image was not converted in any way
- if (pmd->buffer()->data_ptr()->data !=
- const_cast<QImage &>(softImage).data_ptr()->data)
- qFatal("Iternal misalignment of raster data detected. Prolly a QImage copy fail.");
-
- QMeeGoPixmapData::registerSharedImage(handle, softImage);
- return QMeeGoGraphicsSystem::wrapPixmapData(pmd);
- }
-}
-
-void QMeeGoGraphicsSystem::updateEGLSharedImagePixmap(QPixmap *pixmap)
-{
- QMeeGoPixmapData *pmd = (QMeeGoPixmapData *) pixmap->pixmapData();
-
- // Basic sanity check to make sure this is really a QMeeGoPixmapData...
- if (pmd->classId() != QPixmapData::OpenGLClass)
- qFatal("Trying to updated EGLSharedImage pixmap but it's not really a shared image pixmap!");
-
- pmd->updateFromSoftImage();
-}
-
-QPixmapData *QMeeGoGraphicsSystem::pixmapDataWithGLTexture(int w, int h)
-{
- QGLPixmapData *pmd = new QGLPixmapData(QPixmapData::PixmapType);
- pmd->resize(w, h);
- return QMeeGoGraphicsSystem::wrapPixmapData(pmd);
-}
-
-bool QMeeGoGraphicsSystem::meeGoRunning()
-{
- return runningGraphicsSystemName() == "meego";
-}
-
-QPixmapData* QMeeGoGraphicsSystem::pixmapDataWithNewLiveTexture(int w, int h, QImage::Format format)
-{
- return new QMeeGoLivePixmapData(w, h, format);
-}
-
-QPixmapData* QMeeGoGraphicsSystem::pixmapDataFromLiveTextureHandle(Qt::HANDLE handle)
-{
- return new QMeeGoLivePixmapData(handle);
-}
-
-QImage* QMeeGoGraphicsSystem::lockLiveTexture(QPixmap* pixmap, void* fenceSync)
-{
- QMeeGoLivePixmapData *pixmapData = static_cast<QMeeGoLivePixmapData*>(pixmap->data_ptr().data());
- return pixmapData->lock(fenceSync);
-}
-
-bool QMeeGoGraphicsSystem::releaseLiveTexture(QPixmap *pixmap, QImage *image)
-{
- QMeeGoLivePixmapData *pixmapData = static_cast<QMeeGoLivePixmapData*>(pixmap->data_ptr().data());
- return pixmapData->release(image);
-}
-
-Qt::HANDLE QMeeGoGraphicsSystem::getLiveTextureHandle(QPixmap *pixmap)
-{
- QMeeGoLivePixmapData *pixmapData = static_cast<QMeeGoLivePixmapData*>(pixmap->data_ptr().data());
- return pixmapData->handle();
-}
-
-void* QMeeGoGraphicsSystem::createFenceSync()
-{
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
- QMeeGoExtensions::ensureInitialized();
- return QMeeGoExtensions::eglCreateSyncKHR(QEgl::display(), EGL_SYNC_FENCE_KHR, NULL);
-}
-
-void QMeeGoGraphicsSystem::destroyFenceSync(void *fenceSync)
-{
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
- QMeeGoExtensions::ensureInitialized();
- QMeeGoExtensions::eglDestroySyncKHR(QEgl::display(), fenceSync);
-}
-
-QString QMeeGoGraphicsSystem::runningGraphicsSystemName()
-{
- if (!QApplicationPrivate::instance()) {
- qWarning("Querying graphics system but application not running yet!");
- return QString();
- }
-
- QString name = QApplicationPrivate::instance()->graphics_system_name;
- if (name == QLatin1String("runtime")) {
- QRuntimeGraphicsSystem *rsystem = (QRuntimeGraphicsSystem *) QApplicationPrivate::instance()->graphics_system;
- name = rsystem->graphicsSystemName();
- }
-
- return name;
-}
-
-void QMeeGoGraphicsSystem::switchToMeeGo()
-{
- if (switchPolicy == NoSwitch || meeGoRunning())
- return;
-
- if (QApplicationPrivate::instance()->graphics_system_name != QLatin1String("runtime"))
- qWarning("Can't switch to meego - switching only supported with 'runtime' graphics system.");
- else {
- triggerSwitchCallbacks(0, "meego");
-
- QApplication *app = static_cast<QApplication *>(QCoreApplication::instance());
- app->setGraphicsSystem(QLatin1String("meego"));
-
- triggerSwitchCallbacks(1, "meego");
- }
-}
-
-void QMeeGoGraphicsSystem::switchToRaster()
-{
- if (switchPolicy == NoSwitch || runningGraphicsSystemName() == QLatin1String("raster"))
- return;
-
- if (QApplicationPrivate::instance()->graphics_system_name != QLatin1String("runtime"))
- qWarning("Can't switch to raster - switching only supported with 'runtime' graphics system.");
- else {
- triggerSwitchCallbacks(0, "raster");
-
- QApplication *app = static_cast<QApplication *>(QCoreApplication::instance());
- app->setGraphicsSystem(QLatin1String("raster"));
-
- QMeeGoLivePixmapData::invalidateSurfaces();
-
- triggerSwitchCallbacks(1, "raster");
- }
-}
-
-void QMeeGoGraphicsSystem::registerSwitchCallback(QMeeGoSwitchCallback callback)
-{
- switchCallbacks << callback;
-}
-
-void QMeeGoGraphicsSystem::triggerSwitchCallbacks(int type, const char *name)
-{
- for (int i = 0; i < switchCallbacks.size(); ++i)
- switchCallbacks.at(i)(type, name);
-}
-
-/* C API */
-
-int qt_meego_image_to_egl_shared_image(const QImage &image)
-{
- return QMeeGoPixmapData::imageToEGLSharedImage(image);
-}
-
-QPixmapData* qt_meego_pixmapdata_from_egl_shared_image(Qt::HANDLE handle, const QImage &softImage)
-{
- return QMeeGoGraphicsSystem::pixmapDataFromEGLSharedImage(handle, softImage);
-}
-
-QPixmapData* qt_meego_pixmapdata_with_gl_texture(int w, int h)
-{
- return QMeeGoGraphicsSystem::pixmapDataWithGLTexture(w, h);
-}
-
-bool qt_meego_destroy_egl_shared_image(Qt::HANDLE handle)
-{
- return QMeeGoPixmapData::destroyEGLSharedImage(handle);
-}
-
-void qt_meego_set_surface_fixed_size(int width, int height)
-{
- QMeeGoGraphicsSystem::setSurfaceFixedSize(width, height);
-}
-
-void qt_meego_set_surface_scaling(int x, int y, int width, int height)
-{
- QMeeGoGraphicsSystem::setSurfaceScaling(x, y, width, height);
-}
-
-void qt_meego_set_translucent(bool translucent)
-{
- QMeeGoGraphicsSystem::setTranslucent(translucent);
-}
-
-void qt_meego_update_egl_shared_image_pixmap(QPixmap *pixmap)
-{
- QMeeGoGraphicsSystem::updateEGLSharedImagePixmap(pixmap);
-}
-
-QPixmapData* qt_meego_pixmapdata_with_new_live_texture(int w, int h, QImage::Format format)
-{
- return QMeeGoGraphicsSystem::pixmapDataWithNewLiveTexture(w, h, format);
-}
-
-QPixmapData* qt_meego_pixmapdata_from_live_texture_handle(Qt::HANDLE handle)
-{
- return QMeeGoGraphicsSystem::pixmapDataFromLiveTextureHandle(handle);
-}
-
-QImage* qt_meego_live_texture_lock(QPixmap *pixmap, void *fenceSync)
-{
- return QMeeGoGraphicsSystem::lockLiveTexture(pixmap, fenceSync);
-}
-
-bool qt_meego_live_texture_release(QPixmap *pixmap, QImage *image)
-{
- return QMeeGoGraphicsSystem::releaseLiveTexture(pixmap, image);
-}
-
-Qt::HANDLE qt_meego_live_texture_get_handle(QPixmap *pixmap)
-{
- return QMeeGoGraphicsSystem::getLiveTextureHandle(pixmap);
-}
-
-void* qt_meego_create_fence_sync(void)
-{
- return QMeeGoGraphicsSystem::createFenceSync();
-}
-
-void qt_meego_destroy_fence_sync(void* fs)
-{
- return QMeeGoGraphicsSystem::destroyFenceSync(fs);
-}
-
-void qt_meego_invalidate_live_surfaces(void)
-{
- return QMeeGoLivePixmapData::invalidateSurfaces();
-}
-
-void qt_meego_switch_to_raster(void)
-{
- QMeeGoGraphicsSystem::switchToRaster();
-}
-
-void qt_meego_switch_to_meego(void)
-{
- QMeeGoGraphicsSystem::switchToMeeGo();
-}
-
-void qt_meego_register_switch_callback(QMeeGoSwitchCallback callback)
-{
- QMeeGoGraphicsSystem::registerSwitchCallback(callback);
-}
-
-void qt_meego_set_switch_policy(int policy)
-{
- QMeeGoGraphicsSystem::switchPolicy = QMeeGoGraphicsSystem::SwitchPolicy(policy);
-}
-
-#include "qmeegographicssystem.moc"
diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.h b/src/plugins/graphicssystems/meego/qmeegographicssystem.h
deleted file mode 100644
index 352842546f..0000000000
--- a/src/plugins/graphicssystems/meego/qmeegographicssystem.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MGRAPHICSSYSTEM_H
-#define MGRAPHICSSYSTEM_H
-
-#include <private/qgraphicssystem_p.h>
-#include <EGL/egl.h>
-#include <GLES2/gl2.h>
-#include <GLES2/gl2ext.h>
-
-extern "C" typedef void (*QMeeGoSwitchCallback)(int type, const char *name);
-
-class QMeeGoGraphicsSystem : public QGraphicsSystem
-{
-public:
- enum SwitchPolicy { AutomaticSwitch, ManualSwitch, NoSwitch };
-
- QMeeGoGraphicsSystem();
- ~QMeeGoGraphicsSystem();
-
- virtual QWindowSurface *createWindowSurface(QWidget *widget) const;
- virtual QPixmapData *createPixmapData(QPixmapData::PixelType) const;
- virtual QPixmapData *createPixmapData(QPixmapData *origin);
-
- static QPixmapData *wrapPixmapData(QPixmapData *pmd);
- static void setSurfaceFixedSize(int width, int height);
- static void setSurfaceScaling(int x, int y, int width, int height);
- static void setTranslucent(bool translucent);
-
- static QPixmapData *pixmapDataFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage);
- static QPixmapData *pixmapDataFromEGLImage(Qt::HANDLE handle);
- static QPixmapData *pixmapDataWithGLTexture(int w, int h);
- static void updateEGLSharedImagePixmap(QPixmap *pixmap);
-
- static QPixmapData *pixmapDataWithNewLiveTexture(int w, int h, QImage::Format format);
- static QPixmapData *pixmapDataFromLiveTextureHandle(Qt::HANDLE handle);
- static QImage *lockLiveTexture(QPixmap* pixmap, void* fenceSync);
- static bool releaseLiveTexture(QPixmap *pixmap, QImage *image);
- static Qt::HANDLE getLiveTextureHandle(QPixmap *pixmap);
-
- static void* createFenceSync();
- static void destroyFenceSync(void* fenceSync);
-
- static void switchToRaster();
- static void switchToMeeGo();
- static QString runningGraphicsSystemName();
-
- static void registerSwitchCallback(QMeeGoSwitchCallback callback);
-
- static SwitchPolicy switchPolicy;
-
-private:
- static bool meeGoRunning();
- static EGLSurface getSurfaceForLiveTexturePixmap(QPixmap *pixmap);
- static void destroySurfaceForLiveTexturePixmap(QPixmapData* pmd);
- static void triggerSwitchCallbacks(int type, const char *name);
-
- static bool surfaceWasCreated;
- static QHash<Qt::HANDLE, QPixmap*> liveTexturePixmaps;
- static QList<QMeeGoSwitchCallback> switchCallbacks;
-};
-
-/* C api */
-
-extern "C" {
- Q_DECL_EXPORT int qt_meego_image_to_egl_shared_image(const QImage &image);
- Q_DECL_EXPORT QPixmapData* qt_meego_pixmapdata_from_egl_shared_image(Qt::HANDLE handle, const QImage &softImage);
- Q_DECL_EXPORT QPixmapData* qt_meego_pixmapdata_with_gl_texture(int w, int h);
- Q_DECL_EXPORT void qt_meego_update_egl_shared_image_pixmap(QPixmap *pixmap);
- Q_DECL_EXPORT bool qt_meego_destroy_egl_shared_image(Qt::HANDLE handle);
- Q_DECL_EXPORT void qt_meego_set_surface_fixed_size(int width, int height);
- Q_DECL_EXPORT void qt_meego_set_surface_scaling(int x, int y, int width, int height);
- Q_DECL_EXPORT void qt_meego_set_translucent(bool translucent);
- Q_DECL_EXPORT QPixmapData* qt_meego_pixmapdata_with_new_live_texture(int w, int h, QImage::Format format);
- Q_DECL_EXPORT QPixmapData* qt_meego_pixmapdata_from_live_texture_handle(Qt::HANDLE handle);
- Q_DECL_EXPORT QImage* qt_meego_live_texture_lock(QPixmap *pixmap, void *fenceSync);
- Q_DECL_EXPORT bool qt_meego_live_texture_release(QPixmap *pixmap, QImage *image);
- Q_DECL_EXPORT Qt::HANDLE qt_meego_live_texture_get_handle(QPixmap *pixmap);
- Q_DECL_EXPORT void* qt_meego_create_fence_sync(void);
- Q_DECL_EXPORT void qt_meego_destroy_fence_sync(void* fs);
- Q_DECL_EXPORT void qt_meego_invalidate_live_surfaces(void);
- Q_DECL_EXPORT void qt_meego_switch_to_raster(void);
- Q_DECL_EXPORT void qt_meego_switch_to_meego(void);
- Q_DECL_EXPORT void qt_meego_register_switch_callback(QMeeGoSwitchCallback callback);
- Q_DECL_EXPORT void qt_meego_set_switch_policy(int policy);
-}
-
-#endif
diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp b/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp
deleted file mode 100644
index c7410c2b88..0000000000
--- a/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QDebug>
-#include "qmeegographicssystemplugin.h"
-#include "qmeegographicssystem.h"
-
-QStringList QMeeGoGraphicsSystemPlugin::keys() const
-{
- QStringList list;
- list << "meego";
- return list;
-}
-
-QGraphicsSystem *QMeeGoGraphicsSystemPlugin::create(const QString&)
-{
- return new QMeeGoGraphicsSystem;
-}
-
-Q_EXPORT_PLUGIN2(meego, QMeeGoGraphicsSystemPlugin)
diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h b/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h
deleted file mode 100644
index 1fc884476a..0000000000
--- a/src/plugins/graphicssystems/meego/qmeegographicssystemplugin.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MGRAPHICSSYSTEMPLUGIN_H
-#define MGRAPHICSSYSTEMPLUGIN_H
-
-#include <private/qgraphicssystemplugin_p.h>
-
-class QMeeGoGraphicsSystemPlugin : public QGraphicsSystemPlugin
-{
-public:
- virtual QStringList keys() const;
- virtual QGraphicsSystem *create(const QString&);
-};
-
-#endif
diff --git a/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.cpp b/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.cpp
deleted file mode 100644
index b6ba7ec29f..0000000000
--- a/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.cpp
+++ /dev/null
@@ -1,323 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmeegolivepixmapdata.h"
-#include "qmeegorasterpixmapdata.h"
-#include <private/qimage_p.h>
-#include <private/qwindowsurface_gl_p.h>
-#include <private/qeglcontext_p.h>
-#include <private/qapplication_p.h>
-#include <private/qgraphicssystem_runtime_p.h>
-#include <private/qpixmap_x11_p.h>
-#include <stdio.h>
-
-static QMeeGoLivePixmapDataList all_live_pixmaps;
-
-static EGLint lock_attribs[] = {
- EGL_MAP_PRESERVE_PIXELS_KHR, EGL_TRUE,
- EGL_LOCK_USAGE_HINT_KHR, EGL_READ_SURFACE_BIT_KHR | EGL_WRITE_SURFACE_BIT_KHR,
- EGL_NONE
-};
-
-static EGLint preserved_attribs[] = {
- EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
- EGL_NONE
-};
-
-// as copied from qwindowsurface.cpp
-void qt_scrollRectInImage(QImage &img, const QRect &rect, const QPoint &offset)
-{
- // make sure we don't detach
- uchar *mem = const_cast<uchar*>(const_cast<const QImage &>(img).bits());
-
- int lineskip = img.bytesPerLine();
- int depth = img.depth() >> 3;
-
- const QRect imageRect(0, 0, img.width(), img.height());
- const QRect r = rect & imageRect & imageRect.translated(-offset);
- const QPoint p = rect.topLeft() + offset;
-
- if (r.isEmpty())
- return;
-
- const uchar *src;
- uchar *dest;
-
- if (r.top() < p.y()) {
- src = mem + r.bottom() * lineskip + r.left() * depth;
- dest = mem + (p.y() + r.height() - 1) * lineskip + p.x() * depth;
- lineskip = -lineskip;
- } else {
- src = mem + r.top() * lineskip + r.left() * depth;
- dest = mem + p.y() * lineskip + p.x() * depth;
- }
-
- const int w = r.width();
- int h = r.height();
- const int bytes = w * depth;
-
- // overlapping segments?
- if (offset.y() == 0 && qAbs(offset.x()) < w) {
- do {
- ::memmove(dest, src, bytes);
- dest += lineskip;
- src += lineskip;
- } while (--h);
- } else {
- do {
- ::memcpy(dest, src, bytes);
- dest += lineskip;
- src += lineskip;
- } while (--h);
- }
-}
-
-/* Public */
-
-QMeeGoLivePixmapData::QMeeGoLivePixmapData(int w, int h, QImage::Format format) : QGLPixmapData(QPixmapData::PixmapType)
-{
- QImage image(w, h, format);
- QX11PixmapData *pmd = new QX11PixmapData(QPixmapData::PixmapType);
- pmd->fromImage(image, Qt::NoOpaqueDetection);
- backingX11Pixmap = new QPixmap(pmd);
-
- initializeThroughEGLImage();
-
- pos = all_live_pixmaps.insert(all_live_pixmaps.begin(), this);
-}
-
-QMeeGoLivePixmapData::QMeeGoLivePixmapData(Qt::HANDLE h) : QGLPixmapData(QPixmapData::PixmapType)
-{
- backingX11Pixmap = new QPixmap(QPixmap::fromX11Pixmap(h));
- initializeThroughEGLImage();
-
- pos = all_live_pixmaps.insert(all_live_pixmaps.begin(), this);
-}
-
-QMeeGoLivePixmapData::~QMeeGoLivePixmapData()
-{
- delete backingX11Pixmap;
- all_live_pixmaps.erase(pos);
-}
-
-void QMeeGoLivePixmapData::initializeThroughEGLImage()
-{
- if (texture()->id != 0)
- return;
-
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
- QMeeGoExtensions::ensureInitialized();
-
- EGLImageKHR eglImage = EGL_NO_IMAGE_KHR;
- GLuint newTextureId = 0;
-
- eglImage = QEgl::eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR,
- (EGLClientBuffer) backingX11Pixmap->handle(), preserved_attribs);
-
- if (eglImage == EGL_NO_IMAGE_KHR) {
- qWarning("eglCreateImageKHR failed (live texture)!");
- return;
- }
-
- glGenTextures(1, &newTextureId);
- glBindTexture(GL_TEXTURE_2D, newTextureId);
-
- glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (EGLImageKHR) eglImage);
- if (glGetError() == GL_NO_ERROR) {
- resize(backingX11Pixmap->width(), backingX11Pixmap->height());
- texture()->id = newTextureId;
- texture()->options &= ~QGLContext::InvertedYBindOption;
- m_hasAlpha = backingX11Pixmap->hasAlphaChannel();
- } else {
- qWarning("Failed to create a texture from an egl image (live texture)!");
- glDeleteTextures(1, &newTextureId);
- }
-
- QEgl::eglDestroyImageKHR(QEgl::display(), eglImage);
-}
-
-QPixmapData *QMeeGoLivePixmapData::createCompatiblePixmapData() const
-{
- qWarning("Create compatible called on live pixmap! Expect fail soon...");
- return new QMeeGoRasterPixmapData(pixelType());
-}
-
-QImage* QMeeGoLivePixmapData::lock(EGLSyncKHR fenceSync)
-{
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
- QMeeGoExtensions::ensureInitialized();
-
- if (fenceSync) {
- QMeeGoExtensions::eglClientWaitSyncKHR(QEgl::display(),
- fenceSync,
- EGL_SYNC_FLUSH_COMMANDS_BIT_KHR,
- EGL_FOREVER_KHR);
- }
-
- void *data = 0;
- int pitch = 0;
- int surfaceWidth = 0;
- int surfaceHeight = 0;
- EGLSurface surface = 0;
- QImage::Format format;
- lockedImage = QImage();
-
- surface = getSurfaceForBackingPixmap();
- if (! QMeeGoExtensions::eglLockSurfaceKHR(QEgl::display(), surface, lock_attribs)) {
- qWarning("Failed to lock surface (live texture)!");
- return &lockedImage;
- }
-
- eglQuerySurface(QEgl::display(), surface, EGL_BITMAP_POINTER_KHR, (EGLint*) &data);
- eglQuerySurface(QEgl::display(), surface, EGL_BITMAP_PITCH_KHR, (EGLint*) &pitch);
- eglQuerySurface(QEgl::display(), surface, EGL_WIDTH, (EGLint*) &surfaceWidth);
- eglQuerySurface(QEgl::display(), surface, EGL_HEIGHT, (EGLint*) &surfaceHeight);
-
- // Ok, here we know we just support those two formats. Real solution would be:
- // query also the format.
- if (backingX11Pixmap->depth() > 16)
- format = QImage::Format_ARGB32_Premultiplied;
- else
- format = QImage::Format_RGB16;
-
- if (data == NULL || pitch == 0) {
- qWarning("Failed to query the live texture!");
- return &lockedImage;
- }
-
- if (width() != surfaceWidth || height() != surfaceHeight) {
- qWarning("Live texture dimensions don't match!");
- QMeeGoExtensions::eglUnlockSurfaceKHR(QEgl::display(), surface);
- return &lockedImage;
- }
-
- lockedImage = QImage((uchar *) data, width(), height(), pitch, format);
- return &lockedImage;
-}
-
-bool QMeeGoLivePixmapData::release(QImage* /*img*/)
-{
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
- QMeeGoExtensions::ensureInitialized();
-
- if (QMeeGoExtensions::eglUnlockSurfaceKHR(QEgl::display(), getSurfaceForBackingPixmap())) {
- lockedImage = QImage();
- return true;
- } else {
- lockedImage = QImage();
- return false;
- }
-}
-
-Qt::HANDLE QMeeGoLivePixmapData::handle()
-{
- return backingX11Pixmap->handle();
-}
-
-bool QMeeGoLivePixmapData::scroll(int dx, int dy, const QRect &rect)
-{
- lock(NULL);
-
- if (!lockedImage.isNull())
- qt_scrollRectInImage(lockedImage, rect, QPoint(dx, dy));
-
- release(&lockedImage);
- return true;
-}
-
-EGLSurface QMeeGoLivePixmapData::getSurfaceForBackingPixmap()
-{
- initializeThroughEGLImage();
-
- // This code is a crative remix of the stuff that can be found in the
- // Qt's TFP implementation in /src/opengl/qgl_x11egl.cpp ::bindiTextureFromNativePixmap
- QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(backingX11Pixmap->data_ptr().data());
- Q_ASSERT(pixmapData->classId() == QPixmapData::X11Class);
- bool hasAlpha = pixmapData->hasAlphaChannel();
-
- if (pixmapData->gl_surface &&
- hasAlpha == (pixmapData->flags & QX11PixmapData::GlSurfaceCreatedWithAlpha))
- return pixmapData->gl_surface;
-
- // Check to see if the surface is still valid
- if (pixmapData->gl_surface &&
- hasAlpha != ((pixmapData->flags & QX11PixmapData::GlSurfaceCreatedWithAlpha) > 0)) {
- // Surface is invalid!
- destroySurfaceForPixmapData(pixmapData);
- }
-
- if (pixmapData->gl_surface == 0) {
- EGLConfig config = QEgl::defaultConfig(QInternal::Pixmap,
- QEgl::OpenGL,
- hasAlpha ? QEgl::Translucent : QEgl::NoOptions);
-
- pixmapData->gl_surface = (void*)QEgl::createSurface(backingX11Pixmap, config);
-
- if (hasAlpha)
- pixmapData->flags |= QX11PixmapData::GlSurfaceCreatedWithAlpha;
- else
- pixmapData->flags &= ~QX11PixmapData::GlSurfaceCreatedWithAlpha;
-
- if (pixmapData->gl_surface == (void*)EGL_NO_SURFACE)
- return NULL;
- }
-
- return pixmapData->gl_surface;
-}
-
-void QMeeGoLivePixmapData::destroySurfaceForPixmapData(QPixmapData* pmd)
-{
- Q_ASSERT(pmd->classId() == QPixmapData::X11Class);
- QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(pmd);
- if (pixmapData->gl_surface) {
- eglDestroySurface(QEgl::display(), (EGLSurface)pixmapData->gl_surface);
- pixmapData->gl_surface = 0;
- }
-}
-
-void QMeeGoLivePixmapData::invalidateSurfaces()
-{
- foreach (QMeeGoLivePixmapData *data, all_live_pixmaps) {
- QX11PixmapData *pixmapData = static_cast<QX11PixmapData*>(data->backingX11Pixmap->data_ptr().data());
- *data->texture() = QGLTexture();
- pixmapData->gl_surface = 0;
- }
-}
diff --git a/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.h b/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.h
deleted file mode 100644
index 616b33cc95..0000000000
--- a/src/plugins/graphicssystems/meego/qmeegolivepixmapdata.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MLIVEPIXMAPDATA_H
-#define MLIVEPIXMAPDATA_H
-
-#include <QLinkedList>
-#include <private/qpixmapdata_gl_p.h>
-#include "qmeegoextensions.h"
-
-class QMeeGoLivePixmapData;
-typedef QLinkedList<QMeeGoLivePixmapData *> QMeeGoLivePixmapDataList;
-
-class QMeeGoLivePixmapData : public QGLPixmapData
-{
-public:
- QMeeGoLivePixmapData(int w, int h, QImage::Format format);
- QMeeGoLivePixmapData(Qt::HANDLE h);
- ~QMeeGoLivePixmapData();
-
- QPixmapData *createCompatiblePixmapData() const;
- bool scroll(int dx, int dy, const QRect &rect);
-
- void initializeThroughEGLImage();
-
- QImage* lock(EGLSyncKHR fenceSync);
- bool release(QImage *img);
- Qt::HANDLE handle();
-
- EGLSurface getSurfaceForBackingPixmap();
- void destroySurfaceForPixmapData(QPixmapData* pmd);
-
- QPixmap *backingX11Pixmap;
- QImage lockedImage;
- QMeeGoLivePixmapDataList::Iterator pos;
-
- static void invalidateSurfaces();
-};
-
-#endif
diff --git a/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp b/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp
deleted file mode 100644
index ba3799fc33..0000000000
--- a/src/plugins/graphicssystems/meego/qmeegopixmapdata.cpp
+++ /dev/null
@@ -1,224 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmeegopixmapdata.h"
-#include "qmeegoextensions.h"
-#include "qmeegorasterpixmapdata.h"
-#include <private/qimage_p.h>
-#include <private/qwindowsurface_gl_p.h>
-#include <private/qeglcontext_p.h>
-#include <private/qapplication_p.h>
-#include <private/qgraphicssystem_runtime_p.h>
-
-// from dithering.cpp
-extern unsigned short* convertRGB32_to_RGB565(const unsigned char *in, int width, int height, int stride);
-extern unsigned short* convertARGB32_to_RGBA4444(const unsigned char *in, int width, int height, int stride);
-extern unsigned char* convertBGRA32_to_RGBA32(const unsigned char *in, int width, int height, int stride);
-
-static EGLint preserved_image_attribs[] = { EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, EGL_NONE };
-
-QHash <void*, QMeeGoImageInfo*> QMeeGoPixmapData::sharedImagesMap;
-
-/* Public */
-
-QMeeGoPixmapData::QMeeGoPixmapData() : QGLPixmapData(QPixmapData::PixmapType)
-{
-}
-
-void QMeeGoPixmapData::fromTexture(GLuint textureId, int w, int h, bool alpha)
-{
- resize(w, h);
- texture()->id = textureId;
- m_hasAlpha = alpha;
- softImage = QImage();
-}
-
-QImage QMeeGoPixmapData::toImage() const
-{
- return softImage;
-}
-
-void QMeeGoPixmapData::fromImage(const QImage &image,
- Qt::ImageConversionFlags flags)
-{
- void *rawResource = static_cast <void *> (((QImage &) image).data_ptr()->data);
-
- if (sharedImagesMap.contains(rawResource)) {
- QMeeGoImageInfo *info = sharedImagesMap.value(rawResource);
- fromEGLSharedImage(info->handle, image);
- } else {
- // This should *never* happen since the graphics system should never
- // create a QMeeGoPixmapData for an origin that doesn't contain a raster
- // image we know about. But...
- qWarning("QMeeGoPixmapData::fromImage called on non-know resource. Falling back...");
- QGLPixmapData::fromImage(image, flags);
- }
-}
-
-void QMeeGoPixmapData::fromEGLSharedImage(Qt::HANDLE handle, const QImage &si)
-{
- if (si.isNull())
- qFatal("Trying to build pixmap with an empty/null softimage!");
-
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
-
- QMeeGoExtensions::ensureInitialized();
-
- bool textureIsBound = false;
- GLuint newTextureId;
- GLint newWidth, newHeight;
-
- glGenTextures(1, &newTextureId);
- glBindTexture(GL_TEXTURE_2D, newTextureId);
-
- EGLImageKHR image = QEgl::eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_SHARED_IMAGE_NOK,
- (EGLClientBuffer)handle, preserved_image_attribs);
-
- if (image != EGL_NO_IMAGE_KHR) {
- glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
- GLint err = glGetError();
- if (err == GL_NO_ERROR)
- textureIsBound = true;
-
- QMeeGoExtensions::eglQueryImageNOK(QEgl::display(), image, EGL_WIDTH, &newWidth);
- QMeeGoExtensions::eglQueryImageNOK(QEgl::display(), image, EGL_HEIGHT, &newHeight);
-
- QEgl::eglDestroyImageKHR(QEgl::display(), image);
- }
-
- if (textureIsBound) {
- fromTexture(newTextureId, newWidth, newHeight,
- (si.hasAlphaChannel() && const_cast<QImage &>(si).data_ptr()->checkForAlphaPixels()));
- texture()->options &= ~QGLContext::InvertedYBindOption;
- softImage = si;
- QMeeGoPixmapData::registerSharedImage(handle, softImage);
- } else {
- qWarning("Failed to create a texture from a shared image!");
- glDeleteTextures(1, &newTextureId);
- }
-}
-
-Qt::HANDLE QMeeGoPixmapData::imageToEGLSharedImage(const QImage &image)
-{
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
-
- QMeeGoExtensions::ensureInitialized();
-
- GLuint textureId;
-
- glGenTextures(1, &textureId);
- glBindTexture(GL_TEXTURE_2D, textureId);
- if (image.hasAlphaChannel() && const_cast<QImage &>(image).data_ptr()->checkForAlphaPixels()) {
- void *converted = convertBGRA32_to_RGBA32(image.bits(), image.width(), image.height(), image.bytesPerLine());
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.width(), image.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, converted);
- free(converted);
- } else {
- void *converted = convertRGB32_to_RGB565(image.bits(), image.width(), image.height(), image.bytesPerLine());
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, image.width(), image.height(), 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, converted);
- free(converted);
- }
-
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-
- glBindTexture(GL_TEXTURE_2D, textureId);
- EGLImageKHR eglimage = QEgl::eglCreateImageKHR(QEgl::display(), QEglContext::currentContext(QEgl::OpenGL)->context(),
- EGL_GL_TEXTURE_2D_KHR,
- (EGLClientBuffer) textureId,
- preserved_image_attribs);
- glDeleteTextures(1, &textureId);
- if (eglimage) {
- EGLNativeSharedImageTypeNOK handle = QMeeGoExtensions::eglCreateSharedImageNOK(QEgl::display(), eglimage, NULL);
- QEgl::eglDestroyImageKHR(QEgl::display(), eglimage);
- return (Qt::HANDLE) handle;
- } else {
- qWarning("Failed to create shared image from pixmap/texture!");
- return 0;
- }
-}
-
-void QMeeGoPixmapData::updateFromSoftImage()
-{
- // FIXME That's broken with recent 16bit textures changes.
- m_dirty = true;
- m_source = softImage;
- ensureCreated();
-
- if (softImage.width() != w || softImage.height() != h)
- qWarning("Ooops, looks like softImage changed dimensions since last updated! Corruption ahead?!");
-}
-
-bool QMeeGoPixmapData::destroyEGLSharedImage(Qt::HANDLE h)
-{
- QGLShareContextScope ctx(qt_gl_share_widget()->context());
- QMeeGoExtensions::ensureInitialized();
-
- QMutableHashIterator <void*, QMeeGoImageInfo*> i(sharedImagesMap);
- while (i.hasNext()) {
- i.next();
- if (i.value()->handle == h)
- i.remove();
- }
-
- return QMeeGoExtensions::eglDestroySharedImageNOK(QEgl::display(), (EGLNativeSharedImageTypeNOK) h);
-}
-
-void QMeeGoPixmapData::registerSharedImage(Qt::HANDLE handle, const QImage &si)
-{
- void *raw = static_cast <void *> (((QImage) si).data_ptr()->data);
- QMeeGoImageInfo *info;
-
- if (! sharedImagesMap.contains(raw)) {
- info = new QMeeGoImageInfo;
- info->handle = handle;
- info->rawFormat = si.format();
- sharedImagesMap.insert(raw, info);
- } else {
- info = sharedImagesMap.value(raw);
- if (info->handle != handle || info->rawFormat != si.format())
- qWarning("Inconsistency detected: overwriting entry in sharedImagesMap but handle/format different");
- }
-}
-
-QPixmapData *QMeeGoPixmapData::createCompatiblePixmapData() const
-{
- return new QMeeGoRasterPixmapData(pixelType());
-}
diff --git a/src/plugins/graphicssystems/meego/qmeegopixmapdata.h b/src/plugins/graphicssystems/meego/qmeegopixmapdata.h
deleted file mode 100644
index a3d3bbb0b5..0000000000
--- a/src/plugins/graphicssystems/meego/qmeegopixmapdata.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MPIXMAPDATA_H
-#define MPIXMAPDATA_H
-
-#include <private/qpixmapdata_gl_p.h>
-
-struct QMeeGoImageInfo
-{
- Qt::HANDLE handle;
- QImage::Format rawFormat;
-};
-
-class QMeeGoPixmapData : public QGLPixmapData
-{
-public:
- QMeeGoPixmapData();
- void fromTexture(GLuint textureId, int w, int h, bool alpha);
- QPixmapData *createCompatiblePixmapData() const;
-
- virtual void fromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage);
- virtual void fromImage (const QImage &image, Qt::ImageConversionFlags flags);
- virtual QImage toImage() const;
- virtual void updateFromSoftImage();
-
- QImage softImage;
-
- static QHash <void*, QMeeGoImageInfo*> sharedImagesMap;
-
- static Qt::HANDLE imageToEGLSharedImage(const QImage &image);
- static bool destroyEGLSharedImage(Qt::HANDLE h);
- static void registerSharedImage(Qt::HANDLE handle, const QImage &si);
-};
-
-#endif
diff --git a/src/plugins/graphicssystems/meego/qmeegorasterpixmapdata.cpp b/src/plugins/graphicssystems/meego/qmeegorasterpixmapdata.cpp
deleted file mode 100644
index 5b8f23e453..0000000000
--- a/src/plugins/graphicssystems/meego/qmeegorasterpixmapdata.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qmeegorasterpixmapdata.h"
-
-/* Public */
-
-QMeeGoRasterPixmapData::QMeeGoRasterPixmapData() : QRasterPixmapData(QPixmapData::PixmapType)
-{
-}
-
-QMeeGoRasterPixmapData::QMeeGoRasterPixmapData(QPixmapData::PixelType t) : QRasterPixmapData(t)
-{
-}
-
-void QMeeGoRasterPixmapData::copy(const QPixmapData *data, const QRect &rect)
-{
- if (data->classId() == QPixmapData::OpenGLClass)
- fromImage(data->toImage(rect).copy(), Qt::NoOpaqueDetection);
- else
- QRasterPixmapData::copy(data, rect);
-}
diff --git a/src/plugins/graphicssystems/meego/qmeegorasterpixmapdata.h b/src/plugins/graphicssystems/meego/qmeegorasterpixmapdata.h
deleted file mode 100644
index 4320659fe9..0000000000
--- a/src/plugins/graphicssystems/meego/qmeegorasterpixmapdata.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MRASTERPIXMAPDATA_H
-#define MRASTERPIXMAPDATA_H
-
-#include <private/qpixmap_raster_p.h>
-
-class QMeeGoRasterPixmapData : public QRasterPixmapData
-{
-public:
- QMeeGoRasterPixmapData();
- QMeeGoRasterPixmapData(QPixmapData::PixelType t);
- void copy(const QPixmapData *data, const QRect &rect);
-};
-
-#endif
diff --git a/src/plugins/graphicssystems/opengl/main.cpp b/src/plugins/graphicssystems/opengl/main.cpp
deleted file mode 100644
index 4c8f928d66..0000000000
--- a/src/plugins/graphicssystems/opengl/main.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <private/qgraphicssystemplugin_p.h>
-#include <private/qgraphicssystem_gl_p.h>
-#include <qgl.h>
-
-QT_BEGIN_NAMESPACE
-
-class QGLGraphicsSystemPlugin : public QGraphicsSystemPlugin
-{
-public:
- QStringList keys() const;
- QGraphicsSystem *create(const QString&);
-};
-
-QStringList QGLGraphicsSystemPlugin::keys() const
-{
- QStringList list;
- list << QLatin1String("OpenGL") << QLatin1String("OpenGL1");
-#if !defined(QT_OPENGL_ES_1)
- list << QLatin1String("OpenGL2");
-#endif
-#if defined(Q_WS_X11) && !defined(QT_NO_EGL)
- list << QLatin1String("X11GL");
-#endif
- return list;
-}
-
-QGraphicsSystem* QGLGraphicsSystemPlugin::create(const QString& system)
-{
- if (system.toLower() == QLatin1String("opengl1")) {
- QGL::setPreferredPaintEngine(QPaintEngine::OpenGL);
- return new QGLGraphicsSystem(false);
- }
-
-#if !defined(QT_OPENGL_ES_1)
- if (system.toLower() == QLatin1String("opengl2")) {
- QGL::setPreferredPaintEngine(QPaintEngine::OpenGL2);
- return new QGLGraphicsSystem(false);
- }
-#endif
-
-#if defined(Q_WS_X11) && !defined(QT_NO_EGL)
- if (system.toLower() == QLatin1String("x11gl"))
- return new QGLGraphicsSystem(true);
-#endif
-
- if (system.toLower() == QLatin1String("opengl"))
- return new QGLGraphicsSystem(false);
-
- return 0;
-}
-
-Q_EXPORT_PLUGIN2(opengl, QGLGraphicsSystemPlugin)
-
-QT_END_NAMESPACE
diff --git a/src/plugins/graphicssystems/opengl/opengl.pro b/src/plugins/graphicssystems/opengl/opengl.pro
deleted file mode 100644
index 30c88271b6..0000000000
--- a/src/plugins/graphicssystems/opengl/opengl.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TARGET = qglgraphicssystem
-include(../../qpluginbase.pri)
-
-QT += core-private gui-private opengl-private
-
-DESTDIR = $$QT.gui.plugins/graphicssystems
-
-SOURCES = main.cpp
-
-target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems
-INSTALLS += target
-
-symbian: TARGET.UID3 = 0x2002131B
diff --git a/src/plugins/graphicssystems/openvg/main.cpp b/src/plugins/graphicssystems/openvg/main.cpp
deleted file mode 100644
index 6cf368aba8..0000000000
--- a/src/plugins/graphicssystems/openvg/main.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <private/qgraphicssystemplugin_p.h>
-#include "qgraphicssystem_vg_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QVGGraphicsSystemPlugin : public QGraphicsSystemPlugin
-{
-public:
- QStringList keys() const;
- QGraphicsSystem *create(const QString&);
-};
-
-QStringList QVGGraphicsSystemPlugin::keys() const
-{
- QStringList list;
- list << "OpenVG";
- return list;
-}
-
-QGraphicsSystem* QVGGraphicsSystemPlugin::create(const QString& system)
-{
- if (system.toLower() == "openvg")
- return new QVGGraphicsSystem;
-
- return 0;
-}
-
-Q_EXPORT_PLUGIN2(openvg, QVGGraphicsSystemPlugin)
-
-QT_END_NAMESPACE
diff --git a/src/plugins/graphicssystems/openvg/openvg.pro b/src/plugins/graphicssystems/openvg/openvg.pro
deleted file mode 100644
index 6f8b13907a..0000000000
--- a/src/plugins/graphicssystems/openvg/openvg.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-TARGET = qvggraphicssystem
-include(../../qpluginbase.pri)
-
-QT += openvg
-
-DESTDIR = $$QT.gui.plugins/graphicssystems
-
-SOURCES = main.cpp qgraphicssystem_vg.cpp
-HEADERS = qgraphicssystem_vg_p.h
-
-target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems
-INSTALLS += target
-
-symbian: TARGET.UID3 = 0x2001E62C
diff --git a/src/plugins/graphicssystems/openvg/qgraphicssystem_vg.cpp b/src/plugins/graphicssystems/openvg/qgraphicssystem_vg.cpp
deleted file mode 100644
index 4b4f677026..0000000000
--- a/src/plugins/graphicssystems/openvg/qgraphicssystem_vg.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgraphicssystem_vg_p.h"
-#include <QtOpenVG/private/qpixmapdata_vg_p.h>
-#include <QtOpenVG/private/qwindowsurface_vg_p.h>
-#include <QtOpenVG/private/qvgimagepool_p.h>
-#if defined(Q_OS_SYMBIAN)
-#include <QtGui/private/qwidget_p.h>
-#endif
-#include <QtGui/private/qapplication_p.h>
-
-QT_BEGIN_NAMESPACE
-
-QVGGraphicsSystem::QVGGraphicsSystem()
-{
- QApplicationPrivate::graphics_system_name = QLatin1String("openvg");
-}
-
-QPixmapData *QVGGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const
-{
-#if !defined(QVG_NO_SINGLE_CONTEXT) && !defined(QVG_NO_PIXMAP_DATA)
- // Pixmaps can use QVGPixmapData; bitmaps must use raster.
- if (type == QPixmapData::PixmapType)
- return new QVGPixmapData(type);
- else
- return new QRasterPixmapData(type);
-#else
- return new QRasterPixmapData(type);
-#endif
-}
-
-QWindowSurface *QVGGraphicsSystem::createWindowSurface(QWidget *widget) const
-{
-#if defined(Q_OS_SYMBIAN)
- if (!QApplicationPrivate::instance()->useTranslucentEGLSurfaces) {
- QWidgetPrivate *d = qt_widget_private(widget);
- if (!d->isOpaque && widget->testAttribute(Qt::WA_TranslucentBackground))
- return d->createDefaultWindowSurface_sys();
- }
-#endif
- return new QVGWindowSurface(widget);
-}
-
-void QVGGraphicsSystem::releaseCachedResources()
-{
- QVGImagePool::instance()->hibernate();
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/graphicssystems/openvg/qgraphicssystem_vg_p.h b/src/plugins/graphicssystems/openvg/qgraphicssystem_vg_p.h
deleted file mode 100644
index 9c9b3e2b2e..0000000000
--- a/src/plugins/graphicssystems/openvg/qgraphicssystem_vg_p.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSSYSTEM_VG_P_H
-#define QGRAPHICSSYSTEM_VG_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtGui/private/qgraphicssystem_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QVGGraphicsSystem : public QGraphicsSystem
-{
-public:
- QVGGraphicsSystem();
-
- QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
- QWindowSurface *createWindowSurface(QWidget *widget) const;
-
- void releaseCachedResources();
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/plugins/graphicssystems/shivavg/README b/src/plugins/graphicssystems/shivavg/README
deleted file mode 100644
index 15ee7101e8..0000000000
--- a/src/plugins/graphicssystems/shivavg/README
+++ /dev/null
@@ -1,8 +0,0 @@
-
-This graphics system uses ShivaVG (http://sourceforge.net/projects/shivavg)
-to perform OpenVG rendering on X11 systems. The graphics system name for
-the "-graphicssystem" command-line option is "ShivaVG".
-
-ShivaVG support is experimental, mostly to demonstrate how to integrate
-non-EGL OpenVG engines into the system. It will probably not produce
-good output.
diff --git a/src/plugins/graphicssystems/shivavg/main.cpp b/src/plugins/graphicssystems/shivavg/main.cpp
deleted file mode 100644
index 2a95ed6afe..0000000000
--- a/src/plugins/graphicssystems/shivavg/main.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <private/qgraphicssystemplugin_p.h>
-#include "shivavggraphicssystem.h"
-
-QT_BEGIN_NAMESPACE
-
-class ShivaVGGraphicsSystemPlugin : public QGraphicsSystemPlugin
-{
-public:
- QStringList keys() const;
- QGraphicsSystem *create(const QString&);
-};
-
-QStringList ShivaVGGraphicsSystemPlugin::keys() const
-{
- QStringList list;
- list << "ShivaVG";
- return list;
-}
-
-QGraphicsSystem* ShivaVGGraphicsSystemPlugin::create(const QString& system)
-{
- if (system.toLower() == "shivavg")
- return new ShivaVGGraphicsSystem;
-
- return 0;
-}
-
-Q_EXPORT_PLUGIN2(shivavg, ShivaVGGraphicsSystemPlugin)
-
-QT_END_NAMESPACE
diff --git a/src/plugins/graphicssystems/shivavg/shivavg.pro b/src/plugins/graphicssystems/shivavg/shivavg.pro
deleted file mode 100644
index 6bf9d7a975..0000000000
--- a/src/plugins/graphicssystems/shivavg/shivavg.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-TARGET = qshivavggraphicssystem
-include(../../qpluginbase.pri)
-
-QT += openvg
-
-DESTDIR = $$QT.gui.plugins/graphicssystems
-
-SOURCES = main.cpp shivavggraphicssystem.cpp shivavgwindowsurface.cpp
-HEADERS = shivavggraphicssystem.h shivavgwindowsurface.h
-
-target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems
-INSTALLS += target
diff --git a/src/plugins/graphicssystems/shivavg/shivavggraphicssystem.cpp b/src/plugins/graphicssystems/shivavg/shivavggraphicssystem.cpp
deleted file mode 100644
index ee6a15d894..0000000000
--- a/src/plugins/graphicssystems/shivavg/shivavggraphicssystem.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "shivavggraphicssystem.h"
-#include "shivavgwindowsurface.h"
-#include <QtGui/private/qpixmap_raster_p.h>
-
-QT_BEGIN_NAMESPACE
-
-ShivaVGGraphicsSystem::ShivaVGGraphicsSystem()
-{
-}
-
-QPixmapData *ShivaVGGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const
-{
- return new QRasterPixmapData(type);
-}
-
-QWindowSurface *ShivaVGGraphicsSystem::createWindowSurface(QWidget *widget) const
-{
- return new ShivaVGWindowSurface(widget);
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/graphicssystems/shivavg/shivavggraphicssystem.h b/src/plugins/graphicssystems/shivavg/shivavggraphicssystem.h
deleted file mode 100644
index b51bd73abc..0000000000
--- a/src/plugins/graphicssystems/shivavg/shivavggraphicssystem.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef SHIVAVGGRAPHICSSYSTEM_H
-#define SHIVAVGGRAPHICSSYSTEM_H
-
-#include <QtGui/private/qgraphicssystem_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class ShivaVGGraphicsSystem : public QGraphicsSystem
-{
-public:
- ShivaVGGraphicsSystem();
-
- QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
- QWindowSurface *createWindowSurface(QWidget *widget) const;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/plugins/graphicssystems/shivavg/shivavgwindowsurface.cpp b/src/plugins/graphicssystems/shivavg/shivavgwindowsurface.cpp
deleted file mode 100644
index 8e7a3e169f..0000000000
--- a/src/plugins/graphicssystems/shivavg/shivavgwindowsurface.cpp
+++ /dev/null
@@ -1,358 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#define GL_GLEXT_PROTOTYPES
-#include "shivavgwindowsurface.h"
-#include <QtOpenVG/private/qpaintengine_vg_p.h>
-#if defined(Q_WS_X11)
-#include "private/qt_x11_p.h"
-#include "qx11info_x11.h"
-#include <GL/glx.h>
-
-extern QX11Info *qt_x11Info(const QPaintDevice *pd);
-#endif
-
-// Define this to use framebuffer objects.
-//#define QVG_USE_FBO 1
-
-#include <vg/openvg.h>
-
-QT_BEGIN_NAMESPACE
-
-class QShivaContext
-{
-public:
- QShivaContext();
- ~QShivaContext();
-
- bool makeCurrent(ShivaVGWindowSurfacePrivate *surface);
- void doneCurrent();
-
- bool initialized;
- QSize currentSize;
- ShivaVGWindowSurfacePrivate *currentSurface;
-};
-
-Q_GLOBAL_STATIC(QShivaContext, shivaContext);
-
-class ShivaVGWindowSurfacePrivate
-{
-public:
- ShivaVGWindowSurfacePrivate()
- : isCurrent(false)
- , needsResize(true)
- , engine(0)
-#if defined(QVG_USE_FBO)
- , fbo(0)
- , texture(0)
-#endif
-#if defined(Q_WS_X11)
- , drawable(0)
- , context(0)
-#endif
- {
- }
- ~ShivaVGWindowSurfacePrivate();
-
- void ensureContext(QWidget *widget);
-
- QSize size;
- bool isCurrent;
- bool needsResize;
- QVGPaintEngine *engine;
-#if defined(QVG_USE_FBO)
- GLuint fbo;
- GLuint texture;
-#endif
-#if defined(Q_WS_X11)
- GLXDrawable drawable;
- GLXContext context;
-#endif
-};
-
-QShivaContext::QShivaContext()
- : initialized(false)
- , currentSurface(0)
-{
-}
-
-QShivaContext::~QShivaContext()
-{
- if (initialized)
- vgDestroyContextSH();
-}
-
-bool QShivaContext::makeCurrent(ShivaVGWindowSurfacePrivate *surface)
-{
- if (currentSurface)
- currentSurface->isCurrent = false;
- surface->isCurrent = true;
- currentSurface = surface;
- currentSize = surface->size;
-#if defined(Q_WS_X11)
- glXMakeCurrent(X11->display, surface->drawable, surface->context);
-#endif
- if (!initialized) {
- if (!vgCreateContextSH(currentSize.width(), currentSize.height())) {
- qWarning("vgCreateContextSH(%d, %d): could not create context", currentSize.width(), currentSize.height());
- return false;
- }
- initialized = true;
- } else {
- vgResizeSurfaceSH(currentSize.width(), currentSize.height());
- }
-#if defined(QVG_USE_FBO)
- if (surface->fbo)
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, surface->fbo);
- else
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
-#endif
- return true;
-}
-
-void QShivaContext::doneCurrent()
-{
- if (currentSurface) {
- currentSurface->isCurrent = false;
- currentSurface = 0;
- }
-#if defined(Q_WS_X11)
- glXMakeCurrent(X11->display, 0, 0);
-#endif
-}
-
-ShivaVGWindowSurfacePrivate::~ShivaVGWindowSurfacePrivate()
-{
-#if defined(QVG_USE_FBO)
- if (fbo) {
- glDeleteTextures(1, &texture);
- glDeleteFramebuffersEXT(1, &fbo);
- }
-#endif
-}
-
-void ShivaVGWindowSurfacePrivate::ensureContext(QWidget *widget)
-{
-#if defined(Q_WS_X11)
- Window win = widget->winId();
- if (win != drawable) {
- if (context)
- glXDestroyContext(X11->display, context);
- drawable = win;
- }
- if (context == 0) {
- const QX11Info *xinfo = qt_x11Info(widget);
- int spec[64];
- int i = 0;
- spec[i++] = GLX_DOUBLEBUFFER;
- spec[i++] = GLX_DEPTH_SIZE;
- spec[i++] = 1;
- spec[i++] = GLX_STENCIL_SIZE;
- spec[i++] = 1;
- spec[i++] = GLX_RGBA;
- spec[i++] = GLX_RED_SIZE;
- spec[i++] = 1;
- spec[i++] = GLX_GREEN_SIZE;
- spec[i++] = 1;
- spec[i++] = GLX_BLUE_SIZE;
- spec[i++] = 1;
- spec[i++] = GLX_SAMPLE_BUFFERS_ARB;
- spec[i++] = 1;
- spec[i++] = GLX_SAMPLES_ARB;
- spec[i++] = 4;
- spec[i] = XNone;
- XVisualInfo *visual = glXChooseVisual
- (xinfo->display(), xinfo->screen(), spec);
- context = glXCreateContext(X11->display, visual, 0, True);
- if (!context)
- qWarning("glXCreateContext: could not create GL context for VG rendering");
- }
-#else
- Q_UNUSED(widget);
-#endif
-#if defined(QVG_USE_FBO)
- if (needsResize && fbo) {
-#if defined(Q_WS_X11)
- glXMakeCurrent(X11->display, drawable, context);
-#endif
- glDeleteTextures(1, &texture);
- glDeleteFramebuffersEXT(1, &fbo);
-#if defined(Q_WS_X11)
- glXMakeCurrent(X11->display, 0, 0);
-#endif
- fbo = 0;
- texture = 0;
- }
- if (!fbo) {
-#if defined(Q_WS_X11)
- glXMakeCurrent(X11->display, drawable, context);
-#endif
- glGenFramebuffersEXT(1, &fbo);
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
-
- glGenTextures(1, &texture);
- glBindTexture(GL_TEXTURE_2D, texture);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, size.width(), size.height(), 0,
- GL_RGBA, GL_UNSIGNED_BYTE, NULL);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glFramebufferTexture2DEXT
- (GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D,
- texture, 0);
-
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
-#if defined(Q_WS_X11)
- glXMakeCurrent(X11->display, 0, 0);
-#endif
- }
-#endif
- needsResize = false;
-}
-
-ShivaVGWindowSurface::ShivaVGWindowSurface(QWidget *window)
- : QWindowSurface(window), d_ptr(new ShivaVGWindowSurfacePrivate)
-{
-}
-
-ShivaVGWindowSurface::~ShivaVGWindowSurface()
-{
- if (d_ptr->isCurrent) {
- shivaContext()->doneCurrent();
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- }
-#if defined(Q_WS_X11)
- if (d_ptr->context)
- glXDestroyContext(X11->display, d_ptr->context);
-#endif
- delete d_ptr;
-}
-
-QPaintDevice *ShivaVGWindowSurface::paintDevice()
-{
- d_ptr->ensureContext(window());
- shivaContext()->makeCurrent(d_ptr);
- glClearDepth(0.0f);
- glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
- return this;
-}
-
-void ShivaVGWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
-{
- Q_UNUSED(region);
- Q_UNUSED(offset);
- QWidget *parent = widget->internalWinId() ? widget : widget->nativeParentWidget();
- d_ptr->ensureContext(parent);
- QShivaContext *context = shivaContext();
- if (!d_ptr->isCurrent)
- context->makeCurrent(d_ptr);
-#if defined(QVG_USE_FBO)
- glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
- if (d_ptr->fbo) {
- static GLfloat const vertices[][2] = {
- {-1, -1}, {1, -1}, {1, 1}, {-1, 1}
- };
- static GLfloat const texCoords[][2] = {
- {0, 0}, {1, 0}, {1, 1}, {0, 1}
- };
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glVertexPointer(2, GL_FLOAT, 0, vertices);
- glTexCoordPointer(2, GL_FLOAT, 0, texCoords);
- glBindTexture(GL_TEXTURE_2D, d_ptr->texture);
- glEnable(GL_TEXTURE_2D);
- glEnableClientState(GL_VERTEX_ARRAY);
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- glDisableClientState(GL_VERTEX_ARRAY);
- glDisable(GL_TEXTURE_2D);
- glBindTexture(GL_TEXTURE_2D, 0);
- }
-#endif
-#if defined(Q_WS_X11)
- glXSwapBuffers(X11->display, d_ptr->drawable);
-#endif
- context->doneCurrent();
-}
-
-void ShivaVGWindowSurface::setGeometry(const QRect &rect)
-{
- QWindowSurface::setGeometry(rect);
- d_ptr->needsResize = true;
- d_ptr->size = rect.size();
-}
-
-bool ShivaVGWindowSurface::scroll(const QRegion &area, int dx, int dy)
-{
- return QWindowSurface::scroll(area, dx, dy);
-}
-
-void ShivaVGWindowSurface::beginPaint(const QRegion &region)
-{
- // Nothing to do here.
- Q_UNUSED(region);
-}
-
-void ShivaVGWindowSurface::endPaint(const QRegion &region)
-{
- // Nothing to do here.
- Q_UNUSED(region);
-}
-
-Q_GLOBAL_STATIC(QVGPaintEngine, sharedPaintEngine);
-
-QPaintEngine *ShivaVGWindowSurface::paintEngine() const
-{
- if (!d_ptr->engine)
- d_ptr->engine = sharedPaintEngine();
- return d_ptr->engine;
-}
-
-int ShivaVGWindowSurface::metric(PaintDeviceMetric met) const
-{
- return qt_paint_device_metric(window(), met);
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/graphicssystems/shivavg/shivavgwindowsurface.h b/src/plugins/graphicssystems/shivavg/shivavgwindowsurface.h
deleted file mode 100644
index 8b1649ab17..0000000000
--- a/src/plugins/graphicssystems/shivavg/shivavgwindowsurface.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef SHIVAVGWINDOWSURFACE_H
-#define SHIVAVGWINDOWSURFACE_H
-
-#include <QtGui/private/qwindowsurface_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class ShivaVGWindowSurfacePrivate;
-
-class ShivaVGWindowSurface : public QWindowSurface, public QPaintDevice
-{
-public:
- ShivaVGWindowSurface(QWidget *window);
- virtual ~ShivaVGWindowSurface();
-
- QPaintDevice *paintDevice();
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
- void setGeometry(const QRect &rect);
- bool scroll(const QRegion &area, int dx, int dy);
-
- void beginPaint(const QRegion &region);
- void endPaint(const QRegion &region);
-
- QPaintEngine *paintEngine() const;
-
-protected:
- int metric(PaintDeviceMetric metric) const;
-
-private:
- ShivaVGWindowSurfacePrivate *d_ptr;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/plugins/graphicssystems/trace/main.cpp b/src/plugins/graphicssystems/trace/main.cpp
deleted file mode 100644
index 2a84d0bdce..0000000000
--- a/src/plugins/graphicssystems/trace/main.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <private/qgraphicssystemplugin_p.h>
-#include "qgraphicssystem_trace_p.h"
-
-QT_BEGIN_NAMESPACE
-
-class QTraceGraphicsSystemPlugin : public QGraphicsSystemPlugin
-{
-public:
- QStringList keys() const;
- QGraphicsSystem *create(const QString&);
-};
-
-QStringList QTraceGraphicsSystemPlugin::keys() const
-{
- return QStringList(QLatin1String("Trace"));
-}
-
-QGraphicsSystem* QTraceGraphicsSystemPlugin::create(const QString& system)
-{
- if (system.toLower() == QLatin1String("trace"))
- return new QTraceGraphicsSystem;
-
- return 0;
-}
-
-Q_EXPORT_PLUGIN2(trace, QTraceGraphicsSystemPlugin)
-
-QT_END_NAMESPACE
diff --git a/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp b/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp
deleted file mode 100644
index 62b6992f84..0000000000
--- a/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qgraphicssystem_trace_p.h"
-#include <private/qpixmap_raster_p.h>
-#include <private/qpaintbuffer_p.h>
-#include <private/qwindowsurface_raster_p.h>
-
-#include <QFile>
-#include <QPainter>
-#include <QtDebug>
-
-QT_BEGIN_NAMESPACE
-
-class QTraceWindowSurface : public QRasterWindowSurface
-{
-public:
- QTraceWindowSurface(QWidget *widget);
- ~QTraceWindowSurface();
-
- QPaintDevice *paintDevice();
- void beginPaint(const QRegion &rgn);
- void endPaint(const QRegion &rgn);
-
- bool scroll(const QRegion &area, int dx, int dy);
-
-private:
- QPaintBuffer *buffer;
- QList<QRegion> updates;
-
- qulonglong winId;
-};
-
-QTraceWindowSurface::QTraceWindowSurface(QWidget *widget)
- : QRasterWindowSurface(widget)
- , buffer(0)
- , winId(0)
-{
-}
-
-QTraceWindowSurface::~QTraceWindowSurface()
-{
- if (buffer) {
- QFile outputFile(QString(QLatin1String("qtgraphics-%0.trace")).arg(winId));
- if (outputFile.open(QIODevice::WriteOnly)) {
- QDataStream out(&outputFile);
- out.setFloatingPointPrecision(QDataStream::SinglePrecision);
-
- out.writeBytes("qttraceV2", 9);
-
- uint version = 1;
-
- out << version << *buffer << updates;
- }
- delete buffer;
- }
-}
-
-QPaintDevice *QTraceWindowSurface::paintDevice()
-{
- if (!buffer) {
- buffer = new QPaintBuffer;
-#ifdef Q_WS_QPA
- buffer->setBoundingRect(QRect(QPoint(), size()));
-#else
- buffer->setBoundingRect(geometry());
-#endif
- }
- return buffer;
-}
-
-void QTraceWindowSurface::beginPaint(const QRegion &rgn)
-{
- // ensure paint buffer is created
- paintDevice();
- buffer->beginNewFrame();
-
- QRasterWindowSurface::beginPaint(rgn);
-}
-
-void QTraceWindowSurface::endPaint(const QRegion &rgn)
-{
- QPainter p(QRasterWindowSurface::paintDevice());
- buffer->draw(&p, buffer->numFrames()-1);
- p.end();
-
- winId = (qulonglong)window()->winId();
-
- updates << rgn;
-
- QRasterWindowSurface::endPaint(rgn);
-}
-
-bool QTraceWindowSurface::scroll(const QRegion &, int, int)
-{
- // TODO: scrolling should also be streamed and replayed
- // to test scrolling performance
- return false;
-}
-
-QTraceGraphicsSystem::QTraceGraphicsSystem()
-{
-}
-
-QPixmapData *QTraceGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const
-{
- return new QRasterPixmapData(type);
-}
-
-QWindowSurface *QTraceGraphicsSystem::createWindowSurface(QWidget *widget) const
-{
- return new QTraceWindowSurface(widget);
-}
-
-QT_END_NAMESPACE
diff --git a/src/plugins/graphicssystems/trace/qgraphicssystem_trace_p.h b/src/plugins/graphicssystems/trace/qgraphicssystem_trace_p.h
deleted file mode 100644
index e5ab4af147..0000000000
--- a/src/plugins/graphicssystems/trace/qgraphicssystem_trace_p.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QGRAPHICSSYSTEM_TRACE_P_H
-#define QGRAPHICSSYSTEM_TRACE_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of other Qt classes. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtGui/private/qgraphicssystem_p.h>
-
-QT_BEGIN_NAMESPACE
-
-class QTraceGraphicsSystem : public QGraphicsSystem
-{
-public:
- QTraceGraphicsSystem();
-
- QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
- QWindowSurface *createWindowSurface(QWidget *widget) const;
-};
-
-QT_END_NAMESPACE
-
-#endif
diff --git a/src/plugins/graphicssystems/trace/trace.pro b/src/plugins/graphicssystems/trace/trace.pro
deleted file mode 100644
index b31beb35f8..0000000000
--- a/src/plugins/graphicssystems/trace/trace.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TARGET = qtracegraphicssystem
-include(../../qpluginbase.pri)
-
-QT += core-private gui-private network
-
-DESTDIR = $$QT.gui.plugins/graphicssystems
-symbian:TARGET.UID3 = 0x2002130E
-
-SOURCES = main.cpp qgraphicssystem_trace.cpp
-
-target.path += $$[QT_INSTALL_PLUGINS]/graphicssystems
-INSTALLS += target
-INCLUDEPATH += ../../../3rdparty/harfbuzz/src
diff --git a/src/plugins/inputmethods/imsw-multi/imsw-multi.pro b/src/plugins/inputmethods/imsw-multi/imsw-multi.pro
index 5d0535f3ac..e37212abee 100644
--- a/src/plugins/inputmethods/imsw-multi/imsw-multi.pro
+++ b/src/plugins/inputmethods/imsw-multi/imsw-multi.pro
@@ -1,6 +1,7 @@
TARGET = qimsw-multi
include(../../qpluginbase.pri)
CONFIG += warn_on
+QT += widgets
DESTDIR = $$QT.gui.plugins/inputmethods
diff --git a/src/plugins/inputmethods/imsw-multi/qmultiinputcontext.h b/src/plugins/inputmethods/imsw-multi/qmultiinputcontext.h
index 819174f0ad..e684d2fded 100644
--- a/src/plugins/inputmethods/imsw-multi/qmultiinputcontext.h
+++ b/src/plugins/inputmethods/imsw-multi/qmultiinputcontext.h
@@ -58,8 +58,8 @@
#ifndef QT_NO_IM
-#include <QtGui/qwidget.h>
-#include <QtGui/qinputcontext.h>
+#include <QtWidgets/qwidget.h>
+#include <QtWidgets/qinputcontext.h>
#include <QtCore/qstring.h>
#include <QtCore/qnamespace.h>
#include <QtCore/qmap.h>
diff --git a/src/plugins/inputmethods/imsw-multi/qmultiinputcontextplugin.h b/src/plugins/inputmethods/imsw-multi/qmultiinputcontextplugin.h
index 9d7b17b6de..877e0f1d4a 100644
--- a/src/plugins/inputmethods/imsw-multi/qmultiinputcontextplugin.h
+++ b/src/plugins/inputmethods/imsw-multi/qmultiinputcontextplugin.h
@@ -59,7 +59,7 @@
#ifndef QT_NO_IM
#include "qmultiinputcontext.h"
-#include <QtGui/qinputcontextplugin.h>
+#include <QtWidgets/qinputcontextplugin.h>
#include <QtCore/qstringlist.h>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/kbddrivers/kbddrivers.pro b/src/plugins/kbddrivers/kbddrivers.pro
deleted file mode 100644
index dbab47b366..0000000000
--- a/src/plugins/kbddrivers/kbddrivers.pro
+++ /dev/null
@@ -1,2 +0,0 @@
-TEMPLATE = subdirs
-contains(kbd-plugins, linuxinput): SUBDIRS += linuxinput
diff --git a/src/plugins/kbddrivers/linuxinput/linuxinput.pro b/src/plugins/kbddrivers/linuxinput/linuxinput.pro
deleted file mode 100644
index c0af91c7f0..0000000000
--- a/src/plugins/kbddrivers/linuxinput/linuxinput.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-TARGET = qlinuxinputkbddriver
-include(../../qpluginbase.pri)
-
-DESTDIR = $$QT.gui.plugins/kbddrivers
-target.path = $$[QT_INSTALL_PLUGINS]/kbddrivers
-INSTALLS += target
-
-DEFINES += QT_QWS_KBD_LINUXINPUT
-
-HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qkbdlinuxinput_qws.h
-
-SOURCES = main.cpp \
- $$QT_SOURCE_TREE/src/gui/embedded/qkbdlinuxinput_qws.cpp
-
diff --git a/src/plugins/kbddrivers/linuxinput/main.cpp b/src/plugins/kbddrivers/linuxinput/main.cpp
deleted file mode 100644
index 2158b3fac7..0000000000
--- a/src/plugins/kbddrivers/linuxinput/main.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qkbddriverplugin_qws.h>
-#include <qkbdlinuxinput_qws.h>
-
-QT_BEGIN_NAMESPACE
-
-class QLinuxInputKbdDriver : public QKbdDriverPlugin
-{
-public:
- QLinuxInputKbdDriver();
-
- QStringList keys() const;
- QWSKeyboardHandler* create(const QString &driver, const QString &device);
-};
-
-QLinuxInputKbdDriver::QLinuxInputKbdDriver()
- : QKbdDriverPlugin()
-{
-}
-
-QStringList QLinuxInputKbdDriver::keys() const
-{
- return (QStringList() << QLatin1String("LinuxInput"));
-}
-
-QWSKeyboardHandler* QLinuxInputKbdDriver::create(const QString &driver,
- const QString &device)
-{
- Q_UNUSED(device);
- if (driver.compare(QLatin1String("LinuxInput"), Qt::CaseInsensitive))
- return 0;
- return new QWSLinuxInputKeyboardHandler(device);
-}
-
-Q_EXPORT_PLUGIN2(qwslinuxinputkbddriver, QLinuxInputKbdDriver)
-
-QT_END_NAMESPACE
diff --git a/src/plugins/mousedrivers/linuxtp/linuxtp.pro b/src/plugins/mousedrivers/linuxtp/linuxtp.pro
deleted file mode 100644
index b8e26b4483..0000000000
--- a/src/plugins/mousedrivers/linuxtp/linuxtp.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-TARGET = qlinuxtpmousedriver
-include(../../qpluginbase.pri)
-
-DESTDIR = $$QT.gui.plugins/mousedrivers
-target.path = $$[QT_INSTALL_PLUGINS]/mousedrivers
-INSTALLS += target
-
-DEFINES += QT_QWS_MOUSE_LINUXTP
-
-HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qmouselinuxtp_qws.h
-
-SOURCES = main.cpp \
- $$QT_SOURCE_TREE/src/gui/embedded/qmouselinuxtp_qws.cpp
-
diff --git a/src/plugins/mousedrivers/linuxtp/main.cpp b/src/plugins/mousedrivers/linuxtp/main.cpp
deleted file mode 100644
index 7ac358d4ce..0000000000
--- a/src/plugins/mousedrivers/linuxtp/main.cpp
+++ /dev/null
@@ -1,76 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qmousedriverplugin_qws.h>
-#include <qmouselinuxtp_qws.h>
-
-QT_BEGIN_NAMESPACE
-
-class QLinuxTPMouseDriver : public QMouseDriverPlugin
-{
-public:
- QLinuxTPMouseDriver();
-
- QStringList keys() const;
- QWSMouseHandler* create(const QString &driver, const QString &device);
-};
-
-QLinuxTPMouseDriver::QLinuxTPMouseDriver()
- : QMouseDriverPlugin()
-{
-}
-
-QStringList QLinuxTPMouseDriver::keys() const
-{
- return (QStringList() << "LinuxTP");
-}
-
-QWSMouseHandler* QLinuxTPMouseDriver::create(const QString &driver,
- const QString &device)
-{
- if (driver.compare(QLatin1String("LinuxTP"), Qt::CaseInsensitive))
- return 0;
- return new QWSLinuxTPMouseHandler(driver, device);
-}
-
-Q_EXPORT_PLUGIN2(qwslinuxtpmousehandler, QLinuxTPMouseDriver)
-
-QT_END_NAMESPACE
diff --git a/src/plugins/mousedrivers/mousedrivers.pro b/src/plugins/mousedrivers/mousedrivers.pro
deleted file mode 100644
index f89682b880..0000000000
--- a/src/plugins/mousedrivers/mousedrivers.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-TEMPLATE = subdirs
-contains(mouse-plugins, linuxtp): SUBDIRS += linuxtp
-contains(mouse-plugins, pc): SUBDIRS += pc
-contains(mouse-plugins, tslib): SUBDIRS += tslib
-contains(mouse-plugins, linuxinput): SUBDIRS += linuxinput
diff --git a/src/plugins/mousedrivers/pc/main.cpp b/src/plugins/mousedrivers/pc/main.cpp
deleted file mode 100644
index d87ac77e6a..0000000000
--- a/src/plugins/mousedrivers/pc/main.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qmousedriverplugin_qws.h>
-#include <qmousepc_qws.h>
-
-QT_BEGIN_NAMESPACE
-
-class QPcMouseDriver : public QMouseDriverPlugin
-{
-public:
- QPcMouseDriver();
-
- QStringList keys() const;
- QWSMouseHandler* create(const QString &driver, const QString &device);
-};
-
-QPcMouseDriver::QPcMouseDriver()
- : QMouseDriverPlugin()
-{
-}
-
-QStringList QPcMouseDriver::keys() const
-{
- return (QStringList()
- << QLatin1String("Auto")
- << QLatin1String("IntelliMouse")
- << QLatin1String("Microsoft")
- << QLatin1String("MouseSystems")
- << QLatin1String("MouseMan"));
-}
-
-QWSMouseHandler* QPcMouseDriver::create(const QString &driver,
- const QString &device)
-{
- if (!keys().contains(driver, Qt::CaseInsensitive))
- return 0;
- return new QWSPcMouseHandler(driver, device);
-}
-
-Q_EXPORT_PLUGIN2(qwspcmousehandler, QPcMouseDriver)
-
-QT_END_NAMESPACE
diff --git a/src/plugins/mousedrivers/pc/pc.pro b/src/plugins/mousedrivers/pc/pc.pro
deleted file mode 100644
index d38e3fe5d1..0000000000
--- a/src/plugins/mousedrivers/pc/pc.pro
+++ /dev/null
@@ -1,14 +0,0 @@
-TARGET = qpcmousedriver
-include(../../qpluginbase.pri)
-
-DESTDIR = $$QT.gui.plugins/mousedrivers
-target.path = $$[QT_INSTALL_PLUGINS]/mousedrivers
-INSTALLS += target
-
-DEFINES += QT_QWS_MOUSE_PC
-
-HEADERS = $$QT_SOURCE_TREE/src/gui/embedded/qmousepc_qws.h
-
-SOURCES = main.cpp \
- $$QT_SOURCE_TREE/src/gui/embedded/qmousepc_qws.cpp
-
diff --git a/src/plugins/mousedrivers/tslib/main.cpp b/src/plugins/mousedrivers/tslib/main.cpp
deleted file mode 100644
index d21315422b..0000000000
--- a/src/plugins/mousedrivers/tslib/main.cpp
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the plugins of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qmousedriverplugin_qws.h>
-#include <qmousetslib_qws.h>
-
-QT_BEGIN_NAMESPACE
-
-class TslibMouseDriver : public QMouseDriverPlugin
-{
-public:
- TslibMouseDriver();
-
- QStringList keys() const;
- QWSMouseHandler* create(const QString &driver, const QString &device);
-};
-
-TslibMouseDriver::TslibMouseDriver()
- : QMouseDriverPlugin()
-{
-}
-
-QStringList TslibMouseDriver::keys() const
-{
- return (QStringList() << "tslib");
-}
-
-QWSMouseHandler* TslibMouseDriver::create(const QString &driver,
- const QString &device)
-{
- if (driver.toLower() != "tslib")
- return 0;
- return new QWSTslibMouseHandler(driver, device);
-}
-
-Q_EXPORT_STATIC_PLUGIN(TslibMouseDriver)
-Q_EXPORT_PLUGIN2(qwstslibmousehandler, TslibMouseDriver)
-
-QT_END_NAMESPACE
diff --git a/src/plugins/mousedrivers/tslib/tslib.pro b/src/plugins/mousedrivers/tslib/tslib.pro
deleted file mode 100644
index e2fa013fdb..0000000000
--- a/src/plugins/mousedrivers/tslib/tslib.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TARGET = qtslibmousedriver
-include(../../qpluginbase.pri)
-
-DESTDIR = $$QT.gui.plugins/mousedrivers
-
-HEADERS = \
- $$QT_SOURCE_TREE/src/gui/embedded/qmousedriverplugin_qws.h \
- $$QT_SOURCE_TREE/src/gui/embedded/qmousetslib_qws.h
-SOURCES = main.cpp \
- $$QT_SOURCE_TREE/src/gui/embedded/qmousetslib_qws.cpp
-
-LIBS += -lts
-
-target.path += $$[QT_INSTALL_PLUGINS]/mousedrivers
-INSTALLS += target
-
diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.cpp b/src/plugins/platforms/eglconvenience/qeglconvenience.cpp
index df7abc1401..f3ce0fa809 100644
--- a/src/plugins/platforms/eglconvenience/qeglconvenience.cpp
+++ b/src/plugins/platforms/eglconvenience/qeglconvenience.cpp
@@ -43,7 +43,7 @@
QT_BEGIN_NAMESPACE
-QVector<EGLint> q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format)
+QVector<EGLint> q_createConfigAttributesFromFormat(const QWindowFormat &format)
{
int redSize = format.redBufferSize();
int greenSize = format.greenBufferSize();
@@ -53,17 +53,6 @@ QVector<EGLint> q_createConfigAttributesFromFormat(const QPlatformWindowFormat &
int stencilSize = format.stencilBufferSize();
int sampleCount = format.samples();
- // QPlatformWindowFormat uses a magic value of -1 to indicate "don't care", even when a buffer of that
- // type has been requested. So we must check QPlatformWindowFormat's booleans too if size is -1:
- if (format.alpha() && alphaSize <= 0)
- alphaSize = 1;
- if (format.depth() && depthSize <= 0)
- depthSize = 1;
- if (format.stencil() && stencilSize <= 0)
- stencilSize = 1;
- if (format.sampleBuffers() && sampleCount <= 0)
- sampleCount = 1;
-
// We want to make sure 16-bit configs are chosen over 32-bit configs as they will provide
// the best performance. The EGL config selection algorithm is a bit stange in this regard:
// The selection criteria for EGL_BUFFER_SIZE is "AtLeast", so we can't use it to discard
@@ -82,14 +71,14 @@ QVector<EGLint> q_createConfigAttributesFromFormat(const QPlatformWindowFormat &
// if the application sets the red/green/blue size to 5/6/5 on the QPlatformWindowFormat,
// they will probably get a 32-bit config, even when there's an RGB565 config available.
- // Now normalize the values so -1 becomes 0
- redSize = redSize > 0 ? redSize : 0;
- greenSize = greenSize > 0 ? greenSize : 0;
- blueSize = blueSize > 0 ? blueSize : 0;
- alphaSize = alphaSize > 0 ? alphaSize : 0;
- depthSize = depthSize > 0 ? depthSize : 0;
- stencilSize = stencilSize > 0 ? stencilSize : 0;
- sampleCount = sampleCount > 0 ? sampleCount : 0;
+// // Now normalize the values so -1 becomes 0
+// redSize = redSize > 0 ? redSize : 0;
+// greenSize = greenSize > 0 ? greenSize : 0;
+// blueSize = blueSize > 0 ? blueSize : 0;
+// alphaSize = alphaSize > 0 ? alphaSize : 0;
+// depthSize = depthSize > 0 ? depthSize : 0;
+// stencilSize = stencilSize > 0 ? stencilSize : 0;
+// sampleCount = sampleCount > 0 ? sampleCount : 0;
QVector<EGLint> configAttributes;
@@ -206,7 +195,7 @@ bool q_reduceConfigAttributes(QVector<EGLint> *configAttributes)
return false;
}
-EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, bool highestPixelFormat, int surfaceType)
+EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QWindowFormat &format, bool highestPixelFormat, int surfaceType)
{
EGLConfig cfg = 0;
QVector<EGLint> configureAttributes = q_createConfigAttributesFromFormat(format);
@@ -214,11 +203,7 @@ EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformW
configureAttributes.append(surfaceType);
configureAttributes.append(EGL_RENDERABLE_TYPE);
- if (format.windowApi() == QPlatformWindowFormat::OpenVG) {
- configureAttributes.append(EGL_OPENVG_BIT);
- } else {
- configureAttributes.append(EGL_OPENGL_ES2_BIT);
- }
+ configureAttributes.append(EGL_OPENGL_ES2_BIT);
configureAttributes.append(EGL_NONE);
do {
@@ -272,9 +257,9 @@ EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformW
return 0;
}
-QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, const EGLConfig config)
+QWindowFormat q_windowFormatFromConfig(EGLDisplay display, const EGLConfig config)
{
- QPlatformWindowFormat format;
+ QWindowFormat format;
EGLint redSize = 0;
EGLint greenSize = 0;
EGLint blueSize = 0;
@@ -282,7 +267,6 @@ QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, con
EGLint depthSize = 0;
EGLint stencilSize = 0;
EGLint sampleCount = 0;
- EGLint level = 0;
eglGetConfigAttrib(display, config, EGL_RED_SIZE, &redSize);
eglGetConfigAttrib(display, config, EGL_GREEN_SIZE, &greenSize);
@@ -291,7 +275,6 @@ QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, con
eglGetConfigAttrib(display, config, EGL_DEPTH_SIZE, &depthSize);
eglGetConfigAttrib(display, config, EGL_STENCIL_SIZE, &stencilSize);
eglGetConfigAttrib(display, config, EGL_SAMPLES, &sampleCount);
- eglGetConfigAttrib(display, config, EGL_LEVEL, &level);
format.setRedBufferSize(redSize);
format.setGreenBufferSize(greenSize);
@@ -300,10 +283,7 @@ QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, con
format.setDepthBufferSize(depthSize);
format.setStencilBufferSize(stencilSize);
format.setSamples(sampleCount);
- format.setDirectRendering(true); // All EGL contexts are direct-rendered
- format.setRgba(true); // EGL doesn't support colour index rendering
format.setStereo(false); // EGL doesn't support stereo buffers
- format.setAccumBufferSize(0); // EGL doesn't support accululation buffers
// Clear the EGL error state because some of the above may
// have errored out because the attribute is not applicable
diff --git a/src/plugins/platforms/eglconvenience/qeglconvenience.h b/src/plugins/platforms/eglconvenience/qeglconvenience.h
index c7d3d61ae5..d0863219ab 100644
--- a/src/plugins/platforms/eglconvenience/qeglconvenience.h
+++ b/src/plugins/platforms/eglconvenience/qeglconvenience.h
@@ -43,16 +43,16 @@
#define QEGLCONVENIENCE_H
-#include <QtGui/QPlatformWindowFormat>
+#include <QtGui/QWindowFormat>
#include <QtCore/QVector>
#include <EGL/egl.h>
QT_BEGIN_NAMESPACE
-QVector<EGLint> q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format);
+QVector<EGLint> q_createConfigAttributesFromFormat(const QWindowFormat &format);
bool q_reduceConfigAttributes(QVector<EGLint> *configAttributes);
-EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, bool highestPixelFormat = false, int surfaceType = EGL_WINDOW_BIT);
-QPlatformWindowFormat qt_qPlatformWindowFormatFromConfig(EGLDisplay display, const EGLConfig config);
+EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QWindowFormat &format, bool highestPixelFormat = false, int surfaceType = EGL_WINDOW_BIT);
+QWindowFormat q_windowFormatFromConfig(EGLDisplay display, const EGLConfig config);
bool q_hasEglExtension(EGLDisplay display,const char* extensionName);
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp
index ae5215f320..30dd86215d 100644
--- a/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp
+++ b/src/plugins/platforms/eglconvenience/qeglplatformcontext.cpp
@@ -66,7 +66,7 @@ QEGLPlatformContext::QEGLPlatformContext(EGLDisplay display, EGLConfig config, E
qFatal("EGL error");
}
- m_windowFormat = qt_qPlatformWindowFormatFromConfig(display,config);
+ m_windowFormat = q_windowFormatFromConfig(display,config);
}
QEGLPlatformContext::~QEGLPlatformContext()
@@ -88,7 +88,6 @@ QEGLPlatformContext::~QEGLPlatformContext()
void QEGLPlatformContext::makeCurrent()
{
- QPlatformGLContext::makeCurrent();
#ifdef QEGL_EXTRA_DEBUG
qWarning("QEglContext::makeCurrent: %p\n",this);
#endif
@@ -118,7 +117,6 @@ void QEGLPlatformContext::makeCurrent()
}
void QEGLPlatformContext::doneCurrent()
{
- QPlatformGLContext::doneCurrent();
#ifdef QEGL_EXTRA_DEBUG
qWarning("QEglContext::doneCurrent:%p\n",this);
#endif
@@ -146,7 +144,7 @@ void* QEGLPlatformContext::getProcAddress(const QString& procName)
return (void *)eglGetProcAddress(qPrintable(procName));
}
-QPlatformWindowFormat QEGLPlatformContext::platformWindowFormat() const
+QWindowFormat QEGLPlatformContext::windowFormat() const
{
return m_windowFormat;
}
diff --git a/src/plugins/platforms/eglconvenience/qeglplatformcontext.h b/src/plugins/platforms/eglconvenience/qeglplatformcontext.h
index 69835d7eb4..048fd72215 100644
--- a/src/plugins/platforms/eglconvenience/qeglplatformcontext.h
+++ b/src/plugins/platforms/eglconvenience/qeglplatformcontext.h
@@ -56,7 +56,7 @@ public:
void swapBuffers();
void* getProcAddress(const QString& procName);
- QPlatformWindowFormat platformWindowFormat() const;
+ QWindowFormat windowFormat() const;
EGLContext eglContext() const;
private:
@@ -65,7 +65,7 @@ private:
EGLSurface m_eglSurface;
EGLenum m_eglApi;
- QPlatformWindowFormat m_windowFormat;
+ QWindowFormat m_windowFormat;
};
#endif //QOPENKODEGLINTEGRATION_H
diff --git a/src/plugins/platforms/eglfs/qeglfswindow.h b/src/plugins/platforms/eglfs/qeglfswindow.h
index f125eab3c1..66079edacb 100644
--- a/src/plugins/platforms/eglfs/qeglfswindow.h
+++ b/src/plugins/platforms/eglfs/qeglfswindow.h
@@ -46,7 +46,7 @@
#include "qeglfsscreen.h"
#include <QPlatformWindow>
-#include <QtGui/QWidget>
+#include <QtWidgets/QWidget>
QT_BEGIN_NAMESPACE
diff --git a/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp b/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp
index 895f8af58e..c87dc497b4 100644
--- a/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp
+++ b/src/plugins/platforms/fontdatabases/basicunix/qbasicunixfontdatabase.cpp
@@ -41,7 +41,7 @@
#include "qbasicunixfontdatabase.h"
-#include <QtGui/private/qapplication_p.h>
+#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/QPlatformScreen>
#include <QtCore/QFile>
diff --git a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp
index 2a3fd5a8b5..5655b6b7fd 100644
--- a/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp
+++ b/src/plugins/platforms/fontdatabases/fontconfig/qfontconfigdatabase.cpp
@@ -46,7 +46,6 @@
#include <QtCore/QElapsedTimer>
-#include <QtGui/private/qapplication_p.h>
#include <QtGui/QPlatformScreen>
#include <QtGui/private/qfontengine_ft_p.h>
diff --git a/src/plugins/platforms/glxconvenience/qglxconvenience.cpp b/src/plugins/platforms/glxconvenience/qglxconvenience.cpp
index 7cee3e2ea1..abf7b83e04 100644
--- a/src/plugins/platforms/glxconvenience/qglxconvenience.cpp
+++ b/src/plugins/platforms/glxconvenience/qglxconvenience.cpp
@@ -66,7 +66,7 @@ enum {
#undef FontChange
#endif
-QVector<int> qglx_buildSpec(const QPlatformWindowFormat &format, int drawableBit)
+QVector<int> qglx_buildSpec(const QWindowFormat &format, int drawableBit)
{
QVector<int> spec(48);
int i = 0;
@@ -75,54 +75,37 @@ QVector<int> qglx_buildSpec(const QPlatformWindowFormat &format, int drawableBit
spec[i++] = 0;
spec[i++] = GLX_DRAWABLE_TYPE; spec[i++] = drawableBit;
- if (format.rgba()) {
- spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_RGBA_BIT;
- spec[i++] = GLX_RED_SIZE; spec[i++] = (format.redBufferSize() == -1) ? 1 : format.redBufferSize();
- spec[i++] = GLX_GREEN_SIZE; spec[i++] = (format.greenBufferSize() == -1) ? 1 : format.greenBufferSize();
- spec[i++] = GLX_BLUE_SIZE; spec[i++] = (format.blueBufferSize() == -1) ? 1 : format.blueBufferSize();
- if (format.alpha()) {
- spec[i++] = GLX_ALPHA_SIZE; spec[i++] = (format.alphaBufferSize() == -1) ? 1 : format.alphaBufferSize();
- }
-
- spec[i++] = GLX_ACCUM_RED_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
- spec[i++] = GLX_ACCUM_GREEN_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
- spec[i++] = GLX_ACCUM_BLUE_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
-
- if (format.alpha()) {
- spec[i++] = GLX_ACCUM_ALPHA_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
- }
-
- } else {
- spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_COLOR_INDEX_BIT; //I'm really not sure if this works....
- spec[i++] = GLX_BUFFER_SIZE; spec[i++] = 8;
+ spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_RGBA_BIT;
+ spec[i++] = GLX_RED_SIZE; spec[i++] = (format.redBufferSize() == -1) ? 1 : format.redBufferSize();
+ spec[i++] = GLX_GREEN_SIZE; spec[i++] = (format.greenBufferSize() == -1) ? 1 : format.greenBufferSize();
+ spec[i++] = GLX_BLUE_SIZE; spec[i++] = (format.blueBufferSize() == -1) ? 1 : format.blueBufferSize();
+ if (format.hasAlpha()) {
+ spec[i++] = GLX_ALPHA_SIZE; spec[i++] = (format.alphaBufferSize() == -1) ? 1 : format.alphaBufferSize();
}
- spec[i++] = GLX_DOUBLEBUFFER; spec[i++] = format.doubleBuffer() ? True : False;
+ spec[i++] = GLX_DOUBLEBUFFER; spec[i++] = format.swapBehavior() != QWindowFormat::SingleBuffer ? True : False;
spec[i++] = GLX_STEREO; spec[i++] = format.stereo() ? True : False;
- if (format.depth()) {
- spec[i++] = GLX_DEPTH_SIZE; spec[i++] = (format.depthBufferSize() == -1) ? 1 : format.depthBufferSize();
- }
+ spec[i++] = GLX_DEPTH_SIZE; spec[i++] = (format.depthBufferSize() == -1) ? 1 : format.depthBufferSize();
- if (format.stencil()) {
- spec[i++] = GLX_STENCIL_SIZE; spec[i++] = (format.stencilBufferSize() == -1) ? 1 : format.stencilBufferSize();
- }
- if (format.sampleBuffers()) {
+ spec[i++] = GLX_STENCIL_SIZE; spec[i++] = (format.stencilBufferSize() == -1) ? 1 : format.stencilBufferSize();
+
+ if (format.samples() > 1) {
spec[i++] = GLX_SAMPLE_BUFFERS_ARB;
spec[i++] = 1;
spec[i++] = GLX_SAMPLES_ARB;
- spec[i++] = format.samples() == -1 ? 4 : format.samples();
+ spec[i++] = format.samples();
}
spec[i++] = XNone;
return spec;
}
-GLXFBConfig qglx_findConfig(Display *display, int screen , const QPlatformWindowFormat &format, int drawableBit)
+GLXFBConfig qglx_findConfig(Display *display, int screen , const QWindowFormat &format, int drawableBit)
{
bool reduced = true;
GLXFBConfig chosenConfig = 0;
- QPlatformWindowFormat reducedFormat = format;
+ QWindowFormat reducedFormat = format;
while (!chosenConfig && reduced) {
QVector<int> spec = qglx_buildSpec(reducedFormat, drawableBit);
int confcount = 0;
@@ -133,7 +116,7 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , const QPlatformWindow
for (int i = 0; i < confcount; i++) {
chosenConfig = configs[i];
// Make sure we try to get an ARGB visual if the format asked for an alpha:
- if (reducedFormat.alpha()) {
+ if (reducedFormat.hasAlpha()) {
int alphaSize;
glXGetFBConfigAttrib(display,configs[i],GLX_ALPHA_SIZE,&alphaSize);
if (alphaSize > 0)
@@ -145,7 +128,7 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , const QPlatformWindow
XFree(configs);
}
- reducedFormat = qglx_reducePlatformWindowFormat(reducedFormat,&reduced);
+ reducedFormat = qglx_reduceWindowFormat(reducedFormat,&reduced);
}
if (!chosenConfig)
@@ -154,16 +137,16 @@ GLXFBConfig qglx_findConfig(Display *display, int screen , const QPlatformWindow
return chosenConfig;
}
-XVisualInfo *qglx_findVisualInfo(Display *display, int screen, const QPlatformWindowFormat &format)
+XVisualInfo *qglx_findVisualInfo(Display *display, int screen, const QWindowFormat &format)
{
GLXFBConfig config = qglx_findConfig(display,screen,format);
XVisualInfo *visualInfo = glXGetVisualFromFBConfig(display,config);
return visualInfo;
}
-QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext ctx)
+QWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext)
{
- QPlatformWindowFormat format;
+ QWindowFormat format;
int redSize = 0;
int greenSize = 0;
int blueSize = 0;
@@ -172,16 +155,9 @@ QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFB
int stencilSize = 0;
int sampleBuffers = 0;
int sampleCount = 0;
- int level = 0;
- int rgba = 0;
int stereo = 0;
- int accumSizeA = 0;
- int accumSizeR = 0;
- int accumSizeG = 0;
- int accumSizeB = 0;
XVisualInfo *vi = glXGetVisualFromFBConfig(display,config);
- glXGetConfig(display,vi,GLX_RGBA,&rgba);
XFree(vi);
glXGetFBConfigAttrib(display, config, GLX_RED_SIZE, &redSize);
glXGetFBConfigAttrib(display, config, GLX_GREEN_SIZE, &greenSize);
@@ -190,12 +166,7 @@ QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFB
glXGetFBConfigAttrib(display, config, GLX_DEPTH_SIZE, &depthSize);
glXGetFBConfigAttrib(display, config, GLX_STENCIL_SIZE, &stencilSize);
glXGetFBConfigAttrib(display, config, GLX_SAMPLES, &sampleBuffers);
- glXGetFBConfigAttrib(display, config, GLX_LEVEL, &level);
glXGetFBConfigAttrib(display, config, GLX_STEREO, &stereo);
- glXGetFBConfigAttrib(display, config, GLX_ACCUM_ALPHA_SIZE, &accumSizeA);
- glXGetFBConfigAttrib(display, config, GLX_ACCUM_RED_SIZE, &accumSizeR);
- glXGetFBConfigAttrib(display, config, GLX_ACCUM_GREEN_SIZE, &accumSizeG);
- glXGetFBConfigAttrib(display, config, GLX_ACCUM_BLUE_SIZE, &accumSizeB);
format.setRedBufferSize(redSize);
format.setGreenBufferSize(greenSize);
@@ -203,39 +174,31 @@ QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFB
format.setAlphaBufferSize(alphaSize);
format.setDepthBufferSize(depthSize);
format.setStencilBufferSize(stencilSize);
- format.setSampleBuffers(sampleBuffers);
- if (format.sampleBuffers()) {
+ if (sampleBuffers) {
glXGetFBConfigAttrib(display, config, GLX_SAMPLES_ARB, &sampleCount);
format.setSamples(sampleCount);
}
- format.setDirectRendering(glXIsDirect(display, ctx));
- format.setRgba(rgba);
format.setStereo(stereo);
- format.setAccumBufferSize(accumSizeB);
return format;
}
-QPlatformWindowFormat qglx_reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced)
+QWindowFormat qglx_reduceWindowFormat(const QWindowFormat &format, bool *reduced)
{
- QPlatformWindowFormat retFormat = format;
+ QWindowFormat retFormat = format;
*reduced = true;
- if (retFormat.sampleBuffers()) {
- retFormat.setSampleBuffers(false);
+ if (retFormat.samples() > 1) {
+ retFormat.setSamples(0);
} else if (retFormat.stereo()) {
retFormat.setStereo(false);
- } else if (retFormat.accum()) {
- retFormat.setAccum(false);
- }else if (retFormat.stencil()) {
- retFormat.setStencil(false);
- }else if (retFormat.alpha()) {
- retFormat.setAlpha(false);
- }else if (retFormat.depth()) {
- retFormat.setDepth(false);
- }else if (retFormat.doubleBuffer()) {
- retFormat.setDoubleBuffer(false);
+ }else if (retFormat.stencilBufferSize() > 0) {
+ retFormat.setStencilBufferSize(0);
+ }else if (retFormat.hasAlpha()) {
+ retFormat.setAlphaBufferSize(0);
+ }else if (retFormat.depthBufferSize() > 0) {
+ retFormat.setDepthBufferSize(0);
}else{
*reduced = false;
}
diff --git a/src/plugins/platforms/glxconvenience/qglxconvenience.h b/src/plugins/platforms/glxconvenience/qglxconvenience.h
index 2c59dbb324..765a08a39d 100644
--- a/src/plugins/platforms/glxconvenience/qglxconvenience.h
+++ b/src/plugins/platforms/glxconvenience/qglxconvenience.h
@@ -42,15 +42,15 @@
#ifndef QGLXCONVENIENCE_H
#define QGLXCONVENIENCE_H
-#include <QPlatformWindowFormat>
+#include <QWindowFormat>
#include <X11/Xlib.h>
#include <GL/glx.h>
-XVisualInfo *qglx_findVisualInfo(Display *display, int screen, const QPlatformWindowFormat &format);
-GLXFBConfig qglx_findConfig(Display *display, int screen, const QPlatformWindowFormat &format, int drawableBit = GLX_WINDOW_BIT);
-QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext context);
-QVector<int> qglx_buildSpec(const QPlatformWindowFormat &format, int drawableBit = GLX_WINDOW_BIT);
-QPlatformWindowFormat qglx_reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced);
+XVisualInfo *qglx_findVisualInfo(Display *display, int screen, const QWindowFormat &format);
+GLXFBConfig qglx_findConfig(Display *display, int screen, const QWindowFormat &format, int drawableBit = GLX_WINDOW_BIT);
+QWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext context);
+QVector<int> qglx_buildSpec(const QWindowFormat &format, int drawableBit = GLX_WINDOW_BIT);
+QWindowFormat qglx_reduceWindowFormat(const QWindowFormat &format, bool *reduced);
#endif // QGLXCONVENIENCE_H
diff --git a/src/plugins/platforms/minimal/minimal.pro b/src/plugins/platforms/minimal/minimal.pro
index d1088e3233..5c8b55478a 100644
--- a/src/plugins/platforms/minimal/minimal.pro
+++ b/src/plugins/platforms/minimal/minimal.pro
@@ -1,5 +1,6 @@
TARGET = qminimal
include(../../qpluginbase.pri)
+QT += gui-private core-private
QT = core-private gui-private
DESTDIR = $$QT.gui.plugins/platforms
diff --git a/src/plugins/platforms/minimal/qminimalintegration.cpp b/src/plugins/platforms/minimal/qminimalintegration.cpp
index 3a545e4e5c..1fb4f01c1e 100644
--- a/src/plugins/platforms/minimal/qminimalintegration.cpp
+++ b/src/plugins/platforms/minimal/qminimalintegration.cpp
@@ -69,14 +69,14 @@ QPixmapData *QMinimalIntegration::createPixmapData(QPixmapData::PixelType type)
return new QRasterPixmapData(type);
}
-QPlatformWindow *QMinimalIntegration::createPlatformWindow(QWidget *widget, WId winId) const
+QPlatformWindow *QMinimalIntegration::createPlatformWindow(QWindow *window) const
{
- Q_UNUSED(winId);
- return new QPlatformWindow(widget);
+ Q_UNUSED(window);
+ return new QPlatformWindow(window);
}
-QWindowSurface *QMinimalIntegration::createWindowSurface(QWidget *widget, WId winId) const
+QWindowSurface *QMinimalIntegration::createWindowSurface(QWindow *window, WId winId) const
{
Q_UNUSED(winId);
- return new QMinimalWindowSurface(widget);
+ return new QMinimalWindowSurface(window);
}
diff --git a/src/plugins/platforms/minimal/qminimalintegration.h b/src/plugins/platforms/minimal/qminimalintegration.h
index 5f93443b8c..7191441b91 100644
--- a/src/plugins/platforms/minimal/qminimalintegration.h
+++ b/src/plugins/platforms/minimal/qminimalintegration.h
@@ -72,8 +72,8 @@ public:
bool hasCapability(QPlatformIntegration::Capability cap) const;
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
- QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
- QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
+ QPlatformWindow *createPlatformWindow(QWindow *window) const;
+ QWindowSurface *createWindowSurface(QWindow *window, WId winId) const;
QList<QPlatformScreen *> screens() const { return mScreens; }
diff --git a/src/plugins/platforms/minimal/qminimalwindowsurface.cpp b/src/plugins/platforms/minimal/qminimalwindowsurface.cpp
index dd8c9b7045..b3f7532e37 100644
--- a/src/plugins/platforms/minimal/qminimalwindowsurface.cpp
+++ b/src/plugins/platforms/minimal/qminimalwindowsurface.cpp
@@ -42,11 +42,11 @@
#include "qminimalwindowsurface.h"
#include <QtCore/qdebug.h>
-#include <QtGui/private/qapplication_p.h>
+#include <private/qguiapplication_p.h>
QT_BEGIN_NAMESPACE
-QMinimalWindowSurface::QMinimalWindowSurface(QWidget *window)
+QMinimalWindowSurface::QMinimalWindowSurface(QWindow *window)
: QWindowSurface(window)
{
//qDebug() << "QMinimalWindowSurface::QMinimalWindowSurface:" << (long)this;
@@ -62,9 +62,9 @@ QPaintDevice *QMinimalWindowSurface::paintDevice()
return &mImage;
}
-void QMinimalWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+void QMinimalWindowSurface::flush(QWindow *window, const QRegion &region, const QPoint &offset)
{
- Q_UNUSED(widget);
+ Q_UNUSED(window);
Q_UNUSED(region);
Q_UNUSED(offset);
@@ -78,7 +78,7 @@ void QMinimalWindowSurface::resize(const QSize &size)
{
//qDebug() << "QMinimalWindowSurface::setGeometry:" << (long)this << rect;
QWindowSurface::resize(size);
- QImage::Format format = QApplicationPrivate::platformIntegration()->screens().first()->format();
+ QImage::Format format = QGuiApplicationPrivate::platformIntegration()->screens().first()->format();
if (mImage.size() != size)
mImage = QImage(size, format);
}
diff --git a/src/plugins/platforms/minimal/qminimalwindowsurface.h b/src/plugins/platforms/minimal/qminimalwindowsurface.h
index bfeeacadc9..88ed279590 100644
--- a/src/plugins/platforms/minimal/qminimalwindowsurface.h
+++ b/src/plugins/platforms/minimal/qminimalwindowsurface.h
@@ -45,17 +45,18 @@
#include <QtGui/private/qwindowsurface_p.h>
#include <QtGui/QPlatformWindow>
+#include <QtGui/QImage>
QT_BEGIN_NAMESPACE
class QMinimalWindowSurface : public QWindowSurface
{
public:
- QMinimalWindowSurface(QWidget *window);
+ QMinimalWindowSurface(QWindow *window);
~QMinimalWindowSurface();
QPaintDevice *paintDevice();
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+ void flush(QWindow *window, const QRegion &region, const QPoint &offset);
void resize(const QSize &size);
private:
diff --git a/src/plugins/platforms/openkode/qopenkodewindow.cpp b/src/plugins/platforms/openkode/qopenkodewindow.cpp
index d34dff8a34..ef54ee63b9 100644
--- a/src/plugins/platforms/openkode/qopenkodewindow.cpp
+++ b/src/plugins/platforms/openkode/qopenkodewindow.cpp
@@ -53,7 +53,7 @@
#include <EGL/egl.h>
-#include <QtGui/qwidget.h>
+#include <QtWidgets/qwidget.h>
#include <QtGui/private/qwidget_p.h>
#include <QtGui/private/qapplication_p.h>
diff --git a/src/plugins/platforms/vnc/qvncserver.cpp b/src/plugins/platforms/vnc/qvncserver.cpp
index be2de7c007..38dea35bff 100644
--- a/src/plugins/platforms/vnc/qvncserver.cpp
+++ b/src/plugins/platforms/vnc/qvncserver.cpp
@@ -43,7 +43,7 @@
#include <QtCore/qtimer.h>
#include <QtCore/qregexp.h>
-#include <QtGui/qwidget.h>
+#include <QtWidgets/qwidget.h>
#include <QtGui/qpolygon.h>
#include <QtGui/qpainter.h>
diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h
index ac16039c9d..bb829a15fb 100644
--- a/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h
+++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglintegration.h
@@ -44,7 +44,7 @@
class QWaylandWindow;
class QWaylandDisplay;
-class QWidget;
+class QWindow;
class QWaylandGLIntegration
{
@@ -54,7 +54,7 @@ public:
virtual void initialize() = 0;
- virtual QWaylandWindow *createEglWindow(QWidget *widget) = 0;
+ virtual QWaylandWindow *createEglWindow(QWindow *window) = 0;
static QWaylandGLIntegration *createGLIntegration(QWaylandDisplay *waylandDisplay);
};
diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp
index ebe4c7bf86..3fc063aab7 100644
--- a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.cpp
@@ -47,6 +47,7 @@
#include <QtOpenGL/QGLFramebufferObject>
#include <QtOpenGL/QGLContext>
+#include <QPlatformGLContext>
#include <QtOpenGL/private/qglengineshadermanager_p.h>
@@ -133,9 +134,9 @@ static void blitTexture(QGLContext *ctx, GLuint texture, const QSize &viewport,
drawTexture(r, texture, texSize, sourceRect);
}
-QWaylandGLWindowSurface::QWaylandGLWindowSurface(QWidget *window)
+QWaylandGLWindowSurface::QWaylandGLWindowSurface(QWindow *window)
: QWindowSurface(window)
- , mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display())
+ , mDisplay(QWaylandScreen::waylandScreenFromWindow(window)->display())
, mPaintDevice(0)
{
@@ -153,30 +154,29 @@ QPaintDevice *QWaylandGLWindowSurface::paintDevice()
void QWaylandGLWindowSurface::beginPaint(const QRegion &)
{
- window()->platformWindow()->glContext()->makeCurrent();
+ window()->handle()->glContext()->makeCurrent();
glClearColor(0,0,0,0xff);
glClear(GL_COLOR_BUFFER_BIT);
}
-void QWaylandGLWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+void QWaylandGLWindowSurface::flush(QWindow *window, const QRegion &region, const QPoint &offset)
{
Q_UNUSED(offset);
Q_UNUSED(region);
- QWaylandWindow *ww = (QWaylandWindow *) widget->platformWindow();
-
+
if (mPaintDevice->isBound())
mPaintDevice->release();
QRect rect(0,0,size().width(),size().height());
- QGLContext *ctx = QGLContext::fromPlatformGLContext(ww->glContext());
+ QGLContext *ctx = QGLContext::fromWindowContext(window->glContext());
blitTexture(ctx,mPaintDevice->texture(),size(),mPaintDevice->size(),rect,rect);
- ww->glContext()->swapBuffers();
+ window->glContext()->swapBuffers();
}
void QWaylandGLWindowSurface::resize(const QSize &size)
{
QWindowSurface::resize(size);
- window()->platformWindow()->glContext()->makeCurrent();
+ window()->glContext()->makeCurrent();
delete mPaintDevice;
mPaintDevice = new QGLFramebufferObject(size);
}
diff --git a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h
index 8d53b42a56..1de449b4dc 100644
--- a/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h
+++ b/src/plugins/platforms/wayland/gl_integration/qwaylandglwindowsurface.h
@@ -51,13 +51,13 @@ class QGLFramebufferObject;
class QWaylandGLWindowSurface : public QWindowSurface
{
public:
- QWaylandGLWindowSurface(QWidget *window);
+ QWaylandGLWindowSurface(QWindow *window);
~QWaylandGLWindowSurface();
void beginPaint(const QRegion &);
QPaintDevice *paintDevice();
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+ void flush(QWindow *window, const QRegion &region, const QPoint &offset);
void resize(const QSize &size);
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp
index d63087d934..6971459659 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.cpp
@@ -97,8 +97,6 @@ QWaylandReadbackEglContext::~QWaylandReadbackEglContext()
void QWaylandReadbackEglContext::makeCurrent()
{
- QPlatformGLContext::makeCurrent();
-
mWindow->waitForFrameSync();
eglMakeCurrent(mEglIntegration->eglDisplay(),mPixmapSurface,mPixmapSurface,mContext);
@@ -114,7 +112,7 @@ void QWaylandReadbackEglContext::swapBuffers()
{
eglSwapBuffers(mEglIntegration->eglDisplay(),mPixmapSurface);
- if (QPlatformGLContext::currentContext() != this) {
+ if (QWindowContext::currentContext().handle() != this) {
makeCurrent();
}
@@ -145,7 +143,7 @@ void * QWaylandReadbackEglContext::getProcAddress(const QString &procName)
QPlatformWindowFormat QWaylandReadbackEglContext::platformWindowFormat() const
{
- return qt_qPlatformWindowFormatFromConfig(mEglIntegration->eglDisplay(),mConfig);
+ return q_windowFormatFromConfig(mEglIntegration->eglDisplay(),mConfig);
}
void QWaylandReadbackEglContext::geometryChanged()
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h
index ac682759e9..1540b92080 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h
+++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglcontext.h
@@ -43,7 +43,6 @@
#define QWAYLANDREADBACKEGLGLCONTEXT_H
#include <QPlatformGLContext>
-#include <QtGui/QWidget>
#include "qwaylandreadbackeglintegration.h"
#include "qwaylandreadbackeglwindow.h"
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp
index 20f7ffb609..8a3d769e65 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.cpp
@@ -81,7 +81,7 @@ void QWaylandReadbackEglIntegration::initialize()
}
}
-QWaylandWindow * QWaylandReadbackEglIntegration::createEglWindow(QWidget *widget)
+QWaylandWindow * QWaylandReadbackEglIntegration::createEglWindow(QWindow *window)
{
return new QWaylandReadbackEglWindow(widget,this);
}
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h
index 84fa64fd34..767634bbc2 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h
+++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglintegration.h
@@ -48,7 +48,6 @@
#include <QtCore/QDataStream>
#include <QtCore/QMetaType>
#include <QtCore/QVariant>
-#include <QtGui/QWidget>
#include <X11/Xlib.h>
@@ -61,7 +60,7 @@ public:
~QWaylandReadbackEglIntegration();
void initialize();
- QWaylandWindow *createEglWindow(QWidget *widget);
+ QWaylandWindow *createEglWindow(QWindow *window);
QWaylandDisplay *waylandDisplay() const;
Display *xDisplay() const;
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp
index 2ae212ba67..134f431c3d 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.cpp
@@ -43,7 +43,7 @@
#include "qwaylandreadbackeglcontext.h"
-QWaylandReadbackEglWindow::QWaylandReadbackEglWindow(QWidget *window, QWaylandReadbackEglIntegration *eglIntegration)
+QWaylandReadbackEglWindow::QWaylandReadbackEglWindow(QWindow *window, QWaylandReadbackEglIntegration *eglIntegration)
: QWaylandShmWindow(window)
, mEglIntegration(eglIntegration)
, mContext(0)
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h
index 453ad27cd9..6fd09659dc 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h
+++ b/src/plugins/platforms/wayland/gl_integration/readback_egl/qwaylandreadbackeglwindow.h
@@ -50,7 +50,7 @@ class QWaylandReadbackEglContext;
class QWaylandReadbackEglWindow : public QWaylandShmWindow
{
public:
- QWaylandReadbackEglWindow(QWidget *window, QWaylandReadbackEglIntegration *eglIntegration);
+ QWaylandReadbackEglWindow(QWindow *window, QWaylandReadbackEglIntegration *eglIntegration);
WindowType windowType() const;
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp
index 08c5cf6c51..5bafd418df 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxcontext.cpp
@@ -85,8 +85,6 @@ QWaylandReadbackGlxContext::QWaylandReadbackGlxContext(QWaylandReadbackGlxIntegr
void QWaylandReadbackGlxContext::makeCurrent()
{
- QPlatformGLContext::makeCurrent();
-
glXMakeCurrent(mGlxIntegration->xDisplay(),mGlxPixmap,mContext);
}
@@ -97,7 +95,7 @@ void QWaylandReadbackGlxContext::doneCurrent()
void QWaylandReadbackGlxContext::swapBuffers()
{
- if (QPlatformGLContext::currentContext() != this) {
+ if (QWindowContext::currentContext().handle() != this) {
makeCurrent();
}
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp
index 4651f0c30e..25422d6c4f 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.cpp
@@ -66,9 +66,9 @@ void QWaylandReadbackGlxIntegration::initialize()
{
}
-QWaylandWindow * QWaylandReadbackGlxIntegration::createEglWindow(QWidget *widget)
+QWaylandWindow * QWaylandReadbackGlxIntegration::createEglWindow(QWindow *window)
{
- return new QWaylandReadbackGlxWindow(widget,this);
+ return new QWaylandReadbackGlxWindow(window,this);
}
QWaylandGLIntegration * QWaylandGLIntegration::createGLIntegration(QWaylandDisplay *waylandDisplay)
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h
index 9056393905..c706da7f79 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h
+++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxintegration.h
@@ -48,7 +48,7 @@
#include <QtCore/QDataStream>
#include <QtCore/QMetaType>
#include <QtCore/QVariant>
-#include <QtGui/QWidget>
+#include <QtGui/QWindow>
#include <X11/Xlib.h>
@@ -60,7 +60,7 @@ public:
void initialize();
- QWaylandWindow *createEglWindow(QWidget *widget);
+ QWaylandWindow *createEglWindow(QWindow *window);
QWaylandDisplay *waylandDisplay() const;
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp
index ca1603c649..f095862227 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.cpp
@@ -41,7 +41,7 @@
#include "qwaylandreadbackglxwindow.h"
-QWaylandReadbackGlxWindow::QWaylandReadbackGlxWindow(QWidget *window, QWaylandReadbackGlxIntegration *glxIntegration)
+QWaylandReadbackGlxWindow::QWaylandReadbackGlxWindow(QWindow *window, QWaylandReadbackGlxIntegration *glxIntegration)
: QWaylandShmWindow(window)
, mGlxIntegration(glxIntegration)
, mContext(0)
diff --git a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h
index 4d7bb3ee74..47a1ce9ab4 100644
--- a/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h
+++ b/src/plugins/platforms/wayland/gl_integration/readback_glx/qwaylandreadbackglxwindow.h
@@ -49,7 +49,7 @@
class QWaylandReadbackGlxWindow : public QWaylandShmWindow
{
public:
- QWaylandReadbackGlxWindow(QWidget *window, QWaylandReadbackGlxIntegration *glxIntegration);
+ QWaylandReadbackGlxWindow(QWindow *window, QWaylandReadbackGlxIntegration *glxIntegration);
WindowType windowType() const;
QPlatformGLContext *glContext() const;
diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp
index ddd17636c1..ac58312310 100644
--- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.cpp
@@ -73,7 +73,7 @@ void QWaylandEglIntegration::initialize()
}
}
-QWaylandWindow *QWaylandEglIntegration::createEglWindow(QWidget *window)
+QWaylandWindow *QWaylandEglIntegration::createEglWindow(QWindow *window)
{
return new QWaylandEglWindow(window);
}
diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h
index 3a26f97b32..66e272353a 100644
--- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h
+++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglintegration.h
@@ -47,7 +47,7 @@
#include "qwaylandeglinclude.h"
class QWaylandWindow;
-class QWidget;
+class QWindow;
class QWaylandEglIntegration : public QWaylandGLIntegration
{
@@ -57,7 +57,7 @@ public:
void initialize();
- QWaylandWindow *createEglWindow(QWidget *window);
+ QWaylandWindow *createEglWindow(QWindow *window);
EGLDisplay eglDisplay() const;
struct wl_egl_display *nativeDisplay() const;
diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp
index cf52f39d15..ad8786fd50 100644
--- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.cpp
@@ -44,7 +44,7 @@
#include "qwaylandscreen.h"
#include "qwaylandglcontext.h"
-QWaylandEglWindow::QWaylandEglWindow(QWidget *window)
+QWaylandEglWindow::QWaylandEglWindow(QWindow *window)
: QWaylandWindow(window)
, mGLContext(0)
, mWaylandEglWindow(0)
diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h
index 856321dec8..ddc7a5af6e 100644
--- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h
+++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandeglwindow.h
@@ -51,7 +51,7 @@ class QWaylandGLContext;
class QWaylandEglWindow : public QWaylandWindow
{
public:
- QWaylandEglWindow(QWidget *window);
+ QWaylandEglWindow(QWindow *window);
~QWaylandEglWindow();
WindowType windowType() const;
void setGeometry(const QRect &rect);
diff --git a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp
index d293019909..d8cff1f8c1 100644
--- a/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/wayland_egl/qwaylandglcontext.cpp
@@ -55,7 +55,7 @@ QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QPlatformWindo
, mEglDisplay(eglDisplay)
, mSurface(EGL_NO_SURFACE)
, mConfig(q_configFromQPlatformWindowFormat(mEglDisplay,format,true))
- , mFormat(qt_qPlatformWindowFormatFromConfig(mEglDisplay,mConfig))
+ , mFormat(q_windowFormatFromConfig(mEglDisplay,mConfig))
{
QPlatformGLContext *sharePlatformContext = 0;
sharePlatformContext = format.sharedGLContext();
@@ -90,7 +90,6 @@ QWaylandGLContext::~QWaylandGLContext()
void QWaylandGLContext::makeCurrent()
{
- QPlatformGLContext::makeCurrent();
if (mSurface == EGL_NO_SURFACE) {
qWarning("makeCurrent with EGL_NO_SURFACE");
}
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp
index 92acf752e4..21b369d0ae 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglcontext.cpp
@@ -75,8 +75,6 @@ QWaylandXCompositeEGLContext::QWaylandXCompositeEGLContext(QWaylandXCompositeEGL
void QWaylandXCompositeEGLContext::makeCurrent()
{
- QPlatformGLContext::makeCurrent();
-
eglMakeCurrent(mEglIntegration->eglDisplay(),mEglWindowSurface,mEglWindowSurface,mContext);
}
@@ -102,7 +100,7 @@ void * QWaylandXCompositeEGLContext::getProcAddress(const QString &procName)
QPlatformWindowFormat QWaylandXCompositeEGLContext::platformWindowFormat() const
{
- return qt_qPlatformWindowFormatFromConfig(mEglIntegration->eglDisplay(),mConfig);
+ return q_windowFormatFromConfig(mEglIntegration->eglDisplay(),mConfig);
}
void QWaylandXCompositeEGLContext::sync_function(void *data)
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp
index 7537b52d59..6f7428024a 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.cpp
@@ -70,9 +70,9 @@ void QWaylandXCompositeEGLIntegration::initialize()
{
}
-QWaylandWindow * QWaylandXCompositeEGLIntegration::createEglWindow(QWidget *widget)
+QWaylandWindow * QWaylandXCompositeEGLIntegration::createEglWindow(QWindow *window)
{
- return new QWaylandXCompositeEGLWindow(widget,this);
+ return new QWaylandXCompositeEGLWindow(window,this);
}
Display * QWaylandXCompositeEGLIntegration::xDisplay() const
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h
index 590ae3754c..8edaa2becd 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglintegration.h
@@ -49,7 +49,7 @@
#include <QtCore/QDataStream>
#include <QtCore/QMetaType>
#include <QtCore/QVariant>
-#include <QtGui/QWidget>
+#include <QtGui/QWindow>
#include <QWaitCondition>
@@ -66,7 +66,7 @@ public:
void initialize();
- QWaylandWindow *createEglWindow(QWidget *widget);
+ QWaylandWindow *createEglWindow(QWindow *window);
QWaylandDisplay *waylandDisplay() const;
struct wl_xcomposite *waylandXComposite() const;
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp
index 1c9d36fe92..19cbbd2d49 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.cpp
@@ -43,7 +43,7 @@
#include <QtCore/QDebug>
-QWaylandXCompositeEGLWindow::QWaylandXCompositeEGLWindow(QWidget *window, QWaylandXCompositeEGLIntegration *glxIntegration)
+QWaylandXCompositeEGLWindow::QWaylandXCompositeEGLWindow(QWindow *window, QWaylandXCompositeEGLIntegration *glxIntegration)
: QWaylandWindow(window)
, mGlxIntegration(glxIntegration)
, mContext(0)
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h
index fc33b32322..111e751815 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_egl/qwaylandxcompositeeglwindow.h
@@ -49,7 +49,7 @@
class QWaylandXCompositeEGLWindow : public QWaylandWindow
{
public:
- QWaylandXCompositeEGLWindow(QWidget *window, QWaylandXCompositeEGLIntegration *glxIntegration);
+ QWaylandXCompositeEGLWindow(QWindow *window, QWaylandXCompositeEGLIntegration *glxIntegration);
WindowType windowType() const;
QPlatformGLContext *glContext() const;
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp
index caf51170a6..39316adf6c 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.cpp
@@ -46,6 +46,7 @@
#include "wayland-xcomposite-client-protocol.h"
#include <QtCore/QDebug>
+#include <QtGui/QRegion>
#include <X11/extensions/Xcomposite.h>
@@ -55,7 +56,7 @@ QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(QWaylandXCompositeGLX
, mWindow(window)
, mBuffer(0)
, mXWindow(0)
- , mConfig(qglx_findConfig(glxIntegration->xDisplay(),glxIntegration->screen(),window->widget()->platformWindowFormat()))
+ , mConfig(qglx_findConfig(glxIntegration->xDisplay(),glxIntegration->screen(),window->window()->format()))
, mWaitingForSyncCallback(false)
{
XVisualInfo *visualInfo = glXGetVisualFromFBConfig(glxIntegration->xDisplay(),mConfig);
@@ -66,7 +67,6 @@ QWaylandXCompositeGLXContext::QWaylandXCompositeGLXContext(QWaylandXCompositeGLX
void QWaylandXCompositeGLXContext::makeCurrent()
{
- QPlatformGLContext::makeCurrent();
glXMakeCurrent(mGlxIntegration->xDisplay(),mXWindow,mContext);
}
@@ -90,7 +90,7 @@ void * QWaylandXCompositeGLXContext::getProcAddress(const QString &procName)
return (void *) glXGetProcAddress(reinterpret_cast<GLubyte *>(procName.toLatin1().data()));
}
-QPlatformWindowFormat QWaylandXCompositeGLXContext::platformWindowFormat() const
+QWindowFormat QWaylandXCompositeGLXContext::windowFormat() const
{
return qglx_platformWindowFromGLXFBConfig(mGlxIntegration->xDisplay(),mConfig,mContext);
}
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h
index eb2e5a518e..2a94bd1c00 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxcontext.h
@@ -64,7 +64,7 @@ public:
void swapBuffers();
void* getProcAddress(const QString& procName);
- QPlatformWindowFormat platformWindowFormat() const;
+ QWindowFormat windowFormat() const;
void geometryChanged();
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp
index 5cb6ef336b..03b00da910 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.cpp
@@ -70,9 +70,9 @@ void QWaylandXCompositeGLXIntegration::initialize()
{
}
-QWaylandWindow * QWaylandXCompositeGLXIntegration::createEglWindow(QWidget *widget)
+QWaylandWindow * QWaylandXCompositeGLXIntegration::createEglWindow(QWindow *window)
{
- return new QWaylandXCompositeGLXWindow(widget,this);
+ return new QWaylandXCompositeGLXWindow(window,this);
}
Display * QWaylandXCompositeGLXIntegration::xDisplay() const
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h
index 24a40167e2..4f53449915 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxintegration.h
@@ -49,7 +49,7 @@
#include <QtCore/QDataStream>
#include <QtCore/QMetaType>
#include <QtCore/QVariant>
-#include <QtGui/QWidget>
+#include <QtGui/QWindow>
#include <X11/Xlib.h>
@@ -63,7 +63,7 @@ public:
void initialize();
- QWaylandWindow *createEglWindow(QWidget *widget);
+ QWaylandWindow *createEglWindow(QWindow *window);
QWaylandDisplay *waylandDisplay() const;
struct wl_xcomposite *waylandXComposite() const;
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp
index db0f254a20..40b72186f0 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.cpp
@@ -43,7 +43,7 @@
#include <QtCore/QDebug>
-QWaylandXCompositeGLXWindow::QWaylandXCompositeGLXWindow(QWidget *window, QWaylandXCompositeGLXIntegration *glxIntegration)
+QWaylandXCompositeGLXWindow::QWaylandXCompositeGLXWindow(QWindow *window, QWaylandXCompositeGLXIntegration *glxIntegration)
: QWaylandWindow(window)
, mGlxIntegration(glxIntegration)
, mContext(0)
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h
index 536153dbcf..f1bab465d4 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_glx/qwaylandxcompositeglxwindow.h
@@ -49,7 +49,7 @@
class QWaylandXCompositeGLXWindow : public QWaylandWindow
{
public:
- QWaylandXCompositeGLXWindow(QWidget *window, QWaylandXCompositeGLXIntegration *glxIntegration);
+ QWaylandXCompositeGLXWindow(QWindow *window, QWaylandXCompositeGLXIntegration *glxIntegration);
WindowType windowType() const;
QPlatformGLContext *glContext() const;
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp
index 4b0d3a073f..81c18058dd 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.cpp
@@ -42,6 +42,7 @@
#include "qwaylandxcompositebuffer.h"
#include "wayland-client.h"
+#include "wayland-xcomposite-client-protocol.h"
QWaylandXCompositeBuffer::QWaylandXCompositeBuffer(wl_xcomposite *xcomposite, uint32_t window, const QSize &size, wl_visual *visual)
:mSize(size)
diff --git a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h
index b346651957..c51f6bbf4c 100644
--- a/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h
+++ b/src/plugins/platforms/wayland/gl_integration/xcomposite_share/qwaylandxcompositebuffer.h
@@ -43,8 +43,10 @@
#define QWAYLANDXCOMPOSITEBUFFER_H
#include "qwaylandbuffer.h"
+#include <stdint.h>
-#include "wayland-xcomposite-client-protocol.h"
+struct wl_xcomposite;
+struct wl_visual;
class QWaylandXCompositeBuffer : public QWaylandBuffer
{
diff --git a/src/plugins/platforms/wayland/qwaylandcursor.cpp b/src/plugins/platforms/wayland/qwaylandcursor.cpp
index 614686f971..72274a28f9 100644
--- a/src/plugins/platforms/wayland/qwaylandcursor.cpp
+++ b/src/plugins/platforms/wayland/qwaylandcursor.cpp
@@ -108,11 +108,11 @@ QWaylandCursor::QWaylandCursor(QWaylandScreen *screen)
{
}
-void QWaylandCursor::changeCursor(QCursor *cursor, QWidget *widget)
+void QWaylandCursor::changeCursor(QCursor *cursor, QWindow *window)
{
const struct pointer_image *p;
- if (widget == NULL)
+ if (window == NULL)
return;
p = NULL;
diff --git a/src/plugins/platforms/wayland/qwaylandcursor.h b/src/plugins/platforms/wayland/qwaylandcursor.h
index 254cb9473a..9f7d871249 100644
--- a/src/plugins/platforms/wayland/qwaylandcursor.h
+++ b/src/plugins/platforms/wayland/qwaylandcursor.h
@@ -52,7 +52,7 @@ class QWaylandCursor : QPlatformCursor {
public:
QWaylandCursor(QWaylandScreen *screen);
- void changeCursor(QCursor *cursor, QWidget *widget);
+ void changeCursor(QCursor *cursor, QWindow *window);
QWaylandShmBuffer *mBuffer;
QWaylandDisplay *mDisplay;
};
diff --git a/src/plugins/platforms/wayland/qwaylanddisplay.cpp b/src/plugins/platforms/wayland/qwaylanddisplay.cpp
index 974453d39d..bd3f210533 100644
--- a/src/plugins/platforms/wayland/qwaylanddisplay.cpp
+++ b/src/plugins/platforms/wayland/qwaylanddisplay.cpp
@@ -52,8 +52,7 @@
#endif
#include <QtCore/QAbstractEventDispatcher>
-#include <QtGui/QApplication>
-#include <QtGui/private/qapplication_p.h>
+#include <QtGui/private/qguiapplication_p.h>
#include <unistd.h>
#include <fcntl.h>
@@ -266,7 +265,7 @@ void QWaylandDisplay::displayHandleGlobal(uint32_t id,
new QWaylandInputDevice(mDisplay, id);
mInputDevices.append(inputDevice);
} else if (interface == "wl_selection_offer") {
- QPlatformIntegration *plat = QApplicationPrivate::platformIntegration();
+ QPlatformIntegration *plat = QGuiApplicationPrivate::platformIntegration();
QWaylandClipboard *clipboard = static_cast<QWaylandClipboard *>(plat->clipboard());
clipboard->createSelectionOffer(id);
}
diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp
index f9e7c95861..de541f7d64 100644
--- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp
+++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp
@@ -110,7 +110,7 @@ void QWaylandInputDevice::inputHandleMotion(void *data,
inputDevice->mSurfacePos = QPoint(surface_x, surface_y);
inputDevice->mGlobalPos = QPoint(x, y);
inputDevice->mTime = time;
- QWindowSystemInterface::handleMouseEvent(window->widget(),
+ QWindowSystemInterface::handleMouseEvent(window->window(),
time,
inputDevice->mSurfacePos,
inputDevice->mGlobalPos,
@@ -152,7 +152,7 @@ void QWaylandInputDevice::inputHandleButton(void *data,
inputDevice->mButtons &= ~qt_button;
inputDevice->mTime = time;
- QWindowSystemInterface::handleMouseEvent(window->widget(),
+ QWindowSystemInterface::handleMouseEvent(window->window(),
time,
inputDevice->mSurfacePos,
inputDevice->mGlobalPos,
@@ -269,7 +269,7 @@ void QWaylandInputDevice::inputHandleKey(void *data,
sym = translateKey(sym, s, sizeof s);
if (window) {
- QWindowSystemInterface::handleKeyEvent(window->widget(),
+ QWindowSystemInterface::handleKeyEvent(window->window(),
time, type, sym,
inputDevice->mModifiers,
QString::fromLatin1(s));
@@ -292,13 +292,13 @@ void QWaylandInputDevice::inputHandlePointerFocus(void *data,
if (inputDevice->mPointerFocus) {
window = inputDevice->mPointerFocus;
- QWindowSystemInterface::handleLeaveEvent(window->widget());
+ QWindowSystemInterface::handleLeaveEvent(window->window());
inputDevice->mPointerFocus = NULL;
}
if (surface) {
window = (QWaylandWindow *) wl_surface_get_user_data(surface);
- QWindowSystemInterface::handleEnterEvent(window->widget());
+ QWindowSystemInterface::handleEnterEvent(window->window());
inputDevice->mPointerFocus = window;
}
@@ -330,7 +330,7 @@ void QWaylandInputDevice::inputHandleKeyboardFocus(void *data,
if (surface) {
window = (QWaylandWindow *) wl_surface_get_user_data(surface);
inputDevice->mKeyboardFocus = window;
- QWindowSystemInterface::handleWindowActivated(window->widget());
+ QWindowSystemInterface::handleWindowActivated(window->window());
} else {
inputDevice->mKeyboardFocus = NULL;
QWindowSystemInterface::handleWindowActivated(0);
diff --git a/src/plugins/platforms/wayland/qwaylandintegration.cpp b/src/plugins/platforms/wayland/qwaylandintegration.cpp
index 6166c142eb..7df6c4a526 100644
--- a/src/plugins/platforms/wayland/qwaylandintegration.cpp
+++ b/src/plugins/platforms/wayland/qwaylandintegration.cpp
@@ -51,7 +51,7 @@
#include <QtGui/QWindowSystemInterface>
#include <QtGui/QPlatformCursor>
-#include <QtGui/QPlatformWindowFormat>
+#include <QtGui/QWindowFormat>
#include <QtGui/private/qpixmap_raster_p.h>
#ifdef QT_WAYLAND_GL_SUPPORT
@@ -98,27 +98,25 @@ QPixmapData *QWaylandIntegration::createPixmapData(QPixmapData::PixelType type)
return new QRasterPixmapData(type);
}
-QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWidget *widget, WId winId) const
+QPlatformWindow *QWaylandIntegration::createPlatformWindow(QWindow *window) const
{
- Q_UNUSED(winId);
#ifdef QT_WAYLAND_GL_SUPPORT
- bool useOpenGL = mUseOpenGL || (widget->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL);
+ bool useOpenGL = mUseOpenGL || window->surfaceType() == QWindow::OpenGLSurface;
if (useOpenGL)
- return mDisplay->eglIntegration()->createEglWindow(widget);
+ return mDisplay->eglIntegration()->createEglWindow(window);
#endif
- return new QWaylandShmWindow(widget);
+ return new QWaylandShmWindow(window);
}
-QWindowSurface *QWaylandIntegration::createWindowSurface(QWidget *widget, WId winId) const
+QWindowSurface *QWaylandIntegration::createWindowSurface(QWindow *window, WId winId) const
{
Q_UNUSED(winId);
- Q_UNUSED(winId);
#ifdef QT_WAYLAND_GL_SUPPORT
- bool useOpenGL = mUseOpenGL || (widget->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL);
+ bool useOpenGL = mUseOpenGL || window->surfaceType() == QWindow::OpenGLSurface;
if (useOpenGL)
- return new QWaylandGLWindowSurface(widget);
+ return new QWaylandGLWindowSurface(window);
#endif
- return new QWaylandShmWindowSurface(widget);
+ return new QWaylandShmWindowSurface(window);
}
QPlatformFontDatabase *QWaylandIntegration::fontDatabase() const
diff --git a/src/plugins/platforms/wayland/qwaylandintegration.h b/src/plugins/platforms/wayland/qwaylandintegration.h
index fc748b0f1d..f0bb27a4ed 100644
--- a/src/plugins/platforms/wayland/qwaylandintegration.h
+++ b/src/plugins/platforms/wayland/qwaylandintegration.h
@@ -56,8 +56,8 @@ public:
bool hasCapability(QPlatformIntegration::Capability cap) const;
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
- QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
- QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
+ QPlatformWindow *createPlatformWindow(QWindow *window) const;
+ QWindowSurface *createWindowSurface(QWindow *window, WId winId) const;
QList<QPlatformScreen *> screens() const;
diff --git a/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp b/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp
index c3bfba03cc..8a7799e7a9 100644
--- a/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp
+++ b/src/plugins/platforms/wayland/qwaylandnativeinterface.cpp
@@ -43,30 +43,30 @@
#include "qwaylanddisplay.h"
#include "qwaylandwindow.h"
-#include <QtGui/private/qapplication_p.h>
+#include <QtGui/private/qguiapplication_p.h>
-void *QWaylandNativeInterface::nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget)
+void *QWaylandNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window)
{
QByteArray lowerCaseResource = resourceString.toLower();
if (lowerCaseResource == "display")
- return qPlatformScreenForWidget(widget)->display()->wl_display();
+ return qPlatformScreenForWindow(window)->display()->wl_display();
if (lowerCaseResource == "surface") {
- return ((QWaylandWindow *) widget->platformWindow())->wl_surface();
+ return ((QWaylandWindow *) window->handle())->wl_surface();
}
return NULL;
}
-QWaylandScreen * QWaylandNativeInterface::qPlatformScreenForWidget(QWidget *widget)
+QWaylandScreen * QWaylandNativeInterface::qPlatformScreenForWindow(QWindow *window)
{
QWaylandScreen *screen;
- if (widget) {
- screen = static_cast<QWaylandScreen *>(QPlatformScreen::platformScreenForWidget(widget));
+ if (window) {
+ screen = static_cast<QWaylandScreen *>(QPlatformScreen::platformScreenForWindow(window));
} else {
- screen = static_cast<QWaylandScreen *>(QApplicationPrivate::platformIntegration()->screens()[0]);
+ screen = static_cast<QWaylandScreen *>(QGuiApplicationPrivate::platformIntegration()->screens()[0]);
}
return screen;
}
diff --git a/src/plugins/platforms/wayland/qwaylandnativeinterface.h b/src/plugins/platforms/wayland/qwaylandnativeinterface.h
index ac4cdb9a22..dbb17a63a9 100644
--- a/src/plugins/platforms/wayland/qwaylandnativeinterface.h
+++ b/src/plugins/platforms/wayland/qwaylandnativeinterface.h
@@ -49,11 +49,11 @@
class QWaylandNativeInterface : public QPlatformNativeInterface
{
public:
- void *nativeResourceForWidget(const QByteArray &resourceString,
- QWidget *widget);
+ void *nativeResourceForWindow(const QByteArray &resourceString,
+ QWindow *window);
private:
- static QWaylandScreen *qPlatformScreenForWidget(QWidget *widget);
+ static QWaylandScreen *qPlatformScreenForWindow(QWindow *window);
};
diff --git a/src/plugins/platforms/wayland/qwaylandscreen.cpp b/src/plugins/platforms/wayland/qwaylandscreen.cpp
index 4f50cb61e6..8888f256ce 100644
--- a/src/plugins/platforms/wayland/qwaylandscreen.cpp
+++ b/src/plugins/platforms/wayland/qwaylandscreen.cpp
@@ -81,9 +81,9 @@ QImage::Format QWaylandScreen::format() const
return mFormat;
}
-QWaylandScreen * QWaylandScreen::waylandScreenFromWidget(QWidget *widget)
+QWaylandScreen * QWaylandScreen::waylandScreenFromWindow(QWindow *window)
{
- QPlatformScreen *platformScreen = QPlatformScreen::platformScreenForWidget(widget);
+ QPlatformScreen *platformScreen = QPlatformScreen::platformScreenForWindow(window);
return static_cast<QWaylandScreen *>(platformScreen);
}
diff --git a/src/plugins/platforms/wayland/qwaylandscreen.h b/src/plugins/platforms/wayland/qwaylandscreen.h
index 7784646da9..ec52e37166 100644
--- a/src/plugins/platforms/wayland/qwaylandscreen.h
+++ b/src/plugins/platforms/wayland/qwaylandscreen.h
@@ -62,7 +62,7 @@ public:
wl_visual *visual() const;
- static QWaylandScreen *waylandScreenFromWidget(QWidget *widget);
+ static QWaylandScreen *waylandScreenFromWindow(QWindow *window);
private:
QWaylandDisplay *mWaylandDisplay;
diff --git a/src/plugins/platforms/wayland/qwaylandshmsurface.cpp b/src/plugins/platforms/wayland/qwaylandshmsurface.cpp
index 34f4436f25..4bc54399ee 100644
--- a/src/plugins/platforms/wayland/qwaylandshmsurface.cpp
+++ b/src/plugins/platforms/wayland/qwaylandshmsurface.cpp
@@ -41,7 +41,6 @@
#include "qwaylandshmsurface.h"
#include <QtCore/qdebug.h>
-#include <QtGui/private/qapplication_p.h>
#include "qwaylanddisplay.h"
#include "qwaylandshmwindow.h"
@@ -91,10 +90,10 @@ QWaylandShmBuffer::~QWaylandShmBuffer(void)
wl_buffer_destroy(mBuffer);
}
-QWaylandShmWindowSurface::QWaylandShmWindowSurface(QWidget *window)
+QWaylandShmWindowSurface::QWaylandShmWindowSurface(QWindow *window)
: QWindowSurface(window)
, mBuffer(0)
- , mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display())
+ , mDisplay(QWaylandScreen::waylandScreenFromWindow(window)->display())
{
}
@@ -109,27 +108,27 @@ QPaintDevice *QWaylandShmWindowSurface::paintDevice()
void QWaylandShmWindowSurface::beginPaint(const QRegion &)
{
- QWaylandShmWindow *waylandWindow = static_cast<QWaylandShmWindow *>(window()->platformWindow());
+ QWaylandShmWindow *waylandWindow = static_cast<QWaylandShmWindow *>(window()->handle());
Q_ASSERT(waylandWindow->windowType() == QWaylandWindow::Shm);
waylandWindow->waitForFrameSync();
}
-void QWaylandShmWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+void QWaylandShmWindowSurface::flush(QWindow *window, const QRegion &region, const QPoint &offset)
{
- Q_UNUSED(widget);
+ Q_UNUSED(window);
Q_UNUSED(offset);
- QWaylandShmWindow *waylandWindow = static_cast<QWaylandShmWindow *>(window()->platformWindow());
+ QWaylandShmWindow *waylandWindow = static_cast<QWaylandShmWindow *>(window->handle());
Q_ASSERT(waylandWindow->windowType() == QWaylandWindow::Shm);
waylandWindow->damage(region);
}
void QWaylandShmWindowSurface::resize(const QSize &size)
{
- QWaylandShmWindow *waylandWindow = static_cast<QWaylandShmWindow *>(window()->platformWindow());
+ QWaylandShmWindow *waylandWindow = static_cast<QWaylandShmWindow *>(window()->handle());
Q_ASSERT(waylandWindow->windowType() == QWaylandWindow::Shm);
QWindowSurface::resize(size);
- QImage::Format format = QPlatformScreen::platformScreenForWidget(window())->format();
+ QImage::Format format = QPlatformScreen::platformScreenForWindow(window())->format();
if (mBuffer != NULL && mBuffer->size() == size)
return;
diff --git a/src/plugins/platforms/wayland/qwaylandshmsurface.h b/src/plugins/platforms/wayland/qwaylandshmsurface.h
index b29ceaf1b8..ce3e5ff5b9 100644
--- a/src/plugins/platforms/wayland/qwaylandshmsurface.h
+++ b/src/plugins/platforms/wayland/qwaylandshmsurface.h
@@ -44,7 +44,7 @@
#include "qwaylandbuffer.h"
#include <QtGui/private/qwindowsurface_p.h>
-
+#include <QtGui/QImage>
#include <QtGui/QPlatformWindow>
QT_BEGIN_NAMESPACE
@@ -65,11 +65,11 @@ private:
class QWaylandShmWindowSurface : public QWindowSurface
{
public:
- QWaylandShmWindowSurface(QWidget *window);
+ QWaylandShmWindowSurface(QWindow *window);
~QWaylandShmWindowSurface();
QPaintDevice *paintDevice();
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+ void flush(QWindow *window, const QRegion &region, const QPoint &offset);
void resize(const QSize &size);
void beginPaint(const QRegion &);
diff --git a/src/plugins/platforms/wayland/qwaylandshmwindow.cpp b/src/plugins/platforms/wayland/qwaylandshmwindow.cpp
index c083e58305..c298668dfe 100644
--- a/src/plugins/platforms/wayland/qwaylandshmwindow.cpp
+++ b/src/plugins/platforms/wayland/qwaylandshmwindow.cpp
@@ -47,8 +47,8 @@
#include <QtCore/QDebug>
-QWaylandShmWindow::QWaylandShmWindow(QWidget *widget)
- : QWaylandWindow(widget)
+QWaylandShmWindow::QWaylandShmWindow(QWindow *window)
+ : QWaylandWindow(window)
{
newSurfaceCreated();
}
diff --git a/src/plugins/platforms/wayland/qwaylandshmwindow.h b/src/plugins/platforms/wayland/qwaylandshmwindow.h
index 5dc6351c46..473c6df2ee 100644
--- a/src/plugins/platforms/wayland/qwaylandshmwindow.h
+++ b/src/plugins/platforms/wayland/qwaylandshmwindow.h
@@ -48,7 +48,7 @@
class QWaylandShmWindow : public QWaylandWindow
{
public:
- QWaylandShmWindow(QWidget *widget);
+ QWaylandShmWindow(QWindow *window);
~QWaylandShmWindow();
WindowType windowType() const;
diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp
index 53f2f483e9..b30cd4ab16 100644
--- a/src/plugins/platforms/wayland/qwaylandwindow.cpp
+++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp
@@ -46,14 +46,14 @@
#include "qwaylandinputdevice.h"
#include "qwaylandscreen.h"
-#include <QtGui/QWidget>
+#include <QtGui/QWindow>
#include <QtGui/QWindowSystemInterface>
#include <QDebug>
-QWaylandWindow::QWaylandWindow(QWidget *window)
+QWaylandWindow::QWaylandWindow(QWindow *window)
: QPlatformWindow(window)
- , mDisplay(QWaylandScreen::waylandScreenFromWidget(window)->display())
+ , mDisplay(QWaylandScreen::waylandScreenFromWindow(window)->display())
, mBuffer(0)
, mWaitingForFrameSync(false)
{
@@ -109,7 +109,7 @@ void QWaylandWindow::configure(uint32_t time, uint32_t edges,
setGeometry(geometry);
- QWindowSystemInterface::handleGeometryChange(widget(), geometry);
+ QWindowSystemInterface::handleGeometryChange(window(), geometry);
}
void QWaylandWindow::attach(QWaylandBuffer *buffer)
diff --git a/src/plugins/platforms/wayland/qwaylandwindow.h b/src/plugins/platforms/wayland/qwaylandwindow.h
index 47d49a70d9..53bfcc7bd6 100644
--- a/src/plugins/platforms/wayland/qwaylandwindow.h
+++ b/src/plugins/platforms/wayland/qwaylandwindow.h
@@ -59,7 +59,7 @@ public:
Egl
};
- QWaylandWindow(QWidget *window);
+ QWaylandWindow(QWindow *window);
~QWaylandWindow();
virtual WindowType windowType() const = 0;
diff --git a/src/plugins/platforms/wayland/wayland.pro b/src/plugins/platforms/wayland/wayland.pro
index 48734ec99d..1a9368f13c 100644
--- a/src/plugins/platforms/wayland/wayland.pro
+++ b/src/plugins/platforms/wayland/wayland.pro
@@ -39,6 +39,11 @@ QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_WAYLAND
INCLUDEPATH += $$PWD
+QT += gui-private
+QT += opengl-private
+QT += core-private
+QT += widgets-private
+
include ($$PWD/gl_integration/gl_integration.pri)
include (../fontdatabases/genericunix/genericunix.pri)
diff --git a/src/plugins/platforms/xcb/qdri2context.cpp b/src/plugins/platforms/xcb/qdri2context.cpp
index dbbfa67d8f..8d436f1735 100644
--- a/src/plugins/platforms/xcb/qdri2context.cpp
+++ b/src/plugins/platforms/xcb/qdri2context.cpp
@@ -45,7 +45,7 @@
#include "qxcbconnection.h"
#include <QtCore/QDebug>
-#include <QtGui/QWidget>
+#include <QtWidgets/QWidget>
#include <xcb/dri2.h>
#include <xcb/xfixes.h>
@@ -146,7 +146,6 @@ QDri2Context::~QDri2Context()
void QDri2Context::makeCurrent()
{
- QPlatformGLContext::makeCurrent();
Q_D(QDri2Context);
eglMakeCurrent(EGL_DISPLAY_FROM_XCB(d->qXcbWindow),EGL_NO_SURFACE,EGL_NO_SURFACE,d->eglContext);
@@ -156,7 +155,6 @@ void QDri2Context::makeCurrent()
void QDri2Context::doneCurrent()
{
- QPlatformGLContext::doneCurrent();
Q_D(QDri2Context);
eglMakeCurrent(EGL_DISPLAY_FROM_XCB(d->qXcbWindow),EGL_NO_SURFACE,EGL_NO_SURFACE,EGL_NO_CONTEXT);
}
diff --git a/src/plugins/platforms/xcb/qglxintegration.cpp b/src/plugins/platforms/xcb/qglxintegration.cpp
index 1417157bdf..7c0751f896 100644
--- a/src/plugins/platforms/xcb/qglxintegration.cpp
+++ b/src/plugins/platforms/xcb/qglxintegration.cpp
@@ -50,6 +50,8 @@
#include <X11/Xutil.h>
#include <GL/glx.h>
+#include <QtGui/QWindowContext>
+
#include "qglxintegration.h"
#include "qglxconvenience.h"
@@ -57,18 +59,17 @@
#include <dlfcn.h>
#endif
-QGLXContext::QGLXContext(Window window, QXcbScreen *screen, const QPlatformWindowFormat &format)
+QGLXContext::QGLXContext(Window window, QXcbScreen *screen, const QWindowFormat &format)
: QPlatformGLContext()
, m_screen(screen)
, m_drawable((Drawable)window)
, m_context(0)
{
Q_XCB_NOOP(m_screen->connection());
- const QPlatformGLContext *sharePlatformContext;
- sharePlatformContext = format.sharedGLContext();
+ const QWindowContext *shareContext = format.sharedContext();
GLXContext shareGlxContext = 0;
- if (sharePlatformContext)
- shareGlxContext = static_cast<const QGLXContext*>(sharePlatformContext)->glxContext();
+ if (shareContext)
+ shareGlxContext = static_cast<const QGLXContext*>(shareContext->handle())->glxContext();
GLXFBConfig config = qglx_findConfig(DISPLAY_FROM_XCB(screen),screen->screenNumber(),format);
m_context = glXCreateNewContext(DISPLAY_FROM_XCB(screen), config, GLX_RGBA_TYPE, shareGlxContext, TRUE);
@@ -93,7 +94,6 @@ QGLXContext::~QGLXContext()
void QGLXContext::makeCurrent()
{
Q_XCB_NOOP(m_screen->connection());
- QPlatformGLContext::makeCurrent();
glXMakeCurrent(DISPLAY_FROM_XCB(m_screen), m_drawable, m_context);
Q_XCB_NOOP(m_screen->connection());
}
@@ -101,7 +101,6 @@ void QGLXContext::makeCurrent()
void QGLXContext::doneCurrent()
{
Q_XCB_NOOP(m_screen->connection());
- QPlatformGLContext::doneCurrent();
glXMakeCurrent(DISPLAY_FROM_XCB(m_screen), 0, 0);
Q_XCB_NOOP(m_screen->connection());
}
@@ -147,7 +146,7 @@ void* QGLXContext::getProcAddress(const QString& procName)
return glXGetProcAddressARB(reinterpret_cast<const GLubyte *>(procName.toLatin1().data()));
}
-QPlatformWindowFormat QGLXContext::platformWindowFormat() const
+QWindowFormat QGLXContext::windowFormat() const
{
return m_windowFormat;
}
diff --git a/src/plugins/platforms/xcb/qglxintegration.h b/src/plugins/platforms/xcb/qglxintegration.h
index 99b72a04b5..4450083959 100644
--- a/src/plugins/platforms/xcb/qglxintegration.h
+++ b/src/plugins/platforms/xcb/qglxintegration.h
@@ -45,7 +45,7 @@
#include "qxcbwindow.h"
#include <QtGui/QPlatformGLContext>
-#include <QtGui/QPlatformWindowFormat>
+#include <QtGui/QWindowFormat>
#include <QtCore/QMutex>
@@ -54,7 +54,7 @@
class QGLXContext : public QPlatformGLContext
{
public:
- QGLXContext(Window window, QXcbScreen *xd, const QPlatformWindowFormat &format);
+ QGLXContext(Window window, QXcbScreen *xd, const QWindowFormat &format);
~QGLXContext();
virtual void makeCurrent();
@@ -64,13 +64,13 @@ public:
GLXContext glxContext() const { return m_context; }
- QPlatformWindowFormat platformWindowFormat() const;
+ QWindowFormat windowFormat() const;
private:
QXcbScreen *m_screen;
Drawable m_drawable;
GLXContext m_context;
- QPlatformWindowFormat m_windowFormat;
+ QWindowFormat m_windowFormat;
QGLXContext (QXcbScreen *screen, Drawable drawable, GLXContext context);
};
diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp
index 7ad12fe8b1..4035ba1bef 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.cpp
+++ b/src/plugins/platforms/xcb/qxcbconnection.cpp
@@ -46,7 +46,7 @@
#include <QtAlgorithms>
#include <QSocketNotifier>
-#include <QtGui/private/qapplication_p.h>
+#include <QtGui/private/qguiapplication_p.h>
#include <QAbstractEventDispatcher>
#include <QtCore/QDebug>
@@ -143,22 +143,26 @@ QXcbConnection::~QXcbConnection()
delete m_keyboard;
}
-QXcbWindow *platformWindowFromId(xcb_window_t id)
+void QXcbConnection::addWindow(xcb_window_t id, QXcbWindow *window)
{
- QWidget *widget = QWidget::find(id);
- if (widget)
- return static_cast<QXcbWindow *>(widget->platformWindow());
- return 0;
+ m_mapper.insert(id, window);
}
-#define HANDLE_PLATFORM_WINDOW_EVENT(event_t, window, handler) \
+void QXcbConnection::removeWindow(xcb_window_t id)
+{
+ m_mapper.remove(id);
+}
+
+QXcbWindow *QXcbConnection::platformWindowFromId(xcb_window_t id)
+{
+ return m_mapper.value(id, 0);
+}
+
+#define HANDLE_PLATFORM_WINDOW_EVENT(event_t, windowMember, handler) \
{ \
event_t *e = (event_t *)event; \
- if (QXcbWindow *platformWindow = platformWindowFromId(e->window)) { \
- QObjectPrivate *d = QObjectPrivate::get(platformWindow->widget()); \
- if (!d->wasDeleted) \
- platformWindow->handler(e); \
- } \
+ if (QXcbWindow *platformWindow = platformWindowFromId(e->windowMember)) \
+ platformWindow->handler(e); \
} \
break;
@@ -166,7 +170,7 @@ break;
{ \
event_t *e = (event_t *)event; \
if (QXcbWindow *platformWindow = platformWindowFromId(e->event)) \
- m_keyboard->handler(platformWindow->widget(), e); \
+ m_keyboard->handler(platformWindow->window(), e); \
} \
break;
diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h
index 6b5f81047d..cbdfff7e15 100644
--- a/src/plugins/platforms/xcb/qxcbconnection.h
+++ b/src/plugins/platforms/xcb/qxcbconnection.h
@@ -44,6 +44,7 @@
#include <xcb/xcb.h>
+#include <QHash>
#include <QList>
#include <QObject>
#include <QVector>
@@ -51,6 +52,9 @@
#define Q_XCB_DEBUG
class QXcbScreen;
+class QXcbWindow;
+
+typedef QHash<xcb_window_t, QXcbWindow *> WindowMapper;
namespace QXcbAtom {
enum Atom {
@@ -255,6 +259,9 @@ public:
void sync();
void handleXcbError(xcb_generic_error_t *error);
+ void addWindow(xcb_window_t id, QXcbWindow *window);
+ void removeWindow(xcb_window_t id);
+
private slots:
void processXcbEvents();
@@ -264,6 +271,7 @@ private:
#ifdef XCB_USE_DRI2
void initializeDri2();
#endif
+ QXcbWindow *platformWindowFromId(xcb_window_t id);
xcb_connection_t *m_connection;
const xcb_setup_t *m_setup;
@@ -303,6 +311,8 @@ private:
template <typename cookie_t>
friend cookie_t q_xcb_call_template(const cookie_t &cookie, QXcbConnection *connection, const char *file, int line);
#endif
+
+ WindowMapper m_mapper;
};
#define DISPLAY_FROM_XCB(object) ((Display *)(object->connection()->xlib_display()))
diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp
index 9df5f14114..7aa3b3f1ba 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.cpp
+++ b/src/plugins/platforms/xcb/qxcbintegration.cpp
@@ -87,16 +87,15 @@ QPixmapData *QXcbIntegration::createPixmapData(QPixmapData::PixelType type) cons
return new QRasterPixmapData(type);
}
-QPlatformWindow *QXcbIntegration::createPlatformWindow(QWidget *widget, WId winId) const
+QPlatformWindow *QXcbIntegration::createPlatformWindow(QWindow *window) const
{
- Q_UNUSED(winId);
- return new QXcbWindow(widget);
+ return new QXcbWindow(window);
}
-QWindowSurface *QXcbIntegration::createWindowSurface(QWidget *widget, WId winId) const
+QWindowSurface *QXcbIntegration::createWindowSurface(QWindow *window, WId winId) const
{
Q_UNUSED(winId);
- return new QXcbWindowSurface(widget);
+ return new QXcbWindowSurface(window);
}
QList<QPlatformScreen *> QXcbIntegration::screens() const
diff --git a/src/plugins/platforms/xcb/qxcbintegration.h b/src/plugins/platforms/xcb/qxcbintegration.h
index d27fd716ab..0de6f15657 100644
--- a/src/plugins/platforms/xcb/qxcbintegration.h
+++ b/src/plugins/platforms/xcb/qxcbintegration.h
@@ -57,8 +57,8 @@ public:
bool hasCapability(Capability cap) const;
QPixmapData *createPixmapData(QPixmapData::PixelType type) const;
- QPlatformWindow *createPlatformWindow(QWidget *widget, WId winId) const;
- QWindowSurface *createWindowSurface(QWidget *widget, WId winId) const;
+ QPlatformWindow *createPlatformWindow(QWindow *window) const;
+ QWindowSurface *createWindowSurface(QWindow *window, WId winId) const;
QList<QPlatformScreen *> screens() const;
void moveToScreen(QWidget *window, int screen);
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
index f501c00e94..b6e95392a6 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp
@@ -913,7 +913,7 @@ QXcbKeyboard::~QXcbKeyboard()
// #define XCB_KEYBOARD_DEBUG
-void QXcbKeyboard::handleKeyEvent(QWidget *widget, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time)
+void QXcbKeyboard::handleKeyEvent(QWindow *window, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time)
{
int col = state & XCB_MOD_MASK_SHIFT ? 1 : 0;
@@ -954,17 +954,17 @@ void QXcbKeyboard::handleKeyEvent(QWidget *widget, QEvent::Type type, xcb_keycod
QString string = translateKeySym(sym, state, qtcode, modifiers, chars, count);
- QWindowSystemInterface::handleExtendedKeyEvent(widget, time, type, qtcode, modifiers, code, 0, state, string.left(count));
+ QWindowSystemInterface::handleExtendedKeyEvent(window, time, type, qtcode, modifiers, code, 0, state, string.left(count));
}
-void QXcbKeyboard::handleKeyPressEvent(QWidget *widget, const xcb_key_press_event_t *event)
+void QXcbKeyboard::handleKeyPressEvent(QWindow *window, const xcb_key_press_event_t *event)
{
- handleKeyEvent(widget, QEvent::KeyPress, event->detail, event->state, event->time);
+ handleKeyEvent(window, QEvent::KeyPress, event->detail, event->state, event->time);
}
-void QXcbKeyboard::handleKeyReleaseEvent(QWidget *widget, const xcb_key_release_event_t *event)
+void QXcbKeyboard::handleKeyReleaseEvent(QWindow *window, const xcb_key_release_event_t *event)
{
- handleKeyEvent(widget, QEvent::KeyRelease, event->detail, event->state, event->time);
+ handleKeyEvent(window, QEvent::KeyRelease, event->detail, event->state, event->time);
}
void QXcbKeyboard::handleMappingNotifyEvent(const xcb_mapping_notify_event_t *event)
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.h b/src/plugins/platforms/xcb/qxcbkeyboard.h
index ddade79d51..ee951bfd4b 100644
--- a/src/plugins/platforms/xcb/qxcbkeyboard.h
+++ b/src/plugins/platforms/xcb/qxcbkeyboard.h
@@ -48,21 +48,23 @@
#include <QEvent>
+class QWindow;
+
class QXcbKeyboard : public QXcbObject
{
public:
QXcbKeyboard(QXcbConnection *connection);
~QXcbKeyboard();
- void handleKeyPressEvent(QWidget *widget, const xcb_key_press_event_t *event);
- void handleKeyReleaseEvent(QWidget *widget, const xcb_key_release_event_t *event);
+ void handleKeyPressEvent(QWindow *window, const xcb_key_press_event_t *event);
+ void handleKeyReleaseEvent(QWindow *window, const xcb_key_release_event_t *event);
void handleMappingNotifyEvent(const xcb_mapping_notify_event_t *event);
Qt::KeyboardModifiers translateModifiers(int s);
private:
- void handleKeyEvent(QWidget *widget, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time);
+ void handleKeyEvent(QWindow *window, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time);
int translateKeySym(uint key) const;
QString translateKeySym(xcb_keysym_t keysym, uint xmodifiers,
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
index b2ca1beb6e..9d0eb86480 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp
@@ -43,11 +43,13 @@
#include "qxcbscreen.h"
-#include <QtGui/private/qapplication_p.h>
+#include <private/qguiapplication_p.h>
#include <QtCore/QMap>
#include <QtCore/QDebug>
+#include <QtGui/qwindowcontext_qpa.h>
+
#if defined(XCB_USE_EGL)
#include "../eglconvenience/qeglplatformcontext.h"
#elif defined (XCB_USE_DRI2)
@@ -71,29 +73,29 @@ public:
Q_GLOBAL_STATIC(QXcbResourceMap, qXcbResourceMap)
-void *QXcbNativeInterface::nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget)
+void *QXcbNativeInterface::nativeResourceForWindow(const QByteArray &resourceString, QWindow *window)
{
QByteArray lowerCaseResource = resourceString.toLower();
ResourceType resource = qXcbResourceMap()->value(lowerCaseResource);
void *result = 0;
switch(resource) {
case Display:
- result = displayForWidget(widget);
+ result = displayForWindow(window);
break;
case EglDisplay:
- result = eglDisplayForWidget(widget);
+ result = eglDisplayForWindow(window);
break;
case Connection:
- result = connectionForWidget(widget);
+ result = connectionForWindow(window);
break;
case Screen:
- result = qPlatformScreenForWidget(widget);
+ result = qPlatformScreenForWindow(window);
break;
case GraphicsDevice:
- result = graphicsDeviceForWidget(widget);
+ result = graphicsDeviceForWindow(window);
break;
case EglContext:
- result = eglContextForWidget(widget);
+ result = eglContextForWindow(window);
break;
default:
result = 0;
@@ -101,75 +103,70 @@ void *QXcbNativeInterface::nativeResourceForWidget(const QByteArray &resourceStr
return result;
}
-QXcbScreen *QXcbNativeInterface::qPlatformScreenForWidget(QWidget *widget)
+QXcbScreen *QXcbNativeInterface::qPlatformScreenForWindow(QWindow *window)
{
QXcbScreen *screen;
- if (widget) {
- screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(widget));
+ if (window) {
+ screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWindow(window));
}else {
- screen = static_cast<QXcbScreen *>(QApplicationPrivate::platformIntegration()->screens()[0]);
+ screen = static_cast<QXcbScreen *>(QGuiApplicationPrivate::platformIntegration()->screens()[0]);
}
return screen;
}
-void *QXcbNativeInterface::displayForWidget(QWidget *widget)
+void *QXcbNativeInterface::displayForWindow(QWindow *window)
{
#if defined(XCB_USE_XLIB)
- QXcbScreen *screen = qPlatformScreenForWidget(widget);
+ QXcbScreen *screen = qPlatformScreenForWindow(window);
return screen->connection()->xlib_display();
#else
- Q_UNUSED(widget);
+ Q_UNUSED(window);
return 0;
#endif
}
-void *QXcbNativeInterface::eglDisplayForWidget(QWidget *widget)
+void *QXcbNativeInterface::eglDisplayForWindow(QWindow *window)
{
#if defined(XCB_USE_DRI2) || defined(XCB_USE_EGL)
- QXcbScreen *screen = qPlatformScreenForWidget(widget);
+ QXcbScreen *screen = qPlatformScreenForWindow(window);
return screen->connection()->egl_display();
#else
- Q_UNUSED(widget)
+ Q_UNUSED(window)
return 0;
#endif
}
-void *QXcbNativeInterface::connectionForWidget(QWidget *widget)
+void *QXcbNativeInterface::connectionForWindow(QWindow *window)
{
- QXcbScreen *screen = qPlatformScreenForWidget(widget);
+ QXcbScreen *screen = qPlatformScreenForWindow(window);
return screen->xcb_connection();
}
-void *QXcbNativeInterface::screenForWidget(QWidget *widget)
+void *QXcbNativeInterface::screenForWindow(QWindow *window)
{
- QXcbScreen *screen = qPlatformScreenForWidget(widget);
+ QXcbScreen *screen = qPlatformScreenForWindow(window);
return screen->screen();
}
-void *QXcbNativeInterface::graphicsDeviceForWidget(QWidget *widget)
+void *QXcbNativeInterface::graphicsDeviceForWindow(QWindow *window)
{
#if defined(XCB_USE_DRI2)
- QXcbScreen *screen = qPlatformScreenForWidget(widget);
+ QXcbScreen *screen = qPlatformScreenForWindow(window);
QByteArray deviceName = screen->connection()->dri2DeviceName();
return deviceName.data();
#else
- Q_UNUSED(widget);
+ Q_UNUSED(window);
return 0;
#endif
}
-void * QXcbNativeInterface::eglContextForWidget(QWidget *widget)
+void * QXcbNativeInterface::eglContextForWindow(QWindow *window)
{
- Q_ASSERT(widget);
- if (!widget->platformWindow()) {
- qDebug() << "QPlatformWindow does not exist for widget" << widget
- << "cannot return EGLContext";
- return 0;
- }
- QPlatformGLContext *platformContext = widget->platformWindow()->glContext();
+ Q_ASSERT(window);
+ QPlatformGLContext *platformContext = window->glContext()->handle();
if (!platformContext) {
- qDebug() << "QPlatformWindow" << widget->platformWindow() << "does not have a glContext"
+ qDebug() << "QWindow" << window << "does not have a glContext"
<< "cannot return EGLContext";
return 0;
}
diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.h b/src/plugins/platforms/xcb/qxcbnativeinterface.h
index f60905cc3d..5cf3d8c6a6 100644
--- a/src/plugins/platforms/xcb/qxcbnativeinterface.h
+++ b/src/plugins/platforms/xcb/qxcbnativeinterface.h
@@ -59,17 +59,17 @@ public:
EglContext
};
- void *nativeResourceForWidget(const QByteArray &resourceString, QWidget *widget);
+ void *nativeResourceForWindow(const QByteArray &resourceString, QWindow *window);
- void *displayForWidget(QWidget *widget);
- void *eglDisplayForWidget(QWidget *widget);
- void *connectionForWidget(QWidget *widget);
- void *screenForWidget(QWidget *widget);
- void *graphicsDeviceForWidget(QWidget *widget);
- void *eglContextForWidget(QWidget *widget);
+ void *displayForWindow(QWindow *window);
+ void *eglDisplayForWindow(QWindow *window);
+ void *connectionForWindow(QWindow *window);
+ void *screenForWindow(QWindow *window);
+ void *graphicsDeviceForWindow(QWindow *window);
+ void *eglContextForWindow(QWindow *window);
private:
- static QXcbScreen *qPlatformScreenForWidget(QWidget *widget);
+ static QXcbScreen *qPlatformScreenForWindow(QWindow *window);
};
#endif // QXCBNATIVEINTERFACE_H
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index 0456638ab9..4cc07a06a4 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -51,7 +51,7 @@
#include <xcb/xcb_icccm.h>
-#include <private/qapplication_p.h>
+#include <private/qguiapplication_p.h>
#include <private/qwindowsurface_p.h>
#include <QtGui/QWindowSystemInterface>
@@ -72,6 +72,7 @@
#include "../eglconvenience/qxlibeglintegration.h"
#endif
+#if 0
// Returns true if we should set WM_TRANSIENT_FOR on \a w
static inline bool isTransient(const QWidget *w)
{
@@ -84,12 +85,13 @@ static inline bool isTransient(const QWidget *w)
|| w->windowType() == Qt::Popup)
&& !w->testAttribute(Qt::WA_X11BypassTransientForHint));
}
+#endif
-QXcbWindow::QXcbWindow(QWidget *tlw)
- : QPlatformWindow(tlw)
+QXcbWindow::QXcbWindow(QWindow *window)
+ : QPlatformWindow(window)
, m_context(0)
{
- m_screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(tlw));
+ m_screen = static_cast<QXcbScreen *>(QGuiApplicationPrivate::platformIntegration()->screens().at(0));
setConnection(m_screen->connection());
@@ -111,15 +113,21 @@ QXcbWindow::QXcbWindow(QWidget *tlw)
| XCB_EVENT_MASK_FOCUS_CHANGE
};
+ QRect rect = window->geometry();
+
+ xcb_window_t xcb_parent_id = m_screen->root();
+ if (window->parent() && window->parent()->handle())
+ xcb_parent_id = static_cast<QXcbWindow *>(window->parent()->handle())->xcb_window();
+
#if defined(XCB_USE_GLX) || defined(XCB_USE_EGL)
- if (tlw->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenGL
- && QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL))
+ if (window->surfaceType() == QWindow::OpenGLSurface
+ && QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL))
{
#if defined(XCB_USE_GLX)
- XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(m_screen),m_screen->screenNumber(), tlw->platformWindowFormat());
+ XVisualInfo *visualInfo = qglx_findVisualInfo(DISPLAY_FROM_XCB(m_screen),m_screen->screenNumber(), window->requestedWindowFormat());
#elif defined(XCB_USE_EGL)
EGLDisplay eglDisplay = connection()->egl_display();
- EGLConfig eglConfig = q_configFromQPlatformWindowFormat(eglDisplay,tlw->platformWindowFormat(),true);
+ EGLConfig eglConfig = q_configFromQPlatformWindowFormat(eglDisplay,window->requestedWindowFormat(),true);
VisualID id = QXlibEglIntegration::getCompatibleVisualId(DISPLAY_FROM_XCB(this), eglDisplay, eglConfig);
XVisualInfo visualInfoTemplate;
@@ -131,11 +139,11 @@ QXcbWindow::QXcbWindow(QWidget *tlw)
visualInfo = XGetVisualInfo(DISPLAY_FROM_XCB(this), VisualIDMask, &visualInfoTemplate, &matchingCount);
#endif //XCB_USE_GLX
if (visualInfo) {
- Colormap cmap = XCreateColormap(DISPLAY_FROM_XCB(this), m_screen->root(), visualInfo->visual, AllocNone);
+ Colormap cmap = XCreateColormap(DISPLAY_FROM_XCB(this), xcb_parent_id, visualInfo->visual, AllocNone);
XSetWindowAttributes a;
a.colormap = cmap;
- m_window = XCreateWindow(DISPLAY_FROM_XCB(this), m_screen->root(), tlw->x(), tlw->y(), tlw->width(), tlw->height(),
+ m_window = XCreateWindow(DISPLAY_FROM_XCB(this), xcb_parent_id, rect.x(), rect.y(), rect.width(), rect.height(),
0, visualInfo->depth, InputOutput, visualInfo->visual,
CWColormap, &a);
@@ -151,11 +159,11 @@ QXcbWindow::QXcbWindow(QWidget *tlw)
Q_XCB_CALL(xcb_create_window(xcb_connection(),
XCB_COPY_FROM_PARENT, // depth -- same as root
m_window, // window id
- m_screen->root(), // parent window id
- tlw->x(),
- tlw->y(),
- tlw->width(),
- tlw->height(),
+ xcb_parent_id, // parent window id
+ rect.x(),
+ rect.y(),
+ rect.width(),
+ rect.height(),
0, // border width
XCB_WINDOW_CLASS_INPUT_OUTPUT, // window class
m_screen->screen()->root_visual, // visual
@@ -165,6 +173,8 @@ QXcbWindow::QXcbWindow(QWidget *tlw)
printf("created regular window: %d\n", m_window);
}
+ connection()->addWindow(m_window, this);
+
Q_XCB_CALL(xcb_change_window_attributes(xcb_connection(), m_window, mask, values));
xcb_atom_t properties[4];
@@ -176,7 +186,7 @@ QXcbWindow::QXcbWindow(QWidget *tlw)
if (m_screen->syncRequestSupported())
properties[propertyCount++] = atom(QXcbAtom::_NET_WM_SYNC_REQUEST);
- if (tlw->windowFlags() & Qt::WindowContextHelpButtonHint)
+ if (window->windowFlags() & Qt::WindowContextHelpButtonHint)
properties[propertyCount++] = atom(QXcbAtom::_NET_WM_CONTEXT_HELP);
Q_XCB_CALL(xcb_change_property(xcb_connection(),
@@ -204,7 +214,8 @@ QXcbWindow::QXcbWindow(QWidget *tlw)
&m_syncCounter));
}
- if (isTransient(tlw) && tlw->parentWidget()) {
+#if 0
+ if (tlw && isTransient(tlw) && tlw->parentWidget()) {
// ICCCM 4.1.2.6
QWidget *p = tlw->parentWidget()->window();
xcb_window_t parentWindow = p->winId();
@@ -213,6 +224,7 @@ QXcbWindow::QXcbWindow(QWidget *tlw)
1, &parentWindow));
}
+#endif
// set the PID to let the WM kill the application if unresponsive
long pid = getpid();
@@ -226,6 +238,7 @@ QXcbWindow::~QXcbWindow()
delete m_context;
if (m_screen->syncRequestSupported())
Q_XCB_CALL(xcb_sync_destroy_counter(xcb_connection(), m_syncCounter));
+ connection()->removeWindow(m_window);
Q_XCB_CALL(xcb_destroy_window(xcb_connection(), m_window));
}
@@ -243,7 +256,8 @@ void QXcbWindow::setVisible(bool visible)
{
xcb_wm_hints_t hints;
if (visible) {
- if (widget()->isMinimized())
+ // TODO: QWindow::isMinimized() or similar
+ if (window()->windowState() & Qt::WindowMinimized)
xcb_wm_hints_set_iconic(&hints);
else
xcb_wm_hints_set_normal(&hints);
@@ -406,7 +420,7 @@ Qt::WindowFlags QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
Q_XCB_CALL(xcb_change_window_attributes(xcb_connection(), m_window, mask, values));
}
- return QPlatformWindow::setWindowFlags(flags);
+ return flags;
}
void QXcbWindow::setNetWmWindowTypes(Qt::WindowFlags flags)
@@ -453,7 +467,7 @@ WId QXcbWindow::winId() const
void QXcbWindow::setParent(const QPlatformWindow *parent)
{
QPoint topLeft = geometry().topLeft();
- Q_XCB_CALL(xcb_reparent_window(xcb_connection(), window(), static_cast<const QXcbWindow *>(parent)->window(), topLeft.x(), topLeft.y()));
+ Q_XCB_CALL(xcb_reparent_window(xcb_connection(), xcb_window(), static_cast<const QXcbWindow *>(parent)->xcb_window(), topLeft.x(), topLeft.y()));
}
void QXcbWindow::setWindowTitle(const QString &title)
@@ -491,17 +505,17 @@ void QXcbWindow::requestActivateWindow()
QPlatformGLContext *QXcbWindow::glContext() const
{
- if (!QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) {
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) {
printf("no opengl\n");
return 0;
}
if (!m_context) {
#if defined(XCB_USE_GLX)
QXcbWindow *that = const_cast<QXcbWindow *>(this);
- that->m_context = new QGLXContext(m_window, m_screen, widget()->platformWindowFormat());
+ that->m_context = new QGLXContext(m_window, m_screen, window()->requestedWindowFormat());
#elif defined(XCB_USE_EGL)
EGLDisplay display = connection()->egl_display();
- EGLConfig config = q_configFromQPlatformWindowFormat(display,widget()->platformWindowFormat(),true);
+ EGLConfig config = q_configFromQPlatformWindowFormat(display,window()->requestedWindowFormat(),true);
QVector<EGLint> eglContextAttrs;
eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);
eglContextAttrs.append(2);
@@ -520,11 +534,11 @@ QPlatformGLContext *QXcbWindow::glContext() const
void QXcbWindow::handleExposeEvent(const xcb_expose_event_t *event)
{
- QWindowSurface *surface = widget()->windowSurface();
+ QWindowSurface *surface = window()->surface();
if (surface) {
QRect rect(event->x, event->y, event->width, event->height);
- surface->flush(widget(), rect, QPoint());
+ surface->flush(window(), rect, QPoint());
}
}
@@ -532,7 +546,7 @@ void QXcbWindow::handleClientMessageEvent(const xcb_client_message_event_t *even
{
if (event->format == 32 && event->type == atom(QXcbAtom::WM_PROTOCOLS)) {
if (event->data.data32[0] == atom(QXcbAtom::WM_DELETE_WINDOW)) {
- QWindowSystemInterface::handleCloseEvent(widget());
+ QWindowSystemInterface::handleCloseEvent(window());
} else if (event->data.data32[0] == atom(QXcbAtom::_NET_WM_PING)) {
xcb_client_message_event_t reply = *event;
@@ -568,7 +582,7 @@ void QXcbWindow::handleConfigureNotifyEvent(const xcb_configure_notify_event_t *
return;
QPlatformWindow::setGeometry(rect);
- QWindowSystemInterface::handleGeometryChange(widget(), rect);
+ QWindowSystemInterface::handleGeometryChange(window(), rect);
#if XCB_USE_DRI2
if (m_context)
@@ -616,7 +630,7 @@ void QXcbWindow::handleButtonPressEvent(const xcb_button_press_event_t *event)
&& (modifiers & Qt::AltModifier))
|| (event->detail == 6 || event->detail == 7));
- QWindowSystemInterface::handleWheelEvent(widget(), event->time,
+ QWindowSystemInterface::handleWheelEvent(window(), event->time,
local, global, delta, hor ? Qt::Horizontal : Qt::Vertical);
return;
}
@@ -647,22 +661,22 @@ void QXcbWindow::handleMouseEvent(xcb_button_t detail, uint16_t state, xcb_times
buttons ^= button; // X event uses state *before*, Qt uses state *after*
- QWindowSystemInterface::handleMouseEvent(widget(), time, local, global, buttons);
+ QWindowSystemInterface::handleMouseEvent(window(), time, local, global, buttons);
}
void QXcbWindow::handleEnterNotifyEvent(const xcb_enter_notify_event_t *)
{
- QWindowSystemInterface::handleEnterEvent(widget());
+ QWindowSystemInterface::handleEnterEvent(window());
}
void QXcbWindow::handleLeaveNotifyEvent(const xcb_leave_notify_event_t *)
{
- QWindowSystemInterface::handleLeaveEvent(widget());
+ QWindowSystemInterface::handleLeaveEvent(window());
}
void QXcbWindow::handleFocusInEvent(const xcb_focus_in_event_t *)
{
- QWindowSystemInterface::handleWindowActivated(widget());
+ QWindowSystemInterface::handleWindowActivated(window());
}
void QXcbWindow::handleFocusOutEvent(const xcb_focus_out_event_t *)
diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h
index e049837253..3ed58b33d3 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.h
+++ b/src/plugins/platforms/xcb/qxcbwindow.h
@@ -43,7 +43,7 @@
#define QXCBWINDOW_H
#include <QtGui/QPlatformWindow>
-#include <QtGui/QPlatformWindowFormat>
+#include <QtGui/QWindowFormat>
#include <xcb/xcb.h>
#include <xcb/sync.h>
@@ -55,7 +55,7 @@ class QXcbScreen;
class QXcbWindow : public QXcbObject, public QPlatformWindow
{
public:
- QXcbWindow(QWidget *tlw);
+ QXcbWindow(QWindow *window);
~QXcbWindow();
void setGeometry(const QRect &rect);
@@ -73,7 +73,7 @@ public:
QPlatformGLContext *glContext() const;
- xcb_window_t window() const { return m_window; }
+ xcb_window_t xcb_window() const { return m_window; }
void handleExposeEvent(const xcb_expose_event_t *event);
void handleClientMessageEvent(const xcb_client_message_event_t *event);
diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp
index 718f09383c..a371d2dd06 100644
--- a/src/plugins/platforms/xcb/qxcbwindowsurface.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindowsurface.cpp
@@ -167,12 +167,12 @@ void QXcbShmImage::preparePaint(const QRegion &region)
}
}
-QXcbWindowSurface::QXcbWindowSurface(QWidget *widget, bool setDefaultSurface)
- : QWindowSurface(widget, setDefaultSurface)
+QXcbWindowSurface::QXcbWindowSurface(QWindow *window, bool setDefaultSurface)
+ : QWindowSurface(window, setDefaultSurface)
, m_image(0)
, m_syncingResize(false)
{
- QXcbScreen *screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(widget));
+ QXcbScreen *screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWindow(window));
setConnection(screen->connection());
}
@@ -195,7 +195,7 @@ void QXcbWindowSurface::endPaint(const QRegion &)
{
}
-void QXcbWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoint &offset)
+void QXcbWindowSurface::flush(QWindow *window, const QRegion &region, const QPoint &offset)
{
QRect bounds = region.boundingRect();
@@ -204,14 +204,11 @@ void QXcbWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoi
Q_XCB_NOOP(connection());
- QXcbWindow *window = static_cast<QXcbWindow *>(widget->window()->platformWindow());
-
- extern QWidgetData* qt_widget_data(QWidget *);
- QPoint widgetOffset = qt_qwidget_data(widget)->wrect.topLeft();
+ QXcbWindow *platformWindow = static_cast<QXcbWindow *>(window->handle());
QVector<QRect> rects = region.rects();
for (int i = 0; i < rects.size(); ++i)
- m_image->put(window->window(), rects.at(i).topLeft() - widgetOffset, rects.at(i).translated(offset));
+ m_image->put(platformWindow->xcb_window(), rects.at(i).topLeft(), rects.at(i).translated(offset));
Q_XCB_NOOP(connection());
@@ -219,7 +216,7 @@ void QXcbWindowSurface::flush(QWidget *widget, const QRegion &region, const QPoi
xcb_flush(xcb_connection());
connection()->sync();
m_syncingResize = false;
- window->updateSyncRequestCounter();
+ platformWindow->updateSyncRequestCounter();
}
}
@@ -231,7 +228,7 @@ void QXcbWindowSurface::resize(const QSize &size)
Q_XCB_NOOP(connection());
QWindowSurface::resize(size);
- QXcbScreen *screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWidget(window()));
+ QXcbScreen *screen = static_cast<QXcbScreen *>(QPlatformScreen::platformScreenForWindow(window()));
delete m_image;
m_image = new QXcbShmImage(screen, size);
diff --git a/src/plugins/platforms/xcb/qxcbwindowsurface.h b/src/plugins/platforms/xcb/qxcbwindowsurface.h
index 23d32ef445..60ed7497db 100644
--- a/src/plugins/platforms/xcb/qxcbwindowsurface.h
+++ b/src/plugins/platforms/xcb/qxcbwindowsurface.h
@@ -53,11 +53,11 @@ class QXcbShmImage;
class QXcbWindowSurface : public QXcbObject, public QWindowSurface
{
public:
- QXcbWindowSurface(QWidget *widget, bool setDefaultSurface = true);
+ QXcbWindowSurface(QWindow *widget, bool setDefaultSurface = true);
~QXcbWindowSurface();
QPaintDevice *paintDevice();
- void flush(QWidget *widget, const QRegion &region, const QPoint &offset);
+ void flush(QWindow *window, const QRegion &region, const QPoint &offset);
void resize(const QSize &size);
bool scroll(const QRegion &area, int dx, int dy);
diff --git a/src/plugins/platforms/xcb/xcb.pro b/src/plugins/platforms/xcb/xcb.pro
index 83d7eb4d1f..175bdd8451 100644
--- a/src/plugins/platforms/xcb/xcb.pro
+++ b/src/plugins/platforms/xcb/xcb.pro
@@ -27,6 +27,8 @@ HEADERS = \
qxcbwindowsurface.h \
qxcbnativeinterface.h
+QT += gui-private core-private
+
contains(QT_CONFIG, opengl) {
QT += opengl
diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro
index c1aff35428..6950114aaa 100644
--- a/src/plugins/plugins.pro
+++ b/src/plugins/plugins.pro
@@ -7,8 +7,6 @@ unix:!symbian {
SUBDIRS *= codecs
}
!contains(QT_CONFIG, no-gui): SUBDIRS *= imageformats
-!embedded:!qpa:SUBDIRS *= graphicssystems
-embedded:SUBDIRS *= gfxdrivers decorations mousedrivers kbddrivers
!win32:!embedded:!mac:!symbian:SUBDIRS *= inputmethods
!symbian:!contains(QT_CONFIG, no-gui):SUBDIRS += accessible
symbian:SUBDIRS += s60
diff --git a/src/sql/models/qsqlrelationaldelegate.h b/src/sql/models/qsqlrelationaldelegate.h
index f4f4bc5136..d608c0d6cd 100644
--- a/src/sql/models/qsqlrelationaldelegate.h
+++ b/src/sql/models/qsqlrelationaldelegate.h
@@ -44,9 +44,9 @@
#ifdef QT_GUI_LIB
-#include <QtGui/qitemdelegate.h>
-#include <QtGui/qlistview.h>
-#include <QtGui/qcombobox.h>
+#include <QtWidgets/qitemdelegate.h>
+#include <QtWidgets/qlistview.h>
+#include <QtWidgets/qcombobox.h>
#include <QtSql/qsqlrelationaltablemodel.h>
QT_BEGIN_HEADER
diff --git a/src/src.pro b/src/src.pro
index 491973c635..9728c5d99f 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -4,7 +4,7 @@ TEMPLATE = subdirs
unset(SRC_SUBDIRS)
win32:SRC_SUBDIRS += src_winmain
symbian:SRC_SUBDIRS += src_s60main
-SRC_SUBDIRS += src_corelib src_network src_sql src_testlib src_xml src_uitools
+SRC_SUBDIRS += src_corelib src_network src_sql src_testlib src_xml src_uitools src_widgets
nacl: SRC_SUBDIRS -= src_network src_testlib
!symbian:contains(QT_CONFIG, dbus):SRC_SUBDIRS += src_dbus
!contains(QT_CONFIG, no-gui): SRC_SUBDIRS += src_gui
@@ -35,6 +35,8 @@ src_dbus.subdir = $$QT_SOURCE_TREE/src/dbus
src_dbus.target = sub-dbus
src_gui.subdir = $$QT_SOURCE_TREE/src/gui
src_gui.target = sub-gui
+src_widgets.subdir = $$QT_SOURCE_TREE/src/widgets
+src_widgets.target = sub-widgets
src_sql.subdir = $$QT_SOURCE_TREE/src/sql
src_sql.target = sub-sql
src_network.subdir = $$QT_SOURCE_TREE/src/network
@@ -51,13 +53,14 @@ src_testlib.target = sub-testlib
#CONFIG += ordered
!wince*:!ordered:!symbian-abld:!symbian-sbsv2 {
src_corelib.depends = src_tools_moc src_tools_rcc
- src_gui.depends = src_corelib src_tools_uic
+ src_gui.depends = src_corelib
+ src_widgets.depends = src_corelib src_gui src_tools_uic
embedded: src_gui.depends += src_network
src_xml.depends = src_corelib
src_uitools.depends = src_corelib src_xml
src_dbus.depends = src_corelib src_xml
src_network.depends = src_corelib
- src_opengl.depends = src_gui
+ src_opengl.depends = src_gui src_widgets
src_openvg.depends = src_gui
src_sql.depends = src_corelib
src_testlib.depends = src_corelib
diff --git a/src/tools/uic/qclass_lib_map.h b/src/tools/uic/qclass_lib_map.h
index 35b4f928ef..f36d77fd13 100644
--- a/src/tools/uic/qclass_lib_map.h
+++ b/src/tools/uic/qclass_lib_map.h
@@ -607,163 +607,94 @@ QT_CLASS_LIB(QSQLite2Result, QtSql, qsql_sqlite2.h)
QT_CLASS_LIB(QSQLite2Driver, QtSql, qsql_sqlite2.h)
QT_CLASS_LIB(QTDSResult, QtSql, qsql_tds.h)
QT_CLASS_LIB(QTDSDriver, QtSql, qsql_tds.h)
-QT_CLASS_LIB(QAccessible, QtGui, qaccessible.h)
-QT_CLASS_LIB(QAccessibleInterface, QtGui, qaccessible.h)
-QT_CLASS_LIB(QAccessibleInterfaceEx, QtGui, qaccessible.h)
-QT_CLASS_LIB(QAccessibleEvent, QtGui, qaccessible.h)
-QT_CLASS_LIB(QAccessible2Interface, QtGui, qaccessible2.h)
-QT_CLASS_LIB(QAccessibleTextInterface, QtGui, qaccessible2.h)
-QT_CLASS_LIB(QAccessibleEditableTextInterface, QtGui, qaccessible2.h)
-QT_CLASS_LIB(QAccessibleSimpleEditableTextInterface, QtGui, qaccessible2.h)
-QT_CLASS_LIB(QAccessibleValueInterface, QtGui, qaccessible2.h)
-QT_CLASS_LIB(QAccessibleTableInterface, QtGui, qaccessible2.h)
-QT_CLASS_LIB(QAccessibleActionInterface, QtGui, qaccessible2.h)
-QT_CLASS_LIB(QAccessibleImageInterface, QtGui, qaccessible2.h)
-QT_CLASS_LIB(QAccessibleBridge, QtGui, qaccessiblebridge.h)
-QT_CLASS_LIB(QAccessibleBridgeFactoryInterface, QtGui, qaccessiblebridge.h)
-QT_CLASS_LIB(QAccessibleBridgePlugin, QtGui, qaccessiblebridge.h)
-QT_CLASS_LIB(QAccessibleObject, QtGui, qaccessibleobject.h)
-QT_CLASS_LIB(QAccessibleObjectEx, QtGui, qaccessibleobject.h)
-QT_CLASS_LIB(QAccessibleApplication, QtGui, qaccessibleobject.h)
-QT_CLASS_LIB(QAccessibleFactoryInterface, QtGui, qaccessibleplugin.h)
-QT_CLASS_LIB(QAccessiblePlugin, QtGui, qaccessibleplugin.h)
-QT_CLASS_LIB(QAccessibleWidget, QtGui, qaccessiblewidget.h)
-QT_CLASS_LIB(QAccessibleWidgetEx, QtGui, qaccessiblewidget.h)
-QT_CLASS_LIB(QAbstractPageSetupDialog, QtGui, qabstractpagesetupdialog.h)
-QT_CLASS_LIB(QAbstractPrintDialog, QtGui, qabstractprintdialog.h)
-QT_CLASS_LIB(QColorDialog, QtGui, qcolordialog.h)
-QT_CLASS_LIB(QDialog, QtGui, qdialog.h)
-QT_CLASS_LIB(QErrorMessage, QtGui, qerrormessage.h)
-QT_CLASS_LIB(QFileDialog, QtGui, qfiledialog.h)
-QT_CLASS_LIB(QFileSystemModel, QtGui, qfilesystemmodel.h)
-QT_CLASS_LIB(QFontDialog, QtGui, qfontdialog.h)
-QT_CLASS_LIB(QInputDialog, QtGui, qinputdialog.h)
-QT_CLASS_LIB(QMessageBox, QtGui, qmessagebox.h)
-QT_CLASS_LIB(QPageSetupDialog, QtGui, qpagesetupdialog.h)
-QT_CLASS_LIB(QUnixPrintWidget, QtGui, qprintdialog.h)
-QT_CLASS_LIB(QPrintDialog, QtGui, qprintdialog.h)
-QT_CLASS_LIB(QPrintPreviewDialog, QtGui, qprintpreviewdialog.h)
-QT_CLASS_LIB(QProgressDialog, QtGui, qprogressdialog.h)
-QT_CLASS_LIB(QWizard, QtGui, qwizard.h)
-QT_CLASS_LIB(QWizardPage, QtGui, qwizard.h)
-QT_CLASS_LIB(QGraphicsEffect, QtGui, qgraphicseffect.h)
-QT_CLASS_LIB(QGraphicsColorizeEffect, QtGui, qgraphicseffect.h)
-QT_CLASS_LIB(QGraphicsBlurEffect, QtGui, qgraphicseffect.h)
-QT_CLASS_LIB(QGraphicsDropShadowEffect, QtGui, qgraphicseffect.h)
-QT_CLASS_LIB(QGraphicsOpacityEffect, QtGui, qgraphicseffect.h)
-QT_CLASS_LIB(QCopChannel, QtGui, qcopchannel_qws.h)
-QT_CLASS_LIB(QDecorationAction, QtGui, qdecoration_qws.h)
-QT_CLASS_LIB(QDecoration, QtGui, qdecoration_qws.h)
-QT_CLASS_LIB(QDecorationDefault, QtGui, qdecorationdefault_qws.h)
-QT_CLASS_LIB(QDecorationFactory, QtGui, qdecorationfactory_qws.h)
-QT_CLASS_LIB(QDecorationFactoryInterface, QtGui, qdecorationplugin_qws.h)
-QT_CLASS_LIB(QDecorationPlugin, QtGui, qdecorationplugin_qws.h)
-QT_CLASS_LIB(QDecorationStyled, QtGui, qdecorationstyled_qws.h)
-QT_CLASS_LIB(QDecorationWindows, QtGui, qdecorationwindows_qws.h)
-QT_CLASS_LIB(QDirectPainter, QtGui, qdirectpainter_qws.h)
-QT_CLASS_LIB(QWSKeyboardHandler, QtGui, qkbd_qws.h)
-QT_CLASS_LIB(QKbdDriverFactory, QtGui, qkbddriverfactory_qws.h)
-QT_CLASS_LIB(QWSKeyboardHandlerFactoryInterface, QtGui, qkbddriverplugin_qws.h)
-QT_CLASS_LIB(QKbdDriverPlugin, QtGui, qkbddriverplugin_qws.h)
-QT_CLASS_LIB(QWSLinuxInputKeyboardHandler, QtGui, qkbdlinuxinput_qws.h)
-QT_CLASS_LIB(QWSQnxKeyboardHandler, QtGui, qkbdqnx_qws.h)
-QT_CLASS_LIB(QWSTtyKeyboardHandler, QtGui, qkbdtty_qws.h)
-QT_CLASS_LIB(QWSUmKeyboardHandler, QtGui, qkbdum_qws.h)
-QT_CLASS_LIB(QVFbKeyboardHandler, QtGui, qkbdvfb_qws.h)
-QT_CLASS_LIB(QWSPointerCalibrationData, QtGui, qmouse_qws.h)
-QT_CLASS_LIB(QWSMouseHandler, QtGui, qmouse_qws.h)
-QT_CLASS_LIB(QWSCalibratedMouseHandler, QtGui, qmouse_qws.h)
-QT_CLASS_LIB(QMouseDriverFactory, QtGui, qmousedriverfactory_qws.h)
-QT_CLASS_LIB(QWSMouseHandlerFactoryInterface, QtGui, qmousedriverplugin_qws.h)
-QT_CLASS_LIB(QMouseDriverPlugin, QtGui, qmousedriverplugin_qws.h)
-QT_CLASS_LIB(QWSLinuxInputMouseHandler, QtGui, qmouselinuxinput_qws.h)
-QT_CLASS_LIB(QWSLinuxTPMouseHandler, QtGui, qmouselinuxtp_qws.h)
-QT_CLASS_LIB(QWSPcMouseHandler, QtGui, qmousepc_qws.h)
-QT_CLASS_LIB(QQnxMouseHandler, QtGui, qmouseqnx_qws.h)
-QT_CLASS_LIB(QWSTslibMouseHandler, QtGui, qmousetslib_qws.h)
-QT_CLASS_LIB(QVFbMouseHandler, QtGui, qmousevfb_qws.h)
-QT_CLASS_LIB(QScreenCursor, QtGui, qscreen_qws.h)
-QT_CLASS_LIB(QPoolEntry, QtGui, qscreen_qws.h)
-QT_CLASS_LIB(QScreen, QtGui, qscreen_qws.h)
-QT_CLASS_LIB(QScreenDriverFactory, QtGui, qscreendriverfactory_qws.h)
-QT_CLASS_LIB(QScreenDriverFactoryInterface, QtGui, qscreendriverplugin_qws.h)
-QT_CLASS_LIB(QScreenDriverPlugin, QtGui, qscreendriverplugin_qws.h)
-QT_CLASS_LIB(QLinuxFb_Shared, QtGui, qscreenlinuxfb_qws.h)
-QT_CLASS_LIB(QLinuxFbScreen, QtGui, qscreenlinuxfb_qws.h)
-QT_CLASS_LIB(QProxyScreenCursor, QtGui, qscreenproxy_qws.h)
-QT_CLASS_LIB(QProxyScreen, QtGui, qscreenproxy_qws.h)
-QT_CLASS_LIB(QQnxScreen, QtGui, qscreenqnx_qws.h)
-QT_CLASS_LIB(QTransformedScreen, QtGui, qscreentransformed_qws.h)
-QT_CLASS_LIB(QVFbScreen, QtGui, qscreenvfb_qws.h)
-QT_CLASS_LIB(QWSSoundServer, QtGui, qsoundqss_qws.h)
-QT_CLASS_LIB(QWSSoundClient, QtGui, qsoundqss_qws.h)
-QT_CLASS_LIB(QWSSoundServerSocket, QtGui, qsoundqss_qws.h)
-QT_CLASS_LIB(QTransportAuth, QtGui, qtransportauth_qws.h)
-QT_CLASS_LIB(QAuthDevice, QtGui, qtransportauth_qws.h)
-QT_CLASS_LIB(QVFbHeader, QtGui, qvfbhdr.h)
-QT_CLASS_LIB(QVFbKeyData, QtGui, qvfbhdr.h)
-QT_CLASS_LIB(QWSInternalWindowInfo, QtGui, qwindowsystem_qws.h)
-QT_CLASS_LIB(QWSScreenSaver, QtGui, qwindowsystem_qws.h)
-QT_CLASS_LIB(QWSWindow, QtGui, qwindowsystem_qws.h)
-QT_CLASS_LIB(QWSSoundServer, QtGui, qwindowsystem_qws.h)
-QT_CLASS_LIB(QWSServer, QtGui, qwindowsystem_qws.h)
-QT_CLASS_LIB(QWSInputMethod, QtGui, qwindowsystem_qws.h)
-QT_CLASS_LIB(QWSCursorMap, QtGui, qwindowsystem_qws.h)
-QT_CLASS_LIB(QWSClient, QtGui, qwindowsystem_qws.h)
-QT_CLASS_LIB(QWSCursor, QtGui, qwscursor_qws.h)
-QT_CLASS_LIB(QWSWindowInfo, QtGui, qwsdisplay_qws.h)
-QT_CLASS_LIB(QWSDisplay, QtGui, qwsdisplay_qws.h)
-QT_CLASS_LIB(QWSEmbedWidget, QtGui, qwsembedwidget.h)
-QT_CLASS_LIB(QWSEvent, QtGui, qwsevent_qws.h)
-QT_CLASS_LIB(QWSManager, QtGui, qwsmanager_qws.h)
-QT_CLASS_LIB(QWSPropertyManager, QtGui, qwsproperty_qws.h)
-QT_CLASS_LIB(QWSProtocolItem, QtGui, qwsprotocolitem_qws.h)
-QT_CLASS_LIB(QWSSocket, QtGui, qwssocket_qws.h)
-QT_CLASS_LIB(QWSServerSocket, QtGui, qwssocket_qws.h)
-QT_CLASS_LIB(QGraphicsAnchor, QtGui, qgraphicsanchorlayout.h)
-QT_CLASS_LIB(QGraphicsAnchorLayout, QtGui, qgraphicsanchorlayout.h)
-QT_CLASS_LIB(QGraphicsGridLayout, QtGui, qgraphicsgridlayout.h)
-QT_CLASS_LIB(QGraphicsItem, QtGui, qgraphicsitem.h)
-QT_CLASS_LIB(QGraphicsObject, QtGui, qgraphicsitem.h)
-QT_CLASS_LIB(QAbstractGraphicsShapeItem, QtGui, qgraphicsitem.h)
-QT_CLASS_LIB(QGraphicsPathItem, QtGui, qgraphicsitem.h)
-QT_CLASS_LIB(QGraphicsRectItem, QtGui, qgraphicsitem.h)
-QT_CLASS_LIB(QGraphicsEllipseItem, QtGui, qgraphicsitem.h)
-QT_CLASS_LIB(QGraphicsPolygonItem, QtGui, qgraphicsitem.h)
-QT_CLASS_LIB(QGraphicsLineItem, QtGui, qgraphicsitem.h)
-QT_CLASS_LIB(QGraphicsPixmapItem, QtGui, qgraphicsitem.h)
-QT_CLASS_LIB(QGraphicsTextItem, QtGui, qgraphicsitem.h)
-QT_CLASS_LIB(QGraphicsSimpleTextItem, QtGui, qgraphicsitem.h)
-QT_CLASS_LIB(QGraphicsItemGroup, QtGui, qgraphicsitem.h)
-QT_CLASS_LIB(QGraphicsItemAnimation, QtGui, qgraphicsitemanimation.h)
-QT_CLASS_LIB(QGraphicsLayout, QtGui, qgraphicslayout.h)
-QT_CLASS_LIB(QGraphicsLayoutItem, QtGui, qgraphicslayoutitem.h)
-QT_CLASS_LIB(QGraphicsLinearLayout, QtGui, qgraphicslinearlayout.h)
-QT_CLASS_LIB(QGraphicsProxyWidget, QtGui, qgraphicsproxywidget.h)
-QT_CLASS_LIB(QGraphicsScene, QtGui, qgraphicsscene.h)
-QT_CLASS_LIB(QGraphicsSceneEvent, QtGui, qgraphicssceneevent.h)
-QT_CLASS_LIB(QGraphicsSceneMouseEvent, QtGui, qgraphicssceneevent.h)
-QT_CLASS_LIB(QGraphicsSceneWheelEvent, QtGui, qgraphicssceneevent.h)
-QT_CLASS_LIB(QGraphicsSceneContextMenuEvent, QtGui, qgraphicssceneevent.h)
-QT_CLASS_LIB(QGraphicsSceneHoverEvent, QtGui, qgraphicssceneevent.h)
-QT_CLASS_LIB(QGraphicsSceneHelpEvent, QtGui, qgraphicssceneevent.h)
-QT_CLASS_LIB(QGraphicsSceneDragDropEvent, QtGui, qgraphicssceneevent.h)
-QT_CLASS_LIB(QGraphicsSceneResizeEvent, QtGui, qgraphicssceneevent.h)
-QT_CLASS_LIB(QGraphicsSceneMoveEvent, QtGui, qgraphicssceneevent.h)
-QT_CLASS_LIB(QGraphicsTransform, QtGui, qgraphicstransform.h)
-QT_CLASS_LIB(QGraphicsScale, QtGui, qgraphicstransform.h)
-QT_CLASS_LIB(QGraphicsRotation, QtGui, qgraphicstransform.h)
-QT_CLASS_LIB(QGraphicsView, QtGui, qgraphicsview.h)
-QT_CLASS_LIB(QGraphicsWidget, QtGui, qgraphicswidget.h)
+QT_CLASS_LIB(QAccessible, QtWidgets, qaccessible.h)
+QT_CLASS_LIB(QAccessibleInterface, QtWidgets, qaccessible.h)
+QT_CLASS_LIB(QAccessibleInterfaceEx, QtWidgets, qaccessible.h)
+QT_CLASS_LIB(QAccessibleEvent, QtWidgets, qaccessible.h)
+QT_CLASS_LIB(QAccessible2Interface, QtWidgets, qaccessible2.h)
+QT_CLASS_LIB(QAccessibleTextInterface, QtWidgets, qaccessible2.h)
+QT_CLASS_LIB(QAccessibleEditableTextInterface, QtWidgets, qaccessible2.h)
+QT_CLASS_LIB(QAccessibleSimpleEditableTextInterface, QtWidgets, qaccessible2.h)
+QT_CLASS_LIB(QAccessibleValueInterface, QtWidgets, qaccessible2.h)
+QT_CLASS_LIB(QAccessibleTableInterface, QtWidgets, qaccessible2.h)
+QT_CLASS_LIB(QAccessibleActionInterface, QtWidgets, qaccessible2.h)
+QT_CLASS_LIB(QAccessibleImageInterface, QtWidgets, qaccessible2.h)
+QT_CLASS_LIB(QAccessibleBridge, QtWidgets, qaccessiblebridge.h)
+QT_CLASS_LIB(QAccessibleBridgeFactoryInterface, QtWidgets, qaccessiblebridge.h)
+QT_CLASS_LIB(QAccessibleBridgePlugin, QtWidgets, qaccessiblebridge.h)
+QT_CLASS_LIB(QAccessibleObject, QtWidgets, qaccessibleobject.h)
+QT_CLASS_LIB(QAccessibleObjectEx, QtWidgets, qaccessibleobject.h)
+QT_CLASS_LIB(QAccessibleApplication, QtWidgets, qaccessibleobject.h)
+QT_CLASS_LIB(QAccessibleFactoryInterface, QtWidgets, qaccessibleplugin.h)
+QT_CLASS_LIB(QAccessiblePlugin, QtWidgets, qaccessibleplugin.h)
+QT_CLASS_LIB(QAccessibleWidget, QtWidgets, qaccessiblewidget.h)
+QT_CLASS_LIB(QAccessibleWidgetEx, QtWidgets, qaccessiblewidget.h)
+QT_CLASS_LIB(QAbstractPageSetupDialog, QtWidgets, qabstractpagesetupdialog.h)
+QT_CLASS_LIB(QAbstractPrintDialog, QtWidgets, qabstractprintdialog.h)
+QT_CLASS_LIB(QColorDialog, QtWidgets, qcolordialog.h)
+QT_CLASS_LIB(QDialog, QtWidgets, qdialog.h)
+QT_CLASS_LIB(QErrorMessage, QtWidgets, qerrormessage.h)
+QT_CLASS_LIB(QFileDialog, QtWidgets, qfiledialog.h)
+QT_CLASS_LIB(QFileSystemModel, QtWidgets, qfilesystemmodel.h)
+QT_CLASS_LIB(QFontDialog, QtWidgets, qfontdialog.h)
+QT_CLASS_LIB(QInputDialog, QtWidgets, qinputdialog.h)
+QT_CLASS_LIB(QMessageBox, QtWidgets, qmessagebox.h)
+QT_CLASS_LIB(QPageSetupDialog, QtWidgets, qpagesetupdialog.h)
+QT_CLASS_LIB(QUnixPrintWidget, QtWidgets, qprintdialog.h)
+QT_CLASS_LIB(QPrintDialog, QtWidgets, qprintdialog.h)
+QT_CLASS_LIB(QPrintPreviewDialog, QtWidgets, qprintpreviewdialog.h)
+QT_CLASS_LIB(QProgressDialog, QtWidgets, qprogressdialog.h)
+QT_CLASS_LIB(QWizard, QtWidgets, qwizard.h)
+QT_CLASS_LIB(QWizardPage, QtWidgets, qwizard.h)
+QT_CLASS_LIB(QGraphicsEffect, QtWidgets, qgraphicseffect.h)
+QT_CLASS_LIB(QGraphicsColorizeEffect, QtWidgets, qgraphicseffect.h)
+QT_CLASS_LIB(QGraphicsBlurEffect, QtWidgets, qgraphicseffect.h)
+QT_CLASS_LIB(QGraphicsDropShadowEffect, QtWidgets, qgraphicseffect.h)
+QT_CLASS_LIB(QGraphicsOpacityEffect, QtWidgets, qgraphicseffect.h)
+QT_CLASS_LIB(QGraphicsAnchor, QtWidgets, qgraphicsanchorlayout.h)
+QT_CLASS_LIB(QGraphicsAnchorLayout, QtWidgets, qgraphicsanchorlayout.h)
+QT_CLASS_LIB(QGraphicsGridLayout, QtWidgets, qgraphicsgridlayout.h)
+QT_CLASS_LIB(QGraphicsItem, QtWidgets, qgraphicsitem.h)
+QT_CLASS_LIB(QGraphicsObject, QtWidgets, qgraphicsitem.h)
+QT_CLASS_LIB(QAbstractGraphicsShapeItem, QtWidgets, qgraphicsitem.h)
+QT_CLASS_LIB(QGraphicsPathItem, QtWidgets, qgraphicsitem.h)
+QT_CLASS_LIB(QGraphicsRectItem, QtWidgets, qgraphicsitem.h)
+QT_CLASS_LIB(QGraphicsEllipseItem, QtWidgets, qgraphicsitem.h)
+QT_CLASS_LIB(QGraphicsPolygonItem, QtWidgets, qgraphicsitem.h)
+QT_CLASS_LIB(QGraphicsLineItem, QtWidgets, qgraphicsitem.h)
+QT_CLASS_LIB(QGraphicsPixmapItem, QtWidgets, qgraphicsitem.h)
+QT_CLASS_LIB(QGraphicsTextItem, QtWidgets, qgraphicsitem.h)
+QT_CLASS_LIB(QGraphicsSimpleTextItem, QtWidgets, qgraphicsitem.h)
+QT_CLASS_LIB(QGraphicsItemGroup, QtWidgets, qgraphicsitem.h)
+QT_CLASS_LIB(QGraphicsItemAnimation, QtWidgets, qgraphicsitemanimation.h)
+QT_CLASS_LIB(QGraphicsLayout, QtWidgets, qgraphicslayout.h)
+QT_CLASS_LIB(QGraphicsLayoutItem, QtWidgets, qgraphicslayoutitem.h)
+QT_CLASS_LIB(QGraphicsLinearLayout, QtWidgets, qgraphicslinearlayout.h)
+QT_CLASS_LIB(QGraphicsProxyWidget, QtWidgets, qgraphicsproxywidget.h)
+QT_CLASS_LIB(QGraphicsScene, QtWidgets, qgraphicsscene.h)
+QT_CLASS_LIB(QGraphicsSceneEvent, QtWidgets, qgraphicssceneevent.h)
+QT_CLASS_LIB(QGraphicsSceneMouseEvent, QtWidgets, qgraphicssceneevent.h)
+QT_CLASS_LIB(QGraphicsSceneWheelEvent, QtWidgets, qgraphicssceneevent.h)
+QT_CLASS_LIB(QGraphicsSceneContextMenuEvent, QtWidgets, qgraphicssceneevent.h)
+QT_CLASS_LIB(QGraphicsSceneHoverEvent, QtWidgets, qgraphicssceneevent.h)
+QT_CLASS_LIB(QGraphicsSceneHelpEvent, QtWidgets, qgraphicssceneevent.h)
+QT_CLASS_LIB(QGraphicsSceneDragDropEvent, QtWidgets, qgraphicssceneevent.h)
+QT_CLASS_LIB(QGraphicsSceneResizeEvent, QtWidgets, qgraphicssceneevent.h)
+QT_CLASS_LIB(QGraphicsSceneMoveEvent, QtWidgets, qgraphicssceneevent.h)
+QT_CLASS_LIB(QGraphicsTransform, QtWidgets, qgraphicstransform.h)
+QT_CLASS_LIB(QGraphicsScale, QtWidgets, qgraphicstransform.h)
+QT_CLASS_LIB(QGraphicsRotation, QtWidgets, qgraphicstransform.h)
+QT_CLASS_LIB(QGraphicsView, QtWidgets, qgraphicsview.h)
+QT_CLASS_LIB(QGraphicsWidget, QtWidgets, qgraphicswidget.h)
QT_CLASS_LIB(QBitmap, QtGui, qbitmap.h)
-QT_CLASS_LIB(QIcon, QtGui, qicon.h)
-QT_CLASS_LIB(QIconSet, QtGui, qicon.h)
-QT_CLASS_LIB(QIconEngine, QtGui, qiconengine.h)
-QT_CLASS_LIB(QIconEngineV2, QtGui, qiconengine.h)
-QT_CLASS_LIB(QIconEngineFactoryInterface, QtGui, qiconengineplugin.h)
-QT_CLASS_LIB(QIconEnginePlugin, QtGui, qiconengineplugin.h)
-QT_CLASS_LIB(QIconEngineFactoryInterfaceV2, QtGui, qiconengineplugin.h)
-QT_CLASS_LIB(QIconEnginePluginV2, QtGui, qiconengineplugin.h)
+QT_CLASS_LIB(QIcon, QtWidgets, qicon.h)
+QT_CLASS_LIB(QIconSet, QtWidgets, qicon.h)
+QT_CLASS_LIB(QIconEngine, QtWidgets, qiconengine.h)
+QT_CLASS_LIB(QIconEngineV2, QtWidgets, qiconengine.h)
+QT_CLASS_LIB(QIconEngineFactoryInterface, QtWidgets, qiconengineplugin.h)
+QT_CLASS_LIB(QIconEnginePlugin, QtWidgets, qiconengineplugin.h)
+QT_CLASS_LIB(QIconEngineFactoryInterfaceV2, QtWidgets, qiconengineplugin.h)
+QT_CLASS_LIB(QIconEnginePluginV2, QtWidgets, qiconengineplugin.h)
QT_CLASS_LIB(QImageTextKeyLang, QtGui, qimage.h)
QT_CLASS_LIB(QImage, QtGui, qimage.h)
QT_CLASS_LIB(QImageIOHandler, QtGui, qimageiohandler.h)
@@ -778,54 +709,54 @@ QT_CLASS_LIB(QPictureFormatInterface, QtGui, qpictureformatplugin.h)
QT_CLASS_LIB(QPictureFormatPlugin, QtGui, qpictureformatplugin.h)
QT_CLASS_LIB(QPixmap, QtGui, qpixmap.h)
QT_CLASS_LIB(QPixmapCache, QtGui, qpixmapcache.h)
-QT_CLASS_LIB(QInputContext, QtGui, qinputcontext.h)
-QT_CLASS_LIB(QInputContextFactory, QtGui, qinputcontextfactory.h)
-QT_CLASS_LIB(QInputContextFactoryInterface, QtGui, qinputcontextplugin.h)
-QT_CLASS_LIB(QInputContextPlugin, QtGui, qinputcontextplugin.h)
-QT_CLASS_LIB(QAbstractItemDelegate, QtGui, qabstractitemdelegate.h)
-QT_CLASS_LIB(QAbstractItemView, QtGui, qabstractitemview.h)
-QT_CLASS_LIB(QAbstractProxyModel, QtGui, qabstractproxymodel.h)
-QT_CLASS_LIB(QColumnView, QtGui, qcolumnview.h)
-QT_CLASS_LIB(QDataWidgetMapper, QtGui, qdatawidgetmapper.h)
-QT_CLASS_LIB(QDirModel, QtGui, qdirmodel.h)
-QT_CLASS_LIB(QFileIconProvider, QtGui, qfileiconprovider.h)
-QT_CLASS_LIB(QHeaderView, QtGui, qheaderview.h)
-QT_CLASS_LIB(QItemDelegate, QtGui, qitemdelegate.h)
-QT_CLASS_LIB(QItemEditorCreatorBase, QtGui, qitemeditorfactory.h)
-QT_CLASS_LIB(QItemEditorCreator, QtGui, qitemeditorfactory.h)
-QT_CLASS_LIB(QStandardItemEditorCreator, QtGui, qitemeditorfactory.h)
-QT_CLASS_LIB(QItemEditorFactory, QtGui, qitemeditorfactory.h)
-QT_CLASS_LIB(QItemSelectionRange, QtGui, qitemselectionmodel.h)
-QT_CLASS_LIB(QItemSelectionModel, QtGui, qitemselectionmodel.h)
-QT_CLASS_LIB(QItemSelection, QtGui, qitemselectionmodel.h)
-QT_CLASS_LIB(QListView, QtGui, qlistview.h)
-QT_CLASS_LIB(QListWidgetItem, QtGui, qlistwidget.h)
-QT_CLASS_LIB(QListWidget, QtGui, qlistwidget.h)
-QT_CLASS_LIB(QProxyModel, QtGui, qproxymodel.h)
-QT_CLASS_LIB(QSortFilterProxyModel, QtGui, qsortfilterproxymodel.h)
-QT_CLASS_LIB(QStandardItem, QtGui, qstandarditemmodel.h)
-QT_CLASS_LIB(QStandardItemModel, QtGui, qstandarditemmodel.h)
-QT_CLASS_LIB(QStringListModel, QtGui, qstringlistmodel.h)
-QT_CLASS_LIB(QStyledItemDelegate, QtGui, qstyleditemdelegate.h)
-QT_CLASS_LIB(QTableView, QtGui, qtableview.h)
-QT_CLASS_LIB(QTableWidgetSelectionRange, QtGui, qtablewidget.h)
-QT_CLASS_LIB(QTableWidgetItem, QtGui, qtablewidget.h)
-QT_CLASS_LIB(QTableWidget, QtGui, qtablewidget.h)
-QT_CLASS_LIB(QTreeView, QtGui, qtreeview.h)
-QT_CLASS_LIB(QTreeWidgetItem, QtGui, qtreewidget.h)
-QT_CLASS_LIB(QTreeWidget, QtGui, qtreewidget.h)
-QT_CLASS_LIB(QTreeWidgetItemIterator, QtGui, qtreewidgetitemiterator.h)
-QT_CLASS_LIB(QAction, QtGui, qaction.h)
-QT_CLASS_LIB(QActionGroup, QtGui, qactiongroup.h)
-QT_CLASS_LIB(QApplication, QtGui, qapplication.h)
-QT_CLASS_LIB(QBoxLayout, QtGui, qboxlayout.h)
-QT_CLASS_LIB(QHBoxLayout, QtGui, qboxlayout.h)
-QT_CLASS_LIB(QVBoxLayout, QtGui, qboxlayout.h)
+QT_CLASS_LIB(QInputContext, QtWidgets, qinputcontext.h)
+QT_CLASS_LIB(QInputContextFactory, QtWidgets, qinputcontextfactory.h)
+QT_CLASS_LIB(QInputContextFactoryInterface, QtWidgets, qinputcontextplugin.h)
+QT_CLASS_LIB(QInputContextPlugin, QtWidgets, qinputcontextplugin.h)
+QT_CLASS_LIB(QAbstractItemDelegate, QtWidgets, qabstractitemdelegate.h)
+QT_CLASS_LIB(QAbstractItemView, QtWidgets, qabstractitemview.h)
+QT_CLASS_LIB(QAbstractProxyModel, QtWidgets, qabstractproxymodel.h)
+QT_CLASS_LIB(QColumnView, QtWidgets, qcolumnview.h)
+QT_CLASS_LIB(QDataWidgetMapper, QtWidgets, qdatawidgetmapper.h)
+QT_CLASS_LIB(QDirModel, QtWidgets, qdirmodel.h)
+QT_CLASS_LIB(QFileIconProvider, QtWidgets, qfileiconprovider.h)
+QT_CLASS_LIB(QHeaderView, QtWidgets, qheaderview.h)
+QT_CLASS_LIB(QItemDelegate, QtWidgets, qitemdelegate.h)
+QT_CLASS_LIB(QItemEditorCreatorBase, QtWidgets, qitemeditorfactory.h)
+QT_CLASS_LIB(QItemEditorCreator, QtWidgets, qitemeditorfactory.h)
+QT_CLASS_LIB(QStandardItemEditorCreator, QtWidgets, qitemeditorfactory.h)
+QT_CLASS_LIB(QItemEditorFactory, QtWidgets, qitemeditorfactory.h)
+QT_CLASS_LIB(QItemSelectionRange, QtWidgets, qitemselectionmodel.h)
+QT_CLASS_LIB(QItemSelectionModel, QtWidgets, qitemselectionmodel.h)
+QT_CLASS_LIB(QItemSelection, QtWidgets, qitemselectionmodel.h)
+QT_CLASS_LIB(QListView, QtWidgets, qlistview.h)
+QT_CLASS_LIB(QListWidgetItem, QtWidgets, qlistwidget.h)
+QT_CLASS_LIB(QListWidget, QtWidgets, qlistwidget.h)
+QT_CLASS_LIB(QProxyModel, QtWidgets, qproxymodel.h)
+QT_CLASS_LIB(QSortFilterProxyModel, QtWidgets, qsortfilterproxymodel.h)
+QT_CLASS_LIB(QStandardItem, QtWidgets, qstandarditemmodel.h)
+QT_CLASS_LIB(QStandardItemModel, QtWidgets, qstandarditemmodel.h)
+QT_CLASS_LIB(QStringListModel, QtWidgets, qstringlistmodel.h)
+QT_CLASS_LIB(QStyledItemDelegate, QtWidgets, qstyleditemdelegate.h)
+QT_CLASS_LIB(QTableView, QtWidgets, qtableview.h)
+QT_CLASS_LIB(QTableWidgetSelectionRange, QtWidgets, qtablewidget.h)
+QT_CLASS_LIB(QTableWidgetItem, QtWidgets, qtablewidget.h)
+QT_CLASS_LIB(QTableWidget, QtWidgets, qtablewidget.h)
+QT_CLASS_LIB(QTreeView, QtWidgets, qtreeview.h)
+QT_CLASS_LIB(QTreeWidgetItem, QtWidgets, qtreewidget.h)
+QT_CLASS_LIB(QTreeWidget, QtWidgets, qtreewidget.h)
+QT_CLASS_LIB(QTreeWidgetItemIterator, QtWidgets, qtreewidgetitemiterator.h)
+QT_CLASS_LIB(QAction, QtWidgets, qaction.h)
+QT_CLASS_LIB(QActionGroup, QtWidgets, qactiongroup.h)
+QT_CLASS_LIB(QApplication, QtWidgets, qapplication.h)
+QT_CLASS_LIB(QBoxLayout, QtWidgets, qboxlayout.h)
+QT_CLASS_LIB(QHBoxLayout, QtWidgets, qboxlayout.h)
+QT_CLASS_LIB(QVBoxLayout, QtWidgets, qboxlayout.h)
QT_CLASS_LIB(QClipboard, QtGui, qclipboard.h)
QT_CLASS_LIB(QCursor, QtGui, qcursor.h)
QT_CLASS_LIB(QCursor, QtGui, qcursor.h)
-QT_CLASS_LIB(QCursorShape, QtGui, qcursor.h)
-QT_CLASS_LIB(QDesktopWidget, QtGui, qdesktopwidget.h)
+QT_CLASS_LIB(QCursorShape, QtWidgets, qcursor.h)
+QT_CLASS_LIB(QDesktopWidget, QtWidgets, qdesktopwidget.h)
QT_CLASS_LIB(QDrag, QtGui, qdrag.h)
QT_CLASS_LIB(QtEvents, QtGui, qevent.h)
QT_CLASS_LIB(QInputEvent, QtGui, qevent.h)
@@ -864,32 +795,32 @@ QT_CLASS_LIB(QTouchEvent, QtGui, qevent.h)
QT_CLASS_LIB(QGestureEvent, QtGui, qevent.h)
QT_CLASS_LIB(QScrollPrepareEvent, QtGui, qevent.h)
QT_CLASS_LIB(QScrollEvent, QtGui, qevent.h)
-QT_CLASS_LIB(QFormLayout, QtGui, qformlayout.h)
+QT_CLASS_LIB(QFormLayout, QtWidgets, qformlayout.h)
QT_CLASS_LIB(QGenericPluginFactoryInterface, QtGui, qgenericplugin_qpa.h)
QT_CLASS_LIB(QGenericPlugin, QtGui, qgenericplugin_qpa.h)
QT_CLASS_LIB(QGenericPluginFactory, QtGui, qgenericpluginfactory_qpa.h)
-QT_CLASS_LIB(QGesture, QtGui, qgesture.h)
-QT_CLASS_LIB(QPanGesture, QtGui, qgesture.h)
-QT_CLASS_LIB(QPinchGesture, QtGui, qgesture.h)
-QT_CLASS_LIB(QSwipeGesture, QtGui, qgesture.h)
-QT_CLASS_LIB(QTapGesture, QtGui, qgesture.h)
-QT_CLASS_LIB(QTapAndHoldGesture, QtGui, qgesture.h)
-QT_CLASS_LIB(QGestureRecognizer, QtGui, qgesturerecognizer.h)
-QT_CLASS_LIB(QGridLayout, QtGui, qgridlayout.h)
+QT_CLASS_LIB(QGesture, QtWidgets, qgesture.h)
+QT_CLASS_LIB(QPanGesture, QtWidgets, qgesture.h)
+QT_CLASS_LIB(QPinchGesture, QtWidgets, qgesture.h)
+QT_CLASS_LIB(QSwipeGesture, QtWidgets, qgesture.h)
+QT_CLASS_LIB(QTapGesture, QtWidgets, qgesture.h)
+QT_CLASS_LIB(QTapAndHoldGesture, QtWidgets, qgesture.h)
+QT_CLASS_LIB(QGestureRecognizer, QtWidgets, qgesturerecognizer.h)
+QT_CLASS_LIB(QGridLayout, QtWidgets, qgridlayout.h)
QT_CLASS_LIB(QKeySequence, QtGui, qkeysequence.h)
QT_CLASS_LIB(QKeySequence, QtGui, qkeysequence.h)
-QT_CLASS_LIB(QLayoutIterator, QtGui, qlayout.h)
-QT_CLASS_LIB(QLayout, QtGui, qlayout.h)
-QT_CLASS_LIB(QLayoutItem, QtGui, qlayoutitem.h)
-QT_CLASS_LIB(QSpacerItem, QtGui, qlayoutitem.h)
-QT_CLASS_LIB(QWidgetItem, QtGui, qlayoutitem.h)
-QT_CLASS_LIB(QWidgetItemV2, QtGui, qlayoutitem.h)
+QT_CLASS_LIB(QLayoutIterator, QtWidgets, qlayout.h)
+QT_CLASS_LIB(QLayout, QtWidgets, qlayout.h)
+QT_CLASS_LIB(QLayoutItem, QtWidgets, qlayoutitem.h)
+QT_CLASS_LIB(QSpacerItem, QtWidgets, qlayoutitem.h)
+QT_CLASS_LIB(QWidgetItem, QtWidgets, qlayoutitem.h)
+QT_CLASS_LIB(QWidgetItemV2, QtWidgets, qlayoutitem.h)
QT_CLASS_LIB(QMimeSource, QtGui, qmime.h)
QT_CLASS_LIB(QWindowsMime, QtGui, qmime.h)
QT_CLASS_LIB(QMacMime, QtGui, qmime.h)
QT_CLASS_LIB(QMacPasteboardMime, QtGui, qmime.h)
QT_CLASS_LIB(QPalette, QtGui, qpalette.h)
-QT_CLASS_LIB(QColorGroup, QtGui, qpalette.h)
+QT_CLASS_LIB(QColorGroup, QtWidgets, qpalette.h)
QT_CLASS_LIB(QPlatformCursorImage, QtGui, qplatformcursor_qpa.h)
QT_CLASS_LIB(QPlatformCursorPrivate, QtGui, qplatformcursor_qpa.h)
QT_CLASS_LIB(QPlatformCursor, QtGui, qplatformcursor_qpa.h)
@@ -902,22 +833,22 @@ QT_CLASS_LIB(QPlatformScreen, QtGui, qplatformscreen_qpa.h)
QT_CLASS_LIB(QPlatformWindow, QtGui, qplatformwindow_qpa.h)
QT_CLASS_LIB(QPlatformWindowFormat, QtGui, qplatformwindowformat_qpa.h)
QT_CLASS_LIB(QSessionManager, QtGui, qsessionmanager.h)
-QT_CLASS_LIB(QShortcut, QtGui, qshortcut.h)
-QT_CLASS_LIB(QSizePolicy, QtGui, qsizepolicy.h)
-QT_CLASS_LIB(QSound, QtGui, qsound.h)
-QT_CLASS_LIB(QStackedLayout, QtGui, qstackedlayout.h)
-QT_CLASS_LIB(QToolTip, QtGui, qtooltip.h)
-QT_CLASS_LIB(QWhatsThis, QtGui, qwhatsthis.h)
-QT_CLASS_LIB(QWidgetData, QtGui, qwidget.h)
-QT_CLASS_LIB(QWidget, QtGui, qwidget.h)
-QT_CLASS_LIB(QWidgetAction, QtGui, qwidgetaction.h)
-QT_CLASS_LIB(QWidgetList, QtGui, qwindowdefs.h)
-QT_CLASS_LIB(QWidgetMapper, QtGui, qwindowdefs.h)
-QT_CLASS_LIB(QWidgetSet, QtGui, qwindowdefs.h)
-QT_CLASS_LIB(QWindowSystemInterface, QtGui, qwindowsysteminterface_qpa.h)
-QT_CLASS_LIB(QX11EmbedWidget, QtGui, qx11embed_x11.h)
-QT_CLASS_LIB(QX11EmbedContainer, QtGui, qx11embed_x11.h)
-QT_CLASS_LIB(QX11Info, QtGui, qx11info_x11.h)
+QT_CLASS_LIB(QShortcut, QtWidgets, qshortcut.h)
+QT_CLASS_LIB(QSizePolicy, QtWidgets, qsizepolicy.h)
+QT_CLASS_LIB(QSound, QtWidgets, qsound.h)
+QT_CLASS_LIB(QStackedLayout, QtWidgets, qstackedlayout.h)
+QT_CLASS_LIB(QToolTip, QtWidgets, qtooltip.h)
+QT_CLASS_LIB(QWhatsThis, QtWidgets, qwhatsthis.h)
+QT_CLASS_LIB(QWidgetData, QtWidgets, qwidget.h)
+QT_CLASS_LIB(QWidget, QtWidgets, qwidget.h)
+QT_CLASS_LIB(QWidgetAction, QtWidgets, qwidgetaction.h)
+QT_CLASS_LIB(QWidgetList, QtWidgets, qwindowdefs.h)
+QT_CLASS_LIB(QWidgetMapper, QtWidgets, qwindowdefs.h)
+QT_CLASS_LIB(QWidgetSet, QtWidgets, qwindowdefs.h)
+QT_CLASS_LIB(QWindowSystemInterface, QtWidgets, qwindowsysteminterface_qpa.h)
+QT_CLASS_LIB(QX11EmbedWidget, QtWidgets, qx11embed_x11.h)
+QT_CLASS_LIB(QX11EmbedContainer, QtWidgets, qx11embed_x11.h)
+QT_CLASS_LIB(QX11Info, QtWidgets, qx11info_x11.h)
QT_CLASS_LIB(QGenericMatrix, QtGui, qgenericmatrix.h)
QT_CLASS_LIB(QMatrix2x2, QtGui, qgenericmatrix.h)
QT_CLASS_LIB(QMatrix2x3, QtGui, qgenericmatrix.h)
@@ -964,80 +895,80 @@ QT_CLASS_LIB(QStylePainter, QtGui, qstylepainter.h)
QT_CLASS_LIB(QTransform, QtGui, qtransform.h)
QT_CLASS_LIB(QWMatrix, QtGui, qwmatrix.h)
QT_CLASS_LIB(QS60MainApplicationBase, QtGui, qs60mainapplication.h)
-QT_CLASS_LIB(QS60MainApplicationBase, QtGui, qs60mainapplication.h)
-QT_CLASS_LIB(QS60MainApplication, QtGui, qs60mainapplication.h)
-QT_CLASS_LIB(QS60MainAppUiBase, QtGui, qs60mainappui.h)
-QT_CLASS_LIB(QS60StubAknAppUiBase, QtGui, qs60mainappui.h)
-QT_CLASS_LIB(QS60StubMEikStatusPaneObserver, QtGui, qs60mainappui.h)
-QT_CLASS_LIB(QS60StubMAknTouchPaneObserver, QtGui, qs60mainappui.h)
-QT_CLASS_LIB(QS60StubAknAppUi, QtGui, qs60mainappui.h)
-QT_CLASS_LIB(QS60MainAppUiBase, QtGui, qs60mainappui.h)
-QT_CLASS_LIB(QS60MainAppUi, QtGui, qs60mainappui.h)
-QT_CLASS_LIB(QS60MainDocumentBase, QtGui, qs60maindocument.h)
-QT_CLASS_LIB(QS60MainDocumentBase, QtGui, qs60maindocument.h)
-QT_CLASS_LIB(QS60MainDocument, QtGui, qs60maindocument.h)
-QT_CLASS_LIB(QKeyEventTransition, QtGui, qkeyeventtransition.h)
-QT_CLASS_LIB(QMouseEventTransition, QtGui, qmouseeventtransition.h)
-QT_CLASS_LIB(QCDEStyle, QtGui, qcdestyle.h)
-QT_CLASS_LIB(QCleanlooksStyle, QtGui, qcleanlooksstyle.h)
-QT_CLASS_LIB(QCommonStyle, QtGui, qcommonstyle.h)
-QT_CLASS_LIB(QGtkStyle, QtGui, qgtkstyle.h)
-QT_CLASS_LIB(QMacStyle, QtGui, qmacstyle_mac.h)
-QT_CLASS_LIB(QMotifStyle, QtGui, qmotifstyle.h)
-QT_CLASS_LIB(QPlastiqueStyle, QtGui, qplastiquestyle.h)
-QT_CLASS_LIB(QProxyStyle, QtGui, qproxystyle.h)
-QT_CLASS_LIB(QS60Style, QtGui, qs60style.h)
-QT_CLASS_LIB(QStyle, QtGui, qstyle.h)
-QT_CLASS_LIB(QStyleFactory, QtGui, qstylefactory.h)
-QT_CLASS_LIB(QStyleOption, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionFocusRect, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionFrame, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionFrameV2, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionFrameV3, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionTabWidgetFrame, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionTabWidgetFrameV2, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionTabBarBase, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionTabBarBaseV2, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionHeader, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionButton, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionTab, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionTabV2, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionTabV3, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionToolBar, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionProgressBar, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionProgressBarV2, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionMenuItem, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionQ3ListViewItem, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionQ3DockWindow, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionDockWidget, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionDockWidgetV2, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionViewItem, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionViewItemV2, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionViewItemV3, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionViewItemV4, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionToolBox, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionToolBoxV2, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionRubberBand, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionComplex, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionSlider, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionSpinBox, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionQ3ListView, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionToolButton, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionComboBox, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionTitleBar, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionGroupBox, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionSizeGrip, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleOptionGraphicsItem, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleHintReturn, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleHintReturnMask, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleHintReturnVariant, QtGui, qstyleoption.h)
-QT_CLASS_LIB(QStyleFactoryInterface, QtGui, qstyleplugin.h)
-QT_CLASS_LIB(QStylePlugin, QtGui, qstyleplugin.h)
-QT_CLASS_LIB(QWindowsCEStyle, QtGui, qwindowscestyle.h)
-QT_CLASS_LIB(QWindowsMobileStyle, QtGui, qwindowsmobilestyle.h)
-QT_CLASS_LIB(QWindowsStyle, QtGui, qwindowsstyle.h)
-QT_CLASS_LIB(QWindowsVistaStyle, QtGui, qwindowsvistastyle.h)
-QT_CLASS_LIB(QWindowsXPStyle, QtGui, qwindowsxpstyle.h)
+QT_CLASS_LIB(QS60MainApplicationBase, QtWidgets, qs60mainapplication.h)
+QT_CLASS_LIB(QS60MainApplication, QtWidgets, qs60mainapplication.h)
+QT_CLASS_LIB(QS60MainAppUiBase, QtWidgets, qs60mainappui.h)
+QT_CLASS_LIB(QS60StubAknAppUiBase, QtWidgets, qs60mainappui.h)
+QT_CLASS_LIB(QS60StubMEikStatusPaneObserver, QtWidgets, qs60mainappui.h)
+QT_CLASS_LIB(QS60StubMAknTouchPaneObserver, QtWidgets, qs60mainappui.h)
+QT_CLASS_LIB(QS60StubAknAppUi, QtWidgets, qs60mainappui.h)
+QT_CLASS_LIB(QS60MainAppUiBase, QtWidgets, qs60mainappui.h)
+QT_CLASS_LIB(QS60MainAppUi, QtWidgets, qs60mainappui.h)
+QT_CLASS_LIB(QS60MainDocumentBase, QtWidgets, qs60maindocument.h)
+QT_CLASS_LIB(QS60MainDocumentBase, QtWidgets, qs60maindocument.h)
+QT_CLASS_LIB(QS60MainDocument, QtWidgets, qs60maindocument.h)
+QT_CLASS_LIB(QKeyEventTransition, QtWidgets, qkeyeventtransition.h)
+QT_CLASS_LIB(QMouseEventTransition, QtWidgets, qmouseeventtransition.h)
+QT_CLASS_LIB(QCDEStyle, QtWidgets, qcdestyle.h)
+QT_CLASS_LIB(QCleanlooksStyle, QtWidgets, qcleanlooksstyle.h)
+QT_CLASS_LIB(QCommonStyle, QtWidgets, qcommonstyle.h)
+QT_CLASS_LIB(QGtkStyle, QtWidgets, qgtkstyle.h)
+QT_CLASS_LIB(QMacStyle, QtWidgets, qmacstyle_mac.h)
+QT_CLASS_LIB(QMotifStyle, QtWidgets, qmotifstyle.h)
+QT_CLASS_LIB(QPlastiqueStyle, QtWidgets, qplastiquestyle.h)
+QT_CLASS_LIB(QProxyStyle, QtWidgets, qproxystyle.h)
+QT_CLASS_LIB(QS60Style, QtWidgets, qs60style.h)
+QT_CLASS_LIB(QStyle, QtWidgets, qstyle.h)
+QT_CLASS_LIB(QStyleFactory, QtWidgets, qstylefactory.h)
+QT_CLASS_LIB(QStyleOption, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionFocusRect, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionFrame, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionFrameV2, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionFrameV3, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionTabWidgetFrame, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionTabWidgetFrameV2, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionTabBarBase, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionTabBarBaseV2, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionHeader, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionButton, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionTab, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionTabV2, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionTabV3, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionToolBar, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionProgressBar, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionProgressBarV2, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionMenuItem, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionQ3ListViewItem, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionQ3DockWindow, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionDockWidget, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionDockWidgetV2, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionViewItem, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionViewItemV2, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionViewItemV3, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionViewItemV4, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionToolBox, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionToolBoxV2, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionRubberBand, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionComplex, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionSlider, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionSpinBox, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionQ3ListView, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionToolButton, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionComboBox, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionTitleBar, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionGroupBox, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionSizeGrip, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleOptionGraphicsItem, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleHintReturn, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleHintReturnMask, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleHintReturnVariant, QtWidgets, qstyleoption.h)
+QT_CLASS_LIB(QStyleFactoryInterface, QtWidgets, qstyleplugin.h)
+QT_CLASS_LIB(QStylePlugin, QtWidgets, qstyleplugin.h)
+QT_CLASS_LIB(QWindowsCEStyle, QtWidgets, qwindowscestyle.h)
+QT_CLASS_LIB(QWindowsMobileStyle, QtWidgets, qwindowsmobilestyle.h)
+QT_CLASS_LIB(QWindowsStyle, QtWidgets, qwindowsstyle.h)
+QT_CLASS_LIB(QWindowsVistaStyle, QtWidgets, qwindowsvistastyle.h)
+QT_CLASS_LIB(QWindowsXPStyle, QtWidgets, qwindowsxpstyle.h)
QT_CLASS_LIB(QSymbianEvent, QtGui, qsymbianevent.h)
QT_CLASS_LIB(QFontEngineInfo, QtGui, qabstractfontengine_qws.h)
QT_CLASS_LIB(QFontEngineFactoryInterface, QtGui, qabstractfontengine_qws.h)
@@ -1082,76 +1013,76 @@ QT_CLASS_LIB(QTextBlock, QtGui, qtextobject.h)
QT_CLASS_LIB(QTextFragment, QtGui, qtextobject.h)
QT_CLASS_LIB(QTextOption, QtGui, qtextoption.h)
QT_CLASS_LIB(QTextTableCell, QtGui, qtexttable.h)
-QT_CLASS_LIB(QTextTable, QtGui, qtexttable.h)
-QT_CLASS_LIB(QCompleter, QtGui, qcompleter.h)
-QT_CLASS_LIB(QDesktopServices, QtGui, qdesktopservices.h)
-QT_CLASS_LIB(QScroller, QtGui, qscroller.h)
-QT_CLASS_LIB(QScrollerProperties, QtGui, qscrollerproperties.h)
+QT_CLASS_LIB(QTextTable, QtWidgets, qtexttable.h)
+QT_CLASS_LIB(QCompleter, QtWidgets, qcompleter.h)
+QT_CLASS_LIB(QDesktopServices, QtWidgets, qdesktopservices.h)
+QT_CLASS_LIB(QScroller, QtWidgets, qscroller.h)
+QT_CLASS_LIB(QScrollerProperties, QtWidgets, qscrollerproperties.h)
QT_CLASS_LIB(QSystemTrayIcon, QtGui, qsystemtrayicon.h)
-QT_CLASS_LIB(QUndoGroup, QtGui, qundogroup.h)
-QT_CLASS_LIB(QUndoCommand, QtGui, qundostack.h)
-QT_CLASS_LIB(QUndoStack, QtGui, qundostack.h)
-QT_CLASS_LIB(QUndoView, QtGui, qundoview.h)
-QT_CLASS_LIB(QAbstractButton, QtGui, qabstractbutton.h)
-QT_CLASS_LIB(QAbstractScrollArea, QtGui, qabstractscrollarea.h)
-QT_CLASS_LIB(QAbstractSlider, QtGui, qabstractslider.h)
-QT_CLASS_LIB(QAbstractSpinBox, QtGui, qabstractspinbox.h)
-QT_CLASS_LIB(QButtonGroup, QtGui, qbuttongroup.h)
-QT_CLASS_LIB(QCalendarWidget, QtGui, qcalendarwidget.h)
-QT_CLASS_LIB(QCheckBox, QtGui, qcheckbox.h)
-QT_CLASS_LIB(QComboBox, QtGui, qcombobox.h)
-QT_CLASS_LIB(QCommandLinkButton, QtGui, qcommandlinkbutton.h)
-QT_CLASS_LIB(QDateTimeEdit, QtGui, qdatetimeedit.h)
-QT_CLASS_LIB(QTimeEdit, QtGui, qdatetimeedit.h)
-QT_CLASS_LIB(QDateEdit, QtGui, qdatetimeedit.h)
-QT_CLASS_LIB(QDial, QtGui, qdial.h)
-QT_CLASS_LIB(QDialogButtonBox, QtGui, qdialogbuttonbox.h)
-QT_CLASS_LIB(QDockWidget, QtGui, qdockwidget.h)
-QT_CLASS_LIB(QFocusFrame, QtGui, qfocusframe.h)
-QT_CLASS_LIB(QFontComboBox, QtGui, qfontcombobox.h)
-QT_CLASS_LIB(QFrame, QtGui, qframe.h)
-QT_CLASS_LIB(QGroupBox, QtGui, qgroupbox.h)
-QT_CLASS_LIB(QLabel, QtGui, qlabel.h)
-QT_CLASS_LIB(QLCDNumber, QtGui, qlcdnumber.h)
-QT_CLASS_LIB(QLineEdit, QtGui, qlineedit.h)
-QT_CLASS_LIB(QMacCocoaViewContainer, QtGui, qmaccocoaviewcontainer_mac.h)
-QT_CLASS_LIB(QMacNativeWidget, QtGui, qmacnativewidget_mac.h)
-QT_CLASS_LIB(QMainWindow, QtGui, qmainwindow.h)
-QT_CLASS_LIB(QMdiArea, QtGui, qmdiarea.h)
-QT_CLASS_LIB(QMdiSubWindow, QtGui, qmdisubwindow.h)
-QT_CLASS_LIB(QMenu, QtGui, qmenu.h)
-QT_CLASS_LIB(QMenuBar, QtGui, qmenubar.h)
-QT_CLASS_LIB(QMenuItem, QtGui, qmenudata.h)
-QT_CLASS_LIB(QPlainTextEdit, QtGui, qplaintextedit.h)
-QT_CLASS_LIB(QPlainTextDocumentLayout, QtGui, qplaintextedit.h)
-QT_CLASS_LIB(QPrintPreviewWidget, QtGui, qprintpreviewwidget.h)
-QT_CLASS_LIB(QProgressBar, QtGui, qprogressbar.h)
-QT_CLASS_LIB(QPushButton, QtGui, qpushbutton.h)
-QT_CLASS_LIB(QRadioButton, QtGui, qradiobutton.h)
-QT_CLASS_LIB(QRubberBand, QtGui, qrubberband.h)
-QT_CLASS_LIB(QScrollArea, QtGui, qscrollarea.h)
-QT_CLASS_LIB(QScrollBar, QtGui, qscrollbar.h)
-QT_CLASS_LIB(QSizeGrip, QtGui, qsizegrip.h)
-QT_CLASS_LIB(QSlider, QtGui, qslider.h)
-QT_CLASS_LIB(QSpinBox, QtGui, qspinbox.h)
-QT_CLASS_LIB(QDoubleSpinBox, QtGui, qspinbox.h)
-QT_CLASS_LIB(QSplashScreen, QtGui, qsplashscreen.h)
-QT_CLASS_LIB(QSplitter, QtGui, qsplitter.h)
-QT_CLASS_LIB(QSplitterHandle, QtGui, qsplitter.h)
-QT_CLASS_LIB(QStackedWidget, QtGui, qstackedwidget.h)
-QT_CLASS_LIB(QStatusBar, QtGui, qstatusbar.h)
-QT_CLASS_LIB(QTabBar, QtGui, qtabbar.h)
-QT_CLASS_LIB(QTabWidget, QtGui, qtabwidget.h)
-QT_CLASS_LIB(QTextBrowser, QtGui, qtextbrowser.h)
-QT_CLASS_LIB(QTextEdit, QtGui, qtextedit.h)
-QT_CLASS_LIB(QToolBar, QtGui, qtoolbar.h)
-QT_CLASS_LIB(QToolBox, QtGui, qtoolbox.h)
-QT_CLASS_LIB(QToolButton, QtGui, qtoolbutton.h)
-QT_CLASS_LIB(QValidator, QtGui, qvalidator.h)
-QT_CLASS_LIB(QIntValidator, QtGui, qvalidator.h)
-QT_CLASS_LIB(QDoubleValidator, QtGui, qvalidator.h)
-QT_CLASS_LIB(QRegExpValidator, QtGui, qvalidator.h)
-QT_CLASS_LIB(QWorkspace, QtGui, qworkspace.h)
+QT_CLASS_LIB(QUndoGroup, QtWidgets, qundogroup.h)
+QT_CLASS_LIB(QUndoCommand, QtWidgets, qundostack.h)
+QT_CLASS_LIB(QUndoStack, QtWidgets, qundostack.h)
+QT_CLASS_LIB(QUndoView, QtWidgets, qundoview.h)
+QT_CLASS_LIB(QAbstractButton, QtWidgets, qabstractbutton.h)
+QT_CLASS_LIB(QAbstractScrollArea, QtWidgets, qabstractscrollarea.h)
+QT_CLASS_LIB(QAbstractSlider, QtWidgets, qabstractslider.h)
+QT_CLASS_LIB(QAbstractSpinBox, QtWidgets, qabstractspinbox.h)
+QT_CLASS_LIB(QButtonGroup, QtWidgets, qbuttongroup.h)
+QT_CLASS_LIB(QCalendarWidget, QtWidgets, qcalendarwidget.h)
+QT_CLASS_LIB(QCheckBox, QtWidgets, qcheckbox.h)
+QT_CLASS_LIB(QComboBox, QtWidgets, qcombobox.h)
+QT_CLASS_LIB(QCommandLinkButton, QtWidgets, qcommandlinkbutton.h)
+QT_CLASS_LIB(QDateTimeEdit, QtWidgets, qdatetimeedit.h)
+QT_CLASS_LIB(QTimeEdit, QtWidgets, qdatetimeedit.h)
+QT_CLASS_LIB(QDateEdit, QtWidgets, qdatetimeedit.h)
+QT_CLASS_LIB(QDial, QtWidgets, qdial.h)
+QT_CLASS_LIB(QDialogButtonBox, QtWidgets, qdialogbuttonbox.h)
+QT_CLASS_LIB(QDockWidget, QtWidgets, qdockwidget.h)
+QT_CLASS_LIB(QFocusFrame, QtWidgets, qfocusframe.h)
+QT_CLASS_LIB(QFontComboBox, QtWidgets, qfontcombobox.h)
+QT_CLASS_LIB(QFrame, QtWidgets, qframe.h)
+QT_CLASS_LIB(QGroupBox, QtWidgets, qgroupbox.h)
+QT_CLASS_LIB(QLabel, QtWidgets, qlabel.h)
+QT_CLASS_LIB(QLCDNumber, QtWidgets, qlcdnumber.h)
+QT_CLASS_LIB(QLineEdit, QtWidgets, qlineedit.h)
+QT_CLASS_LIB(QMacCocoaViewContainer, QtWidgets, qmaccocoaviewcontainer_mac.h)
+QT_CLASS_LIB(QMacNativeWidget, QtWidgets, qmacnativewidget_mac.h)
+QT_CLASS_LIB(QMainWindow, QtWidgets, qmainwindow.h)
+QT_CLASS_LIB(QMdiArea, QtWidgets, qmdiarea.h)
+QT_CLASS_LIB(QMdiSubWindow, QtWidgets, qmdisubwindow.h)
+QT_CLASS_LIB(QMenu, QtWidgets, qmenu.h)
+QT_CLASS_LIB(QMenuBar, QtWidgets, qmenubar.h)
+QT_CLASS_LIB(QMenuItem, QtWidgets, qmenudata.h)
+QT_CLASS_LIB(QPlainTextEdit, QtWidgets, qplaintextedit.h)
+QT_CLASS_LIB(QPlainTextDocumentLayout, QtWidgets, qplaintextedit.h)
+QT_CLASS_LIB(QPrintPreviewWidget, QtWidgets, qprintpreviewwidget.h)
+QT_CLASS_LIB(QProgressBar, QtWidgets, qprogressbar.h)
+QT_CLASS_LIB(QPushButton, QtWidgets, qpushbutton.h)
+QT_CLASS_LIB(QRadioButton, QtWidgets, qradiobutton.h)
+QT_CLASS_LIB(QRubberBand, QtWidgets, qrubberband.h)
+QT_CLASS_LIB(QScrollArea, QtWidgets, qscrollarea.h)
+QT_CLASS_LIB(QScrollBar, QtWidgets, qscrollbar.h)
+QT_CLASS_LIB(QSizeGrip, QtWidgets, qsizegrip.h)
+QT_CLASS_LIB(QSlider, QtWidgets, qslider.h)
+QT_CLASS_LIB(QSpinBox, QtWidgets, qspinbox.h)
+QT_CLASS_LIB(QDoubleSpinBox, QtWidgets, qspinbox.h)
+QT_CLASS_LIB(QSplashScreen, QtWidgets, qsplashscreen.h)
+QT_CLASS_LIB(QSplitter, QtWidgets, qsplitter.h)
+QT_CLASS_LIB(QSplitterHandle, QtWidgets, qsplitter.h)
+QT_CLASS_LIB(QStackedWidget, QtWidgets, qstackedwidget.h)
+QT_CLASS_LIB(QStatusBar, QtWidgets, qstatusbar.h)
+QT_CLASS_LIB(QTabBar, QtWidgets, qtabbar.h)
+QT_CLASS_LIB(QTabWidget, QtWidgets, qtabwidget.h)
+QT_CLASS_LIB(QTextBrowser, QtWidgets, qtextbrowser.h)
+QT_CLASS_LIB(QTextEdit, QtWidgets, qtextedit.h)
+QT_CLASS_LIB(QToolBar, QtWidgets, qtoolbar.h)
+QT_CLASS_LIB(QToolBox, QtWidgets, qtoolbox.h)
+QT_CLASS_LIB(QToolButton, QtWidgets, qtoolbutton.h)
+QT_CLASS_LIB(QValidator, QtWidgets, qvalidator.h)
+QT_CLASS_LIB(QIntValidator, QtWidgets, qvalidator.h)
+QT_CLASS_LIB(QDoubleValidator, QtWidgets, qvalidator.h)
+QT_CLASS_LIB(QRegExpValidator, QtWidgets, qvalidator.h)
+QT_CLASS_LIB(QWorkspace, QtWidgets, qworkspace.h)
QT_CLASS_LIB(QScriptEngineDebugger, QtScriptTools, qscriptenginedebugger.h)
QT_CLASS_LIB(QUiLoader, QtUiTools, quiloader.h)
QT_CLASS_LIB(QDesignerComponents, QtDesigner, qdesigner_components.h)
diff --git a/src/uitools/quiloader.cpp b/src/uitools/quiloader.cpp
index 7f39b557ea..6270e35d54 100644
--- a/src/uitools/quiloader.cpp
+++ b/src/uitools/quiloader.cpp
@@ -50,21 +50,21 @@
#include <ui4_p.h>
#include <QtCore/qdebug.h>
-#include <QtGui/QAction>
-#include <QtGui/QActionGroup>
-#include <QtGui/QApplication>
+#include <QtWidgets/QAction>
+#include <QtWidgets/QActionGroup>
+#include <QtWidgets/QApplication>
#include <QtCore/QDir>
#include <QtCore/QLibraryInfo>
-#include <QtGui/QLayout>
-#include <QtGui/QWidget>
+#include <QtWidgets/QLayout>
+#include <QtWidgets/QWidget>
#include <QtCore/QMap>
-#include <QtGui/QTabWidget>
-#include <QtGui/QTreeWidget>
-#include <QtGui/QListWidget>
-#include <QtGui/QTableWidget>
-#include <QtGui/QToolBox>
-#include <QtGui/QComboBox>
-#include <QtGui/QFontComboBox>
+#include <QtWidgets/QTabWidget>
+#include <QtWidgets/QTreeWidget>
+#include <QtWidgets/QListWidget>
+#include <QtWidgets/QTableWidget>
+#include <QtWidgets/QToolBox>
+#include <QtWidgets/QComboBox>
+#include <QtWidgets/QFontComboBox>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/QtGui.dynlist b/src/widgets/QtGui.dynlist
index ea47f598a7..ea47f598a7 100644
--- a/src/gui/QtGui.dynlist
+++ b/src/widgets/QtGui.dynlist
diff --git a/src/widgets/accessible/accessible.pri b/src/widgets/accessible/accessible.pri
new file mode 100644
index 0000000000..66a84bcce6
--- /dev/null
+++ b/src/widgets/accessible/accessible.pri
@@ -0,0 +1,25 @@
+# Qt accessibility module
+
+contains(QT_CONFIG, accessibility) {
+ HEADERS += accessible/qaccessible.h \
+ accessible/qaccessible2.h \
+ accessible/qaccessibleobject.h \
+ accessible/qaccessiblewidget.h \
+ accessible/qaccessibleplugin.h
+ SOURCES += accessible/qaccessible.cpp \
+ accessible/qaccessible2.cpp \
+ accessible/qaccessibleobject.cpp \
+ accessible/qaccessiblewidget.cpp \
+ accessible/qaccessibleplugin.cpp
+
+ mac:!qpa {
+ HEADERS += accessible/qaccessible_mac_p.h
+ OBJECTIVE_SOURCES += accessible/qaccessible_mac.mm \
+ accessible/qaccessible_mac_cocoa.mm
+ } else:win32 {
+ SOURCES += accessible/qaccessible_win.cpp
+ } else {
+ HEADERS += accessible/qaccessiblebridge.h
+ SOURCES += accessible/qaccessible_unix.cpp accessible/qaccessiblebridge.cpp
+ }
+}
diff --git a/src/gui/accessible/qaccessible.cpp b/src/widgets/accessible/qaccessible.cpp
index abe68f8108..abe68f8108 100644
--- a/src/gui/accessible/qaccessible.cpp
+++ b/src/widgets/accessible/qaccessible.cpp
diff --git a/src/widgets/accessible/qaccessible.h b/src/widgets/accessible/qaccessible.h
new file mode 100644
index 0000000000..33e76a7ad2
--- /dev/null
+++ b/src/widgets/accessible/qaccessible.h
@@ -0,0 +1,461 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QACCESSIBLE_H
+#define QACCESSIBLE_H
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qobject.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qset.h>
+#include <QtCore/qvector.h>
+#include <QtCore/qvariant.h>
+#include <QtGui/qcolor.h>
+#include <QtGui/qevent.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_ACCESSIBILITY
+
+class QAccessibleInterface;
+
+class Q_GUI_EXPORT QAccessible
+{
+public:
+ enum Event {
+ SoundPlayed = 0x0001,
+ Alert = 0x0002,
+ ForegroundChanged = 0x0003,
+ MenuStart = 0x0004,
+ MenuEnd = 0x0005,
+ PopupMenuStart = 0x0006,
+ PopupMenuEnd = 0x0007,
+ ContextHelpStart = 0x000C,
+ ContextHelpEnd = 0x000D,
+ DragDropStart = 0x000E,
+ DragDropEnd = 0x000F,
+ DialogStart = 0x0010,
+ DialogEnd = 0x0011,
+ ScrollingStart = 0x0012,
+ ScrollingEnd = 0x0013,
+
+ MenuCommand = 0x0018,
+
+ // Values from IAccessible2
+ ActionChanged = 0x0101,
+ ActiveDescendantChanged,
+ AttributeChanged,
+ DocumentContentChanged,
+ DocumentLoadComplete,
+ DocumentLoadStopped,
+ DocumentReload,
+ HyperlinkEndIndexChanged,
+ HyperlinkNumberOfAnchorsChanged,
+ HyperlinkSelectedLinkChanged,
+ HypertextLinkActivated,
+ HypertextLinkSelected,
+ HyperlinkStartIndexChanged,
+ HypertextChanged,
+ HypertextNLinksChanged,
+ ObjectAttributeChanged,
+ PageChanged,
+ SectionChanged,
+ TableCaptionChanged,
+ TableColumnDescriptionChanged,
+ TableColumnHeaderChanged,
+ TableModelChanged,
+ TableRowDescriptionChanged,
+ TableRowHeaderChanged,
+ TableSummaryChanged,
+ TextAttributeChanged,
+ TextCaretMoved,
+ TextChanged,
+ TextColumnChanged,
+ TextInserted,
+ TextRemoved,
+ TextUpdated,
+ TextSelectionChanged,
+ VisibleDataChanged,
+
+ ObjectCreated = 0x8000,
+ ObjectDestroyed = 0x8001,
+ ObjectShow = 0x8002,
+ ObjectHide = 0x8003,
+ ObjectReorder = 0x8004,
+ Focus = 0x8005,
+ Selection = 0x8006,
+ SelectionAdd = 0x8007,
+ SelectionRemove = 0x8008,
+ SelectionWithin = 0x8009,
+ StateChanged = 0x800A,
+ LocationChanged = 0x800B,
+ NameChanged = 0x800C,
+ DescriptionChanged = 0x800D,
+ ValueChanged = 0x800E,
+ ParentChanged = 0x800F,
+ HelpChanged = 0x80A0,
+ DefaultActionChanged = 0x80B0,
+ AcceleratorChanged = 0x80C0
+ };
+
+ enum StateFlag {
+ Normal = 0x00000000,
+ Unavailable = 0x00000001,
+ Selected = 0x00000002,
+ Focused = 0x00000004,
+ Pressed = 0x00000008,
+ Checked = 0x00000010,
+ Mixed = 0x00000020,
+ ReadOnly = 0x00000040,
+ HotTracked = 0x00000080,
+ DefaultButton = 0x00000100,
+ Expanded = 0x00000200,
+ Collapsed = 0x00000400,
+ Busy = 0x00000800,
+ // Floating = 0x00001000,
+ Marqueed = 0x00002000,
+ Animated = 0x00004000,
+ Invisible = 0x00008000,
+ Offscreen = 0x00010000,
+ Sizeable = 0x00020000,
+ Movable = 0x00040000,
+ SelfVoicing = 0x00080000,
+ Focusable = 0x00100000,
+ Selectable = 0x00200000,
+ Linked = 0x00400000,
+ Traversed = 0x00800000,
+ MultiSelectable = 0x01000000,
+ ExtSelectable = 0x02000000,
+ //AlertLow = 0x04000000,
+ //AlertMedium = 0x08000000,
+ //AlertHigh = 0x10000000, /* reused for HasInvokeExtension */
+ Protected = 0x20000000,
+ HasPopup = 0x40000000,
+ Modal = 0x80000000,
+
+ HasInvokeExtension = 0x10000000 // internal
+ };
+ Q_DECLARE_FLAGS(State, StateFlag)
+
+ enum Role {
+ NoRole = 0x00000000,
+ TitleBar = 0x00000001,
+ MenuBar = 0x00000002,
+ ScrollBar = 0x00000003,
+ Grip = 0x00000004,
+ Sound = 0x00000005,
+ Cursor = 0x00000006,
+ Caret = 0x00000007,
+ AlertMessage = 0x00000008,
+ Window = 0x00000009,
+ Client = 0x0000000A,
+ PopupMenu = 0x0000000B,
+ MenuItem = 0x0000000C,
+ ToolTip = 0x0000000D,
+ Application = 0x0000000E,
+ Document = 0x0000000F,
+ Pane = 0x00000010,
+ Chart = 0x00000011,
+ Dialog = 0x00000012,
+ Border = 0x00000013,
+ Grouping = 0x00000014,
+ Separator = 0x00000015,
+ ToolBar = 0x00000016,
+ StatusBar = 0x00000017,
+ Table = 0x00000018,
+ ColumnHeader = 0x00000019,
+ RowHeader = 0x0000001A,
+ Column = 0x0000001B,
+ Row = 0x0000001C,
+ Cell = 0x0000001D,
+ Link = 0x0000001E,
+ HelpBalloon = 0x0000001F,
+ Assistant = 0x00000020,
+ List = 0x00000021,
+ ListItem = 0x00000022,
+ Tree = 0x00000023,
+ TreeItem = 0x00000024,
+ PageTab = 0x00000025,
+ PropertyPage = 0x00000026,
+ Indicator = 0x00000027,
+ Graphic = 0x00000028,
+ StaticText = 0x00000029,
+ EditableText = 0x0000002A, // Editable, selectable, etc.
+ PushButton = 0x0000002B,
+ CheckBox = 0x0000002C,
+ RadioButton = 0x0000002D,
+ ComboBox = 0x0000002E,
+ // DropList = 0x0000002F,
+ ProgressBar = 0x00000030,
+ Dial = 0x00000031,
+ HotkeyField = 0x00000032,
+ Slider = 0x00000033,
+ SpinBox = 0x00000034,
+ Canvas = 0x00000035,
+ Animation = 0x00000036,
+ Equation = 0x00000037,
+ ButtonDropDown = 0x00000038,
+ ButtonMenu = 0x00000039,
+ ButtonDropGrid = 0x0000003A,
+ Whitespace = 0x0000003B,
+ PageTabList = 0x0000003C,
+ Clock = 0x0000003D,
+ Splitter = 0x0000003E,
+ // Additional Qt roles where enum value does not map directly to MSAA:
+ LayeredPane = 0x0000003F,
+ UserRole = 0x0000ffff
+ };
+
+ enum Text {
+ Name = 0,
+ Description,
+ Value,
+ Help,
+ Accelerator,
+ UserText = 0x0000ffff
+ };
+
+ enum RelationFlag {
+ Unrelated = 0x00000000,
+ Self = 0x00000001,
+ Ancestor = 0x00000002,
+ Child = 0x00000004,
+ Descendent = 0x00000008,
+ Sibling = 0x00000010,
+ HierarchyMask = 0x000000ff,
+
+ Up = 0x00000100,
+ Down = 0x00000200,
+ Left = 0x00000400,
+ Right = 0x00000800,
+ Covers = 0x00001000,
+ Covered = 0x00002000,
+ GeometryMask = 0x0000ff00,
+
+ FocusChild = 0x00010000,
+ Label = 0x00020000,
+ Labelled = 0x00040000,
+ Controller = 0x00080000,
+ Controlled = 0x00100000,
+ LogicalMask = 0x00ff0000
+ };
+ Q_DECLARE_FLAGS(Relation, RelationFlag)
+
+ enum Action {
+ DefaultAction = 0,
+ Press = -1,
+ FirstStandardAction = Press,
+ SetFocus = -2,
+ Increase = -3,
+ Decrease = -4,
+ Accept = -5,
+ Cancel = -6,
+ Select = -7,
+ ClearSelection = -8,
+ RemoveSelection = -9,
+ ExtendSelection = -10,
+ AddToSelection = -11,
+ LastStandardAction = AddToSelection
+ };
+
+ enum Method {
+ ListSupportedMethods = 0,
+ SetCursorPosition = 1,
+ GetCursorPosition = 2,
+ ForegroundColor = 3,
+ BackgroundColor = 4
+ };
+
+ typedef QAccessibleInterface*(*InterfaceFactory)(const QString &key, QObject*);
+ typedef void(*UpdateHandler)(QObject*, int who, Event reason);
+ typedef void(*RootObjectHandler)(QObject*);
+
+ static void installFactory(InterfaceFactory);
+ static void removeFactory(InterfaceFactory);
+ static UpdateHandler installUpdateHandler(UpdateHandler);
+ static RootObjectHandler installRootObjectHandler(RootObjectHandler);
+
+ static QAccessibleInterface *queryAccessibleInterface(QObject *);
+ static void updateAccessibility(QObject *, int who, Event reason);
+ static bool isActive();
+ static void setRootObject(QObject*);
+
+ static void initialize();
+ static void cleanup();
+
+private:
+ static UpdateHandler updateHandler;
+ static RootObjectHandler rootObjectHandler;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QAccessible::State)
+Q_DECLARE_OPERATORS_FOR_FLAGS(QAccessible::Relation)
+QT_END_NAMESPACE
+Q_DECLARE_METATYPE(QSet<QAccessible::Method>)
+QT_BEGIN_NAMESPACE
+
+namespace QAccessible2
+{
+ enum InterfaceType
+ {
+ TextInterface,
+ EditableTextInterface,
+ ValueInterface,
+ TableInterface,
+ ActionInterface,
+ ImageInterface
+ };
+}
+
+class QAccessible2Interface;
+class QAccessibleTextInterface;
+class QAccessibleEditableTextInterface;
+class QAccessibleValueInterface;
+class QAccessibleTableInterface;
+class QAccessibleActionInterface;
+class QAccessibleImageInterface;
+
+class Q_GUI_EXPORT QAccessibleInterface : public QAccessible
+{
+public:
+ virtual ~QAccessibleInterface() {}
+ // check for valid pointers
+ virtual bool isValid() const = 0;
+ virtual QObject *object() const = 0;
+
+ // hierarchy
+ virtual int childCount() const = 0;
+ virtual int indexOfChild(const QAccessibleInterface *) const = 0;
+
+ // relations
+ virtual Relation relationTo(int child, const QAccessibleInterface *other,
+ int otherChild) const = 0;
+ virtual int childAt(int x, int y) const = 0;
+
+ // navigation
+ virtual int navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const = 0;
+
+ // properties and state
+ virtual QString text(Text t, int child) const = 0;
+ virtual void setText(Text t, int child, const QString &text) = 0;
+ virtual QRect rect(int child) const = 0;
+ virtual Role role(int child) const = 0;
+ virtual State state(int child) const = 0;
+
+ // action
+ virtual int userActionCount(int child) const = 0;
+ virtual QString actionText(int action, Text t, int child) const = 0;
+ virtual bool doAction(int action, int child, const QVariantList &params = QVariantList()) = 0;
+
+ QVariant invokeMethod(Method method, int child = 0,
+ const QVariantList &params = QVariantList());
+
+ inline QSet<Method> supportedMethods()
+ { return qvariant_cast<QSet<Method> >(invokeMethod(ListSupportedMethods)); }
+
+ inline QColor foregroundColor()
+ { return qvariant_cast<QColor>(invokeMethod(ForegroundColor)); }
+
+ inline QColor backgroundColor()
+ { return qvariant_cast<QColor>(invokeMethod(BackgroundColor)); }
+
+ inline QAccessibleTextInterface *textInterface()
+ { return reinterpret_cast<QAccessibleTextInterface *>(cast_helper(QAccessible2::TextInterface)); }
+
+ inline QAccessibleEditableTextInterface *editableTextInterface()
+ { return reinterpret_cast<QAccessibleEditableTextInterface *>(cast_helper(QAccessible2::EditableTextInterface)); }
+
+ inline QAccessibleValueInterface *valueInterface()
+ { return reinterpret_cast<QAccessibleValueInterface *>(cast_helper(QAccessible2::ValueInterface)); }
+
+ inline QAccessibleTableInterface *tableInterface()
+ { return reinterpret_cast<QAccessibleTableInterface *>(cast_helper(QAccessible2::TableInterface)); }
+
+ inline QAccessibleActionInterface *actionInterface()
+ { return reinterpret_cast<QAccessibleActionInterface *>(cast_helper(QAccessible2::ActionInterface)); }
+
+ inline QAccessibleImageInterface *imageInterface()
+ { return reinterpret_cast<QAccessibleImageInterface *>(cast_helper(QAccessible2::ImageInterface)); }
+
+private:
+ QAccessible2Interface *cast_helper(QAccessible2::InterfaceType);
+};
+
+class Q_GUI_EXPORT QAccessibleInterfaceEx: public QAccessibleInterface
+{
+public:
+ virtual QVariant invokeMethodEx(Method method, int child, const QVariantList &params) = 0;
+ virtual QVariant virtual_hook(const QVariant &data);
+ virtual QAccessible2Interface *interface_cast(QAccessible2::InterfaceType)
+ { return 0; }
+};
+
+
+class Q_GUI_EXPORT QAccessibleEvent : public QEvent
+{
+public:
+ inline QAccessibleEvent(Type type, int child);
+ inline int child() const { return c; }
+ inline QString value() const { return val; }
+ inline void setValue(const QString &aText) { val = aText; }
+
+private:
+ int c;
+ QString val;
+};
+
+inline QAccessibleEvent::QAccessibleEvent(Type atype, int achild)
+ : QEvent(atype), c(achild) {}
+
+#define QAccessibleInterface_iid "com.trolltech.Qt.QAccessibleInterface"
+Q_DECLARE_INTERFACE(QAccessibleInterface, QAccessibleInterface_iid)
+
+#endif // QT_NO_ACCESSIBILITY
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QACCESSIBLE_H
diff --git a/src/gui/accessible/qaccessible2.cpp b/src/widgets/accessible/qaccessible2.cpp
index 36187f5315..36187f5315 100644
--- a/src/gui/accessible/qaccessible2.cpp
+++ b/src/widgets/accessible/qaccessible2.cpp
diff --git a/src/widgets/accessible/qaccessible2.h b/src/widgets/accessible/qaccessible2.h
new file mode 100644
index 0000000000..2f660bda6e
--- /dev/null
+++ b/src/widgets/accessible/qaccessible2.h
@@ -0,0 +1,246 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QACCESSIBLE2_H
+#define QACCESSIBLE2_H
+
+#include <QtWidgets/qaccessible.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_ACCESSIBILITY
+
+namespace QAccessible2
+{
+ enum CoordinateType
+ {
+ RelativeToScreen = 0,
+ RelativeToParent = 1
+ };
+
+ enum BoundaryType {
+ CharBoundary,
+ WordBoundary,
+ SentenceBoundary,
+ ParagraphBoundary,
+ LineBoundary,
+ NoBoundary
+ };
+}
+
+class Q_GUI_EXPORT QAccessible2Interface
+{
+public:
+ virtual ~QAccessible2Interface() {}
+};
+
+// catch-all functions. If an accessible class doesn't implement interface T, return 0
+inline QAccessible2Interface *qAccessibleValueCastHelper() { return 0; }
+inline QAccessible2Interface *qAccessibleTextCastHelper() { return 0; }
+inline QAccessible2Interface *qAccessibleEditableTextCastHelper() { return 0; }
+inline QAccessible2Interface *qAccessibleTableCastHelper() { return 0; }
+inline QAccessible2Interface *qAccessibleActionCastHelper() { return 0; }
+inline QAccessible2Interface *qAccessibleImageCastHelper() { return 0; }
+
+#define Q_ACCESSIBLE_OBJECT \
+ public: \
+ QAccessible2Interface *interface_cast(QAccessible2::InterfaceType t) \
+ { \
+ switch (t) { \
+ case QAccessible2::TextInterface: \
+ return qAccessibleTextCastHelper(); \
+ case QAccessible2::EditableTextInterface: \
+ return qAccessibleEditableTextCastHelper(); \
+ case QAccessible2::ValueInterface: \
+ return qAccessibleValueCastHelper(); \
+ case QAccessible2::TableInterface: \
+ return qAccessibleTableCastHelper(); \
+ case QAccessible2::ActionInterface: \
+ return qAccessibleActionCastHelper(); \
+ case QAccessible2::ImageInterface: \
+ return qAccessibleImageCastHelper(); \
+ } \
+ return 0; \
+ } \
+ private:
+
+class Q_GUI_EXPORT QAccessibleTextInterface: public QAccessible2Interface
+{
+public:
+ inline QAccessible2Interface *qAccessibleTextCastHelper() { return this; }
+
+ virtual ~QAccessibleTextInterface() {}
+
+ virtual void addSelection(int startOffset, int endOffset) = 0;
+ virtual QString attributes(int offset, int *startOffset, int *endOffset) = 0;
+ virtual int cursorPosition() = 0;
+ virtual QRect characterRect(int offset, QAccessible2::CoordinateType coordType) = 0;
+ virtual int selectionCount() = 0;
+ virtual int offsetAtPoint(const QPoint &point, QAccessible2::CoordinateType coordType) = 0;
+ virtual void selection(int selectionIndex, int *startOffset, int *endOffset) = 0;
+ virtual QString text(int startOffset, int endOffset) = 0;
+ virtual QString textBeforeOffset (int offset, QAccessible2::BoundaryType boundaryType,
+ int *startOffset, int *endOffset) = 0;
+ virtual QString textAfterOffset(int offset, QAccessible2::BoundaryType boundaryType,
+ int *startOffset, int *endOffset) = 0;
+ virtual QString textAtOffset(int offset, QAccessible2::BoundaryType boundaryType,
+ int *startOffset, int *endOffset) = 0;
+ virtual void removeSelection(int selectionIndex) = 0;
+ virtual void setCursorPosition(int position) = 0;
+ virtual void setSelection(int selectionIndex, int startOffset, int endOffset) = 0;
+ virtual int characterCount() = 0;
+ virtual void scrollToSubstring(int startIndex, int endIndex) = 0;
+};
+
+class Q_GUI_EXPORT QAccessibleEditableTextInterface: public QAccessible2Interface
+{
+public:
+ inline QAccessible2Interface *qAccessibleEditableTextCastHelper() { return this; }
+
+ virtual ~QAccessibleEditableTextInterface() {}
+
+ virtual void copyText(int startOffset, int endOffset) = 0;
+ virtual void deleteText(int startOffset, int endOffset) = 0;
+ virtual void insertText(int offset, const QString &text) = 0;
+ virtual void cutText(int startOffset, int endOffset) = 0;
+ virtual void pasteText(int offset) = 0;
+ virtual void replaceText(int startOffset, int endOffset, const QString &text) = 0;
+ virtual void setAttributes(int startOffset, int endOffset, const QString &attributes) = 0;
+};
+
+class Q_GUI_EXPORT QAccessibleSimpleEditableTextInterface: public QAccessibleEditableTextInterface
+{
+public:
+ QAccessibleSimpleEditableTextInterface(QAccessibleInterface *accessibleInterface);
+
+ void copyText(int startOffset, int endOffset);
+ void deleteText(int startOffset, int endOffset);
+ void insertText(int offset, const QString &text);
+ void cutText(int startOffset, int endOffset);
+ void pasteText(int offset);
+ void replaceText(int startOffset, int endOffset, const QString &text);
+ inline void setAttributes(int, int, const QString &) {}
+
+private:
+ QAccessibleInterface *iface;
+};
+
+class Q_GUI_EXPORT QAccessibleValueInterface: public QAccessible2Interface
+{
+public:
+ inline QAccessible2Interface *qAccessibleValueCastHelper() { return this; }
+
+ virtual ~QAccessibleValueInterface() {}
+
+ virtual QVariant currentValue() = 0;
+ virtual void setCurrentValue(const QVariant &value) = 0;
+ virtual QVariant maximumValue() = 0;
+ virtual QVariant minimumValue() = 0;
+};
+
+class Q_GUI_EXPORT QAccessibleTableInterface: public QAccessible2Interface
+{
+public:
+ inline QAccessible2Interface *qAccessibleTableCastHelper() { return this; }
+
+ virtual QAccessibleInterface *accessibleAt(int row, int column) = 0;
+ virtual QAccessibleInterface *caption() = 0;
+ virtual int childIndex(int rowIndex, int columnIndex) = 0;
+ virtual QString columnDescription(int column) = 0;
+ virtual int columnSpan(int row, int column) = 0;
+ virtual QAccessibleInterface *columnHeader() = 0;
+ virtual int columnIndex(int childIndex) = 0;
+ virtual int columnCount() = 0;
+ virtual int rowCount() = 0;
+ virtual int selectedColumnCount() = 0;
+ virtual int selectedRowCount() = 0;
+ virtual QString rowDescription(int row) = 0;
+ virtual int rowSpan(int row, int column) = 0;
+ virtual QAccessibleInterface *rowHeader() = 0;
+ virtual int rowIndex(int childIndex) = 0;
+ virtual int selectedRows(int maxRows, QList<int> *rows) = 0;
+ virtual int selectedColumns(int maxColumns, QList<int> *columns) = 0;
+ virtual QAccessibleInterface *summary() = 0;
+ virtual bool isColumnSelected(int column) = 0;
+ virtual bool isRowSelected(int row) = 0;
+ virtual bool isSelected(int row, int column) = 0;
+ virtual void selectRow(int row) = 0;
+ virtual void selectColumn(int column) = 0;
+ virtual void unselectRow(int row) = 0;
+ virtual void unselectColumn(int column) = 0;
+ virtual void cellAtIndex(int index, int *row, int *column, int *rowSpan,
+ int *columnSpan, bool *isSelected) = 0;
+};
+
+class Q_GUI_EXPORT QAccessibleActionInterface : public QAccessible2Interface
+{
+public:
+ inline QAccessible2Interface *qAccessibleActionCastHelper() { return this; }
+
+ virtual int actionCount() = 0;
+ virtual void doAction(int actionIndex) = 0;
+ virtual QString description(int actionIndex) = 0;
+ virtual QString name(int actionIndex) = 0;
+ virtual QString localizedName(int actionIndex) = 0;
+ virtual QStringList keyBindings(int actionIndex) = 0;
+};
+
+class Q_GUI_EXPORT QAccessibleImageInterface : public QAccessible2Interface
+{
+public:
+ inline QAccessible2Interface *qAccessibleImageCastHelper() { return this; }
+
+ virtual QString imageDescription() = 0;
+ virtual QSize imageSize() = 0;
+ virtual QRect imagePosition(QAccessible2::CoordinateType coordType) = 0;
+};
+
+#endif // QT_NO_ACCESSIBILITY
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/gui/accessible/qaccessible_mac.mm b/src/widgets/accessible/qaccessible_mac.mm
index d01c1c9733..d01c1c9733 100644
--- a/src/gui/accessible/qaccessible_mac.mm
+++ b/src/widgets/accessible/qaccessible_mac.mm
diff --git a/src/gui/accessible/qaccessible_mac_carbon.cpp b/src/widgets/accessible/qaccessible_mac_carbon.cpp
index 2e8a7628e8..2e8a7628e8 100644
--- a/src/gui/accessible/qaccessible_mac_carbon.cpp
+++ b/src/widgets/accessible/qaccessible_mac_carbon.cpp
diff --git a/src/gui/accessible/qaccessible_mac_cocoa.mm b/src/widgets/accessible/qaccessible_mac_cocoa.mm
index 60b967ab39..60b967ab39 100644
--- a/src/gui/accessible/qaccessible_mac_cocoa.mm
+++ b/src/widgets/accessible/qaccessible_mac_cocoa.mm
diff --git a/src/gui/accessible/qaccessible_mac_p.h b/src/widgets/accessible/qaccessible_mac_p.h
index 9acb5d3aef..9acb5d3aef 100644
--- a/src/gui/accessible/qaccessible_mac_p.h
+++ b/src/widgets/accessible/qaccessible_mac_p.h
diff --git a/src/gui/accessible/qaccessible_unix.cpp b/src/widgets/accessible/qaccessible_unix.cpp
index f04d075543..f04d075543 100644
--- a/src/gui/accessible/qaccessible_unix.cpp
+++ b/src/widgets/accessible/qaccessible_unix.cpp
diff --git a/src/gui/accessible/qaccessible_win.cpp b/src/widgets/accessible/qaccessible_win.cpp
index 98db5293d2..98db5293d2 100644
--- a/src/gui/accessible/qaccessible_win.cpp
+++ b/src/widgets/accessible/qaccessible_win.cpp
diff --git a/src/gui/accessible/qaccessiblebridge.cpp b/src/widgets/accessible/qaccessiblebridge.cpp
index e151bb6752..e151bb6752 100644
--- a/src/gui/accessible/qaccessiblebridge.cpp
+++ b/src/widgets/accessible/qaccessiblebridge.cpp
diff --git a/src/gui/accessible/qaccessiblebridge.h b/src/widgets/accessible/qaccessiblebridge.h
index d5e35df33f..d5e35df33f 100644
--- a/src/gui/accessible/qaccessiblebridge.h
+++ b/src/widgets/accessible/qaccessiblebridge.h
diff --git a/src/gui/accessible/qaccessibleobject.cpp b/src/widgets/accessible/qaccessibleobject.cpp
index 0cb2c08a3e..0cb2c08a3e 100644
--- a/src/gui/accessible/qaccessibleobject.cpp
+++ b/src/widgets/accessible/qaccessibleobject.cpp
diff --git a/src/widgets/accessible/qaccessibleobject.h b/src/widgets/accessible/qaccessibleobject.h
new file mode 100644
index 0000000000..cc17fdc7c6
--- /dev/null
+++ b/src/widgets/accessible/qaccessibleobject.h
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QACCESSIBLEOBJECT_H
+#define QACCESSIBLEOBJECT_H
+
+#include <QtWidgets/qaccessible.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_ACCESSIBILITY
+
+class QAccessibleObjectPrivate;
+class QObject;
+
+class Q_GUI_EXPORT QAccessibleObject : public QAccessibleInterface
+{
+public:
+ explicit QAccessibleObject(QObject *object);
+
+ bool isValid() const;
+ QObject *object() const;
+
+ // properties
+ QRect rect(int child) const;
+ void setText(Text t, int child, const QString &text);
+
+ // actions
+ int userActionCount(int child) const;
+ bool doAction(int action, int child, const QVariantList &params);
+ QString actionText(int action, Text t, int child) const;
+
+protected:
+ virtual ~QAccessibleObject();
+
+private:
+ friend class QAccessibleObjectEx;
+ QAccessibleObjectPrivate *d;
+ Q_DISABLE_COPY(QAccessibleObject)
+};
+
+class Q_GUI_EXPORT QAccessibleObjectEx : public QAccessibleInterfaceEx
+{
+public:
+ explicit QAccessibleObjectEx(QObject *object);
+
+ bool isValid() const;
+ QObject *object() const;
+
+ // properties
+ QRect rect(int child) const;
+ void setText(Text t, int child, const QString &text);
+
+ // actions
+ int userActionCount(int child) const;
+ bool doAction(int action, int child, const QVariantList &params);
+ QString actionText(int action, Text t, int child) const;
+
+protected:
+ virtual ~QAccessibleObjectEx();
+
+private:
+ QAccessibleObjectPrivate *d;
+ Q_DISABLE_COPY(QAccessibleObjectEx)
+};
+
+class Q_GUI_EXPORT QAccessibleApplication : public QAccessibleObject
+{
+public:
+ QAccessibleApplication();
+
+ // relations
+ int childCount() const;
+ int indexOfChild(const QAccessibleInterface*) const;
+ Relation relationTo(int, const QAccessibleInterface *, int) const;
+
+ // navigation
+ int childAt(int x, int y) const;
+ int navigate(RelationFlag, int, QAccessibleInterface **) const;
+
+ // properties and state
+ QString text(Text t, int child) const;
+ Role role(int child) const;
+ State state(int child) const;
+
+ // actions
+ int userActionCount(int child) const;
+ bool doAction(int action, int child, const QVariantList &params);
+ QString actionText(int action, Text t, int child) const;
+};
+
+#endif // QT_NO_ACCESSIBILITY
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QACCESSIBLEOBJECT_H
diff --git a/src/gui/accessible/qaccessibleplugin.cpp b/src/widgets/accessible/qaccessibleplugin.cpp
index f52d4b1807..f52d4b1807 100644
--- a/src/gui/accessible/qaccessibleplugin.cpp
+++ b/src/widgets/accessible/qaccessibleplugin.cpp
diff --git a/src/widgets/accessible/qaccessibleplugin.h b/src/widgets/accessible/qaccessibleplugin.h
new file mode 100644
index 0000000000..b073ca103a
--- /dev/null
+++ b/src/widgets/accessible/qaccessibleplugin.h
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QACCESSIBLEPLUGIN_H
+#define QACCESSIBLEPLUGIN_H
+
+#include <QtWidgets/qaccessible.h>
+#include <QtCore/qfactoryinterface.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_ACCESSIBILITY
+
+class QStringList;
+class QAccessibleInterface;
+
+struct Q_GUI_EXPORT QAccessibleFactoryInterface : public QAccessible, public QFactoryInterface
+{
+ virtual QAccessibleInterface* create(const QString &key, QObject *object) = 0;
+};
+
+#define QAccessibleFactoryInterface_iid "com.trolltech.Qt.QAccessibleFactoryInterface"
+Q_DECLARE_INTERFACE(QAccessibleFactoryInterface, QAccessibleFactoryInterface_iid)
+
+class QAccessiblePluginPrivate;
+
+class Q_GUI_EXPORT QAccessiblePlugin : public QObject, public QAccessibleFactoryInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(QAccessibleFactoryInterface:QFactoryInterface)
+public:
+ explicit QAccessiblePlugin(QObject *parent = 0);
+ ~QAccessiblePlugin();
+
+ virtual QStringList keys() const = 0;
+ virtual QAccessibleInterface *create(const QString &key, QObject *object) = 0;
+};
+
+#endif // QT_NO_ACCESSIBILITY
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QACCESSIBLEPLUGIN_H
diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp
new file mode 100644
index 0000000000..d2d2984533
--- /dev/null
+++ b/src/widgets/accessible/qaccessiblewidget.cpp
@@ -0,0 +1,1031 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qaccessiblewidget.h"
+
+#ifndef QT_NO_ACCESSIBILITY
+
+#include "qaction.h"
+#include "qapplication.h"
+#include "qgroupbox.h"
+#include "qlabel.h"
+#include "qtooltip.h"
+#include "qwhatsthis.h"
+#include "qwidget.h"
+#include "qdebug.h"
+#include <qmath.h>
+#include <QRubberBand>
+#include <QFocusFrame>
+#include <QMenu>
+
+QT_BEGIN_NAMESPACE
+
+static QList<QWidget*> childWidgets(const QWidget *widget)
+{
+ QList<QObject*> list = widget->children();
+ QList<QWidget*> widgets;
+ for (int i = 0; i < list.size(); ++i) {
+ QWidget *w = qobject_cast<QWidget *>(list.at(i));
+ if (w && !w->isWindow()
+ && !qobject_cast<QFocusFrame*>(w)
+#if !defined(QT_NO_MENU)
+ && !qobject_cast<QMenu*>(w)
+#endif
+ && w->objectName() != QLatin1String("qt_rubberband"))
+ widgets.append(w);
+ }
+ return widgets;
+}
+
+static QString buddyString(const QWidget *widget)
+{
+ if (!widget)
+ return QString();
+ QWidget *parent = widget->parentWidget();
+ if (!parent)
+ return QString();
+#ifndef QT_NO_SHORTCUT
+ QObjectList ol = parent->children();
+ for (int i = 0; i < ol.size(); ++i) {
+ QLabel *label = qobject_cast<QLabel*>(ol.at(i));
+ if (label && label->buddy() == widget)
+ return label->text();
+ }
+#endif
+
+#ifndef QT_NO_GROUPBOX
+ QGroupBox *groupbox = qobject_cast<QGroupBox*>(parent);
+ if (groupbox)
+ return groupbox->title();
+#endif
+
+ return QString();
+}
+
+QString Q_GUI_EXPORT qt_accStripAmp(const QString &text)
+{
+ return QString(text).remove(QLatin1Char('&'));
+}
+
+QString Q_GUI_EXPORT qt_accHotKey(const QString &text)
+{
+#ifndef QT_NO_SHORTCUT
+ if (text.isEmpty())
+ return text;
+
+ int fa = 0;
+ QChar ac;
+ while ((fa = text.indexOf(QLatin1Char('&'), fa)) != -1) {
+ ++fa;
+ if (fa < text.length()) {
+ // ignore "&&"
+ if (text.at(fa) == QLatin1Char('&')) {
+ ++fa;
+ continue;
+ } else {
+ ac = text.at(fa);
+ break;
+ }
+ }
+ }
+ if (ac.isNull())
+ return QString();
+ return (QString)QKeySequence(Qt::ALT) + ac.toUpper();
+#else
+ Q_UNUSED(text);
+ return QString();
+#endif
+}
+
+class QAccessibleWidgetPrivate : public QAccessible
+{
+public:
+ QAccessibleWidgetPrivate()
+ :role(Client)
+ {}
+
+ Role role;
+ QString name;
+ QString description;
+ QString value;
+ QString help;
+ QString accelerator;
+ QStringList primarySignals;
+ const QAccessibleInterface *asking;
+};
+
+/*!
+ \class QAccessibleWidget
+ \brief The QAccessibleWidget class implements the QAccessibleInterface for QWidgets.
+
+ \ingroup accessibility
+
+ This class is convenient to use as a base class for custom
+ implementations of QAccessibleInterfaces that provide information
+ about widget objects.
+
+ The class provides functions to retrieve the parentObject() (the
+ widget's parent widget), and the associated widget(). Controlling
+ signals can be added with addControllingSignal(), and setters are
+ provided for various aspects of the interface implementation, for
+ example setValue(), setDescription(), setAccelerator(), and
+ setHelp().
+
+ \sa QAccessible, QAccessibleObject
+*/
+
+/*!
+ Creates a QAccessibleWidget object for widget \a w.
+ \a role and \a name are optional parameters that set the object's
+ role and name properties.
+*/
+QAccessibleWidget::QAccessibleWidget(QWidget *w, Role role, const QString &name)
+: QAccessibleObject(w)
+{
+ Q_ASSERT(widget());
+ d = new QAccessibleWidgetPrivate();
+ d->role = role;
+ d->name = name;
+ d->asking = 0;
+}
+
+/*!
+ Destroys this object.
+*/
+QAccessibleWidget::~QAccessibleWidget()
+{
+ delete d;
+}
+
+/*!
+ Returns the associated widget.
+*/
+QWidget *QAccessibleWidget::widget() const
+{
+ return qobject_cast<QWidget*>(object());
+}
+
+/*!
+ Returns the associated widget's parent object, which is either the
+ parent widget, or qApp for top-level widgets.
+*/
+QObject *QAccessibleWidget::parentObject() const
+{
+ QObject *parent = object()->parent();
+ if (!parent)
+ parent = qApp;
+ return parent;
+}
+
+/*! \reimp */
+int QAccessibleWidget::childAt(int x, int y) const
+{
+ QWidget *w = widget();
+ if (!w->isVisible())
+ return -1;
+ QPoint gp = w->mapToGlobal(QPoint(0, 0));
+ if (!QRect(gp.x(), gp.y(), w->width(), w->height()).contains(x, y))
+ return -1;
+
+ QWidgetList list = childWidgets(w);
+ int ccount = childCount();
+
+ // a complex child
+ if (list.size() < ccount) {
+ for (int i = 1; i <= ccount; ++i) {
+ if (rect(i).contains(x, y))
+ return i;
+ }
+ return 0;
+ }
+
+ QPoint rp = w->mapFromGlobal(QPoint(x, y));
+ for (int i = 0; i<list.size(); ++i) {
+ QWidget *child = list.at(i);
+ if (!child->isWindow() && !child->isHidden() && child->geometry().contains(rp)) {
+ return i + 1;
+ }
+ }
+ return 0;
+}
+
+/*! \reimp */
+QRect QAccessibleWidget::rect(int child) const
+{
+ if (child) {
+ qWarning("QAccessibleWidget::rect: This implementation does not support subelements! "
+ "(ID %d unknown for %s)", child, widget()->metaObject()->className());
+ }
+
+ QWidget *w = widget();
+ if (!w->isVisible())
+ return QRect();
+ QPoint wpos = w->mapToGlobal(QPoint(0, 0));
+
+ return QRect(wpos.x(), wpos.y(), w->width(), w->height());
+}
+
+QT_BEGIN_INCLUDE_NAMESPACE
+#include <private/qobject_p.h>
+QT_END_INCLUDE_NAMESPACE
+
+class QACConnectionObject : public QObject
+{
+ Q_DECLARE_PRIVATE(QObject)
+public:
+ inline bool isSender(const QObject *receiver, const char *signal) const
+ { return d_func()->isSender(receiver, signal); }
+ inline QObjectList receiverList(const char *signal) const
+ { return d_func()->receiverList(signal); }
+ inline QObjectList senderList() const
+ { return d_func()->senderList(); }
+};
+
+/*!
+ Registers \a signal as a controlling signal.
+
+ An object is a Controller to any other object connected to a
+ controlling signal.
+*/
+void QAccessibleWidget::addControllingSignal(const QString &signal)
+{
+ QByteArray s = QMetaObject::normalizedSignature(signal.toAscii());
+ if (object()->metaObject()->indexOfSignal(s) < 0)
+ qWarning("Signal %s unknown in %s", s.constData(), object()->metaObject()->className());
+ d->primarySignals << QLatin1String(s);
+}
+
+/*!
+ Sets the value of this interface implementation to \a value.
+
+ The default implementation of text() returns the set value for
+ the Value text.
+
+ Note that the object wrapped by this interface is not modified.
+*/
+void QAccessibleWidget::setValue(const QString &value)
+{
+ d->value = value;
+}
+
+/*!
+ Sets the description of this interface implementation to \a desc.
+
+ The default implementation of text() returns the set value for
+ the Description text.
+
+ Note that the object wrapped by this interface is not modified.
+*/
+void QAccessibleWidget::setDescription(const QString &desc)
+{
+ d->description = desc;
+}
+
+/*!
+ Sets the help of this interface implementation to \a help.
+
+ The default implementation of text() returns the set value for
+ the Help text.
+
+ Note that the object wrapped by this interface is not modified.
+*/
+void QAccessibleWidget::setHelp(const QString &help)
+{
+ d->help = help;
+}
+
+/*!
+ Sets the accelerator of this interface implementation to \a accel.
+
+ The default implementation of text() returns the set value for
+ the Accelerator text.
+
+ Note that the object wrapped by this interface is not modified.
+*/
+void QAccessibleWidget::setAccelerator(const QString &accel)
+{
+ d->accelerator = accel;
+}
+
+static inline bool isAncestor(const QObject *obj, const QObject *child)
+{
+ while (child) {
+ if (child == obj)
+ return true;
+ child = child->parent();
+ }
+ return false;
+}
+
+
+/*! \reimp */
+QAccessible::Relation QAccessibleWidget::relationTo(int child,
+ const QAccessibleInterface *other, int otherChild) const
+{
+ Relation relation = Unrelated;
+ if (d->asking == this) // recursive call
+ return relation;
+
+ QObject *o = other ? other->object() : 0;
+ if (!o)
+ return relation;
+
+ QWidget *focus = widget()->focusWidget();
+ if (object() == focus && isAncestor(o, focus))
+ relation |= FocusChild;
+
+ QACConnectionObject *connectionObject = (QACConnectionObject*)object();
+ for (int sig = 0; sig < d->primarySignals.count(); ++sig) {
+ if (connectionObject->isSender(o, d->primarySignals.at(sig).toAscii())) {
+ relation |= Controller;
+ break;
+ }
+ }
+ // test for passive relationships.
+ // d->asking protects from endless recursion.
+ d->asking = this;
+ int inverse = other->relationTo(otherChild, this, child);
+ d->asking = 0;
+
+ if (inverse & Controller)
+ relation |= Controlled;
+ if (inverse & Label)
+ relation |= Labelled;
+
+ if(o == object()) {
+ if (child && !otherChild)
+ return relation | Child;
+ if (!child && otherChild)
+ return relation | Ancestor;
+ if (!child && !otherChild)
+ return relation | Self;
+ }
+
+ QObject *parent = object()->parent();
+ if (o == parent)
+ return relation | Child;
+
+ if (o->parent() == parent) {
+ relation |= Sibling;
+ QAccessibleInterface *sibIface = QAccessible::queryAccessibleInterface(o);
+ Q_ASSERT(sibIface);
+ QRect wg = rect(0);
+ QRect sg = sibIface->rect(0);
+ if (wg.intersects(sg)) {
+ QAccessibleInterface *pIface = 0;
+ sibIface->navigate(Ancestor, 1, &pIface);
+ if (pIface && !((sibIface->state(0) | state(0)) & Invisible)) {
+ int wi = pIface->indexOfChild(this);
+ int si = pIface->indexOfChild(sibIface);
+
+ if (wi > si)
+ relation |= QAccessible::Covers;
+ else
+ relation |= QAccessible::Covered;
+ }
+ delete pIface;
+ } else {
+ QPoint wc = wg.center();
+ QPoint sc = sg.center();
+ if (wc.x() < sc.x())
+ relation |= QAccessible::Left;
+ else if(wc.x() > sc.x())
+ relation |= QAccessible::Right;
+ if (wc.y() < sc.y())
+ relation |= QAccessible::Up;
+ else if (wc.y() > sc.y())
+ relation |= QAccessible::Down;
+ }
+ delete sibIface;
+
+ return relation;
+ }
+
+ if (isAncestor(o, object()))
+ return relation | Descendent;
+ if (isAncestor(object(), o))
+ return relation | Ancestor;
+
+ return relation;
+}
+
+/*! \reimp */
+int QAccessibleWidget::navigate(RelationFlag relation, int entry,
+ QAccessibleInterface **target) const
+{
+ if (!target)
+ return -1;
+
+ *target = 0;
+ QObject *targetObject = 0;
+
+ QWidgetList childList = childWidgets(widget());
+ bool complexWidget = childList.size() < childCount();
+
+ switch (relation) {
+ // Hierarchical
+ case Self:
+ targetObject = object();
+ break;
+ case Child:
+ if (complexWidget) {
+ if (entry > 0 && entry <= childCount())
+ return entry;
+ return -1;
+ }else {
+ if (entry > 0 && childList.size() >= entry)
+ targetObject = childList.at(entry - 1);
+ }
+ break;
+ case Ancestor:
+ {
+ if (entry <= 0)
+ return -1;
+ targetObject = widget()->parentWidget();
+ int i;
+ for (i = entry; i > 1 && targetObject; --i)
+ targetObject = targetObject->parent();
+ if (!targetObject && i == 1)
+ targetObject = qApp;
+ }
+ break;
+ case Sibling:
+ {
+ QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(parentObject());
+ if (!iface)
+ return -1;
+
+ iface->navigate(Child, entry, target);
+ delete iface;
+ if (*target)
+ return 0;
+ }
+ break;
+
+ // Geometrical
+ case QAccessible::Left:
+ if (complexWidget && entry) {
+ if (entry < 2 || widget()->height() > widget()->width() + 20) // looks vertical
+ return -1;
+ return entry - 1;
+ }
+ // fall through
+ case QAccessible::Right:
+ if (complexWidget && entry) {
+ if (entry >= childCount() || widget()->height() > widget()->width() + 20) // looks vertical
+ return -1;
+ return entry + 1;
+ }
+ // fall through
+ case QAccessible::Up:
+ if (complexWidget && entry) {
+ if (entry < 2 || widget()->width() > widget()->height() + 20) // looks horizontal
+ return - 1;
+ return entry - 1;
+ }
+ // fall through
+ case QAccessible::Down:
+ if (complexWidget && entry) {
+ if (entry >= childCount() || widget()->width() > widget()->height() + 20) // looks horizontal
+ return - 1;
+ return entry + 1;
+ } else {
+ QAccessibleInterface *pIface = QAccessible::queryAccessibleInterface(parentObject());
+ if (!pIface)
+ return -1;
+
+ QRect startg = rect(0);
+ QPoint startc = startg.center();
+ QAccessibleInterface *candidate = 0;
+ int mindist = 100000;
+ int sibCount = pIface->childCount();
+ for (int i = 0; i < sibCount; ++i) {
+ QAccessibleInterface *sibling = 0;
+ pIface->navigate(Child, i+1, &sibling);
+ Q_ASSERT(sibling);
+ if ((relationTo(0, sibling, 0) & Self) || (sibling->state(0) & QAccessible::Invisible)) {
+ //ignore ourself and invisible siblings
+ delete sibling;
+ continue;
+ }
+
+ QRect sibg = sibling->rect(0);
+ QPoint sibc = sibg.center();
+ QPoint sibp;
+ QPoint startp;
+ QPoint distp;
+ switch (relation) {
+ case QAccessible::Left:
+ startp = QPoint(startg.left(), startg.top() + startg.height() / 2);
+ sibp = QPoint(sibg.right(), sibg.top() + sibg.height() / 2);
+ if (QPoint(sibc - startc).x() >= 0) {
+ delete sibling;
+ continue;
+ }
+ distp = sibp - startp;
+ break;
+ case QAccessible::Right:
+ startp = QPoint(startg.right(), startg.top() + startg.height() / 2);
+ sibp = QPoint(sibg.left(), sibg.top() + sibg.height() / 2);
+ if (QPoint(sibc - startc).x() <= 0) {
+ delete sibling;
+ continue;
+ }
+ distp = sibp - startp;
+ break;
+ case QAccessible::Up:
+ startp = QPoint(startg.left() + startg.width() / 2, startg.top());
+ sibp = QPoint(sibg.left() + sibg.width() / 2, sibg.bottom());
+ if (QPoint(sibc - startc).y() >= 0) {
+ delete sibling;
+ continue;
+ }
+ distp = sibp - startp;
+ break;
+ case QAccessible::Down:
+ startp = QPoint(startg.left() + startg.width() / 2, startg.bottom());
+ sibp = QPoint(sibg.left() + sibg.width() / 2, sibg.top());
+ if (QPoint(sibc - startc).y() <= 0) {
+ delete sibling;
+ continue;
+ }
+ distp = sibp - startp;
+ break;
+ default:
+ break;
+ }
+
+ int dist = (int)qSqrt((qreal)distp.x() * distp.x() + distp.y() * distp.y());
+ if (dist < mindist) {
+ delete candidate;
+ candidate = sibling;
+ mindist = dist;
+ } else {
+ delete sibling;
+ }
+ }
+ delete pIface;
+ *target = candidate;
+ if (*target)
+ return 0;
+ }
+ break;
+ case Covers:
+ if (entry > 0) {
+ QAccessibleInterface *pIface = QAccessible::queryAccessibleInterface(parentObject());
+ if (!pIface)
+ return -1;
+
+ QRect r = rect(0);
+ int sibCount = pIface->childCount();
+ QAccessibleInterface *sibling = 0;
+ for (int i = pIface->indexOfChild(this) + 1; i <= sibCount && entry; ++i) {
+ pIface->navigate(Child, i, &sibling);
+ if (!sibling || (sibling->state(0) & Invisible)) {
+ delete sibling;
+ sibling = 0;
+ continue;
+ }
+ if (sibling->rect(0).intersects(r))
+ --entry;
+ if (!entry)
+ break;
+ delete sibling;
+ sibling = 0;
+ }
+ delete pIface;
+ *target = sibling;
+ if (*target)
+ return 0;
+ }
+ break;
+ case Covered:
+ if (entry > 0) {
+ QAccessibleInterface *pIface = QAccessible::queryAccessibleInterface(parentObject());
+ if (!pIface)
+ return -1;
+
+ QRect r = rect(0);
+ int index = pIface->indexOfChild(this);
+ QAccessibleInterface *sibling = 0;
+ for (int i = 1; i < index && entry; ++i) {
+ pIface->navigate(Child, i, &sibling);
+ Q_ASSERT(sibling);
+ if (!sibling || (sibling->state(0) & Invisible)) {
+ delete sibling;
+ sibling = 0;
+ continue;
+ }
+ if (sibling->rect(0).intersects(r))
+ --entry;
+ if (!entry)
+ break;
+ delete sibling;
+ sibling = 0;
+ }
+ delete pIface;
+ *target = sibling;
+ if (*target)
+ return 0;
+ }
+ break;
+
+ // Logical
+ case FocusChild:
+ {
+ if (widget()->hasFocus()) {
+ targetObject = object();
+ break;
+ }
+
+ QWidget *fw = widget()->focusWidget();
+ if (!fw)
+ return -1;
+
+ if (isAncestor(widget(), fw) || fw == widget())
+ targetObject = fw;
+ /* ###
+ QWidget *parent = fw;
+ while (parent && !targetObject) {
+ parent = parent->parentWidget();
+ if (parent == widget())
+ targetObject = fw;
+ }
+ */
+ }
+ break;
+ case Label:
+ if (entry > 0) {
+ QAccessibleInterface *pIface = QAccessible::queryAccessibleInterface(parentObject());
+ if (!pIface)
+ return -1;
+
+ // first check for all siblings that are labels to us
+ // ideally we would go through all objects and check, but that
+ // will be too expensive
+ int sibCount = pIface->childCount();
+ QAccessibleInterface *candidate = 0;
+ for (int i = 0; i < sibCount && entry; ++i) {
+ pIface->navigate(Child, i+1, &candidate);
+ Q_ASSERT(candidate);
+ if (candidate->relationTo(0, this, 0) & Label)
+ --entry;
+ if (!entry)
+ break;
+ delete candidate;
+ candidate = 0;
+ }
+ if (!candidate) {
+ if (pIface->relationTo(0, this, 0) & Label)
+ --entry;
+ if (!entry)
+ candidate = pIface;
+ }
+ if (pIface != candidate)
+ delete pIface;
+
+ *target = candidate;
+ if (*target)
+ return 0;
+ }
+ break;
+ case Labelled: // only implemented in subclasses
+ break;
+ case Controller:
+ if (entry > 0) {
+ // check all senders we are connected to,
+ // and figure out which one are controllers to us
+ QACConnectionObject *connectionObject = (QACConnectionObject*)object();
+ QObjectList allSenders = connectionObject->senderList();
+ QObjectList senders;
+ for (int s = 0; s < allSenders.size(); ++s) {
+ QObject *sender = allSenders.at(s);
+ QAccessibleInterface *candidate = QAccessible::queryAccessibleInterface(sender);
+ if (!candidate)
+ continue;
+ if (candidate->relationTo(0, this, 0)&Controller)
+ senders << sender;
+ delete candidate;
+ }
+ if (entry <= senders.size())
+ targetObject = senders.at(entry-1);
+ }
+ break;
+ case Controlled:
+ if (entry > 0) {
+ QObjectList allReceivers;
+ QACConnectionObject *connectionObject = (QACConnectionObject*)object();
+ for (int sig = 0; sig < d->primarySignals.count(); ++sig) {
+ QObjectList receivers = connectionObject->receiverList(d->primarySignals.at(sig).toAscii());
+ allReceivers += receivers;
+ }
+ if (entry <= allReceivers.size())
+ targetObject = allReceivers.at(entry-1);
+ }
+ break;
+ default:
+ break;
+ }
+
+ *target = QAccessible::queryAccessibleInterface(targetObject);
+ return *target ? 0 : -1;
+}
+
+/*! \reimp */
+int QAccessibleWidget::childCount() const
+{
+ QWidgetList cl = childWidgets(widget());
+ return cl.size();
+}
+
+/*! \reimp */
+int QAccessibleWidget::indexOfChild(const QAccessibleInterface *child) const
+{
+ QWidgetList cl = childWidgets(widget());
+ int index = cl.indexOf(qobject_cast<QWidget *>(child->object()));
+ if (index != -1)
+ ++index;
+ return index;
+}
+
+// from qwidget.cpp
+extern QString qt_setWindowTitle_helperHelper(const QString &, const QWidget*);
+
+/*! \reimp */
+QString QAccessibleWidget::text(Text t, int child) const
+{
+ QString str;
+
+ switch (t) {
+ case Name:
+ if (!d->name.isEmpty()) {
+ str = d->name;
+ } else if (!widget()->accessibleName().isEmpty()) {
+ str = widget()->accessibleName();
+ } else if (!child && widget()->isWindow()) {
+ if (widget()->isMinimized())
+ str = qt_setWindowTitle_helperHelper(widget()->windowIconText(), widget());
+ else
+ str = qt_setWindowTitle_helperHelper(widget()->windowTitle(), widget());
+ } else {
+ str = qt_accStripAmp(buddyString(widget()));
+ }
+ break;
+ case Description:
+ if (!d->description.isEmpty())
+ str = d->description;
+ else if (!widget()->accessibleDescription().isEmpty())
+ str = widget()->accessibleDescription();
+#ifndef QT_NO_TOOLTIP
+ else
+ str = widget()->toolTip();
+#endif
+ break;
+ case Help:
+ if (!d->help.isEmpty())
+ str = d->help;
+#ifndef QT_NO_WHATSTHIS
+ else
+ str = widget()->whatsThis();
+#endif
+ break;
+ case Accelerator:
+ if (!d->accelerator.isEmpty())
+ str = d->accelerator;
+ else
+ str = qt_accHotKey(buddyString(widget()));
+ break;
+ case Value:
+ str = d->value;
+ break;
+ default:
+ break;
+ }
+ return str;
+}
+
+#ifndef QT_NO_ACTION
+
+/*! \reimp */
+int QAccessibleWidget::userActionCount(int child) const
+{
+ if (child)
+ return 0;
+ return widget()->actions().count();
+}
+
+/*! \reimp */
+QString QAccessibleWidget::actionText(int action, Text t, int child) const
+{
+ if (action == DefaultAction)
+ action = SetFocus;
+
+ if (action > 0 && !child) {
+ QAction *act = widget()->actions().value(action - 1);
+ if (act) {
+ switch (t) {
+ case Name:
+ return act->text();
+ case Description:
+ return act->toolTip();
+#ifndef QT_NO_SHORTCUT
+ case Accelerator:
+ return act->shortcut().toString();
+#endif
+ default:
+ break;
+ }
+ }
+ }
+
+ return QAccessibleObject::actionText(action, t, child);
+}
+
+/*! \reimp */
+bool QAccessibleWidget::doAction(int action, int child, const QVariantList &params)
+{
+ if (action == SetFocus || action == DefaultAction) {
+ if (child || !widget()->isEnabled())
+ return false;
+ if (widget()->focusPolicy() != Qt::NoFocus)
+ widget()->setFocus();
+ else if (widget()->isWindow())
+ widget()->activateWindow();
+ else
+ return false;
+ return true;
+ } else if (action > 0) {
+ if (QAction *act = widget()->actions().value(action - 1)) {
+ act->trigger();
+ return true;
+ }
+ }
+ return QAccessibleObject::doAction(action, child, params);
+}
+
+#endif // QT_NO_ACTION
+
+/*! \reimp */
+QAccessible::Role QAccessibleWidget::role(int child) const
+{
+ if (!child)
+ return d->role;
+
+ QWidgetList childList = childWidgets(widget());
+ if (childList.count() > 0 && child <= childList.count()) {
+ QWidget *targetWidget = childList.at(child - 1);
+ QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(targetWidget);
+ if (iface) {
+ QAccessible::Role role = iface->role(0);
+ delete iface;
+ return role;
+ }
+ }
+
+ return NoRole;
+}
+
+/*! \reimp */
+QAccessible::State QAccessibleWidget::state(int child) const
+{
+ if (child)
+ return Normal;
+
+ QAccessible::State state = Normal;
+
+ QWidget *w = widget();
+ if (w->testAttribute(Qt::WA_WState_Visible) == false)
+ state |= Invisible;
+ if (w->focusPolicy() != Qt::NoFocus && w->isActiveWindow())
+ state |= Focusable;
+ if (w->hasFocus())
+ state |= Focused;
+ if (!w->isEnabled())
+ state |= Unavailable;
+ if (w->isWindow()) {
+ if (w->windowFlags() & Qt::WindowSystemMenuHint)
+ state |= Movable;
+ if (w->minimumSize() != w->maximumSize())
+ state |= Sizeable;
+ }
+
+ return state;
+}
+
+// ### Qt 5: remove me - binary compatibility hack
+QAccessibleWidgetEx::QAccessibleWidgetEx(QWidget *o, Role role, const QString& name)
+ : QAccessibleObjectEx(o)
+{
+ Q_ASSERT(widget());
+ d = new QAccessibleWidgetPrivate();
+ d->role = role;
+ d->name = name;
+ d->asking = 0;
+}
+
+int QAccessibleWidgetEx::childCount() const
+{ return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::childCount(); }
+int QAccessibleWidgetEx::indexOfChild(const QAccessibleInterface *child) const
+{ return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::indexOfChild(child); }
+QAccessible::Relation QAccessibleWidgetEx::relationTo(int child, const QAccessibleInterface *other, int otherChild) const
+{ return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::relationTo(child, other, otherChild); }
+
+int QAccessibleWidgetEx::childAt(int x, int y) const
+{ return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::childAt(x, y); }
+QRect QAccessibleWidgetEx::rect(int child) const
+{ return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::rect(child); }
+int QAccessibleWidgetEx::navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const
+{ return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::navigate(rel, entry, target); }
+
+QString QAccessibleWidgetEx::text(Text t, int child) const
+{ return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::text(t, child); }
+QAccessible::Role QAccessibleWidgetEx::role(int child) const
+{ return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::role(child); }
+QAccessible::State QAccessibleWidgetEx::state(int child) const
+{ return (reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::state(child))
+ | HasInvokeExtension; }
+
+QString QAccessibleWidgetEx::actionText(int action, Text t, int child) const
+{ return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::actionText(action, t, child); }
+bool QAccessibleWidgetEx::doAction(int action, int child, const QVariantList &params)
+{ return reinterpret_cast<QAccessibleWidget *>(this)->QAccessibleWidget::doAction(action, child, params); }
+
+QAccessibleWidgetEx::~QAccessibleWidgetEx()
+{ delete d; }
+QWidget *QAccessibleWidgetEx::widget() const
+{ return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::widget(); }
+QObject *QAccessibleWidgetEx::parentObject() const
+{ return reinterpret_cast<const QAccessibleWidget *>(this)->QAccessibleWidget::parentObject(); }
+
+void QAccessibleWidgetEx::addControllingSignal(const QString &signal)
+{ reinterpret_cast<QAccessibleWidget *>(this)->QAccessibleWidget::addControllingSignal(signal); }
+void QAccessibleWidgetEx::setValue(const QString &value)
+{ reinterpret_cast<QAccessibleWidget *>(this)->QAccessibleWidget::setValue(value); }
+void QAccessibleWidgetEx::setDescription(const QString &desc)
+{ reinterpret_cast<QAccessibleWidget *>(this)->QAccessibleWidget::setDescription(desc); }
+void QAccessibleWidgetEx::setHelp(const QString &help)
+{ reinterpret_cast<QAccessibleWidget *>(this)->QAccessibleWidget::setHelp(help); }
+void QAccessibleWidgetEx::setAccelerator(const QString &accel)
+{ reinterpret_cast<QAccessibleWidget *>(this)->QAccessibleWidget::setAccelerator(accel); }
+
+QVariant QAccessibleWidgetEx::invokeMethodEx(Method method, int child, const QVariantList & /*params*/)
+{
+ if (child)
+ return QVariant();
+
+ switch (method) {
+ case ListSupportedMethods: {
+ QSet<QAccessible::Method> set;
+ set << ListSupportedMethods << ForegroundColor << BackgroundColor;
+ return QVariant::fromValue(set);
+ }
+ case ForegroundColor:
+ return widget()->palette().color(widget()->foregroundRole());
+ case BackgroundColor:
+ return widget()->palette().color(widget()->backgroundRole());
+ default:
+ return QVariant();
+ }
+}
+
+QT_END_NAMESPACE
+
+#endif //QT_NO_ACCESSIBILITY
diff --git a/src/widgets/accessible/qaccessiblewidget.h b/src/widgets/accessible/qaccessiblewidget.h
new file mode 100644
index 0000000000..4b53e319b1
--- /dev/null
+++ b/src/widgets/accessible/qaccessiblewidget.h
@@ -0,0 +1,141 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QACCESSIBLEWIDGET_H
+#define QACCESSIBLEWIDGET_H
+
+#include <QtWidgets/qaccessibleobject.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_ACCESSIBILITY
+
+class QAccessibleWidgetPrivate;
+
+class Q_GUI_EXPORT QAccessibleWidget : public QAccessibleObject
+{
+public:
+ explicit QAccessibleWidget(QWidget *o, Role r = Client, const QString& name = QString());
+
+ int childCount() const;
+ int indexOfChild(const QAccessibleInterface *child) const;
+ Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const;
+
+ int childAt(int x, int y) const;
+ QRect rect(int child) const;
+ int navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const;
+
+ QString text(Text t, int child) const;
+ Role role(int child) const;
+ State state(int child) const;
+
+#ifndef QT_NO_ACTION
+ int userActionCount(int child) const;
+ QString actionText(int action, Text t, int child) const;
+ bool doAction(int action, int child, const QVariantList &params);
+#endif
+
+protected:
+ ~QAccessibleWidget();
+ QWidget *widget() const;
+ QObject *parentObject() const;
+
+ void addControllingSignal(const QString &signal);
+ void setValue(const QString &value);
+ void setDescription(const QString &desc);
+ void setHelp(const QString &help);
+ void setAccelerator(const QString &accel);
+
+private:
+ friend class QAccessibleWidgetEx;
+ QAccessibleWidgetPrivate *d;
+ Q_DISABLE_COPY(QAccessibleWidget)
+};
+
+class Q_GUI_EXPORT QAccessibleWidgetEx : public QAccessibleObjectEx
+{
+public:
+ explicit QAccessibleWidgetEx(QWidget *o, Role r = Client, const QString& name = QString());
+
+ int childCount() const;
+ int indexOfChild(const QAccessibleInterface *child) const;
+ Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const;
+
+ int childAt(int x, int y) const;
+ QRect rect(int child) const;
+ int navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const;
+
+ QString text(Text t, int child) const;
+ Role role(int child) const;
+ State state(int child) const;
+
+ QString actionText(int action, Text t, int child) const;
+ bool doAction(int action, int child, const QVariantList &params);
+
+ QVariant invokeMethodEx(Method method, int child, const QVariantList &params);
+
+protected:
+ ~QAccessibleWidgetEx();
+ QWidget *widget() const;
+ QObject *parentObject() const;
+
+ void addControllingSignal(const QString &signal);
+ void setValue(const QString &value);
+ void setDescription(const QString &desc);
+ void setHelp(const QString &help);
+ void setAccelerator(const QString &accel);
+
+private:
+ QAccessibleWidgetPrivate *d;
+ Q_DISABLE_COPY(QAccessibleWidgetEx)
+};
+
+#endif // QT_NO_ACCESSIBILITY
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QACCESSIBLEWIDGET_H
diff --git a/src/gui/animation/animation.pri b/src/widgets/animation/animation.pri
index 27763ca003..27763ca003 100644
--- a/src/gui/animation/animation.pri
+++ b/src/widgets/animation/animation.pri
diff --git a/src/gui/animation/qguivariantanimation.cpp b/src/widgets/animation/qguivariantanimation.cpp
index ccd27d5d91..ccd27d5d91 100644
--- a/src/gui/animation/qguivariantanimation.cpp
+++ b/src/widgets/animation/qguivariantanimation.cpp
diff --git a/src/widgets/dialogs/dialogs.pri b/src/widgets/dialogs/dialogs.pri
new file mode 100644
index 0000000000..472787a20c
--- /dev/null
+++ b/src/widgets/dialogs/dialogs.pri
@@ -0,0 +1,106 @@
+# Qt dialogs module
+
+HEADERS += \
+ dialogs/qabstractprintdialog.h \
+ dialogs/qabstractprintdialog_p.h \
+ dialogs/qabstractpagesetupdialog.h \
+ dialogs/qabstractpagesetupdialog_p.h \
+ dialogs/qcolordialog.h \
+ dialogs/qcolordialog_p.h \
+ dialogs/qfscompleter_p.h \
+ dialogs/qdialog.h \
+ dialogs/qdialog_p.h \
+ dialogs/qerrormessage.h \
+ dialogs/qfiledialog.h \
+ dialogs/qfiledialog_p.h \
+ dialogs/qfontdialog.h \
+ dialogs/qfontdialog_p.h \
+ dialogs/qinputdialog.h \
+ dialogs/qmessagebox.h \
+ dialogs/qpagesetupdialog.h \
+ dialogs/qprintdialog.h \
+ dialogs/qprogressdialog.h \
+ dialogs/qsidebar_p.h \
+ dialogs/qfilesystemmodel.h \
+ dialogs/qfilesystemmodel_p.h \
+ dialogs/qfileinfogatherer_p.h \
+ dialogs/qwizard.h \
+ dialogs/qprintpreviewdialog.h
+
+!qpa:mac {
+ OBJECTIVE_SOURCES += dialogs/qfiledialog_mac.mm \
+ dialogs/qfontdialog_mac.mm \
+ dialogs/qnspanelproxy_mac.mm \
+ dialogs/qpagesetupdialog_mac.mm \
+ dialogs/qprintdialog_mac.mm
+
+# Compile qcolordialog_mac.mm with exception support, disregarding the -no-exceptions
+# configure option. (qcolordialog_mac needs to catch exceptions thrown by cocoa)
+ EXCEPTION_SOURCES = dialogs/qcolordialog_mac.mm
+ exceptions_compiler.commands = $$QMAKE_CXX -c
+ exceptions_compiler.commands += $(CXXFLAGS) $(INCPATH) ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
+ exceptions_compiler.commands += -fexceptions
+ exceptions_compiler.dependency_type = TYPE_C
+ exceptions_compiler.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)}
+ exceptions_compiler.input = EXCEPTION_SOURCES
+ exceptions_compiler.variable_out = OBJECTS
+ exceptions_compiler.name = compiling[exceptopns] ${QMAKE_FILE_IN}
+ silent:exceptions_compiler.commands = @echo compiling[exceptopns] ${QMAKE_FILE_IN} && $$exceptions_compiler.commands
+ QMAKE_EXTRA_COMPILERS += exceptions_compiler
+}
+
+win32 {
+ HEADERS += dialogs/qwizard_win_p.h \
+ dialogs/qfiledialog_win_p.h
+ SOURCES += dialogs/qdialogsbinarycompat_win.cpp \
+ dialogs/qfiledialog_win.cpp \
+ dialogs/qpagesetupdialog_win.cpp \
+ dialogs/qprintdialog_win.cpp \
+ dialogs/qwizard_win.cpp
+
+ !win32-borland:!wince*: LIBS += -lshell32 # the filedialog needs this library
+}
+
+!mac:!symbian:unix|qpa {
+ HEADERS += dialogs/qpagesetupdialog_unix_p.h
+ SOURCES += dialogs/qprintdialog_unix.cpp \
+ dialogs/qpagesetupdialog_unix.cpp
+ FORMS += dialogs/qprintsettingsoutput.ui \
+ dialogs/qprintwidget.ui \
+ dialogs/qprintpropertieswidget.ui
+}
+
+wince*|symbian: FORMS += dialogs/qfiledialog_embedded.ui
+else: FORMS += dialogs/qfiledialog.ui
+
+INCLUDEPATH += $$PWD
+SOURCES += \
+ dialogs/qabstractprintdialog.cpp \
+ dialogs/qabstractpagesetupdialog.cpp \
+ dialogs/qcolordialog.cpp \
+ dialogs/qdialog.cpp \
+ dialogs/qerrormessage.cpp \
+ dialogs/qfiledialog.cpp \
+ dialogs/qfontdialog.cpp \
+ dialogs/qinputdialog.cpp \
+ dialogs/qmessagebox.cpp \
+ dialogs/qprogressdialog.cpp \
+ dialogs/qsidebar.cpp \
+ dialogs/qfilesystemmodel.cpp \
+ dialogs/qfileinfogatherer.cpp \
+ dialogs/qpagesetupdialog.cpp \
+ dialogs/qwizard.cpp \
+ dialogs/qprintpreviewdialog.cpp
+
+symbian:contains(QT_CONFIG, s60) {
+ LIBS += -lCommonDialogs
+ SOURCES += dialogs/qfiledialog_symbian.cpp \
+ dialogs/qcolordialog_symbian.cpp
+}
+
+FORMS += dialogs/qpagesetupwidget.ui
+RESOURCES += dialogs/qprintdialog.qrc
+RESOURCES += dialogs/qmessagebox.qrc
+
+# Compensate for lack of platform defines in Symbian3
+symbian: DEFINES += SYMBIAN_VERSION_$$upper($$replace(SYMBIAN_VERSION,\\.,_))
diff --git a/src/gui/dialogs/images/fit-page-24.png b/src/widgets/dialogs/images/fit-page-24.png
index c7b39d8853..c7b39d8853 100644
--- a/src/gui/dialogs/images/fit-page-24.png
+++ b/src/widgets/dialogs/images/fit-page-24.png
Binary files differ
diff --git a/src/gui/dialogs/images/fit-page-32.png b/src/widgets/dialogs/images/fit-page-32.png
index 98bc12d3ed..98bc12d3ed 100644
--- a/src/gui/dialogs/images/fit-page-32.png
+++ b/src/widgets/dialogs/images/fit-page-32.png
Binary files differ
diff --git a/src/gui/dialogs/images/fit-width-24.png b/src/widgets/dialogs/images/fit-width-24.png
index a729ffda54..a729ffda54 100644
--- a/src/gui/dialogs/images/fit-width-24.png
+++ b/src/widgets/dialogs/images/fit-width-24.png
Binary files differ
diff --git a/src/gui/dialogs/images/fit-width-32.png b/src/widgets/dialogs/images/fit-width-32.png
index 470a8b45d0..470a8b45d0 100644
--- a/src/gui/dialogs/images/fit-width-32.png
+++ b/src/widgets/dialogs/images/fit-width-32.png
Binary files differ
diff --git a/src/gui/dialogs/images/go-first-24.png b/src/widgets/dialogs/images/go-first-24.png
index 55315ffa38..55315ffa38 100644
--- a/src/gui/dialogs/images/go-first-24.png
+++ b/src/widgets/dialogs/images/go-first-24.png
Binary files differ
diff --git a/src/gui/dialogs/images/go-first-32.png b/src/widgets/dialogs/images/go-first-32.png
index 0fe6f94b77..0fe6f94b77 100644
--- a/src/gui/dialogs/images/go-first-32.png
+++ b/src/widgets/dialogs/images/go-first-32.png
Binary files differ
diff --git a/src/gui/dialogs/images/go-last-24.png b/src/widgets/dialogs/images/go-last-24.png
index 81061b80f2..81061b80f2 100644
--- a/src/gui/dialogs/images/go-last-24.png
+++ b/src/widgets/dialogs/images/go-last-24.png
Binary files differ
diff --git a/src/gui/dialogs/images/go-last-32.png b/src/widgets/dialogs/images/go-last-32.png
index 887506107e..887506107e 100644
--- a/src/gui/dialogs/images/go-last-32.png
+++ b/src/widgets/dialogs/images/go-last-32.png
Binary files differ
diff --git a/src/gui/dialogs/images/go-next-24.png b/src/widgets/dialogs/images/go-next-24.png
index 9a55ef3d86..9a55ef3d86 100644
--- a/src/gui/dialogs/images/go-next-24.png
+++ b/src/widgets/dialogs/images/go-next-24.png
Binary files differ
diff --git a/src/gui/dialogs/images/go-next-32.png b/src/widgets/dialogs/images/go-next-32.png
index 6d98f50f4f..6d98f50f4f 100644
--- a/src/gui/dialogs/images/go-next-32.png
+++ b/src/widgets/dialogs/images/go-next-32.png
Binary files differ
diff --git a/src/gui/dialogs/images/go-previous-24.png b/src/widgets/dialogs/images/go-previous-24.png
index 2ea769eb8d..2ea769eb8d 100644
--- a/src/gui/dialogs/images/go-previous-24.png
+++ b/src/widgets/dialogs/images/go-previous-24.png
Binary files differ
diff --git a/src/gui/dialogs/images/go-previous-32.png b/src/widgets/dialogs/images/go-previous-32.png
index 37ba0c4e8d..37ba0c4e8d 100644
--- a/src/gui/dialogs/images/go-previous-32.png
+++ b/src/widgets/dialogs/images/go-previous-32.png
Binary files differ
diff --git a/src/gui/dialogs/images/layout-landscape-24.png b/src/widgets/dialogs/images/layout-landscape-24.png
index 6f89a31cb6..6f89a31cb6 100644
--- a/src/gui/dialogs/images/layout-landscape-24.png
+++ b/src/widgets/dialogs/images/layout-landscape-24.png
Binary files differ
diff --git a/src/gui/dialogs/images/layout-landscape-32.png b/src/widgets/dialogs/images/layout-landscape-32.png
index 6a94946c36..6a94946c36 100644
--- a/src/gui/dialogs/images/layout-landscape-32.png
+++ b/src/widgets/dialogs/images/layout-landscape-32.png
Binary files differ
diff --git a/src/gui/dialogs/images/layout-portrait-24.png b/src/widgets/dialogs/images/layout-portrait-24.png
index e0dbabc83b..e0dbabc83b 100644
--- a/src/gui/dialogs/images/layout-portrait-24.png
+++ b/src/widgets/dialogs/images/layout-portrait-24.png
Binary files differ
diff --git a/src/gui/dialogs/images/layout-portrait-32.png b/src/widgets/dialogs/images/layout-portrait-32.png
index d17468c0a4..d17468c0a4 100644
--- a/src/gui/dialogs/images/layout-portrait-32.png
+++ b/src/widgets/dialogs/images/layout-portrait-32.png
Binary files differ
diff --git a/src/gui/dialogs/images/page-setup-24.png b/src/widgets/dialogs/images/page-setup-24.png
index 4bfafdace0..4bfafdace0 100644
--- a/src/gui/dialogs/images/page-setup-24.png
+++ b/src/widgets/dialogs/images/page-setup-24.png
Binary files differ
diff --git a/src/gui/dialogs/images/page-setup-32.png b/src/widgets/dialogs/images/page-setup-32.png
index 2313b8fe3b..2313b8fe3b 100644
--- a/src/gui/dialogs/images/page-setup-32.png
+++ b/src/widgets/dialogs/images/page-setup-32.png
Binary files differ
diff --git a/src/gui/dialogs/images/print-24.png b/src/widgets/dialogs/images/print-24.png
index c6bf3e8672..c6bf3e8672 100644
--- a/src/gui/dialogs/images/print-24.png
+++ b/src/widgets/dialogs/images/print-24.png
Binary files differ
diff --git a/src/gui/dialogs/images/print-32.png b/src/widgets/dialogs/images/print-32.png
index 5830888653..5830888653 100644
--- a/src/gui/dialogs/images/print-32.png
+++ b/src/widgets/dialogs/images/print-32.png
Binary files differ
diff --git a/src/gui/dialogs/images/qtlogo-64.png b/src/widgets/dialogs/images/qtlogo-64.png
index 4f68e162de..4f68e162de 100644
--- a/src/gui/dialogs/images/qtlogo-64.png
+++ b/src/widgets/dialogs/images/qtlogo-64.png
Binary files differ
diff --git a/src/gui/dialogs/images/status-color.png b/src/widgets/dialogs/images/status-color.png
index af3cbfa31c..af3cbfa31c 100644
--- a/src/gui/dialogs/images/status-color.png
+++ b/src/widgets/dialogs/images/status-color.png
Binary files differ
diff --git a/src/gui/dialogs/images/status-gray-scale.png b/src/widgets/dialogs/images/status-gray-scale.png
index 4462588809..4462588809 100644
--- a/src/gui/dialogs/images/status-gray-scale.png
+++ b/src/widgets/dialogs/images/status-gray-scale.png
Binary files differ
diff --git a/src/gui/dialogs/images/view-page-multi-24.png b/src/widgets/dialogs/images/view-page-multi-24.png
index 87241472ae..87241472ae 100644
--- a/src/gui/dialogs/images/view-page-multi-24.png
+++ b/src/widgets/dialogs/images/view-page-multi-24.png
Binary files differ
diff --git a/src/gui/dialogs/images/view-page-multi-32.png b/src/widgets/dialogs/images/view-page-multi-32.png
index 130885a041..130885a041 100644
--- a/src/gui/dialogs/images/view-page-multi-32.png
+++ b/src/widgets/dialogs/images/view-page-multi-32.png
Binary files differ
diff --git a/src/gui/dialogs/images/view-page-one-24.png b/src/widgets/dialogs/images/view-page-one-24.png
index 4c6457b892..4c6457b892 100644
--- a/src/gui/dialogs/images/view-page-one-24.png
+++ b/src/widgets/dialogs/images/view-page-one-24.png
Binary files differ
diff --git a/src/gui/dialogs/images/view-page-one-32.png b/src/widgets/dialogs/images/view-page-one-32.png
index 537193984e..537193984e 100644
--- a/src/gui/dialogs/images/view-page-one-32.png
+++ b/src/widgets/dialogs/images/view-page-one-32.png
Binary files differ
diff --git a/src/gui/dialogs/images/view-page-sided-24.png b/src/widgets/dialogs/images/view-page-sided-24.png
index 2131305c41..2131305c41 100644
--- a/src/gui/dialogs/images/view-page-sided-24.png
+++ b/src/widgets/dialogs/images/view-page-sided-24.png
Binary files differ
diff --git a/src/gui/dialogs/images/view-page-sided-32.png b/src/widgets/dialogs/images/view-page-sided-32.png
index e4d63f9992..e4d63f9992 100644
--- a/src/gui/dialogs/images/view-page-sided-32.png
+++ b/src/widgets/dialogs/images/view-page-sided-32.png
Binary files differ
diff --git a/src/gui/dialogs/images/zoom-in-24.png b/src/widgets/dialogs/images/zoom-in-24.png
index d29b142b6c..d29b142b6c 100644
--- a/src/gui/dialogs/images/zoom-in-24.png
+++ b/src/widgets/dialogs/images/zoom-in-24.png
Binary files differ
diff --git a/src/gui/dialogs/images/zoom-in-32.png b/src/widgets/dialogs/images/zoom-in-32.png
index 34d70af37b..34d70af37b 100644
--- a/src/gui/dialogs/images/zoom-in-32.png
+++ b/src/widgets/dialogs/images/zoom-in-32.png
Binary files differ
diff --git a/src/gui/dialogs/images/zoom-out-24.png b/src/widgets/dialogs/images/zoom-out-24.png
index 19703474f8..19703474f8 100644
--- a/src/gui/dialogs/images/zoom-out-24.png
+++ b/src/widgets/dialogs/images/zoom-out-24.png
Binary files differ
diff --git a/src/gui/dialogs/images/zoom-out-32.png b/src/widgets/dialogs/images/zoom-out-32.png
index b832206612..b832206612 100644
--- a/src/gui/dialogs/images/zoom-out-32.png
+++ b/src/widgets/dialogs/images/zoom-out-32.png
Binary files differ
diff --git a/src/gui/dialogs/qabstractpagesetupdialog.cpp b/src/widgets/dialogs/qabstractpagesetupdialog.cpp
index 080ddeaa85..080ddeaa85 100644
--- a/src/gui/dialogs/qabstractpagesetupdialog.cpp
+++ b/src/widgets/dialogs/qabstractpagesetupdialog.cpp
diff --git a/src/widgets/dialogs/qabstractpagesetupdialog.h b/src/widgets/dialogs/qabstractpagesetupdialog.h
new file mode 100644
index 0000000000..94e8566bc9
--- /dev/null
+++ b/src/widgets/dialogs/qabstractpagesetupdialog.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QABSTRACTPAGESETUPDIALOG_H
+#define QABSTRACTPAGESETUPDIALOG_H
+
+#include <QtWidgets/qdialog.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_PRINTDIALOG
+
+class QAbstractPageSetupDialogPrivate;
+class QPrinter;
+
+// ### Qt 5: Remove this class
+class Q_GUI_EXPORT QAbstractPageSetupDialog : public QDialog
+{
+ Q_DECLARE_PRIVATE(QAbstractPageSetupDialog)
+ Q_OBJECT
+
+public:
+ explicit QAbstractPageSetupDialog(QPrinter *printer, QWidget *parent = 0);
+ QAbstractPageSetupDialog(QAbstractPageSetupDialogPrivate &ptr,
+ QPrinter *printer, QWidget *parent = 0);
+ ~QAbstractPageSetupDialog();
+
+ virtual int exec() = 0;
+ void done(int result);
+
+ QPrinter *printer();
+};
+
+#endif // QT_NO_PRINTDIALOG
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QABSTRACTPAGESETUPDIALOG_H
diff --git a/src/gui/dialogs/qabstractpagesetupdialog_p.h b/src/widgets/dialogs/qabstractpagesetupdialog_p.h
index 3dbfdd5e26..3dbfdd5e26 100644
--- a/src/gui/dialogs/qabstractpagesetupdialog_p.h
+++ b/src/widgets/dialogs/qabstractpagesetupdialog_p.h
diff --git a/src/widgets/dialogs/qabstractprintdialog.cpp b/src/widgets/dialogs/qabstractprintdialog.cpp
new file mode 100644
index 0000000000..004f6877e4
--- /dev/null
+++ b/src/widgets/dialogs/qabstractprintdialog.cpp
@@ -0,0 +1,499 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qabstractprintdialog_p.h"
+#include "qcoreapplication.h"
+#include "qprintdialog.h"
+#include "qprinter.h"
+#include "private/qprinter_p.h"
+
+#ifndef QT_NO_PRINTDIALOG
+
+QT_BEGIN_NAMESPACE
+
+// hack
+class QPrintDialogPrivate : public QAbstractPrintDialogPrivate
+{
+};
+
+/*!
+ \class QAbstractPrintDialog
+ \brief The QAbstractPrintDialog class provides a base implementation for
+ print dialogs used to configure printers.
+
+ \ingroup printing
+
+ This class implements getter and setter functions that are used to
+ customize settings shown in print dialogs, but it is not used directly.
+ Use QPrintDialog to display a print dialog in your application.
+
+ In Symbian, there is no support for printing. Hence, this dialog should not
+ be used in Symbian.
+
+ \sa QPrintDialog, QPrinter, {Printing with Qt}
+*/
+
+/*!
+ \enum QAbstractPrintDialog::PrintRange
+
+ Used to specify the print range selection option.
+
+ \value AllPages All pages should be printed.
+ \value Selection Only the selection should be printed.
+ \value PageRange The specified page range should be printed.
+ \value CurrentPage Only the currently visible page should be printed.
+
+ \sa QPrinter::PrintRange
+*/
+
+/*!
+ \enum QAbstractPrintDialog::PrintDialogOption
+
+ Used to specify which parts of the print dialog should be visible.
+
+ \value None None of the options are enabled.
+ \value PrintToFile The print to file option is enabled.
+ \value PrintSelection The print selection option is enabled.
+ \value PrintPageRange The page range selection option is enabled.
+ \value PrintShowPageSize Show the page size + margins page only if this is enabled.
+ \value PrintCollateCopies The collate copies option is enabled
+ \value PrintCurrentPage The print current page option is enabled
+
+ This value is obsolete and does nothing since Qt 4.5:
+
+ \value DontUseSheet In previous versions of Qt, exec() the print dialog
+ would create a sheet by default the dialog was given a parent.
+ This is no longer supported in Qt 4.5. If you want to use sheets, use
+ QPrintDialog::open() instead.
+*/
+
+/*!
+ Constructs an abstract print dialog for \a printer with \a parent
+ as parent widget.
+*/
+QAbstractPrintDialog::QAbstractPrintDialog(QPrinter *printer, QWidget *parent)
+ : QDialog(*(new QAbstractPrintDialogPrivate), parent)
+{
+ Q_D(QAbstractPrintDialog);
+ setWindowTitle(QCoreApplication::translate("QPrintDialog", "Print"));
+ d->setPrinter(printer);
+}
+
+/*!
+ \internal
+*/
+QAbstractPrintDialog::QAbstractPrintDialog(QAbstractPrintDialogPrivate &ptr,
+ QPrinter *printer,
+ QWidget *parent)
+ : QDialog(ptr, parent)
+{
+ Q_D(QAbstractPrintDialog);
+ setWindowTitle(QCoreApplication::translate("QPrintDialog", "Print"));
+ d->setPrinter(printer);
+}
+
+/*!
+ \internal
+*/
+QAbstractPrintDialog::~QAbstractPrintDialog()
+{
+ Q_D(QAbstractPrintDialog);
+ if (d->ownsPrinter)
+ delete d->printer;
+}
+
+/*!
+ Sets the given \a option to be enabled if \a on is true;
+ otherwise, clears the given \a option.
+
+ \sa options, testOption()
+*/
+void QPrintDialog::setOption(PrintDialogOption option, bool on)
+{
+ Q_D(QPrintDialog);
+ if (!(d->options & option) != !on)
+ setOptions(d->options ^ option);
+}
+
+/*!
+ Returns true if the given \a option is enabled; otherwise, returns
+ false.
+
+ \sa options, setOption()
+*/
+bool QPrintDialog::testOption(PrintDialogOption option) const
+{
+ Q_D(const QPrintDialog);
+ return (d->options & option) != 0;
+}
+
+/*!
+ \property QPrintDialog::options
+ \brief the various options that affect the look and feel of the dialog
+ \since 4.5
+
+ By default, all options are disabled.
+
+ Options should be set before showing the dialog. Setting them while the
+ dialog is visible is not guaranteed to have an immediate effect on the
+ dialog (depending on the option and on the platform).
+
+ \sa setOption(), testOption()
+*/
+void QPrintDialog::setOptions(PrintDialogOptions options)
+{
+ Q_D(QPrintDialog);
+
+ PrintDialogOptions changed = (options ^ d->options);
+ if (!changed)
+ return;
+
+ d->options = options;
+}
+
+QPrintDialog::PrintDialogOptions QPrintDialog::options() const
+{
+ Q_D(const QPrintDialog);
+ return d->options;
+}
+
+/*!
+ \obsolete
+
+ Use QPrintDialog::setOptions() instead.
+*/
+void QAbstractPrintDialog::setEnabledOptions(PrintDialogOptions options)
+{
+ Q_D(QAbstractPrintDialog);
+ d->options = options;
+}
+
+/*!
+ \obsolete
+
+ Use QPrintDialog::setOption(\a option, true) instead.
+*/
+void QAbstractPrintDialog::addEnabledOption(PrintDialogOption option)
+{
+ Q_D(QAbstractPrintDialog);
+ d->options |= option;
+}
+
+/*!
+ \obsolete
+
+ Use QPrintDialog::options() instead.
+*/
+QAbstractPrintDialog::PrintDialogOptions QAbstractPrintDialog::enabledOptions() const
+{
+ Q_D(const QAbstractPrintDialog);
+ return d->options;
+}
+
+/*!
+ \obsolete
+
+ Use QPrintDialog::testOption(\a option) instead.
+*/
+bool QAbstractPrintDialog::isOptionEnabled(PrintDialogOption option) const
+{
+ Q_D(const QAbstractPrintDialog);
+ return d->options & option;
+}
+
+/*!
+ Sets the print range option in to be \a range.
+ */
+void QAbstractPrintDialog::setPrintRange(PrintRange range)
+{
+ Q_D(QAbstractPrintDialog);
+ d->pd->printRange = QPrinter::PrintRange(range);
+}
+
+/*!
+ Returns the print range.
+*/
+QAbstractPrintDialog::PrintRange QAbstractPrintDialog::printRange() const
+{
+ Q_D(const QAbstractPrintDialog);
+ return QAbstractPrintDialog::PrintRange(d->pd->printRange);
+}
+
+/*!
+ Sets the page range in this dialog to be from \a min to \a max. This also
+ enables the PrintPageRange option.
+*/
+void QAbstractPrintDialog::setMinMax(int min, int max)
+{
+ Q_D(QAbstractPrintDialog);
+ Q_ASSERT_X(min <= max, "QAbstractPrintDialog::setMinMax",
+ "'min' must be less than or equal to 'max'");
+ d->pd->minPage = min;
+ d->pd->maxPage = max;
+ d->options |= PrintPageRange;
+}
+
+/*!
+ Returns the minimum page in the page range.
+ By default, this value is set to 1.
+*/
+int QAbstractPrintDialog::minPage() const
+{
+ Q_D(const QAbstractPrintDialog);
+ return d->pd->minPage;
+}
+
+/*!
+ Returns the maximum page in the page range. As of Qt 4.4, this
+ function returns INT_MAX by default. Previous versions returned 1
+ by default.
+*/
+int QAbstractPrintDialog::maxPage() const
+{
+ Q_D(const QAbstractPrintDialog);
+ return d->pd->maxPage;
+}
+
+/*!
+ Sets the range in the print dialog to be from \a from to \a to.
+*/
+void QAbstractPrintDialog::setFromTo(int from, int to)
+{
+ Q_D(QAbstractPrintDialog);
+ Q_ASSERT_X(from <= to, "QAbstractPrintDialog::setFromTo",
+ "'from' must be less than or equal to 'to'");
+ d->pd->fromPage = from;
+ d->pd->toPage = to;
+
+ if (d->pd->minPage == 0 && d->pd->maxPage == 0)
+ setMinMax(1, to);
+}
+
+/*!
+ Returns the first page to be printed
+ By default, this value is set to 0.
+*/
+int QAbstractPrintDialog::fromPage() const
+{
+ Q_D(const QAbstractPrintDialog);
+ return d->pd->fromPage;
+}
+
+/*!
+ Returns the last page to be printed.
+ By default, this value is set to 0.
+*/
+int QAbstractPrintDialog::toPage() const
+{
+ Q_D(const QAbstractPrintDialog);
+ return d->pd->toPage;
+}
+
+
+/*!
+ Returns the printer that this printer dialog operates
+ on.
+*/
+QPrinter *QAbstractPrintDialog::printer() const
+{
+ Q_D(const QAbstractPrintDialog);
+ return d->printer;
+}
+
+void QAbstractPrintDialogPrivate::setPrinter(QPrinter *newPrinter)
+{
+ if (newPrinter) {
+ printer = newPrinter;
+ ownsPrinter = false;
+ if (printer->fromPage() || printer->toPage())
+ options |= QAbstractPrintDialog::PrintPageRange;
+ } else {
+ printer = new QPrinter;
+ ownsPrinter = true;
+ }
+ pd = printer->d_func();
+}
+
+/*!
+ \fn int QAbstractPrintDialog::exec()
+
+ This virtual function is called to pop up the dialog. It must be
+ reimplemented in subclasses.
+*/
+
+/*!
+ \class QPrintDialog
+
+ \brief The QPrintDialog class provides a dialog for specifying
+ the printer's configuration.
+
+ \ingroup standard-dialogs
+ \ingroup printing
+
+ The dialog allows users to change document-related settings, such
+ as the paper size and orientation, type of print (color or
+ grayscale), range of pages, and number of copies to print.
+
+ Controls are also provided to enable users to choose from the
+ printers available, including any configured network printers.
+
+ Typically, QPrintDialog objects are constructed with a QPrinter
+ object, and executed using the exec() function.
+
+ \snippet doc/src/snippets/code/src_gui_dialogs_qabstractprintdialog.cpp 0
+
+ If the dialog is accepted by the user, the QPrinter object is
+ correctly configured for printing.
+
+ \table
+ \row
+ \o \inlineimage plastique-printdialog.png
+ \o \inlineimage plastique-printdialog-properties.png
+ \endtable
+
+ The printer dialog (shown above in Plastique style) enables access to common
+ printing properties. On X11 platforms that use the CUPS printing system, the
+ settings for each available printer can be modified via the dialog's
+ \gui{Properties} push button.
+
+ On Windows and Mac OS X, the native print dialog is used, which means that
+ some QWidget and QDialog properties set on the dialog won't be respected.
+ The native print dialog on Mac OS X does not support setting printer options,
+ i.e. setOptions() and setOption() have no effect.
+
+ In Qt 4.4, it was possible to use the static functions to show a sheet on
+ Mac OS X. This is no longer supported in Qt 4.5. If you want this
+ functionality, use QPrintDialog::open().
+
+ \sa QPageSetupDialog, QPrinter, {Pixelator Example}, {Order Form Example},
+ {Image Viewer Example}, {Scribble Example}
+*/
+
+/*!
+ \fn QPrintDialog::QPrintDialog(QPrinter *printer, QWidget *parent)
+
+ Constructs a new modal printer dialog for the given \a printer
+ with the given \a parent.
+*/
+
+/*!
+ \fn QPrintDialog::~QPrintDialog()
+
+ Destroys the print dialog.
+*/
+
+/*!
+ \fn int QPrintDialog::exec()
+ \reimp
+*/
+
+/*!
+ \since 4.4
+
+ Set a list of widgets as \a tabs to be shown on the print dialog, if supported.
+
+ Currently this option is only supported on X11.
+
+ Setting the option tabs will transfer their ownership to the print dialog.
+*/
+void QAbstractPrintDialog::setOptionTabs(const QList<QWidget*> &tabs)
+{
+ Q_D(QAbstractPrintDialog);
+ d->setTabs(tabs);
+}
+
+/*!
+
+ \fn void QPrintDialog::accepted(QPrinter *printer)
+
+ This signal is emitted when the user accepts the values set in the print dialog.
+ The \a printer parameter includes the printer that the settings were applied to.
+*/
+
+/*!
+ \fn QPrinter *QPrintDialog::printer()
+
+ Returns the printer that this printer dialog operates
+ on. This can be useful when using the QPrintDialog::open() method.
+*/
+
+/*!
+ Closes the dialog and sets its result code to \a result. If this dialog
+ is shown with exec(), done() causes the local event loop to finish,
+ and exec() to return \a result.
+
+ \sa QDialog::done()
+*/
+void QPrintDialog::done(int result)
+{
+ Q_D(QPrintDialog);
+ QDialog::done(result);
+ if (result == Accepted)
+ emit accepted(printer());
+ if (d->receiverToDisconnectOnClose) {
+ disconnect(this, SIGNAL(accepted(QPrinter*)),
+ d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
+ d->receiverToDisconnectOnClose = 0;
+ }
+ d->memberToDisconnectOnClose.clear();
+}
+
+/*!
+ \since 4.5
+ \overload
+
+ Opens the dialog and connects its accepted() signal to the slot specified
+ by \a receiver and \a member.
+
+ The signal will be disconnected from the slot when the dialog is closed.
+*/
+void QPrintDialog::open(QObject *receiver, const char *member)
+{
+ Q_D(QPrintDialog);
+ connect(this, SIGNAL(accepted(QPrinter*)), receiver, member);
+ d->receiverToDisconnectOnClose = receiver;
+ d->memberToDisconnectOnClose = member;
+ QDialog::open();
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_PRINTDIALOG
diff --git a/src/widgets/dialogs/qabstractprintdialog.h b/src/widgets/dialogs/qabstractprintdialog.h
new file mode 100644
index 0000000000..fe02c58598
--- /dev/null
+++ b/src/widgets/dialogs/qabstractprintdialog.h
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QABSTRACTPRINTDIALOG_H
+#define QABSTRACTPRINTDIALOG_H
+
+#include <QtWidgets/qdialog.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_PRINTER
+
+class QAbstractPrintDialogPrivate;
+class QPrinter;
+
+// ### Qt 5: remove this class
+class Q_GUI_EXPORT QAbstractPrintDialog : public QDialog
+{
+ Q_DECLARE_PRIVATE(QAbstractPrintDialog)
+ Q_OBJECT
+
+public:
+ // Keep in sync with QPrinter::PrintRange
+ enum PrintRange {
+ AllPages,
+ Selection,
+ PageRange,
+ CurrentPage
+ };
+
+ enum PrintDialogOption {
+ None = 0x0000, // obsolete
+ PrintToFile = 0x0001,
+ PrintSelection = 0x0002,
+ PrintPageRange = 0x0004,
+ PrintShowPageSize = 0x0008,
+ PrintCollateCopies = 0x0010,
+ DontUseSheet = 0x0020,
+ PrintCurrentPage = 0x0040
+ };
+
+ Q_DECLARE_FLAGS(PrintDialogOptions, PrintDialogOption)
+
+#ifndef QT_NO_PRINTDIALOG
+ explicit QAbstractPrintDialog(QPrinter *printer, QWidget *parent = 0);
+ ~QAbstractPrintDialog();
+
+ virtual int exec() = 0;
+
+ // obsolete
+ void addEnabledOption(PrintDialogOption option);
+ void setEnabledOptions(PrintDialogOptions options);
+ PrintDialogOptions enabledOptions() const;
+ bool isOptionEnabled(PrintDialogOption option) const;
+
+ void setOptionTabs(const QList<QWidget*> &tabs);
+
+ void setPrintRange(PrintRange range);
+ PrintRange printRange() const;
+
+ void setMinMax(int min, int max);
+ int minPage() const;
+ int maxPage() const;
+
+ void setFromTo(int fromPage, int toPage);
+ int fromPage() const;
+ int toPage() const;
+
+ QPrinter *printer() const;
+
+protected:
+ QAbstractPrintDialog(QAbstractPrintDialogPrivate &ptr, QPrinter *printer, QWidget *parent = 0);
+
+private:
+ Q_DISABLE_COPY(QAbstractPrintDialog)
+
+#endif // QT_NO_PRINTDIALOG
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractPrintDialog::PrintDialogOptions)
+
+#endif // QT_NO_PRINTER
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QABSTRACTPRINTDIALOG_H
diff --git a/src/widgets/dialogs/qabstractprintdialog_p.h b/src/widgets/dialogs/qabstractprintdialog_p.h
new file mode 100644
index 0000000000..0de093805f
--- /dev/null
+++ b/src/widgets/dialogs/qabstractprintdialog_p.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QABSTRACTPRINTDIALOG_P_H
+#define QABSTRACTPRINTDIALOG_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "private/qdialog_p.h"
+
+#ifndef QT_NO_PRINTDIALOG
+
+#include "QtWidgets/qabstractprintdialog.h"
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_PRINTER
+
+class QPrinter;
+class QPrinterPrivate;
+
+class QAbstractPrintDialogPrivate : public QDialogPrivate
+{
+ Q_DECLARE_PUBLIC(QAbstractPrintDialog)
+
+public:
+ QAbstractPrintDialogPrivate()
+ : printer(0), pd(0), ownsPrinter(false)
+ , options(QAbstractPrintDialog::PrintToFile | QAbstractPrintDialog::PrintPageRange |
+ QAbstractPrintDialog::PrintCollateCopies | QAbstractPrintDialog::PrintShowPageSize)
+ {
+ }
+
+ QPrinter *printer;
+ QPrinterPrivate *pd;
+ bool ownsPrinter;
+ QPointer<QObject> receiverToDisconnectOnClose;
+ QByteArray memberToDisconnectOnClose;
+
+ QAbstractPrintDialog::PrintDialogOptions options;
+
+ virtual void setTabs(const QList<QWidget *> &) {}
+ void setPrinter(QPrinter *newPrinter);
+};
+
+#endif //QT_NO_PRINTER
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_PRINTDIALOG
+
+#endif // QABSTRACTPRINTDIALOG_P_H
diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp
new file mode 100644
index 0000000000..f99e6c2621
--- /dev/null
+++ b/src/widgets/dialogs/qcolordialog.cpp
@@ -0,0 +1,2115 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qcolordialog_p.h"
+
+#ifndef QT_NO_COLORDIALOG
+
+#include "qapplication.h"
+#include "qdesktopwidget.h"
+#include "qdrawutil.h"
+#include "qevent.h"
+#include "qimage.h"
+#include "qdrag.h"
+#include "qlabel.h"
+#include "qlayout.h"
+#include "qlineedit.h"
+#include "qmenu.h"
+#include "qpainter.h"
+#include "qpixmap.h"
+#include "qpushbutton.h"
+#include "qsettings.h"
+#include "qstyle.h"
+#include "qstyleoption.h"
+#include "qvalidator.h"
+#include "qmime.h"
+#include "qspinbox.h"
+#include "qdialogbuttonbox.h"
+#include "private/qguiplatformplugin_p.h"
+
+#ifdef Q_WS_S60
+#include "private/qt_s60_p.h"
+#endif
+
+#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_5)
+# define QT_SMALL_COLORDIALOG
+#endif
+
+QT_BEGIN_NAMESPACE
+
+//////////// QWellArray BEGIN
+
+struct QWellArrayData;
+
+class QWellArray : public QWidget
+{
+ Q_OBJECT
+ Q_PROPERTY(int selectedColumn READ selectedColumn)
+ Q_PROPERTY(int selectedRow READ selectedRow)
+
+public:
+ QWellArray(int rows, int cols, QWidget* parent=0);
+ ~QWellArray() {}
+ QString cellContent(int row, int col) const;
+
+ int selectedColumn() const { return selCol; }
+ int selectedRow() const { return selRow; }
+
+ virtual void setCurrent(int row, int col);
+ virtual void setSelected(int row, int col);
+
+ QSize sizeHint() const;
+
+ virtual void setCellBrush(int row, int col, const QBrush &);
+ QBrush cellBrush(int row, int col);
+
+ inline int cellWidth() const
+ { return cellw; }
+
+ inline int cellHeight() const
+ { return cellh; }
+
+ inline int rowAt(int y) const
+ { return y / cellh; }
+
+ inline int columnAt(int x) const
+ { if (isRightToLeft()) return ncols - (x / cellw) - 1; return x / cellw; }
+
+ inline int rowY(int row) const
+ { return cellh * row; }
+
+ inline int columnX(int column) const
+ { if (isRightToLeft()) return cellw * (ncols - column - 1); return cellw * column; }
+
+ inline int numRows() const
+ { return nrows; }
+
+ inline int numCols() const
+ {return ncols; }
+
+ inline QRect cellRect() const
+ { return QRect(0, 0, cellw, cellh); }
+
+ inline QSize gridSize() const
+ { return QSize(ncols * cellw, nrows * cellh); }
+
+ QRect cellGeometry(int row, int column)
+ {
+ QRect r;
+ if (row >= 0 && row < nrows && column >= 0 && column < ncols)
+ r.setRect(columnX(column), rowY(row), cellw, cellh);
+ return r;
+ }
+
+ inline void updateCell(int row, int column) { update(cellGeometry(row, column)); }
+
+signals:
+ void selected(int row, int col);
+
+protected:
+ virtual void paintCell(QPainter *, int row, int col, const QRect&);
+ virtual void paintCellContents(QPainter *, int row, int col, const QRect&);
+
+ void mousePressEvent(QMouseEvent*);
+ void mouseReleaseEvent(QMouseEvent*);
+ void keyPressEvent(QKeyEvent*);
+ void focusInEvent(QFocusEvent*);
+ void focusOutEvent(QFocusEvent*);
+ void paintEvent(QPaintEvent *);
+
+private:
+ Q_DISABLE_COPY(QWellArray)
+
+ int nrows;
+ int ncols;
+ int cellw;
+ int cellh;
+ int curRow;
+ int curCol;
+ int selRow;
+ int selCol;
+ QWellArrayData *d;
+};
+
+void QWellArray::paintEvent(QPaintEvent *e)
+{
+ QRect r = e->rect();
+ int cx = r.x();
+ int cy = r.y();
+ int ch = r.height();
+ int cw = r.width();
+ int colfirst = columnAt(cx);
+ int collast = columnAt(cx + cw);
+ int rowfirst = rowAt(cy);
+ int rowlast = rowAt(cy + ch);
+
+ if (isRightToLeft()) {
+ int t = colfirst;
+ colfirst = collast;
+ collast = t;
+ }
+
+ QPainter painter(this);
+ QPainter *p = &painter;
+ QRect rect(0, 0, cellWidth(), cellHeight());
+
+
+ if (collast < 0 || collast >= ncols)
+ collast = ncols-1;
+ if (rowlast < 0 || rowlast >= nrows)
+ rowlast = nrows-1;
+
+ // Go through the rows
+ for (int r = rowfirst; r <= rowlast; ++r) {
+ // get row position and height
+ int rowp = rowY(r);
+
+ // Go through the columns in the row r
+ // if we know from where to where, go through [colfirst, collast],
+ // else go through all of them
+ for (int c = colfirst; c <= collast; ++c) {
+ // get position and width of column c
+ int colp = columnX(c);
+ // Translate painter and draw the cell
+ rect.translate(colp, rowp);
+ paintCell(p, r, c, rect);
+ rect.translate(-colp, -rowp);
+ }
+ }
+}
+
+struct QWellArrayData {
+ QBrush *brush;
+};
+
+QWellArray::QWellArray(int rows, int cols, QWidget *parent)
+ : QWidget(parent)
+ ,nrows(rows), ncols(cols)
+{
+ d = 0;
+ setFocusPolicy(Qt::StrongFocus);
+ cellw = 28;
+ cellh = 24;
+ curCol = 0;
+ curRow = 0;
+ selCol = -1;
+ selRow = -1;
+}
+
+QSize QWellArray::sizeHint() const
+{
+ ensurePolished();
+ return gridSize().boundedTo(QSize(640, 480));
+}
+
+
+void QWellArray::paintCell(QPainter* p, int row, int col, const QRect &rect)
+{
+ int b = 3; //margin
+
+ const QPalette & g = palette();
+ QStyleOptionFrame opt;
+ int dfw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
+ opt.lineWidth = dfw;
+ opt.midLineWidth = 1;
+ opt.rect = rect.adjusted(b, b, -b, -b);
+ opt.palette = g;
+ opt.state = QStyle::State_Enabled | QStyle::State_Sunken;
+ style()->drawPrimitive(QStyle::PE_Frame, &opt, p, this);
+ b += dfw;
+
+ if ((row == curRow) && (col == curCol)) {
+ if (hasFocus()) {
+ QStyleOptionFocusRect opt;
+ opt.palette = g;
+ opt.rect = rect;
+ opt.state = QStyle::State_None | QStyle::State_KeyboardFocusChange;
+ style()->drawPrimitive(QStyle::PE_FrameFocusRect, &opt, p, this);
+ }
+ }
+ paintCellContents(p, row, col, opt.rect.adjusted(dfw, dfw, -dfw, -dfw));
+}
+
+/*!
+ Reimplement this function to change the contents of the well array.
+ */
+void QWellArray::paintCellContents(QPainter *p, int row, int col, const QRect &r)
+{
+ if (d) {
+ p->fillRect(r, d->brush[row*numCols()+col]);
+ } else {
+ p->fillRect(r, Qt::white);
+ p->setPen(Qt::black);
+ p->drawLine(r.topLeft(), r.bottomRight());
+ p->drawLine(r.topRight(), r.bottomLeft());
+ }
+}
+
+void QWellArray::mousePressEvent(QMouseEvent *e)
+{
+ // The current cell marker is set to the cell the mouse is pressed in
+ QPoint pos = e->pos();
+ setCurrent(rowAt(pos.y()), columnAt(pos.x()));
+}
+
+void QWellArray::mouseReleaseEvent(QMouseEvent * /* event */)
+{
+ // The current cell marker is set to the cell the mouse is clicked in
+ setSelected(curRow, curCol);
+}
+
+
+/*
+ Sets the cell currently having the focus. This is not necessarily
+ the same as the currently selected cell.
+*/
+
+void QWellArray::setCurrent(int row, int col)
+{
+ if ((curRow == row) && (curCol == col))
+ return;
+
+ if (row < 0 || col < 0)
+ row = col = -1;
+
+ int oldRow = curRow;
+ int oldCol = curCol;
+
+ curRow = row;
+ curCol = col;
+
+ updateCell(oldRow, oldCol);
+ updateCell(curRow, curCol);
+}
+
+/*
+ Sets the currently selected cell to \a row, \a column. If \a row or
+ \a column are less than zero, the current cell is unselected.
+
+ Does not set the position of the focus indicator.
+*/
+void QWellArray::setSelected(int row, int col)
+{
+ int oldRow = selRow;
+ int oldCol = selCol;
+
+ if (row < 0 || col < 0)
+ row = col = -1;
+
+ selCol = col;
+ selRow = row;
+
+ updateCell(oldRow, oldCol);
+ updateCell(selRow, selCol);
+ if (row >= 0)
+ emit selected(row, col);
+
+#ifndef QT_NO_MENU
+ if (isVisible() && qobject_cast<QMenu*>(parentWidget()))
+ parentWidget()->close();
+#endif
+}
+
+void QWellArray::focusInEvent(QFocusEvent*)
+{
+ updateCell(curRow, curCol);
+}
+
+void QWellArray::setCellBrush(int row, int col, const QBrush &b)
+{
+ if (!d) {
+ d = new QWellArrayData;
+ int i = numRows()*numCols();
+ d->brush = new QBrush[i];
+ }
+ if (row >= 0 && row < numRows() && col >= 0 && col < numCols())
+ d->brush[row*numCols()+col] = b;
+}
+
+/*
+ Returns the brush set for the cell at \a row, \a column. If no brush is
+ set, Qt::NoBrush is returned.
+*/
+
+QBrush QWellArray::cellBrush(int row, int col)
+{
+ if (d && row >= 0 && row < numRows() && col >= 0 && col < numCols())
+ return d->brush[row*numCols()+col];
+ return Qt::NoBrush;
+}
+
+
+
+/*!\reimp
+*/
+
+void QWellArray::focusOutEvent(QFocusEvent*)
+{
+ updateCell(curRow, curCol);
+}
+
+/*\reimp
+*/
+void QWellArray::keyPressEvent(QKeyEvent* e)
+{
+ switch(e->key()) { // Look at the key code
+ case Qt::Key_Left: // If 'left arrow'-key,
+ if(curCol > 0) // and cr't not in leftmost col
+ setCurrent(curRow, curCol - 1); // set cr't to next left column
+ break;
+ case Qt::Key_Right: // Correspondingly...
+ if(curCol < numCols()-1)
+ setCurrent(curRow, curCol + 1);
+ break;
+ case Qt::Key_Up:
+ if(curRow > 0)
+ setCurrent(curRow - 1, curCol);
+ break;
+ case Qt::Key_Down:
+ if(curRow < numRows()-1)
+ setCurrent(curRow + 1, curCol);
+ break;
+#if 0
+ // bad idea that shouldn't have been implemented; very counterintuitive
+ case Qt::Key_Return:
+ case Qt::Key_Enter:
+ /*
+ ignore the key, so that the dialog get it, but still select
+ the current row/col
+ */
+ e->ignore();
+ // fallthrough intended
+#endif
+ case Qt::Key_Space:
+ setSelected(curRow, curCol);
+ break;
+ default: // If not an interesting key,
+ e->ignore(); // we don't accept the event
+ return;
+ }
+
+}
+
+//////////// QWellArray END
+
+static bool initrgb = false;
+static QRgb stdrgb[6*8];
+static QRgb cusrgb[2*8];
+static bool customSet = false;
+
+
+static void initRGB()
+{
+ if (initrgb)
+ return;
+ initrgb = true;
+ int i = 0;
+ for (int g = 0; g < 4; g++)
+ for (int r = 0; r < 4; r++)
+ for (int b = 0; b < 3; b++)
+ stdrgb[i++] = qRgb(r * 255 / 3, g * 255 / 3, b * 255 / 2);
+
+ for (i = 0; i < 2*8; i++)
+ cusrgb[i] = 0xffffffff;
+}
+
+/*!
+ Returns the number of custom colors supported by QColorDialog. All
+ color dialogs share the same custom colors.
+*/
+int QColorDialog::customCount()
+{
+ return 2 * 8;
+}
+
+/*!
+ \since 4.5
+
+ Returns the custom color at the given \a index as a QRgb value.
+*/
+QRgb QColorDialog::customColor(int index)
+{
+ if (uint(index) >= uint(customCount()))
+ return qRgb(255, 255, 255);
+ initRGB();
+ return cusrgb[index];
+}
+
+/*!
+ Sets the custom color at \a index to the QRgb \a color value.
+
+ \note This function does not apply to the Native Color Dialog on the Mac
+ OS X platform. If you still require this function, use the
+ QColorDialog::DontUseNativeDialog option.
+*/
+void QColorDialog::setCustomColor(int index, QRgb color)
+{
+ if (uint(index) >= uint(customCount()))
+ return;
+ initRGB();
+ customSet = true;
+ cusrgb[index] = color;
+}
+
+/*!
+ Sets the standard color at \a index to the QRgb \a color value.
+
+ \note This function does not apply to the Native Color Dialog on the Mac
+ OS X platform. If you still require this function, use the
+ QColorDialog::DontUseNativeDialog option.
+*/
+
+void QColorDialog::setStandardColor(int index, QRgb color)
+{
+ if (uint(index) >= uint(6 * 8))
+ return;
+ initRGB();
+ stdrgb[index] = color;
+}
+
+static inline void rgb2hsv(QRgb rgb, int &h, int &s, int &v)
+{
+ QColor c;
+ c.setRgb(rgb);
+ c.getHsv(&h, &s, &v);
+}
+
+class QColorWell : public QWellArray
+{
+public:
+ QColorWell(QWidget *parent, int r, int c, QRgb *vals)
+ :QWellArray(r, c, parent), values(vals), mousePressed(false), oldCurrent(-1, -1)
+ { setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); }
+
+protected:
+ void paintCellContents(QPainter *, int row, int col, const QRect&);
+ void mousePressEvent(QMouseEvent *e);
+ void mouseMoveEvent(QMouseEvent *e);
+ void mouseReleaseEvent(QMouseEvent *e);
+#ifndef QT_NO_DRAGANDDROP
+ void dragEnterEvent(QDragEnterEvent *e);
+ void dragLeaveEvent(QDragLeaveEvent *e);
+ void dragMoveEvent(QDragMoveEvent *e);
+ void dropEvent(QDropEvent *e);
+#endif
+
+private:
+ QRgb *values;
+ bool mousePressed;
+ QPoint pressPos;
+ QPoint oldCurrent;
+
+};
+
+void QColorWell::paintCellContents(QPainter *p, int row, int col, const QRect &r)
+{
+ int i = row + col*numRows();
+ p->fillRect(r, QColor(values[i]));
+}
+
+void QColorWell::mousePressEvent(QMouseEvent *e)
+{
+ oldCurrent = QPoint(selectedRow(), selectedColumn());
+ QWellArray::mousePressEvent(e);
+ mousePressed = true;
+ pressPos = e->pos();
+}
+
+void QColorWell::mouseMoveEvent(QMouseEvent *e)
+{
+ QWellArray::mouseMoveEvent(e);
+#ifndef QT_NO_DRAGANDDROP
+ if (!mousePressed)
+ return;
+ if ((pressPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) {
+ setCurrent(oldCurrent.x(), oldCurrent.y());
+ int i = rowAt(pressPos.y()) + columnAt(pressPos.x()) * numRows();
+ QColor col(values[i]);
+ QMimeData *mime = new QMimeData;
+ mime->setColorData(col);
+ QPixmap pix(cellWidth(), cellHeight());
+ pix.fill(col);
+ QPainter p(&pix);
+ p.drawRect(0, 0, pix.width() - 1, pix.height() - 1);
+ p.end();
+ QDrag *drg = new QDrag(this);
+ drg->setMimeData(mime);
+ drg->setPixmap(pix);
+ mousePressed = false;
+ drg->start();
+ }
+#endif
+}
+
+#ifndef QT_NO_DRAGANDDROP
+void QColorWell::dragEnterEvent(QDragEnterEvent *e)
+{
+ if (qvariant_cast<QColor>(e->mimeData()->colorData()).isValid())
+ e->accept();
+ else
+ e->ignore();
+}
+
+void QColorWell::dragLeaveEvent(QDragLeaveEvent *)
+{
+ if (hasFocus())
+ parentWidget()->setFocus();
+}
+
+void QColorWell::dragMoveEvent(QDragMoveEvent *e)
+{
+ if (qvariant_cast<QColor>(e->mimeData()->colorData()).isValid()) {
+ setCurrent(rowAt(e->pos().y()), columnAt(e->pos().x()));
+ e->accept();
+ } else {
+ e->ignore();
+ }
+}
+
+void QColorWell::dropEvent(QDropEvent *e)
+{
+ QColor col = qvariant_cast<QColor>(e->mimeData()->colorData());
+ if (col.isValid()) {
+ int i = rowAt(e->pos().y()) + columnAt(e->pos().x()) * numRows();
+ values[i] = col.rgb();
+ update();
+ e->accept();
+ } else {
+ e->ignore();
+ }
+}
+
+#endif // QT_NO_DRAGANDDROP
+
+void QColorWell::mouseReleaseEvent(QMouseEvent *e)
+{
+ if (!mousePressed)
+ return;
+ QWellArray::mouseReleaseEvent(e);
+ mousePressed = false;
+}
+
+class QColorPicker : public QFrame
+{
+ Q_OBJECT
+public:
+ QColorPicker(QWidget* parent);
+ ~QColorPicker();
+
+public slots:
+ void setCol(int h, int s);
+
+signals:
+ void newCol(int h, int s);
+
+protected:
+ QSize sizeHint() const;
+ void paintEvent(QPaintEvent*);
+ void mouseMoveEvent(QMouseEvent *);
+ void mousePressEvent(QMouseEvent *);
+ void resizeEvent(QResizeEvent *);
+
+private:
+ int hue;
+ int sat;
+
+ QPoint colPt();
+ int huePt(const QPoint &pt);
+ int satPt(const QPoint &pt);
+ void setCol(const QPoint &pt);
+
+ QPixmap pix;
+};
+
+static int pWidth = 220;
+static int pHeight = 200;
+
+class QColorLuminancePicker : public QWidget
+{
+ Q_OBJECT
+public:
+ QColorLuminancePicker(QWidget* parent=0);
+ ~QColorLuminancePicker();
+
+public slots:
+ void setCol(int h, int s, int v);
+ void setCol(int h, int s);
+
+signals:
+ void newHsv(int h, int s, int v);
+
+protected:
+ void paintEvent(QPaintEvent*);
+ void mouseMoveEvent(QMouseEvent *);
+ void mousePressEvent(QMouseEvent *);
+
+private:
+ enum { foff = 3, coff = 4 }; //frame and contents offset
+ int val;
+ int hue;
+ int sat;
+
+ int y2val(int y);
+ int val2y(int val);
+ void setVal(int v);
+
+ QPixmap *pix;
+};
+
+
+int QColorLuminancePicker::y2val(int y)
+{
+ int d = height() - 2*coff - 1;
+ return 255 - (y - coff)*255/d;
+}
+
+int QColorLuminancePicker::val2y(int v)
+{
+ int d = height() - 2*coff - 1;
+ return coff + (255-v)*d/255;
+}
+
+QColorLuminancePicker::QColorLuminancePicker(QWidget* parent)
+ :QWidget(parent)
+{
+ hue = 100; val = 100; sat = 100;
+ pix = 0;
+ // setAttribute(WA_NoErase, true);
+}
+
+QColorLuminancePicker::~QColorLuminancePicker()
+{
+ delete pix;
+}
+
+void QColorLuminancePicker::mouseMoveEvent(QMouseEvent *m)
+{
+ setVal(y2val(m->y()));
+}
+void QColorLuminancePicker::mousePressEvent(QMouseEvent *m)
+{
+ setVal(y2val(m->y()));
+}
+
+void QColorLuminancePicker::setVal(int v)
+{
+ if (val == v)
+ return;
+ val = qMax(0, qMin(v,255));
+ delete pix; pix=0;
+ repaint();
+ emit newHsv(hue, sat, val);
+}
+
+//receives from a hue,sat chooser and relays.
+void QColorLuminancePicker::setCol(int h, int s)
+{
+ setCol(h, s, val);
+ emit newHsv(h, s, val);
+}
+
+void QColorLuminancePicker::paintEvent(QPaintEvent *)
+{
+ int w = width() - 5;
+
+ QRect r(0, foff, w, height() - 2*foff);
+ int wi = r.width() - 2;
+ int hi = r.height() - 2;
+ if (!pix || pix->height() != hi || pix->width() != wi) {
+ delete pix;
+ QImage img(wi, hi, QImage::Format_RGB32);
+ int y;
+ uint *pixel = (uint *) img.scanLine(0);
+ for (y = 0; y < hi; y++) {
+ const uint *end = pixel + wi;
+ while (pixel < end) {
+ QColor c;
+ c.setHsv(hue, sat, y2val(y+coff));
+ *pixel = c.rgb();
+ ++pixel;
+ }
+ }
+ pix = new QPixmap(QPixmap::fromImage(img));
+ }
+ QPainter p(this);
+ p.drawPixmap(1, coff, *pix);
+ const QPalette &g = palette();
+ qDrawShadePanel(&p, r, g, true);
+ p.setPen(g.foreground().color());
+ p.setBrush(g.foreground());
+ QPolygon a;
+ int y = val2y(val);
+ a.setPoints(3, w, y, w+5, y+5, w+5, y-5);
+ p.eraseRect(w, 0, 5, height());
+ p.drawPolygon(a);
+}
+
+void QColorLuminancePicker::setCol(int h, int s , int v)
+{
+ val = v;
+ hue = h;
+ sat = s;
+ delete pix; pix=0;
+ repaint();
+}
+
+QPoint QColorPicker::colPt()
+{
+ QRect r = contentsRect();
+ return QPoint((360 - hue) * (r.width() - 1) / 360, (255 - sat) * (r.height() - 1) / 255);
+}
+
+int QColorPicker::huePt(const QPoint &pt)
+{
+ QRect r = contentsRect();
+ return 360 - pt.x() * 360 / (r.width() - 1);
+}
+
+int QColorPicker::satPt(const QPoint &pt)
+{
+ QRect r = contentsRect();
+ return 255 - pt.y() * 255 / (r.height() - 1);
+}
+
+void QColorPicker::setCol(const QPoint &pt)
+{
+ setCol(huePt(pt), satPt(pt));
+}
+
+QColorPicker::QColorPicker(QWidget* parent)
+ : QFrame(parent)
+{
+ hue = 0; sat = 0;
+ setCol(150, 255);
+
+ setAttribute(Qt::WA_NoSystemBackground);
+ setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed) );
+}
+
+QColorPicker::~QColorPicker()
+{
+}
+
+QSize QColorPicker::sizeHint() const
+{
+ return QSize(pWidth + 2*frameWidth(), pHeight + 2*frameWidth());
+}
+
+void QColorPicker::setCol(int h, int s)
+{
+ int nhue = qMin(qMax(0,h), 359);
+ int nsat = qMin(qMax(0,s), 255);
+ if (nhue == hue && nsat == sat)
+ return;
+
+ QRect r(colPt(), QSize(20,20));
+ hue = nhue; sat = nsat;
+ r = r.united(QRect(colPt(), QSize(20,20)));
+ r.translate(contentsRect().x()-9, contentsRect().y()-9);
+ // update(r);
+ repaint(r);
+}
+
+void QColorPicker::mouseMoveEvent(QMouseEvent *m)
+{
+ QPoint p = m->pos() - contentsRect().topLeft();
+ setCol(p);
+ emit newCol(hue, sat);
+}
+
+void QColorPicker::mousePressEvent(QMouseEvent *m)
+{
+ QPoint p = m->pos() - contentsRect().topLeft();
+ setCol(p);
+ emit newCol(hue, sat);
+}
+
+void QColorPicker::paintEvent(QPaintEvent* )
+{
+ QPainter p(this);
+ drawFrame(&p);
+ QRect r = contentsRect();
+
+ p.drawPixmap(r.topLeft(), pix);
+ QPoint pt = colPt() + r.topLeft();
+ p.setPen(Qt::black);
+
+ p.fillRect(pt.x()-9, pt.y(), 20, 2, Qt::black);
+ p.fillRect(pt.x(), pt.y()-9, 2, 20, Qt::black);
+
+}
+
+void QColorPicker::resizeEvent(QResizeEvent *ev)
+{
+ QFrame::resizeEvent(ev);
+
+ int w = width() - frameWidth() * 2;
+ int h = height() - frameWidth() * 2;
+ QImage img(w, h, QImage::Format_RGB32);
+ int x, y;
+ uint *pixel = (uint *) img.scanLine(0);
+ for (y = 0; y < h; y++) {
+ const uint *end = pixel + w;
+ x = 0;
+ while (pixel < end) {
+ QPoint p(x, y);
+ QColor c;
+ c.setHsv(huePt(p), satPt(p), 200);
+ *pixel = c.rgb();
+ ++pixel;
+ ++x;
+ }
+ }
+ pix = QPixmap::fromImage(img);
+}
+
+
+class QColSpinBox : public QSpinBox
+{
+public:
+ QColSpinBox(QWidget *parent)
+ : QSpinBox(parent) { setRange(0, 255); }
+ void setValue(int i) {
+ bool block = signalsBlocked();
+ blockSignals(true);
+ QSpinBox::setValue(i);
+ blockSignals(block);
+ }
+};
+
+class QColorShowLabel;
+
+class QColorShower : public QWidget
+{
+ Q_OBJECT
+public:
+ QColorShower(QColorDialog *parent);
+
+ //things that don't emit signals
+ void setHsv(int h, int s, int v);
+
+ int currentAlpha() const
+ { return (colorDialog->options() & QColorDialog::ShowAlphaChannel) ? alphaEd->value() : 255; }
+ void setCurrentAlpha(int a) { alphaEd->setValue(a); rgbEd(); }
+ void showAlpha(bool b);
+ bool isAlphaVisible() const;
+
+ QRgb currentColor() const { return curCol; }
+ QColor currentQColor() const { return curQColor; }
+ void retranslateStrings();
+ void updateQColor();
+
+public slots:
+ void setRgb(QRgb rgb);
+
+signals:
+ void newCol(QRgb rgb);
+ void currentColorChanged(const QColor &color);
+
+private slots:
+ void rgbEd();
+ void hsvEd();
+private:
+ void showCurrentColor();
+ int hue, sat, val;
+ QRgb curCol;
+ QColor curQColor;
+ QLabel *lblHue;
+ QLabel *lblSat;
+ QLabel *lblVal;
+ QLabel *lblRed;
+ QLabel *lblGreen;
+ QLabel *lblBlue;
+ QColSpinBox *hEd;
+ QColSpinBox *sEd;
+ QColSpinBox *vEd;
+ QColSpinBox *rEd;
+ QColSpinBox *gEd;
+ QColSpinBox *bEd;
+ QColSpinBox *alphaEd;
+ QLabel *alphaLab;
+ QColorShowLabel *lab;
+ bool rgbOriginal;
+ QColorDialog *colorDialog;
+
+ friend class QColorDialog;
+ friend class QColorDialogPrivate;
+};
+
+class QColorShowLabel : public QFrame
+{
+ Q_OBJECT
+
+public:
+ QColorShowLabel(QWidget *parent) : QFrame(parent) {
+ setFrameStyle(QFrame::Panel|QFrame::Sunken);
+ setAcceptDrops(true);
+ mousePressed = false;
+ }
+ void setColor(QColor c) { col = c; }
+
+signals:
+ void colorDropped(QRgb);
+
+protected:
+ void paintEvent(QPaintEvent *);
+ void mousePressEvent(QMouseEvent *e);
+ void mouseMoveEvent(QMouseEvent *e);
+ void mouseReleaseEvent(QMouseEvent *e);
+#ifndef QT_NO_DRAGANDDROP
+ void dragEnterEvent(QDragEnterEvent *e);
+ void dragLeaveEvent(QDragLeaveEvent *e);
+ void dropEvent(QDropEvent *e);
+#endif
+
+private:
+ QColor col;
+ bool mousePressed;
+ QPoint pressPos;
+};
+
+void QColorShowLabel::paintEvent(QPaintEvent *e)
+{
+ QPainter p(this);
+ drawFrame(&p);
+ p.fillRect(contentsRect()&e->rect(), col);
+}
+
+void QColorShower::showAlpha(bool b)
+{
+ alphaLab->setVisible(b);
+ alphaEd->setVisible(b);
+}
+
+inline bool QColorShower::isAlphaVisible() const
+{
+ return alphaLab->isVisible();
+}
+
+void QColorShowLabel::mousePressEvent(QMouseEvent *e)
+{
+ mousePressed = true;
+ pressPos = e->pos();
+}
+
+void QColorShowLabel::mouseMoveEvent(QMouseEvent *e)
+{
+#ifdef QT_NO_DRAGANDDROP
+ Q_UNUSED(e);
+#else
+ if (!mousePressed)
+ return;
+ if ((pressPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) {
+ QMimeData *mime = new QMimeData;
+ mime->setColorData(col);
+ QPixmap pix(30, 20);
+ pix.fill(col);
+ QPainter p(&pix);
+ p.drawRect(0, 0, pix.width() - 1, pix.height() - 1);
+ p.end();
+ QDrag *drg = new QDrag(this);
+ drg->setMimeData(mime);
+ drg->setPixmap(pix);
+ mousePressed = false;
+ drg->start();
+ }
+#endif
+}
+
+#ifndef QT_NO_DRAGANDDROP
+void QColorShowLabel::dragEnterEvent(QDragEnterEvent *e)
+{
+ if (qvariant_cast<QColor>(e->mimeData()->colorData()).isValid())
+ e->accept();
+ else
+ e->ignore();
+}
+
+void QColorShowLabel::dragLeaveEvent(QDragLeaveEvent *)
+{
+}
+
+void QColorShowLabel::dropEvent(QDropEvent *e)
+{
+ QColor color = qvariant_cast<QColor>(e->mimeData()->colorData());
+ if (color.isValid()) {
+ col = color;
+ repaint();
+ emit colorDropped(col.rgb());
+ e->accept();
+ } else {
+ e->ignore();
+ }
+}
+#endif // QT_NO_DRAGANDDROP
+
+void QColorShowLabel::mouseReleaseEvent(QMouseEvent *)
+{
+ if (!mousePressed)
+ return;
+ mousePressed = false;
+}
+
+QColorShower::QColorShower(QColorDialog *parent)
+ : QWidget(parent)
+{
+ colorDialog = parent;
+
+ curCol = qRgb(255, 255, 255);
+ curQColor = Qt::white;
+
+ QGridLayout *gl = new QGridLayout(this);
+ gl->setMargin(gl->spacing());
+ lab = new QColorShowLabel(this);
+
+#ifdef QT_SMALL_COLORDIALOG
+# ifdef Q_WS_S60
+ const bool nonTouchUI = !S60->hasTouchscreen;
+# elif defined Q_WS_MAEMO_5
+ const bool nonTouchUI = false;
+# endif
+#endif
+
+#ifndef Q_WS_WINCE
+#ifdef QT_SMALL_COLORDIALOG
+ lab->setMinimumHeight(60);
+#endif
+ lab->setMinimumWidth(60);
+#else
+ lab->setMinimumWidth(20);
+#endif
+
+// In S60, due to small screen and different screen layouts need to re-arrange the widgets.
+// For QVGA screens only the comboboxes and color label are visible.
+// For nHD screens only color and luminence pickers and color label are visible.
+#if !defined(QT_SMALL_COLORDIALOG)
+ gl->addWidget(lab, 0, 0, -1, 1);
+#else
+ if (nonTouchUI)
+ gl->addWidget(lab, 0, 0, 1, -1);
+ else
+ gl->addWidget(lab, 0, 0, -1, 1);
+#endif
+ connect(lab, SIGNAL(colorDropped(QRgb)), this, SIGNAL(newCol(QRgb)));
+ connect(lab, SIGNAL(colorDropped(QRgb)), this, SLOT(setRgb(QRgb)));
+
+ hEd = new QColSpinBox(this);
+ hEd->setRange(0, 359);
+ lblHue = new QLabel(this);
+#ifndef QT_NO_SHORTCUT
+ lblHue->setBuddy(hEd);
+#endif
+ lblHue->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+#if !defined(QT_SMALL_COLORDIALOG)
+ gl->addWidget(lblHue, 0, 1);
+ gl->addWidget(hEd, 0, 2);
+#else
+ if (nonTouchUI) {
+ gl->addWidget(lblHue, 1, 0);
+ gl->addWidget(hEd, 2, 0);
+ } else {
+ lblHue->hide();
+ hEd->hide();
+ }
+#endif
+
+ sEd = new QColSpinBox(this);
+ lblSat = new QLabel(this);
+#ifndef QT_NO_SHORTCUT
+ lblSat->setBuddy(sEd);
+#endif
+ lblSat->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+#if !defined(QT_SMALL_COLORDIALOG)
+ gl->addWidget(lblSat, 1, 1);
+ gl->addWidget(sEd, 1, 2);
+#else
+ if (nonTouchUI) {
+ gl->addWidget(lblSat, 1, 1);
+ gl->addWidget(sEd, 2, 1);
+ } else {
+ lblSat->hide();
+ sEd->hide();
+ }
+#endif
+
+ vEd = new QColSpinBox(this);
+ lblVal = new QLabel(this);
+#ifndef QT_NO_SHORTCUT
+ lblVal->setBuddy(vEd);
+#endif
+ lblVal->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+#if !defined(QT_SMALL_COLORDIALOG)
+ gl->addWidget(lblVal, 2, 1);
+ gl->addWidget(vEd, 2, 2);
+#else
+ if (nonTouchUI) {
+ gl->addWidget(lblVal, 1, 2);
+ gl->addWidget(vEd, 2, 2);
+ } else {
+ lblVal->hide();
+ vEd->hide();
+ }
+#endif
+
+ rEd = new QColSpinBox(this);
+ lblRed = new QLabel(this);
+#ifndef QT_NO_SHORTCUT
+ lblRed->setBuddy(rEd);
+#endif
+ lblRed->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+#if !defined(QT_SMALL_COLORDIALOG)
+ gl->addWidget(lblRed, 0, 3);
+ gl->addWidget(rEd, 0, 4);
+#else
+ if (nonTouchUI) {
+ gl->addWidget(lblRed, 3, 0);
+ gl->addWidget(rEd, 4, 0);
+ } else {
+ lblRed->hide();
+ rEd->hide();
+ }
+#endif
+
+ gEd = new QColSpinBox(this);
+ lblGreen = new QLabel(this);
+#ifndef QT_NO_SHORTCUT
+ lblGreen->setBuddy(gEd);
+#endif
+ lblGreen->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+#if !defined(QT_SMALL_COLORDIALOG)
+ gl->addWidget(lblGreen, 1, 3);
+ gl->addWidget(gEd, 1, 4);
+#else
+ if (nonTouchUI) {
+ gl->addWidget(lblGreen, 3, 1);
+ gl->addWidget(gEd, 4, 1);
+ } else {
+ lblGreen->hide();
+ gEd->hide();
+ }
+#endif
+
+ bEd = new QColSpinBox(this);
+ lblBlue = new QLabel(this);
+#ifndef QT_NO_SHORTCUT
+ lblBlue->setBuddy(bEd);
+#endif
+ lblBlue->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+#if !defined(QT_SMALL_COLORDIALOG)
+ gl->addWidget(lblBlue, 2, 3);
+ gl->addWidget(bEd, 2, 4);
+#else
+ if (nonTouchUI) {
+ gl->addWidget(lblBlue, 3, 2);
+ gl->addWidget(bEd, 4, 2);
+ } else {
+ lblBlue->hide();
+ bEd->hide();
+ }
+#endif
+
+ alphaEd = new QColSpinBox(this);
+ alphaLab = new QLabel(this);
+#ifndef QT_NO_SHORTCUT
+ alphaLab->setBuddy(alphaEd);
+#endif
+ alphaLab->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+#if !defined(QT_SMALL_COLORDIALOG)
+ gl->addWidget(alphaLab, 3, 1, 1, 3);
+ gl->addWidget(alphaEd, 3, 4);
+#else
+ if (nonTouchUI) {
+ gl->addWidget(alphaLab, 1, 3, 3, 1);
+ gl->addWidget(alphaEd, 4, 3);
+ } else {
+ alphaLab->hide();
+ alphaEd->hide();
+ }
+#endif
+ alphaEd->hide();
+ alphaLab->hide();
+
+ connect(hEd, SIGNAL(valueChanged(int)), this, SLOT(hsvEd()));
+ connect(sEd, SIGNAL(valueChanged(int)), this, SLOT(hsvEd()));
+ connect(vEd, SIGNAL(valueChanged(int)), this, SLOT(hsvEd()));
+
+ connect(rEd, SIGNAL(valueChanged(int)), this, SLOT(rgbEd()));
+ connect(gEd, SIGNAL(valueChanged(int)), this, SLOT(rgbEd()));
+ connect(bEd, SIGNAL(valueChanged(int)), this, SLOT(rgbEd()));
+ connect(alphaEd, SIGNAL(valueChanged(int)), this, SLOT(rgbEd()));
+
+ retranslateStrings();
+}
+
+inline QRgb QColorDialogPrivate::currentColor() const { return cs->currentColor(); }
+inline int QColorDialogPrivate::currentAlpha() const { return cs->currentAlpha(); }
+inline void QColorDialogPrivate::setCurrentAlpha(int a) { cs->setCurrentAlpha(a); }
+inline void QColorDialogPrivate::showAlpha(bool b) { cs->showAlpha(b); }
+inline bool QColorDialogPrivate::isAlphaVisible() const { return cs->isAlphaVisible(); }
+
+QColor QColorDialogPrivate::currentQColor() const
+{
+ return cs->currentQColor();
+}
+
+void QColorShower::showCurrentColor()
+{
+ lab->setColor(currentColor());
+ lab->repaint();
+}
+
+void QColorShower::rgbEd()
+{
+ rgbOriginal = true;
+ curCol = qRgba(rEd->value(), gEd->value(), bEd->value(), currentAlpha());
+
+ rgb2hsv(currentColor(), hue, sat, val);
+
+ hEd->setValue(hue);
+ sEd->setValue(sat);
+ vEd->setValue(val);
+
+ showCurrentColor();
+ emit newCol(currentColor());
+ updateQColor();
+}
+
+void QColorShower::hsvEd()
+{
+ rgbOriginal = false;
+ hue = hEd->value();
+ sat = sEd->value();
+ val = vEd->value();
+
+ QColor c;
+ c.setHsv(hue, sat, val);
+ curCol = c.rgb();
+
+ rEd->setValue(qRed(currentColor()));
+ gEd->setValue(qGreen(currentColor()));
+ bEd->setValue(qBlue(currentColor()));
+
+ showCurrentColor();
+ emit newCol(currentColor());
+ updateQColor();
+}
+
+void QColorShower::setRgb(QRgb rgb)
+{
+ rgbOriginal = true;
+ curCol = rgb;
+
+ rgb2hsv(currentColor(), hue, sat, val);
+
+ hEd->setValue(hue);
+ sEd->setValue(sat);
+ vEd->setValue(val);
+
+ rEd->setValue(qRed(currentColor()));
+ gEd->setValue(qGreen(currentColor()));
+ bEd->setValue(qBlue(currentColor()));
+
+ showCurrentColor();
+ updateQColor();
+}
+
+void QColorShower::setHsv(int h, int s, int v)
+{
+ if (h < -1 || (uint)s > 255 || (uint)v > 255)
+ return;
+
+ rgbOriginal = false;
+ hue = h; val = v; sat = s;
+ QColor c;
+ c.setHsv(hue, sat, val);
+ curCol = c.rgb();
+
+ hEd->setValue(hue);
+ sEd->setValue(sat);
+ vEd->setValue(val);
+
+ rEd->setValue(qRed(currentColor()));
+ gEd->setValue(qGreen(currentColor()));
+ bEd->setValue(qBlue(currentColor()));
+
+ showCurrentColor();
+ updateQColor();
+}
+
+void QColorShower::retranslateStrings()
+{
+ lblHue->setText(QColorDialog::tr("Hu&e:"));
+ lblSat->setText(QColorDialog::tr("&Sat:"));
+ lblVal->setText(QColorDialog::tr("&Val:"));
+ lblRed->setText(QColorDialog::tr("&Red:"));
+ lblGreen->setText(QColorDialog::tr("&Green:"));
+ lblBlue->setText(QColorDialog::tr("Bl&ue:"));
+ alphaLab->setText(QColorDialog::tr("A&lpha channel:"));
+}
+
+void QColorShower::updateQColor()
+{
+ QColor oldQColor(curQColor);
+ curQColor.setRgba(qRgba(qRed(curCol), qGreen(curCol), qBlue(curCol), currentAlpha()));
+ if (curQColor != oldQColor)
+ emit currentColorChanged(curQColor);
+}
+
+//sets all widgets to display h,s,v
+void QColorDialogPrivate::_q_newHsv(int h, int s, int v)
+{
+ cs->setHsv(h, s, v);
+ cp->setCol(h, s);
+ lp->setCol(h, s, v);
+}
+
+//sets all widgets to display rgb
+void QColorDialogPrivate::setCurrentColor(QRgb rgb)
+{
+ cs->setRgb(rgb);
+ _q_newColorTypedIn(rgb);
+}
+
+// hack; doesn't keep curCol in sync, so use with care
+void QColorDialogPrivate::setCurrentQColor(const QColor &color)
+{
+ Q_Q(QColorDialog);
+ if (cs->curQColor != color) {
+ cs->curQColor = color;
+ emit q->currentColorChanged(color);
+ }
+}
+
+bool QColorDialogPrivate::selectColor(const QColor &col)
+{
+ QRgb color = col.rgb();
+ int i = 0, j = 0;
+ // Check standard colors
+ if (standard) {
+ for (i = 0; i < 6; i++) {
+ for (j = 0; j < 8; j++) {
+ if (color == stdrgb[i + j*6]) {
+ _q_newStandard(i, j);
+ standard->setCurrent(i, j);
+ standard->setSelected(i, j);
+ standard->setFocus();
+ return true;
+ }
+ }
+ }
+ }
+ // Check custom colors
+ if (custom) {
+ for (i = 0; i < 2; i++) {
+ for (j = 0; j < 8; j++) {
+ if (color == cusrgb[i + j*2]) {
+ _q_newCustom(i, j);
+ custom->setCurrent(i, j);
+ custom->setSelected(i, j);
+ custom->setFocus();
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
+//sets all widgets except cs to display rgb
+void QColorDialogPrivate::_q_newColorTypedIn(QRgb rgb)
+{
+ int h, s, v;
+ rgb2hsv(rgb, h, s, v);
+ cp->setCol(h, s);
+ lp->setCol(h, s, v);
+}
+
+void QColorDialogPrivate::_q_newCustom(int r, int c)
+{
+ int i = r+2*c;
+ setCurrentColor(cusrgb[i]);
+ nextCust = i;
+ if (standard)
+ standard->setSelected(-1,-1);
+}
+
+void QColorDialogPrivate::_q_newStandard(int r, int c)
+{
+ setCurrentColor(stdrgb[r+c*6]);
+ if (custom)
+ custom->setSelected(-1,-1);
+}
+
+void QColorDialogPrivate::init(const QColor &initial)
+{
+ Q_Q(QColorDialog);
+
+ q->setSizeGripEnabled(false);
+ q->setWindowTitle(QColorDialog::tr("Select Color"));
+
+ nativeDialogInUse = false;
+
+ nextCust = 0;
+ QVBoxLayout *mainLay = new QVBoxLayout(q);
+ // there's nothing in this dialog that benefits from sizing up
+ mainLay->setSizeConstraint(QLayout::SetFixedSize);
+
+ QHBoxLayout *topLay = new QHBoxLayout();
+ mainLay->addLayout(topLay);
+
+ leftLay = 0;
+
+#if defined(Q_WS_WINCE) || defined(QT_SMALL_COLORDIALOG)
+ smallDisplay = true;
+ const int lumSpace = 20;
+#else
+ // small displays (e.g. PDAs) cannot fit the full color dialog,
+ // so just use the color picker.
+ smallDisplay = (QApplication::desktop()->width() < 480 || QApplication::desktop()->height() < 350);
+ const int lumSpace = topLay->spacing() / 2;
+#endif
+
+ if (!smallDisplay) {
+ leftLay = new QVBoxLayout;
+ topLay->addLayout(leftLay);
+ }
+
+ initRGB();
+
+#ifndef QT_NO_SETTINGS
+ if (!customSet) {
+ QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
+ for (int i = 0; i < 2*8; ++i) {
+ QVariant v = settings.value(QLatin1String("Qt/customColors/") + QString::number(i));
+ if (v.isValid()) {
+ QRgb rgb = v.toUInt();
+ cusrgb[i] = rgb;
+ }
+ }
+ }
+#endif
+
+#if defined(QT_SMALL_COLORDIALOG)
+# if defined(Q_WS_S60)
+ const bool nonTouchUI = !S60->hasTouchscreen;
+# elif defined(Q_WS_MAEMO_5)
+ const bool nonTouchUI = false;
+# endif
+#endif
+
+ if (!smallDisplay) {
+ standard = new QColorWell(q, 6, 8, stdrgb);
+ lblBasicColors = new QLabel(q);
+#ifndef QT_NO_SHORTCUT
+ lblBasicColors->setBuddy(standard);
+#endif
+ q->connect(standard, SIGNAL(selected(int,int)), SLOT(_q_newStandard(int,int)));
+ leftLay->addWidget(lblBasicColors);
+ leftLay->addWidget(standard);
+
+#if !defined(Q_WS_WINCE)
+ leftLay->addStretch();
+#endif
+
+ custom = new QColorWell(q, 2, 8, cusrgb);
+ custom->setAcceptDrops(true);
+
+ q->connect(custom, SIGNAL(selected(int,int)), SLOT(_q_newCustom(int,int)));
+ lblCustomColors = new QLabel(q);
+#ifndef QT_NO_SHORTCUT
+ lblCustomColors->setBuddy(custom);
+#endif
+ leftLay->addWidget(lblCustomColors);
+ leftLay->addWidget(custom);
+
+ addCusBt = new QPushButton(q);
+ QObject::connect(addCusBt, SIGNAL(clicked()), q, SLOT(_q_addCustom()));
+ leftLay->addWidget(addCusBt);
+ } else {
+ // better color picker size for small displays
+#if defined(QT_SMALL_COLORDIALOG)
+ QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size();
+ pWidth = pHeight = qMin(screenSize.width(), screenSize.height());
+ pHeight -= 20;
+ if(screenSize.height() > screenSize.width())
+ pWidth -= 20;
+#else
+ pWidth = 150;
+ pHeight = 100;
+#endif
+ custom = 0;
+ standard = 0;
+ }
+
+ QVBoxLayout *rightLay = new QVBoxLayout;
+ topLay->addLayout(rightLay);
+
+ QHBoxLayout *pickLay = new QHBoxLayout;
+ rightLay->addLayout(pickLay);
+
+ QVBoxLayout *cLay = new QVBoxLayout;
+ pickLay->addLayout(cLay);
+ cp = new QColorPicker(q);
+
+ cp->setFrameStyle(QFrame::Panel + QFrame::Sunken);
+
+#if defined(QT_SMALL_COLORDIALOG)
+ if (!nonTouchUI) {
+ pickLay->addWidget(cp);
+ cLay->addSpacing(lumSpace);
+ } else {
+ cp->hide();
+ }
+#else
+ cLay->addSpacing(lumSpace);
+ cLay->addWidget(cp);
+#endif
+ cLay->addSpacing(lumSpace);
+
+ lp = new QColorLuminancePicker(q);
+#if defined(QT_SMALL_COLORDIALOG)
+ QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size();
+ const int minDimension = qMin(screenSize.height(), screenSize.width());
+ //set picker to be finger-usable
+ int pickerWidth = !nonTouchUI ? minDimension/9 : minDimension/12;
+ lp->setFixedWidth(pickerWidth);
+ if (!nonTouchUI)
+ pickLay->addWidget(lp);
+ else
+ lp->hide();
+#else
+ lp->setFixedWidth(20);
+ pickLay->addWidget(lp);
+#endif
+
+ QObject::connect(cp, SIGNAL(newCol(int,int)), lp, SLOT(setCol(int,int)));
+ QObject::connect(lp, SIGNAL(newHsv(int,int,int)), q, SLOT(_q_newHsv(int,int,int)));
+
+ rightLay->addStretch();
+
+ cs = new QColorShower(q);
+ QObject::connect(cs, SIGNAL(newCol(QRgb)), q, SLOT(_q_newColorTypedIn(QRgb)));
+ QObject::connect(cs, SIGNAL(currentColorChanged(QColor)),
+ q, SIGNAL(currentColorChanged(QColor)));
+#if defined(QT_SMALL_COLORDIALOG)
+ if (!nonTouchUI)
+ pWidth -= cp->size().width();
+ topLay->addWidget(cs);
+#else
+ rightLay->addWidget(cs);
+#endif
+
+ buttons = new QDialogButtonBox(q);
+ mainLay->addWidget(buttons);
+
+ ok = buttons->addButton(QDialogButtonBox::Ok);
+ QObject::connect(ok, SIGNAL(clicked()), q, SLOT(accept()));
+ ok->setDefault(true);
+ cancel = buttons->addButton(QDialogButtonBox::Cancel);
+ QObject::connect(cancel, SIGNAL(clicked()), q, SLOT(reject()));
+
+ retranslateStrings();
+
+#ifdef Q_WS_MAC
+ delegate = 0;
+#endif
+
+ q->setCurrentColor(initial);
+}
+
+void QColorDialogPrivate::_q_addCustom()
+{
+ cusrgb[nextCust] = cs->currentColor();
+ if (custom)
+ custom->update();
+ nextCust = (nextCust+1) % 16;
+}
+
+void QColorDialogPrivate::retranslateStrings()
+{
+ if (!smallDisplay) {
+ lblBasicColors->setText(QColorDialog::tr("&Basic colors"));
+ lblCustomColors->setText(QColorDialog::tr("&Custom colors"));
+ addCusBt->setText(QColorDialog::tr("&Add to Custom Colors"));
+ }
+
+ cs->retranslateStrings();
+}
+
+static const Qt::WindowFlags DefaultWindowFlags =
+ Qt::Dialog | Qt::WindowTitleHint | Qt::MSWindowsFixedSizeDialogHint
+ | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint;
+
+/*!
+ \class QColorDialog
+ \brief The QColorDialog class provides a dialog widget for specifying colors.
+
+ \ingroup standard-dialogs
+
+ The color dialog's function is to allow users to choose colors.
+ For example, you might use this in a drawing program to allow the
+ user to set the brush color.
+
+ The static functions provide modal color dialogs.
+ \omit
+ If you require a modeless dialog, use the QColorDialog constructor.
+ \endomit
+
+ The static getColor() function shows the dialog, and allows the user to
+ specify a color. This function can also be used to let users choose a
+ color with a level of transparency: pass the ShowAlphaChannel option as
+ an additional argument.
+
+ The user can store customCount() different custom colors. The
+ custom colors are shared by all color dialogs, and remembered
+ during the execution of the program. Use setCustomColor() to set
+ the custom colors, and use customColor() to get them.
+
+ Additional widgets that allow users to pick colors are available
+ as \l{Qt Solutions}.
+
+ The \l{dialogs/standarddialogs}{Standard Dialogs} example shows
+ how to use QColorDialog as well as other built-in Qt dialogs.
+
+ \image plastique-colordialog.png A color dialog in the Plastique widget style.
+
+ \sa QColor, QFileDialog, QPrintDialog, QFontDialog, {Standard Dialogs Example}
+*/
+
+/*!
+ \since 4.5
+
+ Constructs a color dialog with the given \a parent.
+*/
+QColorDialog::QColorDialog(QWidget *parent)
+ : QDialog(*new QColorDialogPrivate, parent, DefaultWindowFlags)
+{
+ Q_D(QColorDialog);
+ d->init(Qt::white);
+}
+
+/*!
+ \since 4.5
+
+ Constructs a color dialog with the given \a parent and specified
+ \a initial color.
+*/
+QColorDialog::QColorDialog(const QColor &initial, QWidget *parent)
+ : QDialog(*new QColorDialogPrivate, parent, DefaultWindowFlags)
+{
+ Q_D(QColorDialog);
+ d->init(initial);
+}
+
+/*!
+ \property QColorDialog::currentColor
+ \brief the currently selected color in the dialog
+*/
+
+void QColorDialog::setCurrentColor(const QColor &color)
+{
+ Q_D(QColorDialog);
+ d->setCurrentColor(color.rgb());
+ d->selectColor(color);
+ d->setCurrentAlpha(color.alpha());
+
+#ifdef Q_WS_MAC
+ d->setCurrentQColor(color);
+ d->setCocoaPanelColor(color);
+#endif
+ if (d->nativeDialogInUse)
+ qt_guiPlatformPlugin()->colorDialogSetCurrentColor(this, color);
+}
+
+QColor QColorDialog::currentColor() const
+{
+ Q_D(const QColorDialog);
+ return d->currentQColor();
+}
+
+
+/*!
+ Returns the color that the user selected by clicking the \gui{OK}
+ or equivalent button.
+
+ \note This color is not always the same as the color held by the
+ \l currentColor property since the user can choose different colors
+ before finally selecting the one to use.
+*/
+QColor QColorDialog::selectedColor() const
+{
+ Q_D(const QColorDialog);
+ return d->selectedQColor;
+}
+
+/*!
+ Sets the given \a option to be enabled if \a on is true;
+ otherwise, clears the given \a option.
+
+ \sa options, testOption()
+*/
+void QColorDialog::setOption(ColorDialogOption option, bool on)
+{
+ Q_D(QColorDialog);
+ if (!(d->opts & option) != !on)
+ setOptions(d->opts ^ option);
+}
+
+/*!
+ \since 4.5
+
+ Returns true if the given \a option is enabled; otherwise, returns
+ false.
+
+ \sa options, setOption()
+*/
+bool QColorDialog::testOption(ColorDialogOption option) const
+{
+ Q_D(const QColorDialog);
+ return (d->opts & option) != 0;
+}
+
+/*!
+ \property QColorDialog::options
+ \brief the various options that affect the look and feel of the dialog
+
+ By default, all options are disabled.
+
+ Options should be set before showing the dialog. Setting them while the
+ dialog is visible is not guaranteed to have an immediate effect on the
+ dialog (depending on the option and on the platform).
+
+ \sa setOption(), testOption()
+*/
+void QColorDialog::setOptions(ColorDialogOptions options)
+{
+ Q_D(QColorDialog);
+
+ ColorDialogOptions changed = (options ^ d->opts);
+ if (!changed)
+ return;
+
+ d->opts = options;
+ d->buttons->setVisible(!(options & NoButtons));
+ d->showAlpha(options & ShowAlphaChannel);
+}
+
+QColorDialog::ColorDialogOptions QColorDialog::options() const
+{
+ Q_D(const QColorDialog);
+ return d->opts;
+}
+
+/*!
+ \enum QColorDialog::ColorDialogOption
+
+ \since 4.5
+
+ This enum specifies various options that affect the look and feel
+ of a color dialog.
+
+ \value ShowAlphaChannel Allow the user to select the alpha component of a color.
+ \value NoButtons Don't display \gui{OK} and \gui{Cancel} buttons. (Useful for "live dialogs".)
+ \value DontUseNativeDialog Use Qt's standard color dialog on the Mac instead of Apple's
+ native color panel.
+
+ \sa options, setOption(), testOption(), windowModality()
+*/
+
+/*!
+ \fn void QColorDialog::currentColorChanged(const QColor &color)
+
+ This signal is emitted whenever the current color changes in the dialog.
+ The current color is specified by \a color.
+
+ \sa color, colorSelected()
+*/
+
+#ifdef Q_WS_MAC
+// can only have one Cocoa color panel active
+bool QColorDialogPrivate::sharedColorPanelAvailable = true;
+#endif
+
+/*!
+ \fn void QColorDialog::colorSelected(const QColor &color);
+
+ This signal is emitted just after the user has clicked \gui{OK} to
+ select a color to use. The chosen color is specified by \a color.
+
+ \sa color, currentColorChanged()
+*/
+
+/*!
+ Changes the visibility of the dialog. If \a visible is true, the dialog
+ is shown; otherwise, it is hidden.
+*/
+void QColorDialog::setVisible(bool visible)
+{
+ Q_D(QColorDialog);
+
+ if (visible){
+ if (testAttribute(Qt::WA_WState_ExplicitShowHide) && !testAttribute(Qt::WA_WState_Hidden))
+ return;
+ } else if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden))
+ return;
+
+ if (visible)
+ d->selectedQColor = QColor();
+
+#if defined(Q_WS_MAC)
+ if (visible) {
+ if (d->delegate || (QColorDialogPrivate::sharedColorPanelAvailable &&
+ !(testAttribute(Qt::WA_DontShowOnScreen) || (d->opts & DontUseNativeDialog)))){
+ d->openCocoaColorPanel(currentColor(), parentWidget(), windowTitle(), options());
+ QColorDialogPrivate::sharedColorPanelAvailable = false;
+ setAttribute(Qt::WA_DontShowOnScreen);
+ }
+ setWindowFlags(windowModality() == Qt::WindowModal ? Qt::Sheet : DefaultWindowFlags);
+ } else {
+ if (d->delegate) {
+ d->closeCocoaColorPanel();
+ setAttribute(Qt::WA_DontShowOnScreen, false);
+ }
+ }
+#else
+
+ if (!(d->opts & DontUseNativeDialog) && qt_guiPlatformPlugin()->colorDialogSetVisible(this, visible)) {
+ d->nativeDialogInUse = true;
+ // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below
+ // updates the state correctly, but skips showing the non-native version:
+ setAttribute(Qt::WA_DontShowOnScreen);
+ } else {
+ d->nativeDialogInUse = false;
+ setAttribute(Qt::WA_DontShowOnScreen, false);
+ }
+#endif
+
+ QDialog::setVisible(visible);
+}
+
+/*!
+ \overload
+ \since 4.5
+
+ Opens the dialog and connects its colorSelected() signal to the slot specified
+ by \a receiver and \a member.
+
+ The signal will be disconnected from the slot when the dialog is closed.
+*/
+void QColorDialog::open(QObject *receiver, const char *member)
+{
+ Q_D(QColorDialog);
+ connect(this, SIGNAL(colorSelected(QColor)), receiver, member);
+ d->receiverToDisconnectOnClose = receiver;
+ d->memberToDisconnectOnClose = member;
+ QDialog::open();
+}
+
+/*!
+ \fn QColorDialog::open()
+
+ \since 4.5
+ Shows the dialog as a \l{QDialog#Modal Dialogs}{window modal dialog},
+ returning immediately.
+
+ \sa QDialog::open()
+*/
+
+/*
+ For Symbian color dialogs
+*/
+#ifdef Q_WS_S60
+extern QColor qtSymbianGetColor(const QColor &initial);
+#endif
+/*!
+ \since 4.5
+
+ Pops up a modal color dialog with the given window \a title (or "Select Color" if none is
+ specified), lets the user choose a color, and returns that color. The color is initially set
+ to \a initial. The dialog is a child of \a parent. It returns an invalid (see
+ QColor::isValid()) color if the user cancels the dialog.
+
+ The \a options argument allows you to customize the dialog.
+
+ On Symbian, this static function will use the native color dialog and not a QColorDialog.
+ On Symbian the parameters \a title and \a parent has no relevance and the
+ \a options parameter is only used to define if the native color dialog is
+ used or not.
+*/
+QColor QColorDialog::getColor(const QColor &initial, QWidget *parent, const QString &title,
+ ColorDialogOptions options)
+{
+#ifdef Q_WS_S60
+ if (!(options & DontUseNativeDialog))
+ return qtSymbianGetColor(initial);
+#endif
+ QColorDialog dlg(parent);
+ if (!title.isEmpty())
+ dlg.setWindowTitle(title);
+ dlg.setOptions(options);
+ dlg.setCurrentColor(initial);
+ dlg.exec();
+ return dlg.selectedColor();
+}
+
+/*!
+ Pops up a modal color dialog, lets the user choose a color, and
+ returns that color. The color is initially set to \a initial. The
+ dialog is a child of \a parent. It returns an invalid (see
+ QColor::isValid()) color if the user cancels the dialog.
+
+ On Symbian, this static function will use the native
+ color dialog and not a QColorDialog.
+*/
+
+QColor QColorDialog::getColor(const QColor &initial, QWidget *parent)
+{
+#ifdef Q_WS_S60
+ return qtSymbianGetColor(initial);
+#endif
+ return getColor(initial, parent, QString(), ColorDialogOptions(0));
+}
+
+
+/*!
+ \obsolete
+
+ Pops up a modal color dialog to allow the user to choose a color
+ and an alpha channel (transparency) value. The color+alpha is
+ initially set to \a initial. The dialog is a child of \a parent.
+
+ If \a ok is non-null, \e *\a ok is set to true if the user clicked
+ \gui{OK}, and to false if the user clicked Cancel.
+
+ If the user clicks Cancel, the \a initial value is returned.
+
+ Use QColorDialog::getColor() instead, passing the
+ QColorDialog::ShowAlphaChannel option.
+*/
+
+QRgb QColorDialog::getRgba(QRgb initial, bool *ok, QWidget *parent)
+{
+ QColor color(getColor(QColor(initial), parent, QString(), ShowAlphaChannel));
+ QRgb result = color.isValid() ? color.rgba() : initial;
+ if (ok)
+ *ok = color.isValid();
+ return result;
+}
+
+/*!
+ Destroys the color dialog.
+*/
+
+QColorDialog::~QColorDialog()
+{
+ Q_D(QColorDialog);
+#if defined(Q_WS_MAC)
+ if (d->delegate) {
+ d->releaseCocoaColorPanelDelegate();
+ QColorDialogPrivate::sharedColorPanelAvailable = true;
+ }
+#endif
+
+#ifndef QT_NO_SETTINGS
+ if (!customSet) {
+ QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
+ for (int i = 0; i < 2*8; ++i)
+ settings.setValue(QLatin1String("Qt/customColors/") + QString::number(i), cusrgb[i]);
+ }
+#endif
+ if (d->nativeDialogInUse)
+ qt_guiPlatformPlugin()->colorDialogDelete(this);
+
+}
+
+
+/*!
+ \reimp
+*/
+void QColorDialog::changeEvent(QEvent *e)
+{
+ Q_D(QColorDialog);
+ if (e->type() == QEvent::LanguageChange)
+ d->retranslateStrings();
+ QDialog::changeEvent(e);
+}
+
+/*!
+ Closes the dialog and sets its result code to \a result. If this dialog
+ is shown with exec(), done() causes the local event loop to finish,
+ and exec() to return \a result.
+
+ \sa QDialog::done()
+*/
+void QColorDialog::done(int result)
+{
+ Q_D(QColorDialog);
+ QDialog::done(result);
+ if (result == Accepted) {
+ d->selectedQColor = d->currentQColor();
+ emit colorSelected(d->selectedQColor);
+ } else {
+ d->selectedQColor = QColor();
+ }
+ if (d->receiverToDisconnectOnClose) {
+ disconnect(this, SIGNAL(colorSelected(QColor)),
+ d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
+ d->receiverToDisconnectOnClose = 0;
+ }
+ d->memberToDisconnectOnClose.clear();
+}
+
+QT_END_NAMESPACE
+
+#include "qcolordialog.moc"
+#include "moc_qcolordialog.cpp"
+
+#endif // QT_NO_COLORDIALOG
+
+/*!
+ \fn QColor QColorDialog::getColor(const QColor &init, QWidget *parent, const char *name)
+ \compat
+*/
+
+/*!
+ \fn QRgb QColorDialog::getRgba(QRgb rgba, bool *ok, QWidget *parent, const char *name)
+ \compat
+*/
diff --git a/src/widgets/dialogs/qcolordialog.h b/src/widgets/dialogs/qcolordialog.h
new file mode 100644
index 0000000000..2b3d24b171
--- /dev/null
+++ b/src/widgets/dialogs/qcolordialog.h
@@ -0,0 +1,150 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCOLORDIALOG_H
+#define QCOLORDIALOG_H
+
+#include <QtWidgets/qdialog.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_COLORDIALOG
+
+class QColorDialogPrivate;
+
+class Q_GUI_EXPORT QColorDialog : public QDialog
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QColorDialog)
+ Q_ENUMS(ColorDialogOption)
+ Q_PROPERTY(QColor currentColor READ currentColor WRITE setCurrentColor
+ NOTIFY currentColorChanged)
+ Q_PROPERTY(ColorDialogOptions options READ options WRITE setOptions)
+
+public:
+ enum ColorDialogOption {
+ ShowAlphaChannel = 0x00000001,
+ NoButtons = 0x00000002,
+ DontUseNativeDialog = 0x00000004
+ };
+
+ Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)
+
+ explicit QColorDialog(QWidget *parent = 0);
+ explicit QColorDialog(const QColor &initial, QWidget *parent = 0);
+ ~QColorDialog();
+
+ void setCurrentColor(const QColor &color);
+ QColor currentColor() const;
+
+ QColor selectedColor() const;
+
+ void setOption(ColorDialogOption option, bool on = true);
+ bool testOption(ColorDialogOption option) const;
+ void setOptions(ColorDialogOptions options);
+ ColorDialogOptions options() const;
+
+#ifdef Q_NO_USING_KEYWORD
+ void open() { QDialog::open(); }
+#else
+ using QDialog::open;
+#endif
+ void open(QObject *receiver, const char *member);
+
+ void setVisible(bool visible);
+
+ // ### Qt 5: merge overloads with title = QString()
+ static QColor getColor(const QColor &initial, QWidget *parent, const QString &title,
+ ColorDialogOptions options = 0);
+ static QColor getColor(const QColor &initial = Qt::white, QWidget *parent = 0);
+
+ // obsolete
+ static QRgb getRgba(QRgb rgba = 0xffffffff, bool *ok = 0, QWidget *parent = 0);
+
+ // ### Qt 5: use QColor in signatures
+ static int customCount();
+ static QRgb customColor(int index);
+ static void setCustomColor(int index, QRgb color);
+ static void setStandardColor(int index, QRgb color);
+
+#ifdef QT3_SUPPORT
+ static QColor getColor(const QColor &init, QWidget *parent, const char *name)
+ { Q_UNUSED(name); return getColor(init, parent); }
+ static QRgb getRgba(QRgb rgba, bool *ok, QWidget *parent, const char *name)
+ { Q_UNUSED(name); return getRgba(rgba, ok, parent); }
+#endif
+
+Q_SIGNALS:
+ void currentColorChanged(const QColor &color);
+ void colorSelected(const QColor &color);
+
+protected:
+ void changeEvent(QEvent *event);
+ void done(int result);
+
+private:
+ Q_DISABLE_COPY(QColorDialog)
+
+ Q_PRIVATE_SLOT(d_func(), void _q_addCustom())
+ Q_PRIVATE_SLOT(d_func(), void _q_newHsv(int h, int s, int v))
+ Q_PRIVATE_SLOT(d_func(), void _q_newColorTypedIn(QRgb rgb))
+ Q_PRIVATE_SLOT(d_func(), void _q_newCustom(int, int))
+ Q_PRIVATE_SLOT(d_func(), void _q_newStandard(int, int))
+#if defined(Q_WS_MAC)
+ Q_PRIVATE_SLOT(d_func(), void _q_macRunNativeAppModalPanel())
+#endif
+
+ friend class QColorShower;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QColorDialog::ColorDialogOptions)
+
+#endif // QT_NO_COLORDIALOG
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QCOLORDIALOG_H
diff --git a/src/gui/dialogs/qcolordialog_mac.mm b/src/widgets/dialogs/qcolordialog_mac.mm
index 9daf595a9b..9daf595a9b 100644
--- a/src/gui/dialogs/qcolordialog_mac.mm
+++ b/src/widgets/dialogs/qcolordialog_mac.mm
diff --git a/src/gui/dialogs/qcolordialog_p.h b/src/widgets/dialogs/qcolordialog_p.h
index 243e7277c5..243e7277c5 100644
--- a/src/gui/dialogs/qcolordialog_p.h
+++ b/src/widgets/dialogs/qcolordialog_p.h
diff --git a/src/gui/dialogs/qcolordialog_symbian.cpp b/src/widgets/dialogs/qcolordialog_symbian.cpp
index 3dbb5c11a9..3dbb5c11a9 100644
--- a/src/gui/dialogs/qcolordialog_symbian.cpp
+++ b/src/widgets/dialogs/qcolordialog_symbian.cpp
diff --git a/src/gui/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp
index 6838d927a8..6838d927a8 100644
--- a/src/gui/dialogs/qdialog.cpp
+++ b/src/widgets/dialogs/qdialog.cpp
diff --git a/src/widgets/dialogs/qdialog.h b/src/widgets/dialogs/qdialog.h
new file mode 100644
index 0000000000..5780d15781
--- /dev/null
+++ b/src/widgets/dialogs/qdialog.h
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDIALOG_H
+#define QDIALOG_H
+
+#include <QtWidgets/qwidget.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QPushButton;
+class QDialogPrivate;
+
+class Q_GUI_EXPORT QDialog : public QWidget
+{
+ Q_OBJECT
+ friend class QPushButton;
+
+ Q_PROPERTY(bool sizeGripEnabled READ isSizeGripEnabled WRITE setSizeGripEnabled)
+ Q_PROPERTY(bool modal READ isModal WRITE setModal)
+
+public:
+ explicit QDialog(QWidget *parent = 0, Qt::WindowFlags f = 0);
+#ifdef QT3_SUPPORT
+ QT3_SUPPORT_CONSTRUCTOR QDialog(QWidget *parent, const char *name, bool modal = false,
+ Qt::WindowFlags f = 0);
+#endif
+ ~QDialog();
+
+ enum DialogCode { Rejected, Accepted };
+
+ int result() const;
+
+ void setVisible(bool visible);
+
+ void setOrientation(Qt::Orientation orientation);
+ Qt::Orientation orientation() const;
+
+ void setExtension(QWidget* extension);
+ QWidget* extension() const;
+
+ QSize sizeHint() const;
+ QSize minimumSizeHint() const;
+
+ void setSizeGripEnabled(bool);
+ bool isSizeGripEnabled() const;
+
+ void setModal(bool modal);
+ void setResult(int r);
+
+Q_SIGNALS:
+ void finished(int result);
+ void accepted();
+ void rejected();
+
+public Q_SLOTS:
+ void open();
+ int exec();
+ virtual void done(int);
+ virtual void accept();
+ virtual void reject();
+
+ void showExtension(bool);
+
+protected:
+ QDialog(QDialogPrivate &, QWidget *parent, Qt::WindowFlags f = 0);
+
+#if defined(Q_WS_WINCE) || defined(Q_OS_SYMBIAN)
+ bool event(QEvent *e);
+#endif
+ void keyPressEvent(QKeyEvent *);
+ void closeEvent(QCloseEvent *);
+ void showEvent(QShowEvent *);
+ void resizeEvent(QResizeEvent *);
+#ifndef QT_NO_CONTEXTMENU
+ void contextMenuEvent(QContextMenuEvent *);
+#endif
+ bool eventFilter(QObject *, QEvent *);
+ void adjustPosition(QWidget*);
+private:
+ Q_DECLARE_PRIVATE(QDialog)
+ Q_DISABLE_COPY(QDialog)
+
+#if defined(Q_OS_SYMBIAN)
+ bool symbianAdjustedPosition();
+#endif
+
+
+#ifdef Q_WS_WINCE_WM
+ Q_PRIVATE_SLOT(d_func(), void _q_doneAction())
+#endif
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDIALOG_H
diff --git a/src/widgets/dialogs/qdialog_p.h b/src/widgets/dialogs/qdialog_p.h
new file mode 100644
index 0000000000..46c50c3c3f
--- /dev/null
+++ b/src/widgets/dialogs/qdialog_p.h
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDIALOG_P_H
+#define QDIALOG_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "private/qwidget_p.h"
+#include "QtCore/qeventloop.h"
+#include "QtCore/qpointer.h"
+#include "QtWidgets/qdialog.h"
+#include "QtWidgets/qpushbutton.h"
+
+QT_BEGIN_NAMESPACE
+
+class QSizeGrip;
+
+class QDialogPrivate : public QWidgetPrivate
+{
+ Q_DECLARE_PUBLIC(QDialog)
+public:
+
+ QDialogPrivate()
+ : mainDef(0), orientation(Qt::Horizontal),extension(0), doShowExtension(false),
+#ifndef QT_NO_SIZEGRIP
+ resizer(0),
+ sizeGripEnabled(false),
+#endif
+ rescode(0), resetModalityTo(-1), wasModalitySet(true), eventLoop(0)
+ {}
+
+ QPointer<QPushButton> mainDef;
+ Qt::Orientation orientation;
+ QWidget *extension;
+ bool doShowExtension;
+ QSize size, min, max;
+#ifndef QT_NO_SIZEGRIP
+ QSizeGrip *resizer;
+ bool sizeGripEnabled;
+#endif
+ QPoint lastRMBPress;
+
+ void setDefault(QPushButton *);
+ void setMainDefault(QPushButton *);
+ void hideDefault();
+ void resetModalitySetByOpen();
+
+#ifdef Q_WS_WINCE_WM
+ void _q_doneAction();
+#endif
+
+#ifdef Q_WS_MAC
+ virtual void mac_nativeDialogModalHelp() {}
+#endif
+
+ int rescode;
+ int resetModalityTo;
+ bool wasModalitySet;
+
+ QPointer<QEventLoop> eventLoop;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDIALOG_P_H
diff --git a/src/gui/dialogs/qdialogsbinarycompat_win.cpp b/src/widgets/dialogs/qdialogsbinarycompat_win.cpp
index beec2cd29c..beec2cd29c 100644
--- a/src/gui/dialogs/qdialogsbinarycompat_win.cpp
+++ b/src/widgets/dialogs/qdialogsbinarycompat_win.cpp
diff --git a/src/gui/dialogs/qerrormessage.cpp b/src/widgets/dialogs/qerrormessage.cpp
index 6d474cc4f9..6d474cc4f9 100644
--- a/src/gui/dialogs/qerrormessage.cpp
+++ b/src/widgets/dialogs/qerrormessage.cpp
diff --git a/src/widgets/dialogs/qerrormessage.h b/src/widgets/dialogs/qerrormessage.h
new file mode 100644
index 0000000000..7c7b56a7e9
--- /dev/null
+++ b/src/widgets/dialogs/qerrormessage.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QERRORMESSAGE_H
+#define QERRORMESSAGE_H
+
+#include <QtWidgets/qdialog.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_ERRORMESSAGE
+
+class QErrorMessagePrivate;
+
+class Q_GUI_EXPORT QErrorMessage: public QDialog
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QErrorMessage)
+public:
+ explicit QErrorMessage(QWidget* parent = 0);
+ ~QErrorMessage();
+
+ static QErrorMessage * qtHandler();
+
+public Q_SLOTS:
+ void showMessage(const QString &message);
+ void showMessage(const QString &message, const QString &type);
+#ifdef QT3_SUPPORT
+ inline QT_MOC_COMPAT void message(const QString &text) { showMessage(text); }
+#endif
+
+protected:
+ void done(int);
+ void changeEvent(QEvent *e);
+
+private:
+ Q_DISABLE_COPY(QErrorMessage)
+};
+
+#endif // QT_NO_ERRORMESSAGE
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QERRORMESSAGE_H
diff --git a/src/gui/dialogs/qfiledialog.cpp b/src/widgets/dialogs/qfiledialog.cpp
index 897a9164a2..897a9164a2 100644
--- a/src/gui/dialogs/qfiledialog.cpp
+++ b/src/widgets/dialogs/qfiledialog.cpp
diff --git a/src/widgets/dialogs/qfiledialog.h b/src/widgets/dialogs/qfiledialog.h
new file mode 100644
index 0000000000..ce995aad5a
--- /dev/null
+++ b/src/widgets/dialogs/qfiledialog.h
@@ -0,0 +1,331 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QFILEDIALOG_H
+#define QFILEDIALOG_H
+
+#include <QtCore/qdir.h>
+#include <QtCore/qstring.h>
+#include <QtWidgets/qdialog.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_FILEDIALOG
+
+class QModelIndex;
+class QItemSelection;
+struct QFileDialogArgs;
+class QFileIconProvider;
+class QFileDialogPrivate;
+class QAbstractItemDelegate;
+class QAbstractProxyModel;
+class QUrl;
+
+class Q_GUI_EXPORT QFileDialog : public QDialog
+{
+ Q_OBJECT
+ Q_ENUMS(ViewMode FileMode AcceptMode Option)
+ Q_FLAGS(Options)
+ Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode)
+ Q_PROPERTY(FileMode fileMode READ fileMode WRITE setFileMode)
+ Q_PROPERTY(AcceptMode acceptMode READ acceptMode WRITE setAcceptMode)
+ Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly DESIGNABLE false)
+ Q_PROPERTY(bool resolveSymlinks READ resolveSymlinks WRITE setResolveSymlinks DESIGNABLE false)
+ Q_PROPERTY(bool confirmOverwrite READ confirmOverwrite WRITE setConfirmOverwrite DESIGNABLE false)
+ Q_PROPERTY(QString defaultSuffix READ defaultSuffix WRITE setDefaultSuffix)
+ Q_PROPERTY(bool nameFilterDetailsVisible READ isNameFilterDetailsVisible
+ WRITE setNameFilterDetailsVisible DESIGNABLE false)
+ Q_PROPERTY(Options options READ options WRITE setOptions)
+
+public:
+ enum ViewMode { Detail, List };
+ enum FileMode { AnyFile, ExistingFile, Directory, ExistingFiles, DirectoryOnly };
+ enum AcceptMode { AcceptOpen, AcceptSave };
+ enum DialogLabel { LookIn, FileName, FileType, Accept, Reject };
+
+ // ### Rename to FileDialogOption and FileDialogOptions for Qt 5.0
+ enum Option
+ {
+ ShowDirsOnly = 0x00000001,
+ DontResolveSymlinks = 0x00000002,
+ DontConfirmOverwrite = 0x00000004,
+ DontUseSheet = 0x00000008,
+ DontUseNativeDialog = 0x00000010,
+ ReadOnly = 0x00000020,
+ HideNameFilterDetails = 0x00000040
+ };
+ Q_DECLARE_FLAGS(Options, Option)
+
+ QFileDialog(QWidget *parent, Qt::WindowFlags f);
+ explicit QFileDialog(QWidget *parent = 0,
+ const QString &caption = QString(),
+ const QString &directory = QString(),
+ const QString &filter = QString());
+ ~QFileDialog();
+
+ void setDirectory(const QString &directory);
+ inline void setDirectory(const QDir &directory);
+ QDir directory() const;
+
+ void selectFile(const QString &filename);
+ QStringList selectedFiles() const;
+
+#ifdef QT_DEPRECATED
+ QT_DEPRECATED void setFilter(const QString &filter);
+ QT_DEPRECATED void setFilters(const QStringList &filters);
+ QT_DEPRECATED QStringList filters() const;
+ QT_DEPRECATED void selectFilter(const QString &filter);
+ QT_DEPRECATED QString selectedFilter() const;
+#endif
+ void setNameFilterDetailsVisible(bool enabled);
+ bool isNameFilterDetailsVisible() const;
+
+ void setNameFilter(const QString &filter);
+ void setNameFilters(const QStringList &filters);
+ QStringList nameFilters() const;
+ void selectNameFilter(const QString &filter);
+ QString selectedNameFilter() const;
+
+ QDir::Filters filter() const;
+ void setFilter(QDir::Filters filters);
+
+ void setViewMode(ViewMode mode);
+ ViewMode viewMode() const;
+
+ void setFileMode(FileMode mode);
+ FileMode fileMode() const;
+
+ void setAcceptMode(AcceptMode mode);
+ AcceptMode acceptMode() const;
+
+ void setReadOnly(bool enabled);
+ bool isReadOnly() const;
+
+ void setResolveSymlinks(bool enabled);
+ bool resolveSymlinks() const;
+
+ void setSidebarUrls(const QList<QUrl> &urls);
+ QList<QUrl> sidebarUrls() const;
+
+ QByteArray saveState() const;
+ bool restoreState(const QByteArray &state);
+
+ void setConfirmOverwrite(bool enabled);
+ bool confirmOverwrite() const;
+
+ void setDefaultSuffix(const QString &suffix);
+ QString defaultSuffix() const;
+
+ void setHistory(const QStringList &paths);
+ QStringList history() const;
+
+ void setItemDelegate(QAbstractItemDelegate *delegate);
+ QAbstractItemDelegate *itemDelegate() const;
+
+ void setIconProvider(QFileIconProvider *provider);
+ QFileIconProvider *iconProvider() const;
+
+ void setLabelText(DialogLabel label, const QString &text);
+ QString labelText(DialogLabel label) const;
+
+#ifndef QT_NO_PROXYMODEL
+ void setProxyModel(QAbstractProxyModel *model);
+ QAbstractProxyModel *proxyModel() const;
+#endif
+
+ void setOption(Option option, bool on = true);
+ bool testOption(Option option) const;
+ void setOptions(Options options);
+ Options options() const;
+
+#ifdef Q_NO_USING_KEYWORD
+#ifndef Q_QDOC
+ void open() { QDialog::open(); }
+#endif
+#else
+ using QDialog::open;
+#endif
+ void open(QObject *receiver, const char *member);
+ void setVisible(bool visible);
+
+Q_SIGNALS:
+ void fileSelected(const QString &file);
+ void filesSelected(const QStringList &files);
+ void currentChanged(const QString &path);
+ void directoryEntered(const QString &directory);
+ void filterSelected(const QString &filter);
+
+public:
+#ifdef QT3_SUPPORT
+ typedef FileMode Mode;
+ inline QT3_SUPPORT void setMode(FileMode m) { setFileMode(m); }
+ inline QT3_SUPPORT FileMode mode() const { return fileMode(); }
+ inline QT3_SUPPORT void setDir(const QString &directory) { setDirectory(directory); }
+ inline QT3_SUPPORT void setDir( const QDir &directory ) { setDirectory(directory); }
+ QT3_SUPPORT QString selectedFile() const;
+#endif
+
+ static QString getOpenFileName(QWidget *parent = 0,
+ const QString &caption = QString(),
+ const QString &dir = QString(),
+ const QString &filter = QString(),
+ QString *selectedFilter = 0,
+ Options options = 0);
+
+ static QString getSaveFileName(QWidget *parent = 0,
+ const QString &caption = QString(),
+ const QString &dir = QString(),
+ const QString &filter = QString(),
+ QString *selectedFilter = 0,
+ Options options = 0);
+
+ static QString getExistingDirectory(QWidget *parent = 0,
+ const QString &caption = QString(),
+ const QString &dir = QString(),
+ Options options = ShowDirsOnly);
+
+ static QStringList getOpenFileNames(QWidget *parent = 0,
+ const QString &caption = QString(),
+ const QString &dir = QString(),
+ const QString &filter = QString(),
+ QString *selectedFilter = 0,
+ Options options = 0);
+
+#ifdef QT3_SUPPORT
+ inline static QString QT3_SUPPORT getOpenFileName(const QString &dir,
+ const QString &filter = QString(),
+ QWidget *parent = 0, const char* name = 0,
+ const QString &caption = QString(),
+ QString *selectedFilter = 0,
+ bool resolveSymlinks = true)
+ { Q_UNUSED(name);
+ return getOpenFileName(parent, caption, dir, filter, selectedFilter,
+ resolveSymlinks ? Option(0) : DontResolveSymlinks); }
+
+ inline static QString QT3_SUPPORT getSaveFileName(const QString &dir,
+ const QString &filter = QString(),
+ QWidget *parent = 0, const char* name = 0,
+ const QString &caption = QString(),
+ QString *selectedFilter = 0,
+ bool resolveSymlinks = true)
+ { Q_UNUSED(name);
+ return getSaveFileName(parent, caption, dir, filter, selectedFilter,
+ resolveSymlinks ? Option(0) : DontResolveSymlinks); }
+
+ inline static QString QT3_SUPPORT getExistingDirectory(const QString &dir,
+ QWidget *parent = 0,
+ const char* name = 0,
+ const QString &caption = QString(),
+ bool dirOnly = true,
+ bool resolveSymlinks = true)
+ { Q_UNUSED(name);
+ return getExistingDirectory(parent, caption, dir,
+ Options((resolveSymlinks ? Option(0) : DontResolveSymlinks)
+ | (dirOnly ? ShowDirsOnly : Option(0)))); }
+
+ inline static QStringList QT3_SUPPORT getOpenFileNames(const QString &filter,
+ const QString &dir = QString(),
+ QWidget *parent = 0,
+ const char* name = 0,
+ const QString &caption = QString(),
+ QString *selectedFilter = 0,
+ bool resolveSymlinks = true)
+ { Q_UNUSED(name);
+ return getOpenFileNames(parent, caption, dir, filter, selectedFilter,
+ resolveSymlinks ? Option(0) : DontResolveSymlinks); }
+#endif // QT3_SUPPORT
+
+protected:
+ QFileDialog(const QFileDialogArgs &args);
+ void done(int result);
+ void accept();
+ void changeEvent(QEvent *e);
+
+private:
+ Q_DECLARE_PRIVATE(QFileDialog)
+ Q_DISABLE_COPY(QFileDialog)
+
+ Q_PRIVATE_SLOT(d_func(), void _q_pathChanged(const QString &))
+
+ Q_PRIVATE_SLOT(d_func(), void _q_navigateBackward())
+ Q_PRIVATE_SLOT(d_func(), void _q_navigateForward())
+ Q_PRIVATE_SLOT(d_func(), void _q_navigateToParent())
+ Q_PRIVATE_SLOT(d_func(), void _q_createDirectory())
+ Q_PRIVATE_SLOT(d_func(), void _q_showListView())
+ Q_PRIVATE_SLOT(d_func(), void _q_showDetailsView())
+ Q_PRIVATE_SLOT(d_func(), void _q_showContextMenu(const QPoint &))
+ Q_PRIVATE_SLOT(d_func(), void _q_renameCurrent())
+ Q_PRIVATE_SLOT(d_func(), void _q_deleteCurrent())
+ Q_PRIVATE_SLOT(d_func(), void _q_showHidden())
+ Q_PRIVATE_SLOT(d_func(), void _q_updateOkButton())
+ Q_PRIVATE_SLOT(d_func(), void _q_currentChanged(const QModelIndex &index))
+ Q_PRIVATE_SLOT(d_func(), void _q_enterDirectory(const QModelIndex &index))
+ Q_PRIVATE_SLOT(d_func(), void _q_goToDirectory(const QString &path))
+ Q_PRIVATE_SLOT(d_func(), void _q_useNameFilter(int index))
+ Q_PRIVATE_SLOT(d_func(), void _q_selectionChanged())
+ Q_PRIVATE_SLOT(d_func(), void _q_goToUrl(const QUrl &url))
+ Q_PRIVATE_SLOT(d_func(), void _q_goHome())
+ Q_PRIVATE_SLOT(d_func(), void _q_showHeader(QAction *))
+ Q_PRIVATE_SLOT(d_func(), void _q_autoCompleteFileName(const QString &text))
+ Q_PRIVATE_SLOT(d_func(), void _q_rowsInserted(const QModelIndex & parent))
+ Q_PRIVATE_SLOT(d_func(), void _q_fileRenamed(const QString &path,
+ const QString oldName, const QString newName))
+#if defined(Q_WS_MAC)
+ Q_PRIVATE_SLOT(d_func(), void _q_macRunNativeAppModalPanel())
+#endif
+};
+
+inline void QFileDialog::setDirectory(const QDir &adirectory)
+{ setDirectory(adirectory.absolutePath()); }
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QFileDialog::Options)
+
+#endif // QT_NO_FILEDIALOG
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QFILEDIALOG_H
diff --git a/src/gui/dialogs/qfiledialog.ui b/src/widgets/dialogs/qfiledialog.ui
index dcb08114e2..dcb08114e2 100644
--- a/src/gui/dialogs/qfiledialog.ui
+++ b/src/widgets/dialogs/qfiledialog.ui
diff --git a/src/gui/dialogs/qfiledialog_embedded.ui b/src/widgets/dialogs/qfiledialog_embedded.ui
index e8de400cab..e8de400cab 100644
--- a/src/gui/dialogs/qfiledialog_embedded.ui
+++ b/src/widgets/dialogs/qfiledialog_embedded.ui
diff --git a/src/gui/dialogs/qfiledialog_mac.mm b/src/widgets/dialogs/qfiledialog_mac.mm
index 832f9bfaf8..832f9bfaf8 100644
--- a/src/gui/dialogs/qfiledialog_mac.mm
+++ b/src/widgets/dialogs/qfiledialog_mac.mm
diff --git a/src/gui/dialogs/qfiledialog_p.h b/src/widgets/dialogs/qfiledialog_p.h
index 882acdd758..882acdd758 100644
--- a/src/gui/dialogs/qfiledialog_p.h
+++ b/src/widgets/dialogs/qfiledialog_p.h
diff --git a/src/gui/dialogs/qfiledialog_symbian.cpp b/src/widgets/dialogs/qfiledialog_symbian.cpp
index ed9895019f..ed9895019f 100644
--- a/src/gui/dialogs/qfiledialog_symbian.cpp
+++ b/src/widgets/dialogs/qfiledialog_symbian.cpp
diff --git a/src/gui/dialogs/qfiledialog_win.cpp b/src/widgets/dialogs/qfiledialog_win.cpp
index 114f4bedbc..114f4bedbc 100644
--- a/src/gui/dialogs/qfiledialog_win.cpp
+++ b/src/widgets/dialogs/qfiledialog_win.cpp
diff --git a/src/gui/dialogs/qfiledialog_win_p.h b/src/widgets/dialogs/qfiledialog_win_p.h
index 7580f0ad6b..7580f0ad6b 100644
--- a/src/gui/dialogs/qfiledialog_win_p.h
+++ b/src/widgets/dialogs/qfiledialog_win_p.h
diff --git a/src/gui/dialogs/qfileinfogatherer.cpp b/src/widgets/dialogs/qfileinfogatherer.cpp
index b36b21e63d..b36b21e63d 100644
--- a/src/gui/dialogs/qfileinfogatherer.cpp
+++ b/src/widgets/dialogs/qfileinfogatherer.cpp
diff --git a/src/gui/dialogs/qfileinfogatherer_p.h b/src/widgets/dialogs/qfileinfogatherer_p.h
index db308ef57e..db308ef57e 100644
--- a/src/gui/dialogs/qfileinfogatherer_p.h
+++ b/src/widgets/dialogs/qfileinfogatherer_p.h
diff --git a/src/gui/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp
index ff4410db97..ff4410db97 100644
--- a/src/gui/dialogs/qfilesystemmodel.cpp
+++ b/src/widgets/dialogs/qfilesystemmodel.cpp
diff --git a/src/widgets/dialogs/qfilesystemmodel.h b/src/widgets/dialogs/qfilesystemmodel.h
new file mode 100644
index 0000000000..7a6edb2d02
--- /dev/null
+++ b/src/widgets/dialogs/qfilesystemmodel.h
@@ -0,0 +1,180 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QFILESYSTEMMODEL_H
+#define QFILESYSTEMMODEL_H
+
+#include <QtCore/qabstractitemmodel.h>
+#include <QtCore/qpair.h>
+#include <QtCore/qdir.h>
+#include <QtWidgets/qicon.h>
+#include <QtCore/qdiriterator.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_FILESYSTEMMODEL
+
+class ExtendedInformation;
+class QFileSystemModelPrivate;
+class QFileIconProvider;
+
+class Q_GUI_EXPORT QFileSystemModel : public QAbstractItemModel
+{
+ Q_OBJECT
+ Q_PROPERTY(bool resolveSymlinks READ resolveSymlinks WRITE setResolveSymlinks)
+ Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
+ Q_PROPERTY(bool nameFilterDisables READ nameFilterDisables WRITE setNameFilterDisables)
+
+Q_SIGNALS:
+ void rootPathChanged(const QString &newPath);
+ void fileRenamed(const QString &path, const QString &oldName, const QString &newName);
+ void directoryLoaded(const QString &path);
+
+public:
+ enum Roles {
+ FileIconRole = Qt::DecorationRole,
+ FilePathRole = Qt::UserRole + 1,
+ FileNameRole = Qt::UserRole + 2,
+ FilePermissions = Qt::UserRole + 3
+ };
+
+ explicit QFileSystemModel(QObject *parent = 0);
+ ~QFileSystemModel();
+
+ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
+ QModelIndex index(const QString &path, int column = 0) const;
+ QModelIndex parent(const QModelIndex &child) const;
+ bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
+ bool canFetchMore(const QModelIndex &parent) const;
+ void fetchMore(const QModelIndex &parent);
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ int columnCount(const QModelIndex &parent = QModelIndex()) const;
+
+ QVariant myComputer(int role = Qt::DisplayRole) const;
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
+
+ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+
+ void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
+
+ QStringList mimeTypes() const;
+ QMimeData *mimeData(const QModelIndexList &indexes) const;
+ bool dropMimeData(const QMimeData *data, Qt::DropAction action,
+ int row, int column, const QModelIndex &parent);
+ Qt::DropActions supportedDropActions() const;
+
+ // QFileSystemModel specific API
+ QModelIndex setRootPath(const QString &path);
+ QString rootPath() const;
+ QDir rootDirectory() const;
+
+ void setIconProvider(QFileIconProvider *provider);
+ QFileIconProvider *iconProvider() const;
+
+ void setFilter(QDir::Filters filters);
+ QDir::Filters filter() const;
+
+ void setResolveSymlinks(bool enable);
+ bool resolveSymlinks() const;
+
+ void setReadOnly(bool enable);
+ bool isReadOnly() const;
+
+ void setNameFilterDisables(bool enable);
+ bool nameFilterDisables() const;
+
+ void setNameFilters(const QStringList &filters);
+ QStringList nameFilters() const;
+
+ QString filePath(const QModelIndex &index) const;
+ bool isDir(const QModelIndex &index) const;
+ qint64 size(const QModelIndex &index) const;
+ QString type(const QModelIndex &index) const;
+ QDateTime lastModified(const QModelIndex &index) const;
+
+ QModelIndex mkdir(const QModelIndex &parent, const QString &name);
+ bool rmdir(const QModelIndex &index) const; // ### Qt5: should not be const
+ inline QString fileName(const QModelIndex &index) const;
+ inline QIcon fileIcon(const QModelIndex &index) const;
+ QFile::Permissions permissions(const QModelIndex &index) const;
+ inline QFileInfo fileInfo(const QModelIndex &index) const;
+ bool remove(const QModelIndex &index) const;
+
+protected:
+ QFileSystemModel(QFileSystemModelPrivate &, QObject *parent = 0);
+ void timerEvent(QTimerEvent *event);
+ bool event(QEvent *event);
+
+private:
+ Q_DECLARE_PRIVATE(QFileSystemModel)
+ Q_DISABLE_COPY(QFileSystemModel)
+
+ Q_PRIVATE_SLOT(d_func(), void _q_directoryChanged(const QString &directory, const QStringList &list))
+ Q_PRIVATE_SLOT(d_func(), void _q_performDelayedSort())
+ Q_PRIVATE_SLOT(d_func(), void _q_fileSystemChanged(const QString &path, const QList<QPair<QString, QFileInfo> > &))
+ Q_PRIVATE_SLOT(d_func(), void _q_resolvedName(const QString &fileName, const QString &resolvedName))
+
+ friend class QFileDialogPrivate;
+};
+
+inline QString QFileSystemModel::fileName(const QModelIndex &aindex) const
+{ return aindex.data(Qt::DisplayRole).toString(); }
+inline QIcon QFileSystemModel::fileIcon(const QModelIndex &aindex) const
+{ return qvariant_cast<QIcon>(aindex.data(Qt::DecorationRole)); }
+inline QFileInfo QFileSystemModel::fileInfo(const QModelIndex &aindex) const
+{ return QFileInfo(filePath(aindex)); }
+
+#endif // QT_NO_FILESYSTEMMODEL
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QFILESYSTEMMODEL_H
+
diff --git a/src/gui/dialogs/qfilesystemmodel_p.h b/src/widgets/dialogs/qfilesystemmodel_p.h
index e83bbd11d3..e83bbd11d3 100644
--- a/src/gui/dialogs/qfilesystemmodel_p.h
+++ b/src/widgets/dialogs/qfilesystemmodel_p.h
diff --git a/src/widgets/dialogs/qfontdialog.cpp b/src/widgets/dialogs/qfontdialog.cpp
new file mode 100644
index 0000000000..60284ed6a1
--- /dev/null
+++ b/src/widgets/dialogs/qfontdialog.cpp
@@ -0,0 +1,1077 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwindowdefs.h"
+
+#ifndef QT_NO_FONTDIALOG
+
+#include "qfontdialog.h"
+#include "qfontdialog_p.h"
+
+#include <qapplication.h>
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qevent.h>
+#include <qfontdatabase.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qstyle.h>
+#include <qdialogbuttonbox.h>
+#include <qheaderview.h>
+#include <qlistview.h>
+#include <qstringlistmodel.h>
+#include <qvalidator.h>
+#include <private/qdialog_p.h>
+#include <private/qfont_p.h>
+
+#if defined(Q_WS_S60)
+#include <QtWidgets/qdesktopwidget.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+class QFontListView : public QListView
+{
+ Q_OBJECT
+public:
+ QFontListView(QWidget *parent);
+ inline QStringListModel *model() const {
+ return static_cast<QStringListModel *>(QListView::model());
+ }
+ inline void setCurrentItem(int item) {
+ QListView::setCurrentIndex(static_cast<QAbstractListModel*>(model())->index(item));
+ }
+ inline int currentItem() const {
+ return QListView::currentIndex().row();
+ }
+ inline int count() const {
+ return model()->rowCount();
+ }
+ inline QString currentText() const {
+ int row = QListView::currentIndex().row();
+ return row < 0 ? QString() : model()->stringList().at(row);
+ }
+ void currentChanged(const QModelIndex &current, const QModelIndex &previous) {
+ QListView::currentChanged(current, previous);
+ if (current.isValid())
+ emit highlighted(current.row());
+ }
+ QString text(int i) const {
+ return model()->stringList().at(i);
+ }
+signals:
+ void highlighted(int);
+};
+
+QFontListView::QFontListView(QWidget *parent)
+ : QListView(parent)
+{
+ setModel(new QStringListModel(parent));
+ setEditTriggers(NoEditTriggers);
+}
+
+static const Qt::WindowFlags DefaultWindowFlags =
+ Qt::Dialog | Qt::WindowSystemMenuHint;
+
+/*!
+ \class QFontDialog
+ \ingroup standard-dialogs
+
+ \brief The QFontDialog class provides a dialog widget for selecting a font.
+
+ A font dialog is created through one of the static getFont()
+ functions.
+
+ Examples:
+
+ \snippet doc/src/snippets/code/src_gui_dialogs_qfontdialog.cpp 0
+
+ The dialog can also be used to set a widget's font directly:
+ \snippet doc/src/snippets/code/src_gui_dialogs_qfontdialog.cpp 1
+ If the user clicks OK the font they chose will be used for myWidget,
+ and if they click Cancel the original font is used.
+
+ \image plastique-fontdialog.png A font dialog in the Plastique widget style.
+
+ \sa QFont, QFontInfo, QFontMetrics, QColorDialog, QFileDialog, QPrintDialog,
+ {Standard Dialogs Example}
+*/
+
+/*!
+ \since 4.5
+
+ Constructs a standard font dialog.
+
+ Use setCurrentFont() to set the initial font attributes.
+
+ The \a parent parameter is passed to the QDialog constructor.
+
+ \sa getFont()
+*/
+QFontDialog::QFontDialog(QWidget *parent)
+ : QDialog(*new QFontDialogPrivate, parent, DefaultWindowFlags)
+{
+ Q_D(QFontDialog);
+ d->init();
+}
+
+/*!
+ \since 4.5
+
+ Constructs a standard font dialog with the given \a parent and specified
+ \a initial color.
+*/
+QFontDialog::QFontDialog(const QFont &initial, QWidget *parent)
+ : QDialog(*new QFontDialogPrivate, parent, DefaultWindowFlags)
+{
+ Q_D(QFontDialog);
+ d->init();
+ setCurrentFont(initial);
+}
+
+void QFontDialogPrivate::init()
+{
+ Q_Q(QFontDialog);
+
+#ifdef Q_WS_MAC
+ nativeDialogInUse = false;
+ delegate = 0;
+#endif
+
+ q->setSizeGripEnabled(true);
+ q->setWindowTitle(QFontDialog::tr("Select Font"));
+
+ // grid
+ familyEdit = new QLineEdit(q);
+ familyEdit->setReadOnly(true);
+ familyList = new QFontListView(q);
+ familyEdit->setFocusProxy(familyList);
+
+ familyAccel = new QLabel(q);
+#ifndef QT_NO_SHORTCUT
+ familyAccel->setBuddy(familyList);
+#endif
+ familyAccel->setIndent(2);
+
+ styleEdit = new QLineEdit(q);
+ styleEdit->setReadOnly(true);
+ styleList = new QFontListView(q);
+ styleEdit->setFocusProxy(styleList);
+
+ styleAccel = new QLabel(q);
+#ifndef QT_NO_SHORTCUT
+ styleAccel->setBuddy(styleList);
+#endif
+ styleAccel->setIndent(2);
+
+ sizeEdit = new QLineEdit(q);
+ sizeEdit->setFocusPolicy(Qt::ClickFocus);
+ QIntValidator *validator = new QIntValidator(1, 512, q);
+ sizeEdit->setValidator(validator);
+ sizeList = new QFontListView(q);
+
+ sizeAccel = new QLabel(q);
+#ifndef QT_NO_SHORTCUT
+ sizeAccel->setBuddy(sizeEdit);
+#endif
+ sizeAccel->setIndent(2);
+
+ // effects box
+ effects = new QGroupBox(q);
+ QVBoxLayout *vbox = new QVBoxLayout(effects);
+ strikeout = new QCheckBox(effects);
+ vbox->addWidget(strikeout);
+ underline = new QCheckBox(effects);
+ vbox->addWidget(underline);
+
+ sample = new QGroupBox(q);
+ QHBoxLayout *hbox = new QHBoxLayout(sample);
+ sampleEdit = new QLineEdit(sample);
+ sampleEdit->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored));
+ sampleEdit->setAlignment(Qt::AlignCenter);
+ // Note that the sample text is *not* translated with tr(), as the
+ // characters used depend on the charset encoding.
+ sampleEdit->setText(QLatin1String("AaBbYyZz"));
+ hbox->addWidget(sampleEdit);
+
+ writingSystemCombo = new QComboBox(q);
+
+ writingSystemAccel = new QLabel(q);
+#ifndef QT_NO_SHORTCUT
+ writingSystemAccel->setBuddy(writingSystemCombo);
+#endif
+ writingSystemAccel->setIndent(2);
+
+ size = 0;
+ smoothScalable = false;
+
+ QObject::connect(writingSystemCombo, SIGNAL(activated(int)), q, SLOT(_q_writingSystemHighlighted(int)));
+ QObject::connect(familyList, SIGNAL(highlighted(int)), q, SLOT(_q_familyHighlighted(int)));
+ QObject::connect(styleList, SIGNAL(highlighted(int)), q, SLOT(_q_styleHighlighted(int)));
+ QObject::connect(sizeList, SIGNAL(highlighted(int)), q, SLOT(_q_sizeHighlighted(int)));
+ QObject::connect(sizeEdit, SIGNAL(textChanged(QString)), q, SLOT(_q_sizeChanged(QString)));
+
+ QObject::connect(strikeout, SIGNAL(clicked()), q, SLOT(_q_updateSample()));
+ QObject::connect(underline, SIGNAL(clicked()), q, SLOT(_q_updateSample()));
+
+ for (int i = 0; i < QFontDatabase::WritingSystemsCount; ++i) {
+ QFontDatabase::WritingSystem ws = QFontDatabase::WritingSystem(i);
+ QString writingSystemName = QFontDatabase::writingSystemName(ws);
+ if (writingSystemName.isEmpty())
+ break;
+ writingSystemCombo->addItem(writingSystemName);
+ }
+
+ updateFamilies();
+ if (familyList->count() != 0)
+ familyList->setCurrentItem(0);
+
+ // grid layout
+ QGridLayout *mainGrid = new QGridLayout(q);
+
+ int spacing = mainGrid->spacing();
+ if (spacing >= 0) { // uniform spacing
+ mainGrid->setSpacing(0);
+
+ mainGrid->setColumnMinimumWidth(1, spacing);
+ mainGrid->setColumnMinimumWidth(3, spacing);
+
+ int margin = 0;
+ mainGrid->getContentsMargins(0, 0, 0, &margin);
+
+ mainGrid->setRowMinimumHeight(3, margin);
+ mainGrid->setRowMinimumHeight(6, 2);
+ mainGrid->setRowMinimumHeight(8, margin);
+ }
+
+ mainGrid->addWidget(familyAccel, 0, 0);
+ mainGrid->addWidget(familyEdit, 1, 0);
+ mainGrid->addWidget(familyList, 2, 0);
+
+ mainGrid->addWidget(styleAccel, 0, 2);
+ mainGrid->addWidget(styleEdit, 1, 2);
+ mainGrid->addWidget(styleList, 2, 2);
+
+ mainGrid->addWidget(sizeAccel, 0, 4);
+ mainGrid->addWidget(sizeEdit, 1, 4);
+ mainGrid->addWidget(sizeList, 2, 4);
+
+ mainGrid->setColumnStretch(0, 38);
+ mainGrid->setColumnStretch(2, 24);
+ mainGrid->setColumnStretch(4, 10);
+
+ mainGrid->addWidget(effects, 4, 0);
+
+ mainGrid->addWidget(sample, 4, 2, 4, 3);
+
+ mainGrid->addWidget(writingSystemAccel, 5, 0);
+ mainGrid->addWidget(writingSystemCombo, 7, 0);
+
+ buttonBox = new QDialogButtonBox(q);
+ mainGrid->addWidget(buttonBox, 9, 0, 1, 5);
+
+ QPushButton *button
+ = static_cast<QPushButton *>(buttonBox->addButton(QDialogButtonBox::Ok));
+ QObject::connect(buttonBox, SIGNAL(accepted()), q, SLOT(accept()));
+ button->setDefault(true);
+
+ buttonBox->addButton(QDialogButtonBox::Cancel);
+ QObject::connect(buttonBox, SIGNAL(rejected()), q, SLOT(reject()));
+
+#if defined(Q_WS_WINCE)
+ q->resize(180, 120);
+#elif defined(Q_WS_S60)
+ q->resize(QApplication::desktop()->availableGeometry(QCursor::pos()).size());
+#else
+ q->resize(500, 360);
+#endif // Q_WS_WINCE
+
+ sizeEdit->installEventFilter(q);
+ familyList->installEventFilter(q);
+ styleList->installEventFilter(q);
+ sizeList->installEventFilter(q);
+
+ familyList->setFocus();
+ retranslateStrings();
+}
+
+/*!
+ \internal
+ Destroys the font dialog and frees up its storage.
+*/
+
+QFontDialog::~QFontDialog()
+{
+#ifdef Q_WS_MAC
+ Q_D(QFontDialog);
+ if (d->delegate) {
+ d->closeCocoaFontPanel();
+ return;
+ }
+#endif
+}
+
+/*!
+ Executes a modal font dialog and returns a font.
+
+ If the user clicks \gui OK, the selected font is returned. If the user
+ clicks \gui Cancel, the \a initial font is returned.
+
+ The dialog is constructed with the given \a parent and the options specified
+ in \a options. \a title is shown as the window title of the dialog and \a
+ initial is the initially selected font. If the \a ok parameter is not-null,
+ the value it refers to is set to true if the user clicks \gui OK, and set to
+ false if the user clicks \gui Cancel.
+
+ Examples:
+ \snippet doc/src/snippets/code/src_gui_dialogs_qfontdialog.cpp 2
+
+ The dialog can also be used to set a widget's font directly:
+ \snippet doc/src/snippets/code/src_gui_dialogs_qfontdialog.cpp 3
+ In this example, if the user clicks OK the font they chose will be
+ used, and if they click Cancel the original font is used.
+
+ \warning Do not delete \a parent during the execution of the dialog.
+ If you want to do this, you should create the dialog
+ yourself using one of the QFontDialog constructors.
+*/
+QFont QFontDialog::getFont(bool *ok, const QFont &initial, QWidget *parent, const QString &title,
+ FontDialogOptions options)
+{
+ return QFontDialogPrivate::getFont(ok, initial, parent, title, options);
+}
+
+/*!
+ \overload
+ \since 4.5
+*/
+QFont QFontDialog::getFont(bool *ok, const QFont &initial, QWidget *parent, const QString &title)
+{
+ return QFontDialogPrivate::getFont(ok, initial, parent, title, 0);
+}
+
+/*!
+ \overload
+*/
+QFont QFontDialog::getFont(bool *ok, const QFont &initial, QWidget *parent)
+{
+ return QFontDialogPrivate::getFont(ok, initial, parent, QString(), 0);
+}
+
+/*!
+ \overload
+
+ Executes a modal font dialog and returns a font.
+
+ If the user clicks \gui OK, the selected font is returned. If the user
+ clicks \gui Cancel, the Qt default font is returned.
+
+ The dialog is constructed with the given \a parent.
+ If the \a ok parameter is not-null, the value it refers to is set
+ to true if the user clicks \gui OK, and false if the user clicks
+ \gui Cancel.
+
+ Example:
+ \snippet doc/src/snippets/code/src_gui_dialogs_qfontdialog.cpp 4
+
+ \warning Do not delete \a parent during the execution of the dialog.
+ If you want to do this, you should create the dialog
+ yourself using one of the QFontDialog constructors.
+*/
+QFont QFontDialog::getFont(bool *ok, QWidget *parent)
+{
+ QFont initial;
+ return QFontDialogPrivate::getFont(ok, initial, parent, QString(), 0);
+}
+
+QFont QFontDialogPrivate::getFont(bool *ok, const QFont &initial, QWidget *parent,
+ const QString &title, QFontDialog::FontDialogOptions options)
+{
+ QFontDialog dlg(parent);
+ dlg.setOptions(options);
+ dlg.setCurrentFont(initial);
+ if (!title.isEmpty())
+ dlg.setWindowTitle(title);
+
+ int ret = (dlg.exec() || (options & QFontDialog::NoButtons));
+ if (ok)
+ *ok = !!ret;
+ if (ret) {
+ return dlg.selectedFont();
+ } else {
+ return initial;
+ }
+}
+
+/*!
+ \internal
+ An event filter to make the Up, Down, PageUp and PageDown keys work
+ correctly in the line edits. The source of the event is the object
+ \a o and the event is \a e.
+*/
+
+bool QFontDialog::eventFilter(QObject *o , QEvent *e)
+{
+ Q_D(QFontDialog);
+ if (e->type() == QEvent::KeyPress) {
+ QKeyEvent *k = (QKeyEvent *)e;
+ if (o == d->sizeEdit &&
+ (k->key() == Qt::Key_Up ||
+ k->key() == Qt::Key_Down ||
+ k->key() == Qt::Key_PageUp ||
+ k->key() == Qt::Key_PageDown)) {
+
+ int ci = d->sizeList->currentItem();
+ (void)QApplication::sendEvent(d->sizeList, k);
+
+ if (ci != d->sizeList->currentItem()
+ && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, this))
+ d->sizeEdit->selectAll();
+ return true;
+ } else if ((o == d->familyList || o == d->styleList) &&
+ (k->key() == Qt::Key_Return || k->key() == Qt::Key_Enter)) {
+ k->accept();
+ accept();
+ return true;
+ }
+ } else if (e->type() == QEvent::FocusIn
+ && style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, this)) {
+ if (o == d->familyList)
+ d->familyEdit->selectAll();
+ else if (o == d->styleList)
+ d->styleEdit->selectAll();
+ else if (o == d->sizeList)
+ d->sizeEdit->selectAll();
+ } else if (e->type() == QEvent::MouseButtonPress && o == d->sizeList) {
+ d->sizeEdit->setFocus();
+ }
+ return QDialog::eventFilter(o, e);
+}
+
+/*
+ Updates the contents of the "font family" list box. This
+ function can be reimplemented if you have special requirements.
+*/
+
+void QFontDialogPrivate::updateFamilies()
+{
+ Q_Q(QFontDialog);
+
+ enum match_t { MATCH_NONE = 0, MATCH_LAST_RESORT = 1, MATCH_APP = 2, MATCH_FAMILY = 3 };
+
+ QStringList familyNames = fdb.families(writingSystem);
+
+ familyList->model()->setStringList(familyNames);
+
+ QString foundryName1, familyName1, foundryName2, familyName2;
+ int bestFamilyMatch = -1;
+ match_t bestFamilyType = MATCH_NONE;
+
+ QFont f;
+
+ // ##### do the right thing for a list of family names in the font.
+ QFontDatabase::parseFontName(family, foundryName1, familyName1);
+
+ QStringList::const_iterator it = familyNames.constBegin();
+ int i = 0;
+ for(; it != familyNames.constEnd(); ++it, ++i) {
+ QFontDatabase::parseFontName(*it, foundryName2, familyName2);
+
+ //try to match...
+ if (familyName1 == familyName2) {
+ bestFamilyType = MATCH_FAMILY;
+ if (foundryName1 == foundryName2) {
+ bestFamilyMatch = i;
+ break;
+ }
+ if (bestFamilyMatch < MATCH_FAMILY)
+ bestFamilyMatch = i;
+ }
+
+ //and try some fall backs
+ match_t type = MATCH_NONE;
+ if (bestFamilyType <= MATCH_NONE && familyName2 == f.lastResortFamily())
+ type = MATCH_LAST_RESORT;
+ if (bestFamilyType <= MATCH_LAST_RESORT && familyName2 == f.family())
+ type = MATCH_APP;
+ // ### add fallback for writingSystem
+ if (type != MATCH_NONE) {
+ bestFamilyType = type;
+ bestFamilyMatch = i;
+ }
+ }
+
+ if (i != -1 && bestFamilyType != MATCH_NONE)
+ familyList->setCurrentItem(bestFamilyMatch);
+ else
+ familyList->setCurrentItem(0);
+ familyEdit->setText(familyList->currentText());
+ if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
+ && familyList->hasFocus())
+ familyEdit->selectAll();
+
+ updateStyles();
+}
+
+/*
+ Updates the contents of the "font style" list box. This
+ function can be reimplemented if you have special requirements.
+*/
+void QFontDialogPrivate::updateStyles()
+{
+ Q_Q(QFontDialog);
+ QStringList styles = fdb.styles(familyList->currentText());
+ styleList->model()->setStringList(styles);
+
+ if (styles.isEmpty()) {
+ styleEdit->clear();
+ smoothScalable = false;
+ } else {
+ if (!style.isEmpty()) {
+ bool found = false;
+ bool first = true;
+ QString cstyle = style;
+
+ redo:
+ for (int i = 0; i < (int)styleList->count(); i++) {
+ if (cstyle == styleList->text(i)) {
+ styleList->setCurrentItem(i);
+ found = true;
+ break;
+ }
+ }
+ if (!found && first) {
+ if (cstyle.contains(QLatin1String("Italic"))) {
+ cstyle.replace(QLatin1String("Italic"), QLatin1String("Oblique"));
+ first = false;
+ goto redo;
+ } else if (cstyle.contains(QLatin1String("Oblique"))) {
+ cstyle.replace(QLatin1String("Oblique"), QLatin1String("Italic"));
+ first = false;
+ goto redo;
+ }
+ }
+ if (!found)
+ styleList->setCurrentItem(0);
+ } else {
+ styleList->setCurrentItem(0);
+ }
+
+ styleEdit->setText(styleList->currentText());
+ if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
+ && styleList->hasFocus())
+ styleEdit->selectAll();
+
+ smoothScalable = fdb.isSmoothlyScalable(familyList->currentText(), styleList->currentText());
+ }
+
+ updateSizes();
+}
+
+/*!
+ \internal
+ Updates the contents of the "font size" list box. This
+ function can be reimplemented if you have special requirements.
+*/
+
+void QFontDialogPrivate::updateSizes()
+{
+ Q_Q(QFontDialog);
+
+ if (!familyList->currentText().isEmpty()) {
+ QList<int> sizes = fdb.pointSizes(familyList->currentText(), styleList->currentText());
+
+ int i = 0;
+ int current = -1;
+ QStringList str_sizes;
+ for(QList<int>::const_iterator it = sizes.constBegin(); it != sizes.constEnd(); ++it) {
+ str_sizes.append(QString::number(*it));
+ if (current == -1 && *it >= size)
+ current = i;
+ ++i;
+ }
+ sizeList->model()->setStringList(str_sizes);
+ if (current == -1) {
+ // we request a size bigger than the ones in the list, select the biggest one
+ current = sizeList->count() - 1;
+ }
+ sizeList->setCurrentItem(current);
+
+ sizeEdit->blockSignals(true);
+ sizeEdit->setText((smoothScalable ? QString::number(size) : sizeList->currentText()));
+ if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
+ && sizeList->hasFocus())
+ sizeEdit->selectAll();
+ sizeEdit->blockSignals(false);
+ } else {
+ sizeEdit->clear();
+ }
+
+ _q_updateSample();
+}
+
+void QFontDialogPrivate::_q_updateSample()
+{
+ // compute new font
+ int pSize = sizeEdit->text().toInt();
+ QFont newFont(fdb.font(familyList->currentText(), style, pSize));
+ newFont.setStrikeOut(strikeout->isChecked());
+ newFont.setUnderline(underline->isChecked());
+
+ if (familyList->currentText().isEmpty())
+ sampleEdit->clear();
+
+ updateSampleFont(newFont);
+}
+
+void QFontDialogPrivate::updateSampleFont(const QFont &newFont)
+{
+ Q_Q(QFontDialog);
+ if (newFont != sampleEdit->font()) {
+ sampleEdit->setFont(newFont);
+ emit q->currentFontChanged(newFont);
+ }
+}
+
+/*!
+ \internal
+*/
+void QFontDialogPrivate::_q_writingSystemHighlighted(int index)
+{
+ writingSystem = QFontDatabase::WritingSystem(index);
+ sampleEdit->setText(fdb.writingSystemSample(writingSystem));
+ updateFamilies();
+}
+
+/*!
+ \internal
+*/
+void QFontDialogPrivate::_q_familyHighlighted(int i)
+{
+ Q_Q(QFontDialog);
+ family = familyList->text(i);
+ familyEdit->setText(family);
+ if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
+ && familyList->hasFocus())
+ familyEdit->selectAll();
+
+ updateStyles();
+}
+
+
+/*!
+ \internal
+*/
+
+void QFontDialogPrivate::_q_styleHighlighted(int index)
+{
+ Q_Q(QFontDialog);
+ QString s = styleList->text(index);
+ styleEdit->setText(s);
+ if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
+ && styleList->hasFocus())
+ styleEdit->selectAll();
+
+ style = s;
+
+ updateSizes();
+}
+
+
+/*!
+ \internal
+*/
+
+void QFontDialogPrivate::_q_sizeHighlighted(int index)
+{
+ Q_Q(QFontDialog);
+ QString s = sizeList->text(index);
+ sizeEdit->setText(s);
+ if (q->style()->styleHint(QStyle::SH_FontDialog_SelectAssociatedText, 0, q)
+ && sizeEdit->hasFocus())
+ sizeEdit->selectAll();
+
+ size = s.toInt();
+ _q_updateSample();
+}
+
+/*!
+ \internal
+ This slot is called if the user changes the font size.
+ The size is passed in the \a s argument as a \e string.
+*/
+
+void QFontDialogPrivate::_q_sizeChanged(const QString &s)
+{
+ // no need to check if the conversion is valid, since we have an QIntValidator in the size edit
+ int size = s.toInt();
+ if (this->size == size)
+ return;
+
+ this->size = size;
+ if (sizeList->count() != 0) {
+ int i;
+ for (i = 0; i < sizeList->count() - 1; i++) {
+ if (sizeList->text(i).toInt() >= this->size)
+ break;
+ }
+ sizeList->blockSignals(true);
+ sizeList->setCurrentItem(i);
+ sizeList->blockSignals(false);
+ }
+ _q_updateSample();
+}
+
+void QFontDialogPrivate::retranslateStrings()
+{
+ familyAccel->setText(QFontDialog::tr("&Font"));
+ styleAccel->setText(QFontDialog::tr("Font st&yle"));
+ sizeAccel->setText(QFontDialog::tr("&Size"));
+#ifndef Q_WS_S60
+ // Removed the title due to lack of screen estate in small S60 screen.
+ // The effects are descriptive without a title (strikeout, underline).
+ effects->setTitle(QFontDialog::tr("Effects"));
+#endif
+ strikeout->setText(QFontDialog::tr("Stri&keout"));
+ underline->setText(QFontDialog::tr("&Underline"));
+ sample->setTitle(QFontDialog::tr("Sample"));
+ writingSystemAccel->setText(QFontDialog::tr("Wr&iting System"));
+}
+
+/*!
+ \reimp
+*/
+void QFontDialog::changeEvent(QEvent *e)
+{
+ Q_D(QFontDialog);
+ if (e->type() == QEvent::LanguageChange) {
+ d->retranslateStrings();
+ }
+ QDialog::changeEvent(e);
+}
+
+/*!
+ \since 4.5
+
+ \property QFontDialog::currentFont
+ \brief the current font of the dialog.
+*/
+
+/*!
+ \since 4.5
+
+ Sets the font highlighted in the QFontDialog to the given \a font.
+
+ \sa selectedFont()
+*/
+void QFontDialog::setCurrentFont(const QFont &font)
+{
+ Q_D(QFontDialog);
+ d->family = font.family();
+ d->style = d->fdb.styleString(font);
+ d->size = font.pointSize();
+ if (d->size == -1) {
+ QFontInfo fi(font);
+ d->size = fi.pointSize();
+ }
+ d->strikeout->setChecked(font.strikeOut());
+ d->underline->setChecked(font.underline());
+ d->updateFamilies();
+
+#ifdef Q_WS_MAC
+ if (d->delegate)
+ QFontDialogPrivate::setFont(d->delegate, font);
+#endif
+}
+
+/*!
+ \since 4.5
+
+ Returns the current font.
+
+ \sa selectedFont()
+*/
+QFont QFontDialog::currentFont() const
+{
+ Q_D(const QFontDialog);
+ return d->sampleEdit->font();
+}
+
+/*!
+ Returns the font that the user selected by clicking the \gui{OK}
+ or equivalent button.
+
+ \note This font is not always the same as the font held by the
+ \l currentFont property since the user can choose different fonts
+ before finally selecting the one to use.
+*/
+QFont QFontDialog::selectedFont() const
+{
+ Q_D(const QFontDialog);
+ return d->selectedFont;
+}
+
+/*!
+ \enum QFontDialog::FontDialogOption
+ \since 4.5
+
+ This enum specifies various options that affect the look and feel
+ of a font dialog.
+
+ \value NoButtons Don't display \gui{OK} and \gui{Cancel} buttons. (Useful for "live dialogs".)
+ \value DontUseNativeDialog Use Qt's standard font dialog on the Mac instead of Apple's
+ native font panel. (Currently, the native dialog is never used,
+ but this is likely to change in future Qt releases.)
+
+ \sa options, setOption(), testOption()
+*/
+
+/*!
+ Sets the given \a option to be enabled if \a on is true;
+ otherwise, clears the given \a option.
+
+ \sa options, testOption()
+*/
+void QFontDialog::setOption(FontDialogOption option, bool on)
+{
+ Q_D(QFontDialog);
+ if (!(d->opts & option) != !on)
+ setOptions(d->opts ^ option);
+}
+
+/*!
+ Returns true if the given \a option is enabled; otherwise, returns
+ false.
+
+ \sa options, setOption()
+*/
+bool QFontDialog::testOption(FontDialogOption option) const
+{
+ Q_D(const QFontDialog);
+ return (d->opts & option) != 0;
+}
+
+/*!
+ \property QFontDialog::options
+ \brief the various options that affect the look and feel of the dialog
+ \since 4.5
+
+ By default, all options are disabled.
+
+ Options should be set before showing the dialog. Setting them while the
+ dialog is visible is not guaranteed to have an immediate effect on the
+ dialog (depending on the option and on the platform).
+
+ \sa setOption(), testOption()
+*/
+void QFontDialog::setOptions(FontDialogOptions options)
+{
+ Q_D(QFontDialog);
+
+ FontDialogOptions changed = (options ^ d->opts);
+ if (!changed)
+ return;
+
+ d->opts = options;
+ d->buttonBox->setVisible(!(options & NoButtons));
+}
+
+QFontDialog::FontDialogOptions QFontDialog::options() const
+{
+ Q_D(const QFontDialog);
+ return d->opts;
+}
+
+#ifdef Q_WS_MAC
+// can only have one Cocoa font panel active
+bool QFontDialogPrivate::sharedFontPanelAvailable = true;
+#endif
+
+/*!
+ \since 4.5
+ \overload
+
+ Opens the dialog and connects its fontSelected() signal to the slot specified
+ by \a receiver and \a member.
+
+ The signal will be disconnected from the slot when the dialog is closed.
+*/
+void QFontDialog::open(QObject *receiver, const char *member)
+{
+ Q_D(QFontDialog);
+ connect(this, SIGNAL(fontSelected(QFont)), receiver, member);
+ d->receiverToDisconnectOnClose = receiver;
+ d->memberToDisconnectOnClose = member;
+ QDialog::open();
+}
+
+/*!
+ \since 4.5
+
+ \fn void QFontDialog::currentFontChanged(const QFont &font)
+
+ This signal is emitted when the current font is changed. The new font is
+ specified in \a font.
+
+ The signal is emitted while a user is selecting a font. Ultimately, the
+ chosen font may differ from the font currently selected.
+
+ \sa currentFont, fontSelected(), selectedFont()
+*/
+
+/*!
+ \since 4.5
+
+ \fn void QFontDialog::fontSelected(const QFont &font)
+
+ This signal is emitted when a font has been selected. The selected font is
+ specified in \a font.
+
+ The signal is only emitted when a user has chosen the final font to be
+ used. It is not emitted while the user is changing the current font in the
+ font dialog.
+
+ \sa selectedFont(), currentFontChanged(), currentFont
+*/
+
+/*!
+ \reimp
+*/
+void QFontDialog::setVisible(bool visible)
+{
+ if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden) != visible)
+ return;
+#ifdef Q_WS_MAC
+ Q_D(QFontDialog);
+ if (d->canBeNativeDialog()){
+ if (d->setVisible_sys(visible)){
+ d->nativeDialogInUse = true;
+ // Set WA_DontShowOnScreen so that QDialog::setVisible(visible) below
+ // updates the state correctly, but skips showing the non-native version:
+ setAttribute(Qt::WA_DontShowOnScreen, true);
+ } else {
+ d->nativeDialogInUse = false;
+ setAttribute(Qt::WA_DontShowOnScreen, false);
+ }
+ }
+#endif // Q_WS_MAC
+ QDialog::setVisible(visible);
+}
+
+/*!
+ Closes the dialog and sets its result code to \a result. If this dialog
+ is shown with exec(), done() causes the local event loop to finish,
+ and exec() to return \a result.
+
+ \sa QDialog::done()
+*/
+void QFontDialog::done(int result)
+{
+ Q_D(QFontDialog);
+ QDialog::done(result);
+ if (result == Accepted) {
+ // We check if this is the same font we had before, if so we emit currentFontChanged
+ QFont selectedFont = currentFont();
+ if(selectedFont != d->selectedFont)
+ emit(currentFontChanged(selectedFont));
+ d->selectedFont = selectedFont;
+ emit fontSelected(d->selectedFont);
+ } else
+ d->selectedFont = QFont();
+ if (d->receiverToDisconnectOnClose) {
+ disconnect(this, SIGNAL(fontSelected(QFont)),
+ d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
+ d->receiverToDisconnectOnClose = 0;
+ }
+ d->memberToDisconnectOnClose.clear();
+}
+
+#ifdef Q_WS_MAC
+bool QFontDialogPrivate::canBeNativeDialog()
+{
+ Q_Q(QFontDialog);
+ if (nativeDialogInUse)
+ return true;
+ if (q->testAttribute(Qt::WA_DontShowOnScreen))
+ return false;
+ if (opts & QFontDialog::DontUseNativeDialog)
+ return false;
+
+ QLatin1String staticName(QFontDialog::staticMetaObject.className());
+ QLatin1String dynamicName(q->metaObject()->className());
+ return (staticName == dynamicName);
+}
+#endif // Q_WS_MAC
+
+/*!
+ \fn QFont QFontDialog::getFont(bool *ok, const QFont &initial, QWidget* parent, const char* name)
+ \since 4.5
+
+ Call getFont(\a ok, \a initial, \a parent) instead.
+
+ \warning Do not delete \a parent during the execution of the dialog.
+ If you want to do this, you should create the dialog
+ yourself using one of the QFontDialog constructors.
+
+ The \a name parameter is ignored.
+*/
+
+/*!
+ \fn QFont QFontDialog::getFont(bool *ok, QWidget* parent, const char* name)
+
+ Call getFont(\a ok, \a parent) instead.
+
+ \warning Do not delete \a parent during the execution of the dialog.
+ If you want to do this, you should create the dialog
+ yourself using one of the QFontDialog constructors.
+
+ The \a name parameter is ignored.
+*/
+
+QT_END_NAMESPACE
+
+#include "qfontdialog.moc"
+#include "moc_qfontdialog.cpp"
+
+#endif // QT_NO_FONTDIALOG
diff --git a/src/widgets/dialogs/qfontdialog.h b/src/widgets/dialogs/qfontdialog.h
new file mode 100644
index 0000000000..998e384abd
--- /dev/null
+++ b/src/widgets/dialogs/qfontdialog.h
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QFONTDIALOG_H
+#define QFONTDIALOG_H
+
+#include <QtGui/qwindowdefs.h>
+#include <QtWidgets/qdialog.h>
+#include <QtGui/qfont.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_FONTDIALOG
+
+class QFontDialogPrivate;
+
+class Q_GUI_EXPORT QFontDialog : public QDialog
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QFontDialog)
+ Q_ENUMS(FontDialogOption)
+ Q_PROPERTY(QFont currentFont READ currentFont WRITE setCurrentFont NOTIFY currentFontChanged)
+ Q_PROPERTY(FontDialogOptions options READ options WRITE setOptions)
+
+public:
+ enum FontDialogOption {
+ NoButtons = 0x00000001,
+ DontUseNativeDialog = 0x00000002
+ };
+
+ Q_DECLARE_FLAGS(FontDialogOptions, FontDialogOption)
+
+ explicit QFontDialog(QWidget *parent = 0);
+ explicit QFontDialog(const QFont &initial, QWidget *parent = 0);
+ ~QFontDialog();
+
+ void setCurrentFont(const QFont &font);
+ QFont currentFont() const;
+
+ QFont selectedFont() const;
+
+ void setOption(FontDialogOption option, bool on = true);
+ bool testOption(FontDialogOption option) const;
+ void setOptions(FontDialogOptions options);
+ FontDialogOptions options() const;
+
+#ifdef Q_NO_USING_KEYWORD
+#ifndef Q_QDOC
+ void open() { QDialog::open(); }
+#endif
+#else
+ using QDialog::open;
+#endif
+ void open(QObject *receiver, const char *member);
+
+ void setVisible(bool visible);
+
+ // ### Qt 5: merge overloads
+ static QFont getFont(bool *ok, const QFont &initial, QWidget *parent, const QString &title,
+ FontDialogOptions options);
+ static QFont getFont(bool *ok, const QFont &initial, QWidget *parent, const QString &title);
+ static QFont getFont(bool *ok, const QFont &initial, QWidget *parent = 0);
+ static QFont getFont(bool *ok, QWidget *parent = 0);
+
+#ifdef QT3_SUPPORT
+ static QFont getFont(bool *ok, const QFont &initial, QWidget *parent, const char *name)
+ { Q_UNUSED(name); return getFont(ok, initial, parent); }
+ static QFont getFont(bool *ok, QWidget *parent, const char *name)
+ { Q_UNUSED(name); return getFont(ok, parent); }
+#endif
+
+Q_SIGNALS:
+ void currentFontChanged(const QFont &font);
+ void fontSelected(const QFont &font);
+
+protected:
+ void changeEvent(QEvent *event);
+ void done(int result);
+
+private:
+ // ### Qt 5: make protected
+ bool eventFilter(QObject *object, QEvent *event);
+
+ Q_DISABLE_COPY(QFontDialog)
+
+ Q_PRIVATE_SLOT(d_func(), void _q_sizeChanged(const QString &))
+ Q_PRIVATE_SLOT(d_func(), void _q_familyHighlighted(int))
+ Q_PRIVATE_SLOT(d_func(), void _q_writingSystemHighlighted(int))
+ Q_PRIVATE_SLOT(d_func(), void _q_styleHighlighted(int))
+ Q_PRIVATE_SLOT(d_func(), void _q_sizeHighlighted(int))
+ Q_PRIVATE_SLOT(d_func(), void _q_updateSample())
+#if defined(Q_WS_MAC)
+ Q_PRIVATE_SLOT(d_func(), void _q_macRunNativeAppModalPanel())
+#endif
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QFontDialog::FontDialogOptions)
+
+#endif // QT_NO_FONTDIALOG
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QFONTDIALOG_H
diff --git a/src/gui/dialogs/qfontdialog_mac.mm b/src/widgets/dialogs/qfontdialog_mac.mm
index 1552ad675f..1552ad675f 100644
--- a/src/gui/dialogs/qfontdialog_mac.mm
+++ b/src/widgets/dialogs/qfontdialog_mac.mm
diff --git a/src/gui/dialogs/qfontdialog_p.h b/src/widgets/dialogs/qfontdialog_p.h
index 3179b89af7..3179b89af7 100644
--- a/src/gui/dialogs/qfontdialog_p.h
+++ b/src/widgets/dialogs/qfontdialog_p.h
diff --git a/src/widgets/dialogs/qfscompleter_p.h b/src/widgets/dialogs/qfscompleter_p.h
new file mode 100644
index 0000000000..9bb7ca1c26
--- /dev/null
+++ b/src/widgets/dialogs/qfscompleter_p.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QFSCOMPLETOR_P_H
+#define QFSCOMPLETOR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qcompleter.h"
+#include <QtWidgets/qfilesystemmodel.h>
+QT_BEGIN_NAMESPACE
+#ifndef QT_NO_FSCOMPLETER
+
+/*!
+ QCompleter that can deal with QFileSystemModel
+ */
+class QFSCompleter : public QCompleter {
+public:
+ QFSCompleter(QFileSystemModel *model, QObject *parent = 0)
+ : QCompleter(model, parent), proxyModel(0), sourceModel(model)
+ {
+#if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)
+ setCaseSensitivity(Qt::CaseInsensitive);
+#endif
+ }
+ QString pathFromIndex(const QModelIndex &index) const;
+ QStringList splitPath(const QString& path) const;
+
+ QAbstractProxyModel *proxyModel;
+ QFileSystemModel *sourceModel;
+};
+#endif // QT_NO_FSCOMPLETER
+QT_END_NAMESPACE
+#endif // QFSCOMPLETOR_P_H
+
diff --git a/src/gui/dialogs/qinputdialog.cpp b/src/widgets/dialogs/qinputdialog.cpp
index f13b8f55c3..f13b8f55c3 100644
--- a/src/gui/dialogs/qinputdialog.cpp
+++ b/src/widgets/dialogs/qinputdialog.cpp
diff --git a/src/widgets/dialogs/qinputdialog.h b/src/widgets/dialogs/qinputdialog.h
new file mode 100644
index 0000000000..6d8892a7f3
--- /dev/null
+++ b/src/widgets/dialogs/qinputdialog.h
@@ -0,0 +1,256 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QINPUTDIALOG_H
+#define QINPUTDIALOG_H
+
+#include <QtWidgets/qdialog.h>
+#include <QtCore/qstring.h>
+#include <QtWidgets/qlineedit.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_INPUTDIALOG
+
+class QInputDialogPrivate;
+
+class Q_GUI_EXPORT QInputDialog : public QDialog
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QInputDialog)
+// Q_ENUMS(InputMode InputDialogOption)
+ QDOC_PROPERTY(InputMode inputMode READ inputMode WRITE setInputMode)
+ QDOC_PROPERTY(QString labelText READ labelText WRITE setLabelText)
+ QDOC_PROPERTY(InputDialogOptions options READ options WRITE setOptions)
+ QDOC_PROPERTY(QString textValue READ textValue WRITE setTextValue NOTIFY textValueChanged)
+ QDOC_PROPERTY(int intValue READ intValue WRITE setIntValue NOTIFY intValueChanged)
+ QDOC_PROPERTY(int doubleValue READ doubleValue WRITE setDoubleValue NOTIFY doubleValueChanged)
+ QDOC_PROPERTY(QLineEdit::EchoMode textEchoMode READ textEchoMode WRITE setTextEchoMode)
+ QDOC_PROPERTY(bool comboBoxEditable READ isComboBoxEditable WRITE setComboBoxEditable)
+ QDOC_PROPERTY(QStringList comboBoxItems READ comboBoxItems WRITE setComboBoxItems)
+ QDOC_PROPERTY(int intMinimum READ intMinimum WRITE setIntMinimum)
+ QDOC_PROPERTY(int intMaximum READ intMaximum WRITE setIntMaximum)
+ QDOC_PROPERTY(int intStep READ intStep WRITE setIntStep)
+ QDOC_PROPERTY(double doubleMinimum READ doubleMinimum WRITE setDoubleMinimum)
+ QDOC_PROPERTY(double doubleMaximum READ doubleMaximum WRITE setDoubleMaximum)
+ QDOC_PROPERTY(int doubleDecimals READ doubleDecimals WRITE setDoubleDecimals)
+ QDOC_PROPERTY(QString okButtonText READ okButtonText WRITE setOkButtonText)
+ QDOC_PROPERTY(QString cancelButtonText READ cancelButtonText WRITE setCancelButtonText)
+
+public:
+ enum InputDialogOption {
+ NoButtons = 0x00000001,
+ UseListViewForComboBoxItems = 0x00000002
+ };
+
+ Q_DECLARE_FLAGS(InputDialogOptions, InputDialogOption)
+
+ enum InputMode {
+ TextInput,
+ IntInput,
+ DoubleInput
+ };
+
+ QInputDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0);
+ ~QInputDialog();
+
+ void setInputMode(InputMode mode);
+ InputMode inputMode() const;
+
+ void setLabelText(const QString &text);
+ QString labelText() const;
+
+ void setOption(InputDialogOption option, bool on = true);
+ bool testOption(InputDialogOption option) const;
+ void setOptions(InputDialogOptions options);
+ InputDialogOptions options() const;
+
+ void setTextValue(const QString &text);
+ QString textValue() const;
+
+ void setTextEchoMode(QLineEdit::EchoMode mode);
+ QLineEdit::EchoMode textEchoMode() const;
+
+ void setComboBoxEditable(bool editable);
+ bool isComboBoxEditable() const;
+
+ void setComboBoxItems(const QStringList &items);
+ QStringList comboBoxItems() const;
+
+ void setIntValue(int value);
+ int intValue() const;
+
+ void setIntMinimum(int min);
+ int intMinimum() const;
+
+ void setIntMaximum(int max);
+ int intMaximum() const;
+
+ void setIntRange(int min, int max);
+
+ void setIntStep(int step);
+ int intStep() const;
+
+ void setDoubleValue(double value);
+ double doubleValue() const;
+
+ void setDoubleMinimum(double min);
+ double doubleMinimum() const;
+
+ void setDoubleMaximum(double max);
+ double doubleMaximum() const;
+
+ void setDoubleRange(double min, double max);
+
+ void setDoubleDecimals(int decimals);
+ int doubleDecimals() const;
+
+ void setOkButtonText(const QString &text);
+ QString okButtonText() const;
+
+ void setCancelButtonText(const QString &text);
+ QString cancelButtonText() const;
+
+#ifdef Q_NO_USING_KEYWORD
+#ifndef Q_QDOC
+ void open() { QDialog::open(); }
+#endif
+#else
+ using QDialog::open;
+#endif
+ void open(QObject *receiver, const char *member);
+
+ QSize minimumSizeHint() const;
+ QSize sizeHint() const;
+
+ void setVisible(bool visible);
+
+#ifdef Q_QDOC
+ static QString getText(QWidget *parent, const QString &title, const QString &label,
+ QLineEdit::EchoMode echo = QLineEdit::Normal,
+ const QString &text = QString(), bool *ok = 0, Qt::WindowFlags flags = 0,
+ Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
+ static QString getItem(QWidget *parent, const QString &title, const QString &label,
+ const QStringList &items, int current = 0, bool editable = true,
+ bool *ok = 0, Qt::WindowFlags flags = 0,
+ Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
+#else
+ static QString getText(QWidget *parent, const QString &title, const QString &label,
+ QLineEdit::EchoMode echo = QLineEdit::Normal,
+ const QString &text = QString(), bool *ok = 0, Qt::WindowFlags flags = 0);
+ static QString getItem(QWidget *parent, const QString &title, const QString &label,
+ const QStringList &items, int current = 0, bool editable = true,
+ bool *ok = 0, Qt::WindowFlags flags = 0);
+ static QString getText(QWidget *parent, const QString &title, const QString &label,
+ QLineEdit::EchoMode echo,
+ const QString &text, bool *ok, Qt::WindowFlags flags,
+ Qt::InputMethodHints inputMethodHints);
+ static QString getItem(QWidget *parent, const QString &title, const QString &label,
+ const QStringList &items, int current, bool editable,
+ bool *ok, Qt::WindowFlags flags,
+ Qt::InputMethodHints inputMethodHints);
+#endif
+ static int getInt(QWidget *parent, const QString &title, const QString &label, int value = 0,
+ int minValue = -2147483647, int maxValue = 2147483647,
+ int step = 1, bool *ok = 0, Qt::WindowFlags flags = 0);
+ static double getDouble(QWidget *parent, const QString &title, const QString &label, double value = 0,
+ double minValue = -2147483647, double maxValue = 2147483647,
+ int decimals = 1, bool *ok = 0, Qt::WindowFlags flags = 0);
+
+ // obsolete
+ static int getInteger(QWidget *parent, const QString &title, const QString &label, int value = 0,
+ int minValue = -2147483647, int maxValue = 2147483647,
+ int step = 1, bool *ok = 0, Qt::WindowFlags flags = 0);
+
+#ifdef QT3_SUPPORT
+ inline static QT3_SUPPORT QString getText(const QString &title, const QString &label,
+ QLineEdit::EchoMode echo = QLineEdit::Normal,
+ const QString &text = QString(), bool *ok = 0,
+ QWidget *parent = 0, const char * = 0, Qt::WindowFlags flags = 0)
+ { return getText(parent, title, label, echo, text, ok, flags); }
+ inline static QT3_SUPPORT int getInteger(const QString &title, const QString &label, int value = 0,
+ int minValue = -2147483647, int maxValue = 2147483647,
+ int step = 1, bool *ok = 0,
+ QWidget *parent = 0, const char * = 0, Qt::WindowFlags flags = 0)
+ { return getInteger(parent, title, label, value, minValue, maxValue, step, ok, flags); }
+ inline static QT3_SUPPORT double getDouble(const QString &title, const QString &label, double value = 0,
+ double minValue = -2147483647, double maxValue = 2147483647,
+ int decimals = 1, bool *ok = 0,
+ QWidget *parent = 0, const char * = 0, Qt::WindowFlags flags = 0)
+ { return getDouble(parent, title, label, value, minValue, maxValue, decimals, ok, flags); }
+ inline static QT3_SUPPORT QString getItem(const QString &title, const QString &label, const QStringList &list,
+ int current = 0, bool editable = true, bool *ok = 0,
+ QWidget *parent = 0, const char * = 0, Qt::WindowFlags flags = 0)
+ { return getItem(parent, title, label, list, current, editable, ok, flags); }
+#endif
+
+Q_SIGNALS:
+ // ### emit signals!
+ void textValueChanged(const QString &text);
+ void textValueSelected(const QString &text);
+ void intValueChanged(int value);
+ void intValueSelected(int value);
+ void doubleValueChanged(double value);
+ void doubleValueSelected(double value);
+
+
+public:
+ void done(int result); // ### Qt 5: Make protected.
+
+private:
+ Q_DISABLE_COPY(QInputDialog)
+ Q_PRIVATE_SLOT(d_func(), void _q_textChanged(const QString&))
+ Q_PRIVATE_SLOT(d_func(), void _q_currentRowChanged(const QModelIndex&, const QModelIndex&))
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QInputDialog::InputDialogOptions)
+
+#endif // QT_NO_INPUTDIALOG
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QINPUTDIALOG_H
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp
new file mode 100644
index 0000000000..5466a3838c
--- /dev/null
+++ b/src/widgets/dialogs/qmessagebox.cpp
@@ -0,0 +1,2751 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtWidgets/qmessagebox.h>
+
+#ifndef QT_NO_MESSAGEBOX
+
+#include <QtWidgets/qdialogbuttonbox.h>
+#include "private/qlabel_p.h"
+#include "private/qapplication_p.h"
+#include <QtCore/qlist.h>
+#include <QtCore/qdebug.h>
+#include <QtWidgets/qstyle.h>
+#include <QtWidgets/qstyleoption.h>
+#include <QtWidgets/qgridlayout.h>
+#include <QtWidgets/qdesktopwidget.h>
+#include <QtWidgets/qpushbutton.h>
+#include <QtWidgets/qaccessible.h>
+#include <QtWidgets/qicon.h>
+#include <QtGui/qtextdocument.h>
+#include <QtWidgets/qapplication.h>
+#include <QtWidgets/qtextedit.h>
+#include <QtWidgets/qtextbrowser.h>
+#include <QtWidgets/qmenu.h>
+#include "qdialog_p.h"
+#include <QtGui/qfont.h>
+#include <QtGui/qfontmetrics.h>
+#include <QtGui/qclipboard.h>
+
+#ifndef QT_NO_STYLE_S60
+#include <qs60style.h>
+#endif
+
+#ifdef Q_WS_WINCE
+extern bool qt_wince_is_mobile(); //defined in qguifunctions_wince.cpp
+extern bool qt_wince_is_smartphone();//defined in qguifunctions_wince.cpp
+extern bool qt_wince_is_pocket_pc(); //defined in qguifunctions_wince.cpp
+
+#include "qguifunctions_wince.h"
+#endif
+
+QT_BEGIN_NAMESPACE
+
+enum Button { Old_Ok = 1, Old_Cancel = 2, Old_Yes = 3, Old_No = 4, Old_Abort = 5, Old_Retry = 6,
+ Old_Ignore = 7, Old_YesAll = 8, Old_NoAll = 9, Old_ButtonMask = 0xFF,
+ NewButtonMask = 0xFFFFFC00 };
+
+enum DetailButtonLabel { ShowLabel = 0, HideLabel = 1 };
+#ifndef QT_NO_TEXTEDIT
+class QMessageBoxDetailsText : public QWidget
+{
+public:
+ class TextEdit : public QTextEdit
+ {
+ public:
+ TextEdit(QWidget *parent=0) : QTextEdit(parent) { }
+ void contextMenuEvent(QContextMenuEvent * e)
+ {
+#ifndef QT_NO_CONTEXTMENU
+ QMenu *menu = createStandardContextMenu();
+ menu->setAttribute(Qt::WA_DeleteOnClose);
+ menu->popup(e->globalPos());
+#else
+ Q_UNUSED(e);
+#endif
+ }
+ };
+
+ QMessageBoxDetailsText(QWidget *parent=0)
+ : QWidget(parent)
+ {
+ QVBoxLayout *layout = new QVBoxLayout;
+ layout->setMargin(0);
+ QFrame *line = new QFrame(this);
+ line->setFrameShape(QFrame::HLine);
+ line->setFrameShadow(QFrame::Sunken);
+ layout->addWidget(line);
+ textEdit = new TextEdit();
+ textEdit->setFixedHeight(100);
+ textEdit->setFocusPolicy(Qt::NoFocus);
+ textEdit->setReadOnly(true);
+ layout->addWidget(textEdit);
+ setLayout(layout);
+ }
+ void setText(const QString &text) { textEdit->setPlainText(text); }
+ QString text() const { return textEdit->toPlainText(); }
+private:
+ TextEdit *textEdit;
+};
+#endif // QT_NO_TEXTEDIT
+
+class DetailButton : public QPushButton
+{
+public:
+ DetailButton(QWidget *parent) : QPushButton(label(ShowLabel), parent)
+ {
+ setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ }
+
+ QString label(DetailButtonLabel label) const
+ { return label == ShowLabel ? QMessageBox::tr("Show Details...") : QMessageBox::tr("Hide Details..."); }
+
+ void setLabel(DetailButtonLabel lbl)
+ { setText(label(lbl)); }
+
+ QSize sizeHint() const
+ {
+ ensurePolished();
+ QStyleOptionButton opt;
+ initStyleOption(&opt);
+ const QFontMetrics fm = fontMetrics();
+ opt.text = label(ShowLabel);
+ QSize sz = fm.size(Qt::TextShowMnemonic, opt.text);
+ QSize ret = style()->sizeFromContents(QStyle::CT_PushButton, &opt, sz, this).
+ expandedTo(QApplication::globalStrut());
+ opt.text = label(HideLabel);
+ sz = fm.size(Qt::TextShowMnemonic, opt.text);
+ ret.expandedTo(style()->sizeFromContents(QStyle::CT_PushButton, &opt, sz, this).
+ expandedTo(QApplication::globalStrut()));
+ return ret;
+ }
+};
+
+
+class QMessageBoxPrivate : public QDialogPrivate
+{
+ Q_DECLARE_PUBLIC(QMessageBox)
+
+public:
+ QMessageBoxPrivate() : escapeButton(0), defaultButton(0), clickedButton(0), detailsButton(0),
+#ifndef QT_NO_TEXTEDIT
+ detailsText(0),
+#endif
+ compatMode(false), autoAddOkButton(true),
+ detectedEscapeButton(0), informativeLabel(0) { }
+
+ void init(const QString &title = QString(), const QString &text = QString());
+ void _q_buttonClicked(QAbstractButton *);
+
+ QAbstractButton *findButton(int button0, int button1, int button2, int flags);
+ void addOldButtons(int button0, int button1, int button2);
+
+ QAbstractButton *abstractButtonForId(int id) const;
+ int execReturnCode(QAbstractButton *button);
+
+ void detectEscapeButton();
+ void updateSize();
+ int layoutMinimumWidth();
+ void retranslateStrings();
+
+#ifdef Q_WS_WINCE
+ void hideSpecial();
+#endif
+
+ static int showOldMessageBox(QWidget *parent, QMessageBox::Icon icon,
+ const QString &title, const QString &text,
+ int button0, int button1, int button2);
+ static int showOldMessageBox(QWidget *parent, QMessageBox::Icon icon,
+ const QString &title, const QString &text,
+ const QString &button0Text,
+ const QString &button1Text,
+ const QString &button2Text,
+ int defaultButtonNumber,
+ int escapeButtonNumber);
+
+ static QMessageBox::StandardButton showNewMessageBox(QWidget *parent,
+ QMessageBox::Icon icon, const QString& title, const QString& text,
+ QMessageBox::StandardButtons buttons, QMessageBox::StandardButton defaultButton);
+
+ static QPixmap standardIcon(QMessageBox::Icon icon, QMessageBox *mb);
+
+ QLabel *label;
+ QMessageBox::Icon icon;
+ QLabel *iconLabel;
+ QDialogButtonBox *buttonBox;
+ QList<QAbstractButton *> customButtonList;
+ QAbstractButton *escapeButton;
+ QPushButton *defaultButton;
+ QAbstractButton *clickedButton;
+ DetailButton *detailsButton;
+#ifndef QT_NO_TEXTEDIT
+ QMessageBoxDetailsText *detailsText;
+#endif
+ bool compatMode;
+ bool autoAddOkButton;
+ QAbstractButton *detectedEscapeButton;
+ QLabel *informativeLabel;
+#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5)
+ QTextBrowser *textBrowser;
+#endif
+ QPointer<QObject> receiverToDisconnectOnClose;
+ QByteArray memberToDisconnectOnClose;
+ QByteArray signalToDisconnectOnClose;
+};
+
+void QMessageBoxPrivate::init(const QString &title, const QString &text)
+{
+ Q_Q(QMessageBox);
+
+ label = new QLabel;
+ label->setObjectName(QLatin1String("qt_msgbox_label"));
+ label->setTextInteractionFlags(Qt::TextInteractionFlags(q->style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, 0, q)));
+ label->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
+ label->setOpenExternalLinks(true);
+#if defined(Q_WS_MAC)
+ label->setContentsMargins(16, 0, 0, 0);
+#elif !defined(Q_WS_QWS)
+ label->setContentsMargins(2, 0, 0, 0);
+ label->setIndent(9);
+#endif
+ icon = QMessageBox::NoIcon;
+ iconLabel = new QLabel;
+ iconLabel->setObjectName(QLatin1String("qt_msgboxex_icon_label"));
+ iconLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+
+ buttonBox = new QDialogButtonBox;
+ buttonBox->setObjectName(QLatin1String("qt_msgbox_buttonbox"));
+ buttonBox->setCenterButtons(q->style()->styleHint(QStyle::SH_MessageBox_CenterButtons, 0, q));
+ QObject::connect(buttonBox, SIGNAL(clicked(QAbstractButton*)),
+ q, SLOT(_q_buttonClicked(QAbstractButton*)));
+
+ QGridLayout *grid = new QGridLayout;
+#ifndef Q_WS_MAC
+ grid->addWidget(iconLabel, 0, 0, 2, 1, Qt::AlignTop);
+ grid->addWidget(label, 0, 1, 1, 1);
+ // -- leave space for information label --
+ grid->addWidget(buttonBox, 2, 0, 1, 2);
+#else
+ grid->setMargin(0);
+ grid->setVerticalSpacing(8);
+ grid->setHorizontalSpacing(0);
+ q->setContentsMargins(24, 15, 24, 20);
+ grid->addWidget(iconLabel, 0, 0, 2, 1, Qt::AlignTop | Qt::AlignLeft);
+ grid->addWidget(label, 0, 1, 1, 1);
+ // -- leave space for information label --
+ grid->setRowStretch(1, 100);
+ grid->setRowMinimumHeight(2, 6);
+ grid->addWidget(buttonBox, 3, 1, 1, 1);
+#endif
+
+ grid->setSizeConstraint(QLayout::SetNoConstraint);
+ q->setLayout(grid);
+
+ if (!title.isEmpty() || !text.isEmpty()) {
+ q->setWindowTitle(title);
+ q->setText(text);
+ }
+ q->setModal(true);
+
+#ifdef Q_WS_MAC
+ QFont f = q->font();
+ f.setBold(true);
+ label->setFont(f);
+#endif
+ retranslateStrings();
+}
+
+int QMessageBoxPrivate::layoutMinimumWidth()
+{
+ layout->activate();
+ return layout->totalMinimumSize().width();
+}
+
+void QMessageBoxPrivate::updateSize()
+{
+ Q_Q(QMessageBox);
+
+ if (!q->isVisible())
+ return;
+
+ QSize screenSize = QApplication::desktop()->availableGeometry(QCursor::pos()).size();
+#if defined(Q_WS_QWS) || defined(Q_WS_WINCE) || defined(Q_OS_SYMBIAN)
+ // the width of the screen, less the window border.
+ int hardLimit = screenSize.width() - (q->frameGeometry().width() - q->geometry().width());
+#else
+ int hardLimit = qMin(screenSize.width() - 480, 1000); // can never get bigger than this
+ // on small screens allows the messagebox be the same size as the screen
+ if (screenSize.width() <= 1024)
+ hardLimit = screenSize.width();
+#endif
+#ifdef Q_WS_MAC
+ int softLimit = qMin(screenSize.width()/2, 420);
+#elif defined(Q_WS_QWS)
+ int softLimit = qMin(hardLimit, 500);
+#else
+ // note: ideally on windows, hard and soft limits but it breaks compat
+#ifndef Q_WS_WINCE
+ int softLimit = qMin(screenSize.width()/2, 500);
+#else
+ int softLimit = qMin(screenSize.width() * 3 / 4, 500);
+#endif //Q_WS_WINCE
+#endif
+
+ if (informativeLabel)
+ informativeLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
+
+ label->setWordWrap(false); // makes the label return min size
+ int width = layoutMinimumWidth();
+
+ if (width > softLimit) {
+ label->setWordWrap(true);
+ width = qMax(softLimit, layoutMinimumWidth());
+
+ if (width > hardLimit) {
+ label->d_func()->ensureTextControl();
+ if (QTextControl *control = label->d_func()->control) {
+ QTextOption opt = control->document()->defaultTextOption();
+ opt.setWrapMode(QTextOption::WrapAnywhere);
+ control->document()->setDefaultTextOption(opt);
+ }
+ width = hardLimit;
+ }
+ }
+#ifdef Q_WS_S60
+ // in S60 portait messageBoxes should always occupy maximum width
+ if (QApplication::desktop()->size().height() > QApplication::desktop()->size().width()){
+ width = hardLimit;
+ } else {
+ // in landscape the messageBoxes should be of same width as in portrait
+ width = qMin(QApplication::desktop()->size().height(), hardLimit);
+ }
+#endif
+
+ if (informativeLabel) {
+ label->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
+ QSizePolicy policy(QSizePolicy::Minimum, QSizePolicy::Preferred);
+ policy.setHeightForWidth(true);
+ informativeLabel->setSizePolicy(policy);
+ width = qMax(width, layoutMinimumWidth());
+ if (width > hardLimit) { // longest word is really big, so wrap anywhere
+ informativeLabel->d_func()->ensureTextControl();
+ if (QTextControl *control = informativeLabel->d_func()->control) {
+ QTextOption opt = control->document()->defaultTextOption();
+ opt.setWrapMode(QTextOption::WrapAnywhere);
+ control->document()->setDefaultTextOption(opt);
+ }
+ width = hardLimit;
+ }
+ policy.setHeightForWidth(label->wordWrap());
+ label->setSizePolicy(policy);
+ }
+
+ QFontMetrics fm(QApplication::font("QWorkspaceTitleBar"));
+ int windowTitleWidth = qMin(fm.width(q->windowTitle()) + 50, hardLimit);
+ if (windowTitleWidth > width)
+ width = windowTitleWidth;
+
+ layout->activate();
+ int height = (layout->hasHeightForWidth())
+ ? layout->totalHeightForWidth(width)
+ : layout->totalMinimumSize().height();
+
+#ifndef QT_NO_STYLE_S60
+ QS60Style *s60Style = 0;
+ s60Style = qobject_cast<QS60Style *>(QApplication::style());
+
+ //use custom pixel metric to deduce the minimum height of the messagebox
+ if (s60Style)
+ height = qMax(height, s60Style->pixelMetric((QStyle::PixelMetric)PM_MessageBoxHeight));
+#endif
+
+ q->setFixedSize(width, height);
+ QCoreApplication::removePostedEvents(q, QEvent::LayoutRequest);
+}
+
+
+#ifdef Q_WS_WINCE
+/*!
+ \internal
+ Hides special buttons which are rather shown in the title bar
+ on WinCE, to conserve screen space.
+*/
+
+void QMessageBoxPrivate::hideSpecial()
+{
+ Q_Q(QMessageBox);
+ QList<QPushButton*> list = q->findChildren<QPushButton*>();
+ for (int i=0; i<list.size(); ++i) {
+ QPushButton *pb = list.at(i);
+ QString text = pb->text();
+ text.remove(QChar::fromLatin1('&'));
+ if (text == QApplication::translate("QMessageBox", "OK" ))
+ pb->setFixedSize(0,0);
+ }
+}
+#endif
+
+static int oldButton(int button)
+{
+ switch (button & QMessageBox::ButtonMask) {
+ case QMessageBox::Ok:
+ return Old_Ok;
+ case QMessageBox::Cancel:
+ return Old_Cancel;
+ case QMessageBox::Yes:
+ return Old_Yes;
+ case QMessageBox::No:
+ return Old_No;
+ case QMessageBox::Abort:
+ return Old_Abort;
+ case QMessageBox::Retry:
+ return Old_Retry;
+ case QMessageBox::Ignore:
+ return Old_Ignore;
+ case QMessageBox::YesToAll:
+ return Old_YesAll;
+ case QMessageBox::NoToAll:
+ return Old_NoAll;
+ default:
+ return 0;
+ }
+}
+
+int QMessageBoxPrivate::execReturnCode(QAbstractButton *button)
+{
+ int ret = buttonBox->standardButton(button);
+ if (ret == QMessageBox::NoButton) {
+ ret = customButtonList.indexOf(button); // if button == 0, correctly sets ret = -1
+ } else if (compatMode) {
+ ret = oldButton(ret);
+ }
+ return ret;
+}
+
+void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button)
+{
+ Q_Q(QMessageBox);
+#ifndef QT_NO_TEXTEDIT
+ if (detailsButton && detailsText && button == detailsButton) {
+ detailsButton->setLabel(detailsText->isHidden() ? HideLabel : ShowLabel);
+ detailsText->setHidden(!detailsText->isHidden());
+ updateSize();
+ } else
+#endif
+ {
+ clickedButton = button;
+ q->done(execReturnCode(button)); // does not trigger closeEvent
+ emit q->buttonClicked(button);
+
+ if (receiverToDisconnectOnClose) {
+ QObject::disconnect(q, signalToDisconnectOnClose, receiverToDisconnectOnClose,
+ memberToDisconnectOnClose);
+ receiverToDisconnectOnClose = 0;
+ }
+ signalToDisconnectOnClose.clear();
+ memberToDisconnectOnClose.clear();
+ }
+}
+
+/*!
+ \class QMessageBox
+
+ \brief The QMessageBox class provides a modal dialog for informing
+ the user or for asking the user a question and receiving an answer.
+
+ \ingroup standard-dialogs
+
+
+ A message box displays a primary \l{QMessageBox::text}{text} to
+ alert the user to a situation, an \l{QMessageBox::informativeText}
+ {informative text} to further explain the alert or to ask the user
+ a question, and an optional \l{QMessageBox::detailedText}
+ {detailed text} to provide even more data if the user requests
+ it. A message box can also display an \l{QMessageBox::icon} {icon}
+ and \l{QMessageBox::standardButtons} {standard buttons} for
+ accepting a user response.
+
+ Two APIs for using QMessageBox are provided, the property-based
+ API, and the static functions. Calling one of the static functions
+ is the simpler approach, but it is less flexible than using the
+ property-based API, and the result is less informative. Using the
+ property-based API is recommended.
+
+ \section1 The Property-based API
+
+ To use the property-based API, construct an instance of
+ QMessageBox, set the desired properties, and call exec() to show
+ the message. The simplest configuration is to set only the
+ \l{QMessageBox::text} {message text} property.
+
+ \snippet doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp 5
+
+ The user must click the \gui{OK} button to dismiss the message
+ box. The rest of the GUI is blocked until the message box is
+ dismissed.
+
+ \image msgbox1.png
+
+ A better approach than just alerting the user to an event is to
+ also ask the user what to do about it. Store the question in the
+ \l{QMessageBox::informativeText} {informative text} property, and
+ set the \l{QMessageBox::standardButtons} {standard buttons}
+ property to the set of buttons you want as the set of user
+ responses. The buttons are specified by combining values from
+ StandardButtons using the bitwise OR operator. The display order
+ for the buttons is platform-dependent. For example, on Windows,
+ \gui{Save} is displayed to the left of \gui{Cancel}, whereas on
+ Mac OS, the order is reversed.
+
+ Mark one of your standard buttons to be your
+ \l{QMessageBox::defaultButton()} {default button}.
+
+ \snippet doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp 6
+
+ This is the approach recommended in the
+ \l{http://developer.apple.com/documentation/UserExperience/Conceptual/AppleHIGuidelines/XHIGWindows/chapter_18_section_7.html}
+ {Mac OS X Guidlines}. Similar guidlines apply for the other
+ platforms, but note the different ways the
+ \l{QMessageBox::informativeText} {informative text} is handled for
+ different platforms.
+
+ \image msgbox2.png
+
+ The exec() slot returns the StandardButtons value of the button
+ that was clicked.
+
+ \snippet doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp 7
+
+ To give the user more information to help him answer the question,
+ set the \l{QMessageBox::detailedText} {detailed text} property. If
+ the \l{QMessageBox::detailedText} {detailed text} property is set,
+ the \gui{Show Details...} button will be shown.
+
+ \image msgbox3.png
+
+ Clicking the \gui{Show Details...} button displays the detailed text.
+
+ \image msgbox4.png
+
+ \section2 Rich Text and the Text Format Property
+
+ The \l{QMessageBox::detailedText} {detailed text} property is
+ always interpreted as plain text. The \l{QMessageBox::text} {main
+ text} and \l{QMessageBox::informativeText} {informative text}
+ properties can be either plain text or rich text. These strings
+ are interpreted according to the setting of the
+ \l{QMessageBox::textFormat} {text format} property. The default
+ setting is \l{Qt::AutoText} {auto-text}.
+
+ Note that for some plain text strings containing XML
+ meta-characters, the auto-text \l{Qt::mightBeRichText()} {rich
+ text detection test} may fail causing your plain text string to be
+ interpreted incorrectly as rich text. In these rare cases, use
+ Qt::convertFromPlainText() to convert your plain text string to a
+ visually equivalent rich text string, or set the
+ \l{QMessageBox::textFormat} {text format} property explicitly with
+ setTextFormat().
+
+ \section2 Severity Levels and the Icon and Pixmap Properties
+
+ QMessageBox supports four predefined message severity levels, or message
+ types, which really only differ in the predefined icon they each show.
+ Specify one of the four predefined message types by setting the
+ \l{QMessageBox::icon}{icon} property to one of the
+ \l{QMessageBox::Icon}{predefined icons}. The following rules are
+ guidelines:
+
+ \table
+ \row
+ \o \img qmessagebox-quest.png
+ \o \l Question
+ \o For asking a question during normal operations.
+ \row
+ \o \img qmessagebox-info.png
+ \o \l Information
+ \o For reporting information about normal operations.
+ \row
+ \o \img qmessagebox-warn.png
+ \o \l Warning
+ \o For reporting non-critical errors.
+ \row
+ \o \img qmessagebox-crit.png
+ \o \l Critical
+ \o For reporting critical errors.
+ \endtable
+
+ \l{QMessageBox::Icon}{Predefined icons} are not defined by QMessageBox, but
+ provided by the style. The default value is \l{QMessageBox::NoIcon}
+ {No Icon}. The message boxes are otherwise the same for all cases. When
+ using a standard icon, use the one recommended in the table, or use the
+ one recommended by the style guidelines for your platform. If none of the
+ standard icons is right for your message box, you can use a custom icon by
+ setting the \l{QMessageBox::iconPixmap}{icon pixmap} property instead of
+ setting the \l{QMessageBox::icon}{icon} property.
+
+ In summary, to set an icon, use \e{either} setIcon() for one of the
+ standard icons, \e{or} setIconPixmap() for a custom icon.
+
+ \section1 The Static Functions API
+
+ Building message boxes with the static functions API, although
+ convenient, is less flexible than using the property-based API,
+ because the static function signatures lack parameters for setting
+ the \l{QMessageBox::informativeText} {informative text} and
+ \l{QMessageBox::detailedText} {detailed text} properties. One
+ work-around for this has been to use the \c{title} parameter as
+ the message box main text and the \c{text} parameter as the
+ message box informative text. Because this has the obvious
+ drawback of making a less readable message box, platform
+ guidelines do not recommend it. The \e{Microsoft Windows User
+ Interface Guidelines} recommend using the
+ \l{QCoreApplication::applicationName} {application name} as the
+ \l{QMessageBox::setWindowTitle()} {window's title}, which means
+ that if you have an informative text in addition to your main
+ text, you must concatenate it to the \c{text} parameter.
+
+ Note that the static function signatures have changed with respect
+ to their button parameters, which are now used to set the
+ \l{QMessageBox::standardButtons} {standard buttons} and the
+ \l{QMessageBox::defaultButton()} {default button}.
+
+ Static functions are available for creating information(),
+ question(), warning(), and critical() message boxes.
+
+ \snippet doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp 0
+
+ The \l{dialogs/standarddialogs}{Standard Dialogs} example shows
+ how to use QMessageBox and the other built-in Qt dialogs.
+
+ \section1 Advanced Usage
+
+ If the \l{QMessageBox::StandardButtons} {standard buttons} are not
+ flexible enough for your message box, you can use the addButton()
+ overload that takes a text and a ButtonRoleto to add custom
+ buttons. The ButtonRole is used by QMessageBox to determine the
+ ordering of the buttons on screen (which varies according to the
+ platform). You can test the value of clickedButton() after calling
+ exec(). For example,
+
+ \snippet doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp 2
+
+ \section1 Default and Escape Keys
+
+ The default button (i.e., the button activated when \key Enter is
+ pressed) can be specified using setDefaultButton(). If a default
+ button is not specified, QMessageBox tries to find one based on
+ the \l{ButtonRole} {button roles} of the buttons used in the
+ message box.
+
+ The escape button (the button activated when \key Esc is pressed)
+ can be specified using setEscapeButton(). If an escape button is
+ not specified, QMessageBox tries to find one using these rules:
+
+ \list 1
+
+ \o If there is only one button, it is the button activated when
+ \key Esc is pressed.
+
+ \o If there is a \l Cancel button, it is the button activated when
+ \key Esc is pressed.
+
+ \o If there is exactly one button having either
+ \l{QMessageBox::RejectRole} {the Reject role} or the
+ \l{QMessageBox::NoRole} {the No role}, it is the button
+ activated when \key Esc is pressed.
+
+ \endlist
+
+ When an escape button can't be determined using these rules,
+ pressing \key Esc has no effect.
+
+ \sa QDialogButtonBox, {fowler}{GUI Design Handbook: Message Box}, {Standard Dialogs Example}, {Application Example}
+*/
+
+/*!
+ \enum QMessageBox::StandardButton
+ \since 4.2
+
+ These enums describe flags for standard buttons. Each button has a
+ defined \l ButtonRole.
+
+ \value Ok An "OK" button defined with the \l AcceptRole.
+ \value Open A "Open" button defined with the \l AcceptRole.
+ \value Save A "Save" button defined with the \l AcceptRole.
+ \value Cancel A "Cancel" button defined with the \l RejectRole.
+ \value Close A "Close" button defined with the \l RejectRole.
+ \value Discard A "Discard" or "Don't Save" button, depending on the platform,
+ defined with the \l DestructiveRole.
+ \value Apply An "Apply" button defined with the \l ApplyRole.
+ \value Reset A "Reset" button defined with the \l ResetRole.
+ \value RestoreDefaults A "Restore Defaults" button defined with the \l ResetRole.
+ \value Help A "Help" button defined with the \l HelpRole.
+ \value SaveAll A "Save All" button defined with the \l AcceptRole.
+ \value Yes A "Yes" button defined with the \l YesRole.
+ \value YesToAll A "Yes to All" button defined with the \l YesRole.
+ \value No A "No" button defined with the \l NoRole.
+ \value NoToAll A "No to All" button defined with the \l NoRole.
+ \value Abort An "Abort" button defined with the \l RejectRole.
+ \value Retry A "Retry" button defined with the \l AcceptRole.
+ \value Ignore An "Ignore" button defined with the \l AcceptRole.
+
+ \value NoButton An invalid button.
+
+ \omitvalue FirstButton
+ \omitvalue LastButton
+
+ The following values are obsolete:
+
+ \value YesAll Use YesToAll instead.
+ \value NoAll Use NoToAll instead.
+ \value Default Use the \c defaultButton argument of
+ information(), warning(), etc. instead, or call
+ setDefaultButton().
+ \value Escape Call setEscapeButton() instead.
+ \value FlagMask
+ \value ButtonMask
+
+ \sa ButtonRole, standardButtons
+*/
+
+/*!
+ \fn void QMessageBox::buttonClicked(QAbstractButton *button)
+
+ This signal is emitted whenever a button is clicked inside the QMessageBox.
+ The button that was clicked in returned in \a button.
+*/
+
+/*!
+ Constructs a message box with no text and no buttons. \a parent is
+ passed to the QDialog constructor.
+
+ On Mac OS X, if you want your message box to appear
+ as a Qt::Sheet of its \a parent, set the message box's
+ \l{setWindowModality()} {window modality} to Qt::WindowModal or use open().
+ Otherwise, the message box will be a standard dialog.
+
+*/
+QMessageBox::QMessageBox(QWidget *parent)
+ : QDialog(*new QMessageBoxPrivate, parent, Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint)
+{
+ Q_D(QMessageBox);
+ d->init();
+}
+
+/*!
+ Constructs a message box with the given \a icon, \a title, \a
+ text, and standard \a buttons. Standard or custom buttons can be
+ added at any time using addButton(). The \a parent and \a f
+ arguments are passed to the QDialog constructor.
+
+ The message box is an \l{Qt::ApplicationModal} {application modal}
+ dialog box.
+
+ On Mac OS X, if \a parent is not 0 and you want your message box
+ to appear as a Qt::Sheet of that parent, set the message box's
+ \l{setWindowModality()} {window modality} to Qt::WindowModal
+ (default). Otherwise, the message box will be a standard dialog.
+
+ \sa setWindowTitle(), setText(), setIcon(), setStandardButtons()
+*/
+QMessageBox::QMessageBox(Icon icon, const QString &title, const QString &text,
+ StandardButtons buttons, QWidget *parent,
+ Qt::WindowFlags f)
+: QDialog(*new QMessageBoxPrivate, parent, f | Qt::MSWindowsFixedSizeDialogHint | Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint)
+{
+ Q_D(QMessageBox);
+ d->init(title, text);
+ setIcon(icon);
+ if (buttons != NoButton)
+ setStandardButtons(buttons);
+}
+
+/*!
+ Destroys the message box.
+*/
+QMessageBox::~QMessageBox()
+{
+}
+
+/*!
+ \since 4.2
+
+ Adds the given \a button to the message box with the specified \a
+ role.
+
+ \sa removeButton(), button(), setStandardButtons()
+*/
+void QMessageBox::addButton(QAbstractButton *button, ButtonRole role)
+{
+ Q_D(QMessageBox);
+ if (!button)
+ return;
+ removeButton(button);
+ d->buttonBox->addButton(button, (QDialogButtonBox::ButtonRole)role);
+ d->customButtonList.append(button);
+ d->autoAddOkButton = false;
+}
+
+/*!
+ \since 4.2
+ \overload
+
+ Creates a button with the given \a text, adds it to the message box for the
+ specified \a role, and returns it.
+*/
+QPushButton *QMessageBox::addButton(const QString& text, ButtonRole role)
+{
+ Q_D(QMessageBox);
+ QPushButton *pushButton = new QPushButton(text);
+ addButton(pushButton, role);
+ d->updateSize();
+ return pushButton;
+}
+
+/*!
+ \since 4.2
+ \overload
+
+ Adds a standard \a button to the message box if it is valid to do so, and
+ returns the push button.
+
+ \sa setStandardButtons()
+*/
+QPushButton *QMessageBox::addButton(StandardButton button)
+{
+ Q_D(QMessageBox);
+ QPushButton *pushButton = d->buttonBox->addButton((QDialogButtonBox::StandardButton)button);
+ if (pushButton)
+ d->autoAddOkButton = false;
+ return pushButton;
+}
+
+/*!
+ \since 4.2
+
+ Removes \a button from the button box without deleting it.
+
+ \sa addButton(), setStandardButtons()
+*/
+void QMessageBox::removeButton(QAbstractButton *button)
+{
+ Q_D(QMessageBox);
+ d->customButtonList.removeAll(button);
+ if (d->escapeButton == button)
+ d->escapeButton = 0;
+ if (d->defaultButton == button)
+ d->defaultButton = 0;
+ d->buttonBox->removeButton(button);
+ d->updateSize();
+}
+
+/*!
+ \property QMessageBox::standardButtons
+ \brief collection of standard buttons in the message box
+ \since 4.2
+
+ This property controls which standard buttons are used by the message box.
+
+ By default, this property contains no standard buttons.
+
+ \sa addButton()
+*/
+void QMessageBox::setStandardButtons(StandardButtons buttons)
+{
+ Q_D(QMessageBox);
+ d->buttonBox->setStandardButtons(QDialogButtonBox::StandardButtons(int(buttons)));
+
+ QList<QAbstractButton *> buttonList = d->buttonBox->buttons();
+ if (!buttonList.contains(d->escapeButton))
+ d->escapeButton = 0;
+ if (!buttonList.contains(d->defaultButton))
+ d->defaultButton = 0;
+ d->autoAddOkButton = false;
+ d->updateSize();
+}
+
+QMessageBox::StandardButtons QMessageBox::standardButtons() const
+{
+ Q_D(const QMessageBox);
+ return QMessageBox::StandardButtons(int(d->buttonBox->standardButtons()));
+}
+
+/*!
+ \since 4.2
+
+ Returns the standard button enum value corresponding to the given \a button,
+ or NoButton if the given \a button isn't a standard button.
+
+ \sa button(), standardButtons()
+*/
+QMessageBox::StandardButton QMessageBox::standardButton(QAbstractButton *button) const
+{
+ Q_D(const QMessageBox);
+ return (QMessageBox::StandardButton)d->buttonBox->standardButton(button);
+}
+
+/*!
+ \since 4.2
+
+ Returns a pointer corresponding to the standard button \a which,
+ or 0 if the standard button doesn't exist in this message box.
+
+ \sa standardButtons, standardButton()
+*/
+QAbstractButton *QMessageBox::button(StandardButton which) const
+{
+ Q_D(const QMessageBox);
+ return d->buttonBox->button(QDialogButtonBox::StandardButton(which));
+}
+
+/*!
+ \since 4.2
+
+ Returns the button that is activated when escape is pressed.
+
+ By default, QMessageBox attempts to automatically detect an
+ escape button as follows:
+
+ \list 1
+ \o If there is only one button, it is made the escape button.
+ \o If there is a \l Cancel button, it is made the escape button.
+ \o On Mac OS X only, if there is exactly one button with the role
+ QMessageBox::RejectRole, it is made the escape button.
+ \endlist
+
+ When an escape button could not be automatically detected, pressing
+ \key Esc has no effect.
+
+ \sa addButton()
+*/
+QAbstractButton *QMessageBox::escapeButton() const
+{
+ Q_D(const QMessageBox);
+ return d->escapeButton;
+}
+
+/*!
+ \since 4.2
+
+ Sets the button that gets activated when the \key Escape key is
+ pressed to \a button.
+
+ \sa addButton(), clickedButton()
+*/
+void QMessageBox::setEscapeButton(QAbstractButton *button)
+{
+ Q_D(QMessageBox);
+ if (d->buttonBox->buttons().contains(button))
+ d->escapeButton = button;
+}
+
+/*!
+ \since 4.3
+
+ Sets the buttons that gets activated when the \key Escape key is
+ pressed to \a button.
+
+ \sa addButton(), clickedButton()
+*/
+void QMessageBox::setEscapeButton(QMessageBox::StandardButton button)
+{
+ Q_D(QMessageBox);
+ setEscapeButton(d->buttonBox->button(QDialogButtonBox::StandardButton(button)));
+}
+
+void QMessageBoxPrivate::detectEscapeButton()
+{
+ if (escapeButton) { // escape button explicitly set
+ detectedEscapeButton = escapeButton;
+ return;
+ }
+
+ // Cancel button automatically becomes escape button
+ detectedEscapeButton = buttonBox->button(QDialogButtonBox::Cancel);
+ if (detectedEscapeButton)
+ return;
+
+ // If there is only one button, make it the escape button
+ const QList<QAbstractButton *> buttons = buttonBox->buttons();
+ if (buttons.count() == 1) {
+ detectedEscapeButton = buttons.first();
+ return;
+ }
+
+ // if the message box has one RejectRole button, make it the escape button
+ for (int i = 0; i < buttons.count(); i++) {
+ if (buttonBox->buttonRole(buttons.at(i)) == QDialogButtonBox::RejectRole) {
+ if (detectedEscapeButton) { // already detected!
+ detectedEscapeButton = 0;
+ break;
+ }
+ detectedEscapeButton = buttons.at(i);
+ }
+ }
+ if (detectedEscapeButton)
+ return;
+
+ // if the message box has one NoRole button, make it the escape button
+ for (int i = 0; i < buttons.count(); i++) {
+ if (buttonBox->buttonRole(buttons.at(i)) == QDialogButtonBox::NoRole) {
+ if (detectedEscapeButton) { // already detected!
+ detectedEscapeButton = 0;
+ break;
+ }
+ detectedEscapeButton = buttons.at(i);
+ }
+ }
+}
+
+/*!
+ \since 4.2
+
+ Returns the button that was clicked by the user,
+ or 0 if the user hit the \key Esc key and
+ no \l{setEscapeButton()}{escape button} was set.
+
+ If exec() hasn't been called yet, returns 0.
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_gui_dialogs_qmessagebox.cpp 3
+
+ \sa standardButton(), button()
+*/
+QAbstractButton *QMessageBox::clickedButton() const
+{
+ Q_D(const QMessageBox);
+ return d->clickedButton;
+}
+
+/*!
+ \since 4.2
+
+ Returns the button that should be the message box's
+ \l{QPushButton::setDefault()}{default button}. Returns 0
+ if no default button was set.
+
+ \sa addButton(), QPushButton::setDefault()
+*/
+QPushButton *QMessageBox::defaultButton() const
+{
+ Q_D(const QMessageBox);
+ return d->defaultButton;
+}
+
+/*!
+ \since 4.2
+
+ Sets the message box's \l{QPushButton::setDefault()}{default button}
+ to \a button.
+
+ \sa addButton(), QPushButton::setDefault()
+*/
+void QMessageBox::setDefaultButton(QPushButton *button)
+{
+ Q_D(QMessageBox);
+ if (!d->buttonBox->buttons().contains(button))
+ return;
+ d->defaultButton = button;
+ button->setDefault(true);
+ button->setFocus();
+}
+
+/*!
+ \since 4.3
+
+ Sets the message box's \l{QPushButton::setDefault()}{default button}
+ to \a button.
+
+ \sa addButton(), QPushButton::setDefault()
+*/
+void QMessageBox::setDefaultButton(QMessageBox::StandardButton button)
+{
+ Q_D(QMessageBox);
+ setDefaultButton(d->buttonBox->button(QDialogButtonBox::StandardButton(button)));
+}
+
+/*!
+ \property QMessageBox::text
+ \brief the message box text to be displayed.
+
+ The text will be interpreted either as a plain text or as rich text,
+ depending on the text format setting (\l QMessageBox::textFormat).
+ The default setting is Qt::AutoText, i.e., the message box will try
+ to auto-detect the format of the text.
+
+ The default value of this property is an empty string.
+
+ \sa textFormat, QMessageBox::informativeText, QMessageBox::detailedText
+*/
+QString QMessageBox::text() const
+{
+ Q_D(const QMessageBox);
+ return d->label->text();
+}
+
+void QMessageBox::setText(const QString &text)
+{
+ Q_D(QMessageBox);
+ d->label->setText(text);
+ d->label->setWordWrap(d->label->textFormat() == Qt::RichText
+ || (d->label->textFormat() == Qt::AutoText && Qt::mightBeRichText(text)));
+ d->updateSize();
+}
+
+/*!
+ \enum QMessageBox::Icon
+
+ This enum has the following values:
+
+ \value NoIcon the message box does not have any icon.
+
+ \value Question an icon indicating that
+ the message is asking a question.
+
+ \value Information an icon indicating that
+ the message is nothing out of the ordinary.
+
+ \value Warning an icon indicating that the
+ message is a warning, but can be dealt with.
+
+ \value Critical an icon indicating that
+ the message represents a critical problem.
+
+*/
+
+/*!
+ \property QMessageBox::icon
+ \brief the message box's icon
+
+ The icon of the message box can be specified with one of the
+ values:
+
+ \list
+ \o QMessageBox::NoIcon
+ \o QMessageBox::Question
+ \o QMessageBox::Information
+ \o QMessageBox::Warning
+ \o QMessageBox::Critical
+ \endlist
+
+ The default is QMessageBox::NoIcon.
+
+ The pixmap used to display the actual icon depends on the current
+ \l{QWidget::style()} {GUI style}. You can also set a custom pixmap
+ for the icon by setting the \l{QMessageBox::iconPixmap} {icon
+ pixmap} property.
+
+ \sa iconPixmap
+*/
+QMessageBox::Icon QMessageBox::icon() const
+{
+ Q_D(const QMessageBox);
+ return d->icon;
+}
+
+void QMessageBox::setIcon(Icon icon)
+{
+ Q_D(QMessageBox);
+ setIconPixmap(QMessageBoxPrivate::standardIcon((QMessageBox::Icon)icon,
+ this));
+ d->icon = icon;
+}
+
+/*!
+ \property QMessageBox::iconPixmap
+ \brief the current icon
+
+ The icon currently used by the message box. Note that it's often
+ hard to draw one pixmap that looks appropriate in all GUI styles;
+ you may want to supply a different pixmap for each platform.
+
+ By default, this property is undefined.
+
+ \sa icon
+*/
+QPixmap QMessageBox::iconPixmap() const
+{
+ Q_D(const QMessageBox);
+ if (d->iconLabel && d->iconLabel->pixmap())
+ return *d->iconLabel->pixmap();
+ return QPixmap();
+}
+
+void QMessageBox::setIconPixmap(const QPixmap &pixmap)
+{
+ Q_D(QMessageBox);
+ d->iconLabel->setPixmap(pixmap);
+ d->updateSize();
+ d->icon = NoIcon;
+}
+
+/*!
+ \property QMessageBox::textFormat
+ \brief the format of the text displayed by the message box
+
+ The current text format used by the message box. See the \l
+ Qt::TextFormat enum for an explanation of the possible options.
+
+ The default format is Qt::AutoText.
+
+ \sa setText()
+*/
+Qt::TextFormat QMessageBox::textFormat() const
+{
+ Q_D(const QMessageBox);
+ return d->label->textFormat();
+}
+
+void QMessageBox::setTextFormat(Qt::TextFormat format)
+{
+ Q_D(QMessageBox);
+ d->label->setTextFormat(format);
+ d->label->setWordWrap(format == Qt::RichText
+ || (format == Qt::AutoText && Qt::mightBeRichText(d->label->text())));
+ d->updateSize();
+}
+
+/*!
+ \reimp
+*/
+bool QMessageBox::event(QEvent *e)
+{
+ bool result =QDialog::event(e);
+ switch (e->type()) {
+ case QEvent::LayoutRequest:
+ d_func()->updateSize();
+ break;
+ case QEvent::LanguageChange:
+ d_func()->retranslateStrings();
+ break;
+#ifdef Q_WS_WINCE
+ case QEvent::OkRequest:
+ case QEvent::HelpRequest: {
+ QString bName =
+ (e->type() == QEvent::OkRequest)
+ ? QApplication::translate("QMessageBox", "OK")
+ : QApplication::translate("QMessageBox", "Help");
+ QList<QPushButton*> list = findChildren<QPushButton*>();
+ for (int i=0; i<list.size(); ++i) {
+ QPushButton *pb = list.at(i);
+ if (pb->text() == bName) {
+ if (pb->isEnabled())
+ pb->click();
+ return pb->isEnabled();
+ }
+ }
+ }
+#endif
+ default:
+ break;
+ }
+ return result;
+}
+
+/*!
+ \reimp
+*/
+void QMessageBox::resizeEvent(QResizeEvent *event)
+{
+ QDialog::resizeEvent(event);
+}
+
+/*!
+ \reimp
+*/
+void QMessageBox::closeEvent(QCloseEvent *e)
+{
+ Q_D(QMessageBox);
+ if (!d->detectedEscapeButton) {
+ e->ignore();
+ return;
+ }
+ QDialog::closeEvent(e);
+ d->clickedButton = d->detectedEscapeButton;
+ setResult(d->execReturnCode(d->detectedEscapeButton));
+}
+
+/*!
+ \reimp
+*/
+void QMessageBox::changeEvent(QEvent *ev)
+{
+ Q_D(QMessageBox);
+ switch (ev->type()) {
+ case QEvent::StyleChange:
+ {
+ if (d->icon != NoIcon)
+ setIcon(d->icon);
+ Qt::TextInteractionFlags flags(style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, 0, this));
+ d->label->setTextInteractionFlags(flags);
+ d->buttonBox->setCenterButtons(style()->styleHint(QStyle::SH_MessageBox_CenterButtons, 0, this));
+ if (d->informativeLabel)
+ d->informativeLabel->setTextInteractionFlags(flags);
+ // intentional fall through
+ }
+ case QEvent::FontChange:
+ case QEvent::ApplicationFontChange:
+#ifdef Q_WS_MAC
+ {
+ QFont f = font();
+ f.setBold(true);
+ d->label->setFont(f);
+ }
+#endif
+ default:
+ break;
+ }
+ QDialog::changeEvent(ev);
+}
+
+/*!
+ \reimp
+*/
+void QMessageBox::keyPressEvent(QKeyEvent *e)
+{
+ Q_D(QMessageBox);
+ if (e->key() == Qt::Key_Escape
+#ifdef Q_WS_MAC
+ || (e->modifiers() == Qt::ControlModifier && e->key() == Qt::Key_Period)
+#endif
+ ) {
+ if (d->detectedEscapeButton) {
+#ifdef Q_WS_MAC
+ d->detectedEscapeButton->animateClick();
+#else
+ d->detectedEscapeButton->click();
+#endif
+ }
+ return;
+ }
+
+#if defined (Q_OS_WIN) && !defined(QT_NO_CLIPBOARD) && !defined(QT_NO_SHORTCUT)
+ if (e == QKeySequence::Copy) {
+ QString separator = QString::fromLatin1("---------------------------\n");
+ QString textToCopy = separator;
+ separator.prepend(QLatin1Char('\n'));
+ textToCopy += windowTitle() + separator; // title
+ textToCopy += d->label->text() + separator; // text
+
+ if (d->informativeLabel)
+ textToCopy += d->informativeLabel->text() + separator;
+
+ QString buttonTexts;
+ QList<QAbstractButton *> buttons = d->buttonBox->buttons();
+ for (int i = 0; i < buttons.count(); i++) {
+ buttonTexts += buttons[i]->text() + QLatin1String(" ");
+ }
+ textToCopy += buttonTexts + separator;
+
+ QApplication::clipboard()->setText(textToCopy);
+ return;
+ }
+#endif //QT_NO_SHORTCUT QT_NO_CLIPBOARD Q_OS_WIN
+
+#ifndef QT_NO_SHORTCUT
+ if (!(e->modifiers() & Qt::AltModifier)) {
+ int key = e->key() & ~((int)Qt::MODIFIER_MASK|(int)Qt::UNICODE_ACCEL);
+ if (key) {
+ const QList<QAbstractButton *> buttons = d->buttonBox->buttons();
+ for (int i = 0; i < buttons.count(); ++i) {
+ QAbstractButton *pb = buttons.at(i);
+ int acc = pb->shortcut() & ~((int)Qt::MODIFIER_MASK|(int)Qt::UNICODE_ACCEL);
+ if (acc == key) {
+ pb->animateClick();
+ return;
+ }
+ }
+ }
+ }
+#endif
+ QDialog::keyPressEvent(e);
+}
+
+#ifdef Q_WS_WINCE
+/*!
+ \reimp
+*/
+void QMessageBox::setVisible(bool visible)
+{
+ Q_D(QMessageBox);
+ if (visible)
+ d->hideSpecial();
+ QDialog::setVisible(visible);
+}
+#endif
+
+
+/*!
+ \overload
+
+ Opens the dialog and connects its finished() or buttonClicked() signal to
+ the slot specified by \a receiver and \a member. If the slot in \a member
+ has a pointer for its first parameter the connection is to buttonClicked(),
+ otherwise the connection is to finished().
+
+ The signal will be disconnected from the slot when the dialog is closed.
+*/
+void QMessageBox::open(QObject *receiver, const char *member)
+{
+ Q_D(QMessageBox);
+ const char *signal = member && strchr(member, '*') ? SIGNAL(buttonClicked(QAbstractButton*))
+ : SIGNAL(finished(int));
+ connect(this, signal, receiver, member);
+ d->signalToDisconnectOnClose = signal;
+ d->receiverToDisconnectOnClose = receiver;
+ d->memberToDisconnectOnClose = member;
+ QDialog::open();
+}
+
+/*!
+ \since 4.5
+
+ Returns a list of all the buttons that have been added to the message box.
+
+ \sa buttonRole(), addButton(), removeButton()
+*/
+QList<QAbstractButton *> QMessageBox::buttons() const
+{
+ Q_D(const QMessageBox);
+ return d->buttonBox->buttons();
+}
+
+/*!
+ \since 4.5
+
+ Returns the button role for the specified \a button. This function returns
+ \l InvalidRole if \a button is 0 or has not been added to the message box.
+
+ \sa buttons(), addButton()
+*/
+QMessageBox::ButtonRole QMessageBox::buttonRole(QAbstractButton *button) const
+{
+ Q_D(const QMessageBox);
+ return QMessageBox::ButtonRole(d->buttonBox->buttonRole(button));
+}
+
+/*!
+ \reimp
+*/
+void QMessageBox::showEvent(QShowEvent *e)
+{
+ Q_D(QMessageBox);
+ if (d->autoAddOkButton) {
+ addButton(Ok);
+#if defined(Q_WS_WINCE)
+ d->hideSpecial();
+#endif
+ }
+ if (d->detailsButton)
+ addButton(d->detailsButton, QMessageBox::ActionRole);
+ d->detectEscapeButton();
+ d->updateSize();
+
+#ifndef QT_NO_ACCESSIBILITY
+ QAccessible::updateAccessibility(this, 0, QAccessible::Alert);
+#endif
+#ifdef Q_WS_WIN
+ HMENU systemMenu = GetSystemMenu((HWND)winId(), FALSE);
+ if (!d->detectedEscapeButton) {
+ EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_GRAYED);
+ }
+ else {
+ EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND|MF_ENABLED);
+ }
+#endif
+ QDialog::showEvent(e);
+}
+
+
+static QMessageBox::StandardButton showNewMessageBox(QWidget *parent,
+ QMessageBox::Icon icon,
+ const QString& title, const QString& text,
+ QMessageBox::StandardButtons buttons,
+ QMessageBox::StandardButton defaultButton)
+{
+ // necessary for source compatibility with Qt 4.0 and 4.1
+ // handles (Yes, No) and (Yes|Default, No)
+ if (defaultButton && !(buttons & defaultButton))
+ return (QMessageBox::StandardButton)
+ QMessageBoxPrivate::showOldMessageBox(parent, icon, title,
+ text, int(buttons),
+ int(defaultButton), 0);
+
+ QMessageBox msgBox(icon, title, text, QMessageBox::NoButton, parent);
+ QDialogButtonBox *buttonBox = msgBox.findChild<QDialogButtonBox*>();
+ Q_ASSERT(buttonBox != 0);
+
+ uint mask = QMessageBox::FirstButton;
+ while (mask <= QMessageBox::LastButton) {
+ uint sb = buttons & mask;
+ mask <<= 1;
+ if (!sb)
+ continue;
+ QPushButton *button = msgBox.addButton((QMessageBox::StandardButton)sb);
+ // Choose the first accept role as the default
+ if (msgBox.defaultButton())
+ continue;
+ if ((defaultButton == QMessageBox::NoButton && buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole)
+ || (defaultButton != QMessageBox::NoButton && sb == uint(defaultButton)))
+ msgBox.setDefaultButton(button);
+ }
+ if (msgBox.exec() == -1)
+ return QMessageBox::Cancel;
+ return msgBox.standardButton(msgBox.clickedButton());
+}
+
+/*!
+ \since 4.2
+
+ Opens an information message box with the given \a title and
+ \a text in front of the specified \a parent widget.
+
+ The standard \a buttons are added to the message box.
+ \a defaultButton specifies the button used when \key Enter is pressed.
+ \a defaultButton must refer to a button that was given in \a buttons.
+ If \a defaultButton is QMessageBox::NoButton, QMessageBox
+ chooses a suitable default automatically.
+
+ Returns the identity of the standard button that was clicked. If
+ \key Esc was pressed instead, the \l{Default and Escape Keys}
+ {escape button} is returned.
+
+ The message box is an \l{Qt::ApplicationModal}{application modal}
+ dialog box.
+
+ \warning Do not delete \a parent during the execution of the dialog.
+ If you want to do this, you should create the dialog
+ yourself using one of the QMessageBox constructors.
+
+ \sa question(), warning(), critical()
+*/
+QMessageBox::StandardButton QMessageBox::information(QWidget *parent, const QString &title,
+ const QString& text, StandardButtons buttons,
+ StandardButton defaultButton)
+{
+ return showNewMessageBox(parent, Information, title, text, buttons,
+ defaultButton);
+}
+
+
+/*!
+ \since 4.2
+
+ Opens a question message box with the given \a title and \a
+ text in front of the specified \a parent widget.
+
+ The standard \a buttons are added to the message box. \a
+ defaultButton specifies the button used when \key Enter is
+ pressed. \a defaultButton must refer to a button that was given in \a buttons.
+ If \a defaultButton is QMessageBox::NoButton, QMessageBox
+ chooses a suitable default automatically.
+
+ Returns the identity of the standard button that was clicked. If
+ \key Esc was pressed instead, the \l{Default and Escape Keys}
+ {escape button} is returned.
+
+ The message box is an \l{Qt::ApplicationModal} {application modal}
+ dialog box.
+
+ \warning Do not delete \a parent during the execution of the dialog.
+ If you want to do this, you should create the dialog
+ yourself using one of the QMessageBox constructors.
+
+ \sa information(), warning(), critical()
+*/
+QMessageBox::StandardButton QMessageBox::question(QWidget *parent, const QString &title,
+ const QString& text, StandardButtons buttons,
+ StandardButton defaultButton)
+{
+ return showNewMessageBox(parent, Question, title, text, buttons, defaultButton);
+}
+
+/*!
+ \since 4.2
+
+ Opens a warning message box with the given \a title and \a
+ text in front of the specified \a parent widget.
+
+ The standard \a buttons are added to the message box. \a
+ defaultButton specifies the button used when \key Enter is
+ pressed. \a defaultButton must refer to a button that was given in \a buttons.
+ If \a defaultButton is QMessageBox::NoButton, QMessageBox
+ chooses a suitable default automatically.
+
+ Returns the identity of the standard button that was clicked. If
+ \key Esc was pressed instead, the \l{Default and Escape Keys}
+ {escape button} is returned.
+
+ The message box is an \l{Qt::ApplicationModal} {application modal}
+ dialog box.
+
+ \warning Do not delete \a parent during the execution of the dialog.
+ If you want to do this, you should create the dialog
+ yourself using one of the QMessageBox constructors.
+
+ \sa question(), information(), critical()
+*/
+QMessageBox::StandardButton QMessageBox::warning(QWidget *parent, const QString &title,
+ const QString& text, StandardButtons buttons,
+ StandardButton defaultButton)
+{
+ return showNewMessageBox(parent, Warning, title, text, buttons, defaultButton);
+}
+
+/*!
+ \since 4.2
+
+ Opens a critical message box with the given \a title and \a
+ text in front of the specified \a parent widget.
+
+ The standard \a buttons are added to the message box. \a
+ defaultButton specifies the button used when \key Enter is
+ pressed. \a defaultButton must refer to a button that was given in \a buttons.
+ If \a defaultButton is QMessageBox::NoButton, QMessageBox
+ chooses a suitable default automatically.
+
+ Returns the identity of the standard button that was clicked. If
+ \key Esc was pressed instead, the \l{Default and Escape Keys}
+ {escape button} is returned.
+
+ The message box is an \l{Qt::ApplicationModal} {application modal}
+ dialog box.
+
+ \warning Do not delete \a parent during the execution of the dialog.
+ If you want to do this, you should create the dialog
+ yourself using one of the QMessageBox constructors.
+
+ \sa question(), warning(), information()
+*/
+QMessageBox::StandardButton QMessageBox::critical(QWidget *parent, const QString &title,
+ const QString& text, StandardButtons buttons,
+ StandardButton defaultButton)
+{
+ return showNewMessageBox(parent, Critical, title, text, buttons, defaultButton);
+}
+
+/*!
+ Displays a simple about box with title \a title and text \a
+ text. The about box's parent is \a parent.
+
+ about() looks for a suitable icon in four locations:
+
+ \list 1
+ \o It prefers \link QWidget::windowIcon() parent->icon() \endlink
+ if that exists.
+ \o If not, it tries the top-level widget containing \a parent.
+ \o If that fails, it tries the \link
+ QApplication::activeWindow() active window. \endlink
+ \o As a last resort it uses the Information icon.
+ \endlist
+
+ The about box has a single button labelled "OK". On Mac OS X, the
+ about box is popped up as a modeless window; on other platforms,
+ it is currently application modal.
+
+ \sa QWidget::windowIcon(), QApplication::activeWindow()
+*/
+void QMessageBox::about(QWidget *parent, const QString &title, const QString &text)
+{
+#ifdef Q_WS_MAC
+ static QPointer<QMessageBox> oldMsgBox;
+
+ if (oldMsgBox && oldMsgBox->text() == text) {
+ oldMsgBox->show();
+ oldMsgBox->raise();
+ oldMsgBox->activateWindow();
+ return;
+ }
+#endif
+
+ QMessageBox *msgBox = new QMessageBox(title, text, Information, 0, 0, 0, parent
+#ifdef Q_WS_MAC
+ , Qt::WindowTitleHint | Qt::WindowSystemMenuHint
+#endif
+ );
+ msgBox->setAttribute(Qt::WA_DeleteOnClose);
+ QIcon icon = msgBox->windowIcon();
+ QSize size = icon.actualSize(QSize(64, 64));
+ msgBox->setIconPixmap(icon.pixmap(size));
+
+ // should perhaps be a style hint
+#ifdef Q_WS_MAC
+ oldMsgBox = msgBox;
+#if 0
+ // ### doesn't work until close button is enabled in title bar
+ msgBox->d_func()->autoAddOkButton = false;
+#else
+ msgBox->d_func()->buttonBox->setCenterButtons(true);
+#endif
+ msgBox->show();
+#else
+ msgBox->exec();
+#endif
+}
+
+/*!
+ Displays a simple message box about Qt, with the given \a title
+ and centered over \a parent (if \a parent is not 0). The message
+ includes the version number of Qt being used by the application.
+
+ This is useful for inclusion in the \gui Help menu of an application,
+ as shown in the \l{mainwindows/menus}{Menus} example.
+
+ QApplication provides this functionality as a slot.
+
+ On Mac OS X, the about box is popped up as a modeless window; on
+ other platforms, it is currently application modal.
+
+ \sa QApplication::aboutQt()
+*/
+void QMessageBox::aboutQt(QWidget *parent, const QString &title)
+{
+#ifdef Q_WS_MAC
+ static QPointer<QMessageBox> oldMsgBox;
+
+ if (oldMsgBox) {
+ oldMsgBox->show();
+ oldMsgBox->raise();
+ oldMsgBox->activateWindow();
+ return;
+ }
+#endif
+
+ QString translatedTextAboutQtCaption;
+ translatedTextAboutQtCaption = QMessageBox::tr(
+ "<h3>About Qt</h3>"
+ "<p>This program uses Qt version %1.</p>"
+ ).arg(QLatin1String(QT_VERSION_STR));
+ QString translatedTextAboutQtText;
+ translatedTextAboutQtText = QMessageBox::tr(
+ "<p>Qt is a C++ toolkit for cross-platform application "
+ "development.</p>"
+ "<p>Qt provides single-source portability across MS&nbsp;Windows, "
+ "Mac&nbsp;OS&nbsp;X, Linux, and all major commercial Unix variants. "
+ "Qt is also available for embedded devices as Qt for Embedded Linux "
+ "and Qt for Windows CE.</p>"
+ "<p>Qt is available under three different licensing options designed "
+ "to accommodate the needs of our various users.</p>"
+ "<p>Qt licensed under our commercial license agreement is appropriate "
+ "for development of proprietary/commercial software where you do not "
+ "want to share any source code with third parties or otherwise cannot "
+ "comply with the terms of the GNU LGPL version 2.1 or GNU GPL version "
+ "3.0.</p>"
+ "<p>Qt licensed under the GNU LGPL version 2.1 is appropriate for the "
+ "development of Qt applications (proprietary or open source) provided "
+ "you can comply with the terms and conditions of the GNU LGPL version "
+ "2.1.</p>"
+ "<p>Qt licensed under the GNU General Public License version 3.0 is "
+ "appropriate for the development of Qt applications where you wish to "
+ "use such applications in combination with software subject to the "
+ "terms of the GNU GPL version 3.0 or where you are otherwise willing "
+ "to comply with the terms of the GNU GPL version 3.0.</p>"
+ "<p>Please see <a href=\"http://qt.nokia.com/products/licensing\">qt.nokia.com/products/licensing</a> "
+ "for an overview of Qt licensing.</p>"
+ "<p>Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).</p>"
+ "<p>Qt is a Nokia product. See <a href=\"http://qt.nokia.com/\">qt.nokia.com</a> "
+ "for more information.</p>"
+ );
+ QMessageBox *msgBox = new QMessageBox(parent);
+ msgBox->setAttribute(Qt::WA_DeleteOnClose);
+ msgBox->setWindowTitle(title.isEmpty() ? tr("About Qt") : title);
+ msgBox->setText(translatedTextAboutQtCaption);
+ msgBox->setInformativeText(translatedTextAboutQtText);
+
+ QPixmap pm(QLatin1String(":/trolltech/qmessagebox/images/qtlogo-64.png"));
+ if (!pm.isNull())
+ msgBox->setIconPixmap(pm);
+#if defined(Q_WS_WINCE)
+ msgBox->setDefaultButton(msgBox->addButton(QMessageBox::Ok));
+#endif
+
+ // should perhaps be a style hint
+#ifdef Q_WS_MAC
+ oldMsgBox = msgBox;
+#if 0
+ // ### doesn't work until close button is enabled in title bar
+ msgBox->d_func()->autoAddOkButton = false;
+#else
+ msgBox->d_func()->buttonBox->setCenterButtons(true);
+#endif
+ msgBox->show();
+#else
+ msgBox->exec();
+#endif
+}
+
+/*!
+ \internal
+*/
+QSize QMessageBox::sizeHint() const
+{
+ // ### Qt 5: remove
+ return QDialog::sizeHint();
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Source and binary compatibility routines for 4.0 and 4.1
+
+static QMessageBox::StandardButton newButton(int button)
+{
+ // this is needed for source compatibility with Qt 4.0 and 4.1
+ if (button == QMessageBox::NoButton || (button & NewButtonMask))
+ return QMessageBox::StandardButton(button & QMessageBox::ButtonMask);
+
+#if QT_VERSION < 0x050000
+ // this is needed for binary compatibility with Qt 4.0 and 4.1
+ switch (button & Old_ButtonMask) {
+ case Old_Ok:
+ return QMessageBox::Ok;
+ case Old_Cancel:
+ return QMessageBox::Cancel;
+ case Old_Yes:
+ return QMessageBox::Yes;
+ case Old_No:
+ return QMessageBox::No;
+ case Old_Abort:
+ return QMessageBox::Abort;
+ case Old_Retry:
+ return QMessageBox::Retry;
+ case Old_Ignore:
+ return QMessageBox::Ignore;
+ case Old_YesAll:
+ return QMessageBox::YesToAll;
+ case Old_NoAll:
+ return QMessageBox::NoToAll;
+ default:
+ return QMessageBox::NoButton;
+ }
+#endif
+}
+
+static bool detectedCompat(int button0, int button1, int button2)
+{
+ if (button0 != 0 && !(button0 & NewButtonMask))
+ return true;
+ if (button1 != 0 && !(button1 & NewButtonMask))
+ return true;
+ if (button2 != 0 && !(button2 & NewButtonMask))
+ return true;
+ return false;
+}
+
+QAbstractButton *QMessageBoxPrivate::findButton(int button0, int button1, int button2, int flags)
+{
+ Q_Q(QMessageBox);
+ int button = 0;
+
+ if (button0 & flags) {
+ button = button0;
+ } else if (button1 & flags) {
+ button = button1;
+ } else if (button2 & flags) {
+ button = button2;
+ }
+ return q->button(newButton(button));
+}
+
+void QMessageBoxPrivate::addOldButtons(int button0, int button1, int button2)
+{
+ Q_Q(QMessageBox);
+ q->addButton(newButton(button0));
+ q->addButton(newButton(button1));
+ q->addButton(newButton(button2));
+ q->setDefaultButton(
+ static_cast<QPushButton *>(findButton(button0, button1, button2, QMessageBox::Default)));
+ q->setEscapeButton(findButton(button0, button1, button2, QMessageBox::Escape));
+ compatMode = detectedCompat(button0, button1, button2);
+}
+
+QAbstractButton *QMessageBoxPrivate::abstractButtonForId(int id) const
+{
+ Q_Q(const QMessageBox);
+ QAbstractButton *result = customButtonList.value(id);
+ if (result)
+ return result;
+ if (id & QMessageBox::FlagMask) // for compatibility with Qt 4.0/4.1 (even if it is silly)
+ return 0;
+ return q->button(newButton(id));
+}
+
+int QMessageBoxPrivate::showOldMessageBox(QWidget *parent, QMessageBox::Icon icon,
+ const QString &title, const QString &text,
+ int button0, int button1, int button2)
+{
+ QMessageBox messageBox(icon, title, text, QMessageBox::NoButton, parent);
+ messageBox.d_func()->addOldButtons(button0, button1, button2);
+ return messageBox.exec();
+}
+
+int QMessageBoxPrivate::showOldMessageBox(QWidget *parent, QMessageBox::Icon icon,
+ const QString &title, const QString &text,
+ const QString &button0Text,
+ const QString &button1Text,
+ const QString &button2Text,
+ int defaultButtonNumber,
+ int escapeButtonNumber)
+{
+ QMessageBox messageBox(icon, title, text, QMessageBox::NoButton, parent);
+ QString myButton0Text = button0Text;
+ if (myButton0Text.isEmpty())
+ myButton0Text = QDialogButtonBox::tr("OK");
+ messageBox.addButton(myButton0Text, QMessageBox::ActionRole);
+ if (!button1Text.isEmpty())
+ messageBox.addButton(button1Text, QMessageBox::ActionRole);
+ if (!button2Text.isEmpty())
+ messageBox.addButton(button2Text, QMessageBox::ActionRole);
+
+ const QList<QAbstractButton *> &buttonList = messageBox.d_func()->customButtonList;
+ messageBox.setDefaultButton(static_cast<QPushButton *>(buttonList.value(defaultButtonNumber)));
+ messageBox.setEscapeButton(buttonList.value(escapeButtonNumber));
+
+ return messageBox.exec();
+}
+
+void QMessageBoxPrivate::retranslateStrings()
+{
+#ifndef QT_NO_TEXTEDIT
+ if (detailsButton)
+ detailsButton->setLabel(detailsText->isHidden() ? ShowLabel : HideLabel);
+#endif
+}
+
+/*!
+ \obsolete
+
+ Constructs a message box with a \a title, a \a text, an \a icon,
+ and up to three buttons.
+
+ The \a icon must be one of the following:
+ \list
+ \o QMessageBox::NoIcon
+ \o QMessageBox::Question
+ \o QMessageBox::Information
+ \o QMessageBox::Warning
+ \o QMessageBox::Critical
+ \endlist
+
+ Each button, \a button0, \a button1 and \a button2, can have one
+ of the following values:
+ \list
+ \o QMessageBox::NoButton
+ \o QMessageBox::Ok
+ \o QMessageBox::Cancel
+ \o QMessageBox::Yes
+ \o QMessageBox::No
+ \o QMessageBox::Abort
+ \o QMessageBox::Retry
+ \o QMessageBox::Ignore
+ \o QMessageBox::YesAll
+ \o QMessageBox::NoAll
+ \endlist
+
+ Use QMessageBox::NoButton for the later parameters to have fewer
+ than three buttons in your message box. If you don't specify any
+ buttons at all, QMessageBox will provide an Ok button.
+
+ One of the buttons can be OR-ed with the QMessageBox::Default
+ flag to make it the default button (clicked when Enter is
+ pressed).
+
+ One of the buttons can be OR-ed with the QMessageBox::Escape flag
+ to make it the cancel or close button (clicked when \key Esc is
+ pressed).
+
+ \snippet doc/src/snippets/dialogs/dialogs.cpp 2
+
+ The message box is an \l{Qt::ApplicationModal} {application modal}
+ dialog box.
+
+ The \a parent and \a f arguments are passed to
+ the QDialog constructor.
+
+ \sa setWindowTitle(), setText(), setIcon()
+*/
+QMessageBox::QMessageBox(const QString &title, const QString &text, Icon icon,
+ int button0, int button1, int button2, QWidget *parent,
+ Qt::WindowFlags f)
+ : QDialog(*new QMessageBoxPrivate, parent,
+ f /*| Qt::MSWindowsFixedSizeDialogHint #### */| Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint)
+{
+ Q_D(QMessageBox);
+ d->init(title, text);
+ setIcon(icon);
+ d->addOldButtons(button0, button1, button2);
+}
+
+/*!
+ \obsolete
+
+ Opens an information message box with the given \a title and the
+ \a text. The dialog may have up to three buttons. Each of the
+ buttons, \a button0, \a button1 and \a button2 may be set to one
+ of the following values:
+
+ \list
+ \o QMessageBox::NoButton
+ \o QMessageBox::Ok
+ \o QMessageBox::Cancel
+ \o QMessageBox::Yes
+ \o QMessageBox::No
+ \o QMessageBox::Abort
+ \o QMessageBox::Retry
+ \o QMessageBox::Ignore
+ \o QMessageBox::YesAll
+ \o QMessageBox::NoAll
+ \endlist
+
+ If you don't want all three buttons, set the last button, or last
+ two buttons to QMessageBox::NoButton.
+
+ One button can be OR-ed with QMessageBox::Default, and one
+ button can be OR-ed with QMessageBox::Escape.
+
+ Returns the identity (QMessageBox::Ok, or QMessageBox::No, etc.)
+ of the button that was clicked.
+
+ The message box is an \l{Qt::ApplicationModal} {application modal}
+ dialog box.
+
+ \warning Do not delete \a parent during the execution of the dialog.
+ If you want to do this, you should create the dialog
+ yourself using one of the QMessageBox constructors.
+
+ \sa question(), warning(), critical()
+*/
+int QMessageBox::information(QWidget *parent, const QString &title, const QString& text,
+ int button0, int button1, int button2)
+{
+ return QMessageBoxPrivate::showOldMessageBox(parent, Information, title, text,
+ button0, button1, button2);
+}
+
+/*!
+ \obsolete
+ \overload
+
+ Displays an information message box with the given \a title and
+ \a text, as well as one, two or three buttons. Returns the index
+ of the button that was clicked (0, 1 or 2).
+
+ \a button0Text is the text of the first button, and is optional.
+ If \a button0Text is not supplied, "OK" (translated) will be
+ used. \a button1Text is the text of the second button, and is
+ optional. \a button2Text is the text of the third button, and is
+ optional. \a defaultButtonNumber (0, 1 or 2) is the index of the
+ default button; pressing Return or Enter is the same as clicking
+ the default button. It defaults to 0 (the first button). \a
+ escapeButtonNumber is the index of the escape button; pressing
+ \key Esc is the same as clicking this button. It defaults to -1;
+ supply 0, 1 or 2 to make pressing \key Esc equivalent to clicking
+ the relevant button.
+
+ The message box is an \l{Qt::ApplicationModal} {application modal}
+ dialog box.
+
+ \warning Do not delete \a parent during the execution of the dialog.
+ If you want to do this, you should create the dialog
+ yourself using one of the QMessageBox constructors.
+
+ \sa question(), warning(), critical()
+*/
+
+int QMessageBox::information(QWidget *parent, const QString &title, const QString& text,
+ const QString& button0Text, const QString& button1Text,
+ const QString& button2Text, int defaultButtonNumber,
+ int escapeButtonNumber)
+{
+ return QMessageBoxPrivate::showOldMessageBox(parent, Information, title, text,
+ button0Text, button1Text, button2Text,
+ defaultButtonNumber, escapeButtonNumber);
+}
+
+/*!
+ \obsolete
+
+ Opens a question message box with the given \a title and \a text.
+ The dialog may have up to three buttons. Each of the buttons, \a
+ button0, \a button1 and \a button2 may be set to one of the
+ following values:
+
+ \list
+ \o QMessageBox::NoButton
+ \o QMessageBox::Ok
+ \o QMessageBox::Cancel
+ \o QMessageBox::Yes
+ \o QMessageBox::No
+ \o QMessageBox::Abort
+ \o QMessageBox::Retry
+ \o QMessageBox::Ignore
+ \o QMessageBox::YesAll
+ \o QMessageBox::NoAll
+ \endlist
+
+ If you don't want all three buttons, set the last button, or last
+ two buttons to QMessageBox::NoButton.
+
+ One button can be OR-ed with QMessageBox::Default, and one
+ button can be OR-ed with QMessageBox::Escape.
+
+ Returns the identity (QMessageBox::Yes, or QMessageBox::No, etc.)
+ of the button that was clicked.
+
+ The message box is an \l{Qt::ApplicationModal} {application modal}
+ dialog box.
+
+ \warning Do not delete \a parent during the execution of the dialog.
+ If you want to do this, you should create the dialog
+ yourself using one of the QMessageBox constructors.
+
+ \sa information(), warning(), critical()
+*/
+int QMessageBox::question(QWidget *parent, const QString &title, const QString& text,
+ int button0, int button1, int button2)
+{
+ return QMessageBoxPrivate::showOldMessageBox(parent, Question, title, text,
+ button0, button1, button2);
+}
+
+/*!
+ \obsolete
+ \overload
+
+ Displays a question message box with the given \a title and \a
+ text, as well as one, two or three buttons. Returns the index of
+ the button that was clicked (0, 1 or 2).
+
+ \a button0Text is the text of the first button, and is optional.
+ If \a button0Text is not supplied, "OK" (translated) will be used.
+ \a button1Text is the text of the second button, and is optional.
+ \a button2Text is the text of the third button, and is optional.
+ \a defaultButtonNumber (0, 1 or 2) is the index of the default
+ button; pressing Return or Enter is the same as clicking the
+ default button. It defaults to 0 (the first button). \a
+ escapeButtonNumber is the index of the Escape button; pressing
+ Escape is the same as clicking this button. It defaults to -1;
+ supply 0, 1 or 2 to make pressing Escape equivalent to clicking
+ the relevant button.
+
+ The message box is an \l{Qt::ApplicationModal} {application modal}
+ dialog box.
+
+ \warning Do not delete \a parent during the execution of the dialog.
+ If you want to do this, you should create the dialog
+ yourself using one of the QMessageBox constructors.
+
+ \sa information(), warning(), critical()
+*/
+int QMessageBox::question(QWidget *parent, const QString &title, const QString& text,
+ const QString& button0Text, const QString& button1Text,
+ const QString& button2Text, int defaultButtonNumber,
+ int escapeButtonNumber)
+{
+ return QMessageBoxPrivate::showOldMessageBox(parent, Question, title, text,
+ button0Text, button1Text, button2Text,
+ defaultButtonNumber, escapeButtonNumber);
+}
+
+
+/*!
+ \obsolete
+
+ Opens a warning message box with the given \a title and \a text.
+ The dialog may have up to three buttons. Each of the button
+ parameters, \a button0, \a button1 and \a button2 may be set to
+ one of the following values:
+
+ \list
+ \o QMessageBox::NoButton
+ \o QMessageBox::Ok
+ \o QMessageBox::Cancel
+ \o QMessageBox::Yes
+ \o QMessageBox::No
+ \o QMessageBox::Abort
+ \o QMessageBox::Retry
+ \o QMessageBox::Ignore
+ \o QMessageBox::YesAll
+ \o QMessageBox::NoAll
+ \endlist
+
+ If you don't want all three buttons, set the last button, or last
+ two buttons to QMessageBox::NoButton.
+
+ One button can be OR-ed with QMessageBox::Default, and one
+ button can be OR-ed with QMessageBox::Escape.
+
+ Returns the identity (QMessageBox::Ok or QMessageBox::No or ...)
+ of the button that was clicked.
+
+ The message box is an \l{Qt::ApplicationModal} {application modal}
+ dialog box.
+
+ \warning Do not delete \a parent during the execution of the dialog.
+ If you want to do this, you should create the dialog
+ yourself using one of the QMessageBox constructors.
+
+ \sa information(), question(), critical()
+*/
+int QMessageBox::warning(QWidget *parent, const QString &title, const QString& text,
+ int button0, int button1, int button2)
+{
+ return QMessageBoxPrivate::showOldMessageBox(parent, Warning, title, text,
+ button0, button1, button2);
+}
+
+/*!
+ \obsolete
+ \overload
+
+ Displays a warning message box with the given \a title and \a
+ text, as well as one, two, or three buttons. Returns the number
+ of the button that was clicked (0, 1, or 2).
+
+ \a button0Text is the text of the first button, and is optional.
+ If \a button0Text is not supplied, "OK" (translated) will be used.
+ \a button1Text is the text of the second button, and is optional,
+ and \a button2Text is the text of the third button, and is
+ optional. \a defaultButtonNumber (0, 1 or 2) is the index of the
+ default button; pressing Return or Enter is the same as clicking
+ the default button. It defaults to 0 (the first button). \a
+ escapeButtonNumber is the index of the Escape button; pressing
+ Escape is the same as clicking this button. It defaults to -1;
+ supply 0, 1, or 2 to make pressing Escape equivalent to clicking
+ the relevant button.
+
+ The message box is an \l{Qt::ApplicationModal} {application modal}
+ dialog box.
+
+ \warning Do not delete \a parent during the execution of the dialog.
+ If you want to do this, you should create the dialog
+ yourself using one of the QMessageBox constructors.
+
+ \sa information(), question(), critical()
+*/
+int QMessageBox::warning(QWidget *parent, const QString &title, const QString& text,
+ const QString& button0Text, const QString& button1Text,
+ const QString& button2Text, int defaultButtonNumber,
+ int escapeButtonNumber)
+{
+ return QMessageBoxPrivate::showOldMessageBox(parent, Warning, title, text,
+ button0Text, button1Text, button2Text,
+ defaultButtonNumber, escapeButtonNumber);
+}
+
+/*!
+ \obsolete
+
+ Opens a critical message box with the given \a title and \a text.
+ The dialog may have up to three buttons. Each of the button
+ parameters, \a button0, \a button1 and \a button2 may be set to
+ one of the following values:
+
+ \list
+ \o QMessageBox::NoButton
+ \o QMessageBox::Ok
+ \o QMessageBox::Cancel
+ \o QMessageBox::Yes
+ \o QMessageBox::No
+ \o QMessageBox::Abort
+ \o QMessageBox::Retry
+ \o QMessageBox::Ignore
+ \o QMessageBox::YesAll
+ \o QMessageBox::NoAll
+ \endlist
+
+ If you don't want all three buttons, set the last button, or last
+ two buttons to QMessageBox::NoButton.
+
+ One button can be OR-ed with QMessageBox::Default, and one
+ button can be OR-ed with QMessageBox::Escape.
+
+ Returns the identity (QMessageBox::Ok, or QMessageBox::No, etc.)
+ of the button that was clicked.
+
+ The message box is an \l{Qt::ApplicationModal} {application modal}
+ dialog box.
+
+ \warning Do not delete \a parent during the execution of the dialog.
+ If you want to do this, you should create the dialog
+ yourself using one of the QMessageBox constructors.
+
+ \sa information(), question(), warning()
+*/
+
+int QMessageBox::critical(QWidget *parent, const QString &title, const QString& text,
+ int button0, int button1, int button2)
+{
+ return QMessageBoxPrivate::showOldMessageBox(parent, Critical, title, text,
+ button0, button1, button2);
+}
+
+/*!
+ \obsolete
+ \overload
+
+ Displays a critical error message box with the given \a title and
+ \a text, as well as one, two, or three buttons. Returns the
+ number of the button that was clicked (0, 1 or 2).
+
+ \a button0Text is the text of the first button, and is optional.
+ If \a button0Text is not supplied, "OK" (translated) will be used.
+ \a button1Text is the text of the second button, and is optional,
+ and \a button2Text is the text of the third button, and is
+ optional. \a defaultButtonNumber (0, 1 or 2) is the index of the
+ default button; pressing Return or Enter is the same as clicking
+ the default button. It defaults to 0 (the first button). \a
+ escapeButtonNumber is the index of the Escape button; pressing
+ Escape is the same as clicking this button. It defaults to -1;
+ supply 0, 1, or 2 to make pressing Escape equivalent to clicking
+ the relevant button.
+
+ The message box is an \l{Qt::ApplicationModal} {application modal}
+ dialog box.
+
+ \warning Do not delete \a parent during the execution of the dialog.
+ If you want to do this, you should create the dialog
+ yourself using one of the QMessageBox constructors.
+
+ \sa information(), question(), warning()
+*/
+int QMessageBox::critical(QWidget *parent, const QString &title, const QString& text,
+ const QString& button0Text, const QString& button1Text,
+ const QString& button2Text, int defaultButtonNumber,
+ int escapeButtonNumber)
+{
+ return QMessageBoxPrivate::showOldMessageBox(parent, Critical, title, text,
+ button0Text, button1Text, button2Text,
+ defaultButtonNumber, escapeButtonNumber);
+}
+
+
+/*!
+ \obsolete
+
+ Returns the text of the message box button \a button, or
+ an empty string if the message box does not contain the button.
+
+ Use button() and QPushButton::text() instead.
+*/
+QString QMessageBox::buttonText(int button) const
+{
+ Q_D(const QMessageBox);
+
+ if (QAbstractButton *abstractButton = d->abstractButtonForId(button)) {
+ return abstractButton->text();
+ } else if (d->buttonBox->buttons().isEmpty() && (button == Ok || button == Old_Ok)) {
+ // for compatibility with Qt 4.0/4.1
+ return QDialogButtonBox::tr("OK");
+ }
+ return QString();
+}
+
+/*!
+ \obsolete
+
+ Sets the text of the message box button \a button to \a text.
+ Setting the text of a button that is not in the message box is
+ silently ignored.
+
+ Use addButton() instead.
+*/
+void QMessageBox::setButtonText(int button, const QString &text)
+{
+ Q_D(QMessageBox);
+ if (QAbstractButton *abstractButton = d->abstractButtonForId(button)) {
+ abstractButton->setText(text);
+ } else if (d->buttonBox->buttons().isEmpty() && (button == Ok || button == Old_Ok)) {
+ // for compatibility with Qt 4.0/4.1
+ addButton(QMessageBox::Ok)->setText(text);
+ }
+}
+
+#ifndef QT_NO_TEXTEDIT
+/*!
+ \property QMessageBox::detailedText
+ \brief the text to be displayed in the details area.
+ \since 4.2
+
+ The text will be interpreted as a plain text.
+
+ By default, this property contains an empty string.
+
+ \sa QMessageBox::text, QMessageBox::informativeText
+*/
+QString QMessageBox::detailedText() const
+{
+ Q_D(const QMessageBox);
+ return d->detailsText ? d->detailsText->text() : QString();
+}
+
+void QMessageBox::setDetailedText(const QString &text)
+{
+ Q_D(QMessageBox);
+ if (text.isEmpty()) {
+ delete d->detailsText;
+ d->detailsText = 0;
+ removeButton(d->detailsButton);
+ delete d->detailsButton;
+ d->detailsButton = 0;
+ return;
+ }
+
+ if (!d->detailsText) {
+ d->detailsText = new QMessageBoxDetailsText(this);
+ QGridLayout* grid = qobject_cast<QGridLayout*>(layout());
+ if (grid)
+ grid->addWidget(d->detailsText, grid->rowCount(), 0, 1, grid->columnCount());
+ d->detailsText->hide();
+ }
+ if (!d->detailsButton)
+ d->detailsButton = new DetailButton(this);
+ d->detailsText->setText(text);
+}
+#endif // QT_NO_TEXTEDIT
+
+/*!
+ \property QMessageBox::informativeText
+
+ \brief the informative text that provides a fuller description for
+ the message
+
+ \since 4.2
+
+ Infromative text can be used to expand upon the text() to give more
+ information to the user. On the Mac, this text appears in small
+ system font below the text(). On other platforms, it is simply
+ appended to the existing text.
+
+ By default, this property contains an empty string.
+
+ \sa QMessageBox::text, QMessageBox::detailedText
+*/
+QString QMessageBox::informativeText() const
+{
+ Q_D(const QMessageBox);
+ return d->informativeLabel ? d->informativeLabel->text() : QString();
+}
+
+void QMessageBox::setInformativeText(const QString &text)
+{
+ Q_D(QMessageBox);
+ if (text.isEmpty()) {
+ layout()->removeWidget(d->informativeLabel);
+ delete d->informativeLabel;
+ d->informativeLabel = 0;
+#ifndef Q_WS_MAC
+ d->label->setContentsMargins(2, 0, 0, 0);
+#endif
+ d->updateSize();
+ return;
+ }
+
+ if (!d->informativeLabel) {
+ QLabel *label = new QLabel;
+ label->setObjectName(QLatin1String("qt_msgbox_informativelabel"));
+ label->setTextInteractionFlags(Qt::TextInteractionFlags(style()->styleHint(QStyle::SH_MessageBox_TextInteractionFlags, 0, this)));
+ label->setAlignment(Qt::AlignTop | Qt::AlignLeft);
+ label->setOpenExternalLinks(true);
+ label->setWordWrap(true);
+#ifndef Q_WS_MAC
+ d->label->setContentsMargins(2, 0, 0, 0);
+ label->setContentsMargins(2, 0, 0, 6);
+ label->setIndent(9);
+#else
+ label->setContentsMargins(16, 0, 0, 0);
+ // apply a smaller font the information label on the mac
+ label->setFont(qt_app_fonts_hash()->value("QTipLabel"));
+#endif
+ label->setWordWrap(true);
+ QGridLayout *grid = static_cast<QGridLayout *>(layout());
+#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5)
+ label->hide();
+ QTextBrowser *textBrowser = new QTextBrowser(this);
+ textBrowser->setOpenExternalLinks(true);
+ grid->addWidget(textBrowser, 1, 1, 1, 1);
+ d->textBrowser = textBrowser;
+#else
+ grid->addWidget(label, 1, 1, 1, 1);
+#endif
+ d->informativeLabel = label;
+ }
+ d->informativeLabel->setText(text);
+
+#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5)
+ //We need to put the informative label inside textBrowser to enable scrolling of long texts.
+ d->textBrowser->setText(d->informativeLabel->text());
+#endif
+
+ d->updateSize();
+}
+
+/*!
+ \since 4.2
+
+ This function shadows QWidget::setWindowTitle().
+
+ Sets the title of the message box to \a title. On Mac OS X,
+ the window title is ignored (as required by the Mac OS X
+ Guidelines).
+*/
+void QMessageBox::setWindowTitle(const QString &title)
+{
+ // Message boxes on the mac do not have a title
+#ifndef Q_WS_MAC
+ QDialog::setWindowTitle(title);
+#else
+ Q_UNUSED(title);
+#endif
+}
+
+
+/*!
+ \since 4.2
+
+ This function shadows QWidget::setWindowModality().
+
+ Sets the modality of the message box to \a windowModality.
+
+ On Mac OS X, if the modality is set to Qt::WindowModal and the message box
+ has a parent, then the message box will be a Qt::Sheet, otherwise the
+ message box will be a standard dialog.
+*/
+void QMessageBox::setWindowModality(Qt::WindowModality windowModality)
+{
+ QDialog::setWindowModality(windowModality);
+
+ if (parentWidget() && windowModality == Qt::WindowModal)
+ setParent(parentWidget(), Qt::Sheet);
+ else
+ setParent(parentWidget(), Qt::Dialog);
+ setDefaultButton(d_func()->defaultButton);
+}
+
+#ifdef QT3_SUPPORT
+/*!
+ \compat
+
+ Constructs a message box with the given \a parent, \a name, and
+ window flags, \a f.
+ The window title is specified by \a title, and the message box
+ displays message text and an icon specified by \a text and \a icon.
+
+ The buttons that the user can access to respond to the message are
+ defined by \a button0, \a button1, and \a button2.
+*/
+QMessageBox::QMessageBox(const QString& title,
+ const QString &text, Icon icon,
+ int button0, int button1, int button2,
+ QWidget *parent, const char *name,
+ bool modal, Qt::WindowFlags f)
+ : QDialog(*new QMessageBoxPrivate, parent,
+ f | Qt::WStyle_Customize | Qt::WStyle_DialogBorder | Qt::WStyle_Title | Qt::WStyle_SysMenu | Qt::WindowCloseButtonHint)
+{
+ Q_D(QMessageBox);
+ setObjectName(QString::fromAscii(name));
+ d->init(title, text);
+ d->addOldButtons(button0, button1, button2);
+ setModal(modal);
+ setIcon(icon);
+}
+
+/*!
+ \compat
+ Constructs a message box with the given \a parent and \a name.
+*/
+QMessageBox::QMessageBox(QWidget *parent, const char *name)
+ : QDialog(*new QMessageBoxPrivate, parent,
+ Qt::WStyle_Customize | Qt::WStyle_DialogBorder | Qt::WStyle_Title | Qt::WStyle_SysMenu | Qt::WindowCloseButtonHint)
+{
+ Q_D(QMessageBox);
+ setObjectName(QString::fromAscii(name));
+ d->init();
+}
+
+/*!
+ Returns the pixmap used for a standard icon. This
+ allows the pixmaps to be used in more complex message boxes.
+ \a icon specifies the required icon, e.g. QMessageBox::Information,
+ QMessageBox::Warning or QMessageBox::Critical.
+
+ \a style is unused.
+*/
+
+QPixmap QMessageBox::standardIcon(Icon icon, Qt::GUIStyle style)
+{
+ Q_UNUSED(style);
+ return QMessageBox::standardIcon(icon);
+}
+
+/*!
+ \fn int QMessageBox::message(const QString &title, const QString &text,
+ const QString &buttonText, QWidget *parent = 0,
+ const char *name = 0)
+
+ Opens a modal message box with the given \a title and showing the
+ given \a text. The message box has a single button which has the
+ given \a buttonText (or tr("OK")). The message box is centred over
+ its \a parent and is called \a name.
+
+ Use information(), warning(), question(), or critical() instead.
+
+ \oldcode
+ QMessageBox::message(tr("My App"), tr("All occurrences replaced."),
+ tr("Close"), this);
+ \newcode
+ QMessageBox::information(this, tr("My App"),
+ tr("All occurrences replaced."),
+ QMessageBox::Close);
+ \endcode
+*/
+
+/*!
+ \fn bool QMessageBox::query(const QString &caption,
+ const QString& text,
+ const QString& yesButtonText,
+ const QString& noButtonText,
+ QWidget *parent, const char *name)
+
+ \obsolete
+
+ Queries the user using a modal message box with up to two buttons.
+ The message box has the given \a caption (although some window
+ managers don't show it), and shows the given \a text. The left
+ button has the \a yesButtonText (or tr("OK")), and the right button
+ has the \a noButtonText (or isn't shown). The message box is centred
+ over its \a parent and is called \a name.
+
+ Use information(), question(), warning(), or critical() instead.
+*/
+
+#endif
+
+QPixmap QMessageBoxPrivate::standardIcon(QMessageBox::Icon icon, QMessageBox *mb)
+{
+ QStyle *style = mb ? mb->style() : QApplication::style();
+ int iconSize = style->pixelMetric(QStyle::PM_MessageBoxIconSize, 0, mb);
+ QIcon tmpIcon;
+ switch (icon) {
+ case QMessageBox::Information:
+ tmpIcon = style->standardIcon(QStyle::SP_MessageBoxInformation, 0, mb);
+ break;
+ case QMessageBox::Warning:
+ tmpIcon = style->standardIcon(QStyle::SP_MessageBoxWarning, 0, mb);
+ break;
+ case QMessageBox::Critical:
+ tmpIcon = style->standardIcon(QStyle::SP_MessageBoxCritical, 0, mb);
+ break;
+ case QMessageBox::Question:
+ tmpIcon = style->standardIcon(QStyle::SP_MessageBoxQuestion, 0, mb);
+ default:
+ break;
+ }
+ if (!tmpIcon.isNull())
+ return tmpIcon.pixmap(iconSize, iconSize);
+ return QPixmap();
+}
+
+/*!
+ \obsolete
+
+ Returns the pixmap used for a standard icon. This allows the
+ pixmaps to be used in more complex message boxes. \a icon
+ specifies the required icon, e.g. QMessageBox::Question,
+ QMessageBox::Information, QMessageBox::Warning or
+ QMessageBox::Critical.
+
+ Call QStyle::standardIcon() with QStyle::SP_MessageBoxInformation etc.
+ instead.
+*/
+
+QPixmap QMessageBox::standardIcon(Icon icon)
+{
+ return QMessageBoxPrivate::standardIcon(icon, 0);
+}
+
+/*!
+ \typedef QMessageBox::Button
+ \obsolete
+
+ Use QMessageBox::StandardButton instead.
+*/
+
+/*!
+ \fn int QMessageBox::information(QWidget *parent, const QString &title,
+ const QString& text, StandardButton button0,
+ StandardButton button1)
+ \fn int QMessageBox::warning(QWidget *parent, const QString &title,
+ const QString& text, StandardButton button0,
+ StandardButton button1)
+ \fn int QMessageBox::critical(QWidget *parent, const QString &title,
+ const QString& text, StandardButton button0,
+ StandardButton button1)
+ \fn int QMessageBox::question(QWidget *parent, const QString &title,
+ const QString& text, StandardButton button0,
+ StandardButton button1)
+ \internal
+
+ ### Needed for Qt 4 source compatibility
+*/
+
+/*!
+ \fn int QMessageBox::exec()
+
+ Shows the message box as a \l{QDialog#Modal Dialogs}{modal dialog},
+ blocking until the user closes it.
+
+ When using a QMessageBox with standard buttons, this functions returns a
+ \l StandardButton value indicating the standard button that was clicked.
+ When using QMessageBox with custom buttons, this function returns an
+ opaque value; use clickedButton() to determine which button was clicked.
+
+ Users cannot interact with any other window in the same
+ application until they close the dialog, either by clicking a
+ button or by using a mechanism provided by the window system.
+
+ \sa show(), result()
+*/
+
+QT_END_NAMESPACE
+
+#include "moc_qmessagebox.cpp"
+
+#endif // QT_NO_MESSAGEBOX
diff --git a/src/widgets/dialogs/qmessagebox.h b/src/widgets/dialogs/qmessagebox.h
new file mode 100644
index 0000000000..d1894e2c58
--- /dev/null
+++ b/src/widgets/dialogs/qmessagebox.h
@@ -0,0 +1,365 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMESSAGEBOX_H
+#define QMESSAGEBOX_H
+
+#include <QtWidgets/qdialog.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_MESSAGEBOX
+
+class QLabel;
+class QMessageBoxPrivate;
+class QAbstractButton;
+
+class Q_GUI_EXPORT QMessageBox : public QDialog
+{
+ Q_OBJECT
+ Q_ENUMS(Icon)
+ Q_FLAGS(StandardButtons)
+ Q_PROPERTY(QString text READ text WRITE setText)
+ // ### Qt 5: Rename 'icon' 'standardIcon' and 'iconPixmap' 'icon' (and use QIcon?)
+ Q_PROPERTY(Icon icon READ icon WRITE setIcon)
+ Q_PROPERTY(QPixmap iconPixmap READ iconPixmap WRITE setIconPixmap)
+ Q_PROPERTY(Qt::TextFormat textFormat READ textFormat WRITE setTextFormat)
+ Q_PROPERTY(StandardButtons standardButtons READ standardButtons WRITE setStandardButtons)
+#ifndef QT_NO_TEXTEDIT
+ Q_PROPERTY(QString detailedText READ detailedText WRITE setDetailedText)
+#endif
+ Q_PROPERTY(QString informativeText READ informativeText WRITE setInformativeText)
+
+public:
+ enum Icon {
+ NoIcon = 0,
+ Information = 1,
+ Warning = 2,
+ Critical = 3,
+ Question = 4
+ };
+
+ enum ButtonRole {
+ // keep this in sync with QDialogButtonBox::ButtonRole
+ InvalidRole = -1,
+ AcceptRole,
+ RejectRole,
+ DestructiveRole,
+ ActionRole,
+ HelpRole,
+ YesRole,
+ NoRole,
+ ResetRole,
+ ApplyRole,
+
+ NRoles
+ };
+
+ enum StandardButton {
+ // keep this in sync with QDialogButtonBox::StandardButton
+ NoButton = 0x00000000,
+ Ok = 0x00000400,
+ Save = 0x00000800,
+ SaveAll = 0x00001000,
+ Open = 0x00002000,
+ Yes = 0x00004000,
+ YesToAll = 0x00008000,
+ No = 0x00010000,
+ NoToAll = 0x00020000,
+ Abort = 0x00040000,
+ Retry = 0x00080000,
+ Ignore = 0x00100000,
+ Close = 0x00200000,
+ Cancel = 0x00400000,
+ Discard = 0x00800000,
+ Help = 0x01000000,
+ Apply = 0x02000000,
+ Reset = 0x04000000,
+ RestoreDefaults = 0x08000000,
+
+ FirstButton = Ok, // internal
+ LastButton = RestoreDefaults, // internal
+
+ YesAll = YesToAll, // obsolete
+ NoAll = NoToAll, // obsolete
+
+ Default = 0x00000100, // obsolete
+ Escape = 0x00000200, // obsolete
+ FlagMask = 0x00000300, // obsolete
+ ButtonMask = ~FlagMask // obsolete
+ };
+ typedef StandardButton Button; // obsolete
+
+ Q_DECLARE_FLAGS(StandardButtons, StandardButton)
+
+ explicit QMessageBox(QWidget *parent = 0);
+ QMessageBox(Icon icon, const QString &title, const QString &text,
+ StandardButtons buttons = NoButton, QWidget *parent = 0,
+ Qt::WindowFlags flags = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
+ ~QMessageBox();
+
+ void addButton(QAbstractButton *button, ButtonRole role);
+ QPushButton *addButton(const QString &text, ButtonRole role);
+ QPushButton *addButton(StandardButton button);
+ void removeButton(QAbstractButton *button);
+
+#ifdef Q_WS_WINCE
+ void setVisible(bool visible);
+#endif
+
+#ifdef Q_NO_USING_KEYWORD
+#ifndef Q_QDOC
+ void open() { QDialog::open(); }
+#endif
+#else
+ using QDialog::open;
+#endif
+ void open(QObject *receiver, const char *member);
+
+ QList<QAbstractButton *> buttons() const;
+ ButtonRole buttonRole(QAbstractButton *button) const;
+
+ void setStandardButtons(StandardButtons buttons);
+ StandardButtons standardButtons() const;
+ StandardButton standardButton(QAbstractButton *button) const;
+ QAbstractButton *button(StandardButton which) const;
+
+ QPushButton *defaultButton() const;
+ void setDefaultButton(QPushButton *button);
+ void setDefaultButton(StandardButton button);
+
+ QAbstractButton *escapeButton() const;
+ void setEscapeButton(QAbstractButton *button);
+ void setEscapeButton(StandardButton button);
+
+ QAbstractButton *clickedButton() const;
+
+ QString text() const;
+ void setText(const QString &text);
+
+ Icon icon() const;
+ void setIcon(Icon);
+
+ QPixmap iconPixmap() const;
+ void setIconPixmap(const QPixmap &pixmap);
+
+ Qt::TextFormat textFormat() const;
+ void setTextFormat(Qt::TextFormat format);
+
+ static StandardButton information(QWidget *parent, const QString &title,
+ const QString &text, StandardButtons buttons = Ok,
+ StandardButton defaultButton = NoButton);
+ // ### Qt 5: Replace Ok with Yes|No in question() function.
+ // Also consider if Ok == Yes and Cancel == No.
+ static StandardButton question(QWidget *parent, const QString &title,
+ const QString &text, StandardButtons buttons = Ok,
+ StandardButton defaultButton = NoButton);
+ static StandardButton warning(QWidget *parent, const QString &title,
+ const QString &text, StandardButtons buttons = Ok,
+ StandardButton defaultButton = NoButton);
+ static StandardButton critical(QWidget *parent, const QString &title,
+ const QString &text, StandardButtons buttons = Ok,
+ StandardButton defaultButton = NoButton);
+ static void about(QWidget *parent, const QString &title, const QString &text);
+ static void aboutQt(QWidget *parent, const QString &title = QString());
+
+ QSize sizeHint() const;
+
+ // the following functions are obsolete:
+
+ QMessageBox(const QString &title, const QString &text, Icon icon,
+ int button0, int button1, int button2,
+ QWidget *parent = 0,
+ Qt::WindowFlags f = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
+
+ static int information(QWidget *parent, const QString &title,
+ const QString& text,
+ int button0, int button1 = 0, int button2 = 0);
+ static int information(QWidget *parent, const QString &title,
+ const QString& text,
+ const QString& button0Text,
+ const QString& button1Text = QString(),
+ const QString& button2Text = QString(),
+ int defaultButtonNumber = 0,
+ int escapeButtonNumber = -1);
+ inline static StandardButton information(QWidget *parent, const QString &title,
+ const QString& text,
+ StandardButton button0, StandardButton button1 = NoButton)
+ { return information(parent, title, text, StandardButtons(button0), button1); }
+
+ static int question(QWidget *parent, const QString &title,
+ const QString& text,
+ int button0, int button1 = 0, int button2 = 0);
+ static int question(QWidget *parent, const QString &title,
+ const QString& text,
+ const QString& button0Text,
+ const QString& button1Text = QString(),
+ const QString& button2Text = QString(),
+ int defaultButtonNumber = 0,
+ int escapeButtonNumber = -1);
+ inline static int question(QWidget *parent, const QString &title,
+ const QString& text,
+ StandardButton button0, StandardButton button1)
+ { return question(parent, title, text, StandardButtons(button0), button1); }
+
+ static int warning(QWidget *parent, const QString &title,
+ const QString& text,
+ int button0, int button1, int button2 = 0);
+ static int warning(QWidget *parent, const QString &title,
+ const QString& text,
+ const QString& button0Text,
+ const QString& button1Text = QString(),
+ const QString& button2Text = QString(),
+ int defaultButtonNumber = 0,
+ int escapeButtonNumber = -1);
+ inline static int warning(QWidget *parent, const QString &title,
+ const QString& text,
+ StandardButton button0, StandardButton button1)
+ { return warning(parent, title, text, StandardButtons(button0), button1); }
+
+ static int critical(QWidget *parent, const QString &title,
+ const QString& text,
+ int button0, int button1, int button2 = 0);
+ static int critical(QWidget *parent, const QString &title,
+ const QString& text,
+ const QString& button0Text,
+ const QString& button1Text = QString(),
+ const QString& button2Text = QString(),
+ int defaultButtonNumber = 0,
+ int escapeButtonNumber = -1);
+ inline static int critical(QWidget *parent, const QString &title,
+ const QString& text,
+ StandardButton button0, StandardButton button1)
+ { return critical(parent, title, text, StandardButtons(button0), button1); }
+
+ QString buttonText(int button) const;
+ void setButtonText(int button, const QString &text);
+
+ QString informativeText() const;
+ void setInformativeText(const QString &text);
+
+#ifndef QT_NO_TEXTEDIT
+ QString detailedText() const;
+ void setDetailedText(const QString &text);
+#endif
+
+ void setWindowTitle(const QString &title);
+ void setWindowModality(Qt::WindowModality windowModality);
+
+#ifdef QT3_SUPPORT
+ QT3_SUPPORT_CONSTRUCTOR QMessageBox(const QString &title, const QString &text, Icon icon,
+ int button0, int button1, int button2,
+ QWidget *parent, const char *name, bool modal,
+ Qt::WindowFlags f = Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
+ QT3_SUPPORT_CONSTRUCTOR QMessageBox(QWidget *parent, const char *name);
+
+ static QT3_SUPPORT QPixmap standardIcon(Icon icon, Qt::GUIStyle);
+ static QT3_SUPPORT int message(const QString &title,
+ const QString& text,
+ const QString& buttonText=QString(),
+ QWidget *parent = 0, const char * = 0) {
+ return QMessageBox::information(parent, title, text,
+ buttonText.isEmpty() ? tr("OK") : buttonText) == 0;
+ }
+ static QT3_SUPPORT bool query(const QString &title,
+ const QString& text,
+ const QString& yesButtonText = QString(),
+ const QString& noButtonText = QString(),
+ QWidget *parent = 0, const char * = 0) {
+ return QMessageBox::information(parent, title, text,
+ yesButtonText.isEmpty() ? tr("OK") : yesButtonText,
+ noButtonText) == 0;
+ }
+#endif
+
+ static QPixmap standardIcon(Icon icon);
+
+Q_SIGNALS:
+ void buttonClicked(QAbstractButton *button);
+
+#ifdef qdoc
+public Q_SLOTS:
+ int exec();
+#endif
+
+protected:
+ bool event(QEvent *e);
+ void resizeEvent(QResizeEvent *event);
+ void showEvent(QShowEvent *event);
+ void closeEvent(QCloseEvent *event);
+ void keyPressEvent(QKeyEvent *event);
+ void changeEvent(QEvent *event);
+
+private:
+ Q_PRIVATE_SLOT(d_func(), void _q_buttonClicked(QAbstractButton *))
+
+ Q_DISABLE_COPY(QMessageBox)
+ Q_DECLARE_PRIVATE(QMessageBox)
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QMessageBox::StandardButtons)
+
+#define QT_REQUIRE_VERSION(argc, argv, str) { QString s = QString::fromLatin1(str);\
+QString sq = QString::fromLatin1(qVersion()); \
+if ((sq.section(QChar::fromLatin1('.'),0,0).toInt()<<16)+\
+(sq.section(QChar::fromLatin1('.'),1,1).toInt()<<8)+\
+sq.section(QChar::fromLatin1('.'),2,2).toInt()<(s.section(QChar::fromLatin1('.'),0,0).toInt()<<16)+\
+(s.section(QChar::fromLatin1('.'),1,1).toInt()<<8)+\
+s.section(QChar::fromLatin1('.'),2,2).toInt()) { \
+if (!qApp){ \
+ new QApplication(argc,argv); \
+} \
+QString s = QApplication::tr("Executable '%1' requires Qt "\
+ "%2, found Qt %3.").arg(qAppName()).arg(QString::fromLatin1(\
+str)).arg(QString::fromLatin1(qVersion())); QMessageBox::critical(0, QApplication::tr(\
+"Incompatible Qt Library Error"), s, QMessageBox::Abort, 0); qFatal("%s", s.toLatin1().data()); }}
+
+#endif // QT_NO_MESSAGEBOX
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QMESSAGEBOX_H
diff --git a/src/gui/dialogs/qmessagebox.qrc b/src/widgets/dialogs/qmessagebox.qrc
index 8e6d7af671..8e6d7af671 100644
--- a/src/gui/dialogs/qmessagebox.qrc
+++ b/src/widgets/dialogs/qmessagebox.qrc
diff --git a/src/gui/dialogs/qnspanelproxy_mac.mm b/src/widgets/dialogs/qnspanelproxy_mac.mm
index 5c8ef24688..5c8ef24688 100644
--- a/src/gui/dialogs/qnspanelproxy_mac.mm
+++ b/src/widgets/dialogs/qnspanelproxy_mac.mm
diff --git a/src/gui/dialogs/qpagesetupdialog.cpp b/src/widgets/dialogs/qpagesetupdialog.cpp
index 4037e1cff8..4037e1cff8 100644
--- a/src/gui/dialogs/qpagesetupdialog.cpp
+++ b/src/widgets/dialogs/qpagesetupdialog.cpp
diff --git a/src/widgets/dialogs/qpagesetupdialog.h b/src/widgets/dialogs/qpagesetupdialog.h
new file mode 100644
index 0000000000..a0ec268adb
--- /dev/null
+++ b/src/widgets/dialogs/qpagesetupdialog.h
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPAGESETUPDIALOG_H
+#define QPAGESETUPDIALOG_H
+
+#include <QtWidgets/qabstractpagesetupdialog.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_PRINTDIALOG
+
+class QPageSetupDialogPrivate;
+
+class Q_GUI_EXPORT QPageSetupDialog : public QAbstractPageSetupDialog
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QPageSetupDialog)
+ Q_ENUMS(PageSetupDialogOption)
+ Q_PROPERTY(PageSetupDialogOptions options READ options WRITE setOptions)
+
+public:
+ enum PageSetupDialogOption {
+ None = 0x00000000, // internal
+ DontUseSheet = 0x00000001,
+ OwnsPrinter = 0x80000000 // internal
+ };
+
+ Q_DECLARE_FLAGS(PageSetupDialogOptions, PageSetupDialogOption)
+
+ explicit QPageSetupDialog(QPrinter *printer, QWidget *parent = 0);
+ explicit QPageSetupDialog(QWidget *parent = 0);
+
+ // obsolete
+ void addEnabledOption(PageSetupDialogOption option);
+ void setEnabledOptions(PageSetupDialogOptions options);
+ PageSetupDialogOptions enabledOptions() const;
+ bool isOptionEnabled(PageSetupDialogOption option) const;
+
+ void setOption(PageSetupDialogOption option, bool on = true);
+ bool testOption(PageSetupDialogOption option) const;
+ void setOptions(PageSetupDialogOptions options);
+ PageSetupDialogOptions options() const;
+
+#if defined(Q_WS_MAC) || defined(Q_OS_WIN)
+ virtual void setVisible(bool visible);
+#endif
+ virtual int exec();
+
+#ifdef Q_NO_USING_KEYWORD
+#ifndef Q_QDOC
+ void open() { QDialog::open(); }
+#endif
+#else
+ using QDialog::open;
+#endif
+ void open(QObject *receiver, const char *member);
+
+#ifdef qdoc
+ QPrinter *printer();
+#endif
+};
+
+#endif // QT_NO_PRINTDIALOG
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPAGESETUPDIALOG_H
diff --git a/src/gui/dialogs/qpagesetupdialog_mac.mm b/src/widgets/dialogs/qpagesetupdialog_mac.mm
index fa3f47378f..fa3f47378f 100644
--- a/src/gui/dialogs/qpagesetupdialog_mac.mm
+++ b/src/widgets/dialogs/qpagesetupdialog_mac.mm
diff --git a/src/gui/dialogs/qpagesetupdialog_unix.cpp b/src/widgets/dialogs/qpagesetupdialog_unix.cpp
index a4e0927e8c..a4e0927e8c 100644
--- a/src/gui/dialogs/qpagesetupdialog_unix.cpp
+++ b/src/widgets/dialogs/qpagesetupdialog_unix.cpp
diff --git a/src/gui/dialogs/qpagesetupdialog_unix_p.h b/src/widgets/dialogs/qpagesetupdialog_unix_p.h
index fea70b6bfe..fea70b6bfe 100644
--- a/src/gui/dialogs/qpagesetupdialog_unix_p.h
+++ b/src/widgets/dialogs/qpagesetupdialog_unix_p.h
diff --git a/src/gui/dialogs/qpagesetupdialog_win.cpp b/src/widgets/dialogs/qpagesetupdialog_win.cpp
index d74da7c2fc..d74da7c2fc 100644
--- a/src/gui/dialogs/qpagesetupdialog_win.cpp
+++ b/src/widgets/dialogs/qpagesetupdialog_win.cpp
diff --git a/src/gui/dialogs/qpagesetupwidget.ui b/src/widgets/dialogs/qpagesetupwidget.ui
index ace2ab8f44..ace2ab8f44 100644
--- a/src/gui/dialogs/qpagesetupwidget.ui
+++ b/src/widgets/dialogs/qpagesetupwidget.ui
diff --git a/src/widgets/dialogs/qprintdialog.h b/src/widgets/dialogs/qprintdialog.h
new file mode 100644
index 0000000000..a23766f0d8
--- /dev/null
+++ b/src/widgets/dialogs/qprintdialog.h
@@ -0,0 +1,174 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPRINTDIALOG_H
+#define QPRINTDIALOG_H
+
+#include <QtWidgets/qabstractprintdialog.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_PRINTDIALOG
+
+class QPrintDialogPrivate;
+class QPushButton;
+class QPrinter;
+
+#if defined (Q_OS_UNIX) && !defined(QTOPIA_PRINTDIALOG) && !defined(Q_WS_MAC) && !defined(Q_OS_SYMBIAN)
+class QUnixPrintWidgetPrivate;
+
+class Q_GUI_EXPORT QUnixPrintWidget : public QWidget
+{
+ Q_OBJECT
+
+public:
+ QUnixPrintWidget(QPrinter *printer, QWidget *parent = 0);
+ ~QUnixPrintWidget();
+ void updatePrinter();
+
+private:
+ friend class QPrintDialogPrivate;
+ friend class QUnixPrintWidgetPrivate;
+ QUnixPrintWidgetPrivate *d;
+ Q_PRIVATE_SLOT(d, void _q_printerChanged(int))
+ Q_PRIVATE_SLOT(d, void _q_btnBrowseClicked())
+ Q_PRIVATE_SLOT(d, void _q_btnPropertiesClicked())
+};
+#endif
+
+class Q_GUI_EXPORT QPrintDialog : public QAbstractPrintDialog
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QPrintDialog)
+ Q_ENUMS(PrintDialogOption)
+ Q_PROPERTY(PrintDialogOptions options READ options WRITE setOptions)
+
+public:
+ explicit QPrintDialog(QPrinter *printer, QWidget *parent = 0);
+ explicit QPrintDialog(QWidget *parent = 0);
+ ~QPrintDialog();
+
+ int exec();
+#if defined (Q_OS_UNIX) && !defined(QTOPIA_PRINTDIALOG) && !defined(Q_WS_MAC)
+ virtual void accept();
+#endif
+ void done(int result);
+
+#if defined (Q_OS_UNIX) && defined (QT3_SUPPORT)
+ QT3_SUPPORT void setPrinter(QPrinter *, bool = false);
+ QT3_SUPPORT QPrinter *printer() const;
+ QT3_SUPPORT void addButton(QPushButton *button);
+#endif
+
+ void setOption(PrintDialogOption option, bool on = true);
+ bool testOption(PrintDialogOption option) const;
+ void setOptions(PrintDialogOptions options);
+ PrintDialogOptions options() const;
+
+#if defined(Q_OS_UNIX) || defined(Q_WS_MAC) || defined(Q_OS_WIN)
+ void setVisible(bool visible);
+#endif
+
+#ifdef Q_NO_USING_KEYWORD
+#ifndef Q_QDOC
+ void open() { QDialog::open(); }
+#endif
+#else
+ using QDialog::open;
+#endif
+ void open(QObject *receiver, const char *member);
+
+#ifdef qdoc
+ QPrinter *printer();
+#endif
+
+#ifdef QTOPIA_PRINTDIALOG
+public:
+ bool eventFilter(QObject *, QEvent *);
+#endif
+
+#ifdef Q_NO_USING_KEYWORD
+#ifndef Q_QDOC
+ void accepted() { QDialog::accepted(); }
+#endif
+#else
+ using QDialog::accepted;
+#endif
+
+Q_SIGNALS:
+ void accepted(QPrinter *printer);
+
+private:
+#ifndef QTOPIA_PRINTDIALOG
+ Q_PRIVATE_SLOT(d_func(), void _q_chbPrintLastFirstToggled(bool))
+#if defined (Q_OS_UNIX) && !defined (Q_OS_MAC)
+ Q_PRIVATE_SLOT(d_func(), void _q_collapseOrExpandDialog())
+#endif
+# if defined(Q_OS_UNIX) && !defined (Q_OS_MAC) && !defined(QT_NO_MESSAGEBOX)
+ Q_PRIVATE_SLOT(d_func(), void _q_checkFields())
+# endif
+#else // QTOPIA_PRINTDIALOG
+ Q_PRIVATE_SLOT(d_func(), void _q_okClicked())
+ Q_PRIVATE_SLOT(d_func(),void _q_printerOrFileSelected(QAbstractButton *b))
+ Q_PRIVATE_SLOT(d_func(),void _q_paperSizeSelected(int))
+ Q_PRIVATE_SLOT(d_func(), void _q_orientSelected(int))
+ Q_PRIVATE_SLOT(d_func(), void _q_pageOrderSelected(int))
+ Q_PRIVATE_SLOT(d_func(), void _q_colorModeSelected(QAbstractButton *))
+ Q_PRIVATE_SLOT(d_func(), void _q_setNumCopies(int))
+ Q_PRIVATE_SLOT(d_func(), void _q_printRangeSelected(int))
+ Q_PRIVATE_SLOT(d_func(), void _q_setFirstPage(int))
+ Q_PRIVATE_SLOT(d_func(), void _q_setLastPage(int))
+ Q_PRIVATE_SLOT(d_func(), void _q_fileNameEditChanged(const QString &text))
+#endif // QTOPIA_PRINTDIALOG
+ friend class QUnixPrintWidget;
+};
+
+#endif // QT_NO_PRINTDIALOG
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPRINTDIALOG_H
diff --git a/src/gui/dialogs/qprintdialog.qdoc b/src/widgets/dialogs/qprintdialog.qdoc
index 0fff9dd450..0fff9dd450 100644
--- a/src/gui/dialogs/qprintdialog.qdoc
+++ b/src/widgets/dialogs/qprintdialog.qdoc
diff --git a/src/gui/dialogs/qprintdialog.qrc b/src/widgets/dialogs/qprintdialog.qrc
index f54eb6b5ee..f54eb6b5ee 100644
--- a/src/gui/dialogs/qprintdialog.qrc
+++ b/src/widgets/dialogs/qprintdialog.qrc
diff --git a/src/gui/dialogs/qprintdialog_mac.mm b/src/widgets/dialogs/qprintdialog_mac.mm
index ed60b1016f..ed60b1016f 100644
--- a/src/gui/dialogs/qprintdialog_mac.mm
+++ b/src/widgets/dialogs/qprintdialog_mac.mm
diff --git a/src/widgets/dialogs/qprintdialog_unix.cpp b/src/widgets/dialogs/qprintdialog_unix.cpp
new file mode 100644
index 0000000000..bb43e9b689
--- /dev/null
+++ b/src/widgets/dialogs/qprintdialog_unix.cpp
@@ -0,0 +1,1286 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformdefs.h"
+
+#ifndef QT_NO_PRINTDIALOG
+
+#include "private/qabstractprintdialog_p.h"
+#include <QtWidgets/qmessagebox.h>
+#include "qprintdialog.h"
+#include "qfiledialog.h"
+#include <QtCore/qdir.h>
+#include <QtGui/qevent.h>
+#include <QtWidgets/qfilesystemmodel.h>
+#include <QtWidgets/qstyleditemdelegate.h>
+#include <QtGui/qprinter.h>
+
+#include <QtWidgets/qdialogbuttonbox.h>
+
+#include "qfscompleter_p.h"
+#include "ui_qprintpropertieswidget.h"
+#include "ui_qprintsettingsoutput.h"
+#include "ui_qprintwidget.h"
+
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+# include <private/qcups_p.h>
+# include <cups/cups.h>
+# include <private/qpdf_p.h>
+#else
+# include <QtCore/qlibrary.h>
+#endif
+
+#include <private/qprinterinfo_unix_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QOptionTreeItem;
+class QPPDOptionsModel;
+
+class QPrintPropertiesDialog : public QDialog
+{
+ Q_OBJECT
+public:
+ QPrintPropertiesDialog(QAbstractPrintDialog *parent = 0);
+ ~QPrintPropertiesDialog();
+
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ void setCups(QCUPSSupport *cups) { m_cups = cups; }
+ void addItemToOptions(QOptionTreeItem *parent, QList<const ppd_option_t*>& options, QList<const char*>& markedOptions) const;
+#endif
+
+ void selectPrinter();
+ void selectPdfPsPrinter(const QPrinter *p);
+
+ /// copy printer properties to the widget
+ void applyPrinterProperties(QPrinter *p);
+ void setupPrinter() const;
+
+protected:
+ void showEvent(QShowEvent* event);
+
+private:
+ Ui::QPrintPropertiesWidget widget;
+ QDialogButtonBox *m_buttons;
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ QCUPSSupport *m_cups;
+ QPPDOptionsModel *m_cupsOptionsModel;
+#endif
+};
+
+class QPrintDialogPrivate : public QAbstractPrintDialogPrivate
+{
+ Q_DECLARE_PUBLIC(QPrintDialog)
+ Q_DECLARE_TR_FUNCTIONS(QPrintDialog)
+public:
+ QPrintDialogPrivate();
+ ~QPrintDialogPrivate();
+
+ void init();
+ /// copy printer properties to the widget
+ void applyPrinterProperties(QPrinter *p);
+
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ void selectPrinter(QCUPSSupport *cups);
+#endif
+
+ void _q_chbPrintLastFirstToggled(bool);
+#ifndef QT_NO_MESSAGEBOX
+ void _q_checkFields();
+#endif
+ void _q_collapseOrExpandDialog();
+
+ void setupPrinter();
+ void updateWidgets();
+
+ virtual void setTabs(const QList<QWidget*> &tabs);
+
+ Ui::QPrintSettingsOutput options;
+ QUnixPrintWidget *top;
+ QWidget *bottom;
+ QDialogButtonBox *buttons;
+ QPushButton *collapseButton;
+};
+
+#if defined (Q_OS_UNIX)
+class QUnixPrintWidgetPrivate
+{
+public:
+ QUnixPrintWidgetPrivate(QUnixPrintWidget *q);
+ ~QUnixPrintWidgetPrivate();
+
+ /// copy printer properties to the widget
+ void applyPrinterProperties(QPrinter *p);
+ bool checkFields();
+ void setupPrinter();
+ void setOptionsPane(QPrintDialogPrivate *pane);
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ void setCupsProperties();
+#endif
+
+// slots
+ void _q_printerChanged(int index);
+ void _q_btnPropertiesClicked();
+ void _q_btnBrowseClicked();
+
+ QUnixPrintWidget * const parent;
+ QPrintPropertiesDialog *propertiesDialog;
+ Ui::QPrintWidget widget;
+ QAbstractPrintDialog * q;
+ QPrinter *printer;
+ QList<QPrinterDescription> lprPrinters;
+ void updateWidget();
+
+private:
+ QPrintDialogPrivate *optionsPane;
+ bool filePrintersAdded;
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ QCUPSSupport* cups;
+ int cupsPrinterCount;
+ const cups_dest_t* cupsPrinters;
+ const ppd_file_t* cupsPPD;
+#endif
+};
+#endif
+
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+class QOptionTreeItem
+{
+public:
+ enum ItemType { Root, Group, Option, Choice };
+
+ QOptionTreeItem(ItemType t, int i, const void* p, const char* desc, QOptionTreeItem* pi)
+ : type(t),
+ index(i),
+ ptr(p),
+ description(desc),
+ selected(-1),
+ selDescription(0),
+ parentItem(pi) {}
+
+ ~QOptionTreeItem() {
+ while (!childItems.isEmpty())
+ delete childItems.takeFirst();
+ }
+
+ ItemType type;
+ int index;
+ const void* ptr;
+ const char* description;
+ int selected;
+ const char* selDescription;
+ QOptionTreeItem* parentItem;
+ QList<QOptionTreeItem*> childItems;
+};
+
+class QPPDOptionsModel : public QAbstractItemModel
+{
+ friend class QPPDOptionsEditor;
+public:
+ QPPDOptionsModel(QCUPSSupport *cups, QObject *parent = 0);
+ ~QPPDOptionsModel();
+
+ int columnCount(const QModelIndex& parent = QModelIndex()) const;
+ int rowCount(const QModelIndex& parent = QModelIndex()) const;
+ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
+ QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const;
+ QModelIndex parent(const QModelIndex& index) const;
+ Qt::ItemFlags flags(const QModelIndex& index) const;
+ QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const;
+
+ QOptionTreeItem* rootItem;
+ QCUPSSupport *cups;
+ const ppd_file_t* ppd;
+ void parseItems();
+ void parseGroups(QOptionTreeItem* parent);
+ void parseOptions(QOptionTreeItem* parent);
+ void parseChoices(QOptionTreeItem* parent);
+};
+
+class QPPDOptionsEditor : public QStyledItemDelegate
+{
+ Q_OBJECT
+public:
+ QPPDOptionsEditor(QObject* parent = 0) : QStyledItemDelegate(parent) {}
+ ~QPPDOptionsEditor() {}
+
+ 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 cbChanged(int index);
+
+};
+
+#endif
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+QPrintPropertiesDialog::QPrintPropertiesDialog(QAbstractPrintDialog *parent)
+ : QDialog(parent)
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ , m_cups(0), m_cupsOptionsModel(0)
+#endif
+{
+ QVBoxLayout *lay = new QVBoxLayout(this);
+ this->setLayout(lay);
+ QWidget *content = new QWidget(this);
+ widget.setupUi(content);
+ m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);
+ lay->addWidget(content);
+ lay->addWidget(m_buttons);
+
+ connect(m_buttons->button(QDialogButtonBox::Ok), SIGNAL(clicked()), this, SLOT(accept()));
+ connect(m_buttons->button(QDialogButtonBox::Cancel), SIGNAL(clicked()), this, SLOT(reject()));
+}
+
+QPrintPropertiesDialog::~QPrintPropertiesDialog()
+{
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ delete m_cupsOptionsModel;
+#else
+ delete widget.cupsPropertiesPage;
+#endif
+}
+
+void QPrintPropertiesDialog::applyPrinterProperties(QPrinter *p)
+{
+ widget.pageSetup->setPrinter(p);
+}
+
+void QPrintPropertiesDialog::setupPrinter() const
+{
+ widget.pageSetup->setupPrinter();
+
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ QPPDOptionsModel* model = static_cast<QPPDOptionsModel*>(widget.treeView->model());
+ if (model) {
+ QOptionTreeItem* rootItem = model->rootItem;
+ QList<const ppd_option_t*> options;
+ QList<const char*> markedOptions;
+
+ addItemToOptions(rootItem, options, markedOptions);
+ model->cups->saveOptions(options, markedOptions);
+ }
+#endif
+}
+
+void QPrintPropertiesDialog::selectPrinter()
+{
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ widget.pageSetup->selectPrinter(m_cups);
+ widget.treeView->setModel(0);
+ if (m_cups && QCUPSSupport::isAvailable()) {
+
+ if (m_cupsOptionsModel == 0) {
+ m_cupsOptionsModel = new QPPDOptionsModel(m_cups);
+
+ widget.treeView->setItemDelegate(new QPPDOptionsEditor(this));
+ } else {
+ // update the model
+ m_cupsOptionsModel->parseItems();
+ }
+
+ if (m_cupsOptionsModel->rowCount() > 0) {
+ widget.treeView->setModel(m_cupsOptionsModel);
+
+ for (int i = 0; i < m_cupsOptionsModel->rowCount(); ++i)
+ widget.treeView->expand(m_cupsOptionsModel->index(i,0));
+
+ widget.tabs->setTabEnabled(1, true); // enable the advanced tab
+ } else {
+ widget.tabs->setTabEnabled(1, false);
+ }
+
+ } else
+#endif
+ {
+ widget.cupsPropertiesPage->setEnabled(false);
+ widget.pageSetup->selectPrinter(0);
+ }
+}
+
+void QPrintPropertiesDialog::selectPdfPsPrinter(const QPrinter *p)
+{
+ widget.treeView->setModel(0);
+ widget.pageSetup->selectPdfPsPrinter(p);
+ widget.tabs->setTabEnabled(1, false); // disable the advanced tab
+}
+
+void QPrintPropertiesDialog::showEvent(QShowEvent* event)
+{
+ widget.treeView->resizeColumnToContents(0);
+ event->accept();
+}
+
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+void QPrintPropertiesDialog::addItemToOptions(QOptionTreeItem *parent, QList<const ppd_option_t*>& options, QList<const char*>& markedOptions) const
+{
+ for (int i = 0; i < parent->childItems.count(); ++i) {
+ QOptionTreeItem *itm = parent->childItems.at(i);
+ if (itm->type == QOptionTreeItem::Option) {
+ const ppd_option_t* opt = reinterpret_cast<const ppd_option_t*>(itm->ptr);
+ options << opt;
+ if (qstrcmp(opt->defchoice, opt->choices[itm->selected].choice) != 0) {
+ markedOptions << opt->keyword << opt->choices[itm->selected].choice;
+ }
+ } else {
+ addItemToOptions(itm, options, markedOptions);
+ }
+ }
+}
+#endif
+
+QPrintDialogPrivate::QPrintDialogPrivate()
+ : top(0), bottom(0), buttons(0), collapseButton(0)
+{
+}
+
+QPrintDialogPrivate::~QPrintDialogPrivate()
+{
+}
+
+void QPrintDialogPrivate::init()
+{
+ Q_Q(QPrintDialog);
+
+ top = new QUnixPrintWidget(0, q);
+ bottom = new QWidget(q);
+ options.setupUi(bottom);
+ options.color->setIconSize(QSize(32, 32));
+ options.color->setIcon(QIcon(QLatin1String(":/trolltech/dialogs/qprintdialog/images/status-color.png")));
+ options.grayscale->setIconSize(QSize(32, 32));
+ options.grayscale->setIcon(QIcon(QLatin1String(":/trolltech/dialogs/qprintdialog/images/status-gray-scale.png")));
+ top->d->setOptionsPane(this);
+
+ buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, q);
+ collapseButton = new QPushButton(QPrintDialog::tr("&Options >>"), buttons);
+ buttons->addButton(collapseButton, QDialogButtonBox::ResetRole);
+ bottom->setVisible(false);
+
+ QPushButton *printButton = buttons->button(QDialogButtonBox::Ok);
+ printButton->setText(QPrintDialog::tr("&Print"));
+ printButton->setDefault(true);
+
+ QVBoxLayout *lay = new QVBoxLayout(q);
+ q->setLayout(lay);
+ lay->addWidget(top);
+ lay->addWidget(bottom);
+ lay->addWidget(buttons);
+
+ QPrinter* p = q->printer();
+
+ applyPrinterProperties(p);
+
+#ifdef QT_NO_MESSAGEBOX
+ QObject::connect(buttons, SIGNAL(accepted()), q, SLOT(accept()));
+#else
+ QObject::connect(buttons, SIGNAL(accepted()), q, SLOT(_q_checkFields()));
+#endif
+ QObject::connect(buttons, SIGNAL(rejected()), q, SLOT(reject()));
+
+ QObject::connect(options.reverse, SIGNAL(toggled(bool)),
+ q, SLOT(_q_chbPrintLastFirstToggled(bool)));
+
+ QObject::connect(collapseButton, SIGNAL(released()), q, SLOT(_q_collapseOrExpandDialog()));
+}
+
+void QPrintDialogPrivate::applyPrinterProperties(QPrinter *p)
+{
+ if (p->colorMode() == QPrinter::Color)
+ options.color->setChecked(true);
+ else
+ options.grayscale->setChecked(true);
+
+ switch(p->duplex()) {
+ case QPrinter::DuplexNone:
+ options.noDuplex->setChecked(true); break;
+ case QPrinter::DuplexLongSide:
+ case QPrinter::DuplexAuto:
+ options.duplexLong->setChecked(true); break;
+ case QPrinter::DuplexShortSide:
+ options.duplexShort->setChecked(true); break;
+ }
+ options.copies->setValue(p->copyCount());
+ options.collate->setChecked(p->collateCopies());
+ options.reverse->setChecked(p->pageOrder() == QPrinter::LastPageFirst);
+ top->d->applyPrinterProperties(p);
+}
+
+void QPrintDialogPrivate::_q_chbPrintLastFirstToggled(bool checked)
+{
+ Q_Q(QPrintDialog);
+ if (checked)
+ q->printer()->setPageOrder(QPrinter::LastPageFirst);
+ else
+ q->printer()->setPageOrder(QPrinter::FirstPageFirst);
+}
+
+void QPrintDialogPrivate::_q_collapseOrExpandDialog()
+{
+ int collapseHeight = 0;
+ Q_Q(QPrintDialog);
+ QWidget *widgetToHide = bottom;
+ if (widgetToHide->isVisible()) {
+ collapseButton->setText(QPrintDialog::tr("&Options >>"));
+ collapseHeight = widgetToHide->y() + widgetToHide->height() - (top->y() + top->height());
+ }
+ else
+ collapseButton->setText(QPrintDialog::tr("&Options <<"));
+ widgetToHide->setVisible(! widgetToHide->isVisible());
+ if (! widgetToHide->isVisible()) { // make it shrink
+ q->layout()->activate();
+ q->resize( QSize(q->width(), q->height() - collapseHeight) );
+ }
+}
+
+#ifndef QT_NO_MESSAGEBOX
+void QPrintDialogPrivate::_q_checkFields()
+{
+ Q_Q(QPrintDialog);
+ if (top->d->checkFields())
+ q->accept();
+}
+#endif // QT_NO_MESSAGEBOX
+
+void QPrintDialogPrivate::setupPrinter()
+{
+ Q_Q(QPrintDialog);
+ QPrinter* p = q->printer();
+
+ if (options.duplex->isEnabled()) {
+ if (options.noDuplex->isChecked())
+ p->setDuplex(QPrinter::DuplexNone);
+ else if (options.duplexLong->isChecked())
+ p->setDuplex(QPrinter::DuplexLongSide);
+ else
+ p->setDuplex(QPrinter::DuplexShortSide);
+ }
+
+ p->setColorMode( options.color->isChecked() ? QPrinter::Color : QPrinter::GrayScale );
+
+ // print range
+ if (options.printAll->isChecked()) {
+ p->setPrintRange(QPrinter::AllPages);
+ p->setFromTo(0,0);
+ } else if (options.printSelection->isChecked()) {
+ p->setPrintRange(QPrinter::Selection);
+ p->setFromTo(0,0);
+ } else if (options.printCurrentPage->isChecked()) {
+ p->setPrintRange(QPrinter::CurrentPage);
+ p->setFromTo(0,0);
+ } else if (options.printRange->isChecked()) {
+ p->setPrintRange(QPrinter::PageRange);
+ p->setFromTo(options.from->value(), qMax(options.from->value(), options.to->value()));
+ }
+
+ // copies
+ p->setCopyCount(options.copies->value());
+ p->setCollateCopies(options.collate->isChecked());
+
+ top->d->setupPrinter();
+}
+
+void QPrintDialogPrivate::updateWidgets()
+{
+ Q_Q(QPrintDialog);
+ options.gbPrintRange->setVisible(q->isOptionEnabled(QPrintDialog::PrintPageRange) ||
+ q->isOptionEnabled(QPrintDialog::PrintSelection) ||
+ q->isOptionEnabled(QPrintDialog::PrintCurrentPage));
+
+ options.printRange->setEnabled(q->isOptionEnabled(QPrintDialog::PrintPageRange));
+ options.printSelection->setVisible(q->isOptionEnabled(QPrintDialog::PrintSelection));
+ options.printCurrentPage->setVisible(q->isOptionEnabled(QPrintDialog::PrintCurrentPage));
+ options.collate->setVisible(q->isOptionEnabled(QPrintDialog::PrintCollateCopies));
+
+ switch (q->printRange()) {
+ case QPrintDialog::AllPages:
+ options.printAll->setChecked(true);
+ break;
+ case QPrintDialog::Selection:
+ options.printSelection->setChecked(true);
+ break;
+ case QPrintDialog::PageRange:
+ options.printRange->setChecked(true);
+ break;
+ case QPrintDialog::CurrentPage:
+ if (q->isOptionEnabled(QPrintDialog::PrintCurrentPage))
+ options.printCurrentPage->setChecked(true);
+ break;
+ default:
+ break;
+ }
+ const int minPage = qMax(1, qMin(q->minPage() , q->maxPage()));
+ const int maxPage = qMax(1, q->maxPage() == INT_MAX ? 9999 : q->maxPage());
+
+ options.from->setMinimum(minPage);
+ options.to->setMinimum(minPage);
+ options.from->setMaximum(maxPage);
+ options.to->setMaximum(maxPage);
+
+ options.from->setValue(q->fromPage());
+ options.to->setValue(q->toPage());
+ top->d->updateWidget();
+}
+
+void QPrintDialogPrivate::setTabs(const QList<QWidget*> &tabWidgets)
+{
+ while(options.tabs->count() > 2)
+ delete options.tabs->widget(2);
+
+ QList<QWidget*>::ConstIterator iter = tabWidgets.begin();
+ while(iter != tabWidgets.constEnd()) {
+ QWidget *tab = *iter;
+ options.tabs->addTab(tab, tab->windowTitle());
+ ++iter;
+ }
+}
+
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+void QPrintDialogPrivate::selectPrinter(QCUPSSupport *cups)
+{
+ options.duplex->setEnabled(cups && cups->ppdOption("Duplex"));
+}
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+
+QPrintDialog::QPrintDialog(QPrinter *printer, QWidget *parent)
+ : QAbstractPrintDialog(*(new QPrintDialogPrivate), printer, parent)
+{
+ Q_D(QPrintDialog);
+ d->init();
+}
+
+/*!
+ Constructs a print dialog with the given \a parent.
+*/
+QPrintDialog::QPrintDialog(QWidget *parent)
+ : QAbstractPrintDialog(*(new QPrintDialogPrivate), 0, parent)
+{
+ Q_D(QPrintDialog);
+ d->init();
+}
+
+QPrintDialog::~QPrintDialog()
+{
+}
+
+void QPrintDialog::setVisible(bool visible)
+{
+ Q_D(QPrintDialog);
+
+ if (visible)
+ d->updateWidgets();
+
+ QAbstractPrintDialog::setVisible(visible);
+}
+
+int QPrintDialog::exec()
+{
+ return QDialog::exec();
+}
+
+void QPrintDialog::accept()
+{
+ Q_D(QPrintDialog);
+ d->setupPrinter();
+ QDialog::accept();
+}
+
+#ifdef QT3_SUPPORT
+QPrinter *QPrintDialog::printer() const
+{
+ Q_D(const QPrintDialog);
+ return d->printer;
+}
+
+void QPrintDialog::setPrinter(QPrinter *printer, bool pickupSettings)
+{
+ if (!printer)
+ return;
+
+ Q_D(QPrintDialog);
+ d->printer = printer;
+
+ if (pickupSettings)
+ d->applyPrinterProperties(printer);
+}
+
+void QPrintDialog::addButton(QPushButton *button)
+{
+ Q_D(QPrintDialog);
+ d->buttons->addButton(button, QDialogButtonBox::HelpRole);
+}
+#endif // QT3_SUPPORT
+
+#if defined (Q_OS_UNIX)
+
+/*! \internal
+*/
+QUnixPrintWidgetPrivate::QUnixPrintWidgetPrivate(QUnixPrintWidget *p)
+ : parent(p), propertiesDialog(0), printer(0), optionsPane(0), filePrintersAdded(false)
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ , cups(0), cupsPrinterCount(0), cupsPrinters(0), cupsPPD(0)
+#endif
+{
+ q = 0;
+ if (parent)
+ q = qobject_cast<QAbstractPrintDialog*> (parent->parent());
+
+ widget.setupUi(parent);
+
+ int currentPrinterIndex = 0;
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ cups = new QCUPSSupport;
+ if (QCUPSSupport::isAvailable()) {
+ cupsPPD = cups->currentPPD();
+ cupsPrinterCount = cups->availablePrintersCount();
+ cupsPrinters = cups->availablePrinters();
+
+ for (int i = 0; i < cupsPrinterCount; ++i) {
+ QString printerName(QString::fromLocal8Bit(cupsPrinters[i].name));
+ if (cupsPrinters[i].instance)
+ printerName += QLatin1Char('/') + QString::fromLocal8Bit(cupsPrinters[i].instance);
+
+ widget.printers->addItem(printerName);
+ if (cupsPrinters[i].is_default)
+ widget.printers->setCurrentIndex(i);
+ }
+ // the model depends on valid ppd. so before enabling the
+ // properties button we make sure the ppd is in fact valid.
+ if (cupsPrinterCount && cups->currentPPD()) {
+ widget.properties->setEnabled(true);
+ }
+ currentPrinterIndex = cups->currentPrinterIndex();
+ } else {
+#endif
+ currentPrinterIndex = qt_getLprPrinters(lprPrinters);
+ // populating printer combo
+ QList<QPrinterDescription>::const_iterator i = lprPrinters.constBegin();
+ for(; i != lprPrinters.constEnd(); ++i)
+ widget.printers->addItem((*i).name);
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ }
+#endif
+
+#if !defined(QT_NO_FILESYSTEMMODEL) && !defined(QT_NO_COMPLETER)
+ QFileSystemModel *fsm = new QFileSystemModel(widget.filename);
+ fsm->setRootPath(QDir::homePath());
+ widget.filename->setCompleter(new QCompleter(fsm, widget.filename));
+#endif
+ _q_printerChanged(currentPrinterIndex);
+
+ QObject::connect(widget.printers, SIGNAL(currentIndexChanged(int)),
+ parent, SLOT(_q_printerChanged(int)));
+ QObject::connect(widget.fileBrowser, SIGNAL(clicked()), parent, SLOT(_q_btnBrowseClicked()));
+ QObject::connect(widget.properties, SIGNAL(clicked()), parent, SLOT(_q_btnPropertiesClicked()));
+
+ // disable features that QPrinter does not yet support.
+ widget.preview->setVisible(false);
+}
+
+void QUnixPrintWidgetPrivate::updateWidget()
+{
+ const bool printToFile = q == 0 || q->isOptionEnabled(QPrintDialog::PrintToFile);
+ if (printToFile && !filePrintersAdded) {
+ if (widget.printers->count())
+ widget.printers->insertSeparator(widget.printers->count());
+ widget.printers->addItem(QPrintDialog::tr("Print to File (PDF)"));
+ filePrintersAdded = true;
+ }
+ if (!printToFile && filePrintersAdded) {
+ widget.printers->removeItem(widget.printers->count()-1);
+ widget.printers->removeItem(widget.printers->count()-1);
+ if (widget.printers->count())
+ widget.printers->removeItem(widget.printers->count()-1); // remove separator
+ filePrintersAdded = false;
+ }
+ if (printer && filePrintersAdded && (printer->outputFormat() != QPrinter::NativeFormat
+ || printer->printerName().isEmpty()))
+ {
+ if (printer->outputFormat() == QPrinter::PdfFormat)
+ widget.printers->setCurrentIndex(widget.printers->count() - 1);
+ widget.filename->setEnabled(true);
+ widget.lOutput->setEnabled(true);
+ }
+
+ widget.filename->setVisible(printToFile);
+ widget.lOutput->setVisible(printToFile);
+ widget.fileBrowser->setVisible(printToFile);
+
+ widget.properties->setVisible(q->isOptionEnabled(QAbstractPrintDialog::PrintShowPageSize));
+}
+
+QUnixPrintWidgetPrivate::~QUnixPrintWidgetPrivate()
+{
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ delete cups;
+#endif
+}
+
+void QUnixPrintWidgetPrivate::_q_printerChanged(int index)
+{
+ if (index < 0)
+ return;
+ const int printerCount = widget.printers->count();
+ widget.filename->setEnabled(false);
+ widget.lOutput->setEnabled(false);
+
+ if (filePrintersAdded) {
+ Q_ASSERT(index != printerCount - 3); // separator
+ if (index == printerCount - 1) { // PDF
+ widget.location->setText(QPrintDialog::tr("Local file"));
+ widget.type->setText(QPrintDialog::tr("Write PDF file"));
+ widget.properties->setEnabled(true);
+ widget.filename->setEnabled(true);
+ QString filename = widget.filename->text();
+ QString suffix = QFileInfo(filename).suffix();
+ widget.filename->setText(filename);
+ widget.lOutput->setEnabled(true);
+ if (propertiesDialog)
+ propertiesDialog->selectPdfPsPrinter(printer);
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ if (optionsPane)
+ optionsPane->selectPrinter(0);
+#endif
+ return;
+ }
+ }
+
+ widget.location->setText(QString());
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ if (QCUPSSupport::isAvailable()) {
+ cups->setCurrentPrinter(index);
+
+ const cups_option_t *opt = cups->printerOption(QString::fromLatin1("printer-location"));
+ QString location;
+ if (opt)
+ location = QString::fromLocal8Bit(opt->value);
+ widget.location->setText(location);
+
+ cupsPPD = cups->currentPPD();
+ // set printer type line
+ QString type;
+ if (cupsPPD)
+ type = QString::fromLocal8Bit(cupsPPD->manufacturer) + QLatin1String(" - ") + QString::fromLocal8Bit(cupsPPD->modelname);
+ widget.type->setText(type);
+ if (propertiesDialog)
+ propertiesDialog->selectPrinter();
+ if (optionsPane)
+ optionsPane->selectPrinter(cups);
+ } else {
+ if (optionsPane)
+ optionsPane->selectPrinter(0);
+#endif
+ if (lprPrinters.count() > 0) {
+ QString type = lprPrinters.at(index).name + QLatin1Char('@') + lprPrinters.at(index).host;
+ if (!lprPrinters.at(index).comment.isEmpty())
+ type += QLatin1String(", ") + lprPrinters.at(index).comment;
+ widget.type->setText(type);
+ if (propertiesDialog)
+ propertiesDialog->selectPrinter();
+ }
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ }
+#endif
+}
+
+void QUnixPrintWidgetPrivate::setOptionsPane(QPrintDialogPrivate *pane)
+{
+ optionsPane = pane;
+ if (optionsPane)
+ _q_printerChanged(widget.printers->currentIndex());
+}
+
+void QUnixPrintWidgetPrivate::_q_btnBrowseClicked()
+{
+ QString filename = widget.filename->text();
+#ifndef QT_NO_FILEDIALOG
+ filename = QFileDialog::getSaveFileName(parent, QPrintDialog::tr("Print To File ..."), filename,
+ QString(), 0, QFileDialog::DontConfirmOverwrite);
+#else
+ filename.clear();
+#endif
+ if (!filename.isEmpty()) {
+ widget.filename->setText(filename);
+ widget.printers->setCurrentIndex(widget.printers->count() - 1); // the pdf one
+ }
+}
+
+void QUnixPrintWidgetPrivate::applyPrinterProperties(QPrinter *p)
+{
+ if (p == 0)
+ return;
+ printer = p;
+ if (p->outputFileName().isEmpty()) {
+ QString home = QString::fromLocal8Bit(qgetenv("HOME").constData());
+ QString cur = QDir::currentPath();
+ if (home.at(home.length()-1) != QLatin1Char('/'))
+ home += QLatin1Char('/');
+ if (cur.at(cur.length()-1) != QLatin1Char('/'))
+ cur += QLatin1Char('/');
+ if (cur.left(home.length()) != home)
+ cur = home;
+#ifdef Q_WS_X11
+ if (p->docName().isEmpty()) {
+ cur += QLatin1String("print.pdf");
+ } else {
+ QRegExp re(QString::fromLatin1("(.*)\\.\\S+"));
+ if (re.exactMatch(p->docName()))
+ cur += re.cap(1);
+ else
+ cur += p->docName();
+ cur += QLatin1String(".pdf");
+ }
+#endif
+ widget.filename->setText(cur);
+ }
+ else
+ widget.filename->setText( p->outputFileName() );
+ QString printer = p->printerName();
+ if (!printer.isEmpty()) {
+ for (int i = 0; i < widget.printers->count(); ++i) {
+ if (widget.printers->itemText(i) == printer) {
+ widget.printers->setCurrentIndex(i);
+ break;
+ }
+ }
+ }
+ // PDF and PS printers are not added to the dialog yet, we'll handle those cases in QUnixPrintWidgetPrivate::updateWidget
+
+ if (propertiesDialog)
+ propertiesDialog->applyPrinterProperties(p);
+}
+
+#ifndef QT_NO_MESSAGEBOX
+bool QUnixPrintWidgetPrivate::checkFields()
+{
+ if (widget.filename->isEnabled()) {
+ QString file = widget.filename->text();
+ QFile f(file);
+ QFileInfo fi(f);
+ bool exists = fi.exists();
+ bool opened = false;
+ if (exists && fi.isDir()) {
+ QMessageBox::warning(q, q->windowTitle(),
+ QPrintDialog::tr("%1 is a directory.\nPlease choose a different file name.").arg(file));
+ return false;
+ } else if ((exists && !fi.isWritable()) || !(opened = f.open(QFile::Append))) {
+ QMessageBox::warning(q, q->windowTitle(),
+ QPrintDialog::tr("File %1 is not writable.\nPlease choose a different file name.").arg(file));
+ return false;
+ } else if (exists) {
+ int ret = QMessageBox::question(q, q->windowTitle(),
+ QPrintDialog::tr("%1 already exists.\nDo you want to overwrite it?").arg(file),
+ QMessageBox::Yes|QMessageBox::No, QMessageBox::No);
+ if (ret == QMessageBox::No)
+ return false;
+ }
+ if (opened) {
+ f.close();
+ if (!exists)
+ f.remove();
+ }
+ }
+
+ // Every test passed. Accept the dialog.
+ return true;
+}
+#endif // QT_NO_MESSAGEBOX
+
+void QUnixPrintWidgetPrivate::_q_btnPropertiesClicked()
+{
+ if (!propertiesDialog) {
+ propertiesDialog = new QPrintPropertiesDialog(q);
+ propertiesDialog->setResult(QDialog::Rejected);
+ }
+
+ if (propertiesDialog->result() == QDialog::Rejected) {
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ propertiesDialog->setCups(cups);
+#endif
+ propertiesDialog->applyPrinterProperties(q->printer());
+
+ if (q->isOptionEnabled(QPrintDialog::PrintToFile)
+ && (widget.printers->currentIndex() == widget.printers->count() - 1)) // PDF
+ propertiesDialog->selectPdfPsPrinter(q->printer());
+ else
+ propertiesDialog->selectPrinter();
+ }
+ propertiesDialog->exec();
+}
+
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+void QUnixPrintWidgetPrivate::setCupsProperties()
+{
+ if (cups && QCUPSSupport::isAvailable() && cups->pageSizes()) {
+ QPrintEngine *engine = printer->printEngine();
+ const ppd_option_t* pageSizes = cups->pageSizes();
+ QByteArray cupsPageSize;
+ for (int i = 0; i < pageSizes->num_choices; ++i) {
+ if (static_cast<int>(pageSizes->choices[i].marked) == 1)
+ cupsPageSize = pageSizes->choices[i].choice;
+ }
+ engine->setProperty(PPK_CupsStringPageSize, QString::fromLatin1(cupsPageSize));
+ engine->setProperty(PPK_CupsOptions, cups->options());
+
+ QRect pageRect = cups->pageRect(cupsPageSize);
+ engine->setProperty(PPK_CupsPageRect, pageRect);
+
+ QRect paperRect = cups->paperRect(cupsPageSize);
+ engine->setProperty(PPK_CupsPaperRect, paperRect);
+
+ for (int ps = 0; ps < QPrinter::NPaperSize; ++ps) {
+ QPdf::PaperSize size = QPdf::paperSize(QPrinter::PaperSize(ps));
+ if (size.width == paperRect.width() && size.height == paperRect.height())
+ printer->setPaperSize(static_cast<QPrinter::PaperSize>(ps));
+ }
+ }
+}
+#endif
+
+void QUnixPrintWidgetPrivate::setupPrinter()
+{
+ const int printerCount = widget.printers->count();
+ const int index = widget.printers->currentIndex();
+
+ if (filePrintersAdded && index == printerCount - 1) { // PDF
+ printer->setPrinterName(QString());
+ Q_ASSERT(index != printerCount - 3); // separator
+ printer->setOutputFormat(QPrinter::PdfFormat);
+ QString path = widget.filename->text();
+ if (QDir::isRelativePath(path))
+ path = QDir::homePath() + QDir::separator() + path;
+ printer->setOutputFileName(path);
+ }
+ else {
+ printer->setPrinterName(widget.printers->currentText());
+ printer->setOutputFileName(QString());
+ }
+
+ if (propertiesDialog && propertiesDialog->result() == QDialog::Accepted)
+ propertiesDialog->setupPrinter();
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+ if (!propertiesDialog)
+ setCupsProperties();
+#endif
+}
+
+
+/*! \internal
+*/
+QUnixPrintWidget::QUnixPrintWidget(QPrinter *printer, QWidget *parent)
+ : QWidget(parent), d(new QUnixPrintWidgetPrivate(this))
+{
+ d->applyPrinterProperties(printer);
+}
+
+/*! \internal
+*/
+QUnixPrintWidget::~QUnixPrintWidget()
+{
+ delete d;
+}
+
+/*! \internal
+
+ Updates the printer with the states held in the QUnixPrintWidget.
+*/
+void QUnixPrintWidget::updatePrinter()
+{
+ d->setupPrinter();
+}
+
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY)
+
+QPPDOptionsModel::QPPDOptionsModel(QCUPSSupport *c, QObject *parent)
+ : QAbstractItemModel(parent), rootItem(0), cups(c), ppd(c->currentPPD())
+{
+ parseItems();
+}
+
+QPPDOptionsModel::~QPPDOptionsModel()
+{
+}
+
+int QPPDOptionsModel::columnCount(const QModelIndex&) const
+{
+ return 2;
+}
+
+int QPPDOptionsModel::rowCount(const QModelIndex& parent) const
+{
+ QOptionTreeItem* itm;
+ if (!parent.isValid())
+ itm = rootItem;
+ else
+ itm = reinterpret_cast<QOptionTreeItem*>(parent.internalPointer());
+
+ if (itm->type == QOptionTreeItem::Option)
+ return 0;
+
+ return itm->childItems.count();
+}
+
+QVariant QPPDOptionsModel::data(const QModelIndex& index, int role) const
+{
+ switch(role) {
+ case Qt::FontRole: {
+ QOptionTreeItem* itm = reinterpret_cast<QOptionTreeItem*>(index.internalPointer());
+ if (itm && itm->type == QOptionTreeItem::Group){
+ QFont font = QApplication::font();
+ font.setBold(true);
+ return QVariant(font);
+ }
+ return QVariant();
+ }
+ break;
+
+ case Qt::DisplayRole: {
+ QOptionTreeItem* itm;
+ if (!index.isValid())
+ itm = rootItem;
+ else
+ itm = reinterpret_cast<QOptionTreeItem*>(index.internalPointer());
+
+ if (index.column() == 0)
+ return cups->unicodeString(itm->description);
+ else if (itm->type == QOptionTreeItem::Option && itm->selected > -1)
+ return cups->unicodeString(itm->selDescription);
+ else
+ return QVariant();
+ }
+ break;
+
+ default:
+ return QVariant();
+ }
+ if (role != Qt::DisplayRole)
+ return QVariant();
+}
+
+QModelIndex QPPDOptionsModel::index(int row, int column, const QModelIndex& parent) const
+{
+ QOptionTreeItem* itm;
+ if (!parent.isValid())
+ itm = rootItem;
+ else
+ itm = reinterpret_cast<QOptionTreeItem*>(parent.internalPointer());
+
+ return createIndex(row, column, itm->childItems.at(row));
+}
+
+
+QModelIndex QPPDOptionsModel::parent(const QModelIndex& index) const
+{
+ if (!index.isValid())
+ return QModelIndex();
+
+ QOptionTreeItem* itm = reinterpret_cast<QOptionTreeItem*>(index.internalPointer());
+
+ if (itm->parentItem && itm->parentItem != rootItem)
+ return createIndex(itm->parentItem->index, 0, itm->parentItem);
+ else
+ return QModelIndex();
+}
+
+Qt::ItemFlags QPPDOptionsModel::flags(const QModelIndex& index) const
+{
+ if (!index.isValid() || reinterpret_cast<QOptionTreeItem*>(index.internalPointer())->type == QOptionTreeItem::Group)
+ return Qt::ItemIsEnabled;
+
+ if (index.column() == 1)
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
+
+ return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
+}
+
+void QPPDOptionsModel::parseItems()
+{
+ emit layoutAboutToBeChanged();
+ ppd = cups->currentPPD();
+ delete rootItem;
+ rootItem = new QOptionTreeItem(QOptionTreeItem::Root, 0, ppd, "Root Item", 0);
+ parseGroups(rootItem);
+ emit layoutChanged();
+}
+
+void QPPDOptionsModel::parseGroups(QOptionTreeItem* parent)
+{
+ if (parent->type == QOptionTreeItem::Root) {
+
+ const ppd_file_t* ppdFile = reinterpret_cast<const ppd_file_t*>(parent->ptr);
+
+ if (ppdFile) {
+ for (int i = 0; i < ppdFile->num_groups; ++i) {
+ QOptionTreeItem* group = new QOptionTreeItem(QOptionTreeItem::Group, i, &ppdFile->groups[i], ppdFile->groups[i].text, parent);
+ parent->childItems.append(group);
+ parseGroups(group); // parse possible subgroups
+ parseOptions(group); // parse options
+ }
+ }
+ } else if (parent->type == QOptionTreeItem::Group) {
+
+ const ppd_group_t* group = reinterpret_cast<const ppd_group_t*>(parent->ptr);
+
+ if (group) {
+ for (int i = 0; i < group->num_subgroups; ++i) {
+ QOptionTreeItem* subgroup = new QOptionTreeItem(QOptionTreeItem::Group, i, &group->subgroups[i], group->subgroups[i].text, parent);
+ parent->childItems.append(subgroup);
+ parseGroups(subgroup); // parse possible subgroups
+ parseOptions(subgroup); // parse options
+ }
+ }
+ }
+}
+
+void QPPDOptionsModel::parseOptions(QOptionTreeItem* parent)
+{
+ const ppd_group_t* group = reinterpret_cast<const ppd_group_t*>(parent->ptr);
+ for (int i = 0; i < group->num_options; ++i) {
+ QOptionTreeItem* opt = new QOptionTreeItem(QOptionTreeItem::Option, i, &group->options[i], group->options[i].text, parent);
+ parent->childItems.append(opt);
+ parseChoices(opt);
+ }
+}
+
+void QPPDOptionsModel::parseChoices(QOptionTreeItem* parent)
+{
+ const ppd_option_t* option = reinterpret_cast<const ppd_option_t*>(parent->ptr);
+ bool marked = false;
+ for (int i = 0; i < option->num_choices; ++i) {
+ QOptionTreeItem* choice = new QOptionTreeItem(QOptionTreeItem::Choice, i, &option->choices[i], option->choices[i].text, parent);
+ if (static_cast<int>(option->choices[i].marked) == 1) {
+ parent->selected = i;
+ parent->selDescription = option->choices[i].text;
+ marked = true;
+ } else if (!marked && qstrcmp(option->choices[i].choice, option->defchoice) == 0) {
+ parent->selected = i;
+ parent->selDescription = option->choices[i].text;
+ }
+ parent->childItems.append(choice);
+ }
+}
+
+QVariant QPPDOptionsModel::headerData(int section, Qt::Orientation, int role) const
+{
+ if (role != Qt::DisplayRole)
+ return QVariant();
+
+ switch(section){
+ case 0:
+ return QVariant(QApplication::translate("QPPDOptionsModel", "Name"));
+ case 1:
+ return QVariant(QApplication::translate("QPPDOptionsModel", "Value"));
+ default:
+ return QVariant();
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+QWidget* QPPDOptionsEditor::createEditor(QWidget* parent, const QStyleOptionViewItem&, const QModelIndex& index) const
+{
+ if (index.column() == 1 && reinterpret_cast<QOptionTreeItem*>(index.internalPointer())->type == QOptionTreeItem::Option)
+ return new QComboBox(parent);
+ else
+ return 0;
+}
+
+void QPPDOptionsEditor::setEditorData(QWidget* editor, const QModelIndex& index) const
+{
+ if (index.column() != 1)
+ return;
+
+ QComboBox* cb = static_cast<QComboBox*>(editor);
+ QOptionTreeItem* itm = reinterpret_cast<QOptionTreeItem*>(index.internalPointer());
+
+ if (itm->selected == -1)
+ cb->addItem(QString());
+
+ for (int i = 0; i < itm->childItems.count(); ++i)
+ cb->addItem(QString::fromLocal8Bit(itm->childItems.at(i)->description));
+
+ if (itm->selected > -1)
+ cb->setCurrentIndex(itm->selected);
+
+ connect(cb, SIGNAL(currentIndexChanged(int)), this, SLOT(cbChanged(int)));
+}
+
+void QPPDOptionsEditor::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
+{
+ QComboBox* cb = static_cast<QComboBox*>(editor);
+ QOptionTreeItem* itm = reinterpret_cast<QOptionTreeItem*>(index.internalPointer());
+
+ if (itm->selected == cb->currentIndex())
+ return;
+
+ const ppd_option_t* opt = reinterpret_cast<const ppd_option_t*>(itm->ptr);
+ QPPDOptionsModel* m = static_cast<QPPDOptionsModel*>(model);
+
+ if (m->cups->markOption(opt->keyword, opt->choices[cb->currentIndex()].choice) == 0) {
+ itm->selected = cb->currentIndex();
+ itm->selDescription = reinterpret_cast<const ppd_option_t*>(itm->ptr)->choices[itm->selected].text;
+ }
+}
+
+void QPPDOptionsEditor::cbChanged(int)
+{
+/*
+ emit commitData(static_cast<QWidget*>(sender()));
+*/
+}
+
+#endif
+
+QT_END_NAMESPACE
+
+#include "moc_qprintdialog.cpp"
+#include "qprintdialog_unix.moc"
+#include "qrc_qprintdialog.cpp"
+
+#endif // QT_NO_PRINTDIALOG
+
diff --git a/src/gui/dialogs/qprintdialog_win.cpp b/src/widgets/dialogs/qprintdialog_win.cpp
index 4f6866b2df..4f6866b2df 100644
--- a/src/gui/dialogs/qprintdialog_win.cpp
+++ b/src/widgets/dialogs/qprintdialog_win.cpp
diff --git a/src/widgets/dialogs/qprintpreviewdialog.cpp b/src/widgets/dialogs/qprintpreviewdialog.cpp
new file mode 100644
index 0000000000..a83944374b
--- /dev/null
+++ b/src/widgets/dialogs/qprintpreviewdialog.cpp
@@ -0,0 +1,803 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qprintpreviewdialog.h"
+#include "qprintpreviewwidget.h"
+#include <private/qprinter_p.h>
+#include "private/qdialog_p.h"
+#include "qprintdialog.h"
+
+#include <QtWidgets/qaction.h>
+#include <QtWidgets/qboxlayout.h>
+#include <QtWidgets/qcombobox.h>
+#include <QtWidgets/qlabel.h>
+#include <QtWidgets/qlineedit.h>
+#include <QtWidgets/qpagesetupdialog.h>
+#include <QtGui/qprinter.h>
+#include <QtWidgets/qstyle.h>
+#include <QtWidgets/qtoolbutton.h>
+#include <QtGui/qvalidator.h>
+#include <QtWidgets/qfiledialog.h>
+#include <QtWidgets/qmainwindow.h>
+#include <QtWidgets/qtoolbar.h>
+#include <QtWidgets/qformlayout.h>
+#include <QtCore/QCoreApplication>
+
+#include <math.h>
+
+#ifndef QT_NO_PRINTPREVIEWDIALOG
+
+QT_BEGIN_NAMESPACE
+
+namespace {
+class QPrintPreviewMainWindow : public QMainWindow
+{
+public:
+ QPrintPreviewMainWindow(QWidget *parent) : QMainWindow(parent) {}
+ QMenu *createPopupMenu() { return 0; }
+};
+
+class ZoomFactorValidator : public QDoubleValidator
+{
+public:
+ ZoomFactorValidator(QObject* parent)
+ : QDoubleValidator(parent) {}
+ ZoomFactorValidator(qreal bottom, qreal top, int decimals, QObject *parent)
+ : QDoubleValidator(bottom, top, decimals, parent) {}
+
+ State validate(QString &input, int &pos) const
+ {
+ bool replacePercent = false;
+ if (input.endsWith(QLatin1Char('%'))) {
+ input = input.left(input.length() - 1);
+ replacePercent = true;
+ }
+ State state = QDoubleValidator::validate(input, pos);
+ if (replacePercent)
+ input += QLatin1Char('%');
+ const int num_size = 4;
+ if (state == Intermediate) {
+ int i = input.indexOf(QLocale::system().decimalPoint());
+ if ((i == -1 && input.size() > num_size)
+ || (i != -1 && i > num_size))
+ return Invalid;
+ }
+ return state;
+ }
+};
+
+class LineEdit : public QLineEdit
+{
+ Q_OBJECT
+public:
+ LineEdit(QWidget* parent = 0)
+ : QLineEdit(parent)
+ {
+ setContextMenuPolicy(Qt::NoContextMenu);
+ connect(this, SIGNAL(returnPressed()), SLOT(handleReturnPressed()));
+ }
+
+protected:
+ void focusInEvent(QFocusEvent *e)
+ {
+ origText = text();
+ QLineEdit::focusInEvent(e);
+ }
+
+ void focusOutEvent(QFocusEvent *e)
+ {
+ if (isModified() && !hasAcceptableInput())
+ setText(origText);
+ QLineEdit::focusOutEvent(e);
+ }
+
+private slots:
+ void handleReturnPressed()
+ {
+ origText = text();
+ }
+
+private:
+ QString origText;
+};
+} // anonymous namespace
+
+class QPrintPreviewDialogPrivate : public QDialogPrivate
+{
+ Q_DECLARE_PUBLIC(QPrintPreviewDialog)
+public:
+ QPrintPreviewDialogPrivate()
+ : printDialog(0), ownPrinter(false),
+ initialized(false) {}
+
+ // private slots
+ void _q_fit(QAction *action);
+ void _q_zoomIn();
+ void _q_zoomOut();
+ void _q_navigate(QAction *action);
+ void _q_setMode(QAction *action);
+ void _q_pageNumEdited();
+ void _q_print();
+ void _q_pageSetup();
+ void _q_previewChanged();
+ void _q_zoomFactorChanged();
+
+ void init(QPrinter *printer = 0);
+ void populateScene();
+ void layoutPages();
+ void setupActions();
+ void updateNavActions();
+ void setFitting(bool on);
+ bool isFitting();
+ void updatePageNumLabel();
+ void updateZoomFactor();
+
+ QPrintDialog *printDialog;
+ QPrintPreviewWidget *preview;
+ QPrinter *printer;
+ bool ownPrinter;
+ bool initialized;
+
+ // widgets:
+ QLineEdit *pageNumEdit;
+ QLabel *pageNumLabel;
+ QComboBox *zoomFactor;
+
+ // actions:
+ QActionGroup* navGroup;
+ QAction *nextPageAction;
+ QAction *prevPageAction;
+ QAction *firstPageAction;
+ QAction *lastPageAction;
+
+ QActionGroup* fitGroup;
+ QAction *fitWidthAction;
+ QAction *fitPageAction;
+
+ QActionGroup* zoomGroup;
+ QAction *zoomInAction;
+ QAction *zoomOutAction;
+
+ QActionGroup* orientationGroup;
+ QAction *portraitAction;
+ QAction *landscapeAction;
+
+ QActionGroup* modeGroup;
+ QAction *singleModeAction;
+ QAction *facingModeAction;
+ QAction *overviewModeAction;
+
+ QActionGroup *printerGroup;
+ QAction *printAction;
+ QAction *pageSetupAction;
+#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
+ QAction *closeAction;
+#endif
+
+ QPointer<QObject> receiverToDisconnectOnClose;
+ QByteArray memberToDisconnectOnClose;
+};
+
+void QPrintPreviewDialogPrivate::init(QPrinter *_printer)
+{
+ Q_Q(QPrintPreviewDialog);
+
+ if (_printer) {
+ preview = new QPrintPreviewWidget(_printer, q);
+ printer = _printer;
+ } else {
+ ownPrinter = true;
+ printer = new QPrinter;
+ preview = new QPrintPreviewWidget(printer, q);
+ }
+ QObject::connect(preview, SIGNAL(paintRequested(QPrinter*)), q, SIGNAL(paintRequested(QPrinter*)));
+ QObject::connect(preview, SIGNAL(previewChanged()), q, SLOT(_q_previewChanged()));
+ setupActions();
+
+ pageNumEdit = new LineEdit;
+ pageNumEdit->setAlignment(Qt::AlignRight);
+ pageNumEdit->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
+ pageNumLabel = new QLabel;
+ QObject::connect(pageNumEdit, SIGNAL(editingFinished()), q, SLOT(_q_pageNumEdited()));
+
+ zoomFactor = new QComboBox;
+ zoomFactor->setEditable(true);
+ zoomFactor->setMinimumContentsLength(7);
+ zoomFactor->setInsertPolicy(QComboBox::NoInsert);
+ LineEdit *zoomEditor = new LineEdit;
+ zoomEditor->setValidator(new ZoomFactorValidator(1, 1000, 1, zoomEditor));
+ zoomFactor->setLineEdit(zoomEditor);
+ static const short factorsX2[] = { 25, 50, 100, 200, 250, 300, 400, 800, 1600 };
+ for (int i = 0; i < int(sizeof(factorsX2) / sizeof(factorsX2[0])); ++i)
+ zoomFactor->addItem(QPrintPreviewDialog::tr("%1%").arg(factorsX2[i] / 2.0));
+ QObject::connect(zoomFactor->lineEdit(), SIGNAL(editingFinished()),
+ q, SLOT(_q_zoomFactorChanged()));
+ QObject::connect(zoomFactor, SIGNAL(currentIndexChanged(int)),
+ q, SLOT(_q_zoomFactorChanged()));
+
+ QPrintPreviewMainWindow *mw = new QPrintPreviewMainWindow(q);
+ QToolBar *toolbar = new QToolBar(mw);
+ toolbar->addAction(fitWidthAction);
+ toolbar->addAction(fitPageAction);
+ toolbar->addSeparator();
+ toolbar->addWidget(zoomFactor);
+ toolbar->addAction(zoomOutAction);
+ toolbar->addAction(zoomInAction);
+ toolbar->addSeparator();
+ toolbar->addAction(portraitAction);
+ toolbar->addAction(landscapeAction);
+ toolbar->addSeparator();
+ toolbar->addAction(firstPageAction);
+ toolbar->addAction(prevPageAction);
+
+ // this is to ensure the label text and the editor text are
+ // aligned in all styles - the extra QVBoxLayout is a workaround
+ // for bug in QFormLayout
+ QWidget *pageEdit = new QWidget(toolbar);
+ QVBoxLayout *vboxLayout = new QVBoxLayout;
+ vboxLayout->setContentsMargins(0, 0, 0, 0);
+#ifdef Q_WS_MAC
+ // We query the widgets about their size and then we fix the size.
+ // This should do the trick for the laying out part...
+ QSize pageNumEditSize, pageNumLabelSize;
+ pageNumEditSize = pageNumEdit->minimumSizeHint();
+ pageNumLabelSize = pageNumLabel->minimumSizeHint();
+ pageNumEdit->resize(pageNumEditSize);
+ pageNumLabel->resize(pageNumLabelSize);
+#endif
+ QFormLayout *formLayout = new QFormLayout;
+#ifdef Q_WS_MAC
+ // We have to change the growth policy in Mac.
+ formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
+#endif
+ formLayout->setWidget(0, QFormLayout::LabelRole, pageNumEdit);
+ formLayout->setWidget(0, QFormLayout::FieldRole, pageNumLabel);
+ vboxLayout->addLayout(formLayout);
+ vboxLayout->setAlignment(Qt::AlignVCenter);
+ pageEdit->setLayout(vboxLayout);
+ toolbar->addWidget(pageEdit);
+
+ toolbar->addAction(nextPageAction);
+ toolbar->addAction(lastPageAction);
+ toolbar->addSeparator();
+ toolbar->addAction(singleModeAction);
+ toolbar->addAction(facingModeAction);
+ toolbar->addAction(overviewModeAction);
+ toolbar->addSeparator();
+ toolbar->addAction(pageSetupAction);
+ toolbar->addAction(printAction);
+#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
+ toolbar->addAction(closeAction);
+#endif
+
+ // Cannot use the actions' triggered signal here, since it doesn't autorepeat
+ QToolButton *zoomInButton = static_cast<QToolButton *>(toolbar->widgetForAction(zoomInAction));
+ QToolButton *zoomOutButton = static_cast<QToolButton *>(toolbar->widgetForAction(zoomOutAction));
+ zoomInButton->setAutoRepeat(true);
+ zoomInButton->setAutoRepeatInterval(200);
+ zoomInButton->setAutoRepeatDelay(200);
+ zoomOutButton->setAutoRepeat(true);
+ zoomOutButton->setAutoRepeatInterval(200);
+ zoomOutButton->setAutoRepeatDelay(200);
+ QObject::connect(zoomInButton, SIGNAL(clicked()), q, SLOT(_q_zoomIn()));
+ QObject::connect(zoomOutButton, SIGNAL(clicked()), q, SLOT(_q_zoomOut()));
+
+ mw->addToolBar(toolbar);
+ mw->setCentralWidget(preview);
+ // QMainWindows are always created as top levels, force it to be a
+ // plain widget
+ mw->setParent(q, Qt::Widget);
+
+ QVBoxLayout *topLayout = new QVBoxLayout;
+ topLayout->addWidget(mw);
+ topLayout->setMargin(0);
+ q->setLayout(topLayout);
+
+ QString caption = QCoreApplication::translate("QPrintPreviewDialog", "Print Preview");
+ if (!printer->docName().isEmpty())
+ caption += QString::fromLatin1(": ") + printer->docName();
+ q->setWindowTitle(caption);
+
+ if (!printer->isValid()
+#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
+ || printer->outputFormat() != QPrinter::NativeFormat
+#endif
+ )
+ pageSetupAction->setEnabled(false);
+ preview->setFocus();
+}
+
+static inline void qt_setupActionIcon(QAction *action, const QLatin1String &name)
+{
+ QLatin1String imagePrefix(":/trolltech/dialogs/qprintpreviewdialog/images/");
+ QIcon icon;
+ icon.addFile(imagePrefix + name + QLatin1String("-24.png"), QSize(24, 24));
+ icon.addFile(imagePrefix + name + QLatin1String("-32.png"), QSize(32, 32));
+ action->setIcon(icon);
+}
+
+void QPrintPreviewDialogPrivate::setupActions()
+{
+ Q_Q(QPrintPreviewDialog);
+
+ // Navigation
+ navGroup = new QActionGroup(q);
+ navGroup->setExclusive(false);
+ nextPageAction = navGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Next page"));
+ prevPageAction = navGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Previous page"));
+ firstPageAction = navGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "First page"));
+ lastPageAction = navGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Last page"));
+ qt_setupActionIcon(nextPageAction, QLatin1String("go-next"));
+ qt_setupActionIcon(prevPageAction, QLatin1String("go-previous"));
+ qt_setupActionIcon(firstPageAction, QLatin1String("go-first"));
+ qt_setupActionIcon(lastPageAction, QLatin1String("go-last"));
+ QObject::connect(navGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_navigate(QAction*)));
+
+
+ fitGroup = new QActionGroup(q);
+ fitWidthAction = fitGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Fit width"));
+ fitPageAction = fitGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Fit page"));
+ fitWidthAction->setObjectName(QLatin1String("fitWidthAction"));
+ fitPageAction->setObjectName(QLatin1String("fitPageAction"));
+ fitWidthAction->setCheckable(true);
+ fitPageAction->setCheckable(true);
+ qt_setupActionIcon(fitWidthAction, QLatin1String("fit-width"));
+ qt_setupActionIcon(fitPageAction, QLatin1String("fit-page"));
+ QObject::connect(fitGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_fit(QAction*)));
+
+ // Zoom
+ zoomGroup = new QActionGroup(q);
+ zoomInAction = zoomGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Zoom in"));
+ zoomOutAction = zoomGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Zoom out"));
+ qt_setupActionIcon(zoomInAction, QLatin1String("zoom-in"));
+ qt_setupActionIcon(zoomOutAction, QLatin1String("zoom-out"));
+
+ // Portrait/Landscape
+ orientationGroup = new QActionGroup(q);
+ portraitAction = orientationGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Portrait"));
+ landscapeAction = orientationGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Landscape"));
+ portraitAction->setCheckable(true);
+ landscapeAction->setCheckable(true);
+ qt_setupActionIcon(portraitAction, QLatin1String("layout-portrait"));
+ qt_setupActionIcon(landscapeAction, QLatin1String("layout-landscape"));
+ QObject::connect(portraitAction, SIGNAL(triggered(bool)), preview, SLOT(setPortraitOrientation()));
+ QObject::connect(landscapeAction, SIGNAL(triggered(bool)), preview, SLOT(setLandscapeOrientation()));
+
+ // Display mode
+ modeGroup = new QActionGroup(q);
+ singleModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show single page"));
+ facingModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show facing pages"));
+ overviewModeAction = modeGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Show overview of all pages"));
+ qt_setupActionIcon(singleModeAction, QLatin1String("view-page-one"));
+ qt_setupActionIcon(facingModeAction, QLatin1String("view-page-sided"));
+ qt_setupActionIcon(overviewModeAction, QLatin1String("view-page-multi"));
+ singleModeAction->setObjectName(QLatin1String("singleModeAction"));
+ facingModeAction->setObjectName(QLatin1String("facingModeAction"));
+ overviewModeAction->setObjectName(QLatin1String("overviewModeAction"));
+
+ singleModeAction->setCheckable(true);
+ facingModeAction->setCheckable(true);
+ overviewModeAction->setCheckable(true);
+ QObject::connect(modeGroup, SIGNAL(triggered(QAction*)), q, SLOT(_q_setMode(QAction*)));
+
+ // Print
+ printerGroup = new QActionGroup(q);
+ printAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Print"));
+ pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup"));
+ qt_setupActionIcon(printAction, QLatin1String("print"));
+ qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup"));
+ QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print()));
+ QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup()));
+#if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA)
+ closeAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Close"));
+ QObject::connect(closeAction, SIGNAL(triggered(bool)), q, SLOT(reject()));
+#endif
+
+ // Initial state:
+ fitPageAction->setChecked(true);
+ singleModeAction->setChecked(true);
+ if (preview->orientation() == QPrinter::Portrait)
+ portraitAction->setChecked(true);
+ else
+ landscapeAction->setChecked(true);
+}
+
+
+bool QPrintPreviewDialogPrivate::isFitting()
+{
+ return (fitGroup->isExclusive()
+ && (fitWidthAction->isChecked() || fitPageAction->isChecked()));
+}
+
+
+void QPrintPreviewDialogPrivate::setFitting(bool on)
+{
+ if (isFitting() == on)
+ return;
+ fitGroup->setExclusive(on);
+ if (on) {
+ QAction* action = fitWidthAction->isChecked() ? fitWidthAction : fitPageAction;
+ action->setChecked(true);
+ if (fitGroup->checkedAction() != action) {
+ // work around exclusitivity problem
+ fitGroup->removeAction(action);
+ fitGroup->addAction(action);
+ }
+ } else {
+ fitWidthAction->setChecked(false);
+ fitPageAction->setChecked(false);
+ }
+}
+
+void QPrintPreviewDialogPrivate::updateNavActions()
+{
+ int curPage = preview->currentPage();
+ int numPages = preview->pageCount();
+ nextPageAction->setEnabled(curPage < numPages);
+ prevPageAction->setEnabled(curPage > 1);
+ firstPageAction->setEnabled(curPage > 1);
+ lastPageAction->setEnabled(curPage < numPages);
+ pageNumEdit->setText(QString::number(curPage));
+}
+
+void QPrintPreviewDialogPrivate::updatePageNumLabel()
+{
+ Q_Q(QPrintPreviewDialog);
+
+ int numPages = preview->pageCount();
+ int maxChars = QString::number(numPages).length();
+ pageNumLabel->setText(QString::fromLatin1("/ %1").arg(numPages));
+ int cyphersWidth = q->fontMetrics().width(QString().fill(QLatin1Char('8'), maxChars));
+ int maxWidth = pageNumEdit->minimumSizeHint().width() + cyphersWidth;
+ pageNumEdit->setMinimumWidth(maxWidth);
+ pageNumEdit->setMaximumWidth(maxWidth);
+ pageNumEdit->setValidator(new QIntValidator(1, numPages, pageNumEdit));
+ // any old one will be deleted later along with its parent pageNumEdit
+}
+
+void QPrintPreviewDialogPrivate::updateZoomFactor()
+{
+ zoomFactor->lineEdit()->setText(QString().sprintf("%.1f%%", preview->zoomFactor()*100));
+}
+
+void QPrintPreviewDialogPrivate::_q_fit(QAction* action)
+{
+ setFitting(true);
+ if (action == fitPageAction)
+ preview->fitInView();
+ else
+ preview->fitToWidth();
+}
+
+void QPrintPreviewDialogPrivate::_q_zoomIn()
+{
+ setFitting(false);
+ preview->zoomIn();
+ updateZoomFactor();
+}
+
+void QPrintPreviewDialogPrivate::_q_zoomOut()
+{
+ setFitting(false);
+ preview->zoomOut();
+ updateZoomFactor();
+}
+
+void QPrintPreviewDialogPrivate::_q_pageNumEdited()
+{
+ bool ok = false;
+ int res = pageNumEdit->text().toInt(&ok);
+ if (ok)
+ preview->setCurrentPage(res);
+}
+
+void QPrintPreviewDialogPrivate::_q_navigate(QAction* action)
+{
+ int curPage = preview->currentPage();
+ if (action == prevPageAction)
+ preview->setCurrentPage(curPage - 1);
+ else if (action == nextPageAction)
+ preview->setCurrentPage(curPage + 1);
+ else if (action == firstPageAction)
+ preview->setCurrentPage(1);
+ else if (action == lastPageAction)
+ preview->setCurrentPage(preview->pageCount());
+ updateNavActions();
+}
+
+void QPrintPreviewDialogPrivate::_q_setMode(QAction* action)
+{
+ if (action == overviewModeAction) {
+ preview->setViewMode(QPrintPreviewWidget::AllPagesView);
+ setFitting(false);
+ fitGroup->setEnabled(false);
+ navGroup->setEnabled(false);
+ pageNumEdit->setEnabled(false);
+ pageNumLabel->setEnabled(false);
+ } else if (action == facingModeAction) {
+ preview->setViewMode(QPrintPreviewWidget::FacingPagesView);
+ } else {
+ preview->setViewMode(QPrintPreviewWidget::SinglePageView);
+ }
+ if (action == facingModeAction || action == singleModeAction) {
+ fitGroup->setEnabled(true);
+ navGroup->setEnabled(true);
+ pageNumEdit->setEnabled(true);
+ pageNumLabel->setEnabled(true);
+ setFitting(true);
+ }
+}
+
+void QPrintPreviewDialogPrivate::_q_print()
+{
+ Q_Q(QPrintPreviewDialog);
+
+#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
+ if (printer->outputFormat() != QPrinter::NativeFormat) {
+ QString title;
+ QString suffix;
+ if (printer->outputFormat() == QPrinter::PdfFormat) {
+ title = QCoreApplication::translate("QPrintPreviewDialog", "Export to PDF");
+ suffix = QLatin1String(".pdf");
+ } else {
+ title = QCoreApplication::translate("QPrintPreviewDialog", "Export to PostScript");
+ suffix = QLatin1String(".ps");
+ }
+ QString fileName = QFileDialog::getSaveFileName(q, title, printer->outputFileName(),
+ QLatin1Char('*') + suffix);
+ if (!fileName.isEmpty()) {
+ if (QFileInfo(fileName).suffix().isEmpty())
+ fileName.append(suffix);
+ printer->setOutputFileName(fileName);
+ }
+ if (!printer->outputFileName().isEmpty())
+ preview->print();
+ q->accept();
+ return;
+ }
+#endif
+
+ if (!printDialog)
+ printDialog = new QPrintDialog(printer, q);
+ if (printDialog->exec() == QDialog::Accepted) {
+ preview->print();
+ q->accept();
+ }
+}
+
+void QPrintPreviewDialogPrivate::_q_pageSetup()
+{
+ Q_Q(QPrintPreviewDialog);
+
+ QPageSetupDialog pageSetup(printer, q);
+ if (pageSetup.exec() == QDialog::Accepted) {
+ // update possible orientation changes
+ if (preview->orientation() == QPrinter::Portrait) {
+ portraitAction->setChecked(true);
+ preview->setPortraitOrientation();
+ }else {
+ landscapeAction->setChecked(true);
+ preview->setLandscapeOrientation();
+ }
+ }
+}
+
+void QPrintPreviewDialogPrivate::_q_previewChanged()
+{
+ updateNavActions();
+ updatePageNumLabel();
+ updateZoomFactor();
+}
+
+void QPrintPreviewDialogPrivate::_q_zoomFactorChanged()
+{
+ QString text = zoomFactor->lineEdit()->text();
+ bool ok;
+ qreal factor = text.remove(QLatin1Char('%')).toFloat(&ok);
+ factor = qMax(qreal(1.0), qMin(qreal(1000.0), factor));
+ if (ok) {
+ preview->setZoomFactor(factor/100.0);
+ zoomFactor->setEditText(QString::fromLatin1("%1%").arg(factor));
+ setFitting(false);
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////
+
+/*!
+ \class QPrintPreviewDialog
+ \since 4.4
+
+ \brief The QPrintPreviewDialog class provides a dialog for
+ previewing and configuring page layouts for printer output.
+
+ \ingroup standard-dialogs
+ \ingroup printing
+
+ Using QPrintPreviewDialog in your existing application is
+ straightforward:
+
+ \list 1
+ \o Create the QPrintPreviewDialog.
+
+ You can construct a QPrintPreviewDialog with an existing QPrinter
+ object, or you can have QPrintPreviewDialog create one for you,
+ which will be the system default printer.
+
+ \o Connect the paintRequested() signal to a slot.
+
+ When the dialog needs to generate a set of preview pages, the
+ paintRequested() signal will be emitted. You can use the exact
+ same code for the actual printing as for having the preview
+ generated, including calling QPrinter::newPage() to start a new
+ page in the preview. Connect a slot to the paintRequested()
+ signal, where you draw onto the QPrinter object that is passed
+ into the slot.
+
+ \o Call exec().
+
+ Call QPrintPreviewDialog::exec() to show the preview dialog.
+ \endlist
+
+ In Symbian, there is no support for printing. Hence, this dialog should not
+ be used in Symbian.
+
+ \sa QPrinter, QPrintDialog, QPageSetupDialog, QPrintPreviewWidget
+*/
+
+/*!
+ Constructs a QPrintPreviewDialog based on \a printer and with \a
+ parent as the parent widget. The widget flags \a flags are passed on
+ to the QWidget constructor.
+
+ \sa QWidget::setWindowFlags()
+*/
+QPrintPreviewDialog::QPrintPreviewDialog(QPrinter* printer, QWidget *parent, Qt::WindowFlags flags)
+ : QDialog(*new QPrintPreviewDialogPrivate, parent, flags)
+{
+ Q_D(QPrintPreviewDialog);
+ d->init(printer);
+}
+
+/*!
+ \overload
+ \fn QPrintPreviewDialog::QPrintPreviewDialog(QWidget *parent, Qt::WindowFlags flags)
+
+ This will create an internal QPrinter object, which will use the
+ system default printer.
+*/
+QPrintPreviewDialog::QPrintPreviewDialog(QWidget *parent, Qt::WindowFlags f)
+ : QDialog(*new QPrintPreviewDialogPrivate, parent, f)
+{
+ Q_D(QPrintPreviewDialog);
+ d->init();
+}
+
+/*!
+ Destroys the QPrintPreviewDialog.
+*/
+QPrintPreviewDialog::~QPrintPreviewDialog()
+{
+ Q_D(QPrintPreviewDialog);
+ if (d->ownPrinter)
+ delete d->printer;
+ delete d->printDialog;
+}
+
+/*!
+ \reimp
+*/
+void QPrintPreviewDialog::setVisible(bool visible)
+{
+ Q_D(QPrintPreviewDialog);
+ // this will make the dialog get a decent default size
+ if (visible && !d->initialized) {
+ d->preview->updatePreview();
+ d->initialized = true;
+ }
+ QDialog::setVisible(visible);
+}
+
+/*!
+ \reimp
+*/
+void QPrintPreviewDialog::done(int result)
+{
+ Q_D(QPrintPreviewDialog);
+ QDialog::done(result);
+ if (d->receiverToDisconnectOnClose) {
+ disconnect(this, SIGNAL(finished(int)),
+ d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose);
+ d->receiverToDisconnectOnClose = 0;
+ }
+ d->memberToDisconnectOnClose.clear();
+}
+
+/*!
+ \overload
+ \since 4.5
+
+ Opens the dialog and connects its finished(int) signal to the slot specified
+ by \a receiver and \a member.
+
+ The signal will be disconnected from the slot when the dialog is closed.
+*/
+void QPrintPreviewDialog::open(QObject *receiver, const char *member)
+{
+ Q_D(QPrintPreviewDialog);
+ // the int parameter isn't very useful here; we could just as well connect
+ // to reject(), but this feels less robust somehow
+ connect(this, SIGNAL(finished(int)), receiver, member);
+ d->receiverToDisconnectOnClose = receiver;
+ d->memberToDisconnectOnClose = member;
+ QDialog::open();
+}
+
+/*!
+ Returns a pointer to the QPrinter object this dialog is currently
+ operating on.
+*/
+QPrinter *QPrintPreviewDialog::printer()
+{
+ Q_D(QPrintPreviewDialog);
+ return d->printer;
+}
+
+/*!
+ \fn void QPrintPreviewDialog::paintRequested(QPrinter *printer)
+
+ This signal is emitted when the QPrintPreviewDialog needs to generate
+ a set of preview pages.
+
+ The \a printer instance supplied is the paint device onto which you should
+ paint the contents of each page, using the QPrinter instance in the same way
+ as you would when printing directly.
+*/
+
+
+QT_END_NAMESPACE
+
+#include "moc_qprintpreviewdialog.cpp"
+#include "qprintpreviewdialog.moc"
+
+#endif // QT_NO_PRINTPREVIEWDIALOG
+
+
diff --git a/src/widgets/dialogs/qprintpreviewdialog.h b/src/widgets/dialogs/qprintpreviewdialog.h
new file mode 100644
index 0000000000..e7748819d3
--- /dev/null
+++ b/src/widgets/dialogs/qprintpreviewdialog.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPRINTPREVIEWDIALOG_H
+#define QPRINTPREVIEWDIALOG_H
+
+#include <QtWidgets/qdialog.h>
+
+#ifndef QT_NO_PRINTPREVIEWDIALOG
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QGraphicsView;
+class QPrintPreviewDialogPrivate;
+
+class Q_GUI_EXPORT QPrintPreviewDialog : public QDialog
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QPrintPreviewDialog)
+
+public:
+ explicit QPrintPreviewDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0);
+ explicit QPrintPreviewDialog(QPrinter *printer, QWidget *parent = 0, Qt::WindowFlags flags = 0);
+ ~QPrintPreviewDialog();
+
+#ifdef Q_NO_USING_KEYWORD
+#ifndef Q_QDOC
+ void open() { QDialog::open(); }
+#endif
+#else
+ using QDialog::open;
+#endif
+ void open(QObject *receiver, const char *member);
+
+ QPrinter *printer();
+
+ void setVisible(bool visible);
+ void done(int result);
+
+Q_SIGNALS:
+ void paintRequested(QPrinter *printer);
+
+private:
+ Q_PRIVATE_SLOT(d_func(), void _q_fit(QAction *action))
+ Q_PRIVATE_SLOT(d_func(), void _q_zoomIn())
+ Q_PRIVATE_SLOT(d_func(), void _q_zoomOut())
+ Q_PRIVATE_SLOT(d_func(), void _q_navigate(QAction *action))
+ Q_PRIVATE_SLOT(d_func(), void _q_setMode(QAction *action))
+ Q_PRIVATE_SLOT(d_func(), void _q_pageNumEdited())
+ Q_PRIVATE_SLOT(d_func(), void _q_print())
+ Q_PRIVATE_SLOT(d_func(), void _q_pageSetup())
+ Q_PRIVATE_SLOT(d_func(), void _q_previewChanged())
+ Q_PRIVATE_SLOT(d_func(), void _q_zoomFactorChanged())
+
+ void *dummy; // ### Qt 5 - remove me
+};
+
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QT_NO_PRINTPREVIEWDIALOG
+
+#endif // QPRINTPREVIEWDIALOG_H
diff --git a/src/gui/dialogs/qprintpropertieswidget.ui b/src/widgets/dialogs/qprintpropertieswidget.ui
index 26fa09599e..26fa09599e 100644
--- a/src/gui/dialogs/qprintpropertieswidget.ui
+++ b/src/widgets/dialogs/qprintpropertieswidget.ui
diff --git a/src/gui/dialogs/qprintsettingsoutput.ui b/src/widgets/dialogs/qprintsettingsoutput.ui
index be916790fb..be916790fb 100644
--- a/src/gui/dialogs/qprintsettingsoutput.ui
+++ b/src/widgets/dialogs/qprintsettingsoutput.ui
diff --git a/src/gui/dialogs/qprintwidget.ui b/src/widgets/dialogs/qprintwidget.ui
index 8a4f3bde0a..8a4f3bde0a 100644
--- a/src/gui/dialogs/qprintwidget.ui
+++ b/src/widgets/dialogs/qprintwidget.ui
diff --git a/src/widgets/dialogs/qprogressdialog.cpp b/src/widgets/dialogs/qprogressdialog.cpp
new file mode 100644
index 0000000000..841b41eee9
--- /dev/null
+++ b/src/widgets/dialogs/qprogressdialog.cpp
@@ -0,0 +1,907 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qprogressdialog.h"
+
+#ifndef QT_NO_PROGRESSDIALOG
+
+#include "qshortcut.h"
+#include "qpainter.h"
+#include "qdrawutil.h"
+#include "qlabel.h"
+#include "qprogressbar.h"
+#include "qapplication.h"
+#include "qstyle.h"
+#include "qpushbutton.h"
+#include "qcursor.h"
+#include "qtimer.h"
+#include "qelapsedtimer.h"
+#include <private/qdialog_p.h>
+#include <limits.h>
+
+#if defined(QT_SOFTKEYS_ENABLED)
+#include <qaction.h>
+#endif
+#ifdef Q_WS_S60
+#include <QtWidgets/qdesktopwidget.h>
+#endif
+
+
+QT_BEGIN_NAMESPACE
+
+// If the operation is expected to take this long (as predicted by
+// progress time), show the progress dialog.
+static const int defaultShowTime = 4000;
+// Wait at least this long before attempting to make a prediction.
+static const int minWaitTime = 50;
+
+class QProgressDialogPrivate : public QDialogPrivate
+{
+ Q_DECLARE_PUBLIC(QProgressDialog)
+
+public:
+ QProgressDialogPrivate() : label(0), cancel(0), bar(0),
+ shown_once(false),
+ cancellation_flag(false),
+ showTime(defaultShowTime),
+#ifndef QT_NO_SHORTCUT
+ escapeShortcut(0),
+#endif
+#ifdef QT_SOFTKEYS_ENABLED
+ cancelAction(0),
+#endif
+ useDefaultCancelText(false)
+ {
+ }
+
+ void init(const QString &labelText, const QString &cancelText, int min, int max);
+ void layout();
+ void retranslateStrings();
+ void _q_disconnectOnClose();
+
+ QLabel *label;
+ QPushButton *cancel;
+ QProgressBar *bar;
+ QTimer *forceTimer;
+ bool shown_once;
+ bool cancellation_flag;
+ QElapsedTimer starttime;
+#ifndef QT_NO_CURSOR
+ QCursor parentCursor;
+#endif
+ int showTime;
+ bool autoClose;
+ bool autoReset;
+ bool forceHide;
+#ifndef QT_NO_SHORTCUT
+ QShortcut *escapeShortcut;
+#endif
+#ifdef QT_SOFTKEYS_ENABLED
+ QAction *cancelAction;
+#endif
+ bool useDefaultCancelText;
+ QPointer<QObject> receiverToDisconnectOnClose;
+ QByteArray memberToDisconnectOnClose;
+};
+
+void QProgressDialogPrivate::init(const QString &labelText, const QString &cancelText,
+ int min, int max)
+{
+ Q_Q(QProgressDialog);
+ label = new QLabel(labelText, q);
+ int align = q->style()->styleHint(QStyle::SH_ProgressDialog_TextLabelAlignment, 0, q);
+ label->setAlignment(Qt::Alignment(align));
+ bar = new QProgressBar(q);
+ bar->setRange(min, max);
+ autoClose = true;
+ autoReset = true;
+ forceHide = false;
+ QObject::connect(q, SIGNAL(canceled()), q, SLOT(cancel()));
+ forceTimer = new QTimer(q);
+ QObject::connect(forceTimer, SIGNAL(timeout()), q, SLOT(forceShow()));
+ if (useDefaultCancelText) {
+ retranslateStrings();
+ } else {
+ q->setCancelButtonText(cancelText);
+ }
+}
+
+void QProgressDialogPrivate::layout()
+{
+ Q_Q(QProgressDialog);
+ int sp = q->style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing);
+ int mtb = q->style()->pixelMetric(QStyle::PM_DefaultTopLevelMargin);
+ int mlr = qMin(q->width() / 10, mtb);
+ const bool centered =
+ bool(q->style()->styleHint(QStyle::SH_ProgressDialog_CenterCancelButton, 0, q));
+
+ int additionalSpacing = 0;
+#ifdef Q_OS_SYMBIAN
+ //In Symbian, we need to have wider margins for dialog borders, as the actual border is some pixels
+ //inside the dialog area (to enable transparent borders)
+ additionalSpacing = mlr;
+#endif
+
+ QSize cs = cancel ? cancel->sizeHint() : QSize(0,0);
+ QSize bh = bar->sizeHint();
+ int cspc;
+ int lh = 0;
+
+ // Find spacing and sizes that fit. It is important that a progress
+ // dialog can be made very small if the user demands it so.
+ for (int attempt=5; attempt--;) {
+ cspc = cancel ? cs.height() + sp : 0;
+ lh = qMax(0, q->height() - mtb - bh.height() - sp - cspc);
+
+ if (lh < q->height()/4) {
+ // Getting cramped
+ sp /= 2;
+ mtb /= 2;
+ if (cancel) {
+ cs.setHeight(qMax(4,cs.height()-sp-2));
+ }
+ bh.setHeight(qMax(4,bh.height()-sp-1));
+ } else {
+ break;
+ }
+ }
+
+ if (cancel) {
+ cancel->setGeometry(
+ centered ? q->width()/2 - cs.width()/2 : q->width() - mlr - cs.width(),
+ q->height() - mtb - cs.height(),
+ cs.width(), cs.height());
+ }
+
+ if (label)
+ label->setGeometry(mlr, additionalSpacing, q->width() - mlr * 2, lh);
+ bar->setGeometry(mlr, lh + sp + additionalSpacing, q->width() - mlr * 2, bh.height());
+}
+
+void QProgressDialogPrivate::retranslateStrings()
+{
+ Q_Q(QProgressDialog);
+ if (useDefaultCancelText)
+ q->setCancelButtonText(QProgressDialog::tr("Cancel"));
+}
+
+void QProgressDialogPrivate::_q_disconnectOnClose()
+{
+ Q_Q(QProgressDialog);
+ if (receiverToDisconnectOnClose) {
+ QObject::disconnect(q, SIGNAL(canceled()), receiverToDisconnectOnClose,
+ memberToDisconnectOnClose);
+ receiverToDisconnectOnClose = 0;
+ }
+ memberToDisconnectOnClose.clear();
+}
+
+/*!
+ \class QProgressDialog
+ \brief The QProgressDialog class provides feedback on the progress of a slow operation.
+ \ingroup standard-dialogs
+
+
+ A progress dialog is used to give the user an indication of how long
+ an operation is going to take, and to demonstrate that the
+ application has not frozen. It can also give the user an opportunity
+ to abort the operation.
+
+ A common problem with progress dialogs is that it is difficult to know
+ when to use them; operations take different amounts of time on different
+ hardware. QProgressDialog offers a solution to this problem:
+ it estimates the time the operation will take (based on time for
+ steps), and only shows itself if that estimate is beyond minimumDuration()
+ (4 seconds by default).
+
+ Use setMinimum() and setMaximum() or the constructor to set the number of
+ "steps" in the operation and call setValue() as the operation
+ progresses. The number of steps can be chosen arbitrarily. It can be the
+ number of files copied, the number of bytes received, the number of
+ iterations through the main loop of your algorithm, or some other
+ suitable unit. Progress starts at the value set by setMinimum(),
+ and the progress dialog shows that the operation has finished when
+ you call setValue() with the value set by setMaximum() as its argument.
+
+ The dialog automatically resets and hides itself at the end of the
+ operation. Use setAutoReset() and setAutoClose() to change this
+ behavior. Note that if you set a new maximum (using setMaximum() or
+ setRange()) that equals your current value(), the dialog will not
+ close regardless.
+
+ There are two ways of using QProgressDialog: modal and modeless.
+
+ Compared to a modeless QProgressDialog, a modal QProgressDialog is simpler
+ to use for the programmer. Do the operation in a loop, call \l setValue() at
+ intervals, and check for cancellation with wasCanceled(). For example:
+
+ \snippet doc/src/snippets/dialogs/dialogs.cpp 3
+
+ A modeless progress dialog is suitable for operations that take
+ place in the background, where the user is able to interact with the
+ application. Such operations are typically based on QTimer (or
+ QObject::timerEvent()), QSocketNotifier, or QUrlOperator; or performed
+ in a separate thread. A QProgressBar in the status bar of your main window
+ is often an alternative to a modeless progress dialog.
+
+ You need to have an event loop to be running, connect the
+ canceled() signal to a slot that stops the operation, and call \l
+ setValue() at intervals. For example:
+
+ \snippet doc/src/snippets/dialogs/dialogs.cpp 4
+ \codeline
+ \snippet doc/src/snippets/dialogs/dialogs.cpp 5
+ \codeline
+ \snippet doc/src/snippets/dialogs/dialogs.cpp 6
+
+ In both modes the progress dialog may be customized by
+ replacing the child widgets with custom widgets by using setLabel(),
+ setBar(), and setCancelButton().
+ The functions setLabelText() and setCancelButtonText()
+ set the texts shown.
+
+ \image plastique-progressdialog.png A progress dialog shown in the Plastique widget style.
+
+ \sa QDialog, QProgressBar, {fowler}{GUI Design Handbook: Progress Indicator},
+ {Find Files Example}, {Pixelator Example}
+*/
+
+
+/*!
+ Constructs a progress dialog.
+
+ Default settings:
+ \list
+ \i The label text is empty.
+ \i The cancel button text is (translated) "Cancel".
+ \i minimum is 0;
+ \i maximum is 100
+ \endlist
+
+ The \a parent argument is dialog's parent widget. The widget flags, \a f, are
+ passed to the QDialog::QDialog() constructor.
+
+ \sa setLabelText(), setCancelButtonText(), setCancelButton(),
+ setMinimum(), setMaximum()
+*/
+
+QProgressDialog::QProgressDialog(QWidget *parent, Qt::WindowFlags f)
+ : QDialog(*(new QProgressDialogPrivate), parent, f)
+{
+ Q_D(QProgressDialog);
+ d->useDefaultCancelText = true;
+ d->init(QString::fromLatin1(""), QString(), 0, 100);
+}
+
+/*!
+ Constructs a progress dialog.
+
+ The \a labelText is the text used to remind the user what is progressing.
+
+ The \a cancelButtonText is the text to display on the cancel button. If
+ QString() is passed then no cancel button is shown.
+
+ The \a minimum and \a maximum is the number of steps in the operation for
+ which this progress dialog shows progress. For example, if the
+ operation is to examine 50 files, this value minimum value would be 0,
+ and the maximum would be 50. Before examining the first file, call
+ setValue(0). As each file is processed call setValue(1), setValue(2),
+ etc., finally calling setValue(50) after examining the last file.
+
+ The \a parent argument is the dialog's parent widget. The parent, \a parent, and
+ widget flags, \a f, are passed to the QDialog::QDialog() constructor.
+
+ \sa setLabelText(), setLabel(), setCancelButtonText(), setCancelButton(),
+ setMinimum(), setMaximum()
+*/
+
+QProgressDialog::QProgressDialog(const QString &labelText,
+ const QString &cancelButtonText,
+ int minimum, int maximum,
+ QWidget *parent, Qt::WindowFlags f)
+ : QDialog(*(new QProgressDialogPrivate), parent, f)
+{
+ Q_D(QProgressDialog);
+ d->init(labelText, cancelButtonText, minimum, maximum);
+}
+
+
+/*!
+ Destroys the progress dialog.
+*/
+
+QProgressDialog::~QProgressDialog()
+{
+}
+
+/*!
+ \fn void QProgressDialog::canceled()
+
+ This signal is emitted when the cancel button is clicked.
+ It is connected to the cancel() slot by default.
+
+ \sa wasCanceled()
+*/
+
+
+/*!
+ Sets the label to \a label. The progress dialog resizes to fit. The
+ label becomes owned by the progress dialog and will be deleted when
+ necessary, so do not pass the address of an object on the stack.
+
+ \sa setLabelText()
+*/
+
+void QProgressDialog::setLabel(QLabel *label)
+{
+ Q_D(QProgressDialog);
+ delete d->label;
+ d->label = label;
+ if (label) {
+ if (label->parentWidget() == this) {
+ label->hide(); // until we resize
+ } else {
+ label->setParent(this, 0);
+ }
+ }
+ int w = qMax(isVisible() ? width() : 0, sizeHint().width());
+ int h = qMax(isVisible() ? height() : 0, sizeHint().height());
+ resize(w, h);
+ if (label)
+ label->show();
+}
+
+
+/*!
+ \property QProgressDialog::labelText
+ \brief the label's text
+
+ The default text is an empty string.
+*/
+
+QString QProgressDialog::labelText() const
+{
+ Q_D(const QProgressDialog);
+ if (d->label)
+ return d->label->text();
+ return QString();
+}
+
+void QProgressDialog::setLabelText(const QString &text)
+{
+ Q_D(QProgressDialog);
+ if (d->label) {
+ d->label->setText(text);
+ int w = qMax(isVisible() ? width() : 0, sizeHint().width());
+ int h = qMax(isVisible() ? height() : 0, sizeHint().height());
+ resize(w, h);
+ }
+}
+
+
+/*!
+ Sets the cancel button to the push button, \a cancelButton. The
+ progress dialog takes ownership of this button which will be deleted
+ when necessary, so do not pass the address of an object that is on
+ the stack, i.e. use new() to create the button. If 0 is passed then
+ no cancel button will be shown.
+
+ \sa setCancelButtonText()
+*/
+
+void QProgressDialog::setCancelButton(QPushButton *cancelButton)
+{
+ Q_D(QProgressDialog);
+ delete d->cancel;
+ d->cancel = cancelButton;
+ if (cancelButton) {
+ if (cancelButton->parentWidget() == this) {
+ cancelButton->hide(); // until we resize
+ } else {
+ cancelButton->setParent(this, 0);
+ }
+ connect(d->cancel, SIGNAL(clicked()), this, SIGNAL(canceled()));
+#ifndef QT_NO_SHORTCUT
+ d->escapeShortcut = new QShortcut(Qt::Key_Escape, this, SIGNAL(canceled()));
+#endif
+ } else {
+#ifndef QT_NO_SHORTCUT
+ delete d->escapeShortcut;
+ d->escapeShortcut = 0;
+#endif
+ }
+ int w = qMax(isVisible() ? width() : 0, sizeHint().width());
+ int h = qMax(isVisible() ? height() : 0, sizeHint().height());
+ resize(w, h);
+ if (cancelButton)
+#if !defined(QT_SOFTKEYS_ENABLED)
+ cancelButton->show();
+#else
+ {
+ d->cancelAction = new QAction(cancelButton->text(), cancelButton);
+ d->cancelAction->setSoftKeyRole(QAction::NegativeSoftKey);
+ connect(d->cancelAction, SIGNAL(triggered()), this, SIGNAL(canceled()));
+ addAction(d->cancelAction);
+ }
+#endif
+}
+
+/*!
+ Sets the cancel button's text to \a cancelButtonText. If the text
+ is set to QString() then it will cause the cancel button to be
+ hidden and deleted.
+
+ \sa setCancelButton()
+*/
+
+void QProgressDialog::setCancelButtonText(const QString &cancelButtonText)
+{
+ Q_D(QProgressDialog);
+ d->useDefaultCancelText = false;
+
+ if (!cancelButtonText.isNull()) {
+ if (d->cancel) {
+ d->cancel->setText(cancelButtonText);
+#ifdef QT_SOFTKEYS_ENABLED
+ d->cancelAction->setText(cancelButtonText);
+#endif
+ } else {
+ setCancelButton(new QPushButton(cancelButtonText, this));
+ }
+ } else {
+ setCancelButton(0);
+ }
+ int w = qMax(isVisible() ? width() : 0, sizeHint().width());
+ int h = qMax(isVisible() ? height() : 0, sizeHint().height());
+ resize(w, h);
+}
+
+
+/*!
+ Sets the progress bar widget to \a bar. The progress dialog resizes to
+ fit. The progress dialog takes ownership of the progress \a bar which
+ will be deleted when necessary, so do not use a progress bar
+ allocated on the stack.
+*/
+
+void QProgressDialog::setBar(QProgressBar *bar)
+{
+ Q_D(QProgressDialog);
+ if (!bar) {
+ qWarning("QProgressDialog::setBar: Cannot set a null progress bar");
+ return;
+ }
+#ifndef QT_NO_DEBUG
+ if (value() > 0)
+ qWarning("QProgressDialog::setBar: Cannot set a new progress bar "
+ "while the old one is active");
+#endif
+ delete d->bar;
+ d->bar = bar;
+ int w = qMax(isVisible() ? width() : 0, sizeHint().width());
+ int h = qMax(isVisible() ? height() : 0, sizeHint().height());
+ resize(w, h);
+}
+
+
+/*!
+ \property QProgressDialog::wasCanceled
+ \brief whether the dialog was canceled
+*/
+
+bool QProgressDialog::wasCanceled() const
+{
+ Q_D(const QProgressDialog);
+ return d->cancellation_flag;
+}
+
+
+/*!
+ \property QProgressDialog::maximum
+ \brief the highest value represented by the progress bar
+
+ The default is 0.
+
+ \sa minimum, setRange()
+*/
+
+int QProgressDialog::maximum() const
+{
+ Q_D(const QProgressDialog);
+ return d->bar->maximum();
+}
+
+void QProgressDialog::setMaximum(int maximum)
+{
+ Q_D(QProgressDialog);
+ d->bar->setMaximum(maximum);
+}
+
+/*!
+ \property QProgressDialog::minimum
+ \brief the lowest value represented by the progress bar
+
+ The default is 0.
+
+ \sa maximum, setRange()
+*/
+
+int QProgressDialog::minimum() const
+{
+ Q_D(const QProgressDialog);
+ return d->bar->minimum();
+}
+
+void QProgressDialog::setMinimum(int minimum)
+{
+ Q_D(QProgressDialog);
+ d->bar->setMinimum(minimum);
+}
+
+/*!
+ Sets the progress dialog's minimum and maximum values
+ to \a minimum and \a maximum, respectively.
+
+ If \a maximum is smaller than \a minimum, \a minimum becomes the only
+ legal value.
+
+ If the current value falls outside the new range, the progress
+ dialog is reset with reset().
+
+ \sa minimum, maximum
+*/
+void QProgressDialog::setRange(int minimum, int maximum)
+{
+ Q_D(QProgressDialog);
+ d->bar->setRange(minimum, maximum);
+}
+
+
+/*!
+ Resets the progress dialog.
+ The progress dialog becomes hidden if autoClose() is true.
+
+ \sa setAutoClose(), setAutoReset()
+*/
+
+void QProgressDialog::reset()
+{
+ Q_D(QProgressDialog);
+#ifndef QT_NO_CURSOR
+ if (value() >= 0) {
+ if (parentWidget())
+ parentWidget()->setCursor(d->parentCursor);
+ }
+#endif
+ if (d->autoClose || d->forceHide)
+ hide();
+ d->bar->reset();
+ d->cancellation_flag = false;
+ d->shown_once = false;
+ d->forceTimer->stop();
+
+ /*
+ I wish we could disconnect the user slot provided to open() here but
+ unfortunately reset() is usually called before the slot has been invoked.
+ (reset() is itself invoked when canceled() is emitted.)
+ */
+ if (d->receiverToDisconnectOnClose)
+ QMetaObject::invokeMethod(this, "_q_disconnectOnClose", Qt::QueuedConnection);
+}
+
+/*!
+ Resets the progress dialog. wasCanceled() becomes true until
+ the progress dialog is reset.
+ The progress dialog becomes hidden.
+*/
+
+void QProgressDialog::cancel()
+{
+ Q_D(QProgressDialog);
+ d->forceHide = true;
+ reset();
+ d->forceHide = false;
+ d->cancellation_flag = true;
+}
+
+
+int QProgressDialog::value() const
+{
+ Q_D(const QProgressDialog);
+ return d->bar->value();
+}
+
+/*!
+ \property QProgressDialog::value
+ \brief the current amount of progress made.
+
+ For the progress dialog to work as expected, you should initially set
+ this property to 0 and finally set it to
+ QProgressDialog::maximum(); you can call setValue() any number of times
+ in-between.
+
+ \warning If the progress dialog is modal
+ (see QProgressDialog::QProgressDialog()),
+ setValue() calls QApplication::processEvents(), so take care that
+ this does not cause undesirable re-entrancy in your code. For example,
+ don't use a QProgressDialog inside a paintEvent()!
+
+ \sa minimum, maximum
+*/
+void QProgressDialog::setValue(int progress)
+{
+ Q_D(QProgressDialog);
+ if (progress == d->bar->value()
+ || (d->bar->value() == -1 && progress == d->bar->maximum()))
+ return;
+
+ d->bar->setValue(progress);
+
+ if (d->shown_once) {
+ if (isModal())
+ QApplication::processEvents();
+ } else {
+ if (progress == 0) {
+ d->starttime.start();
+ d->forceTimer->start(d->showTime);
+ return;
+ } else {
+ bool need_show;
+ int elapsed = d->starttime.elapsed();
+ if (elapsed >= d->showTime) {
+ need_show = true;
+ } else {
+ if (elapsed > minWaitTime) {
+ int estimate;
+ int totalSteps = maximum() - minimum();
+ int myprogress = progress - minimum();
+ if ((totalSteps - myprogress) >= INT_MAX / elapsed)
+ estimate = (totalSteps - myprogress) / myprogress * elapsed;
+ else
+ estimate = elapsed * (totalSteps - myprogress) / myprogress;
+ need_show = estimate >= d->showTime;
+ } else {
+ need_show = false;
+ }
+ }
+ if (need_show) {
+ int w = qMax(isVisible() ? width() : 0, sizeHint().width());
+ int h = qMax(isVisible() ? height() : 0, sizeHint().height());
+ resize(w, h);
+ show();
+ d->shown_once = true;
+ }
+ }
+#ifdef Q_WS_MAC
+ QApplication::flush();
+#endif
+ }
+
+ if (progress == d->bar->maximum() && d->autoReset)
+ reset();
+}
+
+/*!
+ Returns a size that fits the contents of the progress dialog.
+ The progress dialog resizes itself as required, so you should not
+ need to call this yourself.
+*/
+
+QSize QProgressDialog::sizeHint() const
+{
+ Q_D(const QProgressDialog);
+ QSize sh = d->label ? d->label->sizeHint() : QSize(0, 0);
+ QSize bh = d->bar->sizeHint();
+ int margin = style()->pixelMetric(QStyle::PM_DefaultTopLevelMargin);
+ int spacing = style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing);
+ int h = margin * 2 + bh.height() + sh.height() + spacing;
+ if (d->cancel)
+ h += d->cancel->sizeHint().height() + spacing;
+#ifdef Q_WS_S60
+ if (QApplication::desktop()->size().height() > QApplication::desktop()->size().width())
+ return QSize(qMax(QApplication::desktop()->size().width(), sh.width() + 2 * margin), h);
+ else
+ return QSize(qMax(QApplication::desktop()->size().height(), sh.width() + 2 * margin), h);
+#else
+ return QSize(qMax(200, sh.width() + 2 * margin), h);
+#endif
+}
+
+/*!\reimp
+*/
+void QProgressDialog::resizeEvent(QResizeEvent *)
+{
+ Q_D(QProgressDialog);
+ d->layout();
+}
+
+/*!
+ \reimp
+*/
+void QProgressDialog::changeEvent(QEvent *ev)
+{
+ Q_D(QProgressDialog);
+ if (ev->type() == QEvent::StyleChange) {
+ d->layout();
+ } else if (ev->type() == QEvent::LanguageChange) {
+ d->retranslateStrings();
+ }
+ QDialog::changeEvent(ev);
+}
+
+/*!
+ \property QProgressDialog::minimumDuration
+ \brief the time that must pass before the dialog appears
+
+ If the expected duration of the task is less than the
+ minimumDuration, the dialog will not appear at all. This prevents
+ the dialog popping up for tasks that are quickly over. For tasks
+ that are expected to exceed the minimumDuration, the dialog will
+ pop up after the minimumDuration time or as soon as any progress
+ is set.
+
+ If set to 0, the dialog is always shown as soon as any progress is
+ set. The default is 4000 milliseconds.
+*/
+void QProgressDialog::setMinimumDuration(int ms)
+{
+ Q_D(QProgressDialog);
+ d->showTime = ms;
+ if (d->bar->value() == 0) {
+ d->forceTimer->stop();
+ d->forceTimer->start(ms);
+ }
+}
+
+int QProgressDialog::minimumDuration() const
+{
+ Q_D(const QProgressDialog);
+ return d->showTime;
+}
+
+
+/*!
+ \reimp
+*/
+
+void QProgressDialog::closeEvent(QCloseEvent *e)
+{
+ emit canceled();
+ QDialog::closeEvent(e);
+}
+
+/*!
+ \property QProgressDialog::autoReset
+ \brief whether the progress dialog calls reset() as soon as value() equals maximum()
+
+ The default is true.
+
+ \sa setAutoClose()
+*/
+
+void QProgressDialog::setAutoReset(bool b)
+{
+ Q_D(QProgressDialog);
+ d->autoReset = b;
+}
+
+bool QProgressDialog::autoReset() const
+{
+ Q_D(const QProgressDialog);
+ return d->autoReset;
+}
+
+/*!
+ \property QProgressDialog::autoClose
+ \brief whether the dialog gets hidden by reset()
+
+ The default is true.
+
+ \sa setAutoReset()
+*/
+
+void QProgressDialog::setAutoClose(bool close)
+{
+ Q_D(QProgressDialog);
+ d->autoClose = close;
+}
+
+bool QProgressDialog::autoClose() const
+{
+ Q_D(const QProgressDialog);
+ return d->autoClose;
+}
+
+/*!
+ \reimp
+*/
+
+void QProgressDialog::showEvent(QShowEvent *e)
+{
+ Q_D(QProgressDialog);
+ QDialog::showEvent(e);
+ int w = qMax(isVisible() ? width() : 0, sizeHint().width());
+ int h = qMax(isVisible() ? height() : 0, sizeHint().height());
+ resize(w, h);
+ d->forceTimer->stop();
+}
+
+/*!
+ Shows the dialog if it is still hidden after the algorithm has been started
+ and minimumDuration milliseconds have passed.
+
+ \sa setMinimumDuration()
+*/
+
+void QProgressDialog::forceShow()
+{
+ Q_D(QProgressDialog);
+ d->forceTimer->stop();
+ if (d->shown_once || d->cancellation_flag)
+ return;
+
+ show();
+ d->shown_once = true;
+}
+
+/*!
+ \since 4.5
+ \overload
+
+ Opens the dialog and connects its accepted() signal to the slot specified
+ by \a receiver and \a member.
+
+ The signal will be disconnected from the slot when the dialog is closed.
+*/
+void QProgressDialog::open(QObject *receiver, const char *member)
+{
+ Q_D(QProgressDialog);
+ connect(this, SIGNAL(canceled()), receiver, member);
+ d->receiverToDisconnectOnClose = receiver;
+ d->memberToDisconnectOnClose = member;
+ QDialog::open();
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qprogressdialog.cpp"
+
+#endif // QT_NO_PROGRESSDIALOG
diff --git a/src/widgets/dialogs/qprogressdialog.h b/src/widgets/dialogs/qprogressdialog.h
new file mode 100644
index 0000000000..b7668774b9
--- /dev/null
+++ b/src/widgets/dialogs/qprogressdialog.h
@@ -0,0 +1,145 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPROGRESSDIALOG_H
+#define QPROGRESSDIALOG_H
+
+#include <QtWidgets/qdialog.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_PROGRESSDIALOG
+
+class QPushButton;
+class QLabel;
+class QProgressBar;
+class QTimer;
+class QProgressDialogPrivate;
+
+class Q_GUI_EXPORT QProgressDialog : public QDialog
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QProgressDialog)
+ Q_PROPERTY(bool wasCanceled READ wasCanceled)
+ Q_PROPERTY(int minimum READ minimum WRITE setMinimum)
+ Q_PROPERTY(int maximum READ maximum WRITE setMaximum)
+ Q_PROPERTY(int value READ value WRITE setValue)
+ Q_PROPERTY(bool autoReset READ autoReset WRITE setAutoReset)
+ Q_PROPERTY(bool autoClose READ autoClose WRITE setAutoClose)
+ Q_PROPERTY(int minimumDuration READ minimumDuration WRITE setMinimumDuration)
+ Q_PROPERTY(QString labelText READ labelText WRITE setLabelText)
+
+public:
+ explicit QProgressDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0);
+ QProgressDialog(const QString &labelText, const QString &cancelButtonText,
+ int minimum, int maximum, QWidget *parent = 0, Qt::WindowFlags flags = 0);
+ ~QProgressDialog();
+
+ void setLabel(QLabel *label);
+ void setCancelButton(QPushButton *button);
+ void setBar(QProgressBar *bar);
+
+ bool wasCanceled() const;
+
+ int minimum() const;
+ int maximum() const;
+
+ int value() const;
+
+ QSize sizeHint() const;
+
+ QString labelText() const;
+ int minimumDuration() const;
+
+ void setAutoReset(bool reset);
+ bool autoReset() const;
+ void setAutoClose(bool close);
+ bool autoClose() const;
+
+#ifdef Q_NO_USING_KEYWORD
+#ifndef Q_QDOC
+ void open() { QDialog::open(); }
+#endif
+#else
+ using QDialog::open;
+#endif
+ void open(QObject *receiver, const char *member);
+
+public Q_SLOTS:
+ void cancel();
+ void reset();
+ void setMaximum(int maximum);
+ void setMinimum(int minimum);
+ void setRange(int minimum, int maximum);
+ void setValue(int progress);
+ void setLabelText(const QString &text);
+ void setCancelButtonText(const QString &text);
+ void setMinimumDuration(int ms);
+
+Q_SIGNALS:
+ void canceled();
+
+protected:
+ void resizeEvent(QResizeEvent *event);
+ void closeEvent(QCloseEvent *event);
+ void changeEvent(QEvent *event);
+ void showEvent(QShowEvent *event);
+
+protected Q_SLOTS:
+ void forceShow();
+
+private:
+ Q_DISABLE_COPY(QProgressDialog)
+
+ Q_PRIVATE_SLOT(d_func(), void _q_disconnectOnClose())
+};
+
+#endif // QT_NO_PROGRESSDIALOG
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPROGRESSDIALOG_H
diff --git a/src/gui/dialogs/qsidebar.cpp b/src/widgets/dialogs/qsidebar.cpp
index 2869e1262b..2869e1262b 100644
--- a/src/gui/dialogs/qsidebar.cpp
+++ b/src/widgets/dialogs/qsidebar.cpp
diff --git a/src/gui/dialogs/qsidebar_p.h b/src/widgets/dialogs/qsidebar_p.h
index 188f4d7f0f..188f4d7f0f 100644
--- a/src/gui/dialogs/qsidebar_p.h
+++ b/src/widgets/dialogs/qsidebar_p.h
diff --git a/src/gui/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp
index ce5118f91d..ce5118f91d 100644
--- a/src/gui/dialogs/qwizard.cpp
+++ b/src/widgets/dialogs/qwizard.cpp
diff --git a/src/widgets/dialogs/qwizard.h b/src/widgets/dialogs/qwizard.h
new file mode 100644
index 0000000000..c4813302a6
--- /dev/null
+++ b/src/widgets/dialogs/qwizard.h
@@ -0,0 +1,268 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWIZARD_H
+#define QWIZARD_H
+
+#include <QtWidgets/qdialog.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_WIZARD
+
+class QAbstractButton;
+class QWizardPage;
+class QWizardPrivate;
+
+class Q_GUI_EXPORT QWizard : public QDialog
+{
+ Q_OBJECT
+ Q_ENUMS(WizardStyle WizardOption)
+ Q_FLAGS(WizardOptions)
+ Q_PROPERTY(WizardStyle wizardStyle READ wizardStyle WRITE setWizardStyle)
+ Q_PROPERTY(WizardOptions options READ options WRITE setOptions)
+ Q_PROPERTY(Qt::TextFormat titleFormat READ titleFormat WRITE setTitleFormat)
+ Q_PROPERTY(Qt::TextFormat subTitleFormat READ subTitleFormat WRITE setSubTitleFormat)
+ Q_PROPERTY(int startId READ startId WRITE setStartId)
+ Q_PROPERTY(int currentId READ currentId NOTIFY currentIdChanged)
+
+public:
+ enum WizardButton {
+ BackButton,
+ NextButton,
+ CommitButton,
+ FinishButton,
+ CancelButton,
+ HelpButton,
+ CustomButton1,
+ CustomButton2,
+ CustomButton3,
+ Stretch,
+
+ NoButton = -1,
+ NStandardButtons = 6,
+ NButtons = 9
+ };
+
+ enum WizardPixmap {
+ WatermarkPixmap,
+ LogoPixmap,
+ BannerPixmap,
+ BackgroundPixmap,
+ NPixmaps
+ };
+
+ enum WizardStyle {
+ ClassicStyle,
+ ModernStyle,
+ MacStyle,
+ AeroStyle,
+ NStyles
+ };
+
+ enum WizardOption {
+ IndependentPages = 0x00000001,
+ IgnoreSubTitles = 0x00000002,
+ ExtendedWatermarkPixmap = 0x00000004,
+ NoDefaultButton = 0x00000008,
+ NoBackButtonOnStartPage = 0x00000010,
+ NoBackButtonOnLastPage = 0x00000020,
+ DisabledBackButtonOnLastPage = 0x00000040,
+ HaveNextButtonOnLastPage = 0x00000080,
+ HaveFinishButtonOnEarlyPages = 0x00000100,
+ NoCancelButton = 0x00000200,
+ CancelButtonOnLeft = 0x00000400,
+ HaveHelpButton = 0x00000800,
+ HelpButtonOnRight = 0x00001000,
+ HaveCustomButton1 = 0x00002000,
+ HaveCustomButton2 = 0x00004000,
+ HaveCustomButton3 = 0x00008000
+ };
+
+ Q_DECLARE_FLAGS(WizardOptions, WizardOption)
+
+ explicit QWizard(QWidget *parent = 0, Qt::WindowFlags flags = 0);
+ ~QWizard();
+
+ int addPage(QWizardPage *page);
+ void setPage(int id, QWizardPage *page);
+ void removePage(int id);
+ QWizardPage *page(int id) const;
+ bool hasVisitedPage(int id) const;
+ QList<int> visitedPages() const; // ### visitedIds()?
+ QList<int> pageIds() const;
+ void setStartId(int id);
+ int startId() const;
+ QWizardPage *currentPage() const;
+ int currentId() const;
+
+ virtual bool validateCurrentPage();
+ virtual int nextId() const;
+
+ void setField(const QString &name, const QVariant &value);
+ QVariant field(const QString &name) const;
+
+ void setWizardStyle(WizardStyle style);
+ WizardStyle wizardStyle() const;
+
+ void setOption(WizardOption option, bool on = true);
+ bool testOption(WizardOption option) const;
+ void setOptions(WizardOptions options);
+ WizardOptions options() const;
+
+ void setButtonText(WizardButton which, const QString &text);
+ QString buttonText(WizardButton which) const;
+ void setButtonLayout(const QList<WizardButton> &layout);
+ void setButton(WizardButton which, QAbstractButton *button);
+ QAbstractButton *button(WizardButton which) const;
+
+ void setTitleFormat(Qt::TextFormat format);
+ Qt::TextFormat titleFormat() const;
+ void setSubTitleFormat(Qt::TextFormat format);
+ Qt::TextFormat subTitleFormat() const;
+ void setPixmap(WizardPixmap which, const QPixmap &pixmap);
+ QPixmap pixmap(WizardPixmap which) const;
+
+ void setSideWidget(QWidget *widget);
+ QWidget *sideWidget() const;
+
+ void setDefaultProperty(const char *className, const char *property,
+ const char *changedSignal);
+
+ void setVisible(bool visible);
+ QSize sizeHint() const;
+
+Q_SIGNALS:
+ void currentIdChanged(int id);
+ void helpRequested();
+ void customButtonClicked(int which);
+ void pageAdded(int id);
+ void pageRemoved(int id);
+
+public Q_SLOTS:
+ void back();
+ void next();
+ void restart();
+
+protected:
+ bool event(QEvent *event);
+ void resizeEvent(QResizeEvent *event);
+ void paintEvent(QPaintEvent *event);
+#if defined(Q_WS_WIN)
+ bool winEvent(MSG * message, long * result);
+#endif
+ void done(int result);
+ virtual void initializePage(int id);
+ virtual void cleanupPage(int id);
+
+private:
+ Q_DISABLE_COPY(QWizard)
+ Q_DECLARE_PRIVATE(QWizard)
+ Q_PRIVATE_SLOT(d_func(), void _q_emitCustomButtonClicked())
+ Q_PRIVATE_SLOT(d_func(), void _q_updateButtonStates())
+ Q_PRIVATE_SLOT(d_func(), void _q_handleFieldObjectDestroyed(QObject *))
+
+ friend class QWizardPage;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QWizard::WizardOptions)
+
+class QWizardPagePrivate;
+
+class Q_GUI_EXPORT QWizardPage : public QWidget
+{
+ Q_OBJECT
+ Q_PROPERTY(QString title READ title WRITE setTitle)
+ Q_PROPERTY(QString subTitle READ subTitle WRITE setSubTitle)
+
+public:
+ QWizardPage(QWidget *parent = 0);
+
+ void setTitle(const QString &title);
+ QString title() const;
+ void setSubTitle(const QString &subTitle);
+ QString subTitle() const;
+ void setPixmap(QWizard::WizardPixmap which, const QPixmap &pixmap);
+ QPixmap pixmap(QWizard::WizardPixmap which) const;
+ void setFinalPage(bool finalPage);
+ bool isFinalPage() const;
+ void setCommitPage(bool commitPage);
+ bool isCommitPage() const;
+ void setButtonText(QWizard::WizardButton which, const QString &text);
+ QString buttonText(QWizard::WizardButton which) const;
+
+ virtual void initializePage();
+ virtual void cleanupPage();
+ virtual bool validatePage();
+ virtual bool isComplete() const;
+ virtual int nextId() const;
+
+Q_SIGNALS:
+ void completeChanged();
+
+protected:
+ void setField(const QString &name, const QVariant &value);
+ QVariant field(const QString &name) const;
+ void registerField(const QString &name, QWidget *widget, const char *property = 0,
+ const char *changedSignal = 0);
+ QWizard *wizard() const;
+
+private:
+ Q_DISABLE_COPY(QWizardPage)
+ Q_DECLARE_PRIVATE(QWizardPage)
+ Q_PRIVATE_SLOT(d_func(), void _q_maybeEmitCompleteChanged())
+ Q_PRIVATE_SLOT(d_func(), void _q_updateCachedCompleteState())
+
+ friend class QWizard;
+ friend class QWizardPrivate;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QT_NO_WIZARD
+
+#endif // QWIZARD_H
diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp
new file mode 100644
index 0000000000..3aee39887b
--- /dev/null
+++ b/src/widgets/dialogs/qwizard_win.cpp
@@ -0,0 +1,759 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QT_NO_WIZARD
+#ifndef QT_NO_STYLE_WINDOWSVISTA
+
+#include "qwizard_win_p.h"
+#include <private/qsystemlibrary_p.h>
+#include "qwizard.h"
+#include "qpaintengine.h"
+#include "qapplication.h"
+#include <QtGui/QMouseEvent>
+#include <QtWidgets/QDesktopWidget>
+
+// Note, these tests are duplicates in qwindowsxpstyle_p.h.
+#ifdef Q_CC_GNU
+# include <w32api.h>
+# if (__W32API_MAJOR_VERSION >= 3 || (__W32API_MAJOR_VERSION == 2 && __W32API_MINOR_VERSION >= 5))
+# ifdef _WIN32_WINNT
+# undef _WIN32_WINNT
+# endif
+# define _WIN32_WINNT 0x0501
+# include <commctrl.h>
+# endif
+#endif
+
+#include <uxtheme.h>
+
+QT_BEGIN_NAMESPACE
+
+//DWM related
+typedef struct { //MARGINS
+ int cxLeftWidth; // width of left border that retains its size
+ int cxRightWidth; // width of right border that retains its size
+ int cyTopHeight; // height of top border that retains its size
+ int cyBottomHeight; // height of bottom border that retains its size
+} WIZ_MARGINS;
+typedef struct { //DTTOPTS
+ DWORD dwSize;
+ DWORD dwFlags;
+ COLORREF crText;
+ COLORREF crBorder;
+ COLORREF crShadow;
+ int eTextShadowType;
+ POINT ptShadowOffset;
+ int iBorderSize;
+ int iFontPropId;
+ int iColorPropId;
+ int iStateId;
+ BOOL fApplyOverlay;
+ int iGlowSize;
+} WIZ_DTTOPTS;
+
+typedef struct {
+ DWORD dwFlags;
+ DWORD dwMask;
+} WIZ_WTA_OPTIONS;
+
+#define WIZ_WM_THEMECHANGED 0x031A
+#define WIZ_WM_DWMCOMPOSITIONCHANGED 0x031E
+
+enum WIZ_WINDOWTHEMEATTRIBUTETYPE {
+ WIZ_WTA_NONCLIENT = 1
+};
+
+#define WIZ_WTNCA_NODRAWCAPTION 0x00000001
+#define WIZ_WTNCA_NODRAWICON 0x00000002
+
+#define WIZ_DT_CENTER 0x00000001 //DT_CENTER
+#define WIZ_DT_VCENTER 0x00000004
+#define WIZ_DT_SINGLELINE 0x00000020
+#define WIZ_DT_NOPREFIX 0x00000800
+
+enum WIZ_NAVIGATIONPARTS { //NAVIGATIONPARTS
+ WIZ_NAV_BACKBUTTON = 1,
+ WIZ_NAV_FORWARDBUTTON = 2,
+ WIZ_NAV_MENUBUTTON = 3,
+};
+
+enum WIZ_NAV_BACKBUTTONSTATES { //NAV_BACKBUTTONSTATES
+ WIZ_NAV_BB_NORMAL = 1,
+ WIZ_NAV_BB_HOT = 2,
+ WIZ_NAV_BB_PRESSED = 3,
+ WIZ_NAV_BB_DISABLED = 4,
+};
+
+#define WIZ_TMT_CAPTIONFONT (801) //TMT_CAPTIONFONT
+#define WIZ_DTT_COMPOSITED (1UL << 13) //DTT_COMPOSITED
+#define WIZ_DTT_GLOWSIZE (1UL << 11) //DTT_GLOWSIZE
+
+#define WIZ_WM_NCMOUSELEAVE 674 //WM_NCMOUSELEAVE
+
+#define WIZ_WP_CAPTION 1 //WP_CAPTION
+#define WIZ_CS_ACTIVE 1 //CS_ACTIVE
+#define WIZ_TMT_FILLCOLORHINT 3821 //TMT_FILLCOLORHINT
+#define WIZ_TMT_BORDERCOLORHINT 3822 //TMT_BORDERCOLORHINT
+
+typedef BOOL (WINAPI *PtrDwmDefWindowProc)(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam, LRESULT *plResult);
+typedef HRESULT (WINAPI *PtrDwmIsCompositionEnabled)(BOOL* pfEnabled);
+typedef HRESULT (WINAPI *PtrDwmExtendFrameIntoClientArea)(HWND hWnd, const WIZ_MARGINS* pMarInset);
+typedef HRESULT (WINAPI *PtrSetWindowThemeAttribute)(HWND hwnd, enum WIZ_WINDOWTHEMEATTRIBUTETYPE eAttribute, PVOID pvAttribute, DWORD cbAttribute);
+
+static PtrDwmDefWindowProc pDwmDefWindowProc = 0;
+static PtrDwmIsCompositionEnabled pDwmIsCompositionEnabled = 0;
+static PtrDwmExtendFrameIntoClientArea pDwmExtendFrameIntoClientArea = 0;
+static PtrSetWindowThemeAttribute pSetWindowThemeAttribute = 0;
+
+//Theme related
+typedef bool (WINAPI *PtrIsAppThemed)();
+typedef bool (WINAPI *PtrIsThemeActive)();
+typedef HANDLE (WINAPI *PtrOpenThemeData)(HWND hwnd, LPCWSTR pszClassList);
+typedef HRESULT (WINAPI *PtrCloseThemeData)(HANDLE hTheme);
+typedef HRESULT (WINAPI *PtrGetThemeSysFont)(HANDLE hTheme, int iFontId, LOGFONTW *plf);
+typedef HRESULT (WINAPI *PtrDrawThemeTextEx)(HANDLE hTheme, HDC hdc, int iPartId, int iStateId, LPCWSTR pszText, int cchText, DWORD dwTextFlags, LPRECT pRect, const WIZ_DTTOPTS *pOptions);
+typedef HRESULT (WINAPI *PtrDrawThemeBackground)(HANDLE hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, OPTIONAL const RECT *pClipRect);
+typedef HRESULT (WINAPI *PtrGetThemePartSize)(HANDLE hTheme, HDC hdc, int iPartId, int iStateId, OPTIONAL RECT *prc, enum THEMESIZE eSize, OUT SIZE *psz);
+typedef HRESULT (WINAPI *PtrGetThemeColor)(HANDLE hTheme, int iPartId, int iStateId, int iPropId, OUT COLORREF *pColor);
+
+static PtrIsAppThemed pIsAppThemed = 0;
+static PtrIsThemeActive pIsThemeActive = 0;
+static PtrOpenThemeData pOpenThemeData = 0;
+static PtrCloseThemeData pCloseThemeData = 0;
+static PtrGetThemeSysFont pGetThemeSysFont = 0;
+static PtrDrawThemeTextEx pDrawThemeTextEx = 0;
+static PtrDrawThemeBackground pDrawThemeBackground = 0;
+static PtrGetThemePartSize pGetThemePartSize = 0;
+static PtrGetThemeColor pGetThemeColor = 0;
+
+bool QVistaHelper::is_vista = false;
+QVistaHelper::VistaState QVistaHelper::cachedVistaState = QVistaHelper::Dirty;
+
+/******************************************************************************
+** QVistaBackButton
+*/
+
+QVistaBackButton::QVistaBackButton(QWidget *widget)
+ : QAbstractButton(widget)
+{
+ setFocusPolicy(Qt::NoFocus);
+}
+
+QSize QVistaBackButton::sizeHint() const
+{
+ ensurePolished();
+ int size = int(QStyleHelper::dpiScaled(32));
+ int width = size, height = size;
+/*
+ HANDLE theme = pOpenThemeData(0, L"Navigation");
+ SIZE size;
+ if (pGetThemePartSize(theme, 0, WIZ_NAV_BACKBUTTON, WIZ_NAV_BB_NORMAL, 0, TS_TRUE, &size) == S_OK) {
+ width = size.cx;
+ height = size.cy;
+ }
+*/
+ return QSize(width, height);
+}
+
+void QVistaBackButton::enterEvent(QEvent *event)
+{
+ if (isEnabled())
+ update();
+ QAbstractButton::enterEvent(event);
+}
+
+void QVistaBackButton::leaveEvent(QEvent *event)
+{
+ if (isEnabled())
+ update();
+ QAbstractButton::leaveEvent(event);
+}
+
+void QVistaBackButton::paintEvent(QPaintEvent *)
+{
+ QPainter p(this);
+ QRect r = rect();
+ HANDLE theme = pOpenThemeData(0, L"Navigation");
+ //RECT rect;
+ RECT clipRect;
+ int xoffset = QWidget::mapToParent(r.topLeft()).x() - 1;
+ int yoffset = QWidget::mapToParent(r.topLeft()).y() - 1;
+
+ clipRect.top = r.top() + yoffset;
+ clipRect.bottom = r.bottom() + yoffset;
+ clipRect.left = r.left() + xoffset;
+ clipRect.right = r.right() + xoffset;
+
+ int state = WIZ_NAV_BB_NORMAL;
+ if (!isEnabled())
+ state = WIZ_NAV_BB_DISABLED;
+ else if (isDown())
+ state = WIZ_NAV_BB_PRESSED;
+ else if (underMouse())
+ state = WIZ_NAV_BB_HOT;
+
+ pDrawThemeBackground(theme, p.paintEngine()->getDC(), WIZ_NAV_BACKBUTTON, state, &clipRect, &clipRect);
+}
+
+/******************************************************************************
+** QVistaHelper
+*/
+
+QVistaHelper::QVistaHelper(QWizard *wizard)
+ : QObject(wizard)
+ , pressed(false)
+ , wizard(wizard)
+ , backButton_(0)
+{
+ is_vista = resolveSymbols();
+ if (is_vista)
+ backButton_ = new QVistaBackButton(wizard);
+
+ // Handle diff between Windows 7 and Vista
+ iconSpacing = QStyleHelper::dpiScaled(7);
+ textSpacing = QSysInfo::WindowsVersion >= QSysInfo::WV_WINDOWS7 ?
+ iconSpacing : QStyleHelper::dpiScaled(20);
+}
+
+QVistaHelper::~QVistaHelper()
+{
+}
+
+bool QVistaHelper::isCompositionEnabled()
+{
+ bool value = is_vista;
+ if (is_vista) {
+ HRESULT hr;
+ BOOL bEnabled;
+
+ hr = pDwmIsCompositionEnabled(&bEnabled);
+ value = (SUCCEEDED(hr) && bEnabled);
+ }
+ return value;
+}
+
+bool QVistaHelper::isThemeActive()
+{
+ return is_vista && pIsThemeActive();
+}
+
+QVistaHelper::VistaState QVistaHelper::vistaState()
+{
+ if (cachedVistaState == Dirty)
+ cachedVistaState =
+ isCompositionEnabled() ? VistaAero : isThemeActive() ? VistaBasic : Classic;
+ return cachedVistaState;
+}
+
+QColor QVistaHelper::basicWindowFrameColor()
+{
+ DWORD rgb;
+ HANDLE hTheme = pOpenThemeData(QApplication::desktop()->winId(), L"WINDOW");
+ pGetThemeColor(
+ hTheme, WIZ_WP_CAPTION, WIZ_CS_ACTIVE,
+ wizard->isActiveWindow() ? WIZ_TMT_FILLCOLORHINT : WIZ_TMT_BORDERCOLORHINT,
+ &rgb);
+ BYTE r = GetRValue(rgb);
+ BYTE g = GetGValue(rgb);
+ BYTE b = GetBValue(rgb);
+ return QColor(r, g, b);
+}
+
+bool QVistaHelper::setDWMTitleBar(TitleBarChangeType type)
+{
+ bool value = false;
+ if (vistaState() == VistaAero) {
+ WIZ_MARGINS mar = {0};
+ if (type == NormalTitleBar)
+ mar.cyTopHeight = 0;
+ else
+ mar.cyTopHeight = titleBarSize() + topOffset();
+ HRESULT hr = pDwmExtendFrameIntoClientArea(wizard->winId(), &mar);
+ value = SUCCEEDED(hr);
+ }
+ return value;
+}
+
+void QVistaHelper::drawTitleBar(QPainter *painter)
+{
+ HDC hdc = painter->paintEngine()->getDC();
+
+ if (vistaState() == VistaAero)
+ drawBlackRect(QRect(0, 0, wizard->width(),
+ titleBarSize() + topOffset()), hdc);
+ Q_ASSERT(backButton_);
+ const int btnTop = backButton_->mapToParent(QPoint()).y();
+ const int btnHeight = backButton_->size().height();
+ const int verticalCenter = (btnTop + btnHeight / 2) - 1;
+
+ const QString text = wizard->window()->windowTitle();
+ const QFont font = QApplication::font("QWorkspaceTitleBar");
+ const QFontMetrics fontMetrics(font);
+ const QRect brect = fontMetrics.boundingRect(text);
+ int textHeight = brect.height();
+ int textWidth = brect.width();
+ int glowOffset = 0;
+
+ if (vistaState() == VistaAero) {
+ textHeight += 2 * glowSize();
+ textWidth += 2 * glowSize();
+ glowOffset = glowSize();
+ }
+
+ drawTitleText(
+ painter, text,
+ QRect(titleOffset() - glowOffset, verticalCenter - textHeight / 2, textWidth, textHeight),
+ hdc);
+
+ if (!wizard->windowIcon().isNull()) {
+ QRect rect(leftMargin(), verticalCenter - iconSize() / 2, iconSize(), iconSize());
+ HICON hIcon = wizard->windowIcon().pixmap(iconSize()).toWinHICON();
+ DrawIconEx(hdc, rect.left(), rect.top(), hIcon, 0, 0, 0, NULL, DI_NORMAL | DI_COMPAT);
+ DestroyIcon(hIcon);
+ }
+}
+
+void QVistaHelper::setTitleBarIconAndCaptionVisible(bool visible)
+{
+ if (is_vista) {
+ WIZ_WTA_OPTIONS opt;
+ opt.dwFlags = WIZ_WTNCA_NODRAWICON | WIZ_WTNCA_NODRAWCAPTION;
+ if (visible)
+ opt.dwMask = 0;
+ else
+ opt.dwMask = WIZ_WTNCA_NODRAWICON | WIZ_WTNCA_NODRAWCAPTION;
+ pSetWindowThemeAttribute(wizard->winId(), WIZ_WTA_NONCLIENT, &opt, sizeof(WIZ_WTA_OPTIONS));
+ }
+}
+
+bool QVistaHelper::winEvent(MSG* msg, long* result)
+{
+ bool retval = true;
+
+ switch (msg->message) {
+ case WM_NCHITTEST: {
+ LRESULT lResult;
+ pDwmDefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam, &lResult);
+ if (lResult == HTCLOSE || lResult == HTMAXBUTTON || lResult == HTMINBUTTON || lResult == HTHELP)
+ *result = lResult;
+ else
+ *result = DefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam);
+ break;
+ }
+ case WM_NCMOUSEMOVE:
+ case WM_NCLBUTTONDOWN:
+ case WM_NCLBUTTONUP:
+ case WIZ_WM_NCMOUSELEAVE: {
+ LRESULT lResult;
+ pDwmDefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam, &lResult);
+ *result = DefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam);
+ break;
+ }
+ case WM_NCCALCSIZE: {
+ NCCALCSIZE_PARAMS* lpncsp = (NCCALCSIZE_PARAMS*)msg->lParam;
+ *result = DefWindowProc(msg->hwnd, msg->message, msg->wParam, msg->lParam);
+ lpncsp->rgrc[0].top -= (vistaState() == VistaAero ? titleBarSize() : 0);
+ break;
+ }
+ default:
+ retval = false;
+ }
+
+ return retval;
+}
+
+void QVistaHelper::setMouseCursor(QPoint pos)
+{
+#ifndef QT_NO_CURSOR
+ if (rtTop.contains(pos))
+ wizard->setCursor(Qt::SizeVerCursor);
+ else
+ wizard->setCursor(Qt::ArrowCursor);
+#endif
+}
+
+void QVistaHelper::mouseEvent(QEvent *event)
+{
+ switch (event->type()) {
+ case QEvent::MouseMove:
+ mouseMoveEvent(static_cast<QMouseEvent *>(event));
+ break;
+ case QEvent::MouseButtonPress:
+ mousePressEvent(static_cast<QMouseEvent *>(event));
+ break;
+ case QEvent::MouseButtonRelease:
+ mouseReleaseEvent(static_cast<QMouseEvent *>(event));
+ break;
+ default:
+ break;
+ }
+}
+
+// The following hack ensures that the titlebar is updated correctly
+// when the wizard style changes to and from AeroStyle. Specifically,
+// this function causes a Windows message of type WM_NCCALCSIZE to
+// be triggered.
+void QVistaHelper::setWindowPosHack()
+{
+ const int x = wizard->geometry().x(); // ignored by SWP_NOMOVE
+ const int y = wizard->geometry().y(); // ignored by SWP_NOMOVE
+ const int w = wizard->width();
+ const int h = wizard->height();
+ SetWindowPos(wizard->winId(), 0, x, y, w, h, SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED);
+}
+
+// The following hack allows any QWidget subclass to access
+// QWidgetPrivate::topData() without being declared as a
+// friend by QWidget.
+class QHackWidget : public QWidget
+{
+public:
+ Q_DECLARE_PRIVATE(QWidget)
+ QTLWExtra* topData() { return d_func()->topData(); }
+};
+
+void QVistaHelper::collapseTopFrameStrut()
+{
+ QTLWExtra *top = ((QHackWidget *)wizard)->d_func()->topData();
+ int x1, y1, x2, y2;
+ top->frameStrut.getCoords(&x1, &y1, &x2, &y2);
+ top->frameStrut.setCoords(x1, 0, x2, y2);
+}
+
+bool QVistaHelper::handleWinEvent(MSG *message, long *result)
+{
+ if (message->message == WIZ_WM_THEMECHANGED || message->message == WIZ_WM_DWMCOMPOSITIONCHANGED)
+ cachedVistaState = Dirty;
+
+ bool status = false;
+ if (wizard->wizardStyle() == QWizard::AeroStyle && vistaState() == VistaAero) {
+ status = winEvent(message, result);
+ if (message->message == WM_NCCALCSIZE) {
+ if (status)
+ collapseTopFrameStrut();
+ } else if (message->message == WM_NCPAINT) {
+ wizard->update();
+ }
+ }
+ return status;
+}
+
+void QVistaHelper::resizeEvent(QResizeEvent * event)
+{
+ Q_UNUSED(event);
+ rtTop = QRect (0, 0, wizard->width(), frameSize());
+ int height = captionSize() + topOffset();
+ if (vistaState() == VistaBasic)
+ height -= titleBarSize();
+ rtTitle = QRect (0, frameSize(), wizard->width(), height);
+}
+
+void QVistaHelper::paintEvent(QPaintEvent *event)
+{
+ Q_UNUSED(event);
+ QPainter painter(wizard);
+ drawTitleBar(&painter);
+}
+
+void QVistaHelper::mouseMoveEvent(QMouseEvent *event)
+{
+ if (wizard->windowState() & Qt::WindowMaximized) {
+ event->ignore();
+ return;
+ }
+
+ QRect rect = wizard->geometry();
+ if (pressed) {
+ switch (change) {
+ case resizeTop:
+ {
+ const int dy = event->pos().y() - pressedPos.y();
+ if ((dy > 0 && rect.height() > wizard->minimumHeight())
+ || (dy < 0 && rect.height() < wizard->maximumHeight()))
+ rect.setTop(rect.top() + dy);
+ }
+ break;
+ case movePosition: {
+ QPoint newPos = event->pos() - pressedPos;
+ rect.moveLeft(rect.left() + newPos.x());
+ rect.moveTop(rect.top() + newPos.y());
+ break; }
+ default:
+ break;
+ }
+ wizard->setGeometry(rect);
+
+ } else if (vistaState() == VistaAero) {
+ setMouseCursor(event->pos());
+ }
+ event->ignore();
+}
+
+void QVistaHelper::mousePressEvent(QMouseEvent *event)
+{
+ change = noChange;
+
+ if (wizard->windowState() & Qt::WindowMaximized) {
+ event->ignore();
+ return;
+ }
+
+ if (rtTitle.contains(event->pos())) {
+ change = movePosition;
+ } else if (rtTop.contains(event->pos()))
+ change = (vistaState() == VistaAero) ? resizeTop : movePosition;
+
+ if (change != noChange) {
+ if (vistaState() == VistaAero)
+ setMouseCursor(event->pos());
+ pressed = true;
+ pressedPos = event->pos();
+ } else {
+ event->ignore();
+ }
+}
+
+void QVistaHelper::mouseReleaseEvent(QMouseEvent *event)
+{
+ change = noChange;
+ if (pressed) {
+ pressed = false;
+ wizard->releaseMouse();
+ if (vistaState() == VistaAero)
+ setMouseCursor(event->pos());
+ }
+ event->ignore();
+}
+
+bool QVistaHelper::eventFilter(QObject *obj, QEvent *event)
+{
+ if (obj != wizard)
+ return QObject::eventFilter(obj, event);
+
+ if (event->type() == QEvent::MouseMove) {
+ QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
+ long result;
+ MSG msg;
+ msg.message = WM_NCHITTEST;
+ msg.wParam = 0;
+ msg.lParam = MAKELPARAM(mouseEvent->globalX(), mouseEvent->globalY());
+ msg.hwnd = wizard->winId();
+ winEvent(&msg, &result);
+ msg.wParam = result;
+ msg.message = WM_NCMOUSEMOVE;
+ winEvent(&msg, &result);
+ } else if (event->type() == QEvent::MouseButtonPress) {
+ QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
+ long result;
+ MSG msg;
+ msg.message = WM_NCHITTEST;
+ msg.wParam = 0;
+ msg.lParam = MAKELPARAM(mouseEvent->globalX(), mouseEvent->globalY());
+ msg.hwnd = wizard->winId();
+ winEvent(&msg, &result);
+ msg.wParam = result;
+ msg.message = WM_NCLBUTTONDOWN;
+ winEvent(&msg, &result);
+ } else if (event->type() == QEvent::MouseButtonRelease) {
+ QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
+ long result;
+ MSG msg;
+ msg.message = WM_NCHITTEST;
+ msg.wParam = 0;
+ msg.lParam = MAKELPARAM(mouseEvent->globalX(), mouseEvent->globalY());
+ msg.hwnd = wizard->winId();
+ winEvent(&msg, &result);
+ msg.wParam = result;
+ msg.message = WM_NCLBUTTONUP;
+ winEvent(&msg, &result);
+ }
+
+ return false;
+}
+
+HFONT QVistaHelper::getCaptionFont(HANDLE hTheme)
+{
+ LOGFONT lf = {0};
+
+ if (!hTheme)
+ pGetThemeSysFont(hTheme, WIZ_TMT_CAPTIONFONT, &lf);
+ else
+ {
+ NONCLIENTMETRICS ncm = {sizeof(NONCLIENTMETRICS)};
+ SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, false);
+ lf = ncm.lfMessageFont;
+ }
+ return CreateFontIndirect(&lf);
+}
+
+bool QVistaHelper::drawTitleText(QPainter *painter, const QString &text, const QRect &rect, HDC hdc)
+{
+ bool value = false;
+ if (vistaState() == VistaAero) {
+ HANDLE hTheme = pOpenThemeData(QApplication::desktop()->winId(), L"WINDOW");
+ if (!hTheme) return false;
+ // Set up a memory DC and bitmap that we'll draw into
+ HDC dcMem;
+ HBITMAP bmp;
+ BITMAPINFO dib = {{0}};
+ dcMem = CreateCompatibleDC(hdc);
+
+ dib.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ dib.bmiHeader.biWidth = rect.width();
+ dib.bmiHeader.biHeight = -rect.height();
+ dib.bmiHeader.biPlanes = 1;
+ dib.bmiHeader.biBitCount = 32;
+ dib.bmiHeader.biCompression = BI_RGB;
+
+ bmp = CreateDIBSection(hdc, &dib, DIB_RGB_COLORS, NULL, NULL, 0);
+
+ // Set up the DC
+ HFONT hCaptionFont = getCaptionFont(hTheme);
+ HBITMAP hOldBmp = (HBITMAP)SelectObject(dcMem, (HGDIOBJ) bmp);
+ HFONT hOldFont = (HFONT)SelectObject(dcMem, (HGDIOBJ) hCaptionFont);
+
+ // Draw the text!
+ WIZ_DTTOPTS dto = { sizeof(WIZ_DTTOPTS) };
+ const UINT uFormat = WIZ_DT_SINGLELINE|WIZ_DT_CENTER|WIZ_DT_VCENTER|WIZ_DT_NOPREFIX;
+ RECT rctext ={0,0, rect.width(), rect.height()};
+
+ dto.dwFlags = WIZ_DTT_COMPOSITED|WIZ_DTT_GLOWSIZE;
+ dto.iGlowSize = glowSize();
+
+ pDrawThemeTextEx(hTheme, dcMem, 0, 0, (LPCWSTR)text.utf16(), -1, uFormat, &rctext, &dto );
+ BitBlt(hdc, rect.left(), rect.top(), rect.width(), rect.height(), dcMem, 0, 0, SRCCOPY);
+ SelectObject(dcMem, (HGDIOBJ) hOldBmp);
+ SelectObject(dcMem, (HGDIOBJ) hOldFont);
+ DeleteObject(bmp);
+ DeleteObject(hCaptionFont);
+ DeleteDC(dcMem);
+ //ReleaseDC(hwnd, hdc);
+ } else if (vistaState() == VistaBasic) {
+ painter->drawText(rect, text);
+ }
+ return value;
+}
+
+bool QVistaHelper::drawBlackRect(const QRect &rect, HDC hdc)
+{
+ bool value = false;
+ if (vistaState() == VistaAero) {
+ // Set up a memory DC and bitmap that we'll draw into
+ HDC dcMem;
+ HBITMAP bmp;
+ BITMAPINFO dib = {{0}};
+ dcMem = CreateCompatibleDC(hdc);
+
+ dib.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+ dib.bmiHeader.biWidth = rect.width();
+ dib.bmiHeader.biHeight = -rect.height();
+ dib.bmiHeader.biPlanes = 1;
+ dib.bmiHeader.biBitCount = 32;
+ dib.bmiHeader.biCompression = BI_RGB;
+
+ bmp = CreateDIBSection(hdc, &dib, DIB_RGB_COLORS, NULL, NULL, 0);
+ HBITMAP hOldBmp = (HBITMAP)SelectObject(dcMem, (HGDIOBJ) bmp);
+
+ BitBlt(hdc, rect.left(), rect.top(), rect.width(), rect.height(), dcMem, 0, 0, SRCCOPY);
+ SelectObject(dcMem, (HGDIOBJ) hOldBmp);
+
+ DeleteObject(bmp);
+ DeleteDC(dcMem);
+ }
+ return value;
+}
+
+bool QVistaHelper::resolveSymbols()
+{
+ static bool tried = false;
+ if (!tried) {
+ tried = true;
+ QSystemLibrary dwmLib(L"dwmapi");
+ pDwmIsCompositionEnabled =
+ (PtrDwmIsCompositionEnabled)dwmLib.resolve("DwmIsCompositionEnabled");
+ if (pDwmIsCompositionEnabled) {
+ pDwmDefWindowProc = (PtrDwmDefWindowProc)dwmLib.resolve("DwmDefWindowProc");
+ pDwmExtendFrameIntoClientArea =
+ (PtrDwmExtendFrameIntoClientArea)dwmLib.resolve("DwmExtendFrameIntoClientArea");
+ }
+ QSystemLibrary themeLib(L"uxtheme");
+ pIsAppThemed = (PtrIsAppThemed)themeLib.resolve("IsAppThemed");
+ if (pIsAppThemed) {
+ pDrawThemeBackground = (PtrDrawThemeBackground)themeLib.resolve("DrawThemeBackground");
+ pGetThemePartSize = (PtrGetThemePartSize)themeLib.resolve("GetThemePartSize");
+ pGetThemeColor = (PtrGetThemeColor)themeLib.resolve("GetThemeColor");
+ pIsThemeActive = (PtrIsThemeActive)themeLib.resolve("IsThemeActive");
+ pOpenThemeData = (PtrOpenThemeData)themeLib.resolve("OpenThemeData");
+ pCloseThemeData = (PtrCloseThemeData)themeLib.resolve("CloseThemeData");
+ pGetThemeSysFont = (PtrGetThemeSysFont)themeLib.resolve("GetThemeSysFont");
+ pDrawThemeTextEx = (PtrDrawThemeTextEx)themeLib.resolve("DrawThemeTextEx");
+ pSetWindowThemeAttribute = (PtrSetWindowThemeAttribute)themeLib.resolve("SetWindowThemeAttribute");
+ }
+ }
+
+ return (
+ pDwmIsCompositionEnabled != 0
+ && pDwmDefWindowProc != 0
+ && pDwmExtendFrameIntoClientArea != 0
+ && pIsAppThemed != 0
+ && pDrawThemeBackground != 0
+ && pGetThemePartSize != 0
+ && pGetThemeColor != 0
+ && pIsThemeActive != 0
+ && pOpenThemeData != 0
+ && pCloseThemeData != 0
+ && pGetThemeSysFont != 0
+ && pDrawThemeTextEx != 0
+ && pSetWindowThemeAttribute != 0
+ );
+}
+
+int QVistaHelper::titleOffset()
+{
+ int iconOffset = wizard ->windowIcon().isNull() ? 0 : iconSize() + textSpacing;
+ return leftMargin() + iconOffset;
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_STYLE_WINDOWSVISTA
+
+#endif // QT_NO_WIZARD
diff --git a/src/gui/dialogs/qwizard_win_p.h b/src/widgets/dialogs/qwizard_win_p.h
index b76f08264d..b76f08264d 100644
--- a/src/gui/dialogs/qwizard_win_p.h
+++ b/src/widgets/dialogs/qwizard_win_p.h
diff --git a/src/widgets/effects/effects.pri b/src/widgets/effects/effects.pri
new file mode 100644
index 0000000000..a21f941866
--- /dev/null
+++ b/src/widgets/effects/effects.pri
@@ -0,0 +1,6 @@
+HEADERS += effects/qgraphicseffect.h \
+ effects/qgraphicseffect_p.h \
+ effects/qpixmapfilter_p.h
+
+SOURCES += effects/qgraphicseffect.cpp \
+ effects/qpixmapfilter.cpp
diff --git a/src/widgets/effects/qgraphicseffect.cpp b/src/widgets/effects/qgraphicseffect.cpp
new file mode 100644
index 0000000000..762fc83796
--- /dev/null
+++ b/src/widgets/effects/qgraphicseffect.cpp
@@ -0,0 +1,1235 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \class QGraphicsEffect
+ \brief The QGraphicsEffect class is the base class for all graphics
+ effects.
+ \since 4.6
+ \ingroup multimedia
+ \ingroup graphicsview-api
+
+ Effects alter the appearance of elements by hooking into the rendering
+ pipeline and operating between the source (e.g., a QGraphicsPixmapItem)
+ and the destination device (e.g., QGraphicsView's viewport). Effects can be
+ disabled by calling setEnabled(false). If effects are disabled, the source
+ is rendered directly.
+
+ To add a visual effect to a QGraphicsItem, for example, you can use one of
+ the standard effects, or alternately, create your own effect by creating a
+ subclass of QGraphicsEffect. The effect can then be installed on the item
+ using QGraphicsItem::setGraphicsEffect().
+
+ Qt provides the following standard effects:
+
+ \list
+ \o QGraphicsBlurEffect - blurs the item by a given radius
+ \o QGraphicsDropShadowEffect - renders a dropshadow behind the item
+ \o QGraphicsColorizeEffect - renders the item in shades of any given color
+ \o QGraphicsOpacityEffect - renders the item with an opacity
+ \endlist
+
+ \table
+ \row
+ \o{2,1} \img graphicseffect-plain.png
+ \row
+ \o \img graphicseffect-blur.png
+ \o \img graphicseffect-colorize.png
+ \row
+ \o \img graphicseffect-opacity.png
+ \o \img graphicseffect-drop-shadow.png
+ \endtable
+
+ \img graphicseffect-widget.png
+
+ For more information on how to use each effect, refer to the specific
+ effect's documentation.
+
+ To create your own custom effect, create a subclass of QGraphicsEffect (or
+ any other existing effects) and reimplement the virtual function draw().
+ This function is called whenever the effect needs to redraw. The draw()
+ function takes the painter with which to draw as an argument. For more
+ information, refer to the documenation for draw(). In the draw() function
+ you can call sourcePixmap() to get a pixmap of the graphics effect source
+ which you can then process.
+
+ If your effect changes, use update() to request for a redraw. If your
+ custom effect changes the bounding rectangle of the source, e.g., a radial
+ glow effect may need to apply an extra margin, you can reimplement the
+ virtual boundingRectFor() function, and call updateBoundingRect()
+ to notify the framework whenever this rectangle changes. The virtual
+ sourceChanged() function is called to notify the effects that
+ the source has changed in some way - e.g., if the source is a
+ QGraphicsRectItem and its rectangle parameters have changed.
+
+ \sa QGraphicsItem::setGraphicsEffect(), QWidget::setGraphicsEffect()
+*/
+
+#include "qgraphicseffect_p.h"
+#include "private/qgraphicsitem_p.h"
+
+#include <QtWidgets/qgraphicsitem.h>
+
+#include <QtGui/qimage.h>
+#include <QtGui/qpainter.h>
+#include <QtGui/qpaintengine.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qdebug.h>
+#include <private/qdrawhelper_p.h>
+
+#ifndef QT_NO_GRAPHICSEFFECT
+QT_BEGIN_NAMESPACE
+
+/*!
+ \internal
+ \class QGraphicsEffectSource
+ \brief The QGraphicsEffectSource class represents the source on which a
+ QGraphicsEffect is installed on.
+
+ When a QGraphicsEffect is installed on a QGraphicsItem, for example, this
+ class will act as a wrapper around QGraphicsItem. Then, calling update() is
+ effectively the same as calling QGraphicsItem::update().
+
+ QGraphicsEffectSource also provides a pixmap() function which creates a
+ pixmap with the source painted into it.
+
+ \sa QGraphicsItem::setGraphicsEffect(), QWidget::setGraphicsEffect().
+*/
+
+/*!
+ \internal
+*/
+QGraphicsEffectSource::QGraphicsEffectSource(QGraphicsEffectSourcePrivate &dd, QObject *parent)
+ : QObject(dd, parent)
+{}
+
+/*!
+ Destroys the effect source.
+*/
+QGraphicsEffectSource::~QGraphicsEffectSource()
+{}
+
+/*!
+ Returns the bounding rectangle of the source mapped to the given \a system.
+
+ \sa draw()
+*/
+QRectF QGraphicsEffectSource::boundingRect(Qt::CoordinateSystem system) const
+{
+ return d_func()->boundingRect(system);
+}
+
+/*!
+ Returns the bounding rectangle of the source mapped to the given \a system.
+
+ Calling this function with Qt::DeviceCoordinates outside of
+ QGraphicsEffect::draw() will give undefined results, as there is no device
+ context available.
+
+ \sa draw()
+*/
+QRectF QGraphicsEffect::sourceBoundingRect(Qt::CoordinateSystem system) const
+{
+ Q_D(const QGraphicsEffect);
+ if (d->source)
+ return d->source->boundingRect(system);
+ return QRectF();
+}
+
+/*!
+ Returns a pointer to the item if this source is a QGraphicsItem; otherwise
+ returns 0.
+
+ \sa widget()
+*/
+const QGraphicsItem *QGraphicsEffectSource::graphicsItem() const
+{
+ return d_func()->graphicsItem();
+}
+
+/*!
+ Returns a pointer to the widget if this source is a QWidget; otherwise
+ returns 0.
+
+ \sa graphicsItem()
+*/
+const QWidget *QGraphicsEffectSource::widget() const
+{
+ return d_func()->widget();
+}
+
+/*!
+ Returns a pointer to the style options (used when drawing the source) if
+ available; otherwise returns 0.
+
+ \sa graphicsItem(), widget()
+*/
+const QStyleOption *QGraphicsEffectSource::styleOption() const
+{
+ return d_func()->styleOption();
+}
+
+/*!
+ Draws the source using the given \a painter.
+
+ This function should only be called from QGraphicsEffect::draw().
+
+ \sa QGraphicsEffect::draw()
+*/
+void QGraphicsEffectSource::draw(QPainter *painter)
+{
+ Q_D(const QGraphicsEffectSource);
+
+ QPixmap pm;
+ if (QPixmapCache::find(d->m_cacheKey, &pm)) {
+ QTransform restoreTransform;
+ if (d->m_cachedSystem == Qt::DeviceCoordinates) {
+ restoreTransform = painter->worldTransform();
+ painter->setWorldTransform(QTransform());
+ }
+
+ painter->drawPixmap(d->m_cachedOffset, pm);
+
+ if (d->m_cachedSystem == Qt::DeviceCoordinates)
+ painter->setWorldTransform(restoreTransform);
+ } else {
+ d_func()->draw(painter);
+ }
+}
+
+/*!
+ Draws the source directly using the given \a painter.
+
+ This function should only be called from QGraphicsEffect::draw().
+
+ For example:
+
+ \snippet doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp 0
+
+ \sa QGraphicsEffect::draw()
+*/
+void QGraphicsEffect::drawSource(QPainter *painter)
+{
+ Q_D(const QGraphicsEffect);
+ if (d->source)
+ d->source->draw(painter);
+}
+
+/*!
+ Schedules a redraw of the source. Call this function whenever the source
+ needs to be redrawn.
+
+ \sa QGraphicsEffect::updateBoundingRect(), QWidget::update(),
+ QGraphicsItem::update(),
+*/
+void QGraphicsEffectSource::update()
+{
+ d_func()->update();
+}
+
+/*!
+ Returns true if the source effectively is a pixmap, e.g., a
+ QGraphicsPixmapItem.
+
+ This function is useful for optimization purposes. For instance, there's no
+ point in drawing the source in device coordinates to avoid pixmap scaling
+ if this function returns true - the source pixmap will be scaled anyways.
+*/
+bool QGraphicsEffectSource::isPixmap() const
+{
+ return d_func()->isPixmap();
+}
+
+/*!
+ Returns true if the source effectively is a pixmap, e.g., a
+ QGraphicsPixmapItem.
+
+ This function is useful for optimization purposes. For instance, there's no
+ point in drawing the source in device coordinates to avoid pixmap scaling
+ if this function returns true - the source pixmap will be scaled anyways.
+*/
+bool QGraphicsEffect::sourceIsPixmap() const
+{
+ return source() ? source()->isPixmap() : false;
+}
+
+/*!
+ Returns a pixmap with the source painted into it.
+
+ The \a system specifies which coordinate system to be used for the source.
+ The optional \a offset parameter returns the offset where the pixmap should
+ be painted at using the current painter.
+
+ The \a mode determines how much of the effect the pixmap will contain.
+ By default, the pixmap will contain the whole effect.
+
+ The returned pixmap is bound to the current painter's device rectangle when
+ \a system is Qt::DeviceCoordinates.
+
+ \sa QGraphicsEffect::draw(), boundingRect()
+*/
+QPixmap QGraphicsEffectSource::pixmap(Qt::CoordinateSystem system, QPoint *offset, QGraphicsEffect::PixmapPadMode mode) const
+{
+ Q_D(const QGraphicsEffectSource);
+
+ // Shortcut, no cache for childless pixmap items...
+ const QGraphicsItem *item = graphicsItem();
+ if (system == Qt::LogicalCoordinates && mode == QGraphicsEffect::NoPad && item && isPixmap()) {
+ const QGraphicsPixmapItem *pixmapItem = static_cast<const QGraphicsPixmapItem *>(item);
+ if (offset)
+ *offset = pixmapItem->offset().toPoint();
+ return pixmapItem->pixmap();
+ }
+
+ if (system == Qt::DeviceCoordinates && item
+ && !static_cast<const QGraphicsItemEffectSourcePrivate *>(d_func())->info) {
+ qWarning("QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context");
+ return QPixmap();
+ }
+
+ QPixmap pm;
+ if (item && d->m_cachedSystem == system && d->m_cachedMode == mode)
+ QPixmapCache::find(d->m_cacheKey, &pm);
+
+ if (pm.isNull()) {
+ pm = d->pixmap(system, &d->m_cachedOffset, mode);
+ d->m_cachedSystem = system;
+ d->m_cachedMode = mode;
+
+ d->invalidateCache();
+ d->m_cacheKey = QPixmapCache::insert(pm);
+ }
+
+ if (offset)
+ *offset = d->m_cachedOffset;
+
+ return pm;
+}
+
+/*!
+ Returns a pixmap with the source painted into it.
+
+ The \a system specifies which coordinate system to be used for the source.
+ The optional \a offset parameter returns the offset where the pixmap should
+ be painted at using the current painter. For control on how the pixmap is
+ padded use the \a mode parameter.
+
+ The returned pixmap is clipped to the current painter's device rectangle when
+ \a system is Qt::DeviceCoordinates.
+
+ Calling this function with Qt::DeviceCoordinates outside of
+ QGraphicsEffect::draw() will give undefined results, as there is no device
+ context available.
+
+ \sa draw(), boundingRect()
+*/
+QPixmap QGraphicsEffect::sourcePixmap(Qt::CoordinateSystem system, QPoint *offset, QGraphicsEffect::PixmapPadMode mode) const
+{
+ Q_D(const QGraphicsEffect);
+ if (d->source)
+ return d->source->pixmap(system, offset, mode);
+ return QPixmap();
+}
+
+QGraphicsEffectSourcePrivate::~QGraphicsEffectSourcePrivate()
+{
+ invalidateCache();
+}
+
+void QGraphicsEffectSourcePrivate::setCachedOffset(const QPoint &offset)
+{
+ m_cachedOffset = offset;
+}
+
+void QGraphicsEffectSourcePrivate::invalidateCache(InvalidateReason reason) const
+{
+ if (m_cachedMode != QGraphicsEffect::PadToEffectiveBoundingRect
+ && (reason == EffectRectChanged
+ || (reason == TransformChanged && m_cachedSystem == Qt::LogicalCoordinates))) {
+ return;
+ }
+
+ QPixmapCache::remove(m_cacheKey);
+}
+
+/*!
+ Constructs a new QGraphicsEffect instance having the
+ specified \a parent.
+*/
+QGraphicsEffect::QGraphicsEffect(QObject *parent)
+ : QObject(*new QGraphicsEffectPrivate, parent)
+{
+}
+
+/*!
+ \internal
+*/
+QGraphicsEffect::QGraphicsEffect(QGraphicsEffectPrivate &dd, QObject *parent)
+ : QObject(dd, parent)
+{
+}
+
+/*!
+ Removes the effect from the source, and destroys the graphics effect.
+*/
+QGraphicsEffect::~QGraphicsEffect()
+{
+ Q_D(QGraphicsEffect);
+ d->setGraphicsEffectSource(0);
+}
+
+/*!
+ Returns the effective bounding rectangle for this effect, i.e., the
+ bounding rectangle of the source in device coordinates, adjusted by
+ any margins applied by the effect itself.
+
+ \sa boundingRectFor(), updateBoundingRect()
+*/
+QRectF QGraphicsEffect::boundingRect() const
+{
+ Q_D(const QGraphicsEffect);
+ if (d->source)
+ return boundingRectFor(d->source->boundingRect());
+ return QRectF();
+}
+
+/*!
+ Returns the effective bounding rectangle for this effect, given the
+ provided \a rect in the device coordinates. When writing
+ you own custom effect, you must call updateBoundingRect() whenever any
+ parameters are changed that may cause this this function to return a
+ different value.
+
+ \sa sourceBoundingRect()
+*/
+QRectF QGraphicsEffect::boundingRectFor(const QRectF &rect) const
+{
+ return rect;
+}
+
+/*!
+ \property QGraphicsEffect::enabled
+ \brief whether the effect is enabled or not.
+
+ If an effect is disabled, the source will be rendered with as normal, with
+ no interference from the effect. If the effect is enabled, the source will
+ be rendered with the effect applied.
+
+ This property is enabled by default.
+
+ Using this property, you can disable certain effects on slow platforms, in
+ order to ensure that the user interface is responsive.
+*/
+bool QGraphicsEffect::isEnabled() const
+{
+ Q_D(const QGraphicsEffect);
+ return d->isEnabled;
+}
+
+void QGraphicsEffect::setEnabled(bool enable)
+{
+ Q_D(QGraphicsEffect);
+ if (d->isEnabled == enable)
+ return;
+
+ d->isEnabled = enable;
+ if (d->source) {
+ d->source->d_func()->effectBoundingRectChanged();
+ d->source->d_func()->invalidateCache();
+ }
+ emit enabledChanged(enable);
+}
+
+/*!
+ \fn void QGraphicsEffect::enabledChanged(bool enabled)
+
+ This signal is emitted whenever the effect is enabled or disabled.
+ The \a enabled parameter holds the effects's new enabled state.
+
+ \sa isEnabled()
+*/
+
+/*!
+ Schedules a redraw of the effect. Call this function whenever the effect
+ needs to be redrawn. This function does not trigger a redraw of the source.
+
+ \sa updateBoundingRect()
+*/
+void QGraphicsEffect::update()
+{
+ Q_D(QGraphicsEffect);
+ if (d->source)
+ d->source->update();
+}
+
+/*!
+ \internal
+
+ Returns a pointer to the source, which provides extra context information
+ that can be useful for the effect.
+
+ \sa draw()
+*/
+QGraphicsEffectSource *QGraphicsEffect::source() const
+{
+ Q_D(const QGraphicsEffect);
+ return d->source;
+}
+
+/*!
+ This function notifies the effect framework when the effect's bounding
+ rectangle has changed. As a custom effect author, you must call this
+ function whenever you change any parameters that will cause the virtual
+ boundingRectFor() function to return a different value.
+
+ This function will call update() if this is necessary.
+
+ \sa boundingRectFor(), boundingRect(), sourceBoundingRect()
+*/
+void QGraphicsEffect::updateBoundingRect()
+{
+ Q_D(QGraphicsEffect);
+ if (d->source) {
+ d->source->d_func()->effectBoundingRectChanged();
+ d->source->d_func()->invalidateCache(QGraphicsEffectSourcePrivate::EffectRectChanged);
+ }
+}
+
+/*!
+ \fn virtual void QGraphicsEffect::draw(QPainter *painter) = 0
+
+ This pure virtual function draws the effect and is called whenever the
+ source needs to be drawn.
+
+ Reimplement this function in a QGraphicsEffect subclass to provide the
+ effect's drawing implementation, using \a painter.
+
+ For example:
+
+ \snippet doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp 1
+
+ This function should not be called explicitly by the user, since it is
+ meant for reimplementation purposes only.
+*/
+
+/*!
+ \enum QGraphicsEffect::ChangeFlag
+
+ This enum describes what has changed in QGraphicsEffectSource.
+
+ \value SourceAttached The effect is installed on a source.
+ \value SourceDetached The effect is uninstalled on a source.
+ \value SourceBoundingRectChanged The bounding rect of the source has
+ changed.
+ \value SourceInvalidated The visual appearance of the source has changed.
+*/
+
+/*!
+ \enum QGraphicsEffect::PixmapPadMode
+
+ This enum describes how the pixmap returned from sourcePixmap should be
+ padded.
+
+ \value NoPad The pixmap should not receive any additional
+ padding.
+ \value PadToTransparentBorder The pixmap should be padded
+ to ensure it has a completely transparent border.
+ \value PadToEffectiveBoundingRect The pixmap should be padded to
+ match the effective bounding rectangle of the effect.
+*/
+
+/*!
+ This virtual function is called by QGraphicsEffect to notify the effect
+ that the source has changed. If the effect applies any cache, then this
+ cache must be purged in order to reflect the new appearance of the source.
+
+ The \a flags describes what has changed.
+*/
+void QGraphicsEffect::sourceChanged(ChangeFlags flags)
+{
+ Q_UNUSED(flags);
+}
+
+/*!
+ \class QGraphicsColorizeEffect
+ \brief The QGraphicsColorizeEffect class provides a colorize effect.
+ \since 4.6
+
+ A colorize effect renders the source with a tint of its color(). The color
+ can be modified using the setColor() function.
+
+ By default, the color is light blue (QColor(0, 0, 192)).
+
+ \img graphicseffect-colorize.png
+
+ \sa QGraphicsDropShadowEffect, QGraphicsBlurEffect, QGraphicsOpacityEffect
+*/
+
+/*!
+ Constructs a new QGraphicsColorizeEffect instance.
+ The \a parent parameter is passed to QGraphicsEffect's constructor.
+*/
+QGraphicsColorizeEffect::QGraphicsColorizeEffect(QObject *parent)
+ : QGraphicsEffect(*new QGraphicsColorizeEffectPrivate, parent)
+{
+}
+
+/*!
+ Destroys the effect.
+*/
+QGraphicsColorizeEffect::~QGraphicsColorizeEffect()
+{
+}
+
+/*!
+ \property QGraphicsColorizeEffect::color
+ \brief the color of the effect.
+
+ By default, the color is light blue (QColor(0, 0, 192)).
+*/
+QColor QGraphicsColorizeEffect::color() const
+{
+ Q_D(const QGraphicsColorizeEffect);
+ return d->filter->color();
+}
+
+void QGraphicsColorizeEffect::setColor(const QColor &color)
+{
+ Q_D(QGraphicsColorizeEffect);
+ if (d->filter->color() == color)
+ return;
+
+ d->filter->setColor(color);
+ update();
+ emit colorChanged(color);
+}
+
+/*!
+ \property QGraphicsColorizeEffect::strength
+ \brief the strength of the effect.
+
+ By default, the strength is 1.0.
+ A strength 0.0 equals to no effect, while 1.0 means full colorization.
+*/
+qreal QGraphicsColorizeEffect::strength() const
+{
+ Q_D(const QGraphicsColorizeEffect);
+ return d->filter->strength();
+}
+
+void QGraphicsColorizeEffect::setStrength(qreal strength)
+{
+ Q_D(QGraphicsColorizeEffect);
+ if (qFuzzyCompare(d->filter->strength(), strength))
+ return;
+
+ d->filter->setStrength(strength);
+ d->opaque = !qFuzzyIsNull(strength);
+ update();
+ emit strengthChanged(strength);
+}
+
+/*! \fn void QGraphicsColorizeEffect::strengthChanged(qreal strength)
+ This signal is emitted whenever setStrength() changes the colorize
+ strength property. \a strength contains the new strength value of
+ the colorize effect.
+ */
+
+/*!
+ \fn void QGraphicsColorizeEffect::colorChanged(const QColor &color)
+
+ This signal is emitted whenever the effect's color changes.
+ The \a color parameter holds the effect's new color.
+*/
+
+/*!
+ \reimp
+*/
+void QGraphicsColorizeEffect::draw(QPainter *painter)
+{
+ Q_D(QGraphicsColorizeEffect);
+
+ if (!d->opaque) {
+ drawSource(painter);
+ return;
+ }
+
+ QPoint offset;
+ if (sourceIsPixmap()) {
+ // No point in drawing in device coordinates (pixmap will be scaled anyways).
+ const QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset, NoPad);
+ if (!pixmap.isNull())
+ d->filter->draw(painter, offset, pixmap);
+
+ return;
+ }
+
+ // Draw pixmap in deviceCoordinates to avoid pixmap scaling.
+ const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset);
+ if (pixmap.isNull())
+ return;
+
+ QTransform restoreTransform = painter->worldTransform();
+ painter->setWorldTransform(QTransform());
+ d->filter->draw(painter, offset, pixmap);
+ painter->setWorldTransform(restoreTransform);
+}
+
+/*!
+ \class QGraphicsBlurEffect
+ \brief The QGraphicsBlurEffect class provides a blur effect.
+ \since 4.6
+
+ A blur effect blurs the source. This effect is useful for reducing details,
+ such as when the source loses focus and you want to draw attention to other
+ elements. The level of detail can be modified using the setBlurRadius()
+ function. Use setBlurHints() to choose the blur hints.
+
+ By default, the blur radius is 5 pixels. The blur radius is specified in
+ device coordinates.
+
+ \img graphicseffect-blur.png
+
+ \sa QGraphicsDropShadowEffect, QGraphicsColorizeEffect, QGraphicsOpacityEffect
+*/
+
+/*!
+ \enum QGraphicsBlurEffect::BlurHint
+ \since 4.6
+
+ This enum describes the possible hints that can be used to control how
+ blur effects are applied. The hints might not have an effect in all the
+ paint engines.
+
+ \value PerformanceHint Indicates that rendering performance is the most important factor,
+ at the potential cost of lower quality.
+
+ \value QualityHint Indicates that rendering quality is the most important factor,
+ at the potential cost of lower performance.
+
+ \value AnimationHint Indicates that the blur radius is going to be animated, hinting
+ that the implementation can keep a cache of blurred verisons of the source.
+ Do not use this hint if the source is going to be dynamically changing.
+
+ \sa blurHints(), setBlurHints()
+*/
+
+
+/*!
+ Constructs a new QGraphicsBlurEffect instance.
+ The \a parent parameter is passed to QGraphicsEffect's constructor.
+*/
+QGraphicsBlurEffect::QGraphicsBlurEffect(QObject *parent)
+ : QGraphicsEffect(*new QGraphicsBlurEffectPrivate, parent)
+{
+ Q_D(QGraphicsBlurEffect);
+ d->filter->setBlurHints(QGraphicsBlurEffect::PerformanceHint);
+}
+
+/*!
+ Destroys the effect.
+*/
+QGraphicsBlurEffect::~QGraphicsBlurEffect()
+{
+}
+
+/*!
+ \property QGraphicsBlurEffect::blurRadius
+ \brief the blur radius of the effect.
+
+ Using a smaller radius results in a sharper appearance, whereas a bigger
+ radius results in a more blurred appearance.
+
+ By default, the blur radius is 5 pixels.
+
+ The radius is given in device coordinates, meaning it is
+ unaffected by scale.
+*/
+qreal QGraphicsBlurEffect::blurRadius() const
+{
+ Q_D(const QGraphicsBlurEffect);
+ return d->filter->radius();
+}
+
+void QGraphicsBlurEffect::setBlurRadius(qreal radius)
+{
+ Q_D(QGraphicsBlurEffect);
+ if (qFuzzyCompare(d->filter->radius(), radius))
+ return;
+
+ d->filter->setRadius(radius);
+ updateBoundingRect();
+ emit blurRadiusChanged(radius);
+}
+
+/*!
+ \fn void QGraphicsBlurEffect::blurRadiusChanged(qreal radius)
+
+ This signal is emitted whenever the effect's blur radius changes.
+ The \a radius parameter holds the effect's new blur radius.
+*/
+
+/*!
+ \property QGraphicsBlurEffect::blurHints
+ \brief the blur hint of the effect.
+
+ Use the PerformanceHint hint to say that you want a faster blur,
+ the QualityHint hint to say that you prefer a higher quality blur,
+ or the AnimationHint when you want to animate the blur radius.
+
+ By default, the blur hint is PerformanceHint.
+*/
+QGraphicsBlurEffect::BlurHints QGraphicsBlurEffect::blurHints() const
+{
+ Q_D(const QGraphicsBlurEffect);
+ return d->filter->blurHints();
+}
+
+void QGraphicsBlurEffect::setBlurHints(QGraphicsBlurEffect::BlurHints hints)
+{
+ Q_D(QGraphicsBlurEffect);
+ if (d->filter->blurHints() == hints)
+ return;
+
+ d->filter->setBlurHints(hints);
+ emit blurHintsChanged(hints);
+}
+
+/*!
+ \fn void QGraphicsBlurEffect::blurHintsChanged(QGraphicsBlurEffect::BlurHints hints)
+
+ This signal is emitted whenever the effect's blur hints changes.
+ The \a hints parameter holds the effect's new blur hints.
+*/
+
+/*!
+ \reimp
+*/
+QRectF QGraphicsBlurEffect::boundingRectFor(const QRectF &rect) const
+{
+ Q_D(const QGraphicsBlurEffect);
+ return d->filter->boundingRectFor(rect);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsBlurEffect::draw(QPainter *painter)
+{
+ Q_D(QGraphicsBlurEffect);
+ if (d->filter->radius() < 1) {
+ drawSource(painter);
+ return;
+ }
+
+ PixmapPadMode mode = PadToEffectiveBoundingRect;
+ if (painter->paintEngine()->type() == QPaintEngine::OpenGL2)
+ mode = NoPad;
+
+ QPoint offset;
+ QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset, mode);
+ if (pixmap.isNull())
+ return;
+
+ d->filter->draw(painter, offset, pixmap);
+}
+
+/*!
+ \class QGraphicsDropShadowEffect
+ \brief The QGraphicsDropShadowEffect class provides a drop shadow effect.
+ \since 4.6
+
+ A drop shadow effect renders the source with a drop shadow. The color of
+ the drop shadow can be modified using the setColor() function. The drop
+ shadow offset can be modified using the setOffset() function and the blur
+ radius of the drop shadow can be changed with the setBlurRadius()
+ function.
+
+ By default, the drop shadow is a semi-transparent dark gray
+ (QColor(63, 63, 63, 180)) shadow, blurred with a radius of 1 at an offset
+ of 8 pixels towards the lower right. The drop shadow offset is specified
+ in device coordinates.
+
+ \img graphicseffect-drop-shadow.png
+
+ \sa QGraphicsBlurEffect, QGraphicsColorizeEffect, QGraphicsOpacityEffect
+*/
+
+/*!
+ Constructs a new QGraphicsDropShadowEffect instance.
+ The \a parent parameter is passed to QGraphicsEffect's constructor.
+*/
+QGraphicsDropShadowEffect::QGraphicsDropShadowEffect(QObject *parent)
+ : QGraphicsEffect(*new QGraphicsDropShadowEffectPrivate, parent)
+{
+}
+
+/*!
+ Destroys the effect.
+*/
+QGraphicsDropShadowEffect::~QGraphicsDropShadowEffect()
+{
+}
+
+/*!
+ \property QGraphicsDropShadowEffect::offset
+ \brief the shadow offset in pixels.
+
+ By default, the offset is 8 pixels towards the lower right.
+
+ The offset is given in device coordinates, which means it is
+ unaffected by scale.
+
+ \sa xOffset(), yOffset(), blurRadius(), color()
+*/
+QPointF QGraphicsDropShadowEffect::offset() const
+{
+ Q_D(const QGraphicsDropShadowEffect);
+ return d->filter->offset();
+}
+
+void QGraphicsDropShadowEffect::setOffset(const QPointF &offset)
+{
+ Q_D(QGraphicsDropShadowEffect);
+ if (d->filter->offset() == offset)
+ return;
+
+ d->filter->setOffset(offset);
+ updateBoundingRect();
+ emit offsetChanged(offset);
+}
+
+/*!
+ \property QGraphicsDropShadowEffect::xOffset
+ \brief the horizontal shadow offset in pixels.
+
+ By default, the horizontal shadow offset is 8 pixels.
+
+
+
+ \sa yOffset(), offset()
+*/
+
+/*!
+ \property QGraphicsDropShadowEffect::yOffset
+ \brief the vertical shadow offset in pixels.
+
+ By default, the vertical shadow offset is 8 pixels.
+
+ \sa xOffset(), offset()
+*/
+
+/*!
+ \fn void QGraphicsDropShadowEffect::offsetChanged(const QPointF &offset)
+
+ This signal is emitted whenever the effect's shadow offset changes.
+ The \a offset parameter holds the effect's new shadow offset.
+*/
+
+/*!
+ \property QGraphicsDropShadowEffect::blurRadius
+ \brief the blur radius in pixels of the drop shadow.
+
+ Using a smaller radius results in a sharper shadow, whereas using a bigger
+ radius results in a more blurred shadow.
+
+ By default, the blur radius is 1 pixel.
+
+ \sa color(), offset().
+*/
+qreal QGraphicsDropShadowEffect::blurRadius() const
+{
+ Q_D(const QGraphicsDropShadowEffect);
+ return d->filter->blurRadius();
+}
+
+void QGraphicsDropShadowEffect::setBlurRadius(qreal blurRadius)
+{
+ Q_D(QGraphicsDropShadowEffect);
+ if (qFuzzyCompare(d->filter->blurRadius(), blurRadius))
+ return;
+
+ d->filter->setBlurRadius(blurRadius);
+ updateBoundingRect();
+ emit blurRadiusChanged(blurRadius);
+}
+
+/*!
+ \fn void QGraphicsDropShadowEffect::blurRadiusChanged(qreal blurRadius)
+
+ This signal is emitted whenever the effect's blur radius changes.
+ The \a blurRadius parameter holds the effect's new blur radius.
+*/
+
+/*!
+ \property QGraphicsDropShadowEffect::color
+ \brief the color of the drop shadow.
+
+ By default, the drop color is a semi-transparent dark gray
+ (QColor(63, 63, 63, 180)).
+
+ \sa offset(), blurRadius()
+*/
+QColor QGraphicsDropShadowEffect::color() const
+{
+ Q_D(const QGraphicsDropShadowEffect);
+ return d->filter->color();
+}
+
+void QGraphicsDropShadowEffect::setColor(const QColor &color)
+{
+ Q_D(QGraphicsDropShadowEffect);
+ if (d->filter->color() == color)
+ return;
+
+ d->filter->setColor(color);
+ update();
+ emit colorChanged(color);
+}
+
+/*!
+ \fn void QGraphicsDropShadowEffect::colorChanged(const QColor &color)
+
+ This signal is emitted whenever the effect's color changes.
+ The \a color parameter holds the effect's new color.
+*/
+
+/*!
+ \reimp
+*/
+QRectF QGraphicsDropShadowEffect::boundingRectFor(const QRectF &rect) const
+{
+ Q_D(const QGraphicsDropShadowEffect);
+ return d->filter->boundingRectFor(rect);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsDropShadowEffect::draw(QPainter *painter)
+{
+ Q_D(QGraphicsDropShadowEffect);
+ if (d->filter->blurRadius() <= 0 && d->filter->offset().isNull()) {
+ drawSource(painter);
+ return;
+ }
+
+ PixmapPadMode mode = PadToEffectiveBoundingRect;
+ if (painter->paintEngine()->type() == QPaintEngine::OpenGL2)
+ mode = NoPad;
+
+ // Draw pixmap in device coordinates to avoid pixmap scaling.
+ QPoint offset;
+ const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset, mode);
+ if (pixmap.isNull())
+ return;
+
+ QTransform restoreTransform = painter->worldTransform();
+ painter->setWorldTransform(QTransform());
+ d->filter->draw(painter, offset, pixmap);
+ painter->setWorldTransform(restoreTransform);
+}
+
+/*!
+ \class QGraphicsOpacityEffect
+ \brief The QGraphicsOpacityEffect class provides an opacity effect.
+ \since 4.6
+
+ An opacity effect renders the source with an opacity. This effect is useful
+ for making the source semi-transparent, similar to a fade-in/fade-out
+ sequence. The opacity can be modified using the setOpacity() function.
+
+ By default, the opacity is 0.7.
+
+ \img graphicseffect-opacity.png
+
+ \sa QGraphicsDropShadowEffect, QGraphicsBlurEffect, QGraphicsColorizeEffect
+*/
+
+/*!
+ Constructs a new QGraphicsOpacityEffect instance.
+ The \a parent parameter is passed to QGraphicsEffect's constructor.
+*/
+QGraphicsOpacityEffect::QGraphicsOpacityEffect(QObject *parent)
+ : QGraphicsEffect(*new QGraphicsOpacityEffectPrivate, parent)
+{
+}
+
+/*!
+ Destroys the effect.
+*/
+QGraphicsOpacityEffect::~QGraphicsOpacityEffect()
+{
+}
+
+/*!
+ \property QGraphicsOpacityEffect::opacity
+ \brief the opacity of the effect.
+
+ The value should be in the range of 0.0 to 1.0, where 0.0 is
+ fully transparent and 1.0 is fully opaque.
+
+ By default, the opacity is 0.7.
+
+ \sa setOpacityMask()
+*/
+qreal QGraphicsOpacityEffect::opacity() const
+{
+ Q_D(const QGraphicsOpacityEffect);
+ return d->opacity;
+}
+
+void QGraphicsOpacityEffect::setOpacity(qreal opacity)
+{
+ Q_D(QGraphicsOpacityEffect);
+ opacity = qBound(qreal(0.0), opacity, qreal(1.0));
+
+ if (qFuzzyCompare(d->opacity, opacity))
+ return;
+
+ d->opacity = opacity;
+ if ((d->isFullyTransparent = qFuzzyIsNull(d->opacity)))
+ d->isFullyOpaque = 0;
+ else
+ d->isFullyOpaque = qFuzzyIsNull(d->opacity - 1);
+ update();
+ emit opacityChanged(opacity);
+}
+
+/*!
+ \fn void QGraphicsOpacityEffect::opacityChanged(qreal opacity)
+
+ This signal is emitted whenever the effect's opacity changes.
+ The \a opacity parameter holds the effect's new opacity.
+*/
+
+/*!
+ \property QGraphicsOpacityEffect::opacityMask
+ \brief the opacity mask of the effect.
+
+ An opacity mask allows you apply opacity to portions of an element.
+
+ For example:
+
+ \snippet doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp 2
+
+ There is no opacity mask by default.
+
+ \sa setOpacity()
+*/
+QBrush QGraphicsOpacityEffect::opacityMask() const
+{
+ Q_D(const QGraphicsOpacityEffect);
+ return d->opacityMask;
+}
+
+void QGraphicsOpacityEffect::setOpacityMask(const QBrush &mask)
+{
+ Q_D(QGraphicsOpacityEffect);
+ if (d->opacityMask == mask)
+ return;
+
+ d->opacityMask = mask;
+ d->hasOpacityMask = (mask.style() != Qt::NoBrush);
+ update();
+
+ emit opacityMaskChanged(mask);
+}
+
+/*!
+ \fn void QGraphicsOpacityEffect::opacityMaskChanged(const QBrush &mask)
+
+ This signal is emitted whenever the effect's opacity mask changes.
+ The \a mask parameter holds the effect's new opacity mask.
+*/
+
+/*!
+ \reimp
+*/
+void QGraphicsOpacityEffect::draw(QPainter *painter)
+{
+ Q_D(QGraphicsOpacityEffect);
+
+ // Transparent; nothing to draw.
+ if (d->isFullyTransparent)
+ return;
+
+ // Opaque; draw directly without going through a pixmap.
+ if (d->isFullyOpaque && !d->hasOpacityMask) {
+ drawSource(painter);
+ return;
+ }
+
+ QPoint offset;
+ Qt::CoordinateSystem system = sourceIsPixmap() ? Qt::LogicalCoordinates : Qt::DeviceCoordinates;
+ QPixmap pixmap = sourcePixmap(system, &offset, QGraphicsEffect::NoPad);
+ if (pixmap.isNull())
+ return;
+
+ painter->save();
+ painter->setOpacity(d->opacity);
+
+ if (d->hasOpacityMask) {
+ QPainter pixmapPainter(&pixmap);
+ pixmapPainter.setRenderHints(painter->renderHints());
+ pixmapPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
+ if (system == Qt::DeviceCoordinates) {
+ QTransform worldTransform = painter->worldTransform();
+ worldTransform *= QTransform::fromTranslate(-offset.x(), -offset.y());
+ pixmapPainter.setWorldTransform(worldTransform);
+ pixmapPainter.fillRect(sourceBoundingRect(), d->opacityMask);
+ } else {
+ pixmapPainter.translate(-offset);
+ pixmapPainter.fillRect(pixmap.rect(), d->opacityMask);
+ }
+ }
+
+ if (system == Qt::DeviceCoordinates)
+ painter->setWorldTransform(QTransform());
+
+ painter->drawPixmap(offset, pixmap);
+ painter->restore();
+}
+
+
+QT_END_NAMESPACE
+
+#endif //QT_NO_GRAPHICSEFFECT
diff --git a/src/gui/effects/qgraphicseffect.h b/src/widgets/effects/qgraphicseffect.h
index 9f5e94db89..9f5e94db89 100644
--- a/src/gui/effects/qgraphicseffect.h
+++ b/src/widgets/effects/qgraphicseffect.h
diff --git a/src/gui/effects/qgraphicseffect_p.h b/src/widgets/effects/qgraphicseffect_p.h
index cd1ae38ff8..cd1ae38ff8 100644
--- a/src/gui/effects/qgraphicseffect_p.h
+++ b/src/widgets/effects/qgraphicseffect_p.h
diff --git a/src/widgets/effects/qpixmapfilter.cpp b/src/widgets/effects/qpixmapfilter.cpp
new file mode 100644
index 0000000000..ecab3d7a41
--- /dev/null
+++ b/src/widgets/effects/qpixmapfilter.cpp
@@ -0,0 +1,1381 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qglobal.h>
+
+#include <QDebug>
+
+#include "qpainter.h"
+#include "qpixmap.h"
+#include "qpixmapfilter_p.h"
+#include "qvarlengtharray.h"
+
+#include "private/qguiapplication_p.h"
+#include "private/qpaintengineex_p.h"
+#include "private/qpaintengine_raster_p.h"
+#include "qmath.h"
+#include "private/qmath_p.h"
+#include "private/qmemrotate_p.h"
+#include "private/qdrawhelper_p.h"
+
+#ifndef QT_NO_GRAPHICSEFFECT
+QT_BEGIN_NAMESPACE
+
+class QPixmapFilterPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QPixmapFilter)
+public:
+ QPixmapFilter::FilterType type;
+};
+
+/*!
+ \class QPixmapFilter
+ \since 4.5
+ \ingroup painting
+
+ \brief The QPixmapFilter class provides the basic functionality for
+ pixmap filter classes. Pixmap filter can be for example colorize or blur.
+
+ QPixmapFilter is the base class for every pixmap filter. QPixmapFilter is
+ an abstract class and cannot itself be instantiated. It provides a standard
+ interface for filter processing.
+
+ \internal
+*/
+
+/*!
+ \enum QPixmapFilter::FilterType
+
+ \internal
+
+ This enum describes the types of filter that can be applied to pixmaps.
+
+ \value ConvolutionFilter A filter that is used to calculate the convolution
+ of the image with a kernel. See
+ QPixmapConvolutionFilter for more information.
+ \value ColorizeFilter A filter that is used to change the overall color
+ of an image. See QPixmapColorizeFilter for more
+ information.
+ \value DropShadowFilter A filter that is used to add a drop shadow to an
+ image. See QPixmapDropShadowFilter for more
+ information.
+ \value BlurFilter A filter that is used to blur an image using
+ a simple blur radius. See QPixmapBlurFilter
+ for more information.
+
+ \value UserFilter The first filter type that can be used for
+ application-specific purposes.
+*/
+
+
+/*!
+ Constructs a default QPixmapFilter with the given \a type.
+
+ This constructor should be used when subclassing QPixmapFilter to
+ create custom user filters.
+
+ \internal
+*/
+QPixmapFilter::QPixmapFilter(FilterType type, QObject *parent)
+ : QObject(*new QPixmapFilterPrivate, parent)
+{
+ d_func()->type = type;
+}
+
+
+
+/*!
+ \internal
+*/
+QPixmapFilter::QPixmapFilter(QPixmapFilterPrivate&d, QPixmapFilter::FilterType type, QObject *parent)
+ : QObject(d, parent)
+{
+ d_func()->type = type;
+}
+
+
+/*!
+ Destroys the pixmap filter.
+
+ \internal
+*/
+QPixmapFilter::~QPixmapFilter()
+{
+}
+
+/*!
+ Returns the type of the filter. All standard pixmap filter classes
+ are associated with a unique value.
+
+ \internal
+*/
+QPixmapFilter::FilterType QPixmapFilter::type() const
+{
+ Q_D(const QPixmapFilter);
+ return d->type;
+}
+
+/*!
+ Returns the bounding rectangle that is affected by the pixmap
+ filter if the filter is applied to the specified \a rect.
+
+ \internal
+*/
+QRectF QPixmapFilter::boundingRectFor(const QRectF &rect) const
+{
+ return rect;
+}
+
+/*!
+ \fn void QPixmapFilter::draw(QPainter *painter, const QPointF &p, const QPixmap &src, const QRectF& srcRect) const
+
+ Uses \a painter to draw filtered result of \a src at the point
+ specified by \a p. If \a srcRect is specified the it will
+ be used as a source rectangle to only draw a part of the source.
+
+ draw() will affect the area which boundingRectFor() returns.
+
+ \internal
+*/
+
+/*!
+ \class QPixmapConvolutionFilter
+ \since 4.5
+ \ingroup painting
+
+ \brief The QPixmapConvolutionFilter class provides convolution
+ filtering for pixmaps.
+
+ QPixmapConvolutionFilter implements a convolution pixmap filter,
+ which is applied when \l{QPixmapFilter::}{draw()} is called. A
+ convolution filter lets you distort an image by setting the values
+ of a matrix of qreal values called its
+ \l{setConvolutionKernel()}{kernel}. The matrix's values are
+ usually between -1.0 and 1.0.
+
+ \omit
+ In convolution filtering, the pixel value is calculated from the
+ neighboring pixels based on the weighting convolution kernel.
+ This needs explaining to be useful.
+ \endomit
+
+ Example:
+ \snippet doc/src/snippets/code/src_gui_image_qpixmapfilter.cpp 1
+
+ \sa {Pixmap Filters Example}, QPixmapColorizeFilter, QPixmapDropShadowFilter
+
+
+ \internal
+*/
+
+class QPixmapConvolutionFilterPrivate : public QPixmapFilterPrivate
+{
+public:
+ QPixmapConvolutionFilterPrivate(): convolutionKernel(0), kernelWidth(0), kernelHeight(0), convoluteAlpha(false) {}
+ ~QPixmapConvolutionFilterPrivate() {
+ delete[] convolutionKernel;
+ }
+
+ qreal *convolutionKernel;
+ int kernelWidth;
+ int kernelHeight;
+ bool convoluteAlpha;
+};
+
+
+/*!
+ Constructs a pixmap convolution filter.
+
+ By default there is no convolution kernel.
+
+ \internal
+*/
+QPixmapConvolutionFilter::QPixmapConvolutionFilter(QObject *parent)
+ : QPixmapFilter(*new QPixmapConvolutionFilterPrivate, ConvolutionFilter, parent)
+{
+ Q_D(QPixmapConvolutionFilter);
+ d->convoluteAlpha = true;
+}
+
+/*!
+ Destructor of pixmap convolution filter.
+
+ \internal
+*/
+QPixmapConvolutionFilter::~QPixmapConvolutionFilter()
+{
+}
+
+/*!
+ Sets convolution kernel with the given number of \a rows and \a columns.
+ Values from \a kernel are copied to internal data structure.
+
+ To preserve the intensity of the pixmap, the sum of all the
+ values in the convolution kernel should add up to 1.0. A sum
+ greater than 1.0 produces a lighter result and a sum less than 1.0
+ produces a darker and transparent result.
+
+ \internal
+*/
+void QPixmapConvolutionFilter::setConvolutionKernel(const qreal *kernel, int rows, int columns)
+{
+ Q_D(QPixmapConvolutionFilter);
+ delete [] d->convolutionKernel;
+ d->convolutionKernel = new qreal[rows * columns];
+ memcpy(d->convolutionKernel, kernel, sizeof(qreal) * rows * columns);
+ d->kernelWidth = columns;
+ d->kernelHeight = rows;
+}
+
+/*!
+ Gets the convolution kernel data.
+
+ \internal
+*/
+const qreal *QPixmapConvolutionFilter::convolutionKernel() const
+{
+ Q_D(const QPixmapConvolutionFilter);
+ return d->convolutionKernel;
+}
+
+/*!
+ Gets the number of rows in the convolution kernel.
+
+ \internal
+*/
+int QPixmapConvolutionFilter::rows() const
+{
+ Q_D(const QPixmapConvolutionFilter);
+ return d->kernelHeight;
+}
+
+/*!
+ Gets the number of columns in the convolution kernel.
+
+ \internal
+*/
+int QPixmapConvolutionFilter::columns() const
+{
+ Q_D(const QPixmapConvolutionFilter);
+ return d->kernelWidth;
+}
+
+
+/*!
+ \internal
+*/
+QRectF QPixmapConvolutionFilter::boundingRectFor(const QRectF &rect) const
+{
+ Q_D(const QPixmapConvolutionFilter);
+ return rect.adjusted(-d->kernelWidth / 2, -d->kernelHeight / 2, (d->kernelWidth - 1) / 2, (d->kernelHeight - 1) / 2);
+}
+
+// Convolutes the image
+static void convolute(
+ QImage *destImage,
+ const QPointF &pos,
+ const QImage &srcImage,
+ const QRectF &srcRect,
+ QPainter::CompositionMode mode,
+ qreal *kernel,
+ int kernelWidth,
+ int kernelHeight )
+{
+ const QImage processImage = (srcImage.format() != QImage::Format_ARGB32_Premultiplied ) ? srcImage.convertToFormat(QImage::Format_ARGB32_Premultiplied) : srcImage;
+ // TODO: support also other formats directly without copying
+
+ int *fixedKernel = new int[kernelWidth*kernelHeight];
+ for(int i = 0; i < kernelWidth*kernelHeight; i++)
+ {
+ fixedKernel[i] = (int)(65536 * kernel[i]);
+ }
+ QRectF trect = srcRect.isNull() ? processImage.rect() : srcRect;
+ trect.moveTo(pos);
+ QRectF bounded = trect.adjusted(-kernelWidth / 2, -kernelHeight / 2, (kernelWidth - 1) / 2, (kernelHeight - 1) / 2);
+ QRect rect = bounded.toAlignedRect();
+ QRect targetRect = rect.intersected(destImage->rect());
+
+ QRectF srect = srcRect.isNull() ? processImage.rect() : srcRect;
+ QRectF sbounded = srect.adjusted(-kernelWidth / 2, -kernelHeight / 2, (kernelWidth - 1) / 2, (kernelHeight - 1) / 2);
+ QPoint srcStartPoint = sbounded.toAlignedRect().topLeft()+(targetRect.topLeft()-rect.topLeft());
+
+ const uint *sourceStart = (uint*)processImage.scanLine(0);
+ uint *outputStart = (uint*)destImage->scanLine(0);
+
+ int yk = srcStartPoint.y();
+ for (int y = targetRect.top(); y <= targetRect.bottom(); y++) {
+ uint* output = outputStart + (destImage->bytesPerLine()/sizeof(uint))*y+targetRect.left();
+ int xk = srcStartPoint.x();
+ for(int x = targetRect.left(); x <= targetRect.right(); x++) {
+ int r = 0;
+ int g = 0;
+ int b = 0;
+ int a = 0;
+
+ // some out of bounds pre-checking to avoid inner-loop ifs
+ int kernely = -kernelHeight/2;
+ int starty = 0;
+ int endy = kernelHeight;
+ if(yk+kernely+endy >= srcImage.height())
+ endy = kernelHeight-((yk+kernely+endy)-srcImage.height())-1;
+ if(yk+kernely < 0)
+ starty = -(yk+kernely);
+
+ int kernelx = -kernelWidth/2;
+ int startx = 0;
+ int endx = kernelWidth;
+ if(xk+kernelx+endx >= srcImage.width())
+ endx = kernelWidth-((xk+kernelx+endx)-srcImage.width())-1;
+ if(xk+kernelx < 0)
+ startx = -(xk+kernelx);
+
+ for (int ys = starty; ys < endy; ys ++) {
+ const uint *pix = sourceStart + (processImage.bytesPerLine()/sizeof(uint))*(yk+kernely+ys) + ((xk+kernelx+startx));
+ const uint *endPix = pix+endx-startx;
+ int kernelPos = ys*kernelWidth+startx;
+ while (pix < endPix) {
+ int factor = fixedKernel[kernelPos++];
+ a += (((*pix) & 0xff000000)>>24) * factor;
+ r += (((*pix) & 0x00ff0000)>>16) * factor;
+ g += (((*pix) & 0x0000ff00)>>8 ) * factor;
+ b += (((*pix) & 0x000000ff) ) * factor;
+ pix++;
+ }
+ }
+
+ r = qBound((int)0, r >> 16, (int)255);
+ g = qBound((int)0, g >> 16, (int)255);
+ b = qBound((int)0, b >> 16, (int)255);
+ a = qBound((int)0, a >> 16, (int)255);
+ // composition mode checking could be moved outside of loop
+ if(mode == QPainter::CompositionMode_Source) {
+ uint color = (a<<24)+(r<<16)+(g<<8)+b;
+ *output++ = color;
+ } else {
+ uint current = *output;
+ uchar ca = (current&0xff000000)>>24;
+ uchar cr = (current&0x00ff0000)>>16;
+ uchar cg = (current&0x0000ff00)>>8;
+ uchar cb = (current&0x000000ff);
+ uint color =
+ (((ca*(255-a) >> 8)+a) << 24)+
+ (((cr*(255-a) >> 8)+r) << 16)+
+ (((cg*(255-a) >> 8)+g) << 8)+
+ (((cb*(255-a) >> 8)+b));
+ *output++ = color;;
+ }
+ xk++;
+ }
+ yk++;
+ }
+ delete[] fixedKernel;
+}
+
+/*!
+ \internal
+*/
+void QPixmapConvolutionFilter::draw(QPainter *painter, const QPointF &p, const QPixmap &src, const QRectF& srcRect) const
+{
+ Q_D(const QPixmapConvolutionFilter);
+ if (!painter->isActive())
+ return;
+
+ if(d->kernelWidth<=0 || d->kernelHeight <= 0)
+ return;
+
+ if (src.isNull())
+ return;
+
+ QPixmapFilter *filter = painter->paintEngine() && painter->paintEngine()->isExtended() ?
+ static_cast<QPaintEngineEx *>(painter->paintEngine())->pixmapFilter(type(), this) : 0;
+ QPixmapConvolutionFilter *convolutionFilter = static_cast<QPixmapConvolutionFilter*>(filter);
+ if (convolutionFilter) {
+ convolutionFilter->setConvolutionKernel(d->convolutionKernel, d->kernelWidth, d->kernelHeight);
+ convolutionFilter->d_func()->convoluteAlpha = d->convoluteAlpha;
+ convolutionFilter->draw(painter, p, src, srcRect);
+ return;
+ }
+
+ // falling back to raster implementation
+
+ QImage *target = 0;
+ if (painter->paintEngine()->paintDevice()->devType() == QInternal::Image) {
+ target = static_cast<QImage *>(painter->paintEngine()->paintDevice());
+
+ QTransform mat = painter->combinedTransform();
+
+ if (mat.type() > QTransform::TxTranslate) {
+ // Disabled because of transformation...
+ target = 0;
+ } else {
+ QRasterPaintEngine *pe = static_cast<QRasterPaintEngine *>(painter->paintEngine());
+ if (pe->clipType() == QRasterPaintEngine::ComplexClip)
+ // disabled because of complex clipping...
+ target = 0;
+ else {
+ QRectF clip = pe->clipBoundingRect();
+ QRectF rect = boundingRectFor(srcRect.isEmpty() ? src.rect() : srcRect);
+ QTransform x = painter->deviceTransform();
+ if (!clip.contains(rect.translated(x.dx() + p.x(), x.dy() + p.y()))) {
+ target = 0;
+ }
+
+ }
+ }
+ }
+
+ if (target) {
+ QTransform x = painter->deviceTransform();
+ QPointF offset(x.dx(), x.dy());
+
+ convolute(target, p+offset, src.toImage(), srcRect, QPainter::CompositionMode_SourceOver, d->convolutionKernel, d->kernelWidth, d->kernelHeight);
+ } else {
+ QRect srect = srcRect.isNull() ? src.rect() : srcRect.toRect();
+ QRect rect = boundingRectFor(srect).toRect();
+ QImage result = QImage(rect.size(), QImage::Format_ARGB32_Premultiplied);
+ QPoint offset = srect.topLeft() - rect.topLeft();
+ convolute(&result,
+ offset,
+ src.toImage(),
+ srect,
+ QPainter::CompositionMode_Source,
+ d->convolutionKernel,
+ d->kernelWidth,
+ d->kernelHeight);
+ painter->drawImage(p - offset, result);
+ }
+}
+
+/*!
+ \class QPixmapBlurFilter
+ \since 4.6
+ \ingroup multimedia
+
+ \brief The QPixmapBlurFilter class provides blur filtering
+ for pixmaps.
+
+ QPixmapBlurFilter implements a blur pixmap filter,
+ which is applied when \l{QPixmapFilter::}{draw()} is called.
+
+ The filter lets you specialize the radius of the blur as well
+ as hints as to whether to prefer performance or quality.
+
+ By default, the blur effect is produced by applying an exponential
+ filter generated from the specified blurRadius(). Paint engines
+ may override this with a custom blur that is faster on the
+ underlying hardware.
+
+ \sa {Pixmap Filters Example}, QPixmapConvolutionFilter, QPixmapDropShadowFilter
+
+ \internal
+*/
+
+class QPixmapBlurFilterPrivate : public QPixmapFilterPrivate
+{
+public:
+ QPixmapBlurFilterPrivate() : radius(5), hints(QGraphicsBlurEffect::PerformanceHint) {}
+
+ qreal radius;
+ QGraphicsBlurEffect::BlurHints hints;
+};
+
+
+/*!
+ Constructs a pixmap blur filter.
+
+ \internal
+*/
+QPixmapBlurFilter::QPixmapBlurFilter(QObject *parent)
+ : QPixmapFilter(*new QPixmapBlurFilterPrivate, BlurFilter, parent)
+{
+}
+
+/*!
+ Destructor of pixmap blur filter.
+
+ \internal
+*/
+QPixmapBlurFilter::~QPixmapBlurFilter()
+{
+}
+
+/*!
+ Sets the radius of the blur filter. Higher radius produces increased blurriness.
+
+ \internal
+*/
+void QPixmapBlurFilter::setRadius(qreal radius)
+{
+ Q_D(QPixmapBlurFilter);
+ d->radius = radius;
+}
+
+/*!
+ Gets the radius of the blur filter.
+
+ \internal
+*/
+qreal QPixmapBlurFilter::radius() const
+{
+ Q_D(const QPixmapBlurFilter);
+ return d->radius;
+}
+
+/*!
+ Setting the blur hints to PerformanceHint causes the implementation
+ to trade off visual quality to blur the image faster. Setting the
+ blur hints to QualityHint causes the implementation to improve
+ visual quality at the expense of speed.
+
+ AnimationHint causes the implementation to optimize for animating
+ the blur radius, possibly by caching blurred versions of the source
+ pixmap.
+
+ The implementation is free to ignore this value if it only has a single
+ blur algorithm.
+
+ \internal
+*/
+void QPixmapBlurFilter::setBlurHints(QGraphicsBlurEffect::BlurHints hints)
+{
+ Q_D(QPixmapBlurFilter);
+ d->hints = hints;
+}
+
+/*!
+ Gets the blur hints of the blur filter.
+
+ \internal
+*/
+QGraphicsBlurEffect::BlurHints QPixmapBlurFilter::blurHints() const
+{
+ Q_D(const QPixmapBlurFilter);
+ return d->hints;
+}
+
+const qreal radiusScale = qreal(2.5);
+
+/*!
+ \internal
+*/
+QRectF QPixmapBlurFilter::boundingRectFor(const QRectF &rect) const
+{
+ Q_D(const QPixmapBlurFilter);
+ const qreal delta = radiusScale * d->radius + 1;
+ return rect.adjusted(-delta, -delta, delta, delta);
+}
+
+template <int shift>
+inline int qt_static_shift(int value)
+{
+ if (shift == 0)
+ return value;
+ else if (shift > 0)
+ return value << (uint(shift) & 0x1f);
+ else
+ return value >> (uint(-shift) & 0x1f);
+}
+
+template<int aprec, int zprec>
+inline void qt_blurinner(uchar *bptr, int &zR, int &zG, int &zB, int &zA, int alpha)
+{
+ QRgb *pixel = (QRgb *)bptr;
+
+#define Z_MASK (0xff << zprec)
+ const int A_zprec = qt_static_shift<zprec - 24>(*pixel) & Z_MASK;
+ const int R_zprec = qt_static_shift<zprec - 16>(*pixel) & Z_MASK;
+ const int G_zprec = qt_static_shift<zprec - 8>(*pixel) & Z_MASK;
+ const int B_zprec = qt_static_shift<zprec>(*pixel) & Z_MASK;
+#undef Z_MASK
+
+ const int zR_zprec = zR >> aprec;
+ const int zG_zprec = zG >> aprec;
+ const int zB_zprec = zB >> aprec;
+ const int zA_zprec = zA >> aprec;
+
+ zR += alpha * (R_zprec - zR_zprec);
+ zG += alpha * (G_zprec - zG_zprec);
+ zB += alpha * (B_zprec - zB_zprec);
+ zA += alpha * (A_zprec - zA_zprec);
+
+#define ZA_MASK (0xff << (zprec + aprec))
+ *pixel =
+ qt_static_shift<24 - zprec - aprec>(zA & ZA_MASK)
+ | qt_static_shift<16 - zprec - aprec>(zR & ZA_MASK)
+ | qt_static_shift<8 - zprec - aprec>(zG & ZA_MASK)
+ | qt_static_shift<-zprec - aprec>(zB & ZA_MASK);
+#undef ZA_MASK
+}
+
+const int alphaIndex = (QSysInfo::ByteOrder == QSysInfo::BigEndian ? 0 : 3);
+
+template<int aprec, int zprec>
+inline void qt_blurinner_alphaOnly(uchar *bptr, int &z, int alpha)
+{
+ const int A_zprec = int(*(bptr)) << zprec;
+ const int z_zprec = z >> aprec;
+ z += alpha * (A_zprec - z_zprec);
+ *(bptr) = z >> (zprec + aprec);
+}
+
+template<int aprec, int zprec, bool alphaOnly>
+inline void qt_blurrow(QImage & im, int line, int alpha)
+{
+ uchar *bptr = im.scanLine(line);
+
+ int zR = 0, zG = 0, zB = 0, zA = 0;
+
+ if (alphaOnly && im.format() != QImage::Format_Indexed8)
+ bptr += alphaIndex;
+
+ const int stride = im.depth() >> 3;
+ const int im_width = im.width();
+ for (int index = 0; index < im_width; ++index) {
+ if (alphaOnly)
+ qt_blurinner_alphaOnly<aprec, zprec>(bptr, zA, alpha);
+ else
+ qt_blurinner<aprec, zprec>(bptr, zR, zG, zB, zA, alpha);
+ bptr += stride;
+ }
+
+ bptr -= stride;
+
+ for (int index = im_width - 2; index >= 0; --index) {
+ bptr -= stride;
+ if (alphaOnly)
+ qt_blurinner_alphaOnly<aprec, zprec>(bptr, zA, alpha);
+ else
+ qt_blurinner<aprec, zprec>(bptr, zR, zG, zB, zA, alpha);
+ }
+}
+
+/*
+* expblur(QImage &img, int radius)
+*
+* Based on exponential blur algorithm by Jani Huhtanen
+*
+* In-place blur of image 'img' with kernel
+* of approximate radius 'radius'.
+*
+* Blurs with two sided exponential impulse
+* response.
+*
+* aprec = precision of alpha parameter
+* in fixed-point format 0.aprec
+*
+* zprec = precision of state parameters
+* zR,zG,zB and zA in fp format 8.zprec
+*/
+template <int aprec, int zprec, bool alphaOnly>
+void expblur(QImage &img, qreal radius, bool improvedQuality = false, int transposed = 0)
+{
+ // halve the radius if we're using two passes
+ if (improvedQuality)
+ radius *= qreal(0.5);
+
+ Q_ASSERT(img.format() == QImage::Format_ARGB32_Premultiplied
+ || img.format() == QImage::Format_RGB32
+ || img.format() == QImage::Format_Indexed8);
+
+ // choose the alpha such that pixels at radius distance from a fully
+ // saturated pixel will have an alpha component of no greater than
+ // the cutOffIntensity
+ const qreal cutOffIntensity = 2;
+ int alpha = radius <= qreal(1e-5)
+ ? ((1 << aprec)-1)
+ : qRound((1<<aprec)*(1 - qPow(cutOffIntensity * (1 / qreal(255)), 1 / radius)));
+
+ int img_height = img.height();
+ for (int row = 0; row < img_height; ++row) {
+ for (int i = 0; i <= int(improvedQuality); ++i)
+ qt_blurrow<aprec, zprec, alphaOnly>(img, row, alpha);
+ }
+
+ QImage temp(img.height(), img.width(), img.format());
+ if (transposed >= 0) {
+ if (img.depth() == 8) {
+ qt_memrotate270(reinterpret_cast<const quint8*>(img.bits()),
+ img.width(), img.height(), img.bytesPerLine(),
+ reinterpret_cast<quint8*>(temp.bits()),
+ temp.bytesPerLine());
+ } else {
+ qt_memrotate270(reinterpret_cast<const quint32*>(img.bits()),
+ img.width(), img.height(), img.bytesPerLine(),
+ reinterpret_cast<quint32*>(temp.bits()),
+ temp.bytesPerLine());
+ }
+ } else {
+ if (img.depth() == 8) {
+ qt_memrotate90(reinterpret_cast<const quint8*>(img.bits()),
+ img.width(), img.height(), img.bytesPerLine(),
+ reinterpret_cast<quint8*>(temp.bits()),
+ temp.bytesPerLine());
+ } else {
+ qt_memrotate90(reinterpret_cast<const quint32*>(img.bits()),
+ img.width(), img.height(), img.bytesPerLine(),
+ reinterpret_cast<quint32*>(temp.bits()),
+ temp.bytesPerLine());
+ }
+ }
+
+ img_height = temp.height();
+ for (int row = 0; row < img_height; ++row) {
+ for (int i = 0; i <= int(improvedQuality); ++i)
+ qt_blurrow<aprec, zprec, alphaOnly>(temp, row, alpha);
+ }
+
+ if (transposed == 0) {
+ if (img.depth() == 8) {
+ qt_memrotate90(reinterpret_cast<const quint8*>(temp.bits()),
+ temp.width(), temp.height(), temp.bytesPerLine(),
+ reinterpret_cast<quint8*>(img.bits()),
+ img.bytesPerLine());
+ } else {
+ qt_memrotate90(reinterpret_cast<const quint32*>(temp.bits()),
+ temp.width(), temp.height(), temp.bytesPerLine(),
+ reinterpret_cast<quint32*>(img.bits()),
+ img.bytesPerLine());
+ }
+ } else {
+ img = temp;
+ }
+}
+#define AVG(a,b) ( ((((a)^(b)) & 0xfefefefeUL) >> 1) + ((a)&(b)) )
+#define AVG16(a,b) ( ((((a)^(b)) & 0xf7deUL) >> 1) + ((a)&(b)) )
+
+Q_GUI_EXPORT QImage qt_halfScaled(const QImage &source)
+{
+ if (source.width() < 2 || source.height() < 2)
+ return QImage();
+
+ QImage srcImage = source;
+
+ if (source.format() == QImage::Format_Indexed8) {
+ // assumes grayscale
+ QImage dest(source.width() / 2, source.height() / 2, srcImage.format());
+
+ const uchar *src = reinterpret_cast<const uchar*>(const_cast<const QImage &>(srcImage).bits());
+ int sx = srcImage.bytesPerLine();
+ int sx2 = sx << 1;
+
+ uchar *dst = reinterpret_cast<uchar*>(dest.bits());
+ int dx = dest.bytesPerLine();
+ int ww = dest.width();
+ int hh = dest.height();
+
+ for (int y = hh; y; --y, dst += dx, src += sx2) {
+ const uchar *p1 = src;
+ const uchar *p2 = src + sx;
+ uchar *q = dst;
+ for (int x = ww; x; --x, ++q, p1 += 2, p2 += 2)
+ *q = ((int(p1[0]) + int(p1[1]) + int(p2[0]) + int(p2[1])) + 2) >> 2;
+ }
+
+ return dest;
+ } else if (source.format() == QImage::Format_ARGB8565_Premultiplied) {
+ QImage dest(source.width() / 2, source.height() / 2, srcImage.format());
+
+ const uchar *src = reinterpret_cast<const uchar*>(const_cast<const QImage &>(srcImage).bits());
+ int sx = srcImage.bytesPerLine();
+ int sx2 = sx << 1;
+
+ uchar *dst = reinterpret_cast<uchar*>(dest.bits());
+ int dx = dest.bytesPerLine();
+ int ww = dest.width();
+ int hh = dest.height();
+
+ for (int y = hh; y; --y, dst += dx, src += sx2) {
+ const uchar *p1 = src;
+ const uchar *p2 = src + sx;
+ uchar *q = dst;
+ for (int x = ww; x; --x, q += 3, p1 += 6, p2 += 6) {
+ // alpha
+ q[0] = AVG(AVG(p1[0], p1[3]), AVG(p2[0], p2[3]));
+ // rgb
+ const quint16 p16_1 = (p1[2] << 8) | p1[1];
+ const quint16 p16_2 = (p1[5] << 8) | p1[4];
+ const quint16 p16_3 = (p2[2] << 8) | p2[1];
+ const quint16 p16_4 = (p2[5] << 8) | p2[4];
+ const quint16 result = AVG16(AVG16(p16_1, p16_2), AVG16(p16_3, p16_4));
+ q[1] = result & 0xff;
+ q[2] = result >> 8;
+ }
+ }
+
+ return dest;
+ } else if (source.format() != QImage::Format_ARGB32_Premultiplied
+ && source.format() != QImage::Format_RGB32)
+ {
+ srcImage = source.convertToFormat(QImage::Format_ARGB32_Premultiplied);
+ }
+
+ QImage dest(source.width() / 2, source.height() / 2, srcImage.format());
+
+ const quint32 *src = reinterpret_cast<const quint32*>(const_cast<const QImage &>(srcImage).bits());
+ int sx = srcImage.bytesPerLine() >> 2;
+ int sx2 = sx << 1;
+
+ quint32 *dst = reinterpret_cast<quint32*>(dest.bits());
+ int dx = dest.bytesPerLine() >> 2;
+ int ww = dest.width();
+ int hh = dest.height();
+
+ for (int y = hh; y; --y, dst += dx, src += sx2) {
+ const quint32 *p1 = src;
+ const quint32 *p2 = src + sx;
+ quint32 *q = dst;
+ for (int x = ww; x; --x, q++, p1 += 2, p2 += 2)
+ *q = AVG(AVG(p1[0], p1[1]), AVG(p2[0], p2[1]));
+ }
+
+ return dest;
+}
+
+Q_GUI_EXPORT void qt_blurImage(QPainter *p, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0)
+{
+ if (blurImage.format() != QImage::Format_ARGB32_Premultiplied
+ && blurImage.format() != QImage::Format_RGB32)
+ {
+ blurImage = blurImage.convertToFormat(QImage::Format_ARGB32_Premultiplied);
+ }
+
+ qreal scale = 1;
+ if (radius >= 4 && blurImage.width() >= 2 && blurImage.height() >= 2) {
+ blurImage = qt_halfScaled(blurImage);
+ scale = 2;
+ radius *= qreal(0.5);
+ }
+
+ if (alphaOnly)
+ expblur<12, 10, true>(blurImage, radius, quality, transposed);
+ else
+ expblur<12, 10, false>(blurImage, radius, quality, transposed);
+
+ if (p) {
+ p->scale(scale, scale);
+ p->setRenderHint(QPainter::SmoothPixmapTransform);
+ p->drawImage(QRect(0, 0, blurImage.width(), blurImage.height()), blurImage);
+ }
+}
+
+Q_GUI_EXPORT void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed = 0)
+{
+ if (blurImage.format() == QImage::Format_Indexed8)
+ expblur<12, 10, true>(blurImage, radius, quality, transposed);
+ else
+ expblur<12, 10, false>(blurImage, radius, quality, transposed);
+}
+
+Q_GUI_EXPORT bool qt_scaleForTransform(const QTransform &transform, qreal *scale);
+
+/*!
+ \internal
+*/
+void QPixmapBlurFilter::draw(QPainter *painter, const QPointF &p, const QPixmap &src, const QRectF &rect) const
+{
+ Q_D(const QPixmapBlurFilter);
+ if (!painter->isActive())
+ return;
+
+ if (src.isNull())
+ return;
+
+ QRectF srcRect = rect;
+ if (srcRect.isNull())
+ srcRect = src.rect();
+
+ if (d->radius <= 1) {
+ painter->drawPixmap(srcRect.translated(p), src, srcRect);
+ return;
+ }
+
+ qreal scaledRadius = radiusScale * d->radius;
+ qreal scale;
+ if (qt_scaleForTransform(painter->transform(), &scale))
+ scaledRadius /= scale;
+
+ QPixmapFilter *filter = painter->paintEngine() && painter->paintEngine()->isExtended() ?
+ static_cast<QPaintEngineEx *>(painter->paintEngine())->pixmapFilter(type(), this) : 0;
+ QPixmapBlurFilter *blurFilter = static_cast<QPixmapBlurFilter*>(filter);
+ if (blurFilter) {
+ blurFilter->setRadius(scaledRadius);
+ blurFilter->setBlurHints(d->hints);
+ blurFilter->draw(painter, p, src, srcRect);
+ return;
+ }
+
+ QImage srcImage;
+ QImage destImage;
+
+ if (srcRect == src.rect()) {
+ srcImage = src.toImage();
+ } else {
+ QRect rect = srcRect.toAlignedRect().intersected(src.rect());
+ srcImage = src.copy(rect).toImage();
+ }
+
+ QTransform transform = painter->worldTransform();
+ painter->translate(p);
+ qt_blurImage(painter, srcImage, scaledRadius, (d->hints & QGraphicsBlurEffect::QualityHint), false);
+ painter->setWorldTransform(transform);
+}
+
+// grayscales the image to dest (could be same). If rect isn't defined
+// destination image size is used to determine the dimension of grayscaling
+// process.
+static void grayscale(const QImage &image, QImage &dest, const QRect& rect = QRect())
+{
+ QRect destRect = rect;
+ QRect srcRect = rect;
+ if (rect.isNull()) {
+ srcRect = dest.rect();
+ destRect = dest.rect();
+ }
+ if (&image != &dest) {
+ destRect.moveTo(QPoint(0, 0));
+ }
+
+ unsigned int *data = (unsigned int *)image.bits();
+ unsigned int *outData = (unsigned int *)dest.bits();
+
+ if (dest.size() == image.size() && image.rect() == srcRect) {
+ // a bit faster loop for grayscaling everything
+ int pixels = dest.width() * dest.height();
+ for (int i = 0; i < pixels; ++i) {
+ int val = qGray(data[i]);
+ outData[i] = qRgba(val, val, val, qAlpha(data[i]));
+ }
+ } else {
+ int yd = destRect.top();
+ for (int y = srcRect.top(); y <= srcRect.bottom() && y < image.height(); y++) {
+ data = (unsigned int*)image.scanLine(y);
+ outData = (unsigned int*)dest.scanLine(yd++);
+ int xd = destRect.left();
+ for (int x = srcRect.left(); x <= srcRect.right() && x < image.width(); x++) {
+ int val = qGray(data[x]);
+ outData[xd++] = qRgba(val, val, val, qAlpha(data[x]));
+ }
+ }
+ }
+}
+
+/*!
+ \class QPixmapColorizeFilter
+ \since 4.5
+ \ingroup painting
+
+ \brief The QPixmapColorizeFilter class provides colorizing
+ filtering for pixmaps.
+
+ A colorize filter gives the pixmap a tint of its color(). The
+ filter first grayscales the pixmap and then converts those to
+ colorized values using QPainter::CompositionMode_Screen with the
+ chosen color. The alpha-channel is not changed.
+
+ Example:
+ \snippet doc/src/snippets/code/src_gui_image_qpixmapfilter.cpp 0
+
+ \sa QPainter::CompositionMode
+
+ \internal
+*/
+class QPixmapColorizeFilterPrivate : public QPixmapFilterPrivate
+{
+ Q_DECLARE_PUBLIC(QPixmapColorizeFilter)
+public:
+ QColor color;
+ qreal strength;
+ quint32 opaque : 1;
+ quint32 alphaBlend : 1;
+ quint32 padding : 30;
+};
+
+/*!
+ Constructs an pixmap colorize filter.
+
+ Default color value for colorizing is QColor(0, 0, 192).
+
+ \internal
+*/
+QPixmapColorizeFilter::QPixmapColorizeFilter(QObject *parent)
+ : QPixmapFilter(*new QPixmapColorizeFilterPrivate, ColorizeFilter, parent)
+{
+ Q_D(QPixmapColorizeFilter);
+ d->color = QColor(0, 0, 192);
+ d->strength = qreal(1);
+ d->opaque = true;
+ d->alphaBlend = false;
+}
+
+/*!
+ Gets the color of the colorize filter.
+
+ \internal
+*/
+QColor QPixmapColorizeFilter::color() const
+{
+ Q_D(const QPixmapColorizeFilter);
+ return d->color;
+}
+
+/*!
+ Sets the color of the colorize filter to the \a color specified.
+
+ \internal
+*/
+void QPixmapColorizeFilter::setColor(const QColor &color)
+{
+ Q_D(QPixmapColorizeFilter);
+ d->color = color;
+}
+
+/*!
+ Gets the strength of the colorize filter, 1.0 means full colorized while
+ 0.0 equals to no filtering at all.
+
+ \internal
+*/
+qreal QPixmapColorizeFilter::strength() const
+{
+ Q_D(const QPixmapColorizeFilter);
+ return d->strength;
+}
+
+/*!
+ Sets the strength of the colorize filter to \a strength.
+
+ \internal
+*/
+void QPixmapColorizeFilter::setStrength(qreal strength)
+{
+ Q_D(QPixmapColorizeFilter);
+ d->strength = qBound(qreal(0), strength, qreal(1));
+ d->opaque = !qFuzzyIsNull(d->strength);
+ d->alphaBlend = !qFuzzyIsNull(d->strength - 1);
+}
+
+/*!
+ \internal
+*/
+void QPixmapColorizeFilter::draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect) const
+{
+ Q_D(const QPixmapColorizeFilter);
+
+ if (src.isNull())
+ return;
+
+ QPixmapFilter *filter = painter->paintEngine() && painter->paintEngine()->isExtended() ?
+ static_cast<QPaintEngineEx *>(painter->paintEngine())->pixmapFilter(type(), this) : 0;
+ QPixmapColorizeFilter *colorizeFilter = static_cast<QPixmapColorizeFilter*>(filter);
+ if (colorizeFilter) {
+ colorizeFilter->setColor(d->color);
+ colorizeFilter->setStrength(d->strength);
+ colorizeFilter->draw(painter, dest, src, srcRect);
+ return;
+ }
+
+ // falling back to raster implementation
+
+ if (!d->opaque) {
+ painter->drawPixmap(dest, src, srcRect);
+ return;
+ }
+
+ QImage srcImage;
+ QImage destImage;
+
+ if (srcRect.isNull()) {
+ srcImage = src.toImage();
+ srcImage = srcImage.convertToFormat(srcImage.hasAlphaChannel() ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32);
+ destImage = QImage(srcImage.size(), srcImage.format());
+ } else {
+ QRect rect = srcRect.toAlignedRect().intersected(src.rect());
+
+ srcImage = src.copy(rect).toImage();
+ srcImage = srcImage.convertToFormat(srcImage.hasAlphaChannel() ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32);
+ destImage = QImage(rect.size(), srcImage.format());
+ }
+
+ // do colorizing
+ QPainter destPainter(&destImage);
+ grayscale(srcImage, destImage, srcImage.rect());
+ destPainter.setCompositionMode(QPainter::CompositionMode_Screen);
+ destPainter.fillRect(srcImage.rect(), d->color);
+ destPainter.end();
+
+ if (d->alphaBlend) {
+ // alpha blending srcImage and destImage
+ QImage buffer = srcImage;
+ QPainter bufPainter(&buffer);
+ bufPainter.setOpacity(d->strength);
+ bufPainter.drawImage(0, 0, destImage);
+ bufPainter.end();
+ destImage = buffer;
+ }
+
+ if (srcImage.hasAlphaChannel())
+ destImage.setAlphaChannel(srcImage.alphaChannel());
+
+ painter->drawImage(dest, destImage);
+}
+
+class QPixmapDropShadowFilterPrivate : public QPixmapFilterPrivate
+{
+public:
+ QPixmapDropShadowFilterPrivate()
+ : offset(8, 8), color(63, 63, 63, 180), radius(1) {}
+
+ QPointF offset;
+ QColor color;
+ qreal radius;
+};
+
+/*!
+ \class QPixmapDropShadowFilter
+ \since 4.5
+ \ingroup painting
+
+ \brief The QPixmapDropShadowFilter class is a convenience class
+ for drawing pixmaps with drop shadows.
+
+ The drop shadow is produced by taking a copy of the source pixmap
+ and applying a color to the copy using a
+ QPainter::CompositionMode_DestinationIn operation. This produces a
+ homogeneously-colored pixmap which is then drawn using a
+ QPixmapConvolutionFilter at an offset. The original pixmap is
+ drawn on top.
+
+ The QPixmapDropShadowFilter class provides some customization
+ options to specify how the drop shadow should appear. The color of
+ the drop shadow can be modified using the setColor() function, the
+ drop shadow offset can be modified using the setOffset() function,
+ and the blur radius of the drop shadow can be changed through the
+ setBlurRadius() function.
+
+ By default, the drop shadow is a dark gray shadow, blurred with a
+ radius of 1 at an offset of 8 pixels towards the lower right.
+
+ Example:
+ \snippet doc/src/snippets/code/src_gui_image_qpixmapfilter.cpp 2
+
+ \sa QPixmapColorizeFilter, QPixmapConvolutionFilter
+
+ \internal
+ */
+
+/*!
+ Constructs drop shadow filter.
+
+ \internal
+*/
+QPixmapDropShadowFilter::QPixmapDropShadowFilter(QObject *parent)
+ : QPixmapFilter(*new QPixmapDropShadowFilterPrivate, DropShadowFilter, parent)
+{
+}
+
+/*!
+ Destroys drop shadow filter.
+
+ \internal
+*/
+QPixmapDropShadowFilter::~QPixmapDropShadowFilter()
+{
+}
+
+/*!
+ Returns the radius in pixels of the blur on the drop shadow.
+
+ A smaller radius results in a sharper shadow.
+
+ \sa color(), offset()
+
+ \internal
+*/
+qreal QPixmapDropShadowFilter::blurRadius() const
+{
+ Q_D(const QPixmapDropShadowFilter);
+ return d->radius;
+}
+
+/*!
+ Sets the radius in pixels of the blur on the drop shadow to the \a radius specified.
+
+ Using a smaller radius results in a sharper shadow.
+
+ \sa setColor(), setOffset()
+
+ \internal
+*/
+void QPixmapDropShadowFilter::setBlurRadius(qreal radius)
+{
+ Q_D(QPixmapDropShadowFilter);
+ d->radius = radius;
+}
+
+/*!
+ Returns the color of the drop shadow.
+
+ \sa blurRadius(), offset()
+
+ \internal
+*/
+QColor QPixmapDropShadowFilter::color() const
+{
+ Q_D(const QPixmapDropShadowFilter);
+ return d->color;
+}
+
+/*!
+ Sets the color of the drop shadow to the \a color specified.
+
+ \sa setBlurRadius(), setOffset()
+
+ \internal
+*/
+void QPixmapDropShadowFilter::setColor(const QColor &color)
+{
+ Q_D(QPixmapDropShadowFilter);
+ d->color = color;
+}
+
+/*!
+ Returns the shadow offset in pixels.
+
+ \sa blurRadius(), color()
+
+ \internal
+*/
+QPointF QPixmapDropShadowFilter::offset() const
+{
+ Q_D(const QPixmapDropShadowFilter);
+ return d->offset;
+}
+
+/*!
+ Sets the shadow offset in pixels to the \a offset specified.
+
+ \sa setBlurRadius(), setColor()
+
+ \internal
+*/
+void QPixmapDropShadowFilter::setOffset(const QPointF &offset)
+{
+ Q_D(QPixmapDropShadowFilter);
+ d->offset = offset;
+}
+
+/*!
+ \fn void QPixmapDropShadowFilter::setOffset(qreal dx, qreal dy)
+ \overload
+
+ Sets the shadow offset in pixels to be the displacement specified by the
+ horizontal \a dx and vertical \a dy coordinates.
+
+ \sa setBlurRadius(), setColor()
+
+ \internal
+*/
+
+/*!
+ \internal
+ */
+QRectF QPixmapDropShadowFilter::boundingRectFor(const QRectF &rect) const
+{
+ Q_D(const QPixmapDropShadowFilter);
+ return rect.united(rect.translated(d->offset).adjusted(-d->radius, -d->radius, d->radius, d->radius));
+}
+
+/*!
+ \internal
+ */
+void QPixmapDropShadowFilter::draw(QPainter *p,
+ const QPointF &pos,
+ const QPixmap &px,
+ const QRectF &src) const
+{
+ Q_D(const QPixmapDropShadowFilter);
+
+ if (px.isNull())
+ return;
+
+ QPixmapFilter *filter = p->paintEngine() && p->paintEngine()->isExtended() ?
+ static_cast<QPaintEngineEx *>(p->paintEngine())->pixmapFilter(type(), this) : 0;
+ QPixmapDropShadowFilter *dropShadowFilter = static_cast<QPixmapDropShadowFilter*>(filter);
+ if (dropShadowFilter) {
+ dropShadowFilter->setColor(d->color);
+ dropShadowFilter->setBlurRadius(d->radius);
+ dropShadowFilter->setOffset(d->offset);
+ dropShadowFilter->draw(p, pos, px, src);
+ return;
+ }
+
+ QImage tmp(px.size(), QImage::Format_ARGB32_Premultiplied);
+ tmp.fill(0);
+ QPainter tmpPainter(&tmp);
+ tmpPainter.setCompositionMode(QPainter::CompositionMode_Source);
+ tmpPainter.drawPixmap(d->offset, px);
+ tmpPainter.end();
+
+ // blur the alpha channel
+ QImage blurred(tmp.size(), QImage::Format_ARGB32_Premultiplied);
+ blurred.fill(0);
+ QPainter blurPainter(&blurred);
+ qt_blurImage(&blurPainter, tmp, d->radius, false, true);
+ blurPainter.end();
+
+ tmp = blurred;
+
+ // blacken the image...
+ tmpPainter.begin(&tmp);
+ tmpPainter.setCompositionMode(QPainter::CompositionMode_SourceIn);
+ tmpPainter.fillRect(tmp.rect(), d->color);
+ tmpPainter.end();
+
+ // draw the blurred drop shadow...
+ p->drawImage(pos, tmp);
+
+ // Draw the actual pixmap...
+ p->drawPixmap(pos, px, src);
+}
+
+QT_END_NAMESPACE
+
+#endif //QT_NO_GRAPHICSEFFECT
diff --git a/src/widgets/effects/qpixmapfilter_p.h b/src/widgets/effects/qpixmapfilter_p.h
new file mode 100644
index 0000000000..c20d762e60
--- /dev/null
+++ b/src/widgets/effects/qpixmapfilter_p.h
@@ -0,0 +1,196 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPIXMAPFILTER_H
+#define QPIXMAPFILTER_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qnamespace.h>
+#include <QtGui/qpixmap.h>
+#include <QtWidgets/qgraphicseffect.h>
+
+#ifndef QT_NO_GRAPHICSEFFECT
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QPainter;
+class QPixmapData;
+
+class QPixmapFilterPrivate;
+
+class Q_GUI_EXPORT QPixmapFilter : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QPixmapFilter)
+public:
+ virtual ~QPixmapFilter() = 0;
+
+ enum FilterType {
+ ConvolutionFilter,
+ ColorizeFilter,
+ DropShadowFilter,
+ BlurFilter,
+
+ UserFilter = 1024
+ };
+
+ FilterType type() const;
+
+ virtual QRectF boundingRectFor(const QRectF &rect) const;
+
+ virtual void draw(QPainter *painter, const QPointF &p, const QPixmap &src, const QRectF &srcRect = QRectF()) const = 0;
+
+protected:
+ QPixmapFilter(QPixmapFilterPrivate &d, FilterType type, QObject *parent);
+ QPixmapFilter(FilterType type, QObject *parent);
+};
+
+class QPixmapConvolutionFilterPrivate;
+
+class Q_GUI_EXPORT QPixmapConvolutionFilter : public QPixmapFilter
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QPixmapConvolutionFilter)
+
+public:
+ QPixmapConvolutionFilter(QObject *parent = 0);
+ ~QPixmapConvolutionFilter();
+
+ void setConvolutionKernel(const qreal *matrix, int rows, int columns);
+
+ QRectF boundingRectFor(const QRectF &rect) const;
+ void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect = QRectF()) const;
+
+private:
+ friend class QGLPixmapConvolutionFilter;
+ friend class QVGPixmapConvolutionFilter;
+ const qreal *convolutionKernel() const;
+ int rows() const;
+ int columns() const;
+};
+
+class QPixmapBlurFilterPrivate;
+
+class Q_GUI_EXPORT QPixmapBlurFilter : public QPixmapFilter
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QPixmapBlurFilter)
+
+public:
+ QPixmapBlurFilter(QObject *parent = 0);
+ ~QPixmapBlurFilter();
+
+ void setRadius(qreal radius);
+ void setBlurHints(QGraphicsBlurEffect::BlurHints hints);
+
+ qreal radius() const;
+ QGraphicsBlurEffect::BlurHints blurHints() const;
+
+ QRectF boundingRectFor(const QRectF &rect) const;
+ void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect = QRectF()) const;
+
+private:
+ friend class QGLPixmapBlurFilter;
+};
+
+class QPixmapColorizeFilterPrivate;
+
+class Q_GUI_EXPORT QPixmapColorizeFilter : public QPixmapFilter
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QPixmapColorizeFilter)
+
+public:
+ QPixmapColorizeFilter(QObject *parent = 0);
+
+ void setColor(const QColor& color);
+ QColor color() const;
+
+ void setStrength(qreal strength);
+ qreal strength() const;
+
+ void draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect = QRectF()) const;
+};
+
+class QPixmapDropShadowFilterPrivate;
+
+class Q_GUI_EXPORT QPixmapDropShadowFilter : public QPixmapFilter
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QPixmapDropShadowFilter)
+
+public:
+ QPixmapDropShadowFilter(QObject *parent = 0);
+ ~QPixmapDropShadowFilter();
+
+ QRectF boundingRectFor(const QRectF &rect) const;
+ void draw(QPainter *p, const QPointF &pos, const QPixmap &px, const QRectF &src = QRectF()) const;
+
+ qreal blurRadius() const;
+ void setBlurRadius(qreal radius);
+
+ QColor color() const;
+ void setColor(const QColor &color);
+
+ QPointF offset() const;
+ void setOffset(const QPointF &offset);
+ inline void setOffset(qreal dx, qreal dy) { setOffset(QPointF(dx, dy)); }
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif //QT_NO_GRAPHICSEFFECT
+#endif // QPIXMAPFILTER_H
diff --git a/src/gui/graphicsview/graphicsview.pri b/src/widgets/graphicsview/graphicsview.pri
index 547d7ce7ae..547d7ce7ae 100644
--- a/src/gui/graphicsview/graphicsview.pri
+++ b/src/widgets/graphicsview/graphicsview.pri
diff --git a/src/gui/graphicsview/qgraph_p.h b/src/widgets/graphicsview/qgraph_p.h
index 094fbd1c2a..094fbd1c2a 100644
--- a/src/gui/graphicsview/qgraph_p.h
+++ b/src/widgets/graphicsview/qgraph_p.h
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout.cpp
index 9bb5424641..9bb5424641 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout.cpp
+++ b/src/widgets/graphicsview/qgraphicsanchorlayout.cpp
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout.h b/src/widgets/graphicsview/qgraphicsanchorlayout.h
new file mode 100644
index 0000000000..ab4f957598
--- /dev/null
+++ b/src/widgets/graphicsview/qgraphicsanchorlayout.h
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGRAPHICSANCHORLAYOUT_H
+#define QGRAPHICSANCHORLAYOUT_H
+
+#include <QtWidgets/qgraphicsitem.h>
+#include <QtWidgets/qgraphicslayout.h>
+
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
+
+class QGraphicsAnchorPrivate;
+class QGraphicsAnchorLayout;
+class QGraphicsAnchorLayoutPrivate;
+
+class Q_GUI_EXPORT QGraphicsAnchor : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing RESET unsetSpacing)
+ Q_PROPERTY(QSizePolicy::Policy sizePolicy READ sizePolicy WRITE setSizePolicy)
+public:
+ void setSpacing(qreal spacing);
+ void unsetSpacing();
+ qreal spacing() const;
+ void setSizePolicy(QSizePolicy::Policy policy);
+ QSizePolicy::Policy sizePolicy() const;
+ ~QGraphicsAnchor();
+private:
+ QGraphicsAnchor(QGraphicsAnchorLayout *parent);
+
+ Q_DECLARE_PRIVATE(QGraphicsAnchor)
+
+ friend class QGraphicsAnchorLayoutPrivate;
+ friend struct AnchorData;
+};
+
+class Q_GUI_EXPORT QGraphicsAnchorLayout : public QGraphicsLayout
+{
+public:
+ QGraphicsAnchorLayout(QGraphicsLayoutItem *parent = 0);
+ virtual ~QGraphicsAnchorLayout();
+
+ QGraphicsAnchor *addAnchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,
+ QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge);
+ QGraphicsAnchor *anchor(QGraphicsLayoutItem *firstItem, Qt::AnchorPoint firstEdge,
+ QGraphicsLayoutItem *secondItem, Qt::AnchorPoint secondEdge);
+
+ void addCornerAnchors(QGraphicsLayoutItem *firstItem, Qt::Corner firstCorner,
+ QGraphicsLayoutItem *secondItem, Qt::Corner secondCorner);
+
+ void addAnchors(QGraphicsLayoutItem *firstItem,
+ QGraphicsLayoutItem *secondItem,
+ Qt::Orientations orientations = Qt::Horizontal | Qt::Vertical);
+
+ void setHorizontalSpacing(qreal spacing);
+ void setVerticalSpacing(qreal spacing);
+ void setSpacing(qreal spacing);
+ qreal horizontalSpacing() const;
+ qreal verticalSpacing() const;
+
+ void removeAt(int index);
+ void setGeometry(const QRectF &rect);
+ int count() const;
+ QGraphicsLayoutItem *itemAt(int index) const;
+
+ void invalidate();
+protected:
+ QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
+
+private:
+ Q_DISABLE_COPY(QGraphicsAnchorLayout)
+ Q_DECLARE_PRIVATE(QGraphicsAnchorLayout)
+
+ friend class QGraphicsAnchor;
+};
+
+#endif
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
new file mode 100644
index 0000000000..5f9841ed12
--- /dev/null
+++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -0,0 +1,3015 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtWidgets/qwidget.h>
+#include <QtWidgets/qapplication.h>
+#include <QtCore/qlinkedlist.h>
+#include <QtCore/qstack.h>
+
+#ifdef QT_DEBUG
+#include <QtCore/qfile.h>
+#endif
+
+#include "qgraphicsanchorlayout_p.h"
+
+#ifndef QT_NO_GRAPHICSVIEW
+QT_BEGIN_NAMESPACE
+
+// To ensure that all variables inside the simplex solver are non-negative,
+// we limit the size of anchors in the interval [-limit, limit]. Then before
+// sending them to the simplex solver we add "limit" as an offset, so that
+// they are actually calculated in the interval [0, 2 * limit]
+// To avoid numerical errors in platforms where we use single precision,
+// we use a tighter limit for the variables range.
+const qreal g_offset = (sizeof(qreal) == sizeof(double)) ? QWIDGETSIZE_MAX : QWIDGETSIZE_MAX / 32;
+
+QGraphicsAnchorPrivate::QGraphicsAnchorPrivate(int version)
+ : QObjectPrivate(version), layoutPrivate(0), data(0),
+ sizePolicy(QSizePolicy::Fixed), preferredSize(0),
+ hasSize(true)
+{
+}
+
+QGraphicsAnchorPrivate::~QGraphicsAnchorPrivate()
+{
+ if (data) {
+ // The QGraphicsAnchor was already deleted at this moment. We must clean
+ // the dangling pointer to avoid double deletion in the AnchorData dtor.
+ data->graphicsAnchor = 0;
+
+ layoutPrivate->removeAnchor(data->from, data->to);
+ }
+}
+
+void QGraphicsAnchorPrivate::setSizePolicy(QSizePolicy::Policy policy)
+{
+ if (sizePolicy != policy) {
+ sizePolicy = policy;
+ layoutPrivate->q_func()->invalidate();
+ }
+}
+
+void QGraphicsAnchorPrivate::setSpacing(qreal value)
+{
+ if (!data) {
+ qWarning("QGraphicsAnchor::setSpacing: The anchor does not exist.");
+ return;
+ }
+
+ if (hasSize && (preferredSize == value))
+ return;
+
+ // The anchor has an user-defined size
+ hasSize = true;
+ preferredSize = value;
+
+ layoutPrivate->q_func()->invalidate();
+}
+
+void QGraphicsAnchorPrivate::unsetSpacing()
+{
+ if (!data) {
+ qWarning("QGraphicsAnchor::setSpacing: The anchor does not exist.");
+ return;
+ }
+
+ // Return to standard direction
+ hasSize = false;
+
+ layoutPrivate->q_func()->invalidate();
+}
+
+qreal QGraphicsAnchorPrivate::spacing() const
+{
+ if (!data) {
+ qWarning("QGraphicsAnchor::setSpacing: The anchor does not exist.");
+ return 0;
+ }
+
+ return preferredSize;
+}
+
+
+static void applySizePolicy(QSizePolicy::Policy policy,
+ qreal minSizeHint, qreal prefSizeHint, qreal maxSizeHint,
+ qreal *minSize, qreal *prefSize,
+ qreal *maxSize)
+{
+ // minSize, prefSize and maxSize are initialized
+ // with item's preferred Size: this is QSizePolicy::Fixed.
+ //
+ // Then we check each flag to find the resultant QSizePolicy,
+ // according to the following table:
+ //
+ // constant value
+ // QSizePolicy::Fixed 0
+ // QSizePolicy::Minimum GrowFlag
+ // QSizePolicy::Maximum ShrinkFlag
+ // QSizePolicy::Preferred GrowFlag | ShrinkFlag
+ // QSizePolicy::Ignored GrowFlag | ShrinkFlag | IgnoreFlag
+
+ if (policy & QSizePolicy::ShrinkFlag)
+ *minSize = minSizeHint;
+ else
+ *minSize = prefSizeHint;
+
+ if (policy & QSizePolicy::GrowFlag)
+ *maxSize = maxSizeHint;
+ else
+ *maxSize = prefSizeHint;
+
+ // Note that these two initializations are affected by the previous flags
+ if (policy & QSizePolicy::IgnoreFlag)
+ *prefSize = *minSize;
+ else
+ *prefSize = prefSizeHint;
+}
+
+AnchorData::~AnchorData()
+{
+ if (graphicsAnchor) {
+ // Remove reference to ourself to avoid double removal in
+ // QGraphicsAnchorPrivate dtor.
+ graphicsAnchor->d_func()->data = 0;
+
+ delete graphicsAnchor;
+ }
+}
+
+
+void AnchorData::refreshSizeHints(const QLayoutStyleInfo *styleInfo)
+{
+ QSizePolicy::Policy policy;
+ qreal minSizeHint;
+ qreal prefSizeHint;
+ qreal maxSizeHint;
+
+ if (item) {
+ // It is an internal anchor, fetch size information from the item
+ if (isLayoutAnchor) {
+ minSize = 0;
+ prefSize = 0;
+ maxSize = QWIDGETSIZE_MAX;
+ if (isCenterAnchor)
+ maxSize /= 2;
+
+ minPrefSize = prefSize;
+ maxPrefSize = maxSize;
+ return;
+ } else {
+ if (orientation == QGraphicsAnchorLayoutPrivate::Horizontal) {
+ policy = item->sizePolicy().horizontalPolicy();
+ minSizeHint = item->effectiveSizeHint(Qt::MinimumSize).width();
+ prefSizeHint = item->effectiveSizeHint(Qt::PreferredSize).width();
+ maxSizeHint = item->effectiveSizeHint(Qt::MaximumSize).width();
+ } else {
+ policy = item->sizePolicy().verticalPolicy();
+ minSizeHint = item->effectiveSizeHint(Qt::MinimumSize).height();
+ prefSizeHint = item->effectiveSizeHint(Qt::PreferredSize).height();
+ maxSizeHint = item->effectiveSizeHint(Qt::MaximumSize).height();
+ }
+
+ if (isCenterAnchor) {
+ minSizeHint /= 2;
+ prefSizeHint /= 2;
+ maxSizeHint /= 2;
+ }
+ }
+ } else {
+ // It is a user-created anchor, fetch size information from the associated QGraphicsAnchor
+ Q_ASSERT(graphicsAnchor);
+ QGraphicsAnchorPrivate *anchorPrivate = graphicsAnchor->d_func();
+
+ // Policy, min and max sizes are straightforward
+ policy = anchorPrivate->sizePolicy;
+ minSizeHint = 0;
+ maxSizeHint = QWIDGETSIZE_MAX;
+
+ // Preferred Size
+ if (anchorPrivate->hasSize) {
+ // Anchor has user-defined size
+ prefSizeHint = anchorPrivate->preferredSize;
+ } else {
+ // Fetch size information from style
+ const Qt::Orientation orient = Qt::Orientation(QGraphicsAnchorLayoutPrivate::edgeOrientation(from->m_edge) + 1);
+ qreal s = styleInfo->defaultSpacing(orient);
+ if (s < 0) {
+ QSizePolicy::ControlType controlTypeFrom = from->m_item->sizePolicy().controlType();
+ QSizePolicy::ControlType controlTypeTo = to->m_item->sizePolicy().controlType();
+ s = styleInfo->perItemSpacing(controlTypeFrom, controlTypeTo, orient);
+
+ // ### Currently we do not support negative anchors inside the graph.
+ // To avoid those being created by a negative style spacing, we must
+ // make this test.
+ if (s < 0)
+ s = 0;
+ }
+ prefSizeHint = s;
+ }
+ }
+
+ // Fill minSize, prefSize and maxSize based on policy and sizeHints
+ applySizePolicy(policy, minSizeHint, prefSizeHint, maxSizeHint,
+ &minSize, &prefSize, &maxSize);
+
+ minPrefSize = prefSize;
+ maxPrefSize = maxSize;
+
+ // Set the anchor effective sizes to preferred.
+ //
+ // Note: The idea here is that all items should remain at their
+ // preferred size unless where that's impossible. In cases where
+ // the item is subject to restrictions (anchored to the layout
+ // edges, for instance), the simplex solver will be run to
+ // recalculate and override the values we set here.
+ sizeAtMinimum = prefSize;
+ sizeAtPreferred = prefSize;
+ sizeAtMaximum = prefSize;
+}
+
+void ParallelAnchorData::updateChildrenSizes()
+{
+ firstEdge->sizeAtMinimum = sizeAtMinimum;
+ firstEdge->sizeAtPreferred = sizeAtPreferred;
+ firstEdge->sizeAtMaximum = sizeAtMaximum;
+
+ if (secondForward()) {
+ secondEdge->sizeAtMinimum = sizeAtMinimum;
+ secondEdge->sizeAtPreferred = sizeAtPreferred;
+ secondEdge->sizeAtMaximum = sizeAtMaximum;
+ } else {
+ secondEdge->sizeAtMinimum = -sizeAtMinimum;
+ secondEdge->sizeAtPreferred = -sizeAtPreferred;
+ secondEdge->sizeAtMaximum = -sizeAtMaximum;
+ }
+
+ firstEdge->updateChildrenSizes();
+ secondEdge->updateChildrenSizes();
+}
+
+/*
+ \internal
+
+ Initialize the parallel anchor size hints using the sizeHint information from
+ its children.
+
+ Note that parallel groups can lead to unfeasibility, so during calculation, we can
+ find out one unfeasibility. Because of that this method return boolean. This can't
+ happen in sequential, so there the method is void.
+ */
+bool ParallelAnchorData::calculateSizeHints()
+{
+ // Normalize second child sizes.
+ // A negative anchor of sizes min, minPref, pref, maxPref and max, is equivalent
+ // to a forward anchor of sizes -max, -maxPref, -pref, -minPref, -min
+ qreal secondMin;
+ qreal secondMinPref;
+ qreal secondPref;
+ qreal secondMaxPref;
+ qreal secondMax;
+
+ if (secondForward()) {
+ secondMin = secondEdge->minSize;
+ secondMinPref = secondEdge->minPrefSize;
+ secondPref = secondEdge->prefSize;
+ secondMaxPref = secondEdge->maxPrefSize;
+ secondMax = secondEdge->maxSize;
+ } else {
+ secondMin = -secondEdge->maxSize;
+ secondMinPref = -secondEdge->maxPrefSize;
+ secondPref = -secondEdge->prefSize;
+ secondMaxPref = -secondEdge->minPrefSize;
+ secondMax = -secondEdge->minSize;
+ }
+
+ minSize = qMax(firstEdge->minSize, secondMin);
+ maxSize = qMin(firstEdge->maxSize, secondMax);
+
+ // This condition means that the maximum size of one anchor being simplified is smaller than
+ // the minimum size of the other anchor. The consequence is that there won't be a valid size
+ // for this parallel setup.
+ if (minSize > maxSize) {
+ return false;
+ }
+
+ // Preferred size calculation
+ // The calculation of preferred size is done as follows:
+ //
+ // 1) Check whether one of the child anchors is the layout structural anchor
+ // If so, we can simply copy the preferred information from the other child,
+ // after bounding it to our minimum and maximum sizes.
+ // If not, then we proceed with the actual calculations.
+ //
+ // 2) The whole algorithm for preferred size calculation is based on the fact
+ // that, if a given anchor cannot remain at its preferred size, it'd rather
+ // grow than shrink.
+ //
+ // What happens though is that while this affirmative is true for simple
+ // anchors, it may not be true for sequential anchors that have one or more
+ // reversed anchors inside it. That happens because when a sequential anchor
+ // grows, any reversed anchors inside it may be required to shrink, something
+ // we try to avoid, as said above.
+ //
+ // To overcome this, besides their actual preferred size "prefSize", each anchor
+ // exports what we call "minPrefSize" and "maxPrefSize". These two values define
+ // a surrounding interval where, if required to move, the anchor would rather
+ // remain inside.
+ //
+ // For standard anchors, this area simply represents the region between
+ // prefSize and maxSize, which makes sense since our first affirmation.
+ // For composed anchors, these values are calculated as to reduce the global
+ // "damage", that is, to reduce the total deviation and the total amount of
+ // anchors that had to shrink.
+
+ if (firstEdge->isLayoutAnchor) {
+ prefSize = qBound(minSize, secondPref, maxSize);
+ minPrefSize = qBound(minSize, secondMinPref, maxSize);
+ maxPrefSize = qBound(minSize, secondMaxPref, maxSize);
+ } else if (secondEdge->isLayoutAnchor) {
+ prefSize = qBound(minSize, firstEdge->prefSize, maxSize);
+ minPrefSize = qBound(minSize, firstEdge->minPrefSize, maxSize);
+ maxPrefSize = qBound(minSize, firstEdge->maxPrefSize, maxSize);
+ } else {
+ // Calculate the intersection between the "preferred" regions of each child
+ const qreal lowerBoundary =
+ qBound(minSize, qMax(firstEdge->minPrefSize, secondMinPref), maxSize);
+ const qreal upperBoundary =
+ qBound(minSize, qMin(firstEdge->maxPrefSize, secondMaxPref), maxSize);
+ const qreal prefMean =
+ qBound(minSize, (firstEdge->prefSize + secondPref) / 2, maxSize);
+
+ if (lowerBoundary < upperBoundary) {
+ // If there is an intersection between the two regions, this intersection
+ // will be used as the preferred region of the parallel anchor itself.
+ // The preferred size will be the bounded average between the two preferred
+ // sizes.
+ prefSize = qBound(lowerBoundary, prefMean, upperBoundary);
+ minPrefSize = lowerBoundary;
+ maxPrefSize = upperBoundary;
+ } else {
+ // If there is no intersection, we have to attribute "damage" to at least
+ // one of the children. The minimum total damage is achieved in points
+ // inside the region that extends from (1) the upper boundary of the lower
+ // region to (2) the lower boundary of the upper region.
+ // Then, we expose this region as _our_ preferred region and once again,
+ // use the bounded average as our preferred size.
+ prefSize = qBound(upperBoundary, prefMean, lowerBoundary);
+ minPrefSize = upperBoundary;
+ maxPrefSize = lowerBoundary;
+ }
+ }
+
+ // See comment in AnchorData::refreshSizeHints() about sizeAt* values
+ sizeAtMinimum = prefSize;
+ sizeAtPreferred = prefSize;
+ sizeAtMaximum = prefSize;
+
+ return true;
+}
+
+/*!
+ \internal
+ returns the factor in the interval [-1, 1].
+ -1 is at Minimum
+ 0 is at Preferred
+ 1 is at Maximum
+*/
+static QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> getFactor(qreal value, qreal min,
+ qreal minPref, qreal pref,
+ qreal maxPref, qreal max)
+{
+ QGraphicsAnchorLayoutPrivate::Interval interval;
+ qreal lower;
+ qreal upper;
+
+ if (value < minPref) {
+ interval = QGraphicsAnchorLayoutPrivate::MinimumToMinPreferred;
+ lower = min;
+ upper = minPref;
+ } else if (value < pref) {
+ interval = QGraphicsAnchorLayoutPrivate::MinPreferredToPreferred;
+ lower = minPref;
+ upper = pref;
+ } else if (value < maxPref) {
+ interval = QGraphicsAnchorLayoutPrivate::PreferredToMaxPreferred;
+ lower = pref;
+ upper = maxPref;
+ } else {
+ interval = QGraphicsAnchorLayoutPrivate::MaxPreferredToMaximum;
+ lower = maxPref;
+ upper = max;
+ }
+
+ qreal progress;
+ if (upper == lower) {
+ progress = 0;
+ } else {
+ progress = (value - lower) / (upper - lower);
+ }
+
+ return qMakePair(interval, progress);
+}
+
+static qreal interpolate(const QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> &factor,
+ qreal min, qreal minPref, qreal pref, qreal maxPref, qreal max)
+{
+ qreal lower = 0;
+ qreal upper = 0;
+
+ switch (factor.first) {
+ case QGraphicsAnchorLayoutPrivate::MinimumToMinPreferred:
+ lower = min;
+ upper = minPref;
+ break;
+ case QGraphicsAnchorLayoutPrivate::MinPreferredToPreferred:
+ lower = minPref;
+ upper = pref;
+ break;
+ case QGraphicsAnchorLayoutPrivate::PreferredToMaxPreferred:
+ lower = pref;
+ upper = maxPref;
+ break;
+ case QGraphicsAnchorLayoutPrivate::MaxPreferredToMaximum:
+ lower = maxPref;
+ upper = max;
+ break;
+ }
+
+ return lower + factor.second * (upper - lower);
+}
+
+void SequentialAnchorData::updateChildrenSizes()
+{
+ // Band here refers if the value is in the Minimum To Preferred
+ // band (the lower band) or the Preferred To Maximum (the upper band).
+
+ const QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> minFactor =
+ getFactor(sizeAtMinimum, minSize, minPrefSize, prefSize, maxPrefSize, maxSize);
+ const QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> prefFactor =
+ getFactor(sizeAtPreferred, minSize, minPrefSize, prefSize, maxPrefSize, maxSize);
+ const QPair<QGraphicsAnchorLayoutPrivate::Interval, qreal> maxFactor =
+ getFactor(sizeAtMaximum, minSize, minPrefSize, prefSize, maxPrefSize, maxSize);
+
+ // XXX This is not safe if Vertex simplification takes place after the sequential
+ // anchor is created. In that case, "prev" will be a group-vertex, different from
+ // "from" or "to", that _contains_ one of them.
+ AnchorVertex *prev = from;
+
+ for (int i = 0; i < m_edges.count(); ++i) {
+ AnchorData *e = m_edges.at(i);
+
+ const bool edgeIsForward = (e->from == prev);
+ if (edgeIsForward) {
+ e->sizeAtMinimum = interpolate(minFactor, e->minSize, e->minPrefSize,
+ e->prefSize, e->maxPrefSize, e->maxSize);
+ e->sizeAtPreferred = interpolate(prefFactor, e->minSize, e->minPrefSize,
+ e->prefSize, e->maxPrefSize, e->maxSize);
+ e->sizeAtMaximum = interpolate(maxFactor, e->minSize, e->minPrefSize,
+ e->prefSize, e->maxPrefSize, e->maxSize);
+ prev = e->to;
+ } else {
+ Q_ASSERT(prev == e->to);
+ e->sizeAtMinimum = interpolate(minFactor, e->maxSize, e->maxPrefSize,
+ e->prefSize, e->minPrefSize, e->minSize);
+ e->sizeAtPreferred = interpolate(prefFactor, e->maxSize, e->maxPrefSize,
+ e->prefSize, e->minPrefSize, e->minSize);
+ e->sizeAtMaximum = interpolate(maxFactor, e->maxSize, e->maxPrefSize,
+ e->prefSize, e->minPrefSize, e->minSize);
+ prev = e->from;
+ }
+
+ e->updateChildrenSizes();
+ }
+}
+
+void SequentialAnchorData::calculateSizeHints()
+{
+ minSize = 0;
+ prefSize = 0;
+ maxSize = 0;
+ minPrefSize = 0;
+ maxPrefSize = 0;
+
+ AnchorVertex *prev = from;
+
+ for (int i = 0; i < m_edges.count(); ++i) {
+ AnchorData *edge = m_edges.at(i);
+
+ const bool edgeIsForward = (edge->from == prev);
+ if (edgeIsForward) {
+ minSize += edge->minSize;
+ prefSize += edge->prefSize;
+ maxSize += edge->maxSize;
+ minPrefSize += edge->minPrefSize;
+ maxPrefSize += edge->maxPrefSize;
+ prev = edge->to;
+ } else {
+ Q_ASSERT(prev == edge->to);
+ minSize -= edge->maxSize;
+ prefSize -= edge->prefSize;
+ maxSize -= edge->minSize;
+ minPrefSize -= edge->maxPrefSize;
+ maxPrefSize -= edge->minPrefSize;
+ prev = edge->from;
+ }
+ }
+
+ // See comment in AnchorData::refreshSizeHints() about sizeAt* values
+ sizeAtMinimum = prefSize;
+ sizeAtPreferred = prefSize;
+ sizeAtMaximum = prefSize;
+}
+
+#ifdef QT_DEBUG
+void AnchorData::dump(int indent) {
+ if (type == Parallel) {
+ qDebug("%*s type: parallel:", indent, "");
+ ParallelAnchorData *p = static_cast<ParallelAnchorData *>(this);
+ p->firstEdge->dump(indent+2);
+ p->secondEdge->dump(indent+2);
+ } else if (type == Sequential) {
+ SequentialAnchorData *s = static_cast<SequentialAnchorData *>(this);
+ int kids = s->m_edges.count();
+ qDebug("%*s type: sequential(%d):", indent, "", kids);
+ for (int i = 0; i < kids; ++i) {
+ s->m_edges.at(i)->dump(indent+2);
+ }
+ } else {
+ qDebug("%*s type: Normal:", indent, "");
+ }
+}
+
+#endif
+
+QSimplexConstraint *GraphPath::constraint(const GraphPath &path) const
+{
+ // Calculate
+ QSet<AnchorData *> cPositives;
+ QSet<AnchorData *> cNegatives;
+ QSet<AnchorData *> intersection;
+
+ cPositives = positives + path.negatives;
+ cNegatives = negatives + path.positives;
+
+ intersection = cPositives & cNegatives;
+
+ cPositives -= intersection;
+ cNegatives -= intersection;
+
+ // Fill
+ QSimplexConstraint *c = new QSimplexConstraint;
+ QSet<AnchorData *>::iterator i;
+ for (i = cPositives.begin(); i != cPositives.end(); ++i)
+ c->variables.insert(*i, 1.0);
+
+ for (i = cNegatives.begin(); i != cNegatives.end(); ++i)
+ c->variables.insert(*i, -1.0);
+
+ return c;
+}
+
+#ifdef QT_DEBUG
+QString GraphPath::toString() const
+{
+ QString string(QLatin1String("Path: "));
+ foreach(AnchorData *edge, positives)
+ string += QString::fromAscii(" (+++) %1").arg(edge->toString());
+
+ foreach(AnchorData *edge, negatives)
+ string += QString::fromAscii(" (---) %1").arg(edge->toString());
+
+ return string;
+}
+#endif
+
+QGraphicsAnchorLayoutPrivate::QGraphicsAnchorLayoutPrivate()
+ : calculateGraphCacheDirty(true), styleInfoDirty(true)
+{
+ for (int i = 0; i < NOrientations; ++i) {
+ for (int j = 0; j < 3; ++j) {
+ sizeHints[i][j] = -1;
+ }
+ interpolationProgress[i] = -1;
+
+ spacings[i] = -1;
+ graphHasConflicts[i] = false;
+
+ layoutFirstVertex[i] = 0;
+ layoutCentralVertex[i] = 0;
+ layoutLastVertex[i] = 0;
+ }
+}
+
+Qt::AnchorPoint QGraphicsAnchorLayoutPrivate::oppositeEdge(Qt::AnchorPoint edge)
+{
+ switch (edge) {
+ case Qt::AnchorLeft:
+ edge = Qt::AnchorRight;
+ break;
+ case Qt::AnchorRight:
+ edge = Qt::AnchorLeft;
+ break;
+ case Qt::AnchorTop:
+ edge = Qt::AnchorBottom;
+ break;
+ case Qt::AnchorBottom:
+ edge = Qt::AnchorTop;
+ break;
+ default:
+ break;
+ }
+ return edge;
+}
+
+
+/*!
+ * \internal
+ *
+ * helper function in order to avoid overflowing anchor sizes
+ * the returned size will never be larger than FLT_MAX
+ *
+ */
+inline static qreal checkAdd(qreal a, qreal b)
+{
+ if (FLT_MAX - b < a)
+ return FLT_MAX;
+ return a + b;
+}
+
+/*!
+ \internal
+
+ Adds \a newAnchor to the graph.
+
+ Returns the newAnchor itself if it could be added without further changes to the graph. If a
+ new parallel anchor had to be created, then returns the new parallel anchor. If a parallel anchor
+ had to be created and it results in an unfeasible setup, \a feasible is set to false, otherwise
+ true.
+
+ Note that in the case a new parallel anchor is created, it might also take over some constraints
+ from its children anchors.
+*/
+AnchorData *QGraphicsAnchorLayoutPrivate::addAnchorMaybeParallel(AnchorData *newAnchor, bool *feasible)
+{
+ Orientation orientation = Orientation(newAnchor->orientation);
+ Graph<AnchorVertex, AnchorData> &g = graph[orientation];
+ *feasible = true;
+
+ // If already exists one anchor where newAnchor is supposed to be, we create a parallel
+ // anchor.
+ if (AnchorData *oldAnchor = g.takeEdge(newAnchor->from, newAnchor->to)) {
+ ParallelAnchorData *parallel = new ParallelAnchorData(oldAnchor, newAnchor);
+
+ // The parallel anchor will "replace" its children anchors in
+ // every center constraint that they appear.
+
+ // ### If the dependent (center) anchors had reference(s) to their constraints, we
+ // could avoid traversing all the itemCenterConstraints.
+ QList<QSimplexConstraint *> &constraints = itemCenterConstraints[orientation];
+
+ AnchorData *children[2] = { oldAnchor, newAnchor };
+ QList<QSimplexConstraint *> *childrenConstraints[2] = { &parallel->m_firstConstraints,
+ &parallel->m_secondConstraints };
+
+ for (int i = 0; i < 2; ++i) {
+ AnchorData *child = children[i];
+ QList<QSimplexConstraint *> *childConstraints = childrenConstraints[i];
+
+ // We need to fix the second child constraints if the parallel group will have the
+ // opposite direction of the second child anchor. For the point of view of external
+ // entities, this anchor was reversed. So if at some point we say that the parallel
+ // has a value of 20, this mean that the second child (when reversed) will be
+ // assigned -20.
+ const bool needsReverse = i == 1 && !parallel->secondForward();
+
+ if (!child->isCenterAnchor)
+ continue;
+
+ parallel->isCenterAnchor = true;
+
+ for (int j = 0; j < constraints.count(); ++j) {
+ QSimplexConstraint *c = constraints[j];
+ if (c->variables.contains(child)) {
+ childConstraints->append(c);
+ qreal v = c->variables.take(child);
+ if (needsReverse)
+ v *= -1;
+ c->variables.insert(parallel, v);
+ }
+ }
+ }
+
+ // At this point we can identify that the parallel anchor is not feasible, e.g. one
+ // anchor minimum size is bigger than the other anchor maximum size.
+ *feasible = parallel->calculateSizeHints();
+ newAnchor = parallel;
+ }
+
+ g.createEdge(newAnchor->from, newAnchor->to, newAnchor);
+ return newAnchor;
+}
+
+/*!
+ \internal
+
+ Takes the sequence of vertices described by (\a before, \a vertices, \a after) and removes
+ all anchors connected to the vertices in \a vertices, returning one simplified anchor between
+ \a before and \a after.
+
+ Note that this function doesn't add the created anchor to the graph. This should be done by
+ the caller.
+*/
+static AnchorData *createSequence(Graph<AnchorVertex, AnchorData> *graph,
+ AnchorVertex *before,
+ const QVector<AnchorVertex*> &vertices,
+ AnchorVertex *after)
+{
+#if defined(QT_DEBUG) && 0
+ QString strVertices;
+ for (int i = 0; i < vertices.count(); ++i) {
+ strVertices += QString::fromAscii("%1 - ").arg(vertices.at(i)->toString());
+ }
+ QString strPath = QString::fromAscii("%1 - %2%3").arg(before->toString(), strVertices, after->toString());
+ qDebug("simplifying [%s] to [%s - %s]", qPrintable(strPath), qPrintable(before->toString()), qPrintable(after->toString()));
+#endif
+
+ AnchorVertex *prev = before;
+ QVector<AnchorData *> edges;
+
+ // Take from the graph, the edges that will be simplificated
+ for (int i = 0; i < vertices.count(); ++i) {
+ AnchorVertex *next = vertices.at(i);
+ AnchorData *ad = graph->takeEdge(prev, next);
+ Q_ASSERT(ad);
+ edges.append(ad);
+ prev = next;
+ }
+
+ // Take the last edge (not covered in the loop above)
+ AnchorData *ad = graph->takeEdge(vertices.last(), after);
+ Q_ASSERT(ad);
+ edges.append(ad);
+
+ // Create sequence
+ SequentialAnchorData *sequence = new SequentialAnchorData(vertices, edges);
+ sequence->from = before;
+ sequence->to = after;
+
+ sequence->calculateSizeHints();
+
+ return sequence;
+}
+
+/*!
+ \internal
+
+ The purpose of this function is to simplify the graph.
+ Simplification serves two purposes:
+ 1. Reduce the number of edges in the graph, (thus the number of variables to the equation
+ solver is reduced, and the solver performs better).
+ 2. Be able to do distribution of sequences of edges more intelligently (esp. with sequential
+ anchors)
+
+ It is essential that it must be possible to restore simplified anchors back to their "original"
+ form. This is done by restoreSimplifiedAnchor().
+
+ There are two types of simplification that can be done:
+ 1. Sequential simplification
+ Sequential simplification means that all sequences of anchors will be merged into one single
+ anchor. Only anhcors that points in the same direction will be merged.
+ 2. Parallel simplification
+ If a simplified sequential anchor is about to be inserted between two vertices in the graph
+ and there already exist an anchor between those two vertices, a parallel anchor will be
+ created that serves as a placeholder for the sequential anchor and the anchor that was
+ already between the two vertices.
+
+ The process of simplification can be described as:
+
+ 1. Simplify all sequences of anchors into one anchor.
+ If no further simplification was done, go to (3)
+ - If there already exist an anchor where the sequential anchor is supposed to be inserted,
+ take that anchor out of the graph
+ - Then create a parallel anchor that holds the sequential anchor and the anchor just taken
+ out of the graph.
+ 2. Go to (1)
+ 3. Done
+
+ When creating the parallel anchors, the algorithm might identify unfeasible situations. In this
+ case the simplification process stops and returns false. Otherwise returns true.
+*/
+bool QGraphicsAnchorLayoutPrivate::simplifyGraph(Orientation orientation)
+{
+ if (items.isEmpty())
+ return true;
+
+#if defined(QT_DEBUG) && 0
+ qDebug("Simplifying Graph for %s",
+ orientation == Horizontal ? "Horizontal" : "Vertical");
+
+ static int count = 0;
+ if (orientation == Horizontal) {
+ count++;
+ dumpGraph(QString::fromAscii("%1-full").arg(count));
+ }
+#endif
+
+ // Vertex simplification
+ if (!simplifyVertices(orientation)) {
+ restoreVertices(orientation);
+ return false;
+ }
+
+ // Anchor simplification
+ bool dirty;
+ bool feasible = true;
+ do {
+ dirty = simplifyGraphIteration(orientation, &feasible);
+ } while (dirty && feasible);
+
+ // Note that if we are not feasible, we fallback and make sure that the graph is fully restored
+ if (!feasible) {
+ restoreSimplifiedGraph(orientation);
+ restoreVertices(orientation);
+ return false;
+ }
+
+#if defined(QT_DEBUG) && 0
+ dumpGraph(QString::fromAscii("%1-simplified-%2").arg(count).arg(
+ QString::fromAscii(orientation == Horizontal ? "Horizontal" : "Vertical")));
+#endif
+
+ return true;
+}
+
+static AnchorVertex *replaceVertex_helper(AnchorData *data, AnchorVertex *oldV, AnchorVertex *newV)
+{
+ AnchorVertex *other;
+ if (data->from == oldV) {
+ data->from = newV;
+ other = data->to;
+ } else {
+ data->to = newV;
+ other = data->from;
+ }
+ return other;
+}
+
+bool QGraphicsAnchorLayoutPrivate::replaceVertex(Orientation orientation, AnchorVertex *oldV,
+ AnchorVertex *newV, const QList<AnchorData *> &edges)
+{
+ Graph<AnchorVertex, AnchorData> &g = graph[orientation];
+ bool feasible = true;
+
+ for (int i = 0; i < edges.count(); ++i) {
+ AnchorData *ad = edges[i];
+ AnchorVertex *otherV = replaceVertex_helper(ad, oldV, newV);
+
+#if defined(QT_DEBUG)
+ ad->name = QString::fromAscii("%1 --to--> %2").arg(ad->from->toString()).arg(ad->to->toString());
+#endif
+
+ bool newFeasible;
+ AnchorData *newAnchor = addAnchorMaybeParallel(ad, &newFeasible);
+ feasible &= newFeasible;
+
+ if (newAnchor != ad) {
+ // A parallel was created, we mark that in the list of anchors created by vertex
+ // simplification. This is needed because we want to restore them in a separate step
+ // from the restoration of anchor simplification.
+ anchorsFromSimplifiedVertices[orientation].append(newAnchor);
+ }
+
+ g.takeEdge(oldV, otherV);
+ }
+
+ return feasible;
+}
+
+/*!
+ \internal
+*/
+bool QGraphicsAnchorLayoutPrivate::simplifyVertices(Orientation orientation)
+{
+ Q_Q(QGraphicsAnchorLayout);
+ Graph<AnchorVertex, AnchorData> &g = graph[orientation];
+
+ // We'll walk through vertices
+ QStack<AnchorVertex *> stack;
+ stack.push(layoutFirstVertex[orientation]);
+ QSet<AnchorVertex *> visited;
+
+ while (!stack.isEmpty()) {
+ AnchorVertex *v = stack.pop();
+ visited.insert(v);
+
+ // Each adjacent of 'v' is a possible vertex to be merged. So we traverse all of
+ // them. Since once a merge is made, we might add new adjacents, and we don't want to
+ // pass two times through one adjacent. The 'index' is used to track our position.
+ QList<AnchorVertex *> adjacents = g.adjacentVertices(v);
+ int index = 0;
+
+ while (index < adjacents.count()) {
+ AnchorVertex *next = adjacents.at(index);
+ index++;
+
+ AnchorData *data = g.edgeData(v, next);
+ const bool bothLayoutVertices = v->m_item == q && next->m_item == q;
+ const bool zeroSized = !data->minSize && !data->maxSize;
+
+ if (!bothLayoutVertices && zeroSized) {
+
+ // Create a new vertex pair, note that we keep a list of those vertices so we can
+ // easily process them when restoring the graph.
+ AnchorVertexPair *newV = new AnchorVertexPair(v, next, data);
+ simplifiedVertices[orientation].append(newV);
+
+ // Collect the anchors of both vertices, the new vertex pair will take their place
+ // in those anchors
+ const QList<AnchorVertex *> &vAdjacents = g.adjacentVertices(v);
+ const QList<AnchorVertex *> &nextAdjacents = g.adjacentVertices(next);
+
+ for (int i = 0; i < vAdjacents.count(); ++i) {
+ AnchorVertex *adjacent = vAdjacents.at(i);
+ if (adjacent != next) {
+ AnchorData *ad = g.edgeData(v, adjacent);
+ newV->m_firstAnchors.append(ad);
+ }
+ }
+
+ for (int i = 0; i < nextAdjacents.count(); ++i) {
+ AnchorVertex *adjacent = nextAdjacents.at(i);
+ if (adjacent != v) {
+ AnchorData *ad = g.edgeData(next, adjacent);
+ newV->m_secondAnchors.append(ad);
+
+ // We'll also add new vertices to the adjacent list of the new 'v', to be
+ // created as a vertex pair and replace the current one.
+ if (!adjacents.contains(adjacent))
+ adjacents.append(adjacent);
+ }
+ }
+
+ // ### merge this loop into the ones that calculated m_firstAnchors/m_secondAnchors?
+ // Make newV take the place of v and next
+ bool feasible = replaceVertex(orientation, v, newV, newV->m_firstAnchors);
+ feasible &= replaceVertex(orientation, next, newV, newV->m_secondAnchors);
+
+ // Update the layout vertex information if one of the vertices is a layout vertex.
+ AnchorVertex *layoutVertex = 0;
+ if (v->m_item == q)
+ layoutVertex = v;
+ else if (next->m_item == q)
+ layoutVertex = next;
+
+ if (layoutVertex) {
+ // Layout vertices always have m_item == q...
+ newV->m_item = q;
+ changeLayoutVertex(orientation, layoutVertex, newV);
+ }
+
+ g.takeEdge(v, next);
+
+ // If a non-feasibility is found, we leave early and cancel the simplification
+ if (!feasible)
+ return false;
+
+ v = newV;
+ visited.insert(newV);
+
+ } else if (!visited.contains(next) && !stack.contains(next)) {
+ // If the adjacent is not fit for merge and it wasn't visited by the outermost
+ // loop, we add it to the stack.
+ stack.push(next);
+ }
+ }
+ }
+
+ return true;
+}
+
+/*!
+ \internal
+
+ One iteration of the simplification algorithm. Returns true if another iteration is needed.
+
+ The algorithm walks the graph in depth-first order, and only collects vertices that has two
+ edges connected to it. If the vertex does not have two edges or if it is a layout edge, it
+ will take all the previously collected vertices and try to create a simplified sequential
+ anchor representing all the previously collected vertices. Once the simplified anchor is
+ inserted, the collected list is cleared in order to find the next sequence to simplify.
+
+ Note that there are some catches to this that are not covered by the above explanation, see
+ the function comments for more details.
+*/
+bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutPrivate::Orientation orientation,
+ bool *feasible)
+{
+ Q_Q(QGraphicsAnchorLayout);
+ Graph<AnchorVertex, AnchorData> &g = graph[orientation];
+
+ QSet<AnchorVertex *> visited;
+ QStack<QPair<AnchorVertex *, AnchorVertex *> > stack;
+ stack.push(qMakePair(static_cast<AnchorVertex *>(0), layoutFirstVertex[orientation]));
+ QVector<AnchorVertex*> candidates;
+
+ // Walk depth-first, in the stack we store start of the candidate sequence (beforeSequence)
+ // and the vertex to be visited.
+ while (!stack.isEmpty()) {
+ QPair<AnchorVertex *, AnchorVertex *> pair = stack.pop();
+ AnchorVertex *beforeSequence = pair.first;
+ AnchorVertex *v = pair.second;
+
+ // The basic idea is to determine whether we found an end of sequence,
+ // if that's the case, we stop adding vertices to the candidate list
+ // and do a simplification step.
+ //
+ // A vertex can trigger an end of sequence if
+ // (a) it is a layout vertex, we don't simplify away the layout vertices;
+ // (b) it does not have exactly 2 adjacents;
+ // (c) its next adjacent is already visited (a cycle in the graph).
+ // (d) the next anchor is a center anchor.
+
+ const QList<AnchorVertex *> &adjacents = g.adjacentVertices(v);
+ const bool isLayoutVertex = v->m_item == q;
+ AnchorVertex *afterSequence = v;
+ bool endOfSequence = false;
+
+ //
+ // Identify the end cases.
+ //
+
+ // Identifies cases (a) and (b)
+ endOfSequence = isLayoutVertex || adjacents.count() != 2;
+
+ if (!endOfSequence) {
+ // This is a tricky part. We peek at the next vertex to find out whether
+ //
+ // - we already visited the next vertex (c);
+ // - the next anchor is a center (d).
+ //
+ // Those are needed to identify the remaining end of sequence cases. Note that unlike
+ // (a) and (b), we preempt the end of sequence by looking into the next vertex.
+
+ // Peek at the next vertex
+ AnchorVertex *after;
+ if (candidates.isEmpty())
+ after = (beforeSequence == adjacents.last() ? adjacents.first() : adjacents.last());
+ else
+ after = (candidates.last() == adjacents.last() ? adjacents.first() : adjacents.last());
+
+ // ### At this point we assumed that candidates will not contain 'after', this may not hold
+ // when simplifying FLOATing anchors.
+ Q_ASSERT(!candidates.contains(after));
+
+ const AnchorData *data = g.edgeData(v, after);
+ Q_ASSERT(data);
+ const bool cycleFound = visited.contains(after);
+
+ // Now cases (c) and (d)...
+ endOfSequence = cycleFound || data->isCenterAnchor;
+
+ if (!endOfSequence) {
+ // If it's not an end of sequence, then the vertex didn't trigger neither of the
+ // previously three cases, so it can be added to the candidates list.
+ candidates.append(v);
+ } else if (cycleFound && (beforeSequence != after)) {
+ afterSequence = after;
+ candidates.append(v);
+ }
+ }
+
+ //
+ // Add next non-visited vertices to the stack.
+ //
+ for (int i = 0; i < adjacents.count(); ++i) {
+ AnchorVertex *next = adjacents.at(i);
+ if (visited.contains(next))
+ continue;
+
+ // If current vertex is an end of sequence, and it'll reset the candidates list. So
+ // the next vertices will build candidates lists with the current vertex as 'before'
+ // vertex. If it's not an end of sequence, we keep the original 'before' vertex,
+ // since we are keeping the candidates list.
+ if (endOfSequence)
+ stack.push(qMakePair(v, next));
+ else
+ stack.push(qMakePair(beforeSequence, next));
+ }
+
+ visited.insert(v);
+
+ if (!endOfSequence || candidates.isEmpty())
+ continue;
+
+ //
+ // Create a sequence for (beforeSequence, candidates, afterSequence).
+ //
+
+ // One restriction we have is to not simplify half of an anchor and let the other half
+ // unsimplified. So we remove center edges before and after the sequence.
+ const AnchorData *firstAnchor = g.edgeData(beforeSequence, candidates.first());
+ if (firstAnchor->isCenterAnchor) {
+ beforeSequence = candidates.first();
+ candidates.remove(0);
+
+ // If there's not candidates to be simplified, leave.
+ if (candidates.isEmpty())
+ continue;
+ }
+
+ const AnchorData *lastAnchor = g.edgeData(candidates.last(), afterSequence);
+ if (lastAnchor->isCenterAnchor) {
+ afterSequence = candidates.last();
+ candidates.remove(candidates.count() - 1);
+
+ if (candidates.isEmpty())
+ continue;
+ }
+
+ //
+ // Add the sequence to the graph.
+ //
+
+ AnchorData *sequence = createSequence(&g, beforeSequence, candidates, afterSequence);
+
+ // If 'beforeSequence' and 'afterSequence' already had an anchor between them, we'll
+ // create a parallel anchor between the new sequence and the old anchor.
+ bool newFeasible;
+ AnchorData *newAnchor = addAnchorMaybeParallel(sequence, &newFeasible);
+
+ if (!newFeasible) {
+ *feasible = false;
+ return false;
+ }
+
+ // When a new parallel anchor is create in the graph, we finish the iteration and return
+ // true to indicate a new iteration is needed. This happens because a parallel anchor
+ // changes the number of adjacents one vertex has, possibly opening up oportunities for
+ // building candidate lists (when adjacents == 2).
+ if (newAnchor != sequence)
+ return true;
+
+ // If there was no parallel simplification, we'll keep walking the graph. So we clear the
+ // candidates list to start again.
+ candidates.clear();
+ }
+
+ return false;
+}
+
+void QGraphicsAnchorLayoutPrivate::restoreSimplifiedAnchor(AnchorData *edge)
+{
+#if 0
+ static const char *anchortypes[] = {"Normal",
+ "Sequential",
+ "Parallel"};
+ qDebug("Restoring %s edge.", anchortypes[int(edge->type)]);
+#endif
+
+ Graph<AnchorVertex, AnchorData> &g = graph[edge->orientation];
+
+ if (edge->type == AnchorData::Normal) {
+ g.createEdge(edge->from, edge->to, edge);
+
+ } else if (edge->type == AnchorData::Sequential) {
+ SequentialAnchorData *sequence = static_cast<SequentialAnchorData *>(edge);
+
+ for (int i = 0; i < sequence->m_edges.count(); ++i) {
+ AnchorData *data = sequence->m_edges.at(i);
+ restoreSimplifiedAnchor(data);
+ }
+
+ delete sequence;
+
+ } else if (edge->type == AnchorData::Parallel) {
+
+ // Skip parallel anchors that were created by vertex simplification, they will be processed
+ // later, when restoring vertex simplification.
+ // ### we could improve this check bit having a bit inside 'edge'
+ if (anchorsFromSimplifiedVertices[edge->orientation].contains(edge))
+ return;
+
+ ParallelAnchorData* parallel = static_cast<ParallelAnchorData*>(edge);
+ restoreSimplifiedConstraints(parallel);
+
+ // ### Because of the way parallel anchors are created in the anchor simplification
+ // algorithm, we know that one of these will be a sequence, so it'll be safe if the other
+ // anchor create an edge between the same vertices as the parallel.
+ Q_ASSERT(parallel->firstEdge->type == AnchorData::Sequential
+ || parallel->secondEdge->type == AnchorData::Sequential);
+ restoreSimplifiedAnchor(parallel->firstEdge);
+ restoreSimplifiedAnchor(parallel->secondEdge);
+
+ delete parallel;
+ }
+}
+
+void QGraphicsAnchorLayoutPrivate::restoreSimplifiedConstraints(ParallelAnchorData *parallel)
+{
+ if (!parallel->isCenterAnchor)
+ return;
+
+ for (int i = 0; i < parallel->m_firstConstraints.count(); ++i) {
+ QSimplexConstraint *c = parallel->m_firstConstraints.at(i);
+ qreal v = c->variables[parallel];
+ c->variables.remove(parallel);
+ c->variables.insert(parallel->firstEdge, v);
+ }
+
+ // When restoring, we might have to revert constraints back. See comments on
+ // addAnchorMaybeParallel().
+ const bool needsReverse = !parallel->secondForward();
+
+ for (int i = 0; i < parallel->m_secondConstraints.count(); ++i) {
+ QSimplexConstraint *c = parallel->m_secondConstraints.at(i);
+ qreal v = c->variables[parallel];
+ if (needsReverse)
+ v *= -1;
+ c->variables.remove(parallel);
+ c->variables.insert(parallel->secondEdge, v);
+ }
+}
+
+void QGraphicsAnchorLayoutPrivate::restoreSimplifiedGraph(Orientation orientation)
+{
+#if 0
+ qDebug("Restoring Simplified Graph for %s",
+ orientation == Horizontal ? "Horizontal" : "Vertical");
+#endif
+
+ // Restore anchor simplification
+ Graph<AnchorVertex, AnchorData> &g = graph[orientation];
+ QList<QPair<AnchorVertex*, AnchorVertex*> > connections = g.connections();
+ for (int i = 0; i < connections.count(); ++i) {
+ AnchorVertex *v1 = connections.at(i).first;
+ AnchorVertex *v2 = connections.at(i).second;
+ AnchorData *edge = g.edgeData(v1, v2);
+
+ // We restore only sequential anchors and parallels that were not created by
+ // vertex simplification.
+ if (edge->type == AnchorData::Sequential
+ || (edge->type == AnchorData::Parallel &&
+ !anchorsFromSimplifiedVertices[orientation].contains(edge))) {
+
+ g.takeEdge(v1, v2);
+ restoreSimplifiedAnchor(edge);
+ }
+ }
+
+ restoreVertices(orientation);
+}
+
+void QGraphicsAnchorLayoutPrivate::restoreVertices(Orientation orientation)
+{
+ Q_Q(QGraphicsAnchorLayout);
+
+ Graph<AnchorVertex, AnchorData> &g = graph[orientation];
+ QList<AnchorVertexPair *> &toRestore = simplifiedVertices[orientation];
+
+ // Since we keep a list of parallel anchors and vertices that were created during vertex
+ // simplification, we can now iterate on those lists instead of traversing the graph
+ // recursively.
+
+ // First, restore the constraints changed when we created parallel anchors. Note that this
+ // works at this point because the constraints doesn't depend on vertex information and at
+ // this point it's always safe to identify whether the second child is forward or backwards.
+ // In the next step, we'll change the anchors vertices so that would not be possible anymore.
+ QList<AnchorData *> &parallelAnchors = anchorsFromSimplifiedVertices[orientation];
+
+ for (int i = parallelAnchors.count() - 1; i >= 0; --i) {
+ ParallelAnchorData *parallel = static_cast<ParallelAnchorData *>(parallelAnchors.at(i));
+ restoreSimplifiedConstraints(parallel);
+ }
+
+ // Then, we will restore the vertices in the inverse order of creation, this way we ensure that
+ // the vertex being restored was not wrapped by another simplification.
+ for (int i = toRestore.count() - 1; i >= 0; --i) {
+ AnchorVertexPair *pair = toRestore.at(i);
+ QList<AnchorVertex *> adjacents = g.adjacentVertices(pair);
+
+ // Restore the removed edge, this will also restore both vertices 'first' and 'second' to
+ // the graph structure.
+ AnchorVertex *first = pair->m_first;
+ AnchorVertex *second = pair->m_second;
+ g.createEdge(first, second, pair->m_removedAnchor);
+
+ // Restore the anchors for the first child vertex
+ for (int j = 0; j < pair->m_firstAnchors.count(); ++j) {
+ AnchorData *ad = pair->m_firstAnchors.at(j);
+ Q_ASSERT(ad->from == pair || ad->to == pair);
+
+ replaceVertex_helper(ad, pair, first);
+ g.createEdge(ad->from, ad->to, ad);
+ }
+
+ // Restore the anchors for the second child vertex
+ for (int j = 0; j < pair->m_secondAnchors.count(); ++j) {
+ AnchorData *ad = pair->m_secondAnchors.at(j);
+ Q_ASSERT(ad->from == pair || ad->to == pair);
+
+ replaceVertex_helper(ad, pair, second);
+ g.createEdge(ad->from, ad->to, ad);
+ }
+
+ for (int j = 0; j < adjacents.count(); ++j) {
+ g.takeEdge(pair, adjacents.at(j));
+ }
+
+ // The pair simplified a layout vertex, so place back the correct vertex in the variable
+ // that track layout vertices
+ if (pair->m_item == q) {
+ AnchorVertex *layoutVertex = first->m_item == q ? first : second;
+ Q_ASSERT(layoutVertex->m_item == q);
+ changeLayoutVertex(orientation, pair, layoutVertex);
+ }
+
+ delete pair;
+ }
+ qDeleteAll(parallelAnchors);
+ parallelAnchors.clear();
+ toRestore.clear();
+}
+
+QGraphicsAnchorLayoutPrivate::Orientation
+QGraphicsAnchorLayoutPrivate::edgeOrientation(Qt::AnchorPoint edge)
+{
+ return edge > Qt::AnchorRight ? Vertical : Horizontal;
+}
+
+/*!
+ \internal
+
+ Create internal anchors to connect the layout edges (Left to Right and
+ Top to Bottom).
+
+ These anchors doesn't have size restrictions, that will be enforced by
+ other anchors and items in the layout.
+*/
+void QGraphicsAnchorLayoutPrivate::createLayoutEdges()
+{
+ Q_Q(QGraphicsAnchorLayout);
+ QGraphicsLayoutItem *layout = q;
+
+ // Horizontal
+ AnchorData *data = new AnchorData;
+ addAnchor_helper(layout, Qt::AnchorLeft, layout,
+ Qt::AnchorRight, data);
+ data->maxSize = QWIDGETSIZE_MAX;
+
+ // Save a reference to layout vertices
+ layoutFirstVertex[Horizontal] = internalVertex(layout, Qt::AnchorLeft);
+ layoutCentralVertex[Horizontal] = 0;
+ layoutLastVertex[Horizontal] = internalVertex(layout, Qt::AnchorRight);
+
+ // Vertical
+ data = new AnchorData;
+ addAnchor_helper(layout, Qt::AnchorTop, layout,
+ Qt::AnchorBottom, data);
+ data->maxSize = QWIDGETSIZE_MAX;
+
+ // Save a reference to layout vertices
+ layoutFirstVertex[Vertical] = internalVertex(layout, Qt::AnchorTop);
+ layoutCentralVertex[Vertical] = 0;
+ layoutLastVertex[Vertical] = internalVertex(layout, Qt::AnchorBottom);
+}
+
+void QGraphicsAnchorLayoutPrivate::deleteLayoutEdges()
+{
+ Q_Q(QGraphicsAnchorLayout);
+
+ Q_ASSERT(!internalVertex(q, Qt::AnchorHorizontalCenter));
+ Q_ASSERT(!internalVertex(q, Qt::AnchorVerticalCenter));
+
+ removeAnchor_helper(internalVertex(q, Qt::AnchorLeft),
+ internalVertex(q, Qt::AnchorRight));
+ removeAnchor_helper(internalVertex(q, Qt::AnchorTop),
+ internalVertex(q, Qt::AnchorBottom));
+}
+
+void QGraphicsAnchorLayoutPrivate::createItemEdges(QGraphicsLayoutItem *item)
+{
+ items.append(item);
+
+ // Create horizontal and vertical internal anchors for the item and
+ // refresh its size hint / policy values.
+ AnchorData *data = new AnchorData;
+ addAnchor_helper(item, Qt::AnchorLeft, item, Qt::AnchorRight, data);
+ data->refreshSizeHints();
+
+ data = new AnchorData;
+ addAnchor_helper(item, Qt::AnchorTop, item, Qt::AnchorBottom, data);
+ data->refreshSizeHints();
+}
+
+/*!
+ \internal
+
+ By default, each item in the layout is represented internally as
+ a single anchor in each direction. For instance, from Left to Right.
+
+ However, to support anchorage of items to the center of items, we
+ must split this internal anchor into two half-anchors. From Left
+ to Center and then from Center to Right, with the restriction that
+ these anchors must have the same time at all times.
+*/
+void QGraphicsAnchorLayoutPrivate::createCenterAnchors(
+ QGraphicsLayoutItem *item, Qt::AnchorPoint centerEdge)
+{
+ Q_Q(QGraphicsAnchorLayout);
+
+ Orientation orientation;
+ switch (centerEdge) {
+ case Qt::AnchorHorizontalCenter:
+ orientation = Horizontal;
+ break;
+ case Qt::AnchorVerticalCenter:
+ orientation = Vertical;
+ break;
+ default:
+ // Don't create center edges unless needed
+ return;
+ }
+
+ // Check if vertex already exists
+ if (internalVertex(item, centerEdge))
+ return;
+
+ // Orientation code
+ Qt::AnchorPoint firstEdge;
+ Qt::AnchorPoint lastEdge;
+
+ if (orientation == Horizontal) {
+ firstEdge = Qt::AnchorLeft;
+ lastEdge = Qt::AnchorRight;
+ } else {
+ firstEdge = Qt::AnchorTop;
+ lastEdge = Qt::AnchorBottom;
+ }
+
+ AnchorVertex *first = internalVertex(item, firstEdge);
+ AnchorVertex *last = internalVertex(item, lastEdge);
+ Q_ASSERT(first && last);
+
+ // Create new anchors
+ QSimplexConstraint *c = new QSimplexConstraint;
+
+ AnchorData *data = new AnchorData;
+ c->variables.insert(data, 1.0);
+ addAnchor_helper(item, firstEdge, item, centerEdge, data);
+ data->isCenterAnchor = true;
+ data->dependency = AnchorData::Master;
+ data->refreshSizeHints();
+
+ data = new AnchorData;
+ c->variables.insert(data, -1.0);
+ addAnchor_helper(item, centerEdge, item, lastEdge, data);
+ data->isCenterAnchor = true;
+ data->dependency = AnchorData::Slave;
+ data->refreshSizeHints();
+
+ itemCenterConstraints[orientation].append(c);
+
+ // Remove old one
+ removeAnchor_helper(first, last);
+
+ if (item == q) {
+ layoutCentralVertex[orientation] = internalVertex(q, centerEdge);
+ }
+}
+
+void QGraphicsAnchorLayoutPrivate::removeCenterAnchors(
+ QGraphicsLayoutItem *item, Qt::AnchorPoint centerEdge,
+ bool substitute)
+{
+ Q_Q(QGraphicsAnchorLayout);
+
+ Orientation orientation;
+ switch (centerEdge) {
+ case Qt::AnchorHorizontalCenter:
+ orientation = Horizontal;
+ break;
+ case Qt::AnchorVerticalCenter:
+ orientation = Vertical;
+ break;
+ default:
+ // Don't remove edges that not the center ones
+ return;
+ }
+
+ // Orientation code
+ Qt::AnchorPoint firstEdge;
+ Qt::AnchorPoint lastEdge;
+
+ if (orientation == Horizontal) {
+ firstEdge = Qt::AnchorLeft;
+ lastEdge = Qt::AnchorRight;
+ } else {
+ firstEdge = Qt::AnchorTop;
+ lastEdge = Qt::AnchorBottom;
+ }
+
+ AnchorVertex *center = internalVertex(item, centerEdge);
+ if (!center)
+ return;
+ AnchorVertex *first = internalVertex(item, firstEdge);
+
+ Q_ASSERT(first);
+ Q_ASSERT(center);
+
+ Graph<AnchorVertex, AnchorData> &g = graph[orientation];
+
+
+ AnchorData *oldData = g.edgeData(first, center);
+ // Remove center constraint
+ for (int i = itemCenterConstraints[orientation].count() - 1; i >= 0; --i) {
+ if (itemCenterConstraints[orientation].at(i)->variables.contains(oldData)) {
+ delete itemCenterConstraints[orientation].takeAt(i);
+ break;
+ }
+ }
+
+ if (substitute) {
+ // Create the new anchor that should substitute the left-center-right anchors.
+ AnchorData *data = new AnchorData;
+ addAnchor_helper(item, firstEdge, item, lastEdge, data);
+ data->refreshSizeHints();
+
+ // Remove old anchors
+ removeAnchor_helper(first, center);
+ removeAnchor_helper(center, internalVertex(item, lastEdge));
+
+ } else {
+ // this is only called from removeAnchors()
+ // first, remove all non-internal anchors
+ QList<AnchorVertex*> adjacents = g.adjacentVertices(center);
+ for (int i = 0; i < adjacents.count(); ++i) {
+ AnchorVertex *v = adjacents.at(i);
+ if (v->m_item != item) {
+ removeAnchor_helper(center, internalVertex(v->m_item, v->m_edge));
+ }
+ }
+ // when all non-internal anchors is removed it will automatically merge the
+ // center anchor into a left-right (or top-bottom) anchor. We must also delete that.
+ // by this time, the center vertex is deleted and merged into a non-centered internal anchor
+ removeAnchor_helper(first, internalVertex(item, lastEdge));
+ }
+
+ if (item == q) {
+ layoutCentralVertex[orientation] = 0;
+ }
+}
+
+
+void QGraphicsAnchorLayoutPrivate::removeCenterConstraints(QGraphicsLayoutItem *item,
+ Orientation orientation)
+{
+ // Remove the item center constraints associated to this item
+ // ### This is a temporary solution. We should probably use a better
+ // data structure to hold items and/or their associated constraints
+ // so that we can remove those easily
+
+ AnchorVertex *first = internalVertex(item, orientation == Horizontal ?
+ Qt::AnchorLeft :
+ Qt::AnchorTop);
+ AnchorVertex *center = internalVertex(item, orientation == Horizontal ?
+ Qt::AnchorHorizontalCenter :
+ Qt::AnchorVerticalCenter);
+
+ // Skip if no center constraints exist
+ if (!center)
+ return;
+
+ Q_ASSERT(first);
+ AnchorData *internalAnchor = graph[orientation].edgeData(first, center);
+
+ // Look for our anchor in all item center constraints, then remove it
+ for (int i = 0; i < itemCenterConstraints[orientation].size(); ++i) {
+ if (itemCenterConstraints[orientation].at(i)->variables.contains(internalAnchor)) {
+ delete itemCenterConstraints[orientation].takeAt(i);
+ break;
+ }
+ }
+}
+
+/*!
+ * \internal
+ * Implements the high level "addAnchor" feature. Called by the public API
+ * addAnchor method.
+ *
+ * The optional \a spacing argument defines the size of the anchor. If not provided,
+ * the anchor size is either 0 or not-set, depending on type of anchor created (see
+ * matrix below).
+ *
+ * All anchors that remain with size not-set will assume the standard spacing,
+ * set either by the layout style or through the "setSpacing" layout API.
+ */
+QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::addAnchor(QGraphicsLayoutItem *firstItem,
+ Qt::AnchorPoint firstEdge,
+ QGraphicsLayoutItem *secondItem,
+ Qt::AnchorPoint secondEdge,
+ qreal *spacing)
+{
+ Q_Q(QGraphicsAnchorLayout);
+ if ((firstItem == 0) || (secondItem == 0)) {
+ qWarning("QGraphicsAnchorLayout::addAnchor(): "
+ "Cannot anchor NULL items");
+ return 0;
+ }
+
+ if (firstItem == secondItem) {
+ qWarning("QGraphicsAnchorLayout::addAnchor(): "
+ "Cannot anchor the item to itself");
+ return 0;
+ }
+
+ if (edgeOrientation(secondEdge) != edgeOrientation(firstEdge)) {
+ qWarning("QGraphicsAnchorLayout::addAnchor(): "
+ "Cannot anchor edges of different orientations");
+ return 0;
+ }
+
+ const QGraphicsLayoutItem *parentWidget = q->parentLayoutItem();
+ if (firstItem == parentWidget || secondItem == parentWidget) {
+ qWarning("QGraphicsAnchorLayout::addAnchor(): "
+ "You cannot add the parent of the layout to the layout.");
+ return 0;
+ }
+
+ // In QGraphicsAnchorLayout, items are represented in its internal
+ // graph as four anchors that connect:
+ // - Left -> HCenter
+ // - HCenter-> Right
+ // - Top -> VCenter
+ // - VCenter -> Bottom
+
+ // Ensure that the internal anchors have been created for both items.
+ if (firstItem != q && !items.contains(firstItem)) {
+ createItemEdges(firstItem);
+ addChildLayoutItem(firstItem);
+ }
+ if (secondItem != q && !items.contains(secondItem)) {
+ createItemEdges(secondItem);
+ addChildLayoutItem(secondItem);
+ }
+
+ // Create center edges if needed
+ createCenterAnchors(firstItem, firstEdge);
+ createCenterAnchors(secondItem, secondEdge);
+
+ // Use heuristics to find out what the user meant with this anchor.
+ correctEdgeDirection(firstItem, firstEdge, secondItem, secondEdge);
+
+ AnchorData *data = new AnchorData;
+ QGraphicsAnchor *graphicsAnchor = acquireGraphicsAnchor(data);
+
+ addAnchor_helper(firstItem, firstEdge, secondItem, secondEdge, data);
+
+ if (spacing) {
+ graphicsAnchor->setSpacing(*spacing);
+ } else {
+ // If firstItem or secondItem is the layout itself, the spacing will default to 0.
+ // Otherwise, the following matrix is used (questionmark means that the spacing
+ // is queried from the style):
+ // from
+ // to Left HCenter Right
+ // Left 0 0 ?
+ // HCenter 0 0 0
+ // Right ? 0 0
+ if (firstItem == q
+ || secondItem == q
+ || pickEdge(firstEdge, Horizontal) == Qt::AnchorHorizontalCenter
+ || oppositeEdge(firstEdge) != secondEdge) {
+ graphicsAnchor->setSpacing(0);
+ } else {
+ graphicsAnchor->unsetSpacing();
+ }
+ }
+
+ return graphicsAnchor;
+}
+
+/*
+ \internal
+
+ This method adds an AnchorData to the internal graph. It is responsible for doing
+ the boilerplate part of such task.
+
+ If another AnchorData exists between the mentioned vertices, it is deleted and
+ the new one is inserted.
+*/
+void QGraphicsAnchorLayoutPrivate::addAnchor_helper(QGraphicsLayoutItem *firstItem,
+ Qt::AnchorPoint firstEdge,
+ QGraphicsLayoutItem *secondItem,
+ Qt::AnchorPoint secondEdge,
+ AnchorData *data)
+{
+ Q_Q(QGraphicsAnchorLayout);
+
+ const Orientation orientation = edgeOrientation(firstEdge);
+
+ // Create or increase the reference count for the related vertices.
+ AnchorVertex *v1 = addInternalVertex(firstItem, firstEdge);
+ AnchorVertex *v2 = addInternalVertex(secondItem, secondEdge);
+
+ // Remove previous anchor
+ if (graph[orientation].edgeData(v1, v2)) {
+ removeAnchor_helper(v1, v2);
+ }
+
+ // If its an internal anchor, set the associated item
+ if (firstItem == secondItem)
+ data->item = firstItem;
+
+ data->orientation = orientation;
+
+ // Create a bi-directional edge in the sense it can be transversed both
+ // from v1 or v2. "data" however is shared between the two references
+ // so we still know that the anchor direction is from 1 to 2.
+ data->from = v1;
+ data->to = v2;
+#ifdef QT_DEBUG
+ data->name = QString::fromAscii("%1 --to--> %2").arg(v1->toString()).arg(v2->toString());
+#endif
+ // ### bit to track internal anchors, since inside AnchorData methods
+ // we don't have access to the 'q' pointer.
+ data->isLayoutAnchor = (data->item == q);
+
+ graph[orientation].createEdge(v1, v2, data);
+}
+
+QGraphicsAnchor *QGraphicsAnchorLayoutPrivate::getAnchor(QGraphicsLayoutItem *firstItem,
+ Qt::AnchorPoint firstEdge,
+ QGraphicsLayoutItem *secondItem,
+ Qt::AnchorPoint secondEdge)
+{
+ // Do not expose internal anchors
+ if (firstItem == secondItem)
+ return 0;
+
+ const Orientation orientation = edgeOrientation(firstEdge);
+ AnchorVertex *v1 = internalVertex(firstItem, firstEdge);
+ AnchorVertex *v2 = internalVertex(secondItem, secondEdge);
+
+ QGraphicsAnchor *graphicsAnchor = 0;
+
+ AnchorData *data = graph[orientation].edgeData(v1, v2);
+ if (data) {
+ // We could use "acquireGraphicsAnchor" here, but to avoid a regression where
+ // an internal anchor was wrongly exposed, I want to ensure no new
+ // QGraphicsAnchor instances are created by this call.
+ // This assumption must hold because anchors are either user-created (and already
+ // have their public object created), or they are internal (and must not reach
+ // this point).
+ Q_ASSERT(data->graphicsAnchor);
+ graphicsAnchor = data->graphicsAnchor;
+ }
+ return graphicsAnchor;
+}
+
+/*!
+ * \internal
+ *
+ * Implements the high level "removeAnchor" feature. Called by
+ * the QAnchorData destructor.
+ */
+void QGraphicsAnchorLayoutPrivate::removeAnchor(AnchorVertex *firstVertex,
+ AnchorVertex *secondVertex)
+{
+ Q_Q(QGraphicsAnchorLayout);
+
+ // Save references to items while it's safe to assume the vertices exist
+ QGraphicsLayoutItem *firstItem = firstVertex->m_item;
+ QGraphicsLayoutItem *secondItem = secondVertex->m_item;
+
+ // Delete the anchor (may trigger deletion of center vertices)
+ removeAnchor_helper(firstVertex, secondVertex);
+
+ // Ensure no dangling pointer is left behind
+ firstVertex = secondVertex = 0;
+
+ // Checking if the item stays in the layout or not
+ bool keepFirstItem = false;
+ bool keepSecondItem = false;
+
+ QPair<AnchorVertex *, int> v;
+ int refcount = -1;
+
+ if (firstItem != q) {
+ for (int i = Qt::AnchorLeft; i <= Qt::AnchorBottom; ++i) {
+ v = m_vertexList.value(qMakePair(firstItem, static_cast<Qt::AnchorPoint>(i)));
+ if (v.first) {
+ if (i == Qt::AnchorHorizontalCenter || i == Qt::AnchorVerticalCenter)
+ refcount = 2;
+ else
+ refcount = 1;
+
+ if (v.second > refcount) {
+ keepFirstItem = true;
+ break;
+ }
+ }
+ }
+ } else
+ keepFirstItem = true;
+
+ if (secondItem != q) {
+ for (int i = Qt::AnchorLeft; i <= Qt::AnchorBottom; ++i) {
+ v = m_vertexList.value(qMakePair(secondItem, static_cast<Qt::AnchorPoint>(i)));
+ if (v.first) {
+ if (i == Qt::AnchorHorizontalCenter || i == Qt::AnchorVerticalCenter)
+ refcount = 2;
+ else
+ refcount = 1;
+
+ if (v.second > refcount) {
+ keepSecondItem = true;
+ break;
+ }
+ }
+ }
+ } else
+ keepSecondItem = true;
+
+ if (!keepFirstItem)
+ q->removeAt(items.indexOf(firstItem));
+
+ if (!keepSecondItem)
+ q->removeAt(items.indexOf(secondItem));
+
+ // Removing anchors invalidates the layout
+ q->invalidate();
+}
+
+/*
+ \internal
+
+ Implements the low level "removeAnchor" feature. Called by
+ private methods.
+*/
+void QGraphicsAnchorLayoutPrivate::removeAnchor_helper(AnchorVertex *v1, AnchorVertex *v2)
+{
+ Q_ASSERT(v1 && v2);
+
+ // Remove edge from graph
+ const Orientation o = edgeOrientation(v1->m_edge);
+ graph[o].removeEdge(v1, v2);
+
+ // Decrease vertices reference count (may trigger a deletion)
+ removeInternalVertex(v1->m_item, v1->m_edge);
+ removeInternalVertex(v2->m_item, v2->m_edge);
+}
+
+AnchorVertex *QGraphicsAnchorLayoutPrivate::addInternalVertex(QGraphicsLayoutItem *item,
+ Qt::AnchorPoint edge)
+{
+ QPair<QGraphicsLayoutItem *, Qt::AnchorPoint> pair(item, edge);
+ QPair<AnchorVertex *, int> v = m_vertexList.value(pair);
+
+ if (!v.first) {
+ Q_ASSERT(v.second == 0);
+ v.first = new AnchorVertex(item, edge);
+ }
+ v.second++;
+ m_vertexList.insert(pair, v);
+ return v.first;
+}
+
+/**
+ * \internal
+ *
+ * returns the AnchorVertex that was dereferenced, also when it was removed.
+ * returns 0 if it did not exist.
+ */
+void QGraphicsAnchorLayoutPrivate::removeInternalVertex(QGraphicsLayoutItem *item,
+ Qt::AnchorPoint edge)
+{
+ QPair<QGraphicsLayoutItem *, Qt::AnchorPoint> pair(item, edge);
+ QPair<AnchorVertex *, int> v = m_vertexList.value(pair);
+
+ if (!v.first) {
+ qWarning("This item with this edge is not in the graph");
+ return;
+ }
+
+ v.second--;
+ if (v.second == 0) {
+ // Remove reference and delete vertex
+ m_vertexList.remove(pair);
+ delete v.first;
+ } else {
+ // Update reference count
+ m_vertexList.insert(pair, v);
+
+ if ((v.second == 2) &&
+ ((edge == Qt::AnchorHorizontalCenter) ||
+ (edge == Qt::AnchorVerticalCenter))) {
+ removeCenterAnchors(item, edge, true);
+ }
+ }
+}
+
+void QGraphicsAnchorLayoutPrivate::removeVertex(QGraphicsLayoutItem *item, Qt::AnchorPoint edge)
+{
+ if (AnchorVertex *v = internalVertex(item, edge)) {
+ Graph<AnchorVertex, AnchorData> &g = graph[edgeOrientation(edge)];
+ const QList<AnchorVertex *> allVertices = graph[edgeOrientation(edge)].adjacentVertices(v);
+ AnchorVertex *v2;
+ foreach (v2, allVertices) {
+ g.removeEdge(v, v2);
+ removeInternalVertex(item, edge);
+ removeInternalVertex(v2->m_item, v2->m_edge);
+ }
+ }
+}
+
+void QGraphicsAnchorLayoutPrivate::removeAnchors(QGraphicsLayoutItem *item)
+{
+ // remove the center anchor first!!
+ removeCenterAnchors(item, Qt::AnchorHorizontalCenter, false);
+ removeVertex(item, Qt::AnchorLeft);
+ removeVertex(item, Qt::AnchorRight);
+
+ removeCenterAnchors(item, Qt::AnchorVerticalCenter, false);
+ removeVertex(item, Qt::AnchorTop);
+ removeVertex(item, Qt::AnchorBottom);
+}
+
+/*!
+ \internal
+
+ Use heuristics to determine the correct orientation of a given anchor.
+
+ After API discussions, we decided we would like expressions like
+ anchor(A, Left, B, Right) to mean the same as anchor(B, Right, A, Left).
+ The problem with this is that anchors could become ambiguous, for
+ instance, what does the anchor A, B of size X mean?
+
+ "pos(B) = pos(A) + X" or "pos(A) = pos(B) + X" ?
+
+ To keep the API user friendly and at the same time, keep our algorithm
+ deterministic, we use an heuristic to determine a direction for each
+ added anchor and then keep it. The heuristic is based on the fact
+ that people usually avoid overlapping items, therefore:
+
+ "A, RIGHT to B, LEFT" means that B is to the LEFT of A.
+ "B, LEFT to A, RIGHT" is corrected to the above anchor.
+
+ Special correction is also applied when one of the items is the
+ layout. We handle Layout Left as if it was another items's Right
+ and Layout Right as another item's Left.
+*/
+void QGraphicsAnchorLayoutPrivate::correctEdgeDirection(QGraphicsLayoutItem *&firstItem,
+ Qt::AnchorPoint &firstEdge,
+ QGraphicsLayoutItem *&secondItem,
+ Qt::AnchorPoint &secondEdge)
+{
+ Q_Q(QGraphicsAnchorLayout);
+
+ if ((firstItem != q) && (secondItem != q)) {
+ // If connection is between widgets (not the layout itself)
+ // Ensure that "right-edges" sit to the left of "left-edges".
+ if (firstEdge < secondEdge) {
+ qSwap(firstItem, secondItem);
+ qSwap(firstEdge, secondEdge);
+ }
+ } else if (firstItem == q) {
+ // If connection involves the right or bottom of a layout, ensure
+ // the layout is the second item.
+ if ((firstEdge == Qt::AnchorRight) || (firstEdge == Qt::AnchorBottom)) {
+ qSwap(firstItem, secondItem);
+ qSwap(firstEdge, secondEdge);
+ }
+ } else if ((secondEdge != Qt::AnchorRight) && (secondEdge != Qt::AnchorBottom)) {
+ // If connection involves the left, center or top of layout, ensure
+ // the layout is the first item.
+ qSwap(firstItem, secondItem);
+ qSwap(firstEdge, secondEdge);
+ }
+}
+
+QLayoutStyleInfo &QGraphicsAnchorLayoutPrivate::styleInfo() const
+{
+ if (styleInfoDirty) {
+ Q_Q(const QGraphicsAnchorLayout);
+ //### Fix this if QGV ever gets support for Metal style or different Aqua sizes.
+ QWidget *wid = 0;
+
+ QGraphicsLayoutItem *parent = q->parentLayoutItem();
+ while (parent && parent->isLayout()) {
+ parent = parent->parentLayoutItem();
+ }
+ QGraphicsWidget *w = 0;
+ if (parent) {
+ QGraphicsItem *parentItem = parent->graphicsItem();
+ if (parentItem && parentItem->isWidget())
+ w = static_cast<QGraphicsWidget*>(parentItem);
+ }
+
+ QStyle *style = w ? w->style() : QApplication::style();
+ cachedStyleInfo = QLayoutStyleInfo(style, wid);
+ cachedStyleInfo.setDefaultSpacing(Qt::Horizontal, spacings[0]);
+ cachedStyleInfo.setDefaultSpacing(Qt::Vertical, spacings[1]);
+
+ styleInfoDirty = false;
+ }
+ return cachedStyleInfo;
+}
+
+/*!
+ \internal
+
+ Called on activation. Uses Linear Programming to define minimum, preferred
+ and maximum sizes for the layout. Also calculates the sizes that each item
+ should assume when the layout is in one of such situations.
+*/
+void QGraphicsAnchorLayoutPrivate::calculateGraphs()
+{
+ if (!calculateGraphCacheDirty)
+ return;
+ calculateGraphs(Horizontal);
+ calculateGraphs(Vertical);
+ calculateGraphCacheDirty = false;
+}
+
+// ### Maybe getGraphParts could return the variables when traversing, at least
+// for trunk...
+QList<AnchorData *> getVariables(QList<QSimplexConstraint *> constraints)
+{
+ QSet<AnchorData *> variableSet;
+ for (int i = 0; i < constraints.count(); ++i) {
+ const QSimplexConstraint *c = constraints.at(i);
+ foreach (QSimplexVariable *var, c->variables.keys()) {
+ variableSet += static_cast<AnchorData *>(var);
+ }
+ }
+ return variableSet.toList();
+}
+
+/*!
+ \internal
+
+ Calculate graphs is the method that puts together all the helper routines
+ so that the AnchorLayout can calculate the sizes of each item.
+
+ In a nutshell it should do:
+
+ 1) Refresh anchor nominal sizes, that is, the size that each anchor would
+ have if no other restrictions applied. This is done by quering the
+ layout style and the sizeHints of the items belonging to the layout.
+
+ 2) Simplify the graph by grouping together parallel and sequential anchors
+ into "group anchors". These have equivalent minimum, preferred and maximum
+ sizeHints as the anchors they replace.
+
+ 3) Check if we got to a trivial case. In some cases, the whole graph can be
+ simplified into a single anchor. If so, use this information. If not,
+ then call the Simplex solver to calculate the anchors sizes.
+
+ 4) Once the root anchors had its sizes calculated, propagate that to the
+ anchors they represent.
+*/
+void QGraphicsAnchorLayoutPrivate::calculateGraphs(
+ QGraphicsAnchorLayoutPrivate::Orientation orientation)
+{
+#if defined(QT_DEBUG) || defined(Q_AUTOTEST_EXPORT)
+ lastCalculationUsedSimplex[orientation] = false;
+#endif
+
+ static bool simplificationEnabled = qgetenv("QT_ANCHORLAYOUT_NO_SIMPLIFICATION").isEmpty();
+
+ // Reset the nominal sizes of each anchor based on the current item sizes
+ refreshAllSizeHints(orientation);
+
+ // Simplify the graph
+ if (simplificationEnabled && !simplifyGraph(orientation)) {
+ qWarning("QGraphicsAnchorLayout: anchor setup is not feasible.");
+ graphHasConflicts[orientation] = true;
+ return;
+ }
+
+ // Traverse all graph edges and store the possible paths to each vertex
+ findPaths(orientation);
+
+ // From the paths calculated above, extract the constraints that the current
+ // anchor setup impose, to our Linear Programming problem.
+ constraintsFromPaths(orientation);
+
+ // Split the constraints and anchors into groups that should be fed to the
+ // simplex solver independently. Currently we find two groups:
+ //
+ // 1) The "trunk", that is, the set of anchors (items) that are connected
+ // to the two opposite sides of our layout, and thus need to stretch in
+ // order to fit in the current layout size.
+ //
+ // 2) The floating or semi-floating anchors (items) that are those which
+ // are connected to only one (or none) of the layout sides, thus are not
+ // influenced by the layout size.
+ QList<QList<QSimplexConstraint *> > parts = getGraphParts(orientation);
+
+ // Now run the simplex solver to calculate Minimum, Preferred and Maximum sizes
+ // of the "trunk" set of constraints and variables.
+ // ### does trunk always exist? empty = trunk is the layout left->center->right
+ QList<QSimplexConstraint *> trunkConstraints = parts.at(0);
+ QList<AnchorData *> trunkVariables = getVariables(trunkConstraints);
+
+ // For minimum and maximum, use the path between the two layout sides as the
+ // objective function.
+ AnchorVertex *v = layoutLastVertex[orientation];
+ GraphPath trunkPath = graphPaths[orientation].value(v);
+
+ bool feasible = calculateTrunk(orientation, trunkPath, trunkConstraints, trunkVariables);
+
+ // For the other parts that not the trunk, solve only for the preferred size
+ // that is the size they will remain at, since they are not stretched by the
+ // layout.
+
+ // Skipping the first (trunk)
+ for (int i = 1; i < parts.count(); ++i) {
+ if (!feasible)
+ break;
+
+ QList<QSimplexConstraint *> partConstraints = parts.at(i);
+ QList<AnchorData *> partVariables = getVariables(partConstraints);
+ Q_ASSERT(!partVariables.isEmpty());
+ feasible &= calculateNonTrunk(partConstraints, partVariables);
+ }
+
+ // Propagate the new sizes down the simplified graph, ie. tell the
+ // group anchors to set their children anchors sizes.
+ updateAnchorSizes(orientation);
+
+ graphHasConflicts[orientation] = !feasible;
+
+ // Clean up our data structures. They are not needed anymore since
+ // distribution uses just interpolation.
+ qDeleteAll(constraints[orientation]);
+ constraints[orientation].clear();
+ graphPaths[orientation].clear(); // ###
+
+ if (simplificationEnabled)
+ restoreSimplifiedGraph(orientation);
+}
+
+/*!
+ \internal
+
+ Shift all the constraints by a certain amount. This allows us to deal with negative values in
+ the linear program if they are bounded by a certain limit. Functions should be careful to
+ call it again with a negative amount, to shift the constraints back.
+*/
+static void shiftConstraints(const QList<QSimplexConstraint *> &constraints, qreal amount)
+{
+ for (int i = 0; i < constraints.count(); ++i) {
+ QSimplexConstraint *c = constraints.at(i);
+ qreal multiplier = 0;
+ foreach (qreal v, c->variables.values()) {
+ multiplier += v;
+ }
+ c->constant += multiplier * amount;
+ }
+}
+
+/*!
+ \internal
+
+ Calculate the sizes for all anchors which are part of the trunk. This works
+ on top of a (possibly) simplified graph.
+*/
+bool QGraphicsAnchorLayoutPrivate::calculateTrunk(Orientation orientation, const GraphPath &path,
+ const QList<QSimplexConstraint *> &constraints,
+ const QList<AnchorData *> &variables)
+{
+ bool feasible = true;
+ bool needsSimplex = !constraints.isEmpty();
+
+#if 0
+ qDebug("Simplex %s for trunk of %s", needsSimplex ? "used" : "NOT used",
+ orientation == Horizontal ? "Horizontal" : "Vertical");
+#endif
+
+ if (needsSimplex) {
+
+ QList<QSimplexConstraint *> sizeHintConstraints = constraintsFromSizeHints(variables);
+ QList<QSimplexConstraint *> allConstraints = constraints + sizeHintConstraints;
+
+ shiftConstraints(allConstraints, g_offset);
+
+ // Solve min and max size hints
+ qreal min, max;
+ feasible = solveMinMax(allConstraints, path, &min, &max);
+
+ if (feasible) {
+ solvePreferred(constraints, variables);
+
+ // Calculate and set the preferred size for the layout,
+ // from the edge sizes that were calculated above.
+ qreal pref(0.0);
+ foreach (const AnchorData *ad, path.positives) {
+ pref += ad->sizeAtPreferred;
+ }
+ foreach (const AnchorData *ad, path.negatives) {
+ pref -= ad->sizeAtPreferred;
+ }
+
+ sizeHints[orientation][Qt::MinimumSize] = min;
+ sizeHints[orientation][Qt::PreferredSize] = pref;
+ sizeHints[orientation][Qt::MaximumSize] = max;
+ }
+
+ qDeleteAll(sizeHintConstraints);
+ shiftConstraints(constraints, -g_offset);
+
+ } else {
+ // No Simplex is necessary because the path was simplified all the way to a single
+ // anchor.
+ Q_ASSERT(path.positives.count() == 1);
+ Q_ASSERT(path.negatives.count() == 0);
+
+ AnchorData *ad = path.positives.toList()[0];
+ ad->sizeAtMinimum = ad->minSize;
+ ad->sizeAtPreferred = ad->prefSize;
+ ad->sizeAtMaximum = ad->maxSize;
+
+ sizeHints[orientation][Qt::MinimumSize] = ad->sizeAtMinimum;
+ sizeHints[orientation][Qt::PreferredSize] = ad->sizeAtPreferred;
+ sizeHints[orientation][Qt::MaximumSize] = ad->sizeAtMaximum;
+ }
+
+#if defined(QT_DEBUG) || defined(Q_AUTOTEST_EXPORT)
+ lastCalculationUsedSimplex[orientation] = needsSimplex;
+#endif
+
+ return feasible;
+}
+
+/*!
+ \internal
+*/
+bool QGraphicsAnchorLayoutPrivate::calculateNonTrunk(const QList<QSimplexConstraint *> &constraints,
+ const QList<AnchorData *> &variables)
+{
+ shiftConstraints(constraints, g_offset);
+ bool feasible = solvePreferred(constraints, variables);
+
+ if (feasible) {
+ // Propagate size at preferred to other sizes. Semi-floats always will be
+ // in their sizeAtPreferred.
+ for (int j = 0; j < variables.count(); ++j) {
+ AnchorData *ad = variables.at(j);
+ Q_ASSERT(ad);
+ ad->sizeAtMinimum = ad->sizeAtPreferred;
+ ad->sizeAtMaximum = ad->sizeAtPreferred;
+ }
+ }
+
+ shiftConstraints(constraints, -g_offset);
+ return feasible;
+}
+
+/*!
+ \internal
+
+ Traverse the graph refreshing the size hints. Edges will query their associated
+ item or graphicsAnchor for their size hints.
+*/
+void QGraphicsAnchorLayoutPrivate::refreshAllSizeHints(Orientation orientation)
+{
+ Graph<AnchorVertex, AnchorData> &g = graph[orientation];
+ QList<QPair<AnchorVertex *, AnchorVertex *> > vertices = g.connections();
+
+ QLayoutStyleInfo styleInf = styleInfo();
+ for (int i = 0; i < vertices.count(); ++i) {
+ AnchorData *data = g.edgeData(vertices.at(i).first, vertices.at(i).second);
+ data->refreshSizeHints(&styleInf);
+ }
+}
+
+/*!
+ \internal
+
+ This method walks the graph using a breadth-first search to find paths
+ between the root vertex and each vertex on the graph. The edges
+ directions in each path are considered and they are stored as a
+ positive edge (left-to-right) or negative edge (right-to-left).
+
+ The list of paths is used later to generate a list of constraints.
+ */
+void QGraphicsAnchorLayoutPrivate::findPaths(Orientation orientation)
+{
+ QQueue<QPair<AnchorVertex *, AnchorVertex *> > queue;
+
+ QSet<AnchorData *> visited;
+
+ AnchorVertex *root = layoutFirstVertex[orientation];
+
+ graphPaths[orientation].insert(root, GraphPath());
+
+ foreach (AnchorVertex *v, graph[orientation].adjacentVertices(root)) {
+ queue.enqueue(qMakePair(root, v));
+ }
+
+ while(!queue.isEmpty()) {
+ QPair<AnchorVertex *, AnchorVertex *> pair = queue.dequeue();
+ AnchorData *edge = graph[orientation].edgeData(pair.first, pair.second);
+
+ if (visited.contains(edge))
+ continue;
+
+ visited.insert(edge);
+ GraphPath current = graphPaths[orientation].value(pair.first);
+
+ if (edge->from == pair.first)
+ current.positives.insert(edge);
+ else
+ current.negatives.insert(edge);
+
+ graphPaths[orientation].insert(pair.second, current);
+
+ foreach (AnchorVertex *v,
+ graph[orientation].adjacentVertices(pair.second)) {
+ queue.enqueue(qMakePair(pair.second, v));
+ }
+ }
+
+ // We will walk through every reachable items (non-float) store them in a temporary set.
+ // We them create a set of all items and subtract the non-floating items from the set in
+ // order to get the floating items. The floating items is then stored in m_floatItems
+ identifyFloatItems(visited, orientation);
+}
+
+/*!
+ \internal
+
+ Each vertex on the graph that has more than one path to it
+ represents a contra int to the sizes of the items in these paths.
+
+ This method walks the list of paths to each vertex, generate
+ the constraints and store them in a list so they can be used later
+ by the Simplex solver.
+*/
+void QGraphicsAnchorLayoutPrivate::constraintsFromPaths(Orientation orientation)
+{
+ foreach (AnchorVertex *vertex, graphPaths[orientation].uniqueKeys())
+ {
+ int valueCount = graphPaths[orientation].count(vertex);
+ if (valueCount == 1)
+ continue;
+
+ QList<GraphPath> pathsToVertex = graphPaths[orientation].values(vertex);
+ for (int i = 1; i < valueCount; ++i) {
+ constraints[orientation] += \
+ pathsToVertex[0].constraint(pathsToVertex.at(i));
+ }
+ }
+}
+
+/*!
+ \internal
+*/
+void QGraphicsAnchorLayoutPrivate::updateAnchorSizes(Orientation orientation)
+{
+ Graph<AnchorVertex, AnchorData> &g = graph[orientation];
+ const QList<QPair<AnchorVertex *, AnchorVertex *> > &vertices = g.connections();
+
+ for (int i = 0; i < vertices.count(); ++i) {
+ AnchorData *ad = g.edgeData(vertices.at(i).first, vertices.at(i).second);
+ ad->updateChildrenSizes();
+ }
+}
+
+/*!
+ \internal
+
+ Create LP constraints for each anchor based on its minimum and maximum
+ sizes, as specified in its size hints
+*/
+QList<QSimplexConstraint *> QGraphicsAnchorLayoutPrivate::constraintsFromSizeHints(
+ const QList<AnchorData *> &anchors)
+{
+ if (anchors.isEmpty())
+ return QList<QSimplexConstraint *>();
+
+ // Look for the layout edge. That can be either the first half in case the
+ // layout is split in two, or the whole layout anchor.
+ Orientation orient = Orientation(anchors.first()->orientation);
+ AnchorData *layoutEdge = 0;
+ if (layoutCentralVertex[orient]) {
+ layoutEdge = graph[orient].edgeData(layoutFirstVertex[orient], layoutCentralVertex[orient]);
+ } else {
+ layoutEdge = graph[orient].edgeData(layoutFirstVertex[orient], layoutLastVertex[orient]);
+ }
+
+ // If maxSize is less then "infinite", that means there are other anchors
+ // grouped together with this one. We can't ignore its maximum value so we
+ // set back the variable to NULL to prevent the continue condition from being
+ // satisfied in the loop below.
+ const qreal expectedMax = layoutCentralVertex[orient] ? QWIDGETSIZE_MAX / 2 : QWIDGETSIZE_MAX;
+ qreal actualMax;
+ if (layoutEdge->from == layoutFirstVertex[orient]) {
+ actualMax = layoutEdge->maxSize;
+ } else {
+ actualMax = -layoutEdge->minSize;
+ }
+ if (actualMax != expectedMax) {
+ layoutEdge = 0;
+ }
+
+ // For each variable, create constraints based on size hints
+ QList<QSimplexConstraint *> anchorConstraints;
+ bool unboundedProblem = true;
+ for (int i = 0; i < anchors.size(); ++i) {
+ AnchorData *ad = anchors.at(i);
+
+ // Anchors that have their size directly linked to another one don't need constraints
+ // For exammple, the second half of an item has exactly the same size as the first half
+ // thus constraining the latter is enough.
+ if (ad->dependency == AnchorData::Slave)
+ continue;
+
+ // To use negative variables inside simplex, we shift them so the minimum negative value is
+ // mapped to zero before solving. To make sure that it works, we need to guarantee that the
+ // variables are all inside a certain boundary.
+ qreal boundedMin = qBound(-g_offset, ad->minSize, g_offset);
+ qreal boundedMax = qBound(-g_offset, ad->maxSize, g_offset);
+
+ if ((boundedMin == boundedMax) || qFuzzyCompare(boundedMin, boundedMax)) {
+ QSimplexConstraint *c = new QSimplexConstraint;
+ c->variables.insert(ad, 1.0);
+ c->constant = boundedMin;
+ c->ratio = QSimplexConstraint::Equal;
+ anchorConstraints += c;
+ unboundedProblem = false;
+ } else {
+ QSimplexConstraint *c = new QSimplexConstraint;
+ c->variables.insert(ad, 1.0);
+ c->constant = boundedMin;
+ c->ratio = QSimplexConstraint::MoreOrEqual;
+ anchorConstraints += c;
+
+ // We avoid adding restrictions to the layout internal anchors. That's
+ // to prevent unnecessary fair distribution from happening due to this
+ // artificial restriction.
+ if (ad == layoutEdge)
+ continue;
+
+ c = new QSimplexConstraint;
+ c->variables.insert(ad, 1.0);
+ c->constant = boundedMax;
+ c->ratio = QSimplexConstraint::LessOrEqual;
+ anchorConstraints += c;
+ unboundedProblem = false;
+ }
+ }
+
+ // If no upper boundary restriction was added, add one to avoid unbounded problem
+ if (unboundedProblem) {
+ QSimplexConstraint *c = new QSimplexConstraint;
+ c->variables.insert(layoutEdge, 1.0);
+ // The maximum size that the layout can take
+ c->constant = g_offset;
+ c->ratio = QSimplexConstraint::LessOrEqual;
+ anchorConstraints += c;
+ }
+
+ return anchorConstraints;
+}
+
+/*!
+ \internal
+*/
+QList< QList<QSimplexConstraint *> >
+QGraphicsAnchorLayoutPrivate::getGraphParts(Orientation orientation)
+{
+ Q_ASSERT(layoutFirstVertex[orientation] && layoutLastVertex[orientation]);
+
+ AnchorData *edgeL1 = 0;
+ AnchorData *edgeL2 = 0;
+
+ // The layout may have a single anchor between Left and Right or two half anchors
+ // passing through the center
+ if (layoutCentralVertex[orientation]) {
+ edgeL1 = graph[orientation].edgeData(layoutFirstVertex[orientation], layoutCentralVertex[orientation]);
+ edgeL2 = graph[orientation].edgeData(layoutCentralVertex[orientation], layoutLastVertex[orientation]);
+ } else {
+ edgeL1 = graph[orientation].edgeData(layoutFirstVertex[orientation], layoutLastVertex[orientation]);
+ }
+
+ QLinkedList<QSimplexConstraint *> remainingConstraints;
+ for (int i = 0; i < constraints[orientation].count(); ++i) {
+ remainingConstraints += constraints[orientation].at(i);
+ }
+ for (int i = 0; i < itemCenterConstraints[orientation].count(); ++i) {
+ remainingConstraints += itemCenterConstraints[orientation].at(i);
+ }
+
+ QList<QSimplexConstraint *> trunkConstraints;
+ QSet<QSimplexVariable *> trunkVariables;
+
+ trunkVariables += edgeL1;
+ if (edgeL2)
+ trunkVariables += edgeL2;
+
+ bool dirty;
+ do {
+ dirty = false;
+
+ QLinkedList<QSimplexConstraint *>::iterator it = remainingConstraints.begin();
+ while (it != remainingConstraints.end()) {
+ QSimplexConstraint *c = *it;
+ bool match = false;
+
+ // Check if this constraint have some overlap with current
+ // trunk variables...
+ foreach (QSimplexVariable *ad, trunkVariables) {
+ if (c->variables.contains(ad)) {
+ match = true;
+ break;
+ }
+ }
+
+ // If so, we add it to trunk, and erase it from the
+ // remaining constraints.
+ if (match) {
+ trunkConstraints += c;
+ trunkVariables += QSet<QSimplexVariable *>::fromList(c->variables.keys());
+ it = remainingConstraints.erase(it);
+ dirty = true;
+ } else {
+ // Note that we don't erase the constraint if it's not
+ // a match, since in a next iteration of a do-while we
+ // can pass on it again and it will be a match.
+ //
+ // For example: if trunk share a variable with
+ // remainingConstraints[1] and it shares with
+ // remainingConstraints[0], we need a second iteration
+ // of the do-while loop to match both.
+ ++it;
+ }
+ }
+ } while (dirty);
+
+ QList< QList<QSimplexConstraint *> > result;
+ result += trunkConstraints;
+
+ if (!remainingConstraints.isEmpty()) {
+ QList<QSimplexConstraint *> nonTrunkConstraints;
+ QLinkedList<QSimplexConstraint *>::iterator it = remainingConstraints.begin();
+ while (it != remainingConstraints.end()) {
+ nonTrunkConstraints += *it;
+ ++it;
+ }
+ result += nonTrunkConstraints;
+ }
+
+ return result;
+}
+
+/*!
+ \internal
+
+ Use all visited Anchors on findPaths() so we can identify non-float Items.
+*/
+void QGraphicsAnchorLayoutPrivate::identifyFloatItems(const QSet<AnchorData *> &visited, Orientation orientation)
+{
+ QSet<QGraphicsLayoutItem *> nonFloating;
+
+ foreach (const AnchorData *ad, visited)
+ identifyNonFloatItems_helper(ad, &nonFloating);
+
+ QSet<QGraphicsLayoutItem *> allItems;
+ foreach (QGraphicsLayoutItem *item, items)
+ allItems.insert(item);
+ m_floatItems[orientation] = allItems - nonFloating;
+}
+
+
+/*!
+ \internal
+
+ Given an anchor, if it is an internal anchor and Normal we must mark it's item as non-float.
+ If the anchor is Sequential or Parallel, we must iterate on its children recursively until we reach
+ internal anchors (items).
+*/
+void QGraphicsAnchorLayoutPrivate::identifyNonFloatItems_helper(const AnchorData *ad, QSet<QGraphicsLayoutItem *> *nonFloatingItemsIdentifiedSoFar)
+{
+ Q_Q(QGraphicsAnchorLayout);
+
+ switch(ad->type) {
+ case AnchorData::Normal:
+ if (ad->item && ad->item != q)
+ nonFloatingItemsIdentifiedSoFar->insert(ad->item);
+ break;
+ case AnchorData::Sequential:
+ foreach (const AnchorData *d, static_cast<const SequentialAnchorData *>(ad)->m_edges)
+ identifyNonFloatItems_helper(d, nonFloatingItemsIdentifiedSoFar);
+ break;
+ case AnchorData::Parallel:
+ identifyNonFloatItems_helper(static_cast<const ParallelAnchorData *>(ad)->firstEdge, nonFloatingItemsIdentifiedSoFar);
+ identifyNonFloatItems_helper(static_cast<const ParallelAnchorData *>(ad)->secondEdge, nonFloatingItemsIdentifiedSoFar);
+ break;
+ }
+}
+
+/*!
+ \internal
+
+ Use the current vertices distance to calculate and set the geometry of
+ each item.
+*/
+void QGraphicsAnchorLayoutPrivate::setItemsGeometries(const QRectF &geom)
+{
+ Q_Q(QGraphicsAnchorLayout);
+ AnchorVertex *firstH, *secondH, *firstV, *secondV;
+
+ qreal top;
+ qreal left;
+ qreal right;
+
+ q->getContentsMargins(&left, &top, &right, 0);
+ const Qt::LayoutDirection visualDir = visualDirection();
+ if (visualDir == Qt::RightToLeft)
+ qSwap(left, right);
+
+ left += geom.left();
+ top += geom.top();
+ right = geom.right() - right;
+
+ foreach (QGraphicsLayoutItem *item, items) {
+ QRectF newGeom;
+ QSizeF itemPreferredSize = item->effectiveSizeHint(Qt::PreferredSize);
+ if (m_floatItems[Horizontal].contains(item)) {
+ newGeom.setLeft(0);
+ newGeom.setRight(itemPreferredSize.width());
+ } else {
+ firstH = internalVertex(item, Qt::AnchorLeft);
+ secondH = internalVertex(item, Qt::AnchorRight);
+
+ if (visualDir == Qt::LeftToRight) {
+ newGeom.setLeft(left + firstH->distance);
+ newGeom.setRight(left + secondH->distance);
+ } else {
+ newGeom.setLeft(right - secondH->distance);
+ newGeom.setRight(right - firstH->distance);
+ }
+ }
+
+ if (m_floatItems[Vertical].contains(item)) {
+ newGeom.setTop(0);
+ newGeom.setBottom(itemPreferredSize.height());
+ } else {
+ firstV = internalVertex(item, Qt::AnchorTop);
+ secondV = internalVertex(item, Qt::AnchorBottom);
+
+ newGeom.setTop(top + firstV->distance);
+ newGeom.setBottom(top + secondV->distance);
+ }
+
+ item->setGeometry(newGeom);
+ }
+}
+
+/*!
+ \internal
+
+ Calculate the position of each vertex based on the paths to each of
+ them as well as the current edges sizes.
+*/
+void QGraphicsAnchorLayoutPrivate::calculateVertexPositions(
+ QGraphicsAnchorLayoutPrivate::Orientation orientation)
+{
+ QQueue<QPair<AnchorVertex *, AnchorVertex *> > queue;
+ QSet<AnchorVertex *> visited;
+
+ // Get root vertex
+ AnchorVertex *root = layoutFirstVertex[orientation];
+
+ root->distance = 0;
+ visited.insert(root);
+
+ // Add initial edges to the queue
+ foreach (AnchorVertex *v, graph[orientation].adjacentVertices(root)) {
+ queue.enqueue(qMakePair(root, v));
+ }
+
+ // Do initial calculation required by "interpolateEdge()"
+ setupEdgesInterpolation(orientation);
+
+ // Traverse the graph and calculate vertex positions
+ while (!queue.isEmpty()) {
+ QPair<AnchorVertex *, AnchorVertex *> pair = queue.dequeue();
+ AnchorData *edge = graph[orientation].edgeData(pair.first, pair.second);
+
+ if (visited.contains(pair.second))
+ continue;
+
+ visited.insert(pair.second);
+ interpolateEdge(pair.first, edge);
+
+ QList<AnchorVertex *> adjacents = graph[orientation].adjacentVertices(pair.second);
+ for (int i = 0; i < adjacents.count(); ++i) {
+ if (!visited.contains(adjacents.at(i)))
+ queue.enqueue(qMakePair(pair.second, adjacents.at(i)));
+ }
+ }
+}
+
+/*!
+ \internal
+
+ Calculate interpolation parameters based on current Layout Size.
+ Must be called once before calling "interpolateEdgeSize()" for
+ the edges.
+*/
+void QGraphicsAnchorLayoutPrivate::setupEdgesInterpolation(
+ Orientation orientation)
+{
+ Q_Q(QGraphicsAnchorLayout);
+
+ qreal current;
+ current = (orientation == Horizontal) ? q->contentsRect().width() : q->contentsRect().height();
+
+ QPair<Interval, qreal> result;
+ result = getFactor(current,
+ sizeHints[orientation][Qt::MinimumSize],
+ sizeHints[orientation][Qt::PreferredSize],
+ sizeHints[orientation][Qt::PreferredSize],
+ sizeHints[orientation][Qt::PreferredSize],
+ sizeHints[orientation][Qt::MaximumSize]);
+
+ interpolationInterval[orientation] = result.first;
+ interpolationProgress[orientation] = result.second;
+}
+
+/*!
+ \internal
+
+ Calculate the current Edge size based on the current Layout size and the
+ size the edge is supposed to have when the layout is at its:
+
+ - minimum size,
+ - preferred size,
+ - maximum size.
+
+ These three key values are calculated in advance using linear
+ programming (more expensive) or the simplification algorithm, then
+ subsequential resizes of the parent layout require a simple
+ interpolation.
+*/
+void QGraphicsAnchorLayoutPrivate::interpolateEdge(AnchorVertex *base, AnchorData *edge)
+{
+ const Orientation orientation = Orientation(edge->orientation);
+ const QPair<Interval, qreal> factor(interpolationInterval[orientation],
+ interpolationProgress[orientation]);
+
+ qreal edgeDistance = interpolate(factor, edge->sizeAtMinimum, edge->sizeAtPreferred,
+ edge->sizeAtPreferred, edge->sizeAtPreferred,
+ edge->sizeAtMaximum);
+
+ Q_ASSERT(edge->from == base || edge->to == base);
+
+ // Calculate the distance for the vertex opposite to the base
+ if (edge->from == base) {
+ edge->to->distance = base->distance + edgeDistance;
+ } else {
+ edge->from->distance = base->distance - edgeDistance;
+ }
+}
+
+bool QGraphicsAnchorLayoutPrivate::solveMinMax(const QList<QSimplexConstraint *> &constraints,
+ GraphPath path, qreal *min, qreal *max)
+{
+ QSimplex simplex;
+ bool feasible = simplex.setConstraints(constraints);
+ if (feasible) {
+ // Obtain the objective constraint
+ QSimplexConstraint objective;
+ QSet<AnchorData *>::const_iterator iter;
+ for (iter = path.positives.constBegin(); iter != path.positives.constEnd(); ++iter)
+ objective.variables.insert(*iter, 1.0);
+
+ for (iter = path.negatives.constBegin(); iter != path.negatives.constEnd(); ++iter)
+ objective.variables.insert(*iter, -1.0);
+
+ const qreal objectiveOffset = (path.positives.count() - path.negatives.count()) * g_offset;
+ simplex.setObjective(&objective);
+
+ // Calculate minimum values
+ *min = simplex.solveMin() - objectiveOffset;
+
+ // Save sizeAtMinimum results
+ QList<AnchorData *> variables = getVariables(constraints);
+ for (int i = 0; i < variables.size(); ++i) {
+ AnchorData *ad = static_cast<AnchorData *>(variables.at(i));
+ ad->sizeAtMinimum = ad->result - g_offset;
+ }
+
+ // Calculate maximum values
+ *max = simplex.solveMax() - objectiveOffset;
+
+ // Save sizeAtMaximum results
+ for (int i = 0; i < variables.size(); ++i) {
+ AnchorData *ad = static_cast<AnchorData *>(variables.at(i));
+ ad->sizeAtMaximum = ad->result - g_offset;
+ }
+ }
+ return feasible;
+}
+
+enum slackType { Grower = -1, Shrinker = 1 };
+static QPair<QSimplexVariable *, QSimplexConstraint *> createSlack(QSimplexConstraint *sizeConstraint,
+ qreal interval, slackType type)
+{
+ QSimplexVariable *slack = new QSimplexVariable;
+ sizeConstraint->variables.insert(slack, type);
+
+ QSimplexConstraint *limit = new QSimplexConstraint;
+ limit->variables.insert(slack, 1.0);
+ limit->ratio = QSimplexConstraint::LessOrEqual;
+ limit->constant = interval;
+
+ return qMakePair(slack, limit);
+}
+
+bool QGraphicsAnchorLayoutPrivate::solvePreferred(const QList<QSimplexConstraint *> &constraints,
+ const QList<AnchorData *> &variables)
+{
+ QList<QSimplexConstraint *> preferredConstraints;
+ QList<QSimplexVariable *> preferredVariables;
+ QSimplexConstraint objective;
+
+ // Fill the objective coefficients for this variable. In the
+ // end the objective function will be
+ //
+ // z = n * (A_shrinker_hard + A_grower_hard + B_shrinker_hard + B_grower_hard + ...) +
+ // (A_shrinker_soft + A_grower_soft + B_shrinker_soft + B_grower_soft + ...)
+ //
+ // where n is the number of variables that have
+ // slacks. Note that here we use the number of variables
+ // as coefficient, this is to mark the "shrinker slack
+ // variable" less likely to get value than the "grower
+ // slack variable".
+
+ // This will fill the values for the structural constraints
+ // and we now fill the values for the slack constraints (one per variable),
+ // which have this form (the constant A_pref was set when creating the slacks):
+ //
+ // A + A_shrinker_hard + A_shrinker_soft - A_grower_hard - A_grower_soft = A_pref
+ //
+ for (int i = 0; i < variables.size(); ++i) {
+ AnchorData *ad = variables.at(i);
+
+ // The layout original structure anchors are not relevant in preferred size calculation
+ if (ad->isLayoutAnchor)
+ continue;
+
+ // By default, all variables are equal to their preferred size. If they have room to
+ // grow or shrink, such flexibility will be added by the additional variables below.
+ QSimplexConstraint *sizeConstraint = new QSimplexConstraint;
+ preferredConstraints += sizeConstraint;
+ sizeConstraint->variables.insert(ad, 1.0);
+ sizeConstraint->constant = ad->prefSize + g_offset;
+
+ // Can easily shrink
+ QPair<QSimplexVariable *, QSimplexConstraint *> slack;
+ const qreal softShrinkInterval = ad->prefSize - ad->minPrefSize;
+ if (softShrinkInterval) {
+ slack = createSlack(sizeConstraint, softShrinkInterval, Shrinker);
+ preferredVariables += slack.first;
+ preferredConstraints += slack.second;
+
+ // Add to objective with ratio == 1 (soft)
+ objective.variables.insert(slack.first, 1.0);
+ }
+
+ // Can easily grow
+ const qreal softGrowInterval = ad->maxPrefSize - ad->prefSize;
+ if (softGrowInterval) {
+ slack = createSlack(sizeConstraint, softGrowInterval, Grower);
+ preferredVariables += slack.first;
+ preferredConstraints += slack.second;
+
+ // Add to objective with ratio == 1 (soft)
+ objective.variables.insert(slack.first, 1.0);
+ }
+
+ // Can shrink if really necessary
+ const qreal hardShrinkInterval = ad->minPrefSize - ad->minSize;
+ if (hardShrinkInterval) {
+ slack = createSlack(sizeConstraint, hardShrinkInterval, Shrinker);
+ preferredVariables += slack.first;
+ preferredConstraints += slack.second;
+
+ // Add to objective with ratio == N (hard)
+ objective.variables.insert(slack.first, variables.size());
+ }
+
+ // Can grow if really necessary
+ const qreal hardGrowInterval = ad->maxSize - ad->maxPrefSize;
+ if (hardGrowInterval) {
+ slack = createSlack(sizeConstraint, hardGrowInterval, Grower);
+ preferredVariables += slack.first;
+ preferredConstraints += slack.second;
+
+ // Add to objective with ratio == N (hard)
+ objective.variables.insert(slack.first, variables.size());
+ }
+ }
+
+ QSimplex *simplex = new QSimplex;
+ bool feasible = simplex->setConstraints(constraints + preferredConstraints);
+ if (feasible) {
+ simplex->setObjective(&objective);
+
+ // Calculate minimum values
+ simplex->solveMin();
+
+ // Save sizeAtPreferred results
+ for (int i = 0; i < variables.size(); ++i) {
+ AnchorData *ad = variables.at(i);
+ ad->sizeAtPreferred = ad->result - g_offset;
+ }
+
+ // Make sure we delete the simplex solver -before- we delete the
+ // constraints used by it.
+ delete simplex;
+ }
+ // Delete constraints and variables we created.
+ qDeleteAll(preferredConstraints);
+ qDeleteAll(preferredVariables);
+
+ return feasible;
+}
+
+/*!
+ \internal
+ Returns true if there are no arrangement that satisfies all constraints.
+ Otherwise returns false.
+
+ \sa addAnchor()
+*/
+bool QGraphicsAnchorLayoutPrivate::hasConflicts() const
+{
+ QGraphicsAnchorLayoutPrivate *that = const_cast<QGraphicsAnchorLayoutPrivate*>(this);
+ that->calculateGraphs();
+
+ bool floatConflict = !m_floatItems[0].isEmpty() || !m_floatItems[1].isEmpty();
+
+ return graphHasConflicts[0] || graphHasConflicts[1] || floatConflict;
+}
+
+#ifdef QT_DEBUG
+void QGraphicsAnchorLayoutPrivate::dumpGraph(const QString &name)
+{
+ QFile file(QString::fromAscii("anchorlayout.%1.dot").arg(name));
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate))
+ qWarning("Could not write to %s", file.fileName().toLocal8Bit().constData());
+
+ QString str = QString::fromAscii("digraph anchorlayout {\nnode [shape=\"rect\"]\n%1}");
+ QString dotContents = graph[0].serializeToDot();
+ dotContents += graph[1].serializeToDot();
+ file.write(str.arg(dotContents).toLocal8Bit());
+
+ file.close();
+}
+#endif
+
+QT_END_NAMESPACE
+#endif //QT_NO_GRAPHICSVIEW
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.h b/src/widgets/graphicsview/qgraphicsanchorlayout_p.h
index 9a91c3c8df..9a91c3c8df 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.h
+++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.h
diff --git a/src/gui/graphicsview/qgraphicsgridlayout.cpp b/src/widgets/graphicsview/qgraphicsgridlayout.cpp
index f6eec1d405..f6eec1d405 100644
--- a/src/gui/graphicsview/qgraphicsgridlayout.cpp
+++ b/src/widgets/graphicsview/qgraphicsgridlayout.cpp
diff --git a/src/widgets/graphicsview/qgraphicsgridlayout.h b/src/widgets/graphicsview/qgraphicsgridlayout.h
new file mode 100644
index 0000000000..2778683778
--- /dev/null
+++ b/src/widgets/graphicsview/qgraphicsgridlayout.h
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGRAPHICSGRIDLAYOUT_H
+#define QGRAPHICSGRIDLAYOUT_H
+
+#include <QtWidgets/qgraphicsitem.h>
+#include <QtWidgets/qgraphicslayout.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
+
+class QGraphicsGridLayoutPrivate;
+
+class Q_GUI_EXPORT QGraphicsGridLayout : public QGraphicsLayout
+{
+public:
+ QGraphicsGridLayout(QGraphicsLayoutItem *parent = 0);
+ virtual ~QGraphicsGridLayout();
+
+ void addItem(QGraphicsLayoutItem *item, int row, int column, int rowSpan, int columnSpan,
+ Qt::Alignment alignment = 0);
+ inline void addItem(QGraphicsLayoutItem *item, int row, int column, Qt::Alignment alignment = 0);
+
+ void setHorizontalSpacing(qreal spacing);
+ qreal horizontalSpacing() const;
+ void setVerticalSpacing(qreal spacing);
+ qreal verticalSpacing() const;
+ void setSpacing(qreal spacing);
+
+ void setRowSpacing(int row, qreal spacing);
+ qreal rowSpacing(int row) const;
+ void setColumnSpacing(int column, qreal spacing);
+ qreal columnSpacing(int column) const;
+
+ void setRowStretchFactor(int row, int stretch);
+ int rowStretchFactor(int row) const;
+ void setColumnStretchFactor(int column, int stretch);
+ int columnStretchFactor(int column) const;
+
+ void setRowMinimumHeight(int row, qreal height);
+ qreal rowMinimumHeight(int row) const;
+ void setRowPreferredHeight(int row, qreal height);
+ qreal rowPreferredHeight(int row) const;
+ void setRowMaximumHeight(int row, qreal height);
+ qreal rowMaximumHeight(int row) const;
+ void setRowFixedHeight(int row, qreal height);
+
+ void setColumnMinimumWidth(int column, qreal width);
+ qreal columnMinimumWidth(int column) const;
+ void setColumnPreferredWidth(int column, qreal width);
+ qreal columnPreferredWidth(int column) const;
+ void setColumnMaximumWidth(int column, qreal width);
+ qreal columnMaximumWidth(int column) const;
+ void setColumnFixedWidth(int column, qreal width);
+
+ void setRowAlignment(int row, Qt::Alignment alignment);
+ Qt::Alignment rowAlignment(int row) const;
+ void setColumnAlignment(int column, Qt::Alignment alignment);
+ Qt::Alignment columnAlignment(int column) const;
+
+ void setAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment);
+ Qt::Alignment alignment(QGraphicsLayoutItem *item) const;
+
+ int rowCount() const;
+ int columnCount() const;
+
+ QGraphicsLayoutItem *itemAt(int row, int column) const;
+
+ // inherited from QGraphicsLayout
+ int count() const;
+ QGraphicsLayoutItem *itemAt(int index) const;
+ void removeAt(int index);
+ void removeItem(QGraphicsLayoutItem *item);
+
+ void invalidate();
+
+ // inherited from QGraphicsLayoutItem
+ void setGeometry(const QRectF &rect);
+ QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
+
+ // ####
+ //QRect cellRect(int row, int column, int rowSpan = 1, int columnSpan = 1) const;
+ //QSizePolicy::ControlTypes controlTypes(LayoutSide side) const;
+
+private:
+ Q_DISABLE_COPY(QGraphicsGridLayout)
+ Q_DECLARE_PRIVATE(QGraphicsGridLayout)
+};
+
+inline void QGraphicsGridLayout::addItem(QGraphicsLayoutItem *aitem, int arow, int acolumn, Qt::Alignment aalignment)
+{ addItem(aitem, arow, acolumn, 1, 1, aalignment); }
+
+#endif
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
+
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
new file mode 100644
index 0000000000..72ec5688f6
--- /dev/null
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -0,0 +1,11601 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \class QGraphicsItem
+ \brief The QGraphicsItem class is the base class for all graphical
+ items in a QGraphicsScene.
+ \since 4.2
+
+ \ingroup graphicsview-api
+
+ It provides a light-weight foundation for writing your own custom items.
+ This includes defining the item's geometry, collision detection, its
+ painting implementation and item interaction through its event handlers.
+ QGraphicsItem is part of the \l{Graphics View Framework}
+
+ \image graphicsview-items.png
+
+ For convenience, Qt provides a set of standard graphics items for the most
+ common shapes. These are:
+
+ \list
+ \o QGraphicsEllipseItem provides an ellipse item
+ \o QGraphicsLineItem provides a line item
+ \o QGraphicsPathItem provides an arbitrary path item
+ \o QGraphicsPixmapItem provides a pixmap item
+ \o QGraphicsPolygonItem provides a polygon item
+ \o QGraphicsRectItem provides a rectangular item
+ \o QGraphicsSimpleTextItem provides a simple text label item
+ \o QGraphicsTextItem provides an advanced text browser item
+ \endlist
+
+ All of an item's geometric information is based on its local coordinate
+ system. The item's position, pos(), is the only function that does not
+ operate in local coordinates, as it returns a position in parent
+ coordinates. \l {The Graphics View Coordinate System} describes the coordinate
+ system in detail.
+
+ You can set whether an item should be visible (i.e., drawn, and accepting
+ events), by calling setVisible(). Hiding an item will also hide its
+ children. Similarly, you can enable or disable an item by calling
+ setEnabled(). If you disable an item, all its children will also be
+ disabled. By default, items are both visible and enabled. To toggle
+ whether an item is selected or not, first enable selection by setting
+ the ItemIsSelectable flag, and then call setSelected(). Normally,
+ selection is toggled by the scene, as a result of user interaction.
+
+ To write your own graphics item, you first create a subclass of
+ QGraphicsItem, and then start by implementing its two pure virtual public
+ functions: boundingRect(), which returns an estimate of the area painted
+ by the item, and paint(), which implements the actual painting. For
+ example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 0
+
+ The boundingRect() function has many different purposes.
+ QGraphicsScene bases its item index on boundingRect(), and
+ QGraphicsView uses it both for culling invisible items, and for
+ determining the area that needs to be recomposed when drawing
+ overlapping items. In addition, QGraphicsItem's collision
+ detection mechanisms use boundingRect() to provide an efficient
+ cut-off. The fine grained collision algorithm in
+ collidesWithItem() is based on calling shape(), which returns an
+ accurate outline of the item's shape as a QPainterPath.
+
+ QGraphicsScene expects all items boundingRect() and shape() to
+ remain unchanged unless it is notified. If you want to change an
+ item's geometry in any way, you must first call
+ prepareGeometryChange() to allow QGraphicsScene to update its
+ bookkeeping.
+
+ Collision detection can be done in two ways:
+
+ \list 1
+
+ \o Reimplement shape() to return an accurate shape for your item,
+ and rely on the default implementation of collidesWithItem() to do
+ shape-shape intersection. This can be rather expensive if the
+ shapes are complex.
+
+ \o Reimplement collidesWithItem() to provide your own custom item
+ and shape collision algorithm.
+
+ \endlist
+
+ The contains() function can be called to determine whether the item \e
+ contains a point or not. This function can also be reimplemented by the
+ item. The default behavior of contains() is based on calling shape().
+
+ Items can contain other items, and also be contained by other items. All
+ items can have a parent item and a list of children. Unless the item has
+ no parent, its position is in \e parent coordinates (i.e., the parent's
+ local coordinates). Parent items propagate both their position and their
+ transformation to all children.
+
+ \img graphicsview-parentchild.png
+
+ \target Transformations
+ \section1 Transformations
+
+ QGraphicsItem supports projective transformations in addition to its base
+ position, pos(). There are several ways to change an item's transformation.
+ For simple transformations, you can call either of the convenience
+ functions setRotation() or setScale(), or you can pass any transformation
+ matrix to setTransform(). For advanced transformation control you also have
+ the option of setting several combined transformations by calling
+ setTransformations().
+
+ Item transformations accumulate from parent to child, so if both a parent
+ and child item are rotated 90 degrees, the child's total transformation
+ will be 180 degrees. Similarly, if the item's parent is scaled to 2x its
+ original size, its children will also be twice as large. An item's
+ transformation does not affect its own local geometry; all geometry
+ functions (e.g., contains(), update(), and all the mapping functions) still
+ operate in local coordinates. For convenience, QGraphicsItem provides the
+ functions sceneTransform(), which returns the item's total transformation
+ matrix (including its position and all parents' positions and
+ transformations), and scenePos(), which returns its position in scene
+ coordinates. To reset an item's matrix, call resetTransform().
+
+ Certain transformation operations produce a different outcome depending on
+ the order in which they are applied. For example, if you scale an
+ transform, and then rotate it, you may get a different result than if the
+ transform was rotated first. However, the order you set the transformation
+ properties on QGraphicsItem does not affect the resulting transformation;
+ QGraphicsItem always applies the properties in a fixed, defined order:
+
+ \list
+ \o The item's base transform is applied (transform())
+ \o The item's transformations list is applied in order (transformations())
+ \o The item is rotated relative to its transform origin point (rotation(), transformOriginPoint())
+ \o The item is scaled relative to its transform origin point (scale(), transformOriginPoint())
+ \endlist
+
+ \section1 Painting
+
+ The paint() function is called by QGraphicsView to paint the item's
+ contents. The item has no background or default fill of its own; whatever
+ is behind the item will shine through all areas that are not explicitly
+ painted in this function. You can call update() to schedule a repaint,
+ optionally passing the rectangle that needs a repaint. Depending on
+ whether or not the item is visible in a view, the item may or may not be
+ repainted; there is no equivalent to QWidget::repaint() in QGraphicsItem.
+
+ Items are painted by the view, starting with the parent items and then
+ drawing children, in ascending stacking order. You can set an item's
+ stacking order by calling setZValue(), and test it by calling
+ zValue(), where items with low z-values are painted before items with
+ high z-values. Stacking order applies to sibling items; parents are always
+ drawn before their children.
+
+ \section1 Sorting
+
+ All items are drawn in a defined, stable order, and this same order decides
+ which items will receive mouse input first when you click on the scene.
+ Normally you don't have to worry about sorting, as the items follow a
+ "natural order", following the logical structure of the scene.
+
+ An item's children are stacked on top of the parent, and sibling items are
+ stacked by insertion order (i.e., in the same order that they were either
+ added to the scene, or added to the same parent). If you add item A, and
+ then B, then B will be on top of A. If you then add C, the items' stacking
+ order will be A, then B, then C.
+
+ \image graphicsview-zorder.png
+
+ This example shows the stacking order of all limbs of the robot from the
+ \l{graphicsview/dragdroprobot}{Drag and Drop Robot} example. The torso is
+ the root item (all other items are children or descendants of the torso),
+ so it is drawn first. Next, the head is drawn, as it is the first item in
+ the torso's list of children. Then the upper left arm is drawn. As the
+ lower arm is a child of the upper arm, the lower arm is then drawn,
+ followed by the upper arm's next sibling, which is the upper right arm, and
+ so on.
+
+ For advanced users, there are ways to alter how your items are sorted:
+
+ \list
+ \o You can call setZValue() on an item to explicitly stack it on top of, or
+ under, other sibling items. The default Z value for an item is 0. Items
+ with the same Z value are stacked by insertion order.
+
+ \o You can call stackBefore() to reorder the list of children. This will
+ directly modify the insertion order.
+
+ \o You can set the ItemStacksBehindParent flag to stack a child item behind
+ its parent.
+ \endlist
+
+ The stacking order of two sibling items also counts for each item's
+ children and descendant items. So if one item is on top of another, then
+ all its children will also be on top of all the other item's children as
+ well.
+
+ \section1 Events
+
+ QGraphicsItem receives events from QGraphicsScene through the virtual
+ function sceneEvent(). This function distributes the most common events
+ to a set of convenience event handlers:
+
+ \list
+ \o contextMenuEvent() handles context menu events
+ \o focusInEvent() and focusOutEvent() handle focus in and out events
+ \o hoverEnterEvent(), hoverMoveEvent(), and hoverLeaveEvent() handles
+ hover enter, move and leave events
+ \o inputMethodEvent() handles input events, for accessibility support
+ \o keyPressEvent() and keyReleaseEvent() handle key press and release events
+ \o mousePressEvent(), mouseMoveEvent(), mouseReleaseEvent(), and
+ mouseDoubleClickEvent() handles mouse press, move, release, click and
+ doubleclick events
+ \endlist
+
+ You can filter events for any other item by installing event filters. This
+ functionality is separate from Qt's regular event filters (see
+ QObject::installEventFilter()), which only work on subclasses of QObject. After
+ installing your item as an event filter for another item by calling
+ installSceneEventFilter(), the filtered events will be received by the virtual
+ function sceneEventFilter(). You can remove item event filters by calling
+ removeSceneEventFilter().
+
+ \section1 Custom Data
+
+ Sometimes it's useful to register custom data with an item, be it a custom
+ item, or a standard item. You can call setData() on any item to store data
+ in it using a key-value pair (the key being an integer, and the value is a
+ QVariant). To get custom data from an item, call data(). This
+ functionality is completely untouched by Qt itself; it is provided for the
+ user's convenience.
+
+ \sa QGraphicsScene, QGraphicsView, {Graphics View Framework}
+*/
+
+/*!
+ \variable QGraphicsItem::Type
+
+ The type value returned by the virtual type() function in standard
+ graphics item classes in Qt. All such standard graphics item
+ classes in Qt are associated with a unique value for Type,
+ e.g. the value returned by QGraphicsPathItem::type() is 2.
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 18
+*/
+
+/*!
+ \variable QGraphicsItem::UserType
+
+ The lowest permitted type value for custom items (subclasses
+ of QGraphicsItem or any of the standard items). This value is
+ used in conjunction with a reimplementation of QGraphicsItem::type()
+ and declaring a Type enum value. Example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 1
+
+ \note UserType = 65536
+*/
+
+/*!
+ \enum QGraphicsItem::GraphicsItemFlag
+
+ This enum describes different flags that you can set on an item to
+ toggle different features in the item's behavior.
+
+ All flags are disabled by default.
+
+ \value ItemIsMovable The item supports interactive movement using
+ the mouse. By clicking on the item and then dragging, the item
+ will move together with the mouse cursor. If the item has
+ children, all children are also moved. If the item is part of a
+ selection, all selected items are also moved. This feature is
+ provided as a convenience through the base implementation of
+ QGraphicsItem's mouse event handlers.
+
+ \value ItemIsSelectable The item supports selection. Enabling this
+ feature will enable setSelected() to toggle selection for the
+ item. It will also let the item be selected automatically as a
+ result of calling QGraphicsScene::setSelectionArea(), by clicking
+ on an item, or by using rubber band selection in QGraphicsView.
+
+ \value ItemIsFocusable The item supports keyboard input focus (i.e., it is
+ an input item). Enabling this flag will allow the item to accept focus,
+ which again allows the delivery of key events to
+ QGraphicsItem::keyPressEvent() and QGraphicsItem::keyReleaseEvent().
+
+ \value ItemClipsToShape The item clips to its own shape. The item cannot
+ draw or receive mouse, tablet, drag and drop or hover events outside its
+ shape. It is disabled by default. This behavior is enforced by
+ QGraphicsView::drawItems() or QGraphicsScene::drawItems(). This flag was
+ introduced in Qt 4.3.
+
+ \value ItemClipsChildrenToShape The item clips the painting of all its
+ descendants to its own shape. Items that are either direct or indirect
+ children of this item cannot draw outside this item's shape. By default,
+ this flag is disabled; children can draw anywhere. This behavior is
+ enforced by QGraphicsView::drawItems() or
+ QGraphicsScene::drawItems(). This flag was introduced in Qt 4.3.
+
+ \value ItemIgnoresTransformations The item ignores inherited
+ transformations (i.e., its position is still anchored to its parent, but
+ the parent or view rotation, zoom or shear transformations are ignored).
+ This flag is useful for keeping text label items horizontal and unscaled,
+ so they will still be readable if the view is transformed. When set, the
+ item's view geometry and scene geometry will be maintained separately. You
+ must call deviceTransform() to map coordinates and detect collisions in
+ the view. By default, this flag is disabled. This flag was introduced in
+ Qt 4.3. \note With this flag set you can still scale the item itself, and
+ that scale transformation will influence the item's children.
+
+ \value ItemIgnoresParentOpacity The item ignores its parent's opacity. The
+ item's effective opacity is the same as its own; it does not combine with
+ the parent's opacity. This flags allows your item to keep its absolute
+ opacity even if the parent is semitransparent. This flag was introduced in
+ Qt 4.5.
+
+ \value ItemDoesntPropagateOpacityToChildren The item doesn't propagate its
+ opacity to its children. This flag allows you to create a semitransparent
+ item that does not affect the opacity of its children. This flag was
+ introduced in Qt 4.5.
+
+ \value ItemStacksBehindParent The item is stacked behind its parent. By
+ default, child items are stacked on top of the parent item. But setting
+ this flag, the child will be stacked behind it. This flag is useful for
+ drop shadow effects and for decoration objects that follow the parent
+ item's geometry without drawing on top of it. This flag was introduced
+ in Qt 4.5.
+
+ \value ItemUsesExtendedStyleOption The item makes use of either
+ \l{QStyleOptionGraphicsItem::} {exposedRect} or
+ \l{QStyleOptionGraphicsItem::} {matrix} in
+ QStyleOptionGraphicsItem. By default, the
+ \l{QStyleOptionGraphicsItem::} {exposedRect} is initialized to the
+ item's boundingRect() and the
+ \l{QStyleOptionGraphicsItem::}{matrix} is untransformed. You can
+ enable this flag for the style options to be set up with more
+ fine-grained values. Note that
+ QStyleOptionGraphicsItem::levelOfDetail is unaffected by this flag
+ and always initialized to 1. Use
+ QStyleOptionGraphicsItem::levelOfDetailFromTransform() if you need
+ a higher value. This flag was introduced in Qt 4.6.
+
+ \value ItemHasNoContents The item does not paint anything (i.e., calling
+ paint() on the item has no effect). You should set this flag on items that
+ do not need to be painted to ensure that Graphics View avoids unnecessary
+ painting preparations. This flag was introduced in Qt 4.6.
+
+ \value ItemSendsGeometryChanges The item enables itemChange()
+ notifications for ItemPositionChange, ItemPositionHasChanged,
+ ItemMatrixChange, ItemTransformChange, ItemTransformHasChanged,
+ ItemRotationChange, ItemRotationHasChanged, ItemScaleChange, ItemScaleHasChanged,
+ ItemTransformOriginPointChange, and ItemTransformOriginPointHasChanged. For
+ performance reasons, these notifications are disabled by default. You must
+ enable this flag to receive notifications for position and transform
+ changes. This flag was introduced in Qt 4.6.
+
+ \value ItemAcceptsInputMethod The item supports input methods typically
+ used for Asian languages.
+ This flag was introduced in Qt 4.6.
+
+ \value ItemNegativeZStacksBehindParent The item automatically
+ stacks behind it's parent if it's z-value is negative. This flag
+ enables setZValue() to toggle ItemStacksBehindParent. This flag
+ was introduced in Qt 4.6.
+
+ \value ItemIsPanel The item is a panel. A panel provides activation and
+ contained focus handling. Only one panel can be active at a time (see
+ QGraphicsItem::isActive()). When no panel is active, QGraphicsScene
+ activates all non-panel items. Window items (i.e.,
+ QGraphicsItem::isWindow() returns true) are panels. This flag was
+ introduced in Qt 4.6.
+
+ \omitvalue ItemIsFocusScope \omit Internal only (for now). \endomit
+
+ \value ItemSendsScenePositionChanges The item enables itemChange()
+ notifications for ItemScenePositionHasChanged. For performance reasons,
+ these notifications are disabled by default. You must enable this flag
+ to receive notifications for scene position changes. This flag was
+ introduced in Qt 4.6.
+
+ \omitvalue ItemStopsClickFocusPropagation \omit The item stops propagating
+ click focus to items underneath when being clicked on. This flag
+ allows you create a non-focusable item that can be clicked on without
+ changing the focus. \endomit
+
+ \omitvalue ItemStopsFocusHandling \omit Same as
+ ItemStopsClickFocusPropagation, but also suppresses focus-out. This flag
+ allows you to completely take over focus handling.
+ This flag was introduced in Qt 4.7. \endomit
+*/
+
+/*!
+ \enum QGraphicsItem::GraphicsItemChange
+
+ This enum describes the state changes that are notified by
+ QGraphicsItem::itemChange(). The notifications are sent as the state
+ changes, and in some cases, adjustments can be made (see the documentation
+ for each change for details).
+
+ Note: Be careful with calling functions on the QGraphicsItem itself inside
+ itemChange(), as certain function calls can lead to unwanted
+ recursion. For example, you cannot call setPos() in itemChange() on an
+ ItemPositionChange notification, as the setPos() function will again call
+ itemChange(ItemPositionChange). Instead, you can return the new, adjusted
+ position from itemChange().
+
+ \value ItemEnabledChange The item's enabled state changes. If the item is
+ presently enabled, it will become disabled, and vice verca. The value
+ argument is the new enabled state (i.e., true or false). Do not call
+ setEnabled() in itemChange() as this notification is delivered. Instead,
+ you can return the new state from itemChange().
+
+ \value ItemEnabledHasChanged The item's enabled state has changed. The
+ value argument is the new enabled state (i.e., true or false). Do not call
+ setEnabled() in itemChange() as this notification is delivered. The return
+ value is ignored.
+
+ \value ItemMatrixChange The item's affine transformation matrix is
+ changing. This value is obsolete; you can use ItemTransformChange instead.
+
+ \value ItemPositionChange The item's position changes. This notification
+ is sent if the ItemSendsGeometryChanges flag is enabled, and when the
+ item's local position changes, relative to its parent (i.e., as a result
+ of calling setPos() or moveBy()). The value argument is the new position
+ (i.e., a QPointF). You can call pos() to get the original position. Do
+ not call setPos() or moveBy() in itemChange() as this notification is
+ delivered; instead, you can return the new, adjusted position from
+ itemChange(). After this notification, QGraphicsItem immediately sends the
+ ItemPositionHasChanged notification if the position changed.
+
+ \value ItemPositionHasChanged The item's position has changed. This
+ notification is sent if the ItemSendsGeometryChanges flag is enabled, and
+ after the item's local position, relative to its parent, has changed. The
+ value argument is the new position (the same as pos()), and QGraphicsItem
+ ignores the return value for this notification (i.e., a read-only
+ notification).
+
+ \value ItemTransformChange The item's transformation matrix changes. This
+ notification is send if the ItemSendsGeometryChanges flag is enabled, and
+ when the item's local transformation matrix changes (i.e., as a result of
+ calling setTransform(). The value argument is the new matrix (i.e., a
+ QTransform); to get the old matrix, call transform(). Do not call
+ setTransform() or set any of the transformation properties in itemChange()
+ as this notification is delivered; instead, you can return the new matrix
+ from itemChange(). This notification is not sent if you change the
+ transformation properties.
+
+ \value ItemTransformHasChanged The item's transformation matrix has
+ changed either because setTransform is called, or one of the
+ transformation properties is changed. This notification is sent if the
+ ItemSendsGeometryChanges flag is enabled, and after the item's local
+ transformation matrix has changed. The value argument is the new matrix
+ (same as transform()), and QGraphicsItem ignores the return value for this
+ notification (i.e., a read-only notification).
+
+ \value ItemRotationChange The item's rotation property changes. This
+ notification is sent if the ItemSendsGeometryChanges flag is enabled, and
+ when the item's rotation property changes (i.e., as a result of calling
+ setRotation()). The value argument is the new rotation (i.e., a double);
+ to get the old rotation, call rotation(). Do not call setRotation() in
+ itemChange() as this notification is delivered; instead, you can return
+ the new rotation from itemChange().
+
+ \value ItemRotationHasChanged The item's rotation property has changed.
+ This notification is sent if the ItemSendsGeometryChanges flag is enabled,
+ and after the item's rotation property has changed. The value argument is
+ the new rotation (i.e., a double), and QGraphicsItem ignores the return
+ value for this notification (i.e., a read-only notification). Do not call
+ setRotation() in itemChange() as this notification is delivered.
+
+ \value ItemScaleChange The item's scale property changes. This notification
+ is sent if the ItemSendsGeometryChanges flag is enabled, and when the item's
+ scale property changes (i.e., as a result of calling setScale()). The value
+ argument is the new scale (i.e., a double); to get the old scale, call
+ scale(). Do not call setScale() in itemChange() as this notification is
+ delivered; instead, you can return the new scale from itemChange().
+
+ \value ItemScaleHasChanged The item's scale property has changed. This
+ notification is sent if the ItemSendsGeometryChanges flag is enabled, and
+ after the item's scale property has changed. The value argument is the new
+ scale (i.e., a double), and QGraphicsItem ignores the return value for this
+ notification (i.e., a read-only notification). Do not call setScale() in
+ itemChange() as this notification is delivered.
+
+ \value ItemTransformOriginPointChange The item's transform origin point
+ property changes. This notification is sent if the ItemSendsGeometryChanges
+ flag is enabled, and when the item's transform origin point property changes
+ (i.e., as a result of calling setTransformOriginPoint()). The value argument
+ is the new origin point (i.e., a QPointF); to get the old origin point, call
+ transformOriginPoint(). Do not call setTransformOriginPoint() in itemChange()
+ as this notification is delivered; instead, you can return the new transform
+ origin point from itemChange().
+
+ \value ItemTransformOriginPointHasChanged The item's transform origin point
+ property has changed. This notification is sent if the ItemSendsGeometryChanges
+ flag is enabled, and after the item's transform origin point property has
+ changed. The value argument is the new origin point (i.e., a QPointF), and
+ QGraphicsItem ignores the return value for this notification (i.e., a read-only
+ notification). Do not call setTransformOriginPoint() in itemChange() as this
+ notification is delivered.
+
+ \value ItemSelectedChange The item's selected state changes. If the item is
+ presently selected, it will become unselected, and vice verca. The value
+ argument is the new selected state (i.e., true or false). Do not call
+ setSelected() in itemChange() as this notification is delivered; instead, you
+ can return the new selected state from itemChange().
+
+ \value ItemSelectedHasChanged The item's selected state has changed. The
+ value argument is the new selected state (i.e., true or false). Do not
+ call setSelected() in itemChange() as this notification is delivered. The
+ return value is ignored.
+
+ \value ItemVisibleChange The item's visible state changes. If the item is
+ presently visible, it will become invisible, and vice verca. The value
+ argument is the new visible state (i.e., true or false). Do not call
+ setVisible() in itemChange() as this notification is delivered; instead,
+ you can return the new visible state from itemChange().
+
+ \value ItemVisibleHasChanged The item's visible state has changed. The
+ value argument is the new visible state (i.e., true or false). Do not call
+ setVisible() in itemChange() as this notification is delivered. The return
+ value is ignored.
+
+ \value ItemParentChange The item's parent changes. The value argument is
+ the new parent item (i.e., a QGraphicsItem pointer). Do not call
+ setParentItem() in itemChange() as this notification is delivered;
+ instead, you can return the new parent from itemChange().
+
+ \value ItemParentHasChanged The item's parent has changed. The value
+ argument is the new parent (i.e., a pointer to a QGraphicsItem). Do not
+ call setParentItem() in itemChange() as this notification is
+ delivered. The return value is ignored.
+
+ \value ItemChildAddedChange A child is added to this item. The value
+ argument is the new child item (i.e., a QGraphicsItem pointer). Do not
+ pass this item to any item's setParentItem() function as this notification
+ is delivered. The return value is unused; you cannot adjust anything in
+ this notification. Note that the new child might not be fully constructed
+ when this notification is sent; calling pure virtual functions on
+ the child can lead to a crash.
+
+ \value ItemChildRemovedChange A child is removed from this item. The value
+ argument is the child item that is about to be removed (i.e., a
+ QGraphicsItem pointer). The return value is unused; you cannot adjust
+ anything in this notification.
+
+ \value ItemSceneChange The item is moved to a new scene. This notification is
+ also sent when the item is added to its initial scene, and when it is removed.
+ The item's scene() is the old scene (or 0 if the item has not been added to a
+ scene yet). The value argument is the new scene (i.e., a QGraphicsScene
+ pointer), or a null pointer if the item is removed from a scene. Do not
+ override this change by passing this item to QGraphicsScene::addItem() as this
+ notification is delivered; instead, you can return the new scene from
+ itemChange(). Use this feature with caution; objecting to a scene change can
+ quickly lead to unwanted recursion.
+
+ \value ItemSceneHasChanged The item's scene has changed. The item's scene() is
+ the new scene. This notification is also sent when the item is added to its
+ initial scene, and when it is removed.The value argument is the new scene
+ (i.e., a pointer to a QGraphicsScene). Do not call setScene() in itemChange()
+ as this notification is delivered. The return value is ignored.
+
+ \value ItemCursorChange The item's cursor changes. The value argument is
+ the new cursor (i.e., a QCursor). Do not call setCursor() in itemChange()
+ as this notification is delivered. Instead, you can return a new cursor
+ from itemChange().
+
+ \value ItemCursorHasChanged The item's cursor has changed. The value
+ argument is the new cursor (i.e., a QCursor). Do not call setCursor() as
+ this notification is delivered. The return value is ignored.
+
+ \value ItemToolTipChange The item's tooltip changes. The value argument is
+ the new tooltip (i.e., a QToolTip). Do not call setToolTip() in
+ itemChange() as this notification is delivered. Instead, you can return a
+ new tooltip from itemChange().
+
+ \value ItemToolTipHasChanged The item's tooltip has changed. The value
+ argument is the new tooltip (i.e., a QToolTip). Do not call setToolTip()
+ as this notification is delivered. The return value is ignored.
+
+ \value ItemFlagsChange The item's flags change. The value argument is the
+ new flags (i.e., a quint32). Do not call setFlags() in itemChange() as
+ this notification is delivered. Instead, you can return the new flags from
+ itemChange().
+
+ \value ItemFlagsHaveChanged The item's flags have changed. The value
+ argument is the new flags (i.e., a quint32). Do not call setFlags() in
+ itemChange() as this notification is delivered. The return value is
+ ignored.
+
+ \value ItemZValueChange The item's Z-value changes. The value argument is
+ the new Z-value (i.e., a double). Do not call setZValue() in itemChange()
+ as this notification is delivered. Instead, you can return a new Z-value
+ from itemChange().
+
+ \value ItemZValueHasChanged The item's Z-value has changed. The value
+ argument is the new Z-value (i.e., a double). Do not call setZValue() as
+ this notification is delivered. The return value is ignored.
+
+ \value ItemOpacityChange The item's opacity changes. The value argument is
+ the new opacity (i.e., a double). Do not call setOpacity() in itemChange()
+ as this notification is delivered. Instead, you can return a new opacity
+ from itemChange().
+
+ \value ItemOpacityHasChanged The item's opacity has changed. The value
+ argument is the new opacity (i.e., a double). Do not call setOpacity() as
+ this notification is delivered. The return value is ignored.
+
+ \value ItemScenePositionHasChanged The item's scene position has changed.
+ This notification is sent if the ItemSendsScenePositionChanges flag is
+ enabled, and after the item's scene position has changed (i.e., the
+ position or transformation of the item itself or the position or
+ transformation of any ancestor has changed). The value argument is the
+ new scene position (the same as scenePos()), and QGraphicsItem ignores
+ the return value for this notification (i.e., a read-only notification).
+*/
+
+/*!
+ \enum QGraphicsItem::CacheMode
+ \since 4.4
+
+ This enum describes QGraphicsItem's cache modes. Caching is used to speed
+ up rendering by allocating and rendering to an off-screen pixel buffer,
+ which can be reused when the item requires redrawing. For some paint
+ devices, the cache is stored directly in graphics memory, which makes
+ rendering very quick.
+
+ \value NoCache The default; all item caching is
+ disabled. QGraphicsItem::paint() is called every time the item needs
+ redrawing.
+
+ \value ItemCoordinateCache Caching is enabled for the item's logical
+ (local) coordinate system. QGraphicsItem creates an off-screen pixel
+ buffer with a configurable size / resolution that you can pass to
+ QGraphicsItem::setCacheMode(). Rendering quality will typically degrade,
+ depending on the resolution of the cache and the item transformation. The
+ first time the item is redrawn, it will render itself into the cache, and
+ the cache is then reused for every subsequent expose. The cache is also
+ reused as the item is transformed. To adjust the resolution of the cache,
+ you can call setCacheMode() again.
+
+ \value DeviceCoordinateCache Caching is enabled at the paint device level,
+ in device coordinates. This mode is for items that can move, but are not
+ rotated, scaled or sheared. If the item is transformed directly or
+ indirectly, the cache will be regenerated automatically. Unlike
+ ItemCoordinateCacheMode, DeviceCoordinateCache always renders at maximum
+ quality.
+
+ \sa QGraphicsItem::setCacheMode()
+*/
+
+/*!
+ \enum QGraphicsItem::Extension
+ \internal
+
+ Note: This is provided as a hook to avoid future problems related
+ to adding virtual functions. See also extension(),
+ supportsExtension() and setExtension().
+*/
+
+/*!
+ \enum QGraphicsItem::PanelModality
+ \since 4.6
+
+ This enum specifies the behavior of a modal panel. A modal panel
+ is one that blocks input to other panels. Note that items that
+ are children of a modal panel are not blocked.
+
+ The values are:
+
+ \value NonModal The panel is not modal and does not block input to
+ other panels. This is the default value for panels.
+
+ \value PanelModal The panel is modal to a single item hierarchy
+ and blocks input to its parent pane, all grandparent panels, and
+ all siblings of its parent and grandparent panels.
+
+ \value SceneModal The window is modal to the entire scene and
+ blocks input to all panels.
+
+ \sa QGraphicsItem::setPanelModality(), QGraphicsItem::panelModality(), QGraphicsItem::ItemIsPanel
+*/
+
+#include "qgraphicsitem.h"
+
+#ifndef QT_NO_GRAPHICSVIEW
+
+#include "qgraphicsscene.h"
+#include "qgraphicsscene_p.h"
+#include "qgraphicssceneevent.h"
+#include "qgraphicsview.h"
+#include "qgraphicswidget.h"
+#include "qgraphicsproxywidget.h"
+#include "qgraphicsscenebsptreeindex_p.h"
+#include <QtCore/qbitarray.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qpoint.h>
+#include <QtCore/qstack.h>
+#include <QtCore/qtimer.h>
+#include <QtCore/qvariant.h>
+#include <QtCore/qvarlengtharray.h>
+#include <QtCore/qnumeric.h>
+#include <QtWidgets/qapplication.h>
+#include <QtGui/qbitmap.h>
+#include <QtGui/qpainter.h>
+#include <QtGui/qpainterpath.h>
+#include <QtGui/qpixmapcache.h>
+#include <QtWidgets/qstyleoption.h>
+#include <QtGui/qevent.h>
+#include <QtWidgets/qinputcontext.h>
+#include <QtWidgets/qgraphicseffect.h>
+#ifndef QT_NO_ACCESSIBILITY
+# include "qaccessible.h"
+#endif
+
+#include <private/qgraphicsitem_p.h>
+#include <private/qgraphicswidget_p.h>
+#include <private/qtextcontrol_p.h>
+#include <private/qtextdocumentlayout_p.h>
+#include <private/qtextengine_p.h>
+#include <private/qwidget_p.h>
+#include <private/qapplication_p.h>
+
+#ifdef Q_WS_X11
+#include <private/qt_x11_p.h>
+#include <private/qpixmap_x11_p.h>
+#endif
+
+#include <private/qgesturemanager_p.h>
+
+#include <math.h>
+
+QT_BEGIN_NAMESPACE
+
+static inline void _q_adjustRect(QRect *rect)
+{
+ Q_ASSERT(rect);
+ if (!rect->width())
+ rect->adjust(0, 0, 1, 0);
+ if (!rect->height())
+ rect->adjust(0, 0, 0, 1);
+}
+
+/*
+ ### Move this into QGraphicsItemPrivate
+ */
+class QGraphicsItemCustomDataStore
+{
+public:
+ QMap<const QGraphicsItem *, QMap<int, QVariant> > data;
+};
+Q_GLOBAL_STATIC(QGraphicsItemCustomDataStore, qt_dataStore)
+
+/*!
+ \internal
+
+ Returns a QPainterPath of \a path when stroked with the \a pen.
+ Ignoring dash pattern.
+*/
+static QPainterPath qt_graphicsItem_shapeFromPath(const QPainterPath &path, const QPen &pen)
+{
+ // We unfortunately need this hack as QPainterPathStroker will set a width of 1.0
+ // if we pass a value of 0.0 to QPainterPathStroker::setWidth()
+ const qreal penWidthZero = qreal(0.00000001);
+
+ if (path == QPainterPath())
+ return path;
+ QPainterPathStroker ps;
+ ps.setCapStyle(pen.capStyle());
+ if (pen.widthF() <= 0.0)
+ ps.setWidth(penWidthZero);
+ else
+ ps.setWidth(pen.widthF());
+ ps.setJoinStyle(pen.joinStyle());
+ ps.setMiterLimit(pen.miterLimit());
+ QPainterPath p = ps.createStroke(path);
+ p.addPath(path);
+ return p;
+}
+
+/*!
+ \internal
+
+ Propagates the ancestor flag \a flag with value \a enabled to all this
+ item's children. If \a root is false, the flag is also set on this item
+ (default is true).
+*/
+void QGraphicsItemPrivate::updateAncestorFlag(QGraphicsItem::GraphicsItemFlag childFlag,
+ AncestorFlag flag, bool enabled, bool root)
+{
+ Q_Q(QGraphicsItem);
+ if (root) {
+ // For root items only. This is the item that has either enabled or
+ // disabled \a childFlag, or has been reparented.
+ switch (int(childFlag)) {
+ case -2:
+ flag = AncestorFiltersChildEvents;
+ enabled = q->filtersChildEvents();
+ break;
+ case -1:
+ flag = AncestorHandlesChildEvents;
+ enabled = q->handlesChildEvents();
+ break;
+ case QGraphicsItem::ItemClipsChildrenToShape:
+ flag = AncestorClipsChildren;
+ enabled = flags & QGraphicsItem::ItemClipsChildrenToShape;
+ break;
+ case QGraphicsItem::ItemIgnoresTransformations:
+ flag = AncestorIgnoresTransformations;
+ enabled = flags & QGraphicsItem::ItemIgnoresTransformations;
+ break;
+ default:
+ return;
+ }
+
+ if (parent) {
+ // Inherit the enabled-state from our parents.
+ if ((parent->d_ptr->ancestorFlags & flag)
+ || (int(parent->d_ptr->flags & childFlag) == childFlag)
+ || (childFlag == -1 && parent->d_ptr->handlesChildEvents)
+ || (childFlag == -2 && parent->d_ptr->filtersDescendantEvents)) {
+ enabled = true;
+ ancestorFlags |= flag;
+ } else {
+ ancestorFlags &= ~flag;
+ }
+ } else {
+ // Top-level root items don't have any ancestors, so there are no
+ // ancestor flags either.
+ ancestorFlags = 0;
+ }
+ } else {
+ // Don't set or propagate the ancestor flag if it's already correct.
+ if (((ancestorFlags & flag) && enabled) || (!(ancestorFlags & flag) && !enabled))
+ return;
+
+ // Set the flag.
+ if (enabled)
+ ancestorFlags |= flag;
+ else
+ ancestorFlags &= ~flag;
+
+ // Don't process children if the item has the main flag set on itself.
+ if ((childFlag != -1 && int(flags & childFlag) == childFlag)
+ || (int(childFlag) == -1 && handlesChildEvents)
+ || (int(childFlag) == -2 && filtersDescendantEvents))
+ return;
+ }
+
+ for (int i = 0; i < children.size(); ++i)
+ children.at(i)->d_ptr->updateAncestorFlag(childFlag, flag, enabled, false);
+}
+
+void QGraphicsItemPrivate::updateAncestorFlags()
+{
+ int flags = 0;
+ if (parent) {
+ // Inherit the parent's ancestor flags.
+ QGraphicsItemPrivate *pd = parent->d_ptr.data();
+ flags = pd->ancestorFlags;
+
+ // Add in flags from the parent.
+ if (pd->filtersDescendantEvents)
+ flags |= AncestorFiltersChildEvents;
+ if (pd->handlesChildEvents)
+ flags |= AncestorHandlesChildEvents;
+ if (pd->flags & QGraphicsItem::ItemClipsChildrenToShape)
+ flags |= AncestorClipsChildren;
+ if (pd->flags & QGraphicsItem::ItemIgnoresTransformations)
+ flags |= AncestorIgnoresTransformations;
+ }
+
+ if (ancestorFlags == flags)
+ return; // No change; stop propagation.
+ ancestorFlags = flags;
+
+ // Propagate to children recursively.
+ for (int i = 0; i < children.size(); ++i)
+ children.at(i)->d_ptr->updateAncestorFlags();
+}
+
+/*!
+ \internal
+
+ Propagates item group membership.
+*/
+void QGraphicsItemPrivate::setIsMemberOfGroup(bool enabled)
+{
+ Q_Q(QGraphicsItem);
+ isMemberOfGroup = enabled;
+ if (!qgraphicsitem_cast<QGraphicsItemGroup *>(q)) {
+ foreach (QGraphicsItem *child, children)
+ child->d_func()->setIsMemberOfGroup(enabled);
+ }
+}
+
+/*!
+ \internal
+
+ Maps any item pos properties of \a event to \a item's coordinate system.
+*/
+void QGraphicsItemPrivate::remapItemPos(QEvent *event, QGraphicsItem *item)
+{
+ Q_Q(QGraphicsItem);
+ switch (event->type()) {
+ case QEvent::GraphicsSceneMouseMove:
+ case QEvent::GraphicsSceneMousePress:
+ case QEvent::GraphicsSceneMouseRelease:
+ case QEvent::GraphicsSceneMouseDoubleClick: {
+ QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);
+ mouseEvent->setPos(item->mapFromItem(q, mouseEvent->pos()));
+ mouseEvent->setLastPos(item->mapFromItem(q, mouseEvent->pos()));
+ for (int i = 0x1; i <= 0x10; i <<= 1) {
+ if (mouseEvent->buttons() & i) {
+ Qt::MouseButton button = Qt::MouseButton(i);
+ mouseEvent->setButtonDownPos(button, item->mapFromItem(q, mouseEvent->buttonDownPos(button)));
+ }
+ }
+ break;
+ }
+ case QEvent::GraphicsSceneWheel: {
+ QGraphicsSceneWheelEvent *wheelEvent = static_cast<QGraphicsSceneWheelEvent *>(event);
+ wheelEvent->setPos(item->mapFromItem(q, wheelEvent->pos()));
+ break;
+ }
+ case QEvent::GraphicsSceneContextMenu: {
+ QGraphicsSceneContextMenuEvent *contextEvent = static_cast<QGraphicsSceneContextMenuEvent *>(event);
+ contextEvent->setPos(item->mapFromItem(q, contextEvent->pos()));
+ break;
+ }
+ case QEvent::GraphicsSceneHoverMove: {
+ QGraphicsSceneHoverEvent *hoverEvent = static_cast<QGraphicsSceneHoverEvent *>(event);
+ hoverEvent->setPos(item->mapFromItem(q, hoverEvent->pos()));
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+/*!
+ \internal
+
+ Maps the point \a pos from scene to item coordinates. If \a view is passed and the item
+ is untransformable, this function will correctly map \a pos from the scene using the
+ view's transformation.
+*/
+QPointF QGraphicsItemPrivate::genericMapFromScene(const QPointF &pos,
+ const QWidget *viewport) const
+{
+ Q_Q(const QGraphicsItem);
+ if (!itemIsUntransformable())
+ return q->mapFromScene(pos);
+ QGraphicsView *view = 0;
+ if (viewport)
+ view = qobject_cast<QGraphicsView *>(viewport->parentWidget());
+ if (!view)
+ return q->mapFromScene(pos);
+ // ### More ping pong than needed.
+ return q->deviceTransform(view->viewportTransform()).inverted().map(view->mapFromScene(pos));
+}
+
+/*!
+ \internal
+
+ Combines this item's position and transform onto \a transform.
+
+ If you need to change this function (e.g., adding more transformation
+ modes / options), make sure to change all places marked with COMBINE.
+*/
+void QGraphicsItemPrivate::combineTransformToParent(QTransform *x, const QTransform *viewTransform) const
+{
+ // COMBINE
+ if (viewTransform && itemIsUntransformable()) {
+ *x = q_ptr->deviceTransform(*viewTransform);
+ } else {
+ if (transformData)
+ *x *= transformData->computedFullTransform();
+ if (!pos.isNull())
+ *x *= QTransform::fromTranslate(pos.x(), pos.y());
+ }
+}
+
+/*!
+ \internal
+
+ Combines this item's position and transform onto \a transform.
+
+ If you need to change this function (e.g., adding more transformation
+ modes / options), make sure to change QGraphicsItem::deviceTransform() as
+ well.
+*/
+void QGraphicsItemPrivate::combineTransformFromParent(QTransform *x, const QTransform *viewTransform) const
+{
+ // COMBINE
+ if (viewTransform && itemIsUntransformable()) {
+ *x = q_ptr->deviceTransform(*viewTransform);
+ } else {
+ x->translate(pos.x(), pos.y());
+ if (transformData)
+ *x = transformData->computedFullTransform(x);
+ }
+}
+
+void QGraphicsItemPrivate::updateSceneTransformFromParent()
+{
+ if (parent) {
+ Q_ASSERT(!parent->d_ptr->dirtySceneTransform);
+ if (parent->d_ptr->sceneTransformTranslateOnly) {
+ sceneTransform = QTransform::fromTranslate(parent->d_ptr->sceneTransform.dx() + pos.x(),
+ parent->d_ptr->sceneTransform.dy() + pos.y());
+ } else {
+ sceneTransform = parent->d_ptr->sceneTransform;
+ sceneTransform.translate(pos.x(), pos.y());
+ }
+ if (transformData) {
+ sceneTransform = transformData->computedFullTransform(&sceneTransform);
+ sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate);
+ } else {
+ sceneTransformTranslateOnly = parent->d_ptr->sceneTransformTranslateOnly;
+ }
+ } else if (!transformData) {
+ sceneTransform = QTransform::fromTranslate(pos.x(), pos.y());
+ sceneTransformTranslateOnly = 1;
+ } else if (transformData->onlyTransform) {
+ sceneTransform = transformData->transform;
+ if (!pos.isNull())
+ sceneTransform *= QTransform::fromTranslate(pos.x(), pos.y());
+ sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate);
+ } else if (pos.isNull()) {
+ sceneTransform = transformData->computedFullTransform();
+ sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate);
+ } else {
+ sceneTransform = QTransform::fromTranslate(pos.x(), pos.y());
+ sceneTransform = transformData->computedFullTransform(&sceneTransform);
+ sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate);
+ }
+ dirtySceneTransform = 0;
+}
+
+/*!
+ \internal
+
+ This helper function helped us add input method query support in
+ Qt 4.4.1 without having to reimplement the inputMethodQuery()
+ function in QGraphicsProxyWidget. ### Qt 5: Remove. We cannot
+ remove it in 4.5+ even if we do reimplement the function properly,
+ because apps compiled with 4.4 will not be able to call the
+ reimplementation.
+*/
+QVariant QGraphicsItemPrivate::inputMethodQueryHelper(Qt::InputMethodQuery query) const
+{
+ Q_UNUSED(query);
+ return QVariant();
+}
+
+/*!
+ \internal
+
+ Make sure not to trigger any pure virtual function calls (e.g.,
+ prepareGeometryChange) if the item is in its destructor, i.e.
+ inDestructor is 1.
+*/
+void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const QVariant *newParentVariant,
+ const QVariant *thisPointerVariant)
+{
+ Q_Q(QGraphicsItem);
+ if (newParent == parent)
+ return;
+
+ if (isWidget)
+ static_cast<QGraphicsWidgetPrivate *>(this)->fixFocusChainBeforeReparenting((newParent &&
+ newParent->isWidget()) ? static_cast<QGraphicsWidget *>(newParent) : 0,
+ scene);
+ if (scene) {
+ // Deliver the change to the index
+ if (scene->d_func()->indexMethod != QGraphicsScene::NoIndex)
+ scene->d_func()->index->itemChange(q, QGraphicsItem::ItemParentChange, newParent);
+
+ // Disable scene pos notifications for old ancestors
+ if (scenePosDescendants || (flags & QGraphicsItem::ItemSendsScenePositionChanges))
+ scene->d_func()->setScenePosItemEnabled(q, false);
+ }
+
+ if (subFocusItem && parent) {
+ // Make sure none of the old parents point to this guy.
+ subFocusItem->d_ptr->clearSubFocus(parent);
+ }
+
+ // We anticipate geometry changes. If the item is deleted, it will be
+ // removed from the index at a later stage, and the whole scene will be
+ // updated.
+ if (!inDestructor)
+ q_ptr->prepareGeometryChange();
+
+ if (parent) {
+ // Remove from current parent
+ parent->d_ptr->removeChild(q);
+ if (thisPointerVariant)
+ parent->itemChange(QGraphicsItem::ItemChildRemovedChange, *thisPointerVariant);
+ }
+
+ // Update toplevelitem list. If this item is being deleted, its parent
+ // will be 0 but we don't want to register/unregister it in the TLI list.
+ if (scene && !inDestructor) {
+ if (parent && !newParent) {
+ scene->d_func()->registerTopLevelItem(q);
+ } else if (!parent && newParent) {
+ scene->d_func()->unregisterTopLevelItem(q);
+ }
+ }
+
+ // Ensure any last parent focus scope does not point to this item or any of
+ // its descendents.
+ QGraphicsItem *p = parent;
+ QGraphicsItem *parentFocusScopeItem = 0;
+ while (p) {
+ if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) {
+ // If this item's focus scope's focus scope item points
+ // to this item or a descendent, then clear it.
+ QGraphicsItem *fsi = p->d_ptr->focusScopeItem;
+ if (q_ptr == fsi || q_ptr->isAncestorOf(fsi)) {
+ parentFocusScopeItem = fsi;
+ p->d_ptr->focusScopeItem = 0;
+ fsi->d_ptr->focusScopeItemChange(false);
+ }
+ break;
+ }
+ p = p->d_ptr->parent;
+ }
+
+ // Update graphics effect optimization flag
+ if (newParent && (graphicsEffect || mayHaveChildWithGraphicsEffect))
+ newParent->d_ptr->updateChildWithGraphicsEffectFlagRecursively();
+
+ // Update focus scope item ptr in new scope.
+ QGraphicsItem *newFocusScopeItem = subFocusItem ? subFocusItem : parentFocusScopeItem;
+ if (newFocusScopeItem && newParent) {
+ if (subFocusItem) {
+ // Find the subFocusItem's topmost focus scope.
+ QGraphicsItem *ancestorScope = 0;
+ QGraphicsItem *p = subFocusItem->d_ptr->parent;
+ while (p) {
+ if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope)
+ ancestorScope = p;
+ if (p->d_ptr->flags & QGraphicsItem::ItemIsPanel)
+ break;
+ p = p->d_ptr->parent;
+ }
+ if (ancestorScope)
+ newFocusScopeItem = ancestorScope;
+ }
+
+ QGraphicsItem *p = newParent;
+ while (p) {
+ if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) {
+ p->d_ptr->focusScopeItem = newFocusScopeItem;
+ newFocusScopeItem->d_ptr->focusScopeItemChange(true);
+ // Ensure the new item is no longer the subFocusItem. The
+ // only way to set focus on a child of a focus scope is
+ // by setting focus on the scope itself.
+ if (subFocusItem && !p->focusItem())
+ subFocusItem->d_ptr->clearSubFocus();
+ break;
+ }
+ p = p->d_ptr->parent;
+ }
+ }
+
+ // Resolve depth.
+ invalidateDepthRecursively();
+
+ if ((parent = newParent)) {
+ if (parent->d_func()->scene && parent->d_func()->scene != scene) {
+ // Move this item to its new parent's scene
+ parent->d_func()->scene->addItem(q);
+ } else if (!parent->d_func()->scene && scene) {
+ // Remove this item from its former scene
+ scene->removeItem(q);
+ }
+
+ parent->d_ptr->addChild(q);
+ if (thisPointerVariant)
+ parent->itemChange(QGraphicsItem::ItemChildAddedChange, *thisPointerVariant);
+ if (scene) {
+ // Re-enable scene pos notifications for new ancestors
+ if (scenePosDescendants || (flags & QGraphicsItem::ItemSendsScenePositionChanges))
+ scene->d_func()->setScenePosItemEnabled(q, true);
+ }
+
+ // Propagate dirty flags to the new parent
+ markParentDirty(/*updateBoundingRect=*/true);
+
+ // Inherit ancestor flags from the new parent.
+ updateAncestorFlags();
+
+ // Update item visible / enabled.
+ if (parent->d_ptr->visible != visible) {
+ if (!parent->d_ptr->visible || !explicitlyHidden)
+ setVisibleHelper(parent->d_ptr->visible, /* explicit = */ false, /* update = */ false);
+ }
+ if (parent->isEnabled() != enabled) {
+ if (!parent->d_ptr->enabled || !explicitlyDisabled)
+ setEnabledHelper(parent->d_ptr->enabled, /* explicit = */ false, /* update = */ false);
+ }
+
+ // Auto-activate if visible and the parent is active.
+ if (visible && parent->isActive())
+ q->setActive(true);
+ } else {
+ // Inherit ancestor flags from the new parent.
+ updateAncestorFlags();
+
+ if (!inDestructor) {
+ // Update item visible / enabled.
+ if (!visible && !explicitlyHidden)
+ setVisibleHelper(true, /* explicit = */ false);
+ if (!enabled && !explicitlyDisabled)
+ setEnabledHelper(true, /* explicit = */ false);
+ }
+ }
+
+ dirtySceneTransform = 1;
+ if (!inDestructor && (transformData || (newParent && newParent->d_ptr->transformData)))
+ transformChanged();
+
+ // Restore the sub focus chain.
+ if (subFocusItem) {
+ subFocusItem->d_ptr->setSubFocus(newParent);
+ if (parent && parent->isActive())
+ subFocusItem->setFocus();
+ }
+
+ // Deliver post-change notification
+ if (newParentVariant)
+ q->itemChange(QGraphicsItem::ItemParentHasChanged, *newParentVariant);
+
+ if (isObject)
+ emit static_cast<QGraphicsObject *>(q)->parentChanged();
+}
+
+/*!
+ \internal
+
+ Returns the bounding rect of this item's children (excluding itself).
+*/
+void QGraphicsItemPrivate::childrenBoundingRectHelper(QTransform *x, QRectF *rect, QGraphicsItem *topMostEffectItem)
+{
+ Q_Q(QGraphicsItem);
+
+ QRectF childrenRect;
+ QRectF *result = rect;
+ rect = &childrenRect;
+ const bool setTopMostEffectItem = !topMostEffectItem;
+
+ for (int i = 0; i < children.size(); ++i) {
+ QGraphicsItem *child = children.at(i);
+ QGraphicsItemPrivate *childd = child->d_ptr.data();
+ if (setTopMostEffectItem)
+ topMostEffectItem = child;
+ bool hasPos = !childd->pos.isNull();
+ if (hasPos || childd->transformData) {
+ // COMBINE
+ QTransform matrix = childd->transformToParent();
+ if (x)
+ matrix *= *x;
+ *rect |= matrix.mapRect(child->d_ptr->effectiveBoundingRect(topMostEffectItem));
+ if (!childd->children.isEmpty())
+ childd->childrenBoundingRectHelper(&matrix, rect, topMostEffectItem);
+ } else {
+ if (x)
+ *rect |= x->mapRect(child->d_ptr->effectiveBoundingRect(topMostEffectItem));
+ else
+ *rect |= child->d_ptr->effectiveBoundingRect(topMostEffectItem);
+ if (!childd->children.isEmpty())
+ childd->childrenBoundingRectHelper(x, rect, topMostEffectItem);
+ }
+ }
+
+ if (flags & QGraphicsItem::ItemClipsChildrenToShape){
+ if (x)
+ *rect &= x->mapRect(q->boundingRect());
+ else
+ *rect &= q->boundingRect();
+ }
+
+ *result |= *rect;
+}
+
+void QGraphicsItemPrivate::initStyleOption(QStyleOptionGraphicsItem *option, const QTransform &worldTransform,
+ const QRegion &exposedRegion, bool allItems) const
+{
+ Q_ASSERT(option);
+ Q_Q(const QGraphicsItem);
+
+ // Initialize standard QStyleOption values.
+ const QRectF brect = q->boundingRect();
+ option->state = QStyle::State_None;
+ option->rect = brect.toRect();
+ option->levelOfDetail = 1;
+ option->exposedRect = brect;
+ if (selected)
+ option->state |= QStyle::State_Selected;
+ if (enabled)
+ option->state |= QStyle::State_Enabled;
+ if (q->hasFocus())
+ option->state |= QStyle::State_HasFocus;
+ if (scene) {
+ if (scene->d_func()->hoverItems.contains(q_ptr))
+ option->state |= QStyle::State_MouseOver;
+ if (q == scene->mouseGrabberItem())
+ option->state |= QStyle::State_Sunken;
+ }
+
+ if (!(flags & QGraphicsItem::ItemUsesExtendedStyleOption))
+ return;
+
+ // Initialize QStyleOptionGraphicsItem specific values (matrix, exposedRect).
+ option->matrix = worldTransform.toAffine(); //### discards perspective
+
+ if (!allItems) {
+ // Determine the item's exposed area
+ option->exposedRect = QRectF();
+ const QTransform reverseMap = worldTransform.inverted();
+ const QVector<QRect> exposedRects(exposedRegion.rects());
+ for (int i = 0; i < exposedRects.size(); ++i) {
+ option->exposedRect |= reverseMap.mapRect(QRectF(exposedRects.at(i)));
+ if (option->exposedRect.contains(brect))
+ break;
+ }
+ option->exposedRect &= brect;
+ }
+}
+
+/*!
+ \internal
+
+ Empty all cached pixmaps from the pixmap cache.
+*/
+void QGraphicsItemCache::purge()
+{
+ QPixmapCache::remove(key);
+ key = QPixmapCache::Key();
+ QMutableMapIterator<QPaintDevice *, DeviceData> it(deviceData);
+ while (it.hasNext()) {
+ DeviceData &data = it.next().value();
+ QPixmapCache::remove(data.key);
+ data.cacheIndent = QPoint();
+ }
+ deviceData.clear();
+ allExposed = true;
+ exposed.clear();
+}
+
+/*!
+ Constructs a QGraphicsItem with the given \a parent item.
+ It does not modify the parent object returned by QObject::parent().
+
+ If \a parent is 0, you can add the item to a scene by calling
+ QGraphicsScene::addItem(). The item will then become a top-level item.
+
+ \sa QGraphicsScene::addItem(), setParentItem()
+*/
+QGraphicsItem::QGraphicsItem(QGraphicsItem *parent
+#ifndef Q_QDOC
+ // obsolete argument
+ , QGraphicsScene *scene
+#endif
+ )
+ : d_ptr(new QGraphicsItemPrivate)
+{
+ d_ptr->q_ptr = this;
+ setParentItem(parent);
+
+ if (scene && parent && parent->scene() != scene) {
+ qWarning("QGraphicsItem::QGraphicsItem: ignoring scene (%p), which is"
+ " different from parent's scene (%p)",
+ scene, parent->scene());
+ return;
+ }
+ if (scene && !parent)
+ scene->addItem(this);
+}
+
+/*!
+ \internal
+*/
+QGraphicsItem::QGraphicsItem(QGraphicsItemPrivate &dd, QGraphicsItem *parent,
+ QGraphicsScene *scene)
+ : d_ptr(&dd)
+{
+ d_ptr->q_ptr = this;
+ setParentItem(parent);
+
+ if (scene && parent && parent->scene() != scene) {
+ qWarning("QGraphicsItem::QGraphicsItem: ignoring scene (%p), which is"
+ " different from parent's scene (%p)",
+ scene, parent->scene());
+ return;
+ }
+ if (scene && !parent)
+ scene->addItem(this);
+}
+
+/*!
+ Destroys the QGraphicsItem and all its children. If this item is currently
+ associated with a scene, the item will be removed from the scene before it
+ is deleted.
+
+ \note It is more efficient to remove the item from the QGraphicsScene before
+ destroying the item.
+*/
+QGraphicsItem::~QGraphicsItem()
+{
+ if (d_ptr->isObject) {
+ QGraphicsObject *o = static_cast<QGraphicsObject *>(this);
+ QObjectPrivate *p = QObjectPrivate::get(o);
+ p->wasDeleted = true;
+ if (p->declarativeData) {
+ QAbstractDeclarativeData::destroyed(p->declarativeData, o);
+ p->declarativeData = 0;
+ }
+ }
+
+ d_ptr->inDestructor = 1;
+ d_ptr->removeExtraItemCache();
+
+#ifndef QT_NO_GESTURES
+ if (d_ptr->isObject && !d_ptr->gestureContext.isEmpty()) {
+ QGraphicsObject *o = static_cast<QGraphicsObject *>(this);
+ if (QGestureManager *manager = QGestureManager::instance()) {
+ foreach (Qt::GestureType type, d_ptr->gestureContext.keys())
+ manager->cleanupCachedGestures(o, type);
+ }
+ }
+#endif
+
+ clearFocus();
+
+ // Update focus scope item ptr.
+ QGraphicsItem *p = d_ptr->parent;
+ while (p) {
+ if (p->flags() & ItemIsFocusScope) {
+ if (p->d_ptr->focusScopeItem == this)
+ p->d_ptr->focusScopeItem = 0;
+ break;
+ }
+ p = p->d_ptr->parent;
+ }
+
+ if (!d_ptr->children.isEmpty()) {
+ while (!d_ptr->children.isEmpty())
+ delete d_ptr->children.first();
+ Q_ASSERT(d_ptr->children.isEmpty());
+ }
+
+ if (d_ptr->scene) {
+ d_ptr->scene->d_func()->removeItemHelper(this);
+ } else {
+ d_ptr->resetFocusProxy();
+ setParentItem(0);
+ }
+
+#ifndef QT_NO_GRAPHICSEFFECT
+ delete d_ptr->graphicsEffect;
+#endif //QT_NO_GRAPHICSEFFECT
+ if (d_ptr->transformData) {
+ for(int i = 0; i < d_ptr->transformData->graphicsTransforms.size(); ++i) {
+ QGraphicsTransform *t = d_ptr->transformData->graphicsTransforms.at(i);
+ static_cast<QGraphicsTransformPrivate *>(t->d_ptr.data())->item = 0;
+ delete t;
+ }
+ }
+ delete d_ptr->transformData;
+
+ if (QGraphicsItemCustomDataStore *dataStore = qt_dataStore())
+ dataStore->data.remove(this);
+}
+
+/*!
+ Returns the current scene for the item, or 0 if the item is not stored in
+ a scene.
+
+ To add or move an item to a scene, call QGraphicsScene::addItem().
+*/
+QGraphicsScene *QGraphicsItem::scene() const
+{
+ return d_ptr->scene;
+}
+
+/*!
+ Returns a pointer to this item's item group, or 0 if this item is not
+ member of a group.
+
+ \sa QGraphicsItemGroup, QGraphicsScene::createItemGroup()
+*/
+QGraphicsItemGroup *QGraphicsItem::group() const
+{
+ if (!d_ptr->isMemberOfGroup)
+ return 0;
+ QGraphicsItem *parent = const_cast<QGraphicsItem *>(this);
+ while ((parent = parent->d_ptr->parent)) {
+ if (QGraphicsItemGroup *group = qgraphicsitem_cast<QGraphicsItemGroup *>(parent))
+ return group;
+ }
+ // Unreachable; if d_ptr->isMemberOfGroup is != 0, then one parent of this
+ // item is a group item.
+ return 0;
+}
+
+/*!
+ Adds this item to the item group \a group. If \a group is 0, this item is
+ removed from any current group and added as a child of the previous
+ group's parent.
+
+ \sa group(), QGraphicsScene::createItemGroup()
+*/
+void QGraphicsItem::setGroup(QGraphicsItemGroup *group)
+{
+ if (!group) {
+ if (QGraphicsItemGroup *group = this->group())
+ group->removeFromGroup(this);
+ } else {
+ group->addToGroup(this);
+ }
+}
+
+/*!
+ Returns a pointer to this item's parent item. If this item does not have a
+ parent, 0 is returned.
+
+ \sa setParentItem(), childItems()
+*/
+QGraphicsItem *QGraphicsItem::parentItem() const
+{
+ return d_ptr->parent;
+}
+
+/*!
+ Returns this item's top-level item. The top-level item is the item's
+ topmost ancestor item whose parent is 0. If an item has no parent, its own
+ pointer is returned (i.e., a top-level item is its own top-level item).
+
+ \sa parentItem()
+*/
+QGraphicsItem *QGraphicsItem::topLevelItem() const
+{
+ QGraphicsItem *parent = const_cast<QGraphicsItem *>(this);
+ while (QGraphicsItem *grandPa = parent->parentItem())
+ parent = grandPa;
+ return parent;
+}
+
+/*!
+ \since 4.6
+
+ Returns a pointer to the item's parent, cast to a QGraphicsObject. returns 0 if the parent item
+ is not a QGraphicsObject.
+
+ \sa parentItem(), childItems()
+*/
+QGraphicsObject *QGraphicsItem::parentObject() const
+{
+ QGraphicsItem *p = d_ptr->parent;
+ return (p && p->d_ptr->isObject) ? static_cast<QGraphicsObject *>(p) : 0;
+}
+
+/*!
+ \since 4.4
+
+ Returns a pointer to the item's parent widget. The item's parent widget is
+ the closest parent item that is a widget.
+
+ \sa parentItem(), childItems()
+*/
+QGraphicsWidget *QGraphicsItem::parentWidget() const
+{
+ QGraphicsItem *p = parentItem();
+ while (p && !p->isWidget())
+ p = p->parentItem();
+ return (p && p->isWidget()) ? static_cast<QGraphicsWidget *>(p) : 0;
+}
+
+/*!
+ \since 4.4
+
+ Returns a pointer to the item's top level widget (i.e., the item's
+ ancestor whose parent is 0, or whose parent is not a widget), or 0 if this
+ item does not have a top level widget. If the item is its own top level
+ widget, this function returns a pointer to the item itself.
+*/
+QGraphicsWidget *QGraphicsItem::topLevelWidget() const
+{
+ if (const QGraphicsWidget *p = parentWidget())
+ return p->topLevelWidget();
+ return isWidget() ? static_cast<QGraphicsWidget *>(const_cast<QGraphicsItem *>(this)) : 0;
+}
+
+/*!
+ \since 4.4
+
+ Returns the item's window, or 0 if this item does not have a window. If
+ the item is a window, it will return itself. Otherwise it will return the
+ closest ancestor that is a window.
+
+ \sa QGraphicsWidget::isWindow()
+*/
+QGraphicsWidget *QGraphicsItem::window() const
+{
+ QGraphicsItem *p = panel();
+ if (p && p->isWindow())
+ return static_cast<QGraphicsWidget *>(p);
+ return 0;
+}
+
+/*!
+ \since 4.6
+
+ Returns the item's panel, or 0 if this item does not have a panel. If the
+ item is a panel, it will return itself. Otherwise it will return the
+ closest ancestor that is a panel.
+
+ \sa isPanel(), ItemIsPanel
+*/
+QGraphicsItem *QGraphicsItem::panel() const
+{
+ if (d_ptr->flags & ItemIsPanel)
+ return const_cast<QGraphicsItem *>(this);
+ return d_ptr->parent ? d_ptr->parent->panel() : 0;
+}
+
+/*!
+ \since 4.6
+
+ Return the graphics item cast to a QGraphicsObject, if the class is actually a
+ graphics object, 0 otherwise.
+*/
+QGraphicsObject *QGraphicsItem::toGraphicsObject()
+{
+ return d_ptr->isObject ? static_cast<QGraphicsObject *>(this) : 0;
+}
+
+/*!
+ \since 4.6
+
+ Return the graphics item cast to a QGraphicsObject, if the class is actually a
+ graphics object, 0 otherwise.
+*/
+const QGraphicsObject *QGraphicsItem::toGraphicsObject() const
+{
+ return d_ptr->isObject ? static_cast<const QGraphicsObject *>(this) : 0;
+}
+
+/*!
+ Sets this item's parent item to \a newParent. If this item already
+ has a parent, it is first removed from the previous parent. If \a
+ newParent is 0, this item will become a top-level item.
+
+ Note that this implicitly adds this graphics item to the scene of
+ the parent. You should not \l{QGraphicsScene::addItem()}{add} the
+ item to the scene yourself.
+
+ Calling this function on an item that is an ancestor of \a newParent
+ have undefined behaviour.
+
+ \sa parentItem(), childItems()
+*/
+void QGraphicsItem::setParentItem(QGraphicsItem *newParent)
+{
+ if (newParent == this) {
+ qWarning("QGraphicsItem::setParentItem: cannot assign %p as a parent of itself", this);
+ return;
+ }
+ if (newParent == d_ptr->parent)
+ return;
+
+ const QVariant newParentVariant(itemChange(QGraphicsItem::ItemParentChange,
+ QVariant::fromValue<QGraphicsItem *>(newParent)));
+ newParent = qvariant_cast<QGraphicsItem *>(newParentVariant);
+ if (newParent == d_ptr->parent)
+ return;
+
+ const QVariant thisPointerVariant(QVariant::fromValue<QGraphicsItem *>(this));
+ d_ptr->setParentItemHelper(newParent, &newParentVariant, &thisPointerVariant);
+}
+
+/*!
+ \obsolete
+
+ Use childItems() instead.
+
+ \sa setParentItem()
+*/
+QList<QGraphicsItem *> QGraphicsItem::children() const
+{
+ return childItems();
+}
+
+/*!
+ \since 4.4
+
+ Returns a list of this item's children.
+
+ The items are sorted by stacking order. This takes into account both the
+ items' insertion order and their Z-values.
+
+ \sa setParentItem(), zValue(), {QGraphicsItem#Sorting}{Sorting}
+*/
+QList<QGraphicsItem *> QGraphicsItem::childItems() const
+{
+ const_cast<QGraphicsItem *>(this)->d_ptr->ensureSortedChildren();
+ return d_ptr->children;
+}
+
+/*!
+ \since 4.4
+ Returns true if this item is a widget (i.e., QGraphicsWidget); otherwise,
+ returns false.
+*/
+bool QGraphicsItem::isWidget() const
+{
+ return d_ptr->isWidget;
+}
+
+/*!
+ \since 4.4
+ Returns true if the item is a QGraphicsWidget window, otherwise returns
+ false.
+
+ \sa QGraphicsWidget::windowFlags()
+*/
+bool QGraphicsItem::isWindow() const
+{
+ return d_ptr->isWidget && (static_cast<const QGraphicsWidget *>(this)->windowType() & Qt::Window);
+}
+
+/*!
+ \since 4.6
+ Returns true if the item is a panel; otherwise returns false.
+
+ \sa QGraphicsItem::panel(), ItemIsPanel
+*/
+bool QGraphicsItem::isPanel() const
+{
+ return d_ptr->flags & ItemIsPanel;
+}
+
+/*!
+ Returns this item's flags. The flags describe what configurable features
+ of the item are enabled and not. For example, if the flags include
+ ItemIsFocusable, the item can accept input focus.
+
+ By default, no flags are enabled.
+
+ \sa setFlags(), setFlag()
+*/
+QGraphicsItem::GraphicsItemFlags QGraphicsItem::flags() const
+{
+ return GraphicsItemFlags(d_ptr->flags);
+}
+
+/*!
+ If \a enabled is true, the item flag \a flag is enabled; otherwise, it is
+ disabled.
+
+ \sa flags(), setFlags()
+*/
+void QGraphicsItem::setFlag(GraphicsItemFlag flag, bool enabled)
+{
+ if (enabled)
+ setFlags(GraphicsItemFlags(d_ptr->flags) | flag);
+ else
+ setFlags(GraphicsItemFlags(d_ptr->flags) & ~flag);
+}
+
+/*!
+ \internal
+
+ Sets the flag \a flag on \a item and all its children, to \a enabled.
+*/
+static void _q_qgraphicsItemSetFlag(QGraphicsItem *item, QGraphicsItem::GraphicsItemFlag flag,
+ bool enabled)
+{
+ if (item->flags() & flag) {
+ // If this item already has the correct flag set, we don't have to
+ // propagate it.
+ return;
+ }
+ item->setFlag(flag, enabled);
+ foreach (QGraphicsItem *child, item->children())
+ _q_qgraphicsItemSetFlag(child, flag, enabled);
+}
+
+/*!
+ Sets the item flags to \a flags. All flags in \a flags are enabled; all
+ flags not in \a flags are disabled.
+
+ If the item had focus and \a flags does not enable ItemIsFocusable, the
+ item loses focus as a result of calling this function. Similarly, if the
+ item was selected, and \a flags does not enabled ItemIsSelectable, the
+ item is automatically unselected.
+
+ By default, no flags are enabled. (QGraphicsWidget enables the
+ ItemSendsGeometryChanges flag by default in order to track position
+ changes.)
+
+ \sa flags(), setFlag()
+*/
+void QGraphicsItem::setFlags(GraphicsItemFlags flags)
+{
+ // Notify change and check for adjustment.
+ if (quint32(d_ptr->flags) == quint32(flags))
+ return;
+ flags = GraphicsItemFlags(itemChange(ItemFlagsChange, quint32(flags)).toUInt());
+ if (quint32(d_ptr->flags) == quint32(flags))
+ return;
+ if (d_ptr->scene && d_ptr->scene->d_func()->indexMethod != QGraphicsScene::NoIndex)
+ d_ptr->scene->d_func()->index->itemChange(this, ItemFlagsChange, &flags);
+
+ // Flags that alter the geometry of the item (or its children).
+ const quint32 geomChangeFlagsMask = (ItemClipsChildrenToShape | ItemClipsToShape | ItemIgnoresTransformations | ItemIsSelectable);
+ bool fullUpdate = (quint32(flags) & geomChangeFlagsMask) != (d_ptr->flags & geomChangeFlagsMask);
+ if (fullUpdate)
+ d_ptr->updatePaintedViewBoundingRects(/*children=*/true);
+
+ // Keep the old flags to compare the diff.
+ GraphicsItemFlags oldFlags = GraphicsItemFlags(d_ptr->flags);
+
+ // Update flags.
+ d_ptr->flags = flags;
+
+ if (!(d_ptr->flags & ItemIsFocusable) && hasFocus()) {
+ // Clear focus on the item if it has focus when the focusable flag
+ // is unset.
+ clearFocus();
+ }
+
+ if (!(d_ptr->flags & ItemIsSelectable) && isSelected()) {
+ // Unselect the item if it is selected when the selectable flag is
+ // unset.
+ setSelected(false);
+ }
+
+ if ((flags & ItemClipsChildrenToShape) != (oldFlags & ItemClipsChildrenToShape)) {
+ // Item children clipping changes. Propagate the ancestor flag to
+ // all children.
+ d_ptr->updateAncestorFlag(ItemClipsChildrenToShape);
+ // The childrenBoundingRect is clipped to the boundingRect in case of ItemClipsChildrenToShape,
+ // which means we have to invalidate the cached childrenBoundingRect whenever this flag changes.
+ d_ptr->dirtyChildrenBoundingRect = 1;
+ d_ptr->markParentDirty(true);
+ }
+
+ if ((flags & ItemIgnoresTransformations) != (oldFlags & ItemIgnoresTransformations)) {
+ // Item children clipping changes. Propagate the ancestor flag to
+ // all children.
+ d_ptr->updateAncestorFlag(ItemIgnoresTransformations);
+ }
+
+ if ((flags & ItemNegativeZStacksBehindParent) != (oldFlags & ItemNegativeZStacksBehindParent)) {
+ // NB! We change the flags directly here, so we must also update d_ptr->flags.
+ // Note that this has do be done before the ItemStacksBehindParent check
+ // below; otherwise we will loose the change.
+
+ // Update stack-behind.
+ if (d_ptr->z < qreal(0.0))
+ flags |= ItemStacksBehindParent;
+ else
+ flags &= ~ItemStacksBehindParent;
+ d_ptr->flags = flags;
+ }
+
+ if ((flags & ItemStacksBehindParent) != (oldFlags & ItemStacksBehindParent)) {
+ // NB! This check has to come after the ItemNegativeZStacksBehindParent
+ // check above. Be careful.
+
+ // Ensure child item sorting is up to date when toggling this flag.
+ if (d_ptr->parent)
+ d_ptr->parent->d_ptr->needSortChildren = 1;
+ else if (d_ptr->scene)
+ d_ptr->scene->d_func()->needSortTopLevelItems = 1;
+ }
+
+ if ((flags & ItemAcceptsInputMethod) != (oldFlags & ItemAcceptsInputMethod)) {
+ // Update input method sensitivity in any views.
+ if (d_ptr->scene)
+ d_ptr->scene->d_func()->updateInputMethodSensitivityInViews();
+ }
+
+
+ if ((d_ptr->panelModality != NonModal)
+ && d_ptr->scene
+ && (flags & ItemIsPanel) != (oldFlags & ItemIsPanel)) {
+ // update the panel's modal state
+ if (flags & ItemIsPanel)
+ d_ptr->scene->d_func()->enterModal(this);
+ else
+ d_ptr->scene->d_func()->leaveModal(this);
+ }
+
+ if (d_ptr->scene) {
+ if ((flags & ItemSendsScenePositionChanges) != (oldFlags & ItemSendsScenePositionChanges)) {
+ if (flags & ItemSendsScenePositionChanges)
+ d_ptr->scene->d_func()->registerScenePosItem(this);
+ else
+ d_ptr->scene->d_func()->unregisterScenePosItem(this);
+ }
+ d_ptr->scene->d_func()->markDirty(this, QRectF(), /*invalidateChildren=*/true);
+ }
+
+ // Notify change.
+ itemChange(ItemFlagsHaveChanged, quint32(flags));
+}
+
+/*!
+ \since 4.4
+ Returns the cache mode for this item. The default mode is NoCache (i.e.,
+ cache is disabled and all painting is immediate).
+
+ \sa setCacheMode()
+*/
+QGraphicsItem::CacheMode QGraphicsItem::cacheMode() const
+{
+ return QGraphicsItem::CacheMode(d_ptr->cacheMode);
+}
+
+/*!
+ \since 4.4
+ Sets the item's cache mode to \a mode.
+
+ The optional \a logicalCacheSize argument is used only by
+ ItemCoordinateCache mode, and describes the resolution of the cache
+ buffer; if \a logicalCacheSize is (100, 100), QGraphicsItem will fit the
+ item into 100x100 pixels in graphics memory, regardless of the logical
+ size of the item itself. By default QGraphicsItem uses the size of
+ boundingRect(). For all other cache modes than ItemCoordinateCache, \a
+ logicalCacheSize is ignored.
+
+ Caching can speed up rendering if your item spends a significant time
+ redrawing itself. In some cases the cache can also slow down rendering, in
+ particular when the item spends less time redrawing than QGraphicsItem
+ spends redrawing from the cache. When enabled, the item's paint() function
+ will be called only once for each call to update(); for any subsequent
+ repaint requests, the Graphics View framework will redraw from the
+ cache. This approach works particularly well with QGLWidget, which stores
+ all the cache as OpenGL textures.
+
+ Be aware that QPixmapCache's cache limit may need to be changed to obtain
+ optimal performance.
+
+ You can read more about the different cache modes in the CacheMode
+ documentation.
+
+ \sa CacheMode, QPixmapCache::setCacheLimit()
+*/
+void QGraphicsItem::setCacheMode(CacheMode mode, const QSize &logicalCacheSize)
+{
+ CacheMode lastMode = CacheMode(d_ptr->cacheMode);
+ d_ptr->cacheMode = mode;
+ bool noVisualChange = (mode == NoCache && lastMode == NoCache)
+ || (mode == NoCache && lastMode == DeviceCoordinateCache)
+ || (mode == DeviceCoordinateCache && lastMode == NoCache)
+ || (mode == DeviceCoordinateCache && lastMode == DeviceCoordinateCache);
+ if (mode == NoCache) {
+ d_ptr->removeExtraItemCache();
+ } else {
+ QGraphicsItemCache *cache = d_ptr->extraItemCache();
+
+ // Reset old cache
+ cache->purge();
+
+ if (mode == ItemCoordinateCache) {
+ if (lastMode == mode && cache->fixedSize == logicalCacheSize)
+ noVisualChange = true;
+ cache->fixedSize = logicalCacheSize;
+ }
+ }
+ if (!noVisualChange)
+ update();
+}
+
+/*!
+ \since 4.6
+
+ Returns the modality for this item.
+*/
+QGraphicsItem::PanelModality QGraphicsItem::panelModality() const
+{
+ return d_ptr->panelModality;
+}
+
+/*!
+ \since 4.6
+
+ Sets the modality for this item to \a panelModality.
+
+ Changing the modality of a visible item takes effect immediately.
+*/
+void QGraphicsItem::setPanelModality(PanelModality panelModality)
+{
+ if (d_ptr->panelModality == panelModality)
+ return;
+
+ PanelModality previousModality = d_ptr->panelModality;
+ bool enterLeaveModal = (isPanel() && d_ptr->scene && isVisible());
+ if (enterLeaveModal && panelModality == NonModal)
+ d_ptr->scene->d_func()->leaveModal(this);
+ d_ptr->panelModality = panelModality;
+ if (enterLeaveModal && d_ptr->panelModality != NonModal)
+ d_ptr->scene->d_func()->enterModal(this, previousModality);
+}
+
+/*!
+ \since 4.6
+
+ Returns true if this item is blocked by a modal panel, false otherwise. If \a blockingPanel is
+ non-zero, \a blockingPanel will be set to the modal panel that is blocking this item. If this
+ item is not blocked, \a blockingPanel will not be set by this function.
+
+ This function always returns false for items not in a scene.
+
+ \sa panelModality() setPanelModality() PanelModality
+*/
+bool QGraphicsItem::isBlockedByModalPanel(QGraphicsItem **blockingPanel) const
+{
+ if (!d_ptr->scene)
+ return false;
+
+
+ QGraphicsItem *dummy = 0;
+ if (!blockingPanel)
+ blockingPanel = &dummy;
+
+ QGraphicsScenePrivate *scene_d = d_ptr->scene->d_func();
+ if (scene_d->modalPanels.isEmpty())
+ return false;
+
+ // ###
+ if (!scene_d->popupWidgets.isEmpty() && scene_d->popupWidgets.first() == this)
+ return false;
+
+ for (int i = 0; i < scene_d->modalPanels.count(); ++i) {
+ QGraphicsItem *modalPanel = scene_d->modalPanels.at(i);
+ if (modalPanel->panelModality() == QGraphicsItem::SceneModal) {
+ // Scene modal panels block all non-descendents.
+ if (modalPanel != this && !modalPanel->isAncestorOf(this)) {
+ *blockingPanel = modalPanel;
+ return true;
+ }
+ } else {
+ // Window modal panels block ancestors and siblings/cousins.
+ if (modalPanel != this
+ && !modalPanel->isAncestorOf(this)
+ && commonAncestorItem(modalPanel)) {
+ *blockingPanel = modalPanel;
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+#ifndef QT_NO_TOOLTIP
+/*!
+ Returns the item's tool tip, or an empty QString if no tool tip has been
+ set.
+
+ \sa setToolTip(), QToolTip
+*/
+QString QGraphicsItem::toolTip() const
+{
+ return d_ptr->extra(QGraphicsItemPrivate::ExtraToolTip).toString();
+}
+
+/*!
+ Sets the item's tool tip to \a toolTip. If \a toolTip is empty, the item's
+ tool tip is cleared.
+
+ \sa toolTip(), QToolTip
+*/
+void QGraphicsItem::setToolTip(const QString &toolTip)
+{
+ const QVariant toolTipVariant(itemChange(ItemToolTipChange, toolTip));
+ d_ptr->setExtra(QGraphicsItemPrivate::ExtraToolTip, toolTipVariant.toString());
+ itemChange(ItemToolTipHasChanged, toolTipVariant);
+}
+#endif // QT_NO_TOOLTIP
+
+#ifndef QT_NO_CURSOR
+/*!
+ Returns the current cursor shape for the item. The mouse cursor
+ will assume this shape when it's over this item. See the \link
+ Qt::CursorShape list of predefined cursor objects\endlink for a
+ range of useful shapes.
+
+ An editor item might want to use an I-beam cursor:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 2
+
+ If no cursor has been set, the cursor of the item beneath is used.
+
+ \sa setCursor(), hasCursor(), unsetCursor(), QWidget::cursor,
+ QApplication::overrideCursor()
+*/
+QCursor QGraphicsItem::cursor() const
+{
+ return qvariant_cast<QCursor>(d_ptr->extra(QGraphicsItemPrivate::ExtraCursor));
+}
+
+/*!
+ Sets the current cursor shape for the item to \a cursor. The mouse cursor
+ will assume this shape when it's over this item. See the \link
+ Qt::CursorShape list of predefined cursor objects\endlink for a range of
+ useful shapes.
+
+ An editor item might want to use an I-beam cursor:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 3
+
+ If no cursor has been set, the cursor of the item beneath is used.
+
+ \sa cursor(), hasCursor(), unsetCursor(), QWidget::cursor,
+ QApplication::overrideCursor()
+*/
+void QGraphicsItem::setCursor(const QCursor &cursor)
+{
+ const QVariant cursorVariant(itemChange(ItemCursorChange, QVariant::fromValue<QCursor>(cursor)));
+ d_ptr->setExtra(QGraphicsItemPrivate::ExtraCursor, qvariant_cast<QCursor>(cursorVariant));
+ d_ptr->hasCursor = 1;
+ if (d_ptr->scene) {
+ d_ptr->scene->d_func()->allItemsUseDefaultCursor = false;
+ foreach (QGraphicsView *view, d_ptr->scene->views()) {
+ view->viewport()->setMouseTracking(true);
+ // Note: Some of this logic is duplicated in QGraphicsView's mouse events.
+ if (view->underMouse()) {
+ foreach (QGraphicsItem *itemUnderCursor, view->items(view->mapFromGlobal(QCursor::pos()))) {
+ if (itemUnderCursor->hasCursor()) {
+ QMetaObject::invokeMethod(view, "_q_setViewportCursor",
+ Q_ARG(QCursor, itemUnderCursor->cursor()));
+ break;
+ }
+ }
+ break;
+ }
+ }
+ }
+ itemChange(ItemCursorHasChanged, cursorVariant);
+}
+
+/*!
+ Returns true if this item has a cursor set; otherwise, false is returned.
+
+ By default, items don't have any cursor set. cursor() will return a
+ standard pointing arrow cursor.
+
+ \sa unsetCursor()
+*/
+bool QGraphicsItem::hasCursor() const
+{
+ return d_ptr->hasCursor;
+}
+
+/*!
+ Clears the cursor from this item.
+
+ \sa hasCursor(), setCursor()
+*/
+void QGraphicsItem::unsetCursor()
+{
+ d_ptr->unsetExtra(QGraphicsItemPrivate::ExtraCursor);
+ d_ptr->hasCursor = 0;
+ if (d_ptr->scene) {
+ foreach (QGraphicsView *view, d_ptr->scene->views()) {
+ if (view->underMouse() && view->itemAt(view->mapFromGlobal(QCursor::pos())) == this) {
+ QMetaObject::invokeMethod(view, "_q_unsetViewportCursor");
+ break;
+ }
+ }
+ }
+}
+
+#endif // QT_NO_CURSOR
+
+/*!
+ Returns true if the item is visible; otherwise, false is returned.
+
+ Note that the item's general visibility is unrelated to whether or not it
+ is actually being visualized by a QGraphicsView.
+
+ \sa setVisible()
+*/
+bool QGraphicsItem::isVisible() const
+{
+ return d_ptr->visible;
+}
+
+/*!
+ \since 4.4
+ Returns true if the item is visible to \a parent; otherwise, false is
+ returned. \a parent can be 0, in which case this function will return
+ whether the item is visible to the scene or not.
+
+ An item may not be visible to its ancestors even if isVisible() is true. If
+ any ancestor is hidden, the item itself will be implicitly hidden, in which
+ case this function will return false.
+
+ \sa isVisible(), setVisible()
+*/
+bool QGraphicsItem::isVisibleTo(const QGraphicsItem *parent) const
+{
+ if (!d_ptr->visible)
+ return false;
+ if (parent == this)
+ return true;
+ if (parentItem() && parentItem()->isVisibleTo(parent))
+ return true;
+ if (!parent && !parentItem())
+ return true;
+ return false;
+}
+
+/*!
+ \internal
+
+ Sets this item's visibility to \a newVisible. If \a explicitly is true,
+ this item will be "explicitly" \a newVisible; otherwise, it.. will not be.
+*/
+void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bool update)
+{
+ Q_Q(QGraphicsItem);
+
+ // Update explicit bit.
+ if (explicitly)
+ explicitlyHidden = newVisible ? 0 : 1;
+
+ // Check if there's nothing to do.
+ if (visible == quint32(newVisible))
+ return;
+
+ // Don't show child if parent is not visible
+ if (parent && newVisible && !parent->d_ptr->visible)
+ return;
+
+ // Modify the property.
+ const QVariant newVisibleVariant(q_ptr->itemChange(QGraphicsItem::ItemVisibleChange,
+ quint32(newVisible)));
+ newVisible = newVisibleVariant.toBool();
+ if (visible == quint32(newVisible))
+ return;
+ visible = newVisible;
+
+ // Schedule redrawing
+ if (update) {
+ QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));
+ if (c)
+ c->purge();
+ if (scene) {
+#ifndef QT_NO_GRAPHICSEFFECT
+ invalidateParentGraphicsEffectsRecursively();
+#endif //QT_NO_GRAPHICSEFFECT
+ scene->d_func()->markDirty(q_ptr, QRectF(), /*invalidateChildren=*/false, /*force=*/true);
+ }
+ }
+
+ // Certain properties are dropped as an item becomes invisible.
+ bool hasFocus = q_ptr->hasFocus();
+ if (!newVisible) {
+ if (scene) {
+ if (scene->d_func()->mouseGrabberItems.contains(q))
+ q->ungrabMouse();
+ if (scene->d_func()->keyboardGrabberItems.contains(q))
+ q->ungrabKeyboard();
+ if (q->isPanel() && panelModality != QGraphicsItem::NonModal)
+ scene->d_func()->leaveModal(q_ptr);
+ }
+ if (hasFocus && scene) {
+ // Hiding the closest non-panel ancestor of the focus item
+ QGraphicsItem *focusItem = scene->focusItem();
+ bool clear = true;
+ if (isWidget && !focusItem->isPanel()) {
+ do {
+ if (focusItem == q_ptr) {
+ clear = !static_cast<QGraphicsWidget *>(q_ptr)->focusNextPrevChild(true);
+ break;
+ }
+ } while ((focusItem = focusItem->parentWidget()) && !focusItem->isPanel());
+ }
+ if (clear)
+ clearFocusHelper(/* giveFocusToParent = */ false);
+ }
+ if (q_ptr->isSelected())
+ q_ptr->setSelected(false);
+ } else {
+ geometryChanged = 1;
+ paintedViewBoundingRectsNeedRepaint = 1;
+ if (scene) {
+ if (isWidget) {
+ QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(q_ptr);
+ if (widget->windowType() == Qt::Popup)
+ scene->d_func()->addPopup(widget);
+ }
+ if (q->isPanel() && panelModality != QGraphicsItem::NonModal) {
+ scene->d_func()->enterModal(q_ptr);
+ }
+ }
+ }
+
+ // Update children with explicitly = false.
+ const bool updateChildren = update && !(flags & QGraphicsItem::ItemClipsChildrenToShape);
+ foreach (QGraphicsItem *child, children) {
+ if (!newVisible || !child->d_ptr->explicitlyHidden)
+ child->d_ptr->setVisibleHelper(newVisible, false, updateChildren);
+ }
+
+ // Update activation
+ if (scene && q->isPanel()) {
+ if (newVisible) {
+ if (parent && parent->isActive())
+ q->setActive(true);
+ } else {
+ if (q->isActive())
+ scene->setActivePanel(parent);
+ }
+ }
+
+ // Enable subfocus
+ if (scene) {
+ if (newVisible) {
+ // Item is shown
+ QGraphicsItem *p = parent;
+ bool done = false;
+ while (p) {
+ if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
+ QGraphicsItem *fsi = p->d_ptr->focusScopeItem;
+ if (q_ptr == fsi || q_ptr->isAncestorOf(fsi)) {
+ done = true;
+ while (fsi->d_ptr->focusScopeItem && fsi->d_ptr->focusScopeItem->isVisible())
+ fsi = fsi->d_ptr->focusScopeItem;
+ fsi->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ true,
+ /* focusFromHide = */ false);
+ }
+ break;
+ }
+ p = p->d_ptr->parent;
+ }
+ if (!done) {
+ QGraphicsItem *fi = subFocusItem;
+ if (fi && fi != scene->focusItem()) {
+ scene->setFocusItem(fi);
+ } else if (flags & QGraphicsItem::ItemIsFocusScope &&
+ !scene->focusItem() &&
+ q->isAncestorOf(scene->d_func()->lastFocusItem)) {
+ q_ptr->setFocus();
+ }
+ }
+ } else {
+ // Item is hidden
+ if (hasFocus) {
+ QGraphicsItem *p = parent;
+ while (p) {
+ if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
+ if (p->d_ptr->visible) {
+ p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ true,
+ /* focusFromHide = */ true);
+ }
+ break;
+ }
+ p = p->d_ptr->parent;
+ }
+ }
+ }
+ }
+
+ // Deliver post-change notification.
+ q_ptr->itemChange(QGraphicsItem::ItemVisibleHasChanged, newVisibleVariant);
+
+ if (isObject)
+ emit static_cast<QGraphicsObject *>(q_ptr)->visibleChanged();
+}
+
+/*!
+ If \a visible is true, the item is made visible. Otherwise, the item is
+ made invisible. Invisible items are not painted, nor do they receive any
+ events. In particular, mouse events pass right through invisible items,
+ and are delivered to any item that may be behind. Invisible items are also
+ unselectable, they cannot take input focus, and are not detected by
+ QGraphicsScene's item location functions.
+
+ If an item becomes invisible while grabbing the mouse, (i.e., while it is
+ receiving mouse events,) it will automatically lose the mouse grab, and
+ the grab is not regained by making the item visible again; it must receive
+ a new mouse press to regain the mouse grab.
+
+ Similarly, an invisible item cannot have focus, so if the item has focus
+ when it becomes invisible, it will lose focus, and the focus is not
+ regained by simply making the item visible again.
+
+ If you hide a parent item, all its children will also be hidden. If you
+ show a parent item, all children will be shown, unless they have been
+ explicitly hidden (i.e., if you call setVisible(false) on a child, it will
+ not be reshown even if its parent is hidden, and then shown again).
+
+ Items are visible by default; it is unnecessary to call
+ setVisible() on a new item.
+
+ \sa isVisible(), show(), hide()
+*/
+void QGraphicsItem::setVisible(bool visible)
+{
+ d_ptr->setVisibleHelper(visible, /* explicit = */ true);
+}
+
+/*!
+ \fn void QGraphicsItem::hide()
+
+ Hides the item. (Items are visible by default.)
+
+ This convenience function is equivalent to calling \c setVisible(false).
+
+ \sa show(), setVisible()
+*/
+
+/*!
+ \fn void QGraphicsItem::show()
+
+ Shows the item. (Items are visible by default.)
+
+ This convenience function is equivalent to calling \c setVisible(true).
+
+ \sa hide(), setVisible()
+*/
+
+/*!
+ Returns true if the item is enabled; otherwise, false is returned.
+
+ \sa setEnabled()
+*/
+bool QGraphicsItem::isEnabled() const
+{
+ return d_ptr->enabled;
+}
+
+/*!
+ \internal
+
+ Sets this item's visibility to \a newEnabled. If \a explicitly is true,
+ this item will be "explicitly" \a newEnabled; otherwise, it.. will not be.
+*/
+void QGraphicsItemPrivate::setEnabledHelper(bool newEnabled, bool explicitly, bool update)
+{
+ // Update explicit bit.
+ if (explicitly)
+ explicitlyDisabled = newEnabled ? 0 : 1;
+
+ // Check if there's nothing to do.
+ if (enabled == quint32(newEnabled))
+ return;
+
+ // Certain properties are dropped when an item is disabled.
+ if (!newEnabled) {
+ if (scene && scene->mouseGrabberItem() == q_ptr)
+ q_ptr->ungrabMouse();
+ if (q_ptr->hasFocus()) {
+ // Disabling the closest non-panel ancestor of the focus item
+ // causes focus to pop to the next item, otherwise it's cleared.
+ QGraphicsItem *focusItem = scene->focusItem();
+ bool clear = true;
+ if (isWidget && !focusItem->isPanel() && q_ptr->isAncestorOf(focusItem)) {
+ do {
+ if (focusItem == q_ptr) {
+ clear = !static_cast<QGraphicsWidget *>(q_ptr)->focusNextPrevChild(true);
+ break;
+ }
+ } while ((focusItem = focusItem->parentWidget()) && !focusItem->isPanel());
+ }
+ if (clear)
+ q_ptr->clearFocus();
+ }
+ if (q_ptr->isSelected())
+ q_ptr->setSelected(false);
+ }
+
+ // Modify the property.
+ const QVariant newEnabledVariant(q_ptr->itemChange(QGraphicsItem::ItemEnabledChange,
+ quint32(newEnabled)));
+ enabled = newEnabledVariant.toBool();
+
+ // Schedule redraw.
+ if (update)
+ q_ptr->update();
+
+ foreach (QGraphicsItem *child, children) {
+ if (!newEnabled || !child->d_ptr->explicitlyDisabled)
+ child->d_ptr->setEnabledHelper(newEnabled, /* explicitly = */ false);
+ }
+
+ // Deliver post-change notification.
+ q_ptr->itemChange(QGraphicsItem::ItemEnabledHasChanged, newEnabledVariant);
+
+ if (isObject)
+ emit static_cast<QGraphicsObject *>(q_ptr)->enabledChanged();
+}
+
+/*!
+ If \a enabled is true, the item is enabled; otherwise, it is disabled.
+
+ Disabled items are visible, but they do not receive any events, and cannot
+ take focus nor be selected. Mouse events are discarded; they are not
+ propagated unless the item is also invisible, or if it does not accept
+ mouse events (see acceptedMouseButtons()). A disabled item cannot become the
+ mouse grabber, and as a result of this, an item loses the grab if it
+ becomes disabled when grabbing the mouse, just like it loses focus if it
+ had focus when it was disabled.
+
+ Disabled items are traditionally drawn using grayed-out colors (see \l
+ QPalette::Disabled).
+
+ If you disable a parent item, all its children will also be disabled. If
+ you enable a parent item, all children will be enabled, unless they have
+ been explicitly disabled (i.e., if you call setEnabled(false) on a child,
+ it will not be reenabled if its parent is disabled, and then enabled
+ again).
+
+ Items are enabled by default.
+
+ \note If you install an event filter, you can still intercept events
+ before they are delivered to items; this mechanism disregards the item's
+ enabled state.
+
+ \sa isEnabled()
+*/
+void QGraphicsItem::setEnabled(bool enabled)
+{
+ d_ptr->setEnabledHelper(enabled, /* explicitly = */ true);
+}
+
+/*!
+ Returns true if this item is selected; otherwise, false is returned.
+
+ Items that are in a group inherit the group's selected state.
+
+ Items are not selected by default.
+
+ \sa setSelected(), QGraphicsScene::setSelectionArea()
+*/
+bool QGraphicsItem::isSelected() const
+{
+ if (QGraphicsItemGroup *group = this->group())
+ return group->isSelected();
+ return d_ptr->selected;
+}
+
+/*!
+ If \a selected is true and this item is selectable, this item is selected;
+ otherwise, it is unselected.
+
+ If the item is in a group, the whole group's selected state is toggled by
+ this function. If the group is selected, all items in the group are also
+ selected, and if the group is not selected, no item in the group is
+ selected.
+
+ Only visible, enabled, selectable items can be selected. If \a selected
+ is true and this item is either invisible or disabled or unselectable,
+ this function does nothing.
+
+ By default, items cannot be selected. To enable selection, set the
+ ItemIsSelectable flag.
+
+ This function is provided for convenience, allowing individual toggling of
+ the selected state of an item. However, a more common way of selecting
+ items is to call QGraphicsScene::setSelectionArea(), which will call this
+ function for all visible, enabled, and selectable items within a specified
+ area on the scene.
+
+ \sa isSelected(), QGraphicsScene::selectedItems()
+*/
+void QGraphicsItem::setSelected(bool selected)
+{
+ if (QGraphicsItemGroup *group = this->group()) {
+ group->setSelected(selected);
+ return;
+ }
+
+ if (!(d_ptr->flags & ItemIsSelectable) || !d_ptr->enabled || !d_ptr->visible)
+ selected = false;
+ if (d_ptr->selected == selected)
+ return;
+ const QVariant newSelectedVariant(itemChange(ItemSelectedChange, quint32(selected)));
+ bool newSelected = newSelectedVariant.toBool();
+ if (d_ptr->selected == newSelected)
+ return;
+ d_ptr->selected = newSelected;
+
+ update();
+ if (d_ptr->scene) {
+ QGraphicsScenePrivate *sceneD = d_ptr->scene->d_func();
+ if (selected) {
+ sceneD->selectedItems << this;
+ } else {
+ // QGraphicsScene::selectedItems() lazily pulls out all items that are
+ // no longer selected.
+ }
+ if (!sceneD->selectionChanging)
+ emit d_ptr->scene->selectionChanged();
+ }
+
+ // Deliver post-change notification.
+ itemChange(QGraphicsItem::ItemSelectedHasChanged, newSelectedVariant);
+}
+
+/*!
+ \since 4.5
+
+ Returns this item's local opacity, which is between 0.0 (transparent) and
+ 1.0 (opaque). This value is combined with parent and ancestor values into
+ the effectiveOpacity(). The effective opacity decides how the item is
+ rendered.
+
+ The opacity property decides the state of the painter passed to the
+ paint() function. If the item is cached, i.e., ItemCoordinateCache or
+ DeviceCoordinateCache, the effective property will be applied to the item's
+ cache as it is rendered.
+
+ The default opacity is 1.0; fully opaque.
+
+ \sa setOpacity(), paint(), ItemIgnoresParentOpacity,
+ ItemDoesntPropagateOpacityToChildren
+*/
+qreal QGraphicsItem::opacity() const
+{
+ return d_ptr->opacity;
+}
+
+/*!
+ \since 4.5
+
+ Returns this item's \e effective opacity, which is between 0.0
+ (transparent) and 1.0 (opaque). This value is a combination of this item's
+ local opacity, and its parent and ancestors' opacities. The effective
+ opacity decides how the item is rendered.
+
+ \sa opacity(), setOpacity(), paint(), ItemIgnoresParentOpacity,
+ ItemDoesntPropagateOpacityToChildren
+*/
+qreal QGraphicsItem::effectiveOpacity() const
+{
+ return d_ptr->effectiveOpacity();
+}
+
+/*!
+ \since 4.5
+
+ Sets this item's local \a opacity, between 0.0 (transparent) and 1.0
+ (opaque). The item's local opacity is combined with parent and ancestor
+ opacities into the effectiveOpacity().
+
+ By default, opacity propagates from parent to child, so if a parent's
+ opacity is 0.5 and the child is also 0.5, the child's effective opacity
+ will be 0.25.
+
+ The opacity property decides the state of the painter passed to the
+ paint() function. If the item is cached, i.e., ItemCoordinateCache or
+ DeviceCoordinateCache, the effective property will be applied to the
+ item's cache as it is rendered.
+
+ There are two item flags that affect how the item's opacity is combined
+ with the parent: ItemIgnoresParentOpacity and
+ ItemDoesntPropagateOpacityToChildren.
+
+ \sa opacity(), effectiveOpacity()
+*/
+void QGraphicsItem::setOpacity(qreal opacity)
+{
+ // Notify change.
+ const QVariant newOpacityVariant(itemChange(ItemOpacityChange, opacity));
+
+ // Normalized opacity
+ qreal newOpacity = qBound(qreal(0), newOpacityVariant.toReal(), qreal(1));
+
+ // No change? Done.
+ if (newOpacity == d_ptr->opacity)
+ return;
+
+ bool wasFullyTransparent = d_ptr->isOpacityNull();
+ d_ptr->opacity = newOpacity;
+
+ // Notify change.
+ itemChange(ItemOpacityHasChanged, newOpacityVariant);
+
+ // Update.
+ if (d_ptr->scene) {
+#ifndef QT_NO_GRAPHICSEFFECT
+ d_ptr->invalidateParentGraphicsEffectsRecursively();
+ if (!(d_ptr->flags & ItemDoesntPropagateOpacityToChildren))
+ d_ptr->invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::OpacityChanged);
+#endif //QT_NO_GRAPHICSEFFECT
+ d_ptr->scene->d_func()->markDirty(this, QRectF(),
+ /*invalidateChildren=*/true,
+ /*force=*/false,
+ /*ignoreOpacity=*/d_ptr->isOpacityNull());
+ if (wasFullyTransparent)
+ d_ptr->paintedViewBoundingRectsNeedRepaint = 1;
+ }
+
+ if (d_ptr->isObject)
+ emit static_cast<QGraphicsObject *>(this)->opacityChanged();
+}
+
+/*!
+ Returns a pointer to this item's effect if it has one; otherwise 0.
+
+ \since 4.6
+*/
+#ifndef QT_NO_GRAPHICSEFFECT
+QGraphicsEffect *QGraphicsItem::graphicsEffect() const
+{
+ return d_ptr->graphicsEffect;
+}
+
+/*!
+ Sets \a effect as the item's effect. If there already is an effect installed
+ on this item, QGraphicsItem will delete the existing effect before installing
+ the new \a effect.
+
+ If \a effect is the installed on a different item, setGraphicsEffect() will remove
+ the effect from the item and install it on this item.
+
+ QGraphicsItem takes ownership of \a effect.
+
+ \note This function will apply the effect on itself and all its children.
+
+ \since 4.6
+*/
+void QGraphicsItem::setGraphicsEffect(QGraphicsEffect *effect)
+{
+ if (d_ptr->graphicsEffect == effect)
+ return;
+
+ if (d_ptr->graphicsEffect) {
+ delete d_ptr->graphicsEffect;
+ d_ptr->graphicsEffect = 0;
+ } else if (d_ptr->parent) {
+ d_ptr->parent->d_ptr->updateChildWithGraphicsEffectFlagRecursively();
+ }
+
+ if (effect) {
+ // Set new effect.
+ QGraphicsEffectSourcePrivate *sourced = new QGraphicsItemEffectSourcePrivate(this);
+ QGraphicsEffectSource *source = new QGraphicsEffectSource(*sourced);
+ d_ptr->graphicsEffect = effect;
+ effect->d_func()->setGraphicsEffectSource(source);
+ prepareGeometryChange();
+ }
+}
+#endif //QT_NO_GRAPHICSEFFECT
+
+void QGraphicsItemPrivate::updateChildWithGraphicsEffectFlagRecursively()
+{
+#ifndef QT_NO_GRAPHICSEFFECT
+ QGraphicsItemPrivate *itemPrivate = this;
+ do {
+ // parent chain already notified?
+ if (itemPrivate->mayHaveChildWithGraphicsEffect)
+ return;
+ itemPrivate->mayHaveChildWithGraphicsEffect = 1;
+ } while ((itemPrivate = itemPrivate->parent ? itemPrivate->parent->d_ptr.data() : 0));
+#endif
+}
+
+/*!
+ \internal
+ \since 4.6
+ Returns the effective bounding rect of the given item space rect.
+ If the item has no effect, the rect is returned unmodified.
+ If the item has an effect, the effective rect can be extend beyond the
+ item's bounding rect, depending on the effect.
+
+ \sa boundingRect()
+*/
+QRectF QGraphicsItemPrivate::effectiveBoundingRect(const QRectF &rect) const
+{
+#ifndef QT_NO_GRAPHICSEFFECT
+ Q_Q(const QGraphicsItem);
+ QGraphicsEffect *effect = graphicsEffect;
+ if (scene && effect && effect->isEnabled()) {
+ if (scene->d_func()->views.isEmpty())
+ return effect->boundingRectFor(rect);
+ QRectF sceneRect = q->mapRectToScene(rect);
+ QRectF sceneEffectRect;
+ foreach (QGraphicsView *view, scene->views()) {
+ QRectF deviceRect = view->d_func()->mapRectFromScene(sceneRect);
+ QRect deviceEffectRect = effect->boundingRectFor(deviceRect).toAlignedRect();
+ sceneEffectRect |= view->d_func()->mapRectToScene(deviceEffectRect);
+ }
+ return q->mapRectFromScene(sceneEffectRect);
+ }
+#endif //QT_NO_GRAPHICSEFFECT
+ return rect;
+}
+
+/*!
+ \internal
+ \since 4.6
+ Returns the effective bounding rect of the item.
+ If the item has no effect, this is the same as the item's bounding rect.
+ If the item has an effect, the effective rect can be larger than the item's
+ bouding rect, depending on the effect.
+
+ \sa boundingRect()
+*/
+QRectF QGraphicsItemPrivate::effectiveBoundingRect(QGraphicsItem *topMostEffectItem) const
+{
+#ifndef QT_NO_GRAPHICSEFFECT
+ Q_Q(const QGraphicsItem);
+ QRectF brect = effectiveBoundingRect(q_ptr->boundingRect());
+ if (ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren || topMostEffectItem == q)
+ return brect;
+
+ const QGraphicsItem *effectParent = parent;
+ while (effectParent) {
+ QGraphicsEffect *effect = effectParent->d_ptr->graphicsEffect;
+ if (scene && effect && effect->isEnabled()) {
+ const QRectF brectInParentSpace = q->mapRectToItem(effectParent, brect);
+ const QRectF effectRectInParentSpace = effectParent->d_ptr->effectiveBoundingRect(brectInParentSpace);
+ brect = effectParent->mapRectToItem(q, effectRectInParentSpace);
+ }
+ if (effectParent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren
+ || topMostEffectItem == effectParent) {
+ return brect;
+ }
+ effectParent = effectParent->d_ptr->parent;
+ }
+
+ return brect;
+#else //QT_NO_GRAPHICSEFFECT
+ return q_ptr->boundingRect();
+#endif //QT_NO_GRAPHICSEFFECT
+
+}
+
+/*!
+ \internal
+ \since 4.6
+ Returns the effective bounding rect of this item in scene coordinates,
+ by combining sceneTransform() with boundingRect(), taking into account
+ the effect that the item might have.
+
+ If the item has no effect, this is the same as sceneBoundingRect().
+
+ \sa effectiveBoundingRect(), sceneBoundingRect()
+*/
+QRectF QGraphicsItemPrivate::sceneEffectiveBoundingRect() const
+{
+ // Find translate-only offset
+ // COMBINE
+ QPointF offset;
+ const QGraphicsItem *parentItem = q_ptr;
+ const QGraphicsItemPrivate *itemd;
+ do {
+ itemd = parentItem->d_ptr.data();
+ if (itemd->transformData)
+ break;
+ offset += itemd->pos;
+ } while ((parentItem = itemd->parent));
+
+ QRectF br = effectiveBoundingRect();
+ br.translate(offset);
+ return !parentItem ? br : parentItem->sceneTransform().mapRect(br);
+}
+
+/*!
+ Returns true if this item can accept drag and drop events; otherwise,
+ returns false. By default, items do not accept drag and drop events; items
+ are transparent to drag and drop.
+
+ \sa setAcceptDrops()
+*/
+bool QGraphicsItem::acceptDrops() const
+{
+ return d_ptr->acceptDrops;
+}
+
+/*!
+ If \a on is true, this item will accept drag and drop events; otherwise,
+ it is transparent for drag and drop events. By default, items do not
+ accept drag and drop events.
+
+ \sa acceptDrops()
+*/
+void QGraphicsItem::setAcceptDrops(bool on)
+{
+ d_ptr->acceptDrops = on;
+}
+
+/*!
+ Returns the mouse buttons that this item accepts mouse events for. By
+ default, all mouse buttons are accepted.
+
+ If an item accepts a mouse button, it will become the mouse
+ grabber item when a mouse press event is delivered for that mouse
+ button. However, if the item does not accept the button,
+ QGraphicsScene will forward the mouse events to the first item
+ beneath it that does.
+
+ \sa setAcceptedMouseButtons(), mousePressEvent()
+*/
+Qt::MouseButtons QGraphicsItem::acceptedMouseButtons() const
+{
+ return Qt::MouseButtons(d_ptr->acceptedMouseButtons);
+}
+
+/*!
+ Sets the mouse \a buttons that this item accepts mouse events for.
+
+ By default, all mouse buttons are accepted. If an item accepts a
+ mouse button, it will become the mouse grabber item when a mouse
+ press event is delivered for that button. However, if the item
+ does not accept the mouse button, QGraphicsScene will forward the
+ mouse events to the first item beneath it that does.
+
+ To disable mouse events for an item (i.e., make it transparent for mouse
+ events), call setAcceptedMouseButtons(0).
+
+ \sa acceptedMouseButtons(), mousePressEvent()
+*/
+void QGraphicsItem::setAcceptedMouseButtons(Qt::MouseButtons buttons)
+{
+ if (Qt::MouseButtons(d_ptr->acceptedMouseButtons) != buttons) {
+ if (buttons == 0 && d_ptr->scene && d_ptr->scene->mouseGrabberItem() == this
+ && d_ptr->scene->d_func()->lastMouseGrabberItemHasImplicitMouseGrab) {
+ ungrabMouse();
+ }
+ d_ptr->acceptedMouseButtons = quint32(buttons);
+ }
+}
+
+/*!
+ \since 4.4
+
+ Returns true if an item accepts hover events
+ (QGraphicsSceneHoverEvent); otherwise, returns false. By default,
+ items do not accept hover events.
+
+ \sa setAcceptedMouseButtons()
+*/
+bool QGraphicsItem::acceptHoverEvents() const
+{
+ return d_ptr->acceptsHover;
+}
+
+/*!
+ \obsolete
+
+ Call acceptHoverEvents() instead.
+*/
+bool QGraphicsItem::acceptsHoverEvents() const
+{
+ return d_ptr->acceptsHover;
+}
+
+/*!
+ \since 4.4
+
+ If \a enabled is true, this item will accept hover events;
+ otherwise, it will ignore them. By default, items do not accept
+ hover events.
+
+ Hover events are delivered when there is no current mouse grabber
+ item. They are sent when the mouse cursor enters an item, when it
+ moves around inside the item, and when the cursor leaves an
+ item. Hover events are commonly used to highlight an item when
+ it's entered, and for tracking the mouse cursor as it hovers over
+ the item (equivalent to QWidget::mouseTracking).
+
+ Parent items receive hover enter events before their children, and
+ leave events after their children. The parent does not receive a
+ hover leave event if the cursor enters a child, though; the parent
+ stays "hovered" until the cursor leaves its area, including its
+ children's areas.
+
+ If a parent item handles child events, it will receive hover move,
+ drag move, and drop events as the cursor passes through its
+ children, but it does not receive hover enter and hover leave, nor
+ drag enter and drag leave events on behalf of its children.
+
+ A QGraphicsWidget with window decorations will accept hover events
+ regardless of the value of acceptHoverEvents().
+
+ \sa acceptHoverEvents(), hoverEnterEvent(), hoverMoveEvent(),
+ hoverLeaveEvent()
+*/
+void QGraphicsItem::setAcceptHoverEvents(bool enabled)
+{
+ if (d_ptr->acceptsHover == quint32(enabled))
+ return;
+ d_ptr->acceptsHover = quint32(enabled);
+ if (d_ptr->acceptsHover && d_ptr->scene && d_ptr->scene->d_func()->allItemsIgnoreHoverEvents) {
+ d_ptr->scene->d_func()->allItemsIgnoreHoverEvents = false;
+ d_ptr->scene->d_func()->enableMouseTrackingOnViews();
+ }
+}
+
+/*!
+ \obsolete
+
+ Use setAcceptHoverEvents(\a enabled) instead.
+*/
+void QGraphicsItem::setAcceptsHoverEvents(bool enabled)
+{
+ setAcceptHoverEvents(enabled);
+}
+
+/*! \since 4.6
+
+ Returns true if an item accepts \l{QTouchEvent}{touch events};
+ otherwise, returns false. By default, items do not accept touch events.
+
+ \sa setAcceptTouchEvents()
+*/
+bool QGraphicsItem::acceptTouchEvents() const
+{
+ return d_ptr->acceptTouchEvents;
+}
+
+/*!
+ \since 4.6
+
+ If \a enabled is true, this item will accept \l{QTouchEvent}{touch events};
+ otherwise, it will ignore them. By default, items do not accept
+ touch events.
+*/
+void QGraphicsItem::setAcceptTouchEvents(bool enabled)
+{
+ if (d_ptr->acceptTouchEvents == quint32(enabled))
+ return;
+ d_ptr->acceptTouchEvents = quint32(enabled);
+ if (d_ptr->acceptTouchEvents && d_ptr->scene && d_ptr->scene->d_func()->allItemsIgnoreTouchEvents) {
+ d_ptr->scene->d_func()->allItemsIgnoreTouchEvents = false;
+ d_ptr->scene->d_func()->enableTouchEventsOnViews();
+ }
+}
+
+/*!
+ \since 4.6
+
+ Returns true if this item filters child events (i.e., all events
+ intended for any of its children are instead sent to this item);
+ otherwise, false is returned.
+
+ The default value is false; child events are not filtered.
+
+ \sa setFiltersChildEvents()
+*/
+bool QGraphicsItem::filtersChildEvents() const
+{
+ return d_ptr->filtersDescendantEvents;
+}
+
+/*!
+ \since 4.6
+
+ If \a enabled is true, this item is set to filter all events for
+ all its children (i.e., all events intented for any of its
+ children are instead sent to this item); otherwise, if \a enabled
+ is false, this item will only handle its own events. The default
+ value is false.
+
+ \sa filtersChildEvents()
+*/
+void QGraphicsItem::setFiltersChildEvents(bool enabled)
+{
+ if (d_ptr->filtersDescendantEvents == enabled)
+ return;
+
+ d_ptr->filtersDescendantEvents = enabled;
+ d_ptr->updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-2));
+}
+
+/*!
+ \obsolete
+
+ Returns true if this item handles child events (i.e., all events
+ intended for any of its children are instead sent to this item);
+ otherwise, false is returned.
+
+ This property is useful for item groups; it allows one item to
+ handle events on behalf of its children, as opposed to its
+ children handling their events individually.
+
+ The default is to return false; children handle their own events.
+ The exception for this is if the item is a QGraphicsItemGroup, then
+ it defaults to return true.
+
+ \sa setHandlesChildEvents()
+*/
+bool QGraphicsItem::handlesChildEvents() const
+{
+ return d_ptr->handlesChildEvents;
+}
+
+/*!
+ \obsolete
+
+ If \a enabled is true, this item is set to handle all events for
+ all its children (i.e., all events intented for any of its
+ children are instead sent to this item); otherwise, if \a enabled
+ is false, this item will only handle its own events. The default
+ value is false.
+
+ This property is useful for item groups; it allows one item to
+ handle events on behalf of its children, as opposed to its
+ children handling their events individually.
+
+ If a child item accepts hover events, its parent will receive
+ hover move events as the cursor passes through the child, but it
+ does not receive hover enter and hover leave events on behalf of
+ its child.
+
+ \sa handlesChildEvents()
+*/
+void QGraphicsItem::setHandlesChildEvents(bool enabled)
+{
+ if (d_ptr->handlesChildEvents == enabled)
+ return;
+
+ d_ptr->handlesChildEvents = enabled;
+ d_ptr->updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-1));
+}
+/*!
+ \since 4.6
+ Returns true if this item is active; otherwise returns false.
+
+ An item can only be active if the scene is active. An item is active
+ if it is, or is a descendent of, an active panel. Items in non-active
+ panels are not active.
+
+ Items that are not part of a panel follow scene activation when the
+ scene has no active panel.
+
+ Only active items can gain input focus.
+
+ \sa QGraphicsScene::isActive(), QGraphicsScene::activePanel(), panel(), isPanel()
+*/
+bool QGraphicsItem::isActive() const
+{
+ if (!d_ptr->scene || !d_ptr->scene->isActive())
+ return false;
+ return panel() == d_ptr->scene->activePanel();
+}
+
+/*!
+ \since 4.6
+
+ If \a active is true, and the scene is active, this item's panel will be
+ activated. Otherwise, the panel is deactivated.
+
+ If the item is not part of an active scene, \a active will decide what
+ happens to the panel when the scene becomes active or the item is added to
+ the scene. If true, the item's panel will be activated when the item is
+ either added to the scene or the scene is activated. Otherwise, the item
+ will stay inactive independent of the scene's activated state.
+
+ \sa isPanel(), QGraphicsScene::setActivePanel(), QGraphicsScene::isActive()
+*/
+void QGraphicsItem::setActive(bool active)
+{
+ d_ptr->explicitActivate = 1;
+ d_ptr->wantsActive = active;
+ if (d_ptr->scene) {
+ if (active) {
+ // Activate this item.
+ d_ptr->scene->setActivePanel(this);
+ } else {
+ // Deactivate this item, and reactivate the last active item
+ // (if any).
+ QGraphicsItem *lastActive = d_ptr->scene->d_func()->lastActivePanel;
+ d_ptr->scene->setActivePanel(lastActive != this ? lastActive : 0);
+ }
+ }
+}
+
+/*!
+ Returns true if this item is active, and it or its \l{focusProxy()}{focus
+ proxy} has keyboard input focus; otherwise, returns false.
+
+ \sa focusItem(), setFocus(), QGraphicsScene::setFocusItem(), isActive()
+*/
+bool QGraphicsItem::hasFocus() const
+{
+ if (!d_ptr->scene || !d_ptr->scene->isActive())
+ return false;
+
+ if (d_ptr->focusProxy)
+ return d_ptr->focusProxy->hasFocus();
+
+ if (d_ptr->scene->d_func()->focusItem != this)
+ return false;
+
+ return panel() == d_ptr->scene->d_func()->activePanel;
+}
+
+/*!
+ Gives keyboard input focus to this item. The \a focusReason argument will
+ be passed into any \l{QFocusEvent}{focus event} generated by this function;
+ it is used to give an explanation of what caused the item to get focus.
+
+ Only enabled items that set the ItemIsFocusable flag can accept keyboard
+ focus.
+
+ If this item is not visible, not active, or not associated with a scene,
+ it will not gain immediate input focus. However, it will be registered as
+ the preferred focus item for its subtree of items, should it later become
+ visible.
+
+ As a result of calling this function, this item will receive a
+ \l{focusInEvent()}{focus in event} with \a focusReason. If another item
+ already has focus, that item will first receive a \l{focusOutEvent()}
+ {focus out event} indicating that it has lost input focus.
+
+ \sa clearFocus(), hasFocus(), focusItem(), focusProxy()
+*/
+void QGraphicsItem::setFocus(Qt::FocusReason focusReason)
+{
+ d_ptr->setFocusHelper(focusReason, /* climb = */ true, /* focusFromHide = */ false);
+}
+
+/*!
+ \internal
+*/
+void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool climb, bool focusFromHide)
+{
+ // Disabled / unfocusable items cannot accept focus.
+ if (!q_ptr->isEnabled() || !(flags & QGraphicsItem::ItemIsFocusable))
+ return;
+
+ // Find focus proxy.
+ QGraphicsItem *f = q_ptr;
+ while (f->d_ptr->focusProxy)
+ f = f->d_ptr->focusProxy;
+
+ // Return if it already has focus.
+ if (scene && scene->focusItem() == f)
+ return;
+
+ // Update focus scope item ptr.
+ QGraphicsItem *p = parent;
+ while (p) {
+ if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
+ QGraphicsItem *oldFocusScopeItem = p->d_ptr->focusScopeItem;
+ p->d_ptr->focusScopeItem = q_ptr;
+ if (!p->focusItem() && !focusFromHide) {
+ if (oldFocusScopeItem)
+ oldFocusScopeItem->d_ptr->focusScopeItemChange(false);
+ focusScopeItemChange(true);
+ // If you call setFocus on a child of a focus scope that
+ // doesn't currently have a focus item, then stop.
+ return;
+ }
+ break;
+ }
+ p = p->d_ptr->parent;
+ }
+
+ if (climb) {
+ while (f->d_ptr->focusScopeItem && f->d_ptr->focusScopeItem->isVisible())
+ f = f->d_ptr->focusScopeItem;
+ }
+
+ // Update the child focus chain.
+ QGraphicsItem *commonAncestor = 0;
+ if (scene && scene->focusItem()) {
+ commonAncestor = scene->focusItem()->commonAncestorItem(f);
+ scene->focusItem()->d_ptr->clearSubFocus(scene->focusItem(), commonAncestor);
+ }
+
+ f->d_ptr->setSubFocus(f, commonAncestor);
+
+ // Update the scene's focus item.
+ if (scene) {
+ QGraphicsItem *p = q_ptr->panel();
+ if ((!p && scene->isActive()) || (p && p->isActive())) {
+ // Visible items immediately gain focus from scene.
+ scene->d_func()->setFocusItemHelper(f, focusReason);
+ }
+ }
+}
+
+/*!
+ Takes keyboard input focus from the item.
+
+ If it has focus, a \l{focusOutEvent()}{focus out event} is sent to this
+ item to tell it that it is about to lose the focus.
+
+ Only items that set the ItemIsFocusable flag, or widgets that set an
+ appropriate focus policy, can accept keyboard focus.
+
+ \sa setFocus(), hasFocus(), QGraphicsWidget::focusPolicy
+*/
+void QGraphicsItem::clearFocus()
+{
+ d_ptr->clearFocusHelper(/* giveFocusToParent = */ true);
+}
+
+/*!
+ \internal
+*/
+void QGraphicsItemPrivate::clearFocusHelper(bool giveFocusToParent)
+{
+ if (giveFocusToParent) {
+ // Pass focus to the closest parent focus scope
+ if (!inDestructor) {
+ QGraphicsItem *p = parent;
+ while (p) {
+ if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
+ if (p->d_ptr->focusScopeItem == q_ptr) {
+ p->d_ptr->focusScopeItem = 0;
+ if (!q_ptr->hasFocus()) //if it has focus, focusScopeItemChange is called elsewhere
+ focusScopeItemChange(false);
+ }
+ if (q_ptr->hasFocus())
+ p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ false,
+ /* focusFromHide = */ false);
+ return;
+ }
+ p = p->d_ptr->parent;
+ }
+ }
+ }
+
+ if (q_ptr->hasFocus()) {
+ // Invisible items with focus must explicitly clear subfocus.
+ clearSubFocus(q_ptr);
+
+ // If this item has the scene's input focus, clear it.
+ scene->setFocusItem(0);
+ }
+}
+
+/*!
+ \since 4.6
+
+ Returns this item's focus proxy, or 0 if this item has no
+ focus proxy.
+
+ \sa setFocusProxy(), setFocus(), hasFocus()
+*/
+QGraphicsItem *QGraphicsItem::focusProxy() const
+{
+ return d_ptr->focusProxy;
+}
+
+/*!
+ \since 4.6
+
+ Sets the item's focus proxy to \a item.
+
+ If an item has a focus proxy, the focus proxy will receive
+ input focus when the item gains input focus. The item itself
+ will still have focus (i.e., hasFocus() will return true),
+ but only the focus proxy will receive the keyboard input.
+
+ A focus proxy can itself have a focus proxy, and so on. In
+ such case, keyboard input will be handled by the outermost
+ focus proxy.
+
+ The focus proxy \a item must belong to the same scene as
+ this item.
+
+ \sa focusProxy(), setFocus(), hasFocus()
+*/
+void QGraphicsItem::setFocusProxy(QGraphicsItem *item)
+{
+ if (item == d_ptr->focusProxy)
+ return;
+ if (item == this) {
+ qWarning("QGraphicsItem::setFocusProxy: cannot assign self as focus proxy");
+ return;
+ }
+ if (item) {
+ if (item->d_ptr->scene != d_ptr->scene) {
+ qWarning("QGraphicsItem::setFocusProxy: focus proxy must be in same scene");
+ return;
+ }
+ for (QGraphicsItem *f = item->focusProxy(); f != 0; f = f->focusProxy()) {
+ if (f == this) {
+ qWarning("QGraphicsItem::setFocusProxy: %p is already in the focus proxy chain", item);
+ return;
+ }
+ }
+ }
+
+ QGraphicsItem *lastFocusProxy = d_ptr->focusProxy;
+ if (lastFocusProxy)
+ lastFocusProxy->d_ptr->focusProxyRefs.removeOne(&d_ptr->focusProxy);
+ d_ptr->focusProxy = item;
+ if (item)
+ item->d_ptr->focusProxyRefs << &d_ptr->focusProxy;
+}
+
+/*!
+ \since 4.6
+
+ If this item, a child or descendant of this item currently has input
+ focus, this function will return a pointer to that item. If
+ no descendant has input focus, 0 is returned.
+
+ \sa hasFocus(), setFocus(), QWidget::focusWidget()
+*/
+QGraphicsItem *QGraphicsItem::focusItem() const
+{
+ return d_ptr->subFocusItem;
+}
+
+/*!
+ \internal
+
+ Returns this item's focus scope item.
+*/
+QGraphicsItem *QGraphicsItem::focusScopeItem() const
+{
+ return d_ptr->focusScopeItem;
+}
+
+/*!
+ \since 4.4
+ Grabs the mouse input.
+
+ This item will receive all mouse events for the scene until any of the
+ following events occurs:
+
+ \list
+ \o The item becomes invisible
+ \o The item is removed from the scene
+ \o The item is deleted
+ \o The item call ungrabMouse()
+ \o Another item calls grabMouse(); the item will regain the mouse grab
+ when the other item calls ungrabMouse().
+ \endlist
+
+ When an item gains the mouse grab, it receives a QEvent::GrabMouse
+ event. When it loses the mouse grab, it receives a QEvent::UngrabMouse
+ event. These events can be used to detect when your item gains or loses
+ the mouse grab through other means than receiving mouse button events.
+
+ It is almost never necessary to explicitly grab the mouse in Qt, as Qt
+ grabs and releases it sensibly. In particular, Qt grabs the mouse when you
+ press a mouse button, and keeps the mouse grabbed until you release the
+ last mouse button. Also, Qt::Popup widgets implicitly call grabMouse()
+ when shown, and ungrabMouse() when hidden.
+
+ Note that only visible items can grab mouse input. Calling grabMouse() on
+ an invisible item has no effect.
+
+ Keyboard events are not affected.
+
+ \sa QGraphicsScene::mouseGrabberItem(), ungrabMouse(), grabKeyboard()
+*/
+void QGraphicsItem::grabMouse()
+{
+ if (!d_ptr->scene) {
+ qWarning("QGraphicsItem::grabMouse: cannot grab mouse without scene");
+ return;
+ }
+ if (!d_ptr->visible) {
+ qWarning("QGraphicsItem::grabMouse: cannot grab mouse while invisible");
+ return;
+ }
+ d_ptr->scene->d_func()->grabMouse(this);
+}
+
+/*!
+ \since 4.4
+ Releases the mouse grab.
+
+ \sa grabMouse(), ungrabKeyboard()
+*/
+void QGraphicsItem::ungrabMouse()
+{
+ if (!d_ptr->scene) {
+ qWarning("QGraphicsItem::ungrabMouse: cannot ungrab mouse without scene");
+ return;
+ }
+ d_ptr->scene->d_func()->ungrabMouse(this);
+}
+
+/*!
+ \since 4.4
+ Grabs the keyboard input.
+
+ The item will receive all keyboard input to the scene until one of the
+ following events occur:
+
+ \list
+ \o The item becomes invisible
+ \o The item is removed from the scene
+ \o The item is deleted
+ \o The item calls ungrabKeyboard()
+ \o Another item calls grabKeyboard(); the item will regain the keyboard grab
+ when the other item calls ungrabKeyboard().
+ \endlist
+
+ When an item gains the keyboard grab, it receives a QEvent::GrabKeyboard
+ event. When it loses the keyboard grab, it receives a
+ QEvent::UngrabKeyboard event. These events can be used to detect when your
+ item gains or loses the keyboard grab through other means than gaining
+ input focus.
+
+ It is almost never necessary to explicitly grab the keyboard in Qt, as Qt
+ grabs and releases it sensibly. In particular, Qt grabs the keyboard when
+ your item gains input focus, and releases it when your item loses input
+ focus, or when the item is hidden.
+
+ Note that only visible items can grab keyboard input. Calling
+ grabKeyboard() on an invisible item has no effect.
+
+ Keyboard events are not affected.
+
+ \sa ungrabKeyboard(), grabMouse(), setFocus()
+*/
+void QGraphicsItem::grabKeyboard()
+{
+ if (!d_ptr->scene) {
+ qWarning("QGraphicsItem::grabKeyboard: cannot grab keyboard without scene");
+ return;
+ }
+ if (!d_ptr->visible) {
+ qWarning("QGraphicsItem::grabKeyboard: cannot grab keyboard while invisible");
+ return;
+ }
+ d_ptr->scene->d_func()->grabKeyboard(this);
+}
+
+/*!
+ \since 4.4
+ Releases the keyboard grab.
+
+ \sa grabKeyboard(), ungrabMouse()
+*/
+void QGraphicsItem::ungrabKeyboard()
+{
+ if (!d_ptr->scene) {
+ qWarning("QGraphicsItem::ungrabKeyboard: cannot ungrab keyboard without scene");
+ return;
+ }
+ d_ptr->scene->d_func()->ungrabKeyboard(this);
+}
+
+/*!
+ Returns the position of the item in parent coordinates. If the item has no
+ parent, its position is given in scene coordinates.
+
+ The position of the item describes its origin (local coordinate
+ (0, 0)) in parent coordinates; this function returns the same as
+ mapToParent(0, 0).
+
+ For convenience, you can also call scenePos() to determine the
+ item's position in scene coordinates, regardless of its parent.
+
+ \sa x(), y(), setPos(), transform(), {The Graphics View Coordinate System}
+*/
+QPointF QGraphicsItem::pos() const
+{
+ return d_ptr->pos;
+}
+
+/*!
+ \fn QGraphicsItem::x() const
+
+ This convenience function is equivalent to calling pos().x().
+
+ \sa y()
+*/
+
+/*!
+ \since 4.6
+
+ Set's the \a x coordinate of the item's position. Equivalent to
+ calling setPos(x, y()).
+
+ \sa x(), setPos()
+*/
+void QGraphicsItem::setX(qreal x)
+{
+ if (d_ptr->inDestructor)
+ return;
+
+ if (qIsNaN(x))
+ return;
+
+ setPos(QPointF(x, d_ptr->pos.y()));
+}
+
+/*!
+ \fn QGraphicsItem::y() const
+
+ This convenience function is equivalent to calling pos().y().
+
+ \sa x()
+*/
+
+/*!
+ \since 4.6
+
+ Set's the \a y coordinate of the item's position. Equivalent to
+ calling setPos(x(), y).
+
+ \sa x(), setPos()
+*/
+void QGraphicsItem::setY(qreal y)
+{
+ if (d_ptr->inDestructor)
+ return;
+
+ if (qIsNaN(y))
+ return;
+
+ setPos(QPointF(d_ptr->pos.x(), y));
+}
+
+/*!
+ Returns the item's position in scene coordinates. This is
+ equivalent to calling \c mapToScene(0, 0).
+
+ \sa pos(), sceneTransform(), {The Graphics View Coordinate System}
+*/
+QPointF QGraphicsItem::scenePos() const
+{
+ return mapToScene(0, 0);
+}
+
+/*!
+ \internal
+
+ Sets the position \a pos.
+*/
+void QGraphicsItemPrivate::setPosHelper(const QPointF &pos)
+{
+ Q_Q(QGraphicsItem);
+ inSetPosHelper = 1;
+ if (scene)
+ q->prepareGeometryChange();
+ QPointF oldPos = this->pos;
+ this->pos = pos;
+ dirtySceneTransform = 1;
+ inSetPosHelper = 0;
+ if (isObject) {
+ if (pos.x() != oldPos.x())
+ emit static_cast<QGraphicsObject *>(q_ptr)->xChanged();
+ if (pos.y() != oldPos.y())
+ emit static_cast<QGraphicsObject *>(q_ptr)->yChanged();
+ }
+}
+
+/*!
+ \internal
+
+ Sets the transform \a transform.
+*/
+void QGraphicsItemPrivate::setTransformHelper(const QTransform &transform)
+{
+ q_ptr->prepareGeometryChange();
+ transformData->transform = transform;
+ dirtySceneTransform = 1;
+ transformChanged();
+}
+
+/*!
+ Sets the position of the item to \a pos, which is in parent
+ coordinates. For items with no parent, \a pos is in scene
+ coordinates.
+
+ The position of the item describes its origin (local coordinate
+ (0, 0)) in parent coordinates.
+
+ \sa pos(), scenePos(), {The Graphics View Coordinate System}
+*/
+void QGraphicsItem::setPos(const QPointF &pos)
+{
+ if (d_ptr->pos == pos)
+ return;
+
+ if (d_ptr->inDestructor)
+ return;
+
+ // Update and repositition.
+ if (!(d_ptr->flags & (ItemSendsGeometryChanges | ItemSendsScenePositionChanges))) {
+ d_ptr->setPosHelper(pos);
+ if (d_ptr->isWidget)
+ static_cast<QGraphicsWidget *>(this)->d_func()->setGeometryFromSetPos();
+ if (d_ptr->scenePosDescendants)
+ d_ptr->sendScenePosChange();
+ return;
+ }
+
+ // Notify the item that the position is changing.
+ const QVariant newPosVariant(itemChange(ItemPositionChange, QVariant::fromValue<QPointF>(pos)));
+ QPointF newPos = newPosVariant.toPointF();
+ if (newPos == d_ptr->pos)
+ return;
+
+ // Update and repositition.
+ d_ptr->setPosHelper(newPos);
+
+ // Send post-notification.
+ itemChange(QGraphicsItem::ItemPositionHasChanged, newPosVariant);
+ d_ptr->sendScenePosChange();
+}
+
+/*!
+ \fn void QGraphicsItem::setPos(qreal x, qreal y)
+ \overload
+
+ This convenience function is equivalent to calling setPos(QPointF(\a x, \a
+ y)).
+*/
+
+/*!
+ \fn void QGraphicsItem::moveBy(qreal dx, qreal dy)
+
+ Moves the item by \a dx points horizontally, and \a dy point
+ vertically. This function is equivalent to calling setPos(pos() +
+ QPointF(\a dx, \a dy)).
+*/
+
+/*!
+ If this item is part of a scene that is viewed by a QGraphicsView, this
+ convenience function will attempt to scroll the view to ensure that \a
+ rect is visible inside the view's viewport. If \a rect is a null rect (the
+ default), QGraphicsItem will default to the item's bounding rect. \a xmargin
+ and \a ymargin are the number of pixels the view should use for margins.
+
+ If the specified rect cannot be reached, the contents are scrolled to the
+ nearest valid position.
+
+ If this item is not viewed by a QGraphicsView, this function does nothing.
+
+ \sa QGraphicsView::ensureVisible()
+*/
+void QGraphicsItem::ensureVisible(const QRectF &rect, int xmargin, int ymargin)
+{
+ if (d_ptr->scene) {
+ QRectF sceneRect;
+ if (!rect.isNull())
+ sceneRect = sceneTransform().mapRect(rect);
+ else
+ sceneRect = sceneBoundingRect();
+ foreach (QGraphicsView *view, d_ptr->scene->d_func()->views)
+ view->ensureVisible(sceneRect, xmargin, ymargin);
+ }
+}
+
+/*!
+ \fn void QGraphicsItem::ensureVisible(qreal x, qreal y, qreal w, qreal h,
+ int xmargin = 50, int ymargin = 50)
+
+ This convenience function is equivalent to calling
+ ensureVisible(QRectF(\a x, \a y, \a w, \a h), \a xmargin, \a ymargin):
+*/
+
+/*!
+ \obsolete
+
+ Returns the item's affine transformation matrix. This is a subset or the
+ item's full transformation matrix, and might not represent the item's full
+ transformation.
+
+ Use transform() instead.
+
+ \sa setTransform(), sceneTransform()
+*/
+QMatrix QGraphicsItem::matrix() const
+{
+ return transform().toAffine();
+}
+
+/*!
+ \since 4.3
+
+ Returns this item's transformation matrix.
+
+ The transformation matrix is combined with the item's rotation(), scale()
+ and transformations() into a combined transformations for the item.
+
+ The default transformation matrix is an identity matrix.
+
+ \sa setTransform(), sceneTransform()
+*/
+QTransform QGraphicsItem::transform() const
+{
+ if (!d_ptr->transformData)
+ return QTransform();
+ return d_ptr->transformData->transform;
+}
+
+/*!
+ \since 4.6
+
+ Returns the clockwise rotation, in degrees, around the Z axis. The default
+ value is 0 (i.e., the item is not rotated).
+
+ The rotation is combined with the item's scale(), transform() and
+ transformations() to map the item's coordinate system to the parent item.
+
+ \sa setRotation(), transformOriginPoint(), {Transformations}
+*/
+qreal QGraphicsItem::rotation() const
+{
+ if (!d_ptr->transformData)
+ return 0;
+ return d_ptr->transformData->rotation;
+}
+
+/*!
+ \since 4.6
+
+ Sets the clockwise rotation \a angle, in degrees, around the Z axis. The
+ default value is 0 (i.e., the item is not rotated). Assigning a negative
+ value will rotate the item counter-clockwise. Normally the rotation angle
+ is in the range (-360, 360), but it's also possible to assign values
+ outside of this range (e.g., a rotation of 370 degrees is the same as a
+ rotation of 10 degrees).
+
+ The item is rotated around its transform origin point, which by default
+ is (0, 0). You can select a different transformation origin by calling
+ setTransformOriginPoint().
+
+ The rotation is combined with the item's scale(), transform() and
+ transformations() to map the item's coordinate system to the parent item.
+
+ \sa rotation(), setTransformOriginPoint(), {Transformations}
+*/
+void QGraphicsItem::setRotation(qreal angle)
+{
+ prepareGeometryChange();
+ qreal newRotation = angle;
+
+ if (d_ptr->flags & ItemSendsGeometryChanges) {
+ // Notify the item that the rotation is changing.
+ const QVariant newRotationVariant(itemChange(ItemRotationChange, angle));
+ newRotation = newRotationVariant.toReal();
+ }
+
+ if (!d_ptr->transformData)
+ d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
+
+ if (d_ptr->transformData->rotation == newRotation)
+ return;
+
+ d_ptr->transformData->rotation = newRotation;
+ d_ptr->transformData->onlyTransform = false;
+ d_ptr->dirtySceneTransform = 1;
+
+ // Send post-notification.
+ if (d_ptr->flags & ItemSendsGeometryChanges)
+ itemChange(ItemRotationHasChanged, newRotation);
+
+ if (d_ptr->isObject)
+ emit static_cast<QGraphicsObject *>(this)->rotationChanged();
+
+ d_ptr->transformChanged();
+}
+
+/*!
+ \since 4.6
+
+ Returns the scale factor of the item. The default scale factor is 1.0
+ (i.e., the item is not scaled).
+
+ The scale is combined with the item's rotation(), transform() and
+ transformations() to map the item's coordinate system to the parent item.
+
+ \sa setScale(), rotation(), {Transformations}
+*/
+qreal QGraphicsItem::scale() const
+{
+ if (!d_ptr->transformData)
+ return 1.;
+ return d_ptr->transformData->scale;
+}
+
+/*!
+ \since 4.6
+
+ Sets the scale \a factor of the item. The default scale factor is 1.0
+ (i.e., the item is not scaled). A scale factor of 0.0 will collapse the
+ item to a single point. If you provide a negative scale factor, the
+ item will be flipped and mirrored (i.e., rotated 180 degrees).
+
+ The item is scaled around its transform origin point, which by default
+ is (0, 0). You can select a different transformation origin by calling
+ setTransformOriginPoint().
+
+ The scale is combined with the item's rotation(), transform() and
+ transformations() to map the item's coordinate system to the parent item.
+
+ \sa scale(), setTransformOriginPoint(), {Transformations Example}
+*/
+void QGraphicsItem::setScale(qreal factor)
+{
+ prepareGeometryChange();
+ qreal newScale = factor;
+
+ if (d_ptr->flags & ItemSendsGeometryChanges) {
+ // Notify the item that the scale is changing.
+ const QVariant newScaleVariant(itemChange(ItemScaleChange, factor));
+ newScale = newScaleVariant.toReal();
+ }
+
+ if (!d_ptr->transformData)
+ d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
+
+ if (d_ptr->transformData->scale == newScale)
+ return;
+
+ d_ptr->transformData->scale = newScale;
+ d_ptr->transformData->onlyTransform = false;
+ d_ptr->dirtySceneTransform = 1;
+
+ // Send post-notification.
+ if (d_ptr->flags & ItemSendsGeometryChanges)
+ itemChange(ItemScaleHasChanged, newScale);
+
+ if (d_ptr->isObject)
+ emit static_cast<QGraphicsObject *>(this)->scaleChanged();
+
+ d_ptr->transformChanged();
+}
+
+
+/*!
+ \since 4.6
+
+ Returns a list of graphics transforms that currently apply to this item.
+
+ QGraphicsTransform is for applying and controlling a chain of individual
+ transformation operations on an item. It's particularly useful in
+ animations, where each transform operation needs to be interpolated
+ independently, or differently.
+
+ The transformations are combined with the item's rotation(), scale() and
+ transform() to map the item's coordinate system to the parent item.
+
+ \sa scale(), rotation(), transformOriginPoint(), {Transformations}
+*/
+QList<QGraphicsTransform *> QGraphicsItem::transformations() const
+{
+ if (!d_ptr->transformData)
+ return QList<QGraphicsTransform *>();
+ return d_ptr->transformData->graphicsTransforms;
+}
+
+/*!
+ \since 4.6
+
+ Sets a list of graphics \a transformations (QGraphicsTransform) that
+ currently apply to this item.
+
+ If all you want is to rotate or scale an item, you should call setRotation()
+ or setScale() instead. If you want to set an arbitrary transformation on
+ an item, you can call setTransform().
+
+ QGraphicsTransform is for applying and controlling a chain of individual
+ transformation operations on an item. It's particularly useful in
+ animations, where each transform operation needs to be interpolated
+ independently, or differently.
+
+ The transformations are combined with the item's rotation(), scale() and
+ transform() to map the item's coordinate system to the parent item.
+
+ \sa scale(), setTransformOriginPoint(), {Transformations}
+*/
+void QGraphicsItem::setTransformations(const QList<QGraphicsTransform *> &transformations)
+{
+ prepareGeometryChange();
+ if (!d_ptr->transformData)
+ d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
+ d_ptr->transformData->graphicsTransforms = transformations;
+ for (int i = 0; i < transformations.size(); ++i)
+ transformations.at(i)->d_func()->setItem(this);
+ d_ptr->transformData->onlyTransform = false;
+ d_ptr->dirtySceneTransform = 1;
+ d_ptr->transformChanged();
+}
+
+/*!
+ \internal
+*/
+void QGraphicsItemPrivate::prependGraphicsTransform(QGraphicsTransform *t)
+{
+ if (!transformData)
+ transformData = new QGraphicsItemPrivate::TransformData;
+ if (!transformData->graphicsTransforms.contains(t))
+ transformData->graphicsTransforms.prepend(t);
+
+ Q_Q(QGraphicsItem);
+ t->d_func()->setItem(q);
+ transformData->onlyTransform = false;
+ dirtySceneTransform = 1;
+ transformChanged();
+}
+
+/*!
+ \internal
+*/
+void QGraphicsItemPrivate::appendGraphicsTransform(QGraphicsTransform *t)
+{
+ if (!transformData)
+ transformData = new QGraphicsItemPrivate::TransformData;
+ if (!transformData->graphicsTransforms.contains(t))
+ transformData->graphicsTransforms.append(t);
+
+ Q_Q(QGraphicsItem);
+ t->d_func()->setItem(q);
+ transformData->onlyTransform = false;
+ dirtySceneTransform = 1;
+ transformChanged();
+}
+
+/*!
+ \since 4.6
+
+ Returns the origin point for the transformation in item coordinates.
+
+ The default is QPointF(0,0).
+
+ \sa setTransformOriginPoint(), {Transformations}
+*/
+QPointF QGraphicsItem::transformOriginPoint() const
+{
+ if (!d_ptr->transformData)
+ return QPointF(0,0);
+ return QPointF(d_ptr->transformData->xOrigin, d_ptr->transformData->yOrigin);
+}
+
+/*!
+ \since 4.6
+
+ Sets the \a origin point for the transformation in item coordinates.
+
+ \sa transformOriginPoint(), {Transformations}
+*/
+void QGraphicsItem::setTransformOriginPoint(const QPointF &origin)
+{
+ prepareGeometryChange();
+ QPointF newOrigin = origin;
+
+ if (d_ptr->flags & ItemSendsGeometryChanges) {
+ // Notify the item that the origin point is changing.
+ const QVariant newOriginVariant(itemChange(ItemTransformOriginPointChange,
+ QVariant::fromValue<QPointF>(origin)));
+ newOrigin = newOriginVariant.toPointF();
+ }
+
+ if (!d_ptr->transformData)
+ d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
+
+ if (d_ptr->transformData->xOrigin == newOrigin.x()
+ && d_ptr->transformData->yOrigin == newOrigin.y()) {
+ return;
+ }
+
+ d_ptr->transformData->xOrigin = newOrigin.x();
+ d_ptr->transformData->yOrigin = newOrigin.y();
+ d_ptr->transformData->onlyTransform = false;
+ d_ptr->dirtySceneTransform = 1;
+
+ // Send post-notification.
+ if (d_ptr->flags & ItemSendsGeometryChanges)
+ itemChange(ItemTransformOriginPointHasChanged, QVariant::fromValue<QPointF>(newOrigin));
+}
+
+/*!
+ \fn void QGraphicsItem::setTransformOriginPoint(qreal x, qreal y)
+
+ \since 4.6
+ \overload
+
+ Sets the origin point for the transformation in item coordinates.
+ This is equivalent to calling setTransformOriginPoint(QPointF(\a x, \a y)).
+
+ \sa setTransformOriginPoint(), {Transformations}
+*/
+
+
+/*!
+ \obsolete
+
+ Use sceneTransform() instead.
+
+ \sa transform(), setTransform(), scenePos(), {The Graphics View Coordinate System}
+*/
+QMatrix QGraphicsItem::sceneMatrix() const
+{
+ d_ptr->ensureSceneTransform();
+ return d_ptr->sceneTransform.toAffine();
+}
+
+
+/*!
+ \since 4.3
+
+ Returns this item's scene transformation matrix. This matrix can be used
+ to map coordinates and geometrical shapes from this item's local
+ coordinate system to the scene's coordinate system. To map coordinates
+ from the scene, you must first invert the returned matrix.
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 4
+
+ Unlike transform(), which returns only an item's local transformation, this
+ function includes the item's (and any parents') position, and all the transfomation properties.
+
+ \sa transform(), setTransform(), scenePos(), {The Graphics View Coordinate System}, {Transformations}
+*/
+QTransform QGraphicsItem::sceneTransform() const
+{
+ d_ptr->ensureSceneTransform();
+ return d_ptr->sceneTransform;
+}
+
+/*!
+ \since 4.3
+
+ Returns this item's device transformation matrix, using \a
+ viewportTransform to map from scene to device coordinates. This matrix can
+ be used to map coordinates and geometrical shapes from this item's local
+ coordinate system to the viewport's (or any device's) coordinate
+ system. To map coordinates from the viewport, you must first invert the
+ returned matrix.
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 5
+
+ This function is the same as combining this item's scene transform with
+ the view's viewport transform, but it also understands the
+ ItemIgnoresTransformations flag. The device transform can be used to do
+ accurate coordinate mapping (and collision detection) for untransformable
+ items.
+
+ \sa transform(), setTransform(), scenePos(), {The Graphics View Coordinate
+ System}, itemTransform()
+*/
+QTransform QGraphicsItem::deviceTransform(const QTransform &viewportTransform) const
+{
+ // Ensure we return the standard transform if we're not untransformable.
+ if (!d_ptr->itemIsUntransformable()) {
+ d_ptr->ensureSceneTransform();
+ return d_ptr->sceneTransform * viewportTransform;
+ }
+
+ // Find the topmost item that ignores view transformations.
+ const QGraphicsItem *untransformedAncestor = this;
+ QList<const QGraphicsItem *> parents;
+ while (untransformedAncestor && ((untransformedAncestor->d_ptr->ancestorFlags
+ & QGraphicsItemPrivate::AncestorIgnoresTransformations))) {
+ parents.prepend(untransformedAncestor);
+ untransformedAncestor = untransformedAncestor->parentItem();
+ }
+
+ if (!untransformedAncestor) {
+ // Assert in debug mode, continue in release.
+ Q_ASSERT_X(untransformedAncestor, "QGraphicsItem::deviceTransform",
+ "Invalid object structure!");
+ return QTransform();
+ }
+
+ // First translate the base untransformable item.
+ untransformedAncestor->d_ptr->ensureSceneTransform();
+ QPointF mappedPoint = (untransformedAncestor->d_ptr->sceneTransform * viewportTransform).map(QPointF(0, 0));
+
+ // COMBINE
+ QTransform matrix = QTransform::fromTranslate(mappedPoint.x(), mappedPoint.y());
+ if (untransformedAncestor->d_ptr->transformData)
+ matrix = untransformedAncestor->d_ptr->transformData->computedFullTransform(&matrix);
+
+ // Then transform and translate all children.
+ for (int i = 0; i < parents.size(); ++i) {
+ const QGraphicsItem *parent = parents.at(i);
+ parent->d_ptr->combineTransformFromParent(&matrix);
+ }
+
+ return matrix;
+}
+
+/*!
+ \since 4.5
+
+ Returns a QTransform that maps coordinates from this item to \a other. If
+ \a ok is not null, and if there is no such transform, the boolean pointed
+ to by \a ok will be set to false; otherwise it will be set to true.
+
+ This transform provides an alternative to the mapToItem() or mapFromItem()
+ functions, by returning the appropriate transform so that you can map
+ shapes and coordinates yourself. It also helps you write more efficient
+ code when repeatedly mapping between the same two items.
+
+ \note In rare circumstances, there is no transform that maps between two
+ items.
+
+ \sa mapToItem(), mapFromItem(), deviceTransform()
+*/
+QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) const
+{
+ // Catch simple cases first.
+ if (other == 0) {
+ qWarning("QGraphicsItem::itemTransform: null pointer passed");
+ return QTransform();
+ }
+ if (other == this) {
+ if (ok)
+ *ok = true;
+ return QTransform();
+ }
+
+ QGraphicsItem *parent = d_ptr->parent;
+ const QGraphicsItem *otherParent = other->d_ptr->parent;
+
+ // This is other's child
+ if (parent == other) {
+ if (ok)
+ *ok = true;
+ QTransform x;
+ d_ptr->combineTransformFromParent(&x);
+ return x;
+ }
+
+ // This is other's parent
+ if (otherParent == this) {
+ const QPointF &otherPos = other->d_ptr->pos;
+ if (other->d_ptr->transformData) {
+ QTransform otherToParent;
+ other->d_ptr->combineTransformFromParent(&otherToParent);
+ return otherToParent.inverted(ok);
+ }
+ if (ok)
+ *ok = true;
+ return QTransform::fromTranslate(-otherPos.x(), -otherPos.y());
+ }
+
+ // Siblings
+ if (parent == otherParent) {
+ // COMBINE
+ const QPointF &itemPos = d_ptr->pos;
+ const QPointF &otherPos = other->d_ptr->pos;
+ if (!d_ptr->transformData && !other->d_ptr->transformData) {
+ QPointF delta = itemPos - otherPos;
+ if (ok)
+ *ok = true;
+ return QTransform::fromTranslate(delta.x(), delta.y());
+ }
+
+ QTransform itemToParent;
+ d_ptr->combineTransformFromParent(&itemToParent);
+ QTransform otherToParent;
+ other->d_ptr->combineTransformFromParent(&otherToParent);
+ return itemToParent * otherToParent.inverted(ok);
+ }
+
+ // Find the closest common ancestor. If the two items don't share an
+ // ancestor, then the only way is to combine their scene transforms.
+ const QGraphicsItem *commonAncestor = commonAncestorItem(other);
+ if (!commonAncestor) {
+ d_ptr->ensureSceneTransform();
+ other->d_ptr->ensureSceneTransform();
+ return d_ptr->sceneTransform * other->d_ptr->sceneTransform.inverted(ok);
+ }
+
+ // If the two items are cousins (in sibling branches), map both to the
+ // common ancestor, and combine the two transforms.
+ bool cousins = other != commonAncestor && this != commonAncestor;
+ if (cousins) {
+ bool good = false;
+ QTransform thisToScene = itemTransform(commonAncestor, &good);
+ QTransform otherToScene(Qt::Uninitialized);
+ if (good)
+ otherToScene = other->itemTransform(commonAncestor, &good);
+ if (!good) {
+ if (ok)
+ *ok = false;
+ return QTransform();
+ }
+ return thisToScene * otherToScene.inverted(ok);
+ }
+
+ // One is an ancestor of the other; walk the chain.
+ bool parentOfOther = isAncestorOf(other);
+ const QGraphicsItem *child = parentOfOther ? other : this;
+ const QGraphicsItem *root = parentOfOther ? this : other;
+
+ QTransform x;
+ const QGraphicsItem *p = child;
+ do {
+ p->d_ptr.data()->combineTransformToParent(&x);
+ } while ((p = p->d_ptr->parent) && p != root);
+ if (parentOfOther)
+ return x.inverted(ok);
+ if (ok)
+ *ok = true;
+ return x;
+}
+
+/*!
+ \obsolete
+
+ Sets the item's affine transformation matrix. This is a subset or the
+ item's full transformation matrix, and might not represent the item's full
+ transformation.
+
+ Use setTransform() instead.
+
+ \sa transform(), {The Graphics View Coordinate System}
+*/
+void QGraphicsItem::setMatrix(const QMatrix &matrix, bool combine)
+{
+ if (!d_ptr->transformData)
+ d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
+
+ QTransform newTransform(combine ? QTransform(matrix) * d_ptr->transformData->transform : QTransform(matrix));
+ if (d_ptr->transformData->transform == newTransform)
+ return;
+
+ // Update and set the new transformation.
+ if (!(d_ptr->flags & ItemSendsGeometryChanges)) {
+ d_ptr->setTransformHelper(newTransform);
+ return;
+ }
+
+ // Notify the item that the transformation matrix is changing.
+ const QVariant newMatrixVariant = QVariant::fromValue<QMatrix>(newTransform.toAffine());
+ newTransform = QTransform(qvariant_cast<QMatrix>(itemChange(ItemMatrixChange, newMatrixVariant)));
+ if (d_ptr->transformData->transform == newTransform)
+ return;
+
+ // Update and set the new transformation.
+ d_ptr->setTransformHelper(newTransform);
+
+ // Send post-notification.
+ itemChange(ItemTransformHasChanged, QVariant::fromValue<QTransform>(newTransform));
+}
+
+/*!
+ \since 4.3
+
+ Sets the item's current transformation matrix to \a matrix.
+
+ If \a combine is true, then \a matrix is combined with the current matrix;
+ otherwise, \a matrix \e replaces the current matrix. \a combine is false
+ by default.
+
+ To simplify interation with items using a transformed view, QGraphicsItem
+ provides mapTo... and mapFrom... functions that can translate between
+ items' and the scene's coordinates. For example, you can call mapToScene()
+ to map an item coordiate to a scene coordinate, or mapFromScene() to map
+ from scene coordinates to item coordinates.
+
+ The transformation matrix is combined with the item's rotation(), scale()
+ and transformations() into a combined transformation that maps the item's
+ coordinate system to its parent.
+
+ \sa transform(), setRotation(), setScale(), setTransformOriginPoint(), {The Graphics View Coordinate System}, {Transformations}
+*/
+void QGraphicsItem::setTransform(const QTransform &matrix, bool combine)
+{
+ if (!d_ptr->transformData)
+ d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
+
+ QTransform newTransform(combine ? matrix * d_ptr->transformData->transform : matrix);
+ if (d_ptr->transformData->transform == newTransform)
+ return;
+
+ // Update and set the new transformation.
+ if (!(d_ptr->flags & (ItemSendsGeometryChanges | ItemSendsScenePositionChanges))) {
+ d_ptr->setTransformHelper(newTransform);
+ if (d_ptr->scenePosDescendants)
+ d_ptr->sendScenePosChange();
+ return;
+ }
+
+ // Notify the item that the transformation matrix is changing.
+ const QVariant newTransformVariant(itemChange(ItemTransformChange,
+ QVariant::fromValue<QTransform>(newTransform)));
+ newTransform = qvariant_cast<QTransform>(newTransformVariant);
+ if (d_ptr->transformData->transform == newTransform)
+ return;
+
+ // Update and set the new transformation.
+ d_ptr->setTransformHelper(newTransform);
+
+ // Send post-notification.
+ itemChange(ItemTransformHasChanged, newTransformVariant);
+ d_ptr->sendScenePosChange();
+}
+
+/*!
+ \obsolete
+
+ Use resetTransform() instead.
+*/
+void QGraphicsItem::resetMatrix()
+{
+ resetTransform();
+}
+
+/*!
+ \since 4.3
+
+ Resets this item's transformation matrix to the identity matrix or
+ all the transformation properties to their default values.
+ This is equivalent to calling \c setTransform(QTransform()).
+
+ \sa setTransform(), transform()
+*/
+void QGraphicsItem::resetTransform()
+{
+ setTransform(QTransform(), false);
+}
+
+/*!
+ \obsolete
+
+ Use
+
+ \code
+ setRotation(rotation() + angle);
+ \endcode
+
+ instead.
+
+ Rotates the current item transformation \a angle degrees clockwise around
+ its origin. To translate around an arbitrary point (x, y), you need to
+ combine translation and rotation with setTransform().
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 6
+
+ \sa setTransform(), transform(), scale(), shear(), translate()
+*/
+void QGraphicsItem::rotate(qreal angle)
+{
+ setTransform(QTransform().rotate(angle), true);
+}
+
+/*!
+ \obsolete
+
+ Use
+
+ \code
+ setTransform(QTransform::fromScale(sx, sy), true);
+ \endcode
+
+ instead.
+
+ Scales the current item transformation by (\a sx, \a sy) around its
+ origin. To scale from an arbitrary point (x, y), you need to combine
+ translation and scaling with setTransform().
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 7
+
+ \sa setTransform(), transform()
+*/
+void QGraphicsItem::scale(qreal sx, qreal sy)
+{
+ setTransform(QTransform::fromScale(sx, sy), true);
+}
+
+/*!
+ \obsolete
+
+ Use
+
+ \code
+ setTransform(QTransform().shear(sh, sv), true);
+ \endcode
+
+ instead.
+
+ Shears the current item transformation by (\a sh, \a sv).
+
+ \sa setTransform(), transform()
+*/
+void QGraphicsItem::shear(qreal sh, qreal sv)
+{
+ setTransform(QTransform().shear(sh, sv), true);
+}
+
+/*!
+ \obsolete
+
+ Use setPos() or setTransformOriginPoint() instead. For identical
+ behavior, use
+
+ \code
+ setTransform(QTransform::fromTranslate(dx, dy), true);
+ \endcode
+
+ Translates the current item transformation by (\a dx, \a dy).
+
+ If all you want is to move an item, you should call moveBy() or
+ setPos() instead; this function changes the item's translation,
+ which is conceptually separate from its position.
+
+ \sa setTransform(), transform()
+*/
+void QGraphicsItem::translate(qreal dx, qreal dy)
+{
+ setTransform(QTransform::fromTranslate(dx, dy), true);
+}
+
+/*!
+ This virtual function is called twice for all items by the
+ QGraphicsScene::advance() slot. In the first phase, all items are called
+ with \a phase == 0, indicating that items on the scene are about to
+ advance, and then all items are called with \a phase == 1. Reimplement
+ this function to update your item if you need simple scene-controlled
+ animation.
+
+ The default implementation does nothing.
+
+ For individual item animation, an alternative to this function is to
+ either use QGraphicsItemAnimation, or to multiple-inherit from QObject and
+ QGraphicsItem, and animate your item using QObject::startTimer() and
+ QObject::timerEvent().
+
+ \sa QGraphicsItemAnimation, QTimeLine
+*/
+void QGraphicsItem::advance(int phase)
+{
+ Q_UNUSED(phase);
+}
+
+/*!
+ Returns the Z-value of the item. The Z-value affects the stacking order of
+ sibling (neighboring) items.
+
+ The default Z-value is 0.
+
+ \sa setZValue(), {QGraphicsItem#Sorting}{Sorting}, stackBefore(), ItemStacksBehindParent
+*/
+qreal QGraphicsItem::zValue() const
+{
+ return d_ptr->z;
+}
+
+/*!
+ Sets the Z-value of the item to \a z. The Z value decides the stacking
+ order of sibling (neighboring) items. A sibling item of high Z value will
+ always be drawn on top of another sibling item with a lower Z value.
+
+ If you restore the Z value, the item's insertion order will decide its
+ stacking order.
+
+ The Z-value does not affect the item's size in any way.
+
+ The default Z-value is 0.
+
+ \sa zValue(), {QGraphicsItem#Sorting}{Sorting}, stackBefore(), ItemStacksBehindParent
+*/
+void QGraphicsItem::setZValue(qreal z)
+{
+ const QVariant newZVariant(itemChange(ItemZValueChange, z));
+ qreal newZ = newZVariant.toReal();
+ if (newZ == d_ptr->z)
+ return;
+
+ if (d_ptr->scene && d_ptr->scene->d_func()->indexMethod != QGraphicsScene::NoIndex) {
+ // Z Value has changed, we have to notify the index.
+ d_ptr->scene->d_func()->index->itemChange(this, ItemZValueChange, &newZ);
+ }
+
+ d_ptr->z = newZ;
+ if (d_ptr->parent)
+ d_ptr->parent->d_ptr->needSortChildren = 1;
+ else if (d_ptr->scene)
+ d_ptr->scene->d_func()->needSortTopLevelItems = 1;
+
+ if (d_ptr->scene)
+ d_ptr->scene->d_func()->markDirty(this, QRectF(), /*invalidateChildren=*/true);
+
+ itemChange(ItemZValueHasChanged, newZVariant);
+
+ if (d_ptr->flags & ItemNegativeZStacksBehindParent)
+ setFlag(QGraphicsItem::ItemStacksBehindParent, z < qreal(0.0));
+
+ if (d_ptr->isObject)
+ emit static_cast<QGraphicsObject *>(this)->zChanged();
+}
+
+/*!
+ \internal
+
+ Ensures that the list of children is sorted by insertion order, and that
+ the siblingIndexes are packed (no gaps), and start at 0.
+
+ ### This function is almost identical to
+ QGraphicsScenePrivate::ensureSequentialTopLevelSiblingIndexes().
+*/
+void QGraphicsItemPrivate::ensureSequentialSiblingIndex()
+{
+ if (!sequentialOrdering) {
+ qSort(children.begin(), children.end(), insertionOrder);
+ sequentialOrdering = 1;
+ needSortChildren = 1;
+ }
+ if (holesInSiblingIndex) {
+ holesInSiblingIndex = 0;
+ for (int i = 0; i < children.size(); ++i)
+ children[i]->d_ptr->siblingIndex = i;
+ }
+}
+
+/*!
+ \internal
+*/
+inline void QGraphicsItemPrivate::sendScenePosChange()
+{
+ Q_Q(QGraphicsItem);
+ if (scene) {
+ if (flags & QGraphicsItem::ItemSendsScenePositionChanges)
+ q->itemChange(QGraphicsItem::ItemScenePositionHasChanged, q->scenePos());
+ if (scenePosDescendants) {
+ foreach (QGraphicsItem *item, scene->d_func()->scenePosItems) {
+ if (q->isAncestorOf(item))
+ item->itemChange(QGraphicsItem::ItemScenePositionHasChanged, item->scenePos());
+ }
+ }
+ }
+}
+
+/*!
+ \since 4.6
+
+ Stacks this item before \a sibling, which must be a sibling item (i.e., the
+ two items must share the same parent item, or must both be toplevel items).
+ The \a sibling must have the same Z value as this item, otherwise calling
+ this function will have no effect.
+
+ By default, all sibling items are stacked by insertion order (i.e., the
+ first item you add is drawn before the next item you add). If two items' Z
+ values are different, then the item with the highest Z value is drawn on
+ top. When the Z values are the same, the insertion order will decide the
+ stacking order.
+
+ \sa setZValue(), ItemStacksBehindParent, {QGraphicsItem#Sorting}{Sorting}
+*/
+void QGraphicsItem::stackBefore(const QGraphicsItem *sibling)
+{
+ if (sibling == this)
+ return;
+ if (!sibling || d_ptr->parent != sibling->parentItem()) {
+ qWarning("QGraphicsItem::stackUnder: cannot stack under %p, which must be a sibling", sibling);
+ return;
+ }
+ QList<QGraphicsItem *> *siblings = d_ptr->parent
+ ? &d_ptr->parent->d_ptr->children
+ : (d_ptr->scene ? &d_ptr->scene->d_func()->topLevelItems : 0);
+ if (!siblings) {
+ qWarning("QGraphicsItem::stackUnder: cannot stack under %p, which must be a sibling", sibling);
+ return;
+ }
+
+ // First, make sure that the sibling indexes have no holes. This also
+ // marks the children list for sorting.
+ if (d_ptr->parent)
+ d_ptr->parent->d_ptr->ensureSequentialSiblingIndex();
+ else
+ d_ptr->scene->d_func()->ensureSequentialTopLevelSiblingIndexes();
+
+ // Only move items with the same Z value, and that need moving.
+ int siblingIndex = sibling->d_ptr->siblingIndex;
+ int myIndex = d_ptr->siblingIndex;
+ if (myIndex >= siblingIndex) {
+ siblings->move(myIndex, siblingIndex);
+ // Fixup the insertion ordering.
+ for (int i = 0; i < siblings->size(); ++i) {
+ int &index = siblings->at(i)->d_ptr->siblingIndex;
+ if (i != siblingIndex && index >= siblingIndex && index <= myIndex)
+ ++index;
+ }
+ d_ptr->siblingIndex = siblingIndex;
+ for (int i = 0; i < siblings->size(); ++i) {
+ int &index = siblings->at(i)->d_ptr->siblingIndex;
+ if (i != siblingIndex && index >= siblingIndex && index <= myIndex)
+ siblings->at(i)->d_ptr->siblingOrderChange();
+ }
+ d_ptr->siblingOrderChange();
+ }
+}
+
+/*!
+ Returns the bounding rect of this item's descendants (i.e., its
+ children, their children, etc.) in local coordinates. The
+ rectangle will contain all descendants after they have been mapped
+ to local coordinates. If the item has no children, this function
+ returns an empty QRectF.
+
+ This does not include this item's own bounding rect; it only returns
+ its descendants' accumulated bounding rect. If you need to include this
+ item's bounding rect, you can add boundingRect() to childrenBoundingRect()
+ using QRectF::operator|().
+
+ This function is linear in complexity; it determines the size of the
+ returned bounding rect by iterating through all descendants.
+
+ \sa boundingRect(), sceneBoundingRect()
+*/
+QRectF QGraphicsItem::childrenBoundingRect() const
+{
+ if (!d_ptr->dirtyChildrenBoundingRect)
+ return d_ptr->childrenBoundingRect;
+
+ d_ptr->childrenBoundingRect = QRectF();
+ d_ptr->childrenBoundingRectHelper(0, &d_ptr->childrenBoundingRect, 0);
+ d_ptr->dirtyChildrenBoundingRect = 0;
+ return d_ptr->childrenBoundingRect;
+}
+
+/*!
+ \fn virtual QRectF QGraphicsItem::boundingRect() const = 0
+
+ This pure virtual function defines the outer bounds of the item as
+ a rectangle; all painting must be restricted to inside an item's
+ bounding rect. QGraphicsView uses this to determine whether the
+ item requires redrawing.
+
+ Although the item's shape can be arbitrary, the bounding rect is
+ always rectangular, and it is unaffected by the items'
+ transformation.
+
+ If you want to change the item's bounding rectangle, you must first call
+ prepareGeometryChange(). This notifies the scene of the imminent change,
+ so that its can update its item geometry index; otherwise, the scene will
+ be unaware of the item's new geometry, and the results are undefined
+ (typically, rendering artifacts are left around in the view).
+
+ Reimplement this function to let QGraphicsView determine what
+ parts of the widget, if any, need to be redrawn.
+
+ Note: For shapes that paint an outline / stroke, it is important
+ to include half the pen width in the bounding rect. It is not
+ necessary to compensate for antialiasing, though.
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 8
+
+ \sa boundingRegion(), shape(), contains(), {The Graphics View Coordinate
+ System}, prepareGeometryChange()
+*/
+
+/*!
+ Returns the bounding rect of this item in scene coordinates, by combining
+ sceneTransform() with boundingRect().
+
+ \sa boundingRect(), {The Graphics View Coordinate System}
+*/
+QRectF QGraphicsItem::sceneBoundingRect() const
+{
+ // Find translate-only offset
+ // COMBINE
+ QPointF offset;
+ const QGraphicsItem *parentItem = this;
+ const QGraphicsItemPrivate *itemd;
+ do {
+ itemd = parentItem->d_ptr.data();
+ if (itemd->transformData)
+ break;
+ offset += itemd->pos;
+ } while ((parentItem = itemd->parent));
+
+ QRectF br = boundingRect();
+ br.translate(offset);
+ if (!parentItem)
+ return br;
+ if (parentItem->d_ptr->hasTranslateOnlySceneTransform()) {
+ br.translate(parentItem->d_ptr->sceneTransform.dx(), parentItem->d_ptr->sceneTransform.dy());
+ return br;
+ }
+ return parentItem->d_ptr->sceneTransform.mapRect(br);
+}
+
+/*!
+ Returns the shape of this item as a QPainterPath in local
+ coordinates. The shape is used for many things, including collision
+ detection, hit tests, and for the QGraphicsScene::items() functions.
+
+ The default implementation calls boundingRect() to return a simple
+ rectangular shape, but subclasses can reimplement this function to return
+ a more accurate shape for non-rectangular items. For example, a round item
+ may choose to return an elliptic shape for better collision detection. For
+ example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 9
+
+ The outline of a shape can vary depending on the width and style of the
+ pen used when drawing. If you want to include this outline in the item's
+ shape, you can create a shape from the stroke using QPainterPathStroker.
+
+ This function is called by the default implementations of contains() and
+ collidesWithPath().
+
+ \sa boundingRect(), contains(), prepareGeometryChange(), QPainterPathStroker
+*/
+QPainterPath QGraphicsItem::shape() const
+{
+ QPainterPath path;
+ path.addRect(boundingRect());
+ return path;
+}
+
+/*!
+ Returns true if this item is clipped. An item is clipped if it has either
+ set the \l ItemClipsToShape flag, or if it or any of its ancestors has set
+ the \l ItemClipsChildrenToShape flag.
+
+ Clipping affects the item's appearance (i.e., painting), as well as mouse
+ and hover event delivery.
+
+ \sa clipPath(), shape(), setFlags()
+*/
+bool QGraphicsItem::isClipped() const
+{
+ Q_D(const QGraphicsItem);
+ return (d->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren)
+ || (d->flags & QGraphicsItem::ItemClipsToShape);
+}
+
+/*!
+ \since 4.5
+
+ Returns this item's clip path, or an empty QPainterPath if this item is
+ not clipped. The clip path constrains the item's appearance and
+ interaction (i.e., restricts the area the item can draw, and it also
+ restricts the area that the item receives events).
+
+ You can enable clipping by setting the ItemClipsToShape or
+ ItemClipsChildrenToShape flags. The item's clip path is calculated by
+ intersecting all clipping ancestors' shapes. If the item sets
+ ItemClipsToShape, the final clip is intersected with the item's own shape.
+
+ \note Clipping introduces a performance penalty for all items involved;
+ you should generally avoid using clipping if you can (e.g., if your items
+ always draw inside boundingRect() or shape() boundaries, clipping is not
+ necessary).
+
+ \sa isClipped(), shape(), setFlags()
+*/
+QPainterPath QGraphicsItem::clipPath() const
+{
+ Q_D(const QGraphicsItem);
+ if (!isClipped())
+ return QPainterPath();
+
+ const QRectF thisBoundingRect(boundingRect());
+ if (thisBoundingRect.isEmpty())
+ return QPainterPath();
+
+ QPainterPath clip;
+ // Start with the item's bounding rect.
+ clip.addRect(thisBoundingRect);
+
+ if (d->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) {
+ const QGraphicsItem *parent = this;
+ const QGraphicsItem *lastParent = this;
+
+ // Intersect any in-between clips starting at the top and moving downwards.
+ while ((parent = parent->d_ptr->parent)) {
+ if (parent->d_ptr->flags & ItemClipsChildrenToShape) {
+ // Map clip to the current parent and intersect with its shape/clipPath
+ clip = lastParent->itemTransform(parent).map(clip);
+ clip = clip.intersected(parent->shape());
+ if (clip.isEmpty())
+ return clip;
+ lastParent = parent;
+ }
+
+ if (!(parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren))
+ break;
+ }
+
+ if (lastParent != this) {
+ // Map clip back to the item's transform.
+ // ### what if itemtransform fails
+ clip = lastParent->itemTransform(this).map(clip);
+ }
+ }
+
+ if (d->flags & ItemClipsToShape)
+ clip = clip.intersected(shape());
+
+ return clip;
+}
+
+/*!
+ Returns true if this item contains \a point, which is in local
+ coordinates; otherwise, false is returned. It is most often called from
+ QGraphicsView to determine what item is under the cursor, and for that
+ reason, the implementation of this function should be as light-weight as
+ possible.
+
+ By default, this function calls shape(), but you can reimplement it in a
+ subclass to provide a (perhaps more efficient) implementation.
+
+ \sa shape(), boundingRect(), collidesWithPath()
+*/
+bool QGraphicsItem::contains(const QPointF &point) const
+{
+ return isClipped() ? clipPath().contains(point) : shape().contains(point);
+}
+
+/*!
+
+ Returns true if this item collides with \a other; otherwise
+ returns false.
+
+ The \a mode is applied to \a other, and the resulting shape or
+ bounding rectangle is then compared to this item's shape. The
+ default value for \a mode is Qt::IntersectsItemShape; \a other
+ collides with this item if it either intersects, contains, or is
+ contained by this item's shape (see Qt::ItemSelectionMode for
+ details).
+
+ The default implementation is based on shape intersection, and it calls
+ shape() on both items. Because the complexity of arbitrary shape-shape
+ intersection grows with an order of magnitude when the shapes are complex,
+ this operation can be noticably time consuming. You have the option of
+ reimplementing this function in a subclass of QGraphicsItem to provide a
+ custom algorithm. This allows you to make use of natural constraints in
+ the shapes of your own items, in order to improve the performance of the
+ collision detection. For instance, two untransformed perfectly circular
+ items' collision can be determined very efficiently by comparing their
+ positions and radii.
+
+ Keep in mind that when reimplementing this function and calling shape() or
+ boundingRect() on \a other, the returned coordinates must be mapped to
+ this item's coordinate system before any intersection can take place.
+
+ \sa contains(), shape()
+*/
+bool QGraphicsItem::collidesWithItem(const QGraphicsItem *other, Qt::ItemSelectionMode mode) const
+{
+ if (other == this)
+ return true;
+ if (!other)
+ return false;
+ // The items share the same clip if their closest clipper is the same, or
+ // if one clips the other.
+ bool clips = (d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren);
+ bool otherClips = (other->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren);
+ if (clips || otherClips) {
+ const QGraphicsItem *closestClipper = isAncestorOf(other) ? this : parentItem();
+ while (closestClipper && !(closestClipper->flags() & ItemClipsChildrenToShape))
+ closestClipper = closestClipper->parentItem();
+ const QGraphicsItem *otherClosestClipper = other->isAncestorOf(this) ? other : other->parentItem();
+ while (otherClosestClipper && !(otherClosestClipper->flags() & ItemClipsChildrenToShape))
+ otherClosestClipper = otherClosestClipper->parentItem();
+ if (closestClipper == otherClosestClipper) {
+ d_ptr->localCollisionHack = 1;
+ bool res = collidesWithPath(mapFromItem(other, other->shape()), mode);
+ d_ptr->localCollisionHack = 0;
+ return res;
+ }
+ }
+
+ QPainterPath otherShape = other->isClipped() ? other->clipPath() : other->shape();
+ return collidesWithPath(mapFromItem(other, otherShape), mode);
+}
+
+/*!
+ Returns true if this item collides with \a path.
+
+ The collision is determined by \a mode. The default value for \a mode is
+ Qt::IntersectsItemShape; \a path collides with this item if it either
+ intersects, contains, or is contained by this item's shape.
+
+ Note that this function checks whether the item's shape or
+ bounding rectangle (depending on \a mode) is contained within \a
+ path, and not whether \a path is contained within the items shape
+ or bounding rectangle.
+
+ \sa collidesWithItem(), contains(), shape()
+*/
+bool QGraphicsItem::collidesWithPath(const QPainterPath &path, Qt::ItemSelectionMode mode) const
+{
+ if (path.isEmpty()) {
+ // No collision with empty paths.
+ return false;
+ }
+
+ QRectF rectA(boundingRect());
+ _q_adjustRect(&rectA);
+ QRectF rectB(path.controlPointRect());
+ _q_adjustRect(&rectB);
+ if (!rectA.intersects(rectB)) {
+ // This we can determine efficiently. If the two rects neither
+ // intersect nor contain eachother, then the two items do not collide.
+ return false;
+ }
+
+ // For further testing, we need this item's shape or bounding rect.
+ QPainterPath thisShape;
+ if (mode == Qt::IntersectsItemShape || mode == Qt::ContainsItemShape)
+ thisShape = (isClipped() && !d_ptr->localCollisionHack) ? clipPath() : shape();
+ else
+ thisShape.addRect(rectA);
+
+ if (thisShape == QPainterPath()) {
+ // Empty shape? No collision.
+ return false;
+ }
+
+ // Use QPainterPath boolean operations to determine the collision, O(N*logN).
+ if (mode == Qt::IntersectsItemShape || mode == Qt::IntersectsItemBoundingRect)
+ return path.intersects(thisShape);
+ return path.contains(thisShape);
+}
+
+/*!
+ Returns a list of all items that collide with this item.
+
+ The way collisions are detected is determined by applying \a mode
+ to items that are compared to this item, i.e., each item's shape
+ or bounding rectangle is checked against this item's shape. The
+ default value for \a mode is Qt::IntersectsItemShape.
+
+ \sa collidesWithItem()
+*/
+QList<QGraphicsItem *> QGraphicsItem::collidingItems(Qt::ItemSelectionMode mode) const
+{
+ if (d_ptr->scene)
+ return d_ptr->scene->collidingItems(this, mode);
+ return QList<QGraphicsItem *>();
+}
+
+/*!
+ Returns true if this item's bounding rect is completely obscured by the
+ opaque shape of any of colliding items above it (i.e., with a higher Z
+ value than this item).
+
+ Its implementation is based on calling isObscuredBy(), which you can
+ reimplement to provide a custom obscurity algorithm.
+
+ \sa opaqueArea()
+*/
+bool QGraphicsItem::isObscured() const
+{
+ return isObscured(QRectF());
+}
+
+/*!
+ \internal
+
+ Item obscurity helper function.
+
+ Returns true if the subrect \a rect of \a item's bounding rect is obscured
+ by \a other (i.e., \a other's opaque area covers \a item's \a rect
+ completely. \a other is assumed to already be "on top of" \a item
+ wrt. stacking order.
+*/
+static bool qt_QGraphicsItem_isObscured(const QGraphicsItem *item,
+ const QGraphicsItem *other,
+ const QRectF &rect)
+{
+ return other->mapToItem(item, other->opaqueArea()).contains(rect);
+}
+
+/*!
+ \overload
+ \since 4.3
+
+ Returns true if \a rect is completely obscured by the opaque shape of any
+ of colliding items above it (i.e., with a higher Z value than this item).
+
+ Unlike the default isObscured() function, this function does not call
+ isObscuredBy().
+
+ \sa opaqueArea()
+*/
+bool QGraphicsItem::isObscured(const QRectF &rect) const
+{
+ Q_D(const QGraphicsItem);
+ if (!d->scene)
+ return false;
+
+ QRectF br = boundingRect();
+ QRectF testRect = rect.isNull() ? br : rect;
+
+ foreach (QGraphicsItem *item, d->scene->items(mapToScene(br), Qt::IntersectsItemBoundingRect)) {
+ if (item == this)
+ break;
+ if (qt_QGraphicsItem_isObscured(this, item, testRect))
+ return true;
+ }
+ return false;
+}
+
+/*!
+ \fn bool QGraphicsItem::isObscured(qreal x, qreal y, qreal w, qreal h) const
+ \since 4.3
+
+ This convenience function is equivalent to calling isObscured(QRectF(\a x, \a y, \a w, \a h)).
+*/
+
+/*!
+ Returns true if this item's bounding rect is completely obscured by the
+ opaque shape of \a item.
+
+ The base implementation maps \a item's opaqueArea() to this item's
+ coordinate system, and then checks if this item's boundingRect() is fully
+ contained within the mapped shape.
+
+ You can reimplement this function to provide a custom algorithm for
+ determining whether this item is obscured by \a item.
+
+ \sa opaqueArea(), isObscured()
+*/
+bool QGraphicsItem::isObscuredBy(const QGraphicsItem *item) const
+{
+ if (!item)
+ return false;
+ return qt_closestItemFirst(item, this)
+ && qt_QGraphicsItem_isObscured(this, item, boundingRect());
+}
+
+/*!
+ This virtual function returns a shape representing the area where this
+ item is opaque. An area is opaque if it is filled using an opaque brush or
+ color (i.e., not transparent).
+
+ This function is used by isObscuredBy(), which is called by underlying
+ items to determine if they are obscured by this item.
+
+ The default implementation returns an empty QPainterPath, indicating that
+ this item is completely transparent and does not obscure any other items.
+
+ \sa isObscuredBy(), isObscured(), shape()
+*/
+QPainterPath QGraphicsItem::opaqueArea() const
+{
+ return QPainterPath();
+}
+
+/*!
+ \since 4.4
+
+ Returns the bounding region for this item. The coordinate space of the
+ returned region depends on \a itemToDeviceTransform. If you pass an
+ identity QTransform as a parameter, this function will return a local
+ coordinate region.
+
+ The bounding region describes a coarse outline of the item's visual
+ contents. Although it's expensive to calculate, it's also more precise
+ than boundingRect(), and it can help to avoid unnecessary repainting when
+ an item is updated. This is particularly efficient for thin items (e.g.,
+ lines or simple polygons). You can tune the granularity for the bounding
+ region by calling setBoundingRegionGranularity(). The default granularity
+ is 0; in which the item's bounding region is the same as its bounding
+ rect.
+
+ \a itemToDeviceTransform is the transformation from item coordinates to
+ device coordinates. If you want this function to return a QRegion in scene
+ coordinates, you can pass sceneTransform() as an argument.
+
+ \sa boundingRegionGranularity()
+*/
+QRegion QGraphicsItem::boundingRegion(const QTransform &itemToDeviceTransform) const
+{
+ // ### Ideally we would have a better way to generate this region,
+ // preferably something in the lines of QPainterPath::toRegion(QTransform)
+ // coupled with a way to generate a painter path from a set of painter
+ // operations (e.g., QPicture::toPainterPath() or so). The current
+ // approach generates a bitmap with the size of the item's bounding rect
+ // in device coordinates, scaled by b.r.granularity, then paints the item
+ // into the bitmap, converts the result to a QRegion and scales the region
+ // back to device space with inverse granularity.
+ qreal granularity = boundingRegionGranularity();
+ QRect deviceRect = itemToDeviceTransform.mapRect(boundingRect()).toRect();
+ _q_adjustRect(&deviceRect);
+ if (granularity == 0.0)
+ return QRegion(deviceRect);
+
+ int pad = 1;
+ QSize bitmapSize(qMax(1, int(deviceRect.width() * granularity) + pad * 2),
+ qMax(1, int(deviceRect.height() * granularity) + pad * 2));
+ QImage mask(bitmapSize, QImage::Format_ARGB32_Premultiplied);
+ mask.fill(0);
+ QPainter p(&mask);
+ p.setRenderHints(QPainter::Antialiasing);
+
+ // Transform painter (### this code is from QGraphicsScene::drawItemHelper
+ // and doesn't work properly with perspective transformations).
+ QPointF viewOrigo = itemToDeviceTransform.map(QPointF(0, 0));
+ QPointF offset = viewOrigo - deviceRect.topLeft();
+ p.scale(granularity, granularity);
+ p.translate(offset);
+ p.translate(pad, pad);
+ p.setWorldTransform(itemToDeviceTransform, true);
+ p.translate(itemToDeviceTransform.inverted().map(QPointF(0, 0)));
+
+ // Render
+ QStyleOptionGraphicsItem option;
+ const_cast<QGraphicsItem *>(this)->paint(&p, &option, 0);
+ p.end();
+
+ // Transform QRegion back to device space
+ QTransform unscale = QTransform::fromScale(1 / granularity, 1 / granularity);
+ QRegion r;
+ QBitmap colorMask = QBitmap::fromImage(mask.createMaskFromColor(0));
+ foreach (const QRect &rect, QRegion( colorMask ).rects()) {
+ QRect xrect = unscale.mapRect(rect).translated(deviceRect.topLeft() - QPoint(pad, pad));
+ r += xrect.adjusted(-1, -1, 1, 1) & deviceRect;
+ }
+ return r;
+}
+
+/*!
+ \since 4.4
+
+ Returns the item's bounding region granularity; a value between and
+ including 0 and 1. The default value is 0 (i.e., the lowest granularity,
+ where the bounding region corresponds to the item's bounding rectangle).
+
+\omit
+### NOTE
+\endomit
+
+ \sa setBoundingRegionGranularity()
+*/
+qreal QGraphicsItem::boundingRegionGranularity() const
+{
+ return d_ptr->hasBoundingRegionGranularity
+ ? qvariant_cast<qreal>(d_ptr->extra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity))
+ : 0;
+}
+
+/*!
+ \since 4.4
+ Sets the bounding region granularity to \a granularity; a value between
+ and including 0 and 1. The default value is 0 (i.e., the lowest
+ granularity, where the bounding region corresponds to the item's bounding
+ rectangle).
+
+ The granularity is used by boundingRegion() to calculate how fine the
+ bounding region of the item should be. The highest achievable granularity
+ is 1, where boundingRegion() will return the finest outline possible for
+ the respective device (e.g., for a QGraphicsView viewport, this gives you
+ a pixel-perfect bounding region). The lowest possible granularity is
+ 0. The value of \a granularity describes the ratio between device
+ resolution and the resolution of the bounding region (e.g., a value of
+ 0.25 will provide a region where each chunk corresponds to 4x4 device
+ units / pixels).
+
+ \sa boundingRegionGranularity()
+*/
+void QGraphicsItem::setBoundingRegionGranularity(qreal granularity)
+{
+ if (granularity < 0.0 || granularity > 1.0) {
+ qWarning("QGraphicsItem::setBoundingRegionGranularity: invalid granularity %g", granularity);
+ return;
+ }
+ if (granularity == 0.0) {
+ d_ptr->unsetExtra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity);
+ d_ptr->hasBoundingRegionGranularity = 0;
+ return;
+ }
+ d_ptr->hasBoundingRegionGranularity = 1;
+ d_ptr->setExtra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity,
+ QVariant::fromValue<qreal>(granularity));
+}
+
+/*!
+ \fn virtual void QGraphicsItem::paint(QPainter *painter, const
+ QStyleOptionGraphicsItem *option, QWidget *widget = 0) = 0
+
+ This function, which is usually called by QGraphicsView, paints the
+ contents of an item in local coordinates.
+
+ Reimplement this function in a QGraphicsItem subclass to provide the
+ item's painting implementation, using \a painter. The \a option parameter
+ provides style options for the item, such as its state, exposed area and
+ its level-of-detail hints. The \a widget argument is optional. If
+ provided, it points to the widget that is being painted on; otherwise, it
+ is 0. For cached painting, \a widget is always 0.
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 10
+
+ The painter's pen is 0-width by default, and its pen is initialized to the
+ QPalette::Text brush from the paint device's palette. The brush is
+ initialized to QPalette::Window.
+
+ Make sure to constrain all painting inside the boundaries of
+ boundingRect() to avoid rendering artifacts (as QGraphicsView does not
+ clip the painter for you). In particular, when QPainter renders the
+ outline of a shape using an assigned QPen, half of the outline will be
+ drawn outside, and half inside, the shape you're rendering (e.g., with a
+ pen width of 2 units, you must draw outlines 1 unit inside
+ boundingRect()). QGraphicsItem does not support use of cosmetic pens with
+ a non-zero width.
+
+ All painting is done in local coordinates.
+
+ \sa setCacheMode(), QPen::width(), {Item Coordinates}, ItemUsesExtendedStyleOption
+*/
+
+/*!
+ \internal
+ Returns true if we can discard an update request; otherwise false.
+*/
+bool QGraphicsItemPrivate::discardUpdateRequest(bool ignoreVisibleBit, bool ignoreDirtyBit,
+ bool ignoreOpacity) const
+{
+ // No scene, or if the scene is updating everything, means we have nothing
+ // to do. The only exception is if the scene tracks the growing scene rect.
+ return !scene
+ || (!visible && !ignoreVisibleBit && !this->ignoreVisible)
+ || (!ignoreDirtyBit && fullUpdatePending)
+ || (!ignoreOpacity && !this->ignoreOpacity && childrenCombineOpacity() && isFullyTransparent());
+}
+
+/*!
+ \internal
+*/
+int QGraphicsItemPrivate::depth() const
+{
+ if (itemDepth == -1)
+ const_cast<QGraphicsItemPrivate *>(this)->resolveDepth();
+
+ return itemDepth;
+}
+
+/*!
+ \internal
+*/
+#ifndef QT_NO_GRAPHICSEFFECT
+void QGraphicsItemPrivate::invalidateParentGraphicsEffectsRecursively()
+{
+ QGraphicsItemPrivate *itemPrivate = this;
+ do {
+ if (itemPrivate->graphicsEffect) {
+ itemPrivate->notifyInvalidated = 1;
+
+ if (!itemPrivate->updateDueToGraphicsEffect)
+ static_cast<QGraphicsItemEffectSourcePrivate *>(itemPrivate->graphicsEffect->d_func()->source->d_func())->invalidateCache();
+ }
+ } while ((itemPrivate = itemPrivate->parent ? itemPrivate->parent->d_ptr.data() : 0));
+}
+
+void QGraphicsItemPrivate::invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::InvalidateReason reason)
+{
+ if (!mayHaveChildWithGraphicsEffect)
+ return;
+
+ for (int i = 0; i < children.size(); ++i) {
+ QGraphicsItemPrivate *childPrivate = children.at(i)->d_ptr.data();
+ if (reason == OpacityChanged && (childPrivate->flags & QGraphicsItem::ItemIgnoresParentOpacity))
+ continue;
+ if (childPrivate->graphicsEffect) {
+ childPrivate->notifyInvalidated = 1;
+ static_cast<QGraphicsItemEffectSourcePrivate *>(childPrivate->graphicsEffect->d_func()->source->d_func())->invalidateCache();
+ }
+
+ childPrivate->invalidateChildGraphicsEffectsRecursively(reason);
+ }
+}
+#endif //QT_NO_GRAPHICSEFFECT
+
+/*!
+ \internal
+*/
+void QGraphicsItemPrivate::invalidateDepthRecursively()
+{
+ if (itemDepth == -1)
+ return;
+
+ itemDepth = -1;
+ for (int i = 0; i < children.size(); ++i)
+ children.at(i)->d_ptr->invalidateDepthRecursively();
+}
+
+/*!
+ \internal
+
+ Resolves the stacking depth of this object and all its ancestors.
+*/
+void QGraphicsItemPrivate::resolveDepth()
+{
+ if (!parent)
+ itemDepth = 0;
+ else {
+ if (parent->d_ptr->itemDepth == -1)
+ parent->d_ptr->resolveDepth();
+ itemDepth = parent->d_ptr->itemDepth + 1;
+ }
+}
+
+/*!
+ \internal
+
+ ### This function is almost identical to
+ QGraphicsScenePrivate::registerTopLevelItem().
+*/
+void QGraphicsItemPrivate::addChild(QGraphicsItem *child)
+{
+ // Remove all holes from the sibling index list. Now the max index
+ // number is equal to the size of the children list.
+ ensureSequentialSiblingIndex();
+ needSortChildren = 1; // ### maybe 0
+ child->d_ptr->siblingIndex = children.size();
+ children.append(child);
+ if (isObject)
+ emit static_cast<QGraphicsObject *>(q_ptr)->childrenChanged();
+}
+
+/*!
+ \internal
+
+ ### This function is almost identical to
+ QGraphicsScenePrivate::unregisterTopLevelItem().
+*/
+void QGraphicsItemPrivate::removeChild(QGraphicsItem *child)
+{
+ // When removing elements in the middle of the children list,
+ // there will be a "gap" in the list of sibling indexes (0,1,3,4).
+ if (!holesInSiblingIndex)
+ holesInSiblingIndex = child->d_ptr->siblingIndex != children.size() - 1;
+ if (sequentialOrdering && !holesInSiblingIndex)
+ children.removeAt(child->d_ptr->siblingIndex);
+ else
+ children.removeOne(child);
+ // NB! Do not use children.removeAt(child->d_ptr->siblingIndex) because
+ // the child is not guaranteed to be at the index after the list is sorted.
+ // (see ensureSortedChildren()).
+ child->d_ptr->siblingIndex = -1;
+ if (isObject)
+ emit static_cast<QGraphicsObject *>(q_ptr)->childrenChanged();
+}
+
+/*!
+ \internal
+*/
+QGraphicsItemCache *QGraphicsItemPrivate::maybeExtraItemCache() const
+{
+ return (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));
+}
+
+/*!
+ \internal
+*/
+QGraphicsItemCache *QGraphicsItemPrivate::extraItemCache() const
+{
+ QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));
+ if (!c) {
+ QGraphicsItemPrivate *that = const_cast<QGraphicsItemPrivate *>(this);
+ c = new QGraphicsItemCache;
+ that->setExtra(ExtraCacheData, QVariant::fromValue<void *>(c));
+ }
+ return c;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsItemPrivate::removeExtraItemCache()
+{
+ QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));
+ if (c) {
+ c->purge();
+ delete c;
+ }
+ unsetExtra(ExtraCacheData);
+}
+
+void QGraphicsItemPrivate::updatePaintedViewBoundingRects(bool updateChildren)
+{
+ if (!scene)
+ return;
+
+ for (int i = 0; i < scene->d_func()->views.size(); ++i) {
+ QGraphicsViewPrivate *viewPrivate = scene->d_func()->views.at(i)->d_func();
+ QRect rect = paintedViewBoundingRects.value(viewPrivate->viewport);
+ rect.translate(viewPrivate->dirtyScrollOffset);
+ viewPrivate->updateRect(rect);
+ }
+
+ if (updateChildren) {
+ for (int i = 0; i < children.size(); ++i)
+ children.at(i)->d_ptr->updatePaintedViewBoundingRects(true);
+ }
+}
+
+// Traverses all the ancestors up to the top-level and updates the pointer to
+// always point to the top-most item that has a dirty scene transform.
+// It then backtracks to the top-most dirty item and start calculating the
+// scene transform by combining the item's transform (+pos) with the parent's
+// cached scene transform (which we at this point know for sure is valid).
+void QGraphicsItemPrivate::ensureSceneTransformRecursive(QGraphicsItem **topMostDirtyItem)
+{
+ Q_ASSERT(topMostDirtyItem);
+
+ if (dirtySceneTransform)
+ *topMostDirtyItem = q_ptr;
+
+ if (parent)
+ parent->d_ptr->ensureSceneTransformRecursive(topMostDirtyItem);
+
+ if (*topMostDirtyItem == q_ptr) {
+ if (!dirtySceneTransform)
+ return; // OK, neither my ancestors nor I have dirty scene transforms.
+ *topMostDirtyItem = 0;
+ } else if (*topMostDirtyItem) {
+ return; // Continue backtrack.
+ }
+
+ // This item and all its descendants have dirty scene transforms.
+ // We're about to validate this item's scene transform, so we have to
+ // invalidate all the children; otherwise there's no way for the descendants
+ // to detect that the ancestor has changed.
+ invalidateChildrenSceneTransform();
+
+ // COMBINE my transform with the parent's scene transform.
+ updateSceneTransformFromParent();
+ Q_ASSERT(!dirtySceneTransform);
+}
+
+/*!
+ \internal
+*/
+void QGraphicsItemPrivate::setSubFocus(QGraphicsItem *rootItem, QGraphicsItem *stopItem)
+{
+ // Update focus child chain. Stop at panels, or if this item
+ // is hidden, stop at the first item with a visible parent.
+ QGraphicsItem *parent = rootItem ? rootItem : q_ptr;
+ if (parent->panel() != q_ptr->panel())
+ return;
+
+ do {
+ // Clear any existing ancestor's subFocusItem.
+ if (parent != q_ptr && parent->d_ptr->subFocusItem) {
+ if (parent->d_ptr->subFocusItem == q_ptr)
+ break;
+ parent->d_ptr->subFocusItem->d_ptr->clearSubFocus(0, stopItem);
+ }
+ parent->d_ptr->subFocusItem = q_ptr;
+ parent->d_ptr->subFocusItemChange();
+ } while (!parent->isPanel() && (parent = parent->d_ptr->parent) && (visible || !parent->d_ptr->visible));
+
+ if (scene && !scene->isActive()) {
+ scene->d_func()->passiveFocusItem = subFocusItem;
+ scene->d_func()->lastFocusItem = subFocusItem;
+ }
+}
+
+/*!
+ \internal
+*/
+void QGraphicsItemPrivate::clearSubFocus(QGraphicsItem *rootItem, QGraphicsItem *stopItem)
+{
+ // Reset sub focus chain.
+ QGraphicsItem *parent = rootItem ? rootItem : q_ptr;
+ do {
+ if (parent->d_ptr->subFocusItem != q_ptr)
+ break;
+ parent->d_ptr->subFocusItem = 0;
+ if (parent != stopItem && !parent->isAncestorOf(stopItem))
+ parent->d_ptr->subFocusItemChange();
+ } while (!parent->isPanel() && (parent = parent->d_ptr->parent));
+}
+
+/*!
+ \internal
+
+ Sets the focusProxy pointer to 0 for all items that have this item as their
+ focusProxy. ### Qt 5: Use QPointer instead.
+*/
+void QGraphicsItemPrivate::resetFocusProxy()
+{
+ for (int i = 0; i < focusProxyRefs.size(); ++i)
+ *focusProxyRefs.at(i) = 0;
+ focusProxyRefs.clear();
+}
+
+/*!
+ \internal
+
+ Subclasses can reimplement this function to be notified when subFocusItem
+ changes.
+*/
+void QGraphicsItemPrivate::subFocusItemChange()
+{
+}
+
+/*!
+ \internal
+
+ Subclasses can reimplement this function to be notified when an item
+ becomes a focusScopeItem (or is no longer a focusScopeItem).
+*/
+void QGraphicsItemPrivate::focusScopeItemChange(bool isSubFocusItem)
+{
+ Q_UNUSED(isSubFocusItem);
+}
+
+/*!
+ \internal
+
+ Subclasses can reimplement this function to be notified when its
+ siblingIndex order is changed.
+*/
+void QGraphicsItemPrivate::siblingOrderChange()
+{
+}
+
+/*!
+ \internal
+
+ Tells us if it is a proxy widget
+*/
+bool QGraphicsItemPrivate::isProxyWidget() const
+{
+ return false;
+}
+
+/*!
+ Schedules a redraw of the area covered by \a rect in this item. You can
+ call this function whenever your item needs to be redrawn, such as if it
+ changes appearance or size.
+
+ This function does not cause an immediate paint; instead it schedules a
+ paint request that is processed by QGraphicsView after control reaches the
+ event loop. The item will only be redrawn if it is visible in any
+ associated view.
+
+ As a side effect of the item being repainted, other items that overlap the
+ area \a rect may also be repainted.
+
+ If the item is invisible (i.e., isVisible() returns false), this function
+ does nothing.
+
+ \sa paint(), boundingRect()
+*/
+void QGraphicsItem::update(const QRectF &rect)
+{
+ if (rect.isEmpty() && !rect.isNull())
+ return;
+
+ // Make sure we notify effects about invalidated source.
+#ifndef QT_NO_GRAPHICSEFFECT
+ d_ptr->invalidateParentGraphicsEffectsRecursively();
+#endif //QT_NO_GRAPHICSEFFECT
+
+ if (CacheMode(d_ptr->cacheMode) != NoCache) {
+ // Invalidate cache.
+ QGraphicsItemCache *cache = d_ptr->extraItemCache();
+ if (!cache->allExposed) {
+ if (rect.isNull()) {
+ cache->allExposed = true;
+ cache->exposed.clear();
+ } else {
+ cache->exposed.append(rect);
+ }
+ }
+ // Only invalidate cache; item is already dirty.
+ if (d_ptr->fullUpdatePending)
+ return;
+ }
+
+ if (d_ptr->scene)
+ d_ptr->scene->d_func()->markDirty(this, rect);
+}
+
+/*!
+ \since 4.4
+ Scrolls the contents of \a rect by \a dx, \a dy. If \a rect is a null rect
+ (the default), the item's bounding rect is scrolled.
+
+ Scrolling provides a fast alternative to simply redrawing when the
+ contents of the item (or parts of the item) are shifted vertically or
+ horizontally. Depending on the current transformation and the capabilities
+ of the paint device (i.e., the viewport), this operation may consist of
+ simply moving pixels from one location to another using memmove(). In most
+ cases this is faster than rerendering the entire area.
+
+ After scrolling, the item will issue an update for the newly exposed
+ areas. If scrolling is not supported (e.g., you are rendering to an OpenGL
+ viewport, which does not benefit from scroll optimizations), this function
+ is equivalent to calling update(\a rect).
+
+ \bold{Note:} Scrolling is only supported when QGraphicsItem::ItemCoordinateCache
+ is enabled; in all other cases calling this function is equivalent to calling
+ update(\a rect). If you for sure know that the item is opaque and not overlapped
+ by other items, you can map the \a rect to viewport coordinates and scroll the
+ viewport.
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 19
+
+ \sa boundingRect()
+*/
+void QGraphicsItem::scroll(qreal dx, qreal dy, const QRectF &rect)
+{
+ Q_D(QGraphicsItem);
+ if (dx == 0.0 && dy == 0.0)
+ return;
+ if (!d->scene)
+ return;
+
+ // Accelerated scrolling means moving pixels from one location to another
+ // and only redraw the newly exposed area. The following requirements must
+ // be fulfilled in order to do that:
+ //
+ // 1) Item is opaque.
+ // 2) Item is not overlapped by other items.
+ //
+ // There's (yet) no way to detect whether an item is opaque or not, which means
+ // we cannot do accelerated scrolling unless the cache is enabled. In case of using
+ // DeviceCoordinate cache we also have to take the device transform into account in
+ // order to determine whether we can do accelerated scrolling or not. That's left out
+ // for simplicity here, but it is definitely something we can consider in the future
+ // as a performance improvement.
+ if (d->cacheMode != QGraphicsItem::ItemCoordinateCache
+ || !qFuzzyIsNull(dx - int(dx)) || !qFuzzyIsNull(dy - int(dy))) {
+ update(rect);
+ return;
+ }
+
+ QGraphicsItemCache *cache = d->extraItemCache();
+ if (cache->allExposed || cache->fixedSize.isValid()) {
+ // Cache is either invalidated or item is scaled (see QGraphicsItem::setCacheMode).
+ update(rect);
+ return;
+ }
+
+ // Find pixmap in cache.
+ QPixmap cachedPixmap;
+ if (!QPixmapCache::find(cache->key, &cachedPixmap)) {
+ update(rect);
+ return;
+ }
+
+ QRect scrollRect = (rect.isNull() ? boundingRect() : rect).toAlignedRect();
+ if (!scrollRect.intersects(cache->boundingRect))
+ return; // Nothing to scroll.
+
+ // Remove from cache to avoid deep copy when modifying.
+ QPixmapCache::remove(cache->key);
+
+ QRegion exposed;
+ cachedPixmap.scroll(dx, dy, scrollRect.translated(-cache->boundingRect.topLeft()), &exposed);
+
+ // Reinsert into cache.
+ cache->key = QPixmapCache::insert(cachedPixmap);
+
+ // Translate the existing expose.
+ for (int i = 0; i < cache->exposed.size(); ++i) {
+ QRectF &e = cache->exposed[i];
+ if (!rect.isNull() && !e.intersects(rect))
+ continue;
+ e.translate(dx, dy);
+ }
+
+ // Append newly exposed areas. Note that the exposed region is currently
+ // in pixmap coordinates, so we have to translate it to item coordinates.
+ exposed.translate(cache->boundingRect.topLeft());
+ const QVector<QRect> exposedRects = exposed.rects();
+ for (int i = 0; i < exposedRects.size(); ++i)
+ cache->exposed += exposedRects.at(i);
+
+ // Trigger update. This will redraw the newly exposed area and make sure
+ // the pixmap is re-blitted in case there are overlapping items.
+ d->scene->d_func()->markDirty(this, rect);
+}
+
+/*!
+ \fn void QGraphicsItem::update(qreal x, qreal y, qreal width, qreal height)
+ \overload
+
+ This convenience function is equivalent to calling update(QRectF(\a x, \a
+ y, \a width, \a height)).
+*/
+
+/*!
+ Maps the point \a point, which is in this item's coordinate system, to \a
+ item's coordinate system, and returns the mapped coordinate.
+
+ If \a item is 0, this function returns the same as mapToScene().
+
+ \sa itemTransform(), mapToParent(), mapToScene(), transform(), mapFromItem(), {The Graphics
+ View Coordinate System}
+*/
+QPointF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPointF &point) const
+{
+ if (item)
+ return itemTransform(item).map(point);
+ return mapToScene(point);
+}
+
+/*!
+ \fn QPointF QGraphicsItem::mapToItem(const QGraphicsItem *item, qreal x, qreal y) const
+ \overload
+
+ This convenience function is equivalent to calling mapToItem(\a item,
+ QPointF(\a x, \a y)).
+*/
+
+/*!
+ Maps the point \a point, which is in this item's coordinate system, to its
+ parent's coordinate system, and returns the mapped coordinate. If the item
+ has no parent, \a point will be mapped to the scene's coordinate system.
+
+ \sa mapToItem(), mapToScene(), transform(), mapFromParent(), {The Graphics
+ View Coordinate System}
+*/
+QPointF QGraphicsItem::mapToParent(const QPointF &point) const
+{
+ // COMBINE
+ if (!d_ptr->transformData)
+ return point + d_ptr->pos;
+ return d_ptr->transformToParent().map(point);
+}
+
+/*!
+ \fn QPointF QGraphicsItem::mapToParent(qreal x, qreal y) const
+ \overload
+
+ This convenience function is equivalent to calling mapToParent(QPointF(\a
+ x, \a y)).
+*/
+
+/*!
+ Maps the point \a point, which is in this item's coordinate system, to the
+ scene's coordinate system, and returns the mapped coordinate.
+
+ \sa mapToItem(), mapToParent(), transform(), mapFromScene(), {The Graphics
+ View Coordinate System}
+*/
+QPointF QGraphicsItem::mapToScene(const QPointF &point) const
+{
+ if (d_ptr->hasTranslateOnlySceneTransform())
+ return QPointF(point.x() + d_ptr->sceneTransform.dx(), point.y() + d_ptr->sceneTransform.dy());
+ return d_ptr->sceneTransform.map(point);
+}
+
+/*!
+ \fn QPointF QGraphicsItem::mapToScene(qreal x, qreal y) const
+ \overload
+
+ This convenience function is equivalent to calling mapToScene(QPointF(\a
+ x, \a y)).
+*/
+
+/*!
+ Maps the rectangle \a rect, which is in this item's coordinate system, to
+ \a item's coordinate system, and returns the mapped rectangle as a polygon.
+
+ If \a item is 0, this function returns the same as mapToScene().
+
+ \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The
+ Graphics View Coordinate System}
+*/
+QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QRectF &rect) const
+{
+ if (item)
+ return itemTransform(item).map(rect);
+ return mapToScene(rect);
+}
+
+/*!
+ \fn QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
+ \since 4.3
+
+ This convenience function is equivalent to calling mapToItem(item, QRectF(\a x, \a y, \a w, \a h)).
+*/
+
+/*!
+ Maps the rectangle \a rect, which is in this item's coordinate system, to
+ its parent's coordinate system, and returns the mapped rectangle as a
+ polygon. If the item has no parent, \a rect will be mapped to the scene's
+ coordinate system.
+
+ \sa mapToScene(), mapToItem(), mapFromParent(), {The Graphics View
+ Coordinate System}
+*/
+QPolygonF QGraphicsItem::mapToParent(const QRectF &rect) const
+{
+ // COMBINE
+ if (!d_ptr->transformData)
+ return rect.translated(d_ptr->pos);
+ return d_ptr->transformToParent().map(rect);
+}
+
+/*!
+ \fn QPolygonF QGraphicsItem::mapToParent(qreal x, qreal y, qreal w, qreal h) const
+ \since 4.3
+
+ This convenience function is equivalent to calling mapToParent(QRectF(\a x, \a y, \a w, \a h)).
+*/
+
+/*!
+ Maps the rectangle \a rect, which is in this item's coordinate system, to
+ the scene's coordinate system, and returns the mapped rectangle as a polygon.
+
+ \sa mapToParent(), mapToItem(), mapFromScene(), {The Graphics View
+ Coordinate System}
+*/
+QPolygonF QGraphicsItem::mapToScene(const QRectF &rect) const
+{
+ if (d_ptr->hasTranslateOnlySceneTransform())
+ return rect.translated(d_ptr->sceneTransform.dx(), d_ptr->sceneTransform.dy());
+ return d_ptr->sceneTransform.map(rect);
+}
+
+/*!
+ \fn QPolygonF QGraphicsItem::mapToScene(qreal x, qreal y, qreal w, qreal h) const
+ \since 4.3
+
+ This convenience function is equivalent to calling mapToScene(QRectF(\a x, \a y, \a w, \a h)).
+*/
+
+/*!
+ \since 4.5
+
+ Maps the rectangle \a rect, which is in this item's coordinate system, to
+ \a item's coordinate system, and returns the mapped rectangle as a new
+ rectangle (i.e., the bounding rectangle of the resulting polygon).
+
+ If \a item is 0, this function returns the same as mapRectToScene().
+
+ \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The
+ Graphics View Coordinate System}
+*/
+QRectF QGraphicsItem::mapRectToItem(const QGraphicsItem *item, const QRectF &rect) const
+{
+ if (item)
+ return itemTransform(item).mapRect(rect);
+ return mapRectToScene(rect);
+}
+
+/*!
+ \fn QRectF QGraphicsItem::mapRectToItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
+ \since 4.5
+
+ This convenience function is equivalent to calling mapRectToItem(item, QRectF(\a x, \a y, \a w, \a h)).
+*/
+
+/*!
+ \since 4.5
+
+ Maps the rectangle \a rect, which is in this item's coordinate system, to
+ its parent's coordinate system, and returns the mapped rectangle as a new
+ rectangle (i.e., the bounding rectangle of the resulting polygon).
+
+ \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The
+ Graphics View Coordinate System}
+*/
+QRectF QGraphicsItem::mapRectToParent(const QRectF &rect) const
+{
+ // COMBINE
+ if (!d_ptr->transformData)
+ return rect.translated(d_ptr->pos);
+ return d_ptr->transformToParent().mapRect(rect);
+}
+
+/*!
+ \fn QRectF QGraphicsItem::mapRectToParent(qreal x, qreal y, qreal w, qreal h) const
+ \since 4.5
+
+ This convenience function is equivalent to calling mapRectToParent(QRectF(\a x, \a y, \a w, \a h)).
+*/
+
+/*!
+ \since 4.5
+
+ Maps the rectangle \a rect, which is in this item's coordinate system, to
+ the scene coordinate system, and returns the mapped rectangle as a new
+ rectangle (i.e., the bounding rectangle of the resulting polygon).
+
+ \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The
+ Graphics View Coordinate System}
+*/
+QRectF QGraphicsItem::mapRectToScene(const QRectF &rect) const
+{
+ if (d_ptr->hasTranslateOnlySceneTransform())
+ return rect.translated(d_ptr->sceneTransform.dx(), d_ptr->sceneTransform.dy());
+ return d_ptr->sceneTransform.mapRect(rect);
+}
+
+/*!
+ \fn QRectF QGraphicsItem::mapRectToScene(qreal x, qreal y, qreal w, qreal h) const
+ \since 4.5
+
+ This convenience function is equivalent to calling mapRectToScene(QRectF(\a x, \a y, \a w, \a h)).
+*/
+
+/*!
+ \since 4.5
+
+ Maps the rectangle \a rect, which is in \a item's coordinate system, to
+ this item's coordinate system, and returns the mapped rectangle as a new
+ rectangle (i.e., the bounding rectangle of the resulting polygon).
+
+ If \a item is 0, this function returns the same as mapRectFromScene().
+
+ \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The
+ Graphics View Coordinate System}
+*/
+QRectF QGraphicsItem::mapRectFromItem(const QGraphicsItem *item, const QRectF &rect) const
+{
+ if (item)
+ return item->itemTransform(this).mapRect(rect);
+ return mapRectFromScene(rect);
+}
+
+/*!
+ \fn QRectF QGraphicsItem::mapRectFromItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
+ \since 4.5
+
+ This convenience function is equivalent to calling mapRectFromItem(item, QRectF(\a x, \a y, \a w, \a h)).
+*/
+
+/*!
+ \since 4.5
+
+ Maps the rectangle \a rect, which is in this item's parent's coordinate
+ system, to this item's coordinate system, and returns the mapped rectangle
+ as a new rectangle (i.e., the bounding rectangle of the resulting
+ polygon).
+
+ \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The
+ Graphics View Coordinate System}
+*/
+QRectF QGraphicsItem::mapRectFromParent(const QRectF &rect) const
+{
+ // COMBINE
+ if (!d_ptr->transformData)
+ return rect.translated(-d_ptr->pos);
+ return d_ptr->transformToParent().inverted().mapRect(rect);
+}
+
+/*!
+ \fn QRectF QGraphicsItem::mapRectFromParent(qreal x, qreal y, qreal w, qreal h) const
+ \since 4.5
+
+ This convenience function is equivalent to calling mapRectFromParent(QRectF(\a x, \a y, \a w, \a h)).
+*/
+
+/*!
+ \since 4.5
+
+ Maps the rectangle \a rect, which is in scene coordinates, to this item's
+ coordinate system, and returns the mapped rectangle as a new rectangle
+ (i.e., the bounding rectangle of the resulting polygon).
+
+ \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The
+ Graphics View Coordinate System}
+*/
+QRectF QGraphicsItem::mapRectFromScene(const QRectF &rect) const
+{
+ if (d_ptr->hasTranslateOnlySceneTransform())
+ return rect.translated(-d_ptr->sceneTransform.dx(), -d_ptr->sceneTransform.dy());
+ return d_ptr->sceneTransform.inverted().mapRect(rect);
+}
+
+/*!
+ \fn QRectF QGraphicsItem::mapRectFromScene(qreal x, qreal y, qreal w, qreal h) const
+ \since 4.5
+
+ This convenience function is equivalent to calling mapRectFromScene(QRectF(\a x, \a y, \a w, \a h)).
+*/
+
+/*!
+ Maps the polygon \a polygon, which is in this item's coordinate system, to
+ \a item's coordinate system, and returns the mapped polygon.
+
+ If \a item is 0, this function returns the same as mapToScene().
+
+ \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The
+ Graphics View Coordinate System}
+*/
+QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPolygonF &polygon) const
+{
+ if (item)
+ return itemTransform(item).map(polygon);
+ return mapToScene(polygon);
+}
+
+/*!
+ Maps the polygon \a polygon, which is in this item's coordinate system, to
+ its parent's coordinate system, and returns the mapped polygon. If the
+ item has no parent, \a polygon will be mapped to the scene's coordinate
+ system.
+
+ \sa mapToScene(), mapToItem(), mapFromParent(), {The Graphics View
+ Coordinate System}
+*/
+QPolygonF QGraphicsItem::mapToParent(const QPolygonF &polygon) const
+{
+ // COMBINE
+ if (!d_ptr->transformData)
+ return polygon.translated(d_ptr->pos);
+ return d_ptr->transformToParent().map(polygon);
+}
+
+/*!
+ Maps the polygon \a polygon, which is in this item's coordinate system, to
+ the scene's coordinate system, and returns the mapped polygon.
+
+ \sa mapToParent(), mapToItem(), mapFromScene(), {The Graphics View
+ Coordinate System}
+*/
+QPolygonF QGraphicsItem::mapToScene(const QPolygonF &polygon) const
+{
+ if (d_ptr->hasTranslateOnlySceneTransform())
+ return polygon.translated(d_ptr->sceneTransform.dx(), d_ptr->sceneTransform.dy());
+ return d_ptr->sceneTransform.map(polygon);
+}
+
+/*!
+ Maps the path \a path, which is in this item's coordinate system, to
+ \a item's coordinate system, and returns the mapped path.
+
+ If \a item is 0, this function returns the same as mapToScene().
+
+ \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The
+ Graphics View Coordinate System}
+*/
+QPainterPath QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPainterPath &path) const
+{
+ if (item)
+ return itemTransform(item).map(path);
+ return mapToScene(path);
+}
+
+/*!
+ Maps the path \a path, which is in this item's coordinate system, to
+ its parent's coordinate system, and returns the mapped path. If the
+ item has no parent, \a path will be mapped to the scene's coordinate
+ system.
+
+ \sa mapToScene(), mapToItem(), mapFromParent(), {The Graphics View
+ Coordinate System}
+*/
+QPainterPath QGraphicsItem::mapToParent(const QPainterPath &path) const
+{
+ // COMBINE
+ if (!d_ptr->transformData)
+ return path.translated(d_ptr->pos);
+ return d_ptr->transformToParent().map(path);
+}
+
+/*!
+ Maps the path \a path, which is in this item's coordinate system, to
+ the scene's coordinate system, and returns the mapped path.
+
+ \sa mapToParent(), mapToItem(), mapFromScene(), {The Graphics View
+ Coordinate System}
+*/
+QPainterPath QGraphicsItem::mapToScene(const QPainterPath &path) const
+{
+ if (d_ptr->hasTranslateOnlySceneTransform())
+ return path.translated(d_ptr->sceneTransform.dx(), d_ptr->sceneTransform.dy());
+ return d_ptr->sceneTransform.map(path);
+}
+
+/*!
+ Maps the point \a point, which is in \a item's coordinate system, to this
+ item's coordinate system, and returns the mapped coordinate.
+
+ If \a item is 0, this function returns the same as mapFromScene().
+
+ \sa itemTransform(), mapFromParent(), mapFromScene(), transform(), mapToItem(), {The Graphics
+ View Coordinate System}
+*/
+QPointF QGraphicsItem::mapFromItem(const QGraphicsItem *item, const QPointF &point) const
+{
+ if (item)
+ return item->itemTransform(this).map(point);
+ return mapFromScene(point);
+}
+
+/*!
+ \fn QPointF QGraphicsItem::mapFromItem(const QGraphicsItem *item, qreal x, qreal y) const
+ \overload
+
+ This convenience function is equivalent to calling mapFromItem(\a item,
+ QPointF(\a x, \a y)).
+*/
+
+/*!
+ Maps the point \a point, which is in this item's parent's coordinate
+ system, to this item's coordinate system, and returns the mapped
+ coordinate.
+
+ \sa mapFromItem(), mapFromScene(), transform(), mapToParent(), {The Graphics
+ View Coordinate System}
+*/
+QPointF QGraphicsItem::mapFromParent(const QPointF &point) const
+{
+ // COMBINE
+ if (d_ptr->transformData)
+ return d_ptr->transformToParent().inverted().map(point);
+ return point - d_ptr->pos;
+}
+
+/*!
+ \fn QPointF QGraphicsItem::mapFromParent(qreal x, qreal y) const
+ \overload
+
+ This convenience function is equivalent to calling
+ mapFromParent(QPointF(\a x, \a y)).
+*/
+
+/*!
+ Maps the point \a point, which is in this item's scene's coordinate
+ system, to this item's coordinate system, and returns the mapped
+ coordinate.
+
+ \sa mapFromItem(), mapFromParent(), transform(), mapToScene(), {The Graphics
+ View Coordinate System}
+*/
+QPointF QGraphicsItem::mapFromScene(const QPointF &point) const
+{
+ if (d_ptr->hasTranslateOnlySceneTransform())
+ return QPointF(point.x() - d_ptr->sceneTransform.dx(), point.y() - d_ptr->sceneTransform.dy());
+ return d_ptr->sceneTransform.inverted().map(point);
+}
+
+/*!
+ \fn QPointF QGraphicsItem::mapFromScene(qreal x, qreal y) const
+ \overload
+
+ This convenience function is equivalent to calling mapFromScene(QPointF(\a
+ x, \a y)).
+*/
+
+/*!
+ Maps the rectangle \a rect, which is in \a item's coordinate system, to
+ this item's coordinate system, and returns the mapped rectangle as a
+ polygon.
+
+ If \a item is 0, this function returns the same as mapFromScene()
+
+ \sa itemTransform(), mapToItem(), mapFromParent(), transform(), {The Graphics View Coordinate
+ System}
+*/
+QPolygonF QGraphicsItem::mapFromItem(const QGraphicsItem *item, const QRectF &rect) const
+{
+ if (item)
+ return item->itemTransform(this).map(rect);
+ return mapFromScene(rect);
+}
+
+/*!
+ \fn QPolygonF QGraphicsItem::mapFromItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const
+ \since 4.3
+
+ This convenience function is equivalent to calling mapFromItem(item, QRectF(\a x, \a y, \a w, \a h)).
+*/
+
+/*!
+ Maps the rectangle \a rect, which is in this item's parent's coordinate
+ system, to this item's coordinate system, and returns the mapped rectangle
+ as a polygon.
+
+ \sa mapToParent(), mapFromItem(), transform(), {The Graphics View Coordinate
+ System}
+*/
+QPolygonF QGraphicsItem::mapFromParent(const QRectF &rect) const
+{
+ // COMBINE
+ if (!d_ptr->transformData)
+ return rect.translated(-d_ptr->pos);
+ return d_ptr->transformToParent().inverted().map(rect);
+}
+
+/*!
+ \fn QPolygonF QGraphicsItem::mapFromParent(qreal x, qreal y, qreal w, qreal h) const
+ \since 4.3
+
+ This convenience function is equivalent to calling mapFromItem(QRectF(\a x, \a y, \a w, \a h)).
+*/
+
+/*!
+ Maps the rectangle \a rect, which is in this item's scene's coordinate
+ system, to this item's coordinate system, and returns the mapped rectangle
+ as a polygon.
+
+ \sa mapToScene(), mapFromItem(), transform(), {The Graphics View Coordinate
+ System}
+*/
+QPolygonF QGraphicsItem::mapFromScene(const QRectF &rect) const
+{
+ if (d_ptr->hasTranslateOnlySceneTransform())
+ return rect.translated(-d_ptr->sceneTransform.dx(), -d_ptr->sceneTransform.dy());
+ return d_ptr->sceneTransform.inverted().map(rect);
+}
+
+/*!
+ \fn QPolygonF QGraphicsItem::mapFromScene(qreal x, qreal y, qreal w, qreal h) const
+ \since 4.3
+
+ This convenience function is equivalent to calling mapFromScene(QRectF(\a x, \a y, \a w, \a h)).
+*/
+
+/*!
+ Maps the polygon \a polygon, which is in \a item's coordinate system, to
+ this item's coordinate system, and returns the mapped polygon.
+
+ If \a item is 0, this function returns the same as mapFromScene().
+
+ \sa itemTransform(), mapToItem(), mapFromParent(), transform(), {The
+ Graphics View Coordinate System}
+*/
+QPolygonF QGraphicsItem::mapFromItem(const QGraphicsItem *item, const QPolygonF &polygon) const
+{
+ if (item)
+ return item->itemTransform(this).map(polygon);
+ return mapFromScene(polygon);
+}
+
+/*!
+ Maps the polygon \a polygon, which is in this item's parent's coordinate
+ system, to this item's coordinate system, and returns the mapped polygon.
+
+ \sa mapToParent(), mapToItem(), transform(), {The Graphics View Coordinate
+ System}
+*/
+QPolygonF QGraphicsItem::mapFromParent(const QPolygonF &polygon) const
+{
+ // COMBINE
+ if (!d_ptr->transformData)
+ return polygon.translated(-d_ptr->pos);
+ return d_ptr->transformToParent().inverted().map(polygon);
+}
+
+/*!
+ Maps the polygon \a polygon, which is in this item's scene's coordinate
+ system, to this item's coordinate system, and returns the mapped polygon.
+
+ \sa mapToScene(), mapFromParent(), transform(), {The Graphics View Coordinate
+ System}
+*/
+QPolygonF QGraphicsItem::mapFromScene(const QPolygonF &polygon) const
+{
+ if (d_ptr->hasTranslateOnlySceneTransform())
+ return polygon.translated(-d_ptr->sceneTransform.dx(), -d_ptr->sceneTransform.dy());
+ return d_ptr->sceneTransform.inverted().map(polygon);
+}
+
+/*!
+ Maps the path \a path, which is in \a item's coordinate system, to
+ this item's coordinate system, and returns the mapped path.
+
+ If \a item is 0, this function returns the same as mapFromScene().
+
+ \sa itemTransform(), mapFromParent(), mapFromScene(), mapToItem(), {The
+ Graphics View Coordinate System}
+*/
+QPainterPath QGraphicsItem::mapFromItem(const QGraphicsItem *item, const QPainterPath &path) const
+{
+ if (item)
+ return item->itemTransform(this).map(path);
+ return mapFromScene(path);
+}
+
+/*!
+ Maps the path \a path, which is in this item's parent's coordinate
+ system, to this item's coordinate system, and returns the mapped path.
+
+ \sa mapFromScene(), mapFromItem(), mapToParent(), {The Graphics View
+ Coordinate System}
+*/
+QPainterPath QGraphicsItem::mapFromParent(const QPainterPath &path) const
+{
+ // COMBINE
+ if (!d_ptr->transformData)
+ return path.translated(-d_ptr->pos);
+ return d_ptr->transformToParent().inverted().map(path);
+}
+
+/*!
+ Maps the path \a path, which is in this item's scene's coordinate
+ system, to this item's coordinate system, and returns the mapped path.
+
+ \sa mapFromParent(), mapFromItem(), mapToScene(), {The Graphics View
+ Coordinate System}
+*/
+QPainterPath QGraphicsItem::mapFromScene(const QPainterPath &path) const
+{
+ if (d_ptr->hasTranslateOnlySceneTransform())
+ return path.translated(-d_ptr->sceneTransform.dx(), -d_ptr->sceneTransform.dy());
+ return d_ptr->sceneTransform.inverted().map(path);
+}
+
+/*!
+ Returns true if this item is an ancestor of \a child (i.e., if this item
+ is \a child's parent, or one of \a child's parent's ancestors).
+
+ \sa parentItem()
+*/
+bool QGraphicsItem::isAncestorOf(const QGraphicsItem *child) const
+{
+ if (!child || child == this)
+ return false;
+ if (child->d_ptr->depth() < d_ptr->depth())
+ return false;
+ const QGraphicsItem *ancestor = child;
+ while ((ancestor = ancestor->d_ptr->parent)) {
+ if (ancestor == this)
+ return true;
+ }
+ return false;
+}
+
+/*!
+ \since 4.4
+
+ Returns the closest common ancestor item of this item and \a other, or 0
+ if either \a other is 0, or there is no common ancestor.
+
+ \sa isAncestorOf()
+*/
+QGraphicsItem *QGraphicsItem::commonAncestorItem(const QGraphicsItem *other) const
+{
+ if (!other)
+ return 0;
+ if (other == this)
+ return const_cast<QGraphicsItem *>(this);
+ const QGraphicsItem *thisw = this;
+ const QGraphicsItem *otherw = other;
+ int thisDepth = d_ptr->depth();
+ int otherDepth = other->d_ptr->depth();
+ while (thisDepth > otherDepth) {
+ thisw = thisw->d_ptr->parent;
+ --thisDepth;
+ }
+ while (otherDepth > thisDepth) {
+ otherw = otherw->d_ptr->parent;
+ --otherDepth;
+ }
+ while (thisw && thisw != otherw) {
+ thisw = thisw->d_ptr->parent;
+ otherw = otherw->d_ptr->parent;
+ }
+ return const_cast<QGraphicsItem *>(thisw);
+}
+
+/*!
+ \since 4,4
+ Returns true if this item is currently under the mouse cursor in one of
+ the views; otherwise, false is returned.
+
+ \sa QGraphicsScene::views(), QCursor::pos()
+*/
+bool QGraphicsItem::isUnderMouse() const
+{
+ Q_D(const QGraphicsItem);
+ if (!d->scene)
+ return false;
+
+ QPoint cursorPos = QCursor::pos();
+ foreach (QGraphicsView *view, d->scene->views()) {
+ if (contains(mapFromScene(view->mapToScene(view->mapFromGlobal(cursorPos)))))
+ return true;
+ }
+ return false;
+}
+
+/*!
+ Returns this item's custom data for the key \a key as a QVariant.
+
+ Custom item data is useful for storing arbitrary properties in any
+ item. Example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 11
+
+ Qt does not use this feature for storing data; it is provided solely
+ for the convenience of the user.
+
+ \sa setData()
+*/
+QVariant QGraphicsItem::data(int key) const
+{
+ QGraphicsItemCustomDataStore *store = qt_dataStore();
+ if (!store->data.contains(this))
+ return QVariant();
+ return store->data.value(this).value(key);
+}
+
+/*!
+ Sets this item's custom data for the key \a key to \a value.
+
+ Custom item data is useful for storing arbitrary properties for any
+ item. Qt does not use this feature for storing data; it is provided solely
+ for the convenience of the user.
+
+ \sa data()
+*/
+void QGraphicsItem::setData(int key, const QVariant &value)
+{
+ qt_dataStore()->data[this][key] = value;
+}
+
+/*!
+ \fn T qgraphicsitem_cast(QGraphicsItem *item)
+ \relates QGraphicsItem
+ \since 4.2
+
+ Returns the given \a item cast to type T if \a item is of type T;
+ otherwise, 0 is returned.
+
+ \note To make this function work correctly with custom items, reimplement
+ the \l{QGraphicsItem::}{type()} function for each custom QGraphicsItem
+ subclass.
+
+ \sa QGraphicsItem::type(), QGraphicsItem::UserType
+*/
+
+/*!
+ Returns the type of an item as an int. All standard graphicsitem classes
+ are associated with a unique value; see QGraphicsItem::Type. This type
+ information is used by qgraphicsitem_cast() to distinguish between types.
+
+ The default implementation (in QGraphicsItem) returns UserType.
+
+ To enable use of qgraphicsitem_cast() with a custom item, reimplement this
+ function and declare a Type enum value equal to your custom item's type.
+ Custom items must return a value larger than or equal to UserType (65536).
+
+ For example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp QGraphicsItem type
+
+ \sa UserType
+*/
+int QGraphicsItem::type() const
+{
+ return (int)UserType;
+}
+
+/*!
+ Installs an event filter for this item on \a filterItem, causing
+ all events for this item to first pass through \a filterItem's
+ sceneEventFilter() function.
+
+ To filter another item's events, install this item as an event filter
+ for the other item. Example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 12
+
+ An item can only filter events for other items in the same
+ scene. Also, an item cannot filter its own events; instead, you
+ can reimplement sceneEvent() directly.
+
+ Items must belong to a scene for scene event filters to be installed and
+ used.
+
+ \sa removeSceneEventFilter(), sceneEventFilter(), sceneEvent()
+*/
+void QGraphicsItem::installSceneEventFilter(QGraphicsItem *filterItem)
+{
+ if (!d_ptr->scene) {
+ qWarning("QGraphicsItem::installSceneEventFilter: event filters can only be installed"
+ " on items in a scene.");
+ return;
+ }
+ if (d_ptr->scene != filterItem->scene()) {
+ qWarning("QGraphicsItem::installSceneEventFilter: event filters can only be installed"
+ " on items in the same scene.");
+ return;
+ }
+ d_ptr->scene->d_func()->installSceneEventFilter(this, filterItem);
+}
+
+/*!
+ Removes an event filter on this item from \a filterItem.
+
+ \sa installSceneEventFilter()
+*/
+void QGraphicsItem::removeSceneEventFilter(QGraphicsItem *filterItem)
+{
+ if (!d_ptr->scene || d_ptr->scene != filterItem->scene())
+ return;
+ d_ptr->scene->d_func()->removeSceneEventFilter(this, filterItem);
+}
+
+/*!
+ Filters events for the item \a watched. \a event is the filtered
+ event.
+
+ Reimplementing this function in a subclass makes it possible
+ for the item to be used as an event filter for other items,
+ intercepting all the events send to those items before they are
+ able to respond.
+
+ Reimplementations must return true to prevent further processing of
+ a given event, ensuring that it will not be delivered to the watched
+ item, or return false to indicate that the event should be propagated
+ further by the event system.
+
+ \sa installSceneEventFilter()
+*/
+bool QGraphicsItem::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
+{
+ Q_UNUSED(watched);
+ Q_UNUSED(event);
+ return false;
+}
+
+/*!
+ This virtual function receives events to this item. Reimplement
+ this function to intercept events before they are dispatched to
+ the specialized event handlers contextMenuEvent(), focusInEvent(),
+ focusOutEvent(), hoverEnterEvent(), hoverMoveEvent(),
+ hoverLeaveEvent(), keyPressEvent(), keyReleaseEvent(),
+ mousePressEvent(), mouseReleaseEvent(), mouseMoveEvent(), and
+ mouseDoubleClickEvent().
+
+ Returns true if the event was recognized and handled; otherwise, (e.g., if
+ the event type was not recognized,) false is returned.
+
+ \a event is the intercepted event.
+*/
+bool QGraphicsItem::sceneEvent(QEvent *event)
+{
+ if (d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents) {
+ if (event->type() == QEvent::HoverEnter || event->type() == QEvent::HoverLeave
+ || event->type() == QEvent::DragEnter || event->type() == QEvent::DragLeave) {
+ // Hover enter and hover leave events for children are ignored;
+ // hover move events are forwarded.
+ return true;
+ }
+
+ QGraphicsItem *handler = this;
+ do {
+ handler = handler->d_ptr->parent;
+ Q_ASSERT(handler);
+ } while (handler->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents);
+ // Forward the event to the closest parent that handles child
+ // events, mapping existing item-local coordinates to its
+ // coordinate system.
+ d_ptr->remapItemPos(event, handler);
+ handler->sceneEvent(event);
+ return true;
+ }
+
+ if (event->type() == QEvent::FocusOut) {
+ focusOutEvent(static_cast<QFocusEvent *>(event));
+ return true;
+ }
+
+ if (!d_ptr->visible) {
+ // Eaten
+ return true;
+ }
+
+ switch (event->type()) {
+ case QEvent::FocusIn:
+ focusInEvent(static_cast<QFocusEvent *>(event));
+ break;
+ case QEvent::GraphicsSceneContextMenu:
+ contextMenuEvent(static_cast<QGraphicsSceneContextMenuEvent *>(event));
+ break;
+ case QEvent::GraphicsSceneDragEnter:
+ dragEnterEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
+ break;
+ case QEvent::GraphicsSceneDragMove:
+ dragMoveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
+ break;
+ case QEvent::GraphicsSceneDragLeave:
+ dragLeaveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
+ break;
+ case QEvent::GraphicsSceneDrop:
+ dropEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
+ break;
+ case QEvent::GraphicsSceneHoverEnter:
+ hoverEnterEvent(static_cast<QGraphicsSceneHoverEvent *>(event));
+ break;
+ case QEvent::GraphicsSceneHoverMove:
+ hoverMoveEvent(static_cast<QGraphicsSceneHoverEvent *>(event));
+ break;
+ case QEvent::GraphicsSceneHoverLeave:
+ hoverLeaveEvent(static_cast<QGraphicsSceneHoverEvent *>(event));
+ break;
+ case QEvent::GraphicsSceneMouseMove:
+ mouseMoveEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
+ break;
+ case QEvent::GraphicsSceneMousePress:
+ mousePressEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
+ break;
+ case QEvent::GraphicsSceneMouseRelease:
+ mouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
+ break;
+ case QEvent::GraphicsSceneMouseDoubleClick:
+ mouseDoubleClickEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
+ break;
+ case QEvent::GraphicsSceneWheel:
+ wheelEvent(static_cast<QGraphicsSceneWheelEvent *>(event));
+ break;
+ case QEvent::KeyPress: {
+ QKeyEvent *k = static_cast<QKeyEvent *>(event);
+ if (k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) {
+ if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier?
+ bool res = false;
+ if (k->key() == Qt::Key_Backtab
+ || (k->key() == Qt::Key_Tab && (k->modifiers() & Qt::ShiftModifier))) {
+ if (d_ptr->isWidget) {
+ res = static_cast<QGraphicsWidget *>(this)->focusNextPrevChild(false);
+ } else if (d_ptr->scene) {
+ res = d_ptr->scene->focusNextPrevChild(false);
+ }
+ } else if (k->key() == Qt::Key_Tab) {
+ if (d_ptr->isWidget) {
+ res = static_cast<QGraphicsWidget *>(this)->focusNextPrevChild(true);
+ } else if (d_ptr->scene) {
+ res = d_ptr->scene->focusNextPrevChild(true);
+ }
+ }
+ if (!res)
+ event->ignore();
+ return true;
+ }
+ }
+ keyPressEvent(static_cast<QKeyEvent *>(event));
+ break;
+ }
+ case QEvent::KeyRelease:
+ keyReleaseEvent(static_cast<QKeyEvent *>(event));
+ break;
+ case QEvent::InputMethod:
+ inputMethodEvent(static_cast<QInputMethodEvent *>(event));
+ break;
+ case QEvent::WindowActivate:
+ case QEvent::WindowDeactivate:
+ // Propagate panel activation.
+ if (d_ptr->scene) {
+ for (int i = 0; i < d_ptr->children.size(); ++i) {
+ QGraphicsItem *child = d_ptr->children.at(i);
+ if (child->isVisible() && !child->isPanel()) {
+ if (!(child->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents))
+ d_ptr->scene->sendEvent(child, event);
+ }
+ }
+ }
+ break;
+ default:
+ return false;
+ }
+
+ return true;
+}
+
+/*!
+ This event handler can be reimplemented in a subclass to process context
+ menu events. The \a event parameter contains details about the event to
+ be handled.
+
+ If you ignore the event, (i.e., by calling QEvent::ignore(),) \a event
+ will propagate to any item beneath this item. If no items accept the
+ event, it will be ignored by the scene, and propagate to the view.
+
+ It's common to open a QMenu in response to receiving a context menu
+ event. Example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 13
+
+ The default implementation ignores the event.
+
+ \sa sceneEvent()
+*/
+void QGraphicsItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
+{
+ event->ignore();
+}
+
+/*!
+ This event handler, for event \a event, can be reimplemented to receive
+ drag enter events for this item. Drag enter events are generated as the
+ cursor enters the item's area.
+
+ By accepting the event, (i.e., by calling QEvent::accept(),) the item will
+ accept drop events, in addition to receiving drag move and drag
+ leave. Otherwise, the event will be ignored and propagate to the item
+ beneath. If the event is accepted, the item will receive a drag move event
+ before control goes back to the event loop.
+
+ A common implementation of dragEnterEvent accepts or ignores \a event
+ depending on the associated mime data in \a event. Example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 14
+
+ Items do not receive drag and drop events by default; to enable this
+ feature, call \c setAcceptDrops(true).
+
+ The default implementation does nothing.
+
+ \sa dropEvent(), dragMoveEvent(), dragLeaveEvent()
+*/
+void QGraphicsItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
+{
+ Q_D(QGraphicsItem);
+ // binary compatibility workaround between 4.4 and 4.5
+ if (d->isProxyWidget())
+ static_cast<QGraphicsProxyWidget*>(this)->dragEnterEvent(event);
+}
+
+/*!
+ This event handler, for event \a event, can be reimplemented to receive
+ drag leave events for this item. Drag leave events are generated as the
+ cursor leaves the item's area. Most often you will not need to reimplement
+ this function, but it can be useful for resetting state in your item
+ (e.g., highlighting).
+
+ Calling QEvent::ignore() or QEvent::accept() on \a event has no effect.
+
+ Items do not receive drag and drop events by default; to enable this
+ feature, call \c setAcceptDrops(true).
+
+ The default implementation does nothing.
+
+ \sa dragEnterEvent(), dropEvent(), dragMoveEvent()
+*/
+void QGraphicsItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
+{
+ Q_D(QGraphicsItem);
+ // binary compatibility workaround between 4.4 and 4.5
+ if (d->isProxyWidget())
+ static_cast<QGraphicsProxyWidget*>(this)->dragLeaveEvent(event);
+}
+
+/*!
+ This event handler, for event \a event, can be reimplemented to receive
+ drag move events for this item. Drag move events are generated as the
+ cursor moves around inside the item's area. Most often you will not need
+ to reimplement this function; it is used to indicate that only parts of
+ the item can accept drops.
+
+ Calling QEvent::ignore() or QEvent::accept() on \a event toggles whether
+ or not the item will accept drops at the position from the event. By
+ default, \a event is accepted, indicating that the item allows drops at
+ the specified position.
+
+ Items do not receive drag and drop events by default; to enable this
+ feature, call \c setAcceptDrops(true).
+
+ The default implementation does nothing.
+
+ \sa dropEvent(), dragEnterEvent(), dragLeaveEvent()
+*/
+void QGraphicsItem::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
+{
+ Q_D(QGraphicsItem);
+ // binary compatibility workaround between 4.4 and 4.5
+ if (d->isProxyWidget())
+ static_cast<QGraphicsProxyWidget*>(this)->dragMoveEvent(event);
+}
+
+/*!
+ This event handler, for event \a event, can be reimplemented to receive
+ drop events for this item. Items can only receive drop events if the last
+ drag move event was accepted.
+
+ Calling QEvent::ignore() or QEvent::accept() on \a event has no effect.
+
+ Items do not receive drag and drop events by default; to enable this
+ feature, call \c setAcceptDrops(true).
+
+ The default implementation does nothing.
+
+ \sa dragEnterEvent(), dragMoveEvent(), dragLeaveEvent()
+*/
+void QGraphicsItem::dropEvent(QGraphicsSceneDragDropEvent *event)
+{
+ Q_D(QGraphicsItem);
+ // binary compatibility workaround between 4.4 and 4.5
+ if (d->isProxyWidget())
+ static_cast<QGraphicsProxyWidget*>(this)->dropEvent(event);
+}
+
+/*!
+ This event handler, for event \a event, can be reimplemented to receive
+ focus in events for this item. The default implementation calls
+ ensureVisible().
+
+ \sa focusOutEvent(), sceneEvent(), setFocus()
+*/
+void QGraphicsItem::focusInEvent(QFocusEvent *event)
+{
+ Q_UNUSED(event);
+ update();
+}
+
+/*!
+ This event handler, for event \a event, can be reimplemented to receive
+ focus out events for this item. The default implementation does nothing.
+
+ \sa focusInEvent(), sceneEvent(), setFocus()
+*/
+void QGraphicsItem::focusOutEvent(QFocusEvent *event)
+{
+ Q_UNUSED(event);
+ update();
+}
+
+/*!
+ This event handler, for event \a event, can be reimplemented to receive
+ hover enter events for this item. The default implementation calls
+ update(); otherwise it does nothing.
+
+ Calling QEvent::ignore() or QEvent::accept() on \a event has no effect.
+
+ \sa hoverMoveEvent(), hoverLeaveEvent(), sceneEvent(), setAcceptHoverEvents()
+*/
+void QGraphicsItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
+{
+ Q_UNUSED(event);
+ update();
+}
+
+/*!
+ This event handler, for event \a event, can be reimplemented to receive
+ hover move events for this item. The default implementation does nothing.
+
+ Calling QEvent::ignore() or QEvent::accept() on \a event has no effect.
+
+ \sa hoverEnterEvent(), hoverLeaveEvent(), sceneEvent(), setAcceptHoverEvents()
+*/
+void QGraphicsItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
+{
+ Q_UNUSED(event);
+}
+
+/*!
+ This event handler, for event \a event, can be reimplemented to receive
+ hover leave events for this item. The default implementation calls
+ update(); otherwise it does nothing.
+
+ Calling QEvent::ignore() or QEvent::accept() on \a event has no effect.
+
+ \sa hoverEnterEvent(), hoverMoveEvent(), sceneEvent(), setAcceptHoverEvents()
+*/
+void QGraphicsItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
+{
+ Q_UNUSED(event);
+ update();
+}
+
+/*!
+ This event handler, for event \a event, can be reimplemented to
+ receive key press events for this item. The default implementation
+ ignores the event. If you reimplement this handler, the event will by
+ default be accepted.
+
+ Note that key events are only received for items that set the
+ ItemIsFocusable flag, and that have keyboard input focus.
+
+ \sa keyReleaseEvent(), setFocus(), QGraphicsScene::setFocusItem(),
+ sceneEvent()
+*/
+void QGraphicsItem::keyPressEvent(QKeyEvent *event)
+{
+ event->ignore();
+}
+
+/*!
+ This event handler, for event \a event, can be reimplemented to receive
+ key release events for this item. The default implementation
+ ignores the event. If you reimplement this handler, the event will by
+ default be accepted.
+
+ Note that key events are only received for items that set the
+ ItemIsFocusable flag, and that have keyboard input focus.
+
+ \sa keyPressEvent(), setFocus(), QGraphicsScene::setFocusItem(),
+ sceneEvent()
+*/
+void QGraphicsItem::keyReleaseEvent(QKeyEvent *event)
+{
+ event->ignore();
+}
+
+/*!
+ This event handler, for event \a event, can be reimplemented to
+ receive mouse press events for this item. Mouse press events are
+ only delivered to items that accept the mouse button that is
+ pressed. By default, an item accepts all mouse buttons, but you
+ can change this by calling setAcceptedMouseButtons().
+
+ The mouse press event decides which item should become the mouse
+ grabber (see QGraphicsScene::mouseGrabberItem()). If you do not
+ reimplement this function, the press event will propagate to any
+ topmost item beneath this item, and no other mouse events will be
+ delivered to this item.
+
+ If you do reimplement this function, \a event will by default be
+ accepted (see QEvent::accept()), and this item is then the mouse
+ grabber. This allows the item to receive future move, release and
+ doubleclick events. If you call QEvent::ignore() on \a event, this
+ item will lose the mouse grab, and \a event will propagate to any
+ topmost item beneath. No further mouse events will be delivered to
+ this item unless a new mouse press event is received.
+
+ The default implementation handles basic item interaction, such as
+ selection and moving. If you want to keep the base implementation
+ when reimplementing this function, call
+ QGraphicsItem::mousePressEvent() in your reimplementation.
+
+ The event is \l{QEvent::ignore()}d for items that are neither
+ \l{QGraphicsItem::ItemIsMovable}{movable} nor
+ \l{QGraphicsItem::ItemIsSelectable}{selectable}.
+
+ \sa mouseMoveEvent(), mouseReleaseEvent(),
+ mouseDoubleClickEvent(), sceneEvent()
+*/
+void QGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ if (event->button() == Qt::LeftButton && (flags() & ItemIsSelectable)) {
+ bool multiSelect = (event->modifiers() & Qt::ControlModifier) != 0;
+ if (!multiSelect) {
+ if (!d_ptr->selected) {
+ if (QGraphicsScene *scene = d_ptr->scene) {
+ ++scene->d_func()->selectionChanging;
+ scene->clearSelection();
+ --scene->d_func()->selectionChanging;
+ }
+ setSelected(true);
+ }
+ }
+ } else if (!(flags() & ItemIsMovable)) {
+ event->ignore();
+ }
+ if (d_ptr->isWidget) {
+ // Qt::Popup closes when you click outside.
+ QGraphicsWidget *w = static_cast<QGraphicsWidget *>(this);
+ if ((w->windowFlags() & Qt::Popup) == Qt::Popup) {
+ event->accept();
+ if (!w->rect().contains(event->pos()))
+ w->close();
+ }
+ }
+}
+
+/*!
+ obsolete
+*/
+bool _qt_movableAncestorIsSelected(const QGraphicsItem *item)
+{
+ const QGraphicsItem *parent = item->parentItem();
+ return parent && (((parent->flags() & QGraphicsItem::ItemIsMovable) && parent->isSelected()) || _qt_movableAncestorIsSelected(parent));
+}
+
+bool QGraphicsItemPrivate::movableAncestorIsSelected(const QGraphicsItem *item)
+{
+ const QGraphicsItem *parent = item->d_ptr->parent;
+ return parent && (((parent->flags() & QGraphicsItem::ItemIsMovable) && parent->isSelected()) || _qt_movableAncestorIsSelected(parent));
+}
+
+/*!
+ This event handler, for event \a event, can be reimplemented to
+ receive mouse move events for this item. If you do receive this
+ event, you can be certain that this item also received a mouse
+ press event, and that this item is the current mouse grabber.
+
+ Calling QEvent::ignore() or QEvent::accept() on \a event has no
+ effect.
+
+ The default implementation handles basic item interaction, such as
+ selection and moving. If you want to keep the base implementation
+ when reimplementing this function, call
+ QGraphicsItem::mouseMoveEvent() in your reimplementation.
+
+ Please note that mousePressEvent() decides which graphics item it
+ is that receives mouse events. See the mousePressEvent()
+ description for details.
+
+ \sa mousePressEvent(), mouseReleaseEvent(),
+ mouseDoubleClickEvent(), sceneEvent()
+*/
+void QGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
+{
+ if ((event->buttons() & Qt::LeftButton) && (flags() & ItemIsMovable)) {
+ // Determine the list of items that need to be moved.
+ QList<QGraphicsItem *> selectedItems;
+ QMap<QGraphicsItem *, QPointF> initialPositions;
+ if (d_ptr->scene) {
+ selectedItems = d_ptr->scene->selectedItems();
+ initialPositions = d_ptr->scene->d_func()->movingItemsInitialPositions;
+ if (initialPositions.isEmpty()) {
+ foreach (QGraphicsItem *item, selectedItems)
+ initialPositions[item] = item->pos();
+ initialPositions[this] = pos();
+ }
+ d_ptr->scene->d_func()->movingItemsInitialPositions = initialPositions;
+ }
+
+ // Find the active view.
+ QGraphicsView *view = 0;
+ if (event->widget())
+ view = qobject_cast<QGraphicsView *>(event->widget()->parentWidget());
+
+ // Move all selected items
+ int i = 0;
+ bool movedMe = false;
+ while (i <= selectedItems.size()) {
+ QGraphicsItem *item = 0;
+ if (i < selectedItems.size())
+ item = selectedItems.at(i);
+ else
+ item = this;
+ if (item == this) {
+ // Slightly clumsy-looking way to ensure that "this" is part
+ // of the list of items to move, this is to avoid allocations
+ // (appending this item to the list of selected items causes a
+ // detach).
+ if (movedMe)
+ break;
+ movedMe = true;
+ }
+
+ if ((item->flags() & ItemIsMovable) && !QGraphicsItemPrivate::movableAncestorIsSelected(item)) {
+ QPointF currentParentPos;
+ QPointF buttonDownParentPos;
+ if (item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorIgnoresTransformations) {
+ // Items whose ancestors ignore transformations need to
+ // map screen coordinates to local coordinates, then map
+ // those to the parent.
+ QTransform viewToItemTransform = (item->deviceTransform(view->viewportTransform())).inverted();
+ currentParentPos = mapToParent(viewToItemTransform.map(QPointF(view->mapFromGlobal(event->screenPos()))));
+ buttonDownParentPos = mapToParent(viewToItemTransform.map(QPointF(view->mapFromGlobal(event->buttonDownScreenPos(Qt::LeftButton)))));
+ } else if (item->flags() & ItemIgnoresTransformations) {
+ // Root items that ignore transformations need to
+ // calculate their diff by mapping viewport coordinates
+ // directly to parent coordinates.
+ // COMBINE
+ QTransform itemTransform;
+ if (item->d_ptr->transformData)
+ itemTransform = item->d_ptr->transformData->computedFullTransform();
+ itemTransform.translate(item->d_ptr->pos.x(), item->d_ptr->pos.y());
+ QTransform viewToParentTransform = itemTransform
+ * (item->sceneTransform() * view->viewportTransform()).inverted();
+ currentParentPos = viewToParentTransform.map(QPointF(view->mapFromGlobal(event->screenPos())));
+ buttonDownParentPos = viewToParentTransform.map(QPointF(view->mapFromGlobal(event->buttonDownScreenPos(Qt::LeftButton))));
+ } else {
+ // All other items simply map from the scene.
+ currentParentPos = item->mapToParent(item->mapFromScene(event->scenePos()));
+ buttonDownParentPos = item->mapToParent(item->mapFromScene(event->buttonDownScenePos(Qt::LeftButton)));
+ }
+
+ item->setPos(initialPositions.value(item) + currentParentPos - buttonDownParentPos);
+
+ if (item->flags() & ItemIsSelectable)
+ item->setSelected(true);
+ }
+ ++i;
+ }
+
+ } else {
+ event->ignore();
+ }
+}
+
+/*!
+ This event handler, for event \a event, can be reimplemented to
+ receive mouse release events for this item.
+
+ Calling QEvent::ignore() or QEvent::accept() on \a event has no
+ effect.
+
+ The default implementation handles basic item interaction, such as
+ selection and moving. If you want to keep the base implementation
+ when reimplementing this function, call
+ QGraphicsItem::mouseReleaseEvent() in your reimplementation.
+
+ Please note that mousePressEvent() decides which graphics item it
+ is that receives mouse events. See the mousePressEvent()
+ description for details.
+
+ \sa mousePressEvent(), mouseMoveEvent(), mouseDoubleClickEvent(),
+ sceneEvent()
+*/
+void QGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+ if (flags() & ItemIsSelectable) {
+ bool multiSelect = (event->modifiers() & Qt::ControlModifier) != 0;
+ if (event->scenePos() == event->buttonDownScenePos(Qt::LeftButton)) {
+ // The item didn't move
+ if (multiSelect) {
+ setSelected(!isSelected());
+ } else {
+ bool selectionChanged = false;
+ if (QGraphicsScene *scene = d_ptr->scene) {
+ ++scene->d_func()->selectionChanging;
+ // Clear everything but this item. Bypass
+ // QGraphicsScene::clearSelection()'s default behavior by
+ // temporarily removing this item from the selection list.
+ if (d_ptr->selected) {
+ scene->d_func()->selectedItems.remove(this);
+ foreach (QGraphicsItem *item, scene->d_func()->selectedItems) {
+ if (item->isSelected()) {
+ selectionChanged = true;
+ break;
+ }
+ }
+ }
+ scene->clearSelection();
+ if (d_ptr->selected)
+ scene->d_func()->selectedItems.insert(this);
+ --scene->d_func()->selectionChanging;
+ if (selectionChanged)
+ emit d_ptr->scene->selectionChanged();
+ }
+ setSelected(true);
+ }
+ }
+ }
+ if (d_ptr->scene && !event->buttons())
+ d_ptr->scene->d_func()->movingItemsInitialPositions.clear();
+}
+
+/*!
+ This event handler, for event \a event, can be reimplemented to
+ receive mouse doubleclick events for this item.
+
+ When doubleclicking an item, the item will first receive a mouse
+ press event, followed by a release event (i.e., a click), then a
+ doubleclick event, and finally a release event.
+
+ Calling QEvent::ignore() or QEvent::accept() on \a event has no
+ effect.
+
+ The default implementation calls mousePressEvent(). If you want to
+ keep the base implementation when reimplementing this function,
+ call QGraphicsItem::mouseDoubleClickEvent() in your
+ reimplementation.
+
+ Note that an item will not receive double click events if it is
+ neither \l {QGraphicsItem::ItemIsSelectable}{selectable} nor
+ \l{QGraphicsItem::ItemIsMovable}{movable} (single mouse clicks are
+ ignored in this case, and that stops the generation of double
+ clicks).
+
+ \sa mousePressEvent(), mouseMoveEvent(), mouseReleaseEvent(), sceneEvent()
+*/
+void QGraphicsItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
+{
+ mousePressEvent(event);
+}
+
+/*!
+ This event handler, for event \a event, can be reimplemented to receive
+ wheel events for this item. If you reimplement this function, \a event
+ will be accepted by default.
+
+ If you ignore the event, (i.e., by calling QEvent::ignore(),) it will
+ propagate to any item beneath this item. If no items accept the event, it
+ will be ignored by the scene, and propagate to the view (e.g., the view's
+ vertical scroll bar).
+
+ The default implementation ignores the event.
+
+ \sa sceneEvent()
+*/
+void QGraphicsItem::wheelEvent(QGraphicsSceneWheelEvent *event)
+{
+ event->ignore();
+}
+
+/*!
+ This event handler, for event \a event, can be reimplemented to receive
+ input method events for this item. The default implementation ignores the
+ event.
+
+ \sa inputMethodQuery(), sceneEvent()
+*/
+void QGraphicsItem::inputMethodEvent(QInputMethodEvent *event)
+{
+ event->ignore();
+}
+
+/*!
+ This method is only relevant for input items. It is used by the
+ input method to query a set of properties of the item to be able
+ to support complex input method operations, such as support for
+ surrounding text and reconversions. \a query specifies which
+ property is queried.
+
+ \sa inputMethodEvent(), QInputMethodEvent, QInputContext
+*/
+QVariant QGraphicsItem::inputMethodQuery(Qt::InputMethodQuery query) const
+{
+ if (isWidget()) {
+ // ### Qt 5: Remove. The reimplementation in
+ // QGraphicsProxyWidget solves this problem (but requires a
+ // recompile to take effect).
+ return d_ptr->inputMethodQueryHelper(query);
+ }
+
+ Q_UNUSED(query);
+ return QVariant();
+}
+
+/*!
+ Returns the current input method hints of this item.
+
+ Input method hints are only relevant for input items.
+ The hints are used by the input method to indicate how it should operate.
+ For example, if the Qt::ImhNumbersOnly flag is set, the input method may change
+ its visual components to reflect that only numbers can be entered.
+
+ The effect may vary between input method implementations.
+
+ \since 4.6
+
+ \sa setInputMethodHints(), inputMethodQuery(), QInputContext
+*/
+Qt::InputMethodHints QGraphicsItem::inputMethodHints() const
+{
+ Q_D(const QGraphicsItem);
+ return d->imHints;
+}
+
+/*!
+ Sets the current input method hints of this item to \a hints.
+
+ \since 4.6
+
+ \sa inputMethodHints(), inputMethodQuery(), QInputContext
+*/
+void QGraphicsItem::setInputMethodHints(Qt::InputMethodHints hints)
+{
+ Q_D(QGraphicsItem);
+ d->imHints = hints;
+ if (!hasFocus())
+ return;
+ d->scene->d_func()->updateInputMethodSensitivityInViews();
+#if !defined(QT_NO_IM) && (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN))
+ QWidget *fw = QApplication::focusWidget();
+ if (!fw)
+ return;
+ for (int i = 0 ; i < scene()->views().count() ; ++i)
+ if (scene()->views().at(i) == fw)
+ if (QInputContext *inputContext = fw->inputContext())
+ inputContext->update();
+#endif
+}
+
+/*!
+ Updates the item's micro focus.
+
+ \since 4.7
+
+ \sa QInputContext
+*/
+void QGraphicsItem::updateMicroFocus()
+{
+#if !defined(QT_NO_IM) && (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN))
+ if (QWidget *fw = QApplication::focusWidget()) {
+ if (scene()) {
+ for (int i = 0 ; i < scene()->views().count() ; ++i) {
+ if (scene()->views().at(i) == fw) {
+ if (QInputContext *inputContext = fw->inputContext()) {
+ inputContext->update();
+#ifndef QT_NO_ACCESSIBILITY
+ // ##### is this correct
+ if (toGraphicsObject())
+ QAccessible::updateAccessibility(toGraphicsObject(), 0, QAccessible::StateChanged);
+#endif
+ break;
+ }
+ }
+ }
+ }
+ }
+#endif
+}
+
+/*!
+ This virtual function is called by QGraphicsItem to notify custom items
+ that some part of the item's state changes. By reimplementing this
+ function, your can react to a change, and in some cases, (depending on \a
+ change,) adjustments can be made.
+
+ \a change is the parameter of the item that is changing. \a value is the
+ new value; the type of the value depends on \a change.
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 15
+
+ The default implementation does nothing, and returns \a value.
+
+ Note: Certain QGraphicsItem functions cannot be called in a
+ reimplementation of this function; see the GraphicsItemChange
+ documentation for details.
+
+ \sa GraphicsItemChange
+*/
+QVariant QGraphicsItem::itemChange(GraphicsItemChange change, const QVariant &value)
+{
+ Q_UNUSED(change);
+ return value;
+}
+
+/*!
+ \internal
+
+ Note: This is provided as a hook to avoid future problems related
+ to adding virtual functions.
+*/
+bool QGraphicsItem::supportsExtension(Extension extension) const
+{
+ Q_UNUSED(extension);
+ return false;
+}
+
+/*!
+ \internal
+
+ Note: This is provided as a hook to avoid future problems related
+ to adding virtual functions.
+*/
+void QGraphicsItem::setExtension(Extension extension, const QVariant &variant)
+{
+ Q_UNUSED(extension);
+ Q_UNUSED(variant);
+}
+
+/*!
+ \internal
+
+ Note: This is provided as a hook to avoid future problems related
+ to adding virtual functions.
+*/
+QVariant QGraphicsItem::extension(const QVariant &variant) const
+{
+ Q_UNUSED(variant);
+ return QVariant();
+}
+
+/*!
+ \internal
+
+ Adds this item to the scene's index. Called in conjunction with
+ removeFromIndex() to ensure the index bookkeeping is correct when
+ the item's position, transformation or shape changes.
+*/
+void QGraphicsItem::addToIndex()
+{
+ if (d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) {
+ // ### add to child index only if applicable
+ return;
+ }
+ if (d_ptr->scene)
+ d_ptr->scene->d_func()->index->addItem(this);
+}
+
+/*!
+ \internal
+
+ Removes this item from the scene's index. Called in conjunction
+ with addToIndex() to ensure the index bookkeeping is correct when
+ the item's position, transformation or shape changes.
+*/
+void QGraphicsItem::removeFromIndex()
+{
+ if (d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) {
+ // ### remove from child index only if applicable
+ return;
+ }
+ if (d_ptr->scene)
+ d_ptr->scene->d_func()->index->removeItem(this);
+}
+
+/*!
+ Prepares the item for a geometry change. Call this function before
+ changing the bounding rect of an item to keep QGraphicsScene's index up to
+ date.
+
+ prepareGeometryChange() will call update() if this is necessary.
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 16
+
+ \sa boundingRect()
+*/
+void QGraphicsItem::prepareGeometryChange()
+{
+ if (d_ptr->inDestructor)
+ return;
+ if (d_ptr->scene) {
+ d_ptr->scene->d_func()->dirtyGrowingItemsBoundingRect = true;
+ d_ptr->geometryChanged = 1;
+ d_ptr->paintedViewBoundingRectsNeedRepaint = 1;
+ d_ptr->notifyBoundingRectChanged = !d_ptr->inSetPosHelper;
+
+ QGraphicsScenePrivate *scenePrivate = d_ptr->scene->d_func();
+ scenePrivate->index->prepareBoundingRectChange(this);
+ scenePrivate->markDirty(this, QRectF(), /*invalidateChildren=*/true, /*force=*/false,
+ /*ignoreOpacity=*/ false, /*removingItemFromScene=*/ false,
+ /*updateBoundingRect=*/true);
+
+ // For compatibility reasons, we have to update the item's old geometry
+ // if someone is connected to the changed signal or the scene has no views.
+ // Note that this has to be done *after* markDirty to ensure that
+ // _q_processDirtyItems is called before _q_emitUpdated.
+ if (scenePrivate->isSignalConnected(scenePrivate->changedSignalIndex)
+ || scenePrivate->views.isEmpty()) {
+ if (d_ptr->hasTranslateOnlySceneTransform()) {
+ d_ptr->scene->update(boundingRect().translated(d_ptr->sceneTransform.dx(),
+ d_ptr->sceneTransform.dy()));
+ } else {
+ d_ptr->scene->update(d_ptr->sceneTransform.mapRect(boundingRect()));
+ }
+ }
+ }
+
+ d_ptr->markParentDirty(/*updateBoundingRect=*/true);
+}
+
+/*!
+ \internal
+
+ Highlights \a item as selected.
+
+ NOTE: This function is a duplicate of qt_graphicsItem_highlightSelected() in
+ qgraphicssvgitem.cpp!
+*/
+static void qt_graphicsItem_highlightSelected(
+ QGraphicsItem *item, QPainter *painter, const QStyleOptionGraphicsItem *option)
+{
+ const QRectF murect = painter->transform().mapRect(QRectF(0, 0, 1, 1));
+ if (qFuzzyIsNull(qMax(murect.width(), murect.height())))
+ return;
+
+ const QRectF mbrect = painter->transform().mapRect(item->boundingRect());
+ if (qMin(mbrect.width(), mbrect.height()) < qreal(1.0))
+ return;
+
+ qreal itemPenWidth;
+ switch (item->type()) {
+ case QGraphicsEllipseItem::Type:
+ itemPenWidth = static_cast<QGraphicsEllipseItem *>(item)->pen().widthF();
+ break;
+ case QGraphicsPathItem::Type:
+ itemPenWidth = static_cast<QGraphicsPathItem *>(item)->pen().widthF();
+ break;
+ case QGraphicsPolygonItem::Type:
+ itemPenWidth = static_cast<QGraphicsPolygonItem *>(item)->pen().widthF();
+ break;
+ case QGraphicsRectItem::Type:
+ itemPenWidth = static_cast<QGraphicsRectItem *>(item)->pen().widthF();
+ break;
+ case QGraphicsSimpleTextItem::Type:
+ itemPenWidth = static_cast<QGraphicsSimpleTextItem *>(item)->pen().widthF();
+ break;
+ case QGraphicsLineItem::Type:
+ itemPenWidth = static_cast<QGraphicsLineItem *>(item)->pen().widthF();
+ break;
+ default:
+ itemPenWidth = 1.0;
+ }
+ const qreal pad = itemPenWidth / 2;
+
+ const qreal penWidth = 0; // cosmetic pen
+
+ const QColor fgcolor = option->palette.windowText().color();
+ const QColor bgcolor( // ensure good contrast against fgcolor
+ fgcolor.red() > 127 ? 0 : 255,
+ fgcolor.green() > 127 ? 0 : 255,
+ fgcolor.blue() > 127 ? 0 : 255);
+
+ painter->setPen(QPen(bgcolor, penWidth, Qt::SolidLine));
+ painter->setBrush(Qt::NoBrush);
+ painter->drawRect(item->boundingRect().adjusted(pad, pad, -pad, -pad));
+
+ painter->setPen(QPen(option->palette.windowText(), 0, Qt::DashLine));
+ painter->setBrush(Qt::NoBrush);
+ painter->drawRect(item->boundingRect().adjusted(pad, pad, -pad, -pad));
+}
+
+/*!
+ \class QGraphicsObject
+ \brief The QGraphicsObject class provides a base class for all graphics items that
+ require signals, slots and properties.
+ \since 4.6
+ \ingroup graphicsview-api
+
+ The class extends a QGraphicsItem with QObject's signal/slot and property mechanisms.
+ It maps many of QGraphicsItem's basic setters and getters to properties and adds notification
+ signals for many of them.
+
+ \section1 Parents and Children
+
+ Each graphics object can be constructed with a parent item. This ensures that the
+ item will be destroyed when its parent item is destroyed. Although QGraphicsObject
+ inherits from both QObject and QGraphicsItem, you should use the functions provided
+ by QGraphicsItem, \e not QObject, to manage the relationships between parent and
+ child items.
+
+ The relationships between items can be explored using the parentItem() and childItems()
+ functions. In the hierarchy of items in a scene, the parentObject() and parentWidget()
+ functions are the equivalent of the QWidget::parent() and QWidget::parentWidget()
+ functions for QWidget subclasses.
+
+ \sa QGraphicsWidget
+*/
+
+/*!
+ Constructs a QGraphicsObject with \a parent.
+*/
+QGraphicsObject::QGraphicsObject(QGraphicsItem *parent)
+ : QGraphicsItem(parent)
+{
+ QGraphicsItem::d_ptr->isObject = true;
+}
+
+/*!
+ \internal
+*/
+QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene)
+ : QGraphicsItem(dd, parent, scene)
+{
+ QGraphicsItem::d_ptr->isObject = true;
+}
+
+#ifndef QT_NO_GESTURES
+/*!
+ Subscribes the graphics object to the given \a gesture with specific \a flags.
+
+ \sa ungrabGesture(), QGestureEvent
+*/
+void QGraphicsObject::grabGesture(Qt::GestureType gesture, Qt::GestureFlags flags)
+{
+ bool contains = QGraphicsItem::d_ptr->gestureContext.contains(gesture);
+ QGraphicsItem::d_ptr->gestureContext.insert(gesture, flags);
+ if (!contains && QGraphicsItem::d_ptr->scene)
+ QGraphicsItem::d_ptr->scene->d_func()->grabGesture(this, gesture);
+}
+
+/*!
+ Unsubscribes the graphics object from the given \a gesture.
+
+ \sa grabGesture(), QGestureEvent
+*/
+void QGraphicsObject::ungrabGesture(Qt::GestureType gesture)
+{
+ if (QGraphicsItem::d_ptr->gestureContext.remove(gesture) && QGraphicsItem::d_ptr->scene)
+ QGraphicsItem::d_ptr->scene->d_func()->ungrabGesture(this, gesture);
+}
+#endif // QT_NO_GESTURES
+
+/*!
+ Updates the item's micro focus. This is slot for convenience.
+
+ \since 4.7
+
+ \sa QInputContext
+*/
+void QGraphicsObject::updateMicroFocus()
+{
+ QGraphicsItem::updateMicroFocus();
+}
+
+void QGraphicsItemPrivate::children_append(QDeclarativeListProperty<QGraphicsObject> *list, QGraphicsObject *item)
+{
+ if (item) {
+ QGraphicsObject *graphicsObject = static_cast<QGraphicsObject *>(list->object);
+ if (QGraphicsItemPrivate::get(graphicsObject)->sendParentChangeNotification) {
+ item->setParentItem(graphicsObject);
+ } else {
+ QGraphicsItemPrivate::get(item)->setParentItemHelper(graphicsObject, 0, 0);
+ }
+ }
+}
+
+int QGraphicsItemPrivate::children_count(QDeclarativeListProperty<QGraphicsObject> *list)
+{
+ QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object));
+ return d->children.count();
+}
+
+QGraphicsObject *QGraphicsItemPrivate::children_at(QDeclarativeListProperty<QGraphicsObject> *list, int index)
+{
+ QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object));
+ if (index >= 0 && index < d->children.count())
+ return d->children.at(index)->toGraphicsObject();
+ else
+ return 0;
+}
+
+void QGraphicsItemPrivate::children_clear(QDeclarativeListProperty<QGraphicsObject> *list)
+{
+ QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object));
+ int childCount = d->children.count();
+ if (d->sendParentChangeNotification) {
+ for (int index = 0; index < childCount; index++)
+ d->children.at(0)->setParentItem(0);
+ } else {
+ for (int index = 0; index < childCount; index++)
+ QGraphicsItemPrivate::get(d->children.at(0))->setParentItemHelper(0, 0, 0);
+ }
+}
+
+/*!
+ Returns a list of this item's children.
+
+ The items are sorted by stacking order. This takes into account both the
+ items' insertion order and their Z-values.
+
+*/
+QDeclarativeListProperty<QGraphicsObject> QGraphicsItemPrivate::childrenList()
+{
+ Q_Q(QGraphicsItem);
+ if (isObject) {
+ QGraphicsObject *that = static_cast<QGraphicsObject *>(q);
+ return QDeclarativeListProperty<QGraphicsObject>(that, &children, children_append,
+ children_count, children_at, children_clear);
+ } else {
+ //QGraphicsItem is not supported for this property
+ return QDeclarativeListProperty<QGraphicsObject>();
+ }
+}
+
+/*!
+ \internal
+ Returns the width of the item
+ Reimplemented by QGraphicsWidget
+*/
+qreal QGraphicsItemPrivate::width() const
+{
+ return 0;
+}
+
+/*!
+ \internal
+ Set the width of the item
+ Reimplemented by QGraphicsWidget
+*/
+void QGraphicsItemPrivate::setWidth(qreal w)
+{
+ Q_UNUSED(w);
+}
+
+/*!
+ \internal
+ Reset the width of the item
+ Reimplemented by QGraphicsWidget
+*/
+void QGraphicsItemPrivate::resetWidth()
+{
+}
+
+/*!
+ \internal
+ Returns the height of the item
+ Reimplemented by QGraphicsWidget
+*/
+qreal QGraphicsItemPrivate::height() const
+{
+ return 0;
+}
+
+/*!
+ \internal
+ Set the height of the item
+ Reimplemented by QGraphicsWidget
+*/
+void QGraphicsItemPrivate::setHeight(qreal h)
+{
+ Q_UNUSED(h);
+}
+
+/*!
+ \internal
+ Reset the height of the item
+ Reimplemented by QGraphicsWidget
+*/
+void QGraphicsItemPrivate::resetHeight()
+{
+}
+
+/*!
+ \property QGraphicsObject::children
+ \since 4.7
+ \internal
+*/
+
+/*!
+ \property QGraphicsObject::width
+ \since 4.7
+ \internal
+*/
+
+/*!
+ \property QGraphicsObject::height
+ \since 4.7
+ \internal
+*/
+
+/*!
+ \property QGraphicsObject::parent
+ \brief the parent of the item
+
+ \note The item's parent is set independently of the parent object returned
+ by QObject::parent().
+
+ \sa QGraphicsItem::setParentItem(), QGraphicsItem::parentObject()
+*/
+
+/*!
+ \property QGraphicsObject::opacity
+ \brief the opacity of the item
+
+ \sa QGraphicsItem::setOpacity(), QGraphicsItem::opacity()
+*/
+
+/*!
+ \fn QGraphicsObject::opacityChanged()
+
+ This signal gets emitted whenever the opacity of the item changes
+
+ \sa QGraphicsItem::opacity()
+*/
+
+/*!
+ \fn QGraphicsObject::parentChanged()
+
+ This signal gets emitted whenever the parent of the item changes
+*/
+
+/*!
+ \property QGraphicsObject::pos
+ \brief the position of the item
+
+ Describes the items position.
+
+ \sa QGraphicsItem::setPos(), QGraphicsItem::pos()
+*/
+
+/*!
+ \property QGraphicsObject::x
+ \brief the x position of the item
+
+ Describes the items x position.
+
+ \sa QGraphicsItem::setX(), setPos(), xChanged()
+*/
+
+/*!
+ \fn QGraphicsObject::xChanged()
+
+ This signal gets emitted whenever the x position of the item changes
+
+ \sa pos()
+*/
+
+/*!
+ \property QGraphicsObject::y
+ \brief the y position of the item
+
+ Describes the items y position.
+
+ \sa QGraphicsItem::setY(), setPos(), yChanged()
+*/
+
+/*!
+ \fn QGraphicsObject::yChanged()
+
+ This signal gets emitted whenever the y position of the item changes.
+
+ \sa pos()
+*/
+
+/*!
+ \property QGraphicsObject::z
+ \brief the z value of the item
+
+ Describes the items z value.
+
+ \sa QGraphicsItem::setZValue(), zValue(), zChanged()
+*/
+
+/*!
+ \fn QGraphicsObject::zChanged()
+
+ This signal gets emitted whenever the z value of the item changes.
+
+ \sa pos()
+*/
+
+/*!
+ \property QGraphicsObject::rotation
+ This property holds the rotation of the item in degrees.
+
+ This specifies how many degrees to rotate the item around its transformOrigin.
+ The default rotation is 0 degrees (i.e. not rotated at all).
+*/
+
+/*!
+ \fn QGraphicsObject::rotationChanged()
+
+ This signal gets emitted whenever the roation of the item changes.
+*/
+
+/*!
+ \property QGraphicsObject::scale
+ This property holds the scale of the item.
+
+ A scale of less than 1 means the item will be displayed smaller than
+ normal, and a scale of greater than 1 means the item will be
+ displayed larger than normal. A negative scale means the item will
+ be mirrored.
+
+ By default, items are displayed at a scale of 1 (i.e. at their
+ normal size).
+
+ Scaling is from the item's transformOrigin.
+*/
+
+/*!
+ \fn void QGraphicsObject::scaleChanged()
+
+ This signal is emitted when the scale of the item changes.
+*/
+
+
+/*!
+ \property QGraphicsObject::enabled
+ \brief whether the item is enabled or not
+
+ This property is declared in QGraphicsItem.
+
+ By default, this property is true.
+
+ \sa QGraphicsItem::isEnabled(), QGraphicsItem::setEnabled()
+ \sa QGraphicsObject::enabledChanged()
+*/
+
+/*!
+ \fn void QGraphicsObject::enabledChanged()
+
+ This signal gets emitted whenever the item get's enabled or disabled.
+
+ \sa isEnabled()
+*/
+
+/*!
+ \property QGraphicsObject::visible
+ \brief whether the item is visible or not
+
+ This property is declared in QGraphicsItem.
+
+ By default, this property is true.
+
+ \sa QGraphicsItem::isVisible(), QGraphicsItem::setVisible(), visibleChanged()
+*/
+
+/*!
+ \fn QGraphicsObject::visibleChanged()
+
+ This signal gets emitted whenever the visibility of the item changes
+
+ \sa visible
+*/
+
+/*!
+ \fn const QObjectList &QGraphicsObject::children() const
+ \internal
+
+ This function returns the same value as QObject::children(). It's
+ provided to differentiate between the obsolete member
+ QGraphicsItem::children() and QObject::children(). QGraphicsItem now
+ provides childItems() instead.
+*/
+
+/*!
+ \property QGraphicsObject::transformOriginPoint
+ \brief the transformation origin
+
+ This property sets a specific point in the items coordiante system as the
+ origin for scale and rotation.
+
+ \sa scale, rotation, QGraphicsItem::transformOriginPoint()
+*/
+
+/*!
+ \fn void QGraphicsObject::widthChanged()
+ \internal
+*/
+
+/*!
+ \fn void QGraphicsObject::heightChanged()
+ \internal
+*/
+
+/*!
+
+ \fn QGraphicsObject::childrenChanged()
+
+ This signal gets emitted whenever the children list changes
+ \internal
+*/
+
+/*!
+ \property QGraphicsObject::effect
+ \since 4.7
+ \brief the effect attached to this item
+
+ \sa QGraphicsItem::setGraphicsEffect(), QGraphicsItem::graphicsEffect()
+*/
+
+/*!
+ \class QAbstractGraphicsShapeItem
+ \brief The QAbstractGraphicsShapeItem class provides a common base for
+ all path items.
+ \since 4.2
+ \ingroup graphicsview-api
+
+ This class does not fully implement an item by itself; in particular, it
+ does not implement boundingRect() and paint(), which are inherited by
+ QGraphicsItem.
+
+ You can subclass this item to provide a simple base implementation of
+ accessors for the item's pen and brush.
+
+ \sa QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPathItem,
+ QGraphicsPolygonItem, QGraphicsTextItem, QGraphicsLineItem,
+ QGraphicsPixmapItem, {Graphics View Framework}
+*/
+
+class QAbstractGraphicsShapeItemPrivate : public QGraphicsItemPrivate
+{
+ Q_DECLARE_PUBLIC(QAbstractGraphicsShapeItem)
+public:
+
+ QBrush brush;
+ QPen pen;
+
+ // Cached bounding rectangle
+ mutable QRectF boundingRect;
+};
+
+/*!
+ Constructs a QAbstractGraphicsShapeItem. \a parent is passed to
+ QGraphicsItem's constructor.
+*/
+QAbstractGraphicsShapeItem::QAbstractGraphicsShapeItem(QGraphicsItem *parent
+#ifndef Q_QDOC
+ // obsolete argument
+ , QGraphicsScene *scene
+#endif
+ )
+ : QGraphicsItem(*new QAbstractGraphicsShapeItemPrivate, parent, scene)
+{
+}
+
+/*!
+ \internal
+*/
+QAbstractGraphicsShapeItem::QAbstractGraphicsShapeItem(QAbstractGraphicsShapeItemPrivate &dd,
+ QGraphicsItem *parent,
+ QGraphicsScene *scene)
+ : QGraphicsItem(dd, parent, scene)
+{
+}
+
+/*!
+ Destroys a QAbstractGraphicsShapeItem.
+*/
+QAbstractGraphicsShapeItem::~QAbstractGraphicsShapeItem()
+{
+}
+
+/*!
+ Returns the item's pen. If no pen has been set, this function returns
+ QPen(), a default black solid line pen with 0 width.
+*/
+QPen QAbstractGraphicsShapeItem::pen() const
+{
+ Q_D(const QAbstractGraphicsShapeItem);
+ return d->pen;
+}
+
+/*!
+ Sets the pen for this item to \a pen.
+
+ The pen is used to draw the item's outline.
+
+ \sa pen()
+*/
+void QAbstractGraphicsShapeItem::setPen(const QPen &pen)
+{
+ Q_D(QAbstractGraphicsShapeItem);
+ if (d->pen == pen)
+ return;
+ prepareGeometryChange();
+ d->pen = pen;
+ d->boundingRect = QRectF();
+ update();
+}
+
+/*!
+ Returns the item's brush, or an empty brush if no brush has been set.
+
+ \sa setBrush()
+*/
+QBrush QAbstractGraphicsShapeItem::brush() const
+{
+ Q_D(const QAbstractGraphicsShapeItem);
+ return d->brush;
+}
+
+/*!
+ Sets the item's brush to \a brush.
+
+ The item's brush is used to fill the item.
+
+ If you use a brush with a QGradient, the gradient
+ is relative to the item's coordinate system.
+
+ \sa brush()
+*/
+void QAbstractGraphicsShapeItem::setBrush(const QBrush &brush)
+{
+ Q_D(QAbstractGraphicsShapeItem);
+ if (d->brush == brush)
+ return;
+ d->brush = brush;
+ update();
+}
+
+/*!
+ \reimp
+*/
+bool QAbstractGraphicsShapeItem::isObscuredBy(const QGraphicsItem *item) const
+{
+ return QGraphicsItem::isObscuredBy(item);
+}
+
+/*!
+ \reimp
+*/
+QPainterPath QAbstractGraphicsShapeItem::opaqueArea() const
+{
+ Q_D(const QAbstractGraphicsShapeItem);
+ if (d->brush.isOpaque())
+ return isClipped() ? clipPath() : shape();
+ return QGraphicsItem::opaqueArea();
+}
+
+/*!
+ \class QGraphicsPathItem
+ \brief The QGraphicsPathItem class provides a path item that you
+ can add to a QGraphicsScene.
+ \since 4.2
+ \ingroup graphicsview-api
+
+ To set the item's path, pass a QPainterPath to QGraphicsPathItem's
+ constructor, or call the setPath() function. The path() function
+ returns the current path.
+
+ \image graphicsview-pathitem.png
+
+ QGraphicsPathItem uses the path to provide a reasonable
+ implementation of boundingRect(), shape(), and contains(). The
+ paint() function draws the path using the item's associated pen
+ and brush, which you can set by calling the setPen() and
+ setBrush() functions.
+
+ \sa QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPolygonItem,
+ QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics
+ View Framework}
+*/
+
+class QGraphicsPathItemPrivate : public QAbstractGraphicsShapeItemPrivate
+{
+ Q_DECLARE_PUBLIC(QGraphicsPathItem)
+public:
+ QPainterPath path;
+};
+
+/*!
+ Constructs a QGraphicsPath item using \a path as the default path. \a
+ parent is passed to QAbstractGraphicsShapeItem's constructor.
+
+ \sa QGraphicsScene::addItem()
+*/
+QGraphicsPathItem::QGraphicsPathItem(const QPainterPath &path,
+ QGraphicsItem *parent
+#ifndef Q_QDOC
+ // obsolete argument
+ , QGraphicsScene *scene
+#endif
+ )
+ : QAbstractGraphicsShapeItem(*new QGraphicsPathItemPrivate, parent, scene)
+{
+ if (!path.isEmpty())
+ setPath(path);
+}
+
+/*!
+ Constructs a QGraphicsPath. \a parent is passed to
+ QAbstractGraphicsShapeItem's constructor.
+
+ \sa QGraphicsScene::addItem()
+*/
+QGraphicsPathItem::QGraphicsPathItem(QGraphicsItem *parent
+#ifndef Q_QDOC
+ // obsolete argument
+ , QGraphicsScene *scene
+#endif
+ )
+ : QAbstractGraphicsShapeItem(*new QGraphicsPathItemPrivate, parent, scene)
+{
+}
+
+/*!
+ Destroys the QGraphicsPathItem.
+*/
+QGraphicsPathItem::~QGraphicsPathItem()
+{
+}
+
+/*!
+ Returns the item's path as a QPainterPath. If no item has been set, an
+ empty QPainterPath is returned.
+
+ \sa setPath()
+*/
+QPainterPath QGraphicsPathItem::path() const
+{
+ Q_D(const QGraphicsPathItem);
+ return d->path;
+}
+
+/*!
+ Sets the item's path to be the given \a path.
+
+ \sa path()
+*/
+void QGraphicsPathItem::setPath(const QPainterPath &path)
+{
+ Q_D(QGraphicsPathItem);
+ if (d->path == path)
+ return;
+ prepareGeometryChange();
+ d->path = path;
+ d->boundingRect = QRectF();
+ update();
+}
+
+/*!
+ \reimp
+*/
+QRectF QGraphicsPathItem::boundingRect() const
+{
+ Q_D(const QGraphicsPathItem);
+ if (d->boundingRect.isNull()) {
+ qreal pw = pen().widthF();
+ if (pw == 0.0)
+ d->boundingRect = d->path.controlPointRect();
+ else {
+ d->boundingRect = shape().controlPointRect();
+ }
+ }
+ return d->boundingRect;
+}
+
+/*!
+ \reimp
+*/
+QPainterPath QGraphicsPathItem::shape() const
+{
+ Q_D(const QGraphicsPathItem);
+ return qt_graphicsItem_shapeFromPath(d->path, d->pen);
+}
+
+/*!
+ \reimp
+*/
+bool QGraphicsPathItem::contains(const QPointF &point) const
+{
+ return QAbstractGraphicsShapeItem::contains(point);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsPathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+ QWidget *widget)
+{
+ Q_D(QGraphicsPathItem);
+ Q_UNUSED(widget);
+ painter->setPen(d->pen);
+ painter->setBrush(d->brush);
+ painter->drawPath(d->path);
+
+ if (option->state & QStyle::State_Selected)
+ qt_graphicsItem_highlightSelected(this, painter, option);
+}
+
+/*!
+ \reimp
+*/
+bool QGraphicsPathItem::isObscuredBy(const QGraphicsItem *item) const
+{
+ return QAbstractGraphicsShapeItem::isObscuredBy(item);
+}
+
+/*!
+ \reimp
+*/
+QPainterPath QGraphicsPathItem::opaqueArea() const
+{
+ return QAbstractGraphicsShapeItem::opaqueArea();
+}
+
+/*!
+ \reimp
+*/
+int QGraphicsPathItem::type() const
+{
+ return Type;
+}
+
+/*!
+ \internal
+*/
+bool QGraphicsPathItem::supportsExtension(Extension extension) const
+{
+ Q_UNUSED(extension);
+ return false;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsPathItem::setExtension(Extension extension, const QVariant &variant)
+{
+ Q_UNUSED(extension);
+ Q_UNUSED(variant);
+}
+
+/*!
+ \internal
+*/
+QVariant QGraphicsPathItem::extension(const QVariant &variant) const
+{
+ Q_UNUSED(variant);
+ return QVariant();
+}
+
+/*!
+ \class QGraphicsRectItem
+ \brief The QGraphicsRectItem class provides a rectangle item that you
+ can add to a QGraphicsScene.
+ \since 4.2
+ \ingroup graphicsview-api
+
+ To set the item's rectangle, pass a QRectF to QGraphicsRectItem's
+ constructor, or call the setRect() function. The rect() function
+ returns the current rectangle.
+
+ \image graphicsview-rectitem.png
+
+ QGraphicsRectItem uses the rectangle and the pen width to provide
+ a reasonable implementation of boundingRect(), shape(), and
+ contains(). The paint() function draws the rectangle using the
+ item's associated pen and brush, which you can set by calling the
+ setPen() and setBrush() functions.
+
+ \note The rendering of invalid rectangles, such as those with negative
+ widths or heights, is undefined. If you cannot be sure that you are
+ using valid rectangles (for example, if you are creating
+ rectangles using data from an unreliable source) then you should
+ use QRectF::normalized() to create normalized rectangles, and use
+ those instead.
+
+ \sa QGraphicsPathItem, QGraphicsEllipseItem, QGraphicsPolygonItem,
+ QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics
+ View Framework}
+*/
+
+class QGraphicsRectItemPrivate : public QAbstractGraphicsShapeItemPrivate
+{
+ Q_DECLARE_PUBLIC(QGraphicsRectItem)
+public:
+ QRectF rect;
+};
+
+/*!
+ Constructs a QGraphicsRectItem, using \a rect as the default rectangle.
+ \a parent is passed to QAbstractGraphicsShapeItem's constructor.
+
+ \sa QGraphicsScene::addItem()
+*/
+QGraphicsRectItem::QGraphicsRectItem(const QRectF &rect, QGraphicsItem *parent
+#ifndef Q_QDOC
+ // obsolete argument
+ , QGraphicsScene *scene
+#endif
+ )
+ : QAbstractGraphicsShapeItem(*new QGraphicsRectItemPrivate, parent, scene)
+{
+ setRect(rect);
+}
+
+/*!
+ \fn QGraphicsRectItem::QGraphicsRectItem(qreal x, qreal y, qreal width, qreal height,
+ QGraphicsItem *parent)
+
+ Constructs a QGraphicsRectItem with a default rectangle defined
+ by (\a x, \a y) and the given \a width and \a height.
+
+ \a parent is passed to QAbstractGraphicsShapeItem's constructor.
+
+ \sa QGraphicsScene::addItem()
+*/
+QGraphicsRectItem::QGraphicsRectItem(qreal x, qreal y, qreal w, qreal h,
+ QGraphicsItem *parent
+#ifndef Q_QDOC
+ // obsolete argument
+ , QGraphicsScene *scene
+#endif
+ )
+ : QAbstractGraphicsShapeItem(*new QGraphicsRectItemPrivate, parent, scene)
+{
+ setRect(QRectF(x, y, w, h));
+}
+
+/*!
+ Constructs a QGraphicsRectItem. \a parent is passed to
+ QAbstractGraphicsShapeItem's constructor.
+
+ \sa QGraphicsScene::addItem()
+*/
+QGraphicsRectItem::QGraphicsRectItem(QGraphicsItem *parent
+#ifndef Q_QDOC
+ // obsolete argument
+ , QGraphicsScene *scene
+#endif
+ )
+ : QAbstractGraphicsShapeItem(*new QGraphicsRectItemPrivate, parent, scene)
+{
+}
+
+/*!
+ Destroys the QGraphicsRectItem.
+*/
+QGraphicsRectItem::~QGraphicsRectItem()
+{
+}
+
+/*!
+ Returns the item's rectangle.
+
+ \sa setRect()
+*/
+QRectF QGraphicsRectItem::rect() const
+{
+ Q_D(const QGraphicsRectItem);
+ return d->rect;
+}
+
+/*!
+ \fn void QGraphicsRectItem::setRect(const QRectF &rectangle)
+
+ Sets the item's rectangle to be the given \a rectangle.
+
+ \sa rect()
+*/
+void QGraphicsRectItem::setRect(const QRectF &rect)
+{
+ Q_D(QGraphicsRectItem);
+ if (d->rect == rect)
+ return;
+ prepareGeometryChange();
+ d->rect = rect;
+ d->boundingRect = QRectF();
+ update();
+}
+
+/*!
+ \fn void QGraphicsRectItem::setRect(qreal x, qreal y, qreal width, qreal height)
+ \fn void QGraphicsEllipseItem::setRect(qreal x, qreal y, qreal width, qreal height)
+
+ Sets the item's rectangle to the rectangle defined by (\a x, \a y)
+ and the given \a width and \a height.
+
+ This convenience function is equivalent to calling \c
+ {setRect(QRectF(x, y, width, height))}
+
+ \sa rect()
+*/
+
+/*!
+ \reimp
+*/
+QRectF QGraphicsRectItem::boundingRect() const
+{
+ Q_D(const QGraphicsRectItem);
+ if (d->boundingRect.isNull()) {
+ qreal halfpw = pen().widthF() / 2;
+ d->boundingRect = d->rect;
+ if (halfpw > 0.0)
+ d->boundingRect.adjust(-halfpw, -halfpw, halfpw, halfpw);
+ }
+ return d->boundingRect;
+}
+
+/*!
+ \reimp
+*/
+QPainterPath QGraphicsRectItem::shape() const
+{
+ Q_D(const QGraphicsRectItem);
+ QPainterPath path;
+ path.addRect(d->rect);
+ return qt_graphicsItem_shapeFromPath(path, d->pen);
+}
+
+/*!
+ \reimp
+*/
+bool QGraphicsRectItem::contains(const QPointF &point) const
+{
+ return QAbstractGraphicsShapeItem::contains(point);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsRectItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+ QWidget *widget)
+{
+ Q_D(QGraphicsRectItem);
+ Q_UNUSED(widget);
+ painter->setPen(d->pen);
+ painter->setBrush(d->brush);
+ painter->drawRect(d->rect);
+
+ if (option->state & QStyle::State_Selected)
+ qt_graphicsItem_highlightSelected(this, painter, option);
+}
+
+/*!
+ \reimp
+*/
+bool QGraphicsRectItem::isObscuredBy(const QGraphicsItem *item) const
+{
+ return QAbstractGraphicsShapeItem::isObscuredBy(item);
+}
+
+/*!
+ \reimp
+*/
+QPainterPath QGraphicsRectItem::opaqueArea() const
+{
+ return QAbstractGraphicsShapeItem::opaqueArea();
+}
+
+/*!
+ \reimp
+*/
+int QGraphicsRectItem::type() const
+{
+ return Type;
+}
+
+/*!
+ \internal
+*/
+bool QGraphicsRectItem::supportsExtension(Extension extension) const
+{
+ Q_UNUSED(extension);
+ return false;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsRectItem::setExtension(Extension extension, const QVariant &variant)
+{
+ Q_UNUSED(extension);
+ Q_UNUSED(variant);
+}
+
+/*!
+ \internal
+*/
+QVariant QGraphicsRectItem::extension(const QVariant &variant) const
+{
+ Q_UNUSED(variant);
+ return QVariant();
+}
+
+/*!
+ \class QGraphicsEllipseItem
+ \brief The QGraphicsEllipseItem class provides an ellipse item that you
+ can add to a QGraphicsScene.
+ \since 4.2
+ \ingroup graphicsview-api
+
+ QGraphicsEllipseItem respresents an ellipse with a fill and an outline,
+ and you can also use it for ellipse segments (see startAngle(),
+ spanAngle()).
+
+ \table
+ \row
+ \o \inlineimage graphicsview-ellipseitem.png
+ \o \inlineimage graphicsview-ellipseitem-pie.png
+ \endtable
+
+ To set the item's ellipse, pass a QRectF to QGraphicsEllipseItem's
+ constructor, or call setRect(). The rect() function returns the
+ current ellipse geometry.
+
+ QGraphicsEllipseItem uses the rect and the pen width to provide a
+ reasonable implementation of boundingRect(), shape(), and contains(). The
+ paint() function draws the ellipse using the item's associated pen and
+ brush, which you can set by calling setPen() and setBrush().
+
+ \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsPolygonItem,
+ QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics
+ View Framework}
+*/
+
+class QGraphicsEllipseItemPrivate : public QAbstractGraphicsShapeItemPrivate
+{
+ Q_DECLARE_PUBLIC(QGraphicsEllipseItem)
+public:
+ inline QGraphicsEllipseItemPrivate()
+ : startAngle(0), spanAngle(360 * 16)
+ { }
+
+ QRectF rect;
+ int startAngle;
+ int spanAngle;
+};
+
+/*!
+ Constructs a QGraphicsEllipseItem using \a rect as the default rectangle.
+ \a parent is passed to QAbstractGraphicsShapeItem's constructor.
+
+ \sa QGraphicsScene::addItem()
+*/
+QGraphicsEllipseItem::QGraphicsEllipseItem(const QRectF &rect, QGraphicsItem *parent
+#ifndef Q_QDOC
+ // obsolete argument
+ , QGraphicsScene *scene
+#endif
+ )
+ : QAbstractGraphicsShapeItem(*new QGraphicsEllipseItemPrivate, parent, scene)
+{
+ setRect(rect);
+}
+
+/*!
+ \fn QGraphicsEllipseItem::QGraphicsEllipseItem(qreal x, qreal y, qreal width, qreal height, QGraphicsItem *parent)
+ \since 4.3
+
+ Constructs a QGraphicsEllipseItem using the rectangle defined by (\a x, \a
+ y) and the given \a width and \a height, as the default rectangle. \a
+ parent is passed to QAbstractGraphicsShapeItem's constructor.
+
+ \sa QGraphicsScene::addItem()
+*/
+QGraphicsEllipseItem::QGraphicsEllipseItem(qreal x, qreal y, qreal w, qreal h,
+ QGraphicsItem *parent
+#ifndef Q_QDOC
+ // obsolete argument
+ , QGraphicsScene *scene
+#endif
+ )
+ : QAbstractGraphicsShapeItem(*new QGraphicsEllipseItemPrivate, parent, scene)
+{
+ setRect(x,y,w,h);
+}
+
+
+
+/*!
+ Constructs a QGraphicsEllipseItem. \a parent is passed to
+ QAbstractGraphicsShapeItem's constructor.
+
+ \sa QGraphicsScene::addItem()
+*/
+QGraphicsEllipseItem::QGraphicsEllipseItem(QGraphicsItem *parent
+#ifndef Q_QDOC
+ // obsolete argument
+ , QGraphicsScene *scene
+#endif
+ )
+ : QAbstractGraphicsShapeItem(*new QGraphicsEllipseItemPrivate, parent, scene)
+{
+}
+
+/*!
+ Destroys the QGraphicsEllipseItem.
+*/
+QGraphicsEllipseItem::~QGraphicsEllipseItem()
+{
+}
+
+/*!
+ Returns the item's ellipse geometry as a QRectF.
+
+ \sa setRect(), QPainter::drawEllipse()
+*/
+QRectF QGraphicsEllipseItem::rect() const
+{
+ Q_D(const QGraphicsEllipseItem);
+ return d->rect;
+}
+
+/*!
+ Sets the item's ellipse geometry to \a rect. The rectangle's left edge
+ defines the left edge of the ellipse, and the rectangle's top edge
+ describes the top of the ellipse. The height and width of the rectangle
+ describe the height and width of the ellipse.
+
+ \sa rect(), QPainter::drawEllipse()
+*/
+void QGraphicsEllipseItem::setRect(const QRectF &rect)
+{
+ Q_D(QGraphicsEllipseItem);
+ if (d->rect == rect)
+ return;
+ prepareGeometryChange();
+ d->rect = rect;
+ d->boundingRect = QRectF();
+ update();
+}
+
+/*!
+ Returns the start angle for an ellipse segment in 16ths of a degree. This
+ angle is used together with spanAngle() for representing an ellipse
+ segment (a pie). By default, the start angle is 0.
+
+ \sa setStartAngle(), spanAngle()
+*/
+int QGraphicsEllipseItem::startAngle() const
+{
+ Q_D(const QGraphicsEllipseItem);
+ return d->startAngle;
+}
+
+/*!
+ Sets the start angle for an ellipse segment to \a angle, which is in 16ths
+ of a degree. This angle is used together with spanAngle() for representing
+ an ellipse segment (a pie). By default, the start angle is 0.
+
+ \sa startAngle(), setSpanAngle(), QPainter::drawPie()
+*/
+void QGraphicsEllipseItem::setStartAngle(int angle)
+{
+ Q_D(QGraphicsEllipseItem);
+ if (angle != d->startAngle) {
+ prepareGeometryChange();
+ d->boundingRect = QRectF();
+ d->startAngle = angle;
+ update();
+ }
+}
+
+/*!
+ Returns the span angle of an ellipse segment in 16ths of a degree. This
+ angle is used together with startAngle() for representing an ellipse
+ segment (a pie). By default, this function returns 5760 (360 * 16, a full
+ ellipse).
+
+ \sa setSpanAngle(), startAngle()
+*/
+int QGraphicsEllipseItem::spanAngle() const
+{
+ Q_D(const QGraphicsEllipseItem);
+ return d->spanAngle;
+}
+
+/*!
+ Sets the span angle for an ellipse segment to \a angle, which is in 16ths
+ of a degree. This angle is used together with startAngle() to represent an
+ ellipse segment (a pie). By default, the span angle is 5760 (360 * 16, a
+ full ellipse).
+
+ \sa spanAngle(), setStartAngle(), QPainter::drawPie()
+*/
+void QGraphicsEllipseItem::setSpanAngle(int angle)
+{
+ Q_D(QGraphicsEllipseItem);
+ if (angle != d->spanAngle) {
+ prepareGeometryChange();
+ d->boundingRect = QRectF();
+ d->spanAngle = angle;
+ update();
+ }
+}
+
+/*!
+ \reimp
+*/
+QRectF QGraphicsEllipseItem::boundingRect() const
+{
+ Q_D(const QGraphicsEllipseItem);
+ if (d->boundingRect.isNull()) {
+ qreal pw = pen().widthF();
+ if (pw == 0.0 && d->spanAngle == 360 * 16)
+ d->boundingRect = d->rect;
+ else
+ d->boundingRect = shape().controlPointRect();
+ }
+ return d->boundingRect;
+}
+
+/*!
+ \reimp
+*/
+QPainterPath QGraphicsEllipseItem::shape() const
+{
+ Q_D(const QGraphicsEllipseItem);
+ QPainterPath path;
+ if (d->rect.isNull())
+ return path;
+ if (d->spanAngle != 360 * 16) {
+ path.moveTo(d->rect.center());
+ path.arcTo(d->rect, d->startAngle / 16.0, d->spanAngle / 16.0);
+ } else {
+ path.addEllipse(d->rect);
+ }
+
+ return qt_graphicsItem_shapeFromPath(path, d->pen);
+}
+
+/*!
+ \reimp
+*/
+bool QGraphicsEllipseItem::contains(const QPointF &point) const
+{
+ return QAbstractGraphicsShapeItem::contains(point);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsEllipseItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+ QWidget *widget)
+{
+ Q_D(QGraphicsEllipseItem);
+ Q_UNUSED(widget);
+ painter->setPen(d->pen);
+ painter->setBrush(d->brush);
+ if ((d->spanAngle != 0) && (qAbs(d->spanAngle) % (360 * 16) == 0))
+ painter->drawEllipse(d->rect);
+ else
+ painter->drawPie(d->rect, d->startAngle, d->spanAngle);
+
+ if (option->state & QStyle::State_Selected)
+ qt_graphicsItem_highlightSelected(this, painter, option);
+}
+
+/*!
+ \reimp
+*/
+bool QGraphicsEllipseItem::isObscuredBy(const QGraphicsItem *item) const
+{
+ return QAbstractGraphicsShapeItem::isObscuredBy(item);
+}
+
+/*!
+ \reimp
+*/
+QPainterPath QGraphicsEllipseItem::opaqueArea() const
+{
+ return QAbstractGraphicsShapeItem::opaqueArea();
+}
+
+/*!
+ \reimp
+*/
+int QGraphicsEllipseItem::type() const
+{
+ return Type;
+}
+
+
+/*!
+ \internal
+*/
+bool QGraphicsEllipseItem::supportsExtension(Extension extension) const
+{
+ Q_UNUSED(extension);
+ return false;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsEllipseItem::setExtension(Extension extension, const QVariant &variant)
+{
+ Q_UNUSED(extension);
+ Q_UNUSED(variant);
+}
+
+/*!
+ \internal
+*/
+QVariant QGraphicsEllipseItem::extension(const QVariant &variant) const
+{
+ Q_UNUSED(variant);
+ return QVariant();
+}
+
+/*!
+ \class QGraphicsPolygonItem
+ \brief The QGraphicsPolygonItem class provides a polygon item that you
+ can add to a QGraphicsScene.
+ \since 4.2
+ \ingroup graphicsview-api
+
+ To set the item's polygon, pass a QPolygonF to
+ QGraphicsPolygonItem's constructor, or call the setPolygon()
+ function. The polygon() function returns the current polygon.
+
+ \image graphicsview-polygonitem.png
+
+ QGraphicsPolygonItem uses the polygon and the pen width to provide
+ a reasonable implementation of boundingRect(), shape(), and
+ contains(). The paint() function draws the polygon using the
+ item's associated pen and brush, which you can set by calling the
+ setPen() and setBrush() functions.
+
+ \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem,
+ QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics
+ View Framework}
+*/
+
+class QGraphicsPolygonItemPrivate : public QAbstractGraphicsShapeItemPrivate
+{
+ Q_DECLARE_PUBLIC(QGraphicsPolygonItem)
+public:
+ inline QGraphicsPolygonItemPrivate()
+ : fillRule(Qt::OddEvenFill)
+ { }
+
+ QPolygonF polygon;
+ Qt::FillRule fillRule;
+};
+
+/*!
+ Constructs a QGraphicsPolygonItem with \a polygon as the default
+ polygon. \a parent is passed to QAbstractGraphicsShapeItem's constructor.
+
+ \sa QGraphicsScene::addItem()
+*/
+QGraphicsPolygonItem::QGraphicsPolygonItem(const QPolygonF &polygon,
+ QGraphicsItem *parent
+#ifndef Q_QDOC
+ // obsolete argument
+ , QGraphicsScene *scene
+#endif
+ )
+ : QAbstractGraphicsShapeItem(*new QGraphicsPolygonItemPrivate, parent, scene)
+{
+ setPolygon(polygon);
+}
+
+/*!
+ Constructs a QGraphicsPolygonItem. \a parent is passed to
+ QAbstractGraphicsShapeItem's constructor.
+
+ \sa QGraphicsScene::addItem()
+*/
+QGraphicsPolygonItem::QGraphicsPolygonItem(QGraphicsItem *parent
+#ifndef Q_QDOC
+ // obsolete argument
+ , QGraphicsScene *scene
+#endif
+ )
+ : QAbstractGraphicsShapeItem(*new QGraphicsPolygonItemPrivate, parent, scene)
+{
+}
+
+/*!
+ Destroys the QGraphicsPolygonItem.
+*/
+QGraphicsPolygonItem::~QGraphicsPolygonItem()
+{
+}
+
+/*!
+ Returns the item's polygon, or an empty polygon if no polygon
+ has been set.
+
+ \sa setPolygon()
+*/
+QPolygonF QGraphicsPolygonItem::polygon() const
+{
+ Q_D(const QGraphicsPolygonItem);
+ return d->polygon;
+}
+
+/*!
+ Sets the item's polygon to be the given \a polygon.
+
+ \sa polygon()
+*/
+void QGraphicsPolygonItem::setPolygon(const QPolygonF &polygon)
+{
+ Q_D(QGraphicsPolygonItem);
+ if (d->polygon == polygon)
+ return;
+ prepareGeometryChange();
+ d->polygon = polygon;
+ d->boundingRect = QRectF();
+ update();
+}
+
+/*!
+ Returns the fill rule of the polygon. The default fill rule is
+ Qt::OddEvenFill.
+
+ \sa setFillRule(), QPainterPath::fillRule(), QPainter::drawPolygon()
+*/
+Qt::FillRule QGraphicsPolygonItem::fillRule() const
+{
+ Q_D(const QGraphicsPolygonItem);
+ return d->fillRule;
+}
+
+/*!
+ Sets the fill rule of the polygon to \a rule. The default fill rule is
+ Qt::OddEvenFill.
+
+ \sa fillRule(), QPainterPath::fillRule(), QPainter::drawPolygon()
+*/
+void QGraphicsPolygonItem::setFillRule(Qt::FillRule rule)
+{
+ Q_D(QGraphicsPolygonItem);
+ if (rule != d->fillRule) {
+ d->fillRule = rule;
+ update();
+ }
+}
+
+/*!
+ \reimp
+*/
+QRectF QGraphicsPolygonItem::boundingRect() const
+{
+ Q_D(const QGraphicsPolygonItem);
+ if (d->boundingRect.isNull()) {
+ qreal pw = pen().widthF();
+ if (pw == 0.0)
+ d->boundingRect = d->polygon.boundingRect();
+ else
+ d->boundingRect = shape().controlPointRect();
+ }
+ return d->boundingRect;
+}
+
+/*!
+ \reimp
+*/
+QPainterPath QGraphicsPolygonItem::shape() const
+{
+ Q_D(const QGraphicsPolygonItem);
+ QPainterPath path;
+ path.addPolygon(d->polygon);
+ return qt_graphicsItem_shapeFromPath(path, d->pen);
+}
+
+/*!
+ \reimp
+*/
+bool QGraphicsPolygonItem::contains(const QPointF &point) const
+{
+ return QAbstractGraphicsShapeItem::contains(point);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsPolygonItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ Q_D(QGraphicsPolygonItem);
+ Q_UNUSED(widget);
+ painter->setPen(d->pen);
+ painter->setBrush(d->brush);
+ painter->drawPolygon(d->polygon, d->fillRule);
+
+ if (option->state & QStyle::State_Selected)
+ qt_graphicsItem_highlightSelected(this, painter, option);
+}
+
+/*!
+ \reimp
+*/
+bool QGraphicsPolygonItem::isObscuredBy(const QGraphicsItem *item) const
+{
+ return QAbstractGraphicsShapeItem::isObscuredBy(item);
+}
+
+/*!
+ \reimp
+*/
+QPainterPath QGraphicsPolygonItem::opaqueArea() const
+{
+ return QAbstractGraphicsShapeItem::opaqueArea();
+}
+
+/*!
+ \reimp
+*/
+int QGraphicsPolygonItem::type() const
+{
+ return Type;
+}
+
+/*!
+ \internal
+*/
+bool QGraphicsPolygonItem::supportsExtension(Extension extension) const
+{
+ Q_UNUSED(extension);
+ return false;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsPolygonItem::setExtension(Extension extension, const QVariant &variant)
+{
+ Q_UNUSED(extension);
+ Q_UNUSED(variant);
+}
+
+/*!
+ \internal
+*/
+QVariant QGraphicsPolygonItem::extension(const QVariant &variant) const
+{
+ Q_UNUSED(variant);
+ return QVariant();
+}
+
+/*!
+ \class QGraphicsLineItem
+ \brief The QGraphicsLineItem class provides a line item that you can add to a
+ QGraphicsScene.
+ \since 4.2
+ \ingroup graphicsview-api
+
+ To set the item's line, pass a QLineF to QGraphicsLineItem's
+ constructor, or call the setLine() function. The line() function
+ returns the current line. By default the line is black with a
+ width of 0, but you can change this by calling setPen().
+
+ \img graphicsview-lineitem.png
+
+ QGraphicsLineItem uses the line and the pen width to provide a reasonable
+ implementation of boundingRect(), shape(), and contains(). The paint()
+ function draws the line using the item's associated pen.
+
+ \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem,
+ QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsPixmapItem,
+ {Graphics View Framework}
+*/
+
+class QGraphicsLineItemPrivate : public QGraphicsItemPrivate
+{
+ Q_DECLARE_PUBLIC(QGraphicsLineItem)
+public:
+ QLineF line;
+ QPen pen;
+};
+
+/*!
+ Constructs a QGraphicsLineItem, using \a line as the default line. \a
+ parent is passed to QGraphicsItem's constructor.
+
+ \sa QGraphicsScene::addItem()
+*/
+QGraphicsLineItem::QGraphicsLineItem(const QLineF &line, QGraphicsItem *parent
+#ifndef Q_QDOC
+ // obsolete argument
+ , QGraphicsScene *scene
+#endif
+ )
+ : QGraphicsItem(*new QGraphicsLineItemPrivate, parent, scene)
+{
+ setLine(line);
+}
+
+/*!
+ Constructs a QGraphicsLineItem, using the line between (\a x1, \a y1) and
+ (\a x2, \a y2) as the default line. \a parent is passed to
+ QGraphicsItem's constructor.
+
+ \sa QGraphicsScene::addItem()
+*/
+QGraphicsLineItem::QGraphicsLineItem(qreal x1, qreal y1, qreal x2, qreal y2, QGraphicsItem *parent
+#ifndef Q_QDOC
+ // obsolete argument
+ , QGraphicsScene *scene
+#endif
+ )
+ : QGraphicsItem(*new QGraphicsLineItemPrivate, parent, scene)
+{
+ setLine(x1, y1, x2, y2);
+}
+
+
+
+/*!
+ Constructs a QGraphicsLineItem. \a parent is passed to QGraphicsItem's
+ constructor.
+
+ \sa QGraphicsScene::addItem()
+*/
+QGraphicsLineItem::QGraphicsLineItem(QGraphicsItem *parent
+#ifndef Q_QDOC
+ // obsolete argument
+ , QGraphicsScene *scene
+#endif
+ )
+ : QGraphicsItem(*new QGraphicsLineItemPrivate, parent, scene)
+{
+}
+
+/*!
+ Destroys the QGraphicsLineItem.
+*/
+QGraphicsLineItem::~QGraphicsLineItem()
+{
+}
+
+/*!
+ Returns the item's pen, or a black solid 0-width pen if no pen has
+ been set.
+
+ \sa setPen()
+*/
+QPen QGraphicsLineItem::pen() const
+{
+ Q_D(const QGraphicsLineItem);
+ return d->pen;
+}
+
+/*!
+ Sets the item's pen to \a pen. If no pen is set, the line will be painted
+ using a black solid 0-width pen.
+
+ \sa pen()
+*/
+void QGraphicsLineItem::setPen(const QPen &pen)
+{
+ Q_D(QGraphicsLineItem);
+ if (d->pen == pen)
+ return;
+ prepareGeometryChange();
+ d->pen = pen;
+ update();
+}
+
+/*!
+ Returns the item's line, or a null line if no line has been set.
+
+ \sa setLine()
+*/
+QLineF QGraphicsLineItem::line() const
+{
+ Q_D(const QGraphicsLineItem);
+ return d->line;
+}
+
+/*!
+ Sets the item's line to be the given \a line.
+
+ \sa line()
+*/
+void QGraphicsLineItem::setLine(const QLineF &line)
+{
+ Q_D(QGraphicsLineItem);
+ if (d->line == line)
+ return;
+ prepareGeometryChange();
+ d->line = line;
+ update();
+}
+
+/*!
+ \fn void QGraphicsLineItem::setLine(qreal x1, qreal y1, qreal x2, qreal y2)
+ \overload
+
+ Sets the item's line to be the line between (\a x1, \a y1) and (\a
+ x2, \a y2).
+
+ This is the same as calling \c {setLine(QLineF(x1, y1, x2, y2))}.
+*/
+
+/*!
+ \reimp
+*/
+QRectF QGraphicsLineItem::boundingRect() const
+{
+ Q_D(const QGraphicsLineItem);
+ if (d->pen.widthF() == 0.0) {
+ const qreal x1 = d->line.p1().x();
+ const qreal x2 = d->line.p2().x();
+ const qreal y1 = d->line.p1().y();
+ const qreal y2 = d->line.p2().y();
+ qreal lx = qMin(x1, x2);
+ qreal rx = qMax(x1, x2);
+ qreal ty = qMin(y1, y2);
+ qreal by = qMax(y1, y2);
+ return QRectF(lx, ty, rx - lx, by - ty);
+ }
+ return shape().controlPointRect();
+}
+
+/*!
+ \reimp
+*/
+QPainterPath QGraphicsLineItem::shape() const
+{
+ Q_D(const QGraphicsLineItem);
+ QPainterPath path;
+ if (d->line == QLineF())
+ return path;
+
+ path.moveTo(d->line.p1());
+ path.lineTo(d->line.p2());
+ return qt_graphicsItem_shapeFromPath(path, d->pen);
+}
+
+/*!
+ \reimp
+*/
+bool QGraphicsLineItem::contains(const QPointF &point) const
+{
+ return QGraphicsItem::contains(point);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsLineItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ Q_D(QGraphicsLineItem);
+ Q_UNUSED(widget);
+ painter->setPen(d->pen);
+ painter->drawLine(d->line);
+
+ if (option->state & QStyle::State_Selected)
+ qt_graphicsItem_highlightSelected(this, painter, option);
+}
+
+/*!
+ \reimp
+*/
+bool QGraphicsLineItem::isObscuredBy(const QGraphicsItem *item) const
+{
+ return QGraphicsItem::isObscuredBy(item);
+}
+
+/*!
+ \reimp
+*/
+QPainterPath QGraphicsLineItem::opaqueArea() const
+{
+ return QGraphicsItem::opaqueArea();
+}
+
+/*!
+ \reimp
+*/
+int QGraphicsLineItem::type() const
+{
+ return Type;
+}
+
+/*!
+ \internal
+*/
+bool QGraphicsLineItem::supportsExtension(Extension extension) const
+{
+ Q_UNUSED(extension);
+ return false;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsLineItem::setExtension(Extension extension, const QVariant &variant)
+{
+ Q_UNUSED(extension);
+ Q_UNUSED(variant);
+}
+
+/*!
+ \internal
+*/
+QVariant QGraphicsLineItem::extension(const QVariant &variant) const
+{
+ Q_UNUSED(variant);
+ return QVariant();
+}
+
+/*!
+ \class QGraphicsPixmapItem
+ \brief The QGraphicsPixmapItem class provides a pixmap item that you can add to
+ a QGraphicsScene.
+ \since 4.2
+ \ingroup graphicsview-api
+
+ To set the item's pixmap, pass a QPixmap to QGraphicsPixmapItem's
+ constructor, or call the setPixmap() function. The pixmap()
+ function returns the current pixmap.
+
+ QGraphicsPixmapItem uses pixmap's optional alpha mask to provide a
+ reasonable implementation of boundingRect(), shape(), and contains().
+
+ \image graphicsview-pixmapitem.png
+
+ The pixmap is drawn at the item's (0, 0) coordinate, as returned by
+ offset(). You can change the drawing offset by calling setOffset().
+
+ You can set the pixmap's transformation mode by calling
+ setTransformationMode(). By default, Qt::FastTransformation is used, which
+ provides fast, non-smooth scaling. Qt::SmoothTransformation enables
+ QPainter::SmoothPixmapTransform on the painter, and the quality depends on
+ the platform and viewport. The result is usually not as good as calling
+ QPixmap::scale() directly. Call transformationMode() to get the current
+ transformation mode for the item.
+
+ \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem,
+ QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsLineItem,
+ {Graphics View Framework}
+*/
+
+/*!
+ \enum QGraphicsPixmapItem::ShapeMode
+
+ This enum describes how QGraphicsPixmapItem calculates its shape and
+ opaque area.
+
+ The default value is MaskShape.
+
+ \value MaskShape The shape is determined by calling QPixmap::mask().
+ This shape includes only the opaque pixels of the pixmap.
+ Because the shape is more complex, however, it can be slower than the other modes,
+ and uses more memory.
+
+ \value BoundingRectShape The shape is determined by tracing the outline of
+ the pixmap. This is the fastest shape mode, but it does not take into account
+ any transparent areas on the pixmap.
+
+ \value HeuristicMaskShape The shape is determine by calling
+ QPixmap::createHeuristicMask(). The performance and memory consumption
+ is similar to MaskShape.
+*/
+extern QPainterPath qt_regionToPath(const QRegion &region);
+
+class QGraphicsPixmapItemPrivate : public QGraphicsItemPrivate
+{
+ Q_DECLARE_PUBLIC(QGraphicsPixmapItem)
+public:
+ QGraphicsPixmapItemPrivate()
+ : transformationMode(Qt::FastTransformation),
+ shapeMode(QGraphicsPixmapItem::MaskShape),
+ hasShape(false)
+ {}
+
+ QPixmap pixmap;
+ Qt::TransformationMode transformationMode;
+ QPointF offset;
+ QGraphicsPixmapItem::ShapeMode shapeMode;
+ QPainterPath shape;
+ bool hasShape;
+
+ void updateShape()
+ {
+ shape = QPainterPath();
+ switch (shapeMode) {
+ case QGraphicsPixmapItem::MaskShape: {
+ QBitmap mask = pixmap.mask();
+ if (!mask.isNull()) {
+ shape = qt_regionToPath(QRegion(mask).translated(offset.toPoint()));
+ break;
+ }
+ // FALL THROUGH
+ }
+ case QGraphicsPixmapItem::BoundingRectShape:
+ shape.addRect(QRectF(offset.x(), offset.y(), pixmap.width(), pixmap.height()));
+ break;
+ case QGraphicsPixmapItem::HeuristicMaskShape:
+#ifndef QT_NO_IMAGE_HEURISTIC_MASK
+ shape = qt_regionToPath(QRegion(pixmap.createHeuristicMask()).translated(offset.toPoint()));
+#else
+ shape.addRect(QRectF(offset.x(), offset.y(), pixmap.width(), pixmap.height()));
+#endif
+ break;
+ }
+ }
+};
+
+/*!
+ Constructs a QGraphicsPixmapItem, using \a pixmap as the default pixmap.
+ \a parent is passed to QGraphicsItem's constructor.
+
+ \sa QGraphicsScene::addItem()
+*/
+QGraphicsPixmapItem::QGraphicsPixmapItem(const QPixmap &pixmap,
+ QGraphicsItem *parent
+#ifndef Q_QDOC
+ // obsolete argument
+ , QGraphicsScene *scene
+#endif
+ )
+ : QGraphicsItem(*new QGraphicsPixmapItemPrivate, parent, scene)
+{
+ setPixmap(pixmap);
+}
+
+/*!
+ Constructs a QGraphicsPixmapItem. \a parent is passed to QGraphicsItem's
+ constructor.
+
+ \sa QGraphicsScene::addItem()
+*/
+QGraphicsPixmapItem::QGraphicsPixmapItem(QGraphicsItem *parent
+#ifndef Q_QDOC
+ // obsolete argument
+ , QGraphicsScene *scene
+#endif
+ )
+ : QGraphicsItem(*new QGraphicsPixmapItemPrivate, parent, scene)
+{
+}
+
+/*!
+ Destroys the QGraphicsPixmapItem.
+*/
+QGraphicsPixmapItem::~QGraphicsPixmapItem()
+{
+}
+
+/*!
+ Sets the item's pixmap to \a pixmap.
+
+ \sa pixmap()
+*/
+void QGraphicsPixmapItem::setPixmap(const QPixmap &pixmap)
+{
+ Q_D(QGraphicsPixmapItem);
+ prepareGeometryChange();
+ d->pixmap = pixmap;
+ d->hasShape = false;
+ update();
+}
+
+/*!
+ Returns the item's pixmap, or an invalid QPixmap if no pixmap has been
+ set.
+
+ \sa setPixmap()
+*/
+QPixmap QGraphicsPixmapItem::pixmap() const
+{
+ Q_D(const QGraphicsPixmapItem);
+ return d->pixmap;
+}
+
+/*!
+ Returns the transformation mode of the pixmap. The default mode is
+ Qt::FastTransformation, which provides quick transformation with no
+ smoothing.
+
+ \sa setTransformationMode()
+*/
+Qt::TransformationMode QGraphicsPixmapItem::transformationMode() const
+{
+ Q_D(const QGraphicsPixmapItem);
+ return d->transformationMode;
+}
+
+/*!
+ Sets the pixmap item's transformation mode to \a mode, and toggles an
+ update of the item. The default mode is Qt::FastTransformation, which
+ provides quick transformation with no smoothing.
+
+ Qt::SmoothTransformation enables QPainter::SmoothPixmapTransform on the
+ painter, and the quality depends on the platform and viewport. The result
+ is usually not as good as calling QPixmap::scale() directly.
+
+ \sa transformationMode()
+*/
+void QGraphicsPixmapItem::setTransformationMode(Qt::TransformationMode mode)
+{
+ Q_D(QGraphicsPixmapItem);
+ if (mode != d->transformationMode) {
+ d->transformationMode = mode;
+ update();
+ }
+}
+
+/*!
+ Returns the pixmap item's \e offset, which defines the point of the
+ top-left corner of the pixmap, in local coordinates.
+
+ \sa setOffset()
+*/
+QPointF QGraphicsPixmapItem::offset() const
+{
+ Q_D(const QGraphicsPixmapItem);
+ return d->offset;
+}
+
+/*!
+ Sets the pixmap item's offset to \a offset. QGraphicsPixmapItem will draw
+ its pixmap using \a offset for its top-left corner.
+
+ \sa offset()
+*/
+void QGraphicsPixmapItem::setOffset(const QPointF &offset)
+{
+ Q_D(QGraphicsPixmapItem);
+ if (d->offset == offset)
+ return;
+ prepareGeometryChange();
+ d->offset = offset;
+ d->hasShape = false;
+ update();
+}
+
+/*!
+ \fn void QGraphicsPixmapItem::setOffset(qreal x, qreal y)
+ \since 4.3
+
+ This convenience function is equivalent to calling setOffset(QPointF(\a x, \a y)).
+*/
+
+/*!
+ \reimp
+*/
+QRectF QGraphicsPixmapItem::boundingRect() const
+{
+ Q_D(const QGraphicsPixmapItem);
+ if (d->pixmap.isNull())
+ return QRectF();
+ if (d->flags & ItemIsSelectable) {
+ qreal pw = 1.0;
+ return QRectF(d->offset, d->pixmap.size()).adjusted(-pw/2, -pw/2, pw/2, pw/2);
+ } else {
+ return QRectF(d->offset, d->pixmap.size());
+ }
+}
+
+/*!
+ \reimp
+*/
+QPainterPath QGraphicsPixmapItem::shape() const
+{
+ Q_D(const QGraphicsPixmapItem);
+ if (!d->hasShape) {
+ QGraphicsPixmapItemPrivate *thatD = const_cast<QGraphicsPixmapItemPrivate *>(d);
+ thatD->updateShape();
+ thatD->hasShape = true;
+ }
+ return d_func()->shape;
+}
+
+/*!
+ \reimp
+*/
+bool QGraphicsPixmapItem::contains(const QPointF &point) const
+{
+ return QGraphicsItem::contains(point);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsPixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+ QWidget *widget)
+{
+ Q_D(QGraphicsPixmapItem);
+ Q_UNUSED(widget);
+
+ painter->setRenderHint(QPainter::SmoothPixmapTransform,
+ (d->transformationMode == Qt::SmoothTransformation));
+
+ painter->drawPixmap(d->offset, d->pixmap);
+
+ if (option->state & QStyle::State_Selected)
+ qt_graphicsItem_highlightSelected(this, painter, option);
+}
+
+/*!
+ \reimp
+*/
+bool QGraphicsPixmapItem::isObscuredBy(const QGraphicsItem *item) const
+{
+ return QGraphicsItem::isObscuredBy(item);
+}
+
+/*!
+ \reimp
+*/
+QPainterPath QGraphicsPixmapItem::opaqueArea() const
+{
+ return shape();
+}
+
+/*!
+ \reimp
+*/
+int QGraphicsPixmapItem::type() const
+{
+ return Type;
+}
+
+/*!
+ Returns the item's shape mode. The shape mode describes how
+ QGraphicsPixmapItem calculates its shape. The default mode is MaskShape.
+
+ \sa setShapeMode(), ShapeMode
+*/
+QGraphicsPixmapItem::ShapeMode QGraphicsPixmapItem::shapeMode() const
+{
+ return d_func()->shapeMode;
+}
+
+/*!
+ Sets the item's shape mode to \a mode. The shape mode describes how
+ QGraphicsPixmapItem calculates its shape. The default mode is MaskShape.
+
+ \sa shapeMode(), ShapeMode
+*/
+void QGraphicsPixmapItem::setShapeMode(ShapeMode mode)
+{
+ Q_D(QGraphicsPixmapItem);
+ if (d->shapeMode == mode)
+ return;
+ d->shapeMode = mode;
+ d->hasShape = false;
+}
+
+/*!
+ \internal
+*/
+bool QGraphicsPixmapItem::supportsExtension(Extension extension) const
+{
+ Q_UNUSED(extension);
+ return false;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsPixmapItem::setExtension(Extension extension, const QVariant &variant)
+{
+ Q_UNUSED(extension);
+ Q_UNUSED(variant);
+}
+
+/*!
+ \internal
+*/
+QVariant QGraphicsPixmapItem::extension(const QVariant &variant) const
+{
+ Q_UNUSED(variant);
+ return QVariant();
+}
+
+/*!
+ \class QGraphicsTextItem
+ \brief The QGraphicsTextItem class provides a text item that you can add to
+ a QGraphicsScene to display formatted text.
+ \since 4.2
+ \ingroup graphicsview-api
+
+ If you only need to show plain text in an item, consider using QGraphicsSimpleTextItem
+ instead.
+
+ To set the item's text, pass a QString to QGraphicsTextItem's
+ constructor, or call setHtml()/setPlainText().
+
+ QGraphicsTextItem uses the text's formatted size and the associated font
+ to provide a reasonable implementation of boundingRect(), shape(),
+ and contains(). You can set the font by calling setFont().
+
+ It is possible to make the item editable by setting the Qt::TextEditorInteraction flag
+ using setTextInteractionFlags().
+
+ The item's preferred text width can be set using setTextWidth() and obtained
+ using textWidth().
+
+ \note In order to align HTML text in the center, the item's text width must be set.
+
+ \img graphicsview-textitem.png
+
+ \note QGraphicsTextItem accepts \l{QGraphicsItem::acceptHoverEvents()}{hover events}
+ by default. You can change this with \l{QGraphicsItem::}{setAcceptHoverEvents()}.
+
+ \sa QGraphicsSimpleTextItem, QGraphicsPathItem, QGraphicsRectItem,
+ QGraphicsEllipseItem, QGraphicsPixmapItem, QGraphicsPolygonItem,
+ QGraphicsLineItem, {Graphics View Framework}
+*/
+
+class QGraphicsTextItemPrivate
+{
+public:
+ QGraphicsTextItemPrivate()
+ : control(0), pageNumber(0), useDefaultImpl(false), tabChangesFocus(false), clickCausedFocus(0)
+ { }
+
+ mutable QTextControl *control;
+ QTextControl *textControl() const;
+
+ inline QPointF controlOffset() const
+ { return QPointF(0., pageNumber * control->document()->pageSize().height()); }
+ inline void sendControlEvent(QEvent *e)
+ { if (control) control->processEvent(e, controlOffset()); }
+
+ void _q_updateBoundingRect(const QSizeF &);
+ void _q_update(QRectF);
+ void _q_ensureVisible(QRectF);
+ bool _q_mouseOnEdge(QGraphicsSceneMouseEvent *);
+
+ QRectF boundingRect;
+ int pageNumber;
+ bool useDefaultImpl;
+ bool tabChangesFocus;
+
+ uint clickCausedFocus : 1;
+
+ QGraphicsTextItem *qq;
+};
+
+
+/*!
+ Constructs a QGraphicsTextItem, using \a text as the default plain
+ text. \a parent is passed to QGraphicsItem's constructor.
+
+ \sa QGraphicsScene::addItem()
+*/
+QGraphicsTextItem::QGraphicsTextItem(const QString &text, QGraphicsItem *parent
+#ifndef Q_QDOC
+ // obsolete argument
+ , QGraphicsScene *scene
+#endif
+ )
+ : QGraphicsObject(*new QGraphicsItemPrivate, parent, scene), dd(new QGraphicsTextItemPrivate)
+{
+ dd->qq = this;
+ if (!text.isEmpty())
+ setPlainText(text);
+ setAcceptDrops(true);
+ setAcceptHoverEvents(true);
+ setFlags(ItemUsesExtendedStyleOption);
+}
+
+/*!
+ Constructs a QGraphicsTextItem. \a parent is passed to QGraphicsItem's
+ constructor.
+
+ \sa QGraphicsScene::addItem()
+*/
+QGraphicsTextItem::QGraphicsTextItem(QGraphicsItem *parent
+#ifndef Q_QDOC
+ // obsolete argument
+ , QGraphicsScene *scene
+#endif
+ )
+ : QGraphicsObject(*new QGraphicsItemPrivate, parent, scene), dd(new QGraphicsTextItemPrivate)
+{
+ dd->qq = this;
+ setAcceptDrops(true);
+ setAcceptHoverEvents(true);
+ setFlag(ItemUsesExtendedStyleOption);
+}
+
+/*!
+ Destroys the QGraphicsTextItem.
+*/
+QGraphicsTextItem::~QGraphicsTextItem()
+{
+ delete dd;
+}
+
+/*!
+ Returns the item's text converted to HTML, or an empty QString if no text has been set.
+
+ \sa setHtml()
+*/
+QString QGraphicsTextItem::toHtml() const
+{
+#ifndef QT_NO_TEXTHTMLPARSER
+ if (dd->control)
+ return dd->control->toHtml();
+#endif
+ return QString();
+}
+
+/*!
+ Sets the item's text to \a text, assuming that text is HTML formatted. If
+ the item has keyboard input focus, this function will also call
+ ensureVisible() to ensure that the text is visible in all viewports.
+
+ \sa toHtml(), hasFocus(), QGraphicsSimpleTextItem
+*/
+void QGraphicsTextItem::setHtml(const QString &text)
+{
+ dd->textControl()->setHtml(text);
+}
+
+/*!
+ Returns the item's text converted to plain text, or an empty QString if no text has been set.
+
+ \sa setPlainText()
+*/
+QString QGraphicsTextItem::toPlainText() const
+{
+ if (dd->control)
+ return dd->control->toPlainText();
+ return QString();
+}
+
+/*!
+ Sets the item's text to \a text. If the item has keyboard input focus,
+ this function will also call ensureVisible() to ensure that the text is
+ visible in all viewports.
+
+ \sa toHtml(), hasFocus()
+*/
+void QGraphicsTextItem::setPlainText(const QString &text)
+{
+ dd->textControl()->setPlainText(text);
+}
+
+/*!
+ Returns the item's font, which is used to render the text.
+
+ \sa setFont()
+*/
+QFont QGraphicsTextItem::font() const
+{
+ if (!dd->control)
+ return QFont();
+ return dd->control->document()->defaultFont();
+}
+
+/*!
+ Sets the font used to render the text item to \a font.
+
+ \sa font()
+*/
+void QGraphicsTextItem::setFont(const QFont &font)
+{
+ dd->textControl()->document()->setDefaultFont(font);
+}
+
+/*!
+ Sets the color for unformatted text to \a col.
+*/
+void QGraphicsTextItem::setDefaultTextColor(const QColor &col)
+{
+ QTextControl *c = dd->textControl();
+ QPalette pal = c->palette();
+ QColor old = pal.color(QPalette::Text);
+ pal.setColor(QPalette::Text, col);
+ c->setPalette(pal);
+ if (old != col)
+ update();
+}
+
+/*!
+ Returns the default text color that is used to for unformatted text.
+*/
+QColor QGraphicsTextItem::defaultTextColor() const
+{
+ return dd->textControl()->palette().color(QPalette::Text);
+}
+
+/*!
+ \reimp
+*/
+QRectF QGraphicsTextItem::boundingRect() const
+{
+ return dd->boundingRect;
+}
+
+/*!
+ \reimp
+*/
+QPainterPath QGraphicsTextItem::shape() const
+{
+ if (!dd->control)
+ return QPainterPath();
+ QPainterPath path;
+ path.addRect(dd->boundingRect);
+ return path;
+}
+
+/*!
+ \reimp
+*/
+bool QGraphicsTextItem::contains(const QPointF &point) const
+{
+ return dd->boundingRect.contains(point);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+ QWidget *widget)
+{
+ Q_UNUSED(widget);
+ if (dd->control) {
+ painter->save();
+ QRectF r = option->exposedRect;
+ painter->translate(-dd->controlOffset());
+ r.translate(dd->controlOffset());
+
+ QTextDocument *doc = dd->control->document();
+ QTextDocumentLayout *layout = qobject_cast<QTextDocumentLayout *>(doc->documentLayout());
+
+ // the layout might need to expand the root frame to
+ // the viewport if NoWrap is set
+ if (layout)
+ layout->setViewport(dd->boundingRect);
+
+ dd->control->drawContents(painter, r);
+
+ if (layout)
+ layout->setViewport(QRect());
+
+ painter->restore();
+ }
+
+ if (option->state & (QStyle::State_Selected | QStyle::State_HasFocus))
+ qt_graphicsItem_highlightSelected(this, painter, option);
+}
+
+/*!
+ \reimp
+*/
+bool QGraphicsTextItem::isObscuredBy(const QGraphicsItem *item) const
+{
+ return QGraphicsItem::isObscuredBy(item);
+}
+
+/*!
+ \reimp
+*/
+QPainterPath QGraphicsTextItem::opaqueArea() const
+{
+ return QGraphicsItem::opaqueArea();
+}
+
+/*!
+ \reimp
+*/
+int QGraphicsTextItem::type() const
+{
+ return Type;
+}
+
+/*!
+ Sets the preferred width for the item's text. If the actual text
+ is wider than the specified width then it will be broken into
+ multiple lines.
+
+ If \a width is set to -1 then the text will not be broken into
+ multiple lines unless it is enforced through an explicit line
+ break or a new paragraph.
+
+ The default value is -1.
+
+ Note that QGraphicsTextItem keeps a QTextDocument internally,
+ which is used to calculate the text width.
+
+ \sa textWidth(), QTextDocument::setTextWidth()
+*/
+void QGraphicsTextItem::setTextWidth(qreal width)
+{
+ dd->textControl()->setTextWidth(width);
+}
+
+/*!
+ Returns the text width.
+
+ The width is calculated with the QTextDocument that
+ QGraphicsTextItem keeps internally.
+
+ \sa setTextWidth(), QTextDocument::textWidth()
+*/
+qreal QGraphicsTextItem::textWidth() const
+{
+ if (!dd->control)
+ return -1;
+ return dd->control->textWidth();
+}
+
+/*!
+ Adjusts the text item to a reasonable size.
+*/
+void QGraphicsTextItem::adjustSize()
+{
+ if (dd->control)
+ dd->control->adjustSize();
+}
+
+/*!
+ Sets the text document \a document on the item.
+*/
+void QGraphicsTextItem::setDocument(QTextDocument *document)
+{
+ dd->textControl()->setDocument(document);
+ dd->_q_updateBoundingRect(dd->control->size());
+}
+
+/*!
+ Returns the item's text document.
+*/
+QTextDocument *QGraphicsTextItem::document() const
+{
+ return dd->textControl()->document();
+}
+
+/*!
+ \reimp
+*/
+bool QGraphicsTextItem::sceneEvent(QEvent *event)
+{
+ QEvent::Type t = event->type();
+ if (!dd->tabChangesFocus && (t == QEvent::KeyPress || t == QEvent::KeyRelease)) {
+ int k = ((QKeyEvent *)event)->key();
+ if (k == Qt::Key_Tab || k == Qt::Key_Backtab) {
+ dd->sendControlEvent(event);
+ return true;
+ }
+ }
+ bool result = QGraphicsItem::sceneEvent(event);
+
+ // Ensure input context is updated.
+ switch (event->type()) {
+ case QEvent::ContextMenu:
+ case QEvent::FocusIn:
+ case QEvent::FocusOut:
+ case QEvent::GraphicsSceneDragEnter:
+ case QEvent::GraphicsSceneDragLeave:
+ case QEvent::GraphicsSceneDragMove:
+ case QEvent::GraphicsSceneDrop:
+ case QEvent::GraphicsSceneHoverEnter:
+ case QEvent::GraphicsSceneHoverLeave:
+ case QEvent::GraphicsSceneHoverMove:
+ case QEvent::GraphicsSceneMouseDoubleClick:
+ case QEvent::GraphicsSceneMousePress:
+ case QEvent::GraphicsSceneMouseMove:
+ case QEvent::GraphicsSceneMouseRelease:
+ case QEvent::KeyPress:
+ case QEvent::KeyRelease:
+ // Reset the focus widget's input context, regardless
+ // of how this item gained or lost focus.
+ if (QWidget *fw = qApp->focusWidget()) {
+#ifndef QT_NO_IM
+ if (QInputContext *qic = fw->inputContext()) {
+ if (event->type() == QEvent::FocusIn || event->type() == QEvent::FocusOut)
+ qic->reset();
+ else
+ qic->update();
+ }
+#endif //QT_NO_IM
+ }
+ break;
+ case QEvent::ShortcutOverride:
+ dd->sendControlEvent(event);
+ return true;
+ default:
+ break;
+ }
+
+ return result;
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ if ((QGraphicsItem::d_ptr->flags & (ItemIsSelectable | ItemIsMovable))
+ && (event->buttons() & Qt::LeftButton) && dd->_q_mouseOnEdge(event)) {
+ // User left-pressed on edge of selectable/movable item, use
+ // base impl.
+ dd->useDefaultImpl = true;
+ } else if (event->buttons() == event->button()
+ && dd->control->textInteractionFlags() == Qt::NoTextInteraction) {
+ // User pressed first button on non-interactive item.
+ dd->useDefaultImpl = true;
+ }
+ if (dd->useDefaultImpl) {
+ QGraphicsItem::mousePressEvent(event);
+ if (!event->isAccepted())
+ dd->useDefaultImpl = false;
+ return;
+ }
+
+ dd->sendControlEvent(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
+{
+ if (dd->useDefaultImpl) {
+ QGraphicsItem::mouseMoveEvent(event);
+ return;
+ }
+
+ dd->sendControlEvent(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+ if (dd->useDefaultImpl) {
+ QGraphicsItem::mouseReleaseEvent(event);
+ if (dd->control->textInteractionFlags() == Qt::NoTextInteraction
+ && !event->buttons()) {
+ // User released last button on non-interactive item.
+ dd->useDefaultImpl = false;
+ } else if ((event->buttons() & Qt::LeftButton) == 0) {
+ // User released the left button on an interactive item.
+ dd->useDefaultImpl = false;
+ }
+ return;
+ }
+
+ QWidget *widget = event->widget();
+ if (widget && (dd->control->textInteractionFlags() & Qt::TextEditable) && boundingRect().contains(event->pos())) {
+ qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), dd->clickCausedFocus);
+ }
+ dd->clickCausedFocus = 0;
+ dd->sendControlEvent(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
+{
+ if (dd->useDefaultImpl) {
+ QGraphicsItem::mouseDoubleClickEvent(event);
+ return;
+ }
+
+ if (!hasFocus()) {
+ QGraphicsItem::mouseDoubleClickEvent(event);
+ return;
+ }
+
+ dd->sendControlEvent(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsTextItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
+{
+ dd->sendControlEvent(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsTextItem::keyPressEvent(QKeyEvent *event)
+{
+ dd->sendControlEvent(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsTextItem::keyReleaseEvent(QKeyEvent *event)
+{
+ dd->sendControlEvent(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsTextItem::focusInEvent(QFocusEvent *event)
+{
+ dd->sendControlEvent(event);
+ if (event->reason() == Qt::MouseFocusReason) {
+ dd->clickCausedFocus = 1;
+ }
+ update();
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsTextItem::focusOutEvent(QFocusEvent *event)
+{
+ dd->sendControlEvent(event);
+ update();
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsTextItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
+{
+ dd->sendControlEvent(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsTextItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
+{
+ dd->sendControlEvent(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsTextItem::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
+{
+ dd->sendControlEvent(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsTextItem::dropEvent(QGraphicsSceneDragDropEvent *event)
+{
+ dd->sendControlEvent(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsTextItem::inputMethodEvent(QInputMethodEvent *event)
+{
+ dd->sendControlEvent(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
+{
+ dd->sendControlEvent(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
+{
+ dd->sendControlEvent(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
+{
+ dd->sendControlEvent(event);
+}
+
+/*!
+ \reimp
+*/
+QVariant QGraphicsTextItem::inputMethodQuery(Qt::InputMethodQuery query) const
+{
+ QVariant v;
+ if (dd->control)
+ v = dd->control->inputMethodQuery(query);
+ if (v.type() == QVariant::RectF)
+ v = v.toRectF().translated(-dd->controlOffset());
+ else if (v.type() == QVariant::PointF)
+ v = v.toPointF() - dd->controlOffset();
+ else if (v.type() == QVariant::Rect)
+ v = v.toRect().translated(-dd->controlOffset().toPoint());
+ else if (v.type() == QVariant::Point)
+ v = v.toPoint() - dd->controlOffset().toPoint();
+ return v;
+}
+
+/*!
+ \internal
+*/
+bool QGraphicsTextItem::supportsExtension(Extension extension) const
+{
+ Q_UNUSED(extension);
+ return false;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsTextItem::setExtension(Extension extension, const QVariant &variant)
+{
+ Q_UNUSED(extension);
+ Q_UNUSED(variant);
+}
+
+/*!
+ \internal
+*/
+QVariant QGraphicsTextItem::extension(const QVariant &variant) const
+{
+ Q_UNUSED(variant);
+ return QVariant();
+}
+
+/*!
+ \internal
+*/
+void QGraphicsTextItemPrivate::_q_update(QRectF rect)
+{
+ if (rect.isValid()) {
+ rect.translate(-controlOffset());
+ } else {
+ rect = boundingRect;
+ }
+ if (rect.intersects(boundingRect))
+ qq->update(rect);
+}
+
+/*!
+ \internal
+*/
+void QGraphicsTextItemPrivate::_q_updateBoundingRect(const QSizeF &size)
+{
+ if (!control) return; // can't happen
+ const QSizeF pageSize = control->document()->pageSize();
+ // paged items have a constant (page) size
+ if (size == boundingRect.size() || pageSize.height() != -1)
+ return;
+ qq->prepareGeometryChange();
+ boundingRect.setSize(size);
+ qq->update();
+}
+
+/*!
+ \internal
+*/
+void QGraphicsTextItemPrivate::_q_ensureVisible(QRectF rect)
+{
+ if (qq->hasFocus()) {
+ rect.translate(-controlOffset());
+ qq->ensureVisible(rect, /*xmargin=*/0, /*ymargin=*/0);
+ }
+}
+
+QTextControl *QGraphicsTextItemPrivate::textControl() const
+{
+ if (!control) {
+ QGraphicsTextItem *that = const_cast<QGraphicsTextItem *>(qq);
+ control = new QTextControl(that);
+ control->setTextInteractionFlags(Qt::NoTextInteraction);
+
+ QObject::connect(control, SIGNAL(updateRequest(QRectF)),
+ qq, SLOT(_q_update(QRectF)));
+ QObject::connect(control, SIGNAL(documentSizeChanged(QSizeF)),
+ qq, SLOT(_q_updateBoundingRect(QSizeF)));
+ QObject::connect(control, SIGNAL(visibilityRequest(QRectF)),
+ qq, SLOT(_q_ensureVisible(QRectF)));
+ QObject::connect(control, SIGNAL(linkActivated(QString)),
+ qq, SIGNAL(linkActivated(QString)));
+ QObject::connect(control, SIGNAL(linkHovered(QString)),
+ qq, SIGNAL(linkHovered(QString)));
+
+ const QSizeF pgSize = control->document()->pageSize();
+ if (pgSize.height() != -1) {
+ qq->prepareGeometryChange();
+ that->dd->boundingRect.setSize(pgSize);
+ qq->update();
+ } else {
+ that->dd->_q_updateBoundingRect(control->size());
+ }
+ }
+ return control;
+}
+
+/*!
+ \internal
+*/
+bool QGraphicsTextItemPrivate::_q_mouseOnEdge(QGraphicsSceneMouseEvent *event)
+{
+ QPainterPath path;
+ path.addRect(qq->boundingRect());
+
+ QPainterPath docPath;
+ const QTextFrameFormat format = control->document()->rootFrame()->frameFormat();
+ docPath.addRect(
+ qq->boundingRect().adjusted(
+ format.leftMargin(),
+ format.topMargin(),
+ -format.rightMargin(),
+ -format.bottomMargin()));
+
+ return path.subtracted(docPath).contains(event->pos());
+}
+
+/*!
+ \fn QGraphicsTextItem::linkActivated(const QString &link)
+
+ This signal is emitted when the user clicks on a link on a text item
+ that enables Qt::LinksAccessibleByMouse or Qt::LinksAccessibleByKeyboard.
+ \a link is the link that was clicked.
+
+ \sa setTextInteractionFlags()
+*/
+
+/*!
+ \fn QGraphicsTextItem::linkHovered(const QString &link)
+
+ This signal is emitted when the user hovers over a link on a text item
+ that enables Qt::LinksAccessibleByMouse. \a link is
+ the link that was hovered over.
+
+ \sa setTextInteractionFlags()
+*/
+
+/*!
+ Sets the flags \a flags to specify how the text item should react to user
+ input.
+
+ The default for a QGraphicsTextItem is Qt::NoTextInteraction. This function
+ also affects the ItemIsFocusable QGraphicsItem flag by setting it if \a flags
+ is different from Qt::NoTextInteraction and clearing it otherwise.
+
+ By default, the text is read-only. To transform the item into an editor,
+ set the Qt::TextEditable flag.
+*/
+void QGraphicsTextItem::setTextInteractionFlags(Qt::TextInteractionFlags flags)
+{
+ if (flags == Qt::NoTextInteraction)
+ setFlags(this->flags() & ~(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod));
+ else
+ setFlags(this->flags() | QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod);
+
+ dd->textControl()->setTextInteractionFlags(flags);
+}
+
+/*!
+ Returns the current text interaction flags.
+
+ \sa setTextInteractionFlags()
+*/
+Qt::TextInteractionFlags QGraphicsTextItem::textInteractionFlags() const
+{
+ if (!dd->control)
+ return Qt::NoTextInteraction;
+ return dd->control->textInteractionFlags();
+}
+
+/*!
+ \since 4.5
+
+ If \a b is true, the \gui Tab key will cause the widget to change focus;
+ otherwise, the tab key will insert a tab into the document.
+
+ In some occasions text edits should not allow the user to input tabulators
+ or change indentation using the \gui Tab key, as this breaks the focus
+ chain. The default is false.
+
+ \sa tabChangesFocus(), ItemIsFocusable, textInteractionFlags()
+*/
+void QGraphicsTextItem::setTabChangesFocus(bool b)
+{
+ dd->tabChangesFocus = b;
+}
+
+/*!
+ \since 4.5
+
+ Returns true if the \gui Tab key will cause the widget to change focus;
+ otherwise, false is returned.
+
+ By default, this behavior is disabled, and this function will return false.
+
+ \sa setTabChangesFocus()
+*/
+bool QGraphicsTextItem::tabChangesFocus() const
+{
+ return dd->tabChangesFocus;
+}
+
+/*!
+ \property QGraphicsTextItem::openExternalLinks
+
+ Specifies whether QGraphicsTextItem should automatically open links using
+ QDesktopServices::openUrl() instead of emitting the
+ linkActivated signal.
+
+ The default value is false.
+*/
+void QGraphicsTextItem::setOpenExternalLinks(bool open)
+{
+ dd->textControl()->setOpenExternalLinks(open);
+}
+
+bool QGraphicsTextItem::openExternalLinks() const
+{
+ if (!dd->control)
+ return false;
+ return dd->control->openExternalLinks();
+}
+
+/*!
+ \property QGraphicsTextItem::textCursor
+
+ This property represents the visible text cursor in an editable
+ text item.
+
+ By default, if the item's text has not been set, this property
+ contains a null text cursor; otherwise it contains a text cursor
+ placed at the start of the item's document.
+*/
+void QGraphicsTextItem::setTextCursor(const QTextCursor &cursor)
+{
+ dd->textControl()->setTextCursor(cursor);
+}
+
+QTextCursor QGraphicsTextItem::textCursor() const
+{
+ if (!dd->control)
+ return QTextCursor();
+ return dd->control->textCursor();
+}
+
+class QGraphicsSimpleTextItemPrivate : public QAbstractGraphicsShapeItemPrivate
+{
+ Q_DECLARE_PUBLIC(QGraphicsSimpleTextItem)
+public:
+ inline QGraphicsSimpleTextItemPrivate() {
+ pen.setStyle(Qt::NoPen);
+ brush.setStyle(Qt::SolidPattern);
+ }
+ QString text;
+ QFont font;
+ QRectF boundingRect;
+
+ void updateBoundingRect();
+};
+
+static QRectF setupTextLayout(QTextLayout *layout)
+{
+ layout->setCacheEnabled(true);
+ layout->beginLayout();
+ while (layout->createLine().isValid())
+ ;
+ layout->endLayout();
+ qreal maxWidth = 0;
+ qreal y = 0;
+ for (int i = 0; i < layout->lineCount(); ++i) {
+ QTextLine line = layout->lineAt(i);
+ maxWidth = qMax(maxWidth, line.naturalTextWidth());
+ line.setPosition(QPointF(0, y));
+ y += line.height();
+ }
+ return QRectF(0, 0, maxWidth, y);
+}
+
+void QGraphicsSimpleTextItemPrivate::updateBoundingRect()
+{
+ Q_Q(QGraphicsSimpleTextItem);
+ QRectF br;
+ if (text.isEmpty()) {
+ br = QRectF();
+ } else {
+ QString tmp = text;
+ tmp.replace(QLatin1Char('\n'), QChar::LineSeparator);
+ QStackTextEngine engine(tmp, font);
+ QTextLayout layout(&engine);
+ br = setupTextLayout(&layout);
+ }
+ if (br != boundingRect) {
+ q->prepareGeometryChange();
+ boundingRect = br;
+ q->update();
+ }
+}
+
+/*!
+ \class QGraphicsSimpleTextItem
+ \brief The QGraphicsSimpleTextItem class provides a simple text path item
+ that you can add to a QGraphicsScene.
+ \since 4.2
+ \ingroup graphicsview-api
+
+ To set the item's text, you can either pass a QString to
+ QGraphicsSimpleTextItem's constructor, or call setText() to change the
+ text later. To set the text fill color, call setBrush().
+
+ The simple text item can have both a fill and an outline; setBrush() will
+ set the text fill (i.e., text color), and setPen() sets the pen that will
+ be used to draw the text outline. (The latter can be slow, especially for
+ complex pens, and items with long text content.) If all you want is to
+ draw a simple line of text, you should call setBrush() only, and leave the
+ pen unset; QGraphicsSimpleTextItem's pen is by default Qt::NoPen.
+
+ QGraphicsSimpleTextItem uses the text's formatted size and the associated
+ font to provide a reasonable implementation of boundingRect(), shape(),
+ and contains(). You can set the font by calling setFont().
+
+ QGraphicsSimpleText does not display rich text; instead, you can use
+ QGraphicsTextItem, which provides full text control capabilities.
+
+ \img graphicsview-simpletextitem.png
+
+ \sa QGraphicsTextItem, QGraphicsPathItem, QGraphicsRectItem,
+ QGraphicsEllipseItem, QGraphicsPixmapItem, QGraphicsPolygonItem,
+ QGraphicsLineItem, {Graphics View Framework}
+*/
+
+/*!
+ Constructs a QGraphicsSimpleTextItem.
+
+ \a parent is passed to QGraphicsItem's constructor.
+
+ \sa QGraphicsScene::addItem()
+*/
+QGraphicsSimpleTextItem::QGraphicsSimpleTextItem(QGraphicsItem *parent
+#ifndef Q_QDOC
+ // obsolete argument
+ , QGraphicsScene *scene
+#endif
+ )
+ : QAbstractGraphicsShapeItem(*new QGraphicsSimpleTextItemPrivate, parent, scene)
+{
+}
+
+/*!
+ Constructs a QGraphicsSimpleTextItem, using \a text as the default plain text.
+
+ \a parent is passed to QGraphicsItem's constructor.
+
+ \sa QGraphicsScene::addItem()
+*/
+QGraphicsSimpleTextItem::QGraphicsSimpleTextItem(const QString &text, QGraphicsItem *parent
+#ifndef Q_QDOC
+ // obsolete argument
+ , QGraphicsScene *scene
+#endif
+ )
+ : QAbstractGraphicsShapeItem(*new QGraphicsSimpleTextItemPrivate, parent, scene)
+{
+ setText(text);
+}
+
+/*!
+ Destroys the QGraphicsSimpleTextItem.
+*/
+QGraphicsSimpleTextItem::~QGraphicsSimpleTextItem()
+{
+}
+
+/*!
+ Sets the item's text to \a text. The text will be displayed as
+ plain text. Newline characters ('\n') as well as characters of
+ type QChar::LineSeparator will cause item to break the text into
+ multiple lines.
+*/
+void QGraphicsSimpleTextItem::setText(const QString &text)
+{
+ Q_D(QGraphicsSimpleTextItem);
+ if (d->text == text)
+ return;
+ d->text = text;
+ d->updateBoundingRect();
+ update();
+}
+
+/*!
+ Returns the item's text.
+*/
+QString QGraphicsSimpleTextItem::text() const
+{
+ Q_D(const QGraphicsSimpleTextItem);
+ return d->text;
+}
+
+/*!
+ Sets the font that is used to draw the item's text to \a font.
+*/
+void QGraphicsSimpleTextItem::setFont(const QFont &font)
+{
+ Q_D(QGraphicsSimpleTextItem);
+ d->font = font;
+ d->updateBoundingRect();
+}
+
+/*!
+ Returns the font that is used to draw the item's text.
+*/
+QFont QGraphicsSimpleTextItem::font() const
+{
+ Q_D(const QGraphicsSimpleTextItem);
+ return d->font;
+}
+
+/*!
+ \reimp
+*/
+QRectF QGraphicsSimpleTextItem::boundingRect() const
+{
+ Q_D(const QGraphicsSimpleTextItem);
+ return d->boundingRect;
+}
+
+/*!
+ \reimp
+*/
+QPainterPath QGraphicsSimpleTextItem::shape() const
+{
+ Q_D(const QGraphicsSimpleTextItem);
+ QPainterPath path;
+ path.addRect(d->boundingRect);
+ return path;
+}
+
+/*!
+ \reimp
+*/
+bool QGraphicsSimpleTextItem::contains(const QPointF &point) const
+{
+ Q_D(const QGraphicsSimpleTextItem);
+ return d->boundingRect.contains(point);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ Q_UNUSED(widget);
+ Q_D(QGraphicsSimpleTextItem);
+
+ painter->setFont(d->font);
+
+ QString tmp = d->text;
+ tmp.replace(QLatin1Char('\n'), QChar::LineSeparator);
+ QStackTextEngine engine(tmp, d->font);
+ QTextLayout layout(&engine);
+ setupTextLayout(&layout);
+
+ QPen p;
+ p.setBrush(d->brush);
+ painter->setPen(p);
+ if (d->pen.style() == Qt::NoPen && d->brush.style() == Qt::SolidPattern) {
+ painter->setBrush(Qt::NoBrush);
+ } else {
+ QTextLayout::FormatRange range;
+ range.start = 0;
+ range.length = layout.text().length();
+ range.format.setTextOutline(d->pen);
+ QList<QTextLayout::FormatRange> formats;
+ formats.append(range);
+ layout.setAdditionalFormats(formats);
+ }
+
+ layout.draw(painter, QPointF(0, 0));
+
+ if (option->state & (QStyle::State_Selected | QStyle::State_HasFocus))
+ qt_graphicsItem_highlightSelected(this, painter, option);
+}
+
+/*!
+ \reimp
+*/
+bool QGraphicsSimpleTextItem::isObscuredBy(const QGraphicsItem *item) const
+{
+ return QAbstractGraphicsShapeItem::isObscuredBy(item);
+}
+
+/*!
+ \reimp
+*/
+QPainterPath QGraphicsSimpleTextItem::opaqueArea() const
+{
+ return QAbstractGraphicsShapeItem::opaqueArea();
+}
+
+/*!
+ \reimp
+*/
+int QGraphicsSimpleTextItem::type() const
+{
+ return Type;
+}
+
+/*!
+ \internal
+*/
+bool QGraphicsSimpleTextItem::supportsExtension(Extension extension) const
+{
+ Q_UNUSED(extension);
+ return false;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSimpleTextItem::setExtension(Extension extension, const QVariant &variant)
+{
+ Q_UNUSED(extension);
+ Q_UNUSED(variant);
+}
+
+/*!
+ \internal
+*/
+QVariant QGraphicsSimpleTextItem::extension(const QVariant &variant) const
+{
+ Q_UNUSED(variant);
+ return QVariant();
+}
+
+/*!
+ \class QGraphicsItemGroup
+ \brief The QGraphicsItemGroup class provides a container that treats
+ a group of items as a single item.
+ \since 4.2
+ \ingroup graphicsview-api
+
+ A QGraphicsItemGroup is a special type of compound item that
+ treats itself and all its children as one item (i.e., all events
+ and geometries for all children are merged together). It's common
+ to use item groups in presentation tools, when the user wants to
+ group several smaller items into one big item in order to simplify
+ moving and copying of items.
+
+ If all you want is to store items inside other items, you can use
+ any QGraphicsItem directly by passing a suitable parent to
+ setParentItem().
+
+ The boundingRect() function of QGraphicsItemGroup returns the
+ bounding rectangle of all items in the item group.
+ QGraphicsItemGroup ignores the ItemIgnoresTransformations flag on
+ its children (i.e., with respect to the geometry of the group
+ item, the children are treated as if they were transformable).
+
+ There are two ways to construct an item group. The easiest and
+ most common approach is to pass a list of items (e.g., all
+ selected items) to QGraphicsScene::createItemGroup(), which
+ returns a new QGraphicsItemGroup item. The other approach is to
+ manually construct a QGraphicsItemGroup item, add it to the scene
+ calling QGraphicsScene::addItem(), and then add items to the group
+ manually, one at a time by calling addToGroup(). To dismantle
+ ("ungroup") an item group, you can either call
+ QGraphicsScene::destroyItemGroup(), or you can manually remove all
+ items from the group by calling removeFromGroup().
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsitem.cpp 17
+
+ The operation of adding and removing items preserves the items'
+ scene-relative position and transformation, as opposed to calling
+ setParentItem(), where only the child item's parent-relative
+ position and transformation are kept.
+
+ The addtoGroup() function reparents the target item to this item
+ group, keeping the item's position and transformation intact
+ relative to the scene. Visually, this means that items added via
+ addToGroup() will remain completely unchanged as a result of this
+ operation, regardless of the item or the group's current position
+ or transformation; although the item's position and matrix are
+ likely to change.
+
+ The removeFromGroup() function has similar semantics to
+ setParentItem(); it reparents the item to the parent item of the
+ item group. As with addToGroup(), the item's scene-relative
+ position and transformation remain intact.
+
+ \sa QGraphicsItem, {Graphics View Framework}
+*/
+
+class QGraphicsItemGroupPrivate : public QGraphicsItemPrivate
+{
+public:
+ QRectF itemsBoundingRect;
+};
+
+/*!
+ Constructs a QGraphicsItemGroup. \a parent is passed to QGraphicsItem's
+ constructor.
+
+ \sa QGraphicsScene::addItem()
+*/
+QGraphicsItemGroup::QGraphicsItemGroup(QGraphicsItem *parent
+#ifndef Q_QDOC
+ // obsolete argument
+ , QGraphicsScene *scene
+#endif
+ )
+ : QGraphicsItem(*new QGraphicsItemGroupPrivate, parent, scene)
+{
+ setHandlesChildEvents(true);
+}
+
+/*!
+ Destroys the QGraphicsItemGroup.
+*/
+QGraphicsItemGroup::~QGraphicsItemGroup()
+{
+}
+
+/*!
+ Adds the given \a item to this item group. The item will be
+ reparented to this group, but its position and transformation
+ relative to the scene will stay intact.
+
+ \sa removeFromGroup(), QGraphicsScene::createItemGroup()
+*/
+void QGraphicsItemGroup::addToGroup(QGraphicsItem *item)
+{
+ Q_D(QGraphicsItemGroup);
+ if (!item) {
+ qWarning("QGraphicsItemGroup::addToGroup: cannot add null item");
+ return;
+ }
+ if (item == this) {
+ qWarning("QGraphicsItemGroup::addToGroup: cannot add a group to itself");
+ return;
+ }
+
+ // COMBINE
+ bool ok;
+ QTransform itemTransform = item->itemTransform(this, &ok);
+
+ if (!ok) {
+ qWarning("QGraphicsItemGroup::addToGroup: could not find a valid transformation from item to group coordinates");
+ return;
+ }
+
+ QTransform newItemTransform(itemTransform);
+ item->setPos(mapFromItem(item, 0, 0));
+ item->setParentItem(this);
+
+ // removing position from translation component of the new transform
+ if (!item->pos().isNull())
+ newItemTransform *= QTransform::fromTranslate(-item->x(), -item->y());
+
+ // removing additional transformations properties applied with itemTransform()
+ QPointF origin = item->transformOriginPoint();
+ QMatrix4x4 m;
+ QList<QGraphicsTransform*> transformList = item->transformations();
+ for (int i = 0; i < transformList.size(); ++i)
+ transformList.at(i)->applyTo(&m);
+ newItemTransform *= m.toTransform().inverted();
+ newItemTransform.translate(origin.x(), origin.y());
+ newItemTransform.rotate(-item->rotation());
+ newItemTransform.scale(1/item->scale(), 1/item->scale());
+ newItemTransform.translate(-origin.x(), -origin.y());
+
+ // ### Expensive, we could maybe use dirtySceneTransform bit for optimization
+
+ item->setTransform(newItemTransform);
+ item->d_func()->setIsMemberOfGroup(true);
+ prepareGeometryChange();
+ d->itemsBoundingRect |= itemTransform.mapRect(item->boundingRect() | item->childrenBoundingRect());
+ update();
+}
+
+/*!
+ Removes the specified \a item from this group. The item will be
+ reparented to this group's parent item, or to 0 if this group has
+ no parent. Its position and transformation relative to the scene
+ will stay intact.
+
+ \sa addToGroup(), QGraphicsScene::destroyItemGroup()
+*/
+void QGraphicsItemGroup::removeFromGroup(QGraphicsItem *item)
+{
+ Q_D(QGraphicsItemGroup);
+ if (!item) {
+ qWarning("QGraphicsItemGroup::removeFromGroup: cannot remove null item");
+ return;
+ }
+
+ QGraphicsItem *newParent = d_ptr->parent;
+
+ // COMBINE
+ bool ok;
+ QTransform itemTransform;
+ if (newParent)
+ itemTransform = item->itemTransform(newParent, &ok);
+ else
+ itemTransform = item->sceneTransform();
+
+ QPointF oldPos = item->mapToItem(newParent, 0, 0);
+ item->setParentItem(newParent);
+ item->setPos(oldPos);
+
+ // removing position from translation component of the new transform
+ if (!item->pos().isNull())
+ itemTransform *= QTransform::fromTranslate(-item->x(), -item->y());
+
+ // removing additional transformations properties applied
+ // with itemTransform() or sceneTransform()
+ QPointF origin = item->transformOriginPoint();
+ QMatrix4x4 m;
+ QList<QGraphicsTransform*> transformList = item->transformations();
+ for (int i = 0; i < transformList.size(); ++i)
+ transformList.at(i)->applyTo(&m);
+ itemTransform *= m.toTransform().inverted();
+ itemTransform.translate(origin.x(), origin.y());
+ itemTransform.rotate(-item->rotation());
+ itemTransform.scale(1 / item->scale(), 1 / item->scale());
+ itemTransform.translate(-origin.x(), -origin.y());
+
+ // ### Expensive, we could maybe use dirtySceneTransform bit for optimization
+
+ item->setTransform(itemTransform);
+ item->d_func()->setIsMemberOfGroup(item->group() != 0);
+
+ // ### Quite expensive. But removeFromGroup() isn't called very often.
+ prepareGeometryChange();
+ d->itemsBoundingRect = childrenBoundingRect();
+}
+
+/*!
+ \reimp
+
+ Returns the bounding rect of this group item, and all its children.
+*/
+QRectF QGraphicsItemGroup::boundingRect() const
+{
+ Q_D(const QGraphicsItemGroup);
+ return d->itemsBoundingRect;
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsItemGroup::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+ QWidget *widget)
+{
+ Q_UNUSED(widget);
+ if (option->state & QStyle::State_Selected) {
+ Q_D(QGraphicsItemGroup);
+ painter->setBrush(Qt::NoBrush);
+ painter->drawRect(d->itemsBoundingRect);
+ }
+}
+
+/*!
+ \reimp
+*/
+bool QGraphicsItemGroup::isObscuredBy(const QGraphicsItem *item) const
+{
+ return QGraphicsItem::isObscuredBy(item);
+}
+
+/*!
+ \reimp
+*/
+QPainterPath QGraphicsItemGroup::opaqueArea() const
+{
+ return QGraphicsItem::opaqueArea();
+}
+
+/*!
+ \reimp
+*/
+int QGraphicsItemGroup::type() const
+{
+ return Type;
+}
+
+#ifndef QT_NO_GRAPHICSEFFECT
+QRectF QGraphicsItemEffectSourcePrivate::boundingRect(Qt::CoordinateSystem system) const
+{
+ const bool deviceCoordinates = (system == Qt::DeviceCoordinates);
+ if (!info && deviceCoordinates) {
+ // Device coordinates without info not yet supported.
+ qWarning("QGraphicsEffectSource::boundingRect: Not yet implemented, lacking device context");
+ return QRectF();
+ }
+
+ QRectF rect = item->boundingRect();
+ if (!item->d_ptr->children.isEmpty())
+ rect |= item->childrenBoundingRect();
+
+ if (deviceCoordinates) {
+ Q_ASSERT(info->painter);
+ rect = info->painter->worldTransform().mapRect(rect);
+ }
+
+ return rect;
+}
+
+void QGraphicsItemEffectSourcePrivate::draw(QPainter *painter)
+{
+ if (!info) {
+ qWarning("QGraphicsEffectSource::draw: Can only begin as a result of QGraphicsEffect::draw");
+ return;
+ }
+
+ Q_ASSERT(item->d_ptr->scene);
+ QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func();
+ if (painter == info->painter) {
+ scened->draw(item, painter, info->viewTransform, info->transformPtr, info->exposedRegion,
+ info->widget, info->opacity, info->effectTransform, info->wasDirtySceneTransform,
+ info->drawItem);
+ } else {
+ QTransform effectTransform = info->painter->worldTransform().inverted();
+ effectTransform *= painter->worldTransform();
+ scened->draw(item, painter, info->viewTransform, info->transformPtr, info->exposedRegion,
+ info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform,
+ info->drawItem);
+ }
+}
+
+// sourceRect must be in the given coordinate system
+QRect QGraphicsItemEffectSourcePrivate::paddedEffectRect(Qt::CoordinateSystem system, QGraphicsEffect::PixmapPadMode mode, const QRectF &sourceRect, bool *unpadded) const
+{
+ QRectF effectRectF;
+
+ if (unpadded)
+ *unpadded = false;
+
+ if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) {
+ if (info) {
+ QRectF deviceRect = system == Qt::DeviceCoordinates ? sourceRect : info->painter->worldTransform().mapRect(sourceRect);
+ effectRectF = item->graphicsEffect()->boundingRectFor(deviceRect);
+ if (unpadded)
+ *unpadded = (effectRectF.size() == sourceRect.size());
+ if (info && system == Qt::LogicalCoordinates)
+ effectRectF = info->painter->worldTransform().inverted().mapRect(effectRectF);
+ } else {
+ // no choice but to send a logical coordinate bounding rect to boundingRectFor
+ effectRectF = item->graphicsEffect()->boundingRectFor(sourceRect);
+ }
+ } else if (mode == QGraphicsEffect::PadToTransparentBorder) {
+ // adjust by 1.5 to account for cosmetic pens
+ effectRectF = sourceRect.adjusted(-1.5, -1.5, 1.5, 1.5);
+ } else {
+ effectRectF = sourceRect;
+ if (unpadded)
+ *unpadded = true;
+ }
+
+ return effectRectF.toAlignedRect();
+}
+
+QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset,
+ QGraphicsEffect::PixmapPadMode mode) const
+{
+ const bool deviceCoordinates = (system == Qt::DeviceCoordinates);
+ if (!info && deviceCoordinates) {
+ // Device coordinates without info not yet supported.
+ qWarning("QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context");
+ return QPixmap();
+ }
+ if (!item->d_ptr->scene)
+ return QPixmap();
+ QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func();
+
+ bool unpadded;
+ const QRectF sourceRect = boundingRect(system);
+ QRect effectRect = paddedEffectRect(system, mode, sourceRect, &unpadded);
+
+ if (offset)
+ *offset = effectRect.topLeft();
+
+ bool untransformed = !deviceCoordinates
+ || info->painter->worldTransform().type() <= QTransform::TxTranslate;
+ if (untransformed && unpadded && isPixmap()) {
+ if (offset)
+ *offset = boundingRect(system).topLeft().toPoint();
+ return static_cast<QGraphicsPixmapItem *>(item)->pixmap();
+ }
+
+ if (effectRect.isEmpty())
+ return QPixmap();
+
+ QPixmap pixmap(effectRect.size());
+ pixmap.fill(Qt::transparent);
+ QPainter pixmapPainter(&pixmap);
+ pixmapPainter.setRenderHints(info ? info->painter->renderHints() : QPainter::TextAntialiasing);
+
+ QTransform effectTransform = QTransform::fromTranslate(-effectRect.x(), -effectRect.y());
+ if (deviceCoordinates && info->effectTransform)
+ effectTransform *= *info->effectTransform;
+
+ if (!info) {
+ // Logical coordinates without info.
+ QTransform sceneTransform = item->sceneTransform();
+ QTransform newEffectTransform = sceneTransform.inverted();
+ newEffectTransform *= effectTransform;
+ scened->draw(item, &pixmapPainter, 0, &sceneTransform, 0, 0, qreal(1.0),
+ &newEffectTransform, false, true);
+ } else if (deviceCoordinates) {
+ // Device coordinates with info.
+ scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, 0,
+ info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform,
+ info->drawItem);
+ } else {
+ // Item coordinates with info.
+ QTransform newEffectTransform = info->transformPtr->inverted();
+ newEffectTransform *= effectTransform;
+ scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, 0,
+ info->widget, info->opacity, &newEffectTransform, info->wasDirtySceneTransform,
+ info->drawItem);
+ }
+
+ pixmapPainter.end();
+
+ return pixmap;
+}
+#endif //QT_NO_GRAPHICSEFFECT
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug debug, QGraphicsItem *item)
+{
+ if (!item) {
+ debug << "QGraphicsItem(0)";
+ return debug;
+ }
+
+ if (QGraphicsObject *o = item->toGraphicsObject())
+ debug << o->metaObject()->className();
+ else
+ debug << "QGraphicsItem";
+ debug << "(this =" << (void*)item
+ << ", parent =" << (void*)item->parentItem()
+ << ", pos =" << item->pos()
+ << ", z =" << item->zValue() << ", flags = "
+ << item->flags() << ")";
+ return debug;
+}
+
+QDebug operator<<(QDebug debug, QGraphicsObject *item)
+{
+ if (!item) {
+ debug << "QGraphicsObject(0)";
+ return debug;
+ }
+
+ debug.nospace() << item->metaObject()->className() << '(' << (void*)item;
+ if (!item->objectName().isEmpty())
+ debug << ", name = " << item->objectName();
+ debug.nospace() << ", parent = " << ((void*)item->parentItem())
+ << ", pos = " << item->pos()
+ << ", z = " << item->zValue() << ", flags = "
+ << item->flags() << ')';
+ return debug.space();
+}
+
+QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemChange change)
+{
+ const char *str = "UnknownChange";
+ switch (change) {
+ case QGraphicsItem::ItemChildAddedChange:
+ str = "ItemChildAddedChange";
+ break;
+ case QGraphicsItem::ItemChildRemovedChange:
+ str = "ItemChildRemovedChange";
+ break;
+ case QGraphicsItem::ItemCursorChange:
+ str = "ItemCursorChange";
+ break;
+ case QGraphicsItem::ItemCursorHasChanged:
+ str = "ItemCursorHasChanged";
+ break;
+ case QGraphicsItem::ItemEnabledChange:
+ str = "ItemEnabledChange";
+ break;
+ case QGraphicsItem::ItemEnabledHasChanged:
+ str = "ItemEnabledHasChanged";
+ break;
+ case QGraphicsItem::ItemFlagsChange:
+ str = "ItemFlagsChange";
+ break;
+ case QGraphicsItem::ItemFlagsHaveChanged:
+ str = "ItemFlagsHaveChanged";
+ break;
+ case QGraphicsItem::ItemMatrixChange:
+ str = "ItemMatrixChange";
+ break;
+ case QGraphicsItem::ItemParentChange:
+ str = "ItemParentChange";
+ break;
+ case QGraphicsItem::ItemParentHasChanged:
+ str = "ItemParentHasChanged";
+ break;
+ case QGraphicsItem::ItemPositionChange:
+ str = "ItemPositionChange";
+ break;
+ case QGraphicsItem::ItemPositionHasChanged:
+ str = "ItemPositionHasChanged";
+ break;
+ case QGraphicsItem::ItemSceneChange:
+ str = "ItemSceneChange";
+ break;
+ case QGraphicsItem::ItemSceneHasChanged:
+ str = "ItemSceneHasChanged";
+ break;
+ case QGraphicsItem::ItemSelectedChange:
+ str = "ItemSelectedChange";
+ break;
+ case QGraphicsItem::ItemSelectedHasChanged:
+ str = "ItemSelectedHasChanged";
+ break;
+ case QGraphicsItem::ItemToolTipChange:
+ str = "ItemToolTipChange";
+ break;
+ case QGraphicsItem::ItemToolTipHasChanged:
+ str = "ItemToolTipHasChanged";
+ break;
+ case QGraphicsItem::ItemTransformChange:
+ str = "ItemTransformChange";
+ break;
+ case QGraphicsItem::ItemTransformHasChanged:
+ str = "ItemTransformHasChanged";
+ break;
+ case QGraphicsItem::ItemVisibleChange:
+ str = "ItemVisibleChange";
+ break;
+ case QGraphicsItem::ItemVisibleHasChanged:
+ str = "ItemVisibleHasChanged";
+ break;
+ case QGraphicsItem::ItemZValueChange:
+ str = "ItemZValueChange";
+ break;
+ case QGraphicsItem::ItemZValueHasChanged:
+ str = "ItemZValueHasChanged";
+ break;
+ case QGraphicsItem::ItemOpacityChange:
+ str = "ItemOpacityChange";
+ break;
+ case QGraphicsItem::ItemOpacityHasChanged:
+ str = "ItemOpacityHasChanged";
+ break;
+ case QGraphicsItem::ItemScenePositionHasChanged:
+ str = "ItemScenePositionHasChanged";
+ break;
+ case QGraphicsItem::ItemRotationChange:
+ str = "ItemRotationChange";
+ break;
+ case QGraphicsItem::ItemRotationHasChanged:
+ str = "ItemRotationHasChanged";
+ break;
+ case QGraphicsItem::ItemScaleChange:
+ str = "ItemScaleChange";
+ break;
+ case QGraphicsItem::ItemScaleHasChanged:
+ str = "ItemScaleHasChanged";
+ break;
+ case QGraphicsItem::ItemTransformOriginPointChange:
+ str = "ItemTransformOriginPointChange";
+ break;
+ case QGraphicsItem::ItemTransformOriginPointHasChanged:
+ str = "ItemTransformOriginPointHasChanged";
+ break;
+ }
+ debug << str;
+ return debug;
+}
+
+QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlag flag)
+{
+ const char *str = "UnknownFlag";
+ switch (flag) {
+ case QGraphicsItem::ItemIsMovable:
+ str = "ItemIsMovable";
+ break;
+ case QGraphicsItem::ItemIsSelectable:
+ str = "ItemIsSelectable";
+ break;
+ case QGraphicsItem::ItemIsFocusable:
+ str = "ItemIsFocusable";
+ break;
+ case QGraphicsItem::ItemClipsToShape:
+ str = "ItemClipsToShape";
+ break;
+ case QGraphicsItem::ItemClipsChildrenToShape:
+ str = "ItemClipsChildrenToShape";
+ break;
+ case QGraphicsItem::ItemIgnoresTransformations:
+ str = "ItemIgnoresTransformations";
+ break;
+ case QGraphicsItem::ItemIgnoresParentOpacity:
+ str = "ItemIgnoresParentOpacity";
+ break;
+ case QGraphicsItem::ItemDoesntPropagateOpacityToChildren:
+ str = "ItemDoesntPropagateOpacityToChildren";
+ break;
+ case QGraphicsItem::ItemStacksBehindParent:
+ str = "ItemStacksBehindParent";
+ break;
+ case QGraphicsItem::ItemUsesExtendedStyleOption:
+ str = "ItemUsesExtendedStyleOption";
+ break;
+ case QGraphicsItem::ItemHasNoContents:
+ str = "ItemHasNoContents";
+ break;
+ case QGraphicsItem::ItemSendsGeometryChanges:
+ str = "ItemSendsGeometryChanges";
+ break;
+ case QGraphicsItem::ItemAcceptsInputMethod:
+ str = "ItemAcceptsInputMethod";
+ break;
+ case QGraphicsItem::ItemNegativeZStacksBehindParent:
+ str = "ItemNegativeZStacksBehindParent";
+ break;
+ case QGraphicsItem::ItemIsPanel:
+ str = "ItemIsPanel";
+ break;
+ case QGraphicsItem::ItemIsFocusScope:
+ str = "ItemIsFocusScope";
+ break;
+ case QGraphicsItem::ItemSendsScenePositionChanges:
+ str = "ItemSendsScenePositionChanges";
+ break;
+ case QGraphicsItem::ItemStopsClickFocusPropagation:
+ str = "ItemStopsClickFocusPropagation";
+ break;
+ case QGraphicsItem::ItemStopsFocusHandling:
+ str = "ItemStopsFocusHandling";
+ break;
+ }
+ debug << str;
+ return debug;
+}
+
+QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlags flags)
+{
+ debug << '(';
+ bool f = false;
+ for (int i = 0; i < 17; ++i) {
+ if (flags & (1 << i)) {
+ if (f)
+ debug << '|';
+ f = true;
+ debug << QGraphicsItem::GraphicsItemFlag(int(flags & (1 << i)));
+ }
+ }
+ debug << ')';
+ return debug;
+}
+
+#endif
+
+QT_END_NAMESPACE
+
+#include "moc_qgraphicsitem.cpp"
+
+#endif // QT_NO_GRAPHICSVIEW
diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/widgets/graphicsview/qgraphicsitem.h
index 67c9cd3e2a..67c9cd3e2a 100644
--- a/src/gui/graphicsview/qgraphicsitem.h
+++ b/src/widgets/graphicsview/qgraphicsitem.h
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/widgets/graphicsview/qgraphicsitem_p.h
index 90ff43f93c..90ff43f93c 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/widgets/graphicsview/qgraphicsitem_p.h
diff --git a/src/gui/graphicsview/qgraphicsitemanimation.cpp b/src/widgets/graphicsview/qgraphicsitemanimation.cpp
index 7eedc8dd3d..7eedc8dd3d 100644
--- a/src/gui/graphicsview/qgraphicsitemanimation.cpp
+++ b/src/widgets/graphicsview/qgraphicsitemanimation.cpp
diff --git a/src/gui/graphicsview/qgraphicsitemanimation.h b/src/widgets/graphicsview/qgraphicsitemanimation.h
index 5dfbf4b81e..5dfbf4b81e 100644
--- a/src/gui/graphicsview/qgraphicsitemanimation.h
+++ b/src/widgets/graphicsview/qgraphicsitemanimation.h
diff --git a/src/gui/graphicsview/qgraphicslayout.cpp b/src/widgets/graphicsview/qgraphicslayout.cpp
index 5bd298061d..5bd298061d 100644
--- a/src/gui/graphicsview/qgraphicslayout.cpp
+++ b/src/widgets/graphicsview/qgraphicslayout.cpp
diff --git a/src/widgets/graphicsview/qgraphicslayout.h b/src/widgets/graphicsview/qgraphicslayout.h
new file mode 100644
index 0000000000..113e6b9b7f
--- /dev/null
+++ b/src/widgets/graphicsview/qgraphicslayout.h
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGRAPHICSLAYOUT_H
+#define QGRAPHICSLAYOUT_H
+
+#include <QtWidgets/qgraphicslayoutitem.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
+
+class QGraphicsLayoutPrivate;
+class QGraphicsLayoutItem;
+class QGraphicsWidget;
+
+class Q_GUI_EXPORT QGraphicsLayout : public QGraphicsLayoutItem
+{
+public:
+ QGraphicsLayout(QGraphicsLayoutItem *parent = 0);
+ ~QGraphicsLayout();
+
+ void setContentsMargins(qreal left, qreal top, qreal right, qreal bottom);
+ void getContentsMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const;
+
+ void activate();
+ bool isActivated() const;
+ virtual void invalidate();
+ virtual void updateGeometry();
+
+ virtual void widgetEvent(QEvent *e);
+
+ virtual int count() const = 0;
+ virtual QGraphicsLayoutItem *itemAt(int i) const = 0;
+ virtual void removeAt(int index) = 0;
+
+protected:
+ QGraphicsLayout(QGraphicsLayoutPrivate &, QGraphicsLayoutItem *);
+ void addChildLayoutItem(QGraphicsLayoutItem *layoutItem);
+
+private:
+ Q_DISABLE_COPY(QGraphicsLayout)
+ Q_DECLARE_PRIVATE(QGraphicsLayout)
+ friend class QGraphicsWidget;
+};
+
+Q_DECLARE_INTERFACE(QGraphicsLayout, "com.trolltech.Qt.QGraphicsLayout")
+
+#endif
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
+
diff --git a/src/gui/graphicsview/qgraphicslayout_p.cpp b/src/widgets/graphicsview/qgraphicslayout_p.cpp
index c325602cc6..c325602cc6 100644
--- a/src/gui/graphicsview/qgraphicslayout_p.cpp
+++ b/src/widgets/graphicsview/qgraphicslayout_p.cpp
diff --git a/src/widgets/graphicsview/qgraphicslayout_p.h b/src/widgets/graphicsview/qgraphicslayout_p.h
new file mode 100644
index 0000000000..e3c6ce7607
--- /dev/null
+++ b/src/widgets/graphicsview/qgraphicslayout_p.h
@@ -0,0 +1,154 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGRAPHICSLAYOUT_P_H
+#define QGRAPHICSLAYOUT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qglobal.h>
+
+#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
+
+#include "qgraphicslayout.h"
+#include "qgraphicslayoutitem_p.h"
+#include <QtWidgets/qstyle.h>
+#include <QtWidgets/qwidget.h>
+#include <QtWidgets/qstyleoption.h>
+
+QT_BEGIN_NAMESPACE
+
+class QGraphicsLayoutItem;
+class QGraphicsWidget;
+
+#ifdef QT_DEBUG
+inline bool qt_graphicsLayoutDebug()
+{
+ static int checked_env = -1;
+ if(checked_env == -1)
+ checked_env = !!qgetenv("QT_GRAPHICSLAYOUT_DEBUG").toInt();
+ return checked_env;
+}
+#endif
+
+
+class QLayoutStyleInfo
+{
+public:
+ inline QLayoutStyleInfo() { invalidate(); }
+ inline QLayoutStyleInfo(QStyle *style, QWidget *widget)
+ : m_valid(true), m_style(style), m_widget(widget)
+ {
+ Q_ASSERT(style);
+ if (widget) //###
+ m_styleOption.initFrom(widget);
+ m_defaultSpacing[0] = style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing);
+ m_defaultSpacing[1] = style->pixelMetric(QStyle::PM_LayoutVerticalSpacing);
+ }
+
+ inline void invalidate() { m_valid = false; m_style = 0; m_widget = 0; }
+
+ inline QStyle *style() const { return m_style; }
+ inline QWidget *widget() const { return m_widget; }
+
+ inline bool operator==(const QLayoutStyleInfo &other)
+ { return m_style == other.m_style && m_widget == other.m_widget; }
+ inline bool operator!=(const QLayoutStyleInfo &other)
+ { return !(*this == other); }
+
+ inline void setDefaultSpacing(Qt::Orientation o, qreal spacing){
+ if (spacing >= 0)
+ m_defaultSpacing[o - 1] = spacing;
+ }
+
+ inline qreal defaultSpacing(Qt::Orientation o) const {
+ return m_defaultSpacing[o - 1];
+ }
+
+ inline qreal perItemSpacing(QSizePolicy::ControlType control1,
+ QSizePolicy::ControlType control2,
+ Qt::Orientation orientation) const
+ {
+ Q_ASSERT(style());
+ return style()->layoutSpacing(control1, control2, orientation, &m_styleOption, widget());
+ }
+private:
+ bool m_valid;
+ QStyle *m_style;
+ QWidget *m_widget;
+ QStyleOption m_styleOption;
+ qreal m_defaultSpacing[2];
+};
+
+class Q_AUTOTEST_EXPORT QGraphicsLayoutPrivate : public QGraphicsLayoutItemPrivate
+{
+ Q_DECLARE_PUBLIC(QGraphicsLayout)
+
+public:
+ QGraphicsLayoutPrivate() : QGraphicsLayoutItemPrivate(0, true), left(-1.0), top(-1.0), right(-1.0), bottom(-1.0),
+ activated(true) { }
+
+ void reparentChildItems(QGraphicsItem *newParent);
+ void getMargin(qreal *result, qreal userMargin, QStyle::PixelMetric pm) const;
+ Qt::LayoutDirection visualDirection() const;
+
+ void addChildLayoutItem(QGraphicsLayoutItem *item);
+ void activateRecursive(QGraphicsLayoutItem *item);
+
+ qreal left, top, right, bottom;
+ bool activated;
+};
+
+
+QT_END_NAMESPACE
+
+#endif //QT_NO_GRAPHICSVIEW
+
+#endif
diff --git a/src/gui/graphicsview/qgraphicslayoutitem.cpp b/src/widgets/graphicsview/qgraphicslayoutitem.cpp
index c064e01502..c064e01502 100644
--- a/src/gui/graphicsview/qgraphicslayoutitem.cpp
+++ b/src/widgets/graphicsview/qgraphicslayoutitem.cpp
diff --git a/src/widgets/graphicsview/qgraphicslayoutitem.h b/src/widgets/graphicsview/qgraphicslayoutitem.h
new file mode 100644
index 0000000000..a51b3320ad
--- /dev/null
+++ b/src/widgets/graphicsview/qgraphicslayoutitem.h
@@ -0,0 +1,155 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGRAPHICSLAYOUTITEM_H
+#define QGRAPHICSLAYOUTITEM_H
+
+#include <QtCore/qscopedpointer.h>
+#include <QtWidgets/qsizepolicy.h>
+#include <QtGui/qevent.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
+
+class QGraphicsLayoutItemPrivate;
+class QGraphicsItem;
+class Q_GUI_EXPORT QGraphicsLayoutItem
+{
+public:
+ QGraphicsLayoutItem(QGraphicsLayoutItem *parent = 0, bool isLayout = false);
+ virtual ~QGraphicsLayoutItem();
+
+ void setSizePolicy(const QSizePolicy &policy);
+ void setSizePolicy(QSizePolicy::Policy hPolicy, QSizePolicy::Policy vPolicy, QSizePolicy::ControlType controlType = QSizePolicy::DefaultType);
+ QSizePolicy sizePolicy() const;
+
+ void setMinimumSize(const QSizeF &size);
+ inline void setMinimumSize(qreal w, qreal h);
+ QSizeF minimumSize() const;
+ void setMinimumWidth(qreal width);
+ inline qreal minimumWidth() const;
+ void setMinimumHeight(qreal height);
+ inline qreal minimumHeight() const;
+
+ void setPreferredSize(const QSizeF &size);
+ inline void setPreferredSize(qreal w, qreal h);
+ QSizeF preferredSize() const;
+ void setPreferredWidth(qreal width);
+ inline qreal preferredWidth() const;
+ void setPreferredHeight(qreal height);
+ inline qreal preferredHeight() const;
+
+ void setMaximumSize(const QSizeF &size);
+ inline void setMaximumSize(qreal w, qreal h);
+ QSizeF maximumSize() const;
+ void setMaximumWidth(qreal width);
+ inline qreal maximumWidth() const;
+ void setMaximumHeight(qreal height);
+ inline qreal maximumHeight() const;
+
+ virtual void setGeometry(const QRectF &rect);
+ QRectF geometry() const;
+ virtual void getContentsMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const;
+ QRectF contentsRect() const;
+
+ QSizeF effectiveSizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
+
+ virtual void updateGeometry(); //### rename to sizeHintChanged()
+
+ QGraphicsLayoutItem *parentLayoutItem() const;
+ void setParentLayoutItem(QGraphicsLayoutItem *parent);
+
+ bool isLayout() const;
+ // ###Qt5: Make automatic reparenting work regardless of item/object/widget type.
+ QGraphicsItem *graphicsItem() const;
+ bool ownedByLayout() const;
+
+protected:
+ void setGraphicsItem(QGraphicsItem *item);
+ void setOwnedByLayout(bool ownedByLayout);
+ QGraphicsLayoutItem(QGraphicsLayoutItemPrivate &dd);
+
+ virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const = 0;
+ QScopedPointer<QGraphicsLayoutItemPrivate> d_ptr;
+
+private:
+ QSizeF *effectiveSizeHints(const QSizeF &constraint) const;
+ Q_DECLARE_PRIVATE(QGraphicsLayoutItem)
+
+ friend class QGraphicsLayout;
+};
+
+Q_DECLARE_INTERFACE(QGraphicsLayoutItem, "com.trolltech.Qt.QGraphicsLayoutItem")
+
+inline void QGraphicsLayoutItem::setMinimumSize(qreal aw, qreal ah)
+{ setMinimumSize(QSizeF(aw, ah)); }
+inline void QGraphicsLayoutItem::setPreferredSize(qreal aw, qreal ah)
+{ setPreferredSize(QSizeF(aw, ah)); }
+inline void QGraphicsLayoutItem::setMaximumSize(qreal aw, qreal ah)
+{ setMaximumSize(QSizeF(aw, ah)); }
+
+inline qreal QGraphicsLayoutItem::minimumWidth() const
+{ return effectiveSizeHint(Qt::MinimumSize).width(); }
+inline qreal QGraphicsLayoutItem::minimumHeight() const
+{ return effectiveSizeHint(Qt::MinimumSize).height(); }
+
+inline qreal QGraphicsLayoutItem::preferredWidth() const
+{ return effectiveSizeHint(Qt::PreferredSize).width(); }
+inline qreal QGraphicsLayoutItem::preferredHeight() const
+{ return effectiveSizeHint(Qt::PreferredSize).height(); }
+
+inline qreal QGraphicsLayoutItem::maximumWidth() const
+{ return effectiveSizeHint(Qt::MaximumSize).width(); }
+inline qreal QGraphicsLayoutItem::maximumHeight() const
+{ return effectiveSizeHint(Qt::MaximumSize).height(); }
+
+#endif
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/widgets/graphicsview/qgraphicslayoutitem_p.h b/src/widgets/graphicsview/qgraphicslayoutitem_p.h
new file mode 100644
index 0000000000..3751af315e
--- /dev/null
+++ b/src/widgets/graphicsview/qgraphicslayoutitem_p.h
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGRAPHICSLAYOUTITEM_P_H
+#define QGRAPHICSLAYOUTITEM_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/QSizeF>
+#include <QtWidgets/QSizePolicy>
+
+QT_BEGIN_NAMESPACE
+
+class QGraphicsLayoutItem;
+class Q_AUTOTEST_EXPORT QGraphicsLayoutItemPrivate
+{
+ Q_DECLARE_PUBLIC(QGraphicsLayoutItem)
+public:
+ virtual ~QGraphicsLayoutItemPrivate();
+ QGraphicsLayoutItemPrivate(QGraphicsLayoutItem *parent, bool isLayout);
+ static QGraphicsLayoutItemPrivate *get(QGraphicsLayoutItem *q) { return q->d_func();}
+ static const QGraphicsLayoutItemPrivate *get(const QGraphicsLayoutItem *q) { return q->d_func();}
+
+ void init();
+ QSizeF *effectiveSizeHints(const QSizeF &constraint) const;
+ QGraphicsItem *parentItem() const;
+ void ensureUserSizeHints();
+ void setSize(Qt::SizeHint which, const QSizeF &size);
+ enum SizeComponent { Width, Height };
+ void setSizeComponent(Qt::SizeHint which, SizeComponent component, qreal value);
+
+ bool hasHeightForWidth() const;
+ bool hasWidthForHeight() const;
+
+ QSizePolicy sizePolicy;
+ QGraphicsLayoutItem *parent;
+
+ QSizeF *userSizeHints;
+ mutable QSizeF cachedSizeHints[Qt::NSizeHints];
+ mutable QSizeF cachedConstraint;
+ mutable QSizeF cachedSizeHintsWithConstraints[Qt::NSizeHints];
+
+ mutable quint32 sizeHintCacheDirty : 1;
+ mutable quint32 sizeHintWithConstraintCacheDirty : 1;
+ quint32 isLayout : 1;
+ quint32 ownedByLayout : 1;
+
+ QGraphicsLayoutItem *q_ptr;
+ QRectF geom;
+ QGraphicsItem *graphicsItem;
+};
+
+QT_END_NAMESPACE
+
+#endif //QGRAPHICSLAYOUTITEM_P_H
+
diff --git a/src/gui/graphicsview/qgraphicslinearlayout.cpp b/src/widgets/graphicsview/qgraphicslinearlayout.cpp
index 5591638395..5591638395 100644
--- a/src/gui/graphicsview/qgraphicslinearlayout.cpp
+++ b/src/widgets/graphicsview/qgraphicslinearlayout.cpp
diff --git a/src/widgets/graphicsview/qgraphicslinearlayout.h b/src/widgets/graphicsview/qgraphicslinearlayout.h
new file mode 100644
index 0000000000..013731dc55
--- /dev/null
+++ b/src/widgets/graphicsview/qgraphicslinearlayout.h
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGRAPHICSLINEARLAYOUT_H
+#define QGRAPHICSLINEARLAYOUT_H
+
+#include <QtWidgets/qgraphicsitem.h>
+#include <QtWidgets/qgraphicslayout.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
+
+class QGraphicsLinearLayoutPrivate;
+
+class Q_GUI_EXPORT QGraphicsLinearLayout : public QGraphicsLayout
+{
+public:
+ QGraphicsLinearLayout(QGraphicsLayoutItem *parent = 0);
+ QGraphicsLinearLayout(Qt::Orientation orientation, QGraphicsLayoutItem *parent = 0);
+ virtual ~QGraphicsLinearLayout();
+
+ void setOrientation(Qt::Orientation orientation);
+ Qt::Orientation orientation() const;
+
+ inline void addItem(QGraphicsLayoutItem *item) { insertItem(-1, item); }
+ inline void addStretch(int stretch = 1) { insertStretch(-1, stretch); }
+
+ void insertItem(int index, QGraphicsLayoutItem *item);
+ void insertStretch(int index, int stretch = 1);
+
+ void removeItem(QGraphicsLayoutItem *item);
+ void removeAt(int index);
+
+ void setSpacing(qreal spacing);
+ qreal spacing() const;
+ void setItemSpacing(int index, qreal spacing);
+ qreal itemSpacing(int index) const;
+
+ void setStretchFactor(QGraphicsLayoutItem *item, int stretch);
+ int stretchFactor(QGraphicsLayoutItem *item) const;
+
+ void setAlignment(QGraphicsLayoutItem *item, Qt::Alignment alignment);
+ Qt::Alignment alignment(QGraphicsLayoutItem *item) const;
+
+ void setGeometry(const QRectF &rect);
+
+ int count() const;
+ QGraphicsLayoutItem *itemAt(int index) const;
+
+ void invalidate();
+ QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
+
+#if 0 // ###
+ Q5SizePolicy::ControlTypes controlTypes(LayoutSide side) const;
+#endif
+
+ void dump(int indent = 0) const;
+
+protected:
+#if 0
+ QSize contentsSizeHint(Qt::SizeHint which, const QSize &constraint = QSize()) const;
+#endif
+
+private:
+ Q_DISABLE_COPY(QGraphicsLinearLayout)
+ Q_DECLARE_PRIVATE(QGraphicsLinearLayout)
+};
+
+#endif
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
+
diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.cpp b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
new file mode 100644
index 0000000000..328c0803f1
--- /dev/null
+++ b/src/widgets/graphicsview/qgraphicsproxywidget.cpp
@@ -0,0 +1,1570 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qglobal.h"
+
+#ifndef QT_NO_GRAPHICSVIEW
+
+#include "qgraphicslayout.h"
+#include "qgraphicsproxywidget.h"
+#include "private/qgraphicsproxywidget_p.h"
+#include "private/qwidget_p.h"
+#include "private/qapplication_p.h"
+
+#include <QtCore/qdebug.h>
+#include <QtGui/qevent.h>
+#include <QtWidgets/qgraphicsscene.h>
+#include <QtWidgets/qgraphicssceneevent.h>
+#include <QtWidgets/qlayout.h>
+#include <QtGui/qpainter.h>
+#include <QtWidgets/qstyleoption.h>
+#include <QtWidgets/qgraphicsview.h>
+#include <QtWidgets/qlistview.h>
+#include <QtWidgets/qlineedit.h>
+#include <QtWidgets/qtextedit.h>
+
+QT_BEGIN_NAMESPACE
+
+//#define GRAPHICSPROXYWIDGET_DEBUG
+
+/*!
+ \class QGraphicsProxyWidget
+ \brief The QGraphicsProxyWidget class provides a proxy layer for embedding
+ a QWidget in a QGraphicsScene.
+ \since 4.4
+ \ingroup graphicsview-api
+
+ QGraphicsProxyWidget embeds QWidget-based widgets, for example, a
+ QPushButton, QFontComboBox, or even QFileDialog, into
+ QGraphicsScene. It forwards events between the two objects and
+ translates between QWidget's integer-based geometry and
+ QGraphicsWidget's qreal-based geometry. QGraphicsProxyWidget
+ supports all core features of QWidget, including tab focus,
+ keyboard input, Drag & Drop, and popups. You can also embed
+ complex widgets, e.g., widgets with subwidgets.
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp 0
+
+ QGraphicsProxyWidget takes care of automatically embedding popup children
+ of embedded widgets through creating a child proxy for each popup. This
+ means that when an embedded QComboBox shows its popup list, a new
+ QGraphicsProxyWidget is created automatically, embedding the popup, and
+ positioning it correctly. This only works if the popup is child of the
+ embedded widget (for example QToolButton::setMenu() requires the QMenu instance
+ to be child of the QToolButton).
+
+ \section1 Embedding a Widget with QGraphicsProxyWidget
+
+ There are two ways to embed a widget using QGraphicsProxyWidget. The most
+ common way is to pass a widget pointer to QGraphicsScene::addWidget()
+ together with any relevant \l Qt::WindowFlags. This function returns a
+ pointer to a QGraphicsProxyWidget. You can then choose to reparent or
+ position either the proxy, or the embedded widget itself.
+
+ For example, in the code snippet below, we embed a group box into the proxy:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp 1
+
+ The image below is the output obtained with its contents margin and
+ contents rect labeled.
+
+ \image qgraphicsproxywidget-embed.png
+
+ Alternatively, you can start by creating a new QGraphicsProxyWidget item,
+ and then call setWidget() to embed a QWidget later. The widget() function
+ returns a pointer to the embedded widget. QGraphicsProxyWidget shares
+ ownership with QWidget, so if either of the two widgets are destroyed, the
+ other widget will be automatically destroyed as well.
+
+ \section1 Synchronizing Widget States
+
+ QGraphicsProxyWidget keeps its state in sync with the embedded widget. For
+ example, if the proxy is hidden or disabled, the embedded widget will be
+ hidden or disabled as well, and vice versa. When the widget is embedded by
+ calling addWidget(), QGraphicsProxyWidget copies the state from the widget
+ into the proxy, and after that, the two will stay synchronized where
+ possible. By default, when you embed a widget into a proxy, both the widget
+ and the proxy will be visible because a QGraphicsWidget is visible when
+ created (you do not have to call show()). If you explicitly hide the
+ embedded widget, the proxy will also become invisible.
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsproxywidget.cpp 2
+
+ QGraphicsProxyWidget maintains symmetry for the following states:
+
+ \table
+ \header \o QWidget state \o QGraphicsProxyWidget state \o Notes
+ \row \o QWidget::enabled
+ \o QGraphicsProxyWidget::enabled
+ \o
+ \row \o QWidget::visible
+ \o QGraphicsProxyWidget::visible
+ \o The explicit state is also symmetric.
+ \row \o QWidget::geometry
+ \o QGraphicsProxyWidget::geometry
+ \o Geometry is only guaranteed to be symmetric while
+ the embedded widget is visible.
+ \row \o QWidget::layoutDirection
+ \o QGraphicsProxyWidget::layoutDirection
+ \o
+ \row \o QWidget::style
+ \o QGraphicsProxyWidget::style
+ \o
+ \row \o QWidget::palette
+ \o QGraphicsProxyWidget::palette
+ \o
+ \row \o QWidget::font
+ \o QGraphicsProxyWidget::font
+ \o
+ \row \o QWidget::cursor
+ \o QGraphicsProxyWidget::cursor
+ \o The embedded widget overrides the proxy widget
+ cursor. The proxy cursor changes depending on
+ which embedded subwidget is currently under the
+ mouse.
+ \row \o QWidget::sizeHint()
+ \o QGraphicsProxyWidget::sizeHint()
+ \o All size hint functionality from the embedded
+ widget is forwarded by the proxy.
+ \row \o QWidget::getContentsMargins()
+ \o QGraphicsProxyWidget::getContentsMargins()
+ \o Updated once by setWidget().
+ \row \o QWidget::windowTitle
+ \o QGraphicsProxyWidget::windowTitle
+ \o Updated once by setWidget().
+ \endtable
+
+ \note QGraphicsScene keeps the embedded widget in a special state that
+ prevents it from disturbing other widgets (both embedded and not embedded)
+ while the widget is embedded. In this state, the widget may differ slightly
+ in behavior from when it is not embedded.
+
+ \warning This class is provided for convenience when bridging
+ QWidgets and QGraphicsItems, it should not be used for
+ high-performance scenarios.
+
+ \sa QGraphicsScene::addWidget(), QGraphicsWidget
+*/
+
+extern bool qt_sendSpontaneousEvent(QObject *, QEvent *);
+Q_GUI_EXPORT extern bool qt_tab_all_widgets;
+
+/*!
+ \internal
+*/
+void QGraphicsProxyWidgetPrivate::init()
+{
+ Q_Q(QGraphicsProxyWidget);
+ q->setFocusPolicy(Qt::WheelFocus);
+ q->setAcceptDrops(true);
+}
+
+/*!
+ \internal
+*/
+void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneHoverEvent *event)
+{
+ QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseMove);
+ mouseEvent.setPos(event->pos());
+ mouseEvent.setScreenPos(event->screenPos());
+ mouseEvent.setButton(Qt::NoButton);
+ mouseEvent.setButtons(0);
+ mouseEvent.setModifiers(event->modifiers());
+ sendWidgetMouseEvent(&mouseEvent);
+ event->setAccepted(mouseEvent.isAccepted());
+}
+
+/*!
+ \internal
+*/
+void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneMouseEvent *event)
+{
+ if (!event || !widget || !widget->isVisible())
+ return;
+ Q_Q(QGraphicsProxyWidget);
+
+ // Find widget position and receiver.
+ QPointF pos = event->pos();
+ QPointer<QWidget> alienWidget = widget->childAt(pos.toPoint());
+ QPointer<QWidget> receiver = alienWidget ? alienWidget : widget;
+
+ if (QWidgetPrivate::nearestGraphicsProxyWidget(receiver) != q)
+ return; //another proxywidget will handle the events
+
+ // Translate QGraphicsSceneMouse events to QMouseEvents.
+ QEvent::Type type = QEvent::None;
+ switch (event->type()) {
+ case QEvent::GraphicsSceneMousePress:
+ type = QEvent::MouseButtonPress;
+ if (!embeddedMouseGrabber)
+ embeddedMouseGrabber = receiver;
+ else
+ receiver = embeddedMouseGrabber;
+ break;
+ case QEvent::GraphicsSceneMouseRelease:
+ type = QEvent::MouseButtonRelease;
+ if (embeddedMouseGrabber)
+ receiver = embeddedMouseGrabber;
+ break;
+ case QEvent::GraphicsSceneMouseDoubleClick:
+ type = QEvent::MouseButtonDblClick;
+ if (!embeddedMouseGrabber)
+ embeddedMouseGrabber = receiver;
+ else
+ receiver = embeddedMouseGrabber;
+ break;
+ case QEvent::GraphicsSceneMouseMove:
+ type = QEvent::MouseMove;
+ if (embeddedMouseGrabber)
+ receiver = embeddedMouseGrabber;
+ break;
+ default:
+ Q_ASSERT_X(false, "QGraphicsProxyWidget", "internal error");
+ break;
+ }
+
+ if (!lastWidgetUnderMouse) {
+ QApplicationPrivate::dispatchEnterLeave(embeddedMouseGrabber ? embeddedMouseGrabber : receiver, 0);
+ lastWidgetUnderMouse = receiver;
+ }
+
+ // Map event position from us to the receiver
+ pos = mapToReceiver(pos, receiver);
+
+ // Send mouse event.
+ QMouseEvent *mouseEvent = QMouseEvent::createExtendedMouseEvent(type, pos,
+ receiver->mapToGlobal(pos.toPoint()), event->button(),
+ event->buttons(), event->modifiers());
+
+ QWidget *embeddedMouseGrabberPtr = (QWidget *)embeddedMouseGrabber;
+ QApplicationPrivate::sendMouseEvent(receiver, mouseEvent, alienWidget, widget,
+ &embeddedMouseGrabberPtr, lastWidgetUnderMouse, event->spontaneous());
+ embeddedMouseGrabber = embeddedMouseGrabberPtr;
+
+ // Handle enter/leave events when last button is released from mouse
+ // grabber child widget.
+ if (embeddedMouseGrabber && type == QEvent::MouseButtonRelease && !event->buttons()) {
+ Q_Q(QGraphicsProxyWidget);
+ if (q->rect().contains(event->pos()) && q->acceptsHoverEvents())
+ lastWidgetUnderMouse = alienWidget ? alienWidget : widget;
+ else // released on the frame our outside the item, or doesn't accept hover events.
+ lastWidgetUnderMouse = 0;
+
+ QApplicationPrivate::dispatchEnterLeave(lastWidgetUnderMouse, embeddedMouseGrabber);
+ embeddedMouseGrabber = 0;
+
+#ifndef QT_NO_CURSOR
+ // ### Restore the cursor, don't override it.
+ if (!lastWidgetUnderMouse)
+ q->unsetCursor();
+#endif
+ }
+
+ event->setAccepted(mouseEvent->isAccepted());
+ delete mouseEvent;
+}
+
+void QGraphicsProxyWidgetPrivate::sendWidgetKeyEvent(QKeyEvent *event)
+{
+ Q_Q(QGraphicsProxyWidget);
+ if (!event || !widget || !widget->isVisible())
+ return;
+
+ QPointer<QWidget> receiver = widget->focusWidget();
+ if (!receiver)
+ receiver = widget;
+ Q_ASSERT(receiver);
+
+ do {
+ bool res = QApplication::sendEvent(receiver, event);
+ if ((res && event->isAccepted()) || (q->isWindow() && receiver == widget))
+ break;
+ receiver = receiver->parentWidget();
+ } while (receiver);
+}
+
+/*!
+ \internal
+*/
+void QGraphicsProxyWidgetPrivate::removeSubFocusHelper(QWidget *widget, Qt::FocusReason reason)
+{
+ QFocusEvent event(QEvent::FocusOut, reason);
+ QPointer<QWidget> widgetGuard = widget;
+ QApplication::sendEvent(widget, &event);
+ if (widgetGuard && event.isAccepted())
+ QApplication::sendEvent(widget->style(), &event);
+}
+
+/*!
+ \internal
+
+ Reimplemented from QGraphicsItemPrivate. ### Qt 5: Move impl to
+ reimplementation QGraphicsProxyWidget::inputMethodQuery().
+*/
+QVariant QGraphicsProxyWidgetPrivate::inputMethodQueryHelper(Qt::InputMethodQuery query) const
+{
+ Q_Q(const QGraphicsProxyWidget);
+ if (!widget || !q->hasFocus())
+ return QVariant();
+
+ QWidget *focusWidget = widget->focusWidget();
+ if (!focusWidget)
+ focusWidget = widget;
+ QVariant v = focusWidget->inputMethodQuery(query);
+ QPointF focusWidgetPos = q->subWidgetRect(focusWidget).topLeft();
+ switch (v.type()) {
+ case QVariant::RectF:
+ v = v.toRectF().translated(focusWidgetPos);
+ break;
+ case QVariant::PointF:
+ v = v.toPointF() + focusWidgetPos;
+ break;
+ case QVariant::Rect:
+ v = v.toRect().translated(focusWidgetPos.toPoint());
+ break;
+ case QVariant::Point:
+ v = v.toPoint() + focusWidgetPos.toPoint();
+ break;
+ default:
+ break;
+ }
+ return v;
+}
+
+/*!
+ \internal
+ Some of the logic is shared with QApplicationPrivate::focusNextPrevChild_helper
+*/
+QWidget *QGraphicsProxyWidgetPrivate::findFocusChild(QWidget *child, bool next) const
+{
+ if (!widget)
+ return 0;
+
+ // Run around the focus chain until we find a widget that can take tab focus.
+ if (!child) {
+ child = next ? (QWidget *)widget : widget->d_func()->focus_prev;
+ } else {
+ child = next ? child->d_func()->focus_next : child->d_func()->focus_prev;
+ if ((next && child == widget) || (!next && child == widget->d_func()->focus_prev)) {
+ return 0;
+ }
+ }
+
+ QWidget *oldChild = child;
+ uint focus_flag = qt_tab_all_widgets ? Qt::TabFocus : Qt::StrongFocus;
+ do {
+ if (child->isEnabled()
+ && child->isVisibleTo(widget)
+ && ((child->focusPolicy() & focus_flag) == focus_flag)
+ && !(child->d_func()->extra && child->d_func()->extra->focus_proxy)) {
+ return child;
+ }
+ child = next ? child->d_func()->focus_next : child->d_func()->focus_prev;
+ } while (child != oldChild && !(next && child == widget) && !(!next && child == widget->d_func()->focus_prev));
+ return 0;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsProxyWidgetPrivate::_q_removeWidgetSlot()
+{
+ Q_Q(QGraphicsProxyWidget);
+ widget = 0;
+ delete q;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsProxyWidgetPrivate::updateWidgetGeometryFromProxy()
+{
+}
+
+/*!
+ \internal
+*/
+void QGraphicsProxyWidgetPrivate::updateProxyGeometryFromWidget()
+{
+ Q_Q(QGraphicsProxyWidget);
+ if (!widget)
+ return;
+
+ QRectF widgetGeometry = widget->geometry();
+ QWidget *parentWidget = widget->parentWidget();
+ if (widget->isWindow()) {
+ QGraphicsProxyWidget *proxyParent = 0;
+ if (parentWidget && (proxyParent = qobject_cast<QGraphicsProxyWidget *>(q->parentWidget()))) {
+ // Nested window proxy (e.g., combobox popup), map widget to the
+ // parent widget's global coordinates, and map that to the parent
+ // proxy's child coordinates.
+ widgetGeometry.moveTo(proxyParent->subWidgetRect(parentWidget).topLeft()
+ + parentWidget->mapFromGlobal(widget->pos()));
+ }
+ }
+
+ // Adjust to size hint if the widget has never been resized.
+ if (!widget->size().isValid())
+ widgetGeometry.setSize(widget->sizeHint());
+
+ // Assign new geometry.
+ posChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
+ sizeChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
+ q->setGeometry(widgetGeometry);
+ posChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
+ sizeChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsProxyWidgetPrivate::updateProxyInputMethodAcceptanceFromWidget()
+{
+ Q_Q(QGraphicsProxyWidget);
+ if (!widget)
+ return;
+
+ QWidget *focusWidget = widget->focusWidget();
+ if (!focusWidget)
+ focusWidget = widget;
+ q->setFlag(QGraphicsItem::ItemAcceptsInputMethod,
+ focusWidget->testAttribute(Qt::WA_InputMethodEnabled));
+}
+
+/*!
+ \internal
+
+ Embeds \a subWin as a subwindow of this proxy widget. \a subWin must be a top-level
+ widget and a descendant of the widget managed by this proxy. A separate subproxy
+ will be created as a child of this proxy widget to manage \a subWin.
+*/
+void QGraphicsProxyWidgetPrivate::embedSubWindow(QWidget *subWin)
+{
+ QWExtra *extra;
+ if (!((extra = subWin->d_func()->extra) && extra->proxyWidget)) {
+ QGraphicsProxyWidget *subProxy = new QGraphicsProxyWidget(q_func(), subWin->windowFlags());
+ subProxy->d_func()->setWidget_helper(subWin, false);
+ }
+}
+
+/*!
+ \internal
+
+ Removes ("unembeds") \a subWin and deletes the proxy holder item. This can
+ happen when QWidget::setParent() reparents the embedded window out of
+ "embedded space".
+*/
+void QGraphicsProxyWidgetPrivate::unembedSubWindow(QWidget *subWin)
+{
+ foreach (QGraphicsItem *child, children) {
+ if (child->isWidget()) {
+ if (QGraphicsProxyWidget *proxy = qobject_cast<QGraphicsProxyWidget *>(static_cast<QGraphicsWidget *>(child))) {
+ if (proxy->widget() == subWin) {
+ proxy->setWidget(0);
+ scene->removeItem(proxy);
+ delete proxy;
+ return;
+ }
+ }
+ }
+ }
+}
+
+bool QGraphicsProxyWidgetPrivate::isProxyWidget() const
+{
+ return true;
+}
+
+/*!
+ \internal
+*/
+QPointF QGraphicsProxyWidgetPrivate::mapToReceiver(const QPointF &pos, const QWidget *receiver) const
+{
+ QPointF p = pos;
+ // Map event position from us to the receiver, preserving its
+ // precision (don't use QWidget::mapFrom here).
+ while (receiver && receiver != widget) {
+ p -= QPointF(receiver->pos());
+ receiver = receiver->parentWidget();
+ }
+ return p;
+}
+
+/*!
+ Constructs a new QGraphicsProxy widget. \a parent and \a wFlags are passed
+ to QGraphicsItem's constructor.
+*/
+QGraphicsProxyWidget::QGraphicsProxyWidget(QGraphicsItem *parent, Qt::WindowFlags wFlags)
+ : QGraphicsWidget(*new QGraphicsProxyWidgetPrivate, parent, 0, wFlags)
+{
+ Q_D(QGraphicsProxyWidget);
+ d->init();
+}
+
+/*!
+ Destroys the proxy widget and any embedded widget.
+*/
+QGraphicsProxyWidget::~QGraphicsProxyWidget()
+{
+ Q_D(QGraphicsProxyWidget);
+ if (d->widget) {
+ QObject::disconnect(d->widget, SIGNAL(destroyed()), this, SLOT(_q_removeWidgetSlot()));
+ delete d->widget;
+ }
+}
+
+/*!
+ Embeds \a widget into this proxy widget. The embedded widget must reside
+ exclusively either inside or outside of Graphics View. You cannot embed a
+ widget as long as it is is visible elsewhere in the UI, at the same time.
+
+ \a widget must be a top-level widget whose parent is 0.
+
+ When the widget is embedded, its state (e.g., visible, enabled, geometry,
+ size hints) is copied into the proxy widget. If the embedded widget is
+ explicitly hidden or disabled, the proxy widget will become explicitly
+ hidden or disabled after embedding is complete. The class documentation
+ has a full overview over the shared state.
+
+ QGraphicsProxyWidget's window flags determine whether the widget, after
+ embedding, will be given window decorations or not.
+
+ After this function returns, QGraphicsProxyWidget will keep its state
+ synchronized with that of \a widget whenever possible.
+
+ If a widget is already embedded by this proxy when this function is
+ called, that widget will first be automatically unembedded. Passing 0 for
+ the \a widget argument will only unembed the widget, and the ownership of
+ the currently embedded widget will be passed on to the caller.
+ Every child widget that are embedded will also be embedded and their proxy
+ widget destroyed.
+
+ Note that widgets with the Qt::WA_PaintOnScreen widget attribute
+ set and widgets that wrap an external application or controller
+ cannot be embedded. Examples are QGLWidget and QAxWidget.
+
+ \sa widget()
+*/
+void QGraphicsProxyWidget::setWidget(QWidget *widget)
+{
+ Q_D(QGraphicsProxyWidget);
+ d->setWidget_helper(widget, true);
+}
+
+void QGraphicsProxyWidgetPrivate::setWidget_helper(QWidget *newWidget, bool autoShow)
+{
+ Q_Q(QGraphicsProxyWidget);
+ if (newWidget == widget)
+ return;
+ if (widget) {
+ QObject::disconnect(widget, SIGNAL(destroyed()), q, SLOT(_q_removeWidgetSlot()));
+ widget->removeEventFilter(q);
+ widget->setAttribute(Qt::WA_DontShowOnScreen, false);
+ widget->d_func()->extra->proxyWidget = 0;
+ resolveFont(inheritedFontResolveMask);
+ resolvePalette(inheritedPaletteResolveMask);
+ widget->update();
+
+ foreach (QGraphicsItem *child, q->childItems()) {
+ if (child->d_ptr->isProxyWidget()) {
+ QGraphicsProxyWidget *childProxy = static_cast<QGraphicsProxyWidget *>(child);
+ QWidget * parent = childProxy->widget();
+ while (parent->parentWidget() != 0) {
+ if (parent == widget)
+ break;
+ parent = parent->parentWidget();
+ }
+ if (!childProxy->widget() || parent != widget)
+ continue;
+ childProxy->setWidget(0);
+ delete childProxy;
+ }
+ }
+
+ widget = 0;
+#ifndef QT_NO_CURSOR
+ q->unsetCursor();
+#endif
+ q->setAcceptHoverEvents(false);
+ if (!newWidget)
+ q->update();
+ }
+ if (!newWidget)
+ return;
+ if (!newWidget->isWindow()) {
+ QWExtra *extra = newWidget->parentWidget()->d_func()->extra;
+ if (!extra || !extra->proxyWidget) {
+ qWarning("QGraphicsProxyWidget::setWidget: cannot embed widget %p "
+ "which is not a toplevel widget, and is not a child of an embedded widget", newWidget);
+ return;
+ }
+ }
+
+ // Register this proxy within the widget's private.
+ // ### This is a bit backdoorish
+ QWExtra *extra = newWidget->d_func()->extra;
+ if (!extra) {
+ newWidget->d_func()->createExtra();
+ extra = newWidget->d_func()->extra;
+ }
+ QGraphicsProxyWidget **proxyWidget = &extra->proxyWidget;
+ if (*proxyWidget) {
+ if (*proxyWidget != q) {
+ qWarning("QGraphicsProxyWidget::setWidget: cannot embed widget %p"
+ "; already embedded", newWidget);
+ }
+ return;
+ }
+ *proxyWidget = q;
+
+ newWidget->setAttribute(Qt::WA_DontShowOnScreen);
+ newWidget->ensurePolished();
+ // Do not wait for this widget to close before the app closes ###
+ // shouldn't this widget inherit the attribute?
+ newWidget->setAttribute(Qt::WA_QuitOnClose, false);
+ q->setAcceptHoverEvents(true);
+
+ if (newWidget->testAttribute(Qt::WA_NoSystemBackground))
+ q->setAttribute(Qt::WA_NoSystemBackground);
+ if (newWidget->testAttribute(Qt::WA_OpaquePaintEvent))
+ q->setAttribute(Qt::WA_OpaquePaintEvent);
+
+ widget = newWidget;
+
+ // Changes only go from the widget to the proxy.
+ enabledChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
+ visibleChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
+ posChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
+ sizeChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
+
+ if ((autoShow && !newWidget->testAttribute(Qt::WA_WState_ExplicitShowHide)) || !newWidget->testAttribute(Qt::WA_WState_Hidden)) {
+ newWidget->show();
+ }
+
+ // Copy the state from the widget onto the proxy.
+#ifndef QT_NO_CURSOR
+ if (newWidget->testAttribute(Qt::WA_SetCursor))
+ q->setCursor(widget->cursor());
+#endif
+ q->setEnabled(newWidget->isEnabled());
+ q->setVisible(newWidget->isVisible());
+ q->setLayoutDirection(newWidget->layoutDirection());
+ if (newWidget->testAttribute(Qt::WA_SetStyle))
+ q->setStyle(widget->style());
+
+ resolveFont(inheritedFontResolveMask);
+ resolvePalette(inheritedPaletteResolveMask);
+
+ if (!newWidget->testAttribute(Qt::WA_Resized))
+ newWidget->adjustSize();
+
+ int left, top, right, bottom;
+ newWidget->getContentsMargins(&left, &top, &right, &bottom);
+ q->setContentsMargins(left, top, right, bottom);
+ q->setWindowTitle(newWidget->windowTitle());
+
+ // size policies and constraints..
+ q->setSizePolicy(newWidget->sizePolicy());
+ QSize sz = newWidget->minimumSize();
+ q->setMinimumSize(sz.isNull() ? QSizeF() : QSizeF(sz));
+ sz = newWidget->maximumSize();
+ q->setMaximumSize(sz.isNull() ? QSizeF() : QSizeF(sz));
+
+ updateProxyGeometryFromWidget();
+
+ updateProxyInputMethodAcceptanceFromWidget();
+
+ // Hook up the event filter to keep the state up to date.
+ newWidget->installEventFilter(q);
+ QObject::connect(newWidget, SIGNAL(destroyed()), q, SLOT(_q_removeWidgetSlot()));
+
+ // Changes no longer go only from the widget to the proxy.
+ enabledChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
+ visibleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
+ posChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
+ sizeChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
+}
+
+/*!
+ Returns a pointer to the embedded widget.
+
+ \sa setWidget()
+*/
+QWidget *QGraphicsProxyWidget::widget() const
+{
+ Q_D(const QGraphicsProxyWidget);
+ return d->widget;
+}
+
+/*!
+ Returns the rectangle for \a widget, which must be a descendant of
+ widget(), or widget() itself, in this proxy item's local coordinates.
+
+ If no widget is embedded, \a widget is 0, or \a widget is not a
+ descendant of the embedded widget, this function returns an empty QRectF.
+
+ \sa widget()
+*/
+QRectF QGraphicsProxyWidget::subWidgetRect(const QWidget *widget) const
+{
+ Q_D(const QGraphicsProxyWidget);
+ if (!widget || !d->widget)
+ return QRectF();
+ if (d->widget == widget || d->widget->isAncestorOf(widget))
+ return QRectF(widget->mapTo(d->widget, QPoint(0, 0)), widget->size());
+ return QRectF();
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsProxyWidget::setGeometry(const QRectF &rect)
+{
+ Q_D(QGraphicsProxyWidget);
+ bool proxyResizesWidget = !d->posChangeMode && !d->sizeChangeMode;
+ if (proxyResizesWidget) {
+ d->posChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
+ d->sizeChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
+ }
+ QGraphicsWidget::setGeometry(rect);
+ if (proxyResizesWidget) {
+ d->posChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
+ d->sizeChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
+ }
+}
+
+/*!
+ \reimp
+*/
+QVariant QGraphicsProxyWidget::itemChange(GraphicsItemChange change,
+ const QVariant &value)
+{
+ Q_D(QGraphicsProxyWidget);
+
+ switch (change) {
+ case ItemPositionChange:
+ // The item's position is either changed directly on the proxy, in
+ // which case the position change should propagate to the widget,
+ // otherwise it happens as a side effect when filtering QEvent::Move.
+ if (!d->posChangeMode)
+ d->posChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
+ break;
+ case ItemPositionHasChanged:
+ // Move the internal widget if we're in widget-to-proxy
+ // mode. Otherwise the widget has already moved.
+ if (d->widget && d->posChangeMode != QGraphicsProxyWidgetPrivate::WidgetToProxyMode)
+ d->widget->move(value.toPoint());
+ if (d->posChangeMode == QGraphicsProxyWidgetPrivate::ProxyToWidgetMode)
+ d->posChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
+ break;
+ case ItemVisibleChange:
+ if (!d->visibleChangeMode)
+ d->visibleChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
+ break;
+ case ItemVisibleHasChanged:
+ if (d->widget && d->visibleChangeMode != QGraphicsProxyWidgetPrivate::WidgetToProxyMode)
+ d->widget->setVisible(isVisible());
+ if (d->visibleChangeMode == QGraphicsProxyWidgetPrivate::ProxyToWidgetMode)
+ d->visibleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
+ break;
+ case ItemEnabledChange:
+ if (!d->enabledChangeMode)
+ d->enabledChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
+ break;
+ case ItemEnabledHasChanged:
+ if (d->widget && d->enabledChangeMode != QGraphicsProxyWidgetPrivate::WidgetToProxyMode)
+ d->widget->setEnabled(isEnabled());
+ if (d->enabledChangeMode == QGraphicsProxyWidgetPrivate::ProxyToWidgetMode)
+ d->enabledChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
+ break;
+ default:
+ break;
+ }
+ return QGraphicsWidget::itemChange(change, value);
+}
+
+/*!
+ \reimp
+*/
+bool QGraphicsProxyWidget::event(QEvent *event)
+{
+ Q_D(QGraphicsProxyWidget);
+ if (!d->widget)
+ return QGraphicsWidget::event(event);
+
+ switch (event->type()) {
+ case QEvent::StyleChange:
+ // Propagate style changes to the embedded widget.
+ if (!d->styleChangeMode) {
+ d->styleChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
+ d->widget->setStyle(style());
+ d->styleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
+ }
+ break;
+ case QEvent::FontChange: {
+ // Propagate to widget.
+ QWidgetPrivate *wd = d->widget->d_func();
+ int mask = d->font.resolve() | d->inheritedFontResolveMask;
+ wd->inheritedFontResolveMask = mask;
+ wd->resolveFont();
+ break;
+ }
+ case QEvent::PaletteChange: {
+ // Propagate to widget.
+ QWidgetPrivate *wd = d->widget->d_func();
+ int mask = d->palette.resolve() | d->inheritedPaletteResolveMask;
+ wd->inheritedPaletteResolveMask = mask;
+ wd->resolvePalette();
+ break;
+ }
+ case QEvent::InputMethod: {
+ // Forward input method events if the focus widget enables
+ // input methods.
+ // ### Qt 4.5: this code must also go into a reimplementation
+ // of inputMethodEvent().
+ QWidget *focusWidget = d->widget->focusWidget();
+ if (focusWidget && focusWidget->testAttribute(Qt::WA_InputMethodEnabled))
+ QApplication::sendEvent(focusWidget, event);
+ break;
+ }
+ case QEvent::ShortcutOverride: {
+ QWidget *focusWidget = d->widget->focusWidget();
+ while (focusWidget) {
+ QApplication::sendEvent(focusWidget, event);
+ if (event->isAccepted())
+ return true;
+ focusWidget = focusWidget->parentWidget();
+ }
+ return false;
+ }
+ case QEvent::KeyPress: {
+ QKeyEvent *k = static_cast<QKeyEvent *>(event);
+ if (k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) {
+ if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier?
+ QWidget *focusWidget = d->widget->focusWidget();
+ while (focusWidget) {
+ bool res = QApplication::sendEvent(focusWidget, event);
+ if ((res && event->isAccepted()) || (isWindow() && focusWidget == d->widget)) {
+ event->accept();
+ break;
+ }
+ focusWidget = focusWidget->parentWidget();
+ }
+ return true;
+ }
+ }
+ break;
+ }
+#ifndef QT_NO_TOOLTIP
+ case QEvent::GraphicsSceneHelp: {
+ // Propagate the help event (for tooltip) to the widget under mouse
+ if (d->lastWidgetUnderMouse) {
+ QGraphicsSceneHelpEvent *he = static_cast<QGraphicsSceneHelpEvent *>(event);
+ QPoint pos = d->mapToReceiver(mapFromScene(he->scenePos()), d->lastWidgetUnderMouse).toPoint();
+ QHelpEvent e(QEvent::ToolTip, pos, he->screenPos());
+ QApplication::sendEvent(d->lastWidgetUnderMouse, &e);
+ event->setAccepted(e.isAccepted());
+ return e.isAccepted();
+ }
+ break;
+ }
+ case QEvent::ToolTipChange: {
+ // Propagate tooltip change to the widget
+ if (!d->tooltipChangeMode) {
+ d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::ProxyToWidgetMode;
+ d->widget->setToolTip(toolTip());
+ d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
+ }
+ break;
+ }
+#endif
+ default:
+ break;
+ }
+ return QGraphicsWidget::event(event);
+}
+
+/*!
+ \reimp
+*/
+bool QGraphicsProxyWidget::eventFilter(QObject *object, QEvent *event)
+{
+ Q_D(QGraphicsProxyWidget);
+
+ if (object == d->widget) {
+ switch (event->type()) {
+ case QEvent::LayoutRequest:
+ updateGeometry();
+ break;
+ case QEvent::Resize:
+ // If the widget resizes itself, we resize the proxy too.
+ // Prevent feed-back by checking the geometry change mode.
+ if (!d->sizeChangeMode)
+ d->updateProxyGeometryFromWidget();
+ break;
+ case QEvent::Move:
+ // If the widget moves itself, we move the proxy too. Prevent
+ // feed-back by checking the geometry change mode.
+ if (!d->posChangeMode)
+ d->updateProxyGeometryFromWidget();
+ break;
+ case QEvent::Hide:
+ case QEvent::Show:
+ // If the widget toggles its visible state, the proxy will follow.
+ if (!d->visibleChangeMode) {
+ d->visibleChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
+ setVisible(event->type() == QEvent::Show);
+ d->visibleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
+ }
+ break;
+ case QEvent::EnabledChange:
+ // If the widget toggles its enabled state, the proxy will follow.
+ if (!d->enabledChangeMode) {
+ d->enabledChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
+ setEnabled(d->widget->isEnabled());
+ d->enabledChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
+ }
+ break;
+ case QEvent::StyleChange:
+ // Propagate style changes to the proxy.
+ if (!d->styleChangeMode) {
+ d->styleChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
+ setStyle(d->widget->style());
+ d->styleChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
+ }
+ break;
+#ifndef QT_NO_TOOLTIP
+ case QEvent::ToolTipChange:
+ // Propagate tooltip change to the proxy.
+ if (!d->tooltipChangeMode) {
+ d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::WidgetToProxyMode;
+ setToolTip(d->widget->toolTip());
+ d->tooltipChangeMode = QGraphicsProxyWidgetPrivate::NoMode;
+ }
+ break;
+#endif
+ default:
+ break;
+ }
+ }
+ return QGraphicsWidget::eventFilter(object, event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsProxyWidget::showEvent(QShowEvent *event)
+{
+ Q_UNUSED(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsProxyWidget::hideEvent(QHideEvent *event)
+{
+ Q_UNUSED(event);
+}
+
+#ifndef QT_NO_CONTEXTMENU
+/*!
+ \reimp
+*/
+void QGraphicsProxyWidget::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
+{
+ Q_D(QGraphicsProxyWidget);
+ if (!event || !d->widget || !d->widget->isVisible() || !hasFocus())
+ return;
+
+ // Find widget position and receiver.
+ QPointF pos = event->pos();
+ QPointer<QWidget> alienWidget = d->widget->childAt(pos.toPoint());
+ QPointer<QWidget> receiver = alienWidget ? alienWidget : d->widget;
+
+ // Map event position from us to the receiver
+ pos = d->mapToReceiver(pos, receiver);
+
+ QPoint globalPos = receiver->mapToGlobal(pos.toPoint());
+ //If the receiver by-pass the proxy its popups
+ //will be top level QWidgets therefore they need
+ //the screen position. mapToGlobal expect the widget to
+ //have proper coordinates in regards of the windowing system
+ //but it's not true because the widget is embedded.
+ if (bypassGraphicsProxyWidget(receiver))
+ globalPos = event->screenPos();
+
+ // Send mouse event. ### Doesn't propagate the event.
+ QContextMenuEvent contextMenuEvent(QContextMenuEvent::Reason(event->reason()),
+ pos.toPoint(), globalPos, event->modifiers());
+ QApplication::sendEvent(receiver, &contextMenuEvent);
+
+ event->setAccepted(contextMenuEvent.isAccepted());
+}
+#endif // QT_NO_CONTEXTMENU
+
+#ifndef QT_NO_DRAGANDDROP
+/*!
+ \reimp
+*/
+void QGraphicsProxyWidget::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
+{
+#ifdef QT_NO_DRAGANDDROP
+ Q_UNUSED(event);
+#else
+ Q_D(QGraphicsProxyWidget);
+ if (!d->widget)
+ return;
+
+ QDragEnterEvent proxyDragEnter(event->pos().toPoint(), event->dropAction(), event->mimeData(), event->buttons(), event->modifiers());
+ proxyDragEnter.setAccepted(event->isAccepted());
+ QApplication::sendEvent(d->widget, &proxyDragEnter);
+ event->setAccepted(proxyDragEnter.isAccepted());
+ if (proxyDragEnter.isAccepted()) // we discard answerRect
+ event->setDropAction(proxyDragEnter.dropAction());
+#endif
+}
+/*!
+ \reimp
+*/
+void QGraphicsProxyWidget::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
+{
+ Q_UNUSED(event);
+#ifndef QT_NO_DRAGANDDROP
+ Q_D(QGraphicsProxyWidget);
+ if (!d->widget || !d->dragDropWidget)
+ return;
+ QDragLeaveEvent proxyDragLeave;
+ QApplication::sendEvent(d->dragDropWidget, &proxyDragLeave);
+ d->dragDropWidget = 0;
+#endif
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsProxyWidget::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
+{
+#ifdef QT_NO_DRAGANDDROP
+ Q_UNUSED(event);
+#else
+ Q_D(QGraphicsProxyWidget);
+ if (!d->widget)
+ return;
+ QPointF p = event->pos();
+ event->ignore();
+ QPointer<QWidget> subWidget = d->widget->childAt(p.toPoint());
+ QPointer<QWidget> receiver = subWidget ? subWidget : d->widget;
+ bool eventDelivered = false;
+ for (; receiver; receiver = receiver->parentWidget()) {
+ if (!receiver->isEnabled() || !receiver->acceptDrops())
+ continue;
+ // Map event position from us to the receiver
+ QPoint receiverPos = d->mapToReceiver(p, receiver).toPoint();
+ if (receiver != d->dragDropWidget) {
+ // Try to enter before we leave
+ QDragEnterEvent dragEnter(receiverPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers());
+ dragEnter.setDropAction(event->proposedAction());
+ QApplication::sendEvent(receiver, &dragEnter);
+ event->setAccepted(dragEnter.isAccepted());
+ event->setDropAction(dragEnter.dropAction());
+ if (!event->isAccepted()) {
+ // propagate to the parent widget
+ continue;
+ }
+
+ d->lastDropAction = event->dropAction();
+
+ if (d->dragDropWidget) {
+ QDragLeaveEvent dragLeave;
+ QApplication::sendEvent(d->dragDropWidget, &dragLeave);
+ }
+ d->dragDropWidget = receiver;
+ }
+
+ QDragMoveEvent dragMove(receiverPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers());
+ event->setDropAction(d->lastDropAction);
+ QApplication::sendEvent(receiver, &dragMove);
+ event->setAccepted(dragMove.isAccepted());
+ event->setDropAction(dragMove.dropAction());
+ if (event->isAccepted())
+ d->lastDropAction = event->dropAction();
+ eventDelivered = true;
+ break;
+ }
+
+ if (!eventDelivered) {
+ if (d->dragDropWidget) {
+ // Leave the last drag drop item
+ QDragLeaveEvent dragLeave;
+ QApplication::sendEvent(d->dragDropWidget, &dragLeave);
+ d->dragDropWidget = 0;
+ }
+ // Propagate
+ event->setDropAction(Qt::IgnoreAction);
+ }
+#endif
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsProxyWidget::dropEvent(QGraphicsSceneDragDropEvent *event)
+{
+#ifdef QT_NO_DRAGANDDROP
+ Q_UNUSED(event);
+#else
+ Q_D(QGraphicsProxyWidget);
+ if (d->widget && d->dragDropWidget) {
+ QPoint widgetPos = d->mapToReceiver(event->pos(), d->dragDropWidget).toPoint();
+ QDropEvent dropEvent(widgetPos, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers());
+ QApplication::sendEvent(d->dragDropWidget, &dropEvent);
+ event->setAccepted(dropEvent.isAccepted());
+ d->dragDropWidget = 0;
+ }
+#endif
+}
+#endif
+
+/*!
+ \reimp
+*/
+void QGraphicsProxyWidget::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
+{
+ Q_UNUSED(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsProxyWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
+{
+ Q_UNUSED(event);
+ Q_D(QGraphicsProxyWidget);
+ // If hoverMove was compressed away, make sure we update properly here.
+ if (d->lastWidgetUnderMouse) {
+ QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse);
+ d->lastWidgetUnderMouse = 0;
+ }
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsProxyWidget::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
+{
+ Q_D(QGraphicsProxyWidget);
+#ifdef GRAPHICSPROXYWIDGET_DEBUG
+ qDebug() << "QGraphicsProxyWidget::hoverMoveEvent";
+#endif
+ // Ignore events on the window frame.
+ if (!d->widget || !rect().contains(event->pos())) {
+ if (d->lastWidgetUnderMouse) {
+ QApplicationPrivate::dispatchEnterLeave(0, d->lastWidgetUnderMouse);
+ d->lastWidgetUnderMouse = 0;
+ }
+ return;
+ }
+
+ d->embeddedMouseGrabber = 0;
+ d->sendWidgetMouseEvent(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsProxyWidget::grabMouseEvent(QEvent *event)
+{
+ Q_UNUSED(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsProxyWidget::ungrabMouseEvent(QEvent *event)
+{
+ Q_D(QGraphicsProxyWidget);
+ Q_UNUSED(event);
+ d->embeddedMouseGrabber = 0;
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsProxyWidget::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QGraphicsProxyWidget);
+#ifdef GRAPHICSPROXYWIDGET_DEBUG
+ qDebug() << "QGraphicsProxyWidget::mouseMoveEvent";
+#endif
+ d->sendWidgetMouseEvent(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsProxyWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QGraphicsProxyWidget);
+#ifdef GRAPHICSPROXYWIDGET_DEBUG
+ qDebug() << "QGraphicsProxyWidget::mousePressEvent";
+#endif
+ d->sendWidgetMouseEvent(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsProxyWidget::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QGraphicsProxyWidget);
+#ifdef GRAPHICSPROXYWIDGET_DEBUG
+ qDebug() << "QGraphicsProxyWidget::mouseDoubleClickEvent";
+#endif
+ d->sendWidgetMouseEvent(event);
+}
+
+/*!
+ \reimp
+*/
+#ifndef QT_NO_WHEELEVENT
+void QGraphicsProxyWidget::wheelEvent(QGraphicsSceneWheelEvent *event)
+{
+ Q_D(QGraphicsProxyWidget);
+#ifdef GRAPHICSPROXYWIDGET_DEBUG
+ qDebug() << "QGraphicsProxyWidget::wheelEvent";
+#endif
+ if (!d->widget)
+ return;
+
+ QPointF pos = event->pos();
+ QPointer<QWidget> receiver = d->widget->childAt(pos.toPoint());
+ if (!receiver)
+ receiver = d->widget;
+
+ // Map event position from us to the receiver
+ pos = d->mapToReceiver(pos, receiver);
+
+ // Send mouse event.
+ QWheelEvent wheelEvent(pos.toPoint(), event->screenPos(), event->delta(),
+ event->buttons(), event->modifiers(), event->orientation());
+ QPointer<QWidget> focusWidget = d->widget->focusWidget();
+ extern bool qt_sendSpontaneousEvent(QObject *, QEvent *);
+ qt_sendSpontaneousEvent(receiver, &wheelEvent);
+ event->setAccepted(wheelEvent.isAccepted());
+
+ // ### Remove, this should be done by proper focusIn/focusOut events.
+ if (focusWidget && !focusWidget->hasFocus()) {
+ focusWidget->update();
+ focusWidget = d->widget->focusWidget();
+ if (focusWidget && focusWidget->hasFocus())
+ focusWidget->update();
+ }
+}
+#endif
+
+/*!
+ \reimp
+*/
+void QGraphicsProxyWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_D(QGraphicsProxyWidget);
+#ifdef GRAPHICSPROXYWIDGET_DEBUG
+ qDebug() << "QGraphicsProxyWidget::mouseReleaseEvent";
+#endif
+ d->sendWidgetMouseEvent(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsProxyWidget::keyPressEvent(QKeyEvent *event)
+{
+ Q_D(QGraphicsProxyWidget);
+#ifdef GRAPHICSPROXYWIDGET_DEBUG
+ qDebug() << "QGraphicsProxyWidget::keyPressEvent";
+#endif
+ d->sendWidgetKeyEvent(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsProxyWidget::keyReleaseEvent(QKeyEvent *event)
+{
+ Q_D(QGraphicsProxyWidget);
+#ifdef GRAPHICSPROXYWIDGET_DEBUG
+ qDebug() << "QGraphicsProxyWidget::keyReleaseEvent";
+#endif
+ d->sendWidgetKeyEvent(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsProxyWidget::focusInEvent(QFocusEvent *event)
+{
+#ifdef GRAPHICSPROXYWIDGET_DEBUG
+ qDebug() << "QGraphicsProxyWidget::focusInEvent";
+#endif
+ Q_D(QGraphicsProxyWidget);
+
+ if (d->focusFromWidgetToProxy) {
+ // Prevent recursion when the proxy autogains focus through the
+ // embedded widget calling setFocus(). ### Could be done with event
+ // filter on FocusIn instead?
+ return;
+ }
+
+ d->proxyIsGivingFocus = true;
+
+ switch (event->reason()) {
+ case Qt::TabFocusReason: {
+ if (QWidget *focusChild = d->findFocusChild(0, true))
+ focusChild->setFocus(event->reason());
+ break;
+ }
+ case Qt::BacktabFocusReason:
+ if (QWidget *focusChild = d->findFocusChild(0, false))
+ focusChild->setFocus(event->reason());
+ break;
+ default:
+ if (d->widget && d->widget->focusWidget()) {
+ d->widget->focusWidget()->setFocus(event->reason());
+ }
+ break;
+ }
+
+ d->proxyIsGivingFocus = false;
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsProxyWidget::focusOutEvent(QFocusEvent *event)
+{
+#ifdef GRAPHICSPROXYWIDGET_DEBUG
+ qDebug() << "QGraphicsProxyWidget::focusOutEvent";
+#endif
+ Q_D(QGraphicsProxyWidget);
+ if (d->widget) {
+ // We need to explicitly remove subfocus from the embedded widget's
+ // focus widget.
+ if (QWidget *focusWidget = d->widget->focusWidget())
+ d->removeSubFocusHelper(focusWidget, event->reason());
+ }
+}
+
+/*!
+ \reimp
+*/
+bool QGraphicsProxyWidget::focusNextPrevChild(bool next)
+{
+ Q_D(QGraphicsProxyWidget);
+ if (!d->widget || !d->scene)
+ return QGraphicsWidget::focusNextPrevChild(next);
+
+ Qt::FocusReason reason = next ? Qt::TabFocusReason : Qt::BacktabFocusReason;
+ QWidget *lastFocusChild = d->widget->focusWidget();
+ if (QWidget *newFocusChild = d->findFocusChild(lastFocusChild, next)) {
+ newFocusChild->setFocus(reason);
+ return true;
+ }
+
+ return QGraphicsWidget::focusNextPrevChild(next);
+}
+
+/*!
+ \reimp
+*/
+QSizeF QGraphicsProxyWidget::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
+{
+ Q_D(const QGraphicsProxyWidget);
+ if (!d->widget)
+ return QGraphicsWidget::sizeHint(which, constraint);
+
+ QSizeF sh;
+ switch (which) {
+ case Qt::PreferredSize:
+ if (QLayout *l = d->widget->layout())
+ sh = l->sizeHint();
+ else
+ sh = d->widget->sizeHint();
+ break;
+ case Qt::MinimumSize:
+ if (QLayout *l = d->widget->layout())
+ sh = l->minimumSize();
+ else
+ sh = d->widget->minimumSizeHint();
+ break;
+ case Qt::MaximumSize:
+ if (QLayout *l = d->widget->layout())
+ sh = l->maximumSize();
+ else
+ sh = QSizeF(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
+ break;
+ case Qt::MinimumDescent:
+ sh = constraint;
+ break;
+ default:
+ break;
+ }
+ return sh;
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsProxyWidget::resizeEvent(QGraphicsSceneResizeEvent *event)
+{
+ Q_D(QGraphicsProxyWidget);
+ if (d->widget) {
+ if (d->sizeChangeMode != QGraphicsProxyWidgetPrivate::WidgetToProxyMode)
+ d->widget->resize(event->newSize().toSize());
+ }
+ QGraphicsWidget::resizeEvent(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsProxyWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ Q_D(QGraphicsProxyWidget);
+ Q_UNUSED(widget);
+ if (!d->widget || !d->widget->isVisible())
+ return;
+
+ // Filter out repaints on the window frame.
+ const QRect exposedWidgetRect = (option->exposedRect & rect()).toAlignedRect();
+ if (exposedWidgetRect.isEmpty())
+ return;
+
+ // Disable QPainter's default pen being cosmetic. This allows widgets and
+ // styles to follow Qt's existing defaults without getting ugly cosmetic
+ // lines when scaled.
+ bool restore = !(painter->renderHints() & QPainter::NonCosmeticDefaultPen);
+ painter->setRenderHints(QPainter::NonCosmeticDefaultPen, true);
+
+ d->widget->render(painter, exposedWidgetRect.topLeft(), exposedWidgetRect);
+
+ // Restore the render hints if necessary.
+ if (restore)
+ painter->setRenderHints(QPainter::NonCosmeticDefaultPen, false);
+}
+
+/*!
+ \reimp
+*/
+int QGraphicsProxyWidget::type() const
+{
+ return Type;
+}
+
+/*!
+ \since 4.5
+
+ Creates a proxy widget for the given \a child of the widget
+ contained in this proxy.
+
+ This function makes it possible to acquire proxies for
+ non top-level widgets. For instance, you can embed a dialog,
+ and then transform only one of its widgets.
+
+ If the widget is already embedded, return the existing proxy widget.
+
+ \sa newProxyWidget(), QGraphicsScene::addWidget()
+*/
+QGraphicsProxyWidget *QGraphicsProxyWidget::createProxyForChildWidget(QWidget *child)
+{
+ QGraphicsProxyWidget *proxy = child->graphicsProxyWidget();
+ if (proxy)
+ return proxy;
+ if (!child->parentWidget()) {
+ qWarning("QGraphicsProxyWidget::createProxyForChildWidget: top-level widget not in a QGraphicsScene");
+ return 0;
+ }
+
+ QGraphicsProxyWidget *parentProxy = createProxyForChildWidget(child->parentWidget());
+ if (!parentProxy)
+ return 0;
+
+ if (!QMetaObject::invokeMethod(parentProxy, "newProxyWidget", Qt::DirectConnection,
+ Q_RETURN_ARG(QGraphicsProxyWidget*, proxy), Q_ARG(const QWidget*, child)))
+ return 0;
+ proxy->setParent(parentProxy);
+ proxy->setWidget(child);
+ return proxy;
+}
+
+/*!
+ \fn QGraphicsProxyWidget *QGraphicsProxyWidget::newProxyWidget(const QWidget *child)
+ \since 4.5
+
+ Creates a proxy widget for the given \a child of the widget contained in this
+ proxy.
+
+ You should not call this function directly; use
+ QGraphicsProxyWidget::createProxyForChildWidget() instead.
+
+ This function is a fake virtual slot that you can reimplement in
+ your subclass in order to control how new proxy widgets are
+ created. The default implementation returns a proxy created with
+ the QGraphicsProxyWidget() constructor with this proxy widget as
+ the parent.
+
+ \sa createProxyForChildWidget()
+*/
+QGraphicsProxyWidget *QGraphicsProxyWidget::newProxyWidget(const QWidget *)
+{
+ return new QGraphicsProxyWidget(this);
+}
+
+
+
+QT_END_NAMESPACE
+
+#include "moc_qgraphicsproxywidget.cpp"
+
+#endif //QT_NO_GRAPHICSVIEW
diff --git a/src/widgets/graphicsview/qgraphicsproxywidget.h b/src/widgets/graphicsview/qgraphicsproxywidget.h
new file mode 100644
index 0000000000..289c1e07f0
--- /dev/null
+++ b/src/widgets/graphicsview/qgraphicsproxywidget.h
@@ -0,0 +1,147 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGRAPHICSPROXYWIDGET_H
+#define QGRAPHICSPROXYWIDGET_H
+
+#include <QtWidgets/qgraphicswidget.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
+
+class QGraphicsProxyWidgetPrivate;
+
+class Q_GUI_EXPORT QGraphicsProxyWidget : public QGraphicsWidget
+{
+ Q_OBJECT
+public:
+ QGraphicsProxyWidget(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
+ ~QGraphicsProxyWidget();
+
+ void setWidget(QWidget *widget);
+ QWidget *widget() const;
+
+ QRectF subWidgetRect(const QWidget *widget) const;
+
+ void setGeometry(const QRectF &rect);
+
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
+
+ enum {
+ Type = 12
+ };
+ int type() const;
+
+ QGraphicsProxyWidget *createProxyForChildWidget(QWidget *child);
+
+protected:
+ QVariant itemChange(GraphicsItemChange change, const QVariant &value);
+
+ bool event(QEvent *event);
+ bool eventFilter(QObject *object, QEvent *event);
+
+ void showEvent(QShowEvent *event);
+ void hideEvent(QHideEvent *event);
+
+#ifndef QT_NO_CONTEXTMENU
+ void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
+#endif
+
+#ifndef QT_NO_DRAGANDDROP
+ void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
+ void dragLeaveEvent(QGraphicsSceneDragDropEvent *event);
+ void dragMoveEvent(QGraphicsSceneDragDropEvent *event);
+ void dropEvent(QGraphicsSceneDragDropEvent *event);
+#endif
+
+ void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
+ void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
+ void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
+ void grabMouseEvent(QEvent *event);
+ void ungrabMouseEvent(QEvent *event);
+
+ void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
+ void mousePressEvent(QGraphicsSceneMouseEvent *event);
+ void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+ void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
+#ifndef QT_NO_WHEELEVENT
+ void wheelEvent(QGraphicsSceneWheelEvent *event);
+#endif
+
+ void keyPressEvent(QKeyEvent *event);
+ void keyReleaseEvent(QKeyEvent *event);
+
+ void focusInEvent(QFocusEvent *event);
+ void focusOutEvent(QFocusEvent *event);
+ bool focusNextPrevChild(bool next);
+ // ### Qt 4.5:
+ // QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
+ // void inputMethodEvent(QInputMethodEvent *event);
+
+ QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
+ void resizeEvent(QGraphicsSceneResizeEvent *event);
+
+protected Q_SLOTS:
+ QGraphicsProxyWidget *newProxyWidget(const QWidget *);
+
+private:
+ Q_DISABLE_COPY(QGraphicsProxyWidget)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QGraphicsProxyWidget)
+ Q_PRIVATE_SLOT(d_func(), void _q_removeWidgetSlot())
+
+ friend class QWidget;
+ friend class QWidgetPrivate;
+ friend class QGraphicsItem;
+};
+
+#endif
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
+
diff --git a/src/gui/graphicsview/qgraphicsproxywidget_p.h b/src/widgets/graphicsview/qgraphicsproxywidget_p.h
index e1a96b0021..e1a96b0021 100644
--- a/src/gui/graphicsview/qgraphicsproxywidget_p.h
+++ b/src/widgets/graphicsview/qgraphicsproxywidget_p.h
diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp
new file mode 100644
index 0000000000..8403dfb1fb
--- /dev/null
+++ b/src/widgets/graphicsview/qgraphicsscene.cpp
@@ -0,0 +1,6502 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \class QGraphicsScene
+ \brief The QGraphicsScene class provides a surface for managing a large
+ number of 2D graphical items.
+ \since 4.2
+ \ingroup graphicsview-api
+
+
+ The class serves as a container for QGraphicsItems. It is used together
+ with QGraphicsView for visualizing graphical items, such as lines,
+ rectangles, text, or even custom items, on a 2D surface. QGraphicsScene is
+ part of the \l{Graphics View Framework}.
+
+ QGraphicsScene also provides functionality that lets you efficiently
+ determine both the location of items, and for determining what items are
+ visible within an arbitrary area on the scene. With the QGraphicsView
+ widget, you can either visualize the whole scene, or zoom in and view only
+ parts of the scene.
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp 0
+
+ Note that QGraphicsScene has no visual appearance of its own; it only
+ manages the items. You need to create a QGraphicsView widget to visualize
+ the scene.
+
+ To add items to a scene, you start off by constructing a QGraphicsScene
+ object. Then, you have two options: either add your existing QGraphicsItem
+ objects by calling addItem(), or you can call one of the convenience
+ functions addEllipse(), addLine(), addPath(), addPixmap(), addPolygon(),
+ addRect(), or addText(), which all return a pointer to the newly added item.
+ The dimensions of the items added with these functions are relative to the
+ item's coordinate system, and the items position is initialized to (0,
+ 0) in the scene.
+
+ You can then visualize the scene using QGraphicsView. When the scene
+ changes, (e.g., when an item moves or is transformed) QGraphicsScene
+ emits the changed() signal. To remove an item, call removeItem().
+
+ QGraphicsScene uses an indexing algorithm to manage the location of items
+ efficiently. By default, a BSP (Binary Space Partitioning) tree is used; an
+ algorithm suitable for large scenes where most items remain static (i.e.,
+ do not move around). You can choose to disable this index by calling
+ setItemIndexMethod(). For more information about the available indexing
+ algorithms, see the itemIndexMethod property.
+
+ The scene's bounding rect is set by calling setSceneRect(). Items can be
+ placed at any position on the scene, and the size of the scene is by
+ default unlimited. The scene rect is used only for internal bookkeeping,
+ maintaining the scene's item index. If the scene rect is unset,
+ QGraphicsScene will use the bounding area of all items, as returned by
+ itemsBoundingRect(), as the scene rect. However, itemsBoundingRect() is a
+ relatively time consuming function, as it operates by collecting
+ positional information for every item on the scene. Because of this, you
+ should always set the scene rect when operating on large scenes.
+
+ One of QGraphicsScene's greatest strengths is its ability to efficiently
+ determine the location of items. Even with millions of items on the scene,
+ the items() functions can determine the location of an item within few
+ milliseconds. There are several overloads to items(): one that finds items
+ at a certain position, one that finds items inside or intersecting with a
+ polygon or a rectangle, and more. The list of returned items is sorted by
+ stacking order, with the topmost item being the first item in the list.
+ For convenience, there is also an itemAt() function that returns the
+ topmost item at a given position.
+
+ QGraphicsScene maintains selection information for the scene. To select
+ items, call setSelectionArea(), and to clear the current selection, call
+ clearSelection(). Call selectedItems() to get the list of all selected
+ items.
+
+ \section1 Event Handling and Propagation
+
+ Another responsibility that QGraphicsScene has, is to propagate events
+ from QGraphicsView. To send an event to a scene, you construct an event
+ that inherits QEvent, and then send it using, for example,
+ QApplication::sendEvent(). event() is responsible for dispatching
+ the event to the individual items. Some common events are handled by
+ convenience event handlers. For example, key press events are handled by
+ keyPressEvent(), and mouse press events are handled by mousePressEvent().
+
+ Key events are delivered to the \e {focus item}. To set the focus item,
+ you can either call setFocusItem(), passing an item that accepts focus, or
+ the item itself can call QGraphicsItem::setFocus(). Call focusItem() to
+ get the current focus item. For compatibility with widgets, the scene also
+ maintains its own focus information. By default, the scene does not have
+ focus, and all key events are discarded. If setFocus() is called, or if an
+ item on the scene gains focus, the scene automatically gains focus. If the
+ scene has focus, hasFocus() will return true, and key events will be
+ forwarded to the focus item, if any. If the scene loses focus, (i.e.,
+ someone calls clearFocus()) while an item has focus, the scene will
+ maintain its item focus information, and once the scene regains focus, it
+ will make sure the last focus item regains focus.
+
+ For mouse-over effects, QGraphicsScene dispatches \e {hover
+ events}. If an item accepts hover events (see
+ QGraphicsItem::acceptHoverEvents()), it will receive a \l
+ {QEvent::}{GraphicsSceneHoverEnter} event when the mouse enters
+ its area. As the mouse continues moving inside the item's area,
+ QGraphicsScene will send it \l {QEvent::}{GraphicsSceneHoverMove}
+ events. When the mouse leaves the item's area, the item will
+ receive a \l {QEvent::}{GraphicsSceneHoverLeave} event.
+
+ All mouse events are delivered to the current \e {mouse grabber}
+ item. An item becomes the scene's mouse grabber if it accepts
+ mouse events (see QGraphicsItem::acceptedMouseButtons()) and it
+ receives a mouse press. It stays the mouse grabber until it
+ receives a mouse release when no other mouse buttons are
+ pressed. You can call mouseGrabberItem() to determine what item is
+ currently grabbing the mouse.
+
+ \sa QGraphicsItem, QGraphicsView
+*/
+
+/*!
+ \enum QGraphicsScene::SceneLayer
+ \since 4.3
+
+ This enum describes the rendering layers in a QGraphicsScene. When
+ QGraphicsScene draws the scene contents, it renders each of these layers
+ separately, in order.
+
+ Each layer represents a flag that can be OR'ed together when calling
+ functions such as invalidate() or QGraphicsView::invalidateScene().
+
+ \value ItemLayer The item layer. QGraphicsScene renders all items are in
+ this layer by calling the virtual function drawItems(). The item layer is
+ drawn after the background layer, but before the foreground layer.
+
+ \value BackgroundLayer The background layer. QGraphicsScene renders the
+ scene's background in this layer by calling the virtual function
+ drawBackground(). The background layer is drawn first of all layers.
+
+ \value ForegroundLayer The foreground layer. QGraphicsScene renders the
+ scene's foreground in this layer by calling the virtual function
+ drawForeground(). The foreground layer is drawn last of all layers.
+
+ \value AllLayers All layers; this value represents a combination of all
+ three layers.
+
+ \sa invalidate(), QGraphicsView::invalidateScene()
+*/
+
+/*!
+ \enum QGraphicsScene::ItemIndexMethod
+
+ This enum describes the indexing algorithms QGraphicsScene provides for
+ managing positional information about items on the scene.
+
+ \value BspTreeIndex A Binary Space Partitioning tree is applied. All
+ QGraphicsScene's item location algorithms are of an order close to
+ logarithmic complexity, by making use of binary search. Adding, moving and
+ removing items is logarithmic. This approach is best for static scenes
+ (i.e., scenes where most items do not move).
+
+ \value NoIndex No index is applied. Item location is of linear complexity,
+ as all items on the scene are searched. Adding, moving and removing items,
+ however, is done in constant time. This approach is ideal for dynamic
+ scenes, where many items are added, moved or removed continuously.
+
+ \sa setItemIndexMethod(), bspTreeDepth
+*/
+
+#include "qgraphicsscene.h"
+
+#ifndef QT_NO_GRAPHICSVIEW
+
+#include "qgraphicsitem.h"
+#include "qgraphicsitem_p.h"
+#include "qgraphicslayout.h"
+#include "qgraphicsscene_p.h"
+#include "qgraphicssceneevent.h"
+#include "qgraphicsview.h"
+#include "qgraphicsview_p.h"
+#include "qgraphicswidget.h"
+#include "qgraphicswidget_p.h"
+#include "qgraphicssceneindex_p.h"
+#include "qgraphicsscenebsptreeindex_p.h"
+#include "qgraphicsscenelinearindex_p.h"
+
+#include <QtCore/qdebug.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qmath.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qset.h>
+#include <QtCore/qstack.h>
+#include <QtCore/qtimer.h>
+#include <QtCore/qvarlengtharray.h>
+#include <QtCore/QMetaMethod>
+#include <QtWidgets/qapplication.h>
+#include <QtWidgets/qdesktopwidget.h>
+#include <QtGui/qevent.h>
+#include <QtWidgets/qgraphicslayout.h>
+#include <QtWidgets/qgraphicsproxywidget.h>
+#include <QtWidgets/qgraphicswidget.h>
+#include <QtGui/qmatrix.h>
+#include <QtGui/qpaintengine.h>
+#include <QtGui/qpainter.h>
+#include <QtGui/qpixmapcache.h>
+#include <QtGui/qpolygon.h>
+#include <QtWidgets/qstyleoption.h>
+#include <QtWidgets/qtooltip.h>
+#include <QtGui/qtransform.h>
+#include <QtWidgets/qinputcontext.h>
+#include <QtWidgets/qgraphicseffect.h>
+#ifndef QT_NO_ACCESSIBILITY
+# include <QtWidgets/qaccessible.h>
+#endif
+#include <private/qapplication_p.h>
+#include <private/qobject_p.h>
+#ifdef Q_WS_X11
+#include <private/qt_x11_p.h>
+#endif
+#include <private/qgraphicseffect_p.h>
+#include <private/qgesturemanager_p.h>
+#include <private/qpathclipper_p.h>
+
+// #define GESTURE_DEBUG
+#ifndef GESTURE_DEBUG
+# define DEBUG if (0) qDebug
+#else
+# define DEBUG qDebug
+#endif
+
+QT_BEGIN_NAMESPACE
+
+bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event);
+
+static void _q_hoverFromMouseEvent(QGraphicsSceneHoverEvent *hover, const QGraphicsSceneMouseEvent *mouseEvent)
+{
+ hover->setWidget(mouseEvent->widget());
+ hover->setPos(mouseEvent->pos());
+ hover->setScenePos(mouseEvent->scenePos());
+ hover->setScreenPos(mouseEvent->screenPos());
+ hover->setLastPos(mouseEvent->lastPos());
+ hover->setLastScenePos(mouseEvent->lastScenePos());
+ hover->setLastScreenPos(mouseEvent->lastScreenPos());
+ hover->setModifiers(mouseEvent->modifiers());
+ hover->setAccepted(mouseEvent->isAccepted());
+}
+
+/*!
+ \internal
+*/
+QGraphicsScenePrivate::QGraphicsScenePrivate()
+ : indexMethod(QGraphicsScene::BspTreeIndex),
+ index(0),
+ lastItemCount(0),
+ hasSceneRect(false),
+ dirtyGrowingItemsBoundingRect(true),
+ updateAll(false),
+ calledEmitUpdated(false),
+ processDirtyItemsEmitted(false),
+ needSortTopLevelItems(true),
+ holesInTopLevelSiblingIndex(false),
+ topLevelSequentialOrdering(true),
+ scenePosDescendantsUpdatePending(false),
+ stickyFocus(false),
+ hasFocus(false),
+ lastMouseGrabberItemHasImplicitMouseGrab(false),
+ allItemsIgnoreHoverEvents(true),
+ allItemsUseDefaultCursor(true),
+ painterStateProtection(true),
+ sortCacheEnabled(false),
+ allItemsIgnoreTouchEvents(true),
+ selectionChanging(0),
+ rectAdjust(2),
+ focusItem(0),
+ lastFocusItem(0),
+ passiveFocusItem(0),
+ tabFocusFirst(0),
+ activePanel(0),
+ lastActivePanel(0),
+ activationRefCount(0),
+ childExplicitActivation(0),
+ lastMouseGrabberItem(0),
+ dragDropItem(0),
+ enterWidget(0),
+ lastDropAction(Qt::IgnoreAction),
+ style(0)
+{
+}
+
+/*!
+ \internal
+*/
+void QGraphicsScenePrivate::init()
+{
+ Q_Q(QGraphicsScene);
+
+ index = new QGraphicsSceneBspTreeIndex(q);
+
+ // Keep this index so we can check for connected slots later on.
+ changedSignalIndex = signalIndex("changed(QList<QRectF>)");
+ processDirtyItemsIndex = q->metaObject()->indexOfSlot("_q_processDirtyItems()");
+ polishItemsIndex = q->metaObject()->indexOfSlot("_q_polishItems()");
+
+ qApp->d_func()->scene_list.append(q);
+ q->update();
+}
+
+/*!
+ \internal
+*/
+QGraphicsScenePrivate *QGraphicsScenePrivate::get(QGraphicsScene *q)
+{
+ return q->d_func();
+}
+
+void QGraphicsScenePrivate::_q_emitUpdated()
+{
+ Q_Q(QGraphicsScene);
+ calledEmitUpdated = false;
+
+ if (dirtyGrowingItemsBoundingRect) {
+ if (!hasSceneRect) {
+ const QRectF oldGrowingItemsBoundingRect = growingItemsBoundingRect;
+ growingItemsBoundingRect |= q->itemsBoundingRect();
+ if (oldGrowingItemsBoundingRect != growingItemsBoundingRect)
+ emit q->sceneRectChanged(growingItemsBoundingRect);
+ }
+ dirtyGrowingItemsBoundingRect = false;
+ }
+
+ // Ensure all views are connected if anything is connected. This disables
+ // the optimization that items send updates directly to the views, but it
+ // needs to happen in order to keep compatibility with the behavior from
+ // Qt 4.4 and backward.
+ if (isSignalConnected(changedSignalIndex)) {
+ for (int i = 0; i < views.size(); ++i) {
+ QGraphicsView *view = views.at(i);
+ if (!view->d_func()->connectedToScene) {
+ view->d_func()->connectedToScene = true;
+ q->connect(q, SIGNAL(changed(QList<QRectF>)),
+ views.at(i), SLOT(updateScene(QList<QRectF>)));
+ }
+ }
+ } else {
+ if (views.isEmpty()) {
+ updateAll = false;
+ return;
+ }
+ for (int i = 0; i < views.size(); ++i)
+ views.at(i)->d_func()->processPendingUpdates();
+ // It's important that we update all views before we dispatch, hence two for-loops.
+ for (int i = 0; i < views.size(); ++i)
+ views.at(i)->d_func()->dispatchPendingUpdateRequests();
+ return;
+ }
+
+ // Notify the changes to anybody interested.
+ QList<QRectF> oldUpdatedRects;
+ oldUpdatedRects = updateAll ? (QList<QRectF>() << q->sceneRect()) : updatedRects;
+ updateAll = false;
+ updatedRects.clear();
+ emit q->changed(oldUpdatedRects);
+}
+
+/*!
+ \internal
+
+ ### This function is almost identical to QGraphicsItemPrivate::addChild().
+*/
+void QGraphicsScenePrivate::registerTopLevelItem(QGraphicsItem *item)
+{
+ item->d_ptr->ensureSequentialSiblingIndex();
+ needSortTopLevelItems = true; // ### maybe false
+ item->d_ptr->siblingIndex = topLevelItems.size();
+ topLevelItems.append(item);
+}
+
+/*!
+ \internal
+
+ ### This function is almost identical to QGraphicsItemPrivate::removeChild().
+*/
+void QGraphicsScenePrivate::unregisterTopLevelItem(QGraphicsItem *item)
+{
+ if (!holesInTopLevelSiblingIndex)
+ holesInTopLevelSiblingIndex = item->d_ptr->siblingIndex != topLevelItems.size() - 1;
+ if (topLevelSequentialOrdering && !holesInTopLevelSiblingIndex)
+ topLevelItems.removeAt(item->d_ptr->siblingIndex);
+ else
+ topLevelItems.removeOne(item);
+ // NB! Do not use topLevelItems.removeAt(item->d_ptr->siblingIndex) because
+ // the item is not guaranteed to be at the index after the list is sorted
+ // (see ensureSortedTopLevelItems()).
+ item->d_ptr->siblingIndex = -1;
+ if (topLevelSequentialOrdering)
+ topLevelSequentialOrdering = !holesInTopLevelSiblingIndex;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsScenePrivate::_q_polishItems()
+{
+ if (unpolishedItems.isEmpty())
+ return;
+
+ const QVariant booleanTrueVariant(true);
+ QGraphicsItem *item = 0;
+ QGraphicsItemPrivate *itemd = 0;
+ const int oldUnpolishedCount = unpolishedItems.count();
+
+ for (int i = 0; i < oldUnpolishedCount; ++i) {
+ item = unpolishedItems.at(i);
+ if (!item)
+ continue;
+ itemd = item->d_ptr.data();
+ itemd->pendingPolish = false;
+ if (!itemd->explicitlyHidden) {
+ item->itemChange(QGraphicsItem::ItemVisibleChange, booleanTrueVariant);
+ item->itemChange(QGraphicsItem::ItemVisibleHasChanged, booleanTrueVariant);
+ }
+ if (itemd->isWidget) {
+ QEvent event(QEvent::Polish);
+ QApplication::sendEvent((QGraphicsWidget *)item, &event);
+ }
+ }
+
+ if (unpolishedItems.count() == oldUnpolishedCount) {
+ // No new items were added to the vector.
+ unpolishedItems.clear();
+ } else {
+ // New items were appended; keep them and remove the old ones.
+ unpolishedItems.remove(0, oldUnpolishedCount);
+ unpolishedItems.squeeze();
+ QMetaObject::invokeMethod(q_ptr, "_q_polishItems", Qt::QueuedConnection);
+ }
+}
+
+void QGraphicsScenePrivate::_q_processDirtyItems()
+{
+ processDirtyItemsEmitted = false;
+
+ if (updateAll) {
+ Q_ASSERT(calledEmitUpdated);
+ // No need for further processing (except resetting the dirty states).
+ // The growingItemsBoundingRect is updated in _q_emitUpdated.
+ for (int i = 0; i < topLevelItems.size(); ++i)
+ resetDirtyItem(topLevelItems.at(i), /*recursive=*/true);
+ return;
+ }
+
+ const bool wasPendingSceneUpdate = calledEmitUpdated;
+ const QRectF oldGrowingItemsBoundingRect = growingItemsBoundingRect;
+
+ // Process items recursively.
+ for (int i = 0; i < topLevelItems.size(); ++i)
+ processDirtyItemsRecursive(topLevelItems.at(i));
+
+ dirtyGrowingItemsBoundingRect = false;
+ if (!hasSceneRect && oldGrowingItemsBoundingRect != growingItemsBoundingRect)
+ emit q_func()->sceneRectChanged(growingItemsBoundingRect);
+
+ if (wasPendingSceneUpdate)
+ return;
+
+ for (int i = 0; i < views.size(); ++i)
+ views.at(i)->d_func()->processPendingUpdates();
+
+ if (calledEmitUpdated) {
+ // We did a compatibility QGraphicsScene::update in processDirtyItemsRecursive
+ // and we cannot wait for the control to reach the eventloop before the
+ // changed signal is emitted, so we emit it now.
+ _q_emitUpdated();
+ }
+
+ // Immediately dispatch all pending update requests on the views.
+ for (int i = 0; i < views.size(); ++i)
+ views.at(i)->d_func()->dispatchPendingUpdateRequests();
+}
+
+/*!
+ \internal
+*/
+void QGraphicsScenePrivate::setScenePosItemEnabled(QGraphicsItem *item, bool enabled)
+{
+ QGraphicsItem *p = item->d_ptr->parent;
+ while (p) {
+ p->d_ptr->scenePosDescendants = enabled;
+ p = p->d_ptr->parent;
+ }
+ if (!enabled && !scenePosDescendantsUpdatePending) {
+ scenePosDescendantsUpdatePending = true;
+ QMetaObject::invokeMethod(q_func(), "_q_updateScenePosDescendants", Qt::QueuedConnection);
+ }
+}
+
+/*!
+ \internal
+*/
+void QGraphicsScenePrivate::registerScenePosItem(QGraphicsItem *item)
+{
+ scenePosItems.insert(item);
+ setScenePosItemEnabled(item, true);
+}
+
+/*!
+ \internal
+*/
+void QGraphicsScenePrivate::unregisterScenePosItem(QGraphicsItem *item)
+{
+ scenePosItems.remove(item);
+ setScenePosItemEnabled(item, false);
+}
+
+/*!
+ \internal
+*/
+void QGraphicsScenePrivate::_q_updateScenePosDescendants()
+{
+ foreach (QGraphicsItem *item, scenePosItems) {
+ QGraphicsItem *p = item->d_ptr->parent;
+ while (p) {
+ p->d_ptr->scenePosDescendants = 1;
+ p = p->d_ptr->parent;
+ }
+ }
+ scenePosDescendantsUpdatePending = false;
+}
+
+/*!
+ \internal
+
+ Schedules an item for removal. This function leaves some stale indexes
+ around in the BSP tree if called from the item's destructor; these will
+ be cleaned up the next time someone triggers purgeRemovedItems().
+
+ Note: This function might get called from QGraphicsItem's destructor. \a item is
+ being destroyed, so we cannot call any pure virtual functions on it (such
+ as boundingRect()). Also, it is unnecessary to update the item's own state
+ in any way.
+*/
+void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item)
+{
+ Q_Q(QGraphicsScene);
+
+ // Clear focus on the item to remove any reference in the focusWidget chain.
+ item->clearFocus();
+
+ markDirty(item, QRectF(), /*invalidateChildren=*/false, /*force=*/false,
+ /*ignoreOpacity=*/false, /*removingItemFromScene=*/true);
+
+ if (item->d_ptr->inDestructor) {
+ // The item is actually in its destructor, we call the special method in the index.
+ index->deleteItem(item);
+ } else {
+ // Can potentially call item->boundingRect() (virtual function), that's why
+ // we only can call this function if the item is not in its destructor.
+ index->removeItem(item);
+ }
+
+ item->d_ptr->clearSubFocus();
+
+ if (item->flags() & QGraphicsItem::ItemSendsScenePositionChanges)
+ unregisterScenePosItem(item);
+
+ QGraphicsScene *oldScene = item->d_func()->scene;
+ item->d_func()->scene = 0;
+
+ //We need to remove all children first because they might use their parent
+ //attributes (e.g. sceneTransform).
+ if (!item->d_ptr->inDestructor) {
+ // Remove all children recursively
+ for (int i = 0; i < item->d_ptr->children.size(); ++i)
+ q->removeItem(item->d_ptr->children.at(i));
+ }
+
+ if (!item->d_ptr->inDestructor && item == tabFocusFirst) {
+ QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
+ widget->d_func()->fixFocusChainBeforeReparenting(0, oldScene, 0);
+ }
+
+ // Unregister focus proxy.
+ item->d_ptr->resetFocusProxy();
+
+ // Remove from parent, or unregister from toplevels.
+ if (QGraphicsItem *parentItem = item->parentItem()) {
+ if (parentItem->scene()) {
+ Q_ASSERT_X(parentItem->scene() == q, "QGraphicsScene::removeItem",
+ "Parent item's scene is different from this item's scene");
+ item->setParentItem(0);
+ }
+ } else {
+ unregisterTopLevelItem(item);
+ }
+
+ // Reset the mouse grabber and focus item data.
+ if (item == focusItem)
+ focusItem = 0;
+ if (item == lastFocusItem)
+ lastFocusItem = 0;
+ if (item == passiveFocusItem)
+ passiveFocusItem = 0;
+ if (item == activePanel) {
+ // ### deactivate...
+ activePanel = 0;
+ }
+ if (item == lastActivePanel)
+ lastActivePanel = 0;
+
+ // Cancel active touches
+ {
+ QMap<int, QGraphicsItem *>::iterator it = itemForTouchPointId.begin();
+ while (it != itemForTouchPointId.end()) {
+ if (it.value() == item) {
+ sceneCurrentTouchPoints.remove(it.key());
+ it = itemForTouchPointId.erase(it);
+ } else {
+ ++it;
+ }
+ }
+ }
+
+ // Disable selectionChanged() for individual items
+ ++selectionChanging;
+ int oldSelectedItemsSize = selectedItems.size();
+
+ // Update selected & hovered item bookkeeping
+ selectedItems.remove(item);
+ hoverItems.removeAll(item);
+ cachedItemsUnderMouse.removeAll(item);
+ if (item->d_ptr->pendingPolish) {
+ const int unpolishedIndex = unpolishedItems.indexOf(item);
+ if (unpolishedIndex != -1)
+ unpolishedItems[unpolishedIndex] = 0;
+ item->d_ptr->pendingPolish = false;
+ }
+ resetDirtyItem(item);
+
+ //We remove all references of item from the sceneEventFilter arrays
+ QMultiMap<QGraphicsItem*, QGraphicsItem*>::iterator iterator = sceneEventFilters.begin();
+ while (iterator != sceneEventFilters.end()) {
+ if (iterator.value() == item || iterator.key() == item)
+ iterator = sceneEventFilters.erase(iterator);
+ else
+ ++iterator;
+ }
+
+ if (item->isPanel() && item->isVisible() && item->panelModality() != QGraphicsItem::NonModal)
+ leaveModal(item);
+
+ // Reset the mouse grabber and focus item data.
+ if (mouseGrabberItems.contains(item))
+ ungrabMouse(item, /* item is dying */ item->d_ptr->inDestructor);
+
+ // Reset the keyboard grabber
+ if (keyboardGrabberItems.contains(item))
+ ungrabKeyboard(item, /* item is dying */ item->d_ptr->inDestructor);
+
+ // Reset the last mouse grabber item
+ if (item == lastMouseGrabberItem)
+ lastMouseGrabberItem = 0;
+
+ // Reset the current drop item
+ if (item == dragDropItem)
+ dragDropItem = 0;
+
+ // Reenable selectionChanged() for individual items
+ --selectionChanging;
+ if (!selectionChanging && selectedItems.size() != oldSelectedItemsSize)
+ emit q->selectionChanged();
+
+#ifndef QT_NO_GESTURES
+ QHash<QGesture *, QGraphicsObject *>::iterator it;
+ for (it = gestureTargets.begin(); it != gestureTargets.end();) {
+ if (it.value() == item)
+ it = gestureTargets.erase(it);
+ else
+ ++it;
+ }
+
+ QGraphicsObject *dummy = static_cast<QGraphicsObject *>(item);
+ cachedTargetItems.removeOne(dummy);
+ cachedItemGestures.remove(dummy);
+ cachedAlreadyDeliveredGestures.remove(dummy);
+
+ foreach (Qt::GestureType gesture, item->d_ptr->gestureContext.keys())
+ ungrabGesture(item, gesture);
+#endif // QT_NO_GESTURES
+}
+
+/*!
+ \internal
+*/
+void QGraphicsScenePrivate::setActivePanelHelper(QGraphicsItem *item, bool duringActivationEvent)
+{
+ Q_Q(QGraphicsScene);
+ if (item && item->scene() != q) {
+ qWarning("QGraphicsScene::setActivePanel: item %p must be part of this scene",
+ item);
+ return;
+ }
+
+ // Ensure the scene has focus when we change panel activation.
+ q->setFocus(Qt::ActiveWindowFocusReason);
+
+ // Find the item's panel.
+ QGraphicsItem *panel = item ? item->panel() : 0;
+ lastActivePanel = panel ? activePanel : 0;
+ if (panel == activePanel || (!q->isActive() && !duringActivationEvent))
+ return;
+
+ // Deactivate the last active panel.
+ if (activePanel) {
+ if (QGraphicsItem *fi = activePanel->focusItem()) {
+ // Remove focus from the current focus item.
+ if (fi == q->focusItem())
+ q->setFocusItem(0, Qt::ActiveWindowFocusReason);
+ }
+
+ QEvent event(QEvent::WindowDeactivate);
+ q->sendEvent(activePanel, &event);
+ } else if (panel && !duringActivationEvent) {
+ // Deactivate the scene if changing activation to a panel.
+ QEvent event(QEvent::WindowDeactivate);
+ foreach (QGraphicsItem *item, q->items()) {
+ if (item->isVisible() && !item->isPanel() && !item->parentItem())
+ q->sendEvent(item, &event);
+ }
+ }
+
+ // Update activate state.
+ activePanel = panel;
+ QEvent event(QEvent::ActivationChange);
+ QApplication::sendEvent(q, &event);
+
+ // Activate
+ if (panel) {
+ QEvent event(QEvent::WindowActivate);
+ q->sendEvent(panel, &event);
+
+ // Set focus on the panel's focus item.
+ if (QGraphicsItem *focusItem = panel->focusItem())
+ focusItem->setFocus(Qt::ActiveWindowFocusReason);
+ } else if (q->isActive()) {
+ // Activate the scene
+ QEvent event(QEvent::WindowActivate);
+ foreach (QGraphicsItem *item, q->items()) {
+ if (item->isVisible() && !item->isPanel() && !item->parentItem())
+ q->sendEvent(item, &event);
+ }
+ }
+}
+
+/*!
+ \internal
+*/
+void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item,
+ Qt::FocusReason focusReason)
+{
+ Q_Q(QGraphicsScene);
+ if (item == focusItem)
+ return;
+
+ // Clear focus if asked to set focus on something that can't
+ // accept input focus.
+ if (item && (!(item->flags() & QGraphicsItem::ItemIsFocusable)
+ || !item->isVisible() || !item->isEnabled())) {
+ item = 0;
+ }
+
+ // Set focus on the scene if an item requests focus.
+ if (item) {
+ q->setFocus(focusReason);
+ if (item == focusItem)
+ return;
+ }
+
+ if (focusItem) {
+ lastFocusItem = focusItem;
+
+#ifndef QT_NO_IM
+ if (lastFocusItem
+ && (lastFocusItem->flags() & QGraphicsItem::ItemAcceptsInputMethod)) {
+ // Close any external input method panel. This happens
+ // automatically by removing WA_InputMethodEnabled on
+ // the views, but if we are changing focus, we have to
+ // do it ourselves.
+ for (int i = 0; i < views.size(); ++i)
+ if (views.at(i)->inputContext())
+ views.at(i)->inputContext()->reset();
+ }
+
+ focusItem = 0;
+ QFocusEvent event(QEvent::FocusOut, focusReason);
+ sendEvent(lastFocusItem, &event);
+#endif //QT_NO_IM
+ }
+
+ // This handles the case that the item has been removed from the
+ // scene in response to the FocusOut event.
+ if (item && item->scene() != q)
+ item = 0;
+
+ if (item)
+ focusItem = item;
+ updateInputMethodSensitivityInViews();
+
+#ifndef QT_NO_ACCESSIBILITY
+ if (focusItem) {
+ if (QGraphicsObject *focusObj = focusItem->toGraphicsObject()) {
+ QAccessible::updateAccessibility(focusObj, 0, QAccessible::Focus);
+ }
+ }
+#endif
+ if (item) {
+ QFocusEvent event(QEvent::FocusIn, focusReason);
+ sendEvent(item, &event);
+ }
+}
+
+/*!
+ \internal
+*/
+void QGraphicsScenePrivate::addPopup(QGraphicsWidget *widget)
+{
+ Q_ASSERT(widget);
+ Q_ASSERT(!popupWidgets.contains(widget));
+ popupWidgets << widget;
+ if (QGraphicsWidget *focusWidget = widget->focusWidget()) {
+ focusWidget->setFocus(Qt::PopupFocusReason);
+ } else {
+ grabKeyboard((QGraphicsItem *)widget);
+ if (focusItem && popupWidgets.size() == 1) {
+ QFocusEvent event(QEvent::FocusOut, Qt::PopupFocusReason);
+ sendEvent(focusItem, &event);
+ }
+ }
+ grabMouse((QGraphicsItem *)widget);
+}
+
+/*!
+ \internal
+
+ Remove \a widget from the popup list. Important notes:
+
+ \a widget is guaranteed to be in the list of popups, but it might not be
+ the last entry; you can hide any item in the pop list before the others,
+ and this must cause all later mouse grabbers to lose the grab.
+*/
+void QGraphicsScenePrivate::removePopup(QGraphicsWidget *widget, bool itemIsDying)
+{
+ Q_ASSERT(widget);
+ int index = popupWidgets.indexOf(widget);
+ Q_ASSERT(index != -1);
+
+ for (int i = popupWidgets.size() - 1; i >= index; --i) {
+ QGraphicsWidget *widget = popupWidgets.takeLast();
+ ungrabMouse(widget, itemIsDying);
+ if (focusItem && popupWidgets.isEmpty()) {
+ QFocusEvent event(QEvent::FocusIn, Qt::PopupFocusReason);
+ sendEvent(focusItem, &event);
+ } else if (keyboardGrabberItems.contains(static_cast<QGraphicsItem *>(widget))) {
+ ungrabKeyboard(static_cast<QGraphicsItem *>(widget), itemIsDying);
+ }
+ if (!itemIsDying && widget->isVisible()) {
+ widget->QGraphicsItem::d_ptr->setVisibleHelper(false, /* explicit = */ false);
+ }
+ }
+}
+
+/*!
+ \internal
+*/
+void QGraphicsScenePrivate::grabMouse(QGraphicsItem *item, bool implicit)
+{
+ // Append to list of mouse grabber items, and send a mouse grab event.
+ if (mouseGrabberItems.contains(item)) {
+ if (mouseGrabberItems.last() == item) {
+ Q_ASSERT(!implicit);
+ if (!lastMouseGrabberItemHasImplicitMouseGrab) {
+ qWarning("QGraphicsItem::grabMouse: already a mouse grabber");
+ } else {
+ // Upgrade to an explicit mouse grab
+ lastMouseGrabberItemHasImplicitMouseGrab = false;
+ }
+ } else {
+ qWarning("QGraphicsItem::grabMouse: already blocked by mouse grabber: %p",
+ mouseGrabberItems.last());
+ }
+ return;
+ }
+
+ // Send ungrab event to the last grabber.
+ if (!mouseGrabberItems.isEmpty()) {
+ QGraphicsItem *last = mouseGrabberItems.last();
+ if (lastMouseGrabberItemHasImplicitMouseGrab) {
+ // Implicit mouse grab is immediately lost.
+ last->ungrabMouse();
+ } else {
+ // Just send ungrab event to current grabber.
+ QEvent ungrabEvent(QEvent::UngrabMouse);
+ sendEvent(last, &ungrabEvent);
+ }
+ }
+
+ mouseGrabberItems << item;
+ lastMouseGrabberItemHasImplicitMouseGrab = implicit;
+
+ // Send grab event to current grabber.
+ QEvent grabEvent(QEvent::GrabMouse);
+ sendEvent(item, &grabEvent);
+}
+
+/*!
+ \internal
+*/
+void QGraphicsScenePrivate::ungrabMouse(QGraphicsItem *item, bool itemIsDying)
+{
+ int index = mouseGrabberItems.indexOf(item);
+ if (index == -1) {
+ qWarning("QGraphicsItem::ungrabMouse: not a mouse grabber");
+ return;
+ }
+
+ if (item != mouseGrabberItems.last()) {
+ // Recursively ungrab the next mouse grabber until we reach this item
+ // to ensure state consistency.
+ ungrabMouse(mouseGrabberItems.at(index + 1), itemIsDying);
+ }
+ if (!popupWidgets.isEmpty() && item == popupWidgets.last()) {
+ // If the item is a popup, go via removePopup to ensure state
+ // consistency and that it gets hidden correctly - beware that
+ // removePopup() reenters this function to continue removing the grab.
+ removePopup((QGraphicsWidget *)item, itemIsDying);
+ return;
+ }
+
+ // Send notification about mouse ungrab.
+ if (!itemIsDying) {
+ QEvent event(QEvent::UngrabMouse);
+ sendEvent(item, &event);
+ }
+
+ // Remove the item from the list of grabbers. Whenever this happens, we
+ // reset the implicitGrab (there can be only ever be one implicit grabber
+ // in a scene, and it is always the latest grabber; if the implicit grab
+ // is lost, it is not automatically regained.
+ mouseGrabberItems.takeLast();
+ lastMouseGrabberItemHasImplicitMouseGrab = false;
+
+ // Send notification about mouse regrab. ### It's unfortunate that all the
+ // items get a GrabMouse event, but this is a rare case with a simple
+ // implementation and it does ensure a consistent state.
+ if (!itemIsDying && !mouseGrabberItems.isEmpty()) {
+ QGraphicsItem *last = mouseGrabberItems.last();
+ QEvent event(QEvent::GrabMouse);
+ sendEvent(last, &event);
+ }
+}
+
+/*!
+ \internal
+*/
+void QGraphicsScenePrivate::clearMouseGrabber()
+{
+ if (!mouseGrabberItems.isEmpty())
+ mouseGrabberItems.first()->ungrabMouse();
+ lastMouseGrabberItem = 0;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsScenePrivate::grabKeyboard(QGraphicsItem *item)
+{
+ if (keyboardGrabberItems.contains(item)) {
+ if (keyboardGrabberItems.last() == item)
+ qWarning("QGraphicsItem::grabKeyboard: already a keyboard grabber");
+ else
+ qWarning("QGraphicsItem::grabKeyboard: already blocked by keyboard grabber: %p",
+ keyboardGrabberItems.last());
+ return;
+ }
+
+ // Send ungrab event to the last grabber.
+ if (!keyboardGrabberItems.isEmpty()) {
+ // Just send ungrab event to current grabber.
+ QEvent ungrabEvent(QEvent::UngrabKeyboard);
+ sendEvent(keyboardGrabberItems.last(), &ungrabEvent);
+ }
+
+ keyboardGrabberItems << item;
+
+ // Send grab event to current grabber.
+ QEvent grabEvent(QEvent::GrabKeyboard);
+ sendEvent(item, &grabEvent);
+}
+
+/*!
+ \internal
+*/
+void QGraphicsScenePrivate::ungrabKeyboard(QGraphicsItem *item, bool itemIsDying)
+{
+ int index = keyboardGrabberItems.lastIndexOf(item);
+ if (index == -1) {
+ qWarning("QGraphicsItem::ungrabKeyboard: not a keyboard grabber");
+ return;
+ }
+ if (item != keyboardGrabberItems.last()) {
+ // Recursively ungrab the topmost keyboard grabber until we reach this
+ // item to ensure state consistency.
+ ungrabKeyboard(keyboardGrabberItems.at(index + 1), itemIsDying);
+ }
+
+ // Send notification about keyboard ungrab.
+ if (!itemIsDying) {
+ QEvent event(QEvent::UngrabKeyboard);
+ sendEvent(item, &event);
+ }
+
+ // Remove the item from the list of grabbers.
+ keyboardGrabberItems.takeLast();
+
+ // Send notification about mouse regrab.
+ if (!itemIsDying && !keyboardGrabberItems.isEmpty()) {
+ QGraphicsItem *last = keyboardGrabberItems.last();
+ QEvent event(QEvent::GrabKeyboard);
+ sendEvent(last, &event);
+ }
+}
+
+/*!
+ \internal
+*/
+void QGraphicsScenePrivate::clearKeyboardGrabber()
+{
+ if (!keyboardGrabberItems.isEmpty())
+ ungrabKeyboard(keyboardGrabberItems.first());
+}
+
+void QGraphicsScenePrivate::enableMouseTrackingOnViews()
+{
+ foreach (QGraphicsView *view, views)
+ view->viewport()->setMouseTracking(true);
+}
+
+/*!
+ Returns all items for the screen position in \a event.
+*/
+QList<QGraphicsItem *> QGraphicsScenePrivate::itemsAtPosition(const QPoint &/*screenPos*/,
+ const QPointF &scenePos,
+ QWidget *widget) const
+{
+ Q_Q(const QGraphicsScene);
+ QGraphicsView *view = widget ? qobject_cast<QGraphicsView *>(widget->parentWidget()) : 0;
+ if (!view)
+ return q->items(scenePos, Qt::IntersectsItemShape, Qt::DescendingOrder, QTransform());
+
+ const QRectF pointRect(scenePos, QSizeF(1, 1));
+ if (!view->isTransformed())
+ return q->items(pointRect, Qt::IntersectsItemShape, Qt::DescendingOrder);
+
+ const QTransform viewTransform = view->viewportTransform();
+ return q->items(pointRect, Qt::IntersectsItemShape,
+ Qt::DescendingOrder, viewTransform);
+}
+
+/*!
+ \internal
+*/
+void QGraphicsScenePrivate::storeMouseButtonsForMouseGrabber(QGraphicsSceneMouseEvent *event)
+{
+ for (int i = 0x1; i <= 0x10; i <<= 1) {
+ if (event->buttons() & i) {
+ mouseGrabberButtonDownPos.insert(Qt::MouseButton(i),
+ mouseGrabberItems.last()->d_ptr->genericMapFromScene(event->scenePos(),
+ event->widget()));
+ mouseGrabberButtonDownScenePos.insert(Qt::MouseButton(i), event->scenePos());
+ mouseGrabberButtonDownScreenPos.insert(Qt::MouseButton(i), event->screenPos());
+ }
+ }
+}
+
+/*!
+ \internal
+*/
+void QGraphicsScenePrivate::installSceneEventFilter(QGraphicsItem *watched, QGraphicsItem *filter)
+{
+ sceneEventFilters.insert(watched, filter);
+}
+
+/*!
+ \internal
+*/
+void QGraphicsScenePrivate::removeSceneEventFilter(QGraphicsItem *watched, QGraphicsItem *filter)
+{
+ if (!sceneEventFilters.contains(watched))
+ return;
+
+ QMultiMap<QGraphicsItem *, QGraphicsItem *>::Iterator it = sceneEventFilters.lowerBound(watched);
+ QMultiMap<QGraphicsItem *, QGraphicsItem *>::Iterator end = sceneEventFilters.upperBound(watched);
+ do {
+ if (it.value() == filter)
+ it = sceneEventFilters.erase(it);
+ else
+ ++it;
+ } while (it != end);
+}
+
+/*!
+ \internal
+*/
+bool QGraphicsScenePrivate::filterDescendantEvent(QGraphicsItem *item, QEvent *event)
+{
+ if (item && (item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorFiltersChildEvents)) {
+ QGraphicsItem *parent = item->parentItem();
+ while (parent) {
+ if (parent->d_ptr->filtersDescendantEvents && parent->sceneEventFilter(item, event))
+ return true;
+ if (!(parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorFiltersChildEvents))
+ return false;
+ parent = parent->parentItem();
+ }
+ }
+ return false;
+}
+
+/*!
+ \internal
+*/
+bool QGraphicsScenePrivate::filterEvent(QGraphicsItem *item, QEvent *event)
+{
+ if (item && !sceneEventFilters.contains(item))
+ return false;
+
+ QMultiMap<QGraphicsItem *, QGraphicsItem *>::Iterator it = sceneEventFilters.lowerBound(item);
+ QMultiMap<QGraphicsItem *, QGraphicsItem *>::Iterator end = sceneEventFilters.upperBound(item);
+ while (it != end) {
+ // ### The filterer and filteree might both be deleted.
+ if (it.value()->sceneEventFilter(it.key(), event))
+ return true;
+ ++it;
+ }
+ return false;
+}
+
+/*!
+ \internal
+
+ This is the final dispatch point for any events from the scene to the
+ item. It filters the event first - if the filter returns true, the event
+ is considered to have been eaten by the filter, and is therefore stopped
+ (the default filter returns false). Then/otherwise, if the item is
+ enabled, the event is sent; otherwise it is stopped.
+*/
+bool QGraphicsScenePrivate::sendEvent(QGraphicsItem *item, QEvent *event)
+{
+ if (QGraphicsObject *object = item->toGraphicsObject()) {
+#ifndef QT_NO_GESTURES
+ QGestureManager *gestureManager = QApplicationPrivate::instance()->gestureManager;
+ if (gestureManager) {
+ if (gestureManager->filterEvent(object, event))
+ return true;
+ }
+#endif // QT_NO_GESTURES
+ }
+
+ if (filterEvent(item, event))
+ return false;
+ if (filterDescendantEvent(item, event))
+ return false;
+ if (!item || !item->isEnabled())
+ return false;
+ if (QGraphicsObject *o = item->toGraphicsObject()) {
+ bool spont = event->spontaneous();
+ if (spont ? qt_sendSpontaneousEvent(o, event) : QApplication::sendEvent(o, event))
+ return true;
+ event->spont = spont;
+ }
+ return item->sceneEvent(event);
+}
+
+/*!
+ \internal
+*/
+void QGraphicsScenePrivate::cloneDragDropEvent(QGraphicsSceneDragDropEvent *dest,
+ QGraphicsSceneDragDropEvent *source)
+{
+ dest->setWidget(source->widget());
+ dest->setPos(source->pos());
+ dest->setScenePos(source->scenePos());
+ dest->setScreenPos(source->screenPos());
+ dest->setButtons(source->buttons());
+ dest->setModifiers(source->modifiers());
+ dest->setPossibleActions(source->possibleActions());
+ dest->setProposedAction(source->proposedAction());
+ dest->setDropAction(source->dropAction());
+ dest->setSource(source->source());
+ dest->setMimeData(source->mimeData());
+}
+
+/*!
+ \internal
+*/
+void QGraphicsScenePrivate::sendDragDropEvent(QGraphicsItem *item,
+ QGraphicsSceneDragDropEvent *dragDropEvent)
+{
+ dragDropEvent->setPos(item->d_ptr->genericMapFromScene(dragDropEvent->scenePos(), dragDropEvent->widget()));
+ sendEvent(item, dragDropEvent);
+}
+
+/*!
+ \internal
+*/
+void QGraphicsScenePrivate::sendHoverEvent(QEvent::Type type, QGraphicsItem *item,
+ QGraphicsSceneHoverEvent *hoverEvent)
+{
+ QGraphicsSceneHoverEvent event(type);
+ event.setWidget(hoverEvent->widget());
+ event.setPos(item->d_ptr->genericMapFromScene(hoverEvent->scenePos(), hoverEvent->widget()));
+ event.setScenePos(hoverEvent->scenePos());
+ event.setScreenPos(hoverEvent->screenPos());
+ event.setLastPos(item->d_ptr->genericMapFromScene(hoverEvent->lastScenePos(), hoverEvent->widget()));
+ event.setLastScenePos(hoverEvent->lastScenePos());
+ event.setLastScreenPos(hoverEvent->lastScreenPos());
+ event.setModifiers(hoverEvent->modifiers());
+ sendEvent(item, &event);
+}
+
+/*!
+ \internal
+*/
+void QGraphicsScenePrivate::sendMouseEvent(QGraphicsSceneMouseEvent *mouseEvent)
+{
+ if (mouseEvent->button() == 0 && mouseEvent->buttons() == 0 && lastMouseGrabberItemHasImplicitMouseGrab) {
+ // ### This is a temporary fix for until we get proper mouse
+ // grab events.
+ clearMouseGrabber();
+ return;
+ }
+
+ QGraphicsItem *item = mouseGrabberItems.last();
+ if (item->isBlockedByModalPanel())
+ return;
+
+ for (int i = 0x1; i <= 0x10; i <<= 1) {
+ Qt::MouseButton button = Qt::MouseButton(i);
+ mouseEvent->setButtonDownPos(button, mouseGrabberButtonDownPos.value(button, item->d_ptr->genericMapFromScene(mouseEvent->scenePos(), mouseEvent->widget())));
+ mouseEvent->setButtonDownScenePos(button, mouseGrabberButtonDownScenePos.value(button, mouseEvent->scenePos()));
+ mouseEvent->setButtonDownScreenPos(button, mouseGrabberButtonDownScreenPos.value(button, mouseEvent->screenPos()));
+ }
+ mouseEvent->setPos(item->d_ptr->genericMapFromScene(mouseEvent->scenePos(), mouseEvent->widget()));
+ mouseEvent->setLastPos(item->d_ptr->genericMapFromScene(mouseEvent->lastScenePos(), mouseEvent->widget()));
+ sendEvent(item, mouseEvent);
+}
+
+/*!
+ \internal
+*/
+void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mouseEvent)
+{
+ Q_Q(QGraphicsScene);
+
+ // Ignore by default, unless we find a mouse grabber that accepts it.
+ mouseEvent->ignore();
+
+ // Deliver to any existing mouse grabber.
+ if (!mouseGrabberItems.isEmpty()) {
+ if (mouseGrabberItems.last()->isBlockedByModalPanel())
+ return;
+ // The event is ignored by default, but we disregard the event's
+ // accepted state after delivery; the mouse is grabbed, after all.
+ sendMouseEvent(mouseEvent);
+ return;
+ }
+
+ // Start by determining the number of items at the current position.
+ // Reuse value from earlier calculations if possible.
+ if (cachedItemsUnderMouse.isEmpty()) {
+ cachedItemsUnderMouse = itemsAtPosition(mouseEvent->screenPos(),
+ mouseEvent->scenePos(),
+ mouseEvent->widget());
+ }
+
+ // Update window activation.
+ QGraphicsItem *topItem = cachedItemsUnderMouse.value(0);
+ QGraphicsWidget *newActiveWindow = topItem ? topItem->window() : 0;
+ if (newActiveWindow && newActiveWindow->isBlockedByModalPanel(&topItem)) {
+ // pass activation to the blocking modal window
+ newActiveWindow = topItem ? topItem->window() : 0;
+ }
+
+ if (newActiveWindow != q->activeWindow())
+ q->setActiveWindow(newActiveWindow);
+
+ // Set focus on the topmost enabled item that can take focus.
+ bool setFocus = false;
+
+ foreach (QGraphicsItem *item, cachedItemsUnderMouse) {
+ if (item->isBlockedByModalPanel()
+ || (item->d_ptr->flags & QGraphicsItem::ItemStopsFocusHandling)) {
+ // Make sure we don't clear focus.
+ setFocus = true;
+ break;
+ }
+ if (item->isEnabled() && ((item->flags() & QGraphicsItem::ItemIsFocusable))) {
+ if (!item->isWidget() || ((QGraphicsWidget *)item)->focusPolicy() & Qt::ClickFocus) {
+ setFocus = true;
+ if (item != q->focusItem() && item->d_ptr->mouseSetsFocus)
+ q->setFocusItem(item, Qt::MouseFocusReason);
+ break;
+ }
+ }
+ if (item->isPanel())
+ break;
+ if (item->d_ptr->flags & QGraphicsItem::ItemStopsClickFocusPropagation)
+ break;
+ }
+
+ // Check for scene modality.
+ bool sceneModality = false;
+ for (int i = 0; i < modalPanels.size(); ++i) {
+ if (modalPanels.at(i)->panelModality() == QGraphicsItem::SceneModal) {
+ sceneModality = true;
+ break;
+ }
+ }
+
+ // If nobody could take focus, clear it.
+ if (!stickyFocus && !setFocus && !sceneModality)
+ q->setFocusItem(0, Qt::MouseFocusReason);
+
+ // Any item will do.
+ if (sceneModality && cachedItemsUnderMouse.isEmpty())
+ cachedItemsUnderMouse << modalPanels.first();
+
+ // Find a mouse grabber by sending mouse press events to all mouse grabber
+ // candidates one at a time, until the event is accepted. It's accepted by
+ // default, so the receiver has to explicitly ignore it for it to pass
+ // through.
+ foreach (QGraphicsItem *item, cachedItemsUnderMouse) {
+ if (!(item->acceptedMouseButtons() & mouseEvent->button())) {
+ // Skip items that don't accept the event's mouse button.
+ continue;
+ }
+
+ // Check if this item is blocked by a modal panel and deliver the mouse event to the
+ // blocking panel instead of this item if blocked.
+ (void) item->isBlockedByModalPanel(&item);
+
+ grabMouse(item, /* implicit = */ true);
+ mouseEvent->accept();
+
+ // check if the item we are sending to are disabled (before we send the event)
+ bool disabled = !item->isEnabled();
+ bool isPanel = item->isPanel();
+ if (mouseEvent->type() == QEvent::GraphicsSceneMouseDoubleClick
+ && item != lastMouseGrabberItem && lastMouseGrabberItem) {
+ // If this item is different from the item that received the last
+ // mouse event, and mouseEvent is a doubleclick event, then the
+ // event is converted to a press. Known limitation:
+ // Triple-clicking will not generate a doubleclick, though.
+ QGraphicsSceneMouseEvent mousePress(QEvent::GraphicsSceneMousePress);
+ mousePress.spont = mouseEvent->spont;
+ mousePress.accept();
+ mousePress.setButton(mouseEvent->button());
+ mousePress.setButtons(mouseEvent->buttons());
+ mousePress.setScreenPos(mouseEvent->screenPos());
+ mousePress.setScenePos(mouseEvent->scenePos());
+ mousePress.setModifiers(mouseEvent->modifiers());
+ mousePress.setWidget(mouseEvent->widget());
+ mousePress.setButtonDownPos(mouseEvent->button(),
+ mouseEvent->buttonDownPos(mouseEvent->button()));
+ mousePress.setButtonDownScenePos(mouseEvent->button(),
+ mouseEvent->buttonDownScenePos(mouseEvent->button()));
+ mousePress.setButtonDownScreenPos(mouseEvent->button(),
+ mouseEvent->buttonDownScreenPos(mouseEvent->button()));
+ sendMouseEvent(&mousePress);
+ mouseEvent->setAccepted(mousePress.isAccepted());
+ } else {
+ sendMouseEvent(mouseEvent);
+ }
+
+ bool dontSendUngrabEvents = mouseGrabberItems.isEmpty() || mouseGrabberItems.last() != item;
+ if (disabled) {
+ ungrabMouse(item, /* itemIsDying = */ dontSendUngrabEvents);
+ break;
+ }
+ if (mouseEvent->isAccepted()) {
+ if (!mouseGrabberItems.isEmpty())
+ storeMouseButtonsForMouseGrabber(mouseEvent);
+ lastMouseGrabberItem = item;
+ return;
+ }
+ ungrabMouse(item, /* itemIsDying = */ dontSendUngrabEvents);
+
+ // Don't propagate through panels.
+ if (isPanel)
+ break;
+ }
+
+ // Is the event still ignored? Then the mouse press goes to the scene.
+ // Reset the mouse grabber, clear the selection, clear focus, and leave
+ // the event ignored so that it can propagate through the originating
+ // view.
+ if (!mouseEvent->isAccepted()) {
+ clearMouseGrabber();
+
+ QGraphicsView *view = mouseEvent->widget() ? qobject_cast<QGraphicsView *>(mouseEvent->widget()->parentWidget()) : 0;
+ bool dontClearSelection = view && view->dragMode() == QGraphicsView::ScrollHandDrag;
+ if (!dontClearSelection) {
+ // Clear the selection if the originating view isn't in scroll
+ // hand drag mode. The view will clear the selection if no drag
+ // happened.
+ q->clearSelection();
+ }
+ }
+}
+
+/*!
+ \internal
+
+ Ensures that the list of toplevels is sorted by insertion order, and that
+ the siblingIndexes are packed (no gaps), and start at 0.
+
+ ### This function is almost identical to
+ QGraphicsItemPrivate::ensureSequentialSiblingIndex().
+*/
+void QGraphicsScenePrivate::ensureSequentialTopLevelSiblingIndexes()
+{
+ if (!topLevelSequentialOrdering) {
+ qSort(topLevelItems.begin(), topLevelItems.end(), QGraphicsItemPrivate::insertionOrder);
+ topLevelSequentialOrdering = true;
+ needSortTopLevelItems = 1;
+ }
+ if (holesInTopLevelSiblingIndex) {
+ holesInTopLevelSiblingIndex = 0;
+ for (int i = 0; i < topLevelItems.size(); ++i)
+ topLevelItems[i]->d_ptr->siblingIndex = i;
+ }
+}
+
+/*!
+ \internal
+
+ Set the font and propagate the changes if the font is different from the
+ current font.
+*/
+void QGraphicsScenePrivate::setFont_helper(const QFont &font)
+{
+ if (this->font == font && this->font.resolve() == font.resolve())
+ return;
+ updateFont(font);
+}
+
+/*!
+ \internal
+
+ Resolve the scene's font against the application font, and propagate the
+ changes too all items in the scene.
+*/
+void QGraphicsScenePrivate::resolveFont()
+{
+ QFont naturalFont = QApplication::font();
+ naturalFont.resolve(0);
+ QFont resolvedFont = font.resolve(naturalFont);
+ updateFont(resolvedFont);
+}
+
+/*!
+ \internal
+
+ Update the font, and whether or not it has changed, reresolve all fonts in
+ the scene.
+*/
+void QGraphicsScenePrivate::updateFont(const QFont &font)
+{
+ Q_Q(QGraphicsScene);
+
+ // Update local font setting.
+ this->font = font;
+
+ // Resolve the fonts of all top-level widget items, or widget items
+ // whose parent is not a widget.
+ foreach (QGraphicsItem *item, q->items()) {
+ if (!item->parentItem()) {
+ // Resolvefont for an item is a noop operation, but
+ // every item can be a widget, or can have a widget
+ // childre.
+ item->d_ptr->resolveFont(font.resolve());
+ }
+ }
+
+ // Send the scene a FontChange event.
+ QEvent event(QEvent::FontChange);
+ QApplication::sendEvent(q, &event);
+}
+
+/*!
+ \internal
+
+ Set the palette and propagate the changes if the palette is different from
+ the current palette.
+*/
+void QGraphicsScenePrivate::setPalette_helper(const QPalette &palette)
+{
+ if (this->palette == palette && this->palette.resolve() == palette.resolve())
+ return;
+ updatePalette(palette);
+}
+
+/*!
+ \internal
+
+ Resolve the scene's palette against the application palette, and propagate
+ the changes too all items in the scene.
+*/
+void QGraphicsScenePrivate::resolvePalette()
+{
+ QPalette naturalPalette = QApplication::palette();
+ naturalPalette.resolve(0);
+ QPalette resolvedPalette = palette.resolve(naturalPalette);
+ updatePalette(resolvedPalette);
+}
+
+/*!
+ \internal
+
+ Update the palette, and whether or not it has changed, reresolve all
+ palettes in the scene.
+*/
+void QGraphicsScenePrivate::updatePalette(const QPalette &palette)
+{
+ Q_Q(QGraphicsScene);
+
+ // Update local palette setting.
+ this->palette = palette;
+
+ // Resolve the palettes of all top-level widget items, or widget items
+ // whose parent is not a widget.
+ foreach (QGraphicsItem *item, q->items()) {
+ if (!item->parentItem()) {
+ // Resolvefont for an item is a noop operation, but
+ // every item can be a widget, or can have a widget
+ // childre.
+ item->d_ptr->resolvePalette(palette.resolve());
+ }
+ }
+
+ // Send the scene a PaletteChange event.
+ QEvent event(QEvent::PaletteChange);
+ QApplication::sendEvent(q, &event);
+}
+
+/*!
+ Constructs a QGraphicsScene object. The \a parent parameter is
+ passed to QObject's constructor.
+*/
+QGraphicsScene::QGraphicsScene(QObject *parent)
+ : QObject(*new QGraphicsScenePrivate, parent)
+{
+ d_func()->init();
+}
+
+/*!
+ Constructs a QGraphicsScene object, using \a sceneRect for its
+ scene rectangle. The \a parent parameter is passed to QObject's
+ constructor.
+
+ \sa sceneRect
+*/
+QGraphicsScene::QGraphicsScene(const QRectF &sceneRect, QObject *parent)
+ : QObject(*new QGraphicsScenePrivate, parent)
+{
+ d_func()->init();
+ setSceneRect(sceneRect);
+}
+
+/*!
+ Constructs a QGraphicsScene object, using the rectangle specified
+ by (\a x, \a y), and the given \a width and \a height for its
+ scene rectangle. The \a parent parameter is passed to QObject's
+ constructor.
+
+ \sa sceneRect
+*/
+QGraphicsScene::QGraphicsScene(qreal x, qreal y, qreal width, qreal height, QObject *parent)
+ : QObject(*new QGraphicsScenePrivate, parent)
+{
+ d_func()->init();
+ setSceneRect(x, y, width, height);
+}
+
+/*!
+ Removes and deletes all items from the scene object
+ before destroying the scene object. The scene object
+ is removed from the application's global scene list,
+ and it is removed from all associated views.
+*/
+QGraphicsScene::~QGraphicsScene()
+{
+ Q_D(QGraphicsScene);
+
+ // Remove this scene from qApp's global scene list.
+ qApp->d_func()->scene_list.removeAll(this);
+
+ clear();
+
+ // Remove this scene from all associated views.
+ for (int j = 0; j < d->views.size(); ++j)
+ d->views.at(j)->setScene(0);
+}
+
+/*!
+ \property QGraphicsScene::sceneRect
+ \brief the scene rectangle; the bounding rectangle of the scene
+
+ The scene rectangle defines the extent of the scene. It is
+ primarily used by QGraphicsView to determine the view's default
+ scrollable area, and by QGraphicsScene to manage item indexing.
+
+ If unset, or if set to a null QRectF, sceneRect() will return the largest
+ bounding rect of all items on the scene since the scene was created (i.e.,
+ a rectangle that grows when items are added to or moved in the scene, but
+ never shrinks).
+
+ \sa width(), height(), QGraphicsView::sceneRect
+*/
+QRectF QGraphicsScene::sceneRect() const
+{
+ Q_D(const QGraphicsScene);
+ if (d->hasSceneRect)
+ return d->sceneRect;
+
+ if (d->dirtyGrowingItemsBoundingRect) {
+ // Lazily update the growing items bounding rect
+ QGraphicsScenePrivate *thatd = const_cast<QGraphicsScenePrivate *>(d);
+ QRectF oldGrowingBoundingRect = thatd->growingItemsBoundingRect;
+ thatd->growingItemsBoundingRect |= itemsBoundingRect();
+ thatd->dirtyGrowingItemsBoundingRect = false;
+ if (oldGrowingBoundingRect != thatd->growingItemsBoundingRect)
+ emit const_cast<QGraphicsScene *>(this)->sceneRectChanged(thatd->growingItemsBoundingRect);
+ }
+ return d->growingItemsBoundingRect;
+}
+void QGraphicsScene::setSceneRect(const QRectF &rect)
+{
+ Q_D(QGraphicsScene);
+ if (rect != d->sceneRect) {
+ d->hasSceneRect = !rect.isNull();
+ d->sceneRect = rect;
+ emit sceneRectChanged(d->hasSceneRect ? rect : d->growingItemsBoundingRect);
+ }
+}
+
+/*!
+ \fn qreal QGraphicsScene::width() const
+
+ This convenience function is equivalent to calling sceneRect().width().
+
+ \sa height()
+*/
+
+/*!
+ \fn qreal QGraphicsScene::height() const
+
+ This convenience function is equivalent to calling \c sceneRect().height().
+
+ \sa width()
+*/
+
+/*!
+ Renders the \a source rect from scene into \a target, using \a painter. This
+ function is useful for capturing the contents of the scene onto a paint
+ device, such as a QImage (e.g., to take a screenshot), or for printing
+ with QPrinter. For example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp 1
+
+ If \a source is a null rect, this function will use sceneRect() to
+ determine what to render. If \a target is a null rect, the dimensions of \a
+ painter's paint device will be used.
+
+ The source rect contents will be transformed according to \a
+ aspectRatioMode to fit into the target rect. By default, the aspect ratio
+ is kept, and \a source is scaled to fit in \a target.
+
+ \sa QGraphicsView::render()
+*/
+void QGraphicsScene::render(QPainter *painter, const QRectF &target, const QRectF &source,
+ Qt::AspectRatioMode aspectRatioMode)
+{
+ // ### Switch to using the recursive rendering algorithm instead.
+
+ // Default source rect = scene rect
+ QRectF sourceRect = source;
+ if (sourceRect.isNull())
+ sourceRect = sceneRect();
+
+ // Default target rect = device rect
+ QRectF targetRect = target;
+ if (targetRect.isNull()) {
+ if (painter->device()->devType() == QInternal::Picture)
+ targetRect = sourceRect;
+ else
+ targetRect.setRect(0, 0, painter->device()->width(), painter->device()->height());
+ }
+
+ // Find the ideal x / y scaling ratio to fit \a source into \a target.
+ qreal xratio = targetRect.width() / sourceRect.width();
+ qreal yratio = targetRect.height() / sourceRect.height();
+
+ // Scale according to the aspect ratio mode.
+ switch (aspectRatioMode) {
+ case Qt::KeepAspectRatio:
+ xratio = yratio = qMin(xratio, yratio);
+ break;
+ case Qt::KeepAspectRatioByExpanding:
+ xratio = yratio = qMax(xratio, yratio);
+ break;
+ case Qt::IgnoreAspectRatio:
+ break;
+ }
+
+ // Find all items to draw, and reverse the list (we want to draw
+ // in reverse order).
+ QList<QGraphicsItem *> itemList = items(sourceRect, Qt::IntersectsItemBoundingRect);
+ QGraphicsItem **itemArray = new QGraphicsItem *[itemList.size()];
+ int numItems = itemList.size();
+ for (int i = 0; i < numItems; ++i)
+ itemArray[numItems - i - 1] = itemList.at(i);
+ itemList.clear();
+
+ painter->save();
+
+ // Transform the painter.
+ painter->setClipRect(targetRect, Qt::IntersectClip);
+ QTransform painterTransform;
+ painterTransform *= QTransform()
+ .translate(targetRect.left(), targetRect.top())
+ .scale(xratio, yratio)
+ .translate(-sourceRect.left(), -sourceRect.top());
+ painter->setWorldTransform(painterTransform, true);
+
+ // Two unit vectors.
+ QLineF v1(0, 0, 1, 0);
+ QLineF v2(0, 0, 0, 1);
+
+ // Generate the style options
+ QStyleOptionGraphicsItem *styleOptionArray = new QStyleOptionGraphicsItem[numItems];
+ for (int i = 0; i < numItems; ++i)
+ itemArray[i]->d_ptr->initStyleOption(&styleOptionArray[i], painterTransform, targetRect.toRect());
+
+ // Render the scene.
+ drawBackground(painter, sourceRect);
+ drawItems(painter, numItems, itemArray, styleOptionArray);
+ drawForeground(painter, sourceRect);
+
+ delete [] itemArray;
+ delete [] styleOptionArray;
+
+ painter->restore();
+}
+
+/*!
+ \property QGraphicsScene::itemIndexMethod
+ \brief the item indexing method.
+
+ QGraphicsScene applies an indexing algorithm to the scene, to speed up
+ item discovery functions like items() and itemAt(). Indexing is most
+ efficient for static scenes (i.e., where items don't move around). For
+ dynamic scenes, or scenes with many animated items, the index bookkeeping
+ can outweight the fast lookup speeds.
+
+ For the common case, the default index method BspTreeIndex works fine. If
+ your scene uses many animations and you are experiencing slowness, you can
+ disable indexing by calling \c setItemIndexMethod(NoIndex).
+
+ \sa bspTreeDepth
+*/
+QGraphicsScene::ItemIndexMethod QGraphicsScene::itemIndexMethod() const
+{
+ Q_D(const QGraphicsScene);
+ return d->indexMethod;
+}
+void QGraphicsScene::setItemIndexMethod(ItemIndexMethod method)
+{
+ Q_D(QGraphicsScene);
+ if (d->indexMethod == method)
+ return;
+
+ d->indexMethod = method;
+
+ QList<QGraphicsItem *> oldItems = d->index->items(Qt::DescendingOrder);
+ delete d->index;
+ if (method == BspTreeIndex)
+ d->index = new QGraphicsSceneBspTreeIndex(this);
+ else
+ d->index = new QGraphicsSceneLinearIndex(this);
+ for (int i = oldItems.size() - 1; i >= 0; --i)
+ d->index->addItem(oldItems.at(i));
+}
+
+/*!
+ \property QGraphicsScene::bspTreeDepth
+ \brief the depth of QGraphicsScene's BSP index tree
+ \since 4.3
+
+ This property has no effect when NoIndex is used.
+
+ This value determines the depth of QGraphicsScene's BSP tree. The depth
+ directly affects QGraphicsScene's performance and memory usage; the latter
+ growing exponentially with the depth of the tree. With an optimal tree
+ depth, QGraphicsScene can instantly determine the locality of items, even
+ for scenes with thousands or millions of items. This also greatly improves
+ rendering performance.
+
+ By default, the value is 0, in which case Qt will guess a reasonable
+ default depth based on the size, location and number of items in the
+ scene. If these parameters change frequently, however, you may experience
+ slowdowns as QGraphicsScene retunes the depth internally. You can avoid
+ potential slowdowns by fixating the tree depth through setting this
+ property.
+
+ The depth of the tree and the size of the scene rectangle decide the
+ granularity of the scene's partitioning. The size of each scene segment is
+ determined by the following algorithm:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp 2
+
+ The BSP tree has an optimal size when each segment contains between 0 and
+ 10 items.
+
+ \sa itemIndexMethod
+*/
+int QGraphicsScene::bspTreeDepth() const
+{
+ Q_D(const QGraphicsScene);
+ QGraphicsSceneBspTreeIndex *bspTree = qobject_cast<QGraphicsSceneBspTreeIndex *>(d->index);
+ return bspTree ? bspTree->bspTreeDepth() : 0;
+}
+void QGraphicsScene::setBspTreeDepth(int depth)
+{
+ Q_D(QGraphicsScene);
+ if (depth < 0) {
+ qWarning("QGraphicsScene::setBspTreeDepth: invalid depth %d ignored; must be >= 0", depth);
+ return;
+ }
+
+ QGraphicsSceneBspTreeIndex *bspTree = qobject_cast<QGraphicsSceneBspTreeIndex *>(d->index);
+ if (!bspTree) {
+ qWarning("QGraphicsScene::setBspTreeDepth: can not apply if indexing method is not BSP");
+ return;
+ }
+ bspTree->setBspTreeDepth(depth);
+}
+
+/*!
+ \property QGraphicsScene::sortCacheEnabled
+ \brief whether sort caching is enabled
+ \since 4.5
+ \obsolete
+
+ Since Qt 4.6, this property has no effect.
+*/
+bool QGraphicsScene::isSortCacheEnabled() const
+{
+ Q_D(const QGraphicsScene);
+ return d->sortCacheEnabled;
+}
+void QGraphicsScene::setSortCacheEnabled(bool enabled)
+{
+ Q_D(QGraphicsScene);
+ if (d->sortCacheEnabled == enabled)
+ return;
+ d->sortCacheEnabled = enabled;
+}
+
+/*!
+ Calculates and returns the bounding rect of all items on the scene. This
+ function works by iterating over all items, and because if this, it can
+ be slow for large scenes.
+
+ \sa sceneRect()
+*/
+QRectF QGraphicsScene::itemsBoundingRect() const
+{
+ // Does not take untransformable items into account.
+ QRectF boundingRect;
+ foreach (QGraphicsItem *item, items())
+ boundingRect |= item->sceneBoundingRect();
+ return boundingRect;
+}
+
+/*!
+ Returns a list of all items in the scene in descending stacking order.
+
+ \sa addItem(), removeItem(), {QGraphicsItem#Sorting}{Sorting}
+*/
+QList<QGraphicsItem *> QGraphicsScene::items() const
+{
+ Q_D(const QGraphicsScene);
+ return d->index->items(Qt::DescendingOrder);
+}
+
+/*!
+ Returns an ordered list of all items on the scene. \a order decides the
+ stacking order.
+
+ \sa addItem(), removeItem(), {QGraphicsItem#Sorting}{Sorting}
+*/
+QList<QGraphicsItem *> QGraphicsScene::items(Qt::SortOrder order) const
+{
+ Q_D(const QGraphicsScene);
+ return d->index->items(order);
+}
+
+/*!
+ \obsolete
+
+ Returns all visible items at position \a pos in the scene. The items are
+ listed in descending stacking order (i.e., the first item in the list is the
+ top-most item, and the last item is the bottom-most item).
+
+ This function is deprecated and returns incorrect results if the scene
+ contains items that ignore transformations. Use the overload that takes
+ a QTransform instead.
+
+ \sa itemAt(), {QGraphicsItem#Sorting}{Sorting}
+*/
+QList<QGraphicsItem *> QGraphicsScene::items(const QPointF &pos) const
+{
+ Q_D(const QGraphicsScene);
+ return d->index->items(pos, Qt::IntersectsItemShape, Qt::DescendingOrder);
+}
+
+/*!
+ \overload
+ \obsolete
+
+ Returns all visible items that, depending on \a mode, are either inside or
+ intersect with the specified \a rectangle.
+
+ The default value for \a mode is Qt::IntersectsItemShape; all items whose
+ exact shape intersects with or is contained by \a rectangle are returned.
+
+ This function is deprecated and returns incorrect results if the scene
+ contains items that ignore transformations. Use the overload that takes
+ a QTransform instead.
+
+ \sa itemAt(), {QGraphicsItem#Sorting}{Sorting}
+*/
+QList<QGraphicsItem *> QGraphicsScene::items(const QRectF &rectangle, Qt::ItemSelectionMode mode) const
+{
+ Q_D(const QGraphicsScene);
+ return d->index->items(rectangle, mode, Qt::DescendingOrder);
+}
+
+/*!
+ \fn QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode) const
+ \obsolete
+ \since 4.3
+
+ This convenience function is equivalent to calling items(QRectF(\a x, \a y, \a w, \a h), \a mode).
+
+ This function is deprecated and returns incorrect results if the scene
+ contains items that ignore transformations. Use the overload that takes
+ a QTransform instead.
+*/
+
+/*!
+ \fn QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const
+ \overload
+ \since 4.6
+
+ \brief Returns all visible items that, depending on \a mode, are
+ either inside or intersect with the rectangle defined by \a x, \a y,
+ \a w and \a h, in a list sorted using \a order.
+
+ \a deviceTransform is the transformation that applies to the view, and needs to
+ be provided if the scene contains items that ignore transformations.
+*/
+
+/*!
+ \fn QList<QGraphicsItem *> QGraphicsScene::items(const QPolygonF &polygon, Qt::ItemSelectionMode mode) const
+ \overload
+ \obsolete
+
+ Returns all visible items that, depending on \a mode, are either inside or
+ intersect with the polygon \a polygon.
+
+ The default value for \a mode is Qt::IntersectsItemShape; all items whose
+ exact shape intersects with or is contained by \a polygon are returned.
+
+ This function is deprecated and returns incorrect results if the scene
+ contains items that ignore transformations. Use the overload that takes
+ a QTransform instead.
+
+ \sa itemAt(), {QGraphicsItem#Sorting}{Sorting}
+*/
+QList<QGraphicsItem *> QGraphicsScene::items(const QPolygonF &polygon, Qt::ItemSelectionMode mode) const
+{
+ Q_D(const QGraphicsScene);
+ return d->index->items(polygon, mode, Qt::DescendingOrder);
+}
+
+/*!
+ \fn QList<QGraphicsItem *> QGraphicsScene::items(const QPainterPath &path, Qt::ItemSelectionMode mode) const
+ \overload
+ \obsolete
+
+ Returns all visible items that, depending on \a path, are either inside or
+ intersect with the path \a path.
+
+ The default value for \a mode is Qt::IntersectsItemShape; all items whose
+ exact shape intersects with or is contained by \a path are returned.
+
+ This function is deprecated and returns incorrect results if the scene
+ contains items that ignore transformations. Use the overload that takes
+ a QTransform instead.
+
+ \sa itemAt(), {QGraphicsItem#Sorting}{Sorting}
+*/
+QList<QGraphicsItem *> QGraphicsScene::items(const QPainterPath &path, Qt::ItemSelectionMode mode) const
+{
+ Q_D(const QGraphicsScene);
+ return d->index->items(path, mode, Qt::DescendingOrder);
+}
+
+/*!
+ \fn QList<QGraphicsItem *> QGraphicsScene::items(const QPointF &pos, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const
+ \since 4.6
+
+ \brief Returns all visible items that, depending on \a mode, are at
+ the specified \a pos in a list sorted using \a order.
+
+ The default value for \a mode is Qt::IntersectsItemShape; all items whose
+ exact shape intersects with \a pos are returned.
+
+ \a deviceTransform is the transformation that applies to the view, and needs to
+ be provided if the scene contains items that ignore transformations.
+
+ \sa itemAt(), {QGraphicsItem#Sorting}{Sorting}
+*/
+QList<QGraphicsItem *> QGraphicsScene::items(const QPointF &pos, Qt::ItemSelectionMode mode,
+ Qt::SortOrder order, const QTransform &deviceTransform) const
+{
+ Q_D(const QGraphicsScene);
+ return d->index->items(pos, mode, order, deviceTransform);
+}
+
+/*!
+ \fn QList<QGraphicsItem *> QGraphicsScene::items(const QRectF &rect, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const
+ \overload
+ \since 4.6
+
+ \brief Returns all visible items that, depending on \a mode, are
+ either inside or intersect with the specified \a rect and return a
+ list sorted using \a order.
+
+ The default value for \a mode is Qt::IntersectsItemShape; all items whose
+ exact shape intersects with or is contained by \a rect are returned.
+
+ \a deviceTransform is the transformation that applies to the view, and needs to
+ be provided if the scene contains items that ignore transformations.
+
+ \sa itemAt(), {QGraphicsItem#Sorting}{Sorting}
+*/
+QList<QGraphicsItem *> QGraphicsScene::items(const QRectF &rect, Qt::ItemSelectionMode mode,
+ Qt::SortOrder order, const QTransform &deviceTransform) const
+{
+ Q_D(const QGraphicsScene);
+ return d->index->items(rect, mode, order, deviceTransform);
+}
+
+/*!
+ \fn QList<QGraphicsItem *> QGraphicsScene::items(const QPolygonF &polygon, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const
+ \overload
+ \since 4.6
+
+ \brief Returns all visible items that, depending on \a mode, are
+ either inside or intersect with the specified \a polygon and return
+ a list sorted using \a order.
+
+ The default value for \a mode is Qt::IntersectsItemShape; all items whose
+ exact shape intersects with or is contained by \a polygon are returned.
+
+ \a deviceTransform is the transformation that applies to the view, and needs to
+ be provided if the scene contains items that ignore transformations.
+
+ \sa itemAt(), {QGraphicsItem#Sorting}{Sorting}
+*/
+QList<QGraphicsItem *> QGraphicsScene::items(const QPolygonF &polygon, Qt::ItemSelectionMode mode,
+ Qt::SortOrder order, const QTransform &deviceTransform) const
+{
+ Q_D(const QGraphicsScene);
+ return d->index->items(polygon, mode, order, deviceTransform);
+}
+
+/*!
+ \fn QList<QGraphicsItem *> QGraphicsScene::items(const QPainterPath &path, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const
+ \overload
+ \since 4.6
+
+ \brief Returns all visible items that, depending on \a mode, are
+ either inside or intersect with the specified \a path and return a
+ list sorted using \a order.
+
+ The default value for \a mode is Qt::IntersectsItemShape; all items whose
+ exact shape intersects with or is contained by \a path are returned.
+
+ \a deviceTransform is the transformation that applies to the view, and needs to
+ be provided if the scene contains items that ignore transformations.
+
+ \sa itemAt(), {QGraphicsItem#Sorting}{Sorting}
+*/
+QList<QGraphicsItem *> QGraphicsScene::items(const QPainterPath &path, Qt::ItemSelectionMode mode,
+ Qt::SortOrder order, const QTransform &deviceTransform) const
+{
+ Q_D(const QGraphicsScene);
+ return d->index->items(path, mode, order, deviceTransform);
+}
+
+/*!
+ Returns a list of all items that collide with \a item. Collisions are
+ determined by calling QGraphicsItem::collidesWithItem(); the collision
+ detection is determined by \a mode. By default, all items whose shape
+ intersects \a item or is contained inside \a item's shape are returned.
+
+ The items are returned in descending stacking order (i.e., the first item
+ in the list is the uppermost item, and the last item is the lowermost
+ item).
+
+ \sa items(), itemAt(), QGraphicsItem::collidesWithItem(), {QGraphicsItem#Sorting}{Sorting}
+*/
+QList<QGraphicsItem *> QGraphicsScene::collidingItems(const QGraphicsItem *item,
+ Qt::ItemSelectionMode mode) const
+{
+ Q_D(const QGraphicsScene);
+ if (!item) {
+ qWarning("QGraphicsScene::collidingItems: cannot find collisions for null item");
+ return QList<QGraphicsItem *>();
+ }
+
+ // Does not support ItemIgnoresTransformations.
+ QList<QGraphicsItem *> tmp;
+ foreach (QGraphicsItem *itemInVicinity, d->index->estimateItems(item->sceneBoundingRect(), Qt::DescendingOrder)) {
+ if (item != itemInVicinity && item->collidesWithItem(itemInVicinity, mode))
+ tmp << itemInVicinity;
+ }
+ return tmp;
+}
+
+/*!
+ \overload
+ \obsolete
+
+ Returns the topmost visible item at the specified \a position, or 0 if
+ there are no items at this position.
+
+ This function is deprecated and returns incorrect results if the scene
+ contains items that ignore transformations. Use the overload that takes
+ a QTransform instead.
+
+ \sa items(), collidingItems(), {QGraphicsItem#Sorting}{Sorting}
+*/
+QGraphicsItem *QGraphicsScene::itemAt(const QPointF &position) const
+{
+ QList<QGraphicsItem *> itemsAtPoint = items(position);
+ return itemsAtPoint.isEmpty() ? 0 : itemsAtPoint.first();
+}
+
+/*!
+ \since 4.6
+
+ Returns the topmost visible item at the specified \a position, or 0
+ if there are no items at this position.
+
+ \a deviceTransform is the transformation that applies to the view, and needs to
+ be provided if the scene contains items that ignore transformations.
+
+ \sa items(), collidingItems(), {QGraphicsItem#Sorting}{Sorting}
+*/
+QGraphicsItem *QGraphicsScene::itemAt(const QPointF &position, const QTransform &deviceTransform) const
+{
+ QList<QGraphicsItem *> itemsAtPoint = items(position, Qt::IntersectsItemShape,
+ Qt::DescendingOrder, deviceTransform);
+ return itemsAtPoint.isEmpty() ? 0 : itemsAtPoint.first();
+}
+
+/*!
+ \fn QGraphicsScene::itemAt(qreal x, qreal y, const QTransform &deviceTransform) const
+ \overload
+ \since 4.6
+
+ Returns the topmost item at the position specified by (\a x, \a
+ y), or 0 if there are no items at this position.
+
+ \a deviceTransform is the transformation that applies to the view, and needs to
+ be provided if the scene contains items that ignore transformations.
+
+ This convenience function is equivalent to calling \c
+ {itemAt(QPointF(x, y), deviceTransform)}.
+*/
+
+/*!
+ \fn QGraphicsScene::itemAt(qreal x, qreal y) const
+ \overload
+ \obsolete
+
+ Returns the topmost item at the position specified by (\a x, \a
+ y), or 0 if there are no items at this position.
+
+ This convenience function is equivalent to calling \c
+ {itemAt(QPointF(x, y))}.
+
+ This function is deprecated and returns incorrect results if the scene
+ contains items that ignore transformations. Use the overload that takes
+ a QTransform instead.
+*/
+
+/*!
+ Returns a list of all currently selected items. The items are
+ returned in no particular order.
+
+ \sa setSelectionArea()
+*/
+QList<QGraphicsItem *> QGraphicsScene::selectedItems() const
+{
+ Q_D(const QGraphicsScene);
+
+ // Optimization: Lazily removes items that are not selected.
+ QGraphicsScene *that = const_cast<QGraphicsScene *>(this);
+ QSet<QGraphicsItem *> actuallySelectedSet;
+ foreach (QGraphicsItem *item, that->d_func()->selectedItems) {
+ if (item->isSelected())
+ actuallySelectedSet << item;
+ }
+
+ that->d_func()->selectedItems = actuallySelectedSet;
+
+ return d->selectedItems.values();
+}
+
+/*!
+ Returns the selection area that was previously set with
+ setSelectionArea(), or an empty QPainterPath if no selection area has been
+ set.
+
+ \sa setSelectionArea()
+*/
+QPainterPath QGraphicsScene::selectionArea() const
+{
+ Q_D(const QGraphicsScene);
+ return d->selectionArea;
+}
+
+/*!
+ \since 4.6
+
+ Sets the selection area to \a path. All items within this area are
+ immediately selected, and all items outside are unselected. You can get
+ the list of all selected items by calling selectedItems().
+
+ \a deviceTransform is the transformation that applies to the view, and needs to
+ be provided if the scene contains items that ignore transformations.
+
+ For an item to be selected, it must be marked as \e selectable
+ (QGraphicsItem::ItemIsSelectable).
+
+ \sa clearSelection(), selectionArea()
+*/
+void QGraphicsScene::setSelectionArea(const QPainterPath &path, const QTransform &deviceTransform)
+{
+ setSelectionArea(path, Qt::IntersectsItemShape, deviceTransform);
+}
+
+/*!
+ \obsolete
+ \overload
+
+ Sets the selection area to \a path.
+
+ This function is deprecated and leads to incorrect results if the scene
+ contains items that ignore transformations. Use the overload that takes
+ a QTransform instead.
+*/
+void QGraphicsScene::setSelectionArea(const QPainterPath &path)
+{
+ setSelectionArea(path, Qt::IntersectsItemShape, QTransform());
+}
+
+/*!
+ \obsolete
+ \overload
+ \since 4.3
+
+ Sets the selection area to \a path using \a mode to determine if items are
+ included in the selection area.
+
+ \sa clearSelection(), selectionArea()
+*/
+void QGraphicsScene::setSelectionArea(const QPainterPath &path, Qt::ItemSelectionMode mode)
+{
+ setSelectionArea(path, mode, QTransform());
+}
+
+/*!
+ \overload
+ \since 4.6
+
+ Sets the selection area to \a path using \a mode to determine if items are
+ included in the selection area.
+
+ \a deviceTransform is the transformation that applies to the view, and needs to
+ be provided if the scene contains items that ignore transformations.
+
+ \sa clearSelection(), selectionArea()
+*/
+void QGraphicsScene::setSelectionArea(const QPainterPath &path, Qt::ItemSelectionMode mode,
+ const QTransform &deviceTransform)
+{
+ Q_D(QGraphicsScene);
+
+ // Note: with boolean path operations, we can improve performance here
+ // quite a lot by "growing" the old path instead of replacing it. That
+ // allows us to only check the intersect area for changes, instead of
+ // reevaluating the whole path over again.
+ d->selectionArea = path;
+
+ QSet<QGraphicsItem *> unselectItems = d->selectedItems;
+
+ // Disable emitting selectionChanged() for individual items.
+ ++d->selectionChanging;
+ bool changed = false;
+
+ // Set all items in path to selected.
+ foreach (QGraphicsItem *item, items(path, mode, Qt::DescendingOrder, deviceTransform)) {
+ if (item->flags() & QGraphicsItem::ItemIsSelectable) {
+ if (!item->isSelected())
+ changed = true;
+ unselectItems.remove(item);
+ item->setSelected(true);
+ }
+ }
+
+ // Unselect all items outside path.
+ foreach (QGraphicsItem *item, unselectItems) {
+ item->setSelected(false);
+ changed = true;
+ }
+
+ // Reenable emitting selectionChanged() for individual items.
+ --d->selectionChanging;
+
+ if (!d->selectionChanging && changed)
+ emit selectionChanged();
+}
+
+/*!
+ Clears the current selection.
+
+ \sa setSelectionArea(), selectedItems()
+*/
+void QGraphicsScene::clearSelection()
+{
+ Q_D(QGraphicsScene);
+
+ // Disable emitting selectionChanged
+ ++d->selectionChanging;
+ bool changed = !d->selectedItems.isEmpty();
+
+ foreach (QGraphicsItem *item, d->selectedItems)
+ item->setSelected(false);
+ d->selectedItems.clear();
+
+ // Reenable emitting selectionChanged() for individual items.
+ --d->selectionChanging;
+
+ if (!d->selectionChanging && changed)
+ emit selectionChanged();
+}
+
+/*!
+ \since 4.4
+
+ Removes and deletes all items from the scene, but otherwise leaves the
+ state of the scene unchanged.
+
+ \sa addItem()
+*/
+void QGraphicsScene::clear()
+{
+ Q_D(QGraphicsScene);
+ // NB! We have to clear the index before deleting items; otherwise the
+ // index might try to access dangling item pointers.
+ d->index->clear();
+ // NB! QGraphicsScenePrivate::unregisterTopLevelItem() removes items
+ while (!d->topLevelItems.isEmpty())
+ delete d->topLevelItems.first();
+ Q_ASSERT(d->topLevelItems.isEmpty());
+ d->lastItemCount = 0;
+ d->allItemsIgnoreHoverEvents = true;
+ d->allItemsUseDefaultCursor = true;
+ d->allItemsIgnoreTouchEvents = true;
+}
+
+/*!
+ Groups all items in \a items into a new QGraphicsItemGroup, and returns a
+ pointer to the group. The group is created with the common ancestor of \a
+ items as its parent, and with position (0, 0). The items are all
+ reparented to the group, and their positions and transformations are
+ mapped to the group. If \a items is empty, this function will return an
+ empty top-level QGraphicsItemGroup.
+
+ QGraphicsScene has ownership of the group item; you do not need to delete
+ it. To dismantle (ungroup) a group, call destroyItemGroup().
+
+ \sa destroyItemGroup(), QGraphicsItemGroup::addToGroup()
+*/
+QGraphicsItemGroup *QGraphicsScene::createItemGroup(const QList<QGraphicsItem *> &items)
+{
+ // Build a list of the first item's ancestors
+ QList<QGraphicsItem *> ancestors;
+ int n = 0;
+ if (!items.isEmpty()) {
+ QGraphicsItem *parent = items.at(n++);
+ while ((parent = parent->parentItem()))
+ ancestors.append(parent);
+ }
+
+ // Find the common ancestor for all items
+ QGraphicsItem *commonAncestor = 0;
+ if (!ancestors.isEmpty()) {
+ while (n < items.size()) {
+ int commonIndex = -1;
+ QGraphicsItem *parent = items.at(n++);
+ do {
+ int index = ancestors.indexOf(parent, qMax(0, commonIndex));
+ if (index != -1) {
+ commonIndex = index;
+ break;
+ }
+ } while ((parent = parent->parentItem()));
+
+ if (commonIndex == -1) {
+ commonAncestor = 0;
+ break;
+ }
+
+ commonAncestor = ancestors.at(commonIndex);
+ }
+ }
+
+ // Create a new group at that level
+ QGraphicsItemGroup *group = new QGraphicsItemGroup(commonAncestor);
+ if (!commonAncestor)
+ addItem(group);
+ foreach (QGraphicsItem *item, items)
+ group->addToGroup(item);
+ return group;
+}
+
+/*!
+ Reparents all items in \a group to \a group's parent item, then removes \a
+ group from the scene, and finally deletes it. The items' positions and
+ transformations are mapped from the group to the group's parent.
+
+ \sa createItemGroup(), QGraphicsItemGroup::removeFromGroup()
+*/
+void QGraphicsScene::destroyItemGroup(QGraphicsItemGroup *group)
+{
+ foreach (QGraphicsItem *item, group->children())
+ group->removeFromGroup(item);
+ removeItem(group);
+ delete group;
+}
+
+/*!
+ Adds or moves the \a item and all its childen to this scene.
+ This scene takes ownership of the \a item.
+
+ If the item is visible (i.e., QGraphicsItem::isVisible() returns
+ true), QGraphicsScene will emit changed() once control goes back
+ to the event loop.
+
+ If the item is already in a different scene, it will first be
+ removed from its old scene, and then added to this scene as a
+ top-level.
+
+ QGraphicsScene will send ItemSceneChange notifications to \a item
+ while it is added to the scene. If item does not currently belong
+ to a scene, only one notification is sent. If it does belong to
+ scene already (i.e., it is moved to this scene), QGraphicsScene
+ will send an addition notification as the item is removed from its
+ previous scene.
+
+ If the item is a panel, the scene is active, and there is no
+ active panel in the scene, then the item will be activated.
+
+ \sa removeItem(), addEllipse(), addLine(), addPath(), addPixmap(),
+ addRect(), addText(), addWidget(), {QGraphicsItem#Sorting}{Sorting}
+*/
+void QGraphicsScene::addItem(QGraphicsItem *item)
+{
+ Q_D(QGraphicsScene);
+ if (!item) {
+ qWarning("QGraphicsScene::addItem: cannot add null item");
+ return;
+ }
+ if (item->d_ptr->scene == this) {
+ qWarning("QGraphicsScene::addItem: item has already been added to this scene");
+ return;
+ }
+ // Remove this item from its existing scene
+ if (QGraphicsScene *oldScene = item->d_ptr->scene)
+ oldScene->removeItem(item);
+
+ // Notify the item that its scene is changing, and allow the item to
+ // react.
+ const QVariant newSceneVariant(item->itemChange(QGraphicsItem::ItemSceneChange,
+ QVariant::fromValue<QGraphicsScene *>(this)));
+ QGraphicsScene *targetScene = qvariant_cast<QGraphicsScene *>(newSceneVariant);
+ if (targetScene != this) {
+ if (targetScene && item->d_ptr->scene != targetScene)
+ targetScene->addItem(item);
+ return;
+ }
+
+ // QDeclarativeItems do not rely on initial itemChanged message, as the componentComplete
+ // function allows far more opportunity for delayed-construction optimization.
+ if (!item->d_ptr->isDeclarativeItem) {
+ if (d->unpolishedItems.isEmpty()) {
+ QMetaMethod method = metaObject()->method(d->polishItemsIndex);
+ method.invoke(this, Qt::QueuedConnection);
+ }
+ d->unpolishedItems.append(item);
+ item->d_ptr->pendingPolish = true;
+ }
+
+ // Detach this item from its parent if the parent's scene is different
+ // from this scene.
+ if (QGraphicsItem *itemParent = item->d_ptr->parent) {
+ if (itemParent->d_ptr->scene != this)
+ item->setParentItem(0);
+ }
+
+ // Add the item to this scene
+ item->d_func()->scene = targetScene;
+
+ // Add the item in the index
+ d->index->addItem(item);
+
+ // Add to list of toplevels if this item is a toplevel.
+ if (!item->d_ptr->parent)
+ d->registerTopLevelItem(item);
+
+ // Add to list of items that require an update. We cannot assume that the
+ // item is fully constructed, so calling item->update() can lead to a pure
+ // virtual function call to boundingRect().
+ d->markDirty(item);
+ d->dirtyGrowingItemsBoundingRect = true;
+
+ // Disable selectionChanged() for individual items
+ ++d->selectionChanging;
+ int oldSelectedItemSize = d->selectedItems.size();
+
+ // Enable mouse tracking if the item accepts hover events or has a cursor set.
+ if (d->allItemsIgnoreHoverEvents && d->itemAcceptsHoverEvents_helper(item)) {
+ d->allItemsIgnoreHoverEvents = false;
+ d->enableMouseTrackingOnViews();
+ }
+#ifndef QT_NO_CURSOR
+ if (d->allItemsUseDefaultCursor && item->d_ptr->hasCursor) {
+ d->allItemsUseDefaultCursor = false;
+ if (d->allItemsIgnoreHoverEvents) // already enabled otherwise
+ d->enableMouseTrackingOnViews();
+ }
+#endif //QT_NO_CURSOR
+
+ // Enable touch events if the item accepts touch events.
+ if (d->allItemsIgnoreTouchEvents && item->d_ptr->acceptTouchEvents) {
+ d->allItemsIgnoreTouchEvents = false;
+ d->enableTouchEventsOnViews();
+ }
+
+#ifndef QT_NO_GESTURES
+ foreach (Qt::GestureType gesture, item->d_ptr->gestureContext.keys())
+ d->grabGesture(item, gesture);
+#endif
+
+ // Update selection lists
+ if (item->isSelected())
+ d->selectedItems << item;
+ if (item->isWidget() && item->isVisible() && static_cast<QGraphicsWidget *>(item)->windowType() == Qt::Popup)
+ d->addPopup(static_cast<QGraphicsWidget *>(item));
+ if (item->isPanel() && item->isVisible() && item->panelModality() != QGraphicsItem::NonModal)
+ d->enterModal(item);
+
+ // Update creation order focus chain. Make sure to leave the widget's
+ // internal tab order intact.
+ if (item->isWidget()) {
+ QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
+ if (!d->tabFocusFirst) {
+ // No first tab focus widget - make this the first tab focus
+ // widget.
+ d->tabFocusFirst = widget;
+ } else if (!widget->parentWidget()) {
+ // Adding a widget that is not part of a tab focus chain.
+ QGraphicsWidget *last = d->tabFocusFirst->d_func()->focusPrev;
+ QGraphicsWidget *lastNew = widget->d_func()->focusPrev;
+ last->d_func()->focusNext = widget;
+ widget->d_func()->focusPrev = last;
+ d->tabFocusFirst->d_func()->focusPrev = lastNew;
+ lastNew->d_func()->focusNext = d->tabFocusFirst;
+ }
+ }
+
+ // Add all children recursively
+ item->d_ptr->ensureSortedChildren();
+ for (int i = 0; i < item->d_ptr->children.size(); ++i)
+ addItem(item->d_ptr->children.at(i));
+
+ // Resolve font and palette.
+ item->d_ptr->resolveFont(d->font.resolve());
+ item->d_ptr->resolvePalette(d->palette.resolve());
+
+
+ // Reenable selectionChanged() for individual items
+ --d->selectionChanging;
+ if (!d->selectionChanging && d->selectedItems.size() != oldSelectedItemSize)
+ emit selectionChanged();
+
+ // Deliver post-change notification
+ item->itemChange(QGraphicsItem::ItemSceneHasChanged, newSceneVariant);
+
+ // Update explicit activation
+ bool autoActivate = true;
+ if (!d->childExplicitActivation && item->d_ptr->explicitActivate)
+ d->childExplicitActivation = item->d_ptr->wantsActive ? 1 : 2;
+ if (d->childExplicitActivation && item->isPanel()) {
+ if (d->childExplicitActivation == 1)
+ setActivePanel(item);
+ else
+ autoActivate = false;
+ d->childExplicitActivation = 0;
+ } else if (!item->d_ptr->parent) {
+ d->childExplicitActivation = 0;
+ }
+
+ // Auto-activate this item's panel if nothing else has been activated
+ if (autoActivate) {
+ if (!d->lastActivePanel && !d->activePanel && item->isPanel()) {
+ if (isActive())
+ setActivePanel(item);
+ else
+ d->lastActivePanel = item;
+ }
+ }
+
+ if (item->d_ptr->flags & QGraphicsItem::ItemSendsScenePositionChanges)
+ d->registerScenePosItem(item);
+
+ // Ensure that newly added items that have subfocus set, gain
+ // focus automatically if there isn't a focus item already.
+ if (!d->focusItem && item != d->lastFocusItem && item->focusItem() == item)
+ item->focusItem()->setFocus();
+
+ d->updateInputMethodSensitivityInViews();
+}
+
+/*!
+ Creates and adds an ellipse item to the scene, and returns the item
+ pointer. The geometry of the ellipse is defined by \a rect, and its pen
+ and brush are initialized to \a pen and \a brush.
+
+ Note that the item's geometry is provided in item coordinates, and its
+ position is initialized to (0, 0).
+
+ If the item is visible (i.e., QGraphicsItem::isVisible() returns true),
+ QGraphicsScene will emit changed() once control goes back to the event
+ loop.
+
+ \sa addLine(), addPath(), addPixmap(), addRect(), addText(), addItem(),
+ addWidget()
+*/
+QGraphicsEllipseItem *QGraphicsScene::addEllipse(const QRectF &rect, const QPen &pen, const QBrush &brush)
+{
+ QGraphicsEllipseItem *item = new QGraphicsEllipseItem(rect);
+ item->setPen(pen);
+ item->setBrush(brush);
+ addItem(item);
+ return item;
+}
+
+/*!
+ \fn QGraphicsEllipseItem *QGraphicsScene::addEllipse(qreal x, qreal y, qreal w, qreal h, const QPen &pen, const QBrush &brush)
+ \since 4.3
+
+ This convenience function is equivalent to calling addEllipse(QRectF(\a x,
+ \a y, \a w, \a h), \a pen, \a brush).
+*/
+
+/*!
+ Creates and adds a line item to the scene, and returns the item
+ pointer. The geometry of the line is defined by \a line, and its pen
+ is initialized to \a pen.
+
+ Note that the item's geometry is provided in item coordinates, and its
+ position is initialized to (0, 0).
+
+ If the item is visible (i.e., QGraphicsItem::isVisible() returns true),
+ QGraphicsScene will emit changed() once control goes back to the event
+ loop.
+
+ \sa addEllipse(), addPath(), addPixmap(), addRect(), addText(), addItem(),
+ addWidget()
+*/
+QGraphicsLineItem *QGraphicsScene::addLine(const QLineF &line, const QPen &pen)
+{
+ QGraphicsLineItem *item = new QGraphicsLineItem(line);
+ item->setPen(pen);
+ addItem(item);
+ return item;
+}
+
+/*!
+ \fn QGraphicsLineItem *QGraphicsScene::addLine(qreal x1, qreal y1, qreal x2, qreal y2, const QPen &pen)
+ \since 4.3
+
+ This convenience function is equivalent to calling addLine(QLineF(\a x1,
+ \a y1, \a x2, \a y2), \a pen).
+*/
+
+/*!
+ Creates and adds a path item to the scene, and returns the item
+ pointer. The geometry of the path is defined by \a path, and its pen and
+ brush are initialized to \a pen and \a brush.
+
+ Note that the item's geometry is provided in item coordinates, and its
+ position is initialized to (0, 0).
+
+ If the item is visible (i.e., QGraphicsItem::isVisible() returns true),
+ QGraphicsScene will emit changed() once control goes back to the event
+ loop.
+
+ \sa addEllipse(), addLine(), addPixmap(), addRect(), addText(), addItem(),
+ addWidget()
+*/
+QGraphicsPathItem *QGraphicsScene::addPath(const QPainterPath &path, const QPen &pen, const QBrush &brush)
+{
+ QGraphicsPathItem *item = new QGraphicsPathItem(path);
+ item->setPen(pen);
+ item->setBrush(brush);
+ addItem(item);
+ return item;
+}
+
+/*!
+ Creates and adds a pixmap item to the scene, and returns the item
+ pointer. The pixmap is defined by \a pixmap.
+
+ Note that the item's geometry is provided in item coordinates, and its
+ position is initialized to (0, 0).
+
+ If the item is visible (i.e., QGraphicsItem::isVisible() returns true),
+ QGraphicsScene will emit changed() once control goes back to the event
+ loop.
+
+ \sa addEllipse(), addLine(), addPath(), addRect(), addText(), addItem(),
+ addWidget()
+*/
+QGraphicsPixmapItem *QGraphicsScene::addPixmap(const QPixmap &pixmap)
+{
+ QGraphicsPixmapItem *item = new QGraphicsPixmapItem(pixmap);
+ addItem(item);
+ return item;
+}
+
+/*!
+ Creates and adds a polygon item to the scene, and returns the item
+ pointer. The polygon is defined by \a polygon, and its pen and
+ brush are initialized to \a pen and \a brush.
+
+ Note that the item's geometry is provided in item coordinates, and its
+ position is initialized to (0, 0).
+
+ If the item is visible (i.e., QGraphicsItem::isVisible() returns true),
+ QGraphicsScene will emit changed() once control goes back to the event
+ loop.
+
+ \sa addEllipse(), addLine(), addPath(), addRect(), addText(), addItem(),
+ addWidget()
+*/
+QGraphicsPolygonItem *QGraphicsScene::addPolygon(const QPolygonF &polygon,
+ const QPen &pen, const QBrush &brush)
+{
+ QGraphicsPolygonItem *item = new QGraphicsPolygonItem(polygon);
+ item->setPen(pen);
+ item->setBrush(brush);
+ addItem(item);
+ return item;
+}
+
+/*!
+ Creates and adds a rectangle item to the scene, and returns the item
+ pointer. The geometry of the rectangle is defined by \a rect, and its pen
+ and brush are initialized to \a pen and \a brush.
+
+ Note that the item's geometry is provided in item coordinates, and its
+ position is initialized to (0, 0). For example, if a QRect(50, 50, 100,
+ 100) is added, its top-left corner will be at (50, 50) relative to the
+ origin in the items coordinate system.
+
+ If the item is visible (i.e., QGraphicsItem::isVisible() returns true),
+ QGraphicsScene will emit changed() once control goes back to the event
+ loop.
+
+ \sa addEllipse(), addLine(), addPixmap(), addPixmap(), addText(),
+ addItem(), addWidget()
+*/
+QGraphicsRectItem *QGraphicsScene::addRect(const QRectF &rect, const QPen &pen, const QBrush &brush)
+{
+ QGraphicsRectItem *item = new QGraphicsRectItem(rect);
+ item->setPen(pen);
+ item->setBrush(brush);
+ addItem(item);
+ return item;
+}
+
+/*!
+ \fn QGraphicsRectItem *QGraphicsScene::addRect(qreal x, qreal y, qreal w, qreal h, const QPen &pen, const QBrush &brush)
+ \since 4.3
+
+ This convenience function is equivalent to calling addRect(QRectF(\a x,
+ \a y, \a w, \a h), \a pen, \a brush).
+*/
+
+/*!
+ Creates and adds a text item to the scene, and returns the item
+ pointer. The text string is initialized to \a text, and its font
+ is initialized to \a font.
+
+ The item's position is initialized to (0, 0).
+
+ If the item is visible (i.e., QGraphicsItem::isVisible() returns true),
+ QGraphicsScene will emit changed() once control goes back to the event
+ loop.
+
+ \sa addEllipse(), addLine(), addPixmap(), addPixmap(), addRect(),
+ addItem(), addWidget()
+*/
+QGraphicsTextItem *QGraphicsScene::addText(const QString &text, const QFont &font)
+{
+ QGraphicsTextItem *item = new QGraphicsTextItem(text);
+ item->setFont(font);
+ addItem(item);
+ return item;
+}
+
+/*!
+ Creates and adds a QGraphicsSimpleTextItem to the scene, and returns the
+ item pointer. The text string is initialized to \a text, and its font is
+ initialized to \a font.
+
+ The item's position is initialized to (0, 0).
+
+ If the item is visible (i.e., QGraphicsItem::isVisible() returns true),
+ QGraphicsScene will emit changed() once control goes back to the event
+ loop.
+
+ \sa addEllipse(), addLine(), addPixmap(), addPixmap(), addRect(),
+ addItem(), addWidget()
+*/
+QGraphicsSimpleTextItem *QGraphicsScene::addSimpleText(const QString &text, const QFont &font)
+{
+ QGraphicsSimpleTextItem *item = new QGraphicsSimpleTextItem(text);
+ item->setFont(font);
+ addItem(item);
+ return item;
+}
+
+/*!
+ Creates a new QGraphicsProxyWidget for \a widget, adds it to the scene,
+ and returns a pointer to the proxy. \a wFlags set the default window flags
+ for the embedding proxy widget.
+
+ The item's position is initialized to (0, 0).
+
+ If the item is visible (i.e., QGraphicsItem::isVisible() returns true),
+ QGraphicsScene will emit changed() once control goes back to the event
+ loop.
+
+ Note that widgets with the Qt::WA_PaintOnScreen widget attribute
+ set and widgets that wrap an external application or controller
+ are not supported. Examples are QGLWidget and QAxWidget.
+
+ \sa addEllipse(), addLine(), addPixmap(), addPixmap(), addRect(),
+ addText(), addSimpleText(), addItem()
+*/
+QGraphicsProxyWidget *QGraphicsScene::addWidget(QWidget *widget, Qt::WindowFlags wFlags)
+{
+ QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(0, wFlags);
+ proxy->setWidget(widget);
+ addItem(proxy);
+ return proxy;
+}
+
+/*!
+ Removes the item \a item and all its children from the scene. The
+ ownership of \a item is passed on to the caller (i.e.,
+ QGraphicsScene will no longer delete \a item when destroyed).
+
+ \sa addItem()
+*/
+void QGraphicsScene::removeItem(QGraphicsItem *item)
+{
+ // ### Refactoring: This function shares much functionality with _q_removeItemLater()
+ Q_D(QGraphicsScene);
+ if (!item) {
+ qWarning("QGraphicsScene::removeItem: cannot remove 0-item");
+ return;
+ }
+ if (item->scene() != this) {
+ qWarning("QGraphicsScene::removeItem: item %p's scene (%p)"
+ " is different from this scene (%p)",
+ item, item->scene(), this);
+ return;
+ }
+
+ // Notify the item that it's scene is changing to 0, allowing the item to
+ // react.
+ const QVariant newSceneVariant(item->itemChange(QGraphicsItem::ItemSceneChange,
+ QVariant::fromValue<QGraphicsScene *>(0)));
+ QGraphicsScene *targetScene = qvariant_cast<QGraphicsScene *>(newSceneVariant);
+ if (targetScene != 0 && targetScene != this) {
+ targetScene->addItem(item);
+ return;
+ }
+
+ d->removeItemHelper(item);
+
+ // Deliver post-change notification
+ item->itemChange(QGraphicsItem::ItemSceneHasChanged, newSceneVariant);
+
+ d->updateInputMethodSensitivityInViews();
+}
+
+/*!
+ When the scene is active, this functions returns the scene's current focus
+ item, or 0 if no item currently has focus. When the scene is inactive, this
+ functions returns the item that will gain input focus when the scene becomes
+ active.
+
+ The focus item receives keyboard input when the scene receives a
+ key event.
+
+ \sa setFocusItem(), QGraphicsItem::hasFocus(), isActive()
+*/
+QGraphicsItem *QGraphicsScene::focusItem() const
+{
+ Q_D(const QGraphicsScene);
+ return isActive() ? d->focusItem : d->passiveFocusItem;
+}
+
+/*!
+ Sets the scene's focus item to \a item, with the focus reason \a
+ focusReason, after removing focus from any previous item that may have had
+ focus.
+
+ If \a item is 0, or if it either does not accept focus (i.e., it does not
+ have the QGraphicsItem::ItemIsFocusable flag enabled), or is not visible
+ or not enabled, this function only removes focus from any previous
+ focusitem.
+
+ If item is not 0, and the scene does not currently have focus (i.e.,
+ hasFocus() returns false), this function will call setFocus()
+ automatically.
+
+ \sa focusItem(), hasFocus(), setFocus()
+*/
+void QGraphicsScene::setFocusItem(QGraphicsItem *item, Qt::FocusReason focusReason)
+{
+ Q_D(QGraphicsScene);
+ if (item)
+ item->setFocus(focusReason);
+ else
+ d->setFocusItemHelper(item, focusReason);
+}
+
+/*!
+ Returns true if the scene has focus; otherwise returns false. If the scene
+ has focus, it will will forward key events from QKeyEvent to any item that
+ has focus.
+
+ \sa setFocus(), setFocusItem()
+*/
+bool QGraphicsScene::hasFocus() const
+{
+ Q_D(const QGraphicsScene);
+ return d->hasFocus;
+}
+
+/*!
+ Sets focus on the scene by sending a QFocusEvent to the scene, passing \a
+ focusReason as the reason. If the scene regains focus after having
+ previously lost it while an item had focus, the last focus item will
+ receive focus with \a focusReason as the reason.
+
+ If the scene already has focus, this function does nothing.
+
+ \sa hasFocus(), clearFocus(), setFocusItem()
+*/
+void QGraphicsScene::setFocus(Qt::FocusReason focusReason)
+{
+ Q_D(QGraphicsScene);
+ if (d->hasFocus || !isActive())
+ return;
+ QFocusEvent event(QEvent::FocusIn, focusReason);
+ QCoreApplication::sendEvent(this, &event);
+}
+
+/*!
+ Clears focus from the scene. If any item has focus when this function is
+ called, it will lose focus, and regain focus again once the scene regains
+ focus.
+
+ A scene that does not have focus ignores key events.
+
+ \sa hasFocus(), setFocus(), setFocusItem()
+*/
+void QGraphicsScene::clearFocus()
+{
+ Q_D(QGraphicsScene);
+ if (d->hasFocus) {
+ d->hasFocus = false;
+ d->passiveFocusItem = d->focusItem;
+ setFocusItem(0, Qt::OtherFocusReason);
+ }
+}
+
+/*!
+ \property QGraphicsScene::stickyFocus
+ \brief whether clicking into the scene background will clear focus
+
+ \since 4.6
+
+ In a QGraphicsScene with stickyFocus set to true, focus will remain
+ unchanged when the user clicks into the scene background or on an item
+ that does not accept focus. Otherwise, focus will be cleared.
+
+ By default, this property is false.
+
+ Focus changes in response to a mouse press. You can reimplement
+ mousePressEvent() in a subclass of QGraphicsScene to toggle this property
+ based on where the user has clicked.
+
+ \sa clearFocus(), setFocusItem()
+*/
+void QGraphicsScene::setStickyFocus(bool enabled)
+{
+ Q_D(QGraphicsScene);
+ d->stickyFocus = enabled;
+}
+bool QGraphicsScene::stickyFocus() const
+{
+ Q_D(const QGraphicsScene);
+ return d->stickyFocus;
+}
+
+/*!
+ Returns the current mouse grabber item, or 0 if no item is currently
+ grabbing the mouse. The mouse grabber item is the item that receives all
+ mouse events sent to the scene.
+
+ An item becomes a mouse grabber when it receives and accepts a
+ mouse press event, and it stays the mouse grabber until either of
+ the following events occur:
+
+ \list
+ \o If the item receives a mouse release event when there are no other
+ buttons pressed, it loses the mouse grab.
+ \o If the item becomes invisible (i.e., someone calls \c {item->setVisible(false)}),
+ or if it becomes disabled (i.e., someone calls \c {item->setEnabled(false)}),
+ it loses the mouse grab.
+ \o If the item is removed from the scene, it loses the mouse grab.
+ \endlist
+
+ If the item loses its mouse grab, the scene will ignore all mouse events
+ until a new item grabs the mouse (i.e., until a new item receives a mouse
+ press event).
+*/
+QGraphicsItem *QGraphicsScene::mouseGrabberItem() const
+{
+ Q_D(const QGraphicsScene);
+ return !d->mouseGrabberItems.isEmpty() ? d->mouseGrabberItems.last() : 0;
+}
+
+/*!
+ \property QGraphicsScene::backgroundBrush
+ \brief the background brush of the scene.
+
+ Set this property to changes the scene's background to a different color,
+ gradient or texture. The default background brush is Qt::NoBrush. The
+ background is drawn before (behind) the items.
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp 3
+
+ QGraphicsScene::render() calls drawBackground() to draw the scene
+ background. For more detailed control over how the background is drawn,
+ you can reimplement drawBackground() in a subclass of QGraphicsScene.
+*/
+QBrush QGraphicsScene::backgroundBrush() const
+{
+ Q_D(const QGraphicsScene);
+ return d->backgroundBrush;
+}
+void QGraphicsScene::setBackgroundBrush(const QBrush &brush)
+{
+ Q_D(QGraphicsScene);
+ d->backgroundBrush = brush;
+ foreach (QGraphicsView *view, d->views) {
+ view->resetCachedContent();
+ view->viewport()->update();
+ }
+ update();
+}
+
+/*!
+ \property QGraphicsScene::foregroundBrush
+ \brief the foreground brush of the scene.
+
+ Change this property to set the scene's foreground to a different
+ color, gradient or texture.
+
+ The foreground is drawn after (on top of) the items. The default
+ foreground brush is Qt::NoBrush ( i.e. the foreground is not
+ drawn).
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp 4
+
+ QGraphicsScene::render() calls drawForeground() to draw the scene
+ foreground. For more detailed control over how the foreground is
+ drawn, you can reimplement the drawForeground() function in a
+ QGraphicsScene subclass.
+*/
+QBrush QGraphicsScene::foregroundBrush() const
+{
+ Q_D(const QGraphicsScene);
+ return d->foregroundBrush;
+}
+void QGraphicsScene::setForegroundBrush(const QBrush &brush)
+{
+ Q_D(QGraphicsScene);
+ d->foregroundBrush = brush;
+ foreach (QGraphicsView *view, views())
+ view->viewport()->update();
+ update();
+}
+
+/*!
+ This method is used by input methods to query a set of properties of
+ the scene to be able to support complex input method operations as support
+ for surrounding text and reconversions.
+
+ The \a query parameter specifies which property is queried.
+
+ \sa QWidget::inputMethodQuery()
+*/
+QVariant QGraphicsScene::inputMethodQuery(Qt::InputMethodQuery query) const
+{
+ Q_D(const QGraphicsScene);
+ if (!d->focusItem || !(d->focusItem->flags() & QGraphicsItem::ItemAcceptsInputMethod))
+ return QVariant();
+ const QTransform matrix = d->focusItem->sceneTransform();
+ QVariant value = d->focusItem->inputMethodQuery(query);
+ if (value.type() == QVariant::RectF)
+ value = matrix.mapRect(value.toRectF());
+ else if (value.type() == QVariant::PointF)
+ value = matrix.map(value.toPointF());
+ else if (value.type() == QVariant::Rect)
+ value = matrix.mapRect(value.toRect());
+ else if (value.type() == QVariant::Point)
+ value = matrix.map(value.toPoint());
+ return value;
+}
+
+/*!
+ \fn void QGraphicsScene::update(const QRectF &rect)
+ Schedules a redraw of the area \a rect on the scene.
+
+ \sa sceneRect(), changed()
+*/
+void QGraphicsScene::update(const QRectF &rect)
+{
+ Q_D(QGraphicsScene);
+ if (d->updateAll || (rect.isEmpty() && !rect.isNull()))
+ return;
+
+ // Check if anyone's connected; if not, we can send updates directly to
+ // the views. Otherwise or if there are no views, use old behavior.
+ bool directUpdates = !(d->isSignalConnected(d->changedSignalIndex)) && !d->views.isEmpty();
+ if (rect.isNull()) {
+ d->updateAll = true;
+ d->updatedRects.clear();
+ if (directUpdates) {
+ // Update all views.
+ for (int i = 0; i < d->views.size(); ++i)
+ d->views.at(i)->d_func()->fullUpdatePending = true;
+ }
+ } else {
+ if (directUpdates) {
+ // Update all views.
+ for (int i = 0; i < d->views.size(); ++i) {
+ QGraphicsView *view = d->views.at(i);
+ if (view->isTransformed())
+ view->d_func()->updateRectF(view->viewportTransform().mapRect(rect));
+ else
+ view->d_func()->updateRectF(rect);
+ }
+ } else {
+ d->updatedRects << rect;
+ }
+ }
+
+ if (!d->calledEmitUpdated) {
+ d->calledEmitUpdated = true;
+ QMetaObject::invokeMethod(this, "_q_emitUpdated", Qt::QueuedConnection);
+ }
+}
+
+/*!
+ \fn void QGraphicsScene::update(qreal x, qreal y, qreal w, qreal h)
+ \overload
+ \since 4.3
+
+ This function is equivalent to calling update(QRectF(\a x, \a y, \a w,
+ \a h));
+*/
+
+/*!
+ Invalidates and schedules a redraw of the \a layers in \a rect on the
+ scene. Any cached content in \a layers is unconditionally invalidated and
+ redrawn.
+
+ You can use this function overload to notify QGraphicsScene of changes to
+ the background or the foreground of the scene. This function is commonly
+ used for scenes with tile-based backgrounds to notify changes when
+ QGraphicsView has enabled
+ \l{QGraphicsView::CacheBackground}{CacheBackground}.
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsscene.cpp 5
+
+ Note that QGraphicsView currently supports background caching only (see
+ QGraphicsView::CacheBackground). This function is equivalent to calling
+ update() if any layer but BackgroundLayer is passed.
+
+ \sa QGraphicsView::resetCachedContent()
+*/
+void QGraphicsScene::invalidate(const QRectF &rect, SceneLayers layers)
+{
+ foreach (QGraphicsView *view, views())
+ view->invalidateScene(rect, layers);
+ update(rect);
+}
+
+/*!
+ \fn void QGraphicsScene::invalidate(qreal x, qreal y, qreal w, qreal h, SceneLayers layers)
+ \overload
+ \since 4.3
+
+ This convenience function is equivalent to calling invalidate(QRectF(\a x, \a
+ y, \a w, \a h), \a layers);
+*/
+
+/*!
+ Returns a list of all the views that display this scene.
+
+ \sa QGraphicsView::scene()
+*/
+QList <QGraphicsView *> QGraphicsScene::views() const
+{
+ Q_D(const QGraphicsScene);
+ return d->views;
+}
+
+/*!
+ This slot \e advances the scene by one step, by calling
+ QGraphicsItem::advance() for all items on the scene. This is done in two
+ phases: in the first phase, all items are notified that the scene is about
+ to change, and in the second phase all items are notified that they can
+ move. In the first phase, QGraphicsItem::advance() is called passing a
+ value of 0 as an argument, and 1 is passed in the second phase.
+
+ \sa QGraphicsItem::advance(), QGraphicsItemAnimation, QTimeLine
+*/
+void QGraphicsScene::advance()
+{
+ for (int i = 0; i < 2; ++i) {
+ foreach (QGraphicsItem *item, items())
+ item->advance(i);
+ }
+}
+
+/*!
+ Processes the event \a event, and dispatches it to the respective
+ event handlers.
+
+ In addition to calling the convenience event handlers, this
+ function is responsible for converting mouse move events to hover
+ events for when there is no mouse grabber item. Hover events are
+ delivered directly to items; there is no convenience function for
+ them.
+
+ Unlike QWidget, QGraphicsScene does not have the convenience functions
+ \l{QWidget::}{enterEvent()} and \l{QWidget::}{leaveEvent()}. Use this
+ function to obtain those events instead.
+
+ \sa contextMenuEvent(), keyPressEvent(), keyReleaseEvent(),
+ mousePressEvent(), mouseMoveEvent(), mouseReleaseEvent(),
+ mouseDoubleClickEvent(), focusInEvent(), focusOutEvent()
+*/
+bool QGraphicsScene::event(QEvent *event)
+{
+ Q_D(QGraphicsScene);
+
+ switch (event->type()) {
+ case QEvent::GraphicsSceneMousePress:
+ case QEvent::GraphicsSceneMouseMove:
+ case QEvent::GraphicsSceneMouseRelease:
+ case QEvent::GraphicsSceneMouseDoubleClick:
+ case QEvent::GraphicsSceneHoverEnter:
+ case QEvent::GraphicsSceneHoverLeave:
+ case QEvent::GraphicsSceneHoverMove:
+ case QEvent::TouchBegin:
+ case QEvent::TouchUpdate:
+ case QEvent::TouchEnd:
+ // Reset the under-mouse list to ensure that this event gets fresh
+ // item-under-mouse data. Be careful about this list; if people delete
+ // items from inside event handlers, this list can quickly end up
+ // having stale pointers in it. We need to clear it before dispatching
+ // events that use it.
+ // ### this should only be cleared if we received a new mouse move event,
+ // which relies on us fixing the replay mechanism in QGraphicsView.
+ d->cachedItemsUnderMouse.clear();
+ default:
+ break;
+ }
+
+ switch (event->type()) {
+ case QEvent::GraphicsSceneDragEnter:
+ dragEnterEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
+ break;
+ case QEvent::GraphicsSceneDragMove:
+ dragMoveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
+ break;
+ case QEvent::GraphicsSceneDragLeave:
+ dragLeaveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
+ break;
+ case QEvent::GraphicsSceneDrop:
+ dropEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
+ break;
+ case QEvent::GraphicsSceneContextMenu:
+ contextMenuEvent(static_cast<QGraphicsSceneContextMenuEvent *>(event));
+ break;
+ case QEvent::KeyPress:
+ if (!d->focusItem) {
+ QKeyEvent *k = static_cast<QKeyEvent *>(event);
+ if (k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) {
+ if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier?
+ bool res = false;
+ if (k->key() == Qt::Key_Backtab
+ || (k->key() == Qt::Key_Tab && (k->modifiers() & Qt::ShiftModifier))) {
+ res = focusNextPrevChild(false);
+ } else if (k->key() == Qt::Key_Tab) {
+ res = focusNextPrevChild(true);
+ }
+ if (!res)
+ event->ignore();
+ return true;
+ }
+ }
+ }
+ keyPressEvent(static_cast<QKeyEvent *>(event));
+ break;
+ case QEvent::KeyRelease:
+ keyReleaseEvent(static_cast<QKeyEvent *>(event));
+ break;
+ case QEvent::ShortcutOverride: {
+ QGraphicsItem *parent = focusItem();
+ while (parent) {
+ d->sendEvent(parent, event);
+ if (event->isAccepted())
+ return true;
+ parent = parent->parentItem();
+ }
+ }
+ return false;
+ case QEvent::GraphicsSceneMouseMove:
+ {
+ QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);
+ d->lastSceneMousePos = mouseEvent->scenePos();
+ mouseMoveEvent(mouseEvent);
+ break;
+ }
+ case QEvent::GraphicsSceneMousePress:
+ mousePressEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
+ break;
+ case QEvent::GraphicsSceneMouseRelease:
+ mouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
+ break;
+ case QEvent::GraphicsSceneMouseDoubleClick:
+ mouseDoubleClickEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
+ break;
+ case QEvent::GraphicsSceneWheel:
+ wheelEvent(static_cast<QGraphicsSceneWheelEvent *>(event));
+ break;
+ case QEvent::FocusIn:
+ focusInEvent(static_cast<QFocusEvent *>(event));
+ break;
+ case QEvent::FocusOut:
+ focusOutEvent(static_cast<QFocusEvent *>(event));
+ break;
+ case QEvent::GraphicsSceneHoverEnter:
+ case QEvent::GraphicsSceneHoverLeave:
+ case QEvent::GraphicsSceneHoverMove:
+ {
+ QGraphicsSceneHoverEvent *hoverEvent = static_cast<QGraphicsSceneHoverEvent *>(event);
+ d->lastSceneMousePos = hoverEvent->scenePos();
+ d->dispatchHoverEvent(hoverEvent);
+ break;
+ }
+ case QEvent::Leave:
+ // hackieshly unpacking the viewport pointer from the leave event.
+ d->leaveScene(reinterpret_cast<QWidget *>(event->d));
+ break;
+ case QEvent::GraphicsSceneHelp:
+ helpEvent(static_cast<QGraphicsSceneHelpEvent *>(event));
+ break;
+ case QEvent::InputMethod:
+ inputMethodEvent(static_cast<QInputMethodEvent *>(event));
+ break;
+ case QEvent::WindowActivate:
+ if (!d->activationRefCount++) {
+ if (d->lastActivePanel) {
+ // Activate the last panel.
+ d->setActivePanelHelper(d->lastActivePanel, true);
+ } else if (d->tabFocusFirst && d->tabFocusFirst->isPanel()) {
+ // Activate the panel of the first item in the tab focus
+ // chain.
+ d->setActivePanelHelper(d->tabFocusFirst, true);
+ } else {
+ // Activate all toplevel items.
+ QEvent event(QEvent::WindowActivate);
+ foreach (QGraphicsItem *item, items()) {
+ if (item->isVisible() && !item->isPanel() && !item->parentItem())
+ sendEvent(item, &event);
+ }
+ }
+ }
+ break;
+ case QEvent::WindowDeactivate:
+ if (!--d->activationRefCount) {
+ if (d->activePanel) {
+ // Deactivate the active panel (but keep it so we can
+ // reactivate it later).
+ QGraphicsItem *lastActivePanel = d->activePanel;
+ d->setActivePanelHelper(0, true);
+ d->lastActivePanel = lastActivePanel;
+ } else {
+ // Activate all toplevel items.
+ QEvent event(QEvent::WindowDeactivate);
+ foreach (QGraphicsItem *item, items()) {
+ if (item->isVisible() && !item->isPanel() && !item->parentItem())
+ sendEvent(item, &event);
+ }
+ }
+ }
+ break;
+ case QEvent::ApplicationFontChange: {
+ // Resolve the existing scene font.
+ d->resolveFont();
+ break;
+ }
+ case QEvent::FontChange:
+ // Update the entire scene when the font changes.
+ update();
+ break;
+ case QEvent::ApplicationPaletteChange: {
+ // Resolve the existing scene palette.
+ d->resolvePalette();
+ break;
+ }
+ case QEvent::PaletteChange:
+ // Update the entire scene when the palette changes.
+ update();
+ break;
+ case QEvent::StyleChange:
+ // Reresolve all widgets' styles. Update all top-level widgets'
+ // geometries that do not have an explicit style set.
+ update();
+ break;
+ case QEvent::TouchBegin:
+ case QEvent::TouchUpdate:
+ case QEvent::TouchEnd:
+ d->touchEventHandler(static_cast<QTouchEvent *>(event));
+ break;
+#ifndef QT_NO_GESTURES
+ case QEvent::Gesture:
+ case QEvent::GestureOverride:
+ d->gestureEventHandler(static_cast<QGestureEvent *>(event));
+ break;
+#endif // QT_NO_GESTURES
+ default:
+ return QObject::event(event);
+ }
+ return true;
+}
+
+/*!
+ \reimp
+
+ QGraphicsScene filters QApplication's events to detect palette and font
+ changes.
+*/
+bool QGraphicsScene::eventFilter(QObject *watched, QEvent *event)
+{
+ if (watched != qApp)
+ return false;
+
+ switch (event->type()) {
+ case QEvent::ApplicationPaletteChange:
+ QApplication::postEvent(this, new QEvent(QEvent::ApplicationPaletteChange));
+ break;
+ case QEvent::ApplicationFontChange:
+ QApplication::postEvent(this, new QEvent(QEvent::ApplicationFontChange));
+ break;
+ default:
+ break;
+ }
+ return false;
+}
+
+/*!
+ This event handler, for event \a contextMenuEvent, can be reimplemented in
+ a subclass to receive context menu events. The default implementation
+ forwards the event to the topmost item that accepts context menu events at
+ the position of the event. If no items accept context menu events at this
+ position, the event is ignored.
+
+ \sa QGraphicsItem::contextMenuEvent()
+*/
+void QGraphicsScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent)
+{
+ Q_D(QGraphicsScene);
+ // Ignore by default.
+ contextMenuEvent->ignore();
+
+ // Send the event to all items at this position until one item accepts the
+ // event.
+ foreach (QGraphicsItem *item, d->itemsAtPosition(contextMenuEvent->screenPos(),
+ contextMenuEvent->scenePos(),
+ contextMenuEvent->widget())) {
+ contextMenuEvent->setPos(item->d_ptr->genericMapFromScene(contextMenuEvent->scenePos(),
+ contextMenuEvent->widget()));
+ contextMenuEvent->accept();
+ if (!d->sendEvent(item, contextMenuEvent))
+ break;
+
+ if (contextMenuEvent->isAccepted())
+ break;
+ }
+}
+
+/*!
+ This event handler, for event \a event, can be reimplemented in a subclass
+ to receive drag enter events for the scene.
+
+ The default implementation accepts the event and prepares the scene to
+ accept drag move events.
+
+ \sa QGraphicsItem::dragEnterEvent(), dragMoveEvent(), dragLeaveEvent(),
+ dropEvent()
+*/
+void QGraphicsScene::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
+{
+ Q_D(QGraphicsScene);
+ d->dragDropItem = 0;
+ d->lastDropAction = Qt::IgnoreAction;
+ event->accept();
+}
+
+/*!
+ This event handler, for event \a event, can be reimplemented in a subclass
+ to receive drag move events for the scene.
+
+ \sa QGraphicsItem::dragMoveEvent(), dragEnterEvent(), dragLeaveEvent(),
+ dropEvent()
+*/
+void QGraphicsScene::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
+{
+ Q_D(QGraphicsScene);
+ event->ignore();
+
+ if (!d->mouseGrabberItems.isEmpty()) {
+ // Mouse grabbers that start drag events lose the mouse grab.
+ d->clearMouseGrabber();
+ d->mouseGrabberButtonDownPos.clear();
+ d->mouseGrabberButtonDownScenePos.clear();
+ d->mouseGrabberButtonDownScreenPos.clear();
+ }
+
+ bool eventDelivered = false;
+
+ // Find the topmost enabled items under the cursor. They are all
+ // candidates for accepting drag & drop events.
+ foreach (QGraphicsItem *item, d->itemsAtPosition(event->screenPos(),
+ event->scenePos(),
+ event->widget())) {
+ if (!item->isEnabled() || !item->acceptDrops())
+ continue;
+
+ if (item != d->dragDropItem) {
+ // Enter the new drag drop item. If it accepts the event, we send
+ // the leave to the parent item.
+ QGraphicsSceneDragDropEvent dragEnter(QEvent::GraphicsSceneDragEnter);
+ d->cloneDragDropEvent(&dragEnter, event);
+ dragEnter.setDropAction(event->proposedAction());
+ d->sendDragDropEvent(item, &dragEnter);
+ event->setAccepted(dragEnter.isAccepted());
+ event->setDropAction(dragEnter.dropAction());
+ if (!event->isAccepted()) {
+ // Propagate to the item under
+ continue;
+ }
+
+ d->lastDropAction = event->dropAction();
+
+ if (d->dragDropItem) {
+ // Leave the last drag drop item. A perfect implementation
+ // would set the position of this event to the point where
+ // this event and the last event intersect with the item's
+ // shape, but that's not easy to do. :-)
+ QGraphicsSceneDragDropEvent dragLeave(QEvent::GraphicsSceneDragLeave);
+ d->cloneDragDropEvent(&dragLeave, event);
+ d->sendDragDropEvent(d->dragDropItem, &dragLeave);
+ }
+
+ // We've got a new drag & drop item
+ d->dragDropItem = item;
+ }
+
+ // Send the move event.
+ event->setDropAction(d->lastDropAction);
+ event->accept();
+ d->sendDragDropEvent(item, event);
+ if (event->isAccepted())
+ d->lastDropAction = event->dropAction();
+ eventDelivered = true;
+ break;
+ }
+
+ if (!eventDelivered) {
+ if (d->dragDropItem) {
+ // Leave the last drag drop item
+ QGraphicsSceneDragDropEvent dragLeave(QEvent::GraphicsSceneDragLeave);
+ d->cloneDragDropEvent(&dragLeave, event);
+ d->sendDragDropEvent(d->dragDropItem, &dragLeave);
+ d->dragDropItem = 0;
+ }
+ // Propagate
+ event->setDropAction(Qt::IgnoreAction);
+ }
+}
+
+/*!
+ This event handler, for event \a event, can be reimplemented in a subclass
+ to receive drag leave events for the scene.
+
+ \sa QGraphicsItem::dragLeaveEvent(), dragEnterEvent(), dragMoveEvent(),
+ dropEvent()
+*/
+void QGraphicsScene::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
+{
+ Q_D(QGraphicsScene);
+ if (d->dragDropItem) {
+ // Leave the last drag drop item
+ d->sendDragDropEvent(d->dragDropItem, event);
+ d->dragDropItem = 0;
+ }
+}
+
+/*!
+ This event handler, for event \a event, can be reimplemented in a subclass
+ to receive drop events for the scene.
+
+ \sa QGraphicsItem::dropEvent(), dragEnterEvent(), dragMoveEvent(),
+ dragLeaveEvent()
+*/
+void QGraphicsScene::dropEvent(QGraphicsSceneDragDropEvent *event)
+{
+ Q_UNUSED(event);
+ Q_D(QGraphicsScene);
+ if (d->dragDropItem) {
+ // Drop on the last drag drop item
+ d->sendDragDropEvent(d->dragDropItem, event);
+ d->dragDropItem = 0;
+ }
+}
+
+/*!
+ This event handler, for event \a focusEvent, can be reimplemented in a
+ subclass to receive focus in events.
+
+ The default implementation sets focus on the scene, and then on the last
+ focus item.
+
+ \sa QGraphicsItem::focusOutEvent()
+*/
+void QGraphicsScene::focusInEvent(QFocusEvent *focusEvent)
+{
+ Q_D(QGraphicsScene);
+
+ d->hasFocus = true;
+ switch (focusEvent->reason()) {
+ case Qt::TabFocusReason:
+ if (!focusNextPrevChild(true))
+ focusEvent->ignore();
+ break;
+ case Qt::BacktabFocusReason:
+ if (!focusNextPrevChild(false))
+ focusEvent->ignore();
+ break;
+ default:
+ if (d->passiveFocusItem) {
+ // Set focus on the last focus item
+ setFocusItem(d->passiveFocusItem, focusEvent->reason());
+ }
+ break;
+ }
+}
+
+/*!
+ This event handler, for event \a focusEvent, can be reimplemented in a
+ subclass to receive focus out events.
+
+ The default implementation removes focus from any focus item, then removes
+ focus from the scene.
+
+ \sa QGraphicsItem::focusInEvent()
+*/
+void QGraphicsScene::focusOutEvent(QFocusEvent *focusEvent)
+{
+ Q_D(QGraphicsScene);
+ d->hasFocus = false;
+ d->passiveFocusItem = d->focusItem;
+ setFocusItem(0, focusEvent->reason());
+
+ // Remove all popups when the scene loses focus.
+ if (!d->popupWidgets.isEmpty())
+ d->removePopup(d->popupWidgets.first());
+}
+
+/*!
+ This event handler, for event \a helpEvent, can be
+ reimplemented in a subclass to receive help events. The events
+ are of type QEvent::ToolTip, which are created when a tooltip is
+ requested.
+
+ The default implementation shows the tooltip of the topmost
+ item, i.e., the item with the highest z-value, at the mouse
+ cursor position. If no item has a tooltip set, this function
+ does nothing.
+
+ \sa QGraphicsItem::toolTip(), QGraphicsSceneHelpEvent
+*/
+void QGraphicsScene::helpEvent(QGraphicsSceneHelpEvent *helpEvent)
+{
+#ifdef QT_NO_TOOLTIP
+ Q_UNUSED(helpEvent);
+#else
+ // Find the first item that does tooltips
+ Q_D(QGraphicsScene);
+ QList<QGraphicsItem *> itemsAtPos = d->itemsAtPosition(helpEvent->screenPos(),
+ helpEvent->scenePos(),
+ helpEvent->widget());
+ QGraphicsItem *toolTipItem = 0;
+ for (int i = 0; i < itemsAtPos.size(); ++i) {
+ QGraphicsItem *tmp = itemsAtPos.at(i);
+ if (tmp->d_func()->isProxyWidget()) {
+ // if the item is a proxy widget, the event is forwarded to it
+ sendEvent(tmp, helpEvent);
+ if (helpEvent->isAccepted())
+ return;
+ }
+ if (!tmp->toolTip().isEmpty()) {
+ toolTipItem = tmp;
+ break;
+ }
+ }
+
+ // Show or hide the tooltip
+ QString text;
+ QPoint point;
+ if (toolTipItem && !toolTipItem->toolTip().isEmpty()) {
+ text = toolTipItem->toolTip();
+ point = helpEvent->screenPos();
+ }
+ QToolTip::showText(point, text, helpEvent->widget());
+ helpEvent->setAccepted(!text.isEmpty());
+#endif
+}
+
+bool QGraphicsScenePrivate::itemAcceptsHoverEvents_helper(const QGraphicsItem *item) const
+{
+ return (item->d_ptr->acceptsHover
+ || (item->d_ptr->isWidget
+ && static_cast<const QGraphicsWidget *>(item)->d_func()->hasDecoration()))
+ && !item->isBlockedByModalPanel();
+}
+
+/*!
+ This event handler, for event \a hoverEvent, can be reimplemented in a
+ subclass to receive hover enter events. The default implementation
+ forwards the event to the topmost item that accepts hover events at the
+ scene position from the event.
+
+ \sa QGraphicsItem::hoverEvent(), QGraphicsItem::setAcceptHoverEvents()
+*/
+bool QGraphicsScenePrivate::dispatchHoverEvent(QGraphicsSceneHoverEvent *hoverEvent)
+{
+ if (allItemsIgnoreHoverEvents)
+ return false;
+
+ // Find the first item that accepts hover events, reusing earlier
+ // calculated data is possible.
+ if (cachedItemsUnderMouse.isEmpty()) {
+ cachedItemsUnderMouse = itemsAtPosition(hoverEvent->screenPos(),
+ hoverEvent->scenePos(),
+ hoverEvent->widget());
+ }
+
+ QGraphicsItem *item = 0;
+ for (int i = 0; i < cachedItemsUnderMouse.size(); ++i) {
+ QGraphicsItem *tmp = cachedItemsUnderMouse.at(i);
+ if (itemAcceptsHoverEvents_helper(tmp)) {
+ item = tmp;
+ break;
+ }
+ }
+
+ // Find the common ancestor item for the new topmost hoverItem and the
+ // last item in the hoverItem list.
+ QGraphicsItem *commonAncestorItem = (item && !hoverItems.isEmpty()) ? item->commonAncestorItem(hoverItems.last()) : 0;
+ while (commonAncestorItem && !itemAcceptsHoverEvents_helper(commonAncestorItem))
+ commonAncestorItem = commonAncestorItem->parentItem();
+ if (commonAncestorItem && commonAncestorItem->panel() != item->panel()) {
+ // The common ancestor isn't in the same panel as the two hovered
+ // items.
+ commonAncestorItem = 0;
+ }
+
+ // Check if the common ancestor item is known.
+ int index = commonAncestorItem ? hoverItems.indexOf(commonAncestorItem) : -1;
+ // Send hover leaves to any existing hovered children of the common
+ // ancestor item.
+ for (int i = hoverItems.size() - 1; i > index; --i) {
+ QGraphicsItem *lastItem = hoverItems.takeLast();
+ if (itemAcceptsHoverEvents_helper(lastItem))
+ sendHoverEvent(QEvent::GraphicsSceneHoverLeave, lastItem, hoverEvent);
+ }
+
+ // Item is a child of a known item. Generate enter events for the
+ // missing links.
+ QList<QGraphicsItem *> parents;
+ QGraphicsItem *parent = item;
+ while (parent && parent != commonAncestorItem) {
+ parents.prepend(parent);
+ if (parent->isPanel()) {
+ // Stop at the panel - we don't deliver beyond this point.
+ break;
+ }
+ parent = parent->parentItem();
+ }
+ for (int i = 0; i < parents.size(); ++i) {
+ parent = parents.at(i);
+ hoverItems << parent;
+ if (itemAcceptsHoverEvents_helper(parent))
+ sendHoverEvent(QEvent::GraphicsSceneHoverEnter, parent, hoverEvent);
+ }
+
+ // Generate a move event for the item itself
+ if (item
+ && !hoverItems.isEmpty()
+ && item == hoverItems.last()) {
+ sendHoverEvent(QEvent::GraphicsSceneHoverMove, item, hoverEvent);
+ return true;
+ }
+ return false;
+}
+
+/*!
+ \internal
+
+ Handles all actions necessary to clean up the scene when the mouse leaves
+ the view.
+*/
+void QGraphicsScenePrivate::leaveScene(QWidget *viewport)
+{
+#ifndef QT_NO_TOOLTIP
+ QToolTip::hideText();
+#endif
+ QGraphicsView *view = qobject_cast<QGraphicsView *>(viewport->parent());
+ // Send HoverLeave events to all existing hover items, topmost first.
+ QGraphicsSceneHoverEvent hoverEvent;
+ hoverEvent.setWidget(viewport);
+
+ if (view) {
+ QPoint cursorPos = QCursor::pos();
+ hoverEvent.setScenePos(view->mapToScene(viewport->mapFromGlobal(cursorPos)));
+ hoverEvent.setLastScenePos(hoverEvent.scenePos());
+ hoverEvent.setScreenPos(cursorPos);
+ hoverEvent.setLastScreenPos(hoverEvent.screenPos());
+ }
+
+ while (!hoverItems.isEmpty()) {
+ QGraphicsItem *lastItem = hoverItems.takeLast();
+ if (itemAcceptsHoverEvents_helper(lastItem))
+ sendHoverEvent(QEvent::GraphicsSceneHoverLeave, lastItem, &hoverEvent);
+ }
+}
+
+/*!
+ This event handler, for event \a keyEvent, can be reimplemented in a
+ subclass to receive keypress events. The default implementation forwards
+ the event to current focus item.
+
+ \sa QGraphicsItem::keyPressEvent(), focusItem()
+*/
+void QGraphicsScene::keyPressEvent(QKeyEvent *keyEvent)
+{
+ // ### Merge this function with keyReleaseEvent; they are identical
+ // ### (except this comment).
+ Q_D(QGraphicsScene);
+ QGraphicsItem *item = !d->keyboardGrabberItems.isEmpty() ? d->keyboardGrabberItems.last() : 0;
+ if (!item)
+ item = focusItem();
+ if (item) {
+ QGraphicsItem *p = item;
+ do {
+ // Accept the event by default
+ keyEvent->accept();
+ // Send it; QGraphicsItem::keyPressEvent ignores it. If the event
+ // is filtered out, stop propagating it.
+ if (p->isBlockedByModalPanel())
+ break;
+ if (!d->sendEvent(p, keyEvent))
+ break;
+ } while (!keyEvent->isAccepted() && !p->isPanel() && (p = p->parentItem()));
+ } else {
+ keyEvent->ignore();
+ }
+}
+
+/*!
+ This event handler, for event \a keyEvent, can be reimplemented in a
+ subclass to receive key release events. The default implementation
+ forwards the event to current focus item.
+
+ \sa QGraphicsItem::keyReleaseEvent(), focusItem()
+*/
+void QGraphicsScene::keyReleaseEvent(QKeyEvent *keyEvent)
+{
+ // ### Merge this function with keyPressEvent; they are identical (except
+ // ### this comment).
+ Q_D(QGraphicsScene);
+ QGraphicsItem *item = !d->keyboardGrabberItems.isEmpty() ? d->keyboardGrabberItems.last() : 0;
+ if (!item)
+ item = focusItem();
+ if (item) {
+ QGraphicsItem *p = item;
+ do {
+ // Accept the event by default
+ keyEvent->accept();
+ // Send it; QGraphicsItem::keyPressEvent ignores it. If the event
+ // is filtered out, stop propagating it.
+ if (p->isBlockedByModalPanel())
+ break;
+ if (!d->sendEvent(p, keyEvent))
+ break;
+ } while (!keyEvent->isAccepted() && !p->isPanel() && (p = p->parentItem()));
+ } else {
+ keyEvent->ignore();
+ }
+}
+
+/*!
+ This event handler, for event \a mouseEvent, can be reimplemented
+ in a subclass to receive mouse press events for the scene.
+
+ The default implementation depends on the state of the scene. If
+ there is a mouse grabber item, then the event is sent to the mouse
+ grabber. Otherwise, it is forwarded to the topmost item that
+ accepts mouse events at the scene position from the event, and
+ that item promptly becomes the mouse grabber item.
+
+ If there is no item at the given position on the scene, the
+ selection area is reset, any focus item loses its input focus, and
+ the event is then ignored.
+
+ \sa QGraphicsItem::mousePressEvent(),
+ QGraphicsItem::setAcceptedMouseButtons()
+*/
+void QGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
+{
+ Q_D(QGraphicsScene);
+ if (d->mouseGrabberItems.isEmpty()) {
+ // Dispatch hover events
+ QGraphicsSceneHoverEvent hover;
+ _q_hoverFromMouseEvent(&hover, mouseEvent);
+ d->dispatchHoverEvent(&hover);
+ }
+
+ d->mousePressEventHandler(mouseEvent);
+}
+
+/*!
+ This event handler, for event \a mouseEvent, can be reimplemented
+ in a subclass to receive mouse move events for the scene.
+
+ The default implementation depends on the mouse grabber state. If there is
+ a mouse grabber item, the event is sent to the mouse grabber. If there
+ are any items that accept hover events at the current position, the event
+ is translated into a hover event and accepted; otherwise it's ignored.
+
+ \sa QGraphicsItem::mousePressEvent(), QGraphicsItem::mouseReleaseEvent(),
+ QGraphicsItem::mouseDoubleClickEvent(), QGraphicsItem::setAcceptedMouseButtons()
+*/
+void QGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
+{
+ Q_D(QGraphicsScene);
+ if (d->mouseGrabberItems.isEmpty()) {
+ if (mouseEvent->buttons())
+ return;
+ QGraphicsSceneHoverEvent hover;
+ _q_hoverFromMouseEvent(&hover, mouseEvent);
+ mouseEvent->setAccepted(d->dispatchHoverEvent(&hover));
+ return;
+ }
+
+ // Forward the event to the mouse grabber
+ d->sendMouseEvent(mouseEvent);
+ mouseEvent->accept();
+}
+
+/*!
+ This event handler, for event \a mouseEvent, can be reimplemented
+ in a subclass to receive mouse release events for the scene.
+
+ The default implementation depends on the mouse grabber state. If
+ there is no mouse grabber, the event is ignored. Otherwise, if
+ there is a mouse grabber item, the event is sent to the mouse
+ grabber. If this mouse release represents the last pressed button
+ on the mouse, the mouse grabber item then loses the mouse grab.
+
+ \sa QGraphicsItem::mousePressEvent(), QGraphicsItem::mouseMoveEvent(),
+ QGraphicsItem::mouseDoubleClickEvent(), QGraphicsItem::setAcceptedMouseButtons()
+*/
+void QGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
+{
+ Q_D(QGraphicsScene);
+ if (d->mouseGrabberItems.isEmpty()) {
+ mouseEvent->ignore();
+ return;
+ }
+
+ // Forward the event to the mouse grabber
+ d->sendMouseEvent(mouseEvent);
+ mouseEvent->accept();
+
+ // Reset the mouse grabber when the last mouse button has been released.
+ if (!mouseEvent->buttons()) {
+ if (!d->mouseGrabberItems.isEmpty()) {
+ d->lastMouseGrabberItem = d->mouseGrabberItems.last();
+ if (d->lastMouseGrabberItemHasImplicitMouseGrab)
+ d->mouseGrabberItems.last()->ungrabMouse();
+ } else {
+ d->lastMouseGrabberItem = 0;
+ }
+
+ // Generate a hoverevent
+ QGraphicsSceneHoverEvent hoverEvent;
+ _q_hoverFromMouseEvent(&hoverEvent, mouseEvent);
+ d->dispatchHoverEvent(&hoverEvent);
+ }
+}
+
+/*!
+ This event handler, for event \a mouseEvent, can be reimplemented
+ in a subclass to receive mouse doubleclick events for the scene.
+
+ If someone doubleclicks on the scene, the scene will first receive
+ a mouse press event, followed by a release event (i.e., a click),
+ then a doubleclick event, and finally a release event. If the
+ doubleclick event is delivered to a different item than the one
+ that received the first press and release, it will be delivered as
+ a press event. However, tripleclick events are not delivered as
+ doubleclick events in this case.
+
+ The default implementation is similar to mousePressEvent().
+
+ \sa QGraphicsItem::mousePressEvent(), QGraphicsItem::mouseMoveEvent(),
+ QGraphicsItem::mouseReleaseEvent(), QGraphicsItem::setAcceptedMouseButtons()
+*/
+void QGraphicsScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *mouseEvent)
+{
+ Q_D(QGraphicsScene);
+ d->mousePressEventHandler(mouseEvent);
+}
+
+/*!
+ This event handler, for event \a wheelEvent, can be reimplemented in a
+ subclass to receive mouse wheel events for the scene.
+
+ By default, the event is delivered to the topmost visible item under the
+ cursor. If ignored, the event propagates to the item beneath, and again
+ until the event is accepted, or it reaches the scene. If no items accept
+ the event, it is ignored.
+
+ \sa QGraphicsItem::wheelEvent()
+*/
+void QGraphicsScene::wheelEvent(QGraphicsSceneWheelEvent *wheelEvent)
+{
+ Q_D(QGraphicsScene);
+ QList<QGraphicsItem *> wheelCandidates = d->itemsAtPosition(wheelEvent->screenPos(),
+ wheelEvent->scenePos(),
+ wheelEvent->widget());
+
+#ifdef Q_WS_MAC
+ // On Mac, ignore the event if the first item under the mouse is not the last opened
+ // popup (or one of its descendant)
+ if (!d->popupWidgets.isEmpty() && !wheelCandidates.isEmpty() && wheelCandidates.first() != d->popupWidgets.back() && !d->popupWidgets.back()->isAncestorOf(wheelCandidates.first())) {
+ wheelEvent->accept();
+ return;
+ }
+#else
+ // Find the first popup under the mouse (including the popup's descendants) starting from the last.
+ // Remove all popups after the one found, or all or them if no popup is under the mouse.
+ // Then continue with the event.
+ QList<QGraphicsWidget *>::const_iterator iter = d->popupWidgets.end();
+ while (--iter >= d->popupWidgets.begin() && !wheelCandidates.isEmpty()) {
+ if (wheelCandidates.first() == *iter || (*iter)->isAncestorOf(wheelCandidates.first()))
+ break;
+ d->removePopup(*iter);
+ }
+#endif
+
+ bool hasSetFocus = false;
+ foreach (QGraphicsItem *item, wheelCandidates) {
+ if (!hasSetFocus && item->isEnabled()
+ && ((item->flags() & QGraphicsItem::ItemIsFocusable) && item->d_ptr->mouseSetsFocus)) {
+ if (item->isWidget() && static_cast<QGraphicsWidget *>(item)->focusPolicy() == Qt::WheelFocus) {
+ hasSetFocus = true;
+ if (item != focusItem())
+ setFocusItem(item, Qt::MouseFocusReason);
+ }
+ }
+
+ wheelEvent->setPos(item->d_ptr->genericMapFromScene(wheelEvent->scenePos(),
+ wheelEvent->widget()));
+ wheelEvent->accept();
+ bool isPanel = item->isPanel();
+ d->sendEvent(item, wheelEvent);
+ if (isPanel || wheelEvent->isAccepted())
+ break;
+ }
+}
+
+/*!
+ This event handler, for event \a event, can be reimplemented in a
+ subclass to receive input method events for the scene.
+
+ The default implementation forwards the event to the focusItem().
+ If no item currently has focus or the current focus item does not
+ accept input methods, this function does nothing.
+
+ \sa QGraphicsItem::inputMethodEvent()
+*/
+void QGraphicsScene::inputMethodEvent(QInputMethodEvent *event)
+{
+ Q_D(QGraphicsScene);
+ if (d->focusItem && (d->focusItem->flags() & QGraphicsItem::ItemAcceptsInputMethod))
+ d->sendEvent(d->focusItem, event);
+}
+
+/*!
+ Draws the background of the scene using \a painter, before any items and
+ the foreground are drawn. Reimplement this function to provide a custom
+ background for the scene.
+
+ All painting is done in \e scene coordinates. The \a rect
+ parameter is the exposed rectangle.
+
+ If all you want is to define a color, texture, or gradient for the
+ background, you can call setBackgroundBrush() instead.
+
+ \sa drawForeground(), drawItems()
+*/
+void QGraphicsScene::drawBackground(QPainter *painter, const QRectF &rect)
+{
+ Q_D(QGraphicsScene);
+
+ if (d->backgroundBrush.style() != Qt::NoBrush) {
+ if (d->painterStateProtection)
+ painter->save();
+ painter->setBrushOrigin(0, 0);
+ painter->fillRect(rect, backgroundBrush());
+ if (d->painterStateProtection)
+ painter->restore();
+ }
+}
+
+/*!
+ Draws the foreground of the scene using \a painter, after the background
+ and all items have been drawn. Reimplement this function to provide a
+ custom foreground for the scene.
+
+ All painting is done in \e scene coordinates. The \a rect
+ parameter is the exposed rectangle.
+
+ If all you want is to define a color, texture or gradient for the
+ foreground, you can call setForegroundBrush() instead.
+
+ \sa drawBackground(), drawItems()
+*/
+void QGraphicsScene::drawForeground(QPainter *painter, const QRectF &rect)
+{
+ Q_D(QGraphicsScene);
+
+ if (d->foregroundBrush.style() != Qt::NoBrush) {
+ if (d->painterStateProtection)
+ painter->save();
+ painter->setBrushOrigin(0, 0);
+ painter->fillRect(rect, foregroundBrush());
+ if (d->painterStateProtection)
+ painter->restore();
+ }
+}
+
+static void _q_paintItem(QGraphicsItem *item, QPainter *painter,
+ const QStyleOptionGraphicsItem *option, QWidget *widget,
+ bool useWindowOpacity, bool painterStateProtection)
+{
+ if (!item->isWidget()) {
+ item->paint(painter, option, widget);
+ return;
+ }
+ QGraphicsWidget *widgetItem = static_cast<QGraphicsWidget *>(item);
+ QGraphicsProxyWidget *proxy = qobject_cast<QGraphicsProxyWidget *>(widgetItem);
+ const qreal windowOpacity = (proxy && proxy->widget() && useWindowOpacity)
+ ? proxy->widget()->windowOpacity() : 1.0;
+ const qreal oldPainterOpacity = painter->opacity();
+
+ if (qFuzzyIsNull(windowOpacity))
+ return;
+ // Set new painter opacity.
+ if (windowOpacity < 1.0)
+ painter->setOpacity(oldPainterOpacity * windowOpacity);
+
+ // set layoutdirection on the painter
+ Qt::LayoutDirection oldLayoutDirection = painter->layoutDirection();
+ painter->setLayoutDirection(widgetItem->layoutDirection());
+
+ if (widgetItem->isWindow() && widgetItem->windowType() != Qt::Popup && widgetItem->windowType() != Qt::ToolTip
+ && !(widgetItem->windowFlags() & Qt::FramelessWindowHint)) {
+ if (painterStateProtection)
+ painter->save();
+ widgetItem->paintWindowFrame(painter, option, widget);
+ if (painterStateProtection)
+ painter->restore();
+ } else if (widgetItem->autoFillBackground()) {
+ painter->fillRect(option->exposedRect, widgetItem->palette().window());
+ }
+
+ widgetItem->paint(painter, option, widget);
+
+ // Restore layoutdirection on the painter.
+ painter->setLayoutDirection(oldLayoutDirection);
+ // Restore painter opacity.
+ if (windowOpacity < 1.0)
+ painter->setOpacity(oldPainterOpacity);
+}
+
+static void _q_paintIntoCache(QPixmap *pix, QGraphicsItem *item, const QRegion &pixmapExposed,
+ const QTransform &itemToPixmap, QPainter::RenderHints renderHints,
+ const QStyleOptionGraphicsItem *option, bool painterStateProtection)
+{
+ QPixmap subPix;
+ QPainter pixmapPainter;
+ QRect br = pixmapExposed.boundingRect();
+
+ // Don't use subpixmap if we get a full update.
+ if (pixmapExposed.isEmpty() || (pixmapExposed.rectCount() == 1 && br.contains(pix->rect()))) {
+ pix->fill(Qt::transparent);
+ pixmapPainter.begin(pix);
+ } else {
+ subPix = QPixmap(br.size());
+ subPix.fill(Qt::transparent);
+ pixmapPainter.begin(&subPix);
+ pixmapPainter.translate(-br.topLeft());
+ if (!pixmapExposed.isEmpty()) {
+ // Applied to subPix; paint is adjusted to the coordinate space is
+ // correct.
+ pixmapPainter.setClipRegion(pixmapExposed);
+ }
+ }
+
+ pixmapPainter.setRenderHints(pixmapPainter.renderHints(), false);
+ pixmapPainter.setRenderHints(renderHints, true);
+ pixmapPainter.setWorldTransform(itemToPixmap, true);
+
+ // Render.
+ _q_paintItem(item, &pixmapPainter, option, 0, false, painterStateProtection);
+ pixmapPainter.end();
+
+ if (!subPix.isNull()) {
+ // Blit the subpixmap into the main pixmap.
+ pixmapPainter.begin(pix);
+ pixmapPainter.setCompositionMode(QPainter::CompositionMode_Source);
+ pixmapPainter.setClipRegion(pixmapExposed);
+ pixmapPainter.drawPixmap(br.topLeft(), subPix);
+ pixmapPainter.end();
+ }
+}
+
+// Copied from qpaintengine_vg.cpp
+// Returns true for 90, 180, and 270 degree rotations.
+static inline bool transformIsSimple(const QTransform& transform)
+{
+ QTransform::TransformationType type = transform.type();
+ if (type <= QTransform::TxScale) {
+ return true;
+ } else if (type == QTransform::TxRotate) {
+ // Check for 90, and 270 degree rotations.
+ qreal m11 = transform.m11();
+ qreal m12 = transform.m12();
+ qreal m21 = transform.m21();
+ qreal m22 = transform.m22();
+ if (m11 == 0.0f && m22 == 0.0f) {
+ if (m12 == 1.0f && m21 == -1.0f)
+ return true; // 90 degrees.
+ else if (m12 == -1.0f && m21 == 1.0f)
+ return true; // 270 degrees.
+ else if (m12 == -1.0f && m21 == -1.0f)
+ return true; // 90 degrees inverted y.
+ else if (m12 == 1.0f && m21 == 1.0f)
+ return true; // 270 degrees inverted y.
+ }
+ }
+ return false;
+}
+
+/*!
+ \internal
+
+ Draws items directly, or using cache.
+*/
+void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painter,
+ const QStyleOptionGraphicsItem *option, QWidget *widget,
+ bool painterStateProtection)
+{
+ QGraphicsItemPrivate *itemd = item->d_ptr.data();
+ QGraphicsItem::CacheMode cacheMode = QGraphicsItem::CacheMode(itemd->cacheMode);
+
+ // Render directly, using no cache.
+ if (cacheMode == QGraphicsItem::NoCache
+#ifdef Q_WS_X11
+ || !X11->use_xrender
+#endif
+ ) {
+ _q_paintItem(static_cast<QGraphicsWidget *>(item), painter, option, widget, true, painterStateProtection);
+ return;
+ }
+
+ const qreal oldPainterOpacity = painter->opacity();
+ qreal newPainterOpacity = oldPainterOpacity;
+ QGraphicsProxyWidget *proxy = item->isWidget() ? qobject_cast<QGraphicsProxyWidget *>(static_cast<QGraphicsWidget *>(item)) : 0;
+ if (proxy && proxy->widget()) {
+ const qreal windowOpacity = proxy->widget()->windowOpacity();
+ if (windowOpacity < 1.0)
+ newPainterOpacity *= windowOpacity;
+ }
+
+ // Item's (local) bounding rect
+ QRectF brect = item->boundingRect();
+ QRectF adjustedBrect(brect);
+ _q_adjustRect(&adjustedBrect);
+ if (adjustedBrect.isEmpty())
+ return;
+
+ // Fetch the off-screen transparent buffer and exposed area info.
+ QPixmapCache::Key pixmapKey;
+ QPixmap pix;
+ bool pixmapFound;
+ QGraphicsItemCache *itemCache = itemd->extraItemCache();
+ if (cacheMode == QGraphicsItem::ItemCoordinateCache) {
+ pixmapKey = itemCache->key;
+ } else {
+ pixmapKey = itemCache->deviceData.value(widget).key;
+ }
+
+ // Find pixmap in cache.
+ pixmapFound = QPixmapCache::find(pixmapKey, &pix);
+
+ // Render using item coordinate cache mode.
+ if (cacheMode == QGraphicsItem::ItemCoordinateCache) {
+ QSize pixmapSize;
+ bool fixedCacheSize = false;
+ QRect br = brect.toAlignedRect();
+ if ((fixedCacheSize = itemCache->fixedSize.isValid())) {
+ pixmapSize = itemCache->fixedSize;
+ } else {
+ pixmapSize = br.size();
+ }
+
+ // Create or recreate the pixmap.
+ int adjust = itemCache->fixedSize.isValid() ? 0 : 2;
+ QSize adjustSize(adjust*2, adjust*2);
+ br.adjust(-adjust, -adjust, adjust, adjust);
+ if (pix.isNull() || (!fixedCacheSize && (pixmapSize + adjustSize) != pix.size())) {
+ pix = QPixmap(pixmapSize + adjustSize);
+ itemCache->boundingRect = br;
+ itemCache->exposed.clear();
+ itemCache->allExposed = true;
+ } else if (itemCache->boundingRect != br) {
+ itemCache->boundingRect = br;
+ itemCache->exposed.clear();
+ itemCache->allExposed = true;
+ }
+
+ // Redraw any newly exposed areas.
+ if (itemCache->allExposed || !itemCache->exposed.isEmpty()) {
+
+ //We know that we will modify the pixmap, removing it from the cache
+ //will detach the one we have and avoid a deep copy
+ if (pixmapFound)
+ QPixmapCache::remove(pixmapKey);
+
+ // Fit the item's bounding rect into the pixmap's coordinates.
+ QTransform itemToPixmap;
+ if (fixedCacheSize) {
+ const QPointF scale(pixmapSize.width() / brect.width(), pixmapSize.height() / brect.height());
+ itemToPixmap.scale(scale.x(), scale.y());
+ }
+ itemToPixmap.translate(-br.x(), -br.y());
+
+ // Generate the item's exposedRect and map its list of expose
+ // rects to device coordinates.
+ styleOptionTmp = *option;
+ QRegion pixmapExposed;
+ QRectF exposedRect;
+ if (!itemCache->allExposed) {
+ for (int i = 0; i < itemCache->exposed.size(); ++i) {
+ QRectF r = itemCache->exposed.at(i);
+ exposedRect |= r;
+ pixmapExposed += itemToPixmap.mapRect(r).toAlignedRect();
+ }
+ } else {
+ exposedRect = brect;
+ }
+ styleOptionTmp.exposedRect = exposedRect;
+
+ // Render.
+ _q_paintIntoCache(&pix, item, pixmapExposed, itemToPixmap, painter->renderHints(),
+ &styleOptionTmp, painterStateProtection);
+
+ // insert this pixmap into the cache.
+ itemCache->key = QPixmapCache::insert(pix);
+
+ // Reset expose data.
+ itemCache->allExposed = false;
+ itemCache->exposed.clear();
+ }
+
+ // Redraw the exposed area using the transformed painter. Depending on
+ // the hardware, this may be a server-side operation, or an expensive
+ // qpixmap-image-transform-pixmap roundtrip.
+ if (newPainterOpacity != oldPainterOpacity) {
+ painter->setOpacity(newPainterOpacity);
+ painter->drawPixmap(br.topLeft(), pix);
+ painter->setOpacity(oldPainterOpacity);
+ } else {
+ painter->drawPixmap(br.topLeft(), pix);
+ }
+ return;
+ }
+
+ // Render using device coordinate cache mode.
+ if (cacheMode == QGraphicsItem::DeviceCoordinateCache) {
+ // Find the item's bounds in device coordinates.
+ QRectF deviceBounds = painter->worldTransform().mapRect(brect);
+ QRect deviceRect = deviceBounds.toRect().adjusted(-1, -1, 1, 1);
+ if (deviceRect.isEmpty())
+ return;
+ QRect viewRect = widget ? widget->rect() : QRect();
+ if (widget && !viewRect.intersects(deviceRect))
+ return;
+
+ // Resort to direct rendering if the device rect exceeds the
+ // (optional) maximum bounds. (QGraphicsSvgItem uses this).
+ QSize maximumCacheSize =
+ itemd->extra(QGraphicsItemPrivate::ExtraMaxDeviceCoordCacheSize).toSize();
+ if (!maximumCacheSize.isEmpty()
+ && (deviceRect.width() > maximumCacheSize.width()
+ || deviceRect.height() > maximumCacheSize.height())) {
+ _q_paintItem(static_cast<QGraphicsWidget *>(item), painter, option, widget,
+ oldPainterOpacity != newPainterOpacity, painterStateProtection);
+ return;
+ }
+
+ // Create or reuse offscreen pixmap, possibly scroll/blit from the old one.
+ // If the world transform is rotated we always recreate the cache to avoid
+ // wrong blending.
+ bool pixModified = false;
+ QGraphicsItemCache::DeviceData *deviceData = &itemCache->deviceData[widget];
+ bool invertable = true;
+ QTransform diff = deviceData->lastTransform.inverted(&invertable);
+ if (invertable)
+ diff *= painter->worldTransform();
+ deviceData->lastTransform = painter->worldTransform();
+ bool allowPartialCacheExposure = false;
+ bool simpleTransform = invertable && diff.type() <= QTransform::TxTranslate
+ && transformIsSimple(painter->worldTransform());
+ if (!simpleTransform) {
+ pixModified = true;
+ itemCache->allExposed = true;
+ itemCache->exposed.clear();
+ deviceData->cacheIndent = QPoint();
+ pix = QPixmap();
+ } else if (!viewRect.isNull()) {
+ allowPartialCacheExposure = deviceData->cacheIndent != QPoint();
+ }
+
+ // Allow partial cache exposure if the device rect isn't fully contained and
+ // deviceRect is 20% taller or wider than the viewRect.
+ if (!allowPartialCacheExposure && !viewRect.isNull() && !viewRect.contains(deviceRect)) {
+ allowPartialCacheExposure = (viewRect.width() * 1.2 < deviceRect.width())
+ || (viewRect.height() * 1.2 < deviceRect.height());
+ }
+
+ QRegion scrollExposure;
+ if (allowPartialCacheExposure) {
+ // Part of pixmap is drawn. Either device contains viewrect (big
+ // item covers whole screen) or parts of device are outside the
+ // viewport. In either case the device rect must be the intersect
+ // between the two.
+ int dx = deviceRect.left() < viewRect.left() ? viewRect.left() - deviceRect.left() : 0;
+ int dy = deviceRect.top() < viewRect.top() ? viewRect.top() - deviceRect.top() : 0;
+ QPoint newCacheIndent(dx, dy);
+ deviceRect &= viewRect;
+
+ if (pix.isNull()) {
+ deviceData->cacheIndent = QPoint();
+ itemCache->allExposed = true;
+ itemCache->exposed.clear();
+ pixModified = true;
+ }
+
+ // Copy / "scroll" the old pixmap onto the new ole and calculate
+ // scrolled exposure.
+ if (newCacheIndent != deviceData->cacheIndent || deviceRect.size() != pix.size()) {
+ QPoint diff = newCacheIndent - deviceData->cacheIndent;
+ QPixmap newPix(deviceRect.size());
+ // ### Investigate removing this fill (test with Plasma and
+ // graphicssystem raster).
+ newPix.fill(Qt::transparent);
+ if (!pix.isNull()) {
+ QPainter newPixPainter(&newPix);
+ newPixPainter.drawPixmap(-diff, pix);
+ newPixPainter.end();
+ }
+ QRegion exposed;
+ exposed += newPix.rect();
+ if (!pix.isNull())
+ exposed -= QRect(-diff, pix.size());
+ scrollExposure = exposed;
+
+ pix = newPix;
+ pixModified = true;
+ }
+ deviceData->cacheIndent = newCacheIndent;
+ } else {
+ // Full pixmap is drawn.
+ deviceData->cacheIndent = QPoint();
+
+ // Auto-adjust the pixmap size.
+ if (deviceRect.size() != pix.size()) {
+ // exposed needs to cover the whole pixmap
+ pix = QPixmap(deviceRect.size());
+ pixModified = true;
+ itemCache->allExposed = true;
+ itemCache->exposed.clear();
+ }
+ }
+
+ // Check for newly invalidated areas.
+ if (itemCache->allExposed || !itemCache->exposed.isEmpty() || !scrollExposure.isEmpty()) {
+ //We know that we will modify the pixmap, removing it from the cache
+ //will detach the one we have and avoid a deep copy
+ if (pixmapFound)
+ QPixmapCache::remove(pixmapKey);
+
+ // Construct an item-to-pixmap transform.
+ QPointF p = deviceRect.topLeft();
+ QTransform itemToPixmap = painter->worldTransform();
+ if (!p.isNull())
+ itemToPixmap *= QTransform::fromTranslate(-p.x(), -p.y());
+
+ // Map the item's logical expose to pixmap coordinates.
+ QRegion pixmapExposed = scrollExposure;
+ if (!itemCache->allExposed) {
+ const QVector<QRectF> &exposed = itemCache->exposed;
+ for (int i = 0; i < exposed.size(); ++i)
+ pixmapExposed += itemToPixmap.mapRect(exposed.at(i)).toRect().adjusted(-1, -1, 1, 1);
+ }
+
+ // Calculate the style option's exposedRect.
+ QRectF br;
+ if (itemCache->allExposed) {
+ br = item->boundingRect();
+ } else {
+ const QVector<QRectF> &exposed = itemCache->exposed;
+ for (int i = 0; i < exposed.size(); ++i)
+ br |= exposed.at(i);
+ QTransform pixmapToItem = itemToPixmap.inverted();
+ foreach (QRect r, scrollExposure.rects())
+ br |= pixmapToItem.mapRect(r);
+ }
+ styleOptionTmp = *option;
+ styleOptionTmp.exposedRect = br.adjusted(-1, -1, 1, 1);
+
+ // Render the exposed areas.
+ _q_paintIntoCache(&pix, item, pixmapExposed, itemToPixmap, painter->renderHints(),
+ &styleOptionTmp, painterStateProtection);
+
+ // Reset expose data.
+ pixModified = true;
+ itemCache->allExposed = false;
+ itemCache->exposed.clear();
+ }
+
+ if (pixModified) {
+ // Insert this pixmap into the cache.
+ deviceData->key = QPixmapCache::insert(pix);
+ }
+
+ // Redraw the exposed area using an untransformed painter. This
+ // effectively becomes a bitblit that does not transform the cache.
+ QTransform restoreTransform = painter->worldTransform();
+ painter->setWorldTransform(QTransform());
+ if (newPainterOpacity != oldPainterOpacity) {
+ painter->setOpacity(newPainterOpacity);
+ painter->drawPixmap(deviceRect.topLeft(), pix);
+ painter->setOpacity(oldPainterOpacity);
+ } else {
+ painter->drawPixmap(deviceRect.topLeft(), pix);
+ }
+ painter->setWorldTransform(restoreTransform);
+ return;
+ }
+}
+
+void QGraphicsScenePrivate::drawItems(QPainter *painter, const QTransform *const viewTransform,
+ QRegion *exposedRegion, QWidget *widget)
+{
+ // Make sure we don't have unpolished items before we draw.
+ if (!unpolishedItems.isEmpty())
+ _q_polishItems();
+
+ updateAll = false;
+ QRectF exposedSceneRect;
+ if (exposedRegion && indexMethod != QGraphicsScene::NoIndex) {
+ exposedSceneRect = exposedRegion->boundingRect().adjusted(-1, -1, 1, 1);
+ if (viewTransform)
+ exposedSceneRect = viewTransform->inverted().mapRect(exposedSceneRect);
+ }
+ const QList<QGraphicsItem *> tli = index->estimateTopLevelItems(exposedSceneRect, Qt::AscendingOrder);
+ for (int i = 0; i < tli.size(); ++i)
+ drawSubtreeRecursive(tli.at(i), painter, viewTransform, exposedRegion, widget);
+}
+
+void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *painter,
+ const QTransform *const viewTransform,
+ QRegion *exposedRegion, QWidget *widget,
+ qreal parentOpacity, const QTransform *const effectTransform)
+{
+ Q_ASSERT(item);
+
+ if (!item->d_ptr->visible)
+ return;
+
+ const bool itemHasContents = !(item->d_ptr->flags & QGraphicsItem::ItemHasNoContents);
+ const bool itemHasChildren = !item->d_ptr->children.isEmpty();
+ if (!itemHasContents && !itemHasChildren)
+ return; // Item has neither contents nor children!(?)
+
+ const qreal opacity = item->d_ptr->combineOpacityFromParent(parentOpacity);
+ const bool itemIsFullyTransparent = QGraphicsItemPrivate::isOpacityNull(opacity);
+ if (itemIsFullyTransparent && (!itemHasChildren || item->d_ptr->childrenCombineOpacity()))
+ return;
+
+ QTransform transform(Qt::Uninitialized);
+ QTransform *transformPtr = 0;
+ bool translateOnlyTransform = false;
+#define ENSURE_TRANSFORM_PTR \
+ if (!transformPtr) { \
+ Q_ASSERT(!itemIsUntransformable); \
+ if (viewTransform) { \
+ transform = item->d_ptr->sceneTransform; \
+ transform *= *viewTransform; \
+ transformPtr = &transform; \
+ } else { \
+ transformPtr = &item->d_ptr->sceneTransform; \
+ translateOnlyTransform = item->d_ptr->sceneTransformTranslateOnly; \
+ } \
+ }
+
+ // Update the item's scene transform if the item is transformable;
+ // otherwise calculate the full transform,
+ bool wasDirtyParentSceneTransform = false;
+ const bool itemIsUntransformable = item->d_ptr->itemIsUntransformable();
+ if (itemIsUntransformable) {
+ transform = item->deviceTransform(viewTransform ? *viewTransform : QTransform());
+ transformPtr = &transform;
+ } else if (item->d_ptr->dirtySceneTransform) {
+ item->d_ptr->updateSceneTransformFromParent();
+ Q_ASSERT(!item->d_ptr->dirtySceneTransform);
+ wasDirtyParentSceneTransform = true;
+ }
+
+ const bool itemClipsChildrenToShape = (item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape);
+ bool drawItem = itemHasContents && !itemIsFullyTransparent;
+ if (drawItem) {
+ const QRectF brect = adjustedItemEffectiveBoundingRect(item);
+ ENSURE_TRANSFORM_PTR
+ QRect viewBoundingRect = translateOnlyTransform ? brect.translated(transformPtr->dx(), transformPtr->dy()).toAlignedRect()
+ : transformPtr->mapRect(brect).toAlignedRect();
+ viewBoundingRect.adjust(-int(rectAdjust), -int(rectAdjust), rectAdjust, rectAdjust);
+ if (widget)
+ item->d_ptr->paintedViewBoundingRects.insert(widget, viewBoundingRect);
+ drawItem = exposedRegion ? exposedRegion->intersects(viewBoundingRect)
+ : !viewBoundingRect.normalized().isEmpty();
+ if (!drawItem) {
+ if (!itemHasChildren)
+ return;
+ if (itemClipsChildrenToShape) {
+ if (wasDirtyParentSceneTransform)
+ item->d_ptr->invalidateChildrenSceneTransform();
+ return;
+ }
+ }
+ } // else we know for sure this item has children we must process.
+
+ if (itemHasChildren && itemClipsChildrenToShape)
+ ENSURE_TRANSFORM_PTR;
+
+#ifndef QT_NO_GRAPHICSEFFECT
+ if (item->d_ptr->graphicsEffect && item->d_ptr->graphicsEffect->isEnabled()) {
+ ENSURE_TRANSFORM_PTR;
+ QGraphicsItemPaintInfo info(viewTransform, transformPtr, effectTransform, exposedRegion, widget, &styleOptionTmp,
+ painter, opacity, wasDirtyParentSceneTransform, itemHasContents && !itemIsFullyTransparent);
+ QGraphicsEffectSource *source = item->d_ptr->graphicsEffect->d_func()->source;
+ QGraphicsItemEffectSourcePrivate *sourced = static_cast<QGraphicsItemEffectSourcePrivate *>
+ (source->d_func());
+ sourced->info = &info;
+ const QTransform restoreTransform = painter->worldTransform();
+ if (effectTransform)
+ painter->setWorldTransform(*transformPtr * *effectTransform);
+ else
+ painter->setWorldTransform(*transformPtr);
+ painter->setOpacity(opacity);
+
+ if (sourced->currentCachedSystem() != Qt::LogicalCoordinates
+ && sourced->lastEffectTransform != painter->worldTransform())
+ {
+ if (sourced->lastEffectTransform.type() <= QTransform::TxTranslate
+ && painter->worldTransform().type() <= QTransform::TxTranslate)
+ {
+ QRectF sourceRect = sourced->boundingRect(Qt::DeviceCoordinates);
+ QRect effectRect = sourced->paddedEffectRect(Qt::DeviceCoordinates, sourced->currentCachedMode(), sourceRect);
+
+ sourced->setCachedOffset(effectRect.topLeft());
+ } else {
+ sourced->invalidateCache(QGraphicsEffectSourcePrivate::TransformChanged);
+ }
+
+ sourced->lastEffectTransform = painter->worldTransform();
+ }
+
+ item->d_ptr->graphicsEffect->draw(painter);
+ painter->setWorldTransform(restoreTransform);
+ sourced->info = 0;
+ } else
+#endif //QT_NO_GRAPHICSEFFECT
+ {
+ draw(item, painter, viewTransform, transformPtr, exposedRegion, widget, opacity,
+ effectTransform, wasDirtyParentSceneTransform, drawItem);
+ }
+}
+
+static inline void setClip(QPainter *painter, QGraphicsItem *item)
+{
+ painter->save();
+ QRectF clipRect;
+ const QPainterPath clipPath(item->shape());
+ if (QPathClipper::pathToRect(clipPath, &clipRect))
+ painter->setClipRect(clipRect, Qt::IntersectClip);
+ else
+ painter->setClipPath(clipPath, Qt::IntersectClip);
+}
+
+static inline void setWorldTransform(QPainter *painter, const QTransform *const transformPtr,
+ const QTransform *effectTransform)
+{
+ Q_ASSERT(transformPtr);
+ if (effectTransform)
+ painter->setWorldTransform(*transformPtr * *effectTransform);
+ else
+ painter->setWorldTransform(*transformPtr);
+}
+
+void QGraphicsScenePrivate::draw(QGraphicsItem *item, QPainter *painter, const QTransform *const viewTransform,
+ const QTransform *const transformPtr, QRegion *exposedRegion, QWidget *widget,
+ qreal opacity, const QTransform *effectTransform,
+ bool wasDirtyParentSceneTransform, bool drawItem)
+{
+ const bool itemIsFullyTransparent = QGraphicsItemPrivate::isOpacityNull(opacity);
+ const bool itemClipsChildrenToShape = (item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape);
+ const bool itemHasChildren = !item->d_ptr->children.isEmpty();
+ bool setChildClip = itemClipsChildrenToShape;
+ bool itemHasChildrenStackedBehind = false;
+
+ int i = 0;
+ if (itemHasChildren) {
+ if (itemClipsChildrenToShape)
+ setWorldTransform(painter, transformPtr, effectTransform);
+
+ item->d_ptr->ensureSortedChildren();
+ // Items with the 'ItemStacksBehindParent' flag are put in front of the list
+ // so all we have to do is to check the first item.
+ itemHasChildrenStackedBehind = (item->d_ptr->children.at(0)->d_ptr->flags
+ & QGraphicsItem::ItemStacksBehindParent);
+
+ if (itemHasChildrenStackedBehind) {
+ if (itemClipsChildrenToShape) {
+ setClip(painter, item);
+ setChildClip = false;
+ }
+
+ // Draw children behind
+ for (i = 0; i < item->d_ptr->children.size(); ++i) {
+ QGraphicsItem *child = item->d_ptr->children.at(i);
+ if (wasDirtyParentSceneTransform)
+ child->d_ptr->dirtySceneTransform = 1;
+ if (!(child->d_ptr->flags & QGraphicsItem::ItemStacksBehindParent))
+ break;
+ if (itemIsFullyTransparent && !(child->d_ptr->flags & QGraphicsItem::ItemIgnoresParentOpacity))
+ continue;
+ drawSubtreeRecursive(child, painter, viewTransform, exposedRegion, widget, opacity, effectTransform);
+ }
+ }
+ }
+
+ // Draw item
+ if (drawItem) {
+ Q_ASSERT(!itemIsFullyTransparent);
+ Q_ASSERT(!(item->d_ptr->flags & QGraphicsItem::ItemHasNoContents));
+ Q_ASSERT(transformPtr);
+ item->d_ptr->initStyleOption(&styleOptionTmp, *transformPtr, exposedRegion
+ ? *exposedRegion : QRegion(), exposedRegion == 0);
+
+ const bool itemClipsToShape = item->d_ptr->flags & QGraphicsItem::ItemClipsToShape;
+ bool restorePainterClip = false;
+
+ if (!itemHasChildren || !itemClipsChildrenToShape) {
+ // Item does not have children or clip children to shape.
+ setWorldTransform(painter, transformPtr, effectTransform);
+ if ((restorePainterClip = itemClipsToShape))
+ setClip(painter, item);
+ } else if (itemHasChildrenStackedBehind){
+ // Item clips children to shape and has children stacked behind, which means
+ // the painter is already clipped to the item's shape.
+ if (itemClipsToShape) {
+ // The clip is already correct. Ensure correct world transform.
+ setWorldTransform(painter, transformPtr, effectTransform);
+ } else {
+ // Remove clip (this also ensures correct world transform).
+ painter->restore();
+ setChildClip = true;
+ }
+ } else if (itemClipsToShape) {
+ // Item clips children and itself to shape. It does not have hildren stacked
+ // behind, which means the clip has not yet been set. We set it now and re-use it
+ // for the children.
+ setClip(painter, item);
+ setChildClip = false;
+ }
+
+ if (painterStateProtection && !restorePainterClip)
+ painter->save();
+
+ painter->setOpacity(opacity);
+ if (!item->d_ptr->cacheMode && !item->d_ptr->isWidget)
+ item->paint(painter, &styleOptionTmp, widget);
+ else
+ drawItemHelper(item, painter, &styleOptionTmp, widget, painterStateProtection);
+
+ if (painterStateProtection || restorePainterClip)
+ painter->restore();
+
+ static int drawRect = qgetenv("QT_DRAW_SCENE_ITEM_RECTS").toInt();
+ if (drawRect) {
+ QPen oldPen = painter->pen();
+ QBrush oldBrush = painter->brush();
+ quintptr ptr = reinterpret_cast<quintptr>(item);
+ const QColor color = QColor::fromHsv(ptr % 255, 255, 255);
+ painter->setPen(color);
+ painter->setBrush(Qt::NoBrush);
+ painter->drawRect(adjustedItemBoundingRect(item));
+ painter->setPen(oldPen);
+ painter->setBrush(oldBrush);
+ }
+ }
+
+ // Draw children in front
+ if (itemHasChildren) {
+ if (setChildClip)
+ setClip(painter, item);
+
+ for (; i < item->d_ptr->children.size(); ++i) {
+ QGraphicsItem *child = item->d_ptr->children.at(i);
+ if (wasDirtyParentSceneTransform)
+ child->d_ptr->dirtySceneTransform = 1;
+ if (itemIsFullyTransparent && !(child->d_ptr->flags & QGraphicsItem::ItemIgnoresParentOpacity))
+ continue;
+ drawSubtreeRecursive(child, painter, viewTransform, exposedRegion, widget, opacity, effectTransform);
+ }
+
+ // Restore child clip
+ if (itemClipsChildrenToShape)
+ painter->restore();
+ }
+}
+
+void QGraphicsScenePrivate::markDirty(QGraphicsItem *item, const QRectF &rect, bool invalidateChildren,
+ bool force, bool ignoreOpacity, bool removingItemFromScene,
+ bool updateBoundingRect)
+{
+ Q_ASSERT(item);
+ if (updateAll)
+ return;
+
+ if (removingItemFromScene && !ignoreOpacity && !item->d_ptr->ignoreOpacity) {
+ // If any of the item's ancestors ignore opacity, it means that the opacity
+ // was set to 0 (and the update request has not yet been processed). That
+ // also means that we have to ignore the opacity for the item itself; otherwise
+ // things like: parent->setOpacity(0); scene->removeItem(child) won't work.
+ // Note that we only do this when removing items from the scene. In all other
+ // cases the ignoreOpacity bit propagates properly in processDirtyItems, but
+ // since the item is removed immediately it won't be processed there.
+ QGraphicsItem *p = item->d_ptr->parent;
+ while (p) {
+ if (p->d_ptr->ignoreOpacity) {
+ item->d_ptr->ignoreOpacity = true;
+ break;
+ }
+ p = p->d_ptr->parent;
+ }
+ }
+
+ if (item->d_ptr->discardUpdateRequest(/*ignoreVisibleBit=*/force,
+ /*ignoreDirtyBit=*/removingItemFromScene || invalidateChildren,
+ /*ignoreOpacity=*/ignoreOpacity)) {
+ if (item->d_ptr->dirty) {
+ // The item is already marked as dirty and will be processed later. However,
+ // we have to make sure ignoreVisible and ignoreOpacity are set properly;
+ // otherwise things like: item->update(); item->hide() (force is now true)
+ // won't work as expected.
+ if (force)
+ item->d_ptr->ignoreVisible = 1;
+ if (ignoreOpacity)
+ item->d_ptr->ignoreOpacity = 1;
+ }
+ return;
+ }
+
+ const bool fullItemUpdate = rect.isNull();
+ if (!fullItemUpdate && rect.isEmpty())
+ return;
+
+ if (!processDirtyItemsEmitted) {
+ QMetaMethod method = q_ptr->metaObject()->method(processDirtyItemsIndex);
+ method.invoke(q_ptr, Qt::QueuedConnection);
+// QMetaObject::invokeMethod(q_ptr, "_q_processDirtyItems", Qt::QueuedConnection);
+ processDirtyItemsEmitted = true;
+ }
+
+ if (removingItemFromScene) {
+ // Note that this function can be called from the item's destructor, so
+ // do NOT call any virtual functions on it within this block.
+ if (isSignalConnected(changedSignalIndex) || views.isEmpty()) {
+ // This block of code is kept for compatibility. Since 4.5, by default
+ // QGraphicsView does not connect the signal and we use the below
+ // method of delivering updates.
+ q_func()->update();
+ return;
+ }
+
+ for (int i = 0; i < views.size(); ++i) {
+ QGraphicsViewPrivate *viewPrivate = views.at(i)->d_func();
+ QRect rect = item->d_ptr->paintedViewBoundingRects.value(viewPrivate->viewport);
+ rect.translate(viewPrivate->dirtyScrollOffset);
+ viewPrivate->updateRect(rect);
+ }
+ return;
+ }
+
+ bool hasNoContents = item->d_ptr->flags & QGraphicsItem::ItemHasNoContents;
+ if (!hasNoContents) {
+ item->d_ptr->dirty = 1;
+ if (fullItemUpdate)
+ item->d_ptr->fullUpdatePending = 1;
+ else if (!item->d_ptr->fullUpdatePending)
+ item->d_ptr->needsRepaint |= rect;
+ } else if (item->d_ptr->graphicsEffect) {
+ invalidateChildren = true;
+ }
+
+ if (invalidateChildren) {
+ item->d_ptr->allChildrenDirty = 1;
+ item->d_ptr->dirtyChildren = 1;
+ }
+
+ if (force)
+ item->d_ptr->ignoreVisible = 1;
+ if (ignoreOpacity)
+ item->d_ptr->ignoreOpacity = 1;
+
+ if (!updateBoundingRect)
+ item->d_ptr->markParentDirty();
+}
+
+static inline bool updateHelper(QGraphicsViewPrivate *view, QGraphicsItemPrivate *item,
+ const QRectF &rect, bool itemIsUntransformable)
+{
+ Q_ASSERT(view);
+ Q_ASSERT(item);
+
+ QGraphicsItem *itemq = static_cast<QGraphicsItem *>(item->q_ptr);
+ QGraphicsView *viewq = static_cast<QGraphicsView *>(view->q_ptr);
+
+ if (itemIsUntransformable) {
+ const QTransform xform = itemq->deviceTransform(viewq->viewportTransform());
+ if (!item->hasBoundingRegionGranularity)
+ return view->updateRectF(xform.mapRect(rect));
+ return view->updateRegion(rect, xform);
+ }
+
+ if (item->sceneTransformTranslateOnly && view->identityMatrix) {
+ const qreal dx = item->sceneTransform.dx();
+ const qreal dy = item->sceneTransform.dy();
+ QRectF r(rect);
+ r.translate(dx - view->horizontalScroll(), dy - view->verticalScroll());
+ return view->updateRectF(r);
+ }
+
+ if (!viewq->isTransformed()) {
+ if (!item->hasBoundingRegionGranularity)
+ return view->updateRectF(item->sceneTransform.mapRect(rect));
+ return view->updateRegion(rect, item->sceneTransform);
+ }
+
+ QTransform xform = item->sceneTransform;
+ xform *= viewq->viewportTransform();
+ if (!item->hasBoundingRegionGranularity)
+ return view->updateRectF(xform.mapRect(rect));
+ return view->updateRegion(rect, xform);
+}
+
+void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool dirtyAncestorContainsChildren,
+ qreal parentOpacity)
+{
+ Q_Q(QGraphicsScene);
+ Q_ASSERT(item);
+ Q_ASSERT(!updateAll);
+
+ if (!item->d_ptr->dirty && !item->d_ptr->dirtyChildren) {
+ resetDirtyItem(item);
+ return;
+ }
+
+ const bool itemIsHidden = !item->d_ptr->ignoreVisible && !item->d_ptr->visible;
+ if (itemIsHidden) {
+ resetDirtyItem(item, /*recursive=*/true);
+ return;
+ }
+
+ bool itemHasContents = !(item->d_ptr->flags & QGraphicsItem::ItemHasNoContents);
+ const bool itemHasChildren = !item->d_ptr->children.isEmpty();
+ if (!itemHasContents) {
+ if (!itemHasChildren) {
+ resetDirtyItem(item);
+ return; // Item has neither contents nor children!(?)
+ }
+ if (item->d_ptr->graphicsEffect)
+ itemHasContents = true;
+ }
+
+ const qreal opacity = item->d_ptr->combineOpacityFromParent(parentOpacity);
+ const bool itemIsFullyTransparent = !item->d_ptr->ignoreOpacity
+ && QGraphicsItemPrivate::isOpacityNull(opacity);
+ if (itemIsFullyTransparent && (!itemHasChildren || item->d_ptr->childrenCombineOpacity())) {
+ resetDirtyItem(item, /*recursive=*/itemHasChildren);
+ return;
+ }
+
+ bool wasDirtyParentSceneTransform = item->d_ptr->dirtySceneTransform;
+ const bool itemIsUntransformable = item->d_ptr->itemIsUntransformable();
+ if (wasDirtyParentSceneTransform && !itemIsUntransformable) {
+ item->d_ptr->updateSceneTransformFromParent();
+ Q_ASSERT(!item->d_ptr->dirtySceneTransform);
+ }
+
+ const bool wasDirtyParentViewBoundingRects = item->d_ptr->paintedViewBoundingRectsNeedRepaint;
+ if (itemIsFullyTransparent || !itemHasContents || dirtyAncestorContainsChildren) {
+ // Make sure we don't process invisible items or items with no content.
+ item->d_ptr->dirty = 0;
+ item->d_ptr->fullUpdatePending = 0;
+ // Might have a dirty view bounding rect otherwise.
+ if (itemIsFullyTransparent || !itemHasContents)
+ item->d_ptr->paintedViewBoundingRectsNeedRepaint = 0;
+ }
+
+ if (!hasSceneRect && item->d_ptr->geometryChanged && item->d_ptr->visible) {
+ // Update growingItemsBoundingRect.
+ if (item->d_ptr->sceneTransformTranslateOnly) {
+ growingItemsBoundingRect |= item->boundingRect().translated(item->d_ptr->sceneTransform.dx(),
+ item->d_ptr->sceneTransform.dy());
+ } else {
+ growingItemsBoundingRect |= item->d_ptr->sceneTransform.mapRect(item->boundingRect());
+ }
+ }
+
+ // Process item.
+ if (item->d_ptr->dirty || item->d_ptr->paintedViewBoundingRectsNeedRepaint) {
+ const bool useCompatUpdate = views.isEmpty() || isSignalConnected(changedSignalIndex);
+ const QRectF itemBoundingRect = adjustedItemEffectiveBoundingRect(item);
+
+ if (useCompatUpdate && !itemIsUntransformable && qFuzzyIsNull(item->boundingRegionGranularity())) {
+ // This block of code is kept for compatibility. Since 4.5, by default
+ // QGraphicsView does not connect the signal and we use the below
+ // method of delivering updates.
+ if (item->d_ptr->sceneTransformTranslateOnly) {
+ q->update(itemBoundingRect.translated(item->d_ptr->sceneTransform.dx(),
+ item->d_ptr->sceneTransform.dy()));
+ } else {
+ QRectF rect = item->d_ptr->sceneTransform.mapRect(itemBoundingRect);
+ if (!rect.isEmpty())
+ q->update(rect);
+ }
+ } else {
+ QRectF dirtyRect;
+ bool uninitializedDirtyRect = true;
+
+ for (int j = 0; j < views.size(); ++j) {
+ QGraphicsView *view = views.at(j);
+ QGraphicsViewPrivate *viewPrivate = view->d_func();
+ QRect &paintedViewBoundingRect = item->d_ptr->paintedViewBoundingRects[viewPrivate->viewport];
+ if (viewPrivate->fullUpdatePending
+ || viewPrivate->viewportUpdateMode == QGraphicsView::NoViewportUpdate) {
+ // Okay, if we have a full update pending or no viewport update, this item's
+ // paintedViewBoundingRect will be updated correctly in the next paintEvent if
+ // it is inside the viewport, but for now we can pretend that it is outside.
+ paintedViewBoundingRect = QRect(-1, -1, -1, -1);
+ continue;
+ }
+
+ if (item->d_ptr->paintedViewBoundingRectsNeedRepaint) {
+ paintedViewBoundingRect.translate(viewPrivate->dirtyScrollOffset);
+ if (!viewPrivate->updateRect(paintedViewBoundingRect))
+ paintedViewBoundingRect = QRect(-1, -1, -1, -1); // Outside viewport.
+ }
+
+ if (!item->d_ptr->dirty)
+ continue;
+
+ if (!item->d_ptr->paintedViewBoundingRectsNeedRepaint
+ && paintedViewBoundingRect.x() == -1 && paintedViewBoundingRect.y() == -1
+ && paintedViewBoundingRect.width() == -1 && paintedViewBoundingRect.height() == -1) {
+ continue; // Outside viewport.
+ }
+
+ if (uninitializedDirtyRect) {
+ dirtyRect = itemBoundingRect;
+ if (!item->d_ptr->fullUpdatePending) {
+ _q_adjustRect(&item->d_ptr->needsRepaint);
+ dirtyRect &= item->d_ptr->needsRepaint;
+ }
+ uninitializedDirtyRect = false;
+ }
+
+ if (dirtyRect.isEmpty())
+ continue; // Discard updates outside the bounding rect.
+
+ if (!updateHelper(viewPrivate, item->d_ptr.data(), dirtyRect, itemIsUntransformable)
+ && item->d_ptr->paintedViewBoundingRectsNeedRepaint) {
+ paintedViewBoundingRect = QRect(-1, -1, -1, -1); // Outside viewport.
+ }
+ }
+ }
+ }
+
+ // Process children.
+ if (itemHasChildren && item->d_ptr->dirtyChildren) {
+ const bool itemClipsChildrenToShape = item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape;
+ // Items with no content are threated as 'dummy' items which means they are never drawn and
+ // 'processed', so the painted view bounding rect is never up-to-date. This means that whenever
+ // such an item changes geometry, its children have to take care of the update regardless
+ // of whether the item clips children to shape or not.
+ const bool bypassUpdateClip = !itemHasContents && wasDirtyParentViewBoundingRects;
+ if (itemClipsChildrenToShape && !bypassUpdateClip) {
+ // Make sure child updates are clipped to the item's bounding rect.
+ for (int i = 0; i < views.size(); ++i)
+ views.at(i)->d_func()->setUpdateClip(item);
+ }
+ if (!dirtyAncestorContainsChildren) {
+ dirtyAncestorContainsChildren = item->d_ptr->fullUpdatePending
+ && itemClipsChildrenToShape;
+ }
+ const bool allChildrenDirty = item->d_ptr->allChildrenDirty;
+ const bool parentIgnoresVisible = item->d_ptr->ignoreVisible;
+ const bool parentIgnoresOpacity = item->d_ptr->ignoreOpacity;
+ for (int i = 0; i < item->d_ptr->children.size(); ++i) {
+ QGraphicsItem *child = item->d_ptr->children.at(i);
+ if (wasDirtyParentSceneTransform)
+ child->d_ptr->dirtySceneTransform = 1;
+ if (wasDirtyParentViewBoundingRects)
+ child->d_ptr->paintedViewBoundingRectsNeedRepaint = 1;
+ if (parentIgnoresVisible)
+ child->d_ptr->ignoreVisible = 1;
+ if (parentIgnoresOpacity)
+ child->d_ptr->ignoreOpacity = 1;
+ if (allChildrenDirty) {
+ child->d_ptr->dirty = 1;
+ child->d_ptr->fullUpdatePending = 1;
+ child->d_ptr->dirtyChildren = 1;
+ child->d_ptr->allChildrenDirty = 1;
+ }
+ processDirtyItemsRecursive(child, dirtyAncestorContainsChildren, opacity);
+ }
+
+ if (itemClipsChildrenToShape) {
+ // Reset updateClip.
+ for (int i = 0; i < views.size(); ++i)
+ views.at(i)->d_func()->setUpdateClip(0);
+ }
+ } else if (wasDirtyParentSceneTransform) {
+ item->d_ptr->invalidateChildrenSceneTransform();
+ }
+
+ resetDirtyItem(item);
+}
+
+/*!
+ \obsolete
+
+ Paints the given \a items using the provided \a painter, after the
+ background has been drawn, and before the foreground has been
+ drawn. All painting is done in \e scene coordinates. Before
+ drawing each item, the painter must be transformed using
+ QGraphicsItem::sceneTransform().
+
+ The \a options parameter is the list of style option objects for
+ each item in \a items. The \a numItems parameter is the number of
+ items in \a items and options in \a options. The \a widget
+ parameter is optional; if specified, it should point to the widget
+ that is being painted on.
+
+ The default implementation prepares the painter matrix, and calls
+ QGraphicsItem::paint() on all items. Reimplement this function to
+ provide custom painting of all items for the scene; gaining
+ complete control over how each item is drawn. In some cases this
+ can increase drawing performance significantly.
+
+ Example:
+
+ \snippet doc/src/snippets/graphicssceneadditemsnippet.cpp 0
+
+ Since Qt 4.6, this function is not called anymore unless
+ the QGraphicsView::IndirectPainting flag is given as an Optimization
+ flag.
+
+ \sa drawBackground(), drawForeground()
+*/
+void QGraphicsScene::drawItems(QPainter *painter,
+ int numItems,
+ QGraphicsItem *items[],
+ const QStyleOptionGraphicsItem options[], QWidget *widget)
+{
+ Q_D(QGraphicsScene);
+ // Make sure we don't have unpolished items before we draw.
+ if (!d->unpolishedItems.isEmpty())
+ d->_q_polishItems();
+
+ const qreal opacity = painter->opacity();
+ QTransform viewTransform = painter->worldTransform();
+ Q_UNUSED(options);
+
+ // Determine view, expose and flags.
+ QGraphicsView *view = widget ? qobject_cast<QGraphicsView *>(widget->parentWidget()) : 0;
+ QRegion *expose = 0;
+ const quint32 oldRectAdjust = d->rectAdjust;
+ if (view) {
+ d->updateAll = false;
+ expose = &view->d_func()->exposedRegion;
+ if (view->d_func()->optimizationFlags & QGraphicsView::DontAdjustForAntialiasing)
+ d->rectAdjust = 1;
+ else
+ d->rectAdjust = 2;
+ }
+
+ // Find all toplevels, they are already sorted.
+ QList<QGraphicsItem *> topLevelItems;
+ for (int i = 0; i < numItems; ++i) {
+ QGraphicsItem *item = items[i]->topLevelItem();
+ if (!item->d_ptr->itemDiscovered) {
+ topLevelItems << item;
+ item->d_ptr->itemDiscovered = 1;
+ d->drawSubtreeRecursive(item, painter, &viewTransform, expose, widget);
+ }
+ }
+
+ d->rectAdjust = oldRectAdjust;
+ // Reset discovery bits.
+ for (int i = 0; i < topLevelItems.size(); ++i)
+ topLevelItems.at(i)->d_ptr->itemDiscovered = 0;
+
+ painter->setWorldTransform(viewTransform);
+ painter->setOpacity(opacity);
+}
+
+/*!
+ \since 4.4
+
+ Finds a new widget to give the keyboard focus to, as appropriate for Tab
+ and Shift+Tab, and returns true if it can find a new widget, or false if
+ it cannot. If \a next is true, this function searches forward; if \a next
+ is false, it searches backward.
+
+ You can reimplement this function in a subclass of QGraphicsScene to
+ provide fine-grained control over how tab focus passes inside your
+ scene. The default implementation is based on the tab focus chain defined
+ by QGraphicsWidget::setTabOrder().
+*/
+bool QGraphicsScene::focusNextPrevChild(bool next)
+{
+ Q_D(QGraphicsScene);
+
+ QGraphicsItem *item = focusItem();
+ if (item && !item->isWidget()) {
+ // Tab out of the scene.
+ return false;
+ }
+ if (!item) {
+ if (d->lastFocusItem && !d->lastFocusItem->isWidget()) {
+ // Restore focus to the last focusable non-widget item that had
+ // focus.
+ setFocusItem(d->lastFocusItem, next ? Qt::TabFocusReason : Qt::BacktabFocusReason);
+ return true;
+ }
+ }
+ if (!d->tabFocusFirst) {
+ // No widgets...
+ return false;
+ }
+
+ // The item must be a widget.
+ QGraphicsWidget *widget = 0;
+ if (!item) {
+ widget = next ? d->tabFocusFirst : d->tabFocusFirst->d_func()->focusPrev;
+ } else {
+ QGraphicsWidget *test = static_cast<QGraphicsWidget *>(item);
+ widget = next ? test->d_func()->focusNext : test->d_func()->focusPrev;
+ if ((next && widget == d->tabFocusFirst) || (!next && widget == d->tabFocusFirst->d_func()->focusPrev))
+ return false;
+ }
+ QGraphicsWidget *widgetThatHadFocus = widget;
+
+ // Run around the focus chain until we find a widget that can take tab focus.
+ do {
+ if (widget->flags() & QGraphicsItem::ItemIsFocusable
+ && widget->isEnabled() && widget->isVisibleTo(0)
+ && (widget->focusPolicy() & Qt::TabFocus)
+ && (!item || !item->isPanel() || item->isAncestorOf(widget))
+ ) {
+ setFocusItem(widget, next ? Qt::TabFocusReason : Qt::BacktabFocusReason);
+ return true;
+ }
+ widget = next ? widget->d_func()->focusNext : widget->d_func()->focusPrev;
+ if ((next && widget == d->tabFocusFirst) || (!next && widget == d->tabFocusFirst->d_func()->focusPrev))
+ return false;
+ } while (widget != widgetThatHadFocus);
+
+ return false;
+}
+
+/*!
+ \fn QGraphicsScene::changed(const QList<QRectF> &region)
+
+ This signal is emitted by QGraphicsScene when control reaches the
+ event loop, if the scene content changes. The \a region parameter
+ contains a list of scene rectangles that indicate the area that
+ has been changed.
+
+ \sa QGraphicsView::updateScene()
+*/
+
+/*!
+ \fn QGraphicsScene::sceneRectChanged(const QRectF &rect)
+
+ This signal is emitted by QGraphicsScene whenever the scene rect changes.
+ The \a rect parameter is the new scene rectangle.
+
+ \sa QGraphicsView::updateSceneRect()
+*/
+
+/*!
+ \fn QGraphicsScene::selectionChanged()
+ \since 4.3
+
+ This signal is emitted by QGraphicsScene whenever the selection
+ changes. You can call selectedItems() to get the new list of selected
+ items.
+
+ The selection changes whenever an item is selected or unselected, a
+ selection area is set, cleared or otherwise changed, if a preselected item
+ is added to the scene, or if a selected item is removed from the scene.
+
+ QGraphicsScene emits this signal only once for group selection operations.
+ For example, if you set a selection area, select or unselect a
+ QGraphicsItemGroup, or if you add or remove from the scene a parent item
+ that contains several selected items, selectionChanged() is emitted only
+ once after the operation has completed (instead of once for each item).
+
+ \sa setSelectionArea(), selectedItems(), QGraphicsItem::setSelected()
+*/
+
+/*!
+ \since 4.4
+
+ Returns the scene's style, or the same as QApplication::style() if the
+ scene has not been explicitly assigned a style.
+
+ \sa setStyle()
+*/
+QStyle *QGraphicsScene::style() const
+{
+ Q_D(const QGraphicsScene);
+ // ### This function, and the use of styles in general, is non-reentrant.
+ return d->style ? d->style : QApplication::style();
+}
+
+/*!
+ \since 4.4
+
+ Sets or replaces the style of the scene to \a style, and reparents the
+ style to this scene. Any previously assigned style is deleted. The scene's
+ style defaults to QApplication::style(), and serves as the default for all
+ QGraphicsWidget items in the scene.
+
+ Changing the style, either directly by calling this function, or
+ indirectly by calling QApplication::setStyle(), will automatically update
+ the style for all widgets in the scene that do not have a style explicitly
+ assigned to them.
+
+ If \a style is 0, QGraphicsScene will revert to QApplication::style().
+
+ \sa style()
+*/
+void QGraphicsScene::setStyle(QStyle *style)
+{
+ Q_D(QGraphicsScene);
+ // ### This function, and the use of styles in general, is non-reentrant.
+ if (style == d->style)
+ return;
+
+ // Delete the old style,
+ delete d->style;
+ if ((d->style = style))
+ d->style->setParent(this);
+
+ // Notify the scene.
+ QEvent event(QEvent::StyleChange);
+ QApplication::sendEvent(this, &event);
+
+ // Notify all widgets that don't have a style explicitly set.
+ foreach (QGraphicsItem *item, items()) {
+ if (item->isWidget()) {
+ QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
+ if (!widget->testAttribute(Qt::WA_SetStyle))
+ QApplication::sendEvent(widget, &event);
+ }
+ }
+}
+
+/*!
+ \property QGraphicsScene::font
+ \since 4.4
+ \brief the scene's default font
+
+ This property provides the scene's font. The scene font defaults to,
+ and resolves all its entries from, QApplication::font.
+
+ If the scene's font changes, either directly through setFont() or
+ indirectly when the application font changes, QGraphicsScene first
+ sends itself a \l{QEvent::FontChange}{FontChange} event, and it then
+ sends \l{QEvent::FontChange}{FontChange} events to all top-level
+ widget items in the scene. These items respond by resolving their own
+ fonts to the scene, and they then notify their children, who again
+ notify their children, and so on, until all widget items have updated
+ their fonts.
+
+ Changing the scene font, (directly or indirectly through
+ QApplication::setFont(),) automatically schedules a redraw the entire
+ scene.
+
+ \sa QWidget::font, QApplication::setFont(), palette, style()
+*/
+QFont QGraphicsScene::font() const
+{
+ Q_D(const QGraphicsScene);
+ return d->font;
+}
+void QGraphicsScene::setFont(const QFont &font)
+{
+ Q_D(QGraphicsScene);
+ QFont naturalFont = QApplication::font();
+ naturalFont.resolve(0);
+ QFont resolvedFont = font.resolve(naturalFont);
+ d->setFont_helper(resolvedFont);
+}
+
+/*!
+ \property QGraphicsScene::palette
+ \since 4.4
+ \brief the scene's default palette
+
+ This property provides the scene's palette. The scene palette defaults to,
+ and resolves all its entries from, QApplication::palette.
+
+ If the scene's palette changes, either directly through setPalette() or
+ indirectly when the application palette changes, QGraphicsScene first
+ sends itself a \l{QEvent::PaletteChange}{PaletteChange} event, and it then
+ sends \l{QEvent::PaletteChange}{PaletteChange} events to all top-level
+ widget items in the scene. These items respond by resolving their own
+ palettes to the scene, and they then notify their children, who again
+ notify their children, and so on, until all widget items have updated
+ their palettes.
+
+ Changing the scene palette, (directly or indirectly through
+ QApplication::setPalette(),) automatically schedules a redraw the entire
+ scene.
+
+ \sa QWidget::palette, QApplication::setPalette(), font, style()
+*/
+QPalette QGraphicsScene::palette() const
+{
+ Q_D(const QGraphicsScene);
+ return d->palette;
+}
+void QGraphicsScene::setPalette(const QPalette &palette)
+{
+ Q_D(QGraphicsScene);
+ QPalette naturalPalette = QApplication::palette();
+ naturalPalette.resolve(0);
+ QPalette resolvedPalette = palette.resolve(naturalPalette);
+ d->setPalette_helper(resolvedPalette);
+}
+
+/*!
+ \since 4.6
+
+ Returns true if the scene is active (e.g., it's viewed by
+ at least one QGraphicsView that is active); otherwise returns false.
+
+ \sa QGraphicsItem::isActive(), QWidget::isActiveWindow()
+*/
+bool QGraphicsScene::isActive() const
+{
+ Q_D(const QGraphicsScene);
+ return d->activationRefCount > 0;
+}
+
+/*!
+ \since 4.6
+ Returns the current active panel, or 0 if no panel is currently active.
+
+ \sa QGraphicsScene::setActivePanel()
+*/
+QGraphicsItem *QGraphicsScene::activePanel() const
+{
+ Q_D(const QGraphicsScene);
+ return d->activePanel;
+}
+
+/*!
+ \since 4.6
+ Activates \a item, which must be an item in this scene. You
+ can also pass 0 for \a item, in which case QGraphicsScene will
+ deactivate any currently active panel.
+
+ If the scene is currently inactive, \a item remains inactive until the
+ scene becomes active (or, ir \a item is 0, no item will be activated).
+
+ \sa activePanel(), isActive(), QGraphicsItem::isActive()
+*/
+void QGraphicsScene::setActivePanel(QGraphicsItem *item)
+{
+ Q_D(QGraphicsScene);
+ d->setActivePanelHelper(item, false);
+}
+
+/*!
+ \since 4.4
+
+ Returns the current active window, or 0 if no window is currently
+ active.
+
+ \sa QGraphicsScene::setActiveWindow()
+*/
+QGraphicsWidget *QGraphicsScene::activeWindow() const
+{
+ Q_D(const QGraphicsScene);
+ if (d->activePanel && d->activePanel->isWindow())
+ return static_cast<QGraphicsWidget *>(d->activePanel);
+ return 0;
+}
+
+/*!
+ \since 4.4
+ Activates \a widget, which must be a widget in this scene. You can also
+ pass 0 for \a widget, in which case QGraphicsScene will deactivate any
+ currently active window.
+
+ \sa activeWindow(), QGraphicsWidget::isActiveWindow()
+*/
+void QGraphicsScene::setActiveWindow(QGraphicsWidget *widget)
+{
+ if (widget && widget->scene() != this) {
+ qWarning("QGraphicsScene::setActiveWindow: widget %p must be part of this scene",
+ widget);
+ return;
+ }
+
+ // Activate the widget's panel (all windows are panels).
+ QGraphicsItem *panel = widget ? widget->panel() : 0;
+ setActivePanel(panel);
+
+ // Raise
+ if (panel) {
+ QList<QGraphicsItem *> siblingWindows;
+ QGraphicsItem *parent = panel->parentItem();
+ // Raise ### inefficient for toplevels
+ foreach (QGraphicsItem *sibling, parent ? parent->children() : items()) {
+ if (sibling != panel && sibling->isWindow())
+ siblingWindows << sibling;
+ }
+
+ // Find the highest z value.
+ qreal z = panel->zValue();
+ for (int i = 0; i < siblingWindows.size(); ++i)
+ z = qMax(z, siblingWindows.at(i)->zValue());
+
+ // This will probably never overflow.
+ const qreal litt = qreal(0.001);
+ panel->setZValue(z + litt);
+ }
+}
+
+/*!
+ \since 4.6
+
+ Sends event \a event to item \a item through possible event filters.
+
+ The event is sent only if the item is enabled.
+
+ Returns \c false if the event was filtered or if the item is disabled.
+ Otherwise returns the value that was returned from the event handler.
+
+ \sa QGraphicsItem::sceneEvent(), QGraphicsItem::sceneEventFilter()
+*/
+bool QGraphicsScene::sendEvent(QGraphicsItem *item, QEvent *event)
+{
+ Q_D(QGraphicsScene);
+ if (!item) {
+ qWarning("QGraphicsScene::sendEvent: cannot send event to a null item");
+ return false;
+ }
+ if (item->scene() != this) {
+ qWarning("QGraphicsScene::sendEvent: item %p's scene (%p)"
+ " is different from this scene (%p)",
+ item, item->scene(), this);
+ return false;
+ }
+ return d->sendEvent(item, event);
+}
+
+void QGraphicsScenePrivate::addView(QGraphicsView *view)
+{
+ views << view;
+#ifndef QT_NO_GESTURES
+ foreach (Qt::GestureType gesture, grabbedGestures.keys())
+ view->viewport()->grabGesture(gesture);
+#endif
+}
+
+void QGraphicsScenePrivate::removeView(QGraphicsView *view)
+{
+ views.removeAll(view);
+}
+
+void QGraphicsScenePrivate::updateTouchPointsForItem(QGraphicsItem *item, QTouchEvent *touchEvent)
+{
+ QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();
+ for (int i = 0; i < touchPoints.count(); ++i) {
+ QTouchEvent::TouchPoint &touchPoint = touchPoints[i];
+ touchPoint.setRect(item->mapFromScene(touchPoint.sceneRect()).boundingRect());
+ touchPoint.setStartPos(item->d_ptr->genericMapFromScene(touchPoint.startScenePos(), touchEvent->widget()));
+ touchPoint.setLastPos(item->d_ptr->genericMapFromScene(touchPoint.lastScenePos(), touchEvent->widget()));
+ }
+ touchEvent->setTouchPoints(touchPoints);
+}
+
+int QGraphicsScenePrivate::findClosestTouchPointId(const QPointF &scenePos)
+{
+ int closestTouchPointId = -1;
+ qreal closestDistance = qreal(0.);
+ foreach (const QTouchEvent::TouchPoint &touchPoint, sceneCurrentTouchPoints) {
+ qreal distance = QLineF(scenePos, touchPoint.scenePos()).length();
+ if (closestTouchPointId == -1|| distance < closestDistance) {
+ closestTouchPointId = touchPoint.id();
+ closestDistance = distance;
+ }
+ }
+ return closestTouchPointId;
+}
+
+void QGraphicsScenePrivate::touchEventHandler(QTouchEvent *sceneTouchEvent)
+{
+ typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint> > StatesAndTouchPoints;
+ QHash<QGraphicsItem *, StatesAndTouchPoints> itemsNeedingEvents;
+
+ for (int i = 0; i < sceneTouchEvent->touchPoints().count(); ++i) {
+ const QTouchEvent::TouchPoint &touchPoint = sceneTouchEvent->touchPoints().at(i);
+
+ // update state
+ QGraphicsItem *item = 0;
+ if (touchPoint.state() == Qt::TouchPointPressed) {
+ if (sceneTouchEvent->deviceType() == QTouchEvent::TouchPad) {
+ // on touch-pad devices, send all touch points to the same item
+ item = itemForTouchPointId.isEmpty()
+ ? 0
+ : itemForTouchPointId.constBegin().value();
+ }
+
+ if (!item) {
+ // determine which item this touch point will go to
+ cachedItemsUnderMouse = itemsAtPosition(touchPoint.screenPos().toPoint(),
+ touchPoint.scenePos(),
+ sceneTouchEvent->widget());
+ item = cachedItemsUnderMouse.isEmpty() ? 0 : cachedItemsUnderMouse.first();
+ }
+
+ if (sceneTouchEvent->deviceType() == QTouchEvent::TouchScreen) {
+ // on touch-screens, combine this touch point with the closest one we find
+ int closestTouchPointId = findClosestTouchPointId(touchPoint.scenePos());
+ QGraphicsItem *closestItem = itemForTouchPointId.value(closestTouchPointId);
+ if (!item || (closestItem && cachedItemsUnderMouse.contains(closestItem)))
+ item = closestItem;
+ }
+ if (!item)
+ continue;
+
+ itemForTouchPointId.insert(touchPoint.id(), item);
+ sceneCurrentTouchPoints.insert(touchPoint.id(), touchPoint);
+ } else if (touchPoint.state() == Qt::TouchPointReleased) {
+ item = itemForTouchPointId.take(touchPoint.id());
+ if (!item)
+ continue;
+
+ sceneCurrentTouchPoints.remove(touchPoint.id());
+ } else {
+ item = itemForTouchPointId.value(touchPoint.id());
+ if (!item)
+ continue;
+ Q_ASSERT(sceneCurrentTouchPoints.contains(touchPoint.id()));
+ sceneCurrentTouchPoints[touchPoint.id()] = touchPoint;
+ }
+
+ StatesAndTouchPoints &statesAndTouchPoints = itemsNeedingEvents[item];
+ statesAndTouchPoints.first |= touchPoint.state();
+ statesAndTouchPoints.second.append(touchPoint);
+ }
+
+ if (itemsNeedingEvents.isEmpty()) {
+ sceneTouchEvent->accept();
+ return;
+ }
+
+ bool ignoreSceneTouchEvent = true;
+ QHash<QGraphicsItem *, StatesAndTouchPoints>::ConstIterator it = itemsNeedingEvents.constBegin();
+ const QHash<QGraphicsItem *, StatesAndTouchPoints>::ConstIterator end = itemsNeedingEvents.constEnd();
+ for (; it != end; ++it) {
+ QGraphicsItem *item = it.key();
+
+ (void) item->isBlockedByModalPanel(&item);
+
+ // determine event type from the state mask
+ QEvent::Type eventType;
+ switch (it.value().first) {
+ case Qt::TouchPointPressed:
+ // all touch points have pressed state
+ eventType = QEvent::TouchBegin;
+ break;
+ case Qt::TouchPointReleased:
+ // all touch points have released state
+ eventType = QEvent::TouchEnd;
+ break;
+ case Qt::TouchPointStationary:
+ // don't send the event if nothing changed
+ continue;
+ default:
+ // all other combinations
+ eventType = QEvent::TouchUpdate;
+ break;
+ }
+
+ QTouchEvent touchEvent(eventType);
+ touchEvent.setWidget(sceneTouchEvent->widget());
+ touchEvent.setDeviceType(sceneTouchEvent->deviceType());
+ touchEvent.setModifiers(sceneTouchEvent->modifiers());
+ touchEvent.setTouchPointStates(it.value().first);
+ touchEvent.setTouchPoints(it.value().second);
+
+ switch (touchEvent.type()) {
+ case QEvent::TouchBegin:
+ {
+ // if the TouchBegin handler recurses, we assume that means the event
+ // has been implicitly accepted and continue to send touch events
+ item->d_ptr->acceptedTouchBeginEvent = true;
+ bool res = sendTouchBeginEvent(item, &touchEvent)
+ && touchEvent.isAccepted();
+ if (!res) {
+ // forget about these touch points, we didn't handle them
+ for (int i = 0; i < touchEvent.touchPoints().count(); ++i) {
+ const QTouchEvent::TouchPoint &touchPoint = touchEvent.touchPoints().at(i);
+ itemForTouchPointId.remove(touchPoint.id());
+ sceneCurrentTouchPoints.remove(touchPoint.id());
+ }
+ ignoreSceneTouchEvent = false;
+ }
+ break;
+ }
+ default:
+ if (item->d_ptr->acceptedTouchBeginEvent) {
+ updateTouchPointsForItem(item, &touchEvent);
+ (void) sendEvent(item, &touchEvent);
+ ignoreSceneTouchEvent = false;
+ }
+ break;
+ }
+ }
+ sceneTouchEvent->setAccepted(ignoreSceneTouchEvent);
+}
+
+bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEvent *touchEvent)
+{
+ Q_Q(QGraphicsScene);
+
+ if (cachedItemsUnderMouse.isEmpty() || cachedItemsUnderMouse.first() != origin) {
+ const QTouchEvent::TouchPoint &firstTouchPoint = touchEvent->touchPoints().first();
+ cachedItemsUnderMouse = itemsAtPosition(firstTouchPoint.screenPos().toPoint(),
+ firstTouchPoint.scenePos(),
+ touchEvent->widget());
+ }
+ Q_ASSERT(cachedItemsUnderMouse.first() == origin);
+
+ // Set focus on the topmost enabled item that can take focus.
+ bool setFocus = false;
+
+ foreach (QGraphicsItem *item, cachedItemsUnderMouse) {
+ if (item->isEnabled() && ((item->flags() & QGraphicsItem::ItemIsFocusable) && item->d_ptr->mouseSetsFocus)) {
+ if (!item->isWidget() || ((QGraphicsWidget *)item)->focusPolicy() & Qt::ClickFocus) {
+ setFocus = true;
+ if (item != q->focusItem())
+ q->setFocusItem(item, Qt::MouseFocusReason);
+ break;
+ }
+ }
+ if (item->isPanel())
+ break;
+ if (item->d_ptr->flags & QGraphicsItem::ItemStopsClickFocusPropagation)
+ break;
+ if (item->d_ptr->flags & QGraphicsItem::ItemStopsFocusHandling) {
+ // Make sure we don't clear focus.
+ setFocus = true;
+ break;
+ }
+ }
+
+ // If nobody could take focus, clear it.
+ if (!stickyFocus && !setFocus)
+ q->setFocusItem(0, Qt::MouseFocusReason);
+
+ bool res = false;
+ bool eventAccepted = touchEvent->isAccepted();
+ foreach (QGraphicsItem *item, cachedItemsUnderMouse) {
+ // first, try to deliver the touch event
+ updateTouchPointsForItem(item, touchEvent);
+ bool acceptTouchEvents = item->acceptTouchEvents();
+ touchEvent->setAccepted(acceptTouchEvents);
+ res = acceptTouchEvents && sendEvent(item, touchEvent);
+ eventAccepted = touchEvent->isAccepted();
+ if (itemForTouchPointId.value(touchEvent->touchPoints().first().id()) == 0) {
+ // item was deleted
+ item = 0;
+ } else {
+ item->d_ptr->acceptedTouchBeginEvent = (res && eventAccepted);
+ }
+ touchEvent->spont = false;
+ if (res && eventAccepted) {
+ // the first item to accept the TouchBegin gets an implicit grab.
+ for (int i = 0; i < touchEvent->touchPoints().count(); ++i) {
+ const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().at(i);
+ itemForTouchPointId[touchPoint.id()] = item; // can be zero
+ }
+ break;
+ }
+ if (item && item->isPanel())
+ break;
+ }
+
+ touchEvent->setAccepted(eventAccepted);
+ return res;
+}
+
+void QGraphicsScenePrivate::enableTouchEventsOnViews()
+{
+ foreach (QGraphicsView *view, views)
+ view->viewport()->setAttribute(Qt::WA_AcceptTouchEvents, true);
+}
+
+void QGraphicsScenePrivate::updateInputMethodSensitivityInViews()
+{
+ for (int i = 0; i < views.size(); ++i)
+ views.at(i)->d_func()->updateInputMethodSensitivity();
+}
+
+void QGraphicsScenePrivate::enterModal(QGraphicsItem *panel, QGraphicsItem::PanelModality previousModality)
+{
+ Q_Q(QGraphicsScene);
+ Q_ASSERT(panel && panel->isPanel());
+
+ QGraphicsItem::PanelModality panelModality = panel->d_ptr->panelModality;
+ if (previousModality != QGraphicsItem::NonModal) {
+ // the panel is changing from one modality type to another... temporarily set it back so
+ // that blockedPanels is populated correctly
+ panel->d_ptr->panelModality = previousModality;
+ }
+
+ QSet<QGraphicsItem *> blockedPanels;
+ QList<QGraphicsItem *> items = q->items(); // ### store panels separately
+ for (int i = 0; i < items.count(); ++i) {
+ QGraphicsItem *item = items.at(i);
+ if (item->isPanel() && item->isBlockedByModalPanel())
+ blockedPanels.insert(item);
+ }
+ // blockedPanels contains all currently blocked panels
+
+ if (previousModality != QGraphicsItem::NonModal) {
+ // reset the modality to the proper value, since we changed it above
+ panel->d_ptr->panelModality = panelModality;
+ // remove this panel so that it will be reinserted at the front of the stack
+ modalPanels.removeAll(panel);
+ }
+
+ modalPanels.prepend(panel);
+
+ if (!hoverItems.isEmpty()) {
+ // send GraphicsSceneHoverLeave events to newly blocked hoverItems
+ QGraphicsSceneHoverEvent hoverEvent;
+ hoverEvent.setScenePos(lastSceneMousePos);
+ dispatchHoverEvent(&hoverEvent);
+ }
+
+ if (!mouseGrabberItems.isEmpty() && lastMouseGrabberItemHasImplicitMouseGrab) {
+ QGraphicsItem *item = mouseGrabberItems.last();
+ if (item->isBlockedByModalPanel())
+ ungrabMouse(item, /*itemIsDying =*/ false);
+ }
+
+ QEvent windowBlockedEvent(QEvent::WindowBlocked);
+ QEvent windowUnblockedEvent(QEvent::WindowUnblocked);
+ for (int i = 0; i < items.count(); ++i) {
+ QGraphicsItem *item = items.at(i);
+ if (item->isPanel()) {
+ if (!blockedPanels.contains(item) && item->isBlockedByModalPanel()) {
+ // send QEvent::WindowBlocked to newly blocked panels
+ sendEvent(item, &windowBlockedEvent);
+ } else if (blockedPanels.contains(item) && !item->isBlockedByModalPanel()) {
+ // send QEvent::WindowUnblocked to unblocked panels when downgrading
+ // a panel from SceneModal to PanelModal
+ sendEvent(item, &windowUnblockedEvent);
+ }
+ }
+ }
+}
+
+void QGraphicsScenePrivate::leaveModal(QGraphicsItem *panel)
+{
+ Q_Q(QGraphicsScene);
+ Q_ASSERT(panel && panel->isPanel());
+
+ QSet<QGraphicsItem *> blockedPanels;
+ QList<QGraphicsItem *> items = q->items(); // ### same as above
+ for (int i = 0; i < items.count(); ++i) {
+ QGraphicsItem *item = items.at(i);
+ if (item->isPanel() && item->isBlockedByModalPanel())
+ blockedPanels.insert(item);
+ }
+
+ modalPanels.removeAll(panel);
+
+ QEvent e(QEvent::WindowUnblocked);
+ for (int i = 0; i < items.count(); ++i) {
+ QGraphicsItem *item = items.at(i);
+ if (item->isPanel() && blockedPanels.contains(item) && !item->isBlockedByModalPanel())
+ sendEvent(item, &e);
+ }
+
+ // send GraphicsSceneHoverEnter events to newly unblocked items
+ QGraphicsSceneHoverEvent hoverEvent;
+ hoverEvent.setScenePos(lastSceneMousePos);
+ dispatchHoverEvent(&hoverEvent);
+}
+
+#ifndef QT_NO_GESTURES
+void QGraphicsScenePrivate::gestureTargetsAtHotSpots(const QSet<QGesture *> &gestures,
+ Qt::GestureFlag flag,
+ QHash<QGraphicsObject *, QSet<QGesture *> > *targets,
+ QSet<QGraphicsObject *> *itemsSet,
+ QSet<QGesture *> *normal,
+ QSet<QGesture *> *conflicts)
+{
+ QSet<QGesture *> normalGestures; // that are not in conflicted state.
+ foreach (QGesture *gesture, gestures) {
+ if (!gesture->hasHotSpot())
+ continue;
+ const Qt::GestureType gestureType = gesture->gestureType();
+ QList<QGraphicsItem *> items = itemsAtPosition(QPoint(), gesture->d_func()->sceneHotSpot, 0);
+ for (int j = 0; j < items.size(); ++j) {
+ QGraphicsItem *item = items.at(j);
+
+ // Check if the item is blocked by a modal panel and use it as
+ // a target instead of this item.
+ (void) item->isBlockedByModalPanel(&item);
+
+ if (QGraphicsObject *itemobj = item->toGraphicsObject()) {
+ QGraphicsItemPrivate *d = item->QGraphicsItem::d_func();
+ QMap<Qt::GestureType, Qt::GestureFlags>::const_iterator it =
+ d->gestureContext.find(gestureType);
+ if (it != d->gestureContext.end() && (!flag || (it.value() & flag))) {
+ if (normalGestures.contains(gesture)) {
+ normalGestures.remove(gesture);
+ if (conflicts)
+ conflicts->insert(gesture);
+ } else {
+ normalGestures.insert(gesture);
+ }
+ if (targets)
+ (*targets)[itemobj].insert(gesture);
+ if (itemsSet)
+ (*itemsSet).insert(itemobj);
+ }
+ }
+ // Don't propagate through panels.
+ if (item->isPanel())
+ break;
+ }
+ }
+ if (normal)
+ *normal = normalGestures;
+}
+
+void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event)
+{
+ QWidget *viewport = event->widget();
+ if (!viewport)
+ return;
+ QGraphicsView *graphicsView = qobject_cast<QGraphicsView *>(viewport->parent());
+ if (!graphicsView)
+ return;
+
+ QList<QGesture *> allGestures = event->gestures();
+ DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
+ << "Gestures:" << allGestures;
+
+ QSet<QGesture *> startedGestures;
+ QPoint delta = viewport->mapFromGlobal(QPoint());
+ QTransform toScene = QTransform::fromTranslate(delta.x(), delta.y())
+ * graphicsView->viewportTransform().inverted();
+ foreach (QGesture *gesture, allGestures) {
+ // cache scene coordinates of the hot spot
+ if (gesture->hasHotSpot()) {
+ gesture->d_func()->sceneHotSpot = toScene.map(gesture->hotSpot());
+ } else {
+ gesture->d_func()->sceneHotSpot = QPointF();
+ }
+
+ QGraphicsObject *target = gestureTargets.value(gesture, 0);
+ if (!target) {
+ // when we are not in started mode but don't have a target
+ // then the only one interested in gesture is the view/scene
+ if (gesture->state() == Qt::GestureStarted)
+ startedGestures.insert(gesture);
+ }
+ }
+
+ if (!startedGestures.isEmpty()) {
+ QSet<QGesture *> normalGestures; // that have just one target
+ QSet<QGesture *> conflictedGestures; // that have multiple possible targets
+ gestureTargetsAtHotSpots(startedGestures, Qt::GestureFlag(0), &cachedItemGestures, 0,
+ &normalGestures, &conflictedGestures);
+ cachedTargetItems = cachedItemGestures.keys();
+ qSort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst);
+ DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
+ << "Normal gestures:" << normalGestures
+ << "Conflicting gestures:" << conflictedGestures;
+
+ // deliver conflicted gestures as override events AND remember
+ // initial gesture targets
+ if (!conflictedGestures.isEmpty()) {
+ for (int i = 0; i < cachedTargetItems.size(); ++i) {
+ QWeakPointer<QGraphicsObject> item = cachedTargetItems.at(i);
+
+ // get gestures to deliver to the current item
+ QSet<QGesture *> gestures = conflictedGestures & cachedItemGestures.value(item.data());
+ if (gestures.isEmpty())
+ continue;
+
+ DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
+ << "delivering override to"
+ << item.data() << gestures;
+ // send gesture override
+ QGestureEvent ev(gestures.toList());
+ ev.t = QEvent::GestureOverride;
+ ev.setWidget(event->widget());
+ // mark event and individual gestures as ignored
+ ev.ignore();
+ foreach(QGesture *g, gestures)
+ ev.setAccepted(g, false);
+ sendEvent(item.data(), &ev);
+ // mark all accepted gestures to deliver them as normal gesture events
+ foreach (QGesture *g, gestures) {
+ if (ev.isAccepted() || ev.isAccepted(g)) {
+ conflictedGestures.remove(g);
+ // mark the item as a gesture target
+ if (item) {
+ gestureTargets.insert(g, item.data());
+ QHash<QGraphicsObject *, QSet<QGesture *> >::iterator it, e;
+ it = cachedItemGestures.begin();
+ e = cachedItemGestures.end();
+ for(; it != e; ++it)
+ it.value().remove(g);
+ cachedItemGestures[item.data()].insert(g);
+ }
+ DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
+ << "override was accepted:"
+ << g << item.data();
+ }
+ // remember the first item that received the override event
+ // as it most likely become a target if no one else accepts
+ // the override event
+ if (!gestureTargets.contains(g) && item)
+ gestureTargets.insert(g, item.data());
+
+ }
+ if (conflictedGestures.isEmpty())
+ break;
+ }
+ }
+ // remember the initial target item for each gesture that was not in
+ // the conflicted state.
+ if (!normalGestures.isEmpty()) {
+ for (int i = 0; i < cachedTargetItems.size() && !normalGestures.isEmpty(); ++i) {
+ QGraphicsObject *item = cachedTargetItems.at(i);
+
+ // get gestures to deliver to the current item
+ foreach (QGesture *g, cachedItemGestures.value(item)) {
+ if (!gestureTargets.contains(g)) {
+ gestureTargets.insert(g, item);
+ normalGestures.remove(g);
+ }
+ }
+ }
+ }
+ }
+
+
+ // deliver all gesture events
+ QSet<QGesture *> undeliveredGestures;
+ QSet<QGesture *> parentPropagatedGestures;
+ foreach (QGesture *gesture, allGestures) {
+ if (QGraphicsObject *target = gestureTargets.value(gesture, 0)) {
+ cachedItemGestures[target].insert(gesture);
+ cachedTargetItems.append(target);
+ undeliveredGestures.insert(gesture);
+ QGraphicsItemPrivate *d = target->QGraphicsItem::d_func();
+ const Qt::GestureFlags flags = d->gestureContext.value(gesture->gestureType());
+ if (flags & Qt::IgnoredGesturesPropagateToParent)
+ parentPropagatedGestures.insert(gesture);
+ } else {
+ DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
+ << "no target for" << gesture << "at"
+ << gesture->hotSpot() << gesture->d_func()->sceneHotSpot;
+ }
+ }
+ qSort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst);
+ for (int i = 0; i < cachedTargetItems.size(); ++i) {
+ QWeakPointer<QGraphicsObject> receiver = cachedTargetItems.at(i);
+ QSet<QGesture *> gestures =
+ undeliveredGestures & cachedItemGestures.value(receiver.data());
+ gestures -= cachedAlreadyDeliveredGestures.value(receiver.data());
+
+ if (gestures.isEmpty())
+ continue;
+
+ cachedAlreadyDeliveredGestures[receiver.data()] += gestures;
+ const bool isPanel = receiver.data()->isPanel();
+
+ DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
+ << "delivering to"
+ << receiver.data() << gestures;
+ QGestureEvent ev(gestures.toList());
+ ev.setWidget(event->widget());
+ sendEvent(receiver.data(), &ev);
+ QSet<QGesture *> ignoredGestures;
+ foreach (QGesture *g, gestures) {
+ if (!ev.isAccepted() && !ev.isAccepted(g)) {
+ // if the gesture was ignored by its target, we will update the
+ // targetItems list with a possible target items (items that
+ // want to receive partial gestures).
+ // ### wont' work if the target was destroyed in the event
+ // we will just stop delivering it.
+ if (receiver && receiver.data() == gestureTargets.value(g, 0))
+ ignoredGestures.insert(g);
+ } else {
+ if (receiver && g->state() == Qt::GestureStarted) {
+ // someone accepted the propagated initial GestureStarted
+ // event, let it be the new target for all following events.
+ gestureTargets[g] = receiver.data();
+ }
+ undeliveredGestures.remove(g);
+ }
+ }
+ if (undeliveredGestures.isEmpty())
+ break;
+
+ // ignoredGestures list is only filled when delivering to the gesture
+ // target item, so it is safe to assume item == target.
+ if (!ignoredGestures.isEmpty() && !isPanel) {
+ // look for new potential targets for gestures that were ignored
+ // and should be propagated.
+
+ QSet<QGraphicsObject *> targetsSet = cachedTargetItems.toSet();
+
+ if (receiver) {
+ // first if the gesture should be propagated to parents only
+ for (QSet<QGesture *>::iterator it = ignoredGestures.begin();
+ it != ignoredGestures.end();) {
+ if (parentPropagatedGestures.contains(*it)) {
+ QGesture *gesture = *it;
+ const Qt::GestureType gestureType = gesture->gestureType();
+ QGraphicsItem *item = receiver.data();
+ while (item) {
+ if (QGraphicsObject *obj = item->toGraphicsObject()) {
+ if (item->d_func()->gestureContext.contains(gestureType)) {
+ targetsSet.insert(obj);
+ cachedItemGestures[obj].insert(gesture);
+ }
+ }
+ if (item->isPanel())
+ break;
+ item = item->parentItem();
+ }
+
+ it = ignoredGestures.erase(it);
+ continue;
+ }
+ ++it;
+ }
+ }
+
+ gestureTargetsAtHotSpots(ignoredGestures, Qt::ReceivePartialGestures,
+ &cachedItemGestures, &targetsSet, 0, 0);
+
+ cachedTargetItems = targetsSet.toList();
+ qSort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst);
+ DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
+ << "new targets:" << cachedTargetItems;
+ i = -1; // start delivery again
+ continue;
+ }
+ }
+
+ foreach (QGesture *g, startedGestures) {
+ if (g->gestureCancelPolicy() == QGesture::CancelAllInContext) {
+ DEBUG() << "lets try to cancel some";
+ // find gestures in context in Qt::GestureStarted or Qt::GestureUpdated state and cancel them
+ cancelGesturesForChildren(g);
+ }
+ }
+
+ // forget about targets for gestures that have ended
+ foreach (QGesture *g, allGestures) {
+ switch (g->state()) {
+ case Qt::GestureFinished:
+ case Qt::GestureCanceled:
+ gestureTargets.remove(g);
+ break;
+ default:
+ break;
+ }
+ }
+
+ cachedTargetItems.clear();
+ cachedItemGestures.clear();
+ cachedAlreadyDeliveredGestures.clear();
+}
+
+void QGraphicsScenePrivate::cancelGesturesForChildren(QGesture *original)
+{
+ Q_ASSERT(original);
+ QGraphicsItem *originalItem = gestureTargets.value(original);
+ if (originalItem == 0) // we only act on accepted gestures, which implies it has a target.
+ return;
+
+ // iterate over all active gestures and for each find the owner
+ // if the owner is part of our sub-hierarchy, cancel it.
+
+ QSet<QGesture *> canceledGestures;
+ QHash<QGesture *, QGraphicsObject *>::Iterator iter = gestureTargets.begin();
+ while (iter != gestureTargets.end()) {
+ QGraphicsObject *item = iter.value();
+ // note that we don't touch the gestures for our originalItem
+ if (item != originalItem && originalItem->isAncestorOf(item)) {
+ DEBUG() << " found a gesture to cancel" << iter.key();
+ iter.key()->d_func()->state = Qt::GestureCanceled;
+ canceledGestures << iter.key();
+ }
+ ++iter;
+ }
+
+ // sort them per target item by cherry picking from almostCanceledGestures and delivering
+ QSet<QGesture *> almostCanceledGestures = canceledGestures;
+ QSet<QGesture *>::Iterator setIter;
+ while (!almostCanceledGestures.isEmpty()) {
+ QGraphicsObject *target = 0;
+ QSet<QGesture*> gestures;
+ setIter = almostCanceledGestures.begin();
+ // sort per target item
+ while (setIter != almostCanceledGestures.end()) {
+ QGraphicsObject *item = gestureTargets.value(*setIter);
+ if (target == 0)
+ target = item;
+ if (target == item) {
+ gestures << *setIter;
+ setIter = almostCanceledGestures.erase(setIter);
+ } else {
+ ++setIter;
+ }
+ }
+ Q_ASSERT(target);
+
+ QList<QGesture *> list = gestures.toList();
+ QGestureEvent ev(list);
+ sendEvent(target, &ev);
+
+ foreach (QGesture *g, list) {
+ if (ev.isAccepted() || ev.isAccepted(g))
+ gestures.remove(g);
+ }
+
+ foreach (QGesture *g, gestures) {
+ if (!g->hasHotSpot())
+ continue;
+
+ QList<QGraphicsItem *> items = itemsAtPosition(QPoint(), g->d_func()->sceneHotSpot, 0);
+ for (int j = 0; j < items.size(); ++j) {
+ QGraphicsObject *item = items.at(j)->toGraphicsObject();
+ if (!item)
+ continue;
+ QGraphicsItemPrivate *d = item->QGraphicsItem::d_func();
+ if (d->gestureContext.contains(g->gestureType())) {
+ QList<QGesture *> list;
+ list << g;
+ QGestureEvent ev(list);
+ sendEvent(item, &ev);
+ if (ev.isAccepted() || ev.isAccepted(g))
+ break; // successfully delivered
+ }
+ }
+ }
+ }
+
+ QGestureManager *gestureManager = QApplicationPrivate::instance()->gestureManager;
+ Q_ASSERT(gestureManager); // it would be very odd if we got called without a manager.
+ for (setIter = canceledGestures.begin(); setIter != canceledGestures.end(); ++setIter) {
+ gestureManager->recycle(*setIter);
+ gestureTargets.remove(*setIter);
+ }
+}
+
+void QGraphicsScenePrivate::grabGesture(QGraphicsItem *, Qt::GestureType gesture)
+{
+ (void)QGestureManager::instance(); // create a gesture manager
+ if (!grabbedGestures[gesture]++) {
+ foreach (QGraphicsView *view, views)
+ view->viewport()->grabGesture(gesture);
+ }
+}
+
+void QGraphicsScenePrivate::ungrabGesture(QGraphicsItem *item, Qt::GestureType gesture)
+{
+ // we know this can only be an object
+ Q_ASSERT(item->d_ptr->isObject);
+ QGraphicsObject *obj = static_cast<QGraphicsObject *>(item);
+ QGestureManager::instance()->cleanupCachedGestures(obj, gesture);
+ if (!--grabbedGestures[gesture]) {
+ foreach (QGraphicsView *view, views)
+ view->viewport()->ungrabGesture(gesture);
+ }
+}
+#endif // QT_NO_GESTURES
+
+QT_END_NAMESPACE
+
+#include "moc_qgraphicsscene.cpp"
+
+#endif // QT_NO_GRAPHICSVIEW
diff --git a/src/gui/graphicsview/qgraphicsscene.h b/src/widgets/graphicsview/qgraphicsscene.h
index c17ab96074..c17ab96074 100644
--- a/src/gui/graphicsview/qgraphicsscene.h
+++ b/src/widgets/graphicsview/qgraphicsscene.h
diff --git a/src/gui/graphicsview/qgraphicsscene_bsp.cpp b/src/widgets/graphicsview/qgraphicsscene_bsp.cpp
index 3716debcc4..3716debcc4 100644
--- a/src/gui/graphicsview/qgraphicsscene_bsp.cpp
+++ b/src/widgets/graphicsview/qgraphicsscene_bsp.cpp
diff --git a/src/gui/graphicsview/qgraphicsscene_bsp_p.h b/src/widgets/graphicsview/qgraphicsscene_bsp_p.h
index 4f230eff79..4f230eff79 100644
--- a/src/gui/graphicsview/qgraphicsscene_bsp_p.h
+++ b/src/widgets/graphicsview/qgraphicsscene_bsp_p.h
diff --git a/src/widgets/graphicsview/qgraphicsscene_p.h b/src/widgets/graphicsview/qgraphicsscene_p.h
new file mode 100644
index 0000000000..e75013ff8c
--- /dev/null
+++ b/src/widgets/graphicsview/qgraphicsscene_p.h
@@ -0,0 +1,359 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGRAPHICSSCENE_P_H
+#define QGRAPHICSSCENE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgraphicsscene.h"
+
+#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
+
+#include "qgraphicssceneevent.h"
+#include "qgraphicsview.h"
+#include "qgraphicsview_p.h"
+#include "qgraphicsitem_p.h"
+
+#include <private/qobject_p.h>
+#include <QtCore/qbitarray.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qmap.h>
+#include <QtCore/qset.h>
+#include <QtGui/qfont.h>
+#include <QtGui/qpalette.h>
+#include <QtWidgets/qstyle.h>
+#include <QtWidgets/qstyleoption.h>
+
+QT_BEGIN_NAMESPACE
+
+class QGraphicsSceneIndex;
+class QGraphicsView;
+class QGraphicsWidget;
+
+class Q_AUTOTEST_EXPORT QGraphicsScenePrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QGraphicsScene)
+public:
+ QGraphicsScenePrivate();
+ void init();
+
+ static QGraphicsScenePrivate *get(QGraphicsScene *q);
+
+ int changedSignalIndex;
+ int processDirtyItemsIndex;
+ int polishItemsIndex;
+
+ QGraphicsScene::ItemIndexMethod indexMethod;
+ QGraphicsSceneIndex *index;
+
+ int lastItemCount;
+
+ QRectF sceneRect;
+
+ quint32 hasSceneRect : 1;
+ quint32 dirtyGrowingItemsBoundingRect : 1;
+ quint32 updateAll : 1;
+ quint32 calledEmitUpdated : 1;
+ quint32 processDirtyItemsEmitted : 1;
+ quint32 needSortTopLevelItems : 1;
+ quint32 holesInTopLevelSiblingIndex : 1;
+ quint32 topLevelSequentialOrdering : 1;
+ quint32 scenePosDescendantsUpdatePending : 1;
+ quint32 stickyFocus : 1;
+ quint32 hasFocus : 1;
+ quint32 lastMouseGrabberItemHasImplicitMouseGrab : 1;
+ quint32 allItemsIgnoreHoverEvents : 1;
+ quint32 allItemsUseDefaultCursor : 1;
+ quint32 painterStateProtection : 1;
+ quint32 sortCacheEnabled : 1; // for compatibility
+ quint32 allItemsIgnoreTouchEvents : 1;
+ quint32 padding : 15;
+
+ QRectF growingItemsBoundingRect;
+
+ void _q_emitUpdated();
+ QList<QRectF> updatedRects;
+
+ QPainterPath selectionArea;
+ int selectionChanging;
+ QSet<QGraphicsItem *> selectedItems;
+ QVector<QGraphicsItem *> unpolishedItems;
+ QList<QGraphicsItem *> topLevelItems;
+
+ QMap<QGraphicsItem *, QPointF> movingItemsInitialPositions;
+ void registerTopLevelItem(QGraphicsItem *item);
+ void unregisterTopLevelItem(QGraphicsItem *item);
+ void _q_updateLater();
+ void _q_polishItems();
+
+ void _q_processDirtyItems();
+
+ QSet<QGraphicsItem *> scenePosItems;
+ void setScenePosItemEnabled(QGraphicsItem *item, bool enabled);
+ void registerScenePosItem(QGraphicsItem *item);
+ void unregisterScenePosItem(QGraphicsItem *item);
+ void _q_updateScenePosDescendants();
+
+ void removeItemHelper(QGraphicsItem *item);
+
+ QBrush backgroundBrush;
+ QBrush foregroundBrush;
+
+ quint32 rectAdjust;
+ QGraphicsItem *focusItem;
+ QGraphicsItem *lastFocusItem;
+ QGraphicsItem *passiveFocusItem;
+ QGraphicsWidget *tabFocusFirst;
+ QGraphicsItem *activePanel;
+ QGraphicsItem *lastActivePanel;
+ int activationRefCount;
+ int childExplicitActivation;
+ void setActivePanelHelper(QGraphicsItem *item, bool duringActivationEvent);
+ void setFocusItemHelper(QGraphicsItem *item, Qt::FocusReason focusReason);
+
+ QList<QGraphicsWidget *> popupWidgets;
+ void addPopup(QGraphicsWidget *widget);
+ void removePopup(QGraphicsWidget *widget, bool itemIsDying = false);
+
+ QGraphicsItem *lastMouseGrabberItem;
+ QList<QGraphicsItem *> mouseGrabberItems;
+ void grabMouse(QGraphicsItem *item, bool implicit = false);
+ void ungrabMouse(QGraphicsItem *item, bool itemIsDying = false);
+ void clearMouseGrabber();
+
+ QList<QGraphicsItem *> keyboardGrabberItems;
+ void grabKeyboard(QGraphicsItem *item);
+ void ungrabKeyboard(QGraphicsItem *item, bool itemIsDying = false);
+ void clearKeyboardGrabber();
+
+ QGraphicsItem *dragDropItem;
+ QGraphicsWidget *enterWidget;
+ Qt::DropAction lastDropAction;
+ QList<QGraphicsItem *> cachedItemsUnderMouse;
+ QList<QGraphicsItem *> hoverItems;
+ QPointF lastSceneMousePos;
+ void enableMouseTrackingOnViews();
+ QMap<Qt::MouseButton, QPointF> mouseGrabberButtonDownPos;
+ QMap<Qt::MouseButton, QPointF> mouseGrabberButtonDownScenePos;
+ QMap<Qt::MouseButton, QPoint> mouseGrabberButtonDownScreenPos;
+ QList<QGraphicsItem *> itemsAtPosition(const QPoint &screenPos,
+ const QPointF &scenePos,
+ QWidget *widget) const;
+ void storeMouseButtonsForMouseGrabber(QGraphicsSceneMouseEvent *event);
+
+ QList<QGraphicsView *> views;
+ void addView(QGraphicsView *view);
+ void removeView(QGraphicsView *view);
+
+ QMultiMap<QGraphicsItem *, QGraphicsItem *> sceneEventFilters;
+ void installSceneEventFilter(QGraphicsItem *watched, QGraphicsItem *filter);
+ void removeSceneEventFilter(QGraphicsItem *watched, QGraphicsItem *filter);
+ bool filterDescendantEvent(QGraphicsItem *item, QEvent *event);
+ bool filterEvent(QGraphicsItem *item, QEvent *event);
+ bool sendEvent(QGraphicsItem *item, QEvent *event);
+
+ bool dispatchHoverEvent(QGraphicsSceneHoverEvent *hoverEvent);
+ bool itemAcceptsHoverEvents_helper(const QGraphicsItem *item) const;
+ void leaveScene(QWidget *viewport);
+
+ void cloneDragDropEvent(QGraphicsSceneDragDropEvent *dest,
+ QGraphicsSceneDragDropEvent *source);
+ void sendDragDropEvent(QGraphicsItem *item,
+ QGraphicsSceneDragDropEvent *dragDropEvent);
+ void sendHoverEvent(QEvent::Type type, QGraphicsItem *item,
+ QGraphicsSceneHoverEvent *hoverEvent);
+ void sendMouseEvent(QGraphicsSceneMouseEvent *mouseEvent);
+ void mousePressEventHandler(QGraphicsSceneMouseEvent *mouseEvent);
+ QGraphicsWidget *windowForItem(const QGraphicsItem *item) const;
+
+ void drawItemHelper(QGraphicsItem *item, QPainter *painter,
+ const QStyleOptionGraphicsItem *option, QWidget *widget,
+ bool painterStateProtection);
+
+ void drawItems(QPainter *painter, const QTransform *const viewTransform,
+ QRegion *exposedRegion, QWidget *widget);
+
+ void drawSubtreeRecursive(QGraphicsItem *item, QPainter *painter, const QTransform *const,
+ QRegion *exposedRegion, QWidget *widget, qreal parentOpacity = qreal(1.0),
+ const QTransform *const effectTransform = 0);
+ void draw(QGraphicsItem *, QPainter *, const QTransform *const, const QTransform *const,
+ QRegion *, QWidget *, qreal, const QTransform *const, bool, bool);
+
+ void markDirty(QGraphicsItem *item, const QRectF &rect = QRectF(), bool invalidateChildren = false,
+ bool force = false, bool ignoreOpacity = false, bool removingItemFromScene = false,
+ bool updateBoundingRect = false);
+ void processDirtyItemsRecursive(QGraphicsItem *item, bool dirtyAncestorContainsChildren = false,
+ qreal parentOpacity = qreal(1.0));
+
+ inline void resetDirtyItem(QGraphicsItem *item, bool recursive = false)
+ {
+ Q_ASSERT(item);
+ item->d_ptr->dirty = 0;
+ item->d_ptr->paintedViewBoundingRectsNeedRepaint = 0;
+ item->d_ptr->geometryChanged = 0;
+ if (!item->d_ptr->dirtyChildren)
+ recursive = false;
+ item->d_ptr->dirtyChildren = 0;
+ item->d_ptr->needsRepaint = QRectF();
+ item->d_ptr->allChildrenDirty = 0;
+ item->d_ptr->fullUpdatePending = 0;
+ item->d_ptr->ignoreVisible = 0;
+ item->d_ptr->ignoreOpacity = 0;
+#ifndef QT_NO_GRAPHICSEFFECT
+ QGraphicsEffect::ChangeFlags flags;
+ if (item->d_ptr->notifyBoundingRectChanged) {
+ flags |= QGraphicsEffect::SourceBoundingRectChanged;
+ item->d_ptr->notifyBoundingRectChanged = 0;
+ }
+ if (item->d_ptr->notifyInvalidated) {
+ flags |= QGraphicsEffect::SourceInvalidated;
+ item->d_ptr->notifyInvalidated = 0;
+ }
+#endif //QT_NO_GRAPHICSEFFECT
+ if (recursive) {
+ for (int i = 0; i < item->d_ptr->children.size(); ++i)
+ resetDirtyItem(item->d_ptr->children.at(i), recursive);
+ }
+#ifndef QT_NO_GRAPHICSEFFECT
+ if (flags && item->d_ptr->graphicsEffect)
+ item->d_ptr->graphicsEffect->sourceChanged(flags);
+#endif //QT_NO_GRAPHICSEFFECT
+ }
+
+ inline void ensureSortedTopLevelItems()
+ {
+ if (needSortTopLevelItems) {
+ qSort(topLevelItems.begin(), topLevelItems.end(), qt_notclosestLeaf);
+ topLevelSequentialOrdering = false;
+ needSortTopLevelItems = false;
+ }
+ }
+
+ void ensureSequentialTopLevelSiblingIndexes();
+
+ QStyle *style;
+ QFont font;
+ void setFont_helper(const QFont &font);
+ void resolveFont();
+ void updateFont(const QFont &font);
+ QPalette palette;
+ void setPalette_helper(const QPalette &palette);
+ void resolvePalette();
+ void updatePalette(const QPalette &palette);
+
+ QStyleOptionGraphicsItem styleOptionTmp;
+
+ QMap<int, QTouchEvent::TouchPoint> sceneCurrentTouchPoints;
+ QMap<int, QGraphicsItem *> itemForTouchPointId;
+ static void updateTouchPointsForItem(QGraphicsItem *item, QTouchEvent *touchEvent);
+ int findClosestTouchPointId(const QPointF &scenePos);
+ void touchEventHandler(QTouchEvent *touchEvent);
+ bool sendTouchBeginEvent(QGraphicsItem *item, QTouchEvent *touchEvent);
+ void enableTouchEventsOnViews();
+
+ QList<QGraphicsObject *> cachedTargetItems;
+#ifndef QT_NO_GESTURES
+ QHash<QGraphicsObject *, QSet<QGesture *> > cachedItemGestures;
+ QHash<QGraphicsObject *, QSet<QGesture *> > cachedAlreadyDeliveredGestures;
+ QHash<QGesture *, QGraphicsObject *> gestureTargets;
+ QHash<Qt::GestureType, int> grabbedGestures;
+ void gestureEventHandler(QGestureEvent *event);
+ void gestureTargetsAtHotSpots(const QSet<QGesture *> &gestures,
+ Qt::GestureFlag flag,
+ QHash<QGraphicsObject *, QSet<QGesture *> > *targets,
+ QSet<QGraphicsObject *> *itemsSet = 0,
+ QSet<QGesture *> *normal = 0,
+ QSet<QGesture *> *conflicts = 0);
+ void cancelGesturesForChildren(QGesture *original);
+ void grabGesture(QGraphicsItem *, Qt::GestureType gesture);
+ void ungrabGesture(QGraphicsItem *, Qt::GestureType gesture);
+#endif // QT_NO_GESTURES
+
+ void updateInputMethodSensitivityInViews();
+
+ QList<QGraphicsItem *> modalPanels;
+ void enterModal(QGraphicsItem *item,
+ QGraphicsItem::PanelModality panelModality = QGraphicsItem::NonModal);
+ void leaveModal(QGraphicsItem *item);
+};
+
+// QRectF::intersects() returns false always if either the source or target
+// rectangle's width or height are 0. This works around that problem.
+static inline void _q_adjustRect(QRectF *rect)
+{
+ Q_ASSERT(rect);
+ if (!rect->width())
+ rect->adjust(qreal(-0.00001), 0, qreal(0.00001), 0);
+ if (!rect->height())
+ rect->adjust(0, qreal(-0.00001), 0, qreal(0.00001));
+}
+
+static inline QRectF adjustedItemBoundingRect(const QGraphicsItem *item)
+{
+ Q_ASSERT(item);
+ QRectF boundingRect(item->boundingRect());
+ _q_adjustRect(&boundingRect);
+ return boundingRect;
+}
+
+static inline QRectF adjustedItemEffectiveBoundingRect(const QGraphicsItem *item)
+{
+ Q_ASSERT(item);
+ QRectF boundingRect(QGraphicsItemPrivate::get(item)->effectiveBoundingRect());
+ _q_adjustRect(&boundingRect);
+ return boundingRect;
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_GRAPHICSVIEW
+
+#endif
diff --git a/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp b/src/widgets/graphicsview/qgraphicsscenebsptreeindex.cpp
index 4688fa0b6b..4688fa0b6b 100644
--- a/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp
+++ b/src/widgets/graphicsview/qgraphicsscenebsptreeindex.cpp
diff --git a/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h b/src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h
index fadf9d8a74..fadf9d8a74 100644
--- a/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h
+++ b/src/widgets/graphicsview/qgraphicsscenebsptreeindex_p.h
diff --git a/src/widgets/graphicsview/qgraphicssceneevent.cpp b/src/widgets/graphicsview/qgraphicssceneevent.cpp
new file mode 100644
index 0000000000..1236173840
--- /dev/null
+++ b/src/widgets/graphicsview/qgraphicssceneevent.cpp
@@ -0,0 +1,1674 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \class QGraphicsSceneEvent
+ \brief The QGraphicsSceneEvent class provides a base class for all
+ graphics view related events.
+ \since 4.2
+ \ingroup graphicsview-api
+
+ When a QGraphicsView receives Qt mouse, keyboard, and drag and
+ drop events (QMouseEvent, QKeyEvent, QDragEvent, etc.), it
+ translates them into instances of QGraphicsSceneEvent subclasses
+ and forwards them to the QGraphicsScene it displays. The scene
+ then forwards the events to the relevant items.
+
+ For example, when a QGraphicsView receives a QMouseEvent of type
+ MousePress as a response to a user click, the view sends a
+ QGraphicsSceneMouseEvent of type GraphicsSceneMousePress to the
+ underlying QGraphicsScene through its
+ \l{QGraphicsScene::}{mousePressEvent()} function. The default
+ QGraphicsScene::mousePressEvent() implementation determines which
+ item was clicked and forwards the event to
+ QGraphicsItem::mousePressEvent().
+
+ \omit ### Beskrive widget() \endomit
+
+ Subclasses such as QGraphicsSceneMouseEvent and
+ QGraphicsSceneContextMenuEvent provide the coordinates from the
+ original QEvent in screen, scene, and item coordinates (see
+ \l{QGraphicsSceneMouseEvent::}{screenPos()},
+ \l{QGraphicsSceneMouseEvent::}{scenePos()}, and
+ \l{QGraphicsSceneMouseEvent::}{pos()}). The item coordinates are
+ set by the QGraphicsScene before it forwards the event to the
+ event to a QGraphicsItem. The mouse events also add the
+ possibility to retrieve the coordinates from the last event
+ received by the view (see
+ \l{QGraphicsSceneMouseEvent::}{lastScreenPos()},
+ \l{QGraphicsSceneMouseEvent::}{lastScenePos()}, and
+ \l{QGraphicsSceneMouseEvent::}{lastPos()}).
+
+ \sa QEvent
+*/
+
+/*!
+ \class QGraphicsSceneMouseEvent
+ \brief The QGraphicsSceneMouseEvent class provides mouse events
+ in the graphics view framework.
+ \since 4.2
+ \ingroup graphicsview-api
+
+ When a QGraphicsView receives a QMouseEvent, it translates it to a
+ QGraphicsSceneMouseEvent. The event is then forwarded to the
+ QGraphicsScene associated with the view. If the event is not
+ handled by the scene, the view may use it, e.g., for the
+ \l{QGraphicsView::}{DragMode}.
+
+ In addition to containing the item, scene, and screen coordinates
+ of the event (as pos(), scenePos(), and screenPos()), mouse
+ events also contain the coordinates of the previous mouse
+ event received by the view. These can be retrieved with
+ lastPos(), lastScreenPos(), and lastScenePos().
+
+ \sa QGraphicsSceneContextMenuEvent,
+ QGraphicsSceneHoverEvent, QGraphicsSceneWheelEvent,
+ QMouseEvent
+*/
+
+/*!
+ \class QGraphicsSceneWheelEvent
+ \brief The QGraphicsSceneWheelEvent class provides wheel events
+ in the graphics view framework.
+ \brief The QGraphicsSceneWheelEvent class provides wheel events in the
+ graphics view framework.
+ \since 4.2
+ \ingroup graphicsview-api
+
+ \l{QWheelEvent}{QWheelEvent}s received by a QGraphicsView are translated
+ into QGraphicsSceneWheelEvents; it translates the QWheelEvent::globalPos()
+ into item, scene, and screen coordinates (pos(), scenePos(), and
+ screenPos()).
+
+ \sa QGraphicsSceneMouseEvent, QGraphicsSceneContextMenuEvent,
+ QGraphicsSceneHoverEvent, QWheelEvent
+*/
+
+/*!
+ \class QGraphicsSceneContextMenuEvent
+ \brief The QGraphicsSceneContextMenuEvent class provides context
+ menu events in the graphics view framework.
+ \since 4.2
+ \ingroup graphicsview-api
+
+ A QContextMenuEvent received by a QGraphicsView is translated
+ into a QGraphicsSceneContextMenuEvent. The
+ QContextMenuEvent::globalPos() is translated into item, scene, and
+ screen coordinates (pos(), scenePos(), and screenPos()).
+
+ \sa QGraphicsSceneMouseEvent, QGraphicsSceneWheelEvent,
+ QContextMenuEvent
+*/
+
+/*!
+ \enum QGraphicsSceneContextMenuEvent::Reason
+
+ This enum describes the reason why the context event was sent.
+
+ \value Mouse The mouse caused the event to be sent. On most
+ platforms, this means the right mouse button was clicked.
+
+ \value Keyboard The keyboard caused this event to be sent. On
+ Windows and Mac OS X, this means the menu button was pressed.
+
+ \value Other The event was sent by some other means (i.e. not
+ by the mouse or keyboard).
+*/
+
+/*!
+ \class QGraphicsSceneHoverEvent
+ \brief The QGraphicsSceneHoverEvent class provides hover events
+ in the graphics view framework.
+ \since 4.2
+ \ingroup graphicsview-api
+
+ When a QGraphicsView receives a QHoverEvent event, it translates
+ it into QGraphicsSceneHoverEvent. The event is then forwarded to
+ the QGraphicsScene associated with the view.
+
+ \sa QGraphicsSceneMouseEvent, QGraphicsSceneContextMenuEvent,
+ QGraphicsSceneWheelEvent, QHoverEvent
+*/
+
+/*!
+ \class QGraphicsSceneHelpEvent
+ \brief The QGraphicsSceneHelpEvent class provides events when a
+ tooltip is requested.
+ \since 4.2
+ \ingroup graphicsview-api
+
+ When a QGraphicsView receives a QEvent of type
+ QEvent::ToolTip, it creates a QGraphicsSceneHelpEvent, which is
+ forwarded to the scene. You can set a tooltip on a QGraphicsItem
+ with \l{QGraphicsItem::}{setToolTip()}; by default QGraphicsScene
+ displays the tooltip of the QGraphicsItem with the highest
+ z-value (i.e, the top-most item) under the mouse position.
+
+ QGraphicsView does not forward events when
+ \l{QWhatsThis}{"What's This"} and \l{QStatusTipEvent}{status tip}
+ help is requested. If you need this, you can reimplement
+ QGraphicsView::viewportEvent() and forward QStatusTipEvent
+ events and \l{QEvent}{QEvents} of type QEvent::WhatsThis to the
+ scene.
+
+ \sa QEvent
+*/
+
+/*!
+ \class QGraphicsSceneDragDropEvent
+ \brief The QGraphicsSceneDragDropEvent class provides events for
+ drag and drop in the graphics view framework.
+ \since 4.2
+ \ingroup graphicsview-api
+
+ QGraphicsView inherits the drag and drop functionality provided
+ by QWidget. When it receives a drag and drop event, it translates
+ it to a QGraphicsSceneDragDropEvent.
+
+ QGraphicsSceneDragDropEvent stores events of type
+ GraphicsSceneDragEnter, GraphicsSceneDragLeave,
+ GraphicsSceneDragMove, or GraphicsSceneDrop.
+
+ QGraphicsSceneDragDropEvent contains the position of the mouse
+ cursor in both item, scene, and screen coordinates; this can be
+ retrieved with pos(), scenePos(), and screenPos().
+
+ The scene sends the event to the first QGraphicsItem under the
+ mouse cursor that accepts drops; a graphics item is set to accept
+ drops with \l{QGraphicsItem::}{setAcceptDrops()}.
+*/
+
+/*!
+ \class QGraphicsSceneResizeEvent
+ \brief The QGraphicsSceneResizeEvent class provides events for widget
+ resizing in the graphics view framework.
+ \since 4.4
+ \ingroup graphicsview-api
+
+ A QGraphicsWidget sends itself a QGraphicsSceneResizeEvent immediately
+ when its geometry changes.
+
+ It's similar to QResizeEvent, but its sizes, oldSize() and newSize(), use
+ QSizeF instead of QSize.
+
+ \sa QGraphicsWidget::setGeometry(), QGraphicsWidget::resize()
+*/
+
+/*!
+ \class QGraphicsSceneMoveEvent
+ \brief The QGraphicsSceneMoveEvent class provides events for widget
+ moving in the graphics view framework.
+ \since 4.4
+ \ingroup graphicsview-api
+
+ A QGraphicsWidget sends itself a QGraphicsSceneMoveEvent immediately when
+ its local position changes. The delivery is implemented as part of
+ QGraphicsItem::itemChange().
+
+ It's similar to QMoveEvent, but its positions, oldPos() and newPos(), use
+ QPointF instead of QPoint.
+
+ \sa QGraphicsItem::setPos(), QGraphicsItem::ItemPositionChange,
+ QGraphicsItem::ItemPositionHasChanged
+*/
+
+#include "qgraphicssceneevent.h"
+
+#ifndef QT_NO_GRAPHICSVIEW
+
+#ifndef QT_NO_DEBUG
+#include <QtCore/qdebug.h>
+#endif
+#include <QtCore/qmap.h>
+#include <QtCore/qpoint.h>
+#include <QtCore/qsize.h>
+#include <QtCore/qstring.h>
+#include "qgraphicsview.h"
+#include "qgraphicsitem.h"
+#include <QtWidgets/qgesture.h>
+#include <private/qevent_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QGraphicsSceneEventPrivate
+{
+public:
+ inline QGraphicsSceneEventPrivate()
+ : widget(0),
+ q_ptr(0)
+ { }
+
+ inline virtual ~QGraphicsSceneEventPrivate()
+ { }
+
+ QWidget *widget;
+ QGraphicsSceneEvent *q_ptr;
+};
+
+/*!
+ \internal
+
+ Constructs a generic graphics scene event of the specified \a type.
+*/
+QGraphicsSceneEvent::QGraphicsSceneEvent(Type type)
+ : QEvent(type), d_ptr(new QGraphicsSceneEventPrivate)
+{
+ d_ptr->q_ptr = this;
+}
+
+/*!
+ \internal
+
+ Constructs a generic graphics scene event.
+*/
+QGraphicsSceneEvent::QGraphicsSceneEvent(QGraphicsSceneEventPrivate &dd, Type type)
+ : QEvent(type), d_ptr(&dd)
+{
+ d_ptr->q_ptr = this;
+}
+
+/*!
+ Destroys the event.
+*/
+QGraphicsSceneEvent::~QGraphicsSceneEvent()
+{
+}
+
+/*!
+ Returns the widget where the event originated, or 0 if the event
+ originates from another application.
+*/
+QWidget *QGraphicsSceneEvent::widget() const
+{
+ return d_ptr->widget;
+}
+
+/*!
+ \internal
+
+ Sets the \a widget related to this event.
+
+ \sa widget()
+*/
+void QGraphicsSceneEvent::setWidget(QWidget *widget)
+{
+ d_ptr->widget = widget;
+}
+
+class QGraphicsSceneMouseEventPrivate : public QGraphicsSceneEventPrivate
+{
+ Q_DECLARE_PUBLIC(QGraphicsSceneMouseEvent)
+public:
+ inline QGraphicsSceneMouseEventPrivate()
+ : button(Qt::NoButton),
+ buttons(0), modifiers(0)
+ { }
+
+ QPointF pos;
+ QPointF scenePos;
+ QPoint screenPos;
+ QPointF lastPos;
+ QPointF lastScenePos;
+ QPoint lastScreenPos;
+ QMap<Qt::MouseButton, QPointF> buttonDownPos;
+ QMap<Qt::MouseButton, QPointF> buttonDownScenePos;
+ QMap<Qt::MouseButton, QPoint> buttonDownScreenPos;
+ Qt::MouseButton button;
+ Qt::MouseButtons buttons;
+ Qt::KeyboardModifiers modifiers;
+};
+
+/*!
+ \internal
+
+ Constructs a generic graphics scene mouse event of the specified \a type.
+*/
+QGraphicsSceneMouseEvent::QGraphicsSceneMouseEvent(Type type)
+ : QGraphicsSceneEvent(*new QGraphicsSceneMouseEventPrivate, type)
+{
+}
+
+/*!
+ Destroys the event.
+*/
+QGraphicsSceneMouseEvent::~QGraphicsSceneMouseEvent()
+{
+}
+
+/*!
+ Returns the mouse cursor position in item coordinates.
+
+ \sa scenePos(), screenPos(), lastPos()
+*/
+QPointF QGraphicsSceneMouseEvent::pos() const
+{
+ Q_D(const QGraphicsSceneMouseEvent);
+ return d->pos;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneMouseEvent::setPos(const QPointF &pos)
+{
+ Q_D(QGraphicsSceneMouseEvent);
+ d->pos = pos;
+}
+
+/*!
+ Returns the mouse cursor position in scene coordinates.
+
+ \sa pos(), screenPos(), lastScenePos()
+*/
+QPointF QGraphicsSceneMouseEvent::scenePos() const
+{
+ Q_D(const QGraphicsSceneMouseEvent);
+ return d->scenePos;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneMouseEvent::setScenePos(const QPointF &pos)
+{
+ Q_D(QGraphicsSceneMouseEvent);
+ d->scenePos = pos;
+}
+
+/*!
+ Returns the mouse cursor position in screen coordinates.
+
+ \sa pos(), scenePos(), lastScreenPos()
+*/
+QPoint QGraphicsSceneMouseEvent::screenPos() const
+{
+ Q_D(const QGraphicsSceneMouseEvent);
+ return d->screenPos;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneMouseEvent::setScreenPos(const QPoint &pos)
+{
+ Q_D(QGraphicsSceneMouseEvent);
+ d->screenPos = pos;
+}
+
+/*!
+ Returns the mouse cursor position in item coordinates where the specified
+ \a button was clicked.
+
+ \sa buttonDownScenePos(), buttonDownScreenPos(), pos()
+*/
+QPointF QGraphicsSceneMouseEvent::buttonDownPos(Qt::MouseButton button) const
+{
+ Q_D(const QGraphicsSceneMouseEvent);
+ return d->buttonDownPos.value(button);
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneMouseEvent::setButtonDownPos(Qt::MouseButton button, const QPointF &pos)
+{
+ Q_D(QGraphicsSceneMouseEvent);
+ d->buttonDownPos.insert(button, pos);
+}
+
+/*!
+ Returns the mouse cursor position in scene coordinates where the
+ specified \a button was clicked.
+
+ \sa buttonDownPos(), buttonDownScreenPos(), scenePos()
+*/
+QPointF QGraphicsSceneMouseEvent::buttonDownScenePos(Qt::MouseButton button) const
+{
+ Q_D(const QGraphicsSceneMouseEvent);
+ return d->buttonDownScenePos.value(button);
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneMouseEvent::setButtonDownScenePos(Qt::MouseButton button, const QPointF &pos)
+{
+ Q_D(QGraphicsSceneMouseEvent);
+ d->buttonDownScenePos.insert(button, pos);
+}
+
+/*!
+ Returns the mouse cursor position in screen coordinates where the
+ specified \a button was clicked.
+
+ \sa screenPos(), buttonDownPos(), buttonDownScenePos()
+*/
+QPoint QGraphicsSceneMouseEvent::buttonDownScreenPos(Qt::MouseButton button) const
+{
+ Q_D(const QGraphicsSceneMouseEvent);
+ return d->buttonDownScreenPos.value(button);
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneMouseEvent::setButtonDownScreenPos(Qt::MouseButton button, const QPoint &pos)
+{
+ Q_D(QGraphicsSceneMouseEvent);
+ d->buttonDownScreenPos.insert(button, pos);
+}
+
+/*!
+ Returns the last recorded mouse cursor position in item
+ coordinates.
+
+ \sa lastScenePos(), lastScreenPos(), pos()
+*/
+QPointF QGraphicsSceneMouseEvent::lastPos() const
+{
+ Q_D(const QGraphicsSceneMouseEvent);
+ return d->lastPos;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneMouseEvent::setLastPos(const QPointF &pos)
+{
+ Q_D(QGraphicsSceneMouseEvent);
+ d->lastPos = pos;
+}
+
+/*!
+ Returns the last recorded mouse cursor position in scene
+ coordinates. The last recorded position is the position of
+ the previous mouse event received by the view that created
+ the event.
+
+ \sa lastPos(), lastScreenPos(), scenePos()
+*/
+QPointF QGraphicsSceneMouseEvent::lastScenePos() const
+{
+ Q_D(const QGraphicsSceneMouseEvent);
+ return d->lastScenePos;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneMouseEvent::setLastScenePos(const QPointF &pos)
+{
+ Q_D(QGraphicsSceneMouseEvent);
+ d->lastScenePos = pos;
+}
+
+/*!
+ Returns the last recorded mouse cursor position in screen
+ coordinates. The last recorded position is the position of
+ the previous mouse event received by the view that created
+ the event.
+
+ \sa lastPos(), lastScenePos(), screenPos()
+*/
+QPoint QGraphicsSceneMouseEvent::lastScreenPos() const
+{
+ Q_D(const QGraphicsSceneMouseEvent);
+ return d->lastScreenPos;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneMouseEvent::setLastScreenPos(const QPoint &pos)
+{
+ Q_D(QGraphicsSceneMouseEvent);
+ d->lastScreenPos = pos;
+}
+
+/*!
+ Returns the combination of mouse buttons that were pressed at the
+ time the event was sent.
+
+ \sa button(), modifiers()
+*/
+Qt::MouseButtons QGraphicsSceneMouseEvent::buttons() const
+{
+ Q_D(const QGraphicsSceneMouseEvent);
+ return d->buttons;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneMouseEvent::setButtons(Qt::MouseButtons buttons)
+{
+ Q_D(QGraphicsSceneMouseEvent);
+ d->buttons = buttons;
+}
+
+/*!
+ Returns the mouse button (if any) that caused the event.
+
+ \sa buttons(), modifiers()
+*/
+Qt::MouseButton QGraphicsSceneMouseEvent::button() const
+{
+ Q_D(const QGraphicsSceneMouseEvent);
+ return d->button;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneMouseEvent::setButton(Qt::MouseButton button)
+{
+ Q_D(QGraphicsSceneMouseEvent);
+ d->button = button;
+}
+
+/*!
+ Returns the keyboard modifiers in use at the time the event was
+ sent.
+
+ \sa buttons(), button()
+*/
+Qt::KeyboardModifiers QGraphicsSceneMouseEvent::modifiers() const
+{
+ Q_D(const QGraphicsSceneMouseEvent);
+ return d->modifiers;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneMouseEvent::setModifiers(Qt::KeyboardModifiers modifiers)
+{
+ Q_D(QGraphicsSceneMouseEvent);
+ d->modifiers = modifiers;
+}
+
+class QGraphicsSceneWheelEventPrivate : public QGraphicsSceneEventPrivate
+{
+ Q_DECLARE_PUBLIC(QGraphicsSceneWheelEvent)
+public:
+ inline QGraphicsSceneWheelEventPrivate()
+ : buttons(0), modifiers(0), delta(0), orientation(Qt::Horizontal)
+ { }
+
+ QPointF pos;
+ QPointF scenePos;
+ QPoint screenPos;
+ Qt::MouseButtons buttons;
+ Qt::KeyboardModifiers modifiers;
+ int delta;
+ Qt::Orientation orientation;
+};
+
+/*!
+ \internal
+
+ Constructs a QGraphicsSceneWheelEvent of type \a type, which
+ is always QEvent::GraphicsSceneWheel.
+*/
+QGraphicsSceneWheelEvent::QGraphicsSceneWheelEvent(Type type)
+ : QGraphicsSceneEvent(*new QGraphicsSceneWheelEventPrivate, type)
+{
+}
+
+/*!
+ Destroys the QGraphicsSceneWheelEvent.
+*/
+QGraphicsSceneWheelEvent::~QGraphicsSceneWheelEvent()
+{
+}
+
+/*!
+ Returns the position of the cursor in item coordinates when the
+ wheel event occurred.
+
+ \sa scenePos(), screenPos()
+*/
+QPointF QGraphicsSceneWheelEvent::pos() const
+{
+ Q_D(const QGraphicsSceneWheelEvent);
+ return d->pos;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneWheelEvent::setPos(const QPointF &pos)
+{
+ Q_D(QGraphicsSceneWheelEvent);
+ d->pos = pos;
+}
+
+/*!
+ Returns the position of the cursor in scene coordinates when the wheel
+ event occurred.
+
+ \sa pos(), screenPos()
+*/
+QPointF QGraphicsSceneWheelEvent::scenePos() const
+{
+ Q_D(const QGraphicsSceneWheelEvent);
+ return d->scenePos;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneWheelEvent::setScenePos(const QPointF &pos)
+{
+ Q_D(QGraphicsSceneWheelEvent);
+ d->scenePos = pos;
+}
+
+/*!
+ Returns the position of the cursor in screen coordinates when the wheel
+ event occurred.
+
+ \sa pos(), scenePos()
+*/
+QPoint QGraphicsSceneWheelEvent::screenPos() const
+{
+ Q_D(const QGraphicsSceneWheelEvent);
+ return d->screenPos;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneWheelEvent::setScreenPos(const QPoint &pos)
+{
+ Q_D(QGraphicsSceneWheelEvent);
+ d->screenPos = pos;
+}
+
+/*!
+ Returns the mouse buttons that were pressed when the wheel event occurred.
+
+ \sa modifiers()
+*/
+Qt::MouseButtons QGraphicsSceneWheelEvent::buttons() const
+{
+ Q_D(const QGraphicsSceneWheelEvent);
+ return d->buttons;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneWheelEvent::setButtons(Qt::MouseButtons buttons)
+{
+ Q_D(QGraphicsSceneWheelEvent);
+ d->buttons = buttons;
+}
+
+/*!
+ Returns the keyboard modifiers that were active when the wheel event
+ occurred.
+
+ \sa buttons()
+*/
+Qt::KeyboardModifiers QGraphicsSceneWheelEvent::modifiers() const
+{
+ Q_D(const QGraphicsSceneWheelEvent);
+ return d->modifiers;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneWheelEvent::setModifiers(Qt::KeyboardModifiers modifiers)
+{
+ Q_D(QGraphicsSceneWheelEvent);
+ d->modifiers = modifiers;
+}
+
+/*!
+ Returns the distance that the wheel is rotated, in eighths (1/8s)
+ of a degree. A positive value indicates that the wheel was
+ rotated forwards away from the user; a negative value indicates
+ that the wheel was rotated backwards toward the user.
+
+ Most mouse types work in steps of 15 degrees, in which case the delta
+ value is a multiple of 120 (== 15 * 8).
+*/
+int QGraphicsSceneWheelEvent::delta() const
+{
+ Q_D(const QGraphicsSceneWheelEvent);
+ return d->delta;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneWheelEvent::setDelta(int delta)
+{
+ Q_D(QGraphicsSceneWheelEvent);
+ d->delta = delta;
+}
+
+/*!
+ Returns the wheel orientation.
+*/
+Qt::Orientation QGraphicsSceneWheelEvent::orientation() const
+{
+ Q_D(const QGraphicsSceneWheelEvent);
+ return d->orientation;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneWheelEvent::setOrientation(Qt::Orientation orientation)
+{
+ Q_D(QGraphicsSceneWheelEvent);
+ d->orientation = orientation;
+}
+
+class QGraphicsSceneContextMenuEventPrivate : public QGraphicsSceneEventPrivate
+{
+ Q_DECLARE_PUBLIC(QGraphicsSceneContextMenuEvent)
+ public:
+ inline QGraphicsSceneContextMenuEventPrivate()
+ : modifiers(0), reason(QGraphicsSceneContextMenuEvent::Other)
+ { }
+
+ QPointF pos;
+ QPointF scenePos;
+ QPoint screenPos;
+ Qt::KeyboardModifiers modifiers;
+ QGraphicsSceneContextMenuEvent::Reason reason;
+};
+
+/*!
+ \internal
+
+ Constructs a graphics scene context menu event of the specified \a type.
+*/
+QGraphicsSceneContextMenuEvent::QGraphicsSceneContextMenuEvent(Type type)
+ : QGraphicsSceneEvent(*new QGraphicsSceneContextMenuEventPrivate, type)
+{
+}
+
+/*!
+ Destroys the event.
+*/
+QGraphicsSceneContextMenuEvent::~QGraphicsSceneContextMenuEvent()
+{
+}
+
+/*!
+ Returns the position of the mouse cursor in item coordinates at the moment
+ the context menu was requested.
+
+ \sa scenePos(), screenPos()
+*/
+QPointF QGraphicsSceneContextMenuEvent::pos() const
+{
+ Q_D(const QGraphicsSceneContextMenuEvent);
+ return d->pos;
+}
+
+/*!
+ \fn void QGraphicsSceneContextMenuEvent::setPos(const QPointF &point)
+ \internal
+
+ Sets the position associated with the context menu to the given \a point
+ in item coordinates.
+*/
+void QGraphicsSceneContextMenuEvent::setPos(const QPointF &pos)
+{
+ Q_D(QGraphicsSceneContextMenuEvent);
+ d->pos = pos;
+}
+
+/*!
+ Returns the position of the mouse cursor in scene coordinates at the moment the
+ the context menu was requested.
+
+ \sa pos(), screenPos()
+*/
+QPointF QGraphicsSceneContextMenuEvent::scenePos() const
+{
+ Q_D(const QGraphicsSceneContextMenuEvent);
+ return d->scenePos;
+}
+
+/*!
+ \fn void QGraphicsSceneContextMenuEvent::setScenePos(const QPointF &point)
+ \internal
+
+ Sets the position associated with the context menu to the given \a point
+ in scene coordinates.
+*/
+void QGraphicsSceneContextMenuEvent::setScenePos(const QPointF &pos)
+{
+ Q_D(QGraphicsSceneContextMenuEvent);
+ d->scenePos = pos;
+}
+
+/*!
+ Returns the position of the mouse cursor in screen coordinates at the moment the
+ the context menu was requested.
+
+ \sa pos(), scenePos()
+*/
+QPoint QGraphicsSceneContextMenuEvent::screenPos() const
+{
+ Q_D(const QGraphicsSceneContextMenuEvent);
+ return d->screenPos;
+}
+
+/*!
+ \fn void QGraphicsSceneContextMenuEvent::setScreenPos(const QPoint &point)
+ \internal
+
+ Sets the position associated with the context menu to the given \a point
+ in screen coordinates.
+*/
+void QGraphicsSceneContextMenuEvent::setScreenPos(const QPoint &pos)
+{
+ Q_D(QGraphicsSceneContextMenuEvent);
+ d->screenPos = pos;
+}
+
+/*!
+ Returns the keyboard modifiers in use when the context menu was requested.
+*/
+Qt::KeyboardModifiers QGraphicsSceneContextMenuEvent::modifiers() const
+{
+ Q_D(const QGraphicsSceneContextMenuEvent);
+ return d->modifiers;
+}
+
+/*!
+ \internal
+
+ Sets the keyboard modifiers associated with the context menu to the \a
+ modifiers specified.
+*/
+void QGraphicsSceneContextMenuEvent::setModifiers(Qt::KeyboardModifiers modifiers)
+{
+ Q_D(QGraphicsSceneContextMenuEvent);
+ d->modifiers = modifiers;
+}
+
+/*!
+ Returns the reason for the context menu event.
+
+ \sa QGraphicsSceneContextMenuEvent::Reason
+*/
+QGraphicsSceneContextMenuEvent::Reason QGraphicsSceneContextMenuEvent::reason() const
+{
+ Q_D(const QGraphicsSceneContextMenuEvent);
+ return d->reason;
+}
+
+/*!
+ \internal
+ Sets the reason for the context menu event to \a reason.
+
+ \sa reason()
+*/
+void QGraphicsSceneContextMenuEvent::setReason(Reason reason)
+{
+ Q_D(QGraphicsSceneContextMenuEvent);
+ d->reason = reason;
+}
+
+class QGraphicsSceneHoverEventPrivate : public QGraphicsSceneEventPrivate
+{
+public:
+ QPointF pos;
+ QPointF scenePos;
+ QPoint screenPos;
+ QPointF lastPos;
+ QPointF lastScenePos;
+ QPoint lastScreenPos;
+ Qt::KeyboardModifiers modifiers;
+};
+
+/*!
+ \internal
+
+ Constructs a graphics scene hover event of the specified \a type.
+*/
+QGraphicsSceneHoverEvent::QGraphicsSceneHoverEvent(Type type)
+ : QGraphicsSceneEvent(*new QGraphicsSceneHoverEventPrivate, type)
+{
+}
+
+/*!
+ Destroys the event.
+*/
+QGraphicsSceneHoverEvent::~QGraphicsSceneHoverEvent()
+{
+}
+
+/*!
+ Returns the position of the mouse cursor in item coordinates at the moment
+ the hover event was sent.
+
+ \sa scenePos(), screenPos()
+*/
+QPointF QGraphicsSceneHoverEvent::pos() const
+{
+ Q_D(const QGraphicsSceneHoverEvent);
+ return d->pos;
+}
+
+/*!
+ \fn void QGraphicsSceneHoverEvent::setPos(const QPointF &point)
+ \internal
+
+ Sets the position associated with the hover event to the given \a point in
+ item coordinates.
+*/
+void QGraphicsSceneHoverEvent::setPos(const QPointF &pos)
+{
+ Q_D(QGraphicsSceneHoverEvent);
+ d->pos = pos;
+}
+
+/*!
+ Returns the position of the mouse cursor in scene coordinates at the
+ moment the hover event was sent.
+
+ \sa pos(), screenPos()
+*/
+QPointF QGraphicsSceneHoverEvent::scenePos() const
+{
+ Q_D(const QGraphicsSceneHoverEvent);
+ return d->scenePos;
+}
+
+/*!
+ \fn void QGraphicsSceneHoverEvent::setScenePos(const QPointF &point)
+ \internal
+
+ Sets the position associated with the hover event to the given \a point in
+ scene coordinates.
+*/
+void QGraphicsSceneHoverEvent::setScenePos(const QPointF &pos)
+{
+ Q_D(QGraphicsSceneHoverEvent);
+ d->scenePos = pos;
+}
+
+/*!
+ Returns the position of the mouse cursor in screen coordinates at the
+ moment the hover event was sent.
+
+ \sa pos(), scenePos()
+*/
+QPoint QGraphicsSceneHoverEvent::screenPos() const
+{
+ Q_D(const QGraphicsSceneHoverEvent);
+ return d->screenPos;
+}
+
+/*!
+ \fn void QGraphicsSceneHoverEvent::setScreenPos(const QPoint &point)
+ \internal
+
+ Sets the position associated with the hover event to the given \a point in
+ screen coordinates.
+*/
+void QGraphicsSceneHoverEvent::setScreenPos(const QPoint &pos)
+{
+ Q_D(QGraphicsSceneHoverEvent);
+ d->screenPos = pos;
+}
+
+/*!
+ \since 4.4
+
+ Returns the last recorded mouse cursor position in item coordinates.
+
+ \sa lastScenePos(), lastScreenPos(), pos()
+*/
+QPointF QGraphicsSceneHoverEvent::lastPos() const
+{
+ Q_D(const QGraphicsSceneHoverEvent);
+ return d->lastPos;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneHoverEvent::setLastPos(const QPointF &pos)
+{
+ Q_D(QGraphicsSceneHoverEvent);
+ d->lastPos = pos;
+}
+
+/*!
+ \since 4.4
+
+ Returns the last recorded, the scene coordinates of the previous mouse or
+ hover event received by the view, that created the event mouse cursor
+ position in scene coordinates.
+
+ \sa lastPos(), lastScreenPos(), scenePos()
+*/
+QPointF QGraphicsSceneHoverEvent::lastScenePos() const
+{
+ Q_D(const QGraphicsSceneHoverEvent);
+ return d->lastScenePos;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneHoverEvent::setLastScenePos(const QPointF &pos)
+{
+ Q_D(QGraphicsSceneHoverEvent);
+ d->lastScenePos = pos;
+}
+
+/*!
+ \since 4.4
+
+ Returns the last recorded mouse cursor position in screen coordinates. The
+ last recorded position is the position of the previous mouse or hover
+ event received by the view that created the event.
+
+ \sa lastPos(), lastScenePos(), screenPos()
+*/
+QPoint QGraphicsSceneHoverEvent::lastScreenPos() const
+{
+ Q_D(const QGraphicsSceneHoverEvent);
+ return d->lastScreenPos;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneHoverEvent::setLastScreenPos(const QPoint &pos)
+{
+ Q_D(QGraphicsSceneHoverEvent);
+ d->lastScreenPos = pos;
+}
+
+/*!
+ \since 4.4
+
+ Returns the keyboard modifiers at the moment the hover event was sent.
+*/
+Qt::KeyboardModifiers QGraphicsSceneHoverEvent::modifiers() const
+{
+ Q_D(const QGraphicsSceneHoverEvent);
+ return d->modifiers;
+}
+
+/*!
+ \fn void QGraphicsSceneHoverEvent::setModifiers(Qt::KeyboardModifiers modifiers)
+ \internal
+
+ Sets the modifiers for the current hover event to \a modifiers.
+*/
+void QGraphicsSceneHoverEvent::setModifiers(Qt::KeyboardModifiers modifiers)
+{
+ Q_D(QGraphicsSceneHoverEvent);
+ d->modifiers = modifiers;
+}
+
+class QGraphicsSceneHelpEventPrivate : public QGraphicsSceneEventPrivate
+{
+public:
+ QPointF scenePos;
+ QPoint screenPos;
+};
+
+/*!
+ \internal
+
+ Constructs a graphics scene help event of the specified \a type.
+*/
+QGraphicsSceneHelpEvent::QGraphicsSceneHelpEvent(Type type)
+ : QGraphicsSceneEvent(*new QGraphicsSceneHelpEventPrivate, type)
+{
+}
+
+/*!
+ Destroys the event.
+*/
+QGraphicsSceneHelpEvent::~QGraphicsSceneHelpEvent()
+{
+}
+
+/*!
+ Returns the position of the mouse cursor in scene coordinates at the
+ moment the help event was sent.
+
+ \sa screenPos()
+*/
+QPointF QGraphicsSceneHelpEvent::scenePos() const
+{
+ Q_D(const QGraphicsSceneHelpEvent);
+ return d->scenePos;
+}
+
+/*!
+ \fn void QGraphicsSceneHelpEvent::setScenePos(const QPointF &point)
+ \internal
+
+ Sets the position associated with the context menu to the given \a point
+ in scene coordinates.
+*/
+void QGraphicsSceneHelpEvent::setScenePos(const QPointF &pos)
+{
+ Q_D(QGraphicsSceneHelpEvent);
+ d->scenePos = pos;
+}
+
+/*!
+ Returns the position of the mouse cursor in screen coordinates at the
+ moment the help event was sent.
+
+ \sa scenePos()
+*/
+QPoint QGraphicsSceneHelpEvent::screenPos() const
+{
+ Q_D(const QGraphicsSceneHelpEvent);
+ return d->screenPos;
+}
+
+/*!
+ \fn void QGraphicsSceneHelpEvent::setScreenPos(const QPoint &point)
+ \internal
+
+ Sets the position associated with the context menu to the given \a point
+ in screen coordinates.
+*/
+void QGraphicsSceneHelpEvent::setScreenPos(const QPoint &pos)
+{
+ Q_D(QGraphicsSceneHelpEvent);
+ d->screenPos = pos;
+}
+
+class QGraphicsSceneDragDropEventPrivate : public QGraphicsSceneEventPrivate
+{
+ Q_DECLARE_PUBLIC(QGraphicsSceneDragDropEvent)
+public:
+ inline QGraphicsSceneDragDropEventPrivate()
+ : source(0), mimeData(0)
+ { }
+
+ QPointF pos;
+ QPointF scenePos;
+ QPoint screenPos;
+ Qt::MouseButtons buttons;
+ Qt::KeyboardModifiers modifiers;
+ Qt::DropActions possibleActions;
+ Qt::DropAction proposedAction;
+ Qt::DropAction dropAction;
+ QWidget *source;
+ const QMimeData *mimeData;
+};
+
+/*!
+ \internal
+
+ Constructs a new QGraphicsSceneDragDropEvent of the
+ specified \a type. The type can be either
+ QEvent::GraphicsSceneDragEnter, QEvent::GraphicsSceneDragLeave,
+ QEvent::GraphicsSceneDragMove, or QEvent::GraphicsSceneDrop.
+*/
+QGraphicsSceneDragDropEvent::QGraphicsSceneDragDropEvent(Type type)
+ : QGraphicsSceneEvent(*new QGraphicsSceneDragDropEventPrivate, type)
+{
+}
+
+/*!
+ Destroys the object.
+*/
+QGraphicsSceneDragDropEvent::~QGraphicsSceneDragDropEvent()
+{
+}
+
+/*!
+ Returns the mouse position of the event relative to the
+ view that sent the event.
+
+ \sa QGraphicsView, screenPos(), scenePos()
+*/
+QPointF QGraphicsSceneDragDropEvent::pos() const
+{
+ Q_D(const QGraphicsSceneDragDropEvent);
+ return d->pos;
+}
+
+/*!
+ \internal
+ Sets the position of the mouse to \a pos; this should be
+ relative to the widget that generated the event, which normally
+ is a QGraphicsView.
+
+ \sa pos(), setScenePos(), setScreenPos()
+*/
+
+void QGraphicsSceneDragDropEvent::setPos(const QPointF &pos)
+{
+ Q_D(QGraphicsSceneDragDropEvent);
+ d->pos = pos;
+}
+
+/*!
+ Returns the position of the mouse in scene coordinates.
+
+ \sa pos(), screenPos()
+*/
+QPointF QGraphicsSceneDragDropEvent::scenePos() const
+{
+ Q_D(const QGraphicsSceneDragDropEvent);
+ return d->scenePos;
+}
+
+/*!
+ \internal
+ Sets the scene position of the mouse to \a pos.
+
+ \sa scenePos(), setScreenPos(), setPos()
+*/
+void QGraphicsSceneDragDropEvent::setScenePos(const QPointF &pos)
+{
+ Q_D(QGraphicsSceneDragDropEvent);
+ d->scenePos = pos;
+}
+
+/*!
+ Returns the position of the mouse relative to the screen.
+
+ \sa pos(), scenePos()
+*/
+QPoint QGraphicsSceneDragDropEvent::screenPos() const
+{
+ Q_D(const QGraphicsSceneDragDropEvent);
+ return d->screenPos;
+}
+
+/*!
+ \internal
+ Sets the mouse position relative to the screen to \a pos.
+
+ \sa screenPos(), setScenePos(), setPos()
+*/
+void QGraphicsSceneDragDropEvent::setScreenPos(const QPoint &pos)
+{
+ Q_D(QGraphicsSceneDragDropEvent);
+ d->screenPos = pos;
+}
+
+/*!
+ Returns a Qt::MouseButtons value indicating which buttons
+ were pressed on the mouse when this mouse event was
+ generated.
+
+ \sa Qt::MouseButtons
+*/
+Qt::MouseButtons QGraphicsSceneDragDropEvent::buttons() const
+{
+ Q_D(const QGraphicsSceneDragDropEvent);
+ return d->buttons;
+}
+
+/*!
+ \internal
+ Sets the mouse buttons that were pressed when the event was
+ created to \a buttons.
+
+ \sa Qt::MouseButtons, buttons()
+*/
+void QGraphicsSceneDragDropEvent::setButtons(Qt::MouseButtons buttons)
+{
+ Q_D(QGraphicsSceneDragDropEvent);
+ d->buttons = buttons;
+}
+
+/*!
+ Returns the keyboard modifiers that were pressed when the drag
+ and drop event was created.
+
+ \sa Qt::KeyboardModifiers
+*/
+Qt::KeyboardModifiers QGraphicsSceneDragDropEvent::modifiers() const
+{
+ Q_D(const QGraphicsSceneDragDropEvent);
+ return d->modifiers;
+}
+
+/*!
+ \internal
+ Sets the keyboard modifiers that were pressed when the event
+ was created to \a modifiers.
+
+ \sa Qt::KeyboardModifiers, modifiers()
+*/
+
+void QGraphicsSceneDragDropEvent::setModifiers(Qt::KeyboardModifiers modifiers)
+{
+ Q_D(QGraphicsSceneDragDropEvent);
+ d->modifiers = modifiers;
+}
+
+/*!
+ Returns the possible drop actions that the drag and
+ drop can result in.
+
+ \sa Qt::DropActions
+*/
+
+Qt::DropActions QGraphicsSceneDragDropEvent::possibleActions() const
+{
+ Q_D(const QGraphicsSceneDragDropEvent);
+ return d->possibleActions;
+}
+
+/*!
+ \internal
+ Sets the possible drop actions that the drag can
+ result in to \a actions.
+
+ \sa Qt::DropActions, possibleActions()
+*/
+void QGraphicsSceneDragDropEvent::setPossibleActions(Qt::DropActions actions)
+{
+ Q_D(QGraphicsSceneDragDropEvent);
+ d->possibleActions = actions;
+}
+
+/*!
+ Returns the drop action that is proposed, i.e., preferred.
+ The action must be one of the possible actions as defined by
+ \c possibleActions().
+
+ \sa Qt::DropAction, possibleActions()
+*/
+
+Qt::DropAction QGraphicsSceneDragDropEvent::proposedAction() const
+{
+ Q_D(const QGraphicsSceneDragDropEvent);
+ return d->proposedAction;
+}
+
+/*!
+ \internal
+ Sets the proposed action to \a action. The proposed action
+ is a Qt::DropAction that is one of the possible actions as
+ given by \c possibleActions().
+
+ \sa proposedAction(), Qt::DropAction, possibleActions()
+*/
+
+void QGraphicsSceneDragDropEvent::setProposedAction(Qt::DropAction action)
+{
+ Q_D(QGraphicsSceneDragDropEvent);
+ d->proposedAction = action;
+}
+
+/*!
+ Sets the proposed action as accepted, i.e, the drop action
+ is set to the proposed action. This is equal to:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicssceneevent.cpp 0
+
+ When using this function, one should not call \c accept().
+
+ \sa dropAction(), setDropAction(), proposedAction()
+*/
+
+void QGraphicsSceneDragDropEvent::acceptProposedAction()
+{
+ Q_D(QGraphicsSceneDragDropEvent);
+ d->dropAction = d->proposedAction;
+}
+
+/*!
+ Returns the action that was performed in this drag and drop.
+ This should be set by the receiver of the drop and is
+ returned by QDrag::exec().
+
+ \sa setDropAction(), acceptProposedAction()
+*/
+
+Qt::DropAction QGraphicsSceneDragDropEvent::dropAction() const
+{
+ Q_D(const QGraphicsSceneDragDropEvent);
+ return d->dropAction;
+}
+
+/*!
+ This function lets the receiver of the drop set the drop
+ action that was performed to \a action, which should be one
+ of the
+ \l{QGraphicsSceneDragDropEvent::possibleActions()}{possible
+ actions}. Call \c accept() in stead of \c
+ acceptProposedAction() if you use this function.
+
+ \sa dropAction(), accept(), possibleActions()
+*/
+void QGraphicsSceneDragDropEvent::setDropAction(Qt::DropAction action)
+{
+ Q_D(QGraphicsSceneDragDropEvent);
+ d->dropAction = action;
+}
+
+/*!
+ This function returns the QGraphicsView that created the
+ QGraphicsSceneDragDropEvent.
+*/
+QWidget *QGraphicsSceneDragDropEvent::source() const
+{
+ Q_D(const QGraphicsSceneDragDropEvent);
+ return d->source;
+}
+
+/*!
+ \internal
+ This function set the source widget, i.e., the widget that
+ created the drop event, to \a source.
+*/
+void QGraphicsSceneDragDropEvent::setSource(QWidget *source)
+{
+ Q_D(QGraphicsSceneDragDropEvent);
+ d->source = source;
+}
+
+/*!
+ This function returns the MIME data of the event.
+*/
+const QMimeData *QGraphicsSceneDragDropEvent::mimeData() const
+{
+ Q_D(const QGraphicsSceneDragDropEvent);
+ return d->mimeData;
+}
+
+/*!
+ \internal
+ This function sets the MIME data for the event.
+*/
+void QGraphicsSceneDragDropEvent::setMimeData(const QMimeData *data)
+{
+ Q_D(QGraphicsSceneDragDropEvent);
+ d->mimeData = data;
+}
+
+class QGraphicsSceneResizeEventPrivate : public QGraphicsSceneEventPrivate
+{
+ Q_DECLARE_PUBLIC(QGraphicsSceneResizeEvent)
+public:
+ inline QGraphicsSceneResizeEventPrivate()
+ { }
+
+ QSizeF oldSize;
+ QSizeF newSize;
+};
+
+/*!
+ Constructs a QGraphicsSceneResizeEvent.
+*/
+QGraphicsSceneResizeEvent::QGraphicsSceneResizeEvent()
+ : QGraphicsSceneEvent(*new QGraphicsSceneResizeEventPrivate, QEvent::GraphicsSceneResize)
+{
+}
+
+/*!
+ Destroys the QGraphicsSceneResizeEvent.
+*/
+QGraphicsSceneResizeEvent::~QGraphicsSceneResizeEvent()
+{
+}
+
+/*!
+ Returns the old size (i.e., the size immediately before the widget was
+ resized).
+
+ \sa newSize(), QGraphicsWidget::resize()
+*/
+QSizeF QGraphicsSceneResizeEvent::oldSize() const
+{
+ Q_D(const QGraphicsSceneResizeEvent);
+ return d->oldSize;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneResizeEvent::setOldSize(const QSizeF &size)
+{
+ Q_D(QGraphicsSceneResizeEvent);
+ d->oldSize = size;
+}
+
+/*!
+ Returns the new size (i.e., the current size).
+
+ \sa oldSize(), QGraphicsWidget::resize()
+*/
+QSizeF QGraphicsSceneResizeEvent::newSize() const
+{
+ Q_D(const QGraphicsSceneResizeEvent);
+ return d->newSize;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneResizeEvent::setNewSize(const QSizeF &size)
+{
+ Q_D(QGraphicsSceneResizeEvent);
+ d->newSize = size;
+}
+
+class QGraphicsSceneMoveEventPrivate : public QGraphicsSceneEventPrivate
+{
+ Q_DECLARE_PUBLIC(QGraphicsSceneMoveEvent)
+public:
+ inline QGraphicsSceneMoveEventPrivate()
+ { }
+
+ QPointF oldPos;
+ QPointF newPos;
+};
+
+/*!
+ Constructs a QGraphicsSceneMoveEvent.
+*/
+QGraphicsSceneMoveEvent::QGraphicsSceneMoveEvent()
+ : QGraphicsSceneEvent(*new QGraphicsSceneMoveEventPrivate, QEvent::GraphicsSceneMove)
+{
+}
+
+/*!
+ Destroys the QGraphicsSceneMoveEvent.
+*/
+QGraphicsSceneMoveEvent::~QGraphicsSceneMoveEvent()
+{
+}
+
+/*!
+ Returns the old position (i.e., the position immediately before the widget
+ was moved).
+
+ \sa newPos(), QGraphicsItem::setPos()
+*/
+QPointF QGraphicsSceneMoveEvent::oldPos() const
+{
+ Q_D(const QGraphicsSceneMoveEvent);
+ return d->oldPos;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneMoveEvent::setOldPos(const QPointF &pos)
+{
+ Q_D(QGraphicsSceneMoveEvent);
+ d->oldPos = pos;
+}
+
+/*!
+ Returns the new position (i.e., the current position).
+
+ \sa oldPos(), QGraphicsItem::setPos()
+*/
+QPointF QGraphicsSceneMoveEvent::newPos() const
+{
+ Q_D(const QGraphicsSceneMoveEvent);
+ return d->newPos;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsSceneMoveEvent::setNewPos(const QPointF &pos)
+{
+ Q_D(QGraphicsSceneMoveEvent);
+ d->newPos = pos;
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_GRAPHICSVIEW
diff --git a/src/gui/graphicsview/qgraphicssceneevent.h b/src/widgets/graphicsview/qgraphicssceneevent.h
index afaa33c9ce..afaa33c9ce 100644
--- a/src/gui/graphicsview/qgraphicssceneevent.h
+++ b/src/widgets/graphicsview/qgraphicssceneevent.h
diff --git a/src/gui/graphicsview/qgraphicssceneindex.cpp b/src/widgets/graphicsview/qgraphicssceneindex.cpp
index 964e9cb0ef..964e9cb0ef 100644
--- a/src/gui/graphicsview/qgraphicssceneindex.cpp
+++ b/src/widgets/graphicsview/qgraphicssceneindex.cpp
diff --git a/src/gui/graphicsview/qgraphicssceneindex_p.h b/src/widgets/graphicsview/qgraphicssceneindex_p.h
index e498e822fa..e498e822fa 100644
--- a/src/gui/graphicsview/qgraphicssceneindex_p.h
+++ b/src/widgets/graphicsview/qgraphicssceneindex_p.h
diff --git a/src/gui/graphicsview/qgraphicsscenelinearindex.cpp b/src/widgets/graphicsview/qgraphicsscenelinearindex.cpp
index 074d43961a..074d43961a 100644
--- a/src/gui/graphicsview/qgraphicsscenelinearindex.cpp
+++ b/src/widgets/graphicsview/qgraphicsscenelinearindex.cpp
diff --git a/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h b/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h
new file mode 100644
index 0000000000..04d134b0d6
--- /dev/null
+++ b/src/widgets/graphicsview/qgraphicsscenelinearindex_p.h
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGRAPHICSSCENELINEARINDEX_H
+#define QGRAPHICSSCENELINEARINDEX_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qglobal.h>
+
+#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
+
+#include <QtCore/qrect.h>
+#include <QtCore/qlist.h>
+#include <QtWidgets/qgraphicsitem.h>
+#include <private/qgraphicssceneindex_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class Q_AUTOTEST_EXPORT QGraphicsSceneLinearIndex : public QGraphicsSceneIndex
+{
+ Q_OBJECT
+
+public:
+ QGraphicsSceneLinearIndex(QGraphicsScene *scene = 0) : QGraphicsSceneIndex(scene)
+ { }
+
+ QList<QGraphicsItem *> items(Qt::SortOrder order = Qt::DescendingOrder) const
+ { Q_UNUSED(order); return m_items; }
+
+ virtual QList<QGraphicsItem *> estimateItems(const QRectF &rect, Qt::SortOrder order) const
+ {
+ Q_UNUSED(rect);
+ Q_UNUSED(order);
+ return m_items;
+ }
+
+protected :
+ virtual void clear()
+ { m_items.clear(); }
+
+ virtual void addItem(QGraphicsItem *item)
+ { m_items << item; }
+
+ virtual void removeItem(QGraphicsItem *item)
+ { m_items.removeOne(item); }
+
+private:
+ QList<QGraphicsItem*> m_items;
+};
+
+#endif // QT_NO_GRAPHICSVIEW
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QGRAPHICSSCENELINEARINDEX_H
diff --git a/src/gui/graphicsview/qgraphicstransform.cpp b/src/widgets/graphicsview/qgraphicstransform.cpp
index 513c41f46f..513c41f46f 100644
--- a/src/gui/graphicsview/qgraphicstransform.cpp
+++ b/src/widgets/graphicsview/qgraphicstransform.cpp
diff --git a/src/gui/graphicsview/qgraphicstransform.h b/src/widgets/graphicsview/qgraphicstransform.h
index e2dd05b5be..e2dd05b5be 100644
--- a/src/gui/graphicsview/qgraphicstransform.h
+++ b/src/widgets/graphicsview/qgraphicstransform.h
diff --git a/src/gui/graphicsview/qgraphicstransform_p.h b/src/widgets/graphicsview/qgraphicstransform_p.h
index 2a0bf859e3..2a0bf859e3 100644
--- a/src/gui/graphicsview/qgraphicstransform_p.h
+++ b/src/widgets/graphicsview/qgraphicstransform_p.h
diff --git a/src/widgets/graphicsview/qgraphicsview.cpp b/src/widgets/graphicsview/qgraphicsview.cpp
new file mode 100644
index 0000000000..07f09eb298
--- /dev/null
+++ b/src/widgets/graphicsview/qgraphicsview.cpp
@@ -0,0 +1,3880 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+static const int QGRAPHICSVIEW_REGION_RECT_THRESHOLD = 50;
+
+static const int QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS = 503; // largest prime < 2^9
+
+/*!
+ \class QGraphicsView
+ \brief The QGraphicsView class provides a widget for displaying the
+ contents of a QGraphicsScene.
+ \since 4.2
+ \ingroup graphicsview-api
+
+
+ QGraphicsView visualizes the contents of a QGraphicsScene in a scrollable
+ viewport. To create a scene with geometrical items, see QGraphicsScene's
+ documentation. QGraphicsView is part of the \l{Graphics View Framework}.
+
+ To visualize a scene, you start by constructing a QGraphicsView object,
+ passing the address of the scene you want to visualize to QGraphicsView's
+ constructor. Alternatively, you can call setScene() to set the scene at a
+ later point. After you call show(), the view will by default scroll to the
+ center of the scene and display any items that are visible at this
+ point. For example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp 0
+
+ You can explicitly scroll to any position on the scene by using the
+ scroll bars, or by calling centerOn(). By passing a point to centerOn(),
+ QGraphicsView will scroll its viewport to ensure that the point is
+ centered in the view. An overload is provided for scrolling to a
+ QGraphicsItem, in which case QGraphicsView will see to that the center of
+ the item is centered in the view. If all you want is to ensure that a
+ certain area is visible, (but not necessarily centered,) you can call
+ ensureVisible() instead.
+
+ QGraphicsView can be used to visualize a whole scene, or only parts of it.
+ The visualized area is by default detected automatically when the view is
+ displayed for the first time (by calling
+ QGraphicsScene::itemsBoundingRect()). To set the visualized area rectangle
+ yourself, you can call setSceneRect(). This will adjust the scroll bars'
+ ranges appropriately. Note that although the scene supports a virtually
+ unlimited size, the range of the scroll bars will never exceed the range of
+ an integer (INT_MIN, INT_MAX).
+
+ QGraphicsView visualizes the scene by calling render(). By default, the
+ items are drawn onto the viewport by using a regular QPainter, and using
+ default render hints. To change the default render hints that
+ QGraphicsView passes to QPainter when painting items, you can call
+ setRenderHints().
+
+ By default, QGraphicsView provides a regular QWidget for the viewport
+ widget. You can access this widget by calling viewport(), or you can
+ replace it by calling setViewport(). To render using OpenGL, simply call
+ setViewport(new QGLWidget). QGraphicsView takes ownership of the viewport
+ widget.
+
+ QGraphicsView supports affine transformations, using QTransform. You can
+ either pass a matrix to setTransform(), or you can call one of the
+ convenience functions rotate(), scale(), translate() or shear(). The most
+ two common transformations are scaling, which is used to implement
+ zooming, and rotation. QGraphicsView keeps the center of the view fixed
+ during a transformation. Because of the scene alignment (setAligment()),
+ translating the view will have no visual impact.
+
+ You can interact with the items on the scene by using the mouse and
+ keyboard. QGraphicsView translates the mouse and key events into \e scene
+ events, (events that inherit QGraphicsSceneEvent,), and forward them to
+ the visualized scene. In the end, it's the individual item that handles
+ the events and reacts to them. For example, if you click on a selectable
+ item, the item will typically let the scene know that it has been
+ selected, and it will also redraw itself to display a selection
+ rectangle. Similiary, if you click and drag the mouse to move a movable
+ item, it's the item that handles the mouse moves and moves itself. Item
+ interaction is enabled by default, and you can toggle it by calling
+ setInteractive().
+
+ You can also provide your own custom scene interaction, by creating a
+ subclass of QGraphicsView, and reimplementing the mouse and key event
+ handlers. To simplify how you programmatically interact with items in the
+ view, QGraphicsView provides the mapping functions mapToScene() and
+ mapFromScene(), and the item accessors items() and itemAt(). These
+ functions allow you to map points, rectangles, polygons and paths between
+ view coordinates and scene coordinates, and to find items on the scene
+ using view coordinates.
+
+ \img graphicsview-view.png
+
+ \sa QGraphicsScene, QGraphicsItem, QGraphicsSceneEvent
+*/
+
+/*!
+ \enum QGraphicsView::ViewportAnchor
+
+ This enums describe the possible anchors that QGraphicsView can
+ use when the user resizes the view or when the view is
+ transformed.
+
+ \value NoAnchor No anchor, i.e. the view leaves the scene's
+ position unchanged.
+ \value AnchorViewCenter The scene point at the center of the view
+ is used as the anchor.
+ \value AnchorUnderMouse The point under the mouse is used as the anchor.
+
+ \sa resizeAnchor, transformationAnchor
+*/
+
+/*!
+ \enum QGraphicsView::ViewportUpdateMode
+
+ \since 4.3
+
+ This enum describes how QGraphicsView updates its viewport when the scene
+ contents change or are exposed.
+
+ \value FullViewportUpdate When any visible part of the scene changes or is
+ reexposed, QGraphicsView will update the entire viewport. This approach is
+ fastest when QGraphicsView spends more time figuring out what to draw than
+ it would spend drawing (e.g., when very many small items are repeatedly
+ updated). This is the preferred update mode for viewports that do not
+ support partial updates, such as QGLWidget, and for viewports that need to
+ disable scroll optimization.
+
+ \value MinimalViewportUpdate QGraphicsView will determine the minimal
+ viewport region that requires a redraw, minimizing the time spent drawing
+ by avoiding a redraw of areas that have not changed. This is
+ QGraphicsView's default mode. Although this approach provides the best
+ performance in general, if there are many small visible changes on the
+ scene, QGraphicsView might end up spending more time finding the minimal
+ approach than it will spend drawing.
+
+ \value SmartViewportUpdate QGraphicsView will attempt to find an optimal
+ update mode by analyzing the areas that require a redraw.
+
+ \value BoundingRectViewportUpdate The bounding rectangle of all changes in
+ the viewport will be redrawn. This mode has the advantage that
+ QGraphicsView searches only one region for changes, minimizing time spent
+ determining what needs redrawing. The disadvantage is that areas that have
+ not changed also need to be redrawn.
+
+ \value NoViewportUpdate QGraphicsView will never update its viewport when
+ the scene changes; the user is expected to control all updates. This mode
+ disables all (potentially slow) item visibility testing in QGraphicsView,
+ and is suitable for scenes that either require a fixed frame rate, or where
+ the viewport is otherwise updated externally.
+
+ \sa viewportUpdateMode
+*/
+
+/*!
+ \enum QGraphicsView::OptimizationFlag
+
+ \since 4.3
+
+ This enum describes flags that you can enable to improve rendering
+ performance in QGraphicsView. By default, none of these flags are set.
+ Note that setting a flag usually imposes a side effect, and this effect
+ can vary between paint devices and platforms.
+
+ \value DontClipPainter This value is obsolete and has no effect.
+
+ \value DontSavePainterState When rendering, QGraphicsView protects the
+ painter state (see QPainter::save()) when rendering the background or
+ foreground, and when rendering each item. This allows you to leave the
+ painter in an altered state (i.e., you can call QPainter::setPen() or
+ QPainter::setBrush() without restoring the state after painting). However,
+ if the items consistently do restore the state, you should enable this
+ flag to prevent QGraphicsView from doing the same.
+
+ \value DontAdjustForAntialiasing Disables QGraphicsView's antialiasing
+ auto-adjustment of exposed areas. Items that render antialiased lines on
+ the boundaries of their QGraphicsItem::boundingRect() can end up rendering
+ parts of the line outside. To prevent rendering artifacts, QGraphicsView
+ expands all exposed regions by 2 pixels in all directions. If you enable
+ this flag, QGraphicsView will no longer perform these adjustments,
+ minimizing the areas that require redrawing, which improves performance. A
+ common side effect is that items that do draw with antialiasing can leave
+ painting traces behind on the scene as they are moved.
+
+ \value IndirectPainting Since Qt 4.6, restore the old painting algorithm
+ that calls QGraphicsView::drawItems() and QGraphicsScene::drawItems().
+ To be used only for compatibility with old code.
+*/
+
+/*!
+ \enum QGraphicsView::CacheModeFlag
+
+ This enum describes the flags that you can set for a QGraphicsView's cache
+ mode.
+
+ \value CacheNone All painting is done directly onto the viewport.
+
+ \value CacheBackground The background is cached. This affects both custom
+ backgrounds, and backgrounds based on the backgroundBrush property. When
+ this flag is enabled, QGraphicsView will allocate one pixmap with the full
+ size of the viewport.
+
+ \sa cacheMode
+*/
+
+/*!
+ \enum QGraphicsView::DragMode
+
+ This enum describes the default action for the view when pressing and
+ dragging the mouse over the viewport.
+
+ \value NoDrag Nothing happens; the mouse event is ignored.
+
+ \value ScrollHandDrag The cursor changes into a pointing hand, and
+ dragging the mouse around will scroll the scrolbars. This mode works both
+ in \l{QGraphicsView::interactive}{interactive} and non-interactive mode.
+
+ \value RubberBandDrag A rubber band will appear. Dragging the mouse will
+ set the rubber band geometry, and all items covered by the rubber band are
+ selected. This mode is disabled for non-interactive views.
+
+ \sa dragMode, QGraphicsScene::setSelectionArea()
+*/
+
+#include "qgraphicsview.h"
+#include "qgraphicsview_p.h"
+
+#ifndef QT_NO_GRAPHICSVIEW
+
+#include "qgraphicsitem.h"
+#include "qgraphicsitem_p.h"
+#include "qgraphicsscene.h"
+#include "qgraphicsscene_p.h"
+#include "qgraphicssceneevent.h"
+#include "qgraphicswidget.h"
+
+#include <QtCore/qdatetime.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qmath.h>
+#include <QtWidgets/qapplication.h>
+#include <QtWidgets/qdesktopwidget.h>
+#include <QtGui/qevent.h>
+#include <QtWidgets/qlayout.h>
+#include <QtGui/qtransform.h>
+#include <QtGui/qmatrix.h>
+#include <QtGui/qpainter.h>
+#include <QtWidgets/qscrollbar.h>
+#include <QtWidgets/qstyleoption.h>
+#include <QtWidgets/qinputcontext.h>
+#ifdef Q_WS_X11
+#include <QtGui/qpaintengine.h>
+#include <private/qt_x11_p.h>
+#endif
+
+#include <private/qevent_p.h>
+
+QT_BEGIN_NAMESPACE
+
+bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event);
+
+inline int q_round_bound(qreal d) //### (int)(qreal) INT_MAX != INT_MAX for single precision
+{
+ if (d <= (qreal) INT_MIN)
+ return INT_MIN;
+ else if (d >= (qreal) INT_MAX)
+ return INT_MAX;
+ return d >= 0.0 ? int(d + 0.5) : int(d - int(d-1) + 0.5) + int(d-1);
+}
+
+void QGraphicsViewPrivate::translateTouchEvent(QGraphicsViewPrivate *d, QTouchEvent *touchEvent)
+{
+ QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();
+ for (int i = 0; i < touchPoints.count(); ++i) {
+ QTouchEvent::TouchPoint &touchPoint = touchPoints[i];
+ // the scene will set the item local pos, startPos, lastPos, and rect before delivering to
+ // an item, but for now those functions are returning the view's local coordinates
+ touchPoint.setSceneRect(d->mapToScene(touchPoint.rect()));
+ touchPoint.setStartScenePos(d->mapToScene(touchPoint.startPos()));
+ touchPoint.setLastScenePos(d->mapToScene(touchPoint.lastPos()));
+
+ // screenPos, startScreenPos, lastScreenPos, and screenRect are already set
+ }
+
+ touchEvent->setTouchPoints(touchPoints);
+}
+
+/*!
+ \internal
+*/
+QGraphicsViewPrivate::QGraphicsViewPrivate()
+ : renderHints(QPainter::TextAntialiasing),
+ dragMode(QGraphicsView::NoDrag),
+ sceneInteractionAllowed(true), hasSceneRect(false),
+ connectedToScene(false),
+ useLastMouseEvent(false),
+ identityMatrix(true),
+ dirtyScroll(true),
+ accelerateScrolling(true),
+ keepLastCenterPoint(true),
+ transforming(false),
+ handScrolling(false),
+ mustAllocateStyleOptions(false),
+ mustResizeBackgroundPixmap(true),
+ fullUpdatePending(true),
+ hasUpdateClip(false),
+ mousePressButton(Qt::NoButton),
+ leftIndent(0), topIndent(0),
+ lastMouseEvent(QEvent::None, QPoint(), Qt::NoButton, 0, 0),
+ alignment(Qt::AlignCenter),
+ transformationAnchor(QGraphicsView::AnchorViewCenter), resizeAnchor(QGraphicsView::NoAnchor),
+ viewportUpdateMode(QGraphicsView::MinimalViewportUpdate),
+ optimizationFlags(0),
+ scene(0),
+#ifndef QT_NO_RUBBERBAND
+ rubberBanding(false),
+ rubberBandSelectionMode(Qt::IntersectsItemShape),
+#endif
+ handScrollMotions(0), cacheMode(0),
+#ifndef QT_NO_CURSOR
+ hasStoredOriginalCursor(false),
+#endif
+ lastDragDropEvent(0),
+ updateSceneSlotReimplementedChecked(false)
+{
+ styleOptions.reserve(QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS);
+}
+
+/*!
+ \internal
+*/
+void QGraphicsViewPrivate::recalculateContentSize()
+{
+ Q_Q(QGraphicsView);
+
+ QSize maxSize = q->maximumViewportSize();
+ int width = maxSize.width();
+ int height = maxSize.height();
+ QRectF viewRect = matrix.mapRect(q->sceneRect());
+
+ bool frameOnlyAround = (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, 0, q));
+ if (frameOnlyAround) {
+ if (hbarpolicy == Qt::ScrollBarAlwaysOn)
+ height -= frameWidth * 2;
+ if (vbarpolicy == Qt::ScrollBarAlwaysOn)
+ width -= frameWidth * 2;
+ }
+
+ // Adjust the maximum width and height of the viewport based on the width
+ // of visible scroll bars.
+ int scrollBarExtent = q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, q);
+ if (frameOnlyAround)
+ scrollBarExtent += frameWidth * 2;
+
+ bool useHorizontalScrollBar = (viewRect.width() > width) && hbarpolicy != Qt::ScrollBarAlwaysOff;
+ bool useVerticalScrollBar = (viewRect.height() > height) && vbarpolicy != Qt::ScrollBarAlwaysOff;
+ if (useHorizontalScrollBar && !useVerticalScrollBar) {
+ if (viewRect.height() > height - scrollBarExtent)
+ useVerticalScrollBar = true;
+ }
+ if (useVerticalScrollBar && !useHorizontalScrollBar) {
+ if (viewRect.width() > width - scrollBarExtent)
+ useHorizontalScrollBar = true;
+ }
+ if (useHorizontalScrollBar && hbarpolicy != Qt::ScrollBarAlwaysOn)
+ height -= scrollBarExtent;
+ if (useVerticalScrollBar && vbarpolicy != Qt::ScrollBarAlwaysOn)
+ width -= scrollBarExtent;
+
+ // Setting the ranges of these scroll bars can/will cause the values to
+ // change, and scrollContentsBy() will be called correspondingly. This
+ // will reset the last center point.
+ QPointF savedLastCenterPoint = lastCenterPoint;
+
+ // Remember the former indent settings
+ qreal oldLeftIndent = leftIndent;
+ qreal oldTopIndent = topIndent;
+
+ // If the whole scene fits horizontally, we center the scene horizontally,
+ // and ignore the horizontal scroll bars.
+ int left = q_round_bound(viewRect.left());
+ int right = q_round_bound(viewRect.right() - width);
+ if (left >= right) {
+ hbar->setRange(0, 0);
+
+ switch (alignment & Qt::AlignHorizontal_Mask) {
+ case Qt::AlignLeft:
+ leftIndent = -viewRect.left();
+ break;
+ case Qt::AlignRight:
+ leftIndent = width - viewRect.width() - viewRect.left() - 1;
+ break;
+ case Qt::AlignHCenter:
+ default:
+ leftIndent = width / 2 - (viewRect.left() + viewRect.right()) / 2;
+ break;
+ }
+ } else {
+ hbar->setRange(left, right);
+ hbar->setPageStep(width);
+ hbar->setSingleStep(width / 20);
+ leftIndent = 0;
+ }
+
+ // If the whole scene fits vertically, we center the scene vertically, and
+ // ignore the vertical scroll bars.
+ int top = q_round_bound(viewRect.top());
+ int bottom = q_round_bound(viewRect.bottom() - height);
+ if (top >= bottom) {
+ vbar->setRange(0, 0);
+
+ switch (alignment & Qt::AlignVertical_Mask) {
+ case Qt::AlignTop:
+ topIndent = -viewRect.top();
+ break;
+ case Qt::AlignBottom:
+ topIndent = height - viewRect.height() - viewRect.top() - 1;
+ break;
+ case Qt::AlignVCenter:
+ default:
+ topIndent = height / 2 - (viewRect.top() + viewRect.bottom()) / 2;
+ break;
+ }
+ } else {
+ vbar->setRange(top, bottom);
+ vbar->setPageStep(height);
+ vbar->setSingleStep(height / 20);
+ topIndent = 0;
+ }
+
+ // Restorethe center point from before the ranges changed.
+ lastCenterPoint = savedLastCenterPoint;
+
+ // Issue a full update if the indents change.
+ // ### If the transform is still the same, we can get away with just a
+ // scroll instead.
+ if (oldLeftIndent != leftIndent || oldTopIndent != topIndent) {
+ dirtyScroll = true;
+ updateAll();
+ } else if (q->isRightToLeft() && !leftIndent) {
+ // In reverse mode, the horizontal scroll always changes after the content
+ // size has changed, as the scroll is calculated by summing the min and
+ // max values of the range and subtracting the current value. In normal
+ // mode the scroll remains unchanged unless the indent has changed.
+ dirtyScroll = true;
+ }
+
+ if (cacheMode & QGraphicsView::CacheBackground) {
+ // Invalidate the background pixmap
+ mustResizeBackgroundPixmap = true;
+ }
+}
+
+/*!
+ \internal
+*/
+void QGraphicsViewPrivate::centerView(QGraphicsView::ViewportAnchor anchor)
+{
+ Q_Q(QGraphicsView);
+ switch (anchor) {
+ case QGraphicsView::AnchorUnderMouse: {
+ if (q->underMouse()) {
+ // Last scene pos: lastMouseMoveScenePoint
+ // Current mouse pos:
+ QPointF transformationDiff = q->mapToScene(viewport->rect().center())
+ - q->mapToScene(viewport->mapFromGlobal(QCursor::pos()));
+ q->centerOn(lastMouseMoveScenePoint + transformationDiff);
+ } else {
+ q->centerOn(lastCenterPoint);
+ }
+ break;
+ }
+ case QGraphicsView::AnchorViewCenter:
+ q->centerOn(lastCenterPoint);
+ break;
+ case QGraphicsView::NoAnchor:
+ break;
+ }
+}
+
+/*!
+ \internal
+*/
+void QGraphicsViewPrivate::updateLastCenterPoint()
+{
+ Q_Q(QGraphicsView);
+ lastCenterPoint = q->mapToScene(viewport->rect().center());
+}
+
+/*!
+ \internal
+
+ Returns the horizontal scroll value (the X value of the left edge of the
+ viewport).
+*/
+qint64 QGraphicsViewPrivate::horizontalScroll() const
+{
+ if (dirtyScroll)
+ const_cast<QGraphicsViewPrivate *>(this)->updateScroll();
+ return scrollX;
+}
+
+/*!
+ \internal
+
+ Returns the vertical scroll value (the X value of the top edge of the
+ viewport).
+*/
+qint64 QGraphicsViewPrivate::verticalScroll() const
+{
+ if (dirtyScroll)
+ const_cast<QGraphicsViewPrivate *>(this)->updateScroll();
+ return scrollY;
+}
+
+/*!
+ \internal
+
+ Maps the given rectangle to the scene using QTransform::mapRect()
+*/
+QRectF QGraphicsViewPrivate::mapRectToScene(const QRect &rect) const
+{
+ if (dirtyScroll)
+ const_cast<QGraphicsViewPrivate *>(this)->updateScroll();
+ QRectF scrolled = QRectF(rect.translated(scrollX, scrollY));
+ return identityMatrix ? scrolled : matrix.inverted().mapRect(scrolled);
+}
+
+
+/*!
+ \internal
+
+ Maps the given rectangle from the scene using QTransform::mapRect()
+*/
+QRectF QGraphicsViewPrivate::mapRectFromScene(const QRectF &rect) const
+{
+ if (dirtyScroll)
+ const_cast<QGraphicsViewPrivate *>(this)->updateScroll();
+ return (identityMatrix ? rect : matrix.mapRect(rect)).translated(-scrollX, -scrollY);
+}
+
+/*!
+ \internal
+*/
+void QGraphicsViewPrivate::updateScroll()
+{
+ Q_Q(QGraphicsView);
+ scrollX = qint64(-leftIndent);
+ if (q->isRightToLeft()) {
+ if (!leftIndent) {
+ scrollX += hbar->minimum();
+ scrollX += hbar->maximum();
+ scrollX -= hbar->value();
+ }
+ } else {
+ scrollX += hbar->value();
+ }
+
+ scrollY = qint64(vbar->value() - topIndent);
+
+ dirtyScroll = false;
+}
+
+/*!
+ \internal
+*/
+void QGraphicsViewPrivate::replayLastMouseEvent()
+{
+ if (!useLastMouseEvent || !scene)
+ return;
+ mouseMoveEventHandler(&lastMouseEvent);
+}
+
+/*!
+ \internal
+*/
+void QGraphicsViewPrivate::storeMouseEvent(QMouseEvent *event)
+{
+ useLastMouseEvent = true;
+ lastMouseEvent = QMouseEvent(QEvent::MouseMove, event->pos(), event->globalPos(),
+ event->button(), event->buttons(), event->modifiers());
+}
+
+void QGraphicsViewPrivate::mouseMoveEventHandler(QMouseEvent *event)
+{
+ Q_Q(QGraphicsView);
+
+ storeMouseEvent(event);
+ lastMouseEvent.setAccepted(false);
+
+ if (!sceneInteractionAllowed)
+ return;
+ if (handScrolling)
+ return;
+ if (!scene)
+ return;
+
+ QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseMove);
+ mouseEvent.setWidget(viewport);
+ mouseEvent.setButtonDownScenePos(mousePressButton, mousePressScenePoint);
+ mouseEvent.setButtonDownScreenPos(mousePressButton, mousePressScreenPoint);
+ mouseEvent.setScenePos(q->mapToScene(event->pos()));
+ mouseEvent.setScreenPos(event->globalPos());
+ mouseEvent.setLastScenePos(lastMouseMoveScenePoint);
+ mouseEvent.setLastScreenPos(lastMouseMoveScreenPoint);
+ mouseEvent.setButtons(event->buttons());
+ mouseEvent.setButton(event->button());
+ mouseEvent.setModifiers(event->modifiers());
+ lastMouseMoveScenePoint = mouseEvent.scenePos();
+ lastMouseMoveScreenPoint = mouseEvent.screenPos();
+ mouseEvent.setAccepted(false);
+ if (event->spontaneous())
+ qt_sendSpontaneousEvent(scene, &mouseEvent);
+ else
+ QApplication::sendEvent(scene, &mouseEvent);
+
+ // Remember whether the last event was accepted or not.
+ lastMouseEvent.setAccepted(mouseEvent.isAccepted());
+
+ if (mouseEvent.isAccepted() && mouseEvent.buttons() != 0) {
+ // The event was delivered to a mouse grabber; the press is likely to
+ // have set a cursor, and we must not change it.
+ return;
+ }
+
+#ifndef QT_NO_CURSOR
+ // If all the items ignore hover events, we don't look-up any items
+ // in QGraphicsScenePrivate::dispatchHoverEvent, hence the
+ // cachedItemsUnderMouse list will be empty. We therefore do the look-up
+ // for cursor items here if not all items use the default cursor.
+ if (scene->d_func()->allItemsIgnoreHoverEvents && !scene->d_func()->allItemsUseDefaultCursor
+ && scene->d_func()->cachedItemsUnderMouse.isEmpty()) {
+ scene->d_func()->cachedItemsUnderMouse = scene->d_func()->itemsAtPosition(mouseEvent.screenPos(),
+ mouseEvent.scenePos(),
+ mouseEvent.widget());
+ }
+ // Find the topmost item under the mouse with a cursor.
+ foreach (QGraphicsItem *item, scene->d_func()->cachedItemsUnderMouse) {
+ if (item->hasCursor()) {
+ _q_setViewportCursor(item->cursor());
+ return;
+ }
+ }
+
+ // No items with cursors found; revert to the view cursor.
+ if (hasStoredOriginalCursor) {
+ // Restore the original viewport cursor.
+ hasStoredOriginalCursor = false;
+ viewport->setCursor(originalCursor);
+ }
+#endif
+}
+
+/*!
+ \internal
+*/
+#ifndef QT_NO_RUBBERBAND
+QRegion QGraphicsViewPrivate::rubberBandRegion(const QWidget *widget, const QRect &rect) const
+{
+ QStyleHintReturnMask mask;
+ QStyleOptionRubberBand option;
+ option.initFrom(widget);
+ option.rect = rect;
+ option.opaque = false;
+ option.shape = QRubberBand::Rectangle;
+
+ QRegion tmp;
+ tmp += rect;
+ if (widget->style()->styleHint(QStyle::SH_RubberBand_Mask, &option, widget, &mask))
+ tmp &= mask.region;
+ return tmp;
+}
+#endif
+
+/*!
+ \internal
+*/
+#ifndef QT_NO_CURSOR
+void QGraphicsViewPrivate::_q_setViewportCursor(const QCursor &cursor)
+{
+ if (!hasStoredOriginalCursor) {
+ hasStoredOriginalCursor = true;
+ originalCursor = viewport->cursor();
+ }
+ viewport->setCursor(cursor);
+}
+#endif
+
+/*!
+ \internal
+*/
+#ifndef QT_NO_CURSOR
+void QGraphicsViewPrivate::_q_unsetViewportCursor()
+{
+ Q_Q(QGraphicsView);
+ foreach (QGraphicsItem *item, q->items(lastMouseEvent.pos())) {
+ if (item->hasCursor()) {
+ _q_setViewportCursor(item->cursor());
+ return;
+ }
+ }
+
+ // Restore the original viewport cursor.
+ if (hasStoredOriginalCursor) {
+ hasStoredOriginalCursor = false;
+ if (dragMode == QGraphicsView::ScrollHandDrag)
+ viewport->setCursor(Qt::OpenHandCursor);
+ else
+ viewport->setCursor(originalCursor);
+ }
+}
+#endif
+
+/*!
+ \internal
+*/
+void QGraphicsViewPrivate::storeDragDropEvent(const QGraphicsSceneDragDropEvent *event)
+{
+ delete lastDragDropEvent;
+ lastDragDropEvent = new QGraphicsSceneDragDropEvent(event->type());
+ lastDragDropEvent->setScenePos(event->scenePos());
+ lastDragDropEvent->setScreenPos(event->screenPos());
+ lastDragDropEvent->setButtons(event->buttons());
+ lastDragDropEvent->setModifiers(event->modifiers());
+ lastDragDropEvent->setPossibleActions(event->possibleActions());
+ lastDragDropEvent->setProposedAction(event->proposedAction());
+ lastDragDropEvent->setDropAction(event->dropAction());
+ lastDragDropEvent->setMimeData(event->mimeData());
+ lastDragDropEvent->setWidget(event->widget());
+ lastDragDropEvent->setSource(event->source());
+}
+
+/*!
+ \internal
+*/
+void QGraphicsViewPrivate::populateSceneDragDropEvent(QGraphicsSceneDragDropEvent *dest,
+ QDropEvent *source)
+{
+#ifndef QT_NO_DRAGANDDROP
+ Q_Q(QGraphicsView);
+ dest->setScenePos(q->mapToScene(source->pos()));
+ dest->setScreenPos(q->mapToGlobal(source->pos()));
+ dest->setButtons(source->mouseButtons());
+ dest->setModifiers(source->keyboardModifiers());
+ dest->setPossibleActions(source->possibleActions());
+ dest->setProposedAction(source->proposedAction());
+ dest->setDropAction(source->dropAction());
+ dest->setMimeData(source->mimeData());
+ dest->setWidget(viewport);
+ dest->setSource(source->source());
+#else
+ Q_UNUSED(dest)
+ Q_UNUSED(source)
+#endif
+}
+
+/*!
+ \internal
+*/
+QRect QGraphicsViewPrivate::mapToViewRect(const QGraphicsItem *item, const QRectF &rect) const
+{
+ Q_Q(const QGraphicsView);
+ if (dirtyScroll)
+ const_cast<QGraphicsViewPrivate *>(this)->updateScroll();
+
+ if (item->d_ptr->itemIsUntransformable()) {
+ QTransform itv = item->deviceTransform(q->viewportTransform());
+ return itv.mapRect(rect).toAlignedRect();
+ }
+
+ // Translate-only
+ // COMBINE
+ QPointF offset;
+ const QGraphicsItem *parentItem = item;
+ const QGraphicsItemPrivate *itemd;
+ do {
+ itemd = parentItem->d_ptr.data();
+ if (itemd->transformData)
+ break;
+ offset += itemd->pos;
+ } while ((parentItem = itemd->parent));
+
+ QRectF baseRect = rect.translated(offset.x(), offset.y());
+ if (!parentItem) {
+ if (identityMatrix) {
+ baseRect.translate(-scrollX, -scrollY);
+ return baseRect.toAlignedRect();
+ }
+ return matrix.mapRect(baseRect).translated(-scrollX, -scrollY).toAlignedRect();
+ }
+
+ QTransform tr = parentItem->sceneTransform();
+ if (!identityMatrix)
+ tr *= matrix;
+ QRectF r = tr.mapRect(baseRect);
+ r.translate(-scrollX, -scrollY);
+ return r.toAlignedRect();
+}
+
+/*!
+ \internal
+*/
+QRegion QGraphicsViewPrivate::mapToViewRegion(const QGraphicsItem *item, const QRectF &rect) const
+{
+ Q_Q(const QGraphicsView);
+ if (dirtyScroll)
+ const_cast<QGraphicsViewPrivate *>(this)->updateScroll();
+
+ // Accurate bounding region
+ QTransform itv = item->deviceTransform(q->viewportTransform());
+ return item->boundingRegion(itv) & itv.mapRect(rect).toAlignedRect();
+}
+
+/*!
+ \internal
+*/
+void QGraphicsViewPrivate::processPendingUpdates()
+{
+ if (!scene)
+ return;
+
+ if (fullUpdatePending) {
+ viewport->update();
+ } else if (viewportUpdateMode == QGraphicsView::BoundingRectViewportUpdate) {
+ viewport->update(dirtyBoundingRect);
+ } else {
+ viewport->update(dirtyRegion); // Already adjusted in updateRect/Region.
+ }
+
+ dirtyBoundingRect = QRect();
+ dirtyRegion = QRegion();
+}
+
+static inline bool intersectsViewport(const QRect &r, int width, int height)
+{ return !(r.left() > width) && !(r.right() < 0) && !(r.top() >= height) && !(r.bottom() < 0); }
+
+static inline bool containsViewport(const QRect &r, int width, int height)
+{ return r.left() <= 0 && r.top() <= 0 && r.right() >= width - 1 && r.bottom() >= height - 1; }
+
+static inline void QRect_unite(QRect *rect, const QRect &other)
+{
+ if (rect->isEmpty()) {
+ *rect = other;
+ } else {
+ rect->setCoords(qMin(rect->left(), other.left()), qMin(rect->top(), other.top()),
+ qMax(rect->right(), other.right()), qMax(rect->bottom(), other.bottom()));
+ }
+}
+
+/*
+ Calling this function results in update rects being clipped to the item's
+ bounding rect. Note that updates prior to this function call is not clipped.
+ The clip is removed by passing 0.
+*/
+void QGraphicsViewPrivate::setUpdateClip(QGraphicsItem *item)
+{
+ Q_Q(QGraphicsView);
+ // We simply ignore the request if the update mode is either FullViewportUpdate
+ // or NoViewportUpdate; in that case there's no point in clipping anything.
+ if (!item || viewportUpdateMode == QGraphicsView::NoViewportUpdate
+ || viewportUpdateMode == QGraphicsView::FullViewportUpdate) {
+ hasUpdateClip = false;
+ return;
+ }
+
+ // Calculate the clip (item's bounding rect in view coordinates).
+ // Optimized version of:
+ // QRect clip = item->deviceTransform(q->viewportTransform())
+ // .mapRect(item->boundingRect()).toAlignedRect();
+ QRect clip;
+ if (item->d_ptr->itemIsUntransformable()) {
+ QTransform xform = item->deviceTransform(q->viewportTransform());
+ clip = xform.mapRect(item->boundingRect()).toAlignedRect();
+ } else if (item->d_ptr->sceneTransformTranslateOnly && identityMatrix) {
+ QRectF r(item->boundingRect());
+ r.translate(item->d_ptr->sceneTransform.dx() - horizontalScroll(),
+ item->d_ptr->sceneTransform.dy() - verticalScroll());
+ clip = r.toAlignedRect();
+ } else if (!q->isTransformed()) {
+ clip = item->d_ptr->sceneTransform.mapRect(item->boundingRect()).toAlignedRect();
+ } else {
+ QTransform xform = item->d_ptr->sceneTransform;
+ xform *= q->viewportTransform();
+ clip = xform.mapRect(item->boundingRect()).toAlignedRect();
+ }
+
+ if (hasUpdateClip) {
+ // Intersect with old clip.
+ updateClip &= clip;
+ } else {
+ updateClip = clip;
+ hasUpdateClip = true;
+ }
+}
+
+bool QGraphicsViewPrivate::updateRegion(const QRectF &rect, const QTransform &xform)
+{
+ if (rect.isEmpty())
+ return false;
+
+ if (viewportUpdateMode != QGraphicsView::MinimalViewportUpdate
+ && viewportUpdateMode != QGraphicsView::SmartViewportUpdate) {
+ // No point in updating with QRegion granularity; use the rect instead.
+ return updateRectF(xform.mapRect(rect));
+ }
+
+ // Update mode is either Minimal or Smart, so we have to do a potentially slow operation,
+ // which is clearly documented here: QGraphicsItem::setBoundingRegionGranularity.
+ const QRegion region = xform.map(QRegion(rect.toAlignedRect()));
+ QRect viewRect = region.boundingRect();
+ const bool dontAdjustForAntialiasing = optimizationFlags & QGraphicsView::DontAdjustForAntialiasing;
+ if (dontAdjustForAntialiasing)
+ viewRect.adjust(-1, -1, 1, 1);
+ else
+ viewRect.adjust(-2, -2, 2, 2);
+ if (!intersectsViewport(viewRect, viewport->width(), viewport->height()))
+ return false; // Update region for sure outside viewport.
+
+ const QVector<QRect> &rects = region.rects();
+ for (int i = 0; i < rects.size(); ++i) {
+ viewRect = rects.at(i);
+ if (dontAdjustForAntialiasing)
+ viewRect.adjust(-1, -1, 1, 1);
+ else
+ viewRect.adjust(-2, -2, 2, 2);
+ if (hasUpdateClip)
+ viewRect &= updateClip;
+ dirtyRegion += viewRect;
+ }
+
+ return true;
+}
+
+// NB! Assumes the rect 'r' is already aligned and adjusted for antialiasing.
+// For QRectF use updateRectF(const QRectF &) to ensure proper adjustments.
+bool QGraphicsViewPrivate::updateRect(const QRect &r)
+{
+ if (fullUpdatePending || viewportUpdateMode == QGraphicsView::NoViewportUpdate
+ || !intersectsViewport(r, viewport->width(), viewport->height())) {
+ return false;
+ }
+
+ switch (viewportUpdateMode) {
+ case QGraphicsView::FullViewportUpdate:
+ fullUpdatePending = true;
+ viewport->update();
+ break;
+ case QGraphicsView::BoundingRectViewportUpdate:
+ if (hasUpdateClip)
+ QRect_unite(&dirtyBoundingRect, r & updateClip);
+ else
+ QRect_unite(&dirtyBoundingRect, r);
+ if (containsViewport(dirtyBoundingRect, viewport->width(), viewport->height())) {
+ fullUpdatePending = true;
+ viewport->update();
+ }
+ break;
+ case QGraphicsView::SmartViewportUpdate: // ### DEPRECATE
+ case QGraphicsView::MinimalViewportUpdate:
+ if (hasUpdateClip)
+ dirtyRegion += r & updateClip;
+ else
+ dirtyRegion += r;
+ break;
+ default:
+ break;
+ }
+
+ return true;
+}
+
+QStyleOptionGraphicsItem *QGraphicsViewPrivate::allocStyleOptionsArray(int numItems)
+{
+ if (mustAllocateStyleOptions || (numItems > styleOptions.capacity()))
+ // too many items, let's allocate on-the-fly
+ return new QStyleOptionGraphicsItem[numItems];
+
+ // expand only whenever necessary
+ if (numItems > styleOptions.size())
+ styleOptions.resize(numItems);
+
+ mustAllocateStyleOptions = true;
+ return styleOptions.data();
+}
+
+void QGraphicsViewPrivate::freeStyleOptionsArray(QStyleOptionGraphicsItem *array)
+{
+ mustAllocateStyleOptions = false;
+ if (array != styleOptions.data())
+ delete [] array;
+}
+
+extern QPainterPath qt_regionToPath(const QRegion &region);
+
+/*!
+ ### Adjustments in findItems: mapToScene(QRect) forces us to adjust the
+ input rectangle by (0, 0, 1, 1), because it uses QRect::bottomRight()
+ (etc) when mapping the rectangle to a polygon (which is _wrong_). In
+ addition, as QGraphicsItem::boundingRect() is defined in logical space,
+ but the default pen for QPainter is cosmetic with a width of 0, QPainter
+ is at risk of painting 1 pixel outside the bounding rect. Therefore we
+ must search for items with an adjustment of (-1, -1, 1, 1).
+*/
+QList<QGraphicsItem *> QGraphicsViewPrivate::findItems(const QRegion &exposedRegion, bool *allItems,
+ const QTransform &viewTransform) const
+{
+ Q_Q(const QGraphicsView);
+
+ // Step 1) If all items are contained within the expose region, then
+ // return a list of all visible items. ### the scene's growing bounding
+ // rect does not take into account untransformable items.
+ const QRectF exposedRegionSceneBounds = q->mapToScene(exposedRegion.boundingRect().adjusted(-1, -1, 1, 1))
+ .boundingRect();
+ if (exposedRegionSceneBounds.contains(scene->sceneRect())) {
+ Q_ASSERT(allItems);
+ *allItems = true;
+
+ // All items are guaranteed within the exposed region.
+ return scene->items(Qt::AscendingOrder);
+ }
+
+ // Step 2) If the expose region is a simple rect and the view is only
+ // translated or scaled, search for items using
+ // QGraphicsScene::items(QRectF).
+ bool simpleRectLookup = exposedRegion.rectCount() == 1 && matrix.type() <= QTransform::TxScale;
+ if (simpleRectLookup) {
+ return scene->items(exposedRegionSceneBounds,
+ Qt::IntersectsItemBoundingRect,
+ Qt::AscendingOrder, viewTransform);
+ }
+
+ // If the region is complex or the view has a complex transform, adjust
+ // the expose region, convert it to a path, and then search for items
+ // using QGraphicsScene::items(QPainterPath);
+ QRegion adjustedRegion;
+ foreach (const QRect &r, exposedRegion.rects())
+ adjustedRegion += r.adjusted(-1, -1, 1, 1);
+
+ const QPainterPath exposedScenePath(q->mapToScene(qt_regionToPath(adjustedRegion)));
+ return scene->items(exposedScenePath, Qt::IntersectsItemBoundingRect,
+ Qt::AscendingOrder, viewTransform);
+}
+
+/*!
+ \internal
+
+ Enables input methods for the view if and only if the current focus item of
+ the scene accepts input methods. Call function whenever that condition has
+ potentially changed.
+*/
+void QGraphicsViewPrivate::updateInputMethodSensitivity()
+{
+ Q_Q(QGraphicsView);
+ QGraphicsItem *focusItem = 0;
+ bool enabled = scene && (focusItem = scene->focusItem())
+ && (focusItem->d_ptr->flags & QGraphicsItem::ItemAcceptsInputMethod);
+ q->setAttribute(Qt::WA_InputMethodEnabled, enabled);
+ q->viewport()->setAttribute(Qt::WA_InputMethodEnabled, enabled);
+
+ if (!enabled) {
+ q->setInputMethodHints(0);
+ return;
+ }
+
+ QGraphicsProxyWidget *proxy = focusItem->d_ptr->isWidget && focusItem->d_ptr->isProxyWidget()
+ ? static_cast<QGraphicsProxyWidget *>(focusItem) : 0;
+ if (!proxy) {
+ q->setInputMethodHints(focusItem->inputMethodHints());
+ } else if (QWidget *widget = proxy->widget()) {
+ if (QWidget *fw = widget->focusWidget())
+ widget = fw;
+ q->setInputMethodHints(widget->inputMethodHints());
+ } else {
+ q->setInputMethodHints(0);
+ }
+}
+
+/*!
+ Constructs a QGraphicsView. \a parent is passed to QWidget's constructor.
+*/
+QGraphicsView::QGraphicsView(QWidget *parent)
+ : QAbstractScrollArea(*new QGraphicsViewPrivate, parent)
+{
+ setViewport(0);
+ setAcceptDrops(true);
+ setBackgroundRole(QPalette::Base);
+ // Investigate leaving these disabled by default.
+ setAttribute(Qt::WA_InputMethodEnabled);
+ viewport()->setAttribute(Qt::WA_InputMethodEnabled);
+}
+
+/*!
+ Constructs a QGraphicsView and sets the visualized scene to \a
+ scene. \a parent is passed to QWidget's constructor.
+*/
+QGraphicsView::QGraphicsView(QGraphicsScene *scene, QWidget *parent)
+ : QAbstractScrollArea(*new QGraphicsViewPrivate, parent)
+{
+ setScene(scene);
+ setViewport(0);
+ setAcceptDrops(true);
+ setBackgroundRole(QPalette::Base);
+ // Investigate leaving these disabled by default.
+ setAttribute(Qt::WA_InputMethodEnabled);
+ viewport()->setAttribute(Qt::WA_InputMethodEnabled);
+}
+
+/*!
+ \internal
+ */
+QGraphicsView::QGraphicsView(QGraphicsViewPrivate &dd, QWidget *parent)
+ : QAbstractScrollArea(dd, parent)
+{
+ setViewport(0);
+ setAcceptDrops(true);
+ setBackgroundRole(QPalette::Base);
+ // Investigate leaving these disabled by default.
+ setAttribute(Qt::WA_InputMethodEnabled);
+ viewport()->setAttribute(Qt::WA_InputMethodEnabled);
+}
+
+/*!
+ Destructs the QGraphicsView object.
+*/
+QGraphicsView::~QGraphicsView()
+{
+ Q_D(QGraphicsView);
+ if (d->scene)
+ d->scene->d_func()->views.removeAll(this);
+ delete d->lastDragDropEvent;
+}
+
+/*!
+ \reimp
+*/
+QSize QGraphicsView::sizeHint() const
+{
+ Q_D(const QGraphicsView);
+ if (d->scene) {
+ QSizeF baseSize = d->matrix.mapRect(sceneRect()).size();
+ baseSize += QSizeF(d->frameWidth * 2, d->frameWidth * 2);
+ return baseSize.boundedTo((3 * QApplication::desktop()->size()) / 4).toSize();
+ }
+ return QAbstractScrollArea::sizeHint();
+}
+
+/*!
+ \property QGraphicsView::renderHints
+ \brief the default render hints for the view
+
+ These hints are
+ used to initialize QPainter before each visible item is drawn. QPainter
+ uses render hints to toggle rendering features such as antialiasing and
+ smooth pixmap transformation.
+
+ QPainter::TextAntialiasing is enabled by default.
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp 1
+*/
+QPainter::RenderHints QGraphicsView::renderHints() const
+{
+ Q_D(const QGraphicsView);
+ return d->renderHints;
+}
+void QGraphicsView::setRenderHints(QPainter::RenderHints hints)
+{
+ Q_D(QGraphicsView);
+ if (hints == d->renderHints)
+ return;
+ d->renderHints = hints;
+ d->updateAll();
+}
+
+/*!
+ If \a enabled is true, the render hint \a hint is enabled; otherwise it
+ is disabled.
+
+ \sa renderHints
+*/
+void QGraphicsView::setRenderHint(QPainter::RenderHint hint, bool enabled)
+{
+ Q_D(QGraphicsView);
+ QPainter::RenderHints oldHints = d->renderHints;
+ if (enabled)
+ d->renderHints |= hint;
+ else
+ d->renderHints &= ~hint;
+ if (oldHints != d->renderHints)
+ d->updateAll();
+}
+
+/*!
+ \property QGraphicsView::alignment
+ \brief the alignment of the scene in the view when the whole
+ scene is visible.
+
+ If the whole scene is visible in the view, (i.e., there are no visible
+ scroll bars,) the view's alignment will decide where the scene will be
+ rendered in the view. For example, if the alignment is Qt::AlignCenter,
+ which is default, the scene will be centered in the view, and if the
+ alignment is (Qt::AlignLeft | Qt::AlignTop), the scene will be rendered in
+ the top-left corner of the view.
+*/
+Qt::Alignment QGraphicsView::alignment() const
+{
+ Q_D(const QGraphicsView);
+ return d->alignment;
+}
+void QGraphicsView::setAlignment(Qt::Alignment alignment)
+{
+ Q_D(QGraphicsView);
+ if (d->alignment != alignment) {
+ d->alignment = alignment;
+ d->recalculateContentSize();
+ }
+}
+
+/*!
+ \property QGraphicsView::transformationAnchor
+ \brief how the view should position the scene during transformations.
+
+ QGraphicsView uses this property to decide how to position the scene in
+ the viewport when the transformation matrix changes, and the coordinate
+ system of the view is transformed. The default behavior, AnchorViewCenter,
+ ensures that the scene point at the center of the view remains unchanged
+ during transformations (e.g., when rotating, the scene will appear to
+ rotate around the center of the view).
+
+ Note that the effect of this property is noticeable when only a part of the
+ scene is visible (i.e., when there are scroll bars). Otherwise, if the
+ whole scene fits in the view, QGraphicsScene uses the view \l alignment to
+ position the scene in the view.
+
+ \sa alignment, resizeAnchor
+*/
+QGraphicsView::ViewportAnchor QGraphicsView::transformationAnchor() const
+{
+ Q_D(const QGraphicsView);
+ return d->transformationAnchor;
+}
+void QGraphicsView::setTransformationAnchor(ViewportAnchor anchor)
+{
+ Q_D(QGraphicsView);
+ d->transformationAnchor = anchor;
+
+ // Ensure mouse tracking is enabled in the case we are using AnchorUnderMouse
+ // in order to have up-to-date information for centering the view.
+ if (d->transformationAnchor == AnchorUnderMouse)
+ d->viewport->setMouseTracking(true);
+}
+
+/*!
+ \property QGraphicsView::resizeAnchor
+ \brief how the view should position the scene when the view is resized.
+
+ QGraphicsView uses this property to decide how to position the scene in
+ the viewport when the viewport widget's size changes. The default
+ behavior, NoAnchor, leaves the scene's position unchanged during a resize;
+ the top-left corner of the view will appear to be anchored while resizing.
+
+ Note that the effect of this property is noticeable when only a part of the
+ scene is visible (i.e., when there are scroll bars). Otherwise, if the
+ whole scene fits in the view, QGraphicsScene uses the view \l alignment to
+ position the scene in the view.
+
+ \sa alignment, transformationAnchor, Qt::WNorthWestGravity
+*/
+QGraphicsView::ViewportAnchor QGraphicsView::resizeAnchor() const
+{
+ Q_D(const QGraphicsView);
+ return d->resizeAnchor;
+}
+void QGraphicsView::setResizeAnchor(ViewportAnchor anchor)
+{
+ Q_D(QGraphicsView);
+ d->resizeAnchor = anchor;
+
+ // Ensure mouse tracking is enabled in the case we are using AnchorUnderMouse
+ // in order to have up-to-date information for centering the view.
+ if (d->resizeAnchor == AnchorUnderMouse)
+ d->viewport->setMouseTracking(true);
+}
+
+/*!
+ \property QGraphicsView::viewportUpdateMode
+ \brief how the viewport should update its contents.
+
+ \since 4.3
+
+ QGraphicsView uses this property to decide how to update areas of the
+ scene that have been reexposed or changed. Usually you do not need to
+ modify this property, but there are some cases where doing so can improve
+ rendering performance. See the ViewportUpdateMode documentation for
+ specific details.
+
+ The default value is MinimalViewportUpdate, where QGraphicsView will
+ update as small an area of the viewport as possible when the contents
+ change.
+
+ \sa ViewportUpdateMode, cacheMode
+*/
+QGraphicsView::ViewportUpdateMode QGraphicsView::viewportUpdateMode() const
+{
+ Q_D(const QGraphicsView);
+ return d->viewportUpdateMode;
+}
+void QGraphicsView::setViewportUpdateMode(ViewportUpdateMode mode)
+{
+ Q_D(QGraphicsView);
+ d->viewportUpdateMode = mode;
+}
+
+/*!
+ \property QGraphicsView::optimizationFlags
+ \brief flags that can be used to tune QGraphicsView's performance.
+
+ \since 4.3
+
+ QGraphicsView uses clipping, extra bounding rect adjustments, and certain
+ other aids to improve rendering quality and performance for the common
+ case graphics scene. However, depending on the target platform, the scene,
+ and the viewport in use, some of these operations can degrade performance.
+
+ The effect varies from flag to flag; see the OptimizationFlags
+ documentation for details.
+
+ By default, no optimization flags are enabled.
+
+ \sa setOptimizationFlag()
+*/
+QGraphicsView::OptimizationFlags QGraphicsView::optimizationFlags() const
+{
+ Q_D(const QGraphicsView);
+ return d->optimizationFlags;
+}
+void QGraphicsView::setOptimizationFlags(OptimizationFlags flags)
+{
+ Q_D(QGraphicsView);
+ d->optimizationFlags = flags;
+}
+
+/*!
+ Enables \a flag if \a enabled is true; otherwise disables \a flag.
+
+ \sa optimizationFlags
+*/
+void QGraphicsView::setOptimizationFlag(OptimizationFlag flag, bool enabled)
+{
+ Q_D(QGraphicsView);
+ if (enabled)
+ d->optimizationFlags |= flag;
+ else
+ d->optimizationFlags &= ~flag;
+}
+
+/*!
+ \property QGraphicsView::dragMode
+ \brief the behavior for dragging the mouse over the scene while
+ the left mouse button is pressed.
+
+ This property defines what should happen when the user clicks on the scene
+ background and drags the mouse (e.g., scrolling the viewport contents
+ using a pointing hand cursor, or selecting multiple items with a rubber
+ band). The default value, NoDrag, does nothing.
+
+ This behavior only affects mouse clicks that are not handled by any item.
+ You can define a custom behavior by creating a subclass of QGraphicsView
+ and reimplementing mouseMoveEvent().
+*/
+QGraphicsView::DragMode QGraphicsView::dragMode() const
+{
+ Q_D(const QGraphicsView);
+ return d->dragMode;
+}
+void QGraphicsView::setDragMode(DragMode mode)
+{
+ Q_D(QGraphicsView);
+ if (d->dragMode == mode)
+ return;
+
+#ifndef QT_NO_CURSOR
+ if (d->dragMode == ScrollHandDrag)
+ viewport()->unsetCursor();
+#endif
+
+ // If dragMode is unset while dragging, e.g. via a keyEvent, we
+ // don't unset the handScrolling state. When enabling scrolling
+ // again the mouseMoveEvent will automatically start scrolling,
+ // without a mousePress
+ if (d->dragMode == ScrollHandDrag && mode == NoDrag && d->handScrolling)
+ d->handScrolling = false;
+
+ d->dragMode = mode;
+
+#ifndef QT_NO_CURSOR
+ if (d->dragMode == ScrollHandDrag) {
+ // Forget the stored viewport cursor when we enter scroll hand drag mode.
+ d->hasStoredOriginalCursor = false;
+ viewport()->setCursor(Qt::OpenHandCursor);
+ }
+#endif
+}
+
+#ifndef QT_NO_RUBBERBAND
+/*!
+ \property QGraphicsView::rubberBandSelectionMode
+ \brief the behavior for selecting items with a rubber band selection rectangle.
+ \since 4.3
+
+ This property defines how items are selected when using the RubberBandDrag
+ drag mode.
+
+ The default value is Qt::IntersectsItemShape; all items whose shape
+ intersects with or is contained by the rubber band are selected.
+
+ \sa dragMode, items()
+*/
+Qt::ItemSelectionMode QGraphicsView::rubberBandSelectionMode() const
+{
+ Q_D(const QGraphicsView);
+ return d->rubberBandSelectionMode;
+}
+void QGraphicsView::setRubberBandSelectionMode(Qt::ItemSelectionMode mode)
+{
+ Q_D(QGraphicsView);
+ d->rubberBandSelectionMode = mode;
+}
+#endif
+
+/*!
+ \property QGraphicsView::cacheMode
+ \brief which parts of the view are cached
+
+ QGraphicsView can cache pre-rendered content in a QPixmap, which is then
+ drawn onto the viewport. The purpose of such caching is to speed up the
+ total rendering time for areas that are slow to render. Texture, gradient
+ and alpha blended backgrounds, for example, can be notibly slow to render;
+ especially with a transformed view. The CacheBackground flag enables
+ caching of the view's background. For example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp 2
+
+ The cache is invalidated every time the view is transformed. However, when
+ scrolling, only partial invalidation is required.
+
+ By default, nothing is cached.
+
+ \sa resetCachedContent(), QPixmapCache
+*/
+QGraphicsView::CacheMode QGraphicsView::cacheMode() const
+{
+ Q_D(const QGraphicsView);
+ return d->cacheMode;
+}
+void QGraphicsView::setCacheMode(CacheMode mode)
+{
+ Q_D(QGraphicsView);
+ if (mode == d->cacheMode)
+ return;
+ d->cacheMode = mode;
+ resetCachedContent();
+}
+
+/*!
+ Resets any cached content. Calling this function will clear
+ QGraphicsView's cache. If the current cache mode is \l CacheNone, this
+ function does nothing.
+
+ This function is called automatically for you when the backgroundBrush or
+ QGraphicsScene::backgroundBrush properties change; you only need to call
+ this function if you have reimplemented QGraphicsScene::drawBackground()
+ or QGraphicsView::drawBackground() to draw a custom background, and need
+ to trigger a full redraw.
+
+ \sa cacheMode()
+*/
+void QGraphicsView::resetCachedContent()
+{
+ Q_D(QGraphicsView);
+ if (d->cacheMode == CacheNone)
+ return;
+
+ if (d->cacheMode & CacheBackground) {
+ // Background caching is enabled.
+ d->mustResizeBackgroundPixmap = true;
+ d->updateAll();
+ } else if (d->mustResizeBackgroundPixmap) {
+ // Background caching is disabled.
+ // Cleanup, free some resources.
+ d->mustResizeBackgroundPixmap = false;
+ d->backgroundPixmap = QPixmap();
+ d->backgroundPixmapExposed = QRegion();
+ }
+}
+
+/*!
+ Invalidates and schedules a redraw of \a layers inside \a rect. \a rect is
+ in scene coordinates. Any cached content for \a layers inside \a rect is
+ unconditionally invalidated and redrawn.
+
+ You can call this function to notify QGraphicsView of changes to the
+ background or the foreground of the scene. It is commonly used for scenes
+ with tile-based backgrounds to notify changes when QGraphicsView has
+ enabled background caching.
+
+ Note that QGraphicsView currently supports background caching only (see
+ QGraphicsView::CacheBackground). This function is equivalent to calling update() if any
+ layer but QGraphicsScene::BackgroundLayer is passed.
+
+ \sa QGraphicsScene::invalidate(), update()
+*/
+void QGraphicsView::invalidateScene(const QRectF &rect, QGraphicsScene::SceneLayers layers)
+{
+ Q_D(QGraphicsView);
+ if ((layers & QGraphicsScene::BackgroundLayer) && !d->mustResizeBackgroundPixmap) {
+ QRect viewRect = mapFromScene(rect).boundingRect();
+ if (viewport()->rect().intersects(viewRect)) {
+ // The updated background area is exposed; schedule this area for
+ // redrawing.
+ d->backgroundPixmapExposed += viewRect;
+ if (d->scene)
+ d->scene->update(rect);
+ }
+ }
+}
+
+/*!
+ \property QGraphicsView::interactive
+ \brief whether the view allowed scene interaction.
+
+ If enabled, this view is set to allow scene interaction. Otherwise, this
+ view will not allow interaction, and any mouse or key events are ignored
+ (i.e., it will act as a read-only view).
+
+ By default, this property is true.
+*/
+bool QGraphicsView::isInteractive() const
+{
+ Q_D(const QGraphicsView);
+ return d->sceneInteractionAllowed;
+}
+void QGraphicsView::setInteractive(bool allowed)
+{
+ Q_D(QGraphicsView);
+ d->sceneInteractionAllowed = allowed;
+}
+
+/*!
+ Returns a pointer to the scene that is currently visualized in the
+ view. If no scene is currently visualized, 0 is returned.
+
+ \sa setScene()
+*/
+QGraphicsScene *QGraphicsView::scene() const
+{
+ Q_D(const QGraphicsView);
+ return d->scene;
+}
+
+/*!
+ Sets the current scene to \a scene. If \a scene is already being
+ viewed, this function does nothing.
+
+ When a scene is set on a view, the QGraphicsScene::changed() signal
+ is automatically connected to this view's updateScene() slot, and the
+ view's scroll bars are adjusted to fit the size of the scene.
+*/
+void QGraphicsView::setScene(QGraphicsScene *scene)
+{
+ Q_D(QGraphicsView);
+ if (d->scene == scene)
+ return;
+
+ // Always update the viewport when the scene changes.
+ d->updateAll();
+
+ // Remove the previously assigned scene.
+ if (d->scene) {
+ disconnect(d->scene, SIGNAL(changed(QList<QRectF>)),
+ this, SLOT(updateScene(QList<QRectF>)));
+ disconnect(d->scene, SIGNAL(sceneRectChanged(QRectF)),
+ this, SLOT(updateSceneRect(QRectF)));
+ d->scene->d_func()->removeView(this);
+ d->connectedToScene = false;
+
+ if (isActiveWindow() && isVisible()) {
+ QEvent windowDeactivate(QEvent::WindowDeactivate);
+ QApplication::sendEvent(d->scene, &windowDeactivate);
+ }
+ if(hasFocus())
+ d->scene->clearFocus();
+ }
+
+ // Assign the new scene and update the contents (scrollbars, etc.)).
+ if ((d->scene = scene)) {
+ connect(d->scene, SIGNAL(sceneRectChanged(QRectF)),
+ this, SLOT(updateSceneRect(QRectF)));
+ d->updateSceneSlotReimplementedChecked = false;
+ d->scene->d_func()->addView(this);
+ d->recalculateContentSize();
+ d->lastCenterPoint = sceneRect().center();
+ d->keepLastCenterPoint = true;
+ // We are only interested in mouse tracking if items accept
+ // hover events or use non-default cursors.
+ if (!d->scene->d_func()->allItemsIgnoreHoverEvents
+ || !d->scene->d_func()->allItemsUseDefaultCursor) {
+ d->viewport->setMouseTracking(true);
+ }
+
+ // enable touch events if any items is interested in them
+ if (!d->scene->d_func()->allItemsIgnoreTouchEvents)
+ d->viewport->setAttribute(Qt::WA_AcceptTouchEvents);
+
+ if (isActiveWindow() && isVisible()) {
+ QEvent windowActivate(QEvent::WindowActivate);
+ QApplication::sendEvent(d->scene, &windowActivate);
+ }
+ } else {
+ d->recalculateContentSize();
+ }
+
+ d->updateInputMethodSensitivity();
+
+ if (d->scene && hasFocus())
+ d->scene->setFocus();
+}
+
+/*!
+ \property QGraphicsView::sceneRect
+ \brief the area of the scene visualized by this view.
+
+ The scene rectangle defines the extent of the scene, and in the view's case,
+ this means the area of the scene that you can navigate using the scroll
+ bars.
+
+ If unset, or if a null QRectF is set, this property has the same value as
+ QGraphicsScene::sceneRect, and it changes with
+ QGraphicsScene::sceneRect. Otherwise, the view's scene rect is unaffected
+ by the scene.
+
+ Note that, although the scene supports a virtually unlimited size, the
+ range of the scroll bars will never exceed the range of an integer
+ (INT_MIN, INT_MAX). When the scene is larger than the scroll bars' values,
+ you can choose to use translate() to navigate the scene instead.
+
+ By default, this property contains a rectangle at the origin with zero
+ width and height.
+
+ \sa QGraphicsScene::sceneRect
+*/
+QRectF QGraphicsView::sceneRect() const
+{
+ Q_D(const QGraphicsView);
+ if (d->hasSceneRect)
+ return d->sceneRect;
+ if (d->scene)
+ return d->scene->sceneRect();
+ return QRectF();
+}
+void QGraphicsView::setSceneRect(const QRectF &rect)
+{
+ Q_D(QGraphicsView);
+ d->hasSceneRect = !rect.isNull();
+ d->sceneRect = rect;
+ d->recalculateContentSize();
+}
+
+/*!
+ Returns the current transformation matrix for the view. If no current
+ transformation is set, the identity matrix is returned.
+
+ \sa setMatrix(), transform(), rotate(), scale(), shear(), translate()
+*/
+QMatrix QGraphicsView::matrix() const
+{
+ Q_D(const QGraphicsView);
+ return d->matrix.toAffine();
+}
+
+/*!
+ Sets the view's current transformation matrix to \a matrix.
+
+ If \a combine is true, then \a matrix is combined with the current matrix;
+ otherwise, \a matrix \e replaces the current matrix. \a combine is false
+ by default.
+
+ The transformation matrix tranforms the scene into view coordinates. Using
+ the default transformation, provided by the identity matrix, one pixel in
+ the view represents one unit in the scene (e.g., a 10x10 rectangular item
+ is drawn using 10x10 pixels in the view). If a 2x2 scaling matrix is
+ applied, the scene will be drawn in 1:2 (e.g., a 10x10 rectangular item is
+ then drawn using 20x20 pixels in the view).
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp 3
+
+ To simplify interation with items using a transformed view, QGraphicsView
+ provides mapTo... and mapFrom... functions that can translate between
+ scene and view coordinates. For example, you can call mapToScene() to map
+ a view coordinate to a floating point scene coordinate, or mapFromScene()
+ to map from floating point scene coordinates to view coordinates.
+
+ \sa matrix(), setTransform(), rotate(), scale(), shear(), translate()
+*/
+void QGraphicsView::setMatrix(const QMatrix &matrix, bool combine)
+{
+ setTransform(QTransform(matrix), combine);
+}
+
+/*!
+ Resets the view transformation matrix to the identity matrix.
+
+ \sa resetTransform()
+*/
+void QGraphicsView::resetMatrix()
+{
+ resetTransform();
+}
+
+/*!
+ Rotates the current view transformation \a angle degrees clockwise.
+
+ \sa setTransform(), transform(), scale(), shear(), translate()
+*/
+void QGraphicsView::rotate(qreal angle)
+{
+ Q_D(QGraphicsView);
+ QTransform matrix = d->matrix;
+ matrix.rotate(angle);
+ setTransform(matrix);
+}
+
+/*!
+ Scales the current view transformation by (\a sx, \a sy).
+
+ \sa setTransform(), transform(), rotate(), shear(), translate()
+*/
+void QGraphicsView::scale(qreal sx, qreal sy)
+{
+ Q_D(QGraphicsView);
+ QTransform matrix = d->matrix;
+ matrix.scale(sx, sy);
+ setTransform(matrix);
+}
+
+/*!
+ Shears the current view transformation by (\a sh, \a sv).
+
+ \sa setTransform(), transform(), rotate(), scale(), translate()
+*/
+void QGraphicsView::shear(qreal sh, qreal sv)
+{
+ Q_D(QGraphicsView);
+ QTransform matrix = d->matrix;
+ matrix.shear(sh, sv);
+ setTransform(matrix);
+}
+
+/*!
+ Translates the current view transformation by (\a dx, \a dy).
+
+ \sa setTransform(), transform(), rotate(), shear()
+*/
+void QGraphicsView::translate(qreal dx, qreal dy)
+{
+ Q_D(QGraphicsView);
+ QTransform matrix = d->matrix;
+ matrix.translate(dx, dy);
+ setTransform(matrix);
+}
+
+/*!
+ Scrolls the contents of the viewport to ensure that the scene
+ coordinate \a pos, is centered in the view.
+
+ Because \a pos is a floating point coordinate, and the scroll bars operate
+ on integer coordinates, the centering is only an approximation.
+
+ \note If the item is close to or outside the border, it will be visible
+ in the view, but not centered.
+
+ \sa ensureVisible()
+*/
+void QGraphicsView::centerOn(const QPointF &pos)
+{
+ Q_D(QGraphicsView);
+ qreal width = viewport()->width();
+ qreal height = viewport()->height();
+ QPointF viewPoint = d->matrix.map(pos);
+ QPointF oldCenterPoint = pos;
+
+ if (!d->leftIndent) {
+ if (isRightToLeft()) {
+ qint64 horizontal = 0;
+ horizontal += horizontalScrollBar()->minimum();
+ horizontal += horizontalScrollBar()->maximum();
+ horizontal -= int(viewPoint.x() - width / 2.0);
+ horizontalScrollBar()->setValue(horizontal);
+ } else {
+ horizontalScrollBar()->setValue(int(viewPoint.x() - width / 2.0));
+ }
+ }
+ if (!d->topIndent)
+ verticalScrollBar()->setValue(int(viewPoint.y() - height / 2.0));
+ d->lastCenterPoint = oldCenterPoint;
+}
+
+/*!
+ \fn QGraphicsView::centerOn(qreal x, qreal y)
+ \overload
+
+ This function is provided for convenience. It's equivalent to calling
+ centerOn(QPointF(\a x, \a y)).
+*/
+
+/*!
+ \overload
+
+ Scrolls the contents of the viewport to ensure that \a item
+ is centered in the view.
+
+ \sa ensureVisible()
+*/
+void QGraphicsView::centerOn(const QGraphicsItem *item)
+{
+ centerOn(item->sceneBoundingRect().center());
+}
+
+/*!
+ Scrolls the contents of the viewport so that the scene rectangle \a rect
+ is visible, with margins specified in pixels by \a xmargin and \a
+ ymargin. If the specified rect cannot be reached, the contents are
+ scrolled to the nearest valid position. The default value for both margins
+ is 50 pixels.
+
+ \sa centerOn()
+*/
+void QGraphicsView::ensureVisible(const QRectF &rect, int xmargin, int ymargin)
+{
+ Q_D(QGraphicsView);
+ qreal width = viewport()->width();
+ qreal height = viewport()->height();
+ QRectF viewRect = d->matrix.mapRect(rect);
+
+ qreal left = d->horizontalScroll();
+ qreal right = left + width;
+ qreal top = d->verticalScroll();
+ qreal bottom = top + height;
+
+ if (viewRect.left() <= left + xmargin) {
+ // need to scroll from the left
+ if (!d->leftIndent)
+ horizontalScrollBar()->setValue(int(viewRect.left() - xmargin - 0.5));
+ }
+ if (viewRect.right() >= right - xmargin) {
+ // need to scroll from the right
+ if (!d->leftIndent)
+ horizontalScrollBar()->setValue(int(viewRect.right() - width + xmargin + 0.5));
+ }
+ if (viewRect.top() <= top + ymargin) {
+ // need to scroll from the top
+ if (!d->topIndent)
+ verticalScrollBar()->setValue(int(viewRect.top() - ymargin - 0.5));
+ }
+ if (viewRect.bottom() >= bottom - ymargin) {
+ // need to scroll from the bottom
+ if (!d->topIndent)
+ verticalScrollBar()->setValue(int(viewRect.bottom() - height + ymargin + 0.5));
+ }
+}
+
+/*!
+ \fn QGraphicsView::ensureVisible(qreal x, qreal y, qreal w, qreal h,
+ int xmargin, int ymargin)
+ \overload
+
+ This function is provided for convenience. It's equivalent to calling
+ ensureVisible(QRectF(\a x, \a y, \a w, \a h), \a xmargin, \a ymargin).
+*/
+
+/*!
+ \overload
+
+ Scrolls the contents of the viewport so that the center of item \a item is
+ visible, with margins specified in pixels by \a xmargin and \a ymargin. If
+ the specified point cannot be reached, the contents are scrolled to the
+ nearest valid position. The default value for both margins is 50 pixels.
+
+ \sa centerOn()
+*/
+void QGraphicsView::ensureVisible(const QGraphicsItem *item, int xmargin, int ymargin)
+{
+ ensureVisible(item->sceneBoundingRect(), xmargin, ymargin);
+}
+
+/*!
+ Scales the view matrix and scrolls the scroll bars to ensure that the
+ scene rectangle \a rect fits inside the viewport. \a rect must be inside
+ the scene rect; otherwise, fitInView() cannot guarantee that the whole
+ rect is visible.
+
+ This function keeps the view's rotation, translation, or shear. The view
+ is scaled according to \a aspectRatioMode. \a rect will be centered in the
+ view if it does not fit tightly.
+
+ It's common to call fitInView() from inside a reimplementation of
+ resizeEvent(), to ensure that the whole scene, or parts of the scene,
+ scales automatically to fit the new size of the viewport as the view is
+ resized. Note though, that calling fitInView() from inside resizeEvent()
+ can lead to unwanted resize recursion, if the new transformation toggles
+ the automatic state of the scrollbars. You can toggle the scrollbar
+ policies to always on or always off to prevent this (see
+ horizontalScrollBarPolicy() and verticalScrollBarPolicy()).
+
+ If \a rect is empty, or if the viewport is too small, this
+ function will do nothing.
+
+ \sa setTransform(), ensureVisible(), centerOn()
+*/
+void QGraphicsView::fitInView(const QRectF &rect, Qt::AspectRatioMode aspectRatioMode)
+{
+ Q_D(QGraphicsView);
+ if (!d->scene || rect.isNull())
+ return;
+
+ // Reset the view scale to 1:1.
+ QRectF unity = d->matrix.mapRect(QRectF(0, 0, 1, 1));
+ if (unity.isEmpty())
+ return;
+ scale(1 / unity.width(), 1 / unity.height());
+
+ // Find the ideal x / y scaling ratio to fit \a rect in the view.
+ int margin = 2;
+ QRectF viewRect = viewport()->rect().adjusted(margin, margin, -margin, -margin);
+ if (viewRect.isEmpty())
+ return;
+ QRectF sceneRect = d->matrix.mapRect(rect);
+ if (sceneRect.isEmpty())
+ return;
+ qreal xratio = viewRect.width() / sceneRect.width();
+ qreal yratio = viewRect.height() / sceneRect.height();
+
+ // Respect the aspect ratio mode.
+ switch (aspectRatioMode) {
+ case Qt::KeepAspectRatio:
+ xratio = yratio = qMin(xratio, yratio);
+ break;
+ case Qt::KeepAspectRatioByExpanding:
+ xratio = yratio = qMax(xratio, yratio);
+ break;
+ case Qt::IgnoreAspectRatio:
+ break;
+ }
+
+ // Scale and center on the center of \a rect.
+ scale(xratio, yratio);
+ centerOn(rect.center());
+}
+
+/*!
+ \fn void QGraphicsView::fitInView(qreal x, qreal y, qreal w, qreal h,
+ Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio)
+
+ \overload
+
+ This convenience function is equivalent to calling
+ fitInView(QRectF(\a x, \a y, \a w, \a h), \a aspectRatioMode).
+
+ \sa ensureVisible(), centerOn()
+*/
+
+/*!
+ \overload
+
+ Ensures that \a item fits tightly inside the view, scaling the view
+ according to \a aspectRatioMode.
+
+ \sa ensureVisible(), centerOn()
+*/
+void QGraphicsView::fitInView(const QGraphicsItem *item, Qt::AspectRatioMode aspectRatioMode)
+{
+ QPainterPath path = item->isClipped() ? item->clipPath() : item->shape();
+ if (item->d_ptr->hasTranslateOnlySceneTransform()) {
+ path.translate(item->d_ptr->sceneTransform.dx(), item->d_ptr->sceneTransform.dy());
+ fitInView(path.boundingRect(), aspectRatioMode);
+ } else {
+ fitInView(item->d_ptr->sceneTransform.map(path).boundingRect(), aspectRatioMode);
+ }
+}
+
+/*!
+ Renders the \a source rect, which is in view coordinates, from the scene
+ into \a target, which is in paint device coordinates, using \a
+ painter. This function is useful for capturing the contents of the view
+ onto a paint device, such as a QImage (e.g., to take a screenshot), or for
+ printing to QPrinter. For example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp 4
+
+ If \a source is a null rect, this function will use viewport()->rect() to
+ determine what to draw. If \a target is a null rect, the full dimensions
+ of \a painter's paint device (e.g., for a QPrinter, the page size) will be
+ used.
+
+ The source rect contents will be transformed according to \a
+ aspectRatioMode to fit into the target rect. By default, the aspect ratio
+ is kept, and \a source is scaled to fit in \a target.
+
+ \sa QGraphicsScene::render()
+*/
+void QGraphicsView::render(QPainter *painter, const QRectF &target, const QRect &source,
+ Qt::AspectRatioMode aspectRatioMode)
+{
+ // ### Switch to using the recursive rendering algorithm instead.
+
+ Q_D(QGraphicsView);
+ if (!d->scene || !(painter && painter->isActive()))
+ return;
+
+ // Default source rect = viewport rect
+ QRect sourceRect = source;
+ if (source.isNull())
+ sourceRect = viewport()->rect();
+
+ // Default target rect = device rect
+ QRectF targetRect = target;
+ if (target.isNull()) {
+ if (painter->device()->devType() == QInternal::Picture)
+ targetRect = sourceRect;
+ else
+ targetRect.setRect(0, 0, painter->device()->width(), painter->device()->height());
+ }
+
+ // Find the ideal x / y scaling ratio to fit \a source into \a target.
+ qreal xratio = targetRect.width() / sourceRect.width();
+ qreal yratio = targetRect.height() / sourceRect.height();
+
+ // Scale according to the aspect ratio mode.
+ switch (aspectRatioMode) {
+ case Qt::KeepAspectRatio:
+ xratio = yratio = qMin(xratio, yratio);
+ break;
+ case Qt::KeepAspectRatioByExpanding:
+ xratio = yratio = qMax(xratio, yratio);
+ break;
+ case Qt::IgnoreAspectRatio:
+ break;
+ }
+
+ // Find all items to draw, and reverse the list (we want to draw
+ // in reverse order).
+ QPolygonF sourceScenePoly = mapToScene(sourceRect.adjusted(-1, -1, 1, 1));
+ QList<QGraphicsItem *> itemList = d->scene->items(sourceScenePoly,
+ Qt::IntersectsItemBoundingRect);
+ QGraphicsItem **itemArray = new QGraphicsItem *[itemList.size()];
+ int numItems = itemList.size();
+ for (int i = 0; i < numItems; ++i)
+ itemArray[numItems - i - 1] = itemList.at(i);
+ itemList.clear();
+
+ // Setup painter matrix.
+ QTransform moveMatrix = QTransform::fromTranslate(-d->horizontalScroll(), -d->verticalScroll());
+ QTransform painterMatrix = d->matrix * moveMatrix;
+ painterMatrix *= QTransform()
+ .translate(targetRect.left(), targetRect.top())
+ .scale(xratio, yratio)
+ .translate(-sourceRect.left(), -sourceRect.top());
+
+ // Generate the style options
+ QStyleOptionGraphicsItem *styleOptionArray = d->allocStyleOptionsArray(numItems);
+ for (int i = 0; i < numItems; ++i)
+ itemArray[i]->d_ptr->initStyleOption(&styleOptionArray[i], painterMatrix, targetRect.toRect());
+
+ painter->save();
+
+ // Clip in device coordinates to avoid QRegion transformations.
+ painter->setClipRect(targetRect);
+ QPainterPath path;
+ path.addPolygon(sourceScenePoly);
+ path.closeSubpath();
+ painter->setClipPath(painterMatrix.map(path), Qt::IntersectClip);
+
+ // Transform the painter.
+ painter->setTransform(painterMatrix, true);
+
+ // Render the scene.
+ QRectF sourceSceneRect = sourceScenePoly.boundingRect();
+ drawBackground(painter, sourceSceneRect);
+ drawItems(painter, numItems, itemArray, styleOptionArray);
+ drawForeground(painter, sourceSceneRect);
+
+ delete [] itemArray;
+ d->freeStyleOptionsArray(styleOptionArray);
+
+ painter->restore();
+}
+
+/*!
+ Returns a list of all the items in the associated scene, in descending
+ stacking order (i.e., the first item in the returned list is the uppermost
+ item).
+
+ \sa QGraphicsScene::items(), {QGraphicsItem#Sorting}{Sorting}
+*/
+QList<QGraphicsItem *> QGraphicsView::items() const
+{
+ Q_D(const QGraphicsView);
+ if (!d->scene)
+ return QList<QGraphicsItem *>();
+ return d->scene->items();
+}
+
+/*!
+ Returns a list of all the items at the position \a pos in the view. The
+ items are listed in descending stacking order (i.e., the first item in the
+ list is the uppermost item, and the last item is the lowermost item). \a
+ pos is in viewport coordinates.
+
+ This function is most commonly called from within mouse event handlers in
+ a subclass in QGraphicsView. \a pos is in untransformed viewport
+ coordinates, just like QMouseEvent::pos().
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp 5
+
+ \sa QGraphicsScene::items(), {QGraphicsItem#Sorting}{Sorting}
+*/
+QList<QGraphicsItem *> QGraphicsView::items(const QPoint &pos) const
+{
+ Q_D(const QGraphicsView);
+ if (!d->scene)
+ return QList<QGraphicsItem *>();
+ // ### Unify these two, and use the items(QPointF) version in
+ // QGraphicsScene instead. The scene items function could use the viewport
+ // transform to map the point to a rect/polygon.
+ if ((d->identityMatrix || d->matrix.type() <= QTransform::TxScale)) {
+ // Use the rect version
+ QTransform xinv = viewportTransform().inverted();
+ return d->scene->items(xinv.mapRect(QRectF(pos.x(), pos.y(), 1, 1)),
+ Qt::IntersectsItemShape,
+ Qt::DescendingOrder,
+ viewportTransform());
+ }
+ // Use the polygon version
+ return d->scene->items(mapToScene(pos.x(), pos.y(), 1, 1),
+ Qt::IntersectsItemShape,
+ Qt::DescendingOrder,
+ viewportTransform());
+}
+
+/*!
+ \fn QGraphicsView::items(int x, int y) const
+
+ This function is provided for convenience. It's equivalent to calling
+ items(QPoint(\a x, \a y)).
+*/
+
+/*!
+ \overload
+
+ Returns a list of all the items that, depending on \a mode, are either
+ contained by or intersect with \a rect. \a rect is in viewport
+ coordinates.
+
+ The default value for \a mode is Qt::IntersectsItemShape; all items whose
+ exact shape intersects with or is contained by \a rect are returned.
+
+ The items are sorted in descending stacking order (i.e., the first item in
+ the returned list is the uppermost item).
+
+ \sa itemAt(), items(), mapToScene(), {QGraphicsItem#Sorting}{Sorting}
+*/
+QList<QGraphicsItem *> QGraphicsView::items(const QRect &rect, Qt::ItemSelectionMode mode) const
+{
+ Q_D(const QGraphicsView);
+ if (!d->scene)
+ return QList<QGraphicsItem *>();
+ return d->scene->items(mapToScene(rect), mode, Qt::DescendingOrder, viewportTransform());
+}
+
+/*!
+ \fn QList<QGraphicsItem *> QGraphicsView::items(int x, int y, int w, int h, Qt::ItemSelectionMode mode) const
+ \since 4.3
+
+ This convenience function is equivalent to calling items(QRectF(\a x, \a
+ y, \a w, \a h), \a mode).
+*/
+
+/*!
+ \overload
+
+ Returns a list of all the items that, depending on \a mode, are either
+ contained by or intersect with \a polygon. \a polygon is in viewport
+ coordinates.
+
+ The default value for \a mode is Qt::IntersectsItemShape; all items whose
+ exact shape intersects with or is contained by \a polygon are returned.
+
+ The items are sorted by descending stacking order (i.e., the first item in
+ the returned list is the uppermost item).
+
+ \sa itemAt(), items(), mapToScene(), {QGraphicsItem#Sorting}{Sorting}
+*/
+QList<QGraphicsItem *> QGraphicsView::items(const QPolygon &polygon, Qt::ItemSelectionMode mode) const
+{
+ Q_D(const QGraphicsView);
+ if (!d->scene)
+ return QList<QGraphicsItem *>();
+ return d->scene->items(mapToScene(polygon), mode, Qt::DescendingOrder, viewportTransform());
+}
+
+/*!
+ \overload
+
+ Returns a list of all the items that, depending on \a mode, are either
+ contained by or intersect with \a path. \a path is in viewport
+ coordinates.
+
+ The default value for \a mode is Qt::IntersectsItemShape; all items whose
+ exact shape intersects with or is contained by \a path are returned.
+
+ \sa itemAt(), items(), mapToScene(), {QGraphicsItem#Sorting}{Sorting}
+*/
+QList<QGraphicsItem *> QGraphicsView::items(const QPainterPath &path, Qt::ItemSelectionMode mode) const
+{
+ Q_D(const QGraphicsView);
+ if (!d->scene)
+ return QList<QGraphicsItem *>();
+ return d->scene->items(mapToScene(path), mode, Qt::DescendingOrder, viewportTransform());
+}
+
+/*!
+ Returns the item at position \a pos, which is in viewport coordinates.
+ If there are several items at this position, this function returns
+ the topmost item.
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp 6
+
+ \sa items(), {QGraphicsItem#Sorting}{Sorting}
+*/
+QGraphicsItem *QGraphicsView::itemAt(const QPoint &pos) const
+{
+ Q_D(const QGraphicsView);
+ if (!d->scene)
+ return 0;
+ QList<QGraphicsItem *> itemsAtPos = items(pos);
+ return itemsAtPos.isEmpty() ? 0 : itemsAtPos.first();
+}
+
+/*!
+ \overload
+ \fn QGraphicsItem *QGraphicsView::itemAt(int x, int y) const
+
+ This function is provided for convenience. It's equivalent to
+ calling itemAt(QPoint(\a x, \a y)).
+*/
+
+/*!
+ Returns the viewport coordinate \a point mapped to scene coordinates.
+
+ Note: It can be useful to map the whole rectangle covered by the pixel at
+ \a point instead of the point itself. To do this, you can call
+ mapToScene(QRect(\a point, QSize(2, 2))).
+
+ \sa mapFromScene()
+*/
+QPointF QGraphicsView::mapToScene(const QPoint &point) const
+{
+ Q_D(const QGraphicsView);
+ QPointF p = point;
+ p.rx() += d->horizontalScroll();
+ p.ry() += d->verticalScroll();
+ return d->identityMatrix ? p : d->matrix.inverted().map(p);
+}
+
+/*!
+ \fn QGraphicsView::mapToScene(int x, int y) const
+
+ This function is provided for convenience. It's equivalent to calling
+ mapToScene(QPoint(\a x, \a y)).
+*/
+
+/*!
+ Returns the viewport rectangle \a rect mapped to a scene coordinate
+ polygon.
+
+ \sa mapFromScene()
+*/
+QPolygonF QGraphicsView::mapToScene(const QRect &rect) const
+{
+ Q_D(const QGraphicsView);
+ if (!rect.isValid())
+ return QPolygonF();
+
+ QPointF scrollOffset(d->horizontalScroll(), d->verticalScroll());
+ QRect r = rect.adjusted(0, 0, 1, 1);
+ QPointF tl = scrollOffset + r.topLeft();
+ QPointF tr = scrollOffset + r.topRight();
+ QPointF br = scrollOffset + r.bottomRight();
+ QPointF bl = scrollOffset + r.bottomLeft();
+
+ QPolygonF poly(4);
+ if (!d->identityMatrix) {
+ QTransform x = d->matrix.inverted();
+ poly[0] = x.map(tl);
+ poly[1] = x.map(tr);
+ poly[2] = x.map(br);
+ poly[3] = x.map(bl);
+ } else {
+ poly[0] = tl;
+ poly[1] = tr;
+ poly[2] = br;
+ poly[3] = bl;
+ }
+ return poly;
+}
+
+/*!
+ \fn QGraphicsView::mapToScene(int x, int y, int w, int h) const
+
+ This function is provided for convenience. It's equivalent to calling
+ mapToScene(QRect(\a x, \a y, \a w, \a h)).
+*/
+
+/*!
+ Returns the viewport polygon \a polygon mapped to a scene coordinate
+ polygon.
+
+ \sa mapFromScene()
+*/
+QPolygonF QGraphicsView::mapToScene(const QPolygon &polygon) const
+{
+ QPolygonF poly;
+ foreach (const QPoint &point, polygon)
+ poly << mapToScene(point);
+ return poly;
+}
+
+/*!
+ Returns the viewport painter path \a path mapped to a scene coordinate
+ painter path.
+
+ \sa mapFromScene()
+*/
+QPainterPath QGraphicsView::mapToScene(const QPainterPath &path) const
+{
+ Q_D(const QGraphicsView);
+ QTransform matrix = QTransform::fromTranslate(d->horizontalScroll(), d->verticalScroll());
+ matrix *= d->matrix.inverted();
+ return matrix.map(path);
+}
+
+/*!
+ Returns the scene coordinate \a point to viewport coordinates.
+
+ \sa mapToScene()
+*/
+QPoint QGraphicsView::mapFromScene(const QPointF &point) const
+{
+ Q_D(const QGraphicsView);
+ QPointF p = d->identityMatrix ? point : d->matrix.map(point);
+ p.rx() -= d->horizontalScroll();
+ p.ry() -= d->verticalScroll();
+ return p.toPoint();
+}
+
+/*!
+ \fn QGraphicsView::mapFromScene(qreal x, qreal y) const
+
+ This function is provided for convenience. It's equivalent to
+ calling mapFromScene(QPointF(\a x, \a y)).
+*/
+
+/*!
+ Returns the scene rectangle \a rect to a viewport coordinate
+ polygon.
+
+ \sa mapToScene()
+*/
+QPolygon QGraphicsView::mapFromScene(const QRectF &rect) const
+{
+ Q_D(const QGraphicsView);
+ QPointF tl;
+ QPointF tr;
+ QPointF br;
+ QPointF bl;
+ if (!d->identityMatrix) {
+ const QTransform &x = d->matrix;
+ tl = x.map(rect.topLeft());
+ tr = x.map(rect.topRight());
+ br = x.map(rect.bottomRight());
+ bl = x.map(rect.bottomLeft());
+ } else {
+ tl = rect.topLeft();
+ tr = rect.topRight();
+ br = rect.bottomRight();
+ bl = rect.bottomLeft();
+ }
+ QPointF scrollOffset(d->horizontalScroll(), d->verticalScroll());
+ tl -= scrollOffset;
+ tr -= scrollOffset;
+ br -= scrollOffset;
+ bl -= scrollOffset;
+
+ QPolygon poly(4);
+ poly[0] = tl.toPoint();
+ poly[1] = tr.toPoint();
+ poly[2] = br.toPoint();
+ poly[3] = bl.toPoint();
+ return poly;
+}
+
+/*!
+ \fn QGraphicsView::mapFromScene(qreal x, qreal y, qreal w, qreal h) const
+
+ This function is provided for convenience. It's equivalent to
+ calling mapFromScene(QRectF(\a x, \a y, \a w, \a h)).
+*/
+
+/*!
+ Returns the scene coordinate polygon \a polygon to a viewport coordinate
+ polygon.
+
+ \sa mapToScene()
+*/
+QPolygon QGraphicsView::mapFromScene(const QPolygonF &polygon) const
+{
+ QPolygon poly;
+ foreach (const QPointF &point, polygon)
+ poly << mapFromScene(point);
+ return poly;
+}
+
+/*!
+ Returns the scene coordinate painter path \a path to a viewport coordinate
+ painter path.
+
+ \sa mapToScene()
+*/
+QPainterPath QGraphicsView::mapFromScene(const QPainterPath &path) const
+{
+ Q_D(const QGraphicsView);
+ QTransform matrix = d->matrix;
+ matrix *= QTransform::fromTranslate(-d->horizontalScroll(), -d->verticalScroll());
+ return matrix.map(path);
+}
+
+/*!
+ \reimp
+*/
+QVariant QGraphicsView::inputMethodQuery(Qt::InputMethodQuery query) const
+{
+ Q_D(const QGraphicsView);
+ if (!d->scene)
+ return QVariant();
+
+ QVariant value = d->scene->inputMethodQuery(query);
+ if (value.type() == QVariant::RectF)
+ value = d->mapRectFromScene(value.toRectF());
+ else if (value.type() == QVariant::PointF)
+ value = mapFromScene(value.toPointF());
+ else if (value.type() == QVariant::Rect)
+ value = d->mapRectFromScene(value.toRect()).toRect();
+ else if (value.type() == QVariant::Point)
+ value = mapFromScene(value.toPoint());
+ return value;
+}
+
+/*!
+ \property QGraphicsView::backgroundBrush
+ \brief the background brush of the scene.
+
+ This property sets the background brush for the scene in this view. It is
+ used to override the scene's own background, and defines the behavior of
+ drawBackground(). To provide custom background drawing for this view, you
+ can reimplement drawBackground() instead.
+
+ By default, this property contains a brush with the Qt::NoBrush pattern.
+
+ \sa QGraphicsScene::backgroundBrush, foregroundBrush
+*/
+QBrush QGraphicsView::backgroundBrush() const
+{
+ Q_D(const QGraphicsView);
+ return d->backgroundBrush;
+}
+void QGraphicsView::setBackgroundBrush(const QBrush &brush)
+{
+ Q_D(QGraphicsView);
+ d->backgroundBrush = brush;
+ d->updateAll();
+
+ if (d->cacheMode & CacheBackground) {
+ // Invalidate the background pixmap
+ d->mustResizeBackgroundPixmap = true;
+ }
+}
+
+/*!
+ \property QGraphicsView::foregroundBrush
+ \brief the foreground brush of the scene.
+
+ This property sets the foreground brush for the scene in this view. It is
+ used to override the scene's own foreground, and defines the behavior of
+ drawForeground(). To provide custom foreground drawing for this view, you
+ can reimplement drawForeground() instead.
+
+ By default, this property contains a brush with the Qt::NoBrush pattern.
+
+ \sa QGraphicsScene::foregroundBrush, backgroundBrush
+*/
+QBrush QGraphicsView::foregroundBrush() const
+{
+ Q_D(const QGraphicsView);
+ return d->foregroundBrush;
+}
+void QGraphicsView::setForegroundBrush(const QBrush &brush)
+{
+ Q_D(QGraphicsView);
+ d->foregroundBrush = brush;
+ d->updateAll();
+}
+
+/*!
+ Schedules an update of the scene rectangles \a rects.
+
+ \sa QGraphicsScene::changed()
+*/
+void QGraphicsView::updateScene(const QList<QRectF> &rects)
+{
+ // ### Note: Since 4.5, this slot is only called if the user explicitly
+ // establishes a connection between the scene and the view, as the scene
+ // and view are no longer connected. We need to keep it working (basically
+ // leave it as it is), but the new delivery path is through
+ // QGraphicsScenePrivate::itemUpdate().
+ Q_D(QGraphicsView);
+ if (d->fullUpdatePending || d->viewportUpdateMode == QGraphicsView::NoViewportUpdate)
+ return;
+
+ // Extract and reset dirty scene rect info.
+ QVector<QRect> dirtyViewportRects;
+ const QVector<QRect> &dirtyRects = d->dirtyRegion.rects();
+ for (int i = 0; i < dirtyRects.size(); ++i)
+ dirtyViewportRects += dirtyRects.at(i);
+ d->dirtyRegion = QRegion();
+ d->dirtyBoundingRect = QRect();
+
+ bool fullUpdate = !d->accelerateScrolling || d->viewportUpdateMode == QGraphicsView::FullViewportUpdate;
+ bool boundingRectUpdate = (d->viewportUpdateMode == QGraphicsView::BoundingRectViewportUpdate)
+ || (d->viewportUpdateMode == QGraphicsView::SmartViewportUpdate
+ && ((dirtyViewportRects.size() + rects.size()) >= QGRAPHICSVIEW_REGION_RECT_THRESHOLD));
+
+ QRegion updateRegion;
+ QRect boundingRect;
+ QRect viewportRect = viewport()->rect();
+ bool redraw = false;
+ QTransform transform = viewportTransform();
+
+ // Convert scene rects to viewport rects.
+ foreach (const QRectF &rect, rects) {
+ QRect xrect = transform.mapRect(rect).toAlignedRect();
+ if (!(d->optimizationFlags & DontAdjustForAntialiasing))
+ xrect.adjust(-2, -2, 2, 2);
+ else
+ xrect.adjust(-1, -1, 1, 1);
+ if (!viewportRect.intersects(xrect))
+ continue;
+ dirtyViewportRects << xrect;
+ }
+
+ foreach (const QRect &rect, dirtyViewportRects) {
+ // Add the exposed rect to the update region. In rect update
+ // mode, we only count the bounding rect of items.
+ if (!boundingRectUpdate) {
+ updateRegion += rect;
+ } else {
+ boundingRect |= rect;
+ }
+ redraw = true;
+ if (fullUpdate) {
+ // If fullUpdate is true and we found a visible dirty rect,
+ // we're done.
+ break;
+ }
+ }
+
+ if (!redraw)
+ return;
+
+ if (fullUpdate)
+ viewport()->update();
+ else if (boundingRectUpdate)
+ viewport()->update(boundingRect);
+ else
+ viewport()->update(updateRegion);
+}
+
+/*!
+ Notifies QGraphicsView that the scene's scene rect has changed. \a rect
+ is the new scene rect. If the view already has an explicitly set scene
+ rect, this function does nothing.
+
+ \sa sceneRect, QGraphicsScene::sceneRectChanged()
+*/
+void QGraphicsView::updateSceneRect(const QRectF &rect)
+{
+ Q_D(QGraphicsView);
+ if (!d->hasSceneRect) {
+ d->sceneRect = rect;
+ d->recalculateContentSize();
+ }
+}
+
+/*!
+ This slot is called by QAbstractScrollArea after setViewport() has been
+ called. Reimplement this function in a subclass of QGraphicsView to
+ initialize the new viewport \a widget before it is used.
+
+ \sa setViewport()
+*/
+void QGraphicsView::setupViewport(QWidget *widget)
+{
+ Q_D(QGraphicsView);
+
+ if (!widget) {
+ qWarning("QGraphicsView::setupViewport: cannot initialize null widget");
+ return;
+ }
+
+ const bool isGLWidget = widget->inherits("QGLWidget");
+
+ d->accelerateScrolling = !(isGLWidget);
+
+ widget->setFocusPolicy(Qt::StrongFocus);
+
+ if (!isGLWidget) {
+ // autoFillBackground enables scroll acceleration.
+ widget->setAutoFillBackground(true);
+ }
+
+ // We are only interested in mouse tracking if items
+ // accept hover events or use non-default cursors or if
+ // AnchorUnderMouse is used as transformation or resize anchor.
+ if ((d->scene && (!d->scene->d_func()->allItemsIgnoreHoverEvents
+ || !d->scene->d_func()->allItemsUseDefaultCursor))
+ || d->transformationAnchor == AnchorUnderMouse
+ || d->resizeAnchor == AnchorUnderMouse) {
+ widget->setMouseTracking(true);
+ }
+
+ // enable touch events if any items is interested in them
+ if (d->scene && !d->scene->d_func()->allItemsIgnoreTouchEvents)
+ widget->setAttribute(Qt::WA_AcceptTouchEvents);
+
+#ifndef QT_NO_GESTURES
+ if (d->scene) {
+ foreach (Qt::GestureType gesture, d->scene->d_func()->grabbedGestures.keys())
+ widget->grabGesture(gesture);
+ }
+#endif
+
+ widget->setAcceptDrops(acceptDrops());
+}
+
+/*!
+ \reimp
+*/
+bool QGraphicsView::event(QEvent *event)
+{
+ Q_D(QGraphicsView);
+
+ if (d->sceneInteractionAllowed) {
+ switch (event->type()) {
+ case QEvent::ShortcutOverride:
+ if (d->scene)
+ return QApplication::sendEvent(d->scene, event);
+ break;
+ case QEvent::KeyPress:
+ if (d->scene) {
+ QKeyEvent *k = static_cast<QKeyEvent *>(event);
+ if (k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) {
+ // Send the key events to the scene. This will invoke the
+ // scene's tab focus handling, and if the event is
+ // accepted, we return (prevent further event delivery),
+ // and the base implementation will call QGraphicsView's
+ // focusNextPrevChild() function. If the event is ignored,
+ // we fall back to standard tab focus handling.
+ QApplication::sendEvent(d->scene, event);
+ if (event->isAccepted())
+ return true;
+ // Ensure the event doesn't propagate just because the
+ // scene ignored it. If the event propagates, then tab
+ // handling will be called twice (this and parent).
+ event->accept();
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ return QAbstractScrollArea::event(event);
+}
+
+/*!
+ \reimp
+*/
+bool QGraphicsView::viewportEvent(QEvent *event)
+{
+ Q_D(QGraphicsView);
+ if (!d->scene)
+ return QAbstractScrollArea::viewportEvent(event);
+
+ switch (event->type()) {
+ case QEvent::Enter:
+ QApplication::sendEvent(d->scene, event);
+ break;
+ case QEvent::WindowActivate:
+ QApplication::sendEvent(d->scene, event);
+ break;
+ case QEvent::WindowDeactivate:
+ // ### This is a temporary fix for until we get proper mouse
+ // grab events. mouseGrabberItem should be set to 0 if we lose
+ // the mouse grab.
+ // Remove all popups when the scene loses focus.
+ if (!d->scene->d_func()->popupWidgets.isEmpty())
+ d->scene->d_func()->removePopup(d->scene->d_func()->popupWidgets.first());
+ QApplication::sendEvent(d->scene, event);
+ break;
+ case QEvent::Show:
+ if (d->scene && isActiveWindow()) {
+ QEvent windowActivate(QEvent::WindowActivate);
+ QApplication::sendEvent(d->scene, &windowActivate);
+ }
+ break;
+ case QEvent::Hide:
+ // spontaneous event will generate a WindowDeactivate.
+ if (!event->spontaneous() && d->scene && isActiveWindow()) {
+ QEvent windowDeactivate(QEvent::WindowDeactivate);
+ QApplication::sendEvent(d->scene, &windowDeactivate);
+ }
+ break;
+ case QEvent::Leave:
+ // ### This is a temporary fix for until we get proper mouse grab
+ // events. activeMouseGrabberItem should be set to 0 if we lose the
+ // mouse grab.
+ if ((QApplication::activePopupWidget() && QApplication::activePopupWidget() != window())
+ || (QApplication::activeModalWidget() && QApplication::activeModalWidget() != window())
+ || (QApplication::activeWindow() != window())) {
+ if (!d->scene->d_func()->popupWidgets.isEmpty())
+ d->scene->d_func()->removePopup(d->scene->d_func()->popupWidgets.first());
+ }
+ d->useLastMouseEvent = false;
+ // a hack to pass a viewport pointer to the scene inside the leave event
+ Q_ASSERT(event->d == 0);
+ event->d = reinterpret_cast<QEventPrivate *>(viewport());
+ QApplication::sendEvent(d->scene, event);
+ break;
+#ifndef QT_NO_TOOLTIP
+ case QEvent::ToolTip: {
+ QHelpEvent *toolTip = static_cast<QHelpEvent *>(event);
+ QGraphicsSceneHelpEvent helpEvent(QEvent::GraphicsSceneHelp);
+ helpEvent.setWidget(viewport());
+ helpEvent.setScreenPos(toolTip->globalPos());
+ helpEvent.setScenePos(mapToScene(toolTip->pos()));
+ QApplication::sendEvent(d->scene, &helpEvent);
+ toolTip->setAccepted(helpEvent.isAccepted());
+ return true;
+ }
+#endif
+ case QEvent::Paint:
+ // Reset full update
+ d->fullUpdatePending = false;
+ d->dirtyScrollOffset = QPoint();
+ if (d->scene) {
+ // Check if this view reimplements the updateScene slot; if it
+ // does, we can't do direct update delivery and have to fall back
+ // to connecting the changed signal.
+ if (!d->updateSceneSlotReimplementedChecked) {
+ d->updateSceneSlotReimplementedChecked = true;
+ const QMetaObject *mo = metaObject();
+ if (mo != &QGraphicsView::staticMetaObject) {
+ if (mo->indexOfSlot("updateScene(QList<QRectF>)")
+ != QGraphicsView::staticMetaObject.indexOfSlot("updateScene(QList<QRectF>)")) {
+ connect(d->scene, SIGNAL(changed(QList<QRectF>)),
+ this, SLOT(updateScene(QList<QRectF>)));
+ }
+ }
+ }
+ }
+ break;
+ case QEvent::TouchBegin:
+ case QEvent::TouchUpdate:
+ case QEvent::TouchEnd:
+ {
+ if (!isEnabled())
+ return false;
+
+ if (d->scene && d->sceneInteractionAllowed) {
+ // Convert and deliver the touch event to the scene.
+ QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);
+ touchEvent->setWidget(viewport());
+ QGraphicsViewPrivate::translateTouchEvent(d, touchEvent);
+ (void) QApplication::sendEvent(d->scene, touchEvent);
+ }
+
+ return true;
+ }
+#ifndef QT_NO_GESTURES
+ case QEvent::Gesture:
+ case QEvent::GestureOverride:
+ {
+ if (!isEnabled())
+ return false;
+
+ if (d->scene && d->sceneInteractionAllowed) {
+ QGestureEvent *gestureEvent = static_cast<QGestureEvent *>(event);
+ gestureEvent->setWidget(viewport());
+ (void) QApplication::sendEvent(d->scene, gestureEvent);
+ }
+ return true;
+ }
+#endif // QT_NO_GESTURES
+ default:
+ break;
+ }
+
+ return QAbstractScrollArea::viewportEvent(event);
+}
+
+#ifndef QT_NO_CONTEXTMENU
+/*!
+ \reimp
+*/
+void QGraphicsView::contextMenuEvent(QContextMenuEvent *event)
+{
+ Q_D(QGraphicsView);
+ if (!d->scene || !d->sceneInteractionAllowed)
+ return;
+
+ d->mousePressViewPoint = event->pos();
+ d->mousePressScenePoint = mapToScene(d->mousePressViewPoint);
+ d->mousePressScreenPoint = event->globalPos();
+ d->lastMouseMoveScenePoint = d->mousePressScenePoint;
+ d->lastMouseMoveScreenPoint = d->mousePressScreenPoint;
+
+ QGraphicsSceneContextMenuEvent contextEvent(QEvent::GraphicsSceneContextMenu);
+ contextEvent.setWidget(viewport());
+ contextEvent.setScenePos(d->mousePressScenePoint);
+ contextEvent.setScreenPos(d->mousePressScreenPoint);
+ contextEvent.setModifiers(event->modifiers());
+ contextEvent.setReason((QGraphicsSceneContextMenuEvent::Reason)(event->reason()));
+ contextEvent.setAccepted(event->isAccepted());
+ QApplication::sendEvent(d->scene, &contextEvent);
+ event->setAccepted(contextEvent.isAccepted());
+}
+#endif // QT_NO_CONTEXTMENU
+
+/*!
+ \reimp
+*/
+void QGraphicsView::dropEvent(QDropEvent *event)
+{
+#ifndef QT_NO_DRAGANDDROP
+ Q_D(QGraphicsView);
+ if (!d->scene || !d->sceneInteractionAllowed)
+ return;
+
+ // Generate a scene event.
+ QGraphicsSceneDragDropEvent sceneEvent(QEvent::GraphicsSceneDrop);
+ d->populateSceneDragDropEvent(&sceneEvent, event);
+
+ // Send it to the scene.
+ QApplication::sendEvent(d->scene, &sceneEvent);
+
+ // Accept the originating event if the scene accepted the scene event.
+ event->setAccepted(sceneEvent.isAccepted());
+ if (sceneEvent.isAccepted())
+ event->setDropAction(sceneEvent.dropAction());
+
+ delete d->lastDragDropEvent;
+ d->lastDragDropEvent = 0;
+
+#else
+ Q_UNUSED(event)
+#endif
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsView::dragEnterEvent(QDragEnterEvent *event)
+{
+#ifndef QT_NO_DRAGANDDROP
+ Q_D(QGraphicsView);
+ if (!d->scene || !d->sceneInteractionAllowed)
+ return;
+
+ // Disable replaying of mouse move events.
+ d->useLastMouseEvent = false;
+
+ // Generate a scene event.
+ QGraphicsSceneDragDropEvent sceneEvent(QEvent::GraphicsSceneDragEnter);
+ d->populateSceneDragDropEvent(&sceneEvent, event);
+
+ // Store it for later use.
+ d->storeDragDropEvent(&sceneEvent);
+
+ // Send it to the scene.
+ QApplication::sendEvent(d->scene, &sceneEvent);
+
+ // Accept the originating event if the scene accepted the scene event.
+ if (sceneEvent.isAccepted()) {
+ event->setAccepted(true);
+ event->setDropAction(sceneEvent.dropAction());
+ }
+#else
+ Q_UNUSED(event)
+#endif
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsView::dragLeaveEvent(QDragLeaveEvent *event)
+{
+#ifndef QT_NO_DRAGANDDROP
+ Q_D(QGraphicsView);
+ if (!d->scene || !d->sceneInteractionAllowed)
+ return;
+ if (!d->lastDragDropEvent) {
+ qWarning("QGraphicsView::dragLeaveEvent: drag leave received before drag enter");
+ return;
+ }
+
+ // Generate a scene event.
+ QGraphicsSceneDragDropEvent sceneEvent(QEvent::GraphicsSceneDragLeave);
+ sceneEvent.setScenePos(d->lastDragDropEvent->scenePos());
+ sceneEvent.setScreenPos(d->lastDragDropEvent->screenPos());
+ sceneEvent.setButtons(d->lastDragDropEvent->buttons());
+ sceneEvent.setModifiers(d->lastDragDropEvent->modifiers());
+ sceneEvent.setPossibleActions(d->lastDragDropEvent->possibleActions());
+ sceneEvent.setProposedAction(d->lastDragDropEvent->proposedAction());
+ sceneEvent.setDropAction(d->lastDragDropEvent->dropAction());
+ sceneEvent.setMimeData(d->lastDragDropEvent->mimeData());
+ sceneEvent.setWidget(d->lastDragDropEvent->widget());
+ sceneEvent.setSource(d->lastDragDropEvent->source());
+ delete d->lastDragDropEvent;
+ d->lastDragDropEvent = 0;
+
+ // Send it to the scene.
+ QApplication::sendEvent(d->scene, &sceneEvent);
+
+ // Accept the originating event if the scene accepted the scene event.
+ if (sceneEvent.isAccepted())
+ event->setAccepted(true);
+#else
+ Q_UNUSED(event)
+#endif
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsView::dragMoveEvent(QDragMoveEvent *event)
+{
+#ifndef QT_NO_DRAGANDDROP
+ Q_D(QGraphicsView);
+ if (!d->scene || !d->sceneInteractionAllowed)
+ return;
+
+ // Generate a scene event.
+ QGraphicsSceneDragDropEvent sceneEvent(QEvent::GraphicsSceneDragMove);
+ d->populateSceneDragDropEvent(&sceneEvent, event);
+
+ // Store it for later use.
+ d->storeDragDropEvent(&sceneEvent);
+
+ // Send it to the scene.
+ QApplication::sendEvent(d->scene, &sceneEvent);
+
+ // Ignore the originating event if the scene ignored the scene event.
+ event->setAccepted(sceneEvent.isAccepted());
+ if (sceneEvent.isAccepted())
+ event->setDropAction(sceneEvent.dropAction());
+#else
+ Q_UNUSED(event)
+#endif
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsView::focusInEvent(QFocusEvent *event)
+{
+ Q_D(QGraphicsView);
+ d->updateInputMethodSensitivity();
+ QAbstractScrollArea::focusInEvent(event);
+ if (d->scene)
+ QApplication::sendEvent(d->scene, event);
+ // Pass focus on if the scene cannot accept focus.
+ if (!d->scene || !event->isAccepted())
+ QAbstractScrollArea::focusInEvent(event);
+}
+
+/*!
+ \reimp
+*/
+bool QGraphicsView::focusNextPrevChild(bool next)
+{
+ return QAbstractScrollArea::focusNextPrevChild(next);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsView::focusOutEvent(QFocusEvent *event)
+{
+ Q_D(QGraphicsView);
+ QAbstractScrollArea::focusOutEvent(event);
+ if (d->scene)
+ QApplication::sendEvent(d->scene, event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsView::keyPressEvent(QKeyEvent *event)
+{
+ Q_D(QGraphicsView);
+ if (!d->scene || !d->sceneInteractionAllowed) {
+ QAbstractScrollArea::keyPressEvent(event);
+ return;
+ }
+ QApplication::sendEvent(d->scene, event);
+ if (!event->isAccepted())
+ QAbstractScrollArea::keyPressEvent(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsView::keyReleaseEvent(QKeyEvent *event)
+{
+ Q_D(QGraphicsView);
+ if (!d->scene || !d->sceneInteractionAllowed)
+ return;
+ QApplication::sendEvent(d->scene, event);
+ if (!event->isAccepted())
+ QAbstractScrollArea::keyReleaseEvent(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsView::mouseDoubleClickEvent(QMouseEvent *event)
+{
+ Q_D(QGraphicsView);
+ if (!d->scene || !d->sceneInteractionAllowed)
+ return;
+
+ d->storeMouseEvent(event);
+ d->mousePressViewPoint = event->pos();
+ d->mousePressScenePoint = mapToScene(d->mousePressViewPoint);
+ d->mousePressScreenPoint = event->globalPos();
+ d->lastMouseMoveScenePoint = d->mousePressScenePoint;
+ d->lastMouseMoveScreenPoint = d->mousePressScreenPoint;
+ d->mousePressButton = event->button();
+
+ QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseDoubleClick);
+ mouseEvent.setWidget(viewport());
+ mouseEvent.setButtonDownScenePos(d->mousePressButton, d->mousePressScenePoint);
+ mouseEvent.setButtonDownScreenPos(d->mousePressButton, d->mousePressScreenPoint);
+ mouseEvent.setScenePos(mapToScene(d->mousePressViewPoint));
+ mouseEvent.setScreenPos(d->mousePressScreenPoint);
+ mouseEvent.setLastScenePos(d->lastMouseMoveScenePoint);
+ mouseEvent.setLastScreenPos(d->lastMouseMoveScreenPoint);
+ mouseEvent.setButtons(event->buttons());
+ mouseEvent.setButtons(event->buttons());
+ mouseEvent.setAccepted(false);
+ mouseEvent.setButton(event->button());
+ mouseEvent.setModifiers(event->modifiers());
+ if (event->spontaneous())
+ qt_sendSpontaneousEvent(d->scene, &mouseEvent);
+ else
+ QApplication::sendEvent(d->scene, &mouseEvent);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsView::mousePressEvent(QMouseEvent *event)
+{
+ Q_D(QGraphicsView);
+
+ // Store this event for replaying, finding deltas, and for
+ // scroll-dragging; even in non-interactive mode, scroll hand dragging is
+ // allowed, so we store the event at the very top of this function.
+ d->storeMouseEvent(event);
+ d->lastMouseEvent.setAccepted(false);
+
+ if (d->sceneInteractionAllowed) {
+ // Store some of the event's button-down data.
+ d->mousePressViewPoint = event->pos();
+ d->mousePressScenePoint = mapToScene(d->mousePressViewPoint);
+ d->mousePressScreenPoint = event->globalPos();
+ d->lastMouseMoveScenePoint = d->mousePressScenePoint;
+ d->lastMouseMoveScreenPoint = d->mousePressScreenPoint;
+ d->mousePressButton = event->button();
+
+ if (d->scene) {
+ // Convert and deliver the mouse event to the scene.
+ QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMousePress);
+ mouseEvent.setWidget(viewport());
+ mouseEvent.setButtonDownScenePos(d->mousePressButton, d->mousePressScenePoint);
+ mouseEvent.setButtonDownScreenPos(d->mousePressButton, d->mousePressScreenPoint);
+ mouseEvent.setScenePos(d->mousePressScenePoint);
+ mouseEvent.setScreenPos(d->mousePressScreenPoint);
+ mouseEvent.setLastScenePos(d->lastMouseMoveScenePoint);
+ mouseEvent.setLastScreenPos(d->lastMouseMoveScreenPoint);
+ mouseEvent.setButtons(event->buttons());
+ mouseEvent.setButton(event->button());
+ mouseEvent.setModifiers(event->modifiers());
+ mouseEvent.setAccepted(false);
+ if (event->spontaneous())
+ qt_sendSpontaneousEvent(d->scene, &mouseEvent);
+ else
+ QApplication::sendEvent(d->scene, &mouseEvent);
+
+ // Update the original mouse event accepted state.
+ bool isAccepted = mouseEvent.isAccepted();
+ event->setAccepted(isAccepted);
+
+ // Update the last mouse event accepted state.
+ d->lastMouseEvent.setAccepted(isAccepted);
+
+ if (isAccepted)
+ return;
+ }
+ }
+
+#ifndef QT_NO_RUBBERBAND
+ if (d->dragMode == QGraphicsView::RubberBandDrag && !d->rubberBanding) {
+ if (d->sceneInteractionAllowed) {
+ // Rubberbanding is only allowed in interactive mode.
+ event->accept();
+ d->rubberBanding = true;
+ d->rubberBandRect = QRect();
+ if (d->scene) {
+ // Initiating a rubber band always clears the selection.
+ d->scene->clearSelection();
+ }
+ }
+ } else
+#endif
+ if (d->dragMode == QGraphicsView::ScrollHandDrag && event->button() == Qt::LeftButton) {
+ // Left-button press in scroll hand mode initiates hand scrolling.
+ event->accept();
+ d->handScrolling = true;
+ d->handScrollMotions = 0;
+#ifndef QT_NO_CURSOR
+ viewport()->setCursor(Qt::ClosedHandCursor);
+#endif
+ }
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsView::mouseMoveEvent(QMouseEvent *event)
+{
+ Q_D(QGraphicsView);
+
+#ifndef QT_NO_RUBBERBAND
+ if (d->dragMode == QGraphicsView::RubberBandDrag && d->sceneInteractionAllowed) {
+ d->storeMouseEvent(event);
+ if (d->rubberBanding) {
+ // Check for enough drag distance
+ if ((d->mousePressViewPoint - event->pos()).manhattanLength()
+ < QApplication::startDragDistance()) {
+ return;
+ }
+
+ // Update old rubberband
+ if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate && !d->rubberBandRect.isEmpty()) {
+ if (d->viewportUpdateMode != FullViewportUpdate)
+ viewport()->update(d->rubberBandRegion(viewport(), d->rubberBandRect));
+ else
+ d->updateAll();
+ }
+
+ // Stop rubber banding if the user has let go of all buttons (even
+ // if we didn't get the release events).
+ if (!event->buttons()) {
+ d->rubberBanding = false;
+ d->rubberBandRect = QRect();
+ return;
+ }
+
+ // Update rubberband position
+ const QPoint &mp = d->mousePressViewPoint;
+ QPoint ep = event->pos();
+ d->rubberBandRect = QRect(qMin(mp.x(), ep.x()), qMin(mp.y(), ep.y()),
+ qAbs(mp.x() - ep.x()) + 1, qAbs(mp.y() - ep.y()) + 1);
+
+ // Update new rubberband
+ if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate){
+ if (d->viewportUpdateMode != FullViewportUpdate)
+ viewport()->update(d->rubberBandRegion(viewport(), d->rubberBandRect));
+ else
+ d->updateAll();
+ }
+ // Set the new selection area
+ QPainterPath selectionArea;
+ selectionArea.addPolygon(mapToScene(d->rubberBandRect));
+ selectionArea.closeSubpath();
+ if (d->scene)
+ d->scene->setSelectionArea(selectionArea, d->rubberBandSelectionMode,
+ viewportTransform());
+ return;
+ }
+ } else
+#endif // QT_NO_RUBBERBAND
+ if (d->dragMode == QGraphicsView::ScrollHandDrag) {
+ if (d->handScrolling) {
+ QScrollBar *hBar = horizontalScrollBar();
+ QScrollBar *vBar = verticalScrollBar();
+ QPoint delta = event->pos() - d->lastMouseEvent.pos();
+ hBar->setValue(hBar->value() + (isRightToLeft() ? delta.x() : -delta.x()));
+ vBar->setValue(vBar->value() - delta.y());
+
+ // Detect how much we've scrolled to disambiguate scrolling from
+ // clicking.
+ ++d->handScrollMotions;
+ }
+ }
+
+ d->mouseMoveEventHandler(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsView::mouseReleaseEvent(QMouseEvent *event)
+{
+ Q_D(QGraphicsView);
+
+#ifndef QT_NO_RUBBERBAND
+ if (d->dragMode == QGraphicsView::RubberBandDrag && d->sceneInteractionAllowed && !event->buttons()) {
+ if (d->rubberBanding) {
+ if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate){
+ if (d->viewportUpdateMode != FullViewportUpdate)
+ viewport()->update(d->rubberBandRegion(viewport(), d->rubberBandRect));
+ else
+ d->updateAll();
+ }
+ d->rubberBanding = false;
+ d->rubberBandRect = QRect();
+ }
+ } else
+#endif
+ if (d->dragMode == QGraphicsView::ScrollHandDrag && event->button() == Qt::LeftButton) {
+#ifndef QT_NO_CURSOR
+ // Restore the open hand cursor. ### There might be items
+ // under the mouse that have a valid cursor at this time, so
+ // we could repeat the steps from mouseMoveEvent().
+ viewport()->setCursor(Qt::OpenHandCursor);
+#endif
+ d->handScrolling = false;
+
+ if (d->scene && d->sceneInteractionAllowed && !d->lastMouseEvent.isAccepted() && d->handScrollMotions <= 6) {
+ // If we've detected very little motion during the hand drag, and
+ // no item accepted the last event, we'll interpret that as a
+ // click to the scene, and reset the selection.
+ d->scene->clearSelection();
+ }
+ }
+
+ d->storeMouseEvent(event);
+
+ if (!d->sceneInteractionAllowed)
+ return;
+
+ if (!d->scene)
+ return;
+
+ QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseRelease);
+ mouseEvent.setWidget(viewport());
+ mouseEvent.setButtonDownScenePos(d->mousePressButton, d->mousePressScenePoint);
+ mouseEvent.setButtonDownScreenPos(d->mousePressButton, d->mousePressScreenPoint);
+ mouseEvent.setScenePos(mapToScene(event->pos()));
+ mouseEvent.setScreenPos(event->globalPos());
+ mouseEvent.setLastScenePos(d->lastMouseMoveScenePoint);
+ mouseEvent.setLastScreenPos(d->lastMouseMoveScreenPoint);
+ mouseEvent.setButtons(event->buttons());
+ mouseEvent.setButton(event->button());
+ mouseEvent.setModifiers(event->modifiers());
+ mouseEvent.setAccepted(false);
+ if (event->spontaneous())
+ qt_sendSpontaneousEvent(d->scene, &mouseEvent);
+ else
+ QApplication::sendEvent(d->scene, &mouseEvent);
+
+ // Update the last mouse event selected state.
+ d->lastMouseEvent.setAccepted(mouseEvent.isAccepted());
+
+#ifndef QT_NO_CURSOR
+ if (mouseEvent.isAccepted() && mouseEvent.buttons() == 0 && viewport()->testAttribute(Qt::WA_SetCursor)) {
+ // The last mouse release on the viewport will trigger clearing the cursor.
+ d->_q_unsetViewportCursor();
+ }
+#endif
+}
+
+#ifndef QT_NO_WHEELEVENT
+/*!
+ \reimp
+*/
+void QGraphicsView::wheelEvent(QWheelEvent *event)
+{
+ Q_D(QGraphicsView);
+ if (!d->scene || !d->sceneInteractionAllowed) {
+ QAbstractScrollArea::wheelEvent(event);
+ return;
+ }
+
+ event->ignore();
+
+ QGraphicsSceneWheelEvent wheelEvent(QEvent::GraphicsSceneWheel);
+ wheelEvent.setWidget(viewport());
+ wheelEvent.setScenePos(mapToScene(event->pos()));
+ wheelEvent.setScreenPos(event->globalPos());
+ wheelEvent.setButtons(event->buttons());
+ wheelEvent.setModifiers(event->modifiers());
+ wheelEvent.setDelta(event->delta());
+ wheelEvent.setOrientation(event->orientation());
+ wheelEvent.setAccepted(false);
+ QApplication::sendEvent(d->scene, &wheelEvent);
+ event->setAccepted(wheelEvent.isAccepted());
+ if (!event->isAccepted())
+ QAbstractScrollArea::wheelEvent(event);
+}
+#endif // QT_NO_WHEELEVENT
+
+/*!
+ \reimp
+*/
+void QGraphicsView::paintEvent(QPaintEvent *event)
+{
+ Q_D(QGraphicsView);
+ if (!d->scene) {
+ QAbstractScrollArea::paintEvent(event);
+ return;
+ }
+
+ // Set up painter state protection.
+ d->scene->d_func()->painterStateProtection = !(d->optimizationFlags & DontSavePainterState);
+
+ // Determine the exposed region
+ d->exposedRegion = event->region();
+ QRectF exposedSceneRect = mapToScene(d->exposedRegion.boundingRect()).boundingRect();
+
+ // Set up the painter
+ QPainter painter(viewport());
+#ifndef QT_NO_RUBBERBAND
+ if (d->rubberBanding && !d->rubberBandRect.isEmpty())
+ painter.save();
+#endif
+ // Set up render hints
+ painter.setRenderHints(painter.renderHints(), false);
+ painter.setRenderHints(d->renderHints, true);
+
+ // Set up viewport transform
+ const bool viewTransformed = isTransformed();
+ if (viewTransformed)
+ painter.setWorldTransform(viewportTransform());
+ const QTransform viewTransform = painter.worldTransform();
+
+ // Draw background
+ if ((d->cacheMode & CacheBackground)
+#ifdef Q_WS_X11
+ && X11->use_xrender
+#endif
+ ) {
+ // Recreate the background pixmap, and flag the whole background as
+ // exposed.
+ if (d->mustResizeBackgroundPixmap) {
+ d->backgroundPixmap = QPixmap(viewport()->size());
+ QBrush bgBrush = viewport()->palette().brush(viewport()->backgroundRole());
+ if (!bgBrush.isOpaque())
+ d->backgroundPixmap.fill(Qt::transparent);
+ QPainter p(&d->backgroundPixmap);
+ p.fillRect(0, 0, d->backgroundPixmap.width(), d->backgroundPixmap.height(), bgBrush);
+ d->backgroundPixmapExposed = QRegion(viewport()->rect());
+ d->mustResizeBackgroundPixmap = false;
+ }
+
+ // Redraw exposed areas
+ if (!d->backgroundPixmapExposed.isEmpty()) {
+ QPainter backgroundPainter(&d->backgroundPixmap);
+ backgroundPainter.setClipRegion(d->backgroundPixmapExposed, Qt::ReplaceClip);
+ if (viewTransformed)
+ backgroundPainter.setTransform(viewTransform);
+ QRectF backgroundExposedSceneRect = mapToScene(d->backgroundPixmapExposed.boundingRect()).boundingRect();
+ drawBackground(&backgroundPainter, backgroundExposedSceneRect);
+ d->backgroundPixmapExposed = QRegion();
+ }
+
+ // Blit the background from the background pixmap
+ if (viewTransformed) {
+ painter.setWorldTransform(QTransform());
+ painter.drawPixmap(QPoint(), d->backgroundPixmap);
+ painter.setWorldTransform(viewTransform);
+ } else {
+ painter.drawPixmap(QPoint(), d->backgroundPixmap);
+ }
+ } else {
+ if (!(d->optimizationFlags & DontSavePainterState))
+ painter.save();
+ drawBackground(&painter, exposedSceneRect);
+ if (!(d->optimizationFlags & DontSavePainterState))
+ painter.restore();
+ }
+
+ // Items
+ if (!(d->optimizationFlags & IndirectPainting)) {
+ const quint32 oldRectAdjust = d->scene->d_func()->rectAdjust;
+ if (d->optimizationFlags & QGraphicsView::DontAdjustForAntialiasing)
+ d->scene->d_func()->rectAdjust = 1;
+ else
+ d->scene->d_func()->rectAdjust = 2;
+ d->scene->d_func()->drawItems(&painter, viewTransformed ? &viewTransform : 0,
+ &d->exposedRegion, viewport());
+ d->scene->d_func()->rectAdjust = oldRectAdjust;
+ // Make sure the painter's world transform is restored correctly when
+ // drawing without painter state protection (DontSavePainterState).
+ // We only change the worldTransform() so there's no need to do a full-blown
+ // save() and restore(). Also note that we don't have to do this in case of
+ // IndirectPainting (the else branch), because in that case we always save()
+ // and restore() in QGraphicsScene::drawItems().
+ if (!d->scene->d_func()->painterStateProtection)
+ painter.setOpacity(1.0);
+ painter.setWorldTransform(viewTransform);
+ } else {
+ // Make sure we don't have unpolished items before we draw
+ if (!d->scene->d_func()->unpolishedItems.isEmpty())
+ d->scene->d_func()->_q_polishItems();
+ // We reset updateAll here (after we've issued polish events)
+ // so that we can discard update requests coming from polishEvent().
+ d->scene->d_func()->updateAll = false;
+
+ // Find all exposed items
+ bool allItems = false;
+ QList<QGraphicsItem *> itemList = d->findItems(d->exposedRegion, &allItems, viewTransform);
+ if (!itemList.isEmpty()) {
+ // Generate the style options.
+ const int numItems = itemList.size();
+ QGraphicsItem **itemArray = &itemList[0]; // Relies on QList internals, but is perfectly valid.
+ QStyleOptionGraphicsItem *styleOptionArray = d->allocStyleOptionsArray(numItems);
+ QTransform transform(Qt::Uninitialized);
+ for (int i = 0; i < numItems; ++i) {
+ QGraphicsItem *item = itemArray[i];
+ QGraphicsItemPrivate *itemd = item->d_ptr.data();
+ itemd->initStyleOption(&styleOptionArray[i], viewTransform, d->exposedRegion, allItems);
+ // Cache the item's area in view coordinates.
+ // Note that we have to do this here in case the base class implementation
+ // (QGraphicsScene::drawItems) is not called. If it is, we'll do this
+ // operation twice, but that's the price one has to pay for using indirect
+ // painting :-/.
+ const QRectF brect = adjustedItemEffectiveBoundingRect(item);
+ if (!itemd->itemIsUntransformable()) {
+ transform = item->sceneTransform();
+ if (viewTransformed)
+ transform *= viewTransform;
+ } else {
+ transform = item->deviceTransform(viewTransform);
+ }
+ itemd->paintedViewBoundingRects.insert(d->viewport, transform.mapRect(brect).toRect());
+ }
+ // Draw the items.
+ drawItems(&painter, numItems, itemArray, styleOptionArray);
+ d->freeStyleOptionsArray(styleOptionArray);
+ }
+ }
+
+ // Foreground
+ drawForeground(&painter, exposedSceneRect);
+
+#ifndef QT_NO_RUBBERBAND
+ // Rubberband
+ if (d->rubberBanding && !d->rubberBandRect.isEmpty()) {
+ painter.restore();
+ QStyleOptionRubberBand option;
+ option.initFrom(viewport());
+ option.rect = d->rubberBandRect;
+ option.shape = QRubberBand::Rectangle;
+
+ QStyleHintReturnMask mask;
+ if (viewport()->style()->styleHint(QStyle::SH_RubberBand_Mask, &option, viewport(), &mask)) {
+ // painter clipping for masked rubberbands
+ painter.setClipRegion(mask.region, Qt::IntersectClip);
+ }
+
+ viewport()->style()->drawControl(QStyle::CE_RubberBand, &option, &painter, viewport());
+ }
+#endif
+
+ painter.end();
+
+ // Restore painter state protection.
+ d->scene->d_func()->painterStateProtection = true;
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsView::resizeEvent(QResizeEvent *event)
+{
+ Q_D(QGraphicsView);
+ // Save the last center point - the resize may scroll the view, which
+ // changes the center point.
+ QPointF oldLastCenterPoint = d->lastCenterPoint;
+
+ QAbstractScrollArea::resizeEvent(event);
+ d->recalculateContentSize();
+
+ // Restore the center point again.
+ if (d->resizeAnchor == NoAnchor && !d->keepLastCenterPoint) {
+ d->updateLastCenterPoint();
+ } else {
+ d->lastCenterPoint = oldLastCenterPoint;
+ }
+ d->centerView(d->resizeAnchor);
+ d->keepLastCenterPoint = false;
+
+ if (d->cacheMode & CacheBackground) {
+ // Invalidate the background pixmap
+ d->mustResizeBackgroundPixmap = true;
+ }
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsView::scrollContentsBy(int dx, int dy)
+{
+ Q_D(QGraphicsView);
+ d->dirtyScroll = true;
+ if (d->transforming)
+ return;
+ if (isRightToLeft())
+ dx = -dx;
+
+ if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate) {
+ if (d->viewportUpdateMode != QGraphicsView::FullViewportUpdate) {
+ if (d->accelerateScrolling) {
+#ifndef QT_NO_RUBBERBAND
+ // Update new and old rubberband regions
+ if (!d->rubberBandRect.isEmpty()) {
+ QRegion rubberBandRegion(d->rubberBandRegion(viewport(), d->rubberBandRect));
+ rubberBandRegion += rubberBandRegion.translated(-dx, -dy);
+ viewport()->update(rubberBandRegion);
+ }
+#endif
+ d->dirtyScrollOffset.rx() += dx;
+ d->dirtyScrollOffset.ry() += dy;
+ d->dirtyRegion.translate(dx, dy);
+ viewport()->scroll(dx, dy);
+ } else {
+ d->updateAll();
+ }
+ } else {
+ d->updateAll();
+ }
+ }
+
+ d->updateLastCenterPoint();
+
+ if ((d->cacheMode & CacheBackground)
+#ifdef Q_WS_X11
+ && X11->use_xrender
+#endif
+ ) {
+ // Scroll the background pixmap
+ QRegion exposed;
+ if (!d->backgroundPixmap.isNull())
+ d->backgroundPixmap.scroll(dx, dy, d->backgroundPixmap.rect(), &exposed);
+
+ // Invalidate the background pixmap
+ d->backgroundPixmapExposed.translate(dx, dy);
+ d->backgroundPixmapExposed += exposed;
+ }
+
+ // Always replay on scroll.
+ if (d->sceneInteractionAllowed)
+ d->replayLastMouseEvent();
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsView::showEvent(QShowEvent *event)
+{
+ Q_D(QGraphicsView);
+ d->recalculateContentSize();
+ d->centerView(d->transformationAnchor);
+ QAbstractScrollArea::showEvent(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsView::inputMethodEvent(QInputMethodEvent *event)
+{
+ Q_D(QGraphicsView);
+ if (d->scene)
+ QApplication::sendEvent(d->scene, event);
+}
+
+/*!
+ Draws the background of the scene using \a painter, before any items and
+ the foreground are drawn. Reimplement this function to provide a custom
+ background for this view.
+
+ If all you want is to define a color, texture or gradient for the
+ background, you can call setBackgroundBrush() instead.
+
+ All painting is done in \e scene coordinates. \a rect is the exposed
+ rectangle.
+
+ The default implementation fills \a rect using the view's backgroundBrush.
+ If no such brush is defined (the default), the scene's drawBackground()
+ function is called instead.
+
+ \sa drawForeground(), QGraphicsScene::drawBackground()
+*/
+void QGraphicsView::drawBackground(QPainter *painter, const QRectF &rect)
+{
+ Q_D(QGraphicsView);
+ if (d->scene && d->backgroundBrush.style() == Qt::NoBrush) {
+ d->scene->drawBackground(painter, rect);
+ return;
+ }
+
+ painter->fillRect(rect, d->backgroundBrush);
+}
+
+/*!
+ Draws the foreground of the scene using \a painter, after the background
+ and all items are drawn. Reimplement this function to provide a custom
+ foreground for this view.
+
+ If all you want is to define a color, texture or gradient for the
+ foreground, you can call setForegroundBrush() instead.
+
+ All painting is done in \e scene coordinates. \a rect is the exposed
+ rectangle.
+
+ The default implementation fills \a rect using the view's foregroundBrush.
+ If no such brush is defined (the default), the scene's drawForeground()
+ function is called instead.
+
+ \sa drawBackground(), QGraphicsScene::drawForeground()
+*/
+void QGraphicsView::drawForeground(QPainter *painter, const QRectF &rect)
+{
+ Q_D(QGraphicsView);
+ if (d->scene && d->foregroundBrush.style() == Qt::NoBrush) {
+ d->scene->drawForeground(painter, rect);
+ return;
+ }
+
+ painter->fillRect(rect, d->foregroundBrush);
+}
+
+/*!
+ \obsolete
+
+ Draws the items \a items in the scene using \a painter, after the
+ background and before the foreground are drawn. \a numItems is the number
+ of items in \a items and options in \a options. \a options is a list of
+ styleoptions; one for each item. Reimplement this function to provide
+ custom item drawing for this view.
+
+ The default implementation calls the scene's drawItems() function.
+
+ Since Qt 4.6, this function is not called anymore unless
+ the QGraphicsView::IndirectPainting flag is given as an Optimization
+ flag.
+
+ \sa drawForeground(), drawBackground(), QGraphicsScene::drawItems()
+*/
+void QGraphicsView::drawItems(QPainter *painter, int numItems,
+ QGraphicsItem *items[],
+ const QStyleOptionGraphicsItem options[])
+{
+ Q_D(QGraphicsView);
+ if (d->scene) {
+ QWidget *widget = painter->device() == viewport() ? viewport() : 0;
+ d->scene->drawItems(painter, numItems, items, options, widget);
+ }
+}
+
+/*!
+ Returns the current transformation matrix for the view. If no current
+ transformation is set, the identity matrix is returned.
+
+ \sa setTransform(), rotate(), scale(), shear(), translate()
+*/
+QTransform QGraphicsView::transform() const
+{
+ Q_D(const QGraphicsView);
+ return d->matrix;
+}
+
+/*!
+ Returns a matrix that maps viewport coordinates to scene coordinates.
+
+ \sa mapToScene(), mapFromScene()
+*/
+QTransform QGraphicsView::viewportTransform() const
+{
+ Q_D(const QGraphicsView);
+ QTransform moveMatrix = QTransform::fromTranslate(-d->horizontalScroll(), -d->verticalScroll());
+ return d->identityMatrix ? moveMatrix : d->matrix * moveMatrix;
+}
+
+/*!
+ \since 4.6
+
+ Returns true if the view is transformed (i.e., a non-identity transform
+ has been assigned, or the scrollbars are adjusted).
+
+ \sa setTransform(), horizontalScrollBar(), verticalScrollBar()
+*/
+bool QGraphicsView::isTransformed() const
+{
+ Q_D(const QGraphicsView);
+ return !d->identityMatrix || d->horizontalScroll() || d->verticalScroll();
+}
+
+/*!
+ Sets the view's current transformation matrix to \a matrix.
+
+ If \a combine is true, then \a matrix is combined with the current matrix;
+ otherwise, \a matrix \e replaces the current matrix. \a combine is false
+ by default.
+
+ The transformation matrix tranforms the scene into view coordinates. Using
+ the default transformation, provided by the identity matrix, one pixel in
+ the view represents one unit in the scene (e.g., a 10x10 rectangular item
+ is drawn using 10x10 pixels in the view). If a 2x2 scaling matrix is
+ applied, the scene will be drawn in 1:2 (e.g., a 10x10 rectangular item is
+ then drawn using 20x20 pixels in the view).
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicsview.cpp 7
+
+ To simplify interation with items using a transformed view, QGraphicsView
+ provides mapTo... and mapFrom... functions that can translate between
+ scene and view coordinates. For example, you can call mapToScene() to map
+ a view coordiate to a floating point scene coordinate, or mapFromScene()
+ to map from floating point scene coordinates to view coordinates.
+
+ \sa transform(), rotate(), scale(), shear(), translate()
+*/
+void QGraphicsView::setTransform(const QTransform &matrix, bool combine )
+{
+ Q_D(QGraphicsView);
+ QTransform oldMatrix = d->matrix;
+ if (!combine)
+ d->matrix = matrix;
+ else
+ d->matrix = matrix * d->matrix;
+ if (oldMatrix == d->matrix)
+ return;
+
+ d->identityMatrix = d->matrix.isIdentity();
+ d->transforming = true;
+ if (d->scene) {
+ d->recalculateContentSize();
+ d->centerView(d->transformationAnchor);
+ } else {
+ d->updateLastCenterPoint();
+ }
+
+ if (d->sceneInteractionAllowed)
+ d->replayLastMouseEvent();
+ d->transforming = false;
+
+ // Any matrix operation requires a full update.
+ d->updateAll();
+}
+
+/*!
+ Resets the view transformation to the identity matrix.
+
+ \sa transform(), setTransform()
+*/
+void QGraphicsView::resetTransform()
+{
+ setTransform(QTransform());
+}
+
+QPointF QGraphicsViewPrivate::mapToScene(const QPointF &point) const
+{
+ QPointF p = point;
+ p.rx() += horizontalScroll();
+ p.ry() += verticalScroll();
+ return identityMatrix ? p : matrix.inverted().map(p);
+}
+
+QRectF QGraphicsViewPrivate::mapToScene(const QRectF &rect) const
+{
+ QPointF scrollOffset(horizontalScroll(), verticalScroll());
+ QPointF tl = scrollOffset + rect.topLeft();
+ QPointF tr = scrollOffset + rect.topRight();
+ QPointF br = scrollOffset + rect.bottomRight();
+ QPointF bl = scrollOffset + rect.bottomLeft();
+
+ QPolygonF poly(4);
+ if (!identityMatrix) {
+ QTransform x = matrix.inverted();
+ poly[0] = x.map(tl);
+ poly[1] = x.map(tr);
+ poly[2] = x.map(br);
+ poly[3] = x.map(bl);
+ } else {
+ poly[0] = tl;
+ poly[1] = tr;
+ poly[2] = br;
+ poly[3] = bl;
+ }
+ return poly.boundingRect();
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qgraphicsview.cpp"
+
+#endif // QT_NO_GRAPHICSVIEW
diff --git a/src/widgets/graphicsview/qgraphicsview.h b/src/widgets/graphicsview/qgraphicsview.h
new file mode 100644
index 0000000000..60bd3d5616
--- /dev/null
+++ b/src/widgets/graphicsview/qgraphicsview.h
@@ -0,0 +1,316 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGRAPHICSVIEW_H
+#define QGRAPHICSVIEW_H
+
+#include <QtCore/qmetatype.h>
+#include <QtGui/qpainter.h>
+#include <QtWidgets/qscrollarea.h>
+#include <QtWidgets/qgraphicsscene.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
+
+class QGraphicsItem;
+class QPainterPath;
+class QPolygonF;
+class QStyleOptionGraphicsItem;
+
+class QGraphicsViewPrivate;
+class Q_GUI_EXPORT QGraphicsView : public QAbstractScrollArea
+{
+ Q_OBJECT
+ Q_FLAGS(QPainter::RenderHints CacheMode OptimizationFlags)
+ Q_ENUMS(ViewportAnchor DragMode ViewportUpdateMode)
+ Q_PROPERTY(QBrush backgroundBrush READ backgroundBrush WRITE setBackgroundBrush)
+ Q_PROPERTY(QBrush foregroundBrush READ foregroundBrush WRITE setForegroundBrush)
+ Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive)
+ Q_PROPERTY(QRectF sceneRect READ sceneRect WRITE setSceneRect)
+ Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
+ Q_PROPERTY(QPainter::RenderHints renderHints READ renderHints WRITE setRenderHints)
+ Q_PROPERTY(DragMode dragMode READ dragMode WRITE setDragMode)
+ Q_PROPERTY(CacheMode cacheMode READ cacheMode WRITE setCacheMode)
+ Q_PROPERTY(ViewportAnchor transformationAnchor READ transformationAnchor WRITE setTransformationAnchor)
+ Q_PROPERTY(ViewportAnchor resizeAnchor READ resizeAnchor WRITE setResizeAnchor)
+ Q_PROPERTY(ViewportUpdateMode viewportUpdateMode READ viewportUpdateMode WRITE setViewportUpdateMode)
+#ifndef QT_NO_RUBBERBAND
+ Q_PROPERTY(Qt::ItemSelectionMode rubberBandSelectionMode READ rubberBandSelectionMode WRITE setRubberBandSelectionMode)
+#endif
+ Q_PROPERTY(OptimizationFlags optimizationFlags READ optimizationFlags WRITE setOptimizationFlags)
+
+public:
+ enum ViewportAnchor {
+ NoAnchor,
+ AnchorViewCenter,
+ AnchorUnderMouse
+ };
+
+ enum CacheModeFlag {
+ CacheNone = 0x0,
+ CacheBackground = 0x1
+ };
+ Q_DECLARE_FLAGS(CacheMode, CacheModeFlag)
+
+ enum DragMode {
+ NoDrag,
+ ScrollHandDrag,
+ RubberBandDrag
+ };
+
+ enum ViewportUpdateMode {
+ FullViewportUpdate,
+ MinimalViewportUpdate,
+ SmartViewportUpdate,
+ NoViewportUpdate,
+ BoundingRectViewportUpdate
+ };
+
+ enum OptimizationFlag {
+ DontClipPainter = 0x1, // obsolete
+ DontSavePainterState = 0x2,
+ DontAdjustForAntialiasing = 0x4,
+ IndirectPainting = 0x8
+ };
+ Q_DECLARE_FLAGS(OptimizationFlags, OptimizationFlag)
+
+ QGraphicsView(QWidget *parent = 0);
+ QGraphicsView(QGraphicsScene *scene, QWidget *parent = 0);
+ ~QGraphicsView();
+
+ QSize sizeHint() const;
+
+ QPainter::RenderHints renderHints() const;
+ void setRenderHint(QPainter::RenderHint hint, bool enabled = true);
+ void setRenderHints(QPainter::RenderHints hints);
+
+ Qt::Alignment alignment() const;
+ void setAlignment(Qt::Alignment alignment);
+
+ ViewportAnchor transformationAnchor() const;
+ void setTransformationAnchor(ViewportAnchor anchor);
+
+ ViewportAnchor resizeAnchor() const;
+ void setResizeAnchor(ViewportAnchor anchor);
+
+ ViewportUpdateMode viewportUpdateMode() const;
+ void setViewportUpdateMode(ViewportUpdateMode mode);
+
+ OptimizationFlags optimizationFlags() const;
+ void setOptimizationFlag(OptimizationFlag flag, bool enabled = true);
+ void setOptimizationFlags(OptimizationFlags flags);
+
+ DragMode dragMode() const;
+ void setDragMode(DragMode mode);
+
+#ifndef QT_NO_RUBBERBAND
+ Qt::ItemSelectionMode rubberBandSelectionMode() const;
+ void setRubberBandSelectionMode(Qt::ItemSelectionMode mode);
+#endif
+
+ CacheMode cacheMode() const;
+ void setCacheMode(CacheMode mode);
+ void resetCachedContent();
+
+ bool isInteractive() const;
+ void setInteractive(bool allowed);
+
+ QGraphicsScene *scene() const;
+ void setScene(QGraphicsScene *scene);
+
+ QRectF sceneRect() const;
+ void setSceneRect(const QRectF &rect);
+ inline void setSceneRect(qreal x, qreal y, qreal w, qreal h);
+
+ QMatrix matrix() const;
+ void setMatrix(const QMatrix &matrix, bool combine = false);
+ void resetMatrix();
+ QTransform transform() const;
+ QTransform viewportTransform() const;
+ bool isTransformed() const;
+ void setTransform(const QTransform &matrix, bool combine = false);
+ void resetTransform();
+ void rotate(qreal angle);
+ void scale(qreal sx, qreal sy);
+ void shear(qreal sh, qreal sv);
+ void translate(qreal dx, qreal dy);
+
+ void centerOn(const QPointF &pos);
+ inline void centerOn(qreal x, qreal y);
+ void centerOn(const QGraphicsItem *item);
+ void ensureVisible(const QRectF &rect, int xmargin = 50, int ymargin = 50);
+ inline void ensureVisible(qreal x, qreal y, qreal w, qreal h, int xmargin = 50, int ymargin = 50);
+ void ensureVisible(const QGraphicsItem *item, int xmargin = 50, int ymargin = 50);
+ void fitInView(const QRectF &rect, Qt::AspectRatioMode aspectRadioMode = Qt::IgnoreAspectRatio);
+ inline void fitInView(qreal x, qreal y, qreal w, qreal h,
+ Qt::AspectRatioMode aspectRadioMode = Qt::IgnoreAspectRatio);
+ void fitInView(const QGraphicsItem *item,
+ Qt::AspectRatioMode aspectRadioMode = Qt::IgnoreAspectRatio);
+
+ void render(QPainter *painter, const QRectF &target = QRectF(), const QRect &source = QRect(),
+ Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio);
+
+ QList<QGraphicsItem *> items() const;
+ QList<QGraphicsItem *> items(const QPoint &pos) const;
+ inline QList<QGraphicsItem *> items(int x, int y) const;
+ QList<QGraphicsItem *> items(const QRect &rect, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const;
+ inline QList<QGraphicsItem *> items(int x, int y, int w, int h, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const;
+ QList<QGraphicsItem *> items(const QPolygon &polygon, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const;
+ QList<QGraphicsItem *> items(const QPainterPath &path, Qt::ItemSelectionMode mode = Qt::IntersectsItemShape) const;
+ QGraphicsItem *itemAt(const QPoint &pos) const;
+ inline QGraphicsItem *itemAt(int x, int y) const;
+
+ QPointF mapToScene(const QPoint &point) const;
+ QPolygonF mapToScene(const QRect &rect) const;
+ QPolygonF mapToScene(const QPolygon &polygon) const;
+ QPainterPath mapToScene(const QPainterPath &path) const;
+ QPoint mapFromScene(const QPointF &point) const;
+ QPolygon mapFromScene(const QRectF &rect) const;
+ QPolygon mapFromScene(const QPolygonF &polygon) const;
+ QPainterPath mapFromScene(const QPainterPath &path) const;
+ inline QPointF mapToScene(int x, int y) const;
+ inline QPolygonF mapToScene(int x, int y, int w, int h) const;
+ inline QPoint mapFromScene(qreal x, qreal y) const;
+ inline QPolygon mapFromScene(qreal x, qreal y, qreal w, qreal h) const;
+
+ QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
+
+ QBrush backgroundBrush() const;
+ void setBackgroundBrush(const QBrush &brush);
+
+ QBrush foregroundBrush() const;
+ void setForegroundBrush(const QBrush &brush);
+
+public Q_SLOTS:
+ void updateScene(const QList<QRectF> &rects);
+ void invalidateScene(const QRectF &rect = QRectF(), QGraphicsScene::SceneLayers layers = QGraphicsScene::AllLayers);
+ void updateSceneRect(const QRectF &rect);
+
+protected Q_SLOTS:
+ void setupViewport(QWidget *widget);
+
+protected:
+ QGraphicsView(QGraphicsViewPrivate &, QWidget *parent = 0);
+ bool event(QEvent *event);
+ bool viewportEvent(QEvent *event);
+
+#ifndef QT_NO_CONTEXTMENU
+ void contextMenuEvent(QContextMenuEvent *event);
+#endif
+ void dragEnterEvent(QDragEnterEvent *event);
+ void dragLeaveEvent(QDragLeaveEvent *event);
+ void dragMoveEvent(QDragMoveEvent *event);
+ void dropEvent(QDropEvent *event);
+ void focusInEvent(QFocusEvent *event);
+ bool focusNextPrevChild(bool next);
+ void focusOutEvent(QFocusEvent *event);
+ void keyPressEvent(QKeyEvent *event);
+ void keyReleaseEvent(QKeyEvent *event);
+ void mouseDoubleClickEvent(QMouseEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *event);
+#ifndef QT_NO_WHEELEVENT
+ void wheelEvent(QWheelEvent *event);
+#endif
+ void paintEvent(QPaintEvent *event);
+ void resizeEvent(QResizeEvent *event);
+ void scrollContentsBy(int dx, int dy);
+ void showEvent(QShowEvent *event);
+ void inputMethodEvent(QInputMethodEvent *event);
+
+ virtual void drawBackground(QPainter *painter, const QRectF &rect);
+ virtual void drawForeground(QPainter *painter, const QRectF &rect);
+ virtual void drawItems(QPainter *painter, int numItems,
+ QGraphicsItem *items[],
+ const QStyleOptionGraphicsItem options[]);
+
+private:
+ Q_DECLARE_PRIVATE(QGraphicsView)
+ Q_DISABLE_COPY(QGraphicsView)
+#ifndef QT_NO_CURSOR
+ Q_PRIVATE_SLOT(d_func(), void _q_setViewportCursor(const QCursor &))
+ Q_PRIVATE_SLOT(d_func(), void _q_unsetViewportCursor())
+#endif
+ friend class QGraphicsSceneWidget;
+ friend class QGraphicsScene;
+ friend class QGraphicsScenePrivate;
+ friend class QGraphicsItemPrivate;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsView::CacheMode)
+Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsView::OptimizationFlags)
+
+inline void QGraphicsView::setSceneRect(qreal ax, qreal ay, qreal aw, qreal ah)
+{ setSceneRect(QRectF(ax, ay, aw, ah)); }
+inline void QGraphicsView::centerOn(qreal ax, qreal ay)
+{ centerOn(QPointF(ax, ay)); }
+inline void QGraphicsView::ensureVisible(qreal ax, qreal ay, qreal aw, qreal ah, int xmargin, int ymargin)
+{ ensureVisible(QRectF(ax, ay, aw, ah), xmargin, ymargin); }
+inline void QGraphicsView::fitInView(qreal ax, qreal ay, qreal w, qreal h, Qt::AspectRatioMode mode)
+{ fitInView(QRectF(ax, ay, w, h), mode); }
+inline QList<QGraphicsItem *> QGraphicsView::items(int ax, int ay) const
+{ return items(QPoint(ax, ay)); }
+inline QList<QGraphicsItem *> QGraphicsView::items(int ax, int ay, int w, int h, Qt::ItemSelectionMode mode) const
+{ return items(QRect(ax, ay, w, h), mode); }
+inline QGraphicsItem *QGraphicsView::itemAt(int ax, int ay) const
+{ return itemAt(QPoint(ax, ay)); }
+inline QPointF QGraphicsView::mapToScene(int ax, int ay) const
+{ return mapToScene(QPoint(ax, ay)); }
+inline QPolygonF QGraphicsView::mapToScene(int ax, int ay, int w, int h) const
+{ return mapToScene(QRect(ax, ay, w, h)); }
+inline QPoint QGraphicsView::mapFromScene(qreal ax, qreal ay) const
+{ return mapFromScene(QPointF(ax, ay)); }
+inline QPolygon QGraphicsView::mapFromScene(qreal ax, qreal ay, qreal w, qreal h) const
+{ return mapFromScene(QRectF(ax, ay, w, h)); }
+
+#endif // QT_NO_GRAPHICSVIEW
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QGRAPHICSVIEW_H
diff --git a/src/widgets/graphicsview/qgraphicsview_p.h b/src/widgets/graphicsview/qgraphicsview_p.h
new file mode 100644
index 0000000000..0744ab7357
--- /dev/null
+++ b/src/widgets/graphicsview/qgraphicsview_p.h
@@ -0,0 +1,233 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGRAPHICSVIEW_P_H
+#define QGRAPHICSVIEW_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qgraphicsview.h"
+
+#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
+
+#include <QtGui/qevent.h>
+#include <QtCore/qcoreapplication.h>
+#include "qgraphicssceneevent.h"
+#include <QtWidgets/qstyleoption.h>
+#include <private/qabstractscrollarea_p.h>
+#include <private/qapplication_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class Q_GUI_EXPORT QGraphicsViewPrivate : public QAbstractScrollAreaPrivate
+{
+ Q_DECLARE_PUBLIC(QGraphicsView)
+public:
+ QGraphicsViewPrivate();
+
+ void recalculateContentSize();
+ void centerView(QGraphicsView::ViewportAnchor anchor);
+
+ QPainter::RenderHints renderHints;
+
+ QGraphicsView::DragMode dragMode;
+
+ quint32 sceneInteractionAllowed : 1;
+ quint32 hasSceneRect : 1;
+ quint32 connectedToScene : 1;
+ quint32 useLastMouseEvent : 1;
+ quint32 identityMatrix : 1;
+ quint32 dirtyScroll : 1;
+ quint32 accelerateScrolling : 1;
+ quint32 keepLastCenterPoint : 1;
+ quint32 transforming : 1;
+ quint32 handScrolling : 1;
+ quint32 mustAllocateStyleOptions : 1;
+ quint32 mustResizeBackgroundPixmap : 1;
+ quint32 fullUpdatePending : 1;
+ quint32 hasUpdateClip : 1;
+ quint32 padding : 18;
+
+ QRectF sceneRect;
+ void updateLastCenterPoint();
+
+ qint64 horizontalScroll() const;
+ qint64 verticalScroll() const;
+
+ QRectF mapRectToScene(const QRect &rect) const;
+ QRectF mapRectFromScene(const QRectF &rect) const;
+
+ QRect updateClip;
+ QPointF mousePressItemPoint;
+ QPointF mousePressScenePoint;
+ QPoint mousePressViewPoint;
+ QPoint mousePressScreenPoint;
+ QPointF lastMouseMoveScenePoint;
+ QPoint lastMouseMoveScreenPoint;
+ QPoint dirtyScrollOffset;
+ Qt::MouseButton mousePressButton;
+ QTransform matrix;
+ qint64 scrollX, scrollY;
+ void updateScroll();
+
+ qreal leftIndent;
+ qreal topIndent;
+
+ // Replaying mouse events
+ QMouseEvent lastMouseEvent;
+ void replayLastMouseEvent();
+ void storeMouseEvent(QMouseEvent *event);
+ void mouseMoveEventHandler(QMouseEvent *event);
+
+ QPointF lastCenterPoint;
+ Qt::Alignment alignment;
+
+ QGraphicsView::ViewportAnchor transformationAnchor;
+ QGraphicsView::ViewportAnchor resizeAnchor;
+ QGraphicsView::ViewportUpdateMode viewportUpdateMode;
+ QGraphicsView::OptimizationFlags optimizationFlags;
+
+ QPointer<QGraphicsScene> scene;
+#ifndef QT_NO_RUBBERBAND
+ QRect rubberBandRect;
+ QRegion rubberBandRegion(const QWidget *widget, const QRect &rect) const;
+ bool rubberBanding;
+ Qt::ItemSelectionMode rubberBandSelectionMode;
+#endif
+ int handScrollMotions;
+
+ QGraphicsView::CacheMode cacheMode;
+
+ QVector<QStyleOptionGraphicsItem> styleOptions;
+ QStyleOptionGraphicsItem *allocStyleOptionsArray(int numItems);
+ void freeStyleOptionsArray(QStyleOptionGraphicsItem *array);
+
+ QBrush backgroundBrush;
+ QBrush foregroundBrush;
+ QPixmap backgroundPixmap;
+ QRegion backgroundPixmapExposed;
+
+#ifndef QT_NO_CURSOR
+ QCursor originalCursor;
+ bool hasStoredOriginalCursor;
+ void _q_setViewportCursor(const QCursor &cursor);
+ void _q_unsetViewportCursor();
+#endif
+
+ QGraphicsSceneDragDropEvent *lastDragDropEvent;
+ void storeDragDropEvent(const QGraphicsSceneDragDropEvent *event);
+ void populateSceneDragDropEvent(QGraphicsSceneDragDropEvent *dest,
+ QDropEvent *source);
+
+ QRect mapToViewRect(const QGraphicsItem *item, const QRectF &rect) const;
+ QRegion mapToViewRegion(const QGraphicsItem *item, const QRectF &rect) const;
+ QRegion dirtyRegion;
+ QRect dirtyBoundingRect;
+ void processPendingUpdates();
+ inline void updateAll()
+ {
+ viewport->update();
+ fullUpdatePending = true;
+ dirtyBoundingRect = QRect();
+ dirtyRegion = QRegion();
+ }
+
+ inline void dispatchPendingUpdateRequests()
+ {
+#ifdef Q_WS_MAC
+ // QWidget::update() works slightly different on the Mac without the raster engine;
+ // it's not part of our backing store so it needs special threatment.
+ if (QApplicationPrivate::graphics_system_name != QLatin1String("raster")) {
+ // At this point either HIViewSetNeedsDisplay (Carbon) or setNeedsDisplay: YES (Cocoa)
+ // is called, which means there's a pending update request. We want to dispatch it
+ // now because otherwise graphics view updates would require two
+ // round-trips in the event loop before the item is painted.
+ extern void qt_mac_dispatchPendingUpdateRequests(QWidget *);
+ qt_mac_dispatchPendingUpdateRequests(viewport->window());
+ } else
+#endif // !Q_WS_MAC
+ {
+ if (qt_widget_private(viewport)->paintOnScreen())
+ QCoreApplication::sendPostedEvents(viewport, QEvent::UpdateRequest);
+ else
+ QCoreApplication::sendPostedEvents(viewport->window(), QEvent::UpdateRequest);
+ }
+ }
+
+ void setUpdateClip(QGraphicsItem *);
+
+ inline bool updateRectF(const QRectF &rect)
+ {
+ if (rect.isEmpty())
+ return false;
+ if (optimizationFlags & QGraphicsView::DontAdjustForAntialiasing)
+ return updateRect(rect.toAlignedRect().adjusted(-1, -1, 1, 1));
+ return updateRect(rect.toAlignedRect().adjusted(-2, -2, 2, 2));
+ }
+
+ bool updateRect(const QRect &rect);
+ bool updateRegion(const QRectF &rect, const QTransform &xform);
+ bool updateSceneSlotReimplementedChecked;
+ QRegion exposedRegion;
+
+ QList<QGraphicsItem *> findItems(const QRegion &exposedRegion, bool *allItems,
+ const QTransform &viewTransform) const;
+
+ QPointF mapToScene(const QPointF &point) const;
+ QRectF mapToScene(const QRectF &rect) const;
+ static void translateTouchEvent(QGraphicsViewPrivate *d, QTouchEvent *touchEvent);
+ void updateInputMethodSensitivity();
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_GRAPHICSVIEW
+
+#endif
diff --git a/src/widgets/graphicsview/qgraphicswidget.cpp b/src/widgets/graphicsview/qgraphicswidget.cpp
new file mode 100644
index 0000000000..60a80fc8b8
--- /dev/null
+++ b/src/widgets/graphicsview/qgraphicswidget.cpp
@@ -0,0 +1,2388 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qglobal.h"
+
+#ifndef QT_NO_GRAPHICSVIEW
+
+#include "qgraphicswidget.h"
+#include "qgraphicswidget_p.h"
+#include "qgraphicslayout.h"
+#include "qgraphicslayout_p.h"
+#include "qgraphicsscene.h"
+#include "qgraphicssceneevent.h"
+
+#ifndef QT_NO_ACTION
+#include <private/qaction_p.h>
+#endif
+#include <private/qapplication_p.h>
+#include <private/qgraphicsscene_p.h>
+#ifndef QT_NO_SHORTCUT
+#include <private/qshortcutmap_p.h>
+#endif
+#include <QtCore/qmutex.h>
+#include <QtWidgets/qapplication.h>
+#include <QtWidgets/qgraphicsview.h>
+#include <QtWidgets/qgraphicsproxywidget.h>
+#include <QtGui/qpalette.h>
+#include <QtWidgets/qstyleoption.h>
+
+#include <qdebug.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QGraphicsWidget
+ \brief The QGraphicsWidget class is the base class for all widget
+ items in a QGraphicsScene.
+ \since 4.4
+ \ingroup graphicsview-api
+
+ QGraphicsWidget is an extended base item that provides extra functionality
+ over QGraphicsItem. It is similar to QWidget in many ways:
+
+ \list
+ \o Provides a \l palette, a \l font and a \l style().
+ \o Has a defined geometry().
+ \o Supports layouts with setLayout() and layout().
+ \o Supports shortcuts and actions with grabShortcut() and insertAction()
+ \endlist
+
+ Unlike QGraphicsItem, QGraphicsWidget is not an abstract class; you can
+ create instances of a QGraphicsWidget without having to subclass it.
+ This approach is useful for widgets that only serve the purpose of
+ organizing child widgets into a layout.
+
+ QGraphicsWidget can be used as a base item for your own custom item if
+ you require advanced input focus handling, e.g., tab focus and activation, or
+ layouts.
+
+ Since QGraphicsWidget resembles QWidget and has similar API, it is
+ easier to port a widget from QWidget to QGraphicsWidget, instead of
+ QGraphicsItem.
+
+ \note QWidget-based widgets can be directly embedded into a
+ QGraphicsScene using QGraphicsProxyWidget.
+
+ Noticeable differences between QGraphicsWidget and QWidget are:
+
+ \table
+ \header \o QGraphicsWidget
+ \o QWidget
+ \row \o Coordinates and geometry are defined with qreals (doubles or
+ floats, depending on the platform).
+ \o QWidget uses integer geometry (QPoint, QRect).
+ \row \o The widget is already visible by default; you do not have to
+ call show() to display the widget.
+ \o QWidget is hidden by default until you call show().
+ \row \o A subset of widget attributes are supported.
+ \o All widget attributes are supported.
+ \row \o A top-level item's style defaults to QGraphicsScene::style
+ \o A top-level widget's style defaults to QApplication::style
+ \row \o Graphics View provides a custom drag and drop framework, different
+ from QWidget.
+ \o Standard drag and drop framework.
+ \row \o Widget items do not support modality.
+ \o Full modality support.
+ \endtable
+
+ QGraphicsWidget supports a subset of Qt's widget attributes,
+ (Qt::WidgetAttribute), as shown in the table below. Any attributes not
+ listed in this table are unsupported, or otherwise unused.
+
+ \table
+ \header \o Widget Attribute \o Usage
+ \row \o Qt::WA_SetLayoutDirection
+ \o Set by setLayoutDirection(), cleared by
+ unsetLayoutDirection(). You can test this attribute to
+ check if the widget has been explicitly assigned a
+ \l{QGraphicsWidget::layoutDirection()}
+ {layoutDirection}. If the attribute is not set, the
+ \l{QGraphicsWidget::layoutDirection()}
+ {layoutDirection()} is inherited.
+ \row \o Qt::WA_RightToLeft
+ \o Toggled by setLayoutDirection(). Inherited from the
+ parent/scene. If set, the widget's layout will order
+ horizontally arranged widgets from right to left.
+ \row \o Qt::WA_SetStyle
+ \o Set and cleared by setStyle(). If this attribute is
+ set, the widget has been explicitly assigned a style.
+ If it is unset, the widget will use the scene's or the
+ application's style.
+ \row \o Qt::WA_Resized
+ \o Set by setGeometry() and resize().
+ \row \o Qt::WA_SetPalette
+ \o Set by setPalette().
+ \row \o Qt::WA_SetFont
+ \o Set by setPalette().
+ \row \o Qt::WA_WindowPropagation
+ \o Enables propagation to window widgets.
+ \endtable
+
+ Although QGraphicsWidget inherits from both QObject and QGraphicsItem,
+ you should use the functions provided by QGraphicsItem, \e not QObject, to
+ manage the relationships between parent and child items. These functions
+ control the stacking order of items as well as their ownership.
+
+ \note The QObject::parent() should always return 0 for QGraphicsWidgets,
+ but this policy is not strictly defined.
+
+ \sa QGraphicsProxyWidget, QGraphicsItem, {Widgets and Layouts}
+*/
+
+/*!
+ Constructs a QGraphicsWidget instance. The optional \a parent argument is
+ passed to QGraphicsItem's constructor. The optional \a wFlags argument
+ specifies the widget's window flags (e.g., whether the widget should be a
+ window, a tool, a popup, etc).
+*/
+QGraphicsWidget::QGraphicsWidget(QGraphicsItem *parent, Qt::WindowFlags wFlags)
+ : QGraphicsObject(*new QGraphicsWidgetPrivate, 0, 0), QGraphicsLayoutItem(0, false)
+{
+ Q_D(QGraphicsWidget);
+ d->init(parent, wFlags);
+}
+
+/*!
+ \internal
+
+ Constructs a new QGraphicsWidget, using \a dd as parent.
+*/
+QGraphicsWidget::QGraphicsWidget(QGraphicsWidgetPrivate &dd, QGraphicsItem *parent, QGraphicsScene *scene, Qt::WindowFlags wFlags)
+ : QGraphicsObject(dd, 0, scene), QGraphicsLayoutItem(0, false)
+{
+ Q_D(QGraphicsWidget);
+ d->init(parent, wFlags);
+}
+
+/*
+ \internal
+ \class QGraphicsWidgetStyles
+
+ We use this thread-safe class to maintain a hash of styles for widgets
+ styles. Note that QApplication::style() itself isn't thread-safe, QStyle
+ isn't thread-safe, and we don't have a thread-safe factory for creating
+ the default style, nor cloning a style.
+*/
+class QGraphicsWidgetStyles
+{
+public:
+ QStyle *styleForWidget(const QGraphicsWidget *widget) const
+ {
+ QMutexLocker locker(&mutex);
+ return styles.value(widget, 0);
+ }
+
+ void setStyleForWidget(QGraphicsWidget *widget, QStyle *style)
+ {
+ QMutexLocker locker(&mutex);
+ if (style)
+ styles[widget] = style;
+ else
+ styles.remove(widget);
+ }
+
+private:
+ QMap<const QGraphicsWidget *, QStyle *> styles;
+ mutable QMutex mutex;
+};
+Q_GLOBAL_STATIC(QGraphicsWidgetStyles, widgetStyles)
+
+/*!
+ Destroys the QGraphicsWidget instance.
+*/
+QGraphicsWidget::~QGraphicsWidget()
+{
+ Q_D(QGraphicsWidget);
+#ifndef QT_NO_ACTION
+ // Remove all actions from this widget
+ for (int i = 0; i < d->actions.size(); ++i) {
+ QActionPrivate *apriv = d->actions.at(i)->d_func();
+ apriv->graphicsWidgets.removeAll(this);
+ }
+ d->actions.clear();
+#endif
+
+ if (QGraphicsScene *scn = scene()) {
+ QGraphicsScenePrivate *sceneD = scn->d_func();
+ if (sceneD->tabFocusFirst == this)
+ sceneD->tabFocusFirst = (d->focusNext == this ? 0 : d->focusNext);
+ }
+ d->focusPrev->d_func()->focusNext = d->focusNext;
+ d->focusNext->d_func()->focusPrev = d->focusPrev;
+
+ // Play it really safe
+ d->focusNext = this;
+ d->focusPrev = this;
+
+ clearFocus();
+
+ //we check if we have a layout previously
+ if (d->layout) {
+ QGraphicsLayout *temp = d->layout;
+ foreach (QGraphicsItem * item, childItems()) {
+ // In case of a custom layout which doesn't remove and delete items, we ensure that
+ // the parent layout item does not point to the deleted layout. This code is here to
+ // avoid regression from 4.4 to 4.5, because according to 4.5 docs it is not really needed.
+ if (item->isWidget()) {
+ QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
+ if (widget->parentLayoutItem() == d->layout)
+ widget->setParentLayoutItem(0);
+ }
+ }
+ d->layout = 0;
+ delete temp;
+ }
+
+ // Remove this graphics widget from widgetStyles
+ widgetStyles()->setStyleForWidget(this, 0);
+}
+
+/*!
+ \property QGraphicsWidget::size
+ \brief the size of the widget
+
+ Calling resize() resizes the widget to a \a size bounded by minimumSize()
+ and maximumSize(). This property only affects the widget's width and
+ height (e.g., its right and bottom edges); the widget's position and
+ top-left corner remains unaffected.
+
+ Resizing a widget triggers the widget to immediately receive a
+ \l{QEvent::GraphicsSceneResize}{GraphicsSceneResize} event with the
+ widget's old and new size. If the widget has a layout assigned when this
+ event arrives, the layout will be activated and it will automatically
+ update any child widgets's geometry.
+
+ This property does not affect any layout of the parent widget. If the
+ widget itself is managed by a parent layout; e.g., it has a parent widget
+ with a layout assigned, that layout will not activate.
+
+ By default, this property contains a size with zero width and height.
+
+ \sa setGeometry(), QGraphicsSceneResizeEvent, QGraphicsLayout
+*/
+QSizeF QGraphicsWidget::size() const
+{
+ return QGraphicsLayoutItem::geometry().size();
+}
+
+void QGraphicsWidget::resize(const QSizeF &size)
+{
+ setGeometry(QRectF(pos(), size));
+}
+
+/*!
+ \fn void QGraphicsWidget::resize(qreal w, qreal h)
+
+ This convenience function is equivalent to calling resize(QSizeF(w, h)).
+
+ \sa setGeometry(), setTransform()
+*/
+
+/*!
+ \property QGraphicsWidget::sizePolicy
+ \brief the size policy for the widget
+ \sa sizePolicy(), setSizePolicy(), QWidget::sizePolicy()
+*/
+
+/*!
+ \fn QGraphicsWidget::geometryChanged()
+
+ This signal gets emitted whenever the geometry is changed in setGeometry().
+*/
+
+/*!
+ \property QGraphicsWidget::geometry
+ \brief the geometry of the widget
+
+ Sets the item's geometry to \a rect. The item's position and size are
+ modified as a result of calling this function. The item is first moved,
+ then resized.
+
+ A side effect of calling this function is that the widget will receive
+ a move event and a resize event. Also, if the widget has a layout
+ assigned, the layout will activate.
+
+ \sa geometry(), resize()
+*/
+void QGraphicsWidget::setGeometry(const QRectF &rect)
+{
+ QGraphicsWidgetPrivate *wd = QGraphicsWidget::d_func();
+ QGraphicsLayoutItemPrivate *d = QGraphicsLayoutItem::d_ptr.data();
+ QRectF newGeom;
+ QPointF oldPos = d->geom.topLeft();
+ if (!wd->inSetPos) {
+ setAttribute(Qt::WA_Resized);
+ newGeom = rect;
+ newGeom.setSize(rect.size().expandedTo(effectiveSizeHint(Qt::MinimumSize))
+ .boundedTo(effectiveSizeHint(Qt::MaximumSize)));
+ if (newGeom == d->geom)
+ return;
+
+ // setPos triggers ItemPositionChange, which can adjust position
+ wd->inSetGeometry = 1;
+ setPos(newGeom.topLeft());
+ wd->inSetGeometry = 0;
+ newGeom.moveTopLeft(pos());
+
+ if (newGeom == d->geom)
+ return;
+
+ // Update and prepare to change the geometry (remove from index) if the size has changed.
+ if (wd->scene) {
+ if (rect.topLeft() == d->geom.topLeft()) {
+ prepareGeometryChange();
+ }
+ }
+ }
+
+ // Update the layout item geometry
+ bool moved = oldPos != pos();
+ if (moved) {
+ // Send move event.
+ QGraphicsSceneMoveEvent event;
+ event.setOldPos(oldPos);
+ event.setNewPos(pos());
+ QApplication::sendEvent(this, &event);
+ if (wd->inSetPos) {
+ //set the new pos
+ d->geom.moveTopLeft(pos());
+ emit geometryChanged();
+ return;
+ }
+ }
+ QSizeF oldSize = size();
+ QGraphicsLayoutItem::setGeometry(newGeom);
+ // Send resize event
+ bool resized = newGeom.size() != oldSize;
+ if (resized) {
+ QGraphicsSceneResizeEvent re;
+ re.setOldSize(oldSize);
+ re.setNewSize(newGeom.size());
+ if (oldSize.width() != newGeom.size().width())
+ emit widthChanged();
+ if (oldSize.height() != newGeom.size().height())
+ emit heightChanged();
+ QApplication::sendEvent(this, &re);
+ }
+ emit geometryChanged();
+}
+
+/*!
+ \fn QRectF QGraphicsWidget::rect() const
+
+ Returns the item's local rect as a QRectF. This function is equivalent
+ to QRectF(QPointF(), size()).
+
+ \sa setGeometry(), resize()
+*/
+
+/*!
+ \fn void QGraphicsWidget::setGeometry(qreal x, qreal y, qreal w, qreal h)
+
+ This convenience function is equivalent to calling setGeometry(QRectF(
+ \a x, \a y, \a w, \a h)).
+
+ \sa geometry(), resize()
+*/
+
+/*!
+ \property QGraphicsWidget::minimumSize
+ \brief the minimum size of the widget
+
+ \sa setMinimumSize(), minimumSize(), preferredSize, maximumSize
+*/
+
+/*!
+ \property QGraphicsWidget::preferredSize
+ \brief the preferred size of the widget
+
+ \sa setPreferredSize(), preferredSize(), minimumSize, maximumSize
+*/
+
+/*!
+ \property QGraphicsWidget::maximumSize
+ \brief the maximum size of the widget
+
+ \sa setMaximumSize(), maximumSize(), minimumSize, preferredSize
+*/
+
+/*!
+ Sets the widget's contents margins to \a left, \a top, \a right and \a
+ bottom.
+
+ Contents margins are used by the assigned layout to define the placement
+ of subwidgets and layouts. Margins are particularly useful for widgets
+ that constrain subwidgets to only a section of its own geometry. For
+ example, a group box with a layout will place subwidgets inside its frame,
+ but below the title.
+
+ Changing a widget's contents margins will always trigger an update(), and
+ any assigned layout will be activated automatically. The widget will then
+ receive a \l{QEvent::ContentsRectChange}{ContentsRectChange} event.
+
+ \sa getContentsMargins(), setGeometry()
+*/
+void QGraphicsWidget::setContentsMargins(qreal left, qreal top, qreal right, qreal bottom)
+{
+ Q_D(QGraphicsWidget);
+
+ if (!d->margins && left == 0 && top == 0 && right == 0 && bottom == 0)
+ return;
+ d->ensureMargins();
+ if (left == d->margins[d->Left]
+ && top == d->margins[d->Top]
+ && right == d->margins[d->Right]
+ && bottom == d->margins[d->Bottom])
+ return;
+
+ d->margins[d->Left] = left;
+ d->margins[d->Top] = top;
+ d->margins[d->Right] = right;
+ d->margins[d->Bottom] = bottom;
+
+ if (QGraphicsLayout *l = d->layout)
+ l->invalidate();
+ else
+ updateGeometry();
+
+ QEvent e(QEvent::ContentsRectChange);
+ QApplication::sendEvent(this, &e);
+}
+
+/*!
+ Gets the widget's contents margins. The margins are stored in \a left, \a
+ top, \a right and \a bottom, as pointers to qreals. Each argument can
+ be \e {omitted} by passing 0.
+
+ \sa setContentsMargins()
+*/
+void QGraphicsWidget::getContentsMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const
+{
+ Q_D(const QGraphicsWidget);
+ if (left || top || right || bottom)
+ d->ensureMargins();
+ if (left)
+ *left = d->margins[d->Left];
+ if (top)
+ *top = d->margins[d->Top];
+ if (right)
+ *right = d->margins[d->Right];
+ if (bottom)
+ *bottom = d->margins[d->Bottom];
+}
+
+/*!
+ Sets the widget's window frame margins to \a left, \a top, \a right and
+ \a bottom. The default frame margins are provided by the style, and they
+ depend on the current window flags.
+
+ If you would like to draw your own window decoration, you can set your
+ own frame margins to override the default margins.
+
+ \sa unsetWindowFrameMargins(), getWindowFrameMargins(), windowFrameRect()
+*/
+void QGraphicsWidget::setWindowFrameMargins(qreal left, qreal top, qreal right, qreal bottom)
+{
+ Q_D(QGraphicsWidget);
+
+ if (!d->windowFrameMargins && left == 0 && top == 0 && right == 0 && bottom == 0)
+ return;
+ d->ensureWindowFrameMargins();
+ bool unchanged =
+ d->windowFrameMargins[d->Left] == left
+ && d->windowFrameMargins[d->Top] == top
+ && d->windowFrameMargins[d->Right] == right
+ && d->windowFrameMargins[d->Bottom] == bottom;
+ if (d->setWindowFrameMargins && unchanged)
+ return;
+ if (!unchanged)
+ prepareGeometryChange();
+ d->windowFrameMargins[d->Left] = left;
+ d->windowFrameMargins[d->Top] = top;
+ d->windowFrameMargins[d->Right] = right;
+ d->windowFrameMargins[d->Bottom] = bottom;
+ d->setWindowFrameMargins = true;
+}
+
+/*!
+ Gets the widget's window frame margins. The margins are stored in \a left,
+ \a top, \a right and \a bottom as pointers to qreals. Each argument can
+ be \e {omitted} by passing 0.
+
+ \sa setWindowFrameMargins(), windowFrameRect()
+*/
+void QGraphicsWidget::getWindowFrameMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const
+{
+ Q_D(const QGraphicsWidget);
+ if (left || top || right || bottom)
+ d->ensureWindowFrameMargins();
+ if (left)
+ *left = d->windowFrameMargins[d->Left];
+ if (top)
+ *top = d->windowFrameMargins[d->Top];
+ if (right)
+ *right = d->windowFrameMargins[d->Right];
+ if (bottom)
+ *bottom = d->windowFrameMargins[d->Bottom];
+}
+
+/*!
+ Resets the window frame margins to the default value, provided by the style.
+
+ \sa setWindowFrameMargins(), getWindowFrameMargins(), windowFrameRect()
+*/
+void QGraphicsWidget::unsetWindowFrameMargins()
+{
+ Q_D(QGraphicsWidget);
+ if ((d->windowFlags & Qt::Window) && (d->windowFlags & Qt::WindowType_Mask) != Qt::Popup &&
+ (d->windowFlags & Qt::WindowType_Mask) != Qt::ToolTip && !(d->windowFlags & Qt::FramelessWindowHint)) {
+ QStyleOptionTitleBar bar;
+ d->initStyleOptionTitleBar(&bar);
+ QStyle *style = this->style();
+ qreal margin = style->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth);
+ qreal titleBarHeight = d->titleBarHeight(bar);
+ setWindowFrameMargins(margin, titleBarHeight, margin, margin);
+ } else {
+ setWindowFrameMargins(0, 0, 0, 0);
+ }
+ d->setWindowFrameMargins = false;
+}
+
+/*!
+ Returns the widget's geometry in parent coordinates including any window
+ frame.
+
+ \sa windowFrameRect(), getWindowFrameMargins(), setWindowFrameMargins()
+*/
+QRectF QGraphicsWidget::windowFrameGeometry() const
+{
+ Q_D(const QGraphicsWidget);
+ return d->windowFrameMargins
+ ? geometry().adjusted(-d->windowFrameMargins[d->Left], -d->windowFrameMargins[d->Top],
+ d->windowFrameMargins[d->Right], d->windowFrameMargins[d->Bottom])
+ : geometry();
+}
+
+/*!
+ Returns the widget's local rect including any window frame.
+
+ \sa windowFrameGeometry(), getWindowFrameMargins(), setWindowFrameMargins()
+*/
+QRectF QGraphicsWidget::windowFrameRect() const
+{
+ Q_D(const QGraphicsWidget);
+ return d->windowFrameMargins
+ ? rect().adjusted(-d->windowFrameMargins[d->Left], -d->windowFrameMargins[d->Top],
+ d->windowFrameMargins[d->Right], d->windowFrameMargins[d->Bottom])
+ : rect();
+}
+
+/*!
+ Populates a style option object for this widget based on its current
+ state, and stores the output in \a option. The default implementation
+ populates \a option with the following properties.
+
+ \table
+ \header
+ \o Style Option Property
+ \o Value
+ \row
+ \o state & QStyle::State_Enabled
+ \o Corresponds to QGraphicsItem::isEnabled().
+ \row
+ \o state & QStyle::State_HasFocus
+ \o Corresponds to QGraphicsItem::hasFocus().
+ \row
+ \o state & QStyle::State_MouseOver
+ \o Corresponds to QGraphicsItem::isUnderMouse().
+ \row
+ \o direction
+ \o Corresponds to QGraphicsWidget::layoutDirection().
+ \row
+ \o rect
+ \o Corresponds to QGraphicsWidget::rect().toRect().
+ \row
+ \o palette
+ \o Corresponds to QGraphicsWidget::palette().
+ \row
+ \o fontMetrics
+ \o Corresponds to QFontMetrics(QGraphicsWidget::font()).
+ \endtable
+
+ Subclasses of QGraphicsWidget should call the base implementation, and
+ then test the type of \a option using qstyleoption_cast<>() or test
+ QStyleOption::Type before storing widget-specific options.
+
+ For example:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp 0
+
+ \sa QStyleOption::initFrom()
+*/
+void QGraphicsWidget::initStyleOption(QStyleOption *option) const
+{
+ Q_ASSERT(option);
+
+ option->state = QStyle::State_None;
+ if (isEnabled())
+ option->state |= QStyle::State_Enabled;
+ if (hasFocus())
+ option->state |= QStyle::State_HasFocus;
+ // if (window->testAttribute(Qt::WA_KeyboardFocusChange)) // ### Window
+ // option->state |= QStyle::State_KeyboardFocusChange;
+ if (isUnderMouse())
+ option->state |= QStyle::State_MouseOver;
+ if (QGraphicsWidget *w = window()) {
+ if (w->isActiveWindow())
+ option->state |= QStyle::State_Active;
+ }
+ if (isWindow())
+ option->state |= QStyle::State_Window;
+ /*
+ ###
+#ifdef Q_WS_MAC
+ extern bool qt_mac_can_clickThrough(const QGraphicsWidget *w); //qwidget_mac.cpp
+ if (!(option->state & QStyle::State_Active) && !qt_mac_can_clickThrough(widget))
+ option->state &= ~QStyle::State_Enabled;
+
+ switch (QMacStyle::widgetSizePolicy(widget)) {
+ case QMacStyle::SizeSmall:
+ option->state |= QStyle::State_Small;
+ break;
+ case QMacStyle::SizeMini:
+ option->state |= QStyle::State_Mini;
+ break;
+ default:
+ ;
+ }
+#endif
+#ifdef QT_KEYPAD_NAVIGATION
+ if (widget->hasEditFocus())
+ state |= QStyle::State_HasEditFocus;
+#endif
+ */
+ option->direction = layoutDirection();
+ option->rect = rect().toRect(); // ### truncation!
+ option->palette = palette();
+ if (!isEnabled()) {
+ option->palette.setCurrentColorGroup(QPalette::Disabled);
+ } else if (isActiveWindow()) {
+ option->palette.setCurrentColorGroup(QPalette::Active);
+ } else {
+ option->palette.setCurrentColorGroup(QPalette::Inactive);
+ }
+ option->fontMetrics = QFontMetrics(font());
+}
+
+/*!
+ \reimp
+*/
+QSizeF QGraphicsWidget::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
+{
+ Q_D(const QGraphicsWidget);
+ QSizeF sh;
+ if (d->layout) {
+ QSizeF marginSize(0,0);
+ if (d->margins) {
+ marginSize = QSizeF(d->margins[d->Left] + d->margins[d->Right],
+ d->margins[d->Top] + d->margins[d->Bottom]);
+ }
+ sh = d->layout->effectiveSizeHint(which, constraint - marginSize);
+ sh += marginSize;
+ } else {
+ switch (which) {
+ case Qt::MinimumSize:
+ sh = QSizeF(0, 0);
+ break;
+ case Qt::PreferredSize:
+ sh = QSizeF(50, 50); //rather arbitrary
+ break;
+ case Qt::MaximumSize:
+ sh = QSizeF(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
+ break;
+ default:
+ qWarning("QGraphicsWidget::sizeHint(): Don't know how to handle the value of 'which'");
+ break;
+ }
+ }
+ return sh;
+}
+
+/*!
+ \property QGraphicsWidget::layout
+ \brief The layout of the widget
+
+ Any existing layout manager is deleted before the new layout is assigned. If
+ \a layout is 0, the widget is left without a layout. Existing subwidgets'
+ geometries will remain unaffected.
+
+ QGraphicsWidget takes ownership of \a layout.
+
+ All widgets that are currently managed by \a layout or all of its
+ sublayouts, are automatically reparented to this item. The layout is then
+ invalidated, and the child widget geometries are adjusted according to
+ this item's geometry() and contentsMargins(). Children who are not
+ explicitly managed by \a layout remain unaffected by the layout after
+ it has been assigned to this widget.
+
+ If no layout is currently managing this widget, layout() will return 0.
+
+*/
+
+/*!
+ \fn void QGraphicsWidget::layoutChanged()
+ This signal gets emitted whenever the layout of the item changes
+ \internal
+*/
+
+/*!
+ Returns this widget's layout, or 0 if no layout is currently managing this
+ widget.
+
+ \sa setLayout()
+*/
+QGraphicsLayout *QGraphicsWidget::layout() const
+{
+ Q_D(const QGraphicsWidget);
+ return d->layout;
+}
+
+/*!
+ \fn void QGraphicsWidget::setLayout(QGraphicsLayout *layout)
+
+ Sets the layout for this widget to \a layout. Any existing layout manager
+ is deleted before the new layout is assigned. If \a layout is 0, the
+ widget is left without a layout. Existing subwidgets' geometries will
+ remain unaffected.
+
+ All widgets that are currently managed by \a layout or all of its
+ sublayouts, are automatically reparented to this item. The layout is then
+ invalidated, and the child widget geometries are adjusted according to
+ this item's geometry() and contentsMargins(). Children who are not
+ explicitly managed by \a layout remain unaffected by the layout after
+ it has been assigned to this widget.
+
+ QGraphicsWidget takes ownership of \a layout.
+
+ \sa layout(), QGraphicsLinearLayout::addItem(), QGraphicsLayout::invalidate()
+*/
+void QGraphicsWidget::setLayout(QGraphicsLayout *l)
+{
+ Q_D(QGraphicsWidget);
+ if (d->layout == l)
+ return;
+ d->setLayout_helper(l);
+ if (!l)
+ return;
+
+ // Prevent assigning a layout that is already assigned to another widget.
+ QGraphicsLayoutItem *oldParent = l->parentLayoutItem();
+ if (oldParent && oldParent != this) {
+ qWarning("QGraphicsWidget::setLayout: Attempting to set a layout on %s"
+ " \"%s\", when the layout already has a parent",
+ metaObject()->className(), qPrintable(objectName()));
+ return;
+ }
+
+ // Install and activate the layout.
+ l->setParentLayoutItem(this);
+ l->d_func()->reparentChildItems(this);
+ l->invalidate();
+ emit layoutChanged();
+}
+
+/*!
+ Adjusts the size of the widget to its effective preferred size hint.
+
+ This function is called implicitly when the item is shown for the first
+ time.
+
+ \sa effectiveSizeHint(), Qt::MinimumSize
+*/
+void QGraphicsWidget::adjustSize()
+{
+ QSizeF sz = effectiveSizeHint(Qt::PreferredSize);
+ // What if sz is not valid?!
+ if (sz.isValid())
+ resize(sz);
+}
+
+/*!
+ \property QGraphicsWidget::layoutDirection
+ \brief the layout direction for this widget.
+
+ This property modifies this widget's and all of its descendants'
+ Qt::WA_RightToLeft attribute. It also sets this widget's
+ Qt::WA_SetLayoutDirection attribute.
+
+ The widget's layout direction determines the order in which the layout
+ manager horizontally arranges subwidgets of this widget. The default
+ value depends on the language and locale of the application, and is
+ typically in the same direction as words are read and written. With
+ Qt::LeftToRight, the layout starts placing subwidgets from the left
+ side of this widget towards the right. Qt::RightToLeft does the opposite -
+ the layout will place widgets starting from the right edge moving towards
+ the left.
+
+ Subwidgets inherit their layout direction from the parent. Top-level
+ widget items inherit their layout direction from
+ QGraphicsScene::layoutDirection. If you change a widget's layout direction
+ by calling setLayoutDirection(), the widget will send itself a
+ \l{QEvent::LayoutDirectionChange}{LayoutDirectionChange} event, and then
+ propagate the new layout direction to all its descendants.
+
+ \sa QWidget::layoutDirection, QApplication::layoutDirection
+*/
+Qt::LayoutDirection QGraphicsWidget::layoutDirection() const
+{
+ return testAttribute(Qt::WA_RightToLeft) ? Qt::RightToLeft : Qt::LeftToRight;
+}
+void QGraphicsWidget::setLayoutDirection(Qt::LayoutDirection direction)
+{
+ Q_D(QGraphicsWidget);
+ setAttribute(Qt::WA_SetLayoutDirection, true);
+ d->setLayoutDirection_helper(direction);
+}
+void QGraphicsWidget::unsetLayoutDirection()
+{
+ Q_D(QGraphicsWidget);
+ setAttribute(Qt::WA_SetLayoutDirection, false);
+ d->resolveLayoutDirection();
+}
+
+/*!
+ Returns a pointer to the widget's style. If this widget does not have any
+ explicitly assigned style, the scene's style is returned instead. In turn,
+ if the scene does not have any assigned style, this function returns
+ QApplication::style().
+
+ \sa setStyle()
+*/
+QStyle *QGraphicsWidget::style() const
+{
+ if (QStyle *style = widgetStyles()->styleForWidget(this))
+ return style;
+ // ### This is not thread-safe. QApplication::style() is not thread-safe.
+ return scene() ? scene()->style() : QApplication::style();
+}
+
+/*!
+ Sets the widget's style to \a style. QGraphicsWidget does \e not take
+ ownership of \a style.
+
+ If no style is assigned, or \a style is 0, the widget will use
+ QGraphicsScene::style() (if this has been set). Otherwise the widget will
+ use QApplication::style().
+
+ This function sets the Qt::WA_SetStyle attribute if \a style is not 0;
+ otherwise it clears the attribute.
+
+ \sa style()
+*/
+void QGraphicsWidget::setStyle(QStyle *style)
+{
+ setAttribute(Qt::WA_SetStyle, style != 0);
+ widgetStyles()->setStyleForWidget(this, style);
+
+ // Deliver StyleChange to the widget itself (doesn't propagate).
+ QEvent event(QEvent::StyleChange);
+ QApplication::sendEvent(this, &event);
+}
+
+/*!
+ \property QGraphicsWidget::font
+ \brief the widgets' font
+
+ This property provides the widget's font.
+
+ QFont consists of font properties that have been explicitly defined and
+ properties implicitly inherited from the widget's parent. Hence, font()
+ can return a different font compared to the one set with setFont().
+ This scheme allows you to define single entries in a font without
+ affecting the font's inherited entries.
+
+ When a widget's font changes, it resolves its entries against its
+ parent widget. If the widget does not have a parent widget, it resolves
+ its entries against the scene. The widget then sends itself a
+ \l{QEvent::FontChange}{FontChange} event and notifies all its
+ descendants so that they can resolve their fonts as well.
+
+ By default, this property contains the application's default font.
+
+ \sa QApplication::font(), QGraphicsScene::font, QFont::resolve()
+*/
+QFont QGraphicsWidget::font() const
+{
+ Q_D(const QGraphicsWidget);
+ QFont fnt = d->font;
+ fnt.resolve(fnt.resolve() | d->inheritedFontResolveMask);
+ return fnt;
+}
+void QGraphicsWidget::setFont(const QFont &font)
+{
+ Q_D(QGraphicsWidget);
+ setAttribute(Qt::WA_SetFont, font.resolve() != 0);
+
+ QFont naturalFont = d->naturalWidgetFont();
+ QFont resolvedFont = font.resolve(naturalFont);
+ d->setFont_helper(resolvedFont);
+}
+
+/*!
+ \property QGraphicsWidget::palette
+ \brief the widget's palette
+
+ This property provides the widget's palette. The palette provides colors
+ and brushes for color groups (e.g., QPalette::Button) and states (e.g.,
+ QPalette::Inactive), loosely defining the general look of the widget and
+ its children.
+
+ QPalette consists of color groups that have been explicitly defined, and
+ groups that are implicitly inherited from the widget's parent. Because of
+ this, palette() can return a different palette than what has been set with
+ setPalette(). This scheme allows you to define single entries in a palette
+ without affecting the palette's inherited entries.
+
+ When a widget's palette changes, it resolves its entries against its
+ parent widget, or if it doesn't have a parent widget, it resolves against
+ the scene. It then sends itself a \l{QEvent::PaletteChange}{PaletteChange}
+ event, and notifies all its descendants so they can resolve their palettes
+ as well.
+
+ By default, this property contains the application's default palette.
+
+ \sa QApplication::palette(), QGraphicsScene::palette, QPalette::resolve()
+*/
+QPalette QGraphicsWidget::palette() const
+{
+ Q_D(const QGraphicsWidget);
+ return d->palette;
+}
+void QGraphicsWidget::setPalette(const QPalette &palette)
+{
+ Q_D(QGraphicsWidget);
+ setAttribute(Qt::WA_SetPalette, palette.resolve() != 0);
+
+ QPalette naturalPalette = d->naturalWidgetPalette();
+ QPalette resolvedPalette = palette.resolve(naturalPalette);
+ d->setPalette_helper(resolvedPalette);
+}
+
+/*!
+ \property QGraphicsWidget::autoFillBackground
+ \brief whether the widget background is filled automatically
+ \since 4.7
+
+ If enabled, this property will cause Qt to fill the background of the
+ widget before invoking the paint() method. The color used is defined by the
+ QPalette::Window color role from the widget's \l{QPalette}{palette}.
+
+ In addition, Windows are always filled with QPalette::Window, unless the
+ WA_OpaquePaintEvent or WA_NoSystemBackground attributes are set.
+
+ By default, this property is false.
+
+ \sa Qt::WA_OpaquePaintEvent, Qt::WA_NoSystemBackground,
+*/
+bool QGraphicsWidget::autoFillBackground() const
+{
+ Q_D(const QGraphicsWidget);
+ return d->autoFillBackground;
+}
+void QGraphicsWidget::setAutoFillBackground(bool enabled)
+{
+ Q_D(QGraphicsWidget);
+ if (d->autoFillBackground != enabled) {
+ d->autoFillBackground = enabled;
+ update();
+ }
+}
+
+/*!
+ If this widget is currently managed by a layout, this function notifies
+ the layout that the widget's size hints have changed and the layout
+ may need to resize and reposition the widget accordingly.
+
+ Call this function if the widget's sizeHint() has changed.
+
+ \sa QGraphicsLayout::invalidate()
+*/
+void QGraphicsWidget::updateGeometry()
+{
+ QGraphicsLayoutItem::updateGeometry();
+ QGraphicsLayoutItem *parentItem = parentLayoutItem();
+
+ if (parentItem && parentItem->isLayout()) {
+ parentItem->updateGeometry();
+ } else {
+ if (parentItem) {
+ QGraphicsWidget *parentWid = parentWidget(); //###
+ if (parentWid->isVisible())
+ QApplication::postEvent(parentWid, new QEvent(QEvent::LayoutRequest));
+ }
+ bool wasResized = testAttribute(Qt::WA_Resized);
+ resize(size()); // this will restrict the size
+ setAttribute(Qt::WA_Resized, wasResized);
+ }
+}
+
+/*!
+ \reimp
+
+ QGraphicsWidget uses the base implementation of this function to catch and
+ deliver events related to state changes in the item. Because of this, it is
+ very important that subclasses call the base implementation.
+
+ \a change specifies the type of change, and \a value is the new value.
+
+ For example, QGraphicsWidget uses ItemVisibleChange to deliver
+ \l{QEvent::Show} {Show} and \l{QEvent::Hide}{Hide} events,
+ ItemPositionHasChanged to deliver \l{QEvent::Move}{Move} events,
+ and ItemParentChange both to deliver \l{QEvent::ParentChange}
+ {ParentChange} events, and for managing the focus chain.
+
+ QGraphicsWidget enables the ItemSendsGeometryChanges flag by default in
+ order to track position changes.
+
+ \sa QGraphicsItem::itemChange()
+*/
+QVariant QGraphicsWidget::itemChange(GraphicsItemChange change, const QVariant &value)
+{
+ Q_D(QGraphicsWidget);
+ switch (change) {
+ case ItemEnabledHasChanged: {
+ // Send EnabledChange after the enabled state has changed.
+ QEvent event(QEvent::EnabledChange);
+ QApplication::sendEvent(this, &event);
+ break;
+ }
+ case ItemVisibleChange:
+ if (value.toBool()) {
+ // Send Show event before the item has been shown.
+ QShowEvent event;
+ QApplication::sendEvent(this, &event);
+ bool resized = testAttribute(Qt::WA_Resized);
+ if (!resized) {
+ adjustSize();
+ setAttribute(Qt::WA_Resized, false);
+ }
+ }
+ break;
+ case ItemVisibleHasChanged:
+ if (!value.toBool()) {
+ // Send Hide event after the item has been hidden.
+ QHideEvent event;
+ QApplication::sendEvent(this, &event);
+ }
+ break;
+ case ItemPositionHasChanged:
+ d->setGeometryFromSetPos();
+ break;
+ case ItemParentChange: {
+ // Deliver ParentAboutToChange.
+ QEvent event(QEvent::ParentAboutToChange);
+ QApplication::sendEvent(this, &event);
+ break;
+ }
+ case ItemParentHasChanged: {
+ // Deliver ParentChange.
+ QEvent event(QEvent::ParentChange);
+ QApplication::sendEvent(this, &event);
+ break;
+ }
+ case ItemCursorHasChanged: {
+ // Deliver CursorChange.
+ QEvent event(QEvent::CursorChange);
+ QApplication::sendEvent(this, &event);
+ break;
+ }
+ case ItemToolTipHasChanged: {
+ // Deliver ToolTipChange.
+ QEvent event(QEvent::ToolTipChange);
+ QApplication::sendEvent(this, &event);
+ break;
+ }
+ default:
+ break;
+ }
+ return QGraphicsItem::itemChange(change, value);
+}
+
+/*!
+ \internal
+
+ This virtual function is used to notify changes to any property (both
+ dynamic properties, and registered with Q_PROPERTY) in the
+ widget. Depending on the property itself, the notification can be
+ delivered before or after the value has changed.
+
+ \a propertyName is the name of the property (e.g., "size" or "font"), and
+ \a value is the (proposed) new value of the property. The function returns
+ the new value, which may be different from \a value if the notification
+ supports adjusting the property value. The base implementation simply
+ returns \a value for any \a propertyName.
+
+ QGraphicsWidget delivers notifications for the following properties:
+
+ \table \o propertyName \o Property
+ \row \o layoutDirection \o QGraphicsWidget::layoutDirection
+ \row \o size \o QGraphicsWidget::size
+ \row \o font \o QGraphicsWidget::font
+ \row \o palette \o QGraphicsWidget::palette
+ \endtable
+
+ \sa itemChange()
+*/
+QVariant QGraphicsWidget::propertyChange(const QString &propertyName, const QVariant &value)
+{
+ Q_UNUSED(propertyName);
+ return value;
+}
+
+/*!
+ QGraphicsWidget's implementation of sceneEvent() simply passes \a event to
+ QGraphicsWidget::event(). You can handle all events for your widget in
+ event() or in any of the convenience functions; you should not have to
+ reimplement this function in a subclass of QGraphicsWidget.
+
+ \sa QGraphicsItem::sceneEvent()
+*/
+bool QGraphicsWidget::sceneEvent(QEvent *event)
+{
+ return QGraphicsItem::sceneEvent(event);
+}
+
+/*!
+ This event handler, for \a event, receives events for the window frame if
+ this widget is a window. Its base implementation provides support for
+ default window frame interaction such as moving, resizing, etc.
+
+ You can reimplement this handler in a subclass of QGraphicsWidget to
+ provide your own custom window frame interaction support.
+
+ Returns true if \a event has been recognized and processed; otherwise,
+ returns false.
+
+ \sa event()
+*/
+bool QGraphicsWidget::windowFrameEvent(QEvent *event)
+{
+ Q_D(QGraphicsWidget);
+ switch (event->type()) {
+ case QEvent::GraphicsSceneMousePress:
+ d->windowFrameMousePressEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
+ break;
+ case QEvent::GraphicsSceneMouseMove:
+ d->ensureWindowData();
+ if (d->windowData->grabbedSection != Qt::NoSection) {
+ d->windowFrameMouseMoveEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
+ event->accept();
+ }
+ break;
+ case QEvent::GraphicsSceneMouseRelease:
+ d->windowFrameMouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
+ break;
+ case QEvent::GraphicsSceneHoverMove:
+ d->windowFrameHoverMoveEvent(static_cast<QGraphicsSceneHoverEvent *>(event));
+ break;
+ case QEvent::GraphicsSceneHoverLeave:
+ d->windowFrameHoverLeaveEvent(static_cast<QGraphicsSceneHoverEvent *>(event));
+ break;
+ default:
+ break;
+ }
+ return event->isAccepted();
+}
+
+/*!
+ \since 4.4
+
+ Returns the window frame section at position \a pos, or
+ Qt::NoSection if there is no window frame section at this
+ position.
+
+ This function is used in QGraphicsWidget's base implementation for window
+ frame interaction.
+
+ You can reimplement this function if you want to customize how a window
+ can be interactively moved or resized. For instance, if you only want to
+ allow a window to be resized by the bottom right corner, you can
+ reimplement this function to return Qt::NoSection for all sections except
+ Qt::BottomRightSection.
+
+ \sa windowFrameEvent(), paintWindowFrame(), windowFrameGeometry()
+*/
+Qt::WindowFrameSection QGraphicsWidget::windowFrameSectionAt(const QPointF &pos) const
+{
+ Q_D(const QGraphicsWidget);
+
+ const QRectF r = windowFrameRect();
+ if (!r.contains(pos))
+ return Qt::NoSection;
+
+ const qreal left = r.left();
+ const qreal top = r.top();
+ const qreal right = r.right();
+ const qreal bottom = r.bottom();
+ const qreal x = pos.x();
+ const qreal y = pos.y();
+
+ const qreal cornerMargin = 20;
+ //### Not sure of this one, it should be the same value for all edges.
+ const qreal windowFrameWidth = d->windowFrameMargins
+ ? d->windowFrameMargins[d->Left] : 0;
+
+ Qt::WindowFrameSection s = Qt::NoSection;
+ if (x <= left + cornerMargin) {
+ if (y <= top + windowFrameWidth || (x <= left + windowFrameWidth && y <= top + cornerMargin)) {
+ s = Qt::TopLeftSection;
+ } else if (y >= bottom - windowFrameWidth || (x <= left + windowFrameWidth && y >= bottom - windowFrameWidth)) {
+ s = Qt::BottomLeftSection;
+ } else if (x <= left + windowFrameWidth) {
+ s = Qt::LeftSection;
+ }
+ } else if (x >= right - cornerMargin) {
+ if (y <= top + windowFrameWidth || (x >= right - windowFrameWidth && y <= top + cornerMargin)) {
+ s = Qt::TopRightSection;
+ } else if (y >= bottom - windowFrameWidth || (x >= right - windowFrameWidth && y >= bottom - windowFrameWidth)) {
+ s = Qt::BottomRightSection;
+ } else if (x >= right - windowFrameWidth) {
+ s = Qt::RightSection;
+ }
+ } else if (y <= top + windowFrameWidth) {
+ s = Qt::TopSection;
+ } else if (y >= bottom - windowFrameWidth) {
+ s = Qt::BottomSection;
+ }
+ if (s == Qt::NoSection) {
+ QRectF r1 = r;
+ r1.setHeight(d->windowFrameMargins
+ ? d->windowFrameMargins[d->Top] : 0);
+ if (r1.contains(pos))
+ s = Qt::TitleBarArea;
+ }
+ return s;
+}
+
+/*!
+ \reimp
+
+ Handles the \a event. QGraphicsWidget handles the following
+ events:
+
+ \table \o Event \o Usage
+ \row \o Polish
+ \o Delivered to the widget some time after it has been
+ shown.
+ \row \o GraphicsSceneMove
+ \o Delivered to the widget after its local position has
+ changed.
+ \row \o GraphicsSceneResize
+ \o Delivered to the widget after its size has changed.
+ \row \o Show
+ \o Delivered to the widget before it has been shown.
+ \row \o Hide
+ \o Delivered to the widget after it has been hidden.
+ \row \o PaletteChange
+ \o Delivered to the widget after its palette has changed.
+ \row \o FontChange
+ \o Delivered to the widget after its font has changed.
+ \row \o EnabledChange
+ \o Delivered to the widget after its enabled state has
+ changed.
+ \row \o StyleChange
+ \o Delivered to the widget after its style has changed.
+ \row \o LayoutDirectionChange
+ \o Delivered to the widget after its layout direction has
+ changed.
+ \row \o ContentsRectChange
+ \o Delivered to the widget after its contents margins/
+ contents rect has changed.
+ \endtable
+*/
+bool QGraphicsWidget::event(QEvent *event)
+{
+ Q_D(QGraphicsWidget);
+ // Forward the event to the layout first.
+ if (d->layout)
+ d->layout->widgetEvent(event);
+
+ // Handle the event itself.
+ switch (event->type()) {
+ case QEvent::GraphicsSceneMove:
+ moveEvent(static_cast<QGraphicsSceneMoveEvent *>(event));
+ break;
+ case QEvent::GraphicsSceneResize:
+ resizeEvent(static_cast<QGraphicsSceneResizeEvent *>(event));
+ break;
+ case QEvent::Show:
+ showEvent(static_cast<QShowEvent *>(event));
+ break;
+ case QEvent::Hide:
+ hideEvent(static_cast<QHideEvent *>(event));
+ break;
+ case QEvent::Polish:
+ polishEvent();
+ d->polished = true;
+ if (!d->font.isCopyOf(QApplication::font()))
+ d->updateFont(d->font);
+ break;
+ case QEvent::WindowActivate:
+ case QEvent::WindowDeactivate:
+ update();
+ break;
+ // Taken from QWidget::event
+ case QEvent::ActivationChange:
+ case QEvent::EnabledChange:
+ case QEvent::FontChange:
+ case QEvent::StyleChange:
+ case QEvent::PaletteChange:
+ case QEvent::ParentChange:
+ case QEvent::ContentsRectChange:
+ case QEvent::LayoutDirectionChange:
+ changeEvent(event);
+ break;
+ case QEvent::Close:
+ closeEvent((QCloseEvent *)event);
+ break;
+ case QEvent::GrabMouse:
+ grabMouseEvent(event);
+ break;
+ case QEvent::UngrabMouse:
+ ungrabMouseEvent(event);
+ break;
+ case QEvent::GrabKeyboard:
+ grabKeyboardEvent(event);
+ break;
+ case QEvent::UngrabKeyboard:
+ ungrabKeyboardEvent(event);
+ break;
+ case QEvent::GraphicsSceneMousePress:
+ if (d->hasDecoration() && windowFrameEvent(event))
+ return true;
+ case QEvent::GraphicsSceneMouseMove:
+ case QEvent::GraphicsSceneMouseRelease:
+ case QEvent::GraphicsSceneMouseDoubleClick:
+ d->ensureWindowData();
+ if (d->hasDecoration() && d->windowData->grabbedSection != Qt::NoSection)
+ return windowFrameEvent(event);
+ break;
+ case QEvent::GraphicsSceneHoverEnter:
+ case QEvent::GraphicsSceneHoverMove:
+ case QEvent::GraphicsSceneHoverLeave:
+ if (d->hasDecoration()) {
+ windowFrameEvent(event);
+ // Filter out hover events if they were sent to us only because of the
+ // decoration (special case in QGraphicsScenePrivate::dispatchHoverEvent).
+ if (!acceptsHoverEvents())
+ return true;
+ }
+ break;
+ default:
+ break;
+ }
+ return QObject::event(event);
+}
+
+/*!
+ This event handler can be reimplemented to handle state changes.
+
+ The state being changed in this event can be retrieved through \a event.
+
+ Change events include: QEvent::ActivationChange, QEvent::EnabledChange,
+ QEvent::FontChange, QEvent::StyleChange, QEvent::PaletteChange,
+ QEvent::ParentChange, QEvent::LayoutDirectionChange, and
+ QEvent::ContentsRectChange.
+*/
+void QGraphicsWidget::changeEvent(QEvent *event)
+{
+ Q_D(QGraphicsWidget);
+ switch (event->type()) {
+ case QEvent::StyleChange:
+ // ### Don't unset if the margins are explicitly set.
+ unsetWindowFrameMargins();
+ if (d->layout)
+ d->layout->invalidate();
+ case QEvent::FontChange:
+ update();
+ updateGeometry();
+ break;
+ case QEvent::PaletteChange:
+ update();
+ break;
+ case QEvent::ParentChange:
+ d->resolveFont(d->inheritedFontResolveMask);
+ d->resolvePalette(d->inheritedPaletteResolveMask);
+ break;
+ default:
+ break;
+ }
+}
+
+/*!
+ This event handler, for \a event, can be reimplemented in a subclass to
+ receive widget close events. The default implementation accepts the
+ event.
+
+ \sa close(), QCloseEvent
+*/
+void QGraphicsWidget::closeEvent(QCloseEvent *event)
+{
+ event->accept();
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsWidget::focusInEvent(QFocusEvent *event)
+{
+ Q_UNUSED(event);
+ if (focusPolicy() != Qt::NoFocus)
+ update();
+}
+
+/*!
+ Finds a new widget to give the keyboard focus to, as appropriate for Tab
+ and Shift+Tab, and returns true if it can find a new widget; returns false
+ otherwise. If \a next is true, this function searches forward; if \a next
+ is false, it searches backward.
+
+ Sometimes, you will want to reimplement this function to provide special
+ focus handling for your widget and its subwidgets. For example, a web
+ browser might reimplement it to move its current active link forward or
+ backward, and call the base implementation only when it reaches the last
+ or first link on the page.
+
+ Child widgets call focusNextPrevChild() on their parent widgets, but only
+ the window that contains the child widgets decides where to redirect
+ focus. By reimplementing this function for an object, you gain control of
+ focus traversal for all child widgets.
+
+ \sa focusPolicy()
+*/
+bool QGraphicsWidget::focusNextPrevChild(bool next)
+{
+ Q_D(QGraphicsWidget);
+ // Let the parent's focusNextPrevChild implementation decide what to do.
+ QGraphicsWidget *parent = 0;
+ if (!isWindow() && (parent = parentWidget()))
+ return parent->focusNextPrevChild(next);
+ if (!d->scene)
+ return false;
+ if (d->scene->focusNextPrevChild(next))
+ return true;
+ if (isWindow()) {
+ setFocus(next ? Qt::TabFocusReason : Qt::BacktabFocusReason);
+ if (hasFocus())
+ return true;
+ }
+ return false;
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsWidget::focusOutEvent(QFocusEvent *event)
+{
+ Q_UNUSED(event);
+ if (focusPolicy() != Qt::NoFocus)
+ update();
+}
+
+/*!
+ This event handler, for \l{QEvent::Hide}{Hide} events, is delivered after
+ the widget has been hidden, for example, setVisible(false) has been called
+ for the widget or one of its ancestors when the widget was previously
+ shown.
+
+ You can reimplement this event handler to detect when your widget is
+ hidden. Calling QEvent::accept() or QEvent::ignore() on \a event has no
+ effect.
+
+ \sa showEvent(), QWidget::hideEvent(), ItemVisibleChange
+*/
+void QGraphicsWidget::hideEvent(QHideEvent *event)
+{
+ ///### focusNextPrevChild(true), don't lose focus when the focus widget
+ // is hidden.
+ Q_UNUSED(event);
+}
+
+/*!
+ This event handler, for \l{QEvent::GraphicsSceneMove}{GraphicsSceneMove}
+ events, is delivered after the widget has moved (e.g., its local position
+ has changed).
+
+ This event is only delivered when the item is moved locally. Calling
+ setTransform() or moving any of the item's ancestors does not affect the
+ item's local position.
+
+ You can reimplement this event handler to detect when your widget has
+ moved. Calling QEvent::accept() or QEvent::ignore() on \a event has no
+ effect.
+
+ \sa ItemPositionChange, ItemPositionHasChanged
+*/
+void QGraphicsWidget::moveEvent(QGraphicsSceneMoveEvent *event)
+{
+ // ### Last position is always == current position
+ Q_UNUSED(event);
+}
+
+/*!
+ This event is delivered to the item by the scene at some point after it
+ has been constructed, but before it is shown or otherwise accessed through
+ the scene. You can use this event handler to do last-minute initializations
+ of the widget which require the item to be fully constructed.
+
+ The base implementation does nothing.
+*/
+void QGraphicsWidget::polishEvent()
+{
+}
+
+/*!
+ This event handler, for
+ \l{QEvent::GraphicsSceneResize}{GraphicsSceneResize} events, is
+ delivered after the widget has been resized (i.e., its local size has
+ changed). \a event contains both the old and the new size.
+
+ This event is only delivered when the widget is resized locally; calling
+ setTransform() on the widget or any of its ancestors or view, does not
+ affect the widget's local size.
+
+ You can reimplement this event handler to detect when your widget has been
+ resized. Calling QEvent::accept() or QEvent::ignore() on \a event has no
+ effect.
+
+ \sa geometry(), setGeometry()
+*/
+void QGraphicsWidget::resizeEvent(QGraphicsSceneResizeEvent *event)
+{
+ Q_UNUSED(event);
+}
+
+/*!
+ This event handler, for \l{QEvent::Show}{Show} events, is delivered before
+ the widget has been shown, for example, setVisible(true) has been called
+ for the widget or one of its ancestors when the widget was previously
+ hidden.
+
+ You can reimplement this event handler to detect when your widget is
+ shown. Calling QEvent::accept() or QEvent::ignore() on \a event has no
+ effect.
+
+ \sa hideEvent(), QWidget::showEvent(), ItemVisibleChange
+*/
+void QGraphicsWidget::showEvent(QShowEvent *event)
+{
+ Q_UNUSED(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsWidget::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
+{
+ Q_UNUSED(event);
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsWidget::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
+{
+ Q_UNUSED(event);
+}
+
+/*!
+ This event handler, for \a event, can be reimplemented in a subclass to
+ receive notifications for Qt::GrabMouse events.
+
+ \sa grabMouse(), grabKeyboard()
+*/
+void QGraphicsWidget::grabMouseEvent(QEvent *event)
+{
+ Q_UNUSED(event);
+}
+
+/*!
+ This event handler, for \a event, can be reimplemented in a subclass to
+ receive notifications for Qt::UngrabMouse events.
+
+ \sa ungrabMouse(), ungrabKeyboard()
+*/
+void QGraphicsWidget::ungrabMouseEvent(QEvent *event)
+{
+ Q_UNUSED(event);
+}
+
+/*!
+ This event handler, for \a event, can be reimplemented in a subclass to
+ receive notifications for Qt::GrabKeyboard events.
+
+ \sa grabKeyboard(), grabMouse()
+*/
+void QGraphicsWidget::grabKeyboardEvent(QEvent *event)
+{
+ Q_UNUSED(event);
+}
+
+/*!
+ This event handler, for \a event, can be reimplemented in a subclass to
+ receive notifications for Qt::UngrabKeyboard events.
+
+ \sa ungrabKeyboard(), ungrabMouse()
+*/
+void QGraphicsWidget::ungrabKeyboardEvent(QEvent *event)
+{
+ Q_UNUSED(event);
+}
+
+/*!
+ Returns the widgets window type.
+
+ \sa windowFlags(), isWindow(), isPanel()
+*/
+Qt::WindowType QGraphicsWidget::windowType() const
+{
+ return Qt::WindowType(int(windowFlags()) & Qt::WindowType_Mask);
+}
+
+/*!
+ \property QGraphicsWidget::windowFlags
+ \brief the widget's window flags
+
+ Window flags are a combination of a window type (e.g., Qt::Dialog) and
+ several flags giving hints on the behavior of the window. The behavior
+ is platform-dependent.
+
+ By default, this property contains no window flags.
+
+ Windows are panels. If you set the Qt::Window flag, the ItemIsPanel flag
+ will be set automatically. If you clear the Qt::Window flag, the
+ ItemIsPanel flag is also cleared. Note that the ItemIsPanel flag can be
+ set independently of Qt::Window.
+
+ \sa isWindow(), isPanel()
+*/
+Qt::WindowFlags QGraphicsWidget::windowFlags() const
+{
+ Q_D(const QGraphicsWidget);
+ return d->windowFlags;
+}
+void QGraphicsWidget::setWindowFlags(Qt::WindowFlags wFlags)
+{
+ Q_D(QGraphicsWidget);
+ if (d->windowFlags == wFlags)
+ return;
+ bool wasPopup = (d->windowFlags & Qt::WindowType_Mask) == Qt::Popup;
+
+ d->adjustWindowFlags(&wFlags);
+ d->windowFlags = wFlags;
+ if (!d->setWindowFrameMargins)
+ unsetWindowFrameMargins();
+
+ setFlag(ItemIsPanel, d->windowFlags & Qt::Window);
+
+ bool isPopup = (d->windowFlags & Qt::WindowType_Mask) == Qt::Popup;
+ if (d->scene && isVisible() && wasPopup != isPopup) {
+ // Popup state changed; update implicit mouse grab.
+ if (!isPopup)
+ d->scene->d_func()->removePopup(this);
+ else
+ d->scene->d_func()->addPopup(this);
+ }
+
+ if (d->scene && d->scene->d_func()->allItemsIgnoreHoverEvents && d->hasDecoration()) {
+ d->scene->d_func()->allItemsIgnoreHoverEvents = false;
+ d->scene->d_func()->enableMouseTrackingOnViews();
+ }
+}
+
+/*!
+ Returns true if this widget's window is in the active window, or if the
+ widget does not have a window but is in an active scene (i.e., a scene
+ that currently has focus).
+
+ The active window is the window that either contains a child widget that
+ currently has input focus, or that itself has input focus.
+
+ \sa QGraphicsScene::activeWindow(), QGraphicsScene::setActiveWindow(), isActive()
+*/
+bool QGraphicsWidget::isActiveWindow() const
+{
+ return isActive();
+}
+
+/*!
+ \property QGraphicsWidget::windowTitle
+ \brief This property holds the window title (caption).
+
+ This property is only used for windows.
+
+ By default, if no title has been set, this property contains an
+ empty string.
+*/
+void QGraphicsWidget::setWindowTitle(const QString &title)
+{
+ Q_D(QGraphicsWidget);
+ d->ensureWindowData();
+ d->windowData->windowTitle = title;
+}
+QString QGraphicsWidget::windowTitle() const
+{
+ Q_D(const QGraphicsWidget);
+ return d->windowData ? d->windowData->windowTitle : QString();
+}
+
+/*!
+ \property QGraphicsWidget::focusPolicy
+ \brief the way the widget accepts keyboard focus
+
+ The focus policy is Qt::TabFocus if the widget accepts keyboard focus by
+ tabbing, Qt::ClickFocus if the widget accepts focus by clicking,
+ Qt::StrongFocus if it accepts both, and Qt::NoFocus (the default) if it
+ does not accept focus at all.
+
+ You must enable keyboard focus for a widget if it processes keyboard
+ events. This is normally done from the widget's constructor. For instance,
+ the QLineEdit constructor calls setFocusPolicy(Qt::StrongFocus).
+
+ If you enable a focus policy (i.e., not Qt::NoFocus), QGraphicsWidget will
+ automatically enable the ItemIsFocusable flag. Setting Qt::NoFocus on a
+ widget will clear the ItemIsFocusable flag. If the widget currently has
+ keyboard focus, the widget will automatically lose focus.
+
+ \sa focusInEvent(), focusOutEvent(), keyPressEvent(), keyReleaseEvent(), enabled
+*/
+Qt::FocusPolicy QGraphicsWidget::focusPolicy() const
+{
+ Q_D(const QGraphicsWidget);
+ return d->focusPolicy;
+}
+void QGraphicsWidget::setFocusPolicy(Qt::FocusPolicy policy)
+{
+ Q_D(QGraphicsWidget);
+ if (d->focusPolicy == policy)
+ return;
+ d->focusPolicy = policy;
+ if (hasFocus() && policy == Qt::NoFocus)
+ clearFocus();
+ setFlag(ItemIsFocusable, policy != Qt::NoFocus);
+}
+
+/*!
+ If this widget, a child or descendant of this widget currently has input
+ focus, this function will return a pointer to that widget. If
+ no descendant widget has input focus, 0 is returned.
+
+ \sa QGraphicsItem::focusItem(), QWidget::focusWidget()
+*/
+QGraphicsWidget *QGraphicsWidget::focusWidget() const
+{
+ Q_D(const QGraphicsWidget);
+ if (d->subFocusItem && d->subFocusItem->d_ptr->isWidget)
+ return static_cast<QGraphicsWidget *>(d->subFocusItem);
+ return 0;
+}
+
+#ifndef QT_NO_SHORTCUT
+/*!
+ \since 4.5
+
+ Adds a shortcut to Qt's shortcut system that watches for the given key \a
+ sequence in the given \a context. If the \a context is
+ Qt::ApplicationShortcut, the shortcut applies to the application as a
+ whole. Otherwise, it is either local to this widget, Qt::WidgetShortcut,
+ or to the window itself, Qt::WindowShortcut. For widgets that are not part
+ of a window (i.e., top-level widgets and their children),
+ Qt::WindowShortcut shortcuts apply to the scene.
+
+ If the same key \a sequence has been grabbed by several widgets,
+ when the key \a sequence occurs a QEvent::Shortcut event is sent
+ to all the widgets to which it applies in a non-deterministic
+ order, but with the ``ambiguous'' flag set to true.
+
+ \warning You should not normally need to use this function;
+ instead create \l{QAction}s with the shortcut key sequences you
+ require (if you also want equivalent menu options and toolbar
+ buttons), or create \l{QShortcut}s if you just need key sequences.
+ Both QAction and QShortcut handle all the event filtering for you,
+ and provide signals which are triggered when the user triggers the
+ key sequence, so are much easier to use than this low-level
+ function.
+
+ \sa releaseShortcut() setShortcutEnabled() QWidget::grabShortcut()
+*/
+int QGraphicsWidget::grabShortcut(const QKeySequence &sequence, Qt::ShortcutContext context)
+{
+ Q_ASSERT(qApp);
+ if (sequence.isEmpty())
+ return 0;
+ // ### setAttribute(Qt::WA_GrabbedShortcut);
+ return qApp->d_func()->shortcutMap.addShortcut(this, sequence, context);
+}
+
+/*!
+ \since 4.5
+
+ Removes the shortcut with the given \a id from Qt's shortcut
+ system. The widget will no longer receive QEvent::Shortcut events
+ for the shortcut's key sequence (unless it has other shortcuts
+ with the same key sequence).
+
+ \warning You should not normally need to use this function since
+ Qt's shortcut system removes shortcuts automatically when their
+ parent widget is destroyed. It is best to use QAction or
+ QShortcut to handle shortcuts, since they are easier to use than
+ this low-level function. Note also that this is an expensive
+ operation.
+
+ \sa grabShortcut() setShortcutEnabled() , QWidget::releaseShortcut()
+*/
+void QGraphicsWidget::releaseShortcut(int id)
+{
+ Q_ASSERT(qApp);
+ if (id)
+ qApp->d_func()->shortcutMap.removeShortcut(id, this, 0);
+}
+
+/*!
+ \since 4.5
+
+ If \a enabled is true, the shortcut with the given \a id is
+ enabled; otherwise the shortcut is disabled.
+
+ \warning You should not normally need to use this function since
+ Qt's shortcut system enables/disables shortcuts automatically as
+ widgets become hidden/visible and gain or lose focus. It is best
+ to use QAction or QShortcut to handle shortcuts, since they are
+ easier to use than this low-level function.
+
+ \sa grabShortcut() releaseShortcut(), QWidget::setShortcutEnabled()
+*/
+void QGraphicsWidget::setShortcutEnabled(int id, bool enabled)
+{
+ Q_ASSERT(qApp);
+ if (id)
+ qApp->d_func()->shortcutMap.setShortcutEnabled(enabled, id, this, 0);
+}
+
+/*!
+ \since 4.5
+
+ If \a enabled is true, auto repeat of the shortcut with the
+ given \a id is enabled; otherwise it is disabled.
+
+ \sa grabShortcut() releaseShortcut() QWidget::setShortcutAutoRepeat()
+*/
+void QGraphicsWidget::setShortcutAutoRepeat(int id, bool enabled)
+{
+ Q_ASSERT(qApp);
+ if (id)
+ qApp->d_func()->shortcutMap.setShortcutAutoRepeat(enabled, id, this, 0);
+}
+#endif
+
+#ifndef QT_NO_ACTION
+/*!
+ \since 4.5
+
+ Appends the action \a action to this widget's list of actions.
+
+ All QGraphicsWidgets have a list of \l{QAction}s, however they can be
+ represented graphically in many different ways. The default use of the
+ QAction list (as returned by actions()) is to create a context QMenu.
+
+ A QGraphicsWidget should only have one of each action and adding an action
+ it already has will not cause the same action to be in the widget twice.
+
+ \sa removeAction(), insertAction(), actions(), QWidget::addAction()
+*/
+void QGraphicsWidget::addAction(QAction *action)
+{
+ insertAction(0, action);
+}
+
+/*!
+ \since 4.5
+
+ Appends the actions \a actions to this widget's list of actions.
+
+ \sa removeAction(), QMenu, addAction(), QWidget::addActions()
+*/
+void QGraphicsWidget::addActions(QList<QAction *> actions)
+{
+ for (int i = 0; i < actions.count(); ++i)
+ insertAction(0, actions.at(i));
+}
+
+/*!
+ \since 4.5
+
+ Inserts the action \a action to this widget's list of actions,
+ before the action \a before. It appends the action if \a before is 0 or
+ \a before is not a valid action for this widget.
+
+ A QGraphicsWidget should only have one of each action.
+
+ \sa removeAction(), addAction(), QMenu, actions(),
+ QWidget::insertActions()
+*/
+void QGraphicsWidget::insertAction(QAction *before, QAction *action)
+{
+ if (!action) {
+ qWarning("QWidget::insertAction: Attempt to insert null action");
+ return;
+ }
+
+ Q_D(QGraphicsWidget);
+ int index = d->actions.indexOf(action);
+ if (index != -1)
+ d->actions.removeAt(index);
+
+ int pos = d->actions.indexOf(before);
+ if (pos < 0) {
+ before = 0;
+ pos = d->actions.size();
+ }
+ d->actions.insert(pos, action);
+
+ if (index == -1) {
+ QActionPrivate *apriv = action->d_func();
+ apriv->graphicsWidgets.append(this);
+ }
+
+ QActionEvent e(QEvent::ActionAdded, action, before);
+ QApplication::sendEvent(this, &e);
+}
+
+/*!
+ \since 4.5
+
+ Inserts the actions \a actions to this widget's list of actions,
+ before the action \a before. It appends the action if \a before is 0 or
+ \a before is not a valid action for this widget.
+
+ A QGraphicsWidget can have at most one of each action.
+
+ \sa removeAction(), QMenu, insertAction(), QWidget::insertActions()
+*/
+void QGraphicsWidget::insertActions(QAction *before, QList<QAction *> actions)
+{
+ for (int i = 0; i < actions.count(); ++i)
+ insertAction(before, actions.at(i));
+}
+
+/*!
+ \since 4.5
+
+ Removes the action \a action from this widget's list of actions.
+
+ \sa insertAction(), actions(), insertAction(), QWidget::removeAction()
+*/
+void QGraphicsWidget::removeAction(QAction *action)
+{
+ if (!action)
+ return;
+
+ Q_D(QGraphicsWidget);
+
+ QActionPrivate *apriv = action->d_func();
+ apriv->graphicsWidgets.removeAll(this);
+
+ if (d->actions.removeAll(action)) {
+ QActionEvent e(QEvent::ActionRemoved, action);
+ QApplication::sendEvent(this, &e);
+ }
+}
+
+/*!
+ \since 4.5
+
+ Returns the (possibly empty) list of this widget's actions.
+
+ \sa insertAction(), removeAction(), QWidget::actions(),
+ QAction::associatedWidgets(), QAction::associatedGraphicsWidgets()
+*/
+QList<QAction *> QGraphicsWidget::actions() const
+{
+ Q_D(const QGraphicsWidget);
+ return d->actions;
+}
+#endif
+
+/*!
+ Moves the \a second widget around the ring of focus widgets so that
+ keyboard focus moves from the \a first widget to the \a second widget when
+ the Tab key is pressed.
+
+ Note that since the tab order of the \a second widget is changed, you
+ should order a chain like this:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp 1
+
+ \e not like this:
+
+ \snippet doc/src/snippets/code/src_gui_graphicsview_qgraphicswidget.cpp 2
+
+ If \a first is 0, this indicates that \a second should be the first widget
+ to receive input focus should the scene gain Tab focus (i.e., the user
+ hits Tab so that focus passes into the scene). If \a second is 0, this
+ indicates that \a first should be the first widget to gain focus if the
+ scene gained BackTab focus.
+
+ By default, tab order is defined implicitly using widget creation order.
+
+ \sa focusPolicy, {Keyboard Focus}
+*/
+void QGraphicsWidget::setTabOrder(QGraphicsWidget *first, QGraphicsWidget *second)
+{
+ if (!first && !second) {
+ qWarning("QGraphicsWidget::setTabOrder(0, 0) is undefined");
+ return;
+ }
+ if ((first && second) && first->scene() != second->scene()) {
+ qWarning("QGraphicsWidget::setTabOrder: scenes %p and %p are different",
+ first->scene(), second->scene());
+ return;
+ }
+ QGraphicsScene *scene = first ? first->scene() : second->scene();
+ if (!scene && (!first || !second)) {
+ qWarning("QGraphicsWidget::setTabOrder: assigning tab order from/to the"
+ " scene requires the item to be in a scene.");
+ return;
+ }
+
+ // If either first or second are 0, the scene's tabFocusFirst is updated
+ // to point to the first item in the scene's focus chain. Then first or
+ // second are set to point to tabFocusFirst.
+ QGraphicsScenePrivate *sceneD = scene->d_func();
+ if (!first) {
+ sceneD->tabFocusFirst = second;
+ return;
+ }
+ if (!second) {
+ sceneD->tabFocusFirst = first->d_func()->focusNext;
+ return;
+ }
+
+ // Both first and second are != 0.
+ QGraphicsWidget *firstFocusNext = first->d_func()->focusNext;
+ if (firstFocusNext == second) {
+ // Nothing to do.
+ return;
+ }
+
+ // Update the focus chain.
+ QGraphicsWidget *secondFocusPrev = second->d_func()->focusPrev;
+ QGraphicsWidget *secondFocusNext = second->d_func()->focusNext;
+ firstFocusNext->d_func()->focusPrev = second;
+ first->d_func()->focusNext = second;
+ second->d_func()->focusNext = firstFocusNext;
+ second->d_func()->focusPrev = first;
+ secondFocusPrev->d_func()->focusNext = secondFocusNext;
+ secondFocusNext->d_func()->focusPrev = secondFocusPrev;
+
+ Q_ASSERT(first->d_func()->focusNext->d_func()->focusPrev == first);
+ Q_ASSERT(first->d_func()->focusPrev->d_func()->focusNext == first);
+
+ Q_ASSERT(second->d_func()->focusNext->d_func()->focusPrev == second);
+ Q_ASSERT(second->d_func()->focusPrev->d_func()->focusNext == second);
+
+}
+
+/*!
+ If \a on is true, this function enables \a attribute; otherwise
+ \a attribute is disabled.
+
+ See the class documentation for QGraphicsWidget for a complete list of
+ which attributes are supported, and what they are for.
+
+ \sa testAttribute(), QWidget::setAttribute()
+*/
+void QGraphicsWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
+{
+ Q_D(QGraphicsWidget);
+ // ### most flags require some immediate action
+ // ### we might want to qWarn use of unsupported attributes
+ // ### we might want to not use Qt::WidgetAttribute, but roll our own instead
+ d->setAttribute(attribute, on);
+}
+
+/*!
+ Returns true if \a attribute is enabled for this widget; otherwise,
+ returns false.
+
+ \sa setAttribute()
+*/
+bool QGraphicsWidget::testAttribute(Qt::WidgetAttribute attribute) const
+{
+ Q_D(const QGraphicsWidget);
+ return d->testAttribute(attribute);
+}
+
+/*!
+ \reimp
+*/
+int QGraphicsWidget::type() const
+{
+ return Type;
+}
+
+/*!
+ \reimp
+*/
+void QGraphicsWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ Q_UNUSED(painter);
+ Q_UNUSED(option);
+ Q_UNUSED(widget);
+}
+
+/*!
+ This virtual function is called by QGraphicsScene to draw the window frame
+ for windows using \a painter, \a option, and \a widget, in local
+ coordinates. The base implementation uses the current style to render the
+ frame and title bar.
+
+ You can reimplement this function in a subclass of QGraphicsWidget to
+ provide custom rendering of the widget's window frame.
+
+ \sa QGraphicsItem::paint()
+*/
+void QGraphicsWidget::paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option,
+ QWidget *widget)
+{
+ const bool fillBackground = !testAttribute(Qt::WA_OpaquePaintEvent)
+ && !testAttribute(Qt::WA_NoSystemBackground);
+ QGraphicsProxyWidget *proxy = qobject_cast<QGraphicsProxyWidget *>(this);
+ const bool embeddedWidgetFillsOwnBackground = proxy && proxy->widget();
+
+ if (rect().contains(option->exposedRect)) {
+ if (fillBackground && !embeddedWidgetFillsOwnBackground)
+ painter->fillRect(option->exposedRect, palette().window());
+ return;
+ }
+
+ Q_D(QGraphicsWidget);
+
+ QRect windowFrameRect = QRect(QPoint(), windowFrameGeometry().size().toSize());
+ QStyleOptionTitleBar bar;
+ bar.QStyleOption::operator=(*option);
+ d->initStyleOptionTitleBar(&bar); // this clear flags in bar.state
+ d->ensureWindowData();
+ if (d->windowData->buttonMouseOver)
+ bar.state |= QStyle::State_MouseOver;
+ else
+ bar.state &= ~QStyle::State_MouseOver;
+ if (d->windowData->buttonSunken)
+ bar.state |= QStyle::State_Sunken;
+ else
+ bar.state &= ~QStyle::State_Sunken;
+
+ bar.rect = windowFrameRect;
+
+ // translate painter to make the style happy
+ const QPointF styleOrigin = this->windowFrameRect().topLeft();
+ painter->translate(styleOrigin);
+
+#ifdef Q_WS_MAC
+ const QSize pixmapSize = windowFrameRect.size();
+ if (pixmapSize.width() <= 0 || pixmapSize.height() <= 0)
+ return;
+ QPainter *realPainter = painter;
+ QPixmap pm(pixmapSize);
+ painter = new QPainter(&pm);
+#endif
+
+ // Fill background
+ QStyleHintReturnMask mask;
+ bool setMask = style()->styleHint(QStyle::SH_WindowFrame_Mask, &bar, widget, &mask) && !mask.region.isEmpty();
+ bool hasBorder = !style()->styleHint(QStyle::SH_TitleBar_NoBorder, &bar, widget);
+ int frameWidth = style()->pixelMetric(QStyle::PM_MDIFrameWidth, &bar, widget);
+ if (setMask) {
+ painter->save();
+ painter->setClipRegion(mask.region, Qt::IntersectClip);
+ }
+ if (fillBackground) {
+ if (embeddedWidgetFillsOwnBackground) {
+ // Don't fill the background twice.
+ QPainterPath windowFrameBackground;
+ windowFrameBackground.addRect(windowFrameRect);
+ // Adjust with 0.5 to avoid border artifacts between
+ // widget background and frame background.
+ windowFrameBackground.addRect(rect().translated(-styleOrigin).adjusted(0.5, 0.5, -0.5, -0.5));
+ painter->fillPath(windowFrameBackground, palette().window());
+ } else {
+ painter->fillRect(windowFrameRect, palette().window());
+ }
+ }
+ painter->setRenderHint(QPainter::NonCosmeticDefaultPen);
+
+ // Draw title
+ int height = (int)d->titleBarHeight(bar);
+ bar.rect.setHeight(height);
+ if (hasBorder) // Frame is painted by PE_FrameWindow
+ bar.rect.adjust(frameWidth, frameWidth, -frameWidth, 0);
+
+ painter->save();
+ painter->setFont(QApplication::font("QWorkspaceTitleBar"));
+ style()->drawComplexControl(QStyle::CC_TitleBar, &bar, painter, widget);
+ painter->restore();
+ if (setMask)
+ painter->restore();
+ // Draw window frame
+ QStyleOptionFrame frameOptions;
+ frameOptions.QStyleOption::operator=(*option);
+ initStyleOption(&frameOptions);
+ if (!hasBorder)
+ painter->setClipRect(windowFrameRect.adjusted(0, +height, 0, 0), Qt::IntersectClip);
+ if (hasFocus()) {
+ frameOptions.state |= QStyle::State_HasFocus;
+ } else {
+ frameOptions.state &= ~QStyle::State_HasFocus;
+ }
+ bool isActive = isActiveWindow();
+ if (isActive) {
+ frameOptions.state |= QStyle::State_Active;
+ } else {
+ frameOptions.state &= ~QStyle::State_Active;
+ }
+
+ frameOptions.palette.setCurrentColorGroup(isActive ? QPalette::Active : QPalette::Normal);
+ frameOptions.rect = windowFrameRect;
+ frameOptions.lineWidth = style()->pixelMetric(QStyle::PM_MdiSubWindowFrameWidth, 0, widget);
+ frameOptions.midLineWidth = 1;
+ style()->drawPrimitive(QStyle::PE_FrameWindow, &frameOptions, painter, widget);
+
+#ifdef Q_WS_MAC
+ realPainter->drawPixmap(QPoint(), pm);
+ delete painter;
+#endif
+}
+
+/*!
+ \reimp
+*/
+QRectF QGraphicsWidget::boundingRect() const
+{
+ return windowFrameRect();
+}
+
+/*!
+ \reimp
+*/
+QPainterPath QGraphicsWidget::shape() const
+{
+ QPainterPath path;
+ path.addRect(rect());
+ return path;
+}
+
+/*!
+ Call this function to close the widget.
+
+ Returns true if the widget was closed; otherwise returns false.
+ This slot will first send a QCloseEvent to the widget, which may or may
+ not accept the event. If the event was ignored, nothing happens. If the
+ event was accepted, it will hide() the widget.
+
+ If the widget has the Qt::WA_DeleteOnClose attribute set it will be
+ deleted.
+*/
+bool QGraphicsWidget::close()
+{
+ QCloseEvent closeEvent;
+ QApplication::sendEvent(this, &closeEvent);
+ if (!closeEvent.isAccepted()) {
+ return false;
+ }
+ // hide
+ if (isVisible()) {
+ hide();
+ }
+ if (testAttribute(Qt::WA_DeleteOnClose)) {
+ deleteLater();
+ }
+ return true;
+}
+
+#ifdef Q_NO_USING_KEYWORD
+/*!
+ \fn const QObjectList &QGraphicsWidget::children() const
+ \internal
+
+ This function returns the same value as QObject::children(). It's
+ provided to differentiate between the obsolete member
+ QGraphicsItem::children() and QObject::children(). QGraphicsItem now
+ provides childItems() instead.
+*/
+#endif
+
+#if 0
+void QGraphicsWidget::dumpFocusChain()
+{
+ qDebug() << "=========== Dumping focus chain ==============";
+ int i = 0;
+ QGraphicsWidget *next = this;
+ QSet<QGraphicsWidget*> visited;
+ do {
+ if (!next) {
+ qWarning("Found a focus chain that is not circular, (next == 0)");
+ break;
+ }
+ qDebug() << i++ << QString::number(uint(next), 16) << next->className() << next->data(0) << QString::fromAscii("focusItem:%1").arg(next->hasFocus() ? '1' : '0') << QLatin1String("next:") << next->d_func()->focusNext->data(0) << QLatin1String("prev:") << next->d_func()->focusPrev->data(0);
+ if (visited.contains(next)) {
+ qWarning("Already visited this node. However, I expected to dump until I found myself.");
+ break;
+ }
+ visited << next;
+ next = next->d_func()->focusNext;
+ } while (next != this);
+}
+#endif
+
+QT_END_NAMESPACE
+
+#endif //QT_NO_GRAPHICSVIEW
diff --git a/src/widgets/graphicsview/qgraphicswidget.h b/src/widgets/graphicsview/qgraphicswidget.h
new file mode 100644
index 0000000000..5ccf45a43b
--- /dev/null
+++ b/src/widgets/graphicsview/qgraphicswidget.h
@@ -0,0 +1,257 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGRAPHICSWIDGET_H
+#define QGRAPHICSWIDGET_H
+
+#include <QtGui/qfont.h>
+#include <QtWidgets/qgraphicslayoutitem.h>
+#include <QtWidgets/qgraphicsitem.h>
+#include <QtGui/qpalette.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QFont;
+class QFontMetrics;
+class QGraphicsLayout;
+class QGraphicsSceneMoveEvent;
+class QGraphicsWidgetPrivate;
+class QGraphicsSceneResizeEvent;
+class QStyle;
+class QStyleOption;
+
+#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
+
+class QGraphicsWidgetPrivate;
+
+class Q_GUI_EXPORT QGraphicsWidget : public QGraphicsObject, public QGraphicsLayoutItem
+{
+ Q_OBJECT
+ Q_INTERFACES(QGraphicsItem QGraphicsLayoutItem)
+ Q_PROPERTY(QPalette palette READ palette WRITE setPalette)
+ Q_PROPERTY(QFont font READ font WRITE setFont)
+ Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection RESET unsetLayoutDirection)
+ Q_PROPERTY(QSizeF size READ size WRITE resize NOTIFY geometryChanged)
+ Q_PROPERTY(QSizeF minimumSize READ minimumSize WRITE setMinimumSize)
+ Q_PROPERTY(QSizeF preferredSize READ preferredSize WRITE setPreferredSize)
+ Q_PROPERTY(QSizeF maximumSize READ maximumSize WRITE setMaximumSize)
+ Q_PROPERTY(QSizePolicy sizePolicy READ sizePolicy WRITE setSizePolicy)
+ Q_PROPERTY(Qt::FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy)
+ Q_PROPERTY(Qt::WindowFlags windowFlags READ windowFlags WRITE setWindowFlags)
+ Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle)
+ Q_PROPERTY(QRectF geometry READ geometry WRITE setGeometry NOTIFY geometryChanged)
+ Q_PROPERTY(bool autoFillBackground READ autoFillBackground WRITE setAutoFillBackground)
+ Q_PROPERTY(QGraphicsLayout* layout READ layout WRITE setLayout NOTIFY layoutChanged)
+public:
+ QGraphicsWidget(QGraphicsItem *parent = 0, Qt::WindowFlags wFlags = 0);
+ ~QGraphicsWidget();
+ QGraphicsLayout *layout() const;
+ void setLayout(QGraphicsLayout *layout);
+ void adjustSize();
+
+ Qt::LayoutDirection layoutDirection() const;
+ void setLayoutDirection(Qt::LayoutDirection direction);
+ void unsetLayoutDirection();
+
+ QStyle *style() const;
+ void setStyle(QStyle *style);
+
+ QFont font() const;
+ void setFont(const QFont &font);
+
+ QPalette palette() const;
+ void setPalette(const QPalette &palette);
+
+ bool autoFillBackground() const;
+ void setAutoFillBackground(bool enabled);
+
+ void resize(const QSizeF &size);
+ inline void resize(qreal w, qreal h) { resize(QSizeF(w, h)); }
+ QSizeF size() const;
+
+ void setGeometry(const QRectF &rect);
+ inline void setGeometry(qreal x, qreal y, qreal w, qreal h);
+ inline QRectF rect() const { return QRectF(QPointF(), size()); }
+
+ void setContentsMargins(qreal left, qreal top, qreal right, qreal bottom);
+ void getContentsMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const;
+
+ void setWindowFrameMargins(qreal left, qreal top, qreal right, qreal bottom);
+ void getWindowFrameMargins(qreal *left, qreal *top, qreal *right, qreal *bottom) const;
+ void unsetWindowFrameMargins();
+ QRectF windowFrameGeometry() const;
+ QRectF windowFrameRect() const;
+
+ // Window handling
+ Qt::WindowFlags windowFlags() const;
+ Qt::WindowType windowType() const;
+ void setWindowFlags(Qt::WindowFlags wFlags);
+ bool isActiveWindow() const;
+ void setWindowTitle(const QString &title);
+ QString windowTitle() const;
+
+ // Focus handling
+ Qt::FocusPolicy focusPolicy() const;
+ void setFocusPolicy(Qt::FocusPolicy policy);
+ static void setTabOrder(QGraphicsWidget *first, QGraphicsWidget *second);
+ QGraphicsWidget *focusWidget() const;
+
+#ifndef QT_NO_SHORTCUT
+ int grabShortcut(const QKeySequence &sequence, Qt::ShortcutContext context = Qt::WindowShortcut);
+ void releaseShortcut(int id);
+ void setShortcutEnabled(int id, bool enabled = true);
+ void setShortcutAutoRepeat(int id, bool enabled = true);
+#endif
+
+#ifndef QT_NO_ACTION
+ //actions
+ void addAction(QAction *action);
+ void addActions(QList<QAction*> actions);
+ void insertAction(QAction *before, QAction *action);
+ void insertActions(QAction *before, QList<QAction*> actions);
+ void removeAction(QAction *action);
+ QList<QAction*> actions() const;
+#endif
+
+ void setAttribute(Qt::WidgetAttribute attribute, bool on = true);
+ bool testAttribute(Qt::WidgetAttribute attribute) const;
+
+ enum {
+ Type = 11
+ };
+ int type() const;
+
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+ virtual void paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
+ QRectF boundingRect() const;
+ QPainterPath shape() const;
+
+#if 0
+ void dumpFocusChain();
+#endif
+
+ // ### Qt 5: Disambiguate
+#ifdef Q_NO_USING_KEYWORD
+ const QObjectList &children() const { return QObject::children(); }
+#else
+ using QObject::children;
+#endif
+
+Q_SIGNALS:
+ void geometryChanged();
+ void layoutChanged();
+
+public Q_SLOTS:
+ bool close();
+
+protected:
+ virtual void initStyleOption(QStyleOption *option) const;
+
+ QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
+ void updateGeometry();
+
+ // Notification
+ QVariant itemChange(GraphicsItemChange change, const QVariant &value);
+ virtual QVariant propertyChange(const QString &propertyName, const QVariant &value);
+
+ // Scene events
+ bool sceneEvent(QEvent *event);
+ virtual bool windowFrameEvent(QEvent *e);
+ virtual Qt::WindowFrameSection windowFrameSectionAt(const QPointF& pos) const;
+
+ // Base event handlers
+ bool event(QEvent *event);
+ //virtual void actionEvent(QActionEvent *event);
+ virtual void changeEvent(QEvent *event);
+ virtual void closeEvent(QCloseEvent *event);
+ //void create(WId window = 0, bool initializeWindow = true, bool destroyOldWindow = true);
+ //void destroy(bool destroyWindow = true, bool destroySubWindows = true);
+ void focusInEvent(QFocusEvent *event);
+ virtual bool focusNextPrevChild(bool next);
+ void focusOutEvent(QFocusEvent *event);
+ virtual void hideEvent(QHideEvent *event);
+ //virtual bool macEvent(EventHandlerCallRef caller, EventRef event);
+ //virtual int metric(PaintDeviceMetric m ) const;
+ virtual void moveEvent(QGraphicsSceneMoveEvent *event);
+ virtual void polishEvent();
+ //virtual bool qwsEvent(QWSEvent *event);
+ //void resetInputContext ();
+ virtual void resizeEvent(QGraphicsSceneResizeEvent *event);
+ virtual void showEvent(QShowEvent *event);
+ //virtual void tabletEvent(QTabletEvent *event);
+ //virtual bool winEvent(MSG *message, long *result);
+ //virtual bool x11Event(XEvent *event);
+ virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
+ virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
+ virtual void grabMouseEvent(QEvent *event);
+ virtual void ungrabMouseEvent(QEvent *event);
+ virtual void grabKeyboardEvent(QEvent *event);
+ virtual void ungrabKeyboardEvent(QEvent *event);
+ QGraphicsWidget(QGraphicsWidgetPrivate &, QGraphicsItem *parent, QGraphicsScene *, Qt::WindowFlags wFlags = 0);
+
+private:
+ Q_DISABLE_COPY(QGraphicsWidget)
+ Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QGraphicsWidget)
+ friend class QGraphicsScene;
+ friend class QGraphicsScenePrivate;
+ friend class QGraphicsView;
+ friend class QGraphicsItem;
+ friend class QGraphicsItemPrivate;
+ friend class QGraphicsLayout;
+ friend class QWidget;
+ friend class QApplication;
+};
+
+inline void QGraphicsWidget::setGeometry(qreal ax, qreal ay, qreal aw, qreal ah)
+{ setGeometry(QRectF(ax, ay, aw, ah)); }
+
+#endif
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
+
diff --git a/src/widgets/graphicsview/qgraphicswidget_p.cpp b/src/widgets/graphicsview/qgraphicswidget_p.cpp
new file mode 100644
index 0000000000..ec36c08041
--- /dev/null
+++ b/src/widgets/graphicsview/qgraphicswidget_p.cpp
@@ -0,0 +1,906 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qglobal.h"
+
+#ifndef QT_NO_GRAPHICSVIEW
+
+#include <QtCore/qdebug.h>
+#include <QtCore/qnumeric.h>
+#include "qgraphicswidget_p.h"
+#include "qgraphicslayoutitem_p.h"
+#include "qgraphicslayout.h"
+#include "qgraphicsscene_p.h"
+#include <QtWidgets/qapplication.h>
+#include <QtWidgets/qgraphicsscene.h>
+#include <QtWidgets/qstyleoption.h>
+#include <QtWidgets/QStyleOptionTitleBar>
+#include <QtWidgets/QGraphicsSceneMouseEvent>
+#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC)
+# include <QMacStyle>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+void QGraphicsWidgetPrivate::init(QGraphicsItem *parentItem, Qt::WindowFlags wFlags)
+{
+ Q_Q(QGraphicsWidget);
+
+ attributes = 0;
+ isWidget = 1; // QGraphicsItem::isWidget() returns true.
+ focusNext = focusPrev = q;
+ focusPolicy = Qt::NoFocus;
+
+ adjustWindowFlags(&wFlags);
+ windowFlags = wFlags;
+
+ if (parentItem)
+ setParentItemHelper(parentItem, 0, 0);
+
+ q->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred, QSizePolicy::DefaultType));
+ q->setGraphicsItem(q);
+
+ resolveLayoutDirection();
+ q->unsetWindowFrameMargins();
+ flags |= QGraphicsItem::ItemUsesExtendedStyleOption;
+ flags |= QGraphicsItem::ItemSendsGeometryChanges;
+ if (windowFlags & Qt::Window)
+ flags |= QGraphicsItem::ItemIsPanel;
+}
+
+qreal QGraphicsWidgetPrivate::titleBarHeight(const QStyleOptionTitleBar &options) const
+{
+ Q_Q(const QGraphicsWidget);
+ int height = q->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options);
+#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC)
+ if (qobject_cast<QMacStyle*>(q->style())) {
+ height -=4;
+ }
+#endif
+ return (qreal)height;
+}
+
+/*!
+ \internal
+*/
+QGraphicsWidgetPrivate::~QGraphicsWidgetPrivate()
+{
+ // Remove any lazily allocated data
+ delete[] margins;
+ delete[] windowFrameMargins;
+ delete windowData;
+}
+
+/*!
+ \internal
+
+ Ensures that margins is allocated.
+ This function must be called before any dereferencing.
+*/
+void QGraphicsWidgetPrivate::ensureMargins() const
+{
+ if (!margins) {
+ margins = new qreal[4];
+ for (int i = 0; i < 4; ++i)
+ margins[i] = 0;
+ }
+}
+
+/*!
+ \internal
+
+ Ensures that windowFrameMargins is allocated.
+ This function must be called before any dereferencing.
+*/
+void QGraphicsWidgetPrivate::ensureWindowFrameMargins() const
+{
+ if (!windowFrameMargins) {
+ windowFrameMargins = new qreal[4];
+ for (int i = 0; i < 4; ++i)
+ windowFrameMargins[i] = 0;
+ }
+}
+
+/*!
+ \internal
+
+ Ensures that windowData is allocated.
+ This function must be called before any dereferencing.
+*/
+void QGraphicsWidgetPrivate::ensureWindowData()
+{
+ if (!windowData)
+ windowData = new WindowData;
+}
+
+void QGraphicsWidgetPrivate::setPalette_helper(const QPalette &palette)
+{
+ if (this->palette == palette && this->palette.resolve() == palette.resolve())
+ return;
+ updatePalette(palette);
+}
+
+void QGraphicsWidgetPrivate::resolvePalette(uint inheritedMask)
+{
+ inheritedPaletteResolveMask = inheritedMask;
+ QPalette naturalPalette = naturalWidgetPalette();
+ QPalette resolvedPalette = palette.resolve(naturalPalette);
+ updatePalette(resolvedPalette);
+}
+
+void QGraphicsWidgetPrivate::updatePalette(const QPalette &palette)
+{
+ Q_Q(QGraphicsWidget);
+ // Update local palette setting.
+ this->palette = palette;
+
+ // Calculate new mask.
+ if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation))
+ inheritedPaletteResolveMask = 0;
+ int mask = palette.resolve() | inheritedPaletteResolveMask;
+
+ // Propagate to children.
+ for (int i = 0; i < children.size(); ++i) {
+ QGraphicsItem *item = children.at(i);
+ if (item->isWidget()) {
+ QGraphicsWidget *w = static_cast<QGraphicsWidget *>(item);
+ if (!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))
+ w->d_func()->resolvePalette(mask);
+ } else {
+ item->d_ptr->resolvePalette(mask);
+ }
+ }
+
+ // Notify change.
+ QEvent event(QEvent::PaletteChange);
+ QApplication::sendEvent(q, &event);
+}
+
+void QGraphicsWidgetPrivate::setLayoutDirection_helper(Qt::LayoutDirection direction)
+{
+ Q_Q(QGraphicsWidget);
+ if ((direction == Qt::RightToLeft) == (testAttribute(Qt::WA_RightToLeft)))
+ return;
+ q->setAttribute(Qt::WA_RightToLeft, (direction == Qt::RightToLeft));
+
+ // Propagate this change to all children.
+ for (int i = 0; i < children.size(); ++i) {
+ QGraphicsItem *item = children.at(i);
+ if (item->isWidget()) {
+ QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
+ if (widget->parentWidget() && !widget->testAttribute(Qt::WA_SetLayoutDirection))
+ widget->d_func()->setLayoutDirection_helper(direction);
+ }
+ }
+
+ // Send the notification event to this widget item.
+ QEvent e(QEvent::LayoutDirectionChange);
+ QApplication::sendEvent(q, &e);
+}
+
+void QGraphicsWidgetPrivate::resolveLayoutDirection()
+{
+ Q_Q(QGraphicsWidget);
+ if (q->testAttribute(Qt::WA_SetLayoutDirection)) {
+ return;
+ }
+ if (QGraphicsWidget *parentWidget = q->parentWidget()) {
+ setLayoutDirection_helper(parentWidget->layoutDirection());
+ } else if (scene) {
+ // ### shouldn't the scene have a layoutdirection really? how does
+ // ### QGraphicsWidget get changes from QApplication::layoutDirection?
+ setLayoutDirection_helper(QApplication::layoutDirection());
+ } else {
+ setLayoutDirection_helper(QApplication::layoutDirection());
+ }
+}
+
+QPalette QGraphicsWidgetPrivate::naturalWidgetPalette() const
+{
+ Q_Q(const QGraphicsWidget);
+ QPalette palette;
+ if (QGraphicsWidget *parent = q->parentWidget()) {
+ palette = parent->palette();
+ } else if (scene) {
+ palette = scene->palette();
+ }
+ palette.resolve(0);
+ return palette;
+}
+
+void QGraphicsWidgetPrivate::setFont_helper(const QFont &font)
+{
+ if (this->font == font && this->font.resolve() == font.resolve())
+ return;
+ updateFont(font);
+}
+
+void QGraphicsWidgetPrivate::resolveFont(uint inheritedMask)
+{
+ Q_Q(QGraphicsWidget);
+ inheritedFontResolveMask = inheritedMask;
+ if (QGraphicsWidget *p = q->parentWidget())
+ inheritedFontResolveMask |= p->d_func()->inheritedFontResolveMask;
+ QFont naturalFont = naturalWidgetFont();
+ QFont resolvedFont = font.resolve(naturalFont);
+ updateFont(resolvedFont);
+}
+
+void QGraphicsWidgetPrivate::updateFont(const QFont &font)
+{
+ Q_Q(QGraphicsWidget);
+ // Update the local font setting.
+ this->font = font;
+
+ // Calculate new mask.
+ if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation))
+ inheritedFontResolveMask = 0;
+ int mask = font.resolve() | inheritedFontResolveMask;
+
+ // Propagate to children.
+ for (int i = 0; i < children.size(); ++i) {
+ QGraphicsItem *item = children.at(i);
+ if (item->isWidget()) {
+ QGraphicsWidget *w = static_cast<QGraphicsWidget *>(item);
+ if (!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))
+ w->d_func()->resolveFont(mask);
+ } else {
+ item->d_ptr->resolveFont(mask);
+ }
+ }
+
+ if (!polished)
+ return;
+ // Notify change.
+ QEvent event(QEvent::FontChange);
+ QApplication::sendEvent(q, &event);
+}
+
+QFont QGraphicsWidgetPrivate::naturalWidgetFont() const
+{
+ Q_Q(const QGraphicsWidget);
+ QFont naturalFont; // ### no application font support
+ if (QGraphicsWidget *parent = q->parentWidget()) {
+ naturalFont = parent->font();
+ } else if (scene) {
+ naturalFont = scene->font();
+ }
+ naturalFont.resolve(0);
+ return naturalFont;
+}
+
+void QGraphicsWidgetPrivate::initStyleOptionTitleBar(QStyleOptionTitleBar *option)
+{
+ Q_Q(QGraphicsWidget);
+ ensureWindowData();
+ q->initStyleOption(option);
+ option->rect.setHeight(titleBarHeight(*option));
+ option->titleBarFlags = windowFlags;
+ option->subControls = QStyle::SC_TitleBarCloseButton | QStyle::SC_TitleBarLabel | QStyle::SC_TitleBarSysMenu;
+ option->activeSubControls = windowData->hoveredSubControl;
+ bool isActive = q->isActiveWindow();
+ if (isActive) {
+ option->state |= QStyle::State_Active;
+ option->titleBarState = Qt::WindowActive;
+ option->titleBarState |= QStyle::State_Active;
+ } else {
+ option->state &= ~QStyle::State_Active;
+ option->titleBarState = Qt::WindowNoState;
+ }
+ QFont windowTitleFont = QApplication::font("QWorkspaceTitleBar");
+ QRect textRect = q->style()->subControlRect(QStyle::CC_TitleBar, option, QStyle::SC_TitleBarLabel, 0);
+ option->text = QFontMetrics(windowTitleFont).elidedText(
+ windowData->windowTitle, Qt::ElideRight, textRect.width());
+}
+
+void QGraphicsWidgetPrivate::adjustWindowFlags(Qt::WindowFlags *flags)
+{
+ bool customize = (*flags & (Qt::CustomizeWindowHint
+ | Qt::FramelessWindowHint
+ | Qt::WindowTitleHint
+ | Qt::WindowSystemMenuHint
+ | Qt::WindowMinimizeButtonHint
+ | Qt::WindowMaximizeButtonHint
+ | Qt::WindowContextHelpButtonHint));
+
+ uint type = (*flags & Qt::WindowType_Mask);
+ if (customize)
+ ;
+ else if (type == Qt::Dialog || type == Qt::Sheet)
+ *flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint;
+ else if (type == Qt::Tool)
+ *flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint;
+ else if (type == Qt::Window || type == Qt::SubWindow)
+ *flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint
+ | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint;
+}
+
+void QGraphicsWidgetPrivate::windowFrameMouseReleaseEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_Q(QGraphicsWidget);
+ ensureWindowData();
+ if (windowData->grabbedSection != Qt::NoSection) {
+ if (windowData->grabbedSection == Qt::TitleBarArea) {
+ windowData->buttonSunken = false;
+ QStyleOptionTitleBar bar;
+ initStyleOptionTitleBar(&bar);
+ // make sure that the coordinates (rect and pos) we send to the style are positive.
+ bar.rect = q->windowFrameRect().toRect();
+ bar.rect.moveTo(0,0);
+ bar.rect.setHeight(q->style()->pixelMetric(QStyle::PM_TitleBarHeight, &bar));
+ QPointF pos = event->pos();
+ if (windowFrameMargins) {
+ pos.rx() += windowFrameMargins[Left];
+ pos.ry() += windowFrameMargins[Top];
+ }
+ bar.subControls = QStyle::SC_TitleBarCloseButton;
+ if (q->style()->subControlRect(QStyle::CC_TitleBar, &bar,
+ QStyle::SC_TitleBarCloseButton,
+ event->widget()).contains(pos.toPoint())) {
+ q->close();
+ }
+ }
+ if (!(static_cast<QGraphicsSceneMouseEvent *>(event)->buttons()))
+ windowData->grabbedSection = Qt::NoSection;
+ event->accept();
+ }
+}
+
+void QGraphicsWidgetPrivate::windowFrameMousePressEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_Q(QGraphicsWidget);
+ if (event->button() != Qt::LeftButton)
+ return;
+
+ ensureWindowData();
+ windowData->startGeometry = q->geometry();
+ windowData->grabbedSection = q->windowFrameSectionAt(event->pos());
+ ensureWindowData();
+ if (windowData->grabbedSection == Qt::TitleBarArea
+ && windowData->hoveredSubControl == QStyle::SC_TitleBarCloseButton) {
+ windowData->buttonSunken = true;
+ q->update();
+ }
+ event->setAccepted(windowData->grabbedSection != Qt::NoSection);
+}
+
+/*!
+ Used to calculate the
+ Precondition:
+ \a widget should support either hfw or wfh
+
+ If \a heightForWidth is set to false, this function will query the width for height
+ instead. \a width will then be interpreted as height, \a minh and \a maxh will be interpreted
+ as minimum width and maximum width.
+ */
+static qreal minimumHeightForWidth(qreal width, qreal minh, qreal maxh,
+ const QGraphicsWidget *widget,
+ bool heightForWidth = true)
+{
+ qreal minimumHeightForWidth = -1;
+ const bool hasHFW = QGraphicsLayoutItemPrivate::get(widget)->hasHeightForWidth();
+ if (hasHFW == heightForWidth) {
+ minimumHeightForWidth = hasHFW
+ ? widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(width, -1)).height()
+ : widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, width)).width(); //"width" is here height!
+ } else {
+ // widthForHeight
+ const qreal constraint = width;
+ while (maxh - minh > 0.1) {
+ qreal middle = minh + (maxh - minh)/2;
+ // ### really bad, if we are a widget with a layout it will call
+ // layout->effectiveSizeHint(Qt::MiniumumSize), which again will call
+ // sizeHint three times because of how the cache works
+ qreal hfw = hasHFW
+ ? widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(middle, -1)).height()
+ : widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, middle)).width();
+ if (hfw > constraint) {
+ minh = middle;
+ } else if (hfw <= constraint) {
+ maxh = middle;
+ }
+ }
+ minimumHeightForWidth = maxh;
+ }
+ return minimumHeightForWidth;
+}
+
+static qreal minimumWidthForHeight(qreal height, qreal minw, qreal maxw,
+ const QGraphicsWidget *widget)
+{
+ return minimumHeightForWidth(height, minw, maxw, widget, false);
+}
+
+static QSizeF closestAcceptableSize(const QSizeF &proposed,
+ const QGraphicsWidget *widget)
+{
+ const QSizeF current = widget->size();
+
+ qreal minw = proposed.width();
+ qreal maxw = current.width();
+ qreal minh = proposed.height();
+ qreal maxh = current.height();
+
+ qreal middlew = maxw;
+ qreal middleh = maxh;
+ qreal min_hfw;
+ min_hfw = minimumHeightForWidth(maxw, minh, maxh, widget);
+
+ do {
+ if (maxw - minw < 0.1) {
+ // we still havent found anything, cut off binary search
+ minw = maxw;
+ minh = maxh;
+ }
+ middlew = minw + (maxw - minw)/2.0;
+ middleh = minh + (maxh - minh)/2.0;
+
+ min_hfw = minimumHeightForWidth(middlew, minh, maxh, widget);
+
+ if (min_hfw > middleh) {
+ minw = middlew;
+ minh = middleh;
+ } else if (min_hfw <= middleh) {
+ maxw = middlew;
+ maxh = middleh;
+ }
+ } while (maxw != minw);
+
+ min_hfw = minimumHeightForWidth(middlew, minh, maxh, widget);
+
+ QSizeF result;
+ if (min_hfw < maxh) {
+ result = QSizeF(middlew, min_hfw);
+ } else {
+ // Needed because of the cut-off we do above.
+ result = QSizeF(minimumWidthForHeight(maxh, proposed.width(), current.width(), widget), maxh);
+ }
+ return result;
+}
+
+static void _q_boundGeometryToSizeConstraints(const QRectF &startGeometry,
+ QRectF *rect, Qt::WindowFrameSection section,
+ const QSizeF &min, const QSizeF &max,
+ const QGraphicsWidget *widget)
+{
+ const QRectF proposedRect = *rect;
+ qreal width = qBound(min.width(), proposedRect.width(), max.width());
+ qreal height = qBound(min.height(), proposedRect.height(), max.height());
+
+ const bool hasHFW = QGraphicsLayoutItemPrivate::get(widget)->hasHeightForWidth();
+ const bool hasWFH = QGraphicsLayoutItemPrivate::get(widget)->hasWidthForHeight();
+
+ const bool widthChanged = proposedRect.width() != widget->size().width();
+ const bool heightChanged = proposedRect.height() != widget->size().height();
+
+ if (hasHFW || hasWFH) {
+ if (widthChanged || heightChanged) {
+ qreal minExtent;
+ qreal maxExtent;
+ qreal constraint;
+ qreal proposed;
+ if (hasHFW) {
+ minExtent = min.height();
+ maxExtent = max.height();
+ constraint = width;
+ proposed = proposedRect.height();
+ } else {
+ // width for height
+ minExtent = min.width();
+ maxExtent = max.width();
+ constraint = height;
+ proposed = proposedRect.width();
+ }
+ if (minimumHeightForWidth(constraint, minExtent, maxExtent, widget, hasHFW) > proposed) {
+ QSizeF effectiveSize = closestAcceptableSize(QSizeF(width, height), widget);
+ width = effectiveSize.width();
+ height = effectiveSize.height();
+ }
+ }
+ }
+
+ switch (section) {
+ case Qt::LeftSection:
+ rect->setRect(startGeometry.right() - qRound(width), startGeometry.top(),
+ qRound(width), startGeometry.height());
+ break;
+ case Qt::TopLeftSection:
+ rect->setRect(startGeometry.right() - qRound(width), startGeometry.bottom() - qRound(height),
+ qRound(width), qRound(height));
+ break;
+ case Qt::TopSection:
+ rect->setRect(startGeometry.left(), startGeometry.bottom() - qRound(height),
+ startGeometry.width(), qRound(height));
+ break;
+ case Qt::TopRightSection:
+ rect->setTop(rect->bottom() - qRound(height));
+ rect->setWidth(qRound(width));
+ break;
+ case Qt::RightSection:
+ rect->setWidth(qRound(width));
+ break;
+ case Qt::BottomRightSection:
+ rect->setWidth(qRound(width));
+ rect->setHeight(qRound(height));
+ break;
+ case Qt::BottomSection:
+ rect->setHeight(qRound(height));
+ break;
+ case Qt::BottomLeftSection:
+ rect->setRect(startGeometry.right() - qRound(width), startGeometry.top(),
+ qRound(width), qRound(height));
+ break;
+ default:
+ break;
+ }
+}
+
+void QGraphicsWidgetPrivate::windowFrameMouseMoveEvent(QGraphicsSceneMouseEvent *event)
+{
+ Q_Q(QGraphicsWidget);
+ ensureWindowData();
+ if (!(event->buttons() & Qt::LeftButton) || windowData->hoveredSubControl != QStyle::SC_TitleBarLabel)
+ return;
+
+ QLineF delta(q->mapFromScene(event->buttonDownScenePos(Qt::LeftButton)), event->pos());
+ QLineF parentDelta(q->mapToParent(delta.p1()), q->mapToParent(delta.p2()));
+ QLineF parentXDelta(q->mapToParent(QPointF(delta.p1().x(), 0)), q->mapToParent(QPointF(delta.p2().x(), 0)));
+ QLineF parentYDelta(q->mapToParent(QPointF(0, delta.p1().y())), q->mapToParent(QPointF(0, delta.p2().y())));
+
+ QRectF newGeometry;
+ switch (windowData->grabbedSection) {
+ case Qt::LeftSection:
+ newGeometry = QRectF(windowData->startGeometry.topLeft()
+ + QPointF(parentXDelta.dx(), parentXDelta.dy()),
+ windowData->startGeometry.size() - QSizeF(delta.dx(), delta.dy()));
+ break;
+ case Qt::TopLeftSection:
+ newGeometry = QRectF(windowData->startGeometry.topLeft()
+ + QPointF(parentDelta.dx(), parentDelta.dy()),
+ windowData->startGeometry.size() - QSizeF(delta.dx(), delta.dy()));
+ break;
+ case Qt::TopSection:
+ newGeometry = QRectF(windowData->startGeometry.topLeft()
+ + QPointF(parentYDelta.dx(), parentYDelta.dy()),
+ windowData->startGeometry.size() - QSizeF(0, delta.dy()));
+ break;
+ case Qt::TopRightSection:
+ newGeometry = QRectF(windowData->startGeometry.topLeft()
+ + QPointF(parentYDelta.dx(), parentYDelta.dy()),
+ windowData->startGeometry.size() - QSizeF(-delta.dx(), delta.dy()));
+ break;
+ case Qt::RightSection:
+ newGeometry = QRectF(windowData->startGeometry.topLeft(),
+ windowData->startGeometry.size() + QSizeF(delta.dx(), 0));
+ break;
+ case Qt::BottomRightSection:
+ newGeometry = QRectF(windowData->startGeometry.topLeft(),
+ windowData->startGeometry.size() + QSizeF(delta.dx(), delta.dy()));
+ break;
+ case Qt::BottomSection:
+ newGeometry = QRectF(windowData->startGeometry.topLeft(),
+ windowData->startGeometry.size() + QSizeF(0, delta.dy()));
+ break;
+ case Qt::BottomLeftSection:
+ newGeometry = QRectF(windowData->startGeometry.topLeft()
+ + QPointF(parentXDelta.dx(), parentXDelta.dy()),
+ windowData->startGeometry.size() - QSizeF(delta.dx(), -delta.dy()));
+ break;
+ case Qt::TitleBarArea:
+ newGeometry = QRectF(windowData->startGeometry.topLeft()
+ + QPointF(parentDelta.dx(), parentDelta.dy()),
+ windowData->startGeometry.size());
+ break;
+ case Qt::NoSection:
+ break;
+ }
+
+ if (windowData->grabbedSection != Qt::NoSection) {
+ _q_boundGeometryToSizeConstraints(windowData->startGeometry, &newGeometry,
+ windowData->grabbedSection,
+ q->effectiveSizeHint(Qt::MinimumSize),
+ q->effectiveSizeHint(Qt::MaximumSize),
+ q);
+ q->setGeometry(newGeometry);
+ }
+}
+
+void QGraphicsWidgetPrivate::windowFrameHoverMoveEvent(QGraphicsSceneHoverEvent *event)
+{
+ Q_Q(QGraphicsWidget);
+ if (!hasDecoration())
+ return;
+
+ ensureWindowData();
+
+ if (q->rect().contains(event->pos())) {
+ if (windowData->buttonMouseOver || windowData->hoveredSubControl != QStyle::SC_None)
+ windowFrameHoverLeaveEvent(event);
+ return;
+ }
+
+ bool wasMouseOver = windowData->buttonMouseOver;
+ QRect oldButtonRect = windowData->buttonRect;
+ windowData->buttonRect = QRect();
+ windowData->buttonMouseOver = false;
+ QPointF pos = event->pos();
+ QStyleOptionTitleBar bar;
+ // make sure that the coordinates (rect and pos) we send to the style are positive.
+ if (windowFrameMargins) {
+ pos.rx() += windowFrameMargins[Left];
+ pos.ry() += windowFrameMargins[Top];
+ }
+ initStyleOptionTitleBar(&bar);
+ bar.rect = q->windowFrameRect().toRect();
+ bar.rect.moveTo(0,0);
+ bar.rect.setHeight(int(titleBarHeight(bar)));
+
+ Qt::CursorShape cursorShape = Qt::ArrowCursor;
+ bool needsSetCursorCall = true;
+ switch (q->windowFrameSectionAt(event->pos())) {
+ case Qt::TopLeftSection:
+ case Qt::BottomRightSection:
+ cursorShape = Qt::SizeFDiagCursor;
+ break;
+ case Qt::TopRightSection:
+ case Qt::BottomLeftSection:
+ cursorShape = Qt::SizeBDiagCursor;
+ break;
+ case Qt::LeftSection:
+ case Qt::RightSection:
+ cursorShape = Qt::SizeHorCursor;
+ break;
+ case Qt::TopSection:
+ case Qt::BottomSection:
+ cursorShape = Qt::SizeVerCursor;
+ break;
+ case Qt::TitleBarArea:
+ windowData->buttonRect = q->style()->subControlRect(
+ QStyle::CC_TitleBar, &bar, QStyle::SC_TitleBarCloseButton, 0);
+#ifdef Q_WS_MAC
+ // On mac we should hover if we are in the 'area' of the buttons
+ windowData->buttonRect |= q->style()->subControlRect(
+ QStyle::CC_TitleBar, &bar, QStyle::SC_TitleBarMinButton, 0);
+ windowData->buttonRect |= q->style()->subControlRect(
+ QStyle::CC_TitleBar, &bar, QStyle::SC_TitleBarMaxButton, 0);
+#endif
+ if (windowData->buttonRect.contains(pos.toPoint()))
+ windowData->buttonMouseOver = true;
+ event->ignore();
+ break;
+ default:
+ needsSetCursorCall = false;
+ event->ignore();
+ }
+#ifndef QT_NO_CURSOR
+ if (needsSetCursorCall)
+ q->setCursor(cursorShape);
+#endif
+ // update buttons if we hover over them
+ windowData->hoveredSubControl = q->style()->hitTestComplexControl(QStyle::CC_TitleBar, &bar, pos.toPoint(), 0);
+ if (windowData->hoveredSubControl != QStyle::SC_TitleBarCloseButton)
+ windowData->hoveredSubControl = QStyle::SC_TitleBarLabel;
+
+ if (windowData->buttonMouseOver != wasMouseOver) {
+ if (!oldButtonRect.isNull())
+ q->update(QRectF(oldButtonRect).translated(q->windowFrameRect().topLeft()));
+ if (!windowData->buttonRect.isNull())
+ q->update(QRectF(windowData->buttonRect).translated(q->windowFrameRect().topLeft()));
+ }
+}
+
+void QGraphicsWidgetPrivate::windowFrameHoverLeaveEvent(QGraphicsSceneHoverEvent *event)
+{
+ Q_UNUSED(event);
+ Q_Q(QGraphicsWidget);
+ if (hasDecoration()) {
+ // ### restore the cursor, don't override it
+#ifndef QT_NO_CURSOR
+ q->unsetCursor();
+#endif
+
+ ensureWindowData();
+
+ bool needsUpdate = false;
+ if (windowData->hoveredSubControl == QStyle::SC_TitleBarCloseButton
+ || windowData->buttonMouseOver)
+ needsUpdate = true;
+
+ // update the hover state (of buttons etc...)
+ windowData->hoveredSubControl = QStyle::SC_None;
+ windowData->buttonMouseOver = false;
+ windowData->buttonRect = QRect();
+ if (needsUpdate)
+ q->update(windowData->buttonRect);
+ }
+}
+
+bool QGraphicsWidgetPrivate::hasDecoration() const
+{
+ return (windowFlags & Qt::Window) && (windowFlags & Qt::WindowTitleHint);
+}
+
+/**
+ * is called after a reparent has taken place to fix up the focus chain(s)
+ */
+void QGraphicsWidgetPrivate::fixFocusChainBeforeReparenting(QGraphicsWidget *newParent, QGraphicsScene *oldScene, QGraphicsScene *newScene)
+{
+ Q_Q(QGraphicsWidget);
+
+ Q_ASSERT(focusNext && focusPrev);
+
+ QGraphicsWidget *n = q; //last one in 'new' list
+ QGraphicsWidget *o = 0; //last one in 'old' list
+
+ QGraphicsWidget *w = focusNext;
+
+ QGraphicsWidget *firstOld = 0;
+ bool wasPreviousNew = true;
+
+ while (w != q) {
+ bool isCurrentNew = q->isAncestorOf(w);
+ if (isCurrentNew) {
+ if (!wasPreviousNew) {
+ n->d_func()->focusNext = w;
+ w->d_func()->focusPrev = n;
+ }
+ n = w;
+ } else /*if (!isCurrentNew)*/ {
+ if (wasPreviousNew) {
+ if (o) {
+ o->d_func()->focusNext = w;
+ w->d_func()->focusPrev = o;
+ } else {
+ firstOld = w;
+ }
+ }
+ o = w;
+ }
+ w = w->d_func()->focusNext;
+ wasPreviousNew = isCurrentNew;
+ }
+
+ // repair the 'old' chain
+ if (firstOld) {
+ o->d_func()->focusNext = firstOld;
+ firstOld->d_func()->focusPrev = o;
+ }
+
+ // update tabFocusFirst for oldScene if the item is going to be removed from oldScene
+ if (newParent)
+ newScene = newParent->scene();
+
+ if (oldScene && newScene != oldScene)
+ oldScene->d_func()->tabFocusFirst = (firstOld && firstOld->scene() == oldScene) ? firstOld : 0;
+
+ QGraphicsItem *topLevelItem = newParent ? newParent->topLevelItem() : 0;
+ QGraphicsWidget *topLevel = 0;
+ if (topLevelItem && topLevelItem->isWidget())
+ topLevel = static_cast<QGraphicsWidget *>(topLevelItem);
+
+ if (topLevel && newParent) {
+ QGraphicsWidget *last = topLevel->d_func()->focusPrev;
+ // link last with new chain
+ last->d_func()->focusNext = q;
+ focusPrev = last;
+
+ // link last in chain with
+ topLevel->d_func()->focusPrev = n;
+ n->d_func()->focusNext = topLevel;
+ } else {
+ // q is the start of the focus chain
+ n->d_func()->focusNext = q;
+ focusPrev = n;
+ }
+
+}
+
+void QGraphicsWidgetPrivate::setLayout_helper(QGraphicsLayout *l)
+{
+ delete (this->layout);
+ layout = l;
+ if (!l) {
+ Q_Q(QGraphicsWidget);
+ q->updateGeometry();
+ }
+}
+
+qreal QGraphicsWidgetPrivate::width() const
+{
+ Q_Q(const QGraphicsWidget);
+ return q->geometry().width();
+}
+
+void QGraphicsWidgetPrivate::setWidth(qreal w)
+{
+ if (qIsNaN(w))
+ return;
+ Q_Q(QGraphicsWidget);
+ if (q->geometry().width() == w)
+ return;
+
+ q->setGeometry(QRectF(q->x(), q->y(), w, height()));
+}
+
+void QGraphicsWidgetPrivate::resetWidth()
+{
+ Q_Q(QGraphicsWidget);
+ q->setGeometry(QRectF(q->x(), q->y(), 0, height()));
+}
+
+qreal QGraphicsWidgetPrivate::height() const
+{
+ Q_Q(const QGraphicsWidget);
+ return q->geometry().height();
+}
+
+void QGraphicsWidgetPrivate::setHeight(qreal h)
+{
+ if (qIsNaN(h))
+ return;
+ Q_Q(QGraphicsWidget);
+ if (q->geometry().height() == h)
+ return;
+
+ q->setGeometry(QRectF(q->x(), q->y(), width(), h));
+}
+
+void QGraphicsWidgetPrivate::resetHeight()
+{
+ Q_Q(QGraphicsWidget);
+ q->setGeometry(QRectF(q->x(), q->y(), width(), 0));
+}
+
+void QGraphicsWidgetPrivate::setGeometryFromSetPos()
+{
+ if (inSetGeometry)
+ return;
+ Q_Q(QGraphicsWidget);
+ inSetPos = 1;
+ // Ensure setGeometry is called (avoid recursion when setPos is
+ // called from within setGeometry).
+ q->setGeometry(QRectF(pos, q->size()));
+ inSetPos = 0 ;
+}
+
+QT_END_NAMESPACE
+
+#endif //QT_NO_GRAPHICSVIEW
diff --git a/src/widgets/graphicsview/qgraphicswidget_p.h b/src/widgets/graphicsview/qgraphicswidget_p.h
new file mode 100644
index 0000000000..546bac9d46
--- /dev/null
+++ b/src/widgets/graphicsview/qgraphicswidget_p.h
@@ -0,0 +1,226 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGRAPHICSWIDGET_P_H
+#define QGRAPHICSWIDGET_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qobject_p.h>
+#include "qgraphicsitem_p.h"
+#include "qgraphicswidget.h"
+#include <QtGui/qfont.h>
+#include <QtGui/qpalette.h>
+#include <QtWidgets/qsizepolicy.h>
+#include <QtWidgets/qstyle.h>
+
+QT_BEGIN_NAMESPACE
+
+class QGraphicsLayout;
+class QStyleOptionTitleBar;
+
+#if !defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
+
+class QGraphicsWidgetPrivate : public QGraphicsItemPrivate
+{
+ Q_DECLARE_PUBLIC(QGraphicsWidget)
+public:
+ QGraphicsWidgetPrivate()
+ : margins(0),
+ layout(0),
+ inheritedPaletteResolveMask(0),
+ inheritedFontResolveMask(0),
+ inSetGeometry(0),
+ polished(0),
+ inSetPos(0),
+ autoFillBackground(0),
+ focusPolicy(Qt::NoFocus),
+ focusNext(0),
+ focusPrev(0),
+ windowFlags(0),
+ windowData(0),
+ setWindowFrameMargins(false),
+ windowFrameMargins(0)
+ { }
+ virtual ~QGraphicsWidgetPrivate();
+
+ void init(QGraphicsItem *parentItem, Qt::WindowFlags wFlags);
+ qreal titleBarHeight(const QStyleOptionTitleBar &options) const;
+
+ // Margins
+ enum {Left, Top, Right, Bottom};
+ mutable qreal *margins;
+ void ensureMargins() const;
+
+ void fixFocusChainBeforeReparenting(QGraphicsWidget *newParent, QGraphicsScene *oldScene, QGraphicsScene *newScene = 0);
+ void setLayout_helper(QGraphicsLayout *l);
+
+ // Layouts
+ QGraphicsLayout *layout;
+ void setLayoutDirection_helper(Qt::LayoutDirection direction);
+ void resolveLayoutDirection();
+
+ // Style
+ QPalette palette;
+ uint inheritedPaletteResolveMask;
+ void setPalette_helper(const QPalette &palette);
+ void resolvePalette(uint inheritedMask);
+ void updatePalette(const QPalette &palette);
+ QPalette naturalWidgetPalette() const;
+ QFont font;
+ uint inheritedFontResolveMask;
+ void setFont_helper(const QFont &font);
+ void resolveFont(uint inheritedMask);
+ void updateFont(const QFont &font);
+ QFont naturalWidgetFont() const;
+
+ // Window specific
+ void initStyleOptionTitleBar(QStyleOptionTitleBar *option);
+ void adjustWindowFlags(Qt::WindowFlags *wFlags);
+ void windowFrameMouseReleaseEvent(QGraphicsSceneMouseEvent *event);
+ void windowFrameMousePressEvent(QGraphicsSceneMouseEvent *event);
+ void windowFrameMouseMoveEvent(QGraphicsSceneMouseEvent *event);
+ void windowFrameHoverMoveEvent(QGraphicsSceneHoverEvent *event);
+ void windowFrameHoverLeaveEvent(QGraphicsSceneHoverEvent *event);
+ bool hasDecoration() const;
+
+ // Private Properties
+ qreal width() const;
+ void setWidth(qreal);
+ void resetWidth();
+
+ qreal height() const;
+ void setHeight(qreal);
+ void resetHeight();
+ void setGeometryFromSetPos();
+
+ // State
+ inline int attributeToBitIndex(Qt::WidgetAttribute att) const
+ {
+ int bit = -1;
+ switch (att) {
+ case Qt::WA_SetLayoutDirection: bit = 0; break;
+ case Qt::WA_RightToLeft: bit = 1; break;
+ case Qt::WA_SetStyle: bit = 2; break;
+ case Qt::WA_Resized: bit = 3; break;
+ case Qt::WA_DeleteOnClose: bit = 4; break;
+ case Qt::WA_NoSystemBackground: bit = 5; break;
+ case Qt::WA_OpaquePaintEvent: bit = 6; break;
+ case Qt::WA_SetPalette: bit = 7; break;
+ case Qt::WA_SetFont: bit = 8; break;
+ case Qt::WA_WindowPropagation: bit = 9; break;
+ default: break;
+ }
+ return bit;
+ }
+ inline void setAttribute(Qt::WidgetAttribute att, bool value)
+ {
+ int bit = attributeToBitIndex(att);
+ if (bit == -1) {
+ qWarning("QGraphicsWidget::setAttribute: unsupported attribute %d", int(att));
+ return;
+ }
+ if (value)
+ attributes |= (1 << bit);
+ else
+ attributes &= ~(1 << bit);
+ }
+ inline bool testAttribute(Qt::WidgetAttribute att) const
+ {
+ int bit = attributeToBitIndex(att);
+ if (bit == -1)
+ return false;
+ return (attributes & (1 << bit)) != 0;
+ }
+ quint32 attributes : 10;
+ quint32 inSetGeometry : 1;
+ quint32 polished: 1;
+ quint32 inSetPos : 1;
+ quint32 autoFillBackground : 1;
+
+ // Focus
+ Qt::FocusPolicy focusPolicy;
+ QGraphicsWidget *focusNext;
+ QGraphicsWidget *focusPrev;
+
+ // Windows
+ Qt::WindowFlags windowFlags;
+ struct WindowData {
+ QString windowTitle;
+ QStyle::SubControl hoveredSubControl;
+ Qt::WindowFrameSection grabbedSection;
+ uint buttonMouseOver : 1;
+ uint buttonSunken : 1;
+ QRectF startGeometry;
+ QRect buttonRect;
+ WindowData()
+ : hoveredSubControl(QStyle::SC_None)
+ , grabbedSection(Qt::NoSection)
+ , buttonMouseOver(false)
+ , buttonSunken(false)
+ {}
+ } *windowData;
+ void ensureWindowData();
+
+ bool setWindowFrameMargins;
+ mutable qreal *windowFrameMargins;
+ void ensureWindowFrameMargins() const;
+
+#ifndef QT_NO_ACTION
+ QList<QAction *> actions;
+#endif
+};
+
+#endif //!defined(QT_NO_GRAPHICSVIEW) || (QT_EDITION & QT_MODULE_GRAPHICSVIEW) != QT_MODULE_GRAPHICSVIEW
+
+QT_END_NAMESPACE
+
+#endif //QGRAPHICSWIDGET_P_H
+
diff --git a/src/gui/graphicsview/qgridlayoutengine.cpp b/src/widgets/graphicsview/qgridlayoutengine.cpp
index b8586cef21..b8586cef21 100644
--- a/src/gui/graphicsview/qgridlayoutengine.cpp
+++ b/src/widgets/graphicsview/qgridlayoutengine.cpp
diff --git a/src/gui/graphicsview/qgridlayoutengine_p.h b/src/widgets/graphicsview/qgridlayoutengine_p.h
index c5b35f59e8..c5b35f59e8 100644
--- a/src/gui/graphicsview/qgridlayoutengine_p.h
+++ b/src/widgets/graphicsview/qgridlayoutengine_p.h
diff --git a/src/gui/graphicsview/qsimplex_p.cpp b/src/widgets/graphicsview/qsimplex_p.cpp
index d2d9646b90..d2d9646b90 100644
--- a/src/gui/graphicsview/qsimplex_p.cpp
+++ b/src/widgets/graphicsview/qsimplex_p.cpp
diff --git a/src/gui/graphicsview/qsimplex_p.h b/src/widgets/graphicsview/qsimplex_p.h
index e6eced311e..e6eced311e 100644
--- a/src/gui/graphicsview/qsimplex_p.h
+++ b/src/widgets/graphicsview/qsimplex_p.h
diff --git a/src/widgets/inputmethod/inputmethod.pri b/src/widgets/inputmethod/inputmethod.pri
new file mode 100644
index 0000000000..77ca3bd057
--- /dev/null
+++ b/src/widgets/inputmethod/inputmethod.pri
@@ -0,0 +1,27 @@
+# Qt inputmethod module
+
+HEADERS +=inputmethod/qinputcontextfactory.h \
+ inputmethod/qinputcontextplugin.h \
+ inputmethod/qinputcontext_p.h \
+ inputmethod/qinputcontext.h
+SOURCES +=inputmethod/qinputcontextfactory.cpp \
+ inputmethod/qinputcontextplugin.cpp \
+ inputmethod/qinputcontext.cpp
+x11 {
+ HEADERS += inputmethod/qximinputcontext_p.h
+ SOURCES += inputmethod/qximinputcontext_x11.cpp
+}
+win32 {
+ HEADERS += inputmethod/qwininputcontext_p.h
+ SOURCES += inputmethod/qwininputcontext_win.cpp
+}
+mac:!qpa {
+ HEADERS += inputmethod/qmacinputcontext_p.h
+ SOURCES += inputmethod/qmacinputcontext_mac.cpp
+}
+symbian:contains(QT_CONFIG, s60) {
+ HEADERS += inputmethod/qcoefepinputcontext_p.h
+ SOURCES += inputmethod/qcoefepinputcontext_s60.cpp
+ LIBS += -lfepbase -lakninputlanguage
+}
+
diff --git a/src/gui/inputmethod/qcoefepinputcontext_p.h b/src/widgets/inputmethod/qcoefepinputcontext_p.h
index de3577f1a6..de3577f1a6 100644
--- a/src/gui/inputmethod/qcoefepinputcontext_p.h
+++ b/src/widgets/inputmethod/qcoefepinputcontext_p.h
diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/widgets/inputmethod/qcoefepinputcontext_s60.cpp
index 06dc25c708..06dc25c708 100644
--- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
+++ b/src/widgets/inputmethod/qcoefepinputcontext_s60.cpp
diff --git a/src/gui/inputmethod/qinputcontext.cpp b/src/widgets/inputmethod/qinputcontext.cpp
index f083e51981..f083e51981 100644
--- a/src/gui/inputmethod/qinputcontext.cpp
+++ b/src/widgets/inputmethod/qinputcontext.cpp
diff --git a/src/widgets/inputmethod/qinputcontext.h b/src/widgets/inputmethod/qinputcontext.h
new file mode 100644
index 0000000000..a447ae0fd9
--- /dev/null
+++ b/src/widgets/inputmethod/qinputcontext.h
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/****************************************************************************
+**
+** Definition of QInputContext class
+**
+** Copyright (C) 2003-2004 immodule for Qt Project. All rights reserved.
+**
+** This file is written to contribute to Nokia Corporation and/or its subsidiary(-ies) under their own
+** license. You may use this file under your Qt license. Following
+** description is copied from their original file headers. Contact
+** immodule-qt@freedesktop.org if any conditions of this licensing are
+** not clear to you.
+**
+****************************************************************************/
+
+#ifndef QINPUTCONTEXT_H
+#define QINPUTCONTEXT_H
+
+#include <QtCore/qobject.h>
+#include <QtCore/qglobal.h>
+#include <QtGui/qevent.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qlist.h>
+#include <QtWidgets/qaction.h>
+
+#ifndef QT_NO_IM
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QWidget;
+class QFont;
+class QPopupMenu;
+class QInputContextPrivate;
+#ifdef Q_OS_SYMBIAN
+class QSymbianEvent;
+#endif
+
+class Q_GUI_EXPORT QInputContext : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QInputContext)
+public:
+ explicit QInputContext(QObject* parent = 0);
+ virtual ~QInputContext();
+
+ virtual QString identifierName() = 0;
+ virtual QString language() = 0;
+
+ virtual void reset() = 0;
+ virtual void update();
+
+ virtual void mouseHandler( int x, QMouseEvent *event);
+ virtual QFont font() const;
+ virtual bool isComposing() const = 0;
+
+ QWidget *focusWidget() const;
+ virtual void setFocusWidget( QWidget *w );
+
+ virtual void widgetDestroyed(QWidget *w);
+
+ virtual QList<QAction *> actions();
+
+#if defined(Q_WS_X11)
+ virtual bool x11FilterEvent( QWidget *keywidget, XEvent *event );
+#endif // Q_WS_X11
+#if defined(Q_OS_SYMBIAN)
+ virtual bool symbianFilterEvent( QWidget *keywidget, const QSymbianEvent *event );
+#endif // Q_OS_SYMBIAN
+ virtual bool filterEvent( const QEvent *event );
+
+ void sendEvent(const QInputMethodEvent &event);
+
+ enum StandardFormat {
+ PreeditFormat,
+ SelectionFormat
+ };
+ QTextFormat standardFormat(StandardFormat s) const;
+private:
+ friend class QWidget;
+ friend class QWidgetPrivate;
+ friend class QInputContextFactory;
+ friend class QApplication;
+private: // Disabled copy constructor and operator=
+ QInputContext( const QInputContext & );
+ QInputContext &operator=( const QInputContext & );
+
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif //Q_NO_IM
+
+#endif // QINPUTCONTEXT_H
diff --git a/src/gui/inputmethod/qinputcontext_p.h b/src/widgets/inputmethod/qinputcontext_p.h
index be4c141d05..be4c141d05 100644
--- a/src/gui/inputmethod/qinputcontext_p.h
+++ b/src/widgets/inputmethod/qinputcontext_p.h
diff --git a/src/gui/inputmethod/qinputcontextfactory.cpp b/src/widgets/inputmethod/qinputcontextfactory.cpp
index 636e9d5c52..636e9d5c52 100644
--- a/src/gui/inputmethod/qinputcontextfactory.cpp
+++ b/src/widgets/inputmethod/qinputcontextfactory.cpp
diff --git a/src/gui/inputmethod/qinputcontextfactory.h b/src/widgets/inputmethod/qinputcontextfactory.h
index 2382857ae1..2382857ae1 100644
--- a/src/gui/inputmethod/qinputcontextfactory.h
+++ b/src/widgets/inputmethod/qinputcontextfactory.h
diff --git a/src/gui/inputmethod/qinputcontextplugin.cpp b/src/widgets/inputmethod/qinputcontextplugin.cpp
index a83359324a..a83359324a 100644
--- a/src/gui/inputmethod/qinputcontextplugin.cpp
+++ b/src/widgets/inputmethod/qinputcontextplugin.cpp
diff --git a/src/gui/inputmethod/qinputcontextplugin.h b/src/widgets/inputmethod/qinputcontextplugin.h
index 3038298792..3038298792 100644
--- a/src/gui/inputmethod/qinputcontextplugin.h
+++ b/src/widgets/inputmethod/qinputcontextplugin.h
diff --git a/src/gui/inputmethod/qmacinputcontext_mac.cpp b/src/widgets/inputmethod/qmacinputcontext_mac.cpp
index a1ba39c1d6..a1ba39c1d6 100644
--- a/src/gui/inputmethod/qmacinputcontext_mac.cpp
+++ b/src/widgets/inputmethod/qmacinputcontext_mac.cpp
diff --git a/src/widgets/inputmethod/qmacinputcontext_p.h b/src/widgets/inputmethod/qmacinputcontext_p.h
new file mode 100644
index 0000000000..10226d418d
--- /dev/null
+++ b/src/widgets/inputmethod/qmacinputcontext_p.h
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMACINPUTCONTEXT_P_H
+#define QMACINPUTCONTEXT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "QtWidgets/qinputcontext.h"
+#include "private/qt_mac_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class Q_GUI_EXPORT QMacInputContext : public QInputContext
+{
+ Q_OBJECT
+ //Q_DECLARE_PRIVATE(QMacInputContext)
+ void createTextDocument();
+public:
+ explicit QMacInputContext(QObject* parent = 0);
+ virtual ~QMacInputContext();
+
+ virtual void setFocusWidget(QWidget *w);
+ virtual QString identifierName() { return QLatin1String("mac"); }
+ virtual QString language();
+
+ virtual void reset();
+
+ virtual bool isComposing() const;
+
+ static OSStatus globalEventProcessor(EventHandlerCallRef, EventRef, void *);
+ static void initialize();
+ static void cleanup();
+
+ EventRef lastKeydownEvent() { return keydownEvent; }
+ void setLastKeydownEvent(EventRef);
+
+protected:
+ void mouseHandler(int pos, QMouseEvent *);
+private:
+ bool composing;
+ bool recursionGuard;
+ TSMDocumentID textDocument;
+ QString currentText;
+ EventRef keydownEvent;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMACINPUTCONTEXT_P_H
diff --git a/src/widgets/inputmethod/qwininputcontext_p.h b/src/widgets/inputmethod/qwininputcontext_p.h
new file mode 100644
index 0000000000..0fb574cdc6
--- /dev/null
+++ b/src/widgets/inputmethod/qwininputcontext_p.h
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWININPUTCONTEXT_P_H
+#define QWININPUTCONTEXT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of qinputcontext.cpp. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "QtWidgets/qinputcontext.h"
+#include "QtCore/qt_windows.h"
+
+#if !defined(IMR_RECONVERTSTRING)
+typedef struct tagRECONVERTSTRING {
+ DWORD dwSize;
+ DWORD dwVersion;
+ DWORD dwStrLen;
+ DWORD dwStrOffset;
+ DWORD dwCompStrLen;
+ DWORD dwCompStrOffset;
+ DWORD dwTargetStrLen;
+ DWORD dwTargetStrOffset;
+} RECONVERTSTRING, *PRECONVERTSTRING;
+#endif
+
+QT_BEGIN_NAMESPACE
+
+class QWinInputContext : public QInputContext
+{
+ Q_OBJECT
+public:
+ explicit QWinInputContext(QObject* parent = 0);
+ virtual ~QWinInputContext();
+
+ virtual QString identifierName() { return QLatin1String("win"); }
+ virtual QString language();
+
+ virtual void reset();
+ virtual void update();
+
+ virtual void mouseHandler(int x, QMouseEvent *event);
+ virtual bool isComposing() const;
+
+ virtual void setFocusWidget(QWidget *w);
+
+ bool startComposition();
+ bool endComposition();
+ bool composition(LPARAM lparam);
+ int reconvertString(RECONVERTSTRING *reconv);
+
+ static void TranslateMessage(const MSG *msg);
+ static LRESULT DefWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+
+ static void updateImeStatus(QWidget *w, bool hasFocus);
+ static void enablePopupChild(QWidget *w, bool e);
+ static void enable(QWidget *w, bool e);
+
+private:
+ void init();
+ bool recursionGuard;
+};
+
+QT_END_NAMESPACE
+
+#endif // QWININPUTCONTEXT_P_H
diff --git a/src/gui/inputmethod/qwininputcontext_win.cpp b/src/widgets/inputmethod/qwininputcontext_win.cpp
index 4289cf4191..4289cf4191 100644
--- a/src/gui/inputmethod/qwininputcontext_win.cpp
+++ b/src/widgets/inputmethod/qwininputcontext_win.cpp
diff --git a/src/widgets/inputmethod/qximinputcontext_p.h b/src/widgets/inputmethod/qximinputcontext_p.h
new file mode 100644
index 0000000000..69b4fee9b3
--- /dev/null
+++ b/src/widgets/inputmethod/qximinputcontext_p.h
@@ -0,0 +1,142 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/****************************************************************************
+**
+** Definition of QXIMInputContext class
+**
+** Copyright (C) 2003-2004 immodule for Qt Project. All rights reserved.
+**
+** This file is written to contribute to Nokia Corporation and/or its subsidiary(-ies) under their own
+** license. You may use this file under your Qt license. Following
+** description is copied from their original file headers. Contact
+** immodule-qt@freedesktop.org if any conditions of this licensing are
+** not clear to you.
+**
+****************************************************************************/
+
+#ifndef QXIMINPUTCONTEXT_P_H
+#define QXIMINPUTCONTEXT_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.
+//
+
+#if !defined(Q_NO_IM)
+
+#include "QtCore/qglobal.h"
+#include "QtWidgets/qinputcontext.h"
+#include "QtGui/qfont.h"
+#include "QtCore/qhash.h"
+#ifdef Q_WS_X11
+#include "QtCore/qlist.h"
+#include "QtCore/qbitarray.h"
+#include "QtGui/qwindowdefs.h"
+#include "private/qt_x11_p.h"
+#endif
+
+QT_BEGIN_NAMESPACE
+
+class QKeyEvent;
+class QWidget;
+class QFont;
+class QString;
+
+class QXIMInputContext : public QInputContext
+{
+ Q_OBJECT
+public:
+ struct ICData {
+ XIC ic;
+ XFontSet fontset;
+ QWidget *widget;
+ QString text;
+ QBitArray selectedChars;
+ bool composing;
+ bool preeditEmpty;
+ void clear();
+ };
+
+ QXIMInputContext();
+ ~QXIMInputContext();
+
+ QString identifierName();
+ QString language();
+
+ void reset();
+
+ void mouseHandler( int x, QMouseEvent *event);
+ bool isComposing() const;
+
+ void setFocusWidget( QWidget *w );
+ void widgetDestroyed(QWidget *w);
+
+ void create_xim();
+ void close_xim();
+
+ void update();
+
+ ICData *icData() const;
+protected:
+ bool x11FilterEvent( QWidget *keywidget, XEvent *event );
+
+private:
+ static XIMStyle xim_style;
+
+ QString _language;
+ XIM xim;
+ QHash<WId, ICData *> ximData;
+
+ ICData *createICData(QWidget *w);
+};
+
+QT_END_NAMESPACE
+
+#endif // Q_NO_IM
+
+#endif // QXIMINPUTCONTEXT_P_H
diff --git a/src/gui/inputmethod/qximinputcontext_x11.cpp b/src/widgets/inputmethod/qximinputcontext_x11.cpp
index 155796828e..155796828e 100644
--- a/src/gui/inputmethod/qximinputcontext_x11.cpp
+++ b/src/widgets/inputmethod/qximinputcontext_x11.cpp
diff --git a/src/gui/itemviews/itemviews.pri b/src/widgets/itemviews/itemviews.pri
index bbc1e983ba..bbc1e983ba 100644
--- a/src/gui/itemviews/itemviews.pri
+++ b/src/widgets/itemviews/itemviews.pri
diff --git a/src/gui/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp
index 478c4747ef..478c4747ef 100644
--- a/src/gui/itemviews/qabstractitemdelegate.cpp
+++ b/src/widgets/itemviews/qabstractitemdelegate.cpp
diff --git a/src/widgets/itemviews/qabstractitemdelegate.h b/src/widgets/itemviews/qabstractitemdelegate.h
new file mode 100644
index 0000000000..a0ce7c715c
--- /dev/null
+++ b/src/widgets/itemviews/qabstractitemdelegate.h
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QABSTRACTITEMDELEGATE_H
+#define QABSTRACTITEMDELEGATE_H
+
+#include <QtCore/qobject.h>
+#include <QtWidgets/qstyleoption.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_ITEMVIEWS
+
+class QPainter;
+class QModelIndex;
+class QAbstractItemModel;
+class QAbstractItemView;
+class QHelpEvent;
+
+class Q_GUI_EXPORT QAbstractItemDelegate : public QObject
+{
+ Q_OBJECT
+
+public:
+
+ enum EndEditHint {
+ NoHint,
+ EditNextItem,
+ EditPreviousItem,
+ SubmitModelCache,
+ RevertModelCache
+ };
+
+ explicit QAbstractItemDelegate(QObject *parent = 0);
+ virtual ~QAbstractItemDelegate();
+
+ // painting
+ virtual void paint(QPainter *painter,
+ const QStyleOptionViewItem &option,
+ const QModelIndex &index) const = 0;
+
+ virtual QSize sizeHint(const QStyleOptionViewItem &option,
+ const QModelIndex &index) const = 0;
+
+ // editing
+ virtual QWidget *createEditor(QWidget *parent,
+ const QStyleOptionViewItem &option,
+ const QModelIndex &index) const;
+
+ virtual void setEditorData(QWidget *editor, const QModelIndex &index) const;
+
+ virtual void setModelData(QWidget *editor,
+ QAbstractItemModel *model,
+ const QModelIndex &index) const;
+
+ virtual void updateEditorGeometry(QWidget *editor,
+ const QStyleOptionViewItem &option,
+ const QModelIndex &index) const;
+
+ // for non-widget editors
+ virtual bool editorEvent(QEvent *event,
+ QAbstractItemModel *model,
+ const QStyleOptionViewItem &option,
+ const QModelIndex &index);
+
+ static QString elidedText(const QFontMetrics &fontMetrics, int width,
+ Qt::TextElideMode mode, const QString &text);
+
+public Q_SLOTS:
+ bool helpEvent(QHelpEvent *event,
+ QAbstractItemView *view,
+ const QStyleOptionViewItem &option,
+ const QModelIndex &index);
+
+Q_SIGNALS:
+ void commitData(QWidget *editor);
+ void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint = NoHint);
+ void sizeHintChanged(const QModelIndex &);
+
+protected:
+ QAbstractItemDelegate(QObjectPrivate &, QObject *parent = 0);
+private:
+ Q_DISABLE_COPY(QAbstractItemDelegate)
+};
+
+#endif // QT_NO_ITEMVIEWS
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QABSTRACTITEMDELEGATE_H
diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp
index d6714968b5..d6714968b5 100644
--- a/src/gui/itemviews/qabstractitemview.cpp
+++ b/src/widgets/itemviews/qabstractitemview.cpp
diff --git a/src/widgets/itemviews/qabstractitemview.h b/src/widgets/itemviews/qabstractitemview.h
new file mode 100644
index 0000000000..7ca5400566
--- /dev/null
+++ b/src/widgets/itemviews/qabstractitemview.h
@@ -0,0 +1,380 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QABSTRACTITEMVIEW_H
+#define QABSTRACTITEMVIEW_H
+
+#include <QtWidgets/qabstractscrollarea.h>
+#include <QtCore/qabstractitemmodel.h>
+#include <QtWidgets/qitemselectionmodel.h>
+#include <QtWidgets/qabstractitemdelegate.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_ITEMVIEWS
+
+class QMenu;
+class QDrag;
+class QEvent;
+class QAbstractItemViewPrivate;
+
+class Q_GUI_EXPORT QAbstractItemView : public QAbstractScrollArea
+{
+ Q_OBJECT
+ Q_ENUMS(SelectionMode SelectionBehavior ScrollHint ScrollMode DragDropMode)
+ Q_FLAGS(EditTriggers)
+ Q_PROPERTY(bool autoScroll READ hasAutoScroll WRITE setAutoScroll)
+ Q_PROPERTY(int autoScrollMargin READ autoScrollMargin WRITE setAutoScrollMargin)
+ Q_PROPERTY(EditTriggers editTriggers READ editTriggers WRITE setEditTriggers)
+ Q_PROPERTY(bool tabKeyNavigation READ tabKeyNavigation WRITE setTabKeyNavigation)
+#ifndef QT_NO_DRAGANDDROP
+ Q_PROPERTY(bool showDropIndicator READ showDropIndicator WRITE setDropIndicatorShown)
+ Q_PROPERTY(bool dragEnabled READ dragEnabled WRITE setDragEnabled)
+ Q_PROPERTY(bool dragDropOverwriteMode READ dragDropOverwriteMode WRITE setDragDropOverwriteMode)
+ Q_PROPERTY(DragDropMode dragDropMode READ dragDropMode WRITE setDragDropMode)
+ Q_PROPERTY(Qt::DropAction defaultDropAction READ defaultDropAction WRITE setDefaultDropAction)
+#endif
+ Q_PROPERTY(bool alternatingRowColors READ alternatingRowColors WRITE setAlternatingRowColors)
+ Q_PROPERTY(SelectionMode selectionMode READ selectionMode WRITE setSelectionMode)
+ Q_PROPERTY(SelectionBehavior selectionBehavior READ selectionBehavior WRITE setSelectionBehavior)
+ Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
+ Q_PROPERTY(Qt::TextElideMode textElideMode READ textElideMode WRITE setTextElideMode)
+ Q_PROPERTY(ScrollMode verticalScrollMode READ verticalScrollMode WRITE setVerticalScrollMode)
+ Q_PROPERTY(ScrollMode horizontalScrollMode READ horizontalScrollMode WRITE setHorizontalScrollMode)
+
+public:
+ enum SelectionMode {
+ NoSelection,
+ SingleSelection,
+ MultiSelection,
+ ExtendedSelection,
+ ContiguousSelection
+ };
+
+ enum SelectionBehavior {
+ SelectItems,
+ SelectRows,
+ SelectColumns
+ };
+
+ enum ScrollHint {
+ EnsureVisible,
+ PositionAtTop,
+ PositionAtBottom,
+ PositionAtCenter
+ };
+
+ enum EditTrigger {
+ NoEditTriggers = 0,
+ CurrentChanged = 1,
+ DoubleClicked = 2,
+ SelectedClicked = 4,
+ EditKeyPressed = 8,
+ AnyKeyPressed = 16,
+ AllEditTriggers = 31
+ };
+
+ Q_DECLARE_FLAGS(EditTriggers, EditTrigger)
+
+ enum ScrollMode {
+ ScrollPerItem,
+ ScrollPerPixel
+ };
+
+ explicit QAbstractItemView(QWidget *parent = 0);
+ ~QAbstractItemView();
+
+ virtual void setModel(QAbstractItemModel *model);
+ QAbstractItemModel *model() const;
+
+ virtual void setSelectionModel(QItemSelectionModel *selectionModel);
+ QItemSelectionModel *selectionModel() const;
+
+ void setItemDelegate(QAbstractItemDelegate *delegate);
+ QAbstractItemDelegate *itemDelegate() const;
+
+ void setSelectionMode(QAbstractItemView::SelectionMode mode);
+ QAbstractItemView::SelectionMode selectionMode() const;
+
+ void setSelectionBehavior(QAbstractItemView::SelectionBehavior behavior);
+ QAbstractItemView::SelectionBehavior selectionBehavior() const;
+
+ QModelIndex currentIndex() const;
+ QModelIndex rootIndex() const;
+
+ void setEditTriggers(EditTriggers triggers);
+ EditTriggers editTriggers() const;
+
+ void setVerticalScrollMode(ScrollMode mode);
+ ScrollMode verticalScrollMode() const;
+
+ void setHorizontalScrollMode(ScrollMode mode);
+ ScrollMode horizontalScrollMode() const;
+
+ void setAutoScroll(bool enable);
+ bool hasAutoScroll() const;
+
+ void setAutoScrollMargin(int margin);
+ int autoScrollMargin() const;
+
+ void setTabKeyNavigation(bool enable);
+ bool tabKeyNavigation() const;
+
+#ifndef QT_NO_DRAGANDDROP
+ void setDropIndicatorShown(bool enable);
+ bool showDropIndicator() const;
+
+ void setDragEnabled(bool enable);
+ bool dragEnabled() const;
+
+ void setDragDropOverwriteMode(bool overwrite);
+ bool dragDropOverwriteMode() const;
+
+ enum DragDropMode {
+ NoDragDrop,
+ DragOnly,
+ DropOnly,
+ DragDrop,
+ InternalMove
+ };
+
+ void setDragDropMode(DragDropMode behavior);
+ DragDropMode dragDropMode() const;
+
+ void setDefaultDropAction(Qt::DropAction dropAction);
+ Qt::DropAction defaultDropAction() const;
+#endif
+
+ void setAlternatingRowColors(bool enable);
+ bool alternatingRowColors() const;
+
+ void setIconSize(const QSize &size);
+ QSize iconSize() const;
+
+ void setTextElideMode(Qt::TextElideMode mode);
+ Qt::TextElideMode textElideMode() const;
+
+ virtual void keyboardSearch(const QString &search);
+
+ virtual QRect visualRect(const QModelIndex &index) const = 0;
+ virtual void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible) = 0;
+ virtual QModelIndex indexAt(const QPoint &point) const = 0;
+
+ QSize sizeHintForIndex(const QModelIndex &index) const;
+ virtual int sizeHintForRow(int row) const;
+ virtual int sizeHintForColumn(int column) const;
+
+ void openPersistentEditor(const QModelIndex &index);
+ void closePersistentEditor(const QModelIndex &index);
+
+ void setIndexWidget(const QModelIndex &index, QWidget *widget);
+ QWidget *indexWidget(const QModelIndex &index) const;
+
+ void setItemDelegateForRow(int row, QAbstractItemDelegate *delegate);
+ QAbstractItemDelegate *itemDelegateForRow(int row) const;
+
+ void setItemDelegateForColumn(int column, QAbstractItemDelegate *delegate);
+ QAbstractItemDelegate *itemDelegateForColumn(int column) const;
+
+ QAbstractItemDelegate *itemDelegate(const QModelIndex &index) const;
+
+ virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
+
+#ifdef Q_NO_USING_KEYWORD
+ inline void update() { QAbstractScrollArea::update(); }
+#else
+ using QAbstractScrollArea::update;
+#endif
+
+public Q_SLOTS:
+ virtual void reset();
+ virtual void setRootIndex(const QModelIndex &index);
+ virtual void doItemsLayout();
+ virtual void selectAll();
+ void edit(const QModelIndex &index);
+ void clearSelection();
+ void setCurrentIndex(const QModelIndex &index);
+ void scrollToTop();
+ void scrollToBottom();
+ void update(const QModelIndex &index);
+
+protected Q_SLOTS:
+ virtual void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+ virtual void rowsInserted(const QModelIndex &parent, int start, int end);
+ virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
+ virtual void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
+ virtual void currentChanged(const QModelIndex &current, const QModelIndex &previous);
+ virtual void updateEditorData();
+ virtual void updateEditorGeometries();
+ virtual void updateGeometries();
+ virtual void verticalScrollbarAction(int action);
+ virtual void horizontalScrollbarAction(int action);
+ virtual void verticalScrollbarValueChanged(int value);
+ virtual void horizontalScrollbarValueChanged(int value);
+ virtual void closeEditor(QWidget *editor, QAbstractItemDelegate::EndEditHint hint);
+ virtual void commitData(QWidget *editor);
+ virtual void editorDestroyed(QObject *editor);
+
+Q_SIGNALS:
+ void pressed(const QModelIndex &index);
+ void clicked(const QModelIndex &index);
+ void doubleClicked(const QModelIndex &index);
+
+ void activated(const QModelIndex &index);
+ void entered(const QModelIndex &index);
+ void viewportEntered();
+
+protected:
+ QAbstractItemView(QAbstractItemViewPrivate &, QWidget *parent = 0);
+
+ void setHorizontalStepsPerItem(int steps);
+ int horizontalStepsPerItem() const;
+ void setVerticalStepsPerItem(int steps);
+ int verticalStepsPerItem() const;
+
+ enum CursorAction { MoveUp, MoveDown, MoveLeft, MoveRight,
+ MoveHome, MoveEnd, MovePageUp, MovePageDown,
+ MoveNext, MovePrevious };
+ virtual QModelIndex moveCursor(CursorAction cursorAction,
+ Qt::KeyboardModifiers modifiers) = 0;
+
+ virtual int horizontalOffset() const = 0;
+ virtual int verticalOffset() const = 0;
+
+ virtual bool isIndexHidden(const QModelIndex &index) const = 0;
+
+ virtual void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) = 0;
+ virtual QRegion visualRegionForSelection(const QItemSelection &selection) const = 0;
+ virtual QModelIndexList selectedIndexes() const;
+
+ virtual bool edit(const QModelIndex &index, EditTrigger trigger, QEvent *event);
+
+ virtual QItemSelectionModel::SelectionFlags selectionCommand(const QModelIndex &index,
+ const QEvent *event = 0) const;
+
+#ifndef QT_NO_DRAGANDDROP
+ virtual void startDrag(Qt::DropActions supportedActions);
+#endif
+
+ virtual QStyleOptionViewItem viewOptions() const;
+
+ enum State {
+ NoState,
+ DraggingState,
+ DragSelectingState,
+ EditingState,
+ ExpandingState,
+ CollapsingState,
+ AnimatingState
+ };
+
+ State state() const;
+ void setState(State state);
+
+ void scheduleDelayedItemsLayout();
+ void executeDelayedItemsLayout();
+
+ void setDirtyRegion(const QRegion &region);
+ void scrollDirtyRegion(int dx, int dy);
+ QPoint dirtyRegionOffset() const;
+
+ void startAutoScroll();
+ void stopAutoScroll();
+ void doAutoScroll();
+
+ bool focusNextPrevChild(bool next);
+ bool event(QEvent *event);
+ bool viewportEvent(QEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *event);
+ void mouseDoubleClickEvent(QMouseEvent *event);
+#ifndef QT_NO_DRAGANDDROP
+ void dragEnterEvent(QDragEnterEvent *event);
+ void dragMoveEvent(QDragMoveEvent *event);
+ void dragLeaveEvent(QDragLeaveEvent *event);
+ void dropEvent(QDropEvent *event);
+#endif
+ void focusInEvent(QFocusEvent *event);
+ void focusOutEvent(QFocusEvent *event);
+ void keyPressEvent(QKeyEvent *event);
+ void resizeEvent(QResizeEvent *event);
+ void timerEvent(QTimerEvent *event);
+ void inputMethodEvent(QInputMethodEvent *event);
+
+#ifndef QT_NO_DRAGANDDROP
+ enum DropIndicatorPosition { OnItem, AboveItem, BelowItem, OnViewport };
+ DropIndicatorPosition dropIndicatorPosition() const;
+#endif
+
+private:
+ Q_DECLARE_PRIVATE(QAbstractItemView)
+ Q_DISABLE_COPY(QAbstractItemView)
+ Q_PRIVATE_SLOT(d_func(), void _q_columnsAboutToBeRemoved(const QModelIndex&, int, int))
+ Q_PRIVATE_SLOT(d_func(), void _q_columnsRemoved(const QModelIndex&, int, int))
+ Q_PRIVATE_SLOT(d_func(), void _q_columnsInserted(const QModelIndex&, int, int))
+ Q_PRIVATE_SLOT(d_func(), void _q_rowsRemoved(const QModelIndex&, int, int))
+ Q_PRIVATE_SLOT(d_func(), void _q_modelDestroyed())
+ Q_PRIVATE_SLOT(d_func(), void _q_layoutChanged())
+ Q_PRIVATE_SLOT(d_func(), void _q_headerDataChanged())
+#ifndef QT_NO_GESTURES
+ Q_PRIVATE_SLOT(d_func(), void _q_scrollerStateChanged())
+#endif
+
+ friend class QTreeViewPrivate; // needed to compile with MSVC
+ friend class QAccessibleItemRow;
+ friend class QListModeViewBase;
+ friend class QListViewPrivate; // needed to compile for Symbian emulator
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractItemView::EditTriggers)
+
+#endif // QT_NO_ITEMVIEWS
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QABSTRACTITEMVIEW_H
diff --git a/src/widgets/itemviews/qabstractitemview_p.h b/src/widgets/itemviews/qabstractitemview_p.h
new file mode 100644
index 0000000000..26ad627d90
--- /dev/null
+++ b/src/widgets/itemviews/qabstractitemview_p.h
@@ -0,0 +1,457 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QABSTRACTITEMVIEW_P_H
+#define QABSTRACTITEMVIEW_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "private/qabstractscrollarea_p.h"
+#include "private/qabstractitemmodel_p.h"
+#include "QtWidgets/qapplication.h"
+#include "QtGui/qevent.h"
+#include "QtGui/qmime.h"
+#include "QtGui/qpainter.h"
+#include "QtCore/qpair.h"
+#include "QtGui/qregion.h"
+#include "QtCore/qdebug.h"
+#include "QtGui/qpainter.h"
+#include "QtCore/qbasictimer.h"
+#include "QtCore/qelapsedtimer.h"
+
+#ifndef QT_NO_ITEMVIEWS
+
+QT_BEGIN_NAMESPACE
+
+struct QEditorInfo {
+ QEditorInfo(QWidget *e, bool s): widget(QWeakPointer<QWidget>(e)), isStatic(s) {}
+ QEditorInfo(): isStatic(false) {}
+
+ QWeakPointer<QWidget> widget;
+ bool isStatic;
+};
+
+// Fast associativity between Persistent editors and indices.
+typedef QHash<QWidget *, QPersistentModelIndex> QEditorIndexHash;
+typedef QHash<QPersistentModelIndex, QEditorInfo> QIndexEditorHash;
+
+typedef QPair<QRect, QModelIndex> QItemViewPaintPair;
+typedef QList<QItemViewPaintPair> QItemViewPaintPairs;
+
+class QEmptyModel : public QAbstractItemModel
+{
+public:
+ explicit QEmptyModel(QObject *parent = 0) : QAbstractItemModel(parent) {}
+ QModelIndex index(int, int, const QModelIndex &) const { return QModelIndex(); }
+ QModelIndex parent(const QModelIndex &) const { return QModelIndex(); }
+ int rowCount(const QModelIndex &) const { return 0; }
+ int columnCount(const QModelIndex &) const { return 0; }
+ bool hasChildren(const QModelIndex &) const { return false; }
+ QVariant data(const QModelIndex &, int) const { return QVariant(); }
+};
+
+class Q_AUTOTEST_EXPORT QAbstractItemViewPrivate : public QAbstractScrollAreaPrivate
+{
+ Q_DECLARE_PUBLIC(QAbstractItemView)
+
+public:
+ QAbstractItemViewPrivate();
+ virtual ~QAbstractItemViewPrivate();
+
+ void init();
+
+ virtual void _q_rowsRemoved(const QModelIndex &parent, int start, int end);
+ virtual void _q_columnsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
+ virtual void _q_columnsRemoved(const QModelIndex &parent, int start, int end);
+ virtual void _q_columnsInserted(const QModelIndex &parent, int start, int end);
+ virtual void _q_modelDestroyed();
+ virtual void _q_layoutChanged();
+ void _q_headerDataChanged() { doDelayedItemsLayout(); }
+ void _q_scrollerStateChanged();
+
+ void fetchMore();
+
+ bool shouldEdit(QAbstractItemView::EditTrigger trigger, const QModelIndex &index) const;
+ bool shouldForwardEvent(QAbstractItemView::EditTrigger trigger, const QEvent *event) const;
+ bool shouldAutoScroll(const QPoint &pos) const;
+ void doDelayedItemsLayout(int delay = 0);
+ void interruptDelayedItemsLayout() const;
+
+ void startAutoScroll()
+ { // ### it would be nice to make this into a style hint one day
+ int scrollInterval = (verticalScrollMode == QAbstractItemView::ScrollPerItem) ? 150 : 50;
+ autoScrollTimer.start(scrollInterval, q_func());
+ autoScrollCount = 0;
+ }
+ void stopAutoScroll() { autoScrollTimer.stop(); autoScrollCount = 0;}
+
+#ifndef QT_NO_DRAGANDDROP
+ virtual bool dropOn(QDropEvent *event, int *row, int *col, QModelIndex *index);
+#endif
+ bool droppingOnItself(QDropEvent *event, const QModelIndex &index);
+
+ QWidget *editor(const QModelIndex &index, const QStyleOptionViewItem &options);
+ bool sendDelegateEvent(const QModelIndex &index, QEvent *event) const;
+ bool openEditor(const QModelIndex &index, QEvent *event);
+ void updateEditorData(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+
+ QItemSelectionModel::SelectionFlags multiSelectionCommand(const QModelIndex &index,
+ const QEvent *event) const;
+ QItemSelectionModel::SelectionFlags extendedSelectionCommand(const QModelIndex &index,
+ const QEvent *event) const;
+ QItemSelectionModel::SelectionFlags contiguousSelectionCommand(const QModelIndex &index,
+ const QEvent *event) const;
+ virtual void selectAll(QItemSelectionModel::SelectionFlags command);
+
+ void setHoverIndex(const QPersistentModelIndex &index);
+
+ void checkMouseMove(const QPersistentModelIndex &index);
+ inline void checkMouseMove(const QPoint &pos) { checkMouseMove(q_func()->indexAt(pos)); }
+
+ inline QItemSelectionModel::SelectionFlags selectionBehaviorFlags() const
+ {
+ switch (selectionBehavior) {
+ case QAbstractItemView::SelectRows: return QItemSelectionModel::Rows;
+ case QAbstractItemView::SelectColumns: return QItemSelectionModel::Columns;
+ case QAbstractItemView::SelectItems: default: return QItemSelectionModel::NoUpdate;
+ }
+ }
+
+#ifndef QT_NO_DRAGANDDROP
+ virtual QAbstractItemView::DropIndicatorPosition position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const;
+
+ inline bool canDecode(QDropEvent *e) const {
+ QStringList modelTypes = model->mimeTypes();
+ const QMimeData *mime = e->mimeData();
+ for (int i = 0; i < modelTypes.count(); ++i)
+ if (mime->hasFormat(modelTypes.at(i))
+ && (e->dropAction() & model->supportedDropActions()))
+ return true;
+ return false;
+ }
+
+ inline void paintDropIndicator(QPainter *painter)
+ {
+ if (showDropIndicator && state == QAbstractItemView::DraggingState
+#ifndef QT_NO_CURSOR
+ && viewport->cursor().shape() != Qt::ForbiddenCursor
+#endif
+ ) {
+ QStyleOption opt;
+ opt.init(q_func());
+ opt.rect = dropIndicatorRect;
+ q_func()->style()->drawPrimitive(QStyle::PE_IndicatorItemViewItemDrop, &opt, painter, q_func());
+ }
+ }
+
+#endif
+ virtual QItemViewPaintPairs draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const;
+
+ inline void releaseEditor(QWidget *editor) const {
+ if (editor) {
+ QObject::disconnect(editor, SIGNAL(destroyed(QObject*)),
+ q_func(), SLOT(editorDestroyed(QObject*)));
+ editor->removeEventFilter(itemDelegate);
+ editor->hide();
+ editor->deleteLater();
+ }
+ }
+
+ inline void executePostedLayout() const {
+ if (delayedPendingLayout && state != QAbstractItemView::CollapsingState) {
+ interruptDelayedItemsLayout();
+ const_cast<QAbstractItemView*>(q_func())->doItemsLayout();
+ }
+ }
+
+ inline void setDirtyRegion(const QRegion &visualRegion) {
+ updateRegion += visualRegion;
+ if (!updateTimer.isActive())
+ updateTimer.start(0, q_func());
+ }
+
+ inline void scrollDirtyRegion(int dx, int dy) {
+ scrollDelayOffset = QPoint(-dx, -dy);
+ updateDirtyRegion();
+ scrollDelayOffset = QPoint(0, 0);
+ }
+
+ inline void scrollContentsBy(int dx, int dy) {
+ scrollDirtyRegion(dx, dy);
+ viewport->scroll(dx, dy);
+ }
+
+ void updateDirtyRegion() {
+ updateTimer.stop();
+ viewport->update(updateRegion);
+ updateRegion = QRegion();
+ }
+
+ void clearOrRemove();
+ void checkPersistentEditorFocus();
+
+ QPixmap renderToPixmap(const QModelIndexList &indexes, QRect *r) const;
+
+ inline QPoint offset() const {
+ const Q_Q(QAbstractItemView);
+ return QPoint(q->isRightToLeft() ? -q->horizontalOffset()
+ : q->horizontalOffset(), q->verticalOffset());
+ }
+
+ const QEditorInfo &editorForIndex(const QModelIndex &index) const;
+ inline bool hasEditor(const QModelIndex &index) const {
+ return indexEditorHash.find(index) != indexEditorHash.constEnd();
+ }
+
+ QModelIndex indexForEditor(QWidget *editor) const;
+ void addEditor(const QModelIndex &index, QWidget *editor, bool isStatic);
+ void removeEditor(QWidget *editor);
+
+ inline bool isAnimating() const {
+ return state == QAbstractItemView::AnimatingState;
+ }
+
+ inline QAbstractItemDelegate *delegateForIndex(const QModelIndex &index) const {
+ QAbstractItemDelegate *del;
+ if ((del = rowDelegates.value(index.row(), 0))) return del;
+ if ((del = columnDelegates.value(index.column(), 0))) return del;
+ return itemDelegate;
+ }
+
+ inline bool isIndexValid(const QModelIndex &index) const {
+ return (index.row() >= 0) && (index.column() >= 0) && (index.model() == model);
+ }
+ inline bool isIndexSelectable(const QModelIndex &index) const {
+ return (model->flags(index) & Qt::ItemIsSelectable);
+ }
+ inline bool isIndexEnabled(const QModelIndex &index) const {
+ return (model->flags(index) & Qt::ItemIsEnabled);
+ }
+ inline bool isIndexDropEnabled(const QModelIndex &index) const {
+ return (model->flags(index) & Qt::ItemIsDropEnabled);
+ }
+ inline bool isIndexDragEnabled(const QModelIndex &index) const {
+ return (model->flags(index) & Qt::ItemIsDragEnabled);
+ }
+
+ virtual bool selectionAllowed(const QModelIndex &index) const {
+ // in some views we want to go ahead with selections, even if the index is invalid
+ return isIndexValid(index) && isIndexSelectable(index);
+ }
+
+ // reimplemented from QAbstractScrollAreaPrivate
+ virtual QPoint contentsOffset() const {
+ Q_Q(const QAbstractItemView);
+ return QPoint(q->horizontalOffset(), q->verticalOffset());
+ }
+
+ /**
+ * For now, assume that we have few editors, if we need a more efficient implementation
+ * we should add a QMap<QAbstractItemDelegate*, int> member.
+ */
+ int delegateRefCount(const QAbstractItemDelegate *delegate) const
+ {
+ int ref = 0;
+ if (itemDelegate == delegate)
+ ++ref;
+
+ for (int maps = 0; maps < 2; ++maps) {
+ const QMap<int, QPointer<QAbstractItemDelegate> > *delegates = maps ? &columnDelegates : &rowDelegates;
+ for (QMap<int, QPointer<QAbstractItemDelegate> >::const_iterator it = delegates->begin();
+ it != delegates->end(); ++it) {
+ if (it.value() == delegate) {
+ ++ref;
+ // optimization, we are only interested in the ref count values 0, 1 or >=2
+ if (ref >= 2) {
+ return ref;
+ }
+ }
+ }
+ }
+ return ref;
+ }
+
+ /**
+ * return true if the index is registered as a QPersistentModelIndex
+ */
+ inline bool isPersistent(const QModelIndex &index) const
+ {
+ return static_cast<QAbstractItemModelPrivate *>(model->d_ptr.data())->persistent.indexes.contains(index);
+ }
+
+ QModelIndexList selectedDraggableIndexes() const;
+
+ QStyleOptionViewItemV4 viewOptionsV4() const;
+
+ void doDelayedReset()
+ {
+ //we delay the reset of the timer because some views (QTableView)
+ //with headers can't handle the fact that the model has been destroyed
+ //all _q_modelDestroyed slots must have been called
+ if (!delayedReset.isActive())
+ delayedReset.start(0, q_func());
+ }
+
+ QAbstractItemModel *model;
+ QPointer<QAbstractItemDelegate> itemDelegate;
+ QMap<int, QPointer<QAbstractItemDelegate> > rowDelegates;
+ QMap<int, QPointer<QAbstractItemDelegate> > columnDelegates;
+ QPointer<QItemSelectionModel> selectionModel;
+ QItemSelectionModel::SelectionFlag ctrlDragSelectionFlag;
+ bool noSelectionOnMousePress;
+
+ QAbstractItemView::SelectionMode selectionMode;
+ QAbstractItemView::SelectionBehavior selectionBehavior;
+
+ QEditorIndexHash editorIndexHash;
+ QIndexEditorHash indexEditorHash;
+ QSet<QWidget*> persistent;
+ QWidget *currentlyCommittingEditor;
+
+ QPersistentModelIndex enteredIndex;
+ QPersistentModelIndex pressedIndex;
+ Qt::KeyboardModifiers pressedModifiers;
+ QPoint pressedPosition;
+ bool pressedAlreadySelected;
+
+ //forces the next mouseMoveEvent to send the viewportEntered signal
+ //if the mouse is over the viewport and not over an item
+ bool viewportEnteredNeeded;
+
+ QAbstractItemView::State state;
+ QAbstractItemView::State stateBeforeAnimation;
+ QAbstractItemView::EditTriggers editTriggers;
+ QAbstractItemView::EditTrigger lastTrigger;
+
+ QPersistentModelIndex root;
+ QPersistentModelIndex hover;
+
+ bool tabKeyNavigation;
+
+#ifndef QT_NO_DRAGANDDROP
+ bool showDropIndicator;
+ QRect dropIndicatorRect;
+ bool dragEnabled;
+ QAbstractItemView::DragDropMode dragDropMode;
+ bool overwrite;
+ QAbstractItemView::DropIndicatorPosition dropIndicatorPosition;
+ Qt::DropAction defaultDropAction;
+#endif
+
+#ifdef QT_SOFTKEYS_ENABLED
+ QAction *doneSoftKey;
+#endif
+
+ QString keyboardInput;
+ QElapsedTimer keyboardInputTime;
+
+ bool autoScroll;
+ QBasicTimer autoScrollTimer;
+ int autoScrollMargin;
+ int autoScrollCount;
+ bool shouldScrollToCurrentOnShow; //used to know if we should scroll to current on show event
+ bool shouldClearStatusTip; //if there is a statustip currently shown that need to be cleared when leaving.
+
+ bool alternatingColors;
+
+ QSize iconSize;
+ Qt::TextElideMode textElideMode;
+
+ QRegion updateRegion; // used for the internal update system
+ QPoint scrollDelayOffset;
+
+ QBasicTimer updateTimer;
+ QBasicTimer delayedEditing;
+ QBasicTimer delayedAutoScroll; //used when an item is clicked
+ QBasicTimer delayedReset;
+
+ QAbstractItemView::ScrollMode verticalScrollMode;
+ QAbstractItemView::ScrollMode horizontalScrollMode;
+
+#ifndef QT_NO_GESTURES
+ // the selection before the last mouse down. In case we have to restore it for scrolling
+ QItemSelection oldSelection;
+ QModelIndex oldCurrent;
+#endif
+
+ bool currentIndexSet;
+
+ bool wrapItemText;
+ mutable bool delayedPendingLayout;
+ bool moveCursorUpdatedView;
+
+private:
+ mutable QBasicTimer delayedLayout;
+ mutable QBasicTimer fetchMoreTimer;
+};
+
+QT_BEGIN_INCLUDE_NAMESPACE
+#include <qvector.h>
+QT_END_INCLUDE_NAMESPACE
+
+template <typename T>
+inline int qBinarySearch(const QVector<T> &vec, const T &item, int start, int end)
+{
+ int i = (start + end + 1) >> 1;
+ while (end - start > 0) {
+ if (vec.at(i) > item)
+ end = i - 1;
+ else
+ start = i;
+ i = (start + end + 1) >> 1;
+ }
+ return i;
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_ITEMVIEWS
+
+#endif // QABSTRACTITEMVIEW_P_H
diff --git a/src/gui/itemviews/qabstractproxymodel.cpp b/src/widgets/itemviews/qabstractproxymodel.cpp
index 82b6c8d26a..82b6c8d26a 100644
--- a/src/gui/itemviews/qabstractproxymodel.cpp
+++ b/src/widgets/itemviews/qabstractproxymodel.cpp
diff --git a/src/gui/itemviews/qabstractproxymodel.h b/src/widgets/itemviews/qabstractproxymodel.h
index 4f3bc18448..4f3bc18448 100644
--- a/src/gui/itemviews/qabstractproxymodel.h
+++ b/src/widgets/itemviews/qabstractproxymodel.h
diff --git a/src/gui/itemviews/qabstractproxymodel_p.h b/src/widgets/itemviews/qabstractproxymodel_p.h
index 3e6e35a29f..3e6e35a29f 100644
--- a/src/gui/itemviews/qabstractproxymodel_p.h
+++ b/src/widgets/itemviews/qabstractproxymodel_p.h
diff --git a/src/gui/itemviews/qbsptree.cpp b/src/widgets/itemviews/qbsptree.cpp
index ffe3ae8a10..ffe3ae8a10 100644
--- a/src/gui/itemviews/qbsptree.cpp
+++ b/src/widgets/itemviews/qbsptree.cpp
diff --git a/src/gui/itemviews/qbsptree_p.h b/src/widgets/itemviews/qbsptree_p.h
index f5b559a6d9..f5b559a6d9 100644
--- a/src/gui/itemviews/qbsptree_p.h
+++ b/src/widgets/itemviews/qbsptree_p.h
diff --git a/src/gui/itemviews/qcolumnview.cpp b/src/widgets/itemviews/qcolumnview.cpp
index a44ecc7779..a44ecc7779 100644
--- a/src/gui/itemviews/qcolumnview.cpp
+++ b/src/widgets/itemviews/qcolumnview.cpp
diff --git a/src/widgets/itemviews/qcolumnview.h b/src/widgets/itemviews/qcolumnview.h
new file mode 100644
index 0000000000..42747c2d25
--- /dev/null
+++ b/src/widgets/itemviews/qcolumnview.h
@@ -0,0 +1,123 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCOLUMNVIEW_H
+#define QCOLUMNVIEW_H
+
+#include <QtWidgets/qabstractitemview.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_COLUMNVIEW
+
+class QColumnViewPrivate;
+
+class Q_GUI_EXPORT QColumnView : public QAbstractItemView {
+
+Q_OBJECT
+ Q_PROPERTY(bool resizeGripsVisible READ resizeGripsVisible WRITE setResizeGripsVisible)
+
+Q_SIGNALS:
+ void updatePreviewWidget(const QModelIndex &index);
+
+public:
+ explicit QColumnView(QWidget *parent = 0);
+ ~QColumnView();
+
+ // QAbstractItemView overloads
+ QModelIndex indexAt(const QPoint &point) const;
+ void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible);
+ QSize sizeHint() const;
+ QRect visualRect(const QModelIndex &index) const;
+ void setModel(QAbstractItemModel *model);
+ void setSelectionModel(QItemSelectionModel * selectionModel);
+ void setRootIndex(const QModelIndex &index);
+ void selectAll();
+
+ // QColumnView functions
+ void setResizeGripsVisible(bool visible);
+ bool resizeGripsVisible() const;
+
+ QWidget *previewWidget() const;
+ void setPreviewWidget(QWidget *widget);
+
+ void setColumnWidths(const QList<int> &list);
+ QList<int> columnWidths() const;
+
+protected:
+ QColumnView(QColumnViewPrivate &dd, QWidget *parent = 0);
+
+ // QAbstractItemView overloads
+ bool isIndexHidden(const QModelIndex &index) const;
+ QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
+ void resizeEvent(QResizeEvent *event);
+ void setSelection(const QRect & rect, QItemSelectionModel::SelectionFlags command);
+ QRegion visualRegionForSelection(const QItemSelection &selection) const;
+ int horizontalOffset() const;
+ int verticalOffset() const;
+ void rowsInserted(const QModelIndex &parent, int start, int end);
+ void currentChanged(const QModelIndex &current, const QModelIndex &previous);
+
+ // QColumnView functions
+ void scrollContentsBy(int dx, int dy);
+ virtual QAbstractItemView* createColumn(const QModelIndex &rootIndex);
+ void initializeColumn(QAbstractItemView *column) const;
+
+private:
+ Q_DECLARE_PRIVATE(QColumnView)
+ Q_DISABLE_COPY(QColumnView)
+ Q_PRIVATE_SLOT(d_func(), void _q_gripMoved(int))
+ Q_PRIVATE_SLOT(d_func(), void _q_changeCurrentColumn())
+ Q_PRIVATE_SLOT(d_func(), void _q_clicked(const QModelIndex &))
+};
+
+#endif // QT_NO_COLUMNVIEW
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QCOLUMNVIEW_H
+
diff --git a/src/widgets/itemviews/qcolumnview_p.h b/src/widgets/itemviews/qcolumnview_p.h
new file mode 100644
index 0000000000..2bda4b1213
--- /dev/null
+++ b/src/widgets/itemviews/qcolumnview_p.h
@@ -0,0 +1,189 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCOLUMNVIEW_P_H
+#define QCOLUMNVIEW_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qcolumnview.h"
+
+#ifndef QT_NO_QCOLUMNVIEW
+
+#include <private/qabstractitemview_p.h>
+
+#include <QtCore/qabstractitemmodel.h>
+#include <QtCore/qpropertyanimation.h>
+#include <QtWidgets/qabstractitemdelegate.h>
+#include <QtWidgets/qabstractitemview.h>
+#include <QtWidgets/qitemdelegate.h>
+#include <qlistview.h>
+#include <qevent.h>
+#include <qscrollbar.h>
+
+QT_BEGIN_NAMESPACE
+
+class QColumnViewPreviewColumn : public QAbstractItemView {
+
+public:
+ QColumnViewPreviewColumn(QWidget *parent) : QAbstractItemView(parent), previewWidget(0) {
+ }
+
+ void setPreviewWidget(QWidget *widget) {
+ previewWidget = widget;
+ setMinimumWidth(previewWidget->minimumWidth());
+ }
+
+ void resizeEvent(QResizeEvent * event){
+ if (!previewWidget)
+ return;
+ previewWidget->resize(
+ qMax(previewWidget->minimumWidth(), event->size().width()),
+ previewWidget->height());
+ QSize p = viewport()->size();
+ QSize v = previewWidget->size();
+ horizontalScrollBar()->setRange(0, v.width() - p.width());
+ horizontalScrollBar()->setPageStep(p.width());
+ verticalScrollBar()->setRange(0, v.height() - p.height());
+ verticalScrollBar()->setPageStep(p.height());
+
+ QAbstractScrollArea::resizeEvent(event);
+ }
+
+ QRect visualRect(const QModelIndex &) const
+ {
+ return QRect();
+ }
+ void scrollTo(const QModelIndex &, ScrollHint)
+ {
+ }
+ QModelIndex indexAt(const QPoint &) const
+ {
+ return QModelIndex();
+ }
+ QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers)
+ {
+ return QModelIndex();
+ }
+ int horizontalOffset () const {
+ return 0;
+ }
+ int verticalOffset () const {
+ return 0;
+ }
+ QRegion visualRegionForSelection(const QItemSelection &) const
+ {
+ return QRegion();
+ }
+ bool isIndexHidden(const QModelIndex &) const
+ {
+ return false;
+ }
+ void setSelection(const QRect &, QItemSelectionModel::SelectionFlags)
+ {
+ }
+private:
+ QWidget *previewWidget;
+};
+
+class Q_AUTOTEST_EXPORT QColumnViewPrivate : public QAbstractItemViewPrivate
+{
+ Q_DECLARE_PUBLIC(QColumnView)
+
+public:
+ QColumnViewPrivate();
+ ~QColumnViewPrivate();
+ void initialize();
+
+ QAbstractItemView *createColumn(const QModelIndex &index, bool show);
+
+ void updateScrollbars();
+ void closeColumns(const QModelIndex &parent = QModelIndex(), bool build = false);
+ void doLayout();
+ void setPreviewWidget(QWidget *widget);
+ void checkColumnCreation(const QModelIndex &parent);
+
+
+ void _q_gripMoved(int offset);
+ void _q_changeCurrentColumn();
+ void _q_clicked(const QModelIndex &index);
+ void _q_columnsInserted(const QModelIndex &parent, int start, int end);
+
+ QList<QAbstractItemView*> columns;
+ QVector<int> columnSizes; // used during init and corner moving
+ bool showResizeGrips;
+ int offset;
+#ifndef QT_NO_ANIMATION
+ QPropertyAnimation currentAnimation;
+#endif
+ QWidget *previewWidget;
+ QAbstractItemView *previewColumn;
+};
+
+/*!
+ * This is a delegate that will paint the triangle
+ */
+class QColumnViewDelegate : public QItemDelegate
+{
+
+public:
+ explicit QColumnViewDelegate(QObject *parent = 0) : QItemDelegate(parent) {}
+ ~QColumnViewDelegate() {}
+
+ void paint(QPainter *painter,
+ const QStyleOptionViewItem &option,
+ const QModelIndex &index) const;
+};
+#endif // QT_NO_QCOLUMNVIEW
+
+
+QT_END_NAMESPACE
+#endif //QCOLUMNVIEW_P_H
+
diff --git a/src/gui/itemviews/qcolumnviewgrip.cpp b/src/widgets/itemviews/qcolumnviewgrip.cpp
index 5cd448cc35..5cd448cc35 100644
--- a/src/gui/itemviews/qcolumnviewgrip.cpp
+++ b/src/widgets/itemviews/qcolumnviewgrip.cpp
diff --git a/src/gui/itemviews/qcolumnviewgrip_p.h b/src/widgets/itemviews/qcolumnviewgrip_p.h
index a621f953ea..a621f953ea 100644
--- a/src/gui/itemviews/qcolumnviewgrip_p.h
+++ b/src/widgets/itemviews/qcolumnviewgrip_p.h
diff --git a/src/gui/itemviews/qdatawidgetmapper.cpp b/src/widgets/itemviews/qdatawidgetmapper.cpp
index dac4613071..dac4613071 100644
--- a/src/gui/itemviews/qdatawidgetmapper.cpp
+++ b/src/widgets/itemviews/qdatawidgetmapper.cpp
diff --git a/src/gui/itemviews/qdatawidgetmapper.h b/src/widgets/itemviews/qdatawidgetmapper.h
index 9485cb08a8..9485cb08a8 100644
--- a/src/gui/itemviews/qdatawidgetmapper.h
+++ b/src/widgets/itemviews/qdatawidgetmapper.h
diff --git a/src/gui/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp
index 203ac69c12..203ac69c12 100644
--- a/src/gui/itemviews/qdirmodel.cpp
+++ b/src/widgets/itemviews/qdirmodel.cpp
diff --git a/src/widgets/itemviews/qdirmodel.h b/src/widgets/itemviews/qdirmodel.h
new file mode 100644
index 0000000000..b081dfd34c
--- /dev/null
+++ b/src/widgets/itemviews/qdirmodel.h
@@ -0,0 +1,160 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDIRMODEL_H
+#define QDIRMODEL_H
+
+#include <QtCore/qabstractitemmodel.h>
+#include <QtCore/qdir.h>
+#include <QtWidgets/qfileiconprovider.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_DIRMODEL
+
+class QDirModelPrivate;
+
+class Q_GUI_EXPORT QDirModel : public QAbstractItemModel
+{
+ Q_OBJECT
+ Q_PROPERTY(bool resolveSymlinks READ resolveSymlinks WRITE setResolveSymlinks)
+ Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
+ Q_PROPERTY(bool lazyChildCount READ lazyChildCount WRITE setLazyChildCount)
+
+public:
+ enum Roles {
+ FileIconRole = Qt::DecorationRole,
+ FilePathRole = Qt::UserRole + 1,
+ FileNameRole
+ };
+
+ QDirModel(const QStringList &nameFilters, QDir::Filters filters,
+ QDir::SortFlags sort, QObject *parent = 0);
+ explicit QDirModel(QObject *parent = 0);
+ ~QDirModel();
+
+ 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;
+
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
+
+ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
+
+ bool hasChildren(const QModelIndex &index = QModelIndex()) const;
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+
+ void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
+
+ QStringList mimeTypes() const;
+ QMimeData *mimeData(const QModelIndexList &indexes) const;
+ bool dropMimeData(const QMimeData *data, Qt::DropAction action,
+ int row, int column, const QModelIndex &parent);
+ Qt::DropActions supportedDropActions() const;
+
+ // QDirModel specific API
+
+ void setIconProvider(QFileIconProvider *provider);
+ QFileIconProvider *iconProvider() const;
+
+ void setNameFilters(const QStringList &filters);
+ QStringList nameFilters() const;
+
+ void setFilter(QDir::Filters filters);
+ QDir::Filters filter() const;
+
+ void setSorting(QDir::SortFlags sort);
+ QDir::SortFlags sorting() const;
+
+ void setResolveSymlinks(bool enable);
+ bool resolveSymlinks() const;
+
+ void setReadOnly(bool enable);
+ bool isReadOnly() const;
+
+ void setLazyChildCount(bool enable);
+ bool lazyChildCount() const;
+
+ QModelIndex index(const QString &path, int column = 0) const;
+
+ bool isDir(const QModelIndex &index) const;
+ QModelIndex mkdir(const QModelIndex &parent, const QString &name);
+ bool rmdir(const QModelIndex &index);
+ bool remove(const QModelIndex &index);
+
+ QString filePath(const QModelIndex &index) const;
+ QString fileName(const QModelIndex &index) const;
+ QIcon fileIcon(const QModelIndex &index) const;
+ QFileInfo fileInfo(const QModelIndex &index) const;
+
+#ifdef Q_NO_USING_KEYWORD
+ inline QObject *parent() const { return QObject::parent(); }
+#else
+ using QObject::parent;
+#endif
+
+public Q_SLOTS:
+ void refresh(const QModelIndex &parent = QModelIndex());
+
+protected:
+ QDirModel(QDirModelPrivate &, QObject *parent = 0);
+ friend class QFileDialogPrivate;
+
+private:
+ Q_DECLARE_PRIVATE(QDirModel)
+ Q_DISABLE_COPY(QDirModel)
+ Q_PRIVATE_SLOT(d_func(), void _q_refresh())
+};
+
+#endif // QT_NO_DIRMODEL
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDIRMODEL_H
diff --git a/src/gui/itemviews/qfileiconprovider.cpp b/src/widgets/itemviews/qfileiconprovider.cpp
index ae93054cf3..ae93054cf3 100644
--- a/src/gui/itemviews/qfileiconprovider.cpp
+++ b/src/widgets/itemviews/qfileiconprovider.cpp
diff --git a/src/widgets/itemviews/qfileiconprovider.h b/src/widgets/itemviews/qfileiconprovider.h
new file mode 100644
index 0000000000..4950618979
--- /dev/null
+++ b/src/widgets/itemviews/qfileiconprovider.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QFILEICONPROVIDER_H
+#define QFILEICONPROVIDER_H
+
+#include <QtCore/qfileinfo.h>
+#include <QtCore/qscopedpointer.h>
+#include <QtWidgets/qicon.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_FILEICONPROVIDER
+
+class QFileIconProviderPrivate;
+
+class Q_GUI_EXPORT QFileIconProvider
+{
+public:
+ QFileIconProvider();
+ virtual ~QFileIconProvider();
+ enum IconType { Computer, Desktop, Trashcan, Network, Drive, Folder, File };
+ virtual QIcon icon(IconType type) const;
+ virtual QIcon icon(const QFileInfo &info) const;
+ virtual QString type(const QFileInfo &info) const;
+
+private:
+ Q_DECLARE_PRIVATE(QFileIconProvider)
+ QScopedPointer<QFileIconProviderPrivate> d_ptr;
+ Q_DISABLE_COPY(QFileIconProvider)
+};
+
+#endif // QT_NO_FILEICONPROVIDER
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QFILEICONPROVIDER_H
+
diff --git a/src/gui/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp
index 471c199bc2..471c199bc2 100644
--- a/src/gui/itemviews/qheaderview.cpp
+++ b/src/widgets/itemviews/qheaderview.cpp
diff --git a/src/widgets/itemviews/qheaderview.h b/src/widgets/itemviews/qheaderview.h
new file mode 100644
index 0000000000..422fc7d8ff
--- /dev/null
+++ b/src/widgets/itemviews/qheaderview.h
@@ -0,0 +1,250 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QHEADERVIEW_H
+#define QHEADERVIEW_H
+
+#include <QtWidgets/qabstractitemview.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_ITEMVIEWS
+
+class QHeaderViewPrivate;
+class QStyleOptionHeader;
+
+class Q_GUI_EXPORT QHeaderView : public QAbstractItemView
+{
+ Q_OBJECT
+ Q_PROPERTY(bool showSortIndicator READ isSortIndicatorShown WRITE setSortIndicatorShown)
+ Q_PROPERTY(bool highlightSections READ highlightSections WRITE setHighlightSections)
+ Q_PROPERTY(bool stretchLastSection READ stretchLastSection WRITE setStretchLastSection)
+ Q_PROPERTY(bool cascadingSectionResizes READ cascadingSectionResizes WRITE setCascadingSectionResizes)
+ Q_PROPERTY(int defaultSectionSize READ defaultSectionSize WRITE setDefaultSectionSize)
+ Q_PROPERTY(int minimumSectionSize READ minimumSectionSize WRITE setMinimumSectionSize)
+ Q_PROPERTY(Qt::Alignment defaultAlignment READ defaultAlignment WRITE setDefaultAlignment)
+ Q_ENUMS(ResizeMode)
+
+public:
+
+ enum ResizeMode
+ {
+ Interactive,
+ Stretch,
+ Fixed,
+ ResizeToContents,
+ Custom = Fixed
+ };
+
+ explicit QHeaderView(Qt::Orientation orientation, QWidget *parent = 0);
+ virtual ~QHeaderView();
+
+ void setModel(QAbstractItemModel *model);
+
+ Qt::Orientation orientation() const;
+ int offset() const;
+ int length() const;
+ QSize sizeHint() const;
+ int sectionSizeHint(int logicalIndex) const;
+
+ int visualIndexAt(int position) const;
+ int logicalIndexAt(int position) const;
+
+ inline int logicalIndexAt(int x, int y) const;
+ inline int logicalIndexAt(const QPoint &pos) const;
+
+ int sectionSize(int logicalIndex) const;
+ int sectionPosition(int logicalIndex) const;
+ int sectionViewportPosition(int logicalIndex) const;
+
+ void moveSection(int from, int to);
+ void swapSections(int first, int second);
+ void resizeSection(int logicalIndex, int size);
+ void resizeSections(QHeaderView::ResizeMode mode);
+
+ bool isSectionHidden(int logicalIndex) const;
+ void setSectionHidden(int logicalIndex, bool hide);
+ int hiddenSectionCount() const;
+
+ inline void hideSection(int logicalIndex);
+ inline void showSection(int logicalIndex);
+
+ int count() const;
+ int visualIndex(int logicalIndex) const;
+ int logicalIndex(int visualIndex) const;
+
+ void setMovable(bool movable);
+ bool isMovable() const;
+
+ void setClickable(bool clickable);
+ bool isClickable() const;
+
+ void setHighlightSections(bool highlight);
+ bool highlightSections() const;
+
+ void setResizeMode(ResizeMode mode);
+ void setResizeMode(int logicalIndex, ResizeMode mode);
+ ResizeMode resizeMode(int logicalIndex) const;
+ int stretchSectionCount() const;
+
+ void setSortIndicatorShown(bool show);
+ bool isSortIndicatorShown() const;
+
+ void setSortIndicator(int logicalIndex, Qt::SortOrder order);
+ int sortIndicatorSection() const;
+ Qt::SortOrder sortIndicatorOrder() const;
+
+ bool stretchLastSection() const;
+ void setStretchLastSection(bool stretch);
+
+ bool cascadingSectionResizes() const;
+ void setCascadingSectionResizes(bool enable);
+
+ int defaultSectionSize() const;
+ void setDefaultSectionSize(int size);
+
+ int minimumSectionSize() const;
+ void setMinimumSectionSize(int size);
+
+ Qt::Alignment defaultAlignment() const;
+ void setDefaultAlignment(Qt::Alignment alignment);
+
+ void doItemsLayout();
+ bool sectionsMoved() const;
+ bool sectionsHidden() const;
+
+#ifndef QT_NO_DATASTREAM
+ QByteArray saveState() const;
+ bool restoreState(const QByteArray &state);
+#endif
+
+ void reset();
+
+public Q_SLOTS:
+ void setOffset(int offset);
+ void setOffsetToSectionPosition(int visualIndex);
+ void setOffsetToLastSection();
+ void headerDataChanged(Qt::Orientation orientation, int logicalFirst, int logicalLast);
+
+Q_SIGNALS:
+ void sectionMoved(int logicalIndex, int oldVisualIndex, int newVisualIndex);
+ void sectionResized(int logicalIndex, int oldSize, int newSize);
+ void sectionPressed(int logicalIndex);
+ void sectionClicked(int logicalIndex);
+ void sectionEntered(int logicalIndex);
+ void sectionDoubleClicked(int logicalIndex);
+ void sectionCountChanged(int oldCount, int newCount);
+ void sectionHandleDoubleClicked(int logicalIndex);
+ void sectionAutoResize(int logicalIndex, QHeaderView::ResizeMode mode);
+ void geometriesChanged();
+ void sortIndicatorChanged(int logicalIndex, Qt::SortOrder order);
+
+protected Q_SLOTS:
+ void updateSection(int logicalIndex);
+ void resizeSections();
+ void sectionsInserted(const QModelIndex &parent, int logicalFirst, int logicalLast);
+ void sectionsAboutToBeRemoved(const QModelIndex &parent, int logicalFirst, int logicalLast);
+
+protected:
+ QHeaderView(QHeaderViewPrivate &dd, Qt::Orientation orientation, QWidget *parent = 0);
+ void initialize();
+
+ void initializeSections();
+ void initializeSections(int start, int end);
+ void currentChanged(const QModelIndex &current, const QModelIndex &old);
+
+ bool event(QEvent *e);
+ void paintEvent(QPaintEvent *e);
+ void mousePressEvent(QMouseEvent *e);
+ void mouseMoveEvent(QMouseEvent *e);
+ void mouseReleaseEvent(QMouseEvent *e);
+ void mouseDoubleClickEvent(QMouseEvent *e);
+ bool viewportEvent(QEvent *e);
+
+ virtual void paintSection(QPainter *painter, const QRect &rect, int logicalIndex) const;
+ virtual QSize sectionSizeFromContents(int logicalIndex) const;
+
+ int horizontalOffset() const;
+ int verticalOffset() const;
+ void updateGeometries();
+ void scrollContentsBy(int dx, int dy);
+
+ void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+ void rowsInserted(const QModelIndex &parent, int start, int end);
+
+ QRect visualRect(const QModelIndex &index) const;
+ void scrollTo(const QModelIndex &index, ScrollHint hint);
+
+ QModelIndex indexAt(const QPoint &p) const;
+ bool isIndexHidden(const QModelIndex &index) const;
+
+ QModelIndex moveCursor(CursorAction, Qt::KeyboardModifiers);
+ void setSelection(const QRect& rect, QItemSelectionModel::SelectionFlags flags);
+ QRegion visualRegionForSelection(const QItemSelection &selection) const;
+ void initStyleOption(QStyleOptionHeader *option) const;
+
+private:
+ Q_PRIVATE_SLOT(d_func(), void _q_sectionsRemoved(const QModelIndex &parent, int logicalFirst, int logicalLast))
+ Q_PRIVATE_SLOT(d_func(), void _q_layoutAboutToBeChanged())
+ Q_DECLARE_PRIVATE(QHeaderView)
+ Q_DISABLE_COPY(QHeaderView)
+};
+
+inline int QHeaderView::logicalIndexAt(int ax, int ay) const
+{ return orientation() == Qt::Horizontal ? logicalIndexAt(ax) : logicalIndexAt(ay); }
+inline int QHeaderView::logicalIndexAt(const QPoint &apos) const
+{ return logicalIndexAt(apos.x(), apos.y()); }
+inline void QHeaderView::hideSection(int alogicalIndex)
+{ setSectionHidden(alogicalIndex, true); }
+inline void QHeaderView::showSection(int alogicalIndex)
+{ setSectionHidden(alogicalIndex, false); }
+
+#endif // QT_NO_ITEMVIEWS
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QHEADERVIEW_H
diff --git a/src/widgets/itemviews/qheaderview_p.h b/src/widgets/itemviews/qheaderview_p.h
new file mode 100644
index 0000000000..aeeff6b223
--- /dev/null
+++ b/src/widgets/itemviews/qheaderview_p.h
@@ -0,0 +1,366 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QHEADERVIEW_P_H
+#define QHEADERVIEW_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "private/qabstractitemview_p.h"
+
+#ifndef QT_NO_ITEMVIEWS
+
+#include "QtCore/qbitarray.h"
+#include "QtWidgets/qapplication.h"
+#include "QtWidgets/qlabel.h"
+
+QT_BEGIN_NAMESPACE
+
+class QHeaderViewPrivate: public QAbstractItemViewPrivate
+{
+ Q_DECLARE_PUBLIC(QHeaderView)
+
+public:
+ enum StateVersion { VersionMarker = 0xff };
+
+ QHeaderViewPrivate()
+ : state(NoState),
+ offset(0),
+ sortIndicatorOrder(Qt::DescendingOrder),
+ sortIndicatorSection(0),
+ sortIndicatorShown(false),
+ lastPos(-1),
+ firstPos(-1),
+ originalSize(-1),
+ section(-1),
+ target(-1),
+ pressed(-1),
+ hover(-1),
+ length(0),
+ sectionCount(0),
+ movableSections(false),
+ clickableSections(false),
+ highlightSelected(false),
+ stretchLastSection(false),
+ cascadingResizing(false),
+ resizeRecursionBlock(false),
+ stretchSections(0),
+ contentsSections(0),
+ minimumSectionSize(-1),
+ lastSectionSize(0),
+ sectionIndicatorOffset(0),
+ sectionIndicator(0),
+ globalResizeMode(QHeaderView::Interactive)
+ {}
+
+
+ int lastVisibleVisualIndex() const;
+ int sectionHandleAt(int position);
+ void setupSectionIndicator(int section, int position);
+ void updateSectionIndicator(int section, int position);
+ void updateHiddenSections(int logicalFirst, int logicalLast);
+ void resizeSections(QHeaderView::ResizeMode globalMode, bool useGlobalMode = false);
+ void _q_sectionsRemoved(const QModelIndex &,int,int);
+ void _q_layoutAboutToBeChanged();
+ void _q_layoutChanged();
+
+ bool isSectionSelected(int section) const;
+
+ inline bool rowIntersectsSelection(int row) const {
+ return (selectionModel ? selectionModel->rowIntersectsSelection(row, root) : false);
+ }
+
+ inline bool columnIntersectsSelection(int column) const {
+ return (selectionModel ? selectionModel->columnIntersectsSelection(column, root) : false);
+ }
+
+ inline bool sectionIntersectsSelection(int logical) const {
+ return (orientation == Qt::Horizontal ? columnIntersectsSelection(logical) : rowIntersectsSelection(logical));
+ }
+
+ inline bool isRowSelected(int row) const {
+ return (selectionModel ? selectionModel->isRowSelected(row, root) : false);
+ }
+
+ inline bool isColumnSelected(int column) const {
+ return (selectionModel ? selectionModel->isColumnSelected(column, root) : false);
+ }
+
+ inline void prepareSectionSelected() {
+ if (!selectionModel || !selectionModel->hasSelection())
+ sectionSelected.clear();
+ else if (sectionSelected.count() != sectionCount * 2)
+ sectionSelected.fill(false, sectionCount * 2);
+ else sectionSelected.fill(false);
+ }
+
+ inline bool reverse() const {
+ return orientation == Qt::Horizontal && q_func()->isRightToLeft();
+ }
+
+ inline int logicalIndex(int visualIndex) const {
+ return logicalIndices.isEmpty() ? visualIndex : logicalIndices.at(visualIndex);
+ }
+
+ inline int visualIndex(int logicalIndex) const {
+ return visualIndices.isEmpty() ? logicalIndex : visualIndices.at(logicalIndex);
+ }
+
+ inline void setDefaultValues(Qt::Orientation o) {
+ orientation = o;
+ defaultSectionSize = (o == Qt::Horizontal ? 100
+ : qMax(q_func()->minimumSectionSize(), 30));
+ defaultAlignment = (o == Qt::Horizontal
+ ? Qt::Alignment(Qt::AlignCenter)
+ : Qt::AlignLeft|Qt::AlignVCenter);
+ }
+
+ inline bool isVisualIndexHidden(int visual) const {
+ return !sectionHidden.isEmpty() && sectionHidden.at(visual);
+ }
+
+ inline void setVisualIndexHidden(int visual, bool hidden) {
+ if (!sectionHidden.isEmpty()) sectionHidden.setBit(visual, hidden);
+ }
+
+ inline bool hasAutoResizeSections() const {
+ return stretchSections || stretchLastSection || contentsSections;
+ }
+
+ QStyleOptionHeader getStyleOption() const;
+
+ inline void invalidateCachedSizeHint() const {
+ cachedSizeHint = QSize();
+ }
+
+ inline void initializeIndexMapping() const {
+ if (visualIndices.count() != sectionCount
+ || logicalIndices.count() != sectionCount) {
+ visualIndices.resize(sectionCount);
+ logicalIndices.resize(sectionCount);
+ for (int s = 0; s < sectionCount; ++s) {
+ visualIndices[s] = s;
+ logicalIndices[s] = s;
+ }
+ }
+ }
+
+ inline void clearCascadingSections() {
+ firstCascadingSection = sectionCount;
+ lastCascadingSection = 0;
+ cascadingSectionSize.clear();
+ }
+
+ inline void saveCascadingSectionSize(int visual, int size) {
+ if (!cascadingSectionSize.contains(visual)) {
+ cascadingSectionSize.insert(visual, size);
+ firstCascadingSection = qMin(firstCascadingSection, visual);
+ lastCascadingSection = qMax(lastCascadingSection, visual);
+ }
+ }
+
+ inline bool sectionIsCascadable(int visual) const {
+ return headerSectionResizeMode(visual) == QHeaderView::Interactive;
+ }
+
+ inline int modelSectionCount() const {
+ return (orientation == Qt::Horizontal
+ ? model->columnCount(root)
+ : model->rowCount(root));
+ }
+
+ inline bool modelIsEmpty() const {
+ return (model->rowCount(root) == 0 || model->columnCount(root) == 0);
+ }
+
+ inline void doDelayedResizeSections() {
+ if (!delayedResize.isActive())
+ delayedResize.start(0, q_func());
+ }
+
+ inline void executePostedResize() const {
+ if (delayedResize.isActive() && state == NoState) {
+ const_cast<QHeaderView*>(q_func())->resizeSections();
+ }
+ }
+
+ void clear();
+ void flipSortIndicator(int section);
+ void cascadingResize(int visual, int newSize);
+
+ enum State { NoState, ResizeSection, MoveSection, SelectSections, NoClear } state;
+
+ int offset;
+ Qt::Orientation orientation;
+ Qt::SortOrder sortIndicatorOrder;
+ int sortIndicatorSection;
+ bool sortIndicatorShown;
+
+ mutable QVector<int> visualIndices; // visualIndex = visualIndices.at(logicalIndex)
+ mutable QVector<int> logicalIndices; // logicalIndex = row or column in the model
+ mutable QBitArray sectionSelected; // from logical index to bit
+ mutable QBitArray sectionHidden; // from visual index to bit
+ mutable QHash<int, int> hiddenSectionSize; // from logical index to section size
+ mutable QHash<int, int> cascadingSectionSize; // from visual index to section size
+ mutable QSize cachedSizeHint;
+ mutable QBasicTimer delayedResize;
+
+ int firstCascadingSection;
+ int lastCascadingSection;
+
+ int lastPos;
+ int firstPos;
+ int originalSize;
+ int section; // used for resizing and moving sections
+ int target;
+ int pressed;
+ int hover;
+
+ int length;
+ int sectionCount;
+ bool movableSections;
+ bool clickableSections;
+ bool highlightSelected;
+ bool stretchLastSection;
+ bool cascadingResizing;
+ bool resizeRecursionBlock;
+ int stretchSections;
+ int contentsSections;
+ int defaultSectionSize;
+ int minimumSectionSize;
+ int lastSectionSize; // $$$
+ int sectionIndicatorOffset;
+ Qt::Alignment defaultAlignment;
+ QLabel *sectionIndicator;
+ QHeaderView::ResizeMode globalResizeMode;
+ QList<QPersistentModelIndex> persistentHiddenSections;
+
+ // header section spans
+
+ struct SectionSpan {
+ int size;
+ int count;
+ QHeaderView::ResizeMode resizeMode;
+ inline SectionSpan() : size(0), count(0), resizeMode(QHeaderView::Interactive) {}
+ inline SectionSpan(int length, int sections, QHeaderView::ResizeMode mode)
+ : size(length), count(sections), resizeMode(mode) {}
+ inline int sectionSize() const { return (count > 0 ? size / count : 0); }
+#ifndef QT_NO_DATASTREAM
+ inline void write(QDataStream &out) const
+ { out << size; out << count; out << (int)resizeMode; }
+ inline void read(QDataStream &in)
+ { in >> size; in >> count; int m; in >> m; resizeMode = (QHeaderView::ResizeMode)m; }
+#endif
+ };
+
+ QVector<SectionSpan> sectionSpans;
+
+ void createSectionSpan(int start, int end, int size, QHeaderView::ResizeMode mode);
+ void removeSectionsFromSpans(int start, int end);
+ void resizeSectionSpan(int visualIndex, int oldSize, int newSize);
+ void setDefaultSectionSize(int size);
+
+ inline int headerSectionCount() const { // for debugging
+ int count = 0;
+ for (int i = 0; i < sectionSpans.count(); ++i)
+ count += sectionSpans.at(i).count;
+ return count;
+ }
+
+ inline int headerLength() const { // for debugging
+ int len = 0;
+ for (int i = 0; i < sectionSpans.count(); ++i)
+ len += sectionSpans.at(i).size;
+ return len;
+ }
+
+ inline void removeSpans(const QList<int> &spans) {
+ for (int i = spans.count() - 1; i >= 0; --i) {
+ length -= sectionSpans.at(spans.at(i)).size;
+ sectionSpans.remove(spans.at(i));
+ }
+ }
+
+ inline int sectionSpanIndex(int visual) const {
+ int section_start = 0;
+ for (int i = 0; i < sectionSpans.count(); ++i) {
+ int section_end = section_start + sectionSpans.at(i).count - 1;
+ if (visual >= section_start && visual <= section_end)
+ return i;
+ section_start = section_end + 1;
+ }
+ return -1;
+ }
+
+ int headerSectionSize(int visual) const;
+ int headerSectionPosition(int visual) const;
+ int headerVisualIndexAt(int position) const;
+
+ // resize mode
+ void setHeaderSectionResizeMode(int visual, QHeaderView::ResizeMode mode);
+ QHeaderView::ResizeMode headerSectionResizeMode(int visual) const;
+ void setGlobalHeaderResizeMode(QHeaderView::ResizeMode mode);
+
+ // other
+ int viewSectionSizeHint(int logical) const;
+ int adjustedVisualIndex(int visualIndex) const;
+
+#ifndef QT_NO_DATASTREAM
+ void write(QDataStream &out) const;
+ bool read(QDataStream &in);
+#endif
+
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_ITEMVIEWS
+
+#endif // QHEADERVIEW_P_H
diff --git a/src/gui/itemviews/qitemdelegate.cpp b/src/widgets/itemviews/qitemdelegate.cpp
index f211438dcd..f211438dcd 100644
--- a/src/gui/itemviews/qitemdelegate.cpp
+++ b/src/widgets/itemviews/qitemdelegate.cpp
diff --git a/src/widgets/itemviews/qitemdelegate.h b/src/widgets/itemviews/qitemdelegate.h
new file mode 100644
index 0000000000..b5ca422cf9
--- /dev/null
+++ b/src/widgets/itemviews/qitemdelegate.h
@@ -0,0 +1,141 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QITEMDELEGATE_H
+#define QITEMDELEGATE_H
+
+#include <QtWidgets/qabstractitemdelegate.h>
+#include <QtCore/qstring.h>
+#include <QtGui/qpixmap.h>
+#include <QtCore/qvariant.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_ITEMVIEWS
+
+class QItemDelegatePrivate;
+class QItemEditorFactory;
+
+class Q_GUI_EXPORT QItemDelegate : public QAbstractItemDelegate
+{
+ Q_OBJECT
+ Q_PROPERTY(bool clipping READ hasClipping WRITE setClipping)
+
+public:
+ explicit QItemDelegate(QObject *parent = 0);
+ ~QItemDelegate();
+
+ bool hasClipping() const;
+ void setClipping(bool clip);
+
+ // painting
+ void paint(QPainter *painter,
+ const QStyleOptionViewItem &option,
+ const QModelIndex &index) const;
+ QSize sizeHint(const QStyleOptionViewItem &option,
+ const QModelIndex &index) const;
+
+ // editing
+ 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;
+
+ // editor factory
+ QItemEditorFactory *itemEditorFactory() const;
+ void setItemEditorFactory(QItemEditorFactory *factory);
+
+protected:
+ virtual void drawDisplay(QPainter *painter, const QStyleOptionViewItem &option,
+ const QRect &rect, const QString &text) const;
+ virtual void drawDecoration(QPainter *painter, const QStyleOptionViewItem &option,
+ const QRect &rect, const QPixmap &pixmap) const;
+ virtual void drawFocus(QPainter *painter, const QStyleOptionViewItem &option,
+ const QRect &rect) const;
+ virtual void drawCheck(QPainter *painter, const QStyleOptionViewItem &option,
+ const QRect &rect, Qt::CheckState state) const;
+ void drawBackground(QPainter *painter, const QStyleOptionViewItem &option,
+ const QModelIndex &index) const;
+
+ void doLayout(const QStyleOptionViewItem &option,
+ QRect *checkRect, QRect *iconRect, QRect *textRect, bool hint) const;
+
+ QRect rect(const QStyleOptionViewItem &option, const QModelIndex &index, int role) const;
+
+ bool eventFilter(QObject *object, QEvent *event);
+ bool editorEvent(QEvent *event, QAbstractItemModel *model,
+ const QStyleOptionViewItem &option, const QModelIndex &index);
+
+ QStyleOptionViewItem setOptions(const QModelIndex &index,
+ const QStyleOptionViewItem &option) const;
+
+ QPixmap decoration(const QStyleOptionViewItem &option, const QVariant &variant) const;
+ QPixmap *selected(const QPixmap &pixmap, const QPalette &palette, bool enabled) const;
+
+ QRect check(const QStyleOptionViewItem &option, const QRect &bounding,
+ const QVariant &variant) const;
+ QRect textRectangle(QPainter *painter, const QRect &rect,
+ const QFont &font, const QString &text) const;
+
+private:
+ Q_DECLARE_PRIVATE(QItemDelegate)
+ Q_DISABLE_COPY(QItemDelegate)
+
+ Q_PRIVATE_SLOT(d_func(), void _q_commitDataAndCloseEditor(QWidget*))
+};
+
+#endif // QT_NO_ITEMVIEWS
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QITEMDELEGATE_H
diff --git a/src/gui/itemviews/qitemeditorfactory.cpp b/src/widgets/itemviews/qitemeditorfactory.cpp
index 92c78cb6f1..92c78cb6f1 100644
--- a/src/gui/itemviews/qitemeditorfactory.cpp
+++ b/src/widgets/itemviews/qitemeditorfactory.cpp
diff --git a/src/gui/itemviews/qitemeditorfactory.h b/src/widgets/itemviews/qitemeditorfactory.h
index 28e145460f..28e145460f 100644
--- a/src/gui/itemviews/qitemeditorfactory.h
+++ b/src/widgets/itemviews/qitemeditorfactory.h
diff --git a/src/gui/itemviews/qitemeditorfactory_p.h b/src/widgets/itemviews/qitemeditorfactory_p.h
index 87b39c7a12..87b39c7a12 100644
--- a/src/gui/itemviews/qitemeditorfactory_p.h
+++ b/src/widgets/itemviews/qitemeditorfactory_p.h
diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/widgets/itemviews/qitemselectionmodel.cpp
index 0b6445298e..0b6445298e 100644
--- a/src/gui/itemviews/qitemselectionmodel.cpp
+++ b/src/widgets/itemviews/qitemselectionmodel.cpp
diff --git a/src/gui/itemviews/qitemselectionmodel.h b/src/widgets/itemviews/qitemselectionmodel.h
index 12b875b8ab..12b875b8ab 100644
--- a/src/gui/itemviews/qitemselectionmodel.h
+++ b/src/widgets/itemviews/qitemselectionmodel.h
diff --git a/src/gui/itemviews/qitemselectionmodel_p.h b/src/widgets/itemviews/qitemselectionmodel_p.h
index 1574864477..1574864477 100644
--- a/src/gui/itemviews/qitemselectionmodel_p.h
+++ b/src/widgets/itemviews/qitemselectionmodel_p.h
diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp
new file mode 100644
index 0000000000..26478ffe97
--- /dev/null
+++ b/src/widgets/itemviews/qlistview.cpp
@@ -0,0 +1,3213 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlistview.h"
+
+#ifndef QT_NO_LISTVIEW
+#include <qabstractitemdelegate.h>
+#include <qapplication.h>
+#include <qpainter.h>
+#include <qbitmap.h>
+#include <qdrag.h>
+#include <qvector.h>
+#include <qstyle.h>
+#include <qevent.h>
+#include <qscrollbar.h>
+#include <qrubberband.h>
+#include <private/qlistview_p.h>
+#include <qdebug.h>
+#ifndef QT_NO_ACCESSIBILITY
+#include <qaccessible.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QListView
+
+ \brief The QListView class provides a list or icon view onto a model.
+
+ \ingroup model-view
+ \ingroup advanced
+
+
+ A QListView presents items stored in a model, either as a simple
+ non-hierarchical list, or as a collection of icons. This class is used
+ to provide lists and icon views that were previously provided by the
+ \c QListBox and \c QIconView classes, but using the more flexible
+ approach provided by Qt's model/view architecture.
+
+ The QListView class is one of the \l{Model/View Classes}
+ and is part of Qt's \l{Model/View Programming}{model/view framework}.
+
+ This view does not display horizontal or vertical headers; to display
+ a list of items with a horizontal header, use QTreeView instead.
+
+ QListView implements the interfaces defined by the
+ QAbstractItemView class to allow it to display data provided by
+ models derived from the QAbstractItemModel class.
+
+ Items in a list view can be displayed using one of two view modes:
+ In \l ListMode, the items are displayed in the form of a simple list;
+ in \l IconMode, the list view takes the form of an \e{icon view} in
+ which the items are displayed with icons like files in a file manager.
+ By default, the list view is in \l ListMode. To change the view mode,
+ use the setViewMode() function, and to determine the current view mode,
+ use viewMode().
+
+ Items in these views are laid out in the direction specified by the
+ flow() of the list view. The items may be fixed in place, or allowed
+ to move, depending on the view's movement() state.
+
+ If the items in the model cannot be completely laid out in the
+ direction of flow, they can be wrapped at the boundary of the view
+ widget; this depends on isWrapping(). This property is useful when the
+ items are being represented by an icon view.
+
+ The resizeMode() and layoutMode() govern how and when the items are
+ laid out. Items are spaced according to their spacing(), and can exist
+ within a notional grid of size specified by gridSize(). The items can
+ be rendered as large or small icons depending on their iconSize().
+
+ \table 100%
+ \row \o \inlineimage windowsxp-listview.png Screenshot of a Windows XP style list view
+ \o \inlineimage macintosh-listview.png Screenshot of a Macintosh style table view
+ \o \inlineimage plastique-listview.png Screenshot of a Plastique style table view
+ \row \o A \l{Windows XP Style Widget Gallery}{Windows XP style} list view.
+ \o A \l{Macintosh Style Widget Gallery}{Macintosh style} list view.
+ \o A \l{Plastique Style Widget Gallery}{Plastique style} list view.
+ \endtable
+
+ \section1 Improving Performance
+
+ It is possible to give the view hints about the data it is handling in order
+ to improve its performance when displaying large numbers of items. One approach
+ that can be taken for views that are intended to display items with equal sizes
+ is to set the \l uniformItemSizes property to true.
+
+ \sa {View Classes}, QTreeView, QTableView, QListWidget
+*/
+
+/*!
+ \enum QListView::ViewMode
+
+ \value ListMode The items are laid out using TopToBottom flow, with Small size and Static movement
+ \value IconMode The items are laid out using LeftToRight flow, with Large size and Free movement
+*/
+
+/*!
+ \enum QListView::Movement
+
+ \value Static The items cannot be moved by the user.
+ \value Free The items can be moved freely by the user.
+ \value Snap The items snap to the specified grid when moved; see
+ setGridSize().
+*/
+
+/*!
+ \enum QListView::Flow
+
+ \value LeftToRight The items are laid out in the view from the left
+ to the right.
+ \value TopToBottom The items are laid out in the view from the top
+ to the bottom.
+*/
+
+/*!
+ \enum QListView::ResizeMode
+
+ \value Fixed The items will only be laid out the first time the view is shown.
+ \value Adjust The items will be laid out every time the view is resized.
+*/
+
+/*!
+ \enum QListView::LayoutMode
+
+ \value SinglePass The items are laid out all at once.
+ \value Batched The items are laid out in batches of \l batchSize items.
+ \sa batchSize
+*/
+
+/*!
+ \since 4.2
+ \fn void QListView::indexesMoved(const QModelIndexList &indexes)
+
+ This signal is emitted when the specified \a indexes are moved in the view.
+*/
+
+/*!
+ Creates a new QListView with the given \a parent to view a model.
+ Use setModel() to set the model.
+*/
+QListView::QListView(QWidget *parent)
+ : QAbstractItemView(*new QListViewPrivate, parent)
+{
+ setViewMode(ListMode);
+ setSelectionMode(SingleSelection);
+ setAttribute(Qt::WA_MacShowFocusRect);
+ Q_D(QListView); // We rely on a qobject_cast for PM_DefaultFrameWidth to change
+ d->updateStyledFrameWidths(); // hence we have to force an update now that the object has been constructed
+}
+
+/*!
+ \internal
+*/
+QListView::QListView(QListViewPrivate &dd, QWidget *parent)
+ : QAbstractItemView(dd, parent)
+{
+ setViewMode(ListMode);
+ setSelectionMode(SingleSelection);
+ setAttribute(Qt::WA_MacShowFocusRect);
+ Q_D(QListView); // We rely on a qobject_cast for PM_DefaultFrameWidth to change
+ d->updateStyledFrameWidths(); // hence we have to force an update now that the object has been constructed
+}
+
+/*!
+ Destroys the view.
+*/
+QListView::~QListView()
+{
+}
+
+/*!
+ \property QListView::movement
+ \brief whether the items can be moved freely, are snapped to a
+ grid, or cannot be moved at all.
+
+ This property determines how the user can move the items in the
+ view. \l Static means that the items can't be moved the user. \l
+ Free means that the user can drag and drop the items to any
+ position in the view. \l Snap means that the user can drag and
+ drop the items, but only to the positions in a notional grid
+ signified by the gridSize property.
+
+ Setting this property when the view is visible will cause the
+ items to be laid out again.
+
+ By default, this property is set to \l Static.
+
+ \sa gridSize, resizeMode, viewMode
+*/
+void QListView::setMovement(Movement movement)
+{
+ Q_D(QListView);
+ d->modeProperties |= uint(QListViewPrivate::Movement);
+ d->movement = movement;
+
+#ifndef QT_NO_DRAGANDDROP
+ bool movable = (movement != Static);
+ setDragEnabled(movable);
+ d->viewport->setAcceptDrops(movable);
+#endif
+ d->doDelayedItemsLayout();
+}
+
+QListView::Movement QListView::movement() const
+{
+ Q_D(const QListView);
+ return d->movement;
+}
+
+/*!
+ \property QListView::flow
+ \brief which direction the items layout should flow.
+
+ If this property is \l LeftToRight, the items will be laid out left
+ to right. If the \l isWrapping property is true, the layout will wrap
+ when it reaches the right side of the visible area. If this
+ property is \l TopToBottom, the items will be laid out from the top
+ of the visible area, wrapping when it reaches the bottom.
+
+ Setting this property when the view is visible will cause the
+ items to be laid out again.
+
+ By default, this property is set to \l TopToBottom.
+
+ \sa viewMode
+*/
+void QListView::setFlow(Flow flow)
+{
+ Q_D(QListView);
+ d->modeProperties |= uint(QListViewPrivate::Flow);
+ d->flow = flow;
+ d->doDelayedItemsLayout();
+}
+
+QListView::Flow QListView::flow() const
+{
+ Q_D(const QListView);
+ return d->flow;
+}
+
+/*!
+ \property QListView::isWrapping
+ \brief whether the items layout should wrap.
+
+ This property holds whether the layout should wrap when there is
+ no more space in the visible area. The point at which the layout wraps
+ depends on the \l flow property.
+
+ Setting this property when the view is visible will cause the
+ items to be laid out again.
+
+ By default, this property is false.
+
+ \sa viewMode
+*/
+void QListView::setWrapping(bool enable)
+{
+ Q_D(QListView);
+ d->modeProperties |= uint(QListViewPrivate::Wrap);
+ d->setWrapping(enable);
+ d->doDelayedItemsLayout();
+}
+
+bool QListView::isWrapping() const
+{
+ Q_D(const QListView);
+ return d->isWrapping();
+}
+
+/*!
+ \property QListView::resizeMode
+ \brief whether the items are laid out again when the view is resized.
+
+ If this property is \l Adjust, the items will be laid out again
+ when the view is resized. If the value is \l Fixed, the items will
+ not be laid out when the view is resized.
+
+ By default, this property is set to \l Fixed.
+
+ \sa movement, gridSize, viewMode
+*/
+void QListView::setResizeMode(ResizeMode mode)
+{
+ Q_D(QListView);
+ d->modeProperties |= uint(QListViewPrivate::ResizeMode);
+ d->resizeMode = mode;
+}
+
+QListView::ResizeMode QListView::resizeMode() const
+{
+ Q_D(const QListView);
+ return d->resizeMode;
+}
+
+/*!
+ \property QListView::layoutMode
+ \brief determines whether the layout of items should happen immediately or be delayed.
+
+ This property holds the layout mode for the items. When the mode
+ is \l SinglePass (the default), the items are laid out all in one go.
+ When the mode is \l Batched, the items are laid out in batches of \l batchSize
+ items, while processing events. This makes it possible to
+ instantly view and interact with the visible items while the rest
+ are being laid out.
+
+ \sa viewMode
+*/
+void QListView::setLayoutMode(LayoutMode mode)
+{
+ Q_D(QListView);
+ d->layoutMode = mode;
+}
+
+QListView::LayoutMode QListView::layoutMode() const
+{
+ Q_D(const QListView);
+ return d->layoutMode;
+}
+
+/*!
+ \property QListView::spacing
+ \brief the space around the items in the layout
+
+ This property is the size of the empty space that is padded around
+ an item in the layout.
+
+ Setting this property when the view is visible will cause the
+ items to be laid out again.
+
+ By default, this property contains a value of 0.
+
+ \sa viewMode
+*/
+// ### Qt5: Use same semantic as layouts (spacing is the size of space
+// *between* items)
+void QListView::setSpacing(int space)
+{
+ Q_D(QListView);
+ d->modeProperties |= uint(QListViewPrivate::Spacing);
+ d->setSpacing(space);
+ d->doDelayedItemsLayout();
+}
+
+int QListView::spacing() const
+{
+ Q_D(const QListView);
+ return d->spacing();
+}
+
+/*!
+ \property QListView::batchSize
+ \brief the number of items laid out in each batch if \l layoutMode is
+ set to \l Batched
+
+ The default value is 100.
+
+ \since 4.2
+*/
+
+void QListView::setBatchSize(int batchSize)
+{
+ Q_D(QListView);
+ if (batchSize <= 0) {
+ qWarning("Invalid batchSize (%d)", batchSize);
+ return;
+ }
+ d->batchSize = batchSize;
+}
+
+int QListView::batchSize() const
+{
+ Q_D(const QListView);
+ return d->batchSize;
+}
+
+/*!
+ \property QListView::gridSize
+ \brief the size of the layout grid
+
+ This property is the size of the grid in which the items are laid
+ out. The default is an empty size which means that there is no
+ grid and the layout is not done in a grid. Setting this property
+ to a non-empty size switches on the grid layout. (When a grid
+ layout is in force the \l spacing property is ignored.)
+
+ Setting this property when the view is visible will cause the
+ items to be laid out again.
+
+ \sa viewMode
+*/
+void QListView::setGridSize(const QSize &size)
+{
+ Q_D(QListView);
+ d->modeProperties |= uint(QListViewPrivate::GridSize);
+ d->setGridSize(size);
+ d->doDelayedItemsLayout();
+}
+
+QSize QListView::gridSize() const
+{
+ Q_D(const QListView);
+ return d->gridSize();
+}
+
+/*!
+ \property QListView::viewMode
+ \brief the view mode of the QListView.
+
+ This property will change the other unset properties to conform
+ with the set view mode. QListView-specific properties that have already been set
+ will not be changed, unless clearPropertyFlags() has been called.
+
+ Setting the view mode will enable or disable drag and drop based on the
+ selected movement. For ListMode, the default movement is \l Static
+ (drag and drop disabled); for IconMode, the default movement is
+ \l Free (drag and drop enabled).
+
+ \sa isWrapping, spacing, gridSize, flow, movement, resizeMode
+*/
+void QListView::setViewMode(ViewMode mode)
+{
+ Q_D(QListView);
+ if (d->commonListView && d->viewMode == mode)
+ return;
+ d->viewMode = mode;
+
+ delete d->commonListView;
+ if (mode == ListMode) {
+ d->commonListView = new QListModeViewBase(this, d);
+ if (!(d->modeProperties & QListViewPrivate::Wrap))
+ d->setWrapping(false);
+ if (!(d->modeProperties & QListViewPrivate::Spacing))
+ d->setSpacing(0);
+ if (!(d->modeProperties & QListViewPrivate::GridSize))
+ d->setGridSize(QSize());
+ if (!(d->modeProperties & QListViewPrivate::Flow))
+ d->flow = TopToBottom;
+ if (!(d->modeProperties & QListViewPrivate::Movement))
+ d->movement = Static;
+ if (!(d->modeProperties & QListViewPrivate::ResizeMode))
+ d->resizeMode = Fixed;
+ if (!(d->modeProperties & QListViewPrivate::SelectionRectVisible))
+ d->showElasticBand = false;
+ } else {
+ d->commonListView = new QIconModeViewBase(this, d);
+ if (!(d->modeProperties & QListViewPrivate::Wrap))
+ d->setWrapping(true);
+ if (!(d->modeProperties & QListViewPrivate::Spacing))
+ d->setSpacing(0);
+ if (!(d->modeProperties & QListViewPrivate::GridSize))
+ d->setGridSize(QSize());
+ if (!(d->modeProperties & QListViewPrivate::Flow))
+ d->flow = LeftToRight;
+ if (!(d->modeProperties & QListViewPrivate::Movement))
+ d->movement = Free;
+ if (!(d->modeProperties & QListViewPrivate::ResizeMode))
+ d->resizeMode = Fixed;
+ if (!(d->modeProperties & QListViewPrivate::SelectionRectVisible))
+ d->showElasticBand = true;
+ }
+
+#ifndef QT_NO_DRAGANDDROP
+ bool movable = (d->movement != Static);
+ setDragEnabled(movable);
+ setAcceptDrops(movable);
+#endif
+ d->clear();
+ d->doDelayedItemsLayout();
+}
+
+QListView::ViewMode QListView::viewMode() const
+{
+ Q_D(const QListView);
+ return d->viewMode;
+}
+
+/*!
+ Clears the QListView-specific property flags. See \l{viewMode}.
+
+ Properties inherited from QAbstractItemView are not covered by the
+ property flags. Specifically, \l{QAbstractItemView::dragEnabled}
+ {dragEnabled} and \l{QAbstractItemView::acceptDrops}
+ {acceptsDrops} are computed by QListView when calling
+ setMovement() or setViewMode().
+*/
+void QListView::clearPropertyFlags()
+{
+ Q_D(QListView);
+ d->modeProperties = 0;
+}
+
+/*!
+ Returns true if the \a row is hidden; otherwise returns false.
+*/
+bool QListView::isRowHidden(int row) const
+{
+ Q_D(const QListView);
+ return d->isHidden(row);
+}
+
+/*!
+ If \a hide is true, the given \a row will be hidden; otherwise
+ the \a row will be shown.
+*/
+void QListView::setRowHidden(int row, bool hide)
+{
+ Q_D(QListView);
+ const bool hidden = d->isHidden(row);
+ if (hide && !hidden)
+ d->commonListView->appendHiddenRow(row);
+ else if (!hide && hidden)
+ d->commonListView->removeHiddenRow(row);
+ d->doDelayedItemsLayout();
+ d->viewport->update();
+}
+
+/*!
+ \reimp
+*/
+QRect QListView::visualRect(const QModelIndex &index) const
+{
+ Q_D(const QListView);
+ return d->mapToViewport(rectForIndex(index));
+}
+
+/*!
+ \reimp
+*/
+void QListView::scrollTo(const QModelIndex &index, ScrollHint hint)
+{
+ Q_D(QListView);
+
+ if (index.parent() != d->root || index.column() != d->column)
+ return;
+
+ const QRect rect = visualRect(index);
+ if (hint == EnsureVisible && d->viewport->rect().contains(rect)) {
+ d->viewport->update(rect);
+ return;
+ }
+
+ if (d->flow == QListView::TopToBottom || d->isWrapping()) // vertical
+ verticalScrollBar()->setValue(d->verticalScrollToValue(index, rect, hint));
+
+ if (d->flow == QListView::LeftToRight || d->isWrapping()) // horizontal
+ horizontalScrollBar()->setValue(d->horizontalScrollToValue(index, rect, hint));
+}
+
+int QListViewPrivate::horizontalScrollToValue(const QModelIndex &index, const QRect &rect,
+ QListView::ScrollHint hint) const
+{
+ Q_Q(const QListView);
+ const QRect area = viewport->rect();
+ const bool leftOf = q->isRightToLeft()
+ ? (rect.left() < area.left()) && (rect.right() < area.right())
+ : rect.left() < area.left();
+ const bool rightOf = q->isRightToLeft()
+ ? rect.right() > area.right()
+ : (rect.right() > area.right()) && (rect.left() > area.left());
+ return commonListView->horizontalScrollToValue(q->visualIndex(index), hint, leftOf, rightOf, area, rect);
+}
+
+int QListViewPrivate::verticalScrollToValue(const QModelIndex &index, const QRect &rect,
+ QListView::ScrollHint hint) const
+{
+ Q_Q(const QListView);
+ const QRect area = viewport->rect();
+ const bool above = (hint == QListView::EnsureVisible && rect.top() < area.top());
+ const bool below = (hint == QListView::EnsureVisible && rect.bottom() > area.bottom());
+ return commonListView->verticalScrollToValue(q->visualIndex(index), hint, above, below, area, rect);
+}
+
+void QListViewPrivate::selectAll(QItemSelectionModel::SelectionFlags command)
+{
+ if (!selectionModel)
+ return;
+
+ QItemSelection selection;
+ QModelIndex topLeft;
+ int row = 0;
+ const int colCount = model->columnCount(root);
+ for(; row < model->rowCount(root); ++row) {
+ if (isHidden(row)) {
+ //it might be the end of a selection range
+ if (topLeft.isValid()) {
+ QModelIndex bottomRight = model->index(row - 1, colCount - 1, root);
+ selection.append(QItemSelectionRange(topLeft, bottomRight));
+ topLeft = QModelIndex();
+ }
+ continue;
+ }
+
+ if (!topLeft.isValid()) //start of a new selection range
+ topLeft = model->index(row, 0, root);
+ }
+
+ if (topLeft.isValid()) {
+ //last selected range
+ QModelIndex bottomRight = model->index(row - 1, colCount - 1, root);
+ selection.append(QItemSelectionRange(topLeft, bottomRight));
+ }
+
+ if (!selection.isEmpty())
+ selectionModel->select(selection, command);
+}
+
+/*!
+ \reimp
+
+ We have a QListView way of knowing what elements are on the viewport
+ through the intersectingSet function
+*/
+QItemViewPaintPairs QListViewPrivate::draggablePaintPairs(const QModelIndexList &indexes, QRect *r) const
+{
+ Q_ASSERT(r);
+ Q_Q(const QListView);
+ QRect &rect = *r;
+ const QRect viewportRect = viewport->rect();
+ QItemViewPaintPairs ret;
+ const QSet<QModelIndex> visibleIndexes = intersectingSet(viewportRect).toList().toSet();
+ for (int i = 0; i < indexes.count(); ++i) {
+ const QModelIndex &index = indexes.at(i);
+ if (visibleIndexes.contains(index)) {
+ const QRect current = q->visualRect(index);
+ ret += qMakePair(current, index);
+ rect |= current;
+ }
+ }
+ rect &= viewportRect;
+ return ret;
+}
+
+/*!
+ \internal
+*/
+void QListView::reset()
+{
+ Q_D(QListView);
+ d->clear();
+ d->hiddenRows.clear();
+ QAbstractItemView::reset();
+}
+
+/*!
+ \internal
+*/
+void QListView::setRootIndex(const QModelIndex &index)
+{
+ Q_D(QListView);
+ d->column = qBound(0, d->column, d->model->columnCount(index) - 1);
+ QAbstractItemView::setRootIndex(index);
+ // sometimes we get an update before reset() is called
+ d->clear();
+ d->hiddenRows.clear();
+}
+
+/*!
+ \internal
+
+ Scroll the view contents by \a dx and \a dy.
+*/
+
+void QListView::scrollContentsBy(int dx, int dy)
+{
+ Q_D(QListView);
+ d->delayedAutoScroll.stop(); // auto scroll was canceled by the user scrolling
+ d->commonListView->scrollContentsBy(dx, dy, d->state == QListView::DragSelectingState);
+}
+
+/*!
+ \internal
+
+ Resize the internal contents to \a width and \a height and set the
+ scroll bar ranges accordingly.
+*/
+void QListView::resizeContents(int width, int height)
+{
+ Q_D(QListView);
+ d->setContentsSize(width, height);
+}
+
+/*!
+ \internal
+*/
+QSize QListView::contentsSize() const
+{
+ Q_D(const QListView);
+ return d->contentsSize();
+}
+
+/*!
+ \reimp
+*/
+void QListView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
+{
+ d_func()->commonListView->dataChanged(topLeft, bottomRight);
+ QAbstractItemView::dataChanged(topLeft, bottomRight);
+}
+
+/*!
+ \reimp
+*/
+void QListView::rowsInserted(const QModelIndex &parent, int start, int end)
+{
+ Q_D(QListView);
+ // ### be smarter about inserted items
+ d->clear();
+ d->doDelayedItemsLayout();
+ QAbstractItemView::rowsInserted(parent, start, end);
+}
+
+/*!
+ \reimp
+*/
+void QListView::rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
+{
+ Q_D(QListView);
+ // if the parent is above d->root in the tree, nothing will happen
+ QAbstractItemView::rowsAboutToBeRemoved(parent, start, end);
+ if (parent == d->root) {
+ QSet<QPersistentModelIndex>::iterator it = d->hiddenRows.begin();
+ while (it != d->hiddenRows.end()) {
+ int hiddenRow = it->row();
+ if (hiddenRow >= start && hiddenRow <= end) {
+ it = d->hiddenRows.erase(it);
+ } else {
+ ++it;
+ }
+ }
+ }
+ d->clear();
+ d->doDelayedItemsLayout();
+}
+
+/*!
+ \reimp
+*/
+void QListView::mouseMoveEvent(QMouseEvent *e)
+{
+ if (!isVisible())
+ return;
+ Q_D(QListView);
+ QAbstractItemView::mouseMoveEvent(e);
+ if (state() == DragSelectingState
+ && d->showElasticBand
+ && d->selectionMode != SingleSelection
+ && d->selectionMode != NoSelection) {
+ QRect rect(d->pressedPosition, e->pos() + QPoint(horizontalOffset(), verticalOffset()));
+ rect = rect.normalized();
+ d->viewport->update(d->mapToViewport(rect.united(d->elasticBand)));
+ d->elasticBand = rect;
+ }
+}
+
+/*!
+ \reimp
+*/
+void QListView::mouseReleaseEvent(QMouseEvent *e)
+{
+ Q_D(QListView);
+ QAbstractItemView::mouseReleaseEvent(e);
+ // #### move this implementation into a dynamic class
+ if (d->showElasticBand && d->elasticBand.isValid()) {
+ d->viewport->update(d->mapToViewport(d->elasticBand));
+ d->elasticBand = QRect();
+ }
+}
+
+/*!
+ \reimp
+*/
+void QListView::timerEvent(QTimerEvent *e)
+{
+ Q_D(QListView);
+ if (e->timerId() == d->batchLayoutTimer.timerId()) {
+ if (d->doItemsLayout(d->batchSize)) { // layout is done
+ d->batchLayoutTimer.stop();
+ updateGeometries();
+ d->viewport->update();
+ }
+ }
+ QAbstractItemView::timerEvent(e);
+}
+
+/*!
+ \reimp
+*/
+void QListView::resizeEvent(QResizeEvent *e)
+{
+ Q_D(QListView);
+ if (d->delayedPendingLayout)
+ return;
+
+ QSize delta = e->size() - e->oldSize();
+
+ if (delta.isNull())
+ return;
+
+ bool listWrap = (d->viewMode == ListMode) && d->wrapItemText;
+ bool flowDimensionChanged = (d->flow == LeftToRight && delta.width() != 0)
+ || (d->flow == TopToBottom && delta.height() != 0);
+
+ // We post a delayed relayout in the following cases :
+ // - we're wrapping
+ // - the state is NoState, we're adjusting and the size has changed in the flowing direction
+ if (listWrap
+ || (state() == NoState && d->resizeMode == Adjust && flowDimensionChanged)) {
+ d->doDelayedItemsLayout(100); // wait 1/10 sec before starting the layout
+ } else {
+ QAbstractItemView::resizeEvent(e);
+ }
+}
+
+#ifndef QT_NO_DRAGANDDROP
+
+/*!
+ \reimp
+*/
+void QListView::dragMoveEvent(QDragMoveEvent *e)
+{
+ Q_D(QListView);
+ if (!d->commonListView->filterDragMoveEvent(e)) {
+ if (viewMode() == QListView::ListMode && flow() == QListView::LeftToRight)
+ static_cast<QListModeViewBase *>(d->commonListView)->dragMoveEvent(e);
+ else
+ QAbstractItemView::dragMoveEvent(e);
+ }
+}
+
+
+/*!
+ \reimp
+*/
+void QListView::dragLeaveEvent(QDragLeaveEvent *e)
+{
+ if (!d_func()->commonListView->filterDragLeaveEvent(e))
+ QAbstractItemView::dragLeaveEvent(e);
+}
+
+/*!
+ \reimp
+*/
+void QListView::dropEvent(QDropEvent *e)
+{
+ if (!d_func()->commonListView->filterDropEvent(e))
+ QAbstractItemView::dropEvent(e);
+}
+
+/*!
+ \reimp
+*/
+void QListView::startDrag(Qt::DropActions supportedActions)
+{
+ if (!d_func()->commonListView->filterStartDrag(supportedActions))
+ QAbstractItemView::startDrag(supportedActions);
+}
+
+/*!
+ \internal
+
+ Called whenever items from the view is dropped on the viewport.
+ The \a event provides additional information.
+*/
+void QListView::internalDrop(QDropEvent *event)
+{
+ // ### Qt5: remove that function
+ Q_UNUSED(event);
+}
+
+/*!
+ \internal
+
+ Called whenever the user starts dragging items and the items are movable,
+ enabling internal dragging and dropping of items.
+*/
+void QListView::internalDrag(Qt::DropActions supportedActions)
+{
+ // ### Qt5: remove that function
+ Q_UNUSED(supportedActions);
+}
+
+#endif // QT_NO_DRAGANDDROP
+
+/*!
+ \reimp
+*/
+QStyleOptionViewItem QListView::viewOptions() const
+{
+ Q_D(const QListView);
+ QStyleOptionViewItem option = QAbstractItemView::viewOptions();
+ if (!d->iconSize.isValid()) { // otherwise it was already set in abstractitemview
+ int pm = (d->viewMode == ListMode
+ ? style()->pixelMetric(QStyle::PM_ListViewIconSize, 0, this)
+ : style()->pixelMetric(QStyle::PM_IconViewIconSize, 0, this));
+ option.decorationSize = QSize(pm, pm);
+ }
+ if (d->viewMode == IconMode) {
+ option.showDecorationSelected = false;
+ option.decorationPosition = QStyleOptionViewItem::Top;
+ option.displayAlignment = Qt::AlignCenter;
+ } else {
+ option.decorationPosition = QStyleOptionViewItem::Left;
+ }
+ return option;
+}
+
+
+/*!
+ \reimp
+*/
+void QListView::paintEvent(QPaintEvent *e)
+{
+ Q_D(QListView);
+ if (!d->itemDelegate)
+ return;
+ QStyleOptionViewItemV4 option = d->viewOptionsV4();
+ QPainter painter(d->viewport);
+
+ const QVector<QModelIndex> toBeRendered = d->intersectingSet(e->rect().translated(horizontalOffset(), verticalOffset()), false);
+
+ const QModelIndex current = currentIndex();
+ const QModelIndex hover = d->hover;
+ const QAbstractItemModel *itemModel = d->model;
+ const QItemSelectionModel *selections = d->selectionModel;
+ const bool focus = (hasFocus() || d->viewport->hasFocus()) && current.isValid();
+ const bool alternate = d->alternatingColors;
+ const QStyle::State state = option.state;
+ const QAbstractItemView::State viewState = this->state();
+ const bool enabled = (state & QStyle::State_Enabled) != 0;
+
+ bool alternateBase = false;
+ int previousRow = -2; // trigger the alternateBase adjustment on first pass
+
+ int maxSize = (flow() == TopToBottom)
+ ? qMax(viewport()->size().width(), d->contentsSize().width()) - 2 * d->spacing()
+ : qMax(viewport()->size().height(), d->contentsSize().height()) - 2 * d->spacing();
+
+ QVector<QModelIndex>::const_iterator end = toBeRendered.constEnd();
+ for (QVector<QModelIndex>::const_iterator it = toBeRendered.constBegin(); it != end; ++it) {
+ Q_ASSERT((*it).isValid());
+ option.rect = visualRect(*it);
+
+ if (flow() == TopToBottom)
+ option.rect.setWidth(qMin(maxSize, option.rect.width()));
+ else
+ option.rect.setHeight(qMin(maxSize, option.rect.height()));
+
+ option.state = state;
+ if (selections && selections->isSelected(*it))
+ option.state |= QStyle::State_Selected;
+ if (enabled) {
+ QPalette::ColorGroup cg;
+ if ((itemModel->flags(*it) & Qt::ItemIsEnabled) == 0) {
+ option.state &= ~QStyle::State_Enabled;
+ cg = QPalette::Disabled;
+ } else {
+ cg = QPalette::Normal;
+ }
+ option.palette.setCurrentColorGroup(cg);
+ }
+ if (focus && current == *it) {
+ option.state |= QStyle::State_HasFocus;
+ if (viewState == EditingState)
+ option.state |= QStyle::State_Editing;
+ }
+ if (*it == hover)
+ option.state |= QStyle::State_MouseOver;
+ else
+ option.state &= ~QStyle::State_MouseOver;
+
+ if (alternate) {
+ int row = (*it).row();
+ if (row != previousRow + 1) {
+ // adjust alternateBase according to rows in the "gap"
+ if (!d->hiddenRows.isEmpty()) {
+ for (int r = qMax(previousRow + 1, 0); r < row; ++r) {
+ if (!d->isHidden(r))
+ alternateBase = !alternateBase;
+ }
+ } else {
+ alternateBase = (row & 1) != 0;
+ }
+ }
+ if (alternateBase) {
+ option.features |= QStyleOptionViewItemV2::Alternate;
+ } else {
+ option.features &= ~QStyleOptionViewItemV2::Alternate;
+ }
+
+ // draw background of the item (only alternate row). rest of the background
+ // is provided by the delegate
+ QStyle::State oldState = option.state;
+ option.state &= ~QStyle::State_Selected;
+ style()->drawPrimitive(QStyle::PE_PanelItemViewRow, &option, &painter, this);
+ option.state = oldState;
+
+ alternateBase = !alternateBase;
+ previousRow = row;
+ }
+
+ d->delegateForIndex(*it)->paint(&painter, option, *it);
+ }
+
+#ifndef QT_NO_DRAGANDDROP
+ d->commonListView->paintDragDrop(&painter);
+#endif
+
+#ifndef QT_NO_RUBBERBAND
+ // #### move this implementation into a dynamic class
+ if (d->showElasticBand && d->elasticBand.isValid()) {
+ QStyleOptionRubberBand opt;
+ opt.initFrom(this);
+ opt.shape = QRubberBand::Rectangle;
+ opt.opaque = false;
+ opt.rect = d->mapToViewport(d->elasticBand, false).intersected(
+ d->viewport->rect().adjusted(-16, -16, 16, 16));
+ painter.save();
+ style()->drawControl(QStyle::CE_RubberBand, &opt, &painter);
+ painter.restore();
+ }
+#endif
+}
+
+/*!
+ \reimp
+*/
+QModelIndex QListView::indexAt(const QPoint &p) const
+{
+ Q_D(const QListView);
+ QRect rect(p.x() + horizontalOffset(), p.y() + verticalOffset(), 1, 1);
+ const QVector<QModelIndex> intersectVector = d->intersectingSet(rect);
+ QModelIndex index = intersectVector.count() > 0
+ ? intersectVector.last() : QModelIndex();
+ if (index.isValid() && visualRect(index).contains(p))
+ return index;
+ return QModelIndex();
+}
+
+/*!
+ \reimp
+*/
+int QListView::horizontalOffset() const
+{
+ return d_func()->commonListView->horizontalOffset();
+}
+
+/*!
+ \reimp
+*/
+int QListView::verticalOffset() const
+{
+ return d_func()->commonListView->verticalOffset();
+}
+
+/*!
+ \reimp
+*/
+QModelIndex QListView::moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers)
+{
+ Q_D(QListView);
+ Q_UNUSED(modifiers);
+
+ QModelIndex current = currentIndex();
+ if (!current.isValid()) {
+ int rowCount = d->model->rowCount(d->root);
+ if (!rowCount)
+ return QModelIndex();
+ int row = 0;
+ while (row < rowCount && d->isHiddenOrDisabled(row))
+ ++row;
+ if (row >= rowCount)
+ return QModelIndex();
+ return d->model->index(row, d->column, d->root);
+ }
+
+ const QRect initialRect = rectForIndex(current);
+ QRect rect = initialRect;
+ if (rect.isEmpty()) {
+ return d->model->index(0, d->column, d->root);
+ }
+ if (d->gridSize().isValid()) rect.setSize(d->gridSize());
+
+ QSize contents = d->contentsSize();
+ QVector<QModelIndex> intersectVector;
+
+ switch (cursorAction) {
+ case MoveLeft:
+ while (intersectVector.isEmpty()) {
+ rect.translate(-rect.width(), 0);
+ if (rect.right() <= 0)
+ return current;
+ if (rect.left() < 0)
+ rect.setLeft(0);
+ intersectVector = d->intersectingSet(rect);
+ d->removeCurrentAndDisabled(&intersectVector, current);
+ }
+ return d->closestIndex(initialRect, intersectVector);
+ case MoveRight:
+ while (intersectVector.isEmpty()) {
+ rect.translate(rect.width(), 0);
+ if (rect.left() >= contents.width())
+ return current;
+ if (rect.right() > contents.width())
+ rect.setRight(contents.width());
+ intersectVector = d->intersectingSet(rect);
+ d->removeCurrentAndDisabled(&intersectVector, current);
+ }
+ return d->closestIndex(initialRect, intersectVector);
+ case MovePageUp:
+ // move current by (visibileRowCount - 1) items.
+ // rect.translate(0, -rect.height()); will happen in the switch fallthrough for MoveUp.
+ rect.moveTop(rect.top() - d->viewport->height() + 2 * rect.height());
+ if (rect.top() < rect.height())
+ rect.moveTop(rect.height());
+ case MovePrevious:
+ case MoveUp:
+ while (intersectVector.isEmpty()) {
+ rect.translate(0, -rect.height());
+ if (rect.bottom() <= 0) {
+#ifdef QT_KEYPAD_NAVIGATION
+ if (QApplication::keypadNavigationEnabled()) {
+ int row = d->batchStartRow() - 1;
+ while (row >= 0 && d->isHiddenOrDisabled(row))
+ --row;
+ if (row >= 0)
+ return d->model->index(row, d->column, d->root);
+ }
+#endif
+ return current;
+ }
+ if (rect.top() < 0)
+ rect.setTop(0);
+ intersectVector = d->intersectingSet(rect);
+ d->removeCurrentAndDisabled(&intersectVector, current);
+ }
+ return d->closestIndex(initialRect, intersectVector);
+ case MovePageDown:
+ // move current by (visibileRowCount - 1) items.
+ // rect.translate(0, rect.height()); will happen in the switch fallthrough for MoveDown.
+ rect.moveTop(rect.top() + d->viewport->height() - 2 * rect.height());
+ if (rect.bottom() > contents.height() - rect.height())
+ rect.moveBottom(contents.height() - rect.height());
+ case MoveNext:
+ case MoveDown:
+ while (intersectVector.isEmpty()) {
+ rect.translate(0, rect.height());
+ if (rect.top() >= contents.height()) {
+#ifdef QT_KEYPAD_NAVIGATION
+ if (QApplication::keypadNavigationEnabled()) {
+ int rowCount = d->model->rowCount(d->root);
+ int row = 0;
+ while (row < rowCount && d->isHiddenOrDisabled(row))
+ ++row;
+ if (row < rowCount)
+ return d->model->index(row, d->column, d->root);
+ }
+#endif
+ return current;
+ }
+ if (rect.bottom() > contents.height())
+ rect.setBottom(contents.height());
+ intersectVector = d->intersectingSet(rect);
+ d->removeCurrentAndDisabled(&intersectVector, current);
+ }
+ return d->closestIndex(initialRect, intersectVector);
+ case MoveHome:
+ return d->model->index(0, d->column, d->root);
+ case MoveEnd:
+ return d->model->index(d->batchStartRow() - 1, d->column, d->root);}
+
+ return current;
+}
+
+/*!
+ Returns the rectangle of the item at position \a index in the
+ model. The rectangle is in contents coordinates.
+
+ \sa visualRect()
+*/
+QRect QListView::rectForIndex(const QModelIndex &index) const
+{
+ return d_func()->rectForIndex(index);
+}
+
+/*!
+ \since 4.1
+
+ Sets the contents position of the item at \a index in the model to the given
+ \a position.
+ If the list view's movement mode is Static or its view mode is ListView,
+ this function will have no effect.
+*/
+void QListView::setPositionForIndex(const QPoint &position, const QModelIndex &index)
+{
+ Q_D(QListView);
+ if (d->movement == Static
+ || !d->isIndexValid(index)
+ || index.parent() != d->root
+ || index.column() != d->column)
+ return;
+
+ d->executePostedLayout();
+ d->commonListView->setPositionForIndex(position, index);
+}
+
+/*!
+ \reimp
+*/
+void QListView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command)
+{
+ Q_D(QListView);
+ if (!d->selectionModel)
+ return;
+
+ // if we are wrapping, we can only selecte inside the contents rectangle
+ int w = qMax(d->contentsSize().width(), d->viewport->width());
+ int h = qMax(d->contentsSize().height(), d->viewport->height());
+ if (d->wrap && !QRect(0, 0, w, h).intersects(rect))
+ return;
+
+ QItemSelection selection;
+
+ if (rect.width() == 1 && rect.height() == 1) {
+ const QVector<QModelIndex> intersectVector = d->intersectingSet(rect.translated(horizontalOffset(), verticalOffset()));
+ QModelIndex tl;
+ if (!intersectVector.isEmpty())
+ tl = intersectVector.last(); // special case for mouse press; only select the top item
+ if (tl.isValid() && d->isIndexEnabled(tl))
+ selection.select(tl, tl);
+ } else {
+ if (state() == DragSelectingState) { // visual selection mode (rubberband selection)
+ selection = d->selection(rect.translated(horizontalOffset(), verticalOffset()));
+ } else { // logical selection mode (key and mouse click selection)
+ QModelIndex tl, br;
+ // get the first item
+ const QRect topLeft(rect.left() + horizontalOffset(), rect.top() + verticalOffset(), 1, 1);
+ QVector<QModelIndex> intersectVector = d->intersectingSet(topLeft);
+ if (!intersectVector.isEmpty())
+ tl = intersectVector.last();
+ // get the last item
+ const QRect bottomRight(rect.right() + horizontalOffset(), rect.bottom() + verticalOffset(), 1, 1);
+ intersectVector = d->intersectingSet(bottomRight);
+ if (!intersectVector.isEmpty())
+ br = intersectVector.last();
+
+ // get the ranges
+ if (tl.isValid() && br.isValid()
+ && d->isIndexEnabled(tl)
+ && d->isIndexEnabled(br)) {
+ QRect first = rectForIndex(tl);
+ QRect last = rectForIndex(br);
+ QRect middle;
+ if (d->flow == LeftToRight) {
+ QRect &top = first;
+ QRect &bottom = last;
+ // if bottom is above top, swap them
+ if (top.center().y() > bottom.center().y()) {
+ QRect tmp = top;
+ top = bottom;
+ bottom = tmp;
+ }
+ // if the rect are on differnet lines, expand
+ if (top.top() != bottom.top()) {
+ // top rectangle
+ if (isRightToLeft())
+ top.setLeft(0);
+ else
+ top.setRight(contentsSize().width());
+ // bottom rectangle
+ if (isRightToLeft())
+ bottom.setRight(contentsSize().width());
+ else
+ bottom.setLeft(0);
+ } else if (top.left() > bottom.right()) {
+ if (isRightToLeft())
+ bottom.setLeft(top.right());
+ else
+ bottom.setRight(top.left());
+ } else {
+ if (isRightToLeft())
+ top.setLeft(bottom.right());
+ else
+ top.setRight(bottom.left());
+ }
+ // middle rectangle
+ if (top.bottom() < bottom.top()) {
+ if (gridSize().isValid() && !gridSize().isNull())
+ middle.setTop(top.top() + gridSize().height());
+ else
+ middle.setTop(top.bottom() + 1);
+ middle.setLeft(qMin(top.left(), bottom.left()));
+ middle.setBottom(bottom.top() - 1);
+ middle.setRight(qMax(top.right(), bottom.right()));
+ }
+ } else { // TopToBottom
+ QRect &left = first;
+ QRect &right = last;
+ if (left.center().x() > right.center().x())
+ qSwap(left, right);
+
+ int ch = contentsSize().height();
+ if (left.left() != right.left()) {
+ // left rectangle
+ if (isRightToLeft())
+ left.setTop(0);
+ else
+ left.setBottom(ch);
+
+ // top rectangle
+ if (isRightToLeft())
+ right.setBottom(ch);
+ else
+ right.setTop(0);
+ // only set middle if the
+ middle.setTop(0);
+ middle.setBottom(ch);
+ if (gridSize().isValid() && !gridSize().isNull())
+ middle.setLeft(left.left() + gridSize().width());
+ else
+ middle.setLeft(left.right() + 1);
+ middle.setRight(right.left() - 1);
+ } else if (left.bottom() < right.top()) {
+ left.setBottom(right.top() - 1);
+ } else {
+ right.setBottom(left.top() - 1);
+ }
+ }
+
+ // do the selections
+ QItemSelection topSelection = d->selection(first);
+ QItemSelection middleSelection = d->selection(middle);
+ QItemSelection bottomSelection = d->selection(last);
+ // merge
+ selection.merge(topSelection, QItemSelectionModel::Select);
+ selection.merge(middleSelection, QItemSelectionModel::Select);
+ selection.merge(bottomSelection, QItemSelectionModel::Select);
+ }
+ }
+ }
+
+ d->selectionModel->select(selection, command);
+}
+
+/*!
+ \reimp
+
+ Since 4.7, the returned region only contains rectangles intersecting
+ (or included in) the viewport.
+*/
+QRegion QListView::visualRegionForSelection(const QItemSelection &selection) const
+{
+ Q_D(const QListView);
+ // ### NOTE: this is a potential bottleneck in non-static mode
+ int c = d->column;
+ QRegion selectionRegion;
+ const QRect &viewportRect = d->viewport->rect();
+ for (int i = 0; i < selection.count(); ++i) {
+ if (!selection.at(i).isValid())
+ continue;
+ QModelIndex parent = selection.at(i).topLeft().parent();
+ //we only display the children of the root in a listview
+ //we're not interested in the other model indexes
+ if (parent != d->root)
+ continue;
+ int t = selection.at(i).topLeft().row();
+ int b = selection.at(i).bottomRight().row();
+ if (d->viewMode == IconMode || d->isWrapping()) { // in non-static mode, we have to go through all selected items
+ for (int r = t; r <= b; ++r) {
+ const QRect &rect = visualRect(d->model->index(r, c, parent));
+ if (viewportRect.intersects(rect))
+ selectionRegion += rect;
+ }
+ } else { // in static mode, we can optimize a bit
+ while (t <= b && d->isHidden(t)) ++t;
+ while (b >= t && d->isHidden(b)) --b;
+ const QModelIndex top = d->model->index(t, c, parent);
+ const QModelIndex bottom = d->model->index(b, c, parent);
+ QRect rect(visualRect(top).topLeft(),
+ visualRect(bottom).bottomRight());
+ if (viewportRect.intersects(rect))
+ selectionRegion += rect;
+ }
+ }
+
+ return selectionRegion;
+}
+
+/*!
+ \reimp
+*/
+QModelIndexList QListView::selectedIndexes() const
+{
+ Q_D(const QListView);
+ if (!d->selectionModel)
+ return QModelIndexList();
+
+ QModelIndexList viewSelected = d->selectionModel->selectedIndexes();
+ for (int i = 0; i < viewSelected.count(); ++i) {
+ const QModelIndex &index = viewSelected.at(i);
+ if (!isIndexHidden(index) && index.parent() == d->root && index.column() == d->column)
+ ++i;
+ else
+ viewSelected.removeAt(i);
+ }
+ return viewSelected;
+}
+
+/*!
+ \internal
+
+ Layout the items according to the flow and wrapping properties.
+*/
+void QListView::doItemsLayout()
+{
+ Q_D(QListView);
+ // showing the scroll bars will trigger a resize event,
+ // so we set the state to expanding to avoid
+ // triggering another layout
+ QAbstractItemView::State oldState = state();
+ setState(ExpandingState);
+ if (d->model->columnCount(d->root) > 0) { // no columns means no contents
+ d->resetBatchStartRow();
+ if (layoutMode() == SinglePass)
+ d->doItemsLayout(d->model->rowCount(d->root)); // layout everything
+ else if (!d->batchLayoutTimer.isActive()) {
+ if (!d->doItemsLayout(d->batchSize)) // layout is done
+ d->batchLayoutTimer.start(0, this); // do a new batch as fast as possible
+ }
+ }
+ QAbstractItemView::doItemsLayout();
+ setState(oldState); // restoring the oldState
+}
+
+/*!
+ \reimp
+*/
+void QListView::updateGeometries()
+{
+ Q_D(QListView);
+ if (d->model->rowCount(d->root) <= 0 || d->model->columnCount(d->root) <= 0) {
+ horizontalScrollBar()->setRange(0, 0);
+ verticalScrollBar()->setRange(0, 0);
+ } else {
+ QModelIndex index = d->model->index(0, d->column, d->root);
+ QStyleOptionViewItemV4 option = d->viewOptionsV4();
+ QSize step = d->itemSize(option, index);
+ d->commonListView->updateHorizontalScrollBar(step);
+ d->commonListView->updateVerticalScrollBar(step);
+ }
+
+ QAbstractItemView::updateGeometries();
+
+ // if the scroll bars are turned off, we resize the contents to the viewport
+ if (d->movement == Static && !d->isWrapping()) {
+ const QSize maxSize = maximumViewportSize();
+ if (d->flow == TopToBottom) {
+ if (horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) {
+ d->setContentsSize(maxSize.width(), contentsSize().height());
+ horizontalScrollBar()->setRange(0, 0); // we see all the contents anyway
+ }
+ } else { // LeftToRight
+ if (verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff) {
+ d->setContentsSize(contentsSize().width(), maxSize.height());
+ verticalScrollBar()->setRange(0, 0); // we see all the contents anyway
+ }
+ }
+ }
+
+}
+
+/*!
+ \reimp
+*/
+bool QListView::isIndexHidden(const QModelIndex &index) const
+{
+ Q_D(const QListView);
+ return (d->isHidden(index.row())
+ && (index.parent() == d->root)
+ && index.column() == d->column);
+}
+
+/*!
+ \property QListView::modelColumn
+ \brief the column in the model that is visible
+
+ By default, this property contains 0, indicating that the first
+ column in the model will be shown.
+*/
+void QListView::setModelColumn(int column)
+{
+ Q_D(QListView);
+ if (column < 0 || column >= d->model->columnCount(d->root))
+ return;
+ d->column = column;
+ d->doDelayedItemsLayout();
+}
+
+int QListView::modelColumn() const
+{
+ Q_D(const QListView);
+ return d->column;
+}
+
+/*!
+ \property QListView::uniformItemSizes
+ \brief whether all items in the listview have the same size
+ \since 4.1
+
+ This property should only be set to true if it is guaranteed that all items
+ in the view have the same size. This enables the view to do some
+ optimizations for performance purposes.
+
+ By default, this property is false.
+*/
+void QListView::setUniformItemSizes(bool enable)
+{
+ Q_D(QListView);
+ d->uniformItemSizes = enable;
+}
+
+bool QListView::uniformItemSizes() const
+{
+ Q_D(const QListView);
+ return d->uniformItemSizes;
+}
+
+/*!
+ \property QListView::wordWrap
+ \brief the item text word-wrapping policy
+ \since 4.2
+
+ If this property is true then the item text is wrapped where
+ necessary at word-breaks; otherwise it is not wrapped at all.
+ This property is false by default.
+
+ Please note that even if wrapping is enabled, the cell will not be
+ expanded to make room for the text. It will print ellipsis for
+ text that cannot be shown, according to the view's
+ \l{QAbstractItemView::}{textElideMode}.
+*/
+void QListView::setWordWrap(bool on)
+{
+ Q_D(QListView);
+ if (d->wrapItemText == on)
+ return;
+ d->wrapItemText = on;
+ d->doDelayedItemsLayout();
+}
+
+bool QListView::wordWrap() const
+{
+ Q_D(const QListView);
+ return d->wrapItemText;
+}
+
+/*!
+ \property QListView::selectionRectVisible
+ \brief if the selection rectangle should be visible
+ \since 4.3
+
+ If this property is true then the selection rectangle is visible;
+ otherwise it will be hidden.
+
+ \note The selection rectangle will only be visible if the selection mode
+ is in a mode where more than one item can be selected; i.e., it will not
+ draw a selection rectangle if the selection mode is
+ QAbstractItemView::SingleSelection.
+
+ By default, this property is false.
+*/
+void QListView::setSelectionRectVisible(bool show)
+{
+ Q_D(QListView);
+ d->modeProperties |= uint(QListViewPrivate::SelectionRectVisible);
+ d->setSelectionRectVisible(show);
+}
+
+bool QListView::isSelectionRectVisible() const
+{
+ Q_D(const QListView);
+ return d->isSelectionRectVisible();
+}
+
+/*!
+ \reimp
+*/
+bool QListView::event(QEvent *e)
+{
+ return QAbstractItemView::event(e);
+}
+
+/*
+ * private object implementation
+ */
+
+QListViewPrivate::QListViewPrivate()
+ : QAbstractItemViewPrivate(),
+ commonListView(0),
+ wrap(false),
+ space(0),
+ flow(QListView::TopToBottom),
+ movement(QListView::Static),
+ resizeMode(QListView::Fixed),
+ layoutMode(QListView::SinglePass),
+ viewMode(QListView::ListMode),
+ modeProperties(0),
+ column(0),
+ uniformItemSizes(false),
+ batchSize(100),
+ showElasticBand(false)
+{
+}
+
+QListViewPrivate::~QListViewPrivate()
+{
+ delete commonListView;
+}
+
+void QListViewPrivate::clear()
+{
+ // initialization of data structs
+ cachedItemSize = QSize();
+ commonListView->clear();
+}
+
+void QListViewPrivate::prepareItemsLayout()
+{
+ Q_Q(QListView);
+ clear();
+
+ //take the size as if there were scrollbar in order to prevent scrollbar to blink
+ layoutBounds = QRect(QPoint(), q->maximumViewportSize());
+
+ int frameAroundContents = 0;
+ if (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents))
+ frameAroundContents = q->style()->pixelMetric(QStyle::PM_DefaultFrameWidth) * 2;
+
+ // maximumViewportSize() already takes scrollbar into account if policy is
+ // Qt::ScrollBarAlwaysOn but scrollbar extent must be deduced if policy
+ // is Qt::ScrollBarAsNeeded
+ int verticalMargin = vbarpolicy==Qt::ScrollBarAsNeeded
+ ? q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, vbar) + frameAroundContents
+ : 0;
+ int horizontalMargin = hbarpolicy==Qt::ScrollBarAsNeeded
+ ? q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, hbar) + frameAroundContents
+ : 0;
+
+ layoutBounds.adjust(0, 0, -verticalMargin, -horizontalMargin);
+
+ int rowCount = model->columnCount(root) <= 0 ? 0 : model->rowCount(root);
+ commonListView->setRowCount(rowCount);
+}
+
+/*!
+ \internal
+*/
+bool QListViewPrivate::doItemsLayout(int delta)
+{
+ int max = model->rowCount(root) - 1;
+ int first = batchStartRow();
+ int last = qMin(first + delta - 1, max);
+
+ if (first == 0) {
+ layoutChildren(); // make sure the viewport has the right size
+ prepareItemsLayout();
+ }
+
+ if (max < 0 || last < first) {
+ return true; // nothing to do
+ }
+
+ QListViewLayoutInfo info;
+ info.bounds = layoutBounds;
+ info.grid = gridSize();
+ info.spacing = (info.grid.isValid() ? 0 : spacing());
+ info.first = first;
+ info.last = last;
+ info.wrap = isWrapping();
+ info.flow = flow;
+ info.max = max;
+
+ return commonListView->doBatchedItemLayout(info, max);
+}
+
+QListViewItem QListViewPrivate::indexToListViewItem(const QModelIndex &index) const
+{
+ if (!index.isValid() || isHidden(index.row()))
+ return QListViewItem();
+
+ return commonListView->indexToListViewItem(index);
+}
+
+QRect QListViewPrivate::mapToViewport(const QRect &rect, bool extend) const
+{
+ Q_Q(const QListView);
+ if (!rect.isValid())
+ return rect;
+
+ QRect result = extend ? commonListView->mapToViewport(rect) : rect;
+ int dx = -q->horizontalOffset();
+ int dy = -q->verticalOffset();
+ return result.adjusted(dx, dy, dx, dy);
+}
+
+QModelIndex QListViewPrivate::closestIndex(const QRect &target,
+ const QVector<QModelIndex> &candidates) const
+{
+ int distance = 0;
+ int shortest = INT_MAX;
+ QModelIndex closest;
+ QVector<QModelIndex>::const_iterator it = candidates.begin();
+
+ for (; it != candidates.end(); ++it) {
+ if (!(*it).isValid())
+ continue;
+
+ const QRect indexRect = indexToListViewItem(*it).rect();
+
+ //if the center x (or y) position of an item is included in the rect of the other item,
+ //we define the distance between them as the difference in x (or y) of their respective center.
+ // Otherwise, we use the nahattan length between the 2 items
+ if ((target.center().x() >= indexRect.x() && target.center().x() < indexRect.right())
+ || (indexRect.center().x() >= target.x() && indexRect.center().x() < target.right())) {
+ //one item's center is at the vertical of the other
+ distance = qAbs(indexRect.center().y() - target.center().y());
+ } else if ((target.center().y() >= indexRect.y() && target.center().y() < indexRect.bottom())
+ || (indexRect.center().y() >= target.y() && indexRect.center().y() < target.bottom())) {
+ //one item's center is at the vertical of the other
+ distance = qAbs(indexRect.center().x() - target.center().x());
+ } else {
+ distance = (indexRect.center() - target.center()).manhattanLength();
+ }
+ if (distance < shortest) {
+ shortest = distance;
+ closest = *it;
+ }
+ }
+ return closest;
+}
+
+QSize QListViewPrivate::itemSize(const QStyleOptionViewItem &option, const QModelIndex &index) const
+{
+ if (!uniformItemSizes) {
+ const QAbstractItemDelegate *delegate = delegateForIndex(index);
+ return delegate ? delegate->sizeHint(option, index) : QSize();
+ }
+ if (!cachedItemSize.isValid()) { // the last item is probaly the largest, so we use its size
+ int row = model->rowCount(root) - 1;
+ QModelIndex sample = model->index(row, column, root);
+ const QAbstractItemDelegate *delegate = delegateForIndex(sample);
+ cachedItemSize = delegate ? delegate->sizeHint(option, sample) : QSize();
+ }
+ return cachedItemSize;
+}
+
+QItemSelection QListViewPrivate::selection(const QRect &rect) const
+{
+ QItemSelection selection;
+ QModelIndex tl, br;
+ const QVector<QModelIndex> intersectVector = intersectingSet(rect);
+ QVector<QModelIndex>::const_iterator it = intersectVector.begin();
+ for (; it != intersectVector.end(); ++it) {
+ if (!tl.isValid() && !br.isValid()) {
+ tl = br = *it;
+ } else if ((*it).row() == (tl.row() - 1)) {
+ tl = *it; // expand current range
+ } else if ((*it).row() == (br.row() + 1)) {
+ br = (*it); // expand current range
+ } else {
+ selection.select(tl, br); // select current range
+ tl = br = *it; // start new range
+ }
+ }
+
+ if (tl.isValid() && br.isValid())
+ selection.select(tl, br);
+ else if (tl.isValid())
+ selection.select(tl, tl);
+ else if (br.isValid())
+ selection.select(br, br);
+
+ return selection;
+}
+
+#ifndef QT_NO_DRAGANDDROP
+QAbstractItemView::DropIndicatorPosition QListViewPrivate::position(const QPoint &pos, const QRect &rect, const QModelIndex &idx) const
+{
+ if (viewMode == QListView::ListMode && flow == QListView::LeftToRight)
+ return static_cast<QListModeViewBase *>(commonListView)->position(pos, rect, idx);
+ else
+ return QAbstractItemViewPrivate::position(pos, rect, idx);
+}
+
+bool QListViewPrivate::dropOn(QDropEvent *event, int *dropRow, int *dropCol, QModelIndex *dropIndex)
+{
+ if (viewMode == QListView::ListMode && flow == QListView::LeftToRight)
+ return static_cast<QListModeViewBase *>(commonListView)->dropOn(event, dropRow, dropCol, dropIndex);
+ else
+ return QAbstractItemViewPrivate::dropOn(event, dropRow, dropCol, dropIndex);
+}
+#endif
+
+/*
+ * Common ListView Implementation
+*/
+
+void QCommonListViewBase::appendHiddenRow(int row)
+{
+ dd->hiddenRows.insert(dd->model->index(row, 0, qq->rootIndex()));
+}
+
+void QCommonListViewBase::removeHiddenRow(int row)
+{
+ dd->hiddenRows.remove(dd->model->index(row, 0, qq->rootIndex()));
+}
+
+void QCommonListViewBase::updateHorizontalScrollBar(const QSize &step)
+{
+ horizontalScrollBar()->setSingleStep(step.width() + spacing());
+ horizontalScrollBar()->setPageStep(viewport()->width());
+ horizontalScrollBar()->setRange(0, contentsSize.width() - viewport()->width());
+}
+
+void QCommonListViewBase::updateVerticalScrollBar(const QSize &step)
+{
+ verticalScrollBar()->setSingleStep(step.height() + spacing());
+ verticalScrollBar()->setPageStep(viewport()->height());
+ verticalScrollBar()->setRange(0, contentsSize.height() - viewport()->height());
+}
+
+void QCommonListViewBase::scrollContentsBy(int dx, int dy, bool /*scrollElasticBand*/)
+{
+ dd->scrollContentsBy(isRightToLeft() ? -dx : dx, dy);
+}
+
+int QCommonListViewBase::verticalScrollToValue(int /*index*/, QListView::ScrollHint hint,
+ bool above, bool below, const QRect &area, const QRect &rect) const
+{
+ int verticalValue = verticalScrollBar()->value();
+ QRect adjusted = rect.adjusted(-spacing(), -spacing(), spacing(), spacing());
+ if (hint == QListView::PositionAtTop || above)
+ verticalValue += adjusted.top();
+ else if (hint == QListView::PositionAtBottom || below)
+ verticalValue += qMin(adjusted.top(), adjusted.bottom() - area.height() + 1);
+ else if (hint == QListView::PositionAtCenter)
+ verticalValue += adjusted.top() - ((area.height() - adjusted.height()) / 2);
+ return verticalValue;
+}
+
+int QCommonListViewBase::horizontalOffset() const
+{
+ return (isRightToLeft() ? horizontalScrollBar()->maximum() - horizontalScrollBar()->value() : horizontalScrollBar()->value());
+}
+
+int QCommonListViewBase::horizontalScrollToValue(const int /*index*/, QListView::ScrollHint hint,
+ bool leftOf, bool rightOf, const QRect &area, const QRect &rect) const
+{
+ int horizontalValue = horizontalScrollBar()->value();
+ if (isRightToLeft()) {
+ if (hint == QListView::PositionAtCenter) {
+ horizontalValue += ((area.width() - rect.width()) / 2) - rect.left();
+ } else {
+ if (leftOf)
+ horizontalValue -= rect.left();
+ else if (rightOf)
+ horizontalValue += qMin(rect.left(), area.width() - rect.right());
+ }
+ } else {
+ if (hint == QListView::PositionAtCenter) {
+ horizontalValue += rect.left() - ((area.width()- rect.width()) / 2);
+ } else {
+ if (leftOf)
+ horizontalValue += rect.left();
+ else if (rightOf)
+ horizontalValue += qMin(rect.left(), rect.right() - area.width());
+ }
+ }
+ return horizontalValue;
+}
+
+/*
+ * ListMode ListView Implementation
+*/
+
+#ifndef QT_NO_DRAGANDDROP
+void QListModeViewBase::paintDragDrop(QPainter *painter)
+{
+ // FIXME: Until the we can provide a proper drop indicator
+ // in IconMode, it makes no sense to show it
+ dd->paintDropIndicator(painter);
+}
+
+QAbstractItemView::DropIndicatorPosition QListModeViewBase::position(const QPoint &pos, const QRect &rect, const QModelIndex &index) const
+{
+ QAbstractItemView::DropIndicatorPosition r = QAbstractItemView::OnViewport;
+ if (!dd->overwrite) {
+ const int margin = 2;
+ if (pos.x() - rect.left() < margin) {
+ r = QAbstractItemView::AboveItem; // Visually, on the left
+ } else if (rect.right() - pos.x() < margin) {
+ r = QAbstractItemView::BelowItem; // Visually, on the right
+ } else if (rect.contains(pos, true)) {
+ r = QAbstractItemView::OnItem;
+ }
+ } else {
+ QRect touchingRect = rect;
+ touchingRect.adjust(-1, -1, 1, 1);
+ if (touchingRect.contains(pos, false)) {
+ r = QAbstractItemView::OnItem;
+ }
+ }
+
+ if (r == QAbstractItemView::OnItem && (!(dd->model->flags(index) & Qt::ItemIsDropEnabled)))
+ r = pos.x() < rect.center().x() ? QAbstractItemView::AboveItem : QAbstractItemView::BelowItem;
+
+ return r;
+}
+
+void QListModeViewBase::dragMoveEvent(QDragMoveEvent *event)
+{
+ if (qq->dragDropMode() == QAbstractItemView::InternalMove
+ && (event->source() != qq || !(event->possibleActions() & Qt::MoveAction)))
+ return;
+
+ // ignore by default
+ event->ignore();
+
+ // can't use indexAt, doesn't account for spacing.
+ QPoint p = event->pos();
+ QRect rect(p.x() + horizontalOffset(), p.y() + verticalOffset(), 1, 1);
+ rect.adjust(-dd->spacing(), -dd->spacing(), dd->spacing(), dd->spacing());
+ const QVector<QModelIndex> intersectVector = dd->intersectingSet(rect);
+ QModelIndex index = intersectVector.count() > 0
+ ? intersectVector.last() : QModelIndex();
+ dd->hover = index;
+ if (!dd->droppingOnItself(event, index)
+ && dd->canDecode(event)) {
+
+ if (index.isValid() && dd->showDropIndicator) {
+ QRect rect = qq->visualRect(index);
+ dd->dropIndicatorPosition = position(event->pos(), rect, index);
+ // if spacing, should try to draw between items, not just next to item.
+ switch (dd->dropIndicatorPosition) {
+ case QAbstractItemView::AboveItem:
+ if (dd->isIndexDropEnabled(index.parent())) {
+ dd->dropIndicatorRect = QRect(rect.left()-dd->spacing(), rect.top(), 0, rect.height());
+ event->accept();
+ } else {
+ dd->dropIndicatorRect = QRect();
+ }
+ break;
+ case QAbstractItemView::BelowItem:
+ if (dd->isIndexDropEnabled(index.parent())) {
+ dd->dropIndicatorRect = QRect(rect.right()+dd->spacing(), rect.top(), 0, rect.height());
+ event->accept();
+ } else {
+ dd->dropIndicatorRect = QRect();
+ }
+ break;
+ case QAbstractItemView::OnItem:
+ if (dd->isIndexDropEnabled(index)) {
+ dd->dropIndicatorRect = rect;
+ event->accept();
+ } else {
+ dd->dropIndicatorRect = QRect();
+ }
+ break;
+ case QAbstractItemView::OnViewport:
+ dd->dropIndicatorRect = QRect();
+ if (dd->isIndexDropEnabled(qq->rootIndex())) {
+ event->accept(); // allow dropping in empty areas
+ }
+ break;
+ }
+ } else {
+ dd->dropIndicatorRect = QRect();
+ dd->dropIndicatorPosition = QAbstractItemView::OnViewport;
+ if (dd->isIndexDropEnabled(qq->rootIndex())) {
+ event->accept(); // allow dropping in empty areas
+ }
+ }
+ dd->viewport->update();
+ } // can decode
+
+ if (dd->shouldAutoScroll(event->pos()))
+ qq->startAutoScroll();
+}
+
+/*!
+ If the event hasn't already been accepted, determines the index to drop on.
+
+ if (row == -1 && col == -1)
+ // append to this drop index
+ else
+ // place at row, col in drop index
+
+ If it returns true a drop can be done, and dropRow, dropCol and dropIndex reflects the position of the drop.
+ \internal
+ */
+bool QListModeViewBase::dropOn(QDropEvent *event, int *dropRow, int *dropCol, QModelIndex *dropIndex)
+{
+ if (event->isAccepted())
+ return false;
+
+ QModelIndex index;
+ if (dd->viewport->rect().contains(event->pos())) {
+ // can't use indexAt, doesn't account for spacing.
+ QPoint p = event->pos();
+ QRect rect(p.x() + horizontalOffset(), p.y() + verticalOffset(), 1, 1);
+ rect.adjust(-dd->spacing(), -dd->spacing(), dd->spacing(), dd->spacing());
+ const QVector<QModelIndex> intersectVector = dd->intersectingSet(rect);
+ index = intersectVector.count() > 0
+ ? intersectVector.last() : QModelIndex();
+ if (!index.isValid())
+ index = dd->root;
+ }
+
+ // If we are allowed to do the drop
+ if (dd->model->supportedDropActions() & event->dropAction()) {
+ int row = -1;
+ int col = -1;
+ if (index != dd->root) {
+ dd->dropIndicatorPosition = position(event->pos(), qq->visualRect(index), index);
+ switch (dd->dropIndicatorPosition) {
+ case QAbstractItemView::AboveItem:
+ row = index.row();
+ col = index.column();
+ index = index.parent();
+ break;
+ case QAbstractItemView::BelowItem:
+ row = index.row() + 1;
+ col = index.column();
+ index = index.parent();
+ break;
+ case QAbstractItemView::OnItem:
+ case QAbstractItemView::OnViewport:
+ break;
+ }
+ } else {
+ dd->dropIndicatorPosition = QAbstractItemView::OnViewport;
+ }
+ *dropIndex = index;
+ *dropRow = row;
+ *dropCol = col;
+ if (!dd->droppingOnItself(event, index))
+ return true;
+ }
+ return false;
+}
+
+#endif //QT_NO_DRAGANDDROP
+
+void QListModeViewBase::updateVerticalScrollBar(const QSize &step)
+{
+ if (verticalScrollMode() == QAbstractItemView::ScrollPerItem
+ && ((flow() == QListView::TopToBottom && !isWrapping())
+ || (flow() == QListView::LeftToRight && isWrapping()))) {
+ const int steps = (flow() == QListView::TopToBottom ? scrollValueMap : segmentPositions).count() - 1;
+ if (steps > 0) {
+ const int pageSteps = perItemScrollingPageSteps(viewport()->height(), contentsSize.height(), isWrapping());
+ verticalScrollBar()->setSingleStep(1);
+ verticalScrollBar()->setPageStep(pageSteps);
+ verticalScrollBar()->setRange(0, steps - pageSteps);
+ } else {
+ verticalScrollBar()->setRange(0, 0);
+ }
+ // } else if (vertical && d->isWrapping() && d->movement == Static) {
+ // ### wrapped scrolling in flow direction
+ } else {
+ QCommonListViewBase::updateVerticalScrollBar(step);
+ }
+}
+
+void QListModeViewBase::updateHorizontalScrollBar(const QSize &step)
+{
+ if (horizontalScrollMode() == QAbstractItemView::ScrollPerItem
+ && ((flow() == QListView::TopToBottom && isWrapping())
+ || (flow() == QListView::LeftToRight && !isWrapping()))) {
+ int steps = (flow() == QListView::TopToBottom ? segmentPositions : scrollValueMap).count() - 1;
+ if (steps > 0) {
+ const int pageSteps = perItemScrollingPageSteps(viewport()->width(), contentsSize.width(), isWrapping());
+ horizontalScrollBar()->setSingleStep(1);
+ horizontalScrollBar()->setPageStep(pageSteps);
+ horizontalScrollBar()->setRange(0, steps - pageSteps);
+ } else {
+ horizontalScrollBar()->setRange(0, 0);
+ }
+ } else {
+ QCommonListViewBase::updateHorizontalScrollBar(step);
+ }
+}
+
+int QListModeViewBase::verticalScrollToValue(int index, QListView::ScrollHint hint,
+ bool above, bool below, const QRect &area, const QRect &rect) const
+{
+ if (verticalScrollMode() == QAbstractItemView::ScrollPerItem) {
+ int value;
+ if (scrollValueMap.isEmpty())
+ value = 0;
+ else
+ value = qBound(0, scrollValueMap.at(verticalScrollBar()->value()), flowPositions.count() - 1);
+ if (above)
+ hint = QListView::PositionAtTop;
+ else if (below)
+ hint = QListView::PositionAtBottom;
+ if (hint == QListView::EnsureVisible)
+ return value;
+
+ return perItemScrollToValue(index, value, area.height(), hint, Qt::Vertical, isWrapping(), rect.height());
+ }
+
+ return QCommonListViewBase::verticalScrollToValue(index, hint, above, below, area, rect);
+}
+
+int QListModeViewBase::horizontalOffset() const
+{
+ if (horizontalScrollMode() == QAbstractItemView::ScrollPerItem) {
+ if (isWrapping()) {
+ if (flow() == QListView::TopToBottom && !segmentPositions.isEmpty()) {
+ const int max = segmentPositions.count() - 1;
+ int currentValue = qBound(0, horizontalScrollBar()->value(), max);
+ int position = segmentPositions.at(currentValue);
+ int maximumValue = qBound(0, horizontalScrollBar()->maximum(), max);
+ int maximum = segmentPositions.at(maximumValue);
+ return (isRightToLeft() ? maximum - position : position);
+ }
+ } else if (flow() == QListView::LeftToRight && !flowPositions.isEmpty()) {
+ int position = flowPositions.at(scrollValueMap.at(horizontalScrollBar()->value()));
+ int maximum = flowPositions.at(scrollValueMap.at(horizontalScrollBar()->maximum()));
+ return (isRightToLeft() ? maximum - position : position);
+ }
+ }
+ return QCommonListViewBase::horizontalOffset();
+}
+
+int QListModeViewBase::verticalOffset() const
+{
+ if (verticalScrollMode() == QAbstractItemView::ScrollPerItem) {
+ if (isWrapping()) {
+ if (flow() == QListView::LeftToRight && !segmentPositions.isEmpty()) {
+ int value = verticalScrollBar()->value();
+ if (value >= segmentPositions.count())
+ return 0;
+ return segmentPositions.at(value) - spacing();
+ }
+ } else if (flow() == QListView::TopToBottom && !flowPositions.isEmpty()) {
+ int value = verticalScrollBar()->value();
+ if (value > scrollValueMap.count())
+ return 0;
+ return flowPositions.at(scrollValueMap.at(value)) - spacing();
+ }
+ }
+ return QCommonListViewBase::verticalOffset();
+}
+
+int QListModeViewBase::horizontalScrollToValue(int index, QListView::ScrollHint hint,
+ bool leftOf, bool rightOf, const QRect &area, const QRect &rect) const
+{
+ if (horizontalScrollMode() != QAbstractItemView::ScrollPerItem)
+ return QCommonListViewBase::horizontalScrollToValue(index, hint, leftOf, rightOf, area, rect);
+
+ int value;
+ if (scrollValueMap.isEmpty())
+ value = 0;
+ else
+ value = qBound(0, scrollValueMap.at(horizontalScrollBar()->value()), flowPositions.count() - 1);
+ if (leftOf)
+ hint = QListView::PositionAtTop;
+ else if (rightOf)
+ hint = QListView::PositionAtBottom;
+ if (hint == QListView::EnsureVisible)
+ return value;
+
+ return perItemScrollToValue(index, value, area.width(), hint, Qt::Horizontal, isWrapping(), rect.width());
+}
+
+void QListModeViewBase::scrollContentsBy(int dx, int dy, bool scrollElasticBand)
+{
+ // ### reorder this logic
+ const int verticalValue = verticalScrollBar()->value();
+ const int horizontalValue = horizontalScrollBar()->value();
+ const bool vertical = (verticalScrollMode() == QAbstractItemView::ScrollPerItem);
+ const bool horizontal = (horizontalScrollMode() == QAbstractItemView::ScrollPerItem);
+
+ if (isWrapping()) {
+ if (segmentPositions.isEmpty())
+ return;
+ const int max = segmentPositions.count() - 1;
+ if (horizontal && flow() == QListView::TopToBottom && dx != 0) {
+ int currentValue = qBound(0, horizontalValue, max);
+ int previousValue = qBound(0, currentValue + dx, max);
+ int currentCoordinate = segmentPositions.at(currentValue) - spacing();
+ int previousCoordinate = segmentPositions.at(previousValue) - spacing();
+ dx = previousCoordinate - currentCoordinate;
+ } else if (vertical && flow() == QListView::LeftToRight && dy != 0) {
+ int currentValue = qBound(0, verticalValue, max);
+ int previousValue = qBound(0, currentValue + dy, max);
+ int currentCoordinate = segmentPositions.at(currentValue) - spacing();
+ int previousCoordinate = segmentPositions.at(previousValue) - spacing();
+ dy = previousCoordinate - currentCoordinate;
+ }
+ } else {
+ if (flowPositions.isEmpty())
+ return;
+ const int max = scrollValueMap.count() - 1;
+ if (vertical && flow() == QListView::TopToBottom && dy != 0) {
+ int currentValue = qBound(0, verticalValue, max);
+ int previousValue = qBound(0, currentValue + dy, max);
+ int currentCoordinate = flowPositions.at(scrollValueMap.at(currentValue));
+ int previousCoordinate = flowPositions.at(scrollValueMap.at(previousValue));
+ dy = previousCoordinate - currentCoordinate;
+ } else if (horizontal && flow() == QListView::LeftToRight && dx != 0) {
+ int currentValue = qBound(0, horizontalValue, max);
+ int previousValue = qBound(0, currentValue + dx, max);
+ int currentCoordinate = flowPositions.at(scrollValueMap.at(currentValue));
+ int previousCoordinate = flowPositions.at(scrollValueMap.at(previousValue));
+ dx = previousCoordinate - currentCoordinate;
+ }
+ }
+ QCommonListViewBase::scrollContentsBy(dx, dy, scrollElasticBand);
+}
+
+bool QListModeViewBase::doBatchedItemLayout(const QListViewLayoutInfo &info, int max)
+{
+ doStaticLayout(info);
+ if (batchStartRow > max) { // stop items layout
+ flowPositions.resize(flowPositions.count());
+ segmentPositions.resize(segmentPositions.count());
+ segmentStartRows.resize(segmentStartRows.count());
+ return true; // done
+ }
+ return false; // not done
+}
+
+QListViewItem QListModeViewBase::indexToListViewItem(const QModelIndex &index) const
+{
+ if (flowPositions.isEmpty()
+ || segmentPositions.isEmpty()
+ || index.row() >= flowPositions.count())
+ return QListViewItem();
+
+ const int segment = qBinarySearch<int>(segmentStartRows, index.row(),
+ 0, segmentStartRows.count() - 1);
+
+
+ QStyleOptionViewItemV4 options = viewOptions();
+ options.rect.setSize(contentsSize);
+ QSize size = (uniformItemSizes() && cachedItemSize().isValid())
+ ? cachedItemSize() : itemSize(options, index);
+
+ QPoint pos;
+ if (flow() == QListView::LeftToRight) {
+ pos.setX(flowPositions.at(index.row()));
+ pos.setY(segmentPositions.at(segment));
+ } else { // TopToBottom
+ pos.setY(flowPositions.at(index.row()));
+ pos.setX(segmentPositions.at(segment));
+ if (isWrapping()) { // make the items as wide as the segment
+ int right = (segment + 1 >= segmentPositions.count()
+ ? contentsSize.width()
+ : segmentPositions.at(segment + 1));
+ size.setWidth(right - pos.x());
+ } else { // make the items as wide as the viewport
+ size.setWidth(qMax(size.width(), viewport()->width()));
+ }
+ }
+
+ return QListViewItem(QRect(pos, size), index.row());
+}
+
+QPoint QListModeViewBase::initStaticLayout(const QListViewLayoutInfo &info)
+{
+ int x, y;
+ if (info.first == 0) {
+ flowPositions.clear();
+ segmentPositions.clear();
+ segmentStartRows.clear();
+ segmentExtents.clear();
+ scrollValueMap.clear();
+ x = info.bounds.left() + info.spacing;
+ y = info.bounds.top() + info.spacing;
+ segmentPositions.append(info.flow == QListView::LeftToRight ? y : x);
+ segmentStartRows.append(0);
+ } else if (info.wrap) {
+ if (info.flow == QListView::LeftToRight) {
+ x = batchSavedPosition;
+ y = segmentPositions.last();
+ } else { // flow == QListView::TopToBottom
+ x = segmentPositions.last();
+ y = batchSavedPosition;
+ }
+ } else { // not first and not wrap
+ if (info.flow == QListView::LeftToRight) {
+ x = batchSavedPosition;
+ y = info.bounds.top() + info.spacing;
+ } else { // flow == QListView::TopToBottom
+ x = info.bounds.left() + info.spacing;
+ y = batchSavedPosition;
+ }
+ }
+ return QPoint(x, y);
+}
+
+/*!
+ \internal
+*/
+void QListModeViewBase::doStaticLayout(const QListViewLayoutInfo &info)
+{
+ const bool useItemSize = !info.grid.isValid();
+ const QPoint topLeft = initStaticLayout(info);
+ QStyleOptionViewItemV4 option = viewOptions();
+ option.rect = info.bounds;
+ option.rect.adjust(info.spacing, info.spacing, -info.spacing, -info.spacing);
+
+ // The static layout data structures are as follows:
+ // One vector contains the coordinate in the direction of layout flow.
+ // Another vector contains the coordinates of the segments.
+ // A third vector contains the index (model row) of the first item
+ // of each segment.
+
+ int segStartPosition;
+ int segEndPosition;
+ int deltaFlowPosition;
+ int deltaSegPosition;
+ int deltaSegHint;
+ int flowPosition;
+ int segPosition;
+
+ if (info.flow == QListView::LeftToRight) {
+ segStartPosition = info.bounds.left();
+ segEndPosition = info.bounds.width();
+ flowPosition = topLeft.x();
+ segPosition = topLeft.y();
+ deltaFlowPosition = info.grid.width(); // dx
+ deltaSegPosition = useItemSize ? batchSavedDeltaSeg : info.grid.height(); // dy
+ deltaSegHint = info.grid.height();
+ } else { // flow == QListView::TopToBottom
+ segStartPosition = info.bounds.top();
+ segEndPosition = info.bounds.height();
+ flowPosition = topLeft.y();
+ segPosition = topLeft.x();
+ deltaFlowPosition = info.grid.height(); // dy
+ deltaSegPosition = useItemSize ? batchSavedDeltaSeg : info.grid.width(); // dx
+ deltaSegHint = info.grid.width();
+ }
+
+ for (int row = info.first; row <= info.last; ++row) {
+ if (isHidden(row)) { // ###
+ flowPositions.append(flowPosition);
+ } else {
+ // if we are not using a grid, we need to find the deltas
+ if (useItemSize) {
+ QSize hint = itemSize(option, modelIndex(row));
+ if (info.flow == QListView::LeftToRight) {
+ deltaFlowPosition = hint.width() + info.spacing;
+ deltaSegHint = hint.height() + info.spacing;
+ } else { // TopToBottom
+ deltaFlowPosition = hint.height() + info.spacing;
+ deltaSegHint = hint.width() + info.spacing;
+ }
+ }
+ // create new segment
+ if (info.wrap && (flowPosition + deltaFlowPosition >= segEndPosition)) {
+ segmentExtents.append(flowPosition);
+ flowPosition = info.spacing + segStartPosition;
+ segPosition += deltaSegPosition;
+ if (info.wrap)
+ segPosition += info.spacing;
+ segmentPositions.append(segPosition);
+ segmentStartRows.append(row);
+ deltaSegPosition = 0;
+ }
+ // save the flow position of this item
+ scrollValueMap.append(flowPositions.count());
+ flowPositions.append(flowPosition);
+ // prepare for the next item
+ deltaSegPosition = qMax(deltaSegHint, deltaSegPosition);
+ flowPosition += info.spacing + deltaFlowPosition;
+ }
+ }
+ // used when laying out next batch
+ batchSavedPosition = flowPosition;
+ batchSavedDeltaSeg = deltaSegPosition;
+ batchStartRow = info.last + 1;
+ if (info.last == info.max)
+ flowPosition -= info.spacing; // remove extra spacing
+ // set the contents size
+ QRect rect = info.bounds;
+ if (info.flow == QListView::LeftToRight) {
+ rect.setRight(segmentPositions.count() == 1 ? flowPosition : info.bounds.right());
+ rect.setBottom(segPosition + deltaSegPosition);
+ } else { // TopToBottom
+ rect.setRight(segPosition + deltaSegPosition);
+ rect.setBottom(segmentPositions.count() == 1 ? flowPosition : info.bounds.bottom());
+ }
+ contentsSize = QSize(rect.right(), rect.bottom());
+ // if it is the last batch, save the end of the segments
+ if (info.last == info.max) {
+ segmentExtents.append(flowPosition);
+ scrollValueMap.append(flowPositions.count());
+ flowPositions.append(flowPosition);
+ segmentPositions.append(info.wrap ? segPosition + deltaSegPosition : INT_MAX);
+ }
+ // if the new items are visble, update the viewport
+ QRect changedRect(topLeft, rect.bottomRight());
+ if (clipRect().intersects(changedRect))
+ viewport()->update();
+}
+
+/*!
+ \internal
+ Finds the set of items intersecting with \a area.
+ In this function, itemsize is counted from topleft to the start of the next item.
+*/
+QVector<QModelIndex> QListModeViewBase::intersectingSet(const QRect &area) const
+{
+ QVector<QModelIndex> ret;
+ int segStartPosition;
+ int segEndPosition;
+ int flowStartPosition;
+ int flowEndPosition;
+ if (flow() == QListView::LeftToRight) {
+ segStartPosition = area.top();
+ segEndPosition = area.bottom();
+ flowStartPosition = area.left();
+ flowEndPosition = area.right();
+ } else {
+ segStartPosition = area.left();
+ segEndPosition = area.right();
+ flowStartPosition = area.top();
+ flowEndPosition = area.bottom();
+ }
+ if (segmentPositions.count() < 2 || flowPositions.isEmpty())
+ return ret;
+ // the last segment position is actually the edge of the last segment
+ const int segLast = segmentPositions.count() - 2;
+ int seg = qBinarySearch<int>(segmentPositions, segStartPosition, 0, segLast + 1);
+ for (; seg <= segLast && segmentPositions.at(seg) <= segEndPosition; ++seg) {
+ int first = segmentStartRows.at(seg);
+ int last = (seg < segLast ? segmentStartRows.at(seg + 1) : batchStartRow) - 1;
+ if (segmentExtents.at(seg) < flowStartPosition)
+ continue;
+ int row = qBinarySearch<int>(flowPositions, flowStartPosition, first, last);
+ for (; row <= last && flowPositions.at(row) <= flowEndPosition; ++row) {
+ if (isHidden(row))
+ continue;
+ QModelIndex index = modelIndex(row);
+ if (index.isValid())
+ ret += index;
+#if 0 // for debugging
+ else
+ qWarning("intersectingSet: row %d was invalid", row);
+#endif
+ }
+ }
+ return ret;
+}
+
+void QListModeViewBase::dataChanged(const QModelIndex &, const QModelIndex &)
+{
+ dd->doDelayedItemsLayout();
+}
+
+
+QRect QListModeViewBase::mapToViewport(const QRect &rect) const
+{
+ if (isWrapping())
+ return rect;
+ // If the listview is in "listbox-mode", the items are as wide as the view.
+ // But we don't shrink the items.
+ QRect result = rect;
+ if (flow() == QListView::TopToBottom) {
+ result.setLeft(spacing());
+ result.setWidth(qMax(rect.width(), qMax(contentsSize.width(), viewport()->width()) - 2 * spacing()));
+ } else { // LeftToRight
+ result.setTop(spacing());
+ result.setHeight(qMax(rect.height(), qMax(contentsSize.height(), viewport()->height()) - 2 * spacing()));
+ }
+ return result;
+}
+
+int QListModeViewBase::perItemScrollingPageSteps(int length, int bounds, bool wrap) const
+{
+ QVector<int> positions;
+ if (wrap)
+ positions = segmentPositions;
+ else if (!flowPositions.isEmpty()) {
+ positions.reserve(scrollValueMap.size());
+ foreach (int itemShown, scrollValueMap)
+ positions.append(flowPositions.at(itemShown));
+ }
+ if (positions.isEmpty() || bounds <= length)
+ return positions.count();
+ if (uniformItemSizes()) {
+ for (int i = 1; i < positions.count(); ++i)
+ if (positions.at(i) > 0)
+ return length / positions.at(i);
+ return 0; // all items had height 0
+ }
+ int pageSteps = 0;
+ int steps = positions.count() - 1;
+ int max = qMax(length, bounds);
+ int min = qMin(length, bounds);
+ int pos = min - (max - positions.last());
+
+ while (pos >= 0 && steps > 0) {
+ pos -= (positions.at(steps) - positions.at(steps - 1));
+ if (pos >= 0) //this item should be visible
+ ++pageSteps;
+ --steps;
+ }
+
+ // at this point we know that positions has at least one entry
+ return qMax(pageSteps, 1);
+}
+
+int QListModeViewBase::perItemScrollToValue(int index, int scrollValue, int viewportSize,
+ QAbstractItemView::ScrollHint hint,
+ Qt::Orientation orientation, bool wrap, int itemExtent) const
+{
+ if (index < 0)
+ return scrollValue;
+ if (!wrap) {
+ int topIndex = index;
+ const int bottomIndex = topIndex;
+ const int bottomCoordinate = flowPositions.at(index);
+
+ while (topIndex > 0 &&
+ (bottomCoordinate - flowPositions.at(topIndex-1) + itemExtent) <= (viewportSize)) {
+ topIndex--;
+ }
+
+ const int itemCount = bottomIndex - topIndex + 1;
+ switch (hint) {
+ case QAbstractItemView::PositionAtTop:
+ return index;
+ case QAbstractItemView::PositionAtBottom:
+ return index - itemCount + 1;
+ case QAbstractItemView::PositionAtCenter:
+ return index - (itemCount / 2);
+ default:
+ break;
+ }
+ } else { // wrapping
+ Qt::Orientation flowOrientation = (flow() == QListView::LeftToRight
+ ? Qt::Horizontal : Qt::Vertical);
+ if (flowOrientation == orientation) { // scrolling in the "flow" direction
+ // ### wrapped scrolling in the flow direction
+ return flowPositions.at(index); // ### always pixel based for now
+ } else if (!segmentStartRows.isEmpty()) { // we are scrolling in the "segment" direction
+ int segment = qBinarySearch<int>(segmentStartRows, index, 0, segmentStartRows.count() - 1);
+ int leftSegment = segment;
+ const int rightSegment = leftSegment;
+ const int bottomCoordinate = segmentPositions.at(segment);
+
+ while (leftSegment > scrollValue &&
+ (bottomCoordinate - segmentPositions.at(leftSegment-1) + itemExtent) <= (viewportSize)) {
+ leftSegment--;
+ }
+
+ const int segmentCount = rightSegment - leftSegment + 1;
+ switch (hint) {
+ case QAbstractItemView::PositionAtTop:
+ return segment;
+ case QAbstractItemView::PositionAtBottom:
+ return segment - segmentCount + 1;
+ case QAbstractItemView::PositionAtCenter:
+ return segment - (segmentCount / 2);
+ default:
+ break;
+ }
+ }
+ }
+ return scrollValue;
+}
+
+void QListModeViewBase::clear()
+{
+ flowPositions.clear();
+ segmentPositions.clear();
+ segmentStartRows.clear();
+ segmentExtents.clear();
+ batchSavedPosition = 0;
+ batchStartRow = 0;
+ batchSavedDeltaSeg = 0;
+}
+
+/*
+ * IconMode ListView Implementation
+*/
+
+void QIconModeViewBase::setPositionForIndex(const QPoint &position, const QModelIndex &index)
+{
+ if (index.row() >= items.count())
+ return;
+ const QSize oldContents = contentsSize;
+ qq->update(index); // update old position
+ moveItem(index.row(), position);
+ qq->update(index); // update new position
+
+ if (contentsSize != oldContents)
+ dd->viewUpdateGeometries(); // update the scroll bars
+}
+
+void QIconModeViewBase::appendHiddenRow(int row)
+{
+ if (row >= 0 && row < items.count()) //remove item
+ tree.removeLeaf(items.at(row).rect(), row);
+ QCommonListViewBase::appendHiddenRow(row);
+}
+
+void QIconModeViewBase::removeHiddenRow(int row)
+{
+ QCommonListViewBase::removeHiddenRow(row);
+ if (row >= 0 && row < items.count()) //insert item
+ tree.insertLeaf(items.at(row).rect(), row);
+}
+
+#ifndef QT_NO_DRAGANDDROP
+void QIconModeViewBase::paintDragDrop(QPainter *painter)
+{
+ if (!draggedItems.isEmpty() && viewport()->rect().contains(draggedItemsPos)) {
+ //we need to draw the items that arre dragged
+ painter->translate(draggedItemsDelta());
+ QStyleOptionViewItemV4 option = viewOptions();
+ option.state &= ~QStyle::State_MouseOver;
+ QVector<QModelIndex>::const_iterator it = draggedItems.begin();
+ QListViewItem item = indexToListViewItem(*it);
+ for (; it != draggedItems.end(); ++it) {
+ item = indexToListViewItem(*it);
+ option.rect = viewItemRect(item);
+ delegate(*it)->paint(painter, option, *it);
+ }
+ }
+}
+
+bool QIconModeViewBase::filterStartDrag(Qt::DropActions supportedActions)
+{
+ // This function does the same thing as in QAbstractItemView::startDrag(),
+ // plus adding viewitems to the draggedItems list.
+ // We need these items to draw the drag items
+ QModelIndexList indexes = dd->selectionModel->selectedIndexes();
+ if (indexes.count() > 0 ) {
+ if (viewport()->acceptDrops()) {
+ QModelIndexList::ConstIterator it = indexes.constBegin();
+ for (; it != indexes.constEnd(); ++it)
+ if (dd->model->flags(*it) & Qt::ItemIsDragEnabled
+ && (*it).column() == dd->column)
+ draggedItems.push_back(*it);
+ }
+ QDrag *drag = new QDrag(qq);
+ drag->setMimeData(dd->model->mimeData(indexes));
+ Qt::DropAction action = drag->exec(supportedActions, Qt::CopyAction);
+ draggedItems.clear();
+ if (action == Qt::MoveAction)
+ dd->clearOrRemove();
+ }
+ return true;
+}
+
+bool QIconModeViewBase::filterDropEvent(QDropEvent *e)
+{
+ if (e->source() != qq)
+ return false;
+
+ const QSize contents = contentsSize;
+ QPoint offset(horizontalOffset(), verticalOffset());
+ QPoint end = e->pos() + offset;
+ if (qq->acceptDrops()) {
+ const Qt::ItemFlags dropableFlags = Qt::ItemIsDropEnabled|Qt::ItemIsEnabled;
+ const QVector<QModelIndex> &dropIndices = intersectingSet(QRect(end, QSize(1, 1)));
+ foreach (const QModelIndex &index, dropIndices)
+ if ((index.flags() & dropableFlags) == dropableFlags)
+ return false;
+ }
+ QPoint start = dd->pressedPosition;
+ QPoint delta = (dd->movement == QListView::Snap ? snapToGrid(end) - snapToGrid(start) : end - start);
+ QList<QModelIndex> indexes = dd->selectionModel->selectedIndexes();
+ for (int i = 0; i < indexes.count(); ++i) {
+ QModelIndex index = indexes.at(i);
+ QRect rect = dd->rectForIndex(index);
+ viewport()->update(dd->mapToViewport(rect, false));
+ QPoint dest = rect.topLeft() + delta;
+ if (qq->isRightToLeft())
+ dest.setX(dd->flipX(dest.x()) - rect.width());
+ moveItem(index.row(), dest);
+ qq->update(index);
+ }
+ dd->stopAutoScroll();
+ draggedItems.clear();
+ dd->emitIndexesMoved(indexes);
+ e->accept(); // we have handled the event
+ // if the size has not grown, we need to check if it has shrinked
+ if (contentsSize != contents) {
+ if ((contentsSize.width() <= contents.width()
+ || contentsSize.height() <= contents.height())) {
+ updateContentsSize();
+ }
+ dd->viewUpdateGeometries();
+ }
+ return true;
+}
+
+bool QIconModeViewBase::filterDragLeaveEvent(QDragLeaveEvent *e)
+{
+ viewport()->update(draggedItemsRect()); // erase the area
+ draggedItemsPos = QPoint(-1, -1); // don't draw the dragged items
+ return QCommonListViewBase::filterDragLeaveEvent(e);
+}
+
+bool QIconModeViewBase::filterDragMoveEvent(QDragMoveEvent *e)
+{
+ if (e->source() != qq || !dd->canDecode(e))
+ return false;
+
+ // ignore by default
+ e->ignore();
+ // get old dragged items rect
+ QRect itemsRect = this->itemsRect(draggedItems);
+ viewport()->update(itemsRect.translated(draggedItemsDelta()));
+ // update position
+ draggedItemsPos = e->pos();
+ // get new items rect
+ viewport()->update(itemsRect.translated(draggedItemsDelta()));
+ // set the item under the cursor to current
+ QModelIndex index;
+ if (movement() == QListView::Snap) {
+ QRect rect(snapToGrid(e->pos() + offset()), gridSize());
+ const QVector<QModelIndex> intersectVector = intersectingSet(rect);
+ index = intersectVector.count() > 0 ? intersectVector.last() : QModelIndex();
+ } else {
+ index = qq->indexAt(e->pos());
+ }
+ // check if we allow drops here
+ if (draggedItems.contains(index))
+ e->accept(); // allow changing item position
+ else if (dd->model->flags(index) & Qt::ItemIsDropEnabled)
+ e->accept(); // allow dropping on dropenabled items
+ else if (!index.isValid())
+ e->accept(); // allow dropping in empty areas
+
+ // the event was treated. do autoscrolling
+ if (dd->shouldAutoScroll(e->pos()))
+ dd->startAutoScroll();
+ return true;
+}
+#endif // QT_NO_DRAGANDDROP
+
+void QIconModeViewBase::setRowCount(int rowCount)
+{
+ tree.create(qMax(rowCount - hiddenCount(), 0));
+}
+
+void QIconModeViewBase::scrollContentsBy(int dx, int dy, bool scrollElasticBand)
+{
+ if (scrollElasticBand)
+ dd->scrollElasticBandBy(isRightToLeft() ? -dx : dx, dy);
+
+ QCommonListViewBase::scrollContentsBy(dx, dy, scrollElasticBand);
+ if (!draggedItems.isEmpty())
+ viewport()->update(draggedItemsRect().translated(dx, dy));
+}
+
+void QIconModeViewBase::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
+{
+ if (column() >= topLeft.column() && column() <= bottomRight.column()) {
+ QStyleOptionViewItemV4 option = viewOptions();
+ int bottom = qMin(items.count(), bottomRight.row() + 1);
+ for (int row = topLeft.row(); row < bottom; ++row)
+ items[row].resize(itemSize(option, modelIndex(row)));
+ }
+}
+
+bool QIconModeViewBase::doBatchedItemLayout(const QListViewLayoutInfo &info, int max)
+{
+ if (info.last >= items.count()) {
+ //first we create the items
+ QStyleOptionViewItemV4 option = viewOptions();
+ for (int row = items.count(); row <= info.last; ++row) {
+ QSize size = itemSize(option, modelIndex(row));
+ QListViewItem item(QRect(0, 0, size.width(), size.height()), row); // default pos
+ items.append(item);
+ }
+ doDynamicLayout(info);
+ }
+ return (batchStartRow > max); // done
+}
+
+QListViewItem QIconModeViewBase::indexToListViewItem(const QModelIndex &index) const
+{
+ if (index.isValid() && index.row() < items.count())
+ return items.at(index.row());
+ return QListViewItem();
+}
+
+void QIconModeViewBase::initBspTree(const QSize &contents)
+{
+ // remove all items from the tree
+ int leafCount = tree.leafCount();
+ for (int l = 0; l < leafCount; ++l)
+ tree.leaf(l).clear();
+ // we have to get the bounding rect of the items before we can initialize the tree
+ QBspTree::Node::Type type = QBspTree::Node::Both; // 2D
+ // simple heuristics to get better bsp
+ if (contents.height() / contents.width() >= 3)
+ type = QBspTree::Node::HorizontalPlane;
+ else if (contents.width() / contents.height() >= 3)
+ type = QBspTree::Node::VerticalPlane;
+ // build tree for the bounding rect (not just the contents rect)
+ tree.init(QRect(0, 0, contents.width(), contents.height()), type);
+}
+
+QPoint QIconModeViewBase::initDynamicLayout(const QListViewLayoutInfo &info)
+{
+ int x, y;
+ if (info.first == 0) {
+ x = info.bounds.x() + info.spacing;
+ y = info.bounds.y() + info.spacing;
+ items.reserve(rowCount() - hiddenCount());
+ } else {
+ int idx = info.first - 1;
+ while (idx > 0 && !items.at(idx).isValid())
+ --idx;
+ const QListViewItem &item = items.at(idx);
+ x = item.x;
+ y = item.y;
+ if (info.flow == QListView::LeftToRight)
+ x += (info.grid.isValid() ? info.grid.width() : item.w) + info.spacing;
+ else
+ y += (info.grid.isValid() ? info.grid.height() : item.h) + info.spacing;
+ }
+ return QPoint(x, y);
+}
+
+/*!
+ \internal
+*/
+void QIconModeViewBase::doDynamicLayout(const QListViewLayoutInfo &info)
+{
+ const bool useItemSize = !info.grid.isValid();
+ const QPoint topLeft = initDynamicLayout(info);
+
+ int segStartPosition;
+ int segEndPosition;
+ int deltaFlowPosition;
+ int deltaSegPosition;
+ int deltaSegHint;
+ int flowPosition;
+ int segPosition;
+
+ if (info.flow == QListView::LeftToRight) {
+ segStartPosition = info.bounds.left() + info.spacing;
+ segEndPosition = info.bounds.right();
+ deltaFlowPosition = info.grid.width(); // dx
+ deltaSegPosition = (useItemSize ? batchSavedDeltaSeg : info.grid.height()); // dy
+ deltaSegHint = info.grid.height();
+ flowPosition = topLeft.x();
+ segPosition = topLeft.y();
+ } else { // flow == QListView::TopToBottom
+ segStartPosition = info.bounds.top() + info.spacing;
+ segEndPosition = info.bounds.bottom();
+ deltaFlowPosition = info.grid.height(); // dy
+ deltaSegPosition = (useItemSize ? batchSavedDeltaSeg : info.grid.width()); // dx
+ deltaSegHint = info.grid.width();
+ flowPosition = topLeft.y();
+ segPosition = topLeft.x();
+ }
+
+ if (moved.count() != items.count())
+ moved.resize(items.count());
+
+ QRect rect(QPoint(), topLeft);
+ QListViewItem *item = 0;
+ for (int row = info.first; row <= info.last; ++row) {
+ item = &items[row];
+ if (isHidden(row)) {
+ item->invalidate();
+ } else {
+ // if we are not using a grid, we need to find the deltas
+ if (useItemSize) {
+ if (info.flow == QListView::LeftToRight)
+ deltaFlowPosition = item->w + info.spacing;
+ else
+ deltaFlowPosition = item->h + info.spacing;
+ } else {
+ item->w = qMin<int>(info.grid.width(), item->w);
+ item->h = qMin<int>(info.grid.height(), item->h);
+ }
+
+ // create new segment
+ if (info.wrap
+ && flowPosition + deltaFlowPosition > segEndPosition
+ && flowPosition > segStartPosition) {
+ flowPosition = segStartPosition;
+ segPosition += deltaSegPosition;
+ if (useItemSize)
+ deltaSegPosition = 0;
+ }
+ // We must delay calculation of the seg adjustment, as this item
+ // may have caused a wrap to occur
+ if (useItemSize) {
+ if (info.flow == QListView::LeftToRight)
+ deltaSegHint = item->h + info.spacing;
+ else
+ deltaSegHint = item->w + info.spacing;
+ deltaSegPosition = qMax(deltaSegPosition, deltaSegHint);
+ }
+
+ // set the position of the item
+ // ### idealy we should have some sort of alignment hint for the item
+ // ### (normally that would be a point between the icon and the text)
+ if (!moved.testBit(row)) {
+ if (info.flow == QListView::LeftToRight) {
+ if (useItemSize) {
+ item->x = flowPosition;
+ item->y = segPosition;
+ } else { // use grid
+ item->x = flowPosition + ((deltaFlowPosition - item->w) / 2);
+ item->y = segPosition;
+ }
+ } else { // TopToBottom
+ if (useItemSize) {
+ item->y = flowPosition;
+ item->x = segPosition;
+ } else { // use grid
+ item->y = flowPosition + ((deltaFlowPosition - item->h) / 2);
+ item->x = segPosition;
+ }
+ }
+ }
+
+ // let the contents contain the new item
+ if (useItemSize)
+ rect |= item->rect();
+ else if (info.flow == QListView::LeftToRight)
+ rect |= QRect(flowPosition, segPosition, deltaFlowPosition, deltaSegPosition);
+ else // flow == TopToBottom
+ rect |= QRect(segPosition, flowPosition, deltaSegPosition, deltaFlowPosition);
+
+ // prepare for next item
+ flowPosition += deltaFlowPosition; // current position + item width + gap
+ }
+ }
+ batchSavedDeltaSeg = deltaSegPosition;
+ batchStartRow = info.last + 1;
+ bool done = (info.last >= rowCount() - 1);
+ // resize the content area
+ if (done || !info.bounds.contains(item->rect())) {
+ contentsSize = rect.size();
+ if (info.flow == QListView::LeftToRight)
+ contentsSize.rheight() += info.spacing;
+ else
+ contentsSize.rwidth() += info.spacing;
+ }
+ if (rect.size().isEmpty())
+ return;
+ // resize tree
+ int insertFrom = info.first;
+ if (done || info.first == 0) {
+ initBspTree(rect.size());
+ insertFrom = 0;
+ }
+ // insert items in tree
+ for (int row = insertFrom; row <= info.last; ++row)
+ tree.insertLeaf(items.at(row).rect(), row);
+ // if the new items are visble, update the viewport
+ QRect changedRect(topLeft, rect.bottomRight());
+ if (clipRect().intersects(changedRect))
+ viewport()->update();
+}
+
+QVector<QModelIndex> QIconModeViewBase::intersectingSet(const QRect &area) const
+{
+ QIconModeViewBase *that = const_cast<QIconModeViewBase*>(this);
+ QBspTree::Data data(static_cast<void*>(that));
+ QVector<QModelIndex> res;
+ that->interSectingVector = &res;
+ that->tree.climbTree(area, &QIconModeViewBase::addLeaf, data);
+ that->interSectingVector = 0;
+ return res;
+}
+
+QRect QIconModeViewBase::itemsRect(const QVector<QModelIndex> &indexes) const
+{
+ QVector<QModelIndex>::const_iterator it = indexes.begin();
+ QListViewItem item = indexToListViewItem(*it);
+ QRect rect(item.x, item.y, item.w, item.h);
+ for (; it != indexes.end(); ++it) {
+ item = indexToListViewItem(*it);
+ rect |= viewItemRect(item);
+ }
+ return rect;
+}
+
+int QIconModeViewBase::itemIndex(const QListViewItem &item) const
+{
+ if (!item.isValid())
+ return -1;
+ int i = item.indexHint;
+ if (i < items.count()) {
+ if (items.at(i) == item)
+ return i;
+ } else {
+ i = items.count() - 1;
+ }
+
+ int j = i;
+ int c = items.count();
+ bool a = true;
+ bool b = true;
+
+ while (a || b) {
+ if (a) {
+ if (items.at(i) == item) {
+ items.at(i).indexHint = i;
+ return i;
+ }
+ a = ++i < c;
+ }
+ if (b) {
+ if (items.at(j) == item) {
+ items.at(j).indexHint = j;
+ return j;
+ }
+ b = --j > -1;
+ }
+ }
+ return -1;
+}
+
+void QIconModeViewBase::addLeaf(QVector<int> &leaf, const QRect &area,
+ uint visited, QBspTree::Data data)
+{
+ QListViewItem *vi;
+ QIconModeViewBase *_this = static_cast<QIconModeViewBase *>(data.ptr);
+ for (int i = 0; i < leaf.count(); ++i) {
+ int idx = leaf.at(i);
+ if (idx < 0 || idx >= _this->items.count())
+ continue;
+ vi = &_this->items[idx];
+ Q_ASSERT(vi);
+ if (vi->isValid() && vi->rect().intersects(area) && vi->visited != visited) {
+ QModelIndex index = _this->dd->listViewItemToIndex(*vi);
+ Q_ASSERT(index.isValid());
+ _this->interSectingVector->append(index);
+ vi->visited = visited;
+ }
+ }
+}
+
+void QIconModeViewBase::moveItem(int index, const QPoint &dest)
+{
+ // does not impact on the bintree itself or the contents rect
+ QListViewItem *item = &items[index];
+ QRect rect = item->rect();
+
+ // move the item without removing it from the tree
+ tree.removeLeaf(rect, index);
+ item->move(dest);
+ tree.insertLeaf(QRect(dest, rect.size()), index);
+
+ // resize the contents area
+ contentsSize = (QRect(QPoint(0, 0), contentsSize)|QRect(dest, rect.size())).size();
+
+ // mark the item as moved
+ if (moved.count() != items.count())
+ moved.resize(items.count());
+ moved.setBit(index, true);
+}
+
+QPoint QIconModeViewBase::snapToGrid(const QPoint &pos) const
+{
+ int x = pos.x() - (pos.x() % gridSize().width());
+ int y = pos.y() - (pos.y() % gridSize().height());
+ return QPoint(x, y);
+}
+
+QPoint QIconModeViewBase::draggedItemsDelta() const
+{
+ if (movement() == QListView::Snap) {
+ QPoint snapdelta = QPoint((offset().x() % gridSize().width()),
+ (offset().y() % gridSize().height()));
+ return snapToGrid(draggedItemsPos + snapdelta) - snapToGrid(pressedPosition()) - snapdelta;
+ }
+ return draggedItemsPos - pressedPosition();
+}
+
+QRect QIconModeViewBase::draggedItemsRect() const
+{
+ QRect rect = itemsRect(draggedItems);
+ rect.translate(draggedItemsDelta());
+ return rect;
+}
+
+void QListViewPrivate::scrollElasticBandBy(int dx, int dy)
+{
+ if (dx > 0) // right
+ elasticBand.moveRight(elasticBand.right() + dx);
+ else if (dx < 0) // left
+ elasticBand.moveLeft(elasticBand.left() - dx);
+ if (dy > 0) // down
+ elasticBand.moveBottom(elasticBand.bottom() + dy);
+ else if (dy < 0) // up
+ elasticBand.moveTop(elasticBand.top() - dy);
+}
+
+void QIconModeViewBase::clear()
+{
+ tree.destroy();
+ items.clear();
+ moved.clear();
+ batchStartRow = 0;
+ batchSavedDeltaSeg = 0;
+}
+
+void QIconModeViewBase::updateContentsSize()
+{
+ QRect bounding;
+ for (int i = 0; i < items.count(); ++i)
+ bounding |= items.at(i).rect();
+ contentsSize = bounding.size();
+}
+
+/*!
+ \reimp
+*/
+void QListView::currentChanged(const QModelIndex &current, const QModelIndex &previous)
+{
+#ifndef QT_NO_ACCESSIBILITY
+ if (QAccessible::isActive()) {
+ if (current.isValid()) {
+ int entry = visualIndex(current) + 1;
+ QAccessible::updateAccessibility(viewport(), entry, QAccessible::Focus);
+ }
+ }
+#endif
+ QAbstractItemView::currentChanged(current, previous);
+}
+
+/*!
+ \reimp
+*/
+void QListView::selectionChanged(const QItemSelection &selected,
+ const QItemSelection &deselected)
+{
+#ifndef QT_NO_ACCESSIBILITY
+ if (QAccessible::isActive()) {
+ // ### does not work properly for selection ranges.
+ QModelIndex sel = selected.indexes().value(0);
+ if (sel.isValid()) {
+ int entry = visualIndex(sel) + 1;
+ QAccessible::updateAccessibility(viewport(), entry, QAccessible::Selection);
+ }
+ QModelIndex desel = deselected.indexes().value(0);
+ if (desel.isValid()) {
+ int entry = visualIndex(desel) + 1;
+ QAccessible::updateAccessibility(viewport(), entry, QAccessible::SelectionRemove);
+ }
+ }
+#endif
+ QAbstractItemView::selectionChanged(selected, deselected);
+}
+
+int QListView::visualIndex(const QModelIndex &index) const
+{
+ Q_D(const QListView);
+ d->executePostedLayout();
+ QListViewItem itm = d->indexToListViewItem(index);
+ return d->commonListView->itemIndex(itm);
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_LISTVIEW
diff --git a/src/widgets/itemviews/qlistview.h b/src/widgets/itemviews/qlistview.h
new file mode 100644
index 0000000000..eaf776aff9
--- /dev/null
+++ b/src/widgets/itemviews/qlistview.h
@@ -0,0 +1,203 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLISTVIEW_H
+#define QLISTVIEW_H
+
+#include <QtWidgets/qabstractitemview.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_LISTVIEW
+
+class QListViewPrivate;
+
+class Q_GUI_EXPORT QListView : public QAbstractItemView
+{
+ Q_OBJECT
+ Q_ENUMS(Movement Flow ResizeMode LayoutMode ViewMode)
+ Q_PROPERTY(Movement movement READ movement WRITE setMovement)
+ Q_PROPERTY(Flow flow READ flow WRITE setFlow)
+ Q_PROPERTY(bool isWrapping READ isWrapping WRITE setWrapping)
+ Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode)
+ Q_PROPERTY(LayoutMode layoutMode READ layoutMode WRITE setLayoutMode)
+ Q_PROPERTY(int spacing READ spacing WRITE setSpacing)
+ Q_PROPERTY(QSize gridSize READ gridSize WRITE setGridSize)
+ Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode)
+ Q_PROPERTY(int modelColumn READ modelColumn WRITE setModelColumn)
+ Q_PROPERTY(bool uniformItemSizes READ uniformItemSizes WRITE setUniformItemSizes)
+ Q_PROPERTY(int batchSize READ batchSize WRITE setBatchSize)
+ Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
+ Q_PROPERTY(bool selectionRectVisible READ isSelectionRectVisible WRITE setSelectionRectVisible)
+
+public:
+ enum Movement { Static, Free, Snap };
+ enum Flow { LeftToRight, TopToBottom };
+ enum ResizeMode { Fixed, Adjust };
+ enum LayoutMode { SinglePass, Batched };
+ enum ViewMode { ListMode, IconMode };
+
+ explicit QListView(QWidget *parent = 0);
+ ~QListView();
+
+ void setMovement(Movement movement);
+ Movement movement() const;
+
+ void setFlow(Flow flow);
+ Flow flow() const;
+
+ void setWrapping(bool enable);
+ bool isWrapping() const;
+
+ void setResizeMode(ResizeMode mode);
+ ResizeMode resizeMode() const;
+
+ void setLayoutMode(LayoutMode mode);
+ LayoutMode layoutMode() const;
+
+ void setSpacing(int space);
+ int spacing() const;
+
+ void setBatchSize(int batchSize);
+ int batchSize() const;
+
+ void setGridSize(const QSize &size);
+ QSize gridSize() const;
+
+ void setViewMode(ViewMode mode);
+ ViewMode viewMode() const;
+
+ void clearPropertyFlags();
+
+ bool isRowHidden(int row) const;
+ void setRowHidden(int row, bool hide);
+
+ void setModelColumn(int column);
+ int modelColumn() const;
+
+ void setUniformItemSizes(bool enable);
+ bool uniformItemSizes() const;
+
+ void setWordWrap(bool on);
+ bool wordWrap() const;
+
+ void setSelectionRectVisible(bool show);
+ bool isSelectionRectVisible() const;
+
+ QRect visualRect(const QModelIndex &index) const;
+ void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible);
+ QModelIndex indexAt(const QPoint &p) const;
+
+ void doItemsLayout();
+ void reset();
+ void setRootIndex(const QModelIndex &index);
+
+Q_SIGNALS:
+ void indexesMoved(const QModelIndexList &indexes);
+
+protected:
+ QListView(QListViewPrivate &, QWidget *parent = 0);
+
+ bool event(QEvent *e);
+
+ void scrollContentsBy(int dx, int dy);
+
+ void resizeContents(int width, int height);
+ QSize contentsSize() const;
+
+ void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+ void rowsInserted(const QModelIndex &parent, int start, int end);
+ void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
+
+ void mouseMoveEvent(QMouseEvent *e);
+ void mouseReleaseEvent(QMouseEvent *e);
+
+ void timerEvent(QTimerEvent *e);
+ void resizeEvent(QResizeEvent *e);
+#ifndef QT_NO_DRAGANDDROP
+ void dragMoveEvent(QDragMoveEvent *e);
+ void dragLeaveEvent(QDragLeaveEvent *e);
+ void dropEvent(QDropEvent *e);
+ void startDrag(Qt::DropActions supportedActions);
+
+ void internalDrop(QDropEvent *e);
+ void internalDrag(Qt::DropActions supportedActions);
+#endif // QT_NO_DRAGANDDROP
+
+ QStyleOptionViewItem viewOptions() const;
+ void paintEvent(QPaintEvent *e);
+
+ int horizontalOffset() const;
+ int verticalOffset() const;
+ QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
+ QRect rectForIndex(const QModelIndex &index) const;
+ void setPositionForIndex(const QPoint &position, const QModelIndex &index);
+
+ void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command);
+ QRegion visualRegionForSelection(const QItemSelection &selection) const;
+ QModelIndexList selectedIndexes() const;
+
+ void updateGeometries();
+
+ bool isIndexHidden(const QModelIndex &index) const;
+
+ void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
+ void currentChanged(const QModelIndex &current, const QModelIndex &previous);
+
+private:
+ friend class QAccessibleItemView;
+ int visualIndex(const QModelIndex &index) const;
+
+ Q_DECLARE_PRIVATE(QListView)
+ Q_DISABLE_COPY(QListView)
+};
+
+#endif // QT_NO_LISTVIEW
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QLISTVIEW_H
diff --git a/src/gui/itemviews/qlistview_p.h b/src/widgets/itemviews/qlistview_p.h
index 84aaaca2de..84aaaca2de 100644
--- a/src/gui/itemviews/qlistview_p.h
+++ b/src/widgets/itemviews/qlistview_p.h
diff --git a/src/gui/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp
index 61a935fdc9..61a935fdc9 100644
--- a/src/gui/itemviews/qlistwidget.cpp
+++ b/src/widgets/itemviews/qlistwidget.cpp
diff --git a/src/widgets/itemviews/qlistwidget.h b/src/widgets/itemviews/qlistwidget.h
new file mode 100644
index 0000000000..d9dadc51f0
--- /dev/null
+++ b/src/widgets/itemviews/qlistwidget.h
@@ -0,0 +1,335 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLISTWIDGET_H
+#define QLISTWIDGET_H
+
+#include <QtWidgets/qlistview.h>
+#include <QtCore/qvariant.h>
+#include <QtCore/qvector.h>
+#include <QtWidgets/qitemselectionmodel.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_LISTWIDGET
+
+class QListWidget;
+class QListModel;
+class QWidgetItemData;
+class QListWidgetItemPrivate;
+
+class Q_GUI_EXPORT QListWidgetItem
+{
+ friend class QListModel;
+ friend class QListWidget;
+public:
+ enum ItemType { Type = 0, UserType = 1000 };
+ explicit QListWidgetItem(QListWidget *view = 0, int type = Type);
+ explicit QListWidgetItem(const QString &text, QListWidget *view = 0, int type = Type);
+ explicit QListWidgetItem(const QIcon &icon, const QString &text,
+ QListWidget *view = 0, int type = Type);
+ QListWidgetItem(const QListWidgetItem &other);
+ virtual ~QListWidgetItem();
+
+ virtual QListWidgetItem *clone() const;
+
+ inline QListWidget *listWidget() const { return view; }
+
+ inline void setSelected(bool select);
+ inline bool isSelected() const;
+
+ inline void setHidden(bool hide);
+ inline bool isHidden() const;
+
+ inline Qt::ItemFlags flags() const { return itemFlags; }
+ void setFlags(Qt::ItemFlags flags);
+
+ inline QString text() const
+ { return data(Qt::DisplayRole).toString(); }
+ inline void setText(const QString &text);
+
+ inline QIcon icon() const
+ { return qvariant_cast<QIcon>(data(Qt::DecorationRole)); }
+ inline void setIcon(const QIcon &icon);
+
+ inline QString statusTip() const
+ { return data(Qt::StatusTipRole).toString(); }
+ inline void setStatusTip(const QString &statusTip);
+
+#ifndef QT_NO_TOOLTIP
+ inline QString toolTip() const
+ { return data(Qt::ToolTipRole).toString(); }
+ inline void setToolTip(const QString &toolTip);
+#endif
+
+#ifndef QT_NO_WHATSTHIS
+ inline QString whatsThis() const
+ { return data(Qt::WhatsThisRole).toString(); }
+ inline void setWhatsThis(const QString &whatsThis);
+#endif
+
+ inline QFont font() const
+ { return qvariant_cast<QFont>(data(Qt::FontRole)); }
+ inline void setFont(const QFont &font);
+
+ inline int textAlignment() const
+ { return data(Qt::TextAlignmentRole).toInt(); }
+ inline void setTextAlignment(int alignment)
+ { setData(Qt::TextAlignmentRole, alignment); }
+
+ inline QColor backgroundColor() const
+ { return qvariant_cast<QColor>(data(Qt::BackgroundColorRole)); }
+ virtual void setBackgroundColor(const QColor &color)
+ { setData(Qt::BackgroundColorRole, color); }
+
+ inline QBrush background() const
+ { return qvariant_cast<QBrush>(data(Qt::BackgroundRole)); }
+ inline void setBackground(const QBrush &brush)
+ { setData(Qt::BackgroundRole, brush); }
+
+ inline QColor textColor() const
+ { return qvariant_cast<QColor>(data(Qt::TextColorRole)); }
+ inline void setTextColor(const QColor &color)
+ { setData(Qt::TextColorRole, color); }
+
+ inline QBrush foreground() const
+ { return qvariant_cast<QBrush>(data(Qt::ForegroundRole)); }
+ inline void setForeground(const QBrush &brush)
+ { setData(Qt::ForegroundRole, brush); }
+
+ inline Qt::CheckState checkState() const
+ { return static_cast<Qt::CheckState>(data(Qt::CheckStateRole).toInt()); }
+ inline void setCheckState(Qt::CheckState state)
+ { setData(Qt::CheckStateRole, static_cast<int>(state)); }
+
+ inline QSize sizeHint() const
+ { return qvariant_cast<QSize>(data(Qt::SizeHintRole)); }
+ inline void setSizeHint(const QSize &size)
+ { setData(Qt::SizeHintRole, size); }
+
+ virtual QVariant data(int role) const;
+ virtual void setData(int role, const QVariant &value);
+
+ virtual bool operator<(const QListWidgetItem &other) const;
+
+#ifndef QT_NO_DATASTREAM
+ virtual void read(QDataStream &in);
+ virtual void write(QDataStream &out) const;
+#endif
+ QListWidgetItem &operator=(const QListWidgetItem &other);
+
+ inline int type() const { return rtti; }
+
+private:
+ int rtti;
+ QVector<void *> dummy;
+ QListWidget *view;
+ QListWidgetItemPrivate *d;
+ Qt::ItemFlags itemFlags;
+};
+
+inline void QListWidgetItem::setText(const QString &atext)
+{ setData(Qt::DisplayRole, atext); }
+
+inline void QListWidgetItem::setIcon(const QIcon &aicon)
+{ setData(Qt::DecorationRole, aicon); }
+
+inline void QListWidgetItem::setStatusTip(const QString &astatusTip)
+{ setData(Qt::StatusTipRole, astatusTip); }
+
+#ifndef QT_NO_TOOLTIP
+inline void QListWidgetItem::setToolTip(const QString &atoolTip)
+{ setData(Qt::ToolTipRole, atoolTip); }
+#endif
+
+#ifndef QT_NO_WHATSTHIS
+inline void QListWidgetItem::setWhatsThis(const QString &awhatsThis)
+{ setData(Qt::WhatsThisRole, awhatsThis); }
+#endif
+
+inline void QListWidgetItem::setFont(const QFont &afont)
+{ setData(Qt::FontRole, afont); }
+
+#ifndef QT_NO_DATASTREAM
+Q_GUI_EXPORT QDataStream &operator<<(QDataStream &out, const QListWidgetItem &item);
+Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QListWidgetItem &item);
+#endif
+
+class QListWidgetPrivate;
+
+class Q_GUI_EXPORT QListWidget : public QListView
+{
+ Q_OBJECT
+ Q_PROPERTY(int count READ count)
+ Q_PROPERTY(int currentRow READ currentRow WRITE setCurrentRow NOTIFY currentRowChanged USER true)
+ Q_PROPERTY(bool sortingEnabled READ isSortingEnabled WRITE setSortingEnabled)
+
+ friend class QListWidgetItem;
+ friend class QListModel;
+public:
+ explicit QListWidget(QWidget *parent = 0);
+ ~QListWidget();
+
+ QListWidgetItem *item(int row) const;
+ int row(const QListWidgetItem *item) const;
+ void insertItem(int row, QListWidgetItem *item);
+ void insertItem(int row, const QString &label);
+ void insertItems(int row, const QStringList &labels);
+ inline void addItem(const QString &label) { insertItem(count(), label); }
+ inline void addItem(QListWidgetItem *item);
+ inline void addItems(const QStringList &labels) { insertItems(count(), labels); }
+ QListWidgetItem *takeItem(int row);
+ int count() const;
+
+ QListWidgetItem *currentItem() const;
+ void setCurrentItem(QListWidgetItem *item);
+ void setCurrentItem(QListWidgetItem *item, QItemSelectionModel::SelectionFlags command);
+
+ int currentRow() const;
+ void setCurrentRow(int row);
+ void setCurrentRow(int row, QItemSelectionModel::SelectionFlags command);
+
+ QListWidgetItem *itemAt(const QPoint &p) const;
+ inline QListWidgetItem *itemAt(int x, int y) const;
+ QRect visualItemRect(const QListWidgetItem *item) const;
+
+ void sortItems(Qt::SortOrder order = Qt::AscendingOrder);
+ void setSortingEnabled(bool enable);
+ bool isSortingEnabled() const;
+
+ void editItem(QListWidgetItem *item);
+ void openPersistentEditor(QListWidgetItem *item);
+ void closePersistentEditor(QListWidgetItem *item);
+
+ QWidget *itemWidget(QListWidgetItem *item) const;
+ void setItemWidget(QListWidgetItem *item, QWidget *widget);
+ inline void removeItemWidget(QListWidgetItem *item);
+
+ bool isItemSelected(const QListWidgetItem *item) const;
+ void setItemSelected(const QListWidgetItem *item, bool select);
+ QList<QListWidgetItem*> selectedItems() const;
+ QList<QListWidgetItem*> findItems(const QString &text, Qt::MatchFlags flags) const;
+
+ bool isItemHidden(const QListWidgetItem *item) const;
+ void setItemHidden(const QListWidgetItem *item, bool hide);
+ void dropEvent(QDropEvent *event);
+
+public Q_SLOTS:
+ void scrollToItem(const QListWidgetItem *item, QAbstractItemView::ScrollHint hint = EnsureVisible);
+ void clear();
+
+Q_SIGNALS:
+ void itemPressed(QListWidgetItem *item);
+ void itemClicked(QListWidgetItem *item);
+ void itemDoubleClicked(QListWidgetItem *item);
+ void itemActivated(QListWidgetItem *item);
+ void itemEntered(QListWidgetItem *item);
+ void itemChanged(QListWidgetItem *item);
+
+ void currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous);
+ void currentTextChanged(const QString &currentText);
+ void currentRowChanged(int currentRow);
+
+ void itemSelectionChanged();
+
+protected:
+ bool event(QEvent *e);
+ virtual QStringList mimeTypes() const;
+ virtual QMimeData *mimeData(const QList<QListWidgetItem*> items) const;
+#ifndef QT_NO_DRAGANDDROP
+ virtual bool dropMimeData(int index, const QMimeData *data, Qt::DropAction action);
+ virtual Qt::DropActions supportedDropActions() const;
+#endif
+ QList<QListWidgetItem*> items(const QMimeData *data) const;
+
+ QModelIndex indexFromItem(QListWidgetItem *item) const;
+ QListWidgetItem *itemFromIndex(const QModelIndex &index) const;
+
+private:
+ void setModel(QAbstractItemModel *model);
+ Qt::SortOrder sortOrder() const;
+
+ Q_DECLARE_PRIVATE(QListWidget)
+ Q_DISABLE_COPY(QListWidget)
+
+ Q_PRIVATE_SLOT(d_func(), void _q_emitItemPressed(const QModelIndex &index))
+ Q_PRIVATE_SLOT(d_func(), void _q_emitItemClicked(const QModelIndex &index))
+ Q_PRIVATE_SLOT(d_func(), void _q_emitItemDoubleClicked(const QModelIndex &index))
+ Q_PRIVATE_SLOT(d_func(), void _q_emitItemActivated(const QModelIndex &index))
+ Q_PRIVATE_SLOT(d_func(), void _q_emitItemEntered(const QModelIndex &index))
+ Q_PRIVATE_SLOT(d_func(), void _q_emitItemChanged(const QModelIndex &index))
+ Q_PRIVATE_SLOT(d_func(), void _q_emitCurrentItemChanged(const QModelIndex &previous, const QModelIndex &current))
+ Q_PRIVATE_SLOT(d_func(), void _q_sort())
+ Q_PRIVATE_SLOT(d_func(), void _q_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight))
+};
+
+inline void QListWidget::removeItemWidget(QListWidgetItem *aItem)
+{ setItemWidget(aItem, 0); }
+
+inline void QListWidget::addItem(QListWidgetItem *aitem)
+{ insertItem(count(), aitem); }
+
+inline QListWidgetItem *QListWidget::itemAt(int ax, int ay) const
+{ return itemAt(QPoint(ax, ay)); }
+
+inline void QListWidgetItem::setSelected(bool aselect)
+{ if (view) view->setItemSelected(this, aselect); }
+
+inline bool QListWidgetItem::isSelected() const
+{ return (view ? view->isItemSelected(this) : false); }
+
+inline void QListWidgetItem::setHidden(bool ahide)
+{ if (view) view->setItemHidden(this, ahide); }
+
+inline bool QListWidgetItem::isHidden() const
+{ return (view ? view->isItemHidden(this) : false); }
+
+#endif // QT_NO_LISTWIDGET
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QLISTWIDGET_H
diff --git a/src/widgets/itemviews/qlistwidget_p.h b/src/widgets/itemviews/qlistwidget_p.h
new file mode 100644
index 0000000000..b180b8d51d
--- /dev/null
+++ b/src/widgets/itemviews/qlistwidget_p.h
@@ -0,0 +1,175 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLISTWIDGET_P_H
+#define QLISTWIDGET_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. This header file may change
+// from version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qabstractitemmodel.h>
+#include <QtWidgets/qabstractitemview.h>
+#include <QtWidgets/qlistwidget.h>
+#include <qitemdelegate.h>
+#include <private/qlistview_p.h>
+#include <private/qwidgetitemdata_p.h>
+
+#ifndef QT_NO_LISTWIDGET
+
+QT_BEGIN_NAMESPACE
+
+class QListModelLessThan
+{
+public:
+ inline bool operator()(QListWidgetItem *i1, QListWidgetItem *i2) const
+ { return *i1 < *i2; }
+};
+
+class QListModelGreaterThan
+{
+public:
+ inline bool operator()(QListWidgetItem *i1, QListWidgetItem *i2) const
+ { return *i2 < *i1; }
+};
+
+class Q_AUTOTEST_EXPORT QListModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ QListModel(QListWidget *parent);
+ ~QListModel();
+
+ void clear();
+ QListWidgetItem *at(int row) const;
+ void insert(int row, QListWidgetItem *item);
+ void insert(int row, const QStringList &items);
+ void remove(QListWidgetItem *item);
+ QListWidgetItem *take(int row);
+ void move(int srcRow, int dstRow);
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+
+ QModelIndex index(QListWidgetItem *item) const;
+ QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const;
+
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ bool setData(const QModelIndex &index, const QVariant &value, int role);
+
+ QMap<int, QVariant> itemData(const QModelIndex &index) const;
+
+ bool insertRows(int row, int count = 1, const QModelIndex &parent = QModelIndex());
+ bool removeRows(int row, int count = 1, const QModelIndex &parent = QModelIndex());
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+
+ void sort(int column, Qt::SortOrder order);
+ void ensureSorted(int column, Qt::SortOrder order, int start, int end);
+ static bool itemLessThan(const QPair<QListWidgetItem*,int> &left,
+ const QPair<QListWidgetItem*,int> &right);
+ static bool itemGreaterThan(const QPair<QListWidgetItem*,int> &left,
+ const QPair<QListWidgetItem*,int> &right);
+ static QList<QListWidgetItem*>::iterator sortedInsertionIterator(
+ const QList<QListWidgetItem*>::iterator &begin,
+ const QList<QListWidgetItem*>::iterator &end,
+ Qt::SortOrder order, QListWidgetItem *item);
+
+ void itemChanged(QListWidgetItem *item);
+
+ // dnd
+ QStringList mimeTypes() const;
+ QMimeData *mimeData(const QModelIndexList &indexes) const;
+#ifndef QT_NO_DRAGANDDROP
+ bool dropMimeData(const QMimeData *data, Qt::DropAction action,
+ int row, int column, const QModelIndex &parent);
+ Qt::DropActions supportedDropActions() const;
+#endif
+
+ QMimeData *internalMimeData() const;
+private:
+ QList<QListWidgetItem*> items;
+
+ // A cache must be mutable if get-functions should have const modifiers
+ mutable QModelIndexList cachedIndexes;
+};
+
+
+
+class QListWidgetPrivate : public QListViewPrivate
+{
+ Q_DECLARE_PUBLIC(QListWidget)
+public:
+ QListWidgetPrivate() : QListViewPrivate(), sortOrder(Qt::AscendingOrder), sortingEnabled(false) {}
+ inline QListModel *listModel() const { return qobject_cast<QListModel*>(model); }
+ void setup();
+ void _q_emitItemPressed(const QModelIndex &index);
+ void _q_emitItemClicked(const QModelIndex &index);
+ void _q_emitItemDoubleClicked(const QModelIndex &index);
+ void _q_emitItemActivated(const QModelIndex &index);
+ void _q_emitItemEntered(const QModelIndex &index);
+ void _q_emitItemChanged(const QModelIndex &index);
+ void _q_emitCurrentItemChanged(const QModelIndex &current, const QModelIndex &previous);
+ void _q_sort();
+ void _q_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+ Qt::SortOrder sortOrder;
+ bool sortingEnabled;
+};
+
+class QListWidgetItemPrivate
+{
+public:
+ QListWidgetItemPrivate(QListWidgetItem *item) : q(item), theid(-1) {}
+ QListWidgetItem *q;
+ QVector<QWidgetItemData> values;
+ int theid;
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_LISTWIDGET
+
+#endif // QLISTWIDGET_P_H
diff --git a/src/gui/itemviews/qproxymodel.cpp b/src/widgets/itemviews/qproxymodel.cpp
index 9a232a6a74..9a232a6a74 100644
--- a/src/gui/itemviews/qproxymodel.cpp
+++ b/src/widgets/itemviews/qproxymodel.cpp
diff --git a/src/gui/itemviews/qproxymodel.h b/src/widgets/itemviews/qproxymodel.h
index eeca4b266b..eeca4b266b 100644
--- a/src/gui/itemviews/qproxymodel.h
+++ b/src/widgets/itemviews/qproxymodel.h
diff --git a/src/gui/itemviews/qproxymodel_p.h b/src/widgets/itemviews/qproxymodel_p.h
index ef4bcbada2..ef4bcbada2 100644
--- a/src/gui/itemviews/qproxymodel_p.h
+++ b/src/widgets/itemviews/qproxymodel_p.h
diff --git a/src/gui/itemviews/qsortfilterproxymodel.cpp b/src/widgets/itemviews/qsortfilterproxymodel.cpp
index eb56f56ed4..eb56f56ed4 100644
--- a/src/gui/itemviews/qsortfilterproxymodel.cpp
+++ b/src/widgets/itemviews/qsortfilterproxymodel.cpp
diff --git a/src/widgets/itemviews/qsortfilterproxymodel.h b/src/widgets/itemviews/qsortfilterproxymodel.h
new file mode 100644
index 0000000000..7b15fa1f6e
--- /dev/null
+++ b/src/widgets/itemviews/qsortfilterproxymodel.h
@@ -0,0 +1,201 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSORTFILTERPROXYMODEL_H
+#define QSORTFILTERPROXYMODEL_H
+
+#include <QtWidgets/qabstractproxymodel.h>
+
+#ifndef QT_NO_SORTFILTERPROXYMODEL
+
+#include <QtCore/qregexp.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QSortFilterProxyModelPrivate;
+class QSortFilterProxyModelLessThan;
+class QSortFilterProxyModelGreaterThan;
+
+class Q_GUI_EXPORT QSortFilterProxyModel : public QAbstractProxyModel
+{
+ friend class QSortFilterProxyModelLessThan;
+ friend class QSortFilterProxyModelGreaterThan;
+
+ Q_OBJECT
+ Q_PROPERTY(QRegExp filterRegExp READ filterRegExp WRITE setFilterRegExp)
+ Q_PROPERTY(int filterKeyColumn READ filterKeyColumn WRITE setFilterKeyColumn)
+ Q_PROPERTY(bool dynamicSortFilter READ dynamicSortFilter WRITE setDynamicSortFilter)
+ Q_PROPERTY(Qt::CaseSensitivity filterCaseSensitivity READ filterCaseSensitivity WRITE setFilterCaseSensitivity)
+ Q_PROPERTY(Qt::CaseSensitivity sortCaseSensitivity READ sortCaseSensitivity WRITE setSortCaseSensitivity)
+ Q_PROPERTY(bool isSortLocaleAware READ isSortLocaleAware WRITE setSortLocaleAware)
+ Q_PROPERTY(int sortRole READ sortRole WRITE setSortRole)
+ Q_PROPERTY(int filterRole READ filterRole WRITE setFilterRole)
+
+public:
+ QSortFilterProxyModel(QObject *parent = 0);
+ ~QSortFilterProxyModel();
+
+ void setSourceModel(QAbstractItemModel *sourceModel);
+
+ QModelIndex mapToSource(const QModelIndex &proxyIndex) const;
+ QModelIndex mapFromSource(const QModelIndex &sourceIndex) const;
+
+ QItemSelection mapSelectionToSource(const QItemSelection &proxySelection) const;
+ QItemSelection mapSelectionFromSource(const QItemSelection &sourceSelection) const;
+
+ QRegExp filterRegExp() const;
+ void setFilterRegExp(const QRegExp &regExp);
+
+ int filterKeyColumn() const;
+ void setFilterKeyColumn(int column);
+
+ Qt::CaseSensitivity filterCaseSensitivity() const;
+ void setFilterCaseSensitivity(Qt::CaseSensitivity cs);
+
+ Qt::CaseSensitivity sortCaseSensitivity() const;
+ void setSortCaseSensitivity(Qt::CaseSensitivity cs);
+
+ bool isSortLocaleAware() const;
+ void setSortLocaleAware(bool on);
+
+ int sortColumn() const;
+ Qt::SortOrder sortOrder() const;
+
+ bool dynamicSortFilter() const;
+ void setDynamicSortFilter(bool enable);
+
+ int sortRole() const;
+ void setSortRole(int role);
+
+ int filterRole() const;
+ void setFilterRole(int role);
+
+public Q_SLOTS:
+ void setFilterRegExp(const QString &pattern);
+ void setFilterWildcard(const QString &pattern);
+ void setFilterFixedString(const QString &pattern);
+ void clear();
+ void invalidate();
+
+protected:
+ virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
+ virtual bool filterAcceptsColumn(int source_column, const QModelIndex &source_parent) const;
+ virtual bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
+
+ void filterChanged();
+ void invalidateFilter();
+
+public:
+#ifdef Q_NO_USING_KEYWORD
+ inline QObject *parent() const { return QObject::parent(); }
+#else
+ using QObject::parent;
+#endif
+
+ 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;
+ bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
+
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
+
+ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
+ bool setHeaderData(int section, Qt::Orientation orientation,
+ const QVariant &value, int role = Qt::EditRole);
+
+ QMimeData *mimeData(const QModelIndexList &indexes) const;
+ bool dropMimeData(const QMimeData *data, Qt::DropAction action,
+ int row, int column, const QModelIndex &parent);
+
+ bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
+ bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex());
+ bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
+ bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex());
+
+ void fetchMore(const QModelIndex &parent);
+ bool canFetchMore(const QModelIndex &parent) const;
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+
+ QModelIndex buddy(const QModelIndex &index) const;
+ QModelIndexList match(const QModelIndex &start, int role,
+ const QVariant &value, int hits = 1,
+ Qt::MatchFlags flags =
+ Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const;
+ QSize span(const QModelIndex &index) const;
+ void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
+
+ QStringList mimeTypes() const;
+ Qt::DropActions supportedDropActions() const;
+private:
+ Q_DECLARE_PRIVATE(QSortFilterProxyModel)
+ Q_DISABLE_COPY(QSortFilterProxyModel)
+
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceDataChanged(const QModelIndex &source_top_left, const QModelIndex &source_bottom_right))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceHeaderDataChanged(Qt::Orientation orientation, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceAboutToBeReset())
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceReset())
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutAboutToBeChanged())
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutChanged())
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeInserted(const QModelIndex &source_parent, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsInserted(const QModelIndex &source_parent, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsAboutToBeRemoved(const QModelIndex &source_parent, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceRowsRemoved(const QModelIndex &source_parent, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeInserted(const QModelIndex &source_parent, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsInserted(const QModelIndex &source_parent, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsAboutToBeRemoved(const QModelIndex &source_parent, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceColumnsRemoved(const QModelIndex &source_parent, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_clearMapping())
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QT_NO_SORTFILTERPROXYMODEL
+
+#endif // QSORTFILTERPROXYMODEL_H
diff --git a/src/gui/itemviews/qstandarditemmodel.cpp b/src/widgets/itemviews/qstandarditemmodel.cpp
index 711f5f8a40..711f5f8a40 100644
--- a/src/gui/itemviews/qstandarditemmodel.cpp
+++ b/src/widgets/itemviews/qstandarditemmodel.cpp
diff --git a/src/widgets/itemviews/qstandarditemmodel.h b/src/widgets/itemviews/qstandarditemmodel.h
new file mode 100644
index 0000000000..b1a87f418f
--- /dev/null
+++ b/src/widgets/itemviews/qstandarditemmodel.h
@@ -0,0 +1,456 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSTANDARDITEMMODEL_H
+#define QSTANDARDITEMMODEL_H
+
+#include <QtCore/qabstractitemmodel.h>
+#include <QtGui/qbrush.h>
+#include <QtGui/qfont.h>
+#include <QtWidgets/qicon.h>
+#ifndef QT_NO_DATASTREAM
+#include <QtCore/qdatastream.h>
+#endif
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_STANDARDITEMMODEL
+
+template <class T> class QList;
+
+class QStandardItemModel;
+
+class QStandardItemPrivate;
+class Q_GUI_EXPORT QStandardItem
+{
+public:
+ QStandardItem();
+ QStandardItem(const QString &text);
+ QStandardItem(const QIcon &icon, const QString &text);
+ explicit QStandardItem(int rows, int columns = 1);
+ virtual ~QStandardItem();
+
+ virtual QVariant data(int role = Qt::UserRole + 1) const;
+ virtual void setData(const QVariant &value, int role = Qt::UserRole + 1);
+
+ inline QString text() const {
+ return qvariant_cast<QString>(data(Qt::DisplayRole));
+ }
+ inline void setText(const QString &text);
+
+ inline QIcon icon() const {
+ return qvariant_cast<QIcon>(data(Qt::DecorationRole));
+ }
+ inline void setIcon(const QIcon &icon);
+
+#ifndef QT_NO_TOOLTIP
+ inline QString toolTip() const {
+ return qvariant_cast<QString>(data(Qt::ToolTipRole));
+ }
+ inline void setToolTip(const QString &toolTip);
+#endif
+
+#ifndef QT_NO_STATUSTIP
+ inline QString statusTip() const {
+ return qvariant_cast<QString>(data(Qt::StatusTipRole));
+ }
+ inline void setStatusTip(const QString &statusTip);
+#endif
+
+#ifndef QT_NO_WHATSTHIS
+ inline QString whatsThis() const {
+ return qvariant_cast<QString>(data(Qt::WhatsThisRole));
+ }
+ inline void setWhatsThis(const QString &whatsThis);
+#endif
+
+ inline QSize sizeHint() const {
+ return qvariant_cast<QSize>(data(Qt::SizeHintRole));
+ }
+ inline void setSizeHint(const QSize &sizeHint);
+
+ inline QFont font() const {
+ return qvariant_cast<QFont>(data(Qt::FontRole));
+ }
+ inline void setFont(const QFont &font);
+
+ inline Qt::Alignment textAlignment() const {
+ return Qt::Alignment(qvariant_cast<int>(data(Qt::TextAlignmentRole)));
+ }
+ inline void setTextAlignment(Qt::Alignment textAlignment);
+
+ inline QBrush background() const {
+ return qvariant_cast<QBrush>(data(Qt::BackgroundRole));
+ }
+ inline void setBackground(const QBrush &brush);
+
+ inline QBrush foreground() const {
+ return qvariant_cast<QBrush>(data(Qt::ForegroundRole));
+ }
+ inline void setForeground(const QBrush &brush);
+
+ inline Qt::CheckState checkState() const {
+ return Qt::CheckState(qvariant_cast<int>(data(Qt::CheckStateRole)));
+ }
+ inline void setCheckState(Qt::CheckState checkState);
+
+ inline QString accessibleText() const {
+ return qvariant_cast<QString>(data(Qt::AccessibleTextRole));
+ }
+ inline void setAccessibleText(const QString &accessibleText);
+
+ inline QString accessibleDescription() const {
+ return qvariant_cast<QString>(data(Qt::AccessibleDescriptionRole));
+ }
+ inline void setAccessibleDescription(const QString &accessibleDescription);
+
+ Qt::ItemFlags flags() const;
+ void setFlags(Qt::ItemFlags flags);
+
+ inline bool isEnabled() const {
+ return (flags() & Qt::ItemIsEnabled) != 0;
+ }
+ void setEnabled(bool enabled);
+
+ inline bool isEditable() const {
+ return (flags() & Qt::ItemIsEditable) != 0;
+ }
+ void setEditable(bool editable);
+
+ inline bool isSelectable() const {
+ return (flags() & Qt::ItemIsSelectable) != 0;
+ }
+ void setSelectable(bool selectable);
+
+ inline bool isCheckable() const {
+ return (flags() & Qt::ItemIsUserCheckable) != 0;
+ }
+ void setCheckable(bool checkable);
+
+ inline bool isTristate() const {
+ return (flags() & Qt::ItemIsTristate) != 0;
+ }
+ void setTristate(bool tristate);
+
+#ifndef QT_NO_DRAGANDDROP
+ inline bool isDragEnabled() const {
+ return (flags() & Qt::ItemIsDragEnabled) != 0;
+ }
+ void setDragEnabled(bool dragEnabled);
+
+ inline bool isDropEnabled() const {
+ return (flags() & Qt::ItemIsDropEnabled) != 0;
+ }
+ void setDropEnabled(bool dropEnabled);
+#endif // QT_NO_DRAGANDDROP
+
+ QStandardItem *parent() const;
+ int row() const;
+ int column() const;
+ QModelIndex index() const;
+ QStandardItemModel *model() const;
+
+ int rowCount() const;
+ void setRowCount(int rows);
+ int columnCount() const;
+ void setColumnCount(int columns);
+
+ bool hasChildren() const;
+ QStandardItem *child(int row, int column = 0) const;
+ void setChild(int row, int column, QStandardItem *item);
+ inline void setChild(int row, QStandardItem *item);
+
+ void insertRow(int row, const QList<QStandardItem*> &items);
+ void insertColumn(int column, const QList<QStandardItem*> &items);
+ void insertRows(int row, const QList<QStandardItem*> &items);
+ void insertRows(int row, int count);
+ void insertColumns(int column, int count);
+
+ void removeRow(int row);
+ void removeColumn(int column);
+ void removeRows(int row, int count);
+ void removeColumns(int column, int count);
+
+ inline void appendRow(const QList<QStandardItem*> &items);
+ inline void appendRows(const QList<QStandardItem*> &items);
+ inline void appendColumn(const QList<QStandardItem*> &items);
+ inline void insertRow(int row, QStandardItem *item);
+ inline void appendRow(QStandardItem *item);
+
+ QStandardItem *takeChild(int row, int column = 0);
+ QList<QStandardItem*> takeRow(int row);
+ QList<QStandardItem*> takeColumn(int column);
+
+ void sortChildren(int column, Qt::SortOrder order = Qt::AscendingOrder);
+
+ virtual QStandardItem *clone() const;
+
+ enum ItemType { Type = 0, UserType = 1000 };
+ virtual int type() const;
+
+#ifndef QT_NO_DATASTREAM
+ virtual void read(QDataStream &in);
+ virtual void write(QDataStream &out) const;
+#endif
+ virtual bool operator<(const QStandardItem &other) const;
+
+protected:
+ QStandardItem(const QStandardItem &other);
+ QStandardItem(QStandardItemPrivate &dd);
+ QStandardItem &operator=(const QStandardItem &other);
+ QScopedPointer<QStandardItemPrivate> d_ptr;
+
+ void emitDataChanged();
+
+private:
+ Q_DECLARE_PRIVATE(QStandardItem)
+ friend class QStandardItemModelPrivate;
+ friend class QStandardItemModel;
+};
+
+inline void QStandardItem::setText(const QString &atext)
+{ setData(atext, Qt::DisplayRole); }
+
+inline void QStandardItem::setIcon(const QIcon &aicon)
+{ setData(aicon, Qt::DecorationRole); }
+
+#ifndef QT_NO_TOOLTIP
+inline void QStandardItem::setToolTip(const QString &atoolTip)
+{ setData(atoolTip, Qt::ToolTipRole); }
+#endif
+
+#ifndef QT_NO_STATUSTIP
+inline void QStandardItem::setStatusTip(const QString &astatusTip)
+{ setData(astatusTip, Qt::StatusTipRole); }
+#endif
+
+#ifndef QT_NO_WHATSTHIS
+inline void QStandardItem::setWhatsThis(const QString &awhatsThis)
+{ setData(awhatsThis, Qt::WhatsThisRole); }
+#endif
+
+inline void QStandardItem::setSizeHint(const QSize &asizeHint)
+{ setData(asizeHint, Qt::SizeHintRole); }
+
+inline void QStandardItem::setFont(const QFont &afont)
+{ setData(afont, Qt::FontRole); }
+
+inline void QStandardItem::setTextAlignment(Qt::Alignment atextAlignment)
+{ setData(int(atextAlignment), Qt::TextAlignmentRole); }
+
+inline void QStandardItem::setBackground(const QBrush &abrush)
+{ setData(abrush, Qt::BackgroundRole); }
+
+inline void QStandardItem::setForeground(const QBrush &abrush)
+{ setData(abrush, Qt::ForegroundRole); }
+
+inline void QStandardItem::setCheckState(Qt::CheckState acheckState)
+{ setData(acheckState, Qt::CheckStateRole); }
+
+inline void QStandardItem::setAccessibleText(const QString &aaccessibleText)
+{ setData(aaccessibleText, Qt::AccessibleTextRole); }
+
+inline void QStandardItem::setAccessibleDescription(const QString &aaccessibleDescription)
+{ setData(aaccessibleDescription, Qt::AccessibleDescriptionRole); }
+
+inline void QStandardItem::setChild(int arow, QStandardItem *aitem)
+{ setChild(arow, 0, aitem); }
+
+inline void QStandardItem::appendRow(const QList<QStandardItem*> &aitems)
+{ insertRow(rowCount(), aitems); }
+
+inline void QStandardItem::appendRows(const QList<QStandardItem*> &aitems)
+{ insertRows(rowCount(), aitems); }
+
+inline void QStandardItem::appendColumn(const QList<QStandardItem*> &aitems)
+{ insertColumn(columnCount(), aitems); }
+
+inline void QStandardItem::insertRow(int arow, QStandardItem *aitem)
+{ insertRow(arow, QList<QStandardItem*>() << aitem); }
+
+inline void QStandardItem::appendRow(QStandardItem *aitem)
+{ insertRow(rowCount(), aitem); }
+
+class QStandardItemModelPrivate;
+
+class Q_GUI_EXPORT QStandardItemModel : public QAbstractItemModel
+{
+ Q_OBJECT
+ Q_PROPERTY(int sortRole READ sortRole WRITE setSortRole)
+
+public:
+ explicit QStandardItemModel(QObject *parent = 0);
+ QStandardItemModel(int rows, int columns, QObject *parent = 0);
+ ~QStandardItemModel();
+
+ 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;
+ bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
+
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
+
+ QVariant headerData(int section, Qt::Orientation orientation,
+ int role = Qt::DisplayRole) const;
+ bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value,
+ int role = Qt::EditRole);
+
+ bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
+ bool insertColumns(int column, int count, const QModelIndex &parent = QModelIndex());
+ bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
+ bool removeColumns(int column, int count, const QModelIndex &parent = QModelIndex());
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ Qt::DropActions supportedDropActions() const;
+
+ QMap<int, QVariant> itemData(const QModelIndex &index) const;
+ bool setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles);
+
+ void clear();
+
+#ifdef Q_NO_USING_KEYWORD
+ inline QObject *parent() const { return QObject::parent(); }
+#else
+ using QObject::parent;
+#endif
+
+ void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
+
+ QStandardItem *itemFromIndex(const QModelIndex &index) const;
+ QModelIndex indexFromItem(const QStandardItem *item) const;
+
+ QStandardItem *item(int row, int column = 0) const;
+ void setItem(int row, int column, QStandardItem *item);
+ inline void setItem(int row, QStandardItem *item);
+ QStandardItem *invisibleRootItem() const;
+
+ QStandardItem *horizontalHeaderItem(int column) const;
+ void setHorizontalHeaderItem(int column, QStandardItem *item);
+ QStandardItem *verticalHeaderItem(int row) const;
+ void setVerticalHeaderItem(int row, QStandardItem *item);
+
+ void setHorizontalHeaderLabels(const QStringList &labels);
+ void setVerticalHeaderLabels(const QStringList &labels);
+
+ void setRowCount(int rows);
+ void setColumnCount(int columns);
+
+ void appendRow(const QList<QStandardItem*> &items);
+ void appendColumn(const QList<QStandardItem*> &items);
+ inline void appendRow(QStandardItem *item);
+
+ void insertRow(int row, const QList<QStandardItem*> &items);
+ void insertColumn(int column, const QList<QStandardItem*> &items);
+ inline void insertRow(int row, QStandardItem *item);
+
+ inline bool insertRow(int row, const QModelIndex &parent = QModelIndex());
+ inline bool insertColumn(int column, const QModelIndex &parent = QModelIndex());
+
+ QStandardItem *takeItem(int row, int column = 0);
+ QList<QStandardItem*> takeRow(int row);
+ QList<QStandardItem*> takeColumn(int column);
+
+ QStandardItem *takeHorizontalHeaderItem(int column);
+ QStandardItem *takeVerticalHeaderItem(int row);
+
+ const QStandardItem *itemPrototype() const;
+ void setItemPrototype(const QStandardItem *item);
+
+ QList<QStandardItem*> findItems(const QString &text,
+ Qt::MatchFlags flags = Qt::MatchExactly,
+ int column = 0) const;
+
+ int sortRole() const;
+ void setSortRole(int role);
+
+ QStringList mimeTypes() const;
+ QMimeData *mimeData(const QModelIndexList &indexes) const;
+ bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
+
+Q_SIGNALS:
+ void itemChanged(QStandardItem *item);
+
+protected:
+ QStandardItemModel(QStandardItemModelPrivate &dd, QObject *parent = 0);
+
+private:
+ friend class QStandardItemPrivate;
+ friend class QStandardItem;
+ Q_DISABLE_COPY(QStandardItemModel)
+ Q_DECLARE_PRIVATE(QStandardItemModel)
+
+ Q_PRIVATE_SLOT(d_func(), void _q_emitItemChanged(const QModelIndex &topLeft,
+ const QModelIndex &bottomRight))
+};
+
+inline void QStandardItemModel::setItem(int arow, QStandardItem *aitem)
+{ setItem(arow, 0, aitem); }
+
+inline void QStandardItemModel::appendRow(QStandardItem *aitem)
+{ appendRow(QList<QStandardItem*>() << aitem); }
+
+inline void QStandardItemModel::insertRow(int arow, QStandardItem *aitem)
+{ insertRow(arow, QList<QStandardItem*>() << aitem); }
+
+inline bool QStandardItemModel::insertRow(int arow, const QModelIndex &aparent)
+{ return QAbstractItemModel::insertRow(arow, aparent); }
+inline bool QStandardItemModel::insertColumn(int acolumn, const QModelIndex &aparent)
+{ return QAbstractItemModel::insertColumn(acolumn, aparent); }
+
+#ifndef QT_NO_DATASTREAM
+Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QStandardItem &item);
+Q_GUI_EXPORT QDataStream &operator<<(QDataStream &out, const QStandardItem &item);
+#endif
+
+#endif // QT_NO_STANDARDITEMMODEL
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif //QSTANDARDITEMMODEL_H
diff --git a/src/gui/itemviews/qstandarditemmodel_p.h b/src/widgets/itemviews/qstandarditemmodel_p.h
index bc053398a3..bc053398a3 100644
--- a/src/gui/itemviews/qstandarditemmodel_p.h
+++ b/src/widgets/itemviews/qstandarditemmodel_p.h
diff --git a/src/gui/itemviews/qstringlistmodel.cpp b/src/widgets/itemviews/qstringlistmodel.cpp
index d2e4c2204e..d2e4c2204e 100644
--- a/src/gui/itemviews/qstringlistmodel.cpp
+++ b/src/widgets/itemviews/qstringlistmodel.cpp
diff --git a/src/widgets/itemviews/qstringlistmodel.h b/src/widgets/itemviews/qstringlistmodel.h
new file mode 100644
index 0000000000..06527d6485
--- /dev/null
+++ b/src/widgets/itemviews/qstringlistmodel.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSTRINGLISTMODEL_H
+#define QSTRINGLISTMODEL_H
+
+#include <QtCore/qstringlist.h>
+#include <QtWidgets/qabstractitemview.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_STRINGLISTMODEL
+
+class Q_GUI_EXPORT QStringListModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ explicit QStringListModel(QObject *parent = 0);
+ QStringListModel(const QStringList &strings, QObject *parent = 0);
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+
+ QVariant data(const QModelIndex &index, int role) const;
+ bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+
+ bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
+ bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
+
+ void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
+
+ QStringList stringList() const;
+ void setStringList(const QStringList &strings);
+
+ Qt::DropActions supportedDropActions() const;
+
+private:
+ Q_DISABLE_COPY(QStringListModel)
+ QStringList lst;
+};
+
+#endif // QT_NO_STRINGLISTMODEL
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QSTRINGLISTMODEL_H
diff --git a/src/gui/itemviews/qstyleditemdelegate.cpp b/src/widgets/itemviews/qstyleditemdelegate.cpp
index 4989c05c69..4989c05c69 100644
--- a/src/gui/itemviews/qstyleditemdelegate.cpp
+++ b/src/widgets/itemviews/qstyleditemdelegate.cpp
diff --git a/src/widgets/itemviews/qstyleditemdelegate.h b/src/widgets/itemviews/qstyleditemdelegate.h
new file mode 100644
index 0000000000..b171a6c50e
--- /dev/null
+++ b/src/widgets/itemviews/qstyleditemdelegate.h
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSTYLEDITEMDELEGATE_H
+#define QSTYLEDITEMDELEGATE_H
+
+#include <QtWidgets/qabstractitemdelegate.h>
+#include <QtCore/qstring.h>
+#include <QtGui/qpixmap.h>
+#include <QtCore/qvariant.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_ITEMVIEWS
+
+class QStyledItemDelegatePrivate;
+class QItemEditorFactory;
+
+class Q_GUI_EXPORT QStyledItemDelegate : public QAbstractItemDelegate
+{
+ Q_OBJECT
+
+public:
+ explicit QStyledItemDelegate(QObject *parent = 0);
+ ~QStyledItemDelegate();
+
+ // painting
+ void paint(QPainter *painter,
+ const QStyleOptionViewItem &option, const QModelIndex &index) const;
+ QSize sizeHint(const QStyleOptionViewItem &option,
+ const QModelIndex &index) const;
+
+ // editing
+ 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;
+
+ // editor factory
+ QItemEditorFactory *itemEditorFactory() const;
+ void setItemEditorFactory(QItemEditorFactory *factory);
+
+ virtual QString displayText(const QVariant &value, const QLocale &locale) const;
+
+protected:
+ virtual void initStyleOption(QStyleOptionViewItem *option,
+ const QModelIndex &index) const;
+
+ bool eventFilter(QObject *object, QEvent *event);
+ bool editorEvent(QEvent *event, QAbstractItemModel *model,
+ const QStyleOptionViewItem &option, const QModelIndex &index);
+
+private:
+ Q_DECLARE_PRIVATE(QStyledItemDelegate)
+ Q_DISABLE_COPY(QStyledItemDelegate)
+
+ Q_PRIVATE_SLOT(d_func(), void _q_commitDataAndCloseEditor(QWidget*))
+};
+
+#endif // QT_NO_ITEMVIEWS
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QSTYLEDITEMDELEGATE_H
diff --git a/src/gui/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp
index e70f3569aa..e70f3569aa 100644
--- a/src/gui/itemviews/qtableview.cpp
+++ b/src/widgets/itemviews/qtableview.cpp
diff --git a/src/widgets/itemviews/qtableview.h b/src/widgets/itemviews/qtableview.h
new file mode 100644
index 0000000000..7dfe262b6d
--- /dev/null
+++ b/src/widgets/itemviews/qtableview.h
@@ -0,0 +1,198 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTABLEVIEW_H
+#define QTABLEVIEW_H
+
+#include <QtWidgets/qabstractitemview.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_TABLEVIEW
+
+class QHeaderView;
+class QTableViewPrivate;
+
+class Q_GUI_EXPORT QTableView : public QAbstractItemView
+{
+ Q_OBJECT
+ Q_PROPERTY(bool showGrid READ showGrid WRITE setShowGrid)
+ Q_PROPERTY(Qt::PenStyle gridStyle READ gridStyle WRITE setGridStyle)
+ Q_PROPERTY(bool sortingEnabled READ isSortingEnabled WRITE setSortingEnabled)
+ Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
+ Q_PROPERTY(bool cornerButtonEnabled READ isCornerButtonEnabled WRITE setCornerButtonEnabled)
+
+public:
+ explicit QTableView(QWidget *parent = 0);
+ ~QTableView();
+
+ void setModel(QAbstractItemModel *model);
+ void setRootIndex(const QModelIndex &index);
+ void setSelectionModel(QItemSelectionModel *selectionModel);
+ void doItemsLayout();
+
+ QHeaderView *horizontalHeader() const;
+ QHeaderView *verticalHeader() const;
+ void setHorizontalHeader(QHeaderView *header);
+ void setVerticalHeader(QHeaderView *header);
+
+ int rowViewportPosition(int row) const;
+ int rowAt(int y) const;
+
+ void setRowHeight(int row, int height);
+ int rowHeight(int row) const;
+
+ int columnViewportPosition(int column) const;
+ int columnAt(int x) const;
+
+ void setColumnWidth(int column, int width);
+ int columnWidth(int column) const;
+
+ bool isRowHidden(int row) const;
+ void setRowHidden(int row, bool hide);
+
+ bool isColumnHidden(int column) const;
+ void setColumnHidden(int column, bool hide);
+
+ void setSortingEnabled(bool enable);
+ bool isSortingEnabled() const;
+
+ bool showGrid() const;
+
+ Qt::PenStyle gridStyle() const;
+ void setGridStyle(Qt::PenStyle style);
+
+ void setWordWrap(bool on);
+ bool wordWrap() const;
+
+ void setCornerButtonEnabled(bool enable);
+ bool isCornerButtonEnabled() const;
+
+ QRect visualRect(const QModelIndex &index) const;
+ void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible);
+ QModelIndex indexAt(const QPoint &p) const;
+
+ void setSpan(int row, int column, int rowSpan, int columnSpan);
+ int rowSpan(int row, int column) const;
+ int columnSpan(int row, int column) const;
+ void clearSpans();
+
+ void sortByColumn(int column, Qt::SortOrder order);
+
+public Q_SLOTS:
+ void selectRow(int row);
+ void selectColumn(int column);
+ void hideRow(int row);
+ void hideColumn(int column);
+ void showRow(int row);
+ void showColumn(int column);
+ void resizeRowToContents(int row);
+ void resizeRowsToContents();
+ void resizeColumnToContents(int column);
+ void resizeColumnsToContents();
+ void sortByColumn(int column);
+ void setShowGrid(bool show);
+
+protected Q_SLOTS:
+ void rowMoved(int row, int oldIndex, int newIndex);
+ void columnMoved(int column, int oldIndex, int newIndex);
+ void rowResized(int row, int oldHeight, int newHeight);
+ void columnResized(int column, int oldWidth, int newWidth);
+ void rowCountChanged(int oldCount, int newCount);
+ void columnCountChanged(int oldCount, int newCount);
+
+protected:
+ QTableView(QTableViewPrivate &, QWidget *parent);
+ void scrollContentsBy(int dx, int dy);
+
+ QStyleOptionViewItem viewOptions() const;
+ void paintEvent(QPaintEvent *e);
+
+ void timerEvent(QTimerEvent *event);
+
+ int horizontalOffset() const;
+ int verticalOffset() const;
+ QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
+
+ void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command);
+ QRegion visualRegionForSelection(const QItemSelection &selection) const;
+ QModelIndexList selectedIndexes() const;
+
+ void updateGeometries();
+
+ int sizeHintForRow(int row) const;
+ int sizeHintForColumn(int column) const;
+
+ void verticalScrollbarAction(int action);
+ void horizontalScrollbarAction(int action);
+
+ bool isIndexHidden(const QModelIndex &index) const;
+
+ void selectionChanged(const QItemSelection &selected,
+ const QItemSelection &deselected);
+ void currentChanged(const QModelIndex &current,
+ const QModelIndex &previous);
+
+private:
+ friend class QAccessibleItemView;
+ int visualIndex(const QModelIndex &index) const;
+
+ Q_DECLARE_PRIVATE(QTableView)
+ Q_DISABLE_COPY(QTableView)
+ Q_PRIVATE_SLOT(d_func(), void _q_selectRow(int))
+ Q_PRIVATE_SLOT(d_func(), void _q_selectColumn(int))
+ Q_PRIVATE_SLOT(d_func(), void _q_updateSpanInsertedRows(QModelIndex,int,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_updateSpanInsertedColumns(QModelIndex,int,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_updateSpanRemovedRows(QModelIndex,int,int))
+ Q_PRIVATE_SLOT(d_func(), void _q_updateSpanRemovedColumns(QModelIndex,int,int))
+};
+
+#endif // QT_NO_TABLEVIEW
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QTABLEVIEW_H
diff --git a/src/gui/itemviews/qtableview_p.h b/src/widgets/itemviews/qtableview_p.h
index e3d2a8f4a6..e3d2a8f4a6 100644
--- a/src/gui/itemviews/qtableview_p.h
+++ b/src/widgets/itemviews/qtableview_p.h
diff --git a/src/gui/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp
index 3c5d22379a..3c5d22379a 100644
--- a/src/gui/itemviews/qtablewidget.cpp
+++ b/src/widgets/itemviews/qtablewidget.cpp
diff --git a/src/widgets/itemviews/qtablewidget.h b/src/widgets/itemviews/qtablewidget.h
new file mode 100644
index 0000000000..b675809476
--- /dev/null
+++ b/src/widgets/itemviews/qtablewidget.h
@@ -0,0 +1,377 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTABLEWIDGET_H
+#define QTABLEWIDGET_H
+
+#include <QtWidgets/qtableview.h>
+#include <QtCore/qvariant.h>
+#include <QtCore/qvector.h>
+//#include <QtWidgets/qitemselectionmodel.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_TABLEWIDGET
+
+class Q_GUI_EXPORT QTableWidgetSelectionRange
+{
+public:
+ QTableWidgetSelectionRange();
+ QTableWidgetSelectionRange(int top, int left, int bottom, int right);
+ QTableWidgetSelectionRange(const QTableWidgetSelectionRange &other);
+ ~QTableWidgetSelectionRange();
+
+ inline int topRow() const { return top; }
+ inline int bottomRow() const { return bottom; }
+ inline int leftColumn() const { return left; }
+ inline int rightColumn() const { return right; }
+ inline int rowCount() const { return bottom - top + 1; }
+ inline int columnCount() const { return right - left + 1; }
+
+private:
+ int top, left, bottom, right;
+};
+
+class QTableWidget;
+class QTableModel;
+class QWidgetItemData;
+class QTableWidgetItemPrivate;
+
+class Q_GUI_EXPORT QTableWidgetItem
+{
+ friend class QTableWidget;
+ friend class QTableModel;
+public:
+ enum ItemType { Type = 0, UserType = 1000 };
+ QTableWidgetItem(int type = Type);
+ explicit QTableWidgetItem(const QString &text, int type = Type);
+ explicit QTableWidgetItem(const QIcon &icon, const QString &text, int type = Type);
+ QTableWidgetItem(const QTableWidgetItem &other);
+ virtual ~QTableWidgetItem();
+
+ virtual QTableWidgetItem *clone() const;
+
+ inline QTableWidget *tableWidget() const { return view; }
+
+ inline int row() const;
+ inline int column() const;
+
+ inline void setSelected(bool select);
+ inline bool isSelected() const;
+
+ inline Qt::ItemFlags flags() const { return itemFlags; }
+ void setFlags(Qt::ItemFlags flags);
+
+ inline QString text() const
+ { return data(Qt::DisplayRole).toString(); }
+ inline void setText(const QString &text);
+
+ inline QIcon icon() const
+ { return qvariant_cast<QIcon>(data(Qt::DecorationRole)); }
+ inline void setIcon(const QIcon &icon);
+
+ inline QString statusTip() const
+ { return data(Qt::StatusTipRole).toString(); }
+ inline void setStatusTip(const QString &statusTip);
+
+#ifndef QT_NO_TOOLTIP
+ inline QString toolTip() const
+ { return data(Qt::ToolTipRole).toString(); }
+ inline void setToolTip(const QString &toolTip);
+#endif
+
+#ifndef QT_NO_WHATSTHIS
+ inline QString whatsThis() const
+ { return data(Qt::WhatsThisRole).toString(); }
+ inline void setWhatsThis(const QString &whatsThis);
+#endif
+
+ inline QFont font() const
+ { return qvariant_cast<QFont>(data(Qt::FontRole)); }
+ inline void setFont(const QFont &font);
+
+ inline int textAlignment() const
+ { return data(Qt::TextAlignmentRole).toInt(); }
+ inline void setTextAlignment(int alignment)
+ { setData(Qt::TextAlignmentRole, alignment); }
+
+ inline QColor backgroundColor() const
+ { return qvariant_cast<QColor>(data(Qt::BackgroundColorRole)); }
+ inline void setBackgroundColor(const QColor &color)
+ { setData(Qt::BackgroundColorRole, color); }
+
+ inline QBrush background() const
+ { return qvariant_cast<QBrush>(data(Qt::BackgroundRole)); }
+ inline void setBackground(const QBrush &brush)
+ { setData(Qt::BackgroundRole, brush); }
+
+ inline QColor textColor() const
+ { return qvariant_cast<QColor>(data(Qt::TextColorRole)); }
+ inline void setTextColor(const QColor &color)
+ { setData(Qt::TextColorRole, color); }
+
+ inline QBrush foreground() const
+ { return qvariant_cast<QBrush>(data(Qt::ForegroundRole)); }
+ inline void setForeground(const QBrush &brush)
+ { setData(Qt::ForegroundRole, brush); }
+
+ inline Qt::CheckState checkState() const
+ { return static_cast<Qt::CheckState>(data(Qt::CheckStateRole).toInt()); }
+ inline void setCheckState(Qt::CheckState state)
+ { setData(Qt::CheckStateRole, state); }
+
+ inline QSize sizeHint() const
+ { return qvariant_cast<QSize>(data(Qt::SizeHintRole)); }
+ inline void setSizeHint(const QSize &size)
+ { setData(Qt::SizeHintRole, size); }
+
+ virtual QVariant data(int role) const;
+ virtual void setData(int role, const QVariant &value);
+
+ virtual bool operator<(const QTableWidgetItem &other) const;
+
+#ifndef QT_NO_DATASTREAM
+ virtual void read(QDataStream &in);
+ virtual void write(QDataStream &out) const;
+#endif
+ QTableWidgetItem &operator=(const QTableWidgetItem &other);
+
+ inline int type() const { return rtti; }
+
+private:
+ int rtti;
+ QVector<QWidgetItemData> values;
+ QTableWidget *view;
+ QTableWidgetItemPrivate *d;
+ Qt::ItemFlags itemFlags;
+};
+
+inline void QTableWidgetItem::setText(const QString &atext)
+{ setData(Qt::DisplayRole, atext); }
+
+inline void QTableWidgetItem::setIcon(const QIcon &aicon)
+{ setData(Qt::DecorationRole, aicon); }
+
+inline void QTableWidgetItem::setStatusTip(const QString &astatusTip)
+{ setData(Qt::StatusTipRole, astatusTip); }
+
+#ifndef QT_NO_TOOLTIP
+inline void QTableWidgetItem::setToolTip(const QString &atoolTip)
+{ setData(Qt::ToolTipRole, atoolTip); }
+#endif
+
+#ifndef QT_NO_WHATSTHIS
+inline void QTableWidgetItem::setWhatsThis(const QString &awhatsThis)
+{ setData(Qt::WhatsThisRole, awhatsThis); }
+#endif
+
+inline void QTableWidgetItem::setFont(const QFont &afont)
+{ setData(Qt::FontRole, afont); }
+
+#ifndef QT_NO_DATASTREAM
+Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QTableWidgetItem &item);
+Q_GUI_EXPORT QDataStream &operator<<(QDataStream &out, const QTableWidgetItem &item);
+#endif
+
+class QTableWidgetPrivate;
+
+class Q_GUI_EXPORT QTableWidget : public QTableView
+{
+ Q_OBJECT
+ Q_PROPERTY(int rowCount READ rowCount WRITE setRowCount)
+ Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount)
+
+ friend class QTableModel;
+public:
+ explicit QTableWidget(QWidget *parent = 0);
+ QTableWidget(int rows, int columns, QWidget *parent = 0);
+ ~QTableWidget();
+
+ void setRowCount(int rows);
+ int rowCount() const;
+
+ void setColumnCount(int columns);
+ int columnCount() const;
+
+ int row(const QTableWidgetItem *item) const;
+ int column(const QTableWidgetItem *item) const;
+
+ QTableWidgetItem *item(int row, int column) const;
+ void setItem(int row, int column, QTableWidgetItem *item);
+ QTableWidgetItem *takeItem(int row, int column);
+
+ QTableWidgetItem *verticalHeaderItem(int row) const;
+ void setVerticalHeaderItem(int row, QTableWidgetItem *item);
+ QTableWidgetItem *takeVerticalHeaderItem(int row);
+
+ QTableWidgetItem *horizontalHeaderItem(int column) const;
+ void setHorizontalHeaderItem(int column, QTableWidgetItem *item);
+ QTableWidgetItem *takeHorizontalHeaderItem(int column);
+ void setVerticalHeaderLabels(const QStringList &labels);
+ void setHorizontalHeaderLabels(const QStringList &labels);
+
+ int currentRow() const;
+ int currentColumn() const;
+ QTableWidgetItem *currentItem() const;
+ void setCurrentItem(QTableWidgetItem *item);
+ void setCurrentItem(QTableWidgetItem *item, QItemSelectionModel::SelectionFlags command);
+ void setCurrentCell(int row, int column);
+ void setCurrentCell(int row, int column, QItemSelectionModel::SelectionFlags command);
+
+ void sortItems(int column, Qt::SortOrder order = Qt::AscendingOrder);
+ void setSortingEnabled(bool enable);
+ bool isSortingEnabled() const;
+
+ void editItem(QTableWidgetItem *item);
+ void openPersistentEditor(QTableWidgetItem *item);
+ void closePersistentEditor(QTableWidgetItem *item);
+
+ QWidget *cellWidget(int row, int column) const;
+ void setCellWidget(int row, int column, QWidget *widget);
+ inline void removeCellWidget(int row, int column);
+
+ bool isItemSelected(const QTableWidgetItem *item) const;
+ void setItemSelected(const QTableWidgetItem *item, bool select);
+ void setRangeSelected(const QTableWidgetSelectionRange &range, bool select);
+
+ QList<QTableWidgetSelectionRange> selectedRanges() const;
+ QList<QTableWidgetItem*> selectedItems();
+ QList<QTableWidgetItem*> findItems(const QString &text, Qt::MatchFlags flags) const;
+
+ int visualRow(int logicalRow) const;
+ int visualColumn(int logicalColumn) const;
+
+ QTableWidgetItem *itemAt(const QPoint &p) const;
+ inline QTableWidgetItem *itemAt(int x, int y) const;
+ QRect visualItemRect(const QTableWidgetItem *item) const;
+
+ const QTableWidgetItem *itemPrototype() const;
+ void setItemPrototype(const QTableWidgetItem *item);
+
+public Q_SLOTS:
+ void scrollToItem(const QTableWidgetItem *item, QAbstractItemView::ScrollHint hint = EnsureVisible);
+ void insertRow(int row);
+ void insertColumn(int column);
+ void removeRow(int row);
+ void removeColumn(int column);
+ void clear();
+ void clearContents();
+
+Q_SIGNALS:
+ void itemPressed(QTableWidgetItem *item);
+ void itemClicked(QTableWidgetItem *item);
+ void itemDoubleClicked(QTableWidgetItem *item);
+
+ void itemActivated(QTableWidgetItem *item);
+ void itemEntered(QTableWidgetItem *item);
+ void itemChanged(QTableWidgetItem *item);
+
+ void currentItemChanged(QTableWidgetItem *current, QTableWidgetItem *previous);
+ void itemSelectionChanged();
+
+ void cellPressed(int row, int column);
+ void cellClicked(int row, int column);
+ void cellDoubleClicked(int row, int column);
+
+ void cellActivated(int row, int column);
+ void cellEntered(int row, int column);
+ void cellChanged(int row, int column);
+
+ void currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn);
+
+protected:
+ bool event(QEvent *e);
+ virtual QStringList mimeTypes() const;
+ virtual QMimeData *mimeData(const QList<QTableWidgetItem*> items) const;
+ virtual bool dropMimeData(int row, int column, const QMimeData *data, Qt::DropAction action);
+ virtual Qt::DropActions supportedDropActions() const;
+ QList<QTableWidgetItem*> items(const QMimeData *data) const;
+
+ QModelIndex indexFromItem(QTableWidgetItem *item) const;
+ QTableWidgetItem *itemFromIndex(const QModelIndex &index) const;
+ void dropEvent(QDropEvent *event);
+
+private:
+ void setModel(QAbstractItemModel *model);
+
+ Q_DECLARE_PRIVATE(QTableWidget)
+ Q_DISABLE_COPY(QTableWidget)
+
+ Q_PRIVATE_SLOT(d_func(), void _q_emitItemPressed(const QModelIndex &index))
+ Q_PRIVATE_SLOT(d_func(), void _q_emitItemClicked(const QModelIndex &index))
+ Q_PRIVATE_SLOT(d_func(), void _q_emitItemDoubleClicked(const QModelIndex &index))
+ Q_PRIVATE_SLOT(d_func(), void _q_emitItemActivated(const QModelIndex &index))
+ Q_PRIVATE_SLOT(d_func(), void _q_emitItemEntered(const QModelIndex &index))
+ Q_PRIVATE_SLOT(d_func(), void _q_emitItemChanged(const QModelIndex &index))
+ Q_PRIVATE_SLOT(d_func(), void _q_emitCurrentItemChanged(const QModelIndex &previous, const QModelIndex &current))
+ Q_PRIVATE_SLOT(d_func(), void _q_sort())
+ Q_PRIVATE_SLOT(d_func(), void _q_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight))
+};
+
+inline void QTableWidget::removeCellWidget(int arow, int acolumn)
+{ setCellWidget(arow, acolumn, 0); }
+
+inline QTableWidgetItem *QTableWidget::itemAt(int ax, int ay) const
+{ return itemAt(QPoint(ax, ay)); }
+
+inline int QTableWidgetItem::row() const
+{ return (view ? view->row(this) : -1); }
+
+inline int QTableWidgetItem::column() const
+{ return (view ? view->column(this) : -1); }
+
+inline void QTableWidgetItem::setSelected(bool aselect)
+{ if (view) view->setItemSelected(this, aselect); }
+
+inline bool QTableWidgetItem::isSelected() const
+{ return (view ? view->isItemSelected(this) : false); }
+
+#endif // QT_NO_TABLEWIDGET
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QTABLEWIDGET_H
diff --git a/src/gui/itemviews/qtablewidget_p.h b/src/widgets/itemviews/qtablewidget_p.h
index e0b06cb89c..e0b06cb89c 100644
--- a/src/gui/itemviews/qtablewidget_p.h
+++ b/src/widgets/itemviews/qtablewidget_p.h
diff --git a/src/gui/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp
index 21c9d3b31a..21c9d3b31a 100644
--- a/src/gui/itemviews/qtreeview.cpp
+++ b/src/widgets/itemviews/qtreeview.cpp
diff --git a/src/widgets/itemviews/qtreeview.h b/src/widgets/itemviews/qtreeview.h
new file mode 100644
index 0000000000..aff42435b7
--- /dev/null
+++ b/src/widgets/itemviews/qtreeview.h
@@ -0,0 +1,239 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTREEVIEW_H
+#define QTREEVIEW_H
+
+#include <QtWidgets/qabstractitemview.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_TREEVIEW
+
+class QTreeViewPrivate;
+class QHeaderView;
+
+class Q_GUI_EXPORT QTreeView : public QAbstractItemView
+{
+ Q_OBJECT
+ Q_PROPERTY(int autoExpandDelay READ autoExpandDelay WRITE setAutoExpandDelay)
+ Q_PROPERTY(int indentation READ indentation WRITE setIndentation)
+ Q_PROPERTY(bool rootIsDecorated READ rootIsDecorated WRITE setRootIsDecorated)
+ Q_PROPERTY(bool uniformRowHeights READ uniformRowHeights WRITE setUniformRowHeights)
+ Q_PROPERTY(bool itemsExpandable READ itemsExpandable WRITE setItemsExpandable)
+ Q_PROPERTY(bool sortingEnabled READ isSortingEnabled WRITE setSortingEnabled)
+ Q_PROPERTY(bool animated READ isAnimated WRITE setAnimated)
+ Q_PROPERTY(bool allColumnsShowFocus READ allColumnsShowFocus WRITE setAllColumnsShowFocus)
+ Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
+ Q_PROPERTY(bool headerHidden READ isHeaderHidden WRITE setHeaderHidden)
+ Q_PROPERTY(bool expandsOnDoubleClick READ expandsOnDoubleClick WRITE setExpandsOnDoubleClick)
+
+public:
+ explicit QTreeView(QWidget *parent = 0);
+ ~QTreeView();
+
+ void setModel(QAbstractItemModel *model);
+ void setRootIndex(const QModelIndex &index);
+ void setSelectionModel(QItemSelectionModel *selectionModel);
+
+ QHeaderView *header() const;
+ void setHeader(QHeaderView *header);
+
+ int autoExpandDelay() const;
+ void setAutoExpandDelay(int delay);
+
+ int indentation() const;
+ void setIndentation(int i);
+
+ bool rootIsDecorated() const;
+ void setRootIsDecorated(bool show);
+
+ bool uniformRowHeights() const;
+ void setUniformRowHeights(bool uniform);
+
+ bool itemsExpandable() const;
+ void setItemsExpandable(bool enable);
+
+ bool expandsOnDoubleClick() const;
+ void setExpandsOnDoubleClick(bool enable);
+
+ int columnViewportPosition(int column) const;
+ int columnWidth(int column) const;
+ void setColumnWidth(int column, int width);
+ int columnAt(int x) const;
+
+ bool isColumnHidden(int column) const;
+ void setColumnHidden(int column, bool hide);
+
+ bool isHeaderHidden() const;
+ void setHeaderHidden(bool hide);
+
+ bool isRowHidden(int row, const QModelIndex &parent) const;
+ void setRowHidden(int row, const QModelIndex &parent, bool hide);
+
+ bool isFirstColumnSpanned(int row, const QModelIndex &parent) const;
+ void setFirstColumnSpanned(int row, const QModelIndex &parent, bool span);
+
+ bool isExpanded(const QModelIndex &index) const;
+ void setExpanded(const QModelIndex &index, bool expand);
+
+ void setSortingEnabled(bool enable);
+ bool isSortingEnabled() const;
+
+ void setAnimated(bool enable);
+ bool isAnimated() const;
+
+ void setAllColumnsShowFocus(bool enable);
+ bool allColumnsShowFocus() const;
+
+ void setWordWrap(bool on);
+ bool wordWrap() const;
+
+ void keyboardSearch(const QString &search);
+
+ QRect visualRect(const QModelIndex &index) const;
+ void scrollTo(const QModelIndex &index, ScrollHint hint = EnsureVisible);
+ QModelIndex indexAt(const QPoint &p) const;
+ QModelIndex indexAbove(const QModelIndex &index) const;
+ QModelIndex indexBelow(const QModelIndex &index) const;
+
+ void doItemsLayout();
+ void reset();
+
+ void sortByColumn(int column, Qt::SortOrder order);
+
+ void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+ void selectAll();
+
+Q_SIGNALS:
+ void expanded(const QModelIndex &index);
+ void collapsed(const QModelIndex &index);
+
+public Q_SLOTS:
+ void hideColumn(int column);
+ void showColumn(int column);
+ void expand(const QModelIndex &index);
+ void collapse(const QModelIndex &index);
+ void resizeColumnToContents(int column);
+ void sortByColumn(int column);
+ void expandAll();
+ void collapseAll();
+ void expandToDepth(int depth);
+
+protected Q_SLOTS:
+ void columnResized(int column, int oldSize, int newSize);
+ void columnCountChanged(int oldCount, int newCount);
+ void columnMoved();
+ void reexpand();
+ void rowsRemoved(const QModelIndex &parent, int first, int last);
+
+protected:
+ QTreeView(QTreeViewPrivate &dd, QWidget *parent = 0);
+ void scrollContentsBy(int dx, int dy);
+ void rowsInserted(const QModelIndex &parent, int start, int end);
+ void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
+
+ QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers);
+ int horizontalOffset() const;
+ int verticalOffset() const;
+
+ void setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command);
+ QRegion visualRegionForSelection(const QItemSelection &selection) const;
+ QModelIndexList selectedIndexes() const;
+
+ void timerEvent(QTimerEvent *event);
+ void paintEvent(QPaintEvent *event);
+
+ void drawTree(QPainter *painter, const QRegion &region) const;
+ virtual void drawRow(QPainter *painter,
+ const QStyleOptionViewItem &options,
+ const QModelIndex &index) const;
+ virtual void drawBranches(QPainter *painter,
+ const QRect &rect,
+ const QModelIndex &index) const;
+
+ void mousePressEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *event);
+ void mouseDoubleClickEvent(QMouseEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+ void keyPressEvent(QKeyEvent *event);
+#ifndef QT_NO_DRAGANDDROP
+ void dragMoveEvent(QDragMoveEvent *event);
+#endif
+ bool viewportEvent(QEvent *event);
+
+ void updateGeometries();
+
+ int sizeHintForColumn(int column) const;
+ int indexRowSizeHint(const QModelIndex &index) const;
+ int rowHeight(const QModelIndex &index) const;
+
+ void horizontalScrollbarAction(int action);
+
+ bool isIndexHidden(const QModelIndex &index) const;
+ void selectionChanged(const QItemSelection &selected,
+ const QItemSelection &deselected);
+ void currentChanged(const QModelIndex &current, const QModelIndex &previous);
+
+private:
+ friend class QAccessibleItemView;
+ int visualIndex(const QModelIndex &index) const;
+
+ Q_DECLARE_PRIVATE(QTreeView)
+ Q_DISABLE_COPY(QTreeView)
+#ifndef QT_NO_ANIMATION
+ Q_PRIVATE_SLOT(d_func(), void _q_endAnimatedOperation())
+#endif //QT_NO_ANIMATION
+ Q_PRIVATE_SLOT(d_func(), void _q_modelAboutToBeReset())
+ Q_PRIVATE_SLOT(d_func(), void _q_sortIndicatorChanged(int column, Qt::SortOrder order))
+};
+
+#endif // QT_NO_TREEVIEW
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QTREEVIEW_H
diff --git a/src/gui/itemviews/qtreeview_p.h b/src/widgets/itemviews/qtreeview_p.h
index 9a923c5972..9a923c5972 100644
--- a/src/gui/itemviews/qtreeview_p.h
+++ b/src/widgets/itemviews/qtreeview_p.h
diff --git a/src/gui/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp
index 2ea9a4316b..2ea9a4316b 100644
--- a/src/gui/itemviews/qtreewidget.cpp
+++ b/src/widgets/itemviews/qtreewidget.cpp
diff --git a/src/widgets/itemviews/qtreewidget.h b/src/widgets/itemviews/qtreewidget.h
new file mode 100644
index 0000000000..f835d92567
--- /dev/null
+++ b/src/widgets/itemviews/qtreewidget.h
@@ -0,0 +1,432 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTREEWIDGET_H
+#define QTREEWIDGET_H
+
+#include <QtWidgets/qtreeview.h>
+#include <QtWidgets/qtreewidgetitemiterator.h>
+#include <QtCore/qvariant.h>
+#include <QtCore/qvector.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_TREEWIDGET
+
+class QTreeWidget;
+class QTreeModel;
+class QWidgetItemData;
+class QTreeWidgetItemPrivate;
+
+class Q_GUI_EXPORT QTreeWidgetItem
+{
+ friend class QTreeModel;
+ friend class QTreeWidget;
+ friend class QTreeWidgetPrivate;
+ friend class QTreeWidgetItemIterator;
+ friend class QTreeWidgetItemPrivate;
+public:
+ enum ItemType { Type = 0, UserType = 1000 };
+ explicit QTreeWidgetItem(int type = Type);
+ QTreeWidgetItem(const QStringList &strings, int type = Type);
+ explicit QTreeWidgetItem(QTreeWidget *view, int type = Type);
+ QTreeWidgetItem(QTreeWidget *view, const QStringList &strings, int type = Type);
+ QTreeWidgetItem(QTreeWidget *view, QTreeWidgetItem *after, int type = Type);
+ explicit QTreeWidgetItem(QTreeWidgetItem *parent, int type = Type);
+ QTreeWidgetItem(QTreeWidgetItem *parent, const QStringList &strings, int type = Type);
+ QTreeWidgetItem(QTreeWidgetItem *parent, QTreeWidgetItem *after, int type = Type);
+ QTreeWidgetItem(const QTreeWidgetItem &other);
+ virtual ~QTreeWidgetItem();
+
+ virtual QTreeWidgetItem *clone() const;
+
+ inline QTreeWidget *treeWidget() const { return view; }
+
+ inline void setSelected(bool select);
+ inline bool isSelected() const;
+
+ inline void setHidden(bool hide);
+ inline bool isHidden() const;
+
+ inline void setExpanded(bool expand);
+ inline bool isExpanded() const;
+
+ inline void setFirstColumnSpanned(bool span);
+ inline bool isFirstColumnSpanned() const;
+
+ inline void setDisabled(bool disabled);
+ inline bool isDisabled() const;
+
+ enum ChildIndicatorPolicy { ShowIndicator, DontShowIndicator, DontShowIndicatorWhenChildless };
+ void setChildIndicatorPolicy(QTreeWidgetItem::ChildIndicatorPolicy policy);
+ QTreeWidgetItem::ChildIndicatorPolicy childIndicatorPolicy() const;
+
+ Qt::ItemFlags flags() const;
+ void setFlags(Qt::ItemFlags flags);
+
+ inline QString text(int column) const
+ { return data(column, Qt::DisplayRole).toString(); }
+ inline void setText(int column, const QString &text);
+
+ inline QIcon icon(int column) const
+ { return qvariant_cast<QIcon>(data(column, Qt::DecorationRole)); }
+ inline void setIcon(int column, const QIcon &icon);
+
+ inline QString statusTip(int column) const
+ { return data(column, Qt::StatusTipRole).toString(); }
+ inline void setStatusTip(int column, const QString &statusTip);
+
+#ifndef QT_NO_TOOLTIP
+ inline QString toolTip(int column) const
+ { return data(column, Qt::ToolTipRole).toString(); }
+ inline void setToolTip(int column, const QString &toolTip);
+#endif
+
+#ifndef QT_NO_WHATSTHIS
+ inline QString whatsThis(int column) const
+ { return data(column, Qt::WhatsThisRole).toString(); }
+ inline void setWhatsThis(int column, const QString &whatsThis);
+#endif
+
+ inline QFont font(int column) const
+ { return qvariant_cast<QFont>(data(column, Qt::FontRole)); }
+ inline void setFont(int column, const QFont &font);
+
+ inline int textAlignment(int column) const
+ { return data(column, Qt::TextAlignmentRole).toInt(); }
+ inline void setTextAlignment(int column, int alignment)
+ { setData(column, Qt::TextAlignmentRole, alignment); }
+
+ inline QColor backgroundColor(int column) const
+ { return qvariant_cast<QColor>(data(column, Qt::BackgroundColorRole)); }
+ inline void setBackgroundColor(int column, const QColor &color)
+ { setData(column, Qt::BackgroundColorRole, color); }
+
+ inline QBrush background(int column) const
+ { return qvariant_cast<QBrush>(data(column, Qt::BackgroundRole)); }
+ inline void setBackground(int column, const QBrush &brush)
+ { setData(column, Qt::BackgroundRole, brush); }
+
+ inline QColor textColor(int column) const
+ { return qvariant_cast<QColor>(data(column, Qt::TextColorRole)); }
+ inline void setTextColor(int column, const QColor &color)
+ { setData(column, Qt::TextColorRole, color); }
+
+ inline QBrush foreground(int column) const
+ { return qvariant_cast<QBrush>(data(column, Qt::ForegroundRole)); }
+ inline void setForeground(int column, const QBrush &brush)
+ { setData(column, Qt::ForegroundRole, brush); }
+
+ inline Qt::CheckState checkState(int column) const
+ { return static_cast<Qt::CheckState>(data(column, Qt::CheckStateRole).toInt()); }
+ inline void setCheckState(int column, Qt::CheckState state)
+ { setData(column, Qt::CheckStateRole, state); }
+
+ inline QSize sizeHint(int column) const
+ { return qvariant_cast<QSize>(data(column, Qt::SizeHintRole)); }
+ inline void setSizeHint(int column, const QSize &size)
+ { setData(column, Qt::SizeHintRole, size); }
+
+ virtual QVariant data(int column, int role) const;
+ virtual void setData(int column, int role, const QVariant &value);
+
+ virtual bool operator<(const QTreeWidgetItem &other) const;
+
+#ifndef QT_NO_DATASTREAM
+ virtual void read(QDataStream &in);
+ virtual void write(QDataStream &out) const;
+#endif
+ QTreeWidgetItem &operator=(const QTreeWidgetItem &other);
+
+ inline QTreeWidgetItem *parent() const { return par; }
+ inline QTreeWidgetItem *child(int index) const {
+ if (index < 0 || index >= children.size())
+ return 0;
+ executePendingSort();
+ return children.at(index);
+ }
+ inline int childCount() const { return children.count(); }
+ inline int columnCount() const { return values.count(); }
+ inline int indexOfChild(QTreeWidgetItem *child) const;
+
+ void addChild(QTreeWidgetItem *child);
+ void insertChild(int index, QTreeWidgetItem *child);
+ void removeChild(QTreeWidgetItem *child);
+ QTreeWidgetItem *takeChild(int index);
+
+ void addChildren(const QList<QTreeWidgetItem*> &children);
+ void insertChildren(int index, const QList<QTreeWidgetItem*> &children);
+ QList<QTreeWidgetItem*> takeChildren();
+
+ inline int type() const { return rtti; }
+ inline void sortChildren(int column, Qt::SortOrder order)
+ { sortChildren(column, order, false); }
+
+protected:
+ void emitDataChanged();
+
+private:
+ void sortChildren(int column, Qt::SortOrder order, bool climb);
+ QVariant childrenCheckState(int column) const;
+ void itemChanged();
+ void executePendingSort() const;
+
+ int rtti;
+ // One item has a vector of column entries. Each column has a vector of (role, value) pairs.
+ QVector< QVector<QWidgetItemData> > values;
+ QTreeWidget *view;
+ QTreeWidgetItemPrivate *d;
+ QTreeWidgetItem *par;
+ QList<QTreeWidgetItem*> children;
+ Qt::ItemFlags itemFlags;
+};
+
+inline void QTreeWidgetItem::setText(int column, const QString &atext)
+{ setData(column, Qt::DisplayRole, atext); }
+
+inline void QTreeWidgetItem::setIcon(int column, const QIcon &aicon)
+{ setData(column, Qt::DecorationRole, aicon); }
+
+#ifndef QT_NO_STATUSTIP
+inline void QTreeWidgetItem::setStatusTip(int column, const QString &astatusTip)
+{ setData(column, Qt::StatusTipRole, astatusTip); }
+#endif
+
+#ifndef QT_NO_TOOLTIP
+inline void QTreeWidgetItem::setToolTip(int column, const QString &atoolTip)
+{ setData(column, Qt::ToolTipRole, atoolTip); }
+#endif
+
+#ifndef QT_NO_WHATSTHIS
+inline void QTreeWidgetItem::setWhatsThis(int column, const QString &awhatsThis)
+{ setData(column, Qt::WhatsThisRole, awhatsThis); }
+#endif
+
+inline void QTreeWidgetItem::setFont(int column, const QFont &afont)
+{ setData(column, Qt::FontRole, afont); }
+
+inline int QTreeWidgetItem::indexOfChild(QTreeWidgetItem *achild) const
+{ executePendingSort(); return children.indexOf(achild); }
+
+#ifndef QT_NO_DATASTREAM
+Q_GUI_EXPORT QDataStream &operator<<(QDataStream &out, const QTreeWidgetItem &item);
+Q_GUI_EXPORT QDataStream &operator>>(QDataStream &in, QTreeWidgetItem &item);
+#endif
+
+class QTreeWidgetPrivate;
+
+class Q_GUI_EXPORT QTreeWidget : public QTreeView
+{
+ Q_OBJECT
+ Q_PROPERTY(int columnCount READ columnCount WRITE setColumnCount)
+ Q_PROPERTY(int topLevelItemCount READ topLevelItemCount)
+
+ friend class QTreeModel;
+ friend class QTreeWidgetItem;
+public:
+ explicit QTreeWidget(QWidget *parent = 0);
+ ~QTreeWidget();
+
+ int columnCount() const;
+ void setColumnCount(int columns);
+
+ QTreeWidgetItem *invisibleRootItem() const;
+ QTreeWidgetItem *topLevelItem(int index) const;
+ int topLevelItemCount() const;
+ void insertTopLevelItem(int index, QTreeWidgetItem *item);
+ void addTopLevelItem(QTreeWidgetItem *item);
+ QTreeWidgetItem *takeTopLevelItem(int index);
+ int indexOfTopLevelItem(QTreeWidgetItem *item); // ### Qt 5: remove me
+ int indexOfTopLevelItem(QTreeWidgetItem *item) const;
+
+ void insertTopLevelItems(int index, const QList<QTreeWidgetItem*> &items);
+ void addTopLevelItems(const QList<QTreeWidgetItem*> &items);
+
+ QTreeWidgetItem *headerItem() const;
+ void setHeaderItem(QTreeWidgetItem *item);
+ void setHeaderLabels(const QStringList &labels);
+ inline void setHeaderLabel(const QString &label);
+
+ QTreeWidgetItem *currentItem() const;
+ int currentColumn() const;
+ void setCurrentItem(QTreeWidgetItem *item);
+ void setCurrentItem(QTreeWidgetItem *item, int column);
+ void setCurrentItem(QTreeWidgetItem *item, int column, QItemSelectionModel::SelectionFlags command);
+
+ QTreeWidgetItem *itemAt(const QPoint &p) const;
+ inline QTreeWidgetItem *itemAt(int x, int y) const;
+ QRect visualItemRect(const QTreeWidgetItem *item) const;
+
+ int sortColumn() const;
+ void sortItems(int column, Qt::SortOrder order);
+ void setSortingEnabled(bool enable);
+ bool isSortingEnabled() const;
+
+ void editItem(QTreeWidgetItem *item, int column = 0);
+ void openPersistentEditor(QTreeWidgetItem *item, int column = 0);
+ void closePersistentEditor(QTreeWidgetItem *item, int column = 0);
+
+ QWidget *itemWidget(QTreeWidgetItem *item, int column) const;
+ void setItemWidget(QTreeWidgetItem *item, int column, QWidget *widget);
+ inline void removeItemWidget(QTreeWidgetItem *item, int column);
+
+ bool isItemSelected(const QTreeWidgetItem *item) const;
+ void setItemSelected(const QTreeWidgetItem *item, bool select);
+ QList<QTreeWidgetItem*> selectedItems() const;
+ QList<QTreeWidgetItem*> findItems(const QString &text, Qt::MatchFlags flags,
+ int column = 0) const;
+
+ bool isItemHidden(const QTreeWidgetItem *item) const;
+ void setItemHidden(const QTreeWidgetItem *item, bool hide);
+
+ bool isItemExpanded(const QTreeWidgetItem *item) const;
+ void setItemExpanded(const QTreeWidgetItem *item, bool expand);
+
+ bool isFirstItemColumnSpanned(const QTreeWidgetItem *item) const;
+ void setFirstItemColumnSpanned(const QTreeWidgetItem *item, bool span);
+
+ QTreeWidgetItem *itemAbove(const QTreeWidgetItem *item) const;
+ QTreeWidgetItem *itemBelow(const QTreeWidgetItem *item) const;
+
+ void setSelectionModel(QItemSelectionModel *selectionModel);
+
+public Q_SLOTS:
+ void scrollToItem(const QTreeWidgetItem *item,
+ QAbstractItemView::ScrollHint hint = EnsureVisible);
+ void expandItem(const QTreeWidgetItem *item);
+ void collapseItem(const QTreeWidgetItem *item);
+ void clear();
+
+Q_SIGNALS:
+ void itemPressed(QTreeWidgetItem *item, int column);
+ void itemClicked(QTreeWidgetItem *item, int column);
+ void itemDoubleClicked(QTreeWidgetItem *item, int column);
+ void itemActivated(QTreeWidgetItem *item, int column);
+ void itemEntered(QTreeWidgetItem *item, int column);
+ void itemChanged(QTreeWidgetItem *item, int column);
+ void itemExpanded(QTreeWidgetItem *item);
+ void itemCollapsed(QTreeWidgetItem *item);
+ void currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
+ void itemSelectionChanged();
+
+protected:
+ bool event(QEvent *e);
+ virtual QStringList mimeTypes() const;
+ virtual QMimeData *mimeData(const QList<QTreeWidgetItem*> items) const;
+ virtual bool dropMimeData(QTreeWidgetItem *parent, int index,
+ const QMimeData *data, Qt::DropAction action);
+ virtual Qt::DropActions supportedDropActions() const;
+ QList<QTreeWidgetItem*> items(const QMimeData *data) const;
+
+ QModelIndex indexFromItem(QTreeWidgetItem *item, int column = 0) const;
+ QTreeWidgetItem *itemFromIndex(const QModelIndex &index) const;
+ void dropEvent(QDropEvent *event);
+
+private:
+ void setModel(QAbstractItemModel *model);
+
+ Q_DECLARE_PRIVATE(QTreeWidget)
+ Q_DISABLE_COPY(QTreeWidget)
+
+ Q_PRIVATE_SLOT(d_func(), void _q_emitItemPressed(const QModelIndex &index))
+ Q_PRIVATE_SLOT(d_func(), void _q_emitItemClicked(const QModelIndex &index))
+ Q_PRIVATE_SLOT(d_func(), void _q_emitItemDoubleClicked(const QModelIndex &index))
+ Q_PRIVATE_SLOT(d_func(), void _q_emitItemActivated(const QModelIndex &index))
+ Q_PRIVATE_SLOT(d_func(), void _q_emitItemEntered(const QModelIndex &index))
+ Q_PRIVATE_SLOT(d_func(), void _q_emitItemChanged(const QModelIndex &index))
+ Q_PRIVATE_SLOT(d_func(), void _q_emitItemExpanded(const QModelIndex &index))
+ Q_PRIVATE_SLOT(d_func(), void _q_emitItemCollapsed(const QModelIndex &index))
+ Q_PRIVATE_SLOT(d_func(), void _q_emitCurrentItemChanged(const QModelIndex &previous, const QModelIndex &current))
+ Q_PRIVATE_SLOT(d_func(), void _q_sort())
+ Q_PRIVATE_SLOT(d_func(), void _q_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight))
+ Q_PRIVATE_SLOT(d_func(), void _q_selectionChanged(const QItemSelection &selected, const QItemSelection &deselected))
+};
+
+inline void QTreeWidget::removeItemWidget(QTreeWidgetItem *item, int column)
+{ setItemWidget(item, column, 0); }
+
+inline QTreeWidgetItem *QTreeWidget::itemAt(int ax, int ay) const
+{ return itemAt(QPoint(ax, ay)); }
+
+inline void QTreeWidget::setHeaderLabel(const QString &alabel)
+{ setHeaderLabels(QStringList(alabel)); }
+
+inline void QTreeWidgetItem::setSelected(bool aselect)
+{ if (view) view->setItemSelected(this, aselect); }
+
+inline bool QTreeWidgetItem::isSelected() const
+{ return (view ? view->isItemSelected(this) : false); }
+
+inline void QTreeWidgetItem::setHidden(bool ahide)
+{ if (view) view->setItemHidden(this, ahide); }
+
+inline bool QTreeWidgetItem::isHidden() const
+{ return (view ? view->isItemHidden(this) : false); }
+
+inline void QTreeWidgetItem::setExpanded(bool aexpand)
+{ if (view) view->setItemExpanded(this, aexpand); }
+
+inline bool QTreeWidgetItem::isExpanded() const
+{ return (view ? view->isItemExpanded(this) : false); }
+
+inline void QTreeWidgetItem::setFirstColumnSpanned(bool aspan)
+{ if (view) view->setFirstItemColumnSpanned(this, aspan); }
+
+inline bool QTreeWidgetItem::isFirstColumnSpanned() const
+{ return (view ? view->isFirstItemColumnSpanned(this) : false); }
+
+inline void QTreeWidgetItem::setDisabled(bool disabled)
+{ setFlags(disabled ? (flags() & ~Qt::ItemIsEnabled) : flags() | Qt::ItemIsEnabled); }
+
+inline bool QTreeWidgetItem::isDisabled() const
+{ return !(flags() & Qt::ItemIsEnabled); }
+
+#endif // QT_NO_TREEWIDGET
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QTREEWIDGET_H
diff --git a/src/widgets/itemviews/qtreewidget_p.h b/src/widgets/itemviews/qtreewidget_p.h
new file mode 100644
index 0000000000..d5998daa39
--- /dev/null
+++ b/src/widgets/itemviews/qtreewidget_p.h
@@ -0,0 +1,248 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTREEWIDGET_P_H
+#define QTREEWIDGET_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. This header file may change
+// from version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qabstractitemmodel.h>
+#include <private/qabstractitemmodel_p.h>
+#include <QtCore/qpair.h>
+#include <QtCore/qbasictimer.h>
+#include <QtWidgets/qtreewidget.h>
+#include <private/qtreeview_p.h>
+#include <QtWidgets/qheaderview.h>
+
+#ifndef QT_NO_TREEWIDGET
+
+QT_BEGIN_NAMESPACE
+
+class QTreeWidgetItem;
+class QTreeWidgetItemIterator;
+class QTreeModelPrivate;
+
+class QTreeModel : public QAbstractItemModel
+{
+ Q_OBJECT
+ friend class QTreeWidget;
+ friend class QTreeWidgetPrivate;
+ friend class QTreeWidgetItem;
+ friend class QTreeWidgetItemPrivate;
+ friend class QTreeWidgetItemIterator;
+ friend class QTreeWidgetItemIteratorPrivate;
+
+public:
+ explicit QTreeModel(int columns = 0, QTreeWidget *parent = 0);
+ ~QTreeModel();
+
+ inline QTreeWidget *view() const
+ { return qobject_cast<QTreeWidget*>(QObject::parent()); }
+
+ void clear();
+ void setColumnCount(int columns);
+
+ QTreeWidgetItem *item(const QModelIndex &index) const;
+ void itemChanged(QTreeWidgetItem *item);
+
+ QModelIndex index(const QTreeWidgetItem *item, int column) const;
+ 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 = QModelIndex()) const;
+ bool hasChildren(const QModelIndex &parent) const;
+
+ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ bool setData(const QModelIndex &index, const QVariant &value, int role);
+
+ QMap<int, QVariant> itemData(const QModelIndex &index) const;
+
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const;
+ bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value,
+ int role);
+
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+
+ void sort(int column, Qt::SortOrder order);
+ void ensureSorted(int column, Qt::SortOrder order,
+ int start, int end, const QModelIndex &parent);
+ static bool itemLessThan(const QPair<QTreeWidgetItem*,int> &left,
+ const QPair<QTreeWidgetItem*,int> &right);
+ static bool itemGreaterThan(const QPair<QTreeWidgetItem*,int> &left,
+ const QPair<QTreeWidgetItem*,int> &right);
+ static QList<QTreeWidgetItem*>::iterator sortedInsertionIterator(
+ const QList<QTreeWidgetItem*>::iterator &begin,
+ const QList<QTreeWidgetItem*>::iterator &end,
+ Qt::SortOrder order, QTreeWidgetItem *item);
+
+ bool insertRows(int row, int count, const QModelIndex &);
+ bool insertColumns(int column, int count, const QModelIndex &);
+
+ bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
+
+ // dnd
+ QStringList mimeTypes() const;
+ QMimeData *mimeData(const QModelIndexList &indexes) const;
+ bool dropMimeData(const QMimeData *data, Qt::DropAction action,
+ int row, int column, const QModelIndex &parent);
+ Qt::DropActions supportedDropActions() const;
+
+ QMimeData *internalMimeData() const;
+
+ inline QModelIndex createIndexFromItem(int row, int col, QTreeWidgetItem *item) const
+ { return createIndex(row, col, item); }
+
+protected:
+ QTreeModel(QTreeModelPrivate &, QTreeWidget *parent = 0);
+ void emitDataChanged(QTreeWidgetItem *item, int column);
+ void beginInsertItems(QTreeWidgetItem *parent, int row, int count);
+ void endInsertItems();
+ void beginRemoveItems(QTreeWidgetItem *parent, int row, int count);
+ void endRemoveItems();
+ void sortItems(QList<QTreeWidgetItem*> *items, int column, Qt::SortOrder order);
+ void timerEvent(QTimerEvent *);
+
+private:
+ QTreeWidgetItem *rootItem;
+ QTreeWidgetItem *headerItem;
+
+ mutable QModelIndexList cachedIndexes;
+ QList<QTreeWidgetItemIterator*> iterators;
+
+ mutable QBasicTimer sortPendingTimer;
+ mutable bool skipPendingSort; //while doing internal operation we don't care about sorting
+ bool inline executePendingSort() const;
+
+ bool isChanging() const;
+
+private:
+ Q_DECLARE_PRIVATE(QTreeModel)
+public:
+ struct SkipSorting
+ {
+ const QTreeModel * const model;
+ const bool previous;
+ SkipSorting(const QTreeModel *m) : model(m), previous(model->skipPendingSort)
+ { model->skipPendingSort = true; }
+ ~SkipSorting() { model->skipPendingSort = previous; }
+ };
+ friend struct SkipSorting;
+};
+
+QT_BEGIN_INCLUDE_NAMESPACE
+#include "private/qabstractitemmodel_p.h"
+QT_END_INCLUDE_NAMESPACE
+
+class QTreeModelPrivate : public QAbstractItemModelPrivate
+{
+ Q_DECLARE_PUBLIC(QTreeModel)
+};
+
+class QTreeWidgetItemPrivate
+{
+public:
+ QTreeWidgetItemPrivate(QTreeWidgetItem *item)
+ : q(item), disabled(false), selected(false), rowGuess(-1), policy(QTreeWidgetItem::DontShowIndicatorWhenChildless) {}
+ void propagateDisabled(QTreeWidgetItem *item);
+ void sortChildren(int column, Qt::SortOrder order, bool climb);
+ QTreeWidgetItem *q;
+ QVariantList display;
+ uint disabled : 1;
+ uint selected : 1;
+ int rowGuess;
+ QTreeWidgetItem::ChildIndicatorPolicy policy;
+};
+
+
+inline bool QTreeModel::executePendingSort() const
+{
+ if (!skipPendingSort && sortPendingTimer.isActive() && !isChanging()) {
+ sortPendingTimer.stop();
+ int column = view()->header()->sortIndicatorSection();
+ Qt::SortOrder order = view()->header()->sortIndicatorOrder();
+ QTreeModel *that = const_cast<QTreeModel*>(this);
+ that->sort(column, order);
+ return true;
+ }
+ return false;
+}
+
+class QTreeWidgetPrivate : public QTreeViewPrivate
+{
+ friend class QTreeModel;
+ Q_DECLARE_PUBLIC(QTreeWidget)
+public:
+ QTreeWidgetPrivate() : QTreeViewPrivate(), explicitSortColumn(-1) {}
+ inline QTreeModel *treeModel() const { return qobject_cast<QTreeModel*>(model); }
+ inline QModelIndex index(const QTreeWidgetItem *item, int column = 0) const
+ { return treeModel()->index(item, column); }
+ inline QTreeWidgetItem *item(const QModelIndex &index) const
+ { return treeModel()->item(index); }
+ void _q_emitItemPressed(const QModelIndex &index);
+ void _q_emitItemClicked(const QModelIndex &index);
+ void _q_emitItemDoubleClicked(const QModelIndex &index);
+ void _q_emitItemActivated(const QModelIndex &index);
+ void _q_emitItemEntered(const QModelIndex &index);
+ void _q_emitItemChanged(const QModelIndex &index);
+ void _q_emitItemExpanded(const QModelIndex &index);
+ void _q_emitItemCollapsed(const QModelIndex &index);
+ void _q_emitCurrentItemChanged(const QModelIndex &previous, const QModelIndex &index);
+ void _q_sort();
+ void _q_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+ void _q_selectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
+
+ // used by QTreeWidgetItem::sortChildren to make sure the column argument is used
+ int explicitSortColumn;
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_TREEWIDGET
+
+#endif // QTREEWIDGET_P_H
diff --git a/src/gui/itemviews/qtreewidgetitemiterator.cpp b/src/widgets/itemviews/qtreewidgetitemiterator.cpp
index fa0115ed27..fa0115ed27 100644
--- a/src/gui/itemviews/qtreewidgetitemiterator.cpp
+++ b/src/widgets/itemviews/qtreewidgetitemiterator.cpp
diff --git a/src/gui/itemviews/qtreewidgetitemiterator.h b/src/widgets/itemviews/qtreewidgetitemiterator.h
index 680bac4f51..680bac4f51 100644
--- a/src/gui/itemviews/qtreewidgetitemiterator.h
+++ b/src/widgets/itemviews/qtreewidgetitemiterator.h
diff --git a/src/gui/itemviews/qtreewidgetitemiterator_p.h b/src/widgets/itemviews/qtreewidgetitemiterator_p.h
index 69876eb646..69876eb646 100644
--- a/src/gui/itemviews/qtreewidgetitemiterator_p.h
+++ b/src/widgets/itemviews/qtreewidgetitemiterator_p.h
diff --git a/src/gui/itemviews/qwidgetitemdata_p.h b/src/widgets/itemviews/qwidgetitemdata_p.h
index a7068b7559..a7068b7559 100644
--- a/src/gui/itemviews/qwidgetitemdata_p.h
+++ b/src/widgets/itemviews/qwidgetitemdata_p.h
diff --git a/src/widgets/kernel/kernel.pri b/src/widgets/kernel/kernel.pri
new file mode 100644
index 0000000000..d085bff146
--- /dev/null
+++ b/src/widgets/kernel/kernel.pri
@@ -0,0 +1,246 @@
+# Qt kernel module
+
+# Only used on platforms with CONFIG += precompile_header
+PRECOMPILED_HEADER = kernel/qt_gui_pch.h
+
+
+KERNEL_P= kernel
+HEADERS += \
+ kernel/qaction.h \
+ kernel/qaction_p.h \
+ kernel/qactiongroup.h \
+ kernel/qapplication.h \
+ kernel/qapplication_p.h \
+ kernel/qbackingstore_p.h \
+ kernel/qboxlayout.h \
+ kernel/qdesktopwidget.h \
+ kernel/qformlayout.h \
+ kernel/qgridlayout.h \
+ kernel/qicon.h \
+ kernel/qicon_p.h \
+ kernel/qiconloader_p.h \
+ kernel/qiconengine.h \
+ kernel/qiconengineplugin.h \
+ kernel/qlayout.h \
+ kernel/qlayout_p.h \
+ kernel/qlayoutengine_p.h \
+ kernel/qlayoutitem.h \
+ kernel/qsizepolicy.h \
+ kernel/qstackedlayout.h \
+ kernel/qtooltip.h \
+ kernel/qwhatsthis.h \
+ kernel/qwidget.h \
+ kernel/qwidget_p.h \
+ kernel/qwidgetaction.h \
+ kernel/qwidgetaction_p.h \
+ kernel/qgesture.h \
+ kernel/qgesture_p.h \
+ kernel/qstandardgestures_p.h \
+ kernel/qgesturerecognizer.h \
+ kernel/qgesturemanager_p.h \
+ kernel/qsoftkeymanager_p.h \
+ kernel/qsoftkeymanager_common_p.h \
+ kernel/qguiplatformplugin_p.h
+
+SOURCES += \
+ kernel/qaction.cpp \
+ kernel/qactiongroup.cpp \
+ kernel/qapplication.cpp \
+ kernel/qbackingstore.cpp \
+ kernel/qboxlayout.cpp \
+ kernel/qformlayout.cpp \
+ kernel/qgridlayout.cpp \
+ kernel/qicon.cpp \
+ kernel/qiconloader.cpp \
+ kernel/qiconengine.cpp \
+ kernel/qiconengineplugin.cpp \
+ kernel/qlayout.cpp \
+ kernel/qlayoutengine.cpp \
+ kernel/qlayoutitem.cpp \
+ kernel/qstackedlayout.cpp \
+ kernel/qtooltip.cpp \
+ kernel/qwhatsthis.cpp \
+ kernel/qwidget.cpp \
+ kernel/qwidgetaction.cpp \
+ kernel/qgesture.cpp \
+ kernel/qstandardgestures.cpp \
+ kernel/qgesturerecognizer.cpp \
+ kernel/qgesturemanager.cpp \
+ kernel/qsoftkeymanager.cpp \
+ kernel/qdesktopwidget.cpp \
+ kernel/qguiplatformplugin.cpp \
+ kernel/qwidgetsvariant.cpp
+
+win32 {
+ DEFINES += QT_NO_DIRECTDRAW
+
+ HEADERS += \
+ kernel/qwinnativepangesturerecognizer_win_p.h
+
+ SOURCES += \
+ kernel/qapplication_win.cpp \
+ kernel/qclipboard_win.cpp \
+ kernel/qcursor_win.cpp \
+ kernel/qdesktopwidget_win.cpp \
+ kernel/qdnd_win.cpp \
+ kernel/qmime_win.cpp \
+ kernel/qsound_win.cpp \
+ kernel/qwidget_win.cpp \
+ kernel/qole_win.cpp \
+ kernel/qkeymapper_win.cpp \
+ kernel/qwinnativepangesturerecognizer_win.cpp
+
+ !contains(DEFINES, QT_NO_DIRECTDRAW):LIBS += ddraw.lib
+}
+
+symbian {
+ exists($${EPOCROOT}epoc32/include/platform/mw/akntranseffect.h): DEFINES += QT_SYMBIAN_HAVE_AKNTRANSEFFECT_H
+
+ SOURCES += \
+ kernel/qapplication_s60.cpp \
+ kernel/qeventdispatcher_s60.cpp \
+ kernel/qwidget_s60.cpp \
+ kernel/qcursor_s60.cpp \
+ kernel/qdesktopwidget_s60.cpp \
+ kernel/qkeymapper_s60.cpp\
+ kernel/qclipboard_s60.cpp\
+ kernel/qdnd_s60.cpp \
+ kernel/qsound_s60.cpp
+
+ HEADERS += \
+ kernel/qt_s60_p.h \
+ kernel/qeventdispatcher_s60_p.h
+
+ LIBS += -lbafl -lestor
+
+ INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE
+ INCLUDEPATH += ../3rdparty/s60
+
+ contains(QT_CONFIG, s60) {
+ SOURCES += kernel/qsoftkeymanager_s60.cpp
+ HEADERS += kernel/qsoftkeymanager_s60_p.h
+ }
+}
+
+
+unix:x11 {
+ INCLUDEPATH += ../3rdparty/xorg
+ HEADERS += \
+ kernel/qx11embed_x11.h \
+ kernel/qx11info_x11.h \
+ kernel/qkde_p.h
+
+ SOURCES += \
+ kernel/qapplication_x11.cpp \
+ kernel/qclipboard_x11.cpp \
+ kernel/qcursor_x11.cpp \
+ kernel/qdnd_x11.cpp \
+ kernel/qdesktopwidget_x11.cpp \
+ kernel/qmotifdnd_x11.cpp \
+ kernel/qsound_x11.cpp \
+ kernel/qwidget_x11.cpp \
+ kernel/qwidgetcreate_x11.cpp \
+ kernel/qx11embed_x11.cpp \
+ kernel/qx11info_x11.cpp \
+ kernel/qkeymapper_x11.cpp \
+ kernel/qkde.cpp
+
+ contains(QT_CONFIG, glib) {
+ SOURCES += \
+ kernel/qguieventdispatcher_glib.cpp
+ HEADERS += \
+ kernel/qguieventdispatcher_glib_p.h
+ QMAKE_CXXFLAGS += $$QT_CFLAGS_GLIB
+ LIBS_PRIVATE +=$$QT_LIBS_GLIB
+ }
+ SOURCES += \
+ kernel/qeventdispatcher_x11.cpp
+ HEADERS += \
+ kernel/qeventdispatcher_x11_p.h
+}
+
+!qpa {
+ HEADERS += \
+ kernel/qsound.h \
+ kernel/qsound_p.h
+
+ SOURCES += \
+ kernel/qsound.cpp
+}
+
+qpa {
+ HEADERS += \
+ kernel/qdesktopwidget_qpa_p.h \
+ kernel/qwidgetwindow_qpa_p.h \
+
+ SOURCES += \
+ kernel/qapplication_qpa.cpp \
+ kernel/qdesktopwidget_qpa.cpp \
+ kernel/qwidget_qpa.cpp \
+ kernel/qwidgetwindow_qpa.cpp \
+}
+
+!qpa:!x11:mac {
+ SOURCES += \
+ kernel/qclipboard_mac.cpp \
+ kernel/qmime_mac.cpp \
+ kernel/qt_mac.cpp \
+ kernel/qkeymapper_mac.cpp
+
+ OBJECTIVE_HEADERS += \
+ qcocoawindow_mac_p.h \
+ qcocoapanel_mac_p.h \
+ qcocoawindowdelegate_mac_p.h \
+ qcocoaview_mac_p.h \
+ qcocoaapplication_mac_p.h \
+ qcocoaapplicationdelegate_mac_p.h \
+ qmacgesturerecognizer_mac_p.h \
+ qmultitouch_mac_p.h \
+ qcocoasharedwindowmethods_mac_p.h \
+ qcocoaintrospection_p.h
+
+ OBJECTIVE_SOURCES += \
+ kernel/qcursor_mac.mm \
+ kernel/qdnd_mac.mm \
+ kernel/qsound_mac.mm \
+ kernel/qapplication_mac.mm \
+ kernel/qwidget_mac.mm \
+ kernel/qcocoapanel_mac.mm \
+ kernel/qcocoaview_mac.mm \
+ kernel/qcocoawindow_mac.mm \
+ kernel/qcocoawindowdelegate_mac.mm \
+ kernel/qcocoamenuloader_mac.mm \
+ kernel/qcocoaapplication_mac.mm \
+ kernel/qcocoaapplicationdelegate_mac.mm \
+ kernel/qt_cocoa_helpers_mac.mm \
+ kernel/qdesktopwidget_mac.mm \
+ kernel/qeventdispatcher_mac.mm \
+ kernel/qcocoawindowcustomthemeframe_mac.mm \
+ kernel/qmacgesturerecognizer_mac.mm \
+ kernel/qmultitouch_mac.mm \
+ kernel/qcocoaintrospection_mac.mm
+
+ HEADERS += \
+ kernel/qt_cocoa_helpers_mac_p.h \
+ kernel/qcocoaapplication_mac_p.h \
+ kernel/qcocoaapplicationdelegate_mac_p.h \
+ kernel/qeventdispatcher_mac_p.h
+
+ MENU_NIB.files = mac/qt_menu.nib
+ MENU_NIB.path = Resources
+ MENU_NIB.version = Versions
+ QMAKE_BUNDLE_DATA += MENU_NIB
+ RESOURCES += mac/macresources.qrc
+
+ LIBS_PRIVATE += -framework AppKit
+}
+
+wince*: {
+ HEADERS += \
+ ../corelib/kernel/qfunctions_wince.h \
+ kernel/qguifunctions_wince.h
+
+ SOURCES += \
+ ../corelib/kernel/qfunctions_wince.cpp \
+ kernel/qguifunctions_wince.cpp
+}
diff --git a/src/widgets/kernel/mac.pri b/src/widgets/kernel/mac.pri
new file mode 100644
index 0000000000..df457dd166
--- /dev/null
+++ b/src/widgets/kernel/mac.pri
@@ -0,0 +1,4 @@
+!x11:!qpa:mac {
+ LIBS_PRIVATE += -framework Carbon -lz
+ *-mwerks:INCLUDEPATH += compat
+}
diff --git a/src/gui/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp
index 69e9889e08..69e9889e08 100644
--- a/src/gui/kernel/qaction.cpp
+++ b/src/widgets/kernel/qaction.cpp
diff --git a/src/widgets/kernel/qaction.h b/src/widgets/kernel/qaction.h
new file mode 100644
index 0000000000..765fba1d9f
--- /dev/null
+++ b/src/widgets/kernel/qaction.h
@@ -0,0 +1,264 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QACTION_H
+#define QACTION_H
+
+#include <QtGui/qkeysequence.h>
+#include <QtCore/qstring.h>
+#include <QtWidgets/qwidget.h>
+#include <QtCore/qvariant.h>
+#include <QtWidgets/qicon.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_ACTION
+
+class QMenu;
+class QActionGroup;
+class QActionPrivate;
+class QGraphicsWidget;
+
+class Q_GUI_EXPORT QAction : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QAction)
+
+ Q_ENUMS(MenuRole)
+ Q_ENUMS(SoftKeyRole)
+ Q_ENUMS(Priority)
+ Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY changed)
+ Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled)
+ Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY changed)
+ Q_PROPERTY(QIcon icon READ icon WRITE setIcon NOTIFY changed)
+ Q_PROPERTY(QString text READ text WRITE setText NOTIFY changed)
+ Q_PROPERTY(QString iconText READ iconText WRITE setIconText NOTIFY changed)
+ Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip NOTIFY changed)
+ Q_PROPERTY(QString statusTip READ statusTip WRITE setStatusTip NOTIFY changed)
+ Q_PROPERTY(QString whatsThis READ whatsThis WRITE setWhatsThis NOTIFY changed)
+ Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY changed)
+#ifndef QT_NO_SHORTCUT
+ Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut NOTIFY changed)
+ Q_PROPERTY(Qt::ShortcutContext shortcutContext READ shortcutContext WRITE setShortcutContext NOTIFY changed)
+ Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat NOTIFY changed)
+#endif
+ Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY changed)
+ Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
+ Q_PROPERTY(SoftKeyRole softKeyRole READ softKeyRole WRITE setSoftKeyRole NOTIFY changed)
+ Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
+ Q_PROPERTY(Priority priority READ priority WRITE setPriority)
+
+public:
+ enum MenuRole { NoRole, TextHeuristicRole, ApplicationSpecificRole, AboutQtRole,
+ AboutRole, PreferencesRole, QuitRole };
+ enum SoftKeyRole {
+ NoSoftKey, PositiveSoftKey, NegativeSoftKey, SelectSoftKey };
+ enum Priority { LowPriority = 0,
+ NormalPriority = 128,
+ HighPriority = 256};
+ explicit QAction(QObject* parent);
+ QAction(const QString &text, QObject* parent);
+ QAction(const QIcon &icon, const QString &text, QObject* parent);
+
+#ifdef QT3_SUPPORT
+ QT3_SUPPORT_CONSTRUCTOR QAction(QObject* parent, const char* name);
+ QT3_SUPPORT_CONSTRUCTOR QAction(const QString &text, const QKeySequence &shortcut,
+ QObject* parent, const char* name);
+ QT3_SUPPORT_CONSTRUCTOR QAction(const QIcon &icon, const QString &text,
+ const QKeySequence &shortcut,
+ QObject* parent, const char* name);
+#endif
+ ~QAction();
+
+ void setActionGroup(QActionGroup *group);
+ QActionGroup *actionGroup() const;
+ void setIcon(const QIcon &icon);
+ QIcon icon() const;
+
+ void setText(const QString &text);
+ QString text() const;
+
+ void setIconText(const QString &text);
+ QString iconText() const;
+
+ void setToolTip(const QString &tip);
+ QString toolTip() const;
+
+ void setStatusTip(const QString &statusTip);
+ QString statusTip() const;
+
+ void setWhatsThis(const QString &what);
+ QString whatsThis() const;
+
+ void setPriority(Priority priority);
+ Priority priority() const;
+
+#ifndef QT_NO_MENU
+ QMenu *menu() const;
+ void setMenu(QMenu *menu);
+#endif
+
+ void setSeparator(bool b);
+ bool isSeparator() const;
+
+#ifndef QT_NO_SHORTCUT
+ void setShortcut(const QKeySequence &shortcut);
+ QKeySequence shortcut() const;
+
+ void setShortcuts(const QList<QKeySequence> &shortcuts);
+ void setShortcuts(QKeySequence::StandardKey);
+ QList<QKeySequence> shortcuts() const;
+
+ void setShortcutContext(Qt::ShortcutContext context);
+ Qt::ShortcutContext shortcutContext() const;
+
+ void setAutoRepeat(bool);
+ bool autoRepeat() const;
+#endif
+
+ void setFont(const QFont &font);
+ QFont font() const;
+
+ void setCheckable(bool);
+ bool isCheckable() const;
+
+ QVariant data() const;
+ void setData(const QVariant &var);
+
+ bool isChecked() const;
+
+ bool isEnabled() const;
+
+ bool isVisible() const;
+
+ enum ActionEvent { Trigger, Hover };
+ void activate(ActionEvent event);
+ bool showStatusText(QWidget *widget=0);
+
+ void setMenuRole(MenuRole menuRole);
+ MenuRole menuRole() const;
+
+ void setSoftKeyRole(SoftKeyRole softKeyRole);
+ SoftKeyRole softKeyRole() const;
+
+ void setIconVisibleInMenu(bool visible);
+ bool isIconVisibleInMenu() const;
+
+#ifdef QT3_SUPPORT
+ inline QT3_SUPPORT void setMenuText(const QString &text) { setText(text); }
+ inline QT3_SUPPORT QString menuText() const { return text(); }
+ inline QT3_SUPPORT bool isOn() const { return isChecked(); }
+ inline QT3_SUPPORT bool isToggleAction() const { return isCheckable(); }
+ inline QT3_SUPPORT void setToggleAction(bool b) { setCheckable(b); }
+ inline QT3_SUPPORT void setIconSet(const QIcon &i) { setIcon(i); }
+ inline QT3_SUPPORT QIcon iconSet() const { return icon(); }
+ inline QT3_SUPPORT bool addTo(QWidget *w) { w->addAction(this); return true; }
+ inline QT3_SUPPORT bool removeFrom(QWidget *w) { w->removeAction(this); return true; }
+ inline QT3_SUPPORT void setAccel(const QKeySequence &shortcut) { setShortcut(shortcut); }
+ inline QT3_SUPPORT QKeySequence accel() const { return shortcut(); }
+#endif
+
+ QWidget *parentWidget() const;
+
+ QList<QWidget *> associatedWidgets() const;
+#ifndef QT_NO_GRAPHICSVIEW
+ QList<QGraphicsWidget *> associatedGraphicsWidgets() const; // ### suboptimal
+#endif
+
+protected:
+ bool event(QEvent *);
+ QAction(QActionPrivate &dd, QObject *parent);
+
+public Q_SLOTS:
+#ifdef QT3_SUPPORT
+ inline QT_MOC_COMPAT void setOn(bool b) { setChecked(b); }
+#endif
+ void trigger() { activate(Trigger); }
+ void hover() { activate(Hover); }
+ void setChecked(bool);
+ void toggle();
+ void setEnabled(bool);
+ inline void setDisabled(bool b) { setEnabled(!b); }
+ void setVisible(bool);
+
+Q_SIGNALS:
+ void changed();
+ void triggered(bool checked = false);
+ void hovered();
+ void toggled(bool);
+#ifdef QT3_SUPPORT
+ QT_MOC_COMPAT void activated(int = 0);
+#endif
+
+private:
+ Q_DISABLE_COPY(QAction)
+
+#ifdef QT3_SUPPORT
+ friend class QMenuItem;
+#endif
+ friend class QGraphicsWidget;
+ friend class QWidget;
+ friend class QActionGroup;
+ friend class QMenu;
+ friend class QMenuPrivate;
+ friend class QMenuBar;
+ friend class QShortcutMap;
+ friend class QToolButton;
+#ifdef Q_WS_MAC
+ friend void qt_mac_clear_status_text(QAction *action);
+#endif
+};
+
+QT_BEGIN_INCLUDE_NAMESPACE
+#include <QtWidgets/qactiongroup.h>
+QT_END_INCLUDE_NAMESPACE
+
+#endif // QT_NO_ACTION
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QACTION_H
diff --git a/src/widgets/kernel/qaction_p.h b/src/widgets/kernel/qaction_p.h
new file mode 100644
index 0000000000..652c9358e1
--- /dev/null
+++ b/src/widgets/kernel/qaction_p.h
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QACTION_P_H
+#define QACTION_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "QtWidgets/qaction.h"
+#include "QtWidgets/qmenu.h"
+#include "private/qgraphicswidget_p.h"
+#include "private/qobject_p.h"
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_ACTION
+
+#ifdef QT3_SUPPORT
+class QMenuItemEmitter;
+#endif
+
+class QShortcutMap;
+
+class Q_AUTOTEST_EXPORT QActionPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QAction)
+public:
+ QActionPrivate();
+ ~QActionPrivate();
+
+ static QActionPrivate *get(QAction *q)
+ {
+ return q->d_func();
+ }
+
+ bool showStatusText(QWidget *w, const QString &str);
+
+ QPointer<QActionGroup> group;
+ QString text;
+ QString iconText;
+ QIcon icon;
+ QString tooltip;
+ QString statustip;
+ QString whatsthis;
+#ifndef QT_NO_SHORTCUT
+ QKeySequence shortcut;
+ QList<QKeySequence> alternateShortcuts;
+#endif
+ QVariant userData;
+#ifndef QT_NO_SHORTCUT
+ int shortcutId;
+ QList<int> alternateShortcutIds;
+ Qt::ShortcutContext shortcutContext;
+ uint autorepeat : 1;
+#endif
+ QFont font;
+ QPointer<QMenu> menu;
+ uint enabled : 1, forceDisabled : 1;
+ uint visible : 1, forceInvisible : 1;
+ uint checkable : 1;
+ uint checked : 1;
+ uint separator : 1;
+ uint fontSet : 1;
+
+ //for soft keys management
+ uint forceEnabledInSoftkeys : 1;
+ uint menuActionSoftkeys : 1;
+ int iconVisibleInMenu : 3; // Only has values -1, 0, and 1
+
+ QAction::MenuRole menuRole;
+ QAction::SoftKeyRole softKeyRole;
+ QAction::Priority priority;
+
+ QList<QWidget *> widgets;
+#ifndef QT_NO_GRAPHICSVIEW
+ QList<QGraphicsWidget *> graphicsWidgets;
+#endif
+#ifndef QT_NO_SHORTCUT
+ void redoGrab(QShortcutMap &map);
+ void redoGrabAlternate(QShortcutMap &map);
+ void setShortcutEnabled(bool enable, QShortcutMap &map);
+
+ static QShortcutMap *globalMap;
+#endif // QT_NO_SHORTCUT
+
+#ifdef QT3_SUPPORT //for menubar/menu compat
+ QMenuItemEmitter *act_signal;
+ int id, param;
+#endif
+ void sendDataChanged();
+};
+
+#endif // QT_NO_ACTION
+
+QT_END_NAMESPACE
+
+#endif // QACTION_P_H
diff --git a/src/gui/kernel/qactiongroup.cpp b/src/widgets/kernel/qactiongroup.cpp
index 95ea8afab7..95ea8afab7 100644
--- a/src/gui/kernel/qactiongroup.cpp
+++ b/src/widgets/kernel/qactiongroup.cpp
diff --git a/src/widgets/kernel/qactiongroup.h b/src/widgets/kernel/qactiongroup.h
new file mode 100644
index 0000000000..998d312f35
--- /dev/null
+++ b/src/widgets/kernel/qactiongroup.h
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QACTIONGROUP_H
+#define QACTIONGROUP_H
+
+#include <QtWidgets/qaction.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_ACTION
+
+class QActionGroupPrivate;
+
+class Q_GUI_EXPORT QActionGroup : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QActionGroup)
+
+ Q_PROPERTY(bool exclusive READ isExclusive WRITE setExclusive)
+ Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
+ Q_PROPERTY(bool visible READ isVisible WRITE setVisible)
+
+public:
+ explicit QActionGroup(QObject* parent);
+ ~QActionGroup();
+
+ QAction *addAction(QAction* a);
+ QAction *addAction(const QString &text);
+ QAction *addAction(const QIcon &icon, const QString &text);
+ void removeAction(QAction *a);
+ QList<QAction*> actions() const;
+
+ QAction *checkedAction() const;
+ bool isExclusive() const;
+ bool isEnabled() const;
+ bool isVisible() const;
+
+#ifdef QT3_SUPPORT
+ inline QT3_SUPPORT void add(QAction* a) { addAction(a); }
+ inline QT3_SUPPORT void addSeparator()
+ { QAction *act = new QAction(this); act->setSeparator(true); addAction(act); }
+ inline QT3_SUPPORT bool addTo(QWidget *w) { w->addActions(actions()); return true; }
+#endif
+
+public Q_SLOTS:
+ void setEnabled(bool);
+ inline void setDisabled(bool b) { setEnabled(!b); }
+ void setVisible(bool);
+ void setExclusive(bool);
+
+Q_SIGNALS:
+ void triggered(QAction *);
+ QT_MOC_COMPAT void selected(QAction *);
+ void hovered(QAction *);
+
+private:
+ Q_DISABLE_COPY(QActionGroup)
+ Q_PRIVATE_SLOT(d_func(), void _q_actionTriggered())
+ Q_PRIVATE_SLOT(d_func(), void _q_actionChanged())
+ Q_PRIVATE_SLOT(d_func(), void _q_actionHovered())
+};
+
+#endif // QT_NO_ACTION
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QACTIONGROUP_H
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
new file mode 100644
index 0000000000..059c06d162
--- /dev/null
+++ b/src/widgets/kernel/qapplication.cpp
@@ -0,0 +1,5674 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformdefs.h"
+#include "qabstracteventdispatcher.h"
+#include "qaccessible.h"
+#include "qapplication.h"
+#include "qclipboard.h"
+#include "qcursor.h"
+#include "qdesktopwidget.h"
+#include "qdir.h"
+#include "qevent.h"
+#include "qfile.h"
+#include "qfileinfo.h"
+#include "qgraphicsscene.h"
+#include "qhash.h"
+#include "qset.h"
+#include "qlayout.h"
+#include "qsessionmanager.h"
+#include "qstyle.h"
+#include "qstylefactory.h"
+#include "qtextcodec.h"
+#include "qtranslator.h"
+#include "qvariant.h"
+#include "qwidget.h"
+#include "private/qdnd_p.h"
+#include "qcolormap.h"
+#include "qdebug.h"
+#include "private/qstylesheetstyle_p.h"
+#include "private/qstyle_p.h"
+#include "qmessagebox.h"
+#include <QtWidgets/qgraphicsproxywidget.h>
+
+#include "qinputcontext.h"
+#include "private/qkeymapper_p.h"
+
+#ifdef Q_WS_X11
+#include <private/qt_x11_p.h>
+#endif
+
+#if defined(Q_WS_X11) || defined(Q_OS_SYMBIAN)
+#include "qinputcontextfactory.h"
+#endif
+
+#include "qguiplatformplugin_p.h"
+
+#include <qthread.h>
+#include <private/qthread_p.h>
+
+#include <private/qfont_p.h>
+
+#include <stdlib.h>
+
+#if defined(Q_WS_X11) && !defined(QT_NO_EGL)
+#include <link.h>
+#endif
+
+#include "qapplication_p.h"
+#include "private/qevent_p.h"
+#include "qwidget_p.h"
+
+#include "qapplication.h"
+
+#include "qgesture.h"
+#include "private/qgesturemanager_p.h"
+
+#ifndef QT_NO_LIBRARY
+#include "qlibrary.h"
+#endif
+
+#ifdef Q_WS_WINCE
+#include "qdatetime.h"
+#include "qguifunctions_wince.h"
+extern bool qt_wince_is_smartphone(); //qguifunctions_wince.cpp
+extern bool qt_wince_is_mobile(); //qguifunctions_wince.cpp
+extern bool qt_wince_is_pocket_pc(); //qguifunctions_wince.cpp
+#endif
+
+#include "qdatetime.h"
+
+#ifdef QT_MAC_USE_COCOA
+#include <private/qt_cocoa_helpers_mac_p.h>
+#endif
+
+//#define ALIEN_DEBUG
+
+#if defined(Q_OS_SYMBIAN)
+#include "qt_s60_p.h"
+#endif
+
+static void initResources()
+{
+#if defined(Q_WS_WINCE)
+ Q_INIT_RESOURCE_EXTERN(qstyle_wince)
+ Q_INIT_RESOURCE(qstyle_wince);
+#elif defined(Q_OS_SYMBIAN)
+ Q_INIT_RESOURCE_EXTERN(qstyle_s60)
+ Q_INIT_RESOURCE(qstyle_s60);
+#else
+ Q_INIT_RESOURCE_EXTERN(qstyle)
+ Q_INIT_RESOURCE(qstyle);
+#endif
+ Q_INIT_RESOURCE_EXTERN(qmessagebox)
+ Q_INIT_RESOURCE(qmessagebox);
+#if !defined(QT_NO_PRINTDIALOG)
+ Q_INIT_RESOURCE_EXTERN(qprintdialog)
+ Q_INIT_RESOURCE(qprintdialog);
+#endif
+
+}
+
+QT_BEGIN_NAMESPACE
+
+Q_CORE_EXPORT void qt_call_post_routines();
+
+QApplication::Type qt_appType=QApplication::Tty;
+QApplicationPrivate *QApplicationPrivate::self = 0;
+
+QInputContext *QApplicationPrivate::inputContext = 0;
+
+bool QApplicationPrivate::quitOnLastWindowClosed = true;
+
+#ifdef Q_WS_WINCE
+int QApplicationPrivate::autoMaximizeThreshold = -1;
+bool QApplicationPrivate::autoSipEnabled = false;
+#else
+bool QApplicationPrivate::autoSipEnabled = true;
+#endif
+
+QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, QApplication::Type type, int flags)
+ : QApplicationPrivateBase(argc, argv, flags)
+{
+ application_type = type;
+ qt_appType = type;
+
+#ifndef QT_NO_SESSIONMANAGER
+ is_session_restored = false;
+#endif
+
+ quitOnLastWindowClosed = true;
+
+#ifdef QT3_SUPPORT
+ qt_compat_used = 0;
+ qt_compat_resolved = 0;
+ qt_tryAccelEvent = 0;
+ qt_tryComposeUnicode = 0;
+ qt_dispatchAccelEvent = 0;
+#endif
+#if defined(Q_WS_QWS) && !defined(QT_NO_DIRECTPAINTER)
+ directPainters = 0;
+#endif
+
+#ifndef QT_NO_GESTURES
+ gestureManager = 0;
+ gestureWidget = 0;
+#endif // QT_NO_GESTURES
+
+#if defined(Q_WS_X11) || defined(Q_WS_WIN)
+ move_cursor = 0;
+ copy_cursor = 0;
+ link_cursor = 0;
+#endif
+#if defined(Q_WS_WIN)
+ ignore_cursor = 0;
+#endif
+
+ if (!self)
+ self = this;
+}
+
+QApplicationPrivate::~QApplicationPrivate()
+{
+ if (self == this)
+ self = 0;
+}
+
+/*!
+ \class QApplication
+ \brief The QApplication class manages the GUI application's control
+ flow and main settings.
+
+ QApplication contains the main event loop, where all events from the window
+ system and other sources are processed and dispatched. It also handles the
+ application's initialization, finalization, and provides session
+ management. In addition, QApplication handles most of the system-wide and
+ application-wide settings.
+
+ For any GUI application using Qt, there is precisely \bold one QApplication
+ object, no matter whether the application has 0, 1, 2 or more windows at
+ any given time. For non-GUI Qt applications, use QCoreApplication instead,
+ as it does not depend on the \l QtGui library.
+
+ The QApplication object is accessible through the instance() function that
+ returns a pointer equivalent to the global qApp pointer.
+
+ QApplication's main areas of responsibility are:
+ \list
+ \o It initializes the application with the user's desktop settings
+ such as palette(), font() and doubleClickInterval(). It keeps
+ track of these properties in case the user changes the desktop
+ globally, for example through some kind of control panel.
+
+ \o It performs event handling, meaning that it receives events
+ from the underlying window system and dispatches them to the
+ relevant widgets. By using sendEvent() and postEvent() you can
+ send your own events to widgets.
+
+ \o It parses common command line arguments and sets its internal
+ state accordingly. See the \l{QApplication::QApplication()}
+ {constructor documentation} below for more details.
+
+ \o It defines the application's look and feel, which is
+ encapsulated in a QStyle object. This can be changed at runtime
+ with setStyle().
+
+ \o It specifies how the application is to allocate colors. See
+ setColorSpec() for details.
+
+ \o It provides localization of strings that are visible to the
+ user via translate().
+
+ \o It provides some magical objects like the desktop() and the
+ clipboard().
+
+ \o It knows about the application's windows. You can ask which
+ widget is at a certain position using widgetAt(), get a list of
+ topLevelWidgets() and closeAllWindows(), etc.
+
+ \o It manages the application's mouse cursor handling, see
+ setOverrideCursor()
+
+ \o On the X window system, it provides functions to flush and sync
+ the communication stream, see flushX() and syncX().
+
+ \o It provides support for sophisticated \l{Session Management}
+ {session management}. This makes it possible for applications
+ to terminate gracefully when the user logs out, to cancel a
+ shutdown process if termination isn't possible and even to
+ preserve the entire application's state for a future session.
+ See isSessionRestored(), sessionId() and commitData() and
+ saveState() for details.
+ \endlist
+
+ Since the QApplication object does so much initialization, it \e{must} be
+ created before any other objects related to the user interface are created.
+ QApplication also deals with common command line arguments. Hence, it is
+ usually a good idea to create it \e before any interpretation or
+ modification of \c argv is done in the application itself.
+
+ \table
+ \header
+ \o{2,1} Groups of functions
+
+ \row
+ \o System settings
+ \o desktopSettingsAware(),
+ setDesktopSettingsAware(),
+ cursorFlashTime(),
+ setCursorFlashTime(),
+ doubleClickInterval(),
+ setDoubleClickInterval(),
+ setKeyboardInputInterval(),
+ wheelScrollLines(),
+ setWheelScrollLines(),
+ palette(),
+ setPalette(),
+ font(),
+ setFont(),
+ fontMetrics().
+
+ \row
+ \o Event handling
+ \o exec(),
+ processEvents(),
+ exit(),
+ quit().
+ sendEvent(),
+ postEvent(),
+ sendPostedEvents(),
+ removePostedEvents(),
+ hasPendingEvents(),
+ notify(),
+ macEventFilter(),
+ qwsEventFilter(),
+ x11EventFilter(),
+ x11ProcessEvent(),
+ winEventFilter().
+
+ \row
+ \o GUI Styles
+ \o style(),
+ setStyle().
+
+ \row
+ \o Color usage
+ \o colorSpec(),
+ setColorSpec(),
+ qwsSetCustomColors().
+
+ \row
+ \o Text handling
+ \o installTranslator(),
+ removeTranslator()
+ translate().
+
+ \row
+ \o Widgets
+ \o allWidgets(),
+ topLevelWidgets(),
+ desktop(),
+ activePopupWidget(),
+ activeModalWidget(),
+ clipboard(),
+ focusWidget(),
+ activeWindow(),
+ widgetAt().
+
+ \row
+ \o Advanced cursor handling
+ \o overrideCursor(),
+ setOverrideCursor(),
+ restoreOverrideCursor().
+
+ \row
+ \o X Window System synchronization
+ \o flushX(),
+ syncX().
+
+ \row
+ \o Session management
+ \o isSessionRestored(),
+ sessionId(),
+ commitData(),
+ saveState().
+
+ \row
+ \o Miscellaneous
+ \o closeAllWindows(),
+ startingUp(),
+ closingDown(),
+ type().
+ \endtable
+
+ \sa QCoreApplication, QAbstractEventDispatcher, QEventLoop, QSettings
+*/
+
+/*!
+ \enum QApplication::Type
+
+ \value Tty a console application
+ \value GuiClient a GUI client application
+ \value GuiServer a GUI server application (for Qt for Embedded Linux)
+*/
+
+/*!
+ \enum QApplication::ColorSpec
+
+ \value NormalColor the default color allocation policy
+ \value CustomColor the same as NormalColor for X11; allocates colors
+ to a palette on demand under Windows
+ \value ManyColor the right choice for applications that use thousands of
+ colors
+
+ See setColorSpec() for full details.
+*/
+
+/*!
+ \fn QWidget *QApplication::topLevelAt(const QPoint &point)
+
+ Returns the top-level widget at the given \a point; returns 0 if
+ there is no such widget.
+*/
+
+/*!
+ \fn QWidget *QApplication::topLevelAt(int x, int y)
+
+ \overload
+
+ Returns the top-level widget at the point (\a{x}, \a{y}); returns
+ 0 if there is no such widget.
+*/
+
+
+/*
+ The qt_init() and qt_cleanup() functions are implemented in the
+ qapplication_xyz.cpp file.
+*/
+
+void qt_init(QApplicationPrivate *priv, int type
+#ifdef Q_WS_X11
+ , Display *display = 0, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0
+#endif
+ );
+void qt_cleanup();
+
+Qt::MouseButtons QApplicationPrivate::mouse_buttons = Qt::NoButton;
+Qt::KeyboardModifiers QApplicationPrivate::modifier_buttons = Qt::NoModifier;
+
+QStyle *QApplicationPrivate::app_style = 0; // default application style
+QString QApplicationPrivate::styleOverride; // style override
+
+#ifndef QT_NO_STYLE_STYLESHEET
+QString QApplicationPrivate::styleSheet; // default application stylesheet
+#endif
+QPointer<QWidget> QApplicationPrivate::leaveAfterRelease = 0;
+
+int QApplicationPrivate::app_cspec = QApplication::NormalColor;
+QPalette *QApplicationPrivate::sys_pal = 0; // default system palette
+QPalette *QApplicationPrivate::set_pal = 0; // default palette set by programmer
+
+#ifndef Q_WS_QPA
+Q_GLOBAL_STATIC(QMutex, applicationFontMutex)
+QFont *QApplicationPrivate::app_font = 0; // default application font
+#endif
+QFont *QApplicationPrivate::sys_font = 0; // default system font
+QFont *QApplicationPrivate::set_font = 0; // default font set by programmer
+
+QIcon *QApplicationPrivate::app_icon = 0;
+QWidget *QApplicationPrivate::main_widget = 0; // main application widget
+QWidget *QApplicationPrivate::focus_widget = 0; // has keyboard input focus
+QWidget *QApplicationPrivate::hidden_focus_widget = 0; // will get keyboard input focus after show()
+QWidget *QApplicationPrivate::active_window = 0; // toplevel with keyboard focus
+bool QApplicationPrivate::obey_desktop_settings = true; // use winsys resources
+int QApplicationPrivate::cursor_flash_time = 1000; // text caret flash time
+int QApplicationPrivate::mouse_double_click_time = 400; // mouse dbl click limit
+int QApplicationPrivate::keyboard_input_time = 400; // keyboard input interval
+#ifndef QT_NO_WHEELEVENT
+int QApplicationPrivate::wheel_scroll_lines; // number of lines to scroll
+#endif
+extern bool qt_is_gui_used;
+bool Q_GUI_EXPORT qt_tab_all_widgets = true;
+bool qt_in_tab_key_event = false;
+int qt_antialiasing_threshold = -1;
+static int drag_time = 500;
+#ifndef QT_GUI_DRAG_DISTANCE
+#define QT_GUI_DRAG_DISTANCE 4
+#endif
+#ifdef Q_OS_SYMBIAN
+// The screens are a bit too small to for your thumb when using only 4 pixels drag distance.
+static int drag_distance = 12; //XXX move to qplatformdefs.h
+#else
+static int drag_distance = QT_GUI_DRAG_DISTANCE;
+#endif
+QSize QApplicationPrivate::app_strut = QSize(0,0); // no default application strut
+bool QApplicationPrivate::animate_ui = true;
+bool QApplicationPrivate::animate_menu = false;
+bool QApplicationPrivate::fade_menu = false;
+bool QApplicationPrivate::animate_combo = false;
+bool QApplicationPrivate::animate_tooltip = false;
+bool QApplicationPrivate::fade_tooltip = false;
+bool QApplicationPrivate::animate_toolbox = false;
+bool QApplicationPrivate::widgetCount = false;
+bool QApplicationPrivate::load_testability = false;
+QString QApplicationPrivate::qmljs_debug_arguments;
+#ifdef QT_KEYPAD_NAVIGATION
+# ifdef Q_OS_SYMBIAN
+Qt::NavigationMode QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadDirectional;
+# else
+Qt::NavigationMode QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadTabOrder;
+# endif
+QWidget *QApplicationPrivate::oldEditFocus = 0;
+#endif
+
+bool qt_tabletChokeMouse = false;
+
+inline bool QApplicationPrivate::isAlien(QWidget *widget)
+{
+ if (!widget)
+ return false;
+#if defined(Q_WS_QWS) || defined(Q_WS_QPA)
+ return !widget->isWindow()
+# ifdef Q_BACKINGSTORE_SUBSURFACES
+ && !(widget->d_func()->maybeTopData() && widget->d_func()->maybeTopData()->windowSurface)
+# endif
+ ;
+#else
+ return !widget->internalWinId();
+#endif
+}
+
+// ######## move to QApplicationPrivate
+// Default application palettes and fonts (per widget type)
+Q_GLOBAL_STATIC(PaletteHash, app_palettes)
+PaletteHash *qt_app_palettes_hash()
+{
+ return app_palettes();
+}
+
+Q_GLOBAL_STATIC(FontHash, app_fonts)
+FontHash *qt_app_fonts_hash()
+{
+ return app_fonts();
+}
+
+QWidgetList *QApplicationPrivate::popupWidgets = 0; // has keyboard input focus
+
+QDesktopWidget *qt_desktopWidget = 0; // root window widgets
+#if !defined(Q_WS_QPA) && !defined(QT_NO_CLIPBOARD)
+QClipboard *qt_clipboard = 0; // global clipboard object
+#endif
+QWidgetList * qt_modal_stack=0; // stack of modal widgets
+
+/*!
+ \internal
+*/
+void QApplicationPrivate::process_cmdline()
+{
+ // process platform-indep command line
+ if (!qt_is_gui_used || !argc)
+ return;
+
+ int i, j;
+
+ j = 1;
+ for (i=1; i<argc; i++) { // if you add anything here, modify QCoreApplication::arguments()
+ if (argv[i] && *argv[i] != '-') {
+ argv[j++] = argv[i];
+ continue;
+ }
+ QByteArray arg = argv[i];
+ arg = arg;
+ QString s;
+ if (arg == "-qdevel" || arg == "-qdebug") {
+ // obsolete argument
+ } else if (arg.indexOf("-qmljsdebugger=", 0) != -1) {
+ qmljs_debug_arguments = QString::fromLocal8Bit(arg.right(arg.length() - 15));
+ } else if (arg.indexOf("-style=", 0) != -1) {
+ s = QString::fromLocal8Bit(arg.right(arg.length() - 7).toLower());
+ } else if (arg == "-style" && i < argc-1) {
+ s = QString::fromLocal8Bit(argv[++i]).toLower();
+#ifndef QT_NO_SESSIONMANAGER
+ } else if (arg == "-session" && i < argc-1) {
+ ++i;
+ if (argv[i] && *argv[i]) {
+ session_id = QString::fromLatin1(argv[i]);
+ int p = session_id.indexOf(QLatin1Char('_'));
+ if (p >= 0) {
+ session_key = session_id.mid(p +1);
+ session_id = session_id.left(p);
+ }
+ is_session_restored = true;
+ }
+#endif
+#ifndef QT_NO_STYLE_STYLESHEET
+ } else if (arg == "-stylesheet" && i < argc -1) {
+ styleSheet = QLatin1String("file:///");
+ styleSheet.append(QString::fromLocal8Bit(argv[++i]));
+ } else if (arg.indexOf("-stylesheet=") != -1) {
+ styleSheet = QLatin1String("file:///");
+ styleSheet.append(QString::fromLocal8Bit(arg.right(arg.length() - 12)));
+#endif
+ } else if (qstrcmp(arg, "-widgetcount") == 0) {
+ widgetCount = true;
+ } else if (qstrcmp(arg, "-testability") == 0) {
+ load_testability = true;
+ } else {
+ argv[j++] = argv[i];
+ }
+ if (!s.isEmpty()) {
+ if (app_style) {
+ delete app_style;
+ app_style = 0;
+ }
+ styleOverride = s;
+ }
+ }
+
+ if(j < argc) {
+ argv[j] = 0;
+ argc = j;
+ }
+}
+
+/*!
+ Initializes the window system and constructs an application object with
+ \a argc command line arguments in \a argv.
+
+ \warning The data referred to by \a argc and \a argv must stay valid for
+ the entire lifetime of the QApplication object. In addition, \a argc must
+ be greater than zero and \a argv must contain at least one valid character
+ string.
+
+ The global \c qApp pointer refers to this application object. Only one
+ application object should be created.
+
+ This application object must be constructed before any \l{QPaintDevice}
+ {paint devices} (including widgets, pixmaps, bitmaps etc.).
+
+ \note \a argc and \a argv might be changed as Qt removes command line
+ arguments that it recognizes.
+
+ Qt debugging options (not available if Qt was compiled without the QT_DEBUG
+ flag defined):
+ \list
+ \o -nograb, tells Qt that it must never grab the mouse or the
+ keyboard.
+ \o -dograb (only under X11), running under a debugger can cause an
+ implicit -nograb, use -dograb to override.
+ \o -sync (only under X11), switches to synchronous mode for
+ debugging.
+ \endlist
+
+ See \l{Debugging Techniques} for a more detailed explanation.
+
+ All Qt programs automatically support the following command line options:
+ \list
+ \o -style= \e style, sets the application GUI style. Possible values
+ are \c motif, \c windows, and \c platinum. If you compiled Qt with
+ additional styles or have additional styles as plugins these will
+ be available to the \c -style command line option.
+ \o -style \e style, is the same as listed above.
+ \o -stylesheet= \e stylesheet, sets the application \l styleSheet. The
+ value must be a path to a file that contains the Style Sheet.
+ \note Relative URLs in the Style Sheet file are relative to the
+ Style Sheet file's path.
+ \o -stylesheet \e stylesheet, is the same as listed above.
+ \o -session= \e session, restores the application from an earlier
+ \l{Session Management}{session}.
+ \o -session \e session, is the same as listed above.
+ \o -widgetcount, prints debug message at the end about number of
+ widgets left undestroyed and maximum number of widgets existed at
+ the same time
+ \o -reverse, sets the application's layout direction to
+ Qt::RightToLeft
+ \o -qmljsdebugger=, activates the QML/JS debugger with a specified port.
+ The value must be of format port:1234[,block], where block is optional
+ and will make the application wait until a debugger connects to it.
+ \endlist
+
+ The X11 version of Qt supports some traditional X11 command line options:
+ \list
+ \o -display \e display, sets the X display (default is $DISPLAY).
+ \o -geometry \e geometry, sets the client geometry of the first window
+ that is shown.
+ \o -fn or \c -font \e font, defines the application font. The font
+ should be specified using an X logical font description. Note that
+ this option is ignored when Qt is built with fontconfig support enabled.
+ \o -bg or \c -background \e color, sets the default background color
+ and an application palette (light and dark shades are calculated).
+ \o -fg or \c -foreground \e color, sets the default foreground color.
+ \o -btn or \c -button \e color, sets the default button color.
+ \o -name \e name, sets the application name.
+ \o -title \e title, sets the application title.
+ \o -visual \c TrueColor, forces the application to use a TrueColor
+ visual on an 8-bit display.
+ \o -ncols \e count, limits the number of colors allocated in the color
+ cube on an 8-bit display, if the application is using the
+ QApplication::ManyColor color specification. If \e count is 216
+ then a 6x6x6 color cube is used (i.e. 6 levels of red, 6 of green,
+ and 6 of blue); for other values, a cube approximately proportional
+ to a 2x3x1 cube is used.
+ \o -cmap, causes the application to install a private color map on an
+ 8-bit display.
+ \o -im, sets the input method server (equivalent to setting the
+ XMODIFIERS environment variable)
+ \o -inputstyle, defines how the input is inserted into the given
+ widget, e.g., \c onTheSpot makes the input appear directly in the
+ widget, while \c overTheSpot makes the input appear in a box
+ floating over the widget and is not inserted until the editing is
+ done.
+ \endlist
+
+ \section1 X11 Notes
+
+ If QApplication fails to open the X11 display, it will terminate
+ the process. This behavior is consistent with most X11
+ applications.
+
+ \sa arguments()
+*/
+
+QApplication::QApplication(int &argc, char **argv)
+ : QApplicationBase(*new QApplicationPrivate(argc, argv, GuiClient, 0x040000))
+{ Q_D(QApplication); d->construct(); }
+
+QApplication::QApplication(int &argc, char **argv, int _internal)
+ : QApplicationBase(*new QApplicationPrivate(argc, argv, GuiClient, _internal))
+{ Q_D(QApplication); d->construct(); }
+
+
+/*!
+ Constructs an application object with \a argc command line arguments in
+ \a argv. If \a GUIenabled is true, a GUI application is constructed,
+ otherwise a non-GUI (console) application is created.
+
+ \warning The data referred to by \a argc and \a argv must stay valid for
+ the entire lifetime of the QApplication object. In addition, \a argc must
+ be greater than zero and \a argv must contain at least one valid character
+ string.
+
+ Set \a GUIenabled to false for programs without a graphical user interface
+ that should be able to run without a window system.
+
+ On X11, the window system is initialized if \a GUIenabled is true. If
+ \a GUIenabled is false, the application does not connect to the X server.
+ On Windows and Mac OS, currently the window system is always initialized,
+ regardless of the value of GUIenabled. This may change in future versions
+ of Qt.
+
+ The following example shows how to create an application that uses a
+ graphical interface when available.
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 0
+*/
+
+QApplication::QApplication(int &argc, char **argv, bool GUIenabled )
+ : QApplicationBase(*new QApplicationPrivate(argc, argv, GUIenabled ? GuiClient : Tty, 0x040000))
+{ Q_D(QApplication); d->construct(); }
+
+QApplication::QApplication(int &argc, char **argv, bool GUIenabled , int _internal)
+ : QApplicationBase(*new QApplicationPrivate(argc, argv, GUIenabled ? GuiClient : Tty, _internal))
+{ Q_D(QApplication); d->construct();}
+
+
+
+/*!
+ Constructs an application object with \a argc command line arguments in
+ \a argv.
+
+ \warning The data referred to by \a argc and \a argv must stay valid for
+ the entire lifetime of the QApplication object. In addition, \a argc must
+ be greater than zero and \a argv must contain at least one valid character
+ string.
+
+ With Qt for Embedded Linux, passing QApplication::GuiServer for \a type
+ makes this application the server (equivalent to running with the
+ \c -qws option).
+*/
+QApplication::QApplication(int &argc, char **argv, Type type)
+ : QApplicationBase(*new QApplicationPrivate(argc, argv, type, 0x040000))
+{ Q_D(QApplication); d->construct(); }
+
+QApplication::QApplication(int &argc, char **argv, Type type , int _internal)
+ : QApplicationBase(*new QApplicationPrivate(argc, argv, type, _internal))
+{ Q_D(QApplication); d->construct(); }
+
+#if defined(Q_WS_X11) && !defined(QT_NO_EGL)
+static int qt_matchLibraryName(dl_phdr_info *info, size_t, void *data)
+{
+ const char *name = static_cast<const char *>(data);
+ return strstr(info->dlpi_name, name) != 0;
+}
+#endif
+
+/*!
+ \internal
+*/
+void QApplicationPrivate::construct(
+#ifdef Q_WS_X11
+ Display *dpy, Qt::HANDLE visual, Qt::HANDLE cmap
+#endif
+ )
+{
+ initResources();
+
+ qt_is_gui_used = (qt_appType != QApplication::Tty);
+ process_cmdline();
+
+ // Must be called before initialize()
+ qt_init(this, qt_appType
+#ifdef Q_WS_X11
+ , dpy, visual, cmap
+#endif
+ );
+ initialize();
+ eventDispatcher->startingUp();
+
+#ifdef QT_EVAL
+ extern void qt_gui_eval_init(uint);
+ qt_gui_eval_init(application_type);
+#endif
+
+#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SYSTEMLOCALE)
+ symbianInit();
+#endif
+
+#ifndef QT_NO_LIBRARY
+ if(load_testability) {
+ QLibrary testLib(QLatin1String("qttestability"));
+ if (testLib.load()) {
+ typedef void (*TasInitialize)(void);
+ TasInitialize initFunction = (TasInitialize)testLib.resolve("qt_testability_init");
+#ifdef Q_OS_SYMBIAN
+ // resolving method by name does not work on Symbian OS so need to use ordinal
+ if(!initFunction) {
+ initFunction = (TasInitialize)testLib.resolve("1");
+ }
+#endif
+ if (initFunction) {
+ initFunction();
+ } else {
+ qCritical("Library qttestability resolve failed!");
+ }
+ } else {
+ qCritical("Library qttestability load failed!");
+ }
+ }
+
+ //make sure the plugin is loaded
+ if (qt_is_gui_used)
+ qt_guiPlatformPlugin();
+#endif
+}
+
+#if defined(Q_WS_X11)
+// ### a string literal is a cont char*
+// ### using it as a char* is wrong and could lead to segfaults
+// ### if aargv is modified someday
+// ########## make it work with argc == argv == 0
+static int aargc = 1;
+static char *aargv[] = { (char*)"unknown", 0 };
+
+/*!
+ \fn QApplication::QApplication(Display* display, Qt::HANDLE visual, Qt::HANDLE colormap)
+
+ Creates an application, given an already open display \a display. If
+ \a visual and \a colormap are non-zero, the application will use those
+ values as the default Visual and Colormap contexts.
+
+ \warning Qt only supports TrueColor visuals at depths higher than 8
+ bits-per-pixel.
+
+ This function is only available on X11.
+*/
+QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap)
+ : QApplicationBase(*new QApplicationPrivate(aargc, aargv, GuiClient, 0x040000))
+{
+ if (! dpy)
+ qWarning("QApplication: Invalid Display* argument");
+ Q_D(QApplication);
+ d->construct(dpy, visual, colormap);
+}
+
+QApplication::QApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE colormap, int _internal)
+ : QApplicationBase(*new QApplicationPrivate(aargc, aargv, GuiClient, _internal))
+{
+ if (! dpy)
+ qWarning("QApplication: Invalid Display* argument");
+ Q_D(QApplication);
+ d->construct(dpy, visual, colormap);
+ QApplicationPrivate::app_compile_version = _internal;
+}
+
+/*!
+ \fn QApplication::QApplication(Display *display, int &argc, char **argv,
+ Qt::HANDLE visual, Qt::HANDLE colormap)
+
+ Creates an application, given an already open \a display and using \a argc
+ command line arguments in \a argv. If \a visual and \a colormap are
+ non-zero, the application will use those values as the default Visual
+ and Colormap contexts.
+
+ \warning Qt only supports TrueColor visuals at depths higher than 8
+ bits-per-pixel.
+
+ This function is only available on X11.
+*/
+QApplication::QApplication(Display *dpy, int &argc, char **argv,
+ Qt::HANDLE visual, Qt::HANDLE colormap)
+ : QApplicationBase(*new QApplicationPrivate(argc, argv, GuiClient, 0x040000))
+{
+ if (! dpy)
+ qWarning("QApplication: Invalid Display* argument");
+ Q_D(QApplication);
+ d->construct(dpy, visual, colormap);
+}
+
+QApplication::QApplication(Display *dpy, int &argc, char **argv,
+ Qt::HANDLE visual, Qt::HANDLE colormap, int _internal)
+ : QApplicationBase(*new QApplicationPrivate(argc, argv, GuiClient, _internal))
+{
+ if (! dpy)
+ qWarning("QApplication: Invalid Display* argument");
+ Q_D(QApplication);
+ d->construct(dpy, visual, colormap);
+ QApplicationPrivate::app_compile_version = _internal;
+}
+
+#endif // Q_WS_X11
+
+#ifndef QT_NO_STATEMACHINE
+extern int qRegisterGuiStateMachine();
+extern int qUnregisterGuiStateMachine();
+#endif
+
+/*!
+ \fn void QApplicationPrivate::initialize()
+
+ Initializes the QApplication object, called from the constructors.
+*/
+void QApplicationPrivate::initialize()
+{
+ QWidgetPrivate::mapper = new QWidgetMapper;
+ QWidgetPrivate::allWidgets = new QWidgetSet;
+
+ if (qt_appType != QApplication::Tty)
+ (void) QApplication::style(); // trigger creation of application style
+#ifndef QT_NO_STATEMACHINE
+ // trigger registering of QStateMachine's GUI types
+ qRegisterGuiStateMachine();
+#endif
+
+ is_app_running = true; // no longer starting up
+
+ Q_Q(QApplication);
+#ifndef QT_NO_SESSIONMANAGER
+ // connect to the session manager
+ session_manager = new QSessionManager(q, session_id, session_key);
+#endif
+
+ if (qgetenv("QT_USE_NATIVE_WINDOWS").toInt() > 0)
+ q->setAttribute(Qt::AA_NativeWindows);
+
+#ifdef Q_WS_WINCE
+#ifdef QT_AUTO_MAXIMIZE_THRESHOLD
+ autoMaximizeThreshold = QT_AUTO_MAXIMIZE_THRESHOLD;
+#else
+ if (qt_wince_is_mobile())
+ autoMaximizeThreshold = 50;
+ else
+ autoMaximizeThreshold = -1;
+#endif //QT_AUTO_MAXIMIZE_THRESHOLD
+#endif //Q_WS_WINCE
+
+#ifndef QT_NO_WHEELEVENT
+ QApplicationPrivate::wheel_scroll_lines = 3;
+#endif
+
+ if (qt_is_gui_used)
+ initializeMultitouch();
+}
+
+/*!
+ Returns the type of application (\l Tty, GuiClient, or
+ GuiServer). The type is set when constructing the QApplication
+ object.
+*/
+QApplication::Type QApplication::type()
+{
+ return qt_appType;
+}
+
+/*****************************************************************************
+ Functions returning the active popup and modal widgets.
+ *****************************************************************************/
+
+/*!
+ Returns the active popup widget.
+
+ A popup widget is a special top-level widget that sets the \c
+ Qt::WType_Popup widget flag, e.g. the QMenu widget. When the application
+ opens a popup widget, all events are sent to the popup. Normal widgets and
+ modal widgets cannot be accessed before the popup widget is closed.
+
+ Only other popup widgets may be opened when a popup widget is shown. The
+ popup widgets are organized in a stack. This function returns the active
+ popup widget at the top of the stack.
+
+ \sa activeModalWidget(), topLevelWidgets()
+*/
+
+QWidget *QApplication::activePopupWidget()
+{
+ return QApplicationPrivate::popupWidgets && !QApplicationPrivate::popupWidgets->isEmpty() ?
+ QApplicationPrivate::popupWidgets->last() : 0;
+}
+
+
+/*!
+ Returns the active modal widget.
+
+ A modal widget is a special top-level widget which is a subclass of QDialog
+ that specifies the modal parameter of the constructor as true. A modal
+ widget must be closed before the user can continue with other parts of the
+ program.
+
+ Modal widgets are organized in a stack. This function returns the active
+ modal widget at the top of the stack.
+
+ \sa activePopupWidget(), topLevelWidgets()
+*/
+
+QWidget *QApplication::activeModalWidget()
+{
+ return qt_modal_stack && !qt_modal_stack->isEmpty() ? qt_modal_stack->first() : 0;
+}
+
+/*!
+ Cleans up any window system resources that were allocated by this
+ application. Sets the global variable \c qApp to 0.
+*/
+
+QApplication::~QApplication()
+{
+ Q_D(QApplication);
+
+#if !defined(Q_WS_QPA) && !defined(QT_NO_CLIPBOARD)
+ // flush clipboard contents
+ if (qt_clipboard) {
+ QEvent event(QEvent::Clipboard);
+ QApplication::sendEvent(qt_clipboard, &event);
+ }
+#endif
+
+ //### this should probable be done even later
+ qt_call_post_routines();
+
+ // kill timers before closing down the dispatcher
+ d->toolTipWakeUp.stop();
+ d->toolTipFallAsleep.stop();
+
+#if !defined(Q_WS_QPA)
+ d->eventDispatcher->closingDown();
+ d->eventDispatcher = 0;
+#endif
+ QApplicationPrivate::is_app_closing = true;
+ QApplicationPrivate::is_app_running = false;
+
+ delete QWidgetPrivate::mapper;
+ QWidgetPrivate::mapper = 0;
+
+ // delete all widgets
+ if (QWidgetPrivate::allWidgets) {
+ QWidgetSet *mySet = QWidgetPrivate::allWidgets;
+ QWidgetPrivate::allWidgets = 0;
+ for (QWidgetSet::ConstIterator it = mySet->constBegin(); it != mySet->constEnd(); ++it) {
+ register QWidget *w = *it;
+ if (!w->parent()) // window
+ w->destroy(true, true);
+ }
+ delete mySet;
+ }
+
+ delete qt_desktopWidget;
+ qt_desktopWidget = 0;
+
+#if !defined(Q_WS_QPA) && !defined(QT_NO_CLIPBOARD)
+ delete qt_clipboard;
+ qt_clipboard = 0;
+#endif
+
+#if defined(Q_WS_X11) || defined(Q_WS_WIN)
+ delete d->move_cursor; d->move_cursor = 0;
+ delete d->copy_cursor; d->copy_cursor = 0;
+ delete d->link_cursor; d->link_cursor = 0;
+#endif
+#if defined(Q_WS_WIN)
+ delete d->ignore_cursor; d->ignore_cursor = 0;
+#endif
+
+ delete QApplicationPrivate::app_pal;
+ QApplicationPrivate::app_pal = 0;
+ delete QApplicationPrivate::sys_pal;
+ QApplicationPrivate::sys_pal = 0;
+ delete QApplicationPrivate::set_pal;
+ QApplicationPrivate::set_pal = 0;
+ app_palettes()->clear();
+
+#ifndef Q_WS_QPA
+ {
+ QMutexLocker locker(applicationFontMutex());
+ delete QApplicationPrivate::app_font;
+ QApplicationPrivate::app_font = 0;
+ }
+#endif
+
+ delete QApplicationPrivate::sys_font;
+ QApplicationPrivate::sys_font = 0;
+ delete QApplicationPrivate::set_font;
+ QApplicationPrivate::set_font = 0;
+ app_fonts()->clear();
+
+ delete QApplicationPrivate::app_style;
+ QApplicationPrivate::app_style = 0;
+ delete QApplicationPrivate::app_icon;
+ QApplicationPrivate::app_icon = 0;
+
+#ifndef QT_NO_DRAGANDDROP
+ if (qt_is_gui_used)
+ delete QDragManager::self();
+#endif
+
+ d->cleanupMultitouch();
+
+ qt_cleanup();
+
+ if (QApplicationPrivate::widgetCount)
+ qDebug("Widgets left: %i Max widgets: %i \n", QWidgetPrivate::instanceCounter, QWidgetPrivate::maxInstances);
+#ifndef QT_NO_SESSIONMANAGER
+ delete d->session_manager;
+ d->session_manager = 0;
+#endif //QT_NO_SESSIONMANAGER
+
+ QApplicationPrivate::obey_desktop_settings = true;
+ QApplicationPrivate::cursor_flash_time = 1000;
+ QApplicationPrivate::mouse_double_click_time = 400;
+ QApplicationPrivate::keyboard_input_time = 400;
+
+ drag_time = 500;
+ drag_distance = 4;
+ QApplicationPrivate::app_strut = QSize(0, 0);
+ QApplicationPrivate::animate_ui = true;
+ QApplicationPrivate::animate_menu = false;
+ QApplicationPrivate::fade_menu = false;
+ QApplicationPrivate::animate_combo = false;
+ QApplicationPrivate::animate_tooltip = false;
+ QApplicationPrivate::fade_tooltip = false;
+ QApplicationPrivate::widgetCount = false;
+
+#ifndef QT_NO_STATEMACHINE
+ // trigger unregistering of QStateMachine's GUI types
+ qUnregisterGuiStateMachine();
+#endif
+}
+
+
+/*!
+ \fn QWidget *QApplication::widgetAt(const QPoint &point)
+
+ Returns the widget at global screen position \a point, or 0 if there is no
+ Qt widget there.
+
+ This function can be slow.
+
+ \sa QCursor::pos(), QWidget::grabMouse(), QWidget::grabKeyboard()
+*/
+QWidget *QApplication::widgetAt(const QPoint &p)
+{
+ QWidget *window = QApplication::topLevelAt(p);
+ if (!window)
+ return 0;
+
+ QWidget *child = 0;
+
+ if (!window->testAttribute(Qt::WA_TransparentForMouseEvents))
+ child = window->childAt(window->mapFromGlobal(p));
+
+ if (child)
+ return child;
+
+ if (window->testAttribute(Qt::WA_TransparentForMouseEvents)) {
+ //shoot a hole in the widget and try once again,
+ //suboptimal on Qt for Embedded Linux where we do
+ //know the stacking order of the toplevels.
+ int x = p.x();
+ int y = p.y();
+ QRegion oldmask = window->mask();
+ QPoint wpoint = window->mapFromGlobal(QPoint(x, y));
+ QRegion newmask = (oldmask.isEmpty() ? QRegion(window->rect()) : oldmask)
+ - QRegion(wpoint.x(), wpoint.y(), 1, 1);
+ window->setMask(newmask);
+ QWidget *recurse = 0;
+ if (QApplication::topLevelAt(p) != window) // verify recursion will terminate
+ recurse = widgetAt(x, y);
+ if (oldmask.isEmpty())
+ window->clearMask();
+ else
+ window->setMask(oldmask);
+ return recurse;
+ }
+ return window;
+}
+
+/*!
+ \fn QWidget *QApplication::widgetAt(int x, int y)
+
+ \overload
+
+ Returns the widget at global screen position (\a x, \a y), or 0 if there is
+ no Qt widget there.
+*/
+
+/*!
+ \fn void QApplication::setArgs(int argc, char **argv)
+ \internal
+*/
+
+
+
+/*!
+ \internal
+*/
+bool QApplication::compressEvent(QEvent *event, QObject *receiver, QPostEventList *postedEvents)
+{
+ if ((event->type() == QEvent::UpdateRequest
+#ifdef QT3_SUPPORT
+ || event->type() == QEvent::LayoutHint
+#endif
+ || event->type() == QEvent::LayoutRequest
+ || event->type() == QEvent::Resize
+ || event->type() == QEvent::Move
+ || event->type() == QEvent::LanguageChange
+ || event->type() == QEvent::UpdateSoftKeys
+ || event->type() == QEvent::InputMethod)) {
+ for (int i = 0; i < postedEvents->size(); ++i) {
+ const QPostEvent &cur = postedEvents->at(i);
+ if (cur.receiver != receiver || cur.event == 0 || cur.event->type() != event->type())
+ continue;
+ if (cur.event->type() == QEvent::LayoutRequest
+#ifdef QT3_SUPPORT
+ || cur.event->type() == QEvent::LayoutHint
+#endif
+ || cur.event->type() == QEvent::UpdateRequest) {
+ ;
+ } else if (cur.event->type() == QEvent::Resize) {
+ ((QResizeEvent *)(cur.event))->s = ((QResizeEvent *)event)->s;
+ } else if (cur.event->type() == QEvent::Move) {
+ ((QMoveEvent *)(cur.event))->p = ((QMoveEvent *)event)->p;
+ } else if (cur.event->type() == QEvent::LanguageChange) {
+ ;
+ } else if (cur.event->type() == QEvent::UpdateSoftKeys) {
+ ;
+ } else if ( cur.event->type() == QEvent::InputMethod ) {
+ *(QInputMethodEvent *)(cur.event) = *(QInputMethodEvent *)event;
+ } else {
+ continue;
+ }
+ delete event;
+ return true;
+ }
+ return false;
+ }
+ return QApplicationBase::compressEvent(event, receiver, postedEvents);
+}
+
+/*!
+ \property QApplication::styleSheet
+ \brief the application style sheet
+ \since 4.2
+
+ By default, this property returns an empty string unless the user specifies
+ the \c{-stylesheet} option on the command line when running the application.
+
+ \sa QWidget::setStyle(), {Qt Style Sheets}
+*/
+
+/*!
+ \property QApplication::autoMaximizeThreshold
+ \since 4.4
+ \brief defines a threshold for auto maximizing widgets
+
+ \bold{The auto maximize threshold is only available as part of Qt for
+ Windows CE.}
+
+ This property defines a threshold for the size of a window as a percentage
+ of the screen size. If the minimum size hint of a window exceeds the
+ threshold, calling show() will cause the window to be maximized
+ automatically.
+
+ Setting the threshold to 100 or greater means that the widget will always
+ be maximized. Alternatively, setting the threshold to 50 means that the
+ widget will be maximized only if the vertical minimum size hint is at least
+ 50% of the vertical screen size.
+
+ Setting the threshold to -1 disables the feature.
+
+ On Windows CE the default is -1 (i.e., it is disabled).
+ On Windows Mobile the default is 40.
+*/
+
+/*!
+ \property QApplication::autoSipEnabled
+ \since 4.5
+ \brief toggles automatic SIP (software input panel) visibility
+
+ Set this property to \c true to automatically display the SIP when entering
+ widgets that accept keyboard input. This property only affects widgets with
+ the WA_InputMethodEnabled attribute set, and is typically used to launch
+ a virtual keyboard on devices which have very few or no keys.
+
+ \bold{ The property only has an effect on platforms which use software input
+ panels, such as Windows CE and Symbian.}
+
+ The default is platform dependent.
+*/
+
+#ifdef Q_WS_WINCE
+void QApplication::setAutoMaximizeThreshold(const int threshold)
+{
+ QApplicationPrivate::autoMaximizeThreshold = threshold;
+}
+
+int QApplication::autoMaximizeThreshold() const
+{
+ return QApplicationPrivate::autoMaximizeThreshold;
+}
+#endif
+
+void QApplication::setAutoSipEnabled(const bool enabled)
+{
+ QApplicationPrivate::autoSipEnabled = enabled;
+}
+
+bool QApplication::autoSipEnabled() const
+{
+ return QApplicationPrivate::autoSipEnabled;
+}
+
+#ifndef QT_NO_STYLE_STYLESHEET
+
+QString QApplication::styleSheet() const
+{
+ return QApplicationPrivate::styleSheet;
+}
+
+void QApplication::setStyleSheet(const QString& styleSheet)
+{
+ QApplicationPrivate::styleSheet = styleSheet;
+ QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle*>(QApplicationPrivate::app_style);
+ if (styleSheet.isEmpty()) { // application style sheet removed
+ if (!proxy)
+ return; // there was no stylesheet before
+ setStyle(proxy->base);
+ } else if (proxy) { // style sheet update, just repolish
+ proxy->repolish(qApp);
+ } else { // stylesheet set the first time
+ QStyleSheetStyle *newProxy = new QStyleSheetStyle(QApplicationPrivate::app_style);
+ QApplicationPrivate::app_style->setParent(newProxy);
+ setStyle(newProxy);
+ }
+}
+
+#endif // QT_NO_STYLE_STYLESHEET
+
+/*!
+ Returns the application's style object.
+
+ \sa setStyle(), QStyle
+*/
+QStyle *QApplication::style()
+{
+ if (QApplicationPrivate::app_style)
+ return QApplicationPrivate::app_style;
+ if (!qt_is_gui_used) {
+ Q_ASSERT(!"No style available in non-gui applications!");
+ return 0;
+ }
+
+ if (!QApplicationPrivate::app_style) {
+ // Compile-time search for default style
+ //
+ QString style;
+#ifdef QT_BUILD_INTERNAL
+ QString envStyle = QString::fromLocal8Bit(qgetenv("QT_STYLE_OVERRIDE"));
+#else
+ QString envStyle;
+#endif
+ if (!QApplicationPrivate::styleOverride.isEmpty()) {
+ style = QApplicationPrivate::styleOverride;
+ } else if (!envStyle.isEmpty()) {
+ style = envStyle;
+ } else {
+ style = QApplicationPrivate::desktopStyleKey();
+ }
+
+ QStyle *&app_style = QApplicationPrivate::app_style;
+ app_style = QStyleFactory::create(style);
+ if (!app_style) {
+ QStringList styles = QStyleFactory::keys();
+ for (int i = 0; i < styles.size(); ++i) {
+ if ((app_style = QStyleFactory::create(styles.at(i))))
+ break;
+ }
+ }
+ if (!app_style) {
+ Q_ASSERT(!"No styles available!");
+ return 0;
+ }
+ }
+ // take ownership of the style
+ QApplicationPrivate::app_style->setParent(qApp);
+
+ if (!QApplicationPrivate::sys_pal)
+ QApplicationPrivate::setSystemPalette(QApplicationPrivate::app_style->standardPalette());
+ if (QApplicationPrivate::set_pal) // repolish set palette with the new style
+ QApplication::setPalette(*QApplicationPrivate::set_pal);
+
+#ifndef QT_NO_STYLE_STYLESHEET
+ if (!QApplicationPrivate::styleSheet.isEmpty()) {
+ qApp->setStyleSheet(QApplicationPrivate::styleSheet);
+ } else
+#endif
+ QApplicationPrivate::app_style->polish(qApp);
+
+ return QApplicationPrivate::app_style;
+}
+
+/*!
+ Sets the application's GUI style to \a style. Ownership of the style object
+ is transferred to QApplication, so QApplication will delete the style
+ object on application exit or when a new style is set and the old style is
+ still the parent of the application object.
+
+ Example usage:
+ \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 1
+
+ When switching application styles, the color palette is set back to the
+ initial colors or the system defaults. This is necessary since certain
+ styles have to adapt the color palette to be fully style-guide compliant.
+
+ Setting the style before a palette has been se, i.e., before creating
+ QApplication, will cause the application to use QStyle::standardPalette()
+ for the palette.
+
+ \warning Qt style sheets are currently not supported for custom QStyle
+ subclasses. We plan to address this in some future release.
+
+ \sa style(), QStyle, setPalette(), desktopSettingsAware()
+*/
+void QApplication::setStyle(QStyle *style)
+{
+ if (!style || style == QApplicationPrivate::app_style)
+ return;
+
+ QWidgetList all = allWidgets();
+
+ // clean up the old style
+ if (QApplicationPrivate::app_style) {
+ if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {
+ for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) {
+ register QWidget *w = *it;
+ if (!(w->windowType() == Qt::Desktop) && // except desktop
+ w->testAttribute(Qt::WA_WState_Polished)) { // has been polished
+ QApplicationPrivate::app_style->unpolish(w);
+ }
+ }
+ }
+ QApplicationPrivate::app_style->unpolish(qApp);
+ }
+
+ QStyle *old = QApplicationPrivate::app_style; // save
+
+#ifndef QT_NO_STYLE_STYLESHEET
+ if (!QApplicationPrivate::styleSheet.isEmpty() && !qobject_cast<QStyleSheetStyle *>(style)) {
+ // we have a stylesheet already and a new style is being set
+ QStyleSheetStyle *newProxy = new QStyleSheetStyle(style);
+ style->setParent(newProxy);
+ QApplicationPrivate::app_style = newProxy;
+ } else
+#endif // QT_NO_STYLE_STYLESHEET
+ QApplicationPrivate::app_style = style;
+ QApplicationPrivate::app_style->setParent(qApp); // take ownership
+
+ // take care of possible palette requirements of certain gui
+ // styles. Do it before polishing the application since the style
+ // might call QApplication::setPalette() itself
+ if (QApplicationPrivate::set_pal) {
+ QApplication::setPalette(*QApplicationPrivate::set_pal);
+ } else if (QApplicationPrivate::sys_pal) {
+ QApplicationPrivate::initializeWidgetPaletteHash();
+ QApplicationPrivate::setPalette_helper(*QApplicationPrivate::sys_pal, /*className=*/0, /*clearWidgetPaletteHash=*/false);
+ } else if (!QApplicationPrivate::sys_pal) {
+ // Initialize the sys_pal if it hasn't happened yet...
+ QApplicationPrivate::setSystemPalette(QApplicationPrivate::app_style->standardPalette());
+ }
+
+ // initialize the application with the new style
+ QApplicationPrivate::app_style->polish(qApp);
+
+ // re-polish existing widgets if necessary
+ if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {
+ for (QWidgetList::ConstIterator it1 = all.constBegin(); it1 != all.constEnd(); ++it1) {
+ register QWidget *w = *it1;
+ if (w->windowType() != Qt::Desktop && w->testAttribute(Qt::WA_WState_Polished)) {
+ if (w->style() == QApplicationPrivate::app_style)
+ QApplicationPrivate::app_style->polish(w); // repolish
+#ifndef QT_NO_STYLE_STYLESHEET
+ else
+ w->setStyleSheet(w->styleSheet()); // touch
+#endif
+ }
+ }
+
+ for (QWidgetList::ConstIterator it2 = all.constBegin(); it2 != all.constEnd(); ++it2) {
+ register QWidget *w = *it2;
+ if (w->windowType() != Qt::Desktop && !w->testAttribute(Qt::WA_SetStyle)) {
+ QEvent e(QEvent::StyleChange);
+ QApplication::sendEvent(w, &e);
+#ifdef QT3_SUPPORT
+ if (old)
+ w->styleChange(*old);
+#endif
+ w->update();
+ }
+ }
+ }
+
+#ifndef QT_NO_STYLE_STYLESHEET
+ if (QStyleSheetStyle *oldProxy = qobject_cast<QStyleSheetStyle *>(old)) {
+ oldProxy->deref();
+ } else
+#endif
+ if (old && old->parent() == qApp) {
+ delete old;
+ }
+
+ if (QApplicationPrivate::focus_widget) {
+ QFocusEvent in(QEvent::FocusIn, Qt::OtherFocusReason);
+ QApplication::sendEvent(QApplicationPrivate::focus_widget->style(), &in);
+ QApplicationPrivate::focus_widget->update();
+ }
+}
+
+/*!
+ \overload
+
+ Requests a QStyle object for \a style from the QStyleFactory.
+
+ The string must be one of the QStyleFactory::keys(), typically one of
+ "windows", "motif", "cde", "plastique", "windowsxp", or "macintosh". Style
+ names are case insensitive.
+
+ Returns 0 if an unknown \a style is passed, otherwise the QStyle object
+ returned is set as the application's GUI style.
+
+ \warning To ensure that the application's style is set correctly, it is
+ best to call this function before the QApplication constructor, if
+ possible.
+*/
+QStyle* QApplication::setStyle(const QString& style)
+{
+ QStyle *s = QStyleFactory::create(style);
+ if (!s)
+ return 0;
+
+ setStyle(s);
+ return s;
+}
+
+/*!
+ Returns the color specification.
+
+ \sa QApplication::setColorSpec()
+*/
+
+int QApplication::colorSpec()
+{
+ return QApplicationPrivate::app_cspec;
+}
+
+/*!
+ Sets the color specification for the application to \a spec.
+
+ The color specification controls how the application allocates colors when
+ run on a display with a limited amount of colors, e.g. 8 bit / 256 color
+ displays.
+
+ The color specification must be set before you create the QApplication
+ object.
+
+ The options are:
+ \list
+ \o QApplication::NormalColor. This is the default color allocation
+ strategy. Use this option if your application uses buttons, menus,
+ texts and pixmaps with few colors. With this option, the
+ application uses system global colors. This works fine for most
+ applications under X11, but on the Windows platform, it may cause
+ dithering of non-standard colors.
+ \o QApplication::CustomColor. Use this option if your application
+ needs a small number of custom colors. On X11, this option is the
+ same as NormalColor. On Windows, Qt creates a Windows palette, and
+ allocates colors to it on demand.
+ \o QApplication::ManyColor. Use this option if your application is
+ very color hungry, e.g., it requires thousands of colors. \br
+ Under X11 the effect is:
+ \list
+ \o For 256-color displays which have at best a 256 color true
+ color visual, the default visual is used, and colors are
+ allocated from a color cube. The color cube is the 6x6x6
+ (216 color) "Web palette" (the red, green, and blue
+ components always have one of the following values: 0x00,
+ 0x33, 0x66, 0x99, 0xCC, or 0xFF), but the number of colors
+ can be changed by the \e -ncols option. The user can force
+ the application to use the true color visual with the
+ \l{QApplication::QApplication()}{-visual} option.
+ \o For 256-color displays which have a true color visual with
+ more than 256 colors, use that visual. Silicon Graphics X
+ servers this feature, for example. They provide an 8 bit
+ visual by default but can deliver true color when asked.
+ \endlist
+ On Windows, Qt creates a Windows palette, and fills it with a color
+ cube.
+ \endlist
+
+ Be aware that the CustomColor and ManyColor choices may lead to colormap
+ flashing: The foreground application gets (most) of the available colors,
+ while the background windows will look less attractive.
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 2
+
+ \sa colorSpec()
+*/
+
+void QApplication::setColorSpec(int spec)
+{
+ if (qApp)
+ qWarning("QApplication::setColorSpec: This function must be "
+ "called before the QApplication object is created");
+ QApplicationPrivate::app_cspec = spec;
+}
+
+/*!
+ \property QApplication::globalStrut
+ \brief the minimum size that any GUI element that the user can interact
+ with should have
+
+ For example, no button should be resized to be smaller than the global
+ strut size. The strut size should be considered when reimplementing GUI
+ controls that may be used on touch-screens or similar I/O devices.
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 3
+
+ By default, this property contains a QSize object with zero width and height.
+*/
+QSize QApplication::globalStrut()
+{
+ return QApplicationPrivate::app_strut;
+}
+
+void QApplication::setGlobalStrut(const QSize& strut)
+{
+ QApplicationPrivate::app_strut = strut;
+}
+
+
+/*!
+ \fn QPalette QApplication::palette(const QWidget* widget)
+ \overload
+
+ If a \a widget is passed, the default palette for the widget's class is
+ returned. This may or may not be the application palette. In most cases
+ there is no special palette for certain types of widgets, but one notable
+ exception is the popup menu under Windows, if the user has defined a
+ special background color for menus in the display settings.
+
+ \sa setPalette(), QWidget::palette()
+*/
+QPalette QApplication::palette(const QWidget* w)
+{
+ PaletteHash *hash = app_palettes();
+ if (w && hash && hash->size()) {
+ QHash<QByteArray, QPalette>::ConstIterator it = hash->constFind(w->metaObject()->className());
+ if (it != hash->constEnd())
+ return *it;
+ for (it = hash->constBegin(); it != hash->constEnd(); ++it) {
+ if (w->inherits(it.key()))
+ return it.value();
+ }
+ }
+ return palette();
+}
+
+/*!
+ \overload
+
+ Returns the palette for widgets of the given \a className.
+
+ \sa setPalette(), QWidget::palette()
+*/
+QPalette QApplication::palette(const char *className)
+{
+ if (!QApplicationPrivate::app_pal)
+ palette();
+ PaletteHash *hash = app_palettes();
+ if (className && hash && hash->size()) {
+ QHash<QByteArray, QPalette>::ConstIterator it = hash->constFind(className);
+ if (it != hash->constEnd())
+ return *it;
+ }
+ return *QApplicationPrivate::app_pal;
+}
+
+void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char* className, bool clearWidgetPaletteHash)
+{
+ QPalette pal = palette;
+
+ if (QApplicationPrivate::app_style)
+ QApplicationPrivate::app_style->polish(pal); // NB: non-const reference
+
+ bool all = false;
+ PaletteHash *hash = app_palettes();
+ if (!className) {
+ if (QApplicationPrivate::app_pal && pal.isCopyOf(*QApplicationPrivate::app_pal))
+ return;
+ if (!QApplicationPrivate::app_pal)
+ QApplicationPrivate::app_pal = new QPalette(pal);
+ else
+ *QApplicationPrivate::app_pal = pal;
+ if (hash && hash->size()) {
+ all = true;
+ if (clearWidgetPaletteHash)
+ hash->clear();
+ }
+ } else if (hash) {
+ hash->insert(className, pal);
+ }
+
+ if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {
+ // Send ApplicationPaletteChange to qApp itself, and to the widgets.
+ QEvent e(QEvent::ApplicationPaletteChange);
+ QApplication::sendEvent(QApplication::instance(), &e);
+
+ QWidgetList wids = QApplication::allWidgets();
+ for (QWidgetList::ConstIterator it = wids.constBegin(); it != wids.constEnd(); ++it) {
+ register QWidget *w = *it;
+ if (all || (!className && w->isWindow()) || w->inherits(className)) // matching class
+ QApplication::sendEvent(w, &e);
+ }
+
+ // Send to all scenes as well.
+#ifndef QT_NO_GRAPHICSVIEW
+ QList<QGraphicsScene *> &scenes = qApp->d_func()->scene_list;
+ for (QList<QGraphicsScene *>::ConstIterator it = scenes.constBegin();
+ it != scenes.constEnd(); ++it) {
+ QApplication::sendEvent(*it, &e);
+ }
+#endif //QT_NO_GRAPHICSVIEW
+ }
+ if (!className && (!QApplicationPrivate::sys_pal || !palette.isCopyOf(*QApplicationPrivate::sys_pal))) {
+ if (!QApplicationPrivate::set_pal)
+ QApplicationPrivate::set_pal = new QPalette(palette);
+ else
+ *QApplicationPrivate::set_pal = palette;
+ }
+}
+
+/*!
+ Changes the default application palette to \a palette.
+
+ If \a className is passed, the change applies only to widgets that inherit
+ \a className (as reported by QObject::inherits()). If \a className is left
+ 0, the change affects all widgets, thus overriding any previously set class
+ specific palettes.
+
+ The palette may be changed according to the current GUI style in
+ QStyle::polish().
+
+ \warning Do not use this function in conjunction with \l{Qt Style Sheets}.
+ When using style sheets, the palette of a widget can be customized using
+ the "color", "background-color", "selection-color",
+ "selection-background-color" and "alternate-background-color".
+
+ \note Some styles do not use the palette for all drawing, for instance, if
+ they make use of native theme engines. This is the case for the Windows XP,
+ Windows Vista, and Mac OS X styles.
+
+ \sa QWidget::setPalette(), palette(), QStyle::polish()
+*/
+
+void QApplication::setPalette(const QPalette &palette, const char* className)
+{
+ QApplicationPrivate::setPalette_helper(palette, className, /*clearWidgetPaletteHash=*/ true);
+}
+
+
+
+void QApplicationPrivate::setSystemPalette(const QPalette &pal)
+{
+ QPalette adjusted;
+
+#if 0
+ // adjust the system palette to avoid dithering
+ QColormap cmap = QColormap::instance();
+ if (cmap.depths() > 4 && cmap.depths() < 24) {
+ for (int g = 0; g < QPalette::NColorGroups; g++)
+ for (int i = 0; i < QPalette::NColorRoles; i++) {
+ QColor color = pal.color((QPalette::ColorGroup)g, (QPalette::ColorRole)i);
+ color = cmap.colorAt(cmap.pixel(color));
+ adjusted.setColor((QPalette::ColorGroup)g, (QPalette::ColorRole) i, color);
+ }
+ }
+#else
+ adjusted = pal;
+#endif
+
+ if (!sys_pal)
+ sys_pal = new QPalette(adjusted);
+ else
+ *sys_pal = adjusted;
+
+
+ if (!QApplicationPrivate::set_pal)
+ QApplication::setPalette(*sys_pal);
+}
+
+/*!
+ Returns the default application font.
+
+ \sa fontMetrics(), QWidget::font()
+*/
+QFont QApplication::font()
+{
+#ifndef Q_WS_QPA
+ QMutexLocker locker(applicationFontMutex());
+ if (!QApplicationPrivate::app_font)
+ QApplicationPrivate::app_font = new QFont(QLatin1String("Helvetica"));
+ return *QApplicationPrivate::app_font;
+#else
+ return QGuiApplication::font();
+#endif
+}
+
+/*!
+ \overload
+
+ Returns the default font for the \a widget.
+
+ \sa fontMetrics(), QWidget::setFont()
+*/
+
+QFont QApplication::font(const QWidget *widget)
+{
+ FontHash *hash = app_fonts();
+
+#ifdef Q_WS_MAC
+ // short circuit for small and mini controls
+ if (widget->testAttribute(Qt::WA_MacSmallSize)) {
+ return hash->value("QSmallFont");
+ } else if (widget->testAttribute(Qt::WA_MacMiniSize)) {
+ return hash->value("QMiniFont");
+ }
+#endif
+ if (widget && hash && hash->size()) {
+ QHash<QByteArray, QFont>::ConstIterator it =
+ hash->constFind(widget->metaObject()->className());
+ if (it != hash->constEnd())
+ return it.value();
+ for (it = hash->constBegin(); it != hash->constEnd(); ++it) {
+ if (widget->inherits(it.key()))
+ return it.value();
+ }
+ }
+ return font();
+}
+
+/*!
+ \overload
+
+ Returns the font for widgets of the given \a className.
+
+ \sa setFont(), QWidget::font()
+*/
+QFont QApplication::font(const char *className)
+{
+ FontHash *hash = app_fonts();
+ if (className && hash && hash->size()) {
+ QHash<QByteArray, QFont>::ConstIterator it = hash->constFind(className);
+ if (it != hash->constEnd())
+ return *it;
+ }
+ return font();
+}
+
+
+/*!
+ Changes the default application font to \a font. If \a className is passed,
+ the change applies only to classes that inherit \a className (as reported
+ by QObject::inherits()).
+
+ On application start-up, the default font depends on the window system. It
+ can vary depending on both the window system version and the locale. This
+ function lets you override the default font; but overriding may be a bad
+ idea because, for example, some locales need extra large fonts to support
+ their special characters.
+
+ \warning Do not use this function in conjunction with \l{Qt Style Sheets}.
+ The font of an application can be customized using the "font" style sheet
+ property. To set a bold font for all QPushButtons, set the application
+ styleSheet() as "QPushButton { font: bold }"
+
+ \sa font(), fontMetrics(), QWidget::setFont()
+*/
+
+void QApplication::setFont(const QFont &font, const char *className)
+{
+ bool all = false;
+ FontHash *hash = app_fonts();
+ if (!className) {
+#ifndef Q_WS_QPA
+ QMutexLocker locker(applicationFontMutex());
+ if (!QApplicationPrivate::app_font)
+ QApplicationPrivate::app_font = new QFont(font);
+ else
+ *QApplicationPrivate::app_font = font;
+#else
+ QGuiApplication::setFont(font);
+#endif
+ if (hash && hash->size()) {
+ all = true;
+ hash->clear();
+ }
+ } else if (hash) {
+ hash->insert(className, font);
+ }
+ if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {
+ // Send ApplicationFontChange to qApp itself, and to the widgets.
+ QEvent e(QEvent::ApplicationFontChange);
+ QApplication::sendEvent(QApplication::instance(), &e);
+
+ QWidgetList wids = QApplication::allWidgets();
+ for (QWidgetList::ConstIterator it = wids.constBegin(); it != wids.constEnd(); ++it) {
+ register QWidget *w = *it;
+ if (all || (!className && w->isWindow()) || w->inherits(className)) // matching class
+ sendEvent(w, &e);
+ }
+
+#ifndef QT_NO_GRAPHICSVIEW
+ // Send to all scenes as well.
+ QList<QGraphicsScene *> &scenes = qApp->d_func()->scene_list;
+ for (QList<QGraphicsScene *>::ConstIterator it = scenes.constBegin();
+ it != scenes.constEnd(); ++it) {
+ QApplication::sendEvent(*it, &e);
+ }
+#endif //QT_NO_GRAPHICSVIEW
+ }
+ if (!className && (!QApplicationPrivate::sys_font || !font.isCopyOf(*QApplicationPrivate::sys_font))) {
+ if (!QApplicationPrivate::set_font)
+ QApplicationPrivate::set_font = new QFont(font);
+ else
+ *QApplicationPrivate::set_font = font;
+ }
+}
+
+/*! \internal
+*/
+void QApplicationPrivate::setSystemFont(const QFont &font)
+{
+ if (!sys_font)
+ sys_font = new QFont(font);
+ else
+ *sys_font = font;
+
+ if (!QApplicationPrivate::set_font)
+ QApplication::setFont(*sys_font);
+}
+
+/*! \internal
+*/
+QString QApplicationPrivate::desktopStyleKey()
+{
+ return qt_guiPlatformPlugin()->styleName();
+}
+
+/*!
+ \property QApplication::windowIcon
+ \brief the default window icon
+
+ \sa QWidget::setWindowIcon(), {Setting the Application Icon}
+*/
+QIcon QApplication::windowIcon()
+{
+ return QApplicationPrivate::app_icon ? *QApplicationPrivate::app_icon : QIcon();
+}
+
+void QApplication::setWindowIcon(const QIcon &icon)
+{
+ if (!QApplicationPrivate::app_icon)
+ QApplicationPrivate::app_icon = new QIcon();
+ *QApplicationPrivate::app_icon = icon;
+ if (QApplicationPrivate::is_app_running && !QApplicationPrivate::is_app_closing) {
+#ifdef Q_WS_MAC
+ void qt_mac_set_app_icon(const QPixmap &); //qapplication_mac.cpp
+ QSize size = QApplicationPrivate::app_icon->actualSize(QSize(128, 128));
+ qt_mac_set_app_icon(QApplicationPrivate::app_icon->pixmap(size));
+#endif
+ QEvent e(QEvent::ApplicationWindowIconChange);
+ QWidgetList all = QApplication::allWidgets();
+ for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) {
+ register QWidget *w = *it;
+ if (w->isWindow())
+ sendEvent(w, &e);
+ }
+ }
+}
+
+/*!
+ Returns a list of the top-level widgets (windows) in the application.
+
+ \note Some of the top-level widgets may be hidden, for example a tooltip if
+ no tooltip is currently shown.
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 4
+
+ \sa allWidgets(), QWidget::isWindow(), QWidget::isHidden()
+*/
+QWidgetList QApplication::topLevelWidgets()
+{
+ QWidgetList list;
+ QWidgetList all = allWidgets();
+
+ for (QWidgetList::ConstIterator it = all.constBegin(); it != all.constEnd(); ++it) {
+ QWidget *w = *it;
+ if (w->isWindow() && w->windowType() != Qt::Desktop)
+ list.append(w);
+ }
+ return list;
+}
+
+/*!
+ Returns a list of all the widgets in the application.
+
+ The list is empty (QList::isEmpty()) if there are no widgets.
+
+ \note Some of the widgets may be hidden.
+
+ Example:
+ \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 5
+
+ \sa topLevelWidgets(), QWidget::isVisible()
+*/
+
+QWidgetList QApplication::allWidgets()
+{
+ if (QWidgetPrivate::allWidgets)
+ return QWidgetPrivate::allWidgets->toList();
+ return QWidgetList();
+}
+
+/*!
+ Returns the application widget that has the keyboard input focus, or 0 if
+ no widget in this application has the focus.
+
+ \sa QWidget::setFocus(), QWidget::hasFocus(), activeWindow(), focusChanged()
+*/
+
+QWidget *QApplication::focusWidget()
+{
+ return QApplicationPrivate::focus_widget;
+}
+
+void QApplicationPrivate::setFocusWidget(QWidget *focus, Qt::FocusReason reason)
+{
+#ifndef QT_NO_GRAPHICSVIEW
+ if (focus && focus->window()->graphicsProxyWidget())
+ return;
+#endif
+
+ hidden_focus_widget = 0;
+
+ if (focus != focus_widget) {
+ if (focus && focus->isHidden()) {
+ hidden_focus_widget = focus;
+ return;
+ }
+
+ if (focus && (reason == Qt::BacktabFocusReason || reason == Qt::TabFocusReason)
+ && qt_in_tab_key_event)
+ focus->window()->setAttribute(Qt::WA_KeyboardFocusChange);
+ else if (focus && reason == Qt::ShortcutFocusReason) {
+ focus->window()->setAttribute(Qt::WA_KeyboardFocusChange);
+ }
+ QWidget *prev = focus_widget;
+ focus_widget = focus;
+#ifndef QT_NO_IM
+ if (prev && ((reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason
+ && prev->testAttribute(Qt::WA_InputMethodEnabled))
+ // Do reset the input context, in case the new focus widget won't accept keyboard input
+ // or it is not created fully yet.
+ || (focus_widget && (!focus_widget->testAttribute(Qt::WA_InputMethodEnabled)
+ || !focus_widget->testAttribute(Qt::WA_WState_Created))))) {
+ QInputContext *qic = prev->inputContext();
+ if(qic) {
+ qic->reset();
+ qic->setFocusWidget(0);
+ }
+ }
+#endif //QT_NO_IM
+
+ if(focus_widget)
+ focus_widget->d_func()->setFocus_sys();
+
+ if (reason != Qt::NoFocusReason) {
+
+ //send events
+ if (prev) {
+#ifdef QT_KEYPAD_NAVIGATION
+ if (QApplication::keypadNavigationEnabled()) {
+ if (prev->hasEditFocus() && reason != Qt::PopupFocusReason
+#ifdef Q_OS_SYMBIAN
+ && reason != Qt::ActiveWindowFocusReason
+#endif
+ )
+ prev->setEditFocus(false);
+ }
+#endif
+#ifndef QT_NO_IM
+ if (focus) {
+ QInputContext *prevIc;
+ prevIc = prev->inputContext();
+ if (prevIc && prevIc != focus->inputContext()) {
+ QEvent closeSIPEvent(QEvent::CloseSoftwareInputPanel);
+ QApplication::sendEvent(prev, &closeSIPEvent);
+ }
+ }
+#endif
+ QFocusEvent out(QEvent::FocusOut, reason);
+ QPointer<QWidget> that = prev;
+ QApplication::sendEvent(prev, &out);
+ if (that)
+ QApplication::sendEvent(that->style(), &out);
+ }
+ if(focus && QApplicationPrivate::focus_widget == focus) {
+#ifndef QT_NO_IM
+ if (focus->testAttribute(Qt::WA_InputMethodEnabled)) {
+ QInputContext *qic = focus->inputContext();
+ if (qic && focus->testAttribute(Qt::WA_WState_Created)
+ && focus->isEnabled())
+ qic->setFocusWidget(focus);
+ }
+#endif //QT_NO_IM
+ QFocusEvent in(QEvent::FocusIn, reason);
+ QPointer<QWidget> that = focus;
+ QApplication::sendEvent(focus, &in);
+ if (that)
+ QApplication::sendEvent(that->style(), &in);
+ }
+ emit qApp->focusChanged(prev, focus_widget);
+ }
+ }
+}
+
+
+/*!
+ Returns the application top-level window that has the keyboard input focus,
+ or 0 if no application window has the focus. There might be an
+ activeWindow() even if there is no focusWidget(), for example if no widget
+ in that window accepts key events.
+
+ \sa QWidget::setFocus(), QWidget::hasFocus(), focusWidget()
+*/
+
+QWidget *QApplication::activeWindow()
+{
+ return QApplicationPrivate::active_window;
+}
+
+/*!
+ Returns display (screen) font metrics for the application font.
+
+ \sa font(), setFont(), QWidget::fontMetrics(), QPainter::fontMetrics()
+*/
+
+QFontMetrics QApplication::fontMetrics()
+{
+ return desktop()->fontMetrics();
+}
+
+
+/*!
+ Closes all top-level windows.
+
+ This function is particularly useful for applications with many top-level
+ windows. It could, for example, be connected to a \gui{Exit} entry in the
+ \gui{File} menu:
+
+ \snippet examples/mainwindows/mdi/mainwindow.cpp 0
+
+ The windows are closed in random order, until one window does not accept
+ the close event. The application quits when the last window was
+ successfully closed; this can be turned off by setting
+ \l quitOnLastWindowClosed to false.
+
+ \sa quitOnLastWindowClosed, lastWindowClosed(), QWidget::close(),
+ QWidget::closeEvent(), lastWindowClosed(), quit(), topLevelWidgets(),
+ QWidget::isWindow()
+*/
+void QApplication::closeAllWindows()
+{
+ bool did_close = true;
+ QWidget *w;
+ while ((w = activeModalWidget()) && did_close) {
+ if (!w->isVisible() || w->data->is_closing)
+ break;
+ did_close = w->close();
+ }
+ QWidgetList list = QApplication::topLevelWidgets();
+ for (int i = 0; did_close && i < list.size(); ++i) {
+ w = list.at(i);
+ if (w->isVisible()
+ && w->windowType() != Qt::Desktop
+ && !w->data->is_closing) {
+ did_close = w->close();
+ list = QApplication::topLevelWidgets();
+ i = -1;
+ }
+ }
+}
+
+/*!
+ Displays a simple message box about Qt. The message includes the version
+ number of Qt being used by the application.
+
+ This is useful for inclusion in the \gui Help menu of an application, as
+ shown in the \l{mainwindows/menus}{Menus} example.
+
+ This function is a convenience slot for QMessageBox::aboutQt().
+*/
+void QApplication::aboutQt()
+{
+#ifndef QT_NO_MESSAGEBOX
+ QMessageBox::aboutQt(
+#ifdef Q_WS_MAC
+ 0
+#else
+ activeWindow()
+#endif // Q_WS_MAC
+ );
+#endif // QT_NO_MESSAGEBOX
+}
+
+
+/*!
+ \fn void QApplication::lastWindowClosed()
+
+ This signal is emitted from QApplication::exec() when the last visible
+ primary window (i.e. window with no parent) with the Qt::WA_QuitOnClose
+ attribute set is closed.
+
+ By default,
+
+ \list
+ \o this attribute is set for all widgets except transient windows such
+ as splash screens, tool windows, and popup menus
+
+ \o QApplication implicitly quits when this signal is emitted.
+ \endlist
+
+ This feature can be turned off by setting \l quitOnLastWindowClosed to
+ false.
+
+ \sa QWidget::close()
+*/
+
+/*!
+ \since 4.1
+ \fn void QApplication::focusChanged(QWidget *old, QWidget *now)
+
+ This signal is emitted when the widget that has keyboard focus changed from
+ \a old to \a now, i.e., because the user pressed the tab-key, clicked into
+ a widget or changed the active window. Both \a old and \a now can be the
+ null-pointer.
+
+ The signal is emitted after both widget have been notified about the change
+ through QFocusEvent.
+
+ \sa QWidget::setFocus(), QWidget::clearFocus(), Qt::FocusReason
+*/
+
+
+#ifndef QT_NO_TRANSLATION
+#if defined(Q_WS_MAC)
+static const char *application_menu_strings[] = {
+ QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Services"),
+ QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide %1"),
+ QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Hide Others"),
+ QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Show All"),
+ QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Preferences..."),
+ QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","Quit %1"),
+ QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU","About %1")
+ };
+QString qt_mac_applicationmenu_string(int type)
+{
+ QString menuString = QString::fromLatin1(application_menu_strings[type]);
+ QString translated = qApp->translate("QMenuBar", application_menu_strings[type]);
+ if (translated != menuString)
+ return translated;
+ else
+ return qApp->translate("MAC_APPLICATION_MENU",
+ application_menu_strings[type]);
+}
+#endif
+#endif
+
+/*!\reimp
+
+*/
+bool QApplication::event(QEvent *e)
+{
+ Q_D(QApplication);
+ if(e->type() == QEvent::Close) {
+#if defined(Q_OS_SYMBIAN)
+ // In order to have proper application-exit effects on Symbian, certain
+ // native APIs have to be called _before_ closing/destroying the widgets.
+ bool effectStarted = qt_beginFullScreenEffect();
+#endif
+ QCloseEvent *ce = static_cast<QCloseEvent*>(e);
+ ce->accept();
+ closeAllWindows();
+
+ QWidgetList list = topLevelWidgets();
+ for (int i = 0; i < list.size(); ++i) {
+ QWidget *w = list.at(i);
+ if (w->isVisible() && !(w->windowType() == Qt::Desktop) && !(w->windowType() == Qt::Popup) &&
+ (!(w->windowType() == Qt::Dialog) || !w->parentWidget())) {
+ ce->ignore();
+ break;
+ }
+ }
+ if (ce->isAccepted()) {
+ return true;
+ } else {
+#if defined(Q_OS_SYMBIAN)
+ if (effectStarted)
+ qt_abortFullScreenEffect();
+#endif
+ }
+#ifndef Q_OS_WIN
+ } else if (e->type() == QEvent::LocaleChange) {
+ // on Windows the event propagation is taken care by the
+ // WM_SETTINGCHANGE event handler.
+ QWidgetList list = topLevelWidgets();
+ for (int i = 0; i < list.size(); ++i) {
+ QWidget *w = list.at(i);
+ if (!(w->windowType() == Qt::Desktop)) {
+ if (!w->testAttribute(Qt::WA_SetLocale))
+ w->d_func()->setLocale_helper(QLocale(), true);
+ }
+ }
+#endif
+ } else if (e->type() == QEvent::Timer) {
+ QTimerEvent *te = static_cast<QTimerEvent*>(e);
+ Q_ASSERT(te != 0);
+ if (te->timerId() == d->toolTipWakeUp.timerId()) {
+ d->toolTipWakeUp.stop();
+ if (d->toolTipWidget) {
+ QWidget *w = d->toolTipWidget->window();
+ // show tooltip if WA_AlwaysShowToolTips is set, or if
+ // any ancestor of d->toolTipWidget is the active
+ // window
+ bool showToolTip = w->testAttribute(Qt::WA_AlwaysShowToolTips);
+ while (w && !showToolTip) {
+ showToolTip = w->isActiveWindow();
+ w = w->parentWidget();
+ w = w ? w->window() : 0;
+ }
+ if (showToolTip) {
+ QHelpEvent e(QEvent::ToolTip, d->toolTipPos, d->toolTipGlobalPos);
+ QApplication::sendEvent(d->toolTipWidget, &e);
+ if (e.isAccepted())
+ d->toolTipFallAsleep.start(2000, this);
+ }
+ }
+ } else if (te->timerId() == d->toolTipFallAsleep.timerId()) {
+ d->toolTipFallAsleep.stop();
+ }
+ }
+ return QApplicationBase::event(e);
+
+ if(e->type() == QEvent::LanguageChange) {
+#if defined(QT_MAC_USE_COCOA)
+ qt_mac_post_retranslateAppMenu();
+#endif
+ QWidgetList list = topLevelWidgets();
+ for (int i = 0; i < list.size(); ++i) {
+ QWidget *w = list.at(i);
+ if (!(w->windowType() == Qt::Desktop))
+ postEvent(w, new QEvent(QEvent::LanguageChange));
+ }
+ }
+
+}
+#if !defined(Q_WS_X11)
+
+// The doc and X implementation of this function is in qapplication_x11.cpp
+
+void QApplication::syncX() {} // do nothing
+
+#endif
+
+void QApplicationPrivate::notifyLayoutDirectionChange()
+{
+ Q_Q(QApplication);
+ QWidgetList list = q->topLevelWidgets();
+ for (int i = 0; i < list.size(); ++i) {
+ QWidget *w = list.at(i);
+ QEvent ev(QEvent::ApplicationLayoutDirectionChange);
+ q->sendEvent(w, &ev);
+ }
+}
+
+
+/*!
+ \fn Qt::WindowsVersion QApplication::winVersion()
+
+ Use \l QSysInfo::WindowsVersion instead.
+*/
+
+/*!
+ \fn void QApplication::setActiveWindow(QWidget* active)
+
+ Sets the active window to the \a active widget in response to a system
+ event. The function is called from the platform specific event handlers.
+
+ \warning This function does \e not set the keyboard focus to the active
+ widget. Call QWidget::activateWindow() instead.
+
+ It sets the activeWindow() and focusWidget() attributes and sends proper
+ \l{QEvent::WindowActivate}{WindowActivate}/\l{QEvent::WindowDeactivate}
+ {WindowDeactivate} and \l{QEvent::FocusIn}{FocusIn}/\l{QEvent::FocusOut}
+ {FocusOut} events to all appropriate widgets. The window will then be
+ painted in active state (e.g. cursors in line edits will blink), and it
+ will have tool tips enabled.
+
+ \sa activeWindow(), QWidget::activateWindow()
+*/
+void QApplication::setActiveWindow(QWidget* act)
+{
+ QWidget* window = act?act->window():0;
+
+ if (QApplicationPrivate::active_window == window)
+ return;
+
+#ifndef QT_NO_GRAPHICSVIEW
+ if (window && window->graphicsProxyWidget()) {
+ // Activate the proxy's view->viewport() ?
+ return;
+ }
+#endif
+
+ QWidgetList toBeActivated;
+ QWidgetList toBeDeactivated;
+
+ if (QApplicationPrivate::active_window) {
+ if (style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, QApplicationPrivate::active_window)) {
+ QWidgetList list = topLevelWidgets();
+ for (int i = 0; i < list.size(); ++i) {
+ QWidget *w = list.at(i);
+ if (w->isVisible() && w->isActiveWindow())
+ toBeDeactivated.append(w);
+ }
+ } else {
+ toBeDeactivated.append(QApplicationPrivate::active_window);
+ }
+ }
+
+#if !defined(Q_WS_MAC)
+ QWidget *previousActiveWindow = QApplicationPrivate::active_window;
+#endif
+ QApplicationPrivate::active_window = window;
+
+ if (QApplicationPrivate::active_window) {
+ if (style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, QApplicationPrivate::active_window)) {
+ QWidgetList list = topLevelWidgets();
+ for (int i = 0; i < list.size(); ++i) {
+ QWidget *w = list.at(i);
+ if (w->isVisible() && w->isActiveWindow())
+ toBeActivated.append(w);
+ }
+ } else {
+ toBeActivated.append(QApplicationPrivate::active_window);
+ }
+
+ }
+
+ // first the activation/deactivation events
+ QEvent activationChange(QEvent::ActivationChange);
+ QEvent windowActivate(QEvent::WindowActivate);
+ QEvent windowDeactivate(QEvent::WindowDeactivate);
+
+#if !defined(Q_WS_MAC)
+ if (!previousActiveWindow) {
+ QEvent appActivate(QEvent::ApplicationActivate);
+ sendSpontaneousEvent(qApp, &appActivate);
+ }
+#endif
+
+ for (int i = 0; i < toBeActivated.size(); ++i) {
+ QWidget *w = toBeActivated.at(i);
+ sendSpontaneousEvent(w, &windowActivate);
+ sendSpontaneousEvent(w, &activationChange);
+ }
+
+#ifdef QT_MAC_USE_COCOA
+ // In case the user clicked on a child window, we need to
+ // reestablish the stacking order of the window so
+ // it pops in front of other child windows in cocoa:
+ qt_cocoaStackChildWindowOnTopOfOtherChildren(window);
+#endif
+
+ for(int i = 0; i < toBeDeactivated.size(); ++i) {
+ QWidget *w = toBeDeactivated.at(i);
+ sendSpontaneousEvent(w, &windowDeactivate);
+ sendSpontaneousEvent(w, &activationChange);
+ }
+
+#if !defined(Q_WS_MAC)
+ if (!QApplicationPrivate::active_window) {
+ QEvent appDeactivate(QEvent::ApplicationDeactivate);
+ sendSpontaneousEvent(qApp, &appDeactivate);
+ }
+#endif
+
+ if (QApplicationPrivate::popupWidgets == 0) { // !inPopupMode()
+ // then focus events
+ if (!QApplicationPrivate::active_window && QApplicationPrivate::focus_widget) {
+ QApplicationPrivate::setFocusWidget(0, Qt::ActiveWindowFocusReason);
+ } else if (QApplicationPrivate::active_window) {
+ QWidget *w = QApplicationPrivate::active_window->focusWidget();
+ if (w && w->isVisible() /*&& w->focusPolicy() != QWidget::NoFocus*/)
+ w->setFocus(Qt::ActiveWindowFocusReason);
+ else {
+ w = QApplicationPrivate::focusNextPrevChild_helper(QApplicationPrivate::active_window, true);
+ if (w) {
+ w->setFocus(Qt::ActiveWindowFocusReason);
+ } else {
+ // If the focus widget is not in the activate_window, clear the focus
+ w = QApplicationPrivate::focus_widget;
+ if (!w && QApplicationPrivate::active_window->focusPolicy() != Qt::NoFocus)
+ QApplicationPrivate::setFocusWidget(QApplicationPrivate::active_window, Qt::ActiveWindowFocusReason);
+ else if (!QApplicationPrivate::active_window->isAncestorOf(w))
+ QApplicationPrivate::setFocusWidget(0, Qt::ActiveWindowFocusReason);
+ }
+ }
+ }
+ }
+}
+
+/*!internal
+ * Helper function that returns the new focus widget, but does not set the focus reason.
+ * Returns 0 if a new focus widget could not be found.
+ * Shared with QGraphicsProxyWidgetPrivate::findFocusChild()
+*/
+QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool next)
+{
+ uint focus_flag = qt_tab_all_widgets ? Qt::TabFocus : Qt::StrongFocus;
+
+ QWidget *f = toplevel->focusWidget();
+ if (!f)
+ f = toplevel;
+
+ QWidget *w = f;
+ QWidget *test = f->d_func()->focus_next;
+ while (test && test != f) {
+ if ((test->focusPolicy() & focus_flag) == focus_flag
+ && !(test->d_func()->extra && test->d_func()->extra->focus_proxy)
+ && test->isVisibleTo(toplevel) && test->isEnabled()
+ && !(w->windowType() == Qt::SubWindow && !w->isAncestorOf(test))
+ && (toplevel->windowType() != Qt::SubWindow || toplevel->isAncestorOf(test))) {
+ w = test;
+ if (next)
+ break;
+ }
+ test = test->d_func()->focus_next;
+ }
+ if (w == f) {
+ if (qt_in_tab_key_event) {
+ w->window()->setAttribute(Qt::WA_KeyboardFocusChange);
+ w->update();
+ }
+ return 0;
+ }
+ return w;
+}
+
+/*!
+ \fn void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave)
+ \internal
+
+ Creates the proper Enter/Leave event when widget \a enter is entered and
+ widget \a leave is left.
+ */
+void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave) {
+#if 0
+ if (leave) {
+ QEvent e(QEvent::Leave);
+ QApplication::sendEvent(leave, & e);
+ }
+ if (enter) {
+ QEvent e(QEvent::Enter);
+ QApplication::sendEvent(enter, & e);
+ }
+ return;
+#endif
+
+ QWidget* w ;
+ if ((!enter && !leave) || (enter == leave))
+ return;
+#ifdef ALIEN_DEBUG
+ qDebug() << "QApplicationPrivate::dispatchEnterLeave, ENTER:" << enter << "LEAVE:" << leave;
+#endif
+ QWidgetList leaveList;
+ QWidgetList enterList;
+
+ bool sameWindow = leave && enter && leave->window() == enter->window();
+ if (leave && !sameWindow) {
+ w = leave;
+ do {
+ leaveList.append(w);
+ } while (!w->isWindow() && (w = w->parentWidget()));
+ }
+ if (enter && !sameWindow) {
+ w = enter;
+ do {
+ enterList.prepend(w);
+ } while (!w->isWindow() && (w = w->parentWidget()));
+ }
+ if (sameWindow) {
+ int enterDepth = 0;
+ int leaveDepth = 0;
+ w = enter;
+ while (!w->isWindow() && (w = w->parentWidget()))
+ enterDepth++;
+ w = leave;
+ while (!w->isWindow() && (w = w->parentWidget()))
+ leaveDepth++;
+ QWidget* wenter = enter;
+ QWidget* wleave = leave;
+ while (enterDepth > leaveDepth) {
+ wenter = wenter->parentWidget();
+ enterDepth--;
+ }
+ while (leaveDepth > enterDepth) {
+ wleave = wleave->parentWidget();
+ leaveDepth--;
+ }
+ while (!wenter->isWindow() && wenter != wleave) {
+ wenter = wenter->parentWidget();
+ wleave = wleave->parentWidget();
+ }
+
+ w = leave;
+ while (w != wleave) {
+ leaveList.append(w);
+ w = w->parentWidget();
+ }
+ w = enter;
+ while (w != wenter) {
+ enterList.prepend(w);
+ w = w->parentWidget();
+ }
+ }
+
+ QEvent leaveEvent(QEvent::Leave);
+ for (int i = 0; i < leaveList.size(); ++i) {
+ w = leaveList.at(i);
+ if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) {
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_MAC)
+ if (leaveAfterRelease == w)
+ leaveAfterRelease = 0;
+#endif
+ QApplication::sendEvent(w, &leaveEvent);
+ if (w->testAttribute(Qt::WA_Hover) &&
+ (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) {
+ Q_ASSERT(instance());
+ QHoverEvent he(QEvent::HoverLeave, QPoint(-1, -1), w->mapFromGlobal(QApplicationPrivate::instance()->hoverGlobalPos));
+ qApp->d_func()->notify_helper(w, &he);
+ }
+ }
+ }
+ QPoint posEnter = QCursor::pos();
+ QEvent enterEvent(QEvent::Enter);
+ for (int i = 0; i < enterList.size(); ++i) {
+ w = enterList.at(i);
+ if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, 0)) {
+ QApplication::sendEvent(w, &enterEvent);
+ if (w->testAttribute(Qt::WA_Hover) &&
+ (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) {
+ QHoverEvent he(QEvent::HoverEnter, w->mapFromGlobal(posEnter), QPoint(-1, -1));
+ qApp->d_func()->notify_helper(w, &he);
+ }
+ }
+ }
+
+#ifndef QT_NO_CURSOR
+ // Update cursor for alien/graphics widgets.
+
+ const bool enterOnAlien = (enter && (isAlien(enter) || enter->testAttribute(Qt::WA_DontShowOnScreen)));
+#if defined(Q_WS_X11) || defined(Q_WS_QPA)
+ //Whenever we leave an alien widget on X11, we need to reset its nativeParentWidget()'s cursor.
+ // This is not required on Windows as the cursor is reset on every single mouse move.
+ QWidget *parentOfLeavingCursor = 0;
+ for (int i = 0; i < leaveList.size(); ++i) {
+ w = leaveList.at(i);
+ if (!isAlien(w))
+ break;
+ if (w->testAttribute(Qt::WA_SetCursor)) {
+ QWidget *parent = w->parentWidget();
+ while (parent && parent->d_func()->data.in_destructor)
+ parent = parent->parentWidget();
+ parentOfLeavingCursor = parent;
+ //continue looping, we need to find the downest alien widget with a cursor.
+ // (downest on the screen)
+ }
+ }
+ //check that we will not call qt_x11_enforce_cursor twice with the same native widget
+ if (parentOfLeavingCursor && (!enterOnAlien
+ || parentOfLeavingCursor->effectiveWinId() != enter->effectiveWinId())) {
+#ifndef QT_NO_GRAPHICSVIEW
+ if (!parentOfLeavingCursor->window()->graphicsProxyWidget())
+#endif
+ {
+#if defined(Q_WS_X11)
+ qt_x11_enforce_cursor(parentOfLeavingCursor,true);
+#elif defined(Q_WS_QPA)
+ if (enter == QApplication::desktop()) {
+ qt_qpa_set_cursor(enter, true);
+ } else {
+ qt_qpa_set_cursor(parentOfLeavingCursor, true);
+ }
+#endif
+ }
+ }
+#endif
+ if (enterOnAlien) {
+ QWidget *cursorWidget = enter;
+ while (!cursorWidget->isWindow() && !cursorWidget->isEnabled())
+ cursorWidget = cursorWidget->parentWidget();
+
+ if (!cursorWidget)
+ return;
+
+#ifndef QT_NO_GRAPHICSVIEW
+ if (cursorWidget->window()->graphicsProxyWidget()) {
+ QWidgetPrivate::nearestGraphicsProxyWidget(cursorWidget)->setCursor(cursorWidget->cursor());
+ } else
+#endif
+ {
+#if defined(Q_WS_WIN)
+ qt_win_set_cursor(cursorWidget, true);
+#elif defined(Q_WS_X11)
+ qt_x11_enforce_cursor(cursorWidget, true);
+#elif defined(Q_OS_SYMBIAN)
+ qt_symbian_set_cursor(cursorWidget, true);
+#elif defined(Q_WS_QPA)
+ qt_qpa_set_cursor(cursorWidget, true);
+#endif
+ }
+ }
+#endif
+}
+
+/* exported for the benefit of testing tools */
+Q_GUI_EXPORT bool qt_tryModalHelper(QWidget *widget, QWidget **rettop)
+{
+ return QApplicationPrivate::tryModalHelper(widget, rettop);
+}
+
+/*! \internal
+ Returns true if \a widget is blocked by a modal window.
+ */
+bool QApplicationPrivate::isBlockedByModal(QWidget *widget)
+{
+ widget = widget->window();
+ if (!modalState())
+ return false;
+ if (QApplication::activePopupWidget() == widget)
+ return false;
+
+#if 0
+ for (int i = 0; i < qt_modal_stack->size(); ++i) {
+ QWidget *modalWidget = qt_modal_stack->at(i);
+
+ {
+ // check if the active modal widget is our widget or a parent of our widget
+ QWidget *w = widget;
+ while (w) {
+ if (w == modalWidget)
+ return false;
+ w = w->parentWidget();
+ }
+#ifdef Q_WS_WIN
+ if ((widget->testAttribute(Qt::WA_WState_Created) || widget->data->winid)
+ && (modalWidget->testAttribute(Qt::WA_WState_Created) || modalWidget->data->winid)
+ && IsChild(modalWidget->data->winid, widget->data->winid))
+ return false;
+#endif
+ }
+
+ Qt::WindowModality windowModality = modalWidget->windowModality();
+ if (windowModality == Qt::NonModal) {
+ // determine the modality type if it hasn't been set on the
+ // modalWidget, this normally happens when waiting for a
+ // native dialog. use WindowModal if we are the child of a
+ // group leader; otherwise use ApplicationModal.
+ QWidget *m = modalWidget;
+ while (m && !m->testAttribute(Qt::WA_GroupLeader)) {
+ m = m->parentWidget();
+ if (m)
+ m = m->window();
+ }
+ windowModality = (m && m->testAttribute(Qt::WA_GroupLeader))
+ ? Qt::WindowModal
+ : Qt::ApplicationModal;
+ }
+
+ switch (windowModality) {
+ case Qt::ApplicationModal:
+ {
+ QWidget *groupLeaderForWidget = widget;
+ while (groupLeaderForWidget && !groupLeaderForWidget->testAttribute(Qt::WA_GroupLeader))
+ groupLeaderForWidget = groupLeaderForWidget->parentWidget();
+
+ if (groupLeaderForWidget) {
+ // if \a widget has WA_GroupLeader, it can only be blocked by ApplicationModal children
+ QWidget *m = modalWidget;
+ while (m && m != groupLeaderForWidget && !m->testAttribute(Qt::WA_GroupLeader))
+ m = m->parentWidget();
+ if (m == groupLeaderForWidget)
+ return true;
+ } else if (modalWidget != widget) {
+ return true;
+ }
+ break;
+ }
+ case Qt::WindowModal:
+ {
+ QWidget *w = widget;
+ do {
+ QWidget *m = modalWidget;
+ do {
+ if (m == w)
+ return true;
+ m = m->parentWidget();
+ if (m)
+ m = m->window();
+ } while (m);
+ w = w->parentWidget();
+ if (w)
+ w = w->window();
+ } while (w);
+ break;
+ }
+ default:
+ Q_ASSERT_X(false, "QApplication", "internal error, a modal widget cannot be modeless");
+ break;
+ }
+ }
+#endif
+ return false;
+}
+
+/*!\internal
+ */
+void QApplicationPrivate::enterModal(QWidget *widget)
+{
+ QSet<QWidget*> blocked;
+ QList<QWidget*> windows = QApplication::topLevelWidgets();
+ for (int i = 0; i < windows.count(); ++i) {
+ QWidget *window = windows.at(i);
+ if (window->windowType() != Qt::Tool && isBlockedByModal(window))
+ blocked.insert(window);
+ }
+
+ enterModal_sys(widget);
+
+ windows = QApplication::topLevelWidgets();
+ QEvent e(QEvent::WindowBlocked);
+ for (int i = 0; i < windows.count(); ++i) {
+ QWidget *window = windows.at(i);
+ if (!blocked.contains(window) && window->windowType() != Qt::Tool && isBlockedByModal(window))
+ QApplication::sendEvent(window, &e);
+ }
+}
+
+/*!\internal
+ */
+void QApplicationPrivate::leaveModal(QWidget *widget)
+{
+ QSet<QWidget*> blocked;
+ QList<QWidget*> windows = QApplication::topLevelWidgets();
+ for (int i = 0; i < windows.count(); ++i) {
+ QWidget *window = windows.at(i);
+ if (window->windowType() != Qt::Tool && isBlockedByModal(window))
+ blocked.insert(window);
+ }
+
+ leaveModal_sys(widget);
+
+ windows = QApplication::topLevelWidgets();
+ QEvent e(QEvent::WindowUnblocked);
+ for (int i = 0; i < windows.count(); ++i) {
+ QWidget *window = windows.at(i);
+ if(blocked.contains(window) && window->windowType() != Qt::Tool && !isBlockedByModal(window))
+ QApplication::sendEvent(window, &e);
+ }
+}
+
+
+
+/*!\internal
+
+ Called from qapplication_\e{platform}.cpp, returns true
+ if the widget should accept the event.
+ */
+bool QApplicationPrivate::tryModalHelper(QWidget *widget, QWidget **rettop)
+{
+ QWidget *top = QApplication::activeModalWidget();
+ if (rettop)
+ *rettop = top;
+
+ // the active popup widget always gets the input event
+ if (QApplication::activePopupWidget())
+ return true;
+
+#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
+ top = QApplicationPrivate::tryModalHelper_sys(top);
+ if (rettop)
+ *rettop = top;
+#endif
+
+ return !isBlockedByModal(widget->window());
+}
+
+/*
+ \internal
+*/
+QWidget *QApplicationPrivate::pickMouseReceiver(QWidget *candidate, const QPoint &globalPos,
+ QPoint &pos, QEvent::Type type,
+ Qt::MouseButtons buttons, QWidget *buttonDown,
+ QWidget *alienWidget)
+{
+ Q_ASSERT(candidate);
+
+ QWidget *mouseGrabber = QWidget::mouseGrabber();
+ if (((type == QEvent::MouseMove && buttons) || (type == QEvent::MouseButtonRelease))
+ && !buttonDown && !mouseGrabber) {
+ return 0;
+ }
+
+ if (alienWidget && alienWidget->internalWinId())
+ alienWidget = 0;
+
+ QWidget *receiver = candidate;
+
+ if (!mouseGrabber)
+ mouseGrabber = (buttonDown && !isBlockedByModal(buttonDown)) ? buttonDown : alienWidget;
+
+ if (mouseGrabber && mouseGrabber != candidate) {
+ receiver = mouseGrabber;
+ pos = receiver->mapFromGlobal(globalPos);
+#ifdef ALIEN_DEBUG
+ qDebug() << " ** receiver adjusted to:" << receiver << "pos:" << pos;
+#endif
+ }
+
+ return receiver;
+
+}
+
+/*
+ \internal
+*/
+bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event,
+ QWidget *alienWidget, QWidget *nativeWidget,
+ QWidget **buttonDown, QPointer<QWidget> &lastMouseReceiver,
+ bool spontaneous)
+{
+ Q_ASSERT(receiver);
+ Q_ASSERT(event);
+ Q_ASSERT(nativeWidget);
+ Q_ASSERT(buttonDown);
+
+ if (alienWidget && !isAlien(alienWidget))
+ alienWidget = 0;
+
+ QPointer<QWidget> receiverGuard = receiver;
+ QPointer<QWidget> nativeGuard = nativeWidget;
+ QPointer<QWidget> alienGuard = alienWidget;
+ QPointer<QWidget> activePopupWidget = QApplication::activePopupWidget();
+
+ const bool graphicsWidget = nativeWidget->testAttribute(Qt::WA_DontShowOnScreen);
+
+ if (*buttonDown) {
+ if (!graphicsWidget) {
+ // Register the widget that shall receive a leave event
+ // after the last button is released.
+ if ((alienWidget || !receiver->internalWinId()) && !leaveAfterRelease && !QWidget::mouseGrabber())
+ leaveAfterRelease = *buttonDown;
+ if (event->type() == QEvent::MouseButtonRelease && !event->buttons())
+ *buttonDown = 0;
+ }
+ } else if (lastMouseReceiver) {
+ // Dispatch enter/leave if we move:
+ // 1) from an alien widget to another alien widget or
+ // from a native widget to an alien widget (first OR case)
+ // 2) from an alien widget to a native widget (second OR case)
+ if ((alienWidget && alienWidget != lastMouseReceiver)
+ || (isAlien(lastMouseReceiver) && !alienWidget)) {
+ if (activePopupWidget) {
+ if (!QWidget::mouseGrabber())
+ dispatchEnterLeave(alienWidget ? alienWidget : nativeWidget, lastMouseReceiver);
+ } else {
+ dispatchEnterLeave(receiver, lastMouseReceiver);
+ }
+
+ }
+ }
+
+#ifdef ALIEN_DEBUG
+ qDebug() << "QApplicationPrivate::sendMouseEvent: receiver:" << receiver
+ << "pos:" << event->pos() << "alien" << alienWidget << "button down"
+ << *buttonDown << "last" << lastMouseReceiver << "leave after release"
+ << leaveAfterRelease;
+#endif
+
+ // We need this quard in case someone opens a modal dialog / popup. If that's the case
+ // leaveAfterRelease is set to null, but we shall not update lastMouseReceiver.
+ const bool wasLeaveAfterRelease = leaveAfterRelease != 0;
+ bool result;
+ if (spontaneous)
+ result = QApplication::sendSpontaneousEvent(receiver, event);
+ else
+ result = QApplication::sendEvent(receiver, event);
+
+ if (!graphicsWidget && leaveAfterRelease && event->type() == QEvent::MouseButtonRelease
+ && !event->buttons() && QWidget::mouseGrabber() != leaveAfterRelease) {
+ // Dispatch enter/leave if:
+ // 1) the mouse grabber is an alien widget
+ // 2) the button is released on an alien widget
+ QWidget *enter = 0;
+ if (nativeGuard)
+ enter = alienGuard ? alienWidget : nativeWidget;
+ else // The receiver is typically deleted on mouse release with drag'n'drop.
+ enter = QApplication::widgetAt(event->globalPos());
+ dispatchEnterLeave(enter, leaveAfterRelease);
+ leaveAfterRelease = 0;
+ lastMouseReceiver = enter;
+ } else if (!wasLeaveAfterRelease) {
+ if (activePopupWidget) {
+ if (!QWidget::mouseGrabber())
+ lastMouseReceiver = alienGuard ? alienWidget : (nativeGuard ? nativeWidget : 0);
+ } else {
+ lastMouseReceiver = receiverGuard ? receiver : QApplication::widgetAt(event->globalPos());
+ }
+ }
+
+ return result;
+}
+
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_QPA)
+/*
+ This function should only be called when the widget changes visibility, i.e.
+ when the \a widget is shown, hidden or deleted. This function does nothing
+ if the widget is a top-level or native, i.e. not an alien widget. In that
+ case enter/leave events are genereated by the underlying windowing system.
+*/
+extern QPointer<QWidget> qt_last_mouse_receiver;
+extern QWidget *qt_button_down;
+void QApplicationPrivate::sendSyntheticEnterLeave(QWidget *widget)
+{
+#ifndef QT_NO_CURSOR
+#if defined(Q_WS_QWS) || defined(Q_WS_QPA)
+ if (!widget || widget->isWindow())
+ return;
+#else
+ if (!widget || widget->internalWinId() || widget->isWindow())
+ return;
+#endif
+ const bool widgetInShow = widget->isVisible() && !widget->data->in_destructor;
+ if (!widgetInShow && widget != qt_last_mouse_receiver)
+ return; // Widget was not under the cursor when it was hidden/deleted.
+
+ if (widgetInShow && widget->parentWidget()->data->in_show)
+ return; // Ingore recursive show.
+
+ QWidget *mouseGrabber = QWidget::mouseGrabber();
+ if (mouseGrabber && mouseGrabber != widget)
+ return; // Someone else has the grab; enter/leave should not occur.
+
+ QWidget *tlw = widget->window();
+ if (tlw->data->in_destructor || tlw->data->is_closing)
+ return; // Closing down the business.
+
+ if (widgetInShow && (!qt_last_mouse_receiver || qt_last_mouse_receiver->window() != tlw))
+ return; // Mouse cursor not inside the widget's top-level.
+
+ const QPoint globalPos(QCursor::pos());
+ QPoint pos = tlw->mapFromGlobal(globalPos);
+
+ // Find the current widget under the mouse. If this function was called from
+ // the widget's destructor, we have to make sure childAt() doesn't take into
+ // account widgets that are about to be destructed.
+ QWidget *widgetUnderCursor = tlw->d_func()->childAt_helper(pos, widget->data->in_destructor);
+ if (!widgetUnderCursor)
+ widgetUnderCursor = tlw;
+ else
+ pos = widgetUnderCursor->mapFrom(tlw, pos);
+
+ if (widgetInShow && widgetUnderCursor != widget && !widget->isAncestorOf(widgetUnderCursor))
+ return; // Mouse cursor not inside the widget or any of its children.
+
+ if (widget->data->in_destructor && qt_button_down == widget)
+ qt_button_down = 0;
+
+ // Send enter/leave events followed by a mouse move on the entered widget.
+ QMouseEvent e(QEvent::MouseMove, pos, globalPos, Qt::NoButton, Qt::NoButton, Qt::NoModifier);
+ sendMouseEvent(widgetUnderCursor, &e, widgetUnderCursor, tlw, &qt_button_down, qt_last_mouse_receiver);
+#endif // QT_NO_CURSOR
+}
+#endif // Q_WS_WIN || Q_WS_X11 || Q_WS_MAC
+
+/*!
+ Returns the desktop widget (also called the root window).
+
+ The desktop may be composed of multiple screens, so it would be incorrect,
+ for example, to attempt to \e center some widget in the desktop's geometry.
+ QDesktopWidget has various functions for obtaining useful geometries upon
+ the desktop, such as QDesktopWidget::screenGeometry() and
+ QDesktopWidget::availableGeometry().
+
+ On X11, it is also possible to draw on the desktop.
+*/
+QDesktopWidget *QApplication::desktop()
+{
+ if (!qt_desktopWidget || // not created yet
+ !(qt_desktopWidget->windowType() == Qt::Desktop)) { // reparented away
+ qt_desktopWidget = new QDesktopWidget();
+ }
+ return qt_desktopWidget;
+}
+
+#if !defined(Q_WS_QPA) && !defined(QT_NO_CLIPBOARD)
+/*!
+ Returns a pointer to the application global clipboard.
+
+ \note The QApplication object should already be constructed before
+ accessing the clipboard.
+*/
+QClipboard *QApplication::clipboard()
+{
+ if (qt_clipboard == 0) {
+ if (!qApp) {
+ qWarning("QApplication: Must construct a QApplication before accessing a QClipboard");
+ return 0;
+ }
+ qt_clipboard = new QClipboard(0);
+ }
+ return qt_clipboard;
+}
+#endif // Q_WS_QPA && QT_NO_CLIPBOARD
+/*!
+ Sets whether Qt should use the system's standard colors, fonts, etc., to
+ \a on. By default, this is true.
+
+ This function must be called before creating the QApplication object, like
+ this:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 6
+
+ \sa desktopSettingsAware()
+*/
+void QApplication::setDesktopSettingsAware(bool on)
+{
+ QApplicationPrivate::obey_desktop_settings = on;
+}
+
+/*!
+ Returns true if Qt is set to use the system's standard colors, fonts, etc.;
+ otherwise returns false. The default is true.
+
+ \sa setDesktopSettingsAware()
+*/
+bool QApplication::desktopSettingsAware()
+{
+ return QApplicationPrivate::obey_desktop_settings;
+}
+
+/*!
+ Returns the current state of the modifier keys on the keyboard. The current
+ state is updated sychronously as the event queue is emptied of events that
+ will spontaneously change the keyboard state (QEvent::KeyPress and
+ QEvent::KeyRelease events).
+
+ It should be noted this may not reflect the actual keys held on the input
+ device at the time of calling but rather the modifiers as last reported in
+ one of the above events. If no keys are being held Qt::NoModifier is
+ returned.
+
+ \sa mouseButtons()
+*/
+
+Qt::KeyboardModifiers QApplication::keyboardModifiers()
+{
+ return QApplicationPrivate::modifier_buttons;
+}
+
+/*!
+ Returns the current state of the buttons on the mouse. The current state is
+ updated syncronously as the event queue is emptied of events that will
+ spontaneously change the mouse state (QEvent::MouseButtonPress and
+ QEvent::MouseButtonRelease events).
+
+ It should be noted this may not reflect the actual buttons held on the
+ input device at the time of calling but rather the mouse buttons as last
+ reported in one of the above events. If no mouse buttons are being held
+ Qt::NoButton is returned.
+
+ \sa keyboardModifiers()
+*/
+
+Qt::MouseButtons QApplication::mouseButtons()
+{
+ return QApplicationPrivate::mouse_buttons;
+}
+
+/*!
+ \fn bool QApplication::isSessionRestored() const
+
+ Returns true if the application has been restored from an earlier
+ \l{Session Management}{session}; otherwise returns false.
+
+ \sa sessionId(), commitData(), saveState()
+*/
+
+
+/*!
+ \fn QString QApplication::sessionId() const
+
+ Returns the current \l{Session Management}{session's} identifier.
+
+ If the application has been restored from an earlier session, this
+ identifier is the same as it was in that previous session. The session
+ identifier is guaranteed to be unique both for different applications
+ and for different instances of the same application.
+
+ \sa isSessionRestored(), sessionKey(), commitData(), saveState()
+*/
+
+/*!
+ \fn QString QApplication::sessionKey() const
+
+ Returns the session key in the current \l{Session Management}{session}.
+
+ If the application has been restored from an earlier session, this key is
+ the same as it was when the previous session ended.
+
+ The session key changes with every call of commitData() or saveState().
+
+ \sa isSessionRestored(), sessionId(), commitData(), saveState()
+*/
+#ifndef QT_NO_SESSIONMANAGER
+bool QApplication::isSessionRestored() const
+{
+ Q_D(const QApplication);
+ return d->is_session_restored;
+}
+
+QString QApplication::sessionId() const
+{
+ Q_D(const QApplication);
+ return d->session_id;
+}
+
+QString QApplication::sessionKey() const
+{
+ Q_D(const QApplication);
+ return d->session_key;
+}
+#endif
+
+
+
+/*!
+ \since 4.2
+ \fn void QApplication::commitDataRequest(QSessionManager &manager)
+
+ This signal deals with \l{Session Management}{session management}. It is
+ emitted when the QSessionManager wants the application to commit all its
+ data.
+
+ Usually this means saving all open files, after getting permission from
+ the user. Furthermore you may want to provide a means by which the user
+ can cancel the shutdown.
+
+ You should not exit the application within this signal. Instead,
+ the session manager may or may not do this afterwards, depending on the
+ context.
+
+ \warning Within this signal, no user interaction is possible, \e
+ unless you ask the \a manager for explicit permission. See
+ QSessionManager::allowsInteraction() and
+ QSessionManager::allowsErrorInteraction() for details and example
+ usage.
+
+ \note You should use Qt::DirectConnection when connecting to this signal.
+
+ \sa isSessionRestored(), sessionId(), saveState(), {Session Management}
+*/
+
+/*!
+ This function deals with \l{Session Management}{session management}. It is
+ invoked when the QSessionManager wants the application to commit all its
+ data.
+
+ Usually this means saving all open files, after getting permission from the
+ user. Furthermore you may want to provide a means by which the user can
+ cancel the shutdown.
+
+ You should not exit the application within this function. Instead, the
+ session manager may or may not do this afterwards, depending on the
+ context.
+
+ \warning Within this function, no user interaction is possible, \e
+ unless you ask the \a manager for explicit permission. See
+ QSessionManager::allowsInteraction() and
+ QSessionManager::allowsErrorInteraction() for details and example
+ usage.
+
+ The default implementation requests interaction and sends a close event to
+ all visible top-level widgets. If any event was rejected, the shutdown is
+ canceled.
+
+ \sa isSessionRestored(), sessionId(), saveState(), {Session Management}
+*/
+#ifndef QT_NO_SESSIONMANAGER
+void QApplication::commitData(QSessionManager& manager )
+{
+ emit commitDataRequest(manager);
+ if (manager.allowsInteraction()) {
+ QWidgetList done;
+ QWidgetList list = QApplication::topLevelWidgets();
+ bool cancelled = false;
+ for (int i = 0; !cancelled && i < list.size(); ++i) {
+ QWidget* w = list.at(i);
+ if (w->isVisible() && !done.contains(w)) {
+ cancelled = !w->close();
+ if (!cancelled)
+ done.append(w);
+ list = QApplication::topLevelWidgets();
+ i = -1;
+ }
+ }
+ if (cancelled)
+ manager.cancel();
+ }
+}
+
+/*!
+ \since 4.2
+ \fn void QApplication::saveStateRequest(QSessionManager &manager)
+
+ This signal deals with \l{Session Management}{session management}. It is
+ invoked when the \l{QSessionManager}{session manager} wants the application
+ to preserve its state for a future session.
+
+ For example, a text editor would create a temporary file that includes the
+ current contents of its edit buffers, the location of the cursor and other
+ aspects of the current editing session.
+
+ You should never exit the application within this signal. Instead, the
+ session manager may or may not do this afterwards, depending on the
+ context. Futhermore, most session managers will very likely request a saved
+ state immediately after the application has been started. This permits the
+ session manager to learn about the application's restart policy.
+
+ \warning Within this function, no user interaction is possible, \e
+ unless you ask the \a manager for explicit permission. See
+ QSessionManager::allowsInteraction() and
+ QSessionManager::allowsErrorInteraction() for details.
+
+ \note You should use Qt::DirectConnection when connecting to this signal.
+
+ \sa isSessionRestored(), sessionId(), commitData(), {Session Management}
+*/
+
+/*!
+ This function deals with \l{Session Management}{session management}. It is
+ invoked when the \l{QSessionManager}{session manager} wants the application
+ to preserve its state for a future session.
+
+ For example, a text editor would create a temporary file that includes the
+ current contents of its edit buffers, the location of the cursor and other
+ aspects of the current editing session.
+
+ You should never exit the application within this function. Instead, the
+ session manager may or may not do this afterwards, depending on the
+ context. Futhermore, most session managers will very likely request a saved
+ state immediately after the application has been started. This permits the
+ session manager to learn about the application's restart policy.
+
+ \warning Within this function, no user interaction is possible, \e
+ unless you ask the \a manager for explicit permission. See
+ QSessionManager::allowsInteraction() and
+ QSessionManager::allowsErrorInteraction() for details.
+
+ \sa isSessionRestored(), sessionId(), commitData(), {Session Management}
+*/
+
+void QApplication::saveState(QSessionManager &manager)
+{
+ emit saveStateRequest(manager);
+}
+#endif //QT_NO_SESSIONMANAGER
+/*
+ Sets the time after which a drag should start to \a ms ms.
+
+ \sa startDragTime()
+*/
+
+void QApplication::setStartDragTime(int ms)
+{
+ drag_time = ms;
+}
+
+/*!
+ \property QApplication::startDragTime
+ \brief the time in milliseconds that a mouse button must be held down
+ before a drag and drop operation will begin
+
+ If you support drag and drop in your application, and want to start a drag
+ and drop operation after the user has held down a mouse button for a
+ certain amount of time, you should use this property's value as the delay.
+
+ Qt also uses this delay internally, e.g. in QTextEdit and QLineEdit, for
+ starting a drag.
+
+ The default value is 500 ms.
+
+ \sa startDragDistance(), {Drag and Drop}
+*/
+
+int QApplication::startDragTime()
+{
+ return drag_time;
+}
+
+/*
+ Sets the distance after which a drag should start to \a l pixels.
+
+ \sa startDragDistance()
+*/
+
+void QApplication::setStartDragDistance(int l)
+{
+ drag_distance = l;
+}
+
+/*!
+ \property QApplication::startDragDistance
+
+ If you support drag and drop in your application, and want to start a drag
+ and drop operation after the user has moved the cursor a certain distance
+ with a button held down, you should use this property's value as the
+ minimum distance required.
+
+ For example, if the mouse position of the click is stored in \c startPos
+ and the current position (e.g. in the mouse move event) is \c currentPos,
+ you can find out if a drag should be started with code like this:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 7
+
+ Qt uses this value internally, e.g. in QFileDialog.
+
+ The default value is 4 pixels.
+
+ \sa startDragTime() QPoint::manhattanLength() {Drag and Drop}
+*/
+
+int QApplication::startDragDistance()
+{
+ return drag_distance;
+}
+
+/*!
+ \fn void QApplication::setReverseLayout(bool reverse)
+
+ Use setLayoutDirection() instead.
+*/
+
+/*!
+ \fn void QApplication::reverseLayout()
+
+ Use layoutDirection() instead.
+*/
+
+
+/*!
+ \obsolete
+
+ Strips out vertical alignment flags and transforms an alignment \a align
+ of Qt::AlignLeft into Qt::AlignLeft or Qt::AlignRight according to the
+ language used.
+*/
+
+#ifdef QT3_SUPPORT
+Qt::Alignment QApplication::horizontalAlignment(Qt::Alignment align)
+{
+ return QGuiApplicationPrivate::visualAlignment(layoutDirection(), align);
+}
+#endif
+
+/*!
+ Enters the main event loop and waits until exit() is called, then returns
+ the value that was set to exit() (which is 0 if exit() is called via
+ quit()).
+
+ It is necessary to call this function to start event handling. The main
+ event loop receives events from the window system and dispatches these to
+ the application widgets.
+
+ Generally, no user interaction can take place before calling exec(). As a
+ special case, modal widgets like QMessageBox can be used before calling
+ exec(), because modal widgets call exec() to start a local event loop.
+
+ To make your application perform idle processing, i.e., executing a special
+ function whenever there are no pending events, use a QTimer with 0 timeout.
+ More advanced idle processing schemes can be achieved using processEvents().
+
+ We recommend that you connect clean-up code to the
+ \l{QCoreApplication::}{aboutToQuit()} signal, instead of putting it in your
+ application's \c{main()} function. This is because, on some platforms the
+ QApplication::exec() call may not return. For example, on the Windows
+ platform, when the user logs off, the system terminates the process after Qt
+ closes all top-level windows. Hence, there is \e{no guarantee} that the
+ application will have time to exit its event loop and execute code at the
+ end of the \c{main()} function, after the QApplication::exec() call.
+
+ \sa quitOnLastWindowClosed, quit(), exit(), processEvents(),
+ QCoreApplication::exec()
+*/
+int QApplication::exec()
+{
+#ifndef QT_NO_ACCESSIBILITY
+ QAccessible::setRootObject(qApp);
+#endif
+ return QApplicationBase::exec();
+}
+
+/*! \reimp
+ */
+bool QApplication::notify(QObject *receiver, QEvent *e)
+{
+ Q_D(QApplication);
+ // no events are delivered after ~QCoreApplication() has started
+ if (QApplicationPrivate::is_app_closing)
+ return true;
+
+ if (receiver == 0) { // serious error
+ qWarning("QApplication::notify: Unexpected null receiver");
+ return true;
+ }
+
+#ifndef QT_NO_DEBUG
+ d->checkReceiverThread(receiver);
+#endif
+
+ // capture the current mouse/keyboard state
+ if(e->spontaneous()) {
+ if (e->type() == QEvent::KeyPress
+ || e->type() == QEvent::KeyRelease) {
+ QKeyEvent *ke = static_cast<QKeyEvent*>(e);
+ QApplicationPrivate::modifier_buttons = ke->modifiers();
+ } else if(e->type() == QEvent::MouseButtonPress
+ || e->type() == QEvent::MouseButtonRelease) {
+ QMouseEvent *me = static_cast<QMouseEvent*>(e);
+ QApplicationPrivate::modifier_buttons = me->modifiers();
+ if(me->type() == QEvent::MouseButtonPress)
+ QApplicationPrivate::mouse_buttons |= me->button();
+ else
+ QApplicationPrivate::mouse_buttons &= ~me->button();
+ }
+#if !defined(QT_NO_WHEELEVENT) || !defined(QT_NO_TABLETEVENT)
+ else if (false
+# ifndef QT_NO_WHEELEVENT
+ || e->type() == QEvent::Wheel
+# endif
+# ifndef QT_NO_TABLETEVENT
+ || e->type() == QEvent::TabletMove
+ || e->type() == QEvent::TabletPress
+ || e->type() == QEvent::TabletRelease
+# endif
+ ) {
+ QInputEvent *ie = static_cast<QInputEvent*>(e);
+ QApplicationPrivate::modifier_buttons = ie->modifiers();
+ }
+#endif // !QT_NO_WHEELEVENT || !QT_NO_TABLETEVENT
+ }
+
+#ifndef QT_NO_GESTURES
+ // walk through parents and check for gestures
+ if (d->gestureManager) {
+ switch (e->type()) {
+ case QEvent::Paint:
+ case QEvent::MetaCall:
+ case QEvent::DeferredDelete:
+ case QEvent::DragEnter: case QEvent::DragMove: case QEvent::DragLeave:
+ case QEvent::Drop: case QEvent::DragResponse:
+ case QEvent::ChildAdded: case QEvent::ChildPolished:
+#ifdef QT3_SUPPORT
+ case QEvent::ChildInsertedRequest:
+ case QEvent::ChildInserted:
+ case QEvent::LayoutHint:
+#endif
+ case QEvent::ChildRemoved:
+ case QEvent::UpdateRequest:
+ case QEvent::UpdateLater:
+ case QEvent::AccessibilityPrepare:
+ case QEvent::LocaleChange:
+ case QEvent::Style:
+ case QEvent::IconDrag:
+ case QEvent::StyleChange:
+ case QEvent::AccessibilityHelp:
+ case QEvent::AccessibilityDescription:
+ case QEvent::GraphicsSceneDragEnter:
+ case QEvent::GraphicsSceneDragMove:
+ case QEvent::GraphicsSceneDragLeave:
+ case QEvent::GraphicsSceneDrop:
+ case QEvent::DynamicPropertyChange:
+ case QEvent::NetworkReplyUpdated:
+ break;
+ default:
+ if (receiver->isWidgetType()) {
+ if (d->gestureManager->filterEvent(static_cast<QWidget *>(receiver), e))
+ return true;
+ } else {
+ // a special case for events that go to QGesture objects.
+ // We pass the object to the gesture manager and it'll figure
+ // out if it's QGesture or not.
+ if (d->gestureManager->filterEvent(receiver, e))
+ return true;
+ }
+ }
+ }
+#endif // QT_NO_GESTURES
+
+ // User input and window activation makes tooltips sleep
+ switch (e->type()) {
+ case QEvent::Wheel:
+ case QEvent::ActivationChange:
+ case QEvent::KeyPress:
+ case QEvent::KeyRelease:
+ case QEvent::FocusOut:
+ case QEvent::FocusIn:
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseButtonDblClick:
+ d->toolTipFallAsleep.stop();
+ // fall-through
+ case QEvent::Leave:
+ d->toolTipWakeUp.stop();
+ default:
+ break;
+ }
+
+ bool res = false;
+ if (!receiver->isWidgetType()) {
+ res = d->notify_helper(receiver, e);
+ } else switch (e->type()) {
+#if defined QT3_SUPPORT && !defined(QT_NO_SHORTCUT)
+ case QEvent::Accel:
+ {
+ if (d->use_compat()) {
+ QKeyEvent* key = static_cast<QKeyEvent*>(e);
+ res = d->notify_helper(receiver, e);
+
+ if (!res && !key->isAccepted())
+ res = d->qt_dispatchAccelEvent(static_cast<QWidget *>(receiver), key);
+
+ // next lines are for compatibility with Qt <= 3.0.x: old
+ // QAccel was listening on toplevel widgets
+ if (!res && !key->isAccepted() && !static_cast<QWidget *>(receiver)->isWindow())
+ res = d->notify_helper(static_cast<QWidget *>(receiver)->window(), e);
+ }
+ break;
+ }
+#endif //QT3_SUPPORT && !QT_NO_SHORTCUT
+ case QEvent::ShortcutOverride:
+ case QEvent::KeyPress:
+ case QEvent::KeyRelease:
+ {
+ bool isWidget = receiver->isWidgetType();
+ bool isGraphicsWidget = false;
+#ifndef QT_NO_GRAPHICSVIEW
+ isGraphicsWidget = !isWidget && qobject_cast<QGraphicsWidget *>(receiver);
+#endif
+ if (!isWidget && !isGraphicsWidget) {
+ res = d->notify_helper(receiver, e);
+ break;
+ }
+
+ QKeyEvent* key = static_cast<QKeyEvent*>(e);
+#if defined QT3_SUPPORT && !defined(QT_NO_SHORTCUT)
+ if (d->use_compat() && d->qt_tryComposeUnicode(static_cast<QWidget*>(receiver), key))
+ break;
+#endif
+ if (key->type()==QEvent::KeyPress) {
+#ifndef QT_NO_SHORTCUT
+ // Try looking for a Shortcut before sending key events
+ if ((res = qApp->d_func()->shortcutMap.tryShortcutEvent(receiver, key)))
+ return res;
+#endif
+ qt_in_tab_key_event = (key->key() == Qt::Key_Backtab
+ || key->key() == Qt::Key_Tab
+ || key->key() == Qt::Key_Left
+ || key->key() == Qt::Key_Up
+ || key->key() == Qt::Key_Right
+ || key->key() == Qt::Key_Down);
+ }
+ bool def = key->isAccepted();
+ QPointer<QObject> pr = receiver;
+ while (receiver) {
+ if (def)
+ key->accept();
+ else
+ key->ignore();
+ res = d->notify_helper(receiver, e);
+ QWidget *w = isWidget ? static_cast<QWidget *>(receiver) : 0;
+#ifndef QT_NO_GRAPHICSVIEW
+ QGraphicsWidget *gw = isGraphicsWidget ? static_cast<QGraphicsWidget *>(receiver) : 0;
+#endif
+
+ if ((res && key->isAccepted())
+ /*
+ QLineEdit will emit a signal on Key_Return, but
+ ignore the event, and sometimes the connected
+ slot deletes the QLineEdit (common in itemview
+ delegates), so we have to check if the widget
+ was destroyed even if the event was ignored (to
+ prevent a crash)
+
+ note that we don't have to reset pw while
+ propagating (because the original receiver will
+ be destroyed if one of its ancestors is)
+ */
+ || !pr
+ || (isWidget && (w->isWindow() || !w->parentWidget()))
+#ifndef QT_NO_GRAPHICSVIEW
+ || (isGraphicsWidget && (gw->isWindow() || !gw->parentWidget()))
+#endif
+ ) {
+ break;
+ }
+
+#ifndef QT_NO_GRAPHICSVIEW
+ receiver = w ? (QObject *)w->parentWidget() : (QObject *)gw->parentWidget();
+#else
+ receiver = w->parentWidget();
+#endif
+ }
+ qt_in_tab_key_event = false;
+ }
+ break;
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseButtonDblClick:
+ case QEvent::MouseMove:
+ {
+ QWidget* w = static_cast<QWidget *>(receiver);
+
+ QMouseEvent* mouse = static_cast<QMouseEvent*>(e);
+ QPoint relpos = mouse->pos();
+
+ if (e->spontaneous()) {
+#ifndef QT_NO_IM
+ QInputContext *ic = w->inputContext();
+ if (ic
+ && w->testAttribute(Qt::WA_InputMethodEnabled)
+ && ic->filterEvent(mouse))
+ return true;
+#endif
+
+ if (e->type() == QEvent::MouseButtonPress) {
+ QApplicationPrivate::giveFocusAccordingToFocusPolicy(w,
+ Qt::ClickFocus,
+ Qt::MouseFocusReason);
+ }
+
+ // ### Qt 5 These dynamic tool tips should be an OPT-IN feature. Some platforms
+ // like Mac OS X (probably others too), can optimize their views by not
+ // dispatching mouse move events. We have attributes to control hover,
+ // and mouse tracking, but as long as we are deciding to implement this
+ // feature without choice of opting-in or out, you ALWAYS have to have
+ // tracking enabled. Therefore, the other properties give a false sense of
+ // performance enhancement.
+ if (e->type() == QEvent::MouseMove && mouse->buttons() == 0) {
+ d->toolTipWidget = w;
+ d->toolTipPos = relpos;
+ d->toolTipGlobalPos = mouse->globalPos();
+ d->toolTipWakeUp.start(d->toolTipFallAsleep.isActive()?20:700, this);
+ }
+ }
+
+ bool eventAccepted = mouse->isAccepted();
+
+ QPointer<QWidget> pw = w;
+ while (w) {
+ QMouseEvent me(mouse->type(), relpos, mouse->globalPos(), mouse->button(), mouse->buttons(),
+ mouse->modifiers());
+ me.spont = mouse->spontaneous();
+ // throw away any mouse-tracking-only mouse events
+ if (!w->hasMouseTracking()
+ && mouse->type() == QEvent::MouseMove && mouse->buttons() == 0) {
+ // but still send them through all application event filters (normally done by notify_helper)
+ for (int i = 0; i < d->eventFilters.size(); ++i) {
+ register QObject *obj = d->eventFilters.at(i);
+ if (!obj)
+ continue;
+ if (obj->d_func()->threadData != w->d_func()->threadData) {
+ qWarning("QApplication: Object event filter cannot be in a different thread.");
+ continue;
+ }
+ if (obj->eventFilter(w, w == receiver ? mouse : &me))
+ break;
+ }
+ res = true;
+ } else {
+ w->setAttribute(Qt::WA_NoMouseReplay, false);
+ res = d->notify_helper(w, w == receiver ? mouse : &me);
+ e->spont = false;
+ }
+ eventAccepted = (w == receiver ? mouse : &me)->isAccepted();
+ if (res && eventAccepted)
+ break;
+ if (w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation))
+ break;
+ relpos += w->pos();
+ w = w->parentWidget();
+ }
+
+ mouse->setAccepted(eventAccepted);
+
+ if (e->type() == QEvent::MouseMove) {
+ if (!pw)
+ break;
+
+ w = static_cast<QWidget *>(receiver);
+ relpos = mouse->pos();
+ QPoint diff = relpos - w->mapFromGlobal(d->hoverGlobalPos);
+ while (w) {
+ if (w->testAttribute(Qt::WA_Hover) &&
+ (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) {
+ QHoverEvent he(QEvent::HoverMove, relpos, relpos - diff);
+ d->notify_helper(w, &he);
+ }
+ if (w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation))
+ break;
+ relpos += w->pos();
+ w = w->parentWidget();
+ }
+ }
+
+ d->hoverGlobalPos = mouse->globalPos();
+ }
+ break;
+#ifndef QT_NO_WHEELEVENT
+ case QEvent::Wheel:
+ {
+ QWidget* w = static_cast<QWidget *>(receiver);
+ QWheelEvent* wheel = static_cast<QWheelEvent*>(e);
+ QPoint relpos = wheel->pos();
+ bool eventAccepted = wheel->isAccepted();
+
+ if (e->spontaneous()) {
+ QApplicationPrivate::giveFocusAccordingToFocusPolicy(w,
+ Qt::WheelFocus,
+ Qt::MouseFocusReason);
+ }
+
+ while (w) {
+ QWheelEvent we(relpos, wheel->globalPos(), wheel->delta(), wheel->buttons(),
+ wheel->modifiers(), wheel->orientation());
+ we.spont = wheel->spontaneous();
+ res = d->notify_helper(w, w == receiver ? wheel : &we);
+ eventAccepted = ((w == receiver) ? wheel : &we)->isAccepted();
+ e->spont = false;
+ if ((res && eventAccepted)
+ || w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation))
+ break;
+
+ relpos += w->pos();
+ w = w->parentWidget();
+ }
+ wheel->setAccepted(eventAccepted);
+ }
+ break;
+#endif
+#ifndef QT_NO_CONTEXTMENU
+ case QEvent::ContextMenu:
+ {
+ QWidget* w = static_cast<QWidget *>(receiver);
+ QContextMenuEvent *context = static_cast<QContextMenuEvent*>(e);
+ QPoint relpos = context->pos();
+ bool eventAccepted = context->isAccepted();
+ while (w) {
+ QContextMenuEvent ce(context->reason(), relpos, context->globalPos(), context->modifiers());
+ ce.spont = e->spontaneous();
+ res = d->notify_helper(w, w == receiver ? context : &ce);
+ eventAccepted = ((w == receiver) ? context : &ce)->isAccepted();
+ e->spont = false;
+
+ if ((res && eventAccepted)
+ || w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation))
+ break;
+
+ relpos += w->pos();
+ w = w->parentWidget();
+ }
+ context->setAccepted(eventAccepted);
+ }
+ break;
+#endif // QT_NO_CONTEXTMENU
+#ifndef QT_NO_TABLETEVENT
+ case QEvent::TabletMove:
+ case QEvent::TabletPress:
+ case QEvent::TabletRelease:
+ {
+ QWidget *w = static_cast<QWidget *>(receiver);
+ QTabletEvent *tablet = static_cast<QTabletEvent*>(e);
+ QPoint relpos = tablet->pos();
+ bool eventAccepted = tablet->isAccepted();
+ while (w) {
+ QTabletEvent te(tablet->type(), relpos, tablet->globalPos(),
+ tablet->hiResGlobalPos(), tablet->device(), tablet->pointerType(),
+ tablet->pressure(), tablet->xTilt(), tablet->yTilt(),
+ tablet->tangentialPressure(), tablet->rotation(), tablet->z(),
+ tablet->modifiers(), tablet->uniqueId());
+ te.spont = e->spontaneous();
+ res = d->notify_helper(w, w == receiver ? tablet : &te);
+ eventAccepted = ((w == receiver) ? tablet : &te)->isAccepted();
+ e->spont = false;
+ if ((res && eventAccepted)
+ || w->isWindow()
+ || w->testAttribute(Qt::WA_NoMousePropagation))
+ break;
+
+ relpos += w->pos();
+ w = w->parentWidget();
+ }
+ tablet->setAccepted(eventAccepted);
+ qt_tabletChokeMouse = tablet->isAccepted();
+ }
+ break;
+#endif // QT_NO_TABLETEVENT
+
+#if !defined(QT_NO_TOOLTIP) || !defined(QT_NO_WHATSTHIS)
+ case QEvent::ToolTip:
+ case QEvent::WhatsThis:
+ case QEvent::QueryWhatsThis:
+ {
+ QWidget* w = static_cast<QWidget *>(receiver);
+ QHelpEvent *help = static_cast<QHelpEvent*>(e);
+ QPoint relpos = help->pos();
+ bool eventAccepted = help->isAccepted();
+ while (w) {
+ QHelpEvent he(help->type(), relpos, help->globalPos());
+ he.spont = e->spontaneous();
+ res = d->notify_helper(w, w == receiver ? help : &he);
+ e->spont = false;
+ eventAccepted = (w == receiver ? help : &he)->isAccepted();
+ if ((res && eventAccepted) || w->isWindow())
+ break;
+
+ relpos += w->pos();
+ w = w->parentWidget();
+ }
+ help->setAccepted(eventAccepted);
+ }
+ break;
+#endif
+#if !defined(QT_NO_STATUSTIP) || !defined(QT_NO_WHATSTHIS)
+ case QEvent::StatusTip:
+ case QEvent::WhatsThisClicked:
+ {
+ QWidget *w = static_cast<QWidget *>(receiver);
+ while (w) {
+ res = d->notify_helper(w, e);
+ if ((res && e->isAccepted()) || w->isWindow())
+ break;
+ w = w->parentWidget();
+ }
+ }
+ break;
+#endif
+
+#ifndef QT_NO_DRAGANDDROP
+ case QEvent::DragEnter: {
+ QWidget* w = static_cast<QWidget *>(receiver);
+ QDragEnterEvent *dragEvent = static_cast<QDragEnterEvent *>(e);
+#ifdef Q_WS_MAC
+ // HIView has a slight difference in how it delivers events to children and parents
+ // It will not give a leave to a child's parent when it enters a child.
+ QWidget *currentTarget = QDragManager::self()->currentTarget();
+ if (currentTarget) {
+ // Assume currentTarget did not get a leave
+ QDragLeaveEvent event;
+ QApplication::sendEvent(currentTarget, &event);
+ }
+#endif
+#ifndef QT_NO_GRAPHICSVIEW
+ // QGraphicsProxyWidget handles its own propagation,
+ // and we must not change QDragManagers currentTarget.
+ QWExtra *extra = w->window()->d_func()->extra;
+ if (extra && extra->proxyWidget) {
+ res = d->notify_helper(w, dragEvent);
+ break;
+ }
+#endif
+ while (w) {
+ if (w->isEnabled() && w->acceptDrops()) {
+ res = d->notify_helper(w, dragEvent);
+ if (res && dragEvent->isAccepted()) {
+ QDragManager::self()->setCurrentTarget(w);
+ break;
+ }
+ }
+ if (w->isWindow())
+ break;
+ dragEvent->p = w->mapToParent(dragEvent->p);
+ w = w->parentWidget();
+ }
+ }
+ break;
+ case QEvent::DragMove:
+ case QEvent::Drop:
+ case QEvent::DragLeave: {
+ QWidget* w = static_cast<QWidget *>(receiver);
+#ifndef QT_NO_GRAPHICSVIEW
+ // QGraphicsProxyWidget handles its own propagation,
+ // and we must not change QDragManagers currentTarget.
+ QWExtra *extra = w->window()->d_func()->extra;
+ bool isProxyWidget = extra && extra->proxyWidget;
+ if (!isProxyWidget)
+#endif
+ w = QDragManager::self()->currentTarget();
+
+ if (!w) {
+#ifdef Q_WS_MAC
+ // HIView has a slight difference in how it delivers events to children and parents
+ // It will not give an enter to a child's parent when it leaves the child.
+ if (e->type() == QEvent::DragLeave)
+ break;
+ // Assume that w did not get an enter.
+ QDropEvent *dropEvent = static_cast<QDropEvent *>(e);
+ QDragEnterEvent dragEnterEvent(dropEvent->pos(), dropEvent->possibleActions(),
+ dropEvent->mimeData(), dropEvent->mouseButtons(),
+ dropEvent->keyboardModifiers());
+ QApplication::sendEvent(receiver, &dragEnterEvent);
+ w = QDragManager::self()->currentTarget();
+ if (!w)
+#endif
+ break;
+ }
+ if (e->type() == QEvent::DragMove || e->type() == QEvent::Drop) {
+ QDropEvent *dragEvent = static_cast<QDropEvent *>(e);
+ QWidget *origReciver = static_cast<QWidget *>(receiver);
+ while (origReciver && w != origReciver) {
+ dragEvent->p = origReciver->mapToParent(dragEvent->p);
+ origReciver = origReciver->parentWidget();
+ }
+ }
+ res = d->notify_helper(w, e);
+ if (e->type() != QEvent::DragMove
+#ifndef QT_NO_GRAPHICSVIEW
+ && !isProxyWidget
+#endif
+ )
+ QDragManager::self()->setCurrentTarget(0, e->type() == QEvent::Drop);
+ }
+ break;
+#endif
+ case QEvent::TouchBegin:
+ // Note: TouchUpdate and TouchEnd events are never propagated
+ {
+ QWidget *widget = static_cast<QWidget *>(receiver);
+ QTouchEvent *touchEvent = static_cast<QTouchEvent *>(e);
+ bool eventAccepted = touchEvent->isAccepted();
+ if (widget->testAttribute(Qt::WA_AcceptTouchEvents) && e->spontaneous()) {
+ // give the widget focus if the focus policy allows it
+ QApplicationPrivate::giveFocusAccordingToFocusPolicy(widget,
+ Qt::ClickFocus,
+ Qt::MouseFocusReason);
+ }
+
+ while (widget) {
+ // first, try to deliver the touch event
+ bool acceptTouchEvents = widget->testAttribute(Qt::WA_AcceptTouchEvents);
+ touchEvent->setWidget(widget);
+ touchEvent->setAccepted(acceptTouchEvents);
+ QWeakPointer<QWidget> p = widget;
+ res = acceptTouchEvents && d->notify_helper(widget, touchEvent);
+ eventAccepted = touchEvent->isAccepted();
+ if (p.isNull()) {
+ // widget was deleted
+ widget = 0;
+ } else {
+ widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, res && eventAccepted);
+ }
+ touchEvent->spont = false;
+ if (res && eventAccepted) {
+ // the first widget to accept the TouchBegin gets an implicit grab.
+ for (int i = 0; i < touchEvent->touchPoints().count(); ++i) {
+ const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().at(i);
+ d->widgetForTouchPointId[touchPoint.id()] = widget;
+ }
+ break;
+ } else if (p.isNull() || widget->isWindow() || widget->testAttribute(Qt::WA_NoMousePropagation)) {
+ break;
+ }
+ QPoint offset = widget->pos();
+ widget = widget->parentWidget();
+ touchEvent->setWidget(widget);
+ for (int i = 0; i < touchEvent->_touchPoints.size(); ++i) {
+ QTouchEvent::TouchPoint &pt = touchEvent->_touchPoints[i];
+ QRectF rect = pt.rect();
+ rect.moveCenter(offset);
+ pt.d->rect = rect;
+ pt.d->startPos = pt.startPos() + offset;
+ pt.d->lastPos = pt.lastPos() + offset;
+ }
+ }
+
+ touchEvent->setAccepted(eventAccepted);
+ break;
+ }
+ case QEvent::RequestSoftwareInputPanel:
+ case QEvent::CloseSoftwareInputPanel:
+#ifndef QT_NO_IM
+ if (receiver->isWidgetType()) {
+ QWidget *w = static_cast<QWidget *>(receiver);
+ QInputContext *ic = w->inputContext();
+ if (ic && ic->filterEvent(e)) {
+ break;
+ }
+ }
+#endif
+ res = d->notify_helper(receiver, e);
+ break;
+
+#ifndef QT_NO_GESTURES
+ case QEvent::NativeGesture:
+ {
+ // only propagate the first gesture event (after the GID_BEGIN)
+ QWidget *w = static_cast<QWidget *>(receiver);
+ while (w) {
+ e->ignore();
+ res = d->notify_helper(w, e);
+ if ((res && e->isAccepted()) || w->isWindow())
+ break;
+ w = w->parentWidget();
+ }
+ break;
+ }
+ case QEvent::Gesture:
+ case QEvent::GestureOverride:
+ {
+ if (receiver->isWidgetType()) {
+ QWidget *w = static_cast<QWidget *>(receiver);
+ QGestureEvent *gestureEvent = static_cast<QGestureEvent *>(e);
+ QList<QGesture *> allGestures = gestureEvent->gestures();
+
+ bool eventAccepted = gestureEvent->isAccepted();
+ bool wasAccepted = eventAccepted;
+ while (w) {
+ // send only gestures the widget expects
+ QList<QGesture *> gestures;
+ QWidgetPrivate *wd = w->d_func();
+ for (int i = 0; i < allGestures.size();) {
+ QGesture *g = allGestures.at(i);
+ Qt::GestureType type = g->gestureType();
+ QMap<Qt::GestureType, Qt::GestureFlags>::iterator contextit =
+ wd->gestureContext.find(type);
+ bool deliver = contextit != wd->gestureContext.end() &&
+ (g->state() == Qt::GestureStarted || w == receiver ||
+ (contextit.value() & Qt::ReceivePartialGestures));
+ if (deliver) {
+ allGestures.removeAt(i);
+ gestures.append(g);
+ } else {
+ ++i;
+ }
+ }
+ if (!gestures.isEmpty()) { // we have gestures for this w
+ QGestureEvent ge(gestures);
+ ge.t = gestureEvent->t;
+ ge.spont = gestureEvent->spont;
+ ge.m_accept = wasAccepted;
+ ge.d_func()->accepted = gestureEvent->d_func()->accepted;
+ res = d->notify_helper(w, &ge);
+ gestureEvent->spont = false;
+ eventAccepted = ge.isAccepted();
+ for (int i = 0; i < gestures.size(); ++i) {
+ QGesture *g = gestures.at(i);
+ // Ignore res [event return value] because handling of multiple gestures
+ // packed into a single QEvent depends on not consuming the event
+ if (eventAccepted || ge.isAccepted(g)) {
+ // if the gesture was accepted, mark the target widget for it
+ gestureEvent->d_func()->targetWidgets[g->gestureType()] = w;
+ gestureEvent->setAccepted(g, true);
+ } else {
+ // if the gesture was explicitly ignored by the application,
+ // put it back so a parent can get it
+ allGestures.append(g);
+ }
+ }
+ }
+ if (allGestures.isEmpty()) // everything delivered
+ break;
+ if (w->isWindow())
+ break;
+ w = w->parentWidget();
+ }
+ foreach (QGesture *g, allGestures)
+ gestureEvent->setAccepted(g, false);
+ gestureEvent->m_accept = false; // to make sure we check individual gestures
+ } else {
+ res = d->notify_helper(receiver, e);
+ }
+ break;
+ }
+#endif // QT_NO_GESTURES
+#ifdef QT_MAC_USE_COCOA
+ case QEvent::Enter:
+ if (receiver->isWidgetType()) {
+ QWidget *w = static_cast<QWidget *>(receiver);
+ if (w->testAttribute(Qt::WA_AcceptTouchEvents))
+ qt_widget_private(w)->registerTouchWindow(true);
+ }
+ res = d->notify_helper(receiver, e);
+ break;
+ case QEvent::Leave:
+ if (receiver->isWidgetType()) {
+ QWidget *w = static_cast<QWidget *>(receiver);
+ if (w->testAttribute(Qt::WA_AcceptTouchEvents))
+ qt_widget_private(w)->registerTouchWindow(false);
+ }
+ res = d->notify_helper(receiver, e);
+ break;
+#endif
+ default:
+ res = d->notify_helper(receiver, e);
+ break;
+ }
+
+ return res;
+}
+
+bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e)
+{
+ // send to all application event filters
+ if (sendThroughApplicationEventFilters(receiver, e))
+ return true;
+
+ if (receiver->isWidgetType()) {
+ QWidget *widget = static_cast<QWidget *>(receiver);
+
+#if !defined(Q_WS_WINCE) || (defined(GWES_ICONCURS) && !defined(QT_NO_CURSOR))
+ // toggle HasMouse widget state on enter and leave
+ if ((e->type() == QEvent::Enter || e->type() == QEvent::DragEnter) &&
+ (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == widget->window()))
+ widget->setAttribute(Qt::WA_UnderMouse, true);
+ else if (e->type() == QEvent::Leave || e->type() == QEvent::DragLeave)
+ widget->setAttribute(Qt::WA_UnderMouse, false);
+#endif
+
+ if (QLayout *layout=widget->d_func()->layout) {
+ layout->widgetEvent(e);
+ }
+ }
+
+ // send to all receiver event filters
+ if (sendThroughObjectEventFilters(receiver, e))
+ return true;
+
+ // deliver the event
+ bool consumed = receiver->event(e);
+ e->spont = false;
+ return consumed;
+}
+
+
+/*!
+ \class QSessionManager
+ \brief The QSessionManager class provides access to the session manager.
+
+ A session manager in a desktop environment (in which Qt GUI applications
+ live) keeps track of a session, which is a group of running applications,
+ each of which has a particular state. The state of an application contains
+ (most notably) the documents the application has open and the position and
+ size of its windows.
+
+ The session manager is used to save the session, e.g., when the machine is
+ shut down, and to restore a session, e.g., when the machine is started up.
+ We recommend that you use QSettings to save an application's settings,
+ for example, window positions, recently used files, etc. When the
+ application is restarted by the session manager, you can restore the
+ settings.
+
+ QSessionManager provides an interface between the application and the
+ session manager so that the program can work well with the session manager.
+ In Qt, session management requests for action are handled by the two
+ virtual functions QApplication::commitData() and QApplication::saveState().
+ Both provide a reference to a session manager object as argument, to allow
+ the application to communicate with the session manager. The session
+ manager can only be accessed through these functions.
+
+ No user interaction is possible \e unless the application gets explicit
+ permission from the session manager. You ask for permission by calling
+ allowsInteraction() or, if it is really urgent, allowsErrorInteraction().
+ Qt does not enforce this, but the session manager may.
+
+ You can try to abort the shutdown process by calling cancel(). The default
+ commitData() function does this if some top-level window rejected its
+ closeEvent().
+
+ For sophisticated session managers provided on Unix/X11, QSessionManager
+ offers further possibilities to fine-tune an application's session
+ management behavior: setRestartCommand(), setDiscardCommand(),
+ setRestartHint(), setProperty(), requestPhase2(). See the respective
+ function descriptions for further details.
+
+ \sa QApplication, {Session Management}
+*/
+
+/*! \enum QSessionManager::RestartHint
+
+ This enum type defines the circumstances under which this application wants
+ to be restarted by the session manager. The current values are:
+
+ \value RestartIfRunning If the application is still running when the
+ session is shut down, it wants to be restarted
+ at the start of the next session.
+
+ \value RestartAnyway The application wants to be started at the
+ start of the next session, no matter what.
+ (This is useful for utilities that run just
+ after startup and then quit.)
+
+ \value RestartImmediately The application wants to be started immediately
+ whenever it is not running.
+
+ \value RestartNever The application does not want to be restarted
+ automatically.
+
+ The default hint is \c RestartIfRunning.
+*/
+
+
+/*!
+ \fn QString QSessionManager::sessionId() const
+
+ Returns the identifier of the current session.
+
+ If the application has been restored from an earlier session, this
+ identifier is the same as it was in the earlier session.
+
+ \sa sessionKey(), QApplication::sessionId()
+*/
+
+/*!
+ \fn QString QSessionManager::sessionKey() const
+
+ Returns the session key in the current session.
+
+ If the application has been restored from an earlier session, this key is
+ the same as it was when the previous session ended.
+
+ The session key changes with every call of commitData() or saveState().
+
+ \sa sessionId(), QApplication::sessionKey()
+*/
+
+/*!
+ \fn void* QSessionManager::handle() const
+
+ \internal
+*/
+
+/*!
+ \fn bool QSessionManager::allowsInteraction()
+
+ Asks the session manager for permission to interact with the user. Returns
+ true if interaction is permitted; otherwise returns false.
+
+ The rationale behind this mechanism is to make it possible to synchronize
+ user interaction during a shutdown. Advanced session managers may ask all
+ applications simultaneously to commit their data, resulting in a much
+ faster shutdown.
+
+ When the interaction is completed we strongly recommend releasing the user
+ interaction semaphore with a call to release(). This way, other
+ applications may get the chance to interact with the user while your
+ application is still busy saving data. (The semaphore is implicitly
+ released when the application exits.)
+
+ If the user decides to cancel the shutdown process during the interaction
+ phase, you must tell the session manager that this has happened by calling
+ cancel().
+
+ Here's an example of how an application's QApplication::commitData() might
+ be implemented:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 8
+
+ If an error occurred within the application while saving its data, you may
+ want to try allowsErrorInteraction() instead.
+
+ \sa QApplication::commitData(), release(), cancel()
+*/
+
+
+/*!
+ \fn bool QSessionManager::allowsErrorInteraction()
+
+ Returns true if error interaction is permitted; otherwise returns false.
+
+ This is similar to allowsInteraction(), but also enables the application to
+ tell the user about any errors that occur. Session managers may give error
+ interaction requests higher priority, which means that it is more likely
+ that an error interaction is permitted. However, you are still not
+ guaranteed that the session manager will allow interaction.
+
+ \sa allowsInteraction(), release(), cancel()
+*/
+
+/*!
+ \fn void QSessionManager::release()
+
+ Releases the session manager's interaction semaphore after an interaction
+ phase.
+
+ \sa allowsInteraction(), allowsErrorInteraction()
+*/
+
+/*!
+ \fn void QSessionManager::cancel()
+
+ Tells the session manager to cancel the shutdown process. Applications
+ should not call this function without asking the user first.
+
+ \sa allowsInteraction(), allowsErrorInteraction()
+*/
+
+/*!
+ \fn void QSessionManager::setRestartHint(RestartHint hint)
+
+ Sets the application's restart hint to \a hint. On application startup, the
+ hint is set to \c RestartIfRunning.
+
+ \note These flags are only hints, a session manager may or may not respect
+ them.
+
+ We recommend setting the restart hint in QApplication::saveState() because
+ most session managers perform a checkpoint shortly after an application's
+ startup.
+
+ \sa restartHint()
+*/
+
+/*!
+ \fn QSessionManager::RestartHint QSessionManager::restartHint() const
+
+ Returns the application's current restart hint. The default is
+ \c RestartIfRunning.
+
+ \sa setRestartHint()
+*/
+
+/*!
+ \fn void QSessionManager::setRestartCommand(const QStringList& command)
+
+ If the session manager is capable of restoring sessions it will execute
+ \a command in order to restore the application. The command defaults to
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 9
+
+ The \c -session option is mandatory; otherwise QApplication cannot tell
+ whether it has been restored or what the current session identifier is.
+ See QApplication::isSessionRestored() and QApplication::sessionId() for
+ details.
+
+ If your application is very simple, it may be possible to store the entire
+ application state in additional command line options. This is usually a
+ very bad idea because command lines are often limited to a few hundred
+ bytes. Instead, use QSettings, temporary files, or a database for this
+ purpose. By marking the data with the unique sessionId(), you will be able
+ to restore the application in a future session.
+
+ \sa restartCommand(), setDiscardCommand(), setRestartHint()
+*/
+
+/*!
+ \fn QStringList QSessionManager::restartCommand() const
+
+ Returns the currently set restart command.
+
+ To iterate over the list, you can use the \l foreach pseudo-keyword:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 10
+
+ \sa setRestartCommand(), restartHint()
+*/
+
+/*!
+ \fn void QSessionManager::setDiscardCommand(const QStringList& list)
+
+ Sets the discard command to the given \a list.
+
+ \sa discardCommand(), setRestartCommand()
+*/
+
+
+/*!
+ \fn QStringList QSessionManager::discardCommand() const
+
+ Returns the currently set discard command.
+
+ To iterate over the list, you can use the \l foreach pseudo-keyword:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 11
+
+ \sa setDiscardCommand(), restartCommand(), setRestartCommand()
+*/
+
+/*!
+ \fn void QSessionManager::setManagerProperty(const QString &name, const QString &value)
+ \overload
+
+ Low-level write access to the application's identification and state
+ records are kept in the session manager.
+
+ The property called \a name has its value set to the string \a value.
+*/
+
+/*!
+ \fn void QSessionManager::setManagerProperty(const QString& name,
+ const QStringList& value)
+
+ Low-level write access to the application's identification and state record
+ are kept in the session manager.
+
+ The property called \a name has its value set to the string list \a value.
+*/
+
+/*!
+ \fn bool QSessionManager::isPhase2() const
+
+ Returns true if the session manager is currently performing a second
+ session management phase; otherwise returns false.
+
+ \sa requestPhase2()
+*/
+
+/*!
+ \fn void QSessionManager::requestPhase2()
+
+ Requests a second session management phase for the application. The
+ application may then return immediately from the QApplication::commitData()
+ or QApplication::saveState() function, and they will be called again once
+ most or all other applications have finished their session management.
+
+ The two phases are useful for applications such as the X11 window manager
+ that need to store information about another application's windows and
+ therefore have to wait until these applications have completed their
+ respective session management tasks.
+
+ \note If another application has requested a second phase it may get called
+ before, simultaneously with, or after your application's second phase.
+
+ \sa isPhase2()
+*/
+
+/*****************************************************************************
+ Stubbed session management support
+ *****************************************************************************/
+#ifndef QT_NO_SESSIONMANAGER
+#if defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_WS_QWS)
+
+#if defined(Q_OS_WINCE)
+HRESULT qt_CoCreateGuid(GUID* guid)
+{
+ // We will use the following information to create the GUID
+ // 1. absolute path to application
+ wchar_t tempFilename[MAX_PATH];
+ if (!GetModuleFileName(0, tempFilename, MAX_PATH))
+ return S_FALSE;
+ unsigned int hash = qHash(QString::fromWCharArray(tempFilename));
+ guid->Data1 = hash;
+ // 2. creation time of file
+ QFileInfo info(QString::fromWCharArray(tempFilename));
+ guid->Data2 = qHash(info.created().toTime_t());
+ // 3. current system time
+ guid->Data3 = qHash(QDateTime::currentDateTime().toTime_t());
+ return S_OK;
+}
+#if !defined(OLE32_MCOMGUID) || defined(QT_WINCE_FORCE_CREATE_GUID)
+#define CoCreateGuid qt_CoCreateGuid
+#endif
+
+#endif
+
+class QSessionManagerPrivate : public QObjectPrivate
+{
+public:
+ QStringList restartCommand;
+ QStringList discardCommand;
+ QString sessionId;
+ QString sessionKey;
+ QSessionManager::RestartHint restartHint;
+};
+
+QSessionManager* qt_session_manager_self = 0;
+QSessionManager::QSessionManager(QApplication * app, QString &id, QString &key)
+ : QObject(*new QSessionManagerPrivate, app)
+{
+ Q_D(QSessionManager);
+ setObjectName(QLatin1String("qt_sessionmanager"));
+ qt_session_manager_self = this;
+#if defined(Q_WS_WIN)
+ wchar_t guidstr[40];
+ GUID guid;
+ CoCreateGuid(&guid);
+ StringFromGUID2(guid, guidstr, 40);
+ id = QString::fromWCharArray(guidstr);
+ CoCreateGuid(&guid);
+ StringFromGUID2(guid, guidstr, 40);
+ key = QString::fromWCharArray(guidstr);
+#endif
+ d->sessionId = id;
+ d->sessionKey = key;
+ d->restartHint = RestartIfRunning;
+}
+
+QSessionManager::~QSessionManager()
+{
+ qt_session_manager_self = 0;
+}
+
+QString QSessionManager::sessionId() const
+{
+ Q_D(const QSessionManager);
+ return d->sessionId;
+}
+
+QString QSessionManager::sessionKey() const
+{
+ Q_D(const QSessionManager);
+ return d->sessionKey;
+}
+
+
+#if defined(Q_WS_X11) || defined(Q_WS_MAC)
+void* QSessionManager::handle() const
+{
+ return 0;
+}
+#endif
+
+#if !defined(Q_WS_WIN)
+bool QSessionManager::allowsInteraction()
+{
+ return true;
+}
+
+bool QSessionManager::allowsErrorInteraction()
+{
+ return true;
+}
+void QSessionManager::release()
+{
+}
+
+void QSessionManager::cancel()
+{
+}
+#endif
+
+
+void QSessionManager::setRestartHint(QSessionManager::RestartHint hint)
+{
+ Q_D(QSessionManager);
+ d->restartHint = hint;
+}
+
+QSessionManager::RestartHint QSessionManager::restartHint() const
+{
+ Q_D(const QSessionManager);
+ return d->restartHint;
+}
+
+void QSessionManager::setRestartCommand(const QStringList& command)
+{
+ Q_D(QSessionManager);
+ d->restartCommand = command;
+}
+
+QStringList QSessionManager::restartCommand() const
+{
+ Q_D(const QSessionManager);
+ return d->restartCommand;
+}
+
+void QSessionManager::setDiscardCommand(const QStringList& command)
+{
+ Q_D(QSessionManager);
+ d->discardCommand = command;
+}
+
+QStringList QSessionManager::discardCommand() const
+{
+ Q_D(const QSessionManager);
+ return d->discardCommand;
+}
+
+void QSessionManager::setManagerProperty(const QString&, const QString&)
+{
+}
+
+void QSessionManager::setManagerProperty(const QString&, const QStringList&)
+{
+}
+
+bool QSessionManager::isPhase2() const
+{
+ return false;
+}
+
+void QSessionManager::requestPhase2()
+{
+}
+
+#endif
+#endif // QT_NO_SESSIONMANAGER
+
+/*!
+ \typedef QApplication::ColorMode
+ \compat
+
+ Use ColorSpec instead.
+*/
+
+/*!
+ \fn Qt::MacintoshVersion QApplication::macVersion()
+
+ Use QSysInfo::MacintoshVersion instead.
+*/
+
+/*!
+ \fn QApplication::ColorMode QApplication::colorMode()
+
+ Use colorSpec() instead, and use ColorSpec as the enum type.
+*/
+
+/*!
+ \fn void QApplication::setColorMode(ColorMode mode)
+
+ Use setColorSpec() instead, and pass a ColorSpec value instead.
+*/
+
+/*!
+ \fn bool QApplication::hasGlobalMouseTracking()
+
+ This feature does not exist anymore. This function always returns true
+ in Qt 4.
+*/
+
+/*!
+ \fn void QApplication::setGlobalMouseTracking(bool dummy)
+
+ This function does nothing in Qt 4. The \a dummy parameter is ignored.
+*/
+
+/*!
+ \fn void QApplication::flushX()
+
+ Use flush() instead.
+*/
+
+/*!
+ \fn void QApplication::setWinStyleHighlightColor(const QColor &c)
+
+ Use the palette instead.
+
+ \oldcode
+ app.setWinStyleHighlightColor(color);
+ \newcode
+ QPalette palette(QApplication::palette());
+ palette.setColor(QPalette::Highlight, color);
+ QApplication::setPalette(palette);
+ \endcode
+*/
+
+/*!
+ \fn void QApplication::setPalette(const QPalette &pal, bool b, const char* className = 0)
+
+ Use the two-argument overload instead.
+*/
+
+/*!
+ \fn void QApplication::setFont(const QFont &font, bool b, const char* className = 0)
+
+ Use the two-argument overload instead.
+*/
+
+/*!
+ \fn const QColor &QApplication::winStyleHighlightColor()
+
+ Use QApplication::palette().color(QPalette::Active, QPalette::Highlight) instead.
+*/
+
+/*!
+ \fn QWidget *QApplication::widgetAt(int x, int y, bool child)
+
+ Use the two-argument widgetAt() overload to get the child widget. To get
+ the top-level widget do this:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 12
+*/
+
+/*!
+ \fn QWidget *QApplication::widgetAt(const QPoint &point, bool child)
+
+ Use the single-argument widgetAt() overload to get the child widget. To get
+ the top-level widget do this:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qapplication.cpp 13
+*/
+
+#ifdef QT3_SUPPORT
+QWidget *QApplication::mainWidget()
+{
+ return QApplicationPrivate::main_widget;
+}
+#endif
+bool QApplicationPrivate::inPopupMode() const
+{
+ return QApplicationPrivate::popupWidgets != 0;
+}
+
+/*!
+ \property QApplication::quitOnLastWindowClosed
+
+ \brief whether the application implicitly quits when the last window is
+ closed.
+
+ The default is true.
+
+ If this property is true, the applications quits when the last visible
+ primary window (i.e. window with no parent) with the Qt::WA_QuitOnClose
+ attribute set is closed. By default this attribute is set for all widgets
+ except for sub-windows. Refer to \l{Qt::WindowType} for a detailed list of
+ Qt::Window objects.
+
+ \sa quit(), QWidget::close()
+ */
+
+void QApplication::setQuitOnLastWindowClosed(bool quit)
+{
+ QApplicationPrivate::quitOnLastWindowClosed = quit;
+}
+
+bool QApplication::quitOnLastWindowClosed()
+{
+ return QApplicationPrivate::quitOnLastWindowClosed;
+}
+
+void QApplicationPrivate::emitLastWindowClosed()
+{
+ if (qApp && qApp->d_func()->in_exec) {
+ if (QApplicationPrivate::quitOnLastWindowClosed) {
+ // get ready to quit, this event might be removed if the
+ // event loop is re-entered, however
+ QApplication::postEvent(qApp, new QEvent(QEvent::Quit));
+ }
+ emit qApp->lastWindowClosed();
+ }
+}
+
+/*! \variable QApplication::NormalColors
+ \compat
+
+ Use \l NormalColor instead.
+*/
+
+/*! \variable QApplication::CustomColors
+ \compat
+
+ Use \l CustomColor instead.
+*/
+
+#ifdef QT_KEYPAD_NAVIGATION
+/*!
+ Sets the kind of focus navigation Qt should use to \a mode.
+
+ This feature is available in Qt for Embedded Linux, Symbian and Windows CE
+ only.
+
+ \note On Windows CE this feature is disabled by default for touch device
+ mkspecs. To enable keypad navigation, build Qt with
+ QT_KEYPAD_NAVIGATION defined.
+
+ \note On Symbian, setting the mode to Qt::NavigationModeCursorAuto will enable a
+ virtual mouse cursor on non touchscreen devices, which is controlled
+ by the cursor keys if there is no analog pointer device.
+ On other platforms and on touchscreen devices, it has the same
+ meaning as Qt::NavigationModeNone.
+
+ \since 4.6
+
+ \sa keypadNavigationEnabled()
+*/
+void QApplication::setNavigationMode(Qt::NavigationMode mode)
+{
+#ifdef Q_OS_SYMBIAN
+ QApplicationPrivate::setNavigationMode(mode);
+#else
+ QApplicationPrivate::navigationMode = mode;
+#endif
+}
+
+/*!
+ Returns what kind of focus navigation Qt is using.
+
+ This feature is available in Qt for Embedded Linux, Symbian and Windows CE
+ only.
+
+ \note On Windows CE this feature is disabled by default for touch device
+ mkspecs. To enable keypad navigation, build Qt with
+ QT_KEYPAD_NAVIGATION defined.
+
+ \note On Symbian, the default mode is Qt::NavigationModeNone for touch
+ devices, and Qt::NavigationModeKeypadDirectional.
+
+ \since 4.6
+
+ \sa keypadNavigationEnabled()
+*/
+Qt::NavigationMode QApplication::navigationMode()
+{
+ return QApplicationPrivate::navigationMode;
+}
+
+/*!
+ Sets whether Qt should use focus navigation suitable for use with a
+ minimal keypad.
+
+ This feature is available in Qt for Embedded Linux, Symbian and Windows CE
+ only.
+
+ \note On Windows CE this feature is disabled by default for touch device
+ mkspecs. To enable keypad navigation, build Qt with
+ QT_KEYPAD_NAVIGATION defined.
+
+ \deprecated
+
+ \sa setNavigationMode()
+*/
+void QApplication::setKeypadNavigationEnabled(bool enable)
+{
+ if (enable) {
+#ifdef Q_OS_SYMBIAN
+ QApplication::setNavigationMode(Qt::NavigationModeKeypadDirectional);
+#else
+ QApplication::setNavigationMode(Qt::NavigationModeKeypadTabOrder);
+#endif
+ }
+ else {
+ QApplication::setNavigationMode(Qt::NavigationModeNone);
+ }
+}
+
+/*!
+ Returns true if Qt is set to use keypad navigation; otherwise returns
+ false. The default value is true on Symbian, but false on other platforms.
+
+ This feature is available in Qt for Embedded Linux, Symbian and Windows CE
+ only.
+
+ \note On Windows CE this feature is disabled by default for touch device
+ mkspecs. To enable keypad navigation, build Qt with
+ QT_KEYPAD_NAVIGATION defined.
+
+ \deprecated
+
+ \sa navigationMode()
+*/
+bool QApplication::keypadNavigationEnabled()
+{
+ return QApplicationPrivate::navigationMode == Qt::NavigationModeKeypadTabOrder ||
+ QApplicationPrivate::navigationMode == Qt::NavigationModeKeypadDirectional;
+}
+#endif
+
+/*!
+ \fn void QApplication::alert(QWidget *widget, int msec)
+ \since 4.3
+
+ Causes an alert to be shown for \a widget if the window is not the active
+ window. The alert is shown for \a msec miliseconds. If \a msec is zero (the
+ default), then the alert is shown indefinitely until the window becomes
+ active again.
+
+ Currently this function does nothing on Qt for Embedded Linux.
+
+ On Mac OS X, this works more at the application level and will cause the
+ application icon to bounce in the dock.
+
+ On Windows, this causes the window's taskbar entry to flash for a time. If
+ \a msec is zero, the flashing will stop and the taskbar entry will turn a
+ different color (currently orange).
+
+ On X11, this will cause the window to be marked as "demands attention", the
+ window must not be hidden (i.e. not have hide() called on it, but be
+ visible in some sort of way) in order for this to work.
+*/
+
+/*!
+ \property QApplication::cursorFlashTime
+ \brief the text cursor's flash (blink) time in milliseconds
+
+ The flash time is the time required to display, invert and restore the
+ caret display. Usually the text cursor is displayed for half the cursor
+ flash time, then hidden for the same amount of time, but this may vary.
+
+ The default value on X11 is 1000 milliseconds. On Windows, the
+ \gui{Control Panel} value is used and setting this property sets the cursor
+ flash time for all applications.
+
+ We recommend that widgets do not cache this value as it may change at any
+ time if the user changes the global desktop settings.
+*/
+
+/*!
+ \property QApplication::doubleClickInterval
+ \brief the time limit in milliseconds that distinguishes a double click
+ from two consecutive mouse clicks
+
+ The default value on X11 is 400 milliseconds. On Windows and Mac OS, the
+ operating system's value is used. However, on Windows and Symbian OS,
+ calling this function sets the double click interval for all applications.
+*/
+
+/*!
+ \property QApplication::keyboardInputInterval
+ \brief the time limit in milliseconds that distinguishes a key press
+ from two consecutive key presses
+ \since 4.2
+
+ The default value on X11 is 400 milliseconds. On Windows and Mac OS, the
+ operating system's value is used.
+*/
+
+/*!
+ \property QApplication::wheelScrollLines
+ \brief the number of lines to scroll a widget, when the
+ mouse wheel is rotated.
+
+ If the value exceeds the widget's number of visible lines, the widget
+ should interpret the scroll operation as a single \e{page up} or
+ \e{page down}. If the widget is an \l{QAbstractItemView}{item view class},
+ then the result of scrolling one \e line depends on the setting of the
+ widget's \l{QAbstractItemView::verticalScrollMode()}{scroll mode}. Scroll
+ one \e line can mean \l{QAbstractItemView::ScrollPerItem}{scroll one item}
+ or \l{QAbstractItemView::ScrollPerPixel}{scroll one pixel}.
+
+ By default, this property has a value of 3.
+*/
+
+/*!
+ \fn void QApplication::setEffectEnabled(Qt::UIEffect effect, bool enable)
+
+ Enables the UI effect \a effect if \a enable is true, otherwise the effect
+ will not be used.
+
+ \note All effects are disabled on screens running at less than 16-bit color
+ depth.
+
+ \sa isEffectEnabled(), Qt::UIEffect, setDesktopSettingsAware()
+*/
+
+/*!
+ \fn bool QApplication::isEffectEnabled(Qt::UIEffect effect)
+
+ Returns true if \a effect is enabled; otherwise returns false.
+
+ By default, Qt will try to use the desktop settings. To prevent this, call
+ setDesktopSettingsAware(false).
+
+ \note All effects are disabled on screens running at less than 16-bit color
+ depth.
+
+ \sa setEffectEnabled(), Qt::UIEffect
+*/
+
+/*!
+ \fn QWidget *QApplication::mainWidget()
+
+ Returns the main application widget, or 0 if there is no main widget.
+*/
+
+/*!
+ \fn void QApplication::setMainWidget(QWidget *mainWidget)
+
+ Sets the application's main widget to \a mainWidget.
+
+ In most respects the main widget is like any other widget, except that if
+ it is closed, the application exits. QApplication does \e not take
+ ownership of the \a mainWidget, so if you create your main widget on the
+ heap you must delete it yourself.
+
+ You need not have a main widget; connecting lastWindowClosed() to quit()
+ is an alternative.
+
+ On X11, this function also resizes and moves the main widget according
+ to the \e -geometry command-line option, so you should set the default
+ geometry (using \l QWidget::setGeometry()) before calling setMainWidget().
+
+ \sa mainWidget(), exec(), quit()
+*/
+
+/*!
+ \fn void QApplication::beep()
+
+ Sounds the bell, using the default volume and sound. The function is \e not
+ available in Qt for Embedded Linux.
+*/
+
+/*!
+ \fn void QApplication::setOverrideCursor(const QCursor &cursor)
+
+ Sets the application override cursor to \a cursor.
+
+ Application override cursors are intended for showing the user that the
+ application is in a special state, for example during an operation that
+ might take some time.
+
+ This cursor will be displayed in all the application's widgets until
+ restoreOverrideCursor() or another setOverrideCursor() is called.
+
+ Application cursors are stored on an internal stack. setOverrideCursor()
+ pushes the cursor onto the stack, and restoreOverrideCursor() pops the
+ active cursor off the stack. changeOverrideCursor() changes the curently
+ active application override cursor.
+
+ Every setOverrideCursor() must eventually be followed by a corresponding
+ restoreOverrideCursor(), otherwise the stack will never be emptied.
+
+ Example:
+ \snippet doc/src/snippets/code/src_gui_kernel_qapplication_x11.cpp 0
+
+ \sa overrideCursor(), restoreOverrideCursor(), changeOverrideCursor(),
+ QWidget::setCursor()
+*/
+
+/*!
+ \fn void QApplication::restoreOverrideCursor()
+
+ Undoes the last setOverrideCursor().
+
+ If setOverrideCursor() has been called twice, calling
+ restoreOverrideCursor() will activate the first cursor set. Calling this
+ function a second time restores the original widgets' cursors.
+
+ \sa setOverrideCursor(), overrideCursor()
+*/
+
+/*!
+ \macro qApp
+ \relates QApplication
+
+ A global pointer referring to the unique application object. It is
+ equivalent to the pointer returned by the QCoreApplication::instance()
+ function except that, in GUI applications, it is a pointer to a
+ QApplication instance.
+
+ Only one application object can be created.
+
+ \sa QCoreApplication::instance()
+*/
+
+#ifndef QT_NO_IM
+// ************************************************************************
+// Input Method support
+// ************************************************************************
+
+/*!
+ This function replaces the QInputContext instance used by the application
+ with \a inputContext.
+
+ Qt takes ownership of the given \a inputContext.
+
+ \sa inputContext()
+*/
+void QApplication::setInputContext(QInputContext *inputContext)
+{
+ if (inputContext == QApplicationPrivate::inputContext)
+ return;
+ if (!inputContext) {
+ qWarning("QApplication::setInputContext: called with 0 input context");
+ return;
+ }
+ delete QApplicationPrivate::inputContext;
+ QApplicationPrivate::inputContext = inputContext;
+ QApplicationPrivate::inputContext->setParent(this);
+}
+
+/*!
+ Returns the QInputContext instance used by the application.
+
+ \sa setInputContext()
+*/
+QInputContext *QApplication::inputContext() const
+{
+ Q_D(const QApplication);
+ Q_UNUSED(d);// only static members being used.
+ if (QApplicationPrivate::is_app_closing)
+ return d->inputContext;
+#ifdef Q_WS_X11
+ if (!X11)
+ return 0;
+ if (!d->inputContext) {
+ QApplication *that = const_cast<QApplication *>(this);
+ QInputContext *qic = QInputContextFactory::create(X11->default_im, that);
+ // fallback to default X Input Method.
+ if (!qic)
+ qic = QInputContextFactory::create(QLatin1String("xim"), that);
+ that->d_func()->inputContext = qic;
+ }
+#elif defined(Q_OS_SYMBIAN)
+ if (!d->inputContext) {
+ QApplication *that = const_cast<QApplication *>(this);
+ const QStringList keys = QInputContextFactory::keys();
+ // Try hbim and coefep first, then try others.
+ if (keys.contains(QLatin1String("hbim"))) {
+ that->d_func()->inputContext = QInputContextFactory::create(QLatin1String("hbim"), that);
+ } else if (keys.contains(QLatin1String("coefep"))) {
+ that->d_func()->inputContext = QInputContextFactory::create(QLatin1String("coefep"), that);
+ } else {
+ for (int c = 0; c < keys.size() && !d->inputContext; ++c) {
+ that->d_func()->inputContext = QInputContextFactory::create(keys[c], that);
+ }
+ }
+ }
+#endif
+ return d->inputContext;
+}
+#endif // QT_NO_IM
+
+bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event)
+{
+ return QApplicationBase::sendSpontaneousEvent(receiver, event);
+}
+
+
+void QApplicationPrivate::giveFocusAccordingToFocusPolicy(QWidget *widget,
+ Qt::FocusPolicy focusPolicy,
+ Qt::FocusReason focusReason)
+{
+ QWidget *focusWidget = widget;
+ while (focusWidget) {
+ if (focusWidget->isEnabled()
+ && QApplicationPrivate::shouldSetFocus(focusWidget, focusPolicy)) {
+ focusWidget->setFocus(focusReason);
+ break;
+ }
+ if (focusWidget->isWindow())
+ break;
+ focusWidget = focusWidget->parentWidget();
+ }
+}
+
+bool QApplicationPrivate::shouldSetFocus(QWidget *w, Qt::FocusPolicy policy)
+{
+ QWidget *f = w;
+ while (f->d_func()->extra && f->d_func()->extra->focus_proxy)
+ f = f->d_func()->extra->focus_proxy;
+
+ if ((w->focusPolicy() & policy) != policy)
+ return false;
+ if (w != f && (f->focusPolicy() & policy) != policy)
+ return false;
+ return true;
+}
+
+/*! \fn QDecoration &QApplication::qwsDecoration()
+ Return the QWSDecoration used for decorating windows.
+
+ \warning This method is non-portable. It is only available in
+ Qt for Embedded Linux.
+
+ \sa QDecoration
+*/
+
+/*!
+ \fn void QApplication::qwsSetDecoration(QDecoration *decoration)
+
+ Sets the QDecoration derived class to use for decorating the
+ windows used by Qt for Embedded Linux to the \a decoration
+ specified.
+
+ This method is non-portable. It is only available in Qt for Embedded Linux.
+
+ \sa QDecoration
+*/
+
+/*! \fn QDecoration* QApplication::qwsSetDecoration(const QString &decoration)
+ \overload
+
+ Requests a QDecoration object for \a decoration from the
+ QDecorationFactory.
+
+ The string must be one of the QDecorationFactory::keys(). Keys are case
+ insensitive.
+
+ A later call to the QApplication constructor will override the requested
+ style when a "-style" option is passed in as a commandline parameter.
+
+ Returns 0 if an unknown \a decoration is passed, otherwise the QStyle object
+ returned is set as the application's GUI style.
+*/
+
+/*!
+ \fn bool QApplication::qwsEventFilter(QWSEvent *event)
+
+ This virtual function is only implemented under Qt for Embedded Linux.
+
+ If you create an application that inherits QApplication and
+ reimplement this function, you get direct access to all QWS (Q
+ Window System) events that the are received from the QWS master
+ process. The events are passed in the \a event parameter.
+
+ Return true if you want to stop the event from being processed.
+ Return false for normal event dispatching. The default
+ implementation returns false.
+*/
+
+/*! \fn void QApplication::qwsSetCustomColors(QRgb *colorTable, int start, int numColors)
+ Set Qt for Embedded Linux custom color table.
+
+ Qt for Embedded Linux on 8-bpp displays allocates a standard 216 color cube.
+ The remaining 40 colors may be used by setting a custom color
+ table in the QWS master process before any clients connect.
+
+ \a colorTable is an array of up to 40 custom colors. \a start is
+ the starting index (0-39) and \a numColors is the number of colors
+ to be set (1-40).
+
+ This method is non-portable. It is available \e only in
+ Qt for Embedded Linux.
+
+ \note The custom colors will not be used by the default screen
+ driver. To make use of the new colors, implement a custom screen
+ driver, or use QDirectPainter.
+*/
+
+/*! \fn int QApplication::qwsProcessEvent(QWSEvent* event)
+ \internal
+*/
+
+/*! \fn int QApplication::x11ClientMessage(QWidget* w, XEvent* event, bool passive_only)
+ \internal
+*/
+
+/*! \fn int QApplication::x11ProcessEvent(XEvent* event)
+ This function does the core processing of individual X
+ \a{event}s, normally by dispatching Qt events to the right
+ destination.
+
+ It returns 1 if the event was consumed by special handling, 0 if
+ the \a event was consumed by normal handling, and -1 if the \a
+ event was for an unrecognized widget.
+
+ \sa x11EventFilter()
+*/
+
+/*!
+ \fn bool QApplication::x11EventFilter(XEvent *event)
+
+ \warning This virtual function is only implemented under X11.
+
+ If you create an application that inherits QApplication and
+ reimplement this function, you get direct access to all X events
+ that the are received from the X server. The events are passed in
+ the \a event parameter.
+
+ Return true if you want to stop the event from being processed.
+ Return false for normal event dispatching. The default
+ implementation returns false.
+
+ It is only the directly addressed messages that are filtered.
+ You must install an event filter directly on the event
+ dispatcher, which is returned by
+ QAbstractEventDispatcher::instance(), to handle system wide
+ messages.
+
+ \sa x11ProcessEvent()
+*/
+
+/*! \fn void QApplication::winFocus(QWidget *widget, bool gotFocus)
+ \internal
+ \since 4.1
+
+ If \a gotFocus is true, \a widget will become the active window.
+ Otherwise the active window is reset to 0.
+*/
+
+/*! \fn void QApplication::winMouseButtonUp()
+ \internal
+ */
+
+/*! \fn void QApplication::syncX()
+ Synchronizes with the X server in the X11 implementation.
+ This normally takes some time. Does nothing on other platforms.
+*/
+
+void QApplicationPrivate::updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent)
+{
+ for (int i = 0; i < touchEvent->touchPoints().count(); ++i) {
+ QTouchEvent::TouchPoint &touchPoint = touchEvent->_touchPoints[i];
+
+ // preserve the sub-pixel resolution
+ QRectF rect = touchPoint.screenRect();
+ const QPointF screenPos = rect.center();
+ const QPointF delta = screenPos - screenPos.toPoint();
+
+ rect.moveCenter(widget->mapFromGlobal(screenPos.toPoint()) + delta);
+ touchPoint.d->rect = rect;
+ if (touchPoint.state() == Qt::TouchPointPressed) {
+ touchPoint.d->startPos = widget->mapFromGlobal(touchPoint.startScreenPos().toPoint()) + delta;
+ touchPoint.d->lastPos = widget->mapFromGlobal(touchPoint.lastScreenPos().toPoint()) + delta;
+ }
+ }
+}
+
+void QApplicationPrivate::initializeMultitouch()
+{
+ widgetForTouchPointId.clear();
+ appCurrentTouchPoints.clear();
+
+ initializeMultitouch_sys();
+}
+
+void QApplicationPrivate::cleanupMultitouch()
+{
+ cleanupMultitouch_sys();
+
+ widgetForTouchPointId.clear();
+ appCurrentTouchPoints.clear();
+}
+
+int QApplicationPrivate::findClosestTouchPointId(const QPointF &screenPos)
+{
+ int closestTouchPointId = -1;
+ qreal closestDistance = qreal(0.);
+ foreach (const QTouchEvent::TouchPoint &touchPoint, appCurrentTouchPoints) {
+ qreal distance = QLineF(screenPos, touchPoint.screenPos()).length();
+ if (closestTouchPointId == -1 || distance < closestDistance) {
+ closestTouchPointId = touchPoint.id();
+ closestDistance = distance;
+ }
+ }
+ return closestTouchPointId;
+}
+
+void QApplicationPrivate::translateRawTouchEvent(QWidget *window,
+ QTouchEvent::DeviceType deviceType,
+ const QList<QTouchEvent::TouchPoint> &touchPoints)
+{
+ QApplicationPrivate *d = self;
+ typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint> > StatesAndTouchPoints;
+ QHash<QWidget *, StatesAndTouchPoints> widgetsNeedingEvents;
+
+ for (int i = 0; i < touchPoints.count(); ++i) {
+ QTouchEvent::TouchPoint touchPoint = touchPoints.at(i);
+ // explicitly detach from the original touch point that we got, so even
+ // if the touchpoint structs are reused, we will make a copy that we'll
+ // deliver to the user (which might want to store the struct for later use).
+ touchPoint.d = touchPoint.d->detach();
+
+ // update state
+ QWeakPointer<QWidget> widget;
+ switch (touchPoint.state()) {
+ case Qt::TouchPointPressed:
+ {
+ if (deviceType == QTouchEvent::TouchPad) {
+ // on touch-pads, send all touch points to the same widget
+ widget = d->widgetForTouchPointId.isEmpty()
+ ? QWeakPointer<QWidget>()
+ : d->widgetForTouchPointId.constBegin().value();
+ }
+
+ if (!widget) {
+ // determine which widget this event will go to
+ if (!window)
+ window = QApplication::topLevelAt(touchPoint.screenPos().toPoint());
+ if (!window)
+ continue;
+ widget = window->childAt(window->mapFromGlobal(touchPoint.screenPos().toPoint()));
+ if (!widget)
+ widget = window;
+ }
+
+ if (deviceType == QTouchEvent::TouchScreen) {
+ int closestTouchPointId = d->findClosestTouchPointId(touchPoint.screenPos());
+ QWidget *closestWidget = d->widgetForTouchPointId.value(closestTouchPointId).data();
+ if (closestWidget
+ && (widget.data()->isAncestorOf(closestWidget) || closestWidget->isAncestorOf(widget.data()))) {
+ widget = closestWidget;
+ }
+ }
+
+ d->widgetForTouchPointId[touchPoint.id()] = widget;
+ touchPoint.d->startScreenPos = touchPoint.screenPos();
+ touchPoint.d->lastScreenPos = touchPoint.screenPos();
+ touchPoint.d->startNormalizedPos = touchPoint.normalizedPos();
+ touchPoint.d->lastNormalizedPos = touchPoint.normalizedPos();
+ if (touchPoint.pressure() < qreal(0.))
+ touchPoint.d->pressure = qreal(1.);
+
+ d->appCurrentTouchPoints.insert(touchPoint.id(), touchPoint);
+ break;
+ }
+ case Qt::TouchPointReleased:
+ {
+ widget = d->widgetForTouchPointId.take(touchPoint.id());
+ if (!widget)
+ continue;
+
+ QTouchEvent::TouchPoint previousTouchPoint = d->appCurrentTouchPoints.take(touchPoint.id());
+ touchPoint.d->startScreenPos = previousTouchPoint.startScreenPos();
+ touchPoint.d->lastScreenPos = previousTouchPoint.screenPos();
+ touchPoint.d->startPos = previousTouchPoint.startPos();
+ touchPoint.d->lastPos = previousTouchPoint.pos();
+ touchPoint.d->startNormalizedPos = previousTouchPoint.startNormalizedPos();
+ touchPoint.d->lastNormalizedPos = previousTouchPoint.normalizedPos();
+ if (touchPoint.pressure() < qreal(0.))
+ touchPoint.d->pressure = qreal(0.);
+ break;
+ }
+ default:
+ widget = d->widgetForTouchPointId.value(touchPoint.id());
+ if (!widget)
+ continue;
+
+ Q_ASSERT(d->appCurrentTouchPoints.contains(touchPoint.id()));
+ QTouchEvent::TouchPoint previousTouchPoint = d->appCurrentTouchPoints.value(touchPoint.id());
+ touchPoint.d->startScreenPos = previousTouchPoint.startScreenPos();
+ touchPoint.d->lastScreenPos = previousTouchPoint.screenPos();
+ touchPoint.d->startPos = previousTouchPoint.startPos();
+ touchPoint.d->lastPos = previousTouchPoint.pos();
+ touchPoint.d->startNormalizedPos = previousTouchPoint.startNormalizedPos();
+ touchPoint.d->lastNormalizedPos = previousTouchPoint.normalizedPos();
+ if (touchPoint.pressure() < qreal(0.))
+ touchPoint.d->pressure = qreal(1.);
+ d->appCurrentTouchPoints[touchPoint.id()] = touchPoint;
+ break;
+ }
+ Q_ASSERT(widget.data() != 0);
+
+ // make the *scene* functions return the same as the *screen* functions
+ touchPoint.d->sceneRect = touchPoint.screenRect();
+ touchPoint.d->startScenePos = touchPoint.startScreenPos();
+ touchPoint.d->lastScenePos = touchPoint.lastScreenPos();
+
+ StatesAndTouchPoints &maskAndPoints = widgetsNeedingEvents[widget.data()];
+ maskAndPoints.first |= touchPoint.state();
+ if (touchPoint.isPrimary())
+ maskAndPoints.first |= Qt::TouchPointPrimary;
+ maskAndPoints.second.append(touchPoint);
+ }
+
+ if (widgetsNeedingEvents.isEmpty())
+ return;
+
+ QHash<QWidget *, StatesAndTouchPoints>::ConstIterator it = widgetsNeedingEvents.constBegin();
+ const QHash<QWidget *, StatesAndTouchPoints>::ConstIterator end = widgetsNeedingEvents.constEnd();
+ for (; it != end; ++it) {
+ QWidget *widget = it.key();
+ if (!QApplicationPrivate::tryModalHelper(widget, 0))
+ continue;
+
+ QEvent::Type eventType;
+ switch (it.value().first & Qt::TouchPointStateMask) {
+ case Qt::TouchPointPressed:
+ eventType = QEvent::TouchBegin;
+ break;
+ case Qt::TouchPointReleased:
+ eventType = QEvent::TouchEnd;
+ break;
+ case Qt::TouchPointStationary:
+ // don't send the event if nothing changed
+ continue;
+ default:
+ eventType = QEvent::TouchUpdate;
+ break;
+ }
+
+ QTouchEvent touchEvent(eventType,
+ deviceType,
+ QApplication::keyboardModifiers(),
+ it.value().first,
+ it.value().second);
+ updateTouchPointsForWidget(widget, &touchEvent);
+
+ switch (touchEvent.type()) {
+ case QEvent::TouchBegin:
+ {
+ // if the TouchBegin handler recurses, we assume that means the event
+ // has been implicitly accepted and continue to send touch events
+ widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent);
+ (void ) QApplication::sendSpontaneousEvent(widget, &touchEvent);
+ break;
+ }
+ default:
+ if (widget->testAttribute(Qt::WA_WState_AcceptedTouchBeginEvent)) {
+ if (touchEvent.type() == QEvent::TouchEnd)
+ widget->setAttribute(Qt::WA_WState_AcceptedTouchBeginEvent, false);
+ (void) QApplication::sendSpontaneousEvent(widget, &touchEvent);
+ }
+ break;
+ }
+ }
+}
+
+Q_GUI_EXPORT void qt_translateRawTouchEvent(QWidget *window,
+ QTouchEvent::DeviceType deviceType,
+ const QList<QTouchEvent::TouchPoint> &touchPoints)
+{
+ QApplicationPrivate::translateRawTouchEvent(window, deviceType, touchPoints);
+}
+
+#ifndef QT_NO_GESTURES
+QGestureManager* QGestureManager::instance()
+{
+ QApplicationPrivate *qAppPriv = QApplicationPrivate::instance();
+ if (!qAppPriv)
+ return 0;
+ if (!qAppPriv->gestureManager)
+ qAppPriv->gestureManager = new QGestureManager(qApp);
+ return qAppPriv->gestureManager;
+}
+#endif // QT_NO_GESTURES
+
+QString QApplicationPrivate::qmljsDebugArgumentsString()
+{
+ return qmljs_debug_arguments;
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qapplication.cpp"
diff --git a/src/widgets/kernel/qapplication.h b/src/widgets/kernel/qapplication.h
new file mode 100644
index 0000000000..16c7c7f4c3
--- /dev/null
+++ b/src/widgets/kernel/qapplication.h
@@ -0,0 +1,422 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QAPPLICATION_H
+#define QAPPLICATION_H
+
+#include <QtCore/qcoreapplication.h>
+#include <QtGui/qwindowdefs.h>
+#include <QtCore/qpoint.h>
+#include <QtCore/qsize.h>
+#include <QtGui/qcursor.h>
+#ifdef QT_INCLUDE_COMPAT
+# include <QtWidgets/qdesktopwidget.h>
+#endif
+#ifdef QT3_SUPPORT
+# include <QtWidgets/qwidget.h>
+# include <QtGui/qpalette.h>
+#endif
+#ifdef Q_WS_QWS
+# include <QtGui/qrgb.h>
+# include <QtGui/qtransportauth_qws.h>
+#endif
+#ifdef Q_WS_QPA
+# include <QtGui/qguiapplication.h>
+#endif
+
+QT_BEGIN_HEADER
+
+#if defined(Q_OS_SYMBIAN)
+class CApaApplication;
+#endif
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QSessionManager;
+class QDesktopWidget;
+class QStyle;
+class QEventLoop;
+class QIcon;
+class QInputContext;
+template <typename T> class QList;
+class QLocale;
+#if defined(Q_WS_QWS)
+class QDecoration;
+#elif defined(Q_WS_QPA)
+class QPlatformNativeInterface;
+#endif
+#if defined(Q_OS_SYMBIAN)
+class QSymbianEvent;
+#endif
+
+class QApplication;
+class QApplicationPrivate;
+#if defined(qApp)
+#undef qApp
+#endif
+#define qApp (static_cast<QApplication *>(QCoreApplication::instance()))
+
+#ifdef Q_WS_QPA
+#define QApplicationBase QGuiApplication
+#else
+#define QApplicationBase QCoreApplication
+#endif
+
+class Q_GUI_EXPORT QApplication : public QApplicationBase
+{
+ Q_OBJECT
+ Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon)
+ Q_PROPERTY(int cursorFlashTime READ cursorFlashTime WRITE setCursorFlashTime)
+ Q_PROPERTY(int doubleClickInterval READ doubleClickInterval WRITE setDoubleClickInterval)
+ Q_PROPERTY(int keyboardInputInterval READ keyboardInputInterval WRITE setKeyboardInputInterval)
+#ifndef QT_NO_WHEELEVENT
+ Q_PROPERTY(int wheelScrollLines READ wheelScrollLines WRITE setWheelScrollLines)
+#endif
+ Q_PROPERTY(QSize globalStrut READ globalStrut WRITE setGlobalStrut)
+ Q_PROPERTY(int startDragTime READ startDragTime WRITE setStartDragTime)
+ Q_PROPERTY(int startDragDistance READ startDragDistance WRITE setStartDragDistance)
+ Q_PROPERTY(bool quitOnLastWindowClosed READ quitOnLastWindowClosed WRITE setQuitOnLastWindowClosed)
+#ifndef QT_NO_STYLE_STYLESHEET
+ Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
+#endif
+#ifdef Q_WS_WINCE
+ Q_PROPERTY(int autoMaximizeThreshold READ autoMaximizeThreshold WRITE setAutoMaximizeThreshold)
+#endif
+ Q_PROPERTY(bool autoSipEnabled READ autoSipEnabled WRITE setAutoSipEnabled)
+
+public:
+ enum Type { Tty, GuiClient, GuiServer };
+
+#ifdef Q_OS_SYMBIAN
+ typedef CApaApplication * (*QS60MainApplicationFactory)();
+#endif
+
+#ifndef qdoc
+ QApplication(int &argc, char **argv, int = ApplicationFlags);
+ QApplication(int &argc, char **argv, bool GUIenabled, int = ApplicationFlags);
+ QApplication(int &argc, char **argv, Type, int = ApplicationFlags);
+#if defined(Q_WS_X11)
+ QApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0, int = ApplicationFlags);
+ QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0, int = ApplicationFlags);
+#endif
+#if defined(Q_OS_SYMBIAN)
+ QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv, int = ApplicationFlags);
+#endif
+#endif
+ virtual ~QApplication();
+
+ static Type type();
+
+ static QStyle *style();
+ static void setStyle(QStyle*);
+ static QStyle *setStyle(const QString&);
+ enum ColorSpec { NormalColor=0, CustomColor=1, ManyColor=2 };
+ static int colorSpec();
+ static void setColorSpec(int);
+ // ### Qt4 compatibility, remove?
+ static inline void setGraphicsSystem(const QString &) {}
+
+ using QGuiApplication::palette;
+ static QPalette palette(const QWidget *);
+ static QPalette palette(const char *className);
+ static void setPalette(const QPalette &, const char* className = 0);
+ static QFont font();
+ static QFont font(const QWidget*);
+ static QFont font(const char *className);
+ static void setFont(const QFont &, const char* className = 0);
+ static QFontMetrics fontMetrics();
+
+ static void setWindowIcon(const QIcon &icon);
+ static QIcon windowIcon();
+
+
+#ifdef QT3_SUPPORT
+ static QT3_SUPPORT QWidget *mainWidget();
+ static QT3_SUPPORT void setMainWidget(QWidget *);
+#endif
+
+ static QWidgetList allWidgets();
+ static QWidgetList topLevelWidgets();
+
+ static QDesktopWidget *desktop();
+
+ static QWidget *activePopupWidget();
+ static QWidget *activeModalWidget();
+#if !defined(Q_WS_QPA) && !defined(QT_NO_CLIPBOARD)
+ static QClipboard *clipboard();
+#endif
+ static QWidget *focusWidget();
+
+ static QWidget *activeWindow();
+ static void setActiveWindow(QWidget* act);
+
+ static QWidget *widgetAt(const QPoint &p);
+ static inline QWidget *widgetAt(int x, int y) { return widgetAt(QPoint(x, y)); }
+ static QWidget *topLevelAt(const QPoint &p);
+ static inline QWidget *topLevelAt(int x, int y) { return topLevelAt(QPoint(x, y)); }
+
+ static void syncX();
+ static void beep();
+ static void alert(QWidget *widget, int duration = 0);
+
+ static Qt::KeyboardModifiers keyboardModifiers();
+ static Qt::MouseButtons mouseButtons();
+
+ static void setDesktopSettingsAware(bool);
+ static bool desktopSettingsAware();
+
+ static void setCursorFlashTime(int);
+ static int cursorFlashTime();
+
+ static void setDoubleClickInterval(int);
+ static int doubleClickInterval();
+
+ static void setKeyboardInputInterval(int);
+ static int keyboardInputInterval();
+
+#ifndef QT_NO_WHEELEVENT
+ static void setWheelScrollLines(int);
+ static int wheelScrollLines();
+#endif
+ static void setGlobalStrut(const QSize &);
+ static QSize globalStrut();
+
+ static void setStartDragTime(int ms);
+ static int startDragTime();
+ static void setStartDragDistance(int l);
+ static int startDragDistance();
+
+ static bool isEffectEnabled(Qt::UIEffect);
+ static void setEffectEnabled(Qt::UIEffect, bool enable = true);
+
+#if defined(Q_WS_MAC)
+ virtual bool macEventFilter(EventHandlerCallRef, EventRef);
+#endif
+#if defined(Q_WS_X11)
+ virtual bool x11EventFilter(XEvent *);
+ virtual int x11ClientMessage(QWidget*, XEvent*, bool passive_only);
+ int x11ProcessEvent(XEvent*);
+#endif
+#if defined(Q_OS_SYMBIAN)
+ int symbianProcessEvent(const QSymbianEvent *event);
+ virtual bool symbianEventFilter(const QSymbianEvent *event);
+#endif
+#if defined(Q_WS_QWS)
+ virtual bool qwsEventFilter(QWSEvent *);
+ int qwsProcessEvent(QWSEvent*);
+ void qwsSetCustomColors(QRgb *colortable, int start, int numColors);
+#ifndef QT_NO_QWS_MANAGER
+ static QDecoration &qwsDecoration();
+ static void qwsSetDecoration(QDecoration *);
+ static QDecoration *qwsSetDecoration(const QString &decoration);
+#endif
+#endif
+
+#if defined(Q_WS_QPA)
+ static QPlatformNativeInterface *platformNativeInterface();
+#endif
+
+
+#if defined(Q_WS_WIN)
+ void winFocus(QWidget *, bool);
+ static void winMouseButtonUp();
+#endif
+#ifndef QT_NO_SESSIONMANAGER
+ // session management
+ bool isSessionRestored() const;
+ QString sessionId() const;
+ QString sessionKey() const;
+ virtual void commitData(QSessionManager& sm);
+ virtual void saveState(QSessionManager& sm);
+#endif
+
+#ifndef QT_NO_IM
+ void setInputContext(QInputContext *);
+ QInputContext *inputContext() const;
+#endif
+
+ static int exec();
+ bool notify(QObject *, QEvent *);
+
+
+ static void setQuitOnLastWindowClosed(bool quit);
+ static bool quitOnLastWindowClosed();
+
+#ifdef QT_KEYPAD_NAVIGATION
+ static Q_DECL_DEPRECATED void setKeypadNavigationEnabled(bool);
+ static bool keypadNavigationEnabled();
+ static void setNavigationMode(Qt::NavigationMode mode);
+ static Qt::NavigationMode navigationMode();
+#endif
+
+Q_SIGNALS:
+ void lastWindowClosed();
+ void focusChanged(QWidget *old, QWidget *now);
+#ifndef QT_NO_SESSIONMANAGER
+ void commitDataRequest(QSessionManager &sessionManager);
+ void saveStateRequest(QSessionManager &sessionManager);
+#endif
+
+public:
+ QString styleSheet() const;
+public Q_SLOTS:
+#ifndef QT_NO_STYLE_STYLESHEET
+ void setStyleSheet(const QString& sheet);
+#endif
+#ifdef Q_WS_WINCE
+ void setAutoMaximizeThreshold(const int threshold);
+ int autoMaximizeThreshold() const;
+#endif
+ void setAutoSipEnabled(const bool enabled);
+ bool autoSipEnabled() const;
+ static void closeAllWindows();
+ static void aboutQt();
+
+protected:
+#if defined(Q_WS_QWS)
+ void setArgs(int, char **);
+#endif
+ bool event(QEvent *);
+ bool compressEvent(QEvent *, QObject *receiver, QPostEventList *);
+
+#ifdef QT3_SUPPORT
+public:
+ static inline QT3_SUPPORT void setReverseLayout(bool b) { setLayoutDirection(b?Qt::RightToLeft:Qt::LeftToRight); }
+ static inline bool QT3_SUPPORT reverseLayout() { return layoutDirection() == Qt::RightToLeft; }
+ static QT3_SUPPORT Qt::Alignment horizontalAlignment(Qt::Alignment align);
+ typedef int ColorMode;
+ enum { NormalColors = NormalColor, CustomColors = CustomColor };
+ static inline QT3_SUPPORT ColorMode colorMode() { return static_cast<ColorMode>(colorSpec()); }
+ static inline QT3_SUPPORT void setColorMode(ColorMode mode) { setColorSpec(int(mode)); }
+#if defined(Q_OS_WIN32) || defined(Q_OS_CYGWIN)
+ static QT3_SUPPORT Qt::WindowsVersion winVersion() { return (Qt::WindowsVersion)QSysInfo::WindowsVersion; }
+#endif
+#if defined(Q_OS_MAC)
+ static QT3_SUPPORT Qt::MacintoshVersion macVersion() { return (Qt::MacintoshVersion)QSysInfo::MacintoshVersion; }
+#endif
+# ifndef QT_NO_CURSOR
+ inline static QT3_SUPPORT void setOverrideCursor(const QCursor &cursor, bool replace)
+ { if (replace) changeOverrideCursor(cursor); else setOverrideCursor(cursor); }
+# endif
+ inline static QT3_SUPPORT bool hasGlobalMouseTracking() {return true;}
+ inline static QT3_SUPPORT void setGlobalMouseTracking(bool) {}
+ inline static QT3_SUPPORT void flushX() { flush(); }
+ static inline QT3_SUPPORT void setWinStyleHighlightColor(const QColor &c) {
+ QPalette p(palette());
+ p.setColor(QPalette::Highlight, c);
+ setPalette(p);
+ }
+ static inline QT3_SUPPORT const QColor &winStyleHighlightColor()
+ { return palette().color(QPalette::Active, QPalette::Highlight); }
+ static inline QT3_SUPPORT void setPalette(const QPalette &pal, bool, const char* className = 0)
+ { setPalette(pal, className); }
+ static inline QT3_SUPPORT void setFont(const QFont &font, bool, const char* className = 0)
+ { setFont(font, className); }
+
+ static inline QT3_SUPPORT QWidget *widgetAt(int x, int y, bool child)
+ { QWidget *w = widgetAt(x, y); return child ? w : (w ? w->window() : 0); }
+ static inline QT3_SUPPORT QWidget *widgetAt(const QPoint &p, bool child)
+ { QWidget *w = widgetAt(p); return child ? w : (w ? w->window() : 0); }
+#endif // QT3_SUPPORT
+
+#if defined(Q_INTERNAL_QAPP_SRC) || defined(qdoc)
+ QApplication(int &argc, char **argv);
+ QApplication(int &argc, char **argv, bool GUIenabled);
+ QApplication(int &argc, char **argv, Type);
+#if defined(Q_WS_X11)
+ QApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0);
+ QApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0);
+#endif
+#if defined(Q_OS_SYMBIAN) || defined(qdoc)
+ QApplication(QApplication::QS60MainApplicationFactory factory, int &argc, char **argv);
+#endif
+#endif
+
+private:
+ Q_DISABLE_COPY(QApplication)
+ Q_DECLARE_PRIVATE(QApplication)
+
+ friend class QGraphicsWidget;
+ friend class QGraphicsItem;
+ friend class QGraphicsScene;
+ friend class QGraphicsScenePrivate;
+ friend class QWidget;
+ friend class QWidgetPrivate;
+ friend class QWidgetWindow;
+ friend class QETWidget;
+ friend class Q3AccelManager;
+ friend class QTranslator;
+ friend class QWidgetAnimator;
+#ifndef QT_NO_SHORTCUT
+ friend class QShortcut;
+ friend class QLineEdit;
+ friend class QTextControl;
+#endif
+ friend class QAction;
+
+#if defined(Q_WS_QWS)
+ friend class QInputContext;
+ friend class QWSDirectPainterSurface;
+ friend class QDirectPainter;
+ friend class QDirectPainterPrivate;
+#endif
+#ifndef QT_NO_GESTURES
+ friend class QGestureManager;
+#endif
+
+#if defined(Q_WS_MAC) || defined(Q_WS_X11)
+ Q_PRIVATE_SLOT(d_func(), void _q_alertTimeOut())
+#endif
+#if defined(QT_RX71_MULTITOUCH)
+ Q_PRIVATE_SLOT(d_func(), void _q_readRX71MultiTouchEvents())
+#endif
+#if defined(Q_OS_SYMBIAN)
+ Q_PRIVATE_SLOT(d_func(), void _q_aboutToQuit())
+#endif
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QAPPLICATION_H
diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h
new file mode 100644
index 0000000000..41d3eaeb27
--- /dev/null
+++ b/src/widgets/kernel/qapplication_p.h
@@ -0,0 +1,626 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QAPPLICATION_P_H
+#define QAPPLICATION_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of qapplication_*.cpp, qwidget*.cpp, qcolor_x11.cpp, qfiledialog.cpp
+// and many other. This header file may change from version to version
+// without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "QtWidgets/qapplication.h"
+#include "QtGui/qevent.h"
+#include "QtGui/qfont.h"
+#include "QtGui/qcursor.h"
+#include "QtGui/qregion.h"
+#include "QtCore/qmutex.h"
+#include "QtCore/qtranslator.h"
+#include "QtCore/qbasictimer.h"
+#include "QtCore/qhash.h"
+#include "QtCore/qpointer.h"
+#include "private/qcoreapplication_p.h"
+#include "private/qshortcutmap_p.h"
+#include <private/qthread_p.h>
+#include "QtCore/qpoint.h"
+#include <QTime>
+#ifdef Q_OS_SYMBIAN
+#include <w32std.h>
+#endif
+#ifdef Q_WS_QPA
+#include <QWindowSystemInterface>
+#include "private/qwindowsysteminterface_qpa_p.h"
+#include "QtGui/qplatformintegration_qpa.h"
+#include "private/qguiapplication_p.h"
+#endif
+
+QT_BEGIN_NAMESPACE
+
+class QClipboard;
+class QGraphicsScene;
+class QInputContext;
+class QObject;
+class QWidget;
+class QSocketNotifier;
+#ifndef QT_NO_GESTURES
+class QGestureManager;
+#endif
+
+extern bool qt_is_gui_used;
+#ifndef QT_NO_CLIPBOARD
+extern QClipboard *qt_clipboard;
+#endif
+
+#if defined (Q_OS_WIN32) || defined (Q_OS_CYGWIN) || defined(Q_OS_WINCE)
+extern QSysInfo::WinVersion qt_winver;
+enum { QT_TABLET_NPACKETQSIZE = 128 };
+# ifdef Q_OS_WINCE
+ extern DWORD qt_cever;
+# endif
+#elif defined (Q_OS_MAC)
+extern QSysInfo::MacVersion qt_macver;
+#endif
+#if defined(Q_WS_QWS)
+class QWSManager;
+class QDirectPainter;
+struct QWSServerCleaner { ~QWSServerCleaner(); };
+#endif
+
+#ifndef QT_NO_TABLET
+struct QTabletDeviceData
+{
+#ifndef Q_WS_MAC
+ int minPressure;
+ int maxPressure;
+ int minTanPressure;
+ int maxTanPressure;
+ int minX, maxX, minY, maxY, minZ, maxZ;
+ inline QPointF scaleCoord(int coordX, int coordY, int outOriginX, int outExtentX,
+ int outOriginY, int outExtentY) const;
+#endif
+
+#if defined(Q_WS_X11) || (defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA))
+ QPointer<QWidget> widgetToGetPress;
+#endif
+
+#ifdef Q_WS_X11
+ int deviceType;
+ enum {
+ TOTAL_XINPUT_EVENTS = 64
+ };
+ void *device;
+ int eventCount;
+ long unsigned int eventList[TOTAL_XINPUT_EVENTS]; // XEventClass is in fact a long unsigned int
+
+ int xinput_motion;
+ int xinput_key_press;
+ int xinput_key_release;
+ int xinput_button_press;
+ int xinput_button_release;
+ int xinput_proximity_in;
+ int xinput_proximity_out;
+#elif defined(Q_WS_WIN)
+ qint64 llId;
+ int currentDevice;
+ int currentPointerType;
+#elif defined(Q_WS_MAC)
+ quint64 tabletUniqueID;
+ int tabletDeviceType;
+ int tabletPointerType;
+ int capabilityMask;
+#endif
+};
+
+static inline int sign(int x)
+{
+ return x >= 0 ? 1 : -1;
+}
+
+#ifndef Q_WS_MAC
+inline QPointF QTabletDeviceData::scaleCoord(int coordX, int coordY,
+ int outOriginX, int outExtentX,
+ int outOriginY, int outExtentY) const
+{
+ QPointF ret;
+
+ if (sign(outExtentX) == sign(maxX))
+ ret.setX(((coordX - minX) * qAbs(outExtentX) / qAbs(qreal(maxX - minX))) + outOriginX);
+ else
+ ret.setX(((qAbs(maxX) - (coordX - minX)) * qAbs(outExtentX) / qAbs(qreal(maxX - minX)))
+ + outOriginX);
+
+ if (sign(outExtentY) == sign(maxY))
+ ret.setY(((coordY - minY) * qAbs(outExtentY) / qAbs(qreal(maxY - minY))) + outOriginY);
+ else
+ ret.setY(((qAbs(maxY) - (coordY - minY)) * qAbs(outExtentY) / qAbs(qreal(maxY - minY)))
+ + outOriginY);
+
+ return ret;
+}
+#endif
+
+typedef QList<QTabletDeviceData> QTabletDeviceDataList;
+QTabletDeviceDataList *qt_tablet_devices();
+# if defined(Q_WS_MAC)
+typedef QHash<int, QTabletDeviceData> QMacTabletHash;
+QMacTabletHash *qt_mac_tablet_hash();
+# endif
+#endif
+
+#ifdef QT3_SUPPORT
+extern "C" {
+ typedef bool (*Ptrqt_tryAccelEvent)(QWidget *w, QKeyEvent *e);
+ typedef bool (*Ptrqt_tryComposeUnicode)(QWidget *w, QKeyEvent *e);
+ typedef bool (*Ptrqt_dispatchAccelEvent)(QWidget *w, QKeyEvent *e);
+}
+#endif
+
+#if defined(Q_WS_WIN)
+typedef BOOL (WINAPI *PtrRegisterTouchWindow)(HWND, ULONG);
+typedef BOOL (WINAPI *PtrGetTouchInputInfo)(HANDLE, UINT, PVOID, int);
+typedef BOOL (WINAPI *PtrCloseTouchInputHandle)(HANDLE);
+
+#ifndef QT_NO_GESTURES
+typedef BOOL (WINAPI *PtrGetGestureInfo)(HANDLE, PVOID);
+typedef BOOL (WINAPI *PtrGetGestureExtraArgs)(HANDLE, UINT, PBYTE);
+typedef BOOL (WINAPI *PtrCloseGestureInfoHandle)(HANDLE);
+typedef BOOL (WINAPI *PtrSetGestureConfig)(HWND, DWORD, UINT, PVOID, UINT);
+typedef BOOL (WINAPI *PtrGetGestureConfig)(HWND, DWORD, DWORD, PUINT, PVOID, UINT);
+
+typedef BOOL (WINAPI *PtrBeginPanningFeedback)(HWND);
+typedef BOOL (WINAPI *PtrUpdatePanningFeedback)(HWND, LONG, LONG, BOOL);
+typedef BOOL (WINAPI *PtrEndPanningFeedback)(HWND, BOOL);
+
+#ifndef WM_GESTURE
+# define WM_GESTURE 0x0119
+
+# define GID_BEGIN 1
+# define GID_END 2
+# define GID_ZOOM 3
+# define GID_PAN 4
+# define GID_ROTATE 5
+# define GID_TWOFINGERTAP 6
+# define GID_ROLLOVER 7
+
+typedef struct tagGESTUREINFO
+{
+ UINT cbSize;
+ DWORD dwFlags;
+ DWORD dwID;
+ HWND hwndTarget;
+ POINTS ptsLocation;
+ DWORD dwInstanceID;
+ DWORD dwSequenceID;
+ ULONGLONG ullArguments;
+ UINT cbExtraArgs;
+} GESTUREINFO;
+
+# define GC_PAN 0x00000001
+# define GC_PAN_WITH_SINGLE_FINGER_VERTICALLY 0x00000002
+# define GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY 0x00000004
+
+# define GC_ZOOM 0x00000001
+# define GC_ROTATE 0x00000001
+
+typedef struct tagGESTURECONFIG
+{
+ DWORD dwID;
+ DWORD dwWant;
+ DWORD dwBlock;
+} GESTURECONFIG;
+
+# define GID_ROTATE_ANGLE_FROM_ARGUMENT(arg) ((((double)(arg) / 65535.0) * 4.0 * 3.14159265) - 2.0*3.14159265)
+
+#endif // WM_GESTURE
+
+#if defined(Q_WS_WINCE_WM) && defined(QT_WINCE_GESTURES)
+#undef GID_ZOOM
+#define GID_ZOOM 0xf000
+#undef GID_ROTATE
+#define GID_ROTATE 0xf001
+#undef GID_TWOFINGERTAP
+#define GID_TWOFINGERTAP 0xf002
+#undef GID_ROLLOVER
+#define GID_ROLLOVER 0xf003
+#endif
+
+#endif // QT_NO_GESTURES
+
+#endif // Q_WS_WIN
+
+class QScopedLoopLevelCounter
+{
+ QThreadData *threadData;
+public:
+ QScopedLoopLevelCounter(QThreadData *threadData)
+ : threadData(threadData)
+ { ++threadData->loopLevel; }
+ ~QScopedLoopLevelCounter()
+ { --threadData->loopLevel; }
+};
+
+typedef QHash<QByteArray, QFont> FontHash;
+FontHash *qt_app_fonts_hash();
+
+typedef QHash<QByteArray, QPalette> PaletteHash;
+PaletteHash *qt_app_palettes_hash();
+
+#ifdef Q_WS_QPA
+#define QApplicationPrivateBase QGuiApplicationPrivate
+#else
+#define QApplicationPrivateBase QCoreApplicationPrivate
+#endif
+
+class Q_GUI_EXPORT QApplicationPrivate : public QApplicationPrivateBase
+{
+ Q_DECLARE_PUBLIC(QApplication)
+public:
+ QApplicationPrivate(int &argc, char **argv, QApplication::Type type, int flags);
+ ~QApplicationPrivate();
+
+ virtual void notifyLayoutDirectionChange();
+
+#if defined(Q_WS_X11)
+#ifndef QT_NO_SETTINGS
+ static bool x11_apply_settings();
+#endif
+ static void reset_instance_pointer();
+#elif defined(Q_WS_QWS)
+ static bool qws_apply_settings();
+ static QWidget *findWidget(const QObjectList&, const QPoint &, bool rec);
+#endif
+ static bool quitOnLastWindowClosed;
+ static void emitLastWindowClosed();
+#ifdef Q_WS_WINCE
+ static int autoMaximizeThreshold;
+#endif
+ static bool autoSipEnabled;
+ static QString desktopStyleKey();
+
+
+ void createEventDispatcher();
+ QString appName() const;
+ static void dispatchEnterLeave(QWidget *enter, QWidget *leave);
+
+ //modality
+ static void enterModal(QWidget*);
+ static void leaveModal(QWidget*);
+ static void enterModal_sys(QWidget*);
+ static void leaveModal_sys(QWidget*);
+ static bool isBlockedByModal(QWidget *widget);
+ static bool modalState();
+ static bool tryModalHelper(QWidget *widget, QWidget **rettop = 0);
+#ifdef Q_WS_MAC
+ static QWidget *tryModalHelper_sys(QWidget *top);
+ bool canQuit();
+#endif
+
+ bool notify_helper(QObject *receiver, QEvent * e);
+
+ void construct(
+#ifdef Q_WS_X11
+ Display *dpy = 0, Qt::HANDLE visual = 0, Qt::HANDLE cmap = 0
+#endif
+ );
+ void initialize();
+ void process_cmdline();
+
+#if defined(Q_WS_X11)
+ static void x11_initialize_style();
+#endif
+
+ bool inPopupMode() const;
+ void closePopup(QWidget *popup);
+ void openPopup(QWidget *popup);
+ static void setFocusWidget(QWidget *focus, Qt::FocusReason reason);
+ static QWidget *focusNextPrevChild_helper(QWidget *toplevel, bool next);
+
+#ifndef QT_NO_SESSIONMANAGER
+ QSessionManager *session_manager;
+ QString session_id;
+ QString session_key;
+ bool is_session_restored;
+#endif
+
+#ifndef QT_NO_GRAPHICSVIEW
+ // Maintain a list of all scenes to ensure font and palette propagation to
+ // all scenes.
+ QList<QGraphicsScene *> scene_list;
+#endif
+
+ QBasicTimer toolTipWakeUp, toolTipFallAsleep;
+ QPoint toolTipPos, toolTipGlobalPos, hoverGlobalPos;
+ QPointer<QWidget> toolTipWidget;
+#ifndef QT_NO_SHORTCUT
+ QShortcutMap shortcutMap;
+#endif
+
+#ifdef QT3_SUPPORT
+ bool qt_compat_used;
+ bool qt_compat_resolved;
+ Ptrqt_tryAccelEvent qt_tryAccelEvent;
+ Ptrqt_tryComposeUnicode qt_tryComposeUnicode;
+ Ptrqt_dispatchAccelEvent qt_dispatchAccelEvent;
+
+ bool use_compat() {
+ return qt_tryAccelEvent
+ && qt_tryComposeUnicode
+ && qt_dispatchAccelEvent;
+ }
+#endif
+ static QInputContext *inputContext;
+
+ static Qt::MouseButtons mouse_buttons;
+ static Qt::KeyboardModifiers modifier_buttons;
+
+ static QSize app_strut;
+ static QWidgetList *popupWidgets;
+ static QStyle *app_style;
+ static int app_cspec;
+ static QPalette *sys_pal;
+ static QPalette *set_pal;
+
+private:
+#ifndef Q_WS_QPA
+ static QFont *app_font; // private for a reason! Always use QApplication::font() instead!
+#endif
+public:
+ static QFont *sys_font;
+ static QFont *set_font;
+ static QWidget *main_widget;
+ static QWidget *focus_widget;
+ static QWidget *hidden_focus_widget;
+ static QWidget *active_window;
+ static QIcon *app_icon;
+ static bool obey_desktop_settings;
+ static int cursor_flash_time;
+ static int mouse_double_click_time;
+ static int keyboard_input_time;
+#ifndef QT_NO_WHEELEVENT
+ static int wheel_scroll_lines;
+#endif
+
+ static bool animate_ui;
+ static bool animate_menu;
+ static bool animate_tooltip;
+ static bool animate_combo;
+ static bool fade_menu;
+ static bool fade_tooltip;
+ static bool animate_toolbox;
+ static bool widgetCount; // Coupled with -widgetcount switch
+ static bool load_testability; // Coupled with -testability switch
+ static QString qmljs_debug_arguments; // a string containing arguments for js/qml debugging.
+ static QString qmljsDebugArgumentsString(); // access string from other libraries
+
+#ifdef Q_WS_MAC
+ static bool native_modal_dialog_active;
+#endif
+
+ static void setSystemPalette(const QPalette &pal);
+ static void setPalette_helper(const QPalette &palette, const char* className, bool clearWidgetPaletteHash);
+ static void initializeWidgetPaletteHash();
+ static void setSystemFont(const QFont &font);
+
+#if defined(Q_WS_X11)
+ static void applyX11SpecificCommandLineArguments(QWidget *main_widget);
+#elif defined(Q_WS_QWS)
+ static void applyQWSSpecificCommandLineArguments(QWidget *main_widget);
+#endif
+
+#ifdef Q_WS_MAC
+ static OSStatus globalEventProcessor(EventHandlerCallRef, EventRef, void *);
+ static OSStatus globalAppleEventProcessor(const AppleEvent *, AppleEvent *, long);
+ static OSStatus tabletProximityCallback(EventHandlerCallRef, EventRef, void *);
+#ifdef QT_MAC_USE_COCOA
+ static void qt_initAfterNSAppStarted();
+ static void setupAppleEvents();
+#endif
+ static bool qt_mac_apply_settings();
+#endif
+
+#ifdef Q_WS_QWS
+ QPointer<QWSManager> last_manager;
+ QWSServerCleaner qwsServerCleaner;
+# ifndef QT_NO_DIRECTPAINTER
+ QMap<WId, QDirectPainter *> *directPainters;
+# endif
+ QRect maxWindowRect(const QScreen *screen) const { return maxWindowRects[screen]; }
+ void setMaxWindowRect(const QScreen *screen, int screenNo, const QRect &rect);
+ void setScreenTransformation(QScreen *screen, int screenNo, int transformation);
+#endif
+
+ static QApplicationPrivate *instance() { return self; }
+
+ static QString styleOverride;
+
+#ifdef QT_KEYPAD_NAVIGATION
+ static QWidget *oldEditFocus;
+ static Qt::NavigationMode navigationMode;
+#endif
+
+#if defined(Q_WS_MAC) || defined(Q_WS_X11)
+ void _q_alertTimeOut();
+ QHash<QWidget *, QTimer *> alertTimerHash;
+#endif
+#ifndef QT_NO_STYLE_STYLESHEET
+ static QString styleSheet;
+#endif
+ static QPointer<QWidget> leaveAfterRelease;
+ static QWidget *pickMouseReceiver(QWidget *candidate, const QPoint &globalPos, QPoint &pos,
+ QEvent::Type type, Qt::MouseButtons buttons,
+ QWidget *buttonDown, QWidget *alienWidget);
+ static bool sendMouseEvent(QWidget *receiver, QMouseEvent *event, QWidget *alienWidget,
+ QWidget *native, QWidget **buttonDown, QPointer<QWidget> &lastMouseReceiver,
+ bool spontaneous = true);
+#ifdef Q_OS_SYMBIAN
+ static void setNavigationMode(Qt::NavigationMode mode);
+ static TUint resolveS60ScanCode(TInt scanCode, TUint keysym);
+ QSet<WId> nativeWindows;
+
+ int symbianProcessWsEvent(const QSymbianEvent *symbianEvent);
+ int symbianHandleCommand(const QSymbianEvent *symbianEvent);
+ int symbianResourceChange(const QSymbianEvent *symbianEvent);
+
+ void _q_aboutToQuit();
+#endif
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_QPA)
+ void sendSyntheticEnterLeave(QWidget *widget);
+#endif
+
+#ifndef QT_NO_GESTURES
+ QGestureManager *gestureManager;
+ QWidget *gestureWidget;
+#endif
+#if defined(Q_WS_X11) || defined(Q_WS_WIN)
+ QPixmap *move_cursor;
+ QPixmap *copy_cursor;
+ QPixmap *link_cursor;
+#endif
+#if defined(Q_WS_WIN)
+ QPixmap *ignore_cursor;
+#endif
+
+ QMap<int, QWeakPointer<QWidget> > widgetForTouchPointId;
+ QMap<int, QTouchEvent::TouchPoint> appCurrentTouchPoints;
+ static void updateTouchPointsForWidget(QWidget *widget, QTouchEvent *touchEvent);
+ void initializeMultitouch();
+ void initializeMultitouch_sys();
+ void cleanupMultitouch();
+ void cleanupMultitouch_sys();
+ int findClosestTouchPointId(const QPointF &screenPos);
+ void appendTouchPoint(const QTouchEvent::TouchPoint &touchPoint);
+ void removeTouchPoint(int touchPointId);
+ static void translateRawTouchEvent(QWidget *widget,
+ QTouchEvent::DeviceType deviceType,
+ const QList<QTouchEvent::TouchPoint> &touchPoints);
+
+#if defined(Q_WS_WIN)
+ static bool HasTouchSupport;
+ static PtrRegisterTouchWindow RegisterTouchWindow;
+ static PtrGetTouchInputInfo GetTouchInputInfo;
+ static PtrCloseTouchInputHandle CloseTouchInputHandle;
+
+ QHash<DWORD, int> touchInputIDToTouchPointID;
+ bool translateTouchEvent(const MSG &msg);
+
+#ifndef QT_NO_GESTURES
+ PtrGetGestureInfo GetGestureInfo;
+ PtrGetGestureExtraArgs GetGestureExtraArgs;
+ PtrCloseGestureInfoHandle CloseGestureInfoHandle;
+ PtrSetGestureConfig SetGestureConfig;
+ PtrGetGestureConfig GetGestureConfig;
+ PtrBeginPanningFeedback BeginPanningFeedback;
+ PtrUpdatePanningFeedback UpdatePanningFeedback;
+ PtrEndPanningFeedback EndPanningFeedback;
+#endif // QT_NO_GESTURES
+#endif
+
+#ifdef QT_RX71_MULTITOUCH
+ bool hasRX71MultiTouch;
+
+ struct RX71TouchPointState {
+ QSocketNotifier *socketNotifier;
+ QTouchEvent::TouchPoint touchPoint;
+
+ int minX, maxX, scaleX;
+ int minY, maxY, scaleY;
+ int minZ, maxZ;
+ };
+ QList<RX71TouchPointState> allRX71TouchPoints;
+
+ bool readRX71MultiTouchEvents(int deviceNumber);
+ void fakeMouseEventFromRX71TouchEvent();
+ void _q_readRX71MultiTouchEvents();
+#endif
+
+#if defined(Q_OS_SYMBIAN)
+ int pressureSupported;
+ int maxTouchPressure;
+ QList<QTouchEvent::TouchPoint> appAllTouchPoints;
+
+ bool useTranslucentEGLSurfaces;
+#endif
+
+private:
+#ifdef Q_WS_QWS
+ QMap<const QScreen*, QRect> maxWindowRects;
+#endif
+
+#ifdef Q_OS_SYMBIAN
+ QHash<TInt, TUint> scanCodeCache;
+#endif
+
+ static QApplicationPrivate *self;
+
+ static void giveFocusAccordingToFocusPolicy(QWidget *w,
+ Qt::FocusPolicy focusPolicy,
+ Qt::FocusReason focusReason);
+ static bool shouldSetFocus(QWidget *w, Qt::FocusPolicy policy);
+
+
+ static bool isAlien(QWidget *);
+};
+
+Q_GUI_EXPORT void qt_translateRawTouchEvent(QWidget *window,
+ QTouchEvent::DeviceType deviceType,
+ const QList<QTouchEvent::TouchPoint> &touchPoints);
+
+#if defined(Q_WS_WIN)
+ extern void qt_win_set_cursor(QWidget *, bool);
+#elif defined(Q_WS_X11)
+ extern void qt_x11_enforce_cursor(QWidget *, bool);
+ extern void qt_x11_enforce_cursor(QWidget *);
+#elif defined(Q_OS_SYMBIAN)
+ extern void qt_symbian_set_cursor(QWidget *, bool);
+#else
+ extern void qt_qpa_set_cursor(QWidget * w, bool force);
+#endif
+
+QT_END_NAMESPACE
+
+#endif // QAPPLICATION_P_H
diff --git a/src/widgets/kernel/qapplication_qpa.cpp b/src/widgets/kernel/qapplication_qpa.cpp
new file mode 100644
index 0000000000..3930dc8d68
--- /dev/null
+++ b/src/widgets/kernel/qapplication_qpa.cpp
@@ -0,0 +1,425 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qapplication_p.h"
+#include "qcolormap.h"
+#include "qpixmapcache.h"
+#if !defined(QT_NO_GLIB)
+#include "private/qeventdispatcher_glib_qpa_p.h"
+#endif
+#include "private/qeventdispatcher_qpa_p.h"
+#ifndef QT_NO_CURSOR
+#include "private/qcursor_p.h"
+#endif
+
+#include "private/qwidget_p.h"
+#include "private/qevent_p.h"
+
+#include "qgenericpluginfactory_qpa.h"
+#include "private/qplatformintegrationfactory_qpa_p.h"
+#include <qdesktopwidget.h>
+
+#include <qinputcontext.h>
+#include <QPlatformCursor>
+#include <qdebug.h>
+#include <QWindowSystemInterface>
+#include "private/qwindowsysteminterface_qpa_p.h"
+#include <QPlatformIntegration>
+
+#include "qdesktopwidget_qpa_p.h"
+#include "qwidgetwindow_qpa_p.h"
+
+QT_BEGIN_NAMESPACE
+
+static QString appName;
+static QString appFont;
+
+QString QApplicationPrivate::appName() const
+{
+ return QT_PREPEND_NAMESPACE(appName);
+}
+
+void QApplicationPrivate::createEventDispatcher()
+{
+ QGuiApplicationPrivate::createEventDispatcher();
+}
+
+static bool qt_try_modal(QWidget *widget, QEvent::Type type)
+{
+ QWidget * top = 0;
+
+ if (QApplicationPrivate::tryModalHelper(widget, &top))
+ return true;
+
+ bool block_event = false;
+ bool paint_event = false;
+
+ switch (type) {
+#if 0
+ case QEvent::Focus:
+ if (!static_cast<QWSFocusEvent*>(event)->simpleData.get_focus)
+ break;
+ // drop through
+#endif
+ case QEvent::MouseButtonPress: // disallow mouse/key events
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseMove:
+ case QEvent::KeyPress:
+ case QEvent::KeyRelease:
+ block_event = true;
+ break;
+ default:
+ break;
+ }
+
+ if ((block_event || paint_event) && top->parentWidget() == 0)
+ top->raise();
+
+ return !block_event;
+}
+
+
+
+void QApplicationPrivate::enterModal_sys(QWidget *)
+{
+#if 0
+ if (!qt_modal_stack)
+ qt_modal_stack = new QWidgetList;
+ qt_modal_stack->insert(0, widget);
+ app_do_modal = true;
+#endif
+}
+
+void QApplicationPrivate::leaveModal_sys(QWidget *)
+{
+#if 0
+ if (qt_modal_stack && qt_modal_stack->removeAll(widget)) {
+ if (qt_modal_stack->isEmpty()) {
+ delete qt_modal_stack;
+ qt_modal_stack = 0;
+ }
+ }
+ app_do_modal = qt_modal_stack != 0;
+#endif
+}
+
+bool QApplicationPrivate::modalState()
+{
+ return false;
+#if 0
+ return app_do_modal;
+#endif
+}
+
+void QApplicationPrivate::closePopup(QWidget *popup)
+{
+ Q_Q(QApplication);
+ if (!popupWidgets)
+ return;
+ popupWidgets->removeAll(popup);
+
+//###
+// if (popup == qt_popup_down) {
+// qt_button_down = 0;
+// qt_popup_down = 0;
+// }
+
+ if (QApplicationPrivate::popupWidgets->count() == 0) { // this was the last popup
+ delete QApplicationPrivate::popupWidgets;
+ QApplicationPrivate::popupWidgets = 0;
+
+ //### replay mouse event?
+
+ //### transfer/release mouse grab
+
+ //### transfer/release keyboard grab
+
+ //give back focus
+
+ if (active_window) {
+ if (QWidget *fw = active_window->focusWidget()) {
+ if (fw != QApplication::focusWidget()) {
+ fw->setFocus(Qt::PopupFocusReason);
+ } else {
+ QFocusEvent e(QEvent::FocusIn, Qt::PopupFocusReason);
+ q->sendEvent(fw, &e);
+ }
+ }
+ }
+
+ } else {
+ // A popup was closed, so the previous popup gets the focus.
+
+ QWidget* aw = QApplicationPrivate::popupWidgets->last();
+ if (QWidget *fw = aw->focusWidget())
+ fw->setFocus(Qt::PopupFocusReason);
+
+ //### regrab the keyboard and mouse in case 'popup' lost the grab
+
+
+ }
+
+}
+
+static int openPopupCount = 0;
+void QApplicationPrivate::openPopup(QWidget *popup)
+{
+ openPopupCount++;
+ if (!popupWidgets) { // create list
+ popupWidgets = new QWidgetList;
+
+ /* only grab if you are the first/parent popup */
+ //#### ->grabMouse(popup,true);
+ //#### ->grabKeyboard(popup,true);
+ //### popupGrabOk = true;
+ }
+ popupWidgets->append(popup); // add to end of list
+
+ // popups are not focus-handled by the window system (the first
+ // popup grabbed the keyboard), so we have to do that manually: A
+ // new popup gets the focus
+ if (popup->focusWidget()) {
+ popup->focusWidget()->setFocus(Qt::PopupFocusReason);
+ } else if (popupWidgets->count() == 1) { // this was the first popup
+ if (QWidget *fw = QApplication::focusWidget()) {
+ QFocusEvent e(QEvent::FocusOut, Qt::PopupFocusReason);
+ QApplication::sendEvent(fw, &e);
+ }
+ }
+}
+
+void QApplicationPrivate::initializeMultitouch_sys()
+{
+}
+
+void QApplicationPrivate::cleanupMultitouch_sys()
+{
+}
+
+void QApplicationPrivate::initializeWidgetPaletteHash()
+{
+}
+
+void QApplication::setCursorFlashTime(int msecs)
+{
+ QApplicationPrivate::cursor_flash_time = msecs;
+}
+
+int QApplication::cursorFlashTime()
+{
+ return QApplicationPrivate::cursor_flash_time;
+}
+
+void QApplication::setDoubleClickInterval(int ms)
+{
+ QApplicationPrivate::mouse_double_click_time = ms;
+}
+
+int QApplication::doubleClickInterval()
+{
+ return QApplicationPrivate::mouse_double_click_time;
+}
+
+void QApplication::setKeyboardInputInterval(int ms)
+{
+ QApplicationPrivate::keyboard_input_time = ms;
+}
+
+int QApplication::keyboardInputInterval()
+{
+ return QApplicationPrivate::keyboard_input_time;
+}
+
+#ifndef QT_NO_WHEELEVENT
+void QApplication::setWheelScrollLines(int lines)
+{
+ QApplicationPrivate::wheel_scroll_lines = lines;
+}
+
+int QApplication::wheelScrollLines()
+{
+ return QApplicationPrivate::wheel_scroll_lines;
+}
+#endif
+
+void QApplication::setEffectEnabled(Qt::UIEffect effect, bool enable)
+{
+ switch (effect) {
+ case Qt::UI_AnimateMenu:
+ QApplicationPrivate::animate_menu = enable;
+ break;
+ case Qt::UI_FadeMenu:
+ if (enable)
+ QApplicationPrivate::animate_menu = true;
+ QApplicationPrivate::fade_menu = enable;
+ break;
+ case Qt::UI_AnimateCombo:
+ QApplicationPrivate::animate_combo = enable;
+ break;
+ case Qt::UI_AnimateTooltip:
+ QApplicationPrivate::animate_tooltip = enable;
+ break;
+ case Qt::UI_FadeTooltip:
+ if (enable)
+ QApplicationPrivate::animate_tooltip = true;
+ QApplicationPrivate::fade_tooltip = enable;
+ break;
+ case Qt::UI_AnimateToolBox:
+ QApplicationPrivate::animate_toolbox = enable;
+ break;
+ default:
+ QApplicationPrivate::animate_ui = enable;
+ break;
+ }
+}
+
+bool QApplication::isEffectEnabled(Qt::UIEffect effect)
+{
+ if (QColormap::instance().depth() < 16 || !QApplicationPrivate::animate_ui)
+ return false;
+
+ switch(effect) {
+ case Qt::UI_AnimateMenu:
+ return QApplicationPrivate::animate_menu;
+ case Qt::UI_FadeMenu:
+ return QApplicationPrivate::fade_menu;
+ case Qt::UI_AnimateCombo:
+ return QApplicationPrivate::animate_combo;
+ case Qt::UI_AnimateTooltip:
+ return QApplicationPrivate::animate_tooltip;
+ case Qt::UI_FadeTooltip:
+ return QApplicationPrivate::fade_tooltip;
+ case Qt::UI_AnimateToolBox:
+ return QApplicationPrivate::animate_toolbox;
+ default:
+ return QApplicationPrivate::animate_ui;
+ }
+}
+
+QWidget *QApplication::topLevelAt(const QPoint &pos)
+{
+ QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration();
+
+ QList<QPlatformScreen *> screens = pi->screens();
+ QList<QPlatformScreen *>::const_iterator screen = screens.constBegin();
+ QList<QPlatformScreen *>::const_iterator end = screens.constEnd();
+
+ // The first screen in a virtual environment should know about all top levels
+ if (pi->isVirtualDesktop()) {
+ QWidgetWindow *w = qobject_cast<QWidgetWindow *>((*screen)->topLevelAt(pos));
+ return w ? w->widget() : 0;
+ }
+
+ while (screen != end) {
+ if ((*screen)->geometry().contains(pos)) {
+ QWidgetWindow *w = qobject_cast<QWidgetWindow *>((*screen)->topLevelAt(pos));
+ return w ? w->widget() : 0;
+ }
+ ++screen;
+ }
+ return 0;
+}
+
+void QApplication::beep()
+{
+}
+
+void QApplication::alert(QWidget *, int)
+{
+}
+
+QPlatformNativeInterface *QApplication::platformNativeInterface()
+{
+ QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration();
+ return pi->nativeInterface();
+}
+
+#ifndef QT_NO_QWS_INPUTMETHODS
+class QDummyInputContext : public QInputContext
+{
+public:
+ explicit QDummyInputContext(QObject* parent = 0) : QInputContext(parent) {}
+ ~QDummyInputContext() {}
+ QString identifierName() { return QString(); }
+ QString language() { return QString(); }
+
+ void reset() {}
+ bool isComposing() const { return false; }
+
+};
+#endif // QT_NO_QWS_INPUTMETHODS
+
+void qt_init(QApplicationPrivate *, int type)
+{
+ Q_UNUSED(type);
+
+ qApp->setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
+ QColormap::initialize();
+
+ qApp->setObjectName(appName);
+
+#ifndef QT_NO_QWS_INPUTMETHODS
+ qApp->setInputContext(new QDummyInputContext(qApp));
+#endif
+}
+
+void qt_cleanup()
+{
+ QPixmapCache::clear();
+ QColormap::cleanup();
+ delete QApplicationPrivate::inputContext;
+ QApplicationPrivate::inputContext = 0;
+
+ QApplicationPrivate::active_window = 0; //### this should not be necessary
+}
+
+
+#ifdef QT3_SUPPORT
+void QApplication::setMainWidget(QWidget *mainWidget)
+{
+ QApplicationPrivate::main_widget = mainWidget;
+ if (QApplicationPrivate::main_widget && windowIcon().isNull()
+ && QApplicationPrivate::main_widget->testAttribute(Qt::WA_SetWindowIcon))
+ setWindowIcon(QApplicationPrivate::main_widget->windowIcon());
+}
+#endif
+
+QT_END_NAMESPACE
diff --git a/src/widgets/kernel/qbackingstore.cpp b/src/widgets/kernel/qbackingstore.cpp
new file mode 100644
index 0000000000..5e0c158cec
--- /dev/null
+++ b/src/widgets/kernel/qbackingstore.cpp
@@ -0,0 +1,1665 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "qplatformdefs.h"
+
+#include "qbackingstore_p.h"
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qdebug.h>
+#include <QtCore/qvarlengtharray.h>
+#include <QtGui/qevent.h>
+#include <QtWidgets/qapplication.h>
+#include <QtGui/qpaintengine.h>
+#include <QtWidgets/qgraphicsproxywidget.h>
+
+#include <private/qwidget_p.h>
+#include <private/qapplication_p.h>
+#include <private/qpaintengine_raster_p.h>
+#include <private/qgraphicseffect_p.h>
+
+#ifdef Q_WS_QWS
+#include <QtGui/qwsmanager_qws.h>
+#include <private/qwsmanager_p.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+extern QRegion qt_dirtyRegion(QWidget *);
+
+/*
+ A version of QRect::intersects() that does not normalize the rects.
+*/
+static inline bool qRectIntersects(const QRect &r1, const QRect &r2)
+{
+ return (qMax(r1.left(), r2.left()) <= qMin(r1.right(), r2.right())
+ && qMax(r1.top(), r2.top()) <= qMin(r1.bottom(), r2.bottom()));
+}
+
+/**
+ * Flushes the contents of the \a windowSurface into the screen area of \a widget.
+ * \a tlwOffset is the position of the top level widget relative to the window surface.
+ * \a region is the region to be updated in \a widget coordinates.
+ */
+static inline void qt_flush(QWidget *widget, const QRegion &region, QWindowSurface *windowSurface,
+ QWidget *tlw, const QPoint &tlwOffset)
+{
+ Q_ASSERT(widget);
+ Q_ASSERT(!region.isEmpty());
+ Q_ASSERT(windowSurface);
+ Q_ASSERT(tlw);
+
+#if !defined(QT_NO_PAINT_DEBUG) && !defined(Q_WS_QWS)
+ // QWS does flush update in QWindowSurface::flush (because it needs to lock the surface etc).
+ static int flushUpdate = qgetenv("QT_FLUSH_UPDATE").toInt();
+ if (flushUpdate > 0)
+ QWidgetBackingStore::showYellowThing(widget, region, flushUpdate * 10, false);
+#endif
+
+ //The performance hit by doing this should be negligible. However, be aware that
+ //using this FPS when you have > 1 windowsurface can give you inaccurate FPS
+ static bool fpsDebug = qgetenv("QT_DEBUG_FPS").toInt();
+ if (fpsDebug) {
+ static QTime time = QTime::currentTime();
+ static int frames = 0;
+
+ frames++;
+
+ if(time.elapsed() > 5000) {
+ double fps = double(frames * 1000) /time.restart();
+ fprintf(stderr,"FPS: %.1f\n",fps);
+ frames = 0;
+ }
+ }
+ if (widget != tlw)
+ windowSurface->flush(widget->windowHandle(), region, tlwOffset + widget->mapTo(tlw, QPoint()));
+ else
+ windowSurface->flush(widget->windowHandle(), region, tlwOffset);
+}
+
+#ifndef QT_NO_PAINT_DEBUG
+#ifdef Q_WS_WIN
+static void showYellowThing_win(QWidget *widget, const QRegion &region, int msec)
+{
+ HBRUSH brush;
+ static int i = 0;
+ switch (i) {
+ case 0:
+ brush = CreateSolidBrush(RGB(255, 255, 0));
+ break;
+ case 1:
+ brush = CreateSolidBrush(RGB(255, 200, 55));
+ break;
+ case 2:
+ brush = CreateSolidBrush(RGB(200, 255, 55));
+ break;
+ case 3:
+ brush = CreateSolidBrush(RGB(200, 200, 0));
+ break;
+ }
+ i = (i + 1) & 3;
+
+ HDC hdc = widget->getDC();
+
+ const QVector<QRect> &rects = region.rects();
+ foreach (QRect rect, rects) {
+ RECT winRect;
+ SetRect(&winRect, rect.left(), rect.top(), rect.right(), rect.bottom());
+ FillRect(hdc, &winRect, brush);
+ }
+
+ widget->releaseDC(hdc);
+ ::Sleep(msec);
+}
+#endif
+
+void QWidgetBackingStore::showYellowThing(QWidget *widget, const QRegion &toBePainted, int msec, bool unclipped)
+{
+#ifdef Q_WS_QWS
+ Q_UNUSED(widget);
+ Q_UNUSED(unclipped);
+ static QWSYellowSurface surface(true);
+ surface.setDelay(msec);
+ surface.flush(widget, toBePainted, QPoint());
+#else
+ QRegion paintRegion = toBePainted;
+ QRect widgetRect = widget->rect();
+
+ if (!widget->internalWinId()) {
+ QWidget *nativeParent = widget->nativeParentWidget();
+ const QPoint offset = widget->mapTo(nativeParent, QPoint(0, 0));
+ paintRegion.translate(offset);
+ widgetRect.translate(offset);
+ widget = nativeParent;
+ }
+
+#ifdef Q_WS_WIN
+ Q_UNUSED(unclipped);
+ showYellowThing_win(widget, paintRegion, msec);
+#else
+ //flags to fool painter
+ bool paintUnclipped = widget->testAttribute(Qt::WA_PaintUnclipped);
+ if (unclipped && !widget->d_func()->paintOnScreen())
+ widget->setAttribute(Qt::WA_PaintUnclipped);
+
+ const bool setFlag = !widget->testAttribute(Qt::WA_WState_InPaintEvent);
+ if (setFlag)
+ widget->setAttribute(Qt::WA_WState_InPaintEvent);
+
+ //setup the engine
+ QPaintEngine *pe = widget->paintEngine();
+ if (pe) {
+ pe->setSystemClip(paintRegion);
+ {
+ QPainter p(widget);
+ p.setClipRegion(paintRegion);
+ static int i = 0;
+ switch (i) {
+ case 0:
+ p.fillRect(widgetRect, QColor(255,255,0));
+ break;
+ case 1:
+ p.fillRect(widgetRect, QColor(255,200,55));
+ break;
+ case 2:
+ p.fillRect(widgetRect, QColor(200,255,55));
+ break;
+ case 3:
+ p.fillRect(widgetRect, QColor(200,200,0));
+ break;
+ }
+ i = (i+1) & 3;
+ p.end();
+ }
+ }
+
+ if (setFlag)
+ widget->setAttribute(Qt::WA_WState_InPaintEvent, false);
+
+ //restore
+ widget->setAttribute(Qt::WA_PaintUnclipped, paintUnclipped);
+
+ if (pe)
+ pe->setSystemClip(QRegion());
+
+ QApplication::syncX();
+
+#if defined(Q_OS_UNIX)
+ ::usleep(1000 * msec);
+#endif
+#endif // Q_WS_WIN
+#endif // Q_WS_QWS
+}
+
+bool QWidgetBackingStore::flushPaint(QWidget *widget, const QRegion &rgn)
+{
+ if (!widget)
+ return false;
+
+ int delay = 0;
+ if (widget->testAttribute(Qt::WA_WState_InPaintEvent)) {
+ static int flushPaintEvent = qgetenv("QT_FLUSH_PAINT_EVENT").toInt();
+ if (!flushPaintEvent)
+ return false;
+ delay = flushPaintEvent;
+ } else {
+ static int flushPaint = qgetenv("QT_FLUSH_PAINT").toInt();
+ if (!flushPaint)
+ return false;
+ delay = flushPaint;
+ }
+
+ QWidgetBackingStore::showYellowThing(widget, rgn, delay * 10, true);
+ return true;
+}
+
+void QWidgetBackingStore::unflushPaint(QWidget *widget, const QRegion &rgn)
+{
+ if (widget->d_func()->paintOnScreen() || rgn.isEmpty())
+ return;
+
+ QWidget *tlw = widget->window();
+ QTLWExtra *tlwExtra = tlw->d_func()->maybeTopData();
+ if (!tlwExtra)
+ return;
+
+ const QPoint offset = widget->mapTo(tlw, QPoint());
+ qt_flush(widget, rgn, tlwExtra->backingStore->windowSurface, tlw, offset);
+}
+#endif // QT_NO_PAINT_DEBUG
+
+/*
+ Moves the whole rect by (dx, dy) in widget's coordinate system.
+ Doesn't generate any updates.
+*/
+bool QWidgetBackingStore::bltRect(const QRect &rect, int dx, int dy, QWidget *widget)
+{
+ const QPoint pos(tlwOffset + widget->mapTo(tlw, rect.topLeft()));
+ const QRect tlwRect(QRect(pos, rect.size()));
+ if (fullUpdatePending || dirty.intersects(tlwRect))
+ return false; // We don't want to scroll junk.
+ return windowSurface->scroll(tlwRect, dx, dy);
+}
+
+void QWidgetBackingStore::releaseBuffer()
+{
+ if (windowSurface)
+#if defined(Q_WS_QPA)
+ windowSurface->resize(QSize());
+#else
+ windowSurface->setGeometry(QRect());
+#endif
+#ifdef Q_BACKINGSTORE_SUBSURFACES
+ for (int i = 0; i < subSurfaces.size(); ++i)
+ subSurfaces.at(i)->setGeometry(QRect());
+#endif
+}
+
+/*!
+ Prepares the window surface to paint a\ toClean region of the \a widget and
+ updates the BeginPaintInfo struct accordingly.
+
+ The \a toClean region might be clipped by the window surface.
+*/
+void QWidgetBackingStore::beginPaint(QRegion &toClean, QWidget *widget, QWindowSurface *windowSurface,
+ BeginPaintInfo *returnInfo, bool toCleanIsInTopLevelCoordinates)
+{
+#ifdef Q_WS_QWS
+ QWSWindowSurface *surface = static_cast<QWSWindowSurface *>(windowSurface);
+ QWidget *surfaceWidget = surface->window();
+
+ if (!surface->isValid()) {
+ // this looks strange but it really just releases the surface
+ surface->releaseSurface();
+ // the old window surface is deleted in setWindowSurface, which is
+ // called from QWindowSurface constructor.
+ windowSurface = tlw->d_func()->createDefaultWindowSurface();
+ surface = static_cast<QWSWindowSurface *>(windowSurface);
+ // createDefaultWindowSurface() will set topdata->windowSurface on the
+ // widget to zero. However, if this is a sub-surface, it should point
+ // to the widget's sub windowSurface, so we set that here:
+ if (!surfaceWidget->isWindow())
+ surfaceWidget->d_func()->topData()->windowSurface = windowSurface;
+ surface->setGeometry(topLevelRect());
+ returnInfo->windowSurfaceRecreated = true;
+ }
+
+ const QRegion toCleanUnclipped(toClean);
+
+ if (surfaceWidget->isWindow())
+ tlwOffset = surface->painterOffset();
+#ifdef Q_BACKINGSTORE_SUBSURFACES
+ else if (toCleanIsInTopLevelCoordinates)
+ toClean &= surface->clipRegion().translated(surfaceWidget->mapTo(tlw, QPoint()));
+ if (!toCleanIsInTopLevelCoordinates && windowSurface == this->windowSurface)
+ toClean &= surface->clipRegion().translated(-widget->mapTo(surfaceWidget, QPoint()));
+#else
+ toClean &= surface->clipRegion();
+#endif
+
+ if (toClean.isEmpty()) {
+ if (surfaceWidget->isWindow()) {
+ dirtyFromPreviousSync += toCleanUnclipped;
+ hasDirtyFromPreviousSync = true;
+ }
+
+ returnInfo->nothingToPaint = true;
+ // Nothing to repaint. However, we might have newly exposed areas on the
+ // screen, so we have to make sure those are flushed.
+ flush();
+ return;
+ }
+
+ if (surfaceWidget->isWindow()) {
+ if (toCleanUnclipped != toClean) {
+ dirtyFromPreviousSync += (toCleanUnclipped - surface->clipRegion());
+ hasDirtyFromPreviousSync = true;
+ }
+ if (hasDirtyFromPreviousSync) {
+ dirtyFromPreviousSync -= toClean;
+ hasDirtyFromPreviousSync = !dirtyFromPreviousSync.isEmpty();
+ }
+ }
+
+#endif // Q_WS_QWS
+
+ Q_UNUSED(widget);
+ Q_UNUSED(toCleanIsInTopLevelCoordinates);
+
+ // Always flush repainted areas.
+ dirtyOnScreen += toClean;
+
+#if defined(Q_WS_QWS) && !defined(Q_BACKINGSTORE_SUBSURFACES)
+ toClean.translate(tlwOffset);
+#endif
+
+#ifdef QT_NO_PAINT_DEBUG
+ windowSurface->beginPaint(toClean);
+#else
+ returnInfo->wasFlushed = QWidgetBackingStore::flushPaint(tlw, toClean);
+ // Avoid deadlock with QT_FLUSH_PAINT: the server will wait for
+ // the BackingStore lock, so if we hold that, the server will
+ // never release the Communication lock that we are waiting for in
+ // sendSynchronousCommand
+ if (!returnInfo->wasFlushed)
+ windowSurface->beginPaint(toClean);
+#endif
+
+ Q_UNUSED(returnInfo);
+}
+
+void QWidgetBackingStore::endPaint(const QRegion &cleaned, QWindowSurface *windowSurface,
+ BeginPaintInfo *beginPaintInfo)
+{
+#ifndef QT_NO_PAINT_DEBUG
+ if (!beginPaintInfo->wasFlushed)
+ windowSurface->endPaint(cleaned);
+ else
+ QWidgetBackingStore::unflushPaint(tlw, cleaned);
+#else
+ Q_UNUSED(beginPaintInfo);
+ windowSurface->endPaint(cleaned);
+#endif
+
+#ifdef Q_BACKINGSTORE_SUBSURFACES
+ flush(static_cast<QWSWindowSurface *>(windowSurface)->window(), windowSurface);
+#else
+ flush();
+#endif
+}
+
+/*!
+ Returns the region (in top-level coordinates) that needs repaint and/or flush.
+
+ If the widget is non-zero, only the dirty region for the widget is returned
+ and the region will be in widget coordinates.
+*/
+QRegion QWidgetBackingStore::dirtyRegion(QWidget *widget) const
+{
+ const bool widgetDirty = widget && widget != tlw;
+ const QRect tlwRect(topLevelRect());
+#if defined(Q_WS_QPA)
+ const QRect surfaceGeometry(tlwRect.topLeft(), windowSurface->size());
+#else
+ const QRect surfaceGeometry(windowSurface->geometry());
+#endif
+ if (fullUpdatePending || (surfaceGeometry != tlwRect && surfaceGeometry.size() != tlwRect.size())) {
+ if (widgetDirty) {
+ const QRect dirtyTlwRect = QRect(QPoint(), tlwRect.size());
+ const QPoint offset(widget->mapTo(tlw, QPoint()));
+ const QRect dirtyWidgetRect(dirtyTlwRect & widget->rect().translated(offset));
+ return dirtyWidgetRect.translated(-offset);
+ }
+ return QRect(QPoint(), tlwRect.size());
+ }
+
+ // Calculate the region that needs repaint.
+ QRegion r(dirty);
+ for (int i = 0; i < dirtyWidgets.size(); ++i) {
+ QWidget *w = dirtyWidgets.at(i);
+ if (widgetDirty && w != widget && !widget->isAncestorOf(w))
+ continue;
+ r += w->d_func()->dirty.translated(w->mapTo(tlw, QPoint()));
+ }
+
+ // Append the region that needs flush.
+ r += dirtyOnScreen;
+
+ if (dirtyOnScreenWidgets) { // Only in use with native child widgets.
+ for (int i = 0; i < dirtyOnScreenWidgets->size(); ++i) {
+ QWidget *w = dirtyOnScreenWidgets->at(i);
+ if (widgetDirty && w != widget && !widget->isAncestorOf(w))
+ continue;
+ QWidgetPrivate *wd = w->d_func();
+ Q_ASSERT(wd->needsFlush);
+ r += wd->needsFlush->translated(w->mapTo(tlw, QPoint()));
+ }
+ }
+
+ if (widgetDirty) {
+ // Intersect with the widget geometry and translate to its coordinates.
+ const QPoint offset(widget->mapTo(tlw, QPoint()));
+ r &= widget->rect().translated(offset);
+ r.translate(-offset);
+ }
+ return r;
+}
+
+/*!
+ Returns the static content inside the \a parent if non-zero; otherwise the static content
+ for the entire backing store is returned. The content will be clipped to \a withinClipRect
+ if non-empty.
+*/
+QRegion QWidgetBackingStore::staticContents(QWidget *parent, const QRect &withinClipRect) const
+{
+ if (!parent && tlw->testAttribute(Qt::WA_StaticContents)) {
+#if defined(Q_WS_QPA)
+ const QSize surfaceGeometry(windowSurface->size());
+#else
+ const QRect surfaceGeometry(windowSurface->geometry());
+#endif
+ QRect surfaceRect(0, 0, surfaceGeometry.width(), surfaceGeometry.height());
+ if (!withinClipRect.isEmpty())
+ surfaceRect &= withinClipRect;
+ return QRegion(surfaceRect);
+ }
+
+ QRegion region;
+ if (parent && parent->d_func()->children.isEmpty())
+ return region;
+
+ const bool clipToRect = !withinClipRect.isEmpty();
+ const int count = staticWidgets.count();
+ for (int i = 0; i < count; ++i) {
+ QWidget *w = staticWidgets.at(i);
+ QWidgetPrivate *wd = w->d_func();
+ if (!wd->isOpaque || !wd->extra || wd->extra->staticContentsSize.isEmpty()
+ || !w->isVisible() || (parent && !parent->isAncestorOf(w))) {
+ continue;
+ }
+
+ QRect rect(0, 0, wd->extra->staticContentsSize.width(), wd->extra->staticContentsSize.height());
+ const QPoint offset = w->mapTo(parent ? parent : tlw, QPoint());
+ if (clipToRect)
+ rect &= withinClipRect.translated(-offset);
+ if (rect.isEmpty())
+ continue;
+
+ rect &= wd->clipRect();
+ if (rect.isEmpty())
+ continue;
+
+ QRegion visible(rect);
+ wd->clipToEffectiveMask(visible);
+ if (visible.isEmpty())
+ continue;
+ wd->subtractOpaqueSiblings(visible, 0, /*alsoNonOpaque=*/true);
+
+ visible.translate(offset);
+ region += visible;
+ }
+
+ return region;
+}
+
+static inline void sendUpdateRequest(QWidget *widget, bool updateImmediately)
+{
+ if (!widget)
+ return;
+
+ if (updateImmediately) {
+ QEvent event(QEvent::UpdateRequest);
+ QApplication::sendEvent(widget, &event);
+ } else {
+ QApplication::postEvent(widget, new QEvent(QEvent::UpdateRequest), Qt::LowEventPriority);
+ }
+}
+
+/*!
+ Marks the region of the widget as dirty (if not already marked as dirty) and
+ posts an UpdateRequest event to the top-level widget (if not already posted).
+
+ If updateImmediately is true, the event is sent immediately instead of posted.
+
+ If invalidateBuffer is true, all widgets intersecting with the region will be dirty.
+
+ If the widget paints directly on screen, the event is sent to the widget
+ instead of the top-level widget, and invalidateBuffer is completely ignored.
+
+ ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
+*/
+void QWidgetBackingStore::markDirty(const QRegion &rgn, QWidget *widget, bool updateImmediately,
+ bool invalidateBuffer)
+{
+ Q_ASSERT(tlw->d_func()->extra);
+ Q_ASSERT(tlw->d_func()->extra->topextra);
+ Q_ASSERT(!tlw->d_func()->extra->topextra->inTopLevelResize);
+ Q_ASSERT(widget->isVisible() && widget->updatesEnabled());
+ Q_ASSERT(widget->window() == tlw);
+ Q_ASSERT(!rgn.isEmpty());
+
+#ifndef QT_NO_GRAPHICSEFFECT
+ widget->d_func()->invalidateGraphicsEffectsRecursively();
+#endif //QT_NO_GRAPHICSEFFECT
+
+ if (widget->d_func()->paintOnScreen()) {
+ if (widget->d_func()->dirty.isEmpty()) {
+ widget->d_func()->dirty = rgn;
+ sendUpdateRequest(widget, updateImmediately);
+ return;
+ } else if (qt_region_strictContains(widget->d_func()->dirty, widget->rect())) {
+ if (updateImmediately)
+ sendUpdateRequest(widget, updateImmediately);
+ return; // Already dirty.
+ }
+
+ const bool eventAlreadyPosted = !widget->d_func()->dirty.isEmpty();
+ widget->d_func()->dirty += rgn;
+ if (!eventAlreadyPosted || updateImmediately)
+ sendUpdateRequest(widget, updateImmediately);
+ return;
+ }
+
+ if (fullUpdatePending) {
+ if (updateImmediately)
+ sendUpdateRequest(tlw, updateImmediately);
+ return;
+ }
+
+ if (!windowSurface->hasFeature(QWindowSurface::PartialUpdates)) {
+ fullUpdatePending = true;
+ sendUpdateRequest(tlw, updateImmediately);
+ return;
+ }
+
+ const QPoint offset = widget->mapTo(tlw, QPoint());
+ const QRect widgetRect = widget->d_func()->effectiveRectFor(widget->rect());
+ if (qt_region_strictContains(dirty, widgetRect.translated(offset))) {
+ if (updateImmediately)
+ sendUpdateRequest(tlw, updateImmediately);
+ return; // Already dirty.
+ }
+
+ if (invalidateBuffer) {
+ const bool eventAlreadyPosted = !dirty.isEmpty();
+#ifndef QT_NO_GRAPHICSEFFECT
+ if (widget->d_func()->graphicsEffect)
+ dirty += widget->d_func()->effectiveRectFor(rgn.boundingRect()).translated(offset);
+ else
+#endif //QT_NO_GRAPHICSEFFECT
+ dirty += rgn.translated(offset);
+ if (!eventAlreadyPosted || updateImmediately)
+ sendUpdateRequest(tlw, updateImmediately);
+ return;
+ }
+
+ if (dirtyWidgets.isEmpty()) {
+ addDirtyWidget(widget, rgn);
+ sendUpdateRequest(tlw, updateImmediately);
+ return;
+ }
+
+ if (widget->d_func()->inDirtyList) {
+ if (!qt_region_strictContains(widget->d_func()->dirty, widgetRect)) {
+#ifndef QT_NO_GRAPHICSEFFECT
+ if (widget->d_func()->graphicsEffect)
+ widget->d_func()->dirty += widget->d_func()->effectiveRectFor(rgn.boundingRect());
+ else
+#endif //QT_NO_GRAPHICSEFFECT
+ widget->d_func()->dirty += rgn;
+ }
+ } else {
+ addDirtyWidget(widget, rgn);
+ }
+
+ if (updateImmediately)
+ sendUpdateRequest(tlw, updateImmediately);
+}
+
+/*!
+ This function is equivalent to calling markDirty(QRegion(rect), ...), but
+ is more efficient as it eliminates QRegion operations/allocations and can
+ use the rect more precisely for additional cut-offs.
+
+ ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
+*/
+void QWidgetBackingStore::markDirty(const QRect &rect, QWidget *widget, bool updateImmediately,
+ bool invalidateBuffer)
+{
+ Q_ASSERT(tlw->d_func()->extra);
+ Q_ASSERT(tlw->d_func()->extra->topextra);
+ Q_ASSERT(!tlw->d_func()->extra->topextra->inTopLevelResize);
+ Q_ASSERT(widget->isVisible() && widget->updatesEnabled());
+ Q_ASSERT(widget->window() == tlw);
+ Q_ASSERT(!rect.isEmpty());
+
+#ifndef QT_NO_GRAPHICSEFFECT
+ widget->d_func()->invalidateGraphicsEffectsRecursively();
+#endif //QT_NO_GRAPHICSEFFECT
+
+ if (widget->d_func()->paintOnScreen()) {
+ if (widget->d_func()->dirty.isEmpty()) {
+ widget->d_func()->dirty = QRegion(rect);
+ sendUpdateRequest(widget, updateImmediately);
+ return;
+ } else if (qt_region_strictContains(widget->d_func()->dirty, rect)) {
+ if (updateImmediately)
+ sendUpdateRequest(widget, updateImmediately);
+ return; // Already dirty.
+ }
+
+ const bool eventAlreadyPosted = !widget->d_func()->dirty.isEmpty();
+ widget->d_func()->dirty += rect;
+ if (!eventAlreadyPosted || updateImmediately)
+ sendUpdateRequest(widget, updateImmediately);
+ return;
+ }
+
+ if (fullUpdatePending) {
+ if (updateImmediately)
+ sendUpdateRequest(tlw, updateImmediately);
+ return;
+ }
+
+ if (!windowSurface->hasFeature(QWindowSurface::PartialUpdates)) {
+ fullUpdatePending = true;
+ sendUpdateRequest(tlw, updateImmediately);
+ return;
+ }
+
+ const QRect widgetRect = widget->d_func()->effectiveRectFor(rect);
+ const QRect translatedRect(widgetRect.translated(widget->mapTo(tlw, QPoint())));
+ if (qt_region_strictContains(dirty, translatedRect)) {
+ if (updateImmediately)
+ sendUpdateRequest(tlw, updateImmediately);
+ return; // Already dirty
+ }
+
+ if (invalidateBuffer) {
+ const bool eventAlreadyPosted = !dirty.isEmpty();
+ dirty += translatedRect;
+ if (!eventAlreadyPosted || updateImmediately)
+ sendUpdateRequest(tlw, updateImmediately);
+ return;
+ }
+
+ if (dirtyWidgets.isEmpty()) {
+ addDirtyWidget(widget, rect);
+ sendUpdateRequest(tlw, updateImmediately);
+ return;
+ }
+
+ if (widget->d_func()->inDirtyList) {
+ if (!qt_region_strictContains(widget->d_func()->dirty, widgetRect))
+ widget->d_func()->dirty += widgetRect;
+ } else {
+ addDirtyWidget(widget, rect);
+ }
+
+ if (updateImmediately)
+ sendUpdateRequest(tlw, updateImmediately);
+}
+
+/*!
+ Marks the \a region of the \a widget as dirty on screen. The \a region will be copied from
+ the backing store to the \a widget's native parent next time flush() is called.
+
+ Paint on screen widgets are ignored.
+*/
+void QWidgetBackingStore::markDirtyOnScreen(const QRegion &region, QWidget *widget, const QPoint &topLevelOffset)
+{
+ if (!widget || widget->d_func()->paintOnScreen() || region.isEmpty())
+ return;
+
+#if defined(Q_WS_QWS) || defined(Q_WS_MAC)
+ if (!widget->testAttribute(Qt::WA_WState_InPaintEvent))
+ dirtyOnScreen += region.translated(topLevelOffset);
+ return;
+#endif
+
+ // Top-level.
+ if (widget == tlw) {
+ if (!widget->testAttribute(Qt::WA_WState_InPaintEvent))
+ dirtyOnScreen += region;
+ return;
+ }
+
+ // Alien widgets.
+ if (!widget->internalWinId() && !widget->isWindow()) {
+ QWidget *nativeParent = widget->nativeParentWidget(); // Alien widgets with the top-level as the native parent (common case).
+ if (nativeParent == tlw) {
+ if (!widget->testAttribute(Qt::WA_WState_InPaintEvent))
+ dirtyOnScreen += region.translated(topLevelOffset);
+ return;
+ }
+
+ // Alien widgets with native parent != tlw.
+ QWidgetPrivate *nativeParentPrivate = nativeParent->d_func();
+ if (!nativeParentPrivate->needsFlush)
+ nativeParentPrivate->needsFlush = new QRegion;
+ const QPoint nativeParentOffset = widget->mapTo(nativeParent, QPoint());
+ *nativeParentPrivate->needsFlush += region.translated(nativeParentOffset);
+ appendDirtyOnScreenWidget(nativeParent);
+ return;
+ }
+
+ // Native child widgets.
+ QWidgetPrivate *widgetPrivate = widget->d_func();
+ if (!widgetPrivate->needsFlush)
+ widgetPrivate->needsFlush = new QRegion;
+ *widgetPrivate->needsFlush += region;
+ appendDirtyOnScreenWidget(widget);
+}
+
+void QWidgetBackingStore::removeDirtyWidget(QWidget *w)
+{
+ if (!w)
+ return;
+
+ dirtyWidgetsRemoveAll(w);
+ dirtyOnScreenWidgetsRemoveAll(w);
+ resetWidget(w);
+
+ QWidgetPrivate *wd = w->d_func();
+ const int n = wd->children.count();
+ for (int i = 0; i < n; ++i) {
+ if (QWidget *child = qobject_cast<QWidget*>(wd->children.at(i)))
+ removeDirtyWidget(child);
+ }
+}
+
+#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER)
+bool QWidgetBackingStore::hasDirtyWindowDecoration() const
+{
+ QTLWExtra *tlwExtra = tlw->d_func()->maybeTopData();
+ if (tlwExtra && tlwExtra->qwsManager)
+ return !tlwExtra->qwsManager->d_func()->dirtyRegions.isEmpty();
+ return false;
+}
+
+void QWidgetBackingStore::paintWindowDecoration()
+{
+ if (!hasDirtyWindowDecoration())
+ return;
+
+ QDecoration &decoration = QApplication::qwsDecoration();
+ const QRect decorationRect = tlw->rect();
+ QRegion decorationRegion = decoration.region(tlw, decorationRect);
+
+ QWSManagerPrivate *managerPrivate = tlw->d_func()->topData()->qwsManager->d_func();
+ const bool doClipping = !managerPrivate->entireDecorationNeedsRepaint
+ && !managerPrivate->dirtyClip.isEmpty();
+
+ if (doClipping) {
+ decorationRegion &= static_cast<QWSWindowSurface *>(windowSurface)->clipRegion();
+ decorationRegion &= managerPrivate->dirtyClip;
+ }
+
+ if (decorationRegion.isEmpty())
+ return;
+
+ //### The QWS decorations do not always paint the pixels they promise to paint.
+ // This causes painting problems with QWSMemorySurface. Since none of the other
+ // window surfaces actually use the region, passing an empty region is a safe
+ // workaround.
+
+ windowSurface->beginPaint(QRegion());
+
+ QPaintEngine *engine = windowSurface->paintDevice()->paintEngine();
+ Q_ASSERT(engine);
+ const QRegion oldSystemClip(engine->systemClip());
+ engine->setSystemClip(decorationRegion.translated(tlwOffset));
+
+ QPainter painter(windowSurface->paintDevice());
+ painter.setFont(QApplication::font());
+ painter.translate(tlwOffset);
+
+ const int numDirty = managerPrivate->dirtyRegions.size();
+ for (int i = 0; i < numDirty; ++i) {
+ const int area = managerPrivate->dirtyRegions.at(i);
+
+ QRegion clipRegion = decoration.region(tlw, decorationRect, area);
+ if (!clipRegion.isEmpty()) {
+ // Decoration styles changes the clip and assumes the old clip is non-empty,
+ // so we have to set it, but in theory it shouldn't be required.
+ painter.setClipRegion(clipRegion);
+ decoration.paint(&painter, tlw, area, managerPrivate->dirtyStates.at(i));
+ }
+ }
+ markDirtyOnScreen(decorationRegion, tlw, QPoint());
+
+ painter.end();
+ windowSurface->endPaint(decorationRegion);
+ managerPrivate->clearDirtyRegions();
+ engine->setSystemClip(oldSystemClip);
+}
+#endif
+
+void QWidgetBackingStore::updateLists(QWidget *cur)
+{
+ if (!cur)
+ return;
+
+ QList<QObject*> children = cur->children();
+ for (int i = 0; i < children.size(); ++i) {
+ QWidget *child = qobject_cast<QWidget*>(children.at(i));
+ if (!child)
+ continue;
+
+ updateLists(child);
+ }
+
+ if (cur->testAttribute(Qt::WA_StaticContents))
+ addStaticWidget(cur);
+
+#ifdef Q_BACKINGSTORE_SUBSURFACES
+ QTLWExtra *extra = cur->d_func()->maybeTopData();
+ if (extra && extra->windowSurface && cur != tlw)
+ subSurfaces.append(extra->windowSurface);
+#endif
+}
+
+QWidgetBackingStore::QWidgetBackingStore(QWidget *topLevel)
+ : tlw(topLevel), dirtyOnScreenWidgets(0), hasDirtyFromPreviousSync(false)
+ , fullUpdatePending(0)
+{
+ windowSurface = tlw->windowSurface();
+ if (!windowSurface)
+ windowSurface = topLevel->d_func()->createDefaultWindowSurface();
+
+ // The QWindowSurface constructor will call QWidget::setWindowSurface(),
+ // but automatically created surfaces should not be added to the topdata.
+#ifdef Q_BACKINGSTORE_SUBSURFACES
+ Q_ASSERT(topLevel->d_func()->topData()->windowSurface == windowSurface);
+#endif
+ topLevel->d_func()->topData()->windowSurface = 0;
+
+ // Ensure all existing subsurfaces and static widgets are added to their respective lists.
+ updateLists(topLevel);
+}
+
+QWidgetBackingStore::~QWidgetBackingStore()
+{
+ for (int c = 0; c < dirtyWidgets.size(); ++c) {
+ resetWidget(dirtyWidgets.at(c));
+ }
+
+ delete windowSurface;
+ windowSurface = 0;
+ delete dirtyOnScreenWidgets;
+ dirtyOnScreenWidgets = 0;
+}
+
+//parent's coordinates; move whole rect; update parent and widget
+//assume the screen blt has already been done, so we don't need to refresh that part
+void QWidgetPrivate::moveRect(const QRect &rect, int dx, int dy)
+{
+ Q_Q(QWidget);
+ if (!q->isVisible() || (dx == 0 && dy == 0))
+ return;
+
+ QWidget *tlw = q->window();
+ QTLWExtra* x = tlw->d_func()->topData();
+ if (x->inTopLevelResize)
+ return;
+
+ static int accelEnv = -1;
+ if (accelEnv == -1) {
+ accelEnv = qgetenv("QT_NO_FAST_MOVE").toInt() == 0;
+ }
+
+ QWidget *pw = q->parentWidget();
+ QPoint toplevelOffset = pw->mapTo(tlw, QPoint());
+ QWidgetPrivate *pd = pw->d_func();
+ QRect clipR(pd->clipRect());
+#ifdef Q_WS_QWS
+ QWidgetBackingStore *wbs = x->backingStore.data();
+ QWSWindowSurface *surface = static_cast<QWSWindowSurface*>(wbs->windowSurface);
+ clipR = clipR.intersected(surface->clipRegion().translated(-toplevelOffset).boundingRect());
+#endif
+ const QRect newRect(rect.translated(dx, dy));
+ QRect destRect = rect.intersected(clipR);
+ if (destRect.isValid())
+ destRect = destRect.translated(dx, dy).intersected(clipR);
+ const QRect sourceRect(destRect.translated(-dx, -dy));
+ const QRect parentRect(rect & clipR);
+
+ bool accelerateMove = accelEnv && isOpaque
+#ifndef QT_NO_GRAPHICSVIEW
+ // No accelerate move for proxy widgets.
+ && !tlw->d_func()->extra->proxyWidget
+#endif
+ && !isOverlapped(sourceRect) && !isOverlapped(destRect);
+
+ if (!accelerateMove) {
+ QRegion parentR(effectiveRectFor(parentRect));
+ if (!extra || !extra->hasMask) {
+ parentR -= newRect;
+ } else {
+ // invalidateBuffer() excludes anything outside the mask
+ parentR += newRect & clipR;
+ }
+ pd->invalidateBuffer(parentR);
+ invalidateBuffer((newRect & clipR).translated(-data.crect.topLeft()));
+ } else {
+
+ QWidgetBackingStore *wbs = x->backingStore.data();
+ QRegion childExpose(newRect & clipR);
+
+ if (sourceRect.isValid() && wbs->bltRect(sourceRect, dx, dy, pw))
+ childExpose -= destRect;
+
+ if (!pw->updatesEnabled())
+ return;
+
+ const bool childUpdatesEnabled = q->updatesEnabled();
+ if (childUpdatesEnabled && !childExpose.isEmpty()) {
+ childExpose.translate(-data.crect.topLeft());
+ wbs->markDirty(childExpose, q);
+ isMoved = true;
+ }
+
+ QRegion parentExpose(parentRect);
+ parentExpose -= newRect;
+ if (extra && extra->hasMask)
+ parentExpose += QRegion(newRect) - extra->mask.translated(data.crect.topLeft());
+
+ if (!parentExpose.isEmpty()) {
+ wbs->markDirty(parentExpose, pw);
+ pd->isMoved = true;
+ }
+
+ if (childUpdatesEnabled) {
+ QRegion needsFlush(sourceRect);
+ needsFlush += destRect;
+ wbs->markDirtyOnScreen(needsFlush, pw, toplevelOffset);
+ }
+ }
+}
+
+//widget's coordinates; scroll within rect; only update widget
+void QWidgetPrivate::scrollRect(const QRect &rect, int dx, int dy)
+{
+ Q_Q(QWidget);
+ QWidget *tlw = q->window();
+ QTLWExtra* x = tlw->d_func()->topData();
+ if (x->inTopLevelResize)
+ return;
+
+ QWidgetBackingStore *wbs = x->backingStore.data();
+ if (!wbs)
+ return;
+
+ static int accelEnv = -1;
+ if (accelEnv == -1) {
+ accelEnv = qgetenv("QT_NO_FAST_SCROLL").toInt() == 0;
+ }
+
+ QRect scrollRect = rect & clipRect();
+ bool overlapped = false;
+ bool accelerateScroll = accelEnv && isOpaque
+ && !(overlapped = isOverlapped(scrollRect.translated(data.crect.topLeft())));
+
+#if defined(Q_WS_QWS)
+ QWSWindowSurface *surface;
+ surface = static_cast<QWSWindowSurface*>(wbs->windowSurface);
+
+ if (accelerateScroll && !surface->isBuffered()) {
+ const QRegion surfaceClip = surface->clipRegion();
+ const QRegion outsideClip = QRegion(rect) - surfaceClip;
+ if (!outsideClip.isEmpty()) {
+ const QVector<QRect> clipped = (surfaceClip & rect).rects();
+ if (clipped.size() < 8) {
+ for (int i = 0; i < clipped.size(); ++i)
+ this->scrollRect(clipped.at(i), dx, dy);
+ return;
+ } else {
+ accelerateScroll = false;
+ }
+ }
+ }
+#endif // Q_WS_QWS
+
+ if (!accelerateScroll) {
+ if (overlapped) {
+ QRegion region(scrollRect);
+ subtractOpaqueSiblings(region);
+ invalidateBuffer(region);
+ }else {
+ invalidateBuffer(scrollRect);
+ }
+ } else {
+ const QPoint toplevelOffset = q->mapTo(tlw, QPoint());
+#ifdef Q_WS_QWS
+ QWSWindowSurface *surface = static_cast<QWSWindowSurface*>(wbs->windowSurface);
+ const QRegion clip = surface->clipRegion().translated(-toplevelOffset) & scrollRect;
+ const QRect clipBoundingRect = clip.boundingRect();
+ scrollRect &= clipBoundingRect;
+#endif
+ const QRect destRect = scrollRect.translated(dx, dy) & scrollRect;
+ const QRect sourceRect = destRect.translated(-dx, -dy);
+
+ QRegion childExpose(scrollRect);
+ if (sourceRect.isValid()) {
+ if (wbs->bltRect(sourceRect, dx, dy, q))
+ childExpose -= destRect;
+ }
+
+ if (inDirtyList) {
+ if (rect == q->rect()) {
+ dirty.translate(dx, dy);
+ } else {
+ QRegion dirtyScrollRegion = dirty.intersected(scrollRect);
+ if (!dirtyScrollRegion.isEmpty()) {
+ dirty -= dirtyScrollRegion;
+ dirtyScrollRegion.translate(dx, dy);
+ dirty += dirtyScrollRegion;
+ }
+ }
+ }
+
+ if (!q->updatesEnabled())
+ return;
+
+ if (!childExpose.isEmpty()) {
+ wbs->markDirty(childExpose, q);
+ isScrolled = true;
+ }
+
+ // Instead of using native scroll-on-screen, we copy from
+ // backingstore, giving only one screen update for each
+ // scroll, and a solid appearance
+ wbs->markDirtyOnScreen(destRect, q, toplevelOffset);
+ }
+}
+
+static inline bool discardSyncRequest(QWidget *tlw, QTLWExtra *tlwExtra)
+{
+ if (!tlw || !tlwExtra)
+ return true;
+
+#ifdef Q_WS_X11
+ // Delay the sync until we get an Expose event from X11 (initial show).
+ // Qt::WA_Mapped is set to true, but the actual mapping has not yet occurred.
+ // However, we must repaint immediately regardless of the state if someone calls repaint().
+ if (tlwExtra->waitingForMapNotify && !tlwExtra->inRepaint)
+ return true;
+#endif
+
+ if (!tlw->testAttribute(Qt::WA_Mapped))
+ return true;
+
+ if (!tlw->isVisible()
+#ifndef Q_WS_X11
+ // If we're minimized on X11, WA_Mapped will be false and we
+ // will return in the case above. Some window managers on X11
+ // sends us the PropertyNotify to change the minimized state
+ // *AFTER* we've received the expose event, which is baaad.
+ || tlw->isMinimized()
+#endif
+ )
+ return true;
+
+ return false;
+}
+
+/*!
+ Synchronizes the \a exposedRegion of the \a exposedWidget with the backing store.
+
+ If there's nothing to repaint, the area is flushed and painting does not occur;
+ otherwise the area is marked as dirty on screen and will be flushed right after
+ we are done with all painting.
+*/
+void QWidgetBackingStore::sync(QWidget *exposedWidget, const QRegion &exposedRegion)
+{
+ QTLWExtra *tlwExtra = tlw->d_func()->maybeTopData();
+ if (discardSyncRequest(tlw, tlwExtra) || tlwExtra->inTopLevelResize)
+ return;
+
+ if (!exposedWidget || !exposedWidget->internalWinId() || !exposedWidget->isVisible()
+ || !exposedWidget->updatesEnabled() || exposedRegion.isEmpty()) {
+ return;
+ }
+
+ // If there's no preserved contents support we always need
+ // to do a full repaint before flushing
+ if (!windowSurface->hasFeature(QWindowSurface::PreservedContents))
+ fullUpdatePending = true;
+
+ // Nothing to repaint.
+ if (!isDirty()) {
+ qt_flush(exposedWidget, exposedRegion, windowSurface, tlw, tlwOffset);
+ return;
+ }
+
+ if (exposedWidget != tlw)
+ markDirtyOnScreen(exposedRegion, exposedWidget, exposedWidget->mapTo(tlw, QPoint()));
+ else
+ markDirtyOnScreen(exposedRegion, exposedWidget, QPoint());
+ sync();
+}
+
+/*!
+ Synchronizes the backing store, i.e. dirty areas are repainted and flushed.
+*/
+void QWidgetBackingStore::sync()
+{
+ QTLWExtra *tlwExtra = tlw->d_func()->maybeTopData();
+ if (discardSyncRequest(tlw, tlwExtra)) {
+ // If the top-level is minimized, it's not visible on the screen so we can delay the
+ // update until it's shown again. In order to do that we must keep the dirty states.
+ // These will be cleared when we receive the first expose after showNormal().
+ // However, if the widget is not visible (isVisible() returns false), everything will
+ // be invalidated once the widget is shown again, so clear all dirty states.
+ if (!tlw->isVisible()) {
+ dirty = QRegion();
+ for (int i = 0; i < dirtyWidgets.size(); ++i)
+ resetWidget(dirtyWidgets.at(i));
+ dirtyWidgets.clear();
+ fullUpdatePending = false;
+ }
+ return;
+ }
+
+ const bool updatesDisabled = !tlw->updatesEnabled();
+ bool repaintAllWidgets = false;
+
+ const bool inTopLevelResize = tlwExtra->inTopLevelResize;
+ const QRect tlwRect(topLevelRect());
+#ifdef Q_WS_QPA
+ const QRect surfaceGeometry(tlwRect.topLeft(), windowSurface->size());
+#else
+ const QRect surfaceGeometry(windowSurface->geometry());
+#endif
+ if ((fullUpdatePending || inTopLevelResize || surfaceGeometry.size() != tlwRect.size()) && !updatesDisabled) {
+ if (hasStaticContents()) {
+ // Repaint existing dirty area and newly visible area.
+ const QRect clipRect(0, 0, surfaceGeometry.width(), surfaceGeometry.height());
+ const QRegion staticRegion(staticContents(0, clipRect));
+ QRegion newVisible(0, 0, tlwRect.width(), tlwRect.height());
+ newVisible -= staticRegion;
+ dirty += newVisible;
+ windowSurface->setStaticContents(staticRegion);
+ } else {
+ // Repaint everything.
+ dirty = QRegion(0, 0, tlwRect.width(), tlwRect.height());
+ for (int i = 0; i < dirtyWidgets.size(); ++i)
+ resetWidget(dirtyWidgets.at(i));
+ dirtyWidgets.clear();
+ repaintAllWidgets = true;
+ }
+ }
+
+#ifdef Q_WS_QPA
+ if (inTopLevelResize || surfaceGeometry.size() != tlwRect.size())
+ windowSurface->resize(tlwRect.size());
+#else
+ if (inTopLevelResize || surfaceGeometry != tlwRect)
+ windowSurface->setGeometry(tlwRect);
+#endif
+
+ if (updatesDisabled)
+ return;
+
+ if (hasDirtyFromPreviousSync)
+ dirty += dirtyFromPreviousSync;
+
+ // Contains everything that needs repaint.
+ QRegion toClean(dirty);
+
+ // Loop through all update() widgets and remove them from the list before they are
+ // painted (in case someone calls update() in paintEvent). If the widget is opaque
+ // and does not have transparent overlapping siblings, append it to the
+ // opaqueNonOverlappedWidgets list and paint it directly without composition.
+ QVarLengthArray<QWidget *, 32> opaqueNonOverlappedWidgets;
+ for (int i = 0; i < dirtyWidgets.size(); ++i) {
+ QWidget *w = dirtyWidgets.at(i);
+ QWidgetPrivate *wd = w->d_func();
+ if (wd->data.in_destructor)
+ continue;
+
+ // Clip with mask() and clipRect().
+ wd->dirty &= wd->clipRect();
+ wd->clipToEffectiveMask(wd->dirty);
+
+ // Subtract opaque siblings and children.
+ bool hasDirtySiblingsAbove = false;
+ // We know for sure that the widget isn't overlapped if 'isMoved' is true.
+ if (!wd->isMoved)
+ wd->subtractOpaqueSiblings(wd->dirty, &hasDirtySiblingsAbove);
+ // Scrolled and moved widgets must draw all children.
+ if (!wd->isScrolled && !wd->isMoved)
+ wd->subtractOpaqueChildren(wd->dirty, w->rect());
+
+ if (wd->dirty.isEmpty()) {
+ resetWidget(w);
+ continue;
+ }
+
+ const QRegion widgetDirty(w != tlw ? wd->dirty.translated(w->mapTo(tlw, QPoint()))
+ : wd->dirty);
+ toClean += widgetDirty;
+
+#ifndef QT_NO_GRAPHICSVIEW
+ if (tlw->d_func()->extra->proxyWidget) {
+ resetWidget(w);
+ continue;
+ }
+#endif
+
+ if (!hasDirtySiblingsAbove && wd->isOpaque && !dirty.intersects(widgetDirty.boundingRect())) {
+ opaqueNonOverlappedWidgets.append(w);
+ } else {
+ resetWidget(w);
+ dirty += widgetDirty;
+ }
+ }
+ dirtyWidgets.clear();
+
+ fullUpdatePending = false;
+
+ if (toClean.isEmpty()) {
+ // Nothing to repaint. However, we might have newly exposed areas on the
+ // screen if this function was called from sync(QWidget *, QRegion)), so
+ // we have to make sure those are flushed.
+ flush();
+ return;
+ }
+
+#ifndef QT_NO_GRAPHICSVIEW
+ if (tlw->d_func()->extra->proxyWidget) {
+ updateStaticContentsSize();
+ dirty = QRegion();
+ const QVector<QRect> rects(toClean.rects());
+ for (int i = 0; i < rects.size(); ++i)
+ tlw->d_func()->extra->proxyWidget->update(rects.at(i));
+ return;
+ }
+#endif
+
+#ifndef Q_BACKINGSTORE_SUBSURFACES
+ BeginPaintInfo beginPaintInfo;
+ beginPaint(toClean, tlw, windowSurface, &beginPaintInfo);
+ if (beginPaintInfo.nothingToPaint) {
+ for (int i = 0; i < opaqueNonOverlappedWidgets.size(); ++i)
+ resetWidget(opaqueNonOverlappedWidgets[i]);
+ dirty = QRegion();
+ return;
+ }
+#endif
+
+ // Must do this before sending any paint events because
+ // the size may change in the paint event.
+ updateStaticContentsSize();
+ const QRegion dirtyCopy(dirty);
+ dirty = QRegion();
+
+ // Paint opaque non overlapped widgets.
+ for (int i = 0; i < opaqueNonOverlappedWidgets.size(); ++i) {
+ QWidget *w = opaqueNonOverlappedWidgets[i];
+ QWidgetPrivate *wd = w->d_func();
+
+ int flags = QWidgetPrivate::DrawRecursive;
+ // Scrolled and moved widgets must draw all children.
+ if (!wd->isScrolled && !wd->isMoved)
+ flags |= QWidgetPrivate::DontDrawOpaqueChildren;
+ if (w == tlw)
+ flags |= QWidgetPrivate::DrawAsRoot;
+
+ QRegion toBePainted(wd->dirty);
+ resetWidget(w);
+
+#ifdef Q_BACKINGSTORE_SUBSURFACES
+ QWindowSurface *subSurface = w->windowSurface();
+ BeginPaintInfo beginPaintInfo;
+
+ QPoint off = w->mapTo(tlw, QPoint());
+ toBePainted.translate(off);
+ beginPaint(toBePainted, w, subSurface, &beginPaintInfo, true);
+ toBePainted.translate(-off);
+
+ if (beginPaintInfo.nothingToPaint)
+ continue;
+
+ if (beginPaintInfo.windowSurfaceRecreated) {
+ // Eep the window surface has changed. The old one may have been
+ // deleted, in which case we will segfault on the call to
+ // painterOffset() below. Use the new window surface instead.
+ subSurface = w->windowSurface();
+ }
+
+ QPoint offset(tlwOffset);
+ if (subSurface == windowSurface)
+ offset += w->mapTo(tlw, QPoint());
+ else
+ offset = static_cast<QWSWindowSurface*>(subSurface)->painterOffset();
+ wd->drawWidget(subSurface->paintDevice(), toBePainted, offset, flags, 0, this);
+
+ endPaint(toBePainted, subSurface, &beginPaintInfo);
+#else
+ QPoint offset(tlwOffset);
+ if (w != tlw)
+ offset += w->mapTo(tlw, QPoint());
+ wd->drawWidget(windowSurface->paintDevice(), toBePainted, offset, flags, 0, this);
+#endif
+ }
+
+ // Paint the rest with composition.
+#ifndef Q_BACKINGSTORE_SUBSURFACES
+ if (repaintAllWidgets || !dirtyCopy.isEmpty()) {
+ const int flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive;
+ tlw->d_func()->drawWidget(windowSurface->paintDevice(), dirtyCopy, tlwOffset, flags, 0, this);
+ }
+
+ endPaint(toClean, windowSurface, &beginPaintInfo);
+#else
+ if (!repaintAllWidgets && dirtyCopy.isEmpty())
+ return; // Nothing more to paint.
+
+ QList<QWindowSurface *> surfaceList(subSurfaces);
+ surfaceList.prepend(windowSurface);
+ const QRect dirtyBoundingRect(dirtyCopy.boundingRect());
+
+ // Loop through all window surfaces (incl. the top-level surface) and
+ // repaint those intersecting with the bounding rect of the dirty region.
+ for (int i = 0; i < surfaceList.size(); ++i) {
+ QWindowSurface *subSurface = surfaceList.at(i);
+ QWidget *w = subSurface->window();
+ QWidgetPrivate *wd = w->d_func();
+
+ const QRect clipRect = wd->clipRect().translated(w->mapTo(tlw, QPoint()));
+ if (!qRectIntersects(dirtyBoundingRect, clipRect))
+ continue;
+
+ toClean = dirtyCopy;
+ BeginPaintInfo beginPaintInfo;
+ beginPaint(toClean, w, subSurface, &beginPaintInfo);
+ if (beginPaintInfo.nothingToPaint)
+ continue;
+
+ if (beginPaintInfo.windowSurfaceRecreated) {
+ // Eep the window surface has changed. The old one may have been
+ // deleted, in which case we will segfault on the call to
+ // painterOffset() below. Use the new window surface instead.
+ subSurface = w->windowSurface();
+ }
+
+ int flags = QWidgetPrivate::DrawRecursive;
+ if (w == tlw)
+ flags |= QWidgetPrivate::DrawAsRoot;
+ const QPoint painterOffset = static_cast<QWSWindowSurface*>(subSurface)->painterOffset();
+ wd->drawWidget(subSurface->paintDevice(), toClean, painterOffset, flags, 0, this);
+
+ endPaint(toClean, subSurface, &beginPaintInfo);
+ }
+#endif
+}
+
+/*!
+ Flushes the contents of the backing store into the top-level widget.
+ If the \a widget is non-zero, the content is flushed to the \a widget.
+ If the \a surface is non-zero, the content of the \a surface is flushed.
+*/
+void QWidgetBackingStore::flush(QWidget *widget, QWindowSurface *surface)
+{
+#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER)
+ paintWindowDecoration();
+#endif
+
+ if (!dirtyOnScreen.isEmpty()) {
+ QWidget *target = widget ? widget : tlw;
+ QWindowSurface *source = surface ? surface : windowSurface;
+ qt_flush(target, dirtyOnScreen, source, tlw, tlwOffset);
+ dirtyOnScreen = QRegion();
+ }
+
+ if (!dirtyOnScreenWidgets || dirtyOnScreenWidgets->isEmpty())
+ return;
+
+ for (int i = 0; i < dirtyOnScreenWidgets->size(); ++i) {
+ QWidget *w = dirtyOnScreenWidgets->at(i);
+ QWidgetPrivate *wd = w->d_func();
+ Q_ASSERT(wd->needsFlush);
+ qt_flush(w, *wd->needsFlush, windowSurface, tlw, tlwOffset);
+ *wd->needsFlush = QRegion();
+ }
+ dirtyOnScreenWidgets->clear();
+}
+
+static inline bool discardInvalidateBufferRequest(QWidget *widget, QTLWExtra *tlwExtra)
+{
+ Q_ASSERT(widget);
+ if (QApplication::closingDown())
+ return true;
+
+ if (!tlwExtra || tlwExtra->inTopLevelResize || !tlwExtra->backingStore)
+ return true;
+
+ if (!widget->isVisible() || !widget->updatesEnabled())
+ return true;
+
+ return false;
+}
+
+/*!
+ Invalidates the buffer when the widget is resized.
+ Static areas are never invalidated unless absolutely needed.
+*/
+void QWidgetPrivate::invalidateBuffer_resizeHelper(const QPoint &oldPos, const QSize &oldSize)
+{
+ Q_Q(QWidget);
+ Q_ASSERT(!q->isWindow());
+ Q_ASSERT(q->parentWidget());
+
+ const bool staticContents = q->testAttribute(Qt::WA_StaticContents);
+ const bool sizeDecreased = (data.crect.width() < oldSize.width())
+ || (data.crect.height() < oldSize.height());
+
+ const QPoint offset(data.crect.x() - oldPos.x(), data.crect.y() - oldPos.y());
+ const bool parentAreaExposed = !offset.isNull() || sizeDecreased;
+ const QRect newWidgetRect(q->rect());
+ const QRect oldWidgetRect(0, 0, oldSize.width(), oldSize.height());
+
+ if (!staticContents || graphicsEffect) {
+ QRegion staticChildren;
+ QWidgetBackingStore *bs = 0;
+ if (offset.isNull() && (bs = maybeBackingStore()))
+ staticChildren = bs->staticContents(q, oldWidgetRect);
+ const bool hasStaticChildren = !staticChildren.isEmpty();
+
+ if (hasStaticChildren) {
+ QRegion dirty(newWidgetRect);
+ dirty -= staticChildren;
+ invalidateBuffer(dirty);
+ } else {
+ // Entire widget needs repaint.
+ invalidateBuffer(newWidgetRect);
+ }
+
+ if (!parentAreaExposed)
+ return;
+
+ // Invalidate newly exposed area of the parent.
+ if (!graphicsEffect && extra && extra->hasMask) {
+ QRegion parentExpose(extra->mask.translated(oldPos));
+ parentExpose &= QRect(oldPos, oldSize);
+ if (hasStaticChildren)
+ parentExpose -= data.crect; // Offset is unchanged, safe to do this.
+ q->parentWidget()->d_func()->invalidateBuffer(parentExpose);
+ } else {
+ if (hasStaticChildren && !graphicsEffect) {
+ QRegion parentExpose(QRect(oldPos, oldSize));
+ parentExpose -= data.crect; // Offset is unchanged, safe to do this.
+ q->parentWidget()->d_func()->invalidateBuffer(parentExpose);
+ } else {
+ q->parentWidget()->d_func()->invalidateBuffer(effectiveRectFor(QRect(oldPos, oldSize)));
+ }
+ }
+ return;
+ }
+
+ // Move static content to its new position.
+ if (!offset.isNull()) {
+ if (sizeDecreased) {
+ const QSize minSize(qMin(oldSize.width(), data.crect.width()),
+ qMin(oldSize.height(), data.crect.height()));
+ moveRect(QRect(oldPos, minSize), offset.x(), offset.y());
+ } else {
+ moveRect(QRect(oldPos, oldSize), offset.x(), offset.y());
+ }
+ }
+
+ // Invalidate newly visible area of the widget.
+ if (!sizeDecreased || !oldWidgetRect.contains(newWidgetRect)) {
+ QRegion newVisible(newWidgetRect);
+ newVisible -= oldWidgetRect;
+ invalidateBuffer(newVisible);
+ }
+
+ if (!parentAreaExposed)
+ return;
+
+ // Invalidate newly exposed area of the parent.
+ const QRect oldRect(oldPos, oldSize);
+ if (extra && extra->hasMask) {
+ QRegion parentExpose(oldRect);
+ parentExpose &= extra->mask.translated(oldPos);
+ parentExpose -= (extra->mask.translated(data.crect.topLeft()) & data.crect);
+ q->parentWidget()->d_func()->invalidateBuffer(parentExpose);
+ } else {
+ QRegion parentExpose(oldRect);
+ parentExpose -= data.crect;
+ q->parentWidget()->d_func()->invalidateBuffer(parentExpose);
+ }
+}
+
+/*!
+ Invalidates the \a rgn (in widget's coordinates) of the backing store, i.e.
+ all widgets intersecting with the region will be repainted when the backing store
+ is synced.
+
+ ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
+*/
+void QWidgetPrivate::invalidateBuffer(const QRegion &rgn)
+{
+ Q_Q(QWidget);
+
+ QTLWExtra *tlwExtra = q->window()->d_func()->maybeTopData();
+ if (discardInvalidateBufferRequest(q, tlwExtra) || rgn.isEmpty())
+ return;
+
+ QRegion wrgn(rgn);
+ wrgn &= clipRect();
+ if (!graphicsEffect && extra && extra->hasMask)
+ wrgn &= extra->mask;
+ if (wrgn.isEmpty())
+ return;
+
+ tlwExtra->backingStore->markDirty(wrgn, q, false, true);
+}
+
+/*!
+ This function is equivalent to calling invalidateBuffer(QRegion(rect), ...), but
+ is more efficient as it eliminates QRegion operations/allocations and can
+ use the rect more precisely for additional cut-offs.
+
+ ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
+*/
+void QWidgetPrivate::invalidateBuffer(const QRect &rect)
+{
+ Q_Q(QWidget);
+
+ QTLWExtra *tlwExtra = q->window()->d_func()->maybeTopData();
+ if (discardInvalidateBufferRequest(q, tlwExtra) || rect.isEmpty())
+ return;
+
+ QRect wRect(rect);
+ wRect &= clipRect();
+ if (wRect.isEmpty())
+ return;
+
+ if (graphicsEffect || !extra || !extra->hasMask) {
+ tlwExtra->backingStore->markDirty(wRect, q, false, true);
+ return;
+ }
+
+ QRegion wRgn(extra->mask);
+ wRgn &= wRect;
+ if (wRgn.isEmpty())
+ return;
+
+ tlwExtra->backingStore->markDirty(wRgn, q, false, true);
+}
+
+void QWidgetPrivate::repaint_sys(const QRegion &rgn)
+{
+ if (data.in_destructor)
+ return;
+
+ Q_Q(QWidget);
+ if (q->testAttribute(Qt::WA_StaticContents)) {
+ if (!extra)
+ createExtra();
+ extra->staticContentsSize = data.crect.size();
+ }
+
+#ifdef Q_WS_QPA //Dont even call q->p
+ QPaintEngine *engine = 0;
+#else
+ QPaintEngine *engine = q->paintEngine();
+#endif
+ // QGLWidget does not support partial updates if:
+ // 1) The context is double buffered
+ // 2) The context is single buffered and auto-fill background is enabled.
+ const bool noPartialUpdateSupport = (engine && (engine->type() == QPaintEngine::OpenGL
+ || engine->type() == QPaintEngine::OpenGL2))
+ && (usesDoubleBufferedGLContext || q->autoFillBackground());
+ QRegion toBePainted(noPartialUpdateSupport ? q->rect() : rgn);
+
+#ifdef Q_WS_MAC
+ // No difference between update() and repaint() on the Mac.
+ update_sys(toBePainted);
+ return;
+#endif
+
+ toBePainted &= clipRect();
+ clipToEffectiveMask(toBePainted);
+ if (toBePainted.isEmpty())
+ return; // Nothing to repaint.
+
+#ifndef QT_NO_PAINT_DEBUG
+ bool flushed = QWidgetBackingStore::flushPaint(q, toBePainted);
+#endif
+
+ drawWidget(q, toBePainted, QPoint(), QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawPaintOnScreen, 0);
+
+#ifndef QT_NO_PAINT_DEBUG
+ if (flushed)
+ QWidgetBackingStore::unflushPaint(q, toBePainted);
+#endif
+
+ if (!q->testAttribute(Qt::WA_PaintOutsidePaintEvent) && q->paintingActive())
+ qWarning("QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent");
+}
+
+
+QT_END_NAMESPACE
diff --git a/src/widgets/kernel/qbackingstore_p.h b/src/widgets/kernel/qbackingstore_p.h
new file mode 100644
index 0000000000..fe448da901
--- /dev/null
+++ b/src/widgets/kernel/qbackingstore_p.h
@@ -0,0 +1,278 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBACKINGSTORE_P_H
+#define QBACKINGSTORE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QDebug>
+#include <QtWidgets/qwidget.h>
+#include <private/qwidget_p.h>
+#include <private/qwindowsurface_p.h>
+#ifdef Q_WS_QWS
+#include <private/qwindowsurface_qws_p.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+class QWindowSurface;
+
+struct BeginPaintInfo {
+ inline BeginPaintInfo() : wasFlushed(0), nothingToPaint(0), windowSurfaceRecreated(0) {}
+ uint wasFlushed : 1;
+ uint nothingToPaint : 1;
+ uint windowSurfaceRecreated : 1;
+};
+
+class Q_AUTOTEST_EXPORT QWidgetBackingStore
+{
+public:
+ QWidgetBackingStore(QWidget *t);
+ ~QWidgetBackingStore();
+
+ static void showYellowThing(QWidget *widget, const QRegion &rgn, int msec, bool);
+
+ void sync(QWidget *exposedWidget, const QRegion &exposedRegion);
+ void sync();
+ void flush(QWidget *widget = 0, QWindowSurface *surface = 0);
+
+ inline QPoint topLevelOffset() const { return tlwOffset; }
+
+ QWindowSurface *surface() const { return windowSurface; }
+
+ inline bool isDirty() const
+ {
+ return !(dirtyWidgets.isEmpty() && dirty.isEmpty() && !hasDirtyFromPreviousSync
+ && !fullUpdatePending
+#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER)
+ && !hasDirtyWindowDecoration()
+#endif
+ );
+ }
+
+ // ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
+ void markDirty(const QRegion &rgn, QWidget *widget, bool updateImmediately = false,
+ bool invalidateBuffer = false);
+ void markDirty(const QRect &rect, QWidget *widget, bool updateImmediately = false,
+ bool invalidateBuffer = false);
+
+private:
+ QWidget *tlw;
+ QRegion dirtyOnScreen; // needsFlush
+ QRegion dirty; // needsRepaint
+ QRegion dirtyFromPreviousSync;
+ QVector<QWidget *> dirtyWidgets;
+ QVector<QWidget *> *dirtyOnScreenWidgets;
+ QList<QWidget *> staticWidgets;
+ QWindowSurface *windowSurface;
+#ifdef Q_BACKINGSTORE_SUBSURFACES
+ QList<QWindowSurface*> subSurfaces;
+#endif
+ uint hasDirtyFromPreviousSync : 1;
+ uint fullUpdatePending : 1;
+
+ QPoint tlwOffset;
+
+ static bool flushPaint(QWidget *widget, const QRegion &rgn);
+ static void unflushPaint(QWidget *widget, const QRegion &rgn);
+
+ bool bltRect(const QRect &rect, int dx, int dy, QWidget *widget);
+ void releaseBuffer();
+
+ void beginPaint(QRegion &toClean, QWidget *widget, QWindowSurface *windowSurface,
+ BeginPaintInfo *returnInfo, bool toCleanIsInTopLevelCoordinates = true);
+ void endPaint(const QRegion &cleaned, QWindowSurface *windowSurface, BeginPaintInfo *beginPaintInfo);
+
+ QRegion dirtyRegion(QWidget *widget = 0) const;
+ QRegion staticContents(QWidget *widget = 0, const QRect &withinClipRect = QRect()) const;
+
+ void markDirtyOnScreen(const QRegion &dirtyOnScreen, QWidget *widget, const QPoint &topLevelOffset);
+
+ void removeDirtyWidget(QWidget *w);
+
+#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER)
+ bool hasDirtyWindowDecoration() const;
+ void paintWindowDecoration();
+#endif
+ void updateLists(QWidget *widget);
+
+ inline void addDirtyWidget(QWidget *widget, const QRegion &rgn)
+ {
+ if (widget && !widget->d_func()->inDirtyList && !widget->data->in_destructor) {
+ QWidgetPrivate *widgetPrivate = widget->d_func();
+#ifndef QT_NO_GRAPHICSEFFECT
+ if (widgetPrivate->graphicsEffect)
+ widgetPrivate->dirty = widgetPrivate->effectiveRectFor(rgn.boundingRect());
+ else
+#endif //QT_NO_GRAPHICSEFFECT
+ widgetPrivate->dirty = rgn;
+ dirtyWidgets.append(widget);
+ widgetPrivate->inDirtyList = true;
+ }
+ }
+
+ inline void dirtyWidgetsRemoveAll(QWidget *widget)
+ {
+ int i = 0;
+ while (i < dirtyWidgets.size()) {
+ if (dirtyWidgets.at(i) == widget)
+ dirtyWidgets.remove(i);
+ else
+ ++i;
+ }
+ }
+
+ inline void addStaticWidget(QWidget *widget)
+ {
+ if (!widget)
+ return;
+
+ Q_ASSERT(widget->testAttribute(Qt::WA_StaticContents));
+ if (!staticWidgets.contains(widget))
+ staticWidgets.append(widget);
+ }
+
+ inline void removeStaticWidget(QWidget *widget)
+ { staticWidgets.removeAll(widget); }
+
+ // Move the reparented widget and all its static children from this backing store
+ // to the new backing store if reparented into another top-level / backing store.
+ inline void moveStaticWidgets(QWidget *reparented)
+ {
+ Q_ASSERT(reparented);
+ QWidgetBackingStore *newBs = reparented->d_func()->maybeBackingStore();
+ if (newBs == this)
+ return;
+
+ int i = 0;
+ while (i < staticWidgets.size()) {
+ QWidget *w = staticWidgets.at(i);
+ if (reparented == w || reparented->isAncestorOf(w)) {
+ staticWidgets.removeAt(i);
+ if (newBs)
+ newBs->addStaticWidget(w);
+ } else {
+ ++i;
+ }
+ }
+ }
+
+ inline QRect topLevelRect() const
+ {
+#ifdef Q_WS_QWS
+ return tlw->frameGeometry();
+#else
+ return tlw->data->crect;
+#endif
+ }
+
+ inline void appendDirtyOnScreenWidget(QWidget *widget)
+ {
+ if (!widget)
+ return;
+
+ if (!dirtyOnScreenWidgets) {
+ dirtyOnScreenWidgets = new QVector<QWidget *>;
+ dirtyOnScreenWidgets->append(widget);
+ } else if (!dirtyOnScreenWidgets->contains(widget)) {
+ dirtyOnScreenWidgets->append(widget);
+ }
+ }
+
+ inline void dirtyOnScreenWidgetsRemoveAll(QWidget *widget)
+ {
+ if (!widget || !dirtyOnScreenWidgets)
+ return;
+
+ int i = 0;
+ while (i < dirtyOnScreenWidgets->size()) {
+ if (dirtyOnScreenWidgets->at(i) == widget)
+ dirtyOnScreenWidgets->remove(i);
+ else
+ ++i;
+ }
+ }
+
+ inline void resetWidget(QWidget *widget)
+ {
+ if (widget) {
+ widget->d_func()->inDirtyList = false;
+ widget->d_func()->isScrolled = false;
+ widget->d_func()->isMoved = false;
+ widget->d_func()->dirty = QRegion();
+ }
+ }
+
+ inline void updateStaticContentsSize()
+ {
+ for (int i = 0; i < staticWidgets.size(); ++i) {
+ QWidgetPrivate *wd = staticWidgets.at(i)->d_func();
+ if (!wd->extra)
+ wd->createExtra();
+ wd->extra->staticContentsSize = wd->data.crect.size();
+ }
+ }
+
+ inline bool hasStaticContents() const
+ { return !staticWidgets.isEmpty() && windowSurface->hasFeature(QWindowSurface::StaticContents); }
+
+ friend QRegion qt_dirtyRegion(QWidget *);
+ friend class QWidgetPrivate;
+ friend class QWidget;
+ friend class QWSManagerPrivate;
+ friend class QETWidget;
+ friend class QWindowSurface;
+ friend class QWSWindowSurface;
+};
+
+QT_END_NAMESPACE
+
+#endif // QBACKINGSTORE_P_H
diff --git a/src/gui/kernel/qboxlayout.cpp b/src/widgets/kernel/qboxlayout.cpp
index 6946f9bd27..6946f9bd27 100644
--- a/src/gui/kernel/qboxlayout.cpp
+++ b/src/widgets/kernel/qboxlayout.cpp
diff --git a/src/widgets/kernel/qboxlayout.h b/src/widgets/kernel/qboxlayout.h
new file mode 100644
index 0000000000..b97d909994
--- /dev/null
+++ b/src/widgets/kernel/qboxlayout.h
@@ -0,0 +1,173 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBOXLAYOUT_H
+#define QBOXLAYOUT_H
+
+#include <QtWidgets/qlayout.h>
+#ifdef QT_INCLUDE_COMPAT
+#include <QtWidgets/qwidget.h>
+#endif
+
+#include <limits.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QBoxLayoutPrivate;
+
+class Q_GUI_EXPORT QBoxLayout : public QLayout
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QBoxLayout)
+public:
+ enum Direction { LeftToRight, RightToLeft, TopToBottom, BottomToTop,
+ Down = TopToBottom, Up = BottomToTop };
+
+ explicit QBoxLayout(Direction, QWidget *parent = 0);
+
+#ifdef QT3_SUPPORT
+ QT3_SUPPORT_CONSTRUCTOR QBoxLayout(QWidget *parent, Direction, int border = 0, int spacing = -1,
+ const char *name = 0);
+ QT3_SUPPORT_CONSTRUCTOR QBoxLayout(QLayout *parentLayout, Direction, int spacing = -1,
+ const char *name = 0);
+ QT3_SUPPORT_CONSTRUCTOR QBoxLayout(Direction, int spacing, const char *name = 0);
+#endif
+ ~QBoxLayout();
+
+ Direction direction() const;
+ void setDirection(Direction);
+
+ void addSpacing(int size);
+ void addStretch(int stretch = 0);
+ void addSpacerItem(QSpacerItem *spacerItem);
+ void addWidget(QWidget *, int stretch = 0, Qt::Alignment alignment = 0);
+ void addLayout(QLayout *layout, int stretch = 0);
+ void addStrut(int);
+ void addItem(QLayoutItem *);
+
+ void insertSpacing(int index, int size);
+ void insertStretch(int index, int stretch = 0);
+ void insertSpacerItem(int index, QSpacerItem *spacerItem);
+ void insertWidget(int index, QWidget *widget, int stretch = 0, Qt::Alignment alignment = 0);
+ void insertLayout(int index, QLayout *layout, int stretch = 0);
+
+ int spacing() const;
+ void setSpacing(int spacing);
+
+ bool setStretchFactor(QWidget *w, int stretch);
+ bool setStretchFactor(QLayout *l, int stretch);
+ void setStretch(int index, int stretch);
+ int stretch(int index) const;
+
+ QSize sizeHint() const;
+ QSize minimumSize() const;
+ QSize maximumSize() const;
+
+ bool hasHeightForWidth() const;
+ int heightForWidth(int) const;
+ int minimumHeightForWidth(int) const;
+
+ Qt::Orientations expandingDirections() const;
+ void invalidate();
+ QLayoutItem *itemAt(int) const;
+ QLayoutItem *takeAt(int);
+ int count() const;
+ void setGeometry(const QRect&);
+#ifdef QT3_SUPPORT
+ inline QT3_SUPPORT int findWidget(QWidget* w) {return indexOf(w);}
+#endif
+protected:
+ // ### Qt 5: make public
+ void insertItem(int index, QLayoutItem *);
+
+private:
+ Q_DISABLE_COPY(QBoxLayout)
+};
+
+class Q_GUI_EXPORT QHBoxLayout : public QBoxLayout
+{
+ Q_OBJECT
+public:
+ QHBoxLayout();
+ explicit QHBoxLayout(QWidget *parent);
+ ~QHBoxLayout();
+
+#ifdef QT3_SUPPORT
+ QT3_SUPPORT_CONSTRUCTOR QHBoxLayout(QWidget *parent, int border,
+ int spacing = -1, const char *name = 0);
+ QT3_SUPPORT_CONSTRUCTOR QHBoxLayout(QLayout *parentLayout,
+ int spacing = -1, const char *name = 0);
+ QT3_SUPPORT_CONSTRUCTOR QHBoxLayout(int spacing, const char *name = 0);
+#endif
+
+private:
+ Q_DISABLE_COPY(QHBoxLayout)
+};
+
+class Q_GUI_EXPORT QVBoxLayout : public QBoxLayout
+{
+ Q_OBJECT
+public:
+ QVBoxLayout();
+ explicit QVBoxLayout(QWidget *parent);
+ ~QVBoxLayout();
+
+#ifdef QT3_SUPPORT
+ QT3_SUPPORT_CONSTRUCTOR QVBoxLayout(QWidget *parent, int border,
+ int spacing = -1, const char *name = 0);
+ QT3_SUPPORT_CONSTRUCTOR QVBoxLayout(QLayout *parentLayout,
+ int spacing = -1, const char *name = 0);
+ QT3_SUPPORT_CONSTRUCTOR QVBoxLayout(int spacing, const char *name = 0);
+#endif
+
+private:
+ Q_DISABLE_COPY(QVBoxLayout)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QBOXLAYOUT_H
diff --git a/src/gui/kernel/qdesktopwidget.cpp b/src/widgets/kernel/qdesktopwidget.cpp
index 6e1414dc5d..6e1414dc5d 100644
--- a/src/gui/kernel/qdesktopwidget.cpp
+++ b/src/widgets/kernel/qdesktopwidget.cpp
diff --git a/src/widgets/kernel/qdesktopwidget.h b/src/widgets/kernel/qdesktopwidget.h
new file mode 100644
index 0000000000..7e836b25f2
--- /dev/null
+++ b/src/widgets/kernel/qdesktopwidget.h
@@ -0,0 +1,110 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDESKTOPWIDGET_H
+#define QDESKTOPWIDGET_H
+
+#include <QtWidgets/qwidget.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QApplication;
+class QDesktopWidgetPrivate;
+
+class Q_GUI_EXPORT QDesktopWidget : public QWidget
+{
+ Q_OBJECT
+ Q_PROPERTY(bool virtualDesktop READ isVirtualDesktop)
+ Q_PROPERTY(int screenCount READ screenCount NOTIFY screenCountChanged)
+ Q_PROPERTY(int primaryScreen READ primaryScreen)
+public:
+ QDesktopWidget();
+ ~QDesktopWidget();
+
+ bool isVirtualDesktop() const;
+
+ int numScreens() const;
+ int screenCount() const;
+ int primaryScreen() const;
+
+ int screenNumber(const QWidget *widget = 0) const;
+ int screenNumber(const QPoint &) const;
+
+ QWidget *screen(int screen = -1);
+
+ const QRect screenGeometry(int screen = -1) const;
+ const QRect screenGeometry(const QWidget *widget) const;
+ const QRect screenGeometry(const QPoint &point) const
+ { return screenGeometry(screenNumber(point)); }
+
+ const QRect availableGeometry(int screen = -1) const;
+ const QRect availableGeometry(const QWidget *widget) const;
+ const QRect availableGeometry(const QPoint &point) const
+ { return availableGeometry(screenNumber(point)); }
+
+Q_SIGNALS:
+ void resized(int);
+ void workAreaResized(int);
+ void screenCountChanged(int);
+
+protected:
+ void resizeEvent(QResizeEvent *e);
+
+private:
+ Q_DISABLE_COPY(QDesktopWidget)
+ Q_DECLARE_PRIVATE(QDesktopWidget)
+
+ friend class QApplication;
+ friend class QApplicationPrivate;
+};
+
+inline int QDesktopWidget::screenCount() const
+{ return numScreens(); }
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDESKTOPWIDGET_H
diff --git a/src/gui/kernel/qdesktopwidget.qdoc b/src/widgets/kernel/qdesktopwidget.qdoc
index a79a098d74..a79a098d74 100644
--- a/src/gui/kernel/qdesktopwidget.qdoc
+++ b/src/widgets/kernel/qdesktopwidget.qdoc
diff --git a/src/widgets/kernel/qdesktopwidget_qpa.cpp b/src/widgets/kernel/qdesktopwidget_qpa.cpp
new file mode 100644
index 0000000000..7b175dbe95
--- /dev/null
+++ b/src/widgets/kernel/qdesktopwidget_qpa.cpp
@@ -0,0 +1,174 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdesktopwidget.h"
+#include "private/qapplication_p.h"
+#include <QWidget>
+#include "private/qwidget_p.h"
+#include "private/qdesktopwidget_qpa_p.h"
+QT_BEGIN_NAMESPACE
+
+QT_USE_NAMESPACE
+
+void QDesktopWidgetPrivate::updateScreenList()
+{
+ Q_Q(QDesktopWidget);
+ QList<QPlatformScreen *> screenList = QGuiApplicationPrivate::platformIntegration()->screens();
+ int targetLength = screenList.length();
+ int currentLength = screens.length();
+
+ // Add or remove screen widgets as necessary
+ if(currentLength > targetLength) {
+ QDesktopScreenWidget *screen;
+ while (currentLength-- > targetLength) {
+ screen = screens.takeLast();
+ delete screen;
+ }
+ }
+ else if (currentLength < targetLength) {
+ QDesktopScreenWidget *screen;
+ while (currentLength < targetLength) {
+ screen = new QDesktopScreenWidget(currentLength++);
+ screens.append(screen);
+ }
+ }
+
+ QRegion virtualGeometry;
+
+ // update the geometry of each screen widget
+ for (int i = 0; i < screens.length(); i++) {
+ QRect screenGeometry = screenList.at(i)->geometry();
+ screens.at(i)->setGeometry(screenGeometry);
+ virtualGeometry += screenGeometry;
+ }
+
+ q->setGeometry(virtualGeometry.boundingRect());
+}
+
+QDesktopWidget::QDesktopWidget()
+ : QWidget(*new QDesktopWidgetPrivate, 0, Qt::Desktop)
+{
+ Q_D(QDesktopWidget);
+ setObjectName(QLatin1String("desktop"));
+ d->updateScreenList();
+}
+
+QDesktopWidget::~QDesktopWidget()
+{
+}
+
+bool QDesktopWidget::isVirtualDesktop() const
+{
+ return QGuiApplicationPrivate::platformIntegration()->isVirtualDesktop();
+}
+
+int QDesktopWidget::primaryScreen() const
+{
+ return 0;
+}
+
+int QDesktopWidget::numScreens() const
+{
+ QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration();
+ return qMax(pi->screens().size(), 1);
+}
+
+QWidget *QDesktopWidget::screen(int screen)
+{
+ Q_D(QDesktopWidget);
+ if (screen < 0 || screen >= d->screens.length())
+ return d->screens.at(0);
+ return d->screens.at(screen);
+}
+
+const QRect QDesktopWidget::availableGeometry(int screenNo) const
+{
+ QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration();
+ QList<QPlatformScreen *> screens = pi->screens();
+ if (screenNo == -1)
+ screenNo = 0;
+ if (screenNo < 0 || screenNo >= screens.size())
+ return QRect();
+ else
+ return screens[screenNo]->availableGeometry();
+}
+
+const QRect QDesktopWidget::screenGeometry(int screenNo) const
+{
+ QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration();
+ QList<QPlatformScreen *> screens = pi->screens();
+ if (screenNo == -1)
+ screenNo = 0;
+ if (screenNo < 0 || screenNo >= screens.size())
+ return QRect();
+ else
+ return screens[screenNo]->geometry();
+}
+
+int QDesktopWidget::screenNumber(const QWidget *w) const
+{
+ if (!w)
+ return 0;
+
+ QRect frame = w->frameGeometry();
+ if (!w->isWindow())
+ frame.moveTopLeft(w->mapToGlobal(QPoint(0, 0)));
+ const QPoint midpoint = (frame.topLeft() + frame.bottomRight()) / 2;
+ return screenNumber(midpoint);
+}
+
+int QDesktopWidget::screenNumber(const QPoint &p) const
+{
+ QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration();
+ QList<QPlatformScreen *> screens = pi->screens();
+
+ for (int i = 0; i < screens.size(); ++i)
+ if (screens[i]->geometry().contains(p))
+ return i;
+
+ return primaryScreen(); //even better would be closest screen
+}
+
+void QDesktopWidget::resizeEvent(QResizeEvent *)
+{
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qdesktopwidget_qpa_p.h b/src/widgets/kernel/qdesktopwidget_qpa_p.h
index d6ed686a3f..d6ed686a3f 100644
--- a/src/gui/kernel/qdesktopwidget_qpa_p.h
+++ b/src/widgets/kernel/qdesktopwidget_qpa_p.h
diff --git a/src/gui/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp
index d098c01f0f..d098c01f0f 100644
--- a/src/gui/kernel/qformlayout.cpp
+++ b/src/widgets/kernel/qformlayout.cpp
diff --git a/src/widgets/kernel/qformlayout.h b/src/widgets/kernel/qformlayout.h
new file mode 100644
index 0000000000..60ce12cd3a
--- /dev/null
+++ b/src/widgets/kernel/qformlayout.h
@@ -0,0 +1,163 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QFORMLAYOUT_H
+#define QFORMLAYOUT_H
+
+#include <QtWidgets/QLayout>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QFormLayoutPrivate;
+
+class Q_GUI_EXPORT QFormLayout : public QLayout
+{
+ Q_OBJECT
+ Q_ENUMS(FormStyle FieldGrowthPolicy RowWrapPolicy ItemRole)
+ Q_DECLARE_PRIVATE(QFormLayout)
+ Q_PROPERTY(FieldGrowthPolicy fieldGrowthPolicy READ fieldGrowthPolicy WRITE setFieldGrowthPolicy RESET resetFieldGrowthPolicy)
+ Q_PROPERTY(RowWrapPolicy rowWrapPolicy READ rowWrapPolicy WRITE setRowWrapPolicy RESET resetRowWrapPolicy)
+ Q_PROPERTY(Qt::Alignment labelAlignment READ labelAlignment WRITE setLabelAlignment RESET resetLabelAlignment)
+ Q_PROPERTY(Qt::Alignment formAlignment READ formAlignment WRITE setFormAlignment RESET resetFormAlignment)
+ Q_PROPERTY(int horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing)
+ Q_PROPERTY(int verticalSpacing READ verticalSpacing WRITE setVerticalSpacing)
+
+public:
+ enum FieldGrowthPolicy {
+ FieldsStayAtSizeHint,
+ ExpandingFieldsGrow,
+ AllNonFixedFieldsGrow
+ };
+
+ enum RowWrapPolicy {
+ DontWrapRows,
+ WrapLongRows,
+ WrapAllRows
+ };
+
+ enum ItemRole {
+ LabelRole = 0,
+ FieldRole = 1,
+ SpanningRole = 2
+ };
+
+ explicit QFormLayout(QWidget *parent = 0);
+ ~QFormLayout();
+
+ void setFieldGrowthPolicy(FieldGrowthPolicy policy);
+ FieldGrowthPolicy fieldGrowthPolicy() const;
+ void setRowWrapPolicy(RowWrapPolicy policy);
+ RowWrapPolicy rowWrapPolicy() const;
+ void setLabelAlignment(Qt::Alignment alignment);
+ Qt::Alignment labelAlignment() const;
+ void setFormAlignment(Qt::Alignment alignment);
+ Qt::Alignment formAlignment() const;
+
+ void setHorizontalSpacing(int spacing);
+ int horizontalSpacing() const;
+ void setVerticalSpacing(int spacing);
+ int verticalSpacing() const;
+
+ int spacing() const;
+ void setSpacing(int);
+
+ void addRow(QWidget *label, QWidget *field);
+ void addRow(QWidget *label, QLayout *field);
+ void addRow(const QString &labelText, QWidget *field);
+ void addRow(const QString &labelText, QLayout *field);
+ void addRow(QWidget *widget);
+ void addRow(QLayout *layout);
+
+ void insertRow(int row, QWidget *label, QWidget *field);
+ void insertRow(int row, QWidget *label, QLayout *field);
+ void insertRow(int row, const QString &labelText, QWidget *field);
+ void insertRow(int row, const QString &labelText, QLayout *field);
+ void insertRow(int row, QWidget *widget);
+ void insertRow(int row, QLayout *layout);
+
+ void setItem(int row, ItemRole role, QLayoutItem *item);
+ void setWidget(int row, ItemRole role, QWidget *widget);
+ void setLayout(int row, ItemRole role, QLayout *layout);
+
+ QLayoutItem *itemAt(int row, ItemRole role) const;
+ void getItemPosition(int index, int *rowPtr, ItemRole *rolePtr) const;
+ void getWidgetPosition(QWidget *widget, int *rowPtr, ItemRole *rolePtr) const;
+ void getLayoutPosition(QLayout *layout, int *rowPtr, ItemRole *rolePtr) const;
+ QWidget *labelForField(QWidget *field) const;
+ QWidget *labelForField(QLayout *field) const;
+
+ // reimplemented from QLayout
+ void addItem(QLayoutItem *item);
+ QLayoutItem *itemAt(int index) const;
+ QLayoutItem *takeAt(int index);
+
+ void setGeometry(const QRect &rect);
+ QSize minimumSize() const;
+ QSize sizeHint() const;
+ void invalidate();
+
+ bool hasHeightForWidth() const;
+ int heightForWidth(int width) const;
+ Qt::Orientations expandingDirections() const;
+ int count() const;
+
+ int rowCount() const;
+
+#if 0
+ void dump() const;
+#endif
+
+private:
+ void resetFieldGrowthPolicy();
+ void resetRowWrapPolicy();
+ void resetLabelAlignment();
+ void resetFormAlignment();
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
diff --git a/src/widgets/kernel/qgesture.cpp b/src/widgets/kernel/qgesture.cpp
new file mode 100644
index 0000000000..daabe4f436
--- /dev/null
+++ b/src/widgets/kernel/qgesture.cpp
@@ -0,0 +1,1118 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgesture.h"
+#include "private/qgesture_p.h"
+#include "private/qstandardgestures_p.h"
+#include "qgraphicsview.h"
+
+#ifndef QT_NO_GESTURES
+
+QT_BEGIN_NAMESPACE
+
+ /*!
+ \class QGesture
+ \since 4.6
+ \ingroup gestures
+
+ \brief The QGesture class represents a gesture, containing properties that
+ describe the corresponding user input.
+
+ Gesture objects are not constructed directly by developers. They are created by
+ the QGestureRecognizer object that is registered with the application; see
+ QGestureRecognizer::registerRecognizer().
+
+ For an overview of gesture handling in Qt and information on using gestures
+ in your applications, see the \l{Gestures Programming} document.
+
+ \section1 Gesture Properties
+
+ The class has a list of properties that can be queried by the user to get
+ some gesture-specific arguments. For example, the pinch gesture has a scale
+ factor that is exposed as a property.
+
+ Developers of custom gesture recognizers can add additional properties in
+ order to provide additional information about a gesture. This can be done
+ by adding new dynamic properties to a QGesture object, or by subclassing
+ the QGesture class (or one of its subclasses).
+
+ \section1 Lifecycle of a Gesture Object
+
+ A QGesture instance is implicitly created when needed and is owned by Qt.
+ Developers should never destroy them or store them for later use as Qt may
+ destroy particular instances of them and create new ones to replace them.
+
+ The registered gesture recognizer monitors the input events for the target
+ object via its \l{QGestureRecognizer::}{recognize()} function, updating the
+ properties of the gesture object as required.
+
+ The gesture object may be delivered to the target object in a QGestureEvent if
+ the corresponding gesture is active or has just been canceled. Each event that
+ is delivered contains a list of gesture objects, since support for more than
+ one gesture may be enabled for the target object. Due to the way events are
+ handled in Qt, gesture events may be filtered by other objects.
+
+ \sa QGestureEvent, QGestureRecognizer
+*/
+
+/*!
+ Constructs a new gesture object with the given \a parent.
+
+ QGesture objects are created by gesture recognizers in the
+ QGestureRecognizer::create() function.
+*/
+QGesture::QGesture(QObject *parent)
+ : QObject(*new QGesturePrivate, parent)
+{
+ d_func()->gestureType = Qt::CustomGesture;
+}
+
+/*!
+ \internal
+*/
+QGesture::QGesture(QGesturePrivate &dd, QObject *parent)
+ : QObject(dd, parent)
+{
+}
+
+/*!
+ Destroys the gesture object.
+*/
+QGesture::~QGesture()
+{
+}
+
+/*!
+ \property QGesture::state
+ \brief the current state of the gesture
+*/
+
+/*!
+ \property QGesture::gestureType
+ \brief the type of the gesture
+*/
+
+/*!
+ \property QGesture::hotSpot
+
+ \brief The point that is used to find the receiver for the gesture event.
+
+ The hot-spot is a point in the global coordinate system, use
+ QWidget::mapFromGlobal() or QGestureEvent::mapToGraphicsScene() to get a
+ local hot-spot.
+
+ The hot-spot should be set by the gesture recognizer to allow gesture event
+ delivery to a QGraphicsObject.
+*/
+
+/*!
+ \property QGesture::hasHotSpot
+ \brief whether the gesture has a hot-spot
+*/
+
+Qt::GestureType QGesture::gestureType() const
+{
+ return d_func()->gestureType;
+}
+
+Qt::GestureState QGesture::state() const
+{
+ return d_func()->state;
+}
+
+QPointF QGesture::hotSpot() const
+{
+ return d_func()->hotSpot;
+}
+
+void QGesture::setHotSpot(const QPointF &value)
+{
+ Q_D(QGesture);
+ d->hotSpot = value;
+ d->isHotSpotSet = true;
+}
+
+bool QGesture::hasHotSpot() const
+{
+ return d_func()->isHotSpotSet;
+}
+
+void QGesture::unsetHotSpot()
+{
+ d_func()->isHotSpotSet = false;
+}
+
+/*!
+ \property QGesture::gestureCancelPolicy
+ \brief the policy for deciding what happens on accepting a gesture
+
+ On accepting one gesture Qt can automatically cancel other gestures
+ that belong to other targets. The policy is normally set to not cancel
+ any other gestures and can be set to cancel all active gestures in the
+ context. For example for all child widgets.
+*/
+
+/*!
+ \enum QGesture::GestureCancelPolicy
+
+ This enum describes how accepting a gesture can cancel other gestures
+ automatically.
+
+ \value CancelNone On accepting this gesture no other gestures will be affected.
+
+ \value CancelAllInContext On accepting this gesture all gestures that are
+ active in the context (respecting the Qt::GestureFlag that were specified
+ when subscribed to the gesture) will be cancelled.
+*/
+
+void QGesture::setGestureCancelPolicy(GestureCancelPolicy policy)
+{
+ Q_D(QGesture);
+ d->gestureCancelPolicy = static_cast<uint>(policy);
+}
+
+QGesture::GestureCancelPolicy QGesture::gestureCancelPolicy() const
+{
+ Q_D(const QGesture);
+ return static_cast<GestureCancelPolicy>(d->gestureCancelPolicy);
+}
+
+/*!
+ \class QPanGesture
+ \since 4.6
+ \brief The QPanGesture class describes a panning gesture made by the user.
+ \ingroup gestures
+
+ \image pangesture.png
+
+ For an overview of gesture handling in Qt and information on using gestures
+ in your applications, see the \l{Gestures Programming} document.
+
+ \sa QPinchGesture, QSwipeGesture
+*/
+
+/*!
+ \property QPanGesture::lastOffset
+ \brief the last offset recorded for this gesture
+
+ The last offset contains the change in position of the user's input as
+ reported in the \l offset property when a previous gesture event was
+ delivered for this gesture.
+
+ If no previous event was delivered with information about this gesture
+ (i.e., this gesture object contains information about the first movement
+ in the gesture) then this property contains a zero size.
+*/
+
+/*!
+ \property QPanGesture::offset
+ \brief the total offset from the first input position to the current input
+ position
+
+ The offset measures the total change in position of the user's input
+ covered by the gesture on the input device.
+*/
+
+/*!
+ \property QPanGesture::delta
+ \brief the offset from the previous input position to the current input
+
+ This is essentially the same as the difference between offset() and
+ lastOffset().
+*/
+
+/*!
+ \property QPanGesture::acceleration
+ \brief the acceleration in the motion of the touch point for this gesture
+*/
+
+/*!
+ \property QPanGesture::horizontalVelocity
+ \brief the horizontal component of the motion of the touch point for this
+ gesture
+ \since 4.7.1
+ \internal
+
+ \sa verticalVelocity, acceleration
+*/
+
+/*!
+ \property QPanGesture::verticalVelocity
+ \brief the vertical component of the motion of the touch point for this
+ gesture
+ \since 4.7.1
+ \internal
+
+ \sa horizontalVelocity, acceleration
+*/
+
+/*!
+ \internal
+*/
+QPanGesture::QPanGesture(QObject *parent)
+ : QGesture(*new QPanGesturePrivate, parent)
+{
+ d_func()->gestureType = Qt::PanGesture;
+}
+
+
+QPointF QPanGesture::lastOffset() const
+{
+ return d_func()->lastOffset;
+}
+
+QPointF QPanGesture::offset() const
+{
+ return d_func()->offset;
+}
+
+QPointF QPanGesture::delta() const
+{
+ Q_D(const QPanGesture);
+ return d->offset - d->lastOffset;
+}
+
+qreal QPanGesture::acceleration() const
+{
+ return d_func()->acceleration;
+}
+
+void QPanGesture::setLastOffset(const QPointF &value)
+{
+ d_func()->lastOffset = value;
+}
+
+void QPanGesture::setOffset(const QPointF &value)
+{
+ d_func()->offset = value;
+}
+
+void QPanGesture::setAcceleration(qreal value)
+{
+ d_func()->acceleration = value;
+}
+
+/*!
+ \class QPinchGesture
+ \since 4.6
+ \brief The QPinchGesture class describes a pinch gesture made by the user.
+ \ingroup touch
+ \ingroup gestures
+
+ A pinch gesture is a form of touch user input in which the user typically
+ touches two points on the input device with a thumb and finger, before moving
+ them closer together or further apart to change the scale factor, zoom, or level
+ of detail of the user interface.
+
+ For an overview of gesture handling in Qt and information on using gestures
+ in your applications, see the \l{Gestures Programming} document.
+
+ \image pinchgesture.png
+
+ Instead of repeatedly applying the same pinching gesture, the user may
+ continue to touch the input device in one place, and apply a second touch
+ to a new point, continuing the gesture. When this occurs, gesture events
+ will continue to be delivered to the target object, containing an instance
+ of QPinchGesture in the Qt::GestureUpdated state.
+
+ \sa QPanGesture, QSwipeGesture
+*/
+
+/*!
+ \enum QPinchGesture::ChangeFlag
+
+ This enum describes the changes that can occur to the properties of
+ the gesture object.
+
+ \value ScaleFactorChanged The scale factor held by scaleFactor changed.
+ \value RotationAngleChanged The rotation angle held by rotationAngle changed.
+ \value CenterPointChanged The center point held by centerPoint changed.
+
+ \sa changeFlags, totalChangeFlags
+*/
+
+/*!
+ \property QPinchGesture::totalChangeFlags
+ \brief the property of the gesture that has change
+
+ This property indicates which of the other properties has changed since the
+ gesture has started. You can use this information to determine which aspect
+ of your user interface needs to be updated.
+
+ \sa changeFlags, scaleFactor, rotationAngle, centerPoint
+*/
+
+/*!
+ \property QPinchGesture::changeFlags
+ \brief the property of the gesture that has changed in the current step
+
+ This property indicates which of the other properties has changed since
+ the previous gesture event included information about this gesture. You
+ can use this information to determine which aspect of your user interface
+ needs to be updated.
+
+ \sa totalChangeFlags, scaleFactor, rotationAngle, centerPoint
+*/
+
+/*!
+ \property QPinchGesture::totalScaleFactor
+ \brief the total scale factor
+
+ The total scale factor measures the total change in scale factor from the
+ original value to the current scale factor.
+
+ \sa scaleFactor, lastScaleFactor
+*/
+/*!
+ \property QPinchGesture::lastScaleFactor
+ \brief the last scale factor recorded for this gesture
+
+ The last scale factor contains the scale factor reported in the
+ \l scaleFactor property when a previous gesture event included
+ information about this gesture.
+
+ If no previous event was delivered with information about this gesture
+ (i.e., this gesture object contains information about the first movement
+ in the gesture) then this property contains zero.
+
+ \sa scaleFactor, totalScaleFactor
+*/
+/*!
+ \property QPinchGesture::scaleFactor
+ \brief the current scale factor
+
+ The scale factor measures the scale factor associated with the distance
+ between two of the user's inputs on a touch device.
+
+ \sa totalScaleFactor, lastScaleFactor
+*/
+
+/*!
+ \property QPinchGesture::totalRotationAngle
+ \brief the total angle covered by the gesture
+
+ This total angle measures the complete angle covered by the gesture. Usually, this
+ is equal to the value held by the \l rotationAngle property, except in the case where
+ the user performs multiple rotations by removing and repositioning one of the touch
+ points, as described above. In this case, the total angle will be the sum of the
+ rotation angles for the multiple stages of the gesture.
+
+ \sa rotationAngle, lastRotationAngle
+*/
+/*!
+ \property QPinchGesture::lastRotationAngle
+ \brief the last reported angle covered by the gesture motion
+
+ The last rotation angle is the angle as reported in the \l rotationAngle property
+ when a previous gesture event was delivered for this gesture.
+
+ \sa rotationAngle, totalRotationAngle
+*/
+/*!
+ \property QPinchGesture::rotationAngle
+ \brief the angle covered by the gesture motion
+
+ \sa totalRotationAngle, lastRotationAngle
+*/
+
+/*!
+ \property QPinchGesture::startCenterPoint
+ \brief the starting position of the center point
+
+ \sa centerPoint, lastCenterPoint
+*/
+/*!
+ \property QPinchGesture::lastCenterPoint
+ \brief the last position of the center point recorded for this gesture
+
+ \sa centerPoint, startCenterPoint
+*/
+/*!
+ \property QPinchGesture::centerPoint
+ \brief the current center point
+
+ The center point is the midpoint between the two input points in the gesture.
+
+ \sa startCenterPoint, lastCenterPoint
+*/
+
+/*!
+ \internal
+*/
+QPinchGesture::QPinchGesture(QObject *parent)
+ : QGesture(*new QPinchGesturePrivate, parent)
+{
+ d_func()->gestureType = Qt::PinchGesture;
+}
+
+QPinchGesture::ChangeFlags QPinchGesture::totalChangeFlags() const
+{
+ return d_func()->totalChangeFlags;
+}
+
+void QPinchGesture::setTotalChangeFlags(QPinchGesture::ChangeFlags value)
+{
+ d_func()->totalChangeFlags = value;
+}
+
+QPinchGesture::ChangeFlags QPinchGesture::changeFlags() const
+{
+ return d_func()->changeFlags;
+}
+
+void QPinchGesture::setChangeFlags(QPinchGesture::ChangeFlags value)
+{
+ d_func()->changeFlags = value;
+}
+
+QPointF QPinchGesture::startCenterPoint() const
+{
+ return d_func()->startCenterPoint;
+}
+
+QPointF QPinchGesture::lastCenterPoint() const
+{
+ return d_func()->lastCenterPoint;
+}
+
+QPointF QPinchGesture::centerPoint() const
+{
+ return d_func()->centerPoint;
+}
+
+void QPinchGesture::setStartCenterPoint(const QPointF &value)
+{
+ d_func()->startCenterPoint = value;
+}
+
+void QPinchGesture::setLastCenterPoint(const QPointF &value)
+{
+ d_func()->lastCenterPoint = value;
+}
+
+void QPinchGesture::setCenterPoint(const QPointF &value)
+{
+ d_func()->centerPoint = value;
+}
+
+
+qreal QPinchGesture::totalScaleFactor() const
+{
+ return d_func()->totalScaleFactor;
+}
+
+qreal QPinchGesture::lastScaleFactor() const
+{
+ return d_func()->lastScaleFactor;
+}
+
+qreal QPinchGesture::scaleFactor() const
+{
+ return d_func()->scaleFactor;
+}
+
+void QPinchGesture::setTotalScaleFactor(qreal value)
+{
+ d_func()->totalScaleFactor = value;
+}
+
+void QPinchGesture::setLastScaleFactor(qreal value)
+{
+ d_func()->lastScaleFactor = value;
+}
+
+void QPinchGesture::setScaleFactor(qreal value)
+{
+ d_func()->scaleFactor = value;
+}
+
+
+qreal QPinchGesture::totalRotationAngle() const
+{
+ return d_func()->totalRotationAngle;
+}
+
+qreal QPinchGesture::lastRotationAngle() const
+{
+ return d_func()->lastRotationAngle;
+}
+
+qreal QPinchGesture::rotationAngle() const
+{
+ return d_func()->rotationAngle;
+}
+
+void QPinchGesture::setTotalRotationAngle(qreal value)
+{
+ d_func()->totalRotationAngle = value;
+}
+
+void QPinchGesture::setLastRotationAngle(qreal value)
+{
+ d_func()->lastRotationAngle = value;
+}
+
+void QPinchGesture::setRotationAngle(qreal value)
+{
+ d_func()->rotationAngle = value;
+}
+
+/*!
+ \class QSwipeGesture
+ \since 4.6
+ \brief The QSwipeGesture class describes a swipe gesture made by the user.
+ \ingroup gestures
+
+ \image swipegesture.png
+
+ For an overview of gesture handling in Qt and information on using gestures
+ in your applications, see the \l{Gestures Programming} document.
+
+ \sa QPanGesture, QPinchGesture
+*/
+
+/*!
+ \enum QSwipeGesture::SwipeDirection
+
+ This enum describes the possible directions for the gesture's motion
+ along the horizontal and vertical axes.
+
+ \value NoDirection The gesture had no motion associated with it on a particular axis.
+ \value Left The gesture involved a horizontal motion to the left.
+ \value Right The gesture involved a horizontal motion to the right.
+ \value Up The gesture involved an upward vertical motion.
+ \value Down The gesture involved a downward vertical motion.
+*/
+
+/*!
+ \property QSwipeGesture::horizontalDirection
+ \brief the horizontal direction of the gesture
+
+ If the gesture has a horizontal component, the horizontal direction
+ is either Left or Right; otherwise, it is NoDirection.
+
+ \sa verticalDirection, swipeAngle
+*/
+
+/*!
+ \property QSwipeGesture::verticalDirection
+ \brief the vertical direction of the gesture
+
+ If the gesture has a vertical component, the vertical direction
+ is either Up or Down; otherwise, it is NoDirection.
+
+ \sa horizontalDirection, swipeAngle
+*/
+
+/*!
+ \property QSwipeGesture::swipeAngle
+ \brief the angle of the motion associated with the gesture
+
+ If the gesture has either a horizontal or vertical component, the
+ swipe angle describes the angle between the direction of motion and the
+ x-axis as defined using the standard widget
+ \l{Coordinate System}{coordinate system}.
+
+ \sa horizontalDirection, verticalDirection
+*/
+
+/*!
+ \property QSwipeGesture::velocity
+ \since 4.7.1
+ \internal
+*/
+
+/*!
+ \internal
+*/
+QSwipeGesture::QSwipeGesture(QObject *parent)
+ : QGesture(*new QSwipeGesturePrivate, parent)
+{
+ d_func()->gestureType = Qt::SwipeGesture;
+}
+
+QSwipeGesture::SwipeDirection QSwipeGesture::horizontalDirection() const
+{
+ Q_D(const QSwipeGesture);
+ if (d->swipeAngle < 0 || d->swipeAngle == 90 || d->swipeAngle == 270)
+ return QSwipeGesture::NoDirection;
+ else if (d->swipeAngle < 90 || d->swipeAngle > 270)
+ return QSwipeGesture::Right;
+ else
+ return QSwipeGesture::Left;
+}
+
+QSwipeGesture::SwipeDirection QSwipeGesture::verticalDirection() const
+{
+ Q_D(const QSwipeGesture);
+ if (d->swipeAngle <= 0 || d->swipeAngle == 180)
+ return QSwipeGesture::NoDirection;
+ else if (d->swipeAngle < 180)
+ return QSwipeGesture::Up;
+ else
+ return QSwipeGesture::Down;
+}
+
+qreal QSwipeGesture::swipeAngle() const
+{
+ return d_func()->swipeAngle;
+}
+
+void QSwipeGesture::setSwipeAngle(qreal value)
+{
+ d_func()->swipeAngle = value;
+}
+
+/*!
+ \class QTapGesture
+ \since 4.6
+ \brief The QTapGesture class describes a tap gesture made by the user.
+ \ingroup gestures
+
+ For an overview of gesture handling in Qt and information on using gestures
+ in your applications, see the \l{Gestures Programming} document.
+
+ \sa QPanGesture, QPinchGesture
+*/
+
+/*!
+ \property QTapGesture::position
+ \brief the position of the tap
+*/
+
+/*!
+ \internal
+*/
+QTapGesture::QTapGesture(QObject *parent)
+ : QGesture(*new QTapGesturePrivate, parent)
+{
+ d_func()->gestureType = Qt::TapGesture;
+}
+
+QPointF QTapGesture::position() const
+{
+ return d_func()->position;
+}
+
+void QTapGesture::setPosition(const QPointF &value)
+{
+ d_func()->position = value;
+}
+/*!
+ \class QTapAndHoldGesture
+ \since 4.6
+ \brief The QTapAndHoldGesture class describes a tap-and-hold (aka LongTap)
+ gesture made by the user.
+ \ingroup gestures
+
+ For an overview of gesture handling in Qt and information on using gestures
+ in your applications, see the \l{Gestures Programming} document.
+
+ \sa QPanGesture, QPinchGesture
+*/
+
+/*!
+ \property QTapAndHoldGesture::position
+ \brief the position of the tap
+*/
+
+/*!
+ \internal
+*/
+QTapAndHoldGesture::QTapAndHoldGesture(QObject *parent)
+ : QGesture(*new QTapAndHoldGesturePrivate, parent)
+{
+ d_func()->gestureType = Qt::TapAndHoldGesture;
+}
+
+QPointF QTapAndHoldGesture::position() const
+{
+ return d_func()->position;
+}
+
+void QTapAndHoldGesture::setPosition(const QPointF &value)
+{
+ d_func()->position = value;
+}
+
+/*!
+ Set the timeout, in milliseconds, before the gesture triggers.
+
+ The recognizer will detect a touch down and and if \a msecs
+ later the touch is still down, it will trigger the QTapAndHoldGesture.
+ The default value is 700 milliseconds.
+*/
+// static
+void QTapAndHoldGesture::setTimeout(int msecs)
+{
+ QTapAndHoldGesturePrivate::Timeout = msecs;
+}
+
+/*!
+ Gets the timeout, in milliseconds, before the gesture triggers.
+
+ The recognizer will detect a touch down and and if timeout()
+ later the touch is still down, it will trigger the QTapAndHoldGesture.
+ The default value is 700 milliseconds.
+*/
+// static
+int QTapAndHoldGesture::timeout()
+{
+ return QTapAndHoldGesturePrivate::Timeout;
+}
+
+int QTapAndHoldGesturePrivate::Timeout = 700; // in ms
+
+
+/*!
+ \class QGestureEvent
+ \since 4.6
+ \ingroup events
+ \ingroup gestures
+
+ \brief The QGestureEvent class provides the description of triggered gestures.
+
+ The QGestureEvent class contains a list of gestures, which can be obtained using the
+ gestures() function.
+
+ The gestures are either active or canceled. A list of those that are currently being
+ executed can be obtained using the activeGestures() function. A list of those which
+ were previously active and have been canceled can be accessed using the
+ canceledGestures() function. A gesture might be canceled if the current window loses
+ focus, for example, or because of a timeout, or for other reasons.
+
+ If the event handler does not accept the event by calling the generic
+ QEvent::accept() function, all individual QGesture object that were not
+ accepted and in the Qt::GestureStarted state will be propagated up the
+ parent widget chain until a widget accepts them individually, by calling
+ QGestureEvent::accept() for each of them, or an event filter consumes the
+ event.
+
+ \section1 Further Reading
+
+ For an overview of gesture handling in Qt and information on using gestures
+ in your applications, see the \l{Gestures Programming} document.
+
+ \sa QGesture, QGestureRecognizer,
+ QWidget::grabGesture(), QGraphicsObject::grabGesture()
+*/
+
+/*!
+ Creates new QGestureEvent containing a list of \a gestures.
+*/
+QGestureEvent::QGestureEvent(const QList<QGesture *> &gestures)
+ : QEvent(QEvent::Gesture)
+{
+ d = reinterpret_cast<QEventPrivate *>(new QGestureEventPrivate(gestures));
+}
+
+/*!
+ Destroys QGestureEvent.
+*/
+QGestureEvent::~QGestureEvent()
+{
+ delete reinterpret_cast<QGestureEventPrivate *>(d);
+}
+
+/*!
+ Returns all gestures that are delivered in the event.
+*/
+QList<QGesture *> QGestureEvent::gestures() const
+{
+ return d_func()->gestures;
+}
+
+/*!
+ Returns a gesture object by \a type.
+*/
+QGesture *QGestureEvent::gesture(Qt::GestureType type) const
+{
+ const QGestureEventPrivate *d = d_func();
+ for(int i = 0; i < d->gestures.size(); ++i)
+ if (d->gestures.at(i)->gestureType() == type)
+ return d->gestures.at(i);
+ return 0;
+}
+
+/*!
+ Returns a list of active (not canceled) gestures.
+*/
+QList<QGesture *> QGestureEvent::activeGestures() const
+{
+ QList<QGesture *> gestures;
+ foreach (QGesture *gesture, d_func()->gestures) {
+ if (gesture->state() != Qt::GestureCanceled)
+ gestures.append(gesture);
+ }
+ return gestures;
+}
+
+/*!
+ Returns a list of canceled gestures.
+*/
+QList<QGesture *> QGestureEvent::canceledGestures() const
+{
+ QList<QGesture *> gestures;
+ foreach (QGesture *gesture, d_func()->gestures) {
+ if (gesture->state() == Qt::GestureCanceled)
+ gestures.append(gesture);
+ }
+ return gestures;
+}
+
+/*!
+ Sets the accept flag of the given \a gesture object to the specified \a value.
+
+ Setting the accept flag indicates that the event receiver wants the \a gesture.
+ Unwanted gestures may be propagated to the parent widget.
+
+ By default, gestures in events of type QEvent::Gesture are accepted, and
+ gestures in QEvent::GestureOverride events are ignored.
+
+ For convenience, the accept flag can also be set with
+ \l{QGestureEvent::accept()}{accept(gesture)}, and cleared with
+ \l{QGestureEvent::ignore()}{ignore(gesture)}.
+*/
+void QGestureEvent::setAccepted(QGesture *gesture, bool value)
+{
+ if (gesture)
+ setAccepted(gesture->gestureType(), value);
+}
+
+/*!
+ Sets the accept flag of the given \a gesture object, the equivalent of calling
+ \l{QGestureEvent::setAccepted()}{setAccepted(gesture, true)}.
+
+ Setting the accept flag indicates that the event receiver wants the
+ gesture. Unwanted gestures may be propagated to the parent widget.
+
+ \sa QGestureEvent::ignore()
+*/
+void QGestureEvent::accept(QGesture *gesture)
+{
+ if (gesture)
+ setAccepted(gesture->gestureType(), true);
+}
+
+/*!
+ Clears the accept flag parameter of the given \a gesture object, the equivalent
+ of calling \l{QGestureEvent::setAccepted()}{setAccepted(gesture, false)}.
+
+ Clearing the accept flag indicates that the event receiver does not
+ want the gesture. Unwanted gestures may be propagated to the parent widget.
+
+ \sa QGestureEvent::accept()
+*/
+void QGestureEvent::ignore(QGesture *gesture)
+{
+ if (gesture)
+ setAccepted(gesture->gestureType(), false);
+}
+
+/*!
+ Returns true if the \a gesture is accepted; otherwise returns false.
+*/
+bool QGestureEvent::isAccepted(QGesture *gesture) const
+{
+ return gesture ? isAccepted(gesture->gestureType()) : false;
+}
+
+/*!
+ Sets the accept flag of the given \a gestureType object to the specified
+ \a value.
+
+ Setting the accept flag indicates that the event receiver wants to receive
+ gestures of the specified type, \a gestureType. Unwanted gestures may be
+ propagated to the parent widget.
+
+ By default, gestures in events of type QEvent::Gesture are accepted, and
+ gestures in QEvent::GestureOverride events are ignored.
+
+ For convenience, the accept flag can also be set with
+ \l{QGestureEvent::accept()}{accept(gestureType)}, and cleared with
+ \l{QGestureEvent::ignore()}{ignore(gestureType)}.
+*/
+void QGestureEvent::setAccepted(Qt::GestureType gestureType, bool value)
+{
+ setAccepted(false);
+ d_func()->accepted[gestureType] = value;
+}
+
+/*!
+ Sets the accept flag of the given \a gestureType, the equivalent of calling
+ \l{QGestureEvent::setAccepted()}{setAccepted(gestureType, true)}.
+
+ Setting the accept flag indicates that the event receiver wants the
+ gesture. Unwanted gestures may be propagated to the parent widget.
+
+ \sa QGestureEvent::ignore()
+*/
+void QGestureEvent::accept(Qt::GestureType gestureType)
+{
+ setAccepted(gestureType, true);
+}
+
+/*!
+ Clears the accept flag parameter of the given \a gestureType, the equivalent
+ of calling \l{QGestureEvent::setAccepted()}{setAccepted(gesture, false)}.
+
+ Clearing the accept flag indicates that the event receiver does not
+ want the gesture. Unwanted gestures may be propgated to the parent widget.
+
+ \sa QGestureEvent::accept()
+*/
+void QGestureEvent::ignore(Qt::GestureType gestureType)
+{
+ setAccepted(gestureType, false);
+}
+
+/*!
+ Returns true if the gesture of type \a gestureType is accepted; otherwise
+ returns false.
+*/
+bool QGestureEvent::isAccepted(Qt::GestureType gestureType) const
+{
+ return d_func()->accepted.value(gestureType, true);
+}
+
+/*!
+ \internal
+
+ Sets the widget for this event to the \a widget specified.
+*/
+void QGestureEvent::setWidget(QWidget *widget)
+{
+ d_func()->widget = widget;
+}
+
+/*!
+ Returns the widget on which the event occurred.
+*/
+QWidget *QGestureEvent::widget() const
+{
+ return d_func()->widget;
+}
+
+#ifndef QT_NO_GRAPHICSVIEW
+/*!
+ Returns the scene-local coordinates if the \a gesturePoint is inside a
+ graphics view.
+
+ This functional might be useful when the gesture event is delivered to a
+ QGraphicsObject to translate a point in screen coordinates to scene-local
+ coordinates.
+
+ \sa QPointF::isNull().
+*/
+QPointF QGestureEvent::mapToGraphicsScene(const QPointF &gesturePoint) const
+{
+ QWidget *w = widget();
+ if (w) // we get the viewport as widget, not the graphics view
+ w = w->parentWidget();
+ QGraphicsView *view = qobject_cast<QGraphicsView*>(w);
+ if (view) {
+ return view->mapToScene(view->mapFromGlobal(gesturePoint.toPoint()));
+ }
+ return QPointF();
+}
+#endif //QT_NO_GRAPHICSVIEW
+
+/*!
+ \internal
+*/
+QGestureEventPrivate *QGestureEvent::d_func()
+{
+ return reinterpret_cast<QGestureEventPrivate *>(d);
+}
+
+/*!
+ \internal
+*/
+const QGestureEventPrivate *QGestureEvent::d_func() const
+{
+ return reinterpret_cast<const QGestureEventPrivate *>(d);
+}
+
+#ifdef Q_NO_USING_KEYWORD
+/*!
+ \fn void QGestureEvent::setAccepted(bool accepted)
+
+ Sets or clears the event's internal flag that determines whether it should
+ be delivered to other objects.
+
+ Calling this function with a value of true for \a accepted indicates that the
+ caller has accepted the event and that it should not be propagated further.
+ Calling this function with a value of false indicates that the caller has
+ ignored the event and that it should be delivered to other objects.
+
+ For convenience, the accept flag can also be set with accept(), and cleared
+ with ignore().
+
+ \sa QEvent::accepted
+*/
+/*!
+ \fn bool QGestureEvent::isAccepted() const
+
+ Returns true is the event has been accepted; otherwise returns false.
+
+ \sa QEvent::accepted
+*/
+/*!
+ \fn void QGestureEvent::accept()
+
+ Accepts the event, the equivalent of calling setAccepted(true).
+
+ \sa QEvent::accept()
+*/
+/*!
+ \fn void QGestureEvent::ignore()
+
+ Ignores the event, the equivalent of calling setAccepted(false).
+
+ \sa QEvent::ignore()
+*/
+#endif
+
+QT_END_NAMESPACE
+
+#include <moc_qgesture.cpp>
+
+#endif // QT_NO_GESTURES
diff --git a/src/widgets/kernel/qgesture.h b/src/widgets/kernel/qgesture.h
new file mode 100644
index 0000000000..78fd2e47f1
--- /dev/null
+++ b/src/widgets/kernel/qgesture.h
@@ -0,0 +1,328 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGESTURE_H
+#define QGESTURE_H
+
+#include <QtCore/qobject.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qdatetime.h>
+#include <QtCore/qpoint.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qmetatype.h>
+#include <QtGui/qevent.h>
+
+#ifndef QT_NO_GESTURES
+
+QT_BEGIN_HEADER
+
+Q_DECLARE_METATYPE(Qt::GestureState)
+Q_DECLARE_METATYPE(Qt::GestureType)
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QGesturePrivate;
+class Q_GUI_EXPORT QGesture : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QGesture)
+
+ Q_PROPERTY(Qt::GestureState state READ state)
+ Q_PROPERTY(Qt::GestureType gestureType READ gestureType)
+ Q_PROPERTY(QGesture::GestureCancelPolicy gestureCancelPolicy READ gestureCancelPolicy WRITE setGestureCancelPolicy)
+ Q_PROPERTY(QPointF hotSpot READ hotSpot WRITE setHotSpot RESET unsetHotSpot)
+ Q_PROPERTY(bool hasHotSpot READ hasHotSpot)
+
+public:
+ explicit QGesture(QObject *parent = 0);
+ ~QGesture();
+
+ Qt::GestureType gestureType() const;
+
+ Qt::GestureState state() const;
+
+ QPointF hotSpot() const;
+ void setHotSpot(const QPointF &value);
+ bool hasHotSpot() const;
+ void unsetHotSpot();
+
+ enum GestureCancelPolicy {
+ CancelNone = 0,
+ CancelAllInContext
+ };
+
+ void setGestureCancelPolicy(GestureCancelPolicy policy);
+ GestureCancelPolicy gestureCancelPolicy() const;
+
+protected:
+ QGesture(QGesturePrivate &dd, QObject *parent);
+
+private:
+ friend class QGestureEvent;
+ friend class QGestureRecognizer;
+ friend class QGestureManager;
+ friend class QGraphicsScenePrivate;
+};
+
+class QPanGesturePrivate;
+class Q_GUI_EXPORT QPanGesture : public QGesture
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QPanGesture)
+
+ Q_PROPERTY(QPointF lastOffset READ lastOffset WRITE setLastOffset)
+ Q_PROPERTY(QPointF offset READ offset WRITE setOffset)
+ Q_PROPERTY(QPointF delta READ delta STORED false)
+ Q_PROPERTY(qreal acceleration READ acceleration WRITE setAcceleration)
+ Q_PRIVATE_PROPERTY(QPanGesture::d_func(), qreal horizontalVelocity READ horizontalVelocity WRITE setHorizontalVelocity)
+ Q_PRIVATE_PROPERTY(QPanGesture::d_func(), qreal verticalVelocity READ verticalVelocity WRITE setVerticalVelocity)
+
+public:
+ QPanGesture(QObject *parent = 0);
+
+ QPointF lastOffset() const;
+ QPointF offset() const;
+ QPointF delta() const;
+ qreal acceleration() const;
+
+ void setLastOffset(const QPointF &value);
+ void setOffset(const QPointF &value);
+ void setAcceleration(qreal value);
+
+ friend class QPanGestureRecognizer;
+ friend class QWinNativePanGestureRecognizer;
+};
+
+class QPinchGesturePrivate;
+class Q_GUI_EXPORT QPinchGesture : public QGesture
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QPinchGesture)
+ Q_FLAGS(ChangeFlags ChangeFlag)
+
+public:
+ enum ChangeFlag {
+ ScaleFactorChanged = 0x1,
+ RotationAngleChanged = 0x2,
+ CenterPointChanged = 0x4
+ };
+ Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag)
+
+ Q_PROPERTY(ChangeFlags totalChangeFlags READ totalChangeFlags WRITE setTotalChangeFlags)
+ Q_PROPERTY(ChangeFlags changeFlags READ changeFlags WRITE setChangeFlags)
+
+ Q_PROPERTY(qreal totalScaleFactor READ totalScaleFactor WRITE setTotalScaleFactor)
+ Q_PROPERTY(qreal lastScaleFactor READ lastScaleFactor WRITE setLastScaleFactor)
+ Q_PROPERTY(qreal scaleFactor READ scaleFactor WRITE setScaleFactor)
+
+ Q_PROPERTY(qreal totalRotationAngle READ totalRotationAngle WRITE setTotalRotationAngle)
+ Q_PROPERTY(qreal lastRotationAngle READ lastRotationAngle WRITE setLastRotationAngle)
+ Q_PROPERTY(qreal rotationAngle READ rotationAngle WRITE setRotationAngle)
+
+ Q_PROPERTY(QPointF startCenterPoint READ startCenterPoint WRITE setStartCenterPoint)
+ Q_PROPERTY(QPointF lastCenterPoint READ lastCenterPoint WRITE setLastCenterPoint)
+ Q_PROPERTY(QPointF centerPoint READ centerPoint WRITE setCenterPoint)
+
+public:
+ QPinchGesture(QObject *parent = 0);
+
+ ChangeFlags totalChangeFlags() const;
+ void setTotalChangeFlags(ChangeFlags value);
+
+ ChangeFlags changeFlags() const;
+ void setChangeFlags(ChangeFlags value);
+
+ QPointF startCenterPoint() const;
+ QPointF lastCenterPoint() const;
+ QPointF centerPoint() const;
+ void setStartCenterPoint(const QPointF &value);
+ void setLastCenterPoint(const QPointF &value);
+ void setCenterPoint(const QPointF &value);
+
+ qreal totalScaleFactor() const;
+ qreal lastScaleFactor() const;
+ qreal scaleFactor() const;
+ void setTotalScaleFactor(qreal value);
+ void setLastScaleFactor(qreal value);
+ void setScaleFactor(qreal value);
+
+ qreal totalRotationAngle() const;
+ qreal lastRotationAngle() const;
+ qreal rotationAngle() const;
+ void setTotalRotationAngle(qreal value);
+ void setLastRotationAngle(qreal value);
+ void setRotationAngle(qreal value);
+
+ friend class QPinchGestureRecognizer;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QPinchGesture::ChangeFlags)
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QPinchGesture::ChangeFlags)
+
+QT_BEGIN_NAMESPACE
+
+class QSwipeGesturePrivate;
+class Q_GUI_EXPORT QSwipeGesture : public QGesture
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QSwipeGesture)
+ Q_ENUMS(SwipeDirection)
+
+ Q_PROPERTY(SwipeDirection horizontalDirection READ horizontalDirection STORED false)
+ Q_PROPERTY(SwipeDirection verticalDirection READ verticalDirection STORED false)
+ Q_PROPERTY(qreal swipeAngle READ swipeAngle WRITE setSwipeAngle)
+ Q_PRIVATE_PROPERTY(QSwipeGesture::d_func(), qreal velocity READ velocity WRITE setVelocity)
+
+public:
+ enum SwipeDirection { NoDirection, Left, Right, Up, Down };
+ QSwipeGesture(QObject *parent = 0);
+
+ SwipeDirection horizontalDirection() const;
+ SwipeDirection verticalDirection() const;
+
+ qreal swipeAngle() const;
+ void setSwipeAngle(qreal value);
+
+ friend class QSwipeGestureRecognizer;
+};
+
+class QTapGesturePrivate;
+class Q_GUI_EXPORT QTapGesture : public QGesture
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QTapGesture)
+
+ Q_PROPERTY(QPointF position READ position WRITE setPosition)
+
+public:
+ QTapGesture(QObject *parent = 0);
+
+ QPointF position() const;
+ void setPosition(const QPointF &pos);
+
+ friend class QTapGestureRecognizer;
+};
+
+class QTapAndHoldGesturePrivate;
+class Q_GUI_EXPORT QTapAndHoldGesture : public QGesture
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QTapAndHoldGesture)
+
+ Q_PROPERTY(QPointF position READ position WRITE setPosition)
+
+public:
+ QTapAndHoldGesture(QObject *parent = 0);
+
+ QPointF position() const;
+ void setPosition(const QPointF &pos);
+
+ static void setTimeout(int msecs);
+ static int timeout();
+
+ friend class QTapAndHoldGestureRecognizer;
+};
+
+class QGesture;
+class QGestureEventPrivate;
+class Q_GUI_EXPORT QGestureEvent : public QEvent
+{
+public:
+ QGestureEvent(const QList<QGesture *> &gestures);
+ ~QGestureEvent();
+
+ QList<QGesture *> gestures() const;
+ QGesture *gesture(Qt::GestureType type) const;
+
+ QList<QGesture *> activeGestures() const;
+ QList<QGesture *> canceledGestures() const;
+
+#ifdef Q_NO_USING_KEYWORD
+ inline void setAccepted(bool accepted) { QEvent::setAccepted(accepted); }
+ inline bool isAccepted() const { return QEvent::isAccepted(); }
+
+ inline void accept() { QEvent::accept(); }
+ inline void ignore() { QEvent::ignore(); }
+#else
+ using QEvent::setAccepted;
+ using QEvent::isAccepted;
+ using QEvent::accept;
+ using QEvent::ignore;
+#endif
+
+ void setAccepted(QGesture *, bool);
+ void accept(QGesture *);
+ void ignore(QGesture *);
+ bool isAccepted(QGesture *) const;
+
+ void setAccepted(Qt::GestureType, bool);
+ void accept(Qt::GestureType);
+ void ignore(Qt::GestureType);
+ bool isAccepted(Qt::GestureType) const;
+
+ void setWidget(QWidget *widget);
+ QWidget *widget() const;
+
+#ifndef QT_NO_GRAPHICSVIEW
+ QPointF mapToGraphicsScene(const QPointF &gesturePoint) const;
+#endif
+
+private:
+ QGestureEventPrivate *d_func();
+ const QGestureEventPrivate *d_func() const;
+
+ friend class QApplication;
+ friend class QGestureManager;
+};
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QGesture::GestureCancelPolicy)
+QT_END_HEADER
+
+#endif // QT_NO_GESTURES
+
+#endif // QGESTURE_H
diff --git a/src/widgets/kernel/qgesture_p.h b/src/widgets/kernel/qgesture_p.h
new file mode 100644
index 0000000000..9dd089cc9e
--- /dev/null
+++ b/src/widgets/kernel/qgesture_p.h
@@ -0,0 +1,245 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGESTURE_P_H
+#define QGESTURE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qrect.h"
+#include "qpoint.h"
+#include "qgesture.h"
+#include "qelapsedtimer.h"
+#include "private/qobject_p.h"
+
+#ifndef QT_NO_GESTURES
+
+QT_BEGIN_NAMESPACE
+
+class QGesturePrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QGesture)
+
+public:
+ QGesturePrivate()
+ : gestureType(Qt::CustomGesture), state(Qt::NoGesture),
+ isHotSpotSet(false), gestureCancelPolicy(0)
+ {
+ }
+
+ Qt::GestureType gestureType;
+ Qt::GestureState state;
+ QPointF hotSpot;
+ QPointF sceneHotSpot;
+ uint isHotSpotSet : 1;
+ uint gestureCancelPolicy : 2;
+};
+
+class QPanGesturePrivate : public QGesturePrivate
+{
+ Q_DECLARE_PUBLIC(QPanGesture)
+
+public:
+ QPanGesturePrivate()
+ : acceleration(0), xVelocity(0), yVelocity(0)
+ {
+ }
+
+ qreal horizontalVelocity() const { return xVelocity; }
+ void setHorizontalVelocity(qreal value) { xVelocity = value; }
+ qreal verticalVelocity() const { return yVelocity; }
+ void setVerticalVelocity(qreal value) { yVelocity = value; }
+
+ QPointF lastOffset;
+ QPointF offset;
+ QPoint startPosition;
+ qreal acceleration;
+ qreal xVelocity;
+ qreal yVelocity;
+};
+
+class QPinchGesturePrivate : public QGesturePrivate
+{
+ Q_DECLARE_PUBLIC(QPinchGesture)
+
+public:
+ QPinchGesturePrivate()
+ : totalChangeFlags(0), changeFlags(0),
+ totalScaleFactor(1), lastScaleFactor(1), scaleFactor(1),
+ totalRotationAngle(0), lastRotationAngle(0), rotationAngle(0),
+ isNewSequence(true)
+ {
+ }
+
+ QPinchGesture::ChangeFlags totalChangeFlags;
+ QPinchGesture::ChangeFlags changeFlags;
+
+ QPointF startCenterPoint;
+ QPointF lastCenterPoint;
+ QPointF centerPoint;
+
+ qreal totalScaleFactor;
+ qreal lastScaleFactor;
+ qreal scaleFactor;
+
+ qreal totalRotationAngle;
+ qreal lastRotationAngle;
+ qreal rotationAngle;
+
+ bool isNewSequence;
+ QPointF startPosition[2];
+};
+
+class QSwipeGesturePrivate : public QGesturePrivate
+{
+ Q_DECLARE_PUBLIC(QSwipeGesture)
+
+public:
+ QSwipeGesturePrivate()
+ : horizontalDirection(QSwipeGesture::NoDirection),
+ verticalDirection(QSwipeGesture::NoDirection),
+ swipeAngle(0),
+ started(false), velocityValue(0)
+ {
+ }
+
+ qreal velocity() const { return velocityValue; }
+ void setVelocity(qreal value) { velocityValue = value; }
+
+ QSwipeGesture::SwipeDirection horizontalDirection;
+ QSwipeGesture::SwipeDirection verticalDirection;
+ qreal swipeAngle;
+
+ QPoint lastPositions[3];
+ bool started;
+ qreal velocityValue;
+ QElapsedTimer time;
+};
+
+class QTapGesturePrivate : public QGesturePrivate
+{
+ Q_DECLARE_PUBLIC(QTapGesture)
+
+public:
+ QTapGesturePrivate()
+ {
+ }
+
+ QPointF position;
+};
+
+class QTapAndHoldGesturePrivate : public QGesturePrivate
+{
+ Q_DECLARE_PUBLIC(QTapAndHoldGesture)
+
+public:
+ QTapAndHoldGesturePrivate()
+ : timerId(0)
+ {
+ }
+
+ QPointF position;
+ int timerId;
+ static int Timeout;
+};
+
+#ifndef QT_NO_GESTURES
+class QNativeGestureEvent : public QEvent
+{
+public:
+ enum Type {
+ None,
+ GestureBegin,
+ GestureEnd,
+ Pan,
+ Zoom,
+ Rotate,
+ Swipe
+ };
+
+ QNativeGestureEvent()
+ : QEvent(QEvent::NativeGesture), gestureType(None), percentage(0)
+#ifdef Q_WS_WIN
+ , sequenceId(0), argument(0)
+#endif
+ {
+ }
+
+ Type gestureType;
+ float percentage;
+ QPoint position;
+ float angle;
+#ifdef Q_WS_WIN
+ ulong sequenceId;
+ quint64 argument;
+#endif
+};
+
+class QGestureEventPrivate
+{
+public:
+ inline QGestureEventPrivate(const QList<QGesture *> &list)
+ : gestures(list), widget(0)
+ {
+ }
+
+ QList<QGesture *> gestures;
+ QWidget *widget;
+ QMap<Qt::GestureType, bool> accepted;
+ QMap<Qt::GestureType, QWidget *> targetWidgets;
+};
+#endif // QT_NO_GESTURES
+
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_GESTURES
+
+#endif // QGESTURE_P_H
diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp
index 7aa7dffd9b..7aa7dffd9b 100644
--- a/src/gui/kernel/qgesturemanager.cpp
+++ b/src/widgets/kernel/qgesturemanager.cpp
diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/widgets/kernel/qgesturemanager_p.h
index b4d9f61ec0..b4d9f61ec0 100644
--- a/src/gui/kernel/qgesturemanager_p.h
+++ b/src/widgets/kernel/qgesturemanager_p.h
diff --git a/src/gui/kernel/qgesturerecognizer.cpp b/src/widgets/kernel/qgesturerecognizer.cpp
index f7a4a189b9..f7a4a189b9 100644
--- a/src/gui/kernel/qgesturerecognizer.cpp
+++ b/src/widgets/kernel/qgesturerecognizer.cpp
diff --git a/src/gui/kernel/qgesturerecognizer.h b/src/widgets/kernel/qgesturerecognizer.h
index 80d978d6bb..80d978d6bb 100644
--- a/src/gui/kernel/qgesturerecognizer.h
+++ b/src/widgets/kernel/qgesturerecognizer.h
diff --git a/src/gui/kernel/qgridlayout.cpp b/src/widgets/kernel/qgridlayout.cpp
index 19d101a0b0..19d101a0b0 100644
--- a/src/gui/kernel/qgridlayout.cpp
+++ b/src/widgets/kernel/qgridlayout.cpp
diff --git a/src/widgets/kernel/qgridlayout.h b/src/widgets/kernel/qgridlayout.h
new file mode 100644
index 0000000000..cbfc6f7e48
--- /dev/null
+++ b/src/widgets/kernel/qgridlayout.h
@@ -0,0 +1,176 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGRIDLAYOUT_H
+#define QGRIDLAYOUT_H
+
+#include <QtWidgets/qlayout.h>
+#ifdef QT_INCLUDE_COMPAT
+#include <QtWidgets/qwidget.h>
+#endif
+
+#include <limits.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QGridLayoutPrivate;
+
+class Q_GUI_EXPORT QGridLayout : public QLayout
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QGridLayout)
+ QDOC_PROPERTY(int horizontalSpacing READ horizontalSpacing WRITE setHorizontalSpacing)
+ QDOC_PROPERTY(int verticalSpacing READ verticalSpacing WRITE setVerticalSpacing)
+
+public:
+ explicit QGridLayout(QWidget *parent);
+ QGridLayout();
+
+#ifdef QT3_SUPPORT
+ QT3_SUPPORT_CONSTRUCTOR QGridLayout(QWidget *parent, int nRows , int nCols = 1, int border = 0,
+ int spacing = -1, const char *name = 0);
+ QT3_SUPPORT_CONSTRUCTOR QGridLayout(int nRows , int nCols = 1, int spacing = -1, const char *name = 0);
+ QT3_SUPPORT_CONSTRUCTOR QGridLayout(QLayout *parentLayout, int nRows = 1, int nCols = 1, int spacing = -1,
+ const char *name = 0);
+#endif
+ ~QGridLayout();
+
+ QSize sizeHint() const;
+ QSize minimumSize() const;
+ QSize maximumSize() const;
+
+ void setHorizontalSpacing(int spacing);
+ int horizontalSpacing() const;
+ void setVerticalSpacing(int spacing);
+ int verticalSpacing() const;
+ void setSpacing(int spacing);
+ int spacing() const;
+
+ void setRowStretch(int row, int stretch);
+ void setColumnStretch(int column, int stretch);
+ int rowStretch(int row) const;
+ int columnStretch(int column) const;
+
+ void setRowMinimumHeight(int row, int minSize);
+ void setColumnMinimumWidth(int column, int minSize);
+ int rowMinimumHeight(int row) const;
+ int columnMinimumWidth(int column) const;
+
+ int columnCount() const;
+ int rowCount() const;
+
+ QRect cellRect(int row, int column) const;
+#ifdef QT3_SUPPORT
+ inline QT3_SUPPORT QRect cellGeometry(int row, int column) const {return cellRect(row, column);}
+#endif
+
+ bool hasHeightForWidth() const;
+ int heightForWidth(int) const;
+ int minimumHeightForWidth(int) const;
+
+ Qt::Orientations expandingDirections() const;
+ void invalidate();
+
+ inline void addWidget(QWidget *w) { QLayout::addWidget(w); }
+ void addWidget(QWidget *, int row, int column, Qt::Alignment = 0);
+ void addWidget(QWidget *, int row, int column, int rowSpan, int columnSpan, Qt::Alignment = 0);
+ void addLayout(QLayout *, int row, int column, Qt::Alignment = 0);
+ void addLayout(QLayout *, int row, int column, int rowSpan, int columnSpan, Qt::Alignment = 0);
+
+ void setOriginCorner(Qt::Corner);
+ Qt::Corner originCorner() const;
+
+#ifdef QT3_SUPPORT
+ inline QT3_SUPPORT void setOrigin(Qt::Corner corner) { setOriginCorner(corner); }
+ inline QT3_SUPPORT Qt::Corner origin() const { return originCorner(); }
+#endif
+ QLayoutItem *itemAt(int index) const;
+ QLayoutItem *itemAtPosition(int row, int column) const;
+ QLayoutItem *takeAt(int index);
+ int count() const;
+ void setGeometry(const QRect&);
+
+ void addItem(QLayoutItem *item, int row, int column, int rowSpan = 1, int columnSpan = 1, Qt::Alignment = 0);
+
+ void setDefaultPositioning(int n, Qt::Orientation orient);
+ void getItemPosition(int idx, int *row, int *column, int *rowSpan, int *columnSpan);
+
+protected:
+#ifdef QT3_SUPPORT
+ QT3_SUPPORT bool findWidget(QWidget* w, int *r, int *c);
+#endif
+ void addItem(QLayoutItem *);
+
+private:
+ Q_DISABLE_COPY(QGridLayout)
+
+#ifdef QT3_SUPPORT
+public:
+ QT3_SUPPORT void expand(int rows, int cols);
+ inline QT3_SUPPORT void addRowSpacing(int row, int minsize) { addItem(new QSpacerItem(0,minsize), row, 0); }
+ inline QT3_SUPPORT void addColSpacing(int col, int minsize) { addItem(new QSpacerItem(minsize,0), 0, col); }
+ inline QT3_SUPPORT void addMultiCellWidget(QWidget *w, int fromRow, int toRow, int fromCol, int toCol, Qt::Alignment _align = 0)
+ { addWidget(w, fromRow, fromCol, (toRow < 0) ? -1 : toRow - fromRow + 1, (toCol < 0) ? -1 : toCol - fromCol + 1, _align); }
+ inline QT3_SUPPORT void addMultiCell(QLayoutItem *l, int fromRow, int toRow, int fromCol, int toCol, Qt::Alignment _align = 0)
+ { addItem(l, fromRow, fromCol, (toRow < 0) ? -1 : toRow - fromRow + 1, (toCol < 0) ? -1 : toCol - fromCol + 1, _align); }
+ inline QT3_SUPPORT void addMultiCellLayout(QLayout *layout, int fromRow, int toRow, int fromCol, int toCol, Qt::Alignment _align = 0)
+ { addLayout(layout, fromRow, fromCol, (toRow < 0) ? -1 : toRow - fromRow + 1, (toCol < 0) ? -1 : toCol - fromCol + 1, _align); }
+
+ inline QT3_SUPPORT int numRows() const { return rowCount(); }
+ inline QT3_SUPPORT int numCols() const { return columnCount(); }
+ inline QT3_SUPPORT void setColStretch(int col, int stretch) {setColumnStretch(col, stretch); }
+ inline QT3_SUPPORT int colStretch(int col) const {return columnStretch(col); }
+ inline QT3_SUPPORT void setColSpacing(int col, int minSize) { setColumnMinimumWidth(col, minSize); }
+ inline QT3_SUPPORT int colSpacing(int col) const { return columnMinimumWidth(col); }
+ inline QT3_SUPPORT void setRowSpacing(int row, int minSize) {setRowMinimumHeight(row, minSize); }
+ inline QT3_SUPPORT int rowSpacing(int row) const {return rowMinimumHeight(row); }
+#endif
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QGRIDLAYOUT_H
diff --git a/src/gui/kernel/qguieventdispatcher_glib.cpp b/src/widgets/kernel/qguieventdispatcher_glib.cpp
index 3fa10eb7e9..3fa10eb7e9 100644
--- a/src/gui/kernel/qguieventdispatcher_glib.cpp
+++ b/src/widgets/kernel/qguieventdispatcher_glib.cpp
diff --git a/src/gui/kernel/qguieventdispatcher_glib_p.h b/src/widgets/kernel/qguieventdispatcher_glib_p.h
index d37db93679..d37db93679 100644
--- a/src/gui/kernel/qguieventdispatcher_glib_p.h
+++ b/src/widgets/kernel/qguieventdispatcher_glib_p.h
diff --git a/src/gui/kernel/qguiplatformplugin.cpp b/src/widgets/kernel/qguiplatformplugin.cpp
index 011b816e77..011b816e77 100644
--- a/src/gui/kernel/qguiplatformplugin.cpp
+++ b/src/widgets/kernel/qguiplatformplugin.cpp
diff --git a/src/widgets/kernel/qguiplatformplugin_p.h b/src/widgets/kernel/qguiplatformplugin_p.h
new file mode 100644
index 0000000000..18dd66615f
--- /dev/null
+++ b/src/widgets/kernel/qguiplatformplugin_p.h
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGUIPLATFORM_P_H
+#define QGUIPLATFORM_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qplugin.h>
+#include <QtCore/qfactoryinterface.h>
+#include <QtWidgets/qdialog.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QStyle;
+class QPalette;
+class QIcon;
+class QFileDialog;
+class QColorDialog;
+class QFileInfo;
+
+struct Q_GUI_EXPORT QGuiPlatformPluginInterface : public QFactoryInterface
+{
+};
+
+#define QGuiPlatformPluginInterface_iid "com.nokia.qt.QGuiPlatformPluginInterface"
+
+Q_DECLARE_INTERFACE(QGuiPlatformPluginInterface, QGuiPlatformPluginInterface_iid)
+
+class Q_GUI_EXPORT QGuiPlatformPlugin : public QObject, public QGuiPlatformPluginInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(QGuiPlatformPluginInterface:QFactoryInterface)
+ public:
+ explicit QGuiPlatformPlugin(QObject *parent = 0);
+ ~QGuiPlatformPlugin();
+
+ virtual QStringList keys() const { return QStringList() << QLatin1String("default"); };
+
+ virtual QString styleName();
+ virtual QPalette palette();
+ virtual QString systemIconThemeName();
+ virtual QStringList iconThemeSearchPaths();
+ virtual QIcon fileSystemIcon(const QFileInfo &);
+
+ enum PlatformHint { PH_ToolButtonStyle, PH_ToolBarIconSize, PH_ItemView_ActivateItemOnSingleClick };
+ virtual int platformHint(PlatformHint hint);
+
+
+ virtual void fileDialogDelete(QFileDialog *) {}
+ virtual bool fileDialogSetVisible(QFileDialog *, bool) { return false; }
+ virtual QDialog::DialogCode fileDialogResultCode(QFileDialog *) { return QDialog::Rejected; }
+ virtual void fileDialogSetDirectory(QFileDialog *, const QString &) {}
+ virtual QString fileDialogDirectory(const QFileDialog *) const { return QString(); }
+ virtual void fileDialogSelectFile(QFileDialog *, const QString &) {}
+ virtual QStringList fileDialogSelectedFiles(const QFileDialog *) const { return QStringList(); }
+ virtual void fileDialogSetFilter(QFileDialog *) {}
+ virtual void fileDialogSetNameFilters(QFileDialog *, const QStringList &) {}
+ virtual void fileDialogSelectNameFilter(QFileDialog *, const QString &) {}
+ virtual QString fileDialogSelectedNameFilter(const QFileDialog *) const { return QString(); }
+
+ virtual void colorDialogDelete(QColorDialog *) {}
+ virtual bool colorDialogSetVisible(QColorDialog *, bool) { return false; }
+ virtual void colorDialogSetCurrentColor(QColorDialog *, const QColor &) {}
+};
+
+//internal
+QGuiPlatformPlugin *qt_guiPlatformPlugin();
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+
+#endif // QGUIPLATFORMPLUGIN_H
diff --git a/src/widgets/kernel/qicon.cpp b/src/widgets/kernel/qicon.cpp
new file mode 100644
index 0000000000..59687c709d
--- /dev/null
+++ b/src/widgets/kernel/qicon.cpp
@@ -0,0 +1,1165 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qicon.h"
+#include "qicon_p.h"
+#include "qiconengine.h"
+#include "qiconengineplugin.h"
+#include "private/qfactoryloader_p.h"
+#include "private/qiconloader_p.h"
+#include "qstyleoption.h"
+#include "qpainter.h"
+#include "qfileinfo.h"
+#include "qstyle.h"
+#include "qpixmapcache.h"
+#include "qvariant.h"
+#include "qcache.h"
+#include "qdebug.h"
+#include "private/qguiplatformplugin_p.h"
+#include "qguiapplication.h"
+
+#ifdef Q_WS_MAC
+#include <private/qt_mac_p.h>
+#include <private/qt_cocoa_helpers_mac_p.h>
+#endif
+
+#ifdef Q_WS_X11
+#include "private/qt_x11_p.h"
+#include "private/qkde_p.h"
+#endif
+
+#include "private/qhexstring_p.h"
+
+#ifndef QT_NO_ICON
+QT_BEGIN_NAMESPACE
+
+/*!
+ \enum QIcon::Mode
+
+ This enum type describes the mode for which a pixmap is intended
+ to be used. The currently defined modes are:
+
+ \value Normal
+ Display the pixmap when the user is
+ not interacting with the icon, but the
+ functionality represented by the icon is available.
+ \value Disabled
+ Display the pixmap when the
+ functionality represented by the icon is not available.
+ \value Active
+ Display the pixmap when the
+ functionality represented by the icon is available and
+ the user is interacting with the icon, for example, moving the
+ mouse over it or clicking it.
+ \value Selected
+ Display the pixmap when the item represented by the icon is
+ selected.
+*/
+
+/*!
+ \enum QIcon::State
+
+ This enum describes the state for which a pixmap is intended to be
+ used. The \e state can be:
+
+ \value Off Display the pixmap when the widget is in an "off" state
+ \value On Display the pixmap when the widget is in an "on" state
+*/
+
+static QBasicAtomicInt serialNumCounter = Q_BASIC_ATOMIC_INITIALIZER(1);
+
+static void qt_cleanup_icon_cache();
+typedef QCache<QString, QIcon> IconCache;
+Q_GLOBAL_STATIC_WITH_INITIALIZER(IconCache, qtIconCache, qAddPostRoutine(qt_cleanup_icon_cache))
+
+static void qt_cleanup_icon_cache()
+{
+ qtIconCache()->clear();
+}
+
+QIconPrivate::QIconPrivate()
+ : engine(0), ref(1),
+ serialNum(serialNumCounter.fetchAndAddRelaxed(1)),
+ detach_no(0),
+ engine_version(2),
+ v1RefCount(0)
+{
+}
+
+QPixmapIconEngine::QPixmapIconEngine()
+{
+}
+
+QPixmapIconEngine::QPixmapIconEngine(const QPixmapIconEngine &other)
+ : QIconEngineV2(other), pixmaps(other.pixmaps)
+{
+}
+
+QPixmapIconEngine::~QPixmapIconEngine()
+{
+}
+
+void QPixmapIconEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state)
+{
+ QSize pixmapSize = rect.size();
+#if defined(Q_WS_MAC)
+ pixmapSize *= qt_mac_get_scalefactor();
+#endif
+ painter->drawPixmap(rect, pixmap(pixmapSize, mode, state));
+}
+
+static inline int area(const QSize &s) { return s.width() * s.height(); }
+
+// returns the smallest of the two that is still larger than or equal to size.
+static QPixmapIconEngineEntry *bestSizeMatch( const QSize &size, QPixmapIconEngineEntry *pa, QPixmapIconEngineEntry *pb)
+{
+ int s = area(size);
+ if (pa->size == QSize() && pa->pixmap.isNull()) {
+ pa->pixmap = QPixmap(pa->fileName);
+ pa->size = pa->pixmap.size();
+ }
+ int a = area(pa->size);
+ if (pb->size == QSize() && pb->pixmap.isNull()) {
+ pb->pixmap = QPixmap(pb->fileName);
+ pb->size = pb->pixmap.size();
+ }
+ int b = area(pb->size);
+ int res = a;
+ if (qMin(a,b) >= s)
+ res = qMin(a,b);
+ else
+ res = qMax(a,b);
+ if (res == a)
+ return pa;
+ return pb;
+}
+
+QPixmapIconEngineEntry *QPixmapIconEngine::tryMatch(const QSize &size, QIcon::Mode mode, QIcon::State state)
+{
+ QPixmapIconEngineEntry *pe = 0;
+ for (int i = 0; i < pixmaps.count(); ++i)
+ if (pixmaps.at(i).mode == mode && pixmaps.at(i).state == state) {
+ if (pe)
+ pe = bestSizeMatch(size, &pixmaps[i], pe);
+ else
+ pe = &pixmaps[i];
+ }
+ return pe;
+}
+
+
+QPixmapIconEngineEntry *QPixmapIconEngine::bestMatch(const QSize &size, QIcon::Mode mode, QIcon::State state, bool sizeOnly)
+{
+ QPixmapIconEngineEntry *pe = tryMatch(size, mode, state);
+ while (!pe){
+ QIcon::State oppositeState = (state == QIcon::On) ? QIcon::Off : QIcon::On;
+ if (mode == QIcon::Disabled || mode == QIcon::Selected) {
+ QIcon::Mode oppositeMode = (mode == QIcon::Disabled) ? QIcon::Selected : QIcon::Disabled;
+ if ((pe = tryMatch(size, QIcon::Normal, state)))
+ break;
+ if ((pe = tryMatch(size, QIcon::Active, state)))
+ break;
+ if ((pe = tryMatch(size, mode, oppositeState)))
+ break;
+ if ((pe = tryMatch(size, QIcon::Normal, oppositeState)))
+ break;
+ if ((pe = tryMatch(size, QIcon::Active, oppositeState)))
+ break;
+ if ((pe = tryMatch(size, oppositeMode, state)))
+ break;
+ if ((pe = tryMatch(size, oppositeMode, oppositeState)))
+ break;
+ } else {
+ QIcon::Mode oppositeMode = (mode == QIcon::Normal) ? QIcon::Active : QIcon::Normal;
+ if ((pe = tryMatch(size, oppositeMode, state)))
+ break;
+ if ((pe = tryMatch(size, mode, oppositeState)))
+ break;
+ if ((pe = tryMatch(size, oppositeMode, oppositeState)))
+ break;
+ if ((pe = tryMatch(size, QIcon::Disabled, state)))
+ break;
+ if ((pe = tryMatch(size, QIcon::Selected, state)))
+ break;
+ if ((pe = tryMatch(size, QIcon::Disabled, oppositeState)))
+ break;
+ if ((pe = tryMatch(size, QIcon::Selected, oppositeState)))
+ break;
+ }
+
+ if (!pe)
+ return pe;
+ }
+
+ if (sizeOnly ? (pe->size.isNull() || !pe->size.isValid()) : pe->pixmap.isNull()) {
+ pe->pixmap = QPixmap(pe->fileName);
+ if (!pe->pixmap.isNull())
+ pe->size = pe->pixmap.size();
+ }
+
+ return pe;
+}
+
+QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)
+{
+ QPixmap pm;
+ QPixmapIconEngineEntry *pe = bestMatch(size, mode, state, false);
+ if (pe)
+ pm = pe->pixmap;
+
+ if (pm.isNull()) {
+ int idx = pixmaps.count();
+ while (--idx >= 0) {
+ if (pe == &pixmaps[idx]) {
+ pixmaps.remove(idx);
+ break;
+ }
+ }
+ if (pixmaps.isEmpty())
+ return pm;
+ else
+ return pixmap(size, mode, state);
+ }
+
+ QSize actualSize = pm.size();
+ if (!actualSize.isNull() && (actualSize.width() > size.width() || actualSize.height() > size.height()))
+ actualSize.scale(size, Qt::KeepAspectRatio);
+
+ // #### Qt5 no idea what this really does, but we need to remove the QApp and style references
+// QString key = QLatin1Literal("qt_")
+// % HexString<quint64>(pm.cacheKey())
+// % HexString<uint>(pe->mode)
+// % HexString<quint64>(QApplication::palette().cacheKey())
+// % HexString<uint>(actualSize.width())
+// % HexString<uint>(actualSize.height());
+
+// if (mode == QIcon::Active) {
+// if (QPixmapCache::find(key % HexString<uint>(mode), pm))
+// return pm; // horray
+// if (QPixmapCache::find(key % HexString<uint>(QIcon::Normal), pm)) {
+// QStyleOption opt(0);
+// opt.palette = QApplication::palette();
+// QPixmap active = QApplication::style()->generatedIconPixmap(QIcon::Active, pm, &opt);
+// if (pm.cacheKey() == active.cacheKey())
+// return pm;
+// }
+// }
+
+// if (!QPixmapCache::find(key % HexString<uint>(mode), pm)) {
+ if (pm.size() != actualSize)
+ pm = pm.scaled(actualSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+// if (pe->mode != mode && mode != QIcon::Normal) {
+// QStyleOption opt(0);
+// opt.palette = QApplication::palette();
+// QPixmap generated = QApplication::style()->generatedIconPixmap(mode, pm, &opt);
+// if (!generated.isNull())
+// pm = generated;
+// }
+// QPixmapCache::insert(key % HexString<uint>(mode), pm);
+// }
+ return pm;
+}
+
+QSize QPixmapIconEngine::actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state)
+{
+ QSize actualSize;
+ if (QPixmapIconEngineEntry *pe = bestMatch(size, mode, state, true))
+ actualSize = pe->size;
+
+ if (actualSize.isNull())
+ return actualSize;
+
+ if (!actualSize.isNull() && (actualSize.width() > size.width() || actualSize.height() > size.height()))
+ actualSize.scale(size, Qt::KeepAspectRatio);
+ return actualSize;
+}
+
+void QPixmapIconEngine::addPixmap(const QPixmap &pixmap, QIcon::Mode mode, QIcon::State state)
+{
+ if (!pixmap.isNull()) {
+ QPixmapIconEngineEntry *pe = tryMatch(pixmap.size(), mode, state);
+ if(pe && pe->size == pixmap.size()) {
+ pe->pixmap = pixmap;
+ pe->fileName.clear();
+ } else {
+ pixmaps += QPixmapIconEngineEntry(pixmap, mode, state);
+ }
+ }
+}
+
+void QPixmapIconEngine::addFile(const QString &fileName, const QSize &_size, QIcon::Mode mode, QIcon::State state)
+{
+ if (!fileName.isEmpty()) {
+ QSize size = _size;
+ QPixmap pixmap;
+
+ QString abs = fileName;
+ if (fileName.at(0) != QLatin1Char(':'))
+ abs = QFileInfo(fileName).absoluteFilePath();
+
+ for (int i = 0; i < pixmaps.count(); ++i) {
+ if (pixmaps.at(i).mode == mode && pixmaps.at(i).state == state) {
+ QPixmapIconEngineEntry *pe = &pixmaps[i];
+ if(size == QSize()) {
+ pixmap = QPixmap(abs);
+ size = pixmap.size();
+ }
+ if (pe->size == QSize() && pe->pixmap.isNull()) {
+ pe->pixmap = QPixmap(pe->fileName);
+ pe->size = pe->pixmap.size();
+ }
+ if(pe->size == size) {
+ pe->pixmap = pixmap;
+ pe->fileName = abs;
+ return;
+ }
+ }
+ }
+ QPixmapIconEngineEntry e(abs, size, mode, state);
+ e.pixmap = pixmap;
+ pixmaps += e;
+ }
+}
+
+QString QPixmapIconEngine::key() const
+{
+ return QLatin1String("QPixmapIconEngine");
+}
+
+QIconEngineV2 *QPixmapIconEngine::clone() const
+{
+ return new QPixmapIconEngine(*this);
+}
+
+bool QPixmapIconEngine::read(QDataStream &in)
+{
+ int num_entries;
+ QPixmap pm;
+ QString fileName;
+ QSize sz;
+ uint mode;
+ uint state;
+
+ in >> num_entries;
+ for (int i=0; i < num_entries; ++i) {
+ if (in.atEnd()) {
+ pixmaps.clear();
+ return false;
+ }
+ in >> pm;
+ in >> fileName;
+ in >> sz;
+ in >> mode;
+ in >> state;
+ if (pm.isNull()) {
+ addFile(fileName, sz, QIcon::Mode(mode), QIcon::State(state));
+ } else {
+ QPixmapIconEngineEntry pe(fileName, sz, QIcon::Mode(mode), QIcon::State(state));
+ pe.pixmap = pm;
+ pixmaps += pe;
+ }
+ }
+ return true;
+}
+
+bool QPixmapIconEngine::write(QDataStream &out) const
+{
+ int num_entries = pixmaps.size();
+ out << num_entries;
+ for (int i=0; i < num_entries; ++i) {
+ if (pixmaps.at(i).pixmap.isNull())
+ out << QPixmap(pixmaps.at(i).fileName);
+ else
+ out << pixmaps.at(i).pixmap;
+ out << pixmaps.at(i).fileName;
+ out << pixmaps.at(i).size;
+ out << (uint) pixmaps.at(i).mode;
+ out << (uint) pixmaps.at(i).state;
+ }
+ return true;
+}
+
+void QPixmapIconEngine::virtual_hook(int id, void *data)
+{
+ switch (id) {
+ case QIconEngineV2::AvailableSizesHook: {
+ QIconEngineV2::AvailableSizesArgument &arg =
+ *reinterpret_cast<QIconEngineV2::AvailableSizesArgument*>(data);
+ arg.sizes.clear();
+ for (int i = 0; i < pixmaps.size(); ++i) {
+ QPixmapIconEngineEntry &pe = pixmaps[i];
+ if (pe.size == QSize() && pe.pixmap.isNull()) {
+ pe.pixmap = QPixmap(pe.fileName);
+ pe.size = pe.pixmap.size();
+ }
+ if (pe.mode == arg.mode && pe.state == arg.state && !pe.size.isEmpty())
+ arg.sizes.push_back(pe.size);
+ }
+ break;
+ }
+ default:
+ QIconEngineV2::virtual_hook(id, data);
+ }
+}
+
+#ifndef QT_NO_LIBRARY
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
+ (QIconEngineFactoryInterface_iid, QLatin1String("/iconengines"), Qt::CaseInsensitive))
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loaderV2,
+ (QIconEngineFactoryInterfaceV2_iid, QLatin1String("/iconengines"), Qt::CaseInsensitive))
+#endif
+
+
+
+/*!
+ \class QIcon
+
+ \brief The QIcon class provides scalable icons in different modes
+ and states.
+
+ \ingroup painting
+ \ingroup shared
+
+
+ A QIcon can generate smaller, larger, active, and disabled pixmaps
+ from the set of pixmaps it is given. Such pixmaps are used by Qt
+ widgets to show an icon representing a particular action.
+
+ The simplest use of QIcon is to create one from a QPixmap file or
+ resource, and then use it, allowing Qt to work out all the required
+ icon styles and sizes. For example:
+
+ \snippet doc/src/snippets/code/src_gui_image_qicon.cpp 0
+
+ To undo a QIcon, simply set a null icon in its place:
+
+ \snippet doc/src/snippets/code/src_gui_image_qicon.cpp 1
+
+ Use the QImageReader::supportedImageFormats() and
+ QImageWriter::supportedImageFormats() functions to retrieve a
+ complete list of the supported file formats.
+
+ When you retrieve a pixmap using pixmap(QSize, Mode, State), and no
+ pixmap for this given size, mode and state has been added with
+ addFile() or addPixmap(), then QIcon will generate one on the
+ fly. This pixmap generation happens in a QIconEngineV2. The default
+ engine scales pixmaps down if required, but never up, and it uses
+ the current style to calculate a disabled appearance. By using
+ custom icon engines, you can customize every aspect of generated
+ icons. With QIconEnginePluginV2 it is possible to register different
+ icon engines for different file suffixes, making it possible for
+ third parties to provide additional icon engines to those included
+ with Qt.
+
+ \note Since Qt 4.2, an icon engine that supports SVG is included.
+
+ \section1 Making Classes that Use QIcon
+
+ If you write your own widgets that have an option to set a small
+ pixmap, consider allowing a QIcon to be set for that pixmap. The
+ Qt class QToolButton is an example of such a widget.
+
+ Provide a method to set a QIcon, and when you draw the icon, choose
+ whichever pixmap is appropriate for the current state of your widget.
+ For example:
+ \snippet doc/src/snippets/code/src_gui_image_qicon.cpp 2
+
+ You might also make use of the \c Active mode, perhaps making your
+ widget \c Active when the mouse is over the widget (see \l
+ QWidget::enterEvent()), while the mouse is pressed pending the
+ release that will activate the function, or when it is the currently
+ selected item. If the widget can be toggled, the "On" mode might be
+ used to draw a different icon.
+
+ \img icon.png QIcon
+
+ \sa {fowler}{GUI Design Handbook: Iconic Label}, {Icons Example}
+*/
+
+
+/*!
+ Constructs a null icon.
+*/
+QIcon::QIcon()
+ : d(0)
+{
+}
+
+/*!
+ Constructs an icon from a \a pixmap.
+ */
+QIcon::QIcon(const QPixmap &pixmap)
+ :d(0)
+{
+ addPixmap(pixmap);
+}
+
+/*!
+ Constructs a copy of \a other. This is very fast.
+*/
+QIcon::QIcon(const QIcon &other)
+ :d(other.d)
+{
+ if (d)
+ d->ref.ref();
+}
+
+/*!
+ Constructs an icon from the file with the given \a fileName. The
+ file will be loaded on demand.
+
+ If \a fileName contains a relative path (e.g. the filename only)
+ the relevant file must be found relative to the runtime working
+ directory.
+
+ The file name can be either refer to an actual file on disk or to
+ one of the application's embedded resources. See the
+ \l{resources.html}{Resource System} overview for details on how to
+ embed images and other resource files in the application's
+ executable.
+
+ Use the QImageReader::supportedImageFormats() and
+ QImageWriter::supportedImageFormats() functions to retrieve a
+ complete list of the supported file formats.
+*/
+QIcon::QIcon(const QString &fileName)
+ : d(0)
+{
+ addFile(fileName);
+}
+
+
+/*!
+ Creates an icon with a specific icon \a engine. The icon takes
+ ownership of the engine.
+*/
+QIcon::QIcon(QIconEngine *engine)
+ :d(new QIconPrivate)
+{
+ d->engine_version = 1;
+ d->engine = engine;
+ d->v1RefCount = new QAtomicInt(1);
+}
+
+/*!
+ Creates an icon with a specific icon \a engine. The icon takes
+ ownership of the engine.
+*/
+QIcon::QIcon(QIconEngineV2 *engine)
+ :d(new QIconPrivate)
+{
+ d->engine_version = 2;
+ d->engine = engine;
+}
+
+/*!
+ Destroys the icon.
+*/
+QIcon::~QIcon()
+{
+ if (d && !d->ref.deref())
+ delete d;
+}
+
+/*!
+ Assigns the \a other icon to this icon and returns a reference to
+ this icon.
+*/
+QIcon &QIcon::operator=(const QIcon &other)
+{
+ if (other.d)
+ other.d->ref.ref();
+ if (d && !d->ref.deref())
+ delete d;
+ d = other.d;
+ return *this;
+}
+
+/*!
+ \fn void QIcon::swap(QIcon &other)
+ \since 4.8
+
+ Swaps icon \a other with this icon. This operation is very
+ fast and never fails.
+*/
+
+/*!
+ Returns the icon as a QVariant.
+*/
+QIcon::operator QVariant() const
+{
+ return QVariant(QVariant::Icon, this);
+}
+
+/*! \obsolete
+
+ Returns a number that identifies the contents of this
+ QIcon object. Distinct QIcon objects can have
+ the same serial number if they refer to the same contents
+ (but they don't have to). Also, the serial number of
+ a QIcon object may change during its lifetime.
+
+ Use cacheKey() instead.
+
+ A null icon always has a serial number of 0.
+
+ Serial numbers are mostly useful in conjunction with caching.
+
+ \sa QPixmap::serialNumber()
+*/
+
+int QIcon::serialNumber() const
+{
+ return d ? d->serialNum : 0;
+}
+
+/*!
+ Returns a number that identifies the contents of this QIcon
+ object. Distinct QIcon objects can have the same key if
+ they refer to the same contents.
+ \since 4.3
+
+ The cacheKey() will change when the icon is altered via
+ addPixmap() or addFile().
+
+ Cache keys are mostly useful in conjunction with caching.
+
+ \sa QPixmap::cacheKey()
+*/
+qint64 QIcon::cacheKey() const
+{
+ if (!d)
+ return 0;
+ return (((qint64) d->serialNum) << 32) | ((qint64) (d->detach_no));
+}
+
+/*!
+ Returns a pixmap with the requested \a size, \a mode, and \a
+ state, generating one if necessary. The pixmap might be smaller than
+ requested, but never larger.
+
+ \sa actualSize(), paint()
+*/
+QPixmap QIcon::pixmap(const QSize &size, Mode mode, State state) const
+{
+ if (!d)
+ return QPixmap();
+ return d->engine->pixmap(size, mode, state);
+}
+
+/*!
+ \fn QPixmap QIcon::pixmap(int w, int h, Mode mode = Normal, State state = Off) const
+
+ \overload
+
+ Returns a pixmap of size QSize(\a w, \a h). The pixmap might be smaller than
+ requested, but never larger.
+*/
+
+/*!
+ \fn QPixmap QIcon::pixmap(int extent, Mode mode = Normal, State state = Off) const
+
+ \overload
+
+ Returns a pixmap of size QSize(\a extent, \a extent). The pixmap might be smaller
+ than requested, but never larger.
+*/
+
+/*! Returns the actual size of the icon for the requested \a size, \a
+ mode, and \a state. The result might be smaller than requested, but
+ never larger.
+
+ \sa pixmap(), paint()
+*/
+QSize QIcon::actualSize(const QSize &size, Mode mode, State state) const
+{
+ if (!d)
+ return QSize();
+ return d->engine->actualSize(size, mode, state);
+}
+
+
+/*!
+ Uses the \a painter to paint the icon with specified \a alignment,
+ required \a mode, and \a state into the rectangle \a rect.
+
+ \sa actualSize(), pixmap()
+*/
+void QIcon::paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment, Mode mode, State state) const
+{
+ if (!d || !painter)
+ return;
+ QRect alignedRect = QStyle::alignedRect(painter->layoutDirection(), alignment, d->engine->actualSize(rect.size(), mode, state), rect);
+ d->engine->paint(painter, alignedRect, mode, state);
+}
+
+/*!
+ \fn void QIcon::paint(QPainter *painter, int x, int y, int w, int h, Qt::Alignment alignment,
+ Mode mode, State state) const
+
+ \overload
+
+ Paints the icon into the rectangle QRect(\a x, \a y, \a w, \a h).
+*/
+
+/*!
+ Returns true if the icon is empty; otherwise returns false.
+
+ An icon is empty if it has neither a pixmap nor a filename.
+
+ Note: Even a non-null icon might not be able to create valid
+ pixmaps, eg. if the file does not exist or cannot be read.
+*/
+bool QIcon::isNull() const
+{
+ return !d;
+}
+
+/*!\internal
+ */
+bool QIcon::isDetached() const
+{
+ return !d || d->ref == 1;
+}
+
+/*! \internal
+ */
+void QIcon::detach()
+{
+ if (d) {
+ if (d->ref != 1) {
+ QIconPrivate *x = new QIconPrivate;
+ if (d->engine_version > 1) {
+ QIconEngineV2 *engine = static_cast<QIconEngineV2 *>(d->engine);
+ x->engine = engine->clone();
+ } else {
+ x->engine = d->engine;
+ x->v1RefCount = d->v1RefCount;
+ x->v1RefCount->ref();
+ }
+ x->engine_version = d->engine_version;
+ if (!d->ref.deref())
+ delete d;
+ d = x;
+ }
+ ++d->detach_no;
+ }
+}
+
+/*!
+ Adds \a pixmap to the icon, as a specialization for \a mode and
+ \a state.
+
+ Custom icon engines are free to ignore additionally added
+ pixmaps.
+
+ \sa addFile()
+*/
+void QIcon::addPixmap(const QPixmap &pixmap, Mode mode, State state)
+{
+ if (pixmap.isNull())
+ return;
+ if (!d) {
+ d = new QIconPrivate;
+ d->engine = new QPixmapIconEngine;
+ } else {
+ detach();
+ }
+ d->engine->addPixmap(pixmap, mode, state);
+}
+
+
+/*! Adds an image from the file with the given \a fileName to the
+ icon, as a specialization for \a size, \a mode and \a state. The
+ file will be loaded on demand. Note: custom icon engines are free
+ to ignore additionally added pixmaps.
+
+ If \a fileName contains a relative path (e.g. the filename only)
+ the relevant file must be found relative to the runtime working
+ directory.
+
+ The file name can be either refer to an actual file on disk or to
+ one of the application's embedded resources. See the
+ \l{resources.html}{Resource System} overview for details on how to
+ embed images and other resource files in the application's
+ executable.
+
+ Use the QImageReader::supportedImageFormats() and
+ QImageWriter::supportedImageFormats() functions to retrieve a
+ complete list of the supported file formats.
+
+ Note: When you add a non-empty filename to a QIcon, the icon becomes
+ non-null, even if the file doesn't exist or points to a corrupt file.
+
+ \sa addPixmap()
+ */
+void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State state)
+{
+ if (fileName.isEmpty())
+ return;
+ if (!d) {
+#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
+ QFileInfo info(fileName);
+ QString suffix = info.suffix();
+ if (!suffix.isEmpty()) {
+ // first try version 2 engines..
+ if (QIconEngineFactoryInterfaceV2 *factory = qobject_cast<QIconEngineFactoryInterfaceV2*>(loaderV2()->instance(suffix))) {
+ if (QIconEngine *engine = factory->create(fileName)) {
+ d = new QIconPrivate;
+ d->engine = engine;
+ }
+ }
+ // ..then fall back and try to load version 1 engines
+ if (!d) {
+ if (QIconEngineFactoryInterface *factory = qobject_cast<QIconEngineFactoryInterface*>(loader()->instance(suffix))) {
+ if (QIconEngine *engine = factory->create(fileName)) {
+ d = new QIconPrivate;
+ d->engine = engine;
+ d->engine_version = 1;
+ d->v1RefCount = new QAtomicInt(1);
+ }
+ }
+ }
+ }
+#endif
+ // ...then fall back to the default engine
+ if (!d) {
+ d = new QIconPrivate;
+ d->engine = new QPixmapIconEngine;
+ }
+ } else {
+ detach();
+ }
+ d->engine->addFile(fileName, size, mode, state);
+}
+
+/*!
+ \since 4.5
+
+ Returns a list of available icon sizes for the specified \a mode and
+ \a state.
+*/
+QList<QSize> QIcon::availableSizes(Mode mode, State state) const
+{
+ if (!d || !d->engine || d->engine_version < 2)
+ return QList<QSize>();
+ QIconEngineV2 *engine = static_cast<QIconEngineV2*>(d->engine);
+ return engine->availableSizes(mode, state);
+}
+
+/*!
+ \since 4.7
+
+ Returns the name used to create the icon, if available.
+
+ Depending on the way the icon was created, it may have an associated
+ name. This is the case for icons created with fromTheme() or icons
+ using a QIconEngine which supports the QIconEngineV2::IconNameHook.
+
+ \sa fromTheme(), QIconEngine
+*/
+QString QIcon::name() const
+{
+ if (!d || !d->engine || d->engine_version < 2)
+ return QString();
+ QIconEngineV2 *engine = static_cast<QIconEngineV2*>(d->engine);
+ return engine->iconName();
+}
+
+/*!
+ \since 4.6
+
+ Sets the search paths for icon themes to \a paths.
+ \sa themeSearchPaths(), fromTheme(), setThemeName()
+*/
+void QIcon::setThemeSearchPaths(const QStringList &paths)
+{
+ QIconLoader::instance()->setThemeSearchPath(paths);
+}
+
+/*!
+ \since 4.6
+
+ Returns the search paths for icon themes.
+
+ The default value will depend on the platform:
+
+ On X11, the search path will use the XDG_DATA_DIRS environment
+ variable if available.
+
+ By default all platforms will have the resource directory
+ \c{:\icons} as a fallback. You can use "rcc -project" to generate a
+ resource file from your icon theme.
+
+ \sa setThemeSearchPaths(), fromTheme(), setThemeName()
+*/
+QStringList QIcon::themeSearchPaths()
+{
+ return QIconLoader::instance()->themeSearchPaths();
+}
+
+/*!
+ \since 4.6
+
+ Sets the current icon theme to \a name.
+
+ The \a name should correspond to a directory name in the
+ themeSearchPath() containing an index.theme
+ file describing it's contents.
+
+ \sa themeSearchPaths(), themeName()
+*/
+void QIcon::setThemeName(const QString &name)
+{
+ QIconLoader::instance()->setThemeName(name);
+}
+
+/*!
+ \since 4.6
+
+ Returns the name of the current icon theme.
+
+ On X11, the current icon theme depends on your desktop
+ settings. On other platforms it is not set by default.
+
+ \sa setThemeName(), themeSearchPaths(), fromTheme(),
+ hasThemeIcon()
+*/
+QString QIcon::themeName()
+{
+ return QIconLoader::instance()->themeName();
+}
+
+/*!
+ \since 4.6
+
+ Returns the QIcon corresponding to \a name in the current
+ icon theme. If no such icon is found in the current theme
+ \a fallback is returned instead.
+
+ The latest version of the freedesktop icon specification and naming
+ specification can be obtained here:
+
+ \list
+ \o \l{http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html}
+ \o \l{http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html}
+ \endlist
+
+ To fetch an icon from the current icon theme:
+
+ \snippet doc/src/snippets/code/src_gui_image_qicon.cpp 3
+
+ Or if you want to provide a guaranteed fallback for platforms that
+ do not support theme icons, you can use the second argument:
+
+ \snippet doc/src/snippets/code/src_gui_image_qicon.cpp 4
+
+ \note By default, only X11 will support themed icons. In order to
+ use themed icons on Mac and Windows, you will have to bundle a
+ compliant theme in one of your themeSearchPaths() and set the
+ appropriate themeName().
+
+ \sa themeName(), setThemeName(), themeSearchPaths()
+*/
+QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback)
+{
+ QIcon icon;
+
+ if (qtIconCache()->contains(name)) {
+ icon = *qtIconCache()->object(name);
+ } else {
+ QIcon *cachedIcon = new QIcon(new QIconLoaderEngine(name));
+ qtIconCache()->insert(name, cachedIcon);
+ icon = *cachedIcon;
+ }
+
+ // Note the qapp check is to allow lazy loading of static icons
+ // Supporting fallbacks will not work for this case.
+ if (qApp && icon.availableSizes().isEmpty())
+ return fallback;
+
+ return icon;
+}
+
+/*!
+ \since 4.6
+
+ Returns true if there is an icon available for \a name in the
+ current icon theme, otherwise returns false.
+
+ \sa themeSearchPaths(), fromTheme(), setThemeName()
+*/
+bool QIcon::hasThemeIcon(const QString &name)
+{
+ QIcon icon = fromTheme(name);
+
+ return !icon.isNull();
+}
+
+
+/*****************************************************************************
+ QIcon stream functions
+ *****************************************************************************/
+#if !defined(QT_NO_DATASTREAM)
+/*!
+ \fn QDataStream &operator<<(QDataStream &stream, const QIcon &icon)
+ \relates QIcon
+ \since 4.2
+
+ Writes the given \a icon to the given \a stream as a PNG
+ image. If the icon contains more than one image, all images will
+ be written to the stream. Note that writing the stream to a file
+ will not produce a valid image file.
+*/
+
+QDataStream &operator<<(QDataStream &s, const QIcon &icon)
+{
+ if (s.version() >= QDataStream::Qt_4_3) {
+ if (icon.isNull()) {
+ s << QString();
+ } else {
+ if (icon.d->engine_version > 1) {
+ QIconEngineV2 *engine = static_cast<QIconEngineV2 *>(icon.d->engine);
+ s << engine->key();
+ engine->write(s);
+ } else {
+ // not really supported
+ qWarning("QIcon: Cannot stream QIconEngine. Use QIconEngineV2 instead.");
+ }
+ }
+ } else if (s.version() == QDataStream::Qt_4_2) {
+ if (icon.isNull()) {
+ s << 0;
+ } else {
+ QPixmapIconEngine *engine = static_cast<QPixmapIconEngine *>(icon.d->engine);
+ int num_entries = engine->pixmaps.size();
+ s << num_entries;
+ for (int i=0; i < num_entries; ++i) {
+ s << engine->pixmaps.at(i).pixmap;
+ s << engine->pixmaps.at(i).fileName;
+ s << engine->pixmaps.at(i).size;
+ s << (uint) engine->pixmaps.at(i).mode;
+ s << (uint) engine->pixmaps.at(i).state;
+ }
+ }
+ } else {
+ s << QPixmap(icon.pixmap(22,22));
+ }
+ return s;
+}
+
+/*!
+ \fn QDataStream &operator>>(QDataStream &stream, QIcon &icon)
+ \relates QIcon
+ \since 4.2
+
+ Reads an image, or a set of images, from the given \a stream into
+ the given \a icon.
+*/
+
+QDataStream &operator>>(QDataStream &s, QIcon &icon)
+{
+ if (s.version() >= QDataStream::Qt_4_3) {
+ icon = QIcon();
+ QString key;
+ s >> key;
+ if (key == QLatin1String("QPixmapIconEngine")) {
+ icon.d = new QIconPrivate;
+ QIconEngineV2 *engine = new QPixmapIconEngine;
+ icon.d->engine = engine;
+ engine->read(s);
+ } else if (key == QLatin1String("QIconLoaderEngine")) {
+ icon.d = new QIconPrivate;
+ QIconEngineV2 *engine = new QIconLoaderEngine();
+ icon.d->engine = engine;
+ engine->read(s);
+#if !defined (QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS)
+ } else if (QIconEngineFactoryInterfaceV2 *factory = qobject_cast<QIconEngineFactoryInterfaceV2*>(loaderV2()->instance(key))) {
+ if (QIconEngineV2 *engine= factory->create()) {
+ icon.d = new QIconPrivate;
+ icon.d->engine = engine;
+ engine->read(s);
+ }
+#endif
+ }
+ } else if (s.version() == QDataStream::Qt_4_2) {
+ icon = QIcon();
+ int num_entries;
+ QPixmap pm;
+ QString fileName;
+ QSize sz;
+ uint mode;
+ uint state;
+
+ s >> num_entries;
+ for (int i=0; i < num_entries; ++i) {
+ s >> pm;
+ s >> fileName;
+ s >> sz;
+ s >> mode;
+ s >> state;
+ if (pm.isNull())
+ icon.addFile(fileName, sz, QIcon::Mode(mode), QIcon::State(state));
+ else
+ icon.addPixmap(pm, QIcon::Mode(mode), QIcon::State(state));
+ }
+ } else {
+ QPixmap pm;
+ s >> pm;
+ icon.addPixmap(pm);
+ }
+ return s;
+}
+
+#endif //QT_NO_DATASTREAM
+
+/*!
+ \fn DataPtr &QIcon::data_ptr()
+ \internal
+*/
+
+/*!
+ \typedef QIcon::DataPtr
+ \internal
+*/
+
+QT_END_NAMESPACE
+#endif //QT_NO_ICON
diff --git a/src/widgets/kernel/qicon.h b/src/widgets/kernel/qicon.h
new file mode 100644
index 0000000000..4e3960925e
--- /dev/null
+++ b/src/widgets/kernel/qicon.h
@@ -0,0 +1,143 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QICON_H
+#define QICON_H
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qsize.h>
+#include <QtCore/qlist.h>
+#include <QtGui/qpixmap.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QIconPrivate;
+class QIconEngine;
+class QIconEngineV2;
+
+class Q_GUI_EXPORT QIcon
+{
+public:
+ enum Mode { Normal, Disabled, Active, Selected };
+ enum State { On, Off };
+
+ QIcon();
+ QIcon(const QPixmap &pixmap);
+ QIcon(const QIcon &other);
+ explicit QIcon(const QString &fileName); // file or resource name
+ explicit QIcon(QIconEngine *engine);
+ explicit QIcon(QIconEngineV2 *engine);
+ ~QIcon();
+ QIcon &operator=(const QIcon &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QIcon &operator=(QIcon &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
+ inline void swap(QIcon &other) { qSwap(d, other.d); }
+
+ operator QVariant() const;
+
+ QPixmap pixmap(const QSize &size, Mode mode = Normal, State state = Off) const;
+ inline QPixmap pixmap(int w, int h, Mode mode = Normal, State state = Off) const
+ { return pixmap(QSize(w, h), mode, state); }
+ inline QPixmap pixmap(int extent, Mode mode = Normal, State state = Off) const
+ { return pixmap(QSize(extent, extent), mode, state); }
+
+ QSize actualSize(const QSize &size, Mode mode = Normal, State state = Off) const;
+
+ QString name() const;
+
+ void paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment = Qt::AlignCenter, Mode mode = Normal, State state = Off) const;
+ inline void paint(QPainter *painter, int x, int y, int w, int h, Qt::Alignment alignment = Qt::AlignCenter, Mode mode = Normal, State state = Off) const
+ { paint(painter, QRect(x, y, w, h), alignment, mode, state); }
+
+ bool isNull() const;
+ bool isDetached() const;
+ void detach();
+
+ int serialNumber() const;
+ qint64 cacheKey() const;
+
+ void addPixmap(const QPixmap &pixmap, Mode mode = Normal, State state = Off);
+ void addFile(const QString &fileName, const QSize &size = QSize(), Mode mode = Normal, State state = Off);
+
+ QList<QSize> availableSizes(Mode mode = Normal, State state = Off) const;
+
+ static QIcon fromTheme(const QString &name, const QIcon &fallback = QIcon());
+ static bool hasThemeIcon(const QString &name);
+
+ static QStringList themeSearchPaths();
+ static void setThemeSearchPaths(const QStringList &searchpath);
+
+ static QString themeName();
+ static void setThemeName(const QString &path);
+
+ Q_DUMMY_COMPARISON_OPERATOR(QIcon)
+
+private:
+ QIconPrivate *d;
+#if !defined(QT_NO_DATASTREAM)
+ friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QIcon &);
+ friend Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QIcon &);
+#endif
+
+public:
+ typedef QIconPrivate * DataPtr;
+ inline DataPtr &data_ptr() { return d; }
+};
+
+Q_DECLARE_SHARED(QIcon)
+Q_DECLARE_TYPEINFO(QIcon, Q_MOVABLE_TYPE);
+
+#if !defined(QT_NO_DATASTREAM)
+Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QIcon &);
+Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QIcon &);
+#endif
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QICON_H
diff --git a/src/widgets/kernel/qicon_p.h b/src/widgets/kernel/qicon_p.h
new file mode 100644
index 0000000000..06eae53daf
--- /dev/null
+++ b/src/widgets/kernel/qicon_p.h
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QICON_P_H
+#define QICON_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qsize.h>
+#include <QtCore/qlist.h>
+#include <QtGui/qpixmap.h>
+#include <QtWidgets/qicon.h>
+#include <QtWidgets/qiconengine.h>
+
+#ifndef QT_NO_ICON
+QT_BEGIN_NAMESPACE
+
+class QIconPrivate
+{
+public:
+ QIconPrivate();
+
+ ~QIconPrivate() {
+ if (engine_version == 1) {
+ if (!v1RefCount->deref()) {
+ delete engine;
+ delete v1RefCount;
+ }
+ } else if (engine_version == 2) {
+ delete engine;
+ }
+ }
+
+ QIconEngine *engine;
+
+ QAtomicInt ref;
+ int serialNum;
+ int detach_no;
+ int engine_version;
+
+ QAtomicInt *v1RefCount;
+};
+
+
+struct QPixmapIconEngineEntry
+{
+ QPixmapIconEngineEntry():mode(QIcon::Normal), state(QIcon::Off){}
+ QPixmapIconEngineEntry(const QPixmap &pm, QIcon::Mode m = QIcon::Normal, QIcon::State s = QIcon::Off)
+ :pixmap(pm), size(pm.size()), mode(m), state(s){}
+ QPixmapIconEngineEntry(const QString &file, const QSize &sz = QSize(), QIcon::Mode m = QIcon::Normal, QIcon::State s = QIcon::Off)
+ :fileName(file), size(sz), mode(m), state(s){}
+ QPixmap pixmap;
+ QString fileName;
+ QSize size;
+ QIcon::Mode mode;
+ QIcon::State state;
+ bool isNull() const {return (fileName.isEmpty() && pixmap.isNull()); }
+};
+
+
+
+class QPixmapIconEngine : public QIconEngineV2 {
+public:
+ QPixmapIconEngine();
+ QPixmapIconEngine(const QPixmapIconEngine &);
+ ~QPixmapIconEngine();
+ void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state);
+ QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
+ QPixmapIconEngineEntry *bestMatch(const QSize &size, QIcon::Mode mode, QIcon::State state, bool sizeOnly);
+ QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state);
+ void addPixmap(const QPixmap &pixmap, QIcon::Mode mode, QIcon::State state);
+ void addFile(const QString &fileName, const QSize &size, QIcon::Mode mode, QIcon::State state);
+
+ // v2 functions
+ QString key() const;
+ QIconEngineV2 *clone() const;
+ bool read(QDataStream &in);
+ bool write(QDataStream &out) const;
+ void virtual_hook(int id, void *data);
+
+private:
+ QPixmapIconEngineEntry *tryMatch(const QSize &size, QIcon::Mode mode, QIcon::State state);
+ QVector<QPixmapIconEngineEntry> pixmaps;
+
+ friend QDataStream &operator<<(QDataStream &s, const QIcon &icon);
+ friend class QIconThemeEngine;
+};
+
+QT_END_NAMESPACE
+#endif //QT_NO_ICON
+#endif // QICON_P_H
diff --git a/src/gui/image/qiconengine.cpp b/src/widgets/kernel/qiconengine.cpp
index 6168a83940..6168a83940 100644
--- a/src/gui/image/qiconengine.cpp
+++ b/src/widgets/kernel/qiconengine.cpp
diff --git a/src/widgets/kernel/qiconengine.h b/src/widgets/kernel/qiconengine.h
new file mode 100644
index 0000000000..282dd38aa9
--- /dev/null
+++ b/src/widgets/kernel/qiconengine.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QICONENGINE_H
+#define QICONENGINE_H
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qlist.h>
+#include <QtWidgets/qicon.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class Q_GUI_EXPORT QIconEngine
+{
+public:
+ virtual ~QIconEngine();
+ virtual void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) = 0;
+ virtual QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state);
+ virtual QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
+
+ virtual void addPixmap(const QPixmap &pixmap, QIcon::Mode mode, QIcon::State state);
+ virtual void addFile(const QString &fileName, const QSize &size, QIcon::Mode mode, QIcon::State state);
+
+#if 0
+ virtual int frameCount(QIcon::Mode fromMode, QIcon::State fromState, QIcon::Mode toMode, QIcon::State toState);
+ virtual void paintFrame(QPainter *painter, const QRect &rect, int frameNumber, QIcon::Mode fromMode, QIcon::State fromState, QIcon::Mode toMode, QIcon::State toState);
+#endif
+};
+
+// ### Qt 5: move the below into QIconEngine
+class Q_GUI_EXPORT QIconEngineV2 : public QIconEngine
+{
+public:
+ virtual QString key() const;
+ virtual QIconEngineV2 *clone() const;
+ virtual bool read(QDataStream &in);
+ virtual bool write(QDataStream &out) const;
+ virtual void virtual_hook(int id, void *data);
+
+public:
+ enum IconEngineHook { AvailableSizesHook = 1, IconNameHook };
+
+ struct AvailableSizesArgument
+ {
+ QIcon::Mode mode;
+ QIcon::State state;
+ QList<QSize> sizes;
+ };
+
+ // ### Qt 5: make this function const and virtual.
+ QList<QSize> availableSizes(QIcon::Mode mode = QIcon::Normal,
+ QIcon::State state = QIcon::Off);
+
+ // ### Qt 5: make this function const and virtual.
+ QString iconName();
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QICONENGINE_H
diff --git a/src/gui/image/qiconengineplugin.cpp b/src/widgets/kernel/qiconengineplugin.cpp
index 7c8c3a3c1a..7c8c3a3c1a 100644
--- a/src/gui/image/qiconengineplugin.cpp
+++ b/src/widgets/kernel/qiconengineplugin.cpp
diff --git a/src/gui/image/qiconengineplugin.h b/src/widgets/kernel/qiconengineplugin.h
index e892a38f7b..e892a38f7b 100644
--- a/src/gui/image/qiconengineplugin.h
+++ b/src/widgets/kernel/qiconengineplugin.h
diff --git a/src/widgets/kernel/qiconloader.cpp b/src/widgets/kernel/qiconloader.cpp
new file mode 100644
index 0000000000..361a49a7ee
--- /dev/null
+++ b/src/widgets/kernel/qiconloader.cpp
@@ -0,0 +1,573 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QT_NO_ICON
+#include <private/qiconloader_p.h>
+
+#include <private/qguiapplication_p.h>
+#include <private/qicon_p.h>
+#include <private/qguiplatformplugin_p.h>
+
+#include <QtWidgets/QIconEnginePlugin>
+#include <QtGui/QPixmapCache>
+#include <QtWidgets/QIconEngine>
+#include <QtWidgets/QStyleOption>
+#include <QtCore/QList>
+#include <QtCore/QHash>
+#include <QtCore/QDir>
+#include <QtCore/QSettings>
+#include <QtGui/QPainter>
+
+#ifdef Q_WS_MAC
+#include <private/qt_cocoa_helpers_mac_p.h>
+#endif
+
+#ifdef Q_WS_X11
+#include <private/qt_x11_p.h>
+#endif
+
+#include <private/qhexstring_p.h>
+
+QT_BEGIN_NAMESPACE
+
+Q_GLOBAL_STATIC(QIconLoader, iconLoaderInstance)
+
+/* Theme to use in last resort, if the theme does not have the icon, neither the parents */
+static QString fallbackTheme()
+{
+#ifdef Q_WS_X11
+ if (X11->desktopEnvironment == DE_GNOME) {
+ return QLatin1String("gnome");
+ } else if (X11->desktopEnvironment == DE_KDE) {
+ return X11->desktopVersion >= 4
+ ? QString::fromLatin1("oxygen")
+ : QString::fromLatin1("crystalsvg");
+ } else {
+ return QLatin1String("hicolor");
+ }
+#endif
+ return QString();
+}
+
+QIconLoader::QIconLoader() :
+ m_themeKey(1), m_supportsSvg(false), m_initialized(false)
+{
+}
+
+// We lazily initialize the loader to make static icons
+// work. Though we do not officially support this.
+void QIconLoader::ensureInitialized()
+{
+ if (!m_initialized) {
+ m_initialized = true;
+
+ Q_ASSERT(qApp);
+
+ m_systemTheme = qt_guiPlatformPlugin()->systemIconThemeName();
+ if (m_systemTheme.isEmpty())
+ m_systemTheme = fallbackTheme();
+#ifndef QT_NO_LIBRARY
+ QFactoryLoader iconFactoryLoader(QIconEngineFactoryInterfaceV2_iid,
+ QLatin1String("/iconengines"),
+ Qt::CaseInsensitive);
+ if (iconFactoryLoader.keys().contains(QLatin1String("svg")))
+ m_supportsSvg = true;
+#endif //QT_NO_LIBRARY
+ }
+}
+
+QIconLoader *QIconLoader::instance()
+{
+ return iconLoaderInstance();
+}
+
+// Queries the system theme and invalidates existing
+// icons if the theme has changed.
+void QIconLoader::updateSystemTheme()
+{
+ // Only change if this is not explicitly set by the user
+ if (m_userTheme.isEmpty()) {
+ QString theme = qt_guiPlatformPlugin()->systemIconThemeName();
+ if (theme.isEmpty())
+ theme = fallbackTheme();
+ if (theme != m_systemTheme) {
+ m_systemTheme = theme;
+ invalidateKey();
+ }
+ }
+}
+
+void QIconLoader::setThemeName(const QString &themeName)
+{
+ m_userTheme = themeName;
+ invalidateKey();
+}
+
+void QIconLoader::setThemeSearchPath(const QStringList &searchPaths)
+{
+ m_iconDirs = searchPaths;
+ themeList.clear();
+ invalidateKey();
+}
+
+QStringList QIconLoader::themeSearchPaths() const
+{
+ if (m_iconDirs.isEmpty()) {
+ m_iconDirs = qt_guiPlatformPlugin()->iconThemeSearchPaths();
+ // Always add resource directory as search path
+ m_iconDirs.append(QLatin1String(":/icons"));
+ }
+ return m_iconDirs;
+}
+
+QIconTheme::QIconTheme(const QString &themeName)
+ : m_valid(false)
+{
+ QFile themeIndex;
+
+ QList <QIconDirInfo> keyList;
+ QStringList iconDirs = QIcon::themeSearchPaths();
+ for ( int i = 0 ; i < iconDirs.size() ; ++i) {
+ QDir iconDir(iconDirs[i]);
+ QString themeDir = iconDir.path() + QLatin1Char('/') + themeName;
+ themeIndex.setFileName(themeDir + QLatin1String("/index.theme"));
+ if (themeIndex.exists()) {
+ m_contentDir = themeDir;
+ m_valid = true;
+ break;
+ }
+ }
+#ifndef QT_NO_SETTINGS
+ if (themeIndex.exists()) {
+ const QSettings indexReader(themeIndex.fileName(), QSettings::IniFormat);
+ QStringListIterator keyIterator(indexReader.allKeys());
+ while (keyIterator.hasNext()) {
+
+ const QString key = keyIterator.next();
+ if (key.endsWith(QLatin1String("/Size"))) {
+ // Note the QSettings ini-format does not accept
+ // slashes in key names, hence we have to cheat
+ if (int size = indexReader.value(key).toInt()) {
+ QString directoryKey = key.left(key.size() - 5);
+ QIconDirInfo dirInfo(directoryKey);
+ dirInfo.size = size;
+ QString type = indexReader.value(directoryKey +
+ QLatin1String("/Type")
+ ).toString();
+
+ if (type == QLatin1String("Fixed"))
+ dirInfo.type = QIconDirInfo::Fixed;
+ else if (type == QLatin1String("Scalable"))
+ dirInfo.type = QIconDirInfo::Scalable;
+ else
+ dirInfo.type = QIconDirInfo::Threshold;
+
+ dirInfo.threshold = indexReader.value(directoryKey +
+ QLatin1String("/Threshold"),
+ 2).toInt();
+
+ dirInfo.minSize = indexReader.value(directoryKey +
+ QLatin1String("/MinSize"),
+ size).toInt();
+
+ dirInfo.maxSize = indexReader.value(directoryKey +
+ QLatin1String("/MaxSize"),
+ size).toInt();
+ m_keyList.append(dirInfo);
+ }
+ }
+ }
+
+ // Parent themes provide fallbacks for missing icons
+ m_parents = indexReader.value(
+ QLatin1String("Icon Theme/Inherits")).toStringList();
+
+ // Ensure a default platform fallback for all themes
+ if (m_parents.isEmpty())
+ m_parents.append(fallbackTheme());
+
+ // Ensure that all themes fall back to hicolor
+ if (!m_parents.contains(QLatin1String("hicolor")))
+ m_parents.append(QLatin1String("hicolor"));
+ }
+#endif //QT_NO_SETTINGS
+}
+
+QThemeIconEntries QIconLoader::findIconHelper(const QString &themeName,
+ const QString &iconName,
+ QStringList &visited) const
+{
+ QThemeIconEntries entries;
+ Q_ASSERT(!themeName.isEmpty());
+
+ QPixmap pixmap;
+
+ // Used to protect against potential recursions
+ visited << themeName;
+
+ QIconTheme theme = themeList.value(themeName);
+ if (!theme.isValid()) {
+ theme = QIconTheme(themeName);
+ if (!theme.isValid())
+ theme = QIconTheme(fallbackTheme());
+
+ themeList.insert(themeName, theme);
+ }
+
+ QString contentDir = theme.contentDir() + QLatin1Char('/');
+ QList<QIconDirInfo> subDirs = theme.keyList();
+
+ const QString svgext(QLatin1String(".svg"));
+ const QString pngext(QLatin1String(".png"));
+
+ // Add all relevant files
+ for (int i = 0; i < subDirs.size() ; ++i) {
+ const QIconDirInfo &dirInfo = subDirs.at(i);
+ QString subdir = dirInfo.path;
+ QDir currentDir(contentDir + subdir);
+ if (currentDir.exists(iconName + pngext)) {
+ PixmapEntry *iconEntry = new PixmapEntry;
+ iconEntry->dir = dirInfo;
+ iconEntry->filename = currentDir.filePath(iconName + pngext);
+ // Notice we ensure that pixmap entries always come before
+ // scalable to preserve search order afterwards
+ entries.prepend(iconEntry);
+ } else if (m_supportsSvg &&
+ currentDir.exists(iconName + svgext)) {
+ ScalableEntry *iconEntry = new ScalableEntry;
+ iconEntry->dir = dirInfo;
+ iconEntry->filename = currentDir.filePath(iconName + svgext);
+ entries.append(iconEntry);
+ }
+ }
+
+ if (entries.isEmpty()) {
+ const QStringList parents = theme.parents();
+ // Search recursively through inherited themes
+ for (int i = 0 ; i < parents.size() ; ++i) {
+
+ const QString parentTheme = parents.at(i).trimmed();
+
+ if (!visited.contains(parentTheme)) // guard against recursion
+ entries = findIconHelper(parentTheme, iconName, visited);
+
+ if (!entries.isEmpty()) // success
+ break;
+ }
+ }
+ return entries;
+}
+
+QThemeIconEntries QIconLoader::loadIcon(const QString &name) const
+{
+ if (!themeName().isEmpty()) {
+ QStringList visited;
+ return findIconHelper(themeName(), name, visited);
+ }
+
+ return QThemeIconEntries();
+}
+
+
+// -------- Icon Loader Engine -------- //
+
+
+QIconLoaderEngine::QIconLoaderEngine(const QString& iconName)
+ : m_iconName(iconName), m_key(0)
+{
+}
+
+QIconLoaderEngine::~QIconLoaderEngine()
+{
+ while (!m_entries.isEmpty())
+ delete m_entries.takeLast();
+ Q_ASSERT(m_entries.size() == 0);
+}
+
+QIconLoaderEngine::QIconLoaderEngine(const QIconLoaderEngine &other)
+ : QIconEngineV2(other),
+ m_iconName(other.m_iconName),
+ m_key(0)
+{
+}
+
+QIconEngineV2 *QIconLoaderEngine::clone() const
+{
+ return new QIconLoaderEngine(*this);
+}
+
+bool QIconLoaderEngine::read(QDataStream &in) {
+ in >> m_iconName;
+ return true;
+}
+
+bool QIconLoaderEngine::write(QDataStream &out) const
+{
+ out << m_iconName;
+ return true;
+}
+
+bool QIconLoaderEngine::hasIcon() const
+{
+ return !(m_entries.isEmpty());
+}
+
+// Lazily load the icon
+void QIconLoaderEngine::ensureLoaded()
+{
+
+ iconLoaderInstance()->ensureInitialized();
+
+ if (!(iconLoaderInstance()->themeKey() == m_key)) {
+
+ while (!m_entries.isEmpty())
+ delete m_entries.takeLast();
+
+ Q_ASSERT(m_entries.size() == 0);
+ m_entries = iconLoaderInstance()->loadIcon(m_iconName);
+ m_key = iconLoaderInstance()->themeKey();
+ }
+}
+
+void QIconLoaderEngine::paint(QPainter *painter, const QRect &rect,
+ QIcon::Mode mode, QIcon::State state)
+{
+ QSize pixmapSize = rect.size();
+#if defined(Q_WS_MAC)
+ pixmapSize *= qt_mac_get_scalefactor();
+#endif
+ painter->drawPixmap(rect, pixmap(pixmapSize, mode, state));
+}
+
+/*
+ * This algorithm is defined by the freedesktop spec:
+ * http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html
+ */
+static bool directoryMatchesSize(const QIconDirInfo &dir, int iconsize)
+{
+ if (dir.type == QIconDirInfo::Fixed) {
+ return dir.size == iconsize;
+
+ } else if (dir.type == QIconDirInfo::Scalable) {
+ return dir.size <= dir.maxSize &&
+ iconsize >= dir.minSize;
+
+ } else if (dir.type == QIconDirInfo::Threshold) {
+ return iconsize >= dir.size - dir.threshold &&
+ iconsize <= dir.size + dir.threshold;
+ }
+
+ Q_ASSERT(1); // Not a valid value
+ return false;
+}
+
+/*
+ * This algorithm is defined by the freedesktop spec:
+ * http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html
+ */
+static int directorySizeDistance(const QIconDirInfo &dir, int iconsize)
+{
+ if (dir.type == QIconDirInfo::Fixed) {
+ return qAbs(dir.size - iconsize);
+
+ } else if (dir.type == QIconDirInfo::Scalable) {
+ if (iconsize < dir.minSize)
+ return dir.minSize - iconsize;
+ else if (iconsize > dir.maxSize)
+ return iconsize - dir.maxSize;
+ else
+ return 0;
+
+ } else if (dir.type == QIconDirInfo::Threshold) {
+ if (iconsize < dir.size - dir.threshold)
+ return dir.minSize - iconsize;
+ else if (iconsize > dir.size + dir.threshold)
+ return iconsize - dir.maxSize;
+ else return 0;
+ }
+
+ Q_ASSERT(1); // Not a valid value
+ return INT_MAX;
+}
+
+QIconLoaderEngineEntry *QIconLoaderEngine::entryForSize(const QSize &size)
+{
+ int iconsize = qMin(size.width(), size.height());
+
+ // Note that m_entries are sorted so that png-files
+ // come first
+
+ // Search for exact matches first
+ for (int i = 0; i < m_entries.count(); ++i) {
+ QIconLoaderEngineEntry *entry = m_entries.at(i);
+ if (directoryMatchesSize(entry->dir, iconsize)) {
+ return entry;
+ }
+ }
+
+ // Find the minimum distance icon
+ int minimalSize = INT_MAX;
+ QIconLoaderEngineEntry *closestMatch = 0;
+ for (int i = 0; i < m_entries.count(); ++i) {
+ QIconLoaderEngineEntry *entry = m_entries.at(i);
+ int distance = directorySizeDistance(entry->dir, iconsize);
+ if (distance < minimalSize) {
+ minimalSize = distance;
+ closestMatch = entry;
+ }
+ }
+ return closestMatch;
+}
+
+/*
+ * Returns the actual icon size. For scalable svg's this is equivalent
+ * to the requested size. Otherwise the closest match is returned but
+ * we can never return a bigger size than the requested size.
+ *
+ */
+QSize QIconLoaderEngine::actualSize(const QSize &size, QIcon::Mode mode,
+ QIcon::State state)
+{
+ ensureLoaded();
+
+ QIconLoaderEngineEntry *entry = entryForSize(size);
+ if (entry) {
+ const QIconDirInfo &dir = entry->dir;
+ if (dir.type == QIconDirInfo::Scalable)
+ return size;
+ else {
+ int result = qMin<int>(dir.size, qMin(size.width(), size.height()));
+ return QSize(result, result);
+ }
+ }
+ return QIconEngineV2::actualSize(size, mode, state);
+}
+
+QPixmap PixmapEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)
+{
+ Q_UNUSED(state);
+
+ // Ensure that basePixmap is lazily initialized before generating the
+ // key, otherwise the cache key is not unique
+ if (basePixmap.isNull())
+ basePixmap.load(filename);
+
+#if 0 // ### Qt5
+ int actualSize = qMin(size.width(), size.height());
+ QString key = QLatin1Literal("$qt_theme_")
+ % HexString<qint64>(basePixmap.cacheKey())
+ % HexString<int>(mode)
+ % HexString<qint64>(qApp->palette().cacheKey())
+ % HexString<int>(actualSize);
+
+ QPixmap cachedPixmap;
+ if (QPixmapCache::find(key, &cachedPixmap)) {
+ return cachedPixmap;
+ } else {
+ QStyleOption opt(0);
+ opt.palette = qApp->palette();
+ cachedPixmap = qApp->style()->generatedIconPixmap(mode, basePixmap, &opt);
+ QPixmapCache::insert(key, cachedPixmap);
+ }
+ return cachedPixmap;
+#else
+ return basePixmap;
+#endif
+}
+
+QPixmap ScalableEntry::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)
+{
+ if (svgIcon.isNull())
+ svgIcon = QIcon(filename);
+
+ // Simply reuse svg icon engine
+ return svgIcon.pixmap(size, mode, state);
+}
+
+QPixmap QIconLoaderEngine::pixmap(const QSize &size, QIcon::Mode mode,
+ QIcon::State state)
+{
+ ensureLoaded();
+
+ QIconLoaderEngineEntry *entry = entryForSize(size);
+ if (entry)
+ return entry->pixmap(size, mode, state);
+
+ return QPixmap();
+}
+
+QString QIconLoaderEngine::key() const
+{
+ return QLatin1String("QIconLoaderEngine");
+}
+
+void QIconLoaderEngine::virtual_hook(int id, void *data)
+{
+ ensureLoaded();
+
+ switch (id) {
+ case QIconEngineV2::AvailableSizesHook:
+ {
+ QIconEngineV2::AvailableSizesArgument &arg
+ = *reinterpret_cast<QIconEngineV2::AvailableSizesArgument*>(data);
+ const QList<QIconDirInfo> directoryKey = iconLoaderInstance()->theme().keyList();
+ arg.sizes.clear();
+
+ // Gets all sizes from the DirectoryInfo entries
+ for (int i = 0 ; i < m_entries.size() ; ++i) {
+ int size = m_entries.at(i)->dir.size;
+ arg.sizes.append(QSize(size, size));
+ }
+ }
+ break;
+ case QIconEngineV2::IconNameHook:
+ {
+ QString &name = *reinterpret_cast<QString*>(data);
+ name = m_iconName;
+ }
+ break;
+ default:
+ QIconEngineV2::virtual_hook(id, data);
+ }
+}
+
+QT_END_NAMESPACE
+
+#endif //QT_NO_ICON
diff --git a/src/widgets/kernel/qiconloader_p.h b/src/widgets/kernel/qiconloader_p.h
new file mode 100644
index 0000000000..eff8bbf663
--- /dev/null
+++ b/src/widgets/kernel/qiconloader_p.h
@@ -0,0 +1,192 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDESKTOPICON_P_H
+#define QDESKTOPICON_P_H
+
+#ifndef QT_NO_ICON
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtWidgets/QIcon>
+#include <QtWidgets/QIconEngine>
+#include <QtGui/QPixmapCache>
+#include <private/qicon_p.h>
+#include <private/qfactoryloader_p.h>
+#include <QtCore/QHash>
+
+QT_BEGIN_NAMESPACE
+
+class QIconLoader;
+
+struct QIconDirInfo
+{
+ enum Type { Fixed, Scalable, Threshold };
+ QIconDirInfo(const QString &_path = QString()) :
+ path(_path),
+ size(0),
+ maxSize(0),
+ minSize(0),
+ threshold(0),
+ type(Threshold) {}
+ QString path;
+ short size;
+ short maxSize;
+ short minSize;
+ short threshold;
+ Type type : 4;
+};
+
+class QIconLoaderEngineEntry
+ {
+public:
+ virtual ~QIconLoaderEngineEntry() {}
+ virtual QPixmap pixmap(const QSize &size,
+ QIcon::Mode mode,
+ QIcon::State state) = 0;
+ QString filename;
+ QIconDirInfo dir;
+ static int count;
+};
+
+struct ScalableEntry : public QIconLoaderEngineEntry
+{
+ QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
+ QIcon svgIcon;
+};
+
+struct PixmapEntry : public QIconLoaderEngineEntry
+{
+ QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
+ QPixmap basePixmap;
+};
+
+typedef QList<QIconLoaderEngineEntry*> QThemeIconEntries;
+
+class QIconLoaderEngine : public QIconEngineV2
+{
+public:
+ QIconLoaderEngine(const QString& iconName = QString());
+ ~QIconLoaderEngine();
+
+ void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state);
+ QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
+ QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state);
+ QIconEngineV2 *clone() const;
+ bool read(QDataStream &in);
+ bool write(QDataStream &out) const;
+
+private:
+ QString key() const;
+ bool hasIcon() const;
+ void ensureLoaded();
+ void virtual_hook(int id, void *data);
+ QIconLoaderEngineEntry *entryForSize(const QSize &size);
+ QIconLoaderEngine(const QIconLoaderEngine &other);
+ QThemeIconEntries m_entries;
+ QString m_iconName;
+ uint m_key;
+
+ friend class QIconLoader;
+};
+
+class QIconTheme
+{
+public:
+ QIconTheme(const QString &name);
+ QIconTheme() : m_valid(false) {}
+ QStringList parents() { return m_parents; }
+ QList <QIconDirInfo> keyList() { return m_keyList; }
+ QString contentDir() { return m_contentDir; }
+ bool isValid() { return m_valid; }
+
+private:
+ QString m_contentDir;
+ QList <QIconDirInfo> m_keyList;
+ QStringList m_parents;
+ bool m_valid;
+};
+
+class QIconLoader : public QObject
+{
+public:
+ QIconLoader();
+ QThemeIconEntries loadIcon(const QString &iconName) const;
+ uint themeKey() const { return m_themeKey; }
+
+ QString themeName() const { return m_userTheme.isEmpty() ? m_systemTheme : m_userTheme; }
+ void setThemeName(const QString &themeName);
+ QIconTheme theme() { return themeList.value(themeName()); }
+ void setThemeSearchPath(const QStringList &searchPaths);
+ QStringList themeSearchPaths() const;
+ QIconDirInfo dirInfo(int dirindex);
+ static QIconLoader *instance();
+ void updateSystemTheme();
+ void invalidateKey() { m_themeKey++; }
+ void ensureInitialized();
+
+private:
+ QThemeIconEntries findIconHelper(const QString &themeName,
+ const QString &iconName,
+ QStringList &visited) const;
+ uint m_themeKey;
+ bool m_supportsSvg;
+ bool m_initialized;
+
+ mutable QString m_userTheme;
+ mutable QString m_systemTheme;
+ mutable QStringList m_iconDirs;
+ mutable QHash <QString, QIconTheme> themeList;
+};
+
+QT_END_NAMESPACE
+
+#endif // QDESKTOPICON_P_H
+
+#endif //QT_NO_ICON
diff --git a/src/gui/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp
index e014ec855f..e014ec855f 100644
--- a/src/gui/kernel/qlayout.cpp
+++ b/src/widgets/kernel/qlayout.cpp
diff --git a/src/widgets/kernel/qlayout.h b/src/widgets/kernel/qlayout.h
new file mode 100644
index 0000000000..aca1748f99
--- /dev/null
+++ b/src/widgets/kernel/qlayout.h
@@ -0,0 +1,245 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLAYOUT_H
+#define QLAYOUT_H
+
+#include <QtCore/qobject.h>
+#include <QtWidgets/qlayoutitem.h>
+#include <QtWidgets/qsizepolicy.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qmargins.h>
+
+#include <limits.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QLayout;
+class QSize;
+
+#ifdef QT3_SUPPORT
+class Q_GUI_EXPORT QLayoutIterator
+{
+public:
+ inline QT3_SUPPORT_CONSTRUCTOR QLayoutIterator(QLayout *i) : layout(i), index(0) {}
+ inline QLayoutIterator(const QLayoutIterator &i)
+ : layout(i.layout), index(i.index) {}
+ inline QLayoutIterator &operator=(const QLayoutIterator &i) {
+ layout = i.layout;
+ index = i.index;
+ return *this;
+ }
+ inline QT3_SUPPORT QLayoutItem *operator++();
+ inline QT3_SUPPORT QLayoutItem *current();
+ inline QT3_SUPPORT QLayoutItem *takeCurrent();
+ inline QT3_SUPPORT void deleteCurrent();
+
+private:
+ // hack to avoid deprecated warning
+ friend class QLayout;
+ inline QLayoutIterator(QLayout *i, bool) : layout(i), index(0) {}
+ QLayout *layout;
+ int index;
+};
+#endif
+
+class QLayoutPrivate;
+
+class Q_GUI_EXPORT QLayout : public QObject, public QLayoutItem
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QLayout)
+
+ Q_ENUMS(SizeConstraint)
+ Q_PROPERTY(int margin READ margin WRITE setMargin)
+ Q_PROPERTY(int spacing READ spacing WRITE setSpacing)
+ Q_PROPERTY(SizeConstraint sizeConstraint READ sizeConstraint WRITE setSizeConstraint)
+public:
+ enum SizeConstraint {
+ SetDefaultConstraint,
+ SetNoConstraint,
+ SetMinimumSize,
+ SetFixedSize,
+ SetMaximumSize,
+ SetMinAndMaxSize
+#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
+ , Auto = SetDefaultConstraint,
+ FreeResize = SetNoConstraint,
+ Minimum = SetMinimumSize,
+ Fixed = SetFixedSize
+#endif
+ };
+
+ QLayout(QWidget *parent);
+ QLayout();
+ ~QLayout();
+
+ int margin() const;
+ int spacing() const;
+
+ void setMargin(int);
+ void setSpacing(int);
+
+ void setContentsMargins(int left, int top, int right, int bottom);
+ void setContentsMargins(const QMargins &margins);
+ void getContentsMargins(int *left, int *top, int *right, int *bottom) const;
+ QMargins contentsMargins() const;
+ QRect contentsRect() const;
+
+ bool setAlignment(QWidget *w, Qt::Alignment alignment);
+ bool setAlignment(QLayout *l, Qt::Alignment alignment);
+#ifdef Q_NO_USING_KEYWORD
+ inline void setAlignment(Qt::Alignment alignment) { QLayoutItem::setAlignment(alignment); }
+#else
+ using QLayoutItem::setAlignment;
+#endif
+
+ void setSizeConstraint(SizeConstraint);
+ SizeConstraint sizeConstraint() const;
+#ifdef QT3_SUPPORT
+ inline QT3_SUPPORT void setResizeMode(SizeConstraint s) {setSizeConstraint(s);}
+ inline QT3_SUPPORT SizeConstraint resizeMode() const {return sizeConstraint();}
+#endif
+ void setMenuBar(QWidget *w);
+ QWidget *menuBar() const;
+
+ QWidget *parentWidget() const;
+
+ void invalidate();
+ QRect geometry() const;
+ bool activate();
+ void update();
+
+ void addWidget(QWidget *w);
+ virtual void addItem(QLayoutItem *) = 0;
+
+ void removeWidget(QWidget *w);
+ void removeItem(QLayoutItem *);
+
+ Qt::Orientations expandingDirections() const;
+ QSize minimumSize() const;
+ QSize maximumSize() const;
+ virtual void setGeometry(const QRect&);
+ virtual QLayoutItem *itemAt(int index) const = 0;
+ virtual QLayoutItem *takeAt(int index) = 0;
+ virtual int indexOf(QWidget *) const;
+ virtual int count() const = 0;
+ bool isEmpty() const;
+
+ int totalHeightForWidth(int w) const;
+ QSize totalMinimumSize() const;
+ QSize totalMaximumSize() const;
+ QSize totalSizeHint() const;
+ QLayout *layout();
+
+ void setEnabled(bool);
+ bool isEnabled() const;
+
+#ifdef QT3_SUPPORT
+ QT3_SUPPORT void freeze(int w=0, int h=0);
+ QT3_SUPPORT bool isTopLevel() const;
+#endif
+
+ static QSize closestAcceptableSize(const QWidget *w, const QSize &s);
+
+protected:
+ void widgetEvent(QEvent *);
+ void childEvent(QChildEvent *e);
+ void addChildLayout(QLayout *l);
+ void addChildWidget(QWidget *w);
+#ifdef QT3_SUPPORT
+ QT3_SUPPORT void deleteAllItems();
+#endif
+
+ QRect alignmentRect(const QRect&) const;
+protected:
+ QLayout(QLayoutPrivate &d, QLayout*, QWidget*);
+
+private:
+ Q_DISABLE_COPY(QLayout)
+
+ static void activateRecursiveHelper(QLayoutItem *item);
+
+ friend class QApplicationPrivate;
+ friend class QWidget;
+
+#ifdef QT3_SUPPORT
+public:
+ QT3_SUPPORT_CONSTRUCTOR QLayout(QWidget *parent, int margin, int spacing = -1,
+ const char *name = 0);
+ QT3_SUPPORT_CONSTRUCTOR QLayout(QLayout *parentLayout, int spacing = -1, const char *name = 0);
+ QT3_SUPPORT_CONSTRUCTOR QLayout(int spacing, const char *name = 0);
+ inline QT3_SUPPORT QWidget *mainWidget() const { return parentWidget(); }
+ inline QT3_SUPPORT void remove(QWidget *w) { removeWidget(w); }
+ inline QT3_SUPPORT void add(QWidget *w) { addWidget(w); }
+
+ QT3_SUPPORT void setAutoAdd(bool a);
+ QT3_SUPPORT bool autoAdd() const;
+ inline QT3_SUPPORT QLayoutIterator iterator() { return QLayoutIterator(this,true); }
+
+ inline QT3_SUPPORT int defaultBorder() const { return spacing(); }
+#endif
+};
+
+#ifdef QT3_SUPPORT
+inline QLayoutItem *QLayoutIterator::operator++() { return layout->itemAt(++index); }
+inline QLayoutItem *QLayoutIterator::current() { return layout->itemAt(index); }
+inline QLayoutItem *QLayoutIterator::takeCurrent() { return layout->takeAt(index); }
+inline void QLayoutIterator::deleteCurrent() { delete layout->takeAt(index); }
+#endif
+
+//### support old includes
+#if 1 //def QT3_SUPPORT
+QT_BEGIN_INCLUDE_NAMESPACE
+#include <QtWidgets/qboxlayout.h>
+#include <QtWidgets/qgridlayout.h>
+QT_END_INCLUDE_NAMESPACE
+#endif
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QLAYOUT_H
diff --git a/src/gui/kernel/qlayout_p.h b/src/widgets/kernel/qlayout_p.h
index 342333954c..342333954c 100644
--- a/src/gui/kernel/qlayout_p.h
+++ b/src/widgets/kernel/qlayout_p.h
diff --git a/src/gui/kernel/qlayoutengine.cpp b/src/widgets/kernel/qlayoutengine.cpp
index fdabd8ae1f..fdabd8ae1f 100644
--- a/src/gui/kernel/qlayoutengine.cpp
+++ b/src/widgets/kernel/qlayoutengine.cpp
diff --git a/src/widgets/kernel/qlayoutengine_p.h b/src/widgets/kernel/qlayoutengine_p.h
new file mode 100644
index 0000000000..eede314348
--- /dev/null
+++ b/src/widgets/kernel/qlayoutengine_p.h
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLAYOUTENGINE_P_H
+#define QLAYOUTENGINE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "QtWidgets/qlayoutitem.h"
+#include "QtWidgets/qstyle.h"
+
+QT_BEGIN_NAMESPACE
+
+template <typename T> class QVector;
+
+struct QLayoutStruct
+{
+ inline void init(int stretchFactor = 0, int minSize = 0) {
+ stretch = stretchFactor;
+ minimumSize = sizeHint = minSize;
+ maximumSize = QLAYOUTSIZE_MAX;
+ expansive = false;
+ empty = true;
+ spacing = 0;
+ }
+
+ int smartSizeHint() {
+ return (stretch > 0) ? minimumSize : sizeHint;
+ }
+ int effectiveSpacer(int uniformSpacer) const {
+ Q_ASSERT(uniformSpacer >= 0 || spacing >= 0);
+ return (uniformSpacer >= 0) ? uniformSpacer : spacing;
+ }
+
+ // parameters
+ int stretch;
+ int sizeHint;
+ int maximumSize;
+ int minimumSize;
+ bool expansive;
+ bool empty;
+ int spacing;
+
+ // temporary storage
+ bool done;
+
+ // result
+ int pos;
+ int size;
+};
+
+
+Q_GUI_EXPORT void qGeomCalc(QVector<QLayoutStruct> &chain, int start, int count,
+ int pos, int space, int spacer = -1);
+Q_GUI_EXPORT QSize qSmartMinSize(const QSize &sizeHint, const QSize &minSizeHint,
+ const QSize &minSize, const QSize &maxSize,
+ const QSizePolicy &sizePolicy);
+Q_GUI_EXPORT QSize qSmartMinSize(const QWidgetItem *i);
+Q_GUI_EXPORT QSize qSmartMinSize(const QWidget *w);
+Q_GUI_EXPORT QSize qSmartMaxSize(const QSize &sizeHint,
+ const QSize &minSize, const QSize &maxSize,
+ const QSizePolicy &sizePolicy, Qt::Alignment align = 0);
+Q_GUI_EXPORT QSize qSmartMaxSize(const QWidgetItem *i, Qt::Alignment align = 0);
+Q_GUI_EXPORT QSize qSmartMaxSize(const QWidget *w, Qt::Alignment align = 0);
+
+Q_GUI_EXPORT int qSmartSpacing(const QLayout *layout, QStyle::PixelMetric pm);
+
+/*
+ Modify total maximum (max), total expansion (exp), and total empty
+ when adding boxmax/boxexp.
+
+ Expansive boxes win over non-expansive boxes.
+ Non-empty boxes win over empty boxes.
+*/
+static inline void qMaxExpCalc(int & max, bool &exp, bool &empty,
+ int boxmax, bool boxexp, bool boxempty)
+{
+ if (exp) {
+ if (boxexp)
+ max = qMax(max, boxmax);
+ } else {
+ if (boxexp || (empty && (!boxempty || max == 0)))
+ max = boxmax;
+ else if (empty == boxempty)
+ max = qMin(max, boxmax);
+ }
+ exp = exp || boxexp;
+ empty = empty && boxempty;
+}
+
+QT_END_NAMESPACE
+
+#endif // QLAYOUTENGINE_P_H
diff --git a/src/gui/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp
index aeb96e9ef5..aeb96e9ef5 100644
--- a/src/gui/kernel/qlayoutitem.cpp
+++ b/src/widgets/kernel/qlayoutitem.cpp
diff --git a/src/widgets/kernel/qlayoutitem.h b/src/widgets/kernel/qlayoutitem.h
new file mode 100644
index 0000000000..52878b2c8b
--- /dev/null
+++ b/src/widgets/kernel/qlayoutitem.h
@@ -0,0 +1,182 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLAYOUTITEM_H
+#define QLAYOUTITEM_H
+
+#include <QtWidgets/qsizepolicy.h>
+#include <QtCore/qrect.h>
+
+#include <limits.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+static const int QLAYOUTSIZE_MAX = INT_MAX/256/16;
+
+class QLayout;
+class QLayoutItem;
+class QSpacerItem;
+class QWidget;
+class QSize;
+
+class Q_GUI_EXPORT QLayoutItem
+{
+public:
+ inline explicit QLayoutItem(Qt::Alignment alignment = 0);
+ virtual ~QLayoutItem();
+ virtual QSize sizeHint() const = 0;
+ virtual QSize minimumSize() const = 0;
+ virtual QSize maximumSize() const = 0;
+ virtual Qt::Orientations expandingDirections() const = 0;
+ virtual void setGeometry(const QRect&) = 0;
+ virtual QRect geometry() const = 0;
+ virtual bool isEmpty() const = 0;
+ virtual bool hasHeightForWidth() const;
+ virtual int heightForWidth(int) const;
+ virtual int minimumHeightForWidth(int) const;
+ virtual void invalidate();
+
+ virtual QWidget *widget();
+ virtual QLayout *layout();
+ virtual QSpacerItem *spacerItem();
+
+ Qt::Alignment alignment() const { return align; }
+ void setAlignment(Qt::Alignment a);
+ QSizePolicy::ControlTypes controlTypes() const;
+
+protected:
+ Qt::Alignment align;
+};
+
+inline QLayoutItem::QLayoutItem(Qt::Alignment aalignment)
+ : align(aalignment) { }
+
+class Q_GUI_EXPORT QSpacerItem : public QLayoutItem
+{
+public:
+ QSpacerItem(int w, int h,
+ QSizePolicy::Policy hData = QSizePolicy::Minimum,
+ QSizePolicy::Policy vData = QSizePolicy::Minimum)
+ : width(w), height(h), sizeP(hData, vData) { }
+ void changeSize(int w, int h,
+ QSizePolicy::Policy hData = QSizePolicy::Minimum,
+ QSizePolicy::Policy vData = QSizePolicy::Minimum);
+ QSize sizeHint() const;
+ QSize minimumSize() const;
+ QSize maximumSize() const;
+ Qt::Orientations expandingDirections() const;
+ bool isEmpty() const;
+ void setGeometry(const QRect&);
+ QRect geometry() const;
+ QSpacerItem *spacerItem();
+
+private:
+ int width;
+ int height;
+ QSizePolicy sizeP;
+ QRect rect;
+};
+
+class Q_GUI_EXPORT QWidgetItem : public QLayoutItem
+{
+ Q_DISABLE_COPY(QWidgetItem)
+
+public:
+ explicit QWidgetItem(QWidget *w) : wid(w) { }
+ QSize sizeHint() const;
+ QSize minimumSize() const;
+ QSize maximumSize() const;
+ Qt::Orientations expandingDirections() const;
+ bool isEmpty() const;
+ void setGeometry(const QRect&);
+ QRect geometry() const;
+ virtual QWidget *widget();
+
+ bool hasHeightForWidth() const;
+ int heightForWidth(int) const;
+
+protected:
+ QWidget *wid;
+};
+
+class Q_GUI_EXPORT QWidgetItemV2 : public QWidgetItem
+{
+public:
+ explicit QWidgetItemV2(QWidget *widget);
+ ~QWidgetItemV2();
+
+ QSize sizeHint() const;
+ QSize minimumSize() const;
+ QSize maximumSize() const;
+ int heightForWidth(int width) const;
+
+private:
+ enum { Dirty = -123, HfwCacheMaxSize = 3 };
+
+ inline bool useSizeCache() const;
+ void updateCacheIfNecessary() const;
+ inline void invalidateSizeCache() {
+ q_cachedMinimumSize.setWidth(Dirty);
+ q_hfwCacheSize = 0;
+ }
+
+ mutable QSize q_cachedMinimumSize;
+ mutable QSize q_cachedSizeHint;
+ mutable QSize q_cachedMaximumSize;
+ mutable QSize q_cachedHfws[HfwCacheMaxSize];
+ mutable short q_firstCachedHfw;
+ mutable short q_hfwCacheSize;
+ void *d;
+
+ friend class QWidgetPrivate;
+
+ Q_DISABLE_COPY(QWidgetItemV2)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QLAYOUTITEM_H
diff --git a/src/gui/kernel/qsizepolicy.h b/src/widgets/kernel/qsizepolicy.h
index c0a8cc1f18..c0a8cc1f18 100644
--- a/src/gui/kernel/qsizepolicy.h
+++ b/src/widgets/kernel/qsizepolicy.h
diff --git a/src/gui/kernel/qsizepolicy.qdoc b/src/widgets/kernel/qsizepolicy.qdoc
index 80e9f20f74..80e9f20f74 100644
--- a/src/gui/kernel/qsizepolicy.qdoc
+++ b/src/widgets/kernel/qsizepolicy.qdoc
diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/widgets/kernel/qsoftkeymanager.cpp
index 204efe9ee9..204efe9ee9 100644
--- a/src/gui/kernel/qsoftkeymanager.cpp
+++ b/src/widgets/kernel/qsoftkeymanager.cpp
diff --git a/src/gui/kernel/qsoftkeymanager_common_p.h b/src/widgets/kernel/qsoftkeymanager_common_p.h
index 02ae697eef..02ae697eef 100644
--- a/src/gui/kernel/qsoftkeymanager_common_p.h
+++ b/src/widgets/kernel/qsoftkeymanager_common_p.h
diff --git a/src/widgets/kernel/qsoftkeymanager_p.h b/src/widgets/kernel/qsoftkeymanager_p.h
new file mode 100644
index 0000000000..726c8f7211
--- /dev/null
+++ b/src/widgets/kernel/qsoftkeymanager_p.h
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSOFTKEYMANAGER_P_H
+#define QSOFTKEYMANAGER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qobject.h>
+#include "QtWidgets/qaction.h"
+
+QT_BEGIN_HEADER
+
+#ifndef QT_NO_SOFTKEYMANAGER
+QT_BEGIN_NAMESPACE
+
+class QSoftKeyManagerPrivate;
+
+class Q_AUTOTEST_EXPORT QSoftKeyManager : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QSoftKeyManager)
+
+public:
+
+ enum StandardSoftKey {
+ OkSoftKey,
+ SelectSoftKey,
+ DoneSoftKey,
+ MenuSoftKey,
+ CancelSoftKey
+ };
+
+ static void updateSoftKeys();
+#ifdef Q_WS_S60
+ static bool handleCommand(int);
+#endif
+
+ static QAction *createAction(StandardSoftKey standardKey, QWidget *actionWidget);
+ static QAction *createKeyedAction(StandardSoftKey standardKey, Qt::Key key, QWidget *actionWidget);
+ static QString standardSoftKeyText(StandardSoftKey standardKey);
+ static void setForceEnabledInSoftkeys(QAction *action);
+ static bool isForceEnabledInSofkeys(QAction *action);
+
+protected:
+ bool event(QEvent *e);
+
+private:
+ QSoftKeyManager();
+ static QSoftKeyManager *instance();
+ bool appendSoftkeys(const QWidget &source, int level);
+ QWidget *softkeySource(QWidget *previousSource, bool& recursiveMerging);
+ bool handleUpdateSoftKeys();
+
+private Q_SLOTS:
+ void cleanupHash(QObject* obj);
+ void sendKeyEvent();
+
+private:
+ Q_DISABLE_COPY(QSoftKeyManager)
+};
+
+QT_END_NAMESPACE
+#endif //QT_NO_SOFTKEYMANAGER
+
+QT_END_HEADER
+
+#endif //QSOFTKEYMANAGER_P_H
diff --git a/src/widgets/kernel/qsound.cpp b/src/widgets/kernel/qsound.cpp
new file mode 100644
index 0000000000..55a98758c3
--- /dev/null
+++ b/src/widgets/kernel/qsound.cpp
@@ -0,0 +1,367 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsound.h"
+
+#ifndef QT_NO_SOUND
+
+#include "qlist.h"
+#include <private/qobject_p.h>
+#include "qsound_p.h"
+
+QT_BEGIN_NAMESPACE
+
+static QList<QAuServer*> *servers=0;
+
+QAuServer::QAuServer(QObject* parent)
+ : QObject(parent)
+{
+ if (!servers)
+ servers = new QList<QAuServer*>;
+ servers->prepend(this);
+}
+
+QAuServer::~QAuServer()
+{
+ servers->removeAll(this);
+ if (servers->count() == 0) {
+ delete servers;
+ servers = 0;
+ }
+}
+
+void QAuServer::play(const QString& filename)
+{
+ QSound s(filename);
+ play(&s);
+}
+
+extern QAuServer* qt_new_audio_server();
+
+static QAuServer& server()
+{
+ if (!servers) qt_new_audio_server();
+ return *servers->first();
+}
+
+class QSoundPrivate : public QObjectPrivate
+{
+public:
+ QSoundPrivate(const QString& fname)
+ : filename(fname), bucket(0), looprem(0), looptotal(1)
+ {
+ }
+
+ ~QSoundPrivate()
+ {
+ delete bucket;
+ }
+
+ QString filename;
+ QAuBucket* bucket;
+ int looprem;
+ int looptotal;
+};
+
+/*!
+ \class QSound
+ \brief The QSound class provides access to the platform audio facilities.
+
+ \ingroup multimedia
+
+
+ Qt provides the most commonly required audio operation in GUI
+ applications: asynchronously playing a sound file. This is most
+ easily accomplished using the static play() function:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qsound.cpp 0
+
+ Alternatively, create a QSound object from the sound file first
+ and then call the play() slot:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qsound.cpp 1
+
+ Once created a QSound object can be queried for its fileName() and
+ total number of loops() (i.e. the number of times the sound will
+ play). The number of repetitions can be altered using the
+ setLoops() function. While playing the sound, the loopsRemaining()
+ function returns the remaining number of repetitions. Use the
+ isFinished() function to determine whether the sound has finished
+ playing.
+
+ Sounds played using a QSound object may use more memory than the
+ static play() function, but it may also play more immediately
+ (depending on the underlying platform audio facilities). Use the
+ static isAvailable() function to determine whether sound
+ facilities exist on the platform. Which facilities that are
+ actually used varies:
+
+ \table
+ \header \o Platform \o Audio Facility
+ \row
+ \o Microsoft Windows
+ \o The underlying multimedia system is used; only WAVE format sound files
+ are supported.
+ \row
+ \o X11
+ \o The \l{ftp://ftp.x.org/contrib/audio/nas/}{Network Audio System}
+ is used if available, otherwise all operations work silently. NAS
+ supports WAVE and AU files.
+ \row
+ \o Mac OS X
+ \o NSSound is used. All formats that NSSound supports, including QuickTime formats,
+ are supported by Qt for Mac OS X.
+ \row
+ \o Qt for Embedded Linux
+ \o A built-in mixing sound server is used, accessing \c /dev/dsp
+ directly. Only the WAVE format is supported.
+ \row
+ \o Symbian
+ \o CMdaAudioPlayerUtility is used. All formats that Symbian OS or devices support
+ are supported also by Qt.
+ \endtable
+
+ Note that QSound does not support \l{resources.html}{resources}.
+ This might be fixed in a future Qt version.
+*/
+
+/*!
+ Plays the sound stored in the file specified by the given \a filename.
+
+ \sa stop(), loopsRemaining(), isFinished()
+*/
+void QSound::play(const QString& filename)
+{
+ server().play(filename);
+}
+
+/*!
+ Constructs a QSound object from the file specified by the given \a
+ filename and with the given \a parent.
+
+ This may use more memory than the static play() function, but it
+ may also play more immediately (depending on the underlying
+ platform audio facilities).
+
+ \sa play()
+*/
+QSound::QSound(const QString& filename, QObject* parent)
+ : QObject(*new QSoundPrivate(filename), parent)
+{
+ server().init(this);
+}
+
+/*!
+ Destroys this sound object. If the sound is not finished playing,
+ the stop() function is called before the sound object is
+ destructed.
+
+ \sa stop(), isFinished()
+*/
+QSound::~QSound()
+{
+ if (!isFinished())
+ stop();
+}
+
+/*!
+ Returns true if the sound has finished playing; otherwise returns false.
+
+ \warning On Windows this function always returns true for unlooped sounds.
+*/
+bool QSound::isFinished() const
+{
+ Q_D(const QSound);
+ return d->looprem == 0;
+}
+
+/*!
+ \overload
+
+ Starts playing the sound specified by this QSound object.
+
+ The function returns immediately. Depending on the platform audio
+ facilities, other sounds may stop or be mixed with the new
+ sound. The sound can be played again at any time, possibly mixing
+ or replacing previous plays of the sound.
+
+ \sa fileName()
+*/
+void QSound::play()
+{
+ Q_D(QSound);
+ d->looprem = d->looptotal;
+ server().play(this);
+}
+
+/*!
+ Returns the number of times the sound will play.
+
+ \sa loopsRemaining(), setLoops()
+*/
+int QSound::loops() const
+{
+ Q_D(const QSound);
+ return d->looptotal;
+}
+
+/*!
+ Returns the remaining number of times the sound will loop (this
+ value decreases each time the sound is played).
+
+ \sa loops(), isFinished()
+*/
+int QSound::loopsRemaining() const
+{
+ Q_D(const QSound);
+ return d->looprem;
+}
+
+/*!
+ \fn void QSound::setLoops(int number)
+
+ Sets the sound to repeat the given \a number of times when it is
+ played.
+
+ Note that passing the value -1 will cause the sound to loop
+ indefinitely.
+
+ \sa loops()
+*/
+void QSound::setLoops(int n)
+{
+ Q_D(QSound);
+ d->looptotal = n;
+}
+
+/*!
+ Returns the filename associated with this QSound object.
+
+ \sa QSound()
+*/
+QString QSound::fileName() const
+{
+ Q_D(const QSound);
+ return d->filename;
+}
+
+/*!
+ Stops the sound playing.
+
+ Note that on Windows the current loop will finish if a sound is
+ played in a loop.
+
+ \sa play()
+*/
+void QSound::stop()
+{
+ Q_D(QSound);
+ server().stop(this);
+ d->looprem = 0;
+}
+
+
+/*!
+ Returns true if sound facilities exist on the platform; otherwise
+ returns false.
+
+ If no sound is available, all QSound operations work silently and
+ quickly. An application may choose either to notify the user if
+ sound is crucial to the application or to operate silently without
+ bothering the user.
+
+ Note: On Windows this always returns true because some sound card
+ drivers do not implement a way to find out whether it is available
+ or not.
+*/
+bool QSound::isAvailable()
+{
+ return server().okay();
+}
+
+/*!
+ Sets the internal bucket record of sound \a s to \a b, deleting
+ any previous setting.
+*/
+void QAuServer::setBucket(QSound* s, QAuBucket* b)
+{
+ delete s->d_func()->bucket;
+ s->d_func()->bucket = b;
+}
+
+/*!
+ Returns the internal bucket record of sound \a s.
+*/
+QAuBucket* QAuServer::bucket(QSound* s)
+{
+ return s->d_func()->bucket;
+}
+
+/*!
+ Decrements the QSound::loopRemaining() value for sound \a s,
+ returning the result.
+*/
+int QAuServer::decLoop(QSound* s)
+{
+ if (s->d_func()->looprem > 0)
+ --s->d_func()->looprem;
+ return s->d_func()->looprem;
+}
+
+/*!
+ Initializes the sound. The default implementation does nothing.
+*/
+void QAuServer::init(QSound*)
+{
+}
+
+QAuBucket::~QAuBucket()
+{
+}
+/*!
+ \fn bool QSound::available()
+
+ Use the isAvailable() function instead.
+*/
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_SOUND
diff --git a/src/widgets/kernel/qsound.h b/src/widgets/kernel/qsound.h
new file mode 100644
index 0000000000..a0d058011a
--- /dev/null
+++ b/src/widgets/kernel/qsound.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSOUND_H
+#define QSOUND_H
+
+#include <QtCore/qobject.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_SOUND
+
+class QSoundPrivate;
+
+class Q_GUI_EXPORT QSound : public QObject
+{
+ Q_OBJECT
+
+public:
+ static bool isAvailable();
+ static void play(const QString& filename);
+
+ explicit QSound(const QString& filename, QObject* parent = 0);
+ ~QSound();
+
+ int loops() const;
+ int loopsRemaining() const;
+ void setLoops(int);
+ QString fileName() const;
+
+ bool isFinished() const;
+
+public Q_SLOTS:
+ void play();
+ void stop();
+
+private:
+ Q_DECLARE_PRIVATE(QSound)
+ friend class QAuServer;
+};
+
+#endif // QT_NO_SOUND
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QSOUND_H
diff --git a/src/gui/kernel/qsound_p.h b/src/widgets/kernel/qsound_p.h
index dfdbfff063..dfdbfff063 100644
--- a/src/gui/kernel/qsound_p.h
+++ b/src/widgets/kernel/qsound_p.h
diff --git a/src/gui/kernel/qstackedlayout.cpp b/src/widgets/kernel/qstackedlayout.cpp
index c5ce238958..c5ce238958 100644
--- a/src/gui/kernel/qstackedlayout.cpp
+++ b/src/widgets/kernel/qstackedlayout.cpp
diff --git a/src/widgets/kernel/qstackedlayout.h b/src/widgets/kernel/qstackedlayout.h
new file mode 100644
index 0000000000..b666b0c933
--- /dev/null
+++ b/src/widgets/kernel/qstackedlayout.h
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSTACKEDLAYOUT_H
+#define QSTACKEDLAYOUT_H
+
+#include <QtWidgets/qlayout.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QStackedLayoutPrivate;
+
+class Q_GUI_EXPORT QStackedLayout : public QLayout
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QStackedLayout)
+ Q_ENUMS(StackingMode)
+ Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
+ Q_PROPERTY(StackingMode stackingMode READ stackingMode WRITE setStackingMode)
+ QDOC_PROPERTY(int count READ count)
+
+public:
+ enum StackingMode {
+ StackOne,
+ StackAll
+ };
+
+ QStackedLayout();
+ explicit QStackedLayout(QWidget *parent);
+ explicit QStackedLayout(QLayout *parentLayout);
+ ~QStackedLayout();
+
+ int addWidget(QWidget *w);
+ int insertWidget(int index, QWidget *w);
+
+ QWidget *currentWidget() const;
+ int currentIndex() const;
+#ifdef Q_NO_USING_KEYWORD
+ inline QWidget *widget() { return QLayout::widget(); }
+#else
+ using QLayout::widget;
+#endif
+ QWidget *widget(int) const;
+ int count() const;
+
+ StackingMode stackingMode() const;
+ void setStackingMode(StackingMode stackingMode);
+
+ // abstract virtual functions:
+ void addItem(QLayoutItem *item);
+ QSize sizeHint() const;
+ QSize minimumSize() const;
+ QLayoutItem *itemAt(int) const;
+ QLayoutItem *takeAt(int);
+ void setGeometry(const QRect &rect);
+
+Q_SIGNALS:
+ void widgetRemoved(int index);
+ void currentChanged(int index);
+
+public Q_SLOTS:
+ void setCurrentIndex(int index);
+ void setCurrentWidget(QWidget *w);
+
+private:
+ Q_DISABLE_COPY(QStackedLayout)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QSTACKEDLAYOUT_H
diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/widgets/kernel/qstandardgestures.cpp
index 6338ef7afb..6338ef7afb 100644
--- a/src/gui/kernel/qstandardgestures.cpp
+++ b/src/widgets/kernel/qstandardgestures.cpp
diff --git a/src/gui/kernel/qstandardgestures_p.h b/src/widgets/kernel/qstandardgestures_p.h
index b3c5002565..b3c5002565 100644
--- a/src/gui/kernel/qstandardgestures_p.h
+++ b/src/widgets/kernel/qstandardgestures_p.h
diff --git a/src/gui/kernel/qt_gui_pch.h b/src/widgets/kernel/qt_gui_pch.h
index 368c12d444..368c12d444 100644
--- a/src/gui/kernel/qt_gui_pch.h
+++ b/src/widgets/kernel/qt_gui_pch.h
diff --git a/src/gui/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp
index 4311df58a6..4311df58a6 100644
--- a/src/gui/kernel/qtooltip.cpp
+++ b/src/widgets/kernel/qtooltip.cpp
diff --git a/src/widgets/kernel/qtooltip.h b/src/widgets/kernel/qtooltip.h
new file mode 100644
index 0000000000..076ab0f197
--- /dev/null
+++ b/src/widgets/kernel/qtooltip.h
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTOOLTIP_H
+#define QTOOLTIP_H
+
+#include <QtWidgets/qwidget.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_TOOLTIP
+
+class Q_GUI_EXPORT QToolTip
+{
+ QToolTip();
+public:
+ static void showText(const QPoint &pos, const QString &text, QWidget *w = 0);
+ static void showText(const QPoint &pos, const QString &text, QWidget *w, const QRect &rect);
+ static inline void hideText() { showText(QPoint(), QString()); }
+
+ static bool isVisible();
+ static QString text();
+
+ static QPalette palette();
+ static void setPalette(const QPalette &);
+ static QFont font();
+ static void setFont(const QFont &);
+#ifdef QT3_SUPPORT
+ static inline QT3_SUPPORT void add(QWidget *w, const QString &s) { w->setToolTip(s); }
+ static inline QT3_SUPPORT void add(QWidget *w, const QRect &, const QString &s)
+ { w->setToolTip(s); }
+ static inline QT3_SUPPORT void remove(QWidget *w) { w->setToolTip(QString()); }
+#endif
+};
+
+#endif // QT_NO_TOOLTIP
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QTOOLTIP_H
diff --git a/src/widgets/kernel/qwhatsthis.cpp b/src/widgets/kernel/qwhatsthis.cpp
new file mode 100644
index 0000000000..908668e1c6
--- /dev/null
+++ b/src/widgets/kernel/qwhatsthis.cpp
@@ -0,0 +1,777 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwhatsthis.h"
+#ifndef QT_NO_WHATSTHIS
+#include "qpointer.h"
+#include "qapplication.h"
+#include "qdesktopwidget.h"
+#include "qevent.h"
+#include "qpixmap.h"
+#include "qpainter.h"
+#include "qtimer.h"
+#include "qhash.h"
+#include "qaction.h"
+#include "qcursor.h"
+#include "qbitmap.h"
+#include "qtextdocument.h"
+#include "private/qtextdocumentlayout_p.h"
+#include "qtoolbutton.h"
+#include "qdebug.h"
+#ifndef QT_NO_ACCESSIBILITY
+#include "qaccessible.h"
+#endif
+#if defined(Q_WS_WIN)
+#include "qt_windows.h"
+#ifndef SPI_GETDROPSHADOW
+#define SPI_GETDROPSHADOW 0x1024
+#endif
+#endif
+#if defined(Q_WS_X11)
+#include "qx11info_x11.h"
+#include <qwidget.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QWhatsThis
+ \brief The QWhatsThis class provides a simple description of any
+ widget, i.e. answering the question "What's This?".
+
+ \ingroup helpsystem
+
+
+ "What's This?" help is part of an application's online help
+ system, and provides users with information about the
+ functionality and usage of a particular widget. "What's This?"
+ help texts are typically longer and more detailed than \link
+ QToolTip tooltips\endlink, but generally provide less information
+ than that supplied by separate help windows.
+
+ QWhatsThis provides a single window with an explanatory text that
+ pops up when the user asks "What's This?". The default way for
+ users to ask the question is to move the focus to the relevant
+ widget and press Shift+F1. The help text appears immediately; it
+ goes away as soon as the user does something else.
+ (Note that if there is a shortcut for Shift+F1, this mechanism
+ will not work.) Some dialogs provide a "?" button that users can
+ click to enter "What's This?" mode; they then click the relevant
+ widget to pop up the "What's This?" window. It is also possible to
+ provide a a menu option or toolbar button to switch into "What's
+ This?" mode.
+
+ To add "What's This?" text to a widget or an action, you simply
+ call QWidget::setWhatsThis() or QAction::setWhatsThis().
+
+ The text can be either rich text or plain text. If you specify a
+ rich text formatted string, it will be rendered using the default
+ stylesheet, making it possible to embed images in the displayed
+ text. To be as fast as possible, the default stylesheet uses a
+ simple method to determine whether the text can be rendered as
+ plain text. See Qt::mightBeRichText() for details.
+
+ \snippet doc/src/snippets/whatsthis/whatsthis.cpp 0
+
+ An alternative way to enter "What's This?" mode is to call
+ createAction(), and add the returned QAction to either a menu or
+ a tool bar. By invoking this context help action (in the picture
+ below, the button with the arrow and question mark icon) the user
+ switches into "What's This?" mode. If they now click on a widget
+ the appropriate help text is shown. The mode is left when help is
+ given or when the user presses Esc.
+
+ \img whatsthis.png
+
+ You can enter "What's This?" mode programmatically with
+ enterWhatsThisMode(), check the mode with inWhatsThisMode(), and
+ return to normal mode with leaveWhatsThisMode().
+
+ If you want to control the "What's This?" behavior of a widget
+ manually see Qt::WA_CustomWhatsThis.
+
+ It is also possible to show different help texts for different
+ regions of a widget, by using a QHelpEvent of type
+ QEvent::WhatsThis. Intercept the help event in your widget's
+ QWidget::event() function and call QWhatsThis::showText() with the
+ text you want to display for the position specified in
+ QHelpEvent::pos(). If the text is rich text and the user clicks
+ on a link, the widget also receives a QWhatsThisClickedEvent with
+ the link's reference as QWhatsThisClickedEvent::href(). If a
+ QWhatsThisClickedEvent is handled (i.e. QWidget::event() returns
+ true), the help window remains visible. Call
+ QWhatsThis::hideText() to hide it explicitly.
+
+ \sa QToolTip
+*/
+
+Q_CORE_EXPORT void qDeleteInEventHandler(QObject *o);
+
+class QWhatsThat : public QWidget
+{
+ Q_OBJECT
+
+public:
+ QWhatsThat(const QString& txt, QWidget* parent, QWidget *showTextFor);
+ ~QWhatsThat() ;
+
+ static QWhatsThat *instance;
+
+protected:
+ void showEvent(QShowEvent *e);
+ void mousePressEvent(QMouseEvent*);
+ void mouseReleaseEvent(QMouseEvent*);
+ void mouseMoveEvent(QMouseEvent*);
+ void keyPressEvent(QKeyEvent*);
+ void paintEvent(QPaintEvent*);
+
+private:
+ QPointer<QWidget>widget;
+ bool pressed;
+ QString text;
+ QTextDocument* doc;
+ QString anchor;
+ QPixmap background;
+};
+
+QWhatsThat *QWhatsThat::instance = 0;
+
+// shadowWidth not const, for XP drop-shadow-fu turns it to 0
+static int shadowWidth = 6; // also used as '5' and '6' and even '8' below
+static const int vMargin = 8;
+static const int hMargin = 12;
+
+QWhatsThat::QWhatsThat(const QString& txt, QWidget* parent, QWidget *showTextFor)
+ : QWidget(parent, Qt::Popup),
+ widget(showTextFor), pressed(false), text(txt)
+{
+ delete instance;
+ instance = this;
+ setAttribute(Qt::WA_DeleteOnClose, true);
+ setAttribute(Qt::WA_NoSystemBackground, true);
+ if (parent)
+ setPalette(parent->palette());
+ setMouseTracking(true);
+ setFocusPolicy(Qt::StrongFocus);
+#ifndef QT_NO_CURSOR
+ setCursor(Qt::ArrowCursor);
+#endif
+ QRect r;
+ doc = 0;
+ ensurePolished(); // Ensures style sheet font before size calc
+ if (Qt::mightBeRichText(text)) {
+ doc = new QTextDocument();
+ doc->setUndoRedoEnabled(false);
+ doc->setDefaultFont(QApplication::font(this));
+#ifdef QT_NO_TEXTHTMLPARSER
+ doc->setPlainText(text);
+#else
+ doc->setHtml(text);
+#endif
+ doc->setUndoRedoEnabled(false);
+ doc->adjustSize();
+ r.setTop(0);
+ r.setLeft(0);
+ r.setSize(doc->size().toSize());
+ }
+ else
+ {
+ int sw = QApplication::desktop()->width() / 3;
+ if (sw < 200)
+ sw = 200;
+ else if (sw > 300)
+ sw = 300;
+
+ r = fontMetrics().boundingRect(0, 0, sw, 1000,
+ Qt::AlignLeft + Qt::AlignTop
+ + Qt::TextWordWrap + Qt::TextExpandTabs,
+ text);
+ }
+#if defined(Q_WS_WIN)
+ if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP
+ && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based))
+ {
+ BOOL shadow;
+ SystemParametersInfo(SPI_GETDROPSHADOW, 0, &shadow, 0);
+ shadowWidth = shadow ? 0 : 6;
+ }
+#endif
+ resize(r.width() + 2*hMargin + shadowWidth, r.height() + 2*vMargin + shadowWidth);
+}
+
+QWhatsThat::~QWhatsThat()
+{
+ instance = 0;
+ if (doc)
+ delete doc;
+}
+
+void QWhatsThat::showEvent(QShowEvent *)
+{
+ background = QPixmap::grabWindow(QApplication::desktop()->internalWinId(),
+ x(), y(), width(), height());
+}
+
+void QWhatsThat::mousePressEvent(QMouseEvent* e)
+{
+ pressed = true;
+ if (e->button() == Qt::LeftButton && rect().contains(e->pos())) {
+ if (doc)
+ anchor = doc->documentLayout()->anchorAt(e->pos() - QPoint(hMargin, vMargin));
+ return;
+ }
+ close();
+}
+
+void QWhatsThat::mouseReleaseEvent(QMouseEvent* e)
+{
+ if (!pressed)
+ return;
+ if (widget && e->button() == Qt::LeftButton && doc && rect().contains(e->pos())) {
+ QString a = doc->documentLayout()->anchorAt(e->pos() - QPoint(hMargin, vMargin));
+ QString href;
+ if (anchor == a)
+ href = a;
+ anchor.clear();
+ if (!href.isEmpty()) {
+ QWhatsThisClickedEvent e(href);
+ if (QApplication::sendEvent(widget, &e))
+ return;
+ }
+ }
+ close();
+}
+
+void QWhatsThat::mouseMoveEvent(QMouseEvent* e)
+{
+#ifdef QT_NO_CURSOR
+ Q_UNUSED(e);
+#else
+ if (!doc)
+ return;
+ QString a = doc->documentLayout()->anchorAt(e->pos() - QPoint(hMargin, vMargin));
+ if (!a.isEmpty())
+ setCursor(Qt::PointingHandCursor);
+ else
+ setCursor(Qt::ArrowCursor);
+#endif
+}
+
+void QWhatsThat::keyPressEvent(QKeyEvent*)
+{
+ close();
+}
+
+void QWhatsThat::paintEvent(QPaintEvent*)
+{
+ bool drawShadow = true;
+#if defined(Q_WS_WIN)
+ if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP
+ && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based))
+ {
+ BOOL shadow;
+ SystemParametersInfo(SPI_GETDROPSHADOW, 0, &shadow, 0);
+ drawShadow = !shadow;
+ }
+#elif defined(Q_WS_MAC) || defined(Q_WS_QWS)
+ drawShadow = false; // never draw it on OS X or QWS, as we get it for free
+#endif
+
+ QRect r = rect();
+ r.adjust(0, 0, -1, -1);
+ if (drawShadow)
+ r.adjust(0, 0, -shadowWidth, -shadowWidth);
+ QPainter p(this);
+ p.drawPixmap(0, 0, background);
+ p.setPen(QPen(palette().toolTipText(), 0));
+ p.setBrush(palette().toolTipBase());
+ p.drawRect(r);
+ int w = r.width();
+ int h = r.height();
+ p.setPen(palette().brush(QPalette::Dark).color());
+ p.drawRect(1, 1, w-2, h-2);
+ if (drawShadow) {
+ p.setPen(palette().shadow().color());
+ p.drawPoint(w + 5, 6);
+ p.drawLine(w + 3, 6, w + 5, 8);
+ p.drawLine(w + 1, 6, w + 5, 10);
+ int i;
+ for(i=7; i < h; i += 2)
+ p.drawLine(w, i, w + 5, i + 5);
+ for(i = w - i + h; i > 6; i -= 2)
+ p.drawLine(i, h, i + 5, h + 5);
+ for(; i > 0 ; i -= 2)
+ p.drawLine(6, h + 6 - i, i + 5, h + 5);
+ }
+ r.adjust(0, 0, 1, 1);
+ p.setPen(palette().toolTipText().color());
+ r.adjust(hMargin, vMargin, -hMargin, -vMargin);
+
+ if (doc) {
+ p.translate(r.x(), r.y());
+ QRect rect = r;
+ rect.translate(-r.x(), -r.y());
+ p.setClipRect(rect);
+ QAbstractTextDocumentLayout::PaintContext context;
+ context.palette.setBrush(QPalette::Text, context.palette.toolTipText());
+ doc->documentLayout()->draw(&p, context);
+ }
+ else
+ {
+ p.drawText(r, Qt::AlignLeft + Qt::AlignTop + Qt::TextWordWrap + Qt::TextExpandTabs, text);
+ }
+}
+
+static const char * const button_image[] = {
+"16 16 3 1",
+" c None",
+"o c #000000",
+"a c #000080",
+"o aaaaa ",
+"oo aaa aaa ",
+"ooo aaa aaa",
+"oooo aa aa",
+"ooooo aa aa",
+"oooooo a aaa",
+"ooooooo aaa ",
+"oooooooo aaa ",
+"ooooooooo aaa ",
+"ooooo aaa ",
+"oo ooo ",
+"o ooo aaa ",
+" ooo aaa ",
+" ooo ",
+" ooo ",
+" ooo "};
+
+class QWhatsThisPrivate : public QObject
+{
+ public:
+ QWhatsThisPrivate();
+ ~QWhatsThisPrivate();
+ static QWhatsThisPrivate *instance;
+ bool eventFilter(QObject *, QEvent *);
+ QPointer<QAction> action;
+#ifdef QT3_SUPPORT
+ QPointer<QToolButton> button;
+#endif
+ static void say(QWidget *, const QString &, int x = 0, int y = 0);
+ static void notifyToplevels(QEvent *e);
+ bool leaveOnMouseRelease;
+};
+
+void QWhatsThisPrivate::notifyToplevels(QEvent *e)
+{
+ QWidgetList toplevels = QApplication::topLevelWidgets();
+ for (int i = 0; i < toplevels.count(); ++i) {
+ register QWidget *w = toplevels.at(i);
+ QApplication::sendEvent(w, e);
+ }
+}
+
+QWhatsThisPrivate *QWhatsThisPrivate::instance = 0;
+
+QWhatsThisPrivate::QWhatsThisPrivate()
+ : leaveOnMouseRelease(false)
+{
+ instance = this;
+ qApp->installEventFilter(this);
+
+ QPoint pos = QCursor::pos();
+ if (QWidget *w = QApplication::widgetAt(pos)) {
+ QHelpEvent e(QEvent::QueryWhatsThis, w->mapFromGlobal(pos), pos);
+ bool sentEvent = QApplication::sendEvent(w, &e);
+#ifdef QT_NO_CURSOR
+ Q_UNUSED(sentEvent);
+#else
+ QApplication::setOverrideCursor((!sentEvent || !e.isAccepted())?
+ Qt::ForbiddenCursor:Qt::WhatsThisCursor);
+ } else {
+ QApplication::setOverrideCursor(Qt::WhatsThisCursor);
+#endif
+ }
+#ifndef QT_NO_ACCESSIBILITY
+ QAccessible::updateAccessibility(this, 0, QAccessible::ContextHelpStart);
+#endif
+}
+
+QWhatsThisPrivate::~QWhatsThisPrivate()
+{
+ if (action)
+ action->setChecked(false);
+#ifdef QT3_SUPPORT
+ if (button)
+ button->setChecked(false);
+#endif
+#ifndef QT_NO_CURSOR
+ QApplication::restoreOverrideCursor();
+#endif
+#ifndef QT_NO_ACCESSIBILITY
+ QAccessible::updateAccessibility(this, 0, QAccessible::ContextHelpEnd);
+#endif
+ instance = 0;
+}
+
+bool QWhatsThisPrivate::eventFilter(QObject *o, QEvent *e)
+{
+ if (!o->isWidgetType())
+ return false;
+ QWidget * w = static_cast<QWidget *>(o);
+ bool customWhatsThis = w->testAttribute(Qt::WA_CustomWhatsThis);
+ switch (e->type()) {
+ case QEvent::MouseButtonPress:
+ {
+ QMouseEvent *me = static_cast<QMouseEvent*>(e);
+ if (me->button() == Qt::RightButton || customWhatsThis)
+ return false;
+ QHelpEvent e(QEvent::WhatsThis, me->pos(), me->globalPos());
+ if (!QApplication::sendEvent(w, &e) || !e.isAccepted())
+ leaveOnMouseRelease = true;
+
+ } break;
+
+ case QEvent::MouseMove:
+ {
+ QMouseEvent *me = static_cast<QMouseEvent*>(e);
+ QHelpEvent e(QEvent::QueryWhatsThis, me->pos(), me->globalPos());
+ bool sentEvent = QApplication::sendEvent(w, &e);
+#ifdef QT_NO_CURSOR
+ Q_UNUSED(sentEvent);
+#else
+ QApplication::changeOverrideCursor((!sentEvent || !e.isAccepted())?
+ Qt::ForbiddenCursor:Qt::WhatsThisCursor);
+#endif
+ }
+ // fall through
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseButtonDblClick:
+ if (leaveOnMouseRelease && e->type() == QEvent::MouseButtonRelease)
+ QWhatsThis::leaveWhatsThisMode();
+ if (static_cast<QMouseEvent*>(e)->button() == Qt::RightButton || customWhatsThis)
+ return false; // ignore RMB release
+ break;
+ case QEvent::KeyPress:
+ {
+ QKeyEvent* kev = (QKeyEvent*)e;
+
+ if (kev->key() == Qt::Key_Escape) {
+ QWhatsThis::leaveWhatsThisMode();
+ return true;
+ } else if (customWhatsThis) {
+ return false;
+ } else if (kev->key() == Qt::Key_Menu ||
+ (kev->key() == Qt::Key_F10 &&
+ kev->modifiers() == Qt::ShiftModifier)) {
+ // we don't react to these keys, they are used for context menus
+ return false;
+ } else if (kev->key() != Qt::Key_Shift && kev->key() != Qt::Key_Alt // not a modifier key
+ && kev->key() != Qt::Key_Control && kev->key() != Qt::Key_Meta) {
+ QWhatsThis::leaveWhatsThisMode();
+ }
+ } break;
+ default:
+ return false;
+ }
+ return true;
+}
+
+class QWhatsThisAction: public QAction
+{
+ Q_OBJECT
+
+public:
+ explicit QWhatsThisAction(QObject* parent = 0);
+
+private slots:
+ void actionTriggered();
+};
+
+QWhatsThisAction::QWhatsThisAction(QObject *parent) : QAction(tr("What's This?"), parent)
+{
+#ifndef QT_NO_IMAGEFORMAT_XPM
+ QPixmap p((const char**)button_image);
+ setIcon(p);
+#endif
+ setCheckable(true);
+ connect(this, SIGNAL(triggered()), this, SLOT(actionTriggered()));
+#ifndef QT_NO_SHORTCUT
+ setShortcut(Qt::ShiftModifier + Qt::Key_F1);
+#endif
+}
+
+void QWhatsThisAction::actionTriggered()
+{
+ if (isChecked()) {
+ QWhatsThis::enterWhatsThisMode();
+ QWhatsThisPrivate::instance->action = this;
+ }
+}
+
+QWhatsThis::QWhatsThis()
+{
+}
+
+#ifdef QT3_SUPPORT
+/*!
+ \obsolete
+
+ Sets the What's This text \a s for the widget \a w.
+
+ Use QWidget::setWhatsThis() or QAction::setWhatsThis() instead.
+*/
+void QWhatsThis::add(QWidget *w, const QString &s)
+{
+ w->setWhatsThis(s);
+}
+
+/*!
+ \obsolete
+
+ Remove's the What's This text for the widget \a w.
+
+ Use QWidget::setWhatsThis() or QAction::setWhatsThis() instead.
+*/
+void QWhatsThis::remove(QWidget *w)
+{
+ w->setWhatsThis(QString());
+}
+
+class QWhatsThisButton : public QToolButton
+{
+ Q_OBJECT
+public:
+ QWhatsThisButton(QWidget *p) : QToolButton(p) {
+ setCheckable(true);
+ QPixmap pix( const_cast<const char**>(button_image) );
+ setIcon( pix );
+ QObject::connect(this, SIGNAL(toggled(bool)), this, SLOT(whatToggled(bool)));
+ setAutoRaise(true);
+ setFocusPolicy(Qt::NoFocus);
+ }
+
+public slots:
+ void whatToggled(bool b) {
+ if (b) {
+ QWhatsThis::enterWhatsThisMode();
+ QWhatsThisPrivate::instance->button = this;
+ }
+ }
+};
+
+/*!
+ Returns a new "What's This?" QToolButton with the given \a
+ parent. To do this now, create your own QToolButton and a
+ QWhatsThis object and call the QWhatsThis object's showText()
+ function when the QToolButton is invoked.
+
+ Use createAction() instead.
+*/
+QToolButton * QWhatsThis::whatsThisButton(QWidget * parent)
+{
+ return new QWhatsThisButton(parent);
+}
+#endif
+
+/*!
+ This function switches the user interface into "What's This?"
+ mode. The user interface can be switched back into normal mode by
+ the user (e.g. by them clicking or pressing Esc), or
+ programmatically by calling leaveWhatsThisMode().
+
+ When entering "What's This?" mode, a QEvent of type
+ Qt::EnterWhatsThisMode is sent to all toplevel widgets.
+
+ \sa inWhatsThisMode() leaveWhatsThisMode()
+*/
+void QWhatsThis::enterWhatsThisMode()
+{
+ if (QWhatsThisPrivate::instance)
+ return;
+ (void) new QWhatsThisPrivate;
+ QEvent e(QEvent::EnterWhatsThisMode);
+ QWhatsThisPrivate::notifyToplevels(&e);
+ }
+
+/*!
+ Returns true if the user interface is in "What's This?" mode;
+ otherwise returns false.
+
+ \sa enterWhatsThisMode()
+*/
+bool QWhatsThis::inWhatsThisMode()
+{
+ return (QWhatsThisPrivate::instance != 0);
+}
+
+/*!
+ If the user interface is in "What's This?" mode, this function
+ switches back to normal mode; otherwise it does nothing.
+
+ When leaving "What's This?" mode, a QEvent of type
+ Qt::LeaveWhatsThisMode is sent to all toplevel widgets.
+
+ \sa enterWhatsThisMode() inWhatsThisMode()
+*/
+void QWhatsThis::leaveWhatsThisMode()
+{
+ delete QWhatsThisPrivate::instance;
+ QEvent e(QEvent::LeaveWhatsThisMode);
+ QWhatsThisPrivate::notifyToplevels(&e);
+}
+
+void QWhatsThisPrivate::say(QWidget * widget, const QString &text, int x, int y)
+{
+ if (text.size() == 0)
+ return;
+ // make a fresh widget, and set it up
+ QWhatsThat *whatsThat = new QWhatsThat(
+ text,
+#if defined(Q_WS_X11) && !defined(QT_NO_CURSOR)
+ QApplication::desktop()->screen(widget ? widget->x11Info().screen() : QCursor::x11Screen()),
+#else
+ 0,
+#endif
+ widget
+ );
+
+
+ // okay, now to find a suitable location
+
+ int scr = (widget ?
+ QApplication::desktop()->screenNumber(widget) :
+#if defined(Q_WS_X11) && !defined(QT_NO_CURSOR)
+ QCursor::x11Screen()
+#else
+ QApplication::desktop()->screenNumber(QPoint(x,y))
+#endif // Q_WS_X11
+ );
+ QRect screen = QApplication::desktop()->screenGeometry(scr);
+
+ int w = whatsThat->width();
+ int h = whatsThat->height();
+ int sx = screen.x();
+ int sy = screen.y();
+
+ // first try locating the widget immediately above/below,
+ // with nice alignment if possible.
+ QPoint pos;
+ if (widget)
+ pos = widget->mapToGlobal(QPoint(0,0));
+
+ if (widget && w > widget->width() + 16)
+ x = pos.x() + widget->width()/2 - w/2;
+ else
+ x = x - w/2;
+
+ // squeeze it in if that would result in part of what's this
+ // being only partially visible
+ if (x + w + shadowWidth > sx+screen.width())
+ x = (widget? (qMin(screen.width(),
+ pos.x() + widget->width())
+ ) : screen.width())
+ - w;
+
+ if (x < sx)
+ x = sx;
+
+ if (widget && h > widget->height() + 16) {
+ y = pos.y() + widget->height() + 2; // below, two pixels spacing
+ // what's this is above or below, wherever there's most space
+ if (y + h + 10 > sy+screen.height())
+ y = pos.y() + 2 - shadowWidth - h; // above, overlap
+ }
+ y = y + 2;
+
+ // squeeze it in if that would result in part of what's this
+ // being only partially visible
+ if (y + h + shadowWidth > sy+screen.height())
+ y = (widget ? (qMin(screen.height(),
+ pos.y() + widget->height())
+ ) : screen.height())
+ - h;
+ if (y < sy)
+ y = sy;
+
+ whatsThat->move(x, y);
+ whatsThat->show();
+ whatsThat->grabKeyboard();
+}
+
+/*!
+ Shows \a text as a "What's This?" window, at global position \a
+ pos. The optional widget argument, \a w, is used to determine the
+ appropriate screen on multi-head systems.
+
+ \sa hideText()
+*/
+void QWhatsThis::showText(const QPoint &pos, const QString &text, QWidget *w)
+{
+ leaveWhatsThisMode();
+ QWhatsThisPrivate::say(w, text, pos.x(), pos.y());
+}
+
+/*!
+ If a "What's This?" window is showing, this destroys it.
+
+ \sa showText()
+*/
+void QWhatsThis::hideText()
+{
+ qDeleteInEventHandler(QWhatsThat::instance);
+}
+
+/*!
+ Returns a ready-made QAction, used to invoke "What's This?" context
+ help, with the given \a parent.
+
+ The returned QAction provides a convenient way to let users enter
+ "What's This?" mode.
+*/
+QAction *QWhatsThis::createAction(QObject *parent)
+{
+ return new QWhatsThisAction(parent);
+}
+
+QT_END_NAMESPACE
+
+#include "qwhatsthis.moc"
+
+#endif // QT_NO_WHATSTHIS
diff --git a/src/gui/kernel/qwhatsthis.h b/src/widgets/kernel/qwhatsthis.h
index c2e396d0d0..c2e396d0d0 100644
--- a/src/gui/kernel/qwhatsthis.h
+++ b/src/widgets/kernel/qwhatsthis.h
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
new file mode 100644
index 0000000000..1728cfa57c
--- /dev/null
+++ b/src/widgets/kernel/qwidget.cpp
@@ -0,0 +1,12682 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qapplication.h"
+#include "qapplication_p.h"
+#include "qbrush.h"
+#include "qcursor.h"
+#include "qdesktopwidget.h"
+#include "qevent.h"
+#include "qhash.h"
+#include "qlayout.h"
+#include "qmenu.h"
+#include "qmetaobject.h"
+#include "qpixmap.h"
+#include "qpointer.h"
+#include "qstack.h"
+#include "qstyle.h"
+#include "qstylefactory.h"
+#include "qvariant.h"
+#include "qwidget.h"
+#include "qstyleoption.h"
+#ifndef QT_NO_ACCESSIBILITY
+# include "qaccessible.h"
+#endif
+#if defined(Q_WS_WIN)
+# include "qt_windows.h"
+#endif
+#ifdef Q_WS_MAC
+# include "qt_mac_p.h"
+# include "qt_cocoa_helpers_mac_p.h"
+# include "qmainwindow.h"
+# include "qtoolbar.h"
+# include <private/qmainwindowlayout_p.h>
+#endif
+#if defined(Q_WS_QWS)
+# include "qwsdisplay_qws.h"
+# include "qwsmanager_qws.h"
+# include "qpaintengine.h" // for PorterDuff
+# include "private/qwindowsurface_qws_p.h"
+#endif
+#if defined(Q_WS_QPA)
+#include "qplatformwindow_qpa.h"
+#include "private/qwidgetwindow_qpa_p.h"
+#endif
+#include "qpainter.h"
+#include "qtooltip.h"
+#include "qwhatsthis.h"
+#include "qdebug.h"
+#include "private/qstylesheetstyle_p.h"
+#include "private/qstyle_p.h"
+#include "private/qinputcontext_p.h"
+#include "qfileinfo.h"
+#include "private/qsoftkeymanager_p.h"
+
+#if defined (Q_WS_WIN)
+# include <private/qwininputcontext_p.h>
+#endif
+
+#if defined(Q_WS_X11)
+# include <private/qpaintengine_x11_p.h>
+# include "qx11info_x11.h"
+#endif
+
+#include <private/qgraphicseffect_p.h>
+#include <private/qwindowsurface_p.h>
+#include <private/qbackingstore_p.h>
+#ifdef Q_WS_MAC
+# include <private/qpaintengine_mac_p.h>
+#endif
+#include <private/qpaintengine_raster_p.h>
+
+#if defined(Q_OS_SYMBIAN)
+#include "private/qt_s60_p.h"
+#endif
+
+#include "qwidget_p.h"
+#include "qaction_p.h"
+#include "qlayout_p.h"
+#include "QtWidgets/qgraphicsproxywidget.h"
+#include "QtWidgets/qgraphicsscene.h"
+#include "private/qgraphicsproxywidget_p.h"
+#include "QtWidgets/qabstractscrollarea.h"
+#include "private/qabstractscrollarea_p.h"
+#include "private/qevent_p.h"
+
+#include "private/qgesturemanager_p.h"
+
+#ifdef QT_KEYPAD_NAVIGATION
+#include "qtabwidget.h" // Needed in inTabWidget()
+#endif // QT_KEYPAD_NAVIGATION
+
+#ifdef Q_WS_S60
+#include <aknappui.h>
+#endif
+
+// widget/widget data creation count
+//#define QWIDGET_EXTRA_DEBUG
+//#define ALIEN_DEBUG
+
+QT_BEGIN_NAMESPACE
+
+#if !defined(Q_WS_QWS)
+static bool qt_enable_backingstore = true;
+#endif
+#ifdef Q_WS_X11
+// for compatibility with Qt 4.0
+Q_GUI_EXPORT void qt_x11_set_global_double_buffer(bool enable)
+{
+ qt_enable_backingstore = enable;
+}
+#endif
+
+#if defined(QT_MAC_USE_COCOA)
+bool qt_mac_clearDirtyOnWidgetInsideDrawWidget = false;
+#endif
+
+static inline bool qRectIntersects(const QRect &r1, const QRect &r2)
+{
+ return (qMax(r1.left(), r2.left()) <= qMin(r1.right(), r2.right()) &&
+ qMax(r1.top(), r2.top()) <= qMin(r1.bottom(), r2.bottom()));
+}
+
+static inline bool hasBackingStoreSupport()
+{
+ return true;
+}
+
+#ifdef Q_WS_MAC
+# define QT_NO_PAINT_DEBUG
+#endif
+
+extern bool qt_sendSpontaneousEvent(QObject*, QEvent*); // qapplication.cpp
+extern QDesktopWidget *qt_desktopWidget; // qapplication.cpp
+
+/*!
+ \internal
+ \class QWidgetBackingStoreTracker
+ \brief Class which allows tracking of which widgets are using a given backing store
+
+ QWidgetBackingStoreTracker is a thin wrapper around a QWidgetBackingStore pointer,
+ which maintains a list of the QWidgets which are currently using the backing
+ store. This list is modified via the registerWidget and unregisterWidget functions.
+ */
+
+QWidgetBackingStoreTracker::QWidgetBackingStoreTracker()
+ : m_ptr(0)
+{
+
+}
+
+QWidgetBackingStoreTracker::~QWidgetBackingStoreTracker()
+{
+ delete m_ptr;
+}
+
+/*!
+ \internal
+ Destroy the contained QWidgetBackingStore, if not null, and clear the list of
+ widgets using the backing store, then create a new QWidgetBackingStore, providing
+ the QWidget.
+ */
+void QWidgetBackingStoreTracker::create(QWidget *widget)
+{
+ destroy();
+ m_ptr = new QWidgetBackingStore(widget);
+}
+
+/*!
+ \internal
+ Destroy the contained QWidgetBackingStore, if not null, and clear the list of
+ widgets using the backing store.
+ */
+void QWidgetBackingStoreTracker::destroy()
+{
+ delete m_ptr;
+ m_ptr = 0;
+ m_widgets.clear();
+}
+
+/*!
+ \internal
+ Add the widget to the list of widgets currently using the backing store.
+ If the widget was already in the list, this function is a no-op.
+ */
+void QWidgetBackingStoreTracker::registerWidget(QWidget *w)
+{
+ Q_ASSERT(m_ptr);
+ Q_ASSERT(w->internalWinId());
+ Q_ASSERT(qt_widget_private(w)->maybeBackingStore() == m_ptr);
+ m_widgets.insert(w);
+}
+
+/*!
+ \internal
+ Remove the widget from the list of widgets currently using the backing store.
+ If the widget was in the list, and removing it causes the list to be empty,
+ the backing store is deleted.
+ If the widget was not in the list, this function is a no-op.
+ */
+void QWidgetBackingStoreTracker::unregisterWidget(QWidget *w)
+{
+ if (m_widgets.remove(w) && m_widgets.isEmpty()) {
+ delete m_ptr;
+ m_ptr = 0;
+ }
+}
+
+/*!
+ \internal
+ Recursively remove widget and all of its descendents.
+ */
+void QWidgetBackingStoreTracker::unregisterWidgetSubtree(QWidget *widget)
+{
+ unregisterWidget(widget);
+ foreach (QObject *child, widget->children())
+ if (QWidget *childWidget = qobject_cast<QWidget *>(child))
+ unregisterWidgetSubtree(childWidget);
+}
+
+QWidgetPrivate::QWidgetPrivate(int version)
+ : QObjectPrivate(version)
+ , extra(0)
+ , focus_next(0)
+ , focus_prev(0)
+ , focus_child(0)
+ , layout(0)
+ , needsFlush(0)
+ , redirectDev(0)
+ , widgetItem(0)
+ , extraPaintEngine(0)
+ , polished(0)
+ , graphicsEffect(0)
+#if !defined(QT_NO_IM)
+ , imHints(Qt::ImhNone)
+#endif
+ , inheritedFontResolveMask(0)
+ , inheritedPaletteResolveMask(0)
+ , leftmargin(0)
+ , topmargin(0)
+ , rightmargin(0)
+ , bottommargin(0)
+ , leftLayoutItemMargin(0)
+ , topLayoutItemMargin(0)
+ , rightLayoutItemMargin(0)
+ , bottomLayoutItemMargin(0)
+ , hd(0)
+ , size_policy(QSizePolicy::Preferred, QSizePolicy::Preferred)
+ , fg_role(QPalette::NoRole)
+ , bg_role(QPalette::NoRole)
+ , dirtyOpaqueChildren(1)
+ , isOpaque(0)
+ , inDirtyList(0)
+ , isScrolled(0)
+ , isMoved(0)
+ , isGLWidget(0)
+ , usesDoubleBufferedGLContext(0)
+#ifndef QT_NO_IM
+ , inheritsInputMethodHints(0)
+#endif
+#if defined(Q_WS_X11)
+ , picture(0)
+#elif defined(Q_WS_WIN)
+ , noPaintOnScreen(0)
+ #ifndef QT_NO_GESTURES
+ , nativeGesturePanEnabled(0)
+ #endif
+#elif defined(Q_WS_MAC)
+ , needWindowChange(0)
+ , window_event(0)
+ , qd_hd(0)
+#elif defined(Q_OS_SYMBIAN)
+ , symbianScreenNumber(0)
+ , fixNativeOrientationCalled(false)
+#endif
+{
+ if (!qApp) {
+ qFatal("QWidget: Must construct a QApplication before a QPaintDevice");
+ return;
+ }
+
+ if (version != QObjectPrivateVersion)
+ qFatal("Cannot mix incompatible Qt libraries");
+
+ isWidget = true;
+ memset(high_attributes, 0, sizeof(high_attributes));
+#if QT_MAC_USE_COCOA
+ drawRectOriginalAdded = false;
+ originalDrawMethod = true;
+ changeMethods = false;
+ isInUnifiedToolbar = false;
+ unifiedSurface = 0;
+ toolbar_ancestor = 0;
+ flushRequested = false;
+ touchEventsEnabled = false;
+#endif // QT_MAC_USE_COCOA
+#ifdef QWIDGET_EXTRA_DEBUG
+ static int count = 0;
+ qDebug() << "widgets" << ++count;
+#endif
+}
+
+
+QWidgetPrivate::~QWidgetPrivate()
+{
+ if (widgetItem)
+ widgetItem->wid = 0;
+
+ if (extra)
+ deleteExtra();
+
+#ifndef QT_NO_GRAPHICSEFFECT
+ delete graphicsEffect;
+#endif //QT_NO_GRAPHICSEFFECT
+}
+
+class QDummyWindowSurface : public QWindowSurface
+{
+public:
+ QDummyWindowSurface(QWindow *window) : QWindowSurface(window) {}
+ QPaintDevice *paintDevice() { return static_cast<QWidgetWindow *>(window())->widget(); }
+ void flush(QWindow *, const QRegion &, const QPoint &) {}
+};
+
+QWindowSurface *QWidgetPrivate::createDefaultWindowSurface()
+{
+ Q_Q(QWidget);
+
+ QWindowSurface *surface;
+#ifndef QT_NO_PROPERTIES
+ if (q->property("_q_DummyWindowSurface").toBool()) {
+ surface = new QDummyWindowSurface(q->windowHandle());
+ } else
+#endif
+ {
+ QWindow *win = topData()->window;
+ surface = QGuiApplicationPrivate::platformIntegration()->createWindowSurface(win, win->winId());
+ }
+
+ return surface;
+}
+
+/*!
+ \internal
+*/
+void QWidgetPrivate::scrollChildren(int dx, int dy)
+{
+ Q_Q(QWidget);
+ if (q->children().size() > 0) { // scroll children
+ QPoint pd(dx, dy);
+ QObjectList childObjects = q->children();
+ for (int i = 0; i < childObjects.size(); ++i) { // move all children
+ QWidget *w = qobject_cast<QWidget*>(childObjects.at(i));
+ if (w && !w->isWindow()) {
+ QPoint oldp = w->pos();
+ QRect r(w->pos() + pd, w->size());
+ w->data->crect = r;
+#ifndef Q_WS_QWS
+ if (w->testAttribute(Qt::WA_WState_Created))
+ w->d_func()->setWSGeometry();
+#endif
+ w->d_func()->setDirtyOpaqueRegion();
+ QMoveEvent e(r.topLeft(), oldp);
+ QApplication::sendEvent(w, &e);
+ }
+ }
+ }
+}
+
+QInputContext *QWidgetPrivate::assignedInputContext() const
+{
+#ifndef QT_NO_IM
+ const QWidget *widget = q_func();
+ while (widget) {
+ if (QInputContext *qic = widget->d_func()->ic)
+ return qic;
+ widget = widget->parentWidget();
+ }
+#endif
+ return 0;
+}
+
+QInputContext *QWidgetPrivate::inputContext() const
+{
+#ifndef QT_NO_IM
+ if (QInputContext *qic = assignedInputContext())
+ return qic;
+ return qApp->inputContext();
+#else
+ return 0;
+#endif
+}
+
+/*!
+ This function returns the QInputContext for this widget. By
+ default the input context is inherited from the widgets
+ parent. For toplevels it is inherited from QApplication.
+
+ You can override this and set a special input context for this
+ widget by using the setInputContext() method.
+
+ \sa setInputContext()
+*/
+QInputContext *QWidget::inputContext()
+{
+ Q_D(QWidget);
+ if (!testAttribute(Qt::WA_InputMethodEnabled))
+ return 0;
+
+ return d->inputContext();
+}
+
+/*!
+ This function sets the input context \a context
+ on this widget.
+
+ Qt takes ownership of the given input \a context.
+
+ \sa inputContext()
+*/
+void QWidget::setInputContext(QInputContext *context)
+{
+ Q_D(QWidget);
+ if (!testAttribute(Qt::WA_InputMethodEnabled))
+ return;
+#ifndef QT_NO_IM
+ if (context == d->ic)
+ return;
+ if (d->ic)
+ delete d->ic;
+ d->ic = context;
+ if (d->ic)
+ d->ic->setParent(this);
+#endif
+}
+
+
+/*!
+ \obsolete
+
+ This function can be called on the widget that currently has focus
+ to reset the input method operating on it.
+
+ This function is providing for convenience, instead you should use
+ \l{QInputContext::}{reset()} on the input context that was
+ returned by inputContext().
+
+ \sa QInputContext, inputContext(), QInputContext::reset()
+*/
+void QWidget::resetInputContext()
+{
+ if (!hasFocus())
+ return;
+#ifndef QT_NO_IM
+ QInputContext *qic = this->inputContext();
+ if(qic)
+ qic->reset();
+#endif // QT_NO_IM
+}
+
+#ifdef QT_KEYPAD_NAVIGATION
+QPointer<QWidget> QWidgetPrivate::editingWidget;
+
+/*!
+ Returns true if this widget currently has edit focus; otherwise false.
+
+ This feature is only available in Qt for Embedded Linux.
+
+ \sa setEditFocus(), QApplication::keypadNavigationEnabled()
+*/
+bool QWidget::hasEditFocus() const
+{
+ const QWidget* w = this;
+ while (w->d_func()->extra && w->d_func()->extra->focus_proxy)
+ w = w->d_func()->extra->focus_proxy;
+ return QWidgetPrivate::editingWidget == w;
+}
+
+/*!
+ \fn void QWidget::setEditFocus(bool enable)
+
+ If \a enable is true, make this widget have edit focus, in which
+ case Qt::Key_Up and Qt::Key_Down will be delivered to the widget
+ normally; otherwise, Qt::Key_Up and Qt::Key_Down are used to
+ change focus.
+
+ This feature is only available in Qt for Embedded Linux and Qt
+ for Symbian.
+
+ \sa hasEditFocus(), QApplication::keypadNavigationEnabled()
+*/
+void QWidget::setEditFocus(bool on)
+{
+ QWidget *f = this;
+ while (f->d_func()->extra && f->d_func()->extra->focus_proxy)
+ f = f->d_func()->extra->focus_proxy;
+
+ if (QWidgetPrivate::editingWidget && QWidgetPrivate::editingWidget != f)
+ QWidgetPrivate::editingWidget->setEditFocus(false);
+
+ if (on && !f->hasFocus())
+ f->setFocus();
+
+ if ((!on && !QWidgetPrivate::editingWidget)
+ || (on && QWidgetPrivate::editingWidget == f)) {
+ return;
+ }
+
+ if (!on && QWidgetPrivate::editingWidget == f) {
+ QWidgetPrivate::editingWidget = 0;
+ QEvent event(QEvent::LeaveEditFocus);
+ QApplication::sendEvent(f, &event);
+ QApplication::sendEvent(f->style(), &event);
+ } else if (on) {
+ QWidgetPrivate::editingWidget = f;
+ QEvent event(QEvent::EnterEditFocus);
+ QApplication::sendEvent(f, &event);
+ QApplication::sendEvent(f->style(), &event);
+ }
+}
+#endif
+
+/*!
+ \property QWidget::autoFillBackground
+ \brief whether the widget background is filled automatically
+ \since 4.1
+
+ If enabled, this property will cause Qt to fill the background of the
+ widget before invoking the paint event. The color used is defined by the
+ QPalette::Window color role from the widget's \l{QPalette}{palette}.
+
+ In addition, Windows are always filled with QPalette::Window, unless the
+ WA_OpaquePaintEvent or WA_NoSystemBackground attributes are set.
+
+ This property cannot be turned off (i.e., set to false) if a widget's
+ parent has a static gradient for its background.
+
+ \warning Use this property with caution in conjunction with
+ \l{Qt Style Sheets}. When a widget has a style sheet with a valid
+ background or a border-image, this property is automatically disabled.
+
+ By default, this property is false.
+
+ \sa Qt::WA_OpaquePaintEvent, Qt::WA_NoSystemBackground,
+ {QWidget#Transparency and Double Buffering}{Transparency and Double Buffering}
+*/
+bool QWidget::autoFillBackground() const
+{
+ Q_D(const QWidget);
+ return d->extra && d->extra->autoFillBackground;
+}
+
+void QWidget::setAutoFillBackground(bool enabled)
+{
+ Q_D(QWidget);
+ if (!d->extra)
+ d->createExtra();
+ if (d->extra->autoFillBackground == enabled)
+ return;
+
+ d->extra->autoFillBackground = enabled;
+ d->updateIsOpaque();
+ update();
+ d->updateIsOpaque();
+}
+
+/*!
+ \class QWidget
+ \brief The QWidget class is the base class of all user interface objects.
+
+ \ingroup basicwidgets
+
+ The widget is the atom of the user interface: it receives mouse, keyboard
+ and other events from the window system, and paints a representation of
+ itself on the screen. Every widget is rectangular, and they are sorted in a
+ Z-order. A widget is clipped by its parent and by the widgets in front of
+ it.
+
+ A widget that is not embedded in a parent widget is called a window.
+ Usually, windows have a frame and a title bar, although it is also possible
+ to create windows without such decoration using suitable
+ \l{Qt::WindowFlags}{window flags}). In Qt, QMainWindow and the various
+ subclasses of QDialog are the most common window types.
+
+ Every widget's constructor accepts one or two standard arguments:
+
+ \list 1
+ \i \c{QWidget *parent = 0} is the parent of the new widget. If it is 0
+ (the default), the new widget will be a window. If not, it will be
+ a child of \e parent, and be constrained by \e parent's geometry
+ (unless you specify Qt::Window as window flag).
+ \i \c{Qt::WindowFlags f = 0} (where available) sets the window flags;
+ the default is suitable for almost all widgets, but to get, for
+ example, a window without a window system frame, you must use
+ special flags.
+ \endlist
+
+ QWidget has many member functions, but some of them have little direct
+ functionality; for example, QWidget has a font property, but never uses
+ this itself. There are many subclasses which provide real functionality,
+ such as QLabel, QPushButton, QListWidget, and QTabWidget.
+
+
+ \section1 Top-Level and Child Widgets
+
+ A widget without a parent widget is always an independent window (top-level
+ widget). For these widgets, setWindowTitle() and setWindowIcon() set the
+ title bar and icon respectively.
+
+ Non-window widgets are child widgets, displayed within their parent
+ widgets. Most widgets in Qt are mainly useful as child widgets. For
+ example, it is possible to display a button as a top-level window, but most
+ people prefer to put their buttons inside other widgets, such as QDialog.
+
+ \image parent-child-widgets.png A parent widget containing various child widgets.
+
+ The diagram above shows a QGroupBox widget being used to hold various child
+ widgets in a layout provided by QGridLayout. The QLabel child widgets have
+ been outlined to indicate their full sizes.
+
+ If you want to use a QWidget to hold child widgets you will usually want to
+ add a layout to the parent QWidget. See \l{Layout Management} for more
+ information.
+
+
+ \section1 Composite Widgets
+
+ When a widget is used as a container to group a number of child widgets, it
+ is known as a composite widget. These can be created by constructing a
+ widget with the required visual properties - a QFrame, for example - and
+ adding child widgets to it, usually managed by a layout. The above diagram
+ shows such a composite widget that was created using \l{Qt Designer}.
+
+ Composite widgets can also be created by subclassing a standard widget,
+ such as QWidget or QFrame, and adding the necessary layout and child
+ widgets in the constructor of the subclass. Many of the \l{Qt Examples}
+ {examples provided with Qt} use this approach, and it is also covered in
+ the Qt \l{Tutorials}.
+
+
+ \section1 Custom Widgets and Painting
+
+ Since QWidget is a subclass of QPaintDevice, subclasses can be used to
+ display custom content that is composed using a series of painting
+ operations with an instance of the QPainter class. This approach contrasts
+ with the canvas-style approach used by the \l{Graphics View}
+ {Graphics View Framework} where items are added to a scene by the
+ application and are rendered by the framework itself.
+
+ Each widget performs all painting operations from within its paintEvent()
+ function. This is called whenever the widget needs to be redrawn, either
+ as a result of some external change or when requested by the application.
+
+ The \l{widgets/analogclock}{Analog Clock example} shows how a simple widget
+ can handle paint events.
+
+
+ \section1 Size Hints and Size Policies
+
+ When implementing a new widget, it is almost always useful to reimplement
+ sizeHint() to provide a reasonable default size for the widget and to set
+ the correct size policy with setSizePolicy().
+
+ By default, composite widgets which do not provide a size hint will be
+ sized according to the space requirements of their child widgets.
+
+ The size policy lets you supply good default behavior for the layout
+ management system, so that other widgets can contain and manage yours
+ easily. The default size policy indicates that the size hint represents
+ the preferred size of the widget, and this is often good enough for many
+ widgets.
+
+ \note The size of top-level widgets are constrained to 2/3 of the desktop's
+ height and width. You can resize() the widget manually if these bounds are
+ inadequate.
+
+
+ \section1 Events
+
+ Widgets respond to events that are typically caused by user actions. Qt
+ delivers events to widgets by calling specific event handler functions with
+ instances of QEvent subclasses containing information about each event.
+
+ If your widget only contains child widgets, you probably do not need to
+ implement any event handlers. If you want to detect a mouse click in a
+ child widget call the child's underMouse() function inside the widget's
+ mousePressEvent().
+
+ The \l{widgets/scribble}{Scribble example} implements a wider set of
+ events to handle mouse movement, button presses, and window resizing.
+
+ You will need to supply the behavior and content for your own widgets, but
+ here is a brief overview of the events that are relevant to QWidget,
+ starting with the most common ones:
+
+ \list
+ \i paintEvent() is called whenever the widget needs to be repainted.
+ Every widget displaying custom content must implement it. Painting
+ using a QPainter can only take place in a paintEvent() or a
+ function called by a paintEvent().
+ \i resizeEvent() is called when the widget has been resized.
+ \i mousePressEvent() is called when a mouse button is pressed while
+ the mouse cursor is inside the widget, or when the widget has
+ grabbed the mouse using grabMouse(). Pressing the mouse without
+ releasing it is effectively the same as calling grabMouse().
+ \i mouseReleaseEvent() is called when a mouse button is released. A
+ widget receives mouse release events when it has received the
+ corresponding mouse press event. This means that if the user
+ presses the mouse inside \e your widget, then drags the mouse
+ somewhere else before releasing the mouse button, \e your widget
+ receives the release event. There is one exception: if a popup menu
+ appears while the mouse button is held down, this popup immediately
+ steals the mouse events.
+ \i mouseDoubleClickEvent() is called when the user double-clicks in
+ the widget. If the user double-clicks, the widget receives a mouse
+ press event, a mouse release event and finally this event instead
+ of a second mouse press event. (Some mouse move events may also be
+ received if the mouse is not held steady during this operation.) It
+ is \e{not possible} to distinguish a click from a double-click
+ until the second click arrives. (This is one reason why most GUI
+ books recommend that double-clicks be an extension of
+ single-clicks, rather than trigger a different action.)
+ \endlist
+
+ Widgets that accept keyboard input need to reimplement a few more event
+ handlers:
+
+ \list
+ \i keyPressEvent() is called whenever a key is pressed, and again when
+ a key has been held down long enough for it to auto-repeat. The
+ \key Tab and \key Shift+Tab keys are only passed to the widget if
+ they are not used by the focus-change mechanisms. To force those
+ keys to be processed by your widget, you must reimplement
+ QWidget::event().
+ \i focusInEvent() is called when the widget gains keyboard focus
+ (assuming you have called setFocusPolicy()). Well-behaved widgets
+ indicate that they own the keyboard focus in a clear but discreet
+ way.
+ \i focusOutEvent() is called when the widget loses keyboard focus.
+ \endlist
+
+ You may be required to also reimplement some of the less common event
+ handlers:
+
+ \list
+ \i mouseMoveEvent() is called whenever the mouse moves while a mouse
+ button is held down. This can be useful during drag and drop
+ operations. If you call \l{setMouseTracking()}{setMouseTracking}(true),
+ you get mouse move events even when no buttons are held down.
+ (See also the \l{Drag and Drop} guide.)
+ \i keyReleaseEvent() is called whenever a key is released and while it
+ is held down (if the key is auto-repeating). In that case, the
+ widget will receive a pair of key release and key press event for
+ every repeat. The \key Tab and \key Shift+Tab keys are only passed
+ to the widget if they are not used by the focus-change mechanisms.
+ To force those keys to be processed by your widget, you must
+ reimplement QWidget::event().
+ \i wheelEvent() is called whenever the user turns the mouse wheel
+ while the widget has the focus.
+ \i enterEvent() is called when the mouse enters the widget's screen
+ space. (This excludes screen space owned by any of the widget's
+ children.)
+ \i leaveEvent() is called when the mouse leaves the widget's screen
+ space. If the mouse enters a child widget it will not cause a
+ leaveEvent().
+ \i moveEvent() is called when the widget has been moved relative to
+ its parent.
+ \i closeEvent() is called when the user closes the widget (or when
+ close() is called).
+ \endlist
+
+ There are also some rather obscure events described in the documentation
+ for QEvent::Type. To handle these events, you need to reimplement event()
+ directly.
+
+ The default implementation of event() handles \key Tab and \key Shift+Tab
+ (to move the keyboard focus), and passes on most of the other events to
+ one of the more specialized handlers above.
+
+ Events and the mechanism used to deliver them are covered in
+ \l{The Event System}.
+
+ \section1 Groups of Functions and Properties
+
+ \table
+ \header \i Context \i Functions and Properties
+
+ \row \i Window functions \i
+ show(),
+ hide(),
+ raise(),
+ lower(),
+ close().
+
+ \row \i Top-level windows \i
+ \l windowModified, \l windowTitle, \l windowIcon, \l windowIconText,
+ \l isActiveWindow, activateWindow(), \l minimized, showMinimized(),
+ \l maximized, showMaximized(), \l fullScreen, showFullScreen(),
+ showNormal().
+
+ \row \i Window contents \i
+ update(),
+ repaint(),
+ scroll().
+
+ \row \i Geometry \i
+ \l pos, x(), y(), \l rect, \l size, width(), height(), move(), resize(),
+ \l sizePolicy, sizeHint(), minimumSizeHint(),
+ updateGeometry(), layout(),
+ \l frameGeometry, \l geometry, \l childrenRect, \l childrenRegion,
+ adjustSize(),
+ mapFromGlobal(), mapToGlobal(),
+ mapFromParent(), mapToParent(),
+ \l maximumSize, \l minimumSize, \l sizeIncrement,
+ \l baseSize, setFixedSize()
+
+ \row \i Mode \i
+ \l visible, isVisibleTo(),
+ \l enabled, isEnabledTo(),
+ \l modal,
+ isWindow(),
+ \l mouseTracking,
+ \l updatesEnabled,
+ visibleRegion().
+
+ \row \i Look and feel \i
+ style(),
+ setStyle(),
+ \l styleSheet,
+ \l cursor,
+ \l font,
+ \l palette,
+ backgroundRole(), setBackgroundRole(),
+ fontInfo(), fontMetrics().
+
+ \row \i Keyboard focus functions \i
+ \l focus, \l focusPolicy,
+ setFocus(), clearFocus(), setTabOrder(), setFocusProxy(),
+ focusNextChild(), focusPreviousChild().
+
+ \row \i Mouse and keyboard grabbing \i
+ grabMouse(), releaseMouse(),
+ grabKeyboard(), releaseKeyboard(),
+ mouseGrabber(), keyboardGrabber().
+
+ \row \i Event handlers \i
+ event(),
+ mousePressEvent(),
+ mouseReleaseEvent(),
+ mouseDoubleClickEvent(),
+ mouseMoveEvent(),
+ keyPressEvent(),
+ keyReleaseEvent(),
+ focusInEvent(),
+ focusOutEvent(),
+ wheelEvent(),
+ enterEvent(),
+ leaveEvent(),
+ paintEvent(),
+ moveEvent(),
+ resizeEvent(),
+ closeEvent(),
+ dragEnterEvent(),
+ dragMoveEvent(),
+ dragLeaveEvent(),
+ dropEvent(),
+ childEvent(),
+ showEvent(),
+ hideEvent(),
+ customEvent().
+ changeEvent(),
+
+ \row \i System functions \i
+ parentWidget(), window(), setParent(), winId(),
+ find(), metric().
+
+ \row \i Interactive help \i
+ setToolTip(), setWhatsThis()
+
+ \endtable
+
+
+ \section1 Widget Style Sheets
+
+ In addition to the standard widget styles for each platform, widgets can
+ also be styled according to rules specified in a \l{styleSheet}
+ {style sheet}. This feature enables you to customize the appearance of
+ specific widgets to provide visual cues to users about their purpose. For
+ example, a button could be styled in a particular way to indicate that it
+ performs a destructive action.
+
+ The use of widget style sheets is described in more detail in the
+ \l{Qt Style Sheets} document.
+
+
+ \section1 Transparency and Double Buffering
+
+ Since Qt 4.0, QWidget automatically double-buffers its painting, so there
+ is no need to write double-buffering code in paintEvent() to avoid
+ flicker.
+
+ Since Qt 4.1, the Qt::WA_ContentsPropagated widget attribute has been
+ deprecated. Instead, the contents of parent widgets are propagated by
+ default to each of their children as long as Qt::WA_PaintOnScreen is not
+ set. Custom widgets can be written to take advantage of this feature by
+ updating irregular regions (to create non-rectangular child widgets), or
+ painting with colors that have less than full alpha component. The
+ following diagram shows how attributes and properties of a custom widget
+ can be fine-tuned to achieve different effects.
+
+ \image propagation-custom.png
+
+ In the above diagram, a semi-transparent rectangular child widget with an
+ area removed is constructed and added to a parent widget (a QLabel showing
+ a pixmap). Then, different properties and widget attributes are set to
+ achieve different effects:
+
+ \list
+ \i The left widget has no additional properties or widget attributes
+ set. This default state suits most custom widgets using
+ transparency, are irregularly-shaped, or do not paint over their
+ entire area with an opaque brush.
+ \i The center widget has the \l autoFillBackground property set. This
+ property is used with custom widgets that rely on the widget to
+ supply a default background, and do not paint over their entire
+ area with an opaque brush.
+ \i The right widget has the Qt::WA_OpaquePaintEvent widget attribute
+ set. This indicates that the widget will paint over its entire area
+ with opaque colors. The widget's area will initially be
+ \e{uninitialized}, represented in the diagram with a red diagonal
+ grid pattern that shines through the overpainted area. The
+ Qt::WA_OpaquePaintArea attribute is useful for widgets that need to
+ paint their own specialized contents quickly and do not need a
+ default filled background.
+ \endlist
+
+ To rapidly update custom widgets with simple background colors, such as
+ real-time plotting or graphing widgets, it is better to define a suitable
+ background color (using setBackgroundRole() with the
+ QPalette::Window role), set the \l autoFillBackground property, and only
+ implement the necessary drawing functionality in the widget's paintEvent().
+
+ To rapidly update custom widgets that constantly paint over their entire
+ areas with opaque content, e.g., video streaming widgets, it is better to
+ set the widget's Qt::WA_OpaquePaintEvent, avoiding any unnecessary overhead
+ associated with repainting the widget's background.
+
+ If a widget has both the Qt::WA_OpaquePaintEvent widget attribute \e{and}
+ the \l autoFillBackground property set, the Qt::WA_OpaquePaintEvent
+ attribute takes precedence. Depending on your requirements, you should
+ choose either one of them.
+
+ Since Qt 4.1, the contents of parent widgets are also propagated to
+ standard Qt widgets. This can lead to some unexpected results if the
+ parent widget is decorated in a non-standard way, as shown in the diagram
+ below.
+
+ \image propagation-standard.png
+
+ The scope for customizing the painting behavior of standard Qt widgets,
+ without resorting to subclassing, is slightly less than that possible for
+ custom widgets. Usually, the desired appearance of a standard widget can be
+ achieved by setting its \l autoFillBackground property.
+
+
+ \section1 Creating Translucent Windows
+
+ Since Qt 4.5, it has been possible to create windows with translucent regions
+ on window systems that support compositing.
+
+ To enable this feature in a top-level widget, set its Qt::WA_TranslucentBackground
+ attribute with setAttribute() and ensure that its background is painted with
+ non-opaque colors in the regions you want to be partially transparent.
+
+ Platform notes:
+
+ \list
+ \o X11: This feature relies on the use of an X server that supports ARGB visuals
+ and a compositing window manager.
+ \o Windows: The widget needs to have the Qt::FramelessWindowHint window flag set
+ for the translucency to work.
+ \endlist
+
+
+ \section1 Native Widgets vs Alien Widgets
+
+ Introduced in Qt 4.4, alien widgets are widgets unknown to the windowing
+ system. They do not have a native window handle associated with them. This
+ feature significantly speeds up widget painting, resizing, and removes flicker.
+
+ Should you require the old behavior with native windows, you can choose
+ one of the following options:
+
+ \list 1
+ \i Use the \c{QT_USE_NATIVE_WINDOWS=1} in your environment.
+ \i Set the Qt::AA_NativeWindows attribute on your application. All
+ widgets will be native widgets.
+ \i Set the Qt::WA_NativeWindow attribute on widgets: The widget itself
+ and all of its ancestors will become native (unless
+ Qt::WA_DontCreateNativeAncestors is set).
+ \i Call QWidget::winId to enforce a native window (this implies 3).
+ \i Set the Qt::WA_PaintOnScreen attribute to enforce a native window
+ (this implies 3).
+ \endlist
+
+ \sa QEvent, QPainter, QGridLayout, QBoxLayout
+
+ \section1 Softkeys
+
+ Since Qt 4.6, Softkeys are usually physical keys on a device that have a corresponding label or
+ other visual representation on the screen that is generally located next to its
+ physical counterpart. They are most often found on mobile phone platforms. In
+ modern touch based user interfaces it is also possible to have softkeys that do
+ not correspond to any physical keys. Softkeys differ from other onscreen labels
+ in that they are contextual.
+
+ In Qt, contextual softkeys are added to a widget by calling addAction() and
+ passing a \c QAction with a softkey role set on it. When the widget
+ containing the softkey actions has focus, its softkeys should appear in
+ the user interface. Softkeys are discovered by traversing the widget
+ hierarchy so it is possible to define a single set of softkeys that are
+ present at all times by calling addAction() for a given top level widget.
+
+ On some platforms, this concept overlaps with \c QMenuBar such that if no
+ other softkeys are found and the top level widget is a QMainWindow containing
+ a QMenuBar, the menubar actions may appear on one of the softkeys.
+
+ Note: Currently softkeys are only supported on the Symbian Platform.
+
+ \sa addAction(), QAction, QMenuBar
+
+*/
+
+QWidgetMapper *QWidgetPrivate::mapper = 0; // widget with wid
+QWidgetSet *QWidgetPrivate::allWidgets = 0; // widgets with no wid
+
+
+/*****************************************************************************
+ QWidget utility functions
+ *****************************************************************************/
+
+QRegion qt_dirtyRegion(QWidget *widget)
+{
+ if (!widget)
+ return QRegion();
+
+ QWidgetBackingStore *bs = qt_widget_private(widget)->maybeBackingStore();
+ if (!bs)
+ return QRegion();
+
+ return bs->dirtyRegion(widget);
+}
+
+/*****************************************************************************
+ QWidget member functions
+ *****************************************************************************/
+
+/*
+ Widget state flags:
+ \list
+ \i Qt::WA_WState_Created The widget has a valid winId().
+ \i Qt::WA_WState_Visible The widget is currently visible.
+ \i Qt::WA_WState_Hidden The widget is hidden, i.e. it won't
+ become visible unless you call show() on it. Qt::WA_WState_Hidden
+ implies !Qt::WA_WState_Visible.
+ \i Qt::WA_WState_CompressKeys Compress keyboard events.
+ \i Qt::WA_WState_BlockUpdates Repaints and updates are disabled.
+ \i Qt::WA_WState_InPaintEvent Currently processing a paint event.
+ \i Qt::WA_WState_Reparented The widget has been reparented.
+ \i Qt::WA_WState_ConfigPending A configuration (resize/move) event is pending.
+ \i Qt::WA_WState_DND (Deprecated) The widget supports drag and drop, see setAcceptDrops().
+ \endlist
+*/
+
+struct QWidgetExceptionCleaner
+{
+ /* this cleans up when the constructor throws an exception */
+ static inline void cleanup(QWidget *that, QWidgetPrivate *d)
+ {
+#ifdef QT_NO_EXCEPTIONS
+ Q_UNUSED(that);
+ Q_UNUSED(d);
+#else
+ QWidgetPrivate::allWidgets->remove(that);
+ if (d->focus_next != that) {
+ if (d->focus_next)
+ d->focus_next->d_func()->focus_prev = d->focus_prev;
+ if (d->focus_prev)
+ d->focus_prev->d_func()->focus_next = d->focus_next;
+ }
+#endif
+ }
+};
+
+/*!
+ Constructs a widget which is a child of \a parent, with widget
+ flags set to \a f.
+
+ If \a parent is 0, the new widget becomes a window. If
+ \a parent is another widget, this widget becomes a child window
+ inside \a parent. The new widget is deleted when its \a parent is
+ deleted.
+
+ The widget flags argument, \a f, is normally 0, but it can be set
+ to customize the frame of a window (i.e. \a
+ parent must be 0). To customize the frame, use a value composed
+ from the bitwise OR of any of the \l{Qt::WindowFlags}{window flags}.
+
+ If you add a child widget to an already visible widget you must
+ explicitly show the child to make it visible.
+
+ Note that the X11 version of Qt may not be able to deliver all
+ combinations of style flags on all systems. This is because on
+ X11, Qt can only ask the window manager, and the window manager
+ can override the application's settings. On Windows, Qt can set
+ whatever flags you want.
+
+ \sa windowFlags
+*/
+QWidget::QWidget(QWidget *parent, Qt::WindowFlags f)
+ : QObject(*new QWidgetPrivate, 0), QPaintDevice()
+{
+ QT_TRY {
+ d_func()->init(parent, f);
+ } QT_CATCH(...) {
+ QWidgetExceptionCleaner::cleanup(this, d_func());
+ QT_RETHROW;
+ }
+}
+
+#ifdef QT3_SUPPORT
+/*!
+ \overload
+ \obsolete
+ */
+QWidget::QWidget(QWidget *parent, const char *name, Qt::WindowFlags f)
+ : QObject(*new QWidgetPrivate, 0), QPaintDevice()
+{
+ QT_TRY {
+ d_func()->init(parent , f);
+ setObjectName(QString::fromAscii(name));
+ } QT_CATCH(...) {
+ QWidgetExceptionCleaner::cleanup(this, d_func());
+ QT_RETHROW;
+ }
+}
+#endif
+
+/*! \internal
+*/
+QWidget::QWidget(QWidgetPrivate &dd, QWidget* parent, Qt::WindowFlags f)
+ : QObject(dd, 0), QPaintDevice()
+{
+ Q_D(QWidget);
+ QT_TRY {
+ d->init(parent, f);
+ } QT_CATCH(...) {
+ QWidgetExceptionCleaner::cleanup(this, d_func());
+ QT_RETHROW;
+ }
+}
+
+/*!
+ \internal
+*/
+int QWidget::devType() const
+{
+ return QInternal::Widget;
+}
+
+
+//### w is a "this" ptr, passed as a param because QWorkspace needs special logic
+void QWidgetPrivate::adjustFlags(Qt::WindowFlags &flags, QWidget *w)
+{
+ bool customize = (flags & (Qt::CustomizeWindowHint
+ | Qt::FramelessWindowHint
+ | Qt::WindowTitleHint
+ | Qt::WindowSystemMenuHint
+ | Qt::WindowMinimizeButtonHint
+ | Qt::WindowMaximizeButtonHint
+ | Qt::WindowCloseButtonHint
+ | Qt::WindowContextHelpButtonHint));
+
+ uint type = (flags & Qt::WindowType_Mask);
+
+ if ((type == Qt::Widget || type == Qt::SubWindow) && w && !w->parent()) {
+ type = Qt::Window;
+ flags |= Qt::Window;
+ }
+
+ if (flags & Qt::CustomizeWindowHint) {
+ // modify window flags to make them consistent.
+ // Only enable this on non-Mac platforms. Since the old way of doing this would
+ // interpret WindowSystemMenuHint as a close button and we can't change that behavior
+ // we can't just add this in.
+#ifndef Q_WS_MAC
+ if (flags & (Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | Qt::WindowContextHelpButtonHint)) {
+ flags |= Qt::WindowSystemMenuHint;
+#else
+ if (flags & (Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint
+ | Qt::WindowSystemMenuHint)) {
+#endif
+ flags |= Qt::WindowTitleHint;
+ flags &= ~Qt::FramelessWindowHint;
+ }
+ } else if (customize && !(flags & Qt::FramelessWindowHint)) {
+ // if any of the window hints that affect the titlebar are set
+ // and the window is supposed to have frame, we add a titlebar
+ // and system menu by default.
+ flags |= Qt::WindowSystemMenuHint;
+ flags |= Qt::WindowTitleHint;
+ }
+ if (customize)
+ ; // don't modify window flags if the user explicitly set them.
+ else if (type == Qt::Dialog || type == Qt::Sheet)
+#ifndef Q_WS_WINCE
+ flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint | Qt::WindowCloseButtonHint;
+#else
+ flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint;
+#endif
+ else if (type == Qt::Tool)
+ flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowCloseButtonHint;
+ else
+ flags |= Qt::WindowTitleHint | Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint;
+
+
+}
+
+void QWidgetPrivate::init(QWidget *parentWidget, Qt::WindowFlags f)
+{
+ Q_Q(QWidget);
+ if (QApplication::type() == QApplication::Tty)
+ qFatal("QWidget: Cannot create a QWidget when no GUI is being used");
+
+ Q_ASSERT(allWidgets);
+ if (allWidgets)
+ allWidgets->insert(q);
+
+ QWidget *desktopWidget = 0;
+ if (parentWidget && parentWidget->windowType() == Qt::Desktop) {
+ desktopWidget = parentWidget;
+ parentWidget = 0;
+ }
+
+ q->data = &data;
+
+#ifndef QT_NO_THREAD
+ if (!parent) {
+ Q_ASSERT_X(q->thread() == qApp->thread(), "QWidget",
+ "Widgets must be created in the GUI thread.");
+ }
+#endif
+
+#if defined(Q_WS_X11)
+ if (desktopWidget) {
+ // make sure the widget is created on the same screen as the
+ // programmer specified desktop widget
+ xinfo = desktopWidget->d_func()->xinfo;
+ }
+#elif defined(Q_OS_SYMBIAN)
+ if (desktopWidget) {
+ symbianScreenNumber = qt_widget_private(desktopWidget)->symbianScreenNumber;
+ }
+#elif defined(Q_WS_QPA)
+ if (desktopWidget) {
+ int screen = desktopWidget->d_func()->topData()->screenIndex;
+ QPlatformIntegration *platform = QGuiApplicationPrivate::platformIntegration();
+ platform->moveToScreen(q->windowHandle(), screen);
+ }
+#else
+ Q_UNUSED(desktopWidget);
+#endif
+
+ data.fstrut_dirty = true;
+
+ data.winid = 0;
+ data.widget_attributes = 0;
+ data.window_flags = f;
+ data.window_state = 0;
+ data.focus_policy = 0;
+ data.context_menu_policy = Qt::DefaultContextMenu;
+ data.window_modality = Qt::NonModal;
+
+ data.sizehint_forced = 0;
+ data.is_closing = 0;
+ data.in_show = 0;
+ data.in_set_window_state = 0;
+ data.in_destructor = false;
+
+ // Widgets with Qt::MSWindowsOwnDC (typically QGLWidget) must have a window handle.
+ if (f & Qt::MSWindowsOwnDC)
+ q->setAttribute(Qt::WA_NativeWindow);
+
+//#ifdef Q_WS_MAC
+// q->setAttribute(Qt::WA_NativeWindow);
+//#endif
+
+ q->setAttribute(Qt::WA_QuitOnClose); // might be cleared in adjustQuitOnCloseAttribute()
+ adjustQuitOnCloseAttribute();
+
+ q->setAttribute(Qt::WA_WState_Hidden);
+
+ //give potential windows a bigger "pre-initial" size; create_sys() will give them a new size later
+#ifdef Q_OS_SYMBIAN
+ if (isGLWidget) {
+ // Don't waste GPU mem for unnecessary large egl surface until resized by application
+ data.crect = QRect(0,0,1,1);
+ } else {
+ data.crect = parentWidget ? QRect(0,0,100,30) : QRect(0,0,360,640);
+ }
+#else
+ data.crect = parentWidget ? QRect(0,0,100,30) : QRect(0,0,640,480);
+#endif
+
+ focus_next = focus_prev = q;
+
+ if ((f & Qt::WindowType_Mask) == Qt::Desktop)
+ q->create();
+ else if (parentWidget)
+ q->setParent(parentWidget, data.window_flags);
+ else {
+ adjustFlags(data.window_flags, q);
+ resolveLayoutDirection();
+ // opaque system background?
+ const QBrush &background = q->palette().brush(QPalette::Window);
+ setOpaque(q->isWindow() && background.style() != Qt::NoBrush && background.isOpaque());
+ }
+ data.fnt = QFont(data.fnt, q);
+#if defined(Q_WS_X11)
+ data.fnt.x11SetScreen(xinfo.screen());
+#endif // Q_WS_X11
+
+ q->setAttribute(Qt::WA_PendingMoveEvent);
+ q->setAttribute(Qt::WA_PendingResizeEvent);
+
+ if (++QWidgetPrivate::instanceCounter > QWidgetPrivate::maxInstances)
+ QWidgetPrivate::maxInstances = QWidgetPrivate::instanceCounter;
+
+ if (QApplicationPrivate::app_compile_version < 0x040200
+ || QApplicationPrivate::testAttribute(Qt::AA_ImmediateWidgetCreation))
+ q->create();
+
+
+ QEvent e(QEvent::Create);
+ QApplication::sendEvent(q, &e);
+ QApplication::postEvent(q, new QEvent(QEvent::PolishRequest));
+
+ extraPaintEngine = 0;
+
+#ifdef QT_MAC_USE_COCOA
+ // If we add a child to the unified toolbar, we have to redirect the painting.
+ if (parentWidget && parentWidget->d_func() && parentWidget->d_func()->isInUnifiedToolbar) {
+ if (parentWidget->d_func()->unifiedSurface) {
+ QWidget *toolbar = parentWidget->d_func()->toolbar_ancestor;
+ parentWidget->d_func()->unifiedSurface->recursiveRedirect(toolbar, toolbar, toolbar->d_func()->toolbar_offset);
+ }
+ }
+#endif // QT_MAC_USE_COCOA
+}
+
+
+
+void QWidgetPrivate::createRecursively()
+{
+ Q_Q(QWidget);
+ q->create(0, true, true);
+ for (int i = 0; i < children.size(); ++i) {
+ QWidget *child = qobject_cast<QWidget *>(children.at(i));
+ if (child && !child->isHidden() && !child->isWindow() && !child->testAttribute(Qt::WA_WState_Created))
+ child->d_func()->createRecursively();
+ }
+}
+
+
+
+
+/*!
+ Creates a new widget window if \a window is 0, otherwise sets the
+ widget's window to \a window.
+
+ Initializes the window (sets the geometry etc.) if \a
+ initializeWindow is true. If \a initializeWindow is false, no
+ initialization is performed. This parameter only makes sense if \a
+ window is a valid window.
+
+ Destroys the old window if \a destroyOldWindow is true. If \a
+ destroyOldWindow is false, you are responsible for destroying the
+ window yourself (using platform native code).
+
+ The QWidget constructor calls create(0,true,true) to create a
+ window for this widget.
+*/
+
+void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow)
+{
+ Q_D(QWidget);
+ if (testAttribute(Qt::WA_WState_Created) && window == 0 && internalWinId())
+ return;
+
+ if (d->data.in_destructor)
+ return;
+
+ Qt::WindowType type = windowType();
+ Qt::WindowFlags &flags = data->window_flags;
+
+ if ((type == Qt::Widget || type == Qt::SubWindow) && !parentWidget()) {
+ type = Qt::Window;
+ flags |= Qt::Window;
+ }
+
+#ifndef Q_WS_QPA
+ if (QWidget *parent = parentWidget()) {
+ if (type & Qt::Window) {
+ if (!parent->testAttribute(Qt::WA_WState_Created))
+ parent->createWinId();
+ } else if (testAttribute(Qt::WA_NativeWindow) && !parent->internalWinId()
+ && !testAttribute(Qt::WA_DontCreateNativeAncestors)) {
+ // We're about to create a native child widget that doesn't have a native parent;
+ // enforce a native handle for the parent unless the Qt::WA_DontCreateNativeAncestors
+ // attribute is set.
+ d->createWinId(window);
+ // Nothing more to do.
+ Q_ASSERT(testAttribute(Qt::WA_WState_Created));
+ Q_ASSERT(internalWinId());
+ return;
+ }
+ }
+#endif //Q_WS_QPA
+
+#ifdef QT3_SUPPORT
+ if (flags & Qt::WStaticContents)
+ setAttribute(Qt::WA_StaticContents);
+ if (flags & Qt::WDestructiveClose)
+ setAttribute(Qt::WA_DeleteOnClose);
+ if (flags & Qt::WShowModal)
+ setWindowModality(Qt::ApplicationModal);
+ if (flags & Qt::WMouseNoMask)
+ setAttribute(Qt::WA_MouseNoMask);
+ if (flags & Qt::WGroupLeader)
+ setAttribute(Qt::WA_GroupLeader);
+ if (flags & Qt::WNoMousePropagation)
+ setAttribute(Qt::WA_NoMousePropagation);
+#endif
+
+ static int paintOnScreenEnv = -1;
+ if (paintOnScreenEnv == -1)
+ paintOnScreenEnv = qgetenv("QT_ONSCREEN_PAINT").toInt() > 0 ? 1 : 0;
+ if (paintOnScreenEnv == 1)
+ setAttribute(Qt::WA_PaintOnScreen);
+
+ if (QApplicationPrivate::testAttribute(Qt::AA_NativeWindows))
+ setAttribute(Qt::WA_NativeWindow);
+
+#ifdef ALIEN_DEBUG
+ qDebug() << "QWidget::create:" << this << "parent:" << parentWidget()
+ << "Alien?" << !testAttribute(Qt::WA_NativeWindow);
+#endif
+
+#if defined (Q_WS_WIN) && !defined(QT_NO_DRAGANDDROP)
+ // Unregister the dropsite (if already registered) before we
+ // re-create the widget with a native window.
+ if (testAttribute(Qt::WA_WState_Created) && !internalWinId() && testAttribute(Qt::WA_NativeWindow)
+ && d->extra && d->extra->dropTarget) {
+ d->registerDropSite(false);
+ }
+#endif // defined (Q_WS_WIN) && !defined(QT_NO_DRAGANDDROP)
+
+ d->updateIsOpaque();
+
+ setAttribute(Qt::WA_WState_Created); // set created flag
+ d->create_sys(window, initializeWindow, destroyOldWindow);
+
+ // a real toplevel window needs a backing store
+ if (isWindow() && windowType() != Qt::Desktop) {
+ d->topData()->backingStore.destroy();
+ if (hasBackingStoreSupport())
+ d->topData()->backingStore.create(this);
+ }
+
+ d->setModal_sys();
+
+ if (!isWindow() && parentWidget() && parentWidget()->testAttribute(Qt::WA_DropSiteRegistered))
+ setAttribute(Qt::WA_DropSiteRegistered, true);
+
+#ifdef QT_EVAL
+ extern void qt_eval_init_widget(QWidget *w);
+ qt_eval_init_widget(this);
+#endif
+
+ // need to force the resting of the icon after changing parents
+ if (testAttribute(Qt::WA_SetWindowIcon))
+ d->setWindowIcon_sys(true);
+ if (isWindow() && !d->topData()->iconText.isEmpty())
+ d->setWindowIconText_helper(d->topData()->iconText);
+ if (isWindow() && !d->topData()->caption.isEmpty())
+ d->setWindowTitle_helper(d->topData()->caption);
+ if (windowType() != Qt::Desktop) {
+ d->updateSystemBackground();
+
+ if (isWindow() && !testAttribute(Qt::WA_SetWindowIcon))
+ d->setWindowIcon_sys();
+ }
+}
+
+/*!
+ Destroys the widget.
+
+ All this widget's children are deleted first. The application
+ exits if this widget is the main widget.
+*/
+
+QWidget::~QWidget()
+{
+ Q_D(QWidget);
+ d->data.in_destructor = true;
+
+#if defined (QT_CHECK_STATE)
+ if (paintingActive())
+ qWarning("QWidget: %s (%s) deleted while being painted", className(), name());
+#endif
+
+#ifndef QT_NO_GESTURES
+ foreach (Qt::GestureType type, d->gestureContext.keys())
+ ungrabGesture(type);
+#endif
+
+ // force acceptDrops false before winId is destroyed.
+ d->registerDropSite(false);
+
+#ifndef QT_NO_ACTION
+ // remove all actions from this widget
+ for (int i = 0; i < d->actions.size(); ++i) {
+ QActionPrivate *apriv = d->actions.at(i)->d_func();
+ apriv->widgets.removeAll(this);
+ }
+ d->actions.clear();
+#endif
+
+#ifndef QT_NO_SHORTCUT
+ // Remove all shortcuts grabbed by this
+ // widget, unless application is closing
+ if (!QApplicationPrivate::is_app_closing && testAttribute(Qt::WA_GrabbedShortcut))
+ qApp->d_func()->shortcutMap.removeShortcut(0, this, QKeySequence());
+#endif
+
+ // delete layout while we still are a valid widget
+ delete d->layout;
+ d->layout = 0;
+ // Remove myself from focus list
+
+ Q_ASSERT(d->focus_next->d_func()->focus_prev == this);
+ Q_ASSERT(d->focus_prev->d_func()->focus_next == this);
+
+ if (d->focus_next != this) {
+ d->focus_next->d_func()->focus_prev = d->focus_prev;
+ d->focus_prev->d_func()->focus_next = d->focus_next;
+ d->focus_next = d->focus_prev = 0;
+ }
+
+#ifdef QT3_SUPPORT
+ if (QApplicationPrivate::main_widget == this) { // reset main widget
+ QApplicationPrivate::main_widget = 0;
+ QApplication::quit();
+ }
+#endif
+
+ QT_TRY {
+ clearFocus();
+ } QT_CATCH(...) {
+ // swallow this problem because we are in a destructor
+ }
+
+ d->setDirtyOpaqueRegion();
+
+ if (isWindow() && isVisible() && internalWinId()) {
+ QT_TRY {
+ d->close_helper(QWidgetPrivate::CloseNoEvent);
+ } QT_CATCH(...) {
+ // if we're out of memory, at least hide the window.
+ QT_TRY {
+ hide();
+ } QT_CATCH(...) {
+ // and if that also doesn't work, then give up
+ }
+ }
+ }
+
+#if defined(Q_WS_WIN) || defined(Q_WS_X11)|| defined(Q_WS_MAC)
+ else if (!internalWinId() && isVisible()) {
+ qApp->d_func()->sendSyntheticEnterLeave(this);
+ }
+#elif defined(Q_WS_QWS) || defined(Q_WS_QPA)
+ else if (isVisible()) {
+ qApp->d_func()->sendSyntheticEnterLeave(this);
+ }
+#endif
+
+#ifdef Q_OS_SYMBIAN
+ if (d->extra && d->extra->topextra && d->extra->topextra->backingStore) {
+ // Okay, we are about to destroy the top-level window that owns
+ // the backing store. Make sure we delete the backing store right away
+ // before the window handle is invalid. This is important because
+ // the backing store will delete its window surface, which may or may
+ // not have a reference to this widget that will be used later to
+ // notify the window it no longer has a surface.
+ d->extra->topextra->backingStore.destroy();
+ }
+#endif
+ if (QWidgetBackingStore *bs = d->maybeBackingStore()) {
+ bs->removeDirtyWidget(this);
+ if (testAttribute(Qt::WA_StaticContents))
+ bs->removeStaticWidget(this);
+ }
+
+ delete d->needsFlush;
+ d->needsFlush = 0;
+
+ // set all QPointers for this object to zero
+ if (d->hasGuards)
+ QObjectPrivate::clearGuards(this);
+
+ if (d->declarativeData) {
+ QAbstractDeclarativeData::destroyed(d->declarativeData, this);
+ d->declarativeData = 0; // don't activate again in ~QObject
+ }
+
+#ifdef QT_MAC_USE_COCOA
+ // QCocoaView holds a pointer back to this widget. Clear it now
+ // to make sure it's not followed later on. The lifetime of the
+ // QCocoaView might exceed the lifetime of this widget in cases
+ // where Cocoa itself holds references to it.
+ extern void qt_mac_clearCocoaViewQWidgetPointers(QWidget *);
+ qt_mac_clearCocoaViewQWidgetPointers(this);
+#endif
+
+ if (!d->children.isEmpty())
+ d->deleteChildren();
+
+ QApplication::removePostedEvents(this);
+
+ QT_TRY {
+ destroy(); // platform-dependent cleanup
+ } QT_CATCH(...) {
+ // if this fails we can't do anything about it but at least we are not allowed to throw.
+ }
+ --QWidgetPrivate::instanceCounter;
+
+ if (QWidgetPrivate::allWidgets) // might have been deleted by ~QApplication
+ QWidgetPrivate::allWidgets->remove(this);
+
+ QT_TRY {
+ QEvent e(QEvent::Destroy);
+ QCoreApplication::sendEvent(this, &e);
+ } QT_CATCH(const std::exception&) {
+ // if this fails we can't do anything about it but at least we are not allowed to throw.
+ }
+}
+
+int QWidgetPrivate::instanceCounter = 0; // Current number of widget instances
+int QWidgetPrivate::maxInstances = 0; // Maximum number of widget instances
+
+void QWidgetPrivate::setWinId(WId id) // set widget identifier
+{
+ Q_Q(QWidget);
+ // the user might create a widget with Qt::Desktop window
+ // attribute (or create another QDesktopWidget instance), which
+ // will have the same windowid (the root window id) as the
+ // qt_desktopWidget. We should not add the second desktop widget
+ // to the mapper.
+ bool userDesktopWidget = qt_desktopWidget != 0 && qt_desktopWidget != q && q->windowType() == Qt::Desktop;
+ if (mapper && data.winid && !userDesktopWidget) {
+ mapper->remove(data.winid);
+ }
+
+ const WId oldWinId = data.winid;
+
+ data.winid = id;
+#if defined(Q_WS_X11)
+ hd = id; // X11: hd == ident
+#endif
+ if (mapper && id && !userDesktopWidget) {
+ mapper->insert(data.winid, q);
+ }
+
+ if(oldWinId != id) {
+ QEvent e(QEvent::WinIdChange);
+ QCoreApplication::sendEvent(q, &e);
+ }
+}
+
+void QWidgetPrivate::createTLExtra()
+{
+ if (!extra)
+ createExtra();
+ if (!extra->topextra) {
+ QTLWExtra* x = extra->topextra = new QTLWExtra;
+ x->icon = 0;
+ x->iconPixmap = 0;
+ x->windowSurface = 0;
+ x->sharedPainter = 0;
+ x->incw = x->inch = 0;
+ x->basew = x->baseh = 0;
+ x->frameStrut.setCoords(0, 0, 0, 0);
+ x->normalGeometry = QRect(0,0,-1,-1);
+ x->savedFlags = 0;
+ x->opacity = 255;
+ x->posFromMove = false;
+ x->sizeAdjusted = false;
+ x->inTopLevelResize = false;
+ x->inRepaint = false;
+ x->embedded = 0;
+#ifdef Q_WS_MAC
+#ifdef QT_MAC_USE_COCOA
+ x->wasMaximized = false;
+#endif // QT_MAC_USE_COCOA
+#endif // Q_WS_MAC
+ createTLSysExtra();
+#ifdef QWIDGET_EXTRA_DEBUG
+ static int count = 0;
+ qDebug() << "tlextra" << ++count;
+#endif
+ }
+}
+
+/*!
+ \internal
+ Creates the widget extra data.
+*/
+
+void QWidgetPrivate::createExtra()
+{
+ if (!extra) { // if not exists
+ extra = new QWExtra;
+ extra->glContext = 0;
+ extra->topextra = 0;
+#ifndef QT_NO_GRAPHICSVIEW
+ extra->proxyWidget = 0;
+#endif
+#ifndef QT_NO_CURSOR
+ extra->curs = 0;
+#endif
+ extra->minw = 0;
+ extra->minh = 0;
+ extra->maxw = QWIDGETSIZE_MAX;
+ extra->maxh = QWIDGETSIZE_MAX;
+ extra->customDpiX = 0;
+ extra->customDpiY = 0;
+ extra->explicitMinSize = 0;
+ extra->explicitMaxSize = 0;
+ extra->autoFillBackground = 0;
+ extra->nativeChildrenForced = 0;
+ extra->inRenderWithPainter = 0;
+ extra->hasMask = 0;
+ createSysExtra();
+#ifdef QWIDGET_EXTRA_DEBUG
+ static int count = 0;
+ qDebug() << "extra" << ++count;
+#endif
+ }
+}
+
+
+/*!
+ \internal
+ Deletes the widget extra data.
+*/
+
+void QWidgetPrivate::deleteExtra()
+{
+ if (extra) { // if exists
+#ifndef QT_NO_CURSOR
+ delete extra->curs;
+#endif
+ deleteSysExtra();
+#ifndef QT_NO_STYLE_STYLESHEET
+ // dereference the stylesheet style
+ if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(extra->style))
+ proxy->deref();
+#endif
+ if (extra->topextra) {
+ deleteTLSysExtra();
+ extra->topextra->backingStore.destroy();
+ delete extra->topextra->icon;
+ delete extra->topextra->iconPixmap;
+#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER)
+ delete extra->topextra->qwsManager;
+#endif
+ delete extra->topextra->windowSurface;
+ delete extra->topextra;
+ }
+ delete extra;
+ // extra->xic destroyed in QWidget::destroy()
+ extra = 0;
+ }
+}
+
+/*
+ Returns true if there are widgets above this which overlap with
+ \a rect, which is in parent's coordinate system (same as crect).
+*/
+
+bool QWidgetPrivate::isOverlapped(const QRect &rect) const
+{
+ Q_Q(const QWidget);
+
+ const QWidget *w = q;
+ QRect r = rect;
+ while (w) {
+ if (w->isWindow())
+ return false;
+ QWidgetPrivate *pd = w->parentWidget()->d_func();
+ bool above = false;
+ for (int i = 0; i < pd->children.size(); ++i) {
+ QWidget *sibling = qobject_cast<QWidget *>(pd->children.at(i));
+ if (!sibling || !sibling->isVisible() || sibling->isWindow())
+ continue;
+ if (!above) {
+ above = (sibling == w);
+ continue;
+ }
+
+ if (qRectIntersects(sibling->d_func()->effectiveRectFor(sibling->data->crect), r)) {
+ const QWExtra *siblingExtra = sibling->d_func()->extra;
+ if (siblingExtra && siblingExtra->hasMask && !sibling->d_func()->graphicsEffect
+ && !siblingExtra->mask.translated(sibling->data->crect.topLeft()).intersects(r)) {
+ continue;
+ }
+ return true;
+ }
+ }
+ w = w->parentWidget();
+ r.translate(pd->data.crect.topLeft());
+ }
+ return false;
+}
+
+void QWidgetPrivate::syncBackingStore()
+{
+ if (paintOnScreen()) {
+ repaint_sys(dirty);
+ dirty = QRegion();
+ } else if (QWidgetBackingStore *bs = maybeBackingStore()) {
+ bs->sync();
+ }
+}
+
+void QWidgetPrivate::syncBackingStore(const QRegion &region)
+{
+ if (paintOnScreen())
+ repaint_sys(region);
+ else if (QWidgetBackingStore *bs = maybeBackingStore()) {
+ bs->sync(q_func(), region);
+ }
+}
+
+void QWidgetPrivate::setUpdatesEnabled_helper(bool enable)
+{
+ Q_Q(QWidget);
+
+ if (enable && !q->isWindow() && q->parentWidget() && !q->parentWidget()->updatesEnabled())
+ return; // nothing we can do
+
+ if (enable != q->testAttribute(Qt::WA_UpdatesDisabled))
+ return; // nothing to do
+
+ q->setAttribute(Qt::WA_UpdatesDisabled, !enable);
+ if (enable)
+ q->update();
+
+ Qt::WidgetAttribute attribute = enable ? Qt::WA_ForceUpdatesDisabled : Qt::WA_UpdatesDisabled;
+ for (int i = 0; i < children.size(); ++i) {
+ QWidget *w = qobject_cast<QWidget *>(children.at(i));
+ if (w && !w->isWindow() && !w->testAttribute(attribute))
+ w->d_func()->setUpdatesEnabled_helper(enable);
+ }
+}
+
+/*!
+ \internal
+
+ Propagate this widget's palette to all children, except style sheet
+ widgets, and windows that don't enable window propagation (palettes don't
+ normally propagate to windows).
+*/
+void QWidgetPrivate::propagatePaletteChange()
+{
+ Q_Q(QWidget);
+ // Propagate a new inherited mask to all children.
+#ifndef QT_NO_GRAPHICSVIEW
+ if (!q->parentWidget() && extra && extra->proxyWidget) {
+ QGraphicsProxyWidget *p = extra->proxyWidget;
+ inheritedPaletteResolveMask = p->d_func()->inheritedPaletteResolveMask | p->palette().resolve();
+ } else
+#endif //QT_NO_GRAPHICSVIEW
+ if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) {
+ inheritedPaletteResolveMask = 0;
+ }
+ int mask = data.pal.resolve() | inheritedPaletteResolveMask;
+
+ QEvent pc(QEvent::PaletteChange);
+ QApplication::sendEvent(q, &pc);
+ for (int i = 0; i < children.size(); ++i) {
+ QWidget *w = qobject_cast<QWidget*>(children.at(i));
+ if (w && !w->testAttribute(Qt::WA_StyleSheet)
+ && (!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))) {
+ QWidgetPrivate *wd = w->d_func();
+ wd->inheritedPaletteResolveMask = mask;
+ wd->resolvePalette();
+ }
+ }
+#if defined(QT3_SUPPORT)
+ q->paletteChange(q->palette()); // compatibility
+#endif
+}
+
+/*
+ Returns the widget's clipping rectangle.
+*/
+QRect QWidgetPrivate::clipRect() const
+{
+ Q_Q(const QWidget);
+ const QWidget * w = q;
+ if (!w->isVisible())
+ return QRect();
+ QRect r = effectiveRectFor(q->rect());
+ int ox = 0;
+ int oy = 0;
+ while (w
+ && w->isVisible()
+ && !w->isWindow()
+ && w->parentWidget()) {
+ ox -= w->x();
+ oy -= w->y();
+ w = w->parentWidget();
+ r &= QRect(ox, oy, w->width(), w->height());
+ }
+ return r;
+}
+
+/*
+ Returns the widget's clipping region (without siblings).
+*/
+QRegion QWidgetPrivate::clipRegion() const
+{
+ Q_Q(const QWidget);
+ if (!q->isVisible())
+ return QRegion();
+ QRegion r(q->rect());
+ const QWidget * w = q;
+ const QWidget *ignoreUpTo;
+ int ox = 0;
+ int oy = 0;
+ while (w
+ && w->isVisible()
+ && !w->isWindow()
+ && w->parentWidget()) {
+ ox -= w->x();
+ oy -= w->y();
+ ignoreUpTo = w;
+ w = w->parentWidget();
+ r &= QRegion(ox, oy, w->width(), w->height());
+
+ int i = 0;
+ while(w->d_func()->children.at(i++) != static_cast<const QObject *>(ignoreUpTo))
+ ;
+ for ( ; i < w->d_func()->children.size(); ++i) {
+ if(QWidget *sibling = qobject_cast<QWidget *>(w->d_func()->children.at(i))) {
+ if(sibling->isVisible() && !sibling->isWindow()) {
+ QRect siblingRect(ox+sibling->x(), oy+sibling->y(),
+ sibling->width(), sibling->height());
+ if (qRectIntersects(siblingRect, q->rect()))
+ r -= QRegion(siblingRect);
+ }
+ }
+ }
+ }
+ return r;
+}
+
+#ifndef QT_NO_GRAPHICSEFFECT
+void QWidgetPrivate::invalidateGraphicsEffectsRecursively()
+{
+ Q_Q(QWidget);
+ QWidget *w = q;
+ do {
+ if (w->graphicsEffect()) {
+ QWidgetEffectSourcePrivate *sourced =
+ static_cast<QWidgetEffectSourcePrivate *>(w->graphicsEffect()->source()->d_func());
+ if (!sourced->updateDueToGraphicsEffect)
+ w->graphicsEffect()->source()->d_func()->invalidateCache();
+ }
+ w = w->parentWidget();
+ } while (w);
+}
+#endif //QT_NO_GRAPHICSEFFECT
+
+void QWidgetPrivate::setDirtyOpaqueRegion()
+{
+ Q_Q(QWidget);
+
+ dirtyOpaqueChildren = true;
+
+#ifndef QT_NO_GRAPHICSEFFECT
+ invalidateGraphicsEffectsRecursively();
+#endif //QT_NO_GRAPHICSEFFECT
+
+ if (q->isWindow())
+ return;
+
+ QWidget *parent = q->parentWidget();
+ if (!parent)
+ return;
+
+ // TODO: instead of setting dirtyflag, manipulate the dirtyregion directly?
+ QWidgetPrivate *pd = parent->d_func();
+ if (!pd->dirtyOpaqueChildren)
+ pd->setDirtyOpaqueRegion();
+}
+
+const QRegion &QWidgetPrivate::getOpaqueChildren() const
+{
+ if (!dirtyOpaqueChildren)
+ return opaqueChildren;
+
+ QWidgetPrivate *that = const_cast<QWidgetPrivate*>(this);
+ that->opaqueChildren = QRegion();
+
+ for (int i = 0; i < children.size(); ++i) {
+ QWidget *child = qobject_cast<QWidget *>(children.at(i));
+ if (!child || !child->isVisible() || child->isWindow())
+ continue;
+
+ const QPoint offset = child->geometry().topLeft();
+ QWidgetPrivate *childd = child->d_func();
+ QRegion r = childd->isOpaque ? child->rect() : childd->getOpaqueChildren();
+ if (childd->extra && childd->extra->hasMask)
+ r &= childd->extra->mask;
+ if (r.isEmpty())
+ continue;
+ r.translate(offset);
+ that->opaqueChildren += r;
+ }
+
+ that->opaqueChildren &= q_func()->rect();
+ that->dirtyOpaqueChildren = false;
+
+ return that->opaqueChildren;
+}
+
+void QWidgetPrivate::subtractOpaqueChildren(QRegion &source, const QRect &clipRect) const
+{
+ if (children.isEmpty() || clipRect.isEmpty())
+ return;
+
+ const QRegion &r = getOpaqueChildren();
+ if (!r.isEmpty())
+ source -= (r & clipRect);
+}
+
+//subtract any relatives that are higher up than me --- this is too expensive !!!
+void QWidgetPrivate::subtractOpaqueSiblings(QRegion &sourceRegion, bool *hasDirtySiblingsAbove,
+ bool alsoNonOpaque) const
+{
+ Q_Q(const QWidget);
+ static int disableSubtractOpaqueSiblings = qgetenv("QT_NO_SUBTRACTOPAQUESIBLINGS").toInt();
+ if (disableSubtractOpaqueSiblings || q->isWindow())
+ return;
+
+#ifdef QT_MAC_USE_COCOA
+ if (q->d_func()->isInUnifiedToolbar)
+ return;
+#endif // QT_MAC_USE_COCOA
+
+ QRect clipBoundingRect;
+ bool dirtyClipBoundingRect = true;
+
+ QRegion parentClip;
+ bool dirtyParentClip = true;
+
+ QPoint parentOffset = data.crect.topLeft();
+
+ const QWidget *w = q;
+
+ while (w) {
+ if (w->isWindow())
+ break;
+ QWidgetPrivate *pd = w->parentWidget()->d_func();
+ const int myIndex = pd->children.indexOf(const_cast<QWidget *>(w));
+ const QRect widgetGeometry = w->d_func()->effectiveRectFor(w->data->crect);
+ for (int i = myIndex + 1; i < pd->children.size(); ++i) {
+ QWidget *sibling = qobject_cast<QWidget *>(pd->children.at(i));
+ if (!sibling || !sibling->isVisible() || sibling->isWindow())
+ continue;
+
+ const QRect siblingGeometry = sibling->d_func()->effectiveRectFor(sibling->data->crect);
+ if (!qRectIntersects(siblingGeometry, widgetGeometry))
+ continue;
+
+ if (dirtyClipBoundingRect) {
+ clipBoundingRect = sourceRegion.boundingRect();
+ dirtyClipBoundingRect = false;
+ }
+
+ if (!qRectIntersects(siblingGeometry, clipBoundingRect.translated(parentOffset)))
+ continue;
+
+ if (dirtyParentClip) {
+ parentClip = sourceRegion.translated(parentOffset);
+ dirtyParentClip = false;
+ }
+
+ const QPoint siblingPos(sibling->data->crect.topLeft());
+ const QRect siblingClipRect(sibling->d_func()->clipRect());
+ QRegion siblingDirty(parentClip);
+ siblingDirty &= (siblingClipRect.translated(siblingPos));
+ const bool hasMask = sibling->d_func()->extra && sibling->d_func()->extra->hasMask
+ && !sibling->d_func()->graphicsEffect;
+ if (hasMask)
+ siblingDirty &= sibling->d_func()->extra->mask.translated(siblingPos);
+ if (siblingDirty.isEmpty())
+ continue;
+
+ if (sibling->d_func()->isOpaque || alsoNonOpaque) {
+ if (hasMask) {
+ siblingDirty.translate(-parentOffset);
+ sourceRegion -= siblingDirty;
+ } else {
+ sourceRegion -= siblingGeometry.translated(-parentOffset);
+ }
+ } else {
+ if (hasDirtySiblingsAbove)
+ *hasDirtySiblingsAbove = true;
+ if (sibling->d_func()->children.isEmpty())
+ continue;
+ QRegion opaqueSiblingChildren(sibling->d_func()->getOpaqueChildren());
+ opaqueSiblingChildren.translate(-parentOffset + siblingPos);
+ sourceRegion -= opaqueSiblingChildren;
+ }
+ if (sourceRegion.isEmpty())
+ return;
+
+ dirtyClipBoundingRect = true;
+ dirtyParentClip = true;
+ }
+
+ w = w->parentWidget();
+ parentOffset += pd->data.crect.topLeft();
+ dirtyParentClip = true;
+ }
+}
+
+void QWidgetPrivate::clipToEffectiveMask(QRegion &region) const
+{
+ Q_Q(const QWidget);
+
+ const QWidget *w = q;
+ QPoint offset;
+
+#ifndef QT_NO_GRAPHICSEFFECT
+ if (graphicsEffect) {
+ w = q->parentWidget();
+ offset -= data.crect.topLeft();
+ }
+#endif //QT_NO_GRAPHICSEFFECT
+
+ while (w) {
+ const QWidgetPrivate *wd = w->d_func();
+ if (wd->extra && wd->extra->hasMask)
+ region &= (w != q) ? wd->extra->mask.translated(offset) : wd->extra->mask;
+ if (w->isWindow())
+ return;
+ offset -= wd->data.crect.topLeft();
+ w = w->parentWidget();
+ }
+}
+
+bool QWidgetPrivate::paintOnScreen() const
+{
+#if defined(Q_WS_QWS)
+ return false;
+#elif defined(QT_NO_BACKINGSTORE)
+ return true;
+#else
+ Q_Q(const QWidget);
+ if (q->testAttribute(Qt::WA_PaintOnScreen)
+ || (!q->isWindow() && q->window()->testAttribute(Qt::WA_PaintOnScreen))) {
+ return true;
+ }
+
+ return !qt_enable_backingstore;
+#endif
+}
+
+void QWidgetPrivate::updateIsOpaque()
+{
+ // hw: todo: only needed if opacity actually changed
+ setDirtyOpaqueRegion();
+
+#ifndef QT_NO_GRAPHICSEFFECT
+ if (graphicsEffect) {
+ // ### We should probably add QGraphicsEffect::isOpaque at some point.
+ setOpaque(false);
+ return;
+ }
+#endif //QT_NO_GRAPHICSEFFECT
+
+ Q_Q(QWidget);
+#ifdef Q_WS_X11
+ if (q->testAttribute(Qt::WA_X11OpenGLOverlay)) {
+ setOpaque(false);
+ return;
+ }
+#endif
+
+#ifdef Q_WS_S60
+ if (q->windowType() == Qt::Dialog && q->testAttribute(Qt::WA_TranslucentBackground)
+ && S60->avkonComponentsSupportTransparency) {
+ setOpaque(false);
+ return;
+ }
+#endif
+
+ if (q->testAttribute(Qt::WA_OpaquePaintEvent) || q->testAttribute(Qt::WA_PaintOnScreen)) {
+ setOpaque(true);
+ return;
+ }
+
+ const QPalette &pal = q->palette();
+
+ if (q->autoFillBackground()) {
+ const QBrush &autoFillBrush = pal.brush(q->backgroundRole());
+ if (autoFillBrush.style() != Qt::NoBrush && autoFillBrush.isOpaque()) {
+ setOpaque(true);
+ return;
+ }
+ }
+
+ if (q->isWindow() && !q->testAttribute(Qt::WA_NoSystemBackground)) {
+ const QBrush &windowBrush = q->palette().brush(QPalette::Window);
+ if (windowBrush.style() != Qt::NoBrush && windowBrush.isOpaque()) {
+ setOpaque(true);
+ return;
+ }
+ }
+ setOpaque(false);
+}
+
+void QWidgetPrivate::setOpaque(bool opaque)
+{
+ if (isOpaque == opaque)
+ return;
+ isOpaque = opaque;
+#ifdef Q_WS_MAC
+ macUpdateIsOpaque();
+#endif
+#ifdef Q_WS_X11
+ x11UpdateIsOpaque();
+#endif
+#ifdef Q_WS_WIN
+ winUpdateIsOpaque();
+#endif
+#ifdef Q_OS_SYMBIAN
+ s60UpdateIsOpaque();
+#endif
+}
+
+void QWidgetPrivate::updateIsTranslucent()
+{
+#ifdef Q_WS_MAC
+ macUpdateIsOpaque();
+#endif
+#ifdef Q_WS_X11
+ x11UpdateIsOpaque();
+#endif
+#ifdef Q_WS_WIN
+ winUpdateIsOpaque();
+#endif
+#ifdef Q_OS_SYMBIAN
+ s60UpdateIsOpaque();
+#endif
+}
+
+static inline void fillRegion(QPainter *painter, const QRegion &rgn, const QBrush &brush)
+{
+ Q_ASSERT(painter);
+
+ if (brush.style() == Qt::TexturePattern) {
+#ifdef Q_WS_MAC
+ // Optimize pattern filling on mac by using HITheme directly
+ // when filling with the standard widget background.
+ // Defined in qmacstyle_mac.cpp
+ extern void qt_mac_fill_background(QPainter *painter, const QRegion &rgn, const QBrush &brush);
+ qt_mac_fill_background(painter, rgn, brush);
+#else
+#if !defined(QT_NO_STYLE_S60)
+ // Defined in qs60style.cpp
+ extern bool qt_s60_fill_background(QPainter *painter, const QRegion &rgn, const QBrush &brush);
+ if (!qt_s60_fill_background(painter, rgn, brush))
+#endif // !defined(QT_NO_STYLE_S60)
+ {
+ const QRect rect(rgn.boundingRect());
+ painter->setClipRegion(rgn);
+ painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft());
+ }
+#endif // Q_WS_MAC
+
+ } else if (brush.gradient()
+ && brush.gradient()->coordinateMode() == QGradient::ObjectBoundingMode) {
+ painter->save();
+ painter->setClipRegion(rgn);
+ painter->fillRect(0, 0, painter->device()->width(), painter->device()->height(), brush);
+ painter->restore();
+ } else {
+ const QVector<QRect> &rects = rgn.rects();
+ for (int i = 0; i < rects.size(); ++i)
+ painter->fillRect(rects.at(i), brush);
+ }
+}
+
+void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, int flags) const
+{
+ Q_Q(const QWidget);
+
+#ifndef QT_NO_SCROLLAREA
+ bool resetBrushOrigin = false;
+ QPointF oldBrushOrigin;
+ //If we are painting the viewport of a scrollarea, we must apply an offset to the brush in case we are drawing a texture
+ QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(parent);
+ if (scrollArea && scrollArea->viewport() == q) {
+ QObjectData *scrollPrivate = static_cast<QWidget *>(scrollArea)->d_ptr.data();
+ QAbstractScrollAreaPrivate *priv = static_cast<QAbstractScrollAreaPrivate *>(scrollPrivate);
+ oldBrushOrigin = painter->brushOrigin();
+ resetBrushOrigin = true;
+ painter->setBrushOrigin(-priv->contentsOffset());
+
+ }
+#endif // QT_NO_SCROLLAREA
+
+ const QBrush autoFillBrush = q->palette().brush(q->backgroundRole());
+
+ if ((flags & DrawAsRoot) && !(q->autoFillBackground() && autoFillBrush.isOpaque())) {
+ const QBrush bg = q->palette().brush(QPalette::Window);
+#ifdef Q_WS_QWS
+ if (!(flags & DontSetCompositionMode) && painter->paintEngine()->hasFeature(QPaintEngine::PorterDuff))
+ painter->setCompositionMode(QPainter::CompositionMode_Source); //copy alpha straight in
+#endif
+ fillRegion(painter, rgn, bg);
+ }
+
+ if (q->autoFillBackground())
+ fillRegion(painter, rgn, autoFillBrush);
+
+ if (q->testAttribute(Qt::WA_StyledBackground)) {
+ painter->setClipRegion(rgn);
+ QStyleOption opt;
+ opt.initFrom(q);
+ q->style()->drawPrimitive(QStyle::PE_Widget, &opt, painter, q);
+ }
+
+#ifndef QT_NO_SCROLLAREA
+ if (resetBrushOrigin)
+ painter->setBrushOrigin(oldBrushOrigin);
+#endif // QT_NO_SCROLLAREA
+}
+
+/*
+ \internal
+ This function is called when a widget is hidden or destroyed.
+ It resets some application global pointers that should only refer active,
+ visible widgets.
+*/
+
+#ifdef Q_WS_MAC
+ extern QPointer<QWidget> qt_button_down;
+#else
+ extern QWidget *qt_button_down;
+#endif
+
+void QWidgetPrivate::deactivateWidgetCleanup()
+{
+ Q_Q(QWidget);
+ // If this was the active application window, reset it
+ if (QApplication::activeWindow() == q)
+ QApplication::setActiveWindow(0);
+ // If the is the active mouse press widget, reset it
+ if (q == qt_button_down)
+ qt_button_down = 0;
+}
+
+
+/*!
+ Returns a pointer to the widget with window identifer/handle \a
+ id.
+
+ The window identifier type depends on the underlying window
+ system, see \c qwindowdefs.h for the actual definition. If there
+ is no widget with this identifier, 0 is returned.
+*/
+
+QWidget *QWidget::find(WId id)
+{
+ return QWidgetPrivate::mapper ? QWidgetPrivate::mapper->value(id, 0) : 0;
+}
+
+
+
+/*!
+ \fn WId QWidget::internalWinId() const
+ \internal
+ Returns the window system identifier of the widget, or 0 if the widget is not created yet.
+
+*/
+
+/*!
+ \fn WId QWidget::winId() const
+
+ Returns the window system identifier of the widget.
+
+ Portable in principle, but if you use it you are probably about to
+ do something non-portable. Be careful.
+
+ If a widget is non-native (alien) and winId() is invoked on it, that widget
+ will be provided a native handle.
+
+ On Mac OS X, the type returned depends on which framework Qt was linked
+ against. If Qt is using Carbon, the {WId} is actually an HIViewRef. If Qt
+ is using Cocoa, {WId} is a pointer to an NSView.
+
+ This value may change at run-time. An event with type QEvent::WinIdChange
+ will be sent to the widget following a change in window system identifier.
+
+ \sa find()
+*/
+WId QWidget::winId() const
+{
+ if (!testAttribute(Qt::WA_WState_Created) || !internalWinId()) {
+#ifdef ALIEN_DEBUG
+ qDebug() << "QWidget::winId: creating native window for" << this;
+#endif
+ QWidget *that = const_cast<QWidget*>(this);
+#ifndef Q_WS_QPA
+ that->setAttribute(Qt::WA_NativeWindow);
+#endif
+ that->d_func()->createWinId();
+ return that->data->winid;
+ }
+ return data->winid;
+}
+
+
+void QWidgetPrivate::createWinId(WId winid)
+{
+ Q_Q(QWidget);
+
+#ifdef ALIEN_DEBUG
+ qDebug() << "QWidgetPrivate::createWinId for" << q << winid;
+#endif
+ const bool forceNativeWindow = q->testAttribute(Qt::WA_NativeWindow);
+ if (!q->testAttribute(Qt::WA_WState_Created) || (forceNativeWindow && !q->internalWinId())) {
+#ifndef Q_WS_QPA
+ if (!q->isWindow()) {
+ QWidget *parent = q->parentWidget();
+ QWidgetPrivate *pd = parent->d_func();
+ if (forceNativeWindow && !q->testAttribute(Qt::WA_DontCreateNativeAncestors))
+ parent->setAttribute(Qt::WA_NativeWindow);
+ if (!parent->internalWinId()) {
+ pd->createWinId();
+ }
+
+ for (int i = 0; i < pd->children.size(); ++i) {
+ QWidget *w = qobject_cast<QWidget *>(pd->children.at(i));
+ if (w && !w->isWindow() && (!w->testAttribute(Qt::WA_WState_Created)
+ || (!w->internalWinId() && w->testAttribute(Qt::WA_NativeWindow)))) {
+ if (w!=q) {
+ w->create();
+ } else {
+ w->create(winid);
+ // if the window has already been created, we
+ // need to raise it to its proper stacking position
+ if (winid)
+ w->raise();
+ }
+ }
+ }
+ } else {
+ q->create();
+ }
+#else
+ Q_UNUSED(winid);
+ q->create();
+#endif //Q_WS_QPA
+
+ }
+}
+
+
+/*!
+\internal
+Ensures that the widget has a window system identifier, i.e. that it is known to the windowing system.
+
+*/
+
+void QWidget::createWinId()
+{
+ Q_D(QWidget);
+#ifdef ALIEN_DEBUG
+ qDebug() << "QWidget::createWinId" << this;
+#endif
+// qWarning("QWidget::createWinId is obsolete, please fix your code.");
+ d->createWinId();
+}
+
+/*!
+ \since 4.4
+
+ Returns the effective window system identifier of the widget, i.e. the
+ native parent's window system identifier.
+
+ If the widget is native, this function returns the native widget ID.
+ Otherwise, the window ID of the first native parent widget, i.e., the
+ top-level widget that contains this widget, is returned.
+
+ \note We recommend that you do not store this value as it is likely to
+ change at run-time.
+
+ \sa nativeParentWidget()
+*/
+WId QWidget::effectiveWinId() const
+{
+ WId id = internalWinId();
+ if (id || !testAttribute(Qt::WA_WState_Created))
+ return id;
+ QWidget *realParent = nativeParentWidget();
+ Q_ASSERT(realParent);
+ Q_ASSERT(realParent->internalWinId());
+ return realParent->internalWinId();
+}
+
+#ifndef QT_NO_STYLE_STYLESHEET
+
+/*!
+ \property QWidget::styleSheet
+ \brief the widget's style sheet
+ \since 4.2
+
+ The style sheet contains a textual description of customizations to the
+ widget's style, as described in the \l{Qt Style Sheets} document.
+
+ Since Qt 4.5, Qt style sheets fully supports Mac OS X.
+
+ \warning Qt style sheets are currently not supported for custom QStyle
+ subclasses. We plan to address this in some future release.
+
+ \sa setStyle(), QApplication::styleSheet, {Qt Style Sheets}
+*/
+QString QWidget::styleSheet() const
+{
+ Q_D(const QWidget);
+ if (!d->extra)
+ return QString();
+ return d->extra->styleSheet;
+}
+
+void QWidget::setStyleSheet(const QString& styleSheet)
+{
+ Q_D(QWidget);
+ d->createExtra();
+
+ QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(d->extra->style);
+ d->extra->styleSheet = styleSheet;
+ if (styleSheet.isEmpty()) { // stylesheet removed
+ if (!proxy)
+ return;
+
+ d->inheritStyle();
+ return;
+ }
+
+ if (proxy) { // style sheet update
+ proxy->repolish(this);
+ return;
+ }
+
+ if (testAttribute(Qt::WA_SetStyle)) {
+ d->setStyle_helper(new QStyleSheetStyle(d->extra->style), true);
+ } else {
+ d->setStyle_helper(new QStyleSheetStyle(0), true);
+ }
+}
+
+#endif // QT_NO_STYLE_STYLESHEET
+
+/*!
+ \sa QWidget::setStyle(), QApplication::setStyle(), QApplication::style()
+*/
+
+QStyle *QWidget::style() const
+{
+ Q_D(const QWidget);
+
+ if (d->extra && d->extra->style)
+ return d->extra->style;
+ return QApplication::style();
+}
+
+/*!
+ Sets the widget's GUI style to \a style. The ownership of the style
+ object is not transferred.
+
+ If no style is set, the widget uses the application's style,
+ QApplication::style() instead.
+
+ Setting a widget's style has no effect on existing or future child
+ widgets.
+
+ \warning This function is particularly useful for demonstration
+ purposes, where you want to show Qt's styling capabilities. Real
+ applications should avoid it and use one consistent GUI style
+ instead.
+
+ \warning Qt style sheets are currently not supported for custom QStyle
+ subclasses. We plan to address this in some future release.
+
+ \sa style(), QStyle, QApplication::style(), QApplication::setStyle()
+*/
+
+void QWidget::setStyle(QStyle *style)
+{
+ Q_D(QWidget);
+ setAttribute(Qt::WA_SetStyle, style != 0);
+ d->createExtra();
+#ifndef QT_NO_STYLE_STYLESHEET
+ if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(style)) {
+ //if for some reason someone try to set a QStyleSheetStyle, ref it
+ //(this may happen for exemple in QButtonDialogBox which propagates its style)
+ proxy->ref();
+ d->setStyle_helper(style, false);
+ } else if (qobject_cast<QStyleSheetStyle *>(d->extra->style) || !qApp->styleSheet().isEmpty()) {
+ // if we have an application stylesheet or have a proxy already, propagate
+ d->setStyle_helper(new QStyleSheetStyle(style), true);
+ } else
+#endif
+ d->setStyle_helper(style, false);
+}
+
+void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate, bool
+#ifdef Q_WS_MAC
+ metalHack
+#endif
+ )
+{
+ Q_Q(QWidget);
+ QStyle *oldStyle = q->style();
+#ifndef QT_NO_STYLE_STYLESHEET
+ QWeakPointer<QStyle> origStyle;
+#endif
+
+#ifdef Q_WS_MAC
+ // the metalhack boolean allows Qt/Mac to do a proper re-polish depending
+ // on how the Qt::WA_MacBrushedMetal attribute is set. It is only ever
+ // set when changing that attribute and passes the widget's CURRENT style.
+ // therefore no need to do a reassignment.
+ if (!metalHack)
+#endif
+ {
+ createExtra();
+
+#ifndef QT_NO_STYLE_STYLESHEET
+ origStyle = extra->style.data();
+#endif
+ extra->style = newStyle;
+ }
+
+ // repolish
+ if (q->windowType() != Qt::Desktop) {
+ if (polished) {
+ oldStyle->unpolish(q);
+#ifdef Q_WS_MAC
+ if (metalHack)
+ macUpdateMetalAttribute();
+#endif
+ q->style()->polish(q);
+#ifdef Q_WS_MAC
+ } else if (metalHack) {
+ macUpdateMetalAttribute();
+#endif
+ }
+ }
+
+ if (propagate) {
+ for (int i = 0; i < children.size(); ++i) {
+ QWidget *c = qobject_cast<QWidget*>(children.at(i));
+ if (c)
+ c->d_func()->inheritStyle();
+ }
+ }
+
+#ifndef QT_NO_STYLE_STYLESHEET
+ if (!qobject_cast<QStyleSheetStyle*>(newStyle)) {
+ if (const QStyleSheetStyle* cssStyle = qobject_cast<QStyleSheetStyle*>(origStyle.data())) {
+ cssStyle->clearWidgetFont(q);
+ }
+ }
+#endif
+
+ QEvent e(QEvent::StyleChange);
+ QApplication::sendEvent(q, &e);
+#ifdef QT3_SUPPORT
+ q->styleChange(*oldStyle);
+#endif
+
+#ifndef QT_NO_STYLE_STYLESHEET
+ // dereference the old stylesheet style
+ if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(origStyle.data()))
+ proxy->deref();
+#endif
+}
+
+// Inherits style from the current parent and propagates it as necessary
+void QWidgetPrivate::inheritStyle()
+{
+#ifndef QT_NO_STYLE_STYLESHEET
+ Q_Q(QWidget);
+
+ QStyleSheetStyle *proxy = extra ? qobject_cast<QStyleSheetStyle *>(extra->style) : 0;
+
+ if (!q->styleSheet().isEmpty()) {
+ Q_ASSERT(proxy);
+ proxy->repolish(q);
+ return;
+ }
+
+ QStyle *origStyle = proxy ? proxy->base : (extra ? (QStyle*)extra->style : 0);
+ QWidget *parent = q->parentWidget();
+ QStyle *parentStyle = (parent && parent->d_func()->extra) ? (QStyle*)parent->d_func()->extra->style : 0;
+ // If we have stylesheet on app or parent has stylesheet style, we need
+ // to be running a proxy
+ if (!qApp->styleSheet().isEmpty() || qobject_cast<QStyleSheetStyle *>(parentStyle)) {
+ QStyle *newStyle = parentStyle;
+ if (q->testAttribute(Qt::WA_SetStyle))
+ newStyle = new QStyleSheetStyle(origStyle);
+ else if (QStyleSheetStyle *newProxy = qobject_cast<QStyleSheetStyle *>(parentStyle))
+ newProxy->ref();
+
+ setStyle_helper(newStyle, true);
+ return;
+ }
+
+ // So, we have no stylesheet on parent/app and we have an empty stylesheet
+ // we just need our original style back
+ if (origStyle == (extra ? (QStyle*)extra->style : 0)) // is it any different?
+ return;
+
+ // We could have inherited the proxy from our parent (which has a custom style)
+ // In such a case we need to start following the application style (i.e revert
+ // the propagation behavior of QStyleSheetStyle)
+ if (!q->testAttribute(Qt::WA_SetStyle))
+ origStyle = 0;
+
+ setStyle_helper(origStyle, true);
+#endif // QT_NO_STYLE_STYLESHEET
+}
+
+#ifdef QT3_SUPPORT
+/*!
+ \overload
+
+ Sets the widget's GUI style to \a style using the QStyleFactory.
+*/
+QStyle* QWidget::setStyle(const QString &style)
+{
+ QStyle *s = QStyleFactory::create(style);
+ setStyle(s);
+ return s;
+}
+#endif
+
+/*!
+ \fn bool QWidget::isWindow() const
+
+ Returns true if the widget is an independent window, otherwise
+ returns false.
+
+ A window is a widget that isn't visually the child of any other
+ widget and that usually has a frame and a
+ \l{QWidget::setWindowTitle()}{window title}.
+
+ A window can have a \l{QWidget::parentWidget()}{parent widget}.
+ It will then be grouped with its parent and deleted when the
+ parent is deleted, minimized when the parent is minimized etc. If
+ supported by the window manager, it will also have a common
+ taskbar entry with its parent.
+
+ QDialog and QMainWindow widgets are by default windows, even if a
+ parent widget is specified in the constructor. This behavior is
+ specified by the Qt::Window flag.
+
+ \sa window(), isModal(), parentWidget()
+*/
+
+/*!
+ \property QWidget::modal
+ \brief whether the widget is a modal widget
+
+ This property only makes sense for windows. A modal widget
+ prevents widgets in all other windows from getting any input.
+
+ By default, this property is false.
+
+ \sa isWindow(), windowModality, QDialog
+*/
+
+/*!
+ \property QWidget::windowModality
+ \brief which windows are blocked by the modal widget
+ \since 4.1
+
+ This property only makes sense for windows. A modal widget
+ prevents widgets in other windows from getting input. The value of
+ this property controls which windows are blocked when the widget
+ is visible. Changing this property while the window is visible has
+ no effect; you must hide() the widget first, then show() it again.
+
+ By default, this property is Qt::NonModal.
+
+ \sa isWindow(), QWidget::modal, QDialog
+*/
+
+Qt::WindowModality QWidget::windowModality() const
+{
+ return static_cast<Qt::WindowModality>(data->window_modality);
+}
+
+void QWidget::setWindowModality(Qt::WindowModality windowModality)
+{
+ data->window_modality = windowModality;
+ // setModal_sys() will be called by setAttribute()
+ setAttribute(Qt::WA_ShowModal, (data->window_modality != Qt::NonModal));
+ setAttribute(Qt::WA_SetWindowModality, true);
+}
+
+/*!
+ \fn bool QWidget::underMouse() const
+
+ Returns true if the widget is under the mouse cursor; otherwise
+ returns false.
+
+ This value is not updated properly during drag and drop
+ operations.
+
+ \sa enterEvent(), leaveEvent()
+*/
+
+/*!
+ \property QWidget::minimized
+ \brief whether this widget is minimized (iconified)
+
+ This property is only relevant for windows.
+
+ By default, this property is false.
+
+ \sa showMinimized(), visible, show(), hide(), showNormal(), maximized
+*/
+bool QWidget::isMinimized() const
+{ return data->window_state & Qt::WindowMinimized; }
+
+/*!
+ Shows the widget minimized, as an icon.
+
+ Calling this function only affects \l{isWindow()}{windows}.
+
+ \sa showNormal(), showMaximized(), show(), hide(), isVisible(),
+ isMinimized()
+*/
+void QWidget::showMinimized()
+{
+ bool isMin = isMinimized();
+ if (isMin && isVisible())
+ return;
+
+ ensurePolished();
+#ifdef QT3_SUPPORT
+ if (parent())
+ QApplication::sendPostedEvents(parent(), QEvent::ChildInserted);
+#endif
+
+ if (!isMin)
+ setWindowState((windowState() & ~Qt::WindowActive) | Qt::WindowMinimized);
+ show();
+}
+
+/*!
+ \property QWidget::maximized
+ \brief whether this widget is maximized
+
+ This property is only relevant for windows.
+
+ \note Due to limitations on some window systems, this does not always
+ report the expected results (e.g., if the user on X11 maximizes the
+ window via the window manager, Qt has no way of distinguishing this
+ from any other resize). This is expected to improve as window manager
+ protocols evolve.
+
+ By default, this property is false.
+
+ \sa windowState(), showMaximized(), visible, show(), hide(), showNormal(), minimized
+*/
+bool QWidget::isMaximized() const
+{ return data->window_state & Qt::WindowMaximized; }
+
+
+
+/*!
+ Returns the current window state. The window state is a OR'ed
+ combination of Qt::WindowState: Qt::WindowMinimized,
+ Qt::WindowMaximized, Qt::WindowFullScreen, and Qt::WindowActive.
+
+ \sa Qt::WindowState setWindowState()
+ */
+Qt::WindowStates QWidget::windowState() const
+{
+ return Qt::WindowStates(data->window_state);
+}
+
+/*!\internal
+
+ The function sets the window state on child widgets similar to
+ setWindowState(). The difference is that the window state changed
+ event has the isOverride() flag set. It exists mainly to keep
+ Q3Workspace working.
+ */
+void QWidget::overrideWindowState(Qt::WindowStates newstate)
+{
+ QWindowStateChangeEvent e(Qt::WindowStates(data->window_state), true);
+ data->window_state = newstate;
+ QApplication::sendEvent(this, &e);
+}
+
+/*!
+ \fn void QWidget::setWindowState(Qt::WindowStates windowState)
+
+ Sets the window state to \a windowState. The window state is a OR'ed
+ combination of Qt::WindowState: Qt::WindowMinimized,
+ Qt::WindowMaximized, Qt::WindowFullScreen, and Qt::WindowActive.
+
+ If the window is not visible (i.e. isVisible() returns false), the
+ window state will take effect when show() is called. For visible
+ windows, the change is immediate. For example, to toggle between
+ full-screen and normal mode, use the following code:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 0
+
+ In order to restore and activate a minimized window (while
+ preserving its maximized and/or full-screen state), use the following:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 1
+
+ Calling this function will hide the widget. You must call show() to make
+ the widget visible again.
+
+ \note On some window systems Qt::WindowActive is not immediate, and may be
+ ignored in certain cases.
+
+ When the window state changes, the widget receives a changeEvent()
+ of type QEvent::WindowStateChange.
+
+ \sa Qt::WindowState windowState()
+*/
+
+/*!
+ \property QWidget::fullScreen
+ \brief whether the widget is shown in full screen mode
+
+ A widget in full screen mode occupies the whole screen area and does not
+ display window decorations, such as a title bar.
+
+ By default, this property is false.
+
+ \sa windowState(), minimized, maximized
+*/
+bool QWidget::isFullScreen() const
+{ return data->window_state & Qt::WindowFullScreen; }
+
+/*!
+ Shows the widget in full-screen mode.
+
+ Calling this function only affects \l{isWindow()}{windows}.
+
+ To return from full-screen mode, call showNormal().
+
+ Full-screen mode works fine under Windows, but has certain
+ problems under X. These problems are due to limitations of the
+ ICCCM protocol that specifies the communication between X11
+ clients and the window manager. ICCCM simply does not understand
+ the concept of non-decorated full-screen windows. Therefore, the
+ best we can do is to request a borderless window and place and
+ resize it to fill the entire screen. Depending on the window
+ manager, this may or may not work. The borderless window is
+ requested using MOTIF hints, which are at least partially
+ supported by virtually all modern window managers.
+
+ An alternative would be to bypass the window manager entirely and
+ create a window with the Qt::X11BypassWindowManagerHint flag. This
+ has other severe problems though, like totally broken keyboard focus
+ and very strange effects on desktop changes or when the user raises
+ other windows.
+
+ X11 window managers that follow modern post-ICCCM specifications
+ support full-screen mode properly.
+
+ \sa showNormal(), showMaximized(), show(), hide(), isVisible()
+*/
+void QWidget::showFullScreen()
+{
+#ifdef Q_WS_MAC
+ // If the unified toolbar is enabled, we have to disable it before going fullscreen.
+ QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this);
+ if (mainWindow && mainWindow->unifiedTitleAndToolBarOnMac()) {
+ mainWindow->setUnifiedTitleAndToolBarOnMac(false);
+ QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout());
+ mainLayout->activateUnifiedToolbarAfterFullScreen = true;
+ }
+#endif // Q_WS_MAC
+ ensurePolished();
+#ifdef QT3_SUPPORT
+ if (parent())
+ QApplication::sendPostedEvents(parent(), QEvent::ChildInserted);
+#endif
+
+ setWindowState((windowState() & ~(Qt::WindowMinimized | Qt::WindowMaximized))
+ | Qt::WindowFullScreen);
+ show();
+ activateWindow();
+}
+
+/*!
+ Shows the widget maximized.
+
+ Calling this function only affects \l{isWindow()}{windows}.
+
+ On X11, this function may not work properly with certain window
+ managers. See the \l{Window Geometry} documentation for an explanation.
+
+ \sa setWindowState(), showNormal(), showMinimized(), show(), hide(), isVisible()
+*/
+void QWidget::showMaximized()
+{
+ ensurePolished();
+#ifdef QT3_SUPPORT
+ if (parent())
+ QApplication::sendPostedEvents(parent(), QEvent::ChildInserted);
+#endif
+
+ setWindowState((windowState() & ~(Qt::WindowMinimized | Qt::WindowFullScreen))
+ | Qt::WindowMaximized);
+#ifdef Q_WS_MAC
+ // If the unified toolbar was enabled before going fullscreen, we have to enable it back.
+ QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this);
+ if (mainWindow)
+ {
+ QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout());
+ if (mainLayout->activateUnifiedToolbarAfterFullScreen) {
+ mainWindow->setUnifiedTitleAndToolBarOnMac(true);
+ mainLayout->activateUnifiedToolbarAfterFullScreen = false;
+ }
+ }
+#endif // Q_WS_MAC
+ show();
+}
+
+/*!
+ Restores the widget after it has been maximized or minimized.
+
+ Calling this function only affects \l{isWindow()}{windows}.
+
+ \sa setWindowState(), showMinimized(), showMaximized(), show(), hide(), isVisible()
+*/
+void QWidget::showNormal()
+{
+ ensurePolished();
+#ifdef QT3_SUPPORT
+ if (parent())
+ QApplication::sendPostedEvents(parent(), QEvent::ChildInserted);
+#endif
+
+ setWindowState(windowState() & ~(Qt::WindowMinimized
+ | Qt::WindowMaximized
+ | Qt::WindowFullScreen));
+#ifdef Q_WS_MAC
+ // If the unified toolbar was enabled before going fullscreen, we have to enable it back.
+ QMainWindow *mainWindow = qobject_cast<QMainWindow*>(this);
+ if (mainWindow)
+ {
+ QMainWindowLayout *mainLayout = qobject_cast<QMainWindowLayout*>(mainWindow->layout());
+ if (mainLayout->activateUnifiedToolbarAfterFullScreen) {
+ mainWindow->setUnifiedTitleAndToolBarOnMac(true);
+ mainLayout->activateUnifiedToolbarAfterFullScreen = false;
+ }
+ }
+#endif // Q_WS_MAC
+ show();
+}
+
+/*!
+ Returns true if this widget would become enabled if \a ancestor is
+ enabled; otherwise returns false.
+
+
+
+ This is the case if neither the widget itself nor every parent up
+ to but excluding \a ancestor has been explicitly disabled.
+
+ isEnabledTo(0) is equivalent to isEnabled().
+
+ \sa setEnabled() enabled
+*/
+
+bool QWidget::isEnabledTo(QWidget* ancestor) const
+{
+ const QWidget * w = this;
+ while (!w->testAttribute(Qt::WA_ForceDisabled)
+ && !w->isWindow()
+ && w->parentWidget()
+ && w->parentWidget() != ancestor)
+ w = w->parentWidget();
+ return !w->testAttribute(Qt::WA_ForceDisabled);
+}
+
+#ifndef QT_NO_ACTION
+/*!
+ Appends the action \a action to this widget's list of actions.
+
+ All QWidgets have a list of \l{QAction}s, however they can be
+ represented graphically in many different ways. The default use of
+ the QAction list (as returned by actions()) is to create a context
+ QMenu.
+
+ A QWidget should only have one of each action and adding an action
+ it already has will not cause the same action to be in the widget twice.
+
+ The ownership of \a action is not transferred to this QWidget.
+
+ \sa removeAction(), insertAction(), actions(), QMenu
+*/
+void QWidget::addAction(QAction *action)
+{
+ insertAction(0, action);
+}
+
+/*!
+ Appends the actions \a actions to this widget's list of actions.
+
+ \sa removeAction(), QMenu, addAction()
+*/
+void QWidget::addActions(QList<QAction*> actions)
+{
+ for(int i = 0; i < actions.count(); i++)
+ insertAction(0, actions.at(i));
+}
+
+/*!
+ Inserts the action \a action to this widget's list of actions,
+ before the action \a before. It appends the action if \a before is 0 or
+ \a before is not a valid action for this widget.
+
+ A QWidget should only have one of each action.
+
+ \sa removeAction(), addAction(), QMenu, contextMenuPolicy, actions()
+*/
+void QWidget::insertAction(QAction *before, QAction *action)
+{
+ if(!action) {
+ qWarning("QWidget::insertAction: Attempt to insert null action");
+ return;
+ }
+
+ Q_D(QWidget);
+ if(d->actions.contains(action))
+ removeAction(action);
+
+ int pos = d->actions.indexOf(before);
+ if (pos < 0) {
+ before = 0;
+ pos = d->actions.size();
+ }
+ d->actions.insert(pos, action);
+
+ QActionPrivate *apriv = action->d_func();
+ apriv->widgets.append(this);
+
+ QActionEvent e(QEvent::ActionAdded, action, before);
+ QApplication::sendEvent(this, &e);
+}
+
+/*!
+ Inserts the actions \a actions to this widget's list of actions,
+ before the action \a before. It appends the action if \a before is 0 or
+ \a before is not a valid action for this widget.
+
+ A QWidget can have at most one of each action.
+
+ \sa removeAction(), QMenu, insertAction(), contextMenuPolicy
+*/
+void QWidget::insertActions(QAction *before, QList<QAction*> actions)
+{
+ for(int i = 0; i < actions.count(); ++i)
+ insertAction(before, actions.at(i));
+}
+
+/*!
+ Removes the action \a action from this widget's list of actions.
+ \sa insertAction(), actions(), insertAction()
+*/
+void QWidget::removeAction(QAction *action)
+{
+ if (!action)
+ return;
+
+ Q_D(QWidget);
+
+ QActionPrivate *apriv = action->d_func();
+ apriv->widgets.removeAll(this);
+
+ if (d->actions.removeAll(action)) {
+ QActionEvent e(QEvent::ActionRemoved, action);
+ QApplication::sendEvent(this, &e);
+ }
+}
+
+/*!
+ Returns the (possibly empty) list of this widget's actions.
+
+ \sa contextMenuPolicy, insertAction(), removeAction()
+*/
+QList<QAction*> QWidget::actions() const
+{
+ Q_D(const QWidget);
+ return d->actions;
+}
+#endif // QT_NO_ACTION
+
+/*!
+ \fn bool QWidget::isEnabledToTLW() const
+ \obsolete
+
+ This function is deprecated. It is equivalent to isEnabled()
+*/
+
+/*!
+ \property QWidget::enabled
+ \brief whether the widget is enabled
+
+ An enabled widget handles keyboard and mouse events; a disabled
+ widget does not.
+
+ Some widgets display themselves differently when they are
+ disabled. For example a button might draw its label grayed out. If
+ your widget needs to know when it becomes enabled or disabled, you
+ can use the changeEvent() with type QEvent::EnabledChange.
+
+ Disabling a widget implicitly disables all its children. Enabling
+ respectively enables all child widgets unless they have been
+ explicitly disabled.
+
+ By default, this property is true.
+
+ \sa isEnabledTo(), QKeyEvent, QMouseEvent, changeEvent()
+*/
+void QWidget::setEnabled(bool enable)
+{
+ Q_D(QWidget);
+ setAttribute(Qt::WA_ForceDisabled, !enable);
+ d->setEnabled_helper(enable);
+}
+
+void QWidgetPrivate::setEnabled_helper(bool enable)
+{
+ Q_Q(QWidget);
+
+ if (enable && !q->isWindow() && q->parentWidget() && !q->parentWidget()->isEnabled())
+ return; // nothing we can do
+
+ if (enable != q->testAttribute(Qt::WA_Disabled))
+ return; // nothing to do
+
+ q->setAttribute(Qt::WA_Disabled, !enable);
+ updateSystemBackground();
+
+ if (!enable && q->window()->focusWidget() == q) {
+ bool parentIsEnabled = (!q->parentWidget() || q->parentWidget()->isEnabled());
+ if (!parentIsEnabled || !q->focusNextChild())
+ q->clearFocus();
+ }
+
+ Qt::WidgetAttribute attribute = enable ? Qt::WA_ForceDisabled : Qt::WA_Disabled;
+ for (int i = 0; i < children.size(); ++i) {
+ QWidget *w = qobject_cast<QWidget *>(children.at(i));
+ if (w && !w->testAttribute(attribute))
+ w->d_func()->setEnabled_helper(enable);
+ }
+#if defined(Q_WS_X11)
+ if (q->testAttribute(Qt::WA_SetCursor) || q->isWindow()) {
+ // enforce the windows behavior of clearing the cursor on
+ // disabled widgets
+ qt_x11_enforce_cursor(q);
+ }
+#endif
+#if defined(Q_WS_MAC)
+ setEnabled_helper_sys(enable);
+#endif
+#ifndef QT_NO_IM
+ if (q->testAttribute(Qt::WA_InputMethodEnabled) && q->hasFocus()) {
+ QWidget *focusWidget = effectiveFocusWidget();
+ QInputContext *qic = focusWidget->d_func()->inputContext();
+ if (enable) {
+ if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled))
+ qic->setFocusWidget(focusWidget);
+ } else {
+ qic->reset();
+ qic->setFocusWidget(0);
+ }
+ }
+#endif //QT_NO_IM
+ QEvent e(QEvent::EnabledChange);
+ QApplication::sendEvent(q, &e);
+#ifdef QT3_SUPPORT
+ q->enabledChange(!enable); // compatibility
+#endif
+}
+
+/*!
+ \property QWidget::acceptDrops
+ \brief whether drop events are enabled for this widget
+
+ Setting this property to true announces to the system that this
+ widget \e may be able to accept drop events.
+
+ If the widget is the desktop (windowType() == Qt::Desktop), this may
+ fail if another application is using the desktop; you can call
+ acceptDrops() to test if this occurs.
+
+ \warning Do not modify this property in a drag and drop event handler.
+
+ By default, this property is false.
+
+ \sa {Drag and Drop}
+*/
+bool QWidget::acceptDrops() const
+{
+ return testAttribute(Qt::WA_AcceptDrops);
+}
+
+void QWidget::setAcceptDrops(bool on)
+{
+ setAttribute(Qt::WA_AcceptDrops, on);
+
+}
+
+/*!
+ \fn void QWidget::enabledChange(bool)
+
+ \internal
+ \obsolete
+*/
+
+/*!
+ \fn void QWidget::paletteChange(const QPalette &)
+
+ \internal
+ \obsolete
+*/
+
+/*!
+ \fn void QWidget::fontChange(const QFont &)
+
+ \internal
+ \obsolete
+*/
+
+/*!
+ \fn void QWidget::windowActivationChange(bool)
+
+ \internal
+ \obsolete
+*/
+
+/*!
+ \fn void QWidget::languageChange()
+
+ \obsolete
+*/
+
+/*!
+ \fn void QWidget::styleChange(QStyle& style)
+
+ \internal
+ \obsolete
+*/
+
+/*!
+ Disables widget input events if \a disable is true; otherwise
+ enables input events.
+
+ See the \l enabled documentation for more information.
+
+ \sa isEnabledTo(), QKeyEvent, QMouseEvent, changeEvent()
+*/
+void QWidget::setDisabled(bool disable)
+{
+ setEnabled(!disable);
+}
+
+/*!
+ \property QWidget::frameGeometry
+ \brief geometry of the widget relative to its parent including any
+ window frame
+
+ See the \l{Window Geometry} documentation for an overview of geometry
+ issues with windows.
+
+ By default, this property contains a value that depends on the user's
+ platform and screen geometry.
+
+ \sa geometry() x() y() pos()
+*/
+QRect QWidget::frameGeometry() const
+{
+ Q_D(const QWidget);
+ if (isWindow() && ! (windowType() == Qt::Popup)) {
+ QRect fs = d->frameStrut();
+ return QRect(data->crect.x() - fs.left(),
+ data->crect.y() - fs.top(),
+ data->crect.width() + fs.left() + fs.right(),
+ data->crect.height() + fs.top() + fs.bottom());
+ }
+ return data->crect;
+}
+
+/*!
+ \property QWidget::x
+
+ \brief the x coordinate of the widget relative to its parent including
+ any window frame
+
+ See the \l{Window Geometry} documentation for an overview of geometry
+ issues with windows.
+
+ By default, this property has a value of 0.
+
+ \sa frameGeometry, y, pos
+*/
+int QWidget::x() const
+{
+ Q_D(const QWidget);
+ if (isWindow() && ! (windowType() == Qt::Popup))
+ return data->crect.x() - d->frameStrut().left();
+ return data->crect.x();
+}
+
+/*!
+ \property QWidget::y
+ \brief the y coordinate of the widget relative to its parent and
+ including any window frame
+
+ See the \l{Window Geometry} documentation for an overview of geometry
+ issues with windows.
+
+ By default, this property has a value of 0.
+
+ \sa frameGeometry, x, pos
+*/
+int QWidget::y() const
+{
+ Q_D(const QWidget);
+ if (isWindow() && ! (windowType() == Qt::Popup))
+ return data->crect.y() - d->frameStrut().top();
+ return data->crect.y();
+}
+
+/*!
+ \property QWidget::pos
+ \brief the position of the widget within its parent widget
+
+ If the widget is a window, the position is that of the widget on
+ the desktop, including its frame.
+
+ When changing the position, the widget, if visible, receives a
+ move event (moveEvent()) immediately. If the widget is not
+ currently visible, it is guaranteed to receive an event before it
+ is shown.
+
+ By default, this property contains a position that refers to the
+ origin.
+
+ \warning Calling move() or setGeometry() inside moveEvent() can
+ lead to infinite recursion.
+
+ See the \l{Window Geometry} documentation for an overview of geometry
+ issues with windows.
+
+ \sa frameGeometry, size x(), y()
+*/
+QPoint QWidget::pos() const
+{
+ Q_D(const QWidget);
+ if (isWindow() && ! (windowType() == Qt::Popup)) {
+ QRect fs = d->frameStrut();
+ return QPoint(data->crect.x() - fs.left(), data->crect.y() - fs.top());
+ }
+ return data->crect.topLeft();
+}
+
+/*!
+ \property QWidget::geometry
+ \brief the geometry of the widget relative to its parent and
+ excluding the window frame
+
+ When changing the geometry, the widget, if visible, receives a
+ move event (moveEvent()) and/or a resize event (resizeEvent())
+ immediately. If the widget is not currently visible, it is
+ guaranteed to receive appropriate events before it is shown.
+
+ The size component is adjusted if it lies outside the range
+ defined by minimumSize() and maximumSize().
+
+ \warning Calling setGeometry() inside resizeEvent() or moveEvent()
+ can lead to infinite recursion.
+
+ See the \l{Window Geometry} documentation for an overview of geometry
+ issues with windows.
+
+ By default, this property contains a value that depends on the user's
+ platform and screen geometry.
+
+ \sa frameGeometry(), rect(), move(), resize(), moveEvent(),
+ resizeEvent(), minimumSize(), maximumSize()
+*/
+
+/*!
+ \property QWidget::normalGeometry
+
+ \brief the geometry of the widget as it will appear when shown as
+ a normal (not maximized or full screen) top-level widget
+
+ For child widgets this property always holds an empty rectangle.
+
+ By default, this property contains an empty rectangle.
+
+ \sa QWidget::windowState(), QWidget::geometry
+*/
+
+/*!
+ \property QWidget::size
+ \brief the size of the widget excluding any window frame
+
+ If the widget is visible when it is being resized, it receives a resize event
+ (resizeEvent()) immediately. If the widget is not currently
+ visible, it is guaranteed to receive an event before it is shown.
+
+ The size is adjusted if it lies outside the range defined by
+ minimumSize() and maximumSize().
+
+ By default, this property contains a value that depends on the user's
+ platform and screen geometry.
+
+ \warning Calling resize() or setGeometry() inside resizeEvent() can
+ lead to infinite recursion.
+
+ \note Setting the size to \c{QSize(0, 0)} will cause the widget to not
+ appear on screen. This also applies to windows.
+
+ \sa pos, geometry, minimumSize, maximumSize, resizeEvent(), adjustSize()
+*/
+
+/*!
+ \property QWidget::width
+ \brief the width of the widget excluding any window frame
+
+ See the \l{Window Geometry} documentation for an overview of geometry
+ issues with windows.
+
+ \note Do not use this function to find the width of a screen on
+ a \l{QDesktopWidget}{multiple screen desktop}. Read
+ \l{QDesktopWidget#Screen Geometry}{this note} for details.
+
+ By default, this property contains a value that depends on the user's
+ platform and screen geometry.
+
+ \sa geometry, height, size
+*/
+
+/*!
+ \property QWidget::height
+ \brief the height of the widget excluding any window frame
+
+ See the \l{Window Geometry} documentation for an overview of geometry
+ issues with windows.
+
+ \note Do not use this function to find the height of a screen
+ on a \l{QDesktopWidget}{multiple screen desktop}. Read
+ \l{QDesktopWidget#Screen Geometry}{this note} for details.
+
+ By default, this property contains a value that depends on the user's
+ platform and screen geometry.
+
+ \sa geometry, width, size
+*/
+
+/*!
+ \property QWidget::rect
+ \brief the internal geometry of the widget excluding any window
+ frame
+
+ The rect property equals QRect(0, 0, width(), height()).
+
+ See the \l{Window Geometry} documentation for an overview of geometry
+ issues with windows.
+
+ By default, this property contains a value that depends on the user's
+ platform and screen geometry.
+
+ \sa size
+*/
+
+
+QRect QWidget::normalGeometry() const
+{
+ Q_D(const QWidget);
+ if (!d->extra || !d->extra->topextra)
+ return QRect();
+
+ if (!isMaximized() && !isFullScreen())
+ return geometry();
+
+ return d->topData()->normalGeometry;
+}
+
+
+/*!
+ \property QWidget::childrenRect
+ \brief the bounding rectangle of the widget's children
+
+ Hidden children are excluded.
+
+ By default, for a widget with no children, this property contains a
+ rectangle with zero width and height located at the origin.
+
+ \sa childrenRegion() geometry()
+*/
+
+QRect QWidget::childrenRect() const
+{
+ Q_D(const QWidget);
+ QRect r(0, 0, 0, 0);
+ for (int i = 0; i < d->children.size(); ++i) {
+ QWidget *w = qobject_cast<QWidget *>(d->children.at(i));
+ if (w && !w->isWindow() && !w->isHidden())
+ r |= w->geometry();
+ }
+ return r;
+}
+
+/*!
+ \property QWidget::childrenRegion
+ \brief the combined region occupied by the widget's children
+
+ Hidden children are excluded.
+
+ By default, for a widget with no children, this property contains an
+ empty region.
+
+ \sa childrenRect() geometry() mask()
+*/
+
+QRegion QWidget::childrenRegion() const
+{
+ Q_D(const QWidget);
+ QRegion r;
+ for (int i = 0; i < d->children.size(); ++i) {
+ QWidget *w = qobject_cast<QWidget *>(d->children.at(i));
+ if (w && !w->isWindow() && !w->isHidden()) {
+ QRegion mask = w->mask();
+ if (mask.isEmpty())
+ r |= w->geometry();
+ else
+ r |= mask.translated(w->pos());
+ }
+ }
+ return r;
+}
+
+
+/*!
+ \property QWidget::minimumSize
+ \brief the widget's minimum size
+
+ The widget cannot be resized to a smaller size than the minimum
+ widget size. The widget's size is forced to the minimum size if
+ the current size is smaller.
+
+ The minimum size set by this function will override the minimum size
+ defined by QLayout. In order to unset the minimum size, use a
+ value of \c{QSize(0, 0)}.
+
+ By default, this property contains a size with zero width and height.
+
+ \sa minimumWidth, minimumHeight, maximumSize, sizeIncrement
+*/
+
+QSize QWidget::minimumSize() const
+{
+ Q_D(const QWidget);
+ return d->extra ? QSize(d->extra->minw, d->extra->minh) : QSize(0, 0);
+}
+
+/*!
+ \property QWidget::maximumSize
+ \brief the widget's maximum size in pixels
+
+ The widget cannot be resized to a larger size than the maximum
+ widget size.
+
+ By default, this property contains a size in which both width and height
+ have values of 16777215.
+
+ \note The definition of the \c QWIDGETSIZE_MAX macro limits the maximum size
+ of widgets.
+
+ \sa maximumWidth, maximumHeight, minimumSize, sizeIncrement
+*/
+
+QSize QWidget::maximumSize() const
+{
+ Q_D(const QWidget);
+ return d->extra ? QSize(d->extra->maxw, d->extra->maxh)
+ : QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
+}
+
+
+/*!
+ \property QWidget::minimumWidth
+ \brief the widget's minimum width in pixels
+
+ This property corresponds to the width held by the \l minimumSize property.
+
+ By default, this property has a value of 0.
+
+ \sa minimumSize, minimumHeight
+*/
+
+/*!
+ \property QWidget::minimumHeight
+ \brief the widget's minimum height in pixels
+
+ This property corresponds to the height held by the \l minimumSize property.
+
+ By default, this property has a value of 0.
+
+ \sa minimumSize, minimumWidth
+*/
+
+/*!
+ \property QWidget::maximumWidth
+ \brief the widget's maximum width in pixels
+
+ This property corresponds to the width held by the \l maximumSize property.
+
+ By default, this property contains a value of 16777215.
+
+ \note The definition of the \c QWIDGETSIZE_MAX macro limits the maximum size
+ of widgets.
+
+ \sa maximumSize, maximumHeight
+*/
+
+/*!
+ \property QWidget::maximumHeight
+ \brief the widget's maximum height in pixels
+
+ This property corresponds to the height held by the \l maximumSize property.
+
+ By default, this property contains a value of 16777215.
+
+ \note The definition of the \c QWIDGETSIZE_MAX macro limits the maximum size
+ of widgets.
+
+ \sa maximumSize, maximumWidth
+*/
+
+/*!
+ \property QWidget::sizeIncrement
+ \brief the size increment of the widget
+
+ When the user resizes the window, the size will move in steps of
+ sizeIncrement().width() pixels horizontally and
+ sizeIncrement.height() pixels vertically, with baseSize() as the
+ basis. Preferred widget sizes are for non-negative integers \e i
+ and \e j:
+ \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 2
+
+ Note that while you can set the size increment for all widgets, it
+ only affects windows.
+
+ By default, this property contains a size with zero width and height.
+
+ \warning The size increment has no effect under Windows, and may
+ be disregarded by the window manager on X11.
+
+ \sa size, minimumSize, maximumSize
+*/
+QSize QWidget::sizeIncrement() const
+{
+ Q_D(const QWidget);
+ return (d->extra && d->extra->topextra)
+ ? QSize(d->extra->topextra->incw, d->extra->topextra->inch)
+ : QSize(0, 0);
+}
+
+/*!
+ \property QWidget::baseSize
+ \brief the base size of the widget
+
+ The base size is used to calculate a proper widget size if the
+ widget defines sizeIncrement().
+
+ By default, for a newly-created widget, this property contains a size with
+ zero width and height.
+
+ \sa setSizeIncrement()
+*/
+
+QSize QWidget::baseSize() const
+{
+ Q_D(const QWidget);
+ return (d->extra != 0 && d->extra->topextra != 0)
+ ? QSize(d->extra->topextra->basew, d->extra->topextra->baseh)
+ : QSize(0, 0);
+}
+
+bool QWidgetPrivate::setMinimumSize_helper(int &minw, int &minh)
+{
+ Q_Q(QWidget);
+
+#ifdef Q_WS_QWS
+ if (q->isWindow()) {
+ const QRect maxWindowRect = QApplication::desktop()->availableGeometry(QApplication::desktop()->screenNumber(q));
+ if (!maxWindowRect.isEmpty()) {
+ // ### This is really just a work-around. Layout shouldn't be
+ // asking for minimum sizes bigger than the screen.
+ if (minw > maxWindowRect.width())
+ minw = maxWindowRect.width();
+ if (minh > maxWindowRect.height())
+ minh = maxWindowRect.height();
+ }
+ }
+#endif
+ int mw = minw, mh = minh;
+ if (mw == QWIDGETSIZE_MAX)
+ mw = 0;
+ if (mh == QWIDGETSIZE_MAX)
+ mh = 0;
+ if (minw > QWIDGETSIZE_MAX || minh > QWIDGETSIZE_MAX) {
+ qWarning("QWidget::setMinimumSize: (%s/%s) "
+ "The largest allowed size is (%d,%d)",
+ q->objectName().toLocal8Bit().data(), q->metaObject()->className(), QWIDGETSIZE_MAX,
+ QWIDGETSIZE_MAX);
+ minw = mw = qMin<int>(minw, QWIDGETSIZE_MAX);
+ minh = mh = qMin<int>(minh, QWIDGETSIZE_MAX);
+ }
+ if (minw < 0 || minh < 0) {
+ qWarning("QWidget::setMinimumSize: (%s/%s) Negative sizes (%d,%d) "
+ "are not possible",
+ q->objectName().toLocal8Bit().data(), q->metaObject()->className(), minw, minh);
+ minw = mw = qMax(minw, 0);
+ minh = mh = qMax(minh, 0);
+ }
+ createExtra();
+ if (extra->minw == mw && extra->minh == mh)
+ return false;
+ extra->minw = mw;
+ extra->minh = mh;
+ extra->explicitMinSize = (mw ? Qt::Horizontal : 0) | (mh ? Qt::Vertical : 0);
+ return true;
+}
+
+/*!
+ \overload
+
+ This function corresponds to setMinimumSize(QSize(minw, minh)).
+ Sets the minimum width to \a minw and the minimum height to \a
+ minh.
+*/
+
+void QWidget::setMinimumSize(int minw, int minh)
+{
+ Q_D(QWidget);
+ if (!d->setMinimumSize_helper(minw, minh))
+ return;
+
+ if (isWindow())
+ d->setConstraints_sys();
+ if (minw > width() || minh > height()) {
+ bool resized = testAttribute(Qt::WA_Resized);
+ bool maximized = isMaximized();
+ resize(qMax(minw,width()), qMax(minh,height()));
+ setAttribute(Qt::WA_Resized, resized); //not a user resize
+ if (maximized)
+ data->window_state = data->window_state | Qt::WindowMaximized;
+ }
+#ifndef QT_NO_GRAPHICSVIEW
+ if (d->extra) {
+ if (d->extra->proxyWidget)
+ d->extra->proxyWidget->setMinimumSize(minw, minh);
+ }
+#endif
+ d->updateGeometry_helper(d->extra->minw == d->extra->maxw && d->extra->minh == d->extra->maxh);
+}
+
+bool QWidgetPrivate::setMaximumSize_helper(int &maxw, int &maxh)
+{
+ Q_Q(QWidget);
+ if (maxw > QWIDGETSIZE_MAX || maxh > QWIDGETSIZE_MAX) {
+ qWarning("QWidget::setMaximumSize: (%s/%s) "
+ "The largest allowed size is (%d,%d)",
+ q->objectName().toLocal8Bit().data(), q->metaObject()->className(), QWIDGETSIZE_MAX,
+ QWIDGETSIZE_MAX);
+ maxw = qMin<int>(maxw, QWIDGETSIZE_MAX);
+ maxh = qMin<int>(maxh, QWIDGETSIZE_MAX);
+ }
+ if (maxw < 0 || maxh < 0) {
+ qWarning("QWidget::setMaximumSize: (%s/%s) Negative sizes (%d,%d) "
+ "are not possible",
+ q->objectName().toLocal8Bit().data(), q->metaObject()->className(), maxw, maxh);
+ maxw = qMax(maxw, 0);
+ maxh = qMax(maxh, 0);
+ }
+ createExtra();
+ if (extra->maxw == maxw && extra->maxh == maxh)
+ return false;
+ extra->maxw = maxw;
+ extra->maxh = maxh;
+ extra->explicitMaxSize = (maxw != QWIDGETSIZE_MAX ? Qt::Horizontal : 0) |
+ (maxh != QWIDGETSIZE_MAX ? Qt::Vertical : 0);
+ return true;
+}
+
+/*!
+ \overload
+
+ This function corresponds to setMaximumSize(QSize(\a maxw, \a
+ maxh)). Sets the maximum width to \a maxw and the maximum height
+ to \a maxh.
+*/
+void QWidget::setMaximumSize(int maxw, int maxh)
+{
+ Q_D(QWidget);
+ if (!d->setMaximumSize_helper(maxw, maxh))
+ return;
+
+ if (isWindow())
+ d->setConstraints_sys();
+ if (maxw < width() || maxh < height()) {
+ bool resized = testAttribute(Qt::WA_Resized);
+ resize(qMin(maxw,width()), qMin(maxh,height()));
+ setAttribute(Qt::WA_Resized, resized); //not a user resize
+ }
+
+#ifndef QT_NO_GRAPHICSVIEW
+ if (d->extra) {
+ if (d->extra->proxyWidget)
+ d->extra->proxyWidget->setMaximumSize(maxw, maxh);
+ }
+#endif
+
+ d->updateGeometry_helper(d->extra->minw == d->extra->maxw && d->extra->minh == d->extra->maxh);
+}
+
+/*!
+ \overload
+
+ Sets the x (width) size increment to \a w and the y (height) size
+ increment to \a h.
+*/
+void QWidget::setSizeIncrement(int w, int h)
+{
+ Q_D(QWidget);
+ d->createTLExtra();
+ QTLWExtra* x = d->topData();
+ if (x->incw == w && x->inch == h)
+ return;
+ x->incw = w;
+ x->inch = h;
+ if (isWindow())
+ d->setConstraints_sys();
+}
+
+/*!
+ \overload
+
+ This corresponds to setBaseSize(QSize(\a basew, \a baseh)). Sets
+ the widgets base size to width \a basew and height \a baseh.
+*/
+void QWidget::setBaseSize(int basew, int baseh)
+{
+ Q_D(QWidget);
+ d->createTLExtra();
+ QTLWExtra* x = d->topData();
+ if (x->basew == basew && x->baseh == baseh)
+ return;
+ x->basew = basew;
+ x->baseh = baseh;
+ if (isWindow())
+ d->setConstraints_sys();
+}
+
+/*!
+ Sets both the minimum and maximum sizes of the widget to \a s,
+ thereby preventing it from ever growing or shrinking.
+
+ This will override the default size constraints set by QLayout.
+
+ To remove constraints, set the size to QWIDGETSIZE_MAX.
+
+ Alternatively, if you want the widget to have a
+ fixed size based on its contents, you can call
+ QLayout::setSizeConstraint(QLayout::SetFixedSize);
+
+ \sa maximumSize, minimumSize
+*/
+
+void QWidget::setFixedSize(const QSize & s)
+{
+ setFixedSize(s.width(), s.height());
+}
+
+
+/*!
+ \fn void QWidget::setFixedSize(int w, int h)
+ \overload
+
+ Sets the width of the widget to \a w and the height to \a h.
+*/
+
+void QWidget::setFixedSize(int w, int h)
+{
+ Q_D(QWidget);
+#ifdef Q_WS_QWS
+ // temporary fix for 4.3.x.
+ // Should move the embedded spesific contraints in setMinimumSize_helper into QLayout
+ int tmpW = w;
+ int tmpH = h;
+ bool minSizeSet = d->setMinimumSize_helper(tmpW, tmpH);
+#else
+ bool minSizeSet = d->setMinimumSize_helper(w, h);
+#endif
+ bool maxSizeSet = d->setMaximumSize_helper(w, h);
+ if (!minSizeSet && !maxSizeSet)
+ return;
+
+ if (isWindow())
+ d->setConstraints_sys();
+ else
+ d->updateGeometry_helper(true);
+
+ if (w != QWIDGETSIZE_MAX || h != QWIDGETSIZE_MAX)
+ resize(w, h);
+}
+
+void QWidget::setMinimumWidth(int w)
+{
+ Q_D(QWidget);
+ d->createExtra();
+ uint expl = d->extra->explicitMinSize | (w ? Qt::Horizontal : 0);
+ setMinimumSize(w, minimumSize().height());
+ d->extra->explicitMinSize = expl;
+}
+
+void QWidget::setMinimumHeight(int h)
+{
+ Q_D(QWidget);
+ d->createExtra();
+ uint expl = d->extra->explicitMinSize | (h ? Qt::Vertical : 0);
+ setMinimumSize(minimumSize().width(), h);
+ d->extra->explicitMinSize = expl;
+}
+
+void QWidget::setMaximumWidth(int w)
+{
+ Q_D(QWidget);
+ d->createExtra();
+ uint expl = d->extra->explicitMaxSize | (w == QWIDGETSIZE_MAX ? 0 : Qt::Horizontal);
+ setMaximumSize(w, maximumSize().height());
+ d->extra->explicitMaxSize = expl;
+}
+
+void QWidget::setMaximumHeight(int h)
+{
+ Q_D(QWidget);
+ d->createExtra();
+ uint expl = d->extra->explicitMaxSize | (h == QWIDGETSIZE_MAX ? 0 : Qt::Vertical);
+ setMaximumSize(maximumSize().width(), h);
+ d->extra->explicitMaxSize = expl;
+}
+
+/*!
+ Sets both the minimum and maximum width of the widget to \a w
+ without changing the heights. Provided for convenience.
+
+ \sa sizeHint() minimumSize() maximumSize() setFixedSize()
+*/
+
+void QWidget::setFixedWidth(int w)
+{
+ Q_D(QWidget);
+ d->createExtra();
+ uint explMin = d->extra->explicitMinSize | Qt::Horizontal;
+ uint explMax = d->extra->explicitMaxSize | Qt::Horizontal;
+ setMinimumSize(w, minimumSize().height());
+ setMaximumSize(w, maximumSize().height());
+ d->extra->explicitMinSize = explMin;
+ d->extra->explicitMaxSize = explMax;
+}
+
+
+/*!
+ Sets both the minimum and maximum heights of the widget to \a h
+ without changing the widths. Provided for convenience.
+
+ \sa sizeHint() minimumSize() maximumSize() setFixedSize()
+*/
+
+void QWidget::setFixedHeight(int h)
+{
+ Q_D(QWidget);
+ d->createExtra();
+ uint explMin = d->extra->explicitMinSize | Qt::Vertical;
+ uint explMax = d->extra->explicitMaxSize | Qt::Vertical;
+ setMinimumSize(minimumSize().width(), h);
+ setMaximumSize(maximumSize().width(), h);
+ d->extra->explicitMinSize = explMin;
+ d->extra->explicitMaxSize = explMax;
+}
+
+
+/*!
+ Translates the widget coordinate \a pos to the coordinate system
+ of \a parent. The \a parent must not be 0 and must be a parent
+ of the calling widget.
+
+ \sa mapFrom() mapToParent() mapToGlobal() underMouse()
+*/
+
+QPoint QWidget::mapTo(QWidget * parent, const QPoint & pos) const
+{
+ QPoint p = pos;
+ if (parent) {
+ const QWidget * w = this;
+ while (w != parent) {
+ Q_ASSERT_X(w, "QWidget::mapTo(QWidget *parent, const QPoint &pos)",
+ "parent must be in parent hierarchy");
+ p = w->mapToParent(p);
+ w = w->parentWidget();
+ }
+ }
+ return p;
+}
+
+
+/*!
+ Translates the widget coordinate \a pos from the coordinate system
+ of \a parent to this widget's coordinate system. The \a parent
+ must not be 0 and must be a parent of the calling widget.
+
+ \sa mapTo() mapFromParent() mapFromGlobal() underMouse()
+*/
+
+QPoint QWidget::mapFrom(QWidget * parent, const QPoint & pos) const
+{
+ QPoint p(pos);
+ if (parent) {
+ const QWidget * w = this;
+ while (w != parent) {
+ Q_ASSERT_X(w, "QWidget::mapFrom(QWidget *parent, const QPoint &pos)",
+ "parent must be in parent hierarchy");
+
+ p = w->mapFromParent(p);
+ w = w->parentWidget();
+ }
+ }
+ return p;
+}
+
+
+/*!
+ Translates the widget coordinate \a pos to a coordinate in the
+ parent widget.
+
+ Same as mapToGlobal() if the widget has no parent.
+
+ \sa mapFromParent() mapTo() mapToGlobal() underMouse()
+*/
+
+QPoint QWidget::mapToParent(const QPoint &pos) const
+{
+ return pos + data->crect.topLeft();
+}
+
+/*!
+ Translates the parent widget coordinate \a pos to widget
+ coordinates.
+
+ Same as mapFromGlobal() if the widget has no parent.
+
+ \sa mapToParent() mapFrom() mapFromGlobal() underMouse()
+*/
+
+QPoint QWidget::mapFromParent(const QPoint &pos) const
+{
+ return pos - data->crect.topLeft();
+}
+
+
+/*!
+ Returns the window for this widget, i.e. the next ancestor widget
+ that has (or could have) a window-system frame.
+
+ If the widget is a window, the widget itself is returned.
+
+ Typical usage is changing the window title:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 3
+
+ \sa isWindow()
+*/
+
+QWidget *QWidget::window() const
+{
+ QWidget *w = (QWidget *)this;
+ QWidget *p = w->parentWidget();
+ while (!w->isWindow() && p) {
+ w = p;
+ p = p->parentWidget();
+ }
+ return w;
+}
+
+/*!
+ \since 4.4
+
+ Returns the native parent for this widget, i.e. the next ancestor widget
+ that has a system identifier, or 0 if it does not have any native parent.
+
+ \sa effectiveWinId()
+*/
+QWidget *QWidget::nativeParentWidget() const
+{
+ QWidget *parent = parentWidget();
+ while (parent && !parent->internalWinId())
+ parent = parent->parentWidget();
+ return parent;
+}
+
+/*! \fn QWidget *QWidget::topLevelWidget() const
+ \obsolete
+
+ Use window() instead.
+*/
+
+#ifdef QT3_SUPPORT
+/*!
+ Returns the color role used for painting the widget's background.
+
+ Use QPalette(backgroundRole(()) instead.
+*/
+Qt::BackgroundMode QWidget::backgroundMode() const
+{
+ if (testAttribute(Qt::WA_NoSystemBackground))
+ return Qt::NoBackground;
+ switch(backgroundRole()) {
+ case QPalette::WindowText:
+ return Qt::PaletteForeground;
+ case QPalette::Button:
+ return Qt::PaletteButton;
+ case QPalette::Light:
+ return Qt::PaletteLight;
+ case QPalette::Midlight:
+ return Qt::PaletteMidlight;
+ case QPalette::Dark:
+ return Qt::PaletteDark;
+ case QPalette::Mid:
+ return Qt::PaletteMid;
+ case QPalette::Text:
+ return Qt::PaletteText;
+ case QPalette::BrightText:
+ return Qt::PaletteBrightText;
+ case QPalette::Base:
+ return Qt::PaletteBase;
+ case QPalette::Window:
+ return Qt::PaletteBackground;
+ case QPalette::Shadow:
+ return Qt::PaletteShadow;
+ case QPalette::Highlight:
+ return Qt::PaletteHighlight;
+ case QPalette::HighlightedText:
+ return Qt::PaletteHighlightedText;
+ case QPalette::ButtonText:
+ return Qt::PaletteButtonText;
+ case QPalette::Link:
+ return Qt::PaletteLink;
+ case QPalette::LinkVisited:
+ return Qt::PaletteLinkVisited;
+ default:
+ break;
+ }
+ return Qt::NoBackground;
+}
+
+/*!
+ \fn void QWidget::setBackgroundMode(Qt::BackgroundMode
+ widgetBackground, Qt::BackgroundMode paletteBackground)
+
+ Sets the color role used for painting the widget's background to
+ background mode \a widgetBackground. The \a paletteBackground mode
+ parameter is ignored.
+*/
+void QWidget::setBackgroundMode(Qt::BackgroundMode m, Qt::BackgroundMode)
+{
+ Q_D(QWidget);
+ if(m == Qt::NoBackground) {
+ setAttribute(Qt::WA_NoSystemBackground, true);
+ return;
+ }
+ setAttribute(Qt::WA_NoSystemBackground, false);
+ d->fg_role = QPalette::NoRole;
+ QPalette::ColorRole role = d->bg_role;
+ switch(m) {
+ case Qt::FixedColor:
+ case Qt::FixedPixmap:
+ break;
+ case Qt::PaletteForeground:
+ role = QPalette::WindowText;
+ break;
+ case Qt::PaletteButton:
+ role = QPalette::Button;
+ break;
+ case Qt::PaletteLight:
+ role = QPalette::Light;
+ break;
+ case Qt::PaletteMidlight:
+ role = QPalette::Midlight;
+ break;
+ case Qt::PaletteDark:
+ role = QPalette::Dark;
+ break;
+ case Qt::PaletteMid:
+ role = QPalette::Mid;
+ break;
+ case Qt::PaletteText:
+ role = QPalette::Text;
+ break;
+ case Qt::PaletteBrightText:
+ role = QPalette::BrightText;
+ break;
+ case Qt::PaletteBase:
+ role = QPalette::Base;
+ break;
+ case Qt::PaletteBackground:
+ role = QPalette::Window;
+ break;
+ case Qt::PaletteShadow:
+ role = QPalette::Shadow;
+ break;
+ case Qt::PaletteHighlight:
+ role = QPalette::Highlight;
+ break;
+ case Qt::PaletteHighlightedText:
+ role = QPalette::HighlightedText;
+ break;
+ case Qt::PaletteButtonText:
+ role = QPalette::ButtonText;
+ break;
+ case Qt::PaletteLink:
+ role = QPalette::Link;
+ break;
+ case Qt::PaletteLinkVisited:
+ role = QPalette::LinkVisited;
+ break;
+ case Qt::X11ParentRelative:
+ d->fg_role = role = QPalette::NoRole;
+ default:
+ break;
+ }
+ setBackgroundRole(role);
+}
+
+/*!
+ The widget mapper is no longer part of the public API.
+*/
+QT3_SUPPORT QWidgetMapper *QWidget::wmapper() { return QWidgetPrivate::mapper; }
+
+#endif
+
+
+/*!
+ Returns the background role of the widget.
+
+ The background role defines the brush from the widget's \l palette that
+ is used to render the background.
+
+ If no explicit background role is set, the widget inherts its parent
+ widget's background role.
+
+ \sa setBackgroundRole(), foregroundRole()
+ */
+QPalette::ColorRole QWidget::backgroundRole() const
+{
+
+ const QWidget *w = this;
+ do {
+ QPalette::ColorRole role = w->d_func()->bg_role;
+ if (role != QPalette::NoRole)
+ return role;
+ if (w->isWindow() || w->windowType() == Qt::SubWindow)
+ break;
+ w = w->parentWidget();
+ } while (w);
+ return QPalette::Window;
+}
+
+/*!
+ Sets the background role of the widget to \a role.
+
+ The background role defines the brush from the widget's \l palette that
+ is used to render the background.
+
+ If \a role is QPalette::NoRole, then the widget inherits its
+ parent's background role.
+
+ Note that styles are free to choose any color from the palette.
+ You can modify the palette or set a style sheet if you don't
+ achieve the result you want with setBackgroundRole().
+
+ \sa backgroundRole(), foregroundRole()
+ */
+
+void QWidget::setBackgroundRole(QPalette::ColorRole role)
+{
+ Q_D(QWidget);
+ d->bg_role = role;
+ d->updateSystemBackground();
+ d->propagatePaletteChange();
+ d->updateIsOpaque();
+}
+
+/*!
+ Returns the foreground role.
+
+ The foreground role defines the color from the widget's \l palette that
+ is used to draw the foreground.
+
+ If no explicit foreground role is set, the function returns a role
+ that contrasts with the background role.
+
+ \sa setForegroundRole(), backgroundRole()
+ */
+QPalette::ColorRole QWidget::foregroundRole() const
+{
+ Q_D(const QWidget);
+ QPalette::ColorRole rl = QPalette::ColorRole(d->fg_role);
+ if (rl != QPalette::NoRole)
+ return rl;
+ QPalette::ColorRole role = QPalette::WindowText;
+ switch (backgroundRole()) {
+ case QPalette::Button:
+ role = QPalette::ButtonText;
+ break;
+ case QPalette::Base:
+ role = QPalette::Text;
+ break;
+ case QPalette::Dark:
+ case QPalette::Shadow:
+ role = QPalette::Light;
+ break;
+ case QPalette::Highlight:
+ role = QPalette::HighlightedText;
+ break;
+ case QPalette::ToolTipBase:
+ role = QPalette::ToolTipText;
+ break;
+ default:
+ ;
+ }
+ return role;
+}
+
+/*!
+ Sets the foreground role of the widget to \a role.
+
+ The foreground role defines the color from the widget's \l palette that
+ is used to draw the foreground.
+
+ If \a role is QPalette::NoRole, the widget uses a foreground role
+ that contrasts with the background role.
+
+ Note that styles are free to choose any color from the palette.
+ You can modify the palette or set a style sheet if you don't
+ achieve the result you want with setForegroundRole().
+
+ \sa foregroundRole(), backgroundRole()
+ */
+void QWidget::setForegroundRole(QPalette::ColorRole role)
+{
+ Q_D(QWidget);
+ d->fg_role = role;
+ d->updateSystemBackground();
+ d->propagatePaletteChange();
+}
+
+/*!
+ \property QWidget::palette
+ \brief the widget's palette
+
+ This property describes the widget's palette. The palette is used by the
+ widget's style when rendering standard components, and is available as a
+ means to ensure that custom widgets can maintain consistency with the
+ native platform's look and feel. It's common that different platforms, or
+ different styles, have different palettes.
+
+ When you assign a new palette to a widget, the color roles from this
+ palette are combined with the widget's default palette to form the
+ widget's final palette. The palette entry for the widget's background role
+ is used to fill the widget's background (see QWidget::autoFillBackground),
+ and the foreground role initializes QPainter's pen.
+
+ The default depends on the system environment. QApplication maintains a
+ system/theme palette which serves as a default for all widgets. There may
+ also be special palette defaults for certain types of widgets (e.g., on
+ Windows XP and Vista, all classes that derive from QMenuBar have a special
+ default palette). You can also define default palettes for widgets
+ yourself by passing a custom palette and the name of a widget to
+ QApplication::setPalette(). Finally, the style always has the option of
+ polishing the palette as it's assigned (see QStyle::polish()).
+
+ QWidget propagates explicit palette roles from parent to child. If you
+ assign a brush or color to a specific role on a palette and assign that
+ palette to a widget, that role will propagate to all the widget's
+ children, overriding any system defaults for that role. Note that palettes
+ by default don't propagate to windows (see isWindow()) unless the
+ Qt::WA_WindowPropagation attribute is enabled.
+
+ QWidget's palette propagation is similar to its font propagation.
+
+ The current style, which is used to render the content of all standard Qt
+ widgets, is free to choose colors and brushes from the widget palette, or
+ in some cases, to ignore the palette (partially, or completely). In
+ particular, certain styles like GTK style, Mac style, Windows XP, and
+ Vista style, depend on third party APIs to render the content of widgets,
+ and these styles typically do not follow the palette. Because of this,
+ assigning roles to a widget's palette is not guaranteed to change the
+ appearance of the widget. Instead, you may choose to apply a \l
+ styleSheet. You can refer to our Knowledge Base article
+ \l{http://qt.nokia.com/developer/knowledgebase/22}{here} for more
+ information.
+
+ \warning Do not use this function in conjunction with \l{Qt Style Sheets}.
+ When using style sheets, the palette of a widget can be customized using
+ the "color", "background-color", "selection-color",
+ "selection-background-color" and "alternate-background-color".
+
+ \sa QApplication::palette(), QWidget::font()
+*/
+const QPalette &QWidget::palette() const
+{
+ if (!isEnabled()) {
+ data->pal.setCurrentColorGroup(QPalette::Disabled);
+ } else if ((!isVisible() || isActiveWindow())
+#if defined(Q_OS_WIN) && !defined(Q_WS_WINCE)
+ && !QApplicationPrivate::isBlockedByModal(const_cast<QWidget *>(this))
+#endif
+ ) {
+ data->pal.setCurrentColorGroup(QPalette::Active);
+ } else {
+#ifdef Q_WS_MAC
+ extern bool qt_mac_can_clickThrough(const QWidget *); //qwidget_mac.cpp
+ if (qt_mac_can_clickThrough(this))
+ data->pal.setCurrentColorGroup(QPalette::Active);
+ else
+#endif
+ data->pal.setCurrentColorGroup(QPalette::Inactive);
+ }
+ return data->pal;
+}
+
+void QWidget::setPalette(const QPalette &palette)
+{
+ Q_D(QWidget);
+ setAttribute(Qt::WA_SetPalette, palette.resolve() != 0);
+
+ // Determine which palette is inherited from this widget's ancestors and
+ // QApplication::palette, resolve this against \a palette (attributes from
+ // the inherited palette are copied over this widget's palette). Then
+ // propagate this palette to this widget's children.
+ QPalette naturalPalette = d->naturalWidgetPalette(d->inheritedPaletteResolveMask);
+ QPalette resolvedPalette = palette.resolve(naturalPalette);
+ d->setPalette_helper(resolvedPalette);
+}
+
+/*!
+ \internal
+
+ Returns the palette that the widget \a w inherits from its ancestors and
+ QApplication::palette. \a inheritedMask is the combination of the widget's
+ ancestors palette request masks (i.e., which attributes from the parent
+ widget's palette are implicitly imposed on this widget by the user). Note
+ that this font does not take into account the palette set on \a w itself.
+*/
+QPalette QWidgetPrivate::naturalWidgetPalette(uint inheritedMask) const
+{
+ Q_Q(const QWidget);
+ QPalette naturalPalette = QApplication::palette(q);
+ if (!q->testAttribute(Qt::WA_StyleSheet)
+ && (!q->isWindow() || q->testAttribute(Qt::WA_WindowPropagation)
+#ifndef QT_NO_GRAPHICSVIEW
+ || (extra && extra->proxyWidget)
+#endif //QT_NO_GRAPHICSVIEW
+ )) {
+ if (QWidget *p = q->parentWidget()) {
+ if (!p->testAttribute(Qt::WA_StyleSheet)) {
+ if (!naturalPalette.isCopyOf(QApplication::palette())) {
+ QPalette inheritedPalette = p->palette();
+ inheritedPalette.resolve(inheritedMask);
+ naturalPalette = inheritedPalette.resolve(naturalPalette);
+ } else {
+ naturalPalette = p->palette();
+ }
+ }
+ }
+#ifndef QT_NO_GRAPHICSVIEW
+ else if (extra && extra->proxyWidget) {
+ QPalette inheritedPalette = extra->proxyWidget->palette();
+ inheritedPalette.resolve(inheritedMask);
+ naturalPalette = inheritedPalette.resolve(naturalPalette);
+ }
+#endif //QT_NO_GRAPHICSVIEW
+ }
+ naturalPalette.resolve(0);
+ return naturalPalette;
+}
+/*!
+ \internal
+
+ Determine which palette is inherited from this widget's ancestors and
+ QApplication::palette, resolve this against this widget's palette
+ (attributes from the inherited palette are copied over this widget's
+ palette). Then propagate this palette to this widget's children.
+*/
+void QWidgetPrivate::resolvePalette()
+{
+ QPalette naturalPalette = naturalWidgetPalette(inheritedPaletteResolveMask);
+ QPalette resolvedPalette = data.pal.resolve(naturalPalette);
+ setPalette_helper(resolvedPalette);
+}
+
+void QWidgetPrivate::setPalette_helper(const QPalette &palette)
+{
+ Q_Q(QWidget);
+ if (data.pal == palette && data.pal.resolve() == palette.resolve())
+ return;
+ data.pal = palette;
+ updateSystemBackground();
+ propagatePaletteChange();
+ updateIsOpaque();
+ q->update();
+ updateIsOpaque();
+}
+
+/*!
+ \property QWidget::font
+ \brief the font currently set for the widget
+
+ This property describes the widget's requested font. The font is used by
+ the widget's style when rendering standard components, and is available as
+ a means to ensure that custom widgets can maintain consistency with the
+ native platform's look and feel. It's common that different platforms, or
+ different styles, define different fonts for an application.
+
+ When you assign a new font to a widget, the properties from this font are
+ combined with the widget's default font to form the widget's final
+ font. You can call fontInfo() to get a copy of the widget's final
+ font. The final font is also used to initialize QPainter's font.
+
+ The default depends on the system environment. QApplication maintains a
+ system/theme font which serves as a default for all widgets. There may
+ also be special font defaults for certain types of widgets. You can also
+ define default fonts for widgets yourself by passing a custom font and the
+ name of a widget to QApplication::setFont(). Finally, the font is matched
+ against Qt's font database to find the best match.
+
+ QWidget propagates explicit font properties from parent to child. If you
+ change a specific property on a font and assign that font to a widget,
+ that property will propagate to all the widget's children, overriding any
+ system defaults for that property. Note that fonts by default don't
+ propagate to windows (see isWindow()) unless the Qt::WA_WindowPropagation
+ attribute is enabled.
+
+ QWidget's font propagation is similar to its palette propagation.
+
+ The current style, which is used to render the content of all standard Qt
+ widgets, is free to choose to use the widget font, or in some cases, to
+ ignore it (partially, or completely). In particular, certain styles like
+ GTK style, Mac style, Windows XP, and Vista style, apply special
+ modifications to the widget font to match the platform's native look and
+ feel. Because of this, assigning properties to a widget's font is not
+ guaranteed to change the appearance of the widget. Instead, you may choose
+ to apply a \l styleSheet.
+
+ \note If \l{Qt Style Sheets} are used on the same widget as setFont(),
+ style sheets will take precedence if the settings conflict.
+
+ \sa fontInfo(), fontMetrics()
+*/
+
+void QWidget::setFont(const QFont &font)
+{
+ Q_D(QWidget);
+
+#ifndef QT_NO_STYLE_STYLESHEET
+ const QStyleSheetStyle* style;
+ if (d->extra && (style = qobject_cast<const QStyleSheetStyle*>(d->extra->style))) {
+ style->saveWidgetFont(this, font);
+ }
+#endif
+
+ setAttribute(Qt::WA_SetFont, font.resolve() != 0);
+
+ // Determine which font is inherited from this widget's ancestors and
+ // QApplication::font, resolve this against \a font (attributes from the
+ // inherited font are copied over). Then propagate this font to this
+ // widget's children.
+ QFont naturalFont = d->naturalWidgetFont(d->inheritedFontResolveMask);
+ QFont resolvedFont = font.resolve(naturalFont);
+ d->setFont_helper(resolvedFont);
+}
+
+/*
+ \internal
+
+ Returns the font that the widget \a w inherits from its ancestors and
+ QApplication::font. \a inheritedMask is the combination of the widget's
+ ancestors font request masks (i.e., which attributes from the parent
+ widget's font are implicitly imposed on this widget by the user). Note
+ that this font does not take into account the font set on \a w itself.
+
+ ### Stylesheet has a different font propagation mechanism. When a stylesheet
+ is applied, fonts are not propagated anymore
+*/
+QFont QWidgetPrivate::naturalWidgetFont(uint inheritedMask) const
+{
+ Q_Q(const QWidget);
+ QFont naturalFont = QApplication::font(q);
+ if (!q->testAttribute(Qt::WA_StyleSheet)
+ && (!q->isWindow() || q->testAttribute(Qt::WA_WindowPropagation)
+#ifndef QT_NO_GRAPHICSVIEW
+ || (extra && extra->proxyWidget)
+#endif //QT_NO_GRAPHICSVIEW
+ )) {
+ if (QWidget *p = q->parentWidget()) {
+ if (!p->testAttribute(Qt::WA_StyleSheet)) {
+ if (!naturalFont.isCopyOf(QApplication::font())) {
+ QFont inheritedFont = p->font();
+ inheritedFont.resolve(inheritedMask);
+ naturalFont = inheritedFont.resolve(naturalFont);
+ } else {
+ naturalFont = p->font();
+ }
+ }
+ }
+#ifndef QT_NO_GRAPHICSVIEW
+ else if (extra && extra->proxyWidget) {
+ QFont inheritedFont = extra->proxyWidget->font();
+ inheritedFont.resolve(inheritedMask);
+ naturalFont = inheritedFont.resolve(naturalFont);
+ }
+#endif //QT_NO_GRAPHICSVIEW
+ }
+ naturalFont.resolve(0);
+ return naturalFont;
+}
+
+/*!
+ \internal
+
+ Determine which font is implicitly imposed on this widget by its ancestors
+ and QApplication::font, resolve this against its own font (attributes from
+ the implicit font are copied over). Then propagate this font to this
+ widget's children.
+*/
+void QWidgetPrivate::resolveFont()
+{
+ QFont naturalFont = naturalWidgetFont(inheritedFontResolveMask);
+ QFont resolvedFont = data.fnt.resolve(naturalFont);
+ setFont_helper(resolvedFont);
+}
+
+/*!
+ \internal
+
+ Assign \a font to this widget, and propagate it to all children, except
+ style sheet widgets (handled differently) and windows that don't enable
+ window propagation. \a implicitMask is the union of all ancestor widgets'
+ font request masks, and determines which attributes from this widget's
+ font should propagate.
+*/
+void QWidgetPrivate::updateFont(const QFont &font)
+{
+ Q_Q(QWidget);
+#ifndef QT_NO_STYLE_STYLESHEET
+ const QStyleSheetStyle* cssStyle;
+ cssStyle = extra ? qobject_cast<const QStyleSheetStyle*>(extra->style) : 0;
+#endif
+
+#ifdef QT3_SUPPORT
+ QFont old = data.fnt;
+#endif
+ data.fnt = QFont(font, q);
+#if defined(Q_WS_X11)
+ // make sure the font set on this widget is associated with the correct screen
+ data.fnt.x11SetScreen(xinfo.screen());
+#endif
+ // Combine new mask with natural mask and propagate to children.
+#ifndef QT_NO_GRAPHICSVIEW
+ if (!q->parentWidget() && extra && extra->proxyWidget) {
+ QGraphicsProxyWidget *p = extra->proxyWidget;
+ inheritedFontResolveMask = p->d_func()->inheritedFontResolveMask | p->font().resolve();
+ } else
+#endif //QT_NO_GRAPHICSVIEW
+ if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) {
+ inheritedFontResolveMask = 0;
+ }
+ uint newMask = data.fnt.resolve() | inheritedFontResolveMask;
+
+ for (int i = 0; i < children.size(); ++i) {
+ QWidget *w = qobject_cast<QWidget*>(children.at(i));
+ if (w) {
+ if (0) {
+#ifndef QT_NO_STYLE_STYLESHEET
+ } else if (w->testAttribute(Qt::WA_StyleSheet)) {
+ // Style sheets follow a different font propagation scheme.
+ if (cssStyle)
+ cssStyle->updateStyleSheetFont(w);
+#endif
+ } else if ((!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))) {
+ // Propagate font changes.
+ QWidgetPrivate *wd = w->d_func();
+ wd->inheritedFontResolveMask = newMask;
+ wd->resolveFont();
+ }
+ }
+ }
+
+#ifndef QT_NO_STYLE_STYLESHEET
+ if (cssStyle) {
+ cssStyle->updateStyleSheetFont(q);
+ }
+#endif
+
+ QEvent e(QEvent::FontChange);
+ QApplication::sendEvent(q, &e);
+#ifdef QT3_SUPPORT
+ q->fontChange(old);
+#endif
+}
+
+void QWidgetPrivate::setLayoutDirection_helper(Qt::LayoutDirection direction)
+{
+ Q_Q(QWidget);
+
+ if ( (direction == Qt::RightToLeft) == q->testAttribute(Qt::WA_RightToLeft))
+ return;
+ q->setAttribute(Qt::WA_RightToLeft, (direction == Qt::RightToLeft));
+ if (!children.isEmpty()) {
+ for (int i = 0; i < children.size(); ++i) {
+ QWidget *w = qobject_cast<QWidget*>(children.at(i));
+ if (w && !w->isWindow() && !w->testAttribute(Qt::WA_SetLayoutDirection))
+ w->d_func()->setLayoutDirection_helper(direction);
+ }
+ }
+ QEvent e(QEvent::LayoutDirectionChange);
+ QApplication::sendEvent(q, &e);
+}
+
+void QWidgetPrivate::resolveLayoutDirection()
+{
+ Q_Q(const QWidget);
+ if (!q->testAttribute(Qt::WA_SetLayoutDirection))
+ setLayoutDirection_helper(q->isWindow() ? QApplication::layoutDirection() : q->parentWidget()->layoutDirection());
+}
+
+/*!
+ \property QWidget::layoutDirection
+
+ \brief the layout direction for this widget
+
+ By default, this property is set to Qt::LeftToRight.
+
+ When the layout direction is set on a widget, it will propagate to
+ the widget's children, but not to a child that is a window and not
+ to a child for which setLayoutDirection() has been explicitly
+ called. Also, child widgets added \e after setLayoutDirection()
+ has been called for the parent do not inherit the parent's layout
+ direction.
+
+ This method no longer affects text layout direction since Qt 4.7.
+
+ \sa QApplication::layoutDirection
+*/
+void QWidget::setLayoutDirection(Qt::LayoutDirection direction)
+{
+ Q_D(QWidget);
+
+ if (direction == Qt::LayoutDirectionAuto) {
+ unsetLayoutDirection();
+ return;
+ }
+
+ setAttribute(Qt::WA_SetLayoutDirection);
+ d->setLayoutDirection_helper(direction);
+}
+
+Qt::LayoutDirection QWidget::layoutDirection() const
+{
+ return testAttribute(Qt::WA_RightToLeft) ? Qt::RightToLeft : Qt::LeftToRight;
+}
+
+void QWidget::unsetLayoutDirection()
+{
+ Q_D(QWidget);
+ setAttribute(Qt::WA_SetLayoutDirection, false);
+ d->resolveLayoutDirection();
+}
+
+/*!
+ \fn QFontMetrics QWidget::fontMetrics() const
+
+ Returns the font metrics for the widget's current font.
+ Equivalent to QFontMetrics(widget->font()).
+
+ \sa font(), fontInfo(), setFont()
+*/
+
+/*!
+ \fn QFontInfo QWidget::fontInfo() const
+
+ Returns the font info for the widget's current font.
+ Equivalent to QFontInto(widget->font()).
+
+ \sa font(), fontMetrics(), setFont()
+*/
+
+
+/*!
+ \property QWidget::cursor
+ \brief the cursor shape for this widget
+
+ The mouse cursor will assume this shape when it's over this
+ widget. See the \link Qt::CursorShape list of predefined cursor
+ objects\endlink for a range of useful shapes.
+
+ An editor widget might use an I-beam cursor:
+ \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 6
+
+ If no cursor has been set, or after a call to unsetCursor(), the
+ parent's cursor is used.
+
+ By default, this property contains a cursor with the Qt::ArrowCursor
+ shape.
+
+ Some underlying window implementations will reset the cursor if it
+ leaves a widget even if the mouse is grabbed. If you want to have
+ a cursor set for all widgets, even when outside the window, consider
+ QApplication::setOverrideCursor().
+
+ \sa QApplication::setOverrideCursor()
+*/
+
+#ifndef QT_NO_CURSOR
+QCursor QWidget::cursor() const
+{
+ Q_D(const QWidget);
+ if (testAttribute(Qt::WA_SetCursor))
+ return (d->extra && d->extra->curs)
+ ? *d->extra->curs
+ : QCursor(Qt::ArrowCursor);
+ if (isWindow() || !parentWidget())
+ return QCursor(Qt::ArrowCursor);
+ return parentWidget()->cursor();
+}
+
+void QWidget::setCursor(const QCursor &cursor)
+{
+ Q_D(QWidget);
+// On Mac we must set the cursor even if it is the ArrowCursor.
+#if !defined(Q_WS_MAC) && !defined(Q_WS_QWS)
+ if (cursor.shape() != Qt::ArrowCursor
+ || (d->extra && d->extra->curs))
+#endif
+ {
+ d->createExtra();
+ QCursor *newCursor = new QCursor(cursor);
+ delete d->extra->curs;
+ d->extra->curs = newCursor;
+ }
+ setAttribute(Qt::WA_SetCursor);
+ d->setCursor_sys(cursor);
+
+ QEvent event(QEvent::CursorChange);
+ QApplication::sendEvent(this, &event);
+}
+
+void QWidget::unsetCursor()
+{
+ Q_D(QWidget);
+ if (d->extra) {
+ delete d->extra->curs;
+ d->extra->curs = 0;
+ }
+ if (!isWindow())
+ setAttribute(Qt::WA_SetCursor, false);
+ d->unsetCursor_sys();
+
+ QEvent event(QEvent::CursorChange);
+ QApplication::sendEvent(this, &event);
+}
+
+#endif
+
+/*!
+ \enum QWidget::RenderFlag
+
+ This enum describes how to render the widget when calling QWidget::render().
+
+ \value DrawWindowBackground If you enable this option, the widget's background
+ is rendered into the target even if autoFillBackground is not set. By default,
+ this option is enabled.
+
+ \value DrawChildren If you enable this option, the widget's children
+ are rendered recursively into the target. By default, this option is enabled.
+
+ \value IgnoreMask If you enable this option, the widget's QWidget::mask()
+ is ignored when rendering into the target. By default, this option is disabled.
+
+ \since 4.3
+*/
+
+/*!
+ \since 4.3
+
+ Renders the \a sourceRegion of this widget into the \a target
+ using \a renderFlags to determine how to render. Rendering
+ starts at \a targetOffset in the \a target. For example:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 7
+
+ If \a sourceRegion is a null region, this function will use QWidget::rect() as
+ the region, i.e. the entire widget.
+
+ Ensure that you call QPainter::end() for the \a target device's
+ active painter (if any) before rendering. For example:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 8
+
+ \note To obtain the contents of an OpenGL widget, use QGLWidget::grabFrameBuffer()
+ or QGLWidget::renderPixmap() instead.
+*/
+void QWidget::render(QPaintDevice *target, const QPoint &targetOffset,
+ const QRegion &sourceRegion, RenderFlags renderFlags)
+{
+ d_func()->render(target, targetOffset, sourceRegion, renderFlags, false);
+}
+
+/*!
+ \overload
+
+ Renders the widget into the \a painter's QPainter::device().
+
+ Transformations and settings applied to the \a painter will be used
+ when rendering.
+
+ \note The \a painter must be active. On Mac OS X the widget will be
+ rendered into a QPixmap and then drawn by the \a painter.
+
+ \sa QPainter::device()
+*/
+void QWidget::render(QPainter *painter, const QPoint &targetOffset,
+ const QRegion &sourceRegion, RenderFlags renderFlags)
+{
+ if (!painter) {
+ qWarning("QWidget::render: Null pointer to painter");
+ return;
+ }
+
+ if (!painter->isActive()) {
+ qWarning("QWidget::render: Cannot render with an inactive painter");
+ return;
+ }
+
+ const qreal opacity = painter->opacity();
+ if (qFuzzyIsNull(opacity))
+ return; // Fully transparent.
+
+ Q_D(QWidget);
+ const bool inRenderWithPainter = d->extra && d->extra->inRenderWithPainter;
+ const QRegion toBePainted = !inRenderWithPainter ? d->prepareToRender(sourceRegion, renderFlags)
+ : sourceRegion;
+ if (toBePainted.isEmpty())
+ return;
+
+ if (!d->extra)
+ d->createExtra();
+ d->extra->inRenderWithPainter = true;
+
+#ifdef Q_WS_MAC
+ d->render_helper(painter, targetOffset, toBePainted, renderFlags);
+#else
+ QPaintEngine *engine = painter->paintEngine();
+ Q_ASSERT(engine);
+ QPaintEnginePrivate *enginePriv = engine->d_func();
+ Q_ASSERT(enginePriv);
+ QPaintDevice *target = engine->paintDevice();
+ Q_ASSERT(target);
+
+ // Render via a pixmap when dealing with non-opaque painters or printers.
+ if (!inRenderWithPainter && (opacity < 1.0 || (target->devType() == QInternal::Printer))) {
+ d->render_helper(painter, targetOffset, toBePainted, renderFlags);
+ d->extra->inRenderWithPainter = false;
+ return;
+ }
+
+ // Set new shared painter.
+ QPainter *oldPainter = d->sharedPainter();
+ d->setSharedPainter(painter);
+
+ // Save current system clip, viewport and transform,
+ const QTransform oldTransform = enginePriv->systemTransform;
+ const QRegion oldSystemClip = enginePriv->systemClip;
+ const QRegion oldSystemViewport = enginePriv->systemViewport;
+
+ // This ensures that all painting triggered by render() is clipped to the current engine clip.
+ if (painter->hasClipping()) {
+ const QRegion painterClip = painter->deviceTransform().map(painter->clipRegion());
+ enginePriv->setSystemViewport(oldSystemClip.isEmpty() ? painterClip : oldSystemClip & painterClip);
+ } else {
+ enginePriv->setSystemViewport(oldSystemClip);
+ }
+
+ render(target, targetOffset, toBePainted, renderFlags);
+
+ // Restore system clip, viewport and transform.
+ enginePriv->systemClip = oldSystemClip;
+ enginePriv->setSystemViewport(oldSystemViewport);
+ enginePriv->setSystemTransform(oldTransform);
+
+ // Restore shared painter.
+ d->setSharedPainter(oldPainter);
+#endif
+
+ d->extra->inRenderWithPainter = false;
+}
+
+/*!
+ \brief The graphicsEffect function returns a pointer to the
+ widget's graphics effect.
+
+ If the widget has no graphics effect, 0 is returned.
+
+ \since 4.6
+
+ \sa setGraphicsEffect()
+*/
+#ifndef QT_NO_GRAPHICSEFFECT
+QGraphicsEffect *QWidget::graphicsEffect() const
+{
+ Q_D(const QWidget);
+ return d->graphicsEffect;
+}
+#endif //QT_NO_GRAPHICSEFFECT
+
+/*!
+
+ \brief The setGraphicsEffect function is for setting the widget's graphics effect.
+
+ Sets \a effect as the widget's effect. If there already is an effect installed
+ on this widget, QWidget will delete the existing effect before installing
+ the new \a effect.
+
+ If \a effect is the installed on a different widget, setGraphicsEffect() will remove
+ the effect from the widget and install it on this widget.
+
+ QWidget takes ownership of \a effect.
+
+ \note This function will apply the effect on itself and all its children.
+
+ \since 4.6
+
+ \sa graphicsEffect()
+*/
+#ifndef QT_NO_GRAPHICSEFFECT
+void QWidget::setGraphicsEffect(QGraphicsEffect *effect)
+{
+ Q_D(QWidget);
+ if (d->graphicsEffect == effect)
+ return;
+
+ if (d->graphicsEffect) {
+ d->invalidateBuffer(rect());
+ delete d->graphicsEffect;
+ d->graphicsEffect = 0;
+ }
+
+ if (effect) {
+ // Set new effect.
+ QGraphicsEffectSourcePrivate *sourced = new QWidgetEffectSourcePrivate(this);
+ QGraphicsEffectSource *source = new QGraphicsEffectSource(*sourced);
+ d->graphicsEffect = effect;
+ effect->d_func()->setGraphicsEffectSource(source);
+ update();
+ }
+
+ d->updateIsOpaque();
+}
+#endif //QT_NO_GRAPHICSEFFECT
+
+bool QWidgetPrivate::isAboutToShow() const
+{
+ if (data.in_show)
+ return true;
+
+ Q_Q(const QWidget);
+ if (q->isHidden())
+ return false;
+
+ // The widget will be shown if any of its ancestors are about to show.
+ QWidget *parent = q->parentWidget();
+ return parent ? parent->d_func()->isAboutToShow() : false;
+}
+
+QRegion QWidgetPrivate::prepareToRender(const QRegion &region, QWidget::RenderFlags renderFlags)
+{
+ Q_Q(QWidget);
+ const bool isVisible = q->isVisible();
+
+ // Make sure the widget is laid out correctly.
+ if (!isVisible && !isAboutToShow()) {
+ QWidget *topLevel = q->window();
+ (void)topLevel->d_func()->topData(); // Make sure we at least have top-data.
+ topLevel->ensurePolished();
+
+ // Invalidate the layout of hidden ancestors (incl. myself) and pretend
+ // they're not explicitly hidden.
+ QWidget *widget = q;
+ QWidgetList hiddenWidgets;
+ while (widget) {
+ if (widget->isHidden()) {
+ widget->setAttribute(Qt::WA_WState_Hidden, false);
+ hiddenWidgets.append(widget);
+ if (!widget->isWindow() && widget->parentWidget()->d_func()->layout)
+ widget->d_func()->updateGeometry_helper(true);
+ }
+ widget = widget->parentWidget();
+ }
+
+ // Activate top-level layout.
+ if (topLevel->d_func()->layout)
+ topLevel->d_func()->layout->activate();
+
+ // Adjust size if necessary.
+ QTLWExtra *topLevelExtra = topLevel->d_func()->maybeTopData();
+ if (topLevelExtra && !topLevelExtra->sizeAdjusted
+ && !topLevel->testAttribute(Qt::WA_Resized)) {
+ topLevel->adjustSize();
+ topLevel->setAttribute(Qt::WA_Resized, false);
+ }
+
+ // Activate child layouts.
+ topLevel->d_func()->activateChildLayoutsRecursively();
+
+ // We're not cheating with WA_WState_Hidden anymore.
+ for (int i = 0; i < hiddenWidgets.size(); ++i) {
+ QWidget *widget = hiddenWidgets.at(i);
+ widget->setAttribute(Qt::WA_WState_Hidden);
+ if (!widget->isWindow() && widget->parentWidget()->d_func()->layout)
+ widget->parentWidget()->d_func()->layout->invalidate();
+ }
+ } else if (isVisible) {
+ q->window()->d_func()->sendPendingMoveAndResizeEvents(true, true);
+ }
+
+ // Calculate the region to be painted.
+ QRegion toBePainted = !region.isEmpty() ? region : QRegion(q->rect());
+ if (!(renderFlags & QWidget::IgnoreMask) && extra && extra->hasMask)
+ toBePainted &= extra->mask;
+ return toBePainted;
+}
+
+void QWidgetPrivate::render_helper(QPainter *painter, const QPoint &targetOffset, const QRegion &toBePainted,
+ QWidget::RenderFlags renderFlags)
+{
+ Q_ASSERT(painter);
+ Q_ASSERT(!toBePainted.isEmpty());
+
+ Q_Q(QWidget);
+#ifndef Q_WS_MAC
+ const QTransform originalTransform = painter->worldTransform();
+ const bool useDeviceCoordinates = originalTransform.isScaling();
+ if (!useDeviceCoordinates) {
+#endif
+ // Render via a pixmap.
+ const QRect rect = toBePainted.boundingRect();
+ const QSize size = rect.size();
+ if (size.isNull())
+ return;
+
+ QPixmap pixmap(size);
+ if (!(renderFlags & QWidget::DrawWindowBackground) || !isOpaque)
+ pixmap.fill(Qt::transparent);
+ q->render(&pixmap, QPoint(), toBePainted, renderFlags);
+
+ const bool restore = !(painter->renderHints() & QPainter::SmoothPixmapTransform);
+ painter->setRenderHints(QPainter::SmoothPixmapTransform, true);
+
+ painter->drawPixmap(targetOffset, pixmap);
+
+ if (restore)
+ painter->setRenderHints(QPainter::SmoothPixmapTransform, false);
+
+#ifndef Q_WS_MAC
+ } else {
+ // Render via a pixmap in device coordinates (to avoid pixmap scaling).
+ QTransform transform = originalTransform;
+ transform.translate(targetOffset.x(), targetOffset.y());
+
+ QPaintDevice *device = painter->device();
+ Q_ASSERT(device);
+
+ // Calculate device rect.
+ const QRectF rect(toBePainted.boundingRect());
+ QRect deviceRect = transform.mapRect(QRectF(0, 0, rect.width(), rect.height())).toAlignedRect();
+ deviceRect &= QRect(0, 0, device->width(), device->height());
+
+ QPixmap pixmap(deviceRect.size());
+ pixmap.fill(Qt::transparent);
+
+ // Create a pixmap device coordinate painter.
+ QPainter pixmapPainter(&pixmap);
+ pixmapPainter.setRenderHints(painter->renderHints());
+ transform *= QTransform::fromTranslate(-deviceRect.x(), -deviceRect.y());
+ pixmapPainter.setTransform(transform);
+
+ q->render(&pixmapPainter, QPoint(), toBePainted, renderFlags);
+ pixmapPainter.end();
+
+ // And then draw the pixmap.
+ painter->setTransform(QTransform());
+ painter->drawPixmap(deviceRect.topLeft(), pixmap);
+ painter->setTransform(originalTransform);
+ }
+#endif
+}
+
+void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags,
+ QPainter *sharedPainter, QWidgetBackingStore *backingStore)
+{
+ if (rgn.isEmpty())
+ return;
+
+#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
+ if (qt_mac_clearDirtyOnWidgetInsideDrawWidget)
+ dirtyOnWidget = QRegion();
+
+ // We disable the rendering of QToolBar in the backingStore if
+ // it's supposed to be in the unified toolbar on Mac OS X.
+ if (backingStore && isInUnifiedToolbar)
+ return;
+#endif // Q_WS_MAC && QT_MAC_USE_COCOA
+
+
+ Q_Q(QWidget);
+#ifndef QT_NO_GRAPHICSEFFECT
+ if (graphicsEffect && graphicsEffect->isEnabled()) {
+ QGraphicsEffectSource *source = graphicsEffect->d_func()->source;
+ QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *>
+ (source->d_func());
+ if (!sourced->context) {
+ QWidgetPaintContext context(pdev, rgn, offset, flags, sharedPainter, backingStore);
+ sourced->context = &context;
+ if (!sharedPainter) {
+ QPaintEngine *paintEngine = pdev->paintEngine();
+ paintEngine->d_func()->systemClip = rgn.translated(offset);
+ QPainter p(pdev);
+ p.translate(offset);
+ context.painter = &p;
+ graphicsEffect->draw(&p);
+ paintEngine->d_func()->systemClip = QRegion();
+ } else {
+ context.painter = sharedPainter;
+ if (sharedPainter->worldTransform() != sourced->lastEffectTransform) {
+ sourced->invalidateCache();
+ sourced->lastEffectTransform = sharedPainter->worldTransform();
+ }
+ sharedPainter->save();
+ sharedPainter->translate(offset);
+ graphicsEffect->draw(sharedPainter);
+ sharedPainter->restore();
+ }
+ sourced->context = 0;
+ return;
+ }
+ }
+#endif //QT_NO_GRAFFICSEFFECT
+
+ const bool asRoot = flags & DrawAsRoot;
+ const bool alsoOnScreen = flags & DrawPaintOnScreen;
+ const bool recursive = flags & DrawRecursive;
+ const bool alsoInvisible = flags & DrawInvisible;
+
+ Q_ASSERT(sharedPainter ? sharedPainter->isActive() : true);
+
+ QRegion toBePainted(rgn);
+ if (asRoot && !alsoInvisible)
+ toBePainted &= clipRect(); //(rgn & visibleRegion());
+ if (!(flags & DontSubtractOpaqueChildren))
+ subtractOpaqueChildren(toBePainted, q->rect());
+
+ if (!toBePainted.isEmpty()) {
+ bool onScreen = paintOnScreen();
+ if (!onScreen || alsoOnScreen) {
+ //update the "in paint event" flag
+ if (q->testAttribute(Qt::WA_WState_InPaintEvent))
+ qWarning("QWidget::repaint: Recursive repaint detected");
+ q->setAttribute(Qt::WA_WState_InPaintEvent);
+
+ //clip away the new area
+#ifndef QT_NO_PAINT_DEBUG
+ bool flushed = QWidgetBackingStore::flushPaint(q, toBePainted);
+#endif
+ QPaintEngine *paintEngine = pdev->paintEngine();
+ if (paintEngine) {
+ setRedirected(pdev, -offset);
+
+#ifdef Q_WS_MAC
+ // (Alien support) Special case for Mac when redirecting: If the paint device
+ // is of the Widget type we need to set WA_WState_InPaintEvent since painting
+ // outside the paint event is not supported on QWidgets. The attributeis
+ // restored further down.
+ if (pdev->devType() == QInternal::Widget)
+ static_cast<QWidget *>(pdev)->setAttribute(Qt::WA_WState_InPaintEvent);
+
+#endif
+ if (sharedPainter)
+ paintEngine->d_func()->systemClip = toBePainted;
+ else
+ paintEngine->d_func()->systemRect = q->data->crect;
+
+ //paint the background
+ if ((asRoot || q->autoFillBackground() || onScreen || q->testAttribute(Qt::WA_StyledBackground))
+ && !q->testAttribute(Qt::WA_OpaquePaintEvent) && !q->testAttribute(Qt::WA_NoSystemBackground)) {
+ QPainter p(q);
+ paintBackground(&p, toBePainted, (asRoot || onScreen) ? flags | DrawAsRoot : 0);
+ }
+
+ if (!sharedPainter)
+ paintEngine->d_func()->systemClip = toBePainted.translated(offset);
+
+ if (!onScreen && !asRoot && !isOpaque && q->testAttribute(Qt::WA_TintedBackground)) {
+ QPainter p(q);
+ QColor tint = q->palette().window().color();
+ tint.setAlphaF(qreal(.6));
+ p.fillRect(toBePainted.boundingRect(), tint);
+ }
+ }
+
+#if 0
+ qDebug() << "painting" << q << "opaque ==" << isOpaque();
+ qDebug() << "clipping to" << toBePainted << "location == " << offset
+ << "geometry ==" << QRect(q->mapTo(q->window(), QPoint(0, 0)), q->size());
+#endif
+
+ //actually send the paint event
+ QPaintEvent e(toBePainted);
+ QCoreApplication::sendSpontaneousEvent(q, &e);
+#if !defined(Q_WS_QWS) && !defined(Q_WS_QPA)
+ if (backingStore && !onScreen && !asRoot && (q->internalWinId() || !q->nativeParentWidget()->isWindow()))
+ backingStore->markDirtyOnScreen(toBePainted, q, offset);
+#endif
+
+ //restore
+ if (paintEngine) {
+#ifdef Q_WS_MAC
+ if (pdev->devType() == QInternal::Widget)
+ static_cast<QWidget *>(pdev)->setAttribute(Qt::WA_WState_InPaintEvent, false);
+#endif
+ restoreRedirected();
+ if (!sharedPainter)
+ paintEngine->d_func()->systemRect = QRect();
+ else
+ paintEngine->d_func()->currentClipDevice = 0;
+ paintEngine->d_func()->systemClip = QRegion();
+ }
+ q->setAttribute(Qt::WA_WState_InPaintEvent, false);
+ if (q->paintingActive() && !q->testAttribute(Qt::WA_PaintOutsidePaintEvent))
+ qWarning("QWidget::repaint: It is dangerous to leave painters active on a widget outside of the PaintEvent");
+
+ if (paintEngine && paintEngine->autoDestruct()) {
+ delete paintEngine;
+ }
+
+#ifndef QT_NO_PAINT_DEBUG
+ if (flushed)
+ QWidgetBackingStore::unflushPaint(q, toBePainted);
+#endif
+ } else if (q->isWindow()) {
+ QPaintEngine *engine = pdev->paintEngine();
+ if (engine) {
+ QPainter p(pdev);
+ p.setClipRegion(toBePainted);
+ const QBrush bg = q->palette().brush(QPalette::Window);
+ if (bg.style() == Qt::TexturePattern)
+ p.drawTiledPixmap(q->rect(), bg.texture());
+ else
+ p.fillRect(q->rect(), bg);
+
+ if (engine->autoDestruct())
+ delete engine;
+ }
+ }
+ }
+
+ if (recursive && !children.isEmpty()) {
+ paintSiblingsRecursive(pdev, children, children.size() - 1, rgn, offset, flags & ~DrawAsRoot
+#ifdef Q_BACKINGSTORE_SUBSURFACES
+ , q->windowSurface()
+#endif
+ , sharedPainter, backingStore);
+ }
+}
+
+void QWidgetPrivate::render(QPaintDevice *target, const QPoint &targetOffset,
+ const QRegion &sourceRegion, QWidget::RenderFlags renderFlags,
+ bool readyToRender)
+{
+ if (!target) {
+ qWarning("QWidget::render: null pointer to paint device");
+ return;
+ }
+
+ const bool inRenderWithPainter = extra && extra->inRenderWithPainter;
+ QRegion paintRegion = !inRenderWithPainter && !readyToRender
+ ? prepareToRender(sourceRegion, renderFlags)
+ : sourceRegion;
+ if (paintRegion.isEmpty())
+ return;
+
+#ifndef Q_WS_MAC
+ QPainter *oldSharedPainter = inRenderWithPainter ? sharedPainter() : 0;
+
+ // Use the target's shared painter if set (typically set when doing
+ // "other->render(widget);" in the widget's paintEvent.
+ if (target->devType() == QInternal::Widget) {
+ QWidgetPrivate *targetPrivate = static_cast<QWidget *>(target)->d_func();
+ if (targetPrivate->extra && targetPrivate->extra->inRenderWithPainter) {
+ QPainter *targetPainter = targetPrivate->sharedPainter();
+ if (targetPainter && targetPainter->isActive())
+ setSharedPainter(targetPainter);
+ }
+ }
+#endif
+
+ // Use the target's redirected device if set and adjust offset and paint
+ // region accordingly. This is typically the case when people call render
+ // from the paintEvent.
+ QPoint offset = targetOffset;
+ offset -= paintRegion.boundingRect().topLeft();
+ QPoint redirectionOffset;
+ QPaintDevice *redirected = 0;
+
+ if (target->devType() == QInternal::Widget)
+ redirected = static_cast<QWidget *>(target)->d_func()->redirected(&redirectionOffset);
+ if (!redirected)
+ redirected = QPainter::redirected(target, &redirectionOffset);
+
+ if (redirected) {
+ target = redirected;
+ offset -= redirectionOffset;
+ }
+
+ if (!inRenderWithPainter) { // Clip handled by shared painter (in qpainter.cpp).
+ if (QPaintEngine *targetEngine = target->paintEngine()) {
+ const QRegion targetSystemClip = targetEngine->systemClip();
+ if (!targetSystemClip.isEmpty())
+ paintRegion &= targetSystemClip.translated(-offset);
+ }
+ }
+
+ // Set backingstore flags.
+ int flags = DrawPaintOnScreen | DrawInvisible;
+ if (renderFlags & QWidget::DrawWindowBackground)
+ flags |= DrawAsRoot;
+
+ if (renderFlags & QWidget::DrawChildren)
+ flags |= DrawRecursive;
+ else
+ flags |= DontSubtractOpaqueChildren;
+
+#ifdef Q_WS_QWS
+ flags |= DontSetCompositionMode;
+#endif
+
+ if (target->devType() == QInternal::Printer) {
+ QPainter p(target);
+ render_helper(&p, targetOffset, paintRegion, renderFlags);
+ return;
+ }
+
+#ifndef Q_WS_MAC
+ // Render via backingstore.
+ drawWidget(target, paintRegion, offset, flags, sharedPainter());
+
+ // Restore shared painter.
+ if (oldSharedPainter)
+ setSharedPainter(oldSharedPainter);
+#else
+ // Render via backingstore (no shared painter).
+ drawWidget(target, paintRegion, offset, flags, 0);
+#endif
+}
+
+void QWidgetPrivate::paintSiblingsRecursive(QPaintDevice *pdev, const QObjectList& siblings, int index, const QRegion &rgn,
+ const QPoint &offset, int flags
+#ifdef Q_BACKINGSTORE_SUBSURFACES
+ , const QWindowSurface *currentSurface
+#endif
+ , QPainter *sharedPainter, QWidgetBackingStore *backingStore)
+{
+ QWidget *w = 0;
+ QRect boundingRect;
+ bool dirtyBoundingRect = true;
+ const bool exludeOpaqueChildren = (flags & DontDrawOpaqueChildren);
+ const bool excludeNativeChildren = (flags & DontDrawNativeChildren);
+
+ do {
+ QWidget *x = qobject_cast<QWidget*>(siblings.at(index));
+ if (x && !(exludeOpaqueChildren && x->d_func()->isOpaque) && !x->isHidden() && !x->isWindow()
+ && !(excludeNativeChildren && x->internalWinId())) {
+ if (dirtyBoundingRect) {
+ boundingRect = rgn.boundingRect();
+ dirtyBoundingRect = false;
+ }
+
+ if (qRectIntersects(boundingRect, x->d_func()->effectiveRectFor(x->data->crect))) {
+#ifdef Q_BACKINGSTORE_SUBSURFACES
+ if (x->windowSurface() == currentSurface)
+#endif
+ {
+ w = x;
+ break;
+ }
+ }
+ }
+ --index;
+ } while (index >= 0);
+
+ if (!w)
+ return;
+
+ QWidgetPrivate *wd = w->d_func();
+ const QPoint widgetPos(w->data->crect.topLeft());
+ const bool hasMask = wd->extra && wd->extra->hasMask && !wd->graphicsEffect;
+ if (index > 0) {
+ QRegion wr(rgn);
+ if (wd->isOpaque)
+ wr -= hasMask ? wd->extra->mask.translated(widgetPos) : w->data->crect;
+ paintSiblingsRecursive(pdev, siblings, --index, wr, offset, flags
+#ifdef Q_BACKINGSTORE_SUBSURFACES
+ , currentSurface
+#endif
+ , sharedPainter, backingStore);
+ }
+
+ if (w->updatesEnabled()
+#ifndef QT_NO_GRAPHICSVIEW
+ && (!w->d_func()->extra || !w->d_func()->extra->proxyWidget)
+#endif //QT_NO_GRAPHICSVIEW
+ ) {
+ QRegion wRegion(rgn);
+ wRegion &= wd->effectiveRectFor(w->data->crect);
+ wRegion.translate(-widgetPos);
+ if (hasMask)
+ wRegion &= wd->extra->mask;
+ wd->drawWidget(pdev, wRegion, offset + widgetPos, flags, sharedPainter, backingStore);
+ }
+}
+
+#ifndef QT_NO_GRAPHICSEFFECT
+QRectF QWidgetEffectSourcePrivate::boundingRect(Qt::CoordinateSystem system) const
+{
+ if (system != Qt::DeviceCoordinates)
+ return m_widget->rect();
+
+ if (!context) {
+ // Device coordinates without context not yet supported.
+ qWarning("QGraphicsEffectSource::boundingRect: Not yet implemented, lacking device context");
+ return QRectF();
+ }
+
+ return context->painter->worldTransform().mapRect(m_widget->rect());
+}
+
+void QWidgetEffectSourcePrivate::draw(QPainter *painter)
+{
+ if (!context || context->painter != painter) {
+ m_widget->render(painter);
+ return;
+ }
+
+ // The region saved in the context is neither clipped to the rect
+ // nor the mask, so we have to clip it here before calling drawWidget.
+ QRegion toBePainted = context->rgn;
+ toBePainted &= m_widget->rect();
+ QWidgetPrivate *wd = qt_widget_private(m_widget);
+ if (wd->extra && wd->extra->hasMask)
+ toBePainted &= wd->extra->mask;
+
+ wd->drawWidget(context->pdev, toBePainted, context->offset, context->flags,
+ context->sharedPainter, context->backingStore);
+}
+
+QPixmap QWidgetEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset,
+ QGraphicsEffect::PixmapPadMode mode) const
+{
+ const bool deviceCoordinates = (system == Qt::DeviceCoordinates);
+ if (!context && deviceCoordinates) {
+ // Device coordinates without context not yet supported.
+ qWarning("QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context");
+ return QPixmap();
+ }
+
+ QPoint pixmapOffset;
+ QRectF sourceRect = m_widget->rect();
+
+ if (deviceCoordinates) {
+ const QTransform &painterTransform = context->painter->worldTransform();
+ sourceRect = painterTransform.mapRect(sourceRect);
+ pixmapOffset = painterTransform.map(pixmapOffset);
+ }
+
+ QRect effectRect;
+
+ if (mode == QGraphicsEffect::PadToEffectiveBoundingRect)
+ effectRect = m_widget->graphicsEffect()->boundingRectFor(sourceRect).toAlignedRect();
+ else if (mode == QGraphicsEffect::PadToTransparentBorder)
+ effectRect = sourceRect.adjusted(-1, -1, 1, 1).toAlignedRect();
+ else
+ effectRect = sourceRect.toAlignedRect();
+
+ if (offset)
+ *offset = effectRect.topLeft();
+
+ pixmapOffset -= effectRect.topLeft();
+
+ QPixmap pixmap(effectRect.size());
+ pixmap.fill(Qt::transparent);
+ m_widget->render(&pixmap, pixmapOffset, QRegion(), QWidget::DrawChildren);
+ return pixmap;
+}
+#endif //QT_NO_GRAPHICSEFFECT
+
+#ifndef QT_NO_GRAPHICSVIEW
+/*!
+ \internal
+
+ Finds the nearest widget embedded in a graphics proxy widget along the chain formed by this
+ widget and its ancestors. The search starts at \a origin (inclusive).
+ If successful, the function returns the proxy that embeds the widget, or 0 if no embedded
+ widget was found.
+*/
+QGraphicsProxyWidget * QWidgetPrivate::nearestGraphicsProxyWidget(const QWidget *origin)
+{
+ if (origin) {
+ QWExtra *extra = origin->d_func()->extra;
+ if (extra && extra->proxyWidget)
+ return extra->proxyWidget;
+ return nearestGraphicsProxyWidget(origin->parentWidget());
+ }
+ return 0;
+}
+#endif
+
+/*!
+ \property QWidget::locale
+ \brief the widget's locale
+ \since 4.3
+
+ As long as no special locale has been set, this is either
+ the parent's locale or (if this widget is a top level widget),
+ the default locale.
+
+ If the widget displays dates or numbers, these should be formatted
+ using the widget's locale.
+
+ \sa QLocale QLocale::setDefault()
+*/
+
+void QWidgetPrivate::setLocale_helper(const QLocale &loc, bool forceUpdate)
+{
+ Q_Q(QWidget);
+ if (locale == loc && !forceUpdate)
+ return;
+
+ locale = loc;
+
+ if (!children.isEmpty()) {
+ for (int i = 0; i < children.size(); ++i) {
+ QWidget *w = qobject_cast<QWidget*>(children.at(i));
+ if (!w)
+ continue;
+ if (w->testAttribute(Qt::WA_SetLocale))
+ continue;
+ if (w->isWindow() && !w->testAttribute(Qt::WA_WindowPropagation))
+ continue;
+ w->d_func()->setLocale_helper(loc, forceUpdate);
+ }
+ }
+ QEvent e(QEvent::LocaleChange);
+ QApplication::sendEvent(q, &e);
+}
+
+void QWidget::setLocale(const QLocale &locale)
+{
+ Q_D(QWidget);
+
+ setAttribute(Qt::WA_SetLocale);
+ d->setLocale_helper(locale);
+}
+
+QLocale QWidget::locale() const
+{
+ Q_D(const QWidget);
+
+ return d->locale;
+}
+
+void QWidgetPrivate::resolveLocale()
+{
+ Q_Q(const QWidget);
+
+ if (!q->testAttribute(Qt::WA_SetLocale)) {
+ setLocale_helper(q->isWindow()
+ ? QLocale()
+ : q->parentWidget()->locale());
+ }
+}
+
+void QWidget::unsetLocale()
+{
+ Q_D(QWidget);
+ setAttribute(Qt::WA_SetLocale, false);
+ d->resolveLocale();
+}
+
+static QString constructWindowTitleFromFilePath(const QString &filePath)
+{
+ QFileInfo fi(filePath);
+ QString windowTitle = fi.fileName() + QLatin1String("[*]");
+#ifndef Q_WS_MAC
+ QString appName = QApplication::applicationName();
+ if (!appName.isEmpty())
+ windowTitle += QLatin1Char(' ') + QChar(0x2014) + QLatin1Char(' ') + appName;
+#endif
+ return windowTitle;
+}
+
+/*!
+ \property QWidget::windowTitle
+ \brief the window title (caption)
+
+ This property only makes sense for top-level widgets, such as
+ windows and dialogs. If no caption has been set, the title is based of the
+ \l windowFilePath. If neither of these is set, then the title is
+ an empty string.
+
+ If you use the \l windowModified mechanism, the window title must
+ contain a "[*]" placeholder, which indicates where the '*' should
+ appear. Normally, it should appear right after the file name
+ (e.g., "document1.txt[*] - Text Editor"). If the \l
+ windowModified property is false (the default), the placeholder
+ is simply removed.
+
+ \sa windowIcon, windowIconText, windowModified, windowFilePath
+*/
+QString QWidget::windowTitle() const
+{
+ Q_D(const QWidget);
+ if (d->extra && d->extra->topextra) {
+ if (!d->extra->topextra->caption.isEmpty())
+ return d->extra->topextra->caption;
+ if (!d->extra->topextra->filePath.isEmpty())
+ return constructWindowTitleFromFilePath(d->extra->topextra->filePath);
+ }
+ return QString();
+}
+
+/*!
+ Returns a modified window title with the [*] place holder
+ replaced according to the rules described in QWidget::setWindowTitle
+
+ This function assumes that "[*]" can be quoted by another
+ "[*]", so it will replace two place holders by one and
+ a single last one by either "*" or nothing depending on
+ the modified flag.
+
+ \internal
+*/
+QString qt_setWindowTitle_helperHelper(const QString &title, const QWidget *widget)
+{
+ Q_ASSERT(widget);
+
+#ifdef QT_EVAL
+ extern QString qt_eval_adapt_window_title(const QString &title);
+ QString cap = qt_eval_adapt_window_title(title);
+#else
+ QString cap = title;
+#endif
+
+ if (cap.isEmpty())
+ return cap;
+
+ QLatin1String placeHolder("[*]");
+ int placeHolderLength = 3; // QLatin1String doesn't have length()
+
+ int index = cap.indexOf(placeHolder);
+
+ // here the magic begins
+ while (index != -1) {
+ index += placeHolderLength;
+ int count = 1;
+ while (cap.indexOf(placeHolder, index) == index) {
+ ++count;
+ index += placeHolderLength;
+ }
+
+ if (count%2) { // odd number of [*] -> replace last one
+ int lastIndex = cap.lastIndexOf(placeHolder, index - 1);
+ if (widget->isWindowModified()
+ && widget->style()->styleHint(QStyle::SH_TitleBar_ModifyNotification, 0, widget))
+ cap.replace(lastIndex, 3, QWidget::tr("*"));
+ else
+ cap.remove(lastIndex, 3);
+ }
+
+ index = cap.indexOf(placeHolder, index);
+ }
+
+ cap.replace(QLatin1String("[*][*]"), placeHolder);
+
+ return cap;
+}
+
+void QWidgetPrivate::setWindowTitle_helper(const QString &title)
+{
+ Q_Q(QWidget);
+ if (q->testAttribute(Qt::WA_WState_Created))
+ setWindowTitle_sys(qt_setWindowTitle_helperHelper(title, q));
+}
+
+void QWidgetPrivate::setWindowIconText_helper(const QString &title)
+{
+ Q_Q(QWidget);
+ if (q->testAttribute(Qt::WA_WState_Created))
+ setWindowIconText_sys(qt_setWindowTitle_helperHelper(title, q));
+}
+
+void QWidget::setWindowIconText(const QString &iconText)
+{
+ if (QWidget::windowIconText() == iconText)
+ return;
+
+ Q_D(QWidget);
+ d->topData()->iconText = iconText;
+ d->setWindowIconText_helper(iconText);
+
+ QEvent e(QEvent::IconTextChange);
+ QApplication::sendEvent(this, &e);
+}
+
+void QWidget::setWindowTitle(const QString &title)
+{
+ if (QWidget::windowTitle() == title && !title.isEmpty() && !title.isNull())
+ return;
+
+ Q_D(QWidget);
+ d->topData()->caption = title;
+ d->setWindowTitle_helper(title);
+
+ QEvent e(QEvent::WindowTitleChange);
+ QApplication::sendEvent(this, &e);
+}
+
+
+/*!
+ \property QWidget::windowIcon
+ \brief the widget's icon
+
+ This property only makes sense for windows. If no icon
+ has been set, windowIcon() returns the application icon
+ (QApplication::windowIcon()).
+
+ \sa windowIconText, windowTitle
+*/
+QIcon QWidget::windowIcon() const
+{
+ const QWidget *w = this;
+ while (w) {
+ const QWidgetPrivate *d = w->d_func();
+ if (d->extra && d->extra->topextra && d->extra->topextra->icon)
+ return *d->extra->topextra->icon;
+ w = w->parentWidget();
+ }
+ return QApplication::windowIcon();
+}
+
+void QWidgetPrivate::setWindowIcon_helper()
+{
+ QEvent e(QEvent::WindowIconChange);
+ QApplication::sendEvent(q_func(), &e);
+ for (int i = 0; i < children.size(); ++i) {
+ QWidget *w = qobject_cast<QWidget *>(children.at(i));
+ if (w && !w->isWindow())
+ QApplication::sendEvent(w, &e);
+ }
+}
+
+void QWidget::setWindowIcon(const QIcon &icon)
+{
+ Q_D(QWidget);
+
+ setAttribute(Qt::WA_SetWindowIcon, !icon.isNull());
+ d->createTLExtra();
+
+ if (!d->extra->topextra->icon)
+ d->extra->topextra->icon = new QIcon();
+ *d->extra->topextra->icon = icon;
+
+ delete d->extra->topextra->iconPixmap;
+ d->extra->topextra->iconPixmap = 0;
+
+ d->setWindowIcon_sys();
+ d->setWindowIcon_helper();
+}
+
+
+/*!
+ \property QWidget::windowIconText
+ \brief the widget's icon text
+
+ This property only makes sense for windows. If no icon
+ text has been set, this functions returns an empty string.
+
+ \sa windowIcon, windowTitle
+*/
+
+QString QWidget::windowIconText() const
+{
+ Q_D(const QWidget);
+ return (d->extra && d->extra->topextra) ? d->extra->topextra->iconText : QString();
+}
+
+/*!
+ \property QWidget::windowFilePath
+ \since 4.4
+ \brief the file path associated with a widget
+
+ This property only makes sense for windows. It associates a file path with
+ a window. If you set the file path, but have not set the window title, Qt
+ sets the window title to contain a string created using the following
+ components.
+
+ On Mac OS X:
+
+ \list
+ \o The file name of the specified path, obtained using QFileInfo::fileName().
+ \endlist
+
+ On Windows and X11:
+
+ \list
+ \o The file name of the specified path, obtained using QFileInfo::fileName().
+ \o An optional \c{*} character, if the \l windowModified property is set.
+ \o The \c{0x2014} unicode character, padded either side by spaces.
+ \o The application name, obtained from the application's
+ \l{QCoreApplication::}{applicationName} property.
+ \endlist
+
+ If the window title is set at any point, then the window title takes precedence and
+ will be shown instead of the file path string.
+
+ Additionally, on Mac OS X, this has an added benefit that it sets the
+ \l{http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGWindows/chapter_17_section_3.html}{proxy icon}
+ for the window, assuming that the file path exists.
+
+ If no file path is set, this property contains an empty string.
+
+ By default, this property contains an empty string.
+
+ \sa windowTitle, windowIcon
+*/
+
+QString QWidget::windowFilePath() const
+{
+ Q_D(const QWidget);
+ return (d->extra && d->extra->topextra) ? d->extra->topextra->filePath : QString();
+}
+
+void QWidget::setWindowFilePath(const QString &filePath)
+{
+ if (filePath == windowFilePath())
+ return;
+
+ Q_D(QWidget);
+
+ d->createTLExtra();
+ d->extra->topextra->filePath = filePath;
+ d->setWindowFilePath_helper(filePath);
+}
+
+void QWidgetPrivate::setWindowFilePath_helper(const QString &filePath)
+{
+ if (extra->topextra && extra->topextra->caption.isEmpty()) {
+#ifdef Q_WS_MAC
+ setWindowTitle_helper(QFileInfo(filePath).fileName());
+#else
+ Q_Q(QWidget);
+ Q_UNUSED(filePath);
+ setWindowTitle_helper(q->windowTitle());
+#endif
+ }
+#ifdef Q_WS_MAC
+ setWindowFilePath_sys(filePath);
+#endif
+}
+
+/*!
+ Returns the window's role, or an empty string.
+
+ \sa windowIcon, windowTitle
+*/
+
+QString QWidget::windowRole() const
+{
+ Q_D(const QWidget);
+ return (d->extra && d->extra->topextra) ? d->extra->topextra->role : QString();
+}
+
+/*!
+ Sets the window's role to \a role. This only makes sense for
+ windows on X11.
+*/
+void QWidget::setWindowRole(const QString &role)
+{
+#if defined(Q_WS_X11)
+ Q_D(QWidget);
+ d->topData()->role = role;
+ d->setWindowRole();
+#else
+ Q_UNUSED(role)
+#endif
+}
+
+/*!
+ \property QWidget::mouseTracking
+ \brief whether mouse tracking is enabled for the widget
+
+ If mouse tracking is disabled (the default), the widget only
+ receives mouse move events when at least one mouse button is
+ pressed while the mouse is being moved.
+
+ If mouse tracking is enabled, the widget receives mouse move
+ events even if no buttons are pressed.
+
+ \sa mouseMoveEvent()
+*/
+
+
+/*!
+ Sets the widget's focus proxy to widget \a w. If \a w is 0, the
+ function resets this widget to have no focus proxy.
+
+ Some widgets can "have focus", but create a child widget, such as
+ QLineEdit, to actually handle the focus. In this case, the widget
+ can set the line edit to be its focus proxy.
+
+ setFocusProxy() sets the widget which will actually get focus when
+ "this widget" gets it. If there is a focus proxy, setFocus() and
+ hasFocus() operate on the focus proxy.
+
+ \sa focusProxy()
+*/
+
+void QWidget::setFocusProxy(QWidget * w)
+{
+ Q_D(QWidget);
+ if (!w && !d->extra)
+ return;
+
+ for (QWidget* fp = w; fp; fp = fp->focusProxy()) {
+ if (fp == this) {
+ qWarning("QWidget: %s (%s) already in focus proxy chain", metaObject()->className(), objectName().toLocal8Bit().constData());
+ return;
+ }
+ }
+
+ d->createExtra();
+ d->extra->focus_proxy = w;
+}
+
+
+/*!
+ Returns the focus proxy, or 0 if there is no focus proxy.
+
+ \sa setFocusProxy()
+*/
+
+QWidget * QWidget::focusProxy() const
+{
+ Q_D(const QWidget);
+ return d->extra ? (QWidget *)d->extra->focus_proxy : 0;
+}
+
+
+/*!
+ \property QWidget::focus
+ \brief whether this widget (or its focus proxy) has the keyboard
+ input focus
+
+ By default, this property is false.
+
+ \note Obtaining the value of this property for a widget is effectively equivalent
+ to checking whether QApplication::focusWidget() refers to the widget.
+
+ \sa setFocus(), clearFocus(), setFocusPolicy(), QApplication::focusWidget()
+*/
+bool QWidget::hasFocus() const
+{
+ const QWidget* w = this;
+ while (w->d_func()->extra && w->d_func()->extra->focus_proxy)
+ w = w->d_func()->extra->focus_proxy;
+ if (QWidget *window = w->window()) {
+#ifndef QT_NO_GRAPHICSVIEW
+ QWExtra *e = window->d_func()->extra;
+ if (e && e->proxyWidget && e->proxyWidget->hasFocus() && window->focusWidget() == w)
+ return true;
+#endif
+ }
+ return (QApplication::focusWidget() == w);
+}
+
+/*!
+ Gives the keyboard input focus to this widget (or its focus
+ proxy) if this widget or one of its parents is the \link
+ isActiveWindow() active window\endlink. The \a reason argument will
+ be passed into any focus event sent from this function, it is used
+ to give an explanation of what caused the widget to get focus.
+ If the window is not active, the widget will be given the focus when
+ the window becomes active.
+
+ First, a focus out event is sent to the focus widget (if any) to
+ tell it that it is about to lose the focus. Then a focus in event
+ is sent to this widget to tell it that it just received the focus.
+ (Nothing happens if the focus in and focus out widgets are the
+ same.)
+
+ \note On embedded platforms, setFocus() will not cause an input panel
+ to be opened by the input method. If you want this to happen, you
+ have to send a QEvent::RequestSoftwareInputPanel event to the
+ widget yourself.
+
+ setFocus() gives focus to a widget regardless of its focus policy,
+ but does not clear any keyboard grab (see grabKeyboard()).
+
+ Be aware that if the widget is hidden, it will not accept focus
+ until it is shown.
+
+ \warning If you call setFocus() in a function which may itself be
+ called from focusOutEvent() or focusInEvent(), you may get an
+ infinite recursion.
+
+ \sa hasFocus(), clearFocus(), focusInEvent(), focusOutEvent(),
+ setFocusPolicy(), focusWidget(), QApplication::focusWidget(), grabKeyboard(),
+ grabMouse(), {Keyboard Focus}, QEvent::RequestSoftwareInputPanel
+*/
+
+void QWidget::setFocus(Qt::FocusReason reason)
+{
+ if (!isEnabled())
+ return;
+
+ QWidget *f = this;
+ while (f->d_func()->extra && f->d_func()->extra->focus_proxy)
+ f = f->d_func()->extra->focus_proxy;
+
+ if (QApplication::focusWidget() == f
+#if defined(Q_WS_WIN)
+ && GetFocus() == f->internalWinId()
+#endif
+ )
+ return;
+
+#ifndef QT_NO_GRAPHICSVIEW
+ QWidget *previousProxyFocus = 0;
+ if (QWExtra *topData = window()->d_func()->extra) {
+ if (topData->proxyWidget && topData->proxyWidget->hasFocus()) {
+ previousProxyFocus = topData->proxyWidget->widget()->focusWidget();
+ if (previousProxyFocus && previousProxyFocus->focusProxy())
+ previousProxyFocus = previousProxyFocus->focusProxy();
+ if (previousProxyFocus == this && !topData->proxyWidget->d_func()->proxyIsGivingFocus)
+ return;
+ }
+ }
+#endif
+
+ QWidget *w = f;
+ if (isHidden()) {
+ while (w && w->isHidden()) {
+ w->d_func()->focus_child = f;
+ w = w->isWindow() ? 0 : w->parentWidget();
+ }
+ } else {
+ while (w) {
+ w->d_func()->focus_child = f;
+ w = w->isWindow() ? 0 : w->parentWidget();
+ }
+ }
+
+#ifndef QT_NO_GRAPHICSVIEW
+ // Update proxy state
+ if (QWExtra *topData = window()->d_func()->extra) {
+ if (topData->proxyWidget && !topData->proxyWidget->hasFocus()) {
+ topData->proxyWidget->d_func()->focusFromWidgetToProxy = 1;
+ topData->proxyWidget->setFocus(reason);
+ topData->proxyWidget->d_func()->focusFromWidgetToProxy = 0;
+ }
+ }
+#endif
+
+ if (f->isActiveWindow()) {
+ QApplicationPrivate::setFocusWidget(f, reason);
+#ifndef QT_NO_ACCESSIBILITY
+# ifdef Q_OS_WIN
+ // The negation of the condition in setFocus_sys
+ if (!(testAttribute(Qt::WA_WState_Created) && window()->windowType() != Qt::Popup && internalWinId()))
+ //setFocusWidget will already post a focus event for us (that the AT client receives) on Windows
+# endif
+ QAccessible::updateAccessibility(f, 0, QAccessible::Focus);
+#endif
+#ifndef QT_NO_GRAPHICSVIEW
+ if (QWExtra *topData = window()->d_func()->extra) {
+ if (topData->proxyWidget) {
+ if (previousProxyFocus && previousProxyFocus != f) {
+ // Send event to self
+ QFocusEvent event(QEvent::FocusOut, reason);
+ QPointer<QWidget> that = previousProxyFocus;
+ QApplication::sendEvent(previousProxyFocus, &event);
+ if (that)
+ QApplication::sendEvent(that->style(), &event);
+ }
+ if (!isHidden()) {
+#ifndef QT_NO_GRAPHICSVIEW
+ // Update proxy state
+ if (QWExtra *topData = window()->d_func()->extra)
+ if (topData->proxyWidget && topData->proxyWidget->hasFocus())
+ topData->proxyWidget->d_func()->updateProxyInputMethodAcceptanceFromWidget();
+#endif
+ // Send event to self
+ QFocusEvent event(QEvent::FocusIn, reason);
+ QPointer<QWidget> that = f;
+ QApplication::sendEvent(f, &event);
+ if (that)
+ QApplication::sendEvent(that->style(), &event);
+ }
+ }
+ }
+#endif
+ }
+}
+
+/*!
+ \fn void QWidget::setFocus()
+ \overload
+
+ Gives the keyboard input focus to this widget (or its focus
+ proxy) if this widget or one of its parents is the
+ \l{isActiveWindow()}{active window}.
+*/
+
+/*!
+ Takes keyboard input focus from the widget.
+
+ If the widget has active focus, a \link focusOutEvent() focus out
+ event\endlink is sent to this widget to tell it that it is about
+ to lose the focus.
+
+ This widget must enable focus setting in order to get the keyboard
+ input focus, i.e. it must call setFocusPolicy().
+
+ \sa hasFocus(), setFocus(), focusInEvent(), focusOutEvent(),
+ setFocusPolicy(), QApplication::focusWidget()
+*/
+
+void QWidget::clearFocus()
+{
+ QWidget *w = this;
+ while (w) {
+ if (w->d_func()->focus_child == this)
+ w->d_func()->focus_child = 0;
+ w = w->parentWidget();
+ }
+#ifndef QT_NO_GRAPHICSVIEW
+ QWExtra *topData = d_func()->extra;
+ if (topData && topData->proxyWidget)
+ topData->proxyWidget->clearFocus();
+#endif
+
+ if (hasFocus()) {
+ // Update proxy state
+ QApplicationPrivate::setFocusWidget(0, Qt::OtherFocusReason);
+#if defined(Q_WS_WIN)
+ if (!(windowType() == Qt::Popup) && GetFocus() == internalWinId())
+ SetFocus(0);
+ else
+#endif
+ {
+#ifndef QT_NO_ACCESSIBILITY
+ QAccessible::updateAccessibility(this, 0, QAccessible::Focus);
+#endif
+ }
+ }
+}
+
+
+/*!
+ \fn bool QWidget::focusNextChild()
+
+ Finds a new widget to give the keyboard focus to, as appropriate
+ for \key Tab, and returns true if it can find a new widget, or
+ false if it can't.
+
+ \sa focusPreviousChild()
+*/
+
+/*!
+ \fn bool QWidget::focusPreviousChild()
+
+ Finds a new widget to give the keyboard focus to, as appropriate
+ for \key Shift+Tab, and returns true if it can find a new widget,
+ or false if it can't.
+
+ \sa focusNextChild()
+*/
+
+/*!
+ Finds a new widget to give the keyboard focus to, as appropriate
+ for Tab and Shift+Tab, and returns true if it can find a new
+ widget, or false if it can't.
+
+ If \a next is true, this function searches forward, if \a next
+ is false, it searches backward.
+
+ Sometimes, you will want to reimplement this function. For
+ example, a web browser might reimplement it to move its "current
+ active link" forward or backward, and call
+ focusNextPrevChild() only when it reaches the last or
+ first link on the "page".
+
+ Child widgets call focusNextPrevChild() on their parent widgets,
+ but only the window that contains the child widgets decides where
+ to redirect focus. By reimplementing this function for an object,
+ you thus gain control of focus traversal for all child widgets.
+
+ \sa focusNextChild(), focusPreviousChild()
+*/
+
+bool QWidget::focusNextPrevChild(bool next)
+{
+ Q_D(QWidget);
+ QWidget* p = parentWidget();
+ bool isSubWindow = (windowType() == Qt::SubWindow);
+ if (!isWindow() && !isSubWindow && p)
+ return p->focusNextPrevChild(next);
+#ifndef QT_NO_GRAPHICSVIEW
+ if (d->extra && d->extra->proxyWidget)
+ return d->extra->proxyWidget->focusNextPrevChild(next);
+#endif
+ QWidget *w = QApplicationPrivate::focusNextPrevChild_helper(this, next);
+ if (!w) return false;
+
+ w->setFocus(next ? Qt::TabFocusReason : Qt::BacktabFocusReason);
+ return true;
+}
+
+/*!
+ Returns the last child of this widget that setFocus had been
+ called on. For top level widgets this is the widget that will get
+ focus in case this window gets activated
+
+ This is not the same as QApplication::focusWidget(), which returns
+ the focus widget in the currently active window.
+*/
+
+QWidget *QWidget::focusWidget() const
+{
+ return const_cast<QWidget *>(d_func()->focus_child);
+}
+
+/*!
+ Returns the next widget in this widget's focus chain.
+
+ \sa previousInFocusChain()
+*/
+QWidget *QWidget::nextInFocusChain() const
+{
+ return const_cast<QWidget *>(d_func()->focus_next);
+}
+
+/*!
+ \brief The previousInFocusChain function returns the previous
+ widget in this widget's focus chain.
+
+ \sa nextInFocusChain()
+
+ \since 4.6
+*/
+QWidget *QWidget::previousInFocusChain() const
+{
+ return const_cast<QWidget *>(d_func()->focus_prev);
+}
+
+/*!
+ \property QWidget::isActiveWindow
+ \brief whether this widget's window is the active window
+
+ The active window is the window that contains the widget that has
+ keyboard focus (The window may still have focus if it has no
+ widgets or none of its widgets accepts keyboard focus).
+
+ When popup windows are visible, this property is true for both the
+ active window \e and for the popup.
+
+ By default, this property is false.
+
+ \sa activateWindow(), QApplication::activeWindow()
+*/
+bool QWidget::isActiveWindow() const
+{
+ QWidget *tlw = window();
+ if(tlw == QApplication::activeWindow() || (isVisible() && (tlw->windowType() == Qt::Popup)))
+ return true;
+
+#ifndef QT_NO_GRAPHICSVIEW
+ if (QWExtra *tlwExtra = tlw->d_func()->extra) {
+ if (isVisible() && tlwExtra->proxyWidget)
+ return tlwExtra->proxyWidget->isActiveWindow();
+ }
+#endif
+
+#ifdef Q_WS_MAC
+ extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp
+ if(qt_mac_is_macdrawer(tlw) &&
+ tlw->parentWidget() && tlw->parentWidget()->isActiveWindow())
+ return true;
+
+ extern bool qt_mac_insideKeyWindow(const QWidget *); //qwidget_mac.cpp
+ if (QApplication::testAttribute(Qt::AA_MacPluginApplication) && qt_mac_insideKeyWindow(tlw))
+ return true;
+#endif
+ if(style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, this)) {
+ if(tlw->windowType() == Qt::Tool &&
+ !tlw->isModal() &&
+ (!tlw->parentWidget() || tlw->parentWidget()->isActiveWindow()))
+ return true;
+ QWidget *w = QApplication::activeWindow();
+ while(w && tlw->windowType() == Qt::Tool &&
+ !w->isModal() && w->parentWidget()) {
+ w = w->parentWidget()->window();
+ if(w == tlw)
+ return true;
+ }
+ }
+#if defined(Q_WS_WIN32)
+ HWND active = GetActiveWindow();
+ if (!tlw->testAttribute(Qt::WA_WState_Created))
+ return false;
+ return active == tlw->internalWinId() || ::IsChild(active, tlw->internalWinId());
+#else
+ return false;
+#endif
+}
+
+/*!
+ Puts the \a second widget after the \a first widget in the focus order.
+
+ Note that since the tab order of the \a second widget is changed, you
+ should order a chain like this:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 9
+
+ \e not like this:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 10
+
+ If \a first or \a second has a focus proxy, setTabOrder()
+ correctly substitutes the proxy.
+
+ \sa setFocusPolicy(), setFocusProxy(), {Keyboard Focus}
+*/
+void QWidget::setTabOrder(QWidget* first, QWidget *second)
+{
+ if (!first || !second || first->focusPolicy() == Qt::NoFocus || second->focusPolicy() == Qt::NoFocus)
+ return;
+
+ if (first->window() != second->window()) {
+ qWarning("QWidget::setTabOrder: 'first' and 'second' must be in the same window");
+ return;
+ }
+
+ QWidget *fp = first->focusProxy();
+ if (fp) {
+ // If first is redirected, set first to the last child of first
+ // that can take keyboard focus so that second is inserted after
+ // that last child, and the focus order within first is (more
+ // likely to be) preserved.
+ QList<QWidget *> l = first->findChildren<QWidget *>();
+ for (int i = l.size()-1; i >= 0; --i) {
+ QWidget * next = l.at(i);
+ if (next->window() == fp->window()) {
+ fp = next;
+ if (fp->focusPolicy() != Qt::NoFocus)
+ break;
+ }
+ }
+ first = fp;
+ }
+
+ if (fp == second)
+ return;
+
+ if (QWidget *sp = second->focusProxy())
+ second = sp;
+
+// QWidget *fp = first->d_func()->focus_prev;
+ QWidget *fn = first->d_func()->focus_next;
+
+ if (fn == second || first == second)
+ return;
+
+ QWidget *sp = second->d_func()->focus_prev;
+ QWidget *sn = second->d_func()->focus_next;
+
+ fn->d_func()->focus_prev = second;
+ first->d_func()->focus_next = second;
+
+ second->d_func()->focus_next = fn;
+ second->d_func()->focus_prev = first;
+
+ sp->d_func()->focus_next = sn;
+ sn->d_func()->focus_prev = sp;
+
+
+ Q_ASSERT(first->d_func()->focus_next->d_func()->focus_prev == first);
+ Q_ASSERT(first->d_func()->focus_prev->d_func()->focus_next == first);
+
+ Q_ASSERT(second->d_func()->focus_next->d_func()->focus_prev == second);
+ Q_ASSERT(second->d_func()->focus_prev->d_func()->focus_next == second);
+}
+
+/*!\internal
+
+ Moves the relevant subwidgets of this widget from the \a oldtlw's
+ tab chain to that of the new parent, if there's anything to move and
+ we're really moving
+
+ This function is called from QWidget::reparent() *after* the widget
+ has been reparented.
+
+ \sa reparent()
+*/
+
+void QWidgetPrivate::reparentFocusWidgets(QWidget * oldtlw)
+{
+ Q_Q(QWidget);
+ if (oldtlw == q->window())
+ return; // nothing to do
+
+ if(focus_child)
+ focus_child->clearFocus();
+
+ // separate the focus chain into new (children of myself) and old (the rest)
+ QWidget *firstOld = 0;
+ //QWidget *firstNew = q; //invariant
+ QWidget *o = 0; // last in the old list
+ QWidget *n = q; // last in the new list
+
+ bool prevWasNew = true;
+ QWidget *w = focus_next;
+
+ //Note: for efficiency, we do not maintain the list invariant inside the loop
+ //we append items to the relevant list, and we optimize by not changing pointers
+ //when subsequent items are going into the same list.
+ while (w != q) {
+ bool currentIsNew = q->isAncestorOf(w);
+ if (currentIsNew) {
+ if (!prevWasNew) {
+ //prev was old -- append to new list
+ n->d_func()->focus_next = w;
+ w->d_func()->focus_prev = n;
+ }
+ n = w;
+ } else {
+ if (prevWasNew) {
+ //prev was new -- append to old list, if there is one
+ if (o) {
+ o->d_func()->focus_next = w;
+ w->d_func()->focus_prev = o;
+ } else {
+ // "create" the old list
+ firstOld = w;
+ }
+ }
+ o = w;
+ }
+ w = w->d_func()->focus_next;
+ prevWasNew = currentIsNew;
+ }
+
+ //repair the old list:
+ if (firstOld) {
+ o->d_func()->focus_next = firstOld;
+ firstOld->d_func()->focus_prev = o;
+ }
+
+ if (!q->isWindow()) {
+ QWidget *topLevel = q->window();
+ //insert new chain into toplevel's chain
+
+ QWidget *prev = topLevel->d_func()->focus_prev;
+
+ topLevel->d_func()->focus_prev = n;
+ prev->d_func()->focus_next = q;
+
+ focus_prev = prev;
+ n->d_func()->focus_next = topLevel;
+ } else {
+ //repair the new list
+ n->d_func()->focus_next = q;
+ focus_prev = n;
+ }
+
+}
+
+/*!\internal
+
+ Measures the shortest distance from a point to a rect.
+
+ This function is called from QDesktopwidget::screen(QPoint) to find the
+ closest screen for a point.
+ In directional KeypadNavigation, it is called to find the closest
+ widget to the current focus widget center.
+*/
+int QWidgetPrivate::pointToRect(const QPoint &p, const QRect &r)
+{
+ int dx = 0;
+ int dy = 0;
+ if (p.x() < r.left())
+ dx = r.left() - p.x();
+ else if (p.x() > r.right())
+ dx = p.x() - r.right();
+ if (p.y() < r.top())
+ dy = r.top() - p.y();
+ else if (p.y() > r.bottom())
+ dy = p.y() - r.bottom();
+ return dx + dy;
+}
+
+/*!
+ \property QWidget::frameSize
+ \brief the size of the widget including any window frame
+
+ By default, this property contains a value that depends on the user's
+ platform and screen geometry.
+*/
+QSize QWidget::frameSize() const
+{
+ Q_D(const QWidget);
+ if (isWindow() && !(windowType() == Qt::Popup)) {
+ QRect fs = d->frameStrut();
+ return QSize(data->crect.width() + fs.left() + fs.right(),
+ data->crect.height() + fs.top() + fs.bottom());
+ }
+ return data->crect.size();
+}
+
+/*! \fn void QWidget::move(int x, int y)
+
+ \overload
+
+ This corresponds to move(QPoint(\a x, \a y)).
+*/
+
+void QWidget::move(const QPoint &p)
+{
+ Q_D(QWidget);
+ setAttribute(Qt::WA_Moved);
+ if (isWindow())
+ d->topData()->posFromMove = true;
+ if (testAttribute(Qt::WA_WState_Created)) {
+ d->setGeometry_sys(p.x() + geometry().x() - QWidget::x(),
+ p.y() + geometry().y() - QWidget::y(),
+ width(), height(), true);
+ d->setDirtyOpaqueRegion();
+ } else {
+ data->crect.moveTopLeft(p); // no frame yet
+ setAttribute(Qt::WA_PendingMoveEvent);
+ }
+}
+
+/*! \fn void QWidget::resize(int w, int h)
+ \overload
+
+ This corresponds to resize(QSize(\a w, \a h)).
+*/
+
+void QWidget::resize(const QSize &s)
+{
+ Q_D(QWidget);
+ setAttribute(Qt::WA_Resized);
+ if (testAttribute(Qt::WA_WState_Created)) {
+ d->setGeometry_sys(geometry().x(), geometry().y(), s.width(), s.height(), false);
+ d->setDirtyOpaqueRegion();
+ } else {
+ data->crect.setSize(s.boundedTo(maximumSize()).expandedTo(minimumSize()));
+ setAttribute(Qt::WA_PendingResizeEvent);
+ }
+}
+
+void QWidget::setGeometry(const QRect &r)
+{
+ Q_D(QWidget);
+ setAttribute(Qt::WA_Resized);
+ setAttribute(Qt::WA_Moved);
+ if (isWindow())
+ d->topData()->posFromMove = false;
+ if (testAttribute(Qt::WA_WState_Created)) {
+ d->setGeometry_sys(r.x(), r.y(), r.width(), r.height(), true);
+ d->setDirtyOpaqueRegion();
+ } else {
+ data->crect.setTopLeft(r.topLeft());
+ data->crect.setSize(r.size().boundedTo(maximumSize()).expandedTo(minimumSize()));
+ setAttribute(Qt::WA_PendingMoveEvent);
+ setAttribute(Qt::WA_PendingResizeEvent);
+ }
+}
+
+/*!
+ \since 4.2
+ Saves the current geometry and state for top-level widgets.
+
+ To save the geometry when the window closes, you can
+ implement a close event like this:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 11
+
+ See the \l{Window Geometry} documentation for an overview of geometry
+ issues with windows.
+
+ Use QMainWindow::saveState() to save the geometry and the state of
+ toolbars and dock widgets.
+
+ \sa restoreGeometry(), QMainWindow::saveState(), QMainWindow::restoreState()
+*/
+QByteArray QWidget::saveGeometry() const
+{
+#ifdef QT_MAC_USE_COCOA
+ // We check if the window was maximized during this invocation. If so, we need to record the
+ // starting position as 0,0.
+ Q_D(const QWidget);
+ QRect newFramePosition = frameGeometry();
+ QRect newNormalPosition = normalGeometry();
+ if(d->topData()->wasMaximized && !(windowState() & Qt::WindowMaximized)) {
+ // Change the starting position
+ newFramePosition.moveTo(0, 0);
+ newNormalPosition.moveTo(0, 0);
+ }
+#endif // QT_MAC_USE_COCOA
+ QByteArray array;
+ QDataStream stream(&array, QIODevice::WriteOnly);
+ stream.setVersion(QDataStream::Qt_4_0);
+ const quint32 magicNumber = 0x1D9D0CB;
+ quint16 majorVersion = 1;
+ quint16 minorVersion = 0;
+ stream << magicNumber
+ << majorVersion
+ << minorVersion
+#ifdef QT_MAC_USE_COCOA
+ << newFramePosition
+ << newNormalPosition
+#else
+ << frameGeometry()
+ << normalGeometry()
+#endif // QT_MAC_USE_COCOA
+ << qint32(QApplication::desktop()->screenNumber(this))
+ << quint8(windowState() & Qt::WindowMaximized)
+ << quint8(windowState() & Qt::WindowFullScreen);
+ return array;
+}
+
+/*!
+ \since 4.2
+
+ Restores the geometry and state top-level widgets stored in the
+ byte array \a geometry. Returns true on success; otherwise
+ returns false.
+
+ If the restored geometry is off-screen, it will be modified to be
+ inside the available screen geometry.
+
+ To restore geometry saved using QSettings, you can use code like
+ this:
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 12
+
+ See the \l{Window Geometry} documentation for an overview of geometry
+ issues with windows.
+
+ Use QMainWindow::restoreState() to restore the geometry and the
+ state of toolbars and dock widgets.
+
+ \sa saveGeometry(), QSettings, QMainWindow::saveState(), QMainWindow::restoreState()
+*/
+bool QWidget::restoreGeometry(const QByteArray &geometry)
+{
+ if (geometry.size() < 4)
+ return false;
+ QDataStream stream(geometry);
+ stream.setVersion(QDataStream::Qt_4_0);
+
+ const quint32 magicNumber = 0x1D9D0CB;
+ quint32 storedMagicNumber;
+ stream >> storedMagicNumber;
+ if (storedMagicNumber != magicNumber)
+ return false;
+
+ const quint16 currentMajorVersion = 1;
+ quint16 majorVersion = 0;
+ quint16 minorVersion = 0;
+
+ stream >> majorVersion >> minorVersion;
+
+ if (majorVersion != currentMajorVersion)
+ return false;
+ // (Allow all minor versions.)
+
+ QRect restoredFrameGeometry;
+ QRect restoredNormalGeometry;
+ qint32 restoredScreenNumber;
+ quint8 maximized;
+ quint8 fullScreen;
+
+ stream >> restoredFrameGeometry
+ >> restoredNormalGeometry
+ >> restoredScreenNumber
+ >> maximized
+ >> fullScreen;
+
+ const int frameHeight = 20;
+ if (!restoredFrameGeometry.isValid())
+ restoredFrameGeometry = QRect(QPoint(0,0), sizeHint());
+
+ if (!restoredNormalGeometry.isValid())
+ restoredNormalGeometry = QRect(QPoint(0, frameHeight), sizeHint());
+ if (!restoredNormalGeometry.isValid()) {
+ // use the widget's adjustedSize if the sizeHint() doesn't help
+ restoredNormalGeometry.setSize(restoredNormalGeometry
+ .size()
+ .expandedTo(d_func()->adjustedSize()));
+ }
+
+ const QDesktopWidget * const desktop = QApplication::desktop();
+ if (restoredScreenNumber >= desktop->numScreens())
+ restoredScreenNumber = desktop->primaryScreen();
+
+ const QRect availableGeometry = desktop->availableGeometry(restoredScreenNumber);
+
+ // Modify the restored geometry if we are about to restore to coordinates
+ // that would make the window "lost". This happens if:
+ // - The restored geometry is completely oustside the available geometry
+ // - The title bar is outside the available geometry.
+ // - (Mac only) The window is higher than the available geometry. It must
+ // be possible to bring the size grip on screen by moving the window.
+#ifdef Q_WS_MAC
+ restoredFrameGeometry.setHeight(qMin(restoredFrameGeometry.height(), availableGeometry.height()));
+ restoredNormalGeometry.setHeight(qMin(restoredNormalGeometry.height(), availableGeometry.height() - frameHeight));
+#endif
+
+ if (!restoredFrameGeometry.intersects(availableGeometry)) {
+ restoredFrameGeometry.moveBottom(qMin(restoredFrameGeometry.bottom(), availableGeometry.bottom()));
+ restoredFrameGeometry.moveLeft(qMax(restoredFrameGeometry.left(), availableGeometry.left()));
+ restoredFrameGeometry.moveRight(qMin(restoredFrameGeometry.right(), availableGeometry.right()));
+ }
+ restoredFrameGeometry.moveTop(qMax(restoredFrameGeometry.top(), availableGeometry.top()));
+
+ if (!restoredNormalGeometry.intersects(availableGeometry)) {
+ restoredNormalGeometry.moveBottom(qMin(restoredNormalGeometry.bottom(), availableGeometry.bottom()));
+ restoredNormalGeometry.moveLeft(qMax(restoredNormalGeometry.left(), availableGeometry.left()));
+ restoredNormalGeometry.moveRight(qMin(restoredNormalGeometry.right(), availableGeometry.right()));
+ }
+ restoredNormalGeometry.moveTop(qMax(restoredNormalGeometry.top(), availableGeometry.top() + frameHeight));
+
+ if (maximized || fullScreen) {
+ // set geomerty before setting the window state to make
+ // sure the window is maximized to the right screen.
+ // Skip on windows: the window is restored into a broken
+ // half-maximized state.
+#ifndef Q_WS_WIN
+ setGeometry(restoredNormalGeometry);
+#endif
+ Qt::WindowStates ws = windowState();
+ if (maximized)
+ ws |= Qt::WindowMaximized;
+ if (fullScreen)
+ ws |= Qt::WindowFullScreen;
+ setWindowState(ws);
+ d_func()->topData()->normalGeometry = restoredNormalGeometry;
+ } else {
+ QPoint offset;
+#ifdef Q_WS_X11
+ if (isFullScreen())
+ offset = d_func()->topData()->fullScreenOffset;
+#endif
+ setWindowState(windowState() & ~(Qt::WindowMaximized | Qt::WindowFullScreen));
+ move(restoredFrameGeometry.topLeft() + offset);
+ resize(restoredNormalGeometry.size());
+ }
+ return true;
+}
+
+/*!\fn void QWidget::setGeometry(int x, int y, int w, int h)
+ \overload
+
+ This corresponds to setGeometry(QRect(\a x, \a y, \a w, \a h)).
+*/
+
+/*!
+ Sets the margins around the contents of the widget to have the sizes
+ \a left, \a top, \a right, and \a bottom. The margins are used by
+ the layout system, and may be used by subclasses to specify the area
+ to draw in (e.g. excluding the frame).
+
+ Changing the margins will trigger a resizeEvent().
+
+ \sa contentsRect(), getContentsMargins()
+*/
+void QWidget::setContentsMargins(int left, int top, int right, int bottom)
+{
+ Q_D(QWidget);
+ if (left == d->leftmargin && top == d->topmargin
+ && right == d->rightmargin && bottom == d->bottommargin)
+ return;
+ d->leftmargin = left;
+ d->topmargin = top;
+ d->rightmargin = right;
+ d->bottommargin = bottom;
+
+ if (QLayout *l=d->layout)
+ l->update(); //force activate; will do updateGeometry
+ else
+ updateGeometry();
+
+ // ### Qt 5: compat, remove
+ if (isVisible()) {
+ update();
+ QResizeEvent e(data->crect.size(), data->crect.size());
+ QApplication::sendEvent(this, &e);
+ } else {
+ setAttribute(Qt::WA_PendingResizeEvent, true);
+ }
+
+ QEvent e(QEvent::ContentsRectChange);
+ QApplication::sendEvent(this, &e);
+}
+
+/*!
+ \overload
+ \since 4.6
+
+ \brief The setContentsMargins function sets the margins around the
+ widget's contents.
+
+ Sets the margins around the contents of the widget to have the
+ sizes determined by \a margins. The margins are
+ used by the layout system, and may be used by subclasses to
+ specify the area to draw in (e.g. excluding the frame).
+
+ Changing the margins will trigger a resizeEvent().
+
+ \sa contentsRect(), getContentsMargins()
+*/
+void QWidget::setContentsMargins(const QMargins &margins)
+{
+ setContentsMargins(margins.left(), margins.top(),
+ margins.right(), margins.bottom());
+}
+
+/*!
+ Returns the widget's contents margins for \a left, \a top, \a
+ right, and \a bottom.
+
+ \sa setContentsMargins(), contentsRect()
+ */
+void QWidget::getContentsMargins(int *left, int *top, int *right, int *bottom) const
+{
+ Q_D(const QWidget);
+ if (left)
+ *left = d->leftmargin;
+ if (top)
+ *top = d->topmargin;
+ if (right)
+ *right = d->rightmargin;
+ if (bottom)
+ *bottom = d->bottommargin;
+}
+
+/*!
+ \since 4.6
+
+ \brief The contentsMargins function returns the widget's contents margins.
+
+ \sa getContentsMargins(), setContentsMargins(), contentsRect()
+ */
+QMargins QWidget::contentsMargins() const
+{
+ Q_D(const QWidget);
+ return QMargins(d->leftmargin, d->topmargin, d->rightmargin, d->bottommargin);
+}
+
+
+/*!
+ Returns the area inside the widget's margins.
+
+ \sa setContentsMargins(), getContentsMargins()
+*/
+QRect QWidget::contentsRect() const
+{
+ Q_D(const QWidget);
+ return QRect(QPoint(d->leftmargin, d->topmargin),
+ QPoint(data->crect.width() - 1 - d->rightmargin,
+ data->crect.height() - 1 - d->bottommargin));
+
+}
+
+
+
+/*!
+ \fn void QWidget::customContextMenuRequested(const QPoint &pos)
+
+ This signal is emitted when the widget's \l contextMenuPolicy is
+ Qt::CustomContextMenu, and the user has requested a context menu on
+ the widget. The position \a pos is the position of the context menu
+ event that the widget receives. Normally this is in widget
+ coordinates. The exception to this rule is QAbstractScrollArea and
+ its subclasses that map the context menu event to coordinates of the
+ \link QAbstractScrollArea::viewport() viewport() \endlink .
+
+
+ \sa mapToGlobal() QMenu contextMenuPolicy
+*/
+
+
+/*!
+ \property QWidget::contextMenuPolicy
+ \brief how the widget shows a context menu
+
+ The default value of this property is Qt::DefaultContextMenu,
+ which means the contextMenuEvent() handler is called. Other values
+ are Qt::NoContextMenu, Qt::PreventContextMenu,
+ Qt::ActionsContextMenu, and Qt::CustomContextMenu. With
+ Qt::CustomContextMenu, the signal customContextMenuRequested() is
+ emitted.
+
+ \sa contextMenuEvent(), customContextMenuRequested(), actions()
+*/
+
+Qt::ContextMenuPolicy QWidget::contextMenuPolicy() const
+{
+ return (Qt::ContextMenuPolicy)data->context_menu_policy;
+}
+
+void QWidget::setContextMenuPolicy(Qt::ContextMenuPolicy policy)
+{
+ data->context_menu_policy = (uint) policy;
+}
+
+/*!
+ \property QWidget::focusPolicy
+ \brief the way the widget accepts keyboard focus
+
+ The policy is Qt::TabFocus if the widget accepts keyboard
+ focus by tabbing, Qt::ClickFocus if the widget accepts
+ focus by clicking, Qt::StrongFocus if it accepts both, and
+ Qt::NoFocus (the default) if it does not accept focus at
+ all.
+
+ You must enable keyboard focus for a widget if it processes
+ keyboard events. This is normally done from the widget's
+ constructor. For instance, the QLineEdit constructor calls
+ setFocusPolicy(Qt::StrongFocus).
+
+ If the widget has a focus proxy, then the focus policy will
+ be propagated to it.
+
+ \sa focusInEvent(), focusOutEvent(), keyPressEvent(), keyReleaseEvent(), enabled
+*/
+
+
+Qt::FocusPolicy QWidget::focusPolicy() const
+{
+ return (Qt::FocusPolicy)data->focus_policy;
+}
+
+void QWidget::setFocusPolicy(Qt::FocusPolicy policy)
+{
+ data->focus_policy = (uint) policy;
+ Q_D(QWidget);
+ if (d->extra && d->extra->focus_proxy)
+ d->extra->focus_proxy->setFocusPolicy(policy);
+}
+
+/*!
+ \property QWidget::updatesEnabled
+ \brief whether updates are enabled
+
+ An updates enabled widget receives paint events and has a system
+ background; a disabled widget does not. This also implies that
+ calling update() and repaint() has no effect if updates are
+ disabled.
+
+ By default, this property is true.
+
+ setUpdatesEnabled() is normally used to disable updates for a
+ short period of time, for instance to avoid screen flicker during
+ large changes. In Qt, widgets normally do not generate screen
+ flicker, but on X11 the server might erase regions on the screen
+ when widgets get hidden before they can be replaced by other
+ widgets. Disabling updates solves this.
+
+ Example:
+ \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 13
+
+ Disabling a widget implicitly disables all its children. Enabling a widget
+ enables all child widgets \e except top-level widgets or those that
+ have been explicitly disabled. Re-enabling updates implicitly calls
+ update() on the widget.
+
+ \sa paintEvent()
+*/
+void QWidget::setUpdatesEnabled(bool enable)
+{
+ Q_D(QWidget);
+ setAttribute(Qt::WA_ForceUpdatesDisabled, !enable);
+ d->setUpdatesEnabled_helper(enable);
+}
+
+/*! \fn void QWidget::show()
+
+ Shows the widget and its child widgets. This function is
+ equivalent to setVisible(true).
+
+ \sa raise(), showEvent(), hide(), setVisible(), showMinimized(), showMaximized(),
+ showNormal(), isVisible()
+*/
+
+
+/*! \internal
+
+ Makes the widget visible in the isVisible() meaning of the word.
+ It is only called for toplevels or widgets with visible parents.
+ */
+void QWidgetPrivate::show_recursive()
+{
+ Q_Q(QWidget);
+ // polish if necessary
+
+ if (!q->testAttribute(Qt::WA_WState_Created))
+ createRecursively();
+ q->ensurePolished();
+
+#ifdef QT3_SUPPORT
+ if(sendChildEvents)
+ QApplication::sendPostedEvents(q, QEvent::ChildInserted);
+#endif
+ if (!q->isWindow() && q->parentWidget()->d_func()->layout && !q->parentWidget()->data->in_show)
+ q->parentWidget()->d_func()->layout->activate();
+ // activate our layout before we and our children become visible
+ if (layout)
+ layout->activate();
+
+ show_helper();
+}
+
+void QWidgetPrivate::sendPendingMoveAndResizeEvents(bool recursive, bool disableUpdates)
+{
+ Q_Q(QWidget);
+
+ disableUpdates = disableUpdates && q->updatesEnabled();
+ if (disableUpdates)
+ q->setAttribute(Qt::WA_UpdatesDisabled);
+
+ if (q->testAttribute(Qt::WA_PendingMoveEvent)) {
+ QMoveEvent e(data.crect.topLeft(), data.crect.topLeft());
+ QApplication::sendEvent(q, &e);
+ q->setAttribute(Qt::WA_PendingMoveEvent, false);
+ }
+
+ if (q->testAttribute(Qt::WA_PendingResizeEvent)) {
+ QResizeEvent e(data.crect.size(), QSize());
+ QApplication::sendEvent(q, &e);
+ q->setAttribute(Qt::WA_PendingResizeEvent, false);
+ }
+
+ if (disableUpdates)
+ q->setAttribute(Qt::WA_UpdatesDisabled, false);
+
+ if (!recursive)
+ return;
+
+ for (int i = 0; i < children.size(); ++i) {
+ if (QWidget *child = qobject_cast<QWidget *>(children.at(i)))
+ child->d_func()->sendPendingMoveAndResizeEvents(recursive, disableUpdates);
+ }
+}
+
+void QWidgetPrivate::activateChildLayoutsRecursively()
+{
+ sendPendingMoveAndResizeEvents(false, true);
+
+ for (int i = 0; i < children.size(); ++i) {
+ QWidget *child = qobject_cast<QWidget *>(children.at(i));
+ if (!child || child->isHidden() || child->isWindow())
+ continue;
+
+ child->ensurePolished();
+
+ // Activate child's layout
+ QWidgetPrivate *childPrivate = child->d_func();
+ if (childPrivate->layout)
+ childPrivate->layout->activate();
+
+ // Pretend we're visible.
+ const bool wasVisible = child->isVisible();
+ if (!wasVisible)
+ child->setAttribute(Qt::WA_WState_Visible);
+
+ // Do the same for all my children.
+ childPrivate->activateChildLayoutsRecursively();
+
+ // We're not cheating anymore.
+ if (!wasVisible)
+ child->setAttribute(Qt::WA_WState_Visible, false);
+ }
+}
+
+void QWidgetPrivate::show_helper()
+{
+ Q_Q(QWidget);
+ data.in_show = true; // qws optimization
+ // make sure we receive pending move and resize events
+ sendPendingMoveAndResizeEvents();
+
+ // become visible before showing all children
+ q->setAttribute(Qt::WA_WState_Visible);
+
+ // finally show all children recursively
+ showChildren(false);
+
+#ifdef QT3_SUPPORT
+ if (q->parentWidget() && sendChildEvents)
+ QApplication::sendPostedEvents(q->parentWidget(),
+ QEvent::ChildInserted);
+#endif
+
+
+ // popup handling: new popups and tools need to be raised, and
+ // existing popups must be closed. Also propagate the current
+ // windows's KeyboardFocusChange status.
+ if (q->isWindow()) {
+ if ((q->windowType() == Qt::Tool) || (q->windowType() == Qt::Popup) || q->windowType() == Qt::ToolTip) {
+ q->raise();
+ if (q->parentWidget() && q->parentWidget()->window()->testAttribute(Qt::WA_KeyboardFocusChange))
+ q->setAttribute(Qt::WA_KeyboardFocusChange);
+ } else {
+ while (QApplication::activePopupWidget()) {
+ if (!QApplication::activePopupWidget()->close())
+ break;
+ }
+ }
+ }
+
+ // Automatic embedding of child windows of widgets already embedded into
+ // QGraphicsProxyWidget when they are shown the first time.
+ bool isEmbedded = false;
+#ifndef QT_NO_GRAPHICSVIEW
+ if (q->isWindow()) {
+ isEmbedded = q->graphicsProxyWidget() ? true : false;
+ if (!isEmbedded && !bypassGraphicsProxyWidget(q)) {
+ QGraphicsProxyWidget *ancestorProxy = nearestGraphicsProxyWidget(q->parentWidget());
+ if (ancestorProxy) {
+ isEmbedded = true;
+ ancestorProxy->d_func()->embedSubWindow(q);
+ }
+ }
+ }
+#else
+ Q_UNUSED(isEmbedded);
+#endif
+
+ // On Windows, show the popup now so that our own focus handling
+ // stores the correct old focus widget even if it's stolen in the
+ // showevent
+#if defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN)
+ if (!isEmbedded && q->windowType() == Qt::Popup)
+ qApp->d_func()->openPopup(q);
+#endif
+
+ // send the show event before showing the window
+ QShowEvent showEvent;
+ QApplication::sendEvent(q, &showEvent);
+
+ if (!isEmbedded && q->isModal() && q->isWindow())
+ // QApplicationPrivate::enterModal *before* show, otherwise the initial
+ // stacking might be wrong
+ QApplicationPrivate::enterModal(q);
+
+
+ show_sys();
+
+#if !defined(Q_WS_WIN) && !defined(Q_WS_MAC) && !defined(Q_OS_SYMBIAN)
+ if (!isEmbedded && q->windowType() == Qt::Popup)
+ qApp->d_func()->openPopup(q);
+#endif
+
+#ifndef QT_NO_ACCESSIBILITY
+ if (q->windowType() != Qt::ToolTip) // Tooltips are read aloud twice in MS narrator.
+ QAccessible::updateAccessibility(q, 0, QAccessible::ObjectShow);
+#endif
+
+ if (QApplicationPrivate::hidden_focus_widget == q) {
+ QApplicationPrivate::hidden_focus_widget = 0;
+ q->setFocus(Qt::OtherFocusReason);
+ }
+
+ // Process events when showing a Qt::SplashScreen widget before the event loop
+ // is spinnning; otherwise it might not show up on particular platforms.
+ // This makes QSplashScreen behave the same on all platforms.
+ if (!qApp->d_func()->in_exec && q->windowType() == Qt::SplashScreen)
+ QApplication::processEvents();
+
+ data.in_show = false; // reset qws optimization
+}
+
+/*! \fn void QWidget::hide()
+
+ Hides the widget. This function is equivalent to
+ setVisible(false).
+
+
+ \note If you are working with QDialog or its subclasses and you invoke
+ the show() function after this function, the dialog will be displayed in
+ its original position.
+
+ \sa hideEvent(), isHidden(), show(), setVisible(), isVisible(), close()
+*/
+
+/*!\internal
+ */
+void QWidgetPrivate::hide_helper()
+{
+ Q_Q(QWidget);
+
+ bool isEmbedded = false;
+#if !defined QT_NO_GRAPHICSVIEW
+ isEmbedded = q->isWindow() && !bypassGraphicsProxyWidget(q) && nearestGraphicsProxyWidget(q->parentWidget()) != 0;
+#else
+ Q_UNUSED(isEmbedded);
+#endif
+
+ if (!isEmbedded && (q->windowType() == Qt::Popup))
+ qApp->d_func()->closePopup(q);
+
+ // Move test modal here. Otherwise, a modal dialog could get
+ // destroyed and we lose all access to its parent because we haven't
+ // left modality. (Eg. modal Progress Dialog)
+ if (!isEmbedded && q->isModal() && q->isWindow())
+ QApplicationPrivate::leaveModal(q);
+
+#if defined(Q_WS_WIN)
+ if (q->isWindow() && !(q->windowType() == Qt::Popup) && q->parentWidget()
+ && !q->parentWidget()->isHidden() && q->isActiveWindow())
+ q->parentWidget()->activateWindow(); // Activate parent
+#endif
+
+ q->setAttribute(Qt::WA_Mapped, false);
+ hide_sys();
+
+ bool wasVisible = q->testAttribute(Qt::WA_WState_Visible);
+
+ if (wasVisible) {
+ q->setAttribute(Qt::WA_WState_Visible, false);
+
+ }
+
+ QHideEvent hideEvent;
+ QApplication::sendEvent(q, &hideEvent);
+ hideChildren(false);
+
+ // next bit tries to move the focus if the focus widget is now
+ // hidden.
+ if (wasVisible) {
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_QPA)
+ qApp->d_func()->sendSyntheticEnterLeave(q);
+#endif
+
+ QWidget *fw = QApplication::focusWidget();
+ while (fw && !fw->isWindow()) {
+ if (fw == q) {
+ q->focusNextPrevChild(true);
+ break;
+ }
+ fw = fw->parentWidget();
+ }
+ }
+
+ if (QWidgetBackingStore *bs = maybeBackingStore())
+ bs->removeDirtyWidget(q);
+
+#ifndef QT_NO_ACCESSIBILITY
+ if (wasVisible)
+ QAccessible::updateAccessibility(q, 0, QAccessible::ObjectHide);
+#endif
+}
+
+/*!
+ \fn bool QWidget::isHidden() const
+
+ Returns true if the widget is hidden, otherwise returns false.
+
+ A hidden widget will only become visible when show() is called on
+ it. It will not be automatically shown when the parent is shown.
+
+ To check visibility, use !isVisible() instead (notice the exclamation mark).
+
+ isHidden() implies !isVisible(), but a widget can be not visible
+ and not hidden at the same time. This is the case for widgets that are children of
+ widgets that are not visible.
+
+
+ Widgets are hidden if:
+ \list
+ \o they were created as independent windows,
+ \o they were created as children of visible widgets,
+ \o hide() or setVisible(false) was called.
+ \endlist
+*/
+
+
+void QWidget::setVisible(bool visible)
+{
+ if (visible) { // show
+ if (testAttribute(Qt::WA_WState_ExplicitShowHide) && !testAttribute(Qt::WA_WState_Hidden))
+ return;
+
+ Q_D(QWidget);
+
+ // Designer uses a trick to make grabWidget work without showing
+ if (!isWindow() && parentWidget() && parentWidget()->isVisible()
+ && !parentWidget()->testAttribute(Qt::WA_WState_Created))
+ parentWidget()->window()->d_func()->createRecursively();
+
+ //we have to at least create toplevels before applyX11SpecificCommandLineArguments
+ //but not children of non-visible parents
+ QWidget *pw = parentWidget();
+ if (!testAttribute(Qt::WA_WState_Created)
+ && (isWindow() || pw->testAttribute(Qt::WA_WState_Created))) {
+ create();
+ }
+
+#if defined(Q_WS_X11)
+ if (windowType() == Qt::Window)
+ QApplicationPrivate::applyX11SpecificCommandLineArguments(this);
+#elif defined(Q_WS_QWS)
+ if (windowType() == Qt::Window)
+ QApplicationPrivate::applyQWSSpecificCommandLineArguments(this);
+#endif
+
+ bool wasResized = testAttribute(Qt::WA_Resized);
+ Qt::WindowStates initialWindowState = windowState();
+
+ // polish if necessary
+ ensurePolished();
+
+ // remember that show was called explicitly
+ setAttribute(Qt::WA_WState_ExplicitShowHide);
+ // whether we need to inform the parent widget immediately
+ bool needUpdateGeometry = !isWindow() && testAttribute(Qt::WA_WState_Hidden);
+ // we are no longer hidden
+ setAttribute(Qt::WA_WState_Hidden, false);
+
+ if (needUpdateGeometry)
+ d->updateGeometry_helper(true);
+
+#ifdef QT3_SUPPORT
+ QApplication::sendPostedEvents(this, QEvent::ChildInserted);
+#endif
+ // activate our layout before we and our children become visible
+ if (d->layout)
+ d->layout->activate();
+
+ if (!isWindow()) {
+ QWidget *parent = parentWidget();
+ while (parent && parent->isVisible() && parent->d_func()->layout && !parent->data->in_show) {
+ parent->d_func()->layout->activate();
+ if (parent->isWindow())
+ break;
+ parent = parent->parentWidget();
+ }
+ if (parent)
+ parent->d_func()->setDirtyOpaqueRegion();
+ }
+
+ // adjust size if necessary
+ if (!wasResized
+ && (isWindow() || !parentWidget()->d_func()->layout)) {
+ if (isWindow()) {
+ adjustSize();
+ if (windowState() != initialWindowState)
+ setWindowState(initialWindowState);
+ } else {
+ adjustSize();
+ }
+ setAttribute(Qt::WA_Resized, false);
+ }
+
+ setAttribute(Qt::WA_KeyboardFocusChange, false);
+
+ if (isWindow() || parentWidget()->isVisible()) {
+ // remove posted quit events when showing a new window
+ QCoreApplication::removePostedEvents(qApp, QEvent::Quit);
+
+ d->show_helper();
+
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_QPA)
+ qApp->d_func()->sendSyntheticEnterLeave(this);
+#endif
+ }
+
+ QEvent showToParentEvent(QEvent::ShowToParent);
+ QApplication::sendEvent(this, &showToParentEvent);
+ } else { // hide
+ if (testAttribute(Qt::WA_WState_ExplicitShowHide) && testAttribute(Qt::WA_WState_Hidden))
+ return;
+#if defined(Q_WS_WIN)
+ // reset WS_DISABLED style in a Blocked window
+ if(isWindow() && testAttribute(Qt::WA_WState_Created)
+ && QApplicationPrivate::isBlockedByModal(this))
+ {
+ LONG dwStyle = GetWindowLong(winId(), GWL_STYLE);
+ dwStyle &= ~WS_DISABLED;
+ SetWindowLong(winId(), GWL_STYLE, dwStyle);
+ }
+#endif
+ if (QApplicationPrivate::hidden_focus_widget == this)
+ QApplicationPrivate::hidden_focus_widget = 0;
+
+ Q_D(QWidget);
+
+ // hw: The test on getOpaqueRegion() needs to be more intelligent
+ // currently it doesn't work if the widget is hidden (the region will
+ // be clipped). The real check should be testing the cached region
+ // (and dirty flag) directly.
+ if (!isWindow() && parentWidget()) // && !d->getOpaqueRegion().isEmpty())
+ parentWidget()->d_func()->setDirtyOpaqueRegion();
+
+ setAttribute(Qt::WA_WState_Hidden);
+ setAttribute(Qt::WA_WState_ExplicitShowHide);
+ if (testAttribute(Qt::WA_WState_Created))
+ d->hide_helper();
+
+ // invalidate layout similar to updateGeometry()
+ if (!isWindow() && parentWidget()) {
+ if (parentWidget()->d_func()->layout)
+ parentWidget()->d_func()->layout->invalidate();
+ else if (parentWidget()->isVisible())
+ QApplication::postEvent(parentWidget(), new QEvent(QEvent::LayoutRequest));
+ }
+
+ QEvent hideToParentEvent(QEvent::HideToParent);
+ QApplication::sendEvent(this, &hideToParentEvent);
+ }
+}
+
+/*!\fn void QWidget::setHidden(bool hidden)
+
+ Convenience function, equivalent to setVisible(!\a hidden).
+*/
+
+/*!\fn void QWidget::setShown(bool shown)
+
+ Use setVisible(\a shown) instead.
+*/
+
+
+void QWidgetPrivate::_q_showIfNotHidden()
+{
+ Q_Q(QWidget);
+ if ( !(q->isHidden() && q->testAttribute(Qt::WA_WState_ExplicitShowHide)) )
+ q->setVisible(true);
+}
+
+void QWidgetPrivate::showChildren(bool spontaneous)
+{
+ QList<QObject*> childList = children;
+ for (int i = 0; i < childList.size(); ++i) {
+ QWidget *widget = qobject_cast<QWidget*>(childList.at(i));
+ if (!widget
+ || widget->isWindow()
+ || widget->testAttribute(Qt::WA_WState_Hidden))
+ continue;
+ if (spontaneous) {
+ widget->setAttribute(Qt::WA_Mapped);
+ widget->d_func()->showChildren(true);
+ QShowEvent e;
+ QApplication::sendSpontaneousEvent(widget, &e);
+ } else {
+ if (widget->testAttribute(Qt::WA_WState_ExplicitShowHide))
+ widget->d_func()->show_recursive();
+ else
+ widget->show();
+ }
+ }
+}
+
+void QWidgetPrivate::hideChildren(bool spontaneous)
+{
+ QList<QObject*> childList = children;
+ for (int i = 0; i < childList.size(); ++i) {
+ QWidget *widget = qobject_cast<QWidget*>(childList.at(i));
+ if (!widget || widget->isWindow() || widget->testAttribute(Qt::WA_WState_Hidden))
+ continue;
+#ifdef QT_MAC_USE_COCOA
+ // Before doing anything we need to make sure that we don't leave anything in a non-consistent state.
+ // When hiding a widget we need to make sure that no mouse_down events are active, because
+ // the mouse_up event will never be received by a hidden widget or one of its descendants.
+ // The solution is simple, before going through with this we check if there are any mouse_down events in
+ // progress, if so we check if it is related to this widget or not. If so, we just reset the mouse_down and
+ // then we continue.
+ // In X11 and Windows we send a mouse_release event, however we don't do that here because we were already
+ // ignoring that from before. I.e. Carbon did not send the mouse release event, so we will not send the
+ // mouse release event. There are two ways to interpret this:
+ // 1. If we don't send the mouse release event, the widget might get into an inconsistent state, i.e. it
+ // might be waiting for a release event that will never arrive.
+ // 2. If we send the mouse release event, then the widget might decide to trigger an action that is not
+ // supposed to trigger because it is not visible.
+ if(widget == qt_button_down)
+ qt_button_down = 0;
+#endif // QT_MAC_USE_COCOA
+ if (spontaneous)
+ widget->setAttribute(Qt::WA_Mapped, false);
+ else
+ widget->setAttribute(Qt::WA_WState_Visible, false);
+ widget->d_func()->hideChildren(spontaneous);
+ QHideEvent e;
+ if (spontaneous) {
+ QApplication::sendSpontaneousEvent(widget, &e);
+ } else {
+ QApplication::sendEvent(widget, &e);
+ if (widget->internalWinId()
+ && widget->testAttribute(Qt::WA_DontCreateNativeAncestors)) {
+ // hide_sys() on an ancestor won't have any affect on this
+ // widget, so it needs an explicit hide_sys() of its own
+ widget->d_func()->hide_sys();
+ }
+ }
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined (Q_WS_QWS) || defined(Q_WS_MAC) || defined(Q_WS_QPA)
+ qApp->d_func()->sendSyntheticEnterLeave(widget);
+#endif
+#ifndef QT_NO_ACCESSIBILITY
+ if (!spontaneous)
+ QAccessible::updateAccessibility(widget, 0, QAccessible::ObjectHide);
+#endif
+ }
+}
+
+bool QWidgetPrivate::close_helper(CloseMode mode)
+{
+ if (data.is_closing)
+ return true;
+
+ Q_Q(QWidget);
+ data.is_closing = 1;
+
+ QPointer<QWidget> that = q;
+ QPointer<QWidget> parentWidget = q->parentWidget();
+
+#ifdef QT3_SUPPORT
+ bool isMain = (QApplicationPrivate::main_widget == q);
+#endif
+ bool quitOnClose = q->testAttribute(Qt::WA_QuitOnClose);
+ if (mode != CloseNoEvent) {
+ QCloseEvent e;
+ if (mode == CloseWithSpontaneousEvent)
+ QApplication::sendSpontaneousEvent(q, &e);
+ else
+ QApplication::sendEvent(q, &e);
+ if (!that.isNull() && !e.isAccepted()) {
+ data.is_closing = 0;
+ return false;
+ }
+ }
+
+ if (!that.isNull() && !q->isHidden())
+ q->hide();
+
+#ifdef QT3_SUPPORT
+ if (isMain)
+ QApplication::quit();
+#endif
+ // Attempt to close the application only if this has WA_QuitOnClose set and a non-visible parent
+ quitOnClose = quitOnClose && (parentWidget.isNull() || !parentWidget->isVisible());
+
+ if (quitOnClose) {
+ /* if there is no non-withdrawn primary window left (except
+ the ones without QuitOnClose), we emit the lastWindowClosed
+ signal */
+ QWidgetList list = QApplication::topLevelWidgets();
+ bool lastWindowClosed = true;
+ for (int i = 0; i < list.size(); ++i) {
+ QWidget *w = list.at(i);
+ if (!w->isVisible() || w->parentWidget() || !w->testAttribute(Qt::WA_QuitOnClose))
+ continue;
+ lastWindowClosed = false;
+ break;
+ }
+ if (lastWindowClosed)
+ QApplicationPrivate::emitLastWindowClosed();
+ }
+
+ if (!that.isNull()) {
+ data.is_closing = 0;
+ if (q->testAttribute(Qt::WA_DeleteOnClose)) {
+ q->setAttribute(Qt::WA_DeleteOnClose, false);
+ q->deleteLater();
+ }
+ }
+ return true;
+}
+
+
+/*!
+ Closes this widget. Returns true if the widget was closed;
+ otherwise returns false.
+
+ First it sends the widget a QCloseEvent. The widget is \link
+ hide() hidden\endlink if it \link QCloseEvent::accept()
+ accepts\endlink the close event. If it \link QCloseEvent::ignore()
+ ignores\endlink the event, nothing happens. The default
+ implementation of QWidget::closeEvent() accepts the close event.
+
+ If the widget has the Qt::WA_DeleteOnClose flag, the widget
+ is also deleted. A close events is delivered to the widget no
+ matter if the widget is visible or not.
+
+ The \l QApplication::lastWindowClosed() signal is emitted when the
+ last visible primary window (i.e. window with no parent) with the
+ Qt::WA_QuitOnClose attribute set is closed. By default this
+ attribute is set for all widgets except transient windows such as
+ splash screens, tool windows, and popup menus.
+
+*/
+
+bool QWidget::close()
+{
+ return d_func()->close_helper(QWidgetPrivate::CloseWithEvent);
+}
+
+/*!
+ \property QWidget::visible
+ \brief whether the widget is visible
+
+ Calling setVisible(true) or show() sets the widget to visible
+ status if all its parent widgets up to the window are visible. If
+ an ancestor is not visible, the widget won't become visible until
+ all its ancestors are shown. If its size or position has changed,
+ Qt guarantees that a widget gets move and resize events just
+ before it is shown. If the widget has not been resized yet, Qt
+ will adjust the widget's size to a useful default using
+ adjustSize().
+
+ Calling setVisible(false) or hide() hides a widget explicitly. An
+ explicitly hidden widget will never become visible, even if all
+ its ancestors become visible, unless you show it.
+
+ A widget receives show and hide events when its visibility status
+ changes. Between a hide and a show event, there is no need to
+ waste CPU cycles preparing or displaying information to the user.
+ A video application, for example, might simply stop generating new
+ frames.
+
+ A widget that happens to be obscured by other windows on the
+ screen is considered to be visible. The same applies to iconified
+ windows and windows that exist on another virtual
+ desktop (on platforms that support this concept). A widget
+ receives spontaneous show and hide events when its mapping status
+ is changed by the window system, e.g. a spontaneous hide event
+ when the user minimizes the window, and a spontaneous show event
+ when the window is restored again.
+
+ You almost never have to reimplement the setVisible() function. If
+ you need to change some settings before a widget is shown, use
+ showEvent() instead. If you need to do some delayed initialization
+ use the Polish event delivered to the event() function.
+
+ \sa show(), hide(), isHidden(), isVisibleTo(), isMinimized(),
+ showEvent(), hideEvent()
+*/
+
+
+/*!
+ Returns true if this widget would become visible if \a ancestor is
+ shown; otherwise returns false.
+
+ The true case occurs if neither the widget itself nor any parent
+ up to but excluding \a ancestor has been explicitly hidden.
+
+ This function will still return true if the widget is obscured by
+ other windows on the screen, but could be physically visible if it
+ or they were to be moved.
+
+ isVisibleTo(0) is identical to isVisible().
+
+ \sa show() hide() isVisible()
+*/
+
+bool QWidget::isVisibleTo(QWidget* ancestor) const
+{
+ if (!ancestor)
+ return isVisible();
+ const QWidget * w = this;
+ while (!w->isHidden()
+ && !w->isWindow()
+ && w->parentWidget()
+ && w->parentWidget() != ancestor)
+ w = w->parentWidget();
+ return !w->isHidden();
+}
+
+#ifdef QT3_SUPPORT
+/*!
+ Use visibleRegion() instead.
+*/
+QRect QWidget::visibleRect() const
+{
+ return d_func()->clipRect();
+}
+#endif
+
+/*!
+ Returns the unobscured region where paint events can occur.
+
+ For visible widgets, this is an approximation of the area not
+ covered by other widgets; otherwise, this is an empty region.
+
+ The repaint() function calls this function if necessary, so in
+ general you do not need to call it.
+
+*/
+QRegion QWidget::visibleRegion() const
+{
+ Q_D(const QWidget);
+
+ QRect clipRect = d->clipRect();
+ if (clipRect.isEmpty())
+ return QRegion();
+ QRegion r(clipRect);
+ d->subtractOpaqueChildren(r, clipRect);
+ d->subtractOpaqueSiblings(r);
+#ifdef Q_WS_QWS
+ const QWSWindowSurface *surface = static_cast<const QWSWindowSurface*>(windowSurface());
+ if (surface) {
+ const QPoint offset = mapTo(surface->window(), QPoint());
+ r &= surface->clipRegion().translated(-offset);
+ }
+#endif
+ return r;
+}
+
+
+QSize QWidgetPrivate::adjustedSize() const
+{
+ Q_Q(const QWidget);
+
+ QSize s = q->sizeHint();
+
+ if (q->isWindow()) {
+ Qt::Orientations exp;
+ if (layout) {
+ if (layout->hasHeightForWidth())
+ s.setHeight(layout->totalHeightForWidth(s.width()));
+ exp = layout->expandingDirections();
+ } else
+ {
+ if (q->sizePolicy().hasHeightForWidth())
+ s.setHeight(q->heightForWidth(s.width()));
+ exp = q->sizePolicy().expandingDirections();
+ }
+ if (exp & Qt::Horizontal)
+ s.setWidth(qMax(s.width(), 200));
+ if (exp & Qt::Vertical)
+ s.setHeight(qMax(s.height(), 100));
+#if defined(Q_WS_X11)
+ QRect screen = QApplication::desktop()->screenGeometry(q->x11Info().screen());
+#else // all others
+ QRect screen = QApplication::desktop()->screenGeometry(q->pos());
+#endif
+#if defined (Q_WS_WINCE) || defined (Q_OS_SYMBIAN)
+ s.setWidth(qMin(s.width(), screen.width()));
+ s.setHeight(qMin(s.height(), screen.height()));
+#else
+ s.setWidth(qMin(s.width(), screen.width()*2/3));
+ s.setHeight(qMin(s.height(), screen.height()*2/3));
+#endif
+ if (QTLWExtra *extra = maybeTopData())
+ extra->sizeAdjusted = true;
+ }
+
+ if (!s.isValid()) {
+ QRect r = q->childrenRect(); // get children rectangle
+ if (r.isNull())
+ return s;
+ s = r.size() + QSize(2 * r.x(), 2 * r.y());
+ }
+
+ return s;
+}
+
+/*!
+ Adjusts the size of the widget to fit its contents.
+
+ This function uses sizeHint() if it is valid, i.e., the size hint's width
+ and height are \>= 0. Otherwise, it sets the size to the children
+ rectangle that covers all child widgets (the union of all child widget
+ rectangles).
+
+ For windows, the screen size is also taken into account. If the sizeHint()
+ is less than (200, 100) and the size policy is \l{QSizePolicy::Expanding}
+ {expanding}, the window will be at least (200, 100). The maximum size of
+ a window is 2/3 of the screen's width and height.
+
+ \sa sizeHint(), childrenRect()
+*/
+
+void QWidget::adjustSize()
+{
+ Q_D(QWidget);
+ ensurePolished();
+ QSize s = d->adjustedSize();
+
+ if (d->layout)
+ d->layout->activate();
+
+ if (s.isValid())
+ resize(s);
+}
+
+
+/*!
+ \property QWidget::sizeHint
+ \brief the recommended size for the widget
+
+ If the value of this property is an invalid size, no size is
+ recommended.
+
+ The default implementation of sizeHint() returns an invalid size
+ if there is no layout for this widget, and returns the layout's
+ preferred size otherwise.
+
+ \sa QSize::isValid(), minimumSizeHint(), sizePolicy(),
+ setMinimumSize(), updateGeometry()
+*/
+
+QSize QWidget::sizeHint() const
+{
+ Q_D(const QWidget);
+ if (d->layout)
+ return d->layout->totalSizeHint();
+ return QSize(-1, -1);
+}
+
+/*!
+ \property QWidget::minimumSizeHint
+ \brief the recommended minimum size for the widget
+
+ If the value of this property is an invalid size, no minimum size
+ is recommended.
+
+ The default implementation of minimumSizeHint() returns an invalid
+ size if there is no layout for this widget, and returns the
+ layout's minimum size otherwise. Most built-in widgets reimplement
+ minimumSizeHint().
+
+ \l QLayout will never resize a widget to a size smaller than the
+ minimum size hint unless minimumSize() is set or the size policy is
+ set to QSizePolicy::Ignore. If minimumSize() is set, the minimum
+ size hint will be ignored.
+
+ \sa QSize::isValid(), resize(), setMinimumSize(), sizePolicy()
+*/
+QSize QWidget::minimumSizeHint() const
+{
+ Q_D(const QWidget);
+ if (d->layout)
+ return d->layout->totalMinimumSize();
+ return QSize(-1, -1);
+}
+
+
+/*!
+ \fn QWidget *QWidget::parentWidget() const
+
+ Returns the parent of this widget, or 0 if it does not have any
+ parent widget.
+*/
+
+
+/*!
+ Returns true if this widget is a parent, (or grandparent and so on
+ to any level), of the given \a child, and both widgets are within
+ the same window; otherwise returns false.
+*/
+
+bool QWidget::isAncestorOf(const QWidget *child) const
+{
+ while (child) {
+ if (child == this)
+ return true;
+ if (child->isWindow())
+ return false;
+ child = child->parentWidget();
+ }
+ return false;
+}
+
+#if defined(Q_WS_WIN)
+inline void setDisabledStyle(QWidget *w, bool setStyle)
+{
+ // set/reset WS_DISABLED style.
+ if(w && w->isWindow() && w->isVisible() && w->isEnabled()) {
+ LONG dwStyle = GetWindowLong(w->winId(), GWL_STYLE);
+ LONG newStyle = dwStyle;
+ if (setStyle)
+ newStyle |= WS_DISABLED;
+ else
+ newStyle &= ~WS_DISABLED;
+ if (newStyle != dwStyle) {
+ SetWindowLong(w->winId(), GWL_STYLE, newStyle);
+ // we might need to repaint in some situations (eg. menu)
+ w->repaint();
+ }
+ }
+}
+#endif
+
+/*****************************************************************************
+ QWidget event handling
+ *****************************************************************************/
+
+/*!
+ This is the main event handler; it handles event \a event. You can
+ reimplement this function in a subclass, but we recommend using
+ one of the specialized event handlers instead.
+
+ Key press and release events are treated differently from other
+ events. event() checks for Tab and Shift+Tab and tries to move the
+ focus appropriately. If there is no widget to move the focus to
+ (or the key press is not Tab or Shift+Tab), event() calls
+ keyPressEvent().
+
+ Mouse and tablet event handling is also slightly special: only
+ when the widget is \l enabled, event() will call the specialized
+ handlers such as mousePressEvent(); otherwise it will discard the
+ event.
+
+ This function returns true if the event was recognized, otherwise
+ it returns false. If the recognized event was accepted (see \l
+ QEvent::accepted), any further processing such as event
+ propagation to the parent widget stops.
+
+ \sa closeEvent(), focusInEvent(), focusOutEvent(), enterEvent(),
+ keyPressEvent(), keyReleaseEvent(), leaveEvent(),
+ mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(),
+ mouseReleaseEvent(), moveEvent(), paintEvent(), resizeEvent(),
+ QObject::event(), QObject::timerEvent()
+*/
+
+bool QWidget::event(QEvent *event)
+{
+ Q_D(QWidget);
+
+ // ignore mouse events when disabled
+ if (!isEnabled()) {
+ switch(event->type()) {
+ case QEvent::TabletPress:
+ case QEvent::TabletRelease:
+ case QEvent::TabletMove:
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseButtonDblClick:
+ case QEvent::MouseMove:
+ case QEvent::TouchBegin:
+ case QEvent::TouchUpdate:
+ case QEvent::TouchEnd:
+ case QEvent::ContextMenu:
+#ifndef QT_NO_WHEELEVENT
+ case QEvent::Wheel:
+#endif
+ return false;
+ default:
+ break;
+ }
+ }
+ switch (event->type()) {
+ case QEvent::MouseMove:
+ mouseMoveEvent((QMouseEvent*)event);
+ break;
+
+ case QEvent::MouseButtonPress:
+ // Don't reset input context here. Whether reset or not is
+ // a responsibility of input method. reset() will be
+ // called by mouseHandler() of input method if necessary
+ // via mousePressEvent() of text widgets.
+#if 0
+ resetInputContext();
+#endif
+ mousePressEvent((QMouseEvent*)event);
+ break;
+
+ case QEvent::MouseButtonRelease:
+ mouseReleaseEvent((QMouseEvent*)event);
+ break;
+
+ case QEvent::MouseButtonDblClick:
+ mouseDoubleClickEvent((QMouseEvent*)event);
+ break;
+#ifndef QT_NO_WHEELEVENT
+ case QEvent::Wheel:
+ wheelEvent((QWheelEvent*)event);
+ break;
+#endif
+#ifndef QT_NO_TABLETEVENT
+ case QEvent::TabletMove:
+ case QEvent::TabletPress:
+ case QEvent::TabletRelease:
+ tabletEvent((QTabletEvent*)event);
+ break;
+#endif
+#ifdef QT3_SUPPORT
+ case QEvent::Accel:
+ event->ignore();
+ return false;
+#endif
+ case QEvent::KeyPress: {
+ QKeyEvent *k = (QKeyEvent *)event;
+ bool res = false;
+ if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier?
+ if (k->key() == Qt::Key_Backtab
+ || (k->key() == Qt::Key_Tab && (k->modifiers() & Qt::ShiftModifier)))
+ res = focusNextPrevChild(false);
+ else if (k->key() == Qt::Key_Tab)
+ res = focusNextPrevChild(true);
+ if (res)
+ break;
+ }
+ keyPressEvent(k);
+#ifdef QT_KEYPAD_NAVIGATION
+ if (!k->isAccepted() && QApplication::keypadNavigationEnabled()
+ && !(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier | Qt::ShiftModifier))) {
+ if (QApplication::navigationMode() == Qt::NavigationModeKeypadTabOrder) {
+ if (k->key() == Qt::Key_Up)
+ res = focusNextPrevChild(false);
+ else if (k->key() == Qt::Key_Down)
+ res = focusNextPrevChild(true);
+ } else if (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional) {
+ if (k->key() == Qt::Key_Up)
+ res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionNorth);
+ else if (k->key() == Qt::Key_Right)
+ res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionEast);
+ else if (k->key() == Qt::Key_Down)
+ res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionSouth);
+ else if (k->key() == Qt::Key_Left)
+ res = QWidgetPrivate::navigateToDirection(QWidgetPrivate::DirectionWest);
+ }
+ if (res) {
+ k->accept();
+ break;
+ }
+ }
+#endif
+#ifndef QT_NO_WHATSTHIS
+ if (!k->isAccepted()
+ && k->modifiers() & Qt::ShiftModifier && k->key() == Qt::Key_F1
+ && d->whatsThis.size()) {
+ QWhatsThis::showText(mapToGlobal(inputMethodQuery(Qt::ImMicroFocus).toRect().center()), d->whatsThis, this);
+ k->accept();
+ }
+#endif
+ }
+ break;
+
+ case QEvent::KeyRelease:
+ keyReleaseEvent((QKeyEvent*)event);
+ // fall through
+ case QEvent::ShortcutOverride:
+ break;
+
+ case QEvent::InputMethod:
+ inputMethodEvent((QInputMethodEvent *) event);
+ break;
+
+ case QEvent::PolishRequest:
+ ensurePolished();
+ break;
+
+ case QEvent::Polish: {
+ style()->polish(this);
+ setAttribute(Qt::WA_WState_Polished);
+ if (!QApplication::font(this).isCopyOf(QApplication::font()))
+ d->resolveFont();
+ if (!QApplication::palette(this).isCopyOf(QApplication::palette()))
+ d->resolvePalette();
+#ifdef QT3_SUPPORT
+ if(d->sendChildEvents)
+ QApplication::sendPostedEvents(this, QEvent::ChildInserted);
+#endif
+ }
+ break;
+
+ case QEvent::ApplicationWindowIconChange:
+ if (isWindow() && !testAttribute(Qt::WA_SetWindowIcon)) {
+ d->setWindowIcon_sys();
+ d->setWindowIcon_helper();
+ }
+ break;
+ case QEvent::FocusIn:
+#ifdef QT_SOFTKEYS_ENABLED
+ QSoftKeyManager::updateSoftKeys();
+#endif
+ focusInEvent((QFocusEvent*)event);
+ break;
+
+ case QEvent::FocusOut:
+ focusOutEvent((QFocusEvent*)event);
+ break;
+
+ case QEvent::Enter:
+#ifndef QT_NO_STATUSTIP
+ if (d->statusTip.size()) {
+ QStatusTipEvent tip(d->statusTip);
+ QApplication::sendEvent(const_cast<QWidget *>(this), &tip);
+ }
+#endif
+ enterEvent(event);
+ break;
+
+ case QEvent::Leave:
+#ifndef QT_NO_STATUSTIP
+ if (d->statusTip.size()) {
+ QString empty;
+ QStatusTipEvent tip(empty);
+ QApplication::sendEvent(const_cast<QWidget *>(this), &tip);
+ }
+#endif
+ leaveEvent(event);
+ break;
+
+ case QEvent::HoverEnter:
+ case QEvent::HoverLeave:
+ update();
+ break;
+
+ case QEvent::Paint:
+ // At this point the event has to be delivered, regardless
+ // whether the widget isVisible() or not because it
+ // already went through the filters
+ paintEvent((QPaintEvent*)event);
+ break;
+
+ case QEvent::Move:
+ moveEvent((QMoveEvent*)event);
+ break;
+
+ case QEvent::Resize:
+ resizeEvent((QResizeEvent*)event);
+ break;
+
+ case QEvent::Close:
+ closeEvent((QCloseEvent *)event);
+ break;
+
+#ifndef QT_NO_CONTEXTMENU
+ case QEvent::ContextMenu:
+ switch (data->context_menu_policy) {
+ case Qt::PreventContextMenu:
+ break;
+ case Qt::DefaultContextMenu:
+ contextMenuEvent(static_cast<QContextMenuEvent *>(event));
+ break;
+ case Qt::CustomContextMenu:
+ emit customContextMenuRequested(static_cast<QContextMenuEvent *>(event)->pos());
+ break;
+#ifndef QT_NO_MENU
+ case Qt::ActionsContextMenu:
+ if (d->actions.count()) {
+ QMenu::exec(d->actions, static_cast<QContextMenuEvent *>(event)->globalPos(),
+ 0, this);
+ break;
+ }
+ // fall through
+#endif
+ default:
+ event->ignore();
+ break;
+ }
+ break;
+#endif // QT_NO_CONTEXTMENU
+
+#ifndef QT_NO_DRAGANDDROP
+ case QEvent::Drop:
+ dropEvent((QDropEvent*) event);
+ break;
+
+ case QEvent::DragEnter:
+ dragEnterEvent((QDragEnterEvent*) event);
+ break;
+
+ case QEvent::DragMove:
+ dragMoveEvent((QDragMoveEvent*) event);
+ break;
+
+ case QEvent::DragLeave:
+ dragLeaveEvent((QDragLeaveEvent*) event);
+ break;
+#endif
+
+ case QEvent::Show:
+ showEvent((QShowEvent*) event);
+ break;
+
+ case QEvent::Hide:
+ hideEvent((QHideEvent*) event);
+ break;
+
+ case QEvent::ShowWindowRequest:
+ if (!isHidden())
+ d->show_sys();
+ break;
+
+ case QEvent::ApplicationFontChange:
+ d->resolveFont();
+ break;
+ case QEvent::ApplicationPaletteChange:
+ if (!(windowType() == Qt::Desktop))
+ d->resolvePalette();
+ break;
+
+ case QEvent::ToolBarChange:
+ case QEvent::ActivationChange:
+ case QEvent::EnabledChange:
+ case QEvent::FontChange:
+ case QEvent::StyleChange:
+ case QEvent::PaletteChange:
+ case QEvent::WindowTitleChange:
+ case QEvent::IconTextChange:
+ case QEvent::ModifiedChange:
+ case QEvent::MouseTrackingChange:
+ case QEvent::ParentChange:
+ case QEvent::WindowStateChange:
+ case QEvent::LocaleChange:
+ case QEvent::MacSizeChange:
+ case QEvent::ContentsRectChange:
+ changeEvent(event);
+ break;
+
+ case QEvent::WindowActivate:
+ case QEvent::WindowDeactivate: {
+#ifdef QT3_SUPPORT
+ windowActivationChange(event->type() != QEvent::WindowActivate);
+#endif
+ if (isVisible() && !palette().isEqual(QPalette::Active, QPalette::Inactive))
+ update();
+ QList<QObject*> childList = d->children;
+ for (int i = 0; i < childList.size(); ++i) {
+ QWidget *w = qobject_cast<QWidget *>(childList.at(i));
+ if (w && w->isVisible() && !w->isWindow())
+ QApplication::sendEvent(w, event);
+ }
+
+#ifdef QT_SOFTKEYS_ENABLED
+ if (isWindow())
+ QSoftKeyManager::updateSoftKeys();
+#endif
+
+ break; }
+
+ case QEvent::LanguageChange:
+#ifdef QT3_SUPPORT
+ languageChange();
+#endif
+ changeEvent(event);
+ {
+ QList<QObject*> childList = d->children;
+ for (int i = 0; i < childList.size(); ++i) {
+ QObject *o = childList.at(i);
+ if (o)
+ QApplication::sendEvent(o, event);
+ }
+ }
+ update();
+ break;
+
+ case QEvent::ApplicationLayoutDirectionChange:
+ d->resolveLayoutDirection();
+ break;
+
+ case QEvent::LayoutDirectionChange:
+ if (d->layout)
+ d->layout->invalidate();
+ update();
+ changeEvent(event);
+ break;
+ case QEvent::UpdateRequest:
+ d->syncBackingStore();
+ break;
+ case QEvent::UpdateLater:
+ update(static_cast<QUpdateLaterEvent*>(event)->region());
+ break;
+
+ case QEvent::WindowBlocked:
+ case QEvent::WindowUnblocked:
+ {
+ QList<QObject*> childList = d->children;
+ for (int i = 0; i < childList.size(); ++i) {
+ QObject *o = childList.at(i);
+ if (o && o != QApplication::activeModalWidget()) {
+ if (qobject_cast<QWidget *>(o) && static_cast<QWidget *>(o)->isWindow()) {
+ // do not forward the event to child windows,
+ // QApplication does this for us
+ continue;
+ }
+ QApplication::sendEvent(o, event);
+ }
+ }
+#if defined(Q_WS_WIN)
+ setDisabledStyle(this, (event->type() == QEvent::WindowBlocked));
+#endif
+ }
+ break;
+#ifndef QT_NO_TOOLTIP
+ case QEvent::ToolTip:
+ if (!d->toolTip.isEmpty())
+ QToolTip::showText(static_cast<QHelpEvent*>(event)->globalPos(), d->toolTip, this);
+ else
+ event->ignore();
+ break;
+#endif
+#ifndef QT_NO_WHATSTHIS
+ case QEvent::WhatsThis:
+ if (d->whatsThis.size())
+ QWhatsThis::showText(static_cast<QHelpEvent *>(event)->globalPos(), d->whatsThis, this);
+ else
+ event->ignore();
+ break;
+ case QEvent::QueryWhatsThis:
+ if (d->whatsThis.isEmpty())
+ event->ignore();
+ break;
+#endif
+#ifndef QT_NO_ACCESSIBILITY
+ case QEvent::AccessibilityDescription:
+ case QEvent::AccessibilityHelp: {
+ QAccessibleEvent *ev = static_cast<QAccessibleEvent *>(event);
+ if (ev->child())
+ return false;
+ switch (ev->type()) {
+#ifndef QT_NO_TOOLTIP
+ case QEvent::AccessibilityDescription:
+ ev->setValue(d->toolTip);
+ break;
+#endif
+#ifndef QT_NO_WHATSTHIS
+ case QEvent::AccessibilityHelp:
+ ev->setValue(d->whatsThis);
+ break;
+#endif
+ default:
+ return false;
+ }
+ break; }
+#endif
+ case QEvent::EmbeddingControl:
+ d->topData()->frameStrut.setCoords(0 ,0, 0, 0);
+ data->fstrut_dirty = false;
+#if defined(Q_WS_WIN) || defined(Q_WS_X11)
+ d->topData()->embedded = 1;
+#endif
+ break;
+#ifndef QT_NO_ACTION
+ case QEvent::ActionAdded:
+ case QEvent::ActionRemoved:
+ case QEvent::ActionChanged:
+#ifdef QT_SOFTKEYS_ENABLED
+ QSoftKeyManager::updateSoftKeys();
+#endif
+ actionEvent((QActionEvent*)event);
+ break;
+#endif
+
+ case QEvent::KeyboardLayoutChange:
+ {
+ changeEvent(event);
+
+ // inform children of the change
+ QList<QObject*> childList = d->children;
+ for (int i = 0; i < childList.size(); ++i) {
+ QWidget *w = qobject_cast<QWidget *>(childList.at(i));
+ if (w && w->isVisible() && !w->isWindow())
+ QApplication::sendEvent(w, event);
+ }
+ break;
+ }
+#ifdef Q_WS_MAC
+ case QEvent::MacGLWindowChange:
+ d->needWindowChange = false;
+ break;
+#endif
+ case QEvent::TouchBegin:
+ case QEvent::TouchUpdate:
+ case QEvent::TouchEnd:
+ {
+#ifndef Q_WS_MAC
+ QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event);
+ const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().first();
+ if (touchPoint.isPrimary() || touchEvent->deviceType() == QTouchEvent::TouchPad)
+ break;
+
+ // fake a mouse event!
+ QEvent::Type eventType = QEvent::None;
+ switch (touchEvent->type()) {
+ case QEvent::TouchBegin:
+ eventType = QEvent::MouseButtonPress;
+ break;
+ case QEvent::TouchUpdate:
+ eventType = QEvent::MouseMove;
+ break;
+ case QEvent::TouchEnd:
+ eventType = QEvent::MouseButtonRelease;
+ break;
+ default:
+ Q_ASSERT(!true);
+ break;
+ }
+ if (eventType == QEvent::None)
+ break;
+
+ QMouseEvent mouseEvent(eventType,
+ touchPoint.pos().toPoint(),
+ touchPoint.screenPos().toPoint(),
+ Qt::LeftButton,
+ Qt::LeftButton,
+ touchEvent->modifiers());
+ (void) QApplication::sendEvent(this, &mouseEvent);
+#endif // Q_WS_MAC
+ break;
+ }
+#ifndef QT_NO_GESTURES
+ case QEvent::Gesture:
+ event->ignore();
+ break;
+#endif
+#ifndef QT_NO_PROPERTIES
+ case QEvent::DynamicPropertyChange: {
+ const QByteArray &propName = static_cast<QDynamicPropertyChangeEvent *>(event)->propertyName();
+ if (!qstrncmp(propName, "_q_customDpi", 12) && propName.length() == 13) {
+ uint value = property(propName.constData()).toUInt();
+ if (!d->extra)
+ d->createExtra();
+ const char axis = propName.at(12);
+ if (axis == 'X')
+ d->extra->customDpiX = value;
+ else if (axis == 'Y')
+ d->extra->customDpiY = value;
+ d->updateFont(d->data.fnt);
+ }
+ // fall through
+ }
+#endif
+ default:
+ return QObject::event(event);
+ }
+ return true;
+}
+
+/*!
+ This event handler can be reimplemented to handle state changes.
+
+ The state being changed in this event can be retrieved through the \a event
+ supplied.
+
+ Change events include: QEvent::ToolBarChange,
+ QEvent::ActivationChange, QEvent::EnabledChange, QEvent::FontChange,
+ QEvent::StyleChange, QEvent::PaletteChange,
+ QEvent::WindowTitleChange, QEvent::IconTextChange,
+ QEvent::ModifiedChange, QEvent::MouseTrackingChange,
+ QEvent::ParentChange, QEvent::WindowStateChange,
+ QEvent::LanguageChange, QEvent::LocaleChange,
+ QEvent::LayoutDirectionChange.
+
+*/
+void QWidget::changeEvent(QEvent * event)
+{
+ switch(event->type()) {
+ case QEvent::EnabledChange:
+ update();
+#ifndef QT_NO_ACCESSIBILITY
+ QAccessible::updateAccessibility(this, 0, QAccessible::StateChanged);
+#endif
+ break;
+
+ case QEvent::FontChange:
+ case QEvent::StyleChange: {
+ Q_D(QWidget);
+ update();
+ updateGeometry();
+ if (d->layout)
+ d->layout->invalidate();
+#ifdef Q_WS_QWS
+ if (isWindow())
+ d->data.fstrut_dirty = true;
+#endif
+ break;
+ }
+
+ case QEvent::PaletteChange:
+ update();
+ break;
+
+#ifdef Q_WS_MAC
+ case QEvent::MacSizeChange:
+ updateGeometry();
+ break;
+ case QEvent::ToolTipChange:
+ case QEvent::MouseTrackingChange:
+ qt_mac_update_mouseTracking(this);
+ break;
+#endif
+
+ default:
+ break;
+ }
+}
+
+/*!
+ This event handler, for event \a event, can be reimplemented in a
+ subclass to receive mouse move events for the widget.
+
+ If mouse tracking is switched off, mouse move events only occur if
+ a mouse button is pressed while the mouse is being moved. If mouse
+ tracking is switched on, mouse move events occur even if no mouse
+ button is pressed.
+
+ QMouseEvent::pos() reports the position of the mouse cursor,
+ relative to this widget. For press and release events, the
+ position is usually the same as the position of the last mouse
+ move event, but it might be different if the user's hand shakes.
+ This is a feature of the underlying window system, not Qt.
+
+ If you want to show a tooltip immediately, while the mouse is
+ moving (e.g., to get the mouse coordinates with QMouseEvent::pos()
+ and show them as a tooltip), you must first enable mouse tracking
+ as described above. Then, to ensure that the tooltip is updated
+ immediately, you must call QToolTip::showText() instead of
+ setToolTip() in your implementation of mouseMoveEvent().
+
+ \sa setMouseTracking(), mousePressEvent(), mouseReleaseEvent(),
+ mouseDoubleClickEvent(), event(), QMouseEvent, {Scribble Example}
+*/
+
+void QWidget::mouseMoveEvent(QMouseEvent *event)
+{
+ event->ignore();
+}
+
+/*!
+ This event handler, for event \a event, can be reimplemented in a
+ subclass to receive mouse press events for the widget.
+
+ If you create new widgets in the mousePressEvent() the
+ mouseReleaseEvent() may not end up where you expect, depending on
+ the underlying window system (or X11 window manager), the widgets'
+ location and maybe more.
+
+ The default implementation implements the closing of popup widgets
+ when you click outside the window. For other widget types it does
+ nothing.
+
+ \sa mouseReleaseEvent(), mouseDoubleClickEvent(),
+ mouseMoveEvent(), event(), QMouseEvent, {Scribble Example}
+*/
+
+void QWidget::mousePressEvent(QMouseEvent *event)
+{
+ event->ignore();
+ if ((windowType() == Qt::Popup)) {
+ event->accept();
+ QWidget* w;
+ while ((w = QApplication::activePopupWidget()) && w != this){
+ w->close();
+ if (QApplication::activePopupWidget() == w) // widget does not want to disappear
+ w->hide(); // hide at least
+ }
+ if (!rect().contains(event->pos())){
+ close();
+ }
+ }
+}
+
+/*!
+ This event handler, for event \a event, can be reimplemented in a
+ subclass to receive mouse release events for the widget.
+
+ \sa mousePressEvent(), mouseDoubleClickEvent(),
+ mouseMoveEvent(), event(), QMouseEvent, {Scribble Example}
+*/
+
+void QWidget::mouseReleaseEvent(QMouseEvent *event)
+{
+ event->ignore();
+}
+
+/*!
+ This event handler, for event \a event, can be reimplemented in a
+ subclass to receive mouse double click events for the widget.
+
+ The default implementation generates a normal mouse press event.
+
+ \note The widget will also receive mouse press and mouse release
+ events in addition to the double click event. It is up to the
+ developer to ensure that the application interprets these events
+ correctly.
+
+ \sa mousePressEvent(), mouseReleaseEvent() mouseMoveEvent(),
+ event(), QMouseEvent
+*/
+
+void QWidget::mouseDoubleClickEvent(QMouseEvent *event)
+{
+ mousePressEvent(event); // try mouse press event
+}
+
+#ifndef QT_NO_WHEELEVENT
+/*!
+ This event handler, for event \a event, can be reimplemented in a
+ subclass to receive wheel events for the widget.
+
+ If you reimplement this handler, it is very important that you
+ \link QWheelEvent ignore()\endlink the event if you do not handle
+ it, so that the widget's parent can interpret it.
+
+ The default implementation ignores the event.
+
+ \sa QWheelEvent::ignore(), QWheelEvent::accept(), event(),
+ QWheelEvent
+*/
+
+void QWidget::wheelEvent(QWheelEvent *event)
+{
+ event->ignore();
+}
+#endif // QT_NO_WHEELEVENT
+
+#ifndef QT_NO_TABLETEVENT
+/*!
+ This event handler, for event \a event, can be reimplemented in a
+ subclass to receive tablet events for the widget.
+
+ If you reimplement this handler, it is very important that you
+ \link QTabletEvent ignore()\endlink the event if you do not handle
+ it, so that the widget's parent can interpret it.
+
+ The default implementation ignores the event.
+
+ \sa QTabletEvent::ignore(), QTabletEvent::accept(), event(),
+ QTabletEvent
+*/
+
+void QWidget::tabletEvent(QTabletEvent *event)
+{
+ event->ignore();
+}
+#endif // QT_NO_TABLETEVENT
+
+/*!
+ This event handler, for event \a event, can be reimplemented in a
+ subclass to receive key press events for the widget.
+
+ A widget must call setFocusPolicy() to accept focus initially and
+ have focus in order to receive a key press event.
+
+ If you reimplement this handler, it is very important that you
+ call the base class implementation if you do not act upon the key.
+
+ The default implementation closes popup widgets if the user
+ presses Esc. Otherwise the event is ignored, so that the widget's
+ parent can interpret it.
+
+ Note that QKeyEvent starts with isAccepted() == true, so you do not
+ need to call QKeyEvent::accept() - just do not call the base class
+ implementation if you act upon the key.
+
+ \sa keyReleaseEvent(), setFocusPolicy(),
+ focusInEvent(), focusOutEvent(), event(), QKeyEvent, {Tetrix Example}
+*/
+
+void QWidget::keyPressEvent(QKeyEvent *event)
+{
+ if ((windowType() == Qt::Popup) && event->key() == Qt::Key_Escape) {
+ event->accept();
+ close();
+ } else {
+ event->ignore();
+ }
+}
+
+/*!
+ This event handler, for event \a event, can be reimplemented in a
+ subclass to receive key release events for the widget.
+
+ A widget must \link setFocusPolicy() accept focus\endlink
+ initially and \link hasFocus() have focus\endlink in order to
+ receive a key release event.
+
+ If you reimplement this handler, it is very important that you
+ call the base class implementation if you do not act upon the key.
+
+ The default implementation ignores the event, so that the widget's
+ parent can interpret it.
+
+ Note that QKeyEvent starts with isAccepted() == true, so you do not
+ need to call QKeyEvent::accept() - just do not call the base class
+ implementation if you act upon the key.
+
+ \sa keyPressEvent(), QKeyEvent::ignore(), setFocusPolicy(),
+ focusInEvent(), focusOutEvent(), event(), QKeyEvent
+*/
+
+void QWidget::keyReleaseEvent(QKeyEvent *event)
+{
+ event->ignore();
+}
+
+/*!
+ \fn void QWidget::focusInEvent(QFocusEvent *event)
+
+ This event handler can be reimplemented in a subclass to receive
+ keyboard focus events (focus received) for the widget. The event
+ is passed in the \a event parameter
+
+ A widget normally must setFocusPolicy() to something other than
+ Qt::NoFocus in order to receive focus events. (Note that the
+ application programmer can call setFocus() on any widget, even
+ those that do not normally accept focus.)
+
+ The default implementation updates the widget (except for windows
+ that do not specify a focusPolicy()).
+
+ \sa focusOutEvent(), setFocusPolicy(), keyPressEvent(),
+ keyReleaseEvent(), event(), QFocusEvent
+*/
+
+void QWidget::focusInEvent(QFocusEvent *)
+{
+ if (focusPolicy() != Qt::NoFocus || !isWindow()) {
+ update();
+ }
+}
+
+/*!
+ \fn void QWidget::focusOutEvent(QFocusEvent *event)
+
+ This event handler can be reimplemented in a subclass to receive
+ keyboard focus events (focus lost) for the widget. The events is
+ passed in the \a event parameter.
+
+ A widget normally must setFocusPolicy() to something other than
+ Qt::NoFocus in order to receive focus events. (Note that the
+ application programmer can call setFocus() on any widget, even
+ those that do not normally accept focus.)
+
+ The default implementation updates the widget (except for windows
+ that do not specify a focusPolicy()).
+
+ \sa focusInEvent(), setFocusPolicy(), keyPressEvent(),
+ keyReleaseEvent(), event(), QFocusEvent
+*/
+
+void QWidget::focusOutEvent(QFocusEvent *)
+{
+ if (focusPolicy() != Qt::NoFocus || !isWindow())
+ update();
+}
+
+/*!
+ \fn void QWidget::enterEvent(QEvent *event)
+
+ This event handler can be reimplemented in a subclass to receive
+ widget enter events which are passed in the \a event parameter.
+
+ An event is sent to the widget when the mouse cursor enters the
+ widget.
+
+ \sa leaveEvent(), mouseMoveEvent(), event()
+*/
+
+void QWidget::enterEvent(QEvent *)
+{
+}
+
+/*!
+ \fn void QWidget::leaveEvent(QEvent *event)
+
+ This event handler can be reimplemented in a subclass to receive
+ widget leave events which are passed in the \a event parameter.
+
+ A leave event is sent to the widget when the mouse cursor leaves
+ the widget.
+
+ \sa enterEvent(), mouseMoveEvent(), event()
+*/
+
+void QWidget::leaveEvent(QEvent *)
+{
+}
+
+/*!
+ \fn void QWidget::paintEvent(QPaintEvent *event)
+
+ This event handler can be reimplemented in a subclass to receive paint
+ events passed in \a event.
+
+ A paint event is a request to repaint all or part of a widget. It can
+ happen for one of the following reasons:
+
+ \list
+ \o repaint() or update() was invoked,
+ \o the widget was obscured and has now been uncovered, or
+ \o many other reasons.
+ \endlist
+
+ Many widgets can simply repaint their entire surface when asked to, but
+ some slow widgets need to optimize by painting only the requested region:
+ QPaintEvent::region(). This speed optimization does not change the result,
+ as painting is clipped to that region during event processing. QListView
+ and QTableView do this, for example.
+
+ Qt also tries to speed up painting by merging multiple paint events into
+ one. When update() is called several times or the window system sends
+ several paint events, Qt merges these events into one event with a larger
+ region (see QRegion::united()). The repaint() function does not permit this
+ optimization, so we suggest using update() whenever possible.
+
+ When the paint event occurs, the update region has normally been erased, so
+ you are painting on the widget's background.
+
+ The background can be set using setBackgroundRole() and setPalette().
+
+ Since Qt 4.0, QWidget automatically double-buffers its painting, so there
+ is no need to write double-buffering code in paintEvent() to avoid flicker.
+
+ \bold{Note for the X11 platform}: It is possible to toggle global double
+ buffering by calling \c qt_x11_set_global_double_buffer(). For example,
+
+ \snippet doc/src/snippets/code/src_gui_kernel_qwidget.cpp 14
+
+ \note Generally, you should refrain from calling update() or repaint()
+ \bold{inside} a paintEvent(). For example, calling update() or repaint() on
+ children inside a paintevent() results in undefined behavior; the child may
+ or may not get a paint event.
+
+ \warning If you are using a custom paint engine without Qt's backingstore,
+ Qt::WA_PaintOnScreen must be set. Otherwise, QWidget::paintEngine() will
+ never be called; the backingstore will be used instead.
+
+ \sa event(), repaint(), update(), QPainter, QPixmap, QPaintEvent,
+ {Analog Clock Example}
+*/
+
+void QWidget::paintEvent(QPaintEvent *)
+{
+}
+
+
+/*!
+ \fn void QWidget::moveEvent(QMoveEvent *event)
+
+ This event handler can be reimplemented in a subclass to receive
+ widget move events which are passed in the \a event parameter.
+ When the widget receives this event, it is already at the new
+ position.
+
+ The old position is accessible through QMoveEvent::oldPos().
+
+ \sa resizeEvent(), event(), move(), QMoveEvent
+*/
+
+void QWidget::moveEvent(QMoveEvent *)
+{
+}
+
+
+/*!
+ This event handler can be reimplemented in a subclass to receive
+ widget resize events which are passed in the \a event parameter.
+ When resizeEvent() is called, the widget already has its new
+ geometry. The old size is accessible through
+ QResizeEvent::oldSize().
+
+ The widget will be erased and receive a paint event immediately
+ after processing the resize event. No drawing need be (or should
+ be) done inside this handler.
+
+
+ \sa moveEvent(), event(), resize(), QResizeEvent, paintEvent(),
+ {Scribble Example}
+*/
+
+void QWidget::resizeEvent(QResizeEvent * /* event */)
+{
+}
+
+#ifndef QT_NO_ACTION
+/*!
+ \fn void QWidget::actionEvent(QActionEvent *event)
+
+ This event handler is called with the given \a event whenever the
+ widget's actions are changed.
+
+ \sa addAction(), insertAction(), removeAction(), actions(), QActionEvent
+*/
+void QWidget::actionEvent(QActionEvent *)
+{
+
+}
+#endif
+
+/*!
+ This event handler is called with the given \a event when Qt receives a window
+ close request for a top-level widget from the window system.
+
+ By default, the event is accepted and the widget is closed. You can reimplement
+ this function to change the way the widget responds to window close requests.
+ For example, you can prevent the window from closing by calling \l{QEvent::}{ignore()}
+ on all events.
+
+ Main window applications typically use reimplementations of this function to check
+ whether the user's work has been saved and ask for permission before closing.
+ For example, the \l{Application Example} uses a helper function to determine whether
+ or not to close the window:
+
+ \snippet mainwindows/application/mainwindow.cpp 3
+ \snippet mainwindows/application/mainwindow.cpp 4
+
+ \sa event(), hide(), close(), QCloseEvent, {Application Example}
+*/
+
+void QWidget::closeEvent(QCloseEvent *event)
+{
+ event->accept();
+}
+
+#ifndef QT_NO_CONTEXTMENU
+/*!
+ This event handler, for event \a event, can be reimplemented in a
+ subclass to receive widget context menu events.
+
+ The handler is called when the widget's \l contextMenuPolicy is
+ Qt::DefaultContextMenu.
+
+ The default implementation ignores the context event.
+ See the \l QContextMenuEvent documentation for more details.
+
+ \sa event(), QContextMenuEvent customContextMenuRequested()
+*/
+
+void QWidget::contextMenuEvent(QContextMenuEvent *event)
+{
+ event->ignore();
+}
+#endif // QT_NO_CONTEXTMENU
+
+
+/*!
+ This event handler, for event \a event, can be reimplemented in a
+ subclass to receive Input Method composition events. This handler
+ is called when the state of the input method changes.
+
+ Note that when creating custom text editing widgets, the
+ Qt::WA_InputMethodEnabled window attribute must be set explicitly
+ (using the setAttribute() function) in order to receive input
+ method events.
+
+ The default implementation calls event->ignore(), which rejects the
+ Input Method event. See the \l QInputMethodEvent documentation for more
+ details.
+
+ \sa event(), QInputMethodEvent
+*/
+void QWidget::inputMethodEvent(QInputMethodEvent *event)
+{
+ event->ignore();
+}
+
+/*!
+ This method is only relevant for input widgets. It is used by the
+ input method to query a set of properties of the widget to be
+ able to support complex input method operations as support for
+ surrounding text and reconversions.
+
+ \a query specifies which property is queried.
+
+ \sa inputMethodEvent(), QInputMethodEvent, QInputContext, inputMethodHints
+*/
+QVariant QWidget::inputMethodQuery(Qt::InputMethodQuery query) const
+{
+ switch(query) {
+ case Qt::ImMicroFocus:
+ return QRect(width()/2, 0, 1, height());
+ case Qt::ImFont:
+ return font();
+ case Qt::ImAnchorPosition:
+ // Fallback.
+ return inputMethodQuery(Qt::ImCursorPosition);
+ default:
+ return QVariant();
+ }
+}
+
+/*!
+ \property QWidget::inputMethodHints
+ \brief What input method specific hints the widget has.
+
+ This is only relevant for input widgets. It is used by
+ the input method to retrieve hints as to how the input method
+ should operate. For example, if the Qt::ImhFormattedNumbersOnly flag
+ is set, the input method may change its visual components to reflect
+ that only numbers can be entered.
+
+ \note The flags are only hints, so the particular input method
+ implementation is free to ignore them. If you want to be
+ sure that a certain type of characters are entered,
+ you should also set a QValidator on the widget.
+
+ The default value is Qt::ImhNone.
+
+ \since 4.6
+
+ \sa inputMethodQuery(), QInputContext
+*/
+Qt::InputMethodHints QWidget::inputMethodHints() const
+{
+#ifndef QT_NO_IM
+ const QWidgetPrivate *priv = d_func();
+ while (priv->inheritsInputMethodHints) {
+ priv = priv->q_func()->parentWidget()->d_func();
+ Q_ASSERT(priv);
+ }
+ return priv->imHints;
+#else //QT_NO_IM
+ return 0;
+#endif //QT_NO_IM
+}
+
+void QWidget::setInputMethodHints(Qt::InputMethodHints hints)
+{
+#ifndef QT_NO_IM
+ Q_D(QWidget);
+ d->imHints = hints;
+ // Optimization to update input context only it has already been created.
+ if (d->ic || qApp->d_func()->inputContext) {
+ QInputContext *ic = inputContext();
+ if (ic)
+ ic->update();
+ }
+#endif //QT_NO_IM
+}
+
+
+#ifndef QT_NO_DRAGANDDROP
+
+/*!
+ \fn void QWidget::dragEnterEvent(QDragEnterEvent *event)
+
+ This event handler is called when a drag is in progress and the
+ mouse enters this widget. The event is passed in the \a event parameter.
+
+ If the event is ignored, the widget won't receive any \l{dragMoveEvent()}{drag
+ move events}.
+
+ See the \link dnd.html Drag-and-drop documentation\endlink for an
+ overview of how to provide drag-and-drop in your application.
+
+ \sa QDrag, QDragEnterEvent
+*/
+void QWidget::dragEnterEvent(QDragEnterEvent *)
+{
+}
+
+/*!
+ \fn void QWidget::dragMoveEvent(QDragMoveEvent *event)
+
+ This event handler is called if a drag is in progress, and when
+ any of the following conditions occur: the cursor enters this widget,
+ the cursor moves within this widget, or a modifier key is pressed on
+ the keyboard while this widget has the focus. The event is passed
+ in the \a event parameter.
+
+ See the \link dnd.html Drag-and-drop documentation\endlink for an
+ overview of how to provide drag-and-drop in your application.
+
+ \sa QDrag, QDragMoveEvent
+*/
+void QWidget::dragMoveEvent(QDragMoveEvent *)
+{
+}
+
+/*!
+ \fn void QWidget::dragLeaveEvent(QDragLeaveEvent *event)
+
+ This event handler is called when a drag is in progress and the
+ mouse leaves this widget. The event is passed in the \a event
+ parameter.
+
+ See the \link dnd.html Drag-and-drop documentation\endlink for an
+ overview of how to provide drag-and-drop in your application.
+
+ \sa QDrag, QDragLeaveEvent
+*/
+void QWidget::dragLeaveEvent(QDragLeaveEvent *)
+{
+}
+
+/*!
+ \fn void QWidget::dropEvent(QDropEvent *event)
+
+ This event handler is called when the drag is dropped on this
+ widget. The event is passed in the \a event parameter.
+
+ See the \link dnd.html Drag-and-drop documentation\endlink for an
+ overview of how to provide drag-and-drop in your application.
+
+ \sa QDrag, QDropEvent
+*/
+void QWidget::dropEvent(QDropEvent *)
+{
+}
+
+#endif // QT_NO_DRAGANDDROP
+
+/*!
+ \fn void QWidget::showEvent(QShowEvent *event)
+
+ This event handler can be reimplemented in a subclass to receive
+ widget show events which are passed in the \a event parameter.
+
+ Non-spontaneous show events are sent to widgets immediately
+ before they are shown. The spontaneous show events of windows are
+ delivered afterwards.
+
+ Note: A widget receives spontaneous show and hide events when its
+ mapping status is changed by the window system, e.g. a spontaneous
+ hide event when the user minimizes the window, and a spontaneous
+ show event when the window is restored again. After receiving a
+ spontaneous hide event, a widget is still considered visible in
+ the sense of isVisible().
+
+ \sa visible, event(), QShowEvent
+*/
+void QWidget::showEvent(QShowEvent *)
+{
+}
+
+/*!
+ \fn void QWidget::hideEvent(QHideEvent *event)
+
+ This event handler can be reimplemented in a subclass to receive
+ widget hide events. The event is passed in the \a event parameter.
+
+ Hide events are sent to widgets immediately after they have been
+ hidden.
+
+ Note: A widget receives spontaneous show and hide events when its
+ mapping status is changed by the window system, e.g. a spontaneous
+ hide event when the user minimizes the window, and a spontaneous
+ show event when the window is restored again. After receiving a
+ spontaneous hide event, a widget is still considered visible in
+ the sense of isVisible().
+
+ \sa visible, event(), QHideEvent
+*/
+void QWidget::hideEvent(QHideEvent *)
+{
+}
+
+/*
+ \fn QWidget::x11Event(MSG *)
+
+ This special event handler can be reimplemented in a subclass to receive
+ native X11 events.
+
+ In your reimplementation of this function, if you want to stop Qt from
+ handling the event, return true. If you return false, this native event
+ is passed back to Qt, which translates it into a Qt event and sends it to
+ the widget.
+
+ \note Events are only delivered to this event handler if the widget is
+ native.
+
+ \warning This function is not portable.
+
+ \sa QApplication::x11EventFilter(), QWidget::winId()
+*/
+
+
+#if defined(Q_WS_MAC)
+
+/*!
+ \fn bool QWidget::macEvent(EventHandlerCallRef caller, EventRef event)
+
+ This special event handler can be reimplemented in a subclass to
+ receive native Macintosh events.
+
+ The parameters are a bit different depending if Qt is build against Carbon
+ or Cocoa. In Carbon, \a caller and \a event are the corresponding
+ EventHandlerCallRef and EventRef that correspond to the Carbon event
+ handlers that are installed. In Cocoa, \a caller is always 0 and the
+ EventRef is the EventRef generated from the NSEvent.
+
+ In your reimplementation of this function, if you want to stop the
+ event being handled by Qt, return true. If you return false, this
+ native event is passed back to Qt, which translates the event into
+ a Qt event and sends it to the widget.
+
+ \warning This function is not portable.
+
+ \warning This function was not called inside of Qt until Qt 4.4.
+ If you need compatibility with earlier versions of Qt, consider QApplication::macEventFilter() instead.
+
+ \sa QApplication::macEventFilter()
+*/
+
+bool QWidget::macEvent(EventHandlerCallRef, EventRef)
+{
+ return false;
+}
+
+#endif
+#if defined(Q_WS_WIN)
+
+/*!
+ This special event handler can be reimplemented in a subclass to
+ receive native Windows events which are passed in the \a message
+ parameter.
+
+ In your reimplementation of this function, if you want to stop the
+ event being handled by Qt, return true and set \a result to the value
+ that the window procedure should return. If you return false, this
+ native event is passed back to Qt, which translates the event into
+ a Qt event and sends it to the widget.
+
+ \warning This function is not portable.
+
+ \sa QApplication::winEventFilter()
+*/
+bool QWidget::winEvent(MSG *message, long *result)
+{
+ Q_UNUSED(message);
+ Q_UNUSED(result);
+ return false;
+}
+
+#endif
+#if defined(Q_WS_X11)
+
+/*!
+ \fn bool QWidget::x11Event(XEvent *event)
+
+ This special event handler can be reimplemented in a subclass to receive
+ native X11 events passed in the \a event parameter.
+
+ In your reimplementation of this function, if you want to stop Qt from
+ handling the event, return true. If you return false, this native event
+ is passed back to Qt, which translates it into a Qt event and sends it to
+ the widget.
+
+ \note Events are only delivered to this event handler if the widget is
+ native.
+
+ \warning This function is not portable.
+
+ \sa QApplication::x11EventFilter(), QWidget::winId()
+*/
+bool QWidget::x11Event(XEvent *)
+{
+ return false;
+}
+
+#endif
+#if defined(Q_WS_QWS)
+
+/*!
+ \fn bool QWidget::qwsEvent(QWSEvent *event)
+
+ This special event handler can be reimplemented in a subclass to
+ receive native Qt for Embedded Linux events which are passed in the
+ \a event parameter.
+
+ In your reimplementation of this function, if you want to stop the
+ event being handled by Qt, return true. If you return false, this
+ native event is passed back to Qt, which translates the event into
+ a Qt event and sends it to the widget.
+
+ \warning This function is not portable.
+
+ \sa QApplication::qwsEventFilter()
+*/
+bool QWidget::qwsEvent(QWSEvent *)
+{
+ return false;
+}
+
+#endif
+
+
+/*!
+ Ensures that the widget has been polished by QStyle (i.e., has a
+ proper font and palette).
+
+ QWidget calls this function after it has been fully constructed
+ but before it is shown the very first time. You can call this
+ function if you want to ensure that the widget is polished before
+ doing an operation, e.g., the correct font size might be needed in
+ the widget's sizeHint() reimplementation. Note that this function
+ \e is called from the default implementation of sizeHint().
+
+ Polishing is useful for final initialization that must happen after
+ all constructors (from base classes as well as from subclasses)
+ have been called.
+
+ If you need to change some settings when a widget is polished,
+ reimplement event() and handle the QEvent::Polish event type.
+
+ \bold{Note:} The function is declared const so that it can be called from
+ other const functions (e.g., sizeHint()).
+
+ \sa event()
+*/
+void QWidget::ensurePolished() const
+{
+ Q_D(const QWidget);
+
+ const QMetaObject *m = metaObject();
+ if (m == d->polished)
+ return;
+ d->polished = m;
+
+ QEvent e(QEvent::Polish);
+ QCoreApplication::sendEvent(const_cast<QWidget *>(this), &e);
+
+ // polish children after 'this'
+ QList<QObject*> children = d->children;
+ for (int i = 0; i < children.size(); ++i) {
+ QObject *o = children.at(i);
+ if(!o->isWidgetType())
+ continue;
+ if (QWidget *w = qobject_cast<QWidget *>(o))
+ w->ensurePolished();
+ }
+
+ if (d->parent && d->sendChildEvents) {
+ QChildEvent e(QEvent::ChildPolished, const_cast<QWidget *>(this));
+ QCoreApplication::sendEvent(d->parent, &e);
+ }
+}
+
+/*!
+ Returns the mask currently set on a widget. If no mask is set the
+ return value will be an empty region.
+
+ \sa setMask(), clearMask(), QRegion::isEmpty(), {Shaped Clock Example}
+*/
+QRegion QWidget::mask() const
+{
+ Q_D(const QWidget);
+ return d->extra ? d->extra->mask : QRegion();
+}
+
+/*!
+ Returns the layout manager that is installed on this widget, or 0
+ if no layout manager is installed.
+
+ The layout manager sets the geometry of the widget's children
+ that have been added to the layout.
+
+ \sa setLayout(), sizePolicy(), {Layout Management}
+*/
+QLayout *QWidget::layout() const
+{
+ return d_func()->layout;
+}
+
+
+/*!
+ \fn void QWidget::setLayout(QLayout *layout)
+
+ Sets the layout manager for this widget to \a layout.
+
+ If there already is a layout manager installed on this widget,
+ QWidget won't let you install another. You must first delete the
+ existing layout manager (returned by layout()) before you can
+ call setLayout() with the new layout.
+
+ If \a layout is the layout manger on a different widget, setLayout()
+ will reparent the layout and make it the layout manager for this widget.
+
+ Example:
+
+ \snippet examples/uitools/textfinder/textfinder.cpp 3b
+
+ An alternative to calling this function is to pass this widget to
+ the layout's constructor.
+
+ The QWidget will take ownership of \a layout.
+
+ \sa layout(), {Layout Management}
+*/
+
+void QWidget::setLayout(QLayout *l)
+{
+ if (!l) {
+ qWarning("QWidget::setLayout: Cannot set layout to 0");
+ return;
+ }
+ if (layout()) {
+ if (layout() != l)
+ qWarning("QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", which already has a"
+ " layout", l->objectName().toLocal8Bit().data(), metaObject()->className(),
+ objectName().toLocal8Bit().data());
+ return;
+ }
+
+ QObject *oldParent = l->parent();
+ if (oldParent && oldParent != this) {
+ if (oldParent->isWidgetType()) {
+ // Steal the layout off a widget parent. Takes effect when
+ // morphing laid-out container widgets in Designer.
+ QWidget *oldParentWidget = static_cast<QWidget *>(oldParent);
+ oldParentWidget->takeLayout();
+ } else {
+ qWarning("QWidget::setLayout: Attempting to set QLayout \"%s\" on %s \"%s\", when the QLayout already has a parent",
+ l->objectName().toLocal8Bit().data(), metaObject()->className(),
+ objectName().toLocal8Bit().data());
+ return;
+ }
+ }
+
+ Q_D(QWidget);
+ l->d_func()->topLevel = true;
+ d->layout = l;
+ if (oldParent != this) {
+ l->setParent(this);
+ l->d_func()->reparentChildWidgets(this);
+ l->invalidate();
+ }
+
+ if (isWindow() && d->maybeTopData())
+ d->topData()->sizeAdjusted = false;
+}
+
+/*!
+ \fn QLayout *QWidget::takeLayout()
+
+ Remove the layout from the widget.
+ \since 4.5
+*/
+
+QLayout *QWidget::takeLayout()
+{
+ Q_D(QWidget);
+ QLayout *l = layout();
+ if (!l)
+ return 0;
+ d->layout = 0;
+ l->setParent(0);
+ return l;
+}
+
+/*!
+ \property QWidget::sizePolicy
+ \brief the default layout behavior of the widget
+
+ If there is a QLayout that manages this widget's children, the
+ size policy specified by that layout is used. If there is no such
+ QLayout, the result of this function is used.
+
+ The default policy is Preferred/Preferred, which means that the
+ widget can be freely resized, but prefers to be the size
+ sizeHint() returns. Button-like widgets set the size policy to
+ specify that they may stretch horizontally, but are fixed
+ vertically. The same applies to lineedit controls (such as
+ QLineEdit, QSpinBox or an editable QComboBox) and other
+ horizontally orientated widgets (such as QProgressBar).
+ QToolButton's are normally square, so they allow growth in both
+ directions. Widgets that support different directions (such as
+ QSlider, QScrollBar or QHeader) specify stretching in the
+ respective direction only. Widgets that can provide scroll bars
+ (usually subclasses of QScrollArea) tend to specify that they can
+ use additional space, and that they can make do with less than
+ sizeHint().
+
+ \sa sizeHint() QLayout QSizePolicy updateGeometry()
+*/
+QSizePolicy QWidget::sizePolicy() const
+{
+ Q_D(const QWidget);
+ return d->size_policy;
+}
+
+void QWidget::setSizePolicy(QSizePolicy policy)
+{
+ Q_D(QWidget);
+ setAttribute(Qt::WA_WState_OwnSizePolicy);
+ if (policy == d->size_policy)
+ return;
+ d->size_policy = policy;
+
+#ifndef QT_NO_GRAPHICSVIEW
+ if (QWExtra *extra = d->extra) {
+ if (extra->proxyWidget)
+ extra->proxyWidget->setSizePolicy(policy);
+ }
+#endif
+
+ updateGeometry();
+
+ if (isWindow() && d->maybeTopData())
+ d->topData()->sizeAdjusted = false;
+}
+
+/*!
+ \fn void QWidget::setSizePolicy(QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical)
+ \overload
+
+ Sets the size policy of the widget to \a horizontal and \a
+ vertical, with standard stretch and no height-for-width.
+
+ \sa QSizePolicy::QSizePolicy()
+*/
+
+/*!
+ Returns the preferred height for this widget, given the width \a w.
+
+ If this widget has a layout, the default implementation returns
+ the layout's preferred height. if there is no layout, the default
+ implementation returns -1 indicating that the preferred height
+ does not depend on the width.
+*/
+
+int QWidget::heightForWidth(int w) const
+{
+ if (layout() && layout()->hasHeightForWidth())
+ return layout()->totalHeightForWidth(w);
+ return -1;
+}
+
+
+/*!
+ \internal
+
+ *virtual private*
+
+ This is a bit hackish, but ideally we would have created a virtual function
+ in the public API (however, too late...) so that subclasses could reimplement
+ their own function.
+ Instead we add a virtual function to QWidgetPrivate.
+ ### Qt5: move to public class and make virtual
+*/
+bool QWidgetPrivate::hasHeightForWidth() const
+{
+ return layout ? layout->hasHeightForWidth() : size_policy.hasHeightForWidth();
+}
+
+/*!
+ \fn QWidget *QWidget::childAt(int x, int y) const
+
+ Returns the visible child widget at the position (\a{x}, \a{y})
+ in the widget's coordinate system. If there is no visible child
+ widget at the specified position, the function returns 0.
+*/
+
+/*!
+ \overload
+
+ Returns the visible child widget at point \a p in the widget's own
+ coordinate system.
+*/
+
+QWidget *QWidget::childAt(const QPoint &p) const
+{
+ return d_func()->childAt_helper(p, false);
+}
+
+QWidget *QWidgetPrivate::childAt_helper(const QPoint &p, bool ignoreChildrenInDestructor) const
+{
+ if (children.isEmpty())
+ return 0;
+
+#ifdef Q_WS_MAC
+ Q_Q(const QWidget);
+ // Unified tool bars on the Mac require special handling since they live outside
+ // QMainWindow's geometry(). See commit: 35667fd45ada49269a5987c235fdedfc43e92bb8
+ bool includeFrame = q->isWindow() && qobject_cast<const QMainWindow *>(q)
+ && static_cast<const QMainWindow *>(q)->unifiedTitleAndToolBarOnMac();
+ if (includeFrame)
+ return childAtRecursiveHelper(p, ignoreChildrenInDestructor, includeFrame);
+#endif
+
+ if (!pointInsideRectAndMask(p))
+ return 0;
+ return childAtRecursiveHelper(p, ignoreChildrenInDestructor);
+}
+
+QWidget *QWidgetPrivate::childAtRecursiveHelper(const QPoint &p, bool ignoreChildrenInDestructor, bool includeFrame) const
+{
+#ifndef Q_WS_MAC
+ Q_UNUSED(includeFrame);
+#endif
+ for (int i = children.size() - 1; i >= 0; --i) {
+ QWidget *child = qobject_cast<QWidget *>(children.at(i));
+ if (!child || child->isWindow() || child->isHidden() || child->testAttribute(Qt::WA_TransparentForMouseEvents)
+ || (ignoreChildrenInDestructor && child->data->in_destructor)) {
+ continue;
+ }
+
+ // Map the point 'p' from parent coordinates to child coordinates.
+ QPoint childPoint = p;
+#ifdef Q_WS_MAC
+ // 'includeFrame' is true if the child's parent is a top-level QMainWindow with an unified tool bar.
+ // An unified tool bar on the Mac lives outside QMainWindow's geometry(), so a normal
+ // QWidget::mapFromParent won't do the trick.
+ if (includeFrame && qobject_cast<QToolBar *>(child))
+ childPoint = qt_mac_nativeMapFromParent(child, p);
+ else
+#endif
+ childPoint -= child->data->crect.topLeft();
+
+ // Check if the point hits the child.
+ if (!child->d_func()->pointInsideRectAndMask(childPoint))
+ continue;
+
+ // Do the same for the child's descendants.
+ if (QWidget *w = child->d_func()->childAtRecursiveHelper(childPoint, ignoreChildrenInDestructor))
+ return w;
+
+ // We have found our target; namely the child at position 'p'.
+ return child;
+ }
+ return 0;
+}
+
+void QWidgetPrivate::updateGeometry_helper(bool forceUpdate)
+{
+ Q_Q(QWidget);
+ if (widgetItem)
+ widgetItem->invalidateSizeCache();
+ QWidget *parent;
+ if (forceUpdate || !extra || extra->minw != extra->maxw || extra->minh != extra->maxh) {
+ if (!q->isWindow() && !q->isHidden() && (parent = q->parentWidget())) {
+ if (parent->d_func()->layout)
+ parent->d_func()->layout->invalidate();
+ else if (parent->isVisible())
+ QApplication::postEvent(parent, new QEvent(QEvent::LayoutRequest));
+ }
+ }
+}
+
+/*!
+ Notifies the layout system that this widget has changed and may
+ need to change geometry.
+
+ Call this function if the sizeHint() or sizePolicy() have changed.
+
+ For explicitly hidden widgets, updateGeometry() is a no-op. The
+ layout system will be notified as soon as the widget is shown.
+*/
+
+void QWidget::updateGeometry()
+{
+ Q_D(QWidget);
+ d->updateGeometry_helper(false);
+}
+
+/*! \property QWidget::windowFlags
+
+ Window flags are a combination of a type (e.g. Qt::Dialog) and
+ zero or more hints to the window system (e.g.
+ Qt::FramelessWindowHint).
+
+ If the widget had type Qt::Widget or Qt::SubWindow and becomes a
+ window (Qt::Window, Qt::Dialog, etc.), it is put at position (0,
+ 0) on the desktop. If the widget is a window and becomes a
+ Qt::Widget or Qt::SubWindow, it is put at position (0, 0)
+ relative to its parent widget.
+
+ \note This function calls setParent() when changing the flags for
+ a window, causing the widget to be hidden. You must call show() to make
+ the widget visible again..
+
+ \sa windowType(), {Window Flags Example}
+*/
+void QWidget::setWindowFlags(Qt::WindowFlags flags)
+{
+ if (data->window_flags == flags)
+ return;
+
+ Q_D(QWidget);
+
+ if ((data->window_flags | flags) & Qt::Window) {
+ // the old type was a window and/or the new type is a window
+ QPoint oldPos = pos();
+ bool visible = isVisible();
+ setParent(parentWidget(), flags);
+
+ // if both types are windows or neither of them are, we restore
+ // the old position
+ if (!((data->window_flags ^ flags) & Qt::Window)
+ && (visible || testAttribute(Qt::WA_Moved))) {
+ move(oldPos);
+ }
+ // for backward-compatibility we change Qt::WA_QuitOnClose attribute value only when the window was recreated.
+ d->adjustQuitOnCloseAttribute();
+ } else {
+ data->window_flags = flags;
+ }
+}
+
+/*!
+ Sets the window flags for the widget to \a flags,
+ \e without telling the window system.
+
+ \warning Do not call this function unless you really know what
+ you're doing.
+
+ \sa setWindowFlags()
+*/
+void QWidget::overrideWindowFlags(Qt::WindowFlags flags)
+{
+ data->window_flags = flags;
+}
+
+/*!
+ \fn Qt::WindowType QWidget::windowType() const
+
+ Returns the window type of this widget. This is identical to
+ windowFlags() & Qt::WindowType_Mask.
+
+ \sa windowFlags
+*/
+
+/*!
+ Sets the parent of the widget to \a parent, and resets the window
+ flags. The widget is moved to position (0, 0) in its new parent.
+
+ If the new parent widget is in a different window, the
+ reparented widget and its children are appended to the end of the
+ \l{setFocusPolicy()}{tab chain} of the new parent
+ widget, in the same internal order as before. If one of the moved
+ widgets had keyboard focus, setParent() calls clearFocus() for that
+ widget.
+
+ If the new parent widget is in the same window as the
+ old parent, setting the parent doesn't change the tab order or
+ keyboard focus.
+
+ If the "new" parent widget is the old parent widget, this function
+ does nothing.
+
+ \note The widget becomes invisible as part of changing its parent,
+ even if it was previously visible. You must call show() to make the
+ widget visible again.
+
+ \warning It is very unlikely that you will ever need this
+ function. If you have a widget that changes its content
+ dynamically, it is far easier to use \l QStackedWidget.
+
+ \sa setWindowFlags()
+*/
+void QWidget::setParent(QWidget *parent)
+{
+ if (parent == parentWidget())
+ return;
+ setParent((QWidget*)parent, windowFlags() & ~Qt::WindowType_Mask);
+}
+
+/*!
+ \overload
+
+ This function also takes widget flags, \a f as an argument.
+*/
+
+void QWidget::setParent(QWidget *parent, Qt::WindowFlags f)
+{
+ Q_D(QWidget);
+ bool resized = testAttribute(Qt::WA_Resized);
+ bool wasCreated = testAttribute(Qt::WA_WState_Created);
+ QWidget *oldtlw = window();
+
+ QWidget *desktopWidget = 0;
+ if (parent && parent->windowType() == Qt::Desktop)
+ desktopWidget = parent;
+ bool newParent = (parent != parentWidget()) || !wasCreated || desktopWidget;
+
+#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN)
+ if (newParent && parent && !desktopWidget) {
+ if (testAttribute(Qt::WA_NativeWindow) && !qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings)
+#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
+ // On Mac, toolbars inside the unified title bar will never overlap with
+ // siblings in the content view. So we skip enforce native siblings in that case
+ && !d->isInUnifiedToolbar && parentWidget() && parentWidget()->isWindow()
+#endif // Q_WS_MAC && QT_MAC_USE_COCOA
+ )
+ parent->d_func()->enforceNativeChildren();
+ else if (parent->d_func()->nativeChildrenForced() || parent->testAttribute(Qt::WA_PaintOnScreen))
+ setAttribute(Qt::WA_NativeWindow);
+ }
+#endif
+
+ if (wasCreated) {
+ if (!testAttribute(Qt::WA_WState_Hidden)) {
+ hide();
+ setAttribute(Qt::WA_WState_ExplicitShowHide, false);
+ }
+ if (newParent) {
+ QEvent e(QEvent::ParentAboutToChange);
+ QApplication::sendEvent(this, &e);
+ }
+ }
+ if (newParent && isAncestorOf(focusWidget()))
+ focusWidget()->clearFocus();
+
+ QTLWExtra *oldTopExtra = window()->d_func()->maybeTopData();
+ QWidgetBackingStoreTracker *oldBsTracker = oldTopExtra ? &oldTopExtra->backingStore : 0;
+
+ d->setParent_sys(parent, f);
+
+ QTLWExtra *topExtra = window()->d_func()->maybeTopData();
+ QWidgetBackingStoreTracker *bsTracker = topExtra ? &topExtra->backingStore : 0;
+ if (oldBsTracker && oldBsTracker != bsTracker)
+ oldBsTracker->unregisterWidgetSubtree(this);
+
+ if (desktopWidget)
+ parent = 0;
+
+#ifdef Q_BACKINGSTORE_SUBSURFACES
+ QTLWExtra *extra = d->maybeTopData();
+ QWindowSurface *windowSurface = (extra ? extra->windowSurface : 0);
+ if (newParent && windowSurface) {
+ QWidgetBackingStore *oldBs = oldtlw->d_func()->maybeBackingStore();
+ if (oldBs)
+ oldBs->subSurfaces.removeAll(windowSurface);
+
+ if (parent) {
+ QWidgetBackingStore *newBs = parent->d_func()->maybeBackingStore();
+ if (newBs)
+ newBs->subSurfaces.append(windowSurface);
+ }
+ }
+#endif
+
+ if (QWidgetBackingStore *oldBs = oldtlw->d_func()->maybeBackingStore()) {
+ if (newParent)
+ oldBs->removeDirtyWidget(this);
+ // Move the widget and all its static children from
+ // the old backing store to the new one.
+ oldBs->moveStaticWidgets(this);
+ }
+
+ if ((QApplicationPrivate::app_compile_version < 0x040200
+ || QApplicationPrivate::testAttribute(Qt::AA_ImmediateWidgetCreation))
+ && !testAttribute(Qt::WA_WState_Created))
+ create();
+
+ d->reparentFocusWidgets(oldtlw);
+ setAttribute(Qt::WA_Resized, resized);
+ if (!testAttribute(Qt::WA_StyleSheet)
+ && (!parent || !parent->testAttribute(Qt::WA_StyleSheet))) {
+ d->resolveFont();
+ d->resolvePalette();
+ }
+ d->resolveLayoutDirection();
+ d->resolveLocale();
+
+ // Note: GL widgets under WGL or EGL will always need a ParentChange
+ // event to handle recreation/rebinding of the GL context, hence the
+ // (f & Qt::MSWindowsOwnDC) clause (which is set on QGLWidgets on all
+ // platforms).
+ if (newParent
+#if defined(Q_WS_WIN) || defined(QT_OPENGL_ES)
+ || (f & Qt::MSWindowsOwnDC)
+#endif
+ ) {
+ // propagate enabled updates enabled state to non-windows
+ if (!isWindow()) {
+ if (!testAttribute(Qt::WA_ForceDisabled))
+ d->setEnabled_helper(parent ? parent->isEnabled() : true);
+ if (!testAttribute(Qt::WA_ForceUpdatesDisabled))
+ d->setUpdatesEnabled_helper(parent ? parent->updatesEnabled() : true);
+ }
+ d->inheritStyle();
+
+ // send and post remaining QObject events
+ if (parent && d->sendChildEvents) {
+ QChildEvent e(QEvent::ChildAdded, this);
+ QApplication::sendEvent(parent, &e);
+#ifdef QT3_SUPPORT
+ if (parent->d_func()->pendingChildInsertedEvents.isEmpty()) {
+ QApplication::postEvent(parent,
+ new QEvent(QEvent::ChildInsertedRequest),
+ Qt::HighEventPriority);
+ }
+ parent->d_func()->pendingChildInsertedEvents.append(this);
+#endif
+ }
+
+//### already hidden above ---> must probably do something smart on the mac
+// #ifdef Q_WS_MAC
+// extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp
+// if(!qt_mac_is_macdrawer(q)) //special case
+// q->setAttribute(Qt::WA_WState_Hidden);
+// #else
+// q->setAttribute(Qt::WA_WState_Hidden);
+//#endif
+
+ if (parent && d->sendChildEvents && d->polished) {
+ QChildEvent e(QEvent::ChildPolished, this);
+ QCoreApplication::sendEvent(parent, &e);
+ }
+
+ QEvent e(QEvent::ParentChange);
+ QApplication::sendEvent(this, &e);
+ }
+
+ if (!wasCreated) {
+ if (isWindow() || parentWidget()->isVisible())
+ setAttribute(Qt::WA_WState_Hidden, true);
+ else if (!testAttribute(Qt::WA_WState_ExplicitShowHide))
+ setAttribute(Qt::WA_WState_Hidden, false);
+ }
+
+ d->updateIsOpaque();
+
+#ifndef QT_NO_GRAPHICSVIEW
+ // Embed the widget into a proxy if the parent is embedded.
+ // ### Doesn't handle reparenting out of an embedded widget.
+ if (oldtlw->graphicsProxyWidget()) {
+ if (QGraphicsProxyWidget *ancestorProxy = d->nearestGraphicsProxyWidget(oldtlw))
+ ancestorProxy->d_func()->unembedSubWindow(this);
+ }
+ if (isWindow() && parent && !graphicsProxyWidget() && !bypassGraphicsProxyWidget(this)) {
+ if (QGraphicsProxyWidget *ancestorProxy = d->nearestGraphicsProxyWidget(parent))
+ ancestorProxy->d_func()->embedSubWindow(this);
+ }
+#endif
+}
+
+/*!
+ Scrolls the widget including its children \a dx pixels to the
+ right and \a dy downward. Both \a dx and \a dy may be negative.
+
+ After scrolling, the widgets will receive paint events for
+ the areas that need to be repainted. For widgets that Qt knows to
+ be opaque, this is only the newly exposed parts.
+ For example, if an opaque widget is scrolled 8 pixels to the left,
+ only an 8-pixel wide stripe at the right edge needs updating.
+
+ Since widgets propagate the contents of their parents by default,
+ you need to set the \l autoFillBackground property, or use
+ setAttribute() to set the Qt::WA_OpaquePaintEvent attribute, to make
+ a widget opaque.
+
+ For widgets that use contents propagation, a scroll will cause an
+ update of the entire scroll area.
+
+ \sa {Transparency and Double Buffering}
+*/
+
+void QWidget::scroll(int dx, int dy)
+{
+ if ((!updatesEnabled() && children().size() == 0) || !isVisible())
+ return;
+ if (dx == 0 && dy == 0)
+ return;
+ Q_D(QWidget);
+#ifndef QT_NO_GRAPHICSVIEW
+ if (QGraphicsProxyWidget *proxy = QWidgetPrivate::nearestGraphicsProxyWidget(this)) {
+ // Graphics View maintains its own dirty region as a list of rects;
+ // until we can connect item updates directly to the view, we must
+ // separately add a translated dirty region.
+ if (!d->dirty.isEmpty()) {
+ foreach (const QRect &rect, (d->dirty.translated(dx, dy)).rects())
+ proxy->update(rect);
+ }
+ proxy->scroll(dx, dy, proxy->subWidgetRect(this));
+ return;
+ }
+#endif
+ d->setDirtyOpaqueRegion();
+ d->scroll_sys(dx, dy);
+}
+
+/*!
+ \overload
+
+ This version only scrolls \a r and does not move the children of
+ the widget.
+
+ If \a r is empty or invalid, the result is undefined.
+
+ \sa QScrollArea
+*/
+void QWidget::scroll(int dx, int dy, const QRect &r)
+{
+
+ if ((!updatesEnabled() && children().size() == 0) || !isVisible())
+ return;
+ if (dx == 0 && dy == 0)
+ return;
+ Q_D(QWidget);
+#ifndef QT_NO_GRAPHICSVIEW
+ if (QGraphicsProxyWidget *proxy = QWidgetPrivate::nearestGraphicsProxyWidget(this)) {
+ // Graphics View maintains its own dirty region as a list of rects;
+ // until we can connect item updates directly to the view, we must
+ // separately add a translated dirty region.
+ if (!d->dirty.isEmpty()) {
+ foreach (const QRect &rect, (d->dirty.translated(dx, dy) & r).rects())
+ proxy->update(rect);
+ }
+ proxy->scroll(dx, dy, r.translated(proxy->subWidgetRect(this).topLeft().toPoint()));
+ return;
+ }
+#endif
+ d->scroll_sys(dx, dy, r);
+}
+
+/*!
+ Repaints the widget directly by calling paintEvent() immediately,
+ unless updates are disabled or the widget is hidden.
+
+ We suggest only using repaint() if you need an immediate repaint,
+ for example during animation. In almost all circumstances update()
+ is better, as it permits Qt to optimize for speed and minimize
+ flicker.
+
+ \warning If you call repaint() in a function which may itself be
+ called from paintEvent(), you may get infinite recursion. The
+ update() function never causes recursion.
+
+ \sa update(), paintEvent(), setUpdatesEnabled()
+*/
+
+void QWidget::repaint()
+{
+ repaint(rect());
+}
+
+/*! \overload
+
+ This version repaints a rectangle (\a x, \a y, \a w, \a h) inside
+ the widget.
+
+ If \a w is negative, it is replaced with \c{width() - x}, and if
+ \a h is negative, it is replaced width \c{height() - y}.
+*/
+void QWidget::repaint(int x, int y, int w, int h)
+{
+ if (x > data->crect.width() || y > data->crect.height())
+ return;
+
+ if (w < 0)
+ w = data->crect.width() - x;
+ if (h < 0)
+ h = data->crect.height() - y;
+
+ repaint(QRect(x, y, w, h));
+}
+
+/*! \overload
+
+ This version repaints a rectangle \a rect inside the widget.
+*/
+void QWidget::repaint(const QRect &rect)
+{
+ Q_D(QWidget);
+
+ if (testAttribute(Qt::WA_WState_ConfigPending)) {
+ update(rect);
+ return;
+ }
+
+ if (!isVisible() || !updatesEnabled() || rect.isEmpty())
+ return;
+
+ if (hasBackingStoreSupport()) {
+#ifdef QT_MAC_USE_COCOA
+ if (qt_widget_private(this)->isInUnifiedToolbar) {
+ qt_widget_private(this)->unifiedSurface->renderToolbar(this, true);
+ return;
+ }
+#endif // QT_MAC_USE_COCOA
+ QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
+ if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
+ tlwExtra->inRepaint = true;
+ tlwExtra->backingStore->markDirty(rect, this, true);
+ tlwExtra->inRepaint = false;
+ }
+ } else {
+ d->repaint_sys(rect);
+ }
+}
+
+/*!
+ \overload
+
+ This version repaints a region \a rgn inside the widget.
+*/
+void QWidget::repaint(const QRegion &rgn)
+{
+ Q_D(QWidget);
+
+ if (testAttribute(Qt::WA_WState_ConfigPending)) {
+ update(rgn);
+ return;
+ }
+
+ if (!isVisible() || !updatesEnabled() || rgn.isEmpty())
+ return;
+
+ if (hasBackingStoreSupport()) {
+#ifdef QT_MAC_USE_COCOA
+ if (qt_widget_private(this)->isInUnifiedToolbar) {
+ qt_widget_private(this)->unifiedSurface->renderToolbar(this, true);
+ return;
+ }
+#endif // QT_MAC_USE_COCOA
+ QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
+ if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) {
+ tlwExtra->inRepaint = true;
+ tlwExtra->backingStore->markDirty(rgn, this, true);
+ tlwExtra->inRepaint = false;
+ }
+ } else {
+ d->repaint_sys(rgn);
+ }
+}
+
+/*!
+ Updates the widget unless updates are disabled or the widget is
+ hidden.
+
+ This function does not cause an immediate repaint; instead it
+ schedules a paint event for processing when Qt returns to the main
+ event loop. This permits Qt to optimize for more speed and less
+ flicker than a call to repaint() does.
+
+ Calling update() several times normally results in just one
+ paintEvent() call.
+
+ Qt normally erases the widget's area before the paintEvent() call.
+ If the Qt::WA_OpaquePaintEvent widget attribute is set, the widget is
+ responsible for painting all its pixels with an opaque color.
+
+ \sa repaint() paintEvent(), setUpdatesEnabled(), {Analog Clock Example}
+*/
+void QWidget::update()
+{
+ update(rect());
+}
+
+/*! \fn void QWidget::update(int x, int y, int w, int h)
+ \overload
+
+ This version updates a rectangle (\a x, \a y, \a w, \a h) inside
+ the widget.
+*/
+
+/*!
+ \overload
+
+ This version updates a rectangle \a rect inside the widget.
+*/
+void QWidget::update(const QRect &rect)
+{
+ if (!isVisible() || !updatesEnabled() || rect.isEmpty())
+ return;
+
+ if (testAttribute(Qt::WA_WState_InPaintEvent)) {
+ QApplication::postEvent(this, new QUpdateLaterEvent(rect));
+ return;
+ }
+
+ if (hasBackingStoreSupport()) {
+#ifdef QT_MAC_USE_COCOA
+ if (qt_widget_private(this)->isInUnifiedToolbar) {
+ qt_widget_private(this)->unifiedSurface->renderToolbar(this, true);
+ return;
+ }
+#endif // QT_MAC_USE_COCOA
+ QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
+ if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore)
+ tlwExtra->backingStore->markDirty(rect, this);
+ } else {
+ d_func()->repaint_sys(rect);
+ }
+}
+
+/*!
+ \overload
+
+ This version repaints a region \a rgn inside the widget.
+*/
+void QWidget::update(const QRegion &rgn)
+{
+ if (!isVisible() || !updatesEnabled() || rgn.isEmpty())
+ return;
+
+ if (testAttribute(Qt::WA_WState_InPaintEvent)) {
+ QApplication::postEvent(this, new QUpdateLaterEvent(rgn));
+ return;
+ }
+
+ if (hasBackingStoreSupport()) {
+#ifdef QT_MAC_USE_COCOA
+ if (qt_widget_private(this)->isInUnifiedToolbar) {
+ qt_widget_private(this)->unifiedSurface->renderToolbar(this, true);
+ return;
+ }
+#endif // QT_MAC_USE_COCOA
+ QTLWExtra *tlwExtra = window()->d_func()->maybeTopData();
+ if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore)
+ tlwExtra->backingStore->markDirty(rgn, this);
+ } else {
+ d_func()->repaint_sys(rgn);
+ }
+}
+
+#ifdef QT3_SUPPORT
+/*!
+ Clear the rectangle at point (\a x, \a y) of width \a w and height
+ \a h.
+
+ \warning This is best done in a paintEvent().
+*/
+void QWidget::erase_helper(int x, int y, int w, int h)
+{
+ if (testAttribute(Qt::WA_NoSystemBackground) || testAttribute(Qt::WA_UpdatesDisabled) || !testAttribute(Qt::WA_WState_Visible))
+ return;
+ if (w < 0)
+ w = data->crect.width() - x;
+ if (h < 0)
+ h = data->crect.height() - y;
+ if (w != 0 && h != 0) {
+ QPainter p(this);
+ p.eraseRect(QRect(x, y, w, h));
+ }
+}
+
+/*!
+ \overload
+
+ Clear the given region, \a rgn.
+
+ Drawing may only take place in a QPaintEvent. Overload
+ paintEvent() to do your erasing and call update() to schedule a
+ replaint whenever necessary. See also QPainter.
+*/
+void QWidget::erase(const QRegion& rgn)
+{
+ if (testAttribute(Qt::WA_NoSystemBackground) || testAttribute(Qt::WA_UpdatesDisabled) || !testAttribute(Qt::WA_WState_Visible))
+ return;
+
+ QPainter p(this);
+ p.setClipRegion(rgn);
+ p.eraseRect(rgn.boundingRect());
+}
+
+void QWidget::drawText_helper(int x, int y, const QString &str)
+{
+ if(!testAttribute(Qt::WA_WState_Visible))
+ return;
+ QPainter paint(this);
+ paint.drawText(x, y, str);
+}
+
+
+/*!
+ Closes the widget.
+
+ Use the no-argument overload instead.
+*/
+bool QWidget::close(bool alsoDelete)
+{
+ QPointer<QWidget> that = this;
+ bool accepted = close();
+ if (alsoDelete && accepted && that)
+ deleteLater();
+ return accepted;
+}
+
+void QWidget::setIcon(const QPixmap &i)
+{
+ setWindowIcon(i);
+}
+
+/*!
+ Return's the widget's icon.
+
+ Use windowIcon() instead.
+*/
+const QPixmap *QWidget::icon() const
+{
+ Q_D(const QWidget);
+ return (d->extra && d->extra->topextra) ? d->extra->topextra->iconPixmap : 0;
+}
+
+#endif // QT3_SUPPORT
+
+ /*!
+ \internal
+
+ This just sets the corresponding attribute bit to 1 or 0
+ */
+static void setAttribute_internal(Qt::WidgetAttribute attribute, bool on, QWidgetData *data,
+ QWidgetPrivate *d)
+{
+ if (attribute < int(8*sizeof(uint))) {
+ if (on)
+ data->widget_attributes |= (1<<attribute);
+ else
+ data->widget_attributes &= ~(1<<attribute);
+ } else {
+ const int x = attribute - 8*sizeof(uint);
+ const int int_off = x / (8*sizeof(uint));
+ if (on)
+ d->high_attributes[int_off] |= (1<<(x-(int_off*8*sizeof(uint))));
+ else
+ d->high_attributes[int_off] &= ~(1<<(x-(int_off*8*sizeof(uint))));
+ }
+}
+
+/*!
+ Sets the attribute \a attribute on this widget if \a on is true;
+ otherwise clears the attribute.
+
+ \sa testAttribute()
+*/
+void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on)
+{
+ if (testAttribute(attribute) == on)
+ return;
+
+ Q_D(QWidget);
+ Q_ASSERT_X(sizeof(d->high_attributes)*8 >= (Qt::WA_AttributeCount - sizeof(uint)*8),
+ "QWidget::setAttribute(WidgetAttribute, bool)",
+ "QWidgetPrivate::high_attributes[] too small to contain all attributes in WidgetAttribute");
+#ifdef Q_WS_WIN
+ // ### Don't use PaintOnScreen+paintEngine() to do native painting in 5.0
+ if (attribute == Qt::WA_PaintOnScreen && on && !inherits("QGLWidget")) {
+ // see qwidget_win.cpp, ::paintEngine for details
+ paintEngine();
+ if (d->noPaintOnScreen)
+ return;
+ }
+#endif
+
+ setAttribute_internal(attribute, on, data, d);
+
+ switch (attribute) {
+
+#ifndef QT_NO_DRAGANDDROP
+ case Qt::WA_AcceptDrops: {
+ if (on && !testAttribute(Qt::WA_DropSiteRegistered))
+ setAttribute(Qt::WA_DropSiteRegistered, true);
+ else if (!on && (isWindow() || !parentWidget() || !parentWidget()->testAttribute(Qt::WA_DropSiteRegistered)))
+ setAttribute(Qt::WA_DropSiteRegistered, false);
+ QEvent e(QEvent::AcceptDropsChange);
+ QApplication::sendEvent(this, &e);
+ break;
+ }
+ case Qt::WA_DropSiteRegistered: {
+ d->registerDropSite(on);
+ for (int i = 0; i < d->children.size(); ++i) {
+ QWidget *w = qobject_cast<QWidget *>(d->children.at(i));
+ if (w && !w->isWindow() && !w->testAttribute(Qt::WA_AcceptDrops) && w->testAttribute(Qt::WA_DropSiteRegistered) != on)
+ w->setAttribute(Qt::WA_DropSiteRegistered, on);
+ }
+ break;
+ }
+#endif
+
+ case Qt::WA_NoChildEventsForParent:
+ d->sendChildEvents = !on;
+ break;
+ case Qt::WA_NoChildEventsFromChildren:
+ d->receiveChildEvents = !on;
+ break;
+ case Qt::WA_MacBrushedMetal:
+#ifdef Q_WS_MAC
+ d->setStyle_helper(style(), false, true); // Make sure things get unpolished/polished correctly.
+ // fall through since changing the metal attribute affects the opaque size grip.
+ case Qt::WA_MacOpaqueSizeGrip:
+ d->macUpdateOpaqueSizeGrip();
+ break;
+ case Qt::WA_MacShowFocusRect:
+ if (hasFocus()) {
+ clearFocus();
+ setFocus();
+ }
+ break;
+ case Qt::WA_Hover:
+ qt_mac_update_mouseTracking(this);
+ break;
+#endif
+ case Qt::WA_MacAlwaysShowToolWindow:
+#ifdef Q_WS_MAC
+ d->macUpdateHideOnSuspend();
+#endif
+ break;
+ case Qt::WA_MacNormalSize:
+ case Qt::WA_MacSmallSize:
+ case Qt::WA_MacMiniSize:
+#ifdef Q_WS_MAC
+ {
+ // We can only have one of these set at a time
+ const Qt::WidgetAttribute MacSizes[] = { Qt::WA_MacNormalSize, Qt::WA_MacSmallSize,
+ Qt::WA_MacMiniSize };
+ for (int i = 0; i < 3; ++i) {
+ if (MacSizes[i] != attribute)
+ setAttribute_internal(MacSizes[i], false, data, d);
+ }
+ d->macUpdateSizeAttribute();
+ }
+#endif
+ break;
+ case Qt::WA_ShowModal:
+ if (!on) {
+ if (isVisible())
+ QApplicationPrivate::leaveModal(this);
+ // reset modality type to Modeless when clearing WA_ShowModal
+ data->window_modality = Qt::NonModal;
+ } else if (data->window_modality == Qt::NonModal) {
+ // determine the modality type if it hasn't been set prior
+ // to setting WA_ShowModal. set the default to WindowModal
+ // if we are the child of a group leader; otherwise use
+ // ApplicationModal.
+ QWidget *w = parentWidget();
+ if (w)
+ w = w->window();
+ while (w && !w->testAttribute(Qt::WA_GroupLeader)) {
+ w = w->parentWidget();
+ if (w)
+ w = w->window();
+ }
+ data->window_modality = (w && w->testAttribute(Qt::WA_GroupLeader))
+ ? Qt::WindowModal
+ : Qt::ApplicationModal;
+ // Some window managers does not allow us to enter modal after the
+ // window is showing. Therefore, to be consistent, we cannot call
+ // QApplicationPrivate::enterModal(this) here. The window must be
+ // hidden before changing modality.
+ }
+ if (testAttribute(Qt::WA_WState_Created)) {
+ // don't call setModal_sys() before create_sys()
+ d->setModal_sys();
+ }
+ break;
+ case Qt::WA_MouseTracking: {
+ QEvent e(QEvent::MouseTrackingChange);
+ QApplication::sendEvent(this, &e);
+ break; }
+ case Qt::WA_NativeWindow: {
+#if defined(Q_WS_QPA)
+ d->createTLExtra();
+#endif
+#ifndef QT_NO_IM
+ QWidget *focusWidget = d->effectiveFocusWidget();
+ QInputContext *ic = 0;
+ if (on && !internalWinId() && hasFocus()
+ && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
+ ic = focusWidget->d_func()->inputContext();
+ if (ic) {
+ ic->reset();
+ ic->setFocusWidget(0);
+ }
+ }
+ if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget()
+#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)
+ // On Mac, toolbars inside the unified title bar will never overlap with
+ // siblings in the content view. So we skip enforce native siblings in that case
+ && !d->isInUnifiedToolbar && parentWidget()->isWindow()
+#endif // Q_WS_MAC && QT_MAC_USE_COCOA
+ )
+ parentWidget()->d_func()->enforceNativeChildren();
+ if (on && !internalWinId() && testAttribute(Qt::WA_WState_Created))
+ d->createWinId();
+ if (ic && isEnabled() && focusWidget->isEnabled()
+ && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
+ ic->setFocusWidget(focusWidget);
+ }
+#endif //QT_NO_IM
+ break;
+ }
+ case Qt::WA_PaintOnScreen:
+ d->updateIsOpaque();
+#if defined(Q_WS_WIN) || defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN)
+ // Recreate the widget if it's already created as an alien widget and
+ // WA_PaintOnScreen is enabled. Paint on screen widgets must have win id.
+ // So must their children.
+ if (on) {
+ setAttribute(Qt::WA_NativeWindow);
+ d->enforceNativeChildren();
+ }
+#endif
+ // fall through
+ case Qt::WA_OpaquePaintEvent:
+ d->updateIsOpaque();
+ break;
+ case Qt::WA_NoSystemBackground:
+ d->updateIsOpaque();
+ // fall through...
+ case Qt::WA_UpdatesDisabled:
+ d->updateSystemBackground();
+ break;
+ case Qt::WA_TransparentForMouseEvents:
+#ifdef Q_WS_MAC
+ d->macUpdateIgnoreMouseEvents();
+#endif
+ break;
+ case Qt::WA_InputMethodEnabled: {
+#ifndef QT_NO_IM
+ QWidget *focusWidget = d->effectiveFocusWidget();
+ QInputContext *ic = focusWidget->d_func()->assignedInputContext();
+ if (!ic && (!on || hasFocus()))
+ ic = focusWidget->d_func()->inputContext();
+ if (ic) {
+ if (on && hasFocus() && ic->focusWidget() != focusWidget && isEnabled()
+ && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) {
+ ic->setFocusWidget(focusWidget);
+ } else if (!on && ic->focusWidget() == focusWidget) {
+ ic->reset();
+ ic->setFocusWidget(0);
+ }
+ }
+#endif //QT_NO_IM
+ break;
+ }
+ case Qt::WA_WindowPropagation:
+ d->resolvePalette();
+ d->resolveFont();
+ d->resolveLocale();
+ break;
+#ifdef Q_WS_X11
+ case Qt::WA_NoX11EventCompression:
+ if (!d->extra)
+ d->createExtra();
+ d->extra->compress_events = on;
+ break;
+ case Qt::WA_X11OpenGLOverlay:
+ d->updateIsOpaque();
+ break;
+ case Qt::WA_X11DoNotAcceptFocus:
+ if (testAttribute(Qt::WA_WState_Created))
+ d->updateX11AcceptFocus();
+ break;
+#endif
+ case Qt::WA_DontShowOnScreen: {
+ if (on && isVisible()) {
+ // Make sure we keep the current state and only hide the widget
+ // from the desktop. show_sys will only update platform specific
+ // attributes at this point.
+ d->hide_sys();
+#ifdef Q_WS_QWS
+ // Release the region for this window from qws if the widget has
+ // been shown before the attribute was set.
+ if (QWSWindowSurface *surface = static_cast<QWSWindowSurface *>(windowSurface())) {
+ QWidget::qwsDisplay()->requestRegion(surface->winId(), surface->key(),
+ surface->permanentState(), QRegion());
+ }
+#endif
+ d->show_sys();
+ }
+ break;
+ }
+
+#ifdef Q_WS_X11
+ case Qt::WA_X11NetWmWindowTypeDesktop:
+ case Qt::WA_X11NetWmWindowTypeDock:
+ case Qt::WA_X11NetWmWindowTypeToolBar:
+ case Qt::WA_X11NetWmWindowTypeMenu:
+ case Qt::WA_X11NetWmWindowTypeUtility:
+ case Qt::WA_X11NetWmWindowTypeSplash:
+ case Qt::WA_X11NetWmWindowTypeDialog:
+ case Qt::WA_X11NetWmWindowTypeDropDownMenu:
+ case Qt::WA_X11NetWmWindowTypePopupMenu:
+ case Qt::WA_X11NetWmWindowTypeToolTip:
+ case Qt::WA_X11NetWmWindowTypeNotification:
+ case Qt::WA_X11NetWmWindowTypeCombo:
+ case Qt::WA_X11NetWmWindowTypeDND:
+ if (testAttribute(Qt::WA_WState_Created))
+ d->setNetWmWindowTypes();
+ break;
+#endif
+
+ case Qt::WA_StaticContents:
+ if (QWidgetBackingStore *bs = d->maybeBackingStore()) {
+ if (on)
+ bs->addStaticWidget(this);
+ else
+ bs->removeStaticWidget(this);
+ }
+ break;
+ case Qt::WA_TranslucentBackground:
+ if (on) {
+ setAttribute(Qt::WA_NoSystemBackground);
+ d->updateIsTranslucent();
+ }
+
+ break;
+ case Qt::WA_AcceptTouchEvents:
+#if defined(Q_WS_WIN) || defined(Q_WS_MAC) || defined(Q_OS_SYMBIAN)
+ if (on)
+ d->registerTouchWindow();
+#endif
+ break;
+ case Qt::WA_LockPortraitOrientation:
+ case Qt::WA_LockLandscapeOrientation:
+ case Qt::WA_AutoOrientation: {
+ const Qt::WidgetAttribute orientations[3] = {
+ Qt::WA_LockPortraitOrientation,
+ Qt::WA_LockLandscapeOrientation,
+ Qt::WA_AutoOrientation
+ };
+
+ if (on) {
+ // We can only have one of these set at a time
+ for (int i = 0; i < 3; ++i) {
+ if (orientations[i] != attribute)
+ setAttribute_internal(orientations[i], false, data, d);
+ }
+ }
+
+#ifdef Q_WS_S60
+ CAknAppUiBase* appUi = static_cast<CAknAppUiBase*>(CEikonEnv::Static()->EikAppUi());
+ const CAknAppUiBase::TAppUiOrientation s60orientations[] = {
+ CAknAppUiBase::EAppUiOrientationPortrait,
+ CAknAppUiBase::EAppUiOrientationLandscape,
+ CAknAppUiBase::EAppUiOrientationAutomatic
+ };
+ CAknAppUiBase::TAppUiOrientation s60orientation = CAknAppUiBase::EAppUiOrientationUnspecified;
+ for (int i = 0; i < 3; ++i) {
+ if (testAttribute(orientations[i])) {
+ s60orientation = s60orientations[i];
+ break;
+ }
+ }
+ QT_TRAP_THROWING(appUi->SetOrientationL(s60orientation));
+ S60->orientationSet = true;
+ QSymbianControl *window = static_cast<QSymbianControl *>(internalWinId());
+ if (window)
+ window->ensureFixNativeOrientation();
+#endif
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+/*! \fn bool QWidget::testAttribute(Qt::WidgetAttribute attribute) const
+
+ Returns true if attribute \a attribute is set on this widget;
+ otherwise returns false.
+
+ \sa setAttribute()
+ */
+bool QWidget::testAttribute_helper(Qt::WidgetAttribute attribute) const
+{
+ Q_D(const QWidget);
+ const int x = attribute - 8*sizeof(uint);
+ const int int_off = x / (8*sizeof(uint));
+ return (d->high_attributes[int_off] & (1<<(x-(int_off*8*sizeof(uint)))));
+}
+
+/*!
+ \property QWidget::windowOpacity
+
+ \brief The level of opacity for the window.
+
+ The valid range of opacity is from 1.0 (completely opaque) to
+ 0.0 (completely transparent).
+
+ By default the value of this property is 1.0.
+
+ This feature is available on Embedded Linux, Mac OS X, Windows,
+ and X11 platforms that support the Composite extension.
+
+ This feature is not available on Windows CE.
+
+ Note that under X11 you need to have a composite manager running,
+ and the X11 specific _NET_WM_WINDOW_OPACITY atom needs to be
+ supported by the window manager you are using.
+
+ \warning Changing this property from opaque to transparent might issue a
+ paint event that needs to be processed before the window is displayed
+ correctly. This affects mainly the use of QPixmap::grabWindow(). Also note
+ that semi-transparent windows update and resize significantly slower than
+ opaque windows.
+
+ \sa setMask()
+*/
+qreal QWidget::windowOpacity() const
+{
+ Q_D(const QWidget);
+ return (isWindow() && d->maybeTopData()) ? d->maybeTopData()->opacity / 255. : 1.0;
+}
+
+void QWidget::setWindowOpacity(qreal opacity)
+{
+ Q_D(QWidget);
+ if (!isWindow())
+ return;
+
+ opacity = qBound(qreal(0.0), opacity, qreal(1.0));
+ QTLWExtra *extra = d->topData();
+ extra->opacity = uint(opacity * 255);
+ setAttribute(Qt::WA_WState_WindowOpacitySet);
+
+#ifndef Q_WS_QWS
+ if (!testAttribute(Qt::WA_WState_Created))
+ return;
+#endif
+
+#ifndef QT_NO_GRAPHICSVIEW
+ if (QGraphicsProxyWidget *proxy = graphicsProxyWidget()) {
+ // Avoid invalidating the cache if set.
+ if (proxy->cacheMode() == QGraphicsItem::NoCache)
+ proxy->update();
+ else if (QGraphicsScene *scene = proxy->scene())
+ scene->update(proxy->sceneBoundingRect());
+ return;
+ }
+#endif
+
+ d->setWindowOpacity_sys(opacity);
+}
+
+/*!
+ \property QWidget::windowModified
+ \brief whether the document shown in the window has unsaved changes
+
+ A modified window is a window whose content has changed but has
+ not been saved to disk. This flag will have different effects
+ varied by the platform. On Mac OS X the close button will have a
+ modified look; on other platforms, the window title will have an
+ '*' (asterisk).
+
+ The window title must contain a "[*]" placeholder, which
+ indicates where the '*' should appear. Normally, it should appear
+ right after the file name (e.g., "document1.txt[*] - Text
+ Editor"). If the window isn't modified, the placeholder is simply
+ removed.
+
+ Note that if a widget is set as modified, all its ancestors will
+ also be set as modified. However, if you call \c
+ {setWindowModified(false)} on a widget, this will not propagate to
+ its parent because other children of the parent might have been
+ modified.
+
+ \sa windowTitle, {Application Example}, {SDI Example}, {MDI Example}
+*/
+bool QWidget::isWindowModified() const
+{
+ return testAttribute(Qt::WA_WindowModified);
+}
+
+void QWidget::setWindowModified(bool mod)
+{
+ Q_D(QWidget);
+ setAttribute(Qt::WA_WindowModified, mod);
+
+#ifndef Q_WS_MAC
+ if (!windowTitle().contains(QLatin1String("[*]")) && mod)
+ qWarning("QWidget::setWindowModified: The window title does not contain a '[*]' placeholder");
+#endif
+ d->setWindowTitle_helper(windowTitle());
+ d->setWindowIconText_helper(windowIconText());
+#ifdef Q_WS_MAC
+ d->setWindowModified_sys(mod);
+#endif
+
+ QEvent e(QEvent::ModifiedChange);
+ QApplication::sendEvent(this, &e);
+}
+
+#ifndef QT_NO_TOOLTIP
+/*!
+ \property QWidget::toolTip
+
+ \brief the widget's tooltip
+
+ Note that by default tooltips are only shown for widgets that are
+ children of the active window. You can change this behavior by
+ setting the attribute Qt::WA_AlwaysShowToolTips on the \e window,
+ not on the widget with the tooltip.
+
+ If you want to control a tooltip's behavior, you can intercept the
+ event() function and catch the QEvent::ToolTip event (e.g., if you
+ want to customize the area for which the tooltip should be shown).
+
+ By default, this property contains an empty string.
+
+ \sa QToolTip statusTip whatsThis
+*/
+void QWidget::setToolTip(const QString &s)
+{
+ Q_D(QWidget);
+ d->toolTip = s;
+
+ QEvent event(QEvent::ToolTipChange);
+ QApplication::sendEvent(this, &event);
+}
+
+QString QWidget::toolTip() const
+{
+ Q_D(const QWidget);
+ return d->toolTip;
+}
+#endif // QT_NO_TOOLTIP
+
+
+#ifndef QT_NO_STATUSTIP
+/*!
+ \property QWidget::statusTip
+ \brief the widget's status tip
+
+ By default, this property contains an empty string.
+
+ \sa toolTip whatsThis
+*/
+void QWidget::setStatusTip(const QString &s)
+{
+ Q_D(QWidget);
+ d->statusTip = s;
+}
+
+QString QWidget::statusTip() const
+{
+ Q_D(const QWidget);
+ return d->statusTip;
+}
+#endif // QT_NO_STATUSTIP
+
+#ifndef QT_NO_WHATSTHIS
+/*!
+ \property QWidget::whatsThis
+
+ \brief the widget's What's This help text.
+
+ By default, this property contains an empty string.
+
+ \sa QWhatsThis QWidget::toolTip QWidget::statusTip
+*/
+void QWidget::setWhatsThis(const QString &s)
+{
+ Q_D(QWidget);
+ d->whatsThis = s;
+}
+
+QString QWidget::whatsThis() const
+{
+ Q_D(const QWidget);
+ return d->whatsThis;
+}
+#endif // QT_NO_WHATSTHIS
+
+#ifndef QT_NO_ACCESSIBILITY
+/*!
+ \property QWidget::accessibleName
+
+ \brief the widget's name as seen by assistive technologies
+
+ This property is used by accessible clients to identify, find, or announce
+ the widget for accessible clients.
+
+ By default, this property contains an empty string.
+
+ \sa QAccessibleInterface::text()
+*/
+void QWidget::setAccessibleName(const QString &name)
+{
+ Q_D(QWidget);
+ d->accessibleName = name;
+ QAccessible::updateAccessibility(this, 0, QAccessible::NameChanged);
+}
+
+QString QWidget::accessibleName() const
+{
+ Q_D(const QWidget);
+ return d->accessibleName;
+}
+
+/*!
+ \property QWidget::accessibleDescription
+
+ \brief the widget's description as seen by assistive technologies
+
+ By default, this property contains an empty string.
+
+ \sa QAccessibleInterface::text()
+*/
+void QWidget::setAccessibleDescription(const QString &description)
+{
+ Q_D(QWidget);
+ d->accessibleDescription = description;
+ QAccessible::updateAccessibility(this, 0, QAccessible::DescriptionChanged);
+}
+
+QString QWidget::accessibleDescription() const
+{
+ Q_D(const QWidget);
+ return d->accessibleDescription;
+}
+#endif // QT_NO_ACCESSIBILITY
+
+#ifndef QT_NO_SHORTCUT
+/*!
+ Adds a shortcut to Qt's shortcut system that watches for the given
+ \a key sequence in the given \a context. If the \a context is
+ Qt::ApplicationShortcut, the shortcut applies to the application as a
+ whole. Otherwise, it is either local to this widget, Qt::WidgetShortcut,
+ or to the window itself, Qt::WindowShortcut.
+
+ If the same \a key sequence has been grabbed by several widgets,
+ when the \a key sequence occurs a QEvent::Shortcut event is sent
+ to all the widgets to which it applies in a non-deterministic
+ order, but with the ``ambiguous'' flag set to true.
+
+ \warning You should not normally need to use this function;
+ instead create \l{QAction}s with the shortcut key sequences you
+ require (if you also want equivalent menu options and toolbar
+ buttons), or create \l{QShortcut}s if you just need key sequences.
+ Both QAction and QShortcut handle all the event filtering for you,
+ and provide signals which are triggered when the user triggers the
+ key sequence, so are much easier to use than this low-level
+ function.
+
+ \sa releaseShortcut() setShortcutEnabled()
+*/
+int QWidget::grabShortcut(const QKeySequence &key, Qt::ShortcutContext context)
+{
+ Q_ASSERT(qApp);
+ if (key.isEmpty())
+ return 0;
+ setAttribute(Qt::WA_GrabbedShortcut);
+ return qApp->d_func()->shortcutMap.addShortcut(this, key, context);
+}
+
+/*!
+ Removes the shortcut with the given \a id from Qt's shortcut
+ system. The widget will no longer receive QEvent::Shortcut events
+ for the shortcut's key sequence (unless it has other shortcuts
+ with the same key sequence).
+
+ \warning You should not normally need to use this function since
+ Qt's shortcut system removes shortcuts automatically when their
+ parent widget is destroyed. It is best to use QAction or
+ QShortcut to handle shortcuts, since they are easier to use than
+ this low-level function. Note also that this is an expensive
+ operation.
+
+ \sa grabShortcut() setShortcutEnabled()
+*/
+void QWidget::releaseShortcut(int id)
+{
+ Q_ASSERT(qApp);
+ if (id)
+ qApp->d_func()->shortcutMap.removeShortcut(id, this, 0);
+}
+
+/*!
+ If \a enable is true, the shortcut with the given \a id is
+ enabled; otherwise the shortcut is disabled.
+
+ \warning You should not normally need to use this function since
+ Qt's shortcut system enables/disables shortcuts automatically as
+ widgets become hidden/visible and gain or lose focus. It is best
+ to use QAction or QShortcut to handle shortcuts, since they are
+ easier to use than this low-level function.
+
+ \sa grabShortcut() releaseShortcut()
+*/
+void QWidget::setShortcutEnabled(int id, bool enable)
+{
+ Q_ASSERT(qApp);
+ if (id)
+ qApp->d_func()->shortcutMap.setShortcutEnabled(enable, id, this, 0);
+}
+
+/*!
+ \since 4.2
+
+ If \a enable is true, auto repeat of the shortcut with the
+ given \a id is enabled; otherwise it is disabled.
+
+ \sa grabShortcut() releaseShortcut()
+*/
+void QWidget::setShortcutAutoRepeat(int id, bool enable)
+{
+ Q_ASSERT(qApp);
+ if (id)
+ qApp->d_func()->shortcutMap.setShortcutAutoRepeat(enable, id, this, 0);
+}
+#endif // QT_NO_SHORTCUT
+/*!
+ Updates the widget's micro focus.
+
+ \sa QInputContext
+*/
+void QWidget::updateMicroFocus()
+{
+#if !defined(QT_NO_IM) && (defined(Q_WS_X11) || defined(Q_WS_QWS) || defined(Q_OS_SYMBIAN))
+ Q_D(QWidget);
+ // and optimization to update input context only it has already been created.
+ if (d->assignedInputContext() || qApp->d_func()->inputContext) {
+ QInputContext *ic = inputContext();
+ if (ic)
+ ic->update();
+ }
+#endif
+#ifndef QT_NO_ACCESSIBILITY
+ if (isVisible()) {
+ // ##### is this correct
+ QAccessible::updateAccessibility(this, 0, QAccessible::StateChanged);
+ }
+#endif
+}
+
+
+#if defined (Q_WS_WIN)
+/*!
+ Returns the window system handle of the widget, for low-level
+ access. Using this function is not portable.
+
+ An HDC acquired with getDC() has to be released with releaseDC().
+
+ \warning Using this function is not portable.
+*/
+HDC QWidget::getDC() const
+{
+ Q_D(const QWidget);
+ if (d->hd)
+ return (HDC) d->hd;
+ return GetDC(winId());
+}
+
+/*!
+ Releases the HDC \a hdc acquired by a previous call to getDC().
+
+ \warning Using this function is not portable.
+*/
+void QWidget::releaseDC(HDC hdc) const
+{
+ Q_D(const QWidget);
+ // If its the widgets own dc, it will be released elsewhere. If
+ // its a different HDC we release it and issue a warning if it
+ // fails.
+ if (hdc != d->hd && !ReleaseDC(winId(), hdc))
+ qErrnoWarning("QWidget::releaseDC(): failed to release HDC");
+}
+#else
+/*!
+ Returns the window system handle of the widget, for low-level
+ access. Using this function is not portable.
+
+ The HANDLE type varies with platform; see \c qwindowdefs.h for
+ details.
+*/
+Qt::HANDLE QWidget::handle() const
+{
+ Q_D(const QWidget);
+ if (!internalWinId() && testAttribute(Qt::WA_WState_Created))
+ (void)winId(); // enforce native window
+ return d->hd;
+}
+#endif
+
+
+/*!
+ Raises this widget to the top of the parent widget's stack.
+
+ After this call the widget will be visually in front of any
+ overlapping sibling widgets.
+
+ \note When using activateWindow(), you can call this function to
+ ensure that the window is stacked on top.
+
+ \sa lower(), stackUnder()
+*/
+
+void QWidget::raise()
+{
+ Q_D(QWidget);
+ if (!isWindow()) {
+ QWidget *p = parentWidget();
+ const int parentChildCount = p->d_func()->children.size();
+ if (parentChildCount < 2)
+ return;
+ const int from = p->d_func()->children.indexOf(this);
+ Q_ASSERT(from >= 0);
+ // Do nothing if the widget is already in correct stacking order _and_ created.
+ if (from != parentChildCount -1)
+ p->d_func()->children.move(from, parentChildCount - 1);
+ if (!testAttribute(Qt::WA_WState_Created) && p->testAttribute(Qt::WA_WState_Created))
+ create();
+ else if (from == parentChildCount - 1)
+ return;
+
+ QRegion region(rect());
+ d->subtractOpaqueSiblings(region);
+ d->invalidateBuffer(region);
+ }
+ if (testAttribute(Qt::WA_WState_Created))
+ d->raise_sys();
+
+ QEvent e(QEvent::ZOrderChange);
+ QApplication::sendEvent(this, &e);
+}
+
+/*!
+ Lowers the widget to the bottom of the parent widget's stack.
+
+ After this call the widget will be visually behind (and therefore
+ obscured by) any overlapping sibling widgets.
+
+ \sa raise(), stackUnder()
+*/
+
+void QWidget::lower()
+{
+ Q_D(QWidget);
+ if (!isWindow()) {
+ QWidget *p = parentWidget();
+ const int parentChildCount = p->d_func()->children.size();
+ if (parentChildCount < 2)
+ return;
+ const int from = p->d_func()->children.indexOf(this);
+ Q_ASSERT(from >= 0);
+ // Do nothing if the widget is already in correct stacking order _and_ created.
+ if (from != 0)
+ p->d_func()->children.move(from, 0);
+ if (!testAttribute(Qt::WA_WState_Created) && p->testAttribute(Qt::WA_WState_Created))
+ create();
+ else if (from == 0)
+ return;
+ }
+ if (testAttribute(Qt::WA_WState_Created))
+ d->lower_sys();
+
+ QEvent e(QEvent::ZOrderChange);
+ QApplication::sendEvent(this, &e);
+}
+
+
+/*!
+ Places the widget under \a w in the parent widget's stack.
+
+ To make this work, the widget itself and \a w must be siblings.
+
+ \sa raise(), lower()
+*/
+void QWidget::stackUnder(QWidget* w)
+{
+ Q_D(QWidget);
+ QWidget *p = parentWidget();
+ if (!w || isWindow() || p != w->parentWidget() || this == w)
+ return;
+ if (p) {
+ int from = p->d_func()->children.indexOf(this);
+ int to = p->d_func()->children.indexOf(w);
+ Q_ASSERT(from >= 0);
+ Q_ASSERT(to >= 0);
+ if (from < to)
+ --to;
+ // Do nothing if the widget is already in correct stacking order _and_ created.
+ if (from != to)
+ p->d_func()->children.move(from, to);
+ if (!testAttribute(Qt::WA_WState_Created) && p->testAttribute(Qt::WA_WState_Created))
+ create();
+ else if (from == to)
+ return;
+ }
+ if (testAttribute(Qt::WA_WState_Created))
+ d->stackUnder_sys(w);
+
+ QEvent e(QEvent::ZOrderChange);
+ QApplication::sendEvent(this, &e);
+}
+
+void QWidget::styleChange(QStyle&) { }
+void QWidget::enabledChange(bool) { } // compat
+void QWidget::paletteChange(const QPalette &) { } // compat
+void QWidget::fontChange(const QFont &) { } // compat
+void QWidget::windowActivationChange(bool) { } // compat
+void QWidget::languageChange() { } // compat
+
+
+/*!
+ \enum QWidget::BackgroundOrigin
+
+ \compat
+
+ \value WidgetOrigin
+ \value ParentOrigin
+ \value WindowOrigin
+ \value AncestorOrigin
+
+*/
+
+/*!
+ \fn bool QWidget::isVisibleToTLW() const
+
+ Use isVisible() instead.
+*/
+
+/*!
+ \fn void QWidget::iconify()
+
+ Use showMinimized() instead.
+*/
+
+/*!
+ \fn void QWidget::constPolish() const
+
+ Use ensurePolished() instead.
+*/
+
+/*!
+ \fn void QWidget::reparent(QWidget *parent, Qt::WindowFlags f, const QPoint &p, bool showIt)
+
+ Use setParent() to change the parent or the widget's widget flags;
+ use move() to move the widget, and use show() to show the widget.
+*/
+
+/*!
+ \fn void QWidget::reparent(QWidget *parent, const QPoint &p, bool showIt)
+
+ Use setParent() to change the parent; use move() to move the
+ widget, and use show() to show the widget.
+*/
+
+/*!
+ \fn void QWidget::recreate(QWidget *parent, Qt::WindowFlags f, const QPoint & p, bool showIt)
+
+ Use setParent() to change the parent or the widget's widget flags;
+ use move() to move the widget, and use show() to show the widget.
+*/
+
+/*!
+ \fn bool QWidget::hasMouse() const
+
+ Use testAttribute(Qt::WA_UnderMouse) instead.
+*/
+
+/*!
+ \fn bool QWidget::ownCursor() const
+
+ Use testAttribute(Qt::WA_SetCursor) instead.
+*/
+
+/*!
+ \fn bool QWidget::ownFont() const
+
+ Use testAttribute(Qt::WA_SetFont) instead.
+*/
+
+/*!
+ \fn void QWidget::unsetFont()
+
+ Use setFont(QFont()) instead.
+*/
+
+/*!
+ \fn bool QWidget::ownPalette() const
+
+ Use testAttribute(Qt::WA_SetPalette) instead.
+*/
+
+/*!
+ \fn void QWidget::unsetPalette()
+
+ Use setPalette(QPalette()) instead.
+*/
+
+/*!
+ \fn void QWidget::setEraseColor(const QColor &color)
+
+ Use the palette instead.
+
+ \oldcode
+ widget->setEraseColor(color);
+ \newcode
+ QPalette palette;
+ palette.setColor(widget->backgroundRole(), color);
+ widget->setPalette(palette);
+ \endcode
+*/
+
+/*!
+ \fn void QWidget::setErasePixmap(const QPixmap &pixmap)
+
+ Use the palette instead.
+
+ \oldcode
+ widget->setErasePixmap(pixmap);
+ \newcode
+ QPalette palette;
+ palette.setBrush(widget->backgroundRole(), QBrush(pixmap));
+ widget->setPalette(palette);
+ \endcode
+*/
+
+/*!
+ \fn void QWidget::setPaletteForegroundColor(const QColor &color)
+
+ Use the palette directly.
+
+ \oldcode
+ widget->setPaletteForegroundColor(color);
+ \newcode
+ QPalette palette;
+ palette.setColor(widget->foregroundRole(), color);
+ widget->setPalette(palette);
+ \endcode
+*/
+
+/*!
+ \fn void QWidget::setPaletteBackgroundColor(const QColor &color)
+
+ Use the palette directly.
+
+ \oldcode
+ widget->setPaletteBackgroundColor(color);
+ \newcode
+ QPalette palette;
+ palette.setColor(widget->backgroundRole(), color);
+ widget->setPalette(palette);
+ \endcode
+*/
+
+/*!
+ \fn void QWidget::setPaletteBackgroundPixmap(const QPixmap &pixmap)
+
+ Use the palette directly.
+
+ \oldcode
+ widget->setPaletteBackgroundPixmap(pixmap);
+ \newcode
+ QPalette palette;
+ palette.setBrush(widget->backgroundRole(), QBrush(pixmap));
+ widget->setPalette(palette);
+ \endcode
+*/
+
+/*!
+ \fn void QWidget::setBackgroundPixmap(const QPixmap &pixmap)
+
+ Use the palette instead.
+
+ \oldcode
+ widget->setBackgroundPixmap(pixmap);
+ \newcode
+ QPalette palette;
+ palette.setBrush(widget->backgroundRole(), QBrush(pixmap));
+ widget->setPalette(palette);
+ \endcode
+*/
+
+/*!
+ \fn void QWidget::setBackgroundColor(const QColor &color)
+
+ Use the palette instead.
+
+ \oldcode
+ widget->setBackgroundColor(color);
+ \newcode
+ QPalette palette;
+ palette.setColor(widget->backgroundRole(), color);
+ widget->setPalette(palette);
+ \endcode
+*/
+
+
+/*!
+ \fn QWidget *QWidget::parentWidget(bool sameWindow) const
+
+ Use the no-argument overload instead.
+*/
+
+/*!
+ \fn void QWidget::setKeyCompression(bool b)
+
+ Use setAttribute(Qt::WA_KeyCompression, b) instead.
+*/
+
+/*!
+ \fn void QWidget::setFont(const QFont &f, bool b)
+
+ Use the single-argument overload instead.
+*/
+
+/*!
+ \fn void QWidget::setPalette(const QPalette &p, bool b)
+
+ Use the single-argument overload instead.
+*/
+
+/*!
+ \fn void QWidget::setBackgroundOrigin(BackgroundOrigin background)
+
+ \obsolete
+*/
+
+/*!
+ \fn BackgroundOrigin QWidget::backgroundOrigin() const
+
+ \obsolete
+
+ Always returns \c WindowOrigin.
+*/
+
+/*!
+ \fn QPoint QWidget::backgroundOffset() const
+
+ \obsolete
+
+ Always returns QPoint().
+*/
+
+/*!
+ \fn void QWidget::repaint(bool b)
+
+ The boolean parameter \a b is ignored. Use the no-argument overload instead.
+*/
+
+/*!
+ \fn void QWidget::repaint(int x, int y, int w, int h, bool b)
+
+ The boolean parameter \a b is ignored. Use the four-argument overload instead.
+*/
+
+/*!
+ \fn void QWidget::repaint(const QRect &r, bool b)
+
+ The boolean parameter \a b is ignored. Use the single rect-argument overload instead.
+*/
+
+/*!
+ \fn void QWidget::repaint(const QRegion &rgn, bool b)
+
+ The boolean parameter \a b is ignored. Use the single region-argument overload instead.
+*/
+
+/*!
+ \fn void QWidget::erase()
+
+ Drawing may only take place in a QPaintEvent. Overload
+ paintEvent() to do your erasing and call update() to schedule a
+ replaint whenever necessary. See also QPainter.
+*/
+
+/*!
+ \fn void QWidget::erase(int x, int y, int w, int h)
+
+ Drawing may only take place in a QPaintEvent. Overload
+ paintEvent() to do your erasing and call update() to schedule a
+ replaint whenever necessary. See also QPainter.
+*/
+
+/*!
+ \fn void QWidget::erase(const QRect &rect)
+
+ Drawing may only take place in a QPaintEvent. Overload
+ paintEvent() to do your erasing and call update() to schedule a
+ replaint whenever necessary. See also QPainter.
+*/
+
+/*!
+ \fn void QWidget::drawText(const QPoint &p, const QString &s)
+
+ Drawing may only take place in a QPaintEvent. Overload
+ paintEvent() to do your drawing and call update() to schedule a
+ replaint whenever necessary. See also QPainter.
+*/
+
+/*!
+ \fn void QWidget::drawText(int x, int y, const QString &s)
+
+ Drawing may only take place in a QPaintEvent. Overload
+ paintEvent() to do your drawing and call update() to schedule a
+ replaint whenever necessary. See also QPainter.
+*/
+
+/*!
+ \fn QWidget *QWidget::childAt(const QPoint &p, bool includeThis) const
+
+ Use the single point argument overload instead.
+*/
+
+/*!
+ \fn void QWidget::setCaption(const QString &c)
+
+ Use setWindowTitle() instead.
+*/
+
+/*!
+ \fn void QWidget::setIcon(const QPixmap &i)
+
+ Use setWindowIcon() instead.
+*/
+
+/*!
+ \fn void QWidget::setIconText(const QString &it)
+
+ Use setWindowIconText() instead.
+*/
+
+/*!
+ \fn QString QWidget::caption() const
+
+ Use windowTitle() instead.
+*/
+
+/*!
+ \fn QString QWidget::iconText() const
+
+ Use windowIconText() instead.
+*/
+
+/*!
+ \fn bool QWidget::isTopLevel() const
+ \obsolete
+
+ Use isWindow() instead.
+*/
+
+/*!
+ \fn bool QWidget::isRightToLeft() const
+ \internal
+*/
+
+/*!
+ \fn bool QWidget::isLeftToRight() const
+ \internal
+*/
+
+/*!
+ \fn void QWidget::setInputMethodEnabled(bool enabled)
+
+ Use setAttribute(Qt::WA_InputMethodEnabled, \a enabled) instead.
+*/
+
+/*!
+ \fn bool QWidget::isInputMethodEnabled() const
+
+ Use testAttribute(Qt::WA_InputMethodEnabled) instead.
+*/
+
+/*!
+ \fn void QWidget::setActiveWindow()
+
+ Use activateWindow() instead.
+*/
+
+/*!
+ \fn bool QWidget::isShown() const
+
+ Use !isHidden() instead (notice the exclamation mark), or use isVisible() to check whether the widget is visible.
+*/
+
+/*!
+ \fn bool QWidget::isDialog() const
+
+ Use windowType() == Qt::Dialog instead.
+*/
+
+/*!
+ \fn bool QWidget::isPopup() const
+
+ Use windowType() == Qt::Popup instead.
+*/
+
+/*!
+ \fn bool QWidget::isDesktop() const
+
+ Use windowType() == Qt::Desktop instead.
+*/
+
+/*!
+ \fn void QWidget::polish()
+
+ Use ensurePolished() instead.
+*/
+
+/*!
+ \fn QWidget *QWidget::childAt(int x, int y, bool includeThis) const
+
+ Use the childAt() overload that doesn't have an \a includeThis parameter.
+
+ \oldcode
+ return widget->childAt(x, y, true);
+ \newcode
+ QWidget *child = widget->childAt(x, y, true);
+ if (child)
+ return child;
+ if (widget->rect().contains(x, y))
+ return widget;
+ \endcode
+*/
+
+/*!
+ \fn void QWidget::setSizePolicy(QSizePolicy::Policy hor, QSizePolicy::Policy ver, bool hfw)
+ \compat
+
+ Use the \l sizePolicy property and heightForWidth() function instead.
+*/
+
+/*!
+ \fn bool QWidget::isUpdatesEnabled() const
+ \compat
+
+ Use the \l updatesEnabled property instead.
+*/
+
+/*!
+ \macro QWIDGETSIZE_MAX
+ \relates QWidget
+
+ Defines the maximum size for a QWidget object.
+
+ The largest allowed size for a widget is QSize(QWIDGETSIZE_MAX,
+ QWIDGETSIZE_MAX), i.e. QSize (16777215,16777215).
+
+ \sa QWidget::setMaximumSize()
+*/
+
+/*!
+ \fn QWidget::setupUi(QWidget *widget)
+
+ Sets up the user interface for the specified \a widget.
+
+ \note This function is available with widgets that derive from user
+ interface descriptions created using \l{uic}.
+
+ \sa {Using a Designer UI File in Your Application}
+*/
+
+QRect QWidgetPrivate::frameStrut() const
+{
+ Q_Q(const QWidget);
+ if (!q->isWindow() || (q->windowType() == Qt::Desktop) || q->testAttribute(Qt::WA_DontShowOnScreen)) {
+ // x2 = x1 + w - 1, so w/h = 1
+ return QRect(0, 0, 1, 1);
+ }
+
+ if (data.fstrut_dirty
+#ifndef Q_WS_WIN
+ // ### Fix properly for 4.3
+ && q->isVisible()
+#endif
+ && q->testAttribute(Qt::WA_WState_Created))
+ const_cast<QWidgetPrivate *>(this)->updateFrameStrut();
+
+ return maybeTopData() ? maybeTopData()->frameStrut : QRect();
+}
+
+#ifdef QT_KEYPAD_NAVIGATION
+/*!
+ \internal
+
+ Changes the focus from the current focusWidget to a widget in
+ the \a direction.
+
+ Returns true, if there was a widget in that direction
+*/
+bool QWidgetPrivate::navigateToDirection(Direction direction)
+{
+ QWidget *targetWidget = widgetInNavigationDirection(direction);
+ if (targetWidget)
+ targetWidget->setFocus();
+ return (targetWidget != 0);
+}
+
+/*!
+ \internal
+
+ Searches for a widget that is positioned in the \a direction, starting
+ from the current focusWidget.
+
+ Returns the pointer to a found widget or 0, if there was no widget in
+ that direction.
+*/
+QWidget *QWidgetPrivate::widgetInNavigationDirection(Direction direction)
+{
+ const QWidget *sourceWidget = QApplication::focusWidget();
+ if (!sourceWidget)
+ return 0;
+ const QRect sourceRect = sourceWidget->rect().translated(sourceWidget->mapToGlobal(QPoint()));
+ const int sourceX =
+ (direction == DirectionNorth || direction == DirectionSouth) ?
+ (sourceRect.left() + (sourceRect.right() - sourceRect.left()) / 2)
+ :(direction == DirectionEast ? sourceRect.right() : sourceRect.left());
+ const int sourceY =
+ (direction == DirectionEast || direction == DirectionWest) ?
+ (sourceRect.top() + (sourceRect.bottom() - sourceRect.top()) / 2)
+ :(direction == DirectionSouth ? sourceRect.bottom() : sourceRect.top());
+ const QPoint sourcePoint(sourceX, sourceY);
+ const QPoint sourceCenter = sourceRect.center();
+ const QWidget *sourceWindow = sourceWidget->window();
+
+ QWidget *targetWidget = 0;
+ int shortestDistance = INT_MAX;
+ foreach(QWidget *targetCandidate, QApplication::allWidgets()) {
+
+ const QRect targetCandidateRect = targetCandidate->rect().translated(targetCandidate->mapToGlobal(QPoint()));
+
+ // For focus proxies, the child widget handling the focus can have keypad navigation focus,
+ // but the owner of the proxy cannot.
+ // Additionally, empty widgets should be ignored.
+ if (targetCandidate->focusProxy() || targetCandidateRect.isEmpty())
+ continue;
+
+ // Only navigate to a target widget that...
+ if ( targetCandidate != sourceWidget
+ // ...takes the focus,
+ && targetCandidate->focusPolicy() & Qt::TabFocus
+ // ...is above if DirectionNorth,
+ && !(direction == DirectionNorth && targetCandidateRect.bottom() > sourceRect.top())
+ // ...is on the right if DirectionEast,
+ && !(direction == DirectionEast && targetCandidateRect.left() < sourceRect.right())
+ // ...is below if DirectionSouth,
+ && !(direction == DirectionSouth && targetCandidateRect.top() < sourceRect.bottom())
+ // ...is on the left if DirectionWest,
+ && !(direction == DirectionWest && targetCandidateRect.right() > sourceRect.left())
+ // ...is enabled,
+ && targetCandidate->isEnabled()
+ // ...is visible,
+ && targetCandidate->isVisible()
+ // ...is in the same window,
+ && targetCandidate->window() == sourceWindow) {
+ const int targetCandidateDistance = pointToRect(sourcePoint, targetCandidateRect);
+ if (targetCandidateDistance < shortestDistance) {
+ shortestDistance = targetCandidateDistance;
+ targetWidget = targetCandidate;
+ }
+ }
+ }
+ return targetWidget;
+}
+
+/*!
+ \internal
+
+ Tells us if it there is currently a reachable widget by keypad navigation in
+ a certain \a orientation.
+ If no navigation is possible, occurring key events in that \a orientation may
+ be used to interact with the value in the focused widget, even though it
+ currently has not the editFocus.
+
+ \sa QWidgetPrivate::widgetInNavigationDirection(), QWidget::hasEditFocus()
+*/
+bool QWidgetPrivate::canKeypadNavigate(Qt::Orientation orientation)
+{
+ return orientation == Qt::Horizontal?
+ (QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionEast)
+ || QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionWest))
+ :(QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionNorth)
+ || QWidgetPrivate::widgetInNavigationDirection(QWidgetPrivate::DirectionSouth));
+}
+/*!
+ \internal
+
+ Checks, if the \a widget is inside a QTabWidget. If is is inside
+ one, left/right key events will be used to switch between tabs in keypad
+ navigation. If there is no QTabWidget, the horizontal key events can be used
+to
+ interact with the value in the focused widget, even though it currently has
+ not the editFocus.
+
+ \sa QWidget::hasEditFocus()
+*/
+bool QWidgetPrivate::inTabWidget(QWidget *widget)
+{
+ for (QWidget *tabWidget = widget; tabWidget; tabWidget = tabWidget->parentWidget())
+ if (qobject_cast<const QTabWidget*>(tabWidget))
+ return true;
+ return false;
+}
+#endif
+
+/*!
+ \preliminary
+ \since 4.2
+ \obsolete
+
+ Sets the window surface to be the \a surface specified.
+ The QWidget takes will ownership of the \a surface.
+ widget itself is deleted.
+*/
+void QWidget::setWindowSurface(QWindowSurface *surface)
+{
+ // ### createWinId() ??
+
+#ifndef Q_BACKINGSTORE_SUBSURFACES
+ if (!isTopLevel())
+ return;
+#endif
+
+ Q_D(QWidget);
+
+ QTLWExtra *topData = d->topData();
+ if (topData->windowSurface == surface)
+ return;
+
+ QWindowSurface *oldSurface = topData->windowSurface;
+ delete topData->windowSurface;
+ topData->windowSurface = surface;
+
+ QWidgetBackingStore *bs = d->maybeBackingStore();
+ if (!bs)
+ return;
+
+ if (isTopLevel()) {
+ if (bs->windowSurface != oldSurface && bs->windowSurface != surface)
+ delete bs->windowSurface;
+ bs->windowSurface = surface;
+ }
+#ifdef Q_BACKINGSTORE_SUBSURFACES
+ else {
+ bs->subSurfaces.append(surface);
+ }
+ bs->subSurfaces.removeOne(oldSurface);
+#endif
+}
+
+/*!
+ \preliminary
+ \since 4.2
+
+ Returns the QWindowSurface this widget will be drawn into.
+*/
+QWindowSurface *QWidget::windowSurface() const
+{
+ Q_D(const QWidget);
+ QTLWExtra *extra = d->maybeTopData();
+ if (extra && extra->windowSurface)
+ return extra->windowSurface;
+
+ QWidgetBackingStore *bs = d->maybeBackingStore();
+
+#ifdef Q_BACKINGSTORE_SUBSURFACES
+ if (bs && bs->subSurfaces.isEmpty())
+ return bs->windowSurface;
+
+ if (!isTopLevel()) {
+ const QWidget *w = parentWidget();
+ while (w) {
+ QTLWExtra *extra = w->d_func()->maybeTopData();
+ if (extra && extra->windowSurface)
+ return extra->windowSurface;
+ if (w->isTopLevel())
+ break;
+ w = w->parentWidget();
+ }
+ }
+#endif // Q_BACKINGSTORE_SUBSURFACES
+
+ return bs ? bs->windowSurface : 0;
+}
+
+void QWidgetPrivate::getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const
+{
+ if (left)
+ *left = (int)leftLayoutItemMargin;
+ if (top)
+ *top = (int)topLayoutItemMargin;
+ if (right)
+ *right = (int)rightLayoutItemMargin;
+ if (bottom)
+ *bottom = (int)bottomLayoutItemMargin;
+}
+
+void QWidgetPrivate::setLayoutItemMargins(int left, int top, int right, int bottom)
+{
+ if (leftLayoutItemMargin == left
+ && topLayoutItemMargin == top
+ && rightLayoutItemMargin == right
+ && bottomLayoutItemMargin == bottom)
+ return;
+
+ Q_Q(QWidget);
+ leftLayoutItemMargin = (signed char)left;
+ topLayoutItemMargin = (signed char)top;
+ rightLayoutItemMargin = (signed char)right;
+ bottomLayoutItemMargin = (signed char)bottom;
+ q->updateGeometry();
+}
+
+void QWidgetPrivate::setLayoutItemMargins(QStyle::SubElement element, const QStyleOption *opt)
+{
+ Q_Q(QWidget);
+ QStyleOption myOpt;
+ if (!opt) {
+ myOpt.initFrom(q);
+ myOpt.rect.setRect(0, 0, 32768, 32768); // arbitrary
+ opt = &myOpt;
+ }
+
+ QRect liRect = q->style()->subElementRect(element, opt, q);
+ if (liRect.isValid()) {
+ leftLayoutItemMargin = (signed char)(opt->rect.left() - liRect.left());
+ topLayoutItemMargin = (signed char)(opt->rect.top() - liRect.top());
+ rightLayoutItemMargin = (signed char)(liRect.right() - opt->rect.right());
+ bottomLayoutItemMargin = (signed char)(liRect.bottom() - opt->rect.bottom());
+ } else {
+ leftLayoutItemMargin = 0;
+ topLayoutItemMargin = 0;
+ rightLayoutItemMargin = 0;
+ bottomLayoutItemMargin = 0;
+ }
+}
+// resets the Qt::WA_QuitOnClose attribute to the default value for transient widgets.
+void QWidgetPrivate::adjustQuitOnCloseAttribute()
+{
+ Q_Q(QWidget);
+
+ if (!q->parentWidget()) {
+ Qt::WindowType type = q->windowType();
+ if (type == Qt::Widget || type == Qt::SubWindow)
+ type = Qt::Window;
+ if (type != Qt::Widget && type != Qt::Window && type != Qt::Dialog)
+ q->setAttribute(Qt::WA_QuitOnClose, false);
+ }
+}
+
+
+
+Q_GUI_EXPORT QWidgetData *qt_qwidget_data(QWidget *widget)
+{
+ return widget->data;
+}
+
+Q_GUI_EXPORT QWidgetPrivate *qt_widget_private(QWidget *widget)
+{
+ return widget->d_func();
+}
+
+
+#ifndef QT_NO_GRAPHICSVIEW
+/*!
+ \since 4.5
+
+ Returns the proxy widget for the corresponding embedded widget in a graphics
+ view; otherwise returns 0.
+
+ \sa QGraphicsProxyWidget::createProxyForChildWidget(),
+ QGraphicsScene::addWidget()
+ */
+QGraphicsProxyWidget *QWidget::graphicsProxyWidget() const
+{
+ Q_D(const QWidget);
+ if (d->extra) {
+ return d->extra->proxyWidget;
+ }
+ return 0;
+}
+#endif
+
+
+/*!
+ \typedef QWidgetList
+ \relates QWidget
+
+ Synonym for QList<QWidget *>.
+*/
+
+#ifndef QT_NO_GESTURES
+/*!
+ Subscribes the widget to a given \a gesture with specific \a flags.
+
+ \sa ungrabGesture(), QGestureEvent
+ \since 4.6
+*/
+void QWidget::grabGesture(Qt::GestureType gesture, Qt::GestureFlags flags)
+{
+ Q_D(QWidget);
+ d->gestureContext.insert(gesture, flags);
+ (void)QGestureManager::instance(); // create a gesture manager
+}
+
+/*!
+ Unsubscribes the widget from a given \a gesture type
+
+ \sa grabGesture(), QGestureEvent
+ \since 4.6
+*/
+void QWidget::ungrabGesture(Qt::GestureType gesture)
+{
+ Q_D(QWidget);
+ if (d->gestureContext.remove(gesture)) {
+ if (QGestureManager *manager = QGestureManager::instance())
+ manager->cleanupCachedGestures(this, gesture);
+ }
+}
+#endif // QT_NO_GESTURES
+
+/*!
+ \typedef WId
+ \relates QWidget
+
+ Platform dependent window identifier.
+*/
+
+/*!
+ \fn void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
+
+ Frees up window system resources. Destroys the widget window if \a
+ destroyWindow is true.
+
+ destroy() calls itself recursively for all the child widgets,
+ passing \a destroySubWindows for the \a destroyWindow parameter.
+ To have more control over destruction of subwidgets, destroy
+ subwidgets selectively first.
+
+ This function is usually called from the QWidget destructor.
+*/
+
+/*!
+ \fn QPaintEngine *QWidget::paintEngine() const
+
+ Returns the widget's paint engine.
+
+ Note that this function should not be called explicitly by the
+ user, since it's meant for reimplementation purposes only. The
+ function is called by Qt internally, and the default
+ implementation may not always return a valid pointer.
+*/
+
+/*!
+ \fn QPoint QWidget::mapToGlobal(const QPoint &pos) const
+
+ Translates the widget coordinate \a pos to global screen
+ coordinates. For example, \c{mapToGlobal(QPoint(0,0))} would give
+ the global coordinates of the top-left pixel of the widget.
+
+ \sa mapFromGlobal() mapTo() mapToParent()
+*/
+
+/*!
+ \fn QPoint QWidget::mapFromGlobal(const QPoint &pos) const
+
+ Translates the global screen coordinate \a pos to widget
+ coordinates.
+
+ \sa mapToGlobal() mapFrom() mapFromParent()
+*/
+
+/*!
+ \fn void QWidget::grabMouse()
+
+ Grabs the mouse input.
+
+ This widget receives all mouse events until releaseMouse() is
+ called; other widgets get no mouse events at all. Keyboard
+ events are not affected. Use grabKeyboard() if you want to grab
+ that.
+
+ \warning Bugs in mouse-grabbing applications very often lock the
+ terminal. Use this function with extreme caution, and consider
+ using the \c -nograb command line option while debugging.
+
+ It is almost never necessary to grab the mouse when using Qt, as
+ Qt grabs and releases it sensibly. In particular, Qt grabs the
+ mouse when a mouse button is pressed and keeps it until the last
+ button is released.
+
+ \note Only visible widgets can grab mouse input. If isVisible()
+ returns false for a widget, that widget cannot call grabMouse().
+
+ \note \bold{(Mac OS X developers)} For \e Cocoa, calling
+ grabMouse() on a widget only works when the mouse is inside the
+ frame of that widget. For \e Carbon, it works outside the widget's
+ frame as well, like for Windows and X11.
+
+ \sa releaseMouse() grabKeyboard() releaseKeyboard()
+*/
+
+/*!
+ \fn void QWidget::grabMouse(const QCursor &cursor)
+ \overload grabMouse()
+
+ Grabs the mouse input and changes the cursor shape.
+
+ The cursor will assume shape \a cursor (for as long as the mouse
+ focus is grabbed) and this widget will be the only one to receive
+ mouse events until releaseMouse() is called().
+
+ \warning Grabbing the mouse might lock the terminal.
+
+ \note \bold{(Mac OS X developers)} See the note in QWidget::grabMouse().
+
+ \sa releaseMouse(), grabKeyboard(), releaseKeyboard(), setCursor()
+*/
+
+/*!
+ \fn void QWidget::releaseMouse()
+
+ Releases the mouse grab.
+
+ \sa grabMouse(), grabKeyboard(), releaseKeyboard()
+*/
+
+/*!
+ \fn void QWidget::grabKeyboard()
+
+ Grabs the keyboard input.
+
+ This widget receives all keyboard events until releaseKeyboard()
+ is called; other widgets get no keyboard events at all. Mouse
+ events are not affected. Use grabMouse() if you want to grab that.
+
+ The focus widget is not affected, except that it doesn't receive
+ any keyboard events. setFocus() moves the focus as usual, but the
+ new focus widget receives keyboard events only after
+ releaseKeyboard() is called.
+
+ If a different widget is currently grabbing keyboard input, that
+ widget's grab is released first.
+
+ \sa releaseKeyboard() grabMouse() releaseMouse() focusWidget()
+*/
+
+/*!
+ \fn void QWidget::releaseKeyboard()
+
+ Releases the keyboard grab.
+
+ \sa grabKeyboard(), grabMouse(), releaseMouse()
+*/
+
+/*!
+ \fn QWidget *QWidget::mouseGrabber()
+
+ Returns the widget that is currently grabbing the mouse input.
+
+ If no widget in this application is currently grabbing the mouse,
+ 0 is returned.
+
+ \sa grabMouse(), keyboardGrabber()
+*/
+
+/*!
+ \fn QWidget *QWidget::keyboardGrabber()
+
+ Returns the widget that is currently grabbing the keyboard input.
+
+ If no widget in this application is currently grabbing the
+ keyboard, 0 is returned.
+
+ \sa grabMouse(), mouseGrabber()
+*/
+
+/*!
+ \fn void QWidget::activateWindow()
+
+ Sets the top-level widget containing this widget to be the active
+ window.
+
+ An active window is a visible top-level window that has the
+ keyboard input focus.
+
+ This function performs the same operation as clicking the mouse on
+ the title bar of a top-level window. On X11, the result depends on
+ the Window Manager. If you want to ensure that the window is
+ stacked on top as well you should also call raise(). Note that the
+ window must be visible, otherwise activateWindow() has no effect.
+
+ On Windows, if you are calling this when the application is not
+ currently the active one then it will not make it the active
+ window. It will change the color of the taskbar entry to indicate
+ that the window has changed in some way. This is because Microsoft
+ does not allow an application to interrupt what the user is currently
+ doing in another application.
+
+ \sa isActiveWindow(), window(), show()
+*/
+
+/*!
+ \fn int QWidget::metric(PaintDeviceMetric m) const
+
+ Internal implementation of the virtual QPaintDevice::metric()
+ function.
+
+ \a m is the metric to get.
+*/
+
+void QWidget::init(QPainter *painter) const
+{
+ const QPalette &pal = palette();
+ painter->d_func()->state->pen = QPen(pal.brush(foregroundRole()), 0);
+ painter->d_func()->state->bgBrush = pal.brush(backgroundRole());
+ QFont f(font(), const_cast<QWidget *>(this));
+ painter->d_func()->state->deviceFont = f;
+ painter->d_func()->state->font = f;
+}
+
+QPaintDevice *QWidget::redirected(QPoint *offset) const
+{
+ return d_func()->redirected(offset);
+}
+
+QPainter *QWidget::sharedPainter() const
+{
+ // Someone sent a paint event directly to the widget
+ if (!d_func()->redirectDev)
+ return 0;
+
+ QPainter *sp = d_func()->sharedPainter();
+ if (!sp || !sp->isActive())
+ return 0;
+
+ if (sp->paintEngine()->paintDevice() != d_func()->redirectDev)
+ return 0;
+
+ return sp;
+}
+
+/*!
+ \fn void QWidget::setMask(const QRegion &region)
+ \overload
+
+ Causes only the parts of the widget which overlap \a region to be
+ visible. If the region includes pixels outside the rect() of the
+ widget, window system controls in that area may or may not be
+ visible, depending on the platform.
+
+ Note that this effect can be slow if the region is particularly
+ complex.
+
+ \sa windowOpacity
+*/
+void QWidget::setMask(const QRegion &newMask)
+{
+ Q_D(QWidget);
+
+ d->createExtra();
+ if (newMask == d->extra->mask)
+ return;
+
+#ifndef QT_NO_BACKINGSTORE
+ const QRegion oldMask(d->extra->mask);
+#endif
+
+ d->extra->mask = newMask;
+ d->extra->hasMask = !newMask.isEmpty();
+
+#ifndef QT_MAC_USE_COCOA
+ if (!testAttribute(Qt::WA_WState_Created))
+ return;
+#endif
+
+ d->setMask_sys(newMask);
+
+#ifndef QT_NO_BACKINGSTORE
+ if (!isVisible())
+ return;
+
+ if (!d->extra->hasMask) {
+ // Mask was cleared; update newly exposed area.
+ QRegion expose(rect());
+ expose -= oldMask;
+ if (!expose.isEmpty()) {
+ d->setDirtyOpaqueRegion();
+ update(expose);
+ }
+ return;
+ }
+
+ if (!isWindow()) {
+ // Update newly exposed area on the parent widget.
+ QRegion parentExpose(rect());
+ parentExpose -= newMask;
+ if (!parentExpose.isEmpty()) {
+ d->setDirtyOpaqueRegion();
+ parentExpose.translate(data->crect.topLeft());
+ parentWidget()->update(parentExpose);
+ }
+
+ // Update newly exposed area on this widget
+ if (!oldMask.isEmpty())
+ update(newMask - oldMask);
+ }
+#endif
+}
+
+/*!
+ \fn void QWidget::setMask(const QBitmap &bitmap)
+
+ Causes only the pixels of the widget for which \a bitmap has a
+ corresponding 1 bit to be visible. If the region includes pixels
+ outside the rect() of the widget, window system controls in that
+ area may or may not be visible, depending on the platform.
+
+ Note that this effect can be slow if the region is particularly
+ complex.
+
+ The following code shows how an image with an alpha channel can be
+ used to generate a mask for a widget:
+
+ \snippet doc/src/snippets/widget-mask/main.cpp 0
+
+ The label shown by this code is masked using the image it contains,
+ giving the appearance that an irregularly-shaped image is being drawn
+ directly onto the screen.
+
+ Masked widgets receive mouse events only on their visible
+ portions.
+
+ \sa clearMask(), windowOpacity(), {Shaped Clock Example}
+*/
+void QWidget::setMask(const QBitmap &bitmap)
+{
+ setMask(QRegion(bitmap));
+}
+
+/*!
+ \fn void QWidget::clearMask()
+
+ Removes any mask set by setMask().
+
+ \sa setMask()
+*/
+void QWidget::clearMask()
+{
+ setMask(QRegion());
+}
+
+/*! \fn const QX11Info &QWidget::x11Info() const
+ Returns information about the configuration of the X display used to display
+ the widget.
+
+ \warning This function is only available on X11.
+*/
+
+/*! \fn Qt::HANDLE QWidget::x11PictureHandle() const
+ Returns the X11 Picture handle of the widget for XRender
+ support. Use of this function is not portable. This function will
+ return 0 if XRender support is not compiled into Qt, if the
+ XRender extension is not supported on the X11 display, or if the
+ handle could not be created.
+*/
+
+#ifdef Q_OS_SYMBIAN
+void QWidgetPrivate::_q_delayedDestroy(WId winId)
+{
+ delete winId;
+}
+#endif
+
+#if QT_MAC_USE_COCOA
+void QWidgetPrivate::syncUnifiedMode() {
+ // The whole purpose of this method is to keep the unifiedToolbar in sync.
+ // That means making sure we either exchange the drawing methods or we let
+ // the toolbar know that it does not require to draw the baseline.
+ Q_Q(QWidget);
+ // This function makes sense only if this is a top level
+ if(!q->isWindow())
+ return;
+ OSWindowRef window = qt_mac_window_for(q);
+ if(changeMethods) {
+ // Ok, we are in documentMode.
+ if(originalDrawMethod)
+ qt_mac_replaceDrawRect(window, this);
+ } else {
+ if(!originalDrawMethod)
+ qt_mac_replaceDrawRectOriginal(window, this);
+ }
+}
+
+#endif // QT_MAC_USE_COCOA
+
+QT_END_NAMESPACE
+
+#include "moc_qwidget.cpp"
+
diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h
new file mode 100644
index 0000000000..415fb67b38
--- /dev/null
+++ b/src/widgets/kernel/qwidget.h
@@ -0,0 +1,1091 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWIDGET_H
+#define QWIDGET_H
+
+#include <QtGui/qwindowdefs.h>
+#include <QtCore/qobject.h>
+#include <QtCore/qmargins.h>
+#include <QtGui/qpaintdevice.h>
+#include <QtGui/qpalette.h>
+#include <QtGui/qfont.h>
+#include <QtGui/qfontmetrics.h>
+#include <QtGui/qfontinfo.h>
+#include <QtWidgets/qsizepolicy.h>
+#include <QtGui/qregion.h>
+#include <QtGui/qbrush.h>
+#include <QtGui/qcursor.h>
+#include <QtGui/qkeysequence.h>
+
+#ifdef Q_WS_QPA //should this go somewhere else?
+#include <QtGui/qwindow.h>
+#include <QtGui/qwindowformat_qpa.h>
+#endif
+
+#ifdef QT_INCLUDE_COMPAT
+#include <QtGui/qevent.h>
+#endif
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QLayout;
+class QWSRegionManager;
+class QStyle;
+class QAction;
+class QVariant;
+
+class QActionEvent;
+class QMouseEvent;
+class QWheelEvent;
+class QHoverEvent;
+class QKeyEvent;
+class QFocusEvent;
+class QPaintEvent;
+class QMoveEvent;
+class QResizeEvent;
+class QCloseEvent;
+class QContextMenuEvent;
+class QInputMethodEvent;
+class QTabletEvent;
+class QDragEnterEvent;
+class QDragMoveEvent;
+class QDragLeaveEvent;
+class QDropEvent;
+class QShowEvent;
+class QHideEvent;
+class QInputContext;
+class QIcon;
+class QWindowSurface;
+class QPlatformWindow;
+class QLocale;
+class QGraphicsProxyWidget;
+class QGraphicsEffect;
+class QRasterWindowSurface;
+class QUnifiedToolbarSurface;
+#if defined(Q_WS_X11)
+class QX11Info;
+#endif
+
+class QWidgetData
+{
+public:
+ WId winid;
+ uint widget_attributes;
+ Qt::WindowFlags window_flags;
+ uint window_state : 4;
+ uint focus_policy : 4;
+ uint sizehint_forced :1;
+ uint is_closing :1;
+ uint in_show : 1;
+ uint in_set_window_state : 1;
+ mutable uint fstrut_dirty : 1;
+ uint context_menu_policy : 3;
+ uint window_modality : 2;
+ uint in_destructor : 1;
+ uint unused : 13;
+ QRect crect;
+ mutable QPalette pal;
+ QFont fnt;
+#if defined(Q_WS_QWS)
+// QRegion req_region; // Requested region
+// mutable QRegion paintable_region; // Paintable region
+// mutable bool paintable_region_dirty;// needs to be recalculated
+// mutable QRegion alloc_region; // Allocated region
+// mutable bool alloc_region_dirty; // needs to be recalculated
+// mutable int overlapping_children; // Handle overlapping children
+
+ int alloc_region_index;
+// int alloc_region_revision;
+#endif
+ QRect wrect;
+};
+
+class QWidgetPrivate;
+
+class Q_GUI_EXPORT QWidget : public QObject, public QPaintDevice
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWidget)
+
+ Q_PROPERTY(bool modal READ isModal)
+ Q_PROPERTY(Qt::WindowModality windowModality READ windowModality WRITE setWindowModality)
+ Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
+ Q_PROPERTY(QRect geometry READ geometry WRITE setGeometry)
+ Q_PROPERTY(QRect frameGeometry READ frameGeometry)
+ Q_PROPERTY(QRect normalGeometry READ normalGeometry)
+ Q_PROPERTY(int x READ x)
+ Q_PROPERTY(int y READ y)
+ Q_PROPERTY(QPoint pos READ pos WRITE move DESIGNABLE false STORED false)
+ Q_PROPERTY(QSize frameSize READ frameSize)
+ Q_PROPERTY(QSize size READ size WRITE resize DESIGNABLE false STORED false)
+ Q_PROPERTY(int width READ width)
+ Q_PROPERTY(int height READ height)
+ Q_PROPERTY(QRect rect READ rect)
+ Q_PROPERTY(QRect childrenRect READ childrenRect)
+ Q_PROPERTY(QRegion childrenRegion READ childrenRegion)
+ Q_PROPERTY(QSizePolicy sizePolicy READ sizePolicy WRITE setSizePolicy)
+ Q_PROPERTY(QSize minimumSize READ minimumSize WRITE setMinimumSize)
+ Q_PROPERTY(QSize maximumSize READ maximumSize WRITE setMaximumSize)
+ Q_PROPERTY(int minimumWidth READ minimumWidth WRITE setMinimumWidth STORED false DESIGNABLE false)
+ Q_PROPERTY(int minimumHeight READ minimumHeight WRITE setMinimumHeight STORED false DESIGNABLE false)
+ Q_PROPERTY(int maximumWidth READ maximumWidth WRITE setMaximumWidth STORED false DESIGNABLE false)
+ Q_PROPERTY(int maximumHeight READ maximumHeight WRITE setMaximumHeight STORED false DESIGNABLE false)
+ Q_PROPERTY(QSize sizeIncrement READ sizeIncrement WRITE setSizeIncrement)
+ Q_PROPERTY(QSize baseSize READ baseSize WRITE setBaseSize)
+ Q_PROPERTY(QPalette palette READ palette WRITE setPalette)
+ Q_PROPERTY(QFont font READ font WRITE setFont)
+#ifndef QT_NO_CURSOR
+ Q_PROPERTY(QCursor cursor READ cursor WRITE setCursor RESET unsetCursor)
+#endif
+ Q_PROPERTY(bool mouseTracking READ hasMouseTracking WRITE setMouseTracking)
+ Q_PROPERTY(bool isActiveWindow READ isActiveWindow)
+ Q_PROPERTY(Qt::FocusPolicy focusPolicy READ focusPolicy WRITE setFocusPolicy)
+ Q_PROPERTY(bool focus READ hasFocus)
+ Q_PROPERTY(Qt::ContextMenuPolicy contextMenuPolicy READ contextMenuPolicy WRITE setContextMenuPolicy)
+ Q_PROPERTY(bool updatesEnabled READ updatesEnabled WRITE setUpdatesEnabled DESIGNABLE false)
+ Q_PROPERTY(bool visible READ isVisible WRITE setVisible DESIGNABLE false)
+ Q_PROPERTY(bool minimized READ isMinimized)
+ Q_PROPERTY(bool maximized READ isMaximized)
+ Q_PROPERTY(bool fullScreen READ isFullScreen)
+ Q_PROPERTY(QSize sizeHint READ sizeHint)
+ Q_PROPERTY(QSize minimumSizeHint READ minimumSizeHint)
+ Q_PROPERTY(bool acceptDrops READ acceptDrops WRITE setAcceptDrops)
+ Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle DESIGNABLE isWindow)
+ Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon DESIGNABLE isWindow)
+ Q_PROPERTY(QString windowIconText READ windowIconText WRITE setWindowIconText DESIGNABLE isWindow)
+ Q_PROPERTY(double windowOpacity READ windowOpacity WRITE setWindowOpacity DESIGNABLE isWindow)
+ Q_PROPERTY(bool windowModified READ isWindowModified WRITE setWindowModified DESIGNABLE isWindow)
+#ifndef QT_NO_TOOLTIP
+ Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip)
+#endif
+#ifndef QT_NO_STATUSTIP
+ Q_PROPERTY(QString statusTip READ statusTip WRITE setStatusTip)
+#endif
+#ifndef QT_NO_WHATSTHIS
+ Q_PROPERTY(QString whatsThis READ whatsThis WRITE setWhatsThis)
+#endif
+#ifndef QT_NO_ACCESSIBILITY
+ Q_PROPERTY(QString accessibleName READ accessibleName WRITE setAccessibleName)
+ Q_PROPERTY(QString accessibleDescription READ accessibleDescription WRITE setAccessibleDescription)
+#endif
+ Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection RESET unsetLayoutDirection)
+ QDOC_PROPERTY(Qt::WindowFlags windowFlags READ windowFlags WRITE setWindowFlags)
+ Q_PROPERTY(bool autoFillBackground READ autoFillBackground WRITE setAutoFillBackground)
+#ifndef QT_NO_STYLE_STYLESHEET
+ Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
+#endif
+ Q_PROPERTY(QLocale locale READ locale WRITE setLocale RESET unsetLocale)
+ Q_PROPERTY(QString windowFilePath READ windowFilePath WRITE setWindowFilePath DESIGNABLE isWindow)
+ Q_PROPERTY(Qt::InputMethodHints inputMethodHints READ inputMethodHints WRITE setInputMethodHints)
+
+public:
+ enum RenderFlag {
+ DrawWindowBackground = 0x1,
+ DrawChildren = 0x2,
+ IgnoreMask = 0x4
+ };
+ Q_DECLARE_FLAGS(RenderFlags, RenderFlag)
+
+ explicit QWidget(QWidget* parent = 0, Qt::WindowFlags f = 0);
+#ifdef QT3_SUPPORT
+ QT3_SUPPORT_CONSTRUCTOR QWidget(QWidget* parent, const char *name, Qt::WindowFlags f = 0);
+#endif
+ ~QWidget();
+
+ int devType() const;
+
+ WId winId() const;
+ void createWinId(); // internal, going away
+ inline WId internalWinId() const { return data->winid; }
+ WId effectiveWinId() const;
+
+ // GUI style setting
+ QStyle *style() const;
+ void setStyle(QStyle *);
+ // Widget types and states
+
+ bool isTopLevel() const;
+ bool isWindow() const;
+
+ bool isModal() const;
+ Qt::WindowModality windowModality() const;
+ void setWindowModality(Qt::WindowModality windowModality);
+
+ bool isEnabled() const;
+ bool isEnabledTo(QWidget*) const;
+ bool isEnabledToTLW() const;
+
+public Q_SLOTS:
+ void setEnabled(bool);
+ void setDisabled(bool);
+ void setWindowModified(bool);
+
+ // Widget coordinates
+
+public:
+ QRect frameGeometry() const;
+ const QRect &geometry() const;
+ QRect normalGeometry() const;
+
+ int x() const;
+ int y() const;
+ QPoint pos() const;
+ QSize frameSize() const;
+ QSize size() const;
+ inline int width() const;
+ inline int height() const;
+ inline QRect rect() const;
+ QRect childrenRect() const;
+ QRegion childrenRegion() const;
+
+ QSize minimumSize() const;
+ QSize maximumSize() const;
+ int minimumWidth() const;
+ int minimumHeight() const;
+ int maximumWidth() const;
+ int maximumHeight() const;
+ void setMinimumSize(const QSize &);
+ void setMinimumSize(int minw, int minh);
+ void setMaximumSize(const QSize &);
+ void setMaximumSize(int maxw, int maxh);
+ void setMinimumWidth(int minw);
+ void setMinimumHeight(int minh);
+ void setMaximumWidth(int maxw);
+ void setMaximumHeight(int maxh);
+
+#ifdef Q_QDOC
+ void setupUi(QWidget *widget);
+#endif
+
+ QSize sizeIncrement() const;
+ void setSizeIncrement(const QSize &);
+ void setSizeIncrement(int w, int h);
+ QSize baseSize() const;
+ void setBaseSize(const QSize &);
+ void setBaseSize(int basew, int baseh);
+
+ void setFixedSize(const QSize &);
+ void setFixedSize(int w, int h);
+ void setFixedWidth(int w);
+ void setFixedHeight(int h);
+
+ // Widget coordinate mapping
+
+ QPoint mapToGlobal(const QPoint &) const;
+ QPoint mapFromGlobal(const QPoint &) const;
+ QPoint mapToParent(const QPoint &) const;
+ QPoint mapFromParent(const QPoint &) const;
+ QPoint mapTo(QWidget *, const QPoint &) const;
+ QPoint mapFrom(QWidget *, const QPoint &) const;
+
+ QWidget *window() const;
+ QWidget *nativeParentWidget() const;
+ inline QWidget *topLevelWidget() const { return window(); }
+
+ // Widget appearance functions
+ const QPalette &palette() const;
+ void setPalette(const QPalette &);
+
+ void setBackgroundRole(QPalette::ColorRole);
+ QPalette::ColorRole backgroundRole() const;
+
+ void setForegroundRole(QPalette::ColorRole);
+ QPalette::ColorRole foregroundRole() const;
+
+ const QFont &font() const;
+ void setFont(const QFont &);
+ QFontMetrics fontMetrics() const;
+ QFontInfo fontInfo() const;
+
+#ifndef QT_NO_CURSOR
+ QCursor cursor() const;
+ void setCursor(const QCursor &);
+ void unsetCursor();
+#endif
+
+ void setMouseTracking(bool enable);
+ bool hasMouseTracking() const;
+ bool underMouse() const;
+
+ void setMask(const QBitmap &);
+ void setMask(const QRegion &);
+ QRegion mask() const;
+ void clearMask();
+
+ void render(QPaintDevice *target, const QPoint &targetOffset = QPoint(),
+ const QRegion &sourceRegion = QRegion(),
+ RenderFlags renderFlags = RenderFlags(DrawWindowBackground | DrawChildren));
+
+ void render(QPainter *painter, const QPoint &targetOffset = QPoint(),
+ const QRegion &sourceRegion = QRegion(),
+ RenderFlags renderFlags = RenderFlags(DrawWindowBackground | DrawChildren));
+
+#ifndef QT_NO_GRAPHICSEFFECT
+ QGraphicsEffect *graphicsEffect() const;
+ void setGraphicsEffect(QGraphicsEffect *effect);
+#endif //QT_NO_GRAPHICSEFFECT
+
+#ifndef QT_NO_GESTURES
+ void grabGesture(Qt::GestureType type, Qt::GestureFlags flags = Qt::GestureFlags());
+ void ungrabGesture(Qt::GestureType type);
+#endif
+
+public Q_SLOTS:
+ void setWindowTitle(const QString &);
+#ifndef QT_NO_STYLE_STYLESHEET
+ void setStyleSheet(const QString& styleSheet);
+#endif
+public:
+#ifndef QT_NO_STYLE_STYLESHEET
+ QString styleSheet() const;
+#endif
+ QString windowTitle() const;
+ void setWindowIcon(const QIcon &icon);
+ QIcon windowIcon() const;
+ void setWindowIconText(const QString &);
+ QString windowIconText() const;
+ void setWindowRole(const QString &);
+ QString windowRole() const;
+ void setWindowFilePath(const QString &filePath);
+ QString windowFilePath() const;
+
+ void setWindowOpacity(qreal level);
+ qreal windowOpacity() const;
+
+ bool isWindowModified() const;
+#ifndef QT_NO_TOOLTIP
+ void setToolTip(const QString &);
+ QString toolTip() const;
+#endif
+#ifndef QT_NO_STATUSTIP
+ void setStatusTip(const QString &);
+ QString statusTip() const;
+#endif
+#ifndef QT_NO_WHATSTHIS
+ void setWhatsThis(const QString &);
+ QString whatsThis() const;
+#endif
+#ifndef QT_NO_ACCESSIBILITY
+ QString accessibleName() const;
+ void setAccessibleName(const QString &name);
+ QString accessibleDescription() const;
+ void setAccessibleDescription(const QString &description);
+#endif
+
+ void setLayoutDirection(Qt::LayoutDirection direction);
+ Qt::LayoutDirection layoutDirection() const;
+ void unsetLayoutDirection();
+
+ void setLocale(const QLocale &locale);
+ QLocale locale() const;
+ void unsetLocale();
+
+ inline bool isRightToLeft() const { return layoutDirection() == Qt::RightToLeft; }
+ inline bool isLeftToRight() const { return layoutDirection() == Qt::LeftToRight; }
+
+public Q_SLOTS:
+ inline void setFocus() { setFocus(Qt::OtherFocusReason); }
+
+public:
+ bool isActiveWindow() const;
+ void activateWindow();
+ void clearFocus();
+
+ void setFocus(Qt::FocusReason reason);
+ Qt::FocusPolicy focusPolicy() const;
+ void setFocusPolicy(Qt::FocusPolicy policy);
+ bool hasFocus() const;
+ static void setTabOrder(QWidget *, QWidget *);
+ void setFocusProxy(QWidget *);
+ QWidget *focusProxy() const;
+ Qt::ContextMenuPolicy contextMenuPolicy() const;
+ void setContextMenuPolicy(Qt::ContextMenuPolicy policy);
+
+ // Grab functions
+ void grabMouse();
+#ifndef QT_NO_CURSOR
+ void grabMouse(const QCursor &);
+#endif
+ void releaseMouse();
+ void grabKeyboard();
+ void releaseKeyboard();
+#ifndef QT_NO_SHORTCUT
+ int grabShortcut(const QKeySequence &key, Qt::ShortcutContext context = Qt::WindowShortcut);
+ void releaseShortcut(int id);
+ void setShortcutEnabled(int id, bool enable = true);
+ void setShortcutAutoRepeat(int id, bool enable = true);
+#endif
+ static QWidget *mouseGrabber();
+ static QWidget *keyboardGrabber();
+
+ // Update/refresh functions
+ inline bool updatesEnabled() const;
+ void setUpdatesEnabled(bool enable);
+
+#if 0 //def Q_WS_QWS
+ void repaintUnclipped(const QRegion &, bool erase = true);
+#endif
+
+#ifndef QT_NO_GRAPHICSVIEW
+ QGraphicsProxyWidget *graphicsProxyWidget() const;
+#endif
+
+public Q_SLOTS:
+ void update();
+ void repaint();
+
+public:
+ inline void update(int x, int y, int w, int h);
+ void update(const QRect&);
+ void update(const QRegion&);
+
+ void repaint(int x, int y, int w, int h);
+ void repaint(const QRect &);
+ void repaint(const QRegion &);
+
+public Q_SLOTS:
+ // Widget management functions
+
+ virtual void setVisible(bool visible);
+ inline void setHidden(bool hidden) { setVisible(!hidden); }
+#ifndef Q_WS_WINCE
+ inline void show() { setVisible(true); }
+#else
+ void show();
+#endif
+ inline void hide() { setVisible(false); }
+ inline QT_MOC_COMPAT void setShown(bool shown) { setVisible(shown); }
+
+ void showMinimized();
+ void showMaximized();
+ void showFullScreen();
+ void showNormal();
+
+ bool close();
+ void raise();
+ void lower();
+
+public:
+ void stackUnder(QWidget*);
+ void move(int x, int y);
+ void move(const QPoint &);
+ void resize(int w, int h);
+ void resize(const QSize &);
+ inline void setGeometry(int x, int y, int w, int h);
+ void setGeometry(const QRect &);
+ QByteArray saveGeometry() const;
+ bool restoreGeometry(const QByteArray &geometry);
+ void adjustSize();
+ bool isVisible() const;
+ bool isVisibleTo(QWidget*) const;
+ // ### Qt 5: bool isVisibleTo(_const_ QWidget *) const
+ inline bool isHidden() const;
+
+ bool isMinimized() const;
+ bool isMaximized() const;
+ bool isFullScreen() const;
+
+ Qt::WindowStates windowState() const;
+ void setWindowState(Qt::WindowStates state);
+ void overrideWindowState(Qt::WindowStates state);
+
+ virtual QSize sizeHint() const;
+ virtual QSize minimumSizeHint() const;
+
+ QSizePolicy sizePolicy() const;
+ void setSizePolicy(QSizePolicy);
+ inline void setSizePolicy(QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical);
+ virtual int heightForWidth(int) const;
+
+ QRegion visibleRegion() const;
+
+ void setContentsMargins(int left, int top, int right, int bottom);
+ void setContentsMargins(const QMargins &margins);
+ void getContentsMargins(int *left, int *top, int *right, int *bottom) const;
+ QMargins contentsMargins() const;
+
+ QRect contentsRect() const;
+
+public:
+ QLayout *layout() const;
+ void setLayout(QLayout *);
+ void updateGeometry();
+
+ void setParent(QWidget *parent);
+ void setParent(QWidget *parent, Qt::WindowFlags f);
+
+ void scroll(int dx, int dy);
+ void scroll(int dx, int dy, const QRect&);
+
+ // Misc. functions
+
+ QWidget *focusWidget() const;
+ QWidget *nextInFocusChain() const;
+ QWidget *previousInFocusChain() const;
+
+ // drag and drop
+ bool acceptDrops() const;
+ void setAcceptDrops(bool on);
+
+#ifndef QT_NO_ACTION
+ //actions
+ void addAction(QAction *action);
+ void addActions(QList<QAction*> actions);
+ void insertAction(QAction *before, QAction *action);
+ void insertActions(QAction *before, QList<QAction*> actions);
+ void removeAction(QAction *action);
+ QList<QAction*> actions() const;
+#endif
+
+ QWidget *parentWidget() const;
+
+ void setWindowFlags(Qt::WindowFlags type);
+ inline Qt::WindowFlags windowFlags() const;
+ void overrideWindowFlags(Qt::WindowFlags type);
+
+ inline Qt::WindowType windowType() const;
+
+ static QWidget *find(WId);
+#ifdef QT3_SUPPORT
+ static QT3_SUPPORT QWidgetMapper *wmapper();
+#endif
+ inline QWidget *childAt(int x, int y) const;
+ QWidget *childAt(const QPoint &p) const;
+
+#if defined(Q_WS_X11)
+ const QX11Info &x11Info() const;
+ Qt::HANDLE x11PictureHandle() const;
+#endif
+
+#if defined(Q_WS_MAC)
+ Qt::HANDLE macQDHandle() const;
+ Qt::HANDLE macCGHandle() const;
+#endif
+
+#if defined(Q_WS_WIN)
+ HDC getDC() const;
+ void releaseDC(HDC) const;
+#else
+ Qt::HANDLE handle() const;
+#endif
+
+ void setAttribute(Qt::WidgetAttribute, bool on = true);
+ inline bool testAttribute(Qt::WidgetAttribute) const;
+
+ QPaintEngine *paintEngine() const;
+
+ void ensurePolished() const;
+
+ QInputContext *inputContext();
+ void setInputContext(QInputContext *);
+
+ bool isAncestorOf(const QWidget *child) const;
+
+#ifdef QT_KEYPAD_NAVIGATION
+ bool hasEditFocus() const;
+ void setEditFocus(bool on);
+#endif
+
+ bool autoFillBackground() const;
+ void setAutoFillBackground(bool enabled);
+
+ void setWindowSurface(QWindowSurface *surface);
+ QWindowSurface *windowSurface() const;
+
+#if defined(Q_WS_QPA)
+ void setWindowHandle(QWindow *window);
+ QWindow *windowHandle() const;
+
+ friend class QDesktopScreenWidget;
+#endif
+
+Q_SIGNALS:
+ void customContextMenuRequested(const QPoint &pos);
+
+protected:
+ // Event handlers
+ bool event(QEvent *);
+ virtual void mousePressEvent(QMouseEvent *);
+ virtual void mouseReleaseEvent(QMouseEvent *);
+ virtual void mouseDoubleClickEvent(QMouseEvent *);
+ virtual void mouseMoveEvent(QMouseEvent *);
+#ifndef QT_NO_WHEELEVENT
+ virtual void wheelEvent(QWheelEvent *);
+#endif
+ virtual void keyPressEvent(QKeyEvent *);
+ virtual void keyReleaseEvent(QKeyEvent *);
+ virtual void focusInEvent(QFocusEvent *);
+ virtual void focusOutEvent(QFocusEvent *);
+ virtual void enterEvent(QEvent *);
+ virtual void leaveEvent(QEvent *);
+ virtual void paintEvent(QPaintEvent *);
+ virtual void moveEvent(QMoveEvent *);
+ virtual void resizeEvent(QResizeEvent *);
+ virtual void closeEvent(QCloseEvent *);
+#ifndef QT_NO_CONTEXTMENU
+ virtual void contextMenuEvent(QContextMenuEvent *);
+#endif
+#ifndef QT_NO_TABLETEVENT
+ virtual void tabletEvent(QTabletEvent *);
+#endif
+#ifndef QT_NO_ACTION
+ virtual void actionEvent(QActionEvent *);
+#endif
+
+#ifndef QT_NO_DRAGANDDROP
+ virtual void dragEnterEvent(QDragEnterEvent *);
+ virtual void dragMoveEvent(QDragMoveEvent *);
+ virtual void dragLeaveEvent(QDragLeaveEvent *);
+ virtual void dropEvent(QDropEvent *);
+#endif
+
+ virtual void showEvent(QShowEvent *);
+ virtual void hideEvent(QHideEvent *);
+
+#if defined(Q_WS_MAC)
+ virtual bool macEvent(EventHandlerCallRef, EventRef);
+#endif
+#if defined(Q_WS_WIN)
+ virtual bool winEvent(MSG *message, long *result);
+#endif
+#if defined(Q_WS_X11)
+ virtual bool x11Event(XEvent *);
+#endif
+#if defined(Q_WS_QWS)
+ virtual bool qwsEvent(QWSEvent *);
+#endif
+
+ // Misc. protected functions
+ virtual void changeEvent(QEvent *);
+
+ int metric(PaintDeviceMetric) const;
+ void init(QPainter *painter) const;
+ QPaintDevice *redirected(QPoint *offset) const;
+ QPainter *sharedPainter() const;
+
+ virtual void inputMethodEvent(QInputMethodEvent *);
+public:
+ virtual QVariant inputMethodQuery(Qt::InputMethodQuery) const;
+
+ Qt::InputMethodHints inputMethodHints() const;
+ void setInputMethodHints(Qt::InputMethodHints hints);
+
+protected:
+ void resetInputContext();
+protected Q_SLOTS:
+ void updateMicroFocus();
+protected:
+
+ void create(WId = 0, bool initializeWindow = true,
+ bool destroyOldWindow = true);
+ void destroy(bool destroyWindow = true,
+ bool destroySubWindows = true);
+
+ virtual bool focusNextPrevChild(bool next);
+ inline bool focusNextChild() { return focusNextPrevChild(true); }
+ inline bool focusPreviousChild() { return focusNextPrevChild(false); }
+
+protected:
+ QWidget(QWidgetPrivate &d, QWidget* parent, Qt::WindowFlags f);
+private:
+
+ bool testAttribute_helper(Qt::WidgetAttribute) const;
+
+ QLayout *takeLayout();
+
+ friend class QBackingStoreDevice;
+ friend class QWidgetBackingStore;
+ friend class QApplication;
+ friend class QApplicationPrivate;
+ friend class QGuiApplication;
+ friend class QGuiApplicationPrivate;
+ friend class QBaseApplication;
+ friend class QPainter;
+ friend class QPainterPrivate;
+ friend class QPixmap; // for QPixmap::fill()
+ friend class QFontMetrics;
+ friend class QFontInfo;
+ friend class QETWidget;
+ friend class QLayout;
+ friend class QWidgetItem;
+ friend class QWidgetItemV2;
+ friend class QGLContext;
+ friend class QGLWidget;
+ friend class QGLWindowSurface;
+ friend class QX11PaintEngine;
+ friend class QWin32PaintEngine;
+ friend class QShortcutPrivate;
+ friend class QShortcutMap;
+ friend class QWindowSurface;
+ friend class QGraphicsProxyWidget;
+ friend class QGraphicsProxyWidgetPrivate;
+ friend class QStyleSheetStyle;
+ friend struct QWidgetExceptionCleaner;
+ friend class QWidgetWindow;
+#ifndef QT_NO_GESTURES
+ friend class QGestureManager;
+ friend class QWinNativePanGestureRecognizer;
+#endif // QT_NO_GESTURES
+ friend class QWidgetEffectSourcePrivate;
+
+#ifdef Q_WS_MAC
+ friend class QCoreGraphicsPaintEnginePrivate;
+ friend QPoint qt_mac_posInWindow(const QWidget *w);
+ friend OSWindowRef qt_mac_window_for(const QWidget *w);
+ friend bool qt_mac_is_metal(const QWidget *w);
+ friend OSViewRef qt_mac_nativeview_for(const QWidget *w);
+ friend void qt_event_request_window_change(QWidget *widget);
+ friend bool qt_mac_sendMacEventToWidget(QWidget *widget, EventRef ref);
+ friend class QRasterWindowSurface;
+ friend class QUnifiedToolbarSurface;
+#endif
+#ifdef Q_WS_QWS
+ friend class QWSBackingStore;
+ friend class QWSManager;
+ friend class QWSManagerPrivate;
+ friend class QDecoration;
+ friend class QWSWindowSurface;
+ friend class QScreen;
+ friend class QVNCScreen;
+ friend bool isWidgetOpaque(const QWidget *);
+ friend class QGLWidgetPrivate;
+#endif
+#ifdef Q_OS_SYMBIAN
+ friend class QSymbianControl;
+ friend class QS60WindowSurface;
+#endif
+#ifdef Q_WS_X11
+ friend void qt_net_update_user_time(QWidget *tlw, unsigned long timestamp);
+ friend void qt_net_remove_user_time(QWidget *tlw);
+ friend void qt_set_winid_on_widget(QWidget*, Qt::HANDLE);
+#endif
+
+ friend Q_GUI_EXPORT QWidgetData *qt_qwidget_data(QWidget *widget);
+ friend Q_GUI_EXPORT QWidgetPrivate *qt_widget_private(QWidget *widget);
+
+private:
+ Q_DISABLE_COPY(QWidget)
+ Q_PRIVATE_SLOT(d_func(), void _q_showIfNotHidden())
+#ifdef Q_OS_SYMBIAN
+ Q_PRIVATE_SLOT(d_func(), void _q_delayedDestroy(WId winId))
+#endif
+
+ QWidgetData *data;
+
+#ifdef QT3_SUPPORT
+public:
+ inline QT3_SUPPORT bool isUpdatesEnabled() const { return updatesEnabled(); }
+ QT3_SUPPORT QStyle *setStyle(const QString&);
+ inline QT3_SUPPORT bool isVisibleToTLW() const;
+ QT3_SUPPORT QRect visibleRect() const;
+ inline QT3_SUPPORT void iconify() { showMinimized(); }
+ inline QT3_SUPPORT void constPolish() const { ensurePolished(); }
+ inline QT3_SUPPORT void polish() { ensurePolished(); }
+ inline QT3_SUPPORT void reparent(QWidget *parent, Qt::WindowFlags f, const QPoint &p, bool showIt=false)
+ { setParent(parent, f); setGeometry(p.x(),p.y(),width(),height()); if (showIt) show(); }
+ inline QT3_SUPPORT void reparent(QWidget *parent, const QPoint &p, bool showIt=false)
+ { setParent(parent, windowFlags() & ~Qt::WindowType_Mask); setGeometry(p.x(),p.y(),width(),height()); if (showIt) show(); }
+ inline QT3_SUPPORT void recreate(QWidget *parent, Qt::WindowFlags f, const QPoint & p, bool showIt=false)
+ { setParent(parent, f); setGeometry(p.x(),p.y(),width(),height()); if (showIt) show(); }
+ inline QT3_SUPPORT void setSizePolicy(QSizePolicy::Policy hor, QSizePolicy::Policy ver, bool hfw)
+ { QSizePolicy sp(hor, ver); sp.setHeightForWidth(hfw); setSizePolicy(sp);}
+ inline QT3_SUPPORT bool hasMouse() const { return testAttribute(Qt::WA_UnderMouse); }
+#ifndef QT_NO_CURSOR
+ inline QT3_SUPPORT bool ownCursor() const { return testAttribute(Qt::WA_SetCursor); }
+#endif
+ inline QT3_SUPPORT bool ownFont() const { return testAttribute(Qt::WA_SetFont); }
+ inline QT3_SUPPORT void unsetFont() { setFont(QFont()); }
+ inline QT3_SUPPORT bool ownPalette() const { return testAttribute(Qt::WA_SetPalette); }
+ inline QT3_SUPPORT void unsetPalette() { setPalette(QPalette()); }
+ Qt::BackgroundMode QT3_SUPPORT backgroundMode() const;
+ void QT3_SUPPORT setBackgroundMode(Qt::BackgroundMode, Qt::BackgroundMode = Qt::PaletteBackground);
+ const QT3_SUPPORT QColor &eraseColor() const;
+ void QT3_SUPPORT setEraseColor(const QColor &);
+ const QT3_SUPPORT QColor &foregroundColor() const;
+ const QT3_SUPPORT QPixmap *erasePixmap() const;
+ void QT3_SUPPORT setErasePixmap(const QPixmap &);
+ const QT3_SUPPORT QColor &paletteForegroundColor() const;
+ void QT3_SUPPORT setPaletteForegroundColor(const QColor &);
+ const QT3_SUPPORT QColor &paletteBackgroundColor() const;
+ void QT3_SUPPORT setPaletteBackgroundColor(const QColor &);
+ const QT3_SUPPORT QPixmap *paletteBackgroundPixmap() const;
+ void QT3_SUPPORT setPaletteBackgroundPixmap(const QPixmap &);
+ const QT3_SUPPORT QBrush& backgroundBrush() const;
+ const QT3_SUPPORT QColor &backgroundColor() const;
+ const QT3_SUPPORT QPixmap *backgroundPixmap() const;
+ void QT3_SUPPORT setBackgroundPixmap(const QPixmap &);
+ QT3_SUPPORT void setBackgroundColor(const QColor &);
+ QT3_SUPPORT QWidget *parentWidget(bool sameWindow) const;
+ inline QT3_SUPPORT void setKeyCompression(bool b) { setAttribute(Qt::WA_KeyCompression, b); }
+ inline QT3_SUPPORT void setFont(const QFont &f, bool) { setFont(f); }
+ inline QT3_SUPPORT void setPalette(const QPalette &p, bool) { setPalette(p); }
+ enum BackgroundOrigin { WidgetOrigin, ParentOrigin, WindowOrigin, AncestorOrigin };
+ inline QT3_SUPPORT void setBackgroundOrigin(BackgroundOrigin) {}
+ inline QT3_SUPPORT BackgroundOrigin backgroundOrigin() const { return WindowOrigin; }
+ inline QT3_SUPPORT QPoint backgroundOffset() const { return QPoint(); }
+ inline QT3_SUPPORT void repaint(bool) { repaint(); }
+ inline QT3_SUPPORT void repaint(int x, int y, int w, int h, bool) { repaint(x,y,w,h); }
+ inline QT3_SUPPORT void repaint(const QRect &r, bool) { repaint(r); }
+ inline QT3_SUPPORT void repaint(const QRegion &rgn, bool) { repaint(rgn); }
+ QT3_SUPPORT void erase();
+ inline QT3_SUPPORT void erase(int x, int y, int w, int h) { erase_helper(x, y, w, h); }
+ QT3_SUPPORT void erase(const QRect &);
+ QT3_SUPPORT void erase(const QRegion &);
+ QT3_SUPPORT void drawText(const QPoint &p, const QString &s)
+ { drawText_helper(p.x(), p.y(), s); }
+ inline QT3_SUPPORT void drawText(int x, int y, const QString &s)
+ { drawText_helper(x, y, s); }
+ QT3_SUPPORT bool close(bool);
+ inline QT3_SUPPORT QWidget *childAt(int x, int y, bool includeThis) const
+ {
+ QWidget *w = childAt(x, y);
+ return w ? w : ((includeThis && rect().contains(x,y))?const_cast<QWidget*>(this):0);
+ }
+ inline QT3_SUPPORT QWidget *childAt(const QPoint &p, bool includeThis) const
+ {
+ QWidget *w = childAt(p);
+ return w ? w : ((includeThis && rect().contains(p))?const_cast<QWidget*>(this):0);
+ }
+ inline QT3_SUPPORT void setCaption(const QString &c) { setWindowTitle(c); }
+ QT3_SUPPORT void setIcon(const QPixmap &i);
+ inline QT3_SUPPORT void setIconText(const QString &it) { setWindowIconText(it); }
+ inline QT3_SUPPORT QString caption() const { return windowTitle(); }
+ QT3_SUPPORT const QPixmap *icon() const;
+ inline QT3_SUPPORT QString iconText() const { return windowIconText(); }
+ inline QT3_SUPPORT void setInputMethodEnabled(bool b) { setAttribute(Qt::WA_InputMethodEnabled, b); }
+ inline QT3_SUPPORT bool isInputMethodEnabled() const { return testAttribute(Qt::WA_InputMethodEnabled); }
+ inline QT3_SUPPORT void setActiveWindow() { activateWindow(); }
+ inline QT3_SUPPORT bool isShown() const { return !isHidden(); }
+ inline QT3_SUPPORT bool isDialog() const { return windowType() == Qt::Dialog; }
+ inline QT3_SUPPORT bool isPopup() const { return windowType() == Qt::Popup; }
+ inline QT3_SUPPORT bool isDesktop() const { return windowType() == Qt::Desktop; }
+
+
+private:
+ void drawText_helper(int x, int y, const QString &);
+ void erase_helper(int x, int y, int w, int h);
+#endif // QT3_SUPPORT
+
+protected:
+ virtual void styleChange(QStyle&); // compat
+ virtual void enabledChange(bool); // compat
+ virtual void paletteChange(const QPalette &); // compat
+ virtual void fontChange(const QFont &); // compat
+ virtual void windowActivationChange(bool); // compat
+ virtual void languageChange(); // compat
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QWidget::RenderFlags)
+
+template <> inline QWidget *qobject_cast<QWidget*>(QObject *o)
+{
+ if (!o || !o->isWidgetType()) return 0;
+ return static_cast<QWidget*>(o);
+}
+template <> inline const QWidget *qobject_cast<const QWidget*>(const QObject *o)
+{
+ if (!o || !o->isWidgetType()) return 0;
+ return static_cast<const QWidget*>(o);
+}
+
+inline QWidget *QWidget::childAt(int ax, int ay) const
+{ return childAt(QPoint(ax, ay)); }
+
+inline Qt::WindowType QWidget::windowType() const
+{ return static_cast<Qt::WindowType>(int(data->window_flags & Qt::WindowType_Mask)); }
+inline Qt::WindowFlags QWidget::windowFlags() const
+{ return data->window_flags; }
+
+inline bool QWidget::isTopLevel() const
+{ return (windowType() & Qt::Window); }
+
+inline bool QWidget::isWindow() const
+{ return (windowType() & Qt::Window); }
+
+inline bool QWidget::isEnabled() const
+{ return !testAttribute(Qt::WA_Disabled); }
+
+inline bool QWidget::isModal() const
+{ return data->window_modality != Qt::NonModal; }
+
+inline bool QWidget::isEnabledToTLW() const
+{ return isEnabled(); }
+
+inline int QWidget::minimumWidth() const
+{ return minimumSize().width(); }
+
+inline int QWidget::minimumHeight() const
+{ return minimumSize().height(); }
+
+inline int QWidget::maximumWidth() const
+{ return maximumSize().width(); }
+
+inline int QWidget::maximumHeight() const
+{ return maximumSize().height(); }
+
+inline void QWidget::setMinimumSize(const QSize &s)
+{ setMinimumSize(s.width(),s.height()); }
+
+inline void QWidget::setMaximumSize(const QSize &s)
+{ setMaximumSize(s.width(),s.height()); }
+
+inline void QWidget::setSizeIncrement(const QSize &s)
+{ setSizeIncrement(s.width(),s.height()); }
+
+inline void QWidget::setBaseSize(const QSize &s)
+{ setBaseSize(s.width(),s.height()); }
+
+inline const QFont &QWidget::font() const
+{ return data->fnt; }
+
+inline QFontMetrics QWidget::fontMetrics() const
+{ return QFontMetrics(data->fnt); }
+
+inline QFontInfo QWidget::fontInfo() const
+{ return QFontInfo(data->fnt); }
+
+inline void QWidget::setMouseTracking(bool enable)
+{ setAttribute(Qt::WA_MouseTracking, enable); }
+
+inline bool QWidget::hasMouseTracking() const
+{ return testAttribute(Qt::WA_MouseTracking); }
+
+inline bool QWidget::underMouse() const
+{ return testAttribute(Qt::WA_UnderMouse); }
+
+inline bool QWidget::updatesEnabled() const
+{ return !testAttribute(Qt::WA_UpdatesDisabled); }
+
+inline void QWidget::update(int ax, int ay, int aw, int ah)
+{ update(QRect(ax, ay, aw, ah)); }
+
+inline bool QWidget::isVisible() const
+{ return testAttribute(Qt::WA_WState_Visible); }
+
+inline bool QWidget::isHidden() const
+{ return testAttribute(Qt::WA_WState_Hidden); }
+
+inline void QWidget::move(int ax, int ay)
+{ move(QPoint(ax, ay)); }
+
+inline void QWidget::resize(int w, int h)
+{ resize(QSize(w, h)); }
+
+inline void QWidget::setGeometry(int ax, int ay, int aw, int ah)
+{ setGeometry(QRect(ax, ay, aw, ah)); }
+
+inline QRect QWidget::rect() const
+{ return QRect(0,0,data->crect.width(),data->crect.height()); }
+
+inline const QRect &QWidget::geometry() const
+{ return data->crect; }
+
+inline QSize QWidget::size() const
+{ return data->crect.size(); }
+
+inline int QWidget::width() const
+{ return data->crect.width(); }
+
+inline int QWidget::height() const
+{ return data->crect.height(); }
+
+inline QWidget *QWidget::parentWidget() const
+{ return static_cast<QWidget *>(QObject::parent()); }
+
+inline void QWidget::setSizePolicy(QSizePolicy::Policy hor, QSizePolicy::Policy ver)
+{ setSizePolicy(QSizePolicy(hor, ver)); }
+
+inline bool QWidget::testAttribute(Qt::WidgetAttribute attribute) const
+{
+ if (attribute < int(8*sizeof(uint)))
+ return data->widget_attributes & (1<<attribute);
+ return testAttribute_helper(attribute);
+}
+
+#ifdef QT3_SUPPORT
+inline bool QWidget::isVisibleToTLW() const
+{ return isVisible(); }
+inline QWidget *QWidget::parentWidget(bool sameWindow) const
+{
+ if (sameWindow && isWindow())
+ return 0;
+ return static_cast<QWidget *>(QObject::parent());
+}
+inline void QWidget::setPaletteForegroundColor(const QColor &c)
+{ QPalette p = palette(); p.setColor(foregroundRole(), c); setPalette(p); }
+inline const QBrush& QWidget::backgroundBrush() const { return palette().brush(backgroundRole()); }
+inline void QWidget::setBackgroundPixmap(const QPixmap &pm)
+{ QPalette p = palette(); p.setBrush(backgroundRole(), QBrush(pm)); setPalette(p); }
+inline const QPixmap *QWidget::backgroundPixmap() const { return 0; }
+inline void QWidget::setBackgroundColor(const QColor &c)
+{ QPalette p = palette(); p.setColor(backgroundRole(), c); setPalette(p); }
+inline const QColor & QWidget::backgroundColor() const { return palette().color(backgroundRole()); }
+inline const QColor &QWidget::foregroundColor() const { return palette().color(foregroundRole());}
+inline const QColor &QWidget::eraseColor() const { return palette().color(backgroundRole()); }
+inline void QWidget::setEraseColor(const QColor &c)
+{ QPalette p = palette(); p.setColor(backgroundRole(), c); setPalette(p); }
+inline const QPixmap *QWidget::erasePixmap() const { return 0; }
+inline void QWidget::setErasePixmap(const QPixmap &pm)
+{ QPalette p = palette(); p.setBrush(backgroundRole(), QBrush(pm)); setPalette(p); }
+inline const QColor &QWidget::paletteForegroundColor() const { return palette().color(foregroundRole());}
+inline const QColor &QWidget::paletteBackgroundColor() const { return palette().color(backgroundRole()); }
+inline void QWidget::setPaletteBackgroundColor(const QColor &c)
+{ QPalette p = palette(); p.setColor(backgroundRole(), c); setPalette(p); }
+inline const QPixmap *QWidget::paletteBackgroundPixmap() const
+{ return 0; }
+inline void QWidget::setPaletteBackgroundPixmap(const QPixmap &pm)
+{ QPalette p = palette(); p.setBrush(backgroundRole(), QBrush(pm)); setPalette(p); }
+inline QT3_SUPPORT void QWidget::erase() { erase_helper(0, 0, data->crect.width(), data->crect.height()); }
+inline QT3_SUPPORT void QWidget::erase(const QRect &r) { erase_helper(r.x(), r.y(), r.width(), r.height()); }
+#endif
+
+#define QWIDGETSIZE_MAX ((1<<24)-1)
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QWIDGET_H
diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h
new file mode 100644
index 0000000000..e9d7682289
--- /dev/null
+++ b/src/widgets/kernel/qwidget_p.h
@@ -0,0 +1,1034 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWIDGET_P_H
+#define QWIDGET_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header
+// file may change from version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "QtWidgets/qwidget.h"
+#include "private/qobject_p.h"
+#include "QtCore/qrect.h"
+#include "QtCore/qlocale.h"
+#include "QtCore/qset.h"
+#include "QtGui/qregion.h"
+#include "QtWidgets/qsizepolicy.h"
+#include "QtWidgets/qstyle.h"
+#include "QtWidgets/qapplication.h"
+#include <private/qgraphicseffect_p.h>
+#include "QtWidgets/qgraphicsproxywidget.h"
+#include "QtWidgets/qgraphicsscene.h"
+#include "QtWidgets/qgraphicsview.h"
+#include <private/qgesture_p.h>
+
+#ifdef Q_WS_WIN
+#include "QtCore/qt_windows.h"
+#include <private/qdnd_p.h>
+#endif // Q_WS_WIN
+
+#ifdef Q_WS_X11
+#include "QtGui/qx11info_x11.h"
+#endif
+
+#ifdef Q_WS_MAC
+#include <private/qt_mac_p.h>
+#endif
+
+#if defined(Q_WS_QWS)
+#include "QtWidgets/qinputcontext.h"
+#include "QtGui/qscreen_qws.h"
+#endif
+
+#if defined(Q_OS_SYMBIAN)
+class RDrawableWindow;
+class CCoeControl;
+#endif
+
+QT_BEGIN_NAMESPACE
+
+// Extra QWidget data
+// - to minimize memory usage for members that are seldom used.
+// - top-level widgets have extra extra data to reduce cost further
+#if defined(Q_WS_QWS)
+class QWSManager;
+#endif
+#if defined(Q_WS_MAC)
+class QCoreGraphicsPaintEnginePrivate;
+#endif
+#if defined(Q_WS_QPA)
+class QWidgetWindow;
+#endif
+class QPaintEngine;
+class QPixmap;
+class QWidgetBackingStore;
+class QGraphicsProxyWidget;
+class QWidgetItemV2;
+
+class QStyle;
+
+class QUnifiedToolbarSurface;
+
+class Q_AUTOTEST_EXPORT QWidgetBackingStoreTracker
+{
+
+public:
+ QWidgetBackingStoreTracker();
+ ~QWidgetBackingStoreTracker();
+
+ void create(QWidget *tlw);
+ void destroy();
+
+ void registerWidget(QWidget *w);
+ void unregisterWidget(QWidget *w);
+ void unregisterWidgetSubtree(QWidget *w);
+
+ inline QWidgetBackingStore* data()
+ {
+ return m_ptr;
+ }
+
+ inline QWidgetBackingStore* operator->()
+ {
+ return m_ptr;
+ }
+
+ inline QWidgetBackingStore& operator*()
+ {
+ return *m_ptr;
+ }
+
+ inline operator bool() const
+ {
+ return (0 != m_ptr);
+ }
+
+private:
+ Q_DISABLE_COPY(QWidgetBackingStoreTracker)
+
+private:
+ QWidgetBackingStore* m_ptr;
+ QSet<QWidget *> m_widgets;
+};
+
+struct QTLWExtra {
+ // *************************** Cross-platform variables *****************************
+
+ // Regular pointers (keep them together to avoid gaps on 64 bits architectures).
+ QIcon *icon; // widget icon
+ QPixmap *iconPixmap;
+ QWidgetBackingStoreTracker backingStore;
+ QWindowSurface *windowSurface;
+ QPainter *sharedPainter;
+
+ // Implicit pointers (shared_null).
+ QString caption; // widget caption
+ QString iconText; // widget icon text
+ QString role; // widget role
+ QString filePath; // widget file path
+
+ // Other variables.
+ short incw, inch; // size increments
+ short basew, baseh; // base sizes
+ // frame strut, don't use these directly, use QWidgetPrivate::frameStrut() instead.
+ QRect frameStrut;
+ QRect normalGeometry; // used by showMin/maximized/FullScreen
+ Qt::WindowFlags savedFlags; // Save widget flags while showing fullscreen
+
+ // *************************** Cross-platform bit fields ****************************
+ uint opacity : 8;
+ uint posFromMove : 1;
+ uint sizeAdjusted : 1;
+ uint inTopLevelResize : 1;
+ uint inRepaint : 1;
+ uint embedded : 1;
+
+ // *************************** Platform specific values (bit fields first) **********
+#if defined(Q_WS_X11) // <----------------------------------------------------------- X11
+ uint spont_unmapped: 1; // window was spontaneously unmapped
+ uint dnd : 1; // DND properties installed
+ uint validWMState : 1; // is WM_STATE valid?
+ uint waitingForMapNotify : 1; // show() has been called, haven't got the MapNotify yet
+ WId parentWinId; // parent window Id (valid after reparenting)
+ WId userTimeWindow; // window id that contains user-time timestamp when WM supports a _NET_WM_USER_TIME_WINDOW atom
+ QPoint fullScreenOffset;
+#ifndef QT_NO_XSYNC
+ WId syncUpdateCounter;
+ ulong syncRequestTimestamp;
+ qint32 newCounterValueHi;
+ quint32 newCounterValueLo;
+#endif
+#elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN
+ uint hotkeyRegistered: 1; // Hot key from the STARTUPINFO has been registered.
+ HICON winIconBig; // internal big Windows icon
+ HICON winIconSmall; // internal small Windows icon
+#elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC
+ uint resizer : 4;
+ uint isSetGeometry : 1;
+ uint isMove : 1;
+ quint32 wattr;
+ quint32 wclass;
+ WindowGroupRef group;
+ IconRef windowIcon; // the current window icon, if set with setWindowIcon_sys.
+ quint32 savedWindowAttributesFromMaximized; // Saved attributes from when the calling updateMaximizeButton_sys()
+#ifdef QT_MAC_USE_COCOA
+ // This value is just to make sure we maximize and restore to the right location, yet we allow apps to be maximized and
+ // manually resized.
+ // The name is misleading, since this is set when maximizing the window. It is a hint to saveGeometry(..) to record the
+ // starting position as 0,0 instead of the normal starting position.
+ bool wasMaximized;
+#endif // QT_MAC_USE_COCOA
+
+#elif defined(Q_WS_QWS) // <--------------------------------------------------------- QWS
+#ifndef QT_NO_QWS_MANAGER
+ QWSManager *qwsManager;
+#endif
+#elif defined(Q_OS_SYMBIAN)
+ uint inExpose : 1; // Prevents drawing recursion
+ uint nativeWindowTransparencyEnabled : 1; // Tracks native window transparency
+#elif defined(Q_WS_QPA)
+ QWidgetWindow *window;
+ quint32 screenIndex; // index in qplatformscreenlist
+#endif
+};
+
+struct QWExtra {
+ // *************************** Cross-platform variables *****************************
+
+ // Regular pointers (keep them together to avoid gaps on 64 bits architectures).
+ void *glContext; // if the widget is hijacked by QGLWindowSurface
+ QTLWExtra *topextra; // only useful for TLWs
+#ifndef QT_NO_GRAPHICSVIEW
+ QGraphicsProxyWidget *proxyWidget; // if the widget is embedded
+#endif
+#ifndef QT_NO_CURSOR
+ QCursor *curs;
+#endif
+ QPointer<QStyle> style;
+ QPointer<QWidget> focus_proxy;
+
+ // Implicit pointers (shared_empty/shared_null).
+ QRegion mask; // widget mask
+ QString styleSheet;
+
+ // Other variables.
+ qint32 minw;
+ qint32 minh; // minimum size
+ qint32 maxw;
+ qint32 maxh; // maximum size
+ quint16 customDpiX;
+ quint16 customDpiY;
+ QSize staticContentsSize;
+
+ // *************************** Cross-platform bit fields ****************************
+ uint explicitMinSize : 2;
+ uint explicitMaxSize : 2;
+ uint autoFillBackground : 1;
+ uint nativeChildrenForced : 1;
+ uint inRenderWithPainter : 1;
+ uint hasMask : 1;
+
+ // *************************** Platform specific values (bit fields first) **********
+#if defined(Q_WS_WIN) // <----------------------------------------------------------- WIN
+#ifndef QT_NO_DRAGANDDROP
+ QOleDropTarget *dropTarget; // drop target
+ QList<QPointer<QWidget> > oleDropWidgets;
+#endif
+#elif defined(Q_WS_X11) // <--------------------------------------------------------- X11
+ uint compress_events : 1;
+ WId xDndProxy; // XDND forwarding to embedded windows
+#elif defined(Q_WS_MAC) // <------------------------------------------------------ MAC
+#ifdef QT_MAC_USE_COCOA
+ // Cocoa Mask stuff
+ QImage maskBits;
+ CGImageRef imageMask;
+#endif
+#elif defined(Q_OS_SYMBIAN) // <----------------------------------------------------- Symbian
+ uint activated : 1; // RWindowBase::Activated has been called
+
+ /**
+ * If this bit is set, each native widget receives the signals from the
+ * Symbian control immediately before and immediately after draw ops are
+ * sent to the window server for this control:
+ * void beginNativePaintEvent(const QRect &paintRect);
+ * void endNativePaintEvent(const QRect &paintRect);
+ */
+ uint receiveNativePaintEvents : 1;
+
+ /**
+ * Defines the behaviour of QSymbianControl::Draw.
+ */
+ enum NativePaintMode {
+ /**
+ * Normal drawing mode: blits the required region of the backing store
+ * via WSERV.
+ */
+ Blit,
+
+ /**
+ * Disable drawing for this widget.
+ */
+ Disable,
+
+ /**
+ * Paint zeros into the WSERV framebuffer, using BitGDI APIs. For windows
+ * with an EColor16MU display mode, zero is written only into the R, G and B
+ * channels of the pixel.
+ */
+ ZeroFill,
+
+ /**
+ * Blit backing store, propagating alpha channel into the framebuffer.
+ */
+ BlitWriteAlpha,
+
+ Default = Blit
+ };
+
+ NativePaintMode nativePaintMode;
+
+#endif
+};
+
+/*!
+ \internal
+
+ Returns true if \a p or any of its parents enable the
+ Qt::BypassGraphicsProxyWidget window flag. Used in QWidget::show() and
+ QWidget::setParent() to determine whether it's necessary to embed the
+ widget into a QGraphicsProxyWidget or not.
+*/
+static inline bool bypassGraphicsProxyWidget(const QWidget *p)
+{
+ while (p) {
+ if (p->windowFlags() & Qt::BypassGraphicsProxyWidget)
+ return true;
+ p = p->parentWidget();
+ }
+ return false;
+}
+
+class Q_GUI_EXPORT QWidgetPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QWidget)
+
+public:
+ // *************************** Cross-platform ***************************************
+ enum DrawWidgetFlags {
+ DrawAsRoot = 0x01,
+ DrawPaintOnScreen = 0x02,
+ DrawRecursive = 0x04,
+ DrawInvisible = 0x08,
+ DontSubtractOpaqueChildren = 0x10,
+ DontSetCompositionMode = 0x20,
+ DontDrawOpaqueChildren = 0x40,
+ DontDrawNativeChildren = 0x80
+ };
+
+ enum CloseMode {
+ CloseNoEvent,
+ CloseWithEvent,
+ CloseWithSpontaneousEvent
+ };
+
+ enum Direction {
+ DirectionNorth = 0x01,
+ DirectionEast = 0x10,
+ DirectionSouth = 0x02,
+ DirectionWest = 0x20
+ };
+
+ // Functions.
+ explicit QWidgetPrivate(int version = QObjectPrivateVersion);
+ ~QWidgetPrivate();
+
+ QWExtra *extraData() const;
+ QTLWExtra *topData() const;
+ QTLWExtra *maybeTopData() const;
+ QPainter *sharedPainter() const;
+ void setSharedPainter(QPainter *painter);
+ QWidgetBackingStore *maybeBackingStore() const;
+ void init(QWidget *desktopWidget, Qt::WindowFlags f);
+ void create_sys(WId window, bool initializeWindow, bool destroyOldWindow);
+ void createRecursively();
+ void createWinId(WId id = 0);
+
+ void createTLExtra();
+ void createExtra();
+ void deleteExtra();
+ void createSysExtra();
+ void deleteSysExtra();
+ void createTLSysExtra();
+ void deleteTLSysExtra();
+ void updateSystemBackground();
+ void propagatePaletteChange();
+
+ void setPalette_helper(const QPalette &);
+ void resolvePalette();
+ QPalette naturalWidgetPalette(uint inheritedMask) const;
+
+ void setMask_sys(const QRegion &);
+#ifdef Q_OS_SYMBIAN
+ void setSoftKeys_sys(const QList<QAction*> &softkeys);
+ void activateSymbianWindow(WId wid = 0);
+ void _q_delayedDestroy(WId winId);
+#endif
+
+ void raise_sys();
+ void lower_sys();
+ void stackUnder_sys(QWidget *);
+
+ void setFocus_sys();
+
+ void updateFont(const QFont &);
+ inline void setFont_helper(const QFont &font) {
+ if (data.fnt == font && data.fnt.resolve() == font.resolve())
+ return;
+ updateFont(font);
+ }
+ void resolveFont();
+ QFont naturalWidgetFont(uint inheritedMask) const;
+
+ void setLayoutDirection_helper(Qt::LayoutDirection);
+ void resolveLayoutDirection();
+
+ void setLocale_helper(const QLocale &l, bool forceUpdate = false);
+ void resolveLocale();
+
+ void setStyle_helper(QStyle *newStyle, bool propagate, bool metalHack = false);
+ void inheritStyle();
+
+ void setUpdatesEnabled_helper(bool );
+
+ void paintBackground(QPainter *, const QRegion &, int flags = DrawAsRoot) const;
+ bool isAboutToShow() const;
+ QRegion prepareToRender(const QRegion &region, QWidget::RenderFlags renderFlags);
+ void render_helper(QPainter *painter, const QPoint &targetOffset, const QRegion &sourceRegion,
+ QWidget::RenderFlags renderFlags);
+ void render(QPaintDevice *target, const QPoint &targetOffset, const QRegion &sourceRegion,
+ QWidget::RenderFlags renderFlags, bool readyToRender);
+ void drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QPoint &offset, int flags,
+ QPainter *sharedPainter = 0, QWidgetBackingStore *backingStore = 0);
+
+
+ void paintSiblingsRecursive(QPaintDevice *pdev, const QObjectList& children, int index,
+ const QRegion &rgn, const QPoint &offset, int flags
+#ifdef Q_BACKINGSTORE_SUBSURFACES
+ , const QWindowSurface *currentSurface
+#endif
+ , QPainter *sharedPainter, QWidgetBackingStore *backingStore);
+
+
+ QPainter *beginSharedPainter();
+ bool endSharedPainter();
+#ifndef QT_NO_GRAPHICSVIEW
+ static QGraphicsProxyWidget * nearestGraphicsProxyWidget(const QWidget *origin);
+#endif
+ QWindowSurface *createDefaultWindowSurface();
+ QWindowSurface *createDefaultWindowSurface_sys();
+ void repaint_sys(const QRegion &rgn);
+
+ QRect clipRect() const;
+ QRegion clipRegion() const;
+ void subtractOpaqueChildren(QRegion &rgn, const QRect &clipRect) const;
+ void subtractOpaqueSiblings(QRegion &source, bool *hasDirtySiblingsAbove = 0,
+ bool alsoNonOpaque = false) const;
+ void clipToEffectiveMask(QRegion &region) const;
+ void updateIsOpaque();
+ void setOpaque(bool opaque);
+ void updateIsTranslucent();
+ bool paintOnScreen() const;
+#ifndef QT_NO_GRAPHICSEFFECT
+ void invalidateGraphicsEffectsRecursively();
+#endif //QT_NO_GRAPHICSEFFECT
+
+ const QRegion &getOpaqueChildren() const;
+ void setDirtyOpaqueRegion();
+
+ bool close_helper(CloseMode mode);
+
+ void setWindowIcon_helper();
+ void setWindowIcon_sys(bool forceReset = false);
+ void setWindowOpacity_sys(qreal opacity);
+ void adjustQuitOnCloseAttribute();
+
+ void scrollChildren(int dx, int dy);
+ void moveRect(const QRect &, int dx, int dy);
+ void scrollRect(const QRect &, int dx, int dy);
+ void invalidateBuffer_resizeHelper(const QPoint &oldPos, const QSize &oldSize);
+ // ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore).
+ void invalidateBuffer(const QRegion &);
+ void invalidateBuffer(const QRect &);
+ bool isOverlapped(const QRect&) const;
+ void syncBackingStore();
+ void syncBackingStore(const QRegion &region);
+
+ void reparentFocusWidgets(QWidget *oldtlw);
+
+ static int pointToRect(const QPoint &p, const QRect &r);
+
+ void setWinId(WId);
+ void showChildren(bool spontaneous);
+ void hideChildren(bool spontaneous);
+ void setParent_sys(QWidget *parent, Qt::WindowFlags);
+ void scroll_sys(int dx, int dy);
+ void scroll_sys(int dx, int dy, const QRect &r);
+ void deactivateWidgetCleanup();
+ void setGeometry_sys(int, int, int, int, bool);
+ void sendPendingMoveAndResizeEvents(bool recursive = false, bool disableUpdates = false);
+ void activateChildLayoutsRecursively();
+ void show_recursive();
+ void show_helper();
+ void show_sys();
+ void hide_sys();
+ void hide_helper();
+ void _q_showIfNotHidden();
+
+ void setEnabled_helper(bool);
+ void registerDropSite(bool);
+ static void adjustFlags(Qt::WindowFlags &flags, QWidget *w = 0);
+
+ void updateFrameStrut();
+ QRect frameStrut() const;
+
+#ifdef QT_KEYPAD_NAVIGATION
+ static bool navigateToDirection(Direction direction);
+ static QWidget *widgetInNavigationDirection(Direction direction);
+ static bool canKeypadNavigate(Qt::Orientation orientation);
+ static bool inTabWidget(QWidget *widget);
+#endif
+
+ void setWindowIconText_sys(const QString &cap);
+ void setWindowIconText_helper(const QString &cap);
+ void setWindowTitle_sys(const QString &cap);
+
+#ifndef QT_NO_CURSOR
+ void setCursor_sys(const QCursor &cursor);
+ void unsetCursor_sys();
+#endif
+
+ void setWindowTitle_helper(const QString &cap);
+ void setWindowFilePath_helper(const QString &filePath);
+
+ bool setMinimumSize_helper(int &minw, int &minh);
+ bool setMaximumSize_helper(int &maxw, int &maxh);
+ virtual bool hasHeightForWidth() const;
+ void setConstraints_sys();
+ bool pointInsideRectAndMask(const QPoint &) const;
+ QWidget *childAt_helper(const QPoint &, bool) const;
+ QWidget *childAtRecursiveHelper(const QPoint &p, bool, bool includeFrame = false) const;
+ void updateGeometry_helper(bool forceUpdate);
+
+ void getLayoutItemMargins(int *left, int *top, int *right, int *bottom) const;
+ void setLayoutItemMargins(int left, int top, int right, int bottom);
+ void setLayoutItemMargins(QStyle::SubElement element, const QStyleOption *opt = 0);
+
+ // aboutToDestroy() is called just before the contents of
+ // QWidget::destroy() is executed. It's used to signal QWidget
+ // sub-classes that their internals are about to be released.
+ virtual void aboutToDestroy() {}
+
+ QInputContext *assignedInputContext() const;
+ QInputContext *inputContext() const;
+ inline QWidget *effectiveFocusWidget() {
+ QWidget *w = q_func();
+ while (w->focusProxy())
+ w = w->focusProxy();
+ return w;
+ }
+
+ void setModal_sys();
+
+ // This is an helper function that return the available geometry for
+ // a widget and takes care is this one is in QGraphicsView.
+ // If the widget is not embed in a scene then the geometry available is
+ // null, we let QDesktopWidget decide for us.
+ static QRect screenGeometry(const QWidget *widget)
+ {
+ QRect screen;
+#ifndef QT_NO_GRAPHICSVIEW
+ QGraphicsProxyWidget *ancestorProxy = widget->d_func()->nearestGraphicsProxyWidget(widget);
+ //It's embedded if it has an ancestor
+ if (ancestorProxy) {
+ if (!bypassGraphicsProxyWidget(widget) && ancestorProxy->scene() != 0) {
+ // One view, let be smart and return the viewport rect then the popup is aligned
+ if (ancestorProxy->scene()->views().size() == 1) {
+ QGraphicsView *view = ancestorProxy->scene()->views().at(0);
+ screen = view->mapToScene(view->viewport()->rect()).boundingRect().toRect();
+ } else {
+ screen = ancestorProxy->scene()->sceneRect().toRect();
+ }
+ }
+ }
+#endif
+ return screen;
+ }
+
+ inline void setRedirected(QPaintDevice *replacement, const QPoint &offset)
+ {
+ Q_ASSERT(q_func()->testAttribute(Qt::WA_WState_InPaintEvent));
+ redirectDev = replacement;
+ redirectOffset = offset;
+ }
+
+ inline QPaintDevice *redirected(QPoint *offset) const
+ {
+ if (offset)
+ *offset = redirectDev ? redirectOffset : QPoint();
+ return redirectDev;
+ }
+
+ inline void restoreRedirected()
+ { redirectDev = 0; }
+
+ inline void enforceNativeChildren()
+ {
+ if (!extra)
+ createExtra();
+
+ if (extra->nativeChildrenForced)
+ return;
+ extra->nativeChildrenForced = 1;
+
+ for (int i = 0; i < children.size(); ++i) {
+ if (QWidget *child = qobject_cast<QWidget *>(children.at(i)))
+ child->setAttribute(Qt::WA_NativeWindow);
+ }
+ }
+
+ inline bool nativeChildrenForced() const
+ {
+ return extra ? extra->nativeChildrenForced : false;
+ }
+
+ inline QRect effectiveRectFor(const QRect &rect) const
+ {
+#ifndef QT_NO_GRAPHICSEFFECT
+ if (graphicsEffect && graphicsEffect->isEnabled())
+ return graphicsEffect->boundingRectFor(rect).toAlignedRect();
+#endif //QT_NO_GRAPHICSEFFECT
+ return rect;
+ }
+
+ QSize adjustedSize() const;
+
+ inline void handleSoftwareInputPanel(Qt::MouseButton button, bool clickCausedFocus)
+ {
+ Q_Q(QWidget);
+ if (button == Qt::LeftButton && qApp->autoSipEnabled()) {
+ QStyle::RequestSoftwareInputPanel behavior = QStyle::RequestSoftwareInputPanel(
+ q->style()->styleHint(QStyle::SH_RequestSoftwareInputPanel));
+ if (!clickCausedFocus || behavior == QStyle::RSIP_OnMouseClick) {
+ QEvent event(QEvent::RequestSoftwareInputPanel);
+ QApplication::sendEvent(q, &event);
+ }
+ }
+ }
+
+#ifndef Q_WS_QWS // Almost cross-platform :-)
+ void setWSGeometry(bool dontShow=false, const QRect &oldRect = QRect());
+
+ inline QPoint mapToWS(const QPoint &p) const
+ { return p - data.wrect.topLeft(); }
+
+ inline QPoint mapFromWS(const QPoint &p) const
+ { return p + data.wrect.topLeft(); }
+
+ inline QRect mapToWS(const QRect &r) const
+ { QRect rr(r); rr.translate(-data.wrect.topLeft()); return rr; }
+
+ inline QRect mapFromWS(const QRect &r) const
+ { QRect rr(r); rr.translate(data.wrect.topLeft()); return rr; }
+#endif
+
+ // Variables.
+ // Regular pointers (keep them together to avoid gaps on 64 bit architectures).
+ QWExtra *extra;
+ QWidget *focus_next;
+ QWidget *focus_prev;
+ QWidget *focus_child;
+ QLayout *layout;
+ QRegion *needsFlush;
+ QPaintDevice *redirectDev;
+ QWidgetItemV2 *widgetItem;
+ QPaintEngine *extraPaintEngine;
+ mutable const QMetaObject *polished;
+ QGraphicsEffect *graphicsEffect;
+ // All widgets are added into the allWidgets set. Once
+ // they receive a window id they are also added to the mapper.
+ // This should just ensure that all widgets are deleted by QApplication
+ static QWidgetMapper *mapper;
+ static QWidgetSet *allWidgets;
+#if !defined(QT_NO_IM)
+ QPointer<QInputContext> ic;
+ Qt::InputMethodHints imHints;
+#endif
+#ifdef QT_KEYPAD_NAVIGATION
+ static QPointer<QWidget> editingWidget;
+#endif
+
+ // Implicit pointers (shared_null/shared_empty).
+ QRegion opaqueChildren;
+ QRegion dirty;
+#ifndef QT_NO_TOOLTIP
+ QString toolTip;
+#endif
+#ifndef QT_NO_STATUSTIP
+ QString statusTip;
+#endif
+#ifndef QT_NO_WHATSTHIS
+ QString whatsThis;
+#endif
+#ifndef QT_NO_ACCESSIBILITY
+ QString accessibleName;
+ QString accessibleDescription;
+#endif
+
+ // Other variables.
+ uint inheritedFontResolveMask;
+ uint inheritedPaletteResolveMask;
+ short leftmargin;
+ short topmargin;
+ short rightmargin;
+ short bottommargin;
+ signed char leftLayoutItemMargin;
+ signed char topLayoutItemMargin;
+ signed char rightLayoutItemMargin;
+ signed char bottomLayoutItemMargin;
+ static int instanceCounter; // Current number of widget instances
+ static int maxInstances; // Maximum number of widget instances
+ Qt::HANDLE hd;
+ QWidgetData data;
+ QSizePolicy size_policy;
+ QLocale locale;
+ QPoint redirectOffset;
+#ifndef QT_NO_ACTION
+ QList<QAction*> actions;
+#endif
+#ifndef QT_NO_GESTURES
+ QMap<Qt::GestureType, Qt::GestureFlags> gestureContext;
+#endif
+
+ // Bit fields.
+ uint high_attributes[4]; // the low ones are in QWidget::widget_attributes
+ QPalette::ColorRole fg_role : 8;
+ QPalette::ColorRole bg_role : 8;
+ uint dirtyOpaqueChildren : 1;
+ uint isOpaque : 1;
+ uint inDirtyList : 1;
+ uint isScrolled : 1;
+ uint isMoved : 1;
+ uint isGLWidget : 1;
+ uint usesDoubleBufferedGLContext : 1;
+#ifndef QT_NO_IM
+ uint inheritsInputMethodHints : 1;
+#endif
+
+ // *************************** Platform specific ************************************
+#if defined(Q_WS_X11) // <----------------------------------------------------------- X11
+ QX11Info xinfo;
+ Qt::HANDLE picture;
+ static QWidget *mouseGrabber;
+ static QWidget *keyboardGrabber;
+
+ void setWindowRole();
+ void sendStartupMessage(const char *message) const;
+ void setNetWmWindowTypes();
+ void x11UpdateIsOpaque();
+ bool isBackgroundInherited() const;
+ void updateX11AcceptFocus();
+ QPoint mapToGlobal(const QPoint &pos) const;
+ QPoint mapFromGlobal(const QPoint &pos) const;
+#elif defined(Q_WS_WIN) // <--------------------------------------------------------- WIN
+ uint noPaintOnScreen : 1; // see qwidget_win.cpp ::paintEngine()
+#ifndef QT_NO_GESTURES
+ uint nativeGesturePanEnabled : 1;
+#endif
+ bool shouldShowMaximizeButton();
+ void winUpdateIsOpaque();
+ void reparentChildren();
+#ifndef QT_NO_DRAGANDDROP
+ QOleDropTarget *registerOleDnd(QWidget *widget);
+ void unregisterOleDnd(QWidget *widget, QOleDropTarget *target);
+#endif
+ void grabMouseWhileInWindow();
+ void registerTouchWindow();
+ void winSetupGestures();
+#elif defined(Q_WS_MAC) // <--------------------------------------------------------- MAC
+ // This is new stuff
+ uint needWindowChange : 1;
+
+ // Each wiget keeps a list of all its child and grandchild OpenGL widgets.
+ // This list is used to update the gl context whenever a parent and a granparent
+ // moves, and also to check for intersections with gl widgets within the window
+ // when a widget moves.
+ struct GlWidgetInfo
+ {
+ GlWidgetInfo(QWidget *widget) : widget(widget), lastUpdateWidget(0) { }
+ bool operator==(const GlWidgetInfo &other) const { return (widget == other.widget); }
+ QWidget * widget;
+ QWidget * lastUpdateWidget;
+ };
+
+ // dirtyOnWidget contains the areas in the widget that needs to be repained,
+ // in the same way as dirtyOnScreen does for the window. Areas are added in
+ // dirtyWidget_sys and cleared in the paint event. In scroll_sys we then use
+ // this information repaint invalid areas when widgets are scrolled.
+ QRegion dirtyOnWidget;
+ EventHandlerRef window_event;
+ QList<GlWidgetInfo> glWidgets;
+
+ //these are here just for code compat (HIViews)
+ Qt::HANDLE qd_hd;
+
+ void macUpdateSizeAttribute();
+ void macUpdateHideOnSuspend();
+ void macUpdateOpaqueSizeGrip();
+ void macUpdateIgnoreMouseEvents();
+ void macUpdateMetalAttribute();
+ void macUpdateIsOpaque();
+ void macSetNeedsDisplay(QRegion region);
+ void setEnabled_helper_sys(bool enable);
+ bool isRealWindow() const;
+ void adjustWithinMaxAndMinSize(int &w, int &h);
+ void applyMaxAndMinSizeOnWindow();
+ void update_sys(const QRect &rect);
+ void update_sys(const QRegion &rgn);
+ void setGeometry_sys_helper(int, int, int, int, bool);
+ void setWindowModified_sys(bool b);
+ void updateMaximizeButton_sys();
+ void setWindowFilePath_sys(const QString &filePath);
+ void createWindow_sys();
+ void recreateMacWindow();
+#ifndef QT_MAC_USE_COCOA
+ void initWindowPtr();
+ void finishCreateWindow_sys_Carbon(OSWindowRef windowRef);
+#else
+ void setSubWindowStacking(bool set);
+ void setWindowLevel();
+ void finishCreateWindow_sys_Cocoa(void * /*NSWindow * */ windowRef);
+ void syncCocoaMask();
+ void finishCocoaMaskSetup();
+ void syncUnifiedMode();
+ // Did we add the drawRectOriginal method?
+ bool drawRectOriginalAdded;
+ // Is the original drawRect method available?
+ bool originalDrawMethod;
+ // Do we need to change the methods?
+ bool changeMethods;
+
+ // Unified toolbar variables
+ bool isInUnifiedToolbar;
+ QUnifiedToolbarSurface *unifiedSurface;
+ QPoint toolbar_offset;
+ QWidget *toolbar_ancestor;
+ bool flushRequested;
+ bool touchEventsEnabled;
+#endif // QT_MAC_USE_COCOA
+ void determineWindowClass();
+ void transferChildren();
+ bool qt_mac_dnd_event(uint, DragRef);
+ void toggleDrawers(bool);
+ //mac event functions
+ static bool qt_create_root_win();
+ static void qt_clean_root_win();
+ static bool qt_mac_update_sizer(QWidget *, int up = 0);
+ static OSStatus qt_window_event(EventHandlerCallRef er, EventRef event, void *);
+ static OSStatus qt_widget_event(EventHandlerCallRef er, EventRef event, void *);
+ static bool qt_widget_rgn(QWidget *, short, RgnHandle, bool);
+ void registerTouchWindow(bool enable = true);
+#elif defined(Q_WS_QWS) // <--------------------------------------------------------- QWS
+ void setMaxWindowState_helper();
+ void setFullScreenSize_helper();
+ void moveSurface(QWindowSurface *surface, const QPoint &offset);
+ QRegion localRequestedRegion() const;
+ QRegion localAllocatedRegion() const;
+
+ friend class QWSManager;
+ friend class QWSManagerPrivate;
+ friend class QDecoration;
+#ifndef QT_NO_CURSOR
+ void updateCursor() const;
+#endif
+ QScreen* getScreen() const;
+#elif defined(Q_WS_QPA) // <--------------------------------------------------------- QPA
+ void setMaxWindowState_helper();
+ void setFullScreenSize_helper();
+#ifndef QT_NO_CURSOR
+ void updateCursor() const;
+#endif
+#elif defined(Q_OS_SYMBIAN) // <--------------------------------------------------------- SYMBIAN
+ static QWidget *mouseGrabber;
+ static QWidget *keyboardGrabber;
+ int symbianScreenNumber; // only valid for desktop widget and top-levels
+ bool fixNativeOrientationCalled;
+ void s60UpdateIsOpaque();
+ void reparentChildren();
+ void registerTouchWindow();
+#endif
+
+};
+
+struct QWidgetPaintContext
+{
+ inline QWidgetPaintContext(QPaintDevice *d, const QRegion &r, const QPoint &o, int f,
+ QPainter *p, QWidgetBackingStore *b)
+ : pdev(d), rgn(r), offset(o), flags(f), sharedPainter(p), backingStore(b), painter(0) {}
+
+ QPaintDevice *pdev;
+ QRegion rgn;
+ QPoint offset;
+ int flags;
+ QPainter *sharedPainter;
+ QWidgetBackingStore *backingStore;
+ QPainter *painter;
+};
+
+#ifndef QT_NO_GRAPHICSEFFECT
+class QWidgetEffectSourcePrivate : public QGraphicsEffectSourcePrivate
+{
+public:
+ QWidgetEffectSourcePrivate(QWidget *widget)
+ : QGraphicsEffectSourcePrivate(), m_widget(widget), context(0), updateDueToGraphicsEffect(false)
+ {}
+
+ inline void detach()
+ { m_widget->d_func()->graphicsEffect = 0; }
+
+ inline const QGraphicsItem *graphicsItem() const
+ { return 0; }
+
+ inline const QWidget *widget() const
+ { return m_widget; }
+
+ inline void update()
+ {
+ updateDueToGraphicsEffect = true;
+ m_widget->update();
+ updateDueToGraphicsEffect = false;
+ }
+
+ inline bool isPixmap() const
+ { return false; }
+
+ inline void effectBoundingRectChanged()
+ {
+ // ### This function should take a rect parameter; then we can avoid
+ // updating too much on the parent widget.
+ if (QWidget *parent = m_widget->parentWidget())
+ parent->update();
+ else
+ update();
+ }
+
+ inline const QStyleOption *styleOption() const
+ { return 0; }
+
+ inline QRect deviceRect() const
+ { return m_widget->window()->rect(); }
+
+ QRectF boundingRect(Qt::CoordinateSystem system) const;
+ void draw(QPainter *p);
+ QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset,
+ QGraphicsEffect::PixmapPadMode mode) const;
+
+ QWidget *m_widget;
+ QWidgetPaintContext *context;
+ QTransform lastEffectTransform;
+ bool updateDueToGraphicsEffect;
+};
+#endif //QT_NO_GRAPHICSEFFECT
+
+inline QWExtra *QWidgetPrivate::extraData() const
+{
+ return extra;
+}
+
+inline QTLWExtra *QWidgetPrivate::topData() const
+{
+ const_cast<QWidgetPrivate *>(this)->createTLExtra();
+ return extra->topextra;
+}
+
+inline QTLWExtra *QWidgetPrivate::maybeTopData() const
+{
+ return extra ? extra->topextra : 0;
+}
+
+inline QPainter *QWidgetPrivate::sharedPainter() const
+{
+ Q_Q(const QWidget);
+ QTLWExtra *x = q->window()->d_func()->maybeTopData();
+ return x ? x->sharedPainter : 0;
+}
+
+inline void QWidgetPrivate::setSharedPainter(QPainter *painter)
+{
+ Q_Q(QWidget);
+ QTLWExtra *x = q->window()->d_func()->topData();
+ x->sharedPainter = painter;
+}
+
+inline bool QWidgetPrivate::pointInsideRectAndMask(const QPoint &p) const
+{
+ Q_Q(const QWidget);
+ return q->rect().contains(p) && (!extra || !extra->hasMask || q->testAttribute(Qt::WA_MouseNoMask)
+ || extra->mask.contains(p));
+}
+
+inline QWidgetBackingStore *QWidgetPrivate::maybeBackingStore() const
+{
+ Q_Q(const QWidget);
+ QTLWExtra *x = q->window()->d_func()->maybeTopData();
+ return x ? x->backingStore.data() : 0;
+}
+
+QT_END_NAMESPACE
+
+#endif // QWIDGET_P_H
diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp
new file mode 100644
index 0000000000..f6833915ec
--- /dev/null
+++ b/src/widgets/kernel/qwidget_qpa.cpp
@@ -0,0 +1,824 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "QtWidgets/qwidget.h"
+#include "QtGui/qevent.h"
+#include "QtWidgets/qapplication.h"
+#include "private/qbackingstore_p.h"
+#include "private/qwidget_p.h"
+#include "private/qwidgetwindow_qpa_p.h"
+#include "private/qapplication_p.h"
+#include "QtWidgets/qdesktopwidget.h"
+#include "QtGui/qplatformwindow_qpa.h"
+#include "QtGui/qplatformglcontext_qpa.h"
+
+#include <QtGui/QPlatformCursor>
+
+QT_BEGIN_NAMESPACE
+
+void q_createNativeChildrenAndSetParent(QWindow *parentWindow, const QWidget *parentWidget)
+{
+ QObjectList children = parentWidget->children();
+ for (int i = 0; i < children.size(); i++) {
+ if (children.at(i)->isWidgetType()) {
+ const QWidget *childWidget = qobject_cast<const QWidget *>(children.at(i));
+ if (childWidget) { // should not be necessary
+ if (childWidget->testAttribute(Qt::WA_NativeWindow)) {
+ if (!childWidget->windowHandle())
+ childWidget->winId();
+ if (childWidget->windowHandle())
+ childWidget->windowHandle()->setParent(parentWindow);
+ } else {
+ q_createNativeChildrenAndSetParent(parentWindow,childWidget);
+ }
+ }
+ }
+ }
+
+}
+
+void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow)
+{
+ Q_Q(QWidget);
+
+ Q_UNUSED(window);
+ Q_UNUSED(initializeWindow);
+ Q_UNUSED(destroyOldWindow);
+
+ Qt::WindowFlags flags = data.window_flags;
+
+ if ((!q->testAttribute(Qt::WA_NativeWindow) && !q->isWindow()) || q->windowType() == Qt::Desktop )
+ return; // we only care about real toplevels
+
+ QWindowSurface *surface = q->windowSurface();
+
+ QWindow *win = topData()->window;
+
+ if (!q->isWindow()) {
+ if (QWidget *nativeParent = q->nativeParentWidget()) {
+ if (nativeParent->windowHandle())
+ win->setParent(nativeParent->windowHandle());
+ }
+ }
+
+ win->setWindowFlags(data.window_flags);
+ win->setGeometry(q->geometry());
+ win->create();
+
+ data.window_flags = win->windowFlags();
+
+ if (!surface ) {
+ if (win) {
+ surface = QGuiApplicationPrivate::platformIntegration()->createWindowSurface(win, win->winId());
+ q->setWindowSurface(surface);
+ } else {
+ q->setAttribute(Qt::WA_PaintOnScreen,true);
+ }
+ }
+
+ setWinId(win->winId());
+
+// first check children. and create them if necessary
+// q_createNativeChildrenAndSetParent(q->windowHandle(),q);
+
+ QGuiApplicationPrivate::platformIntegration()->moveToScreen(win, topData()->screenIndex);
+// qDebug() << "create_sys" << q << q->internalWinId();
+}
+
+void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
+{
+ Q_D(QWidget);
+
+ if ((windowType() == Qt::Popup))
+ qApp->d_func()->closePopup(this);
+
+ //### we don't have proper focus event handling yet
+ if (this == QApplicationPrivate::active_window)
+ QApplication::setActiveWindow(0);
+
+ if (windowType() != Qt::Desktop) {
+ if (destroySubWindows) {
+ QObjectList childList(children());
+ for (int i = 0; i < childList.size(); i++) {
+ QWidget *widget = qobject_cast<QWidget *>(childList.at(i));
+ if (widget && widget->testAttribute(Qt::WA_NativeWindow)) {
+ if (widget->windowHandle()) {
+ widget->destroy();
+ }
+ }
+ }
+ }
+ if (destroyWindow) {
+ d->deleteTLSysExtra();
+ } else {
+ if (parentWidget() && parentWidget()->testAttribute(Qt::WA_WState_Created)) {
+ d->hide_sys();
+ }
+ }
+ }
+}
+
+void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f)
+{
+ Q_Q(QWidget);
+
+ Qt::WindowFlags oldFlags = data.window_flags;
+
+ int targetScreen = -1;
+ // Handle a request to move the widget to a particular screen
+ if (newparent && newparent->windowType() == Qt::Desktop) {
+ // make sure the widget is created on the same screen as the
+ // programmer specified desktop widget
+
+ // get the desktop's screen number
+ targetScreen = newparent->window()->d_func()->topData()->screenIndex;
+ newparent = 0;
+ }
+
+ if (parent != newparent) {
+ QObjectPrivate::setParent_helper(newparent); //### why does this have to be done in the _sys function???
+ if (q->windowHandle() && newparent) {
+ QWidget * parentWithWindow = newparent->windowHandle()? newparent : newparent->nativeParentWidget();
+ if (parentWithWindow && parentWithWindow->windowHandle()) {
+ q->windowHandle()->setParent(parentWithWindow->windowHandle());
+ }
+ }
+
+ }
+
+ if (!newparent) {
+ f |= Qt::Window;
+ if (targetScreen == -1) {
+ if (parent)
+ targetScreen = q->parentWidget()->window()->d_func()->topData()->screenIndex;
+ }
+ }
+
+ bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide);
+
+ // Reparenting toplevel to child
+ if (!(f&Qt::Window) && (oldFlags&Qt::Window) && !q->testAttribute(Qt::WA_NativeWindow)) {
+ //qDebug() << "setParent_sys() change from toplevel";
+ q->destroy();
+ }
+
+ data.window_flags = f;
+ q->setAttribute(Qt::WA_WState_Created, false);
+ q->setAttribute(Qt::WA_WState_Visible, false);
+ q->setAttribute(Qt::WA_WState_Hidden, false);
+
+ if (q->isWindow() || (!newparent || newparent->isVisible()) || explicitlyHidden)
+ q->setAttribute(Qt::WA_WState_Hidden);
+ q->setAttribute(Qt::WA_WState_ExplicitShowHide, explicitlyHidden);
+
+ // move the window to the selected screen
+ if (!newparent && targetScreen != -1) {
+ if (maybeTopData())
+ maybeTopData()->screenIndex = targetScreen;
+ // only if it is already created
+ if (q->testAttribute(Qt::WA_WState_Created)) {
+ QPlatformIntegration *platform = QGuiApplicationPrivate::platformIntegration();
+ platform->moveToScreen(q->windowHandle(), targetScreen);
+ }
+ }
+}
+
+QPoint QWidget::mapToGlobal(const QPoint &pos) const
+{
+ int x=pos.x(), y=pos.y();
+ const QWidget* w = this;
+ while (w) {
+ x += w->data->crect.x();
+ y += w->data->crect.y();
+ w = w->isWindow() ? 0 : w->parentWidget();
+ }
+ return QPoint(x, y);
+}
+
+QPoint QWidget::mapFromGlobal(const QPoint &pos) const
+{
+ int x=pos.x(), y=pos.y();
+ const QWidget* w = this;
+ while (w) {
+ x -= w->data->crect.x();
+ y -= w->data->crect.y();
+ w = w->isWindow() ? 0 : w->parentWidget();
+ }
+ return QPoint(x, y);
+}
+
+void QWidgetPrivate::updateSystemBackground() {}
+
+#ifndef QT_NO_CURSOR
+void QWidgetPrivate::setCursor_sys(const QCursor &cursor)
+{
+ Q_UNUSED(cursor);
+ Q_Q(QWidget);
+ if (q->isVisible())
+ qt_qpa_set_cursor(q, false);
+}
+
+void QWidgetPrivate::unsetCursor_sys()
+{
+ Q_Q(QWidget);
+ if (q->isVisible())
+ qt_qpa_set_cursor(q, false);
+}
+
+void QWidgetPrivate::updateCursor() const
+{
+ // XXX
+}
+
+#endif //QT_NO_CURSOR
+
+void QWidgetPrivate::setWindowTitle_sys(const QString &caption)
+{
+ Q_Q(QWidget);
+ if (!q->isWindow())
+ return;
+
+ if (QWindow *window = q->windowHandle())
+ window->setWindowTitle(caption);
+
+}
+
+void QWidgetPrivate::setWindowIcon_sys(bool /*forceReset*/)
+{
+}
+
+void QWidgetPrivate::setWindowIconText_sys(const QString &iconText)
+{
+ Q_UNUSED(iconText);
+}
+
+QWidget *qt_pressGrab = 0;
+QWidget *qt_mouseGrb = 0;
+static QWidget *keyboardGrb = 0;
+
+void QWidget::grabMouse()
+{
+ if (qt_mouseGrb)
+ qt_mouseGrb->releaseMouse();
+
+ // XXX
+ //qwsDisplay()->grabMouse(this,true);
+
+ qt_mouseGrb = this;
+ qt_pressGrab = 0;
+}
+
+#ifndef QT_NO_CURSOR
+void QWidget::grabMouse(const QCursor &cursor)
+{
+ Q_UNUSED(cursor);
+
+ if (qt_mouseGrb)
+ qt_mouseGrb->releaseMouse();
+
+ // XXX
+ //qwsDisplay()->grabMouse(this,true);
+ //qwsDisplay()->selectCursor(this, cursor.handle());
+ qt_mouseGrb = this;
+ qt_pressGrab = 0;
+}
+#endif
+
+void QWidget::releaseMouse()
+{
+ if (qt_mouseGrb == this) {
+ // XXX
+ //qwsDisplay()->grabMouse(this,false);
+ qt_mouseGrb = 0;
+ }
+}
+
+void QWidget::grabKeyboard()
+{
+ if (keyboardGrb)
+ keyboardGrb->releaseKeyboard();
+ // XXX
+ //qwsDisplay()->grabKeyboard(this, true);
+ keyboardGrb = this;
+}
+
+void QWidget::releaseKeyboard()
+{
+ if (keyboardGrb == this) {
+ // XXX
+ //qwsDisplay()->grabKeyboard(this, false);
+ keyboardGrb = 0;
+ }
+}
+
+QWidget *QWidget::mouseGrabber()
+{
+ if (qt_mouseGrb)
+ return qt_mouseGrb;
+ return qt_pressGrab;
+}
+
+QWidget *QWidget::keyboardGrabber()
+{
+ return keyboardGrb;
+}
+
+void QWidget::activateWindow()
+{
+ if (windowHandle())
+ windowHandle()->requestActivateWindow();
+}
+
+void QWidgetPrivate::show_sys()
+{
+ Q_Q(QWidget);
+ q->setAttribute(Qt::WA_Mapped);
+ if (q->testAttribute(Qt::WA_DontShowOnScreen)) {
+ invalidateBuffer(q->rect());
+ return;
+ }
+
+ QApplication::postEvent(q, new QUpdateLaterEvent(q->rect()));
+
+ if (!q->isWindow() && !q->testAttribute(Qt::WA_NativeWindow))
+ return;
+
+ QWindow *window = q->windowHandle();
+ if (window) {
+ QRect geomRect = q->geometry();
+ if (!q->isWindow()) {
+ QPoint topLeftOfWindow = q->mapTo(q->nativeParentWidget(),QPoint());
+ geomRect.moveTopLeft(topLeftOfWindow);
+ }
+ const QRect windowRect = window->geometry();
+ if (windowRect != geomRect) {
+ window->setGeometry(geomRect);
+ }
+ if (QWindowSurface *surface = q->windowSurface()) {
+ if (windowRect.size() != geomRect.size()) {
+ surface->resize(geomRect.size());
+ }
+ }
+ if (window)
+ window->setVisible(true);
+ }
+}
+
+
+void QWidgetPrivate::hide_sys()
+{
+ Q_Q(QWidget);
+ q->setAttribute(Qt::WA_Mapped, false);
+ if (!q->isWindow()) {
+ QWidget *p = q->parentWidget();
+ if (p &&p->isVisible()) {
+ invalidateBuffer(q->rect());
+ }
+ return;
+ }
+ if (QWindow *window = q->windowHandle()) {
+ window->setVisible(false);
+ }
+
+ //### we don't yet have proper focus event handling
+ if (q == QApplicationPrivate::active_window)
+ QApplication::setActiveWindow(0);
+
+}
+
+void QWidgetPrivate::setMaxWindowState_helper()
+{
+ setFullScreenSize_helper(); //### decoration size
+}
+
+void QWidgetPrivate::setFullScreenSize_helper()
+{
+ Q_Q(QWidget);
+
+ const uint old_state = data.in_set_window_state;
+ data.in_set_window_state = 1;
+
+ const QRect screen = qApp->desktop()->screenGeometry(qApp->desktop()->screenNumber(q));
+ q->move(screen.topLeft());
+ q->resize(screen.size());
+
+ data.in_set_window_state = old_state;
+}
+
+static Qt::WindowStates effectiveState(Qt::WindowStates state)
+ {
+ if (state & Qt::WindowMinimized)
+ return Qt::WindowMinimized;
+ else if (state & Qt::WindowFullScreen)
+ return Qt::WindowFullScreen;
+ else if (state & Qt::WindowMaximized)
+ return Qt::WindowMaximized;
+ return Qt::WindowNoState;
+ }
+
+void QWidget::setWindowState(Qt::WindowStates newstate)
+{
+ Q_D(QWidget);
+ Qt::WindowStates oldstate = windowState();
+ if (oldstate == newstate)
+ return;
+ if (isWindow() && !testAttribute(Qt::WA_WState_Created))
+ create();
+
+ data->window_state = newstate;
+ data->in_set_window_state = 1;
+ bool needShow = false;
+ Qt::WindowStates newEffectiveState = effectiveState(newstate);
+ Qt::WindowStates oldEffectiveState = effectiveState(oldstate);
+ if (isWindow() && newEffectiveState != oldEffectiveState) {
+ d->createTLExtra();
+ if (oldEffectiveState == Qt::WindowNoState) { //normal
+ d->topData()->normalGeometry = geometry();
+ } else if (oldEffectiveState == Qt::WindowFullScreen) {
+ setParent(0, d->topData()->savedFlags);
+ needShow = true;
+ } else if (oldEffectiveState == Qt::WindowMinimized) {
+ needShow = true;
+ }
+
+ if (newEffectiveState == Qt::WindowMinimized) {
+ //### not ideal...
+ hide();
+ needShow = false;
+ } else if (newEffectiveState == Qt::WindowFullScreen) {
+ d->topData()->savedFlags = windowFlags();
+ setParent(0, Qt::FramelessWindowHint | (windowFlags() & Qt::WindowStaysOnTopHint));
+ d->setFullScreenSize_helper();
+ raise();
+ needShow = true;
+ } else if (newEffectiveState == Qt::WindowMaximized) {
+ createWinId();
+ d->setMaxWindowState_helper();
+ } else { //normal
+ QRect r = d->topData()->normalGeometry;
+ if (r.width() >= 0) {
+ d->topData()->normalGeometry = QRect(0,0,-1,-1);
+ setGeometry(r);
+ }
+ }
+ }
+ data->in_set_window_state = 0;
+
+ if (needShow)
+ show();
+
+ if (newstate & Qt::WindowActive)
+ activateWindow();
+
+ QWindowStateChangeEvent e(oldstate);
+ QApplication::sendEvent(this, &e);
+}
+
+void QWidgetPrivate::setFocus_sys()
+{
+
+}
+
+void QWidgetPrivate::raise_sys()
+{
+ Q_Q(QWidget);
+ if (q->isWindow()) {
+ q->windowHandle()->raise();
+ }
+}
+
+void QWidgetPrivate::lower_sys()
+{
+ Q_Q(QWidget);
+ if (q->isWindow()) {
+ Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
+ q->windowHandle()->lower();
+ } else if (QWidget *p = q->parentWidget()) {
+ setDirtyOpaqueRegion();
+ p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry()));
+ }
+}
+
+void QWidgetPrivate::stackUnder_sys(QWidget*)
+{
+ Q_Q(QWidget);
+ if (QWidget *p = q->parentWidget()) {
+ setDirtyOpaqueRegion();
+ p->d_func()->invalidateBuffer(effectiveRectFor(q->geometry()));
+ }
+}
+
+void QWidgetPrivate::setGeometry_sys(int x, int y, int w, int h, bool isMove)
+{
+ Q_Q(QWidget);
+ if (extra) { // any size restrictions?
+ w = qMin(w,extra->maxw);
+ h = qMin(h,extra->maxh);
+ w = qMax(w,extra->minw);
+ h = qMax(h,extra->minh);
+ }
+
+ QPoint oldp = q->geometry().topLeft();
+ QSize olds = q->size();
+ QRect r(x, y, w, h);
+
+ bool isResize = olds != r.size();
+ isMove = oldp != r.topLeft(); //### why do we have isMove as a parameter?
+
+
+ // We only care about stuff that changes the geometry, or may
+ // cause the window manager to change its state
+ if (r.size() == olds && oldp == r.topLeft())
+ return;
+
+ if (!data.in_set_window_state) {
+ q->data->window_state &= ~Qt::WindowMaximized;
+ q->data->window_state &= ~Qt::WindowFullScreen;
+ if (q->isWindow())
+ topData()->normalGeometry = QRect(0, 0, -1, -1);
+ }
+
+ QPoint oldPos = q->pos();
+ data.crect = r;
+
+ if (q->isVisible()) {
+ if (q->windowHandle()) {
+ if (q->isWindow()) {
+ q->windowHandle()->setGeometry(q->geometry());
+ } else {
+ QPoint posInNativeParent = q->mapTo(q->nativeParentWidget(),QPoint());
+ q->windowHandle()->setGeometry(QRect(posInNativeParent,r.size()));
+ }
+ const QWidgetBackingStore *bs = maybeBackingStore();
+ if (bs->windowSurface) {
+ if (isResize)
+ bs->windowSurface->resize(r.size());
+ }
+ } else {
+ if (isMove && !isResize)
+ moveRect(QRect(oldPos, olds), x - oldPos.x(), y - oldPos.y());
+ else
+ invalidateBuffer_resizeHelper(oldPos, olds);
+ }
+
+ if (isMove) {
+ QMoveEvent e(q->pos(), oldPos);
+ QApplication::sendEvent(q, &e);
+ }
+ if (isResize) {
+ QResizeEvent e(r.size(), olds);
+ QApplication::sendEvent(q, &e);
+ if (q->windowHandle())
+ q->update();
+ }
+ } else { // not visible
+ if (isMove && q->pos() != oldPos)
+ q->setAttribute(Qt::WA_PendingMoveEvent, true);
+ if (isResize)
+ q->setAttribute(Qt::WA_PendingResizeEvent, true);
+ }
+
+}
+
+void QWidgetPrivate::setConstraints_sys()
+{
+}
+
+void QWidgetPrivate::scroll_sys(int dx, int dy)
+{
+ Q_Q(QWidget);
+ scrollChildren(dx, dy);
+ scrollRect(q->rect(), dx, dy);
+}
+
+void QWidgetPrivate::scroll_sys(int dx, int dy, const QRect &r)
+{
+ scrollRect(r, dx, dy);
+}
+
+int QWidget::metric(PaintDeviceMetric m) const
+{
+ Q_D(const QWidget);
+
+ QPlatformScreen *screen = QPlatformScreen::platformScreenForWindow(windowHandle());
+ if (!screen) {
+ if (m == PdmDpiX || m == PdmDpiY)
+ return 72;
+ return QPaintDevice::metric(m);
+ }
+ int val;
+ if (m == PdmWidth) {
+ val = data->crect.width();
+ } else if (m == PdmWidthMM) {
+ val = data->crect.width() * screen->physicalSize().width() / screen->geometry().width();
+ } else if (m == PdmHeight) {
+ val = data->crect.height();
+ } else if (m == PdmHeightMM) {
+ val = data->crect.height() * screen->physicalSize().height() / screen->geometry().height();
+ } else if (m == PdmDepth) {
+ return screen->depth();
+ } else if (m == PdmDpiX || m == PdmPhysicalDpiX) {
+ if (d->extra && d->extra->customDpiX)
+ return d->extra->customDpiX;
+ else if (d->parent)
+ return static_cast<QWidget *>(d->parent)->metric(m);
+ return qRound(screen->geometry().width() / double(screen->physicalSize().width() / 25.4));
+ } else if (m == PdmDpiY || m == PdmPhysicalDpiY) {
+ if (d->extra && d->extra->customDpiY)
+ return d->extra->customDpiY;
+ else if (d->parent)
+ return static_cast<QWidget *>(d->parent)->metric(m);
+ return qRound(screen->geometry().height() / double(screen->physicalSize().height() / 25.4));
+ } else {
+ val = QPaintDevice::metric(m);// XXX
+ }
+ return val;
+}
+
+/*!
+ \preliminary
+
+ Returns the QPlatformWindow this widget will be drawn into.
+*/
+QWindow *QWidget::windowHandle() const
+{
+ Q_D(const QWidget);
+ QTLWExtra *extra = d->maybeTopData();
+ if (extra && extra->window)
+ return extra->window;
+
+ return 0;
+}
+
+void QWidgetPrivate::createSysExtra()
+{
+}
+
+void QWidgetPrivate::deleteSysExtra()
+{
+
+}
+
+void QWidgetPrivate::createTLSysExtra()
+{
+ Q_Q(QWidget);
+ extra->topextra->screenIndex = 0;
+ extra->topextra->window = new QWidgetWindow(q);
+}
+
+void QWidgetPrivate::deleteTLSysExtra()
+{
+ if (extra && extra->topextra) {
+ //the toplevel might have a context with a "qglcontext associated with it. We need to
+ //delete the qglcontext before we delete the qplatformglcontext.
+ //One unfortunate thing about this is that we potentially create a glContext just to
+ //delete it straight afterwards.
+ if (extra->topextra->window) {
+ extra->topextra->window->destroy();
+ }
+ setWinId(0);
+ //hmmm. should we delete window..
+ delete extra->topextra->window;
+ extra->topextra->window = 0;
+ }
+}
+
+void QWidgetPrivate::registerDropSite(bool on)
+{
+ Q_UNUSED(on);
+}
+
+void QWidgetPrivate::setMask_sys(const QRegion &region)
+{
+ Q_UNUSED(region);
+ // XXX
+}
+
+void QWidgetPrivate::updateFrameStrut()
+{
+ // XXX
+}
+
+void QWidgetPrivate::setWindowOpacity_sys(qreal level)
+{
+ Q_Q(QWidget);
+ q->windowHandle()->setOpacity(level);
+}
+
+void QWidgetPrivate::setWSGeometry(bool dontShow, const QRect &oldRect)
+{
+ Q_UNUSED(dontShow);
+ Q_UNUSED(oldRect);
+ // XXX
+}
+
+QPaintEngine *QWidget::paintEngine() const
+{
+ qWarning("QWidget::paintEngine: Should no longer be called");
+ return 0; //##### @@@
+}
+
+QWindowSurface *QWidgetPrivate::createDefaultWindowSurface_sys()
+{
+ //This function should not be called.
+ Q_ASSERT(false);
+ return 0;
+}
+
+void QWidgetPrivate::setModal_sys()
+{
+}
+
+#ifndef QT_NO_CURSOR
+void qt_qpa_set_cursor(QWidget * w, bool force)
+{
+ static QCursor arrowCursor(Qt::ArrowCursor);
+ static QPointer<QWidget> lastUnderMouse = 0;
+
+ QCursor * override = QApplication::overrideCursor();
+
+ if (override && w != 0)
+ return;
+
+ QWidget *cursorWidget;
+ QCursor cursorCursor;
+
+ do {
+ if (w == 0) {
+ if (override) {
+ cursorCursor = *override;
+ cursorWidget = QApplication::topLevelAt(QCursor::pos());
+ break;
+ }
+ w = QApplication::widgetAt(QCursor::pos());
+ if (w == 0) // clear the override cursor while over empty space
+ w = QApplication::desktop();
+ } else if (force) {
+ lastUnderMouse = w;
+ } else if (w->testAttribute(Qt::WA_WState_Created) && lastUnderMouse
+ && lastUnderMouse->effectiveWinId() == w->effectiveWinId()) {
+ w = lastUnderMouse;
+ }
+ if (w == QApplication::desktop() && !override) {
+ cursorCursor = arrowCursor;
+ cursorWidget = w;
+ break;
+ }
+
+ QWidget * curWin = QApplication::activeWindow();
+ if (!curWin && w && w->internalWinId())
+ return;
+ QWidget* cW = w && !w->internalWinId() ? w : curWin;
+
+ if (!cW || cW->window() != w->window() ||
+ !cW->isVisible() || !cW->underMouse() || override)
+ return;
+
+ cursorCursor = w->cursor();
+ cursorWidget = w;
+ } while (0);
+ foreach (QWeakPointer<QPlatformCursor> cursor, QPlatformCursorPrivate::getInstances())
+ if (cursor)
+ cursor.data()->changeCursor(&cursorCursor, cursorWidget->windowHandle());
+}
+#endif //QT_NO_CURSOR
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qwidgetaction.cpp b/src/widgets/kernel/qwidgetaction.cpp
index 29586da34b..29586da34b 100644
--- a/src/gui/kernel/qwidgetaction.cpp
+++ b/src/widgets/kernel/qwidgetaction.cpp
diff --git a/src/widgets/kernel/qwidgetaction.h b/src/widgets/kernel/qwidgetaction.h
new file mode 100644
index 0000000000..cf9f2e6da5
--- /dev/null
+++ b/src/widgets/kernel/qwidgetaction.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWIDGETACTION_H
+#define QWIDGETACTION_H
+
+#include <QtWidgets/qaction.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_ACTION
+
+class QWidgetActionPrivate;
+
+class Q_GUI_EXPORT QWidgetAction : public QAction
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QWidgetAction)
+
+public:
+ explicit QWidgetAction(QObject *parent);
+ virtual ~QWidgetAction();
+
+ void setDefaultWidget(QWidget *w);
+ QWidget *defaultWidget() const;
+
+ QWidget *requestWidget(QWidget *parent);
+ void releaseWidget(QWidget *widget);
+
+protected:
+ virtual bool event(QEvent *);
+ virtual bool eventFilter(QObject *, QEvent *);
+ virtual QWidget *createWidget(QWidget *parent);
+ virtual void deleteWidget(QWidget *widget);
+ QList<QWidget *> createdWidgets() const;
+
+private:
+ Q_DISABLE_COPY(QWidgetAction)
+ Q_PRIVATE_SLOT(d_func(), void _q_widgetDestroyed(QObject *))
+ friend class QToolBar;
+};
+
+#endif // QT_NO_ACTION
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QWIDGETACTION_H
diff --git a/src/gui/kernel/qwidgetaction_p.h b/src/widgets/kernel/qwidgetaction_p.h
index e4f59a04d2..e4f59a04d2 100644
--- a/src/gui/kernel/qwidgetaction_p.h
+++ b/src/widgets/kernel/qwidgetaction_p.h
diff --git a/src/widgets/kernel/qwidgetsvariant.cpp b/src/widgets/kernel/qwidgetsvariant.cpp
new file mode 100644
index 0000000000..680c8f9cfa
--- /dev/null
+++ b/src/widgets/kernel/qwidgetsvariant.cpp
@@ -0,0 +1,213 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qvariant.h"
+
+#include "qicon.h"
+#include "qsizepolicy.h"
+
+#include "private/qvariant_p.h"
+
+QT_BEGIN_NAMESPACE
+
+
+static void construct(QVariant::Private *x, const void *copy)
+{
+ switch (x->type) {
+#ifndef QT_NO_ICON
+ case QVariant::Icon:
+ v_construct<QIcon>(x, copy);
+ break;
+#endif
+ case QVariant::SizePolicy:
+ v_construct<QSizePolicy>(x, copy);
+ break;
+ default:
+ Q_ASSERT(false);
+ return;
+ }
+ x->is_null = !copy;
+}
+
+static void clear(QVariant::Private *d)
+{
+ switch (d->type) {
+#ifndef QT_NO_ICON
+ case QVariant::Icon:
+ v_clear<QIcon>(d);
+ break;
+#endif
+ case QVariant::SizePolicy:
+ v_clear<QSizePolicy>(d);
+ break;
+ default:
+ Q_ASSERT(false);
+ return;
+ }
+
+ d->type = QVariant::Invalid;
+ d->is_null = true;
+ d->is_shared = false;
+}
+
+
+static bool isNull(const QVariant::Private *d)
+{
+ switch(d->type) {
+#ifndef QT_NO_ICON
+ case QVariant::Icon:
+ return v_cast<QIcon>(d)->isNull();
+#endif
+ default:
+ Q_ASSERT(false);
+ }
+ return true;
+}
+
+static bool compare(const QVariant::Private *a, const QVariant::Private *b)
+{
+ Q_ASSERT(a->type == b->type);
+ switch(a->type) {
+ case QVariant::SizePolicy:
+ return *v_cast<QSizePolicy>(a) == *v_cast<QSizePolicy>(b);
+ default:
+ Q_ASSERT(false);
+ }
+ return false;
+}
+
+
+static const QVariant::Handler widgets_handler = {
+ construct,
+ clear,
+ isNull,
+#ifndef QT_NO_DATASTREAM
+ 0,
+ 0,
+#endif
+ compare,
+ 0,
+ 0,
+#if !defined(QT_NO_DEBUG_STREAM) && !defined(Q_BROKEN_DEBUG_STREAM)
+ 0
+#else
+ 0
+#endif
+};
+
+struct QMetaTypeGuiHelper
+{
+ QMetaType::Constructor constr;
+ QMetaType::Destructor destr;
+#ifndef QT_NO_DATASTREAM
+ QMetaType::SaveOperator saveOp;
+ QMetaType::LoadOperator loadOp;
+#endif
+};
+
+extern Q_CORE_EXPORT const QMetaTypeGuiHelper *qMetaTypeWidgetsHelper;
+
+
+#ifdef QT_NO_DATASTREAM
+# define Q_DECL_METATYPE_HELPER(TYPE) \
+ typedef void *(*QConstruct##TYPE)(const TYPE *); \
+ static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper<TYPE>; \
+ typedef void (*QDestruct##TYPE)(TYPE *); \
+ static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDeleteHelper<TYPE>;
+#else
+# define Q_DECL_METATYPE_HELPER(TYPE) \
+ typedef void *(*QConstruct##TYPE)(const TYPE *); \
+ static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper<TYPE>; \
+ typedef void (*QDestruct##TYPE)(TYPE *); \
+ static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDeleteHelper<TYPE>; \
+ typedef void (*QSave##TYPE)(QDataStream &, const TYPE *); \
+ static const QSave##TYPE qSave##TYPE = qMetaTypeSaveHelper<TYPE>; \
+ typedef void (*QLoad##TYPE)(QDataStream &, TYPE *); \
+ static const QLoad##TYPE qLoad##TYPE = qMetaTypeLoadHelper<TYPE>;
+#endif
+
+#ifndef QT_NO_ICON
+Q_DECL_METATYPE_HELPER(QIcon)
+#endif
+Q_DECL_METATYPE_HELPER(QSizePolicy)
+
+#ifdef QT_NO_DATASTREAM
+# define Q_IMPL_METATYPE_HELPER(TYPE) \
+ { reinterpret_cast<QMetaType::Constructor>(qConstruct##TYPE), \
+ reinterpret_cast<QMetaType::Destructor>(qDestruct##TYPE) }
+#else
+# define Q_IMPL_METATYPE_HELPER(TYPE) \
+ { reinterpret_cast<QMetaType::Constructor>(qConstruct##TYPE), \
+ reinterpret_cast<QMetaType::Destructor>(qDestruct##TYPE), \
+ reinterpret_cast<QMetaType::SaveOperator>(qSave##TYPE), \
+ reinterpret_cast<QMetaType::LoadOperator>(qLoad##TYPE) \
+ }
+#endif
+
+static const QMetaTypeGuiHelper qVariantWidgetsHelper[] = {
+#ifdef QT_NO_ICON
+ {0, 0, 0, 0},
+#else
+ Q_IMPL_METATYPE_HELPER(QIcon),
+#endif
+ Q_IMPL_METATYPE_HELPER(QSizePolicy),
+};
+
+extern Q_GUI_EXPORT const QVariant::Handler *qt_widgets_variant_handler;
+
+int qRegisterWidgetsVariant()
+{
+ qt_widgets_variant_handler = &widgets_handler;
+ qMetaTypeWidgetsHelper = qVariantWidgetsHelper;
+ return 1;
+}
+Q_CONSTRUCTOR_FUNCTION(qRegisterWidgetsVariant)
+
+int qUnregisterWidgetsVariant()
+{
+ qt_widgets_variant_handler = 0;
+ qMetaTypeWidgetsHelper = 0;
+ return 1;
+}
+Q_DESTRUCTOR_FUNCTION(qUnregisterWidgetsVariant)
+
+
+QT_END_NAMESPACE
diff --git a/src/widgets/kernel/qwidgetwindow_qpa.cpp b/src/widgets/kernel/qwidgetwindow_qpa.cpp
new file mode 100644
index 0000000000..e8b1a6d096
--- /dev/null
+++ b/src/widgets/kernel/qwidgetwindow_qpa.cpp
@@ -0,0 +1,195 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qwidgetwindow_qpa_p.h"
+
+#include "private/qwidget_p.h"
+#include "private/qapplication_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QWidget *qt_button_down = 0; // widget got last button-down
+
+QWidgetWindow::QWidgetWindow(QWidget *widget)
+ : m_widget(widget)
+{
+}
+
+bool QWidgetWindow::event(QEvent *event)
+{
+ switch (event->type()) {
+ case QEvent::Close:
+ handleCloseEvent(static_cast<QCloseEvent *>(event));
+ return true;
+
+ case QEvent::Enter:
+ case QEvent::Leave:
+ handleEnterLeaveEvent(event);
+ return true;
+
+ case QEvent::KeyPress:
+ case QEvent::KeyRelease:
+ handleKeyEvent(static_cast<QKeyEvent *>(event));
+ return true;
+
+ case QEvent::MouseMove:
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseButtonDblClick:
+ handleMouseEvent(static_cast<QMouseEvent *>(event));
+ return true;
+
+ case QEvent::Move:
+ handleMoveEvent(static_cast<QMoveEvent *>(event));
+ return true;
+
+ case QEvent::Resize:
+ handleResizeEvent(static_cast<QResizeEvent *>(event));
+ return true;
+
+ case QEvent::Wheel:
+ handleWheelEvent(static_cast<QWheelEvent *>(event));
+ return true;
+
+ default:
+ break;
+ }
+
+ return m_widget->event(event) || QWindow::event(event);
+}
+
+QPointer<QWidget> qt_last_mouse_receiver = 0;
+
+void QWidgetWindow::handleEnterLeaveEvent(QEvent *event)
+{
+ if (event->type() == QEvent::Leave) {
+ QApplicationPrivate::dispatchEnterLeave(0, m_widget);
+ qt_last_mouse_receiver = 0;
+ } else {
+ QApplicationPrivate::dispatchEnterLeave(m_widget, 0);
+ qt_last_mouse_receiver = m_widget;
+ }
+}
+
+void QWidgetWindow::handleMouseEvent(QMouseEvent *event)
+{
+ // which child should have it?
+ QPoint mapped = event->pos();
+ QWidget *widget = 0;
+
+ if (m_implicit_mouse_grabber) {
+ widget = m_implicit_mouse_grabber.data();
+ mapped = widget->mapFromGlobal(m_widget->mapToGlobal(event->pos()));
+ } else if ((widget = m_widget->childAt(event->pos()))) {
+ mapped = widget->mapFrom(m_widget, event->pos());
+ }
+
+ if (qApp->d_func()->inPopupMode()) {
+ widget = qApp->activePopupWidget();
+ mapped = widget->mapFromGlobal(m_widget->mapToGlobal(event->pos()));
+ m_implicit_mouse_grabber.clear();
+ }
+
+ if (!widget)
+ widget = m_widget;
+
+ if (event->type() == QEvent::MouseButtonPress && !m_implicit_mouse_grabber)
+ m_implicit_mouse_grabber = widget;
+
+ if (event->buttons() == Qt::NoButton)
+ m_implicit_mouse_grabber.clear();
+
+ if (widget != qt_last_mouse_receiver) {
+ QApplicationPrivate::dispatchEnterLeave(widget, qt_last_mouse_receiver);
+ qt_last_mouse_receiver = widget;
+ }
+
+ QMouseEvent translated(event->type(), mapped, event->globalPos(), event->button(), event->buttons(), event->modifiers());
+ QGuiApplication::sendSpontaneousEvent(widget, &translated);
+
+ if (event->type() == QEvent::MouseButtonPress && event->button() == Qt::RightButton) {
+ QContextMenuEvent e(QContextMenuEvent::Mouse, mapped, event->globalPos(), event->modifiers());
+ QGuiApplication::sendSpontaneousEvent(widget, &e);
+ }
+}
+
+void QWidgetWindow::handleKeyEvent(QKeyEvent *event)
+{
+ QWidget *widget = m_widget->focusWidget();
+
+ if (!widget)
+ widget = m_widget;
+
+ QGuiApplication::sendSpontaneousEvent(widget, event);
+}
+
+void QWidgetWindow::handleMoveEvent(QMoveEvent *event)
+{
+ m_widget->data->crect = geometry();
+ QGuiApplication::sendSpontaneousEvent(m_widget, event);
+}
+
+void QWidgetWindow::handleResizeEvent(QResizeEvent *event)
+{
+ m_widget->data->crect = geometry();
+ QGuiApplication::sendSpontaneousEvent(m_widget, event);
+}
+
+void QWidgetWindow::handleCloseEvent(QCloseEvent *)
+{
+ m_widget->d_func()->close_helper(QWidgetPrivate::CloseWithSpontaneousEvent);
+}
+
+void QWidgetWindow::handleWheelEvent(QWheelEvent *event)
+{
+ // which child should have it?
+ QWidget *widget = m_widget->childAt(event->pos());
+
+ if (!widget)
+ widget = m_widget;
+
+ QPoint mapped = widget->mapFrom(m_widget, event->pos());
+
+ QWheelEvent translated(mapped, event->globalPos(), event->delta(), event->buttons(), event->modifiers(), event->orientation());
+ QGuiApplication::sendSpontaneousEvent(widget, &translated);
+}
+
+QT_END_NAMESPACE
diff --git a/src/widgets/kernel/qwidgetwindow_qpa_p.h b/src/widgets/kernel/qwidgetwindow_qpa_p.h
new file mode 100644
index 0000000000..9eb1e4f60e
--- /dev/null
+++ b/src/widgets/kernel/qwidgetwindow_qpa_p.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWIDGETWINDOW_QPA_P_H
+#define QWIDGETWINDOW_QPA_P_H
+
+#include <QtGui/qwindow.h>
+
+#include <QtCore/private/qobject_p.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QWidgetWindow : public QWindow
+{
+ Q_OBJECT
+public:
+ QWidgetWindow(QWidget *widget);
+
+ QWidget *widget() const { return m_widget; }
+
+protected:
+ bool event(QEvent *);
+
+ void handleCloseEvent(QCloseEvent *);
+ void handleEnterLeaveEvent(QEvent *);
+ void handleKeyEvent(QKeyEvent *);
+ void handleMouseEvent(QMouseEvent *);
+ void handleMoveEvent(QMoveEvent *);
+ void handleResizeEvent(QResizeEvent *);
+ void handleWheelEvent(QWheelEvent *);
+
+private:
+ QWidget *m_widget;
+ QWeakPointer<QWidget> m_implicit_mouse_grabber;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QWIDGETWINDOW_QPA_P_H
diff --git a/src/gui/kernel/symbian.pri b/src/widgets/kernel/symbian.pri
index 69422dd02e..69422dd02e 100644
--- a/src/gui/kernel/symbian.pri
+++ b/src/widgets/kernel/symbian.pri
diff --git a/src/gui/kernel/win.pri b/src/widgets/kernel/win.pri
index 5ecf4dd94a..5ecf4dd94a 100644
--- a/src/gui/kernel/win.pri
+++ b/src/widgets/kernel/win.pri
diff --git a/src/gui/kernel/x11.pri b/src/widgets/kernel/x11.pri
index 82de1b68af..82de1b68af 100644
--- a/src/gui/kernel/x11.pri
+++ b/src/widgets/kernel/x11.pri
diff --git a/src/gui/mac/images/copyarrowcursor.png b/src/widgets/mac/images/copyarrowcursor.png
index 13dfca95bc..13dfca95bc 100644
--- a/src/gui/mac/images/copyarrowcursor.png
+++ b/src/widgets/mac/images/copyarrowcursor.png
Binary files differ
diff --git a/src/gui/mac/images/forbiddencursor.png b/src/widgets/mac/images/forbiddencursor.png
index a9f21b4a5e..a9f21b4a5e 100644
--- a/src/gui/mac/images/forbiddencursor.png
+++ b/src/widgets/mac/images/forbiddencursor.png
Binary files differ
diff --git a/src/gui/mac/images/leopard-unified-toolbar-on.png b/src/widgets/mac/images/leopard-unified-toolbar-on.png
index 6716597046..6716597046 100644
--- a/src/gui/mac/images/leopard-unified-toolbar-on.png
+++ b/src/widgets/mac/images/leopard-unified-toolbar-on.png
Binary files differ
diff --git a/src/gui/mac/images/pluscursor.png b/src/widgets/mac/images/pluscursor.png
index c583c088c9..c583c088c9 100644
--- a/src/gui/mac/images/pluscursor.png
+++ b/src/widgets/mac/images/pluscursor.png
Binary files differ
diff --git a/src/gui/mac/images/spincursor.png b/src/widgets/mac/images/spincursor.png
index ca44ab50fd..ca44ab50fd 100644
--- a/src/gui/mac/images/spincursor.png
+++ b/src/widgets/mac/images/spincursor.png
Binary files differ
diff --git a/src/gui/mac/images/waitcursor.png b/src/widgets/mac/images/waitcursor.png
index a9abe61320..a9abe61320 100644
--- a/src/gui/mac/images/waitcursor.png
+++ b/src/widgets/mac/images/waitcursor.png
Binary files differ
diff --git a/src/gui/mac/macresources.qrc b/src/widgets/mac/macresources.qrc
index 9696002205..9696002205 100644
--- a/src/gui/mac/macresources.qrc
+++ b/src/widgets/mac/macresources.qrc
diff --git a/src/gui/mac/qt_menu.nib/classes.nib b/src/widgets/mac/qt_menu.nib/classes.nib
index 0031e0e4e5..0031e0e4e5 100644
--- a/src/gui/mac/qt_menu.nib/classes.nib
+++ b/src/widgets/mac/qt_menu.nib/classes.nib
diff --git a/src/gui/mac/qt_menu.nib/info.nib b/src/widgets/mac/qt_menu.nib/info.nib
index 02e5cca562..02e5cca562 100644
--- a/src/gui/mac/qt_menu.nib/info.nib
+++ b/src/widgets/mac/qt_menu.nib/info.nib
diff --git a/src/gui/mac/qt_menu.nib/keyedobjects.nib b/src/widgets/mac/qt_menu.nib/keyedobjects.nib
index 3edb0ed2eb..3edb0ed2eb 100644
--- a/src/gui/mac/qt_menu.nib/keyedobjects.nib
+++ b/src/widgets/mac/qt_menu.nib/keyedobjects.nib
Binary files differ
diff --git a/src/gui/kernel/qapplication_mac.mm b/src/widgets/platforms/mac/qapplication_mac.mm
index f607a72e92..f607a72e92 100644
--- a/src/gui/kernel/qapplication_mac.mm
+++ b/src/widgets/platforms/mac/qapplication_mac.mm
diff --git a/src/gui/kernel/qclipboard_mac.cpp b/src/widgets/platforms/mac/qclipboard_mac.cpp
index 4a8bc56e41..4a8bc56e41 100644
--- a/src/gui/kernel/qclipboard_mac.cpp
+++ b/src/widgets/platforms/mac/qclipboard_mac.cpp
diff --git a/src/gui/kernel/qcocoaapplication_mac.mm b/src/widgets/platforms/mac/qcocoaapplication_mac.mm
index 872f31dec7..872f31dec7 100644
--- a/src/gui/kernel/qcocoaapplication_mac.mm
+++ b/src/widgets/platforms/mac/qcocoaapplication_mac.mm
diff --git a/src/gui/kernel/qcocoaapplication_mac_p.h b/src/widgets/platforms/mac/qcocoaapplication_mac_p.h
index 0c3f5e442d..0c3f5e442d 100644
--- a/src/gui/kernel/qcocoaapplication_mac_p.h
+++ b/src/widgets/platforms/mac/qcocoaapplication_mac_p.h
diff --git a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm b/src/widgets/platforms/mac/qcocoaapplicationdelegate_mac.mm
index 77cd8902c3..77cd8902c3 100644
--- a/src/gui/kernel/qcocoaapplicationdelegate_mac.mm
+++ b/src/widgets/platforms/mac/qcocoaapplicationdelegate_mac.mm
diff --git a/src/gui/kernel/qcocoaapplicationdelegate_mac_p.h b/src/widgets/platforms/mac/qcocoaapplicationdelegate_mac_p.h
index 714c046f48..714c046f48 100644
--- a/src/gui/kernel/qcocoaapplicationdelegate_mac_p.h
+++ b/src/widgets/platforms/mac/qcocoaapplicationdelegate_mac_p.h
diff --git a/src/gui/kernel/qcocoaintrospection_mac.mm b/src/widgets/platforms/mac/qcocoaintrospection_mac.mm
index 70c893aeec..70c893aeec 100644
--- a/src/gui/kernel/qcocoaintrospection_mac.mm
+++ b/src/widgets/platforms/mac/qcocoaintrospection_mac.mm
diff --git a/src/gui/kernel/qcocoaintrospection_p.h b/src/widgets/platforms/mac/qcocoaintrospection_p.h
index 1c7d6ac13c..1c7d6ac13c 100644
--- a/src/gui/kernel/qcocoaintrospection_p.h
+++ b/src/widgets/platforms/mac/qcocoaintrospection_p.h
diff --git a/src/gui/kernel/qcocoamenuloader_mac.mm b/src/widgets/platforms/mac/qcocoamenuloader_mac.mm
index 71ff011069..71ff011069 100644
--- a/src/gui/kernel/qcocoamenuloader_mac.mm
+++ b/src/widgets/platforms/mac/qcocoamenuloader_mac.mm
diff --git a/src/gui/kernel/qcocoamenuloader_mac_p.h b/src/widgets/platforms/mac/qcocoamenuloader_mac_p.h
index cfcc7e00c6..cfcc7e00c6 100644
--- a/src/gui/kernel/qcocoamenuloader_mac_p.h
+++ b/src/widgets/platforms/mac/qcocoamenuloader_mac_p.h
diff --git a/src/gui/kernel/qcocoapanel_mac.mm b/src/widgets/platforms/mac/qcocoapanel_mac.mm
index 67a12e25f8..67a12e25f8 100644
--- a/src/gui/kernel/qcocoapanel_mac.mm
+++ b/src/widgets/platforms/mac/qcocoapanel_mac.mm
diff --git a/src/gui/kernel/qcocoapanel_mac_p.h b/src/widgets/platforms/mac/qcocoapanel_mac_p.h
index 542615903e..542615903e 100644
--- a/src/gui/kernel/qcocoapanel_mac_p.h
+++ b/src/widgets/platforms/mac/qcocoapanel_mac_p.h
diff --git a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h b/src/widgets/platforms/mac/qcocoasharedwindowmethods_mac_p.h
index ee1115bd4e..ee1115bd4e 100644
--- a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
+++ b/src/widgets/platforms/mac/qcocoasharedwindowmethods_mac_p.h
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/widgets/platforms/mac/qcocoaview_mac.mm
index e885d1552c..e885d1552c 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/widgets/platforms/mac/qcocoaview_mac.mm
diff --git a/src/gui/kernel/qcocoaview_mac_p.h b/src/widgets/platforms/mac/qcocoaview_mac_p.h
index cc79b6705b..cc79b6705b 100644
--- a/src/gui/kernel/qcocoaview_mac_p.h
+++ b/src/widgets/platforms/mac/qcocoaview_mac_p.h
diff --git a/src/gui/kernel/qcocoawindow_mac.mm b/src/widgets/platforms/mac/qcocoawindow_mac.mm
index 6e5023aaca..6e5023aaca 100644
--- a/src/gui/kernel/qcocoawindow_mac.mm
+++ b/src/widgets/platforms/mac/qcocoawindow_mac.mm
diff --git a/src/gui/kernel/qcocoawindow_mac_p.h b/src/widgets/platforms/mac/qcocoawindow_mac_p.h
index d567cab244..d567cab244 100644
--- a/src/gui/kernel/qcocoawindow_mac_p.h
+++ b/src/widgets/platforms/mac/qcocoawindow_mac_p.h
diff --git a/src/gui/kernel/qcocoawindowcustomthemeframe_mac.mm b/src/widgets/platforms/mac/qcocoawindowcustomthemeframe_mac.mm
index b761934c01..b761934c01 100644
--- a/src/gui/kernel/qcocoawindowcustomthemeframe_mac.mm
+++ b/src/widgets/platforms/mac/qcocoawindowcustomthemeframe_mac.mm
diff --git a/src/gui/kernel/qcocoawindowcustomthemeframe_mac_p.h b/src/widgets/platforms/mac/qcocoawindowcustomthemeframe_mac_p.h
index 09b40875f6..09b40875f6 100644
--- a/src/gui/kernel/qcocoawindowcustomthemeframe_mac_p.h
+++ b/src/widgets/platforms/mac/qcocoawindowcustomthemeframe_mac_p.h
diff --git a/src/gui/kernel/qcocoawindowdelegate_mac.mm b/src/widgets/platforms/mac/qcocoawindowdelegate_mac.mm
index 1faf068a12..1faf068a12 100644
--- a/src/gui/kernel/qcocoawindowdelegate_mac.mm
+++ b/src/widgets/platforms/mac/qcocoawindowdelegate_mac.mm
diff --git a/src/gui/kernel/qcocoawindowdelegate_mac_p.h b/src/widgets/platforms/mac/qcocoawindowdelegate_mac_p.h
index 638ce2df9a..638ce2df9a 100644
--- a/src/gui/kernel/qcocoawindowdelegate_mac_p.h
+++ b/src/widgets/platforms/mac/qcocoawindowdelegate_mac_p.h
diff --git a/src/gui/painting/qcolormap_mac.cpp b/src/widgets/platforms/mac/qcolormap_mac.cpp
index 28589f41b8..28589f41b8 100644
--- a/src/gui/painting/qcolormap_mac.cpp
+++ b/src/widgets/platforms/mac/qcolormap_mac.cpp
diff --git a/src/gui/kernel/qcursor_mac.mm b/src/widgets/platforms/mac/qcursor_mac.mm
index 0afa3ee4f0..0afa3ee4f0 100644
--- a/src/gui/kernel/qcursor_mac.mm
+++ b/src/widgets/platforms/mac/qcursor_mac.mm
diff --git a/src/gui/kernel/qdesktopwidget_mac.mm b/src/widgets/platforms/mac/qdesktopwidget_mac.mm
index 0b529c9843..0b529c9843 100644
--- a/src/gui/kernel/qdesktopwidget_mac.mm
+++ b/src/widgets/platforms/mac/qdesktopwidget_mac.mm
diff --git a/src/gui/kernel/qdesktopwidget_mac_p.h b/src/widgets/platforms/mac/qdesktopwidget_mac_p.h
index ac638ea7d8..ac638ea7d8 100644
--- a/src/gui/kernel/qdesktopwidget_mac_p.h
+++ b/src/widgets/platforms/mac/qdesktopwidget_mac_p.h
diff --git a/src/gui/kernel/qdnd_mac.mm b/src/widgets/platforms/mac/qdnd_mac.mm
index 3af2ba007c..3af2ba007c 100644
--- a/src/gui/kernel/qdnd_mac.mm
+++ b/src/widgets/platforms/mac/qdnd_mac.mm
diff --git a/src/gui/kernel/qeventdispatcher_mac.mm b/src/widgets/platforms/mac/qeventdispatcher_mac.mm
index 677a7368b4..677a7368b4 100644
--- a/src/gui/kernel/qeventdispatcher_mac.mm
+++ b/src/widgets/platforms/mac/qeventdispatcher_mac.mm
diff --git a/src/gui/kernel/qeventdispatcher_mac_p.h b/src/widgets/platforms/mac/qeventdispatcher_mac_p.h
index 12fcafbb01..12fcafbb01 100644
--- a/src/gui/kernel/qeventdispatcher_mac_p.h
+++ b/src/widgets/platforms/mac/qeventdispatcher_mac_p.h
diff --git a/src/gui/text/qfont_mac.cpp b/src/widgets/platforms/mac/qfont_mac.cpp
index 044fd84a8b..044fd84a8b 100644
--- a/src/gui/text/qfont_mac.cpp
+++ b/src/widgets/platforms/mac/qfont_mac.cpp
diff --git a/src/gui/text/qfontdatabase_mac.cpp b/src/widgets/platforms/mac/qfontdatabase_mac.cpp
index 5ba236b5f7..5ba236b5f7 100644
--- a/src/gui/text/qfontdatabase_mac.cpp
+++ b/src/widgets/platforms/mac/qfontdatabase_mac.cpp
diff --git a/src/gui/text/qfontengine_coretext.mm b/src/widgets/platforms/mac/qfontengine_coretext.mm
index cbf51e6ec5..cbf51e6ec5 100644
--- a/src/gui/text/qfontengine_coretext.mm
+++ b/src/widgets/platforms/mac/qfontengine_coretext.mm
diff --git a/src/gui/text/qfontengine_coretext_p.h b/src/widgets/platforms/mac/qfontengine_coretext_p.h
index 3775bc6002..3775bc6002 100644
--- a/src/gui/text/qfontengine_coretext_p.h
+++ b/src/widgets/platforms/mac/qfontengine_coretext_p.h
diff --git a/src/gui/text/qfontengine_mac.mm b/src/widgets/platforms/mac/qfontengine_mac.mm
index 9f094ad7d1..9f094ad7d1 100644
--- a/src/gui/text/qfontengine_mac.mm
+++ b/src/widgets/platforms/mac/qfontengine_mac.mm
diff --git a/src/gui/text/qfontengine_mac_p.h b/src/widgets/platforms/mac/qfontengine_mac_p.h
index 292ea98d9a..292ea98d9a 100644
--- a/src/gui/text/qfontengine_mac_p.h
+++ b/src/widgets/platforms/mac/qfontengine_mac_p.h
diff --git a/src/gui/kernel/qkeymapper_mac.cpp b/src/widgets/platforms/mac/qkeymapper_mac.cpp
index d3bbf89711..d3bbf89711 100644
--- a/src/gui/kernel/qkeymapper_mac.cpp
+++ b/src/widgets/platforms/mac/qkeymapper_mac.cpp
diff --git a/src/gui/kernel/qmacdefines_mac.h b/src/widgets/platforms/mac/qmacdefines_mac.h
index d6ccb93593..d6ccb93593 100644
--- a/src/gui/kernel/qmacdefines_mac.h
+++ b/src/widgets/platforms/mac/qmacdefines_mac.h
diff --git a/src/gui/kernel/qmacgesturerecognizer_mac.mm b/src/widgets/platforms/mac/qmacgesturerecognizer_mac.mm
index 6a4f0bb445..6a4f0bb445 100644
--- a/src/gui/kernel/qmacgesturerecognizer_mac.mm
+++ b/src/widgets/platforms/mac/qmacgesturerecognizer_mac.mm
diff --git a/src/gui/kernel/qmacgesturerecognizer_mac_p.h b/src/widgets/platforms/mac/qmacgesturerecognizer_mac_p.h
index 465f6a2ac8..465f6a2ac8 100644
--- a/src/gui/kernel/qmacgesturerecognizer_mac_p.h
+++ b/src/widgets/platforms/mac/qmacgesturerecognizer_mac_p.h
diff --git a/src/gui/kernel/qmime_mac.cpp b/src/widgets/platforms/mac/qmime_mac.cpp
index d6f6222c23..d6f6222c23 100644
--- a/src/gui/kernel/qmime_mac.cpp
+++ b/src/widgets/platforms/mac/qmime_mac.cpp
diff --git a/src/gui/kernel/qmultitouch_mac.mm b/src/widgets/platforms/mac/qmultitouch_mac.mm
index d9e845a01c..d9e845a01c 100644
--- a/src/gui/kernel/qmultitouch_mac.mm
+++ b/src/widgets/platforms/mac/qmultitouch_mac.mm
diff --git a/src/gui/kernel/qmultitouch_mac_p.h b/src/widgets/platforms/mac/qmultitouch_mac_p.h
index 16be930d0a..16be930d0a 100644
--- a/src/gui/kernel/qmultitouch_mac_p.h
+++ b/src/widgets/platforms/mac/qmultitouch_mac_p.h
diff --git a/src/gui/kernel/qnsframeview_mac_p.h b/src/widgets/platforms/mac/qnsframeview_mac_p.h
index 6ec3f64efa..6ec3f64efa 100644
--- a/src/gui/kernel/qnsframeview_mac_p.h
+++ b/src/widgets/platforms/mac/qnsframeview_mac_p.h
diff --git a/src/gui/kernel/qnsthemeframe_mac_p.h b/src/widgets/platforms/mac/qnsthemeframe_mac_p.h
index 2cb4916c06..2cb4916c06 100644
--- a/src/gui/kernel/qnsthemeframe_mac_p.h
+++ b/src/widgets/platforms/mac/qnsthemeframe_mac_p.h
diff --git a/src/gui/kernel/qnstitledframe_mac_p.h b/src/widgets/platforms/mac/qnstitledframe_mac_p.h
index 4eb5332194..4eb5332194 100644
--- a/src/gui/kernel/qnstitledframe_mac_p.h
+++ b/src/widgets/platforms/mac/qnstitledframe_mac_p.h
diff --git a/src/gui/painting/qpaintdevice_mac.cpp b/src/widgets/platforms/mac/qpaintdevice_mac.cpp
index 245408a0b0..245408a0b0 100644
--- a/src/gui/painting/qpaintdevice_mac.cpp
+++ b/src/widgets/platforms/mac/qpaintdevice_mac.cpp
diff --git a/src/gui/painting/qpaintengine_mac.cpp b/src/widgets/platforms/mac/qpaintengine_mac.cpp
index 6dcc3cc9fc..6dcc3cc9fc 100644
--- a/src/gui/painting/qpaintengine_mac.cpp
+++ b/src/widgets/platforms/mac/qpaintengine_mac.cpp
diff --git a/src/gui/painting/qpaintengine_mac_p.h b/src/widgets/platforms/mac/qpaintengine_mac_p.h
index 3e71d6ca6b..3e71d6ca6b 100644
--- a/src/gui/painting/qpaintengine_mac_p.h
+++ b/src/widgets/platforms/mac/qpaintengine_mac_p.h
diff --git a/src/gui/image/qpixmap_mac.cpp b/src/widgets/platforms/mac/qpixmap_mac.cpp
index 72e2aa6e04..72e2aa6e04 100644
--- a/src/gui/image/qpixmap_mac.cpp
+++ b/src/widgets/platforms/mac/qpixmap_mac.cpp
diff --git a/src/gui/image/qpixmap_mac_p.h b/src/widgets/platforms/mac/qpixmap_mac_p.h
index 307e38aceb..307e38aceb 100644
--- a/src/gui/image/qpixmap_mac_p.h
+++ b/src/widgets/platforms/mac/qpixmap_mac_p.h
diff --git a/src/gui/painting/qprintengine_mac.mm b/src/widgets/platforms/mac/qprintengine_mac.mm
index 1dce30301f..1dce30301f 100644
--- a/src/gui/painting/qprintengine_mac.mm
+++ b/src/widgets/platforms/mac/qprintengine_mac.mm
diff --git a/src/gui/painting/qprintengine_mac_p.h b/src/widgets/platforms/mac/qprintengine_mac_p.h
index 511705d26f..511705d26f 100644
--- a/src/gui/painting/qprintengine_mac_p.h
+++ b/src/widgets/platforms/mac/qprintengine_mac_p.h
diff --git a/src/gui/painting/qprinterinfo_mac.cpp b/src/widgets/platforms/mac/qprinterinfo_mac.cpp
index b24ab70267..b24ab70267 100644
--- a/src/gui/painting/qprinterinfo_mac.cpp
+++ b/src/widgets/platforms/mac/qprinterinfo_mac.cpp
diff --git a/src/gui/text/qrawfont_mac.cpp b/src/widgets/platforms/mac/qrawfont_mac.cpp
index 1ed4185a5d..1ed4185a5d 100644
--- a/src/gui/text/qrawfont_mac.cpp
+++ b/src/widgets/platforms/mac/qrawfont_mac.cpp
diff --git a/src/gui/painting/qregion_mac.cpp b/src/widgets/platforms/mac/qregion_mac.cpp
index 50fd783df4..50fd783df4 100644
--- a/src/gui/painting/qregion_mac.cpp
+++ b/src/widgets/platforms/mac/qregion_mac.cpp
diff --git a/src/gui/kernel/qsound_mac.mm b/src/widgets/platforms/mac/qsound_mac.mm
index 5a9af135b0..5a9af135b0 100644
--- a/src/gui/kernel/qsound_mac.mm
+++ b/src/widgets/platforms/mac/qsound_mac.mm
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/widgets/platforms/mac/qt_cocoa_helpers_mac.mm
index 32123ee682..32123ee682 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac.mm
+++ b/src/widgets/platforms/mac/qt_cocoa_helpers_mac.mm
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac_p.h b/src/widgets/platforms/mac/qt_cocoa_helpers_mac_p.h
index a49753ae2f..a49753ae2f 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac_p.h
+++ b/src/widgets/platforms/mac/qt_cocoa_helpers_mac_p.h
diff --git a/src/gui/kernel/qt_mac.cpp b/src/widgets/platforms/mac/qt_mac.cpp
index 046bcf6a54..046bcf6a54 100644
--- a/src/gui/kernel/qt_mac.cpp
+++ b/src/widgets/platforms/mac/qt_mac.cpp
diff --git a/src/gui/kernel/qt_mac_p.h b/src/widgets/platforms/mac/qt_mac_p.h
index b2bb804ff0..b2bb804ff0 100644
--- a/src/gui/kernel/qt_mac_p.h
+++ b/src/widgets/platforms/mac/qt_mac_p.h
diff --git a/src/gui/text/qtextengine_mac.cpp b/src/widgets/platforms/mac/qtextengine_mac.cpp
index 2c6e579b45..2c6e579b45 100644
--- a/src/gui/text/qtextengine_mac.cpp
+++ b/src/widgets/platforms/mac/qtextengine_mac.cpp
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/widgets/platforms/mac/qwidget_mac.mm
index 27a1bb6940..27a1bb6940 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/widgets/platforms/mac/qwidget_mac.mm
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/widgets/platforms/s60/qapplication_s60.cpp
index 222150056e..222150056e 100644
--- a/src/gui/kernel/qapplication_s60.cpp
+++ b/src/widgets/platforms/s60/qapplication_s60.cpp
diff --git a/src/gui/kernel/qclipboard_s60.cpp b/src/widgets/platforms/s60/qclipboard_s60.cpp
index 0dafae0996..0dafae0996 100644
--- a/src/gui/kernel/qclipboard_s60.cpp
+++ b/src/widgets/platforms/s60/qclipboard_s60.cpp
diff --git a/src/gui/painting/qcolormap_s60.cpp b/src/widgets/platforms/s60/qcolormap_s60.cpp
index 2c634db8a5..2c634db8a5 100644
--- a/src/gui/painting/qcolormap_s60.cpp
+++ b/src/widgets/platforms/s60/qcolormap_s60.cpp
diff --git a/src/gui/kernel/qcursor_s60.cpp b/src/widgets/platforms/s60/qcursor_s60.cpp
index 8dfe87ef81..8dfe87ef81 100644
--- a/src/gui/kernel/qcursor_s60.cpp
+++ b/src/widgets/platforms/s60/qcursor_s60.cpp
diff --git a/src/gui/kernel/qdesktopwidget_s60.cpp b/src/widgets/platforms/s60/qdesktopwidget_s60.cpp
index 62a4d40eba..62a4d40eba 100644
--- a/src/gui/kernel/qdesktopwidget_s60.cpp
+++ b/src/widgets/platforms/s60/qdesktopwidget_s60.cpp
diff --git a/src/gui/kernel/qdnd_s60.cpp b/src/widgets/platforms/s60/qdnd_s60.cpp
index a9847a98f8..a9847a98f8 100644
--- a/src/gui/kernel/qdnd_s60.cpp
+++ b/src/widgets/platforms/s60/qdnd_s60.cpp
diff --git a/src/gui/kernel/qeventdispatcher_s60.cpp b/src/widgets/platforms/s60/qeventdispatcher_s60.cpp
index 2d92c89c07..2d92c89c07 100644
--- a/src/gui/kernel/qeventdispatcher_s60.cpp
+++ b/src/widgets/platforms/s60/qeventdispatcher_s60.cpp
diff --git a/src/gui/kernel/qeventdispatcher_s60_p.h b/src/widgets/platforms/s60/qeventdispatcher_s60_p.h
index 7c5a8d03d4..7c5a8d03d4 100644
--- a/src/gui/kernel/qeventdispatcher_s60_p.h
+++ b/src/widgets/platforms/s60/qeventdispatcher_s60_p.h
diff --git a/src/gui/text/qfont_s60.cpp b/src/widgets/platforms/s60/qfont_s60.cpp
index 114191d765..114191d765 100644
--- a/src/gui/text/qfont_s60.cpp
+++ b/src/widgets/platforms/s60/qfont_s60.cpp
diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/widgets/platforms/s60/qfontdatabase_s60.cpp
index 3ab1ac8850..3ab1ac8850 100644
--- a/src/gui/text/qfontdatabase_s60.cpp
+++ b/src/widgets/platforms/s60/qfontdatabase_s60.cpp
diff --git a/src/gui/text/qfontengine_s60.cpp b/src/widgets/platforms/s60/qfontengine_s60.cpp
index e9b54e350f..e9b54e350f 100644
--- a/src/gui/text/qfontengine_s60.cpp
+++ b/src/widgets/platforms/s60/qfontengine_s60.cpp
diff --git a/src/gui/text/qfontengine_s60_p.h b/src/widgets/platforms/s60/qfontengine_s60_p.h
index c0eeef5264..c0eeef5264 100644
--- a/src/gui/text/qfontengine_s60_p.h
+++ b/src/widgets/platforms/s60/qfontengine_s60_p.h
diff --git a/src/gui/kernel/qkeymapper_s60.cpp b/src/widgets/platforms/s60/qkeymapper_s60.cpp
index 08cfae0d2d..08cfae0d2d 100644
--- a/src/gui/kernel/qkeymapper_s60.cpp
+++ b/src/widgets/platforms/s60/qkeymapper_s60.cpp
diff --git a/src/gui/painting/qpaintengine_s60.cpp b/src/widgets/platforms/s60/qpaintengine_s60.cpp
index ca303be03d..ca303be03d 100644
--- a/src/gui/painting/qpaintengine_s60.cpp
+++ b/src/widgets/platforms/s60/qpaintengine_s60.cpp
diff --git a/src/gui/painting/qpaintengine_s60_p.h b/src/widgets/platforms/s60/qpaintengine_s60_p.h
index a62bdac97c..a62bdac97c 100644
--- a/src/gui/painting/qpaintengine_s60_p.h
+++ b/src/widgets/platforms/s60/qpaintengine_s60_p.h
diff --git a/src/gui/image/qpixmap_s60.cpp b/src/widgets/platforms/s60/qpixmap_s60.cpp
index c8aa003ffa..c8aa003ffa 100644
--- a/src/gui/image/qpixmap_s60.cpp
+++ b/src/widgets/platforms/s60/qpixmap_s60.cpp
diff --git a/src/gui/image/qpixmap_s60_p.h b/src/widgets/platforms/s60/qpixmap_s60_p.h
index c440bbc33a..c440bbc33a 100644
--- a/src/gui/image/qpixmap_s60_p.h
+++ b/src/widgets/platforms/s60/qpixmap_s60_p.h
diff --git a/src/gui/painting/qregion_s60.cpp b/src/widgets/platforms/s60/qregion_s60.cpp
index eafff1b965..eafff1b965 100644
--- a/src/gui/painting/qregion_s60.cpp
+++ b/src/widgets/platforms/s60/qregion_s60.cpp
diff --git a/src/gui/kernel/qsoftkeymanager_s60.cpp b/src/widgets/platforms/s60/qsoftkeymanager_s60.cpp
index 79ed91af5b..79ed91af5b 100644
--- a/src/gui/kernel/qsoftkeymanager_s60.cpp
+++ b/src/widgets/platforms/s60/qsoftkeymanager_s60.cpp
diff --git a/src/gui/kernel/qsoftkeymanager_s60_p.h b/src/widgets/platforms/s60/qsoftkeymanager_s60_p.h
index 9cb3787cb8..9cb3787cb8 100644
--- a/src/gui/kernel/qsoftkeymanager_s60_p.h
+++ b/src/widgets/platforms/s60/qsoftkeymanager_s60_p.h
diff --git a/src/gui/kernel/qsound_s60.cpp b/src/widgets/platforms/s60/qsound_s60.cpp
index acc5c2a56f..acc5c2a56f 100644
--- a/src/gui/kernel/qsound_s60.cpp
+++ b/src/widgets/platforms/s60/qsound_s60.cpp
diff --git a/src/gui/kernel/qt_s60_p.h b/src/widgets/platforms/s60/qt_s60_p.h
index 02977ceaf5..02977ceaf5 100644
--- a/src/gui/kernel/qt_s60_p.h
+++ b/src/widgets/platforms/s60/qt_s60_p.h
diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/widgets/platforms/s60/qwidget_s60.cpp
index 12bcc4b4cc..12bcc4b4cc 100644
--- a/src/gui/kernel/qwidget_s60.cpp
+++ b/src/widgets/platforms/s60/qwidget_s60.cpp
diff --git a/src/gui/kernel/qapplication_win.cpp b/src/widgets/platforms/win/qapplication_win.cpp
index 63e2319b3e..63e2319b3e 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/widgets/platforms/win/qapplication_win.cpp
diff --git a/src/gui/kernel/qclipboard_win.cpp b/src/widgets/platforms/win/qclipboard_win.cpp
index ea41165b9c..ea41165b9c 100644
--- a/src/gui/kernel/qclipboard_win.cpp
+++ b/src/widgets/platforms/win/qclipboard_win.cpp
diff --git a/src/gui/painting/qcolormap_win.cpp b/src/widgets/platforms/win/qcolormap_win.cpp
index 1773f717c0..1773f717c0 100644
--- a/src/gui/painting/qcolormap_win.cpp
+++ b/src/widgets/platforms/win/qcolormap_win.cpp
diff --git a/src/gui/kernel/qcursor_win.cpp b/src/widgets/platforms/win/qcursor_win.cpp
index 8a9362ebfc..8a9362ebfc 100644
--- a/src/gui/kernel/qcursor_win.cpp
+++ b/src/widgets/platforms/win/qcursor_win.cpp
diff --git a/src/gui/kernel/qdesktopwidget_win.cpp b/src/widgets/platforms/win/qdesktopwidget_win.cpp
index d57b355ef4..d57b355ef4 100644
--- a/src/gui/kernel/qdesktopwidget_win.cpp
+++ b/src/widgets/platforms/win/qdesktopwidget_win.cpp
diff --git a/src/gui/kernel/qdnd_win.cpp b/src/widgets/platforms/win/qdnd_win.cpp
index 176e3cef7f..176e3cef7f 100644
--- a/src/gui/kernel/qdnd_win.cpp
+++ b/src/widgets/platforms/win/qdnd_win.cpp
diff --git a/src/gui/text/qfont_win.cpp b/src/widgets/platforms/win/qfont_win.cpp
index 3ef761bfa5..3ef761bfa5 100644
--- a/src/gui/text/qfont_win.cpp
+++ b/src/widgets/platforms/win/qfont_win.cpp
diff --git a/src/gui/text/qfontdatabase_win.cpp b/src/widgets/platforms/win/qfontdatabase_win.cpp
index 05b7509bf6..05b7509bf6 100644
--- a/src/gui/text/qfontdatabase_win.cpp
+++ b/src/widgets/platforms/win/qfontdatabase_win.cpp
diff --git a/src/gui/text/qfontengine_win.cpp b/src/widgets/platforms/win/qfontengine_win.cpp
index 54d7ec2980..54d7ec2980 100644
--- a/src/gui/text/qfontengine_win.cpp
+++ b/src/widgets/platforms/win/qfontengine_win.cpp
diff --git a/src/gui/text/qfontengine_win_p.h b/src/widgets/platforms/win/qfontengine_win_p.h
index 114149d61f..114149d61f 100644
--- a/src/gui/text/qfontengine_win_p.h
+++ b/src/widgets/platforms/win/qfontengine_win_p.h
diff --git a/src/gui/kernel/qguifunctions_wince.cpp b/src/widgets/platforms/win/qguifunctions_wince.cpp
index bb4ed11589..bb4ed11589 100644
--- a/src/gui/kernel/qguifunctions_wince.cpp
+++ b/src/widgets/platforms/win/qguifunctions_wince.cpp
diff --git a/src/gui/kernel/qguifunctions_wince.h b/src/widgets/platforms/win/qguifunctions_wince.h
index 2e14de0693..2e14de0693 100644
--- a/src/gui/kernel/qguifunctions_wince.h
+++ b/src/widgets/platforms/win/qguifunctions_wince.h
diff --git a/src/gui/kernel/qkeymapper_win.cpp b/src/widgets/platforms/win/qkeymapper_win.cpp
index 92fa582617..92fa582617 100644
--- a/src/gui/kernel/qkeymapper_win.cpp
+++ b/src/widgets/platforms/win/qkeymapper_win.cpp
diff --git a/src/gui/kernel/qmime_win.cpp b/src/widgets/platforms/win/qmime_win.cpp
index feb8b78eca..feb8b78eca 100644
--- a/src/gui/kernel/qmime_win.cpp
+++ b/src/widgets/platforms/win/qmime_win.cpp
diff --git a/src/gui/kernel/qole_win.cpp b/src/widgets/platforms/win/qole_win.cpp
index 24e2d5b292..24e2d5b292 100644
--- a/src/gui/kernel/qole_win.cpp
+++ b/src/widgets/platforms/win/qole_win.cpp
diff --git a/src/gui/painting/qpaintdevice_win.cpp b/src/widgets/platforms/win/qpaintdevice_win.cpp
index 3dbe97492a..3dbe97492a 100644
--- a/src/gui/painting/qpaintdevice_win.cpp
+++ b/src/widgets/platforms/win/qpaintdevice_win.cpp
diff --git a/src/gui/image/qpixmap_win.cpp b/src/widgets/platforms/win/qpixmap_win.cpp
index 9c14ac7726..9c14ac7726 100644
--- a/src/gui/image/qpixmap_win.cpp
+++ b/src/widgets/platforms/win/qpixmap_win.cpp
diff --git a/src/gui/painting/qprintengine_win.cpp b/src/widgets/platforms/win/qprintengine_win.cpp
index 07d66f5bd0..07d66f5bd0 100644
--- a/src/gui/painting/qprintengine_win.cpp
+++ b/src/widgets/platforms/win/qprintengine_win.cpp
diff --git a/src/gui/painting/qprintengine_win_p.h b/src/widgets/platforms/win/qprintengine_win_p.h
index b4d0670e7b..b4d0670e7b 100644
--- a/src/gui/painting/qprintengine_win_p.h
+++ b/src/widgets/platforms/win/qprintengine_win_p.h
diff --git a/src/gui/painting/qprinterinfo_win.cpp b/src/widgets/platforms/win/qprinterinfo_win.cpp
index 2c4014d8dc..2c4014d8dc 100644
--- a/src/gui/painting/qprinterinfo_win.cpp
+++ b/src/widgets/platforms/win/qprinterinfo_win.cpp
diff --git a/src/gui/text/qrawfont_win.cpp b/src/widgets/platforms/win/qrawfont_win.cpp
index d8acf57431..d8acf57431 100644
--- a/src/gui/text/qrawfont_win.cpp
+++ b/src/widgets/platforms/win/qrawfont_win.cpp
diff --git a/src/gui/painting/qregion_win.cpp b/src/widgets/platforms/win/qregion_win.cpp
index 3466b62cbd..3466b62cbd 100644
--- a/src/gui/painting/qregion_win.cpp
+++ b/src/widgets/platforms/win/qregion_win.cpp
diff --git a/src/gui/kernel/qsound_win.cpp b/src/widgets/platforms/win/qsound_win.cpp
index c11482d608..c11482d608 100644
--- a/src/gui/kernel/qsound_win.cpp
+++ b/src/widgets/platforms/win/qsound_win.cpp
diff --git a/src/gui/kernel/qwidget_win.cpp b/src/widgets/platforms/win/qwidget_win.cpp
index a02c5ba008..a02c5ba008 100644
--- a/src/gui/kernel/qwidget_win.cpp
+++ b/src/widgets/platforms/win/qwidget_win.cpp
diff --git a/src/gui/kernel/qwidget_wince.cpp b/src/widgets/platforms/win/qwidget_wince.cpp
index 7676182ef0..7676182ef0 100644
--- a/src/gui/kernel/qwidget_wince.cpp
+++ b/src/widgets/platforms/win/qwidget_wince.cpp
diff --git a/src/gui/kernel/qwindowdefs_win.h b/src/widgets/platforms/win/qwindowdefs_win.h
index a4dd38410c..a4dd38410c 100644
--- a/src/gui/kernel/qwindowdefs_win.h
+++ b/src/widgets/platforms/win/qwindowdefs_win.h
diff --git a/src/gui/kernel/qwinnativepangesturerecognizer_win.cpp b/src/widgets/platforms/win/qwinnativepangesturerecognizer_win.cpp
index 0d13bafc0c..0d13bafc0c 100644
--- a/src/gui/kernel/qwinnativepangesturerecognizer_win.cpp
+++ b/src/widgets/platforms/win/qwinnativepangesturerecognizer_win.cpp
diff --git a/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h b/src/widgets/platforms/win/qwinnativepangesturerecognizer_win_p.h
index 6d23e41ce3..6d23e41ce3 100644
--- a/src/gui/kernel/qwinnativepangesturerecognizer_win_p.h
+++ b/src/widgets/platforms/win/qwinnativepangesturerecognizer_win_p.h
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/widgets/platforms/x11/qapplication_x11.cpp
index 20542ea328..20542ea328 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/widgets/platforms/x11/qapplication_x11.cpp
diff --git a/src/gui/kernel/qclipboard_x11.cpp b/src/widgets/platforms/x11/qclipboard_x11.cpp
index d566c86e04..d566c86e04 100644
--- a/src/gui/kernel/qclipboard_x11.cpp
+++ b/src/widgets/platforms/x11/qclipboard_x11.cpp
diff --git a/src/gui/painting/qcolormap_x11.cpp b/src/widgets/platforms/x11/qcolormap_x11.cpp
index 05eefa455b..05eefa455b 100644
--- a/src/gui/painting/qcolormap_x11.cpp
+++ b/src/widgets/platforms/x11/qcolormap_x11.cpp
diff --git a/src/gui/kernel/qcursor_x11.cpp b/src/widgets/platforms/x11/qcursor_x11.cpp
index 0bc725036c..0bc725036c 100644
--- a/src/gui/kernel/qcursor_x11.cpp
+++ b/src/widgets/platforms/x11/qcursor_x11.cpp
diff --git a/src/gui/kernel/qdesktopwidget_x11.cpp b/src/widgets/platforms/x11/qdesktopwidget_x11.cpp
index b0f12903a1..b0f12903a1 100644
--- a/src/gui/kernel/qdesktopwidget_x11.cpp
+++ b/src/widgets/platforms/x11/qdesktopwidget_x11.cpp
diff --git a/src/widgets/platforms/x11/qdnd_x11.cpp b/src/widgets/platforms/x11/qdnd_x11.cpp
new file mode 100644
index 0000000000..9ff1543e51
--- /dev/null
+++ b/src/widgets/platforms/x11/qdnd_x11.cpp
@@ -0,0 +1,2072 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformdefs.h"
+
+#include "qapplication.h"
+
+#ifndef QT_NO_DRAGANDDROP
+
+#include "qwidget.h"
+#include "qpainter.h"
+#include "qpixmap.h"
+#include "qbitmap.h"
+#include "qdesktopwidget.h"
+#include "qevent.h"
+#include "qiodevice.h"
+#include "qpointer.h"
+#include "qcursor.h"
+#include "qelapsedtimer.h"
+#include "qvariant.h"
+#include "qvector.h"
+#include "qurl.h"
+#include "qdebug.h"
+#include "qimagewriter.h"
+#include "qbuffer.h"
+#include "qtextcodec.h"
+
+#include "qdnd_p.h"
+#include "qapplication_p.h"
+#include "qt_x11_p.h"
+#include "qx11info_x11.h"
+
+#include "qwidget_p.h"
+#include "qcursor_p.h"
+
+QT_BEGIN_NAMESPACE
+
+// #define DND_DEBUG
+#ifdef DND_DEBUG
+#define DEBUG qDebug
+#else
+#define DEBUG if(0) qDebug
+#endif
+
+#ifdef DND_DEBUG
+#define DNDDEBUG qDebug()
+#else
+#define DNDDEBUG if(0) qDebug()
+#endif
+
+static int findXdndDropTransactionByWindow(Window window)
+{
+ int at = -1;
+ for (int i = 0; i < X11->dndDropTransactions.count(); ++i) {
+ const QXdndDropTransaction &t = X11->dndDropTransactions.at(i);
+ if (t.target == window || t.proxy_target == window) {
+ at = i;
+ break;
+ }
+ }
+ return at;
+}
+
+static int findXdndDropTransactionByTime(Time timestamp)
+{
+ int at = -1;
+ for (int i = 0; i < X11->dndDropTransactions.count(); ++i) {
+ const QXdndDropTransaction &t = X11->dndDropTransactions.at(i);
+ if (t.timestamp == timestamp) {
+ at = i;
+ break;
+ }
+ }
+ return at;
+}
+
+// timer used to discard old XdndDrop transactions
+static int transaction_expiry_timer = -1;
+enum { XdndDropTransactionTimeout = 5000 }; // 5 seconds
+
+static void restartXdndDropExpiryTimer()
+{
+ if (transaction_expiry_timer != -1)
+ QDragManager::self()->killTimer(transaction_expiry_timer);
+ transaction_expiry_timer = QDragManager::self()->startTimer(XdndDropTransactionTimeout);
+}
+
+
+// find an ancestor with XdndAware on it
+static Window findXdndAwareParent(Window window)
+{
+ Window target = 0;
+ forever {
+ // check if window has XdndAware
+ Atom type = 0;
+ int f;
+ unsigned long n, a;
+ unsigned char *data = 0;
+ if (XGetWindowProperty(X11->display, window, ATOM(XdndAware), 0, 0, False,
+ AnyPropertyType, &type, &f,&n,&a,&data) == Success) {
+ if (data)
+ XFree(data);
+ if (type) {
+ target = window;
+ break;
+ }
+ }
+
+ // try window's parent
+ Window root;
+ Window parent;
+ Window *children;
+ uint unused;
+ if (!XQueryTree(X11->display, window, &root, &parent, &children, &unused))
+ break;
+ if (children)
+ XFree(children);
+ if (window == root)
+ break;
+ window = parent;
+ }
+ return target;
+}
+
+
+
+
+// and all this stuff is copied -into- qapp_x11.cpp
+
+static void handle_xdnd_position(QWidget *, const XEvent *, bool);
+static void handle_xdnd_status(QWidget * w, const XEvent * xe, bool /*passive*/);
+
+const int xdnd_version = 5;
+
+static Qt::DropAction xdndaction_to_qtaction(Atom atom)
+{
+ if (atom == ATOM(XdndActionCopy) || atom == 0)
+ return Qt::CopyAction;
+ if (atom == ATOM(XdndActionLink))
+ return Qt::LinkAction;
+ if (atom == ATOM(XdndActionMove))
+ return Qt::MoveAction;
+ return Qt::CopyAction;
+}
+
+static int qtaction_to_xdndaction(Qt::DropAction a)
+{
+ switch (a) {
+ case Qt::CopyAction:
+ return ATOM(XdndActionCopy);
+ case Qt::LinkAction:
+ return ATOM(XdndActionLink);
+ case Qt::MoveAction:
+ case Qt::TargetMoveAction:
+ return ATOM(XdndActionMove);
+ case Qt::IgnoreAction:
+ return XNone;
+ default:
+ return ATOM(XdndActionCopy);
+ }
+}
+
+// clean up the stuff used.
+static void qt_xdnd_cleanup();
+
+static void qt_xdnd_send_leave();
+
+// real variables:
+// xid of current drag source
+static Atom qt_xdnd_dragsource_xid = 0;
+
+// the types in this drop. 100 is no good, but at least it's big.
+const int qt_xdnd_max_type = 100;
+static Atom qt_xdnd_types[qt_xdnd_max_type + 1];
+
+// timer used when target wants "continuous" move messages (eg. scroll)
+static int heartbeat = -1;
+// rectangle in which the answer will be the same
+static QRect qt_xdnd_source_sameanswer;
+// top-level window we sent position to last.
+static Window qt_xdnd_current_target;
+// window to send events to (always valid if qt_xdnd_current_target)
+static Window qt_xdnd_current_proxy_target;
+static Time qt_xdnd_source_current_time;
+
+// widget we forwarded position to last, and local position
+static QPointer<QWidget> qt_xdnd_current_widget;
+static QPoint qt_xdnd_current_position;
+// timestamp from the XdndPosition and XdndDrop
+static Time qt_xdnd_target_current_time;
+// screen number containing the pointer... -1 means default
+static int qt_xdnd_current_screen = -1;
+// state of dragging... true if dragging, false if not
+bool qt_xdnd_dragging = false;
+
+static bool waiting_for_status = false;
+
+// used to preset each new QDragMoveEvent
+static Qt::DropAction last_target_accepted_action = Qt::IgnoreAction;
+
+// Shift/Ctrl handling, and final drop status
+static Qt::DropAction global_accepted_action = Qt::CopyAction;
+static Qt::DropActions possible_actions = Qt::IgnoreAction;
+
+// for embedding only
+static QWidget* current_embedding_widget = 0;
+static XEvent last_enter_event;
+
+// cursors
+static QCursor *noDropCursor = 0;
+static QCursor *moveCursor = 0;
+static QCursor *copyCursor = 0;
+static QCursor *linkCursor = 0;
+
+static QPixmap *defaultPm = 0;
+
+static const int default_pm_hotx = -2;
+static const int default_pm_hoty = -16;
+static const char* const default_pm[] = {
+"13 9 3 1",
+". c None",
+" c #000000",
+"X c #FFFFFF",
+"X X X X X X X",
+" X X X X X X ",
+"X ......... X",
+" X.........X ",
+"X ......... X",
+" X.........X ",
+"X ......... X",
+" X X X X X X ",
+"X X X X X X X"
+};
+
+class QShapedPixmapWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ QShapedPixmapWidget(QWidget* w) :
+ QWidget(w,
+ Qt::Tool | Qt::FramelessWindowHint
+ | Qt::X11BypassWindowManagerHint
+ | Qt::BypassGraphicsProxyWidget)
+ {
+ setAttribute(Qt::WA_X11NetWmWindowTypeDND);
+ }
+
+ void setPixmap(const QPixmap &pm)
+ {
+ QBitmap mask = pm.mask();
+ if (!mask.isNull()) {
+ setMask(mask);
+ } else {
+ clearMask();
+ }
+ resize(pm.width(),pm.height());
+ pixmap = pm;
+ update();
+ }
+ QPoint pm_hot;
+
+protected:
+ QPixmap pixmap;
+ void paintEvent(QPaintEvent*)
+ {
+ QPainter p(this);
+ p.drawPixmap(0, 0, pixmap);
+ }
+};
+
+#include "qdnd_x11.moc"
+
+struct XdndData {
+ QShapedPixmapWidget *deco;
+ QWidget* desktop_proxy;
+};
+
+static XdndData xdnd_data = { 0, 0 };
+
+class QExtraWidget : public QWidget
+{
+ Q_DECLARE_PRIVATE(QWidget)
+public:
+ inline QWExtra* extraData();
+ inline QTLWExtra* topData();
+};
+
+inline QWExtra* QExtraWidget::extraData() { return d_func()->extraData(); }
+inline QTLWExtra* QExtraWidget::topData() { return d_func()->topData(); }
+
+
+static WId xdndProxy(WId w)
+{
+ Atom type = XNone;
+ int f;
+ unsigned long n, a;
+ unsigned char *retval = 0;
+ XGetWindowProperty(X11->display, w, ATOM(XdndProxy), 0, 1, False,
+ XA_WINDOW, &type, &f,&n,&a,&retval);
+ WId *proxy_id_ptr = (WId *)retval;
+ WId proxy_id = 0;
+ if (type == XA_WINDOW && proxy_id_ptr) {
+ proxy_id = *proxy_id_ptr;
+ XFree(proxy_id_ptr);
+ proxy_id_ptr = 0;
+ // Already exists. Real?
+ X11->ignoreBadwindow();
+ XGetWindowProperty(X11->display, proxy_id, ATOM(XdndProxy), 0, 1, False,
+ XA_WINDOW, &type, &f,&n,&a,&retval);
+ proxy_id_ptr = (WId *)retval;
+ if (X11->badwindow() || type != XA_WINDOW || !proxy_id_ptr || *proxy_id_ptr != proxy_id)
+ // Bogus - we will overwrite.
+ proxy_id = 0;
+ }
+ if (proxy_id_ptr)
+ XFree(proxy_id_ptr);
+ return proxy_id;
+}
+
+static bool xdndEnable(QWidget* w, bool on)
+{
+ DNDDEBUG << "xdndEnable" << w << on;
+ if (on) {
+ QWidget * xdnd_widget = 0;
+ if ((w->windowType() == Qt::Desktop)) {
+ if (xdnd_data.desktop_proxy) // *WE* already have one.
+ return false;
+
+ // As per Xdnd4, use XdndProxy
+ XGrabServer(X11->display);
+ Q_ASSERT(w->testAttribute(Qt::WA_WState_Created));
+ WId proxy_id = xdndProxy(w->effectiveWinId());
+
+ if (!proxy_id) {
+ xdnd_widget = xdnd_data.desktop_proxy = new QWidget;
+ proxy_id = xdnd_data.desktop_proxy->effectiveWinId();
+ XChangeProperty (X11->display, w->effectiveWinId(), ATOM(XdndProxy),
+ XA_WINDOW, 32, PropModeReplace, (unsigned char *)&proxy_id, 1);
+ XChangeProperty (X11->display, proxy_id, ATOM(XdndProxy),
+ XA_WINDOW, 32, PropModeReplace, (unsigned char *)&proxy_id, 1);
+ }
+
+ XUngrabServer(X11->display);
+ } else {
+ xdnd_widget = w->window();
+ }
+ if (xdnd_widget) {
+ DNDDEBUG << "setting XdndAware for" << xdnd_widget << xdnd_widget->effectiveWinId();
+ Atom atm = (Atom)xdnd_version;
+ Q_ASSERT(xdnd_widget->testAttribute(Qt::WA_WState_Created));
+ XChangeProperty(X11->display, xdnd_widget->effectiveWinId(), ATOM(XdndAware),
+ XA_ATOM, 32, PropModeReplace, (unsigned char *)&atm, 1);
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ if ((w->windowType() == Qt::Desktop)) {
+ XDeleteProperty(X11->display, w->internalWinId(), ATOM(XdndProxy));
+ delete xdnd_data.desktop_proxy;
+ xdnd_data.desktop_proxy = 0;
+ } else {
+ DNDDEBUG << "not deleting XDndAware";
+ }
+ return true;
+ }
+}
+
+QByteArray QX11Data::xdndAtomToString(Atom a)
+{
+ if (!a) return 0;
+
+ if (a == XA_STRING || a == ATOM(UTF8_STRING)) {
+ return "text/plain"; // some Xdnd clients are dumb
+ }
+ char *atom = XGetAtomName(display, a);
+ QByteArray result = atom;
+ XFree(atom);
+ return result;
+}
+
+Atom QX11Data::xdndStringToAtom(const char *mimeType)
+{
+ if (!mimeType || !*mimeType)
+ return 0;
+ return XInternAtom(display, mimeType, False);
+}
+
+//$$$
+QString QX11Data::xdndMimeAtomToString(Atom a)
+{
+ QString atomName;
+ if (a) {
+ char *atom = XGetAtomName(display, a);
+ atomName = QString::fromLatin1(atom);
+ XFree(atom);
+ }
+ return atomName;
+}
+
+//$$$
+Atom QX11Data::xdndMimeStringToAtom(const QString &mimeType)
+{
+ if (mimeType.isEmpty())
+ return 0;
+ return XInternAtom(display, mimeType.toLatin1().constData(), False);
+}
+
+//$$$ replace ccxdndAtomToString()
+QStringList QX11Data::xdndMimeFormatsForAtom(Atom a)
+{
+ QStringList formats;
+ if (a) {
+ QString atomName = xdndMimeAtomToString(a);
+ formats.append(atomName);
+
+ // special cases for string type
+ if (a == ATOM(UTF8_STRING) || a == XA_STRING
+ || a == ATOM(TEXT) || a == ATOM(COMPOUND_TEXT))
+ formats.append(QLatin1String("text/plain"));
+
+ // special cases for uris
+ if (atomName == QLatin1String("text/x-moz-url"))
+ formats.append(QLatin1String("text/uri-list"));
+
+ // special case for images
+ if (a == XA_PIXMAP)
+ formats.append(QLatin1String("image/ppm"));
+ }
+ return formats;
+}
+
+//$$$
+bool QX11Data::xdndMimeDataForAtom(Atom a, QMimeData *mimeData, QByteArray *data, Atom *atomFormat, int *dataFormat)
+{
+ bool ret = false;
+ *atomFormat = a;
+ *dataFormat = 8;
+ QString atomName = xdndMimeAtomToString(a);
+ if (QInternalMimeData::hasFormatHelper(atomName, mimeData)) {
+ *data = QInternalMimeData::renderDataHelper(atomName, mimeData);
+ if (atomName == QLatin1String("application/x-color"))
+ *dataFormat = 16;
+ ret = true;
+ } else {
+ if ((a == ATOM(UTF8_STRING) || a == XA_STRING
+ || a == ATOM(TEXT) || a == ATOM(COMPOUND_TEXT))
+ && QInternalMimeData::hasFormatHelper(QLatin1String("text/plain"), mimeData)) {
+ if (a == ATOM(UTF8_STRING)){
+ *data = QInternalMimeData::renderDataHelper(QLatin1String("text/plain"), mimeData);
+ ret = true;
+ } else if (a == XA_STRING) {
+ *data = QString::fromUtf8(QInternalMimeData::renderDataHelper(
+ QLatin1String("text/plain"), mimeData)).toLocal8Bit();
+ ret = true;
+ } else if (a == ATOM(TEXT) || a == ATOM(COMPOUND_TEXT)) {
+ // the ICCCM states that TEXT and COMPOUND_TEXT are in the
+ // encoding of choice, so we choose the encoding of the locale
+ QByteArray strData = QString::fromUtf8(QInternalMimeData::renderDataHelper(
+ QLatin1String("text/plain"), mimeData)).toLocal8Bit();
+ char *list[] = { strData.data(), NULL };
+
+ XICCEncodingStyle style = (a == ATOM(COMPOUND_TEXT))
+ ? XCompoundTextStyle : XStdICCTextStyle;
+ XTextProperty textprop;
+ if (list[0] != NULL
+ && XmbTextListToTextProperty(X11->display, list, 1, style,
+ &textprop) == Success) {
+ *atomFormat = textprop.encoding;
+ *dataFormat = textprop.format;
+ *data = QByteArray((const char *) textprop.value, textprop.nitems * textprop.format / 8);
+ ret = true;
+
+ DEBUG(" textprop type %lx\n"
+ " textprop name '%s'\n"
+ " format %d\n"
+ " %ld items\n"
+ " %d bytes\n",
+ textprop.encoding,
+ X11->xdndMimeAtomToString(textprop.encoding).toLatin1().data(),
+ textprop.format, textprop.nitems, data->size());
+
+ XFree(textprop.value);
+ }
+ }
+ } else if (atomName == QLatin1String("text/x-moz-url") &&
+ QInternalMimeData::hasFormatHelper(QLatin1String("text/uri-list"), mimeData)) {
+ QByteArray uri = QInternalMimeData::renderDataHelper(
+ QLatin1String("text/uri-list"), mimeData).split('\n').first();
+ QString mozUri = QString::fromLatin1(uri, uri.size());
+ mozUri += QLatin1Char('\n');
+ *data = QByteArray(reinterpret_cast<const char *>(mozUri.utf16()), mozUri.length() * 2);
+ ret = true;
+ } else if ((a == XA_PIXMAP || a == XA_BITMAP) && mimeData->hasImage()) {
+ QPixmap pm = qvariant_cast<QPixmap>(mimeData->imageData());
+ if (a == XA_BITMAP && pm.depth() != 1) {
+ QImage img = pm.toImage();
+ img = img.convertToFormat(QImage::Format_MonoLSB);
+ pm = QPixmap::fromImage(img);
+ }
+ QDragManager *dm = QDragManager::self();
+ if (dm) {
+ Pixmap handle = pm.handle();
+ *data = QByteArray((const char *) &handle, sizeof(Pixmap));
+ dm->xdndMimeTransferedPixmap[dm->xdndMimeTransferedPixmapIndex] = pm;
+ dm->xdndMimeTransferedPixmapIndex =
+ (dm->xdndMimeTransferedPixmapIndex + 1) % 2;
+ ret = true;
+ }
+ } else {
+ DEBUG("QClipboard: xdndMimeDataForAtom(): converting to type '%s' is not supported", qPrintable(atomName));
+ }
+ }
+ return ret && data != 0;
+}
+
+//$$$
+QList<Atom> QX11Data::xdndMimeAtomsForFormat(const QString &format)
+{
+ QList<Atom> atoms;
+ atoms.append(xdndMimeStringToAtom(format));
+
+ // special cases for strings
+ if (format == QLatin1String("text/plain")) {
+ atoms.append(ATOM(UTF8_STRING));
+ atoms.append(XA_STRING);
+ atoms.append(ATOM(TEXT));
+ atoms.append(ATOM(COMPOUND_TEXT));
+ }
+
+ // special cases for uris
+ if (format == QLatin1String("text/uri-list")) {
+ atoms.append(xdndMimeStringToAtom(QLatin1String("text/x-moz-url")));
+ }
+
+ //special cases for images
+ if (format == QLatin1String("image/ppm"))
+ atoms.append(XA_PIXMAP);
+ if (format == QLatin1String("image/pbm"))
+ atoms.append(XA_BITMAP);
+
+ return atoms;
+}
+
+//$$$
+QVariant QX11Data::xdndMimeConvertToFormat(Atom a, const QByteArray &data, const QString &format, QVariant::Type requestedType, const QByteArray &encoding)
+{
+ QString atomName = xdndMimeAtomToString(a);
+ if (atomName == format)
+ return data;
+
+ if (!encoding.isEmpty()
+ && atomName == format + QLatin1String(";charset=") + QString::fromLatin1(encoding)) {
+
+ if (requestedType == QVariant::String) {
+ QTextCodec *codec = QTextCodec::codecForName(encoding);
+ if (codec)
+ return codec->toUnicode(data);
+ }
+
+ return data;
+ }
+
+ // special cases for string types
+ if (format == QLatin1String("text/plain")) {
+ if (a == ATOM(UTF8_STRING))
+ return QString::fromUtf8(data);
+ if (a == XA_STRING)
+ return QString::fromLatin1(data);
+ if (a == ATOM(TEXT) || a == ATOM(COMPOUND_TEXT))
+ // #### might be wrong for COMPUND_TEXT
+ return QString::fromLocal8Bit(data, data.size());
+ }
+
+ // special case for uri types
+ if (format == QLatin1String("text/uri-list")) {
+ if (atomName == QLatin1String("text/x-moz-url")) {
+ // we expect this as utf16 <url><space><title>
+ // the first part is a url that should only contain ascci char
+ // so it should be safe to check that the second char is 0
+ // to verify that it is utf16
+ if (data.size() > 1 && data.at(1) == 0)
+ return QString::fromRawData((const QChar *)data.constData(),
+ data.size() / 2).split(QLatin1Char('\n')).first().toLatin1();
+ }
+ }
+
+ // special cas for images
+ if (format == QLatin1String("image/ppm")) {
+ if (a == XA_PIXMAP && data.size() == sizeof(Pixmap)) {
+ Pixmap xpm = *((Pixmap*)data.data());
+ if (!xpm)
+ return QByteArray();
+ QPixmap qpm = QPixmap::fromX11Pixmap(xpm);
+ QImageWriter imageWriter;
+ imageWriter.setFormat("PPMRAW");
+ QImage imageToWrite = qpm.toImage();
+ QBuffer buf;
+ buf.open(QIODevice::WriteOnly);
+ imageWriter.setDevice(&buf);
+ imageWriter.write(imageToWrite);
+ return buf.buffer();
+ }
+ }
+ return QVariant();
+}
+
+//$$$ middle of xdndObtainData
+Atom QX11Data::xdndMimeAtomForFormat(const QString &format, QVariant::Type requestedType, const QList<Atom> &atoms, QByteArray *encoding)
+{
+ encoding->clear();
+
+ // find matches for string types
+ if (format == QLatin1String("text/plain")) {
+ if (atoms.contains(ATOM(UTF8_STRING)))
+ return ATOM(UTF8_STRING);
+ if (atoms.contains(ATOM(COMPOUND_TEXT)))
+ return ATOM(COMPOUND_TEXT);
+ if (atoms.contains(ATOM(TEXT)))
+ return ATOM(TEXT);
+ if (atoms.contains(XA_STRING))
+ return XA_STRING;
+ }
+
+ // find matches for uri types
+ if (format == QLatin1String("text/uri-list")) {
+ Atom a = xdndMimeStringToAtom(format);
+ if (a && atoms.contains(a))
+ return a;
+ a = xdndMimeStringToAtom(QLatin1String("text/x-moz-url"));
+ if (a && atoms.contains(a))
+ return a;
+ }
+
+ // find match for image
+ if (format == QLatin1String("image/ppm")) {
+ if (atoms.contains(XA_PIXMAP))
+ return XA_PIXMAP;
+ }
+
+ // for string/text requests try to use a format with a well-defined charset
+ // first to avoid encoding problems
+ if (requestedType == QVariant::String
+ && format.startsWith(QLatin1String("text/"))
+ && !format.contains(QLatin1String("charset="))) {
+
+ QString formatWithCharset = format;
+ formatWithCharset.append(QLatin1String(";charset=utf-8"));
+
+ Atom a = xdndMimeStringToAtom(formatWithCharset);
+ if (a && atoms.contains(a)) {
+ *encoding = "utf-8";
+ return a;
+ }
+ }
+
+ Atom a = xdndMimeStringToAtom(format);
+ if (a && atoms.contains(a))
+ return a;
+
+ return 0;
+}
+
+void QX11Data::xdndSetup() {
+ QCursorData::initialize();
+ qAddPostRoutine(qt_xdnd_cleanup);
+}
+
+
+void qt_xdnd_cleanup()
+{
+ delete noDropCursor;
+ noDropCursor = 0;
+ delete copyCursor;
+ copyCursor = 0;
+ delete moveCursor;
+ moveCursor = 0;
+ delete linkCursor;
+ linkCursor = 0;
+ delete defaultPm;
+ defaultPm = 0;
+ delete xdnd_data.desktop_proxy;
+ xdnd_data.desktop_proxy = 0;
+ delete xdnd_data.deco;
+ xdnd_data.deco = 0;
+}
+
+
+static QWidget *find_child(QWidget *tlw, QPoint & p)
+{
+ QWidget *widget = tlw;
+
+ p = widget->mapFromGlobal(p);
+ bool done = false;
+ while (!done) {
+ done = true;
+ if (((QExtraWidget*)widget)->extraData() &&
+ ((QExtraWidget*)widget)->extraData()->xDndProxy != 0)
+ break; // stop searching for widgets under the mouse cursor if found widget is a proxy.
+ QObjectList children = widget->children();
+ if (!children.isEmpty()) {
+ for(int i = children.size(); i > 0;) {
+ --i;
+ QWidget *w = qobject_cast<QWidget *>(children.at(i));
+ if (!w)
+ continue;
+ if (w->testAttribute(Qt::WA_TransparentForMouseEvents))
+ continue;
+ if (w->isVisible() &&
+ w->geometry().contains(p) &&
+ !w->isWindow()) {
+ widget = w;
+ done = false;
+ p = widget->mapFromParent(p);
+ break;
+ }
+ }
+ }
+ }
+ return widget;
+}
+
+
+static bool checkEmbedded(QWidget* w, const XEvent* xe)
+{
+ if (!w)
+ return false;
+
+ if (current_embedding_widget != 0 && current_embedding_widget != w) {
+ qt_xdnd_current_target = ((QExtraWidget*)current_embedding_widget)->extraData()->xDndProxy;
+ qt_xdnd_current_proxy_target = qt_xdnd_current_target;
+ qt_xdnd_send_leave();
+ qt_xdnd_current_target = 0;
+ qt_xdnd_current_proxy_target = 0;
+ current_embedding_widget = 0;
+ }
+
+ QWExtra* extra = ((QExtraWidget*)w)->extraData();
+ if (extra && extra->xDndProxy != 0) {
+
+ if (current_embedding_widget != w) {
+
+ last_enter_event.xany.window = extra->xDndProxy;
+ XSendEvent(X11->display, extra->xDndProxy, False, NoEventMask, &last_enter_event);
+ current_embedding_widget = w;
+ }
+
+ ((XEvent*)xe)->xany.window = extra->xDndProxy;
+ XSendEvent(X11->display, extra->xDndProxy, False, NoEventMask, (XEvent*)xe);
+ if (qt_xdnd_current_widget != w) {
+ qt_xdnd_current_widget = w;
+ }
+ return true;
+ }
+ current_embedding_widget = 0;
+ return false;
+}
+
+void QX11Data::xdndHandleEnter(QWidget *, const XEvent * xe, bool /*passive*/)
+{
+ motifdnd_active = false;
+
+ last_enter_event.xclient = xe->xclient;
+
+ const long *l = xe->xclient.data.l;
+ int version = (int)(((unsigned long)(l[1])) >> 24);
+
+ if (version > xdnd_version)
+ return;
+
+ qt_xdnd_dragsource_xid = l[0];
+
+ int j = 0;
+ if (l[1] & 1) {
+ // get the types from XdndTypeList
+ Atom type = XNone;
+ int f;
+ unsigned long n, a;
+ unsigned char *retval = 0;
+ XGetWindowProperty(X11->display, qt_xdnd_dragsource_xid, ATOM(XdndTypelist), 0,
+ qt_xdnd_max_type, False, XA_ATOM, &type, &f,&n,&a,&retval);
+ if (retval) {
+ Atom *data = (Atom *)retval;
+ for (; j<qt_xdnd_max_type && j < (int)n; j++) {
+ qt_xdnd_types[j] = data[j];
+ }
+ XFree((uchar*)data);
+ }
+ } else {
+ // get the types from the message
+ int i;
+ for(i=2; i < 5; i++) {
+ qt_xdnd_types[j++] = l[i];
+ }
+ }
+ qt_xdnd_types[j] = 0;
+}
+
+static void handle_xdnd_position(QWidget *w, const XEvent * xe, bool passive)
+{
+ const unsigned long *l = (const unsigned long *)xe->xclient.data.l;
+
+ QPoint p((l[2] & 0xffff0000) >> 16, l[2] & 0x0000ffff);
+ QWidget * c = find_child(w, p); // changes p to to c-local coordinates
+
+ if (!passive && checkEmbedded(c, xe))
+ return;
+
+ if (!c || (!c->acceptDrops() && (c->windowType() == Qt::Desktop)))
+ return;
+
+ if (l[0] != qt_xdnd_dragsource_xid) {
+ DEBUG("xdnd drag position from unexpected source (%08lx not %08lx)", l[0], qt_xdnd_dragsource_xid);
+ return;
+ }
+
+ // timestamp from the source
+ if (l[3] != 0) {
+ // Some X server/client combination swallow the first 32 bit and
+ // interpret a set bit 31 as negative sign.
+ qt_xdnd_target_current_time = X11->userTime =
+ ((sizeof(Time) == 8 && xe->xclient.data.l[3] < 0)
+ ? uint(l[3])
+ : l[3]);
+ }
+
+ QDragManager *manager = QDragManager::self();
+ QMimeData *dropData = manager->object ? manager->dragPrivate()->data : manager->dropData;
+
+ XClientMessageEvent response;
+ response.type = ClientMessage;
+ response.window = qt_xdnd_dragsource_xid;
+ response.format = 32;
+ response.message_type = ATOM(XdndStatus);
+ response.data.l[0] = w->effectiveWinId();
+ response.data.l[1] = 0; // flags
+ response.data.l[2] = 0; // x, y
+ response.data.l[3] = 0; // w, h
+ response.data.l[4] = 0; // action
+
+ if (!passive) { // otherwise just reject
+ while (c && !c->acceptDrops() && !c->isWindow()) {
+ p = c->mapToParent(p);
+ c = c->parentWidget();
+ }
+ QWidget *target_widget = c && c->acceptDrops() ? c : 0;
+
+ QRect answerRect(c->mapToGlobal(p), QSize(1,1));
+
+ if (manager->object) {
+ possible_actions = manager->dragPrivate()->possible_actions;
+ } else {
+ possible_actions = Qt::DropActions(xdndaction_to_qtaction(l[4]));
+// possible_actions |= Qt::CopyAction;
+ }
+ QDragMoveEvent me(p, possible_actions, dropData, QApplication::mouseButtons(), QApplication::keyboardModifiers());
+
+ Qt::DropAction accepted_action = Qt::IgnoreAction;
+
+
+ if (target_widget != qt_xdnd_current_widget) {
+ if (qt_xdnd_current_widget) {
+ QDragLeaveEvent e;
+ QApplication::sendEvent(qt_xdnd_current_widget, &e);
+ }
+ if (qt_xdnd_current_widget != target_widget) {
+ qt_xdnd_current_widget = target_widget;
+ }
+ if (target_widget) {
+ qt_xdnd_current_position = p;
+
+ last_target_accepted_action = Qt::IgnoreAction;
+ QDragEnterEvent de(p, possible_actions, dropData, QApplication::mouseButtons(), QApplication::keyboardModifiers());
+ QApplication::sendEvent(target_widget, &de);
+ if (de.isAccepted() && de.dropAction() != Qt::IgnoreAction)
+ last_target_accepted_action = de.dropAction();
+ }
+ }
+
+ DEBUG() << "qt_handle_xdnd_position action=" << X11->xdndAtomToString(l[4]);
+ if (!target_widget) {
+ answerRect = QRect(p, QSize(1, 1));
+ } else {
+ qt_xdnd_current_widget = c;
+ qt_xdnd_current_position = p;
+
+ if (last_target_accepted_action != Qt::IgnoreAction) {
+ me.setDropAction(last_target_accepted_action);
+ me.accept();
+ }
+ QApplication::sendEvent(c, &me);
+ if (me.isAccepted()) {
+ response.data.l[1] = 1; // yes
+ accepted_action = me.dropAction();
+ last_target_accepted_action = accepted_action;
+ } else {
+ response.data.l[0] = 0;
+ last_target_accepted_action = Qt::IgnoreAction;
+ }
+ answerRect = me.answerRect().intersected(c->rect());
+ }
+ answerRect = QRect(c->mapToGlobal(answerRect.topLeft()), answerRect.size());
+
+ if (answerRect.left() < 0)
+ answerRect.setLeft(0);
+ if (answerRect.right() > 4096)
+ answerRect.setRight(4096);
+ if (answerRect.top() < 0)
+ answerRect.setTop(0);
+ if (answerRect.bottom() > 4096)
+ answerRect.setBottom(4096);
+ if (answerRect.width() < 0)
+ answerRect.setWidth(0);
+ if (answerRect.height() < 0)
+ answerRect.setHeight(0);
+
+ response.data.l[2] = (answerRect.x() << 16) + answerRect.y();
+ response.data.l[3] = (answerRect.width() << 16) + answerRect.height();
+ response.data.l[4] = qtaction_to_xdndaction(accepted_action);
+ }
+
+ // reset
+ qt_xdnd_target_current_time = CurrentTime;
+
+ QWidget * source = QWidget::find(qt_xdnd_dragsource_xid);
+ if (source && (source->windowType() == Qt::Desktop) && !source->acceptDrops())
+ source = 0;
+
+ DEBUG() << "sending XdndStatus";
+ if (source)
+ handle_xdnd_status(source, (const XEvent *)&response, passive);
+ else
+ XSendEvent(X11->display, qt_xdnd_dragsource_xid, False, NoEventMask, (XEvent*)&response);
+}
+
+static Bool xdnd_position_scanner(Display *, XEvent *event, XPointer)
+{
+ if (event->type != ClientMessage)
+ return false;
+ XClientMessageEvent *ev = &event->xclient;
+
+ if (ev->message_type == ATOM(XdndPosition))
+ return true;
+
+ return false;
+}
+
+void QX11Data::xdndHandlePosition(QWidget * w, const XEvent * xe, bool passive)
+{
+ DEBUG("xdndHandlePosition");
+ while (XCheckIfEvent(X11->display, (XEvent *)xe, xdnd_position_scanner, 0))
+ ;
+
+ handle_xdnd_position(w, xe, passive);
+}
+
+
+static void handle_xdnd_status(QWidget *, const XEvent * xe, bool)
+{
+ const unsigned long *l = (const unsigned long *)xe->xclient.data.l;
+ // ignore late status messages
+ if (l[0] && l[0] != qt_xdnd_current_proxy_target)
+ return;
+ Qt::DropAction newAction = (l[1] & 0x1) ? xdndaction_to_qtaction(l[4]) : Qt::IgnoreAction;
+
+ if ((int)(l[1] & 2) == 0) {
+ QPoint p((l[2] & 0xffff0000) >> 16, l[2] & 0x0000ffff);
+ QSize s((l[3] & 0xffff0000) >> 16, l[3] & 0x0000ffff);
+ qt_xdnd_source_sameanswer = QRect(p, s);
+ } else {
+ qt_xdnd_source_sameanswer = QRect();
+ }
+ QDragManager *manager = QDragManager::self();
+ manager->willDrop = (l[1] & 0x1);
+ if (global_accepted_action != newAction)
+ manager->emitActionChanged(newAction);
+ global_accepted_action = newAction;
+ manager->updateCursor();
+ waiting_for_status = false;
+}
+
+static Bool xdnd_status_scanner(Display *, XEvent *event, XPointer)
+{
+ if (event->type != ClientMessage)
+ return false;
+ XClientMessageEvent *ev = &event->xclient;
+
+ if (ev->message_type == ATOM(XdndStatus))
+ return true;
+
+ return false;
+}
+
+void QX11Data::xdndHandleStatus(QWidget * w, const XEvent * xe, bool passive)
+{
+ DEBUG("xdndHandleStatus");
+ while (XCheckIfEvent(X11->display, (XEvent *)xe, xdnd_status_scanner, 0))
+ ;
+
+ handle_xdnd_status(w, xe, passive);
+ DEBUG("xdndHandleStatus end");
+}
+
+void QX11Data::xdndHandleLeave(QWidget *w, const XEvent * xe, bool /*passive*/)
+{
+ DEBUG("xdnd leave");
+ if (!qt_xdnd_current_widget ||
+ w->window() != qt_xdnd_current_widget->window()) {
+ return; // sanity
+ }
+
+ if (checkEmbedded(current_embedding_widget, xe)) {
+ current_embedding_widget = 0;
+ qt_xdnd_current_widget = 0;
+ return;
+ }
+
+ const unsigned long *l = (const unsigned long *)xe->xclient.data.l;
+
+ QDragLeaveEvent e;
+ QApplication::sendEvent(qt_xdnd_current_widget, &e);
+
+ if (l[0] != qt_xdnd_dragsource_xid) {
+ // This often happens - leave other-process window quickly
+ DEBUG("xdnd drag leave from unexpected source (%08lx not %08lx", l[0], qt_xdnd_dragsource_xid);
+ qt_xdnd_current_widget = 0;
+ return;
+ }
+
+ qt_xdnd_dragsource_xid = 0;
+ qt_xdnd_types[0] = 0;
+ qt_xdnd_current_widget = 0;
+}
+
+
+void qt_xdnd_send_leave()
+{
+ if (!qt_xdnd_current_target)
+ return;
+
+ QDragManager *manager = QDragManager::self();
+
+ XClientMessageEvent leave;
+ leave.type = ClientMessage;
+ leave.window = qt_xdnd_current_target;
+ leave.format = 32;
+ leave.message_type = ATOM(XdndLeave);
+ leave.data.l[0] = manager->dragPrivate()->source->effectiveWinId();
+ leave.data.l[1] = 0; // flags
+ leave.data.l[2] = 0; // x, y
+ leave.data.l[3] = 0; // w, h
+ leave.data.l[4] = 0; // just null
+
+ QWidget * w = QWidget::find(qt_xdnd_current_proxy_target);
+
+ if (w && (w->windowType() == Qt::Desktop) && !w->acceptDrops())
+ w = 0;
+
+ if (w)
+ X11->xdndHandleLeave(w, (const XEvent *)&leave, false);
+ else
+ XSendEvent(X11->display, qt_xdnd_current_proxy_target, False,
+ NoEventMask, (XEvent*)&leave);
+
+ // reset the drag manager state
+ manager->willDrop = false;
+ if (global_accepted_action != Qt::IgnoreAction)
+ manager->emitActionChanged(Qt::IgnoreAction);
+ global_accepted_action = Qt::IgnoreAction;
+ manager->updateCursor();
+ qt_xdnd_current_target = 0;
+ qt_xdnd_current_proxy_target = 0;
+ qt_xdnd_source_current_time = 0;
+ waiting_for_status = false;
+}
+
+// TODO: remove and use QApplication::currentKeyboardModifiers() in Qt 4.8.
+static Qt::KeyboardModifiers currentKeyboardModifiers()
+{
+ Window root;
+ Window child;
+ int root_x, root_y, win_x, win_y;
+ uint keybstate;
+ for (int i = 0; i < ScreenCount(X11->display); ++i) {
+ if (XQueryPointer(X11->display, QX11Info::appRootWindow(i), &root, &child,
+ &root_x, &root_y, &win_x, &win_y, &keybstate))
+ return X11->translateModifiers(keybstate & 0x00ff);
+ }
+ return 0;
+}
+
+void QX11Data::xdndHandleDrop(QWidget *, const XEvent * xe, bool passive)
+{
+ DEBUG("xdndHandleDrop");
+ if (!qt_xdnd_current_widget) {
+ qt_xdnd_dragsource_xid = 0;
+ return; // sanity
+ }
+
+ if (!passive && checkEmbedded(qt_xdnd_current_widget, xe)){
+ current_embedding_widget = 0;
+ qt_xdnd_dragsource_xid = 0;
+ qt_xdnd_current_widget = 0;
+ return;
+ }
+ const unsigned long *l = (const unsigned long *)xe->xclient.data.l;
+
+ QDragManager *manager = QDragManager::self();
+ DEBUG("xdnd drop");
+
+ if (l[0] != qt_xdnd_dragsource_xid) {
+ DEBUG("xdnd drop from unexpected source (%08lx not %08lx", l[0], qt_xdnd_dragsource_xid);
+ return;
+ }
+
+ // update the "user time" from the timestamp in the event.
+ if (l[2] != 0) {
+ // Some X server/client combination swallow the first 32 bit and
+ // interpret a set bit 31 as negative sign.
+ qt_xdnd_target_current_time = X11->userTime =
+ ((sizeof(Time) == 8 && xe->xclient.data.l[2] < 0)
+ ? uint(l[2])
+ : l[2]);
+ }
+
+ if (!passive) {
+ // this could be a same-application drop, just proxied due to
+ // some XEMBEDding, so try to find the real QMimeData used
+ // based on the timestamp for this drop.
+ QMimeData *dropData = 0;
+ int at = findXdndDropTransactionByTime(qt_xdnd_target_current_time);
+ if (at != -1)
+ dropData = QDragManager::dragPrivate(X11->dndDropTransactions.at(at).object)->data;
+ // if we can't find it, then use the data in the drag manager
+ if (!dropData)
+ dropData = (manager->object) ? manager->dragPrivate()->data : manager->dropData;
+
+ // Drop coming from another app? Update keyboard modifiers.
+ if (!qt_xdnd_dragging) {
+ QApplicationPrivate::modifier_buttons = currentKeyboardModifiers();
+ }
+
+ QDropEvent de(qt_xdnd_current_position, possible_actions, dropData,
+ QApplication::mouseButtons(), QApplication::keyboardModifiers());
+ QApplication::sendEvent(qt_xdnd_current_widget, &de);
+ if (!de.isAccepted()) {
+ // Ignore a failed drag
+ global_accepted_action = Qt::IgnoreAction;
+ } else {
+ global_accepted_action = de.dropAction();
+ }
+ XClientMessageEvent finished;
+ finished.type = ClientMessage;
+ finished.window = qt_xdnd_dragsource_xid;
+ finished.format = 32;
+ finished.message_type = ATOM(XdndFinished);
+ DNDDEBUG << "xdndHandleDrop"
+ << "qt_xdnd_current_widget" << qt_xdnd_current_widget
+ << (qt_xdnd_current_widget ? qt_xdnd_current_widget->effectiveWinId() : 0)
+ << "t_xdnd_current_widget->window()"
+ << (qt_xdnd_current_widget ? qt_xdnd_current_widget->window() : 0)
+ << (qt_xdnd_current_widget ? qt_xdnd_current_widget->window()->internalWinId() : 0);
+ finished.data.l[0] = qt_xdnd_current_widget?qt_xdnd_current_widget->window()->internalWinId():0;
+ finished.data.l[1] = de.isAccepted() ? 1 : 0; // flags
+ finished.data.l[2] = qtaction_to_xdndaction(global_accepted_action);
+ XSendEvent(X11->display, qt_xdnd_dragsource_xid, False,
+ NoEventMask, (XEvent*)&finished);
+ } else {
+ QDragLeaveEvent e;
+ QApplication::sendEvent(qt_xdnd_current_widget, &e);
+ }
+ qt_xdnd_dragsource_xid = 0;
+ qt_xdnd_current_widget = 0;
+ waiting_for_status = false;
+
+ // reset
+ qt_xdnd_target_current_time = CurrentTime;
+}
+
+
+void QX11Data::xdndHandleFinished(QWidget *, const XEvent * xe, bool passive)
+{
+ DEBUG("xdndHandleFinished");
+ const unsigned long *l = (const unsigned long *)xe->xclient.data.l;
+
+ DNDDEBUG << "xdndHandleFinished, l[0]" << l[0]
+ << "qt_xdnd_current_target" << qt_xdnd_current_target
+ << "qt_xdnd_current_proxy_targe" << qt_xdnd_current_proxy_target;
+
+ if (l[0]) {
+ int at = findXdndDropTransactionByWindow(l[0]);
+ if (at != -1) {
+ restartXdndDropExpiryTimer();
+
+ QXdndDropTransaction t = X11->dndDropTransactions.takeAt(at);
+ QDragManager *manager = QDragManager::self();
+
+ Window target = qt_xdnd_current_target;
+ Window proxy_target = qt_xdnd_current_proxy_target;
+ QWidget *embedding_widget = current_embedding_widget;
+ QDrag *currentObject = manager->object;
+
+ qt_xdnd_current_target = t.target;
+ qt_xdnd_current_proxy_target = t.proxy_target;
+ current_embedding_widget = t.embedding_widget;
+ manager->object = t.object;
+
+ if (!passive)
+ (void) checkEmbedded(qt_xdnd_current_widget, xe);
+
+ current_embedding_widget = 0;
+ qt_xdnd_current_target = 0;
+ qt_xdnd_current_proxy_target = 0;
+
+ if (t.object)
+ t.object->deleteLater();
+
+ qt_xdnd_current_target = target;
+ qt_xdnd_current_proxy_target = proxy_target;
+ current_embedding_widget = embedding_widget;
+ manager->object = currentObject;
+ }
+ }
+ waiting_for_status = false;
+}
+
+
+void QDragManager::timerEvent(QTimerEvent* e)
+{
+ if (e->timerId() == heartbeat && qt_xdnd_source_sameanswer.isNull()) {
+ move(QCursor::pos());
+ } else if (e->timerId() == transaction_expiry_timer) {
+ for (int i = 0; i < X11->dndDropTransactions.count(); ++i) {
+ const QXdndDropTransaction &t = X11->dndDropTransactions.at(i);
+ if (t.targetWidget) {
+ // dnd within the same process, don't delete these
+ continue;
+ }
+ t.object->deleteLater();
+ X11->dndDropTransactions.removeAt(i--);
+ }
+
+ killTimer(transaction_expiry_timer);
+ transaction_expiry_timer = -1;
+ }
+}
+
+bool QDragManager::eventFilter(QObject * o, QEvent * e)
+{
+ if (beingCancelled) {
+ if (e->type() == QEvent::KeyRelease && ((QKeyEvent*)e)->key() == Qt::Key_Escape) {
+ qApp->removeEventFilter(this);
+ Q_ASSERT(object == 0);
+ beingCancelled = false;
+ eventLoop->exit();
+ return true; // block the key release
+ }
+ return false;
+ }
+
+ Q_ASSERT(object != 0);
+
+ if (!o->isWidgetType())
+ return false;
+
+ if (e->type() == QEvent::MouseMove) {
+ QMouseEvent* me = (QMouseEvent *)e;
+ move(me->globalPos());
+ return true;
+ } else if (e->type() == QEvent::MouseButtonRelease) {
+ DEBUG("pre drop");
+ qApp->removeEventFilter(this);
+ if (willDrop)
+ drop();
+ else
+ cancel();
+ DEBUG("drop, resetting object");
+ beingCancelled = false;
+ eventLoop->exit();
+ return true;
+ }
+
+ if (e->type() == QEvent::ShortcutOverride) {
+ // prevent accelerators from firing while dragging
+ e->accept();
+ return true;
+ }
+
+ if (e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease) {
+ QKeyEvent *ke = ((QKeyEvent*)e);
+ if (ke->key() == Qt::Key_Escape && e->type() == QEvent::KeyPress) {
+ cancel();
+ qApp->removeEventFilter(this);
+ beingCancelled = false;
+ eventLoop->exit();
+ } else {
+ qt_xdnd_source_sameanswer = QRect(); // force move
+ move(QCursor::pos());
+ }
+ return true; // Eat all key events
+ }
+
+ // ### We bind modality to widgets, so we have to do this
+ // ### "manually".
+ // DnD is modal - eat all other interactive events
+ switch (e->type()) {
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseButtonDblClick:
+ case QEvent::MouseMove:
+ case QEvent::KeyPress:
+ case QEvent::KeyRelease:
+ case QEvent::Wheel:
+ case QEvent::ShortcutOverride:
+ return true;
+ default:
+ return false;
+ }
+}
+
+void QDragManager::updateCursor()
+{
+ if (!noDropCursor) {
+#ifndef QT_NO_CURSOR
+ noDropCursor = new QCursor(Qt::ForbiddenCursor);
+ moveCursor = new QCursor(Qt::DragMoveCursor);
+ copyCursor = new QCursor(Qt::DragCopyCursor);
+ linkCursor = new QCursor(Qt::DragLinkCursor);
+#endif
+ }
+
+ QCursor *c;
+ if (willDrop) {
+ if (global_accepted_action == Qt::CopyAction) {
+ c = copyCursor;
+ } else if (global_accepted_action == Qt::LinkAction) {
+ c = linkCursor;
+ } else {
+ c = moveCursor;
+ }
+ if (xdnd_data.deco) {
+ xdnd_data.deco->show();
+ xdnd_data.deco->raise();
+ }
+ } else {
+ c = noDropCursor;
+ //if (qt_xdnd_deco)
+ // qt_xdnd_deco->hide();
+ }
+#ifndef QT_NO_CURSOR
+ if (c)
+ qApp->changeOverrideCursor(*c);
+#endif
+}
+
+
+void QDragManager::cancel(bool deleteSource)
+{
+ DEBUG("QDragManager::cancel");
+ Q_ASSERT(heartbeat != -1);
+ killTimer(heartbeat);
+ heartbeat = -1;
+ beingCancelled = true;
+ qt_xdnd_dragging = false;
+
+ if (qt_xdnd_current_target)
+ qt_xdnd_send_leave();
+
+#ifndef QT_NO_CURSOR
+ if (restoreCursor) {
+ QApplication::restoreOverrideCursor();
+ restoreCursor = false;
+ }
+#endif
+
+ if (deleteSource && object)
+ object->deleteLater();
+ object = 0;
+ qDeleteInEventHandler(xdnd_data.deco);
+ xdnd_data.deco = 0;
+
+ global_accepted_action = Qt::IgnoreAction;
+}
+
+static
+Window findRealWindow(const QPoint & pos, Window w, int md)
+{
+ if (xdnd_data.deco && w == xdnd_data.deco->effectiveWinId())
+ return 0;
+
+ if (md) {
+ X11->ignoreBadwindow();
+ XWindowAttributes attr;
+ XGetWindowAttributes(X11->display, w, &attr);
+ if (X11->badwindow())
+ return 0;
+
+ if (attr.map_state == IsViewable
+ && QRect(attr.x,attr.y,attr.width,attr.height).contains(pos)) {
+ {
+ Atom type = XNone;
+ int f;
+ unsigned long n, a;
+ unsigned char *data;
+
+ XGetWindowProperty(X11->display, w, ATOM(XdndAware), 0, 0, False,
+ AnyPropertyType, &type, &f,&n,&a,&data);
+ if (data) XFree(data);
+ if (type)
+ return w;
+ }
+
+ Window r, p;
+ Window* c;
+ uint nc;
+ if (XQueryTree(X11->display, w, &r, &p, &c, &nc)) {
+ r=0;
+ for (uint i=nc; !r && i--;) {
+ r = findRealWindow(pos-QPoint(attr.x,attr.y),
+ c[i], md-1);
+ }
+ XFree(c);
+ if (r)
+ return r;
+
+ // We didn't find a client window! Just use the
+ // innermost window.
+ }
+
+ // No children!
+ return w;
+ }
+ }
+ return 0;
+}
+
+void QDragManager::move(const QPoint & globalPos)
+{
+#ifdef QT_NO_CURSOR
+ Q_UNUSED(globalPos);
+ return;
+#else
+ DEBUG() << "QDragManager::move enter";
+ if (!object) {
+ // perhaps the target crashed?
+ return;
+ }
+
+ int screen = QCursor::x11Screen();
+ if ((qt_xdnd_current_screen == -1 && screen != X11->defaultScreen) || (screen != qt_xdnd_current_screen)) {
+ // recreate the pixmap on the new screen...
+ delete xdnd_data.deco;
+ QWidget* parent = object->source()->window()->x11Info().screen() == screen
+ ? object->source()->window() : QApplication::desktop()->screen(screen);
+ xdnd_data.deco = new QShapedPixmapWidget(parent);
+ if (!QWidget::mouseGrabber()) {
+ updatePixmap();
+ xdnd_data.deco->grabMouse();
+ }
+ }
+ xdnd_data.deco->move(QCursor::pos() - xdnd_data.deco->pm_hot);
+
+ if (qt_xdnd_source_sameanswer.contains(globalPos) && qt_xdnd_source_sameanswer.isValid())
+ return;
+
+ qt_xdnd_current_screen = screen;
+ Window rootwin = QX11Info::appRootWindow(qt_xdnd_current_screen);
+ Window target = 0;
+ int lx = 0, ly = 0;
+ if (!XTranslateCoordinates(X11->display, rootwin, rootwin, globalPos.x(), globalPos.y(), &lx, &ly, &target))
+ // some weird error...
+ return;
+
+ if (target == rootwin) {
+ // Ok.
+ } else if (target) {
+ //me
+ Window src = rootwin;
+ while (target != 0) {
+ DNDDEBUG << "checking target for XdndAware" << QWidget::find(target) << target;
+ int lx2, ly2;
+ Window t;
+ // translate coordinates
+ if (!XTranslateCoordinates(X11->display, src, target, lx, ly, &lx2, &ly2, &t)) {
+ target = 0;
+ break;
+ }
+ lx = lx2;
+ ly = ly2;
+ src = target;
+
+ // check if it has XdndAware
+ Atom type = 0;
+ int f;
+ unsigned long n, a;
+ unsigned char *data = 0;
+ XGetWindowProperty(X11->display, target, ATOM(XdndAware), 0, 0, False,
+ AnyPropertyType, &type, &f,&n,&a,&data);
+ if (data)
+ XFree(data);
+ if (type) {
+ DNDDEBUG << "Found XdndAware on " << QWidget::find(target) << target;
+ break;
+ }
+
+ // find child at the coordinates
+ if (!XTranslateCoordinates(X11->display, src, src, lx, ly, &lx2, &ly2, &target)) {
+ target = 0;
+ break;
+ }
+ }
+ if (xdnd_data.deco && (!target || target == xdnd_data.deco->effectiveWinId())) {
+ DNDDEBUG << "need to find real window";
+ target = findRealWindow(globalPos, rootwin, 6);
+ DNDDEBUG << "real window found" << QWidget::find(target) << target;
+ }
+ }
+
+ QWidget* w;
+ if (target) {
+ w = QWidget::find((WId)target);
+ if (w && (w->windowType() == Qt::Desktop) && !w->acceptDrops())
+ w = 0;
+ } else {
+ w = 0;
+ target = rootwin;
+ }
+
+ DNDDEBUG << "and the final target is " << QWidget::find(target) << target;
+ DNDDEBUG << "the widget w is" << w;
+
+ WId proxy_target = xdndProxy(target);
+ if (!proxy_target)
+ proxy_target = target;
+ int target_version = 1;
+
+ if (proxy_target) {
+ Atom type = XNone;
+ int r, f;
+ unsigned long n, a;
+ unsigned char *retval;
+ X11->ignoreBadwindow();
+ r = XGetWindowProperty(X11->display, proxy_target, ATOM(XdndAware), 0,
+ 1, False, AnyPropertyType, &type, &f,&n,&a,&retval);
+ int *tv = (int *)retval;
+ if (r != Success || X11->badwindow()) {
+ target = 0;
+ } else {
+ target_version = qMin(xdnd_version,tv ? *tv : 1);
+ if (tv)
+ XFree(tv);
+// if (!(!X11->badwindow() && type))
+// target = 0;
+ }
+ }
+
+ if (target != qt_xdnd_current_target) {
+ if (qt_xdnd_current_target)
+ qt_xdnd_send_leave();
+
+ qt_xdnd_current_target = target;
+ qt_xdnd_current_proxy_target = proxy_target;
+ if (target) {
+ QVector<Atom> types;
+ int flags = target_version << 24;
+ QStringList fmts = QInternalMimeData::formatsHelper(dragPrivate()->data);
+ for (int i = 0; i < fmts.size(); ++i) {
+ QList<Atom> atoms = X11->xdndMimeAtomsForFormat(fmts.at(i));
+ for (int j = 0; j < atoms.size(); ++j) {
+ if (!types.contains(atoms.at(j)))
+ types.append(atoms.at(j));
+ }
+ }
+ if (types.size() > 3) {
+ XChangeProperty(X11->display,
+ dragPrivate()->source->effectiveWinId(), ATOM(XdndTypelist),
+ XA_ATOM, 32, PropModeReplace,
+ (unsigned char *)types.data(),
+ types.size());
+ flags |= 0x0001;
+ }
+ XClientMessageEvent enter;
+ enter.type = ClientMessage;
+ enter.window = target;
+ enter.format = 32;
+ enter.message_type = ATOM(XdndEnter);
+ enter.data.l[0] = dragPrivate()->source->effectiveWinId();
+ enter.data.l[1] = flags;
+ enter.data.l[2] = types.size()>0 ? types.at(0) : 0;
+ enter.data.l[3] = types.size()>1 ? types.at(1) : 0;
+ enter.data.l[4] = types.size()>2 ? types.at(2) : 0;
+ // provisionally set the rectangle to 5x5 pixels...
+ qt_xdnd_source_sameanswer = QRect(globalPos.x() - 2,
+ globalPos.y() -2 , 5, 5);
+
+ DEBUG("sending Xdnd enter");
+ if (w)
+ X11->xdndHandleEnter(w, (const XEvent *)&enter, false);
+ else if (target)
+ XSendEvent(X11->display, proxy_target, False, NoEventMask, (XEvent*)&enter);
+ waiting_for_status = false;
+ }
+ }
+ if (waiting_for_status)
+ return;
+
+ if (target) {
+ waiting_for_status = true;
+
+ XClientMessageEvent move;
+ move.type = ClientMessage;
+ move.window = target;
+ move.format = 32;
+ move.message_type = ATOM(XdndPosition);
+ move.window = target;
+ move.data.l[0] = dragPrivate()->source->effectiveWinId();
+ move.data.l[1] = 0; // flags
+ move.data.l[2] = (globalPos.x() << 16) + globalPos.y();
+ move.data.l[3] = X11->time;
+ move.data.l[4] = qtaction_to_xdndaction(defaultAction(dragPrivate()->possible_actions, QApplication::keyboardModifiers()));
+ DEBUG("sending Xdnd position");
+
+ qt_xdnd_source_current_time = X11->time;
+
+ if (w)
+ handle_xdnd_position(w, (const XEvent *)&move, false);
+ else
+ XSendEvent(X11->display, proxy_target, False, NoEventMask,
+ (XEvent*)&move);
+ } else {
+ if (willDrop) {
+ willDrop = false;
+ updateCursor();
+ }
+ }
+ DEBUG() << "QDragManager::move leave";
+#endif
+}
+
+
+void QDragManager::drop()
+{
+ Q_ASSERT(heartbeat != -1);
+ killTimer(heartbeat);
+ heartbeat = -1;
+ qt_xdnd_dragging = false;
+
+ if (!qt_xdnd_current_target)
+ return;
+
+ qDeleteInEventHandler(xdnd_data.deco);
+ xdnd_data.deco = 0;
+
+ XClientMessageEvent drop;
+ drop.type = ClientMessage;
+ drop.window = qt_xdnd_current_target;
+ drop.format = 32;
+ drop.message_type = ATOM(XdndDrop);
+ drop.data.l[0] = dragPrivate()->source->effectiveWinId();
+ drop.data.l[1] = 0; // flags
+ drop.data.l[2] = X11->time;
+
+ drop.data.l[3] = 0;
+ drop.data.l[4] = 0;
+
+ QWidget * w = QWidget::find(qt_xdnd_current_proxy_target);
+
+ if (w && (w->windowType() == Qt::Desktop) && !w->acceptDrops())
+ w = 0;
+
+ QXdndDropTransaction t = {
+ X11->time,
+ qt_xdnd_current_target,
+ qt_xdnd_current_proxy_target,
+ w,
+ current_embedding_widget,
+ object
+ };
+ X11->dndDropTransactions.append(t);
+ restartXdndDropExpiryTimer();
+
+ if (w)
+ X11->xdndHandleDrop(w, (const XEvent *)&drop, false);
+ else
+ XSendEvent(X11->display, qt_xdnd_current_proxy_target, False,
+ NoEventMask, (XEvent*)&drop);
+
+ qt_xdnd_current_target = 0;
+ qt_xdnd_current_proxy_target = 0;
+ qt_xdnd_source_current_time = 0;
+ current_embedding_widget = 0;
+ object = 0;
+
+#ifndef QT_NO_CURSOR
+ if (restoreCursor) {
+ QApplication::restoreOverrideCursor();
+ restoreCursor = false;
+ }
+#endif
+}
+
+
+
+bool QX11Data::xdndHandleBadwindow()
+{
+ if (qt_xdnd_current_target) {
+ QDragManager *manager = QDragManager::self();
+ if (manager->object) {
+ qt_xdnd_current_target = 0;
+ qt_xdnd_current_proxy_target = 0;
+ manager->object->deleteLater();
+ manager->object = 0;
+ delete xdnd_data.deco;
+ xdnd_data.deco = 0;
+ return true;
+ }
+ }
+ if (qt_xdnd_dragsource_xid) {
+ qt_xdnd_dragsource_xid = 0;
+ if (qt_xdnd_current_widget) {
+ QApplication::postEvent(qt_xdnd_current_widget, new QDragLeaveEvent);
+ qt_xdnd_current_widget = 0;
+ }
+ return true;
+ }
+ return false;
+}
+
+void QX11Data::xdndHandleSelectionRequest(const XSelectionRequestEvent * req)
+{
+ if (!req)
+ return;
+ XEvent evt;
+ evt.xselection.type = SelectionNotify;
+ evt.xselection.display = req->display;
+ evt.xselection.requestor = req->requestor;
+ evt.xselection.selection = req->selection;
+ evt.xselection.target = XNone;
+ evt.xselection.property = XNone;
+ evt.xselection.time = req->time;
+
+ QDragManager *manager = QDragManager::self();
+ QDrag *currentObject = manager->object;
+
+ // which transaction do we use? (note: -2 means use current manager->object)
+ int at = -1;
+
+ // figure out which data the requestor is really interested in
+ if (manager->object && req->time == qt_xdnd_source_current_time) {
+ // requestor wants the current drag data
+ at = -2;
+ } else {
+ // if someone has requested data in response to XdndDrop, find the corresponding transaction. the
+ // spec says to call XConvertSelection() using the timestamp from the XdndDrop
+ at = findXdndDropTransactionByTime(req->time);
+ if (at == -1) {
+ // no dice, perhaps the client was nice enough to use the same window id in XConvertSelection()
+ // that we sent the XdndDrop event to.
+ at = findXdndDropTransactionByWindow(req->requestor);
+ }
+ if (at == -1 && req->time == CurrentTime) {
+ // previous Qt versions always requested the data on a child of the target window
+ // using CurrentTime... but it could be asking for either drop data or the current drag's data
+ Window target = findXdndAwareParent(req->requestor);
+ if (target) {
+ if (qt_xdnd_current_target && qt_xdnd_current_target == target)
+ at = -2;
+ else
+ at = findXdndDropTransactionByWindow(target);
+ }
+ }
+ }
+ if (at >= 0) {
+ restartXdndDropExpiryTimer();
+
+ // use the drag object from an XdndDrop tansaction
+ manager->object = X11->dndDropTransactions.at(at).object;
+ } else if (at != -2) {
+ // no transaction found, we'll have to reject the request
+ manager->object = 0;
+ }
+ if (manager->object) {
+ Atom atomFormat = req->target;
+ int dataFormat = 0;
+ QByteArray data;
+ if (X11->xdndMimeDataForAtom(req->target, manager->dragPrivate()->data,
+ &data, &atomFormat, &dataFormat)) {
+ int dataSize = data.size() / (dataFormat / 8);
+ XChangeProperty (X11->display, req->requestor, req->property,
+ atomFormat, dataFormat, PropModeReplace,
+ (unsigned char *)data.data(), dataSize);
+ evt.xselection.property = req->property;
+ evt.xselection.target = atomFormat;
+ }
+ }
+
+ // reset manager->object in case we modified it above
+ manager->object = currentObject;
+
+ // ### this can die if req->requestor crashes at the wrong
+ // ### moment
+ XSendEvent(X11->display, req->requestor, False, 0, &evt);
+}
+
+static QVariant xdndObtainData(const char *format, QVariant::Type requestedType)
+{
+ QByteArray result;
+
+ QWidget* w;
+ QDragManager *manager = QDragManager::self();
+ if (qt_xdnd_dragsource_xid && manager->object &&
+ (w=QWidget::find(qt_xdnd_dragsource_xid))
+ && (!(w->windowType() == Qt::Desktop) || w->acceptDrops()))
+ {
+ QDragPrivate * o = QDragManager::self()->dragPrivate();
+ if (o->data->hasFormat(QLatin1String(format)))
+ result = o->data->data(QLatin1String(format));
+ return result;
+ }
+
+ QList<Atom> atoms;
+ int i = 0;
+ while ((qt_xdnd_types[i])) {
+ atoms.append(qt_xdnd_types[i]);
+ ++i;
+ }
+ QByteArray encoding;
+ Atom a = X11->xdndMimeAtomForFormat(QLatin1String(format), requestedType, atoms, &encoding);
+ if (!a)
+ return result;
+
+ if (XGetSelectionOwner(X11->display, ATOM(XdndSelection)) == XNone)
+ return result; // should never happen?
+
+ QWidget* tw = qt_xdnd_current_widget;
+ if (!qt_xdnd_current_widget || (qt_xdnd_current_widget->windowType() == Qt::Desktop))
+ tw = new QWidget;
+
+ XConvertSelection(X11->display, ATOM(XdndSelection), a, ATOM(XdndSelection), tw->effectiveWinId(),
+ qt_xdnd_target_current_time);
+ XFlush(X11->display);
+
+ XEvent xevent;
+ bool got=X11->clipboardWaitForEvent(tw->effectiveWinId(), SelectionNotify, &xevent, 5000);
+ if (got) {
+ Atom type;
+
+ if (X11->clipboardReadProperty(tw->effectiveWinId(), ATOM(XdndSelection), true, &result, 0, &type, 0)) {
+ if (type == ATOM(INCR)) {
+ int nbytes = result.size() >= 4 ? *((int*)result.data()) : 0;
+ result = X11->clipboardReadIncrementalProperty(tw->effectiveWinId(), ATOM(XdndSelection), nbytes, false);
+ } else if (type != a && type != XNone) {
+ DEBUG("Qt clipboard: unknown atom %ld", type);
+ }
+ }
+ }
+ if (!qt_xdnd_current_widget || (qt_xdnd_current_widget->windowType() == Qt::Desktop))
+ delete tw;
+
+ return X11->xdndMimeConvertToFormat(a, result, QLatin1String(format), requestedType, encoding);
+}
+
+
+/*
+ Enable drag and drop for widget w by installing the proper
+ properties on w's toplevel widget.
+*/
+bool QX11Data::dndEnable(QWidget* w, bool on)
+{
+ w = w->window();
+
+ if (bool(((QExtraWidget*)w)->topData()->dnd) == on)
+ return true; // been there, done that
+ ((QExtraWidget*)w)->topData()->dnd = on ? 1 : 0;
+
+ motifdndEnable(w, on);
+ return xdndEnable(w, on);
+}
+
+Qt::DropAction QDragManager::drag(QDrag * o)
+{
+ if (object == o || !o || !o->d_func()->source)
+ return Qt::IgnoreAction;
+
+ if (object) {
+ cancel();
+ qApp->removeEventFilter(this);
+ beingCancelled = false;
+ }
+
+ if (object) {
+ // the last drag and drop operation hasn't finished, so we are going to wait
+ // for one second to see if it does... if the finish message comes after this,
+ // then we could still have problems, but this is highly unlikely
+ QApplication::flush();
+
+ QElapsedTimer timer;
+ timer.start();
+ do {
+ XEvent event;
+ if (XCheckTypedEvent(X11->display, ClientMessage, &event))
+ qApp->x11ProcessEvent(&event);
+
+ // sleep 50 ms, so we don't use up CPU cycles all the time.
+ struct timeval usleep_tv;
+ usleep_tv.tv_sec = 0;
+ usleep_tv.tv_usec = 50000;
+ select(0, 0, 0, 0, &usleep_tv);
+ } while (object && timer.hasExpired(1000));
+ }
+
+ object = o;
+ object->d_func()->target = 0;
+ xdnd_data.deco = new QShapedPixmapWidget(object->source()->window());
+
+ willDrop = false;
+
+ updatePixmap();
+
+ qApp->installEventFilter(this);
+ XSetSelectionOwner(X11->display, ATOM(XdndSelection), dragPrivate()->source->window()->internalWinId(), X11->time);
+ global_accepted_action = Qt::CopyAction;
+ qt_xdnd_source_sameanswer = QRect();
+#ifndef QT_NO_CURSOR
+ // set the override cursor (must be done here, since it is updated
+ // in the call to move() below)
+ qApp->setOverrideCursor(Qt::ArrowCursor);
+ restoreCursor = true;
+#endif
+ move(QCursor::pos());
+ heartbeat = startTimer(200);
+
+ qt_xdnd_dragging = true;
+
+ if (!QWidget::mouseGrabber())
+ xdnd_data.deco->grabMouse();
+
+ eventLoop = new QEventLoop;
+ (void) eventLoop->exec();
+ delete eventLoop;
+ eventLoop = 0;
+
+#ifndef QT_NO_CURSOR
+ if (restoreCursor) {
+ qApp->restoreOverrideCursor();
+ restoreCursor = false;
+ }
+#endif
+
+ // delete cursors as they may be different next drag.
+ delete noDropCursor;
+ noDropCursor = 0;
+ delete copyCursor;
+ copyCursor = 0;
+ delete moveCursor;
+ moveCursor = 0;
+ delete linkCursor;
+ linkCursor = 0;
+
+ delete xdnd_data.deco;
+ xdnd_data.deco = 0;
+ if (heartbeat != -1)
+ killTimer(heartbeat);
+ heartbeat = -1;
+ qt_xdnd_current_screen = -1;
+ qt_xdnd_dragging = false;
+
+ return global_accepted_action;
+ // object persists until we get an xdnd_finish message
+}
+
+void QDragManager::updatePixmap()
+{
+ if (xdnd_data.deco) {
+ QPixmap pm;
+ QPoint pm_hot(default_pm_hotx,default_pm_hoty);
+ if (object) {
+ pm = dragPrivate()->pixmap;
+ if (!pm.isNull())
+ pm_hot = dragPrivate()->hotspot;
+ }
+ if (pm.isNull()) {
+ if (!defaultPm)
+ defaultPm = new QPixmap(default_pm);
+ pm = *defaultPm;
+ }
+ xdnd_data.deco->pm_hot = pm_hot;
+ xdnd_data.deco->setPixmap(pm);
+ xdnd_data.deco->move(QCursor::pos()-pm_hot);
+ xdnd_data.deco->show();
+ }
+}
+
+QVariant QDropData::retrieveData_sys(const QString &mimetype, QVariant::Type requestedType) const
+{
+ QByteArray mime = mimetype.toLatin1();
+ QVariant data = X11->motifdnd_active
+ ? X11->motifdndObtainData(mime)
+ : xdndObtainData(mime, requestedType);
+ return data;
+}
+
+bool QDropData::hasFormat_sys(const QString &format) const
+{
+ return formats().contains(format);
+}
+
+QStringList QDropData::formats_sys() const
+{
+ QStringList formats;
+ if (X11->motifdnd_active) {
+ int i = 0;
+ QByteArray fmt;
+ while (!(fmt = X11->motifdndFormat(i)).isEmpty()) {
+ formats.append(QLatin1String(fmt));
+ ++i;
+ }
+ } else {
+ int i = 0;
+ while ((qt_xdnd_types[i])) {
+ QStringList formatsForAtom = X11->xdndMimeFormatsForAtom(qt_xdnd_types[i]);
+ for (int j = 0; j < formatsForAtom.size(); ++j) {
+ if (!formats.contains(formatsForAtom.at(j)))
+ formats.append(formatsForAtom.at(j));
+ }
+ ++i;
+ }
+ }
+ return formats;
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_DRAGANDDROP
diff --git a/src/gui/kernel/qeventdispatcher_x11.cpp b/src/widgets/platforms/x11/qeventdispatcher_x11.cpp
index 110786a378..110786a378 100644
--- a/src/gui/kernel/qeventdispatcher_x11.cpp
+++ b/src/widgets/platforms/x11/qeventdispatcher_x11.cpp
diff --git a/src/gui/kernel/qeventdispatcher_x11_p.h b/src/widgets/platforms/x11/qeventdispatcher_x11_p.h
index cfdd2a5fa6..cfdd2a5fa6 100644
--- a/src/gui/kernel/qeventdispatcher_x11_p.h
+++ b/src/widgets/platforms/x11/qeventdispatcher_x11_p.h
diff --git a/src/gui/text/qfont_x11.cpp b/src/widgets/platforms/x11/qfont_x11.cpp
index c72a5fade5..c72a5fade5 100644
--- a/src/gui/text/qfont_x11.cpp
+++ b/src/widgets/platforms/x11/qfont_x11.cpp
diff --git a/src/gui/text/qfontdatabase_x11.cpp b/src/widgets/platforms/x11/qfontdatabase_x11.cpp
index 0c0c4c8343..0c0c4c8343 100644
--- a/src/gui/text/qfontdatabase_x11.cpp
+++ b/src/widgets/platforms/x11/qfontdatabase_x11.cpp
diff --git a/src/gui/text/qfontengine_x11.cpp b/src/widgets/platforms/x11/qfontengine_x11.cpp
index 4260b85b11..4260b85b11 100644
--- a/src/gui/text/qfontengine_x11.cpp
+++ b/src/widgets/platforms/x11/qfontengine_x11.cpp
diff --git a/src/gui/text/qfontengine_x11_p.h b/src/widgets/platforms/x11/qfontengine_x11_p.h
index d7eb39daaa..d7eb39daaa 100644
--- a/src/gui/text/qfontengine_x11_p.h
+++ b/src/widgets/platforms/x11/qfontengine_x11_p.h
diff --git a/src/gui/kernel/qkde.cpp b/src/widgets/platforms/x11/qkde.cpp
index 7d333feb9a..7d333feb9a 100644
--- a/src/gui/kernel/qkde.cpp
+++ b/src/widgets/platforms/x11/qkde.cpp
diff --git a/src/widgets/platforms/x11/qkde_p.h b/src/widgets/platforms/x11/qkde_p.h
new file mode 100644
index 0000000000..f1f7c57f15
--- /dev/null
+++ b/src/widgets/platforms/x11/qkde_p.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QKDE_H
+#define QKDE_H
+
+#include <QtCore/qglobal.h>
+#include <QtGui/QPalette>
+#include <QtWidgets/QIcon>
+
+//
+// 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.
+//
+#if defined(Q_WS_X11)
+
+
+QT_BEGIN_NAMESPACE
+
+/*!\internal
+ This namespace contains helper function to help KDE integration
+ They are only used if we detect the use of KDE and the KDE platform plugin is not found (old KDE version)
+ Or if the detected KDE version is KDE3
+*/
+namespace QKde {
+ QString kdeHome();
+ QString kdeStyle();
+ QPalette kdePalette();
+ int kdeToolButtonStyle();
+ int kdeToolBarIconSize();
+}
+
+
+QT_END_NAMESPACE
+
+#endif // Q_WS_X11
+#endif // QKDE_H
diff --git a/src/gui/kernel/qkeymapper_x11.cpp b/src/widgets/platforms/x11/qkeymapper_x11.cpp
index 5383bfd456..5383bfd456 100644
--- a/src/gui/kernel/qkeymapper_x11.cpp
+++ b/src/widgets/platforms/x11/qkeymapper_x11.cpp
diff --git a/src/gui/kernel/qkeymapper_x11_p.cpp b/src/widgets/platforms/x11/qkeymapper_x11_p.cpp
index 2dbe1e77a4..2dbe1e77a4 100644
--- a/src/gui/kernel/qkeymapper_x11_p.cpp
+++ b/src/widgets/platforms/x11/qkeymapper_x11_p.cpp
diff --git a/src/gui/kernel/qmotifdnd_x11.cpp b/src/widgets/platforms/x11/qmotifdnd_x11.cpp
index eef4cc470b..eef4cc470b 100644
--- a/src/gui/kernel/qmotifdnd_x11.cpp
+++ b/src/widgets/platforms/x11/qmotifdnd_x11.cpp
diff --git a/src/widgets/platforms/x11/qpaintdevice_x11.cpp b/src/widgets/platforms/x11/qpaintdevice_x11.cpp
new file mode 100644
index 0000000000..690dea99d7
--- /dev/null
+++ b/src/widgets/platforms/x11/qpaintdevice_x11.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qpaintdevice.h"
+#include "qpainter.h"
+#include "qwidget.h"
+#include "qbitmap.h"
+#include "qapplication.h"
+#include <private/qt_x11_p.h>
+#include "qx11info_x11.h"
+
+QT_BEGIN_NAMESPACE
+
+/*! \internal
+
+ Returns the X11 Drawable of the paint device. 0 is returned if it
+ can't be obtained.
+*/
+
+Drawable Q_GUI_EXPORT qt_x11Handle(const QPaintDevice *pd)
+{
+ if (!pd) return 0;
+ if (pd->devType() == QInternal::Widget)
+ return static_cast<const QWidget *>(pd)->handle();
+ else if (pd->devType() == QInternal::Pixmap)
+ return static_cast<const QPixmap *>(pd)->handle();
+ return 0;
+}
+
+/*!
+ \relates QPaintDevice
+
+ Returns the QX11Info structure for the \a pd paint device. 0 is
+ returned if it can't be obtained.
+*/
+const Q_GUI_EXPORT QX11Info *qt_x11Info(const QPaintDevice *pd)
+{
+ if (!pd) return 0;
+ if (pd->devType() == QInternal::Widget)
+ return &static_cast<const QWidget *>(pd)->x11Info();
+ else if (pd->devType() == QInternal::Pixmap)
+ return &static_cast<const QPixmap *>(pd)->x11Info();
+ return 0;
+}
+
+QT_END_NAMESPACE
diff --git a/src/widgets/platforms/x11/qpaintengine_x11.cpp b/src/widgets/platforms/x11/qpaintengine_x11.cpp
new file mode 100644
index 0000000000..d3c750a5f1
--- /dev/null
+++ b/src/widgets/platforms/x11/qpaintengine_x11.cpp
@@ -0,0 +1,2504 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformdefs.h"
+
+#include "private/qpixmap_x11_p.h"
+
+#include "qapplication.h"
+#include "qdebug.h"
+#include "qfont.h"
+#include "qwidget.h"
+#include "qbitmap.h"
+#include "qpixmapcache.h"
+#include "qtextcodec.h"
+#include "qcoreevent.h"
+#include "qiodevice.h"
+#include <qmath.h>
+
+#include "qpainter_p.h"
+#include <qtextlayout.h>
+#include <qvarlengtharray.h>
+#include <private/qfont_p.h>
+#include <private/qtextengine_p.h>
+#include <private/qpaintengine_x11_p.h>
+#include <private/qfontengine_x11_p.h>
+#include <private/qwidget_p.h>
+#include <private/qpainterpath_p.h>
+
+#include "qpen.h"
+#include "qcolor.h"
+#include "qcolormap.h"
+
+#include <private/qpaintengine_p.h>
+#include "qpaintengine_x11_p.h"
+
+#include <private/qt_x11_p.h>
+#include <private/qnumeric_p.h>
+#include <limits.h>
+
+#ifndef QT_NO_XRENDER
+#include <private/qtessellator_p.h>
+#endif
+
+#include <private/qhexstring_p.h>
+
+QT_BEGIN_NAMESPACE
+
+extern Drawable qt_x11Handle(const QPaintDevice *pd);
+extern const QX11Info *qt_x11Info(const QPaintDevice *pd);
+extern QPixmap qt_pixmapForBrush(int brushStyle, bool invert); //in qbrush.cpp
+extern QPixmap qt_toX11Pixmap(const QPixmap &pixmap);
+
+// use the same rounding as in qrasterizer.cpp (6 bit fixed point)
+static const qreal aliasedCoordinateDelta = 0.5 - 0.015625;
+
+#undef X11 // defined in qt_x11_p.h
+/*!
+ Returns the X11 specific pen GC for the painter \a p. Note that
+ QPainter::begin() must be called before this function returns a
+ valid GC.
+*/
+Q_GUI_EXPORT GC qt_x11_get_pen_gc(QPainter *p)
+{
+ if (p && p->paintEngine()
+ && p->paintEngine()->isActive()
+ && p->paintEngine()->type() == QPaintEngine::X11) {
+ return static_cast<QX11PaintEngine *>(p->paintEngine())->d_func()->gc;
+ }
+ return 0;
+}
+
+/*!
+ Returns the X11 specific brush GC for the painter \a p. Note that
+ QPainter::begin() must be called before this function returns a
+ valid GC.
+*/
+Q_GUI_EXPORT GC qt_x11_get_brush_gc(QPainter *p)
+{
+ if (p && p->paintEngine()
+ && p->paintEngine()->isActive()
+ && p->paintEngine()->type() == QPaintEngine::X11) {
+ return static_cast<QX11PaintEngine *>(p->paintEngine())->d_func()->gc_brush;
+ }
+ return 0;
+}
+#define X11 qt_x11Data
+
+#ifndef QT_NO_XRENDER
+static const int compositionModeToRenderOp[QPainter::CompositionMode_Xor + 1] = {
+ PictOpOver, //CompositionMode_SourceOver,
+ PictOpOverReverse, //CompositionMode_DestinationOver,
+ PictOpClear, //CompositionMode_Clear,
+ PictOpSrc, //CompositionMode_Source,
+ PictOpDst, //CompositionMode_Destination,
+ PictOpIn, //CompositionMode_SourceIn,
+ PictOpInReverse, //CompositionMode_DestinationIn,
+ PictOpOut, //CompositionMode_SourceOut,
+ PictOpOutReverse, //CompositionMode_DestinationOut,
+ PictOpAtop, //CompositionMode_SourceAtop,
+ PictOpAtopReverse, //CompositionMode_DestinationAtop,
+ PictOpXor //CompositionMode_Xor
+};
+
+static inline int qpainterOpToXrender(QPainter::CompositionMode mode)
+{
+ Q_ASSERT(mode <= QPainter::CompositionMode_Xor);
+ return compositionModeToRenderOp[mode];
+}
+#endif
+
+// hack, so we don't have to make QRegion::clipRectangles() public or include
+// X11 headers in qregion.h
+Q_GUI_EXPORT void *qt_getClipRects(const QRegion &r, int &num)
+{
+ return r.clipRectangles(num);
+}
+
+static inline void x11SetClipRegion(Display *dpy, GC gc, GC gc2,
+#ifndef QT_NO_XRENDER
+ Picture picture,
+#else
+ Qt::HANDLE picture,
+#endif
+ const QRegion &r)
+{
+ int num;
+ XRectangle *rects = (XRectangle *)qt_getClipRects(r, num);
+
+ if (gc)
+ XSetClipRectangles( dpy, gc, 0, 0, rects, num, YXBanded );
+ if (gc2)
+ XSetClipRectangles( dpy, gc2, 0, 0, rects, num, YXBanded );
+
+#ifndef QT_NO_XRENDER
+ if (picture)
+ XRenderSetPictureClipRectangles(dpy, picture, 0, 0, rects, num);
+#else
+ Q_UNUSED(picture);
+#endif // QT_NO_XRENDER
+}
+
+
+static inline void x11ClearClipRegion(Display *dpy, GC gc, GC gc2,
+#ifndef QT_NO_XRENDER
+ Picture picture
+#else
+ Qt::HANDLE picture
+#endif
+ )
+{
+ if (gc)
+ XSetClipMask(dpy, gc, XNone);
+ if (gc2)
+ XSetClipMask(dpy, gc2, XNone);
+
+#ifndef QT_NO_XRENDER
+ if (picture) {
+ XRenderPictureAttributes attrs;
+ attrs.clip_mask = XNone;
+ XRenderChangePicture (dpy, picture, CPClipMask, &attrs);
+ }
+#else
+ Q_UNUSED(picture);
+#endif // QT_NO_XRENDER
+}
+
+
+#define DITHER_SIZE 16
+static const uchar base_dither_matrix[DITHER_SIZE][DITHER_SIZE] = {
+ { 0,192, 48,240, 12,204, 60,252, 3,195, 51,243, 15,207, 63,255 },
+ { 128, 64,176,112,140, 76,188,124,131, 67,179,115,143, 79,191,127 },
+ { 32,224, 16,208, 44,236, 28,220, 35,227, 19,211, 47,239, 31,223 },
+ { 160, 96,144, 80,172,108,156, 92,163, 99,147, 83,175,111,159, 95 },
+ { 8,200, 56,248, 4,196, 52,244, 11,203, 59,251, 7,199, 55,247 },
+ { 136, 72,184,120,132, 68,180,116,139, 75,187,123,135, 71,183,119 },
+ { 40,232, 24,216, 36,228, 20,212, 43,235, 27,219, 39,231, 23,215 },
+ { 168,104,152, 88,164,100,148, 84,171,107,155, 91,167,103,151, 87 },
+ { 2,194, 50,242, 14,206, 62,254, 1,193, 49,241, 13,205, 61,253 },
+ { 130, 66,178,114,142, 78,190,126,129, 65,177,113,141, 77,189,125 },
+ { 34,226, 18,210, 46,238, 30,222, 33,225, 17,209, 45,237, 29,221 },
+ { 162, 98,146, 82,174,110,158, 94,161, 97,145, 81,173,109,157, 93 },
+ { 10,202, 58,250, 6,198, 54,246, 9,201, 57,249, 5,197, 53,245 },
+ { 138, 74,186,122,134, 70,182,118,137, 73,185,121,133, 69,181,117 },
+ { 42,234, 26,218, 38,230, 22,214, 41,233, 25,217, 37,229, 21,213 },
+ { 170,106,154, 90,166,102,150, 86,169,105,153, 89,165,101,149, 85 }
+};
+
+static QPixmap qt_patternForAlpha(uchar alpha, int screen)
+{
+ QPixmap pm;
+ QString key = QLatin1Literal("$qt-alpha-brush$")
+ % HexString<uchar>(alpha)
+ % HexString<int>(screen);
+
+ if (!QPixmapCache::find(key, pm)) {
+ // #### why not use a mono image here????
+ QImage pattern(DITHER_SIZE, DITHER_SIZE, QImage::Format_ARGB32);
+ pattern.fill(0xffffffff);
+ for (int y = 0; y < DITHER_SIZE; ++y) {
+ for (int x = 0; x < DITHER_SIZE; ++x) {
+ if (base_dither_matrix[x][y] <= alpha)
+ pattern.setPixel(x, y, 0x00000000);
+ }
+ }
+ pm = QBitmap::fromImage(pattern);
+ pm.x11SetScreen(screen);
+ QPixmapCache::insert(key, pm);
+ }
+ return pm;
+}
+
+#if !defined(QT_NO_XRENDER)
+
+class QXRenderTessellator : public QTessellator
+{
+public:
+ QXRenderTessellator() : traps(0), allocated(0), size(0) {}
+ ~QXRenderTessellator() { free(traps); }
+ XTrapezoid *traps;
+ int allocated;
+ int size;
+ void addTrap(const Trapezoid &trap);
+ QRect tessellate(const QPointF *points, int nPoints, bool winding) {
+ size = 0;
+ setWinding(winding);
+ return QTessellator::tessellate(points, nPoints).toRect();
+ }
+ void done() {
+ if (allocated > 64) {
+ free(traps);
+ traps = 0;
+ allocated = 0;
+ }
+ }
+};
+
+void QXRenderTessellator::addTrap(const Trapezoid &trap)
+{
+ if (size == allocated) {
+ allocated = qMax(2*allocated, 64);
+ traps = q_check_ptr((XTrapezoid *)realloc(traps, allocated * sizeof(XTrapezoid)));
+ }
+ traps[size].top = Q27Dot5ToXFixed(trap.top);
+ traps[size].bottom = Q27Dot5ToXFixed(trap.bottom);
+ traps[size].left.p1.x = Q27Dot5ToXFixed(trap.topLeft->x);
+ traps[size].left.p1.y = Q27Dot5ToXFixed(trap.topLeft->y);
+ traps[size].left.p2.x = Q27Dot5ToXFixed(trap.bottomLeft->x);
+ traps[size].left.p2.y = Q27Dot5ToXFixed(trap.bottomLeft->y);
+ traps[size].right.p1.x = Q27Dot5ToXFixed(trap.topRight->x);
+ traps[size].right.p1.y = Q27Dot5ToXFixed(trap.topRight->y);
+ traps[size].right.p2.x = Q27Dot5ToXFixed(trap.bottomRight->x);
+ traps[size].right.p2.y = Q27Dot5ToXFixed(trap.bottomRight->y);
+ ++size;
+}
+
+#endif // !defined(QT_NO_XRENDER)
+
+
+#ifndef QT_NO_XRENDER
+static Picture getPatternFill(int screen, const QBrush &b)
+{
+ if (!X11->use_xrender)
+ return XNone;
+
+ XRenderColor color = X11->preMultiply(b.color());
+ XRenderColor bg_color;
+
+ bg_color = X11->preMultiply(QColor(0, 0, 0, 0));
+
+ for (int i = 0; i < X11->pattern_fill_count; ++i) {
+ if (X11->pattern_fills[i].screen == screen
+ && X11->pattern_fills[i].opaque == false
+ && X11->pattern_fills[i].style == b.style()
+ && X11->pattern_fills[i].color.alpha == color.alpha
+ && X11->pattern_fills[i].color.red == color.red
+ && X11->pattern_fills[i].color.green == color.green
+ && X11->pattern_fills[i].color.blue == color.blue
+ && X11->pattern_fills[i].bg_color.alpha == bg_color.alpha
+ && X11->pattern_fills[i].bg_color.red == bg_color.red
+ && X11->pattern_fills[i].bg_color.green == bg_color.green
+ && X11->pattern_fills[i].bg_color.blue == bg_color.blue)
+ return X11->pattern_fills[i].picture;
+ }
+ // none found, replace one
+ int i = qrand() % 16;
+
+ if (X11->pattern_fills[i].screen != screen && X11->pattern_fills[i].picture) {
+ XRenderFreePicture (X11->display, X11->pattern_fills[i].picture);
+ X11->pattern_fills[i].picture = 0;
+ }
+
+ if (!X11->pattern_fills[i].picture) {
+ Pixmap pixmap = XCreatePixmap (X11->display, RootWindow (X11->display, screen), 8, 8, 32);
+ XRenderPictureAttributes attrs;
+ attrs.repeat = True;
+ X11->pattern_fills[i].picture = XRenderCreatePicture (X11->display, pixmap,
+ XRenderFindStandardFormat(X11->display, PictStandardARGB32),
+ CPRepeat, &attrs);
+ XFreePixmap (X11->display, pixmap);
+ }
+
+ X11->pattern_fills[i].screen = screen;
+ X11->pattern_fills[i].color = color;
+ X11->pattern_fills[i].bg_color = bg_color;
+ X11->pattern_fills[i].opaque = false;
+ X11->pattern_fills[i].style = b.style();
+
+ XRenderFillRectangle(X11->display, PictOpSrc, X11->pattern_fills[i].picture, &bg_color, 0, 0, 8, 8);
+
+ QPixmap pattern(qt_pixmapForBrush(b.style(), true));
+ XRenderPictureAttributes attrs;
+ attrs.repeat = true;
+ XRenderChangePicture(X11->display, pattern.x11PictureHandle(), CPRepeat, &attrs);
+
+ Picture fill_fg = X11->getSolidFill(screen, b.color());
+ XRenderComposite(X11->display, PictOpOver, fill_fg, pattern.x11PictureHandle(),
+ X11->pattern_fills[i].picture,
+ 0, 0, 0, 0, 0, 0, 8, 8);
+
+ return X11->pattern_fills[i].picture;
+}
+
+static void qt_render_bitmap(Display *dpy, int scrn, Picture src, Picture dst,
+ int sx, int sy, int x, int y, int sw, int sh,
+ const QPen &pen)
+{
+ Picture fill_fg = X11->getSolidFill(scrn, pen.color());
+ XRenderComposite(dpy, PictOpOver,
+ fill_fg, src, dst, sx, sy, sx, sy, x, y, sw, sh);
+}
+#endif
+
+void QX11PaintEnginePrivate::init()
+{
+ dpy = 0;
+ scrn = 0;
+ hd = 0;
+ picture = 0;
+ xinfo = 0;
+#ifndef QT_NO_XRENDER
+ current_brush = 0;
+ composition_mode = PictOpOver;
+ tessellator = new QXRenderTessellator;
+#endif
+}
+
+void QX11PaintEnginePrivate::setupAdaptedOrigin(const QPoint &p)
+{
+ if (adapted_pen_origin)
+ XSetTSOrigin(dpy, gc, p.x(), p.y());
+ if (adapted_brush_origin)
+ XSetTSOrigin(dpy, gc_brush, p.x(), p.y());
+}
+
+void QX11PaintEnginePrivate::resetAdaptedOrigin()
+{
+ if (adapted_pen_origin)
+ XSetTSOrigin(dpy, gc, 0, 0);
+ if (adapted_brush_origin)
+ XSetTSOrigin(dpy, gc_brush, 0, 0);
+}
+
+void QX11PaintEnginePrivate::clipPolygon_dev(const QPolygonF &poly, QPolygonF *clipped_poly)
+{
+ int clipped_count = 0;
+ qt_float_point *clipped_points = 0;
+ polygonClipper.clipPolygon((qt_float_point *) poly.data(), poly.size(),
+ &clipped_points, &clipped_count);
+ clipped_poly->resize(clipped_count);
+ for (int i=0; i<clipped_count; ++i)
+ (*clipped_poly)[i] = *((QPointF *)(&clipped_points[i]));
+}
+
+void QX11PaintEnginePrivate::systemStateChanged()
+{
+ Q_Q(QX11PaintEngine);
+ QPainter *painter = q->state ? static_cast<QPainterState *>(q->state)->painter : 0;
+ if (painter && painter->hasClipping()) {
+ if (q->testDirty(QPaintEngine::DirtyTransform))
+ q->updateMatrix(q->state->transform());
+ QPolygonF clip_poly_dev(matrix.map(painter->clipPath().toFillPolygon()));
+ QPolygonF clipped_poly_dev;
+ clipPolygon_dev(clip_poly_dev, &clipped_poly_dev);
+ q->updateClipRegion_dev(QRegion(clipped_poly_dev.toPolygon()), Qt::ReplaceClip);
+ } else {
+ q->updateClipRegion_dev(QRegion(), Qt::NoClip);
+ }
+}
+
+static QPaintEngine::PaintEngineFeatures qt_decide_features()
+{
+ QPaintEngine::PaintEngineFeatures features =
+ QPaintEngine::PrimitiveTransform
+ | QPaintEngine::PatternBrush
+ | QPaintEngine::AlphaBlend
+ | QPaintEngine::PainterPaths
+ | QPaintEngine::RasterOpModes;
+
+ if (X11->use_xrender) {
+ features |= QPaintEngine::Antialiasing;
+ features |= QPaintEngine::PorterDuff;
+ features |= QPaintEngine::MaskedBrush;
+#if 0
+ if (X11->xrender_version > 10) {
+ features |= QPaintEngine::LinearGradientFill;
+ // ###
+ }
+#endif
+ }
+
+ return features;
+}
+
+/*
+ * QX11PaintEngine members
+ */
+
+QX11PaintEngine::QX11PaintEngine()
+ : QPaintEngine(*(new QX11PaintEnginePrivate), qt_decide_features())
+{
+ d_func()->init();
+}
+
+QX11PaintEngine::QX11PaintEngine(QX11PaintEnginePrivate &dptr)
+ : QPaintEngine(dptr, qt_decide_features())
+{
+ d_func()->init();
+}
+
+QX11PaintEngine::~QX11PaintEngine()
+{
+#ifndef QT_NO_XRENDER
+ Q_D(QX11PaintEngine);
+ delete d->tessellator;
+#endif
+}
+
+bool QX11PaintEngine::begin(QPaintDevice *pdev)
+{
+ Q_D(QX11PaintEngine);
+ d->xinfo = qt_x11Info(pdev);
+ QWidget *w = d->pdev->devType() == QInternal::Widget ? static_cast<QWidget *>(d->pdev) : 0;
+ const bool isAlienWidget = w && !w->internalWinId() && w->testAttribute(Qt::WA_WState_Created);
+#ifndef QT_NO_XRENDER
+ if (w) {
+ if (isAlienWidget)
+ d->picture = (::Picture)w->nativeParentWidget()->x11PictureHandle();
+ else
+ d->picture = (::Picture)w->x11PictureHandle();
+ } else if (pdev->devType() == QInternal::Pixmap) {
+ const QPixmap *pm = static_cast<const QPixmap *>(pdev);
+ QX11PixmapData *data = static_cast<QX11PixmapData*>(pm->data.data());
+ if (X11->use_xrender && data->depth() != 32 && data->x11_mask)
+ data->convertToARGB32();
+ d->picture = (::Picture)static_cast<const QPixmap *>(pdev)->x11PictureHandle();
+ }
+#else
+ d->picture = 0;
+#endif
+ d->hd = !isAlienWidget ? qt_x11Handle(pdev) : qt_x11Handle(w->nativeParentWidget());
+
+ Q_ASSERT(d->xinfo != 0);
+ d->dpy = d->xinfo->display(); // get display variable
+ d->scrn = d->xinfo->screen(); // get screen variable
+
+ d->crgn = QRegion();
+ d->gc = XCreateGC(d->dpy, d->hd, 0, 0);
+ d->gc_brush = XCreateGC(d->dpy, d->hd, 0, 0);
+ d->has_alpha_brush = false;
+ d->has_alpha_pen = false;
+ d->has_clipping = false;
+ d->has_complex_xform = false;
+ d->has_scaling_xform = false;
+ d->has_non_scaling_xform = true;
+ d->xform_scale = 1;
+ d->has_custom_pen = false;
+ d->matrix = QTransform();
+ d->pdev_depth = d->pdev->depth();
+ d->render_hints = 0;
+ d->txop = QTransform::TxNone;
+ d->use_path_fallback = false;
+#if !defined(QT_NO_XRENDER)
+ d->composition_mode = PictOpOver;
+#endif
+ d->xlibMaxLinePoints = 32762; // a safe number used to avoid, call to XMaxRequestSize(d->dpy) - 3;
+ d->opacity = 1;
+
+ // Set up the polygon clipper. Note: This will only work in
+ // polyline mode as long as we have a buffer zone, since a
+ // polyline may be clipped into several non-connected polylines.
+ const int BUFFERZONE = 1000;
+ QRect devClipRect(-BUFFERZONE, -BUFFERZONE,
+ pdev->width() + 2*BUFFERZONE, pdev->height() + 2*BUFFERZONE);
+ d->polygonClipper.setBoundingRect(devClipRect);
+
+ if (isAlienWidget) {
+ // Set system clip for alien widgets painting outside the paint event.
+ // This is not a problem with native windows since the windowing system
+ // will handle the clip.
+ QWidgetPrivate *wd = w->d_func();
+ QRegion widgetClip(wd->clipRect());
+ wd->clipToEffectiveMask(widgetClip);
+ wd->subtractOpaqueSiblings(widgetClip);
+ widgetClip.translate(w->mapTo(w->nativeParentWidget(), QPoint()));
+ setSystemClip(widgetClip);
+ }
+
+ QPixmap::x11SetDefaultScreen(d->xinfo->screen());
+
+ if (w && w->testAttribute(Qt::WA_PaintUnclipped)) { // paint direct on device
+ updatePen(QPen(Qt::black));
+ updateBrush(QBrush(Qt::white), QPoint());
+ XSetSubwindowMode(d->dpy, d->gc, IncludeInferiors);
+ XSetSubwindowMode(d->dpy, d->gc_brush, IncludeInferiors);
+#ifndef QT_NO_XRENDER
+ XRenderPictureAttributes attrs;
+ attrs.subwindow_mode = IncludeInferiors;
+ XRenderChangePicture(d->dpy, d->picture, CPSubwindowMode, &attrs);
+#endif
+ }
+
+ setDirty(QPaintEngine::DirtyClipRegion);
+ setDirty(QPaintEngine::DirtyPen);
+ setDirty(QPaintEngine::DirtyBrush);
+ setDirty(QPaintEngine::DirtyBackground);
+
+ return true;
+}
+
+bool QX11PaintEngine::end()
+{
+ Q_D(QX11PaintEngine);
+
+#if !defined(QT_NO_XRENDER)
+ if (d->picture) {
+ // reset clipping/subwindow mode on our render picture
+ XRenderPictureAttributes attrs;
+ attrs.subwindow_mode = ClipByChildren;
+ attrs.clip_mask = XNone;
+ XRenderChangePicture(d->dpy, d->picture, CPClipMask|CPSubwindowMode, &attrs);
+ }
+#endif
+
+ if (d->gc_brush && d->pdev->painters < 2) {
+ XFreeGC(d->dpy, d->gc_brush);
+ d->gc_brush = 0;
+ }
+
+ if (d->gc && d->pdev->painters < 2) {
+ XFreeGC(d->dpy, d->gc);
+ d->gc = 0;
+ }
+
+ // Restore system clip for alien widgets painting outside the paint event.
+ if (d->pdev->devType() == QInternal::Widget && !static_cast<QWidget *>(d->pdev)->internalWinId())
+ setSystemClip(QRegion());
+
+ return true;
+}
+
+static bool clipLine(QLineF *line, const QRect &rect)
+{
+ qreal x1 = line->x1();
+ qreal x2 = line->x2();
+ qreal y1 = line->y1();
+ qreal y2 = line->y2();
+
+ qreal left = rect.x();
+ qreal right = rect.x() + rect.width() - 1;
+ qreal top = rect.y();
+ qreal bottom = rect.y() + rect.height() - 1;
+
+ enum { Left, Right, Top, Bottom };
+ // clip the lines, after cohen-sutherland, see e.g. http://www.nondot.org/~sabre/graphpro/line6.html
+ int p1 = ((x1 < left) << Left)
+ | ((x1 > right) << Right)
+ | ((y1 < top) << Top)
+ | ((y1 > bottom) << Bottom);
+ int p2 = ((x2 < left) << Left)
+ | ((x2 > right) << Right)
+ | ((y2 < top) << Top)
+ | ((y2 > bottom) << Bottom);
+
+ if (p1 & p2)
+ // completely outside
+ return false;
+
+ if (p1 | p2) {
+ qreal dx = x2 - x1;
+ qreal dy = y2 - y1;
+
+ // clip x coordinates
+ if (x1 < left) {
+ y1 += dy/dx * (left - x1);
+ x1 = left;
+ } else if (x1 > right) {
+ y1 -= dy/dx * (x1 - right);
+ x1 = right;
+ }
+ if (x2 < left) {
+ y2 += dy/dx * (left - x2);
+ x2 = left;
+ } else if (x2 > right) {
+ y2 -= dy/dx * (x2 - right);
+ x2 = right;
+ }
+ p1 = ((y1 < top) << Top)
+ | ((y1 > bottom) << Bottom);
+ p2 = ((y2 < top) << Top)
+ | ((y2 > bottom) << Bottom);
+ if (p1 & p2)
+ return false;
+ // clip y coordinates
+ if (y1 < top) {
+ x1 += dx/dy * (top - y1);
+ y1 = top;
+ } else if (y1 > bottom) {
+ x1 -= dx/dy * (y1 - bottom);
+ y1 = bottom;
+ }
+ if (y2 < top) {
+ x2 += dx/dy * (top - y2);
+ y2 = top;
+ } else if (y2 > bottom) {
+ x2 -= dx/dy * (y2 - bottom);
+ y2 = bottom;
+ }
+ *line = QLineF(QPointF(x1, y1), QPointF(x2, y2));
+ }
+ return true;
+}
+
+void QX11PaintEngine::drawLines(const QLine *lines, int lineCount)
+{
+ Q_ASSERT(lines);
+ Q_ASSERT(lineCount);
+ Q_D(QX11PaintEngine);
+ if (d->has_alpha_brush
+ || d->has_alpha_pen
+ || d->has_custom_pen
+ || (d->cpen.widthF() > 0 && d->has_complex_xform
+ && !d->has_non_scaling_xform)
+ || (d->render_hints & QPainter::Antialiasing)) {
+ for (int i = 0; i < lineCount; ++i) {
+ QPainterPath path(lines[i].p1());
+ path.lineTo(lines[i].p2());
+ drawPath(path);
+ }
+ return;
+ }
+
+ if (d->has_pen) {
+ for (int i = 0; i < lineCount; ++i) {
+ QLineF linef;
+ if (d->txop == QTransform::TxNone) {
+ linef = lines[i];
+ } else {
+ linef = d->matrix.map(QLineF(lines[i]));
+ }
+ if (clipLine(&linef, d->polygonClipper.boundingRect())) {
+ int x1 = qRound(linef.x1() + aliasedCoordinateDelta);
+ int y1 = qRound(linef.y1() + aliasedCoordinateDelta);
+ int x2 = qRound(linef.x2() + aliasedCoordinateDelta);
+ int y2 = qRound(linef.y2() + aliasedCoordinateDelta);
+
+ XDrawLine(d->dpy, d->hd, d->gc, x1, y1, x2, y2);
+ }
+ }
+ }
+}
+
+void QX11PaintEngine::drawLines(const QLineF *lines, int lineCount)
+{
+ Q_ASSERT(lines);
+ Q_ASSERT(lineCount);
+ Q_D(QX11PaintEngine);
+ if (d->has_alpha_brush
+ || d->has_alpha_pen
+ || d->has_custom_pen
+ || (d->cpen.widthF() > 0 && d->has_complex_xform
+ && !d->has_non_scaling_xform)
+ || (d->render_hints & QPainter::Antialiasing)) {
+ for (int i = 0; i < lineCount; ++i) {
+ QPainterPath path(lines[i].p1());
+ path.lineTo(lines[i].p2());
+ drawPath(path);
+ }
+ return;
+ }
+
+ if (d->has_pen) {
+ for (int i = 0; i < lineCount; ++i) {
+ QLineF linef = d->matrix.map(lines[i]);
+ if (clipLine(&linef, d->polygonClipper.boundingRect())) {
+ int x1 = qRound(linef.x1() + aliasedCoordinateDelta);
+ int y1 = qRound(linef.y1() + aliasedCoordinateDelta);
+ int x2 = qRound(linef.x2() + aliasedCoordinateDelta);
+ int y2 = qRound(linef.y2() + aliasedCoordinateDelta);
+
+ XDrawLine(d->dpy, d->hd, d->gc, x1, y1, x2, y2);
+ }
+ }
+ }
+}
+
+static inline QLine clipStraightLine(const QRect &clip, const QLine &l)
+{
+ if (l.p1().x() == l.p2().x()) {
+ int x = qBound(clip.left(), l.p1().x(), clip.right());
+ int y1 = qBound(clip.top(), l.p1().y(), clip.bottom());
+ int y2 = qBound(clip.top(), l.p2().y(), clip.bottom());
+
+ return QLine(x, y1, x, y2);
+ } else {
+ Q_ASSERT(l.p1().y() == l.p2().y());
+
+ int x1 = qBound(clip.left(), l.p1().x(), clip.right());
+ int x2 = qBound(clip.left(), l.p2().x(), clip.right());
+ int y = qBound(clip.top(), l.p1().y(), clip.bottom());
+
+ return QLine(x1, y, x2, y);
+ }
+}
+
+void QX11PaintEngine::drawRects(const QRectF *rects, int rectCount)
+{
+ Q_D(QX11PaintEngine);
+ Q_ASSERT(rects);
+ Q_ASSERT(rectCount);
+
+ if (rectCount != 1
+ || d->has_pen
+ || d->has_alpha_brush
+ || d->has_complex_xform
+ || d->has_custom_pen
+ || d->cbrush.style() != Qt::SolidPattern)
+ {
+ QPaintEngine::drawRects(rects, rectCount);
+ return;
+ }
+
+ QPoint alignedOffset;
+ if (d->txop == QTransform::TxTranslate) {
+ QPointF offset(d->matrix.dx(), d->matrix.dy());
+ alignedOffset = offset.toPoint();
+ if (offset != QPointF(alignedOffset)) {
+ QPaintEngine::drawRects(rects, rectCount);
+ return;
+ }
+ }
+
+ const QRectF& r = rects[0];
+ QRect alignedRect = r.toAlignedRect();
+ if (r != QRectF(alignedRect)) {
+ QPaintEngine::drawRects(rects, rectCount);
+ return;
+ }
+ alignedRect.translate(alignedOffset);
+
+ QRect clip(d->polygonClipper.boundingRect());
+ alignedRect = alignedRect.intersected(clip);
+ if (alignedRect.isEmpty())
+ return;
+
+ // simple-case:
+ // the rectangle is pixel-aligned
+ // the fill brush is just a solid non-alpha color
+ // the painter transform is only integer translation
+ // ignore: antialiasing and just XFillRectangles directly
+ XRectangle xrect;
+ xrect.x = short(alignedRect.x());
+ xrect.y = short(alignedRect.y());
+ xrect.width = ushort(alignedRect.width());
+ xrect.height = ushort(alignedRect.height());
+ XFillRectangles(d->dpy, d->hd, d->gc_brush, &xrect, 1);
+}
+
+void QX11PaintEngine::drawRects(const QRect *rects, int rectCount)
+{
+ Q_D(QX11PaintEngine);
+ Q_ASSERT(rects);
+ Q_ASSERT(rectCount);
+
+ if (d->has_alpha_pen
+ || d->has_complex_xform
+ || d->has_custom_pen
+ || (d->render_hints & QPainter::Antialiasing))
+ {
+ for (int i = 0; i < rectCount; ++i) {
+ QPainterPath path;
+ path.addRect(rects[i]);
+ drawPath(path);
+ }
+ return;
+ }
+
+ QRect clip(d->polygonClipper.boundingRect());
+ QPoint offset(qRound(d->matrix.dx()), qRound(d->matrix.dy()));
+#if !defined(QT_NO_XRENDER)
+ ::Picture pict = d->picture;
+
+ if (X11->use_xrender && pict && d->has_brush && d->pdev_depth != 1
+ && (d->has_texture || d->has_alpha_brush))
+ {
+ XRenderColor xc;
+ if (!d->has_texture && !d->has_pattern)
+ xc = X11->preMultiply(d->cbrush.color());
+
+ for (int i = 0; i < rectCount; ++i) {
+ QRect r(rects[i]);
+ if (d->txop == QTransform::TxTranslate)
+ r.translate(offset);
+
+ if (r.width() == 0 || r.height() == 0) {
+ if (d->has_pen) {
+ const QLine l = clipStraightLine(clip, QLine(r.left(), r.top(), r.left() + r.width(), r.top() + r.height()));
+ XDrawLine(d->dpy, d->hd, d->gc, l.p1().x(), l.p1().y(), l.p2().x(), l.p2().y());
+ }
+ continue;
+ }
+
+ r = r.intersected(clip);
+ if (r.isEmpty())
+ continue;
+ if (d->has_texture || d->has_pattern) {
+ XRenderComposite(d->dpy, d->composition_mode, d->current_brush, 0, pict,
+ qRound(r.x() - d->bg_origin.x()), qRound(r.y() - d->bg_origin.y()),
+ 0, 0, r.x(), r.y(), r.width(), r.height());
+ } else {
+ XRenderFillRectangle(d->dpy, d->composition_mode, pict, &xc, r.x(), r.y(), r.width(), r.height());
+ }
+ if (d->has_pen)
+ XDrawRectangle(d->dpy, d->hd, d->gc, r.x(), r.y(), r.width(), r.height());
+ }
+ } else
+#endif // !QT_NO_XRENDER
+ {
+ if (d->has_brush && d->has_pen) {
+ for (int i = 0; i < rectCount; ++i) {
+ QRect r(rects[i]);
+ if (d->txop == QTransform::TxTranslate)
+ r.translate(offset);
+
+ if (r.width() == 0 || r.height() == 0) {
+ const QLine l = clipStraightLine(clip, QLine(r.left(), r.top(), r.left() + r.width(), r.top() + r.height()));
+ XDrawLine(d->dpy, d->hd, d->gc, l.p1().x(), l.p1().y(), l.p2().x(), l.p2().y());
+ continue;
+ }
+
+ r = r.intersected(clip);
+ if (r.isEmpty())
+ continue;
+ d->setupAdaptedOrigin(r.topLeft());
+ XFillRectangle(d->dpy, d->hd, d->gc_brush, r.x(), r.y(), r.width(), r.height());
+ XDrawRectangle(d->dpy, d->hd, d->gc, r.x(), r.y(), r.width(), r.height());
+ }
+ d->resetAdaptedOrigin();
+ } else {
+ QVarLengthArray<XRectangle> xrects(rectCount);
+ int numClipped = rectCount;
+ for (int i = 0; i < rectCount; ++i) {
+ QRect r(rects[i]);
+ if (d->txop == QTransform::TxTranslate)
+ r.translate(offset);
+
+ if (r.width() == 0 || r.height() == 0) {
+ --numClipped;
+ if (d->has_pen) {
+ const QLine l = clipStraightLine(clip, QLine(r.left(), r.top(), r.left() + r.width(), r.top() + r.height()));
+ XDrawLine(d->dpy, d->hd, d->gc, l.p1().x(), l.p1().y(), l.p2().x(), l.p2().y());
+ }
+ continue;
+ }
+
+ r = r.intersected(clip);
+ if (r.isEmpty()) {
+ --numClipped;
+ continue;
+ }
+ xrects[i].x = short(r.x());
+ xrects[i].y = short(r.y());
+ xrects[i].width = ushort(r.width());
+ xrects[i].height = ushort(r.height());
+ }
+ if (numClipped) {
+ d->setupAdaptedOrigin(rects[0].topLeft());
+ if (d->has_brush)
+ XFillRectangles(d->dpy, d->hd, d->gc_brush, xrects.data(), numClipped);
+ else if (d->has_pen)
+ XDrawRectangles(d->dpy, d->hd, d->gc, xrects.data(), numClipped);
+ d->resetAdaptedOrigin();
+ }
+ }
+ }
+}
+
+static inline void setCapStyle(int cap_style, GC gc)
+{
+ ulong mask = GCCapStyle;
+ XGCValues vals;
+ vals.cap_style = cap_style;
+ XChangeGC(X11->display, gc, mask, &vals);
+}
+
+void QX11PaintEngine::drawPoints(const QPoint *points, int pointCount)
+{
+ Q_ASSERT(points);
+ Q_ASSERT(pointCount);
+ Q_D(QX11PaintEngine);
+
+ if (!d->has_pen)
+ return;
+
+ // use the same test here as in drawPath to ensure that we don't use the path fallback
+ // and end up in XDrawLines for pens with width <= 1
+ if (d->cpen.widthF() > 1.0f
+ || (X11->use_xrender && (d->has_alpha_pen || (d->render_hints & QPainter::Antialiasing)))
+ || (!d->cpen.isCosmetic() && d->txop > QTransform::TxTranslate))
+ {
+ Qt::PenCapStyle capStyle = d->cpen.capStyle();
+ if (capStyle == Qt::FlatCap) {
+ setCapStyle(CapProjecting, d->gc);
+ d->cpen.setCapStyle(Qt::SquareCap);
+ }
+ const QPoint *end = points + pointCount;
+ while (points < end) {
+ QPainterPath path;
+ path.moveTo(*points);
+ path.lineTo(points->x()+.005, points->y());
+ drawPath(path);
+ ++points;
+ }
+
+ if (capStyle == Qt::FlatCap) {
+ setCapStyle(CapButt, d->gc);
+ d->cpen.setCapStyle(capStyle);
+ }
+ return;
+ }
+
+ static const int BUF_SIZE = 1024;
+ XPoint xPoints[BUF_SIZE];
+ int i = 0, j = 0;
+ while (i < pointCount) {
+ while (i < pointCount && j < BUF_SIZE) {
+ const QPoint &xformed = d->matrix.map(points[i]);
+ int x = xformed.x();
+ int y = xformed.y();
+ if (x >= SHRT_MIN && y >= SHRT_MIN && x < SHRT_MAX && y < SHRT_MAX) {
+ xPoints[j].x = x;
+ xPoints[j].y = y;
+ ++j;
+ }
+ ++i;
+ }
+ if (j)
+ XDrawPoints(d->dpy, d->hd, d->gc, xPoints, j, CoordModeOrigin);
+
+ j = 0;
+ }
+}
+
+void QX11PaintEngine::drawPoints(const QPointF *points, int pointCount)
+{
+ Q_ASSERT(points);
+ Q_ASSERT(pointCount);
+ Q_D(QX11PaintEngine);
+
+ if (!d->has_pen)
+ return;
+
+ // use the same test here as in drawPath to ensure that we don't use the path fallback
+ // and end up in XDrawLines for pens with width <= 1
+ if (d->cpen.widthF() > 1.0f
+ || (X11->use_xrender && (d->has_alpha_pen || (d->render_hints & QPainter::Antialiasing)))
+ || (!d->cpen.isCosmetic() && d->txop > QTransform::TxTranslate))
+ {
+ Qt::PenCapStyle capStyle = d->cpen.capStyle();
+ if (capStyle == Qt::FlatCap) {
+ setCapStyle(CapProjecting, d->gc);
+ d->cpen.setCapStyle(Qt::SquareCap);
+ }
+
+ const QPointF *end = points + pointCount;
+ while (points < end) {
+ QPainterPath path;
+ path.moveTo(*points);
+ path.lineTo(points->x() + 0.005, points->y());
+ drawPath(path);
+ ++points;
+ }
+ if (capStyle == Qt::FlatCap) {
+ setCapStyle(CapButt, d->gc);
+ d->cpen.setCapStyle(capStyle);
+ }
+ return;
+ }
+
+ static const int BUF_SIZE = 1024;
+ XPoint xPoints[BUF_SIZE];
+ int i = 0, j = 0;
+ while (i < pointCount) {
+ while (i < pointCount && j < BUF_SIZE) {
+ const QPointF &xformed = d->matrix.map(points[i]);
+ int x = qFloor(xformed.x());
+ int y = qFloor(xformed.y());
+
+ if (x >= SHRT_MIN && y >= SHRT_MIN && x < SHRT_MAX && y < SHRT_MAX) {
+ xPoints[j].x = x;
+ xPoints[j].y = y;
+ ++j;
+ }
+ ++i;
+ }
+ if (j)
+ XDrawPoints(d->dpy, d->hd, d->gc, xPoints, j, CoordModeOrigin);
+
+ j = 0;
+ }
+}
+
+QPainter::RenderHints QX11PaintEngine::supportedRenderHints() const
+{
+#if !defined(QT_NO_XRENDER)
+ if (X11->use_xrender)
+ return QPainter::Antialiasing;
+#endif
+ return QFlag(0);
+}
+
+void QX11PaintEngine::updateState(const QPaintEngineState &state)
+{
+ Q_D(QX11PaintEngine);
+ QPaintEngine::DirtyFlags flags = state.state();
+
+
+ if (flags & DirtyOpacity) {
+ d->opacity = state.opacity();
+ // Force update pen/brush as to get proper alpha colors propagated
+ flags |= DirtyPen;
+ flags |= DirtyBrush;
+ }
+
+ if (flags & DirtyTransform) updateMatrix(state.transform());
+ if (flags & DirtyPen) updatePen(state.pen());
+ if (flags & (DirtyBrush | DirtyBrushOrigin)) updateBrush(state.brush(), state.brushOrigin());
+ if (flags & DirtyFont) updateFont(state.font());
+
+ if (state.state() & DirtyClipEnabled) {
+ if (state.isClipEnabled()) {
+ QPolygonF clip_poly_dev(d->matrix.map(painter()->clipPath().toFillPolygon()));
+ QPolygonF clipped_poly_dev;
+ d->clipPolygon_dev(clip_poly_dev, &clipped_poly_dev);
+ updateClipRegion_dev(QRegion(clipped_poly_dev.toPolygon()), Qt::ReplaceClip);
+ } else {
+ updateClipRegion_dev(QRegion(), Qt::NoClip);
+ }
+ }
+
+ if (flags & DirtyClipPath) {
+ QPolygonF clip_poly_dev(d->matrix.map(state.clipPath().toFillPolygon()));
+ QPolygonF clipped_poly_dev;
+ d->clipPolygon_dev(clip_poly_dev, &clipped_poly_dev);
+ updateClipRegion_dev(QRegion(clipped_poly_dev.toPolygon(), state.clipPath().fillRule()),
+ state.clipOperation());
+ } else if (flags & DirtyClipRegion) {
+ extern QPainterPath qt_regionToPath(const QRegion &region);
+ QPainterPath clip_path = qt_regionToPath(state.clipRegion());
+ QPolygonF clip_poly_dev(d->matrix.map(clip_path.toFillPolygon()));
+ QPolygonF clipped_poly_dev;
+ d->clipPolygon_dev(clip_poly_dev, &clipped_poly_dev);
+ updateClipRegion_dev(QRegion(clipped_poly_dev.toPolygon()), state.clipOperation());
+ }
+ if (flags & DirtyHints) updateRenderHints(state.renderHints());
+ if (flags & DirtyCompositionMode) {
+ int function = GXcopy;
+ if (state.compositionMode() >= QPainter::RasterOp_SourceOrDestination) {
+ switch (state.compositionMode()) {
+ case QPainter::RasterOp_SourceOrDestination:
+ function = GXor;
+ break;
+ case QPainter::RasterOp_SourceAndDestination:
+ function = GXand;
+ break;
+ case QPainter::RasterOp_SourceXorDestination:
+ function = GXxor;
+ break;
+ case QPainter::RasterOp_NotSourceAndNotDestination:
+ function = GXnor;
+ break;
+ case QPainter::RasterOp_NotSourceOrNotDestination:
+ function = GXnand;
+ break;
+ case QPainter::RasterOp_NotSourceXorDestination:
+ function = GXequiv;
+ break;
+ case QPainter::RasterOp_NotSource:
+ function = GXcopyInverted;
+ break;
+ case QPainter::RasterOp_SourceAndNotDestination:
+ function = GXandReverse;
+ break;
+ case QPainter::RasterOp_NotSourceAndDestination:
+ function = GXandInverted;
+ break;
+ default:
+ function = GXcopy;
+ }
+ }
+#if !defined(QT_NO_XRENDER)
+ else {
+ d->composition_mode =
+ qpainterOpToXrender(state.compositionMode());
+ }
+#endif
+ XSetFunction(X11->display, d->gc, function);
+ XSetFunction(X11->display, d->gc_brush, function);
+ }
+ d->decidePathFallback();
+ d->decideCoordAdjust();
+}
+
+void QX11PaintEngine::updateRenderHints(QPainter::RenderHints hints)
+{
+ Q_D(QX11PaintEngine);
+ d->render_hints = hints;
+
+#if !defined(QT_NO_XRENDER)
+ if (X11->use_xrender && d->picture) {
+ XRenderPictureAttributes attrs;
+ attrs.poly_edge = (hints & QPainter::Antialiasing) ? PolyEdgeSmooth : PolyEdgeSharp;
+ XRenderChangePicture(d->dpy, d->picture, CPPolyEdge, &attrs);
+ }
+#endif
+}
+
+void QX11PaintEngine::updatePen(const QPen &pen)
+{
+ Q_D(QX11PaintEngine);
+ d->cpen = pen;
+ int cp = CapButt;
+ int jn = JoinMiter;
+ int ps = pen.style();
+
+ if (d->opacity < 1.0) {
+ QColor c = d->cpen.color();
+ c.setAlpha(qRound(c.alpha()*d->opacity));
+ d->cpen.setColor(c);
+ }
+
+ d->has_pen = (ps != Qt::NoPen);
+ d->has_alpha_pen = (pen.color().alpha() != 255);
+
+ switch (pen.capStyle()) {
+ case Qt::SquareCap:
+ cp = CapProjecting;
+ break;
+ case Qt::RoundCap:
+ cp = CapRound;
+ break;
+ case Qt::FlatCap:
+ default:
+ cp = CapButt;
+ break;
+ }
+ switch (pen.joinStyle()) {
+ case Qt::BevelJoin:
+ jn = JoinBevel;
+ break;
+ case Qt::RoundJoin:
+ jn = JoinRound;
+ break;
+ case Qt::MiterJoin:
+ default:
+ jn = JoinMiter;
+ break;
+ }
+
+ d->adapted_pen_origin = false;
+
+ char dashes[10]; // custom pen dashes
+ int dash_len = 0; // length of dash list
+ int xStyle = LineSolid;
+
+ /*
+ We are emulating Windows here. Windows treats cpen.width() == 1
+ (or 0) as a very special case. The fudge variable unifies this
+ case with the general case.
+ */
+ qreal pen_width = pen.widthF();
+ int scale = qRound(pen_width < 1 ? 1 : pen_width);
+ int space = (pen_width < 1 && pen_width > 0 ? 1 : (2 * scale));
+ int dot = 1 * scale;
+ int dash = 4 * scale;
+
+ d->has_custom_pen = false;
+
+ switch (ps) {
+ case Qt::NoPen:
+ case Qt::SolidLine:
+ xStyle = LineSolid;
+ break;
+ case Qt::DashLine:
+ dashes[0] = dash;
+ dashes[1] = space;
+ dash_len = 2;
+ xStyle = LineOnOffDash;
+ break;
+ case Qt::DotLine:
+ dashes[0] = dot;
+ dashes[1] = space;
+ dash_len = 2;
+ xStyle = LineOnOffDash;
+ break;
+ case Qt::DashDotLine:
+ dashes[0] = dash;
+ dashes[1] = space;
+ dashes[2] = dot;
+ dashes[3] = space;
+ dash_len = 4;
+ xStyle = LineOnOffDash;
+ break;
+ case Qt::DashDotDotLine:
+ dashes[0] = dash;
+ dashes[1] = space;
+ dashes[2] = dot;
+ dashes[3] = space;
+ dashes[4] = dot;
+ dashes[5] = space;
+ dash_len = 6;
+ xStyle = LineOnOffDash;
+ break;
+ case Qt::CustomDashLine:
+ d->has_custom_pen = true;
+ break;
+ }
+
+ ulong mask = GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth
+ | GCCapStyle | GCJoinStyle | GCLineStyle;
+ XGCValues vals;
+ vals.graphics_exposures = false;
+ if (d->pdev_depth == 1) {
+ vals.foreground = qGray(pen.color().rgb()) > 127 ? 0 : 1;
+ vals.background = qGray(QColor(Qt::transparent).rgb()) > 127 ? 0 : 1;
+ } else if (d->pdev->devType() == QInternal::Pixmap && d->pdev_depth == 32
+ && X11->use_xrender) {
+ vals.foreground = pen.color().rgba();
+ vals.background = QColor(Qt::transparent).rgba();
+ } else {
+ QColormap cmap = QColormap::instance(d->scrn);
+ vals.foreground = cmap.pixel(pen.color());
+ vals.background = cmap.pixel(QColor(Qt::transparent));
+ }
+
+
+ vals.line_width = qRound(pen.widthF());
+ vals.cap_style = cp;
+ vals.join_style = jn;
+ vals.line_style = xStyle;
+
+ XChangeGC(d->dpy, d->gc, mask, &vals);
+
+ if (dash_len) { // make dash list
+ XSetDashes(d->dpy, d->gc, 0, dashes, dash_len);
+ }
+
+ if (!d->has_clipping) { // if clipping is set the paintevent clip region is merged with the clip region
+ QRegion sysClip = systemClip();
+ if (!sysClip.isEmpty())
+ x11SetClipRegion(d->dpy, d->gc, 0, d->picture, sysClip);
+ else
+ x11ClearClipRegion(d->dpy, d->gc, 0, d->picture);
+ }
+}
+
+void QX11PaintEngine::updateBrush(const QBrush &brush, const QPointF &origin)
+{
+ Q_D(QX11PaintEngine);
+ d->cbrush = brush;
+ d->bg_origin = origin;
+ d->adapted_brush_origin = false;
+#if !defined(QT_NO_XRENDER)
+ d->current_brush = 0;
+#endif
+ if (d->opacity < 1.0) {
+ QColor c = d->cbrush.color();
+ c.setAlpha(qRound(c.alpha()*d->opacity));
+ d->cbrush.setColor(c);
+ }
+
+ int s = FillSolid;
+ int bs = d->cbrush.style();
+ d->has_brush = (bs != Qt::NoBrush);
+ d->has_pattern = bs >= Qt::Dense1Pattern && bs <= Qt::DiagCrossPattern;
+ d->has_texture = bs == Qt::TexturePattern;
+ d->has_alpha_brush = brush.color().alpha() != 255;
+ d->has_alpha_texture = d->has_texture && d->cbrush.texture().hasAlphaChannel();
+
+ ulong mask = GCForeground | GCBackground | GCGraphicsExposures
+ | GCLineStyle | GCCapStyle | GCJoinStyle | GCFillStyle;
+ XGCValues vals;
+ vals.graphics_exposures = false;
+ if (d->pdev_depth == 1) {
+ vals.foreground = qGray(d->cbrush.color().rgb()) > 127 ? 0 : 1;
+ vals.background = qGray(QColor(Qt::transparent).rgb()) > 127 ? 0 : 1;
+ } else if (X11->use_xrender && d->pdev->devType() == QInternal::Pixmap
+ && d->pdev_depth == 32) {
+ vals.foreground = d->cbrush.color().rgba();
+ vals.background = QColor(Qt::transparent).rgba();
+ } else {
+ QColormap cmap = QColormap::instance(d->scrn);
+ vals.foreground = cmap.pixel(d->cbrush.color());
+ vals.background = cmap.pixel(QColor(Qt::transparent));
+
+ if (!X11->use_xrender && d->has_brush && !d->has_pattern && !brush.isOpaque()) {
+ QPixmap pattern = qt_patternForAlpha(brush.color().alpha(), d->scrn);
+ mask |= GCStipple;
+ vals.stipple = pattern.handle();
+ s = FillStippled;
+ d->adapted_brush_origin = true;
+ }
+ }
+ vals.cap_style = CapButt;
+ vals.join_style = JoinMiter;
+ vals.line_style = LineSolid;
+
+ if (d->has_pattern || d->has_texture) {
+ if (bs == Qt::TexturePattern) {
+ d->brush_pm = qt_toX11Pixmap(d->cbrush.texture());
+#if !defined(QT_NO_XRENDER)
+ if (X11->use_xrender) {
+ XRenderPictureAttributes attrs;
+ attrs.repeat = true;
+ XRenderChangePicture(d->dpy, d->brush_pm.x11PictureHandle(), CPRepeat, &attrs);
+ QX11PixmapData *data = static_cast<QX11PixmapData*>(d->brush_pm.data.data());
+ if (data->mask_picture)
+ XRenderChangePicture(d->dpy, data->mask_picture, CPRepeat, &attrs);
+ }
+#endif
+ } else {
+ d->brush_pm = qt_toX11Pixmap(qt_pixmapForBrush(bs, true));
+ }
+ d->brush_pm.x11SetScreen(d->scrn);
+ if (d->brush_pm.depth() == 1) {
+ mask |= GCStipple;
+ vals.stipple = d->brush_pm.handle();
+ s = FillStippled;
+#if !defined(QT_NO_XRENDER)
+ if (X11->use_xrender) {
+ d->bitmap_texture = QPixmap(d->brush_pm.size());
+ d->bitmap_texture.fill(Qt::transparent);
+ d->bitmap_texture = qt_toX11Pixmap(d->bitmap_texture);
+ d->bitmap_texture.x11SetScreen(d->scrn);
+
+ ::Picture src = X11->getSolidFill(d->scrn, d->cbrush.color());
+ XRenderComposite(d->dpy, PictOpSrc, src, d->brush_pm.x11PictureHandle(),
+ d->bitmap_texture.x11PictureHandle(),
+ 0, 0, d->brush_pm.width(), d->brush_pm.height(),
+ 0, 0, d->brush_pm.width(), d->brush_pm.height());
+
+ XRenderPictureAttributes attrs;
+ attrs.repeat = true;
+ XRenderChangePicture(d->dpy, d->bitmap_texture.x11PictureHandle(), CPRepeat, &attrs);
+
+ d->current_brush = d->bitmap_texture.x11PictureHandle();
+ }
+#endif
+ } else {
+ mask |= GCTile;
+#ifndef QT_NO_XRENDER
+ if (d->pdev_depth == 32 && d->brush_pm.depth() != 32) {
+ d->brush_pm.detach();
+ QX11PixmapData *brushData = static_cast<QX11PixmapData*>(d->brush_pm.data.data());
+ brushData->convertToARGB32();
+ }
+#endif
+ vals.tile = (d->brush_pm.depth() == d->pdev_depth
+ ? d->brush_pm.handle()
+ : static_cast<QX11PixmapData*>(d->brush_pm.data.data())->x11ConvertToDefaultDepth());
+ s = FillTiled;
+#if !defined(QT_NO_XRENDER)
+ d->current_brush = d->cbrush.texture().x11PictureHandle();
+#endif
+ }
+
+ mask |= GCTileStipXOrigin | GCTileStipYOrigin;
+ vals.ts_x_origin = qRound(origin.x());
+ vals.ts_y_origin = qRound(origin.y());
+ }
+#if !defined(QT_NO_XRENDER)
+ else if (d->has_alpha_brush) {
+ d->current_brush = X11->getSolidFill(d->scrn, d->cbrush.color());
+ }
+#endif
+
+ vals.fill_style = s;
+ XChangeGC(d->dpy, d->gc_brush, mask, &vals);
+ if (!d->has_clipping) {
+ QRegion sysClip = systemClip();
+ if (!sysClip.isEmpty())
+ x11SetClipRegion(d->dpy, d->gc_brush, 0, d->picture, sysClip);
+ else
+ x11ClearClipRegion(d->dpy, d->gc_brush, 0, d->picture);
+ }
+}
+
+void QX11PaintEngine::drawEllipse(const QRectF &rect)
+{
+ QRect aligned = rect.toAlignedRect();
+ if (aligned == rect)
+ drawEllipse(aligned);
+ else
+ QPaintEngine::drawEllipse(rect);
+}
+
+void QX11PaintEngine::drawEllipse(const QRect &rect)
+{
+ if (rect.isEmpty()) {
+ drawRects(&rect, 1);
+ return;
+ }
+
+ Q_D(QX11PaintEngine);
+ QRect devclip(SHRT_MIN, SHRT_MIN, SHRT_MAX*2 - 1, SHRT_MAX*2 - 1);
+ QRect r(rect);
+ if (d->txop < QTransform::TxRotate) {
+ r = d->matrix.mapRect(rect);
+ } else if (d->txop == QTransform::TxRotate && rect.width() == rect.height()) {
+ QPainterPath path;
+ path.addEllipse(rect);
+ r = d->matrix.map(path).boundingRect().toRect();
+ }
+
+ if (d->has_alpha_brush || d->has_alpha_pen || d->has_custom_pen || (d->render_hints & QPainter::Antialiasing)
+ || d->has_alpha_texture || devclip.intersected(r) != r
+ || (d->has_complex_xform
+ && !(d->has_non_scaling_xform && rect.width() == rect.height())))
+ {
+ QPainterPath path;
+ path.addEllipse(rect);
+ drawPath(path);
+ return;
+ }
+
+ int x = r.x();
+ int y = r.y();
+ int w = r.width();
+ int h = r.height();
+ if (w < 1 || h < 1)
+ return;
+ if (w == 1 && h == 1) {
+ XDrawPoint(d->dpy, d->hd, d->has_pen ? d->gc : d->gc_brush, x, y);
+ return;
+ }
+ d->setupAdaptedOrigin(rect.topLeft());
+ if (d->has_brush) { // draw filled ellipse
+ XFillArc(d->dpy, d->hd, d->gc_brush, x, y, w, h, 0, 360*64);
+ if (!d->has_pen) // make smoother outline
+ XDrawArc(d->dpy, d->hd, d->gc_brush, x, y, w-1, h-1, 0, 360*64);
+ }
+ if (d->has_pen) // draw outline
+ XDrawArc(d->dpy, d->hd, d->gc, x, y, w, h, 0, 360*64);
+ d->resetAdaptedOrigin();
+}
+
+
+
+void QX11PaintEnginePrivate::fillPolygon_translated(const QPointF *polygonPoints, int pointCount,
+ QX11PaintEnginePrivate::GCMode gcMode,
+ QPaintEngine::PolygonDrawMode mode)
+{
+
+ QVarLengthArray<QPointF> translated_points(pointCount);
+ QPointF offset(matrix.dx(), matrix.dy());
+
+ qreal offs = adjust_coords ? aliasedCoordinateDelta : 0.0;
+ if (!X11->use_xrender || !(render_hints & QPainter::Antialiasing))
+ offset += QPointF(aliasedCoordinateDelta, aliasedCoordinateDelta);
+
+ for (int i = 0; i < pointCount; ++i) {
+ translated_points[i] = polygonPoints[i] + offset;
+
+ translated_points[i].rx() = qRound(translated_points[i].x()) + offs;
+ translated_points[i].ry() = qRound(translated_points[i].y()) + offs;
+ }
+
+ fillPolygon_dev(translated_points.data(), pointCount, gcMode, mode);
+}
+
+#ifndef QT_NO_XRENDER
+static void qt_XRenderCompositeTrapezoids(Display *dpy,
+ int op,
+ Picture src,
+ Picture dst,
+ _Xconst XRenderPictFormat *maskFormat,
+ int xSrc,
+ int ySrc,
+ const XTrapezoid *traps, int size)
+{
+ const int MAX_TRAPS = 50000;
+ while (size) {
+ int to_draw = size;
+ if (to_draw > MAX_TRAPS)
+ to_draw = MAX_TRAPS;
+ XRenderCompositeTrapezoids(dpy, op, src, dst,
+ maskFormat,
+ xSrc, ySrc,
+ traps, to_draw);
+ size -= to_draw;
+ traps += to_draw;
+ }
+}
+#endif
+
+void QX11PaintEnginePrivate::fillPolygon_dev(const QPointF *polygonPoints, int pointCount,
+ QX11PaintEnginePrivate::GCMode gcMode,
+ QPaintEngine::PolygonDrawMode mode)
+{
+ Q_Q(QX11PaintEngine);
+
+ int clippedCount = 0;
+ qt_float_point *clippedPoints = 0;
+
+#ifndef QT_NO_XRENDER
+ //can change if we switch to pen if gcMode != BrushGC
+ bool has_fill_texture = has_texture;
+ bool has_fill_pattern = has_pattern;
+ ::Picture src;
+#endif
+ QBrush fill;
+ GC fill_gc;
+ if (gcMode == BrushGC) {
+ fill = cbrush;
+ fill_gc = gc_brush;
+#ifndef QT_NO_XRENDER
+ if (current_brush)
+ src = current_brush;
+ else
+ src = X11->getSolidFill(scrn, fill.color());
+#endif
+ } else {
+ fill = QBrush(cpen.brush());
+ fill_gc = gc;
+#ifndef QT_NO_XRENDER
+ //we use the pens brush
+ has_fill_texture = (fill.style() == Qt::TexturePattern);
+ has_fill_pattern = (fill.style() >= Qt::Dense1Pattern && fill.style() <= Qt::DiagCrossPattern);
+ if (has_fill_texture)
+ src = fill.texture().x11PictureHandle();
+ else if (has_fill_pattern)
+ src = getPatternFill(scrn, fill);
+ else
+ src = X11->getSolidFill(scrn, fill.color());
+#endif
+ }
+
+ polygonClipper.clipPolygon((qt_float_point *) polygonPoints, pointCount,
+ &clippedPoints, &clippedCount);
+
+#ifndef QT_NO_XRENDER
+ bool solid_fill = fill.color().alpha() == 255;
+ if (has_fill_texture && fill.texture().depth() == 1 && solid_fill) {
+ has_fill_texture = false;
+ has_fill_pattern = true;
+ }
+
+ bool antialias = render_hints & QPainter::Antialiasing;
+
+ if (X11->use_xrender
+ && picture
+ && !has_fill_pattern
+ && (clippedCount > 0)
+ && (fill.style() != Qt::NoBrush)
+ && ((has_fill_texture && fill.texture().hasAlpha()) || antialias || !solid_fill || has_alpha_pen != has_alpha_brush))
+ {
+ if (tessellator->size > 0) {
+ XRenderPictureAttributes attrs;
+ attrs.poly_edge = antialias ? PolyEdgeSmooth : PolyEdgeSharp;
+ XRenderChangePicture(dpy, picture, CPPolyEdge, &attrs);
+ int x_offset = int(XFixedToDouble(tessellator->traps[0].left.p1.x) - bg_origin.x());
+ int y_offset = int(XFixedToDouble(tessellator->traps[0].left.p1.y) - bg_origin.y());
+ qt_XRenderCompositeTrapezoids(dpy, composition_mode, src, picture,
+ antialias
+ ? XRenderFindStandardFormat(dpy, PictStandardA8)
+ : XRenderFindStandardFormat(dpy, PictStandardA1),
+ x_offset, y_offset,
+ tessellator->traps, tessellator->size);
+ tessellator->done();
+ }
+ } else
+#endif
+ if (fill.style() != Qt::NoBrush) {
+ if (clippedCount > 200000) {
+ QPolygon poly;
+ for (int i = 0; i < clippedCount; ++i)
+ poly << QPoint(qFloor(clippedPoints[i].x), qFloor(clippedPoints[i].y));
+
+ const QRect bounds = poly.boundingRect();
+ const QRect aligned = bounds
+ & QRect(QPoint(), QSize(pdev->width(), pdev->height()));
+
+ QImage img(aligned.size(), QImage::Format_ARGB32_Premultiplied);
+ img.fill(0);
+
+ QPainter painter(&img);
+ painter.translate(-aligned.x(), -aligned.y());
+ painter.setPen(Qt::NoPen);
+ painter.setBrush(fill);
+ if (gcMode == BrushGC)
+ painter.setBrushOrigin(q->painter()->brushOrigin());
+ painter.drawPolygon(poly);
+ painter.end();
+
+ q->drawImage(aligned, img, img.rect(), Qt::AutoColor);
+ } else if (clippedCount > 0) {
+ QVarLengthArray<XPoint> xpoints(clippedCount);
+ for (int i = 0; i < clippedCount; ++i) {
+ xpoints[i].x = qFloor(clippedPoints[i].x);
+ xpoints[i].y = qFloor(clippedPoints[i].y);
+ }
+ if (mode == QPaintEngine::WindingMode)
+ XSetFillRule(dpy, fill_gc, WindingRule);
+ setupAdaptedOrigin(QPoint(xpoints[0].x, xpoints[0].y));
+ XFillPolygon(dpy, hd, fill_gc,
+ xpoints.data(), clippedCount,
+ mode == QPaintEngine::ConvexMode ? Convex : Complex, CoordModeOrigin);
+ resetAdaptedOrigin();
+ if (mode == QPaintEngine::WindingMode)
+ XSetFillRule(dpy, fill_gc, EvenOddRule);
+ }
+ }
+}
+
+void QX11PaintEnginePrivate::strokePolygon_translated(const QPointF *polygonPoints, int pointCount, bool close)
+{
+ QVarLengthArray<QPointF> translated_points(pointCount);
+ QPointF offset(matrix.dx(), matrix.dy());
+ for (int i = 0; i < pointCount; ++i)
+ translated_points[i] = polygonPoints[i] + offset;
+ strokePolygon_dev(translated_points.data(), pointCount, close);
+}
+
+void QX11PaintEnginePrivate::strokePolygon_dev(const QPointF *polygonPoints, int pointCount, bool close)
+{
+ int clippedCount = 0;
+ qt_float_point *clippedPoints = 0;
+ polygonClipper.clipPolygon((qt_float_point *) polygonPoints, pointCount,
+ &clippedPoints, &clippedCount, close);
+
+ if (clippedCount > 0) {
+ QVarLengthArray<XPoint> xpoints(clippedCount);
+ for (int i = 0; i < clippedCount; ++i) {
+ xpoints[i].x = qRound(clippedPoints[i].x + aliasedCoordinateDelta);
+ xpoints[i].y = qRound(clippedPoints[i].y + aliasedCoordinateDelta);
+ }
+ uint numberPoints = qMin(clippedCount, xlibMaxLinePoints);
+ XPoint *pts = xpoints.data();
+ XDrawLines(dpy, hd, gc, pts, numberPoints, CoordModeOrigin);
+ pts += numberPoints;
+ clippedCount -= numberPoints;
+ numberPoints = qMin(clippedCount, xlibMaxLinePoints-1);
+ while (clippedCount) {
+ XDrawLines(dpy, hd, gc, pts-1, numberPoints+1, CoordModeOrigin);
+ pts += numberPoints;
+ clippedCount -= numberPoints;
+ numberPoints = qMin(clippedCount, xlibMaxLinePoints-1);
+ }
+ }
+}
+
+void QX11PaintEngine::drawPolygon(const QPointF *polygonPoints, int pointCount, PolygonDrawMode mode)
+{
+ Q_D(QX11PaintEngine);
+ if (d->use_path_fallback) {
+ QPainterPath path(polygonPoints[0]);
+ for (int i = 1; i < pointCount; ++i)
+ path.lineTo(polygonPoints[i]);
+ if (mode == PolylineMode) {
+ QBrush oldBrush = d->cbrush;
+ d->cbrush = QBrush(Qt::NoBrush);
+ path.setFillRule(Qt::WindingFill);
+ drawPath(path);
+ d->cbrush = oldBrush;
+ } else {
+ path.setFillRule(mode == OddEvenMode ? Qt::OddEvenFill : Qt::WindingFill);
+ path.closeSubpath();
+ drawPath(path);
+ }
+ return;
+ }
+ if (mode != PolylineMode && d->has_brush)
+ d->fillPolygon_translated(polygonPoints, pointCount, QX11PaintEnginePrivate::BrushGC, mode);
+
+ if (d->has_pen)
+ d->strokePolygon_translated(polygonPoints, pointCount, mode != PolylineMode);
+}
+
+
+void QX11PaintEnginePrivate::fillPath(const QPainterPath &path, QX11PaintEnginePrivate::GCMode gc_mode, bool transform)
+{
+ qreal offs = adjust_coords ? aliasedCoordinateDelta : 0.0;
+
+ QPainterPath clippedPath;
+ QPainterPath clipPath;
+ clipPath.addRect(polygonClipper.boundingRect());
+
+ if (transform)
+ clippedPath = (path*matrix).intersected(clipPath);
+ else
+ clippedPath = path.intersected(clipPath);
+
+ QList<QPolygonF> polys = clippedPath.toFillPolygons();
+ for (int i = 0; i < polys.size(); ++i) {
+ QVarLengthArray<QPointF> translated_points(polys.at(i).size());
+
+ for (int j = 0; j < polys.at(i).size(); ++j) {
+ translated_points[j] = polys.at(i).at(j);
+ if (!X11->use_xrender || !(render_hints & QPainter::Antialiasing)) {
+ translated_points[j].rx() = qRound(translated_points[j].rx() + aliasedCoordinateDelta) + offs;
+ translated_points[j].ry() = qRound(translated_points[j].ry() + aliasedCoordinateDelta) + offs;
+ }
+ }
+
+ fillPolygon_dev(translated_points.data(), polys.at(i).size(), gc_mode,
+ path.fillRule() == Qt::OddEvenFill ? QPaintEngine::OddEvenMode : QPaintEngine::WindingMode);
+ }
+}
+
+void QX11PaintEngine::drawPath(const QPainterPath &path)
+{
+ Q_D(QX11PaintEngine);
+ if (path.isEmpty())
+ return;
+
+ if (d->has_brush)
+ d->fillPath(path, QX11PaintEnginePrivate::BrushGC, true);
+ if (d->has_pen
+ && ((X11->use_xrender && (d->has_alpha_pen || (d->render_hints & QPainter::Antialiasing)))
+ || (!d->cpen.isCosmetic() && d->txop > QTransform::TxTranslate
+ && !d->has_non_scaling_xform)
+ || (d->cpen.style() == Qt::CustomDashLine))) {
+ QPainterPathStroker stroker;
+ if (d->cpen.style() == Qt::CustomDashLine) {
+ stroker.setDashPattern(d->cpen.dashPattern());
+ stroker.setDashOffset(d->cpen.dashOffset());
+ } else {
+ stroker.setDashPattern(d->cpen.style());
+ }
+ stroker.setCapStyle(d->cpen.capStyle());
+ stroker.setJoinStyle(d->cpen.joinStyle());
+ QPainterPath stroke;
+ qreal width = d->cpen.widthF();
+ QPolygonF poly;
+ QRectF deviceRect(0, 0, d->pdev->width(), d->pdev->height());
+ // necessary to get aliased alphablended primitives to be drawn correctly
+ if (d->cpen.isCosmetic() || d->has_scaling_xform) {
+ if (d->cpen.isCosmetic())
+ stroker.setWidth(width == 0 ? 1 : width);
+ else
+ stroker.setWidth(width * d->xform_scale);
+ stroker.d_ptr->stroker.setClipRect(deviceRect);
+ stroke = stroker.createStroke(path * d->matrix);
+ if (stroke.isEmpty())
+ return;
+ stroke.setFillRule(Qt::WindingFill);
+ d->fillPath(stroke, QX11PaintEnginePrivate::PenGC, false);
+ } else {
+ stroker.setWidth(width);
+ stroker.d_ptr->stroker.setClipRect(d->matrix.inverted().mapRect(deviceRect));
+ stroke = stroker.createStroke(path);
+ if (stroke.isEmpty())
+ return;
+ stroke.setFillRule(Qt::WindingFill);
+ d->fillPath(stroke, QX11PaintEnginePrivate::PenGC, true);
+ }
+ } else if (d->has_pen) {
+ // if we have a cosmetic pen - use XDrawLine() for speed
+ QList<QPolygonF> polys = path.toSubpathPolygons(d->matrix);
+ for (int i = 0; i < polys.size(); ++i)
+ d->strokePolygon_dev(polys.at(i).data(), polys.at(i).size(), false);
+ }
+}
+
+Q_GUI_EXPORT void qt_x11_drawImage(const QRect &rect, const QPoint &pos, const QImage &image,
+ Drawable hd, GC gc, Display *dpy, Visual *visual, int depth)
+{
+ Q_ASSERT(image.format() == QImage::Format_RGB32);
+ Q_ASSERT(image.depth() == 32);
+
+ XImage *xi;
+ // Note: this code assumes either RGB or BGR, 8 bpc server layouts
+ const uint red_mask = (uint) visual->red_mask;
+ bool bgr_layout = (red_mask == 0xff);
+
+ const int w = rect.width();
+ const int h = rect.height();
+
+ QImage im;
+ int image_byte_order = ImageByteOrder(X11->display);
+ if ((QSysInfo::ByteOrder == QSysInfo::BigEndian && ((image_byte_order == LSBFirst) || bgr_layout))
+ || (image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian)
+ || (image_byte_order == LSBFirst && bgr_layout))
+ {
+ im = image.copy(rect);
+ const int iw = im.bytesPerLine() / 4;
+ uint *data = (uint *)im.bits();
+ for (int i=0; i < h; i++) {
+ uint *p = data;
+ uint *end = p + w;
+ if (bgr_layout && image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian) {
+ while (p < end) {
+ *p = ((*p << 8) & 0xffffff00) | ((*p >> 24) & 0x000000ff);
+ p++;
+ }
+ } else if ((image_byte_order == LSBFirst && QSysInfo::ByteOrder == QSysInfo::BigEndian)
+ || (image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::LittleEndian)) {
+ while (p < end) {
+ *p = ((*p << 24) & 0xff000000) | ((*p << 8) & 0x00ff0000)
+ | ((*p >> 8) & 0x0000ff00) | ((*p >> 24) & 0x000000ff);
+ p++;
+ }
+ } else if ((image_byte_order == MSBFirst && QSysInfo::ByteOrder == QSysInfo::BigEndian)
+ || (image_byte_order == LSBFirst && bgr_layout))
+ {
+ while (p < end) {
+ *p = ((*p << 16) & 0x00ff0000) | ((*p >> 16) & 0x000000ff)
+ | ((*p ) & 0xff00ff00);
+ p++;
+ }
+ }
+ data += iw;
+ }
+ xi = XCreateImage(dpy, visual, depth, ZPixmap,
+ 0, (char *) im.bits(), w, h, 32, im.bytesPerLine());
+ } else {
+ xi = XCreateImage(dpy, visual, depth, ZPixmap,
+ 0, (char *) image.scanLine(rect.y())+rect.x()*sizeof(uint), w, h, 32, image.bytesPerLine());
+ }
+ XPutImage(dpy, hd, gc, xi, 0, 0, pos.x(), pos.y(), w, h);
+ xi->data = 0; // QImage owns these bits
+ XDestroyImage(xi);
+}
+
+void QX11PaintEngine::drawImage(const QRectF &r, const QImage &image, const QRectF &sr, Qt::ImageConversionFlags flags)
+{
+ Q_D(QX11PaintEngine);
+
+ if (image.format() == QImage::Format_RGB32
+ && d->pdev_depth >= 24 && image.depth() == 32
+ && r.size() == sr.size())
+ {
+ int sx = qRound(sr.x());
+ int sy = qRound(sr.y());
+ int x = qRound(r.x());
+ int y = qRound(r.y());
+ int w = qRound(r.width());
+ int h = qRound(r.height());
+
+ qt_x11_drawImage(QRect(sx, sy, w, h), QPoint(x, y), image, d->hd, d->gc, d->dpy,
+ (Visual *)d->xinfo->visual(), d->pdev_depth);
+ } else {
+ QPaintEngine::drawImage(r, image, sr, flags);
+ }
+}
+
+void QX11PaintEngine::drawPixmap(const QRectF &r, const QPixmap &px, const QRectF &_sr)
+{
+ Q_D(QX11PaintEngine);
+ QRectF sr = _sr;
+ int x = qRound(r.x());
+ int y = qRound(r.y());
+ int sx = qRound(sr.x());
+ int sy = qRound(sr.y());
+ int sw = qRound(sr.width());
+ int sh = qRound(sr.height());
+
+ QPixmap pixmap = qt_toX11Pixmap(px);
+ if(pixmap.isNull())
+ return;
+
+ if ((d->xinfo && d->xinfo->screen() != pixmap.x11Info().screen())
+ || (pixmap.x11Info().screen() != DefaultScreen(X11->display))) {
+ QPixmap* p = const_cast<QPixmap *>(&pixmap);
+ p->x11SetScreen(d->xinfo ? d->xinfo->screen() : DefaultScreen(X11->display));
+ }
+
+ QPixmap::x11SetDefaultScreen(pixmap.x11Info().screen());
+
+#ifndef QT_NO_XRENDER
+ ::Picture src_pict = static_cast<QX11PixmapData*>(pixmap.data.data())->picture;
+ if (src_pict && d->picture) {
+ const int pDepth = pixmap.depth();
+ if (pDepth == 1 && (d->has_alpha_pen)) {
+ qt_render_bitmap(d->dpy, d->scrn, src_pict, d->picture,
+ sx, sy, x, y, sw, sh, d->cpen);
+ return;
+ } else if (pDepth != 1 && (pDepth == 32 || pDepth != d->pdev_depth)) {
+ XRenderComposite(d->dpy, d->composition_mode,
+ src_pict, 0, d->picture, sx, sy, 0, 0, x, y, sw, sh);
+ return;
+ }
+ }
+#endif
+
+ bool mono_src = pixmap.depth() == 1;
+ bool mono_dst = d->pdev_depth == 1;
+ bool restore_clip = false;
+
+ if (static_cast<QX11PixmapData*>(pixmap.data.data())->x11_mask) { // pixmap has a mask
+ QBitmap comb(sw, sh);
+ GC cgc = XCreateGC(d->dpy, comb.handle(), 0, 0);
+ XSetForeground(d->dpy, cgc, 0);
+ XFillRectangle(d->dpy, comb.handle(), cgc, 0, 0, sw, sh);
+ XSetBackground(d->dpy, cgc, 0);
+ XSetForeground(d->dpy, cgc, 1);
+ if (!d->crgn.isEmpty()) {
+ int num;
+ XRectangle *rects = (XRectangle *)qt_getClipRects(d->crgn, num);
+ XSetClipRectangles(d->dpy, cgc, -x, -y, rects, num, Unsorted);
+ } else if (d->has_clipping) {
+ XSetClipRectangles(d->dpy, cgc, 0, 0, 0, 0, Unsorted);
+ }
+ XSetFillStyle(d->dpy, cgc, FillOpaqueStippled);
+ XSetTSOrigin(d->dpy, cgc, -sx, -sy);
+ XSetStipple(d->dpy, cgc,
+ static_cast<QX11PixmapData*>(pixmap.data.data())->x11_mask);
+ XFillRectangle(d->dpy, comb.handle(), cgc, 0, 0, sw, sh);
+ XFreeGC(d->dpy, cgc);
+
+ XSetClipOrigin(d->dpy, d->gc, x, y);
+ XSetClipMask(d->dpy, d->gc, comb.handle());
+ restore_clip = true;
+ }
+
+ if (mono_src) {
+ if (!d->crgn.isEmpty()) {
+ Pixmap comb = XCreatePixmap(d->dpy, d->hd, sw, sh, 1);
+ GC cgc = XCreateGC(d->dpy, comb, 0, 0);
+ XSetForeground(d->dpy, cgc, 0);
+ XFillRectangle(d->dpy, comb, cgc, 0, 0, sw, sh);
+ int num;
+ XRectangle *rects = (XRectangle *)qt_getClipRects(d->crgn, num);
+ XSetClipRectangles(d->dpy, cgc, -x, -y, rects, num, Unsorted);
+ XCopyArea(d->dpy, pixmap.handle(), comb, cgc, sx, sy, sw, sh, 0, 0);
+ XFreeGC(d->dpy, cgc);
+
+ XSetClipMask(d->dpy, d->gc, comb);
+ XSetClipOrigin(d->dpy, d->gc, x, y);
+ XFreePixmap(d->dpy, comb);
+ } else {
+ XSetClipMask(d->dpy, d->gc, pixmap.handle());
+ XSetClipOrigin(d->dpy, d->gc, x - sx, y - sy);
+ }
+
+ if (mono_dst) {
+ XSetForeground(d->dpy, d->gc, qGray(d->cpen.color().rgb()) > 127 ? 0 : 1);
+ } else {
+ QColormap cmap = QColormap::instance(d->scrn);
+ XSetForeground(d->dpy, d->gc, cmap.pixel(d->cpen.color()));
+ }
+ XFillRectangle(d->dpy, d->hd, d->gc, x, y, sw, sh);
+ restore_clip = true;
+ } else if (mono_dst && !mono_src) {
+ QBitmap bitmap(pixmap);
+ XCopyArea(d->dpy, bitmap.handle(), d->hd, d->gc, sx, sy, sw, sh, x, y);
+ } else {
+ XCopyArea(d->dpy, pixmap.handle(), d->hd, d->gc, sx, sy, sw, sh, x, y);
+ }
+
+ if (d->pdev->devType() == QInternal::Pixmap) {
+ const QPixmap *px = static_cast<const QPixmap*>(d->pdev);
+ Pixmap src_mask = static_cast<QX11PixmapData*>(pixmap.data.data())->x11_mask;
+ Pixmap dst_mask = static_cast<QX11PixmapData*>(px->data.data())->x11_mask;
+ if (dst_mask) {
+ GC cgc = XCreateGC(d->dpy, dst_mask, 0, 0);
+ if (src_mask) { // copy src mask into dst mask
+ XCopyArea(d->dpy, src_mask, dst_mask, cgc, sx, sy, sw, sh, x, y);
+ } else { // no src mask, but make sure the area copied is opaque in dest
+ XSetBackground(d->dpy, cgc, 0);
+ XSetForeground(d->dpy, cgc, 1);
+ XFillRectangle(d->dpy, dst_mask, cgc, x, y, sw, sh);
+ }
+ XFreeGC(d->dpy, cgc);
+ }
+ }
+
+ if (restore_clip) {
+ XSetClipOrigin(d->dpy, d->gc, 0, 0);
+ int num;
+ XRectangle *rects = (XRectangle *)qt_getClipRects(d->crgn, num);
+ if (num == 0)
+ XSetClipMask(d->dpy, d->gc, XNone);
+ else
+ XSetClipRectangles(d->dpy, d->gc, 0, 0, rects, num, Unsorted);
+ }
+}
+
+void QX11PaintEngine::updateMatrix(const QTransform &mtx)
+{
+ Q_D(QX11PaintEngine);
+ d->txop = mtx.type();
+ d->matrix = mtx;
+
+ d->has_complex_xform = (d->txop > QTransform::TxTranslate);
+
+ extern bool qt_scaleForTransform(const QTransform &transform, qreal *scale);
+ bool scaling = qt_scaleForTransform(d->matrix, &d->xform_scale);
+ d->has_scaling_xform = scaling && d->xform_scale != 1.0;
+ d->has_non_scaling_xform = scaling && d->xform_scale == 1.0;
+}
+
+/*
+ NB! the clip region is expected to be in dev coordinates
+*/
+void QX11PaintEngine::updateClipRegion_dev(const QRegion &clipRegion, Qt::ClipOperation op)
+{
+ Q_D(QX11PaintEngine);
+ QRegion sysClip = systemClip();
+ if (op == Qt::NoClip) {
+ d->has_clipping = false;
+ d->crgn = sysClip;
+ if (!sysClip.isEmpty()) {
+ x11SetClipRegion(d->dpy, d->gc, d->gc_brush, d->picture, sysClip);
+ } else {
+ x11ClearClipRegion(d->dpy, d->gc, d->gc_brush, d->picture);
+ }
+ return;
+ }
+
+ switch (op) {
+ case Qt::IntersectClip:
+ if (d->has_clipping) {
+ d->crgn &= clipRegion;
+ break;
+ }
+ // fall through
+ case Qt::ReplaceClip:
+ if (!sysClip.isEmpty())
+ d->crgn = clipRegion.intersected(sysClip);
+ else
+ d->crgn = clipRegion;
+ break;
+ case Qt::UniteClip:
+ d->crgn |= clipRegion;
+ if (!sysClip.isEmpty())
+ d->crgn = d->crgn.intersected(sysClip);
+ break;
+ default:
+ break;
+ }
+ d->has_clipping = true;
+ x11SetClipRegion(d->dpy, d->gc, d->gc_brush, d->picture, d->crgn);
+}
+
+void QX11PaintEngine::updateFont(const QFont &)
+{
+}
+
+Qt::HANDLE QX11PaintEngine::handle() const
+{
+ Q_D(const QX11PaintEngine);
+ Q_ASSERT(isActive());
+ Q_ASSERT(d->hd);
+ return d->hd;
+}
+
+extern void qt_draw_tile(QPaintEngine *, qreal, qreal, qreal, qreal, const QPixmap &,
+ qreal, qreal);
+
+void QX11PaintEngine::drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &p)
+{
+ int x = qRound(r.x());
+ int y = qRound(r.y());
+ int w = qRound(r.width());
+ int h = qRound(r.height());
+ int sx = qRound(p.x());
+ int sy = qRound(p.y());
+
+ bool mono_src = pixmap.depth() == 1;
+ Q_D(QX11PaintEngine);
+
+ if ((d->xinfo && d->xinfo->screen() != pixmap.x11Info().screen())
+ || (pixmap.x11Info().screen() != DefaultScreen(X11->display))) {
+ QPixmap* p = const_cast<QPixmap *>(&pixmap);
+ p->x11SetScreen(d->xinfo ? d->xinfo->screen() : DefaultScreen(X11->display));
+ }
+
+ QPixmap::x11SetDefaultScreen(pixmap.x11Info().screen());
+
+#ifndef QT_NO_XRENDER
+ if (X11->use_xrender && d->picture && pixmap.x11PictureHandle()) {
+#if 0
+ // ### Qt 5: enable this
+ XRenderPictureAttributes attrs;
+ attrs.repeat = true;
+ XRenderChangePicture(d->dpy, pixmap.x11PictureHandle(), CPRepeat, &attrs);
+
+ if (mono_src) {
+ qt_render_bitmap(d->dpy, d->scrn, pixmap.x11PictureHandle(), d->picture,
+ sx, sy, x, y, w, h, d->cpen);
+ } else {
+ XRenderComposite(d->dpy, d->composition_mode,
+ pixmap.x11PictureHandle(), XNone, d->picture,
+ sx, sy, 0, 0, x, y, w, h);
+ }
+#else
+ const int numTiles = (w / pixmap.width()) * (h / pixmap.height());
+ if (numTiles < 100) {
+ // this is essentially qt_draw_tile(), inlined for
+ // the XRenderComposite call
+ int yPos, xPos, drawH, drawW, yOff, xOff;
+ yPos = y;
+ yOff = sy;
+ while(yPos < y + h) {
+ drawH = pixmap.height() - yOff; // Cropping first row
+ if (yPos + drawH > y + h) // Cropping last row
+ drawH = y + h - yPos;
+ xPos = x;
+ xOff = sx;
+ while(xPos < x + w) {
+ drawW = pixmap.width() - xOff; // Cropping first column
+ if (xPos + drawW > x + w) // Cropping last column
+ drawW = x + w - xPos;
+ if (mono_src) {
+ qt_render_bitmap(d->dpy, d->scrn, pixmap.x11PictureHandle(), d->picture,
+ xOff, yOff, xPos, yPos, drawW, drawH, d->cpen);
+ } else {
+ XRenderComposite(d->dpy, d->composition_mode,
+ pixmap.x11PictureHandle(), XNone, d->picture,
+ xOff, yOff, 0, 0, xPos, yPos, drawW, drawH);
+ }
+ xPos += drawW;
+ xOff = 0;
+ }
+ yPos += drawH;
+ yOff = 0;
+ }
+ } else {
+ w = qMin(w, d->pdev->width() - x);
+ h = qMin(h, d->pdev->height() - y);
+ if (w <= 0 || h <= 0)
+ return;
+
+ const int pw = w + sx;
+ const int ph = h + sy;
+ QPixmap pm(pw, ph);
+ if (pixmap.hasAlpha() || mono_src)
+ pm.fill(Qt::transparent);
+
+ const int mode = pixmap.hasAlpha() ? PictOpOver : PictOpSrc;
+ const ::Picture pmPicture = pm.x11PictureHandle();
+
+ // first tile
+ XRenderComposite(d->dpy, mode,
+ pixmap.x11PictureHandle(), XNone, pmPicture,
+ 0, 0, 0, 0, 0, 0, qMin(pw, pixmap.width()), qMin(ph, pixmap.height()));
+
+ // first row of tiles
+ int xPos = pixmap.width();
+ const int sh = qMin(ph, pixmap.height());
+ while (xPos < pw) {
+ const int sw = qMin(xPos, pw - xPos);
+ XRenderComposite(d->dpy, mode,
+ pmPicture, XNone, pmPicture,
+ 0, 0, 0, 0, xPos, 0, sw, sh);
+ xPos *= 2;
+ }
+
+ // remaining rows
+ int yPos = pixmap.height();
+ const int sw = pw;
+ while (yPos < ph) {
+ const int sh = qMin(yPos, ph - yPos);
+ XRenderComposite(d->dpy, mode,
+ pmPicture, XNone, pmPicture,
+ 0, 0, 0, 0, 0, yPos, sw, sh);
+ yPos *= 2;
+ }
+
+ // composite
+ if (mono_src)
+ qt_render_bitmap(d->dpy, d->scrn, pmPicture, d->picture,
+ sx, sy, x, y, w, h, d->cpen);
+ else
+ XRenderComposite(d->dpy, d->composition_mode,
+ pmPicture, XNone, d->picture,
+ sx, sy, 0, 0, x, y, w, h);
+ }
+#endif
+ } else
+#endif // !QT_NO_XRENDER
+ if (pixmap.depth() > 1 && !static_cast<QX11PixmapData*>(pixmap.data.data())->x11_mask) {
+ XSetTile(d->dpy, d->gc, pixmap.handle());
+ XSetFillStyle(d->dpy, d->gc, FillTiled);
+ XSetTSOrigin(d->dpy, d->gc, x-sx, y-sy);
+ XFillRectangle(d->dpy, d->hd, d->gc, x, y, w, h);
+ XSetTSOrigin(d->dpy, d->gc, 0, 0);
+ XSetFillStyle(d->dpy, d->gc, FillSolid);
+ } else {
+ qt_draw_tile(this, x, y, w, h, pixmap, sx, sy);
+ }
+}
+
+void QX11PaintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem)
+{
+ const QTextItemInt &ti = static_cast<const QTextItemInt &>(textItem);
+
+ switch(ti.fontEngine->type()) {
+ case QFontEngine::TestFontEngine:
+ case QFontEngine::Box:
+ d_func()->drawBoxTextItem(p, ti);
+ break;
+ case QFontEngine::XLFD:
+ drawXLFD(p, ti);
+ break;
+#ifndef QT_NO_FONTCONFIG
+ case QFontEngine::Freetype:
+ drawFreetype(p, ti);
+ break;
+#endif
+ default:
+ Q_ASSERT(false);
+ }
+}
+
+void QX11PaintEngine::drawXLFD(const QPointF &p, const QTextItemInt &ti)
+{
+ Q_D(QX11PaintEngine);
+
+ if (d->txop > QTransform::TxTranslate) {
+ // XServer or font don't support server side transformations, need to do it by hand
+ QPaintEngine::drawTextItem(p, ti);
+ return;
+ }
+
+ if (!ti.glyphs.numGlyphs)
+ return;
+
+ QVarLengthArray<QFixedPoint> positions;
+ QVarLengthArray<glyph_t> glyphs;
+ QTransform matrix = d->matrix;
+ matrix.translate(p.x(), p.y());
+ ti.fontEngine->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
+ if (glyphs.size() == 0)
+ return;
+
+ QFontEngineXLFD *xlfd = static_cast<QFontEngineXLFD *>(ti.fontEngine);
+ Qt::HANDLE font_id = xlfd->fontStruct()->fid;
+
+ XSetFont(d->dpy, d->gc, font_id);
+
+ const QFixed offs = QFixed::fromReal(aliasedCoordinateDelta);
+ for (int i = 0; i < glyphs.size(); i++) {
+ int xp = qRound(positions[i].x + offs);
+ int yp = qRound(positions[i].y + offs);
+ if (xp < SHRT_MAX && xp > SHRT_MIN && yp > SHRT_MIN && yp < SHRT_MAX) {
+ XChar2b ch;
+ ch.byte1 = glyphs[i] >> 8;
+ ch.byte2 = glyphs[i] & 0xff;
+ XDrawString16(d->dpy, d->hd, d->gc, xp, yp, &ch, 1);
+ }
+ }
+}
+
+#ifndef QT_NO_FONTCONFIG
+static QPainterPath path_for_glyphs(const QVarLengthArray<glyph_t> &glyphs,
+ const QVarLengthArray<QFixedPoint> &positions,
+ const QFontEngineFT *ft)
+{
+ QPainterPath path;
+ path.setFillRule(Qt::WindingFill);
+ ft->lockFace();
+ int i = 0;
+ while (i < glyphs.size()) {
+ QFontEngineFT::Glyph *glyph = ft->loadGlyph(glyphs[i], QFontEngineFT::Format_Mono);
+ // #### fix case where we don't get a glyph
+ if (!glyph)
+ break;
+
+ Q_ASSERT(glyph->format == QFontEngineFT::Format_Mono);
+ int n = 0;
+ int h = glyph->height;
+ int xp = qRound(positions[i].x);
+ int yp = qRound(positions[i].y);
+
+ xp += glyph->x;
+ yp += -glyph->y + glyph->height;
+ int pitch = ((glyph->width + 31) & ~31) >> 3;
+
+ uchar *src = glyph->data;
+ while (h--) {
+ for (int x = 0; x < glyph->width; ++x) {
+ bool set = src[x >> 3] & (0x80 >> (x & 7));
+ if (set) {
+ QRect r(xp + x, yp - h, 1, 1);
+ while (x < glyph->width-1 && src[(x+1) >> 3] & (0x80 >> ((x+1) & 7))) {
+ ++x;
+ r.setRight(r.right()+1);
+ }
+
+ path.addRect(r);
+ ++n;
+ }
+ }
+ src += pitch;
+ }
+ ++i;
+ }
+ ft->unlockFace();
+ return path;
+}
+
+void QX11PaintEngine::drawFreetype(const QPointF &p, const QTextItemInt &ti)
+{
+ Q_D(QX11PaintEngine);
+ if (!ti.glyphs.numGlyphs)
+ return;
+
+ QFontEngineX11FT *ft = static_cast<QFontEngineX11FT *>(ti.fontEngine);
+
+ if (!d->cpen.isSolid()) {
+ QPaintEngine::drawTextItem(p, ti);
+ return;
+ }
+
+ const bool xrenderPath = (X11->use_xrender
+ && !(d->pdev->devType() == QInternal::Pixmap
+ && static_cast<const QPixmap *>(d->pdev)->data->pixelType() == QPixmapData::BitmapType));
+
+ QVarLengthArray<QFixedPoint> positions;
+ QVarLengthArray<glyph_t> glyphs;
+ QTransform matrix;
+
+ if (xrenderPath)
+ matrix = d->matrix;
+ matrix.translate(p.x(), p.y());
+ ft->getGlyphPositions(ti.glyphs, matrix, ti.flags, glyphs, positions);
+ if (glyphs.count() == 0)
+ return;
+
+#ifndef QT_NO_XRENDER
+ QFontEngineFT::QGlyphSet *set = ft->defaultGlyphs();
+ if (d->txop >= QTransform::TxScale && xrenderPath)
+ set = ft->loadTransformedGlyphSet(d->matrix);
+
+ if (!set || set->outline_drawing
+ || !ft->loadGlyphs(set, glyphs.constData(), glyphs.size(), positions.constData(), QFontEngineFT::Format_Render))
+ {
+ QPaintEngine::drawTextItem(p, ti);
+ return;
+ }
+
+ if (xrenderPath) {
+ GlyphSet glyphSet = set->id;
+ const QColor &pen = d->cpen.color();
+ ::Picture src = X11->getSolidFill(d->scrn, pen);
+ XRenderPictFormat *maskFormat = 0;
+ if (ft->xglyph_format != PictStandardA1)
+ maskFormat = XRenderFindStandardFormat(X11->display, ft->xglyph_format);
+
+ enum { t_min = SHRT_MIN, t_max = SHRT_MAX };
+
+ int i = 0;
+ for (; i < glyphs.size()
+ && (positions[i].x < t_min || positions[i].x > t_max
+ || positions[i].y < t_min || positions[i].y > t_max);
+ ++i)
+ ;
+
+ if (i >= glyphs.size())
+ return;
+ ++i;
+
+ QFixed xp = positions[i - 1].x;
+ QFixed yp = positions[i - 1].y;
+ QFixed offs = QFixed::fromReal(aliasedCoordinateDelta);
+
+ XGlyphElt32 elt;
+ elt.glyphset = glyphSet;
+ elt.chars = &glyphs[i - 1];
+ elt.nchars = 1;
+ elt.xOff = qRound(xp + offs);
+ elt.yOff = qRound(yp + offs);
+ for (; i < glyphs.size(); ++i) {
+ if (positions[i].x < t_min || positions[i].x > t_max
+ || positions[i].y < t_min || positions[i].y > t_max) {
+ break;
+ }
+ QFontEngineFT::Glyph *g = ft->cachedGlyph(glyphs[i - 1]);
+ if (g
+ && positions[i].x == xp + g->advance
+ && positions[i].y == yp
+ && elt.nchars < 253 // don't draw more than 253 characters as some X servers
+ // hang with it
+ ) {
+ elt.nchars++;
+ xp += g->advance;
+ } else {
+ xp = positions[i].x;
+ yp = positions[i].y;
+
+ XRenderCompositeText32(X11->display, PictOpOver, src, d->picture,
+ maskFormat, 0, 0, 0, 0,
+ &elt, 1);
+ elt.chars = &glyphs[i];
+ elt.nchars = 1;
+ elt.xOff = qRound(xp + offs);
+ elt.yOff = qRound(yp + offs);
+ }
+ }
+ XRenderCompositeText32(X11->display, PictOpOver, src, d->picture,
+ maskFormat, 0, 0, 0, 0,
+ &elt, 1);
+
+ return;
+
+ }
+#endif
+
+ QPainterPath path = path_for_glyphs(glyphs, positions, ft);
+ if (path.elementCount() <= 1)
+ return;
+ Q_ASSERT((path.elementCount() % 5) == 0);
+ if (d->txop >= QTransform::TxScale) {
+ painter()->save();
+ painter()->setBrush(d->cpen.brush());
+ painter()->setPen(Qt::NoPen);
+ painter()->drawPath(path);
+ painter()->restore();
+ return;
+ }
+
+ const int rectcount = 256;
+ XRectangle rects[rectcount];
+ int num_rects = 0;
+
+ QPoint delta(qRound(d->matrix.dx()), qRound(d->matrix.dy()));
+ QRect clip(d->polygonClipper.boundingRect());
+ for (int i=0; i < path.elementCount(); i+=5) {
+ int x = qRound(path.elementAt(i).x);
+ int y = qRound(path.elementAt(i).y);
+ int w = qRound(path.elementAt(i+1).x) - x;
+ int h = qRound(path.elementAt(i+2).y) - y;
+
+ QRect rect = QRect(x + delta.x(), y + delta.y(), w, h);
+ rect = rect.intersected(clip);
+ if (rect.isEmpty())
+ continue;
+
+ rects[num_rects].x = short(rect.x());
+ rects[num_rects].y = short(rect.y());
+ rects[num_rects].width = ushort(rect.width());
+ rects[num_rects].height = ushort(rect.height());
+ ++num_rects;
+ if (num_rects == rectcount) {
+ XFillRectangles(d->dpy, d->hd, d->gc, rects, num_rects);
+ num_rects = 0;
+ }
+ }
+ if (num_rects > 0)
+ XFillRectangles(d->dpy, d->hd, d->gc, rects, num_rects);
+
+}
+#endif // !QT_NO_XRENDER
+
+QT_END_NAMESPACE
diff --git a/src/gui/painting/qpaintengine_x11_p.h b/src/widgets/platforms/x11/qpaintengine_x11_p.h
index 897c69f122..897c69f122 100644
--- a/src/gui/painting/qpaintengine_x11_p.h
+++ b/src/widgets/platforms/x11/qpaintengine_x11_p.h
diff --git a/src/gui/image/qpixmap_x11.cpp b/src/widgets/platforms/x11/qpixmap_x11.cpp
index bc468cb7ec..bc468cb7ec 100644
--- a/src/gui/image/qpixmap_x11.cpp
+++ b/src/widgets/platforms/x11/qpixmap_x11.cpp
diff --git a/src/gui/image/qpixmap_x11_p.h b/src/widgets/platforms/x11/qpixmap_x11_p.h
index eb8e5819ad..eb8e5819ad 100644
--- a/src/gui/image/qpixmap_x11_p.h
+++ b/src/widgets/platforms/x11/qpixmap_x11_p.h
diff --git a/src/gui/painting/qregion_x11.cpp b/src/widgets/platforms/x11/qregion_x11.cpp
index ef4e844bfa..ef4e844bfa 100644
--- a/src/gui/painting/qregion_x11.cpp
+++ b/src/widgets/platforms/x11/qregion_x11.cpp
diff --git a/src/gui/kernel/qsound_x11.cpp b/src/widgets/platforms/x11/qsound_x11.cpp
index 12c06f0aa1..12c06f0aa1 100644
--- a/src/gui/kernel/qsound_x11.cpp
+++ b/src/widgets/platforms/x11/qsound_x11.cpp
diff --git a/src/gui/kernel/qt_x11_p.h b/src/widgets/platforms/x11/qt_x11_p.h
index 69079cfaad..69079cfaad 100644
--- a/src/gui/kernel/qt_x11_p.h
+++ b/src/widgets/platforms/x11/qt_x11_p.h
diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/widgets/platforms/x11/qwidget_x11.cpp
index 3eec5c7331..3eec5c7331 100644
--- a/src/gui/kernel/qwidget_x11.cpp
+++ b/src/widgets/platforms/x11/qwidget_x11.cpp
diff --git a/src/gui/kernel/qwidgetcreate_x11.cpp b/src/widgets/platforms/x11/qwidgetcreate_x11.cpp
index 16bd6abf9a..16bd6abf9a 100644
--- a/src/gui/kernel/qwidgetcreate_x11.cpp
+++ b/src/widgets/platforms/x11/qwidgetcreate_x11.cpp
diff --git a/src/gui/kernel/qx11embed_x11.cpp b/src/widgets/platforms/x11/qx11embed_x11.cpp
index 49a819469e..49a819469e 100644
--- a/src/gui/kernel/qx11embed_x11.cpp
+++ b/src/widgets/platforms/x11/qx11embed_x11.cpp
diff --git a/src/widgets/platforms/x11/qx11embed_x11.h b/src/widgets/platforms/x11/qx11embed_x11.h
new file mode 100644
index 0000000000..c6af4f491a
--- /dev/null
+++ b/src/widgets/platforms/x11/qx11embed_x11.h
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QX11EMBED_X11_H
+#define QX11EMBED_X11_H
+
+#include <QtWidgets/qwidget.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QX11EmbedWidgetPrivate;
+class Q_GUI_EXPORT QX11EmbedWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ QX11EmbedWidget(QWidget *parent = 0);
+ ~QX11EmbedWidget();
+
+ void embedInto(WId id);
+ WId containerWinId() const;
+
+ enum Error {
+ Unknown,
+ Internal,
+ InvalidWindowID
+ };
+ Error error() const;
+
+Q_SIGNALS:
+ void embedded();
+ void containerClosed();
+ void error(QX11EmbedWidget::Error error);
+
+protected:
+ bool x11Event(XEvent *);
+ bool eventFilter(QObject *, QEvent *);
+ bool event(QEvent *);
+ void resizeEvent(QResizeEvent *);
+
+private:
+ Q_DECLARE_PRIVATE(QX11EmbedWidget)
+ Q_DISABLE_COPY(QX11EmbedWidget)
+};
+
+class QX11EmbedContainerPrivate;
+class Q_GUI_EXPORT QX11EmbedContainer : public QWidget
+{
+ Q_OBJECT
+public:
+ QX11EmbedContainer(QWidget *parent = 0);
+ ~QX11EmbedContainer();
+
+ void embedClient(WId id);
+ void discardClient();
+
+ WId clientWinId() const;
+
+ QSize minimumSizeHint() const;
+
+ enum Error {
+ Unknown,
+ Internal,
+ InvalidWindowID
+ };
+ Error error() const;
+
+Q_SIGNALS:
+ void clientIsEmbedded();
+ void clientClosed();
+ void error(QX11EmbedContainer::Error);
+
+protected:
+ bool x11Event(XEvent *);
+ bool eventFilter(QObject *, QEvent *);
+ void paintEvent(QPaintEvent *e);
+ void resizeEvent(QResizeEvent *);
+ void showEvent(QShowEvent *);
+ void hideEvent(QHideEvent *);
+ bool event(QEvent *);
+
+private:
+ Q_DECLARE_PRIVATE(QX11EmbedContainer)
+ Q_DISABLE_COPY(QX11EmbedContainer)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QX11EMBED_X11_H
diff --git a/src/gui/kernel/qx11info_x11.cpp b/src/widgets/platforms/x11/qx11info_x11.cpp
index f52443befc..f52443befc 100644
--- a/src/gui/kernel/qx11info_x11.cpp
+++ b/src/widgets/platforms/x11/qx11info_x11.cpp
diff --git a/src/gui/kernel/qx11info_x11.h b/src/widgets/platforms/x11/qx11info_x11.h
index ece85740d2..ece85740d2 100644
--- a/src/gui/kernel/qx11info_x11.h
+++ b/src/widgets/platforms/x11/qx11info_x11.h
diff --git a/src/gui/s60framework/qs60mainapplication.cpp b/src/widgets/s60framework/qs60mainapplication.cpp
index 289d81cf96..289d81cf96 100644
--- a/src/gui/s60framework/qs60mainapplication.cpp
+++ b/src/widgets/s60framework/qs60mainapplication.cpp
diff --git a/src/gui/s60framework/qs60mainapplication.h b/src/widgets/s60framework/qs60mainapplication.h
index 133f69a83d..133f69a83d 100644
--- a/src/gui/s60framework/qs60mainapplication.h
+++ b/src/widgets/s60framework/qs60mainapplication.h
diff --git a/src/gui/s60framework/qs60mainapplication_p.h b/src/widgets/s60framework/qs60mainapplication_p.h
index bb76676b13..bb76676b13 100644
--- a/src/gui/s60framework/qs60mainapplication_p.h
+++ b/src/widgets/s60framework/qs60mainapplication_p.h
diff --git a/src/widgets/s60framework/qs60mainappui.cpp b/src/widgets/s60framework/qs60mainappui.cpp
new file mode 100644
index 0000000000..8a00668f22
--- /dev/null
+++ b/src/widgets/s60framework/qs60mainappui.cpp
@@ -0,0 +1,430 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Symbian application wrapper of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// INCLUDE FILES
+#include <exception>
+#include <qglobal.h>
+#ifdef Q_WS_S60
+#include <avkon.hrh>
+#include <eikmenub.h>
+#include <eikmenup.h>
+#include <avkon.rsg>
+#endif
+#include <barsread.h>
+#include <coeutils.h>
+#include <qconfig.h>
+
+#include "qs60mainappui.h"
+#include <QtWidgets/qapplication.h>
+#include <QtWidgets/qsymbianevent.h>
+#include <QtWidgets/qmenu.h>
+#include <private/qmenu_p.h>
+#include <private/qt_s60_p.h>
+#include <qdebug.h>
+
+//Animated wallpapers in Qt applications are not supported.
+const TInt KAknDisableAnimationBackground = 0x02000000;
+const TInt KAknSingleClickCompatible = 0x01000000;
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QS60MainAppUi
+ \since 4.6
+ \brief The QS60MainAppUi class is a helper class for S60 migration.
+
+ \warning This class is provided only to get access to S60 specific
+ functionality in the application framework classes. It is not
+ portable. We strongly recommend against using it in new applications.
+
+ The QS60MainAppUi provides a helper class for use in migrating from
+ existing S60 based applications to Qt based applications. It is used
+ in the exact same way as the \c CAknAppUi class from Symbian, but
+ internally provides extensions used by Qt.
+
+ When modifying old S60 applications that rely on implementing
+ functions in \c CAknAppUi, the class should be modified to inherit
+ from this class instead of \c CAknAppUi. Then the application can
+ choose to override only certain functions.
+
+ For more information on \c CAknAppUi, please see the S60
+ documentation.
+
+ Unlike other Qt classes, QS60MainAppUi behaves like an S60 class,
+ and can throw Symbian leaves.
+
+ \sa QS60MainDocument, QS60MainApplication
+ */
+
+/*!
+ * \brief Second phase Symbian constructor.
+ *
+ * Constructs all the elements of the class that can cause a leave to happen.
+ *
+ * If you override this function, you should call the base class implementation as well.
+ */
+void QS60MainAppUi::ConstructL()
+{
+ // Cone's heap and handle checks on app destruction are not suitable for Qt apps, as many
+ // objects can still exist in static data at that point. Instead we will print relevant information
+ // so that comparative checks may be made for memory leaks, using ~SPrintExitInfo in corelib.
+ iEikonEnv->DisableExitChecks(ETrue);
+
+ // Initialise app UI with standard value.
+ // ENoAppResourceFile and ENonStandardResourceFile makes UI to work without
+ // resource files in most SDKs. S60 3rd FP1 public seems to require resource file
+ // even these flags are defined
+ TInt flags = CEikAppUi::ENoScreenFurniture
+ | CEikAppUi::ENonStandardResourceFile;
+#ifdef Q_WS_S60
+ flags |= CAknAppUi::EAknEnableSkin;
+ // After 5th Edition S60, native side supports animated wallpapers.
+ // However, there is no support for that feature on Qt side, so indicate to
+ // native UI framework that this application will not support background animations.
+
+ // Also, add support for single touch for post 5th edition platforms.
+ // This has only impact when launching native dialogs/menus from inside QApplication.
+ if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0) {
+ flags |= (KAknDisableAnimationBackground | KAknSingleClickCompatible);
+ }
+#endif
+ BaseConstructL(flags);
+}
+
+/*!
+ * \brief Contructs an instance of QS60MainAppUi.
+ */
+QS60MainAppUi::QS60MainAppUi()
+{
+ // No implementation required
+}
+
+/*!
+ * \brief Destroys the QS60MainAppUi.
+ */
+QS60MainAppUi::~QS60MainAppUi()
+{
+}
+
+/*!
+ * \brief Handles commands produced by the S60 framework.
+ *
+ * \a command holds the ID of the command to handle, and is S60 specific.
+ *
+ * If you override this function, you should call the base class implementation if you do not
+ * handle the command.
+ */
+void QS60MainAppUi::HandleCommandL(TInt command)
+{
+ if (qApp) {
+ QSymbianEvent event(QSymbianEvent::CommandEvent, command);
+ QT_TRYCATCH_LEAVING(qApp->symbianProcessEvent(&event));
+ }
+}
+
+/*!
+ * \brief Handles a resource change in the S60 framework.
+ *
+ * Resource changes include layout switches. \a type holds the type of resource change that
+ * occurred.
+ *
+ * If you override this function, you should call the base class implementation if you do not
+ * handle the resource change.
+ */
+void QS60MainAppUi::HandleResourceChangeL(TInt type)
+{
+ QS60MainAppUiBase::HandleResourceChangeL(type);
+
+ if (qApp) {
+ QSymbianEvent event(QSymbianEvent::ResourceChangeEvent, type);
+ QT_TRYCATCH_LEAVING(qApp->symbianProcessEvent(&event));
+ }
+}
+
+/*!
+ * \brief Handles raw window server events.
+ *
+ * The event type and information is passed in \a wsEvent, while the receiving control is passed in
+ * \a destination.
+ *
+ * If you override this function, you should call the base class implementation if you do not
+ * handle the event.
+ */
+void QS60MainAppUi::HandleWsEventL(const TWsEvent &wsEvent, CCoeControl *destination)
+{
+ int result = 0;
+ if (qApp) {
+ QSymbianEvent event(&wsEvent);
+ QT_TRYCATCH_LEAVING(
+ result = qApp->symbianProcessEvent(&event)
+ );
+ }
+
+ if (result <= 0)
+ QS60MainAppUiBase::HandleWsEventL(wsEvent, destination);
+}
+
+
+/*!
+ * \brief Handles changes to the status pane size.
+ *
+ * Called by the framework when the application status pane size is changed.
+ *
+ * If you override this function, you should call the base class implementation if you do not
+ * handle the size change.
+ */
+void QS60MainAppUi::HandleStatusPaneSizeChange()
+{
+ TRAP_IGNORE(HandleResourceChangeL(KInternalStatusPaneChange));
+ HandleStackedControlsResourceChange(KInternalStatusPaneChange);
+}
+
+/*!
+ * \brief Dynamically initializes a menu bar.
+ *
+ * The resource associated with the menu is given in \a resourceId, and the actual menu bar is
+ * passed in \a menuBar.
+ *
+ * If you override this function, you should call the base class implementation as well.
+ */
+void QS60MainAppUi::DynInitMenuBarL(TInt /* resourceId */, CEikMenuBar * /* menuBar */)
+{
+}
+
+/*!
+ * \brief Dynamically initializes a menu pane.
+ *
+ * The resource associated with the menu is given in \a resourceId, and the actual menu pane is
+ * passed in \a menuPane.
+ *
+ * If you override this function, you should call the base class implementation as well.
+ */
+void QS60MainAppUi::DynInitMenuPaneL(TInt resourceId, CEikMenuPane *menuPane)
+{
+#ifdef Q_WS_S60
+ if (resourceId == R_AVKON_MENUPANE_EMPTY) {
+ if (menuPane->NumberOfItemsInPane() <= 1)
+ QT_TRYCATCH_LEAVING(qt_symbian_show_toplevel(menuPane));
+
+ } else if (resourceId != R_AVKON_MENUPANE_FEP_DEFAULT
+ && resourceId != R_AVKON_MENUPANE_EDITTEXT_DEFAULT
+ && resourceId != R_AVKON_MENUPANE_LANGUAGE_DEFAULT) {
+ QT_TRYCATCH_LEAVING(qt_symbian_show_submenu(menuPane, resourceId));
+ }
+#else
+ QS60MainAppUiBase::DynInitMenuPaneL(resourceId, menuPane);
+#endif
+}
+
+/*!
+ * \brief Restores a menu window.
+ *
+ * The menu window to restore is given in \a menuWindow. The resource ID and type of menu is given
+ * in \a resourceId and \a menuType, respectively.
+ *
+ * If you override this function, you should call the base class implementation as well.
+ */
+void QS60MainAppUi::RestoreMenuL(CCoeControl *menuWindow, TInt resourceId, TMenuType menuType)
+{
+#ifdef Q_WS_S60
+ if (resourceId >= QT_SYMBIAN_FIRST_MENU_ITEM && resourceId <= QT_SYMBIAN_LAST_MENU_ITEM) {
+ if (menuType == EMenuPane)
+ DynInitMenuPaneL(resourceId, (CEikMenuPane*)menuWindow);
+ else
+ DynInitMenuBarL(resourceId, (CEikMenuBar*)menuWindow);
+ } else if(resourceId == R_AVKON_MENUPANE_EMPTY) {
+ CEikMenuBarTitle *title = new(ELeave) CEikMenuBarTitle;
+ CleanupStack::PushL(title);
+
+ title->iData.iMenuPaneResourceId = R_AVKON_MENUPANE_EMPTY;
+ title->iTitleFlags = 0;
+
+ S60->menuBar()->TitleArray()->AddTitleL(title);
+ CleanupStack::Pop( title );
+ }
+ else
+#endif
+ {
+ QS60MainAppUiBase::RestoreMenuL(menuWindow, resourceId, menuType);
+ }
+}
+
+/*!
+ \internal
+*/
+void QS60MainAppUi::Exit()
+{
+ QS60MainAppUiBase::Exit();
+}
+
+/*!
+ \internal
+*/
+void QS60MainAppUi::SetFadedL(TBool aFaded)
+{
+ QS60MainAppUiBase::SetFadedL(aFaded);
+}
+
+/*!
+ \internal
+*/
+TRect QS60MainAppUi::ApplicationRect() const
+{
+ return QS60MainAppUiBase::ApplicationRect();
+}
+
+/*!
+ \internal
+*/
+void QS60MainAppUi::HandleScreenDeviceChangedL()
+{
+ QS60MainAppUiBase::HandleScreenDeviceChangedL();
+}
+
+/*!
+ \internal
+*/
+void QS60MainAppUi::HandleApplicationSpecificEventL(TInt aType, const TWsEvent &aEvent)
+{
+ QS60MainAppUiBase::HandleApplicationSpecificEventL(aType, aEvent);
+}
+
+/*!
+ \internal
+*/
+TTypeUid::Ptr QS60MainAppUi::MopSupplyObject(TTypeUid aId)
+{
+ return QS60MainAppUiBase::MopSupplyObject(aId);
+}
+
+/*!
+ \internal
+*/
+void QS60MainAppUi::ProcessCommandL(TInt aCommand)
+{
+ QS60MainAppUiBase::ProcessCommandL(aCommand);
+}
+
+/*!
+ \internal
+*/
+TErrorHandlerResponse QS60MainAppUi::HandleError (TInt aError, const SExtendedError &aExtErr, TDes &aErrorText, TDes &aContextText)
+{
+ return QS60MainAppUiBase::HandleError(aError, aExtErr, aErrorText, aContextText);
+}
+
+/*!
+ \internal
+*/
+void QS60MainAppUi::HandleViewDeactivation(const TVwsViewId &aViewIdToBeDeactivated, const TVwsViewId &aNewlyActivatedViewId)
+{
+ QS60MainAppUiBase::HandleViewDeactivation(aViewIdToBeDeactivated, aNewlyActivatedViewId);
+}
+
+/*!
+ \internal
+*/
+void QS60MainAppUi::PrepareToExit()
+{
+ QS60MainAppUiBase::PrepareToExit();
+}
+
+/*!
+ \internal
+*/
+void QS60MainAppUi::HandleTouchPaneSizeChange()
+{
+ QS60MainAppUiBase::HandleTouchPaneSizeChange();
+}
+
+/*!
+ \internal
+*/
+void QS60MainAppUi::HandleSystemEventL(const TWsEvent &aEvent)
+{
+ QS60MainAppUiBase::HandleSystemEventL(aEvent);
+}
+
+/*!
+ \internal
+*/
+void QS60MainAppUi::Reserved_MtsmPosition()
+{
+ QS60MainAppUiBase::Reserved_MtsmPosition();
+}
+
+/*!
+ \internal
+*/
+void QS60MainAppUi::Reserved_MtsmObject()
+{
+ QS60MainAppUiBase::Reserved_MtsmObject();
+}
+
+/*!
+ \internal
+*/
+void QS60MainAppUi::HandleForegroundEventL(TBool aForeground)
+{
+ QS60MainAppUiBase::HandleForegroundEventL(aForeground);
+}
+
+/*!
+ \internal
+*/
+TBool QS60MainAppUi::ProcessCommandParametersL(TApaCommand /*aCommand*/, TFileName &/*aDocumentName*/, const TDesC8 &/*aTail*/)
+{
+ // bypass CEikAppUi::ProcessCommandParametersL(..) which modifies aDocumentName, preventing apparc document opening from working.
+ // The return value is effectively unused in Qt apps (see QS60MainDocument::OpenFileL)
+ return EFalse;
+}
+
+#ifndef Q_WS_S60
+
+void QS60StubAknAppUi::HandleViewDeactivation(const TVwsViewId &, const TVwsViewId &) {}
+void QS60StubAknAppUi::HandleTouchPaneSizeChange() {}
+void QS60StubAknAppUi::HandleStatusPaneSizeChange() {}
+void QS60StubAknAppUi::Reserved_MtsmPosition() {}
+void QS60StubAknAppUi::Reserved_MtsmObject() {}
+
+#endif
+
+QT_END_NAMESPACE
diff --git a/src/gui/s60framework/qs60mainappui.h b/src/widgets/s60framework/qs60mainappui.h
index bf118ffbe8..bf118ffbe8 100644
--- a/src/gui/s60framework/qs60mainappui.h
+++ b/src/widgets/s60framework/qs60mainappui.h
diff --git a/src/gui/s60framework/qs60maindocument.cpp b/src/widgets/s60framework/qs60maindocument.cpp
index 37bd55f22e..37bd55f22e 100644
--- a/src/gui/s60framework/qs60maindocument.cpp
+++ b/src/widgets/s60framework/qs60maindocument.cpp
diff --git a/src/gui/s60framework/qs60maindocument.h b/src/widgets/s60framework/qs60maindocument.h
index 16ea92281d..16ea92281d 100644
--- a/src/gui/s60framework/qs60maindocument.h
+++ b/src/widgets/s60framework/qs60maindocument.h
diff --git a/src/gui/s60framework/s60framework.pri b/src/widgets/s60framework/s60framework.pri
index 19525b7fdb..19525b7fdb 100644
--- a/src/gui/s60framework/s60framework.pri
+++ b/src/widgets/s60framework/s60framework.pri
diff --git a/src/gui/s60framework/s60main.rss b/src/widgets/s60framework/s60main.rss
index a38087ddfc..a38087ddfc 100644
--- a/src/gui/s60framework/s60main.rss
+++ b/src/widgets/s60framework/s60main.rss
diff --git a/src/gui/statemachine/qbasickeyeventtransition.cpp b/src/widgets/statemachine/qbasickeyeventtransition.cpp
index 2f1848144c..2f1848144c 100644
--- a/src/gui/statemachine/qbasickeyeventtransition.cpp
+++ b/src/widgets/statemachine/qbasickeyeventtransition.cpp
diff --git a/src/gui/statemachine/qbasickeyeventtransition_p.h b/src/widgets/statemachine/qbasickeyeventtransition_p.h
index 629cae7009..629cae7009 100644
--- a/src/gui/statemachine/qbasickeyeventtransition_p.h
+++ b/src/widgets/statemachine/qbasickeyeventtransition_p.h
diff --git a/src/gui/statemachine/qbasicmouseeventtransition.cpp b/src/widgets/statemachine/qbasicmouseeventtransition.cpp
index d11b537c42..d11b537c42 100644
--- a/src/gui/statemachine/qbasicmouseeventtransition.cpp
+++ b/src/widgets/statemachine/qbasicmouseeventtransition.cpp
diff --git a/src/gui/statemachine/qbasicmouseeventtransition_p.h b/src/widgets/statemachine/qbasicmouseeventtransition_p.h
index 61eefa6cfe..61eefa6cfe 100644
--- a/src/gui/statemachine/qbasicmouseeventtransition_p.h
+++ b/src/widgets/statemachine/qbasicmouseeventtransition_p.h
diff --git a/src/widgets/statemachine/qguistatemachine.cpp b/src/widgets/statemachine/qguistatemachine.cpp
new file mode 100644
index 0000000000..b22bd4a64d
--- /dev/null
+++ b/src/widgets/statemachine/qguistatemachine.cpp
@@ -0,0 +1,500 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/qstatemachine.h>
+
+#ifndef QT_NO_STATEMACHINE
+
+#include <private/qstatemachine_p.h>
+#include <QtGui/qevent.h>
+#include <QtWidgets/qgraphicssceneevent.h>
+
+QT_BEGIN_NAMESPACE
+
+Q_CORE_EXPORT const QStateMachinePrivate::Handler *qcoreStateMachineHandler();
+
+static QEvent *cloneEvent(QEvent *e)
+{
+ switch (e->type()) {
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseButtonDblClick:
+ case QEvent::MouseMove:
+ return new QMouseEvent(*static_cast<QMouseEvent*>(e));
+ case QEvent::KeyPress:
+ case QEvent::KeyRelease:
+ return new QKeyEvent(*static_cast<QKeyEvent*>(e));
+ case QEvent::FocusIn:
+ case QEvent::FocusOut:
+ return new QFocusEvent(*static_cast<QFocusEvent*>(e));
+ case QEvent::Enter:
+ return new QEvent(*e);
+ case QEvent::Leave:
+ return new QEvent(*e);
+ break;
+ case QEvent::Paint:
+ Q_ASSERT_X(false, "cloneEvent()", "not implemented");
+ break;
+ case QEvent::Move:
+ return new QMoveEvent(*static_cast<QMoveEvent*>(e));
+ case QEvent::Resize:
+ return new QResizeEvent(*static_cast<QResizeEvent*>(e));
+ case QEvent::Create:
+ Q_ASSERT_X(false, "cloneEvent()", "not implemented");
+ break;
+ case QEvent::Destroy:
+ Q_ASSERT_X(false, "cloneEvent()", "not implemented");
+ break;
+ case QEvent::Show:
+ return new QShowEvent(*static_cast<QShowEvent*>(e));
+ case QEvent::Hide:
+ return new QHideEvent(*static_cast<QHideEvent*>(e));
+ case QEvent::Close:
+ return new QCloseEvent(*static_cast<QCloseEvent*>(e));
+ case QEvent::Quit:
+ return new QEvent(*e);
+ case QEvent::ParentChange:
+ return new QEvent(*e);
+ case QEvent::ParentAboutToChange:
+ return new QEvent(*e);
+ case QEvent::ThreadChange:
+ return new QEvent(*e);
+
+ case QEvent::WindowActivate:
+ case QEvent::WindowDeactivate:
+ return new QEvent(*e);
+
+ case QEvent::ShowToParent:
+ return new QEvent(*e);
+ case QEvent::HideToParent:
+ return new QEvent(*e);
+#ifndef QT_NO_WHEELEVENT
+ case QEvent::Wheel:
+ return new QWheelEvent(*static_cast<QWheelEvent*>(e));
+#endif //QT_NO_WHEELEVENT
+ case QEvent::WindowTitleChange:
+ return new QEvent(*e);
+ case QEvent::WindowIconChange:
+ return new QEvent(*e);
+ case QEvent::ApplicationWindowIconChange:
+ return new QEvent(*e);
+ case QEvent::ApplicationFontChange:
+ return new QEvent(*e);
+ case QEvent::ApplicationLayoutDirectionChange:
+ return new QEvent(*e);
+ case QEvent::ApplicationPaletteChange:
+ return new QEvent(*e);
+ case QEvent::PaletteChange:
+ return new QEvent(*e);
+ case QEvent::Clipboard:
+ Q_ASSERT_X(false, "cloneEvent()", "not implemented");
+ break;
+ case QEvent::Speech:
+ Q_ASSERT_X(false, "cloneEvent()", "not implemented");
+ break;
+ case QEvent::MetaCall:
+ Q_ASSERT_X(false, "cloneEvent()", "not implemented");
+ break;
+ case QEvent::SockAct:
+ return new QEvent(*e);
+ case QEvent::WinEventAct:
+ return new QEvent(*e);
+ case QEvent::DeferredDelete:
+ return new QEvent(*e);
+#ifndef QT_NO_DRAGANDDROP
+ case QEvent::DragEnter:
+ return new QDragEnterEvent(*static_cast<QDragEnterEvent*>(e));
+ case QEvent::DragMove:
+ return new QDragMoveEvent(*static_cast<QDragMoveEvent*>(e));
+ case QEvent::DragLeave:
+ return new QDragLeaveEvent(*static_cast<QDragLeaveEvent*>(e));
+ case QEvent::Drop:
+ return new QDropEvent(*static_cast<QDragMoveEvent*>(e));
+ case QEvent::DragResponse:
+ return new QDragResponseEvent(*static_cast<QDragResponseEvent*>(e));
+#endif
+ case QEvent::ChildAdded:
+ return new QChildEvent(*static_cast<QChildEvent*>(e));
+ case QEvent::ChildPolished:
+ return new QChildEvent(*static_cast<QChildEvent*>(e));
+ case QEvent::ChildRemoved:
+ return new QChildEvent(*static_cast<QChildEvent*>(e));
+ case QEvent::ShowWindowRequest:
+ return new QEvent(*e);
+ case QEvent::PolishRequest:
+ return new QEvent(*e);
+ case QEvent::Polish:
+ return new QEvent(*e);
+ case QEvent::LayoutRequest:
+ return new QEvent(*e);
+ case QEvent::UpdateRequest:
+ return new QEvent(*e);
+ case QEvent::UpdateLater:
+ return new QEvent(*e);
+
+ case QEvent::EmbeddingControl:
+ return new QEvent(*e);
+ case QEvent::ActivateControl:
+ return new QEvent(*e);
+ case QEvent::DeactivateControl:
+ return new QEvent(*e);
+
+#ifndef QT_NO_CONTEXTMENU
+ case QEvent::ContextMenu:
+ return new QContextMenuEvent(*static_cast<QContextMenuEvent*>(e));
+#endif
+ case QEvent::InputMethod:
+ return new QInputMethodEvent(*static_cast<QInputMethodEvent*>(e));
+ case QEvent::AccessibilityPrepare:
+ return new QEvent(*e);
+#ifndef QT_NO_TABLETEVENT
+ case QEvent::TabletMove:
+ return new QTabletEvent(*static_cast<QTabletEvent*>(e));
+#endif //QT_NO_TABLETEVENT
+ case QEvent::LocaleChange:
+ return new QEvent(*e);
+ case QEvent::LanguageChange:
+ return new QEvent(*e);
+ case QEvent::LayoutDirectionChange:
+ return new QEvent(*e);
+ case QEvent::Style:
+ return new QEvent(*e);
+#ifndef QT_NO_TABLETEVENT
+ case QEvent::TabletPress:
+ return new QTabletEvent(*static_cast<QTabletEvent*>(e));
+ case QEvent::TabletRelease:
+ return new QTabletEvent(*static_cast<QTabletEvent*>(e));
+#endif //QT_NO_TABLETEVENT
+ case QEvent::OkRequest:
+ return new QEvent(*e);
+ case QEvent::HelpRequest:
+ return new QEvent(*e);
+
+ case QEvent::IconDrag:
+ return new QIconDragEvent(*static_cast<QIconDragEvent*>(e));
+
+ case QEvent::FontChange:
+ return new QEvent(*e);
+ case QEvent::EnabledChange:
+ return new QEvent(*e);
+ case QEvent::ActivationChange:
+ return new QEvent(*e);
+ case QEvent::StyleChange:
+ return new QEvent(*e);
+ case QEvent::IconTextChange:
+ return new QEvent(*e);
+ case QEvent::ModifiedChange:
+ return new QEvent(*e);
+ case QEvent::MouseTrackingChange:
+ return new QEvent(*e);
+
+ case QEvent::WindowBlocked:
+ return new QEvent(*e);
+ case QEvent::WindowUnblocked:
+ return new QEvent(*e);
+ case QEvent::WindowStateChange:
+ return new QWindowStateChangeEvent(*static_cast<QWindowStateChangeEvent*>(e));
+
+ case QEvent::ToolTip:
+ return new QHelpEvent(*static_cast<QHelpEvent*>(e));
+ case QEvent::WhatsThis:
+ return new QHelpEvent(*static_cast<QHelpEvent*>(e));
+#ifndef QT_NO_STATUSTIP
+ case QEvent::StatusTip:
+ return new QStatusTipEvent(*static_cast<QStatusTipEvent*>(e));
+#endif //QT_NO_STATUSTIP
+#ifndef QT_NO_ACTION
+ case QEvent::ActionChanged:
+ case QEvent::ActionAdded:
+ case QEvent::ActionRemoved:
+ return new QActionEvent(*static_cast<QActionEvent*>(e));
+#endif
+ case QEvent::FileOpen:
+ return new QFileOpenEvent(*static_cast<QFileOpenEvent*>(e));
+
+#ifndef QT_NO_SHORTCUT
+ case QEvent::Shortcut:
+ return new QShortcutEvent(*static_cast<QShortcutEvent*>(e));
+#endif //QT_NO_SHORTCUT
+ case QEvent::ShortcutOverride:
+ return new QKeyEvent(*static_cast<QKeyEvent*>(e));
+
+#ifndef QT_NO_WHATSTHIS
+ case QEvent::WhatsThisClicked:
+ return new QWhatsThisClickedEvent(*static_cast<QWhatsThisClickedEvent*>(e));
+#endif //QT_NO_WHATSTHIS
+
+#ifndef QT_NO_TOOLBAR
+ case QEvent::ToolBarChange:
+ return new QToolBarChangeEvent(*static_cast<QToolBarChangeEvent*>(e));
+#endif //QT_NO_TOOLBAR
+
+ case QEvent::ApplicationActivate:
+ return new QEvent(*e);
+ case QEvent::ApplicationDeactivate:
+ return new QEvent(*e);
+
+ case QEvent::QueryWhatsThis:
+ return new QHelpEvent(*static_cast<QHelpEvent*>(e));
+ case QEvent::EnterWhatsThisMode:
+ return new QEvent(*e);
+ case QEvent::LeaveWhatsThisMode:
+ return new QEvent(*e);
+
+ case QEvent::ZOrderChange:
+ return new QEvent(*e);
+
+ case QEvent::HoverEnter:
+ case QEvent::HoverLeave:
+ case QEvent::HoverMove:
+ return new QHoverEvent(*static_cast<QHoverEvent*>(e));
+
+ case QEvent::AccessibilityHelp:
+ Q_ASSERT_X(false, "cloneEvent()", "not implemented");
+ break;
+ case QEvent::AccessibilityDescription:
+ Q_ASSERT_X(false, "cloneEvent()", "not implemented");
+ break;
+
+#ifdef QT_KEYPAD_NAVIGATION
+ case QEvent::EnterEditFocus:
+ return new QEvent(*e);
+ case QEvent::LeaveEditFocus:
+ return new QEvent(*e);
+#endif
+ case QEvent::AcceptDropsChange:
+ return new QEvent(*e);
+
+ case QEvent::ZeroTimerEvent:
+ Q_ASSERT_X(false, "cloneEvent()", "not implemented");
+ break;
+#ifndef QT_NO_GRAPHICSVIEW
+ case QEvent::GraphicsSceneMouseMove:
+ case QEvent::GraphicsSceneMousePress:
+ case QEvent::GraphicsSceneMouseRelease:
+ case QEvent::GraphicsSceneMouseDoubleClick: {
+ QGraphicsSceneMouseEvent *me = static_cast<QGraphicsSceneMouseEvent*>(e);
+ QGraphicsSceneMouseEvent *me2 = new QGraphicsSceneMouseEvent(me->type());
+ me2->setWidget(me->widget());
+ me2->setPos(me->pos());
+ me2->setScenePos(me->scenePos());
+ me2->setScreenPos(me->screenPos());
+// ### for all buttons
+ me2->setButtonDownPos(Qt::LeftButton, me->buttonDownPos(Qt::LeftButton));
+ me2->setButtonDownPos(Qt::RightButton, me->buttonDownPos(Qt::RightButton));
+ me2->setButtonDownScreenPos(Qt::LeftButton, me->buttonDownScreenPos(Qt::LeftButton));
+ me2->setButtonDownScreenPos(Qt::RightButton, me->buttonDownScreenPos(Qt::RightButton));
+ me2->setLastPos(me->lastPos());
+ me2->setLastScenePos(me->lastScenePos());
+ me2->setLastScreenPos(me->lastScreenPos());
+ me2->setButtons(me->buttons());
+ me2->setButton(me->button());
+ me2->setModifiers(me->modifiers());
+ return me2;
+ }
+
+ case QEvent::GraphicsSceneContextMenu: {
+ QGraphicsSceneContextMenuEvent *me = static_cast<QGraphicsSceneContextMenuEvent*>(e);
+ QGraphicsSceneContextMenuEvent *me2 = new QGraphicsSceneContextMenuEvent(me->type());
+ me2->setWidget(me->widget());
+ me2->setPos(me->pos());
+ me2->setScenePos(me->scenePos());
+ me2->setScreenPos(me->screenPos());
+ me2->setModifiers(me->modifiers());
+ me2->setReason(me->reason());
+ return me2;
+ }
+
+ case QEvent::GraphicsSceneHoverEnter:
+ case QEvent::GraphicsSceneHoverMove:
+ case QEvent::GraphicsSceneHoverLeave: {
+ QGraphicsSceneHoverEvent *he = static_cast<QGraphicsSceneHoverEvent*>(e);
+ QGraphicsSceneHoverEvent *he2 = new QGraphicsSceneHoverEvent(he->type());
+ he2->setPos(he->pos());
+ he2->setScenePos(he->scenePos());
+ he2->setScreenPos(he->screenPos());
+ he2->setLastPos(he->lastPos());
+ he2->setLastScenePos(he->lastScenePos());
+ he2->setLastScreenPos(he->lastScreenPos());
+ he2->setModifiers(he->modifiers());
+ return he2;
+ }
+ case QEvent::GraphicsSceneHelp:
+ return new QHelpEvent(*static_cast<QHelpEvent*>(e));
+ case QEvent::GraphicsSceneDragEnter:
+ case QEvent::GraphicsSceneDragMove:
+ case QEvent::GraphicsSceneDragLeave:
+ case QEvent::GraphicsSceneDrop: {
+ QGraphicsSceneDragDropEvent *dde = static_cast<QGraphicsSceneDragDropEvent*>(e);
+ QGraphicsSceneDragDropEvent *dde2 = new QGraphicsSceneDragDropEvent(dde->type());
+ dde2->setPos(dde->pos());
+ dde2->setScenePos(dde->scenePos());
+ dde2->setScreenPos(dde->screenPos());
+ dde2->setButtons(dde->buttons());
+ dde2->setModifiers(dde->modifiers());
+ return dde2;
+ }
+ case QEvent::GraphicsSceneWheel: {
+ QGraphicsSceneWheelEvent *we = static_cast<QGraphicsSceneWheelEvent*>(e);
+ QGraphicsSceneWheelEvent *we2 = new QGraphicsSceneWheelEvent(we->type());
+ we2->setPos(we->pos());
+ we2->setScenePos(we->scenePos());
+ we2->setScreenPos(we->screenPos());
+ we2->setButtons(we->buttons());
+ we2->setModifiers(we->modifiers());
+ we2->setOrientation(we->orientation());
+ we2->setDelta(we->delta());
+ return we2;
+ }
+#endif
+ case QEvent::KeyboardLayoutChange:
+ return new QEvent(*e);
+
+ case QEvent::DynamicPropertyChange:
+ return new QDynamicPropertyChangeEvent(*static_cast<QDynamicPropertyChangeEvent*>(e));
+
+#ifndef QT_NO_TABLETEVENT
+ case QEvent::TabletEnterProximity:
+ case QEvent::TabletLeaveProximity:
+ return new QTabletEvent(*static_cast<QTabletEvent*>(e));
+#endif //QT_NO_TABLETEVENT
+
+ case QEvent::NonClientAreaMouseMove:
+ case QEvent::NonClientAreaMouseButtonPress:
+ case QEvent::NonClientAreaMouseButtonRelease:
+ case QEvent::NonClientAreaMouseButtonDblClick:
+ return new QMouseEvent(*static_cast<QMouseEvent*>(e));
+
+ case QEvent::MacSizeChange:
+ return new QEvent(*e);
+
+ case QEvent::ContentsRectChange:
+ return new QEvent(*e);
+
+ case QEvent::MacGLWindowChange:
+ return new QEvent(*e);
+
+ case QEvent::FutureCallOut:
+ Q_ASSERT_X(false, "cloneEvent()", "not implemented");
+ break;
+#ifndef QT_NO_GRAPHICSVIEW
+ case QEvent::GraphicsSceneResize: {
+ QGraphicsSceneResizeEvent *re = static_cast<QGraphicsSceneResizeEvent*>(e);
+ QGraphicsSceneResizeEvent *re2 = new QGraphicsSceneResizeEvent();
+ re2->setOldSize(re->oldSize());
+ re2->setNewSize(re->newSize());
+ return re2;
+ }
+ case QEvent::GraphicsSceneMove: {
+ QGraphicsSceneMoveEvent *me = static_cast<QGraphicsSceneMoveEvent*>(e);
+ QGraphicsSceneMoveEvent *me2 = new QGraphicsSceneMoveEvent();
+ me2->setWidget(me->widget());
+ me2->setNewPos(me->newPos());
+ me2->setOldPos(me->oldPos());
+ return me2;
+ }
+#endif
+ case QEvent::CursorChange:
+ return new QEvent(*e);
+ case QEvent::ToolTipChange:
+ return new QEvent(*e);
+
+ case QEvent::NetworkReplyUpdated:
+ Q_ASSERT_X(false, "cloneEvent()", "not implemented");
+ break;
+
+ case QEvent::GrabMouse:
+ case QEvent::UngrabMouse:
+ case QEvent::GrabKeyboard:
+ case QEvent::UngrabKeyboard:
+ return new QEvent(*e);
+
+ case QEvent::TouchBegin:
+ case QEvent::TouchUpdate:
+ case QEvent::TouchEnd:
+ return new QTouchEvent(*static_cast<QTouchEvent*>(e));
+
+#ifndef QT_NO_GESTURES
+ case QEvent::NativeGesture:
+ Q_ASSERT_X(false, "cloneEvent()", "not implemented");
+ break;
+#endif
+
+ case QEvent::RequestSoftwareInputPanel:
+ case QEvent::CloseSoftwareInputPanel:
+ return new QEvent(*e);
+
+ case QEvent::UpdateSoftKeys:
+ return new QEvent(*e);
+
+ case QEvent::User:
+ case QEvent::MaxUser:
+ Q_ASSERT_X(false, "cloneEvent()", "not implemented");
+ break;
+ default:
+ ;
+ }
+ return qcoreStateMachineHandler()->cloneEvent(e);
+}
+
+const QStateMachinePrivate::Handler qt_gui_statemachine_handler = {
+ cloneEvent
+};
+
+static const QStateMachinePrivate::Handler *qt_guistatemachine_last_handler = 0;
+int qRegisterGuiStateMachine()
+{
+ qt_guistatemachine_last_handler = QStateMachinePrivate::handler;
+ QStateMachinePrivate::handler = &qt_gui_statemachine_handler;
+ return 1;
+}
+Q_CONSTRUCTOR_FUNCTION(qRegisterGuiStateMachine)
+
+int qUnregisterGuiStateMachine()
+{
+ QStateMachinePrivate::handler = qt_guistatemachine_last_handler;
+ return 1;
+}
+Q_DESTRUCTOR_FUNCTION(qUnregisterGuiStateMachine)
+
+QT_END_NAMESPACE
+
+#endif //QT_NO_STATEMACHINE
diff --git a/src/gui/statemachine/qkeyeventtransition.cpp b/src/widgets/statemachine/qkeyeventtransition.cpp
index 65af91b382..65af91b382 100644
--- a/src/gui/statemachine/qkeyeventtransition.cpp
+++ b/src/widgets/statemachine/qkeyeventtransition.cpp
diff --git a/src/gui/statemachine/qkeyeventtransition.h b/src/widgets/statemachine/qkeyeventtransition.h
index 2bc47e4178..2bc47e4178 100644
--- a/src/gui/statemachine/qkeyeventtransition.h
+++ b/src/widgets/statemachine/qkeyeventtransition.h
diff --git a/src/gui/statemachine/qmouseeventtransition.cpp b/src/widgets/statemachine/qmouseeventtransition.cpp
index 3ecf1e2fa8..3ecf1e2fa8 100644
--- a/src/gui/statemachine/qmouseeventtransition.cpp
+++ b/src/widgets/statemachine/qmouseeventtransition.cpp
diff --git a/src/gui/statemachine/qmouseeventtransition.h b/src/widgets/statemachine/qmouseeventtransition.h
index 8be10c8513..8be10c8513 100644
--- a/src/gui/statemachine/qmouseeventtransition.h
+++ b/src/widgets/statemachine/qmouseeventtransition.h
diff --git a/src/gui/statemachine/statemachine.pri b/src/widgets/statemachine/statemachine.pri
index 2eb1e05be6..2eb1e05be6 100644
--- a/src/gui/statemachine/statemachine.pri
+++ b/src/widgets/statemachine/statemachine.pri
diff --git a/src/gui/styles/images/cdr-128.png b/src/widgets/styles/images/cdr-128.png
index c5daa15fc8..c5daa15fc8 100644
--- a/src/gui/styles/images/cdr-128.png
+++ b/src/widgets/styles/images/cdr-128.png
Binary files differ
diff --git a/src/gui/styles/images/cdr-16.png b/src/widgets/styles/images/cdr-16.png
index 82d7533bd1..82d7533bd1 100644
--- a/src/gui/styles/images/cdr-16.png
+++ b/src/widgets/styles/images/cdr-16.png
Binary files differ
diff --git a/src/gui/styles/images/cdr-32.png b/src/widgets/styles/images/cdr-32.png
index dcfb085da5..dcfb085da5 100644
--- a/src/gui/styles/images/cdr-32.png
+++ b/src/widgets/styles/images/cdr-32.png
Binary files differ
diff --git a/src/gui/styles/images/closedock-16.png b/src/widgets/styles/images/closedock-16.png
index ab9d669eee..ab9d669eee 100644
--- a/src/gui/styles/images/closedock-16.png
+++ b/src/widgets/styles/images/closedock-16.png
Binary files differ
diff --git a/src/gui/styles/images/closedock-down-16.png b/src/widgets/styles/images/closedock-down-16.png
index c1791dd2cc..c1791dd2cc 100644
--- a/src/gui/styles/images/closedock-down-16.png
+++ b/src/widgets/styles/images/closedock-down-16.png
Binary files differ
diff --git a/src/gui/styles/images/computer-16.png b/src/widgets/styles/images/computer-16.png
index 43fb0bb581..43fb0bb581 100644
--- a/src/gui/styles/images/computer-16.png
+++ b/src/widgets/styles/images/computer-16.png
Binary files differ
diff --git a/src/gui/styles/images/computer-32.png b/src/widgets/styles/images/computer-32.png
index 6d750ce89b..6d750ce89b 100644
--- a/src/gui/styles/images/computer-32.png
+++ b/src/widgets/styles/images/computer-32.png
Binary files differ
diff --git a/src/gui/styles/images/defaults60theme.blob b/src/widgets/styles/images/defaults60theme.blob
index f3a59528d6..f3a59528d6 100644
--- a/src/gui/styles/images/defaults60theme.blob
+++ b/src/widgets/styles/images/defaults60theme.blob
Binary files differ
diff --git a/src/gui/styles/images/desktop-16.png b/src/widgets/styles/images/desktop-16.png
index d612dfb0fc..d612dfb0fc 100644
--- a/src/gui/styles/images/desktop-16.png
+++ b/src/widgets/styles/images/desktop-16.png
Binary files differ
diff --git a/src/gui/styles/images/desktop-32.png b/src/widgets/styles/images/desktop-32.png
index ad85b48d3a..ad85b48d3a 100644
--- a/src/gui/styles/images/desktop-32.png
+++ b/src/widgets/styles/images/desktop-32.png
Binary files differ
diff --git a/src/gui/styles/images/dirclosed-128.png b/src/widgets/styles/images/dirclosed-128.png
index e4fa843162..e4fa843162 100644
--- a/src/gui/styles/images/dirclosed-128.png
+++ b/src/widgets/styles/images/dirclosed-128.png
Binary files differ
diff --git a/src/gui/styles/images/dirclosed-16.png b/src/widgets/styles/images/dirclosed-16.png
index 333fe8eaac..333fe8eaac 100644
--- a/src/gui/styles/images/dirclosed-16.png
+++ b/src/widgets/styles/images/dirclosed-16.png
Binary files differ
diff --git a/src/gui/styles/images/dirclosed-32.png b/src/widgets/styles/images/dirclosed-32.png
index 3add907ed5..3add907ed5 100644
--- a/src/gui/styles/images/dirclosed-32.png
+++ b/src/widgets/styles/images/dirclosed-32.png
Binary files differ
diff --git a/src/gui/styles/images/dirlink-128.png b/src/widgets/styles/images/dirlink-128.png
index ec299f8e52..ec299f8e52 100644
--- a/src/gui/styles/images/dirlink-128.png
+++ b/src/widgets/styles/images/dirlink-128.png
Binary files differ
diff --git a/src/gui/styles/images/dirlink-16.png b/src/widgets/styles/images/dirlink-16.png
index 9f16cd3520..9f16cd3520 100644
--- a/src/gui/styles/images/dirlink-16.png
+++ b/src/widgets/styles/images/dirlink-16.png
Binary files differ
diff --git a/src/gui/styles/images/dirlink-32.png b/src/widgets/styles/images/dirlink-32.png
index 776536d131..776536d131 100644
--- a/src/gui/styles/images/dirlink-32.png
+++ b/src/widgets/styles/images/dirlink-32.png
Binary files differ
diff --git a/src/gui/styles/images/diropen-128.png b/src/widgets/styles/images/diropen-128.png
index b91c4af72a..b91c4af72a 100644
--- a/src/gui/styles/images/diropen-128.png
+++ b/src/widgets/styles/images/diropen-128.png
Binary files differ
diff --git a/src/gui/styles/images/diropen-16.png b/src/widgets/styles/images/diropen-16.png
index 95f0771d06..95f0771d06 100644
--- a/src/gui/styles/images/diropen-16.png
+++ b/src/widgets/styles/images/diropen-16.png
Binary files differ
diff --git a/src/gui/styles/images/diropen-32.png b/src/widgets/styles/images/diropen-32.png
index af5f7e7e81..af5f7e7e81 100644
--- a/src/gui/styles/images/diropen-32.png
+++ b/src/widgets/styles/images/diropen-32.png
Binary files differ
diff --git a/src/gui/styles/images/dockdock-16.png b/src/widgets/styles/images/dockdock-16.png
index 4ac9483176..4ac9483176 100644
--- a/src/gui/styles/images/dockdock-16.png
+++ b/src/widgets/styles/images/dockdock-16.png
Binary files differ
diff --git a/src/gui/styles/images/dockdock-down-16.png b/src/widgets/styles/images/dockdock-down-16.png
index 2e85a679be..2e85a679be 100644
--- a/src/gui/styles/images/dockdock-down-16.png
+++ b/src/widgets/styles/images/dockdock-down-16.png
Binary files differ
diff --git a/src/gui/styles/images/down-128.png b/src/widgets/styles/images/down-128.png
index 09dfe43a93..09dfe43a93 100644
--- a/src/gui/styles/images/down-128.png
+++ b/src/widgets/styles/images/down-128.png
Binary files differ
diff --git a/src/gui/styles/images/down-16.png b/src/widgets/styles/images/down-16.png
index c60a174e25..c60a174e25 100644
--- a/src/gui/styles/images/down-16.png
+++ b/src/widgets/styles/images/down-16.png
Binary files differ
diff --git a/src/gui/styles/images/down-32.png b/src/widgets/styles/images/down-32.png
index 46eadb8e12..46eadb8e12 100644
--- a/src/gui/styles/images/down-32.png
+++ b/src/widgets/styles/images/down-32.png
Binary files differ
diff --git a/src/gui/styles/images/dvd-128.png b/src/widgets/styles/images/dvd-128.png
index 9ed9dc1e55..9ed9dc1e55 100644
--- a/src/gui/styles/images/dvd-128.png
+++ b/src/widgets/styles/images/dvd-128.png
Binary files differ
diff --git a/src/gui/styles/images/dvd-16.png b/src/widgets/styles/images/dvd-16.png
index 623386d4ca..623386d4ca 100644
--- a/src/gui/styles/images/dvd-16.png
+++ b/src/widgets/styles/images/dvd-16.png
Binary files differ
diff --git a/src/gui/styles/images/dvd-32.png b/src/widgets/styles/images/dvd-32.png
index 089b72accb..089b72accb 100644
--- a/src/gui/styles/images/dvd-32.png
+++ b/src/widgets/styles/images/dvd-32.png
Binary files differ
diff --git a/src/gui/styles/images/file-128.png b/src/widgets/styles/images/file-128.png
index 46e6ceb49a..46e6ceb49a 100644
--- a/src/gui/styles/images/file-128.png
+++ b/src/widgets/styles/images/file-128.png
Binary files differ
diff --git a/src/gui/styles/images/file-16.png b/src/widgets/styles/images/file-16.png
index 664b56356b..664b56356b 100644
--- a/src/gui/styles/images/file-16.png
+++ b/src/widgets/styles/images/file-16.png
Binary files differ
diff --git a/src/gui/styles/images/file-32.png b/src/widgets/styles/images/file-32.png
index 83e5c3d311..83e5c3d311 100644
--- a/src/gui/styles/images/file-32.png
+++ b/src/widgets/styles/images/file-32.png
Binary files differ
diff --git a/src/gui/styles/images/filecontents-128.png b/src/widgets/styles/images/filecontents-128.png
index 50e0a838e2..50e0a838e2 100644
--- a/src/gui/styles/images/filecontents-128.png
+++ b/src/widgets/styles/images/filecontents-128.png
Binary files differ
diff --git a/src/gui/styles/images/filecontents-16.png b/src/widgets/styles/images/filecontents-16.png
index b9399ccf2e..b9399ccf2e 100644
--- a/src/gui/styles/images/filecontents-16.png
+++ b/src/widgets/styles/images/filecontents-16.png
Binary files differ
diff --git a/src/gui/styles/images/filecontents-32.png b/src/widgets/styles/images/filecontents-32.png
index 3761f70690..3761f70690 100644
--- a/src/gui/styles/images/filecontents-32.png
+++ b/src/widgets/styles/images/filecontents-32.png
Binary files differ
diff --git a/src/gui/styles/images/fileinfo-128.png b/src/widgets/styles/images/fileinfo-128.png
index 8c5b331876..8c5b331876 100644
--- a/src/gui/styles/images/fileinfo-128.png
+++ b/src/widgets/styles/images/fileinfo-128.png
Binary files differ
diff --git a/src/gui/styles/images/fileinfo-16.png b/src/widgets/styles/images/fileinfo-16.png
index 729be4d5f2..729be4d5f2 100644
--- a/src/gui/styles/images/fileinfo-16.png
+++ b/src/widgets/styles/images/fileinfo-16.png
Binary files differ
diff --git a/src/gui/styles/images/fileinfo-32.png b/src/widgets/styles/images/fileinfo-32.png
index ca795aa49b..ca795aa49b 100644
--- a/src/gui/styles/images/fileinfo-32.png
+++ b/src/widgets/styles/images/fileinfo-32.png
Binary files differ
diff --git a/src/gui/styles/images/filelink-128.png b/src/widgets/styles/images/filelink-128.png
index be86a82901..be86a82901 100644
--- a/src/gui/styles/images/filelink-128.png
+++ b/src/widgets/styles/images/filelink-128.png
Binary files differ
diff --git a/src/gui/styles/images/filelink-16.png b/src/widgets/styles/images/filelink-16.png
index 6643f2c428..6643f2c428 100644
--- a/src/gui/styles/images/filelink-16.png
+++ b/src/widgets/styles/images/filelink-16.png
Binary files differ
diff --git a/src/gui/styles/images/filelink-32.png b/src/widgets/styles/images/filelink-32.png
index 1e46fdc13c..1e46fdc13c 100644
--- a/src/gui/styles/images/filelink-32.png
+++ b/src/widgets/styles/images/filelink-32.png
Binary files differ
diff --git a/src/gui/styles/images/floppy-128.png b/src/widgets/styles/images/floppy-128.png
index fa7a3e1334..fa7a3e1334 100644
--- a/src/gui/styles/images/floppy-128.png
+++ b/src/widgets/styles/images/floppy-128.png
Binary files differ
diff --git a/src/gui/styles/images/floppy-16.png b/src/widgets/styles/images/floppy-16.png
index 91c59c567d..91c59c567d 100644
--- a/src/gui/styles/images/floppy-16.png
+++ b/src/widgets/styles/images/floppy-16.png
Binary files differ
diff --git a/src/gui/styles/images/floppy-32.png b/src/widgets/styles/images/floppy-32.png
index e63b3213bf..e63b3213bf 100644
--- a/src/gui/styles/images/floppy-32.png
+++ b/src/widgets/styles/images/floppy-32.png
Binary files differ
diff --git a/src/gui/styles/images/fontbitmap-16.png b/src/widgets/styles/images/fontbitmap-16.png
index 03efc9cbab..03efc9cbab 100644
--- a/src/gui/styles/images/fontbitmap-16.png
+++ b/src/widgets/styles/images/fontbitmap-16.png
Binary files differ
diff --git a/src/gui/styles/images/fonttruetype-16.png b/src/widgets/styles/images/fonttruetype-16.png
index 25205021e9..25205021e9 100644
--- a/src/gui/styles/images/fonttruetype-16.png
+++ b/src/widgets/styles/images/fonttruetype-16.png
Binary files differ
diff --git a/src/gui/styles/images/harddrive-128.png b/src/widgets/styles/images/harddrive-128.png
index 0b73d9de1e..0b73d9de1e 100644
--- a/src/gui/styles/images/harddrive-128.png
+++ b/src/widgets/styles/images/harddrive-128.png
Binary files differ
diff --git a/src/gui/styles/images/harddrive-16.png b/src/widgets/styles/images/harddrive-16.png
index 45d592baa3..45d592baa3 100644
--- a/src/gui/styles/images/harddrive-16.png
+++ b/src/widgets/styles/images/harddrive-16.png
Binary files differ
diff --git a/src/gui/styles/images/harddrive-32.png b/src/widgets/styles/images/harddrive-32.png
index 7041452b68..7041452b68 100644
--- a/src/gui/styles/images/harddrive-32.png
+++ b/src/widgets/styles/images/harddrive-32.png
Binary files differ
diff --git a/src/gui/styles/images/left-128.png b/src/widgets/styles/images/left-128.png
index a26a5195f8..a26a5195f8 100644
--- a/src/gui/styles/images/left-128.png
+++ b/src/widgets/styles/images/left-128.png
Binary files differ
diff --git a/src/gui/styles/images/left-16.png b/src/widgets/styles/images/left-16.png
index 110dd90f2d..110dd90f2d 100644
--- a/src/gui/styles/images/left-16.png
+++ b/src/widgets/styles/images/left-16.png
Binary files differ
diff --git a/src/gui/styles/images/left-32.png b/src/widgets/styles/images/left-32.png
index ec4107b372..ec4107b372 100644
--- a/src/gui/styles/images/left-32.png
+++ b/src/widgets/styles/images/left-32.png
Binary files differ
diff --git a/src/gui/styles/images/media-pause-16.png b/src/widgets/styles/images/media-pause-16.png
index 6cb1fd7f63..6cb1fd7f63 100644
--- a/src/gui/styles/images/media-pause-16.png
+++ b/src/widgets/styles/images/media-pause-16.png
Binary files differ
diff --git a/src/gui/styles/images/media-pause-32.png b/src/widgets/styles/images/media-pause-32.png
index 3f172a04d6..3f172a04d6 100644
--- a/src/gui/styles/images/media-pause-32.png
+++ b/src/widgets/styles/images/media-pause-32.png
Binary files differ
diff --git a/src/gui/styles/images/media-play-16.png b/src/widgets/styles/images/media-play-16.png
index d7ee3ccbe3..d7ee3ccbe3 100644
--- a/src/gui/styles/images/media-play-16.png
+++ b/src/widgets/styles/images/media-play-16.png
Binary files differ
diff --git a/src/gui/styles/images/media-play-32.png b/src/widgets/styles/images/media-play-32.png
index af8d2f7ba5..af8d2f7ba5 100644
--- a/src/gui/styles/images/media-play-32.png
+++ b/src/widgets/styles/images/media-play-32.png
Binary files differ
diff --git a/src/gui/styles/images/media-seek-backward-16.png b/src/widgets/styles/images/media-seek-backward-16.png
index b8a8ea42d1..b8a8ea42d1 100644
--- a/src/gui/styles/images/media-seek-backward-16.png
+++ b/src/widgets/styles/images/media-seek-backward-16.png
Binary files differ
diff --git a/src/gui/styles/images/media-seek-backward-32.png b/src/widgets/styles/images/media-seek-backward-32.png
index a21d1372fe..a21d1372fe 100644
--- a/src/gui/styles/images/media-seek-backward-32.png
+++ b/src/widgets/styles/images/media-seek-backward-32.png
Binary files differ
diff --git a/src/gui/styles/images/media-seek-forward-16.png b/src/widgets/styles/images/media-seek-forward-16.png
index 3c900dcb62..3c900dcb62 100644
--- a/src/gui/styles/images/media-seek-forward-16.png
+++ b/src/widgets/styles/images/media-seek-forward-16.png
Binary files differ
diff --git a/src/gui/styles/images/media-seek-forward-32.png b/src/widgets/styles/images/media-seek-forward-32.png
index 4f8d370fa1..4f8d370fa1 100644
--- a/src/gui/styles/images/media-seek-forward-32.png
+++ b/src/widgets/styles/images/media-seek-forward-32.png
Binary files differ
diff --git a/src/gui/styles/images/media-skip-backward-16.png b/src/widgets/styles/images/media-skip-backward-16.png
index f5b3f4f56d..f5b3f4f56d 100644
--- a/src/gui/styles/images/media-skip-backward-16.png
+++ b/src/widgets/styles/images/media-skip-backward-16.png
Binary files differ
diff --git a/src/gui/styles/images/media-skip-backward-32.png b/src/widgets/styles/images/media-skip-backward-32.png
index 1d338035ef..1d338035ef 100644
--- a/src/gui/styles/images/media-skip-backward-32.png
+++ b/src/widgets/styles/images/media-skip-backward-32.png
Binary files differ
diff --git a/src/gui/styles/images/media-skip-forward-16.png b/src/widgets/styles/images/media-skip-forward-16.png
index 27e205b02f..27e205b02f 100644
--- a/src/gui/styles/images/media-skip-forward-16.png
+++ b/src/widgets/styles/images/media-skip-forward-16.png
Binary files differ
diff --git a/src/gui/styles/images/media-skip-forward-32.png b/src/widgets/styles/images/media-skip-forward-32.png
index a583fa1b11..a583fa1b11 100644
--- a/src/gui/styles/images/media-skip-forward-32.png
+++ b/src/widgets/styles/images/media-skip-forward-32.png
Binary files differ
diff --git a/src/gui/styles/images/media-stop-16.png b/src/widgets/styles/images/media-stop-16.png
index 9ce035d696..9ce035d696 100644
--- a/src/gui/styles/images/media-stop-16.png
+++ b/src/widgets/styles/images/media-stop-16.png
Binary files differ
diff --git a/src/gui/styles/images/media-stop-32.png b/src/widgets/styles/images/media-stop-32.png
index aae24ba925..aae24ba925 100644
--- a/src/gui/styles/images/media-stop-32.png
+++ b/src/widgets/styles/images/media-stop-32.png
Binary files differ
diff --git a/src/gui/styles/images/media-volume-16.png b/src/widgets/styles/images/media-volume-16.png
index ad258340f2..ad258340f2 100644
--- a/src/gui/styles/images/media-volume-16.png
+++ b/src/widgets/styles/images/media-volume-16.png
Binary files differ
diff --git a/src/gui/styles/images/media-volume-muted-16.png b/src/widgets/styles/images/media-volume-muted-16.png
index 06bded21e7..06bded21e7 100644
--- a/src/gui/styles/images/media-volume-muted-16.png
+++ b/src/widgets/styles/images/media-volume-muted-16.png
Binary files differ
diff --git a/src/gui/styles/images/networkdrive-128.png b/src/widgets/styles/images/networkdrive-128.png
index fd4a59c6bd..fd4a59c6bd 100644
--- a/src/gui/styles/images/networkdrive-128.png
+++ b/src/widgets/styles/images/networkdrive-128.png
Binary files differ
diff --git a/src/gui/styles/images/networkdrive-16.png b/src/widgets/styles/images/networkdrive-16.png
index 1bc62f766a..1bc62f766a 100644
--- a/src/gui/styles/images/networkdrive-16.png
+++ b/src/widgets/styles/images/networkdrive-16.png
Binary files differ
diff --git a/src/gui/styles/images/networkdrive-32.png b/src/widgets/styles/images/networkdrive-32.png
index 6a389dcae4..6a389dcae4 100644
--- a/src/gui/styles/images/networkdrive-32.png
+++ b/src/widgets/styles/images/networkdrive-32.png
Binary files differ
diff --git a/src/gui/styles/images/newdirectory-128.png b/src/widgets/styles/images/newdirectory-128.png
index fdbee27688..fdbee27688 100644
--- a/src/gui/styles/images/newdirectory-128.png
+++ b/src/widgets/styles/images/newdirectory-128.png
Binary files differ
diff --git a/src/gui/styles/images/newdirectory-16.png b/src/widgets/styles/images/newdirectory-16.png
index 6c9f80318b..6c9f80318b 100644
--- a/src/gui/styles/images/newdirectory-16.png
+++ b/src/widgets/styles/images/newdirectory-16.png
Binary files differ
diff --git a/src/gui/styles/images/newdirectory-32.png b/src/widgets/styles/images/newdirectory-32.png
index 4fd0329216..4fd0329216 100644
--- a/src/gui/styles/images/newdirectory-32.png
+++ b/src/widgets/styles/images/newdirectory-32.png
Binary files differ
diff --git a/src/gui/styles/images/parentdir-128.png b/src/widgets/styles/images/parentdir-128.png
index 84d14ab079..84d14ab079 100644
--- a/src/gui/styles/images/parentdir-128.png
+++ b/src/widgets/styles/images/parentdir-128.png
Binary files differ
diff --git a/src/gui/styles/images/parentdir-16.png b/src/widgets/styles/images/parentdir-16.png
index 665f8280f2..665f8280f2 100644
--- a/src/gui/styles/images/parentdir-16.png
+++ b/src/widgets/styles/images/parentdir-16.png
Binary files differ
diff --git a/src/gui/styles/images/parentdir-32.png b/src/widgets/styles/images/parentdir-32.png
index 44f3c4876d..44f3c4876d 100644
--- a/src/gui/styles/images/parentdir-32.png
+++ b/src/widgets/styles/images/parentdir-32.png
Binary files differ
diff --git a/src/gui/styles/images/refresh-24.png b/src/widgets/styles/images/refresh-24.png
index 4c9b72c489..4c9b72c489 100644
--- a/src/gui/styles/images/refresh-24.png
+++ b/src/widgets/styles/images/refresh-24.png
Binary files differ
diff --git a/src/gui/styles/images/refresh-32.png b/src/widgets/styles/images/refresh-32.png
index eecde4b8f9..eecde4b8f9 100644
--- a/src/gui/styles/images/refresh-32.png
+++ b/src/widgets/styles/images/refresh-32.png
Binary files differ
diff --git a/src/gui/styles/images/right-128.png b/src/widgets/styles/images/right-128.png
index 14b1cfd8eb..14b1cfd8eb 100644
--- a/src/gui/styles/images/right-128.png
+++ b/src/widgets/styles/images/right-128.png
Binary files differ
diff --git a/src/gui/styles/images/right-16.png b/src/widgets/styles/images/right-16.png
index 81ca628ff6..81ca628ff6 100644
--- a/src/gui/styles/images/right-16.png
+++ b/src/widgets/styles/images/right-16.png
Binary files differ
diff --git a/src/gui/styles/images/right-32.png b/src/widgets/styles/images/right-32.png
index 0f6ba8608b..0f6ba8608b 100644
--- a/src/gui/styles/images/right-32.png
+++ b/src/widgets/styles/images/right-32.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-apply-128.png b/src/widgets/styles/images/standardbutton-apply-128.png
index 85f07a57ef..85f07a57ef 100644
--- a/src/gui/styles/images/standardbutton-apply-128.png
+++ b/src/widgets/styles/images/standardbutton-apply-128.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-apply-16.png b/src/widgets/styles/images/standardbutton-apply-16.png
index 8f11ce6504..8f11ce6504 100644
--- a/src/gui/styles/images/standardbutton-apply-16.png
+++ b/src/widgets/styles/images/standardbutton-apply-16.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-apply-32.png b/src/widgets/styles/images/standardbutton-apply-32.png
index e8f7853a1e..e8f7853a1e 100644
--- a/src/gui/styles/images/standardbutton-apply-32.png
+++ b/src/widgets/styles/images/standardbutton-apply-32.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-cancel-128.png b/src/widgets/styles/images/standardbutton-cancel-128.png
index 16d857030f..16d857030f 100644
--- a/src/gui/styles/images/standardbutton-cancel-128.png
+++ b/src/widgets/styles/images/standardbutton-cancel-128.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-cancel-16.png b/src/widgets/styles/images/standardbutton-cancel-16.png
index 7bd25bd7c7..7bd25bd7c7 100644
--- a/src/gui/styles/images/standardbutton-cancel-16.png
+++ b/src/widgets/styles/images/standardbutton-cancel-16.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-cancel-32.png b/src/widgets/styles/images/standardbutton-cancel-32.png
index 64a78727a1..64a78727a1 100644
--- a/src/gui/styles/images/standardbutton-cancel-32.png
+++ b/src/widgets/styles/images/standardbutton-cancel-32.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-clear-128.png b/src/widgets/styles/images/standardbutton-clear-128.png
index 107aea2234..107aea2234 100644
--- a/src/gui/styles/images/standardbutton-clear-128.png
+++ b/src/widgets/styles/images/standardbutton-clear-128.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-clear-16.png b/src/widgets/styles/images/standardbutton-clear-16.png
index 5359134c72..5359134c72 100644
--- a/src/gui/styles/images/standardbutton-clear-16.png
+++ b/src/widgets/styles/images/standardbutton-clear-16.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-clear-32.png b/src/widgets/styles/images/standardbutton-clear-32.png
index 8b85d6b7b3..8b85d6b7b3 100644
--- a/src/gui/styles/images/standardbutton-clear-32.png
+++ b/src/widgets/styles/images/standardbutton-clear-32.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-close-128.png b/src/widgets/styles/images/standardbutton-close-128.png
index 571aeae2bd..571aeae2bd 100644
--- a/src/gui/styles/images/standardbutton-close-128.png
+++ b/src/widgets/styles/images/standardbutton-close-128.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-close-16.png b/src/widgets/styles/images/standardbutton-close-16.png
index e9e481987a..e9e481987a 100644
--- a/src/gui/styles/images/standardbutton-close-16.png
+++ b/src/widgets/styles/images/standardbutton-close-16.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-close-32.png b/src/widgets/styles/images/standardbutton-close-32.png
index 47e5733062..47e5733062 100644
--- a/src/gui/styles/images/standardbutton-close-32.png
+++ b/src/widgets/styles/images/standardbutton-close-32.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-closetab-16.png b/src/widgets/styles/images/standardbutton-closetab-16.png
index 540694eae3..540694eae3 100644
--- a/src/gui/styles/images/standardbutton-closetab-16.png
+++ b/src/widgets/styles/images/standardbutton-closetab-16.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-closetab-down-16.png b/src/widgets/styles/images/standardbutton-closetab-down-16.png
index ccec241652..ccec241652 100644
--- a/src/gui/styles/images/standardbutton-closetab-down-16.png
+++ b/src/widgets/styles/images/standardbutton-closetab-down-16.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-closetab-hover-16.png b/src/widgets/styles/images/standardbutton-closetab-hover-16.png
index b22a0ffaf0..b22a0ffaf0 100644
--- a/src/gui/styles/images/standardbutton-closetab-hover-16.png
+++ b/src/widgets/styles/images/standardbutton-closetab-hover-16.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-delete-128.png b/src/widgets/styles/images/standardbutton-delete-128.png
index 11947ba681..11947ba681 100644
--- a/src/gui/styles/images/standardbutton-delete-128.png
+++ b/src/widgets/styles/images/standardbutton-delete-128.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-delete-16.png b/src/widgets/styles/images/standardbutton-delete-16.png
index 63fe93fe98..63fe93fe98 100644
--- a/src/gui/styles/images/standardbutton-delete-16.png
+++ b/src/widgets/styles/images/standardbutton-delete-16.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-delete-32.png b/src/widgets/styles/images/standardbutton-delete-32.png
index 336d965d1c..336d965d1c 100644
--- a/src/gui/styles/images/standardbutton-delete-32.png
+++ b/src/widgets/styles/images/standardbutton-delete-32.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-help-128.png b/src/widgets/styles/images/standardbutton-help-128.png
index aa38e6fdfb..aa38e6fdfb 100644
--- a/src/gui/styles/images/standardbutton-help-128.png
+++ b/src/widgets/styles/images/standardbutton-help-128.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-help-16.png b/src/widgets/styles/images/standardbutton-help-16.png
index e8299418da..e8299418da 100644
--- a/src/gui/styles/images/standardbutton-help-16.png
+++ b/src/widgets/styles/images/standardbutton-help-16.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-help-32.png b/src/widgets/styles/images/standardbutton-help-32.png
index 310056a632..310056a632 100644
--- a/src/gui/styles/images/standardbutton-help-32.png
+++ b/src/widgets/styles/images/standardbutton-help-32.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-no-128.png b/src/widgets/styles/images/standardbutton-no-128.png
index 491c048ebd..491c048ebd 100644
--- a/src/gui/styles/images/standardbutton-no-128.png
+++ b/src/widgets/styles/images/standardbutton-no-128.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-no-16.png b/src/widgets/styles/images/standardbutton-no-16.png
index 812d3f57dd..812d3f57dd 100644
--- a/src/gui/styles/images/standardbutton-no-16.png
+++ b/src/widgets/styles/images/standardbutton-no-16.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-no-32.png b/src/widgets/styles/images/standardbutton-no-32.png
index 9548d59196..9548d59196 100644
--- a/src/gui/styles/images/standardbutton-no-32.png
+++ b/src/widgets/styles/images/standardbutton-no-32.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-ok-128.png b/src/widgets/styles/images/standardbutton-ok-128.png
index 63cc5279ae..63cc5279ae 100644
--- a/src/gui/styles/images/standardbutton-ok-128.png
+++ b/src/widgets/styles/images/standardbutton-ok-128.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-ok-16.png b/src/widgets/styles/images/standardbutton-ok-16.png
index fb4b4dbf96..fb4b4dbf96 100644
--- a/src/gui/styles/images/standardbutton-ok-16.png
+++ b/src/widgets/styles/images/standardbutton-ok-16.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-ok-32.png b/src/widgets/styles/images/standardbutton-ok-32.png
index 2dadd7a690..2dadd7a690 100644
--- a/src/gui/styles/images/standardbutton-ok-32.png
+++ b/src/widgets/styles/images/standardbutton-ok-32.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-open-128.png b/src/widgets/styles/images/standardbutton-open-128.png
index 8a052e829d..8a052e829d 100644
--- a/src/gui/styles/images/standardbutton-open-128.png
+++ b/src/widgets/styles/images/standardbutton-open-128.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-open-16.png b/src/widgets/styles/images/standardbutton-open-16.png
index 08cdc2b91f..08cdc2b91f 100644
--- a/src/gui/styles/images/standardbutton-open-16.png
+++ b/src/widgets/styles/images/standardbutton-open-16.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-open-32.png b/src/widgets/styles/images/standardbutton-open-32.png
index db33c79852..db33c79852 100644
--- a/src/gui/styles/images/standardbutton-open-32.png
+++ b/src/widgets/styles/images/standardbutton-open-32.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-save-128.png b/src/widgets/styles/images/standardbutton-save-128.png
index fc6fd7ce1d..fc6fd7ce1d 100644
--- a/src/gui/styles/images/standardbutton-save-128.png
+++ b/src/widgets/styles/images/standardbutton-save-128.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-save-16.png b/src/widgets/styles/images/standardbutton-save-16.png
index dd4e228280..dd4e228280 100644
--- a/src/gui/styles/images/standardbutton-save-16.png
+++ b/src/widgets/styles/images/standardbutton-save-16.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-save-32.png b/src/widgets/styles/images/standardbutton-save-32.png
index 177678c963..177678c963 100644
--- a/src/gui/styles/images/standardbutton-save-32.png
+++ b/src/widgets/styles/images/standardbutton-save-32.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-yes-128.png b/src/widgets/styles/images/standardbutton-yes-128.png
index 79c8296016..79c8296016 100644
--- a/src/gui/styles/images/standardbutton-yes-128.png
+++ b/src/widgets/styles/images/standardbutton-yes-128.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-yes-16.png b/src/widgets/styles/images/standardbutton-yes-16.png
index cc16dbbec3..cc16dbbec3 100644
--- a/src/gui/styles/images/standardbutton-yes-16.png
+++ b/src/widgets/styles/images/standardbutton-yes-16.png
Binary files differ
diff --git a/src/gui/styles/images/standardbutton-yes-32.png b/src/widgets/styles/images/standardbutton-yes-32.png
index e3340c6453..e3340c6453 100644
--- a/src/gui/styles/images/standardbutton-yes-32.png
+++ b/src/widgets/styles/images/standardbutton-yes-32.png
Binary files differ
diff --git a/src/gui/styles/images/stop-24.png b/src/widgets/styles/images/stop-24.png
index 99856e9640..99856e9640 100644
--- a/src/gui/styles/images/stop-24.png
+++ b/src/widgets/styles/images/stop-24.png
Binary files differ
diff --git a/src/gui/styles/images/stop-32.png b/src/widgets/styles/images/stop-32.png
index 4f4952bb2a..4f4952bb2a 100644
--- a/src/gui/styles/images/stop-32.png
+++ b/src/widgets/styles/images/stop-32.png
Binary files differ
diff --git a/src/gui/styles/images/trash-128.png b/src/widgets/styles/images/trash-128.png
index 334fe5b6f3..334fe5b6f3 100644
--- a/src/gui/styles/images/trash-128.png
+++ b/src/widgets/styles/images/trash-128.png
Binary files differ
diff --git a/src/gui/styles/images/trash-16.png b/src/widgets/styles/images/trash-16.png
index c471791ee8..c471791ee8 100644
--- a/src/gui/styles/images/trash-16.png
+++ b/src/widgets/styles/images/trash-16.png
Binary files differ
diff --git a/src/gui/styles/images/trash-32.png b/src/widgets/styles/images/trash-32.png
index 68625cf698..68625cf698 100644
--- a/src/gui/styles/images/trash-32.png
+++ b/src/widgets/styles/images/trash-32.png
Binary files differ
diff --git a/src/gui/styles/images/up-128.png b/src/widgets/styles/images/up-128.png
index c10df10677..c10df10677 100644
--- a/src/gui/styles/images/up-128.png
+++ b/src/widgets/styles/images/up-128.png
Binary files differ
diff --git a/src/gui/styles/images/up-16.png b/src/widgets/styles/images/up-16.png
index 33e939db8f..33e939db8f 100644
--- a/src/gui/styles/images/up-16.png
+++ b/src/widgets/styles/images/up-16.png
Binary files differ
diff --git a/src/gui/styles/images/up-32.png b/src/widgets/styles/images/up-32.png
index d7157c9476..d7157c9476 100644
--- a/src/gui/styles/images/up-32.png
+++ b/src/widgets/styles/images/up-32.png
Binary files differ
diff --git a/src/gui/styles/images/viewdetailed-128.png b/src/widgets/styles/images/viewdetailed-128.png
index 363937a857..363937a857 100644
--- a/src/gui/styles/images/viewdetailed-128.png
+++ b/src/widgets/styles/images/viewdetailed-128.png
Binary files differ
diff --git a/src/gui/styles/images/viewdetailed-16.png b/src/widgets/styles/images/viewdetailed-16.png
index 44a14b923a..44a14b923a 100644
--- a/src/gui/styles/images/viewdetailed-16.png
+++ b/src/widgets/styles/images/viewdetailed-16.png
Binary files differ
diff --git a/src/gui/styles/images/viewdetailed-32.png b/src/widgets/styles/images/viewdetailed-32.png
index fac1a3e683..fac1a3e683 100644
--- a/src/gui/styles/images/viewdetailed-32.png
+++ b/src/widgets/styles/images/viewdetailed-32.png
Binary files differ
diff --git a/src/gui/styles/images/viewlist-128.png b/src/widgets/styles/images/viewlist-128.png
index cc301059c1..cc301059c1 100644
--- a/src/gui/styles/images/viewlist-128.png
+++ b/src/widgets/styles/images/viewlist-128.png
Binary files differ
diff --git a/src/gui/styles/images/viewlist-16.png b/src/widgets/styles/images/viewlist-16.png
index 9132877ff6..9132877ff6 100644
--- a/src/gui/styles/images/viewlist-16.png
+++ b/src/widgets/styles/images/viewlist-16.png
Binary files differ
diff --git a/src/gui/styles/images/viewlist-32.png b/src/widgets/styles/images/viewlist-32.png
index fae3c24536..fae3c24536 100644
--- a/src/gui/styles/images/viewlist-32.png
+++ b/src/widgets/styles/images/viewlist-32.png
Binary files differ
diff --git a/src/gui/styles/qcdestyle.cpp b/src/widgets/styles/qcdestyle.cpp
index 5acf399396..5acf399396 100644
--- a/src/gui/styles/qcdestyle.cpp
+++ b/src/widgets/styles/qcdestyle.cpp
diff --git a/src/widgets/styles/qcdestyle.h b/src/widgets/styles/qcdestyle.h
new file mode 100644
index 0000000000..b0f010fbc5
--- /dev/null
+++ b/src/widgets/styles/qcdestyle.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef QCDESTYLE_H
+#define QCDESTYLE_H
+
+#include <QtWidgets/qmotifstyle.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#if !defined(QT_NO_STYLE_CDE)
+
+class Q_GUI_EXPORT QCDEStyle : public QMotifStyle
+{
+ Q_OBJECT
+public:
+ explicit QCDEStyle(bool useHighlightCols = false);
+ virtual ~QCDEStyle();
+
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = 0,
+ const QWidget *widget = 0) const;
+ void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
+ const QWidget *w = 0) const;
+ void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
+ const QWidget *w = 0) const;
+ QPalette standardPalette() const;
+
+protected Q_SLOTS:
+ QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt = 0,
+ const QWidget *widget = 0) const;
+};
+
+#endif // QT_NO_STYLE_CDE
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QCDESTYLE_H
diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/widgets/styles/qcleanlooksstyle.cpp
index 786aab34c3..786aab34c3 100644
--- a/src/gui/styles/qcleanlooksstyle.cpp
+++ b/src/widgets/styles/qcleanlooksstyle.cpp
diff --git a/src/widgets/styles/qcleanlooksstyle.h b/src/widgets/styles/qcleanlooksstyle.h
new file mode 100644
index 0000000000..de13b0947d
--- /dev/null
+++ b/src/widgets/styles/qcleanlooksstyle.h
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCLEANLOOKSSTYLE_H
+#define QCLEANLOOKSSTYLE_H
+
+#include <QtWidgets/qwindowsstyle.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#if !defined(QT_NO_STYLE_CLEANLOOKS)
+
+class QCleanlooksStylePrivate;
+class Q_GUI_EXPORT QCleanlooksStyle : public QWindowsStyle
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QCleanlooksStyle)
+
+public:
+ QCleanlooksStyle();
+ ~QCleanlooksStyle();
+
+ QPalette standardPalette () const;
+ void drawPrimitive(PrimitiveElement elem,
+ const QStyleOption *option,
+ QPainter *painter, const QWidget *widget = 0) const;
+ void drawControl(ControlElement ce, const QStyleOption *option, QPainter *painter,
+ const QWidget *widget) const;
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
+ void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
+ QPainter *painter, const QWidget *widget) const;
+ QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const;
+ QSize sizeFromContents(ContentsType type, const QStyleOption *option,
+ const QSize &size, const QWidget *widget) const;
+ SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
+ const QPoint &pt, const QWidget *w = 0) const;
+ QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt,
+ SubControl sc, const QWidget *widget) const;
+ QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
+ const QStyleOption *opt) const;
+ int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0,
+ QStyleHintReturn *returnData = 0) const;
+ QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const;
+ QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
+ const QWidget *widget = 0) const;
+ void drawItemPixmap(QPainter *painter, const QRect &rect,
+ int alignment, const QPixmap &pixmap) const;
+ void drawItemText(QPainter *painter, const QRect &rect,
+ int flags, const QPalette &pal, bool enabled,
+ const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const;
+ void polish(QWidget *widget);
+ void polish(QApplication *app);
+ void polish(QPalette &pal);
+ void unpolish(QWidget *widget);
+ void unpolish(QApplication *app);
+
+protected Q_SLOTS:
+ QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option,
+ const QWidget *widget = 0) const;
+
+protected:
+ QCleanlooksStyle(QCleanlooksStylePrivate &dd);
+
+};
+
+#endif // QT_NO_STYLE_CLEANLOOKS
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QCLEANLOOKSSTYLE_H
diff --git a/src/gui/styles/qcleanlooksstyle_p.h b/src/widgets/styles/qcleanlooksstyle_p.h
index 52cc282578..52cc282578 100644
--- a/src/gui/styles/qcleanlooksstyle_p.h
+++ b/src/widgets/styles/qcleanlooksstyle_p.h
diff --git a/src/gui/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp
index 95ebdb4662..95ebdb4662 100644
--- a/src/gui/styles/qcommonstyle.cpp
+++ b/src/widgets/styles/qcommonstyle.cpp
diff --git a/src/widgets/styles/qcommonstyle.h b/src/widgets/styles/qcommonstyle.h
new file mode 100644
index 0000000000..b420dd9b04
--- /dev/null
+++ b/src/widgets/styles/qcommonstyle.h
@@ -0,0 +1,109 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCOMMONSTYLE_H
+#define QCOMMONSTYLE_H
+
+#include <QtWidgets/qstyle.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+QT_MODULE(Gui)
+
+class QCommonStylePrivate;
+
+class Q_GUI_EXPORT QCommonStyle: public QStyle
+{
+ Q_OBJECT
+
+public:
+ QCommonStyle();
+ ~QCommonStyle();
+
+ void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
+ const QWidget *w = 0) const;
+ void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
+ const QWidget *w = 0) const;
+ QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const;
+ void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
+ const QWidget *w = 0) const;
+ SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
+ const QPoint &pt, const QWidget *w = 0) const;
+ QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc,
+ const QWidget *w = 0) const;
+ QSize sizeFromContents(ContentsType ct, const QStyleOption *opt,
+ const QSize &contentsSize, const QWidget *widget = 0) const;
+
+ int pixelMetric(PixelMetric m, const QStyleOption *opt = 0, const QWidget *widget = 0) const;
+
+ int styleHint(StyleHint sh, const QStyleOption *opt = 0, const QWidget *w = 0,
+ QStyleHintReturn *shret = 0) const;
+
+ QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *opt = 0,
+ const QWidget *widget = 0) const;
+
+ QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
+ const QStyleOption *opt) const;
+
+ void polish(QPalette &);
+ void polish(QApplication *app);
+ void polish(QWidget *widget);
+ void unpolish(QWidget *widget);
+ void unpolish(QApplication *application);
+
+protected Q_SLOTS:
+ QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt = 0,
+ const QWidget *widget = 0) const;
+
+protected:
+ QCommonStyle(QCommonStylePrivate &dd);
+
+private:
+ Q_DECLARE_PRIVATE(QCommonStyle)
+ Q_DISABLE_COPY(QCommonStyle)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QCOMMONSTYLE_H
diff --git a/src/gui/styles/qcommonstyle_p.h b/src/widgets/styles/qcommonstyle_p.h
index a02bd44259..a02bd44259 100644
--- a/src/gui/styles/qcommonstyle_p.h
+++ b/src/widgets/styles/qcommonstyle_p.h
diff --git a/src/gui/styles/qcommonstylepixmaps_p.h b/src/widgets/styles/qcommonstylepixmaps_p.h
index fb87c0e7a7..fb87c0e7a7 100644
--- a/src/gui/styles/qcommonstylepixmaps_p.h
+++ b/src/widgets/styles/qcommonstylepixmaps_p.h
diff --git a/src/widgets/styles/qdrawutil.cpp b/src/widgets/styles/qdrawutil.cpp
new file mode 100644
index 0000000000..c674da8394
--- /dev/null
+++ b/src/widgets/styles/qdrawutil.cpp
@@ -0,0 +1,1053 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qdrawutil.h"
+#include "qbitmap.h"
+#include "qpixmapcache.h"
+#include "qpainter.h"
+#include "qpalette.h"
+#include <private/qpaintengineex_p.h>
+#include <qvarlengtharray.h>
+#include <qmath.h>
+#include <private/qhexstring_p.h>
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \headerfile <qdrawutil.h>
+ \title Drawing Utility Functions
+
+ \sa QPainter
+*/
+
+/*!
+ \fn void qDrawShadeLine(QPainter *painter, int x1, int y1, int x2, int y2,
+ const QPalette &palette, bool sunken,
+ int lineWidth, int midLineWidth)
+ \relates <qdrawutil.h>
+
+ Draws a horizontal (\a y1 == \a y2) or vertical (\a x1 == \a x2)
+ shaded line using the given \a painter. Note that nothing is
+ drawn if \a y1 != \a y2 and \a x1 != \a x2 (i.e. the line is
+ neither horizontal nor vertical).
+
+ The provided \a palette specifies the shading colors (\l
+ {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
+ {QPalette::mid()}{middle} colors). The given \a lineWidth
+ specifies the line width for each of the lines; it is not the
+ total line width. The given \a midLineWidth specifies the width of
+ a middle line drawn in the QPalette::mid() color.
+
+ The line appears sunken if \a sunken is true, otherwise raised.
+
+ \warning This function does not look at QWidget::style() or
+ QApplication::style(). Use the drawing functions in QStyle to
+ make widgets that follow the current GUI style.
+
+
+ Alternatively you can use a QFrame widget and apply the
+ QFrame::setFrameStyle() function to display a shaded line:
+
+ \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 0
+
+ \sa qDrawShadeRect(), qDrawShadePanel(), QStyle
+*/
+
+void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2,
+ const QPalette &pal, bool sunken,
+ int lineWidth, int midLineWidth)
+{
+ if (!(p && lineWidth >= 0 && midLineWidth >= 0)) {
+ qWarning("qDrawShadeLine: Invalid parameters");
+ return;
+ }
+ int tlw = lineWidth*2 + midLineWidth; // total line width
+ QPen oldPen = p->pen(); // save pen
+ if (sunken)
+ p->setPen(pal.color(QPalette::Dark));
+ else
+ p->setPen(pal.light().color());
+ QPolygon a;
+ int i;
+ if (y1 == y2) { // horizontal line
+ int y = y1 - tlw/2;
+ if (x1 > x2) { // swap x1 and x2
+ int t = x1;
+ x1 = x2;
+ x2 = t;
+ }
+ x2--;
+ for (i=0; i<lineWidth; i++) { // draw top shadow
+ a.setPoints(3, x1+i, y+tlw-1-i,
+ x1+i, y+i,
+ x2-i, y+i);
+ p->drawPolyline(a);
+ }
+ if (midLineWidth > 0) {
+ p->setPen(pal.mid().color());
+ for (i=0; i<midLineWidth; i++) // draw lines in the middle
+ p->drawLine(x1+lineWidth, y+lineWidth+i,
+ x2-lineWidth, y+lineWidth+i);
+ }
+ if (sunken)
+ p->setPen(pal.light().color());
+ else
+ p->setPen(pal.dark().color());
+ for (i=0; i<lineWidth; i++) { // draw bottom shadow
+ a.setPoints(3, x1+i, y+tlw-i-1,
+ x2-i, y+tlw-i-1,
+ x2-i, y+i+1);
+ p->drawPolyline(a);
+ }
+ }
+ else if (x1 == x2) { // vertical line
+ int x = x1 - tlw/2;
+ if (y1 > y2) { // swap y1 and y2
+ int t = y1;
+ y1 = y2;
+ y2 = t;
+ }
+ y2--;
+ for (i=0; i<lineWidth; i++) { // draw left shadow
+ a.setPoints(3, x+i, y2,
+ x+i, y1+i,
+ x+tlw-1, y1+i);
+ p->drawPolyline(a);
+ }
+ if (midLineWidth > 0) {
+ p->setPen(pal.mid().color());
+ for (i=0; i<midLineWidth; i++) // draw lines in the middle
+ p->drawLine(x+lineWidth+i, y1+lineWidth, x+lineWidth+i, y2);
+ }
+ if (sunken)
+ p->setPen(pal.light().color());
+ else
+ p->setPen(pal.dark().color());
+ for (i=0; i<lineWidth; i++) { // draw right shadow
+ a.setPoints(3, x+lineWidth, y2-i,
+ x+tlw-i-1, y2-i,
+ x+tlw-i-1, y1+lineWidth);
+ p->drawPolyline(a);
+ }
+ }
+ p->setPen(oldPen);
+}
+
+/*!
+ \fn void qDrawShadeRect(QPainter *painter, int x, int y, int width, int height,
+ const QPalette &palette, bool sunken,
+ int lineWidth, int midLineWidth,
+ const QBrush *fill)
+ \relates <qdrawutil.h>
+
+ Draws the shaded rectangle beginning at (\a x, \a y) with the
+ given \a width and \a height using the provided \a painter.
+
+ The provide \a palette specifies the shading colors (\l
+ {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
+ {QPalette::mid()}{middle} colors. The given \a lineWidth
+ specifies the line width for each of the lines; it is not the
+ total line width. The \a midLineWidth specifies the width of a
+ middle line drawn in the QPalette::mid() color. The rectangle's
+ interior is filled with the \a fill brush unless \a fill is 0.
+
+ The rectangle appears sunken if \a sunken is true, otherwise
+ raised.
+
+ \warning This function does not look at QWidget::style() or
+ QApplication::style(). Use the drawing functions in QStyle to make
+ widgets that follow the current GUI style.
+
+ Alternatively you can use a QFrame widget and apply the
+ QFrame::setFrameStyle() function to display a shaded rectangle:
+
+ \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 1
+
+ \sa qDrawShadeLine(), qDrawShadePanel(), qDrawPlainRect(), QStyle
+*/
+
+void qDrawShadeRect(QPainter *p, int x, int y, int w, int h,
+ const QPalette &pal, bool sunken,
+ int lineWidth, int midLineWidth,
+ const QBrush *fill)
+{
+ if (w == 0 || h == 0)
+ return;
+ if (! (w > 0 && h > 0 && lineWidth >= 0 && midLineWidth >= 0)) {
+ qWarning("qDrawShadeRect: Invalid parameters");
+ return;
+ }
+ QPen oldPen = p->pen();
+ if (sunken)
+ p->setPen(pal.dark().color());
+ else
+ p->setPen(pal.light().color());
+ int x1=x, y1=y, x2=x+w-1, y2=y+h-1;
+
+ if (lineWidth == 1 && midLineWidth == 0) {// standard shade rectangle
+ p->drawRect(x1, y1, w-2, h-2);
+ if (sunken)
+ p->setPen(pal.light().color());
+ else
+ p->setPen(pal.dark().color());
+ QLineF lines[4] = { QLineF(x1+1, y1+1, x2-2, y1+1),
+ QLineF(x1+1, y1+2, x1+1, y2-2),
+ QLineF(x1, y2, x2, y2),
+ QLineF(x2,y1, x2,y2-1) };
+ p->drawLines(lines, 4); // draw bottom/right lines
+ } else { // more complicated
+ int m = lineWidth+midLineWidth;
+ int i, j=0, k=m;
+ for (i=0; i<lineWidth; i++) { // draw top shadow
+ QLineF lines[4] = { QLineF(x1+i, y2-i, x1+i, y1+i),
+ QLineF(x1+i, y1+i, x2-i, y1+i),
+ QLineF(x1+k, y2-k, x2-k, y2-k),
+ QLineF(x2-k, y2-k, x2-k, y1+k) };
+ p->drawLines(lines, 4);
+ k++;
+ }
+ p->setPen(pal.mid().color());
+ j = lineWidth*2;
+ for (i=0; i<midLineWidth; i++) { // draw lines in the middle
+ p->drawRect(x1+lineWidth+i, y1+lineWidth+i, w-j-1, h-j-1);
+ j += 2;
+ }
+ if (sunken)
+ p->setPen(pal.light().color());
+ else
+ p->setPen(pal.dark().color());
+ k = m;
+ for (i=0; i<lineWidth; i++) { // draw bottom shadow
+ QLineF lines[4] = { QLineF(x1+1+i, y2-i, x2-i, y2-i),
+ QLineF(x2-i, y2-i, x2-i, y1+i+1),
+ QLineF(x1+k, y2-k, x1+k, y1+k),
+ QLineF(x1+k, y1+k, x2-k, y1+k) };
+ p->drawLines(lines, 4);
+ k++;
+ }
+ }
+ if (fill) {
+ QBrush oldBrush = p->brush();
+ int tlw = lineWidth + midLineWidth;
+ p->setPen(Qt::NoPen);
+ p->setBrush(*fill);
+ p->drawRect(x+tlw, y+tlw, w-2*tlw, h-2*tlw);
+ p->setBrush(oldBrush);
+ }
+ p->setPen(oldPen); // restore pen
+}
+
+
+/*!
+ \fn void qDrawShadePanel(QPainter *painter, int x, int y, int width, int height,
+ const QPalette &palette, bool sunken,
+ int lineWidth, const QBrush *fill)
+ \relates <qdrawutil.h>
+
+ Draws the shaded panel beginning at (\a x, \a y) with the given \a
+ width and \a height using the provided \a painter and the given \a
+ lineWidth.
+
+ The given \a palette specifies the shading colors (\l
+ {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
+ {QPalette::mid()}{middle} colors). The panel's interior is filled
+ with the \a fill brush unless \a fill is 0.
+
+ The panel appears sunken if \a sunken is true, otherwise raised.
+
+ \warning This function does not look at QWidget::style() or
+ QApplication::style(). Use the drawing functions in QStyle to make
+ widgets that follow the current GUI style.
+
+ Alternatively you can use a QFrame widget and apply the
+ QFrame::setFrameStyle() function to display a shaded panel:
+
+ \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 2
+
+ \sa qDrawWinPanel(), qDrawShadeLine(), qDrawShadeRect(), QStyle
+*/
+
+void qDrawShadePanel(QPainter *p, int x, int y, int w, int h,
+ const QPalette &pal, bool sunken,
+ int lineWidth, const QBrush *fill)
+{
+ if (w == 0 || h == 0)
+ return;
+ if (!(w > 0 && h > 0 && lineWidth >= 0)) {
+ qWarning("qDrawShadePanel: Invalid parameters");
+ }
+ QColor shade = pal.dark().color();
+ QColor light = pal.light().color();
+ if (fill) {
+ if (fill->color() == shade)
+ shade = pal.shadow().color();
+ if (fill->color() == light)
+ light = pal.midlight().color();
+ }
+ QPen oldPen = p->pen(); // save pen
+ QVector<QLineF> lines;
+ lines.reserve(2*lineWidth);
+
+ if (sunken)
+ p->setPen(shade);
+ else
+ p->setPen(light);
+ int x1, y1, x2, y2;
+ int i;
+ x1 = x;
+ y1 = y2 = y;
+ x2 = x+w-2;
+ for (i=0; i<lineWidth; i++) { // top shadow
+ lines << QLineF(x1, y1++, x2--, y2++);
+ }
+ x2 = x1;
+ y1 = y+h-2;
+ for (i=0; i<lineWidth; i++) { // left shado
+ lines << QLineF(x1++, y1, x2++, y2--);
+ }
+ p->drawLines(lines);
+ lines.clear();
+ if (sunken)
+ p->setPen(light);
+ else
+ p->setPen(shade);
+ x1 = x;
+ y1 = y2 = y+h-1;
+ x2 = x+w-1;
+ for (i=0; i<lineWidth; i++) { // bottom shadow
+ lines << QLineF(x1++, y1--, x2, y2--);
+ }
+ x1 = x2;
+ y1 = y;
+ y2 = y+h-lineWidth-1;
+ for (i=0; i<lineWidth; i++) { // right shadow
+ lines << QLineF(x1--, y1++, x2--, y2);
+ }
+ p->drawLines(lines);
+ if (fill) // fill with fill color
+ p->fillRect(x+lineWidth, y+lineWidth, w-lineWidth*2, h-lineWidth*2, *fill);
+ p->setPen(oldPen); // restore pen
+}
+
+
+/*!
+ \internal
+ This function draws a rectangle with two pixel line width.
+ It is called from qDrawWinButton() and qDrawWinPanel().
+
+ c1..c4 and fill are used:
+
+ 1 1 1 1 1 2
+ 1 3 3 3 4 2
+ 1 3 F F 4 2
+ 1 3 F F 4 2
+ 1 4 4 4 4 2
+ 2 2 2 2 2 2
+*/
+
+static void qDrawWinShades(QPainter *p,
+ int x, int y, int w, int h,
+ const QColor &c1, const QColor &c2,
+ const QColor &c3, const QColor &c4,
+ const QBrush *fill)
+{
+ if (w < 2 || h < 2) // can't do anything with that
+ return;
+ QPen oldPen = p->pen();
+ QPoint a[3] = { QPoint(x, y+h-2), QPoint(x, y), QPoint(x+w-2, y) };
+ p->setPen(c1);
+ p->drawPolyline(a, 3);
+ QPoint b[3] = { QPoint(x, y+h-1), QPoint(x+w-1, y+h-1), QPoint(x+w-1, y) };
+ p->setPen(c2);
+ p->drawPolyline(b, 3);
+ if (w > 4 && h > 4) {
+ QPoint c[3] = { QPoint(x+1, y+h-3), QPoint(x+1, y+1), QPoint(x+w-3, y+1) };
+ p->setPen(c3);
+ p->drawPolyline(c, 3);
+ QPoint d[3] = { QPoint(x+1, y+h-2), QPoint(x+w-2, y+h-2), QPoint(x+w-2, y+1) };
+ p->setPen(c4);
+ p->drawPolyline(d, 3);
+ if (fill)
+ p->fillRect(QRect(x+2, y+2, w-4, h-4), *fill);
+ }
+ p->setPen(oldPen);
+}
+
+
+/*!
+ \fn void qDrawWinButton(QPainter *painter, int x, int y, int width, int height,
+ const QPalette &palette, bool sunken,
+ const QBrush *fill)
+ \relates <qdrawutil.h>
+
+ Draws the Windows-style button specified by the given point (\a x,
+ \a y}, \a width and \a height using the provided \a painter with a
+ line width of 2 pixels. The button's interior is filled with the
+ \a{fill} brush unless \a fill is 0.
+
+ The given \a palette specifies the shading colors (\l
+ {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
+ {QPalette::mid()}{middle} colors).
+
+ The button appears sunken if \a sunken is true, otherwise raised.
+
+ \warning This function does not look at QWidget::style() or
+ QApplication::style()-> Use the drawing functions in QStyle to make
+ widgets that follow the current GUI style.
+
+ \sa qDrawWinPanel(), QStyle
+*/
+
+void qDrawWinButton(QPainter *p, int x, int y, int w, int h,
+ const QPalette &pal, bool sunken,
+ const QBrush *fill)
+{
+ if (sunken)
+ qDrawWinShades(p, x, y, w, h,
+ pal.shadow().color(), pal.light().color(), pal.dark().color(),
+ pal.button().color(), fill);
+ else
+ qDrawWinShades(p, x, y, w, h,
+ pal.light().color(), pal.shadow().color(), pal.button().color(),
+ pal.dark().color(), fill);
+}
+
+/*!
+ \fn void qDrawWinPanel(QPainter *painter, int x, int y, int width, int height,
+ const QPalette &palette, bool sunken,
+ const QBrush *fill)
+ \relates <qdrawutil.h>
+
+ Draws the Windows-style panel specified by the given point(\a x,
+ \a y), \a width and \a height using the provided \a painter with a
+ line width of 2 pixels. The button's interior is filled with the
+ \a fill brush unless \a fill is 0.
+
+ The given \a palette specifies the shading colors. The panel
+ appears sunken if \a sunken is true, otherwise raised.
+
+ \warning This function does not look at QWidget::style() or
+ QApplication::style(). Use the drawing functions in QStyle to make
+ widgets that follow the current GUI style.
+
+ Alternatively you can use a QFrame widget and apply the
+ QFrame::setFrameStyle() function to display a shaded panel:
+
+ \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 3
+
+ \sa qDrawShadePanel(), qDrawWinButton(), QStyle
+*/
+
+void qDrawWinPanel(QPainter *p, int x, int y, int w, int h,
+ const QPalette &pal, bool sunken,
+ const QBrush *fill)
+{
+ if (sunken)
+ qDrawWinShades(p, x, y, w, h,
+ pal.dark().color(), pal.light().color(), pal.shadow().color(),
+ pal.midlight().color(), fill);
+ else
+ qDrawWinShades(p, x, y, w, h,
+ pal.light().color(), pal.shadow().color(), pal.midlight().color(),
+ pal.dark().color(), fill);
+}
+
+/*!
+ \fn void qDrawPlainRect(QPainter *painter, int x, int y, int width, int height, const QColor &lineColor,
+ int lineWidth, const QBrush *fill)
+ \relates <qdrawutil.h>
+
+ Draws the plain rectangle beginning at (\a x, \a y) with the given
+ \a width and \a height, using the specified \a painter, \a lineColor
+ and \a lineWidth. The rectangle's interior is filled with the \a
+ fill brush unless \a fill is 0.
+
+ \warning This function does not look at QWidget::style() or
+ QApplication::style(). Use the drawing functions in QStyle to make
+ widgets that follow the current GUI style.
+
+ Alternatively you can use a QFrame widget and apply the
+ QFrame::setFrameStyle() function to display a plain rectangle:
+
+ \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 4
+
+ \sa qDrawShadeRect(), QStyle
+*/
+
+void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &c,
+ int lineWidth, const QBrush *fill)
+{
+ if (w == 0 || h == 0)
+ return;
+ if (!(w > 0 && h > 0 && lineWidth >= 0)) {
+ qWarning("qDrawPlainRect: Invalid parameters");
+ }
+ QPen oldPen = p->pen();
+ QBrush oldBrush = p->brush();
+ p->setPen(c);
+ p->setBrush(Qt::NoBrush);
+ for (int i=0; i<lineWidth; i++)
+ p->drawRect(x+i, y+i, w-i*2 - 1, h-i*2 - 1);
+ if (fill) { // fill with fill color
+ p->setPen(Qt::NoPen);
+ p->setBrush(*fill);
+ p->drawRect(x+lineWidth, y+lineWidth, w-lineWidth*2, h-lineWidth*2);
+ }
+ p->setPen(oldPen);
+ p->setBrush(oldBrush);
+}
+
+/*****************************************************************************
+ Overloaded functions.
+ *****************************************************************************/
+
+/*!
+ \fn void qDrawShadeLine(QPainter *painter, const QPoint &p1, const QPoint &p2,
+ const QPalette &palette, bool sunken, int lineWidth, int midLineWidth)
+ \relates <qdrawutil.h>
+ \overload
+
+ Draws a horizontal or vertical shaded line between \a p1 and \a p2
+ using the given \a painter. Note that nothing is drawn if the line
+ between the points would be neither horizontal nor vertical.
+
+ The provided \a palette specifies the shading colors (\l
+ {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
+ {QPalette::mid()}{middle} colors). The given \a lineWidth
+ specifies the line width for each of the lines; it is not the
+ total line width. The given \a midLineWidth specifies the width of
+ a middle line drawn in the QPalette::mid() color.
+
+ The line appears sunken if \a sunken is true, otherwise raised.
+
+ \warning This function does not look at QWidget::style() or
+ QApplication::style(). Use the drawing functions in QStyle to
+ make widgets that follow the current GUI style.
+
+
+ Alternatively you can use a QFrame widget and apply the
+ QFrame::setFrameStyle() function to display a shaded line:
+
+ \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 5
+
+ \sa qDrawShadeRect(), qDrawShadePanel(), QStyle
+*/
+
+void qDrawShadeLine(QPainter *p, const QPoint &p1, const QPoint &p2,
+ const QPalette &pal, bool sunken,
+ int lineWidth, int midLineWidth)
+{
+ qDrawShadeLine(p, p1.x(), p1.y(), p2.x(), p2.y(), pal, sunken,
+ lineWidth, midLineWidth);
+}
+
+/*!
+ \fn void qDrawShadeRect(QPainter *painter, const QRect &rect, const QPalette &palette,
+ bool sunken, int lineWidth, int midLineWidth, const QBrush *fill)
+ \relates <qdrawutil.h>
+ \overload
+
+ Draws the shaded rectangle specified by \a rect using the given \a painter.
+
+ The provide \a palette specifies the shading colors (\l
+ {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
+ {QPalette::mid()}{middle} colors. The given \a lineWidth
+ specifies the line width for each of the lines; it is not the
+ total line width. The \a midLineWidth specifies the width of a
+ middle line drawn in the QPalette::mid() color. The rectangle's
+ interior is filled with the \a fill brush unless \a fill is 0.
+
+ The rectangle appears sunken if \a sunken is true, otherwise
+ raised.
+
+ \warning This function does not look at QWidget::style() or
+ QApplication::style(). Use the drawing functions in QStyle to make
+ widgets that follow the current GUI style.
+
+ Alternatively you can use a QFrame widget and apply the
+ QFrame::setFrameStyle() function to display a shaded rectangle:
+
+ \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 6
+
+ \sa qDrawShadeLine(), qDrawShadePanel(), qDrawPlainRect(), QStyle
+*/
+
+void qDrawShadeRect(QPainter *p, const QRect &r,
+ const QPalette &pal, bool sunken,
+ int lineWidth, int midLineWidth,
+ const QBrush *fill)
+{
+ qDrawShadeRect(p, r.x(), r.y(), r.width(), r.height(), pal, sunken,
+ lineWidth, midLineWidth, fill);
+}
+
+/*!
+ \fn void qDrawShadePanel(QPainter *painter, const QRect &rect, const QPalette &palette,
+ bool sunken, int lineWidth, const QBrush *fill)
+ \relates <qdrawutil.h>
+ \overload
+
+ Draws the shaded panel at the rectangle specified by \a rect using the
+ given \a painter and the given \a lineWidth.
+
+ The given \a palette specifies the shading colors (\l
+ {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
+ {QPalette::mid()}{middle} colors). The panel's interior is filled
+ with the \a fill brush unless \a fill is 0.
+
+ The panel appears sunken if \a sunken is true, otherwise raised.
+
+ \warning This function does not look at QWidget::style() or
+ QApplication::style(). Use the drawing functions in QStyle to make
+ widgets that follow the current GUI style.
+
+ Alternatively you can use a QFrame widget and apply the
+ QFrame::setFrameStyle() function to display a shaded panel:
+
+ \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 7
+
+ \sa qDrawWinPanel(), qDrawShadeLine(), qDrawShadeRect(), QStyle
+*/
+
+void qDrawShadePanel(QPainter *p, const QRect &r,
+ const QPalette &pal, bool sunken,
+ int lineWidth, const QBrush *fill)
+{
+ qDrawShadePanel(p, r.x(), r.y(), r.width(), r.height(), pal, sunken,
+ lineWidth, fill);
+}
+
+/*!
+ \fn void qDrawWinButton(QPainter *painter, const QRect &rect, const QPalette &palette,
+ bool sunken, const QBrush *fill)
+ \relates <qdrawutil.h>
+ \overload
+
+ Draws the Windows-style button at the rectangle specified by \a rect using
+ the given \a painter with a line width of 2 pixels. The button's interior
+ is filled with the \a{fill} brush unless \a fill is 0.
+
+ The given \a palette specifies the shading colors (\l
+ {QPalette::light()}{light}, \l {QPalette::dark()}{dark} and \l
+ {QPalette::mid()}{middle} colors).
+
+ The button appears sunken if \a sunken is true, otherwise raised.
+
+ \warning This function does not look at QWidget::style() or
+ QApplication::style()-> Use the drawing functions in QStyle to make
+ widgets that follow the current GUI style.
+
+ \sa qDrawWinPanel(), QStyle
+*/
+
+void qDrawWinButton(QPainter *p, const QRect &r,
+ const QPalette &pal, bool sunken, const QBrush *fill)
+{
+ qDrawWinButton(p, r.x(), r.y(), r.width(), r.height(), pal, sunken, fill);
+}
+
+/*!
+ \fn void qDrawWinPanel(QPainter *painter, const QRect &rect, const QPalette &palette,
+ bool sunken, const QBrush *fill)
+ \overload
+
+ Draws the Windows-style panel at the rectangle specified by \a rect using
+ the given \a painter with a line width of 2 pixels. The button's interior
+ is filled with the \a fill brush unless \a fill is 0.
+
+ The given \a palette specifies the shading colors. The panel
+ appears sunken if \a sunken is true, otherwise raised.
+
+ \warning This function does not look at QWidget::style() or
+ QApplication::style(). Use the drawing functions in QStyle to make
+ widgets that follow the current GUI style.
+
+ Alternatively you can use a QFrame widget and apply the
+ QFrame::setFrameStyle() function to display a shaded panel:
+
+ \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 8
+
+ \sa qDrawShadePanel(), qDrawWinButton(), QStyle
+*/
+
+void qDrawWinPanel(QPainter *p, const QRect &r,
+ const QPalette &pal, bool sunken, const QBrush *fill)
+{
+ qDrawWinPanel(p, r.x(), r.y(), r.width(), r.height(), pal, sunken, fill);
+}
+
+/*!
+ \fn void qDrawPlainRect(QPainter *painter, const QRect &rect, const QColor &lineColor, int lineWidth, const QBrush *fill)
+ \relates <qdrawutil.h>
+ \overload
+
+ Draws the plain rectangle specified by \a rect using the given \a painter,
+ \a lineColor and \a lineWidth. The rectangle's interior is filled with the
+ \a fill brush unless \a fill is 0.
+
+ \warning This function does not look at QWidget::style() or
+ QApplication::style(). Use the drawing functions in QStyle to make
+ widgets that follow the current GUI style.
+
+ Alternatively you can use a QFrame widget and apply the
+ QFrame::setFrameStyle() function to display a plain rectangle:
+
+ \snippet doc/src/snippets/code/src_gui_painting_qdrawutil.cpp 9
+
+ \sa qDrawShadeRect(), QStyle
+*/
+
+void qDrawPlainRect(QPainter *p, const QRect &r, const QColor &c,
+ int lineWidth, const QBrush *fill)
+{
+ qDrawPlainRect(p, r.x(), r.y(), r.width(), r.height(), c,
+ lineWidth, fill);
+}
+
+
+/*!
+ \class QTileRules
+ \since 4.6
+
+ Holds the rules used to draw a pixmap or image split into nine segments,
+ similar to \l{http://www.w3.org/TR/css3-background/}{CSS3 border-images}.
+
+ \sa Qt::TileRule, QMargins
+*/
+
+/*! \fn QTileRules::QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule)
+ Constructs a QTileRules with the given \a horizontalRule and
+ \a verticalRule.
+ */
+
+/*! \fn QTileRules::QTileRules(Qt::TileRule rule)
+ Constructs a QTileRules with the given \a rule used for both
+ the horizontal rule and the vertical rule.
+ */
+
+/*!
+ \fn void qDrawBorderPixmap(QPainter *painter, const QRect &target, const QMargins &margins, const QPixmap &pixmap)
+ \relates <qdrawutil.h>
+ \since 4.6
+ \overload
+
+ \brief The qDrawBorderPixmap function is for drawing a pixmap into
+ the margins of a rectangle.
+
+ Draws the given \a pixmap into the given \a target rectangle, using the
+ given \a painter. The pixmap will be split into nine segments and drawn
+ according to the \a margins structure.
+*/
+
+typedef QVarLengthArray<QPainter::PixmapFragment, 16> QPixmapFragmentsArray;
+
+/*!
+ \since 4.6
+
+ Draws the indicated \a sourceRect rectangle from the given \a pixmap into
+ the given \a targetRect rectangle, using the given \a painter. The pixmap
+ will be split into nine segments according to the given \a targetMargins
+ and \a sourceMargins structures. Finally, the pixmap will be drawn
+ according to the given \a rules.
+
+ This function is used to draw a scaled pixmap, similar to
+ \l{http://www.w3.org/TR/css3-background/}{CSS3 border-images}
+
+ \sa Qt::TileRule, QTileRules, QMargins
+*/
+
+void qDrawBorderPixmap(QPainter *painter, const QRect &targetRect, const QMargins &targetMargins,
+ const QPixmap &pixmap, const QRect &sourceRect,const QMargins &sourceMargins,
+ const QTileRules &rules, QDrawBorderPixmap::DrawingHints hints)
+{
+ QPainter::PixmapFragment d;
+ d.opacity = 1.0;
+ d.rotation = 0.0;
+
+ QPixmapFragmentsArray opaqueData;
+ QPixmapFragmentsArray translucentData;
+
+ // source center
+ const int sourceCenterTop = sourceRect.top() + sourceMargins.top();
+ const int sourceCenterLeft = sourceRect.left() + sourceMargins.left();
+ const int sourceCenterBottom = sourceRect.bottom() - sourceMargins.bottom() + 1;
+ const int sourceCenterRight = sourceRect.right() - sourceMargins.right() + 1;
+ const int sourceCenterWidth = sourceCenterRight - sourceCenterLeft;
+ const int sourceCenterHeight = sourceCenterBottom - sourceCenterTop;
+ // target center
+ const int targetCenterTop = targetRect.top() + targetMargins.top();
+ const int targetCenterLeft = targetRect.left() + targetMargins.left();
+ const int targetCenterBottom = targetRect.bottom() - targetMargins.bottom() + 1;
+ const int targetCenterRight = targetRect.right() - targetMargins.right() + 1;
+ const int targetCenterWidth = targetCenterRight - targetCenterLeft;
+ const int targetCenterHeight = targetCenterBottom - targetCenterTop;
+
+ QVarLengthArray<qreal, 16> xTarget; // x-coordinates of target rectangles
+ QVarLengthArray<qreal, 16> yTarget; // y-coordinates of target rectangles
+
+ int columns = 3;
+ int rows = 3;
+ if (rules.horizontal != Qt::StretchTile && sourceCenterWidth != 0)
+ columns = qMax(3, 2 + qCeil(targetCenterWidth / qreal(sourceCenterWidth)));
+ if (rules.vertical != Qt::StretchTile && sourceCenterHeight != 0)
+ rows = qMax(3, 2 + qCeil(targetCenterHeight / qreal(sourceCenterHeight)));
+
+ xTarget.resize(columns + 1);
+ yTarget.resize(rows + 1);
+
+ bool oldAA = painter->testRenderHint(QPainter::Antialiasing);
+ if (painter->paintEngine()->type() != QPaintEngine::OpenGL
+ && painter->paintEngine()->type() != QPaintEngine::OpenGL2
+ && oldAA && painter->combinedTransform().type() != QTransform::TxNone) {
+ painter->setRenderHint(QPainter::Antialiasing, false);
+ }
+
+ xTarget[0] = targetRect.left();
+ xTarget[1] = targetCenterLeft;
+ xTarget[columns - 1] = targetCenterRight;
+ xTarget[columns] = targetRect.left() + targetRect.width();
+
+ yTarget[0] = targetRect.top();
+ yTarget[1] = targetCenterTop;
+ yTarget[rows - 1] = targetCenterBottom;
+ yTarget[rows] = targetRect.top() + targetRect.height();
+
+ qreal dx = targetCenterWidth;
+ qreal dy = targetCenterHeight;
+
+ switch (rules.horizontal) {
+ case Qt::StretchTile:
+ dx = targetCenterWidth;
+ break;
+ case Qt::RepeatTile:
+ dx = sourceCenterWidth;
+ break;
+ case Qt::RoundTile:
+ dx = targetCenterWidth / qreal(columns - 2);
+ break;
+ }
+
+ for (int i = 2; i < columns - 1; ++i)
+ xTarget[i] = xTarget[i - 1] + dx;
+
+ switch (rules.vertical) {
+ case Qt::StretchTile:
+ dy = targetCenterHeight;
+ break;
+ case Qt::RepeatTile:
+ dy = sourceCenterHeight;
+ break;
+ case Qt::RoundTile:
+ dy = targetCenterHeight / qreal(rows - 2);
+ break;
+ }
+
+ for (int i = 2; i < rows - 1; ++i)
+ yTarget[i] = yTarget[i - 1] + dy;
+
+ // corners
+ if (targetMargins.top() > 0 && targetMargins.left() > 0 && sourceMargins.top() > 0 && sourceMargins.left() > 0) { // top left
+ d.x = (0.5 * (xTarget[1] + xTarget[0]));
+ d.y = (0.5 * (yTarget[1] + yTarget[0]));
+ d.sourceLeft = sourceRect.left();
+ d.sourceTop = sourceRect.top();
+ d.width = sourceMargins.left();
+ d.height = sourceMargins.top();
+ d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width;
+ d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height;
+ if (hints & QDrawBorderPixmap::OpaqueTopLeft)
+ opaqueData.append(d);
+ else
+ translucentData.append(d);
+ }
+ if (targetMargins.top() > 0 && targetMargins.right() > 0 && sourceMargins.top() > 0 && sourceMargins.right() > 0) { // top right
+ d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
+ d.y = (0.5 * (yTarget[1] + yTarget[0]));
+ d.sourceLeft = sourceCenterRight;
+ d.sourceTop = sourceRect.top();
+ d.width = sourceMargins.right();
+ d.height = sourceMargins.top();
+ d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width;
+ d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height;
+ if (hints & QDrawBorderPixmap::OpaqueTopRight)
+ opaqueData.append(d);
+ else
+ translucentData.append(d);
+ }
+ if (targetMargins.bottom() > 0 && targetMargins.left() > 0 && sourceMargins.bottom() > 0 && sourceMargins.left() > 0) { // bottom left
+ d.x = (0.5 * (xTarget[1] + xTarget[0]));
+ d.y =(0.5 * (yTarget[rows] + yTarget[rows - 1]));
+ d.sourceLeft = sourceRect.left();
+ d.sourceTop = sourceCenterBottom;
+ d.width = sourceMargins.left();
+ d.height = sourceMargins.bottom();
+ d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width;
+ d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height;
+ if (hints & QDrawBorderPixmap::OpaqueBottomLeft)
+ opaqueData.append(d);
+ else
+ translucentData.append(d);
+ }
+ if (targetMargins.bottom() > 0 && targetMargins.right() > 0 && sourceMargins.bottom() > 0 && sourceMargins.right() > 0) { // bottom right
+ d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
+ d.y = (0.5 * (yTarget[rows] + yTarget[rows - 1]));
+ d.sourceLeft = sourceCenterRight;
+ d.sourceTop = sourceCenterBottom;
+ d.width = sourceMargins.right();
+ d.height = sourceMargins.bottom();
+ d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width;
+ d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height;
+ if (hints & QDrawBorderPixmap::OpaqueBottomRight)
+ opaqueData.append(d);
+ else
+ translucentData.append(d);
+ }
+
+ // horizontal edges
+ if (targetCenterWidth > 0 && sourceCenterWidth > 0) {
+ if (targetMargins.top() > 0 && sourceMargins.top() > 0) { // top
+ QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueTop ? opaqueData : translucentData;
+ d.sourceLeft = sourceCenterLeft;
+ d.sourceTop = sourceRect.top();
+ d.width = sourceCenterWidth;
+ d.height = sourceMargins.top();
+ d.y = (0.5 * (yTarget[1] + yTarget[0]));
+ d.scaleX = dx / d.width;
+ d.scaleY = qreal(yTarget[1] - yTarget[0]) / d.height;
+ for (int i = 1; i < columns - 1; ++i) {
+ d.x = (0.5 * (xTarget[i + 1] + xTarget[i]));
+ data.append(d);
+ }
+ if (rules.horizontal == Qt::RepeatTile)
+ data[data.size() - 1].width = ((xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX);
+ }
+ if (targetMargins.bottom() > 0 && sourceMargins.bottom() > 0) { // bottom
+ QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueBottom ? opaqueData : translucentData;
+ d.sourceLeft = sourceCenterLeft;
+ d.sourceTop = sourceCenterBottom;
+ d.width = sourceCenterWidth;
+ d.height = sourceMargins.bottom();
+ d.y = (0.5 * (yTarget[rows] + yTarget[rows - 1]));
+ d.scaleX = dx / d.width;
+ d.scaleY = qreal(yTarget[rows] - yTarget[rows - 1]) / d.height;
+ for (int i = 1; i < columns - 1; ++i) {
+ d.x = (0.5 * (xTarget[i + 1] + xTarget[i]));
+ data.append(d);
+ }
+ if (rules.horizontal == Qt::RepeatTile)
+ data[data.size() - 1].width = ((xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX);
+ }
+ }
+
+ // vertical edges
+ if (targetCenterHeight > 0 && sourceCenterHeight > 0) {
+ if (targetMargins.left() > 0 && sourceMargins.left() > 0) { // left
+ QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueLeft ? opaqueData : translucentData;
+ d.sourceLeft = sourceRect.left();
+ d.sourceTop = sourceCenterTop;
+ d.width = sourceMargins.left();
+ d.height = sourceCenterHeight;
+ d.x = (0.5 * (xTarget[1] + xTarget[0]));
+ d.scaleX = qreal(xTarget[1] - xTarget[0]) / d.width;
+ d.scaleY = dy / d.height;
+ for (int i = 1; i < rows - 1; ++i) {
+ d.y = (0.5 * (yTarget[i + 1] + yTarget[i]));
+ data.append(d);
+ }
+ if (rules.vertical == Qt::RepeatTile)
+ data[data.size() - 1].height = ((yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY);
+ }
+ if (targetMargins.right() > 0 && sourceMargins.right() > 0) { // right
+ QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueRight ? opaqueData : translucentData;
+ d.sourceLeft = sourceCenterRight;
+ d.sourceTop = sourceCenterTop;
+ d.width = sourceMargins.right();
+ d.height = sourceCenterHeight;
+ d.x = (0.5 * (xTarget[columns] + xTarget[columns - 1]));
+ d.scaleX = qreal(xTarget[columns] - xTarget[columns - 1]) / d.width;
+ d.scaleY = dy / d.height;
+ for (int i = 1; i < rows - 1; ++i) {
+ d.y = (0.5 * (yTarget[i + 1] + yTarget[i]));
+ data.append(d);
+ }
+ if (rules.vertical == Qt::RepeatTile)
+ data[data.size() - 1].height = ((yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY);
+ }
+ }
+
+ // center
+ if (targetCenterWidth > 0 && targetCenterHeight > 0 && sourceCenterWidth > 0 && sourceCenterHeight > 0) {
+ QPixmapFragmentsArray &data = hints & QDrawBorderPixmap::OpaqueCenter ? opaqueData : translucentData;
+ d.sourceLeft = sourceCenterLeft;
+ d.sourceTop = sourceCenterTop;
+ d.width = sourceCenterWidth;
+ d.height = sourceCenterHeight;
+ d.scaleX = dx / d.width;
+ d.scaleY = dy / d.height;
+
+ qreal repeatWidth = (xTarget[columns - 1] - xTarget[columns - 2]) / d.scaleX;
+ qreal repeatHeight = (yTarget[rows - 1] - yTarget[rows - 2]) / d.scaleY;
+
+ for (int j = 1; j < rows - 1; ++j) {
+ d.y = (0.5 * (yTarget[j + 1] + yTarget[j]));
+ for (int i = 1; i < columns - 1; ++i) {
+ d.x = (0.5 * (xTarget[i + 1] + xTarget[i]));
+ data.append(d);
+ }
+ if (rules.horizontal == Qt::RepeatTile)
+ data[data.size() - 1].width = repeatWidth;
+ }
+ if (rules.vertical == Qt::RepeatTile) {
+ for (int i = 1; i < columns - 1; ++i)
+ data[data.size() - i].height = repeatHeight;
+ }
+ }
+
+ if (opaqueData.size())
+ painter->drawPixmapFragments(opaqueData.data(), opaqueData.size(), pixmap, QPainter::OpaqueHint);
+ if (translucentData.size())
+ painter->drawPixmapFragments(translucentData.data(), translucentData.size(), pixmap);
+
+ if (oldAA)
+ painter->setRenderHint(QPainter::Antialiasing, true);
+}
+
+QT_END_NAMESPACE
diff --git a/src/widgets/styles/qdrawutil.h b/src/widgets/styles/qdrawutil.h
new file mode 100644
index 0000000000..f46f720f2c
--- /dev/null
+++ b/src/widgets/styles/qdrawutil.h
@@ -0,0 +1,175 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDRAWUTIL_H
+#define QDRAWUTIL_H
+
+#include <QtCore/qnamespace.h>
+#include <QtCore/qstring.h> // char*->QString conversion
+#include <QtCore/qmargins.h>
+#include <QtGui/qpixmap.h>
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QPainter;
+class QPalette;
+class QPoint;
+class QColor;
+class QBrush;
+class QRect;
+
+//
+// Standard shade drawing
+//
+
+Q_GUI_EXPORT void qDrawShadeLine(QPainter *p, int x1, int y1, int x2, int y2,
+ const QPalette &pal, bool sunken = true,
+ int lineWidth = 1, int midLineWidth = 0);
+
+Q_GUI_EXPORT void qDrawShadeLine(QPainter *p, const QPoint &p1, const QPoint &p2,
+ const QPalette &pal, bool sunken = true,
+ int lineWidth = 1, int midLineWidth = 0);
+
+Q_GUI_EXPORT void qDrawShadeRect(QPainter *p, int x, int y, int w, int h,
+ const QPalette &pal, bool sunken = false,
+ int lineWidth = 1, int midLineWidth = 0,
+ const QBrush *fill = 0);
+
+Q_GUI_EXPORT void qDrawShadeRect(QPainter *p, const QRect &r,
+ const QPalette &pal, bool sunken = false,
+ int lineWidth = 1, int midLineWidth = 0,
+ const QBrush *fill = 0);
+
+Q_GUI_EXPORT void qDrawShadePanel(QPainter *p, int x, int y, int w, int h,
+ const QPalette &pal, bool sunken = false,
+ int lineWidth = 1, const QBrush *fill = 0);
+
+Q_GUI_EXPORT void qDrawShadePanel(QPainter *p, const QRect &r,
+ const QPalette &pal, bool sunken = false,
+ int lineWidth = 1, const QBrush *fill = 0);
+
+Q_GUI_EXPORT void qDrawWinButton(QPainter *p, int x, int y, int w, int h,
+ const QPalette &pal, bool sunken = false,
+ const QBrush *fill = 0);
+
+Q_GUI_EXPORT void qDrawWinButton(QPainter *p, const QRect &r,
+ const QPalette &pal, bool sunken = false,
+ const QBrush *fill = 0);
+
+Q_GUI_EXPORT void qDrawWinPanel(QPainter *p, int x, int y, int w, int h,
+ const QPalette &pal, bool sunken = false,
+ const QBrush *fill = 0);
+
+Q_GUI_EXPORT void qDrawWinPanel(QPainter *p, const QRect &r,
+ const QPalette &pal, bool sunken = false,
+ const QBrush *fill = 0);
+
+Q_GUI_EXPORT void qDrawPlainRect(QPainter *p, int x, int y, int w, int h, const QColor &,
+ int lineWidth = 1, const QBrush *fill = 0);
+
+Q_GUI_EXPORT void qDrawPlainRect(QPainter *p, const QRect &r, const QColor &,
+ int lineWidth = 1, const QBrush *fill = 0);
+
+
+
+struct QTileRules
+{
+ inline QTileRules(Qt::TileRule horizontalRule, Qt::TileRule verticalRule)
+ : horizontal(horizontalRule), vertical(verticalRule) {}
+ inline QTileRules(Qt::TileRule rule = Qt::StretchTile)
+ : horizontal(rule), vertical(rule) {}
+ Qt::TileRule horizontal;
+ Qt::TileRule vertical;
+};
+
+#ifndef Q_QDOC
+// For internal use only.
+namespace QDrawBorderPixmap
+{
+ enum DrawingHint
+ {
+ OpaqueTopLeft = 0x0001,
+ OpaqueTop = 0x0002,
+ OpaqueTopRight = 0x0004,
+ OpaqueLeft = 0x0008,
+ OpaqueCenter = 0x0010,
+ OpaqueRight = 0x0020,
+ OpaqueBottomLeft = 0x0040,
+ OpaqueBottom = 0x0080,
+ OpaqueBottomRight = 0x0100,
+ OpaqueCorners = OpaqueTopLeft | OpaqueTopRight | OpaqueBottomLeft | OpaqueBottomRight,
+ OpaqueEdges = OpaqueTop | OpaqueLeft | OpaqueRight | OpaqueBottom,
+ OpaqueFrame = OpaqueCorners | OpaqueEdges,
+ OpaqueAll = OpaqueCenter | OpaqueFrame
+ };
+
+ Q_DECLARE_FLAGS(DrawingHints, DrawingHint)
+}
+#endif
+
+Q_GUI_EXPORT void qDrawBorderPixmap(QPainter *painter,
+ const QRect &targetRect,
+ const QMargins &targetMargins,
+ const QPixmap &pixmap,
+ const QRect &sourceRect,
+ const QMargins &sourceMargins,
+ const QTileRules &rules = QTileRules()
+#ifndef Q_QDOC
+ , QDrawBorderPixmap::DrawingHints hints = 0
+#endif
+ );
+
+inline void qDrawBorderPixmap(QPainter *painter,
+ const QRect &target,
+ const QMargins &margins,
+ const QPixmap &pixmap)
+{
+ qDrawBorderPixmap(painter, target, margins, pixmap, pixmap.rect(), margins);
+}
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDRAWUTIL_H
diff --git a/src/widgets/styles/qgtkpainter.cpp b/src/widgets/styles/qgtkpainter.cpp
new file mode 100644
index 0000000000..8da3a605c6
--- /dev/null
+++ b/src/widgets/styles/qgtkpainter.cpp
@@ -0,0 +1,716 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgtkpainter_p.h"
+
+#include <QtCore/qglobal.h>
+#if !defined(QT_NO_STYLE_GTK)
+
+// This class is primarily a wrapper around the gtk painter functions
+// and takes care of converting all such calls into cached Qt pixmaps.
+
+#include <private/qstylehelper_p.h>
+#include <QtWidgets/QWidget>
+#include <QtWidgets/QStyleOption>
+#include <QtGui/QPixmapCache>
+
+QT_BEGIN_NAMESPACE
+
+#undef GTK_OBJECT_FLAGS
+#define GTK_OBJECT_FLAGS(obj)(((GtkObject*)(obj))->flags)
+
+#if Q_BYTE_ORDER == Q_BIG_ENDIAN
+# define QT_RED 3
+# define QT_GREEN 2
+# define QT_BLUE 1
+# define QT_ALPHA 0
+#else
+# define QT_RED 0
+# define QT_GREEN 1
+# define QT_BLUE 2
+# define QT_ALPHA 3
+#endif
+# define GTK_RED 2
+# define GTK_GREEN 1
+# define GTK_BLUE 0
+# define GTK_ALPHA 3
+
+// To recover alpha we apply the gtk painting function two times to
+// white, and black window backgrounds. This can be used to
+// recover the premultiplied alpha channel
+QPixmap QGtkPainter::renderTheme(uchar *bdata, uchar *wdata, const QRect &rect)
+{
+ const int bytecount = rect.width() * rect.height() * 4;
+ for (int index = 0; index < bytecount ; index += 4) {
+ uchar val = bdata[index + GTK_BLUE];
+ if (m_alpha) {
+ int alphaval = qMax(bdata[index + GTK_BLUE] - wdata[index + GTK_BLUE],
+ bdata[index + GTK_GREEN] - wdata[index + GTK_GREEN]);
+ alphaval = qMax(alphaval, bdata[index + GTK_RED] - wdata[index + GTK_RED]) + 255;
+ bdata[index + QT_ALPHA] = alphaval;
+ }
+ bdata[index + QT_RED] = bdata[index + GTK_RED];
+ bdata[index + QT_GREEN] = bdata[index + GTK_GREEN];
+ bdata[index + QT_BLUE] = val;
+ }
+ QImage converted((const uchar*)bdata, rect.width(), rect.height(), m_alpha ?
+ QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32);
+
+ if (m_hflipped || m_vflipped) {
+ return QPixmap::fromImage(converted.mirrored(m_hflipped, m_vflipped));
+ } else {
+ // on raster graphicssystem we need to do a copy here, because
+ // we intend to deallocate the qimage bits shortly after...
+ return QPixmap::fromImage(converted.copy());
+ }
+}
+
+// This macro is responsible for painting any GtkStyle painting function onto a QPixmap
+#define DRAW_TO_CACHE(draw_func) \
+ if (rect.width() > QWIDGETSIZE_MAX || rect.height() > QWIDGETSIZE_MAX) \
+ return; \
+ QRect pixmapRect(0, 0, rect.width(), rect.height()); \
+ { \
+ GdkPixmap *pixmap = QGtkStylePrivate::gdk_pixmap_new((GdkDrawable*)(m_window->window), \
+ rect.width(), rect.height(), -1); \
+ if (!pixmap) \
+ return; \
+ style = QGtkStylePrivate::gtk_style_attach (style, m_window->window); \
+ QGtkStylePrivate::gdk_draw_rectangle(pixmap, m_alpha ? style->black_gc : *style->bg_gc, true, \
+ 0, 0, rect.width(), rect.height()); \
+ draw_func; \
+ GdkPixbuf *imgb = QGtkStylePrivate::gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, rect.width(), rect.height());\
+ if (!imgb) \
+ return; \
+ imgb = QGtkStylePrivate::gdk_pixbuf_get_from_drawable(imgb, pixmap, NULL, 0, 0, 0, 0, \
+ rect.width(), rect.height()); \
+ uchar* bdata = (uchar*)QGtkStylePrivate::gdk_pixbuf_get_pixels(imgb); \
+ if (m_alpha) { \
+ QGtkStylePrivate::gdk_draw_rectangle(pixmap, style->white_gc, true, 0, 0, rect.width(), rect.height()); \
+ draw_func; \
+ GdkPixbuf *imgw = QGtkStylePrivate::gdk_pixbuf_new(GDK_COLORSPACE_RGB, true, 8, rect. \
+ width(), rect.height()); \
+ if (!imgw) \
+ return; \
+ imgw = QGtkStylePrivate::gdk_pixbuf_get_from_drawable(imgw, pixmap, NULL, 0, 0, 0, 0, \
+ rect.width(), rect.height()); \
+ uchar* wdata = (uchar*)QGtkStylePrivate::gdk_pixbuf_get_pixels(imgw); \
+ cache = renderTheme(bdata, wdata, rect); \
+ QGtkStylePrivate::gdk_pixbuf_unref(imgw); \
+ } else { \
+ cache = renderTheme(bdata, 0, rect); \
+ } \
+ QGtkStylePrivate::gdk_drawable_unref(pixmap); \
+ QGtkStylePrivate::gdk_pixbuf_unref(imgb); \
+ }
+
+QGtkPainter::QGtkPainter(QPainter *_painter)
+ : m_window(QGtkStylePrivate::gtkWidget("GtkWindow"))
+ , m_painter(_painter)
+ , m_alpha(true)
+ , m_hflipped(false)
+ , m_vflipped(false)
+ , m_usePixmapCache(true)
+{}
+
+
+static QString uniqueName(const QString &key, GtkStateType state, GtkShadowType shadow,
+ const QSize &size, GtkWidget *widget = 0)
+{
+ // Note the widget arg should ideally use the widget path, though would compromise performance
+ QString tmp = key
+ % HexString<uint>(state)
+ % HexString<uint>(shadow)
+ % HexString<uint>(size.width())
+ % HexString<uint>(size.height())
+ % HexString<quint64>(quint64(widget));
+ return tmp;
+}
+
+
+GtkStateType QGtkPainter::gtkState(const QStyleOption *option)
+
+{
+ GtkStateType state = GTK_STATE_NORMAL;
+ if (!(option->state & QStyle::State_Enabled))
+ state = GTK_STATE_INSENSITIVE;
+ else if (option->state & QStyle::State_MouseOver)
+ state = GTK_STATE_PRELIGHT;
+
+ return state;
+}
+
+
+GtkStyle* QGtkPainter::getStyle(GtkWidget *gtkWidget)
+
+{
+ Q_ASSERT(gtkWidget);
+ GtkStyle* style = gtkWidget->style;
+ Q_ASSERT(style);
+ return style;
+}
+
+QPixmap QGtkPainter::getIcon(const char* iconName, GtkIconSize size)
+{
+ GtkStyle *style = QGtkStylePrivate::gtkStyle();
+ GtkIconSet* iconSet = QGtkStylePrivate::gtk_icon_factory_lookup_default (iconName);
+ GdkPixbuf* icon = QGtkStylePrivate::gtk_icon_set_render_icon(iconSet,
+ style,
+ GTK_TEXT_DIR_LTR,
+ GTK_STATE_NORMAL,
+ size,
+ NULL,
+ "button");
+ uchar* data = (uchar*)QGtkStylePrivate::gdk_pixbuf_get_pixels(icon);
+ int width = QGtkStylePrivate::gdk_pixbuf_get_width(icon);
+ int height = QGtkStylePrivate::gdk_pixbuf_get_height(icon);
+ QImage converted(width, height, QImage::Format_ARGB32);
+ uchar* tdata = (uchar*)converted.bits();
+
+ for ( int index = 0 ; index < height * width*4 ; index +=4 ) {
+ //int index = y * rowstride + x;
+ tdata[index + QT_RED] = data[index + GTK_RED];
+ tdata[index + QT_GREEN] = data[index + GTK_GREEN];
+ tdata[index + QT_BLUE] = data[index + GTK_BLUE];
+ tdata[index + QT_ALPHA] = data[index + GTK_ALPHA];
+ }
+
+ QGtkStylePrivate::gdk_pixbuf_unref(icon);
+
+ // should we free iconset?
+ return QPixmap::fromImage(converted);
+
+}
+
+// Note currently painted without alpha for performance reasons
+void QGtkPainter::paintBoxGap(GtkWidget *gtkWidget, const gchar* part,
+ const QRect &paintRect, GtkStateType state,
+ GtkShadowType shadow, GtkPositionType gap_side,
+ gint x, gint width,
+ GtkStyle *style)
+{
+ if (!paintRect.isValid())
+ return;
+
+ QPixmap cache;
+ QRect rect = paintRect;
+
+ // To avoid exhausting cache on large tabframes we cheat a bit by
+ // tiling the center part.
+
+ const int maxHeight = 256;
+ const int border = 16;
+ if (rect.height() > maxHeight && (gap_side == GTK_POS_TOP || gap_side == GTK_POS_BOTTOM))
+ rect.setHeight(2 * border + 1);
+
+ QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget)
+ % HexString<uchar>(gap_side)
+ % HexString<gint>(width)
+ % HexString<gint>(x);
+
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_box_gap (style,
+ pixmap,
+ state,
+ shadow,
+ NULL,
+ gtkWidget,
+ (gchar*)part,
+ 0, 0,
+ rect.width(),
+ rect.height(),
+ gap_side,
+ x,
+ width));
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+ if (rect.size() != paintRect.size()) {
+ // We assume we can stretch the middle tab part
+ // Note: the side effect of this is that pinstripe patterns will get fuzzy
+ const QSize size = cache.size();
+ // top part
+ m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top(),
+ paintRect.width(), border), cache,
+ QRect(0, 0, size.width(), border));
+
+ // tiled center part
+ QPixmap tilePart(cache.width(), 1);
+ QPainter scanLinePainter(&tilePart);
+ scanLinePainter.drawPixmap(QRect(0, 0, tilePart.width(), tilePart.height()), cache, QRect(0, border, size.width(), 1));
+ scanLinePainter.end();
+ m_painter->drawTiledPixmap(QRect(paintRect.left(), paintRect.top() + border,
+ paintRect.width(), paintRect.height() - 2*border), tilePart);
+
+ // bottom part
+ m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top() + paintRect.height() - border,
+ paintRect.width(), border), cache,
+ QRect(0, size.height() - border, size.width(), border));
+ } else
+ m_painter->drawPixmap(paintRect.topLeft(), cache);
+}
+
+void QGtkPainter::paintBox(GtkWidget *gtkWidget, const gchar* part,
+ const QRect &paintRect, GtkStateType state,
+ GtkShadowType shadow, GtkStyle *style,
+ const QString &pmKey)
+{
+ if (!paintRect.isValid())
+ return;
+
+ QPixmap cache;
+ QRect rect = paintRect;
+
+ // To avoid exhausting cache on large tabframes we cheat a bit by
+ // tiling the center part.
+
+ const int maxHeight = 256;
+ const int maxArea = 256*512;
+ const int border = 32;
+ if (rect.height() > maxHeight && (rect.width()*rect.height() > maxArea))
+ rect.setHeight(2 * border + 1);
+
+ QString pixmapName = uniqueName(QLS(part), state, shadow,
+ rect.size(), gtkWidget) % pmKey;
+
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_box (style,
+ pixmap,
+ state,
+ shadow,
+ NULL,
+ gtkWidget,
+ part,
+ 0, 0,
+ rect.width(),
+ rect.height()));
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+ if (rect.size() != paintRect.size()) {
+ // We assume we can stretch the middle tab part
+ // Note: the side effect of this is that pinstripe patterns will get fuzzy
+ const QSize size = cache.size();
+ // top part
+ m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top(),
+ paintRect.width(), border), cache,
+ QRect(0, 0, size.width(), border));
+
+ // tiled center part
+ QPixmap tilePart(cache.width(), 1);
+ QPainter scanLinePainter(&tilePart);
+ scanLinePainter.drawPixmap(QRect(0, 0, tilePart.width(), tilePart.height()), cache, QRect(0, border, size.width(), 1));
+ scanLinePainter.end();
+ m_painter->drawTiledPixmap(QRect(paintRect.left(), paintRect.top() + border,
+ paintRect.width(), paintRect.height() - 2*border), tilePart);
+
+ // bottom part
+ m_painter->drawPixmap(QRect(paintRect.left(), paintRect.top() + paintRect.height() - border,
+ paintRect.width(), border), cache,
+ QRect(0, size.height() - border, size.width(), border));
+ } else
+ m_painter->drawPixmap(paintRect.topLeft(), cache);
+}
+
+void QGtkPainter::paintHline(GtkWidget *gtkWidget, const gchar* part,
+ const QRect &rect, GtkStateType state,
+ GtkStyle *style, int x1, int x2, int y,
+ const QString &pmKey)
+{
+ if (!rect.isValid())
+ return;
+
+ QPixmap cache;
+ QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget)
+ % HexString<int>(x1)
+ % HexString<int>(x2)
+ % HexString<int>(y)
+ % pmKey;
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_hline (style,
+ pixmap,
+ state,
+ NULL,
+ gtkWidget,
+ part,
+ x1, x2, y));
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+
+ m_painter->drawPixmap(rect.topLeft(), cache);
+}
+
+void QGtkPainter::paintVline(GtkWidget *gtkWidget, const gchar* part,
+ const QRect &rect, GtkStateType state,
+ GtkStyle *style, int y1, int y2, int x,
+ const QString &pmKey)
+{
+ if (!rect.isValid())
+ return;
+
+ QPixmap cache;
+ QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget)
+ % HexString<int>(y1)
+ % HexString<int>(y2)
+ % HexString<int>(x)
+ % pmKey;
+
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_vline (style,
+ pixmap,
+ state,
+ NULL,
+ gtkWidget,
+ part,
+ y1, y2,
+ x));
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+ m_painter->drawPixmap(rect.topLeft(), cache);
+}
+
+
+void QGtkPainter::paintExpander(GtkWidget *gtkWidget,
+ const gchar* part, const QRect &rect,
+ GtkStateType state, GtkExpanderStyle expander_state,
+ GtkStyle *style, const QString &pmKey)
+{
+ if (!rect.isValid())
+ return;
+
+ QPixmap cache;
+ QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget)
+ % HexString<uchar>(expander_state)
+ % pmKey;
+
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_expander (style, pixmap,
+ state, NULL,
+ gtkWidget, part,
+ rect.width()/2,
+ rect.height()/2,
+ expander_state));
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+
+ m_painter->drawPixmap(rect.topLeft(), cache);
+}
+
+void QGtkPainter::paintFocus(GtkWidget *gtkWidget, const gchar* part,
+ const QRect &rect, GtkStateType state,
+ GtkStyle *style, const QString &pmKey)
+{
+ if (!rect.isValid())
+ return;
+
+ QPixmap cache;
+ QString pixmapName = uniqueName(QLS(part), state, GTK_SHADOW_NONE, rect.size(), gtkWidget) % pmKey;
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_focus (style, pixmap, state, NULL,
+ gtkWidget,
+ part,
+ 0, 0,
+ rect.width(),
+ rect.height()));
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+
+ m_painter->drawPixmap(rect.topLeft(), cache);
+}
+
+
+void QGtkPainter::paintResizeGrip(GtkWidget *gtkWidget, const gchar* part,
+ const QRect &rect, GtkStateType state,
+ GtkShadowType shadow, GdkWindowEdge edge,
+ GtkStyle *style, const QString &pmKey)
+{
+ if (!rect.isValid())
+ return;
+
+ QPixmap cache;
+ QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget) % pmKey;
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_resize_grip (style, pixmap, state,
+ NULL, gtkWidget,
+ part, edge, 0, 0,
+ rect.width(),
+ rect.height()));
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+
+ m_painter->drawPixmap(rect.topLeft(), cache);
+}
+
+
+void QGtkPainter::paintArrow(GtkWidget *gtkWidget, const gchar* part,
+ const QRect &arrowrect, GtkArrowType arrow_type,
+ GtkStateType state, GtkShadowType shadow,
+ gboolean fill, GtkStyle *style, const QString &pmKey)
+{
+ QRect rect = m_cliprect.isValid() ? m_cliprect : arrowrect;
+ if (!rect.isValid())
+ return;
+
+ QPixmap cache;
+ QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size())
+ % HexString<uchar>(arrow_type)
+ % pmKey;
+
+ GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()};
+ int xOffset = m_cliprect.isValid() ? arrowrect.x() - m_cliprect.x() : 0;
+ int yOffset = m_cliprect.isValid() ? arrowrect.y() - m_cliprect.y() : 0;
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_arrow (style, pixmap, state, shadow,
+ &gtkCliprect,
+ gtkWidget,
+ part,
+ arrow_type, fill,
+ xOffset, yOffset,
+ arrowrect.width(),
+ arrowrect.height()))
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+
+ m_painter->drawPixmap(rect.topLeft(), cache);
+}
+
+
+void QGtkPainter::paintHandle(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
+ GtkStateType state, GtkShadowType shadow,
+ GtkOrientation orientation, GtkStyle *style)
+{
+ if (!rect.isValid())
+ return;
+
+ QPixmap cache;
+ QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size())
+ % HexString<uchar>(orientation);
+
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_handle (style,
+ pixmap,
+ state,
+ shadow,
+ NULL,
+ gtkWidget,
+ part, 0, 0,
+ rect.width(),
+ rect.height(),
+ orientation));
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+ m_painter->drawPixmap(rect.topLeft(), cache);
+}
+
+
+void QGtkPainter::paintSlider(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
+ GtkStateType state, GtkShadowType shadow,
+ GtkStyle *style, GtkOrientation orientation,
+ const QString &pmKey)
+{
+ if (!rect.isValid())
+ return;
+
+ QPixmap cache;
+ QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget) % pmKey;
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_slider (style,
+ pixmap,
+ state,
+ shadow,
+ NULL,
+ gtkWidget,
+ part,
+ 0, 0,
+ rect.width(),
+ rect.height(),
+ orientation));
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+ m_painter->drawPixmap(rect.topLeft(), cache);
+}
+
+
+void QGtkPainter::paintShadow(GtkWidget *gtkWidget, const gchar* part,
+ const QRect &rect, GtkStateType state,
+ GtkShadowType shadow, GtkStyle *style,
+ const QString &pmKey)
+
+{
+ if (!rect.isValid())
+ return;
+
+ QPixmap cache;
+ QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) % pmKey;
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_shadow(style, pixmap, state, shadow, NULL,
+ gtkWidget, part, 0, 0, rect.width(), rect.height()));
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+ m_painter->drawPixmap(rect.topLeft(), cache);
+}
+
+void QGtkPainter::paintFlatBox(GtkWidget *gtkWidget, const gchar* part,
+ const QRect &rect, GtkStateType state,
+ GtkShadowType shadow, GtkStyle *style,
+ const QString &pmKey)
+{
+ if (!rect.isValid())
+ return;
+ QPixmap cache;
+ QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size()) % pmKey;
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_flat_box (style,
+ pixmap,
+ state,
+ shadow,
+ NULL,
+ gtkWidget,
+ part, 0, 0,
+ rect.width(),
+ rect.height()));
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+ m_painter->drawPixmap(rect.topLeft(), cache);
+}
+
+void QGtkPainter::paintExtention(GtkWidget *gtkWidget,
+ const gchar *part, const QRect &rect,
+ GtkStateType state, GtkShadowType shadow,
+ GtkPositionType gap_pos, GtkStyle *style)
+{
+ if (!rect.isValid())
+ return;
+
+ QPixmap cache;
+ QString pixmapName = uniqueName(QLS(part), state, shadow, rect.size(), gtkWidget)
+ % HexString<uchar>(gap_pos);
+
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_extension (style, pixmap, state, shadow,
+ NULL, gtkWidget,
+ (gchar*)part, 0, 0,
+ rect.width(),
+ rect.height(),
+ gap_pos));
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+
+ m_painter->drawPixmap(rect.topLeft(), cache);
+}
+
+void QGtkPainter::paintOption(GtkWidget *gtkWidget, const QRect &radiorect,
+ GtkStateType state, GtkShadowType shadow,
+ GtkStyle *style, const QString &detail)
+
+{
+ QRect rect = m_cliprect.isValid() ? m_cliprect : radiorect;
+ if (!rect.isValid())
+ return;
+
+ QPixmap cache;
+ QString pixmapName = uniqueName(detail, state, shadow, rect.size());
+ GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()};
+ int xOffset = m_cliprect.isValid() ? radiorect.x() - m_cliprect.x() : 0;
+ int yOffset = m_cliprect.isValid() ? radiorect.y() - m_cliprect.y() : 0;
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_option(style, pixmap,
+ state, shadow,
+ &gtkCliprect,
+ gtkWidget,
+ detail.toLatin1(),
+ xOffset, yOffset,
+ radiorect.width(),
+ radiorect.height()));
+
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+
+ m_painter->drawPixmap(rect.topLeft(), cache);
+}
+
+void QGtkPainter::paintCheckbox(GtkWidget *gtkWidget, const QRect &checkrect,
+ GtkStateType state, GtkShadowType shadow,
+ GtkStyle *style, const QString &detail)
+
+{
+ QRect rect = m_cliprect.isValid() ? m_cliprect : checkrect;
+ if (!rect.isValid())
+ return;
+
+ QPixmap cache;
+ QString pixmapName = uniqueName(detail, state, shadow, rect.size());
+ GdkRectangle gtkCliprect = {0, 0, rect.width(), rect.height()};
+ int xOffset = m_cliprect.isValid() ? checkrect.x() - m_cliprect.x() : 0;
+ int yOffset = m_cliprect.isValid() ? checkrect.y() - m_cliprect.y() : 0;
+ if (!m_usePixmapCache || !QPixmapCache::find(pixmapName, cache)) {
+ DRAW_TO_CACHE(QGtkStylePrivate::gtk_paint_check (style,
+ pixmap,
+ state,
+ shadow,
+ &gtkCliprect,
+ gtkWidget,
+ detail.toLatin1(),
+ xOffset, yOffset,
+ checkrect.width(),
+ checkrect.height()));
+ if (m_usePixmapCache)
+ QPixmapCache::insert(pixmapName, cache);
+ }
+
+ m_painter->drawPixmap(rect.topLeft(), cache);
+}
+
+QT_END_NAMESPACE
+
+#endif //!defined(QT_NO_STYLE_GTK)
diff --git a/src/widgets/styles/qgtkpainter_p.h b/src/widgets/styles/qgtkpainter_p.h
new file mode 100644
index 0000000000..121466622b
--- /dev/null
+++ b/src/widgets/styles/qgtkpainter_p.h
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGTKPAINTER_H
+#define QGTKPAINTER_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qglobal.h>
+#if !defined(QT_NO_STYLE_GTK)
+
+#include <QtWidgets/QCleanlooksStyle>
+#include <QtGui/QPainter>
+#include <QtGui/QPalette>
+#include <QtGui/QFont>
+#include <private/qgtkstyle_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QGtkPainter
+{
+
+public:
+ QGtkPainter(QPainter *painter);
+ GtkStyle *getStyle(GtkWidget *gtkWidget);
+ GtkStateType gtkState(const QStyleOption *option);
+
+ void setAlphaSupport(bool value) { m_alpha = value; }
+ void setClipRect(const QRect &rect) { m_cliprect = rect; }
+ void setFlipHorizontal(bool value) { m_hflipped = value; }
+ void setFlipVertical(bool value) { m_vflipped = value; }
+ void setUsePixmapCache(bool value) { m_usePixmapCache = value; }
+
+ void paintBoxGap(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
+ GtkStateType state, GtkShadowType shadow, GtkPositionType gap_side, gint x,
+ gint width, GtkStyle *style);
+ void paintBox(GtkWidget *gtkWidget, const gchar* part,
+ const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style,
+ const QString &pmKey = QString());
+ void paintHline(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
+ int x1, int x2, int y, const QString &pmKey = QString());
+ void paintVline(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
+ int y1, int y2, int x, const QString &pmKey = QString());
+ void paintExpander(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state,
+ GtkExpanderStyle expander_state, GtkStyle *style, const QString &pmKey = QString());
+ void paintFocus(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkStyle *style,
+ const QString &pmKey = QString());
+ void paintResizeGrip(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
+ GdkWindowEdge edge, GtkStyle *style, const QString &pmKey = QString());
+ void paintArrow(GtkWidget *gtkWidget, const gchar* part, const QRect &arrowrect, GtkArrowType arrow_type, GtkStateType state, GtkShadowType shadow,
+ gboolean fill, GtkStyle *style, const QString &pmKey = QString());
+ void paintHandle(GtkWidget *gtkWidget, const gchar* part, const QRect &rect,
+ GtkStateType state, GtkShadowType shadow, GtkOrientation orientation, GtkStyle *style);
+ void paintSlider(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
+ GtkStyle *style, GtkOrientation orientation, const QString &pmKey = QString());
+ void paintShadow(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
+ GtkStyle *style, const QString &pmKey = QString());
+ void paintFlatBox(GtkWidget *gtkWidget, const gchar* part, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString & = QString());
+ void paintExtention(GtkWidget *gtkWidget, const gchar *part, const QRect &rect, GtkStateType state, GtkShadowType shadow,
+ GtkPositionType gap_pos, GtkStyle *style);
+ void paintOption(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail);
+ void paintCheckbox(GtkWidget *gtkWidget, const QRect &rect, GtkStateType state, GtkShadowType shadow, GtkStyle *style, const QString &detail);
+
+ static QPixmap getIcon(const char* iconName, GtkIconSize size = GTK_ICON_SIZE_BUTTON);
+private:
+ QPixmap renderTheme(uchar *bdata, uchar *wdata, const QRect&);
+
+ GtkWidget *m_window;
+ QPainter *m_painter;
+ bool m_alpha;
+ bool m_hflipped;
+ bool m_vflipped;
+ bool m_usePixmapCache;
+ QRect m_cliprect;
+
+};
+
+QT_END_NAMESPACE
+
+#endif //!defined(QT_NO_STYLE_QGTK)
+
+#endif // QGTKPAINTER_H
diff --git a/src/widgets/styles/qgtkstyle.cpp b/src/widgets/styles/qgtkstyle.cpp
new file mode 100644
index 0000000000..78a0c945a1
--- /dev/null
+++ b/src/widgets/styles/qgtkstyle.cpp
@@ -0,0 +1,3560 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "qgtkstyle.h"
+
+#if !defined(QT_NO_STYLE_GTK)
+
+#include <private/qapplication_p.h>
+#include <QtCore/QLibrary>
+#include <QtCore/QSettings>
+#include <QtWidgets/QDialogButtonBox>
+#include <QtWidgets/QStatusBar>
+#include <QtWidgets/QLineEdit>
+#include <QtWidgets/QWidget>
+#include <QtWidgets/QListView>
+#include <QtWidgets/QApplication>
+#include <QtWidgets/QStyleOption>
+#include <QtWidgets/QPushButton>
+#include <QtGui/QPainter>
+#include <QtWidgets/QMainWindow>
+#include <QtWidgets/QToolBar>
+#include <QtWidgets/QHeaderView>
+#include <QtWidgets/QMenuBar>
+#include <QtWidgets/QComboBox>
+#include <QtWidgets/QSpinBox>
+#include <QtWidgets/QScrollBar>
+#include <QtWidgets/QAbstractButton>
+#include <QtWidgets/QToolButton>
+#include <QtWidgets/QGroupBox>
+#include <QtWidgets/QRadioButton>
+#include <QtWidgets/QCheckBox>
+#include <QtWidgets/QTreeView>
+#include <QtWidgets/QStyledItemDelegate>
+#include <qpixmapcache.h>
+#undef signals // Collides with GTK stymbols
+#include <private/qgtkpainter_p.h>
+#include <private/qstylehelper_p.h>
+#include <private/qgtkstyle_p.h>
+#include <private/qcleanlooksstyle_p.h>
+
+
+QT_BEGIN_NAMESPACE
+
+static const char * const dock_widget_close_xpm[] =
+ {
+ "11 13 5 1",
+ " c None",
+ ". c #D5CFCB",
+ "+ c #6C6A67",
+ "@ c #6C6A67",
+ "$ c #B5B0AC",
+ " ",
+ " @@@@@@@@@ ",
+ "@+ +@",
+ "@ +@ @+ @",
+ "@ @@@ @@@ @",
+ "@ @@@@@ @",
+ "@ @@@ @",
+ "@ @@@@@ @",
+ "@ @@@ @@@ @",
+ "@ +@ @+ @",
+ "@+ +@",
+ " @@@@@@@@@ ",
+ " "
+ };
+
+static const char * const dock_widget_restore_xpm[] =
+ {
+ "11 13 5 1",
+ " c None",
+ ". c #D5CFCB",
+ "+ c #6C6A67",
+ "@ c #6C6A67",
+ "# c #6C6A67",
+ " ",
+ " @@@@@@@@@ ",
+ "@+ +@",
+ "@ #@@@# @",
+ "@ @ @ @",
+ "@ #@@@# @ @",
+ "@ @ @ @ @",
+ "@ @ @@@ @",
+ "@ @ @ @",
+ "@ #@@@@ @",
+ "@+ +@",
+ " @@@@@@@@@ ",
+ " "
+ };
+
+static const int groupBoxBottomMargin = 2; // space below the groupbox
+static const int groupBoxTitleMargin = 6; // space between contents and title
+static const int groupBoxTopMargin = 2;
+
+/*!
+ Returns the configuration string for \a value.
+ Returns \a fallback if \a value is not found.
+ */
+QString QGtkStyle::getGConfString(const QString &value, const QString &fallback)
+{
+ return QGtkStylePrivate::getGConfString(value, fallback);
+}
+
+/*!
+ Returns the configuration boolean for \a key.
+ Returns \a fallback if \a key is not found.
+ */
+bool QGtkStyle::getGConfBool(const QString &key, bool fallback)
+{
+ return QGtkStylePrivate::getGConfBool(key, fallback);
+}
+
+static QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor = 50)
+{
+ const int maxFactor = 100;
+ QColor tmp = colorA;
+ tmp.setRed((tmp.red() * factor) / maxFactor + (colorB.red() * (maxFactor - factor)) / maxFactor);
+ tmp.setGreen((tmp.green() * factor) / maxFactor + (colorB.green() * (maxFactor - factor)) / maxFactor);
+ tmp.setBlue((tmp.blue() * factor) / maxFactor + (colorB.blue() * (maxFactor - factor)) / maxFactor);
+ return tmp;
+}
+
+static GdkColor fromQColor(const QColor &color)
+{
+ GdkColor retval;
+ retval.red = color.red() * 255;
+ retval.green = color.green() * 255;
+ retval.blue = color.blue() * 255;
+ return retval;
+}
+
+/*!
+ \class QGtkStyle
+ \brief The QGtkStyle class provides a widget style rendered by GTK+
+ \since 4.5
+
+ The QGtkStyle style provides a look and feel that integrates well
+ into GTK-based desktop environments such as the XFCe and GNOME.
+
+ It does this by making use of the GTK+ theme engine, ensuring
+ that Qt applications look and feel native on these platforms.
+
+ Note: The style requires GTK+ version 2.10 or later.
+ The Qt3-based "Qt" GTK+ theme engine will not work with QGtkStyle.
+
+ \sa {Cleanlooks Style Widget Gallery}, QWindowsXPStyle, QMacStyle, QWindowsStyle,
+ QCDEStyle, QMotifStyle, QPlastiqueStyle, QCleanlooksStyle
+*/
+
+/*!
+ Constructs a QGtkStyle object.
+*/
+QGtkStyle::QGtkStyle()
+ : QCleanlooksStyle(*new QGtkStylePrivate)
+{
+ Q_D(QGtkStyle);
+ d->init();
+}
+
+/*!
+ \internal
+
+ Constructs a QGtkStyle object.
+*/
+QGtkStyle::QGtkStyle(QGtkStylePrivate &dd)
+ : QCleanlooksStyle(dd)
+{
+ Q_D(QGtkStyle);
+ d->init();
+}
+
+
+/*!
+ Destroys the QGtkStyle object.
+*/
+QGtkStyle::~QGtkStyle()
+{
+}
+
+/*!
+ \reimp
+*/
+QPalette QGtkStyle::standardPalette() const
+{
+ Q_D(const QGtkStyle);
+
+ QPalette palette = QCleanlooksStyle::standardPalette();
+ if (d->isThemeAvailable()) {
+ GtkStyle *style = d->gtkStyle();
+ GtkWidget *gtkButton = d->gtkWidget("GtkButton");
+ GtkWidget *gtkEntry = d->getTextColorWidget();
+ GdkColor gdkBg, gdkBase, gdkText, gdkForeground, gdkSbg, gdkSfg, gdkaSbg, gdkaSfg;
+ QColor bg, base, text, fg, highlight, highlightText, inactiveHighlight, inactiveHighlightedTExt;
+ gdkBg = style->bg[GTK_STATE_NORMAL];
+ gdkForeground = gtkButton->style->fg[GTK_STATE_NORMAL];
+
+ // Our base and selected color is primarily used for text
+ // so we assume a gtkEntry will have the most correct value
+ gdkBase = gtkEntry->style->base[GTK_STATE_NORMAL];
+ gdkText = gtkEntry->style->text[GTK_STATE_NORMAL];
+ gdkSbg = gtkEntry->style->base[GTK_STATE_SELECTED];
+ gdkSfg = gtkEntry->style->text[GTK_STATE_SELECTED];
+
+ // The ACTIVE base color is really used for inactive windows
+ gdkaSbg = gtkEntry->style->base[GTK_STATE_ACTIVE];
+ gdkaSfg = gtkEntry->style->text[GTK_STATE_ACTIVE];
+
+ bg = QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8);
+ text = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
+ fg = QColor(gdkForeground.red>>8, gdkForeground.green>>8, gdkForeground.blue>>8);
+ base = QColor(gdkBase.red>>8, gdkBase.green>>8, gdkBase.blue>>8);
+ highlight = QColor(gdkSbg.red>>8, gdkSbg.green>>8, gdkSbg.blue>>8);
+ highlightText = QColor(gdkSfg.red>>8, gdkSfg.green>>8, gdkSfg.blue>>8);
+ inactiveHighlight = QColor(gdkaSbg.red>>8, gdkaSbg.green>>8, gdkaSbg.blue>>8);
+ inactiveHighlightedTExt = QColor(gdkaSfg.red>>8, gdkaSfg.green>>8, gdkaSfg.blue>>8);
+
+ palette.setColor(QPalette::HighlightedText, highlightText);
+
+
+ palette.setColor(QPalette::Light, bg.lighter(125));
+ palette.setColor(QPalette::Shadow, bg.darker(130));
+ palette.setColor(QPalette::Dark, bg.darker(120));
+ palette.setColor(QPalette::Text, text);
+ palette.setColor(QPalette::WindowText, fg);
+ palette.setColor(QPalette::ButtonText, fg);
+ palette.setColor(QPalette::Base, base);
+
+ QColor alternateRowColor = palette.base().color().lighter(93); // ref gtkstyle.c draw_flat_box
+ GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView");
+ GdkColor *gtkAltBase = NULL;
+ d->gtk_widget_style_get(gtkTreeView, "odd-row-color", &gtkAltBase, NULL);
+ if (gtkAltBase) {
+ alternateRowColor = QColor(gtkAltBase->red>>8, gtkAltBase->green>>8, gtkAltBase->blue>>8);
+ d->gdk_color_free(gtkAltBase);
+ }
+ palette.setColor(QPalette::AlternateBase, alternateRowColor);
+
+ palette.setColor(QPalette::Window, bg);
+ palette.setColor(QPalette::Button, bg);
+ palette.setColor(QPalette::Background, bg);
+ QColor disabled((fg.red() + bg.red()) / 2,
+ (fg.green() + bg.green())/ 2,
+ (fg.blue() + bg.blue()) / 2);
+ palette.setColor(QPalette::Disabled, QPalette::Text, disabled);
+ palette.setColor(QPalette::Disabled, QPalette::WindowText, disabled);
+ palette.setColor(QPalette::Disabled, QPalette::Foreground, disabled);
+ palette.setColor(QPalette::Disabled, QPalette::ButtonText, disabled);
+ palette.setColor(QPalette::Highlight, highlight);
+ // calculate disabled colors by removing saturation
+ highlight.setHsv(highlight.hue(), 0, highlight.value(), highlight.alpha());
+ highlightText.setHsv(highlightText.hue(), 0, highlightText.value(), highlightText.alpha());
+ palette.setColor(QPalette::Disabled, QPalette::Highlight, highlight);
+ palette.setColor(QPalette::Disabled, QPalette::HighlightedText, highlightText);
+
+ palette.setColor(QPalette::Inactive, QPalette::HighlightedText, inactiveHighlightedTExt);
+ palette.setColor(QPalette::Inactive, QPalette::Highlight, inactiveHighlight);
+
+ style = d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(), "gtk-tooltips", "GtkWindow",
+ d->gtk_window_get_type());
+ if (style) {
+ gdkText = style->fg[GTK_STATE_NORMAL];
+ text = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
+ palette.setColor(QPalette::ToolTipText, text);
+ }
+ }
+ return palette;
+}
+
+/*!
+ \reimp
+*/
+void QGtkStyle::polish(QPalette &palette)
+{
+ Q_D(QGtkStyle);
+
+ // QCleanlooksStyle will alter the palette, hence we do
+ // not want to polish the palette unless we are using it as
+ // the fallback
+ if (!d->isThemeAvailable())
+ QCleanlooksStyle::polish(palette);
+ else
+ palette = palette.resolve(standardPalette());
+}
+
+/*!
+ \reimp
+*/
+void QGtkStyle::polish(QApplication *app)
+{
+ Q_D(QGtkStyle);
+
+ QCleanlooksStyle::polish(app);
+ // Custom fonts and palettes with QtConfig are intentionally
+ // not supported as these should be entirely determined by
+ // current Gtk settings
+ if (app->desktopSettingsAware() && d->isThemeAvailable()) {
+ QApplicationPrivate::setSystemPalette(standardPalette());
+ QApplicationPrivate::setSystemFont(d->getThemeFont());
+ d->applyCustomPaletteHash();
+ if (!d->isKDE4Session()) {
+ qt_filedialog_open_filename_hook = &QGtkStylePrivate::openFilename;
+ qt_filedialog_save_filename_hook = &QGtkStylePrivate::saveFilename;
+ qt_filedialog_open_filenames_hook = &QGtkStylePrivate::openFilenames;
+ qt_filedialog_existing_directory_hook = &QGtkStylePrivate::openDirectory;
+ qApp->installEventFilter(&d->filter);
+ }
+ }
+}
+
+/*!
+ \reimp
+*/
+void QGtkStyle::unpolish(QApplication *app)
+{
+ Q_D(QGtkStyle);
+
+ QCleanlooksStyle::unpolish(app);
+ QPixmapCache::clear();
+
+ if (app->desktopSettingsAware() && d->isThemeAvailable()
+ && !d->isKDE4Session()) {
+ qt_filedialog_open_filename_hook = 0;
+ qt_filedialog_save_filename_hook = 0;
+ qt_filedialog_open_filenames_hook = 0;
+ qt_filedialog_existing_directory_hook = 0;
+ qApp->removeEventFilter(&d->filter);
+ }
+}
+
+/*!
+ \reimp
+*/
+
+void QGtkStyle::polish(QWidget *widget)
+{
+ Q_D(QGtkStyle);
+
+ QCleanlooksStyle::polish(widget);
+ if (!d->isThemeAvailable())
+ return;
+ if (qobject_cast<QAbstractButton*>(widget)
+ || qobject_cast<QToolButton*>(widget)
+ || qobject_cast<QComboBox*>(widget)
+ || qobject_cast<QGroupBox*>(widget)
+ || qobject_cast<QScrollBar*>(widget)
+ || qobject_cast<QSlider*>(widget)
+ || qobject_cast<QAbstractSpinBox*>(widget)
+ || qobject_cast<QSpinBox*>(widget)
+ || qobject_cast<QHeaderView*>(widget))
+ widget->setAttribute(Qt::WA_Hover);
+ else if (QTreeView *tree = qobject_cast<QTreeView *> (widget))
+ tree->viewport()->setAttribute(Qt::WA_Hover);
+}
+
+/*!
+ \reimp
+*/
+void QGtkStyle::unpolish(QWidget *widget)
+{
+ QCleanlooksStyle::unpolish(widget);
+}
+
+/*!
+ \reimp
+*/
+int QGtkStyle::pixelMetric(PixelMetric metric,
+ const QStyleOption *option,
+ const QWidget *widget) const
+{
+ Q_D(const QGtkStyle);
+
+ if (!d->isThemeAvailable())
+ return QCleanlooksStyle::pixelMetric(metric, option, widget);
+
+ switch (metric) {
+ case PM_DefaultFrameWidth:
+ if (qobject_cast<const QFrame*>(widget)) {
+ if (GtkStyle *style =
+ d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(),
+ "*.GtkScrolledWindow",
+ "*.GtkScrolledWindow",
+ d->gtk_window_get_type()))
+ return qMax(style->xthickness, style->ythickness);
+ }
+ return 2;
+
+ case PM_MenuButtonIndicator:
+ return 20;
+
+ case PM_TabBarBaseOverlap:
+ return 1;
+
+ case PM_ToolBarSeparatorExtent:
+ return 11;
+
+ case PM_ToolBarFrameWidth:
+ return 1;
+
+ case PM_ToolBarItemSpacing:
+ return 0;
+
+ case PM_ButtonShiftHorizontal: {
+ GtkWidget *gtkButton = d->gtkWidget("GtkButton");
+ guint horizontal_shift;
+ d->gtk_widget_style_get(gtkButton, "child-displacement-x", &horizontal_shift, NULL);
+ return horizontal_shift;
+ }
+
+ case PM_ButtonShiftVertical: {
+ GtkWidget *gtkButton = d->gtkWidget("GtkButton");
+ guint vertical_shift;
+ d->gtk_widget_style_get(gtkButton, "child-displacement-y", &vertical_shift, NULL);
+ return vertical_shift;
+ }
+
+ case PM_MenuBarPanelWidth:
+ return 0;
+
+ case PM_MenuPanelWidth: {
+ GtkWidget *gtkMenu = d->gtkWidget("GtkMenu");
+ guint horizontal_padding = 0;
+ // horizontal-padding is used by Maemo to get thicker borders
+ if (!d->gtk_check_version(2, 10, 0))
+ d->gtk_widget_style_get(gtkMenu, "horizontal-padding", &horizontal_padding, NULL);
+ int padding = qMax<int>(gtkMenu->style->xthickness, horizontal_padding);
+ return padding;
+ }
+
+ case PM_ButtonIconSize: {
+ int retVal = 24;
+ GtkSettings *settings = d->gtk_settings_get_default();
+ gchararray icon_sizes;
+ g_object_get(settings, "gtk-icon-sizes", &icon_sizes, NULL);
+ QStringList values = QString(QLS(icon_sizes)).split(QLatin1Char(':'));
+ g_free(icon_sizes);
+ QChar splitChar(QLatin1Char(','));
+ foreach (const QString &value, values) {
+ if (value.startsWith(QLS("gtk-button="))) {
+ QString iconSize = value.right(value.size() - 11);
+
+ if (iconSize.contains(splitChar))
+ retVal = iconSize.split(splitChar)[0].toInt();
+ break;
+ }
+ }
+ return retVal;
+ }
+
+ case PM_MenuVMargin:
+
+ case PM_MenuHMargin:
+ return 0;
+
+ case PM_DockWidgetTitleMargin:
+ return 0;
+
+ case PM_DockWidgetTitleBarButtonMargin:
+ return 5;
+
+ case PM_TabBarTabVSpace:
+ return 12;
+
+ case PM_TabBarTabHSpace:
+ return 14;
+
+ case PM_TabBarTabShiftVertical:
+ return 2;
+
+ case PM_ToolBarHandleExtent:
+ return 9;
+
+ case PM_SplitterWidth:
+ return 6;
+
+ case PM_SliderThickness:
+ case PM_SliderControlThickness: {
+ GtkWidget *gtkScale = d->gtkWidget("GtkHScale");
+ gint val;
+ d->gtk_widget_style_get(gtkScale, "slider-width", &val, NULL);
+ if (metric == PM_SliderControlThickness)
+ return val + 2*gtkScale->style->ythickness;
+ return val;
+ }
+
+ case PM_ScrollBarExtent: {
+ gint sliderLength;
+ gint trough_border;
+ GtkWidget *hScrollbar = d->gtkWidget("GtkHScrollbar");
+ d->gtk_widget_style_get(hScrollbar,
+ "trough-border", &trough_border,
+ "slider-width", &sliderLength,
+ NULL);
+ return sliderLength + trough_border*2;
+ }
+
+ case PM_ScrollBarSliderMin:
+ return 34;
+
+ case PM_SliderLength:
+ gint val;
+ d->gtk_widget_style_get(d->gtkWidget("GtkHScale"), "slider-length", &val, NULL);
+ return val;
+
+ case PM_ExclusiveIndicatorWidth:
+ case PM_ExclusiveIndicatorHeight:
+ case PM_IndicatorWidth:
+ case PM_IndicatorHeight: {
+ GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton");
+ gint size, spacing;
+ d->gtk_widget_style_get(gtkCheckButton, "indicator-spacing", &spacing, "indicator-size", &size, NULL);
+ return size + 2 * spacing;
+ }
+
+ case PM_MenuBarVMargin: {
+ GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar");
+ return qMax(0, gtkMenubar->style->ythickness);
+ }
+ case PM_ScrollView_ScrollBarSpacing:
+ {
+ gint spacing = 3;
+ GtkWidget *gtkScrollWindow = d->gtkWidget("GtkScrolledWindow");
+ Q_ASSERT(gtkScrollWindow);
+ d->gtk_widget_style_get(gtkScrollWindow, "scrollbar-spacing", &spacing, NULL);
+ return spacing;
+ }
+ case PM_SubMenuOverlap: {
+ gint offset = 0;
+ GtkWidget *gtkMenu = d->gtkWidget("GtkMenu");
+ d->gtk_widget_style_get(gtkMenu, "horizontal-offset", &offset, NULL);
+ return offset;
+ }
+ default:
+ return QCleanlooksStyle::pixelMetric(metric, option, widget);
+ }
+}
+
+/*!
+ \reimp
+*/
+int QGtkStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget,
+
+ QStyleHintReturn *returnData = 0) const
+{
+ Q_D(const QGtkStyle);
+
+ if (!d->isThemeAvailable())
+ return QCleanlooksStyle::styleHint(hint, option, widget, returnData);
+
+ switch (hint) {
+
+ case SH_DialogButtonLayout: {
+ int ret = QDialogButtonBox::GnomeLayout;
+ gboolean alternateOrder = 0;
+ GtkSettings *settings = d->gtk_settings_get_default();
+ g_object_get(settings, "gtk-alternative-button-order", &alternateOrder, NULL);
+
+ if (alternateOrder)
+ ret = QDialogButtonBox::WinLayout;
+
+ return ret;
+ }
+
+ break;
+
+ case SH_ToolButtonStyle:
+ {
+ if (d->isKDE4Session())
+ return QCleanlooksStyle::styleHint(hint, option, widget, returnData);
+ GtkWidget *gtkToolbar = d->gtkWidget("GtkToolbar");
+ GtkToolbarStyle toolbar_style = GTK_TOOLBAR_ICONS;
+ g_object_get(gtkToolbar, "toolbar-style", &toolbar_style, NULL);
+ switch (toolbar_style) {
+ case GTK_TOOLBAR_TEXT:
+ return Qt::ToolButtonTextOnly;
+ case GTK_TOOLBAR_BOTH:
+ return Qt::ToolButtonTextUnderIcon;
+ case GTK_TOOLBAR_BOTH_HORIZ:
+ return Qt::ToolButtonTextBesideIcon;
+ case GTK_TOOLBAR_ICONS:
+ default:
+ return Qt::ToolButtonIconOnly;
+ }
+ }
+ break;
+ case SH_SpinControls_DisableOnBounds:
+ return int(true);
+
+ case SH_DitherDisabledText:
+ return int(false);
+
+ case SH_ComboBox_Popup: {
+ GtkWidget *gtkComboBox = d->gtkWidget("GtkComboBox");
+ gboolean appears_as_list;
+ d->gtk_widget_style_get((GtkWidget*)gtkComboBox, "appears-as-list", &appears_as_list, NULL);
+ return appears_as_list ? 0 : 1;
+ }
+
+ case SH_MenuBar_AltKeyNavigation:
+ return int(false);
+
+ case SH_EtchDisabledText:
+ return int(false);
+
+ case SH_Menu_SubMenuPopupDelay: {
+ gint delay = 225;
+ GtkSettings *settings = d->gtk_settings_get_default();
+ g_object_get(settings, "gtk-menu-popup-delay", &delay, NULL);
+ return delay;
+ }
+
+ case SH_ScrollView_FrameOnlyAroundContents: {
+ gboolean scrollbars_within_bevel = false;
+ if (widget && widget->isWindow())
+ scrollbars_within_bevel = true;
+ else if (!d->gtk_check_version(2, 12, 0)) {
+ GtkWidget *gtkScrollWindow = d->gtkWidget("GtkScrolledWindow");
+ d->gtk_widget_style_get(gtkScrollWindow, "scrollbars-within-bevel", &scrollbars_within_bevel, NULL);
+ }
+ return !scrollbars_within_bevel;
+ }
+
+ case SH_DialogButtonBox_ButtonsHaveIcons: {
+ static bool buttonsHaveIcons = d->getGConfBool(QLS("/desktop/gnome/interface/buttons_have_icons"));
+ return buttonsHaveIcons;
+ }
+
+ case SH_UnderlineShortcut: {
+ gboolean underlineShortcut = true;
+ if (!d->gtk_check_version(2, 12, 0)) {
+ GtkSettings *settings = d->gtk_settings_get_default();
+ g_object_get(settings, "gtk-enable-mnemonics", &underlineShortcut, NULL);
+ }
+ return underlineShortcut;
+ }
+
+ default:
+ return QCleanlooksStyle::styleHint(hint, option, widget, returnData);
+ }
+}
+
+/*!
+ \reimp
+*/
+void QGtkStyle::drawPrimitive(PrimitiveElement element,
+ const QStyleOption *option,
+ QPainter *painter,
+ const QWidget *widget) const
+{
+ Q_D(const QGtkStyle);
+
+ if (!d->isThemeAvailable()) {
+ QCleanlooksStyle::drawPrimitive(element, option, painter, widget);
+ return;
+ }
+
+ GtkStyle* style = d->gtkStyle();
+ QGtkPainter gtkPainter(painter);
+
+ switch (element) {
+ case PE_Frame: {
+ if (widget && widget->inherits("QComboBoxPrivateContainer")){
+ QStyleOption copy = *option;
+ copy.state |= State_Raised;
+ proxy()->drawPrimitive(PE_PanelMenu, &copy, painter, widget);
+ break;
+ }
+ // Drawing the entire itemview frame is very expensive, especially on the native X11 engine
+ // Instead we cheat a bit and draw a border image without the center part, hence only scaling
+ // thin rectangular images
+ const int pmSize = 64;
+ const int border = proxy()->pixelMetric(PM_DefaultFrameWidth, option, widget);
+ const QString pmKey = QLatin1Literal("windowframe") % HexString<uint>(option->state);
+
+ QPixmap pixmap;
+ QRect pmRect(QPoint(0,0), QSize(pmSize, pmSize));
+
+ // Only draw through style once
+ if (!QPixmapCache::find(pmKey, pixmap)) {
+ pixmap = QPixmap(pmSize, pmSize);
+ pixmap.fill(Qt::transparent);
+ QPainter pmPainter(&pixmap);
+ QGtkPainter gtkFramePainter(&pmPainter);
+ gtkFramePainter.setUsePixmapCache(false); // Don't cache twice
+
+ GtkShadowType shadow_type = GTK_SHADOW_NONE;
+ if (option->state & State_Sunken)
+ shadow_type = GTK_SHADOW_IN;
+ else if (option->state & State_Raised)
+ shadow_type = GTK_SHADOW_OUT;
+
+ GtkStyle *style = d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(),
+ "*.GtkScrolledWindow", "*.GtkScrolledWindow", d->gtk_window_get_type());
+ if (style)
+ gtkFramePainter.paintShadow(d->gtkWidget("GtkFrame"), "viewport", pmRect,
+ option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
+ shadow_type, style);
+ QPixmapCache::insert(pmKey, pixmap);
+ }
+
+ QRect rect = option->rect;
+ const int rw = rect.width() - border;
+ const int rh = rect.height() - border;
+ const int pw = pmRect.width() - border;
+ const int ph = pmRect.height() - border;
+
+ // Sidelines
+ painter->drawPixmap(rect.adjusted(border, 0, -border, -rh), pixmap, pmRect.adjusted(border, 0, -border,-ph));
+ painter->drawPixmap(rect.adjusted(border, rh, -border, 0), pixmap, pmRect.adjusted(border, ph,-border,0));
+ painter->drawPixmap(rect.adjusted(0, border, -rw, -border), pixmap, pmRect.adjusted(0, border, -pw, -border));
+ painter->drawPixmap(rect.adjusted(rw, border, 0, -border), pixmap, pmRect.adjusted(pw, border, 0, -border));
+
+ // Corners
+ painter->drawPixmap(rect.adjusted(0, 0, -rw, -rh), pixmap, pmRect.adjusted(0, 0, -pw,-ph));
+ painter->drawPixmap(rect.adjusted(rw, 0, 0, -rh), pixmap, pmRect.adjusted(pw, 0, 0,-ph));
+ painter->drawPixmap(rect.adjusted(0, rh, -rw, 0), pixmap, pmRect.adjusted(0, ph, -pw,0));
+ painter->drawPixmap(rect.adjusted(rw, rh, 0, 0), pixmap, pmRect.adjusted(pw, ph, 0,0));
+ }
+ break;
+
+ case PE_PanelTipLabel: {
+ GtkWidget *gtkWindow = d->gtkWidget("GtkWindow"); // The Murrine Engine currently assumes a widget is passed
+ style = d->gtk_rc_get_style_by_paths(d->gtk_settings_get_default(), "gtk-tooltips", "GtkWindow",
+ d->gtk_window_get_type());
+ gtkPainter.paintFlatBox(gtkWindow, "tooltip", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_NONE, style);
+ }
+ break;
+
+ case PE_PanelStatusBar: {
+ if (widget && widget->testAttribute(Qt::WA_SetPalette) &&
+ option->palette.resolve() & (1 << QPalette::Window)) {
+ // Respect custom palette
+ painter->fillRect(option->rect, option->palette.window());
+ break;
+ }
+ GtkShadowType shadow_type;
+ GtkWidget *gtkStatusbarFrame = d->gtkWidget("GtkStatusbar.GtkFrame");
+ d->gtk_widget_style_get(gtkStatusbarFrame->parent, "shadow-type", &shadow_type, NULL);
+ gtkPainter.paintShadow(gtkStatusbarFrame, "frame", option->rect, GTK_STATE_NORMAL,
+ shadow_type, gtkStatusbarFrame->style);
+ }
+ break;
+
+ case PE_IndicatorHeaderArrow:
+ if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
+ GtkWidget *gtkTreeHeader = d->gtkWidget("GtkTreeView.GtkButton");
+ GtkStateType state = gtkPainter.gtkState(option);
+ style = gtkTreeHeader->style;
+ GtkArrowType type = GTK_ARROW_UP;
+ QImage arrow;
+ // This sorting indicator inversion is intentional, and follows the GNOME HIG.
+ // See http://library.gnome.org/devel/hig-book/stable/controls-lists.html.en#controls-lists-sortable
+ if (header->sortIndicator & QStyleOptionHeader::SortUp)
+ type = GTK_ARROW_UP;
+ else if (header->sortIndicator & QStyleOptionHeader::SortDown)
+ type = GTK_ARROW_DOWN;
+
+ gtkPainter.paintArrow(gtkTreeHeader, "button", option->rect.adjusted(1, 1, -1, -1), type, state,
+ GTK_SHADOW_NONE, FALSE, style);
+ }
+ break;
+
+ case PE_FrameFocusRect:
+ if (!widget || qobject_cast<const QAbstractItemView*>(widget))
+ QCleanlooksStyle::drawPrimitive(element, option, painter, widget);
+ else {
+ // ### this mess should move to subcontrolrect
+ QRect frameRect = option->rect.adjusted(1, 1, -1, -2);
+
+ if (qobject_cast<const QTabBar*>(widget)) {
+ GtkWidget *gtkNotebook = d->gtkWidget("GtkNotebook");
+ style = gtkPainter.getStyle(gtkNotebook);
+ gtkPainter.paintFocus(gtkNotebook, "tab", frameRect.adjusted(-1, 1, 1, 1), GTK_STATE_ACTIVE, style);
+ } else {
+ gtkPainter.paintFocus(NULL, "tab", frameRect, GTK_STATE_ACTIVE, style);
+ }
+ }
+ break;
+
+ case PE_IndicatorBranch:
+ if (option->state & State_Children) {
+ QRect rect = option->rect;
+ rect = QRect(0, 0, 12, 12);
+ rect.moveCenter(option->rect.center());
+ rect.translate(2, 0);
+ GtkExpanderStyle openState = GTK_EXPANDER_EXPANDED;
+ GtkExpanderStyle closedState = GTK_EXPANDER_COLLAPSED;
+ GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView");
+
+ GtkStateType state = GTK_STATE_NORMAL;
+ if (!(option->state & State_Enabled))
+ state = GTK_STATE_INSENSITIVE;
+ else if (option->state & State_MouseOver)
+ state = GTK_STATE_PRELIGHT;
+
+ gtkPainter.paintExpander(gtkTreeView, "treeview", rect, state,
+ option->state & State_Open ? openState : closedState , gtkTreeView->style);
+ }
+ break;
+
+ case PE_PanelItemViewRow:
+ // This primitive is only used to draw selection behind selected expander arrows.
+ // We try not to decorate the tree branch background unless you inherit from StyledItemDelegate
+ // The reason for this is that a lot of code that relies on custom item delegates will look odd having
+ // a gradient on the branch but a flat shaded color on the item itself.
+ QCommonStyle::drawPrimitive(element, option, painter, widget);
+ if (!option->state & State_Selected) {
+ break;
+ } else {
+ if (const QAbstractItemView *view = qobject_cast<const QAbstractItemView*>(widget)) {
+ if (!qobject_cast<QStyledItemDelegate*>(view->itemDelegate()))
+ break;
+ }
+ } // fall through
+
+ case PE_PanelItemViewItem:
+ if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(option)) {
+ uint resolve_mask = vopt->palette.resolve();
+ if (vopt->backgroundBrush.style() != Qt::NoBrush
+ || (resolve_mask & (1 << QPalette::Base)))
+ {
+ QPointF oldBO = painter->brushOrigin();
+ painter->setBrushOrigin(vopt->rect.topLeft());
+ painter->fillRect(vopt->rect, vopt->backgroundBrush);
+ painter->setBrushOrigin(oldBO);
+ if (!(option->state & State_Selected))
+ break;
+ }
+ if (GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView")) {
+ const char *detail = "cell_even_ruled";
+ if (vopt && vopt->features & QStyleOptionViewItemV2::Alternate)
+ detail = "cell_odd_ruled";
+ bool isActive = option->state & State_Active;
+ QString key;
+ if (isActive ) {
+ // Required for active/non-active window appearance
+ key = QLS("a");
+ GTK_WIDGET_SET_FLAGS(gtkTreeView, GTK_HAS_FOCUS);
+ }
+ bool isEnabled = (widget ? widget->isEnabled() : (vopt->state & QStyle::State_Enabled));
+ gtkPainter.paintFlatBox(gtkTreeView, detail, option->rect,
+ option->state & State_Selected ? GTK_STATE_SELECTED :
+ isEnabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
+ GTK_SHADOW_OUT, gtkTreeView->style, key);
+ if (isActive )
+ GTK_WIDGET_UNSET_FLAGS(gtkTreeView, GTK_HAS_FOCUS);
+ }
+ }
+ break;
+ case PE_IndicatorToolBarSeparator:
+ {
+ const int margin = 6;
+ GtkWidget *gtkSeparator = d->gtkWidget("GtkToolbar.GtkSeparatorToolItem");
+ if (option->state & State_Horizontal) {
+ const int offset = option->rect.width()/2;
+ QRect rect = option->rect.adjusted(offset, margin, 0, -margin);
+ painter->setPen(QPen(option->palette.background().color().darker(110)));
+ gtkPainter.paintVline( gtkSeparator, "vseparator",
+ rect, GTK_STATE_NORMAL, gtkSeparator->style,
+ 0, rect.height(), 0);
+ } else { //Draw vertical separator
+ const int offset = option->rect.height()/2;
+ QRect rect = option->rect.adjusted(margin, offset, -margin, 0);
+ painter->setPen(QPen(option->palette.background().color().darker(110)));
+ gtkPainter.paintHline( gtkSeparator, "hseparator",
+ rect, GTK_STATE_NORMAL, gtkSeparator->style,
+ 0, rect.width(), 0);
+ }
+ }
+ break;
+
+ case PE_IndicatorToolBarHandle: {
+ GtkWidget *gtkToolbar = d->gtkWidget("GtkToolbar");
+ GtkShadowType shadow_type;
+ d->gtk_widget_style_get(gtkToolbar, "shadow-type", &shadow_type, NULL);
+ //Note when the toolbar is horizontal, the handle is vertical
+ painter->setClipRect(option->rect);
+ gtkPainter.paintHandle(gtkToolbar, "toolbar", option->rect.adjusted(-1, -1 ,0 ,1),
+ GTK_STATE_NORMAL, shadow_type, !(option->state & State_Horizontal) ?
+ GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, gtkToolbar->style);
+ }
+ break;
+
+ case PE_IndicatorArrowUp:
+ case PE_IndicatorArrowDown:
+ case PE_IndicatorArrowLeft:
+ case PE_IndicatorArrowRight: {
+
+
+ GtkArrowType type = GTK_ARROW_UP;
+
+ switch (element) {
+
+ case PE_IndicatorArrowDown:
+ type = GTK_ARROW_DOWN;
+ break;
+
+ case PE_IndicatorArrowLeft:
+ type = GTK_ARROW_LEFT;
+ break;
+
+ case PE_IndicatorArrowRight:
+ type = GTK_ARROW_RIGHT;
+ break;
+
+ default:
+ break;
+ }
+ int size = qMin(option->rect.height(), option->rect.width());
+ int border = (size > 9) ? (size/4) : 0; //Allow small arrows to have exact dimensions
+ int bsx = 0, bsy = 0;
+ if (option->state & State_Sunken) {
+ bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal);
+ bsy = proxy()->pixelMetric(PM_ButtonShiftVertical);
+ }
+ QRect arrowRect = option->rect.adjusted(border + bsx, border + bsy, -border + bsx, -border + bsy);
+ GtkShadowType shadow = option->state & State_Sunken ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
+ GtkStateType state = gtkPainter.gtkState(option);
+
+ QColor arrowColor = option->palette.buttonText().color();
+ GtkWidget *gtkArrow = d->gtkWidget("GtkArrow");
+ GdkColor color = fromQColor(arrowColor);
+ d->gtk_widget_modify_fg (gtkArrow, state, &color);
+ gtkPainter.paintArrow(gtkArrow, "button", arrowRect,
+ type, state, shadow, FALSE, gtkArrow->style,
+ QString::number(arrowColor.rgba(), 16));
+ // Passing NULL will revert the color change
+ d->gtk_widget_modify_fg (gtkArrow, state, NULL);
+ }
+ break;
+
+ case PE_FrameGroupBox:
+ // Do nothing here, the GNOME groupboxes are flat
+ break;
+
+ case PE_PanelMenu: {
+ GtkWidget *gtkMenu = d->gtkWidget("GtkMenu");
+ gtkPainter.setAlphaSupport(false); // Note, alpha disabled for performance reasons
+ gtkPainter.paintBox(gtkMenu, "menu", option->rect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, gtkMenu->style, QString());
+ }
+ break;
+
+ case PE_FrameMenu:
+ //This is actually done by PE_Widget due to a clipping issue
+ //Otherwise Menu items will not be able to span the entire menu width
+
+ // This is only used by floating tool bars
+ if (qobject_cast<const QToolBar *>(widget)) {
+ GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar");
+ gtkPainter.paintBox( gtkMenubar, "toolbar", option->rect,
+ GTK_STATE_NORMAL, GTK_SHADOW_OUT, style);
+ gtkPainter.paintBox( gtkMenubar, "menu", option->rect,
+ GTK_STATE_NORMAL, GTK_SHADOW_OUT, style);
+ }
+ break;
+
+ case PE_FrameLineEdit: {
+ GtkWidget *gtkEntry = d->gtkWidget("GtkEntry");
+
+
+ gboolean interior_focus;
+ gint focus_line_width;
+ QRect rect = option->rect;
+ d->gtk_widget_style_get(gtkEntry,
+ "interior-focus", &interior_focus,
+ "focus-line-width", &focus_line_width, NULL);
+
+ // See https://bugzilla.mozilla.org/show_bug.cgi?id=405421 for info about this hack
+ g_object_set_data(G_OBJECT(gtkEntry), "transparent-bg-hint", GINT_TO_POINTER(TRUE));
+
+ if (!interior_focus && option->state & State_HasFocus)
+ rect.adjust(focus_line_width, focus_line_width, -focus_line_width, -focus_line_width);
+
+ if (option->state & State_HasFocus)
+ GTK_WIDGET_SET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
+ gtkPainter.paintShadow(gtkEntry, "entry", rect, option->state & State_Enabled ?
+ GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
+ GTK_SHADOW_IN, gtkEntry->style,
+ option->state & State_HasFocus ? QLS("focus") : QString());
+ if (!interior_focus && option->state & State_HasFocus)
+ gtkPainter.paintShadow(gtkEntry, "entry", option->rect, option->state & State_Enabled ?
+ GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE,
+ GTK_SHADOW_IN, gtkEntry->style, QLS("GtkEntryShadowIn"));
+
+ if (option->state & State_HasFocus)
+ GTK_WIDGET_UNSET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
+ }
+ break;
+
+ case PE_PanelLineEdit:
+ if (const QStyleOptionFrame *panel = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
+ GtkWidget *gtkEntry = d->gtkWidget("GtkEntry");
+ if (panel->lineWidth > 0)
+ proxy()->drawPrimitive(PE_FrameLineEdit, option, painter, widget);
+ uint resolve_mask = option->palette.resolve();
+ QRect textRect = option->rect.adjusted(gtkEntry->style->xthickness, gtkEntry->style->ythickness,
+ -gtkEntry->style->xthickness, -gtkEntry->style->ythickness);
+
+ if (widget && widget->testAttribute(Qt::WA_SetPalette) &&
+ resolve_mask & (1 << QPalette::Base)) // Palette overridden by user
+ painter->fillRect(textRect, option->palette.base());
+ else
+ gtkPainter.paintFlatBox( gtkEntry, "entry_bg", textRect,
+ option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, GTK_SHADOW_NONE, gtkEntry->style);
+ }
+ break;
+
+ case PE_FrameTabWidget:
+ if (const QStyleOptionTabWidgetFrame *frame = qstyleoption_cast<const QStyleOptionTabWidgetFrame*>(option)) {
+ GtkWidget *gtkNotebook = d->gtkWidget("GtkNotebook");
+ style = gtkPainter.getStyle(gtkNotebook);
+ gtkPainter.setAlphaSupport(false);
+ GtkShadowType shadow = GTK_SHADOW_OUT;
+ GtkStateType state = GTK_STATE_NORMAL; // Only state supported by gtknotebook
+ bool reverse = (option->direction == Qt::RightToLeft);
+ QGtkStylePrivate::gtk_widget_set_direction(gtkNotebook, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
+ if (const QStyleOptionTabWidgetFrameV2 *tabframe = qstyleoption_cast<const QStyleOptionTabWidgetFrameV2*>(option)) {
+ GtkPositionType frameType = GTK_POS_TOP;
+ QTabBar::Shape shape = frame->shape;
+ int gapStart = 0;
+ int gapSize = 0;
+ if (shape == QTabBar::RoundedNorth || shape == QTabBar::RoundedSouth) {
+ frameType = (shape == QTabBar::RoundedNorth) ? GTK_POS_TOP : GTK_POS_BOTTOM;
+ gapStart = tabframe->selectedTabRect.left();
+ gapSize = tabframe->selectedTabRect.width();
+ } else {
+ frameType = (shape == QTabBar::RoundedWest) ? GTK_POS_LEFT : GTK_POS_RIGHT;
+ gapStart = tabframe->selectedTabRect.y();
+ gapSize = tabframe->selectedTabRect.height();
+ }
+ gtkPainter.paintBoxGap(gtkNotebook, "notebook", option->rect, state, shadow, frameType,
+ gapStart, gapSize, style);
+ break; // done
+ }
+
+ // Note this is only the fallback option
+ gtkPainter.paintBox(gtkNotebook, "notebook", option->rect, state, shadow, style);
+ }
+ break;
+
+ case PE_PanelButtonCommand:
+ case PE_PanelButtonTool: {
+ bool isDefault = false;
+ bool isTool = (element == PE_PanelButtonTool);
+ if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton*>(option))
+ isDefault = btn->features & QStyleOptionButton::DefaultButton;
+
+ // don't draw a frame for tool buttons that have the autoRaise flag and are not enabled or on
+ if (isTool && !(option->state & State_Enabled || option->state & State_On) && (option->state & State_AutoRaise))
+ break;
+ // don't draw a frame for dock widget buttons, unless we are hovering
+ if (widget && widget->inherits("QDockWidgetTitleButton") && !(option->state & State_MouseOver))
+ break;
+
+ GtkStateType state = gtkPainter.gtkState(option);
+ if (option->state & State_On || option->state & State_Sunken)
+ state = GTK_STATE_ACTIVE;
+ GtkWidget *gtkButton = isTool ? d->gtkWidget("GtkToolButton.GtkButton") : d->gtkWidget("GtkButton");
+ gint focusWidth, focusPad;
+ gboolean interiorFocus = false;
+ d->gtk_widget_style_get (gtkButton,
+ "focus-line-width", &focusWidth,
+ "focus-padding", &focusPad,
+ "interior-focus", &interiorFocus, NULL);
+
+ style = gtkButton->style;
+
+ QRect buttonRect = option->rect;
+
+ QString key;
+ if (isDefault) {
+ key += QLS("def");
+ GTK_WIDGET_SET_FLAGS(gtkButton, GTK_HAS_DEFAULT);
+ gtkPainter.paintBox(gtkButton, "buttondefault", buttonRect, state, GTK_SHADOW_IN,
+ style, isDefault ? QLS("d") : QString());
+ }
+
+ bool hasFocus = option->state & State_HasFocus;
+
+ if (hasFocus) {
+ key += QLS("def");
+ GTK_WIDGET_SET_FLAGS(gtkButton, GTK_HAS_FOCUS);
+ }
+
+ if (!interiorFocus)
+ buttonRect = buttonRect.adjusted(focusWidth, focusWidth, -focusWidth, -focusWidth);
+
+ GtkShadowType shadow = (option->state & State_Sunken || option->state & State_On ) ?
+ GTK_SHADOW_IN : GTK_SHADOW_OUT;
+
+ gtkPainter.paintBox(gtkButton, "button", buttonRect, state, shadow,
+ style, key);
+ if (isDefault)
+ GTK_WIDGET_UNSET_FLAGS(gtkButton, GTK_HAS_DEFAULT);
+ if (hasFocus)
+ GTK_WIDGET_UNSET_FLAGS(gtkButton, GTK_HAS_FOCUS);
+ }
+ break;
+
+ case PE_IndicatorRadioButton: {
+ GtkShadowType shadow = GTK_SHADOW_OUT;
+ GtkStateType state = gtkPainter.gtkState(option);
+
+ if (option->state & State_Sunken)
+ state = GTK_STATE_ACTIVE;
+
+ if (option->state & State_NoChange)
+ shadow = GTK_SHADOW_ETCHED_IN;
+ else if (option->state & State_On)
+ shadow = GTK_SHADOW_IN;
+ else
+ shadow = GTK_SHADOW_OUT;
+
+ GtkWidget *gtkRadioButton = d->gtkWidget("GtkRadioButton");
+ gint spacing;
+ d->gtk_widget_style_get(gtkRadioButton, "indicator-spacing", &spacing, NULL);
+ QRect buttonRect = option->rect.adjusted(spacing, spacing, -spacing, -spacing);
+ gtkPainter.setClipRect(option->rect);
+ // ### Note: Ubuntulooks breaks when the proper widget is passed
+ // Murrine engine requires a widget not to get RGBA check - warnings
+ GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton");
+ QString key(QLS("radiobutton"));
+ if (option->state & State_HasFocus) { // Themes such as Nodoka check this flag
+ key += QLatin1Char('f');
+ GTK_WIDGET_SET_FLAGS(gtkCheckButton, GTK_HAS_FOCUS);
+ }
+ gtkPainter.paintOption(gtkCheckButton , buttonRect, state, shadow, gtkRadioButton->style, key);
+ if (option->state & State_HasFocus)
+ GTK_WIDGET_UNSET_FLAGS(gtkCheckButton, GTK_HAS_FOCUS);
+ }
+ break;
+
+ case PE_IndicatorCheckBox: {
+ GtkShadowType shadow = GTK_SHADOW_OUT;
+ GtkStateType state = gtkPainter.gtkState(option);
+
+ if (option->state & State_Sunken)
+ state = GTK_STATE_ACTIVE;
+
+ if (option->state & State_NoChange)
+ shadow = GTK_SHADOW_ETCHED_IN;
+ else if (option->state & State_On)
+ shadow = GTK_SHADOW_IN;
+ else
+ shadow = GTK_SHADOW_OUT;
+
+ int spacing;
+
+ GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton");
+ QString key(QLS("checkbutton"));
+ if (option->state & State_HasFocus) { // Themes such as Nodoka checks this flag
+ key += QLatin1Char('f');
+ GTK_WIDGET_SET_FLAGS(gtkCheckButton, GTK_HAS_FOCUS);
+ }
+
+ // Some styles such as aero-clone assume they can paint in the spacing area
+ gtkPainter.setClipRect(option->rect);
+
+ d->gtk_widget_style_get(gtkCheckButton, "indicator-spacing", &spacing, NULL);
+
+ QRect checkRect = option->rect.adjusted(spacing, spacing, -spacing, -spacing);
+
+ gtkPainter.paintCheckbox(gtkCheckButton, checkRect, state, shadow, gtkCheckButton->style,
+ key);
+ if (option->state & State_HasFocus)
+ GTK_WIDGET_UNSET_FLAGS(gtkCheckButton, GTK_HAS_FOCUS);
+
+ }
+ break;
+
+#ifndef QT_NO_TABBAR
+
+ case PE_FrameTabBarBase:
+ if (const QStyleOptionTabBarBase *tbb
+ = qstyleoption_cast<const QStyleOptionTabBarBase *>(option)) {
+ QRect tabRect = tbb->rect;
+ painter->save();
+ painter->setPen(QPen(option->palette.dark().color().dark(110), 0));
+ switch (tbb->shape) {
+
+ case QTabBar::RoundedNorth:
+ painter->drawLine(tabRect.topLeft(), tabRect.topRight());
+ break;
+
+ case QTabBar::RoundedWest:
+ painter->drawLine(tabRect.left(), tabRect.top(), tabRect.left(), tabRect.bottom());
+ break;
+
+ case QTabBar::RoundedSouth:
+ painter->drawLine(tbb->rect.left(), tbb->rect.bottom(),
+ tabRect.right(), tabRect.bottom());
+ break;
+
+ case QTabBar::RoundedEast:
+ painter->drawLine(tabRect.topRight(), tabRect.bottomRight());
+ break;
+
+ case QTabBar::TriangularNorth:
+ case QTabBar::TriangularEast:
+ case QTabBar::TriangularWest:
+ case QTabBar::TriangularSouth:
+ painter->restore();
+ QWindowsStyle::drawPrimitive(element, option, painter, widget);
+ return;
+ }
+
+ painter->restore();
+ }
+ return;
+
+#endif // QT_NO_TABBAR
+
+ case PE_Widget:
+ break;
+
+ default:
+ QCleanlooksStyle::drawPrimitive(element, option, painter, widget);
+ }
+}
+
+/*!
+ \reimp
+*/
+void QGtkStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
+
+ QPainter *painter, const QWidget *widget) const
+{
+ Q_D(const QGtkStyle);
+
+ if (!d->isThemeAvailable()) {
+ QCleanlooksStyle::drawComplexControl(control, option, painter, widget);
+ return;
+ }
+
+ GtkStyle* style = d->gtkStyle();
+ QGtkPainter gtkPainter(painter);
+ QColor button = option->palette.button().color();
+ QColor dark;
+ QColor grooveColor;
+ QColor darkOutline;
+ dark.setHsv(button.hue(),
+ qMin(255, (int)(button.saturation()*1.9)),
+ qMin(255, (int)(button.value()*0.7)));
+ grooveColor.setHsv(button.hue(),
+ qMin(255, (int)(button.saturation()*2.6)),
+ qMin(255, (int)(button.value()*0.9)));
+ darkOutline.setHsv(button.hue(),
+ qMin(255, (int)(button.saturation()*3.0)),
+ qMin(255, (int)(button.value()*0.6)));
+
+ QColor alphaCornerColor;
+
+ if (widget)
+ alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), darkOutline);
+ else
+ alphaCornerColor = mergedColors(option->palette.background().color(), darkOutline);
+
+ switch (control) {
+
+ case CC_TitleBar:
+ if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(option)) {
+ // Since this is drawn by metacity and not Gtk we
+ // have to rely on Cleanlooks for a fallback
+ QStyleOptionTitleBar copyOpt = *tb;
+ QPalette pal = copyOpt.palette;
+ // Bg color is closer to the window selection than
+ // the base selection color
+ GdkColor gdkBg = style->bg[GTK_STATE_SELECTED];
+ QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8);
+ pal.setBrush(QPalette::Active, QPalette::Highlight, bgColor);
+ copyOpt.palette = pal;
+ QCleanlooksStyle::drawComplexControl(control, &copyOpt, painter, widget);
+ }
+ break;
+
+#ifndef QT_NO_GROUPBOX
+
+ case CC_GroupBox:
+ painter->save();
+
+ if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) {
+ QRect textRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxLabel, widget);
+ QRect checkBoxRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxCheckBox, widget);
+ // Draw title
+
+ if ((groupBox->subControls & QStyle::SC_GroupBoxLabel) && !groupBox->text.isEmpty()) {
+ // Draw prelight background
+ GtkWidget *gtkCheckButton = d->gtkWidget("GtkCheckButton");
+
+ if (option->state & State_MouseOver) {
+ QRect bgRect = textRect | checkBoxRect;
+ gtkPainter.paintFlatBox(gtkCheckButton, "checkbutton", bgRect.adjusted(0, 0, 0, -2),
+ GTK_STATE_PRELIGHT, GTK_SHADOW_ETCHED_OUT, gtkCheckButton->style);
+ }
+
+ if (!groupBox->text.isEmpty()) {
+ int alignment = int(groupBox->textAlignment);
+ if (!proxy()->styleHint(QStyle::SH_UnderlineShortcut, option, widget))
+ alignment |= Qt::TextHideMnemonic;
+ QColor textColor = groupBox->textColor; // Note: custom textColor is currently ignored
+ int labelState = GTK_STATE_INSENSITIVE;
+
+ if (option->state & State_Enabled)
+ labelState = (option->state & State_MouseOver) ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL;
+
+ GdkColor gdkText = gtkCheckButton->style->fg[labelState];
+ textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
+ painter->setPen(textColor);
+ QFont font = painter->font();
+ font.setBold(true);
+ painter->setFont(font);
+ painter->drawText(textRect, Qt::TextShowMnemonic | Qt::AlignLeft| alignment, groupBox->text);
+
+ if (option->state & State_HasFocus)
+ gtkPainter.paintFocus( NULL, "tab", textRect.adjusted(-4, -1, 0, -3), GTK_STATE_ACTIVE, style);
+ }
+ }
+
+ if (groupBox->subControls & SC_GroupBoxCheckBox) {
+ QStyleOptionButton box;
+ box.QStyleOption::operator=(*groupBox);
+ box.rect = checkBoxRect;
+ proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget);
+ }
+ }
+
+ painter->restore();
+ break;
+#endif // QT_NO_GROUPBOX
+
+#ifndef QT_NO_COMBOBOX
+
+ case CC_ComboBox:
+ // See: http://live.gnome.org/GnomeArt/Tutorials/GtkThemes/GtkComboBox
+ // and http://live.gnome.org/GnomeArt/Tutorials/GtkThemes/GtkComboBoxEntry
+ if (const QStyleOptionComboBox *comboBox = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
+ bool sunken = comboBox->state & State_On; // play dead, if combobox has no items
+ BEGIN_STYLE_PIXMAPCACHE(QString::fromLatin1("cb-%0-%1").arg(sunken).arg(comboBox->editable));
+ QGtkPainter gtkCachedPainter(p);
+ gtkCachedPainter.setUsePixmapCache(false); // cached externally
+
+ bool isEnabled = (comboBox->state & State_Enabled);
+ bool focus = isEnabled && (comboBox->state & State_HasFocus);
+ GtkStateType state = gtkPainter.gtkState(option);
+ int appears_as_list = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, comboBox, widget);
+ QStyleOptionComboBox comboBoxCopy = *comboBox;
+ comboBoxCopy.rect = option->rect;
+
+ bool reverse = (option->direction == Qt::RightToLeft);
+ QRect rect = option->rect;
+ QRect arrowButtonRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy,
+ SC_ComboBoxArrow, widget);
+
+ GtkShadowType shadow = (option->state & State_Sunken || option->state & State_On ) ?
+ GTK_SHADOW_IN : GTK_SHADOW_OUT;
+ const QHashableLatin1Literal comboBoxPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry") : QHashableLatin1Literal("GtkComboBox");
+
+ // We use the gtk widget to position arrows and separators for us
+ GtkWidget *gtkCombo = d->gtkWidget(comboBoxPath);
+ GtkAllocation geometry = {0, 0, option->rect.width(), option->rect.height()};
+ d->gtk_widget_set_direction(gtkCombo, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
+ d->gtk_widget_size_allocate(gtkCombo, &geometry);
+
+ QHashableLatin1Literal buttonPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton")
+ : QHashableLatin1Literal("GtkComboBox.GtkToggleButton");
+ GtkWidget *gtkToggleButton = d->gtkWidget(buttonPath);
+ d->gtk_widget_set_direction(gtkToggleButton, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
+ if (gtkToggleButton && (appears_as_list || comboBox->editable)) {
+ if (focus)
+ GTK_WIDGET_SET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
+ // Draw the combo box as a line edit with a button next to it
+ if (comboBox->editable || appears_as_list) {
+ GtkStateType frameState = (state == GTK_STATE_PRELIGHT) ? GTK_STATE_NORMAL : state;
+ QHashableLatin1Literal entryPath = comboBox->editable ? QHashableLatin1Literal("GtkComboBoxEntry.GtkEntry") : QHashableLatin1Literal("GtkComboBox.GtkFrame");
+ GtkWidget *gtkEntry = d->gtkWidget(entryPath);
+ d->gtk_widget_set_direction(gtkEntry, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
+ QRect frameRect = option->rect;
+
+ if (reverse)
+ frameRect.setLeft(arrowButtonRect.right());
+ else
+ frameRect.setRight(arrowButtonRect.left());
+
+ // Fill the line edit background
+ // We could have used flat_box with "entry_bg" but that is probably not worth the overhead
+ uint resolve_mask = option->palette.resolve();
+ int xt = gtkEntry->style->xthickness;
+ int yt = gtkEntry->style->ythickness;
+ QRect contentRect = frameRect.adjusted(xt, yt, -xt, -yt);
+ // Required for inner blue highlight with clearlooks
+ if (focus)
+ GTK_WIDGET_SET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
+
+ if (widget && widget->testAttribute(Qt::WA_SetPalette) &&
+ resolve_mask & (1 << QPalette::Base)) // Palette overridden by user
+ p->fillRect(contentRect, option->palette.base().color());
+ else {
+ gtkCachedPainter.paintFlatBox(gtkEntry, "entry_bg", contentRect,
+ option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE,
+ GTK_SHADOW_NONE, gtkEntry->style, entryPath.toString() + QString::number(focus));
+ }
+
+ gtkCachedPainter.paintShadow(gtkEntry, comboBox->editable ? "entry" : "frame", frameRect, frameState,
+ GTK_SHADOW_IN, gtkEntry->style, entryPath.toString() +
+ QString::number(focus) + QString::number(comboBox->editable) +
+ QString::number(option->direction));
+ if (focus)
+ GTK_WIDGET_UNSET_FLAGS(gtkEntry, GTK_HAS_FOCUS);
+ }
+
+ GtkStateType buttonState = GTK_STATE_NORMAL;
+
+ if (!(option->state & State_Enabled))
+ buttonState = GTK_STATE_INSENSITIVE;
+ else if (option->state & State_Sunken || option->state & State_On)
+ buttonState = GTK_STATE_ACTIVE;
+ else if (option->state & State_MouseOver && comboBox->activeSubControls & SC_ComboBoxArrow)
+ buttonState = GTK_STATE_PRELIGHT;
+
+ Q_ASSERT(gtkToggleButton);
+ gtkCachedPainter.paintBox( gtkToggleButton, "button", arrowButtonRect, buttonState,
+ shadow, gtkToggleButton->style, buttonPath.toString() +
+ QString::number(focus) + QString::number(option->direction));
+ if (focus)
+ GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
+ } else {
+ // Draw combo box as a button
+ QRect buttonRect = option->rect;
+
+ if (focus) // Clearlooks actually check the widget for the default state
+ GTK_WIDGET_SET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
+ gtkCachedPainter.paintBox(gtkToggleButton, "button",
+ buttonRect, state,
+ shadow, gtkToggleButton->style,
+ buttonPath.toString() + QString::number(focus));
+ if (focus)
+ GTK_WIDGET_UNSET_FLAGS(gtkToggleButton, GTK_HAS_FOCUS);
+
+
+ // Draw the separator between label and arrows
+ QHashableLatin1Literal vSeparatorPath = comboBox->editable
+ ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkHBox.GtkVSeparator")
+ : QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkHBox.GtkVSeparator");
+
+ if (GtkWidget *gtkVSeparator = d->gtkWidget(vSeparatorPath)) {
+ QRect vLineRect(gtkVSeparator->allocation.x,
+ gtkVSeparator->allocation.y,
+ gtkVSeparator->allocation.width,
+ gtkVSeparator->allocation.height);
+
+ gtkCachedPainter.paintVline( gtkVSeparator, "vseparator",
+ vLineRect, state, gtkVSeparator->style,
+ 0, vLineRect.height(), 0, vSeparatorPath.toString());
+
+
+ gint interiorFocus = true;
+ d->gtk_widget_style_get(gtkToggleButton, "interior-focus", &interiorFocus, NULL);
+ int xt = interiorFocus ? gtkToggleButton->style->xthickness : 0;
+ int yt = interiorFocus ? gtkToggleButton->style->ythickness : 0;
+ if (focus && ((option->state & State_KeyboardFocusChange) || styleHint(SH_UnderlineShortcut, option, widget)))
+ gtkCachedPainter.paintFocus(gtkToggleButton, "button",
+ option->rect.adjusted(xt, yt, -xt, -yt),
+ option->state & State_Sunken ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL,
+ gtkToggleButton->style);
+ }
+ }
+
+ if (comboBox->subControls & SC_ComboBoxArrow) {
+ if (!isEnabled)
+ state = GTK_STATE_INSENSITIVE;
+ else if (sunken)
+ state = GTK_STATE_ACTIVE;
+ else if (option->state & State_MouseOver)
+ state = GTK_STATE_PRELIGHT;
+ else
+ state = GTK_STATE_NORMAL;
+
+ QHashableLatin1Literal arrowPath("");
+ if (comboBox->editable) {
+ if (appears_as_list)
+ arrowPath = QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkArrow");
+ else
+ arrowPath = QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton.GtkHBox.GtkArrow");
+ } else {
+ if (appears_as_list)
+ arrowPath = QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkArrow");
+ else
+ arrowPath = QHashableLatin1Literal("GtkComboBox.GtkToggleButton.GtkHBox.GtkArrow");
+ }
+
+ GtkWidget *gtkArrow = d->gtkWidget(arrowPath);
+ gfloat scale = 0.7;
+ gint minSize = 15;
+ QRect arrowWidgetRect;
+
+ if (gtkArrow && !d->gtk_check_version(2, 12, 0)) {
+ d->gtk_widget_style_get(gtkArrow, "arrow-scaling", &scale, NULL);
+ d->gtk_widget_style_get(gtkCombo, "arrow-size", &minSize, NULL);
+ }
+ if (gtkArrow) {
+ arrowWidgetRect = QRect(gtkArrow->allocation.x, gtkArrow->allocation.y,
+ gtkArrow->allocation.width, gtkArrow->allocation.height);
+ style = gtkArrow->style;
+ }
+
+ // Note that for some reason the arrow-size is not properly respected with Hildon
+ // Hence we enforce the minimum "arrow-size" ourselves
+ int arrowSize = qMax(qMin(rect.height() - gtkCombo->style->ythickness * 2, minSize),
+ qMin(arrowWidgetRect.width(), arrowWidgetRect.height()));
+ QRect arrowRect(0, 0, static_cast<int>(arrowSize * scale), static_cast<int>(arrowSize * scale));
+
+ arrowRect.moveCenter(arrowWidgetRect.center());
+
+ if (sunken) {
+ int xoff, yoff;
+ const QHashableLatin1Literal toggleButtonPath = comboBox->editable
+ ? QHashableLatin1Literal("GtkComboBoxEntry.GtkToggleButton")
+ : QHashableLatin1Literal("GtkComboBox.GtkToggleButton");
+
+ GtkWidget *gtkButton = d->gtkWidget(toggleButtonPath);
+ d->gtk_widget_style_get(gtkButton, "child-displacement-x", &xoff, NULL);
+ d->gtk_widget_style_get(gtkButton, "child-displacement-y", &yoff, NULL);
+ arrowRect = arrowRect.adjusted(xoff, yoff, xoff, yoff);
+ }
+
+ // Some styles such as Nimbus paint outside the arrowRect
+ // hence we have provide the whole widget as the cliprect
+ if (gtkArrow) {
+ gtkCachedPainter.setClipRect(option->rect);
+ gtkCachedPainter.paintArrow( gtkArrow, "arrow", arrowRect,
+ GTK_ARROW_DOWN, state, GTK_SHADOW_NONE, TRUE,
+ style, arrowPath.toString() + QString::number(option->direction));
+ }
+ }
+ END_STYLE_PIXMAPCACHE;
+ }
+ break;
+#endif // QT_NO_COMBOBOX
+#ifndef QT_NO_TOOLBUTTON
+
+ case CC_ToolButton:
+ if (const QStyleOptionToolButton *toolbutton
+ = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
+ QRect button, menuarea;
+ button = proxy()->subControlRect(control, toolbutton, SC_ToolButton, widget);
+ menuarea = proxy()->subControlRect(control, toolbutton, SC_ToolButtonMenu, widget);
+ State bflags = toolbutton->state & ~(State_Sunken | State_MouseOver);
+
+ if (bflags & State_AutoRaise)
+ if (!(bflags & State_MouseOver))
+ bflags &= ~State_Raised;
+
+ State mflags = bflags;
+
+ if (toolbutton->state & State_Sunken) {
+ if (toolbutton->activeSubControls & SC_ToolButton)
+ bflags |= State_Sunken;
+ if (toolbutton->activeSubControls & SC_ToolButtonMenu)
+ mflags |= State_Sunken;
+ } else if (toolbutton->state & State_MouseOver) {
+ if (toolbutton->activeSubControls & SC_ToolButton)
+ bflags |= State_MouseOver;
+ if (toolbutton->activeSubControls & SC_ToolButtonMenu)
+ mflags |= State_MouseOver;
+ }
+
+ QStyleOption tool(0);
+
+ tool.palette = toolbutton->palette;
+
+ if (toolbutton->subControls & SC_ToolButton) {
+ if (bflags & (State_Sunken | State_On | State_Raised | State_MouseOver)) {
+ tool.rect = button;
+ tool.state = bflags;
+ proxy()->drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);
+ }
+ }
+
+ bool drawMenuArrow = toolbutton->features & QStyleOptionToolButton::HasMenu &&
+ !(toolbutton->features & QStyleOptionToolButton::MenuButtonPopup);
+ int popupArrowSize = drawMenuArrow ? 7 : 0;
+
+ if (toolbutton->state & State_HasFocus) {
+ QStyleOptionFocusRect fr;
+ fr.QStyleOption::operator=(*toolbutton);
+ fr.rect = proxy()->subControlRect(CC_ToolButton, toolbutton, SC_ToolButton, widget);
+ fr.rect.adjust(1, 1, -1, -1);
+ proxy()->drawPrimitive(PE_FrameFocusRect, &fr, painter, widget);
+ }
+
+ QStyleOptionToolButton label = *toolbutton;
+ label.state = bflags;
+ GtkWidget *gtkButton = d->gtkWidget("GtkToolButton.GtkButton");
+ QPalette pal = toolbutton->palette;
+ if (option->state & State_Enabled &&
+ option->state & State_MouseOver && !(widget && widget->testAttribute(Qt::WA_SetPalette))) {
+ GdkColor gdkText = gtkButton->style->fg[GTK_STATE_PRELIGHT];
+ QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
+ pal.setBrush(QPalette::All, QPalette::ButtonText, textColor);
+ label.palette = pal;
+ }
+ label.rect = button.adjusted(style->xthickness, style->ythickness,
+ -style->xthickness - popupArrowSize, -style->ythickness);
+ proxy()->drawControl(CE_ToolButtonLabel, &label, painter, widget);
+
+ if (toolbutton->subControls & SC_ToolButtonMenu) {
+ tool.rect = menuarea;
+ tool.state = mflags;
+ if ((mflags & State_Enabled && (mflags & (State_Sunken | State_Raised | State_MouseOver))) || !(mflags & State_AutoRaise))
+ proxy()->drawPrimitive(PE_IndicatorButtonDropDown, &tool, painter, widget);
+
+ proxy()->drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget);
+
+ } else if (drawMenuArrow) {
+ QRect ir = toolbutton->rect;
+ QStyleOptionToolButton newBtn = *toolbutton;
+ newBtn.rect = QRect(ir.right() - popupArrowSize - style->xthickness - 3, ir.height()/2 - 1, popupArrowSize, popupArrowSize);
+ proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget);
+ }
+ }
+ break;
+
+#endif // QT_NO_TOOLBUTTON
+#ifndef QT_NO_SCROLLBAR
+
+ case CC_ScrollBar:
+ if (const QStyleOptionSlider *scrollBar = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
+ GtkWidget *gtkHScrollBar = d->gtkWidget("GtkHScrollbar");
+ GtkWidget *gtkVScrollBar = d->gtkWidget("GtkVScrollbar");
+
+ // Fill background in case the scrollbar is partially transparent
+ painter->fillRect(option->rect, option->palette.background());
+
+ QRect rect = scrollBar->rect;
+ QRect scrollBarSubLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget);
+ QRect scrollBarAddLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget);
+ QRect scrollBarSlider = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSlider, widget);
+ QRect grooveRect = proxy()->subControlRect(control, scrollBar, SC_ScrollBarGroove, widget);
+ bool horizontal = scrollBar->orientation == Qt::Horizontal;
+ GtkWidget * scrollbarWidget = horizontal ? gtkHScrollBar : gtkVScrollBar;
+ style = scrollbarWidget->style;
+ gboolean trough_under_steppers = true;
+ gboolean trough_side_details = false;
+ gboolean activate_slider = false;
+ gboolean stepper_size = 14;
+ gint trough_border = 1;
+ if (!d->gtk_check_version(2, 10, 0)) {
+ d->gtk_widget_style_get((GtkWidget*)(scrollbarWidget),
+ "trough-border", &trough_border,
+ "trough-side-details", &trough_side_details,
+ "trough-under-steppers", &trough_under_steppers,
+ "activate-slider", &activate_slider,
+ "stepper-size", &stepper_size, NULL);
+ }
+ if (trough_under_steppers) {
+ scrollBarAddLine.adjust(trough_border, trough_border, -trough_border, -trough_border);
+ scrollBarSubLine.adjust(trough_border, trough_border, -trough_border, -trough_border);
+ scrollBarSlider.adjust(horizontal ? -trough_border : 0, horizontal ? 0 : -trough_border,
+ horizontal ? trough_border : 0, horizontal ? 0 : trough_border);
+ }
+
+ // Some styles check the position of scrollbars in order to determine
+ // if lines should be painted when the scrollbar is in max or min positions.
+ int maximum = 2;
+ int fakePos = 0;
+ bool reverse = (option->direction == Qt::RightToLeft);
+ if (scrollBar->minimum == scrollBar->maximum)
+ maximum = 0;
+ if (scrollBar->sliderPosition == scrollBar->maximum)
+ fakePos = maximum;
+ else if (scrollBar->sliderPosition > scrollBar->minimum)
+ fakePos = maximum - 1;
+
+
+ GtkRange *range = (GtkRange*)(horizontal ? gtkHScrollBar : gtkVScrollBar);
+ GtkAdjustment *adjustment = d->gtk_range_get_adjustment(range);
+
+ if (adjustment) {
+ d->gtk_adjustment_configure(adjustment, fakePos, 0, maximum, 0, 0, 0);
+ } else {
+ adjustment = (GtkAdjustment*)d->gtk_adjustment_new(fakePos, 0, maximum, 0, 0, 0);
+ d->gtk_range_set_adjustment(range, adjustment);
+ }
+
+ if (scrollBar->subControls & SC_ScrollBarGroove) {
+ GtkStateType state = GTK_STATE_ACTIVE;
+
+ if (!(option->state & State_Enabled))
+ state = GTK_STATE_INSENSITIVE;
+
+ if (trough_under_steppers)
+ grooveRect = option->rect;
+
+ gtkPainter.paintBox( scrollbarWidget, "trough", grooveRect, state, GTK_SHADOW_IN, style);
+ }
+
+ //paint slider
+ if (scrollBar->subControls & SC_ScrollBarSlider) {
+ GtkStateType state = GTK_STATE_NORMAL;
+
+ if (!(option->state & State_Enabled))
+ state = GTK_STATE_INSENSITIVE;
+ else if (activate_slider &&
+ option->state & State_Sunken && (scrollBar->activeSubControls & SC_ScrollBarSlider))
+ state = GTK_STATE_ACTIVE;
+ else if (option->state & State_MouseOver && (scrollBar->activeSubControls & SC_ScrollBarSlider))
+ state = GTK_STATE_PRELIGHT;
+
+ GtkShadowType shadow = GTK_SHADOW_OUT;
+
+ if (trough_under_steppers) {
+ if (!horizontal)
+ scrollBarSlider.adjust(trough_border, 0, -trough_border, 0);
+ else
+ scrollBarSlider.adjust(0, trough_border, 0, -trough_border);
+ }
+
+ gtkPainter.paintSlider( scrollbarWidget, "slider", scrollBarSlider, state, shadow, style,
+
+ horizontal ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL, QString(QLS("%0%1")).arg(fakePos).arg(maximum));
+ }
+
+ if (scrollBar->subControls & SC_ScrollBarAddLine) {
+ gtkVScrollBar->allocation.y = scrollBarAddLine.top();
+ gtkVScrollBar->allocation.height = scrollBarAddLine.height() - rect.height() + 6;
+ gtkHScrollBar->allocation.x = scrollBarAddLine.right();
+ gtkHScrollBar->allocation.width = scrollBarAddLine.width() - rect.width();
+
+ GtkShadowType shadow = GTK_SHADOW_OUT;
+ GtkStateType state = GTK_STATE_NORMAL;
+
+ if (!(option->state & State_Enabled) || (fakePos == maximum))
+ state = GTK_STATE_INSENSITIVE;
+ else if (option->state & State_Sunken && (scrollBar->activeSubControls & SC_ScrollBarAddLine)) {
+ state = GTK_STATE_ACTIVE;
+ shadow = GTK_SHADOW_IN;
+
+ } else if (option->state & State_MouseOver && (scrollBar->activeSubControls & SC_ScrollBarAddLine))
+ state = GTK_STATE_PRELIGHT;
+
+ gtkPainter.paintBox( scrollbarWidget,
+ horizontal ? "hscrollbar" : "vscrollbar", scrollBarAddLine,
+ state, shadow, style, QLS("add"));
+
+ gtkPainter.paintArrow( scrollbarWidget, horizontal ? "hscrollbar" : "vscrollbar", scrollBarAddLine.adjusted(4, 4, -4, -4),
+ horizontal ? (reverse ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT) :
+ GTK_ARROW_DOWN, state, GTK_SHADOW_NONE, FALSE, style);
+ }
+
+ if (scrollBar->subControls & SC_ScrollBarSubLine) {
+ gtkVScrollBar->allocation.y = 0;
+ gtkVScrollBar->allocation.height = scrollBarSubLine.height();
+ gtkHScrollBar->allocation.x = 0;
+ gtkHScrollBar->allocation.width = scrollBarSubLine.width();
+
+ GtkShadowType shadow = GTK_SHADOW_OUT;
+ GtkStateType state = GTK_STATE_NORMAL;
+
+ if (!(option->state & State_Enabled) || (fakePos == 0))
+ state = GTK_STATE_INSENSITIVE;
+ else if (option->state & State_Sunken && (scrollBar->activeSubControls & SC_ScrollBarSubLine)) {
+ shadow = GTK_SHADOW_IN;
+ state = GTK_STATE_ACTIVE;
+
+ } else if (option->state & State_MouseOver && (scrollBar->activeSubControls & SC_ScrollBarSubLine))
+ state = GTK_STATE_PRELIGHT;
+
+ gtkPainter.paintBox(scrollbarWidget, horizontal ? "hscrollbar" : "vscrollbar", scrollBarSubLine,
+ state, shadow, style, QLS("sub"));
+
+ gtkPainter.paintArrow(scrollbarWidget, horizontal ? "hscrollbar" : "vscrollbar", scrollBarSubLine.adjusted(4, 4, -4, -4),
+ horizontal ? (reverse ? GTK_ARROW_RIGHT : GTK_ARROW_LEFT) :
+ GTK_ARROW_UP, state, GTK_SHADOW_NONE, FALSE, style);
+ }
+ }
+ break;
+
+#endif //QT_NO_SCROLLBAR
+#ifndef QT_NO_SPINBOX
+
+ case CC_SpinBox:
+ if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
+
+ GtkWidget *gtkSpinButton = spinBox->buttonSymbols == QAbstractSpinBox::NoButtons
+ ? d->gtkWidget("GtkEntry")
+ : d->gtkWidget("GtkSpinButton");
+ bool isEnabled = (spinBox->state & State_Enabled);
+ bool hover = isEnabled && (spinBox->state & State_MouseOver);
+ bool sunken = (spinBox->state & State_Sunken);
+ bool upIsActive = (spinBox->activeSubControls == SC_SpinBoxUp);
+ bool downIsActive = (spinBox->activeSubControls == SC_SpinBoxDown);
+ bool reverse = (spinBox->direction == Qt::RightToLeft);
+
+ QRect editArea = option->rect;
+ QRect editRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxEditField, widget);
+ QRect upRect, downRect, buttonRect;
+ if (spinBox->buttonSymbols != QAbstractSpinBox::NoButtons) {
+ upRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget);
+ downRect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget);
+
+ //### Move this to subControlRect
+ upRect.setTop(option->rect.top());
+
+ if (reverse)
+ upRect.setLeft(option->rect.left());
+ else
+ upRect.setRight(option->rect.right());
+
+ downRect.setBottom(option->rect.bottom());
+
+ if (reverse)
+ downRect.setLeft(option->rect.left());
+ else
+ downRect.setRight(option->rect.right());
+
+ buttonRect = upRect | downRect;
+
+ if (reverse)
+ editArea.setLeft(upRect.right());
+ else
+ editArea.setRight(upRect.left());
+ }
+ if (spinBox->frame) {
+ GtkStateType state = gtkPainter.gtkState(option);
+
+ if (!(option->state & State_Enabled))
+ state = GTK_STATE_INSENSITIVE;
+ else if (option->state & State_HasFocus)
+ state = GTK_STATE_NORMAL;
+ else if (state == GTK_STATE_PRELIGHT)
+ state = GTK_STATE_NORMAL;
+
+ style = gtkPainter.getStyle(gtkSpinButton);
+
+
+ QString key;
+
+ if (option->state & State_HasFocus) {
+ key += QLatin1Char('f');
+ GTK_WIDGET_SET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS);
+ }
+
+ uint resolve_mask = option->palette.resolve();
+
+ if (resolve_mask & (1 << QPalette::Base)) // Palette overridden by user
+ painter->fillRect(editRect, option->palette.base().color());
+ else
+ gtkPainter.paintFlatBox(gtkSpinButton, "entry_bg", editArea.adjusted(style->xthickness, style->ythickness,
+ -style->xthickness, -style->ythickness),
+ option->state & State_Enabled ?
+ GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE, GTK_SHADOW_NONE, style, key);
+
+ gtkPainter.paintShadow(gtkSpinButton, "entry", editArea, state, GTK_SHADOW_IN, gtkSpinButton->style, key);
+ if (spinBox->buttonSymbols != QAbstractSpinBox::NoButtons) {
+ gtkPainter.paintBox(gtkSpinButton, "spinbutton", buttonRect, state, GTK_SHADOW_IN, style, key);
+
+ upRect.setSize(downRect.size());
+ if (!(option->state & State_Enabled))
+ gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key);
+ else if (upIsActive && sunken)
+ gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key);
+ else if (upIsActive && hover)
+ gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key);
+ else
+ gtkPainter.paintBox( gtkSpinButton, "spinbutton_up", upRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key);
+
+ if (!(option->state & State_Enabled))
+ gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_INSENSITIVE, GTK_SHADOW_IN, style, key);
+ else if (downIsActive && sunken)
+ gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_ACTIVE, GTK_SHADOW_IN, style, key);
+ else if (downIsActive && hover)
+ gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style, key);
+ else
+ gtkPainter.paintBox( gtkSpinButton, "spinbutton_down", downRect, GTK_STATE_NORMAL, GTK_SHADOW_OUT, style, key);
+
+ if (option->state & State_HasFocus)
+ GTK_WIDGET_UNSET_FLAGS(gtkSpinButton, GTK_HAS_FOCUS);
+ }
+ }
+
+ if (spinBox->buttonSymbols == QAbstractSpinBox::PlusMinus) {
+ int centerX = upRect.center().x();
+ int centerY = upRect.center().y();
+ // plus/minus
+
+ if (spinBox->activeSubControls == SC_SpinBoxUp && sunken) {
+ painter->drawLine(1 + centerX - 2, 1 + centerY, 1 + centerX + 2, 1 + centerY);
+ painter->drawLine(1 + centerX, 1 + centerY - 2, 1 + centerX, 1 + centerY + 2);
+
+ } else {
+ painter->drawLine(centerX - 2, centerY, centerX + 2, centerY);
+ painter->drawLine(centerX, centerY - 2, centerX, centerY + 2);
+ }
+ centerX = downRect.center().x();
+ centerY = downRect.center().y();
+
+ if (spinBox->activeSubControls == SC_SpinBoxDown && sunken) {
+ painter->drawLine(1 + centerX - 2, 1 + centerY, 1 + centerX + 2, 1 + centerY);
+ } else {
+ painter->drawLine(centerX - 2, centerY, centerX + 2, centerY);
+ }
+
+ } else if (spinBox->buttonSymbols == QAbstractSpinBox::UpDownArrows) {
+ int size = d->getSpinboxArrowSize();
+ int w = size / 2 - 1;
+ w -= w % 2 - 1; // force odd
+ int h = (w + 1)/2;
+ QRect arrowRect(0, 0, w, h);
+ arrowRect.moveCenter(upRect.center());
+ // arrows
+ GtkStateType state = GTK_STATE_NORMAL;
+
+ if (!(option->state & State_Enabled) || !(spinBox->stepEnabled & QAbstractSpinBox::StepUpEnabled))
+ state = GTK_STATE_INSENSITIVE;
+
+ gtkPainter.paintArrow( gtkSpinButton, "spinbutton", arrowRect, GTK_ARROW_UP, state,
+ GTK_SHADOW_NONE, FALSE, style);
+
+ arrowRect.moveCenter(downRect.center());
+
+ if (!(option->state & State_Enabled) || !(spinBox->stepEnabled & QAbstractSpinBox::StepDownEnabled))
+ state = GTK_STATE_INSENSITIVE;
+
+ gtkPainter.paintArrow( gtkSpinButton, "spinbutton", arrowRect, GTK_ARROW_DOWN, state,
+ GTK_SHADOW_NONE, FALSE, style);
+ }
+ }
+ break;
+
+#endif // QT_NO_SPINBOX
+
+#ifndef QT_NO_SLIDER
+
+ case CC_Slider:
+ if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
+ GtkWidget *hScaleWidget = d->gtkWidget("GtkHScale");
+ GtkWidget *vScaleWidget = d->gtkWidget("GtkVScale");
+
+ QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget);
+ QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget);
+
+ bool horizontal = slider->orientation == Qt::Horizontal;
+ bool ticksAbove = slider->tickPosition & QSlider::TicksAbove;
+ bool ticksBelow = slider->tickPosition & QSlider::TicksBelow;
+
+ QBrush oldBrush = painter->brush();
+ QPen oldPen = painter->pen();
+
+ QColor shadowAlpha(Qt::black);
+ shadowAlpha.setAlpha(10);
+ QColor highlightAlpha(Qt::white);
+ highlightAlpha.setAlpha(80);
+
+ QGtkStylePrivate::gtk_widget_set_direction(hScaleWidget, slider->upsideDown ?
+ GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
+ GtkWidget *scaleWidget = horizontal ? hScaleWidget : vScaleWidget;
+ style = scaleWidget->style;
+
+ if ((option->subControls & SC_SliderGroove) && groove.isValid()) {
+
+ GtkRange *range = (GtkRange*)scaleWidget;
+ GtkAdjustment *adjustment = d->gtk_range_get_adjustment(range);
+ if (adjustment) {
+ d->gtk_adjustment_configure(adjustment,
+ slider->sliderPosition,
+ slider->minimum,
+ slider->maximum,
+ slider->singleStep,
+ slider->singleStep,
+ slider->pageStep);
+ } else {
+ adjustment = (GtkAdjustment*)d->gtk_adjustment_new(slider->sliderPosition,
+ slider->minimum,
+ slider->maximum,
+ slider->singleStep,
+ slider->singleStep,
+ slider->pageStep);
+ d->gtk_range_set_adjustment(range, adjustment);
+ }
+
+ int outerSize;
+ d->gtk_range_set_inverted(range, !horizontal);
+ d->gtk_widget_style_get(scaleWidget, "trough-border", &outerSize, NULL);
+ outerSize++;
+
+ GtkStateType state = gtkPainter.gtkState(option);
+ int focusFrameMargin = 2;
+ QRect grooveRect = option->rect.adjusted(focusFrameMargin, outerSize + focusFrameMargin,
+ -focusFrameMargin, -outerSize - focusFrameMargin);
+
+ gboolean trough_side_details = false; // Indicates if the upper or lower scale background differs
+ if (!d->gtk_check_version(2, 10, 0))
+ d->gtk_widget_style_get((GtkWidget*)(scaleWidget), "trough-side-details", &trough_side_details, NULL);
+
+ if (!trough_side_details) {
+ gtkPainter.paintBox( scaleWidget, "trough", grooveRect, state,
+ GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition));
+ } else {
+ QRect upperGroove = grooveRect;
+ QRect lowerGroove = grooveRect;
+
+ if (horizontal) {
+ if (slider->upsideDown) {
+ lowerGroove.setLeft(handle.center().x());
+ upperGroove.setRight(handle.center().x());
+ } else {
+ upperGroove.setLeft(handle.center().x());
+ lowerGroove.setRight(handle.center().x());
+ }
+ } else {
+ if (!slider->upsideDown) {
+ lowerGroove.setBottom(handle.center().y());
+ upperGroove.setTop(handle.center().y());
+ } else {
+ upperGroove.setBottom(handle.center().y());
+ lowerGroove.setTop(handle.center().y());
+ }
+ }
+
+ gtkPainter.paintBox( scaleWidget, "trough-upper", upperGroove, state,
+ GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition));
+ gtkPainter.paintBox( scaleWidget, "trough-lower", lowerGroove, state,
+ GTK_SHADOW_IN, style, QString(QLS("p%0")).arg(slider->sliderPosition));
+ }
+ }
+
+ if (option->subControls & SC_SliderTickmarks) {
+ painter->setPen(darkOutline);
+ int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget);
+ int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget);
+ int interval = slider->tickInterval;
+
+ if (interval <= 0) {
+ interval = slider->singleStep;
+
+ if (QStyle::sliderPositionFromValue(slider->minimum, slider->maximum, interval,
+ available)
+ - QStyle::sliderPositionFromValue(slider->minimum, slider->maximum,
+ 0, available) < 3)
+ interval = slider->pageStep;
+ }
+
+ if (interval <= 0)
+ interval = 1;
+
+ int v = slider->minimum;
+ int len = proxy()->pixelMetric(PM_SliderLength, slider, widget);
+ while (v <= slider->maximum + 1) {
+ if (v == slider->maximum + 1 && interval == 1)
+ break;
+ const int v_ = qMin(v, slider->maximum);
+ int pos = sliderPositionFromValue(slider->minimum, slider->maximum,
+ v_, (horizontal
+ ? slider->rect.width()
+ : slider->rect.height()) - len,
+ slider->upsideDown) + len / 2;
+ int extra = 2 - ((v_ == slider->minimum || v_ == slider->maximum) ? 1 : 0);
+ if (horizontal) {
+ if (ticksAbove)
+ painter->drawLine(pos, slider->rect.top() + extra,
+ pos, slider->rect.top() + tickSize);
+ if (ticksBelow)
+ painter->drawLine(pos, slider->rect.bottom() - extra,
+ pos, slider->rect.bottom() - tickSize);
+
+ } else {
+ if (ticksAbove)
+ painter->drawLine(slider->rect.left() + extra, pos,
+ slider->rect.left() + tickSize, pos);
+ if (ticksBelow)
+ painter->drawLine(slider->rect.right() - extra, pos,
+ slider->rect.right() - tickSize, pos);
+ }
+
+ // In the case where maximum is max int
+ int nextInterval = v + interval;
+ if (nextInterval < v)
+ break;
+ v = nextInterval;
+ }
+ }
+
+ // Draw slider handle
+ if (option->subControls & SC_SliderHandle) {
+ GtkShadowType shadow = GTK_SHADOW_OUT;
+ GtkStateType state = GTK_STATE_NORMAL;
+
+ if (!(option->state & State_Enabled))
+ state = GTK_STATE_INSENSITIVE;
+ else if (option->state & State_MouseOver && option->activeSubControls & SC_SliderHandle)
+ state = GTK_STATE_PRELIGHT;
+
+ bool horizontal = option->state & State_Horizontal;
+
+ if (slider->state & State_HasFocus) {
+ QStyleOptionFocusRect fropt;
+ fropt.QStyleOption::operator=(*slider);
+ fropt.rect = slider->rect.adjusted(-1, -1 ,1, 1);
+
+ if (horizontal) {
+ fropt.rect.setTop(handle.top() - 3);
+ fropt.rect.setBottom(handle.bottom() + 4);
+
+ } else {
+ fropt.rect.setLeft(handle.left() - 3);
+ fropt.rect.setRight(handle.right() + 3);
+ }
+ proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
+ }
+ gtkPainter.paintSlider( scaleWidget, horizontal ? "hscale" : "vscale", handle, state, shadow, style,
+
+ horizontal ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
+ }
+ painter->setBrush(oldBrush);
+ painter->setPen(oldPen);
+ }
+ break;
+
+#endif // QT_NO_SLIDER
+
+ default:
+ QCleanlooksStyle::drawComplexControl(control, option, painter, widget);
+
+ break;
+ }
+}
+
+
+/*!
+ \reimp
+*/
+void QGtkStyle::drawControl(ControlElement element,
+ const QStyleOption *option,
+ QPainter *painter,
+ const QWidget *widget) const
+{
+ Q_D(const QGtkStyle);
+
+ if (!d->isThemeAvailable()) {
+ QCleanlooksStyle::drawControl(element, option, painter, widget);
+ return;
+ }
+
+ GtkStyle* style = d->gtkStyle();
+ QGtkPainter gtkPainter(painter);
+
+ switch (element) {
+ case CE_ProgressBarLabel:
+ if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
+ GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar");
+ if (!gtkProgressBar)
+ return;
+
+ QRect leftRect;
+ QRect rect = bar->rect;
+ GdkColor gdkText = gtkProgressBar->style->fg[GTK_STATE_NORMAL];
+ QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
+ gdkText = gtkProgressBar->style->fg[GTK_STATE_PRELIGHT];
+ QColor alternateTextColor= QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
+
+ painter->save();
+ bool vertical = false, inverted = false;
+ if (const QStyleOptionProgressBarV2 *bar2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) {
+ vertical = (bar2->orientation == Qt::Vertical);
+ inverted = bar2->invertedAppearance;
+ }
+ if (vertical)
+ rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height
+ const int progressIndicatorPos = (bar->progress - qreal(bar->minimum)) * rect.width() /
+ qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum);
+ if (progressIndicatorPos >= 0 && progressIndicatorPos <= rect.width())
+ leftRect = QRect(rect.left(), rect.top(), progressIndicatorPos, rect.height());
+ if (vertical)
+ leftRect.translate(rect.width() - progressIndicatorPos, 0);
+
+ bool flip = (!vertical && (((bar->direction == Qt::RightToLeft) && !inverted) ||
+ ((bar->direction == Qt::LeftToRight) && inverted)));
+
+ QRegion rightRect = rect;
+ rightRect = rightRect.subtracted(leftRect);
+ painter->setClipRegion(rightRect);
+ painter->setPen(flip ? alternateTextColor : textColor);
+ painter->drawText(rect, bar->text, QTextOption(Qt::AlignAbsolute | Qt::AlignHCenter | Qt::AlignVCenter));
+ if (!leftRect.isNull()) {
+ painter->setPen(flip ? textColor : alternateTextColor);
+ painter->setClipRect(leftRect);
+ painter->drawText(rect, bar->text, QTextOption(Qt::AlignAbsolute | Qt::AlignHCenter | Qt::AlignVCenter));
+ }
+ painter->restore();
+ }
+ break;
+ case CE_PushButtonLabel:
+ if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+ QRect ir = button->rect;
+ uint tf = Qt::AlignVCenter | Qt::TextShowMnemonic;
+ QPoint buttonShift;
+
+ if (option->state & State_Sunken)
+ buttonShift = QPoint(pixelMetric(PM_ButtonShiftHorizontal, option, widget),
+ proxy()->pixelMetric(PM_ButtonShiftVertical, option, widget));
+
+ if (proxy()->styleHint(SH_UnderlineShortcut, button, widget))
+ tf |= Qt::TextShowMnemonic;
+ else
+ tf |= Qt::TextHideMnemonic;
+
+ if (!button->icon.isNull()) {
+ //Center both icon and text
+ QPoint point;
+
+ QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal : QIcon::Disabled;
+ if (mode == QIcon::Normal && button->state & State_HasFocus)
+ mode = QIcon::Active;
+
+ QIcon::State state = QIcon::Off;
+
+ if (button->state & State_On)
+ state = QIcon::On;
+
+ QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state);
+ int w = pixmap.width();
+ int h = pixmap.height();
+
+ if (!button->text.isEmpty())
+ w += button->fontMetrics.boundingRect(option->rect, tf, button->text).width() + 4;
+
+ point = QPoint(ir.x() + ir.width() / 2 - w / 2,
+ ir.y() + ir.height() / 2 - h / 2);
+
+ if (button->direction == Qt::RightToLeft)
+ point.rx() += pixmap.width();
+
+ painter->drawPixmap(visualPos(button->direction, button->rect, point + buttonShift), pixmap);
+
+ if (button->direction == Qt::RightToLeft)
+ ir.translate(-point.x() - 2, 0);
+ else
+ ir.translate(point.x() + pixmap.width() + 2, 0);
+
+ // left-align text if there is
+ if (!button->text.isEmpty())
+ tf |= Qt::AlignLeft;
+
+ } else {
+ tf |= Qt::AlignHCenter;
+ }
+
+ ir.translate(buttonShift);
+
+ if (button->features & QStyleOptionButton::HasMenu)
+ ir = ir.adjusted(0, 0, -pixelMetric(PM_MenuButtonIndicator, button, widget), 0);
+
+ GtkWidget *gtkButton = d->gtkWidget("GtkButton");
+ QPalette pal = button->palette;
+ int labelState = GTK_STATE_INSENSITIVE;
+ if (option->state & State_Enabled)
+ labelState = (option->state & State_MouseOver && !(option->state & State_Sunken)) ?
+ GTK_STATE_PRELIGHT : GTK_STATE_NORMAL;
+
+ GdkColor gdkText = gtkButton->style->fg[labelState];
+ QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
+ pal.setBrush(QPalette::ButtonText, textColor);
+ proxy()->drawItemText(painter, ir, tf, pal, (button->state & State_Enabled),
+ button->text, QPalette::ButtonText);
+ }
+ break;
+
+ case CE_RadioButton: // Fall through
+ case CE_CheckBox:
+ if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+ bool isRadio = (element == CE_RadioButton);
+
+ // Draw prelight background
+ GtkWidget *gtkRadioButton = d->gtkWidget("GtkRadioButton");
+
+ if (option->state & State_MouseOver) {
+ gtkPainter.paintFlatBox(gtkRadioButton, "checkbutton", option->rect,
+ GTK_STATE_PRELIGHT, GTK_SHADOW_ETCHED_OUT, gtkRadioButton->style);
+ }
+
+ QStyleOptionButton subopt = *btn;
+ subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator
+ : SE_CheckBoxIndicator, btn, widget);
+ proxy()->drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox,
+ &subopt, painter, widget);
+ subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents
+ : SE_CheckBoxContents, btn, widget);
+ // Get label text color
+ QPalette pal = subopt.palette;
+ int labelState = GTK_STATE_INSENSITIVE;
+ if (option->state & State_Enabled)
+ labelState = (option->state & State_MouseOver) ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL;
+
+ GdkColor gdkText = gtkRadioButton->style->fg[labelState];
+ QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
+ pal.setBrush(QPalette::WindowText, textColor);
+ subopt.palette = pal;
+ proxy()->drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, painter, widget);
+
+ if (btn->state & State_HasFocus) {
+ QStyleOptionFocusRect fropt;
+ fropt.QStyleOption::operator=(*btn);
+ fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect
+ : SE_CheckBoxFocusRect, btn, widget);
+ proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
+ }
+ }
+ break;
+
+#ifndef QT_NO_COMBOBOX
+
+ case CE_ComboBoxLabel:
+ if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
+ QRect editRect = proxy()->subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget);
+ bool appearsAsList = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, cb, widget);
+ painter->save();
+ painter->setClipRect(editRect);
+
+ if (!cb->currentIcon.isNull()) {
+ QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal
+ : QIcon::Disabled;
+ QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode);
+ QRect iconRect(editRect);
+ iconRect.setWidth(cb->iconSize.width() + 4);
+
+ iconRect = alignedRect(cb->direction,
+ Qt::AlignLeft | Qt::AlignVCenter,
+ iconRect.size(), editRect);
+
+ if (cb->editable)
+ painter->fillRect(iconRect, option->palette.brush(QPalette::Base));
+
+ proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap);
+
+ if (cb->direction == Qt::RightToLeft)
+ editRect.translate(-4 - cb->iconSize.width(), 0);
+ else
+ editRect.translate(cb->iconSize.width() + 4, 0);
+ }
+
+ if (!cb->currentText.isEmpty() && !cb->editable) {
+ GtkWidget *gtkCombo = d->gtkWidget("GtkComboBox");
+ QPalette pal = cb->palette;
+ int labelState = GTK_STATE_INSENSITIVE;
+
+ if (option->state & State_Enabled)
+ labelState = (option->state & State_MouseOver && !appearsAsList) ? GTK_STATE_PRELIGHT : GTK_STATE_NORMAL;
+
+ GdkColor gdkText = gtkCombo->style->fg[labelState];
+
+ QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
+
+ pal.setBrush(QPalette::ButtonText, textColor);
+
+ proxy()->drawItemText(painter, editRect.adjusted(1, 0, -1, 0),
+ visualAlignment(cb->direction, Qt::AlignLeft | Qt::AlignVCenter),
+ pal, cb->state & State_Enabled, cb->currentText, QPalette::ButtonText);
+ }
+
+ painter->restore();
+ }
+ break;
+
+#endif // QT_NO_COMBOBOX
+
+ case CE_DockWidgetTitle:
+ painter->save();
+ if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(option)) {
+ const QStyleOptionDockWidgetV2 *v2
+ = qstyleoption_cast<const QStyleOptionDockWidgetV2*>(dwOpt);
+ bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar;
+
+ QRect rect = dwOpt->rect;
+ QRect titleRect = subElementRect(SE_DockWidgetTitleBarText, option, widget).adjusted(-2, 0, -2, 0);
+ QRect r = rect.adjusted(0, 0, -1, -1);
+ if (verticalTitleBar)
+ r.adjust(0, 0, 0, -1);
+
+ if (verticalTitleBar) {
+ QRect r = rect;
+ QSize s = r.size();
+ s.transpose();
+ r.setSize(s);
+
+ titleRect = QRect(r.left() + rect.bottom()
+ - titleRect.bottom(),
+ r.top() + titleRect.left() - rect.left(),
+ titleRect.height(), titleRect.width());
+
+ painter->translate(r.left(), r.top() + r.width());
+ painter->rotate(-90);
+ painter->translate(-r.left(), -r.top());
+
+ rect = r;
+ }
+
+ if (!dwOpt->title.isEmpty()) {
+ QString titleText
+ = painter->fontMetrics().elidedText(dwOpt->title,
+ Qt::ElideRight, titleRect.width());
+ proxy()->drawItemText(painter,
+ titleRect,
+ Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, dwOpt->palette,
+ dwOpt->state & State_Enabled, titleText,
+ QPalette::WindowText);
+ }
+ }
+ painter->restore();
+ break;
+
+
+
+ case CE_HeaderSection:
+ painter->save();
+
+ // Draws the header in tables.
+ if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
+ Q_UNUSED(header);
+ GtkWidget *gtkTreeView = d->gtkWidget("GtkTreeView");
+ // Get the middle column
+ GtkTreeViewColumn *column = d->gtk_tree_view_get_column((GtkTreeView*)gtkTreeView, 1);
+ Q_ASSERT(column);
+
+ GtkWidget *gtkTreeHeader = column->button;
+ GtkStateType state = gtkPainter.gtkState(option);
+ GtkShadowType shadow = GTK_SHADOW_OUT;
+
+ if (option->state & State_Sunken)
+ shadow = GTK_SHADOW_IN;
+
+ gtkPainter.paintBox(gtkTreeHeader, "button", option->rect.adjusted(-1, 0, 0, 0), state, shadow, gtkTreeHeader->style);
+ }
+
+ painter->restore();
+ break;
+
+#ifndef QT_NO_SIZEGRIP
+
+ case CE_SizeGrip: {
+ GtkWidget *gtkStatusbar = d->gtkWidget("GtkStatusbar.GtkFrame");
+ QRect gripRect = option->rect.adjusted(0, 0, -gtkStatusbar->style->xthickness, -gtkStatusbar->style->ythickness);
+ gtkPainter.paintResizeGrip( gtkStatusbar, "statusbar", gripRect, GTK_STATE_NORMAL,
+ GTK_SHADOW_OUT, QApplication::isRightToLeft() ?
+ GDK_WINDOW_EDGE_SOUTH_WEST : GDK_WINDOW_EDGE_SOUTH_EAST,
+ gtkStatusbar->style);
+ }
+ break;
+
+#endif // QT_NO_SIZEGRIP
+
+ case CE_MenuBarEmptyArea: {
+ GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar");
+ GdkColor gdkBg = gtkMenubar->style->bg[GTK_STATE_NORMAL]; // Theme can depend on transparency
+ painter->fillRect(option->rect, QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8));
+ if (widget) { // See CE_MenuBarItem
+ QRect menuBarRect = widget->rect();
+ QPixmap pixmap(menuBarRect.size());
+ pixmap.fill(Qt::transparent);
+ QPainter pmPainter(&pixmap);
+ QGtkPainter gtkMenuBarPainter(&pmPainter);
+ GtkShadowType shadow_type;
+ d->gtk_widget_style_get(gtkMenubar, "shadow-type", &shadow_type, NULL);
+ gtkMenuBarPainter.paintBox( gtkMenubar, "menubar", menuBarRect,
+ GTK_STATE_NORMAL, shadow_type, gtkMenubar->style);
+ pmPainter.end();
+ painter->drawPixmap(option->rect, pixmap, option->rect);
+ }
+ }
+ break;
+
+ case CE_MenuBarItem:
+ painter->save();
+
+ if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
+ GtkWidget *gtkMenubarItem = d->gtkWidget("GtkMenuBar.GtkMenuItem");
+ GtkWidget *gtkMenubar = d->gtkWidget("GtkMenuBar");
+
+ style = gtkMenubarItem->style;
+
+ if (widget) {
+ // Since Qt does not currently allow filling the entire background
+ // we use a hack for this by making a complete menubar each time and
+ // paint with the correct offset inside it. Pixmap caching should resolve
+ // most of the performance penalty.
+ QRect menuBarRect = widget->rect();
+ QPixmap pixmap(menuBarRect.size());
+ pixmap.fill(Qt::transparent);
+ QPainter pmPainter(&pixmap);
+ QGtkPainter menubarPainter(&pmPainter);
+ GtkShadowType shadow_type;
+ d->gtk_widget_style_get(gtkMenubar, "shadow-type", &shadow_type, NULL);
+ GdkColor gdkBg = gtkMenubar->style->bg[GTK_STATE_NORMAL]; // Theme can depend on transparency
+ painter->fillRect(option->rect, QColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8));
+ menubarPainter.paintBox(gtkMenubar, "menubar", menuBarRect,
+ GTK_STATE_NORMAL, shadow_type, gtkMenubar->style);
+ pmPainter.end();
+ painter->drawPixmap(option->rect, pixmap, option->rect);
+ }
+
+ QStyleOptionMenuItem item = *mbi;
+ bool act = mbi->state & State_Selected && mbi->state & State_Sunken;
+ bool dis = !(mbi->state & State_Enabled);
+ item.rect = mbi->rect;
+ GdkColor gdkText = gtkMenubarItem->style->fg[dis ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL];
+ GdkColor gdkHText = gtkMenubarItem->style->fg[GTK_STATE_PRELIGHT];
+ QColor normalTextColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
+ QColor highlightedTextColor = QColor(gdkHText.red>>8, gdkHText.green>>8, gdkHText.blue>>8);
+ item.palette.setBrush(QPalette::HighlightedText, highlightedTextColor);
+ item.palette.setBrush(QPalette::Text, normalTextColor);
+ item.palette.setBrush(QPalette::ButtonText, normalTextColor);
+ QCommonStyle::drawControl(element, &item, painter, widget);
+
+ if (act) {
+ GtkShadowType shadowType = GTK_SHADOW_NONE;
+ d->gtk_widget_style_get (gtkMenubarItem, "selected-shadow-type", &shadowType, NULL);
+ gtkPainter.paintBox(gtkMenubarItem, "menuitem", option->rect.adjusted(0, 0, 0, 3),
+ GTK_STATE_PRELIGHT, shadowType, gtkMenubarItem->style);
+ //draw text
+ QPalette::ColorRole textRole = dis ? QPalette::Text : QPalette::HighlightedText;
+ uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
+
+ if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget))
+ alignment |= Qt::TextHideMnemonic;
+
+ proxy()->drawItemText(painter, item.rect, alignment, item.palette, mbi->state & State_Enabled, mbi->text, textRole);
+ }
+ }
+ painter->restore();
+ break;
+
+ case CE_Splitter: {
+ GtkWidget *gtkWindow = d->gtkWidget("GtkWindow"); // The Murrine Engine currently assumes a widget is passed
+ gtkPainter.paintHandle(gtkWindow, "splitter", option->rect, gtkPainter.gtkState(option), GTK_SHADOW_NONE,
+ !(option->state & State_Horizontal) ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL,
+ style);
+ }
+ break;
+
+#ifndef QT_NO_TOOLBAR
+
+ case CE_ToolBar:
+ if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(option)) {
+ // Reserve the beveled appearance only for mainwindow toolbars
+ if (!(widget && qobject_cast<const QMainWindow*> (widget->parentWidget())))
+ break;
+
+ QRect rect = option->rect;
+ // There is a 1 pixel gap between toolbar lines in some styles (i.e Human)
+ if (toolbar->positionWithinLine != QStyleOptionToolBar::End)
+ rect.adjust(0, 0, 1, 0);
+
+ GtkWidget *gtkToolbar = d->gtkWidget("GtkToolbar");
+ GtkShadowType shadow_type = GTK_SHADOW_NONE;
+ d->gtk_widget_style_get(gtkToolbar, "shadow-type", &shadow_type, NULL);
+ gtkPainter.paintBox( gtkToolbar, "toolbar", rect,
+ GTK_STATE_NORMAL, shadow_type, gtkToolbar->style);
+ }
+ break;
+
+#endif // QT_NO_TOOLBAR
+
+ case CE_MenuItem:
+ painter->save();
+
+ // Draws one item in a popup menu.
+ if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
+ const int windowsItemFrame = 2; // menu item frame width
+ const int windowsItemHMargin = 3; // menu item hor text margin
+ const int windowsItemVMargin = 26; // menu item ver text margin
+ const int windowsRightBorder = 15; // right border on windows
+ GtkWidget *gtkMenuItem = menuItem->checked ? d->gtkWidget("GtkMenu.GtkCheckMenuItem") :
+ d->gtkWidget("GtkMenu.GtkMenuItem");
+
+ style = gtkPainter.getStyle(gtkMenuItem);
+ QColor shadow = option->palette.dark().color();
+
+ if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
+ GtkWidget *gtkMenuSeparator = d->gtkWidget("GtkMenu.GtkSeparatorMenuItem");
+ painter->setPen(shadow.lighter(106));
+ gboolean wide_separators = 0;
+ gint separator_height = 0;
+ guint horizontal_padding = 3;
+ QRect separatorRect = option->rect;
+ if (!d->gtk_check_version(2, 10, 0)) {
+ d->gtk_widget_style_get(gtkMenuSeparator,
+ "wide-separators", &wide_separators,
+ "separator-height", &separator_height,
+ "horizontal-padding", &horizontal_padding,
+ NULL);
+ }
+ separatorRect.setHeight(option->rect.height() - 2 * gtkMenuSeparator->style->ythickness);
+ separatorRect.setWidth(option->rect.width() - 2 * (horizontal_padding + gtkMenuSeparator->style->xthickness));
+ separatorRect.moveCenter(option->rect.center());
+ if (wide_separators)
+ gtkPainter.paintBox( gtkMenuSeparator, "hseparator",
+ separatorRect, GTK_STATE_NORMAL, GTK_SHADOW_NONE, gtkMenuSeparator->style);
+ else
+ gtkPainter.paintHline( gtkMenuSeparator, "hseparator",
+ separatorRect, GTK_STATE_NORMAL, gtkMenuSeparator->style,
+ 0, option->rect.right() - 1, 1);
+ painter->restore();
+ break;
+ }
+
+ bool selected = menuItem->state & State_Selected && menuItem->state & State_Enabled;
+
+ if (selected) {
+ QRect rect = option->rect;
+#ifndef QT_NO_COMBOBOX
+ if (qobject_cast<const QComboBox*>(widget))
+ rect = option->rect;
+#endif
+ gtkPainter.paintBox( gtkMenuItem, "menuitem", rect, GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, style);
+ }
+
+ bool checkable = menuItem->checkType != QStyleOptionMenuItem::NotCheckable;
+ bool checked = menuItem->checked;
+ bool enabled = menuItem->state & State_Enabled;
+ bool ignoreCheckMark = false;
+
+ gint checkSize;
+ d->gtk_widget_style_get(d->gtkWidget("GtkMenu.GtkCheckMenuItem"), "indicator-size", &checkSize, NULL);
+
+ int checkcol = qMax(menuItem->maxIconWidth, qMax(20, checkSize));
+
+#ifndef QT_NO_COMBOBOX
+
+ if (qobject_cast<const QComboBox*>(widget))
+ ignoreCheckMark = true; // Ignore the checkmarks provided by the QComboMenuDelegate
+
+#endif
+ if (!ignoreCheckMark) {
+ // Check
+ QRect checkRect(option->rect.left() + 7, option->rect.center().y() - checkSize/2 + 1, checkSize, checkSize);
+ checkRect = visualRect(menuItem->direction, menuItem->rect, checkRect);
+
+ if (checkable && menuItem->icon.isNull()) {
+ // Some themes such as aero-clone draw slightly outside the paint rect
+ int spacing = 1; // ### Consider using gtkCheckBox : "indicator-spacing" instead
+
+ if (menuItem->checkType & QStyleOptionMenuItem::Exclusive) {
+ // Radio button
+ GtkShadowType shadow = GTK_SHADOW_OUT;
+ GtkStateType state = gtkPainter.gtkState(option);
+
+ if (selected)
+ state = GTK_STATE_PRELIGHT;
+ if (checked)
+ shadow = GTK_SHADOW_IN;
+
+ gtkPainter.setClipRect(checkRect.adjusted(-spacing, -spacing, spacing, spacing));
+ gtkPainter.paintOption(gtkMenuItem, checkRect.translated(-spacing, -spacing), state, shadow,
+ gtkMenuItem->style, QLS("option"));
+ gtkPainter.setClipRect(QRect());
+
+ } else {
+ // Check box
+ if (menuItem->icon.isNull()) {
+ GtkShadowType shadow = GTK_SHADOW_OUT;
+ GtkStateType state = gtkPainter.gtkState(option);
+
+ if (selected)
+ state = GTK_STATE_PRELIGHT;
+ if (checked)
+ shadow = GTK_SHADOW_IN;
+
+ gtkPainter.setClipRect(checkRect.adjusted(-spacing, -spacing, -spacing, -spacing));
+ gtkPainter.paintCheckbox(gtkMenuItem, checkRect.translated(-spacing, -spacing), state, shadow,
+ gtkMenuItem->style, QLS("check"));
+ gtkPainter.setClipRect(QRect());
+ }
+ }
+ }
+
+ } else {
+ // Ignore checkmark
+ if (menuItem->icon.isNull())
+ checkcol = 0;
+ else
+ checkcol = menuItem->maxIconWidth;
+ }
+
+ bool dis = !(menuItem->state & State_Enabled);
+ bool act = menuItem->state & State_Selected;
+ const QStyleOption *opt = option;
+ const QStyleOptionMenuItem *menuitem = menuItem;
+ QPainter *p = painter;
+ QRect vCheckRect = visualRect(opt->direction, menuitem->rect,
+ QRect(menuitem->rect.x() + 3, menuitem->rect.y(),
+ checkcol, menuitem->rect.height()));
+
+ if (!menuItem->icon.isNull()) {
+ QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
+
+ if (act && !dis)
+ mode = QIcon::Active;
+
+ QPixmap pixmap;
+ int smallIconSize = proxy()->pixelMetric(PM_SmallIconSize, option, widget);
+ QSize iconSize(smallIconSize, smallIconSize);
+
+#ifndef QT_NO_COMBOBOX
+ if (const QComboBox *combo = qobject_cast<const QComboBox*>(widget))
+ iconSize = combo->iconSize();
+
+#endif // QT_NO_COMBOBOX
+ if (checked)
+ pixmap = menuItem->icon.pixmap(iconSize, mode, QIcon::On);
+ else
+ pixmap = menuItem->icon.pixmap(iconSize, mode);
+
+ int pixw = pixmap.width();
+ int pixh = pixmap.height();
+ QRect pmr(0, 0, pixw, pixh);
+ pmr.moveCenter(vCheckRect.center() - QPoint(0, 1));
+ painter->setPen(menuItem->palette.text().color());
+ if (!ignoreCheckMark && checkable && checked) {
+ QStyleOption opt = *option;
+
+ if (act) {
+ QColor activeColor = mergedColors(option->palette.background().color(),
+ option->palette.highlight().color());
+ opt.palette.setBrush(QPalette::Button, activeColor);
+ }
+ opt.state |= State_Sunken;
+ opt.rect = vCheckRect;
+ proxy()->drawPrimitive(PE_PanelButtonCommand, &opt, painter, widget);
+ }
+ painter->drawPixmap(pmr.topLeft(), pixmap);
+ }
+
+ GdkColor gdkText = gtkMenuItem->style->fg[GTK_STATE_NORMAL];
+ GdkColor gdkDText = gtkMenuItem->style->fg[GTK_STATE_INSENSITIVE];
+ GdkColor gdkHText = gtkMenuItem->style->fg[GTK_STATE_PRELIGHT];
+ uint resolve_mask = option->palette.resolve();
+ QColor textColor = QColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
+ QColor disabledTextColor = QColor(gdkDText.red>>8, gdkDText.green>>8, gdkDText.blue>>8);
+ if (resolve_mask & (1 << QPalette::ButtonText)) {
+ textColor = option->palette.buttonText().color();
+ disabledTextColor = option->palette.brush(QPalette::Disabled, QPalette::ButtonText).color();
+ }
+
+ QColor highlightedTextColor = QColor(gdkHText.red>>8, gdkHText.green>>8, gdkHText.blue>>8);
+ if (resolve_mask & (1 << QPalette::HighlightedText)) {
+ highlightedTextColor = option->palette.highlightedText().color();
+ }
+
+ if (selected)
+ painter->setPen(highlightedTextColor);
+ else
+ painter->setPen(textColor);
+
+ int x, y, w, h;
+ menuitem->rect.getRect(&x, &y, &w, &h);
+ int tab = menuitem->tabWidth;
+ int xm = windowsItemFrame + checkcol + windowsItemHMargin;
+ int xpos = menuitem->rect.x() + xm + 1;
+ QRect textRect(xpos, y + windowsItemVMargin, w - xm - windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin);
+ QRect vTextRect = visualRect(opt->direction, menuitem->rect, textRect);
+ QString s = menuitem->text;
+
+ if (!s.isEmpty()) { // Draw text
+ p->save();
+ int t = s.indexOf(QLatin1Char('\t'));
+ int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
+
+ if (!proxy()->styleHint(SH_UnderlineShortcut, menuitem, widget))
+ text_flags |= Qt::TextHideMnemonic;
+
+ // Draw shortcut right aligned
+ text_flags |= Qt::AlignRight;
+
+ if (t >= 0) {
+ int rightMargin = 12; // Hardcode for now
+ QRect vShortcutRect = visualRect(opt->direction, menuitem->rect,
+ QRect(textRect.topRight(), QPoint(menuitem->rect.right() - rightMargin, textRect.bottom())));
+
+ if (dis)
+ p->setPen(disabledTextColor);
+ p->drawText(vShortcutRect, text_flags , s.mid(t + 1));
+ s = s.left(t);
+ }
+
+ text_flags &= ~Qt::AlignRight;
+ text_flags |= Qt::AlignLeft;
+ QFont font = menuitem->font;
+ if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem)
+ font.setBold(true);
+ p->setFont(font);
+
+ if (dis)
+ p->setPen(disabledTextColor);
+ p->drawText(vTextRect, text_flags, s.left(t));
+ p->restore();
+ }
+
+ // Arrow
+ if (menuItem->menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
+
+ QFontMetrics fm(menuitem->font);
+ int arrow_size = fm.ascent() + fm.descent() - 2 * gtkMenuItem->style->ythickness;
+ gfloat arrow_scaling = 0.8;
+ int extra = 0;
+ if (!d->gtk_check_version(2, 16, 0)) {
+ // "arrow-scaling" is actually hardcoded and fails on hardy (see gtk+-2.12/gtkmenuitem.c)
+ // though the current documentation states otherwise
+ d->gtk_widget_style_get(gtkMenuItem, "arrow-scaling", &arrow_scaling, NULL);
+ // in versions < 2.16 ythickness was previously subtracted from the arrow_size
+ extra = 2 * gtkMenuItem->style->ythickness;
+ }
+
+ int horizontal_padding;
+ d->gtk_widget_style_get(gtkMenuItem, "horizontal-padding", &horizontal_padding, NULL);
+
+ const int dim = static_cast<int>(arrow_size * arrow_scaling) + extra;
+ int xpos = menuItem->rect.left() + menuItem->rect.width() - horizontal_padding - dim;
+ QRect vSubMenuRect = visualRect(option->direction, menuItem->rect,
+ QRect(xpos, menuItem->rect.top() +
+ menuItem->rect.height() / 2 - dim / 2, dim, dim));
+ GtkStateType state = enabled ? (act ? GTK_STATE_PRELIGHT: GTK_STATE_NORMAL) : GTK_STATE_INSENSITIVE;
+ GtkShadowType shadowType = (state == GTK_STATE_PRELIGHT) ? GTK_SHADOW_OUT : GTK_SHADOW_IN;
+ gtkPainter.paintArrow(gtkMenuItem, "menuitem", vSubMenuRect, QApplication::isRightToLeft() ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT, state,
+ shadowType, FALSE, style);
+ }
+ }
+ painter->restore();
+ break;
+
+ case CE_PushButton:
+ if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+ GtkWidget *gtkButton = d->gtkWidget("GtkButton");
+ proxy()->drawControl(CE_PushButtonBevel, btn, painter, widget);
+ QStyleOptionButton subopt = *btn;
+ subopt.rect = subElementRect(SE_PushButtonContents, btn, widget);
+ gint interiorFocus = true;
+ d->gtk_widget_style_get(gtkButton, "interior-focus", &interiorFocus, NULL);
+ int xt = interiorFocus ? gtkButton->style->xthickness : 0;
+ int yt = interiorFocus ? gtkButton->style->ythickness : 0;
+
+ if (btn->features & QStyleOptionButton::Flat && btn->state & State_HasFocus)
+ // The normal button focus rect does not work well for flat buttons in Clearlooks
+ proxy()->drawPrimitive(PE_FrameFocusRect, option, painter, widget);
+ else if (btn->state & State_HasFocus)
+ gtkPainter.paintFocus(gtkButton, "button",
+ option->rect.adjusted(xt, yt, -xt, -yt),
+ btn->state & State_Sunken ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL,
+ gtkButton->style);
+
+ proxy()->drawControl(CE_PushButtonLabel, &subopt, painter, widget);
+ }
+ break;
+
+#ifndef QT_NO_TABBAR
+
+ case CE_TabBarTabShape:
+ if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
+ GtkWidget *gtkNotebook = d->gtkWidget("GtkNotebook");
+ style = gtkPainter.getStyle(gtkNotebook);
+
+ QRect rect = option->rect;
+ GtkShadowType shadow = GTK_SHADOW_OUT;
+ GtkStateType state = GTK_STATE_ACTIVE;
+ if (tab->state & State_Selected)
+ state = GTK_STATE_NORMAL;
+
+ bool selected = (tab->state & State_Selected);
+ bool first = false, last = false;
+ if (widget) {
+ // This is most accurate and avoids resizing tabs while moving
+ first = tab->rect.left() == widget->rect().left();
+ last = tab->rect.right() == widget->rect().right();
+ } else if (option->direction == Qt::RightToLeft) {
+ bool tmp = first;
+ first = last;
+ last = tmp;
+ }
+ int topIndent = 3;
+ int bottomIndent = 1;
+ int tabOverlap = 1;
+ painter->save();
+
+ switch (tab->shape) {
+ case QTabBar::RoundedNorth:
+ if (!selected)
+ rect.adjust(first ? 0 : -tabOverlap, topIndent, last ? 0 : tabOverlap, -bottomIndent);
+ gtkPainter.paintExtention( gtkNotebook, "tab", rect,
+ state, shadow, GTK_POS_BOTTOM, style);
+ break;
+
+ case QTabBar::RoundedSouth:
+ if (!selected)
+ rect.adjust(first ? 0 : -tabOverlap, 0, last ? 0 : tabOverlap, -topIndent);
+ gtkPainter.paintExtention( gtkNotebook, "tab", rect.adjusted(0, 1, 0, 0),
+ state, shadow, GTK_POS_TOP, style);
+ break;
+
+ case QTabBar::RoundedWest:
+ if (!selected)
+ rect.adjust(topIndent, 0, -bottomIndent, 0);
+ gtkPainter.paintExtention( gtkNotebook, "tab", rect, state, shadow, GTK_POS_RIGHT, style);
+ break;
+
+ case QTabBar::RoundedEast:
+ if (!selected)
+ rect.adjust(bottomIndent, 0, -topIndent, 0);
+ gtkPainter.paintExtention( gtkNotebook, "tab", rect, state, shadow, GTK_POS_LEFT, style);
+ break;
+
+ default:
+ QCleanlooksStyle::drawControl(element, option, painter, widget);
+ break;
+ }
+
+ painter->restore();
+ }
+
+ break;
+
+#endif //QT_NO_TABBAR
+
+ case CE_ProgressBarGroove:
+ if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
+ Q_UNUSED(bar);
+ GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar");
+ GtkStateType state = gtkPainter.gtkState(option);
+ gtkPainter.paintBox( gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, gtkProgressBar->style);
+ }
+
+ break;
+
+ case CE_ProgressBarContents:
+ if (const QStyleOptionProgressBar *bar = qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
+ GtkStateType state = option->state & State_Enabled ? GTK_STATE_NORMAL : GTK_STATE_INSENSITIVE;
+ GtkWidget *gtkProgressBar = d->gtkWidget("GtkProgressBar");
+ style = gtkProgressBar->style;
+ gtkPainter.paintBox( gtkProgressBar, "trough", option->rect, state, GTK_SHADOW_IN, style);
+ int xt = style->xthickness;
+ int yt = style->ythickness;
+ QRect rect = bar->rect.adjusted(xt, yt, -xt, -yt);
+ bool vertical = false;
+ bool inverted = false;
+ bool indeterminate = (bar->minimum == 0 && bar->maximum == 0);
+ // Get extra style options if version 2
+
+ if (const QStyleOptionProgressBarV2 *bar2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(option)) {
+ vertical = (bar2->orientation == Qt::Vertical);
+ inverted = bar2->invertedAppearance;
+ }
+
+ // If the orientation is vertical, we use a transform to rotate
+ // the progress bar 90 degrees clockwise. This way we can use the
+ // same rendering code for both orientations.
+ if (vertical) {
+ rect.translate(xt, -yt * 2);
+ rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // Flip width and height
+ QTransform m = QTransform::fromTranslate(rect.height(), 0);
+ m.rotate(90.0);
+ painter->setTransform(m);
+ }
+
+ int maxWidth = rect.width();
+ int minWidth = 4;
+
+ qint64 progress = (qint64)qMax(bar->progress, bar->minimum); // Workaround for bug in QProgressBar
+ double vc6_workaround = ((progress - qint64(bar->minimum)) / double(qint64(bar->maximum) - qint64(bar->minimum))) * maxWidth;
+ int progressBarWidth = (int(vc6_workaround) > minWidth ) ? int(vc6_workaround) : minWidth;
+ int width = indeterminate ? maxWidth : progressBarWidth;
+ bool reverse = (!vertical && (bar->direction == Qt::RightToLeft)) || vertical;
+
+ if (inverted)
+ reverse = !reverse;
+
+ int maximum = 2;
+ int fakePos = 0;
+ if (bar->minimum == bar->maximum)
+ maximum = 0;
+ if (bar->progress == bar->maximum)
+ fakePos = maximum;
+ else if (bar->progress > bar->minimum)
+ fakePos = maximum - 1;
+
+ d->gtk_progress_configure((GtkProgress*)gtkProgressBar, fakePos, 0, maximum);
+
+ QRect progressBar;
+
+ if (!indeterminate) {
+ if (!reverse)
+ progressBar.setRect(rect.left(), rect.top(), width, rect.height());
+ else
+ progressBar.setRect(rect.right() - width, rect.top(), width, rect.height());
+
+ } else {
+ Q_D(const QGtkStyle);
+ int slideWidth = ((rect.width() - 4) * 2) / 3;
+ int step = ((d->animateStep * slideWidth) / d->animationFps) % slideWidth;
+ if ((((d->animateStep * slideWidth) / d->animationFps) % (2 * slideWidth)) >= slideWidth)
+ step = slideWidth - step;
+ progressBar.setRect(rect.left() + step, rect.top(), slideWidth / 2, rect.height());
+ }
+
+ QString key = QString(QLS("%0")).arg(fakePos);
+ if (inverted) {
+ key += QLatin1String("inv");
+ gtkPainter.setFlipHorizontal(true);
+ }
+ gtkPainter.paintBox( gtkProgressBar, "bar", progressBar, GTK_STATE_SELECTED, GTK_SHADOW_OUT, style, key);
+ }
+
+ break;
+
+ default:
+ QCleanlooksStyle::drawControl(element, option, painter, widget);
+ }
+}
+
+/*!
+ \reimp
+*/
+QRect QGtkStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option,
+ SubControl subControl, const QWidget *widget) const
+{
+ Q_D(const QGtkStyle);
+
+ QRect rect = QWindowsStyle::subControlRect(control, option, subControl, widget);
+ if (!d->isThemeAvailable())
+ return QCleanlooksStyle::subControlRect(control, option, subControl, widget);
+
+ switch (control) {
+ case CC_TitleBar:
+ return QCleanlooksStyle::subControlRect(control, option, subControl, widget);
+
+ case CC_Slider:
+ if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
+ // Reserve space for outside focus rect
+ QStyleOptionSlider sliderCopy = *slider;
+ sliderCopy.rect = option->rect.adjusted(2, 2, -2, -2);
+ return QCleanlooksStyle::subControlRect(control, &sliderCopy, subControl, widget);
+ }
+
+ break;
+
+#ifndef QT_NO_GROUPBOX
+
+ case CC_GroupBox:
+ if (qstyleoption_cast<const QStyleOptionGroupBox *>(option)) {
+ rect = option->rect.adjusted(0, groupBoxTopMargin, 0, -groupBoxBottomMargin);
+ int topMargin = 0;
+ int topHeight = 0;
+ topHeight = 10;
+ QRect frameRect = rect;
+ frameRect.setTop(topMargin);
+
+ if (subControl == SC_GroupBoxFrame)
+ return rect;
+ else if (subControl == SC_GroupBoxContents) {
+ int margin = 0;
+ int leftMarginExtension = 8;
+ return frameRect.adjusted(leftMarginExtension + margin, margin + topHeight + groupBoxTitleMargin, -margin, -margin);
+ }
+
+ if (const QGroupBox *groupBoxWidget = qobject_cast<const QGroupBox *>(widget)) {
+ //Prepare metrics for a bold font
+ QFont font = widget->font();
+ font.setBold(true);
+ QFontMetrics fontMetrics(font);
+ QSize textRect = fontMetrics.boundingRect(groupBoxWidget->title()).size() + QSize(4, 4);
+ int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, option, widget);
+ int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, option, widget);
+
+ if (subControl == SC_GroupBoxCheckBox) {
+ rect.setWidth(indicatorWidth);
+ rect.setHeight(indicatorHeight);
+ rect.moveTop((textRect.height() - indicatorHeight) / 2);
+
+ } else if (subControl == SC_GroupBoxLabel) {
+ if (groupBoxWidget->isCheckable())
+ rect.adjust(indicatorWidth + 4, 0, 0, 0);
+ rect.setSize(textRect);
+ }
+ rect = visualRect(option->direction, option->rect, rect);
+ }
+ }
+
+ return rect;
+
+#endif
+#ifndef QT_NO_SPINBOX
+
+ case CC_SpinBox:
+ if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
+ GtkWidget *gtkSpinButton = d->gtkWidget("GtkSpinButton");
+ int center = spinbox->rect.height() / 2;
+ int xt = spinbox->frame ? gtkSpinButton->style->xthickness : 0;
+ int yt = spinbox->frame ? gtkSpinButton->style->ythickness : 0;
+ int y = yt;
+
+ QSize bs;
+ bs.setHeight(qMax(8, spinbox->rect.height()/2 - y));
+ bs.setWidth(d->getSpinboxArrowSize());
+ int x, lx, rx;
+ x = spinbox->rect.width() - y - bs.width() + 2;
+ lx = xt;
+ rx = x - xt;
+
+ switch (subControl) {
+
+ case SC_SpinBoxUp:
+ if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
+ return QRect();
+ rect = QRect(x, xt, bs.width(), center - yt);
+ break;
+
+ case SC_SpinBoxDown:
+ if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
+ return QRect();
+ rect = QRect(x, center, bs.width(), spinbox->rect.bottom() - center - yt + 1);
+ break;
+
+ case SC_SpinBoxEditField:
+ if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
+ rect = QRect(lx, yt, spinbox->rect.width() - 2*xt, spinbox->rect.height() - 2*yt);
+ else
+ rect = QRect(lx, yt, rx - qMax(xt - 1, 0), spinbox->rect.height() - 2*yt);
+ break;
+
+ case SC_SpinBoxFrame:
+ rect = spinbox->rect;
+
+ default:
+ break;
+ }
+
+ rect = visualRect(spinbox->direction, spinbox->rect, rect);
+ }
+
+ break;
+
+#endif // Qt_NO_SPINBOX
+#ifndef QT_NO_COMBOBOX
+
+ case CC_ComboBox:
+ if (const QStyleOptionComboBox *box = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
+ // We employ the gtk widget to position arrows and separators for us
+ GtkWidget *gtkCombo = box->editable ? d->gtkWidget("GtkComboBoxEntry")
+ : d->gtkWidget("GtkComboBox");
+ d->gtk_widget_set_direction(gtkCombo, (option->direction == Qt::RightToLeft) ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR);
+ GtkAllocation geometry = {0, 0, qMax(0, option->rect.width()), qMax(0, option->rect.height())};
+ d->gtk_widget_size_allocate(gtkCombo, &geometry);
+ int appears_as_list = !proxy()->styleHint(QStyle::SH_ComboBox_Popup, option, widget);
+ QHashableLatin1Literal arrowPath("GtkComboBoxEntry.GtkToggleButton");
+ if (!box->editable) {
+ if (appears_as_list)
+ arrowPath = "GtkComboBox.GtkToggleButton";
+ else
+ arrowPath = "GtkComboBox.GtkToggleButton.GtkHBox.GtkArrow";
+ }
+
+ GtkWidget *arrowWidget = d->gtkWidget(arrowPath);
+ if (!arrowWidget)
+ return QCleanlooksStyle::subControlRect(control, option, subControl, widget);
+
+ QRect buttonRect(option->rect.left() + arrowWidget->allocation.x,
+ option->rect.top() + arrowWidget->allocation.y,
+ arrowWidget->allocation.width, arrowWidget->allocation.height);
+
+ switch (subControl) {
+
+ case SC_ComboBoxArrow: // Note: this indicates the arrowbutton for editable combos
+ rect = buttonRect;
+ break;
+
+ case SC_ComboBoxEditField: {
+ rect = visualRect(option->direction, option->rect, rect);
+ int xMargin = box->editable ? 1 : 4, yMargin = 2;
+ rect.setRect(option->rect.left() + gtkCombo->style->xthickness + xMargin,
+ option->rect.top() + gtkCombo->style->ythickness + yMargin,
+ option->rect.width() - buttonRect.width() - 2*(gtkCombo->style->xthickness + xMargin),
+ option->rect.height() - 2*(gtkCombo->style->ythickness + yMargin));
+ rect = visualRect(option->direction, option->rect, rect);
+ break;
+ }
+
+ default:
+ break;
+ }
+ }
+
+ break;
+
+#endif // QT_NO_COMBOBOX
+
+ default:
+ break;
+ }
+
+ return rect;
+}
+
+/*!
+ \reimp
+*/
+QSize QGtkStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
+ const QSize &size, const QWidget *widget) const
+{
+ Q_D(const QGtkStyle);
+
+ QSize newSize = QCleanlooksStyle::sizeFromContents(type, option, size, widget);
+ if (!d->isThemeAvailable())
+ return newSize;
+
+ switch (type) {
+
+ case CT_ToolButton:
+ if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
+ GtkWidget *gtkButton = d->gtkWidget("GtkToolButton.GtkButton");
+ newSize = size + QSize(2 * gtkButton->style->xthickness, 2 + 2 * gtkButton->style->ythickness);
+ if (widget && qobject_cast<QToolBar *>(widget->parentWidget())) {
+ QSize minSize(0, 25);
+ if (toolbutton->toolButtonStyle != Qt::ToolButtonTextOnly)
+ minSize = toolbutton->iconSize + QSize(12, 12);
+ newSize = newSize.expandedTo(minSize);
+ }
+
+ if (toolbutton->features & QStyleOptionToolButton::HasMenu)
+ newSize += QSize(6, 0);
+ }
+ break;
+ case CT_MenuItem:
+ if (const QStyleOptionMenuItem *menuItem = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
+ int textMargin = 8;
+
+ if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) {
+ GtkWidget *gtkMenuSeparator = d->gtkWidget("GtkMenu.GtkSeparatorMenuItem");
+ GtkRequisition sizeReq = {0, 0};
+ d->gtk_widget_size_request(gtkMenuSeparator, &sizeReq);
+ newSize = QSize(size.width(), sizeReq.height);
+ break;
+ }
+
+ GtkWidget *gtkMenuItem = d->gtkWidget("GtkMenu.GtkCheckMenuItem");
+ GtkStyle* style = gtkMenuItem->style;
+
+ // Note we get the perfect height for the default font since we
+ // set a fake text label on the gtkMenuItem
+ // But if custom fonts are used on the widget we need a minimum size
+ GtkRequisition sizeReq = {0, 0};
+ d->gtk_widget_size_request(gtkMenuItem, &sizeReq);
+ newSize.setHeight(qMax(newSize.height() - 4, sizeReq.height));
+ newSize += QSize(textMargin + style->xthickness - 1, 0);
+
+ // Cleanlooks assumes a check column of 20 pixels so we need to
+ // expand it a bit
+ gint checkSize;
+ d->gtk_widget_style_get(gtkMenuItem, "indicator-size", &checkSize, NULL);
+ newSize.setWidth(newSize.width() + qMax(0, checkSize - 20));
+ }
+
+ break;
+
+ case CT_SpinBox:
+ // QSpinBox does some nasty things that depends on CT_LineEdit
+ newSize = size + QSize(0, -d->gtkWidget("GtkSpinButton")->style->ythickness * 2);
+ break;
+
+ case CT_PushButton:
+ if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(option)) {
+ GtkWidget *gtkButton = d->gtkWidget("GtkButton");
+ gint focusPadding, focusWidth;
+ d->gtk_widget_style_get(gtkButton, "focus-padding", &focusPadding, NULL);
+ d->gtk_widget_style_get(gtkButton, "focus-line-width", &focusWidth, NULL);
+ newSize = size;
+ newSize += QSize(2*gtkButton->style->xthickness + 4, 2*gtkButton->style->ythickness);
+ newSize += QSize(2*(focusWidth + focusPadding + 2), 2*(focusWidth + focusPadding));
+
+ GtkWidget *gtkButtonBox = d->gtkWidget("GtkHButtonBox");
+ gint minWidth = 85, minHeight = 0;
+ d->gtk_widget_style_get(gtkButtonBox, "child-min-width", &minWidth,
+ "child-min-height", &minHeight, NULL);
+ if (!btn->text.isEmpty() && newSize.width() < minWidth)
+ newSize.setWidth(minWidth);
+ if (newSize.height() < minHeight)
+ newSize.setHeight(minHeight);
+ }
+
+ break;
+
+ case CT_Slider: {
+ GtkWidget *gtkSlider = d->gtkWidget("GtkHScale");
+ newSize = size + QSize(2*gtkSlider->style->xthickness, 2*gtkSlider->style->ythickness);
+ }
+ break;
+
+ case CT_LineEdit: {
+ GtkWidget *gtkEntry = d->gtkWidget("GtkEntry");
+ newSize = size + QSize(2*gtkEntry->style->xthickness, 2 + 2*gtkEntry->style->ythickness);
+ }
+ break;
+
+ case CT_ItemViewItem:
+ newSize += QSize(0, 2);
+ break;
+
+ case CT_ComboBox:
+ if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
+ GtkWidget *gtkCombo = d->gtkWidget("GtkComboBox");
+ QRect arrowButtonRect = proxy()->subControlRect(CC_ComboBox, combo, SC_ComboBoxArrow, widget);
+ newSize = size + QSize(12 + arrowButtonRect.width() + 2*gtkCombo->style->xthickness, 4 + 2*gtkCombo->style->ythickness);
+
+ if (!(widget && qobject_cast<QToolBar *>(widget->parentWidget())))
+ newSize += QSize(0, 2);
+ }
+ break;
+
+ case CT_GroupBox:
+ newSize += QSize(4, groupBoxBottomMargin + groupBoxTopMargin + groupBoxTitleMargin); // Add some space below the groupbox
+ break;
+
+ case CT_TabBarTab:
+ if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(option)) {
+ if (!tab->icon.isNull())
+ newSize += QSize(6, 0);
+ }
+ newSize += QSize(1, 1);
+ break;
+
+ default:
+ break;
+ }
+
+ return newSize;
+}
+
+
+/*! \reimp */
+QPixmap QGtkStyle::standardPixmap(StandardPixmap sp, const QStyleOption *option,
+ const QWidget *widget) const
+{
+ Q_D(const QGtkStyle);
+
+ if (!d->isThemeAvailable())
+ return QCleanlooksStyle::standardPixmap(sp, option, widget);
+
+ QPixmap pixmap;
+ switch (sp) {
+
+ case SP_TitleBarNormalButton: {
+ QImage restoreButton((const char **)dock_widget_restore_xpm);
+ QColor alphaCorner = restoreButton.color(2);
+ alphaCorner.setAlpha(80);
+ restoreButton.setColor(2, alphaCorner.rgba());
+ alphaCorner.setAlpha(180);
+ restoreButton.setColor(4, alphaCorner.rgba());
+ return QPixmap::fromImage(restoreButton);
+ }
+ break;
+
+ case SP_TitleBarCloseButton: // Fall through
+ case SP_DockWidgetCloseButton: {
+
+ QImage closeButton((const char **)dock_widget_close_xpm);
+ QColor alphaCorner = closeButton.color(2);
+ alphaCorner.setAlpha(80);
+ closeButton.setColor(2, alphaCorner.rgba());
+ return QPixmap::fromImage(closeButton);
+ }
+ break;
+
+ case SP_DialogDiscardButton:
+ return QGtkPainter::getIcon(GTK_STOCK_DELETE);
+ case SP_DialogOkButton:
+ return QGtkPainter::getIcon(GTK_STOCK_OK);
+ case SP_DialogCancelButton:
+ return QGtkPainter::getIcon(GTK_STOCK_CANCEL);
+ case SP_DialogYesButton:
+ return QGtkPainter::getIcon(GTK_STOCK_YES);
+ case SP_DialogNoButton:
+ return QGtkPainter::getIcon(GTK_STOCK_NO);
+ case SP_DialogOpenButton:
+ return QGtkPainter::getIcon(GTK_STOCK_OPEN);
+ case SP_DialogCloseButton:
+ return QGtkPainter::getIcon(GTK_STOCK_CLOSE);
+ case SP_DialogApplyButton:
+ return QGtkPainter::getIcon(GTK_STOCK_APPLY);
+ case SP_DialogSaveButton:
+ return QGtkPainter::getIcon(GTK_STOCK_SAVE);
+ case SP_MessageBoxWarning:
+ return QGtkPainter::getIcon(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
+ case SP_MessageBoxQuestion:
+ return QGtkPainter::getIcon(GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
+ case SP_MessageBoxInformation:
+ return QGtkPainter::getIcon(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
+ case SP_MessageBoxCritical:
+ return QGtkPainter::getIcon(GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG);
+ default:
+ return QCleanlooksStyle::standardPixmap(sp, option, widget);
+ }
+ return pixmap;
+}
+
+/*!
+ \internal
+*/
+QIcon QGtkStyle::standardIconImplementation(StandardPixmap standardIcon,
+ const QStyleOption *option,
+ const QWidget *widget) const
+{
+ Q_D(const QGtkStyle);
+
+ if (!d->isThemeAvailable())
+ return QCleanlooksStyle::standardIconImplementation(standardIcon, option, widget);
+ switch (standardIcon) {
+ case SP_DialogDiscardButton:
+ return QGtkPainter::getIcon(GTK_STOCK_DELETE);
+ case SP_DialogOkButton:
+ return QGtkPainter::getIcon(GTK_STOCK_OK);
+ case SP_DialogCancelButton:
+ return QGtkPainter::getIcon(GTK_STOCK_CANCEL);
+ case SP_DialogYesButton:
+ return QGtkPainter::getIcon(GTK_STOCK_YES);
+ case SP_DialogNoButton:
+ return QGtkPainter::getIcon(GTK_STOCK_NO);
+ case SP_DialogOpenButton:
+ return QGtkPainter::getIcon(GTK_STOCK_OPEN);
+ case SP_DialogCloseButton:
+ return QGtkPainter::getIcon(GTK_STOCK_CLOSE);
+ case SP_DialogApplyButton:
+ return QGtkPainter::getIcon(GTK_STOCK_APPLY);
+ case SP_DialogSaveButton:
+ return QGtkPainter::getIcon(GTK_STOCK_SAVE);
+ case SP_MessageBoxWarning:
+ return QGtkPainter::getIcon(GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
+ case SP_MessageBoxQuestion:
+ return QGtkPainter::getIcon(GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
+ case SP_MessageBoxInformation:
+ return QGtkPainter::getIcon(GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
+ case SP_MessageBoxCritical:
+ return QGtkPainter::getIcon(GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG);
+ default:
+ return QCleanlooksStyle::standardIconImplementation(standardIcon, option, widget);
+ }
+}
+
+
+/*! \reimp */
+QRect QGtkStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const
+{
+ Q_D(const QGtkStyle);
+
+ QRect r = QCleanlooksStyle::subElementRect(element, option, widget);
+ if (!d->isThemeAvailable())
+ return r;
+
+ switch (element) {
+ case SE_ProgressBarLabel:
+ case SE_ProgressBarContents:
+ case SE_ProgressBarGroove:
+ return option->rect;
+ case SE_PushButtonContents:
+ if (!d->gtk_check_version(2, 10, 0)) {
+ GtkWidget *gtkButton = d->gtkWidget("GtkButton");
+ GtkBorder *border = 0;
+ d->gtk_widget_style_get(gtkButton, "inner-border", &border, NULL);
+ if (border) {
+ r = option->rect.adjusted(border->left, border->top, -border->right, -border->bottom);
+ d->gtk_border_free(border);
+ } else {
+ r = option->rect.adjusted(1, 1, -1, -1);
+ }
+ r = visualRect(option->direction, option->rect, r);
+ }
+ break;
+ default:
+ break;
+ }
+
+ return r;
+}
+
+/*!
+ \reimp
+*/
+QRect QGtkStyle::itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const
+{
+ return QCleanlooksStyle::itemPixmapRect(r, flags, pixmap);
+}
+
+/*!
+ \reimp
+*/
+void QGtkStyle::drawItemPixmap(QPainter *painter, const QRect &rect,
+ int alignment, const QPixmap &pixmap) const
+{
+ QCleanlooksStyle::drawItemPixmap(painter, rect, alignment, pixmap);
+}
+
+/*!
+ \reimp
+*/
+QStyle::SubControl QGtkStyle::hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
+ const QPoint &pt, const QWidget *w) const
+{
+ return QCleanlooksStyle::hitTestComplexControl(cc, opt, pt, w);
+}
+
+/*!
+ \reimp
+*/
+QPixmap QGtkStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
+ const QStyleOption *opt) const
+{
+ return QCleanlooksStyle::generatedIconPixmap(iconMode, pixmap, opt);
+}
+
+/*!
+ \reimp
+*/
+void QGtkStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal,
+ bool enabled, const QString& text, QPalette::ColorRole textRole) const
+{
+ return QCleanlooksStyle::drawItemText(painter, rect, alignment, pal, enabled, text, textRole);
+}
+
+QT_END_NAMESPACE
+
+#endif //!defined(QT_NO_STYLE_QGTK)
diff --git a/src/widgets/styles/qgtkstyle.h b/src/widgets/styles/qgtkstyle.h
new file mode 100644
index 0000000000..abf8ed4fbd
--- /dev/null
+++ b/src/widgets/styles/qgtkstyle.h
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGTKSTYLE_H
+#define QGTKSTYLE_H
+
+#include <QtWidgets/QCleanlooksStyle>
+#include <QtGui/QPalette>
+#include <QtGui/QFont>
+#include <QtWidgets/QFileDialog>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#if !defined(QT_NO_STYLE_GTK)
+
+class QPainterPath;
+class QGtkStylePrivate;
+
+class Q_GUI_EXPORT QGtkStyle : public QCleanlooksStyle
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QGtkStyle)
+
+public:
+ QGtkStyle();
+ QGtkStyle(QGtkStylePrivate &dd);
+
+ ~QGtkStyle();
+
+ QPalette standardPalette() const;
+
+ void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const;
+ void drawControl(ControlElement control, const QStyleOption *option,
+ QPainter *painter, const QWidget *widget) const;
+ void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
+ QPainter *painter, const QWidget *widget) const;
+ void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
+ const QPixmap &pixmap) const;
+ void drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal,
+ bool enabled, const QString& text, QPalette::ColorRole textRole) const;
+
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = 0,
+ const QWidget *widget = 0) const;
+ int styleHint(StyleHint hint, const QStyleOption *option,
+ const QWidget *widget, QStyleHintReturn *returnData) const;
+
+ QStyle::SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
+ const QPoint &pt, const QWidget *w) const;
+
+ QRect subControlRect(ComplexControl control, const QStyleOptionComplex *option,
+ SubControl subControl, const QWidget *widget) const;
+ QRect subElementRect(SubElement sr, const QStyleOption *opt, const QWidget *w) const;
+ QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const;
+
+
+ QSize sizeFromContents(ContentsType type, const QStyleOption *option,
+ const QSize &size, const QWidget *widget) const;
+ QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *option,
+ const QWidget *widget) const;
+ QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
+ const QStyleOption *opt) const;
+
+ void polish(QWidget *widget);
+ void polish(QApplication *app);
+ void polish(QPalette &palette);
+
+ void unpolish(QWidget *widget);
+ void unpolish(QApplication *app);
+
+ static bool getGConfBool(const QString &key, bool fallback = 0);
+ static QString getGConfString(const QString &key, const QString &fallback = QString());
+
+
+protected Q_SLOTS:
+ QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option,
+ const QWidget *widget = 0) const;
+};
+
+#endif //!defined(QT_NO_STYLE_QGTK)
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif //QGTKSTYLE_H
diff --git a/src/widgets/styles/qgtkstyle_p.cpp b/src/widgets/styles/qgtkstyle_p.cpp
new file mode 100644
index 0000000000..e0ebf51c5b
--- /dev/null
+++ b/src/widgets/styles/qgtkstyle_p.cpp
@@ -0,0 +1,1146 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qgtkstyle_p.h"
+
+// This file is responsible for resolving all GTK functions we use
+// dynamically. This is done to avoid link-time dependancy on GTK
+// as well as crashes occurring due to usage of the GTK_QT engines
+//
+// Additionally we create a map of common GTK widgets that we can pass
+// to the GTK theme engine as many engines resort to querying the
+// actual widget pointers for details that are not covered by the
+// state flags
+
+#include <QtCore/qglobal.h>
+#if !defined(QT_NO_STYLE_GTK)
+
+#include <QtCore/QEvent>
+#include <QtCore/QFile>
+#include <QtCore/QStringList>
+#include <QtCore/QTextStream>
+#include <QtCore/QHash>
+#include <QtCore/QUrl>
+#include <QtCore/QLibrary>
+#include <QtCore/QDebug>
+
+#include <private/qapplication_p.h>
+#include <private/qiconloader_p.h>
+
+#include <QtWidgets/QMenu>
+#include <QtWidgets/QStyle>
+#include <QtWidgets/QApplication>
+#include <QtGui/QPixmapCache>
+#include <QtWidgets/QStatusBar>
+#include <QtWidgets/QMenuBar>
+#include <QtWidgets/QToolBar>
+#include <QtWidgets/QToolButton>
+#include <QtWidgets/QX11Info>
+
+#include <private/qt_x11_p.h>
+
+QT_BEGIN_NAMESPACE
+
+static bool displayDepth = -1;
+Q_GLOBAL_STATIC(QGtkStyleUpdateScheduler, styleScheduler)
+
+Ptr_gtk_container_forall QGtkStylePrivate::gtk_container_forall = 0;
+Ptr_gtk_init QGtkStylePrivate::gtk_init = 0;
+Ptr_gtk_style_attach QGtkStylePrivate::gtk_style_attach = 0;
+Ptr_gtk_window_new QGtkStylePrivate::gtk_window_new = 0;
+Ptr_gtk_widget_destroy QGtkStylePrivate::gtk_widget_destroy = 0;
+Ptr_gtk_widget_realize QGtkStylePrivate::gtk_widget_realize = 0;
+Ptr_gtk_widget_set_default_direction QGtkStylePrivate::gtk_widget_set_default_direction = 0;
+Ptr_gtk_widget_modify_color QGtkStylePrivate::gtk_widget_modify_fg = 0;
+Ptr_gtk_widget_modify_color QGtkStylePrivate::gtk_widget_modify_bg = 0;
+Ptr_gtk_arrow_new QGtkStylePrivate::gtk_arrow_new = 0;
+Ptr_gtk_menu_item_new_with_label QGtkStylePrivate::gtk_menu_item_new_with_label = 0;
+Ptr_gtk_check_menu_item_new_with_label QGtkStylePrivate::gtk_check_menu_item_new_with_label = 0;
+Ptr_gtk_menu_bar_new QGtkStylePrivate::gtk_menu_bar_new = 0;
+Ptr_gtk_menu_new QGtkStylePrivate::gtk_menu_new = 0;
+Ptr_gtk_button_new QGtkStylePrivate::gtk_button_new = 0;
+Ptr_gtk_tool_button_new QGtkStylePrivate::gtk_tool_button_new = 0;
+Ptr_gtk_hbutton_box_new QGtkStylePrivate::gtk_hbutton_box_new = 0;
+Ptr_gtk_check_button_new QGtkStylePrivate::gtk_check_button_new = 0;
+Ptr_gtk_radio_button_new QGtkStylePrivate::gtk_radio_button_new = 0;
+Ptr_gtk_spin_button_new QGtkStylePrivate::gtk_spin_button_new = 0;
+Ptr_gtk_frame_new QGtkStylePrivate::gtk_frame_new = 0;
+Ptr_gtk_expander_new QGtkStylePrivate::gtk_expander_new = 0;
+Ptr_gtk_statusbar_new QGtkStylePrivate::gtk_statusbar_new = 0;
+Ptr_gtk_entry_new QGtkStylePrivate::gtk_entry_new = 0;
+Ptr_gtk_hscale_new QGtkStylePrivate::gtk_hscale_new = 0;
+Ptr_gtk_vscale_new QGtkStylePrivate::gtk_vscale_new = 0;
+Ptr_gtk_hscrollbar_new QGtkStylePrivate::gtk_hscrollbar_new = 0;
+Ptr_gtk_vscrollbar_new QGtkStylePrivate::gtk_vscrollbar_new = 0;
+Ptr_gtk_scrolled_window_new QGtkStylePrivate::gtk_scrolled_window_new = 0;
+Ptr_gtk_notebook_new QGtkStylePrivate::gtk_notebook_new = 0;
+Ptr_gtk_toolbar_new QGtkStylePrivate::gtk_toolbar_new = 0;
+Ptr_gtk_toolbar_insert QGtkStylePrivate::gtk_toolbar_insert = 0;
+Ptr_gtk_separator_tool_item_new QGtkStylePrivate::gtk_separator_tool_item_new = 0;
+Ptr_gtk_tree_view_new QGtkStylePrivate::gtk_tree_view_new = 0;
+Ptr_gtk_combo_box_new QGtkStylePrivate::gtk_combo_box_new = 0;
+Ptr_gtk_combo_box_entry_new QGtkStylePrivate::gtk_combo_box_entry_new = 0;
+Ptr_gtk_progress_bar_new QGtkStylePrivate::gtk_progress_bar_new = 0;
+Ptr_gtk_container_add QGtkStylePrivate::gtk_container_add = 0;
+Ptr_gtk_menu_shell_append QGtkStylePrivate::gtk_menu_shell_append = 0;
+Ptr_gtk_progress_configure QGtkStylePrivate::gtk_progress_configure = 0;
+Ptr_gtk_range_get_adjustment QGtkStylePrivate::gtk_range_get_adjustment = 0;
+Ptr_gtk_range_set_adjustment QGtkStylePrivate::gtk_range_set_adjustment = 0;
+Ptr_gtk_range_set_inverted QGtkStylePrivate::gtk_range_set_inverted = 0;
+Ptr_gtk_icon_factory_lookup_default QGtkStylePrivate::gtk_icon_factory_lookup_default = 0;
+Ptr_gtk_icon_theme_get_default QGtkStylePrivate::gtk_icon_theme_get_default = 0;
+Ptr_gtk_widget_style_get QGtkStylePrivate::gtk_widget_style_get = 0;
+Ptr_gtk_icon_set_render_icon QGtkStylePrivate::gtk_icon_set_render_icon = 0;
+Ptr_gtk_fixed_new QGtkStylePrivate::gtk_fixed_new = 0;
+Ptr_gtk_tree_view_column_new QGtkStylePrivate::gtk_tree_view_column_new = 0;
+Ptr_gtk_tree_view_get_column QGtkStylePrivate::gtk_tree_view_get_column = 0;
+Ptr_gtk_tree_view_append_column QGtkStylePrivate::gtk_tree_view_append_column = 0;
+Ptr_gtk_paint_check QGtkStylePrivate::gtk_paint_check = 0;
+Ptr_gtk_paint_box QGtkStylePrivate::gtk_paint_box = 0;
+Ptr_gtk_paint_box_gap QGtkStylePrivate::gtk_paint_box_gap = 0;
+Ptr_gtk_paint_flat_box QGtkStylePrivate::gtk_paint_flat_box = 0;
+Ptr_gtk_paint_option QGtkStylePrivate::gtk_paint_option = 0;
+Ptr_gtk_paint_extension QGtkStylePrivate::gtk_paint_extension = 0;
+Ptr_gtk_paint_slider QGtkStylePrivate::gtk_paint_slider = 0;
+Ptr_gtk_paint_shadow QGtkStylePrivate::gtk_paint_shadow = 0;
+Ptr_gtk_paint_resize_grip QGtkStylePrivate::gtk_paint_resize_grip = 0;
+Ptr_gtk_paint_focus QGtkStylePrivate::gtk_paint_focus = 0;
+Ptr_gtk_paint_arrow QGtkStylePrivate::gtk_paint_arrow = 0;
+Ptr_gtk_paint_handle QGtkStylePrivate::gtk_paint_handle = 0;
+Ptr_gtk_paint_expander QGtkStylePrivate::gtk_paint_expander = 0;
+Ptr_gtk_adjustment_configure QGtkStylePrivate::gtk_adjustment_configure = 0;
+Ptr_gtk_adjustment_new QGtkStylePrivate::gtk_adjustment_new = 0;
+Ptr_gtk_paint_hline QGtkStylePrivate::gtk_paint_hline = 0;
+Ptr_gtk_paint_vline QGtkStylePrivate::gtk_paint_vline = 0;
+Ptr_gtk_menu_item_set_submenu QGtkStylePrivate::gtk_menu_item_set_submenu = 0;
+Ptr_gtk_settings_get_default QGtkStylePrivate::gtk_settings_get_default = 0;
+Ptr_gtk_separator_menu_item_new QGtkStylePrivate::gtk_separator_menu_item_new = 0;
+Ptr_gtk_widget_size_allocate QGtkStylePrivate::gtk_widget_size_allocate = 0;
+Ptr_gtk_widget_size_request QGtkStylePrivate::gtk_widget_size_request = 0;
+Ptr_gtk_widget_set_direction QGtkStylePrivate::gtk_widget_set_direction = 0;
+Ptr_gtk_widget_path QGtkStylePrivate::gtk_widget_path = 0;
+Ptr_gtk_container_get_type QGtkStylePrivate::gtk_container_get_type = 0;
+Ptr_gtk_window_get_type QGtkStylePrivate::gtk_window_get_type = 0;
+Ptr_gtk_widget_get_type QGtkStylePrivate::gtk_widget_get_type = 0;
+Ptr_gtk_rc_get_style_by_paths QGtkStylePrivate::gtk_rc_get_style_by_paths = 0;
+Ptr_gtk_check_version QGtkStylePrivate::gtk_check_version = 0;
+Ptr_gtk_border_free QGtkStylePrivate::gtk_border_free = 0;
+Ptr_pango_font_description_get_size QGtkStylePrivate::pango_font_description_get_size = 0;
+Ptr_pango_font_description_get_weight QGtkStylePrivate::pango_font_description_get_weight = 0;
+Ptr_pango_font_description_get_family QGtkStylePrivate::pango_font_description_get_family = 0;
+Ptr_pango_font_description_get_style QGtkStylePrivate::pango_font_description_get_style = 0;
+
+Ptr_gtk_file_filter_new QGtkStylePrivate::gtk_file_filter_new = 0;
+Ptr_gtk_file_filter_set_name QGtkStylePrivate::gtk_file_filter_set_name = 0;
+Ptr_gtk_file_filter_add_pattern QGtkStylePrivate::gtk_file_filter_add_pattern = 0;
+Ptr_gtk_file_chooser_add_filter QGtkStylePrivate::gtk_file_chooser_add_filter = 0;
+Ptr_gtk_file_chooser_set_filter QGtkStylePrivate::gtk_file_chooser_set_filter = 0;
+Ptr_gtk_file_chooser_get_filter QGtkStylePrivate::gtk_file_chooser_get_filter = 0;
+Ptr_gtk_file_chooser_dialog_new QGtkStylePrivate::gtk_file_chooser_dialog_new = 0;
+Ptr_gtk_file_chooser_set_current_folder QGtkStylePrivate::gtk_file_chooser_set_current_folder = 0;
+Ptr_gtk_file_chooser_get_filename QGtkStylePrivate::gtk_file_chooser_get_filename = 0;
+Ptr_gtk_file_chooser_get_filenames QGtkStylePrivate::gtk_file_chooser_get_filenames = 0;
+Ptr_gtk_file_chooser_set_current_name QGtkStylePrivate::gtk_file_chooser_set_current_name = 0;
+Ptr_gtk_dialog_run QGtkStylePrivate::gtk_dialog_run = 0;
+Ptr_gtk_file_chooser_set_filename QGtkStylePrivate::gtk_file_chooser_set_filename = 0;
+
+Ptr_gdk_pixbuf_get_pixels QGtkStylePrivate::gdk_pixbuf_get_pixels = 0;
+Ptr_gdk_pixbuf_get_width QGtkStylePrivate::gdk_pixbuf_get_width = 0;
+Ptr_gdk_pixbuf_get_height QGtkStylePrivate::gdk_pixbuf_get_height = 0;
+Ptr_gdk_pixmap_new QGtkStylePrivate::gdk_pixmap_new = 0;
+Ptr_gdk_pixbuf_new QGtkStylePrivate::gdk_pixbuf_new = 0;
+Ptr_gdk_pixbuf_get_from_drawable QGtkStylePrivate::gdk_pixbuf_get_from_drawable = 0;
+Ptr_gdk_draw_rectangle QGtkStylePrivate::gdk_draw_rectangle = 0;
+Ptr_gdk_pixbuf_unref QGtkStylePrivate::gdk_pixbuf_unref = 0;
+Ptr_gdk_drawable_unref QGtkStylePrivate::gdk_drawable_unref = 0;
+Ptr_gdk_drawable_get_depth QGtkStylePrivate::gdk_drawable_get_depth = 0;
+Ptr_gdk_color_free QGtkStylePrivate::gdk_color_free = 0;
+Ptr_gdk_x11_window_set_user_time QGtkStylePrivate::gdk_x11_window_set_user_time = 0;
+Ptr_gdk_x11_drawable_get_xid QGtkStylePrivate::gdk_x11_drawable_get_xid = 0;
+Ptr_gdk_x11_drawable_get_xdisplay QGtkStylePrivate::gdk_x11_drawable_get_xdisplay = 0;
+
+Ptr_gconf_client_get_default QGtkStylePrivate::gconf_client_get_default = 0;
+Ptr_gconf_client_get_string QGtkStylePrivate::gconf_client_get_string = 0;
+Ptr_gconf_client_get_bool QGtkStylePrivate::gconf_client_get_bool = 0;
+
+Ptr_gnome_icon_lookup_sync QGtkStylePrivate::gnome_icon_lookup_sync = 0;
+Ptr_gnome_vfs_init QGtkStylePrivate::gnome_vfs_init = 0;
+
+typedef int (*x11ErrorHandler)(Display*, XErrorEvent*);
+
+QT_END_NAMESPACE
+
+Q_DECLARE_METATYPE(QGtkStylePrivate*);
+
+QT_BEGIN_NAMESPACE
+
+static void gtkStyleSetCallback(GtkWidget*)
+{
+ qRegisterMetaType<QGtkStylePrivate *>();
+
+ // We have to let this function return and complete the event
+ // loop to ensure that all gtk widgets have been styled before
+ // updating
+ QMetaObject::invokeMethod(styleScheduler(), "updateTheme", Qt::QueuedConnection);
+}
+
+static void update_toolbar_style(GtkWidget *gtkToolBar, GParamSpec *, gpointer)
+{
+ GtkToolbarStyle toolbar_style = GTK_TOOLBAR_ICONS;
+ g_object_get(gtkToolBar, "toolbar-style", &toolbar_style, NULL);
+ QWidgetList widgets = QApplication::allWidgets();
+ for (int i = 0; i < widgets.size(); ++i) {
+ QWidget *widget = widgets.at(i);
+ if (qobject_cast<QToolButton*>(widget)) {
+ QEvent event(QEvent::StyleChange);
+ QApplication::sendEvent(widget, &event);
+ }
+ }
+}
+
+static QHashableLatin1Literal classPath(GtkWidget *widget)
+{
+ char *class_path;
+ QGtkStylePrivate::gtk_widget_path (widget, NULL, &class_path, NULL);
+
+ char *copy = class_path;
+ if (strncmp(copy, "GtkWindow.", 10) == 0)
+ copy += 10;
+ if (strncmp(copy, "GtkFixed.", 9) == 0)
+ copy += 9;
+
+ copy = strdup(copy);
+
+ g_free(class_path);
+
+ return QHashableLatin1Literal::fromData(copy);
+}
+
+
+
+bool QGtkStyleFilter::eventFilter(QObject *obj, QEvent *e)
+{
+ if (e->type() == QEvent::ApplicationPaletteChange) {
+ // Only do this the first time since this will also
+ // generate applicationPaletteChange events
+ if (!qt_app_palettes_hash() || qt_app_palettes_hash()->isEmpty()) {
+ stylePrivate->applyCustomPaletteHash();
+ }
+ }
+ return QObject::eventFilter(obj, e);
+}
+
+QList<QGtkStylePrivate *> QGtkStylePrivate::instances;
+QGtkStylePrivate::WidgetMap *QGtkStylePrivate::widgetMap = 0;
+
+QGtkStylePrivate::QGtkStylePrivate()
+ : QCleanlooksStylePrivate()
+ , filter(this)
+{
+ instances.append(this);
+}
+
+QGtkStylePrivate::~QGtkStylePrivate()
+{
+ instances.removeOne(this);
+}
+
+void QGtkStylePrivate::init()
+{
+ resolveGtk();
+ initGtkWidgets();
+}
+
+GtkWidget* QGtkStylePrivate::gtkWidget(const QHashableLatin1Literal &path)
+{
+ GtkWidget *widget = gtkWidgetMap()->value(path);
+ if (!widget) {
+ // Theme might have rearranged widget internals
+ widget = gtkWidgetMap()->value(path);
+ }
+ return widget;
+}
+
+GtkStyle* QGtkStylePrivate::gtkStyle(const QHashableLatin1Literal &path)
+{
+ if (GtkWidget *w = gtkWidgetMap()->value(path))
+ return w->style;
+ return 0;
+}
+
+/*! \internal
+ * Get references to gtk functions after we dynamically load the library.
+ */
+void QGtkStylePrivate::resolveGtk() const
+{
+ // enforce the "0" suffix, so we'll open libgtk-x11-2.0.so.0
+ QLibrary libgtk(QLS("gtk-x11-2.0"), 0, 0);
+
+ gtk_init = (Ptr_gtk_init)libgtk.resolve("gtk_init");
+ gtk_window_new = (Ptr_gtk_window_new)libgtk.resolve("gtk_window_new");
+ gtk_style_attach = (Ptr_gtk_style_attach)libgtk.resolve("gtk_style_attach");
+ gtk_widget_destroy = (Ptr_gtk_widget_destroy)libgtk.resolve("gtk_widget_destroy");
+ gtk_widget_realize = (Ptr_gtk_widget_realize)libgtk.resolve("gtk_widget_realize");
+
+ gtk_file_chooser_set_current_folder = (Ptr_gtk_file_chooser_set_current_folder)libgtk.resolve("gtk_file_chooser_set_current_folder");
+ gtk_file_filter_new = (Ptr_gtk_file_filter_new)libgtk.resolve("gtk_file_filter_new");
+ gtk_file_filter_set_name = (Ptr_gtk_file_filter_set_name)libgtk.resolve("gtk_file_filter_set_name");
+ gtk_file_filter_add_pattern = (Ptr_gtk_file_filter_add_pattern)libgtk.resolve("gtk_file_filter_add_pattern");
+ gtk_file_chooser_add_filter = (Ptr_gtk_file_chooser_add_filter)libgtk.resolve("gtk_file_chooser_add_filter");
+ gtk_file_chooser_set_filter = (Ptr_gtk_file_chooser_set_filter)libgtk.resolve("gtk_file_chooser_set_filter");
+ gtk_file_chooser_get_filter = (Ptr_gtk_file_chooser_get_filter)libgtk.resolve("gtk_file_chooser_get_filter");
+ gtk_file_chooser_dialog_new = (Ptr_gtk_file_chooser_dialog_new)libgtk.resolve("gtk_file_chooser_dialog_new");
+ gtk_file_chooser_set_current_folder = (Ptr_gtk_file_chooser_set_current_folder)libgtk.resolve("gtk_file_chooser_set_current_folder");
+ gtk_file_chooser_get_filename = (Ptr_gtk_file_chooser_get_filename)libgtk.resolve("gtk_file_chooser_get_filename");
+ gtk_file_chooser_get_filenames = (Ptr_gtk_file_chooser_get_filenames)libgtk.resolve("gtk_file_chooser_get_filenames");
+ gtk_file_chooser_set_current_name = (Ptr_gtk_file_chooser_set_current_name)libgtk.resolve("gtk_file_chooser_set_current_name");
+ gtk_dialog_run = (Ptr_gtk_dialog_run)libgtk.resolve("gtk_dialog_run");
+ gtk_file_chooser_set_filename = (Ptr_gtk_file_chooser_set_filename)libgtk.resolve("gtk_file_chooser_set_filename");
+
+ gdk_pixbuf_get_pixels = (Ptr_gdk_pixbuf_get_pixels)libgtk.resolve("gdk_pixbuf_get_pixels");
+ gdk_pixbuf_get_width = (Ptr_gdk_pixbuf_get_width)libgtk.resolve("gdk_pixbuf_get_width");
+ gdk_pixbuf_get_height = (Ptr_gdk_pixbuf_get_height)libgtk.resolve("gdk_pixbuf_get_height");
+ gdk_pixmap_new = (Ptr_gdk_pixmap_new)libgtk.resolve("gdk_pixmap_new");
+ gdk_pixbuf_new = (Ptr_gdk_pixbuf_new)libgtk.resolve("gdk_pixbuf_new");
+ gdk_pixbuf_get_from_drawable = (Ptr_gdk_pixbuf_get_from_drawable)libgtk.resolve("gdk_pixbuf_get_from_drawable");
+ gdk_draw_rectangle = (Ptr_gdk_draw_rectangle)libgtk.resolve("gdk_draw_rectangle");
+ gdk_pixbuf_unref = (Ptr_gdk_pixbuf_unref)libgtk.resolve("gdk_pixbuf_unref");
+ gdk_drawable_unref = (Ptr_gdk_drawable_unref)libgtk.resolve("gdk_drawable_unref");
+ gdk_drawable_get_depth = (Ptr_gdk_drawable_get_depth)libgtk.resolve("gdk_drawable_get_depth");
+ gdk_color_free = (Ptr_gdk_color_free)libgtk.resolve("gdk_color_free");
+ gdk_x11_window_set_user_time = (Ptr_gdk_x11_window_set_user_time)libgtk.resolve("gdk_x11_window_set_user_time");
+ gdk_x11_drawable_get_xid = (Ptr_gdk_x11_drawable_get_xid)libgtk.resolve("gdk_x11_drawable_get_xid");
+ gdk_x11_drawable_get_xdisplay = (Ptr_gdk_x11_drawable_get_xdisplay)libgtk.resolve("gdk_x11_drawable_get_xdisplay");
+
+ gtk_widget_set_default_direction = (Ptr_gtk_widget_set_default_direction)libgtk.resolve("gtk_widget_set_default_direction");
+ gtk_widget_modify_fg = (Ptr_gtk_widget_modify_color)libgtk.resolve("gtk_widget_modify_fg");
+ gtk_widget_modify_bg = (Ptr_gtk_widget_modify_color)libgtk.resolve("gtk_widget_modify_bg");
+ gtk_arrow_new = (Ptr_gtk_arrow_new)libgtk.resolve("gtk_arrow_new");
+ gtk_menu_item_new_with_label = (Ptr_gtk_menu_item_new_with_label)libgtk.resolve("gtk_menu_item_new_with_label");
+ gtk_check_menu_item_new_with_label = (Ptr_gtk_check_menu_item_new_with_label)libgtk.resolve("gtk_check_menu_item_new_with_label");
+ gtk_menu_bar_new = (Ptr_gtk_menu_bar_new)libgtk.resolve("gtk_menu_bar_new");
+ gtk_menu_new = (Ptr_gtk_menu_new)libgtk.resolve("gtk_menu_new");
+ gtk_toolbar_new = (Ptr_gtk_toolbar_new)libgtk.resolve("gtk_toolbar_new");
+ gtk_separator_tool_item_new = (Ptr_gtk_separator_tool_item_new)libgtk.resolve("gtk_separator_tool_item_new");
+ gtk_toolbar_insert = (Ptr_gtk_toolbar_insert)libgtk.resolve("gtk_toolbar_insert");
+ gtk_button_new = (Ptr_gtk_button_new)libgtk.resolve("gtk_button_new");
+ gtk_tool_button_new = (Ptr_gtk_tool_button_new)libgtk.resolve("gtk_tool_button_new");
+ gtk_hbutton_box_new = (Ptr_gtk_hbutton_box_new)libgtk.resolve("gtk_hbutton_box_new");
+ gtk_check_button_new = (Ptr_gtk_check_button_new)libgtk.resolve("gtk_check_button_new");
+ gtk_radio_button_new = (Ptr_gtk_radio_button_new)libgtk.resolve("gtk_radio_button_new");
+ gtk_notebook_new = (Ptr_gtk_notebook_new)libgtk.resolve("gtk_notebook_new");
+ gtk_progress_bar_new = (Ptr_gtk_progress_bar_new)libgtk.resolve("gtk_progress_bar_new");
+ gtk_spin_button_new = (Ptr_gtk_spin_button_new)libgtk.resolve("gtk_spin_button_new");
+ gtk_hscale_new = (Ptr_gtk_hscale_new)libgtk.resolve("gtk_hscale_new");
+ gtk_vscale_new = (Ptr_gtk_vscale_new)libgtk.resolve("gtk_vscale_new");
+ gtk_hscrollbar_new = (Ptr_gtk_hscrollbar_new)libgtk.resolve("gtk_hscrollbar_new");
+ gtk_vscrollbar_new = (Ptr_gtk_vscrollbar_new)libgtk.resolve("gtk_vscrollbar_new");
+ gtk_scrolled_window_new = (Ptr_gtk_scrolled_window_new)libgtk.resolve("gtk_scrolled_window_new");
+ gtk_menu_shell_append = (Ptr_gtk_menu_shell_append)libgtk.resolve("gtk_menu_shell_append");
+ gtk_entry_new = (Ptr_gtk_entry_new)libgtk.resolve("gtk_entry_new");
+ gtk_tree_view_new = (Ptr_gtk_tree_view_new)libgtk.resolve("gtk_tree_view_new");
+ gtk_combo_box_new = (Ptr_gtk_combo_box_new)libgtk.resolve("gtk_combo_box_new");
+ gtk_progress_configure = (Ptr_gtk_progress_configure)libgtk.resolve("gtk_progress_configure");
+ gtk_range_get_adjustment = (Ptr_gtk_range_get_adjustment)libgtk.resolve("gtk_range_get_adjustment");
+ gtk_range_set_adjustment = (Ptr_gtk_range_set_adjustment)libgtk.resolve("gtk_range_set_adjustment");
+ gtk_range_set_inverted = (Ptr_gtk_range_set_inverted)libgtk.resolve("gtk_range_set_inverted");
+ gtk_container_add = (Ptr_gtk_container_add)libgtk.resolve("gtk_container_add");
+ gtk_icon_factory_lookup_default = (Ptr_gtk_icon_factory_lookup_default)libgtk.resolve("gtk_icon_factory_lookup_default");
+ gtk_icon_theme_get_default = (Ptr_gtk_icon_theme_get_default)libgtk.resolve("gtk_icon_theme_get_default");
+ gtk_widget_style_get = (Ptr_gtk_widget_style_get)libgtk.resolve("gtk_widget_style_get");
+ gtk_icon_set_render_icon = (Ptr_gtk_icon_set_render_icon)libgtk.resolve("gtk_icon_set_render_icon");
+ gtk_fixed_new = (Ptr_gtk_fixed_new)libgtk.resolve("gtk_fixed_new");
+ gtk_tree_view_column_new = (Ptr_gtk_tree_view_column_new)libgtk.resolve("gtk_tree_view_column_new");
+ gtk_tree_view_append_column= (Ptr_gtk_tree_view_append_column )libgtk.resolve("gtk_tree_view_append_column");
+ gtk_tree_view_get_column = (Ptr_gtk_tree_view_get_column )libgtk.resolve("gtk_tree_view_get_column");
+ gtk_paint_check = (Ptr_gtk_paint_check)libgtk.resolve("gtk_paint_check");
+ gtk_paint_box = (Ptr_gtk_paint_box)libgtk.resolve("gtk_paint_box");
+ gtk_paint_flat_box = (Ptr_gtk_paint_flat_box)libgtk.resolve("gtk_paint_flat_box");
+ gtk_paint_check = (Ptr_gtk_paint_check)libgtk.resolve("gtk_paint_check");
+ gtk_paint_box = (Ptr_gtk_paint_box)libgtk.resolve("gtk_paint_box");
+ gtk_paint_resize_grip = (Ptr_gtk_paint_resize_grip)libgtk.resolve("gtk_paint_resize_grip");
+ gtk_paint_focus = (Ptr_gtk_paint_focus)libgtk.resolve("gtk_paint_focus");
+ gtk_paint_shadow = (Ptr_gtk_paint_shadow)libgtk.resolve("gtk_paint_shadow");
+ gtk_paint_slider = (Ptr_gtk_paint_slider)libgtk.resolve("gtk_paint_slider");
+ gtk_paint_expander = (Ptr_gtk_paint_expander)libgtk.resolve("gtk_paint_expander");
+ gtk_paint_handle = (Ptr_gtk_paint_handle)libgtk.resolve("gtk_paint_handle");
+ gtk_paint_option = (Ptr_gtk_paint_option)libgtk.resolve("gtk_paint_option");
+ gtk_paint_arrow = (Ptr_gtk_paint_arrow)libgtk.resolve("gtk_paint_arrow");
+ gtk_paint_box_gap = (Ptr_gtk_paint_box_gap)libgtk.resolve("gtk_paint_box_gap");
+ gtk_paint_extension = (Ptr_gtk_paint_extension)libgtk.resolve("gtk_paint_extension");
+ gtk_paint_hline = (Ptr_gtk_paint_hline)libgtk.resolve("gtk_paint_hline");
+ gtk_paint_vline = (Ptr_gtk_paint_vline)libgtk.resolve("gtk_paint_vline");
+ gtk_adjustment_configure = (Ptr_gtk_adjustment_configure)libgtk.resolve("gtk_adjustment_configure");
+ gtk_adjustment_new = (Ptr_gtk_adjustment_new)libgtk.resolve("gtk_adjustment_new");
+ gtk_menu_item_set_submenu = (Ptr_gtk_menu_item_set_submenu)libgtk.resolve("gtk_menu_item_set_submenu");
+ gtk_settings_get_default = (Ptr_gtk_settings_get_default)libgtk.resolve("gtk_settings_get_default");
+ gtk_separator_menu_item_new = (Ptr_gtk_separator_menu_item_new)libgtk.resolve("gtk_separator_menu_item_new");
+ gtk_frame_new = (Ptr_gtk_frame_new)libgtk.resolve("gtk_frame_new");
+ gtk_expander_new = (Ptr_gtk_expander_new)libgtk.resolve("gtk_expander_new");
+ gtk_statusbar_new = (Ptr_gtk_statusbar_new)libgtk.resolve("gtk_statusbar_new");
+ gtk_combo_box_entry_new = (Ptr_gtk_combo_box_entry_new)libgtk.resolve("gtk_combo_box_entry_new");
+ gtk_container_forall = (Ptr_gtk_container_forall)libgtk.resolve("gtk_container_forall");
+ gtk_widget_size_allocate =(Ptr_gtk_widget_size_allocate)libgtk.resolve("gtk_widget_size_allocate");
+ gtk_widget_size_request =(Ptr_gtk_widget_size_request)libgtk.resolve("gtk_widget_size_request");
+ gtk_widget_set_direction =(Ptr_gtk_widget_set_direction)libgtk.resolve("gtk_widget_set_direction");
+ gtk_widget_path =(Ptr_gtk_widget_path)libgtk.resolve("gtk_widget_path");
+ gtk_container_get_type =(Ptr_gtk_container_get_type)libgtk.resolve("gtk_container_get_type");
+ gtk_window_get_type =(Ptr_gtk_window_get_type)libgtk.resolve("gtk_window_get_type");
+ gtk_widget_get_type =(Ptr_gtk_widget_get_type)libgtk.resolve("gtk_widget_get_type");
+
+ gtk_rc_get_style_by_paths =(Ptr_gtk_rc_get_style_by_paths)libgtk.resolve("gtk_rc_get_style_by_paths");
+ gtk_check_version =(Ptr_gtk_check_version)libgtk.resolve("gtk_check_version");
+ gtk_border_free =(Ptr_gtk_border_free)libgtk.resolve("gtk_border_free");
+ pango_font_description_get_size = (Ptr_pango_font_description_get_size)libgtk.resolve("pango_font_description_get_size");
+ pango_font_description_get_weight = (Ptr_pango_font_description_get_weight)libgtk.resolve("pango_font_description_get_weight");
+ pango_font_description_get_family = (Ptr_pango_font_description_get_family)libgtk.resolve("pango_font_description_get_family");
+ pango_font_description_get_style = (Ptr_pango_font_description_get_style)libgtk.resolve("pango_font_description_get_style");
+
+ gnome_icon_lookup_sync = (Ptr_gnome_icon_lookup_sync)QLibrary::resolve(QLS("gnomeui-2"), 0, "gnome_icon_lookup_sync");
+ gnome_vfs_init= (Ptr_gnome_vfs_init)QLibrary::resolve(QLS("gnomevfs-2"), 0, "gnome_vfs_init");
+}
+
+/* \internal
+ * Initializes a number of gtk menu widgets.
+ * The widgets are cached.
+ */
+void QGtkStylePrivate::initGtkMenu() const
+{
+ // Create menubar
+ GtkWidget *gtkMenuBar = QGtkStylePrivate::gtk_menu_bar_new();
+ setupGtkWidget(gtkMenuBar);
+
+ GtkWidget *gtkMenuBarItem = QGtkStylePrivate::gtk_menu_item_new_with_label("X");
+ gtk_menu_shell_append((GtkMenuShell*)(gtkMenuBar), gtkMenuBarItem);
+ gtk_widget_realize(gtkMenuBarItem);
+
+ // Create menu
+ GtkWidget *gtkMenu = QGtkStylePrivate::gtk_menu_new();
+ gtk_menu_item_set_submenu((GtkMenuItem*)(gtkMenuBarItem), gtkMenu);
+ gtk_widget_realize(gtkMenu);
+
+ GtkWidget *gtkMenuItem = QGtkStylePrivate::gtk_menu_item_new_with_label("X");
+ gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkMenuItem);
+ gtk_widget_realize(gtkMenuItem);
+
+ GtkWidget *gtkCheckMenuItem = QGtkStylePrivate::gtk_check_menu_item_new_with_label("X");
+ gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkCheckMenuItem);
+ gtk_widget_realize(gtkCheckMenuItem);
+
+ GtkWidget *gtkMenuSeparator = QGtkStylePrivate::gtk_separator_menu_item_new();
+ gtk_menu_shell_append((GtkMenuShell*)gtkMenu, gtkMenuSeparator);
+
+ addAllSubWidgets(gtkMenuBar);
+ addAllSubWidgets(gtkMenu);
+}
+
+
+void QGtkStylePrivate::initGtkTreeview() const
+{
+ GtkWidget *gtkTreeView = gtk_tree_view_new();
+ gtk_tree_view_append_column((GtkTreeView*)gtkTreeView, gtk_tree_view_column_new());
+ gtk_tree_view_append_column((GtkTreeView*)gtkTreeView, gtk_tree_view_column_new());
+ gtk_tree_view_append_column((GtkTreeView*)gtkTreeView, gtk_tree_view_column_new());
+ addWidget(gtkTreeView);
+}
+
+
+/* \internal
+ * Initializes a number of gtk widgets that we can later on use to determine some of our styles.
+ * The widgets are cached.
+ */
+void QGtkStylePrivate::initGtkWidgets() const
+{
+ // From gtkmain.c
+ uid_t ruid = getuid ();
+ uid_t rgid = getgid ();
+ uid_t euid = geteuid ();
+ uid_t egid = getegid ();
+ if (ruid != euid || rgid != egid) {
+ qWarning("\nThis process is currently running setuid or setgid.\nGTK+ does not allow this "
+ "therefore Qt cannot use the GTK+ integration.\nTry launching your app using \'gksudo\', "
+ "\'kdesudo\' or a similar tool.\n\n"
+ "See http://www.gtk.org/setuid.html for more information.\n");
+ return;
+ }
+
+ static QString themeName;
+ if (!gtkWidgetMap()->contains("GtkWindow") && themeName.isEmpty()) {
+ themeName = getThemeName();
+
+ if (themeName.isEmpty()) {
+ qWarning("QGtkStyle was unable to detect the current GTK+ theme.");
+ return;
+ } else if (themeName == QLS("Qt") || themeName == QLS("Qt4")) {
+ // Due to namespace conflicts with Qt3 and obvious recursion with Qt4,
+ // we cannot support the GTK_Qt Gtk engine
+ qWarning("QGtkStyle cannot be used together with the GTK_Qt engine.");
+ return;
+ }
+ }
+
+ if (QGtkStylePrivate::gtk_init) {
+ // Gtk will set the Qt error handler so we have to reset it afterwards
+ x11ErrorHandler qt_x_errhandler = XSetErrorHandler(0);
+ QGtkStylePrivate::gtk_init (NULL, NULL);
+ XSetErrorHandler(qt_x_errhandler);
+
+ // make a window
+ GtkWidget* gtkWindow = QGtkStylePrivate::gtk_window_new(GTK_WINDOW_POPUP);
+ QGtkStylePrivate::gtk_widget_realize(gtkWindow);
+ if (displayDepth == -1)
+ displayDepth = QGtkStylePrivate::gdk_drawable_get_depth(gtkWindow->window);
+ QHashableLatin1Literal widgetPath = QHashableLatin1Literal::fromData(strdup("GtkWindow"));
+ removeWidgetFromMap(widgetPath);
+ gtkWidgetMap()->insert(widgetPath, gtkWindow);
+
+
+ // Make all other widgets. respect the text direction
+ if (qApp->layoutDirection() == Qt::RightToLeft)
+ QGtkStylePrivate::gtk_widget_set_default_direction(GTK_TEXT_DIR_RTL);
+
+ if (!gtkWidgetMap()->contains("GtkButton")) {
+ GtkWidget *gtkButton = QGtkStylePrivate::gtk_button_new();
+ addWidget(gtkButton);
+ g_signal_connect(gtkButton, "style-set", G_CALLBACK(gtkStyleSetCallback), 0);
+ addWidget(QGtkStylePrivate::gtk_tool_button_new(NULL, "Qt"));
+ addWidget(QGtkStylePrivate::gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_NONE));
+ addWidget(QGtkStylePrivate::gtk_hbutton_box_new());
+ addWidget(QGtkStylePrivate::gtk_check_button_new());
+ addWidget(QGtkStylePrivate::gtk_radio_button_new(NULL));
+ addWidget(QGtkStylePrivate::gtk_combo_box_new());
+ addWidget(QGtkStylePrivate::gtk_combo_box_entry_new());
+ addWidget(QGtkStylePrivate::gtk_entry_new());
+ addWidget(QGtkStylePrivate::gtk_frame_new(NULL));
+ addWidget(QGtkStylePrivate::gtk_expander_new(""));
+ addWidget(QGtkStylePrivate::gtk_statusbar_new());
+ addWidget(QGtkStylePrivate::gtk_hscale_new((GtkAdjustment*)(QGtkStylePrivate::gtk_adjustment_new(1, 0, 1, 0, 0, 0))));
+ addWidget(QGtkStylePrivate::gtk_hscrollbar_new(NULL));
+ addWidget(QGtkStylePrivate::gtk_scrolled_window_new(NULL, NULL));
+
+ initGtkMenu();
+ addWidget(QGtkStylePrivate::gtk_notebook_new());
+ addWidget(QGtkStylePrivate::gtk_progress_bar_new());
+ addWidget(QGtkStylePrivate::gtk_spin_button_new((GtkAdjustment*)
+ (QGtkStylePrivate::gtk_adjustment_new(1, 0, 1, 0, 0, 0)), 0.1, 3));
+ GtkWidget *toolbar = gtk_toolbar_new();
+ g_signal_connect (toolbar, "notify::toolbar-style", G_CALLBACK (update_toolbar_style), toolbar);
+ gtk_toolbar_insert((GtkToolbar*)toolbar, gtk_separator_tool_item_new(), -1);
+ addWidget(toolbar);
+ initGtkTreeview();
+ addWidget(gtk_vscale_new((GtkAdjustment*)(QGtkStylePrivate::gtk_adjustment_new(1, 0, 1, 0, 0, 0))));
+ addWidget(gtk_vscrollbar_new(NULL));
+ }
+ else // Rebuild map
+ {
+ // When styles change subwidgets can get rearranged
+ // as with the combo box. We need to update the widget map
+ // to reflect this;
+ QHash<QHashableLatin1Literal, GtkWidget*> oldMap = *gtkWidgetMap();
+ gtkWidgetMap()->clear();
+ QHashIterator<QHashableLatin1Literal, GtkWidget*> it(oldMap);
+ while (it.hasNext()) {
+ it.next();
+ if (!strchr(it.key().data(), '.')) {
+ addAllSubWidgets(it.value());
+ }
+ free(const_cast<char *>(it.key().data()));
+ }
+ }
+ } else {
+ qWarning("QGtkStyle could not resolve GTK. Make sure you have installed the proper libraries.");
+ }
+}
+
+/*! \internal
+ * destroys all previously buffered widgets.
+ */
+void QGtkStylePrivate::cleanupGtkWidgets()
+{
+ if (!widgetMap)
+ return;
+ if (widgetMap->contains("GtkWindow")) // Gtk will destroy all children
+ gtk_widget_destroy(widgetMap->value("GtkWindow"));
+ for (QHash<QHashableLatin1Literal, GtkWidget *>::const_iterator it = widgetMap->constBegin();
+ it != widgetMap->constEnd(); ++it)
+ free(const_cast<char *>(it.key().data()));
+}
+
+static bool resolveGConf()
+{
+ if (!QGtkStylePrivate::gconf_client_get_default) {
+ QGtkStylePrivate::gconf_client_get_default = (Ptr_gconf_client_get_default)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_default");
+ QGtkStylePrivate::gconf_client_get_string = (Ptr_gconf_client_get_string)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_string");
+ QGtkStylePrivate::gconf_client_get_bool = (Ptr_gconf_client_get_bool)QLibrary::resolve(QLS("gconf-2"), 4, "gconf_client_get_bool");
+ }
+ return (QGtkStylePrivate::gconf_client_get_default !=0);
+}
+
+QString QGtkStylePrivate::getGConfString(const QString &value, const QString &fallback)
+{
+ QString retVal = fallback;
+ if (resolveGConf()) {
+ g_type_init();
+ GConfClient* client = gconf_client_get_default();
+ GError *err = 0;
+ char *str = gconf_client_get_string(client, qPrintable(value), &err);
+ if (!err) {
+ retVal = QString::fromUtf8(str);
+ g_free(str);
+ }
+ g_object_unref(client);
+ if (err)
+ g_error_free (err);
+ }
+ return retVal;
+}
+
+bool QGtkStylePrivate::getGConfBool(const QString &key, bool fallback)
+{
+ bool retVal = fallback;
+ if (resolveGConf()) {
+ g_type_init();
+ GConfClient* client = gconf_client_get_default();
+ GError *err = 0;
+ bool result = gconf_client_get_bool(client, qPrintable(key), &err);
+ g_object_unref(client);
+ if (!err)
+ retVal = result;
+ else
+ g_error_free (err);
+ }
+ return retVal;
+}
+
+QString QGtkStylePrivate::getThemeName()
+{
+ QString themeName;
+ // We try to parse the gtkrc file first
+ // primarily to avoid resolving Gtk functions if
+ // the KDE 3 "Qt" style is currently in use
+ QString rcPaths = QString::fromLocal8Bit(qgetenv("GTK2_RC_FILES"));
+ if (!rcPaths.isEmpty()) {
+ QStringList paths = rcPaths.split(QLS(":"));
+ foreach (const QString &rcPath, paths) {
+ if (!rcPath.isEmpty()) {
+ QFile rcFile(rcPath);
+ if (rcFile.exists() && rcFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ QTextStream in(&rcFile);
+ while(!in.atEnd()) {
+ QString line = in.readLine();
+ if (line.contains(QLS("gtk-theme-name"))) {
+ line = line.right(line.length() - line.indexOf(QLatin1Char('=')) - 1);
+ line.remove(QLatin1Char('\"'));
+ line = line.trimmed();
+ themeName = line;
+ break;
+ }
+ }
+ }
+ }
+ if (!themeName.isEmpty())
+ break;
+ }
+ }
+
+ // Fall back to gconf
+ if (themeName.isEmpty() && resolveGConf())
+ themeName = getGConfString(QLS("/desktop/gnome/interface/gtk_theme"));
+
+ return themeName;
+}
+
+// Get size of the arrow controls in a GtkSpinButton
+int QGtkStylePrivate::getSpinboxArrowSize() const
+{
+ const int MIN_ARROW_WIDTH = 6;
+ GtkWidget *spinButton = gtkWidget("GtkSpinButton");
+ GtkStyle *style = spinButton->style;
+ gint size = pango_font_description_get_size (style->font_desc);
+ gint arrow_size;
+ arrow_size = qMax(PANGO_PIXELS (size), MIN_ARROW_WIDTH) + style->xthickness;
+ arrow_size += arrow_size%2 + 1;
+ return arrow_size;
+}
+
+
+bool QGtkStylePrivate::isKDE4Session()
+{
+ static int version = -1;
+ if (version == -1)
+ version = qgetenv("KDE_SESSION_VERSION").toInt();
+ return (version == 4);
+}
+
+void QGtkStylePrivate::applyCustomPaletteHash()
+{
+ QPalette menuPal = gtkWidgetPalette("GtkMenu");
+ GdkColor gdkBg = gtkWidget("GtkMenu")->style->bg[GTK_STATE_NORMAL];
+ QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8);
+ menuPal.setBrush(QPalette::Base, bgColor);
+ menuPal.setBrush(QPalette::Window, bgColor);
+ qApp->setPalette(menuPal, "QMenu");
+
+ QPalette toolbarPal = gtkWidgetPalette("GtkToolbar");
+ qApp->setPalette(toolbarPal, "QToolBar");
+
+ QPalette menuBarPal = gtkWidgetPalette("GtkMenuBar");
+ qApp->setPalette(menuBarPal, "QMenuBar");
+}
+
+/*! \internal
+ * Returns the gtk Widget that should be used to determine text foreground and background colors.
+*/
+GtkWidget* QGtkStylePrivate::getTextColorWidget() const
+{
+ return gtkWidget("GtkEntry");
+}
+
+void QGtkStylePrivate::setupGtkWidget(GtkWidget* widget)
+{
+ if (Q_GTK_IS_WIDGET(widget)) {
+ static GtkWidget* protoLayout = 0;
+ if (!protoLayout) {
+ protoLayout = QGtkStylePrivate::gtk_fixed_new();
+ QGtkStylePrivate::gtk_container_add((GtkContainer*)(gtkWidgetMap()->value("GtkWindow")), protoLayout);
+ }
+ Q_ASSERT(protoLayout);
+
+ if (!widget->parent && !GTK_WIDGET_TOPLEVEL(widget))
+ QGtkStylePrivate::gtk_container_add((GtkContainer*)(protoLayout), widget);
+ QGtkStylePrivate::gtk_widget_realize(widget);
+ }
+}
+
+void QGtkStylePrivate::removeWidgetFromMap(const QHashableLatin1Literal &path)
+{
+ WidgetMap *map = gtkWidgetMap();
+ WidgetMap::iterator it = map->find(path);
+ if (it != map->end()) {
+ free(const_cast<char *>(it.key().data()));
+ map->erase(it);
+ }
+}
+
+void QGtkStylePrivate::addWidgetToMap(GtkWidget *widget)
+{
+ if (Q_GTK_IS_WIDGET(widget)) {
+ gtk_widget_realize(widget);
+ QHashableLatin1Literal widgetPath = classPath(widget);
+
+ removeWidgetFromMap(widgetPath);
+ gtkWidgetMap()->insert(widgetPath, widget);
+#ifdef DUMP_GTK_WIDGET_TREE
+ qWarning("Inserted Gtk Widget: %s", widgetPath.data());
+#endif
+ }
+ }
+
+void QGtkStylePrivate::addAllSubWidgets(GtkWidget *widget, gpointer v)
+{
+ Q_UNUSED(v);
+ addWidgetToMap(widget);
+ if (GTK_CHECK_TYPE ((widget), gtk_container_get_type()))
+ gtk_container_forall((GtkContainer*)widget, addAllSubWidgets, NULL);
+}
+
+// Updates window/windowtext palette based on the indicated gtk widget
+QPalette QGtkStylePrivate::gtkWidgetPalette(const QHashableLatin1Literal &gtkWidgetName) const
+{
+ GtkWidget *gtkWidget = QGtkStylePrivate::gtkWidget(gtkWidgetName);
+ Q_ASSERT(gtkWidget);
+ QPalette pal = QApplication::palette();
+ GdkColor gdkBg = gtkWidget->style->bg[GTK_STATE_NORMAL];
+ GdkColor gdkText = gtkWidget->style->fg[GTK_STATE_NORMAL];
+ GdkColor gdkDisabledText = gtkWidget->style->fg[GTK_STATE_INSENSITIVE];
+ QColor bgColor(gdkBg.red>>8, gdkBg.green>>8, gdkBg.blue>>8);
+ QColor textColor(gdkText.red>>8, gdkText.green>>8, gdkText.blue>>8);
+ QColor disabledTextColor(gdkDisabledText.red>>8, gdkDisabledText.green>>8, gdkDisabledText.blue>>8);
+ pal.setBrush(QPalette::Window, bgColor);
+ pal.setBrush(QPalette::Button, bgColor);
+ pal.setBrush(QPalette::All, QPalette::WindowText, textColor);
+ pal.setBrush(QPalette::Disabled, QPalette::WindowText, disabledTextColor);
+ pal.setBrush(QPalette::All, QPalette::ButtonText, textColor);
+ pal.setBrush(QPalette::Disabled, QPalette::ButtonText, disabledTextColor);
+ return pal;
+}
+
+
+void QGtkStyleUpdateScheduler::updateTheme()
+{
+ static QString oldTheme(QLS("qt_not_set"));
+ QPixmapCache::clear();
+
+ QFont font = QGtkStylePrivate::getThemeFont();
+ if (QApplication::font() != font)
+ qApp->setFont(font);
+
+ if (oldTheme != QGtkStylePrivate::getThemeName()) {
+ oldTheme = QGtkStylePrivate::getThemeName();
+ QPalette newPalette = qApp->style()->standardPalette();
+ QApplicationPrivate::setSystemPalette(newPalette);
+ QApplication::setPalette(newPalette);
+ if (!QGtkStylePrivate::instances.isEmpty()) {
+ QGtkStylePrivate::instances.last()->initGtkWidgets();
+ QGtkStylePrivate::instances.last()->applyCustomPaletteHash();
+ }
+ QList<QWidget*> widgets = QApplication::allWidgets();
+ // Notify all widgets that size metrics might have changed
+ foreach (QWidget *widget, widgets) {
+ QEvent e(QEvent::StyleChange);
+ QApplication::sendEvent(widget, &e);
+ }
+ }
+ QIconLoader::instance()->updateSystemTheme();
+}
+
+void QGtkStylePrivate::addWidget(GtkWidget *widget)
+{
+ if (widget) {
+ setupGtkWidget(widget);
+ addAllSubWidgets(widget);
+ }
+}
+
+
+// Fetch the application font from the pango font description
+// contained in the theme.
+QFont QGtkStylePrivate::getThemeFont()
+{
+ QFont font;
+ GtkStyle *style = gtkStyle();
+ if (style && qApp->desktopSettingsAware())
+ {
+ PangoFontDescription *gtk_font = style->font_desc;
+ font.setPointSizeF((float)(pango_font_description_get_size(gtk_font))/PANGO_SCALE);
+
+ QString family = QString::fromLatin1(pango_font_description_get_family(gtk_font));
+ if (!family.isEmpty())
+ font.setFamily(family);
+
+ int weight = pango_font_description_get_weight(gtk_font);
+ if (weight >= PANGO_WEIGHT_HEAVY)
+ font.setWeight(QFont::Black);
+ else if (weight >= PANGO_WEIGHT_BOLD)
+ font.setWeight(QFont::Bold);
+ else if (weight >= PANGO_WEIGHT_SEMIBOLD)
+ font.setWeight(QFont::DemiBold);
+ else if (weight >= PANGO_WEIGHT_NORMAL)
+ font.setWeight(QFont::Normal);
+ else
+ font.setWeight(QFont::Light);
+
+ PangoStyle fontstyle = pango_font_description_get_style(gtk_font);
+ if (fontstyle == PANGO_STYLE_ITALIC)
+ font.setStyle(QFont::StyleItalic);
+ else if (fontstyle == PANGO_STYLE_OBLIQUE)
+ font.setStyle(QFont::StyleOblique);
+ else
+ font.setStyle(QFont::StyleNormal);
+ }
+ return font;
+}
+
+
+// ----------- Native file dialogs -----------
+
+// Extract filter list from expressions of type: foo (*.a *.b *.c)"
+QStringList QGtkStylePrivate::extract_filter(const QString &rawFilter)
+{
+ QString result = rawFilter;
+ QRegExp r(QString::fromLatin1("^([^()]*)\\(([a-zA-Z0-9_.*? +;#\\-\\[\\]@\\{\\}/!<>\\$%&=^~:\\|]*)\\)$"));
+ int index = r.indexIn(result);
+ if (index >= 0)
+ result = r.cap(2);
+ return result.split(QLatin1Char(' '));
+}
+
+extern QStringList qt_make_filter_list(const QString &filter);
+
+void QGtkStylePrivate::setupGtkFileChooser(GtkWidget* gtkFileChooser, QWidget *parent,
+ const QString &dir, const QString &filter, QString *selectedFilter,
+ QFileDialog::Options options, bool isSaveDialog,
+ QMap<GtkFileFilter *, QString> *filterMap)
+{
+ g_object_set(gtkFileChooser, "do-overwrite-confirmation", gboolean(!(options & QFileDialog::DontConfirmOverwrite)), NULL);
+ g_object_set(gtkFileChooser, "local_only", gboolean(true), NULL);
+ if (!filter.isEmpty()) {
+ QStringList filters = qt_make_filter_list(filter);
+ foreach (const QString &rawfilter, filters) {
+ GtkFileFilter *gtkFilter = QGtkStylePrivate::gtk_file_filter_new ();
+ QString name = rawfilter.left(rawfilter.indexOf(QLatin1Char('(')));
+ QStringList extensions = extract_filter(rawfilter);
+ QGtkStylePrivate::gtk_file_filter_set_name(gtkFilter, qPrintable(name.isEmpty() ? extensions.join(QLS(", ")) : name));
+
+ foreach (const QString &fileExtension, extensions) {
+ // Note Gtk file dialogs are by default case sensitive
+ // and only supports basic glob syntax so we
+ // rewrite .xyz to .[xX][yY][zZ]
+ QString caseInsensitive;
+ for (int i = 0 ; i < fileExtension.length() ; ++i) {
+ QChar ch = fileExtension.at(i);
+ if (ch.isLetter()) {
+ caseInsensitive.append(
+ QLatin1Char('[') +
+ ch.toLower() +
+ ch.toUpper() +
+ QLatin1Char(']'));
+ } else {
+ caseInsensitive.append(ch);
+ }
+ }
+ QGtkStylePrivate::gtk_file_filter_add_pattern (gtkFilter, qPrintable(caseInsensitive));
+
+ }
+ if (filterMap)
+ filterMap->insert(gtkFilter, rawfilter);
+ QGtkStylePrivate::gtk_file_chooser_add_filter((GtkFileChooser*)gtkFileChooser, gtkFilter);
+ if (selectedFilter && (rawfilter == *selectedFilter))
+ QGtkStylePrivate::gtk_file_chooser_set_filter((GtkFileChooser*)gtkFileChooser, gtkFilter);
+ }
+ }
+
+ // Using the currently active window is not entirely correct, however
+ // it gives more sensible behavior for applications that do not provide a
+ // parent
+ QWidget *modalFor = parent ? parent->window() : qApp->activeWindow();
+ if (modalFor) {
+ QGtkStylePrivate::gtk_widget_realize(gtkFileChooser); // Creates X window
+ XSetTransientForHint(QGtkStylePrivate::gdk_x11_drawable_get_xdisplay(gtkFileChooser->window),
+ QGtkStylePrivate::gdk_x11_drawable_get_xid(gtkFileChooser->window),
+ modalFor->winId());
+ QGtkStylePrivate::gdk_x11_window_set_user_time (gtkFileChooser->window, QX11Info::appUserTime());
+
+ }
+
+ QFileInfo fileinfo(dir);
+ if (dir.isEmpty())
+ fileinfo.setFile(QDir::currentPath());
+ fileinfo.makeAbsolute();
+ if (fileinfo.isDir()) {
+ QGtkStylePrivate::gtk_file_chooser_set_current_folder((GtkFileChooser*)gtkFileChooser, qPrintable(dir));
+ } else if (isSaveDialog) {
+ QGtkStylePrivate::gtk_file_chooser_set_current_folder((GtkFileChooser*)gtkFileChooser, qPrintable(fileinfo.absolutePath()));
+ QGtkStylePrivate::gtk_file_chooser_set_current_name((GtkFileChooser*)gtkFileChooser, qPrintable(fileinfo.fileName()));
+ } else {
+ QGtkStylePrivate::gtk_file_chooser_set_filename((GtkFileChooser*)gtkFileChooser, qPrintable(dir));
+ }
+}
+
+QString QGtkStylePrivate::openFilename(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
+ QString *selectedFilter, QFileDialog::Options options)
+{
+ QMap<GtkFileFilter *, QString> filterMap;
+ GtkWidget *gtkFileChooser = QGtkStylePrivate::gtk_file_chooser_dialog_new (qPrintable(caption),
+ NULL,
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+ NULL);
+
+ setupGtkFileChooser(gtkFileChooser, parent, dir, filter, selectedFilter, options, false, &filterMap);
+
+ QWidget modal_widget;
+ modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
+ modal_widget.setParent(parent, Qt::Window);
+ QApplicationPrivate::enterModal(&modal_widget);
+
+ QString filename;
+ if (QGtkStylePrivate::gtk_dialog_run ((GtkDialog*)gtkFileChooser) == GTK_RESPONSE_ACCEPT) {
+ char *gtk_filename = QGtkStylePrivate::gtk_file_chooser_get_filename ((GtkFileChooser*)gtkFileChooser);
+ filename = QString::fromUtf8(gtk_filename);
+ g_free (gtk_filename);
+ if (selectedFilter) {
+ GtkFileFilter *gtkFilter = QGtkStylePrivate::gtk_file_chooser_get_filter ((GtkFileChooser*)gtkFileChooser);
+ *selectedFilter = filterMap.value(gtkFilter);
+ }
+ }
+
+ QApplicationPrivate::leaveModal(&modal_widget);
+ gtk_widget_destroy (gtkFileChooser);
+ return filename;
+}
+
+
+QString QGtkStylePrivate::openDirectory(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options)
+{
+ QMap<GtkFileFilter *, QString> filterMap;
+ GtkWidget *gtkFileChooser = QGtkStylePrivate::gtk_file_chooser_dialog_new (qPrintable(caption),
+ NULL,
+ GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+ NULL);
+
+ setupGtkFileChooser(gtkFileChooser, parent, dir, QString(), 0, options);
+ QWidget modal_widget;
+ modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
+ modal_widget.setParent(parent, Qt::Window);
+ QApplicationPrivate::enterModal(&modal_widget);
+
+ QString filename;
+ if (QGtkStylePrivate::gtk_dialog_run ((GtkDialog*)gtkFileChooser) == GTK_RESPONSE_ACCEPT) {
+ char *gtk_filename = QGtkStylePrivate::gtk_file_chooser_get_filename ((GtkFileChooser*)gtkFileChooser);
+ filename = QString::fromUtf8(gtk_filename);
+ g_free (gtk_filename);
+ }
+
+ QApplicationPrivate::leaveModal(&modal_widget);
+ gtk_widget_destroy (gtkFileChooser);
+ return filename;
+}
+
+QStringList QGtkStylePrivate::openFilenames(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
+ QString *selectedFilter, QFileDialog::Options options)
+{
+ QStringList filenames;
+ QMap<GtkFileFilter *, QString> filterMap;
+ GtkWidget *gtkFileChooser = QGtkStylePrivate::gtk_file_chooser_dialog_new (qPrintable(caption),
+ NULL,
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
+ NULL);
+
+ setupGtkFileChooser(gtkFileChooser, parent, dir, filter, selectedFilter, options, false, &filterMap);
+ g_object_set(gtkFileChooser, "select-multiple", gboolean(true), NULL);
+
+ QWidget modal_widget;
+ modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
+ modal_widget.setParent(parent, Qt::Window);
+ QApplicationPrivate::enterModal(&modal_widget);
+
+ if (gtk_dialog_run ((GtkDialog*)gtkFileChooser) == GTK_RESPONSE_ACCEPT) {
+ GSList *gtk_file_names = QGtkStylePrivate::gtk_file_chooser_get_filenames((GtkFileChooser*)gtkFileChooser);
+ for (GSList *iterator = gtk_file_names ; iterator; iterator = iterator->next)
+ filenames << QString::fromUtf8((const char*)iterator->data);
+ g_slist_free(gtk_file_names);
+ if (selectedFilter) {
+ GtkFileFilter *gtkFilter = QGtkStylePrivate::gtk_file_chooser_get_filter ((GtkFileChooser*)gtkFileChooser);
+ *selectedFilter = filterMap.value(gtkFilter);
+ }
+ }
+
+ QApplicationPrivate::leaveModal(&modal_widget);
+ gtk_widget_destroy (gtkFileChooser);
+ return filenames;
+}
+
+QString QGtkStylePrivate::saveFilename(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
+ QString *selectedFilter, QFileDialog::Options options)
+{
+ QMap<GtkFileFilter *, QString> filterMap;
+ GtkWidget *gtkFileChooser = QGtkStylePrivate::gtk_file_chooser_dialog_new (qPrintable(caption),
+ NULL,
+ GTK_FILE_CHOOSER_ACTION_SAVE,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
+ NULL);
+ setupGtkFileChooser(gtkFileChooser, parent, dir, filter, selectedFilter, options, true, &filterMap);
+
+ QWidget modal_widget;
+ modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
+ modal_widget.setParent(parent, Qt::Window);
+ QApplicationPrivate::enterModal(&modal_widget);
+
+ QString filename;
+ if (QGtkStylePrivate::gtk_dialog_run ((GtkDialog*)gtkFileChooser) == GTK_RESPONSE_ACCEPT) {
+ char *gtk_filename = QGtkStylePrivate::gtk_file_chooser_get_filename ((GtkFileChooser*)gtkFileChooser);
+ filename = QString::fromUtf8(gtk_filename);
+ g_free (gtk_filename);
+ if (selectedFilter) {
+ GtkFileFilter *gtkFilter = QGtkStylePrivate::gtk_file_chooser_get_filter ((GtkFileChooser*)gtkFileChooser);
+ *selectedFilter = filterMap.value(gtkFilter);
+ }
+ }
+
+ QApplicationPrivate::leaveModal(&modal_widget);
+ gtk_widget_destroy (gtkFileChooser);
+ return filename;
+}
+
+QIcon QGtkStylePrivate::getFilesystemIcon(const QFileInfo &info)
+{
+ QIcon icon;
+ if (gnome_vfs_init && gnome_icon_lookup_sync) {
+ gnome_vfs_init();
+ GtkIconTheme *theme = gtk_icon_theme_get_default();
+ QByteArray fileurl = QUrl::fromLocalFile(info.absoluteFilePath()).toEncoded();
+ char * icon_name = gnome_icon_lookup_sync(theme,
+ NULL,
+ fileurl.data(),
+ NULL,
+ GNOME_ICON_LOOKUP_FLAGS_NONE,
+ NULL);
+ QString iconName = QString::fromUtf8(icon_name);
+ g_free(icon_name);
+ if (iconName.startsWith(QLatin1Char('/')))
+ return QIcon(iconName);
+ return QIcon::fromTheme(iconName);
+ }
+ return icon;
+}
+
+bool operator==(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2)
+{
+ return l1.size() == l2.size() || qstrcmp(l1.data(), l2.data()) == 0;
+}
+
+// copied from qHash.cpp
+uint qHash(const QHashableLatin1Literal &key)
+{
+ int n = key.size();
+ const uchar *p = reinterpret_cast<const uchar *>(key.data());
+ uint h = 0;
+ uint g;
+
+ while (n--) {
+ h = (h << 4) + *p++;
+ if ((g = (h & 0xf0000000)) != 0)
+ h ^= g >> 23;
+ h &= ~g;
+ }
+ return h;
+}
+
+QT_END_NAMESPACE
+
+#endif // !defined(QT_NO_STYLE_GTK)
diff --git a/src/widgets/styles/qgtkstyle_p.h b/src/widgets/styles/qgtkstyle_p.h
new file mode 100644
index 0000000000..8c84eb3b9d
--- /dev/null
+++ b/src/widgets/styles/qgtkstyle_p.h
@@ -0,0 +1,531 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGTKSTYLE_P_H
+#define QGTKSTYLE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/qglobal.h>
+#if !defined(QT_NO_STYLE_GTK)
+
+#include <QtCore/qstring.h>
+#include <QtCore/qstringbuilder.h>
+#include <QtCore/qcoreapplication.h>
+
+#include <QtWidgets/QFileDialog>
+
+#include <QtWidgets/QGtkStyle>
+#include <private/qcleanlooksstyle_p.h>
+
+#undef signals // Collides with GTK stymbols
+#include <gtk/gtk.h>
+
+typedef unsigned long XID;
+
+#undef GTK_OBJECT_FLAGS
+#define GTK_OBJECT_FLAGS(obj)(((GtkObject*)(obj))->flags)
+#define Q_GTK_IS_WIDGET(widget) widget && GTK_CHECK_TYPE ((widget), QGtkStylePrivate::gtk_widget_get_type())
+
+#define QLS(x) QLatin1String(x)
+
+QT_BEGIN_NAMESPACE
+
+// ### Qt 4.7 - merge with QLatin1Literal
+class QHashableLatin1Literal
+{
+public:
+ int size() const { return m_size; }
+ const char *data() const { return m_data; }
+
+#ifdef __SUNPRO_CC
+ QHashableLatin1Literal(const char* str)
+ : m_size(strlen(str)), m_data(str) {}
+#else
+ template <int N>
+ QHashableLatin1Literal(const char (&str)[N])
+ : m_size(N - 1), m_data(str) {}
+#endif
+
+ QHashableLatin1Literal(const QHashableLatin1Literal &other)
+ : m_size(other.m_size), m_data(other.m_data)
+ {}
+
+ QHashableLatin1Literal &operator=(const QHashableLatin1Literal &other)
+ {
+ if (this == &other)
+ return *this;
+ *const_cast<int *>(&m_size) = other.m_size;
+ *const_cast<char **>(&m_data) = const_cast<char *>(other.m_data);
+ return *this;
+ }
+
+ QString toString() const { return QString::fromLatin1(m_data, m_size); }
+
+ static QHashableLatin1Literal fromData(const char *str)
+ {
+ return QHashableLatin1Literal(str, qstrlen(str));
+ }
+
+private:
+ QHashableLatin1Literal(const char *str, int length)
+ : m_size(length), m_data(str)
+ {}
+
+ const int m_size;
+ const char *m_data;
+};
+
+bool operator==(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2);
+inline bool operator!=(const QHashableLatin1Literal &l1, const QHashableLatin1Literal &l2) { return !operator==(l1, l2); }
+uint qHash(const QHashableLatin1Literal &key);
+
+QT_END_NAMESPACE
+
+class GConf;
+class GConfClient;
+
+typedef GConfClient* (*Ptr_gconf_client_get_default)();
+typedef char* (*Ptr_gconf_client_get_string)(GConfClient*, const char*, GError **);
+typedef bool (*Ptr_gconf_client_get_bool)(GConfClient*, const char*, GError **);
+
+typedef void (*Ptr_gtk_init)(int *, char ***);
+typedef GtkWidget* (*Ptr_gtk_window_new) (GtkWindowType);
+typedef GtkStyle* (*Ptr_gtk_style_attach)(GtkStyle *, GdkWindow *);
+typedef void (*Ptr_gtk_widget_destroy) (GtkWidget *);
+typedef void (*Ptr_gtk_widget_realize) (GtkWidget *);
+typedef void (*Ptr_gtk_widget_set_default_direction) (GtkTextDirection);
+typedef void (*Ptr_gtk_widget_modify_color)(GtkWidget *widget, GtkStateType state, const GdkColor *color);
+typedef GtkWidget* (*Ptr_gtk_arrow_new)(GtkArrowType, GtkShadowType);
+typedef GtkWidget* (*Ptr_gtk_menu_item_new_with_label)(const gchar *);
+typedef GtkWidget* (*Ptr_gtk_separator_menu_item_new)(void);
+typedef GtkWidget* (*Ptr_gtk_check_menu_item_new_with_label)(const gchar *);
+typedef GtkWidget* (*Ptr_gtk_menu_bar_new)(void);
+typedef GtkWidget* (*Ptr_gtk_menu_new)(void);
+typedef GtkWidget* (*Ptr_gtk_combo_box_entry_new)(void);
+typedef GtkWidget* (*Ptr_gtk_toolbar_new)(void);
+typedef GtkWidget* (*Ptr_gtk_spin_button_new)(GtkAdjustment*, double, int);
+typedef GtkWidget* (*Ptr_gtk_button_new)(void);
+typedef GtkWidget* (*Ptr_gtk_tool_button_new)(GtkWidget *, const gchar *);
+typedef GtkWidget* (*Ptr_gtk_hbutton_box_new)(void);
+typedef GtkWidget* (*Ptr_gtk_check_button_new)(void);
+typedef GtkWidget* (*Ptr_gtk_radio_button_new)(GSList *);
+typedef GtkWidget* (*Ptr_gtk_notebook_new)(void);
+typedef GtkWidget* (*Ptr_gtk_progress_bar_new)(void);
+typedef GtkWidget* (*Ptr_gtk_hscale_new)(GtkAdjustment*);
+typedef GtkWidget* (*Ptr_gtk_vscale_new)(GtkAdjustment*);
+typedef GtkWidget* (*Ptr_gtk_hscrollbar_new)(GtkAdjustment*);
+typedef GtkWidget* (*Ptr_gtk_vscrollbar_new)(GtkAdjustment*);
+typedef GtkWidget* (*Ptr_gtk_scrolled_window_new)(GtkAdjustment*, GtkAdjustment*);
+typedef gchar* (*Ptr_gtk_check_version)(guint, guint, guint);
+typedef GtkToolItem* (*Ptr_gtk_separator_tool_item_new) (void);
+typedef GtkWidget* (*Ptr_gtk_entry_new)(void);
+typedef GtkWidget* (*Ptr_gtk_tree_view_new)(void);
+typedef GtkTreeViewColumn* (*Ptr_gtk_tree_view_get_column)(GtkTreeView *, gint);
+typedef GtkWidget* (*Ptr_gtk_combo_box_new)(void);
+typedef GtkWidget* (*Ptr_gtk_frame_new)(const gchar *);
+typedef GtkWidget* (*Ptr_gtk_expander_new)(const gchar*);
+typedef GtkWidget* (*Ptr_gtk_statusbar_new)(void);
+typedef GtkSettings* (*Ptr_gtk_settings_get_default)(void);
+typedef GtkAdjustment* (*Ptr_gtk_range_get_adjustment)(GtkRange *);
+typedef void (*Ptr_gtk_range_set_adjustment)(GtkRange *, GtkAdjustment *);
+typedef void (*Ptr_gtk_progress_configure)(GtkProgress *, double, double, double);
+typedef void (*Ptr_gtk_range_set_inverted)(GtkRange*, bool);
+typedef void (*Ptr_gtk_container_add)(GtkContainer *container, GtkWidget *widget);
+typedef GtkIconSet* (*Ptr_gtk_icon_factory_lookup_default) (const gchar*);
+typedef GtkIconTheme* (*Ptr_gtk_icon_theme_get_default) (void);
+typedef void (*Ptr_gtk_widget_style_get)(GtkWidget *, const gchar *first_property_name, ...);
+typedef GtkTreeViewColumn* (*Ptr_gtk_tree_view_column_new)(void);
+typedef GtkWidget* (*Ptr_gtk_fixed_new)(void);
+typedef GdkPixbuf* (*Ptr_gtk_icon_set_render_icon)(GtkIconSet *, GtkStyle *, GtkTextDirection, GtkStateType, GtkIconSize, GtkWidget *,const char *);
+typedef void (*Ptr_gtk_tree_view_append_column) (GtkTreeView*, GtkTreeViewColumn*);
+typedef void (*Ptr_gtk_paint_check) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
+typedef void (*Ptr_gtk_paint_box) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
+typedef void (*Ptr_gtk_paint_box_gap) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint , gint, GtkPositionType, gint gap_x, gint gap_width);
+typedef void (*Ptr_gtk_paint_resize_grip) (GtkStyle*,GdkWindow*, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, GdkWindowEdge, gint , gint , gint , gint);
+typedef void (*Ptr_gtk_paint_focus) (GtkStyle*,GdkWindow*, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
+typedef void (*Ptr_gtk_paint_shadow) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
+typedef void (*Ptr_gtk_paint_slider) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint, GtkOrientation);
+typedef void (*Ptr_gtk_paint_expander) (GtkStyle*,GdkWindow*, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , GtkExpanderStyle );
+typedef void (*Ptr_gtk_paint_handle) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint, GtkOrientation);
+typedef void (*Ptr_gtk_paint_arrow) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, GtkArrowType, gboolean, gint , gint , gint , gint);
+typedef void (*Ptr_gtk_paint_option) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
+typedef void (*Ptr_gtk_paint_flat_box) (GtkStyle*,GdkWindow*, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint , gint , gint , gint);
+typedef void (*Ptr_gtk_paint_extension) (GtkStyle *, GdkWindow *, GtkStateType, GtkShadowType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint, gint, GtkPositionType);
+typedef void (*Ptr_gtk_adjustment_configure) (GtkAdjustment *, double, double, double, double, double, double);
+typedef GtkObject* (*Ptr_gtk_adjustment_new) (double, double, double, double, double, double);
+typedef void (*Ptr_gtk_paint_hline) (GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint y);
+typedef void (*Ptr_gtk_paint_vline) (GtkStyle *, GdkWindow *, GtkStateType, const GdkRectangle *, GtkWidget *, const gchar *, gint, gint, gint);
+typedef void (*Ptr_gtk_menu_item_set_submenu) (GtkMenuItem *, GtkWidget *);
+typedef void (*Ptr_gtk_container_forall) (GtkContainer *, GtkCallback, gpointer);
+typedef void (*Ptr_gtk_widget_size_allocate) (GtkWidget *, GtkAllocation*);
+typedef void (*Ptr_gtk_widget_size_request) (GtkWidget *widget, GtkRequisition *requisition);
+typedef void (*Ptr_gtk_widget_set_direction) (GtkWidget *, GtkTextDirection);
+typedef void (*Ptr_gtk_widget_path) (GtkWidget *, guint *, gchar **, gchar**);
+
+typedef void (*Ptr_gtk_toolbar_insert) (GtkToolbar *toolbar, GtkToolItem *item, int pos);
+typedef void (*Ptr_gtk_menu_shell_append)(GtkMenuShell *, GtkWidget *);
+typedef GtkType (*Ptr_gtk_container_get_type) (void);
+typedef GtkType (*Ptr_gtk_window_get_type) (void);
+typedef GtkType (*Ptr_gtk_widget_get_type) (void);
+typedef GtkStyle* (*Ptr_gtk_rc_get_style_by_paths) (GtkSettings *, const char *, const char *, GType);
+typedef gint (*Ptr_pango_font_description_get_size) (const PangoFontDescription *);
+typedef PangoWeight (*Ptr_pango_font_description_get_weight) (const PangoFontDescription *);
+typedef const char* (*Ptr_pango_font_description_get_family) (const PangoFontDescription *);
+typedef PangoStyle (*Ptr_pango_font_description_get_style) (const PangoFontDescription *desc);
+typedef gboolean (*Ptr_gtk_file_chooser_set_current_folder)(GtkFileChooser *, const gchar *);
+typedef GtkFileFilter* (*Ptr_gtk_file_filter_new)(void);
+typedef void (*Ptr_gtk_file_filter_set_name)(GtkFileFilter *, const gchar *);
+typedef void (*Ptr_gtk_file_filter_add_pattern)(GtkFileFilter *filter, const gchar *pattern);
+typedef void (*Ptr_gtk_file_chooser_add_filter)(GtkFileChooser *chooser, GtkFileFilter *filter);
+typedef void (*Ptr_gtk_file_chooser_set_filter)(GtkFileChooser *chooser, GtkFileFilter *filter);
+typedef GtkFileFilter* (*Ptr_gtk_file_chooser_get_filter)(GtkFileChooser *chooser);
+typedef gchar* (*Ptr_gtk_file_chooser_get_filename)(GtkFileChooser *chooser);
+typedef GSList* (*Ptr_gtk_file_chooser_get_filenames)(GtkFileChooser *chooser);
+typedef GtkWidget* (*Ptr_gtk_file_chooser_dialog_new)(const gchar *title,
+ GtkWindow *parent,
+ GtkFileChooserAction action,
+ const gchar *first_button_text,
+ ...);
+typedef void (*Ptr_gtk_file_chooser_set_current_name) (GtkFileChooser *, const gchar *);
+typedef gboolean (*Ptr_gtk_file_chooser_set_filename) (GtkFileChooser *chooser, const gchar *name);
+typedef gint (*Ptr_gtk_dialog_run) (GtkDialog*);
+typedef void (*Ptr_gtk_border_free)(GtkBorder *);
+
+typedef guchar* (*Ptr_gdk_pixbuf_get_pixels) (const GdkPixbuf *pixbuf);
+typedef int (*Ptr_gdk_pixbuf_get_width) (const GdkPixbuf *pixbuf);
+typedef void (*Ptr_gdk_color_free) (const GdkColor *);
+typedef int (*Ptr_gdk_pixbuf_get_height) (const GdkPixbuf *pixbuf);
+typedef GdkPixbuf* (*Ptr_gdk_pixbuf_get_from_drawable) (GdkPixbuf *dest, GdkDrawable *src,
+ GdkColormap *cmap, int src_x,
+ int src_y, int dest_x, int dest_y,
+ int width, int height);
+typedef GdkPixmap* (*Ptr_gdk_pixmap_new) (GdkDrawable *drawable, gint width, gint height, gint depth);
+typedef GdkPixbuf* (*Ptr_gdk_pixbuf_new) (GdkColorspace colorspace, gboolean has_alpha,
+ int bits_per_sample, int width, int height);
+typedef void (*Ptr_gdk_draw_rectangle) (GdkDrawable *drawable, GdkGC *gc,
+ gboolean filled, gint x, gint y, gint width, gint height);
+typedef void (*Ptr_gdk_pixbuf_unref)(GdkPixbuf *);
+typedef void (*Ptr_gdk_drawable_unref)(GdkDrawable *);
+typedef gint (*Ptr_gdk_drawable_get_depth)(GdkDrawable *);
+typedef void (*Ptr_gdk_x11_window_set_user_time) (GdkWindow *window, guint32);
+typedef XID (*Ptr_gdk_x11_drawable_get_xid) (GdkDrawable *);
+typedef Display* (*Ptr_gdk_x11_drawable_get_xdisplay) ( GdkDrawable *);
+
+
+QT_BEGIN_NAMESPACE
+
+typedef QStringList (*_qt_filedialog_open_filenames_hook)(QWidget * parent, const QString &caption, const QString &dir,
+ const QString &filter, QString *selectedFilter, QFileDialog::Options options);
+typedef QString (*_qt_filedialog_open_filename_hook) (QWidget * parent, const QString &caption, const QString &dir,
+ const QString &filter, QString *selectedFilter, QFileDialog::Options options);
+typedef QString (*_qt_filedialog_save_filename_hook) (QWidget * parent, const QString &caption, const QString &dir,
+ const QString &filter, QString *selectedFilter, QFileDialog::Options options);
+typedef QString (*_qt_filedialog_existing_directory_hook)(QWidget *parent, const QString &caption, const QString &dir,
+ QFileDialog::Options options);
+
+extern Q_GUI_EXPORT _qt_filedialog_open_filename_hook qt_filedialog_open_filename_hook;
+extern Q_GUI_EXPORT _qt_filedialog_open_filenames_hook qt_filedialog_open_filenames_hook;
+extern Q_GUI_EXPORT _qt_filedialog_save_filename_hook qt_filedialog_save_filename_hook;
+extern Q_GUI_EXPORT _qt_filedialog_existing_directory_hook qt_filedialog_existing_directory_hook;
+
+class QGtkStylePrivate;
+
+class QGtkStyleFilter : public QObject
+{
+public:
+ QGtkStyleFilter(QGtkStylePrivate* sp)
+ : stylePrivate(sp)
+ {}
+private:
+ QGtkStylePrivate* stylePrivate;
+ bool eventFilter(QObject *obj, QEvent *e);
+};
+
+typedef enum {
+ GNOME_ICON_LOOKUP_FLAGS_NONE = 0,
+ GNOME_ICON_LOOKUP_FLAGS_EMBEDDING_TEXT = 1<<0,
+ GNOME_ICON_LOOKUP_FLAGS_SHOW_SMALL_IMAGES_AS_THEMSELVES = 1<<1,
+ GNOME_ICON_LOOKUP_FLAGS_ALLOW_SVG_AS_THEMSELVES = 1<<2
+} GnomeIconLookupFlags;
+
+typedef enum {
+ GNOME_ICON_LOOKUP_RESULT_FLAGS_NONE = 0,
+ GNOME_ICON_LOOKUP_RESULT_FLAGS_THUMBNAIL = 1<<0
+} GnomeIconLookupResultFlags;
+
+struct GnomeThumbnailFactory;
+typedef gboolean (*Ptr_gnome_vfs_init) (void);
+typedef char* (*Ptr_gnome_icon_lookup_sync) (
+ GtkIconTheme *icon_theme,
+ GnomeThumbnailFactory *,
+ const char *file_uri,
+ const char *custom_icon,
+ GnomeIconLookupFlags flags,
+ GnomeIconLookupResultFlags *result);
+
+class QGtkStylePrivate : public QCleanlooksStylePrivate
+{
+ Q_DECLARE_PUBLIC(QGtkStyle)
+public:
+ QGtkStylePrivate();
+ ~QGtkStylePrivate();
+
+ QGtkStyleFilter filter;
+
+ static GtkWidget* gtkWidget(const QHashableLatin1Literal &path);
+ static GtkStyle* gtkStyle(const QHashableLatin1Literal &path = QHashableLatin1Literal("GtkWindow"));
+
+ virtual void resolveGtk() const;
+ virtual void initGtkMenu() const;
+ virtual void initGtkTreeview() const;
+ virtual void initGtkWidgets() const;
+
+ static void cleanupGtkWidgets();
+
+ static bool isKDE4Session();
+ void applyCustomPaletteHash();
+ static QFont getThemeFont();
+ static bool isThemeAvailable() { return gtkStyle() != 0; }
+
+ static bool getGConfBool(const QString &key, bool fallback = 0);
+ static QString getGConfString(const QString &key, const QString &fallback = QString());
+
+ static QString getThemeName();
+ virtual int getSpinboxArrowSize() const;
+
+ static void setupGtkFileChooser(GtkWidget* gtkFileChooser, QWidget *parent,
+ const QString &dir, const QString &filter, QString *selectedFilter,
+ QFileDialog::Options options, bool isSaveDialog = false,
+ QMap<GtkFileFilter *, QString> *filterMap = 0);
+
+ static QString openFilename(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
+ QString *selectedFilter, QFileDialog::Options options);
+ static QString saveFilename(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
+ QString *selectedFilter, QFileDialog::Options options);
+ static QString openDirectory(QWidget *parent, const QString &caption, const QString &dir, QFileDialog::Options options);
+ static QStringList openFilenames(QWidget *parent, const QString &caption, const QString &dir, const QString &filter,
+ QString *selectedFilter, QFileDialog::Options options);
+ static QIcon getFilesystemIcon(const QFileInfo &);
+
+ static Ptr_gtk_container_forall gtk_container_forall;
+ static Ptr_gtk_init gtk_init;
+ static Ptr_gtk_style_attach gtk_style_attach;
+ static Ptr_gtk_window_new gtk_window_new;
+ static Ptr_gtk_widget_destroy gtk_widget_destroy;
+ static Ptr_gtk_widget_realize gtk_widget_realize;
+ static Ptr_gtk_widget_set_default_direction gtk_widget_set_default_direction;
+ static Ptr_gtk_widget_modify_color gtk_widget_modify_fg;
+ static Ptr_gtk_widget_modify_color gtk_widget_modify_bg;
+ static Ptr_gtk_menu_item_new_with_label gtk_menu_item_new_with_label;
+ static Ptr_gtk_arrow_new gtk_arrow_new;
+ static Ptr_gtk_check_menu_item_new_with_label gtk_check_menu_item_new_with_label;
+ static Ptr_gtk_menu_bar_new gtk_menu_bar_new;
+ static Ptr_gtk_menu_new gtk_menu_new;
+ static Ptr_gtk_expander_new gtk_expander_new;
+ static Ptr_gtk_button_new gtk_button_new;
+ static Ptr_gtk_tool_button_new gtk_tool_button_new;
+ static Ptr_gtk_hbutton_box_new gtk_hbutton_box_new;
+ static Ptr_gtk_check_button_new gtk_check_button_new;
+ static Ptr_gtk_radio_button_new gtk_radio_button_new;
+ static Ptr_gtk_spin_button_new gtk_spin_button_new;
+ static Ptr_gtk_separator_tool_item_new gtk_separator_tool_item_new;
+ static Ptr_gtk_toolbar_insert gtk_toolbar_insert;
+ static Ptr_gtk_frame_new gtk_frame_new;
+ static Ptr_gtk_statusbar_new gtk_statusbar_new;
+ static Ptr_gtk_entry_new gtk_entry_new;
+ static Ptr_gtk_hscale_new gtk_hscale_new;
+ static Ptr_gtk_vscale_new gtk_vscale_new;
+ static Ptr_gtk_hscrollbar_new gtk_hscrollbar_new;
+ static Ptr_gtk_vscrollbar_new gtk_vscrollbar_new;
+ static Ptr_gtk_scrolled_window_new gtk_scrolled_window_new;
+ static Ptr_gtk_notebook_new gtk_notebook_new;
+ static Ptr_gtk_toolbar_new gtk_toolbar_new;
+ static Ptr_gtk_tree_view_new gtk_tree_view_new;
+ static Ptr_gtk_tree_view_get_column gtk_tree_view_get_column;
+ static Ptr_gtk_combo_box_new gtk_combo_box_new;
+ static Ptr_gtk_combo_box_entry_new gtk_combo_box_entry_new;
+ static Ptr_gtk_progress_bar_new gtk_progress_bar_new;
+ static Ptr_gtk_container_add gtk_container_add;
+ static Ptr_gtk_menu_shell_append gtk_menu_shell_append;
+ static Ptr_gtk_progress_configure gtk_progress_configure;
+ static Ptr_gtk_range_get_adjustment gtk_range_get_adjustment;
+ static Ptr_gtk_range_set_adjustment gtk_range_set_adjustment;
+ static Ptr_gtk_range_set_inverted gtk_range_set_inverted;
+ static Ptr_gtk_icon_factory_lookup_default gtk_icon_factory_lookup_default;
+ static Ptr_gtk_icon_theme_get_default gtk_icon_theme_get_default;
+ static Ptr_gtk_widget_style_get gtk_widget_style_get;
+ static Ptr_gtk_icon_set_render_icon gtk_icon_set_render_icon;
+ static Ptr_gtk_fixed_new gtk_fixed_new;
+ static Ptr_gtk_tree_view_column_new gtk_tree_view_column_new;
+ static Ptr_gtk_tree_view_append_column gtk_tree_view_append_column;
+ static Ptr_gtk_paint_check gtk_paint_check;
+ static Ptr_gtk_paint_box gtk_paint_box;
+ static Ptr_gtk_paint_box_gap gtk_paint_box_gap;
+ static Ptr_gtk_paint_flat_box gtk_paint_flat_box;
+ static Ptr_gtk_paint_option gtk_paint_option;
+ static Ptr_gtk_paint_extension gtk_paint_extension;
+ static Ptr_gtk_paint_slider gtk_paint_slider;
+ static Ptr_gtk_paint_shadow gtk_paint_shadow;
+ static Ptr_gtk_paint_resize_grip gtk_paint_resize_grip;
+ static Ptr_gtk_paint_focus gtk_paint_focus;
+ static Ptr_gtk_paint_arrow gtk_paint_arrow;
+ static Ptr_gtk_paint_handle gtk_paint_handle;
+ static Ptr_gtk_paint_expander gtk_paint_expander;
+ static Ptr_gtk_adjustment_configure gtk_adjustment_configure;
+ static Ptr_gtk_adjustment_new gtk_adjustment_new;
+ static Ptr_gtk_paint_vline gtk_paint_vline;
+ static Ptr_gtk_paint_hline gtk_paint_hline;
+ static Ptr_gtk_menu_item_set_submenu gtk_menu_item_set_submenu;
+ static Ptr_gtk_settings_get_default gtk_settings_get_default;
+ static Ptr_gtk_separator_menu_item_new gtk_separator_menu_item_new;
+ static Ptr_gtk_widget_size_allocate gtk_widget_size_allocate;
+ static Ptr_gtk_widget_size_request gtk_widget_size_request;
+ static Ptr_gtk_widget_set_direction gtk_widget_set_direction;
+ static Ptr_gtk_widget_path gtk_widget_path;
+ static Ptr_gtk_container_get_type gtk_container_get_type;
+ static Ptr_gtk_window_get_type gtk_window_get_type;
+ static Ptr_gtk_widget_get_type gtk_widget_get_type;
+ static Ptr_gtk_rc_get_style_by_paths gtk_rc_get_style_by_paths;
+ static Ptr_gtk_check_version gtk_check_version;
+ static Ptr_gtk_border_free gtk_border_free;
+
+ static Ptr_pango_font_description_get_size pango_font_description_get_size;
+ static Ptr_pango_font_description_get_weight pango_font_description_get_weight;
+ static Ptr_pango_font_description_get_family pango_font_description_get_family;
+ static Ptr_pango_font_description_get_style pango_font_description_get_style;
+
+ static Ptr_gtk_file_filter_new gtk_file_filter_new;
+ static Ptr_gtk_file_filter_set_name gtk_file_filter_set_name;
+ static Ptr_gtk_file_filter_add_pattern gtk_file_filter_add_pattern;
+ static Ptr_gtk_file_chooser_add_filter gtk_file_chooser_add_filter;
+ static Ptr_gtk_file_chooser_set_filter gtk_file_chooser_set_filter;
+ static Ptr_gtk_file_chooser_get_filter gtk_file_chooser_get_filter;
+ static Ptr_gtk_file_chooser_dialog_new gtk_file_chooser_dialog_new;
+ static Ptr_gtk_file_chooser_set_current_folder gtk_file_chooser_set_current_folder;
+ static Ptr_gtk_file_chooser_get_filename gtk_file_chooser_get_filename;
+ static Ptr_gtk_file_chooser_get_filenames gtk_file_chooser_get_filenames;
+ static Ptr_gtk_file_chooser_set_current_name gtk_file_chooser_set_current_name;
+ static Ptr_gtk_dialog_run gtk_dialog_run;
+ static Ptr_gtk_file_chooser_set_filename gtk_file_chooser_set_filename;
+
+ static Ptr_gdk_pixbuf_get_pixels gdk_pixbuf_get_pixels;
+ static Ptr_gdk_pixbuf_get_width gdk_pixbuf_get_width;
+ static Ptr_gdk_pixbuf_get_height gdk_pixbuf_get_height;
+ static Ptr_gdk_pixmap_new gdk_pixmap_new;
+ static Ptr_gdk_pixbuf_new gdk_pixbuf_new;
+ static Ptr_gdk_pixbuf_get_from_drawable gdk_pixbuf_get_from_drawable;
+ static Ptr_gdk_draw_rectangle gdk_draw_rectangle;
+ static Ptr_gdk_pixbuf_unref gdk_pixbuf_unref;
+ static Ptr_gdk_drawable_unref gdk_drawable_unref;
+ static Ptr_gdk_drawable_get_depth gdk_drawable_get_depth;
+ static Ptr_gdk_color_free gdk_color_free;
+ static Ptr_gdk_x11_window_set_user_time gdk_x11_window_set_user_time;
+ static Ptr_gdk_x11_drawable_get_xid gdk_x11_drawable_get_xid;
+ static Ptr_gdk_x11_drawable_get_xdisplay gdk_x11_drawable_get_xdisplay;
+
+ static Ptr_gconf_client_get_default gconf_client_get_default;
+ static Ptr_gconf_client_get_string gconf_client_get_string;
+ static Ptr_gconf_client_get_bool gconf_client_get_bool;
+
+ static Ptr_gnome_icon_lookup_sync gnome_icon_lookup_sync;
+ static Ptr_gnome_vfs_init gnome_vfs_init;
+
+ virtual QPalette gtkWidgetPalette(const QHashableLatin1Literal &gtkWidgetName) const;
+
+protected:
+ typedef QHash<QHashableLatin1Literal, GtkWidget*> WidgetMap;
+
+ static inline void destroyWidgetMap()
+ {
+ cleanupGtkWidgets();
+ delete widgetMap;
+ widgetMap = 0;
+ }
+
+ static inline WidgetMap *gtkWidgetMap()
+ {
+ if (!widgetMap) {
+ widgetMap = new WidgetMap();
+ qAddPostRoutine(destroyWidgetMap);
+ }
+ return widgetMap;
+ }
+
+ static QStringList extract_filter(const QString &rawFilter);
+
+ virtual GtkWidget* getTextColorWidget() const;
+ static void setupGtkWidget(GtkWidget* widget);
+ static void addWidgetToMap(GtkWidget* widget);
+ static void addAllSubWidgets(GtkWidget *widget, gpointer v = 0);
+ static void addWidget(GtkWidget *widget);
+ static void removeWidgetFromMap(const QHashableLatin1Literal &path);
+
+ virtual void init();
+
+private:
+ static QList<QGtkStylePrivate *> instances;
+ static WidgetMap *widgetMap;
+ friend class QGtkStyleUpdateScheduler;
+};
+
+// Helper to ensure that we have polished all our gtk widgets
+// before updating our own palettes
+class QGtkStyleUpdateScheduler : public QObject
+{
+ Q_OBJECT
+public slots:
+ void updateTheme();
+};
+
+QT_END_NAMESPACE
+
+#endif // !QT_NO_STYLE_GTK
+#endif // QGTKSTYLE_P_H
diff --git a/src/gui/styles/qmacstyle.qdoc b/src/widgets/styles/qmacstyle.qdoc
index 2f42d7156b..2f42d7156b 100644
--- a/src/gui/styles/qmacstyle.qdoc
+++ b/src/widgets/styles/qmacstyle.qdoc
diff --git a/src/widgets/styles/qmacstyle_mac.h b/src/widgets/styles/qmacstyle_mac.h
new file mode 100644
index 0000000000..099c552929
--- /dev/null
+++ b/src/widgets/styles/qmacstyle_mac.h
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMACSTYLE_MAC_H
+#define QMACSTYLE_MAC_H
+
+#include <QtWidgets/qwindowsstyle.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#if defined(Q_WS_MAC) && !defined(QT_NO_STYLE_MAC)
+
+class QPalette;
+
+#if defined(QT_PLUGIN)
+#define Q_GUI_EXPORT_STYLE_MAC
+#else
+#define Q_GUI_EXPORT_STYLE_MAC Q_GUI_EXPORT
+#endif
+
+class QPushButton;
+class QStyleOptionButton;
+class QMacStylePrivate;
+class Q_GUI_EXPORT_STYLE_MAC QMacStyle : public QWindowsStyle
+{
+ Q_OBJECT
+public:
+ QMacStyle();
+ virtual ~QMacStyle();
+
+ void polish(QWidget *w);
+ void unpolish(QWidget *w);
+
+ void polish(QApplication*);
+ void unpolish(QApplication*);
+
+ void polish(QPalette &pal);
+
+ void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
+ const QWidget *w = 0) const;
+ void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
+ const QWidget *w = 0) const;
+ QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const;
+ void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
+ const QWidget *w = 0) const;
+ SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
+ const QPoint &pt, const QWidget *w = 0) const;
+ QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc,
+ const QWidget *w = 0) const;
+ QSize sizeFromContents(ContentsType ct, const QStyleOption *opt,
+ const QSize &contentsSize, const QWidget *w = 0) const;
+
+ int pixelMetric(PixelMetric pm, const QStyleOption *opt = 0, const QWidget *widget = 0) const;
+
+ QPalette standardPalette() const;
+
+ virtual int styleHint(StyleHint sh, const QStyleOption *opt = 0, const QWidget *w = 0,
+ QStyleHintReturn *shret = 0) const;
+
+ enum FocusRectPolicy { FocusEnabled, FocusDisabled, FocusDefault };
+ static void setFocusRectPolicy(QWidget *w, FocusRectPolicy policy);
+ static FocusRectPolicy focusRectPolicy(const QWidget *w);
+
+ enum WidgetSizePolicy { SizeSmall, SizeLarge, SizeMini, SizeDefault
+#ifdef QT3_SUPPORT
+ , SizeNone = SizeDefault
+#endif
+ };
+ static void setWidgetSizePolicy(const QWidget *w, WidgetSizePolicy policy);
+ static WidgetSizePolicy widgetSizePolicy(const QWidget *w);
+
+ QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *opt,
+ const QWidget *widget = 0) const;
+
+ QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
+ const QStyleOption *opt) const;
+
+ virtual void drawItemText(QPainter *p, const QRect &r, int flags, const QPalette &pal,
+ bool enabled, const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const;
+
+ bool event(QEvent *e);
+
+protected Q_SLOTS:
+ QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt = 0,
+ const QWidget *widget = 0) const;
+ int layoutSpacingImplementation(QSizePolicy::ControlType control1,
+ QSizePolicy::ControlType control2,
+ Qt::Orientation orientation,
+ const QStyleOption *option = 0,
+ const QWidget *widget = 0) const;
+
+private:
+ Q_DISABLE_COPY(QMacStyle)
+
+ QMacStylePrivate *d;
+
+ friend bool qt_mac_buttonIsRenderedFlat(const QPushButton *pushButton, const QStyleOptionButton *option);
+};
+
+#endif // Q_WS_MAC
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QMACSTYLE_H
diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm
index 18003ce2a2..18003ce2a2 100644
--- a/src/gui/styles/qmacstyle_mac.mm
+++ b/src/widgets/styles/qmacstyle_mac.mm
diff --git a/src/widgets/styles/qmacstyle_mac_p.h b/src/widgets/styles/qmacstyle_mac_p.h
new file mode 100644
index 0000000000..d5d3ed0d0d
--- /dev/null
+++ b/src/widgets/styles/qmacstyle_mac_p.h
@@ -0,0 +1,241 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef QMACSTYLE_MAC_P_H
+#define QMACSTYLE_MAC_P_H
+
+#include <qmacstyle_mac.h>
+#include <private/qapplication_p.h>
+#include <private/qcombobox_p.h>
+#include <private/qmacstylepixmaps_mac_p.h>
+#include <private/qpaintengine_mac_p.h>
+#include <private/qpainter_p.h>
+#include <private/qprintengine_mac_p.h>
+#include <private/qstylehelper_p.h>
+#include <qapplication.h>
+#include <qbitmap.h>
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qdialogbuttonbox.h>
+#include <qdockwidget.h>
+#include <qevent.h>
+#include <qfocusframe.h>
+#include <qformlayout.h>
+#include <qgroupbox.h>
+#include <qhash.h>
+#include <qheaderview.h>
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qlistview.h>
+#include <qmainwindow.h>
+#include <qmap.h>
+#include <qmenubar.h>
+#include <qpaintdevice.h>
+#include <qpainter.h>
+#include <qpixmapcache.h>
+#include <qpointer.h>
+#include <qprogressbar.h>
+#include <qpushbutton.h>
+#include <qradiobutton.h>
+#include <qrubberband.h>
+#include <qsizegrip.h>
+#include <qspinbox.h>
+#include <qsplitter.h>
+#include <qstyleoption.h>
+#include <qtextedit.h>
+#include <qtextstream.h>
+#include <qtoolbar.h>
+#include <qtoolbutton.h>
+#include <qtreeview.h>
+#include <qtableview.h>
+#include <qwizard.h>
+#include <qdebug.h>
+#include <qlibrary.h>
+#include <qdatetimeedit.h>
+#include <qmath.h>
+#include <QtWidgets/qgraphicsproxywidget.h>
+#include <QtWidgets/qgraphicsview.h>
+#include <private/qt_cocoa_helpers_mac_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.
+//
+
+QT_BEGIN_NAMESPACE
+
+#if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5)
+enum {
+ kThemePushButtonTextured = 31,
+ kThemePushButtonTexturedSmall = 32,
+ kThemePushButtonTexturedMini = 33
+};
+
+/* Search fields */
+enum {
+ kHIThemeFrameTextFieldRound = 1000,
+ kHIThemeFrameTextFieldRoundSmall = 1001,
+ kHIThemeFrameTextFieldRoundMini = 1002
+};
+#endif
+
+/*
+ AHIG:
+ Apple Human Interface Guidelines
+ http://developer.apple.com/documentation/UserExperience/Conceptual/OSXHIGuidelines/
+
+ Builder:
+ Apple Interface Builder v. 3.1.1
+*/
+
+// this works as long as we have at most 16 different control types
+#define CT1(c) CT2(c, c)
+#define CT2(c1, c2) ((uint(c1) << 16) | uint(c2))
+
+enum QAquaWidgetSize { QAquaSizeLarge = 0, QAquaSizeSmall = 1, QAquaSizeMini = 2,
+ QAquaSizeUnknown = -1 };
+
+#define SIZE(large, small, mini) \
+ (controlSize == QAquaSizeLarge ? (large) : controlSize == QAquaSizeSmall ? (small) : (mini))
+
+// same as return SIZE(...) but optimized
+#define return_SIZE(large, small, mini) \
+ do { \
+ static const int sizes[] = { (large), (small), (mini) }; \
+ return sizes[controlSize]; \
+ } while (0)
+
+bool qt_mac_buttonIsRenderedFlat(const QPushButton *pushButton, const QStyleOptionButton *option);
+
+class QMacStylePrivate : public QObject
+{
+ Q_OBJECT
+
+public:
+ QMacStylePrivate(QMacStyle *style);
+
+ // Ideally these wouldn't exist, but since they already exist we need some accessors.
+ static const int PushButtonLeftOffset;
+ static const int PushButtonTopOffset;
+ static const int PushButtonRightOffset;
+ static const int PushButtonBottomOffset;
+ static const int MiniButtonH;
+ static const int SmallButtonH;
+ static const int BevelButtonW;
+ static const int BevelButtonH;
+ static const int PushButtonContentPadding;
+
+
+ // Stuff from QAquaAnimate:
+ bool addWidget(QWidget *);
+ void removeWidget(QWidget *);
+
+ enum Animates { AquaPushButton, AquaProgressBar, AquaListViewItemOpen };
+ bool animatable(Animates, const QWidget *) const;
+ void stopAnimate(Animates, QWidget *);
+ void startAnimate(Animates, QWidget *);
+ static ThemeDrawState getDrawState(QStyle::State flags);
+ QAquaWidgetSize aquaSizeConstrain(const QStyleOption *option, const QWidget *widg,
+ QStyle::ContentsType ct = QStyle::CT_CustomBase,
+ QSize szHint=QSize(-1, -1), QSize *insz = 0) const;
+ void getSliderInfo(QStyle::ComplexControl cc, const QStyleOptionSlider *slider,
+ HIThemeTrackDrawInfo *tdi, const QWidget *needToRemoveMe);
+ bool doAnimate(Animates);
+ inline int animateSpeed(Animates) const { return 33; }
+
+ // Utility functions
+ void drawColorlessButton(const HIRect &macRect, HIThemeButtonDrawInfo *bdi,
+ QPainter *p, const QStyleOption *opt) const;
+
+ QSize pushButtonSizeFromContents(const QStyleOptionButton *btn) const;
+
+ HIRect pushButtonContentBounds(const QStyleOptionButton *btn,
+ const HIThemeButtonDrawInfo *bdi) const;
+
+ void initComboboxBdi(const QStyleOptionComboBox *combo, HIThemeButtonDrawInfo *bdi,
+ const QWidget *widget, const ThemeDrawState &tds);
+
+ static HIRect comboboxInnerBounds(const HIRect &outerBounds, int buttonKind);
+
+ static QRect comboboxEditBounds(const QRect &outerBounds, const HIThemeButtonDrawInfo &bdi);
+
+ static void drawCombobox(const HIRect &outerBounds, const HIThemeButtonDrawInfo &bdi, QPainter *p);
+ static void drawTableHeader(const HIRect &outerBounds, bool drawTopBorder, bool drawLeftBorder,
+ const HIThemeButtonDrawInfo &bdi, QPainter *p);
+ bool contentFitsInPushButton(const QStyleOptionButton *btn, HIThemeButtonDrawInfo *bdi,
+ ThemeButtonKind buttonKindToCheck) const;
+ void initHIThemePushButton(const QStyleOptionButton *btn, const QWidget *widget,
+ const ThemeDrawState tds,
+ HIThemeButtonDrawInfo *bdi) const;
+ QPixmap generateBackgroundPattern() const;
+protected:
+ bool eventFilter(QObject *, QEvent *);
+ void timerEvent(QTimerEvent *);
+
+private slots:
+ void startAnimationTimer();
+
+public:
+ QPointer<QPushButton> defaultButton; //default push buttons
+ int timerID;
+ QList<QPointer<QWidget> > progressBars; //existing progress bars that need animation
+
+ struct ButtonState {
+ int frame;
+ enum { ButtonDark, ButtonLight } dir;
+ } buttonState;
+ UInt8 progressFrame;
+ QPointer<QFocusFrame> focusWidget;
+ CFAbsoluteTime defaultButtonStart;
+ QMacStyle *q;
+ bool mouseDown;
+};
+
+QT_END_NAMESPACE
+
+#endif // QMACSTYLE_MAC_P_H
diff --git a/src/gui/styles/qmacstylepixmaps_mac_p.h b/src/widgets/styles/qmacstylepixmaps_mac_p.h
index 41794387ea..41794387ea 100644
--- a/src/gui/styles/qmacstylepixmaps_mac_p.h
+++ b/src/widgets/styles/qmacstylepixmaps_mac_p.h
diff --git a/src/widgets/styles/qmotifstyle.cpp b/src/widgets/styles/qmotifstyle.cpp
new file mode 100644
index 0000000000..876db114c6
--- /dev/null
+++ b/src/widgets/styles/qmotifstyle.cpp
@@ -0,0 +1,2721 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmotifstyle.h"
+#include "qcdestyle.h"
+
+#if !defined(QT_NO_STYLE_MOTIF) || defined(QT_PLUGIN)
+
+#include "qmenu.h"
+#include "qapplication.h"
+#include "qpainter.h"
+#include "qdrawutil.h"
+#include "qpixmap.h"
+#include "qpalette.h"
+#include "qwidget.h"
+#include "qpushbutton.h"
+#include "qscrollbar.h"
+#include "qtabbar.h"
+#include "qtabwidget.h"
+#include "qlistview.h"
+#include "qsplitter.h"
+#include "qslider.h"
+#include "qcombobox.h"
+#include "qlineedit.h"
+#include "qprogressbar.h"
+#include "qimage.h"
+#include "qfocusframe.h"
+#include "qdebug.h"
+#include "qpainterpath.h"
+#include "qmotifstyle_p.h"
+#include "qdialogbuttonbox.h"
+#include "qformlayout.h"
+#include <limits.h>
+#include <QtWidgets/qgraphicsproxywidget.h>
+#include <QtWidgets/qgraphicsview.h>
+
+#ifdef Q_WS_X11
+#include "qx11info_x11.h"
+#endif
+
+QT_BEGIN_NAMESPACE
+
+// old constants that might still be useful...
+static const int motifItemFrame = 2; // menu item frame width
+static const int motifSepHeight = 2; // separator item height
+static const int motifItemHMargin = 3; // menu item hor text margin
+static const int motifItemVMargin = 2; // menu item ver text margin
+static const int motifArrowHMargin = 6; // arrow horizontal margin
+static const int motifTabSpacing = 12; // space between text and tab
+static const int motifCheckMarkHMargin = 2; // horiz. margins of check mark
+static const int motifCheckMarkSpace = 16;
+
+
+/*!
+ \class QMotifStyle
+ \brief The QMotifStyle class provides Motif look and feel.
+
+ \ingroup appearance
+
+ This class implements the Motif look and feel. It closely
+ resembles the original Motif look as defined by the Open Group,
+ but with some minor improvements. The Motif style is Qt's default
+ GUI style on Unix platforms.
+
+ \img qmotifstyle.png
+ \sa QWindowsXPStyle, QMacStyle, QWindowsStyle, QPlastiqueStyle, QCDEStyle
+*/
+
+/*!
+ \variable QMotifStyle::focus
+ \internal
+*/
+
+/*!
+ Constructs a QMotifStyle.
+
+ If \a useHighlightCols is false (the default), the style will
+ polish the application's color palette to emulate the Motif way of
+ highlighting, which is a simple inversion between the base and the
+ text color.
+*/
+QMotifStyle::QMotifStyle(bool useHighlightCols)
+ : QCommonStyle(*new QMotifStylePrivate)
+{
+ focus = 0;
+ highlightCols = useHighlightCols;
+}
+
+
+/*!
+ \internal
+*/
+QMotifStyle::QMotifStyle(QMotifStylePrivate &dd, bool useHighlightColors)
+ : QCommonStyle(dd)
+{
+ focus = 0;
+ highlightCols = useHighlightColors;
+}
+
+
+/*!
+ \overload
+
+ Destroys the style.
+*/
+QMotifStyle::~QMotifStyle()
+{
+ delete focus;
+}
+
+/*!
+ \internal
+ Animate indeterminate progress bars only when visible
+*/
+bool QMotifStyle::eventFilter(QObject *o, QEvent *e)
+{
+#ifndef QT_NO_PROGRESSBAR
+ Q_D(QMotifStyle);
+ switch(e->type()) {
+ case QEvent::StyleChange:
+ case QEvent::Show:
+ if (QProgressBar *bar = qobject_cast<QProgressBar *>(o)) {
+ d->bars << bar;
+ if (d->bars.size() == 1) {
+ Q_ASSERT(d->animationFps> 0);
+ d->animateTimer = startTimer(1000 / d->animationFps);
+ }
+ }
+ break;
+ case QEvent::Destroy:
+ case QEvent::Hide:
+ // reinterpret_cast because there is no type info when getting
+ // the destroy event. We know that it is a QProgressBar.
+ if (QProgressBar *bar = reinterpret_cast<QProgressBar *>(o)) {
+ d->bars.removeAll(bar);
+ if (d->bars.isEmpty() && d->animateTimer) {
+ killTimer(d->animateTimer);
+ d->animateTimer = 0;
+ }
+ }
+ default:
+ break;
+ }
+#endif // QT_NO_PROGRESSBAR
+ return QStyle::eventFilter(o, e);
+}
+
+/*!
+ \internal
+*/
+QIcon QMotifStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt,
+ const QWidget *widget) const
+{
+ return QCommonStyle::standardIconImplementation(standardIcon, opt, widget);
+}
+
+/*!
+ \reimp
+*/
+void QMotifStyle::timerEvent(QTimerEvent *event)
+{
+#ifndef QT_NO_PROGRESSBAR
+ Q_D(QMotifStyle);
+ if (event->timerId() == d->animateTimer) {
+ Q_ASSERT(d->animationFps > 0);
+ d->animateStep = d->startTime.elapsed() / (1000 / d->animationFps);
+ foreach (QProgressBar *bar, d->bars) {
+ if ((bar->minimum() == 0 && bar->maximum() == 0))
+ bar->update();
+ }
+ }
+#endif // QT_NO_PROGRESSBAR
+ event->ignore();
+}
+
+
+QMotifStylePrivate::QMotifStylePrivate()
+#ifndef QT_NO_PROGRESSBAR
+ : animationFps(25), animateTimer(0), animateStep(0)
+#endif
+{
+}
+
+/*!
+ If \a arg is false, the style will polish the application's color
+ palette to emulate the Motif way of highlighting, which is a
+ simple inversion between the base and the text color.
+
+ The effect will show up the next time an application palette is
+ set via QApplication::setPalette(). The current color palette of
+ the application remains unchanged.
+
+ \sa QStyle::polish()
+*/
+void QMotifStyle::setUseHighlightColors(bool arg)
+{
+ highlightCols = arg;
+}
+
+/*!
+ Returns true if the style treats the highlight colors of the
+ palette in a Motif-like manner, which is a simple inversion
+ between the base and the text color; otherwise returns false. The
+ default is false.
+*/
+bool QMotifStyle::useHighlightColors() const
+{
+ return highlightCols;
+}
+
+/*! \reimp */
+
+void QMotifStyle::polish(QPalette& pal)
+{
+ if (pal.brush(QPalette::Active, QPalette::Light) == pal.brush(QPalette::Active, QPalette::Base)) {
+ QColor nlight = pal.color(QPalette::Active, QPalette::Light).darker(108);
+ pal.setColor(QPalette::Active, QPalette::Light, nlight) ;
+ pal.setColor(QPalette::Disabled, QPalette::Light, nlight) ;
+ pal.setColor(QPalette::Inactive, QPalette::Light, nlight) ;
+ }
+
+ if (highlightCols)
+ return;
+
+ // force the ugly motif way of highlighting *sigh*
+ pal.setColor(QPalette::Active, QPalette::Highlight,
+ pal.color(QPalette::Active, QPalette::Text));
+ pal.setColor(QPalette::Active, QPalette::HighlightedText,
+ pal.color(QPalette::Active, QPalette::Base));
+ pal.setColor(QPalette::Disabled, QPalette::Highlight,
+ pal.color(QPalette::Disabled, QPalette::Text));
+ pal.setColor(QPalette::Disabled, QPalette::HighlightedText,
+ pal.color(QPalette::Disabled, QPalette::Base));
+ pal.setColor(QPalette::Inactive, QPalette::Highlight,
+ pal.color(QPalette::Active, QPalette::Text));
+ pal.setColor(QPalette::Inactive, QPalette::HighlightedText,
+ pal.color(QPalette::Active, QPalette::Base));
+}
+
+/*!
+ \reimp
+ \internal
+ Keep QStyle::polish() visible.
+*/
+void QMotifStyle::polish(QWidget* widget)
+{
+ QStyle::polish(widget);
+#ifndef QT_NO_PROGRESSBAR
+ if (qobject_cast<QProgressBar *>(widget))
+ widget->installEventFilter(this);
+#endif
+}
+
+/*!
+ \reimp
+ \internal
+ Keep QStyle::polish() visible.
+*/
+void QMotifStyle::unpolish(QWidget* widget)
+{
+ QCommonStyle::unpolish(widget);
+#ifndef QT_NO_PROGRESSBAR
+ if (qobject_cast<QProgressBar *>(widget)) {
+ Q_D(QMotifStyle);
+ widget->removeEventFilter(this);
+ d->bars.removeAll(static_cast<QProgressBar*>(widget));
+ }
+#endif
+}
+
+
+/*!
+ \reimp
+ \internal
+ Keep QStyle::polish() visible.
+*/
+void QMotifStyle::polish(QApplication* a)
+{
+ QCommonStyle::polish(a);
+}
+
+
+/*!
+ \reimp
+ \internal
+ Keep QStyle::polish() visible.
+*/
+void QMotifStyle::unpolish(QApplication* a)
+{
+ QCommonStyle::unpolish(a);
+}
+
+static void rot(QPolygon& a, int n)
+{
+ QPolygon r(a.size());
+ for (int i = 0; i < (int)a.size(); i++) {
+ switch (n) {
+ case 1: r.setPoint(i,-a[i].y(),a[i].x()); break;
+ case 2: r.setPoint(i,-a[i].x(),-a[i].y()); break;
+ case 3: r.setPoint(i,a[i].y(),-a[i].x()); break;
+ }
+ }
+ a = r;
+}
+
+
+/*!
+ \reimp
+*/
+void QMotifStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
+ const QWidget *w) const
+{
+ switch(pe) {
+ case PE_Q3CheckListExclusiveIndicator:
+ if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) {
+ if (lv->items.isEmpty())
+ return;
+
+ if (lv->state & State_Enabled)
+ p->setPen(QPen(opt->palette.text().color()));
+ else
+ p->setPen(QPen(lv->palette.color(QPalette::Disabled, QPalette::Text)));
+ QPolygon a;
+
+ int cx = opt->rect.width()/2 - 1;
+ int cy = opt->rect.height()/2;
+ int e = opt->rect.width()/2 - 1;
+ for (int i = 0; i < 3; i++) { //penWidth 2 doesn't quite work
+ a.setPoints(4, cx-e, cy, cx, cy-e, cx+e, cy, cx, cy+e);
+ p->drawPolygon(a);
+ e--;
+ }
+ if (opt->state & State_On) {
+ if (lv->state & State_Enabled)
+ p->setPen(QPen(opt->palette.text().color()));
+ else
+ p->setPen(QPen(lv->palette.color(QPalette::Disabled,
+ QPalette::Text)));
+ QBrush saveBrush = p->brush();
+ p->setBrush(opt->palette.text());
+ e = e - 2;
+ a.setPoints(4, cx-e, cy, cx, cy-e, cx+e, cy, cx, cy+e);
+ p->drawPolygon(a);
+ p->setBrush(saveBrush);
+ }
+ }
+ break;
+
+ case PE_FrameTabWidget:
+ case PE_FrameWindow:
+ qDrawShadePanel(p, opt->rect, opt->palette, QStyle::State_None, proxy()->pixelMetric(PM_DefaultFrameWidth));
+ break;
+ case PE_FrameFocusRect:
+ if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(opt)) {
+ if ((fropt->state & State_HasFocus) && focus && focus->isVisible()
+ && !(fropt->state & QStyle::State_Item))
+ break;
+ QCommonStyle::drawPrimitive(pe, opt, p, w);
+ }
+ break;
+
+ case PE_IndicatorToolBarHandle: {
+ p->save();
+ p->translate(opt->rect.x(), opt->rect.y());
+
+ QColor dark(opt->palette.dark().color());
+ QColor light(opt->palette.light().color());
+ int i;
+ if (opt->state & State_Horizontal) {
+ int h = opt->rect.height();
+ if (h > 6) {
+ if (opt->state & State_On)
+ p->fillRect(1, 1, 8, h - 2, opt->palette.highlight());
+ QPolygon a(2 * ((h-6)/3));
+ int y = 3 + (h%3)/2;
+ p->setPen(dark);
+ p->drawLine(8, 1, 8, h-2);
+ for (i=0; 2*i < a.size(); ++i) {
+ a.setPoint(2*i, 5, y+1+3*i);
+ a.setPoint(2*i+1, 2, y+2+3*i);
+ }
+ p->drawPoints(a);
+ p->setPen(light);
+ p->drawLine(9, 1, 9, h-2);
+ for (i=0; 2*i < a.size(); i++) {
+ a.setPoint(2*i, 4, y+3*i);
+ a.setPoint(2*i+1, 1, y+1+3*i);
+ }
+ p->drawPoints(a);
+ // if (drawBorder) {
+ // p->setPen(QPen(Qt::darkGray));
+ // p->drawLine(0, opt->rect.height() - 1,
+ // tbExtent, opt->rect.height() - 1);
+ // }
+ }
+ } else {
+ int w = opt->rect.width();
+ if (w > 6) {
+ if (opt->state & State_On)
+ p->fillRect(1, 1, w - 2, 9, opt->palette.highlight());
+ QPolygon a(2 * ((w-6)/3));
+
+ int x = 3 + (w%3)/2;
+ p->setPen(dark);
+ p->drawLine(1, 8, w-2, 8);
+ for (i=0; 2*i < a.size(); ++i) {
+ a.setPoint(2*i, x+1+3*i, 6);
+ a.setPoint(2*i+1, x+2+3*i, 3);
+ }
+ p->drawPoints(a);
+ p->setPen(light);
+ p->drawLine(1, 9, w-2, 9);
+ for (i=0; 2*i < a.size(); ++i) {
+ a.setPoint(2*i, x+3*i, 5);
+ a.setPoint(2*i+1, x+1+3*i, 2);
+ }
+ p->drawPoints(a);
+ // if (drawBorder) {
+ // p->setPen(QPen(Qt::darkGray));
+ // p->drawLine(opt->rect.width() - 1, 0,
+ // opt->rect.width() - 1, tbExtent);
+ // }
+ }
+ }
+ p->restore();
+ break; }
+
+ case PE_PanelButtonCommand:
+ case PE_PanelButtonBevel:
+ case PE_PanelButtonTool: {
+ QBrush fill;
+ if (opt->state & State_Sunken)
+ fill = opt->palette.brush(QPalette::Mid);
+ else if ((opt->state & State_On) && (opt->state & State_Enabled))
+ fill = QBrush(opt->palette.mid().color(), Qt::Dense4Pattern);
+ else
+ fill = opt->palette.brush(QPalette::Button);
+ if ((opt->state & State_Enabled || opt->state & State_On) || !(opt->state & State_AutoRaise))
+ qDrawShadePanel(p, opt->rect, opt->palette, bool(opt->state & (State_Sunken | State_On)),
+ proxy()->pixelMetric(PM_DefaultFrameWidth), &fill);
+ break; }
+
+ case PE_IndicatorCheckBox: {
+ bool on = opt->state & State_On;
+ bool down = opt->state & State_Sunken;
+ bool showUp = !(down ^ on);
+ QBrush fill = opt->palette.brush((showUp || opt->state & State_NoChange) ?QPalette::Button : QPalette::Mid);
+ if (opt->state & State_NoChange) {
+ qDrawPlainRect(p, opt->rect, opt->palette.text().color(),
+ 1, &fill);
+ p->drawLine(opt->rect.x() + opt->rect.width() - 1, opt->rect.y(),
+ opt->rect.x(), opt->rect.y() + opt->rect.height() - 1);
+ } else {
+ qDrawShadePanel(p, opt->rect, opt->palette, !showUp,
+ proxy()->pixelMetric(PM_DefaultFrameWidth), &fill);
+ }
+ if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText))
+ p->fillRect(opt->rect, QBrush(p->background().color(), Qt::Dense5Pattern));
+ break; }
+
+ case PE_IndicatorRadioButton: {
+#define INTARRLEN(x) sizeof(x)/(sizeof(int)*2)
+ int inner_pts[] = { // used for filling diamond
+ 2,opt->rect.height()/2,
+ opt->rect.width()/2,2,
+ opt->rect.width()-3,opt->rect.height()/2,
+ opt->rect.width()/2,opt->rect.height()-3
+ };
+ int top_pts[] = { // top (^) of diamond
+ 0,opt->rect.height()/2,
+ opt->rect.width()/2,0,
+ opt->rect.width()-2,opt->rect.height()/2-1,
+ opt->rect.width()-3,opt->rect.height()/2-1,
+ opt->rect.width()/2,1,
+ 1,opt->rect.height()/2,
+ 2,opt->rect.height()/2,
+ opt->rect.width()/2,2,
+ opt->rect.width()-4,opt->rect.height()/2-1
+ };
+ int bottom_pts[] = { // bottom (v) of diamond
+ 1,opt->rect.height()/2+1,
+ opt->rect.width()/2,opt->rect.height()-1,
+ opt->rect.width()-1,opt->rect.height()/2,
+ opt->rect.width()-2,opt->rect.height()/2,
+ opt->rect.width()/2,opt->rect.height()-2,
+ 2,opt->rect.height()/2+1,
+ 3,opt->rect.height()/2+1,
+ opt->rect.width()/2,opt->rect.height()-3,
+ opt->rect.width()-3,opt->rect.height()/2
+ };
+ bool on = opt->state & State_On;
+ bool down = opt->state & State_Sunken;
+ bool showUp = !(down ^ on);
+ QPen oldPen = p->pen();
+ QBrush oldBrush = p->brush();
+ QPolygon a(INTARRLEN(inner_pts), inner_pts);
+ p->setPen(Qt::NoPen);
+ p->setBrush(opt->palette.brush(showUp ? QPalette::Button : QPalette::Mid));
+ a.translate(opt->rect.x(), opt->rect.y());
+ p->drawPolygon(a);
+ p->setPen(showUp ? opt->palette.light().color() : opt->palette.dark().color());
+ p->setBrush(Qt::NoBrush);
+ a.setPoints(INTARRLEN(top_pts), top_pts);
+ a.translate(opt->rect.x(), opt->rect.y());
+ p->drawPolyline(a);
+ p->setPen(showUp ? opt->palette.dark().color() : opt->palette.light().color());
+ a.setPoints(INTARRLEN(bottom_pts), bottom_pts);
+ a.translate(opt->rect.x(), opt->rect.y());
+ p->drawPolyline(a);
+ if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText))
+ p->fillRect(opt->rect, QBrush(p->background().color(), Qt::Dense5Pattern));
+ p->setPen(oldPen);
+ p->setBrush(oldBrush);
+ break; }
+
+ case PE_IndicatorSpinUp:
+ case PE_IndicatorSpinPlus:
+ case PE_IndicatorSpinDown:
+ case PE_IndicatorSpinMinus:
+ case PE_IndicatorArrowUp:
+ case PE_IndicatorArrowDown:
+ case PE_IndicatorArrowRight:
+ case PE_IndicatorArrowLeft: {
+ QRect rect = opt->rect;
+ QPolygon bFill;
+ QPolygon bTop;
+ QPolygon bBot;
+ QPolygon bLeft;
+ if (pe == PE_IndicatorSpinPlus || pe == PE_IndicatorSpinUp)
+ pe = PE_IndicatorArrowUp;
+ else if (pe == PE_IndicatorSpinMinus || pe == PE_IndicatorSpinDown)
+ pe = PE_IndicatorArrowDown;
+ bool vertical = pe == PE_IndicatorArrowUp || pe == PE_IndicatorArrowDown;
+ bool horizontal = !vertical;
+ int dim = rect.width() < rect.height() ? rect.width() : rect.height();
+ int colspec = 0x0000;
+
+ if (!(opt->state & State_Enabled))
+ dim -= 2;
+ if(dim < 2)
+ break;
+
+ // adjust size and center (to fix rotation below)
+ if (rect.width() > dim) {
+ rect.setX(rect.x() + ((rect.width() - dim) / 2));
+ rect.setWidth(dim);
+ }
+ if (rect.height() > dim) {
+ rect.setY(rect.y() + ((rect.height() - dim) / 2));
+ rect.setHeight(dim);
+ }
+
+ if (dim > 3) {
+ if (pixelMetric(PM_DefaultFrameWidth) < 2) { // thin style
+ bFill.resize( dim & 1 ? 3 : 4 );
+ bTop.resize( 2 );
+ bBot.resize( 2 );
+ bLeft.resize( 2 );
+ bLeft.putPoints( 0, 2, 0, 0, 0, dim-1 );
+ bTop.putPoints( 0, 2, 1, 0, dim-1, dim/2 );
+ bBot.putPoints( 0, 2, 1, dim-1, dim-1, dim/2 );
+
+ if ( dim > 6 ) { // dim>6: must fill interior
+ bFill.putPoints( 0, 2, 0, dim-1, 0, 0 );
+ if ( dim & 1 ) // if size is an odd number
+ bFill.setPoint( 2, dim - 1, dim / 2 );
+ else
+ bFill.putPoints( 2, 2, dim-1, dim/2-1, dim-1, dim/2 );
+ }
+ } else {
+ if (dim > 6)
+ bFill.resize(dim & 1 ? 3 : 4);
+ bTop.resize((dim/2)*2);
+ bBot.resize(dim & 1 ? dim + 1 : dim);
+ bLeft.resize(dim > 4 ? 4 : 2);
+ bLeft.putPoints(0, 2, 0,0, 0,dim-1);
+ if (dim > 4)
+ bLeft.putPoints(2, 2, 1,2, 1,dim-3);
+ bTop.putPoints(0, 4, 1,0, 1,1, 2,1, 3,1);
+ bBot.putPoints(0, 4, 1,dim-1, 1,dim-2, 2,dim-2, 3,dim-2);
+
+ for(int i=0; i<dim/2-2 ; i++) {
+ bTop.putPoints(i*2+4, 2, 2+i*2,2+i, 5+i*2, 2+i);
+ bBot.putPoints(i*2+4, 2, 2+i*2,dim-3-i, 5+i*2,dim-3-i);
+ }
+ if (dim & 1) // odd number size: extra line
+ bBot.putPoints(dim-1, 2, dim-3,dim/2, dim-1,dim/2);
+ if (dim > 6) { // dim>6: must fill interior
+ bFill.putPoints(0, 2, 1,dim-3, 1,2);
+ if (dim & 1) // if size is an odd number
+ bFill.setPoint(2, dim - 3, dim / 2);
+ else
+ bFill.putPoints(2, 2, dim-4,dim/2-1, dim-4,dim/2);
+ }
+ }
+ } else {
+ if (dim == 3) { // 3x3 arrow pattern
+ bLeft.setPoints(4, 0,0, 0,2, 1,1, 1,1);
+ bTop .setPoints(2, 1,0, 1,0);
+ bBot .setPoints(2, 1,2, 2,1);
+ }
+ else { // 2x2 arrow pattern
+ bLeft.setPoints(2, 0,0, 0,1);
+ bTop .setPoints(2, 1,0, 1,0);
+ bBot .setPoints(2, 1,1, 1,1);
+ }
+ }
+
+ // We use rot() and translate() as it is more efficient that
+ // matrix transformations on the painter, and because it still
+ // works with QT_NO_TRANSFORMATIONS defined.
+
+ if (pe == PE_IndicatorArrowUp || pe == PE_IndicatorArrowLeft) {
+ if (vertical) {
+ rot(bFill,3);
+ rot(bLeft,3);
+ rot(bTop,3);
+ rot(bBot,3);
+ bFill.translate(0, rect.height() - 1);
+ bLeft.translate(0, rect.height() - 1);
+ bTop.translate(0, rect.height() - 1);
+ bBot.translate(0, rect.height() - 1);
+ } else {
+ rot(bFill,2);
+ rot(bLeft,2);
+ rot(bTop,2);
+ rot(bBot,2);
+ bFill.translate(rect.width() - 1, rect.height() - 1);
+ bLeft.translate(rect.width() - 1, rect.height() - 1);
+ bTop.translate(rect.width() - 1, rect.height() - 1);
+ bBot.translate(rect.width() - 1, rect.height() - 1);
+ }
+ if (opt->state & State_Sunken)
+ colspec = horizontal ? 0x2334 : 0x2343;
+ else
+ colspec = horizontal ? 0x1443 : 0x1434;
+ } else {
+ if (vertical) {
+ rot(bFill,1);
+ rot(bLeft,1);
+ rot(bTop,1);
+ rot(bBot,1);
+ bFill.translate(rect.width() - 1, 0);
+ bLeft.translate(rect.width() - 1, 0);
+ bTop.translate(rect.width() - 1, 0);
+ bBot.translate(rect.width() - 1, 0);
+ }
+ if (opt->state & State_Sunken)
+ colspec = horizontal ? 0x2443 : 0x2434;
+ else
+ colspec = horizontal ? 0x1334 : 0x1343;
+ }
+ bFill.translate(rect.x(), rect.y());
+ bLeft.translate(rect.x(), rect.y());
+ bTop.translate(rect.x(), rect.y());
+ bBot.translate(rect.x(), rect.y());
+
+ const QColor *cols[5];
+ if (opt->state & State_Enabled) {
+ cols[0] = 0;
+ cols[1] = &opt->palette.button().color();
+ cols[2] = &opt->palette.mid().color();
+ cols[3] = &opt->palette.light().color();
+ cols[4] = &opt->palette.dark().color();
+ } else {
+ cols[0] = 0;
+ cols[1] = &opt->palette.mid().color();
+ cols[2] = &opt->palette.mid().color();
+ cols[3] = &opt->palette.mid().color();
+ cols[4] = &opt->palette.mid().color();
+ }
+
+#define CMID *cols[(colspec>>12) & 0xf]
+#define CLEFT *cols[(colspec>>8) & 0xf]
+#define CTOP *cols[(colspec>>4) & 0xf]
+#define CBOT *cols[colspec & 0xf]
+
+ QPen savePen = p->pen();
+ QBrush saveBrush = p->brush();
+ QPen pen(Qt::NoPen);
+ QBrush brush = opt->palette.brush((opt->state & State_Enabled) ?
+ QPalette::Button : QPalette::Mid);
+ p->setPen(pen);
+ p->setBrush(brush);
+ p->drawPolygon(bFill);
+ p->setBrush(Qt::NoBrush);
+
+ p->setPen(CLEFT);
+ p->drawPolyline(bLeft);
+ p->setPen(CTOP);
+ p->drawPolyline(bTop);
+ p->setPen(CBOT);
+ p->drawPolyline(bBot);
+
+ p->setBrush(saveBrush);
+ p->setPen(savePen);
+#undef CMID
+#undef CLEFT
+#undef CTOP
+#undef CBOT
+ if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText))
+ p->fillRect(opt->rect, QBrush(p->background().color(), Qt::Dense5Pattern));
+ break; }
+
+ case PE_IndicatorDockWidgetResizeHandle: {
+ const int motifOffset = 10;
+ int sw = proxy()->pixelMetric(PM_SplitterWidth);
+ if (opt->state & State_Horizontal) {
+ int yPos = opt->rect.y() + opt->rect.height() / 2;
+ int kPos = opt->rect.right() - motifOffset - sw;
+ int kSize = sw - 2;
+
+ qDrawShadeLine(p, opt->rect.left(), yPos, kPos, yPos, opt->palette);
+ qDrawShadePanel(p, kPos, yPos - sw / 2 + 1, kSize, kSize,
+ opt->palette, false, 1, &opt->palette.brush(QPalette::Button));
+ qDrawShadeLine(p, kPos + kSize - 1, yPos, opt->rect.right(), yPos, opt->palette);
+ } else {
+ int xPos = opt->rect.x() + opt->rect.width() / 2;
+ int kPos = motifOffset;
+ int kSize = sw - 2;
+
+ qDrawShadeLine(p, xPos, opt->rect.top() + kPos + kSize - 1, xPos, opt->rect.bottom(), opt->palette);
+ qDrawShadePanel(p, xPos - sw / 2 + 1, opt->rect.top() + kPos, kSize, kSize, opt->palette,
+ false, 1, &opt->palette.brush(QPalette::Button));
+ qDrawShadeLine(p, xPos, opt->rect.top(), xPos, opt->rect.top() + kPos, opt->palette);
+ }
+ break; }
+
+ case PE_IndicatorMenuCheckMark: {
+ const int markW = 6;
+ const int markH = 6;
+ int posX = opt->rect.x() + (opt->rect.width() - markW) / 2 - 1;
+ int posY = opt->rect.y() + (opt->rect.height() - markH) / 2;
+ int dfw = proxy()->pixelMetric(PM_DefaultFrameWidth);
+
+ if (dfw < 2) {
+ // Could do with some optimizing/caching...
+ QPolygon a(7*2);
+ int i, xx, yy;
+ xx = posX;
+ yy = 3 + posY;
+ for (i=0; i<3; i++) {
+ a.setPoint(2*i, xx, yy);
+ a.setPoint(2*i+1, xx, yy+2);
+ xx++; yy++;
+ }
+ yy -= 2;
+ for (i=3; i<7; i++) {
+ a.setPoint(2*i, xx, yy);
+ a.setPoint(2*i+1, xx, yy+2);
+ xx++; yy--;
+ }
+ if (! (opt->state & State_Enabled) && ! (opt->state & State_On)) {
+ int pnt;
+ p->setPen(opt->palette.highlightedText().color());
+ QPoint offset(1,1);
+ for (pnt = 0; pnt < (int)a.size(); pnt++)
+ a[pnt] += offset;
+ p->drawPolyline(a);
+ for (pnt = 0; pnt < (int)a.size(); pnt++)
+ a[pnt] -= offset;
+ }
+ p->setPen(opt->palette.text().color());
+ p->drawPolyline(a);
+
+ qDrawShadePanel(p, posX-2, posY-2, markW+4, markH+6, opt->palette, true, dfw);
+ } else
+ qDrawShadePanel(p, posX, posY, markW, markH, opt->palette, true, dfw,
+ &opt->palette.brush(QPalette::Mid));
+
+ break; }
+
+ case PE_IndicatorProgressChunk:
+ {
+ bool vertical = false;
+ if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt))
+ vertical = (pb2->orientation == Qt::Vertical);
+ if (!vertical) {
+ p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width(),
+ opt->rect.height(), opt->palette.brush(QPalette::Highlight));
+ } else {
+ p->fillRect(opt->rect.x(), opt->rect.y(), opt->rect.width(), opt->rect.height(),
+ opt->palette.brush(QPalette::Highlight));
+ }
+ }
+ break;
+
+ default:
+ QCommonStyle::drawPrimitive(pe, opt, p, w);
+ break;
+ }
+}
+
+
+/*!
+ \reimp
+*/
+void QMotifStyle::drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
+ const QWidget *widget) const
+{
+ switch(element) {
+ case CE_Splitter: {
+ QStyleOption handleOpt = *opt;
+ if (handleOpt.state & State_Horizontal)
+ handleOpt.state &= ~State_Horizontal;
+ else
+ handleOpt.state |= State_Horizontal;
+ proxy()->drawPrimitive(PE_IndicatorDockWidgetResizeHandle, &handleOpt, p, widget);
+ break; }
+
+ case CE_ScrollBarSubLine:
+ case CE_ScrollBarAddLine:{
+ PrimitiveElement pe;
+ if (element == CE_ScrollBarAddLine)
+ pe = (opt->state & State_Horizontal) ? (opt->direction == Qt::LeftToRight ? PE_IndicatorArrowRight : PE_IndicatorArrowLeft) : PE_IndicatorArrowDown;
+ else
+ pe = (opt->state & State_Horizontal) ? (opt->direction == Qt::LeftToRight ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight) : PE_IndicatorArrowUp;
+ QStyleOption arrowOpt = *opt;
+ arrowOpt.state |= State_Enabled;
+ proxy()->drawPrimitive(pe, &arrowOpt, p, widget);
+ if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText)) {
+ int fw = proxy()->pixelMetric(PM_DefaultFrameWidth);
+ p->fillRect(opt->rect.adjusted(fw, fw, -fw, -fw), QBrush(p->background().color(), Qt::Dense5Pattern));
+ }
+ }break;
+
+ case CE_ScrollBarSubPage:
+ case CE_ScrollBarAddPage:
+ p->fillRect(opt->rect, opt->palette.brush((opt->state & State_Enabled) ? QPalette::Mid : QPalette::Window));
+ break;
+
+ case CE_ScrollBarSlider: {
+ QStyleOption bevelOpt = *opt;
+ bevelOpt.state |= State_Raised;
+ bevelOpt.state &= ~(State_Sunken | State_On);
+ p->save();
+ p->setBrushOrigin(bevelOpt.rect.topLeft());
+ proxy()->drawPrimitive(PE_PanelButtonBevel, &bevelOpt, p, widget);
+ p->restore();
+ if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText))
+ p->fillRect(opt->rect, QBrush(p->background().color(), Qt::Dense5Pattern));
+ break; }
+
+ case CE_RadioButton:
+ case CE_CheckBox:
+ if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
+ bool isRadio = (element == CE_RadioButton);
+ QStyleOptionButton subopt = *btn;
+ subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator
+ : SE_CheckBoxIndicator, btn, widget);
+ proxy()->drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox,
+ &subopt, p, widget);
+ subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents
+ : SE_CheckBoxContents, btn, widget);
+ proxy()->drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, p, widget);
+ if ((btn->state & State_HasFocus) && (!focus || !focus->isVisible())) {
+ QStyleOptionFocusRect fropt;
+ fropt.QStyleOption::operator=(*btn);
+ fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect
+ : SE_CheckBoxFocusRect, btn, widget);
+ proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
+ }
+ }
+ break;
+ case CE_PushButton:
+ if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
+ proxy()->drawControl(CE_PushButtonBevel, btn, p, widget);
+ QStyleOptionButton subopt = *btn;
+ subopt.rect = subElementRect(SE_PushButtonContents, btn, widget);
+ proxy()->drawControl(CE_PushButtonLabel, &subopt, p, widget);
+ if ((btn->state & State_HasFocus) && (!focus || !focus->isVisible())) {
+ QStyleOptionFocusRect fropt;
+ fropt.QStyleOption::operator=(*btn);
+ fropt.rect = subElementRect(SE_PushButtonFocusRect, btn, widget);
+ proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
+ }
+ }
+ break;
+ case CE_PushButtonBevel:
+ if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
+ int diw, x1, y1, x2, y2;
+ p->setPen(opt->palette.foreground().color());
+ p->setBrush(QBrush(opt->palette.button().color(), Qt::NoBrush));
+ diw = proxy()->pixelMetric(PM_ButtonDefaultIndicator);
+ opt->rect.getCoords(&x1, &y1, &x2, &y2);
+ if (btn->features & (QStyleOptionButton::AutoDefaultButton|QStyleOptionButton::DefaultButton)) {
+ x1 += diw;
+ y1 += diw;
+ x2 -= diw;
+ y2 -= diw;
+ }
+ if (btn->features & QStyleOptionButton::DefaultButton) {
+ if (diw == 0) {
+ QPolygon a;
+ a.setPoints(9,
+ x1, y1, x2, y1, x2, y2, x1, y2, x1, y1+1,
+ x2-1, y1+1, x2-1, y2-1, x1+1, y2-1, x1+1, y1+1);
+ p->setPen(opt->palette.shadow().color());
+ p->drawPolygon(a);
+ x1 += 2;
+ y1 += 2;
+ x2 -= 2;
+ y2 -= 2;
+ } else {
+ qDrawShadePanel(p, opt->rect.adjusted(1, 1, -1, -1), opt->palette, true);
+ }
+ }
+ if (!(btn->features & QStyleOptionButton::Flat) ||
+ (btn->state & (State_Sunken | State_On))) {
+ QStyleOptionButton newOpt = *btn;
+ newOpt.rect = QRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
+ p->setBrushOrigin(p->brushOrigin());
+ proxy()->drawPrimitive(PE_PanelButtonCommand, &newOpt, p, widget);
+ }
+ if (btn->features & QStyleOptionButton::HasMenu) {
+ int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, btn, widget);
+ QRect ir = btn->rect;
+ QStyleOptionButton newBtn = *btn;
+ newBtn.rect = QRect(ir.right() - mbi - 3, ir.y() + 4, mbi, ir.height() - 8);
+ proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget);
+ }
+ break;
+ }
+
+#ifndef QT_NO_TABBAR
+ case CE_TabBarTabShape:
+ if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
+ const int default_frame = proxy()->pixelMetric(PM_DefaultFrameWidth, tab, widget);
+ const int frame_offset = (default_frame > 1) ? 1 : 0;
+
+ if (tab->shape == QTabBar::RoundedNorth || tab->shape == QTabBar::RoundedEast ||
+ tab->shape == QTabBar::RoundedSouth || tab->shape == QTabBar::RoundedWest) {
+ p->save();
+ QRect tabRect = opt->rect;
+ QColor tabLight = opt->palette.light().color();
+ QColor tabDark = opt->palette.dark().color();
+
+ p->fillRect(opt->rect.adjusted(default_frame, default_frame,
+ -default_frame, -default_frame),
+ tab->palette.background());
+
+ if(tab->shape == QTabBar::RoundedWest) {
+ tabDark = opt->palette.light().color();
+ tabLight = opt->palette.dark().color();
+ tabRect = QRect(0, 0, tabRect.height(), tabRect.width());
+ p->translate(opt->rect.left(), opt->rect.bottom());
+ p->rotate(-90);
+ } else if(tab->shape == QTabBar::RoundedSouth) {
+ tabDark = opt->palette.light().color();
+ tabLight = opt->palette.dark().color();
+ tabRect = QRect(0, 0, tabRect.width(), tabRect.height());
+ p->translate(opt->rect.right(), opt->rect.bottom());
+ p->rotate(180);
+ } else if(tab->shape == QTabBar::RoundedEast) {
+ tabRect = QRect(0, 0, tabRect.height(), tabRect.width());
+ p->translate(opt->rect.right(), opt->rect.top());
+ p->rotate(90);
+ }
+
+ if (default_frame > 1) {
+ p->setPen(tabLight);
+ p->drawLine(tabRect.left(), tabRect.bottom(),
+ tabRect.right(), tabRect.bottom());
+ p->setPen(tabLight);
+ p->drawLine(tabRect.left(), tabRect.bottom()-1,
+ tabRect.right(), tabRect.bottom()-1);
+ if (tabRect.left() == 0)
+ p->drawPoint(tabRect.bottomLeft());
+ } else {
+ p->setPen(tabLight);
+ p->drawLine(tabRect.left(), tabRect.bottom(),
+ tabRect.right(), tabRect.bottom());
+ }
+
+ if (opt->state & State_Selected) {
+ p->fillRect(QRect(tabRect.left()+1, tabRect.bottom()-frame_offset,
+ tabRect.width()-3, 2),
+ tab->palette.brush(QPalette::Active, QPalette::Background));
+ p->setPen(tab->palette.background().color());
+ p->drawLine(tabRect.left()+1, tabRect.bottom(),
+ tabRect.left()+1, tabRect.top()+2);
+ p->setPen(tabLight);
+ } else {
+ p->setPen(tabLight);
+ }
+ p->drawLine(tabRect.left(), tabRect.bottom()-1,
+ tabRect.left(), tabRect.top() + 2);
+ p->drawPoint(tabRect.left()+1, tabRect.top() + 1);
+ p->drawLine(tabRect.left()+2, tabRect.top(),
+ tabRect.right() - 2, tabRect.top());
+ p->drawPoint(tabRect.left(), tabRect.bottom());
+
+ if (default_frame > 1) {
+ p->drawLine(tabRect.left()+1, tabRect.bottom(),
+ tabRect.left()+1, tabRect.top() + 2);
+ p->drawLine(tabRect.left()+2, tabRect.top()+1,
+ tabRect.right() - 2, tabRect.top()+1);
+ }
+
+ p->setPen(tabDark);
+ p->drawLine(tabRect.right() - 1, tabRect.top() + 2,
+ tabRect.right() - 1, tabRect.bottom() - 1 +
+ ((opt->state & State_Selected) ? frame_offset : -frame_offset));
+ if (default_frame > 1) {
+ p->drawPoint(tabRect.right() - 1, tabRect.top() + 1);
+ p->drawLine(tabRect.right(), tabRect.top() + 2, tabRect.right(),
+ tabRect.bottom() -
+ ((opt->state & State_Selected) ?
+ ((tab->position == QStyleOptionTab::End) ? 0:1):1+frame_offset));
+ p->drawPoint(tabRect.right() - 1, tabRect.top() + 1);
+ }
+ p->restore();
+ } else {
+ QCommonStyle::drawControl(element, opt, p, widget);
+ }
+ break; }
+#endif // QT_NO_TABBAR
+ case CE_ProgressBarGroove:
+ qDrawShadePanel(p, opt->rect, opt->palette, true, 2);
+ break;
+
+ case CE_ProgressBarLabel:
+ if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
+ QTransform oldMatrix = p->transform();
+ QRect rect = pb->rect;
+ bool vertical = false;
+ bool invert = false;
+ bool bottomToTop = false;
+ if (const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
+ vertical = (pb2->orientation == Qt::Vertical);
+ invert = pb2->invertedAppearance;
+ bottomToTop = pb2->bottomToTop;
+ }
+ if (vertical) {
+ QTransform m;
+ rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height
+ if (bottomToTop) {
+ m.translate(0.0, rect.width());
+ m.rotate(-90);
+ } else {
+ m.translate(rect.height(), 0.0);
+ m.rotate(90);
+ }
+ p->setTransform(m, true);
+ }
+ const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, opt, widget);
+ int u = rect.width() / unit_width;
+ int p_v = pb->progress - pb->minimum;
+ int t_s = qMax(0, pb->maximum - pb->minimum);
+ if (u > 0 && pb->progress >= INT_MAX / u && t_s >= u) {
+ // scale down to something usable.
+ p_v /= u;
+ t_s /= u;
+ }
+ if (pb->textVisible && t_s) {
+ int nu = (u * p_v + t_s/2) / t_s;
+ int x = unit_width * nu;
+ QRect left(rect.x(), rect.y(), x, rect.height());
+ QRect right(rect.x() + x, rect.y(), rect.width() - x, rect.height());
+ Qt::LayoutDirection dir;
+ dir = vertical ? (bottomToTop ? Qt::LeftToRight : Qt::RightToLeft) : pb->direction;
+ if (invert)
+ dir = (dir == Qt::LeftToRight) ? Qt::RightToLeft : Qt::LeftToRight;
+ const QRect highlighted = visualRect(dir, rect, left);
+ const QRect background = visualRect(dir, rect, right);
+ p->setPen(opt->palette.highlightedText().color());
+ p->setClipRect(highlighted);
+ p->drawText(rect, Qt::AlignCenter | Qt::TextSingleLine, pb->text);
+
+ if (pb->progress != pb->maximum) {
+ p->setClipRect(background);
+ p->setPen(opt->palette.highlight().color());
+ p->drawText(rect, Qt::AlignCenter | Qt::TextSingleLine, pb->text);
+ }
+ }
+ p->setTransform(oldMatrix, false);
+ break;
+ }
+
+ case CE_MenuTearoff: {
+ if(opt->state & State_Selected) {
+ if(pixelMetric(PM_MenuPanelWidth, opt, widget) > 1)
+ qDrawShadePanel(p, opt->rect.x(), opt->rect.y(), opt->rect.width(),
+ opt->rect.height(), opt->palette, false, motifItemFrame,
+ &opt->palette.brush(QPalette::Button));
+ else
+ qDrawShadePanel(p, opt->rect.x()+1, opt->rect.y()+1, opt->rect.width()-2,
+ opt->rect.height()-2, opt->palette, true, 1, &opt->palette.brush(QPalette::Button));
+ } else {
+ p->fillRect(opt->rect, opt->palette.brush(QPalette::Button));
+ }
+ p->setPen(QPen(opt->palette.dark().color(), 1, Qt::DashLine));
+ p->drawLine(opt->rect.x()+2, opt->rect.y()+opt->rect.height()/2-1, opt->rect.x()+opt->rect.width()-4,
+ opt->rect.y()+opt->rect.height()/2-1);
+ p->setPen(QPen(opt->palette.light().color(), 1, Qt::DashLine));
+ p->drawLine(opt->rect.x()+2, opt->rect.y()+opt->rect.height()/2, opt->rect.x()+opt->rect.width()-4,
+ opt->rect.y()+opt->rect.height()/2);
+ break; }
+
+ case CE_MenuItem:
+ if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
+ int maxpmw = menuitem->maxIconWidth;
+ if(menuitem->menuHasCheckableItems)
+ maxpmw = qMax(maxpmw, motifCheckMarkSpace);
+
+ int x, y, w, h;
+ opt->rect.getRect(&x, &y, &w, &h);
+
+ if (menuitem->menuItemType == QStyleOptionMenuItem::Separator) { // draw separator
+ int textWidth = 0;
+ if (!menuitem->text.isEmpty()) {
+ QFont oldFont = p->font();
+ p->setFont(menuitem->font);
+ p->fillRect(x, y, w, h, opt->palette.brush(QPalette::Button));
+ proxy()->drawItemText(p, menuitem->rect.adjusted(10, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter,
+ menuitem->palette, menuitem->state & State_Enabled, menuitem->text,
+ QPalette::Text);
+ textWidth = menuitem->fontMetrics.width(menuitem->text) + 10;
+ y += menuitem->fontMetrics.height() / 2;
+ p->setFont(oldFont);
+ }
+ p->setPen(opt->palette.dark().color());
+ p->drawLine(x, y, x + 5, y);
+ p->drawLine(x + 5 + textWidth, y, x+w, y);
+ p->setPen(opt->palette.light().color());
+ p->drawLine(x, y + 1, x + 5, y + 1);
+ p->drawLine(x + 5 + textWidth, y + 1, x+w, y + 1);
+ return;
+ }
+
+ int pw = motifItemFrame;
+ if((opt->state & State_Selected) && (opt->state & State_Enabled)) { // active item frame
+ if(pixelMetric(PM_MenuPanelWidth, opt) > 1)
+ qDrawShadePanel(p, x, y, w, h, opt->palette, false, pw,
+ &opt->palette.brush(QPalette::Button));
+ else
+ qDrawShadePanel(p, x+1, y+1, w-2, h-2, opt->palette, true, 1,
+ &opt->palette.brush(QPalette::Button));
+ } else { // incognito frame
+ p->fillRect(x, y, w, h, opt->palette.brush(QPalette::Button));
+ }
+
+ QRect vrect = visualRect(opt->direction, opt->rect,
+ QRect(x+motifItemFrame, y+motifItemFrame, maxpmw,
+ h-2*motifItemFrame));
+ int xvis = vrect.x();
+ if (menuitem->checked) {
+ if(!menuitem->icon.isNull())
+ qDrawShadePanel(p, xvis, y+motifItemFrame, maxpmw, h-2*motifItemFrame,
+ opt->palette, true, 1, &opt->palette.brush(QPalette::Midlight));
+ } else if (!(opt->state & State_Selected)) {
+ p->fillRect(xvis, y+motifItemFrame, maxpmw, h-2*motifItemFrame,
+ opt->palette.brush(QPalette::Button));
+ }
+
+ if(!menuitem->icon.isNull()) { // draw icon
+ QIcon::Mode mode = QIcon::Normal; // no disabled icons in Motif
+ if ((opt->state & State_Selected) && !!(opt->state & State_Enabled))
+ mode = QIcon::Active;
+ QPixmap pixmap;
+ if (menuitem->checkType != QStyleOptionMenuItem::NotCheckable && menuitem->checked)
+ pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize, opt, widget), mode, QIcon::On);
+ else
+ pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize, opt, widget), mode);
+
+ int pixw = pixmap.width();
+ int pixh = pixmap.height();
+ QRect pmr(0, 0, pixw, pixh);
+ pmr.moveCenter(vrect.center());
+ p->setPen(opt->palette.text().color());
+ p->drawPixmap(pmr.topLeft(), pixmap);
+
+ } else if (menuitem->checkType != QStyleOptionMenuItem::NotCheckable) { // just "checking"...
+ int mh = h - 2*motifItemFrame;
+
+ QStyleOptionButton newMenuItem;
+ newMenuItem.state = menuitem->checked ? State_On : State_None;
+ if (opt->state & State_Enabled) {
+ newMenuItem.state |= State_Enabled;
+ if (menuitem->state & State_Sunken)
+ newMenuItem.state |= State_Sunken;
+ }
+ if (menuitem->checkType & QStyleOptionMenuItem::Exclusive) {
+ newMenuItem.rect.setRect(xvis + 2, y + motifItemFrame + mh / 4, 11, 11);
+ proxy()->drawPrimitive(PE_IndicatorRadioButton, &newMenuItem, p, widget);
+ } else {
+ newMenuItem.rect.setRect(xvis + 5, y + motifItemFrame + mh / 4, 9, 9);
+ proxy()->drawPrimitive(PE_IndicatorCheckBox, &newMenuItem, p, widget);
+ }
+ }
+
+ p->setPen(opt->palette.buttonText().color());
+
+ QColor discol;
+ if (!(opt->state & State_Enabled)) {
+ discol = opt->palette.text().color();
+ p->setPen(discol);
+ }
+
+ int xm = motifItemFrame + maxpmw + motifItemHMargin;
+
+ vrect = visualRect(opt->direction, opt->rect,
+ QRect(x+xm, y+motifItemVMargin, w-xm-menuitem->tabWidth,
+ h-2*motifItemVMargin));
+ xvis = vrect.x();
+
+ QString s = menuitem->text;
+ if (!s.isNull()) { // draw text
+ int t = s.indexOf(QLatin1Char('\t'));
+ int m = motifItemVMargin;
+ int text_flags = Qt::AlignVCenter|Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
+ text_flags |= Qt::AlignLeft;
+ QFont oldFont = p->font();
+ p->setFont(menuitem->font);
+ if (t >= 0) { // draw tab text
+ QRect vr = visualRect(opt->direction, opt->rect,
+ QRect(x+w-menuitem->tabWidth-motifItemHMargin-motifItemFrame,
+ y+motifItemVMargin, menuitem->tabWidth,
+ h-2*motifItemVMargin));
+ int xv = vr.x();
+ QRect tr(xv, y+m, menuitem->tabWidth, h-2*m);
+ p->drawText(tr, text_flags, s.mid(t+1));
+ if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText))
+ p->fillRect(tr, QBrush(p->background().color(), Qt::Dense5Pattern));
+ s = s.left(t);
+ }
+ QRect tr(xvis, y+m, w - xm - menuitem->tabWidth + 1, h-2*m);
+ p->drawText(tr, text_flags, s.left(t));
+ p->setFont(oldFont);
+ if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText))
+ p->fillRect(tr, QBrush(p->background().color(), Qt::Dense5Pattern));
+ }
+ if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) { // draw sub menu arrow
+ int dim = (h-2*motifItemFrame) / 2;
+ QStyle::PrimitiveElement arrow = (opt->direction == Qt::RightToLeft ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight);
+ QStyleOption arrowOpt = *opt;
+ arrowOpt.rect = visualRect(opt->direction, opt->rect,
+ QRect(x+w - motifArrowHMargin - motifItemFrame - dim,
+ y+h/2-dim/2, dim, dim));
+ if ((opt->state & State_Selected))
+ arrowOpt.state = (State_Sunken | ((opt->state & State_Enabled) ? State_Enabled : State_None));
+ else
+ arrowOpt.state = ((opt->state & State_Enabled) ? State_Enabled : State_None);
+ proxy()->drawPrimitive(arrow, &arrowOpt, p, widget);
+ }
+ break; }
+
+ case CE_MenuBarItem:
+ if (opt->state & State_Selected) // active item
+ qDrawShadePanel(p, opt->rect, opt->palette, false, motifItemFrame,
+ &opt->palette.brush(QPalette::Button));
+ else // other item
+ p->fillRect(opt->rect, opt->palette.brush(QPalette::Button));
+ QCommonStyle::drawControl(element, opt, p, widget);
+ break;
+
+ case CE_HeaderSection:
+ p->save();
+ p->setBrushOrigin(opt->rect.topLeft());
+ qDrawShadePanel(p, opt->rect, opt->palette, bool(opt->state & (State_Sunken|State_On)),
+ proxy()->pixelMetric(PM_DefaultFrameWidth),
+ &opt->palette.brush((opt->state & State_Sunken) ? QPalette::Mid : QPalette::Button));
+ p->restore();
+ break;
+ case CE_RubberBand: {
+ QPixmap tiledPixmap(16, 16);
+ QPainter pixmapPainter(&tiledPixmap);
+ pixmapPainter.setPen(Qt::NoPen);
+ pixmapPainter.setBrush(Qt::Dense4Pattern);
+ pixmapPainter.setBackground(QBrush(opt->palette.base()));
+ pixmapPainter.setBackgroundMode(Qt::OpaqueMode);
+ pixmapPainter.drawRect(0, 0, tiledPixmap.width(), tiledPixmap.height());
+ pixmapPainter.end();
+ // ### workaround for borked XRENDER
+ tiledPixmap = QPixmap::fromImage(tiledPixmap.toImage());
+
+ p->save();
+ QRect r = opt->rect;
+ QStyleHintReturnMask mask;
+ if (styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask))
+ p->setClipRegion(mask.region);
+ p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap);
+ p->restore();
+ }
+ break;
+#ifndef QT_NO_PROGRESSBAR
+ case CE_ProgressBarContents:
+ if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
+ QRect rect = pb->rect;
+ bool vertical = false;
+ bool inverted = false;
+
+ // Get extra style options if version 2
+ const QStyleOptionProgressBarV2 *pb2 = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt);
+ if (pb2) {
+ vertical = (pb2->orientation == Qt::Vertical);
+ inverted = pb2->invertedAppearance;
+ }
+
+ QTransform m;
+ if (vertical) {
+ rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height
+ m.rotate(90);
+ m.translate(0, -(rect.height() + rect.y()*2));
+ }
+
+ QPalette pal2 = pb->palette;
+ // Correct the highlight color if it is the same as the background
+ if (pal2.highlight() == pal2.background())
+ pal2.setColor(QPalette::Highlight, pb->palette.color(QPalette::Active,
+ QPalette::Highlight));
+ bool reverse = ((!vertical && (pb->direction == Qt::RightToLeft)) || vertical);
+ if (inverted)
+ reverse = !reverse;
+ int w = rect.width();
+ if (pb->minimum == 0 && pb->maximum == 0) {
+ QRect progressBar;
+ Q_D(const QMotifStyle);
+ // draw busy indicator
+ int x = (d->animateStep*8)% (w * 2);
+ if (x > w)
+ x = 2 * w - x;
+ x = reverse ? rect.right() - x : x + rect.x();
+ p->setTransform(m, true);
+ p->setPen(QPen(pal2.highlight().color(), 4));
+ p->drawLine(x, rect.y(), x, rect.height());
+
+ } else
+ QCommonStyle::drawControl(element, opt, p, widget);
+ }
+ break;
+#endif // QT_NO_PROGRESSBAR
+ default:
+ QCommonStyle::drawControl(element, opt, p, widget);
+ break; }
+}
+
+static int get_combo_extra_width(int h, int w, int *return_awh=0)
+{
+ int awh,
+ tmp;
+ if (h < 8) {
+ awh = 6;
+ } else if (h < 14) {
+ awh = h - 2;
+ } else {
+ awh = h/2;
+ }
+ tmp = (awh * 3) / 2;
+ if (tmp > w / 2) {
+ awh = w / 2 - 3;
+ tmp = w / 2 + 3;
+ }
+
+ if (return_awh)
+ *return_awh = awh;
+
+ return tmp;
+}
+
+static void get_combo_parameters(const QRect &r,
+ int &ew, int &awh, int &ax,
+ int &ay, int &sh, int &dh,
+ int &sy)
+{
+ ew = get_combo_extra_width(r.height(), r.width(), &awh);
+
+ sh = (awh+3)/4;
+ if (sh < 3)
+ sh = 3;
+ dh = sh/2 + 1;
+
+ ay = r.y() + (r.height()-awh-sh-dh)/2;
+ if (ay < 0) {
+ //panic mode
+ ay = 0;
+ sy = r.height();
+ } else {
+ sy = ay+awh+dh;
+ }
+ ax = r.x() + r.width() - ew;
+ ax += (ew-awh)/2;
+}
+
+/*!
+ \reimp
+*/
+void QMotifStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
+ const QWidget *widget) const
+{
+ switch (cc) {
+ case CC_ToolButton:
+ if (const QStyleOptionToolButton *toolbutton
+ = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
+ QRect button, menuarea;
+ button = proxy()->subControlRect(cc, toolbutton, SC_ToolButton, widget);
+ menuarea = proxy()->subControlRect(cc, toolbutton, SC_ToolButtonMenu, widget);
+
+ State bflags = toolbutton->state & ~State_Sunken;
+ if (bflags & State_AutoRaise) {
+ if (!(bflags & State_MouseOver) || !(bflags & State_Enabled)) {
+ bflags &= ~State_Raised;
+ }
+ }
+ State mflags = bflags;
+ if (toolbutton->state & State_Sunken) {
+ if (toolbutton->activeSubControls & SC_ToolButton)
+ bflags |= State_Sunken;
+ mflags |= State_Sunken;
+ }
+
+ QStyleOption tool(0);
+ tool.palette = toolbutton->palette;
+ if (toolbutton->subControls & SC_ToolButton) {
+ if (bflags & (State_Sunken | State_On | State_Raised)) {
+ tool.rect = button;
+ tool.state = bflags;
+ proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget);
+ }
+ }
+
+ if ((toolbutton->state & State_HasFocus) && (!focus || !focus->isVisible())) {
+ QStyleOptionFocusRect fr;
+ fr.QStyleOption::operator=(*toolbutton);
+ fr.rect = toolbutton->rect.adjusted(3, 3, -3, -3);
+ proxy()->drawPrimitive(PE_FrameFocusRect, &fr, p, widget);
+ }
+ QStyleOptionToolButton label = *toolbutton;
+ label.state = bflags;
+ int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget);
+ label.rect = button.adjusted(fw, fw, -fw, -fw);
+ proxy()->drawControl(CE_ToolButtonLabel, &label, p, widget);
+
+ if (toolbutton->subControls & SC_ToolButtonMenu) {
+ tool.rect = menuarea;
+ tool.state = mflags;
+ if (mflags & (State_Sunken | State_On | State_Raised))
+ proxy()->drawPrimitive(PE_IndicatorButtonDropDown, &tool, p, widget);
+ proxy()->drawPrimitive(PE_IndicatorArrowDown, &tool, p, widget);
+ } else if (toolbutton->features & QStyleOptionToolButton::HasMenu) {
+ int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, toolbutton, widget);
+ QRect ir = toolbutton->rect;
+ QStyleOptionToolButton newBtn = *toolbutton;
+ newBtn.rect = QRect(ir.right() + 5 - mbi, ir.height() - mbi + 4, mbi - 6, mbi - 6);
+ proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget);
+ }
+ }
+ break;
+#ifndef QT_NO_SPINBOX
+ case CC_SpinBox:
+ if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
+ QStyleOptionSpinBox copy = *spinbox;
+ PrimitiveElement pe;
+
+ if (spinbox->frame && (spinbox->subControls & SC_SpinBoxFrame)) {
+ QRect r = proxy()->subControlRect(CC_SpinBox, spinbox, SC_SpinBoxFrame, widget);
+ qDrawShadePanel(p, r, opt->palette, false, proxy()->pixelMetric(PM_SpinBoxFrameWidth));
+
+ int fw = proxy()->pixelMetric(QStyle::PM_DefaultFrameWidth);
+ r = proxy()->subControlRect(CC_SpinBox, spinbox, SC_SpinBoxEditField, widget).adjusted(-fw,-fw,fw,fw);
+ QStyleOptionFrame lineOpt;
+ lineOpt.QStyleOption::operator=(*opt);
+ lineOpt.rect = r;
+ lineOpt.lineWidth = fw;
+ lineOpt.midLineWidth = 0;
+ lineOpt.state |= QStyle::State_Sunken;
+ proxy()->drawPrimitive(QStyle::PE_FrameLineEdit, &lineOpt, p, widget);
+ }
+
+ if (spinbox->subControls & SC_SpinBoxUp) {
+ copy.subControls = SC_SpinBoxUp;
+ QPalette pal2 = spinbox->palette;
+ if (!(spinbox->stepEnabled & QAbstractSpinBox::StepUpEnabled)) {
+ pal2.setCurrentColorGroup(QPalette::Disabled);
+ copy.state &= ~State_Enabled;
+ }
+
+ copy.palette = pal2;
+
+ if (spinbox->activeSubControls == SC_SpinBoxUp && (spinbox->state & State_Sunken)) {
+ copy.state |= State_On;
+ copy.state |= State_Sunken;
+ } else {
+ copy.state |= State_Raised;
+ copy.state &= ~State_Sunken;
+ }
+ pe = (spinbox->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus
+ : PE_IndicatorSpinUp);
+
+ copy.rect = proxy()->subControlRect(CC_SpinBox, spinbox, SC_SpinBoxUp, widget);
+ proxy()->drawPrimitive(pe, &copy, p, widget);
+ }
+
+ if (spinbox->subControls & SC_SpinBoxDown) {
+ copy.subControls = SC_SpinBoxDown;
+ copy.state = spinbox->state;
+ QPalette pal2 = spinbox->palette;
+ if (!(spinbox->stepEnabled & QAbstractSpinBox::StepDownEnabled)) {
+ pal2.setCurrentColorGroup(QPalette::Disabled);
+ copy.state &= ~State_Enabled;
+ }
+ copy.palette = pal2;
+
+ if (spinbox->activeSubControls == SC_SpinBoxDown && (spinbox->state & State_Sunken)) {
+ copy.state |= State_On;
+ copy.state |= State_Sunken;
+ } else {
+ copy.state |= State_Raised;
+ copy.state &= ~State_Sunken;
+ }
+ pe = (spinbox->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus
+ : PE_IndicatorSpinDown);
+
+ copy.rect = proxy()->subControlRect(CC_SpinBox, spinbox, SC_SpinBoxDown, widget);
+ proxy()->drawPrimitive(pe, &copy, p, widget);
+ }
+ }
+ break;
+#endif // QT_NO_SPINBOX
+#ifndef QT_NO_SLIDER
+ case CC_Slider:
+ if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
+ QRect groove = proxy()->subControlRect(CC_Slider, opt, SC_SliderGroove, widget),
+ handle = proxy()->subControlRect(CC_Slider, opt, SC_SliderHandle, widget);
+
+ if ((opt->subControls & SC_SliderGroove) && groove.isValid()) {
+ qDrawShadePanel(p, groove, opt->palette, true, proxy()->pixelMetric(PM_DefaultFrameWidth),
+ &opt->palette.brush((opt->state & State_Enabled) ? QPalette::Mid : QPalette::Window));
+ if ((opt->state & State_HasFocus) && (!focus || !focus->isVisible())) {
+ QStyleOption focusOpt = *opt;
+ focusOpt.rect = subElementRect(SE_SliderFocusRect, opt, widget);
+ proxy()->drawPrimitive(PE_FrameFocusRect, &focusOpt, p, widget);
+ }
+ }
+
+ if ((opt->subControls & SC_SliderHandle) && handle.isValid()) {
+ QStyleOption bevelOpt = *opt;
+ bevelOpt.state = (opt->state | State_Raised) & ~State_Sunken;
+ bevelOpt.rect = handle;
+ p->save();
+ p->setBrushOrigin(bevelOpt.rect.topLeft());
+ proxy()->drawPrimitive(PE_PanelButtonBevel, &bevelOpt, p, widget);
+ p->restore();
+
+ if (slider->orientation == Qt::Horizontal) {
+ int mid = handle.x() + handle.width() / 2;
+ qDrawShadeLine(p, mid, handle.y(), mid, handle.y() + handle.height() - 2,
+ opt->palette, true, 1);
+ } else {
+ int mid = handle.y() + handle.height() / 2;
+ qDrawShadeLine(p, handle.x(), mid, handle.x() + handle.width() - 2, mid, opt->palette,
+ true, 1);
+ }
+ if (!(opt->state & State_Enabled) && proxy()->styleHint(SH_DitherDisabledText))
+ p->fillRect(handle, QBrush(p->background().color(), Qt::Dense5Pattern));
+ }
+
+ if (slider->subControls & SC_SliderTickmarks) {
+ QStyleOptionSlider tmpSlider = *slider;
+ tmpSlider.subControls = SC_SliderTickmarks;
+ int frameWidth = proxy()->pixelMetric(PM_DefaultFrameWidth);
+ tmpSlider.rect.translate(frameWidth - 1, 0);
+ QCommonStyle::drawComplexControl(cc, &tmpSlider, p, widget);
+ }
+ }
+ break;
+#endif // QT_NO_SLIDER
+ case CC_ComboBox:
+ if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
+ if (opt->subControls & SC_ComboBoxArrow) {
+ int awh, ax, ay, sh, sy, dh, ew;
+ int fw = cb->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth, opt, widget) : 0;
+
+ if (cb->frame) {
+ QStyleOptionButton btn;
+ btn.QStyleOption::operator=(*cb);
+ btn.state |= QStyle::State_Raised;
+ proxy()->drawPrimitive(PE_PanelButtonCommand, &btn, p, widget);
+ } else {
+ p->fillRect(opt->rect, opt->palette.brush(QPalette::Button));
+ }
+
+ QRect tr = opt->rect;
+ tr.adjust(fw, fw, -fw, -fw);
+ get_combo_parameters(tr, ew, awh, ax, ay, sh, dh, sy);
+
+ QRect ar = QStyle::visualRect(opt->direction, opt->rect, QRect(ax,ay,awh,awh));
+
+ QStyleOption arrowOpt = *opt;
+ arrowOpt.rect = ar;
+ arrowOpt.state |= State_Enabled;
+ proxy()->drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget);
+
+
+ // draws the shaded line under the arrow
+ p->setPen(opt->palette.light().color());
+ p->drawLine(ar.x(), sy, ar.x()+awh-1, sy);
+ p->drawLine(ar.x(), sy, ar.x(), sy+sh-1);
+ p->setPen(opt->palette.dark().color());
+ p->drawLine(ar.x()+1, sy+sh-1, ar.x()+awh-1, sy+sh-1);
+ p->drawLine(ar.x()+awh-1, sy+1, ar.x()+awh-1, sy+sh-1);
+
+ if ((cb->state & State_HasFocus) && (!focus || !focus->isVisible())) {
+ QStyleOptionFocusRect focus;
+ focus.QStyleOption::operator=(*opt);
+ focus.rect = subElementRect(SE_ComboBoxFocusRect, opt, widget);
+ focus.backgroundColor = opt->palette.button().color();
+ proxy()->drawPrimitive(PE_FrameFocusRect, &focus, p, widget);
+ }
+ }
+
+ if (opt->subControls & SC_ComboBoxEditField) {
+ if (cb->editable) {
+ QRect er = proxy()->subControlRect(CC_ComboBox, opt, SC_ComboBoxEditField, widget);
+ er.adjust(-1, -1, 1, 1);
+ qDrawShadePanel(p, er, opt->palette, true, 1,
+ &opt->palette.brush(QPalette::Base));
+ }
+ }
+ p->setPen(opt->palette.buttonText().color());
+ }
+ break;
+
+#ifndef QT_NO_SCROLLBAR
+ case CC_ScrollBar: {
+ if (opt->subControls & SC_ScrollBarGroove)
+ qDrawShadePanel(p, opt->rect, opt->palette, true,
+ proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget),
+ &opt->palette.brush((opt->state & State_Enabled) ? QPalette::Mid : QPalette::Window));
+
+ if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
+ QStyleOptionSlider newScrollbar = *scrollbar;
+ if (scrollbar->minimum == scrollbar->maximum)
+ newScrollbar.state |= State_Enabled; // make sure that the slider is drawn.
+ QCommonStyle::drawComplexControl(cc, &newScrollbar, p, widget);
+ }
+ break; }
+#endif
+
+ case CC_Q3ListView:
+ if (opt->subControls & (SC_Q3ListViewBranch | SC_Q3ListViewExpand)) {
+ int i;
+ if (opt->subControls & SC_Q3ListView)
+ QCommonStyle::drawComplexControl(cc, opt, p, widget);
+ if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) {
+ QStyleOptionQ3ListViewItem item = lv->items.at(0);
+ int y = opt->rect.y();
+ int c;
+ QPolygon dotlines;
+ if ((opt->activeSubControls & SC_All) && (opt->subControls & SC_Q3ListViewExpand)) {
+ c = 2;
+ dotlines.resize(2);
+ dotlines[0] = QPoint(opt->rect.right(), opt->rect.top());
+ dotlines[1] = QPoint(opt->rect.right(), opt->rect.bottom());
+ } else {
+ int linetop = 0, linebot = 0;
+ // each branch needs at most two lines, ie. four end points
+ dotlines.resize(item.childCount * 4);
+ c = 0;
+
+ // skip the stuff above the exposed rectangle
+ for (i = 1; i < lv->items.size(); ++i) {
+ QStyleOptionQ3ListViewItem child = lv->items.at(i);
+ if (child.height + y > 0)
+ break;
+ y += child.totalHeight;
+ }
+
+ int bx = opt->rect.width() / 2;
+
+ // paint stuff in the magical area
+ while (i < lv->items.size() && y < lv->rect.height()) {
+ QStyleOptionQ3ListViewItem child = lv->items.at(i);
+ if (child.features & QStyleOptionQ3ListViewItem::Visible) {
+ int lh;
+ if (!(item.features & QStyleOptionQ3ListViewItem::MultiLine))
+ lh = child.height;
+ else
+ lh = p->fontMetrics().height() + 2 * lv->itemMargin;
+ lh = qMax(lh, QApplication::globalStrut().height());
+ if (lh % 2 > 0)
+ lh++;
+ linebot = y + lh/2;
+ if ((child.features & QStyleOptionQ3ListViewItem::Expandable || child.childCount > 0) &&
+ child.height > 0) {
+ // needs a box
+ p->setPen(opt->palette.text().color());
+ p->drawRect(bx-4, linebot-4, 9, 9);
+ QPolygon a;
+ if ((child.state & State_Open))
+ a.setPoints(3, bx-2, linebot-2,
+ bx, linebot+2,
+ bx+2, linebot-2); //Qt::RightArrow
+ else
+ a.setPoints(3, bx-2, linebot-2,
+ bx+2, linebot,
+ bx-2, linebot+2); //Qt::DownArrow
+ p->setBrush(opt->palette.text());
+ p->drawPolygon(a);
+ p->setBrush(Qt::NoBrush);
+ // dotlinery
+ dotlines[c++] = QPoint(bx, linetop);
+ dotlines[c++] = QPoint(bx, linebot - 5);
+ dotlines[c++] = QPoint(bx + 5, linebot);
+ dotlines[c++] = QPoint(opt->rect.width(), linebot);
+ linetop = linebot + 5;
+ } else {
+ // just dotlinery
+ dotlines[c++] = QPoint(bx+1, linebot);
+ dotlines[c++] = QPoint(opt->rect.width(), linebot);
+ }
+ y += child.totalHeight;
+ }
+ ++i;
+ }
+
+ // Expand line height to edge of rectangle if there's any
+ // visible child below
+ while (i < lv->items.size() && lv->items.at(i).height <= 0)
+ ++i;
+ if (i < lv->items.size())
+ linebot = opt->rect.height();
+
+ if (linetop < linebot) {
+ dotlines[c++] = QPoint(bx, linetop);
+ dotlines[c++] = QPoint(bx, linebot);
+ }
+ }
+
+ int line; // index into dotlines
+ p->setPen(opt->palette.text().color());
+ if (opt->subControls & SC_Q3ListViewBranch) for(line = 0; line < c; line += 2) {
+ p->drawLine(dotlines[line].x(), dotlines[line].y(),
+ dotlines[line+1].x(), dotlines[line+1].y());
+ }
+ }
+ break; }
+
+ default:
+ QCommonStyle::drawComplexControl(cc, opt, p, widget);
+ break;
+ }
+}
+
+
+/*! \reimp */
+int QMotifStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt,
+ const QWidget *widget) const
+{
+ int ret = 0;
+
+ switch(pm) {
+ case PM_ButtonDefaultIndicator:
+ ret = 5;
+ break;
+
+ case PM_CheckBoxLabelSpacing:
+ case PM_RadioButtonLabelSpacing:
+ ret = 10;
+ break;
+
+ case PM_ToolBarFrameWidth:
+ ret = proxy()->pixelMetric(PM_DefaultFrameWidth);
+ break;
+
+ case PM_ToolBarItemMargin:
+ ret = 1;
+ break;
+
+ case PM_ButtonShiftHorizontal:
+ case PM_ButtonShiftVertical:
+ ret = 0;
+ break;
+
+ case PM_SplitterWidth:
+ ret = qMax(10, QApplication::globalStrut().width());
+ break;
+
+ case PM_SliderLength:
+ ret = 30;
+ break;
+
+ case PM_SliderThickness:
+ ret = 16 + 4 * proxy()->pixelMetric(PM_DefaultFrameWidth);
+ break;
+#ifndef QT_NO_SLIDER
+ case PM_SliderControlThickness:
+ if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
+ int space = (sl->orientation == Qt::Horizontal) ? sl->rect.height() : sl->rect.width();
+ int ticks = sl->tickPosition;
+ int n = 0;
+ if (ticks & QSlider::TicksAbove)
+ n++;
+ if (ticks & QSlider::TicksBelow)
+ n++;
+ if (!n) {
+ ret = space;
+ break;
+ }
+
+ int thick = 6; // Magic constant to get 5 + 16 + 5
+
+ space -= thick;
+ //### the two sides may be unequal in size
+ if (space > 0)
+ thick += (space * 2) / (n + 2);
+ ret = thick;
+ }
+ break;
+
+ case PM_SliderSpaceAvailable:
+ if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
+ if (sl->orientation == Qt::Horizontal)
+ ret = sl->rect.width() - proxy()->pixelMetric(PM_SliderLength, opt, widget) - 2 * proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget);
+ else
+ ret = sl->rect.height() - proxy()->pixelMetric(PM_SliderLength, opt, widget) - 2 * proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget);
+ }
+ break;
+#endif // QT_NO_SLIDER
+ case PM_DockWidgetFrameWidth:
+ ret = 2;
+ break;
+
+ case PM_DockWidgetHandleExtent:
+ ret = 9;
+ break;
+
+ case PM_ProgressBarChunkWidth:
+ ret = 1;
+ break;
+
+ case PM_ExclusiveIndicatorWidth:
+ case PM_ExclusiveIndicatorHeight:
+ ret = 13;
+ break;
+
+ case PM_MenuBarHMargin:
+ ret = 2; // really ugly, but Motif
+ break;
+
+ case PM_MenuButtonIndicator:
+ if (!opt)
+ ret = 12;
+ else
+ ret = qMax(12, (opt->rect.height() - 4) / 3);
+ break;
+ default:
+ ret = QCommonStyle::pixelMetric(pm, opt, widget);
+ break;
+ }
+ return ret;
+}
+
+
+/*!
+ \reimp
+*/
+QRect
+QMotifStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt,
+ SubControl sc, const QWidget *widget) const
+{
+ switch (cc) {
+#ifndef QT_NO_SPINBOX
+ case CC_SpinBox:
+ if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
+ int fw = spinbox->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0;
+ QSize bs;
+ bs.setHeight(opt->rect.height()/2 - fw);
+ bs.setWidth(qMin(bs.height() * 8 / 5, opt->rect.width() / 4)); // 1.6 -approximate golden mean
+ bs = bs.expandedTo(QApplication::globalStrut());
+ int y = fw + spinbox->rect.y();
+ int x, lx, rx;
+ x = spinbox->rect.x() + opt->rect.width() - fw - bs.width();
+ lx = fw;
+ rx = x - fw * 2;
+ const int margin = spinbox->frame ? 4 : 0;
+ switch (sc) {
+ case SC_SpinBoxUp:
+ if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
+ return QRect();
+ return visualRect(spinbox->direction, spinbox->rect,
+ QRect(x, y, bs.width(), bs.height() - 1));
+ case SC_SpinBoxDown:
+ if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
+ return QRect();
+ return visualRect(spinbox->direction, spinbox->rect,
+ QRect(x, y + bs.height() + 1, bs.width(), bs.height() - 1));
+ case SC_SpinBoxEditField:
+ if (spinbox->buttonSymbols == QAbstractSpinBox::NoButtons)
+ return visualRect(spinbox->direction, spinbox->rect,
+ QRect(lx + margin, y + margin,
+ spinbox->rect.width() - 2*fw - 2*margin,
+ spinbox->rect.height() - 2*fw - 2*margin));
+
+ return visualRect(spinbox->direction, spinbox->rect,
+ QRect(lx + margin, y + margin, rx - margin,
+ spinbox->rect.height() - 2*fw - 2 * margin));
+ case SC_SpinBoxFrame:
+ return visualRect(spinbox->direction, spinbox->rect, spinbox->rect);
+ default:
+ break;
+ }
+ break; }
+#endif // QT_NO_SPINBOX
+#ifndef QT_NO_SLIDER
+ case CC_Slider:
+ if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
+ if (sc == SC_SliderHandle) {
+ int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, opt, widget);
+ int thickness = proxy()->pixelMetric(PM_SliderControlThickness, opt, widget);
+ bool horizontal = slider->orientation == Qt::Horizontal;
+ int len = proxy()->pixelMetric(PM_SliderLength, opt, widget);
+ int motifBorder = proxy()->pixelMetric(PM_DefaultFrameWidth);
+ int sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum, slider->sliderPosition,
+ horizontal ? slider->rect.width() - len - 2 * motifBorder
+ : slider->rect.height() - len - 2 * motifBorder,
+ slider->upsideDown);
+ if (horizontal)
+ return visualRect(slider->direction, slider->rect,
+ QRect(sliderPos + motifBorder, tickOffset + motifBorder, len,
+ thickness - 2 * motifBorder));
+ return visualRect(slider->direction, slider->rect,
+ QRect(tickOffset + motifBorder, sliderPos + motifBorder,
+ thickness - 2 * motifBorder, len));
+ }
+ }
+ break;
+#endif // QT_NO_SLIDER
+#ifndef QT_NO_SCROLLBAR
+ case CC_ScrollBar:
+ if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
+ int dfw = proxy()->pixelMetric(PM_DefaultFrameWidth);
+ QRect rect = visualRect(scrollbar->direction, scrollbar->rect,
+ QCommonStyle::subControlRect(cc, scrollbar, sc, widget));
+ if (sc == SC_ScrollBarSlider) {
+ if (scrollbar->orientation == Qt::Horizontal)
+ rect.adjust(-dfw, dfw, dfw, -dfw);
+ else
+ rect.adjust(dfw, -dfw, -dfw, dfw);
+ } else if (sc != SC_ScrollBarGroove) {
+ if (scrollbar->orientation == Qt::Horizontal)
+ rect.adjust(0, dfw, 0, -dfw);
+ else
+ rect.adjust(dfw, 0, -dfw, 0);
+ }
+ return visualRect(scrollbar->direction, scrollbar->rect, rect);
+ }
+ break;
+#endif // QT_NO_SCROLLBAR
+#ifndef QT_NO_COMBOBOX
+ case CC_ComboBox:
+ if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
+ switch (sc) {
+ case SC_ComboBoxArrow: {
+ int ew, awh, sh, dh, ax, ay, sy;
+ int fw = cb->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth, opt, widget) : 0;
+ QRect cr = opt->rect;
+ cr.adjust(fw, fw, -fw, -fw);
+ get_combo_parameters(cr, ew, awh, ax, ay, sh, dh, sy);
+ return visualRect(cb->direction, cb->rect, QRect(QPoint(ax, ay), cr.bottomRight()));
+ }
+
+ case SC_ComboBoxEditField: {
+ int fw = cb->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth, opt, widget) : 0;
+ QRect rect = opt->rect;
+ rect.adjust(fw, fw, -fw, -fw);
+ int ew = get_combo_extra_width(rect.height(), rect.width());
+ rect.adjust(1, 1, -1-ew, -1);
+ return visualRect(cb->direction, cb->rect, rect);
+ }
+
+ default:
+ break;
+ }
+ }
+ break;
+#endif // QT_NO_SCROLLBAR
+ default:
+ break;
+ }
+ return QCommonStyle::subControlRect(cc, opt, sc, widget);
+}
+
+/*!
+ \reimp
+*/
+QSize
+QMotifStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
+ const QSize &contentsSize, const QWidget *widget) const
+{
+ QSize sz(contentsSize);
+
+ switch(ct) {
+ case CT_RadioButton:
+ case CT_CheckBox:
+ sz = QCommonStyle::sizeFromContents(ct, opt, contentsSize, widget);
+ sz.rwidth() += motifItemFrame;
+ break;
+
+ case CT_PushButton:
+ if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
+ sz = QCommonStyle::sizeFromContents(ct, opt, contentsSize, widget);
+ if (!btn->text.isEmpty() && (btn->features & (QStyleOptionButton::AutoDefaultButton|QStyleOptionButton::DefaultButton)))
+ sz.setWidth(qMax(75, sz.width()));
+ sz += QSize(0, 1); // magical extra pixel
+ }
+ break;
+
+ case CT_MenuBarItem: {
+ if(!sz.isEmpty())
+ sz += QSize(5*motifItemHMargin+1, 2*motifItemVMargin + motifItemFrame);
+ break; }
+
+ case CT_MenuItem:
+ if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
+ sz = QCommonStyle::sizeFromContents(ct, opt, sz, widget);
+ int w = sz.width(), h = sz.height();
+
+ if (mi->menuItemType == QStyleOptionMenuItem::Separator) {
+ w = 10;
+ h = (mi->text.isEmpty()) ? motifSepHeight : mi->fontMetrics.height();
+ }
+
+ // a little bit of border can never harm
+ w += 2*motifItemHMargin + 2*motifItemFrame;
+
+ if (!mi->text.isNull() && mi->text.indexOf(QLatin1Char('\t')) >= 0)
+ // string contains tab
+ w += motifTabSpacing;
+ else if (mi->menuItemType == QStyleOptionMenuItem::SubMenu)
+ // submenu indicator needs some room if we don't have a tab column
+ w += motifArrowHMargin + 4*motifItemFrame;
+
+ int checkColumn = mi->maxIconWidth;
+ if (mi->menuHasCheckableItems)
+ checkColumn = qMax(checkColumn, motifCheckMarkSpace);
+ if (checkColumn > 0)
+ w += checkColumn + motifCheckMarkHMargin;
+
+ sz = QSize(w, h);
+ }
+ break;
+
+
+ default:
+ sz = QCommonStyle::sizeFromContents(ct, opt, contentsSize, widget);
+ break;
+ }
+
+ return sz;
+}
+
+/*!
+ \reimp
+*/
+QRect
+QMotifStyle::subElementRect(SubElement sr, const QStyleOption *opt, const QWidget *widget) const
+{
+ QRect rect;
+
+ switch (sr) {
+ case SE_SliderFocusRect:
+ rect = QCommonStyle::subElementRect(sr, opt, widget);
+ rect.adjust(2, 2, -2, -2);
+ break;
+
+ case SE_CheckBoxIndicator:
+ case SE_RadioButtonIndicator:
+ {
+ rect = visualRect(opt->direction, opt->rect,
+ QCommonStyle::subElementRect(sr, opt, widget));
+ rect.adjust(motifItemFrame,0, motifItemFrame,0);
+ rect = visualRect(opt->direction, opt->rect, rect);
+ }
+ break;
+
+ case SE_ComboBoxFocusRect:
+ {
+ int awh, ax, ay, sh, sy, dh, ew;
+ int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget);
+ QRect tr = opt->rect;
+
+ tr.adjust(fw, fw, -fw, -fw);
+ get_combo_parameters(tr, ew, awh, ax, ay, sh, dh, sy);
+ rect.setRect(ax-2, ay-2, awh+4, awh+sh+dh+4);
+ break;
+ }
+
+ case SE_Q3DockWindowHandleRect:
+ if (const QStyleOptionQ3DockWindow *dw = qstyleoption_cast<const QStyleOptionQ3DockWindow *>(opt)) {
+ if (!dw->docked || !dw->closeEnabled)
+ rect.setRect(0, 0, opt->rect.width(), opt->rect.height());
+ else {
+ if (dw->state == State_Horizontal)
+ rect.setRect(2, 15, opt->rect.width()-2, opt->rect.height() - 15);
+ else
+ rect.setRect(0, 2, opt->rect.width() - 15, opt->rect.height() - 2);
+ }
+ rect = visualRect(dw->direction, dw->rect, rect);
+ }
+ break;
+
+ case SE_ProgressBarLabel:
+ case SE_ProgressBarGroove:
+ case SE_ProgressBarContents:
+ if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
+ int textw = 0;
+ if (pb->textVisible)
+ textw = pb->fontMetrics.width(QLatin1String("100%")) + 6;
+
+ if (pb->textAlignment == Qt::AlignLeft || pb->textAlignment == Qt::AlignCenter) {
+ rect = opt->rect;
+ } else {
+ if(sr == SE_ProgressBarLabel)
+ rect.setCoords(opt->rect.right() - textw, opt->rect.top(),
+ opt->rect.right(), opt->rect.bottom());
+ else
+ rect.setCoords(opt->rect.left(), opt->rect.top(),
+ opt->rect.right() - textw, opt->rect.bottom());
+ }
+ if (sr == SE_ProgressBarContents)
+ rect.adjust(2, 2, -2, -2);
+ rect = visualRect(pb->direction, pb->rect, rect);
+ }
+ break;
+ case SE_CheckBoxClickRect:
+ case SE_RadioButtonClickRect:
+ rect = visualRect(opt->direction, opt->rect, opt->rect);
+ break;
+
+ default:
+ rect = QCommonStyle::subElementRect(sr, opt, widget);
+ }
+ return rect;
+}
+
+#ifndef QT_NO_IMAGEFORMAT_XPM
+static const char * const qt_menu_xpm[] = {
+"16 16 11 1",
+" c #000000",
+", c #336600",
+". c #99CC00",
+"X c #666600",
+"o c #999933",
+"+ c #333300",
+"@ c #669900",
+"# c #999900",
+"$ c #336633",
+"% c #666633",
+"& c #99CC33",
+"................",
+"................",
+".....#,++X#.....",
+"....X X....",
+"...X Xo#% X&..",
+"..# o..&@o o..",
+".., X..#+ @X X..",
+"..+ o.o+ +o# +..",
+"..+ #o+ +## +..",
+".., %@ ++ +, X..",
+"..# o@oo+ #..",
+"...X X##$ o..",
+"....X X..",
+"....&oX++X#oX...",
+"................",
+"................"};
+
+
+static const char * const qt_close_xpm[] = {
+ "12 12 2 1",
+ " s None c None",
+ ". c black",
+ " ",
+ " ",
+ " . . ",
+ " ... ... ",
+ " ...... ",
+ " .... ",
+ " .... ",
+ " ...... ",
+ " ... ... ",
+ " . . ",
+ " ",
+ " "};
+
+static const char * const qt_maximize_xpm[] = {
+ "12 12 2 1",
+ " s None c None",
+ ". c black",
+ " ",
+ " ",
+ " ",
+ " . ",
+ " ... ",
+ " ..... ",
+ " ....... ",
+ " ......... ",
+ " ",
+ " ",
+ " ",
+ " "};
+
+static const char * const qt_minimize_xpm[] = {
+ "12 12 2 1",
+ " s None c None",
+ ". c black",
+ " ",
+ " ",
+ " ",
+ " ",
+ " ......... ",
+ " ....... ",
+ " ..... ",
+ " ... ",
+ " . ",
+ " ",
+ " ",
+ " "};
+
+#if 0 // ### not used???
+static const char * const qt_normalize_xpm[] = {
+ "12 12 2 1",
+ " s None c None",
+ ". c black",
+ " ",
+ " ",
+ " . ",
+ " .. ",
+ " ... ",
+ " .... ",
+ " ..... ",
+ " ...... ",
+ " ....... ",
+ " ",
+ " ",
+ " "};
+#endif
+
+static const char * const qt_normalizeup_xpm[] = {
+ "12 12 2 1",
+ " s None c None",
+ ". c black",
+ " ",
+ " ",
+ " ",
+ " ....... ",
+ " ...... ",
+ " ..... ",
+ " .... ",
+ " ... ",
+ " .. ",
+ " . ",
+ " ",
+ " "};
+
+static const char * const qt_shade_xpm[] = {
+ "12 12 2 1", "# c #000000",
+ ". c None",
+ "............",
+ "............",
+ ".#########..",
+ ".#########..",
+ "............",
+ "............",
+ "............",
+ "............",
+ "............",
+ "............",
+ "............",
+ "............"};
+
+
+static const char * const qt_unshade_xpm[] = {
+ "12 12 2 1",
+ "# c #000000",
+ ". c None",
+ "............",
+ "............",
+ ".#########..",
+ ".#########..",
+ ".#.......#..",
+ ".#.......#..",
+ ".#.......#..",
+ ".#.......#..",
+ ".#.......#..",
+ ".#########..",
+ "............",
+ "............"};
+
+
+static const char * dock_window_close_xpm[] = {
+ "8 8 2 1",
+ "# c #000000",
+ ". c None",
+ "##....##",
+ ".##..##.",
+ "..####..",
+ "...##...",
+ "..####..",
+ ".##..##.",
+ "##....##",
+ "........"};
+
+// Message box icons, from page 210 of the Windows style guide.
+
+// Hand-drawn to resemble Microsoft's icons, but in the Mac/Netscape palette.
+// Thanks to TrueColor displays, it is slightly more efficient to have
+// them duplicated.
+/* XPM */
+static const char * const information_xpm[]={
+ "32 32 5 1",
+ ". c None",
+ "c c #000000",
+ "* c #999999",
+ "a c #ffffff",
+ "b c #0000ff",
+ "...........********.............",
+ "........***aaaaaaaa***..........",
+ "......**aaaaaaaaaaaaaa**........",
+ ".....*aaaaaaaaaaaaaaaaaa*.......",
+ "....*aaaaaaaabbbbaaaaaaaac......",
+ "...*aaaaaaaabbbbbbaaaaaaaac.....",
+ "..*aaaaaaaaabbbbbbaaaaaaaaac....",
+ ".*aaaaaaaaaaabbbbaaaaaaaaaaac...",
+ ".*aaaaaaaaaaaaaaaaaaaaaaaaaac*..",
+ "*aaaaaaaaaaaaaaaaaaaaaaaaaaaac*.",
+ "*aaaaaaaaaabbbbbbbaaaaaaaaaaac*.",
+ "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
+ "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
+ "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
+ "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
+ "*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
+ ".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
+ ".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
+ "..*aaaaaaaaaabbbbbaaaaaaaaac***.",
+ "...caaaaaaabbbbbbbbbaaaaaac****.",
+ "....caaaaaaaaaaaaaaaaaaaac****..",
+ ".....caaaaaaaaaaaaaaaaaac****...",
+ "......ccaaaaaaaaaaaaaacc****....",
+ ".......*cccaaaaaaaaccc*****.....",
+ "........***cccaaaac*******......",
+ "..........****caaac*****........",
+ ".............*caaac**...........",
+ "...............caac**...........",
+ "................cac**...........",
+ ".................cc**...........",
+ "..................***...........",
+ "...................**..........."};
+/* XPM */
+static const char* const warning_xpm[]={
+ "32 32 4 1",
+ ". c None",
+ "a c #ffff00",
+ "* c #000000",
+ "b c #999999",
+ ".............***................",
+ "............*aaa*...............",
+ "...........*aaaaa*b.............",
+ "...........*aaaaa*bb............",
+ "..........*aaaaaaa*bb...........",
+ "..........*aaaaaaa*bb...........",
+ ".........*aaaaaaaaa*bb..........",
+ ".........*aaaaaaaaa*bb..........",
+ "........*aaaaaaaaaaa*bb.........",
+ "........*aaaa***aaaa*bb.........",
+ ".......*aaaa*****aaaa*bb........",
+ ".......*aaaa*****aaaa*bb........",
+ "......*aaaaa*****aaaaa*bb.......",
+ "......*aaaaa*****aaaaa*bb.......",
+ ".....*aaaaaa*****aaaaaa*bb......",
+ ".....*aaaaaa*****aaaaaa*bb......",
+ "....*aaaaaaaa***aaaaaaaa*bb.....",
+ "....*aaaaaaaa***aaaaaaaa*bb.....",
+ "...*aaaaaaaaa***aaaaaaaaa*bb....",
+ "...*aaaaaaaaaa*aaaaaaaaaa*bb....",
+ "..*aaaaaaaaaaa*aaaaaaaaaaa*bb...",
+ "..*aaaaaaaaaaaaaaaaaaaaaaa*bb...",
+ ".*aaaaaaaaaaaa**aaaaaaaaaaa*bb..",
+ ".*aaaaaaaaaaa****aaaaaaaaaa*bb..",
+ "*aaaaaaaaaaaa****aaaaaaaaaaa*bb.",
+ "*aaaaaaaaaaaaa**aaaaaaaaaaaa*bb.",
+ "*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
+ "*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
+ ".*aaaaaaaaaaaaaaaaaaaaaaaaa*bbbb",
+ "..*************************bbbbb",
+ "....bbbbbbbbbbbbbbbbbbbbbbbbbbb.",
+ ".....bbbbbbbbbbbbbbbbbbbbbbbbb.."};
+/* XPM */
+static const char* const critical_xpm[]={
+ "32 32 4 1",
+ ". c None",
+ "a c #999999",
+ "* c #ff0000",
+ "b c #ffffff",
+ "...........********.............",
+ ".........************...........",
+ ".......****************.........",
+ "......******************........",
+ ".....********************a......",
+ "....**********************a.....",
+ "...************************a....",
+ "..*******b**********b*******a...",
+ "..******bbb********bbb******a...",
+ ".******bbbbb******bbbbb******a..",
+ ".*******bbbbb****bbbbb*******a..",
+ "*********bbbbb**bbbbb*********a.",
+ "**********bbbbbbbbbb**********a.",
+ "***********bbbbbbbb***********aa",
+ "************bbbbbb************aa",
+ "************bbbbbb************aa",
+ "***********bbbbbbbb***********aa",
+ "**********bbbbbbbbbb**********aa",
+ "*********bbbbb**bbbbb*********aa",
+ ".*******bbbbb****bbbbb*******aa.",
+ ".******bbbbb******bbbbb******aa.",
+ "..******bbb********bbb******aaa.",
+ "..*******b**********b*******aa..",
+ "...************************aaa..",
+ "....**********************aaa...",
+ "....a********************aaa....",
+ ".....a******************aaa.....",
+ "......a****************aaa......",
+ ".......aa************aaaa.......",
+ ".........aa********aaaaa........",
+ "...........aaaaaaaaaaa..........",
+ ".............aaaaaaa............"};
+/* XPM */
+static const char *const question_xpm[] = {
+ "32 32 5 1",
+ ". c None",
+ "c c #000000",
+ "* c #999999",
+ "a c #ffffff",
+ "b c #0000ff",
+ "...........********.............",
+ "........***aaaaaaaa***..........",
+ "......**aaaaaaaaaaaaaa**........",
+ ".....*aaaaaaaaaaaaaaaaaa*.......",
+ "....*aaaaaaaaaaaaaaaaaaaac......",
+ "...*aaaaaaaabbbbbbaaaaaaaac.....",
+ "..*aaaaaaaabaaabbbbaaaaaaaac....",
+ ".*aaaaaaaabbaaaabbbbaaaaaaaac...",
+ ".*aaaaaaaabbbbaabbbbaaaaaaaac*..",
+ "*aaaaaaaaabbbbaabbbbaaaaaaaaac*.",
+ "*aaaaaaaaaabbaabbbbaaaaaaaaaac*.",
+ "*aaaaaaaaaaaaabbbbaaaaaaaaaaac**",
+ "*aaaaaaaaaaaaabbbaaaaaaaaaaaac**",
+ "*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
+ "*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
+ "*aaaaaaaaaaaaaaaaaaaaaaaaaaaac**",
+ ".*aaaaaaaaaaaabbaaaaaaaaaaaac***",
+ ".*aaaaaaaaaaabbbbaaaaaaaaaaac***",
+ "..*aaaaaaaaaabbbbaaaaaaaaaac***.",
+ "...caaaaaaaaaabbaaaaaaaaaac****.",
+ "....caaaaaaaaaaaaaaaaaaaac****..",
+ ".....caaaaaaaaaaaaaaaaaac****...",
+ "......ccaaaaaaaaaaaaaacc****....",
+ ".......*cccaaaaaaaaccc*****.....",
+ "........***cccaaaac*******......",
+ "..........****caaac*****........",
+ ".............*caaac**...........",
+ "...............caac**...........",
+ "................cac**...........",
+ ".................cc**...........",
+ "..................***...........",
+ "...................**...........",
+};
+#endif
+
+/*!
+ \reimp
+*/
+QPixmap
+QMotifStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
+ const QWidget *widget) const
+{
+#ifndef QT_NO_IMAGEFORMAT_XPM
+ switch (standardPixmap) {
+ case SP_TitleBarMenuButton:
+ return QPixmap(qt_menu_xpm);
+ case SP_TitleBarShadeButton:
+ return QPixmap(qt_shade_xpm);
+ case SP_TitleBarUnshadeButton:
+ return QPixmap(qt_unshade_xpm);
+ case SP_TitleBarNormalButton:
+ return QPixmap(qt_normalizeup_xpm);
+ case SP_TitleBarMinButton:
+ return QPixmap(qt_minimize_xpm);
+ case SP_TitleBarMaxButton:
+ return QPixmap(qt_maximize_xpm);
+ case SP_TitleBarCloseButton:
+ return QPixmap(qt_close_xpm);
+ case SP_DockWidgetCloseButton:
+ return QPixmap(dock_window_close_xpm);
+
+ case SP_MessageBoxInformation:
+ case SP_MessageBoxWarning:
+ case SP_MessageBoxCritical:
+ case SP_MessageBoxQuestion:
+ {
+ const char * const * xpm_data;
+ switch (standardPixmap) {
+ case SP_MessageBoxInformation:
+ xpm_data = information_xpm;
+ break;
+ case SP_MessageBoxWarning:
+ xpm_data = warning_xpm;
+ break;
+ case SP_MessageBoxCritical:
+ xpm_data = critical_xpm;
+ break;
+ case SP_MessageBoxQuestion:
+ xpm_data = question_xpm;
+ break;
+ default:
+ xpm_data = 0;
+ break;
+ }
+ QPixmap pm;
+ if (xpm_data) {
+ QImage image((const char **) xpm_data);
+ // All that color looks ugly in Motif
+ const QPalette &pal = QApplication::palette();
+ switch (standardPixmap) {
+ case SP_MessageBoxInformation:
+ case SP_MessageBoxQuestion:
+ image.setColor(2, 0xff000000 |
+ pal.color(QPalette::Active, QPalette::Dark).rgb());
+ image.setColor(3, 0xff000000 |
+ pal.color(QPalette::Active, QPalette::Base).rgb());
+ image.setColor(4, 0xff000000 |
+ pal.color(QPalette::Active, QPalette::Text).rgb());
+ break;
+ case SP_MessageBoxWarning:
+ image.setColor(1, 0xff000000 |
+ pal.color(QPalette::Active, QPalette::Base).rgb());
+ image.setColor(2, 0xff000000 |
+ pal.color(QPalette::Active, QPalette::Text).rgb());
+ image.setColor(3, 0xff000000 |
+ pal.color(QPalette::Active, QPalette::Dark).rgb());
+ break;
+ case SP_MessageBoxCritical:
+ image.setColor(1, 0xff000000 |
+ pal.color(QPalette::Active, QPalette::Dark).rgb());
+ image.setColor(2, 0xff000000 |
+ pal.color(QPalette::Active, QPalette::Text).rgb());
+ image.setColor(3, 0xff000000 |
+ pal.color(QPalette::Active, QPalette::Base).rgb());
+ break;
+ default:
+ break;
+ }
+ pm = QPixmap::fromImage(image);
+ }
+ return pm;
+ }
+
+ default:
+ break;
+ }
+#endif
+
+ return QCommonStyle::standardPixmap(standardPixmap, opt, widget);
+}
+
+/*! \reimp */
+bool QMotifStyle::event(QEvent *e)
+{
+ if(e->type() == QEvent::FocusIn) {
+ if (QWidget *focusWidget = QApplication::focusWidget()) {
+#ifndef QT_NO_GRAPHICSVIEW
+ if (QGraphicsView *graphicsView = qobject_cast<QGraphicsView *>(focusWidget)) {
+ QGraphicsItem *focusItem = graphicsView->scene() ? graphicsView->scene()->focusItem() : 0;
+ if (focusItem && focusItem->type() == QGraphicsProxyWidget::Type) {
+ QGraphicsProxyWidget *proxy = static_cast<QGraphicsProxyWidget *>(focusItem);
+ if (proxy->widget())
+ focusWidget = proxy->widget()->focusWidget();
+ }
+ }
+#endif
+ if(!focus)
+ focus = new QFocusFrame(focusWidget);
+ focus->setWidget(focusWidget);
+ } else {
+ if(focus)
+ focus->setWidget(0);
+ }
+ } else if(e->type() == QEvent::FocusOut) {
+ if(focus)
+ focus->setWidget(0);
+ }
+ return QCommonStyle::event(e);
+}
+
+
+/*! \reimp */
+int
+QMotifStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWidget *widget,
+ QStyleHintReturn *returnData) const
+{
+ int ret;
+
+ switch (hint) {
+#ifdef QT3_SUPPORT
+ case SH_GUIStyle:
+ ret = Qt::MotifStyle;
+ break;
+#endif
+ case SH_DrawMenuBarSeparator:
+ ret = true;
+ break;
+
+ case SH_ScrollBar_MiddleClickAbsolutePosition:
+ case SH_Slider_SloppyKeyEvents:
+ case SH_ProgressDialog_CenterCancelButton:
+ case SH_Menu_SpaceActivatesItem:
+ case SH_ScrollView_FrameOnlyAroundContents:
+ case SH_DitherDisabledText:
+ ret = 1;
+ break;
+
+ case SH_Menu_SubMenuPopupDelay:
+ ret = 96;
+ break;
+
+ case SH_ProgressDialog_TextLabelAlignment:
+ ret = Qt::AlignLeft | Qt::AlignVCenter;
+ break;
+
+ case SH_ItemView_ChangeHighlightOnFocus:
+ ret = 0;
+ break;
+
+ case SH_MessageBox_UseBorderForButtonSpacing:
+ ret = 1;
+ break;
+
+ case SH_Dial_BackgroundRole:
+ ret = QPalette::Mid;
+ break;
+
+ case SH_DialogButtonLayout:
+ ret = QDialogButtonBox::KdeLayout;
+ break;
+ case SH_LineEdit_PasswordCharacter:
+ ret = '*';
+ break;
+ case SH_DialogButtonBox_ButtonsHaveIcons:
+ ret = 0;
+ break;
+ default:
+ ret = QCommonStyle::styleHint(hint, opt, widget, returnData);
+ break;
+ }
+
+ return ret;
+}
+
+/*! \reimp */
+QPalette QMotifStyle::standardPalette() const
+{
+#ifdef Q_WS_X11
+ QColor background(0xcf, 0xcf, 0xcf);
+ if (QX11Info::appDepth() <= 8)
+ background = QColor(0xc0, 0xc0, 0xc0);
+#else
+ QColor background = QColor(0xcf, 0xcf, 0xcf);
+#endif
+
+ QColor light = background.lighter();
+ QColor mid = QColor(0xa6, 0xa6, 0xa6);
+ QColor dark = QColor(0x79, 0x7d, 0x79);
+ QPalette palette(Qt::black, background, light, dark, mid, Qt::black, Qt::white);
+ palette.setBrush(QPalette::Disabled, QPalette::WindowText, dark);
+ palette.setBrush(QPalette::Disabled, QPalette::Text, dark);
+ palette.setBrush(QPalette::Disabled, QPalette::ButtonText, dark);
+ palette.setBrush(QPalette::Disabled, QPalette::Base, background);
+ return palette;
+}
+
+QT_END_NAMESPACE
+
+#endif // !defined(QT_NO_STYLE_MOTIF) || defined(QT_PLUGIN)
diff --git a/src/widgets/styles/qmotifstyle.h b/src/widgets/styles/qmotifstyle.h
new file mode 100644
index 0000000000..809443d0fe
--- /dev/null
+++ b/src/widgets/styles/qmotifstyle.h
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMOTIFSTYLE_H
+#define QMOTIFSTYLE_H
+
+#include <QtWidgets/qcommonstyle.h>
+#include <QtCore/qpointer.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#if !defined(QT_NO_STYLE_MOTIF)
+
+class QPalette;
+class QFocusFrame;
+
+class QMotifStylePrivate;
+class Q_GUI_EXPORT QMotifStyle : public QCommonStyle
+{
+ Q_OBJECT
+public:
+ explicit QMotifStyle(bool useHighlightCols=false);
+ virtual ~QMotifStyle();
+
+ void setUseHighlightColors(bool);
+ bool useHighlightColors() const;
+
+ void polish(QPalette&);
+ void polish(QWidget*);
+ void unpolish(QWidget*);
+ void polish(QApplication*);
+ void unpolish(QApplication*);
+
+ void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
+ const QWidget *w = 0) const;
+
+ void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
+ const QWidget *w = 0) const;
+
+ void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
+ const QWidget *w = 0) const;
+
+ QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt,
+ SubControl sc, const QWidget *widget = 0) const;
+
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = 0,
+ const QWidget *widget = 0) const;
+
+ QSize sizeFromContents(ContentsType ct, const QStyleOption *opt,
+ const QSize &contentsSize, const QWidget *widget = 0) const;
+
+ QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const;
+
+ QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
+ const QWidget *widget = 0) const;
+
+ int styleHint(StyleHint hint, const QStyleOption *opt = 0, const QWidget *widget = 0,
+ QStyleHintReturn *returnData = 0) const;
+
+ bool event(QEvent *);
+ QPalette standardPalette() const;
+
+protected Q_SLOTS:
+ QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt = 0,
+ const QWidget *widget = 0) const;
+
+protected:
+ QPointer<QFocusFrame> focus;
+ QMotifStyle(QMotifStylePrivate &dd, bool useHighlightCols = false);
+ void timerEvent(QTimerEvent *event);
+ bool eventFilter(QObject *o, QEvent *e);
+
+private:
+ Q_DECLARE_PRIVATE(QMotifStyle)
+ Q_DISABLE_COPY(QMotifStyle)
+
+ bool highlightCols;
+};
+
+#endif // QT_NO_STYLE_MOTIF
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QMOTIFSTYLE_H
diff --git a/src/gui/styles/qmotifstyle_p.h b/src/widgets/styles/qmotifstyle_p.h
index 47043b582b..47043b582b 100644
--- a/src/gui/styles/qmotifstyle_p.h
+++ b/src/widgets/styles/qmotifstyle_p.h
diff --git a/src/gui/styles/qplastiquestyle.cpp b/src/widgets/styles/qplastiquestyle.cpp
index 1d33212457..1d33212457 100644
--- a/src/gui/styles/qplastiquestyle.cpp
+++ b/src/widgets/styles/qplastiquestyle.cpp
diff --git a/src/widgets/styles/qplastiquestyle.h b/src/widgets/styles/qplastiquestyle.h
new file mode 100644
index 0000000000..1f9a0524ec
--- /dev/null
+++ b/src/widgets/styles/qplastiquestyle.h
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLASTIQUESTYLE_H
+#define QPLASTIQUESTYLE_H
+
+#include <QtWidgets/qwindowsstyle.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#if !defined(QT_NO_STYLE_PLASTIQUE)
+
+class QPlastiqueStylePrivate;
+class Q_GUI_EXPORT QPlastiqueStyle : public QWindowsStyle
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QPlastiqueStyle)
+public:
+ QPlastiqueStyle();
+ ~QPlastiqueStyle();
+
+ 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;
+
+ int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0,
+ QStyleHintReturn *returnData = 0) const;
+ SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option,
+ const QPoint &pos, const QWidget *widget = 0) const;
+
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
+
+ QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
+ const QWidget *widget = 0) const;
+
+ void polish(QWidget *widget);
+ void polish(QApplication *app);
+ void polish(QPalette &pal);
+ void unpolish(QWidget *widget);
+ void unpolish(QApplication *app);
+
+ QPalette standardPalette() const;
+
+protected Q_SLOTS:
+ QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt = 0,
+ const QWidget *widget = 0) const;
+ int layoutSpacingImplementation(QSizePolicy::ControlType control1,
+ QSizePolicy::ControlType control2,
+ Qt::Orientation orientation,
+ const QStyleOption *option = 0,
+ const QWidget *widget = 0) const;
+
+protected:
+ bool eventFilter(QObject *watched, QEvent *event);
+ void timerEvent(QTimerEvent *event);
+
+private:
+ Q_DISABLE_COPY(QPlastiqueStyle)
+ void *reserved;
+};
+
+#endif // QT_NO_STYLE_PLASTIQUE
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPLASTIQUESTYLE_H
diff --git a/src/gui/styles/qproxystyle.cpp b/src/widgets/styles/qproxystyle.cpp
index 516d17fa69..516d17fa69 100644
--- a/src/gui/styles/qproxystyle.cpp
+++ b/src/widgets/styles/qproxystyle.cpp
diff --git a/src/widgets/styles/qproxystyle.h b/src/widgets/styles/qproxystyle.h
new file mode 100644
index 0000000000..5c87c95ae8
--- /dev/null
+++ b/src/widgets/styles/qproxystyle.h
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPROXYSTYLE_H
+#define QPROXYSTYLE_H
+
+#include <QtWidgets/QCommonStyle>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#if !defined(QT_NO_STYLE_PROXY)
+
+class QProxyStylePrivate;
+class Q_GUI_EXPORT QProxyStyle : public QCommonStyle
+{
+ Q_OBJECT
+
+public:
+ QProxyStyle(QStyle *baseStyle = 0);
+ ~QProxyStyle();
+
+ QStyle *baseStyle() const;
+ void setBaseStyle(QStyle *style);
+
+ 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 = 0) const;
+ void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = 0) const;
+ void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled,
+ const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const;
+ virtual void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) 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;
+ QRect itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const;
+ QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const;
+
+ SubControl hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, const QPoint &pos, const QWidget *widget = 0) const;
+ int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const;
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
+
+ QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget = 0) const;
+ QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const;
+ QPalette standardPalette() const;
+
+ void polish(QWidget *widget);
+ void polish(QPalette &pal);
+ void polish(QApplication *app);
+
+ void unpolish(QWidget *widget);
+ void unpolish(QApplication *app);
+
+protected:
+ bool event(QEvent *e);
+
+protected Q_SLOTS:
+ QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const;
+ int layoutSpacingImplementation(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2,
+ Qt::Orientation orientation, const QStyleOption *option = 0, const QWidget *widget = 0) const;
+private:
+ Q_DISABLE_COPY(QProxyStyle)
+ Q_DECLARE_PRIVATE(QProxyStyle)
+};
+
+#endif // QT_NO_STYLE_PROXY
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPROXYSTYLE_H
diff --git a/src/gui/styles/qproxystyle_p.h b/src/widgets/styles/qproxystyle_p.h
index 8c330d0330..8c330d0330 100644
--- a/src/gui/styles/qproxystyle_p.h
+++ b/src/widgets/styles/qproxystyle_p.h
diff --git a/src/gui/styles/qs60style.cpp b/src/widgets/styles/qs60style.cpp
index fa6eeb7b36..fa6eeb7b36 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/widgets/styles/qs60style.cpp
diff --git a/src/widgets/styles/qs60style.h b/src/widgets/styles/qs60style.h
new file mode 100644
index 0000000000..61cf472b57
--- /dev/null
+++ b/src/widgets/styles/qs60style.h
@@ -0,0 +1,118 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QS60STYLE_H
+#define QS60STYLE_H
+
+#include <QtWidgets/qcommonstyle.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+//Public custom pixel metrics values.
+//These can be used to fetch custom pixel metric value from outside QS60Style.
+enum {
+ PM_FrameCornerWidth = QStyle::PM_CustomBase + 1,
+ PM_FrameCornerHeight,
+ PM_BoldLineWidth,
+ PM_ThinLineWidth,
+ PM_MessageBoxHeight
+ };
+
+class QS60StylePrivate;
+
+class Q_GUI_EXPORT QS60Style : public QCommonStyle
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QS60Style)
+
+public:
+ QS60Style();
+ ~QS60Style();
+
+ void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = 0) const;
+ void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const;
+ void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const;
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
+ QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w = 0) const;
+ int styleHint(StyleHint sh, const QStyleOption *opt = 0, const QWidget *w = 0,
+ QStyleHintReturn *shret = 0) const;
+ QRect subControlRect(ComplexControl control, const QStyleOptionComplex *option, SubControl scontrol, const QWidget *widget = 0) const;
+ QRect subElementRect(SubElement element, const QStyleOption *opt, const QWidget *widget = 0) const;
+ void polish(QWidget *widget);
+ void unpolish(QWidget *widget);
+ void polish(QApplication *application);
+ void unpolish(QApplication *application);
+#ifndef Q_NO_USING_KEYWORD
+ using QCommonStyle::polish;
+#endif
+ bool event(QEvent *e);
+
+#ifndef Q_OS_SYMBIAN
+ static QStringList partKeys();
+ static QStringList colorListKeys();
+ void setS60Theme(const QHash<QString, QPicture> &parts,
+ const QHash<QPair<QString , int>, QColor> &colors);
+ bool loadS60ThemeFromBlob(const QString &blobFile);
+ bool saveS60ThemeToBlob(const QString &blobFile) const;
+#endif // !Q_OS_SYMBIAN
+
+protected Q_SLOTS:
+ QIcon standardIconImplementation(
+ StandardPixmap standardIcon, const QStyleOption * option = 0, const QWidget * widget = 0 ) const;
+
+protected:
+ void timerEvent(QTimerEvent *event);
+ bool eventFilter(QObject *o, QEvent *e);
+private:
+ Q_DISABLE_COPY(QS60Style)
+ friend class QStyleFactory;
+ friend class QApplicationPrivate;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QS60STYLE_H
diff --git a/src/gui/styles/qs60style_p.h b/src/widgets/styles/qs60style_p.h
index e146a4e3ac..e146a4e3ac 100644
--- a/src/gui/styles/qs60style_p.h
+++ b/src/widgets/styles/qs60style_p.h
diff --git a/src/gui/styles/qs60style_s60.cpp b/src/widgets/styles/qs60style_s60.cpp
index 1e374cbc09..1e374cbc09 100644
--- a/src/gui/styles/qs60style_s60.cpp
+++ b/src/widgets/styles/qs60style_s60.cpp
diff --git a/src/gui/styles/qs60style_simulated.cpp b/src/widgets/styles/qs60style_simulated.cpp
index a5aeac3fb9..a5aeac3fb9 100644
--- a/src/gui/styles/qs60style_simulated.cpp
+++ b/src/widgets/styles/qs60style_simulated.cpp
diff --git a/src/gui/styles/qs60style_stub.cpp b/src/widgets/styles/qs60style_stub.cpp
index a3a5b9d0ec..a3a5b9d0ec 100644
--- a/src/gui/styles/qs60style_stub.cpp
+++ b/src/widgets/styles/qs60style_stub.cpp
diff --git a/src/widgets/styles/qstyle.cpp b/src/widgets/styles/qstyle.cpp
new file mode 100644
index 0000000000..ecb5ee51a1
--- /dev/null
+++ b/src/widgets/styles/qstyle.cpp
@@ -0,0 +1,2459 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qstyle.h"
+#include "qapplication.h"
+#include "qpainter.h"
+#include "qwidget.h"
+#include "qbitmap.h"
+#include "qpixmapcache.h"
+#include "qstyleoption.h"
+#include "private/qstyle_p.h"
+#include "private/qguiapplication_p.h"
+#ifndef QT_NO_DEBUG
+#include "qdebug.h"
+#endif
+
+#ifdef Q_WS_X11
+#include <qx11info_x11.h>
+#endif
+
+#include <limits.h>
+
+QT_BEGIN_NAMESPACE
+
+static const int MaxBits = 8 * sizeof(QSizePolicy::ControlType);
+
+static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::ControlType *array)
+{
+ if (!controls)
+ return 0;
+
+ // optimization: exactly one bit is set
+ if ((controls & (controls - 1)) == 0) {
+ array[0] = QSizePolicy::ControlType(uint(controls));
+ return 1;
+ }
+
+ int count = 0;
+ for (int i = 0; i < MaxBits; ++i) {
+ if (uint bit = (controls & (0x1 << i)))
+ array[count++] = QSizePolicy::ControlType(bit);
+ }
+ return count;
+}
+
+/*!
+ \class QStyle
+ \brief The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
+
+ \ingroup appearance
+
+ Qt contains a set of QStyle subclasses that emulate the styles of
+ the different platforms supported by Qt (QWindowsStyle,
+ QMacStyle, QMotifStyle, etc.). By default, these styles are built
+ into the QtGui library. Styles can also be made available as
+ plugins.
+
+ Qt's built-in widgets use QStyle to perform nearly all of their
+ drawing, ensuring that they look exactly like the equivalent
+ native widgets. The diagram below shows a QComboBox in eight
+ different styles.
+
+ \img qstyle-comboboxes.png Eight combo boxes
+
+ Topics:
+
+ \tableofcontents
+
+ \section1 Setting a Style
+
+ The style of the entire application can be set using the
+ QApplication::setStyle() function. It can also be specified by the
+ user of the application, using the \c -style command-line option:
+
+ \snippet doc/src/snippets/code/src_gui_styles_qstyle.cpp 0
+
+ If no style is specified, Qt will choose the most appropriate
+ style for the user's platform or desktop environment.
+
+ A style can also be set on an individual widget using the
+ QWidget::setStyle() function.
+
+ \section1 Developing Style-Aware Custom Widgets
+
+ If you are developing custom widgets and want them to look good on
+ all platforms, you can use QStyle functions to perform parts of
+ the widget drawing, such as drawItemText(), drawItemPixmap(),
+ drawPrimitive(), drawControl(), and drawComplexControl().
+
+ Most QStyle draw functions take four arguments:
+ \list
+ \o an enum value specifying which graphical element to draw
+ \o a QStyleOption specifying how and where to render that element
+ \o a QPainter that should be used to draw the element
+ \o a QWidget on which the drawing is performed (optional)
+ \endlist
+
+ For example, if you want to draw a focus rectangle on your
+ widget, you can write:
+
+ \snippet doc/src/snippets/styles/styles.cpp 1
+
+ QStyle gets all the information it needs to render the graphical
+ element from QStyleOption. The widget is passed as the last
+ argument in case the style needs it to perform special effects
+ (such as animated default buttons on Mac OS X), but it isn't
+ mandatory. In fact, you can use QStyle to draw on any paint
+ device, not just widgets, by setting the QPainter properly.
+
+ QStyleOption has various subclasses for the various types of
+ graphical elements that can be drawn. For example,
+ PE_FrameFocusRect expects a QStyleOptionFocusRect argument.
+
+ To ensure that drawing operations are as fast as possible,
+ QStyleOption and its subclasses have public data members. See the
+ QStyleOption class documentation for details on how to use it.
+
+ For convenience, Qt provides the QStylePainter class, which
+ combines a QStyle, a QPainter, and a QWidget. This makes it
+ possible to write
+
+ \snippet doc/src/snippets/styles/styles.cpp 5
+ \dots
+ \snippet doc/src/snippets/styles/styles.cpp 7
+
+ instead of
+
+ \snippet doc/src/snippets/styles/styles.cpp 2
+ \dots
+ \snippet doc/src/snippets/styles/styles.cpp 3
+
+ \section1 Creating a Custom Style
+
+ You can create a custom look and feel for your application by
+ creating a custom style. There are two approaches to creating a
+ custom style. In the static approach, you either choose an
+ existing QStyle class, subclass it, and reimplement virtual
+ functions to provide the custom behavior, or you create an entire
+ QStyle class from scratch. In the dynamic approach, you modify the
+ behavior of your system style at runtime. The static approach is
+ described below. The dynamic approach is described in QProxyStyle.
+
+ The first step in the static approach is to pick one of the styles
+ provided by Qt from which you will build your custom style. Your
+ choice of QStyle class will depend on which style resembles your
+ desired style the most. The most general class that you can use as
+ a base is QCommonStyle (not QStyle). This is because Qt requires
+ its styles to be \l{QCommonStyle}s.
+
+ Depending on which parts of the base style you want to change,
+ you must reimplement the functions that are used to draw those
+ parts of the interface. To illustrate this, we will modify the
+ look of the spin box arrows drawn by QWindowsStyle. The arrows
+ are \e{primitive elements} that are drawn by the drawPrimitive()
+ function, so we need to reimplement that function. We need the
+ following class declaration:
+
+ \snippet doc/src/snippets/customstyle/customstyle.h 0
+
+ To draw its up and down arrows, QSpinBox uses the
+ PE_IndicatorSpinUp and PE_IndicatorSpinDown primitive elements.
+ Here's how to reimplement the drawPrimitive() function to draw
+ them differently:
+
+ \snippet doc/src/snippets/customstyle/customstyle.cpp 2
+ \snippet doc/src/snippets/customstyle/customstyle.cpp 3
+ \snippet doc/src/snippets/customstyle/customstyle.cpp 4
+
+ Notice that we don't use the \c widget argument, except to pass it
+ on to the QWindowStyle::drawPrimitive() function. As mentioned
+ earlier, the information about what is to be drawn and how it
+ should be drawn is specified by a QStyleOption object, so there is
+ no need to ask the widget.
+
+ If you need to use the \c widget argument to obtain additional
+ information, be careful to ensure that it isn't 0 and that it is
+ of the correct type before using it. For example:
+
+ \snippet doc/src/snippets/customstyle/customstyle.cpp 0
+ \dots
+ \snippet doc/src/snippets/customstyle/customstyle.cpp 1
+
+ When implementing a custom style, you cannot assume that the
+ widget is a QSpinBox just because the enum value is called
+ PE_IndicatorSpinUp or PE_IndicatorSpinDown.
+
+ The documentation for the \l{widgets/styles}{Styles} example
+ covers this topic in more detail.
+
+ \warning Qt style sheets are currently not supported for custom QStyle
+ subclasses. We plan to address this in some future release.
+
+
+ \section1 Using a Custom Style
+
+ There are several ways of using a custom style in a Qt
+ application. The simplest way is to pass the custom style to the
+ QApplication::setStyle() static function before creating the
+ QApplication object:
+
+ \snippet snippets/customstyle/main.cpp using a custom style
+
+ You can call QApplication::setStyle() at any time, but by calling
+ it before the constructor, you ensure that the user's preference,
+ set using the \c -style command-line option, is respected.
+
+ You may want to make your custom style available for use in other
+ applications, which may not be yours and hence not available for
+ you to recompile. The Qt Plugin system makes it possible to create
+ styles as plugins. Styles created as plugins are loaded as shared
+ objects at runtime by Qt itself. Please refer to the \link
+ plugins-howto.html Qt Plugin\endlink documentation for more
+ information on how to go about creating a style plugin.
+
+ Compile your plugin and put it into Qt's \c plugins/styles
+ directory. We now have a pluggable style that Qt can load
+ automatically. To use your new style with existing applications,
+ simply start the application with the following argument:
+
+ \snippet doc/src/snippets/code/src_gui_styles_qstyle.cpp 1
+
+ The application will use the look and feel from the custom style you
+ implemented.
+
+ \section1 Right-to-Left Desktops
+
+ Languages written from right to left (such as Arabic and Hebrew)
+ usually also mirror the whole layout of widgets, and require the
+ light to come from the screen's top-right corner instead of
+ top-left.
+
+ If you create a custom style, you should take special care when
+ drawing asymmetric elements to make sure that they also look
+ correct in a mirrored layout. An easy way to test your styles is
+ to run applications with the \c -reverse command-line option or
+ to call QApplication::setLayoutDirection() in your \c main()
+ function.
+
+ Here are some things to keep in mind when making a style work well in a
+ right-to-left environment:
+
+ \list
+ \o subControlRect() and subElementRect() return rectangles in screen coordinates
+ \o QStyleOption::direction indicates in which direction the item should be drawn in
+ \o If a style is not right-to-left aware it will display items as if it were left-to-right
+ \o visualRect(), visualPos(), and visualAlignment() are helpful functions that will
+ translate from logical to screen representations.
+ \o alignedRect() will return a logical rect aligned for the current direction
+ \endlist
+
+ \section1 Styles in Item Views
+
+ The painting of items in views is performed by a delegate. Qt's
+ default delegate, QStyledItemDelegate, is also used for for calculating bounding
+ rectangles of items, and their sub-elements for the various kind
+ of item \l{Qt::ItemDataRole}{data roles}
+ QStyledItemDelegate supports. See the QStyledItemDelegate class
+ description to find out which datatypes and roles are supported. You
+ can read more about item data roles in \l{Model/View Programming}.
+
+ When QStyledItemDelegate paints its items, it draws
+ CE_ItemViewItem, and calculates their size with CT_ItemViewItem.
+ Note also that it uses SE_ItemViewItemText to set the size of
+ editors. When implementing a style to customize drawing of item
+ views, you need to check the implementation of QCommonStyle (and
+ any other subclasses from which your style
+ inherits). This way, you find out which and how
+ other style elements are painted, and you can then reimplement the
+ painting of elements that should be drawn differently.
+
+ We include a small example where we customize the drawing of item
+ backgrounds.
+
+ \snippet doc/src/snippets/customviewstyle.cpp 0
+
+ The primitive element PE_PanelItemViewItem is responsible for
+ painting the background of items, and is called from
+ \l{QCommonStyle}'s implementation of CE_ItemViewItem.
+
+ To add support for drawing of new datatypes and item data roles,
+ it is necessary to create a custom delegate. But if you only
+ need to support the datatypes implemented by the default
+ delegate, a custom style does not need an accompanying
+ delegate. The QStyledItemDelegate class description gives more
+ information on custom delegates.
+
+ The drawing of item view headers is also done by the style, giving
+ control over size of header items and row and column sizes.
+
+ \sa QStyleOption, QStylePainter, {Styles Example},
+ {Styles and Style Aware Widgets}, QStyledItemDelegate
+*/
+
+/*!
+ Constructs a style object.
+*/
+QStyle::QStyle()
+ : QObject(*new QStylePrivate)
+{
+ Q_D(QStyle);
+ d->proxyStyle = this;
+}
+
+/*!
+ \internal
+
+ Constructs a style object.
+*/
+QStyle::QStyle(QStylePrivate &dd)
+ : QObject(dd)
+{
+ Q_D(QStyle);
+ d->proxyStyle = this;
+}
+
+/*!
+ Destroys the style object.
+*/
+QStyle::~QStyle()
+{
+}
+
+/*!
+ Initializes the appearance of the given \a widget.
+
+ This function is called for every widget at some point after it
+ has been fully created but just \e before it is shown for the very
+ first time.
+
+ Note that the default implementation does nothing. Reasonable
+ actions in this function might be to call the
+ QWidget::setBackgroundMode() function for the widget. Do not use
+ the function to set, for example, the geometry. Reimplementing
+ this function provides a back-door through which the appearance
+ of a widget can be changed, but with Qt's style engine it is
+ rarely necessary to implement this function; reimplement
+ drawItemPixmap(), drawItemText(), drawPrimitive(), etc. instead.
+
+ The QWidget::inherits() function may provide enough information to
+ allow class-specific customizations. But because new QStyle
+ subclasses are expected to work reasonably with all current and \e
+ future widgets, limited use of hard-coded customization is
+ recommended.
+
+ \sa unpolish()
+*/
+void QStyle::polish(QWidget * /* widget */)
+{
+}
+
+/*!
+ Uninitialize the given \a{widget}'s appearance.
+
+ This function is the counterpart to polish(). It is called for
+ every polished widget whenever the style is dynamically changed;
+ the former style has to unpolish its settings before the new style
+ can polish them again.
+
+ Note that unpolish() will only be called if the widget is
+ destroyed. This can cause problems in some cases, e.g, if you
+ remove a widget from the UI, cache it, and then reinsert it after
+ the style has changed; some of Qt's classes cache their widgets.
+
+ \sa polish()
+*/
+void QStyle::unpolish(QWidget * /* widget */)
+{
+}
+
+/*!
+ \fn void QStyle::polish(QApplication * application)
+ \overload
+
+ Late initialization of the given \a application object.
+*/
+void QStyle::polish(QApplication * /* app */)
+{
+}
+
+/*!
+ \fn void QStyle::unpolish(QApplication * application)
+ \overload
+
+ Uninitialize the given \a application.
+*/
+void QStyle::unpolish(QApplication * /* app */)
+{
+}
+
+/*!
+ \fn void QStyle::polish(QPalette & palette)
+ \overload
+
+ Changes the \a palette according to style specific requirements
+ for color palettes (if any).
+
+ \sa QPalette, QApplication::setPalette()
+*/
+void QStyle::polish(QPalette & /* pal */)
+{
+}
+
+/*!
+ \fn QRect QStyle::itemTextRect(const QFontMetrics &metrics, const QRect &rectangle, int alignment, bool enabled, const QString &text) const
+
+ Returns the area within the given \a rectangle in which to draw
+ the provided \a text according to the specified font \a metrics
+ and \a alignment. The \a enabled parameter indicates whether or
+ not the associated item is enabled.
+
+ If the given \a rectangle is larger than the area needed to render
+ the \a text, the rectangle that is returned will be offset within
+ \a rectangle according to the specified \a alignment. For
+ example, if \a alignment is Qt::AlignCenter, the returned
+ rectangle will be centered within \a rectangle. If the given \a
+ rectangle is smaller than the area needed, the returned rectangle
+ will be the smallest rectangle large enough to render the \a text.
+
+ \sa Qt::Alignment
+*/
+QRect QStyle::itemTextRect(const QFontMetrics &metrics, const QRect &rect, int alignment, bool enabled,
+ const QString &text) const
+{
+ QRect result;
+ int x, y, w, h;
+ rect.getRect(&x, &y, &w, &h);
+ if (!text.isEmpty()) {
+ result = metrics.boundingRect(x, y, w, h, alignment, text);
+ if (!enabled && proxy()->styleHint(SH_EtchDisabledText)) {
+ result.setWidth(result.width()+1);
+ result.setHeight(result.height()+1);
+ }
+ } else {
+ result = QRect(x, y, w, h);
+ }
+ return result;
+}
+
+/*!
+ \fn QRect QStyle::itemPixmapRect(const QRect &rectangle, int alignment, const QPixmap &pixmap) const
+
+ Returns the area within the given \a rectangle in which to draw
+ the specified \a pixmap according to the defined \a alignment.
+*/
+QRect QStyle::itemPixmapRect(const QRect &rect, int alignment, const QPixmap &pixmap) const
+{
+ QRect result;
+ int x, y, w, h;
+ rect.getRect(&x, &y, &w, &h);
+ if ((alignment & Qt::AlignVCenter) == Qt::AlignVCenter)
+ y += h/2 - pixmap.height()/2;
+ else if ((alignment & Qt::AlignBottom) == Qt::AlignBottom)
+ y += h - pixmap.height();
+ if ((alignment & Qt::AlignRight) == Qt::AlignRight)
+ x += w - pixmap.width();
+ else if ((alignment & Qt::AlignHCenter) == Qt::AlignHCenter)
+ x += w/2 - pixmap.width()/2;
+ else if ((alignment & Qt::AlignLeft) != Qt::AlignLeft && QApplication::isRightToLeft())
+ x += w - pixmap.width();
+ result = QRect(x, y, pixmap.width(), pixmap.height());
+ return result;
+}
+
+/*!
+ \fn void QStyle::drawItemText(QPainter *painter, const QRect &rectangle, int alignment, const QPalette &palette, bool enabled, const QString& text, QPalette::ColorRole textRole) const
+
+ Draws the given \a text in the specified \a rectangle using the
+ provided \a painter and \a palette.
+
+ The text is drawn using the painter's pen, and aligned and wrapped
+ according to the specified \a alignment. If an explicit \a
+ textRole is specified, the text is drawn using the \a palette's
+ color for the given role. The \a enabled parameter indicates
+ whether or not the item is enabled; when reimplementing this
+ function, the \a enabled parameter should influence how the item is
+ drawn.
+
+ \sa Qt::Alignment, drawItemPixmap()
+*/
+void QStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal,
+ bool enabled, const QString& text, QPalette::ColorRole textRole) const
+{
+ if (text.isEmpty())
+ return;
+ QPen savedPen;
+ if (textRole != QPalette::NoRole) {
+ savedPen = painter->pen();
+ painter->setPen(QPen(pal.brush(textRole), savedPen.widthF()));
+ }
+ if (!enabled) {
+ if (proxy()->styleHint(SH_DitherDisabledText)) {
+ QRect br;
+ painter->drawText(rect, alignment, text, &br);
+ painter->fillRect(br, QBrush(painter->background().color(), Qt::Dense5Pattern));
+ return;
+ } else if (proxy()->styleHint(SH_EtchDisabledText)) {
+ QPen pen = painter->pen();
+ painter->setPen(pal.light().color());
+ painter->drawText(rect.adjusted(1, 1, 1, 1), alignment, text);
+ painter->setPen(pen);
+ }
+ }
+ painter->drawText(rect, alignment, text);
+ if (textRole != QPalette::NoRole)
+ painter->setPen(savedPen);
+}
+
+/*!
+ \fn void QStyle::drawItemPixmap(QPainter *painter, const QRect &rectangle, int alignment,
+ const QPixmap &pixmap) const
+
+ Draws the given \a pixmap in the specified \a rectangle, according
+ to the specified \a alignment, using the provided \a painter.
+
+ \sa drawItemText()
+*/
+
+void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
+ const QPixmap &pixmap) const
+{
+ QRect aligned = alignedRect(QApplication::layoutDirection(), QFlag(alignment), pixmap.size(), rect);
+ QRect inter = aligned.intersected(rect);
+
+ painter->drawPixmap(inter.x(), inter.y(), pixmap, inter.x() - aligned.x(), inter.y() - aligned.y(), inter.width(), inter.height());
+}
+
+/*!
+ \enum QStyle::PrimitiveElement
+
+ This enum describes the various primitive elements. A
+ primitive element is a common GUI element, such as a checkbox
+ indicator or button bevel.
+
+ \omitvalue PE_IndicatorViewItemCheck
+ \value PE_FrameStatusBar Frame
+
+ \value PE_PanelButtonCommand Button used to initiate an action, for
+ example, a QPushButton.
+
+ \value PE_FrameDefaultButton This frame around a default button, e.g. in a dialog.
+ \value PE_PanelButtonBevel Generic panel with a button bevel.
+ \value PE_PanelButtonTool Panel for a Tool button, used with QToolButton.
+ \value PE_PanelLineEdit Panel for a QLineEdit.
+ \value PE_IndicatorButtonDropDown Indicator for a drop down button, for example, a tool
+ button that displays a menu.
+
+ \value PE_FrameFocusRect Generic focus indicator.
+
+ \value PE_IndicatorArrowUp Generic Up arrow.
+ \value PE_IndicatorArrowDown Generic Down arrow.
+ \value PE_IndicatorArrowRight Generic Right arrow.
+ \value PE_IndicatorArrowLeft Generic Left arrow.
+
+ \value PE_IndicatorSpinUp Up symbol for a spin widget, for example a QSpinBox.
+ \value PE_IndicatorSpinDown Down symbol for a spin widget.
+ \value PE_IndicatorSpinPlus Increase symbol for a spin widget.
+ \value PE_IndicatorSpinMinus Decrease symbol for a spin widget.
+
+ \value PE_IndicatorItemViewItemCheck On/off indicator for a view item.
+
+ \value PE_IndicatorCheckBox On/off indicator, for example, a QCheckBox.
+ \value PE_IndicatorRadioButton Exclusive on/off indicator, for example, a QRadioButton.
+
+ \value PE_Q3DockWindowSeparator Item separator for Qt 3 compatible dock window
+ and toolbar contents.
+ \value PE_IndicatorDockWidgetResizeHandle Resize handle for dock windows.
+
+ \value PE_Frame Generic frame
+ \value PE_FrameMenu Frame for popup windows/menus; see also QMenu.
+ \value PE_PanelMenuBar Panel for menu bars.
+ \value PE_PanelScrollAreaCorner Panel at the bottom-right (or
+ bottom-left) corner of a scroll area.
+
+ \value PE_FrameDockWidget Panel frame for dock windows and toolbars.
+ \value PE_FrameTabWidget Frame for tab widgets.
+ \value PE_FrameLineEdit Panel frame for line edits.
+ \value PE_FrameGroupBox Panel frame around group boxes.
+ \value PE_FrameButtonBevel Panel frame for a button bevel.
+ \value PE_FrameButtonTool Panel frame for a tool button.
+
+ \value PE_IndicatorHeaderArrow Arrow used to indicate sorting on a list or table
+ header.
+ \value PE_FrameStatusBarItem Frame for an item of a status bar; see also QStatusBar.
+
+ \value PE_FrameWindow Frame around a MDI window or a docking window.
+
+ \value PE_Q3Separator Qt 3 compatible generic separator.
+
+ \value PE_IndicatorMenuCheckMark Check mark used in a menu.
+
+ \value PE_IndicatorProgressChunk Section of a progress bar indicator; see also QProgressBar.
+
+ \value PE_Q3CheckListController Qt 3 compatible controller part of a list view item.
+ \value PE_Q3CheckListIndicator Qt 3 compatible checkbox part of a list view item.
+ \value PE_Q3CheckListExclusiveIndicator Qt 3 compatible radio button part of a list view item.
+
+ \value PE_IndicatorBranch Lines used to represent the branch of a tree in a tree view.
+ \value PE_IndicatorToolBarHandle The handle of a toolbar.
+ \value PE_IndicatorToolBarSeparator The separator in a toolbar.
+ \value PE_PanelToolBar The panel for a toolbar.
+ \value PE_PanelTipLabel The panel for a tip label.
+ \value PE_FrameTabBarBase The frame that is drawn for a tab bar, ususally drawn for a tab bar that isn't part of a tab widget.
+ \value PE_IndicatorTabTear An indicator that a tab is partially scrolled out of the visible tab bar when there are many tabs.
+ \value PE_IndicatorColumnViewArrow An arrow in a QColumnView.
+
+ \value PE_Widget A plain QWidget.
+
+ \value PE_CustomBase Base value for custom primitive elements.
+ All values above this are reserved for custom use. Custom values
+ must be greater than this value.
+
+ \value PE_IndicatorItemViewItemDrop An indicator that is drawn to show where an item in an item view is about to be dropped
+ during a drag-and-drop operation in an item view.
+ \value PE_PanelItemViewItem The background for an item in an item view.
+ \value PE_PanelItemViewRow The background of a row in an item view.
+
+ \value PE_PanelStatusBar The panel for a status bar.
+
+ \value PE_IndicatorTabClose The close button on a tab bar.
+ \value PE_PanelMenu The panel for a menu.
+
+ \sa drawPrimitive()
+*/
+
+/*!
+ \typedef QStyle::SFlags
+ \internal
+*/
+
+/*!
+ \typedef QStyle::SCFlags
+ \internal
+*/
+
+/*!
+ \enum QStyle::StateFlag
+
+ This enum describes flags that are used when drawing primitive
+ elements.
+
+ Note that not all primitives use all of these flags, and that the
+ flags may mean different things to different items.
+
+ \value State_None Indicates that the widget does not have a state.
+ \value State_Active Indicates that the widget is active.
+ \value State_AutoRaise Used to indicate if auto-raise appearance should be usd on a tool button.
+ \value State_Children Used to indicate if an item view branch has children.
+ \value State_DownArrow Used to indicate if a down arrow should be visible on the widget.
+ \value State_Editing Used to indicate if an editor is opened on the widget.
+ \value State_Enabled Used to indicate if the widget is enabled.
+ \value State_HasEditFocus Used to indicate if the widget currently has edit focus.
+ \value State_HasFocus Used to indicate if the widget has focus.
+ \value State_Horizontal Used to indicate if the widget is laid out horizontally, for example. a tool bar.
+ \value State_KeyboardFocusChange Used to indicate if the focus was changed with the keyboard, e.g., tab, backtab or shortcut.
+ \value State_MouseOver Used to indicate if the widget is under the mouse.
+ \value State_NoChange Used to indicate a tri-state checkbox.
+ \value State_Off Used to indicate if the widget is not checked.
+ \value State_On Used to indicate if the widget is checked.
+ \value State_Raised Used to indicate if a button is raised.
+ \value State_ReadOnly Used to indicate if a widget is read-only.
+ \value State_Selected Used to indicate if a widget is selected.
+ \value State_Item Used by item views to indicate if a horizontal branch should be drawn.
+ \value State_Open Used by item views to indicate if the tree branch is open.
+ \value State_Sibling Used by item views to indicate if a vertical line needs to be drawn (for siblings).
+ \value State_Sunken Used to indicate if the widget is sunken or pressed.
+ \value State_UpArrow Used to indicate if an up arrow should be visible on the widget.
+ \value State_Mini Used to indicate a mini style Mac widget or button.
+ \value State_Small Used to indicate a small style Mac widget or button.
+ \omitvalue State_Window
+ \omitvalue State_Bottom
+ \omitvalue State_Default
+ \omitvalue State_FocusAtBorder
+ \omitvalue State_Top
+
+ \sa drawPrimitive()
+*/
+
+/*!
+ \fn void QStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, \
+ QPainter *painter, const QWidget *widget) const
+
+ Draws the given primitive \a element with the provided \a painter using the style
+ options specified by \a option.
+
+ The \a widget argument is optional and may contain a widget that may
+ aid in drawing the primitive element.
+
+ The table below is listing the primitive elements and their
+ associated style option subclasses. The style options contain all
+ the parameters required to draw the elements, including
+ QStyleOption::state which holds the style flags that are used when
+ drawing. The table also describes which flags that are set when
+ casting the given option to the appropriate subclass.
+
+ Note that if a primitive element is not listed here, it is because
+ it uses a plain QStyleOption object.
+
+ \table
+ \header \o Primitive Element \o QStyleOption Subclass \o Style Flag \o Remark
+ \row \o \l PE_FrameFocusRect \o \l QStyleOptionFocusRect
+ \o \l State_FocusAtBorder
+ \o Whether the focus is is at the border or inside the widget.
+ \row \o{1,2} \l PE_IndicatorCheckBox \o{1,2} \l QStyleOptionButton
+ \o \l State_NoChange \o Indicates a "tri-state" checkbox.
+ \row \o \l State_On \o Indicates the indicator is checked.
+ \row \o \l PE_IndicatorRadioButton \o \l QStyleOptionButton
+ \o \l State_On \o Indicates that a radio button is selected.
+ \row \o{1,3} \l PE_Q3CheckListExclusiveIndicator, \l PE_Q3CheckListIndicator
+ \o{1,3} \l QStyleOptionQ3ListView \o \l State_On
+ \o Indicates whether or not the controller is selected.
+ \row \o \l State_NoChange \o Indicates a "tri-state" controller.
+ \row \o \l State_Enabled \o Indicates the controller is enabled.
+ \row \o{1,4} \l PE_IndicatorBranch \o{1,4} \l QStyleOption
+ \o \l State_Children \o Indicates that the control for expanding the tree to show child items, should be drawn.
+ \row \o \l State_Item \o Indicates that a horizontal branch (to show a child item), should be drawn.
+ \row \o \l State_Open \o Indicates that the tree branch is expanded.
+ \row \o \l State_Sibling \o Indicates that a vertical line (to show a sibling item), should be drawn.
+ \row \o \l PE_IndicatorHeaderArrow \o \l QStyleOptionHeader
+ \o \l State_UpArrow \o Indicates that the arrow should be drawn up;
+ otherwise it should be down.
+ \row \o \l PE_FrameGroupBox, \l PE_Frame, \l PE_FrameLineEdit,
+ \l PE_FrameMenu, \l PE_FrameDockWidget, \l PE_FrameWindow
+ \o \l QStyleOptionFrame \o \l State_Sunken
+ \o Indicates that the Frame should be sunken.
+ \row \o \l PE_IndicatorToolBarHandle \o \l QStyleOption
+ \o \l State_Horizontal \o Indicates that the window handle is horizontal
+ instead of vertical.
+ \row \o \l PE_Q3DockWindowSeparator \o \l QStyleOption
+ \o \l State_Horizontal \o Indicates that the separator is horizontal
+ instead of vertical.
+ \row \o \l PE_IndicatorSpinPlus, \l PE_IndicatorSpinMinus, \l PE_IndicatorSpinUp,
+ \l PE_IndicatorSpinDown,
+ \o \l QStyleOptionSpinBox
+ \o \l State_Sunken \o Indicates that the button is pressed.
+ \row \o{1,5} \l PE_PanelButtonCommand
+ \o{1,5} \l QStyleOptionButton
+ \o \l State_Enabled \o Set if the button is enabled.
+ \row \o \l State_HasFocus \o Set if the button has input focus.
+ \row \o \l State_Raised \o Set if the button is not down, not on and not flat.
+ \row \o \l State_On \o Set if the button is a toggle button and is toggled on.
+ \row \o \l State_Sunken
+ \o Set if the button is down (i.e., the mouse button or the
+ space bar is pressed on the button).
+ \endtable
+
+ \sa drawComplexControl(), drawControl()
+*/
+
+/*!
+ \enum QStyle::ControlElement
+
+ This enum represents a control element. A control element is a
+ part of a widget that performs some action or displays information
+ to the user.
+
+ \value CE_PushButton A QPushButton, draws CE_PushButtonBevel, CE_PushButtonLabel and PE_FrameFocusRect.
+ \value CE_PushButtonBevel The bevel and default indicator of a QPushButton.
+ \value CE_PushButtonLabel The label (an icon with text or pixmap) of a QPushButton.
+
+ \value CE_DockWidgetTitle Dock window title.
+ \value CE_Splitter Splitter handle; see also QSplitter.
+
+
+ \value CE_CheckBox A QCheckBox, draws a PE_IndicatorCheckBox, a CE_CheckBoxLabel and a PE_FrameFocusRect.
+ \value CE_CheckBoxLabel The label (text or pixmap) of a QCheckBox.
+
+ \value CE_RadioButton A QRadioButton, draws a PE_IndicatorRadioButton, a CE_RadioButtonLabel and a PE_FrameFocusRect.
+ \value CE_RadioButtonLabel The label (text or pixmap) of a QRadioButton.
+
+ \value CE_TabBarTab The tab and label within a QTabBar.
+ \value CE_TabBarTabShape The tab shape within a tab bar.
+ \value CE_TabBarTabLabel The label within a tab.
+
+ \value CE_ProgressBar A QProgressBar, draws CE_ProgressBarGroove, CE_ProgressBarContents and CE_ProgressBarLabel.
+ \value CE_ProgressBarGroove The groove where the progress
+ indicator is drawn in a QProgressBar.
+ \value CE_ProgressBarContents The progress indicator of a QProgressBar.
+ \value CE_ProgressBarLabel The text label of a QProgressBar.
+
+ \value CE_ToolButtonLabel A tool button's label.
+
+ \value CE_MenuBarItem A menu item in a QMenuBar.
+ \value CE_MenuBarEmptyArea The empty area of a QMenuBar.
+
+ \value CE_MenuItem A menu item in a QMenu.
+ \value CE_MenuScroller Scrolling areas in a QMenu when the
+ style supports scrolling.
+ \value CE_MenuTearoff A menu item representing the tear off section of
+ a QMenu.
+ \value CE_MenuEmptyArea The area in a menu without menu items.
+ \value CE_MenuHMargin The horizontal extra space on the left/right of a menu.
+ \value CE_MenuVMargin The vertical extra space on the top/bottom of a menu.
+
+ \value CE_Q3DockWindowEmptyArea The empty area of a QDockWidget.
+
+ \value CE_ToolBoxTab The toolbox's tab and label within a QToolBox.
+ \value CE_SizeGrip Window resize handle; see also QSizeGrip.
+
+ \value CE_Header A header.
+ \value CE_HeaderSection A header section.
+ \value CE_HeaderLabel The header's label.
+
+ \value CE_ScrollBarAddLine Scroll bar line increase indicator.
+ (i.e., scroll down); see also QScrollBar.
+ \value CE_ScrollBarSubLine Scroll bar line decrease indicator (i.e., scroll up).
+ \value CE_ScrollBarAddPage Scolllbar page increase indicator (i.e., page down).
+ \value CE_ScrollBarSubPage Scroll bar page decrease indicator (i.e., page up).
+ \value CE_ScrollBarSlider Scroll bar slider.
+ \value CE_ScrollBarFirst Scroll bar first line indicator (i.e., home).
+ \value CE_ScrollBarLast Scroll bar last line indicator (i.e., end).
+
+ \value CE_RubberBand Rubber band used in for example an icon view.
+
+ \value CE_FocusFrame Focus frame that is style controlled.
+
+ \value CE_ItemViewItem An item inside an item view.
+
+ \value CE_CustomBase Base value for custom control elements;
+ custom values must be greater than this value.
+ \value CE_ComboBoxLabel The label of a non-editable QComboBox.
+ \value CE_ToolBar A toolbar like QToolBar.
+ \value CE_ToolBoxTabShape The toolbox's tab shape.
+ \value CE_ToolBoxTabLabel The toolbox's tab label.
+ \value CE_HeaderEmptyArea The area of a header view where there are no header sections.
+
+ \value CE_ShapedFrame The frame with the shape specified in the QStyleOptionFrameV3; see QFrame.
+
+ \omitvalue CE_ColumnViewGrip
+
+ \sa drawControl()
+*/
+
+/*!
+ \fn void QStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
+
+ Draws the given \a element with the provided \a painter with the
+ style options specified by \a option.
+
+ The \a widget argument is optional and can be used as aid in
+ drawing the control. The \a option parameter is a pointer to a
+ QStyleOption object that can be cast to the correct subclass
+ using the qstyleoption_cast() function.
+
+ The table below is listing the control elements and their
+ associated style option subclass. The style options contain all
+ the parameters required to draw the controls, including
+ QStyleOption::state which holds the style flags that are used when
+ drawing. The table also describes which flags that are set when
+ casting the given option to the appropriate subclass.
+
+ Note that if a control element is not listed here, it is because
+ it uses a plain QStyleOption object.
+
+ \table
+ \header \o Control Element \o QStyleOption Subclass \o Style Flag \o Remark
+ \row \o{1,5} \l CE_MenuItem, \l CE_MenuBarItem
+ \o{1,5} \l QStyleOptionMenuItem
+ \o \l State_Selected \o The menu item is currently selected item.
+ \row \o \l State_Enabled \o The item is enabled.
+ \row \o \l State_DownArrow \o Indicates that a scroll down arrow should be drawn.
+ \row \o \l State_UpArrow \o Indicates that a scroll up arrow should be drawn
+ \row \o \l State_HasFocus \o Set if the menu bar has input focus.
+
+ \row \o{1,5} \l CE_PushButton, \l CE_PushButtonBevel, \l CE_PushButtonLabel
+ \o{1,5} \l QStyleOptionButton
+ \o \l State_Enabled \o Set if the button is enabled.
+ \row \o \l State_HasFocus \o Set if the button has input focus.
+ \row \o \l State_Raised \o Set if the button is not down, not on and not flat.
+ \row \o \l State_On \o Set if the button is a toggle button and is toggled on.
+ \row \o \l State_Sunken
+ \o Set if the button is down (i.e., the mouse button or the
+ space bar is pressed on the button).
+
+ \row \o{1,6} \l CE_RadioButton, \l CE_RadioButtonLabel,
+ \l CE_CheckBox, \l CE_CheckBoxLabel
+ \o{1,6} \l QStyleOptionButton
+ \o \l State_Enabled \o Set if the button is enabled.
+ \row \o \l State_HasFocus \o Set if the button has input focus.
+ \row \o \l State_On \o Set if the button is checked.
+ \row \o \l State_Off \o Set if the button is not checked.
+ \row \o \l State_NoChange \o Set if the button is in the NoChange state.
+ \row \o \l State_Sunken
+ \o Set if the button is down (i.e., the mouse button or
+ the space bar is pressed on the button).
+
+ \row \o{1,2} \l CE_ProgressBarContents, \l CE_ProgressBarLabel,
+ \l CE_ProgressBarGroove
+ \o{1,2} \l QStyleOptionProgressBar
+ \o \l State_Enabled \o Set if the progress bar is enabled.
+ \row \o \l State_HasFocus \o Set if the progress bar has input focus.
+
+ \row \o \l CE_Header, \l CE_HeaderSection, \l CE_HeaderLabel \o \l QStyleOptionHeader \o \o
+
+ \row \o{1,3} \l CE_TabBarTab, CE_TabBarTabShape, CE_TabBarTabLabel
+ \o{1,3} \l QStyleOptionTab
+ \o \l State_Enabled \o Set if the tab bar is enabled.
+ \row \o \l State_Selected \o The tab bar is the currently selected tab bar.
+ \row \o \l State_HasFocus \o Set if the tab bar tab has input focus.
+
+ \row \o{1,7} \l CE_ToolButtonLabel
+ \o{1,7} \l QStyleOptionToolButton
+ \o \l State_Enabled \o Set if the tool button is enabled.
+ \row \o \l State_HasFocus \o Set if the tool button has input focus.
+ \row \o \l State_Sunken
+ \o Set if the tool button is down (i.e., a mouse button or
+ the space bar is pressed).
+ \row \o \l State_On \o Set if the tool button is a toggle button and is toggled on.
+ \row \o \l State_AutoRaise \o Set if the tool button has auto-raise enabled.
+ \row \o \l State_MouseOver \o Set if the mouse pointer is over the tool button.
+ \row \o \l State_Raised \o Set if the button is not down and is not on.
+
+ \row \o \l CE_ToolBoxTab \o \l QStyleOptionToolBox
+ \o \l State_Selected \o The tab is the currently selected tab.
+ \row \o{1,3} \l CE_HeaderSection \o{1,3} \l QStyleOptionHeader
+ \o \l State_Sunken \o Indicates that the section is pressed.
+ \row \o \l State_UpArrow \o Indicates that the sort indicator should be pointing up.
+ \row \o \l State_DownArrow \o Indicates that the sort indicator should be pointing down.
+ \endtable
+
+ \sa drawPrimitive(), drawComplexControl()
+*/
+
+/*!
+ \enum QStyle::SubElement
+
+ This enum represents a sub-area of a widget. Style implementations
+ use these areas to draw the different parts of a widget.
+
+ \value SE_PushButtonContents Area containing the label (icon
+ with text or pixmap).
+ \value SE_PushButtonFocusRect Area for the focus rect (usually
+ larger than the contents rect).
+ \value SE_PushButtonLayoutItem Area that counts for the parent layout.
+
+ \value SE_CheckBoxIndicator Area for the state indicator (e.g., check mark).
+ \value SE_CheckBoxContents Area for the label (text or pixmap).
+ \value SE_CheckBoxFocusRect Area for the focus indicator.
+ \value SE_CheckBoxClickRect Clickable area, defaults to SE_CheckBoxFocusRect.
+ \value SE_CheckBoxLayoutItem Area that counts for the parent layout.
+
+ \value SE_DateTimeEditLayoutItem Area that counts for the parent layout.
+
+ \value SE_RadioButtonIndicator Area for the state indicator.
+ \value SE_RadioButtonContents Area for the label.
+ \value SE_RadioButtonFocusRect Area for the focus indicator.
+ \value SE_RadioButtonClickRect Clickable area, defaults to SE_RadioButtonFocusRect.
+ \value SE_RadioButtonLayoutItem Area that counts for the parent layout.
+
+ \value SE_ComboBoxFocusRect Area for the focus indicator.
+
+ \value SE_SliderFocusRect Area for the focus indicator.
+ \value SE_SliderLayoutItem Area that counts for the parent layout.
+
+ \value SE_SpinBoxLayoutItem Area that counts for the parent layout.
+
+ \value SE_Q3DockWindowHandleRect Area for the tear-off handle.
+
+ \value SE_ProgressBarGroove Area for the groove.
+ \value SE_ProgressBarContents Area for the progress indicator.
+ \value SE_ProgressBarLabel Area for the text label.
+ \value SE_ProgressBarLayoutItem Area that counts for the parent layout.
+
+ \omitvalue SE_DialogButtonAccept
+ \omitvalue SE_DialogButtonReject
+ \omitvalue SE_DialogButtonApply
+ \omitvalue SE_DialogButtonHelp
+ \omitvalue SE_DialogButtonAll
+ \omitvalue SE_DialogButtonRetry
+ \omitvalue SE_DialogButtonAbort
+ \omitvalue SE_DialogButtonIgnore
+ \omitvalue SE_DialogButtonCustom
+ \omitvalue SE_ViewItemCheckIndicator
+
+ \value SE_FrameContents Area for a frame's contents.
+ \value SE_ShapedFrameContents Area for a frame's contents using the shape in QStyleOptionFrameV3; see QFrame
+ \value SE_FrameLayoutItem Area that counts for the parent layout.
+
+ \value SE_HeaderArrow Area for the sort indicator for a header.
+ \value SE_HeaderLabel Area for the label in a header.
+
+ \value SE_LabelLayoutItem Area that counts for the parent layout.
+
+ \value SE_LineEditContents Area for a line edit's contents.
+
+ \value SE_TabWidgetLeftCorner Area for the left corner widget in a tab widget.
+ \value SE_TabWidgetRightCorner Area for the right corner widget in a tab widget.
+ \value SE_TabWidgetTabBar Area for the tab bar widget in a tab widget.
+ \value SE_TabWidgetTabContents Area for the contents of the tab widget.
+ \value SE_TabWidgetTabPane Area for the pane of a tab widget.
+ \value SE_TabWidgetLayoutItem Area that counts for the parent layout.
+
+ \value SE_ToolBoxTabContents Area for a toolbox tab's icon and label.
+
+ \value SE_ToolButtonLayoutItem Area that counts for the parent layout.
+
+ \value SE_ItemViewItemCheckIndicator Area for a view item's check mark.
+
+ \value SE_TabBarTearIndicator Area for the tear indicator on a tab bar with scroll arrows.
+
+ \value SE_TreeViewDisclosureItem Area for the actual disclosure item in a tree branch.
+
+ \value SE_DialogButtonBoxLayoutItem Area that counts for the parent layout.
+
+ \value SE_GroupBoxLayoutItem Area that counts for the parent layout.
+
+ \value SE_CustomBase Base value for custom sub-elements.
+ Custom values must be greater than this value.
+
+ \value SE_DockWidgetFloatButton The float button of a dock
+ widget.
+ \value SE_DockWidgetTitleBarText The text bounds of the dock
+ widgets title.
+ \value SE_DockWidgetCloseButton The close button of a dock
+ widget.
+ \value SE_DockWidgetIcon The icon of a dock widget.
+ \value SE_ComboBoxLayoutItem Area that counts for the parent layout.
+
+
+ \value SE_ItemViewItemDecoration Area for a view item's decoration (icon).
+ \value SE_ItemViewItemText Area for a view item's text.
+ \value SE_ItemViewItemFocusRect Area for a view item's focus rect.
+
+ \value SE_TabBarTabLeftButton Area for a widget on the left side of a tab in a tab bar.
+ \value SE_TabBarTabRightButton Area for a widget on the right side of a tab in a tab bar.
+ \value SE_TabBarTabText Area for the text on a tab in a tab bar.
+
+ \value SE_ToolBarHandle Area for the handle of a tool bar.
+
+ \sa subElementRect()
+*/
+
+/*!
+ \fn QRect QStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const
+
+ Returns the sub-area for the given \a element as described in the
+ provided style \a option. The returned rectangle is defined in
+ screen coordinates.
+
+ The \a widget argument is optional and can be used to aid
+ determining the area. The QStyleOption object can be cast to the
+ appropriate type using the qstyleoption_cast() function. See the
+ table below for the appropriate \a option casts:
+
+ \table
+ \header \o Sub Element \o QStyleOption Subclass
+ \row \o \l SE_PushButtonContents \o \l QStyleOptionButton
+ \row \o \l SE_PushButtonFocusRect \o \l QStyleOptionButton
+ \row \o \l SE_CheckBoxIndicator \o \l QStyleOptionButton
+ \row \o \l SE_CheckBoxContents \o \l QStyleOptionButton
+ \row \o \l SE_CheckBoxFocusRect \o \l QStyleOptionButton
+ \row \o \l SE_RadioButtonIndicator \o \l QStyleOptionButton
+ \row \o \l SE_RadioButtonContents \o \l QStyleOptionButton
+ \row \o \l SE_RadioButtonFocusRect \o \l QStyleOptionButton
+ \row \o \l SE_ComboBoxFocusRect \o \l QStyleOptionComboBox
+ \row \o \l SE_Q3DockWindowHandleRect \o \l QStyleOptionQ3DockWindow
+ \row \o \l SE_ProgressBarGroove \o \l QStyleOptionProgressBar
+ \row \o \l SE_ProgressBarContents \o \l QStyleOptionProgressBar
+ \row \o \l SE_ProgressBarLabel \o \l QStyleOptionProgressBar
+ \endtable
+*/
+
+/*!
+ \enum QStyle::ComplexControl
+
+ This enum describes the available complex controls. Complex
+ controls have different behavior depending upon where the user
+ clicks on them or which keys are pressed.
+
+ \value CC_SpinBox A spinbox, like QSpinBox.
+ \value CC_ComboBox A combobox, like QComboBox.
+ \value CC_ScrollBar A scroll bar, like QScrollBar.
+ \value CC_Slider A slider, like QSlider.
+ \value CC_ToolButton A tool button, like QToolButton.
+ \value CC_TitleBar A Title bar, like those used in QMdiSubWindow.
+ \value CC_Q3ListView Used for drawing the Q3ListView class.
+ \value CC_GroupBox A group box, like QGroupBox.
+ \value CC_Dial A dial, like QDial.
+ \value CC_MdiControls The minimize, close, and normal
+ button in the menu bar for a
+ maximized MDI subwindow.
+
+ \value CC_CustomBase Base value for custom complex controls. Custom
+ values must be greater than this value.
+
+ \sa SubControl drawComplexControl()
+*/
+
+/*!
+ \enum QStyle::SubControl
+
+ This enum describes the available sub controls. A subcontrol is a
+ control element within a complex control (ComplexControl).
+
+ \value SC_None Special value that matches no other sub control.
+
+ \value SC_ScrollBarAddLine Scroll bar add line (i.e., down/right
+ arrow); see also QScrollBar.
+ \value SC_ScrollBarSubLine Scroll bar sub line (i.e., up/left arrow).
+ \value SC_ScrollBarAddPage Scroll bar add page (i.e., page down).
+ \value SC_ScrollBarSubPage Scroll bar sub page (i.e., page up).
+ \value SC_ScrollBarFirst Scroll bar first line (i.e., home).
+ \value SC_ScrollBarLast Scroll bar last line (i.e., end).
+ \value SC_ScrollBarSlider Scroll bar slider handle.
+ \value SC_ScrollBarGroove Special sub-control which contains the
+ area in which the slider handle may move.
+
+ \value SC_SpinBoxUp Spin widget up/increase; see also QSpinBox.
+ \value SC_SpinBoxDown Spin widget down/decrease.
+ \value SC_SpinBoxFrame Spin widget frame.
+ \value SC_SpinBoxEditField Spin widget edit field.
+
+ \value SC_ComboBoxEditField Combobox edit field; see also QComboBox.
+ \value SC_ComboBoxArrow Combobox arrow button.
+ \value SC_ComboBoxFrame Combobox frame.
+ \value SC_ComboBoxListBoxPopup The reference rectangle for the combobox popup.
+ Used to calculate the position of the popup.
+
+ \value SC_SliderGroove Special sub-control which contains the area
+ in which the slider handle may move.
+ \value SC_SliderHandle Slider handle.
+ \value SC_SliderTickmarks Slider tickmarks.
+
+ \value SC_ToolButton Tool button (see also QToolButton).
+ \value SC_ToolButtonMenu Sub-control for opening a popup menu in a
+ tool button; see also Q3PopupMenu.
+
+ \value SC_TitleBarSysMenu System menu button (i.e., restore, close, etc.).
+ \value SC_TitleBarMinButton Minimize button.
+ \value SC_TitleBarMaxButton Maximize button.
+ \value SC_TitleBarCloseButton Close button.
+ \value SC_TitleBarLabel Window title label.
+ \value SC_TitleBarNormalButton Normal (restore) button.
+ \value SC_TitleBarShadeButton Shade button.
+ \value SC_TitleBarUnshadeButton Unshade button.
+ \value SC_TitleBarContextHelpButton Context Help button.
+
+ \value SC_Q3ListView The list view area.
+ \value SC_Q3ListViewExpand Expand item (i.e., show/hide child items).
+
+ \value SC_DialHandle The handle of the dial (i.e. what you use to control the dial).
+ \value SC_DialGroove The groove for the dial.
+ \value SC_DialTickmarks The tickmarks for the dial.
+
+ \value SC_GroupBoxFrame The frame of a group box.
+ \value SC_GroupBoxLabel The title of a group box.
+ \value SC_GroupBoxCheckBox The optional check box of a group box.
+ \value SC_GroupBoxContents The group box contents.
+
+ \value SC_MdiNormalButton The normal button for a MDI
+ subwindow in the menu bar.
+ \value SC_MdiMinButton The minimize button for a MDI
+ subwindow in the menu bar.
+ \value SC_MdiCloseButton The close button for a MDI subwindow
+ in the menu bar.
+
+ \value SC_All Special value that matches all sub-controls.
+ \omitvalue SC_Q3ListViewBranch
+ \omitvalue SC_CustomBase
+
+ \sa ComplexControl
+*/
+
+/*!
+ \fn void QStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const
+
+ Draws the given \a control using the provided \a painter with the
+ style options specified by \a option.
+
+ The \a widget argument is optional and can be used as aid in
+ drawing the control.
+
+ The \a option parameter is a pointer to a QStyleOptionComplex
+ object that can be cast to the correct subclass using the
+ qstyleoption_cast() function. Note that the \c rect member of the
+ specified \a option must be in logical
+ coordinates. Reimplementations of this function should use
+ visualRect() to change the logical coordinates into screen
+ coordinates before calling the drawPrimitive() or drawControl()
+ function.
+
+ The table below is listing the complex control elements and their
+ associated style option subclass. The style options contain all
+ the parameters required to draw the controls, including
+ QStyleOption::state which holds the \l {QStyle::StateFlag}{style
+ flags} that are used when drawing. The table also describes which
+ flags that are set when casting the given \a option to the
+ appropriate subclass.
+
+ \table
+ \header \o Complex Control \o QStyleOptionComplex Subclass \o Style Flag \o Remark
+ \row \o{1,2} \l{CC_SpinBox} \o{1,2} \l QStyleOptionSpinBox
+ \o \l State_Enabled \o Set if the spin box is enabled.
+ \row \o \l State_HasFocus \o Set if the spin box has input focus.
+
+ \row \o{1,2} \l {CC_ComboBox} \o{1,2} \l QStyleOptionComboBox
+ \o \l State_Enabled \o Set if the combobox is enabled.
+ \row \o \l State_HasFocus \o Set if the combobox has input focus.
+
+ \row \o{1,2} \l {CC_ScrollBar} \o{1,2} \l QStyleOptionSlider
+ \o \l State_Enabled \o Set if the scroll bar is enabled.
+ \row \o \l State_HasFocus \o Set if the scroll bar has input focus.
+
+ \row \o{1,2} \l {CC_Slider} \o{1,2} \l QStyleOptionSlider
+ \o \l State_Enabled \o Set if the slider is enabled.
+ \row \o \l State_HasFocus \o Set if the slider has input focus.
+
+ \row \o{1,2} \l {CC_Dial} \o{1,2} \l QStyleOptionSlider
+ \o \l State_Enabled \o Set if the dial is enabled.
+ \row \o \l State_HasFocus \o Set if the dial has input focus.
+
+ \row \o{1,6} \l {CC_ToolButton} \o{1,6} \l QStyleOptionToolButton
+ \o \l State_Enabled \o Set if the tool button is enabled.
+ \row \o \l State_HasFocus \o Set if the tool button has input focus.
+ \row \o \l State_DownArrow \o Set if the tool button is down (i.e., a mouse
+ button or the space bar is pressed).
+ \row \o \l State_On \o Set if the tool button is a toggle button
+ and is toggled on.
+ \row \o \l State_AutoRaise \o Set if the tool button has auto-raise enabled.
+ \row \o \l State_Raised \o Set if the button is not down, not on, and doesn't
+ contain the mouse when auto-raise is enabled.
+
+ \row \o \l{CC_TitleBar} \o \l QStyleOptionTitleBar
+ \o \l State_Enabled \o Set if the title bar is enabled.
+
+ \row \o \l{CC_Q3ListView} \o \l QStyleOptionQ3ListView
+ \o \l State_Enabled \o Set if the list view is enabled.
+
+ \endtable
+
+ \sa drawPrimitive(), drawControl()
+*/
+
+
+/*!
+ \fn QRect QStyle::subControlRect(ComplexControl control,
+ const QStyleOptionComplex *option, SubControl subControl,
+ const QWidget *widget) const = 0
+
+ Returns the rectangle containing the specified \a subControl of
+ the given complex \a control (with the style specified by \a
+ option). The rectangle is defined in screen coordinates.
+
+ The \a option argument is a pointer to QStyleOptionComplex or
+ one of its subclasses, and can be cast to the appropriate type
+ using the qstyleoption_cast() function. See drawComplexControl()
+ for details. The \a widget is optional and can contain additional
+ information for the function.
+
+ \sa drawComplexControl()
+*/
+
+/*!
+ \fn QStyle::SubControl QStyle::hitTestComplexControl(ComplexControl control,
+ const QStyleOptionComplex *option, const QPoint &position,
+ const QWidget *widget) const = 0
+
+ Returns the sub control at the given \a position in the given
+ complex \a control (with the style options specified by \a
+ option).
+
+ Note that the \a position is expressed in screen coordinates.
+
+ The \a option argument is a pointer to a QStyleOptionComplex
+ object (or one of its subclasses). The object can be cast to the
+ appropriate type using the qstyleoption_cast() function. See
+ drawComplexControl() for details. The \a widget argument is
+ optional and can contain additional information for the function.
+
+ \sa drawComplexControl(), subControlRect()
+*/
+
+/*!
+ \enum QStyle::PixelMetric
+
+ This enum describes the various available pixel metrics. A pixel
+ metric is a style dependent size represented by a single pixel
+ value.
+
+ \value PM_ButtonMargin Amount of whitespace between push button
+ labels and the frame.
+ \value PM_DockWidgetTitleBarButtonMargin Amount of whitespace between dock widget's
+ title bar button labels and the frame.
+ \value PM_ButtonDefaultIndicator Width of the default-button indicator frame.
+ \value PM_MenuButtonIndicator Width of the menu button indicator
+ proportional to the widget height.
+ \value PM_ButtonShiftHorizontal Horizontal contents shift of a
+ button when the button is down.
+ \value PM_ButtonShiftVertical Vertical contents shift of a button when the
+ button is down.
+
+ \value PM_DefaultFrameWidth Default frame width (usually 2).
+ \value PM_SpinBoxFrameWidth Frame width of a spin box, defaults to PM_DefaultFrameWidth.
+ \value PM_ComboBoxFrameWidth Frame width of a combo box, defaults to PM_DefaultFrameWidth.
+
+ \value PM_MDIFrameWidth Obsolete. Use PM_MdiSubWindowFrameWidth instead.
+ \value PM_MdiSubWindowFrameWidth Frame width of an MDI window.
+ \value PM_MDIMinimizedWidth Obsolete. Use PM_MdiSubWindowMinimizedWidth instead.
+ \value PM_MdiSubWindowMinimizedWidth Width of a minimized MDI window.
+
+ \value PM_LayoutLeftMargin Default \l{QLayout::setContentsMargins()}{left margin} for a
+ QLayout.
+ \value PM_LayoutTopMargin Default \l{QLayout::setContentsMargins()}{top margin} for a QLayout.
+ \value PM_LayoutRightMargin Default \l{QLayout::setContentsMargins()}{right margin} for a
+ QLayout.
+ \value PM_LayoutBottomMargin Default \l{QLayout::setContentsMargins()}{bottom margin} for a
+ QLayout.
+ \value PM_LayoutHorizontalSpacing Default \l{QLayout::spacing}{horizontal spacing} for a
+ QLayout.
+ \value PM_LayoutVerticalSpacing Default \l{QLayout::spacing}{vertical spacing} for a QLayout.
+
+ \value PM_MaximumDragDistance The maximum allowed distance between
+ the mouse and a scrollbar when dragging. Exceeding the specified
+ distance will cause the slider to jump back to the original
+ position; a value of -1 disables this behavior.
+
+ \value PM_ScrollBarExtent Width of a vertical scroll bar and the
+ height of a horizontal scroll bar.
+ \value PM_ScrollBarSliderMin The minimum height of a vertical
+ scroll bar's slider and the minimum width of a horizontal
+ scroll bar's slider.
+
+ \value PM_SliderThickness Total slider thickness.
+ \value PM_SliderControlThickness Thickness of the slider handle.
+ \value PM_SliderLength Length of the slider.
+ \value PM_SliderTickmarkOffset The offset between the tickmarks
+ and the slider.
+ \value PM_SliderSpaceAvailable The available space for the slider to move.
+
+ \value PM_DockWidgetSeparatorExtent Width of a separator in a
+ horizontal dock window and the height of a separator in a
+ vertical dock window.
+ \value PM_DockWidgetHandleExtent Width of the handle in a
+ horizontal dock window and the height of the handle in a
+ vertical dock window.
+ \value PM_DockWidgetFrameWidth Frame width of a dock window.
+ \value PM_DockWidgetTitleMargin Margin of the dock window title.
+
+ \value PM_MenuBarPanelWidth Frame width of a menu bar, defaults to PM_DefaultFrameWidth.
+ \value PM_MenuBarItemSpacing Spacing between menu bar items.
+ \value PM_MenuBarHMargin Spacing between menu bar items and left/right of bar.
+ \value PM_MenuBarVMargin Spacing between menu bar items and top/bottom of bar.
+
+ \value PM_ToolBarFrameWidth Width of the frame around toolbars.
+ \value PM_ToolBarHandleExtent Width of a toolbar handle in a
+ horizontal toolbar and the height of the handle in a vertical toolbar.
+ \value PM_ToolBarItemMargin Spacing between the toolbar frame and the items.
+ \value PM_ToolBarItemSpacing Spacing between toolbar items.
+ \value PM_ToolBarSeparatorExtent Width of a toolbar separator in a
+ horizontal toolbar and the height of a separator in a vertical toolbar.
+ \value PM_ToolBarExtensionExtent Width of a toolbar extension
+ button in a horizontal toolbar and the height of the button in a
+ vertical toolbar.
+
+ \value PM_TabBarTabOverlap Number of pixels the tabs should overlap.
+ (Currently only used in styles, not inside of QTabBar)
+ \value PM_TabBarTabHSpace Extra space added to the tab width.
+ \value PM_TabBarTabVSpace Extra space added to the tab height.
+ \value PM_TabBarBaseHeight Height of the area between the tab bar
+ and the tab pages.
+ \value PM_TabBarBaseOverlap Number of pixels the tab bar overlaps
+ the tab bar base.
+ \value PM_TabBarScrollButtonWidth
+ \value PM_TabBarTabShiftHorizontal Horizontal pixel shift when a
+ tab is selected.
+ \value PM_TabBarTabShiftVertical Vertical pixel shift when a
+ tab is selected.
+
+ \value PM_ProgressBarChunkWidth Width of a chunk in a progress bar indicator.
+
+ \value PM_SplitterWidth Width of a splitter.
+
+ \value PM_TitleBarHeight Height of the title bar.
+
+ \value PM_IndicatorWidth Width of a check box indicator.
+ \value PM_IndicatorHeight Height of a checkbox indicator.
+ \value PM_ExclusiveIndicatorWidth Width of a radio button indicator.
+ \value PM_ExclusiveIndicatorHeight Height of a radio button indicator.
+
+ \value PM_MenuPanelWidth Border width (applied on all sides) for a QMenu.
+ \value PM_MenuHMargin Additional border (used on left and right) for a QMenu.
+ \value PM_MenuVMargin Additional border (used for bottom and top) for a QMenu.
+ \value PM_MenuScrollerHeight Height of the scroller area in a QMenu.
+ \value PM_MenuTearoffHeight Height of a tear off area in a QMenu.
+ \value PM_MenuDesktopFrameWidth The frame width for the menu on the desktop.
+
+ \value PM_CheckListButtonSize Area (width/height) of the
+ checkbox/radio button in a Q3CheckListItem.
+ \value PM_CheckListControllerSize Area (width/height) of the
+ controller in a Q3CheckListItem.
+
+ \omitvalue PM_DialogButtonsSeparator
+ \omitvalue PM_DialogButtonsButtonWidth
+ \omitvalue PM_DialogButtonsButtonHeight
+
+ \value PM_HeaderMarkSize The size of the sort indicator in a header.
+ \value PM_HeaderGripMargin The size of the resize grip in a header.
+ \value PM_HeaderMargin The size of the margin between the sort indicator and the text.
+ \value PM_SpinBoxSliderHeight The height of the optional spin box slider.
+
+ \value PM_ToolBarIconSize Default tool bar icon size
+ \value PM_SmallIconSize Default small icon size
+ \value PM_LargeIconSize Default large icon size
+
+ \value PM_FocusFrameHMargin Horizontal margin that the focus frame will outset the widget by.
+ \value PM_FocusFrameVMargin Vertical margin that the focus frame will outset the widget by.
+ \value PM_IconViewIconSize The default size for icons in an icon view.
+ \value PM_ListViewIconSize The default size for icons in a list view.
+
+ \value PM_ToolTipLabelFrameWidth The frame width for a tool tip label.
+ \value PM_CheckBoxLabelSpacing The spacing between a check box indicator and its label.
+ \value PM_RadioButtonLabelSpacing The spacing between a radio button indicator and its label.
+ \value PM_TabBarIconSize The default icon size for a tab bar.
+ \value PM_SizeGripSize The size of a size grip.
+ \value PM_MessageBoxIconSize The size of the standard icons in a message box
+ \value PM_ButtonIconSize The default size of button icons
+ \value PM_TextCursorWidth The width of the cursor in a line edit or text edit
+ \value PM_TabBar_ScrollButtonOverlap The distance between the left and right buttons in a tab bar.
+
+ \value PM_TabCloseIndicatorWidth The default width of a close button on a tab in a tab bar.
+ \value PM_TabCloseIndicatorHeight The default height of a close button on a tab in a tab bar.
+
+ \value PM_CustomBase Base value for custom pixel metrics. Custom
+ values must be greater than this value.
+
+ The following values are obsolete:
+
+ \value PM_DefaultTopLevelMargin Use PM_LayoutLeftMargin,
+ PM_LayoutTopMargin,
+ PM_LayoutRightMargin, and
+ PM_LayoutBottomMargin instead.
+ \value PM_DefaultChildMargin Use PM_LayoutLeftMargin,
+ PM_LayoutTopMargin,
+ PM_LayoutRightMargin, and
+ PM_LayoutBottomMargin instead.
+ \value PM_DefaultLayoutSpacing Use PM_LayoutHorizontalSpacing
+ and PM_LayoutVerticalSpacing
+ instead.
+
+ \value PM_ScrollView_ScrollBarSpacing Distance between frame and scrollbar
+ with SH_ScrollView_FrameOnlyAroundContents set.
+ \value PM_SubMenuOverlap The horizontal overlap between a submenu and its parent.
+
+
+ \sa pixelMetric()
+*/
+
+/*!
+ \fn int QStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const;
+
+ Returns the value of the given pixel \a metric.
+
+ The specified \a option and \a widget can be used for calculating
+ the metric. In general, the \a widget argument is not used. The \a
+ option can be cast to the appropriate type using the
+ qstyleoption_cast() function. Note that the \a option may be zero
+ even for PixelMetrics that can make use of it. See the table below
+ for the appropriate \a option casts:
+
+ \table
+ \header \o Pixel Metric \o QStyleOption Subclass
+ \row \o \l PM_SliderControlThickness \o \l QStyleOptionSlider
+ \row \o \l PM_SliderLength \o \l QStyleOptionSlider
+ \row \o \l PM_SliderTickmarkOffset \o \l QStyleOptionSlider
+ \row \o \l PM_SliderSpaceAvailable \o \l QStyleOptionSlider
+ \row \o \l PM_ScrollBarExtent \o \l QStyleOptionSlider
+ \row \o \l PM_TabBarTabOverlap \o \l QStyleOptionTab
+ \row \o \l PM_TabBarTabHSpace \o \l QStyleOptionTab
+ \row \o \l PM_TabBarTabVSpace \o \l QStyleOptionTab
+ \row \o \l PM_TabBarBaseHeight \o \l QStyleOptionTab
+ \row \o \l PM_TabBarBaseOverlap \o \l QStyleOptionTab
+ \endtable
+
+ Some pixel metrics are called from widgets and some are only called
+ internally by the style. If the metric is not called by a widget, it is the
+ discretion of the style author to make use of it. For some styles, this
+ may not be appropriate.
+*/
+
+/*!
+ \enum QStyle::ContentsType
+
+ This enum describes the available contents types. These are used to
+ calculate sizes for the contents of various widgets.
+
+ \value CT_CheckBox A check box, like QCheckBox.
+ \value CT_ComboBox A combo box, like QComboBox.
+ \omitvalue CT_DialogButtons
+ \value CT_Q3DockWindow A Q3DockWindow.
+ \value CT_HeaderSection A header section, like QHeader.
+ \value CT_LineEdit A line edit, like QLineEdit.
+ \value CT_Menu A menu, like QMenu.
+ \value CT_Q3Header A Qt 3 header section, like Q3Header.
+ \value CT_MenuBar A menu bar, like QMenuBar.
+ \value CT_MenuBarItem A menu bar item, like the buttons in a QMenuBar.
+ \value CT_MenuItem A menu item, like QMenuItem.
+ \value CT_ProgressBar A progress bar, like QProgressBar.
+ \value CT_PushButton A push button, like QPushButton.
+ \value CT_RadioButton A radio button, like QRadioButton.
+ \value CT_SizeGrip A size grip, like QSizeGrip.
+ \value CT_Slider A slider, like QSlider.
+ \value CT_ScrollBar A scroll bar, like QScrollBar.
+ \value CT_SpinBox A spin box, like QSpinBox.
+ \value CT_Splitter A splitter, like QSplitter.
+ \value CT_TabBarTab A tab on a tab bar, like QTabBar.
+ \value CT_TabWidget A tab widget, like QTabWidget.
+ \value CT_ToolButton A tool button, like QToolButton.
+ \value CT_GroupBox A group box, like QGroupBox.
+ \value CT_ItemViewItem An item inside an item view.
+
+ \value CT_CustomBase Base value for custom contents types.
+ Custom values must be greater than this value.
+
+ \value CT_MdiControls The minimize, normal, and close button
+ in the menu bar for a maximized MDI
+ subwindow.
+
+ \sa sizeFromContents()
+*/
+
+/*!
+ \fn QSize QStyle::sizeFromContents(ContentsType type, const QStyleOption *option, \
+ const QSize &contentsSize, const QWidget *widget) const
+
+ Returns the size of the element described by the specified
+ \a option and \a type, based on the provided \a contentsSize.
+
+ The \a option argument is a pointer to a QStyleOption or one of
+ its subclasses. The \a option can be cast to the appropriate type
+ using the qstyleoption_cast() function. The \a widget is an
+ optional argument and can contain extra information used for
+ calculating the size.
+
+ See the table below for the appropriate \a option casts:
+
+ \table
+ \header \o Contents Type \o QStyleOption Subclass
+ \row \o \l CT_PushButton \o \l QStyleOptionButton
+ \row \o \l CT_CheckBox \o \l QStyleOptionButton
+ \row \o \l CT_RadioButton \o \l QStyleOptionButton
+ \row \o \l CT_ToolButton \o \l QStyleOptionToolButton
+ \row \o \l CT_ComboBox \o \l QStyleOptionComboBox
+ \row \o \l CT_Splitter \o \l QStyleOption
+ \row \o \l CT_Q3DockWindow \o \l QStyleOptionQ3DockWindow
+ \row \o \l CT_ProgressBar \o \l QStyleOptionProgressBar
+ \row \o \l CT_MenuItem \o \l QStyleOptionMenuItem
+ \endtable
+
+ \sa ContentsType QStyleOption
+*/
+
+/*!
+ \enum QStyle::RequestSoftwareInputPanel
+
+ This enum describes under what circumstances a software input panel will be
+ requested by input capable widgets.
+
+ \value RSIP_OnMouseClickAndAlreadyFocused Requests an input panel if the user
+ clicks on the widget, but only if it is already focused.
+ \value RSIP_OnMouseClick Requests an input panel if the user clicks on the
+ widget.
+
+ \sa QEvent::RequestSoftwareInputPanel, QInputContext
+*/
+
+/*!
+ \enum QStyle::StyleHint
+
+ This enum describes the available style hints. A style hint is a general look
+ and/or feel hint.
+
+ \value SH_EtchDisabledText Disabled text is "etched" as it is on Windows.
+
+ \value SH_DitherDisabledText Disabled text is dithered as it is on Motif.
+
+ \value SH_GUIStyle The GUI style to use.
+
+ \value SH_ScrollBar_ContextMenu Whether or not a scroll bar has a context menu.
+
+ \value SH_ScrollBar_MiddleClickAbsolutePosition A boolean value.
+ If true, middle clicking on a scroll bar causes the slider to
+ jump to that position. If false, middle clicking is
+ ignored.
+
+ \value SH_ScrollBar_LeftClickAbsolutePosition A boolean value.
+ If true, left clicking on a scroll bar causes the slider to
+ jump to that position. If false, left clicking will
+ behave as appropriate for each control.
+
+ \value SH_ScrollBar_ScrollWhenPointerLeavesControl A boolean
+ value. If true, when clicking a scroll bar SubControl, holding
+ the mouse button down and moving the pointer outside the
+ SubControl, the scroll bar continues to scroll. If false, the
+ scollbar stops scrolling when the pointer leaves the
+ SubControl.
+
+ \value SH_ScrollBar_RollBetweenButtons A boolean value.
+ If true, when clicking a scroll bar button (SC_ScrollBarAddLine or
+ SC_ScrollBarSubLine) and dragging over to the opposite button (rolling)
+ will press the new button and release the old one. When it is false, the
+ original button is released and nothing happens (like a push button).
+
+ \value SH_TabBar_Alignment The alignment for tabs in a
+ QTabWidget. Possible values are Qt::AlignLeft,
+ Qt::AlignCenter and Qt::AlignRight.
+
+ \value SH_Header_ArrowAlignment The placement of the sorting
+ indicator may appear in list or table headers. Possible values
+ are Qt::Left or Qt::Right.
+
+ \value SH_Slider_SnapToValue Sliders snap to values while moving,
+ as they do on Windows.
+
+ \value SH_Slider_SloppyKeyEvents Key presses handled in a sloppy
+ manner, i.e., left on a vertical slider subtracts a line.
+
+ \value SH_ProgressDialog_CenterCancelButton Center button on
+ progress dialogs, like Motif, otherwise right aligned.
+
+ \value SH_ProgressDialog_TextLabelAlignment The alignment for text
+ labels in progress dialogs; Qt::AlignCenter on Windows,
+ Qt::AlignVCenter otherwise.
+
+ \value SH_PrintDialog_RightAlignButtons Right align buttons in
+ the print dialog, as done on Windows.
+
+ \value SH_MainWindow_SpaceBelowMenuBar One or two pixel space between
+ the menu bar and the dockarea, as done on Windows.
+
+ \value SH_FontDialog_SelectAssociatedText Select the text in the
+ line edit, or when selecting an item from the listbox, or when
+ the line edit receives focus, as done on Windows.
+
+ \value SH_Menu_KeyboardSearch Typing causes a menu to be search
+ for relevant items, otherwise only mnemnonic is considered.
+
+ \value SH_Menu_AllowActiveAndDisabled Allows disabled menu
+ items to be active.
+
+ \value SH_Menu_SpaceActivatesItem Pressing the space bar activates
+ the item, as done on Motif.
+
+ \value SH_Menu_SubMenuPopupDelay The number of milliseconds
+ to wait before opening a submenu (256 on Windows, 96 on Motif).
+
+ \value SH_Menu_Scrollable Whether popup menus must support scrolling.
+
+ \value SH_Menu_SloppySubMenus Whether popupmenu's must support
+ sloppy submenu; as implemented on Mac OS.
+
+ \value SH_ScrollView_FrameOnlyAroundContents Whether scrollviews
+ draw their frame only around contents (like Motif), or around
+ contents, scroll bars and corner widgets (like Windows).
+
+ \value SH_MenuBar_AltKeyNavigation Menu bars items are navigable
+ by pressing Alt, followed by using the arrow keys to select
+ the desired item.
+
+ \value SH_ComboBox_ListMouseTracking Mouse tracking in combobox
+ drop-down lists.
+
+ \value SH_Menu_MouseTracking Mouse tracking in popup menus.
+
+ \value SH_MenuBar_MouseTracking Mouse tracking in menu bars.
+
+ \value SH_Menu_FillScreenWithScroll Whether scrolling popups
+ should fill the screen as they are scrolled.
+
+ \value SH_Menu_SelectionWrap Whether popups should allow the selections
+ to wrap, that is when selection should the next item be the first item.
+
+ \value SH_ItemView_ChangeHighlightOnFocus Gray out selected items
+ when losing focus.
+
+ \value SH_Widget_ShareActivation Turn on sharing activation with
+ floating modeless dialogs.
+
+ \value SH_TabBar_SelectMouseType Which type of mouse event should
+ cause a tab to be selected.
+
+ \value SH_Q3ListViewExpand_SelectMouseType Which type of mouse event should
+ cause a list view expansion to be selected.
+
+ \value SH_TabBar_PreferNoArrows Whether a tab bar should suggest a size
+ to prevent scoll arrows.
+
+ \value SH_ComboBox_Popup Allows popups as a combobox drop-down
+ menu.
+
+ \value SH_Workspace_FillSpaceOnMaximize The workspace should
+ maximize the client area.
+
+ \value SH_TitleBar_NoBorder The title bar has no border.
+
+ \value SH_ScrollBar_StopMouseOverSlider Obsolete. Use
+ SH_Slider_StopMouseOverSlider instead.
+
+ \value SH_Slider_StopMouseOverSlider Stops auto-repeat when
+ the slider reaches the mouse position.
+
+ \value SH_BlinkCursorWhenTextSelected Whether cursor should blink
+ when text is selected.
+
+ \value SH_RichText_FullWidthSelection Whether richtext selections
+ should extend to the full width of the document.
+
+ \value SH_GroupBox_TextLabelVerticalAlignment How to vertically align a
+ group box's text label.
+
+ \value SH_GroupBox_TextLabelColor How to paint a group box's text label.
+
+ \value SH_DialogButtons_DefaultButton Which button gets the
+ default status in a dialog's button widget.
+
+ \value SH_ToolBox_SelectedPageTitleBold Boldness of the selected
+ page title in a QToolBox.
+
+ \value SH_LineEdit_PasswordCharacter The Unicode character to be
+ used for passwords.
+
+ \value SH_Table_GridLineColor The RGB value of the grid for a table.
+
+ \value SH_UnderlineShortcut Whether shortcuts are underlined.
+
+ \value SH_SpellCheckUnderlineStyle A
+ QTextCharFormat::UnderlineStyle value that specifies the way
+ misspelled words should be underlined.
+
+ \value SH_SpinBox_AnimateButton Animate a click when up or down is
+ pressed in a spin box.
+ \value SH_SpinBox_KeyPressAutoRepeatRate Auto-repeat interval for
+ spinbox key presses.
+ \value SH_SpinBox_ClickAutoRepeatRate Auto-repeat interval for
+ spinbox mouse clicks.
+ \value SH_SpinBox_ClickAutoRepeatThreshold Auto-repeat threshold for
+ spinbox mouse clicks.
+ \value SH_ToolTipLabel_Opacity An integer indicating the opacity for
+ the tip label, 0 is completely transparent, 255 is completely
+ opaque.
+ \value SH_DrawMenuBarSeparator Indicates whether or not the menu bar draws separators.
+ \value SH_TitleBar_ModifyNotification Indicates if the title bar should show
+ a '*' for windows that are modified.
+
+ \value SH_Button_FocusPolicy The default focus policy for buttons.
+
+ \value SH_CustomBase Base value for custom style hints.
+ Custom values must be greater than this value.
+
+ \value SH_MenuBar_DismissOnSecondClick A boolean indicating if a menu in
+ the menu bar should be dismissed when it is clicked on a second time. (Example:
+ Clicking and releasing on the File Menu in a menu bar and then
+ immediately clicking on the File Menu again.)
+
+ \value SH_MessageBox_UseBorderForButtonSpacing A boolean indicating what the to
+ use the border of the buttons (computed as half the button height) for the spacing
+ of the button in a message box.
+
+ \value SH_MessageBox_CenterButtons A boolean indicating whether the buttons in the
+ message box should be centered or not (see QDialogButtonBox::setCentered()).
+
+ \value SH_MessageBox_TextInteractionFlags A boolean indicating if
+ the text in a message box should allow user interfactions (e.g.
+ selection) or not.
+
+ \value SH_TitleBar_AutoRaise A boolean indicating whether
+ controls on a title bar ought to update when the mouse is over them.
+
+ \value SH_ToolButton_PopupDelay An int indicating the popup delay in milliseconds
+ for menus attached to tool buttons.
+
+ \value SH_FocusFrame_Mask The mask of the focus frame.
+
+ \value SH_RubberBand_Mask The mask of the rubber band.
+
+ \value SH_WindowFrame_Mask The mask of the window frame.
+
+ \value SH_SpinControls_DisableOnBounds Determines if the spin controls will shown
+ as disabled when reaching the spin range boundary.
+
+ \value SH_Dial_BackgroundRole Defines the style's preferred
+ background role (as QPalette::ColorRole) for a dial widget.
+
+ \value SH_ScrollBar_BackgroundMode The background mode for a scroll bar.
+
+ \value SH_ComboBox_LayoutDirection The layout direction for the
+ combo box. By default it should be the same as indicated by the
+ QStyleOption::direction variable.
+
+ \value SH_ItemView_EllipsisLocation The location where ellipses should be
+ added for item text that is too long to fit in an view item.
+
+ \value SH_ItemView_ShowDecorationSelected When an item in an item
+ view is selected, also highlight the branch or other decoration.
+
+ \value SH_ItemView_ActivateItemOnSingleClick Emit the activated signal
+ when the user single clicks on an item in an item in an item view.
+ Otherwise the signal is emitted when the user double clicks on an item.
+
+ \value SH_Slider_AbsoluteSetButtons Which mouse buttons cause a slider
+ to set the value to the position clicked on.
+
+ \value SH_Slider_PageSetButtons Which mouse buttons cause a slider
+ to page step the value.
+
+ \value SH_TabBar_ElideMode The default eliding style for a tab bar.
+
+ \value SH_DialogButtonLayout Controls how buttons are laid out in a QDialogButtonBox, returns a QDialogButtonBox::ButtonLayout enum.
+
+ \value SH_WizardStyle Controls the look and feel of a QWizard. Returns a QWizard::WizardStyle enum.
+
+ \value SH_FormLayoutWrapPolicy Provides a default for how rows are wrapped in a QFormLayout. Returns a QFormLayout::RowWrapPolicy enum.
+ \value SH_FormLayoutFieldGrowthPolicy Provides a default for how fields can grow in a QFormLayout. Returns a QFormLayout::FieldGrowthPolicy enum.
+ \value SH_FormLayoutFormAlignment Provides a default for how a QFormLayout aligns its contents within the available space. Returns a Qt::Alignment enum.
+ \value SH_FormLayoutLabelAlignment Provides a default for how a QFormLayout aligns labels within the available space. Returns a Qt::Alignment enum.
+
+ \value SH_ItemView_ArrowKeysNavigateIntoChildren Controls whether the tree view will select the first child when it is exapanded and the right arrow key is pressed.
+ \value SH_ComboBox_PopupFrameStyle The frame style used when drawing a combobox popup menu.
+
+ \value SH_DialogButtonBox_ButtonsHaveIcons Indicates whether or not StandardButtons in QDialogButtonBox should have icons or not.
+ \value SH_ItemView_MovementWithoutUpdatingSelection The item view is able to indicate a current item without changing the selection.
+ \value SH_ToolTip_Mask The mask of a tool tip.
+
+ \value SH_FocusFrame_AboveWidget The FocusFrame is stacked above the widget that it is "focusing on".
+
+ \value SH_TextControl_FocusIndicatorTextCharFormat Specifies the text format used to highlight focused anchors in rich text
+ documents displayed for example in QTextBrowser. The format has to be a QTextCharFormat returned in the variant of the
+ QStyleHintReturnVariant return value. The QTextFormat::OutlinePen property is used for the outline and QTextFormat::BackgroundBrush
+ for the background of the highlighted area.
+
+ \value SH_Menu_FlashTriggeredItem Flash triggered item.
+ \value SH_Menu_FadeOutOnHide Fade out the menu instead of hiding it immediately.
+
+ \value SH_TabWidget_DefaultTabPosition Default position of the tab bar in a tab widget.
+
+ \value SH_ToolBar_Movable Determines if the tool bar is movable by default.
+
+ \value SH_ItemView_PaintAlternatingRowColorsForEmptyArea Whether QTreeView paints alternating row colors for the area that does not have any items.
+
+ \value SH_Menu_Mask The mask for a popup menu.
+
+ \value SH_ItemView_DrawDelegateFrame Determines if there should be a frame for a delegate widget.
+
+ \value SH_TabBar_CloseButtonPosition Determines the position of the close button on a tab in a tab bar.
+
+ \value SH_DockWidget_ButtonsHaveFrame Determines if dockwidget buttons should have frames. Default is true.
+
+ \value SH_ToolButtonStyle Determines the default system style for tool buttons that uses Qt::ToolButtonFollowStyle.
+
+ \value SH_RequestSoftwareInputPanel Determines when a software input panel should
+ be requested by input widgets. Returns an enum of type QStyle::RequestSoftwareInputPanel.
+
+ \omitvalue SH_UnderlineAccelerator
+
+ \sa styleHint()
+*/
+
+/*!
+ \fn int QStyle::styleHint(StyleHint hint, const QStyleOption *option, \
+ const QWidget *widget, QStyleHintReturn *returnData) const
+
+ Returns an integer representing the specified style \a hint for
+ the given \a widget described by the provided style \a option.
+
+ \a returnData is used when the querying widget needs more detailed data than
+ the integer that styleHint() returns. See the QStyleHintReturn class
+ description for details.
+*/
+
+/*!
+ \enum QStyle::StandardPixmap
+
+ This enum describes the available standard pixmaps. A standard pixmap is a pixmap that
+ can follow some existing GUI style or guideline.
+
+ \value SP_TitleBarMinButton Minimize button on title bars (e.g.,
+ in QMdiSubWindow).
+ \value SP_TitleBarMenuButton Menu button on a title bar.
+ \value SP_TitleBarMaxButton Maximize button on title bars.
+ \value SP_TitleBarCloseButton Close button on title bars.
+ \value SP_TitleBarNormalButton Normal (restore) button on title bars.
+ \value SP_TitleBarShadeButton Shade button on title bars.
+ \value SP_TitleBarUnshadeButton Unshade button on title bars.
+ \value SP_TitleBarContextHelpButton The Context help button on title bars.
+ \value SP_MessageBoxInformation The "information" icon.
+ \value SP_MessageBoxWarning The "warning" icon.
+ \value SP_MessageBoxCritical The "critical" icon.
+ \value SP_MessageBoxQuestion The "question" icon.
+ \value SP_DesktopIcon The "desktop" icon.
+ \value SP_TrashIcon The "trash" icon.
+ \value SP_ComputerIcon The "My computer" icon.
+ \value SP_DriveFDIcon The floppy icon.
+ \value SP_DriveHDIcon The harddrive icon.
+ \value SP_DriveCDIcon The CD icon.
+ \value SP_DriveDVDIcon The DVD icon.
+ \value SP_DriveNetIcon The network icon.
+ \value SP_DirHomeIcon The home directory icon.
+ \value SP_DirOpenIcon The open directory icon.
+ \value SP_DirClosedIcon The closed directory icon.
+ \value SP_DirIcon The directory icon.
+ \value SP_DirLinkIcon The link to directory icon.
+ \value SP_FileIcon The file icon.
+ \value SP_FileLinkIcon The link to file icon.
+ \value SP_FileDialogStart The "start" icon in a file dialog.
+ \value SP_FileDialogEnd The "end" icon in a file dialog.
+ \value SP_FileDialogToParent The "parent directory" icon in a file dialog.
+ \value SP_FileDialogNewFolder The "create new folder" icon in a file dialog.
+ \value SP_FileDialogDetailedView The detailed view icon in a file dialog.
+ \value SP_FileDialogInfoView The file info icon in a file dialog.
+ \value SP_FileDialogContentsView The contents view icon in a file dialog.
+ \value SP_FileDialogListView The list view icon in a file dialog.
+ \value SP_FileDialogBack The back arrow in a file dialog.
+ \value SP_DockWidgetCloseButton Close button on dock windows (see also QDockWidget).
+ \value SP_ToolBarHorizontalExtensionButton Extension button for horizontal toolbars.
+ \value SP_ToolBarVerticalExtensionButton Extension button for vertical toolbars.
+ \value SP_DialogOkButton Icon for a standard OK button in a QDialogButtonBox.
+ \value SP_DialogCancelButton Icon for a standard Cancel button in a QDialogButtonBox.
+ \value SP_DialogHelpButton Icon for a standard Help button in a QDialogButtonBox.
+ \value SP_DialogOpenButton Icon for a standard Open button in a QDialogButtonBox.
+ \value SP_DialogSaveButton Icon for a standard Save button in a QDialogButtonBox.
+ \value SP_DialogCloseButton Icon for a standard Close button in a QDialogButtonBox.
+ \value SP_DialogApplyButton Icon for a standard Apply button in a QDialogButtonBox.
+ \value SP_DialogResetButton Icon for a standard Reset button in a QDialogButtonBox.
+ \value SP_DialogDiscardButton Icon for a standard Discard button in a QDialogButtonBox.
+ \value SP_DialogYesButton Icon for a standard Yes button in a QDialogButtonBox.
+ \value SP_DialogNoButton Icon for a standard No button in a QDialogButtonBox.
+ \value SP_ArrowUp Icon arrow pointing up.
+ \value SP_ArrowDown Icon arrow pointing down.
+ \value SP_ArrowLeft Icon arrow pointing left.
+ \value SP_ArrowRight Icon arrow pointing right.
+ \value SP_ArrowBack Equivalent to SP_ArrowLeft when the current layout direction is Qt::LeftToRight, otherwise SP_ArrowRight.
+ \value SP_ArrowForward Equivalent to SP_ArrowRight when the current layout direction is Qt::LeftToRight, otherwise SP_ArrowLeft.
+ \value SP_CommandLink Icon used to indicate a Vista style command link glyph.
+ \value SP_VistaShield Icon used to indicate UAC prompts on Windows Vista. This will return a null pixmap or icon on all other platforms.
+ \value SP_BrowserReload Icon indicating that the current page should be reloaded.
+ \value SP_BrowserStop Icon indicating that the page loading should stop.
+ \value SP_MediaPlay Icon indicating that media should begin playback.
+ \value SP_MediaStop Icon indicating that media should stop playback.
+ \value SP_MediaPause Icon indicating that media should pause playback.
+ \value SP_MediaSkipForward Icon indicating that media should skip forward.
+ \value SP_MediaSkipBackward Icon indicating that media should skip backward.
+ \value SP_MediaSeekForward Icon indicating that media should seek forward.
+ \value SP_MediaSeekBackward Icon indicating that media should seek backward.
+ \value SP_MediaVolume Icon indicating a volume control.
+ \value SP_MediaVolumeMuted Icon indicating a muted volume control.
+ \value SP_CustomBase Base value for custom standard pixmaps;
+ custom values must be greater than this value.
+
+ \sa standardIcon()
+*/
+
+/*!
+ \fn QPixmap QStyle::generatedIconPixmap(QIcon::Mode iconMode,
+ const QPixmap &pixmap, const QStyleOption *option) const
+
+ Returns a copy of the given \a pixmap, styled to conform to the
+ specified \a iconMode and taking into account the palette
+ specified by \a option.
+
+ The \a option parameter can pass extra information, but
+ it must contain a palette.
+
+ Note that not all pixmaps will conform, in which case the returned
+ pixmap is a plain copy.
+
+ \sa QIcon
+*/
+
+/*!
+ \fn QPixmap QStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option, \
+ const QWidget *widget) const
+
+ \obsolete
+ Returns a pixmap for the given \a standardPixmap.
+
+ A standard pixmap is a pixmap that can follow some existing GUI
+ style or guideline. The \a option argument can be used to pass
+ extra information required when defining the appropriate
+ pixmap. The \a widget argument is optional and can also be used to
+ aid the determination of the pixmap.
+
+ Developers calling standardPixmap() should instead call standardIcon()
+ Developers who re-implemented standardPixmap() should instead re-implement
+ the slot standardIconImplementation().
+
+ \sa standardIcon()
+*/
+
+
+/*!
+ \fn QRect QStyle::visualRect(Qt::LayoutDirection direction, const QRect &boundingRectangle, const QRect &logicalRectangle)
+
+ Returns the given \a logicalRectangle converted to screen
+ coordinates based on the specified \a direction. The \a
+ boundingRectangle is used when performing the translation.
+
+ This function is provided to support right-to-left desktops, and
+ is typically used in implementations of the subControlRect()
+ function.
+
+ \sa QWidget::layoutDirection
+*/
+QRect QStyle::visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect)
+{
+ if (direction == Qt::LeftToRight)
+ return logicalRect;
+ QRect rect = logicalRect;
+ rect.translate(2 * (boundingRect.right() - logicalRect.right()) +
+ logicalRect.width() - boundingRect.width(), 0);
+ return rect;
+}
+
+/*!
+ \fn QPoint QStyle::visualPos(Qt::LayoutDirection direction, const QRect &boundingRectangle, const QPoint &logicalPosition)
+
+ Returns the given \a logicalPosition converted to screen
+ coordinates based on the specified \a direction. The \a
+ boundingRectangle is used when performing the translation.
+
+ \sa QWidget::layoutDirection
+*/
+QPoint QStyle::visualPos(Qt::LayoutDirection direction, const QRect &boundingRect, const QPoint &logicalPos)
+{
+ if (direction == Qt::LeftToRight)
+ return logicalPos;
+ return QPoint(boundingRect.right() - logicalPos.x(), logicalPos.y());
+}
+
+/*!
+ Returns a new rectangle of the specified \a size that is aligned to the given \a
+ rectangle according to the specified \a alignment and \a direction.
+ */
+QRect QStyle::alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment, const QSize &size, const QRect &rectangle)
+{
+ alignment = visualAlignment(direction, alignment);
+ int x = rectangle.x();
+ int y = rectangle.y();
+ int w = size.width();
+ int h = size.height();
+ if ((alignment & Qt::AlignVCenter) == Qt::AlignVCenter)
+ y += rectangle.size().height()/2 - h/2;
+ else if ((alignment & Qt::AlignBottom) == Qt::AlignBottom)
+ y += rectangle.size().height() - h;
+ if ((alignment & Qt::AlignRight) == Qt::AlignRight)
+ x += rectangle.size().width() - w;
+ else if ((alignment & Qt::AlignHCenter) == Qt::AlignHCenter)
+ x += rectangle.size().width()/2 - w/2;
+ return QRect(x, y, w, h);
+}
+
+/*!
+ Transforms an \a alignment of Qt::AlignLeft or Qt::AlignRight
+ without Qt::AlignAbsolute into Qt::AlignLeft or Qt::AlignRight with
+ Qt::AlignAbsolute according to the layout \a direction. The other
+ alignment flags are left untouched.
+
+ If no horizontal alignment was specified, the function returns the
+ default alignment for the given layout \a direction.
+
+ QWidget::layoutDirection
+*/
+Qt::Alignment QStyle::visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment)
+{
+ return QGuiApplicationPrivate::visualAlignment(direction, alignment);
+}
+
+/*!
+ Converts the given \a logicalValue to a pixel position. The \a min
+ parameter maps to 0, \a max maps to \a span and other values are
+ distributed evenly in-between.
+
+ This function can handle the entire integer range without
+ overflow, providing that \a span is less than 4096.
+
+ By default, this function assumes that the maximum value is on the
+ right for horizontal items and on the bottom for vertical items.
+ Set the \a upsideDown parameter to true to reverse this behavior.
+
+ \sa sliderValueFromPosition()
+*/
+
+int QStyle::sliderPositionFromValue(int min, int max, int logicalValue, int span, bool upsideDown)
+{
+ if (span <= 0 || logicalValue < min || max <= min)
+ return 0;
+ if (logicalValue > max)
+ return upsideDown ? span : min;
+
+ uint range = max - min;
+ uint p = upsideDown ? max - logicalValue : logicalValue - min;
+
+ if (range > (uint)INT_MAX/4096) {
+ double dpos = (double(p))/(double(range)/span);
+ return int(dpos);
+ } else if (range > (uint)span) {
+ return (2 * p * span + range) / (2*range);
+ } else {
+ uint div = span / range;
+ uint mod = span % range;
+ return p * div + (2 * p * mod + range) / (2 * range);
+ }
+ // equiv. to (p * span) / range + 0.5
+ // no overflow because of this implicit assumption:
+ // span <= 4096
+}
+
+/*!
+ \fn int QStyle::sliderValueFromPosition(int min, int max, int position, int span, bool upsideDown)
+
+ Converts the given pixel \a position to a logical value. 0 maps to
+ the \a min parameter, \a span maps to \a max and other values are
+ distributed evenly in-between.
+
+ This function can handle the entire integer range without
+ overflow.
+
+ By default, this function assumes that the maximum value is on the
+ right for horizontal items and on the bottom for vertical
+ items. Set the \a upsideDown parameter to true to reverse this
+ behavior.
+
+ \sa sliderPositionFromValue()
+*/
+
+int QStyle::sliderValueFromPosition(int min, int max, int pos, int span, bool upsideDown)
+{
+ if (span <= 0 || pos <= 0)
+ return upsideDown ? max : min;
+ if (pos >= span)
+ return upsideDown ? min : max;
+
+ uint range = max - min;
+
+ if ((uint)span > range) {
+ int tmp = (2 * pos * range + span) / (2 * span);
+ return upsideDown ? max - tmp : tmp + min;
+ } else {
+ uint div = range / span;
+ uint mod = range % span;
+ int tmp = pos * div + (2 * pos * mod + span) / (2 * span);
+ return upsideDown ? max - tmp : tmp + min;
+ }
+ // equiv. to min + (pos*range)/span + 0.5
+ // no overflow because of this implicit assumption:
+ // pos <= span < sqrt(INT_MAX+0.0625)+0.25 ~ sqrt(INT_MAX)
+}
+
+/*!
+ Returns the style's standard palette.
+
+ Note that on systems that support system colors, the style's
+ standard palette is not used. In particular, the Windows XP,
+ Vista, and Mac styles do not use the standard palette, but make
+ use of native theme engines. With these styles, you should not set
+ the palette with QApplication::setStandardPalette().
+
+ */
+QPalette QStyle::standardPalette() const
+{
+#ifdef Q_WS_X11
+ QColor background;
+ if (QX11Info::appDepth() > 8)
+ background = QColor(0xd4, 0xd0, 0xc8); // win 2000 grey
+ else
+ background = QColor(192, 192, 192);
+#else
+ QColor background(0xd4, 0xd0, 0xc8); // win 2000 grey
+#endif
+ QColor light(background.lighter());
+ QColor dark(background.darker());
+ QColor mid(Qt::gray);
+ QPalette palette(Qt::black, background, light, dark, mid, Qt::black, Qt::white);
+ palette.setBrush(QPalette::Disabled, QPalette::WindowText, dark);
+ palette.setBrush(QPalette::Disabled, QPalette::Text, dark);
+ palette.setBrush(QPalette::Disabled, QPalette::ButtonText, dark);
+ palette.setBrush(QPalette::Disabled, QPalette::Base, background);
+ return palette;
+}
+
+/*!
+ \since 4.1
+
+ Returns an icon for the given \a standardIcon.
+
+ The \a standardIcon is a standard pixmap which can follow some
+ existing GUI style or guideline. The \a option argument can be
+ used to pass extra information required when defining the
+ appropriate icon. The \a widget argument is optional and can also
+ be used to aid the determination of the icon.
+
+ \warning Because of binary compatibility constraints, this
+ function is not virtual. If you want to provide your own icons in
+ a QStyle subclass, reimplement the standardIconImplementation()
+ slot in your subclass instead. The standardIcon() function will
+ dynamically detect the slot and call it.
+
+ \sa standardIconImplementation()
+*/
+QIcon QStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption *option,
+ const QWidget *widget) const
+{
+ QIcon result;
+ // ### Qt 4.1: invokeMethod should accept const functions, to avoid this dirty cast
+ QMetaObject::invokeMethod(const_cast<QStyle*>(this),
+ "standardIconImplementation", Qt::DirectConnection,
+ Q_RETURN_ARG(QIcon, result),
+ Q_ARG(StandardPixmap, standardIcon),
+ Q_ARG(const QStyleOption*, option),
+ Q_ARG(const QWidget*, widget));
+ return result;
+}
+
+/*!
+ \since 4.1
+
+ Returns an icon for the given \a standardIcon.
+
+ Reimplement this slot to provide your own icons in a QStyle
+ subclass; because of binary compatibility constraints, the
+ standardIcon() function (introduced in Qt 4.1) is not
+ virtual. Instead, standardIcon() will dynamically detect and call
+ \e this slot.
+
+ The \a standardIcon is a standard pixmap which can follow some
+ existing GUI style or guideline. The \a option argument can be
+ used to pass extra information required when defining the
+ appropriate icon. The \a widget argument is optional and can also
+ be used to aid the determination of the icon.
+
+ \sa standardIcon()
+*/
+QIcon QStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option,
+ const QWidget *widget) const
+{
+ return QIcon(standardPixmap(standardIcon, option, widget));
+}
+
+/*!
+ \since 4.3
+
+ Returns the spacing that should be used between \a control1 and
+ \a control2 in a layout. \a orientation specifies whether the
+ controls are laid out side by side or stacked vertically. The \a
+ option parameter can be used to pass extra information about the
+ parent widget. The \a widget parameter is optional and can also
+ be used if \a option is 0.
+
+ This function is called by the layout system. It is used only if
+ PM_LayoutHorizontalSpacing or PM_LayoutVerticalSpacing returns a
+ negative value.
+
+ For binary compatibility reasons, this function is not virtual.
+ If you want to specify custom layout spacings in a QStyle
+ subclass, implement a slot called layoutSpacingImplementation().
+ QStyle will discover the slot at run-time (using Qt's
+ \l{meta-object system}) and direct all calls to layoutSpacing()
+ to layoutSpacingImplementation().
+
+ \sa combinedLayoutSpacing(), layoutSpacingImplementation()
+*/
+int QStyle::layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2,
+ Qt::Orientation orientation, const QStyleOption *option,
+ const QWidget *widget) const
+{
+ Q_D(const QStyle);
+ if (d->layoutSpacingIndex == -1) {
+ d->layoutSpacingIndex = metaObject()->indexOfMethod(
+ "layoutSpacingImplementation(QSizePolicy::ControlType,QSizePolicy::ControlType,"
+ "Qt::Orientation,const QStyleOption*,const QWidget*)"
+ );
+ }
+ if (d->layoutSpacingIndex < 0)
+ return -1;
+ int result = -1;
+ void *param[] = {&result, &control1, &control2, &orientation, &option, &widget};
+
+ const_cast<QStyle *>(this)->qt_metacall(QMetaObject::InvokeMetaMethod,
+ d->layoutSpacingIndex, param);
+ return result;
+}
+
+/*!
+ \since 4.3
+
+ Returns the spacing that should be used between \a controls1 and
+ \a controls2 in a layout. \a orientation specifies whether the
+ controls are laid out side by side or stacked vertically. The \a
+ option parameter can be used to pass extra information about the
+ parent widget. The \a widget parameter is optional and can also
+ be used if \a option is 0.
+
+ \a controls1 and \a controls2 are OR-combination of zero or more
+ \l{QSizePolicy::ControlTypes}{control types}.
+
+ This function is called by the layout system. It is used only if
+ PM_LayoutHorizontalSpacing or PM_LayoutVerticalSpacing returns a
+ negative value.
+
+ \sa layoutSpacing(), layoutSpacingImplementation()
+*/
+int QStyle::combinedLayoutSpacing(QSizePolicy::ControlTypes controls1,
+ QSizePolicy::ControlTypes controls2, Qt::Orientation orientation,
+ QStyleOption *option, QWidget *widget) const
+{
+ QSizePolicy::ControlType array1[MaxBits];
+ QSizePolicy::ControlType array2[MaxBits];
+ int count1 = unpackControlTypes(controls1, array1);
+ int count2 = unpackControlTypes(controls2, array2);
+ int result = -1;
+
+ for (int i = 0; i < count1; ++i) {
+ for (int j = 0; j < count2; ++j) {
+ int spacing = layoutSpacing(array1[i], array2[j], orientation, option, widget);
+ result = qMax(spacing, result);
+ }
+ }
+ return result;
+}
+
+/*!
+ \since 4.3
+
+ This slot is called by layoutSpacing() to determine the spacing
+ that should be used between \a control1 and \a control2 in a
+ layout. \a orientation specifies whether the controls are laid
+ out side by side or stacked vertically. The \a option parameter
+ can be used to pass extra information about the parent widget.
+ The \a widget parameter is optional and can also be used if \a
+ option is 0.
+
+ If you want to provide custom layout spacings in a QStyle
+ subclass, implement a slot called layoutSpacingImplementation()
+ in your subclass. Be aware that this slot will only be called if
+ PM_LayoutHorizontalSpacing or PM_LayoutVerticalSpacing returns a
+ negative value.
+
+ The default implementation returns -1.
+
+ \sa layoutSpacing(), combinedLayoutSpacing()
+*/
+int QStyle::layoutSpacingImplementation(QSizePolicy::ControlType /* control1 */,
+ QSizePolicy::ControlType /* control2 */,
+ Qt::Orientation /*orientation*/,
+ const QStyleOption * /* option */,
+ const QWidget * /* widget */) const
+{
+ return -1;
+}
+
+QT_BEGIN_INCLUDE_NAMESPACE
+#include <QDebug>
+QT_END_INCLUDE_NAMESPACE
+
+#if !defined(QT_NO_DEBUG_STREAM)
+QDebug operator<<(QDebug debug, QStyle::State state)
+{
+#if !defined(QT_NO_DEBUG)
+ debug << "QStyle::State(";
+
+ QStringList states;
+ if (state & QStyle::State_Active) states << QLatin1String("Active");
+ if (state & QStyle::State_AutoRaise) states << QLatin1String("AutoRaise");
+ if (state & QStyle::State_Bottom) states << QLatin1String("Bottom");
+ if (state & QStyle::State_Children) states << QLatin1String("Children");
+ if (state & QStyle::State_DownArrow) states << QLatin1String("DownArrow");
+ if (state & QStyle::State_Editing) states << QLatin1String("Editing");
+ if (state & QStyle::State_Enabled) states << QLatin1String("Enabled");
+ if (state & QStyle::State_FocusAtBorder) states << QLatin1String("FocusAtBorder");
+ if (state & QStyle::State_HasFocus) states << QLatin1String("HasFocus");
+ if (state & QStyle::State_Horizontal) states << QLatin1String("Horizontal");
+ if (state & QStyle::State_Item) states << QLatin1String("Item");
+ if (state & QStyle::State_KeyboardFocusChange) states << QLatin1String("KeyboardFocusChange");
+ if (state & QStyle::State_MouseOver) states << QLatin1String("MouseOver");
+ if (state & QStyle::State_NoChange) states << QLatin1String("NoChange");
+ if (state & QStyle::State_Off) states << QLatin1String("Off");
+ if (state & QStyle::State_On) states << QLatin1String("On");
+ if (state & QStyle::State_Open) states << QLatin1String("Open");
+ if (state & QStyle::State_Raised) states << QLatin1String("Raised");
+ if (state & QStyle::State_ReadOnly) states << QLatin1String("ReadOnly");
+ if (state & QStyle::State_Selected) states << QLatin1String("Selected");
+ if (state & QStyle::State_Sibling) states << QLatin1String("Sibling");
+ if (state & QStyle::State_Sunken) states << QLatin1String("Sunken");
+ if (state & QStyle::State_Top) states << QLatin1String("Top");
+ if (state & QStyle::State_UpArrow) states << QLatin1String("UpArrow");
+
+ qSort(states);
+ debug << states.join(QLatin1String(" | "));
+ debug << ')';
+#else
+ Q_UNUSED(state);
+#endif
+ return debug;
+}
+#endif
+
+/*!
+ \since 4.6
+
+ \fn const QStyle *QStyle::proxy() const
+
+ This function returns the current proxy for this style.
+ By default most styles will return themselves. However
+ when a proxy style is in use, it will allow the style to
+ call back into its proxy.
+*/
+const QStyle * QStyle::proxy() const
+{
+ Q_D(const QStyle);
+ return d->proxyStyle;
+}
+
+/* \internal
+
+ This function sets the base style that style calls will be
+ redirected to. Note that ownership is not transferred.
+*/
+void QStyle::setProxy(QStyle *style)
+{
+ Q_D(QStyle);
+ d->proxyStyle = style;
+}
+
+QT_END_NAMESPACE
diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h
new file mode 100644
index 0000000000..26a1e0fa20
--- /dev/null
+++ b/src/widgets/styles/qstyle.h
@@ -0,0 +1,889 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSTYLE_H
+#define QSTYLE_H
+
+#include <QtCore/qobject.h>
+#include <QtCore/qrect.h>
+#include <QtCore/qsize.h>
+#include <QtWidgets/qicon.h>
+#include <QtGui/qpixmap.h>
+#include <QtGui/qpalette.h>
+#include <QtWidgets/qsizepolicy.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QAction;
+class QDebug;
+class QTab;
+class QFontMetrics;
+class QStyleHintReturn;
+class QStyleOption;
+class QStyleOptionComplex;
+class QStylePrivate;
+
+class Q_GUI_EXPORT QStyle : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QStyle)
+
+protected:
+ QStyle(QStylePrivate &dd);
+
+public:
+ QStyle();
+ virtual ~QStyle();
+
+ virtual void polish(QWidget *);
+ virtual void unpolish(QWidget *);
+
+ virtual void polish(QApplication *);
+ virtual void unpolish(QApplication *);
+
+ virtual void polish(QPalette &);
+
+ virtual QRect itemTextRect(const QFontMetrics &fm, const QRect &r,
+ int flags, bool enabled,
+ const QString &text) const;
+
+ virtual QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const;
+
+ virtual void drawItemText(QPainter *painter, const QRect &rect,
+ int flags, const QPalette &pal, bool enabled,
+ const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) const;
+
+ virtual void drawItemPixmap(QPainter *painter, const QRect &rect,
+ int alignment, const QPixmap &pixmap) const;
+
+ virtual QPalette standardPalette() const;
+
+ enum StateFlag {
+ State_None = 0x00000000,
+#ifdef QT3_SUPPORT
+ State_Default = State_None,
+#endif
+ State_Enabled = 0x00000001,
+ State_Raised = 0x00000002,
+ State_Sunken = 0x00000004,
+ State_Off = 0x00000008,
+ State_NoChange = 0x00000010,
+ State_On = 0x00000020,
+ State_DownArrow = 0x00000040,
+ State_Horizontal = 0x00000080,
+ State_HasFocus = 0x00000100,
+ State_Top = 0x00000200,
+ State_Bottom = 0x00000400,
+ State_FocusAtBorder = 0x00000800,
+ State_AutoRaise = 0x00001000,
+ State_MouseOver = 0x00002000,
+ State_UpArrow = 0x00004000,
+ State_Selected = 0x00008000,
+ State_Active = 0x00010000,
+ State_Window = 0x00020000,
+ State_Open = 0x00040000,
+ State_Children = 0x00080000,
+ State_Item = 0x00100000,
+ State_Sibling = 0x00200000,
+ State_Editing = 0x00400000,
+ State_KeyboardFocusChange = 0x00800000,
+#ifdef QT_KEYPAD_NAVIGATION
+ State_HasEditFocus = 0x01000000,
+#endif
+ State_ReadOnly = 0x02000000,
+ State_Small = 0x04000000,
+ State_Mini = 0x08000000
+ };
+ Q_DECLARE_FLAGS(State, StateFlag)
+
+#ifdef QT3_SUPPORT
+ typedef State SFlags;
+#endif
+
+ enum PrimitiveElement {
+ PE_Q3CheckListController,
+ PE_Q3CheckListExclusiveIndicator,
+ PE_Q3CheckListIndicator,
+ PE_Q3DockWindowSeparator,
+ PE_Q3Separator,
+
+ PE_Frame,
+ PE_FrameDefaultButton,
+ PE_FrameDockWidget,
+ PE_FrameFocusRect,
+ PE_FrameGroupBox,
+ PE_FrameLineEdit,
+ PE_FrameMenu,
+ PE_FrameStatusBar, // obsolete
+ PE_FrameStatusBarItem = PE_FrameStatusBar,
+ PE_FrameTabWidget,
+ PE_FrameWindow,
+ PE_FrameButtonBevel,
+ PE_FrameButtonTool,
+ PE_FrameTabBarBase,
+
+ PE_PanelButtonCommand,
+ PE_PanelButtonBevel,
+ PE_PanelButtonTool,
+ PE_PanelMenuBar,
+ PE_PanelToolBar,
+ PE_PanelLineEdit,
+
+ PE_IndicatorArrowDown,
+ PE_IndicatorArrowLeft,
+ PE_IndicatorArrowRight,
+ PE_IndicatorArrowUp,
+ PE_IndicatorBranch,
+ PE_IndicatorButtonDropDown,
+ PE_IndicatorViewItemCheck,
+ PE_IndicatorItemViewItemCheck = PE_IndicatorViewItemCheck,
+ PE_IndicatorCheckBox,
+ PE_IndicatorDockWidgetResizeHandle,
+ PE_IndicatorHeaderArrow,
+ PE_IndicatorMenuCheckMark,
+ PE_IndicatorProgressChunk,
+ PE_IndicatorRadioButton,
+ PE_IndicatorSpinDown,
+ PE_IndicatorSpinMinus,
+ PE_IndicatorSpinPlus,
+ PE_IndicatorSpinUp,
+ PE_IndicatorToolBarHandle,
+ PE_IndicatorToolBarSeparator,
+ PE_PanelTipLabel,
+ PE_IndicatorTabTear,
+ PE_PanelScrollAreaCorner,
+
+ PE_Widget,
+
+ PE_IndicatorColumnViewArrow,
+ PE_IndicatorItemViewItemDrop,
+
+ PE_PanelItemViewItem,
+ PE_PanelItemViewRow, // ### Qt 5: remove
+
+ PE_PanelStatusBar,
+
+ PE_IndicatorTabClose,
+ PE_PanelMenu,
+
+ // do not add any values below/greater this
+ PE_CustomBase = 0xf000000
+ };
+
+ virtual void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
+ const QWidget *w = 0) const = 0;
+ enum ControlElement {
+ CE_PushButton,
+ CE_PushButtonBevel,
+ CE_PushButtonLabel,
+
+ CE_CheckBox,
+ CE_CheckBoxLabel,
+
+ CE_RadioButton,
+ CE_RadioButtonLabel,
+
+ CE_TabBarTab,
+ CE_TabBarTabShape,
+ CE_TabBarTabLabel,
+
+ CE_ProgressBar,
+ CE_ProgressBarGroove,
+ CE_ProgressBarContents,
+ CE_ProgressBarLabel,
+
+ CE_MenuItem,
+ CE_MenuScroller,
+ CE_MenuVMargin,
+ CE_MenuHMargin,
+ CE_MenuTearoff,
+ CE_MenuEmptyArea,
+
+ CE_MenuBarItem,
+ CE_MenuBarEmptyArea,
+
+ CE_ToolButtonLabel,
+
+ CE_Header,
+ CE_HeaderSection,
+ CE_HeaderLabel,
+
+ CE_Q3DockWindowEmptyArea,
+ CE_ToolBoxTab,
+ CE_SizeGrip,
+ CE_Splitter,
+ CE_RubberBand,
+ CE_DockWidgetTitle,
+
+ CE_ScrollBarAddLine,
+ CE_ScrollBarSubLine,
+ CE_ScrollBarAddPage,
+ CE_ScrollBarSubPage,
+ CE_ScrollBarSlider,
+ CE_ScrollBarFirst,
+ CE_ScrollBarLast,
+
+ CE_FocusFrame,
+ CE_ComboBoxLabel,
+
+ CE_ToolBar,
+ CE_ToolBoxTabShape,
+ CE_ToolBoxTabLabel,
+ CE_HeaderEmptyArea,
+
+ CE_ColumnViewGrip,
+
+ CE_ItemViewItem,
+
+ CE_ShapedFrame,
+
+ // do not add any values below/greater than this
+ CE_CustomBase = 0xf0000000
+ };
+
+ virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
+ const QWidget *w = 0) const = 0;
+
+ enum SubElement {
+ SE_PushButtonContents,
+ SE_PushButtonFocusRect,
+
+ SE_CheckBoxIndicator,
+ SE_CheckBoxContents,
+ SE_CheckBoxFocusRect,
+ SE_CheckBoxClickRect,
+
+ SE_RadioButtonIndicator,
+ SE_RadioButtonContents,
+ SE_RadioButtonFocusRect,
+ SE_RadioButtonClickRect,
+
+ SE_ComboBoxFocusRect,
+
+ SE_SliderFocusRect,
+
+ SE_Q3DockWindowHandleRect,
+
+ SE_ProgressBarGroove,
+ SE_ProgressBarContents,
+ SE_ProgressBarLabel,
+
+ // ### Qt 5: These values are unused; eliminate them
+ SE_DialogButtonAccept,
+ SE_DialogButtonReject,
+ SE_DialogButtonApply,
+ SE_DialogButtonHelp,
+ SE_DialogButtonAll,
+ SE_DialogButtonAbort,
+ SE_DialogButtonIgnore,
+ SE_DialogButtonRetry,
+ SE_DialogButtonCustom,
+
+ SE_ToolBoxTabContents,
+
+ SE_HeaderLabel,
+ SE_HeaderArrow,
+
+ SE_TabWidgetTabBar,
+ SE_TabWidgetTabPane,
+ SE_TabWidgetTabContents,
+ SE_TabWidgetLeftCorner,
+ SE_TabWidgetRightCorner,
+
+ SE_ViewItemCheckIndicator,
+ SE_ItemViewItemCheckIndicator = SE_ViewItemCheckIndicator,
+
+ SE_TabBarTearIndicator,
+
+ SE_TreeViewDisclosureItem,
+
+ SE_LineEditContents,
+ SE_FrameContents,
+
+ SE_DockWidgetCloseButton,
+ SE_DockWidgetFloatButton,
+ SE_DockWidgetTitleBarText,
+ SE_DockWidgetIcon,
+
+ SE_CheckBoxLayoutItem,
+ SE_ComboBoxLayoutItem,
+ SE_DateTimeEditLayoutItem,
+ SE_DialogButtonBoxLayoutItem, // ### remove
+ SE_LabelLayoutItem,
+ SE_ProgressBarLayoutItem,
+ SE_PushButtonLayoutItem,
+ SE_RadioButtonLayoutItem,
+ SE_SliderLayoutItem,
+ SE_SpinBoxLayoutItem,
+ SE_ToolButtonLayoutItem,
+
+ SE_FrameLayoutItem,
+ SE_GroupBoxLayoutItem,
+ SE_TabWidgetLayoutItem,
+
+ SE_ItemViewItemDecoration,
+ SE_ItemViewItemText,
+ SE_ItemViewItemFocusRect,
+
+ SE_TabBarTabLeftButton,
+ SE_TabBarTabRightButton,
+ SE_TabBarTabText,
+
+ SE_ShapedFrameContents,
+
+ SE_ToolBarHandle,
+
+ // do not add any values below/greater than this
+ SE_CustomBase = 0xf0000000
+ };
+
+ virtual QRect subElementRect(SubElement subElement, const QStyleOption *option,
+ const QWidget *widget = 0) const = 0;
+
+
+ enum ComplexControl {
+ CC_SpinBox,
+ CC_ComboBox,
+ CC_ScrollBar,
+ CC_Slider,
+ CC_ToolButton,
+ CC_TitleBar,
+ CC_Q3ListView,
+ CC_Dial,
+ CC_GroupBox,
+ CC_MdiControls,
+
+ // do not add any values below/greater than this
+ CC_CustomBase = 0xf0000000
+ };
+
+ enum SubControl {
+ SC_None = 0x00000000,
+
+ SC_ScrollBarAddLine = 0x00000001,
+ SC_ScrollBarSubLine = 0x00000002,
+ SC_ScrollBarAddPage = 0x00000004,
+ SC_ScrollBarSubPage = 0x00000008,
+ SC_ScrollBarFirst = 0x00000010,
+ SC_ScrollBarLast = 0x00000020,
+ SC_ScrollBarSlider = 0x00000040,
+ SC_ScrollBarGroove = 0x00000080,
+
+ SC_SpinBoxUp = 0x00000001,
+ SC_SpinBoxDown = 0x00000002,
+ SC_SpinBoxFrame = 0x00000004,
+ SC_SpinBoxEditField = 0x00000008,
+
+ SC_ComboBoxFrame = 0x00000001,
+ SC_ComboBoxEditField = 0x00000002,
+ SC_ComboBoxArrow = 0x00000004,
+ SC_ComboBoxListBoxPopup = 0x00000008,
+
+ SC_SliderGroove = 0x00000001,
+ SC_SliderHandle = 0x00000002,
+ SC_SliderTickmarks = 0x00000004,
+
+ SC_ToolButton = 0x00000001,
+ SC_ToolButtonMenu = 0x00000002,
+
+ SC_TitleBarSysMenu = 0x00000001,
+ SC_TitleBarMinButton = 0x00000002,
+ SC_TitleBarMaxButton = 0x00000004,
+ SC_TitleBarCloseButton = 0x00000008,
+ SC_TitleBarNormalButton = 0x00000010,
+ SC_TitleBarShadeButton = 0x00000020,
+ SC_TitleBarUnshadeButton = 0x00000040,
+ SC_TitleBarContextHelpButton = 0x00000080,
+ SC_TitleBarLabel = 0x00000100,
+
+ SC_Q3ListView = 0x00000001,
+ SC_Q3ListViewBranch = 0x00000002,
+ SC_Q3ListViewExpand = 0x00000004,
+
+ SC_DialGroove = 0x00000001,
+ SC_DialHandle = 0x00000002,
+ SC_DialTickmarks = 0x00000004,
+
+ SC_GroupBoxCheckBox = 0x00000001,
+ SC_GroupBoxLabel = 0x00000002,
+ SC_GroupBoxContents = 0x00000004,
+ SC_GroupBoxFrame = 0x00000008,
+
+ SC_MdiMinButton = 0x00000001,
+ SC_MdiNormalButton = 0x00000002,
+ SC_MdiCloseButton = 0x00000004,
+
+ SC_CustomBase = 0xf0000000,
+ SC_All = 0xffffffff
+ };
+ Q_DECLARE_FLAGS(SubControls, SubControl)
+
+#ifdef QT3_SUPPORT
+ typedef SubControls SCFlags;
+#endif
+
+ virtual void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
+ const QWidget *widget = 0) const = 0;
+ virtual SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
+ const QPoint &pt, const QWidget *widget = 0) const = 0;
+ virtual QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt,
+ SubControl sc, const QWidget *widget = 0) const = 0;
+
+ enum PixelMetric {
+ PM_ButtonMargin,
+ PM_ButtonDefaultIndicator,
+ PM_MenuButtonIndicator,
+ PM_ButtonShiftHorizontal,
+ PM_ButtonShiftVertical,
+
+ PM_DefaultFrameWidth,
+ PM_SpinBoxFrameWidth,
+ PM_ComboBoxFrameWidth,
+
+ PM_MaximumDragDistance,
+
+ PM_ScrollBarExtent,
+ PM_ScrollBarSliderMin,
+
+ PM_SliderThickness, // total slider thickness
+ PM_SliderControlThickness, // thickness of the business part
+ PM_SliderLength, // total length of slider
+ PM_SliderTickmarkOffset, //
+ PM_SliderSpaceAvailable, // available space for slider to move
+
+ PM_DockWidgetSeparatorExtent,
+ PM_DockWidgetHandleExtent,
+ PM_DockWidgetFrameWidth,
+
+ PM_TabBarTabOverlap,
+ PM_TabBarTabHSpace,
+ PM_TabBarTabVSpace,
+ PM_TabBarBaseHeight,
+ PM_TabBarBaseOverlap,
+
+ PM_ProgressBarChunkWidth,
+
+ PM_SplitterWidth,
+ PM_TitleBarHeight,
+
+ PM_MenuScrollerHeight,
+ PM_MenuHMargin,
+ PM_MenuVMargin,
+ PM_MenuPanelWidth,
+ PM_MenuTearoffHeight,
+ PM_MenuDesktopFrameWidth,
+
+ PM_MenuBarPanelWidth,
+ PM_MenuBarItemSpacing,
+ PM_MenuBarVMargin,
+ PM_MenuBarHMargin,
+
+ PM_IndicatorWidth,
+ PM_IndicatorHeight,
+ PM_ExclusiveIndicatorWidth,
+ PM_ExclusiveIndicatorHeight,
+ PM_CheckListButtonSize,
+ PM_CheckListControllerSize,
+
+ PM_DialogButtonsSeparator,
+ PM_DialogButtonsButtonWidth,
+ PM_DialogButtonsButtonHeight,
+
+ PM_MdiSubWindowFrameWidth,
+ PM_MDIFrameWidth = PM_MdiSubWindowFrameWidth, //obsolete
+ PM_MdiSubWindowMinimizedWidth,
+ PM_MDIMinimizedWidth = PM_MdiSubWindowMinimizedWidth, //obsolete
+
+ PM_HeaderMargin,
+ PM_HeaderMarkSize,
+ PM_HeaderGripMargin,
+ PM_TabBarTabShiftHorizontal,
+ PM_TabBarTabShiftVertical,
+ PM_TabBarScrollButtonWidth,
+
+ PM_ToolBarFrameWidth,
+ PM_ToolBarHandleExtent,
+ PM_ToolBarItemSpacing,
+ PM_ToolBarItemMargin,
+ PM_ToolBarSeparatorExtent,
+ PM_ToolBarExtensionExtent,
+
+ PM_SpinBoxSliderHeight,
+
+ PM_DefaultTopLevelMargin,
+ PM_DefaultChildMargin,
+ PM_DefaultLayoutSpacing,
+
+ PM_ToolBarIconSize,
+ PM_ListViewIconSize,
+ PM_IconViewIconSize,
+ PM_SmallIconSize,
+ PM_LargeIconSize,
+
+ PM_FocusFrameVMargin,
+ PM_FocusFrameHMargin,
+
+ PM_ToolTipLabelFrameWidth,
+ PM_CheckBoxLabelSpacing,
+ PM_TabBarIconSize,
+ PM_SizeGripSize,
+ PM_DockWidgetTitleMargin,
+ PM_MessageBoxIconSize,
+ PM_ButtonIconSize,
+
+ PM_DockWidgetTitleBarButtonMargin,
+
+ PM_RadioButtonLabelSpacing,
+ PM_LayoutLeftMargin,
+ PM_LayoutTopMargin,
+ PM_LayoutRightMargin,
+ PM_LayoutBottomMargin,
+ PM_LayoutHorizontalSpacing,
+ PM_LayoutVerticalSpacing,
+ PM_TabBar_ScrollButtonOverlap,
+
+ PM_TextCursorWidth,
+
+ PM_TabCloseIndicatorWidth,
+ PM_TabCloseIndicatorHeight,
+
+ PM_ScrollView_ScrollBarSpacing,
+ PM_SubMenuOverlap,
+
+ // do not add any values below/greater than this
+ PM_CustomBase = 0xf0000000
+ };
+
+ virtual int pixelMetric(PixelMetric metric, const QStyleOption *option = 0,
+ const QWidget *widget = 0) const = 0;
+
+ enum ContentsType {
+ CT_PushButton,
+ CT_CheckBox,
+ CT_RadioButton,
+ CT_ToolButton,
+ CT_ComboBox,
+ CT_Splitter,
+ CT_Q3DockWindow,
+ CT_ProgressBar,
+ CT_MenuItem,
+ CT_MenuBarItem,
+ CT_MenuBar,
+ CT_Menu,
+ CT_TabBarTab,
+ CT_Slider,
+ CT_ScrollBar,
+ CT_Q3Header,
+ CT_LineEdit,
+ CT_SpinBox,
+ CT_SizeGrip,
+ CT_TabWidget,
+ CT_DialogButtons,
+ CT_HeaderSection,
+ CT_GroupBox,
+ CT_MdiControls,
+ CT_ItemViewItem,
+ // do not add any values below/greater than this
+ CT_CustomBase = 0xf0000000
+ };
+
+ virtual QSize sizeFromContents(ContentsType ct, const QStyleOption *opt,
+ const QSize &contentsSize, const QWidget *w = 0) const = 0;
+
+ enum RequestSoftwareInputPanel {
+ RSIP_OnMouseClickAndAlreadyFocused,
+ RSIP_OnMouseClick
+ };
+
+ enum StyleHint {
+ SH_EtchDisabledText,
+ SH_DitherDisabledText,
+ SH_ScrollBar_MiddleClickAbsolutePosition,
+ SH_ScrollBar_ScrollWhenPointerLeavesControl,
+ SH_TabBar_SelectMouseType,
+ SH_TabBar_Alignment,
+ SH_Header_ArrowAlignment,
+ SH_Slider_SnapToValue,
+ SH_Slider_SloppyKeyEvents,
+ SH_ProgressDialog_CenterCancelButton,
+ SH_ProgressDialog_TextLabelAlignment,
+ SH_PrintDialog_RightAlignButtons,
+ SH_MainWindow_SpaceBelowMenuBar,
+ SH_FontDialog_SelectAssociatedText,
+ SH_Menu_AllowActiveAndDisabled,
+ SH_Menu_SpaceActivatesItem,
+ SH_Menu_SubMenuPopupDelay,
+ SH_ScrollView_FrameOnlyAroundContents,
+ SH_MenuBar_AltKeyNavigation,
+ SH_ComboBox_ListMouseTracking,
+ SH_Menu_MouseTracking,
+ SH_MenuBar_MouseTracking,
+ SH_ItemView_ChangeHighlightOnFocus,
+ SH_Widget_ShareActivation,
+ SH_Workspace_FillSpaceOnMaximize,
+ SH_ComboBox_Popup,
+ SH_TitleBar_NoBorder,
+ SH_Slider_StopMouseOverSlider,
+ SH_ScrollBar_StopMouseOverSlider = SH_Slider_StopMouseOverSlider, // obsolete
+ SH_BlinkCursorWhenTextSelected,
+ SH_RichText_FullWidthSelection,
+ SH_Menu_Scrollable,
+ SH_GroupBox_TextLabelVerticalAlignment,
+ SH_GroupBox_TextLabelColor,
+ SH_Menu_SloppySubMenus,
+ SH_Table_GridLineColor,
+ SH_LineEdit_PasswordCharacter,
+ SH_DialogButtons_DefaultButton,
+ SH_ToolBox_SelectedPageTitleBold,
+ SH_TabBar_PreferNoArrows,
+ SH_ScrollBar_LeftClickAbsolutePosition,
+ SH_Q3ListViewExpand_SelectMouseType,
+ SH_UnderlineShortcut,
+ SH_SpinBox_AnimateButton,
+ SH_SpinBox_KeyPressAutoRepeatRate,
+ SH_SpinBox_ClickAutoRepeatRate,
+ SH_Menu_FillScreenWithScroll,
+ SH_ToolTipLabel_Opacity,
+ SH_DrawMenuBarSeparator,
+ SH_TitleBar_ModifyNotification,
+ SH_Button_FocusPolicy,
+ SH_MenuBar_DismissOnSecondClick,
+ SH_MessageBox_UseBorderForButtonSpacing,
+ SH_TitleBar_AutoRaise,
+ SH_ToolButton_PopupDelay,
+ SH_FocusFrame_Mask,
+ SH_RubberBand_Mask,
+ SH_WindowFrame_Mask,
+ SH_SpinControls_DisableOnBounds,
+ SH_Dial_BackgroundRole,
+ SH_ComboBox_LayoutDirection,
+ SH_ItemView_EllipsisLocation,
+ SH_ItemView_ShowDecorationSelected,
+ SH_ItemView_ActivateItemOnSingleClick,
+ SH_ScrollBar_ContextMenu,
+ SH_ScrollBar_RollBetweenButtons,
+ SH_Slider_AbsoluteSetButtons,
+ SH_Slider_PageSetButtons,
+ SH_Menu_KeyboardSearch,
+ SH_TabBar_ElideMode,
+ SH_DialogButtonLayout,
+ SH_ComboBox_PopupFrameStyle,
+ SH_MessageBox_TextInteractionFlags,
+ SH_DialogButtonBox_ButtonsHaveIcons,
+ SH_SpellCheckUnderlineStyle,
+ SH_MessageBox_CenterButtons,
+ SH_Menu_SelectionWrap,
+ SH_ItemView_MovementWithoutUpdatingSelection,
+ SH_ToolTip_Mask,
+ SH_FocusFrame_AboveWidget,
+ SH_TextControl_FocusIndicatorTextCharFormat,
+ SH_WizardStyle,
+ SH_ItemView_ArrowKeysNavigateIntoChildren,
+ SH_Menu_Mask,
+ SH_Menu_FlashTriggeredItem,
+ SH_Menu_FadeOutOnHide,
+ SH_SpinBox_ClickAutoRepeatThreshold,
+ SH_ItemView_PaintAlternatingRowColorsForEmptyArea,
+ SH_FormLayoutWrapPolicy,
+ SH_TabWidget_DefaultTabPosition,
+ SH_ToolBar_Movable,
+ SH_FormLayoutFieldGrowthPolicy,
+ SH_FormLayoutFormAlignment,
+ SH_FormLayoutLabelAlignment,
+ SH_ItemView_DrawDelegateFrame,
+ SH_TabBar_CloseButtonPosition,
+ SH_DockWidget_ButtonsHaveFrame,
+ SH_ToolButtonStyle,
+ SH_RequestSoftwareInputPanel,
+ // Add new style hint values here
+
+#ifdef QT3_SUPPORT
+ SH_GUIStyle = 0x00000100,
+ SH_ScrollBar_BackgroundMode,
+ // Add other compat values here
+
+ SH_UnderlineAccelerator = SH_UnderlineShortcut,
+#endif
+ SH_CustomBase = 0xf0000000
+ };
+
+ virtual int styleHint(StyleHint stylehint, const QStyleOption *opt = 0,
+ const QWidget *widget = 0, QStyleHintReturn* returnData = 0) const = 0;
+
+ enum StandardPixmap {
+ SP_TitleBarMenuButton,
+ SP_TitleBarMinButton,
+ SP_TitleBarMaxButton,
+ SP_TitleBarCloseButton,
+ SP_TitleBarNormalButton,
+ SP_TitleBarShadeButton,
+ SP_TitleBarUnshadeButton,
+ SP_TitleBarContextHelpButton,
+ SP_DockWidgetCloseButton,
+ SP_MessageBoxInformation,
+ SP_MessageBoxWarning,
+ SP_MessageBoxCritical,
+ SP_MessageBoxQuestion,
+ SP_DesktopIcon,
+ SP_TrashIcon,
+ SP_ComputerIcon,
+ SP_DriveFDIcon,
+ SP_DriveHDIcon,
+ SP_DriveCDIcon,
+ SP_DriveDVDIcon,
+ SP_DriveNetIcon,
+ SP_DirOpenIcon,
+ SP_DirClosedIcon,
+ SP_DirLinkIcon,
+ SP_FileIcon,
+ SP_FileLinkIcon,
+ SP_ToolBarHorizontalExtensionButton,
+ SP_ToolBarVerticalExtensionButton,
+ SP_FileDialogStart,
+ SP_FileDialogEnd,
+ SP_FileDialogToParent,
+ SP_FileDialogNewFolder,
+ SP_FileDialogDetailedView,
+ SP_FileDialogInfoView,
+ SP_FileDialogContentsView,
+ SP_FileDialogListView,
+ SP_FileDialogBack,
+ SP_DirIcon,
+ SP_DialogOkButton,
+ SP_DialogCancelButton,
+ SP_DialogHelpButton,
+ SP_DialogOpenButton,
+ SP_DialogSaveButton,
+ SP_DialogCloseButton,
+ SP_DialogApplyButton,
+ SP_DialogResetButton,
+ SP_DialogDiscardButton,
+ SP_DialogYesButton,
+ SP_DialogNoButton,
+ SP_ArrowUp,
+ SP_ArrowDown,
+ SP_ArrowLeft,
+ SP_ArrowRight,
+ SP_ArrowBack,
+ SP_ArrowForward,
+ SP_DirHomeIcon,
+ SP_CommandLink,
+ SP_VistaShield,
+ SP_BrowserReload,
+ SP_BrowserStop,
+ SP_MediaPlay,
+ SP_MediaStop,
+ SP_MediaPause,
+ SP_MediaSkipForward,
+ SP_MediaSkipBackward,
+ SP_MediaSeekForward,
+ SP_MediaSeekBackward,
+ SP_MediaVolume,
+ SP_MediaVolumeMuted,
+ // do not add any values below/greater than this
+ SP_CustomBase = 0xf0000000
+ };
+
+ virtual QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt = 0,
+ const QWidget *widget = 0) const = 0;
+
+ QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *option = 0,
+ const QWidget *widget = 0) const;
+
+ virtual QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
+ const QStyleOption *opt) const = 0;
+
+ static QRect visualRect(Qt::LayoutDirection direction, const QRect &boundingRect,
+ const QRect &logicalRect);
+ static QPoint visualPos(Qt::LayoutDirection direction, const QRect &boundingRect,
+ const QPoint &logicalPos);
+ static int sliderPositionFromValue(int min, int max, int val, int space,
+ bool upsideDown = false);
+ static int sliderValueFromPosition(int min, int max, int pos, int space,
+ bool upsideDown = false);
+ static Qt::Alignment visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment);
+ static QRect alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment,
+ const QSize &size, const QRect &rectangle);
+
+ int layoutSpacing(QSizePolicy::ControlType control1,
+ QSizePolicy::ControlType control2, Qt::Orientation orientation,
+ const QStyleOption *option = 0, const QWidget *widget = 0) const;
+ int combinedLayoutSpacing(QSizePolicy::ControlTypes controls1,
+ QSizePolicy::ControlTypes controls2, Qt::Orientation orientation,
+ QStyleOption *option = 0, QWidget *widget = 0) const;
+
+ const QStyle * proxy() const;
+
+protected Q_SLOTS:
+ QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt = 0,
+ const QWidget *widget = 0) const;
+ int layoutSpacingImplementation(QSizePolicy::ControlType control1,
+ QSizePolicy::ControlType control2,
+ Qt::Orientation orientation,
+ const QStyleOption *option = 0,
+ const QWidget *widget = 0) const;
+
+private:
+ Q_DISABLE_COPY(QStyle)
+ friend class QWidget;
+ friend class QWidgetPrivate;
+ friend class QApplication;
+ friend class QProxyStyle;
+ friend class QProxyStylePrivate;
+ void setProxy(QStyle *style);
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QStyle::State)
+Q_DECLARE_OPERATORS_FOR_FLAGS(QStyle::SubControls)
+
+#if !defined(QT_NO_DEBUG_STREAM)
+Q_GUI_EXPORT QDebug operator<<(QDebug debug, QStyle::State state);
+#endif
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QSTYLE_H
diff --git a/src/gui/styles/qstyle.qrc b/src/widgets/styles/qstyle.qrc
index 8654e66a37..8654e66a37 100644
--- a/src/gui/styles/qstyle.qrc
+++ b/src/widgets/styles/qstyle.qrc
diff --git a/src/widgets/styles/qstyle_p.h b/src/widgets/styles/qstyle_p.h
new file mode 100644
index 0000000000..0f3513d640
--- /dev/null
+++ b/src/widgets/styles/qstyle_p.h
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSTYLE_P_H
+#define QSTYLE_P_H
+
+#include "private/qobject_p.h"
+#include <QtWidgets/qstyle.h>
+
+QT_BEGIN_NAMESPACE
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of qstyle_*.cpp. This header file may change from version to version
+// without notice, or even be removed.
+//
+// We mean it.
+//
+
+// Private class
+
+class QStyle;
+
+class QStylePrivate: public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QStyle)
+public:
+ inline QStylePrivate()
+ : layoutSpacingIndex(-1), proxyStyle(0) {}
+ mutable int layoutSpacingIndex;
+ QStyle *proxyStyle;
+};
+
+
+#define BEGIN_STYLE_PIXMAPCACHE(a) \
+ QRect rect = option->rect; \
+ QPixmap internalPixmapCache; \
+ QImage imageCache; \
+ QPainter *p = painter; \
+ QString unique = QStyleHelper::uniqueName((a), option, option->rect.size()); \
+ int txType = painter->deviceTransform().type() | painter->worldTransform().type(); \
+ bool doPixmapCache = txType <= QTransform::TxTranslate; \
+ if (doPixmapCache && QPixmapCache::find(unique, internalPixmapCache)) { \
+ painter->drawPixmap(option->rect.topLeft(), internalPixmapCache); \
+ } else { \
+ if (doPixmapCache) { \
+ rect.setRect(0, 0, option->rect.width(), option->rect.height()); \
+ imageCache = QImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); \
+ imageCache.fill(0); \
+ p = new QPainter(&imageCache); \
+ }
+
+
+
+#define END_STYLE_PIXMAPCACHE \
+ if (doPixmapCache) { \
+ p->end(); \
+ delete p; \
+ internalPixmapCache = QPixmap::fromImage(imageCache); \
+ painter->drawPixmap(option->rect.topLeft(), internalPixmapCache); \
+ QPixmapCache::insert(unique, internalPixmapCache); \
+ } \
+ }
+
+QT_END_NAMESPACE
+
+#endif //QSTYLE_P_H
diff --git a/src/gui/styles/qstyle_s60.qrc b/src/widgets/styles/qstyle_s60.qrc
index dbee38b266..dbee38b266 100644
--- a/src/gui/styles/qstyle_s60.qrc
+++ b/src/widgets/styles/qstyle_s60.qrc
diff --git a/src/gui/styles/qstyle_s60_simulated.qrc b/src/widgets/styles/qstyle_s60_simulated.qrc
index 969732e1e0..969732e1e0 100644
--- a/src/gui/styles/qstyle_s60_simulated.qrc
+++ b/src/widgets/styles/qstyle_s60_simulated.qrc
diff --git a/src/gui/styles/qstyle_wince.qrc b/src/widgets/styles/qstyle_wince.qrc
index bdcf604625..bdcf604625 100644
--- a/src/gui/styles/qstyle_wince.qrc
+++ b/src/widgets/styles/qstyle_wince.qrc
diff --git a/src/gui/styles/qstylefactory.cpp b/src/widgets/styles/qstylefactory.cpp
index 1a9682a831..1a9682a831 100644
--- a/src/gui/styles/qstylefactory.cpp
+++ b/src/widgets/styles/qstylefactory.cpp
diff --git a/src/gui/styles/qstylefactory.h b/src/widgets/styles/qstylefactory.h
index b665e5fce4..b665e5fce4 100644
--- a/src/gui/styles/qstylefactory.h
+++ b/src/widgets/styles/qstylefactory.h
diff --git a/src/gui/styles/qstylehelper.cpp b/src/widgets/styles/qstylehelper.cpp
index 59766cae0f..59766cae0f 100644
--- a/src/gui/styles/qstylehelper.cpp
+++ b/src/widgets/styles/qstylehelper.cpp
diff --git a/src/widgets/styles/qstylehelper_p.h b/src/widgets/styles/qstylehelper_p.h
new file mode 100644
index 0000000000..6aeb71c103
--- /dev/null
+++ b/src/widgets/styles/qstylehelper_p.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/qglobal.h>
+#include <QtCore/qpoint.h>
+#include <QtCore/qstring.h>
+#include <QtGui/qpolygon.h>
+#include <QtCore/qstringbuilder.h>
+
+#ifndef QSTYLEHELPER_P_H
+#define QSTYLEHELPER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <private/qhexstring_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QPainter;
+class QPixmap;
+class QStyleOptionSlider;
+class QStyleOption;
+
+namespace QStyleHelper
+{
+ QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size);
+ qreal dpiScaled(qreal value);
+#ifndef QT_NO_DIAL
+ qreal angle(const QPointF &p1, const QPointF &p2);
+ QPolygonF calcLines(const QStyleOptionSlider *dial);
+ int calcBigLineSize(int radius);
+ void drawDial(const QStyleOptionSlider *dial, QPainter *painter);
+#endif //QT_NO_DIAL
+ void drawBorderPixmap(const QPixmap &pixmap, QPainter *painter, const QRect &rect,
+ int left = 0, int top = 0, int right = 0,
+ int bottom = 0);
+}
+
+
+QT_END_NAMESPACE
+
+#endif // QSTYLEHELPER_P_H
diff --git a/src/gui/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp
index ee8e177546..ee8e177546 100644
--- a/src/gui/styles/qstyleoption.cpp
+++ b/src/widgets/styles/qstyleoption.cpp
diff --git a/src/widgets/styles/qstyleoption.h b/src/widgets/styles/qstyleoption.h
new file mode 100644
index 0000000000..8611e952c2
--- /dev/null
+++ b/src/widgets/styles/qstyleoption.h
@@ -0,0 +1,970 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSTYLEOPTION_H
+#define QSTYLEOPTION_H
+
+#include <QtCore/qvariant.h>
+#include <QtWidgets/qabstractspinbox.h>
+#include <QtWidgets/qicon.h>
+#include <QtGui/qmatrix.h>
+#include <QtWidgets/qslider.h>
+#include <QtWidgets/qstyle.h>
+#include <QtWidgets/qtabbar.h>
+#include <QtWidgets/qtabwidget.h>
+#include <QtWidgets/qrubberband.h>
+#include <QtWidgets/qframe.h>
+#ifndef QT_NO_ITEMVIEWS
+# include <QtCore/qabstractitemmodel.h>
+#endif
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QDebug;
+
+class Q_GUI_EXPORT QStyleOption
+{
+public:
+ enum OptionType {
+ SO_Default, SO_FocusRect, SO_Button, SO_Tab, SO_MenuItem,
+ SO_Frame, SO_ProgressBar, SO_ToolBox, SO_Header, SO_Q3DockWindow,
+ SO_DockWidget, SO_Q3ListViewItem, SO_ViewItem, SO_TabWidgetFrame,
+ SO_TabBarBase, SO_RubberBand, SO_ToolBar, SO_GraphicsItem,
+
+ SO_Complex = 0xf0000, SO_Slider, SO_SpinBox, SO_ToolButton, SO_ComboBox,
+ SO_Q3ListView, SO_TitleBar, SO_GroupBox, SO_SizeGrip,
+
+ SO_CustomBase = 0xf00,
+ SO_ComplexCustomBase = 0xf000000
+ };
+
+ enum StyleOptionType { Type = SO_Default };
+ enum StyleOptionVersion { Version = 1 };
+
+ int version;
+ int type;
+ QStyle::State state;
+ Qt::LayoutDirection direction;
+ QRect rect;
+ QFontMetrics fontMetrics;
+ QPalette palette;
+
+ QStyleOption(int version = QStyleOption::Version, int type = SO_Default);
+ QStyleOption(const QStyleOption &other);
+ ~QStyleOption();
+
+ void init(const QWidget *w);
+ inline void initFrom(const QWidget *w) { init(w); }
+ QStyleOption &operator=(const QStyleOption &other);
+};
+
+class Q_GUI_EXPORT QStyleOptionFocusRect : public QStyleOption
+{
+public:
+ enum StyleOptionType { Type = SO_FocusRect };
+ enum StyleOptionVersion { Version = 1 };
+
+ QColor backgroundColor;
+
+ QStyleOptionFocusRect();
+ QStyleOptionFocusRect(const QStyleOptionFocusRect &other) : QStyleOption(Version, Type) { *this = other; }
+
+protected:
+ QStyleOptionFocusRect(int version);
+};
+
+class Q_GUI_EXPORT QStyleOptionFrame : public QStyleOption
+{
+public:
+ enum StyleOptionType { Type = SO_Frame };
+ enum StyleOptionVersion { Version = 1 };
+
+ int lineWidth;
+ int midLineWidth;
+
+ QStyleOptionFrame();
+ QStyleOptionFrame(const QStyleOptionFrame &other) : QStyleOption(Version, Type) { *this = other; }
+
+protected:
+ QStyleOptionFrame(int version);
+};
+
+class Q_GUI_EXPORT QStyleOptionFrameV2 : public QStyleOptionFrame
+{
+public:
+ enum StyleOptionVersion { Version = 2 };
+ enum FrameFeature {
+ None = 0x00,
+ Flat = 0x01
+ };
+ Q_DECLARE_FLAGS(FrameFeatures, FrameFeature)
+ FrameFeatures features;
+
+ QStyleOptionFrameV2();
+ QStyleOptionFrameV2(const QStyleOptionFrameV2 &other) : QStyleOptionFrame(Version) { *this = other; }
+ QStyleOptionFrameV2(const QStyleOptionFrame &other);
+ QStyleOptionFrameV2 &operator=(const QStyleOptionFrame &other);
+
+protected:
+ QStyleOptionFrameV2(int version);
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionFrameV2::FrameFeatures)
+
+
+class Q_GUI_EXPORT QStyleOptionFrameV3 : public QStyleOptionFrameV2
+{
+public:
+ enum StyleOptionVersion { Version = 3 };
+ QFrame::Shape frameShape : 4;
+ uint unused : 28;
+
+ QStyleOptionFrameV3();
+ QStyleOptionFrameV3(const QStyleOptionFrameV3 &other) : QStyleOptionFrameV2(Version) { *this = other; }
+ QStyleOptionFrameV3(const QStyleOptionFrame &other);
+ QStyleOptionFrameV3 &operator=(const QStyleOptionFrame &other);
+
+protected:
+ QStyleOptionFrameV3(int version);
+};
+
+
+#ifndef QT_NO_TABWIDGET
+class Q_GUI_EXPORT QStyleOptionTabWidgetFrame : public QStyleOption
+{
+public:
+ enum StyleOptionType { Type = SO_TabWidgetFrame };
+ enum StyleOptionVersion { Version = 1 };
+
+ int lineWidth;
+ int midLineWidth;
+ QTabBar::Shape shape;
+ QSize tabBarSize;
+ QSize rightCornerWidgetSize;
+ QSize leftCornerWidgetSize;
+
+ QStyleOptionTabWidgetFrame();
+ inline QStyleOptionTabWidgetFrame(const QStyleOptionTabWidgetFrame &other)
+ : QStyleOption(Version, Type) { *this = other; }
+
+protected:
+ QStyleOptionTabWidgetFrame(int version);
+};
+
+class Q_GUI_EXPORT QStyleOptionTabWidgetFrameV2 : public QStyleOptionTabWidgetFrame
+{
+public:
+ enum StyleOptionVersion { Version = 2 };
+
+ QRect tabBarRect;
+ QRect selectedTabRect;
+
+ QStyleOptionTabWidgetFrameV2();
+ QStyleOptionTabWidgetFrameV2(const QStyleOptionTabWidgetFrameV2 &other) :
+ QStyleOptionTabWidgetFrame(Version) { *this = other; }
+ QStyleOptionTabWidgetFrameV2(const QStyleOptionTabWidgetFrame &other);
+ QStyleOptionTabWidgetFrameV2 &operator=(const QStyleOptionTabWidgetFrame &other);
+
+protected:
+ QStyleOptionTabWidgetFrameV2(int version);
+};
+
+#endif
+
+
+#ifndef QT_NO_TABBAR
+class Q_GUI_EXPORT QStyleOptionTabBarBase : public QStyleOption
+{
+public:
+ enum StyleOptionType { Type = SO_TabBarBase };
+ enum StyleOptionVersion { Version = 1 };
+
+ QTabBar::Shape shape;
+ QRect tabBarRect;
+ QRect selectedTabRect;
+
+ QStyleOptionTabBarBase();
+ QStyleOptionTabBarBase(const QStyleOptionTabBarBase &other) : QStyleOption(Version, Type) { *this = other; }
+
+protected:
+ QStyleOptionTabBarBase(int version);
+};
+
+class Q_GUI_EXPORT QStyleOptionTabBarBaseV2 : public QStyleOptionTabBarBase
+{
+public:
+ enum StyleOptionVersion { Version = 2 };
+ bool documentMode;
+ QStyleOptionTabBarBaseV2();
+ QStyleOptionTabBarBaseV2(const QStyleOptionTabBarBaseV2 &other) : QStyleOptionTabBarBase(Version) { *this = other; }
+ QStyleOptionTabBarBaseV2(const QStyleOptionTabBarBase &other);
+ QStyleOptionTabBarBaseV2 &operator=(const QStyleOptionTabBarBase &other);
+
+protected:
+ QStyleOptionTabBarBaseV2(int version);
+};
+
+#endif
+
+class Q_GUI_EXPORT QStyleOptionHeader : public QStyleOption
+{
+public:
+ enum StyleOptionType { Type = SO_Header };
+ enum StyleOptionVersion { Version = 1 };
+
+ enum SectionPosition { Beginning, Middle, End, OnlyOneSection };
+ enum SelectedPosition { NotAdjacent, NextIsSelected, PreviousIsSelected,
+ NextAndPreviousAreSelected };
+ enum SortIndicator { None, SortUp, SortDown };
+
+ int section;
+ QString text;
+ Qt::Alignment textAlignment;
+ QIcon icon;
+ Qt::Alignment iconAlignment;
+ SectionPosition position;
+ SelectedPosition selectedPosition;
+ SortIndicator sortIndicator;
+ Qt::Orientation orientation;
+
+ QStyleOptionHeader();
+ QStyleOptionHeader(const QStyleOptionHeader &other) : QStyleOption(Version, Type) { *this = other; }
+
+protected:
+ QStyleOptionHeader(int version);
+};
+
+class Q_GUI_EXPORT QStyleOptionButton : public QStyleOption
+{
+public:
+ enum StyleOptionType { Type = SO_Button };
+ enum StyleOptionVersion { Version = 1 };
+
+ enum ButtonFeature { None = 0x00, Flat = 0x01, HasMenu = 0x02, DefaultButton = 0x04,
+ AutoDefaultButton = 0x08, CommandLinkButton = 0x10 };
+ Q_DECLARE_FLAGS(ButtonFeatures, ButtonFeature)
+
+ ButtonFeatures features;
+ QString text;
+ QIcon icon;
+ QSize iconSize;
+
+ QStyleOptionButton();
+ QStyleOptionButton(const QStyleOptionButton &other) : QStyleOption(Version, Type) { *this = other; }
+
+protected:
+ QStyleOptionButton(int version);
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionButton::ButtonFeatures)
+
+#ifndef QT_NO_TABBAR
+class Q_GUI_EXPORT QStyleOptionTab : public QStyleOption
+{
+public:
+ enum StyleOptionType { Type = SO_Tab };
+ enum StyleOptionVersion { Version = 1 };
+
+ enum TabPosition { Beginning, Middle, End, OnlyOneTab };
+ enum SelectedPosition { NotAdjacent, NextIsSelected, PreviousIsSelected };
+ enum CornerWidget { NoCornerWidgets = 0x00, LeftCornerWidget = 0x01,
+ RightCornerWidget = 0x02 };
+ Q_DECLARE_FLAGS(CornerWidgets, CornerWidget)
+
+ QTabBar::Shape shape;
+ QString text;
+ QIcon icon;
+ int row;
+ TabPosition position;
+ SelectedPosition selectedPosition;
+ CornerWidgets cornerWidgets;
+
+ QStyleOptionTab();
+ QStyleOptionTab(const QStyleOptionTab &other) : QStyleOption(Version, Type) { *this = other; }
+
+protected:
+ QStyleOptionTab(int version);
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionTab::CornerWidgets)
+
+class Q_GUI_EXPORT QStyleOptionTabV2 : public QStyleOptionTab
+{
+public:
+ enum StyleOptionVersion { Version = 2 };
+ QSize iconSize;
+ QStyleOptionTabV2();
+ QStyleOptionTabV2(const QStyleOptionTabV2 &other) : QStyleOptionTab(Version) { *this = other; }
+ QStyleOptionTabV2(const QStyleOptionTab &other);
+ QStyleOptionTabV2 &operator=(const QStyleOptionTab &other);
+
+protected:
+ QStyleOptionTabV2(int version);
+};
+
+class Q_GUI_EXPORT QStyleOptionTabV3 : public QStyleOptionTabV2
+{
+public:
+ enum StyleOptionVersion { Version = 3 };
+ bool documentMode;
+ QSize leftButtonSize;
+ QSize rightButtonSize;
+ QStyleOptionTabV3();
+ QStyleOptionTabV3(const QStyleOptionTabV3 &other) : QStyleOptionTabV2(Version) { *this = other; }
+ QStyleOptionTabV3(const QStyleOptionTabV2 &other) : QStyleOptionTabV2(Version) { *this = other; }
+ QStyleOptionTabV3(const QStyleOptionTab &other);
+ QStyleOptionTabV3 &operator=(const QStyleOptionTab &other);
+
+protected:
+ QStyleOptionTabV3(int version);
+};
+
+#endif
+
+
+#ifndef QT_NO_TOOLBAR
+
+class Q_GUI_EXPORT QStyleOptionToolBar : public QStyleOption
+{
+public:
+ enum StyleOptionType { Type = SO_ToolBar };
+ enum StyleOptionVersion { Version = 1 };
+ enum ToolBarPosition { Beginning, Middle, End, OnlyOne };
+ enum ToolBarFeature { None = 0x0, Movable = 0x1 };
+ Q_DECLARE_FLAGS(ToolBarFeatures, ToolBarFeature)
+ ToolBarPosition positionOfLine; // The toolbar line position
+ ToolBarPosition positionWithinLine; // The position within a toolbar
+ Qt::ToolBarArea toolBarArea; // The toolbar docking area
+ ToolBarFeatures features;
+ int lineWidth;
+ int midLineWidth;
+ QStyleOptionToolBar();
+ QStyleOptionToolBar(const QStyleOptionToolBar &other) : QStyleOption(Version, Type) { *this = other; }
+
+protected:
+ QStyleOptionToolBar(int version);
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionToolBar::ToolBarFeatures)
+
+#endif
+
+
+
+class Q_GUI_EXPORT QStyleOptionProgressBar : public QStyleOption
+{
+public:
+ enum StyleOptionType { Type = SO_ProgressBar };
+ enum StyleOptionVersion { Version = 1 };
+
+ int minimum;
+ int maximum;
+ int progress;
+ QString text;
+ Qt::Alignment textAlignment;
+ bool textVisible;
+
+ QStyleOptionProgressBar();
+ QStyleOptionProgressBar(const QStyleOptionProgressBar &other) : QStyleOption(Version, Type) { *this = other; }
+
+protected:
+ QStyleOptionProgressBar(int version);
+};
+
+// Adds style info for vertical progress bars
+class Q_GUI_EXPORT QStyleOptionProgressBarV2 : public QStyleOptionProgressBar
+{
+public:
+ enum StyleOptionType { Type = SO_ProgressBar };
+ enum StyleOptionVersion { Version = 2 };
+ Qt::Orientation orientation;
+ bool invertedAppearance;
+ bool bottomToTop;
+
+ QStyleOptionProgressBarV2();
+ QStyleOptionProgressBarV2(const QStyleOptionProgressBar &other);
+ QStyleOptionProgressBarV2(const QStyleOptionProgressBarV2 &other);
+ QStyleOptionProgressBarV2 &operator=(const QStyleOptionProgressBar &other);
+
+protected:
+ QStyleOptionProgressBarV2(int version);
+};
+
+class Q_GUI_EXPORT QStyleOptionMenuItem : public QStyleOption
+{
+public:
+ enum StyleOptionType { Type = SO_MenuItem };
+ enum StyleOptionVersion { Version = 1 };
+
+ enum MenuItemType { Normal, DefaultItem, Separator, SubMenu, Scroller, TearOff, Margin,
+ EmptyArea };
+ enum CheckType { NotCheckable, Exclusive, NonExclusive };
+
+ MenuItemType menuItemType;
+ CheckType checkType;
+ bool checked;
+ bool menuHasCheckableItems;
+ QRect menuRect;
+ QString text;
+ QIcon icon;
+ int maxIconWidth;
+ int tabWidth;
+ QFont font;
+
+ QStyleOptionMenuItem();
+ QStyleOptionMenuItem(const QStyleOptionMenuItem &other) : QStyleOption(Version, Type) { *this = other; }
+
+protected:
+ QStyleOptionMenuItem(int version);
+};
+
+class Q_GUI_EXPORT QStyleOptionQ3ListViewItem : public QStyleOption
+{
+public:
+ enum StyleOptionType { Type = SO_Q3ListViewItem };
+ enum StyleOptionVersion { Version = 1 };
+
+ enum Q3ListViewItemFeature { None = 0x00, Expandable = 0x01, MultiLine = 0x02, Visible = 0x04,
+ ParentControl = 0x08 };
+ Q_DECLARE_FLAGS(Q3ListViewItemFeatures, Q3ListViewItemFeature)
+
+ Q3ListViewItemFeatures features;
+ int height;
+ int totalHeight;
+ int itemY;
+ int childCount;
+
+ QStyleOptionQ3ListViewItem();
+ QStyleOptionQ3ListViewItem(const QStyleOptionQ3ListViewItem &other) : QStyleOption(Version, Type) { *this = other; }
+
+protected:
+ QStyleOptionQ3ListViewItem(int version);
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionQ3ListViewItem::Q3ListViewItemFeatures)
+
+class Q_GUI_EXPORT QStyleOptionQ3DockWindow : public QStyleOption
+{
+public:
+ enum StyleOptionType { Type = SO_Q3DockWindow };
+ enum StyleOptionVersion { Version = 1 };
+
+ bool docked;
+ bool closeEnabled;
+
+ QStyleOptionQ3DockWindow();
+ QStyleOptionQ3DockWindow(const QStyleOptionQ3DockWindow &other) : QStyleOption(Version, Type) { *this = other; }
+
+protected:
+ QStyleOptionQ3DockWindow(int version);
+};
+
+class Q_GUI_EXPORT QStyleOptionDockWidget : public QStyleOption
+{
+public:
+ enum StyleOptionType { Type = SO_DockWidget };
+ enum StyleOptionVersion { Version = 1 };
+
+ QString title;
+ bool closable;
+ bool movable;
+ bool floatable;
+
+ QStyleOptionDockWidget();
+ QStyleOptionDockWidget(const QStyleOptionDockWidget &other) : QStyleOption(Version, Type) { *this = other; }
+
+protected:
+ QStyleOptionDockWidget(int version);
+};
+
+class Q_GUI_EXPORT QStyleOptionDockWidgetV2 : public QStyleOptionDockWidget
+{
+public:
+ enum StyleOptionVersion { Version = 2 };
+
+ bool verticalTitleBar;
+
+ QStyleOptionDockWidgetV2();
+ QStyleOptionDockWidgetV2(const QStyleOptionDockWidgetV2 &other)
+ : QStyleOptionDockWidget(Version) { *this = other; }
+ QStyleOptionDockWidgetV2(const QStyleOptionDockWidget &other);
+ QStyleOptionDockWidgetV2 &operator = (const QStyleOptionDockWidget &other);
+
+protected:
+ QStyleOptionDockWidgetV2(int version);
+};
+
+class Q_GUI_EXPORT QStyleOptionViewItem : public QStyleOption
+{
+public:
+ enum StyleOptionType { Type = SO_ViewItem };
+ enum StyleOptionVersion { Version = 1 };
+
+ enum Position { Left, Right, Top, Bottom };
+
+ Qt::Alignment displayAlignment;
+ Qt::Alignment decorationAlignment;
+ Qt::TextElideMode textElideMode;
+ Position decorationPosition;
+ QSize decorationSize;
+ QFont font;
+ bool showDecorationSelected;
+
+ QStyleOptionViewItem();
+ QStyleOptionViewItem(const QStyleOptionViewItem &other) : QStyleOption(Version, Type) { *this = other; }
+
+protected:
+ QStyleOptionViewItem(int version);
+};
+
+class Q_GUI_EXPORT QStyleOptionViewItemV2 : public QStyleOptionViewItem
+{
+public:
+ enum StyleOptionVersion { Version = 2 };
+
+ enum ViewItemFeature {
+ None = 0x00,
+ WrapText = 0x01,
+ Alternate = 0x02,
+ HasCheckIndicator = 0x04,
+ HasDisplay = 0x08,
+ HasDecoration = 0x10
+ };
+ Q_DECLARE_FLAGS(ViewItemFeatures, ViewItemFeature)
+
+ ViewItemFeatures features;
+
+ QStyleOptionViewItemV2();
+ QStyleOptionViewItemV2(const QStyleOptionViewItemV2 &other) : QStyleOptionViewItem(Version) { *this = other; }
+ QStyleOptionViewItemV2(const QStyleOptionViewItem &other);
+ QStyleOptionViewItemV2 &operator=(const QStyleOptionViewItem &other);
+
+protected:
+ QStyleOptionViewItemV2(int version);
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionViewItemV2::ViewItemFeatures)
+
+class Q_GUI_EXPORT QStyleOptionViewItemV3 : public QStyleOptionViewItemV2
+{
+public:
+ enum StyleOptionVersion { Version = 3 };
+
+ QLocale locale;
+ const QWidget *widget;
+
+ QStyleOptionViewItemV3();
+ QStyleOptionViewItemV3(const QStyleOptionViewItemV3 &other)
+ : QStyleOptionViewItemV2(Version) { *this = other; }
+ QStyleOptionViewItemV3(const QStyleOptionViewItem &other);
+ QStyleOptionViewItemV3 &operator = (const QStyleOptionViewItem &other);
+
+protected:
+ QStyleOptionViewItemV3(int version);
+};
+
+#ifndef QT_NO_ITEMVIEWS
+class Q_GUI_EXPORT QStyleOptionViewItemV4 : public QStyleOptionViewItemV3
+{
+public:
+ enum StyleOptionVersion { Version = 4 };
+ enum ViewItemPosition { Invalid, Beginning, Middle, End, OnlyOne };
+
+ QModelIndex index;
+ Qt::CheckState checkState;
+ QIcon icon;
+ QString text;
+ ViewItemPosition viewItemPosition;
+ QBrush backgroundBrush;
+
+ QStyleOptionViewItemV4();
+ QStyleOptionViewItemV4(const QStyleOptionViewItemV4 &other)
+ : QStyleOptionViewItemV3(Version) { *this = other; }
+ QStyleOptionViewItemV4(const QStyleOptionViewItem &other);
+ QStyleOptionViewItemV4 &operator = (const QStyleOptionViewItem &other);
+
+protected:
+ QStyleOptionViewItemV4(int version);
+};
+#endif
+
+class Q_GUI_EXPORT QStyleOptionToolBox : public QStyleOption
+{
+public:
+ enum StyleOptionType { Type = SO_ToolBox };
+ enum StyleOptionVersion { Version = 1 };
+
+ QString text;
+ QIcon icon;
+
+ QStyleOptionToolBox();
+ QStyleOptionToolBox(const QStyleOptionToolBox &other) : QStyleOption(Version, Type) { *this = other; }
+
+protected:
+ QStyleOptionToolBox(int version);
+};
+
+class Q_GUI_EXPORT QStyleOptionToolBoxV2 : public QStyleOptionToolBox
+{
+public:
+ enum StyleOptionVersion { Version = 2 };
+ enum TabPosition { Beginning, Middle, End, OnlyOneTab };
+ enum SelectedPosition { NotAdjacent, NextIsSelected, PreviousIsSelected };
+
+ TabPosition position;
+ SelectedPosition selectedPosition;
+
+ QStyleOptionToolBoxV2();
+ QStyleOptionToolBoxV2(const QStyleOptionToolBoxV2 &other) : QStyleOptionToolBox(Version) { *this = other; }
+ QStyleOptionToolBoxV2(const QStyleOptionToolBox &other);
+ QStyleOptionToolBoxV2 &operator=(const QStyleOptionToolBox &other);
+
+protected:
+ QStyleOptionToolBoxV2(int version);
+};
+
+#ifndef QT_NO_RUBBERBAND
+class Q_GUI_EXPORT QStyleOptionRubberBand : public QStyleOption
+{
+public:
+ enum StyleOptionType { Type = SO_RubberBand };
+ enum StyleOptionVersion { Version = 1 };
+
+ QRubberBand::Shape shape;
+ bool opaque;
+
+ QStyleOptionRubberBand();
+ QStyleOptionRubberBand(const QStyleOptionRubberBand &other) : QStyleOption(Version, Type) { *this = other; }
+
+protected:
+ QStyleOptionRubberBand(int version);
+};
+#endif // QT_NO_RUBBERBAND
+
+// -------------------------- Complex style options -------------------------------
+class Q_GUI_EXPORT QStyleOptionComplex : public QStyleOption
+{
+public:
+ enum StyleOptionType { Type = SO_Complex };
+ enum StyleOptionVersion { Version = 1 };
+
+ QStyle::SubControls subControls;
+ QStyle::SubControls activeSubControls;
+
+ QStyleOptionComplex(int version = QStyleOptionComplex::Version, int type = SO_Complex);
+ QStyleOptionComplex(const QStyleOptionComplex &other) : QStyleOption(Version, Type) { *this = other; }
+};
+
+#ifndef QT_NO_SLIDER
+class Q_GUI_EXPORT QStyleOptionSlider : public QStyleOptionComplex
+{
+public:
+ enum StyleOptionType { Type = SO_Slider };
+ enum StyleOptionVersion { Version = 1 };
+
+ Qt::Orientation orientation;
+ int minimum;
+ int maximum;
+ QSlider::TickPosition tickPosition;
+ int tickInterval;
+ bool upsideDown;
+ int sliderPosition;
+ int sliderValue;
+ int singleStep;
+ int pageStep;
+ qreal notchTarget;
+ bool dialWrapping;
+
+ QStyleOptionSlider();
+ QStyleOptionSlider(const QStyleOptionSlider &other) : QStyleOptionComplex(Version, Type) { *this = other; }
+
+protected:
+ QStyleOptionSlider(int version);
+};
+#endif // QT_NO_SLIDER
+
+#ifndef QT_NO_SPINBOX
+class Q_GUI_EXPORT QStyleOptionSpinBox : public QStyleOptionComplex
+{
+public:
+ enum StyleOptionType { Type = SO_SpinBox };
+ enum StyleOptionVersion { Version = 1 };
+
+ QAbstractSpinBox::ButtonSymbols buttonSymbols;
+ QAbstractSpinBox::StepEnabled stepEnabled;
+ bool frame;
+
+ QStyleOptionSpinBox();
+ QStyleOptionSpinBox(const QStyleOptionSpinBox &other) : QStyleOptionComplex(Version, Type) { *this = other; }
+
+protected:
+ QStyleOptionSpinBox(int version);
+};
+#endif // QT_NO_SPINBOX
+
+class Q_GUI_EXPORT QStyleOptionQ3ListView : public QStyleOptionComplex
+{
+public:
+ enum StyleOptionType { Type = SO_Q3ListView };
+ enum StyleOptionVersion { Version = 1 };
+
+ QList<QStyleOptionQ3ListViewItem> items;
+ QPalette viewportPalette;
+ QPalette::ColorRole viewportBGRole;
+ int sortColumn;
+ int itemMargin;
+ int treeStepSize;
+ bool rootIsDecorated;
+
+ QStyleOptionQ3ListView();
+ QStyleOptionQ3ListView(const QStyleOptionQ3ListView &other) : QStyleOptionComplex(Version, Type) { *this = other; }
+
+protected:
+ QStyleOptionQ3ListView(int version);
+};
+
+class Q_GUI_EXPORT QStyleOptionToolButton : public QStyleOptionComplex
+{
+public:
+ enum StyleOptionType { Type = SO_ToolButton };
+ enum StyleOptionVersion { Version = 1 };
+
+ enum ToolButtonFeature { None = 0x00, Arrow = 0x01, Menu = 0x04, MenuButtonPopup = Menu, PopupDelay = 0x08,
+ HasMenu = 0x10 };
+ Q_DECLARE_FLAGS(ToolButtonFeatures, ToolButtonFeature)
+
+ ToolButtonFeatures features;
+ QIcon icon;
+ QSize iconSize;
+ QString text;
+ Qt::ArrowType arrowType;
+ Qt::ToolButtonStyle toolButtonStyle;
+ QPoint pos;
+ QFont font;
+
+ QStyleOptionToolButton();
+ QStyleOptionToolButton(const QStyleOptionToolButton &other) : QStyleOptionComplex(Version, Type) { *this = other; }
+
+protected:
+ QStyleOptionToolButton(int version);
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QStyleOptionToolButton::ToolButtonFeatures)
+
+class Q_GUI_EXPORT QStyleOptionComboBox : public QStyleOptionComplex
+{
+public:
+ enum StyleOptionType { Type = SO_ComboBox };
+ enum StyleOptionVersion { Version = 1 };
+
+ bool editable;
+ QRect popupRect;
+ bool frame;
+ QString currentText;
+ QIcon currentIcon;
+ QSize iconSize;
+
+ QStyleOptionComboBox();
+ QStyleOptionComboBox(const QStyleOptionComboBox &other) : QStyleOptionComplex(Version, Type) { *this = other; }
+
+protected:
+ QStyleOptionComboBox(int version);
+};
+
+class Q_GUI_EXPORT QStyleOptionTitleBar : public QStyleOptionComplex
+{
+public:
+ enum StyleOptionType { Type = SO_TitleBar };
+ enum StyleOptionVersion { Version = 1 };
+
+ QString text;
+ QIcon icon;
+ int titleBarState;
+ Qt::WindowFlags titleBarFlags;
+
+ QStyleOptionTitleBar();
+ QStyleOptionTitleBar(const QStyleOptionTitleBar &other) : QStyleOptionComplex(Version, Type) { *this = other; }
+
+protected:
+ QStyleOptionTitleBar(int version);
+};
+
+class Q_GUI_EXPORT QStyleOptionGroupBox : public QStyleOptionComplex
+{
+public:
+ enum StyleOptionType { Type = SO_GroupBox };
+ enum StyleOptionVersion { Version = 1 };
+
+ QStyleOptionFrameV2::FrameFeatures features;
+ QString text;
+ Qt::Alignment textAlignment;
+ QColor textColor;
+ int lineWidth;
+ int midLineWidth;
+
+ QStyleOptionGroupBox();
+ QStyleOptionGroupBox(const QStyleOptionGroupBox &other) : QStyleOptionComplex(Version, Type) { *this = other; }
+protected:
+ QStyleOptionGroupBox(int version);
+};
+
+class Q_GUI_EXPORT QStyleOptionSizeGrip : public QStyleOptionComplex
+{
+public:
+ enum StyleOptionType { Type = SO_SizeGrip };
+ enum StyleOptionVersion { Version = 1 };
+
+ Qt::Corner corner;
+
+ QStyleOptionSizeGrip();
+ QStyleOptionSizeGrip(const QStyleOptionSizeGrip &other) : QStyleOptionComplex(Version, Type) { *this = other; }
+protected:
+ QStyleOptionSizeGrip(int version);
+};
+
+class Q_GUI_EXPORT QStyleOptionGraphicsItem : public QStyleOption
+{
+public:
+ enum StyleOptionType { Type = SO_GraphicsItem };
+ enum StyleOptionVersion { Version = 1 };
+
+ QRectF exposedRect;
+ QMatrix matrix;
+ qreal levelOfDetail;
+
+ QStyleOptionGraphicsItem();
+ QStyleOptionGraphicsItem(const QStyleOptionGraphicsItem &other) : QStyleOption(Version, Type) { *this = other; }
+ static qreal levelOfDetailFromTransform(const QTransform &worldTransform);
+protected:
+ QStyleOptionGraphicsItem(int version);
+};
+
+template <typename T>
+T qstyleoption_cast(const QStyleOption *opt)
+{
+ if (opt && opt->version >= static_cast<T>(0)->Version && (opt->type == static_cast<T>(0)->Type
+ || int(static_cast<T>(0)->Type) == QStyleOption::SO_Default
+ || (int(static_cast<T>(0)->Type) == QStyleOption::SO_Complex
+ && opt->type > QStyleOption::SO_Complex)))
+ return static_cast<T>(opt);
+ return 0;
+}
+
+template <typename T>
+T qstyleoption_cast(QStyleOption *opt)
+{
+ if (opt && opt->version >= static_cast<T>(0)->Version && (opt->type == static_cast<T>(0)->Type
+ || int(static_cast<T>(0)->Type) == QStyleOption::SO_Default
+ || (int(static_cast<T>(0)->Type) == QStyleOption::SO_Complex
+ && opt->type > QStyleOption::SO_Complex)))
+ return static_cast<T>(opt);
+ return 0;
+}
+
+// -------------------------- QStyleHintReturn -------------------------------
+class Q_GUI_EXPORT QStyleHintReturn {
+public:
+ enum HintReturnType {
+ SH_Default=0xf000, SH_Mask, SH_Variant
+ };
+
+ enum StyleOptionType { Type = SH_Default };
+ enum StyleOptionVersion { Version = 1 };
+
+ QStyleHintReturn(int version = QStyleOption::Version, int type = SH_Default);
+ ~QStyleHintReturn();
+
+ int version;
+ int type;
+};
+
+class Q_GUI_EXPORT QStyleHintReturnMask : public QStyleHintReturn {
+public:
+ enum StyleOptionType { Type = SH_Mask };
+ enum StyleOptionVersion { Version = 1 };
+
+ QStyleHintReturnMask();
+
+ QRegion region;
+};
+
+class Q_GUI_EXPORT QStyleHintReturnVariant : public QStyleHintReturn {
+public:
+ enum StyleOptionType { Type = SH_Variant };
+ enum StyleOptionVersion { Version = 1 };
+
+ QStyleHintReturnVariant();
+
+ QVariant variant;
+};
+
+template <typename T>
+T qstyleoption_cast(const QStyleHintReturn *hint)
+{
+ if (hint && hint->version <= static_cast<T>(0)->Version &&
+ (hint->type == static_cast<T>(0)->Type || int(static_cast<T>(0)->Type) == QStyleHintReturn::SH_Default))
+ return static_cast<T>(hint);
+ return 0;
+}
+
+template <typename T>
+T qstyleoption_cast(QStyleHintReturn *hint)
+{
+ if (hint && hint->version <= static_cast<T>(0)->Version &&
+ (hint->type == static_cast<T>(0)->Type || int(static_cast<T>(0)->Type) == QStyleHintReturn::SH_Default))
+ return static_cast<T>(hint);
+ return 0;
+}
+
+#if !defined(QT_NO_DEBUG_STREAM)
+Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType);
+Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QStyleOption &option);
+#endif
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QSTYLEOPTION_H
diff --git a/src/gui/painting/qstylepainter.cpp b/src/widgets/styles/qstylepainter.cpp
index c8f9d05315..c8f9d05315 100644
--- a/src/gui/painting/qstylepainter.cpp
+++ b/src/widgets/styles/qstylepainter.cpp
diff --git a/src/widgets/styles/qstylepainter.h b/src/widgets/styles/qstylepainter.h
new file mode 100644
index 0000000000..1a65ef0616
--- /dev/null
+++ b/src/widgets/styles/qstylepainter.h
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSTYLEPAINTER_H
+#define QSTYLEPAINTER_H
+
+#include <QtGui/qpainter.h>
+#include <QtWidgets/qstyle.h>
+#include <QtWidgets/qwidget.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QStylePainter : public QPainter
+{
+public:
+ inline QStylePainter() : QPainter(), widget(0), wstyle(0) {}
+ inline explicit QStylePainter(QWidget *w) { begin(w, w); }
+ inline QStylePainter(QPaintDevice *pd, QWidget *w) { begin(pd, w); }
+ inline bool begin(QWidget *w) { return begin(w, w); }
+ inline bool begin(QPaintDevice *pd, QWidget *w) {
+ Q_ASSERT_X(w, "QStylePainter::QStylePainter", "Widget must be non-zero");
+ widget = w;
+ wstyle = w->style();
+ return QPainter::begin(pd);
+ };
+ inline void drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption &opt);
+ inline void drawControl(QStyle::ControlElement ce, const QStyleOption &opt);
+ inline void drawComplexControl(QStyle::ComplexControl cc, const QStyleOptionComplex &opt);
+ inline void drawItemText(const QRect &r, int flags, const QPalette &pal, bool enabled,
+ const QString &text, QPalette::ColorRole textRole = QPalette::NoRole);
+ inline void drawItemPixmap(const QRect &r, int flags, const QPixmap &pixmap);
+ inline QStyle *style() const { return wstyle; }
+
+private:
+ QWidget *widget;
+ QStyle *wstyle;
+ Q_DISABLE_COPY(QStylePainter)
+};
+
+void QStylePainter::drawPrimitive(QStyle::PrimitiveElement pe, const QStyleOption &opt)
+{
+ wstyle->drawPrimitive(pe, &opt, this, widget);
+}
+
+void QStylePainter::drawControl(QStyle::ControlElement ce, const QStyleOption &opt)
+{
+ wstyle->drawControl(ce, &opt, this, widget);
+}
+
+void QStylePainter::drawComplexControl(QStyle::ComplexControl cc, const QStyleOptionComplex &opt)
+{
+ wstyle->drawComplexControl(cc, &opt, this, widget);
+}
+
+void QStylePainter::drawItemText(const QRect &r, int flags, const QPalette &pal, bool enabled,
+ const QString &text, QPalette::ColorRole textRole)
+{
+ wstyle->drawItemText(this, r, flags, pal, enabled, text, textRole);
+}
+
+void QStylePainter::drawItemPixmap(const QRect &r, int flags, const QPixmap &pixmap)
+{
+ wstyle->drawItemPixmap(this, r, flags, pixmap);
+}
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QSTYLEPAINTER_H
diff --git a/src/gui/styles/qstyleplugin.cpp b/src/widgets/styles/qstyleplugin.cpp
index f2143e307a..f2143e307a 100644
--- a/src/gui/styles/qstyleplugin.cpp
+++ b/src/widgets/styles/qstyleplugin.cpp
diff --git a/src/gui/styles/qstyleplugin.h b/src/widgets/styles/qstyleplugin.h
index 56d690f6ff..56d690f6ff 100644
--- a/src/gui/styles/qstyleplugin.h
+++ b/src/widgets/styles/qstyleplugin.h
diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp
new file mode 100644
index 0000000000..750b408bd9
--- /dev/null
+++ b/src/widgets/styles/qstylesheetstyle.cpp
@@ -0,0 +1,5900 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qglobal.h>
+
+#ifndef QT_NO_STYLE_STYLESHEET
+
+#include "qstylesheetstyle_p.h"
+#include "private/qcssutil_p.h"
+#include <qdebug.h>
+#include <qapplication.h>
+#include <qmenu.h>
+#include <qmenubar.h>
+#include <qpainter.h>
+#include <qstyleoption.h>
+#include <qlineedit.h>
+#include <qwindowsstyle.h>
+#include <qcombobox.h>
+#include <qwindowsstyle.h>
+#include <qplastiquestyle.h>
+#include "private/qcssparser_p.h"
+#include "private/qmath_p.h"
+#include <qabstractscrollarea.h>
+#include "private/qabstractscrollarea_p.h"
+#include <qtooltip.h>
+#include <qshareddata.h>
+#include <qradiobutton.h>
+#include <qtoolbutton.h>
+#include <qscrollbar.h>
+#include <qstring.h>
+#include <qfile.h>
+#include <qcheckbox.h>
+#include <qstatusbar.h>
+#include <qheaderview.h>
+#include <qprogressbar.h>
+#include <private/qwindowsstyle_p.h>
+#include <qtabbar.h>
+#include <QMetaProperty>
+#include <qmainwindow.h>
+#include <qdockwidget.h>
+#include <qmdisubwindow.h>
+#include <qdialog.h>
+#include <private/qwidget_p.h>
+#include <QAbstractSpinBox>
+#include <QLabel>
+#include "qdrawutil.h"
+
+#include <limits.h>
+#include <QtWidgets/qtoolbar.h>
+
+QT_BEGIN_NAMESPACE
+
+using namespace QCss;
+
+
+class QStyleSheetStylePrivate : public QWindowsStylePrivate
+{
+ Q_DECLARE_PUBLIC(QStyleSheetStyle)
+public:
+ QStyleSheetStylePrivate() { }
+};
+
+
+static QStyleSheetStyleCaches *styleSheetCaches = 0;
+
+/* RECURSION_GUARD:
+ * the QStyleSheetStyle is a proxy. If used with others proxy style, we may end up with something like:
+ * QStyleSheetStyle -> ProxyStyle -> QStyleSheetStyle -> OriginalStyle
+ * Recursion may happen if the style call the widget()->style() again.
+ * Not to mention the performence penalty of having two lookup of rules.
+ *
+ * The first instance of QStyleSheetStyle will set globalStyleSheetStyle to itself. The second one
+ * will notice the globalStyleSheetStyle is not istelf and call its base style directly.
+ */
+static const QStyleSheetStyle *globalStyleSheetStyle = 0;
+class QStyleSheetStyleRecursionGuard
+{
+ public:
+ QStyleSheetStyleRecursionGuard(const QStyleSheetStyle *that)
+ : guarded(globalStyleSheetStyle == 0)
+ {
+ if (guarded) globalStyleSheetStyle = that;
+ }
+ ~QStyleSheetStyleRecursionGuard() { if (guarded) globalStyleSheetStyle = 0; }
+ bool guarded;
+};
+#define RECURSION_GUARD(RETURN) \
+ if (globalStyleSheetStyle != 0 && globalStyleSheetStyle != this) { RETURN; } \
+ QStyleSheetStyleRecursionGuard recursion_guard(this);
+
+#define ceil(x) ((int)(x) + ((x) > 0 && (x) != (int)(x)))
+
+enum PseudoElement {
+ PseudoElement_None,
+ PseudoElement_DownArrow,
+ PseudoElement_UpArrow,
+ PseudoElement_LeftArrow,
+ PseudoElement_RightArrow,
+ PseudoElement_Indicator,
+ PseudoElement_ExclusiveIndicator,
+ PseudoElement_PushButtonMenuIndicator,
+ PseudoElement_ComboBoxDropDown,
+ PseudoElement_ComboBoxArrow,
+ PseudoElement_Item,
+ PseudoElement_SpinBoxUpButton,
+ PseudoElement_SpinBoxUpArrow,
+ PseudoElement_SpinBoxDownButton,
+ PseudoElement_SpinBoxDownArrow,
+ PseudoElement_GroupBoxTitle,
+ PseudoElement_GroupBoxIndicator,
+ PseudoElement_ToolButtonMenu,
+ PseudoElement_ToolButtonMenuArrow,
+ PseudoElement_ToolButtonDownArrow,
+ PseudoElement_ToolBoxTab,
+ PseudoElement_ScrollBarSlider,
+ PseudoElement_ScrollBarAddPage,
+ PseudoElement_ScrollBarSubPage,
+ PseudoElement_ScrollBarAddLine,
+ PseudoElement_ScrollBarSubLine,
+ PseudoElement_ScrollBarFirst,
+ PseudoElement_ScrollBarLast,
+ PseudoElement_ScrollBarUpArrow,
+ PseudoElement_ScrollBarDownArrow,
+ PseudoElement_ScrollBarLeftArrow,
+ PseudoElement_ScrollBarRightArrow,
+ PseudoElement_SplitterHandle,
+ PseudoElement_ToolBarHandle,
+ PseudoElement_ToolBarSeparator,
+ PseudoElement_MenuScroller,
+ PseudoElement_MenuTearoff,
+ PseudoElement_MenuCheckMark,
+ PseudoElement_MenuSeparator,
+ PseudoElement_MenuIcon,
+ PseudoElement_MenuRightArrow,
+ PseudoElement_TreeViewBranch,
+ PseudoElement_HeaderViewSection,
+ PseudoElement_HeaderViewUpArrow,
+ PseudoElement_HeaderViewDownArrow,
+ PseudoElement_ProgressBarChunk,
+ PseudoElement_TabBarTab,
+ PseudoElement_TabBarScroller,
+ PseudoElement_TabBarTear,
+ PseudoElement_SliderGroove,
+ PseudoElement_SliderHandle,
+ PseudoElement_SliderAddPage,
+ PseudoElement_SliderSubPage,
+ PseudoElement_SliderTickmark,
+ PseudoElement_TabWidgetPane,
+ PseudoElement_TabWidgetTabBar,
+ PseudoElement_TabWidgetLeftCorner,
+ PseudoElement_TabWidgetRightCorner,
+ PseudoElement_DockWidgetTitle,
+ PseudoElement_DockWidgetCloseButton,
+ PseudoElement_DockWidgetFloatButton,
+ PseudoElement_DockWidgetSeparator,
+ PseudoElement_MdiCloseButton,
+ PseudoElement_MdiMinButton,
+ PseudoElement_MdiNormalButton,
+ PseudoElement_TitleBar,
+ PseudoElement_TitleBarCloseButton,
+ PseudoElement_TitleBarMinButton,
+ PseudoElement_TitleBarMaxButton,
+ PseudoElement_TitleBarShadeButton,
+ PseudoElement_TitleBarUnshadeButton,
+ PseudoElement_TitleBarNormalButton,
+ PseudoElement_TitleBarContextHelpButton,
+ PseudoElement_TitleBarSysMenu,
+ PseudoElement_ViewItem,
+ PseudoElement_ViewItemIcon,
+ PseudoElement_ViewItemText,
+ PseudoElement_ViewItemIndicator,
+ PseudoElement_ScrollAreaCorner,
+ PseudoElement_TabBarTabCloseButton,
+ NumPseudoElements
+};
+
+struct PseudoElementInfo {
+ QStyle::SubControl subControl;
+ const char *name;
+};
+
+static const PseudoElementInfo knownPseudoElements[NumPseudoElements] = {
+ { QStyle::SC_None, "" },
+ { QStyle::SC_None, "down-arrow" },
+ { QStyle::SC_None, "up-arrow" },
+ { QStyle::SC_None, "left-arrow" },
+ { QStyle::SC_None, "right-arrow" },
+ { QStyle::SC_None, "indicator" },
+ { QStyle::SC_None, "indicator" },
+ { QStyle::SC_None, "menu-indicator" },
+ { QStyle::SC_ComboBoxArrow, "drop-down" },
+ { QStyle::SC_ComboBoxArrow, "down-arrow" },
+ { QStyle::SC_None, "item" },
+ { QStyle::SC_SpinBoxUp, "up-button" },
+ { QStyle::SC_SpinBoxUp, "up-arrow" },
+ { QStyle::SC_SpinBoxDown, "down-button" },
+ { QStyle::SC_SpinBoxDown, "down-arrow" },
+ { QStyle::SC_GroupBoxLabel, "title" },
+ { QStyle::SC_GroupBoxCheckBox, "indicator" },
+ { QStyle::SC_ToolButtonMenu, "menu-button" },
+ { QStyle::SC_ToolButtonMenu, "menu-arrow" },
+ { QStyle::SC_None, "menu-indicator" },
+ { QStyle::SC_None, "tab" },
+ { QStyle::SC_ScrollBarSlider, "handle" },
+ { QStyle::SC_ScrollBarAddPage, "add-page" },
+ { QStyle::SC_ScrollBarSubPage, "sub-page" },
+ { QStyle::SC_ScrollBarAddLine, "add-line" },
+ { QStyle::SC_ScrollBarSubLine, "sub-line" },
+ { QStyle::SC_ScrollBarFirst, "first" },
+ { QStyle::SC_ScrollBarLast, "last" },
+ { QStyle::SC_ScrollBarSubLine, "up-arrow" },
+ { QStyle::SC_ScrollBarAddLine, "down-arrow" },
+ { QStyle::SC_ScrollBarSubLine, "left-arrow" },
+ { QStyle::SC_ScrollBarAddLine, "right-arrow" },
+ { QStyle::SC_None, "handle" },
+ { QStyle::SC_None, "handle" },
+ { QStyle::SC_None, "separator" },
+ { QStyle::SC_None, "scroller" },
+ { QStyle::SC_None, "tearoff" },
+ { QStyle::SC_None, "indicator" },
+ { QStyle::SC_None, "separator" },
+ { QStyle::SC_None, "icon" },
+ { QStyle::SC_None, "right-arrow" },
+ { QStyle::SC_None, "branch" },
+ { QStyle::SC_None, "section" },
+ { QStyle::SC_None, "down-arrow" },
+ { QStyle::SC_None, "up-arrow" },
+ { QStyle::SC_None, "chunk" },
+ { QStyle::SC_None, "tab" },
+ { QStyle::SC_None, "scroller" },
+ { QStyle::SC_None, "tear" },
+ { QStyle::SC_SliderGroove, "groove" },
+ { QStyle::SC_SliderHandle, "handle" },
+ { QStyle::SC_None, "add-page" },
+ { QStyle::SC_None, "sub-page"},
+ { QStyle::SC_SliderTickmarks, "tick-mark" },
+ { QStyle::SC_None, "pane" },
+ { QStyle::SC_None, "tab-bar" },
+ { QStyle::SC_None, "left-corner" },
+ { QStyle::SC_None, "right-corner" },
+ { QStyle::SC_None, "title" },
+ { QStyle::SC_None, "close-button" },
+ { QStyle::SC_None, "float-button" },
+ { QStyle::SC_None, "separator" },
+ { QStyle::SC_MdiCloseButton, "close-button" },
+ { QStyle::SC_MdiMinButton, "minimize-button" },
+ { QStyle::SC_MdiNormalButton, "normal-button" },
+ { QStyle::SC_TitleBarLabel, "title" },
+ { QStyle::SC_TitleBarCloseButton, "close-button" },
+ { QStyle::SC_TitleBarMinButton, "minimize-button" },
+ { QStyle::SC_TitleBarMaxButton, "maximize-button" },
+ { QStyle::SC_TitleBarShadeButton, "shade-button" },
+ { QStyle::SC_TitleBarUnshadeButton, "unshade-button" },
+ { QStyle::SC_TitleBarNormalButton, "normal-button" },
+ { QStyle::SC_TitleBarContextHelpButton, "contexthelp-button" },
+ { QStyle::SC_TitleBarSysMenu, "sys-menu" },
+ { QStyle::SC_None, "item" },
+ { QStyle::SC_None, "icon" },
+ { QStyle::SC_None, "text" },
+ { QStyle::SC_None, "indicator" },
+ { QStyle::SC_None, "corner" },
+ { QStyle::SC_None, "close-button" },
+};
+
+
+struct QStyleSheetBorderImageData : public QSharedData
+{
+ QStyleSheetBorderImageData()
+ : horizStretch(QCss::TileMode_Unknown), vertStretch(QCss::TileMode_Unknown)
+ {
+ for (int i = 0; i < 4; i++)
+ cuts[i] = -1;
+ }
+ int cuts[4];
+ QPixmap pixmap;
+ QImage image;
+ QCss::TileMode horizStretch, vertStretch;
+};
+
+struct QStyleSheetBackgroundData : public QSharedData
+{
+ QStyleSheetBackgroundData(const QBrush& b, const QPixmap& p, QCss::Repeat r,
+ Qt::Alignment a, QCss::Origin o, Attachment t, QCss::Origin c)
+ : brush(b), pixmap(p), repeat(r), position(a), origin(o), attachment(t), clip(c) { }
+
+ bool isTransparent() const {
+ if (brush.style() != Qt::NoBrush)
+ return !brush.isOpaque();
+ return pixmap.isNull() ? false : pixmap.hasAlpha();
+ }
+ QBrush brush;
+ QPixmap pixmap;
+ QCss::Repeat repeat;
+ Qt::Alignment position;
+ QCss::Origin origin;
+ QCss::Attachment attachment;
+ QCss::Origin clip;
+};
+
+struct QStyleSheetBorderData : public QSharedData
+{
+ QStyleSheetBorderData() : bi(0)
+ {
+ for (int i = 0; i < 4; i++) {
+ borders[i] = 0;
+ styles[i] = QCss::BorderStyle_None;
+ }
+ }
+
+ QStyleSheetBorderData(int *b, QBrush *c, QCss::BorderStyle *s, QSize *r) : bi(0)
+ {
+ for (int i = 0; i < 4; i++) {
+ borders[i] = b[i];
+ styles[i] = s[i];
+ colors[i] = c[i];
+ radii[i] = r[i];
+ }
+ }
+
+ int borders[4];
+ QBrush colors[4];
+ QCss::BorderStyle styles[4];
+ QSize radii[4]; // topleft, topright, bottomleft, bottomright
+
+ const QStyleSheetBorderImageData *borderImage() const
+ { return bi; }
+ bool hasBorderImage() const { return bi!=0; }
+
+ QSharedDataPointer<QStyleSheetBorderImageData> bi;
+
+ bool isOpaque() const
+ {
+ for (int i = 0; i < 4; i++) {
+ if (styles[i] == QCss::BorderStyle_Native || styles[i] == QCss::BorderStyle_None)
+ continue;
+ if (styles[i] >= QCss::BorderStyle_Dotted && styles[i] <= QCss::BorderStyle_DotDotDash
+ && styles[i] != BorderStyle_Solid)
+ return false;
+ if (!colors[i].isOpaque())
+ return false;
+ if (!radii[i].isEmpty())
+ return false;
+ }
+ if (bi != 0 && bi->pixmap.hasAlpha())
+ return false;
+ return true;
+ }
+};
+
+
+struct QStyleSheetOutlineData : public QStyleSheetBorderData
+{
+ QStyleSheetOutlineData()
+ {
+ for (int i = 0; i < 4; i++) {
+ offsets[i] = 0;
+ }
+ }
+
+ QStyleSheetOutlineData(int *b, QBrush *c, QCss::BorderStyle *s, QSize *r, int *o)
+ : QStyleSheetBorderData(b, c, s, r)
+ {
+ for (int i = 0; i < 4; i++) {
+ offsets[i] = o[i];
+ }
+ }
+
+ int offsets[4];
+};
+
+struct QStyleSheetBoxData : public QSharedData
+{
+ QStyleSheetBoxData(int *m, int *p, int s) : spacing(s)
+ {
+ for (int i = 0; i < 4; i++) {
+ margins[i] = m[i];
+ paddings[i] = p[i];
+ }
+ }
+
+ int margins[4];
+ int paddings[4];
+
+ int spacing;
+};
+
+struct QStyleSheetPaletteData : public QSharedData
+{
+ QStyleSheetPaletteData(const QBrush &fg, const QBrush &sfg, const QBrush &sbg,
+ const QBrush &abg)
+ : foreground(fg), selectionForeground(sfg), selectionBackground(sbg),
+ alternateBackground(abg) { }
+
+ QBrush foreground;
+ QBrush selectionForeground;
+ QBrush selectionBackground;
+ QBrush alternateBackground;
+};
+
+struct QStyleSheetGeometryData : public QSharedData
+{
+ QStyleSheetGeometryData(int w, int h, int minw, int minh, int maxw, int maxh)
+ : minWidth(minw), minHeight(minh), width(w), height(h), maxWidth(maxw), maxHeight(maxh) { }
+
+ int minWidth, minHeight, width, height, maxWidth, maxHeight;
+};
+
+struct QStyleSheetPositionData : public QSharedData
+{
+ QStyleSheetPositionData(int l, int t, int r, int b, Origin o, Qt::Alignment p, QCss::PositionMode m, Qt::Alignment a = 0)
+ : left(l), top(t), bottom(b), right(r), origin(o), position(p), mode(m), textAlignment(a) { }
+
+ int left, top, bottom, right;
+ Origin origin;
+ Qt::Alignment position;
+ QCss::PositionMode mode;
+ Qt::Alignment textAlignment;
+};
+
+struct QStyleSheetImageData : public QSharedData
+{
+ QStyleSheetImageData(const QIcon &i, Qt::Alignment a, const QSize &sz)
+ : icon(i), alignment(a), size(sz) { }
+
+ QIcon icon;
+ Qt::Alignment alignment;
+ QSize size;
+};
+
+class QRenderRule
+{
+public:
+ QRenderRule() : features(0), hasFont(false), pal(0), b(0), bg(0), bd(0), ou(0), geo(0), p(0), img(0), clipset(0) { }
+ QRenderRule(const QVector<QCss::Declaration> &, const QWidget *);
+ ~QRenderRule() { }
+
+ QRect borderRect(const QRect &r) const;
+ QRect outlineRect(const QRect &r) const;
+ QRect paddingRect(const QRect &r) const;
+ QRect contentsRect(const QRect &r) const;
+
+ enum { Margin = 1, Border = 2, Padding = 4, All=Margin|Border|Padding };
+ QRect boxRect(const QRect &r, int flags = All) const;
+ QSize boxSize(const QSize &s, int flags = All) const;
+ QRect originRect(const QRect &rect, Origin origin) const;
+
+ QPainterPath borderClip(QRect rect);
+ void drawBorder(QPainter *, const QRect&);
+ void drawOutline(QPainter *, const QRect&);
+ void drawBorderImage(QPainter *, const QRect&);
+ void drawBackground(QPainter *, const QRect&, const QPoint& = QPoint(0, 0));
+ void drawBackgroundImage(QPainter *, const QRect&, QPoint = QPoint(0, 0));
+ void drawFrame(QPainter *, const QRect&);
+ void drawImage(QPainter *p, const QRect &rect);
+ void drawRule(QPainter *, const QRect&);
+ void configurePalette(QPalette *, QPalette::ColorGroup, const QWidget *, bool);
+ void configurePalette(QPalette *p, QPalette::ColorRole fr, QPalette::ColorRole br);
+
+ const QStyleSheetPaletteData *palette() const { return pal; }
+ const QStyleSheetBoxData *box() const { return b; }
+ const QStyleSheetBackgroundData *background() const { return bg; }
+ const QStyleSheetBorderData *border() const { return bd; }
+ const QStyleSheetOutlineData *outline() const { return ou; }
+ const QStyleSheetGeometryData *geometry() const { return geo; }
+ const QStyleSheetPositionData *position() const { return p; }
+
+ bool hasPalette() const { return pal != 0; }
+ bool hasBackground() const { return bg != 0 && (!bg->pixmap.isNull() || bg->brush.style() != Qt::NoBrush); }
+ bool hasGradientBackground() const { return bg && bg->brush.style() >= Qt::LinearGradientPattern
+ && bg->brush.style() <= Qt::ConicalGradientPattern; }
+
+ bool hasNativeBorder() const {
+ return bd == 0
+ || (!bd->hasBorderImage() && bd->styles[0] == BorderStyle_Native);
+ }
+
+ bool hasNativeOutline() const {
+ return (ou == 0
+ || (!ou->hasBorderImage() && ou->styles[0] == BorderStyle_Native));
+ }
+
+ bool baseStyleCanDraw() const {
+ if (!hasBackground() || (background()->brush.style() == Qt::NoBrush && bg->pixmap.isNull()))
+ return true;
+ if (bg && !bg->pixmap.isNull())
+ return false;
+ if (hasGradientBackground())
+ return features & StyleFeature_BackgroundGradient;
+ return features & StyleFeature_BackgroundColor;
+ }
+
+ bool hasBox() const { return b != 0; }
+ bool hasBorder() const { return bd != 0; }
+ bool hasOutline() const { return ou != 0; }
+ bool hasPosition() const { return p != 0; }
+ bool hasGeometry() const { return geo != 0; }
+ bool hasDrawable() const { return !hasNativeBorder() || hasBackground() || hasImage(); }
+ bool hasImage() const { return img != 0; }
+
+ QSize minimumContentsSize() const
+ { return geo ? QSize(geo->minWidth, geo->minHeight) : QSize(0, 0); }
+ QSize minimumSize() const
+ { return boxSize(minimumContentsSize()); }
+
+ QSize contentsSize() const
+ { return geo ? QSize(geo->width, geo->height)
+ : ((img && img->size.isValid()) ? img->size : QSize()); }
+ QSize contentsSize(const QSize &sz) const
+ {
+ QSize csz = contentsSize();
+ if (csz.width() == -1) csz.setWidth(sz.width());
+ if (csz.height() == -1) csz.setHeight(sz.height());
+ return csz;
+ }
+ bool hasContentsSize() const
+ { return (geo && (geo->width != -1 || geo->height != -1)) || (img && img->size.isValid()); }
+
+ QSize size() const { return boxSize(contentsSize()); }
+ QSize size(const QSize &sz) const { return boxSize(contentsSize(sz)); }
+ QSize adjustSize(const QSize &sz)
+ {
+ if (!geo)
+ return sz;
+ QSize csz = contentsSize();
+ if (csz.width() == -1) csz.setWidth(sz.width());
+ if (csz.height() == -1) csz.setHeight(sz.height());
+ if (geo->maxWidth != -1 && csz.width() > geo->maxWidth) csz.setWidth(geo->maxWidth);
+ if (geo->maxHeight != -1 && csz.height() > geo->maxHeight) csz.setHeight(geo->maxHeight);
+ csz=csz.expandedTo(QSize(geo->minWidth, geo->minHeight));
+ return csz;
+ }
+
+ int features;
+ QBrush defaultBackground;
+ QFont font;
+ bool hasFont;
+
+ QHash<QString, QVariant> styleHints;
+ bool hasStyleHint(const QString& sh) const { return styleHints.contains(sh); }
+ QVariant styleHint(const QString& sh) const { return styleHints.value(sh); }
+
+ void fixupBorder(int);
+
+ QSharedDataPointer<QStyleSheetPaletteData> pal;
+ QSharedDataPointer<QStyleSheetBoxData> b;
+ QSharedDataPointer<QStyleSheetBackgroundData> bg;
+ QSharedDataPointer<QStyleSheetBorderData> bd;
+ QSharedDataPointer<QStyleSheetOutlineData> ou;
+ QSharedDataPointer<QStyleSheetGeometryData> geo;
+ QSharedDataPointer<QStyleSheetPositionData> p;
+ QSharedDataPointer<QStyleSheetImageData> img;
+
+ // Shouldn't be here
+ void setClip(QPainter *p, const QRect &rect);
+ void unsetClip(QPainter *);
+ int clipset;
+ QPainterPath clipPath;
+};
+
+///////////////////////////////////////////////////////////////////////////////////////////
+static const char *knownStyleHints[] = {
+ "activate-on-singleclick",
+ "alignment",
+ "arrow-keys-navigate-into-children",
+ "backward-icon",
+ "button-layout",
+ "cd-icon",
+ "combobox-list-mousetracking",
+ "combobox-popup",
+ "computer-icon",
+ "desktop-icon",
+ "dialog-apply-icon",
+ "dialog-cancel-icon",
+ "dialog-close-icon",
+ "dialog-discard-icon",
+ "dialog-help-icon",
+ "dialog-no-icon",
+ "dialog-ok-icon",
+ "dialog-open-icon",
+ "dialog-reset-icon",
+ "dialog-save-icon",
+ "dialog-yes-icon",
+ "dialogbuttonbox-buttons-have-icons",
+ "directory-closed-icon",
+ "directory-icon",
+ "directory-link-icon",
+ "directory-open-icon",
+ "dither-disable-text",
+ "dockwidget-close-icon",
+ "downarrow-icon",
+ "dvd-icon",
+ "etch-disabled-text",
+ "file-icon",
+ "file-link-icon",
+ "filedialog-backward-icon", // unused
+ "filedialog-contentsview-icon",
+ "filedialog-detailedview-icon",
+ "filedialog-end-icon",
+ "filedialog-infoview-icon",
+ "filedialog-listview-icon",
+ "filedialog-new-directory-icon",
+ "filedialog-parent-directory-icon",
+ "filedialog-start-icon",
+ "floppy-icon",
+ "forward-icon",
+ "gridline-color",
+ "harddisk-icon",
+ "home-icon",
+ "icon-size",
+ "leftarrow-icon",
+ "lineedit-password-character",
+ "mdi-fill-space-on-maximize",
+ "menu-scrollable",
+ "menubar-altkey-navigation",
+ "menubar-separator",
+ "messagebox-critical-icon",
+ "messagebox-information-icon",
+ "messagebox-question-icon",
+ "messagebox-text-interaction-flags",
+ "messagebox-warning-icon",
+ "mouse-tracking",
+ "network-icon",
+ "opacity",
+ "paint-alternating-row-colors-for-empty-area",
+ "rightarrow-icon",
+ "scrollbar-contextmenu",
+ "scrollbar-leftclick-absolute-position",
+ "scrollbar-middleclick-absolute-position",
+ "scrollbar-roll-between-buttons",
+ "scrollbar-scroll-when-pointer-leaves-control",
+ "scrollview-frame-around-contents",
+ "show-decoration-selected",
+ "spinbox-click-autorepeat-rate",
+ "spincontrol-disable-on-bounds",
+ "tabbar-elide-mode",
+ "tabbar-prefer-no-arrows",
+ "titlebar-close-icon",
+ "titlebar-contexthelp-icon",
+ "titlebar-maximize-icon",
+ "titlebar-menu-icon",
+ "titlebar-minimize-icon",
+ "titlebar-normal-icon",
+ "titlebar-shade-icon",
+ "titlebar-unshade-icon",
+ "toolbutton-popup-delay",
+ "trash-icon",
+ "uparrow-icon"
+};
+
+static const int numKnownStyleHints = sizeof(knownStyleHints)/sizeof(knownStyleHints[0]);
+
+static QList<QVariant> subControlLayout(const QString& layout)
+{
+ QList<QVariant> buttons;
+ for (int i = 0; i < layout.count(); i++) {
+ int button = layout[i].toAscii();
+ switch (button) {
+ case 'm':
+ buttons.append(PseudoElement_MdiMinButton);
+ buttons.append(PseudoElement_TitleBarMinButton);
+ break;
+ case 'M':
+ buttons.append(PseudoElement_TitleBarMaxButton);
+ break;
+ case 'X':
+ buttons.append(PseudoElement_MdiCloseButton);
+ buttons.append(PseudoElement_TitleBarCloseButton);
+ break;
+ case 'N':
+ buttons.append(PseudoElement_MdiNormalButton);
+ buttons.append(PseudoElement_TitleBarNormalButton);
+ break;
+ case 'I':
+ buttons.append(PseudoElement_TitleBarSysMenu);
+ break;
+ case 'T':
+ buttons.append(PseudoElement_TitleBar);
+ break;
+ case 'H':
+ buttons.append(PseudoElement_TitleBarContextHelpButton);
+ break;
+ case 'S':
+ buttons.append(PseudoElement_TitleBarShadeButton);
+ break;
+ default:
+ buttons.append(button);
+ break;
+ }
+ }
+ return buttons;
+}
+
+namespace {
+ struct ButtonInfo {
+ QRenderRule rule;
+ int element;
+ int offset;
+ int where;
+ int width;
+ };
+}
+
+QHash<QStyle::SubControl, QRect> QStyleSheetStyle::titleBarLayout(const QWidget *w, const QStyleOptionTitleBar *tb) const
+{
+ QHash<QStyle::SubControl, QRect> layoutRects;
+ const bool isMinimized = tb->titleBarState & Qt::WindowMinimized;
+ const bool isMaximized = tb->titleBarState & Qt::WindowMaximized;
+ QRenderRule subRule = renderRule(w, tb);
+ QRect cr = subRule.contentsRect(tb->rect);
+ QList<QVariant> layout = subRule.styleHint(QLatin1String("button-layout")).toList();
+ if (layout.isEmpty())
+ layout = subControlLayout(QLatin1String("I(T)HSmMX"));
+
+ int offsets[3] = { 0, 0, 0 };
+ enum Where { Left, Right, Center, NoWhere } where = Left;
+ QList<ButtonInfo> infos;
+ for (int i = 0; i < layout.count(); i++) {
+ ButtonInfo info;
+ info.element = layout[i].toInt();
+ if (info.element == '(') {
+ where = Center;
+ } else if (info.element == ')') {
+ where = Right;
+ } else {
+ switch (info.element) {
+ case PseudoElement_TitleBar:
+ if (!(tb->titleBarFlags & (Qt::WindowTitleHint | Qt::WindowSystemMenuHint)))
+ continue;
+ break;
+ case PseudoElement_TitleBarContextHelpButton:
+ if (!(tb->titleBarFlags & Qt::WindowContextHelpButtonHint))
+ continue;
+ break;
+ case PseudoElement_TitleBarMinButton:
+ if (!(tb->titleBarFlags & Qt::WindowMinimizeButtonHint))
+ continue;
+ if (isMinimized)
+ info.element = PseudoElement_TitleBarNormalButton;
+ break;
+ case PseudoElement_TitleBarMaxButton:
+ if (!(tb->titleBarFlags & Qt::WindowMaximizeButtonHint))
+ continue;
+ if (isMaximized)
+ info.element = PseudoElement_TitleBarNormalButton;
+ break;
+ case PseudoElement_TitleBarShadeButton:
+ if (!(tb->titleBarFlags & Qt::WindowShadeButtonHint))
+ continue;
+ if (isMinimized)
+ info.element = PseudoElement_TitleBarUnshadeButton;
+ break;
+ case PseudoElement_TitleBarCloseButton:
+ case PseudoElement_TitleBarSysMenu:
+ if (!(tb->titleBarFlags & Qt::WindowSystemMenuHint))
+ continue;
+ break;
+ default:
+ continue;
+ }
+ if (info.element == PseudoElement_TitleBar) {
+ info.width = tb->fontMetrics.width(tb->text) + 6;
+ subRule.geo = new QStyleSheetGeometryData(info.width, tb->fontMetrics.height(), -1, -1, -1, -1);
+ } else {
+ subRule = renderRule(w, tb, info.element);
+ info.width = subRule.size().width();
+ }
+ info.rule = subRule;
+ info.offset = offsets[where];
+ info.where = where;
+ infos.append(info);
+
+ offsets[where] += info.width;
+ }
+ }
+
+ for (int i = 0; i < infos.count(); i++) {
+ ButtonInfo info = infos[i];
+ QRect lr = cr;
+ switch (info.where) {
+ case Center: {
+ lr.setLeft(cr.left() + offsets[Left]);
+ lr.setRight(cr.right() - offsets[Right]);
+ QRect r(0, 0, offsets[Center], lr.height());
+ r.moveCenter(lr.center());
+ r.setLeft(r.left()+info.offset);
+ r.setWidth(info.width);
+ lr = r;
+ break; }
+ case Left:
+ lr.translate(info.offset, 0);
+ lr.setWidth(info.width);
+ break;
+ case Right:
+ lr.moveLeft(cr.right() + 1 - offsets[Right] + info.offset);
+ lr.setWidth(info.width);
+ break;
+ default:
+ break;
+ }
+ QStyle::SubControl control = knownPseudoElements[info.element].subControl;
+ layoutRects[control] = positionRect(w, info.rule, info.element, lr, tb->direction);
+ }
+
+ return layoutRects;
+}
+
+static QStyle::StandardPixmap subControlIcon(int pe)
+{
+ switch (pe) {
+ case PseudoElement_MdiCloseButton: return QStyle::SP_TitleBarCloseButton;
+ case PseudoElement_MdiMinButton: return QStyle::SP_TitleBarMinButton;
+ case PseudoElement_MdiNormalButton: return QStyle::SP_TitleBarNormalButton;
+ case PseudoElement_TitleBarCloseButton: return QStyle::SP_TitleBarCloseButton;
+ case PseudoElement_TitleBarMinButton: return QStyle::SP_TitleBarMinButton;
+ case PseudoElement_TitleBarMaxButton: return QStyle::SP_TitleBarMaxButton;
+ case PseudoElement_TitleBarShadeButton: return QStyle::SP_TitleBarShadeButton;
+ case PseudoElement_TitleBarUnshadeButton: return QStyle::SP_TitleBarUnshadeButton;
+ case PseudoElement_TitleBarNormalButton: return QStyle::SP_TitleBarNormalButton;
+ case PseudoElement_TitleBarContextHelpButton: return QStyle::SP_TitleBarContextHelpButton;
+ default: break;
+ }
+ return QStyle::SP_CustomBase;
+}
+
+QRenderRule::QRenderRule(const QVector<Declaration> &declarations, const QWidget *widget)
+: features(0), hasFont(false), pal(0), b(0), bg(0), bd(0), ou(0), geo(0), p(0), img(0), clipset(0)
+{
+ QPalette palette = QApplication::palette(); // ###: ideally widget's palette
+ ValueExtractor v(declarations, palette);
+ features = v.extractStyleFeatures();
+
+ int w = -1, h = -1, minw = -1, minh = -1, maxw = -1, maxh = -1;
+ if (v.extractGeometry(&w, &h, &minw, &minh, &maxw, &maxh))
+ geo = new QStyleSheetGeometryData(w, h, minw, minh, maxw, maxh);
+
+ int left = 0, top = 0, right = 0, bottom = 0;
+ Origin origin = Origin_Unknown;
+ Qt::Alignment position = 0;
+ QCss::PositionMode mode = PositionMode_Unknown;
+ Qt::Alignment textAlignment = 0;
+ if (v.extractPosition(&left, &top, &right, &bottom, &origin, &position, &mode, &textAlignment))
+ p = new QStyleSheetPositionData(left, top, right, bottom, origin, position, mode, textAlignment);
+
+ int margins[4], paddings[4], spacing = -1;
+ for (int i = 0; i < 4; i++)
+ margins[i] = paddings[i] = 0;
+ if (v.extractBox(margins, paddings, &spacing))
+ b = new QStyleSheetBoxData(margins, paddings, spacing);
+
+ int borders[4];
+ QBrush colors[4];
+ QCss::BorderStyle styles[4];
+ QSize radii[4];
+ for (int i = 0; i < 4; i++) {
+ borders[i] = 0;
+ styles[i] = BorderStyle_None;
+ }
+ if (v.extractBorder(borders, colors, styles, radii))
+ bd = new QStyleSheetBorderData(borders, colors, styles, radii);
+
+ int offsets[4];
+ for (int i = 0; i < 4; i++) {
+ borders[i] = offsets[i] = 0;
+ styles[i] = BorderStyle_None;
+ }
+ if (v.extractOutline(borders, colors, styles, radii, offsets))
+ ou = new QStyleSheetOutlineData(borders, colors, styles, radii, offsets);
+
+ QBrush brush;
+ QString uri;
+ Repeat repeat = Repeat_XY;
+ Qt::Alignment alignment = Qt::AlignTop | Qt::AlignLeft;
+ Attachment attachment = Attachment_Scroll;
+ origin = Origin_Padding;
+ Origin clip = Origin_Border;
+ if (v.extractBackground(&brush, &uri, &repeat, &alignment, &origin, &attachment, &clip))
+ bg = new QStyleSheetBackgroundData(brush, QPixmap(uri), repeat, alignment, origin, attachment, clip);
+
+ QBrush sfg, fg;
+ QBrush sbg, abg;
+ if (v.extractPalette(&fg, &sfg, &sbg, &abg))
+ pal = new QStyleSheetPaletteData(fg, sfg, sbg, abg);
+
+ QIcon icon;
+ alignment = Qt::AlignCenter;
+ QSize size;
+ if (v.extractImage(&icon, &alignment, &size))
+ img = new QStyleSheetImageData(icon, alignment, size);
+
+ int adj = -255;
+ hasFont = v.extractFont(&font, &adj);
+
+#ifndef QT_NO_TOOLTIP
+ if (widget && qstrcmp(widget->metaObject()->className(), "QTipLabel") == 0)
+ palette = QToolTip::palette();
+#endif
+
+ for (int i = 0; i < declarations.count(); i++) {
+ const Declaration& decl = declarations.at(i);
+ if (decl.d->propertyId == BorderImage) {
+ QString uri;
+ QCss::TileMode horizStretch, vertStretch;
+ int cuts[4];
+
+ decl.borderImageValue(&uri, cuts, &horizStretch, &vertStretch);
+ if (uri.isEmpty() || uri == QLatin1String("none")) {
+ if (bd && bd->bi)
+ bd->bi->pixmap = QPixmap();
+ } else {
+ if (!bd)
+ bd = new QStyleSheetBorderData;
+ if (!bd->bi)
+ bd->bi = new QStyleSheetBorderImageData;
+
+ QStyleSheetBorderImageData *bi = bd->bi;
+ bi->pixmap = QPixmap(uri);
+ for (int i = 0; i < 4; i++)
+ bi->cuts[i] = cuts[i];
+ bi->horizStretch = horizStretch;
+ bi->vertStretch = vertStretch;
+ }
+ } else if (decl.d->propertyId == QtBackgroundRole) {
+ if (bg && bg->brush.style() != Qt::NoBrush)
+ continue;
+ int role = decl.d->values.at(0).variant.toInt();
+ if (role >= Value_FirstColorRole && role <= Value_LastColorRole)
+ defaultBackground = palette.color((QPalette::ColorRole)(role-Value_FirstColorRole));
+ } else if (decl.d->property.startsWith(QLatin1String("qproperty-"), Qt::CaseInsensitive)) {
+ // intentionally left blank...
+ } else if (decl.d->propertyId == UnknownProperty) {
+ bool knownStyleHint = false;
+ for (int i = 0; i < numKnownStyleHints; i++) {
+ QLatin1String styleHint(knownStyleHints[i]);
+ if (decl.d->property.compare(styleHint) == 0) {
+ QString hintName = QString(styleHint);
+ QVariant hintValue;
+ if (hintName.endsWith(QLatin1String("alignment"))) {
+ hintValue = (int) decl.alignmentValue();
+ } else if (hintName.endsWith(QLatin1String("color"))) {
+ hintValue = (int) decl.colorValue().rgba();
+ } else if (hintName.endsWith(QLatin1String("size"))) {
+ hintValue = decl.sizeValue();
+ // ### Qt5
+// } else if (hintName.endsWith(QLatin1String("icon"))) {
+// hintValue = decl.iconValue();
+ } else if (hintName == QLatin1String("button-layout")
+ && decl.d->values.count() != 0 && decl.d->values.at(0).type == Value::String) {
+ hintValue = subControlLayout(decl.d->values.at(0).variant.toString());
+ } else {
+ int integer;
+ decl.intValue(&integer);
+ hintValue = integer;
+ }
+ styleHints[decl.d->property] = hintValue;
+ knownStyleHint = true;
+ break;
+ }
+ }
+ if (!knownStyleHint)
+ qDebug("Unknown property %s", qPrintable(decl.d->property));
+ }
+ }
+
+ if (widget) {
+ QStyleSheetStyle *style = const_cast<QStyleSheetStyle *>(globalStyleSheetStyle);
+ if (!style)
+ style = qobject_cast<QStyleSheetStyle *>(widget->style());
+ if (style)
+ fixupBorder(style->nativeFrameWidth(widget));
+
+ }
+ if (hasBorder() && border()->hasBorderImage())
+ defaultBackground = QBrush();
+}
+
+QRect QRenderRule::borderRect(const QRect& r) const
+{
+ if (!hasBox())
+ return r;
+ const int* m = box()->margins;
+ return r.adjusted(m[LeftEdge], m[TopEdge], -m[RightEdge], -m[BottomEdge]);
+}
+
+QRect QRenderRule::outlineRect(const QRect& r) const
+{
+ QRect br = borderRect(r);
+ if (!hasOutline())
+ return br;
+ const int *b = outline()->borders;
+ return r.adjusted(b[LeftEdge], b[TopEdge], -b[RightEdge], -b[BottomEdge]);
+}
+
+QRect QRenderRule::paddingRect(const QRect& r) const
+{
+ QRect br = borderRect(r);
+ if (!hasBorder())
+ return br;
+ const int *b = border()->borders;
+ return br.adjusted(b[LeftEdge], b[TopEdge], -b[RightEdge], -b[BottomEdge]);
+}
+
+QRect QRenderRule::contentsRect(const QRect& r) const
+{
+ QRect pr = paddingRect(r);
+ if (!hasBox())
+ return pr;
+ const int *p = box()->paddings;
+ return pr.adjusted(p[LeftEdge], p[TopEdge], -p[RightEdge], -p[BottomEdge]);
+}
+
+QRect QRenderRule::boxRect(const QRect& cr, int flags) const
+{
+ QRect r = cr;
+ if (hasBox()) {
+ if (flags & Margin) {
+ const int *m = box()->margins;
+ r.adjust(-m[LeftEdge], -m[TopEdge], m[RightEdge], m[BottomEdge]);
+ }
+ if (flags & Padding) {
+ const int *p = box()->paddings;
+ r.adjust(-p[LeftEdge], -p[TopEdge], p[RightEdge], p[BottomEdge]);
+ }
+ }
+ if (hasBorder() && (flags & Border)) {
+ const int *b = border()->borders;
+ r.adjust(-b[LeftEdge], -b[TopEdge], b[RightEdge], b[BottomEdge]);
+ }
+ return r;
+}
+
+QSize QRenderRule::boxSize(const QSize &cs, int flags) const
+{
+ QSize bs = boxRect(QRect(QPoint(0, 0), cs), flags).size();
+ if (cs.width() < 0) bs.setWidth(-1);
+ if (cs.height() < 0) bs.setHeight(-1);
+ return bs;
+}
+
+void QRenderRule::fixupBorder(int nativeWidth)
+{
+ if (bd == 0)
+ return;
+
+ if (!bd->hasBorderImage() || bd->bi->pixmap.isNull()) {
+ bd->bi = 0;
+ // ignore the color, border of edges that have none border-style
+ QBrush color = pal ? pal->foreground : QBrush();
+ const bool hasRadius = bd->radii[0].isValid() || bd->radii[1].isValid()
+ || bd->radii[2].isValid() || bd->radii[3].isValid();
+ for (int i = 0; i < 4; i++) {
+ if ((bd->styles[i] == BorderStyle_Native) && hasRadius)
+ bd->styles[i] = BorderStyle_None;
+
+ switch (bd->styles[i]) {
+ case BorderStyle_None:
+ // border-style: none forces width to be 0
+ bd->colors[i] = QBrush();
+ bd->borders[i] = 0;
+ break;
+ case BorderStyle_Native:
+ if (bd->borders[i] == 0)
+ bd->borders[i] = nativeWidth;
+ // intentional fall through
+ default:
+ if (!bd->colors[i].style() != Qt::NoBrush) // auto-acquire 'color'
+ bd->colors[i] = color;
+ break;
+ }
+ }
+
+ return;
+ }
+
+ // inspect the border image
+ QStyleSheetBorderImageData *bi = bd->bi;
+ if (bi->cuts[0] == -1) {
+ for (int i = 0; i < 4; i++) // assume, cut = border
+ bi->cuts[i] = int(border()->borders[i]);
+ }
+}
+
+void QRenderRule::drawBorderImage(QPainter *p, const QRect& rect)
+{
+ setClip(p, rect);
+ static const Qt::TileRule tileMode2TileRule[] = {
+ Qt::StretchTile, Qt::RoundTile, Qt::StretchTile, Qt::RepeatTile, Qt::StretchTile };
+
+ const QStyleSheetBorderImageData *borderImageData = border()->borderImage();
+ const int *targetBorders = border()->borders;
+ const int *sourceBorders = borderImageData->cuts;
+ QMargins sourceMargins(sourceBorders[LeftEdge], sourceBorders[TopEdge],
+ sourceBorders[RightEdge], sourceBorders[BottomEdge]);
+ QMargins targetMargins(targetBorders[LeftEdge], targetBorders[TopEdge],
+ targetBorders[RightEdge], targetBorders[BottomEdge]);
+
+ bool wasSmoothPixmapTransform = p->renderHints() & QPainter::SmoothPixmapTransform;
+ p->setRenderHint(QPainter::SmoothPixmapTransform);
+ qDrawBorderPixmap(p, rect, targetMargins, borderImageData->pixmap,
+ QRect(QPoint(), borderImageData->pixmap.size()), sourceMargins,
+ QTileRules(tileMode2TileRule[borderImageData->horizStretch], tileMode2TileRule[borderImageData->vertStretch]));
+ p->setRenderHint(QPainter::SmoothPixmapTransform, wasSmoothPixmapTransform);
+ unsetClip(p);
+}
+
+QRect QRenderRule::originRect(const QRect &rect, Origin origin) const
+{
+ switch (origin) {
+ case Origin_Padding:
+ return paddingRect(rect);
+ case Origin_Border:
+ return borderRect(rect);
+ case Origin_Content:
+ return contentsRect(rect);
+ case Origin_Margin:
+ default:
+ return rect;
+ }
+}
+
+void QRenderRule::drawBackgroundImage(QPainter *p, const QRect &rect, QPoint off)
+{
+ if (!hasBackground())
+ return;
+
+ const QPixmap& bgp = background()->pixmap;
+ if (bgp.isNull())
+ return;
+
+ setClip(p, borderRect(rect));
+
+ if (background()->origin != background()->clip) {
+ p->save();
+ p->setClipRect(originRect(rect, background()->clip), Qt::IntersectClip);
+ }
+
+ if (background()->attachment == Attachment_Fixed)
+ off = QPoint(0, 0);
+
+ QRect r = originRect(rect, background()->origin);
+ QRect aligned = QStyle::alignedRect(Qt::LeftToRight, background()->position, bgp.size(), r);
+ QRect inter = aligned.translated(-off).intersected(r);
+
+ switch (background()->repeat) {
+ case Repeat_Y:
+ p->drawTiledPixmap(inter.x(), r.y(), inter.width(), r.height(), bgp,
+ inter.x() - aligned.x() + off.x(),
+ bgp.height() - int(aligned.y() - r.y()) % bgp.height() + off.y());
+ break;
+ case Repeat_X:
+ p->drawTiledPixmap(r.x(), inter.y(), r.width(), inter.height(), bgp,
+ bgp.width() - int(aligned.x() - r.x())%bgp.width() + off.x(),
+ inter.y() - aligned.y() + off.y());
+ break;
+ case Repeat_XY:
+ p->drawTiledPixmap(r, bgp,
+ QPoint(bgp.width() - int(aligned.x() - r.x())% bgp.width() + off.x(),
+ bgp.height() - int(aligned.y() - r.y())%bgp.height() + off.y()));
+ break;
+ case Repeat_None:
+ default:
+ p->drawPixmap(inter.x(), inter.y(), bgp, inter.x() - aligned.x() + off.x(),
+ inter.y() - aligned.y() + off.y(), inter.width(), inter.height());
+ break;
+ }
+
+
+ if (background()->origin != background()->clip)
+ p->restore();
+
+ unsetClip(p);
+}
+
+void QRenderRule::drawOutline(QPainter *p, const QRect &rect)
+{
+ if (!hasOutline())
+ return;
+
+ bool wasAntialiased = p->renderHints() & QPainter::Antialiasing;
+ p->setRenderHint(QPainter::Antialiasing);
+ qDrawBorder(p, rect, ou->styles, ou->borders, ou->colors, ou->radii);
+ p->setRenderHint(QPainter::Antialiasing, wasAntialiased);
+}
+
+void QRenderRule::drawBorder(QPainter *p, const QRect& rect)
+{
+ if (!hasBorder())
+ return;
+
+ if (border()->hasBorderImage()) {
+ drawBorderImage(p, rect);
+ return;
+ }
+
+ bool wasAntialiased = p->renderHints() & QPainter::Antialiasing;
+ p->setRenderHint(QPainter::Antialiasing);
+ qDrawBorder(p, rect, bd->styles, bd->borders, bd->colors, bd->radii);
+ p->setRenderHint(QPainter::Antialiasing, wasAntialiased);
+}
+
+QPainterPath QRenderRule::borderClip(QRect r)
+{
+ if (!hasBorder())
+ return QPainterPath();
+
+ QSize tlr, trr, blr, brr;
+ qNormalizeRadii(r, bd->radii, &tlr, &trr, &blr, &brr);
+ if (tlr.isNull() && trr.isNull() && blr.isNull() && brr.isNull())
+ return QPainterPath();
+
+ const QRectF rect(r);
+ const int *borders = border()->borders;
+ QPainterPath path;
+ qreal curY = rect.y() + borders[TopEdge]/2.0;
+ path.moveTo(rect.x() + tlr.width(), curY);
+ path.lineTo(rect.right() - trr.width(), curY);
+ qreal curX = rect.right() - borders[RightEdge]/2.0;
+ path.arcTo(curX - 2*trr.width() + borders[RightEdge], curY,
+ trr.width()*2 - borders[RightEdge], trr.height()*2 - borders[TopEdge], 90, -90);
+
+ path.lineTo(curX, rect.bottom() - brr.height());
+ curY = rect.bottom() - borders[BottomEdge]/2.0;
+ path.arcTo(curX - 2*brr.width() + borders[RightEdge], curY - 2*brr.height() + borders[BottomEdge],
+ brr.width()*2 - borders[RightEdge], brr.height()*2 - borders[BottomEdge], 0, -90);
+
+ path.lineTo(rect.x() + blr.width(), curY);
+ curX = rect.left() + borders[LeftEdge]/2.0;
+ path.arcTo(curX, rect.bottom() - 2*blr.height() + borders[BottomEdge]/2,
+ blr.width()*2 - borders[LeftEdge], blr.height()*2 - borders[BottomEdge], 270, -90);
+
+ path.lineTo(curX, rect.top() + tlr.height());
+ path.arcTo(curX, rect.top() + borders[TopEdge]/2,
+ tlr.width()*2 - borders[LeftEdge], tlr.height()*2 - borders[TopEdge], 180, -90);
+
+ path.closeSubpath();
+ return path;
+}
+
+/*! \internal
+ Clip the painter to the border (in case we are using radius border)
+ */
+void QRenderRule::setClip(QPainter *p, const QRect &rect)
+{
+ if (clipset++)
+ return;
+ clipPath = borderClip(rect);
+ if (!clipPath.isEmpty()) {
+ p->save();
+ p->setClipPath(clipPath, Qt::IntersectClip);
+ }
+}
+
+void QRenderRule::unsetClip(QPainter *p)
+{
+ if (--clipset)
+ return;
+ if (!clipPath.isEmpty())
+ p->restore();
+}
+
+void QRenderRule::drawBackground(QPainter *p, const QRect& rect, const QPoint& off)
+{
+ QBrush brush = hasBackground() ? background()->brush : QBrush();
+ if (brush.style() == Qt::NoBrush)
+ brush = defaultBackground;
+
+ if (brush.style() != Qt::NoBrush) {
+ Origin origin = hasBackground() ? background()->clip : Origin_Border;
+ // ### fix for gradients
+ const QPainterPath &borderPath = borderClip(originRect(rect, origin));
+ if (!borderPath.isEmpty()) {
+ // Drawn intead of being used as clipping path for better visual quality
+ bool wasAntialiased = p->renderHints() & QPainter::Antialiasing;
+ p->setRenderHint(QPainter::Antialiasing);
+ p->fillPath(borderPath, brush);
+ p->setRenderHint(QPainter::Antialiasing, wasAntialiased);
+ } else {
+ p->fillRect(originRect(rect, origin), brush);
+ }
+ }
+
+ drawBackgroundImage(p, rect, off);
+}
+
+void QRenderRule::drawFrame(QPainter *p, const QRect& rect)
+{
+ drawBackground(p, rect);
+ if (hasBorder())
+ drawBorder(p, borderRect(rect));
+}
+
+void QRenderRule::drawImage(QPainter *p, const QRect &rect)
+{
+ if (!hasImage())
+ return;
+ img->icon.paint(p, rect, img->alignment);
+}
+
+void QRenderRule::drawRule(QPainter *p, const QRect& rect)
+{
+ drawFrame(p, rect);
+ drawImage(p, contentsRect(rect));
+}
+
+// *shudder* , *horror*, *whoa* <-- what you might feel when you see the functions below
+void QRenderRule::configurePalette(QPalette *p, QPalette::ColorRole fr, QPalette::ColorRole br)
+{
+ if (bg && bg->brush.style() != Qt::NoBrush) {
+ if (br != QPalette::NoRole)
+ p->setBrush(br, bg->brush);
+ p->setBrush(QPalette::Window, bg->brush);
+ if (bg->brush.style() == Qt::SolidPattern) {
+ p->setBrush(QPalette::Light, bg->brush.color().lighter(115));
+ p->setBrush(QPalette::Midlight, bg->brush.color().lighter(107));
+ p->setBrush(QPalette::Dark, bg->brush.color().darker(150));
+ p->setBrush(QPalette::Shadow, bg->brush.color().darker(300));
+ }
+ }
+
+ if (!hasPalette())
+ return;
+
+ if (pal->foreground.style() != Qt::NoBrush) {
+ if (fr != QPalette::NoRole)
+ p->setBrush(fr, pal->foreground);
+ p->setBrush(QPalette::WindowText, pal->foreground);
+ p->setBrush(QPalette::Text, pal->foreground);
+ }
+ if (pal->selectionBackground.style() != Qt::NoBrush)
+ p->setBrush(QPalette::Highlight, pal->selectionBackground);
+ if (pal->selectionForeground.style() != Qt::NoBrush)
+ p->setBrush(QPalette::HighlightedText, pal->selectionForeground);
+ if (pal->alternateBackground.style() != Qt::NoBrush)
+ p->setBrush(QPalette::AlternateBase, pal->alternateBackground);
+}
+
+void QRenderRule::configurePalette(QPalette *p, QPalette::ColorGroup cg, const QWidget *w, bool embedded)
+{
+ if (bg && bg->brush.style() != Qt::NoBrush) {
+ p->setBrush(cg, QPalette::Base, bg->brush); // for windows, windowxp
+ p->setBrush(cg, QPalette::Button, bg->brush); // for plastique
+ p->setBrush(cg, w->backgroundRole(), bg->brush);
+ p->setBrush(cg, QPalette::Window, bg->brush);
+ }
+
+ if (embedded) {
+ /* For embedded widgets (ComboBox, SpinBox and ScrollArea) we want the embedded widget
+ * to be transparent when we have a transparent background or border image */
+ if ((hasBackground() && background()->isTransparent())
+ || (hasBorder() && border()->hasBorderImage() && !border()->borderImage()->pixmap.isNull()))
+ p->setBrush(cg, w->backgroundRole(), Qt::NoBrush);
+ }
+
+ if (!hasPalette())
+ return;
+
+ if (pal->foreground.style() != Qt::NoBrush) {
+ p->setBrush(cg, QPalette::ButtonText, pal->foreground);
+ p->setBrush(cg, w->foregroundRole(), pal->foreground);
+ p->setBrush(cg, QPalette::WindowText, pal->foreground);
+ p->setBrush(cg, QPalette::Text, pal->foreground);
+ }
+ if (pal->selectionBackground.style() != Qt::NoBrush)
+ p->setBrush(cg, QPalette::Highlight, pal->selectionBackground);
+ if (pal->selectionForeground.style() != Qt::NoBrush)
+ p->setBrush(cg, QPalette::HighlightedText, pal->selectionForeground);
+ if (pal->alternateBackground.style() != Qt::NoBrush)
+ p->setBrush(cg, QPalette::AlternateBase, pal->alternateBackground);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Style rules
+#define WIDGET(x) (static_cast<QWidget *>(x.ptr))
+
+static inline QWidget *parentWidget(const QWidget *w)
+{
+ if(qobject_cast<const QLabel *>(w) && qstrcmp(w->metaObject()->className(), "QTipLabel") == 0) {
+ QWidget *p = qvariant_cast<QWidget *>(w->property("_q_stylesheet_parent"));
+ if (p)
+ return p;
+ }
+ return w->parentWidget();
+}
+
+class QStyleSheetStyleSelector : public StyleSelector
+{
+public:
+ QStyleSheetStyleSelector() { }
+
+ QStringList nodeNames(NodePtr node) const
+ {
+ if (isNullNode(node))
+ return QStringList();
+ const QMetaObject *metaObject = WIDGET(node)->metaObject();
+#ifndef QT_NO_TOOLTIP
+ if (qstrcmp(metaObject->className(), "QTipLabel") == 0)
+ return QStringList(QLatin1String("QToolTip"));
+#endif
+ QStringList result;
+ do {
+ result += QString::fromLatin1(metaObject->className()).replace(QLatin1Char(':'), QLatin1Char('-'));
+ metaObject = metaObject->superClass();
+ } while (metaObject != 0);
+ return result;
+ }
+ QString attribute(NodePtr node, const QString& name) const
+ {
+ if (isNullNode(node))
+ return QString();
+
+ QHash<QString, QString> &cache = m_attributeCache[WIDGET(node)];
+ QHash<QString, QString>::const_iterator cacheIt = cache.constFind(name);
+ if (cacheIt != cache.constEnd())
+ return cacheIt.value();
+
+ QVariant value = WIDGET(node)->property(name.toLatin1());
+ if (!value.isValid()) {
+ if (name == QLatin1String("class")) {
+ QString className = QString::fromLatin1(WIDGET(node)->metaObject()->className());
+ if (className.contains(QLatin1Char(':')))
+ className.replace(QLatin1Char(':'), QLatin1Char('-'));
+ cache[name] = className;
+ return className;
+ } else if (name == QLatin1String("style")) {
+ QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(WIDGET(node)->style());
+ if (proxy) {
+ QString styleName = QString::fromLatin1(proxy->baseStyle()->metaObject()->className());
+ cache[name] = styleName;
+ return styleName;
+ }
+ }
+ }
+ QString valueStr;
+ if(value.type() == QVariant::StringList || value.type() == QVariant::List)
+ valueStr = value.toStringList().join(QLatin1String(" "));
+ else
+ valueStr = value.toString();
+ cache[name] = valueStr;
+ return valueStr;
+ }
+ bool nodeNameEquals(NodePtr node, const QString& nodeName) const
+ {
+ if (isNullNode(node))
+ return false;
+ const QMetaObject *metaObject = WIDGET(node)->metaObject();
+#ifndef QT_NO_TOOLTIP
+ if (qstrcmp(metaObject->className(), "QTipLabel") == 0)
+ return nodeName == QLatin1String("QToolTip");
+#endif
+ do {
+ const ushort *uc = (const ushort *)nodeName.constData();
+ const ushort *e = uc + nodeName.length();
+ const uchar *c = (uchar *)metaObject->className();
+ while (*c && uc != e && (*uc == *c || (*c == ':' && *uc == '-'))) {
+ ++uc;
+ ++c;
+ }
+ if (uc == e && !*c)
+ return true;
+ metaObject = metaObject->superClass();
+ } while (metaObject != 0);
+ return false;
+ }
+ bool hasAttributes(NodePtr) const
+ { return true; }
+ QStringList nodeIds(NodePtr node) const
+ { return isNullNode(node) ? QStringList() : QStringList(WIDGET(node)->objectName()); }
+ bool isNullNode(NodePtr node) const
+ { return node.ptr == 0; }
+ NodePtr parentNode(NodePtr node) const
+ { NodePtr n; n.ptr = isNullNode(node) ? 0 : parentWidget(WIDGET(node)); return n; }
+ NodePtr previousSiblingNode(NodePtr) const
+ { NodePtr n; n.ptr = 0; return n; }
+ NodePtr duplicateNode(NodePtr node) const
+ { return node; }
+ void freeNode(NodePtr) const
+ { }
+
+private:
+ mutable QHash<const QWidget *, QHash<QString, QString> > m_attributeCache;
+};
+
+QVector<QCss::StyleRule> QStyleSheetStyle::styleRules(const QWidget *w) const
+{
+ QHash<const QWidget *, QVector<StyleRule> >::const_iterator cacheIt = styleSheetCaches->styleRulesCache.constFind(w);
+ if (cacheIt != styleSheetCaches->styleRulesCache.constEnd())
+ return cacheIt.value();
+
+ if (!initWidget(w)) {
+ return QVector<StyleRule>();
+ }
+
+ QStyleSheetStyleSelector styleSelector;
+
+ StyleSheet defaultSs;
+ QHash<const void *, StyleSheet>::const_iterator defaultCacheIt = styleSheetCaches->styleSheetCache.constFind(baseStyle());
+ if (defaultCacheIt == styleSheetCaches->styleSheetCache.constEnd()) {
+ defaultSs = getDefaultStyleSheet();
+ QStyle *bs = baseStyle();
+ styleSheetCaches->styleSheetCache.insert(bs, defaultSs);
+ QObject::connect(bs, SIGNAL(destroyed(QObject*)), styleSheetCaches, SLOT(styleDestroyed(QObject*)), Qt::UniqueConnection);
+ } else {
+ defaultSs = defaultCacheIt.value();
+ }
+ styleSelector.styleSheets += defaultSs;
+
+ if (!qApp->styleSheet().isEmpty()) {
+ StyleSheet appSs;
+ QHash<const void *, StyleSheet>::const_iterator appCacheIt = styleSheetCaches->styleSheetCache.constFind(qApp);
+ if (appCacheIt == styleSheetCaches->styleSheetCache.constEnd()) {
+ QString ss = qApp->styleSheet();
+ if (ss.startsWith(QLatin1String("file:///")))
+ ss.remove(0, 8);
+ parser.init(ss, qApp->styleSheet() != ss);
+ if (!parser.parse(&appSs))
+ qWarning("Could not parse application stylesheet");
+ appSs.origin = StyleSheetOrigin_Inline;
+ appSs.depth = 1;
+ styleSheetCaches->styleSheetCache.insert(qApp, appSs);
+ } else {
+ appSs = appCacheIt.value();
+ }
+ styleSelector.styleSheets += appSs;
+ }
+
+ QVector<QCss::StyleSheet> widgetSs;
+ for (const QWidget *wid = w; wid; wid = parentWidget(wid)) {
+ if (wid->styleSheet().isEmpty())
+ continue;
+ StyleSheet ss;
+ QHash<const void *, StyleSheet>::const_iterator widCacheIt = styleSheetCaches->styleSheetCache.constFind(wid);
+ if (widCacheIt == styleSheetCaches->styleSheetCache.constEnd()) {
+ parser.init(wid->styleSheet());
+ if (!parser.parse(&ss)) {
+ parser.init(QLatin1String("* {") + wid->styleSheet() + QLatin1Char('}'));
+ if (!parser.parse(&ss))
+ qWarning("Could not parse stylesheet of widget %p", wid);
+ }
+ ss.origin = StyleSheetOrigin_Inline;
+ styleSheetCaches->styleSheetCache.insert(wid, ss);
+ } else {
+ ss = widCacheIt.value();
+ }
+ widgetSs.append(ss);
+ }
+
+ for (int i = 0; i < widgetSs.count(); i++)
+ widgetSs[i].depth = widgetSs.count() - i + 2;
+
+ styleSelector.styleSheets += widgetSs;
+
+ StyleSelector::NodePtr n;
+ n.ptr = (void *)w;
+ QVector<QCss::StyleRule> rules = styleSelector.styleRulesForNode(n);
+ styleSheetCaches->styleRulesCache.insert(w, rules);
+ return rules;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Rendering rules
+static QVector<Declaration> declarations(const QVector<StyleRule> &styleRules, const QString &part, quint64 pseudoClass = PseudoClass_Unspecified)
+{
+ QVector<Declaration> decls;
+ for (int i = 0; i < styleRules.count(); i++) {
+ const Selector& selector = styleRules.at(i).selectors.at(0);
+ // Rules with pseudo elements don't cascade. This is an intentional
+ // diversion for CSS
+ if (part.compare(selector.pseudoElement(), Qt::CaseInsensitive) != 0)
+ continue;
+ quint64 negated = 0;
+ quint64 cssClass = selector.pseudoClass(&negated);
+ if ((pseudoClass == PseudoClass_Any) || (cssClass == PseudoClass_Unspecified)
+ || ((((cssClass & pseudoClass) == cssClass)) && ((negated & pseudoClass) == 0)))
+ decls += styleRules.at(i).declarations;
+ }
+ return decls;
+}
+
+int QStyleSheetStyle::nativeFrameWidth(const QWidget *w)
+{
+ QStyle *base = baseStyle();
+
+#ifndef QT_NO_SPINBOX
+ if (qobject_cast<const QAbstractSpinBox *>(w))
+ return base->pixelMetric(QStyle::PM_SpinBoxFrameWidth, 0, w);
+#endif
+
+#ifndef QT_NO_COMBOBOX
+ if (qobject_cast<const QComboBox *>(w))
+ return base->pixelMetric(QStyle::PM_ComboBoxFrameWidth, 0, w);
+#endif
+
+#ifndef QT_NO_MENU
+ if (qobject_cast<const QMenu *>(w))
+ return base->pixelMetric(QStyle::PM_MenuPanelWidth, 0, w);
+#endif
+
+#ifndef QT_NO_MENUBAR
+ if (qobject_cast<const QMenuBar *>(w))
+ return base->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, w);
+#endif
+#ifndef QT_NO_FRAME
+ if (const QFrame *frame = qobject_cast<const QFrame *>(w)) {
+ if (frame->frameShape() == QFrame::NoFrame)
+ return 0;
+ }
+#endif
+
+ if (qstrcmp(w->metaObject()->className(), "QTipLabel") == 0)
+ return base->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0, w);
+
+ return base->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, w);
+}
+
+static quint64 pseudoClass(QStyle::State state)
+{
+ quint64 pc = 0;
+ if (state & QStyle::State_Enabled) {
+ pc |= PseudoClass_Enabled;
+ if (state & QStyle::State_MouseOver)
+ pc |= PseudoClass_Hover;
+ } else {
+ pc |= PseudoClass_Disabled;
+ }
+ if (state & QStyle::State_Active)
+ pc |= PseudoClass_Active;
+ if (state & QStyle::State_Window)
+ pc |= PseudoClass_Window;
+ if (state & QStyle::State_Sunken)
+ pc |= PseudoClass_Pressed;
+ if (state & QStyle::State_HasFocus)
+ pc |= PseudoClass_Focus;
+ if (state & QStyle::State_On)
+ pc |= (PseudoClass_On | PseudoClass_Checked);
+ if (state & QStyle::State_Off)
+ pc |= (PseudoClass_Off | PseudoClass_Unchecked);
+ if (state & QStyle::State_NoChange)
+ pc |= PseudoClass_Indeterminate;
+ if (state & QStyle::State_Selected)
+ pc |= PseudoClass_Selected;
+ if (state & QStyle::State_Horizontal)
+ pc |= PseudoClass_Horizontal;
+ else
+ pc |= PseudoClass_Vertical;
+ if (state & (QStyle::State_Open | QStyle::State_On | QStyle::State_Sunken))
+ pc |= PseudoClass_Open;
+ else
+ pc |= PseudoClass_Closed;
+ if (state & QStyle::State_Children)
+ pc |= PseudoClass_Children;
+ if (state & QStyle::State_Sibling)
+ pc |= PseudoClass_Sibling;
+ if (state & QStyle::State_ReadOnly)
+ pc |= PseudoClass_ReadOnly;
+ if (state & QStyle::State_Item)
+ pc |= PseudoClass_Item;
+#ifdef QT_KEYPAD_NAVIGATION
+ if (state & QStyle::State_HasEditFocus)
+ pc |= PseudoClass_EditFocus;
+#endif
+ return pc;
+}
+
+static void qt_check_if_internal_widget(const QWidget **w, int *element)
+{
+#ifdef QT_NO_DOCKWIDGET
+ Q_UNUSED(w);
+ Q_UNUSED(element);
+#else
+ if (*w && qstrcmp((*w)->metaObject()->className(), "QDockWidgetTitleButton") == 0) {
+ if ((*w)->objectName() == QLatin1String("qt_dockwidget_closebutton")) {
+ *element = PseudoElement_DockWidgetCloseButton;
+ } else if ((*w)->objectName() == QLatin1String("qt_dockwidget_floatbutton")) {
+ *element = PseudoElement_DockWidgetFloatButton;
+ }
+ *w = (*w)->parentWidget();
+ }
+#endif
+}
+
+QRenderRule QStyleSheetStyle::renderRule(const QWidget *w, int element, quint64 state) const
+{
+ qt_check_if_internal_widget(&w, &element);
+ QHash<quint64, QRenderRule> &cache = styleSheetCaches->renderRulesCache[w][element];
+ QHash<quint64, QRenderRule>::const_iterator cacheIt = cache.constFind(state);
+ if (cacheIt != cache.constEnd())
+ return cacheIt.value();
+
+ if (!initWidget(w))
+ return QRenderRule();
+
+ quint64 stateMask = 0;
+ const QVector<StyleRule> rules = styleRules(w);
+ for (int i = 0; i < rules.count(); i++) {
+ const Selector& selector = rules.at(i).selectors.at(0);
+ quint64 negated = 0;
+ stateMask |= selector.pseudoClass(&negated);
+ stateMask |= negated;
+ }
+
+ cacheIt = cache.constFind(state & stateMask);
+ if (cacheIt != cache.constEnd()) {
+ const QRenderRule &newRule = cacheIt.value();
+ cache[state] = newRule;
+ return newRule;
+ }
+
+
+ const QString part = QLatin1String(knownPseudoElements[element].name);
+ QVector<Declaration> decls = declarations(rules, part, state);
+ QRenderRule newRule(decls, w);
+ cache[state] = newRule;
+ if ((state & stateMask) != state)
+ cache[state&stateMask] = newRule;
+ return newRule;
+}
+
+QRenderRule QStyleSheetStyle::renderRule(const QWidget *w, const QStyleOption *opt, int pseudoElement) const
+{
+ quint64 extraClass = 0;
+ QStyle::State state = opt ? opt->state : QStyle::State(QStyle::State_None);
+
+ if (const QStyleOptionComplex *complex = qstyleoption_cast<const QStyleOptionComplex *>(opt)) {
+ if (pseudoElement != PseudoElement_None) {
+ // if not an active subcontrol, just pass enabled/disabled
+ QStyle::SubControl subControl = knownPseudoElements[pseudoElement].subControl;
+
+ if (!(complex->activeSubControls & subControl))
+ state &= (QStyle::State_Enabled | QStyle::State_Horizontal | QStyle::State_HasFocus);
+ }
+
+ switch (pseudoElement) {
+ case PseudoElement_ComboBoxDropDown:
+ case PseudoElement_ComboBoxArrow:
+ state |= (complex->state & (QStyle::State_On|QStyle::State_ReadOnly));
+ break;
+ case PseudoElement_SpinBoxUpButton:
+ case PseudoElement_SpinBoxDownButton:
+ case PseudoElement_SpinBoxUpArrow:
+ case PseudoElement_SpinBoxDownArrow:
+#ifndef QT_NO_SPINBOX
+ if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
+ bool on = false;
+ bool up = pseudoElement == PseudoElement_SpinBoxUpButton
+ || pseudoElement == PseudoElement_SpinBoxUpArrow;
+ if ((sb->stepEnabled & QAbstractSpinBox::StepUpEnabled) && up)
+ on = true;
+ else if ((sb->stepEnabled & QAbstractSpinBox::StepDownEnabled) && !up)
+ on = true;
+ state |= (on ? QStyle::State_On : QStyle::State_Off);
+ }
+#endif // QT_NO_SPINBOX
+ break;
+ case PseudoElement_GroupBoxTitle:
+ state |= (complex->state & (QStyle::State_MouseOver | QStyle::State_Sunken));
+ break;
+ case PseudoElement_ToolButtonMenu:
+ case PseudoElement_ToolButtonMenuArrow:
+ case PseudoElement_ToolButtonDownArrow:
+ state |= complex->state & QStyle::State_MouseOver;
+ if (complex->state & QStyle::State_Sunken ||
+ complex->activeSubControls & QStyle::SC_ToolButtonMenu)
+ state |= QStyle::State_Sunken;
+ break;
+ case PseudoElement_SliderGroove:
+ state |= complex->state & QStyle::State_MouseOver;
+ break;
+ default:
+ break;
+ }
+
+ if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
+ // QStyle::State_On is set when the popup is being shown
+ // Propagate EditField Pressed state
+ if (pseudoElement == PseudoElement_None
+ && (complex->activeSubControls & QStyle::SC_ComboBoxEditField)
+ && (!(state & QStyle::State_MouseOver))) {
+ state |= QStyle::State_Sunken;
+ }
+
+ if (!combo->frame)
+ extraClass |= PseudoClass_Frameless;
+ if (!combo->editable)
+ extraClass |= PseudoClass_ReadOnly;
+ else
+ extraClass |= PseudoClass_Editable;
+#ifndef QT_NO_SPINBOX
+ } else if (const QStyleOptionSpinBox *spin = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
+ if (!spin->frame)
+ extraClass |= PseudoClass_Frameless;
+#endif // QT_NO_SPINBOX
+ } else if (const QStyleOptionGroupBox *gb = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
+ if (gb->features & QStyleOptionFrameV2::Flat)
+ extraClass |= PseudoClass_Flat;
+ if (gb->lineWidth == 0)
+ extraClass |= PseudoClass_Frameless;
+ } else if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
+ if (tb->titleBarState & Qt::WindowMinimized) {
+ extraClass |= PseudoClass_Minimized;
+ }
+ else if (tb->titleBarState & Qt::WindowMaximized)
+ extraClass |= PseudoClass_Maximized;
+ }
+ } else {
+ // handle simple style options
+ if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
+ if (mi->menuItemType == QStyleOptionMenuItem::DefaultItem)
+ extraClass |= PseudoClass_Default;
+ if (mi->checkType == QStyleOptionMenuItem::Exclusive)
+ extraClass |= PseudoClass_Exclusive;
+ else if (mi->checkType == QStyleOptionMenuItem::NonExclusive)
+ extraClass |= PseudoClass_NonExclusive;
+ if (mi->checkType != QStyleOptionMenuItem::NotCheckable)
+ extraClass |= (mi->checked) ? (PseudoClass_On|PseudoClass_Checked)
+ : (PseudoClass_Off|PseudoClass_Unchecked);
+ } else if (const QStyleOptionHeader *hdr = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
+ if (hdr->position == QStyleOptionHeader::OnlyOneSection)
+ extraClass |= PseudoClass_OnlyOne;
+ else if (hdr->position == QStyleOptionHeader::Beginning)
+ extraClass |= PseudoClass_First;
+ else if (hdr->position == QStyleOptionHeader::End)
+ extraClass |= PseudoClass_Last;
+ else if (hdr->position == QStyleOptionHeader::Middle)
+ extraClass |= PseudoClass_Middle;
+
+ if (hdr->selectedPosition == QStyleOptionHeader::NextAndPreviousAreSelected)
+ extraClass |= (PseudoClass_NextSelected | PseudoClass_PreviousSelected);
+ else if (hdr->selectedPosition == QStyleOptionHeader::NextIsSelected)
+ extraClass |= PseudoClass_NextSelected;
+ else if (hdr->selectedPosition == QStyleOptionHeader::PreviousIsSelected)
+ extraClass |= PseudoClass_PreviousSelected;
+#ifndef QT_NO_TABWIDGET
+ } else if (const QStyleOptionTabWidgetFrame *tab = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
+ switch (tab->shape) {
+ case QTabBar::RoundedNorth:
+ case QTabBar::TriangularNorth:
+ extraClass |= PseudoClass_Top;
+ break;
+ case QTabBar::RoundedSouth:
+ case QTabBar::TriangularSouth:
+ extraClass |= PseudoClass_Bottom;
+ break;
+ case QTabBar::RoundedEast:
+ case QTabBar::TriangularEast:
+ extraClass |= PseudoClass_Left;
+ break;
+ case QTabBar::RoundedWest:
+ case QTabBar::TriangularWest:
+ extraClass |= PseudoClass_Right;
+ break;
+ default:
+ break;
+ }
+#endif
+#ifndef QT_NO_TABBAR
+ } else if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
+ if (tab->position == QStyleOptionTab::OnlyOneTab)
+ extraClass |= PseudoClass_OnlyOne;
+ else if (tab->position == QStyleOptionTab::Beginning)
+ extraClass |= PseudoClass_First;
+ else if (tab->position == QStyleOptionTab::End)
+ extraClass |= PseudoClass_Last;
+ else if (tab->position == QStyleOptionTab::Middle)
+ extraClass |= PseudoClass_Middle;
+
+ if (tab->selectedPosition == QStyleOptionTab::NextIsSelected)
+ extraClass |= PseudoClass_NextSelected;
+ else if (tab->selectedPosition == QStyleOptionTab::PreviousIsSelected)
+ extraClass |= PseudoClass_PreviousSelected;
+
+ switch (tab->shape) {
+ case QTabBar::RoundedNorth:
+ case QTabBar::TriangularNorth:
+ extraClass |= PseudoClass_Top;
+ break;
+ case QTabBar::RoundedSouth:
+ case QTabBar::TriangularSouth:
+ extraClass |= PseudoClass_Bottom;
+ break;
+ case QTabBar::RoundedEast:
+ case QTabBar::TriangularEast:
+ extraClass |= PseudoClass_Left;
+ break;
+ case QTabBar::RoundedWest:
+ case QTabBar::TriangularWest:
+ extraClass |= PseudoClass_Right;
+ break;
+ default:
+ break;
+ }
+#endif // QT_NO_TABBAR
+ } else if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
+ if (btn->features & QStyleOptionButton::Flat)
+ extraClass |= PseudoClass_Flat;
+ if (btn->features & QStyleOptionButton::DefaultButton)
+ extraClass |= PseudoClass_Default;
+ } else if (const QStyleOptionFrame *frm = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
+ if (frm->lineWidth == 0)
+ extraClass |= PseudoClass_Frameless;
+ if (const QStyleOptionFrameV2 *frame2 = qstyleoption_cast<const QStyleOptionFrameV2 *>(opt)) {
+ if (frame2->features & QStyleOptionFrameV2::Flat)
+ extraClass |= PseudoClass_Flat;
+ }
+ }
+#ifndef QT_NO_TOOLBAR
+ else if (const QStyleOptionToolBar *tb = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
+ if (tb->toolBarArea == Qt::LeftToolBarArea)
+ extraClass |= PseudoClass_Left;
+ else if (tb->toolBarArea == Qt::RightToolBarArea)
+ extraClass |= PseudoClass_Right;
+ else if (tb->toolBarArea == Qt::TopToolBarArea)
+ extraClass |= PseudoClass_Top;
+ else if (tb->toolBarArea == Qt::BottomToolBarArea)
+ extraClass |= PseudoClass_Bottom;
+
+ if (tb->positionWithinLine == QStyleOptionToolBar::Beginning)
+ extraClass |= PseudoClass_First;
+ else if (tb->positionWithinLine == QStyleOptionToolBar::Middle)
+ extraClass |= PseudoClass_Middle;
+ else if (tb->positionWithinLine == QStyleOptionToolBar::End)
+ extraClass |= PseudoClass_Last;
+ else if (tb->positionWithinLine == QStyleOptionToolBar::OnlyOne)
+ extraClass |= PseudoClass_OnlyOne;
+ }
+#endif // QT_NO_TOOLBAR
+#ifndef QT_NO_TOOLBOX
+ else if (const QStyleOptionToolBoxV2 *tab = qstyleoption_cast<const QStyleOptionToolBoxV2 *>(opt)) {
+ if (tab->position == QStyleOptionToolBoxV2::OnlyOneTab)
+ extraClass |= PseudoClass_OnlyOne;
+ else if (tab->position == QStyleOptionToolBoxV2::Beginning)
+ extraClass |= PseudoClass_First;
+ else if (tab->position == QStyleOptionToolBoxV2::End)
+ extraClass |= PseudoClass_Last;
+ else if (tab->position == QStyleOptionToolBoxV2::Middle)
+ extraClass |= PseudoClass_Middle;
+
+ if (tab->selectedPosition == QStyleOptionToolBoxV2::NextIsSelected)
+ extraClass |= PseudoClass_NextSelected;
+ else if (tab->selectedPosition == QStyleOptionToolBoxV2::PreviousIsSelected)
+ extraClass |= PseudoClass_PreviousSelected;
+ }
+#endif // QT_NO_TOOLBOX
+#ifndef QT_NO_DOCKWIDGET
+ else if (const QStyleOptionDockWidgetV2 *dw = qstyleoption_cast<const QStyleOptionDockWidgetV2 *>(opt)) {
+ if (dw->verticalTitleBar)
+ extraClass |= PseudoClass_Vertical;
+ else
+ extraClass |= PseudoClass_Horizontal;
+ if (dw->closable)
+ extraClass |= PseudoClass_Closable;
+ if (dw->floatable)
+ extraClass |= PseudoClass_Floatable;
+ if (dw->movable)
+ extraClass |= PseudoClass_Movable;
+ }
+#endif // QT_NO_DOCKWIDGET
+#ifndef QT_NO_ITEMVIEWS
+ else if (const QStyleOptionViewItemV2 *v2 = qstyleoption_cast<const QStyleOptionViewItemV2 *>(opt)) {
+ if (v2->features & QStyleOptionViewItemV2::Alternate)
+ extraClass |= PseudoClass_Alternate;
+ if (const QStyleOptionViewItemV4 *v4 = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
+ if (v4->viewItemPosition == QStyleOptionViewItemV4::OnlyOne)
+ extraClass |= PseudoClass_OnlyOne;
+ else if (v4->viewItemPosition == QStyleOptionViewItemV4::Beginning)
+ extraClass |= PseudoClass_First;
+ else if (v4->viewItemPosition == QStyleOptionViewItemV4::End)
+ extraClass |= PseudoClass_Last;
+ else if (v4->viewItemPosition == QStyleOptionViewItemV4::Middle)
+ extraClass |= PseudoClass_Middle;
+ }
+ }
+#endif
+#ifndef QT_NO_LINEEDIT
+ // LineEdit sets Sunken flag to indicate Sunken frame (argh)
+ if (const QLineEdit *lineEdit = qobject_cast<const QLineEdit *>(w)) {
+ state &= ~QStyle::State_Sunken;
+ if (lineEdit->hasFrame()) {
+ extraClass &= ~PseudoClass_Frameless;
+ } else {
+ extraClass |= PseudoClass_Frameless;
+ }
+ } else
+#endif
+ if (const QFrame *frm = qobject_cast<const QFrame *>(w)) {
+ if (frm->lineWidth() == 0)
+ extraClass |= PseudoClass_Frameless;
+ }
+ }
+
+ return renderRule(w, pseudoElement, pseudoClass(state) | extraClass);
+}
+
+bool QStyleSheetStyle::hasStyleRule(const QWidget *w, int part) const
+{
+ QHash<int, bool> &cache = styleSheetCaches->hasStyleRuleCache[w];
+ QHash<int, bool>::const_iterator cacheIt = cache.constFind(part);
+ if (cacheIt != cache.constEnd())
+ return cacheIt.value();
+
+ if (!initWidget(w))
+ return false;
+
+
+ const QVector<StyleRule> &rules = styleRules(w);
+ if (part == PseudoElement_None) {
+ bool result = w && !rules.isEmpty();
+ cache[part] = result;
+ return result;
+ }
+
+ QString pseudoElement = QLatin1String(knownPseudoElements[part].name);
+ QVector<Declaration> declarations;
+ for (int i = 0; i < rules.count(); i++) {
+ const Selector& selector = rules.at(i).selectors.at(0);
+ if (pseudoElement.compare(selector.pseudoElement(), Qt::CaseInsensitive) == 0) {
+ cache[part] = true;
+ return true;
+ }
+ }
+
+ cache[part] = false;
+ return false;
+}
+
+static Origin defaultOrigin(int pe)
+{
+ switch (pe) {
+ case PseudoElement_ScrollBarAddPage:
+ case PseudoElement_ScrollBarSubPage:
+ case PseudoElement_ScrollBarAddLine:
+ case PseudoElement_ScrollBarSubLine:
+ case PseudoElement_ScrollBarFirst:
+ case PseudoElement_ScrollBarLast:
+ case PseudoElement_GroupBoxTitle:
+ case PseudoElement_GroupBoxIndicator: // never used
+ case PseudoElement_ToolButtonMenu:
+ case PseudoElement_SliderAddPage:
+ case PseudoElement_SliderSubPage:
+ return Origin_Border;
+
+ case PseudoElement_SpinBoxUpButton:
+ case PseudoElement_SpinBoxDownButton:
+ case PseudoElement_PushButtonMenuIndicator:
+ case PseudoElement_ComboBoxDropDown:
+ case PseudoElement_ToolButtonDownArrow:
+ case PseudoElement_MenuCheckMark:
+ case PseudoElement_MenuIcon:
+ case PseudoElement_MenuRightArrow:
+ return Origin_Padding;
+
+ case PseudoElement_Indicator:
+ case PseudoElement_ExclusiveIndicator:
+ case PseudoElement_ComboBoxArrow:
+ case PseudoElement_ScrollBarSlider:
+ case PseudoElement_ScrollBarUpArrow:
+ case PseudoElement_ScrollBarDownArrow:
+ case PseudoElement_ScrollBarLeftArrow:
+ case PseudoElement_ScrollBarRightArrow:
+ case PseudoElement_SpinBoxUpArrow:
+ case PseudoElement_SpinBoxDownArrow:
+ case PseudoElement_ToolButtonMenuArrow:
+ case PseudoElement_HeaderViewUpArrow:
+ case PseudoElement_HeaderViewDownArrow:
+ case PseudoElement_SliderGroove:
+ case PseudoElement_SliderHandle:
+ return Origin_Content;
+
+ default:
+ return Origin_Margin;
+ }
+}
+
+static Qt::Alignment defaultPosition(int pe)
+{
+ switch (pe) {
+ case PseudoElement_Indicator:
+ case PseudoElement_ExclusiveIndicator:
+ case PseudoElement_MenuCheckMark:
+ case PseudoElement_MenuIcon:
+ return Qt::AlignLeft | Qt::AlignVCenter;
+
+ case PseudoElement_ScrollBarAddLine:
+ case PseudoElement_ScrollBarLast:
+ case PseudoElement_SpinBoxDownButton:
+ case PseudoElement_PushButtonMenuIndicator:
+ case PseudoElement_ToolButtonDownArrow:
+ return Qt::AlignRight | Qt::AlignBottom;
+
+ case PseudoElement_ScrollBarSubLine:
+ case PseudoElement_ScrollBarFirst:
+ case PseudoElement_SpinBoxUpButton:
+ case PseudoElement_ComboBoxDropDown:
+ case PseudoElement_ToolButtonMenu:
+ case PseudoElement_DockWidgetCloseButton:
+ case PseudoElement_DockWidgetFloatButton:
+ return Qt::AlignRight | Qt::AlignTop;
+
+ case PseudoElement_ScrollBarUpArrow:
+ case PseudoElement_ScrollBarDownArrow:
+ case PseudoElement_ScrollBarLeftArrow:
+ case PseudoElement_ScrollBarRightArrow:
+ case PseudoElement_SpinBoxUpArrow:
+ case PseudoElement_SpinBoxDownArrow:
+ case PseudoElement_ComboBoxArrow:
+ case PseudoElement_DownArrow:
+ case PseudoElement_ToolButtonMenuArrow:
+ case PseudoElement_SliderGroove:
+ return Qt::AlignCenter;
+
+ case PseudoElement_GroupBoxTitle:
+ case PseudoElement_GroupBoxIndicator: // never used
+ return Qt::AlignLeft | Qt::AlignTop;
+
+ case PseudoElement_HeaderViewUpArrow:
+ case PseudoElement_HeaderViewDownArrow:
+ case PseudoElement_MenuRightArrow:
+ return Qt::AlignRight | Qt::AlignVCenter;
+
+ default:
+ return 0;
+ }
+}
+
+QSize QStyleSheetStyle::defaultSize(const QWidget *w, QSize sz, const QRect& rect, int pe) const
+{
+ QStyle *base = baseStyle();
+
+ switch (pe) {
+ case PseudoElement_Indicator:
+ case PseudoElement_MenuCheckMark:
+ if (sz.width() == -1)
+ sz.setWidth(base->pixelMetric(PM_IndicatorWidth, 0, w));
+ if (sz.height() == -1)
+ sz.setHeight(base->pixelMetric(PM_IndicatorHeight, 0, w));
+ break;
+
+ case PseudoElement_ExclusiveIndicator:
+ case PseudoElement_GroupBoxIndicator:
+ if (sz.width() == -1)
+ sz.setWidth(base->pixelMetric(PM_ExclusiveIndicatorWidth, 0, w));
+ if (sz.height() == -1)
+ sz.setHeight(base->pixelMetric(PM_ExclusiveIndicatorHeight, 0, w));
+ break;
+
+ case PseudoElement_PushButtonMenuIndicator: {
+ int pm = base->pixelMetric(PM_MenuButtonIndicator, 0, w);
+ if (sz.width() == -1)
+ sz.setWidth(pm);
+ if (sz.height() == -1)
+ sz.setHeight(pm);
+ }
+ break;
+
+ case PseudoElement_ComboBoxDropDown:
+ if (sz.width() == -1)
+ sz.setWidth(16);
+ break;
+
+ case PseudoElement_ComboBoxArrow:
+ case PseudoElement_DownArrow:
+ case PseudoElement_ToolButtonMenuArrow:
+ case PseudoElement_ToolButtonDownArrow:
+ case PseudoElement_MenuRightArrow:
+ if (sz.width() == -1)
+ sz.setWidth(13);
+ if (sz.height() == -1)
+ sz.setHeight(13);
+ break;
+
+ case PseudoElement_SpinBoxUpButton:
+ case PseudoElement_SpinBoxDownButton:
+ if (sz.width() == -1)
+ sz.setWidth(16);
+ if (sz.height() == -1)
+ sz.setHeight(rect.height()/2);
+ break;
+
+ case PseudoElement_ToolButtonMenu:
+ if (sz.width() == -1)
+ sz.setWidth(base->pixelMetric(PM_MenuButtonIndicator, 0, w));
+ break;
+
+ case PseudoElement_HeaderViewUpArrow:
+ case PseudoElement_HeaderViewDownArrow: {
+ int pm = base->pixelMetric(PM_HeaderMargin, 0, w);
+ if (sz.width() == -1)
+ sz.setWidth(pm);
+ if (sz.height() == 1)
+ sz.setHeight(pm);
+ break;
+ }
+
+ case PseudoElement_ScrollBarFirst:
+ case PseudoElement_ScrollBarLast:
+ case PseudoElement_ScrollBarAddLine:
+ case PseudoElement_ScrollBarSubLine:
+ case PseudoElement_ScrollBarSlider: {
+ int pm = pixelMetric(QStyle::PM_ScrollBarExtent, 0, w);
+ if (sz.width() == -1)
+ sz.setWidth(pm);
+ if (sz.height() == -1)
+ sz.setHeight(pm);
+ break;
+ }
+
+ case PseudoElement_DockWidgetCloseButton:
+ case PseudoElement_DockWidgetFloatButton: {
+ int iconSize = pixelMetric(PM_SmallIconSize, 0, w);
+ return QSize(iconSize, iconSize);
+ }
+
+ default:
+ break;
+ }
+
+ // expand to rectangle
+ if (sz.height() == -1)
+ sz.setHeight(rect.height());
+ if (sz.width() == -1)
+ sz.setWidth(rect.width());
+
+ return sz;
+}
+
+static PositionMode defaultPositionMode(int pe)
+{
+ switch (pe) {
+ case PseudoElement_ScrollBarFirst:
+ case PseudoElement_ScrollBarLast:
+ case PseudoElement_ScrollBarAddLine:
+ case PseudoElement_ScrollBarSubLine:
+ case PseudoElement_ScrollBarAddPage:
+ case PseudoElement_ScrollBarSubPage:
+ case PseudoElement_ScrollBarSlider:
+ case PseudoElement_SliderGroove:
+ case PseudoElement_SliderHandle:
+ case PseudoElement_TabWidgetPane:
+ return PositionMode_Absolute;
+ default:
+ return PositionMode_Static;
+ }
+}
+
+QRect QStyleSheetStyle::positionRect(const QWidget *w, const QRenderRule &rule2, int pe,
+ const QRect &originRect, Qt::LayoutDirection dir) const
+{
+ const QStyleSheetPositionData *p = rule2.position();
+ PositionMode mode = (p && p->mode != PositionMode_Unknown) ? p->mode : defaultPositionMode(pe);
+ Qt::Alignment position = (p && p->position != 0) ? p->position : defaultPosition(pe);
+ QRect r;
+
+ if (mode != PositionMode_Absolute) {
+ QSize sz = defaultSize(w, rule2.size(), originRect, pe);
+ sz = sz.expandedTo(rule2.minimumContentsSize());
+ r = QStyle::alignedRect(dir, position, sz, originRect);
+ if (p) {
+ int left = p->left ? p->left : -p->right;
+ int top = p->top ? p->top : -p->bottom;
+ r.translate(dir == Qt::LeftToRight ? left : -left, top);
+ }
+ } else {
+ r = p ? originRect.adjusted(dir == Qt::LeftToRight ? p->left : p->right, p->top,
+ dir == Qt::LeftToRight ? -p->right : -p->left, -p->bottom)
+ : originRect;
+ if (rule2.hasContentsSize()) {
+ QSize sz = rule2.size().expandedTo(rule2.minimumContentsSize());
+ if (sz.width() == -1) sz.setWidth(r.width());
+ if (sz.height() == -1) sz.setHeight(r.height());
+ r = QStyle::alignedRect(dir, position, sz, r);
+ }
+ }
+ return r;
+}
+
+QRect QStyleSheetStyle::positionRect(const QWidget *w, const QRenderRule& rule1, const QRenderRule& rule2, int pe,
+ const QRect& rect, Qt::LayoutDirection dir) const
+{
+ const QStyleSheetPositionData *p = rule2.position();
+ Origin origin = (p && p->origin != Origin_Unknown) ? p->origin : defaultOrigin(pe);
+ QRect originRect = rule1.originRect(rect, origin);
+ return positionRect(w, rule2, pe, originRect, dir);
+}
+
+
+/** \internal
+ For widget that have an embedded widget (such as combobox) return that embedded widget.
+ otherwise return the widget itself
+ */
+static QWidget *embeddedWidget(QWidget *w)
+{
+#ifndef QT_NO_COMBOBOX
+ if (QComboBox *cmb = qobject_cast<QComboBox *>(w)) {
+ if (cmb->isEditable())
+ return cmb->lineEdit();
+ else
+ return cmb;
+ }
+#endif
+
+#ifndef QT_NO_SPINBOX
+ if (QAbstractSpinBox *sb = qobject_cast<QAbstractSpinBox *>(w))
+ return sb->findChild<QLineEdit *>();
+#endif
+
+#ifndef QT_NO_SCROLLAREA
+ if (QAbstractScrollArea *sa = qobject_cast<QAbstractScrollArea *>(w))
+ return sa->viewport();
+#endif
+
+ return w;
+}
+
+/** \internal
+ in case w is an embedded widget, return the container widget
+ (i.e, the widget for which the rules actualy apply)
+ (exemple, if w is a lineedit embedded in a combobox, return the combobox)
+
+ if w is not embedded, return w itself
+*/
+static QWidget *containerWidget(const QWidget *w)
+{
+#ifndef QT_NO_LINEEDIT
+ if (qobject_cast<const QLineEdit *>(w)) {
+ //if the QLineEdit is an embeddedWidget, we need the rule of the real widget
+#ifndef QT_NO_COMBOBOX
+ if (qobject_cast<const QComboBox *>(w->parentWidget()))
+ return w->parentWidget();
+#endif
+#ifndef QT_NO_SPINBOX
+ if (qobject_cast<const QAbstractSpinBox *>(w->parentWidget()))
+ return w->parentWidget();
+#endif
+ }
+#endif // QT_NO_LINEEDIT
+
+#ifndef QT_NO_SCROLLAREA
+ if (const QAbstractScrollArea *sa = qobject_cast<const QAbstractScrollArea *>(w->parentWidget())) {
+ if (sa->viewport() == w)
+ return w->parentWidget();
+ }
+#endif
+
+ return const_cast<QWidget *>(w);
+}
+
+/** \internal
+ returns true if the widget can NOT be styled directly
+ */
+static bool unstylable(const QWidget *w)
+{
+ if (w->windowType() == Qt::Desktop)
+ return true;
+
+ if (!w->styleSheet().isEmpty())
+ return false;
+
+ if (containerWidget(w) != w)
+ return true;
+
+#ifndef QT_NO_FRAME
+ // detect QComboBoxPrivateContainer
+ else if (qobject_cast<const QFrame *>(w)) {
+ if (0
+#ifndef QT_NO_COMBOBOX
+ || qobject_cast<const QComboBox *>(w->parentWidget())
+#endif
+ )
+ return true;
+ }
+#endif
+ return false;
+}
+
+static quint64 extendedPseudoClass(const QWidget *w)
+{
+ quint64 pc = w->isWindow() ? quint64(PseudoClass_Window) : 0;
+ if (const QAbstractSlider *slider = qobject_cast<const QAbstractSlider *>(w)) {
+ pc |= ((slider->orientation() == Qt::Vertical) ? PseudoClass_Vertical : PseudoClass_Horizontal);
+ } else
+#ifndef QT_NO_COMBOBOX
+ if (const QComboBox *combo = qobject_cast<const QComboBox *>(w)) {
+ if (combo->isEditable())
+ pc |= (combo->isEditable() ? PseudoClass_Editable : PseudoClass_ReadOnly);
+ } else
+#endif
+#ifndef QT_NO_LINEEDIT
+ if (const QLineEdit *edit = qobject_cast<const QLineEdit *>(w)) {
+ pc |= (edit->isReadOnly() ? PseudoClass_ReadOnly : PseudoClass_Editable);
+ } else
+#endif
+ { } // required for the above ifdef'ery to work
+ return pc;
+}
+
+// sets up the geometry of the widget. We set a dynamic property when
+// we modify the min/max size of the widget. The min/max size is restored
+// to their original value when a new stylesheet that does not contain
+// the CSS properties is set and when the widget has this dynamic property set.
+// This way we don't trample on users who had setup a min/max size in code and
+// don't use stylesheets at all.
+void QStyleSheetStyle::setGeometry(QWidget *w)
+{
+ QRenderRule rule = renderRule(w, PseudoElement_None, PseudoClass_Enabled | extendedPseudoClass(w));
+ const QStyleSheetGeometryData *geo = rule.geometry();
+ if (w->property("_q_stylesheet_minw").toBool()
+ && ((!rule.hasGeometry() || geo->minWidth == -1))) {
+ w->setMinimumWidth(0);
+ w->setProperty("_q_stylesheet_minw", QVariant());
+ }
+ if (w->property("_q_stylesheet_minh").toBool()
+ && ((!rule.hasGeometry() || geo->minHeight == -1))) {
+ w->setMinimumHeight(0);
+ w->setProperty("_q_stylesheet_minh", QVariant());
+ }
+ if (w->property("_q_stylesheet_maxw").toBool()
+ && ((!rule.hasGeometry() || geo->maxWidth == -1))) {
+ w->setMaximumWidth(QWIDGETSIZE_MAX);
+ w->setProperty("_q_stylesheet_maxw", QVariant());
+ }
+ if (w->property("_q_stylesheet_maxh").toBool()
+ && ((!rule.hasGeometry() || geo->maxHeight == -1))) {
+ w->setMaximumHeight(QWIDGETSIZE_MAX);
+ w->setProperty("_q_stylesheet_maxh", QVariant());
+ }
+
+
+ if (rule.hasGeometry()) {
+ if (geo->minWidth != -1) {
+ w->setProperty("_q_stylesheet_minw", true);
+ w->setMinimumWidth(rule.boxSize(QSize(qMax(geo->width, geo->minWidth), 0)).width());
+ }
+ if (geo->minHeight != -1) {
+ w->setProperty("_q_stylesheet_minh", true);
+ w->setMinimumHeight(rule.boxSize(QSize(0, qMax(geo->height, geo->minHeight))).height());
+ }
+ if (geo->maxWidth != -1) {
+ w->setProperty("_q_stylesheet_maxw", true);
+ w->setMaximumWidth(rule.boxSize(QSize(qMin(geo->width == -1 ? QWIDGETSIZE_MAX : geo->width,
+ geo->maxWidth == -1 ? QWIDGETSIZE_MAX : geo->maxWidth), 0)).width());
+ }
+ if (geo->maxHeight != -1) {
+ w->setProperty("_q_stylesheet_maxh", true);
+ w->setMaximumHeight(rule.boxSize(QSize(0, qMin(geo->height == -1 ? QWIDGETSIZE_MAX : geo->height,
+ geo->maxHeight == -1 ? QWIDGETSIZE_MAX : geo->maxHeight))).height());
+ }
+ }
+}
+
+void QStyleSheetStyle::setProperties(QWidget *w)
+{
+ QHash<QString, QVariant> propertyHash;
+ QVector<Declaration> decls = declarations(styleRules(w), QString());
+
+ // run through the declarations in order
+ for (int i = 0; i < decls.count(); i++) {
+ const Declaration &decl = decls.at(i);
+ QString property = decl.d->property;
+ if (!property.startsWith(QLatin1String("qproperty-"), Qt::CaseInsensitive))
+ continue;
+ property.remove(0, 10); // strip "qproperty-"
+ const QVariant value = w->property(property.toLatin1());
+ const QMetaObject *metaObject = w->metaObject();
+ int index = metaObject->indexOfProperty(property.toLatin1());
+ if (index == -1) {
+ qWarning() << w << " does not have a property named " << property;
+ continue;
+ }
+ QMetaProperty metaProperty = metaObject->property(index);
+ if (!metaProperty.isWritable() || !metaProperty.isDesignable()) {
+ qWarning() << w << " cannot design property named " << property;
+ continue;
+ }
+ QVariant v;
+ switch (value.type()) {
+ // ### Qt 5
+// case QVariant::Icon: v = decl.iconValue(); break;
+ case QVariant::Image: v = QImage(decl.uriValue()); break;
+ case QVariant::Pixmap: v = QPixmap(decl.uriValue()); break;
+ case QVariant::Rect: v = decl.rectValue(); break;
+ case QVariant::Size: v = decl.sizeValue(); break;
+ case QVariant::Color: v = decl.colorValue(); break;
+ case QVariant::Brush: v = decl.brushValue(); break;
+#ifndef QT_NO_SHORTCUT
+ case QVariant::KeySequence: v = QKeySequence(decl.d->values.at(0).variant.toString()); break;
+#endif
+ default: v = decl.d->values.at(0).variant; break;
+ }
+ propertyHash[property] = v;
+ }
+ // apply the values
+ const QList<QString> properties = propertyHash.keys();
+ for (int i = 0; i < properties.count(); i++) {
+ const QString &property = properties.at(i);
+ w->setProperty(property.toLatin1(), propertyHash[property]);
+ }
+}
+
+void QStyleSheetStyle::setPalette(QWidget *w)
+{
+ struct RuleRoleMap {
+ int state;
+ QPalette::ColorGroup group;
+ } map[3] = {
+ { int(PseudoClass_Active | PseudoClass_Enabled), QPalette::Active },
+ { PseudoClass_Disabled, QPalette::Disabled },
+ { PseudoClass_Enabled, QPalette::Inactive }
+ };
+
+ QPalette p = w->palette();
+ QWidget *ew = embeddedWidget(w);
+
+ for (int i = 0; i < 3; i++) {
+ QRenderRule rule = renderRule(w, PseudoElement_None, map[i].state | extendedPseudoClass(w));
+ if (i == 0) {
+ if (!w->property("_q_styleSheetWidgetFont").isValid()) {
+ saveWidgetFont(w, w->font());
+ }
+ updateStyleSheetFont(w);
+ if (ew != w)
+ updateStyleSheetFont(ew);
+ }
+
+ rule.configurePalette(&p, map[i].group, ew, ew != w);
+ }
+
+ styleSheetCaches->customPaletteWidgets.insert(w, w->palette());
+ w->setPalette(p);
+ if (ew != w)
+ ew->setPalette(p);
+}
+
+void QStyleSheetStyle::unsetPalette(QWidget *w)
+{
+ if (styleSheetCaches->customPaletteWidgets.contains(w)) {
+ QPalette p = styleSheetCaches->customPaletteWidgets.value(w);
+ w->setPalette(p);
+ QWidget *ew = embeddedWidget(w);
+ if (ew != w)
+ ew->setPalette(p);
+ styleSheetCaches->customPaletteWidgets.remove(w);
+ }
+ QVariant oldFont = w->property("_q_styleSheetWidgetFont");
+ if (oldFont.isValid()) {
+ w->setFont(qvariant_cast<QFont>(oldFont));
+ }
+ if (styleSheetCaches->autoFillDisabledWidgets.contains(w)) {
+ embeddedWidget(w)->setAutoFillBackground(true);
+ styleSheetCaches->autoFillDisabledWidgets.remove(w);
+ }
+}
+
+static void updateWidgets(const QList<const QWidget *>& widgets)
+{
+ if (!styleSheetCaches->styleRulesCache.isEmpty() || !styleSheetCaches->hasStyleRuleCache.isEmpty() || !styleSheetCaches->renderRulesCache.isEmpty()) {
+ for (int i = 0; i < widgets.size(); ++i) {
+ const QWidget *widget = widgets.at(i);
+ styleSheetCaches->styleRulesCache.remove(widget);
+ styleSheetCaches->hasStyleRuleCache.remove(widget);
+ styleSheetCaches->renderRulesCache.remove(widget);
+ }
+ }
+ for (int i = 0; i < widgets.size(); ++i) {
+ QWidget *widget = const_cast<QWidget *>(widgets.at(i));
+ if (widget == 0)
+ continue;
+ widget->style()->polish(widget);
+ QEvent event(QEvent::StyleChange);
+ QApplication::sendEvent(widget, &event);
+ widget->update();
+ widget->updateGeometry();
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// The stylesheet style
+int QStyleSheetStyle::numinstances = 0;
+
+QStyleSheetStyle::QStyleSheetStyle(QStyle *base)
+ : QWindowsStyle(*new QStyleSheetStylePrivate), base(base), refcount(1)
+{
+ ++numinstances;
+ if (numinstances == 1) {
+ styleSheetCaches = new QStyleSheetStyleCaches;
+ }
+}
+
+QStyleSheetStyle::~QStyleSheetStyle()
+{
+ --numinstances;
+ if (numinstances == 0) {
+ delete styleSheetCaches;
+ }
+}
+QStyle *QStyleSheetStyle::baseStyle() const
+{
+ if (base)
+ return base;
+ if (QStyleSheetStyle *me = qobject_cast<QStyleSheetStyle *>(QApplication::style()))
+ return me->base;
+ return QApplication::style();
+}
+
+void QStyleSheetStyleCaches::widgetDestroyed(QObject *o)
+{
+ styleRulesCache.remove((const QWidget *)o);
+ hasStyleRuleCache.remove((const QWidget *)o);
+ renderRulesCache.remove((const QWidget *)o);
+ customPaletteWidgets.remove((const QWidget *)o);
+ styleSheetCache.remove((const QWidget *)o);
+ autoFillDisabledWidgets.remove((const QWidget *)o);
+}
+
+void QStyleSheetStyleCaches::styleDestroyed(QObject *o)
+{
+ styleSheetCache.remove(o);
+}
+
+/*!
+ * Make sure that the cache will be clean by connecting destroyed if needed.
+ * return false if the widget is not stylable;
+ */
+bool QStyleSheetStyle::initWidget(const QWidget *w) const
+{
+ if (!w)
+ return false;
+ if(w->testAttribute(Qt::WA_StyleSheet))
+ return true;
+
+ if(unstylable(w))
+ return false;
+
+ const_cast<QWidget *>(w)->setAttribute(Qt::WA_StyleSheet, true);
+ QObject::connect(w, SIGNAL(destroyed(QObject*)), styleSheetCaches, SLOT(widgetDestroyed(QObject*)), Qt::UniqueConnection);
+ return true;
+}
+
+void QStyleSheetStyle::polish(QWidget *w)
+{
+ baseStyle()->polish(w);
+ RECURSION_GUARD(return)
+
+ if (!initWidget(w))
+ return;
+
+ if (styleSheetCaches->styleRulesCache.contains(w)) {
+ // the widget accessed its style pointer before polish (or repolish)
+ // (exemple: the QAbstractSpinBox constructor ask for the stylehint)
+ styleSheetCaches->styleRulesCache.remove(w);
+ styleSheetCaches->hasStyleRuleCache.remove(w);
+ styleSheetCaches->renderRulesCache.remove(w);
+ }
+ setGeometry(w);
+ setProperties(w);
+ unsetPalette(w);
+ setPalette(w);
+
+ //set the WA_Hover attribute if one of the selector depends of the hover state
+ QVector<StyleRule> rules = styleRules(w);
+ for (int i = 0; i < rules.count(); i++) {
+ const Selector& selector = rules.at(i).selectors.at(0);
+ quint64 negated = 0;
+ quint64 cssClass = selector.pseudoClass(&negated);
+ if ( cssClass & PseudoClass_Hover || negated & PseudoClass_Hover) {
+ w->setAttribute(Qt::WA_Hover);
+ embeddedWidget(w)->setAttribute(Qt::WA_Hover);
+ }
+ }
+
+
+#ifndef QT_NO_SCROLLAREA
+ if (QAbstractScrollArea *sa = qobject_cast<QAbstractScrollArea *>(w)) {
+ QRenderRule rule = renderRule(sa, PseudoElement_None, PseudoClass_Enabled);
+ if ((rule.hasBorder() && rule.border()->hasBorderImage())
+ || (rule.hasBackground() && !rule.background()->pixmap.isNull())) {
+ QObject::connect(sa->horizontalScrollBar(), SIGNAL(valueChanged(int)),
+ sa, SLOT(update()), Qt::UniqueConnection);
+ QObject::connect(sa->verticalScrollBar(), SIGNAL(valueChanged(int)),
+ sa, SLOT(update()), Qt::UniqueConnection);
+ }
+ }
+#endif
+
+#ifndef QT_NO_PROGRESSBAR
+ if (QProgressBar *pb = qobject_cast<QProgressBar *>(w)) {
+ QWindowsStyle::polish(pb);
+ }
+#endif
+
+ QRenderRule rule = renderRule(w, PseudoElement_None, PseudoClass_Any);
+ if (rule.hasDrawable() || rule.hasBox()) {
+ if (w->metaObject() == &QWidget::staticMetaObject
+#ifndef QT_NO_ITEMVIEWS
+ || qobject_cast<QHeaderView *>(w)
+#endif
+#ifndef QT_NO_TABBAR
+ || qobject_cast<QTabBar *>(w)
+#endif
+#ifndef QT_NO_FRAME
+ || qobject_cast<QFrame *>(w)
+#endif
+#ifndef QT_NO_MAINWINDOW
+ || qobject_cast<QMainWindow *>(w)
+#endif
+#ifndef QT_NO_MDIAREA
+ || qobject_cast<QMdiSubWindow *>(w)
+#endif
+#ifndef QT_NO_MENUBAR
+ || qobject_cast<QMenuBar *>(w)
+#endif
+ || qobject_cast<QDialog *>(w)) {
+ w->setAttribute(Qt::WA_StyledBackground, true);
+ }
+ QWidget *ew = embeddedWidget(w);
+ if (ew->autoFillBackground()) {
+ ew->setAutoFillBackground(false);
+ styleSheetCaches->autoFillDisabledWidgets.insert(w);
+ if (ew != w) { //eg. viewport of a scrollarea
+ //(in order to draw the background anyway in case we don't.)
+ ew->setAttribute(Qt::WA_StyledBackground, true);
+ }
+ }
+ if (!rule.hasBackground() || rule.background()->isTransparent() || rule.hasBox()
+ || (!rule.hasNativeBorder() && !rule.border()->isOpaque()))
+ w->setAttribute(Qt::WA_OpaquePaintEvent, false);
+ }
+}
+
+void QStyleSheetStyle::polish(QApplication *app)
+{
+ baseStyle()->polish(app);
+}
+
+void QStyleSheetStyle::polish(QPalette &pal)
+{
+ baseStyle()->polish(pal);
+}
+
+void QStyleSheetStyle::repolish(QWidget *w)
+{
+ QList<const QWidget *> children = w->findChildren<const QWidget *>(QString());
+ children.append(w);
+ styleSheetCaches->styleSheetCache.remove(w);
+ updateWidgets(children);
+}
+
+void QStyleSheetStyle::repolish(QApplication *app)
+{
+ Q_UNUSED(app);
+ const QList<const QWidget*> allWidgets = styleSheetCaches->styleRulesCache.keys();
+ styleSheetCaches->styleSheetCache.remove(qApp);
+ styleSheetCaches->styleRulesCache.clear();
+ styleSheetCaches->hasStyleRuleCache.clear();
+ styleSheetCaches->renderRulesCache.clear();
+ updateWidgets(allWidgets);
+}
+
+void QStyleSheetStyle::unpolish(QWidget *w)
+{
+ if (!w || !w->testAttribute(Qt::WA_StyleSheet)) {
+ baseStyle()->unpolish(w);
+ return;
+ }
+
+ styleSheetCaches->styleRulesCache.remove(w);
+ styleSheetCaches->hasStyleRuleCache.remove(w);
+ styleSheetCaches->renderRulesCache.remove(w);
+ styleSheetCaches->styleSheetCache.remove(w);
+ unsetPalette(w);
+ w->setProperty("_q_stylesheet_minw", QVariant());
+ w->setProperty("_q_stylesheet_minh", QVariant());
+ w->setProperty("_q_stylesheet_maxw", QVariant());
+ w->setProperty("_q_stylesheet_maxh", QVariant());
+ w->setAttribute(Qt::WA_StyleSheet, false);
+ QObject::disconnect(w, 0, this, 0);
+#ifndef QT_NO_SCROLLAREA
+ if (QAbstractScrollArea *sa = qobject_cast<QAbstractScrollArea *>(w)) {
+ QObject::disconnect(sa->horizontalScrollBar(), SIGNAL(valueChanged(int)),
+ sa, SLOT(update()));
+ QObject::disconnect(sa->verticalScrollBar(), SIGNAL(valueChanged(int)),
+ sa, SLOT(update()));
+ }
+#endif
+#ifndef QT_NO_PROGRESSBAR
+ if (QProgressBar *pb = qobject_cast<QProgressBar *>(w))
+ QWindowsStyle::unpolish(pb);
+#endif
+ baseStyle()->unpolish(w);
+}
+
+void QStyleSheetStyle::unpolish(QApplication *app)
+{
+ baseStyle()->unpolish(app);
+ RECURSION_GUARD(return)
+ styleSheetCaches->styleRulesCache.clear();
+ styleSheetCaches->hasStyleRuleCache.clear();
+ styleSheetCaches->renderRulesCache.clear();
+ styleSheetCaches->styleSheetCache.remove(qApp);
+}
+
+#ifndef QT_NO_TABBAR
+inline static bool verticalTabs(QTabBar::Shape shape)
+{
+ return shape == QTabBar::RoundedWest
+ || shape == QTabBar::RoundedEast
+ || shape == QTabBar::TriangularWest
+ || shape == QTabBar::TriangularEast;
+}
+#endif // QT_NO_TABBAR
+
+void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
+ const QWidget *w) const
+{
+ RECURSION_GUARD(baseStyle()->drawComplexControl(cc, opt, p, w); return)
+
+ QRenderRule rule = renderRule(w, opt);
+
+ switch (cc) {
+ case CC_ComboBox:
+ if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
+ QStyleOptionComboBox cmbOpt(*cmb);
+ cmbOpt.rect = rule.borderRect(opt->rect);
+ if (rule.hasNativeBorder()) {
+ rule.drawBackgroundImage(p, cmbOpt.rect);
+ rule.configurePalette(&cmbOpt.palette, QPalette::ButtonText, QPalette::Button);
+ bool customDropDown = (opt->subControls & QStyle::SC_ComboBoxArrow)
+ && (hasStyleRule(w, PseudoElement_ComboBoxDropDown) || hasStyleRule(w, PseudoElement_ComboBoxArrow));
+ if (customDropDown)
+ cmbOpt.subControls &= ~QStyle::SC_ComboBoxArrow;
+ if (rule.baseStyleCanDraw()) {
+ baseStyle()->drawComplexControl(cc, &cmbOpt, p, w);
+ } else {
+ QWindowsStyle::drawComplexControl(cc, &cmbOpt, p, w);
+ }
+ if (!customDropDown)
+ return;
+ } else {
+ rule.drawRule(p, opt->rect);
+ }
+
+ if (opt->subControls & QStyle::SC_ComboBoxArrow) {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_ComboBoxDropDown);
+ if (subRule.hasDrawable()) {
+ QRect r = subControlRect(CC_ComboBox, opt, SC_ComboBoxArrow, w);
+ subRule.drawRule(p, r);
+ QRenderRule subRule2 = renderRule(w, opt, PseudoElement_ComboBoxArrow);
+ r = positionRect(w, subRule, subRule2, PseudoElement_ComboBoxArrow, r, opt->direction);
+ subRule2.drawRule(p, r);
+ } else {
+ cmbOpt.subControls = QStyle::SC_ComboBoxArrow;
+ QWindowsStyle::drawComplexControl(cc, &cmbOpt, p, w);
+ }
+ }
+
+ return;
+ }
+ break;
+
+#ifndef QT_NO_SPINBOX
+ case CC_SpinBox:
+ if (const QStyleOptionSpinBox *spin = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
+ QStyleOptionSpinBox spinOpt(*spin);
+ rule.configurePalette(&spinOpt.palette, QPalette::ButtonText, QPalette::Button);
+ rule.configurePalette(&spinOpt.palette, QPalette::Text, QPalette::Base);
+ spinOpt.rect = rule.borderRect(opt->rect);
+ bool customUp = true, customDown = true;
+ QRenderRule upRule = renderRule(w, opt, PseudoElement_SpinBoxUpButton);
+ QRenderRule downRule = renderRule(w, opt, PseudoElement_SpinBoxDownButton);
+ bool upRuleMatch = upRule.hasGeometry() || upRule.hasPosition();
+ bool downRuleMatch = downRule.hasGeometry() || downRule.hasPosition();
+ if (rule.hasNativeBorder() && !upRuleMatch && !downRuleMatch) {
+ rule.drawBackgroundImage(p, spinOpt.rect);
+ customUp = (opt->subControls & QStyle::SC_SpinBoxUp)
+ && (hasStyleRule(w, PseudoElement_SpinBoxUpButton) || hasStyleRule(w, PseudoElement_UpArrow));
+ if (customUp)
+ spinOpt.subControls &= ~QStyle::SC_SpinBoxUp;
+ customDown = (opt->subControls & QStyle::SC_SpinBoxDown)
+ && (hasStyleRule(w, PseudoElement_SpinBoxDownButton) || hasStyleRule(w, PseudoElement_DownArrow));
+ if (customDown)
+ spinOpt.subControls &= ~QStyle::SC_SpinBoxDown;
+ if (rule.baseStyleCanDraw()) {
+ baseStyle()->drawComplexControl(cc, &spinOpt, p, w);
+ } else {
+ QWindowsStyle::drawComplexControl(cc, &spinOpt, p, w);
+ }
+ if (!customUp && !customDown)
+ return;
+ } else {
+ rule.drawRule(p, opt->rect);
+ }
+
+ if ((opt->subControls & QStyle::SC_SpinBoxUp) && customUp) {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_SpinBoxUpButton);
+ if (subRule.hasDrawable()) {
+ QRect r = subControlRect(CC_SpinBox, opt, SC_SpinBoxUp, w);
+ subRule.drawRule(p, r);
+ QRenderRule subRule2 = renderRule(w, opt, PseudoElement_SpinBoxUpArrow);
+ r = positionRect(w, subRule, subRule2, PseudoElement_SpinBoxUpArrow, r, opt->direction);
+ subRule2.drawRule(p, r);
+ } else {
+ spinOpt.subControls = QStyle::SC_SpinBoxUp;
+ QWindowsStyle::drawComplexControl(cc, &spinOpt, p, w);
+ }
+ }
+
+ if ((opt->subControls & QStyle::SC_SpinBoxDown) && customDown) {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_SpinBoxDownButton);
+ if (subRule.hasDrawable()) {
+ QRect r = subControlRect(CC_SpinBox, opt, SC_SpinBoxDown, w);
+ subRule.drawRule(p, r);
+ QRenderRule subRule2 = renderRule(w, opt, PseudoElement_SpinBoxDownArrow);
+ r = positionRect(w, subRule, subRule2, PseudoElement_SpinBoxDownArrow, r, opt->direction);
+ subRule2.drawRule(p, r);
+ } else {
+ spinOpt.subControls = QStyle::SC_SpinBoxDown;
+ QWindowsStyle::drawComplexControl(cc, &spinOpt, p, w);
+ }
+ }
+ return;
+ }
+ break;
+#endif // QT_NO_SPINBOX
+
+ case CC_GroupBox:
+ if (const QStyleOptionGroupBox *gb = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
+
+ QRect labelRect, checkBoxRect, titleRect, frameRect;
+ bool hasTitle = (gb->subControls & QStyle::SC_GroupBoxCheckBox) || !gb->text.isEmpty();
+
+ if (!rule.hasDrawable() && (!hasTitle || !hasStyleRule(w, PseudoElement_GroupBoxTitle))
+ && !hasStyleRule(w, PseudoElement_Indicator) && !rule.hasBox() && !rule.hasFont && !rule.hasPalette()) {
+ // let the native style draw the combobox if there is no style for it.
+ break;
+ }
+ rule.drawBackground(p, opt->rect);
+
+ QRenderRule titleRule = renderRule(w, opt, PseudoElement_GroupBoxTitle);
+ bool clipSet = false;
+
+ if (hasTitle) {
+ labelRect = subControlRect(CC_GroupBox, opt, SC_GroupBoxLabel, w);
+ //Some native style (such as mac) may return a too small rectangle (because they use smaller fonts), so we may need to expand it a little bit.
+ labelRect.setSize(labelRect.size().expandedTo(ParentStyle::subControlRect(CC_GroupBox, opt, SC_GroupBoxLabel, w).size()));
+ if (gb->subControls & QStyle::SC_GroupBoxCheckBox) {
+ checkBoxRect = subControlRect(CC_GroupBox, opt, SC_GroupBoxCheckBox, w);
+ titleRect = titleRule.boxRect(checkBoxRect.united(labelRect));
+ } else {
+ titleRect = titleRule.boxRect(labelRect);
+ }
+ if (!titleRule.hasBackground() || !titleRule.background()->isTransparent()) {
+ clipSet = true;
+ p->save();
+ p->setClipRegion(QRegion(opt->rect) - titleRect);
+ }
+ }
+
+ frameRect = subControlRect(CC_GroupBox, opt, SC_GroupBoxFrame, w);
+ QStyleOptionFrameV2 frame;
+ frame.QStyleOption::operator=(*gb);
+ frame.features = gb->features;
+ frame.lineWidth = gb->lineWidth;
+ frame.midLineWidth = gb->midLineWidth;
+ frame.rect = frameRect;
+ drawPrimitive(PE_FrameGroupBox, &frame, p, w);
+
+ if (clipSet)
+ p->restore();
+
+ // draw background and frame of the title
+ if (hasTitle)
+ titleRule.drawRule(p, titleRect);
+
+ // draw the indicator
+ if (gb->subControls & QStyle::SC_GroupBoxCheckBox) {
+ QStyleOptionButton box;
+ box.QStyleOption::operator=(*gb);
+ box.rect = checkBoxRect;
+ drawPrimitive(PE_IndicatorCheckBox, &box, p, w);
+ }
+
+ // draw the text
+ if (!gb->text.isEmpty()) {
+ int alignment = int(Qt::AlignCenter | Qt::TextShowMnemonic);
+ if (!styleHint(QStyle::SH_UnderlineShortcut, opt, w)) {
+ alignment |= Qt::TextHideMnemonic;
+ }
+
+ QPalette pal = gb->palette;
+ if (gb->textColor.isValid())
+ pal.setColor(QPalette::WindowText, gb->textColor);
+ titleRule.configurePalette(&pal, QPalette::WindowText, QPalette::Window);
+ drawItemText(p, labelRect, alignment, pal, gb->state & State_Enabled,
+ gb->text, QPalette::WindowText);
+
+ if (gb->state & State_HasFocus) {
+ QStyleOptionFocusRect fropt;
+ fropt.QStyleOption::operator=(*gb);
+ fropt.rect = labelRect;
+ drawPrimitive(PE_FrameFocusRect, &fropt, p, w);
+ }
+ }
+
+ return;
+ }
+ break;
+
+ case CC_ToolButton:
+ if (const QStyleOptionToolButton *tool = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
+ QStyleOptionToolButton toolOpt(*tool);
+ rule.configurePalette(&toolOpt.palette, QPalette::ButtonText, QPalette::Button);
+ toolOpt.font = rule.font.resolve(toolOpt.font);
+ toolOpt.rect = rule.borderRect(opt->rect);
+ bool customArrow = (tool->features & (QStyleOptionToolButton::HasMenu | QStyleOptionToolButton::MenuButtonPopup));
+ bool customDropDown = tool->features & QStyleOptionToolButton::MenuButtonPopup;
+ if (rule.hasNativeBorder()) {
+ if (tool->subControls & SC_ToolButton) {
+ //in some case (eg. the button is "auto raised") the style doesn't draw the background
+ //so we need to draw the background.
+ // use the same condition as in QCommonStyle
+ State bflags = tool->state & ~State_Sunken;
+ if (bflags & State_AutoRaise && (!(bflags & State_MouseOver) || !(bflags & State_Enabled)))
+ bflags &= ~State_Raised;
+ if (tool->state & State_Sunken && tool->activeSubControls & SC_ToolButton)
+ bflags |= State_Sunken;
+ if (!(bflags & (State_Sunken | State_On | State_Raised)))
+ rule.drawBackground(p, toolOpt.rect);
+ }
+ customArrow = customArrow && hasStyleRule(w, PseudoElement_ToolButtonDownArrow);
+ if (customArrow)
+ toolOpt.features &= ~QStyleOptionToolButton::HasMenu;
+ customDropDown = customDropDown && hasStyleRule(w, PseudoElement_ToolButtonMenu);
+ if (customDropDown)
+ toolOpt.subControls &= ~QStyle::SC_ToolButtonMenu;
+
+ if (rule.baseStyleCanDraw() && !(tool->features & QStyleOptionToolButton::Arrow)) {
+ baseStyle()->drawComplexControl(cc, &toolOpt, p, w);
+ } else {
+ QWindowsStyle::drawComplexControl(cc, &toolOpt, p, w);
+ }
+
+ if (!customArrow && !customDropDown)
+ return;
+ } else {
+ rule.drawRule(p, opt->rect);
+ toolOpt.rect = rule.contentsRect(opt->rect);
+ if (rule.hasFont)
+ toolOpt.font = rule.font;
+ drawControl(CE_ToolButtonLabel, &toolOpt, p, w);
+ }
+
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_ToolButtonMenu);
+ QRect r = subControlRect(CC_ToolButton, opt, QStyle::SC_ToolButtonMenu, w);
+ if (customDropDown) {
+ if (opt->subControls & QStyle::SC_ToolButtonMenu) {
+ if (subRule.hasDrawable()) {
+ subRule.drawRule(p, r);
+ } else {
+ toolOpt.rect = r;
+ baseStyle()->drawPrimitive(PE_IndicatorButtonDropDown, &toolOpt, p, w);
+ }
+ }
+ }
+
+ if (customArrow) {
+ QRenderRule subRule2 = customDropDown ? renderRule(w, opt, PseudoElement_ToolButtonMenuArrow)
+ : renderRule(w, opt, PseudoElement_ToolButtonDownArrow);
+ QRect r2 = customDropDown
+ ? positionRect(w, subRule, subRule2, PseudoElement_ToolButtonMenuArrow, r, opt->direction)
+ : positionRect(w, rule, subRule2, PseudoElement_ToolButtonDownArrow, opt->rect, opt->direction);
+ if (subRule2.hasDrawable()) {
+ subRule2.drawRule(p, r2);
+ } else {
+ toolOpt.rect = r2;
+ baseStyle()->drawPrimitive(QStyle::PE_IndicatorArrowDown, &toolOpt, p, w);
+ }
+ }
+
+ return;
+ }
+ break;
+
+#ifndef QT_NO_SCROLLBAR
+ case CC_ScrollBar:
+ if (const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
+ QStyleOptionSlider sbOpt(*sb);
+ if (!rule.hasDrawable()) {
+ sbOpt.rect = rule.borderRect(opt->rect);
+ rule.drawBackgroundImage(p, opt->rect);
+ baseStyle()->drawComplexControl(cc, &sbOpt, p, w);
+ } else {
+ rule.drawRule(p, opt->rect);
+ QWindowsStyle::drawComplexControl(cc, opt, p, w);
+ }
+ return;
+ }
+ break;
+#endif // QT_NO_SCROLLBAR
+
+#ifndef QT_NO_SLIDER
+ case CC_Slider:
+ if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
+ rule.drawRule(p, opt->rect);
+
+ QRenderRule grooveSubRule = renderRule(w, opt, PseudoElement_SliderGroove);
+ QRenderRule handleSubRule = renderRule(w, opt, PseudoElement_SliderHandle);
+ if (!grooveSubRule.hasDrawable()) {
+ QStyleOptionSlider slOpt(*slider);
+ bool handleHasRule = handleSubRule.hasDrawable();
+ // If the style specifies a different handler rule, draw the groove without the handler.
+ if (handleHasRule)
+ slOpt.subControls &= ~SC_SliderHandle;
+ baseStyle()->drawComplexControl(cc, &slOpt, p, w);
+ if (!handleHasRule)
+ return;
+ }
+
+ QRect gr = subControlRect(cc, opt, SC_SliderGroove, w);
+ if (slider->subControls & SC_SliderGroove) {
+ grooveSubRule.drawRule(p, gr);
+ }
+
+ if (slider->subControls & SC_SliderHandle) {
+ QRect hr = subControlRect(cc, opt, SC_SliderHandle, w);
+
+ QRenderRule subRule1 = renderRule(w, opt, PseudoElement_SliderSubPage);
+ if (subRule1.hasDrawable()) {
+ QRect r(gr.topLeft(),
+ slider->orientation == Qt::Horizontal
+ ? QPoint(hr.x()+hr.width()/2, gr.y()+gr.height() - 1)
+ : QPoint(gr.x()+gr.width() - 1, hr.y()+hr.height()/2));
+ subRule1.drawRule(p, r);
+ }
+
+ QRenderRule subRule2 = renderRule(w, opt, PseudoElement_SliderAddPage);
+ if (subRule2.hasDrawable()) {
+ QRect r(slider->orientation == Qt::Horizontal
+ ? QPoint(hr.x()+hr.width()/2+1, gr.y())
+ : QPoint(gr.x(), hr.y()+hr.height()/2+1),
+ gr.bottomRight());
+ subRule2.drawRule(p, r);
+ }
+
+ handleSubRule.drawRule(p, handleSubRule.boxRect(hr, Margin));
+ }
+
+ if (slider->subControls & SC_SliderTickmarks) {
+ // TODO...
+ }
+
+ return;
+ }
+ break;
+#endif // QT_NO_SLIDER
+
+ case CC_MdiControls:
+ if (hasStyleRule(w, PseudoElement_MdiCloseButton)
+ || hasStyleRule(w, PseudoElement_MdiNormalButton)
+ || hasStyleRule(w, PseudoElement_MdiMinButton)) {
+ QList<QVariant> layout = rule.styleHint(QLatin1String("button-layout")).toList();
+ if (layout.isEmpty())
+ layout = subControlLayout(QLatin1String("mNX"));
+
+ QStyleOptionComplex optCopy(*opt);
+ optCopy.subControls = 0;
+ for (int i = 0; i < layout.count(); i++) {
+ int layoutButton = layout[i].toInt();
+ if (layoutButton < PseudoElement_MdiCloseButton
+ || layoutButton > PseudoElement_MdiNormalButton)
+ continue;
+ QStyle::SubControl control = knownPseudoElements[layoutButton].subControl;
+ if (!(opt->subControls & control))
+ continue;
+ QRenderRule subRule = renderRule(w, opt, layoutButton);
+ if (subRule.hasDrawable()) {
+ QRect rect = subRule.boxRect(subControlRect(CC_MdiControls, opt, control, w), Margin);
+ subRule.drawRule(p, rect);
+ QIcon icon = standardIcon(subControlIcon(layoutButton), opt);
+ icon.paint(p, subRule.contentsRect(rect), Qt::AlignCenter);
+ } else {
+ optCopy.subControls |= control;
+ }
+ }
+
+ if (optCopy.subControls)
+ baseStyle()->drawComplexControl(CC_MdiControls, &optCopy, p, w);
+ return;
+ }
+ break;
+
+ case CC_TitleBar:
+ if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_TitleBar);
+ if (!subRule.hasDrawable() && !subRule.hasBox() && !subRule.hasBorder())
+ break;
+ subRule.drawRule(p, opt->rect);
+ QHash<QStyle::SubControl, QRect> layout = titleBarLayout(w, tb);
+
+ QRect ir;
+ ir = layout[SC_TitleBarLabel];
+ if (ir.isValid()) {
+ if (subRule.hasPalette())
+ p->setPen(subRule.palette()->foreground.color());
+ p->fillRect(ir, Qt::white);
+ p->drawText(ir.x(), ir.y(), ir.width(), ir.height(), Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine, tb->text);
+ }
+
+ QPixmap pm;
+
+ ir = layout[SC_TitleBarSysMenu];
+ if (ir.isValid()) {
+ QRenderRule subSubRule = renderRule(w, opt, PseudoElement_TitleBarSysMenu);
+ subSubRule.drawRule(p, ir);
+ ir = subSubRule.contentsRect(ir);
+ if (!tb->icon.isNull()) {
+ tb->icon.paint(p, ir);
+ } else {
+ int iconSize = pixelMetric(PM_SmallIconSize, tb, w);
+ pm = standardIcon(SP_TitleBarMenuButton, 0, w).pixmap(iconSize, iconSize);
+ drawItemPixmap(p, ir, Qt::AlignCenter, pm);
+ }
+ }
+
+ ir = layout[SC_TitleBarCloseButton];
+ if (ir.isValid()) {
+ QRenderRule subSubRule = renderRule(w, opt, PseudoElement_TitleBarCloseButton);
+ subSubRule.drawRule(p, ir);
+
+ QSize sz = subSubRule.contentsRect(ir).size();
+ if ((tb->titleBarFlags & Qt::WindowType_Mask) == Qt::Tool)
+ pm = standardIcon(SP_DockWidgetCloseButton, 0, w).pixmap(sz);
+ else
+ pm = standardIcon(SP_TitleBarCloseButton, 0, w).pixmap(sz);
+ drawItemPixmap(p, ir, Qt::AlignCenter, pm);
+ }
+
+ int pes[] = {
+ PseudoElement_TitleBarMaxButton,
+ PseudoElement_TitleBarMinButton,
+ PseudoElement_TitleBarNormalButton,
+ PseudoElement_TitleBarShadeButton,
+ PseudoElement_TitleBarUnshadeButton,
+ PseudoElement_TitleBarContextHelpButton
+ };
+
+ for (unsigned int i = 0; i < sizeof(pes)/sizeof(int); i++) {
+ int pe = pes[i];
+ QStyle::SubControl sc = knownPseudoElements[pe].subControl;
+ ir = layout[sc];
+ if (!ir.isValid())
+ continue;
+ QRenderRule subSubRule = renderRule(w, opt, pe);
+ subSubRule.drawRule(p, ir);
+ pm = standardIcon(subControlIcon(pe), 0, w).pixmap(subSubRule.contentsRect(ir).size());
+ drawItemPixmap(p, ir, Qt::AlignCenter, pm);
+ }
+
+ return;
+ }
+ break;
+
+
+ default:
+ break;
+ }
+
+ baseStyle()->drawComplexControl(cc, opt, p, w);
+}
+
+void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter *p,
+ const QWidget *w) const
+{
+ RECURSION_GUARD(baseStyle()->drawControl(ce, opt, p, w); return)
+
+ QRenderRule rule = renderRule(w, opt);
+ int pe1 = PseudoElement_None, pe2 = PseudoElement_None;
+ bool fallback = false;
+
+ switch (ce) {
+ case CE_ToolButtonLabel:
+ if (const QStyleOptionToolButton *btn = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
+ if (rule.hasBox() || btn->features & QStyleOptionToolButton::Arrow) {
+ QCommonStyle::drawControl(ce, opt, p, w);
+ } else {
+ QStyleOptionToolButton butOpt(*btn);
+ rule.configurePalette(&butOpt.palette, QPalette::ButtonText, QPalette::Button);
+ baseStyle()->drawControl(ce, &butOpt, p, w);
+ }
+ return;
+ }
+ break;
+
+ case CE_FocusFrame:
+ if (!rule.hasNativeBorder()) {
+ rule.drawBorder(p, opt->rect);
+ return;
+ }
+ break;
+
+ case CE_PushButton:
+ if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
+ if (rule.hasDrawable() || rule.hasBox() || rule.hasPosition() || rule.hasPalette() ||
+ ((btn->features & QStyleOptionButton::HasMenu) && hasStyleRule(w, PseudoElement_PushButtonMenuIndicator))) {
+ ParentStyle::drawControl(ce, opt, p, w);
+ return;
+ }
+ }
+ break;
+ case CE_PushButtonBevel:
+ if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
+ QStyleOptionButton btnOpt(*btn);
+ btnOpt.rect = rule.borderRect(opt->rect);
+ if (rule.hasNativeBorder()) {
+ rule.drawBackgroundImage(p, btnOpt.rect);
+ rule.configurePalette(&btnOpt.palette, QPalette::ButtonText, QPalette::Button);
+ bool customMenu = (btn->features & QStyleOptionButton::HasMenu
+ && hasStyleRule(w, PseudoElement_PushButtonMenuIndicator));
+ if (customMenu)
+ btnOpt.features &= ~QStyleOptionButton::HasMenu;
+ if (rule.baseStyleCanDraw()) {
+ baseStyle()->drawControl(ce, &btnOpt, p, w);
+ } else {
+ QWindowsStyle::drawControl(ce, &btnOpt, p, w);
+ }
+ if (!customMenu)
+ return;
+ } else {
+ rule.drawRule(p, opt->rect);
+ }
+
+ if (btn->features & QStyleOptionButton::HasMenu) {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_PushButtonMenuIndicator);
+ QRect ir = positionRect(w, rule, subRule, PseudoElement_PushButtonMenuIndicator, opt->rect, opt->direction);
+ if (subRule.hasDrawable()) {
+ subRule.drawRule(p, ir);
+ } else {
+ btnOpt.rect = ir;
+ baseStyle()->drawPrimitive(PE_IndicatorArrowDown, &btnOpt, p, w);
+ }
+ }
+ }
+ return;
+
+ case CE_PushButtonLabel:
+ if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
+ QStyleOptionButton butOpt(*button);
+ rule.configurePalette(&butOpt.palette, QPalette::ButtonText, QPalette::Button);
+ if (rule.hasPosition() && rule.position()->textAlignment != 0) {
+ Qt::Alignment textAlignment = rule.position()->textAlignment;
+ QRect textRect = button->rect;
+ uint tf = Qt::TextShowMnemonic;
+ const uint verticalAlignMask = Qt::AlignVCenter | Qt::AlignTop | Qt::AlignLeft;
+ tf |= (textAlignment & verticalAlignMask) ? (textAlignment & verticalAlignMask) : Qt::AlignVCenter;
+ if (!styleHint(SH_UnderlineShortcut, button, w))
+ tf |= Qt::TextHideMnemonic;
+ if (!button->icon.isNull()) {
+ //Group both icon and text
+ QRect iconRect;
+ QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal : QIcon::Disabled;
+ if (mode == QIcon::Normal && button->state & State_HasFocus)
+ mode = QIcon::Active;
+ QIcon::State state = QIcon::Off;
+ if (button->state & State_On)
+ state = QIcon::On;
+
+ QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state);
+ int labelWidth = pixmap.width();
+ int labelHeight = pixmap.height();
+ int iconSpacing = 4;//### 4 is currently hardcoded in QPushButton::sizeHint()
+ int textWidth = button->fontMetrics.boundingRect(opt->rect, tf, button->text).width();
+ if (!button->text.isEmpty())
+ labelWidth += (textWidth + iconSpacing);
+
+ //Determine label alignment:
+ if (textAlignment & Qt::AlignLeft) { /*left*/
+ iconRect = QRect(textRect.x(), textRect.y() + (textRect.height() - labelHeight) / 2,
+ pixmap.width(), pixmap.height());
+ } else if (textAlignment & Qt::AlignHCenter) { /* center */
+ iconRect = QRect(textRect.x() + (textRect.width() - labelWidth) / 2,
+ textRect.y() + (textRect.height() - labelHeight) / 2,
+ pixmap.width(), pixmap.height());
+ } else { /*right*/
+ iconRect = QRect(textRect.x() + textRect.width() - labelWidth,
+ textRect.y() + (textRect.height() - labelHeight) / 2,
+ pixmap.width(), pixmap.height());
+ }
+
+ iconRect = visualRect(button->direction, textRect, iconRect);
+
+ tf |= Qt::AlignLeft; //left align, we adjust the text-rect instead
+
+ if (button->direction == Qt::RightToLeft)
+ textRect.setRight(iconRect.left() - iconSpacing);
+ else
+ textRect.setLeft(iconRect.left() + iconRect.width() + iconSpacing);
+
+ if (button->state & (State_On | State_Sunken))
+ iconRect.translate(pixelMetric(PM_ButtonShiftHorizontal, opt, w),
+ pixelMetric(PM_ButtonShiftVertical, opt, w));
+ p->drawPixmap(iconRect, pixmap);
+ } else {
+ tf |= textAlignment;
+ }
+ if (button->state & (State_On | State_Sunken))
+ textRect.translate(pixelMetric(PM_ButtonShiftHorizontal, opt, w),
+ pixelMetric(PM_ButtonShiftVertical, opt, w));
+
+ if (button->features & QStyleOptionButton::HasMenu) {
+ int indicatorSize = pixelMetric(PM_MenuButtonIndicator, button, w);
+ if (button->direction == Qt::LeftToRight)
+ textRect = textRect.adjusted(0, 0, -indicatorSize, 0);
+ else
+ textRect = textRect.adjusted(indicatorSize, 0, 0, 0);
+ }
+ drawItemText(p, textRect, tf, butOpt.palette, (button->state & State_Enabled),
+ button->text, QPalette::ButtonText);
+ } else {
+ ParentStyle::drawControl(ce, &butOpt, p, w);
+ }
+ }
+ return;
+
+ case CE_RadioButton:
+ case CE_CheckBox:
+ if (rule.hasBox() || !rule.hasNativeBorder() || rule.hasDrawable() || hasStyleRule(w, PseudoElement_Indicator)) {
+ rule.drawRule(p, opt->rect);
+ ParentStyle::drawControl(ce, opt, p, w);
+ return;
+ } else if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
+ QStyleOptionButton butOpt(*btn);
+ rule.configurePalette(&butOpt.palette, QPalette::ButtonText, QPalette::Button);
+ baseStyle()->drawControl(ce, &butOpt, p, w);
+ return;
+ }
+ break;
+ case CE_RadioButtonLabel:
+ case CE_CheckBoxLabel:
+ if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
+ QStyleOptionButton butOpt(*btn);
+ rule.configurePalette(&butOpt.palette, QPalette::ButtonText, QPalette::Button);
+ ParentStyle::drawControl(ce, &butOpt, p, w);
+ }
+ return;
+
+ case CE_Splitter:
+ pe1 = PseudoElement_SplitterHandle;
+ break;
+
+ case CE_ToolBar:
+ if (rule.hasBackground()) {
+ rule.drawBackground(p, opt->rect);
+ }
+ if (rule.hasBorder()) {
+ rule.drawBorder(p, rule.borderRect(opt->rect));
+ } else {
+#ifndef QT_NO_TOOLBAR
+ if (const QStyleOptionToolBar *tb = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
+ QStyleOptionToolBar newTb(*tb);
+ newTb.rect = rule.borderRect(opt->rect);
+ baseStyle()->drawControl(ce, &newTb, p, w);
+ }
+#endif // QT_NO_TOOLBAR
+ }
+ return;
+
+ case CE_MenuEmptyArea:
+ case CE_MenuBarEmptyArea:
+ if (rule.hasDrawable()) {
+ // Drawn by PE_Widget
+ return;
+ }
+ break;
+
+ case CE_MenuTearoff:
+ case CE_MenuScroller:
+ if (const QStyleOptionMenuItem *m = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
+ QStyleOptionMenuItem mi(*m);
+ int pe = ce == CE_MenuTearoff ? PseudoElement_MenuTearoff : PseudoElement_MenuScroller;
+ QRenderRule subRule = renderRule(w, opt, pe);
+ mi.rect = subRule.contentsRect(opt->rect);
+ rule.configurePalette(&mi.palette, QPalette::ButtonText, QPalette::Button);
+ subRule.configurePalette(&mi.palette, QPalette::ButtonText, QPalette::Button);
+
+ if (subRule.hasDrawable()) {
+ subRule.drawRule(p, opt->rect);
+ } else {
+ baseStyle()->drawControl(ce, &mi, p, w);
+ }
+ }
+ return;
+
+ case CE_MenuItem:
+ if (const QStyleOptionMenuItem *m = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
+ QStyleOptionMenuItem mi(*m);
+
+ int pseudo = (mi.menuItemType == QStyleOptionMenuItem::Separator) ? PseudoElement_MenuSeparator : PseudoElement_Item;
+ QRenderRule subRule = renderRule(w, opt, pseudo);
+ mi.rect = subRule.contentsRect(opt->rect);
+ rule.configurePalette(&mi.palette, QPalette::ButtonText, QPalette::Button);
+ rule.configurePalette(&mi.palette, QPalette::HighlightedText, QPalette::Highlight);
+ subRule.configurePalette(&mi.palette, QPalette::ButtonText, QPalette::Button);
+ subRule.configurePalette(&mi.palette, QPalette::HighlightedText, QPalette::Highlight);
+ QFont oldFont = p->font();
+ if (subRule.hasFont)
+ p->setFont(subRule.font.resolve(p->font()));
+
+ // We fall back to drawing with the style sheet code whenever at least one of the
+ // items are styled in an incompatible way, such as having a background image.
+ QRenderRule allRules = renderRule(w, PseudoElement_Item, PseudoClass_Any);
+
+ if ((pseudo == PseudoElement_MenuSeparator) && subRule.hasDrawable()) {
+ subRule.drawRule(p, opt->rect);
+ } else if ((pseudo == PseudoElement_Item)
+ && (allRules.hasBox() || allRules.hasBorder()
+ || (allRules.background() && !allRules.background()->pixmap.isNull()))) {
+ subRule.drawRule(p, opt->rect);
+ if (subRule.hasBackground()) {
+ mi.palette.setBrush(QPalette::Highlight, Qt::NoBrush);
+ mi.palette.setBrush(QPalette::Button, Qt::NoBrush);
+ } else {
+ mi.palette.setBrush(QPalette::Highlight, mi.palette.brush(QPalette::Button));
+ }
+ mi.palette.setBrush(QPalette::HighlightedText, mi.palette.brush(QPalette::ButtonText));
+
+ bool checkable = mi.checkType != QStyleOptionMenuItem::NotCheckable;
+ bool checked = checkable ? mi.checked : false;
+
+ bool dis = !(opt->state & QStyle::State_Enabled),
+ act = opt->state & QStyle::State_Selected;
+
+ if (!mi.icon.isNull()) {
+ QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
+ if (act && !dis)
+ mode = QIcon::Active;
+ QPixmap pixmap;
+ if (checked)
+ pixmap = mi.icon.pixmap(pixelMetric(PM_SmallIconSize), mode, QIcon::On);
+ else
+ pixmap = mi.icon.pixmap(pixelMetric(PM_SmallIconSize), mode);
+ int pixw = pixmap.width();
+ int pixh = pixmap.height();
+ QRenderRule iconRule = renderRule(w, opt, PseudoElement_MenuIcon);
+ if (!iconRule.hasGeometry()) {
+ iconRule.geo = new QStyleSheetGeometryData(pixw, pixh, pixw, pixh, -1, -1);
+ } else {
+ iconRule.geo->width = pixw;
+ iconRule.geo->height = pixh;
+ }
+ QRect iconRect = positionRect(w, subRule, iconRule, PseudoElement_MenuIcon, opt->rect, opt->direction);
+ iconRule.drawRule(p, iconRect);
+ QRect pmr(0, 0, pixw, pixh);
+ pmr.moveCenter(iconRect.center());
+ p->drawPixmap(pmr.topLeft(), pixmap);
+ } else if (checkable) {
+ QRenderRule subSubRule = renderRule(w, opt, PseudoElement_MenuCheckMark);
+ if (subSubRule.hasDrawable() || checked) {
+ QStyleOptionMenuItem newMi = mi;
+ newMi.rect = positionRect(w, subRule, subSubRule, PseudoElement_MenuCheckMark, opt->rect, opt->direction);
+ drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, w);
+ }
+ }
+
+ QRect textRect = subRule.contentsRect(opt->rect);
+ textRect.setWidth(textRect.width() - mi.tabWidth);
+ QString s = mi.text;
+ p->setPen(mi.palette.buttonText().color());
+ if (!s.isEmpty()) {
+ int text_flags = Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
+ if (!styleHint(SH_UnderlineShortcut, &mi, w))
+ text_flags |= Qt::TextHideMnemonic;
+ int t = s.indexOf(QLatin1Char('\t'));
+ if (t >= 0) {
+ QRect vShortcutRect = visualRect(opt->direction, mi.rect,
+ QRect(textRect.topRight(), QPoint(mi.rect.right(), textRect.bottom())));
+ p->drawText(vShortcutRect, text_flags, s.mid(t + 1));
+ s = s.left(t);
+ }
+ p->drawText(textRect, text_flags, s.left(t));
+ }
+
+ if (mi.menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
+ PrimitiveElement arrow = (opt->direction == Qt::RightToLeft) ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
+ QRenderRule subRule2 = renderRule(w, opt, PseudoElement_MenuRightArrow);
+ mi.rect = positionRect(w, subRule, subRule2, PseudoElement_MenuRightArrow, opt->rect, mi.direction);
+ drawPrimitive(arrow, &mi, p, w);
+ }
+ } else if (hasStyleRule(w, PseudoElement_MenuCheckMark) || hasStyleRule(w, PseudoElement_MenuRightArrow)) {
+ QWindowsStyle::drawControl(ce, &mi, p, w);
+ if (mi.checkType != QStyleOptionMenuItem::NotCheckable && !mi.checked) {
+ // We have a style defined, but QWindowsStyle won't draw anything if not checked.
+ // So we mimick what QWindowsStyle would do.
+ int checkcol = qMax<int>(mi.maxIconWidth, QWindowsStylePrivate::windowsCheckMarkWidth);
+ QRect vCheckRect = visualRect(opt->direction, mi.rect, QRect(mi.rect.x(), mi.rect.y(), checkcol, mi.rect.height()));
+ if (mi.state.testFlag(State_Enabled) && mi.state.testFlag(State_Selected)) {
+ qDrawShadePanel(p, vCheckRect, mi.palette, true, 1, &mi.palette.brush(QPalette::Button));
+ } else {
+ QBrush fill(mi.palette.light().color(), Qt::Dense4Pattern);
+ qDrawShadePanel(p, vCheckRect, mi.palette, true, 1, &fill);
+ }
+ QRenderRule subSubRule = renderRule(w, opt, PseudoElement_MenuCheckMark);
+ if (subSubRule.hasDrawable()) {
+ QStyleOptionMenuItem newMi(mi);
+ newMi.rect = visualRect(opt->direction, mi.rect, QRect(mi.rect.x() + QWindowsStylePrivate::windowsItemFrame,
+ mi.rect.y() + QWindowsStylePrivate::windowsItemFrame,
+ checkcol - 2 * QWindowsStylePrivate::windowsItemFrame,
+ mi.rect.height() - 2 * QWindowsStylePrivate::windowsItemFrame));
+ drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, w);
+ }
+ }
+ } else {
+ if (rule.hasDrawable() && !subRule.hasDrawable() && !(opt->state & QStyle::State_Selected)) {
+ mi.palette.setColor(QPalette::Window, Qt::transparent);
+ mi.palette.setColor(QPalette::Button, Qt::transparent);
+ }
+ if (rule.baseStyleCanDraw() && subRule.baseStyleCanDraw()) {
+ baseStyle()->drawControl(ce, &mi, p, w);
+ } else {
+ ParentStyle::drawControl(ce, &mi, p, w);
+ }
+ }
+
+ if (subRule.hasFont)
+ p->setFont(oldFont);
+
+ return;
+ }
+ return;
+
+ case CE_MenuBarItem:
+ if (const QStyleOptionMenuItem *m = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
+ QStyleOptionMenuItem mi(*m);
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_Item);
+ mi.rect = subRule.contentsRect(opt->rect);
+ rule.configurePalette(&mi.palette, QPalette::ButtonText, QPalette::Button);
+ subRule.configurePalette(&mi.palette, QPalette::ButtonText, QPalette::Button);
+
+ if (subRule.hasDrawable()) {
+ subRule.drawRule(p, opt->rect);
+ QCommonStyle::drawControl(ce, &mi, p, w);
+ } else {
+ if (rule.hasDrawable() && !(opt->state & QStyle::State_Selected)) {
+ // So that the menu bar background is not hidden by the items
+ mi.palette.setColor(QPalette::Window, Qt::transparent);
+ mi.palette.setColor(QPalette::Button, Qt::transparent);
+ }
+ baseStyle()->drawControl(ce, &mi, p, w);
+ }
+ }
+ return;
+
+#ifndef QT_NO_COMBOBOX
+ case CE_ComboBoxLabel:
+ if (!rule.hasBox())
+ break;
+ if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
+ QRect editRect = subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, w);
+ p->save();
+ p->setClipRect(editRect);
+ if (!cb->currentIcon.isNull()) {
+ int spacing = rule.hasBox() ? rule.box()->spacing : -1;
+ if (spacing == -1)
+ spacing = 6;
+ QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal : QIcon::Disabled;
+ QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode);
+ QRect iconRect(editRect);
+ iconRect.setWidth(cb->iconSize.width());
+ iconRect = alignedRect(cb->direction,
+ Qt::AlignLeft | Qt::AlignVCenter,
+ iconRect.size(), editRect);
+ drawItemPixmap(p, iconRect, Qt::AlignCenter, pixmap);
+
+ if (cb->direction == Qt::RightToLeft)
+ editRect.translate(-spacing - cb->iconSize.width(), 0);
+ else
+ editRect.translate(cb->iconSize.width() + spacing, 0);
+ }
+ if (!cb->currentText.isEmpty() && !cb->editable) {
+ QPalette styledPalette(cb->palette);
+ rule.configurePalette(&styledPalette, QPalette::Text, QPalette::Base);
+ drawItemText(p, editRect.adjusted(0, 0, 0, 0), Qt::AlignLeft | Qt::AlignVCenter, styledPalette,
+ cb->state & State_Enabled, cb->currentText, QPalette::Text);
+ }
+ p->restore();
+ return;
+ }
+ break;
+#endif // QT_NO_COMBOBOX
+
+ case CE_Header:
+ if (hasStyleRule(w, PseudoElement_HeaderViewUpArrow)
+ || hasStyleRule(w, PseudoElement_HeaderViewDownArrow)) {
+ ParentStyle::drawControl(ce, opt, p, w);
+ return;
+ }
+ if(hasStyleRule(w, PseudoElement_HeaderViewSection)) {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewSection);
+ if (!subRule.hasNativeBorder() || !subRule.baseStyleCanDraw()
+ || subRule.hasBackground() || subRule.hasPalette()) {
+ ParentStyle::drawControl(ce, opt, p, w);
+ return;
+ }
+ }
+ break;
+ case CE_HeaderSection:
+ if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewSection);
+ if (subRule.hasNativeBorder()) {
+ QStyleOptionHeader hdr(*header);
+ subRule.configurePalette(&hdr.palette, QPalette::ButtonText, QPalette::Button);
+
+ if (subRule.baseStyleCanDraw()) {
+ baseStyle()->drawControl(CE_HeaderSection, &hdr, p, w);
+ } else {
+ QWindowsStyle::drawControl(CE_HeaderSection, &hdr, p, w);
+ }
+ } else {
+ subRule.drawRule(p, opt->rect);
+ }
+ return;
+ }
+ break;
+
+ case CE_HeaderLabel:
+ if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
+ QStyleOptionHeader hdr(*header);
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewSection);
+ subRule.configurePalette(&hdr.palette, QPalette::ButtonText, QPalette::Button);
+ QFont oldFont = p->font();
+ if (subRule.hasFont)
+ p->setFont(subRule.font.resolve(p->font()));
+ baseStyle()->drawControl(ce, &hdr, p, w);
+ if (subRule.hasFont)
+ p->setFont(oldFont);
+ return;
+ }
+ break;
+
+ case CE_HeaderEmptyArea:
+ if (rule.hasDrawable()) {
+ return;
+ }
+ break;
+
+ case CE_ProgressBar:
+ QWindowsStyle::drawControl(ce, opt, p, w);
+ return;
+
+ case CE_ProgressBarGroove:
+ if (!rule.hasNativeBorder()) {
+ rule.drawRule(p, rule.boxRect(opt->rect, Margin));
+ return;
+ }
+ break;
+
+ case CE_ProgressBarContents: {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_ProgressBarChunk);
+ if (subRule.hasDrawable()) {
+ if (const QStyleOptionProgressBarV2 *pb = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
+ p->save();
+ p->setClipRect(pb->rect);
+
+ qint64 minimum = qint64(pb->minimum);
+ qint64 maximum = qint64(pb->maximum);
+ qint64 progress = qint64(pb->progress);
+ bool vertical = (pb->orientation == Qt::Vertical);
+ bool inverted = pb->invertedAppearance;
+
+ QTransform m;
+ QRect rect = pb->rect;
+ if (vertical) {
+ rect = QRect(rect.y(), rect.x(), rect.height(), rect.width());
+ m.rotate(90);
+ m.translate(0, -(rect.height() + rect.y()*2));
+ }
+
+ bool reverse = ((!vertical && (pb->direction == Qt::RightToLeft)) || vertical);
+ if (inverted)
+ reverse = !reverse;
+ const bool indeterminate = pb->minimum == pb->maximum;
+ qreal fillRatio = indeterminate ? 0.50 : qreal(progress - minimum)/(maximum - minimum);
+ int fillWidth = int(rect.width() * fillRatio);
+ int chunkWidth = fillWidth;
+ if (subRule.hasContentsSize()) {
+ QSize sz = subRule.size();
+ chunkWidth = (opt->state & QStyle::State_Horizontal) ? sz.width() : sz.height();
+ }
+
+ QRect r = rect;
+ if (pb->minimum == 0 && pb->maximum == 0) {
+ Q_D(const QWindowsStyle);
+ int chunkCount = fillWidth/chunkWidth;
+ int offset = (d->animateStep*8%rect.width());
+ int x = reverse ? r.left() + r.width() - offset - chunkWidth : r.x() + offset;
+ while (chunkCount > 0) {
+ r.setRect(x, rect.y(), chunkWidth, rect.height());
+ r = m.mapRect(QRectF(r)).toRect();
+ subRule.drawRule(p, r);
+ x += reverse ? -chunkWidth : chunkWidth;
+ if (reverse ? x < rect.left() : x > rect.right())
+ break;
+ --chunkCount;
+ }
+
+ r = rect;
+ x = reverse ? r.right() - (r.left() - x - chunkWidth)
+ : r.left() + (x - r.right() - chunkWidth);
+ while (chunkCount > 0) {
+ r.setRect(x, rect.y(), chunkWidth, rect.height());
+ r = m.mapRect(QRectF(r)).toRect();
+ subRule.drawRule(p, r);
+ x += reverse ? -chunkWidth : chunkWidth;
+ --chunkCount;
+ };
+ } else {
+ int x = reverse ? r.left() + r.width() - chunkWidth : r.x();
+
+ for (int i = 0; i < ceil(qreal(fillWidth)/chunkWidth); ++i) {
+ r.setRect(x, rect.y(), chunkWidth, rect.height());
+ r = m.mapRect(QRectF(r)).toRect();
+ subRule.drawRule(p, r);
+ x += reverse ? -chunkWidth : chunkWidth;
+ }
+ }
+
+ p->restore();
+ return;
+ }
+ }
+ }
+ break;
+
+ case CE_ProgressBarLabel:
+ if (const QStyleOptionProgressBarV2 *pb = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
+ if (rule.hasBox() || rule.hasBorder() || hasStyleRule(w, PseudoElement_ProgressBarChunk)) {
+ drawItemText(p, pb->rect, pb->textAlignment | Qt::TextSingleLine, pb->palette,
+ pb->state & State_Enabled, pb->text, QPalette::Text);
+ } else {
+ QStyleOptionProgressBarV2 pbCopy(*pb);
+ rule.configurePalette(&pbCopy.palette, QPalette::HighlightedText, QPalette::Highlight);
+ baseStyle()->drawControl(ce, &pbCopy, p, w);
+ }
+ return;
+ }
+ break;
+
+ case CE_SizeGrip:
+ if (const QStyleOptionSizeGrip *sgOpt = qstyleoption_cast<const QStyleOptionSizeGrip *>(opt)) {
+ if (rule.hasDrawable()) {
+ rule.drawFrame(p, opt->rect);
+ p->save();
+ switch (sgOpt->corner) {
+ case Qt::BottomRightCorner: break;
+ case Qt::BottomLeftCorner: p->rotate(90); break;
+ case Qt::TopLeftCorner: p->rotate(180); break;
+ case Qt::TopRightCorner: p->rotate(270); break;
+ default: break;
+ }
+ rule.drawImage(p, opt->rect);
+ p->restore();
+ } else {
+ QStyleOptionSizeGrip sg(*sgOpt);
+ sg.rect = rule.contentsRect(opt->rect);
+ baseStyle()->drawControl(CE_SizeGrip, &sg, p, w);
+ }
+ return;
+ }
+ break;
+
+ case CE_ToolBoxTab:
+ QWindowsStyle::drawControl(ce, opt, p, w);
+ return;
+
+ case CE_ToolBoxTabShape: {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_ToolBoxTab);
+ if (subRule.hasDrawable()) {
+ subRule.drawRule(p, opt->rect);
+ return;
+ }
+ }
+ break;
+
+ case CE_ToolBoxTabLabel:
+ if (const QStyleOptionToolBox *box = qstyleoption_cast<const QStyleOptionToolBox *>(opt)) {
+ QStyleOptionToolBox boxCopy(*box);
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_ToolBoxTab);
+ subRule.configurePalette(&boxCopy.palette, QPalette::ButtonText, QPalette::Button);
+ QFont oldFont = p->font();
+ if (subRule.hasFont)
+ p->setFont(subRule.font);
+ boxCopy.rect = subRule.contentsRect(opt->rect);
+ QWindowsStyle::drawControl(ce, &boxCopy, p , w);
+ if (subRule.hasFont)
+ p->setFont(oldFont);
+ return;
+ }
+ break;
+
+ case CE_ScrollBarAddPage:
+ pe1 = PseudoElement_ScrollBarAddPage;
+ break;
+
+ case CE_ScrollBarSubPage:
+ pe1 = PseudoElement_ScrollBarSubPage;
+ break;
+
+ case CE_ScrollBarAddLine:
+ pe1 = PseudoElement_ScrollBarAddLine;
+ pe2 = (opt->state & QStyle::State_Horizontal) ? PseudoElement_ScrollBarRightArrow : PseudoElement_ScrollBarDownArrow;
+ fallback = true;
+ break;
+
+ case CE_ScrollBarSubLine:
+ pe1 = PseudoElement_ScrollBarSubLine;
+ pe2 = (opt->state & QStyle::State_Horizontal) ? PseudoElement_ScrollBarLeftArrow : PseudoElement_ScrollBarUpArrow;
+ fallback = true;
+ break;
+
+ case CE_ScrollBarFirst:
+ pe1 = PseudoElement_ScrollBarFirst;
+ break;
+
+ case CE_ScrollBarLast:
+ pe1 = PseudoElement_ScrollBarLast;
+ break;
+
+ case CE_ScrollBarSlider:
+ pe1 = PseudoElement_ScrollBarSlider;
+ fallback = true;
+ break;
+
+#ifndef QT_NO_ITEMVIEWS
+ case CE_ItemViewItem:
+ if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_ViewItem);
+ if (subRule.hasDrawable() || hasStyleRule(w, PseudoElement_Indicator)) {
+ QStyleOptionViewItemV4 optCopy(*vopt);
+ subRule.configurePalette(&optCopy.palette, vopt->state & QStyle::State_Selected ? QPalette::HighlightedText : QPalette::Text,
+ vopt->state & QStyle::State_Selected ? QPalette::Highlight : QPalette::Base);
+ QWindowsStyle::drawControl(ce, &optCopy, p, w);
+ } else {
+ QStyleOptionViewItemV4 voptCopy(*vopt);
+ subRule.configurePalette(&voptCopy.palette, QPalette::Text, QPalette::NoRole);
+ baseStyle()->drawControl(ce, &voptCopy, p, w);
+ }
+ return;
+ }
+ break;
+#endif // QT_NO_ITEMVIEWS
+
+#ifndef QT_NO_TABBAR
+ case CE_TabBarTab:
+ if (hasStyleRule(w, PseudoElement_TabBarTab)) {
+ QWindowsStyle::drawControl(ce, opt, p, w);
+ return;
+ }
+ break;
+
+ case CE_TabBarTabLabel:
+ case CE_TabBarTabShape:
+ if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
+ QStyleOptionTabV3 tabCopy(*tab);
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTab);
+ QRect r = positionRect(w, subRule, PseudoElement_TabBarTab, opt->rect, opt->direction);
+ if (ce == CE_TabBarTabShape && subRule.hasDrawable()) {
+ subRule.drawRule(p, r);
+ return;
+ }
+ subRule.configurePalette(&tabCopy.palette, QPalette::WindowText, QPalette::Window);
+ QFont oldFont = p->font();
+ if (subRule.hasFont)
+ p->setFont(subRule.font);
+ if (subRule.hasBox() || !subRule.hasNativeBorder()) {
+ tabCopy.rect = ce == CE_TabBarTabShape ? subRule.borderRect(r)
+ : subRule.contentsRect(r);
+ QWindowsStyle::drawControl(ce, &tabCopy, p, w);
+ } else {
+ baseStyle()->drawControl(ce, &tabCopy, p, w);
+ }
+ if (subRule.hasFont)
+ p->setFont(oldFont);
+
+ return;
+ }
+ break;
+#endif // QT_NO_TABBAR
+
+ case CE_ColumnViewGrip:
+ if (rule.hasDrawable()) {
+ rule.drawRule(p, opt->rect);
+ return;
+ }
+ break;
+
+ case CE_DockWidgetTitle:
+ if (const QStyleOptionDockWidgetV2 *dwOpt = qstyleoption_cast<const QStyleOptionDockWidgetV2 *>(opt)) {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_DockWidgetTitle);
+ if (!subRule.hasDrawable() && !subRule.hasPosition())
+ break;
+ if (subRule.hasDrawable()) {
+ subRule.drawRule(p, opt->rect);
+ } else {
+ QStyleOptionDockWidgetV2 dwCopy(*dwOpt);
+ dwCopy.title = QString();
+ baseStyle()->drawControl(ce, &dwCopy, p, w);
+ }
+
+ if (!dwOpt->title.isEmpty()) {
+ QRect r = opt->rect;
+ if (dwOpt->verticalTitleBar) {
+ QSize s = r.size();
+ s.transpose();
+ r.setSize(s);
+
+ p->save();
+ p->translate(r.left(), r.top() + r.width());
+ p->rotate(-90);
+ p->translate(-r.left(), -r.top());
+ }
+
+ Qt::Alignment alignment = 0;
+ if (subRule.hasPosition())
+ alignment = subRule.position()->textAlignment;
+ if (alignment == 0)
+ alignment = Qt::AlignLeft;
+ drawItemText(p, subRule.contentsRect(opt->rect),
+ alignment | Qt::TextShowMnemonic, dwOpt->palette,
+ dwOpt->state & State_Enabled, dwOpt->title,
+ QPalette::WindowText);
+
+ if (dwOpt->verticalTitleBar)
+ p->restore();
+ }
+
+ return;
+ }
+ break;
+ case CE_ShapedFrame:
+ if (const QStyleOptionFrame *frm = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
+ if (rule.hasNativeBorder()) {
+ QStyleOptionFrameV3 frmOpt(*frm);
+ rule.configurePalette(&frmOpt.palette, QPalette::Text, QPalette::Base);
+ frmOpt.rect = rule.borderRect(frmOpt.rect);
+ baseStyle()->drawControl(ce, &frmOpt, p, w);
+ }
+ // else, borders are already drawn in PE_Widget
+ }
+ return;
+
+
+ default:
+ break;
+ }
+
+ if (pe1 != PseudoElement_None) {
+ QRenderRule subRule = renderRule(w, opt, pe1);
+ if (subRule.bg != 0 || subRule.hasDrawable()) {
+ //We test subRule.bg directly because hasBackground() would return false for background:none.
+ //But we still don't want the default drawning in that case (example for QScrollBar::add-page) (task 198926)
+ subRule.drawRule(p, opt->rect);
+ } else if (fallback) {
+ QWindowsStyle::drawControl(ce, opt, p, w);
+ pe2 = PseudoElement_None;
+ } else {
+ baseStyle()->drawControl(ce, opt, p, w);
+ }
+ if (pe2 != PseudoElement_None) {
+ QRenderRule subSubRule = renderRule(w, opt, pe2);
+ QRect r = positionRect(w, subRule, subSubRule, pe2, opt->rect, opt->direction);
+ subSubRule.drawRule(p, r);
+ }
+ return;
+ }
+
+ baseStyle()->drawControl(ce, opt, p, w);
+}
+
+void QStyleSheetStyle::drawItemPixmap(QPainter *p, const QRect &rect, int alignment, const
+ QPixmap &pixmap) const
+{
+ baseStyle()->drawItemPixmap(p, rect, alignment, pixmap);
+}
+
+void QStyleSheetStyle::drawItemText(QPainter *painter, const QRect& rect, int alignment, const QPalette &pal,
+ bool enabled, const QString& text, QPalette::ColorRole textRole) const
+{
+ baseStyle()->drawItemText(painter, rect, alignment, pal, enabled, text, textRole);
+}
+
+void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
+ const QWidget *w) const
+{
+ RECURSION_GUARD(baseStyle()->drawPrimitive(pe, opt, p, w); return)
+
+ int pseudoElement = PseudoElement_None;
+ QRenderRule rule = renderRule(w, opt);
+ QRect rect = opt->rect;
+
+ switch (pe) {
+
+ case PE_FrameStatusBar: {
+ QRenderRule subRule = renderRule(w->parentWidget(), opt, PseudoElement_Item);
+ if (subRule.hasDrawable()) {
+ subRule.drawRule(p, opt->rect);
+ return;
+ }
+ break;
+ }
+
+ case PE_IndicatorArrowDown:
+ pseudoElement = PseudoElement_DownArrow;
+ break;
+
+ case PE_IndicatorArrowUp:
+ pseudoElement = PseudoElement_UpArrow;
+ break;
+
+ case PE_IndicatorRadioButton:
+ pseudoElement = PseudoElement_ExclusiveIndicator;
+ break;
+
+ case PE_IndicatorViewItemCheck:
+ pseudoElement = PseudoElement_ViewItemIndicator;
+ break;
+
+ case PE_IndicatorCheckBox:
+ pseudoElement = PseudoElement_Indicator;
+ break;
+
+ case PE_IndicatorHeaderArrow:
+ if (const QStyleOptionHeader *hdr = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
+ pseudoElement = hdr->sortIndicator == QStyleOptionHeader::SortUp
+ ? PseudoElement_HeaderViewUpArrow
+ : PseudoElement_HeaderViewDownArrow;
+ }
+ break;
+
+ case PE_PanelButtonTool:
+ case PE_PanelButtonCommand:
+ if (qobject_cast<const QAbstractButton *>(w) && rule.hasBackground() && rule.hasNativeBorder()) {
+ //the window style will draw the borders
+ ParentStyle::drawPrimitive(pe, opt, p, w);
+ if (!rule.background()->pixmap.isNull() || rule.hasImage()) {
+ rule.drawRule(p, rule.boxRect(opt->rect, QRenderRule::Margin).adjusted(1,1,-1,-1));
+ }
+ return;
+ }
+ if (!rule.hasNativeBorder()) {
+ rule.drawRule(p, rule.boxRect(opt->rect, QRenderRule::Margin));
+ return;
+ }
+ break;
+
+ case PE_IndicatorButtonDropDown: {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_ToolButtonMenu);
+ if (!subRule.hasNativeBorder()) {
+ rule.drawBorder(p, opt->rect);
+ return;
+ }
+ break;
+ }
+
+ case PE_FrameDefaultButton:
+ if (rule.hasNativeBorder()) {
+ if (rule.baseStyleCanDraw())
+ break;
+ QWindowsStyle::drawPrimitive(pe, opt, p, w);
+ }
+ return;
+
+ case PE_FrameWindow:
+ case PE_FrameDockWidget:
+ case PE_Frame:
+ if (const QStyleOptionFrame *frm = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
+ if (rule.hasNativeBorder()) {
+ QStyleOptionFrameV2 frmOpt(*frm);
+ rule.configurePalette(&frmOpt.palette, QPalette::Text, QPalette::Base);
+ if (!qstyleoption_cast<const QStyleOptionFrameV3 *>(opt)) //if it comes from CE_ShapedFrame, the margins are already sustracted
+ frmOpt.rect = rule.borderRect(frmOpt.rect);
+ baseStyle()->drawPrimitive(pe, &frmOpt, p, w);
+ } else {
+ rule.drawBorder(p, rule.borderRect(opt->rect));
+ }
+ }
+ return;
+
+ case PE_PanelLineEdit:
+ if (const QStyleOptionFrame *frm = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
+#ifndef QT_NO_SPINBOX
+ if (w && qobject_cast<const QAbstractSpinBox *>(w->parentWidget())) {
+ QRenderRule spinboxRule = renderRule(w->parentWidget(), opt);
+ if (!spinboxRule.hasNativeBorder() || !spinboxRule.baseStyleCanDraw())
+ return;
+ rule = spinboxRule;
+ }
+#endif
+ if (rule.hasNativeBorder()) {
+ QStyleOptionFrame frmOpt(*frm);
+ rule.configurePalette(&frmOpt.palette, QPalette::Text, QPalette::Base);
+ frmOpt.rect = rule.borderRect(frmOpt.rect);
+ if (rule.baseStyleCanDraw()) {
+ rule.drawBackgroundImage(p, opt->rect);
+ baseStyle()->drawPrimitive(pe, &frmOpt, p, w);
+ } else {
+ rule.drawBackground(p, opt->rect);
+ if (frmOpt.lineWidth > 0)
+ baseStyle()->drawPrimitive(PE_FrameLineEdit, &frmOpt, p, w);
+ }
+ } else {
+ rule.drawRule(p, opt->rect);
+ }
+ }
+ return;
+
+ case PE_Widget:
+ if (w && !rule.hasDrawable()) {
+ QWidget *container = containerWidget(w);
+ if (styleSheetCaches->autoFillDisabledWidgets.contains(container)
+ && (container == w || !renderRule(container, opt).hasBackground())) {
+ //we do not have a background, but we disabled the autofillbackground anyway. so fill the background now.
+ // (this may happen if we have rules like :focus)
+ p->fillRect(opt->rect, opt->palette.brush(w->backgroundRole()));
+ }
+ break;
+ }
+#ifndef QT_NO_SCROLLAREA
+ if (const QAbstractScrollArea *sa = qobject_cast<const QAbstractScrollArea *>(w)) {
+ const QAbstractScrollAreaPrivate *sap = sa->d_func();
+ rule.drawBackground(p, opt->rect, sap->contentsOffset());
+ if (rule.hasBorder()) {
+ QRect brect = rule.borderRect(opt->rect);
+ if (styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, opt, w)) {
+ QRect r = brect.adjusted(0, 0, sa->verticalScrollBar()->isVisible() ? -sa->verticalScrollBar()->width() : 0,
+ sa->horizontalScrollBar()->isVisible() ? -sa->horizontalScrollBar()->height() : 0);
+ brect = QStyle::visualRect(opt->direction, brect, r);
+ }
+ rule.drawBorder(p, brect);
+ }
+ break;
+ }
+#endif
+ //fall tghought
+ case PE_PanelMenu:
+ case PE_PanelStatusBar:
+ if(rule.hasDrawable()) {
+ rule.drawRule(p, opt->rect);
+ return;
+ }
+ break;
+
+ case PE_FrameMenu:
+ if (rule.hasDrawable()) {
+ // Drawn by PE_PanelMenu
+ return;
+ }
+ break;
+
+ case PE_PanelMenuBar:
+ if (rule.hasDrawable()) {
+ // Drawn by PE_Widget
+ return;
+ }
+ break;
+
+ case PE_IndicatorToolBarSeparator:
+ case PE_IndicatorToolBarHandle: {
+ PseudoElement ps = pe == PE_IndicatorToolBarHandle ? PseudoElement_ToolBarHandle : PseudoElement_ToolBarSeparator;
+ QRenderRule subRule = renderRule(w, opt, ps);
+ if (subRule.hasDrawable()) {
+ subRule.drawRule(p, opt->rect);
+ return;
+ }
+ }
+ break;
+
+ case PE_IndicatorMenuCheckMark:
+ pseudoElement = PseudoElement_MenuCheckMark;
+ break;
+
+ case PE_IndicatorArrowLeft:
+ pseudoElement = PseudoElement_LeftArrow;
+ break;
+
+ case PE_IndicatorArrowRight:
+ pseudoElement = PseudoElement_RightArrow;
+ break;
+
+ case PE_IndicatorColumnViewArrow:
+ if (const QStyleOptionViewItem *viewOpt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
+ bool reverse = (viewOpt->direction == Qt::RightToLeft);
+ pseudoElement = reverse ? PseudoElement_LeftArrow : PseudoElement_RightArrow;
+ } else {
+ pseudoElement = PseudoElement_RightArrow;
+ }
+ break;
+
+ case PE_IndicatorBranch:
+ if (const QStyleOptionViewItemV2 *v2 = qstyleoption_cast<const QStyleOptionViewItemV2 *>(opt)) {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_TreeViewBranch);
+ if (subRule.hasDrawable()) {
+ if ((v2->state & QStyle::State_Selected) && v2->showDecorationSelected)
+ p->fillRect(v2->rect, v2->palette.highlight());
+ else if (v2->features & QStyleOptionViewItemV2::Alternate)
+ p->fillRect(v2->rect, v2->palette.alternateBase());
+ subRule.drawRule(p, opt->rect);
+ } else {
+ baseStyle()->drawPrimitive(pe, v2, p, w);
+ }
+ }
+ return;
+
+ case PE_PanelTipLabel:
+ if (!rule.hasDrawable())
+ break;
+
+ if (const QStyleOptionFrame *frmOpt = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
+ if (rule.hasNativeBorder()) {
+ rule.drawBackground(p, opt->rect);
+ QStyleOptionFrame optCopy(*frmOpt);
+ optCopy.rect = rule.borderRect(opt->rect);
+ optCopy.palette.setBrush(QPalette::Window, Qt::NoBrush); // oh dear
+ baseStyle()->drawPrimitive(pe, &optCopy, p, w);
+ } else {
+ rule.drawRule(p, opt->rect);
+ }
+ }
+ return;
+
+ case PE_FrameGroupBox:
+ if (rule.hasNativeBorder())
+ break;
+ rule.drawBorder(p, opt->rect);
+ return;
+
+#ifndef QT_NO_TABWIDGET
+ case PE_FrameTabWidget:
+ if (const QStyleOptionTabWidgetFrame *frm = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_TabWidgetPane);
+ if (subRule.hasNativeBorder()) {
+ subRule.drawBackground(p, opt->rect);
+ QStyleOptionTabWidgetFrameV2 frmCopy(*frm);
+ subRule.configurePalette(&frmCopy.palette, QPalette::WindowText, QPalette::Window);
+ baseStyle()->drawPrimitive(pe, &frmCopy, p, w);
+ } else {
+ subRule.drawRule(p, opt->rect);
+ }
+ return;
+ }
+ break;
+#endif // QT_NO_TABWIDGET
+
+ case PE_IndicatorProgressChunk:
+ pseudoElement = PseudoElement_ProgressBarChunk;
+ break;
+
+ case PE_IndicatorTabTear:
+ pseudoElement = PseudoElement_TabBarTear;
+ break;
+
+ case PE_FrameFocusRect:
+ if (!rule.hasNativeOutline()) {
+ rule.drawOutline(p, opt->rect);
+ return;
+ }
+ break;
+
+ case PE_IndicatorDockWidgetResizeHandle:
+ pseudoElement = PseudoElement_DockWidgetSeparator;
+ break;
+
+ case PE_PanelItemViewItem:
+ pseudoElement = PseudoElement_ViewItem;
+ break;
+
+ case PE_PanelScrollAreaCorner:
+ pseudoElement = PseudoElement_ScrollAreaCorner;
+ break;
+
+ case PE_IndicatorSpinDown:
+ case PE_IndicatorSpinMinus:
+ pseudoElement = PseudoElement_SpinBoxDownArrow;
+ break;
+
+ case PE_IndicatorSpinUp:
+ case PE_IndicatorSpinPlus:
+ pseudoElement = PseudoElement_SpinBoxUpArrow;
+ break;
+#ifndef QT_NO_TABBAR
+ case PE_IndicatorTabClose:
+ if (w)
+ w = w->parentWidget(); //match on the QTabBar instead of the CloseButton
+ pseudoElement = PseudoElement_TabBarTabCloseButton;
+#endif
+
+ default:
+ break;
+ }
+
+ if (pseudoElement != PseudoElement_None) {
+ QRenderRule subRule = renderRule(w, opt, pseudoElement);
+ if (subRule.hasDrawable()) {
+ subRule.drawRule(p, rect);
+ } else {
+ baseStyle()->drawPrimitive(pe, opt, p, w);
+ }
+ } else {
+ baseStyle()->drawPrimitive(pe, opt, p, w);
+ }
+}
+
+QPixmap QStyleSheetStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap& pixmap,
+ const QStyleOption *option) const
+{
+ return baseStyle()->generatedIconPixmap(iconMode, pixmap, option);
+}
+
+QStyle::SubControl QStyleSheetStyle::hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
+ const QPoint &pt, const QWidget *w) const
+{
+ RECURSION_GUARD(return baseStyle()->hitTestComplexControl(cc, opt, pt, w))
+ switch (cc) {
+ case CC_TitleBar:
+ if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
+ QRenderRule rule = renderRule(w, opt, PseudoElement_TitleBar);
+ if (rule.hasDrawable() || rule.hasBox() || rule.hasBorder()) {
+ QHash<QStyle::SubControl, QRect> layout = titleBarLayout(w, tb);
+ QRect r;
+ QStyle::SubControl sc = QStyle::SC_None;
+ uint ctrl = SC_TitleBarSysMenu;
+ while (ctrl <= SC_TitleBarLabel) {
+ r = layout[QStyle::SubControl(ctrl)];
+ if (r.isValid() && r.contains(pt)) {
+ sc = QStyle::SubControl(ctrl);
+ break;
+ }
+ ctrl <<= 1;
+ }
+ return sc;
+ }
+ }
+ break;
+
+ case CC_MdiControls:
+ if (hasStyleRule(w, PseudoElement_MdiCloseButton)
+ || hasStyleRule(w, PseudoElement_MdiNormalButton)
+ || hasStyleRule(w, PseudoElement_MdiMinButton))
+ return QWindowsStyle::hitTestComplexControl(cc, opt, pt, w);
+ break;
+
+ case CC_ScrollBar: {
+ QRenderRule rule = renderRule(w, opt);
+ if (!rule.hasDrawable() && !rule.hasBox())
+ break;
+ }
+ // intentionally falls through
+ case CC_SpinBox:
+ case CC_GroupBox:
+ case CC_ComboBox:
+ case CC_Slider:
+ case CC_ToolButton:
+ return QWindowsStyle::hitTestComplexControl(cc, opt, pt, w);
+ default:
+ break;
+ }
+
+ return baseStyle()->hitTestComplexControl(cc, opt, pt, w);
+}
+
+QRect QStyleSheetStyle::itemPixmapRect(const QRect &rect, int alignment, const QPixmap &pixmap) const
+{
+ return baseStyle()->itemPixmapRect(rect, alignment, pixmap);
+}
+
+QRect QStyleSheetStyle::itemTextRect(const QFontMetrics &metrics, const QRect& rect, int alignment,
+ bool enabled, const QString& text) const
+{
+ return baseStyle()->itemTextRect(metrics, rect, alignment, enabled, text);
+}
+
+int QStyleSheetStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWidget *w) const
+{
+ RECURSION_GUARD(return baseStyle()->pixelMetric(m, opt, w))
+
+ QRenderRule rule = renderRule(w, opt);
+ QRenderRule subRule;
+
+ switch (m) {
+ case PM_MenuButtonIndicator:
+#ifndef QT_NO_TOOLBUTTON
+ // QToolButton adds this directly to the width
+ if (qobject_cast<const QToolButton *>(w) && (rule.hasBox() || !rule.hasNativeBorder()))
+ return 0;
+#endif
+ subRule = renderRule(w, opt, PseudoElement_PushButtonMenuIndicator);
+ if (subRule.hasContentsSize())
+ return subRule.size().width();
+ break;
+
+ case PM_ButtonShiftHorizontal:
+ case PM_ButtonShiftVertical:
+ case PM_ButtonMargin:
+ case PM_ButtonDefaultIndicator:
+ if (rule.hasBox())
+ return 0;
+ break;
+
+ case PM_DefaultFrameWidth:
+ if (!rule.hasNativeBorder())
+ return rule.border()->borders[LeftEdge];
+ break;
+
+ case PM_ExclusiveIndicatorWidth:
+ case PM_IndicatorWidth:
+ case PM_ExclusiveIndicatorHeight:
+ case PM_IndicatorHeight:
+ subRule = renderRule(w, opt, PseudoElement_Indicator);
+ if (subRule.hasContentsSize()) {
+ return (m == PM_ExclusiveIndicatorWidth) || (m == PM_IndicatorWidth)
+ ? subRule.size().width() : subRule.size().height();
+ }
+ break;
+
+ case PM_DockWidgetFrameWidth:
+ case PM_ToolTipLabelFrameWidth: // border + margin + padding (support only one width)
+ if (!rule.hasDrawable())
+ break;
+
+ return (rule.border() ? rule.border()->borders[LeftEdge] : 0)
+ + (rule.hasBox() ? rule.box()->margins[LeftEdge] + rule.box()->paddings[LeftEdge]: 0);
+
+ case PM_ToolBarFrameWidth:
+ if (rule.hasBorder() || rule.hasBox())
+ return (rule.border() ? rule.border()->borders[LeftEdge] : 0)
+ + (rule.hasBox() ? rule.box()->paddings[LeftEdge]: 0);
+ break;
+
+ case PM_MenuPanelWidth:
+ case PM_MenuBarPanelWidth:
+ if (rule.hasBorder() || rule.hasBox())
+ return (rule.border() ? rule.border()->borders[LeftEdge] : 0)
+ + (rule.hasBox() ? rule.box()->margins[LeftEdge]: 0);
+ break;
+
+
+ case PM_MenuHMargin:
+ case PM_MenuBarHMargin:
+ if (rule.hasBox())
+ return rule.box()->paddings[LeftEdge];
+ break;
+
+ case PM_MenuVMargin:
+ case PM_MenuBarVMargin:
+ if (rule.hasBox())
+ return rule.box()->paddings[TopEdge];
+ break;
+
+ case PM_DockWidgetTitleBarButtonMargin:
+ case PM_ToolBarItemMargin:
+ if (rule.hasBox())
+ return rule.box()->margins[TopEdge];
+ break;
+
+ case PM_ToolBarItemSpacing:
+ case PM_MenuBarItemSpacing:
+ if (rule.hasBox() && rule.box()->spacing != -1)
+ return rule.box()->spacing;
+ break;
+
+ case PM_MenuTearoffHeight:
+ case PM_MenuScrollerHeight: {
+ PseudoElement ps = m == PM_MenuTearoffHeight ? PseudoElement_MenuTearoff : PseudoElement_MenuScroller;
+ subRule = renderRule(w, opt, ps);
+ if (subRule.hasContentsSize())
+ return subRule.size().height();
+ break;
+ }
+
+ case PM_ToolBarExtensionExtent:
+ break;
+
+ case PM_SplitterWidth:
+ case PM_ToolBarSeparatorExtent:
+ case PM_ToolBarHandleExtent: {
+ PseudoElement ps;
+ if (m == PM_ToolBarHandleExtent) ps = PseudoElement_ToolBarHandle;
+ else if (m == PM_SplitterWidth) ps = PseudoElement_SplitterHandle;
+ else ps = PseudoElement_ToolBarSeparator;
+ subRule = renderRule(w, opt, ps);
+ if (subRule.hasContentsSize()) {
+ QSize sz = subRule.size();
+ return (opt && opt->state & QStyle::State_Horizontal) ? sz.width() : sz.height();
+ }
+ break;
+ }
+
+ case PM_RadioButtonLabelSpacing:
+ if (rule.hasBox() && rule.box()->spacing != -1)
+ return rule.box()->spacing;
+ break;
+ case PM_CheckBoxLabelSpacing:
+ if (qobject_cast<const QCheckBox *>(w)) {
+ if (rule.hasBox() && rule.box()->spacing != -1)
+ return rule.box()->spacing;
+ }
+ // assume group box
+ subRule = renderRule(w, opt, PseudoElement_GroupBoxTitle);
+ if (subRule.hasBox() && subRule.box()->spacing != -1)
+ return subRule.box()->spacing;
+ break;
+
+#ifndef QT_NO_SCROLLBAR
+ case PM_ScrollBarExtent:
+ if (rule.hasContentsSize()) {
+ QSize sz = rule.size();
+ if (const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(opt))
+ return sb->orientation == Qt::Horizontal ? sz.height() : sz.width();
+ return sz.width() == -1 ? sz.height() : sz.width();
+ }
+ break;
+
+ case PM_ScrollBarSliderMin:
+ if (hasStyleRule(w, PseudoElement_ScrollBarSlider)) {
+ subRule = renderRule(w, opt, PseudoElement_ScrollBarSlider);
+ QSize msz = subRule.minimumSize();
+ if (const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(opt))
+ return sb->orientation == Qt::Horizontal ? msz.width() : msz.height();
+ return msz.width() == -1 ? msz.height() : msz.width();
+ }
+ break;
+
+ case PM_ScrollView_ScrollBarSpacing:
+ if(!rule.hasNativeBorder() || rule.hasBox())
+ return 0;
+ break;
+#endif // QT_NO_SCROLLBAR
+
+ case PM_ProgressBarChunkWidth:
+ subRule = renderRule(w, opt, PseudoElement_ProgressBarChunk);
+ if (subRule.hasContentsSize()) {
+ QSize sz = subRule.size();
+ return (opt->state & QStyle::State_Horizontal)
+ ? sz.width() : sz.height();
+ }
+ break;
+
+#ifndef QT_NO_TABWIDGET
+ case PM_TabBarTabHSpace:
+ case PM_TabBarTabVSpace:
+ subRule = renderRule(w, opt, PseudoElement_TabBarTab);
+ if (subRule.hasBox() || subRule.hasBorder())
+ return 0;
+ break;
+
+ case PM_TabBarScrollButtonWidth: {
+ subRule = renderRule(w, opt, PseudoElement_TabBarScroller);
+ if (subRule.hasContentsSize()) {
+ QSize sz = subRule.size();
+ return sz.width() != -1 ? sz.width() : sz.height();
+ }
+ }
+ break;
+
+ case PM_TabBarTabShiftHorizontal:
+ case PM_TabBarTabShiftVertical:
+ subRule = renderRule(w, opt, PseudoElement_TabBarTab);
+ if (subRule.hasBox())
+ return 0;
+ break;
+
+ case PM_TabBarBaseOverlap: {
+ const QWidget *tabWidget = qobject_cast<const QTabWidget *>(w) ? w : w->parentWidget();
+ if (hasStyleRule(tabWidget, PseudoElement_TabWidgetPane)) {
+ return 0;
+ }
+ break;
+ }
+#endif // QT_NO_TABWIDGET
+
+ case PM_SliderThickness: // horizontal slider's height (sizeHint)
+ case PM_SliderLength: // minimum length of slider
+ if (rule.hasContentsSize()) {
+ bool horizontal = opt->state & QStyle::State_Horizontal;
+ if (m == PM_SliderThickness) {
+ QSize sz = rule.size();
+ return horizontal ? sz.height() : sz.width();
+ } else {
+ QSize msz = rule.minimumContentsSize();
+ return horizontal ? msz.width() : msz.height();
+ }
+ }
+ break;
+
+ case PM_SliderControlThickness: {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_SliderHandle);
+ if (!subRule.hasContentsSize())
+ break;
+ QSize size = subRule.size();
+ return (opt->state & QStyle::State_Horizontal) ? size.height() : size.width();
+ }
+
+ case PM_ToolBarIconSize:
+ case PM_ListViewIconSize:
+ case PM_IconViewIconSize:
+ case PM_TabBarIconSize:
+ case PM_MessageBoxIconSize:
+ case PM_ButtonIconSize:
+ case PM_SmallIconSize:
+ if (rule.hasStyleHint(QLatin1String("icon-size"))) {
+ return rule.styleHint(QLatin1String("icon-size")).toSize().width();
+ }
+ break;
+
+ case PM_DockWidgetTitleMargin: {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_DockWidgetTitle);
+ if (!subRule.hasBox())
+ break;
+ return (subRule.border() ? subRule.border()->borders[TopEdge] : 0)
+ + (subRule.hasBox() ? subRule.box()->margins[TopEdge] + subRule.box()->paddings[TopEdge]: 0);
+ }
+
+ case PM_DockWidgetSeparatorExtent: {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_DockWidgetSeparator);
+ if (!subRule.hasContentsSize())
+ break;
+ QSize sz = subRule.size();
+ return qMax(sz.width(), sz.height());
+ }
+
+ case PM_TitleBarHeight: {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_TitleBar);
+ if (subRule.hasContentsSize())
+ return subRule.size().height();
+ else if (subRule.hasBox() || subRule.hasBorder()) {
+ QFontMetrics fm = opt ? opt->fontMetrics : w->fontMetrics();
+ return subRule.size(QSize(0, fm.height())).height();
+ }
+ break;
+ }
+
+ case PM_MdiSubWindowFrameWidth:
+ if (rule.hasBox() || rule.hasBorder()) {
+ return (rule.border() ? rule.border()->borders[LeftEdge] : 0)
+ + (rule.hasBox() ? rule.box()->paddings[LeftEdge]+rule.box()->margins[LeftEdge]: 0);
+ }
+ break;
+
+ case PM_MdiSubWindowMinimizedWidth: {
+ QRenderRule subRule = renderRule(w, PseudoElement_None, PseudoClass_Minimized);
+ int width = subRule.size().width();
+ if (width != -1)
+ return width;
+ break;
+ }
+ default:
+ break;
+ }
+
+ return baseStyle()->pixelMetric(m, opt, w);
+}
+
+QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
+ const QSize &csz, const QWidget *w) const
+{
+ RECURSION_GUARD(return baseStyle()->sizeFromContents(ct, opt, csz, w))
+
+ QRenderRule rule = renderRule(w, opt);
+ QSize sz = rule.adjustSize(csz);
+
+ switch (ct) {
+ case CT_SpinBox: // ### hopelessly broken QAbstractSpinBox (part 1)
+ if (rule.hasBox() || !rule.hasNativeBorder())
+ return csz;
+ return rule.baseStyleCanDraw() ? baseStyle()->sizeFromContents(ct, opt, sz, w)
+ : QWindowsStyle::sizeFromContents(ct, opt, sz, w);
+ case CT_ToolButton:
+ if (rule.hasBox() || !rule.hasNativeBorder() || !rule.baseStyleCanDraw())
+ sz += QSize(3, 3); // ### broken QToolButton
+ //fall thought
+ case CT_ComboBox:
+ case CT_PushButton:
+ if (rule.hasBox() || !rule.hasNativeBorder()) {
+ if(ct == CT_ComboBox) {
+ //add some space for the drop down.
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_ComboBoxDropDown);
+ QRect comboRect = positionRect(w, rule, subRule, PseudoElement_ComboBoxDropDown, opt->rect, opt->direction);
+ //+2 because there is hardcoded margins in QCommonStyle::drawControl(CE_ComboBoxLabel)
+ sz += QSize(comboRect.width() + 2, 0);
+ }
+ return rule.boxSize(sz);
+ }
+ sz = rule.baseStyleCanDraw() ? baseStyle()->sizeFromContents(ct, opt, sz, w)
+ : QWindowsStyle::sizeFromContents(ct, opt, sz, w);
+ return rule.boxSize(sz, Margin);
+
+ case CT_HeaderSection: {
+ if (const QStyleOptionHeader *hdr = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewSection);
+ if (subRule.hasGeometry() || subRule.hasBox() || !subRule.hasNativeBorder()) {
+ sz = subRule.adjustSize(csz);
+ if (!subRule.hasGeometry()) {
+ QSize nativeContentsSize;
+ bool nullIcon = hdr->icon.isNull();
+ int iconSize = nullIcon ? 0 : pixelMetric(QStyle::PM_SmallIconSize, hdr, w);
+ QSize txt = hdr->fontMetrics.size(0, hdr->text);
+ nativeContentsSize.setHeight(qMax(iconSize, txt.height()));
+ nativeContentsSize.setWidth(iconSize + txt.width());
+ sz = sz.expandedTo(nativeContentsSize);
+ }
+ return subRule.size(sz);
+ }
+ return subRule.baseStyleCanDraw() ? baseStyle()->sizeFromContents(ct, opt, sz, w)
+ : QWindowsStyle::sizeFromContents(ct, opt, sz, w);
+ }
+ }
+ break;
+ case CT_GroupBox:
+ case CT_LineEdit:
+#ifndef QT_NO_SPINBOX
+ // ### hopelessly broken QAbstractSpinBox (part 2)
+ if (QAbstractSpinBox *spinBox = qobject_cast<QAbstractSpinBox *>(w ? w->parentWidget() : 0)) {
+ QRenderRule rule = renderRule(spinBox, opt);
+ if (rule.hasBox() || !rule.hasNativeBorder())
+ return csz;
+ return rule.baseStyleCanDraw() ? baseStyle()->sizeFromContents(ct, opt, sz, w)
+ : QWindowsStyle::sizeFromContents(ct, opt, sz, w);
+ }
+#endif
+ if (rule.hasBox() || !rule.hasNativeBorder()) {
+ return rule.boxSize(sz);
+ }
+ break;
+
+ case CT_CheckBox:
+ case CT_RadioButton:
+ if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
+ if (rule.hasBox() || rule.hasBorder() || hasStyleRule(w, PseudoElement_Indicator)) {
+ bool isRadio = (ct == CT_RadioButton);
+ int iw = pixelMetric(isRadio ? PM_ExclusiveIndicatorWidth
+ : PM_IndicatorWidth, btn, w);
+ int ih = pixelMetric(isRadio ? PM_ExclusiveIndicatorHeight
+ : PM_IndicatorHeight, btn, w);
+
+ int spacing = pixelMetric(isRadio ? PM_RadioButtonLabelSpacing
+ : PM_CheckBoxLabelSpacing, btn, w);
+ sz.setWidth(sz.width() + iw + spacing);
+ sz.setHeight(qMax(sz.height(), ih));
+ return rule.boxSize(sz);
+ }
+ }
+ break;
+
+ case CT_Menu:
+ case CT_MenuBar: // already has everything!
+ case CT_ScrollBar:
+ if (rule.hasBox() || rule.hasBorder())
+ return sz;
+ break;
+
+ case CT_MenuItem:
+ if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
+ PseudoElement pe = (mi->menuItemType == QStyleOptionMenuItem::Separator)
+ ? PseudoElement_MenuSeparator : PseudoElement_Item;
+ QRenderRule subRule = renderRule(w, opt, pe);
+ if ((pe == PseudoElement_MenuSeparator) && subRule.hasContentsSize()) {
+ return QSize(sz.width(), subRule.size().height());
+ } else if ((pe == PseudoElement_Item) && (subRule.hasBox() || subRule.hasBorder())) {
+ int width = csz.width();
+ if (mi->text.contains(QLatin1Char('\t')))
+ width += 12; //as in QCommonStyle
+ return subRule.boxSize(subRule.adjustSize(QSize(width, csz.height())));
+ }
+ }
+ break;
+
+ case CT_Splitter:
+ case CT_MenuBarItem: {
+ PseudoElement pe = (ct == CT_Splitter) ? PseudoElement_SplitterHandle : PseudoElement_Item;
+ QRenderRule subRule = renderRule(w, opt, pe);
+ if (subRule.hasBox() || subRule.hasBorder())
+ return subRule.boxSize(sz);
+ break;
+ }
+
+ case CT_ProgressBar:
+ case CT_SizeGrip:
+ return (rule.hasContentsSize())
+ ? rule.size(sz)
+ : rule.boxSize(baseStyle()->sizeFromContents(ct, opt, sz, w));
+ break;
+
+ case CT_Slider:
+ if (rule.hasBorder() || rule.hasBox() || rule.hasGeometry())
+ return rule.boxSize(sz);
+ break;
+
+#ifndef QT_NO_TABBAR
+ case CT_TabBarTab: {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTab);
+ if (subRule.hasBox() || !subRule.hasNativeBorder()) {
+ int spaceForIcon = 0;
+ bool vertical = false;
+ if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
+ if (!tab->icon.isNull())
+ spaceForIcon = 6 /* icon offset */ + 4 /* spacing */ + 2 /* magic */; // ###: hardcoded to match with common style
+ vertical = verticalTabs(tab->shape);
+ }
+ sz = csz + QSize(vertical ? 0 : spaceForIcon, vertical ? spaceForIcon : 0);
+ return subRule.boxSize(subRule.adjustSize(sz));
+ }
+#ifdef Q_WS_MAC
+ if (baseStyle()->inherits("QMacStyle")) {
+ //adjust the size after the call to the style because the mac style ignore the size arguments anyway.
+ //this might cause the (max-){width,height} property to include the native style border while they should not.
+ return subRule.adjustSize(baseStyle()->sizeFromContents(ct, opt, csz, w));
+ }
+#endif
+ sz = subRule.adjustSize(csz);
+ break;
+ }
+#endif // QT_NO_TABBAR
+
+ case CT_MdiControls:
+ if (const QStyleOptionComplex *ccOpt = qstyleoption_cast<const QStyleOptionComplex *>(opt)) {
+ if (!hasStyleRule(w, PseudoElement_MdiCloseButton)
+ && !hasStyleRule(w, PseudoElement_MdiNormalButton)
+ && !hasStyleRule(w, PseudoElement_MdiMinButton))
+ break;
+
+ QList<QVariant> layout = rule.styleHint(QLatin1String("button-layout")).toList();
+ if (layout.isEmpty())
+ layout = subControlLayout(QLatin1String("mNX"));
+
+ int width = 0, height = 0;
+ for (int i = 0; i < layout.count(); i++) {
+ int layoutButton = layout[i].toInt();
+ if (layoutButton < PseudoElement_MdiCloseButton
+ || layoutButton > PseudoElement_MdiNormalButton)
+ continue;
+ QStyle::SubControl sc = knownPseudoElements[layoutButton].subControl;
+ if (!(ccOpt->subControls & sc))
+ continue;
+ QRenderRule subRule = renderRule(w, opt, layoutButton);
+ QSize sz = subRule.size();
+ width += sz.width();
+ height = qMax(height, sz.height());
+ }
+
+ return QSize(width, height);
+ }
+ break;
+
+#ifndef QT_NO_ITEMVIEWS
+ case CT_ItemViewItem: {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_ViewItem);
+ sz = baseStyle()->sizeFromContents(ct, opt, csz, w);
+ sz = subRule.adjustSize(sz);
+ if (subRule.hasBox() || subRule.hasBorder())
+ sz = subRule.boxSize(sz);
+ return sz;
+ }
+#endif // QT_NO_ITEMVIEWS
+
+ default:
+ break;
+ }
+
+ return baseStyle()->sizeFromContents(ct, opt, sz, w);
+}
+
+/*!
+ \internal
+*/
+static QLatin1String propertyNameForStandardPixmap(QStyle::StandardPixmap sp)
+{
+ switch (sp) {
+ case QStyle::SP_TitleBarMenuButton: return QLatin1String("titlebar-menu-icon");
+ case QStyle::SP_TitleBarMinButton: return QLatin1String("titlebar-minimize-icon");
+ case QStyle::SP_TitleBarMaxButton: return QLatin1String("titlebar-maximize-icon");
+ case QStyle::SP_TitleBarCloseButton: return QLatin1String("titlebar-close-icon");
+ case QStyle::SP_TitleBarNormalButton: return QLatin1String("titlebar-normal-icon");
+ case QStyle::SP_TitleBarShadeButton: return QLatin1String("titlebar-shade-icon");
+ case QStyle::SP_TitleBarUnshadeButton: return QLatin1String("titlebar-unshade-icon");
+ case QStyle::SP_TitleBarContextHelpButton: return QLatin1String("titlebar-contexthelp-icon");
+ case QStyle::SP_DockWidgetCloseButton: return QLatin1String("dockwidget-close-icon");
+ case QStyle::SP_MessageBoxInformation: return QLatin1String("messagebox-information-icon");
+ case QStyle::SP_MessageBoxWarning: return QLatin1String("messagebox-warning-icon");
+ case QStyle::SP_MessageBoxCritical: return QLatin1String("messagebox-critical-icon");
+ case QStyle::SP_MessageBoxQuestion: return QLatin1String("messagebox-question-icon");
+ case QStyle::SP_DesktopIcon: return QLatin1String("desktop-icon");
+ case QStyle::SP_TrashIcon: return QLatin1String("trash-icon");
+ case QStyle::SP_ComputerIcon: return QLatin1String("computer-icon");
+ case QStyle::SP_DriveFDIcon: return QLatin1String("floppy-icon");
+ case QStyle::SP_DriveHDIcon: return QLatin1String("harddisk-icon");
+ case QStyle::SP_DriveCDIcon: return QLatin1String("cd-icon");
+ case QStyle::SP_DriveDVDIcon: return QLatin1String("dvd-icon");
+ case QStyle::SP_DriveNetIcon: return QLatin1String("network-icon");
+ case QStyle::SP_DirOpenIcon: return QLatin1String("directory-open-icon");
+ case QStyle::SP_DirClosedIcon: return QLatin1String("directory-closed-icon");
+ case QStyle::SP_DirLinkIcon: return QLatin1String("directory-link-icon");
+ case QStyle::SP_FileIcon: return QLatin1String("file-icon");
+ case QStyle::SP_FileLinkIcon: return QLatin1String("file-link-icon");
+ case QStyle::SP_FileDialogStart: return QLatin1String("filedialog-start-icon");
+ case QStyle::SP_FileDialogEnd: return QLatin1String("filedialog-end-icon");
+ case QStyle::SP_FileDialogToParent: return QLatin1String("filedialog-parent-directory-icon");
+ case QStyle::SP_FileDialogNewFolder: return QLatin1String("filedialog-new-directory-icon");
+ case QStyle::SP_FileDialogDetailedView: return QLatin1String("filedialog-detailedview-icon");
+ case QStyle::SP_FileDialogInfoView: return QLatin1String("filedialog-infoview-icon");
+ case QStyle::SP_FileDialogContentsView: return QLatin1String("filedialog-contentsview-icon");
+ case QStyle::SP_FileDialogListView: return QLatin1String("filedialog-listview-icon");
+ case QStyle::SP_FileDialogBack: return QLatin1String("filedialog-backward-icon");
+ case QStyle::SP_DirIcon: return QLatin1String("directory-icon");
+ case QStyle::SP_DialogOkButton: return QLatin1String("dialog-ok-icon");
+ case QStyle::SP_DialogCancelButton: return QLatin1String("dialog-cancel-icon");
+ case QStyle::SP_DialogHelpButton: return QLatin1String("dialog-help-icon");
+ case QStyle::SP_DialogOpenButton: return QLatin1String("dialog-open-icon");
+ case QStyle::SP_DialogSaveButton: return QLatin1String("dialog-save-icon");
+ case QStyle::SP_DialogCloseButton: return QLatin1String("dialog-close-icon");
+ case QStyle::SP_DialogApplyButton: return QLatin1String("dialog-apply-icon");
+ case QStyle::SP_DialogResetButton: return QLatin1String("dialog-reset-icon");
+ case QStyle::SP_DialogDiscardButton: return QLatin1String("discard-icon");
+ case QStyle::SP_DialogYesButton: return QLatin1String("dialog-yes-icon");
+ case QStyle::SP_DialogNoButton: return QLatin1String("dialog-no-icon");
+ case QStyle::SP_ArrowUp: return QLatin1String("uparrow-icon");
+ case QStyle::SP_ArrowDown: return QLatin1String("downarrow-icon");
+ case QStyle::SP_ArrowLeft: return QLatin1String("leftarrow-icon");
+ case QStyle::SP_ArrowRight: return QLatin1String("rightarrow-icon");
+ case QStyle::SP_ArrowBack: return QLatin1String("backward-icon");
+ case QStyle::SP_ArrowForward: return QLatin1String("forward-icon");
+ case QStyle::SP_DirHomeIcon: return QLatin1String("home-icon");
+ default: return QLatin1String("");
+ }
+}
+
+QIcon QStyleSheetStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt,
+ const QWidget *w) const
+{
+ RECURSION_GUARD(return baseStyle()->standardIcon(standardIcon, opt, w))
+ QString s = propertyNameForStandardPixmap(standardIcon);
+ if (!s.isEmpty()) {
+ QRenderRule rule = renderRule(w, opt);
+ if (rule.hasStyleHint(s))
+ return qvariant_cast<QIcon>(rule.styleHint(s));
+ }
+ return baseStyle()->standardIcon(standardIcon, opt, w);
+}
+
+QPalette QStyleSheetStyle::standardPalette() const
+{
+ return baseStyle()->standardPalette();
+}
+
+QPixmap QStyleSheetStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
+ const QWidget *w) const
+{
+ RECURSION_GUARD(return baseStyle()->standardPixmap(standardPixmap, opt, w))
+ QString s = propertyNameForStandardPixmap(standardPixmap);
+ if (!s.isEmpty()) {
+ QRenderRule rule = renderRule(w, opt);
+ if (rule.hasStyleHint(s)) {
+ QIcon icon = qvariant_cast<QIcon>(rule.styleHint(s));
+ return icon.pixmap(16, 16); // ###: unhard-code this if someone complains
+ }
+ }
+ return baseStyle()->standardPixmap(standardPixmap, opt, w);
+}
+
+int QStyleSheetStyle::layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2,
+ Qt::Orientation orientation, const QStyleOption *option,
+ const QWidget *widget) const
+{
+ return baseStyle()->layoutSpacing(control1, control2, orientation, option, widget);
+}
+
+int QStyleSheetStyle::layoutSpacingImplementation(QSizePolicy::ControlType control1 ,
+ QSizePolicy::ControlType control2,
+ Qt::Orientation orientation,
+ const QStyleOption * option ,
+ const QWidget * widget) const
+{
+ return baseStyle()->layoutSpacing(control1, control2, orientation, option, widget);
+}
+
+int QStyleSheetStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w,
+ QStyleHintReturn *shret) const
+{
+ RECURSION_GUARD(return baseStyle()->styleHint(sh, opt, w, shret))
+ // Prevent endless loop if somebody use isActiveWindow property as selector.
+ // QWidget::isActiveWindow uses this styleHint to determine if the window is active or not
+ if (sh == SH_Widget_ShareActivation)
+ return baseStyle()->styleHint(sh, opt, w, shret);
+
+ QRenderRule rule = renderRule(w, opt);
+ QString s;
+ switch (sh) {
+ case SH_LineEdit_PasswordCharacter: s = QLatin1String("lineedit-password-character"); break;
+ case SH_DitherDisabledText: s = QLatin1String("dither-disabled-text"); break;
+ case SH_EtchDisabledText: s = QLatin1String("etch-disabled-text"); break;
+ case SH_ItemView_ActivateItemOnSingleClick: s = QLatin1String("activate-on-singleclick"); break;
+ case SH_ItemView_ShowDecorationSelected: s = QLatin1String("show-decoration-selected"); break;
+ case SH_Table_GridLineColor: s = QLatin1String("gridline-color"); break;
+ case SH_DialogButtonLayout: s = QLatin1String("button-layout"); break;
+ case SH_ToolTipLabel_Opacity: s = QLatin1String("opacity"); break;
+ case SH_ComboBox_Popup: s = QLatin1String("combobox-popup"); break;
+ case SH_ComboBox_ListMouseTracking: s = QLatin1String("combobox-list-mousetracking"); break;
+ case SH_MenuBar_AltKeyNavigation: s = QLatin1String("menubar-altkey-navigation"); break;
+ case SH_Menu_Scrollable: s = QLatin1String("menu-scrollable"); break;
+ case SH_DrawMenuBarSeparator: s = QLatin1String("menubar-separator"); break;
+ case SH_MenuBar_MouseTracking: s = QLatin1String("mouse-tracking"); break;
+ case SH_SpinBox_ClickAutoRepeatRate: s = QLatin1String("spinbox-click-autorepeat-rate"); break;
+ case SH_SpinControls_DisableOnBounds: s = QLatin1String("spincontrol-disable-on-bounds"); break;
+ case SH_MessageBox_TextInteractionFlags: s = QLatin1String("messagebox-text-interaction-flags"); break;
+ case SH_ToolButton_PopupDelay: s = QLatin1String("toolbutton-popup-delay"); break;
+ case SH_ToolBox_SelectedPageTitleBold:
+ if (renderRule(w, opt, PseudoElement_ToolBoxTab).hasFont)
+ return 0;
+ break;
+ case SH_GroupBox_TextLabelColor:
+ if (rule.hasPalette() && rule.palette()->foreground.style() != Qt::NoBrush)
+ return rule.palette()->foreground.color().rgba();
+ break;
+ case SH_ScrollView_FrameOnlyAroundContents: s = QLatin1String("scrollview-frame-around-contents"); break;
+ case SH_ScrollBar_ContextMenu: s = QLatin1String("scrollbar-contextmenu"); break;
+ case SH_ScrollBar_LeftClickAbsolutePosition: s = QLatin1String("scrollbar-leftclick-absolute-position"); break;
+ case SH_ScrollBar_MiddleClickAbsolutePosition: s = QLatin1String("scrollbar-middleclick-absolute-position"); break;
+ case SH_ScrollBar_RollBetweenButtons: s = QLatin1String("scrollbar-roll-between-buttons"); break;
+ case SH_ScrollBar_ScrollWhenPointerLeavesControl: s = QLatin1String("scrollbar-scroll-when-pointer-leaves-control"); break;
+ case SH_TabBar_Alignment:
+#ifndef QT_NO_TABWIDGET
+ if (qobject_cast<const QTabWidget *>(w)) {
+ rule = renderRule(w, opt, PseudoElement_TabWidgetTabBar);
+ if (rule.hasPosition())
+ return rule.position()->position;
+ }
+#endif // QT_NO_TABWIDGET
+ s = QLatin1String("alignment");
+ break;
+#ifndef QT_NO_TABBAR
+ case SH_TabBar_CloseButtonPosition:
+ rule = renderRule(w, opt, PseudoElement_TabBarTabCloseButton);
+ if (rule.hasPosition()) {
+ Qt::Alignment align = rule.position()->position;
+ if (align & Qt::AlignLeft || align & Qt::AlignTop)
+ return QTabBar::LeftSide;
+ if (align & Qt::AlignRight || align & Qt::AlignBottom)
+ return QTabBar::RightSide;
+ }
+ break;
+#endif
+ case SH_TabBar_ElideMode: s = QLatin1String("tabbar-elide-mode"); break;
+ case SH_TabBar_PreferNoArrows: s = QLatin1String("tabbar-prefer-no-arrows"); break;
+ case SH_ComboBox_PopupFrameStyle:
+#ifndef QT_NO_COMBOBOX
+ if (qobject_cast<const QComboBox *>(w)) {
+ QAbstractItemView *view = w->findChild<QAbstractItemView *>();
+ if (view) {
+ view->ensurePolished();
+ QRenderRule subRule = renderRule(view, PseudoElement_None);
+ if (subRule.hasBox() || !subRule.hasNativeBorder())
+ return QFrame::NoFrame;
+ }
+ }
+#endif // QT_NO_COMBOBOX
+ break;
+ case SH_DialogButtonBox_ButtonsHaveIcons: s = QLatin1String("dialogbuttonbox-buttons-have-icons"); break;
+ case SH_Workspace_FillSpaceOnMaximize: s = QLatin1String("mdi-fill-space-on-maximize"); break;
+ case SH_TitleBar_NoBorder:
+ if (rule.hasBorder())
+ return !rule.border()->borders[LeftEdge];
+ break;
+ case SH_TitleBar_AutoRaise: { // plain absurd
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_TitleBar);
+ if (subRule.hasDrawable())
+ return 1;
+ break;
+ }
+ case SH_ItemView_ArrowKeysNavigateIntoChildren: s = QLatin1String("arrow-keys-navigate-into-children"); break;
+ case SH_ItemView_PaintAlternatingRowColorsForEmptyArea: s = QLatin1String("paint-alternating-row-colors-for-empty-area"); break;
+ default: break;
+ }
+ if (!s.isEmpty() && rule.hasStyleHint(s)) {
+ return rule.styleHint(s).toInt();
+ }
+
+ return baseStyle()->styleHint(sh, opt, w, shret);
+}
+
+QRect QStyleSheetStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc,
+ const QWidget *w) const
+{
+ RECURSION_GUARD(return baseStyle()->subControlRect(cc, opt, sc, w))
+
+ QRenderRule rule = renderRule(w, opt);
+ switch (cc) {
+ case CC_ComboBox:
+ if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
+ if (rule.hasBox() || !rule.hasNativeBorder()) {
+ switch (sc) {
+ case SC_ComboBoxFrame: return rule.borderRect(opt->rect);
+ case SC_ComboBoxEditField:
+ {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_ComboBoxDropDown);
+ QRect r = rule.contentsRect(opt->rect);
+ QRect r2 = positionRect(w, rule, subRule, PseudoElement_ComboBoxDropDown,
+ opt->rect, opt->direction);
+ if (subRule.hasPosition() && subRule.position()->position & Qt::AlignLeft) {
+ return visualRect(opt->direction, r, r.adjusted(r2.width(),0,0,0));
+ } else {
+ return visualRect(opt->direction, r, r.adjusted(0,0,-r2.width(),0));
+ }
+ }
+ case SC_ComboBoxArrow: {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_ComboBoxDropDown);
+ return positionRect(w, rule, subRule, PseudoElement_ComboBoxDropDown, opt->rect, opt->direction);
+ }
+ case SC_ComboBoxListBoxPopup:
+ default:
+ return baseStyle()->subControlRect(cc, opt, sc, w);
+ }
+ }
+
+ QStyleOptionComboBox comboBox(*cb);
+ comboBox.rect = rule.borderRect(opt->rect);
+ return rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, &comboBox, sc, w)
+ : QWindowsStyle::subControlRect(cc, &comboBox, sc, w);
+ }
+ break;
+
+#ifndef QT_NO_SPINBOX
+ case CC_SpinBox:
+ if (const QStyleOptionSpinBox *spin = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
+ QRenderRule upRule = renderRule(w, opt, PseudoElement_SpinBoxUpButton);
+ QRenderRule downRule = renderRule(w, opt, PseudoElement_SpinBoxDownButton);
+ bool ruleMatch = rule.hasBox() || !rule.hasNativeBorder();
+ bool upRuleMatch = upRule.hasGeometry() || upRule.hasPosition();
+ bool downRuleMatch = downRule.hasGeometry() || upRule.hasPosition();
+ if (ruleMatch || upRuleMatch || downRuleMatch) {
+ switch (sc) {
+ case SC_SpinBoxFrame:
+ return rule.borderRect(opt->rect);
+ case SC_SpinBoxEditField:
+ {
+ QRect r = rule.contentsRect(opt->rect);
+ // Use the widest button on each side to determine edit field size.
+ Qt::Alignment upAlign, downAlign;
+
+ upAlign = upRule.hasPosition() ? upRule.position()->position
+ : Qt::Alignment(Qt::AlignRight);
+ upAlign = resolveAlignment(opt->direction, upAlign);
+
+ downAlign = downRule.hasPosition() ? downRule.position()->position
+ : Qt::Alignment(Qt::AlignRight);
+ downAlign = resolveAlignment(opt->direction, downAlign);
+
+ int upSize = subControlRect(CC_SpinBox, opt, SC_SpinBoxUp, w).width();
+ int downSize = subControlRect(CC_SpinBox, opt, SC_SpinBoxDown, w).width();
+ int widestL = qMax((upAlign & Qt::AlignLeft) ? upSize : 0,
+ (downAlign & Qt::AlignLeft) ? downSize : 0);
+ int widestR = qMax((upAlign & Qt::AlignRight) ? upSize : 0,
+ (downAlign & Qt::AlignRight) ? downSize : 0);
+ r.setRight(r.right() - widestR);
+ r.setLeft(r.left() + widestL);
+ return r;
+ }
+ case SC_SpinBoxDown:
+ if (downRuleMatch)
+ return positionRect(w, rule, downRule, PseudoElement_SpinBoxDownButton,
+ opt->rect, opt->direction);
+ break;
+ case SC_SpinBoxUp:
+ if (upRuleMatch)
+ return positionRect(w, rule, upRule, PseudoElement_SpinBoxUpButton,
+ opt->rect, opt->direction);
+ break;
+ default:
+ break;
+ }
+
+ return baseStyle()->subControlRect(cc, opt, sc, w);
+ }
+
+ QStyleOptionSpinBox spinBox(*spin);
+ spinBox.rect = rule.borderRect(opt->rect);
+ return rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, &spinBox, sc, w)
+ : QWindowsStyle::subControlRect(cc, &spinBox, sc, w);
+ }
+ break;
+#endif // QT_NO_SPINBOX
+
+ case CC_GroupBox:
+ if (const QStyleOptionGroupBox *gb = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
+ switch (sc) {
+ case SC_GroupBoxFrame:
+ case SC_GroupBoxContents: {
+ if (rule.hasBox() || !rule.hasNativeBorder()) {
+ return sc == SC_GroupBoxFrame ? rule.borderRect(opt->rect)
+ : rule.contentsRect(opt->rect);
+ }
+ QStyleOptionGroupBox groupBox(*gb);
+ groupBox.rect = rule.borderRect(opt->rect);
+ return baseStyle()->subControlRect(cc, &groupBox, sc, w);
+ }
+ default:
+ case SC_GroupBoxLabel:
+ case SC_GroupBoxCheckBox: {
+ QRenderRule indRule = renderRule(w, opt, PseudoElement_GroupBoxIndicator);
+ QRenderRule labelRule = renderRule(w, opt, PseudoElement_GroupBoxTitle);
+ if (!labelRule.hasPosition() && !labelRule.hasGeometry() && !labelRule.hasBox()
+ && !labelRule.hasBorder() && !indRule.hasContentsSize()) {
+ QStyleOptionGroupBox groupBox(*gb);
+ groupBox.rect = rule.borderRect(opt->rect);
+ return baseStyle()->subControlRect(cc, &groupBox, sc, w);
+ }
+ int tw = opt->fontMetrics.width(gb->text);
+ int th = opt->fontMetrics.height();
+ int spacing = pixelMetric(QStyle::PM_CheckBoxLabelSpacing, opt, w);
+ int iw = pixelMetric(QStyle::PM_IndicatorWidth, opt, w);
+ int ih = pixelMetric(QStyle::PM_IndicatorHeight, opt, w);
+
+ if (gb->subControls & QStyle::SC_GroupBoxCheckBox) {
+ tw = tw + iw + spacing;
+ th = qMax(th, ih);
+ }
+ if (!labelRule.hasGeometry()) {
+ labelRule.geo = new QStyleSheetGeometryData(tw, th, tw, th, -1, -1);
+ } else {
+ labelRule.geo->width = tw;
+ labelRule.geo->height = th;
+ }
+ if (!labelRule.hasPosition()) {
+ labelRule.p = new QStyleSheetPositionData(0, 0, 0, 0, defaultOrigin(PseudoElement_GroupBoxTitle),
+ gb->textAlignment, PositionMode_Static);
+ }
+ QRect r = positionRect(w, rule, labelRule, PseudoElement_GroupBoxTitle,
+ opt->rect, opt->direction);
+ if (gb->subControls & SC_GroupBoxCheckBox) {
+ r = labelRule.contentsRect(r);
+ if (sc == SC_GroupBoxLabel) {
+ r.setLeft(r.left() + iw + spacing);
+ r.setTop(r.center().y() - th/2);
+ } else {
+ r = QRect(r.left(), r.center().y() - ih/2, iw, ih);
+ }
+ return r;
+ } else {
+ return labelRule.contentsRect(r);
+ }
+ }
+ } // switch
+ }
+ break;
+
+ case CC_ToolButton:
+ if (const QStyleOptionToolButton *tb = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
+ if (rule.hasBox() || !rule.hasNativeBorder()) {
+ switch (sc) {
+ case SC_ToolButton: return rule.borderRect(opt->rect);
+ case SC_ToolButtonMenu: {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_ToolButtonMenu);
+ return positionRect(w, rule, subRule, PseudoElement_ToolButtonMenu, opt->rect, opt->direction);
+ }
+ default:
+ break;
+ }
+ }
+
+ QStyleOptionToolButton tool(*tb);
+ tool.rect = rule.borderRect(opt->rect);
+ return rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, &tool, sc, w)
+ : QWindowsStyle::subControlRect(cc, &tool, sc, w);
+ }
+ break;
+
+#ifndef QT_NO_SCROLLBAR
+ case CC_ScrollBar:
+ if (const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
+ QStyleOptionSlider styleOptionSlider(*sb);
+ styleOptionSlider.rect = rule.borderRect(opt->rect);
+ if (rule.hasDrawable() || rule.hasBox()) {
+ QRect grooveRect;
+ if (!rule.hasBox()) {
+ grooveRect = rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, sb, SC_ScrollBarGroove, w)
+ : QWindowsStyle::subControlRect(cc, sb, SC_ScrollBarGroove, w);
+ } else {
+ grooveRect = rule.contentsRect(opt->rect);
+ }
+
+ PseudoElement pe = PseudoElement_None;
+
+ switch (sc) {
+ case SC_ScrollBarGroove:
+ return grooveRect;
+ case SC_ScrollBarAddPage:
+ case SC_ScrollBarSubPage:
+ case SC_ScrollBarSlider: {
+ QRect contentRect = grooveRect;
+ if (hasStyleRule(w, PseudoElement_ScrollBarSlider)) {
+ QRenderRule sliderRule = renderRule(w, opt, PseudoElement_ScrollBarSlider);
+ Origin origin = sliderRule.hasPosition() ? sliderRule.position()->origin : defaultOrigin(PseudoElement_ScrollBarSlider);
+ contentRect = rule.originRect(opt->rect, origin);
+ }
+ int maxlen = (styleOptionSlider.orientation == Qt::Horizontal) ? contentRect.width() : contentRect.height();
+ int sliderlen;
+ if (sb->maximum != sb->minimum) {
+ uint range = sb->maximum - sb->minimum;
+ sliderlen = (qint64(sb->pageStep) * maxlen) / (range + sb->pageStep);
+
+ int slidermin = pixelMetric(PM_ScrollBarSliderMin, sb, w);
+ if (sliderlen < slidermin || range > INT_MAX / 2)
+ sliderlen = slidermin;
+ if (sliderlen > maxlen)
+ sliderlen = maxlen;
+ } else {
+ sliderlen = maxlen;
+ }
+
+ int sliderstart = (styleOptionSlider.orientation == Qt::Horizontal ? contentRect.left() : contentRect.top())
+ + sliderPositionFromValue(sb->minimum, sb->maximum, sb->sliderPosition,
+ maxlen - sliderlen, sb->upsideDown);
+
+ QRect sr = (sb->orientation == Qt::Horizontal)
+ ? QRect(sliderstart, contentRect.top(), sliderlen, contentRect.height())
+ : QRect(contentRect.left(), sliderstart, contentRect.width(), sliderlen);
+ if (sc == SC_ScrollBarSlider) {
+ return sr;
+ } else if (sc == SC_ScrollBarSubPage) {
+ return QRect(contentRect.topLeft(), sb->orientation == Qt::Horizontal ? sr.bottomLeft() : sr.topRight());
+ } else { // SC_ScrollBarAddPage
+ return QRect(sb->orientation == Qt::Horizontal ? sr.topRight() : sr.bottomLeft(), contentRect.bottomRight());
+ }
+ break;
+ }
+ case SC_ScrollBarAddLine: pe = PseudoElement_ScrollBarAddLine; break;
+ case SC_ScrollBarSubLine: pe = PseudoElement_ScrollBarSubLine; break;
+ case SC_ScrollBarFirst: pe = PseudoElement_ScrollBarFirst; break;
+ case SC_ScrollBarLast: pe = PseudoElement_ScrollBarLast; break;
+ default: break;
+ }
+ if (hasStyleRule(w,pe)) {
+ QRenderRule subRule = renderRule(w, opt, pe);
+ if (subRule.hasPosition() || subRule.hasGeometry() || subRule.hasBox()) {
+ const QStyleSheetPositionData *pos = subRule.position();
+ QRect originRect = grooveRect;
+ if (rule.hasBox()) {
+ Origin origin = (pos && pos->origin != Origin_Unknown) ? pos->origin : defaultOrigin(pe);
+ originRect = rule.originRect(opt->rect, origin);
+ }
+ return positionRect(w, subRule, pe, originRect, styleOptionSlider.direction);
+ }
+ }
+ }
+ return rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, &styleOptionSlider, sc, w)
+ : QWindowsStyle::subControlRect(cc, &styleOptionSlider, sc, w);
+ }
+ break;
+#endif // QT_NO_SCROLLBAR
+
+#ifndef QT_NO_SLIDER
+ case CC_Slider:
+ if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_SliderGroove);
+ if (!subRule.hasDrawable())
+ break;
+ subRule.img = 0;
+ QRect gr = positionRect(w, rule, subRule, PseudoElement_SliderGroove, opt->rect, opt->direction);
+ switch (sc) {
+ case SC_SliderGroove:
+ return gr;
+ case SC_SliderHandle: {
+ bool horizontal = slider->orientation & Qt::Horizontal;
+ QRect cr = subRule.contentsRect(gr);
+ QRenderRule subRule2 = renderRule(w, opt, PseudoElement_SliderHandle);
+ int len = horizontal ? subRule2.size().width() : subRule2.size().height();
+ subRule2.img = 0;
+ subRule2.geo = 0;
+ cr = positionRect(w, subRule2, PseudoElement_SliderHandle, cr, opt->direction);
+ int thickness = horizontal ? cr.height() : cr.width();
+ int sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum, slider->sliderPosition,
+ (horizontal ? cr.width() : cr.height()) - len, slider->upsideDown);
+ cr = horizontal ? QRect(cr.x() + sliderPos, cr.y(), len, thickness)
+ : QRect(cr.x(), cr.y() + sliderPos, thickness, len);
+ return subRule2.borderRect(cr);
+ break; }
+ case SC_SliderTickmarks:
+ // TODO...
+ default:
+ break;
+ }
+ }
+ break;
+#endif // QT_NO_SLIDER
+
+ case CC_MdiControls:
+ if (hasStyleRule(w, PseudoElement_MdiCloseButton)
+ || hasStyleRule(w, PseudoElement_MdiNormalButton)
+ || hasStyleRule(w, PseudoElement_MdiMinButton)) {
+ QList<QVariant> layout = rule.styleHint(QLatin1String("button-layout")).toList();
+ if (layout.isEmpty())
+ layout = subControlLayout(QLatin1String("mNX"));
+
+ int x = 0, width = 0;
+ QRenderRule subRule;
+ for (int i = 0; i < layout.count(); i++) {
+ int layoutButton = layout[i].toInt();
+ if (layoutButton < PseudoElement_MdiCloseButton
+ || layoutButton > PseudoElement_MdiNormalButton)
+ continue;
+ QStyle::SubControl control = knownPseudoElements[layoutButton].subControl;
+ if (!(opt->subControls & control))
+ continue;
+ subRule = renderRule(w, opt, layoutButton);
+ width = subRule.size().width();
+ if (sc == control)
+ break;
+ x += width;
+ }
+
+ return subRule.borderRect(QRect(x, opt->rect.top(), width, opt->rect.height()));
+ }
+ break;
+
+ case CC_TitleBar:
+ if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_TitleBar);
+ if (!subRule.hasDrawable() && !subRule.hasBox() && !subRule.hasBorder())
+ break;
+ QHash<QStyle::SubControl, QRect> layoutRects = titleBarLayout(w, tb);
+ return layoutRects.value(sc);
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ return baseStyle()->subControlRect(cc, opt, sc, w);
+}
+
+QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, const QWidget *w) const
+{
+ RECURSION_GUARD(return baseStyle()->subElementRect(se, opt, w))
+
+ QRenderRule rule = renderRule(w, opt);
+#ifndef QT_NO_TABBAR
+ int pe = PseudoElement_None;
+#endif
+
+ switch (se) {
+ case SE_PushButtonContents:
+ case SE_PushButtonFocusRect:
+ if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
+ QStyleOptionButton btnOpt(*btn);
+ if (rule.hasBox() || !rule.hasNativeBorder())
+ return visualRect(opt->direction, opt->rect, rule.contentsRect(opt->rect));
+ return rule.baseStyleCanDraw() ? baseStyle()->subElementRect(se, &btnOpt, w)
+ : QWindowsStyle::subElementRect(se, &btnOpt, w);
+ }
+ break;
+
+ case SE_LineEditContents:
+ case SE_FrameContents:
+ case SE_ShapedFrameContents:
+ if (rule.hasBox() || !rule.hasNativeBorder()) {
+ return visualRect(opt->direction, opt->rect, rule.contentsRect(opt->rect));
+ }
+ break;
+
+ case SE_CheckBoxIndicator:
+ case SE_RadioButtonIndicator:
+ if (rule.hasBox() || rule.hasBorder() || hasStyleRule(w, PseudoElement_Indicator)) {
+ PseudoElement pe = se == SE_CheckBoxIndicator ? PseudoElement_Indicator : PseudoElement_ExclusiveIndicator;
+ QRenderRule subRule = renderRule(w, opt, pe);
+ return positionRect(w, rule, subRule, pe, opt->rect, opt->direction);
+ }
+ break;
+
+ case SE_CheckBoxContents:
+ case SE_RadioButtonContents:
+ if (rule.hasBox() || rule.hasBorder() || hasStyleRule(w, PseudoElement_Indicator)) {
+ bool isRadio = se == SE_RadioButtonContents;
+ QRect ir = subElementRect(isRadio ? SE_RadioButtonIndicator : SE_CheckBoxIndicator,
+ opt, w);
+ ir = visualRect(opt->direction, opt->rect, ir);
+ int spacing = pixelMetric(isRadio ? PM_RadioButtonLabelSpacing : PM_CheckBoxLabelSpacing, 0, w);
+ QRect cr = rule.contentsRect(opt->rect);
+ ir.setRect(ir.left() + ir.width() + spacing, cr.y(),
+ cr.width() - ir.width() - spacing, cr.height());
+ return visualRect(opt->direction, opt->rect, ir);
+ }
+ break;
+
+ case SE_ToolBoxTabContents:
+ if (w && hasStyleRule(w->parentWidget(), PseudoElement_ToolBoxTab)) {
+ QRenderRule subRule = renderRule(w->parentWidget(), opt, PseudoElement_ToolBoxTab);
+ return visualRect(opt->direction, opt->rect, subRule.contentsRect(opt->rect));
+ }
+ break;
+
+ case SE_RadioButtonFocusRect:
+ case SE_RadioButtonClickRect: // focusrect | indicator
+ if (rule.hasBox() || rule.hasBorder() || hasStyleRule(w, PseudoElement_Indicator)) {
+ return opt->rect;
+ }
+ break;
+
+ case SE_CheckBoxFocusRect:
+ case SE_CheckBoxClickRect: // relies on indicator and contents
+ return ParentStyle::subElementRect(se, opt, w);
+
+#ifndef QT_NO_ITEMVIEWS
+ case SE_ViewItemCheckIndicator:
+ if (!qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
+ return subElementRect(SE_CheckBoxIndicator, opt, w);
+ }
+ // intentionally falls through
+ case SE_ItemViewItemText:
+ case SE_ItemViewItemDecoration:
+ case SE_ItemViewItemFocusRect:
+ if (const QStyleOptionViewItemV4 *vopt = qstyleoption_cast<const QStyleOptionViewItemV4 *>(opt)) {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_ViewItem);
+ PseudoElement pe = PseudoElement_None;
+ if (se == SE_ItemViewItemText || se == SE_ItemViewItemFocusRect)
+ pe = PseudoElement_ViewItemText;
+ else if (se == SE_ItemViewItemDecoration && vopt->features & QStyleOptionViewItemV2::HasDecoration)
+ pe = PseudoElement_ViewItemIcon;
+ else if (se == SE_ItemViewItemCheckIndicator && vopt->features & QStyleOptionViewItemV2::HasCheckIndicator)
+ pe = PseudoElement_ViewItemIndicator;
+ else
+ break;
+ if (subRule.hasGeometry() || subRule.hasBox() || !subRule.hasNativeBorder() || hasStyleRule(w, pe)) {
+ QRenderRule subRule2 = renderRule(w, opt, pe);
+ QStyleOptionViewItemV4 optCopy(*vopt);
+ optCopy.rect = subRule.contentsRect(vopt->rect);
+ QRect rect = ParentStyle::subElementRect(se, &optCopy, w);
+ return positionRect(w, subRule2, pe, rect, opt->direction);
+ }
+ }
+ break;
+#endif // QT_NO_ITEMVIEWS
+
+ case SE_HeaderArrow: {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewUpArrow);
+ if (subRule.hasPosition() || subRule.hasGeometry())
+ return positionRect(w, rule, subRule, PseudoElement_HeaderViewUpArrow, opt->rect, opt->direction);
+ }
+ break;
+
+ case SE_HeaderLabel: {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewSection);
+ if (subRule.hasBox() || !subRule.hasNativeBorder())
+ return subRule.contentsRect(opt->rect);
+ }
+ break;
+
+ case SE_ProgressBarGroove:
+ case SE_ProgressBarContents:
+ case SE_ProgressBarLabel:
+ if (const QStyleOptionProgressBarV2 *pb = qstyleoption_cast<const QStyleOptionProgressBarV2 *>(opt)) {
+ if (rule.hasBox() || !rule.hasNativeBorder() || rule.hasPosition() || hasStyleRule(w, PseudoElement_ProgressBarChunk)) {
+ if (se == SE_ProgressBarGroove)
+ return rule.borderRect(pb->rect);
+ else if (se == SE_ProgressBarContents)
+ return rule.contentsRect(pb->rect);
+
+ QSize sz = pb->fontMetrics.size(0, pb->text);
+ return QStyle::alignedRect(Qt::LeftToRight, rule.hasPosition() ? rule.position()->textAlignment : pb->textAlignment,
+ sz, pb->rect);
+ }
+ }
+ break;
+
+#ifndef QT_NO_TABBAR
+ case SE_TabWidgetLeftCorner:
+ pe = PseudoElement_TabWidgetLeftCorner;
+ // intentionally falls through
+ case SE_TabWidgetRightCorner:
+ if (pe == PseudoElement_None)
+ pe = PseudoElement_TabWidgetRightCorner;
+ // intentionally falls through
+ case SE_TabWidgetTabBar:
+ if (pe == PseudoElement_None)
+ pe = PseudoElement_TabWidgetTabBar;
+ // intentionally falls through
+ case SE_TabWidgetTabPane:
+ case SE_TabWidgetTabContents:
+ if (pe == PseudoElement_None)
+ pe = PseudoElement_TabWidgetPane;
+
+ if (hasStyleRule(w, pe)) {
+ QRect r = QWindowsStyle::subElementRect(pe == PseudoElement_TabWidgetPane ? SE_TabWidgetTabPane : se, opt, w);
+ QRenderRule subRule = renderRule(w, opt, pe);
+ r = positionRect(w, subRule, pe, r, opt->direction);
+ if (pe == PseudoElement_TabWidgetTabBar) {
+ Q_ASSERT(opt);
+ r = opt->rect.intersected(r);
+ }
+ if (se == SE_TabWidgetTabContents)
+ r = subRule.contentsRect(r);
+ return r;
+ }
+ break;
+
+ case SE_TabBarTearIndicator: {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTear);
+ if (subRule.hasContentsSize()) {
+ QRect r;
+ if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
+ switch (tab->shape) {
+ case QTabBar::RoundedNorth:
+ case QTabBar::TriangularNorth:
+ case QTabBar::RoundedSouth:
+ case QTabBar::TriangularSouth:
+ r.setRect(tab->rect.left(), tab->rect.top(), subRule.size().width(), opt->rect.height());
+ break;
+ case QTabBar::RoundedWest:
+ case QTabBar::TriangularWest:
+ case QTabBar::RoundedEast:
+ case QTabBar::TriangularEast:
+ r.setRect(tab->rect.left(), tab->rect.top(), opt->rect.width(), subRule.size().height());
+ break;
+ default:
+ break;
+ }
+ r = visualRect(opt->direction, opt->rect, r);
+ }
+ return r;
+ }
+ break;
+ }
+ case SE_TabBarTabText:
+ case SE_TabBarTabLeftButton:
+ case SE_TabBarTabRightButton: {
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTab);
+ if (subRule.hasBox() || !subRule.hasNativeBorder()) {
+ return ParentStyle::subElementRect(se, opt, w);
+ }
+ break;
+ }
+#endif // QT_NO_TABBAR
+
+ case SE_DockWidgetCloseButton:
+ case SE_DockWidgetFloatButton: {
+ PseudoElement pe = (se == SE_DockWidgetCloseButton) ? PseudoElement_DockWidgetCloseButton : PseudoElement_DockWidgetFloatButton;
+ QRenderRule subRule2 = renderRule(w, opt, pe);
+ if (!subRule2.hasPosition())
+ break;
+ QRenderRule subRule = renderRule(w, opt, PseudoElement_DockWidgetTitle);
+ return positionRect(w, subRule, subRule2, pe, opt->rect, opt->direction);
+ }
+
+#ifndef QT_NO_TOOLBAR
+ case SE_ToolBarHandle:
+ if (hasStyleRule(w, PseudoElement_ToolBarHandle))
+ return ParentStyle::subElementRect(se, opt, w);
+ break;
+#endif //QT_NO_TOOLBAR
+
+ default:
+ break;
+ }
+
+ return baseStyle()->subElementRect(se, opt, w);
+}
+
+bool QStyleSheetStyle::event(QEvent *e)
+{
+ return (baseStyle()->event(e) && e->isAccepted()) || ParentStyle::event(e);
+}
+
+void QStyleSheetStyle::updateStyleSheetFont(QWidget* w) const
+{
+ QWidget *container = containerWidget(w);
+ QRenderRule rule = renderRule(container, PseudoElement_None,
+ PseudoClass_Active | PseudoClass_Enabled | extendedPseudoClass(container));
+ QFont font = rule.font.resolve(w->font());
+
+ if ((!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))
+ && isNaturalChild(w) && qobject_cast<QWidget *>(w->parent())) {
+
+ font = font.resolve(static_cast<QWidget *>(w->parent())->font());
+ }
+
+ if (w->data->fnt == font)
+ return;
+
+#ifdef QT3_SUPPORT
+ QFont old = w->data->fnt;
+#endif
+ w->data->fnt = font;
+#if defined(Q_WS_X11)
+ // make sure the font set on this widget is associated with the correct screen
+ //w->data->fnt.x11SetScreen(w->d_func()->xinfo.screen());
+#endif
+
+ QEvent e(QEvent::FontChange);
+ QApplication::sendEvent(w, &e);
+#ifdef QT3_SUPPORT
+ w->fontChange(old);
+#endif
+}
+
+void QStyleSheetStyle::saveWidgetFont(QWidget* w, const QFont& font) const
+{
+ w->setProperty("_q_styleSheetWidgetFont", font);
+}
+
+void QStyleSheetStyle::clearWidgetFont(QWidget* w) const
+{
+ w->setProperty("_q_styleSheetWidgetFont", QVariant(QVariant::Invalid));
+}
+
+// Polish palette that should be used for a particular widget, with particular states
+// (eg. :focus, :hover, ...)
+// this is called by widgets that paint themself in their paint event
+// Returns true if there is a new palette in pal.
+bool QStyleSheetStyle::styleSheetPalette(const QWidget* w, const QStyleOption* opt, QPalette* pal)
+{
+ if (!w || !opt || !pal)
+ return false;
+
+ RECURSION_GUARD(return false)
+
+ w = containerWidget(w);
+
+ QRenderRule rule = renderRule(w, PseudoElement_None, pseudoClass(opt->state) | extendedPseudoClass(w));
+ if (!rule.hasPalette())
+ return false;
+
+ rule.configurePalette(pal, QPalette::NoRole, QPalette::NoRole);
+ return true;
+}
+
+Qt::Alignment QStyleSheetStyle::resolveAlignment(Qt::LayoutDirection layDir, Qt::Alignment src)
+{
+ if (layDir == Qt::LeftToRight || src & Qt::AlignAbsolute)
+ return src;
+
+ if (src & Qt::AlignLeft) {
+ src &= ~Qt::AlignLeft;
+ src |= Qt::AlignRight;
+ } else if (src & Qt::AlignRight) {
+ src &= ~Qt::AlignRight;
+ src |= Qt::AlignLeft;
+ }
+ src |= Qt::AlignAbsolute;
+ return src;
+}
+
+// Returns whether the given QWidget has a "natural" parent, meaning that
+// the parent contains this child as part of its normal operation.
+// An example is the QTabBar inside a QTabWidget.
+// This does not mean that any QTabBar which is a child of QTabWidget will
+// match, only the one that was created by the QTabWidget initialization
+// (and hence has the correct object name).
+bool QStyleSheetStyle::isNaturalChild(const QWidget *w)
+{
+ if (w->objectName().startsWith(QLatin1String("qt_")))
+ return true;
+
+ return false;
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qstylesheetstyle_p.cpp"
+
+#endif // QT_NO_STYLE_STYLESHEET
diff --git a/src/gui/styles/qstylesheetstyle_default.cpp b/src/widgets/styles/qstylesheetstyle_default.cpp
index 76ffac8187..76ffac8187 100644
--- a/src/gui/styles/qstylesheetstyle_default.cpp
+++ b/src/widgets/styles/qstylesheetstyle_default.cpp
diff --git a/src/widgets/styles/qstylesheetstyle_p.h b/src/widgets/styles/qstylesheetstyle_p.h
new file mode 100644
index 0000000000..1e885e0e52
--- /dev/null
+++ b/src/widgets/styles/qstylesheetstyle_p.h
@@ -0,0 +1,204 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSTYLESHEETSTYLE_P_H
+#define QSTYLESHEETSTYLE_P_H
+
+#include "QtWidgets/qwindowsstyle.h"
+
+#ifndef QT_NO_STYLE_STYLESHEET
+
+#include "QtWidgets/qstyleoption.h"
+#include "QtCore/qhash.h"
+#include "QtGui/qevent.h"
+#include "QtCore/qvector.h"
+#include "QtWidgets/qapplication.h"
+#include "private/qcssparser_p.h"
+#include "QtGui/qbrush.h"
+
+QT_BEGIN_NAMESPACE
+
+//
+// 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.
+//
+
+class QRenderRule;
+class QAbstractScrollArea;
+class QStyleSheetStylePrivate;
+class QStyleOptionTitleBar;
+
+class Q_AUTOTEST_EXPORT QStyleSheetStyle : public QWindowsStyle
+{
+ typedef QWindowsStyle ParentStyle;
+
+ Q_OBJECT
+public:
+ QStyleSheetStyle(QStyle *baseStyle);
+ ~QStyleSheetStyle();
+
+ void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
+ const QWidget *w = 0) const;
+ void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
+ const QWidget *w = 0) const;
+ void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const;
+ void drawItemText(QPainter *painter, const QRect& rect, int alignment, const QPalette &pal,
+ bool enabled, const QString& text, QPalette::ColorRole textRole = QPalette::NoRole) const;
+ void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
+ const QWidget *w = 0) const;
+ QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
+ const QStyleOption *option) const;
+ SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt,
+ const QPoint &pt, const QWidget *w = 0) const;
+ QRect itemPixmapRect(const QRect &rect, int alignment, const QPixmap &pixmap) const;
+ QRect itemTextRect(const QFontMetrics &metrics, const QRect &rect, int alignment, bool enabled,
+ const QString &text) const;
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
+ void polish(QWidget *widget);
+ void polish(QApplication *app);
+ void polish(QPalette &pal);
+ QSize sizeFromContents(ContentsType ct, const QStyleOption *opt,
+ const QSize &contentsSize, const QWidget *widget = 0) const;
+ QPalette standardPalette() const;
+ QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option = 0,
+ const QWidget *w = 0 ) const;
+ int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2,
+ Qt::Orientation orientation, const QStyleOption *option = 0,
+ const QWidget *widget = 0) const;
+ int styleHint(StyleHint sh, const QStyleOption *opt = 0, const QWidget *w = 0,
+ QStyleHintReturn *shret = 0) const;
+ QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const;
+ QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc,
+ const QWidget *w = 0) const;
+
+ // These functions are called from QApplication/QWidget. Be careful.
+ QStyle *baseStyle() const;
+ void repolish(QWidget *widget);
+ void repolish(QApplication *app);
+
+ void unpolish(QWidget *widget);
+ void unpolish(QApplication *app);
+
+ QStyle *base;
+ void ref() { ++refcount; }
+ void deref() { Q_ASSERT(refcount > 0); if (!--refcount) delete this; }
+
+ void updateStyleSheetFont(QWidget* w) const;
+ void saveWidgetFont(QWidget* w, const QFont& font) const;
+ void clearWidgetFont(QWidget* w) const;
+
+ bool styleSheetPalette(const QWidget* w, const QStyleOption* opt, QPalette* pal);
+
+protected Q_SLOTS:
+ QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *opt = 0,
+ const QWidget *widget = 0) const;
+ int layoutSpacingImplementation(QSizePolicy::ControlType control1,
+ QSizePolicy::ControlType control2,
+ Qt::Orientation orientation,
+ const QStyleOption *option = 0,
+ const QWidget *widget = 0) const;
+
+protected:
+ bool event(QEvent *e);
+
+private:
+ int refcount;
+
+ friend class QRenderRule;
+ int nativeFrameWidth(const QWidget *);
+ QRenderRule renderRule(const QWidget *, int, quint64 = 0) const;
+ QRenderRule renderRule(const QWidget *, const QStyleOption *, int = 0) const;
+ QSize defaultSize(const QWidget *, QSize, const QRect&, int) const;
+ QRect positionRect(const QWidget *, const QRenderRule&, const QRenderRule&, int,
+ const QRect&, Qt::LayoutDirection) const;
+ QRect positionRect(const QWidget *w, const QRenderRule &rule2, int pe,
+ const QRect &originRect, Qt::LayoutDirection dir) const;
+
+ mutable QCss::Parser parser;
+
+ void setPalette(QWidget *);
+ void unsetPalette(QWidget *);
+ void setProperties(QWidget *);
+ void setGeometry(QWidget *);
+ QVector<QCss::StyleRule> styleRules(const QWidget *w) const;
+ bool hasStyleRule(const QWidget *w, int part) const;
+
+ QHash<QStyle::SubControl, QRect> titleBarLayout(const QWidget *w, const QStyleOptionTitleBar *tb) const;
+
+ QCss::StyleSheet getDefaultStyleSheet() const;
+
+ static Qt::Alignment resolveAlignment(Qt::LayoutDirection, Qt::Alignment);
+ static bool isNaturalChild(const QWidget *w);
+ bool initWidget(const QWidget *w) const;
+public:
+ static int numinstances;
+
+private:
+ Q_DISABLE_COPY(QStyleSheetStyle)
+ Q_DECLARE_PRIVATE(QStyleSheetStyle)
+};
+
+class QStyleSheetStyleCaches : public QObject
+{
+ Q_OBJECT
+public Q_SLOTS:
+ void widgetDestroyed(QObject *);
+ void styleDestroyed(QObject *);
+public:
+ QHash<const QWidget *, QVector<QCss::StyleRule> > styleRulesCache;
+ QHash<const QWidget *, QHash<int, bool> > hasStyleRuleCache;
+ typedef QHash<int, QHash<quint64, QRenderRule> > QRenderRules;
+ QHash<const QWidget *, QRenderRules> renderRulesCache;
+ QHash<const QWidget *, QPalette> customPaletteWidgets; // widgets whose palette we tampered
+ QHash<const void *, QCss::StyleSheet> styleSheetCache; // parsed style sheets
+ QSet<const QWidget *> autoFillDisabledWidgets;
+};
+
+
+QT_END_NAMESPACE
+#endif // QT_NO_STYLE_STYLESHEET
+#endif // QSTYLESHEETSTYLE_P_H
diff --git a/src/gui/styles/qwindowscestyle.cpp b/src/widgets/styles/qwindowscestyle.cpp
index d7947bc653..d7947bc653 100644
--- a/src/gui/styles/qwindowscestyle.cpp
+++ b/src/widgets/styles/qwindowscestyle.cpp
diff --git a/src/widgets/styles/qwindowscestyle.h b/src/widgets/styles/qwindowscestyle.h
new file mode 100644
index 0000000000..15a8f2c66a
--- /dev/null
+++ b/src/widgets/styles/qwindowscestyle.h
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINDOWSCESTYLE_H
+#define QWINDOWSCESTYLE_H
+
+#include <QtWidgets/qwindowsstyle.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#if !defined(QT_NO_STYLE_WINDOWSCE)
+
+class Q_GUI_EXPORT QWindowsCEStyle : public QWindowsStyle
+{
+ Q_OBJECT
+public:
+ QWindowsCEStyle();
+
+ 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;
+
+ virtual void drawItemText(QPainter *painter, const QRect &rect,
+ int flags, const QPalette &pal, bool enabled,
+ const QString &text, QPalette::ColorRole textRole = QPalette::NoRole) 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;
+
+ QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
+ const QWidget *widget = 0) const;
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
+
+ int styleHint(StyleHint hint, const QStyleOption *opt = 0, const QWidget *widget = 0,
+ QStyleHintReturn *returnData = 0) const;
+
+ void polish(QWidget *widget);
+ void polish(QPalette &palette);
+ void polish(QApplication *app);
+ QPalette standardPalette() const;
+};
+
+#endif // QT_NO_STYLE_WINDOWSCE
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QWINDOWSCESTYLE_H
diff --git a/src/gui/styles/qwindowscestyle_p.h b/src/widgets/styles/qwindowscestyle_p.h
index c2d9c68ea7..c2d9c68ea7 100644
--- a/src/gui/styles/qwindowscestyle_p.h
+++ b/src/widgets/styles/qwindowscestyle_p.h
diff --git a/src/gui/styles/qwindowsmobilestyle.cpp b/src/widgets/styles/qwindowsmobilestyle.cpp
index 32cc2e63b8..32cc2e63b8 100644
--- a/src/gui/styles/qwindowsmobilestyle.cpp
+++ b/src/widgets/styles/qwindowsmobilestyle.cpp
diff --git a/src/widgets/styles/qwindowsmobilestyle.h b/src/widgets/styles/qwindowsmobilestyle.h
new file mode 100644
index 0000000000..2a396b5dbb
--- /dev/null
+++ b/src/widgets/styles/qwindowsmobilestyle.h
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINDOWSMOBILESTYLE_H
+#define QWINDOWSMOBILESTYLE_H
+
+#include <QtWidgets/qwindowsstyle.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#if !defined(QT_NO_STYLE_WINDOWSMOBILE)
+
+class QWindowsMobileStylePrivate;
+
+class Q_GUI_EXPORT QWindowsMobileStyle : public QWindowsStyle
+{
+ Q_OBJECT
+public:
+ QWindowsMobileStyle();
+
+ 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;
+
+ QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap,
+ const QStyleOption *option) const;
+
+ QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *option,
+ const QWidget *widget) const;
+
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
+
+ int styleHint(StyleHint hint, const QStyleOption *opt = 0, const QWidget *widget = 0,
+ QStyleHintReturn *returnData = 0) const;
+
+ void polish(QApplication*);
+ void unpolish(QApplication*);
+ void polish(QWidget *widget);
+ void unpolish(QWidget *widget);
+ void polish(QPalette &);
+
+ QPalette standardPalette() const;
+
+ bool doubleControls() const;
+
+ void setDoubleControls(bool);
+
+protected:
+ QWindowsMobileStyle(QWindowsMobileStylePrivate &dd);
+
+private:
+ Q_DECLARE_PRIVATE(QWindowsMobileStyle)
+};
+
+#endif // QT_NO_STYLE_WINDOWSMOBILE
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif //QWINDOWSMOBILESTYLE_H
diff --git a/src/gui/styles/qwindowsmobilestyle_p.h b/src/widgets/styles/qwindowsmobilestyle_p.h
index cfc6aea1c6..cfc6aea1c6 100644
--- a/src/gui/styles/qwindowsmobilestyle_p.h
+++ b/src/widgets/styles/qwindowsmobilestyle_p.h
diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp
index 754486ee16..754486ee16 100644
--- a/src/gui/styles/qwindowsstyle.cpp
+++ b/src/widgets/styles/qwindowsstyle.cpp
diff --git a/src/widgets/styles/qwindowsstyle.h b/src/widgets/styles/qwindowsstyle.h
new file mode 100644
index 0000000000..644da5e6fa
--- /dev/null
+++ b/src/widgets/styles/qwindowsstyle.h
@@ -0,0 +1,111 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINDOWSSTYLE_H
+#define QWINDOWSSTYLE_H
+
+#include <QtWidgets/qcommonstyle.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#if !defined(QT_NO_STYLE_WINDOWS)
+
+class QWindowsStylePrivate;
+
+class Q_GUI_EXPORT QWindowsStyle : public QCommonStyle
+{
+ Q_OBJECT
+public:
+ QWindowsStyle();
+ ~QWindowsStyle();
+
+ void polish(QApplication*);
+ void unpolish(QApplication*);
+
+ void polish(QWidget*);
+ void unpolish(QWidget*);
+
+ void polish(QPalette &);
+
+ void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
+ const QWidget *w = 0) const;
+ void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
+ const QWidget *w = 0) const;
+ QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const;
+ void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
+ const QWidget *w = 0) const;
+ QSize sizeFromContents(ContentsType ct, const QStyleOption *opt,
+ const QSize &contentsSize, const QWidget *widget = 0) const;
+
+ int pixelMetric(PixelMetric pm, const QStyleOption *option = 0, const QWidget *widget = 0) const;
+
+ int styleHint(StyleHint hint, const QStyleOption *opt = 0, const QWidget *widget = 0,
+ QStyleHintReturn *returnData = 0) const;
+
+ QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
+ const QWidget *widget = 0) const;
+
+protected Q_SLOTS:
+ QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option,
+ const QWidget *widget = 0) const;
+
+protected:
+ bool eventFilter(QObject *o, QEvent *e);
+ void timerEvent(QTimerEvent *event);
+ QWindowsStyle(QWindowsStylePrivate &dd);
+
+private:
+ Q_DISABLE_COPY(QWindowsStyle)
+ Q_DECLARE_PRIVATE(QWindowsStyle)
+ void *reserved;
+};
+
+#endif // QT_NO_STYLE_WINDOWS
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QWINDOWSSTYLE_H
diff --git a/src/gui/styles/qwindowsstyle_p.h b/src/widgets/styles/qwindowsstyle_p.h
index a10f2baffd..a10f2baffd 100644
--- a/src/gui/styles/qwindowsstyle_p.h
+++ b/src/widgets/styles/qwindowsstyle_p.h
diff --git a/src/gui/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp
index 123741ecf7..123741ecf7 100644
--- a/src/gui/styles/qwindowsvistastyle.cpp
+++ b/src/widgets/styles/qwindowsvistastyle.cpp
diff --git a/src/widgets/styles/qwindowsvistastyle.h b/src/widgets/styles/qwindowsvistastyle.h
new file mode 100644
index 0000000000..83e336c4e4
--- /dev/null
+++ b/src/widgets/styles/qwindowsvistastyle.h
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINDOWSVISTASTYLE_H
+#define QWINDOWSVISTASTYLE_H
+
+#include <QtWidgets/qwindowsxpstyle.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#if !defined(QT_NO_STYLE_WINDOWSVISTA)
+
+class QWindowsVistaStylePrivate;
+class Q_GUI_EXPORT QWindowsVistaStyle : public QWindowsXPStyle
+{
+ Q_OBJECT
+public:
+ QWindowsVistaStyle();
+
+ 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;
+
+ QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
+ const QWidget *widget = 0) const;
+ int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const;
+ int styleHint(StyleHint hint, const QStyleOption *opt = 0, const QWidget *widget = 0,
+ QStyleHintReturn *returnData = 0) const;
+
+
+ void polish(QWidget *widget);
+ void unpolish(QWidget *widget);
+ void polish(QPalette &pal);
+ void polish(QApplication *app);
+ void unpolish(QApplication *app);
+ bool event(QEvent *event);
+ QPalette standardPalette() const;
+
+protected Q_SLOTS:
+ QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option,
+ const QWidget *widget = 0) const;
+
+private:
+ Q_DISABLE_COPY(QWindowsVistaStyle)
+ Q_DECLARE_PRIVATE(QWindowsVistaStyle)
+ friend class QStyleFactory;
+};
+#endif //QT_NO_STYLE_WINDOWSVISTA
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif //QWINDOWSVISTASTYLE_H
diff --git a/src/gui/styles/qwindowsvistastyle_p.h b/src/widgets/styles/qwindowsvistastyle_p.h
index ba653880c9..ba653880c9 100644
--- a/src/gui/styles/qwindowsvistastyle_p.h
+++ b/src/widgets/styles/qwindowsvistastyle_p.h
diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp
index 4b2c3a59a4..4b2c3a59a4 100644
--- a/src/gui/styles/qwindowsxpstyle.cpp
+++ b/src/widgets/styles/qwindowsxpstyle.cpp
diff --git a/src/widgets/styles/qwindowsxpstyle.h b/src/widgets/styles/qwindowsxpstyle.h
new file mode 100644
index 0000000000..9895cc5f11
--- /dev/null
+++ b/src/widgets/styles/qwindowsxpstyle.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWINDOWSXPSTYLE_H
+#define QWINDOWSXPSTYLE_H
+
+#include <QtWidgets/qwindowsstyle.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#if !defined(QT_NO_STYLE_WINDOWSXP)
+
+class QWindowsXPStylePrivate;
+class Q_GUI_EXPORT QWindowsXPStyle : public QWindowsStyle
+{
+ Q_OBJECT
+public:
+ QWindowsXPStyle();
+ QWindowsXPStyle(QWindowsXPStylePrivate &dd);
+ ~QWindowsXPStyle();
+
+ void unpolish(QApplication*);
+ void polish(QApplication*);
+ void polish(QWidget*);
+ void polish(QPalette&);
+ void unpolish(QWidget*);
+
+ void drawPrimitive(PrimitiveElement pe, const QStyleOption *option, QPainter *p,
+ const QWidget *widget = 0) const;
+ void drawControl(ControlElement element, const QStyleOption *option, QPainter *p,
+ const QWidget *wwidget = 0) const;
+ QRect subElementRect(SubElement r, const QStyleOption *option, const QWidget *widget = 0) const;
+ QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *option, SubControl sc,
+ const QWidget *widget = 0) const;
+ void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *option, QPainter *p,
+ const QWidget *widget = 0) const;
+ QSize sizeFromContents(ContentsType ct, const QStyleOption *option, const QSize &contentsSize,
+ const QWidget *widget = 0) const;
+ int pixelMetric(PixelMetric pm, const QStyleOption *option = 0,
+ const QWidget *widget = 0) const;
+ int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0,
+ QStyleHintReturn *returnData = 0) const;
+
+ QPalette standardPalette() const;
+ QPixmap standardPixmap(StandardPixmap standardIcon, const QStyleOption *option,
+ const QWidget *widget = 0) const;
+
+protected Q_SLOTS:
+ QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option,
+ const QWidget *widget = 0) const;
+
+private:
+ Q_DISABLE_COPY(QWindowsXPStyle)
+ Q_DECLARE_PRIVATE(QWindowsXPStyle)
+ friend class QStyleFactory;
+ void *reserved;
+};
+
+#endif // QT_NO_STYLE_WINDOWSXP
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QWINDOWSXPSTYLE_H
diff --git a/src/gui/styles/qwindowsxpstyle_p.h b/src/widgets/styles/qwindowsxpstyle_p.h
index 5509cba512..5509cba512 100644
--- a/src/gui/styles/qwindowsxpstyle_p.h
+++ b/src/widgets/styles/qwindowsxpstyle_p.h
diff --git a/src/widgets/styles/styles.pri b/src/widgets/styles/styles.pri
new file mode 100644
index 0000000000..b20caf726e
--- /dev/null
+++ b/src/widgets/styles/styles.pri
@@ -0,0 +1,194 @@
+# Qt styles module
+
+HEADERS += \
+ styles/qdrawutil.h \
+ styles/qstyle.h \
+ styles/qstylefactory.h \
+ styles/qstyleoption.h \
+ styles/qstyleplugin.h \
+ styles/qcommonstylepixmaps_p.h \
+ styles/qcommonstyle.h \
+ styles/qstylehelper_p.h \
+ styles/qproxystyle.h \
+ styles/qproxystyle_p.h \
+ styles/qstylepainter.h \
+ styles/qstylesheetstyle_p.h
+
+SOURCES += \
+ styles/qdrawutil.cpp \
+ styles/qstyle.cpp \
+ styles/qstylefactory.cpp \
+ styles/qstyleoption.cpp \
+ styles/qstyleplugin.cpp \
+ styles/qstylehelper.cpp \
+ styles/qcommonstyle.cpp \
+ styles/qproxystyle.cpp \
+ styles/qstylepainter.cpp \
+ styles/qstylesheetstyle.cpp \
+ styles/qstylesheetstyle_default.cpp
+
+wince* {
+ RESOURCES += styles/qstyle_wince.qrc
+} else:symbian {
+ RESOURCES += styles/qstyle_s60.qrc
+} else {
+ RESOURCES += styles/qstyle.qrc
+}
+
+contains( styles, all ) {
+ styles = mac windows windowsxp windowsvista
+}
+
+x11|qpa|!macx-*:styles -= mac
+
+x11{
+ QMAKE_CXXFLAGS += $$QT_CFLAGS_QGTKSTYLE
+ LIBS_PRIVATE += $$QT_LIBS_QGTKSTYLE
+ styles += gtk
+}
+
+contains( styles, mac ) {
+ HEADERS += \
+ styles/qmacstyle_mac.h \
+ styles/qmacstylepixmaps_mac_p.h \
+ styles/qmacstyle_mac_p.h
+ OBJECTIVE_SOURCES += styles/qmacstyle_mac.mm
+
+ !contains( styles, windows ) {
+ message( mac requires windows )
+ styles += windows
+ DEFINES+= QT_STYLE_WINDOWS
+ }
+} else {
+ DEFINES += QT_NO_STYLE_MAC
+}
+
+contains( styles, cde ) {
+ HEADERS += styles/qcdestyle.h
+ SOURCES += styles/qcdestyle.cpp
+
+ !contains( styles, motif ) {
+ message( cde requires motif )
+ styles += motif
+ DEFINES+= QT_STYLE_MOTIF
+ }
+} else {
+ DEFINES += QT_NO_STYLE_CDE
+}
+
+contains( styles, windowsvista ) {
+ HEADERS += styles/qwindowsvistastyle.h
+ HEADERS += styles/qwindowsvistastyle_p.h
+ SOURCES += styles/qwindowsvistastyle.cpp
+ !contains( styles, windowsxp ) {
+ message( windowsvista requires windowsxp )
+ styles += windowsxp
+ DEFINES+= QT_STYLE_WINDOWSXP
+ }
+} else {
+ DEFINES += QT_NO_STYLE_WINDOWSVISTA
+}
+
+contains( styles, windowsxp ) {
+ HEADERS += styles/qwindowsxpstyle.h
+ SOURCES += styles/qwindowsxpstyle.cpp
+ !contains( styles, windows ) {
+ message( windowsxp requires windows )
+ styles += windows
+ DEFINES+= QT_STYLE_WINDOWS
+ }
+} else {
+ DEFINES += QT_NO_STYLE_WINDOWSXP
+}
+
+contains( styles, plastique ) {
+ HEADERS += styles/qplastiquestyle.h
+ SOURCES += styles/qplastiquestyle.cpp
+ !contains( styles, windows ) {
+ message( plastique requires windows )
+ styles += windows
+ DEFINES+= QT_STYLE_WINDOWS
+ }
+} else {
+ DEFINES += QT_NO_STYLE_PLASTIQUE
+}
+
+contains( styles, gtk ) {
+ HEADERS += styles/qgtkstyle.h
+ HEADERS += styles/qgtkpainter_p.h
+ HEADERS += styles/qgtkstyle_p.h
+ SOURCES += styles/qgtkstyle.cpp
+ SOURCES += styles/qgtkpainter.cpp
+ SOURCES += styles/qgtkstyle_p.cpp
+ !contains( styles, cleanlooks ) {
+ styles += cleanlooks
+ DEFINES+= QT_STYLE_CLEANLOOKS
+ }
+} else {
+ DEFINES += QT_NO_STYLE_GTK
+}
+
+contains( styles, cleanlooks ) {
+ HEADERS += styles/qcleanlooksstyle.h
+ HEADERS += styles/qcleanlooksstyle_p.h
+ SOURCES += styles/qcleanlooksstyle.cpp
+ !contains( styles, windows ) {
+ styles += windows
+ DEFINES+= QT_STYLE_WINDOWS
+ }
+} else {
+ DEFINES += QT_NO_STYLE_CLEANLOOKS
+}
+
+contains( styles, windows ) {
+ HEADERS += styles/qwindowsstyle.h
+ SOURCES += styles/qwindowsstyle.cpp
+} else {
+ DEFINES += QT_NO_STYLE_WINDOWS
+}
+
+contains( styles, motif ) {
+ HEADERS += styles/qmotifstyle.h
+ SOURCES += styles/qmotifstyle.cpp
+} else {
+ DEFINES += QT_NO_STYLE_MOTIF
+}
+
+contains( styles, windowsce ) {
+ HEADERS += styles/qwindowscestyle.h
+ SOURCES += styles/qwindowscestyle.cpp
+} else {
+ DEFINES += QT_NO_STYLE_WINDOWSCE
+}
+
+contains( styles, windowsmobile ) {
+ HEADERS += styles/qwindowsmobilestyle.h
+ SOURCES += styles/qwindowsmobilestyle.cpp
+} else {
+ DEFINES += QT_NO_STYLE_WINDOWSMOBILE
+}
+
+contains( styles, s60 ):contains(QT_CONFIG, s60) {
+ HEADERS += \
+ styles/qs60style.h \
+ styles/qs60style_p.h
+ SOURCES += styles/qs60style.cpp
+ symbian {
+ SOURCES += styles/qs60style_s60.cpp
+ LIBS += -legul -lbmpanim
+ contains(CONFIG, is_using_gnupoc) {
+ LIBS += -laknicon -laknskins -laknskinsrv -lfontutils
+ } else {
+ LIBS += -lAknIcon -lAKNSKINS -lAKNSKINSRV -lFontUtils
+ }
+ } else {
+ SOURCES += styles/qs60style_simulated.cpp
+ RESOURCES += styles/qstyle_s60_simulated.qrc
+ }
+} else {
+ symbian {
+ HEADERS += styles/qs60style.h
+ SOURCES += styles/qs60style_stub.cpp
+ }
+ DEFINES += QT_NO_STYLE_S60
+}
diff --git a/src/gui/symbian/images/blank.png b/src/widgets/symbian/images/blank.png
index bd396de62e..bd396de62e 100644
--- a/src/gui/symbian/images/blank.png
+++ b/src/widgets/symbian/images/blank.png
Binary files differ
diff --git a/src/gui/symbian/images/busy12.png b/src/widgets/symbian/images/busy12.png
index 909e70fa4f..909e70fa4f 100644
--- a/src/gui/symbian/images/busy12.png
+++ b/src/widgets/symbian/images/busy12.png
Binary files differ
diff --git a/src/gui/symbian/images/busy3.png b/src/widgets/symbian/images/busy3.png
index 983f5d8b8f..983f5d8b8f 100644
--- a/src/gui/symbian/images/busy3.png
+++ b/src/widgets/symbian/images/busy3.png
Binary files differ
diff --git a/src/gui/symbian/images/busy6.png b/src/widgets/symbian/images/busy6.png
index b2e878074f..b2e878074f 100644
--- a/src/gui/symbian/images/busy6.png
+++ b/src/widgets/symbian/images/busy6.png
Binary files differ
diff --git a/src/gui/symbian/images/busy9.png b/src/widgets/symbian/images/busy9.png
index e093d015c5..e093d015c5 100644
--- a/src/gui/symbian/images/busy9.png
+++ b/src/widgets/symbian/images/busy9.png
Binary files differ
diff --git a/src/gui/symbian/images/closehand.png b/src/widgets/symbian/images/closehand.png
index 05534f580d..05534f580d 100644
--- a/src/gui/symbian/images/closehand.png
+++ b/src/widgets/symbian/images/closehand.png
Binary files differ
diff --git a/src/gui/symbian/images/cross.png b/src/widgets/symbian/images/cross.png
index 50da7aafc3..50da7aafc3 100644
--- a/src/gui/symbian/images/cross.png
+++ b/src/widgets/symbian/images/cross.png
Binary files differ
diff --git a/src/gui/symbian/images/forbidden.png b/src/widgets/symbian/images/forbidden.png
index a3a0fd61e1..a3a0fd61e1 100644
--- a/src/gui/symbian/images/forbidden.png
+++ b/src/widgets/symbian/images/forbidden.png
Binary files differ
diff --git a/src/gui/symbian/images/handpoint.png b/src/widgets/symbian/images/handpoint.png
index a221548d22..a221548d22 100644
--- a/src/gui/symbian/images/handpoint.png
+++ b/src/widgets/symbian/images/handpoint.png
Binary files differ
diff --git a/src/gui/symbian/images/ibeam.png b/src/widgets/symbian/images/ibeam.png
index ace2fada1c..ace2fada1c 100644
--- a/src/gui/symbian/images/ibeam.png
+++ b/src/widgets/symbian/images/ibeam.png
Binary files differ
diff --git a/src/gui/symbian/images/openhand.png b/src/widgets/symbian/images/openhand.png
index 6f232f0d8f..6f232f0d8f 100644
--- a/src/gui/symbian/images/openhand.png
+++ b/src/widgets/symbian/images/openhand.png
Binary files differ
diff --git a/src/gui/symbian/images/pointer.png b/src/widgets/symbian/images/pointer.png
index 677404e250..677404e250 100644
--- a/src/gui/symbian/images/pointer.png
+++ b/src/widgets/symbian/images/pointer.png
Binary files differ
diff --git a/src/gui/symbian/images/sizeall.png b/src/widgets/symbian/images/sizeall.png
index 29500677eb..29500677eb 100644
--- a/src/gui/symbian/images/sizeall.png
+++ b/src/widgets/symbian/images/sizeall.png
Binary files differ
diff --git a/src/gui/symbian/images/sizebdiag.png b/src/widgets/symbian/images/sizebdiag.png
index f565a3a7a1..f565a3a7a1 100644
--- a/src/gui/symbian/images/sizebdiag.png
+++ b/src/widgets/symbian/images/sizebdiag.png
Binary files differ
diff --git a/src/gui/symbian/images/sizefdiag.png b/src/widgets/symbian/images/sizefdiag.png
index 9493f12723..9493f12723 100644
--- a/src/gui/symbian/images/sizefdiag.png
+++ b/src/widgets/symbian/images/sizefdiag.png
Binary files differ
diff --git a/src/gui/symbian/images/sizehor.png b/src/widgets/symbian/images/sizehor.png
index 217bf39fe2..217bf39fe2 100644
--- a/src/gui/symbian/images/sizehor.png
+++ b/src/widgets/symbian/images/sizehor.png
Binary files differ
diff --git a/src/gui/symbian/images/sizever.png b/src/widgets/symbian/images/sizever.png
index 2c99038c3f..2c99038c3f 100644
--- a/src/gui/symbian/images/sizever.png
+++ b/src/widgets/symbian/images/sizever.png
Binary files differ
diff --git a/src/gui/symbian/images/splith.png b/src/widgets/symbian/images/splith.png
index 343bed529a..343bed529a 100644
--- a/src/gui/symbian/images/splith.png
+++ b/src/widgets/symbian/images/splith.png
Binary files differ
diff --git a/src/gui/symbian/images/splitv.png b/src/widgets/symbian/images/splitv.png
index 69ee4163e8..69ee4163e8 100644
--- a/src/gui/symbian/images/splitv.png
+++ b/src/widgets/symbian/images/splitv.png
Binary files differ
diff --git a/src/gui/symbian/images/uparrow.png b/src/widgets/symbian/images/uparrow.png
index 92dd933856..92dd933856 100644
--- a/src/gui/symbian/images/uparrow.png
+++ b/src/widgets/symbian/images/uparrow.png
Binary files differ
diff --git a/src/gui/symbian/images/wait1.png b/src/widgets/symbian/images/wait1.png
index 5aebaab1f9..5aebaab1f9 100644
--- a/src/gui/symbian/images/wait1.png
+++ b/src/widgets/symbian/images/wait1.png
Binary files differ
diff --git a/src/gui/symbian/images/wait10.png b/src/widgets/symbian/images/wait10.png
index 3b549b08ed..3b549b08ed 100644
--- a/src/gui/symbian/images/wait10.png
+++ b/src/widgets/symbian/images/wait10.png
Binary files differ
diff --git a/src/gui/symbian/images/wait11.png b/src/widgets/symbian/images/wait11.png
index 24a943fa68..24a943fa68 100644
--- a/src/gui/symbian/images/wait11.png
+++ b/src/widgets/symbian/images/wait11.png
Binary files differ
diff --git a/src/gui/symbian/images/wait12.png b/src/widgets/symbian/images/wait12.png
index 15afd4daa2..15afd4daa2 100644
--- a/src/gui/symbian/images/wait12.png
+++ b/src/widgets/symbian/images/wait12.png
Binary files differ
diff --git a/src/gui/symbian/images/wait2.png b/src/widgets/symbian/images/wait2.png
index f2022b2853..f2022b2853 100644
--- a/src/gui/symbian/images/wait2.png
+++ b/src/widgets/symbian/images/wait2.png
Binary files differ
diff --git a/src/gui/symbian/images/wait3.png b/src/widgets/symbian/images/wait3.png
index 5b73e57124..5b73e57124 100644
--- a/src/gui/symbian/images/wait3.png
+++ b/src/widgets/symbian/images/wait3.png
Binary files differ
diff --git a/src/gui/symbian/images/wait4.png b/src/widgets/symbian/images/wait4.png
index 17a03396e0..17a03396e0 100644
--- a/src/gui/symbian/images/wait4.png
+++ b/src/widgets/symbian/images/wait4.png
Binary files differ
diff --git a/src/gui/symbian/images/wait5.png b/src/widgets/symbian/images/wait5.png
index 16a5c231f2..16a5c231f2 100644
--- a/src/gui/symbian/images/wait5.png
+++ b/src/widgets/symbian/images/wait5.png
Binary files differ
diff --git a/src/gui/symbian/images/wait6.png b/src/widgets/symbian/images/wait6.png
index 2870093a30..2870093a30 100644
--- a/src/gui/symbian/images/wait6.png
+++ b/src/widgets/symbian/images/wait6.png
Binary files differ
diff --git a/src/gui/symbian/images/wait7.png b/src/widgets/symbian/images/wait7.png
index 54f75a1db0..54f75a1db0 100644
--- a/src/gui/symbian/images/wait7.png
+++ b/src/widgets/symbian/images/wait7.png
Binary files differ
diff --git a/src/gui/symbian/images/wait8.png b/src/widgets/symbian/images/wait8.png
index 1d370c752e..1d370c752e 100644
--- a/src/gui/symbian/images/wait8.png
+++ b/src/widgets/symbian/images/wait8.png
Binary files differ
diff --git a/src/gui/symbian/images/wait9.png b/src/widgets/symbian/images/wait9.png
index c28096fe63..c28096fe63 100644
--- a/src/gui/symbian/images/wait9.png
+++ b/src/widgets/symbian/images/wait9.png
Binary files differ
diff --git a/src/gui/symbian/images/whatsthis.png b/src/widgets/symbian/images/whatsthis.png
index 3386ef0c50..3386ef0c50 100644
--- a/src/gui/symbian/images/whatsthis.png
+++ b/src/widgets/symbian/images/whatsthis.png
Binary files differ
diff --git a/src/gui/symbian/qsymbianevent.cpp b/src/widgets/symbian/qsymbianevent.cpp
index e177d1702b..e177d1702b 100644
--- a/src/gui/symbian/qsymbianevent.cpp
+++ b/src/widgets/symbian/qsymbianevent.cpp
diff --git a/src/gui/symbian/qsymbianevent.h b/src/widgets/symbian/qsymbianevent.h
index cf05f63176..cf05f63176 100644
--- a/src/gui/symbian/qsymbianevent.h
+++ b/src/widgets/symbian/qsymbianevent.h
diff --git a/src/gui/symbian/symbianresources.qrc b/src/widgets/symbian/symbianresources.qrc
index 0a4fc36c9a..0a4fc36c9a 100644
--- a/src/gui/symbian/symbianresources.qrc
+++ b/src/widgets/symbian/symbianresources.qrc
diff --git a/src/widgets/to_be_moved/qdnd.cpp b/src/widgets/to_be_moved/qdnd.cpp
new file mode 100644
index 0000000000..db79b9042d
--- /dev/null
+++ b/src/widgets/to_be_moved/qdnd.cpp
@@ -0,0 +1,491 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qplatformdefs.h"
+
+#include "qbitmap.h"
+#include "qdrag.h"
+#include "qpixmap.h"
+#include "qevent.h"
+#include "qfile.h"
+#include "qtextcodec.h"
+#include "qguiapplication.h"
+#include "qpoint.h"
+#include "qwidget.h"
+#include "qbuffer.h"
+#include "qimage.h"
+#include "qregexp.h"
+#include "qdir.h"
+#include "qdnd_p.h"
+#include "qimagereader.h"
+#include "qimagewriter.h"
+#include "qdebug.h"
+#include <ctype.h>
+
+#include <private/qguiapplication_p.h>
+
+#ifndef QT_NO_DRAGANDDROP
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_DRAGANDDROP
+
+//#define QDND_DEBUG
+
+#ifdef QDND_DEBUG
+QString dragActionsToString(Qt::DropActions actions)
+{
+ QString str;
+ if (actions == Qt::IgnoreAction) {
+ if (!str.isEmpty())
+ str += " | ";
+ str += "IgnoreAction";
+ }
+ if (actions & Qt::LinkAction) {
+ if (!str.isEmpty())
+ str += " | ";
+ str += "LinkAction";
+ }
+ if (actions & Qt::CopyAction) {
+ if (!str.isEmpty())
+ str += " | ";
+ str += "CopyAction";
+ }
+ if (actions & Qt::MoveAction) {
+ if (!str.isEmpty())
+ str += " | ";
+ str += "MoveAction";
+ }
+ if ((actions & Qt::TargetMoveAction) == Qt::TargetMoveAction ) {
+ if (!str.isEmpty())
+ str += " | ";
+ str += "TargetMoveAction";
+ }
+ return str;
+}
+
+QString KeyboardModifiersToString(Qt::KeyboardModifiers moderfies)
+{
+ QString str;
+ if (moderfies & Qt::ControlModifier) {
+ if (!str.isEmpty())
+ str += " | ";
+ str += Qt::ControlModifier;
+ }
+ if (moderfies & Qt::AltModifier) {
+ if (!str.isEmpty())
+ str += " | ";
+ str += Qt::AltModifier;
+ }
+ if (moderfies & Qt::ShiftModifier) {
+ if (!str.isEmpty())
+ str += " | ";
+ str += Qt::ShiftModifier;
+ }
+ return str;
+}
+#endif
+
+
+// the universe's only drag manager
+QDragManager *QDragManager::instance = 0;
+
+
+QDragManager::QDragManager()
+ : QObject(qApp)
+{
+ Q_ASSERT(!instance);
+
+#ifdef Q_WS_QWS
+ currentActionForOverrideCursor = Qt::IgnoreAction;
+#endif
+ object = 0;
+ beingCancelled = false;
+ restoreCursor = false;
+ willDrop = false;
+ eventLoop = 0;
+ dropData = new QDropData();
+ currentDropTarget = 0;
+#ifdef Q_WS_X11
+ xdndMimeTransferedPixmapIndex = 0;
+#endif
+}
+
+
+QDragManager::~QDragManager()
+{
+#ifndef QT_NO_CURSOR
+ if (restoreCursor)
+ QGuiApplication::restoreOverrideCursor();
+#endif
+ instance = 0;
+ delete dropData;
+}
+
+QDragManager *QDragManager::self()
+{
+ if (!instance && !QApplication::closingDown())
+ instance = new QDragManager;
+ return instance;
+}
+
+QPixmap QDragManager::dragCursor(Qt::DropAction action) const
+{
+ QDragPrivate * d = dragPrivate();
+ if (d && d->customCursors.contains(action))
+ return d->customCursors[action];
+ else if (action == Qt::MoveAction)
+ return QGuiApplicationPrivate::instance()->getPixmapCursor(Qt::DragMoveCursor);
+ else if (action == Qt::CopyAction)
+ return QGuiApplicationPrivate::instance()->getPixmapCursor(Qt::DragCopyCursor);
+ else if (action == Qt::LinkAction)
+ return QGuiApplicationPrivate::instance()->getPixmapCursor(Qt::DragLinkCursor);
+#ifdef Q_WS_WIN
+ else if (action == Qt::IgnoreAction)
+ return QGuiApplicationPrivate::instance()->getPixmapCursor(Qt::ForbiddenCursor);
+#endif
+ return QPixmap();
+}
+
+bool QDragManager::hasCustomDragCursors() const
+{
+ QDragPrivate * d = dragPrivate();
+ return d && !d->customCursors.isEmpty();
+}
+
+Qt::DropAction QDragManager::defaultAction(Qt::DropActions possibleActions,
+ Qt::KeyboardModifiers modifiers) const
+{
+#ifdef QDND_DEBUG
+ qDebug("QDragManager::defaultAction(Qt::DropActions possibleActions)");
+ qDebug("keyboard modifiers : %s", KeyboardModifiersToString(modifiers).latin1());
+#endif
+
+ QDragPrivate *d = dragPrivate();
+ Qt::DropAction defaultAction = d ? d->defaultDropAction : Qt::IgnoreAction;
+
+ if (defaultAction == Qt::IgnoreAction) {
+ //This means that the drag was initiated by QDrag::start and we need to
+ //preserve the old behavior
+#ifdef Q_WS_MAC
+ defaultAction = Qt::MoveAction;
+#else
+ defaultAction = Qt::CopyAction;
+#endif
+ }
+
+#ifdef Q_WS_MAC
+ if (modifiers & Qt::ControlModifier && modifiers & Qt::AltModifier)
+ defaultAction = Qt::LinkAction;
+ else if (modifiers & Qt::AltModifier)
+ defaultAction = Qt::CopyAction;
+ else if (modifiers & Qt::ControlModifier)
+ defaultAction = Qt::MoveAction;
+#else
+ if (modifiers & Qt::ControlModifier && modifiers & Qt::ShiftModifier)
+ defaultAction = Qt::LinkAction;
+ else if (modifiers & Qt::ControlModifier)
+ defaultAction = Qt::CopyAction;
+ else if (modifiers & Qt::ShiftModifier)
+ defaultAction = Qt::MoveAction;
+ else if (modifiers & Qt::AltModifier)
+ defaultAction = Qt::LinkAction;
+#endif
+
+ // if the object is set take the list of possibles from it
+ if (object)
+ possibleActions = object->d_func()->possible_actions;
+
+#ifdef QDND_DEBUG
+ qDebug("possible actions : %s", dragActionsToString(possibleActions).latin1());
+#endif
+
+ // Check if the action determined is allowed
+ if (!(possibleActions & defaultAction)) {
+ if (possibleActions & Qt::CopyAction)
+ defaultAction = Qt::CopyAction;
+ else if (possibleActions & Qt::MoveAction)
+ defaultAction = Qt::MoveAction;
+ else if (possibleActions & Qt::LinkAction)
+ defaultAction = Qt::LinkAction;
+ else
+ defaultAction = Qt::IgnoreAction;
+ }
+
+#ifdef QDND_DEBUG
+ qDebug("default action : %s", dragActionsToString(defaultAction).latin1());
+#endif
+
+ return defaultAction;
+}
+
+void QDragManager::setCurrentTarget(QWidget *target, bool dropped)
+{
+ if (currentDropTarget == target)
+ return;
+
+ currentDropTarget = target;
+ if (!dropped && object) {
+ object->d_func()->target = target;
+ emit object->targetChanged(target);
+ }
+
+}
+
+QWidget *QDragManager::currentTarget()
+{
+ return currentDropTarget;
+}
+
+#endif
+
+QDropData::QDropData()
+ : QInternalMimeData()
+{
+}
+
+QDropData::~QDropData()
+{
+}
+#endif // QT_NO_DRAGANDDROP
+
+#if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD))
+
+static QStringList imageReadMimeFormats()
+{
+ QStringList formats;
+ QList<QByteArray> imageFormats = QImageReader::supportedImageFormats();
+ for (int i = 0; i < imageFormats.size(); ++i) {
+ QString format = QLatin1String("image/");
+ format += QString::fromLatin1(imageFormats.at(i).toLower());
+ formats.append(format);
+ }
+
+ //put png at the front because it is best
+ int pngIndex = formats.indexOf(QLatin1String("image/png"));
+ if (pngIndex != -1 && pngIndex != 0)
+ formats.move(pngIndex, 0);
+
+ return formats;
+}
+
+
+static QStringList imageWriteMimeFormats()
+{
+ QStringList formats;
+ QList<QByteArray> imageFormats = QImageWriter::supportedImageFormats();
+ for (int i = 0; i < imageFormats.size(); ++i) {
+ QString format = QLatin1String("image/");
+ format += QString::fromLatin1(imageFormats.at(i).toLower());
+ formats.append(format);
+ }
+
+ //put png at the front because it is best
+ int pngIndex = formats.indexOf(QLatin1String("image/png"));
+ if (pngIndex != -1 && pngIndex != 0)
+ formats.move(pngIndex, 0);
+
+ return formats;
+}
+
+QInternalMimeData::QInternalMimeData()
+ : QMimeData()
+{
+}
+
+QInternalMimeData::~QInternalMimeData()
+{
+}
+
+bool QInternalMimeData::hasFormat(const QString &mimeType) const
+{
+ bool foundFormat = hasFormat_sys(mimeType);
+ if (!foundFormat && mimeType == QLatin1String("application/x-qt-image")) {
+ QStringList imageFormats = imageReadMimeFormats();
+ for (int i = 0; i < imageFormats.size(); ++i) {
+ if ((foundFormat = hasFormat_sys(imageFormats.at(i))))
+ break;
+ }
+ }
+ return foundFormat;
+}
+
+QStringList QInternalMimeData::formats() const
+{
+ QStringList realFormats = formats_sys();
+ if (!realFormats.contains(QLatin1String("application/x-qt-image"))) {
+ QStringList imageFormats = imageReadMimeFormats();
+ for (int i = 0; i < imageFormats.size(); ++i) {
+ if (realFormats.contains(imageFormats.at(i))) {
+ realFormats += QLatin1String("application/x-qt-image");
+ break;
+ }
+ }
+ }
+ return realFormats;
+}
+
+QVariant QInternalMimeData::retrieveData(const QString &mimeType, QVariant::Type type) const
+{
+ QVariant data = retrieveData_sys(mimeType, type);
+ if (mimeType == QLatin1String("application/x-qt-image")) {
+ if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty())) {
+ // try to find an image
+ QStringList imageFormats = imageReadMimeFormats();
+ for (int i = 0; i < imageFormats.size(); ++i) {
+ data = retrieveData_sys(imageFormats.at(i), type);
+ if (data.isNull() || (data.type() == QVariant::ByteArray && data.toByteArray().isEmpty()))
+ continue;
+ break;
+ }
+ }
+ // we wanted some image type, but all we got was a byte array. Convert it to an image.
+ if (data.type() == QVariant::ByteArray
+ && (type == QVariant::Image || type == QVariant::Pixmap || type == QVariant::Bitmap))
+ data = QImage::fromData(data.toByteArray());
+
+ } else if (mimeType == QLatin1String("application/x-color") && data.type() == QVariant::ByteArray) {
+ QColor c;
+ QByteArray ba = data.toByteArray();
+ if (ba.size() == 8) {
+ ushort * colBuf = (ushort *)ba.data();
+ c.setRgbF(qreal(colBuf[0]) / qreal(0xFFFF),
+ qreal(colBuf[1]) / qreal(0xFFFF),
+ qreal(colBuf[2]) / qreal(0xFFFF),
+ qreal(colBuf[3]) / qreal(0xFFFF));
+ data = c;
+ } else {
+ qWarning("Qt: Invalid color format");
+ }
+ } else if (data.type() != type && data.type() == QVariant::ByteArray) {
+ // try to use mime data's internal conversion stuf.
+ QInternalMimeData *that = const_cast<QInternalMimeData *>(this);
+ that->setData(mimeType, data.toByteArray());
+ data = QMimeData::retrieveData(mimeType, type);
+ that->clear();
+ }
+ return data;
+}
+
+bool QInternalMimeData::canReadData(const QString &mimeType)
+{
+ return imageReadMimeFormats().contains(mimeType);
+}
+
+// helper functions for rendering mimedata to the system, this is needed because QMimeData is in core.
+QStringList QInternalMimeData::formatsHelper(const QMimeData *data)
+{
+ QStringList realFormats = data->formats();
+ if (realFormats.contains(QLatin1String("application/x-qt-image"))) {
+ // add all supported image formats
+ QStringList imageFormats = imageWriteMimeFormats();
+ for (int i = 0; i < imageFormats.size(); ++i) {
+ if (!realFormats.contains(imageFormats.at(i)))
+ realFormats.append(imageFormats.at(i));
+ }
+ }
+ return realFormats;
+}
+
+bool QInternalMimeData::hasFormatHelper(const QString &mimeType, const QMimeData *data)
+{
+
+ bool foundFormat = data->hasFormat(mimeType);
+ if (!foundFormat) {
+ if (mimeType == QLatin1String("application/x-qt-image")) {
+ // check all supported image formats
+ QStringList imageFormats = imageWriteMimeFormats();
+ for (int i = 0; i < imageFormats.size(); ++i) {
+ if ((foundFormat = data->hasFormat(imageFormats.at(i))))
+ break;
+ }
+ } else if (mimeType.startsWith(QLatin1String("image/"))) {
+ return data->hasImage() && imageWriteMimeFormats().contains(mimeType);
+ }
+ }
+ return foundFormat;
+}
+
+QByteArray QInternalMimeData::renderDataHelper(const QString &mimeType, const QMimeData *data)
+{
+ QByteArray ba;
+ if (mimeType == QLatin1String("application/x-color")) {
+ /* QMimeData can only provide colors as QColor or the name
+ of a color as a QByteArray or a QString. So we need to do
+ the conversion to application/x-color here.
+ The application/x-color format is :
+ type: application/x-color
+ format: 16
+ data[0]: red
+ data[1]: green
+ data[2]: blue
+ data[3]: opacity
+ */
+ ba.resize(8);
+ ushort * colBuf = (ushort *)ba.data();
+ QColor c = qvariant_cast<QColor>(data->colorData());
+ colBuf[0] = ushort(c.redF() * 0xFFFF);
+ colBuf[1] = ushort(c.greenF() * 0xFFFF);
+ colBuf[2] = ushort(c.blueF() * 0xFFFF);
+ colBuf[3] = ushort(c.alphaF() * 0xFFFF);
+ } else {
+ ba = data->data(mimeType);
+ if (ba.isEmpty()) {
+ if (mimeType == QLatin1String("application/x-qt-image") && data->hasImage()) {
+ QImage image = qvariant_cast<QImage>(data->imageData());
+ QBuffer buf(&ba);
+ buf.open(QBuffer::WriteOnly);
+ // would there not be PNG ??
+ image.save(&buf, "PNG");
+ } else if (mimeType.startsWith(QLatin1String("image/")) && data->hasImage()) {
+ QImage image = qvariant_cast<QImage>(data->imageData());
+ QBuffer buf(&ba);
+ buf.open(QBuffer::WriteOnly);
+ image.save(&buf, mimeType.mid(mimeType.indexOf(QLatin1Char('/')) + 1).toLatin1().toUpper());
+ }
+ }
+ }
+ return ba;
+}
+
+#endif // QT_NO_DRAGANDDROP && QT_NO_CLIPBOARD
+
+QT_END_NAMESPACE
diff --git a/src/widgets/to_be_moved/qdnd_p.h b/src/widgets/to_be_moved/qdnd_p.h
new file mode 100644
index 0000000000..dc18ffa22e
--- /dev/null
+++ b/src/widgets/to_be_moved/qdnd_p.h
@@ -0,0 +1,336 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDND_P_H
+#define QDND_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "QtCore/qobject.h"
+#include "QtCore/qmap.h"
+#include "QtGui/qmime.h"
+#include "QtWidgets/qdrag.h"
+#include "QtGui/qpixmap.h"
+#include "QtGui/qcursor.h"
+#include "QtCore/qpoint.h"
+#include "private/qobject_p.h"
+#ifdef Q_WS_MAC
+# include "private/qt_mac_p.h"
+#endif
+
+#if defined(Q_WS_WIN)
+# include <qt_windows.h>
+# include <objidl.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+class QEventLoop;
+
+#if !(defined(QT_NO_DRAGANDDROP) && defined(QT_NO_CLIPBOARD))
+
+class Q_GUI_EXPORT QInternalMimeData : public QMimeData
+{
+ Q_OBJECT
+public:
+ QInternalMimeData();
+ ~QInternalMimeData();
+
+ bool hasFormat(const QString &mimeType) const;
+ QStringList formats() const;
+ static bool canReadData(const QString &mimeType);
+
+
+ static QStringList formatsHelper(const QMimeData *data);
+ static bool hasFormatHelper(const QString &mimeType, const QMimeData *data);
+ static QByteArray renderDataHelper(const QString &mimeType, const QMimeData *data);
+
+protected:
+ QVariant retrieveData(const QString &mimeType, QVariant::Type type) const;
+
+ virtual bool hasFormat_sys(const QString &mimeType) const = 0;
+ virtual QStringList formats_sys() const = 0;
+ virtual QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const = 0;
+};
+
+#ifdef Q_WS_WIN
+class QOleDataObject : public IDataObject
+{
+public:
+ explicit QOleDataObject(QMimeData *mimeData);
+ virtual ~QOleDataObject();
+
+ void releaseQt();
+ const QMimeData *mimeData() const;
+ DWORD reportedPerformedEffect() const;
+
+ // IUnknown methods
+ STDMETHOD(QueryInterface)(REFIID riid, void FAR* FAR* ppvObj);
+ STDMETHOD_(ULONG,AddRef)(void);
+ STDMETHOD_(ULONG,Release)(void);
+
+ // IDataObject methods
+ STDMETHOD(GetData)(LPFORMATETC pformatetcIn, LPSTGMEDIUM pmedium);
+ STDMETHOD(GetDataHere)(LPFORMATETC pformatetc, LPSTGMEDIUM pmedium);
+ STDMETHOD(QueryGetData)(LPFORMATETC pformatetc);
+ STDMETHOD(GetCanonicalFormatEtc)(LPFORMATETC pformatetc, LPFORMATETC pformatetcOut);
+ STDMETHOD(SetData)(LPFORMATETC pformatetc, STGMEDIUM FAR * pmedium,
+ BOOL fRelease);
+ STDMETHOD(EnumFormatEtc)(DWORD dwDirection, LPENUMFORMATETC FAR* ppenumFormatEtc);
+ STDMETHOD(DAdvise)(FORMATETC FAR* pFormatetc, DWORD advf,
+ LPADVISESINK pAdvSink, DWORD FAR* pdwConnection);
+ STDMETHOD(DUnadvise)(DWORD dwConnection);
+ STDMETHOD(EnumDAdvise)(LPENUMSTATDATA FAR* ppenumAdvise);
+
+private:
+ ULONG m_refs;
+ QPointer<QMimeData> data;
+ int CF_PERFORMEDDROPEFFECT;
+ DWORD performedEffect;
+};
+
+class QOleEnumFmtEtc : public IEnumFORMATETC
+{
+public:
+ explicit QOleEnumFmtEtc(const QVector<FORMATETC> &fmtetcs);
+ explicit QOleEnumFmtEtc(const QVector<LPFORMATETC> &lpfmtetcs);
+ virtual ~QOleEnumFmtEtc();
+
+ bool isNull() const;
+
+ // IUnknown methods
+ STDMETHOD(QueryInterface)(REFIID riid, void FAR* FAR* ppvObj);
+ STDMETHOD_(ULONG,AddRef)(void);
+ STDMETHOD_(ULONG,Release)(void);
+
+ // IEnumFORMATETC methods
+ STDMETHOD(Next)(ULONG celt, LPFORMATETC rgelt, ULONG FAR* pceltFetched);
+ STDMETHOD(Skip)(ULONG celt);
+ STDMETHOD(Reset)(void);
+ STDMETHOD(Clone)(LPENUMFORMATETC FAR* newEnum);
+
+private:
+ bool copyFormatEtc(LPFORMATETC dest, LPFORMATETC src) const;
+
+ ULONG m_dwRefs;
+ ULONG m_nIndex;
+ QVector<LPFORMATETC> m_lpfmtetcs;
+ bool m_isNull;
+};
+
+#endif
+
+#endif //QT_NO_DRAGANDDROP && QT_NO_CLIPBOARD
+
+#ifndef QT_NO_DRAGANDDROP
+
+class QDragPrivate : public QObjectPrivate
+{
+public:
+ QWidget *source;
+ QWidget *target;
+ QMimeData *data;
+ QPixmap pixmap;
+ QPoint hotspot;
+ Qt::DropActions possible_actions;
+ Qt::DropAction executed_action;
+ QMap<Qt::DropAction, QPixmap> customCursors;
+ Qt::DropAction defaultDropAction;
+};
+
+class QDropData : public QInternalMimeData
+{
+ Q_OBJECT
+public:
+ QDropData();
+ ~QDropData();
+
+protected:
+ bool hasFormat_sys(const QString &mimeType) const;
+ QStringList formats_sys() const;
+ QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const;
+
+#if defined(Q_WS_WIN)
+public:
+ LPDATAOBJECT currentDataObject;
+#endif
+};
+
+class QDragManager: public QObject {
+ Q_OBJECT
+
+ QDragManager();
+ ~QDragManager();
+ // only friend classes can use QDragManager.
+ friend class QDrag;
+ friend class QDragMoveEvent;
+ friend class QDropEvent;
+ friend class QApplication;
+#ifdef Q_WS_MAC
+ friend class QWidgetPrivate; //dnd is implemented here
+#endif
+
+ bool eventFilter(QObject *, QEvent *);
+ void timerEvent(QTimerEvent*);
+
+public:
+ Qt::DropAction drag(QDrag *);
+
+ void cancel(bool deleteSource = true);
+ void move(const QPoint &);
+ void drop();
+ void updatePixmap();
+ QWidget *source() const { return object ? object->d_func()->source : 0; }
+ QDragPrivate *dragPrivate() const { return object ? object->d_func() : 0; }
+ static QDragPrivate *dragPrivate(QDrag *drag) { return drag ? drag->d_func() : 0; }
+
+ static QDragManager *self();
+ Qt::DropAction defaultAction(Qt::DropActions possibleActions,
+ Qt::KeyboardModifiers modifiers) const;
+
+ QDrag *object;
+
+ void updateCursor();
+
+ bool beingCancelled;
+ bool restoreCursor;
+ bool willDrop;
+ QEventLoop *eventLoop;
+
+ QPixmap dragCursor(Qt::DropAction action) const;
+
+ bool hasCustomDragCursors() const;
+
+ QDropData *dropData;
+
+ void emitActionChanged(Qt::DropAction newAction) { if (object) emit object->actionChanged(newAction); }
+
+ void setCurrentTarget(QWidget *target, bool dropped = false);
+ QWidget *currentTarget();
+
+#ifdef Q_WS_X11
+ QPixmap xdndMimeTransferedPixmap[2];
+ int xdndMimeTransferedPixmapIndex;
+#endif
+
+private:
+#if defined(Q_WS_QWS) || defined(Q_WS_QPA)
+ Qt::DropAction currentActionForOverrideCursor;
+#endif
+#ifdef Q_OS_SYMBIAN
+#ifndef QT_NO_CURSOR
+ QCursor overrideCursor;
+#endif
+#endif
+ QWidget *currentDropTarget;
+
+ static QDragManager *instance;
+ Q_DISABLE_COPY(QDragManager)
+};
+
+
+#if defined(Q_WS_WIN)
+
+class QOleDropTarget : public IDropTarget
+{
+public:
+ QOleDropTarget(QWidget* w);
+ virtual ~QOleDropTarget() {}
+
+ void releaseQt();
+
+ // IUnknown methods
+ STDMETHOD(QueryInterface)(REFIID riid, void FAR* FAR* ppvObj);
+ STDMETHOD_(ULONG, AddRef)(void);
+ STDMETHOD_(ULONG, Release)(void);
+
+ // IDropTarget methods
+ STDMETHOD(DragEnter)(LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect);
+ STDMETHOD(DragOver)(DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect);
+ STDMETHOD(DragLeave)();
+ STDMETHOD(Drop)(LPDATAOBJECT pDataObj, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect);
+
+private:
+ ULONG m_refs;
+ QWidget* widget;
+ QPointer<QWidget> currentWidget;
+ QRect answerRect;
+ QPoint lastPoint;
+ DWORD chosenEffect;
+ DWORD lastKeyState;
+
+ void sendDragEnterEvent(QWidget *to, DWORD grfKeyState, POINTL pt, LPDWORD pdwEffect);
+};
+
+#endif
+
+#if defined (Q_WS_MAC)
+class QCocoaDropData : public QInternalMimeData
+{
+ Q_OBJECT
+public:
+ QCocoaDropData(CFStringRef pasteboard);
+ ~QCocoaDropData();
+
+protected:
+ bool hasFormat_sys(const QString &mimeType) const;
+ QStringList formats_sys() const;
+ QVariant retrieveData_sys(const QString &mimeType, QVariant::Type type) const;
+public:
+ CFStringRef dropPasteboard;
+};
+#endif
+
+#endif // !QT_NO_DRAGANDDROP
+
+
+QT_END_NAMESPACE
+
+#endif // QDND_P_H
diff --git a/src/widgets/to_be_moved/qdnd_qpa.cpp b/src/widgets/to_be_moved/qdnd_qpa.cpp
new file mode 100644
index 0000000000..82e8d580ae
--- /dev/null
+++ b/src/widgets/to_be_moved/qdnd_qpa.cpp
@@ -0,0 +1,426 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qguiapplication.h"
+
+#ifndef QT_NO_DRAGANDDROP
+
+#include "qwidget.h"
+#include "qdatetime.h"
+#include "qbitmap.h"
+#include "qcursor.h"
+#include "qevent.h"
+#include "qpainter.h"
+#include "qdnd_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QT_USE_NAMESPACE
+
+static QPixmap *defaultPm = 0;
+static const int default_pm_hotx = -2;
+static const int default_pm_hoty = -16;
+static const char *const default_pm[] = {
+"13 9 3 1",
+". c None",
+" c #000000",
+"X c #FFFFFF",
+"X X X X X X X",
+" X X X X X X ",
+"X ......... X",
+" X.........X ",
+"X ......... X",
+" X.........X ",
+"X ......... X",
+" X X X X X X ",
+"X X X X X X X",
+};
+
+// Shift/Ctrl handling, and final drop status
+static Qt::DropAction global_accepted_action = Qt::CopyAction;
+static Qt::DropActions possible_actions = Qt::IgnoreAction;
+
+
+// static variables in place of a proper cross-process solution
+static QDrag *drag_object;
+static bool qt_qws_dnd_dragging = false;
+
+
+static Qt::KeyboardModifiers oldstate;
+
+class QShapedPixmapWidget : public QWidget {
+ QPixmap pixmap;
+public:
+ QShapedPixmapWidget() :
+ QWidget(0, Qt::Tool | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint)
+ {
+ // ### Temporary workaround for 4.2-rc1!!! To prevent flickering when
+ // using drag'n drop in a client application. (task 126956)
+ // setAttribute() should be done unconditionally!
+ // if (QApplication::type() == QApplication::GuiServer)
+ setAttribute(Qt::WA_TransparentForMouseEvents);
+ }
+
+ void setPixmap(QPixmap pm)
+ {
+ pixmap = pm;
+ if (!pixmap.mask().isNull()) {
+ setMask(pixmap.mask());
+ } else {
+ clearMask();
+ }
+ resize(pm.width(),pm.height());
+ }
+
+ void paintEvent(QPaintEvent*)
+ {
+ QPainter p(this);
+ p.drawPixmap(0,0,pixmap);
+ }
+};
+
+
+static QShapedPixmapWidget *qt_qws_dnd_deco = 0;
+
+
+void QDragManager::updatePixmap()
+{
+ if (qt_qws_dnd_deco) {
+ QPixmap pm;
+ QPoint pm_hot(default_pm_hotx,default_pm_hoty);
+ if (drag_object) {
+ pm = drag_object->pixmap();
+ if (!pm.isNull())
+ pm_hot = drag_object->hotSpot();
+ }
+ if (pm.isNull()) {
+ if (!defaultPm)
+ defaultPm = new QPixmap(default_pm);
+ pm = *defaultPm;
+ }
+ qt_qws_dnd_deco->setPixmap(pm);
+ qt_qws_dnd_deco->move(QCursor::pos()-pm_hot);
+ if (willDrop) {
+ qt_qws_dnd_deco->show();
+ } else {
+ qt_qws_dnd_deco->hide();
+ }
+ }
+}
+
+void QDragManager::timerEvent(QTimerEvent *) { }
+
+void QDragManager::move(const QPoint &) { }
+
+void QDragManager::updateCursor()
+{
+#ifndef QT_NO_CURSOR
+ if (willDrop) {
+ if (qt_qws_dnd_deco)
+ qt_qws_dnd_deco->show();
+ if (currentActionForOverrideCursor != global_accepted_action) {
+ QGuiApplication::changeOverrideCursor(QCursor(dragCursor(global_accepted_action), 0, 0));
+ currentActionForOverrideCursor = global_accepted_action;
+ }
+ } else {
+ QCursor *overrideCursor = QGuiApplication::overrideCursor();
+ if (!overrideCursor || overrideCursor->shape() != Qt::ForbiddenCursor) {
+ QGuiApplication::changeOverrideCursor(QCursor(Qt::ForbiddenCursor));
+ currentActionForOverrideCursor = Qt::IgnoreAction;
+ }
+ if (qt_qws_dnd_deco)
+ qt_qws_dnd_deco->hide();
+ }
+#endif
+}
+
+
+bool QDragManager::eventFilter(QObject *o, QEvent *e)
+{
+ if (beingCancelled) {
+ if (e->type() == QEvent::KeyRelease && static_cast<QKeyEvent*>(e)->key() == Qt::Key_Escape) {
+ qApp->removeEventFilter(this);
+ Q_ASSERT(object == 0);
+ beingCancelled = false;
+ eventLoop->exit();
+ return true; // block the key release
+ }
+ return false;
+ }
+
+
+
+ if (!o->isWidgetType())
+ return false;
+
+ switch(e->type()) {
+ case QEvent::ShortcutOverride:
+ // prevent accelerators from firing while dragging
+ e->accept();
+ return true;
+
+ case QEvent::KeyPress:
+ case QEvent::KeyRelease:
+ {
+ QKeyEvent *ke = ((QKeyEvent*)e);
+ if (ke->key() == Qt::Key_Escape && e->type() == QEvent::KeyPress) {
+ cancel();
+ qApp->removeEventFilter(this);
+ beingCancelled = false;
+ eventLoop->exit();
+ } else {
+ updateCursor();
+ }
+ return true; // Eat all key events
+ }
+
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseMove:
+ {
+ if (!object) { //#### this should not happen
+ qWarning("QDragManager::eventFilter: No object");
+ return true;
+ }
+
+ QDragManager *manager = QDragManager::self();
+ QMimeData *dropData = manager->object ? manager->dragPrivate()->data : manager->dropData;
+ if (manager->object)
+ possible_actions = manager->dragPrivate()->possible_actions;
+ else
+ possible_actions = Qt::IgnoreAction;
+
+ QMouseEvent *me = (QMouseEvent *)e;
+ if (me->buttons()) {
+ Qt::DropAction prevAction = global_accepted_action;
+ QWidget *cw = QApplication::widgetAt(me->globalPos());
+
+ // Fix for when we move mouse on to the deco widget
+ if (qt_qws_dnd_deco && cw == qt_qws_dnd_deco)
+ cw = object->target();
+
+ while (cw && !cw->acceptDrops() && !cw->isWindow())
+ cw = cw->parentWidget();
+
+ if (object->target() != cw) {
+ if (object->target()) {
+ QDragLeaveEvent dle;
+ QCoreApplication::sendEvent(object->target(), &dle);
+ willDrop = false;
+ global_accepted_action = Qt::IgnoreAction;
+ updateCursor();
+ restoreCursor = true;
+ object->d_func()->target = 0;
+ }
+ if (cw && cw->acceptDrops()) {
+ object->d_func()->target = cw;
+ QDragEnterEvent dee(cw->mapFromGlobal(me->globalPos()), possible_actions, dropData,
+ me->buttons(), me->modifiers());
+ QCoreApplication::sendEvent(object->target(), &dee);
+ willDrop = dee.isAccepted() && dee.dropAction() != Qt::IgnoreAction;
+ global_accepted_action = willDrop ? dee.dropAction() : Qt::IgnoreAction;
+ updateCursor();
+ restoreCursor = true;
+ }
+ } else if (cw) {
+ QDragMoveEvent dme(cw->mapFromGlobal(me->globalPos()), possible_actions, dropData,
+ me->buttons(), me->modifiers());
+ if (global_accepted_action != Qt::IgnoreAction) {
+ dme.setDropAction(global_accepted_action);
+ dme.accept();
+ }
+ QCoreApplication::sendEvent(cw, &dme);
+ willDrop = dme.isAccepted();
+ global_accepted_action = willDrop ? dme.dropAction() : Qt::IgnoreAction;
+ updatePixmap();
+ updateCursor();
+ }
+ if (global_accepted_action != prevAction)
+ emitActionChanged(global_accepted_action);
+ }
+ return true; // Eat all mouse events
+ }
+
+ case QEvent::MouseButtonRelease:
+ {
+ qApp->removeEventFilter(this);
+ if (restoreCursor) {
+ willDrop = false;
+#ifndef QT_NO_CURSOR
+ QGuiApplication::restoreOverrideCursor();
+#endif
+ restoreCursor = false;
+ }
+ if (object && object->target()) {
+ QMouseEvent *me = (QMouseEvent *)e;
+
+ QDragManager *manager = QDragManager::self();
+ QMimeData *dropData = manager->object ? manager->dragPrivate()->data : manager->dropData;
+
+ QDropEvent de(object->target()->mapFromGlobal(me->globalPos()), possible_actions, dropData,
+ me->buttons(), me->modifiers());
+ QCoreApplication::sendEvent(object->target(), &de);
+ if (de.isAccepted())
+ global_accepted_action = de.dropAction();
+ else
+ global_accepted_action = Qt::IgnoreAction;
+
+ if (object)
+ object->deleteLater();
+ drag_object = object = 0;
+ }
+ eventLoop->exit();
+ return true; // Eat all mouse events
+ }
+
+ default:
+ break;
+ }
+
+ return false;
+}
+
+Qt::DropAction QDragManager::drag(QDrag *o)
+{
+ if (object == o || !o || !o->source())
+ return Qt::IgnoreAction;
+
+ if (object) {
+ cancel();
+ qApp->removeEventFilter(this);
+ beingCancelled = false;
+ }
+
+ object = drag_object = o;
+ qt_qws_dnd_deco = new QShapedPixmapWidget();
+ oldstate = Qt::NoModifier; // #### Should use state that caused the drag
+// drag_mode = mode;
+
+ willDrop = false;
+ updatePixmap();
+ updateCursor();
+ restoreCursor = true;
+ object->d_func()->target = 0;
+ qApp->installEventFilter(this);
+
+ global_accepted_action = Qt::CopyAction;
+#ifndef QT_NO_CURSOR
+ qApp->setOverrideCursor(Qt::ArrowCursor);
+ restoreCursor = true;
+ updateCursor();
+#endif
+
+ qt_qws_dnd_dragging = true;
+
+ eventLoop = new QEventLoop;
+ (void) eventLoop->exec();
+ delete eventLoop;
+ eventLoop = 0;
+
+ delete qt_qws_dnd_deco;
+ qt_qws_dnd_deco = 0;
+ qt_qws_dnd_dragging = false;
+
+
+ return global_accepted_action;
+}
+
+
+void QDragManager::cancel(bool deleteSource)
+{
+// qDebug("QDragManager::cancel");
+ beingCancelled = true;
+
+ if (object->target()) {
+ QDragLeaveEvent dle;
+ QCoreApplication::sendEvent(object->target(), &dle);
+ }
+
+#ifndef QT_NO_CURSOR
+ if (restoreCursor) {
+ QGuiApplication::restoreOverrideCursor();
+ restoreCursor = false;
+ }
+#endif
+
+ if (drag_object) {
+ if (deleteSource)
+ object->deleteLater();
+ drag_object = object = 0;
+ }
+
+ delete qt_qws_dnd_deco;
+ qt_qws_dnd_deco = 0;
+
+ global_accepted_action = Qt::IgnoreAction;
+}
+
+
+void QDragManager::drop()
+{
+}
+
+QVariant QDropData::retrieveData_sys(const QString &mimetype, QVariant::Type type) const
+{
+ if (!drag_object)
+ return QVariant();
+ QByteArray data = drag_object->mimeData()->data(mimetype);
+ if (type == QVariant::String)
+ return QString::fromUtf8(data);
+ return data;
+}
+
+bool QDropData::hasFormat_sys(const QString &format) const
+{
+ return formats().contains(format);
+}
+
+QStringList QDropData::formats_sys() const
+{
+ if (drag_object)
+ return drag_object->mimeData()->formats();
+ return QStringList();
+}
+
+
+#endif // QT_NO_DRAGANDDROP
+
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qdrag.cpp b/src/widgets/to_be_moved/qdrag.cpp
index d8d14cb45c..d8d14cb45c 100644
--- a/src/gui/kernel/qdrag.cpp
+++ b/src/widgets/to_be_moved/qdrag.cpp
diff --git a/src/gui/kernel/qdrag.h b/src/widgets/to_be_moved/qdrag.h
index da847898b2..da847898b2 100644
--- a/src/gui/kernel/qdrag.h
+++ b/src/widgets/to_be_moved/qdrag.h
diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/widgets/to_be_moved/qlinecontrol.cpp
index eb4e142328..eb4e142328 100644
--- a/src/gui/widgets/qlinecontrol.cpp
+++ b/src/widgets/to_be_moved/qlinecontrol.cpp
diff --git a/src/widgets/to_be_moved/qlinecontrol_p.h b/src/widgets/to_be_moved/qlinecontrol_p.h
new file mode 100644
index 0000000000..a5de15ff8b
--- /dev/null
+++ b/src/widgets/to_be_moved/qlinecontrol_p.h
@@ -0,0 +1,456 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLINECONTROL_P_H
+#define QLINECONTROL_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "QtCore/qglobal.h"
+
+#ifndef QT_NO_LINEEDIT
+#include "private/qwidget_p.h"
+#include "QtWidgets/qlineedit.h"
+#include "QtGui/qtextlayout.h"
+#include "QtWidgets/qstyleoption.h"
+#include "QtCore/qpointer.h"
+#include "QtWidgets/qlineedit.h"
+#include "QtGui/qclipboard.h"
+#include "QtCore/qpoint.h"
+#include "QtWidgets/qcompleter.h"
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class Q_GUI_EXPORT QLineControl : public QObject
+{
+ Q_OBJECT
+
+public:
+ QLineControl(const QString &txt = QString())
+ : m_cursor(0), m_preeditCursor(0), m_cursorWidth(0), m_layoutDirection(Qt::LayoutDirectionAuto),
+ m_hideCursor(false), m_separator(0), m_readOnly(0),
+ m_dragEnabled(0), m_echoMode(0), m_textDirty(0), m_selDirty(0),
+ m_validInput(1), m_blinkStatus(0), m_blinkPeriod(0), m_blinkTimer(0), m_deleteAllTimer(0),
+ m_ascent(0), m_maxLength(32767), m_lastCursorPos(-1),
+ m_tripleClickTimer(0), m_maskData(0), m_modifiedState(0), m_undoState(0),
+ m_selstart(0), m_selend(0), m_passwordEchoEditing(false)
+ {
+ init(txt);
+ }
+
+ ~QLineControl()
+ {
+ delete [] m_maskData;
+ }
+
+ int nextMaskBlank(int pos)
+ {
+ int c = findInMask(pos, true, false);
+ m_separator |= (c != pos);
+ return (c != -1 ? c : m_maxLength);
+ }
+
+ int prevMaskBlank(int pos)
+ {
+ int c = findInMask(pos, false, false);
+ m_separator |= (c != pos);
+ return (c != -1 ? c : 0);
+ }
+
+ bool isUndoAvailable() const { return !m_readOnly && m_undoState; }
+ bool isRedoAvailable() const { return !m_readOnly && m_undoState < (int)m_history.size(); }
+ void clearUndo() { m_history.clear(); m_modifiedState = m_undoState = 0; }
+
+ bool isModified() const { return m_modifiedState != m_undoState; }
+ void setModified(bool modified) { m_modifiedState = modified ? -1 : m_undoState; }
+
+ bool allSelected() const { return !m_text.isEmpty() && m_selstart == 0 && m_selend == (int)m_text.length(); }
+ bool hasSelectedText() const { return !m_text.isEmpty() && m_selend > m_selstart; }
+
+ int width() const { return qRound(m_textLayout.lineAt(0).width()) + 1; }
+ int height() const { return qRound(m_textLayout.lineAt(0).height()) + 1; }
+ int ascent() const { return m_ascent; }
+ qreal naturalTextWidth() const { return m_textLayout.lineAt(0).naturalTextWidth(); }
+
+ void setSelection(int start, int length);
+
+ inline QString selectedText() const { return hasSelectedText() ? m_text.mid(m_selstart, m_selend - m_selstart) : QString(); }
+ QString textBeforeSelection() const { return hasSelectedText() ? m_text.left(m_selstart) : QString(); }
+ QString textAfterSelection() const { return hasSelectedText() ? m_text.mid(m_selend) : QString(); }
+
+ int selectionStart() const { return hasSelectedText() ? m_selstart : -1; }
+ int selectionEnd() const { return hasSelectedText() ? m_selend : -1; }
+ bool inSelection(int x) const
+ {
+ if (m_selstart >= m_selend)
+ return false;
+ int pos = xToPos(x, QTextLine::CursorOnCharacter);
+ return pos >= m_selstart && pos < m_selend;
+ }
+
+ void removeSelection()
+ {
+ int priorState = m_undoState;
+ removeSelectedText();
+ finishChange(priorState);
+ }
+
+ int start() const { return 0; }
+ int end() const { return m_text.length(); }
+
+#ifndef QT_NO_CLIPBOARD
+ void copy(QClipboard::Mode mode = QClipboard::Clipboard) const;
+ void paste(QClipboard::Mode mode = QClipboard::Clipboard);
+#endif
+
+ int cursor() const{ return m_cursor; }
+ int preeditCursor() const { return m_preeditCursor; }
+
+ int cursorWidth() const { return m_cursorWidth; }
+ void setCursorWidth(int value) { m_cursorWidth = value; }
+
+ QTextCursor::MoveStyle cursorMoveStyle() const { return m_textLayout.cursorMoveStyle(); }
+ void setCursorMoveStyle(QTextCursor::MoveStyle style) { m_textLayout.setCursorMoveStyle(style); }
+
+ void moveCursor(int pos, bool mark = false);
+ void cursorForward(bool mark, int steps)
+ {
+ int c = m_cursor;
+ if (steps > 0) {
+ while (steps--)
+ c = cursorMoveStyle() == QTextCursor::Visual ? m_textLayout.rightCursorPosition(c)
+ : m_textLayout.nextCursorPosition(c);
+ } else if (steps < 0) {
+ while (steps++)
+ c = cursorMoveStyle() == QTextCursor::Visual ? m_textLayout.leftCursorPosition(c)
+ : m_textLayout.previousCursorPosition(c);
+ }
+ moveCursor(c, mark);
+ }
+
+ void cursorWordForward(bool mark) { moveCursor(m_textLayout.nextCursorPosition(m_cursor, QTextLayout::SkipWords), mark); }
+ void cursorWordBackward(bool mark) { moveCursor(m_textLayout.previousCursorPosition(m_cursor, QTextLayout::SkipWords), mark); }
+
+ void home(bool mark) { moveCursor(0, mark); }
+ void end(bool mark) { moveCursor(text().length(), mark); }
+
+ int xToPos(int x, QTextLine::CursorPosition = QTextLine::CursorBetweenCharacters) const;
+ QRect cursorRect() const;
+
+ qreal cursorToX(int cursor) const { return m_textLayout.lineAt(0).cursorToX(cursor); }
+ qreal cursorToX() const
+ {
+ int cursor = m_cursor;
+ if (m_preeditCursor != -1)
+ cursor += m_preeditCursor;
+ return cursorToX(cursor);
+ }
+
+ bool isReadOnly() const { return m_readOnly; }
+ void setReadOnly(bool enable) { m_readOnly = enable; }
+
+ QString text() const
+ {
+ QString res = m_maskData ? stripString(m_text) : m_text;
+ return (res.isNull() ? QString::fromLatin1("") : res);
+ }
+ void setText(const QString &txt) { internalSetText(txt, -1, false); }
+ QString displayText() const { return m_textLayout.text(); }
+
+ void backspace();
+ void del();
+ void deselect() { internalDeselect(); finishChange(); }
+ void selectAll() { m_selstart = m_selend = m_cursor = 0; moveCursor(m_text.length(), true); }
+
+ void insert(const QString &);
+ void clear();
+ void undo() { internalUndo(); finishChange(-1, true); }
+ void redo() { internalRedo(); finishChange(); }
+ void selectWordAtPos(int);
+
+ uint echoMode() const { return m_echoMode; }
+ void setEchoMode(uint mode)
+ {
+ m_echoMode = mode;
+ m_passwordEchoEditing = false;
+ updateDisplayText();
+ }
+
+ int maxLength() const { return m_maxLength; }
+ void setMaxLength(int maxLength)
+ {
+ if (m_maskData)
+ return;
+ m_maxLength = maxLength;
+ setText(m_text);
+ }
+
+#ifndef QT_NO_VALIDATOR
+ const QValidator *validator() const { return m_validator; }
+ void setValidator(const QValidator *v) { m_validator = const_cast<QValidator*>(v); }
+#endif
+
+#ifndef QT_NO_COMPLETER
+ QCompleter *completer() const { return m_completer; }
+ /* Note that you must set the widget for the completer separately */
+ void setCompleter(const QCompleter *c) { m_completer = const_cast<QCompleter*>(c); }
+ void complete(int key);
+#endif
+
+ int cursorPosition() const { return m_cursor; }
+ void setCursorPosition(int pos) { if (pos <= m_text.length()) moveCursor(qMax(0, pos)); }
+
+ bool hasAcceptableInput() const { return hasAcceptableInput(m_text); }
+ bool fixup();
+
+ QString inputMask() const { return m_maskData ? m_inputMask + QLatin1Char(';') + m_blank : QString(); }
+ void setInputMask(const QString &mask)
+ {
+ parseInputMask(mask);
+ if (m_maskData)
+ moveCursor(nextMaskBlank(0));
+ }
+
+ // input methods
+#ifndef QT_NO_IM
+ bool composeMode() const { return !m_textLayout.preeditAreaText().isEmpty(); }
+ void setPreeditArea(int cursor, const QString &text) { m_textLayout.setPreeditArea(cursor, text); }
+#endif
+
+ QString preeditAreaText() const { return m_textLayout.preeditAreaText(); }
+
+ void updatePasswordEchoEditing(bool editing);
+ bool passwordEchoEditing() const { return m_passwordEchoEditing; }
+
+ QChar passwordCharacter() const { return m_passwordCharacter; }
+ void setPasswordCharacter(const QChar &character) { m_passwordCharacter = character; updateDisplayText(); }
+
+ Qt::LayoutDirection layoutDirection() const {
+ if (m_layoutDirection == Qt::LayoutDirectionAuto) {
+ if (m_text.isEmpty())
+ return QApplication::keyboardInputDirection();
+ return m_text.isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight;
+ }
+ return m_layoutDirection;
+ }
+ void setLayoutDirection(Qt::LayoutDirection direction)
+ {
+ if (direction != m_layoutDirection) {
+ m_layoutDirection = direction;
+ updateDisplayText();
+ }
+ }
+
+ void setFont(const QFont &font) { m_textLayout.setFont(font); updateDisplayText(); }
+
+ void processInputMethodEvent(QInputMethodEvent *event);
+ void processMouseEvent(QMouseEvent* ev);
+ void processKeyEvent(QKeyEvent* ev);
+
+ int cursorBlinkPeriod() const { return m_blinkPeriod; }
+ void setCursorBlinkPeriod(int msec);
+ void resetCursorBlinkTimer();
+
+ QString cancelText() const { return m_cancelText; }
+ void setCancelText(const QString &text) { m_cancelText = text; }
+
+ const QPalette &palette() const { return m_palette; }
+ void setPalette(const QPalette &p) { m_palette = p; }
+
+ enum DrawFlags {
+ DrawText = 0x01,
+ DrawSelections = 0x02,
+ DrawCursor = 0x04,
+ DrawAll = DrawText | DrawSelections | DrawCursor
+ };
+ void draw(QPainter *, const QPoint &, const QRect &, int flags = DrawAll);
+
+ bool processEvent(QEvent *ev);
+
+private:
+ void init(const QString &txt);
+ void removeSelectedText();
+ void internalSetText(const QString &txt, int pos = -1, bool edited = true);
+ void updateDisplayText(bool forceUpdate = false);
+
+ void internalInsert(const QString &s);
+ void internalDelete(bool wasBackspace = false);
+ void internalRemove(int pos);
+
+ inline void internalDeselect()
+ {
+ m_selDirty |= (m_selend > m_selstart);
+ m_selstart = m_selend = 0;
+ }
+
+ void internalUndo(int until = -1);
+ void internalRedo();
+
+ QString m_text;
+ QPalette m_palette;
+ int m_cursor;
+ int m_preeditCursor;
+ int m_cursorWidth;
+ Qt::LayoutDirection m_layoutDirection;
+ uint m_hideCursor : 1; // used to hide the m_cursor inside preedit areas
+ uint m_separator : 1;
+ uint m_readOnly : 1;
+ uint m_dragEnabled : 1;
+ uint m_echoMode : 2;
+ uint m_textDirty : 1;
+ uint m_selDirty : 1;
+ uint m_validInput : 1;
+ uint m_blinkStatus : 1;
+ int m_blinkPeriod; // 0 for non-blinking cursor
+ int m_blinkTimer;
+ int m_deleteAllTimer;
+ int m_ascent;
+ int m_maxLength;
+ int m_lastCursorPos;
+ QList<int> m_transactions;
+ QPoint m_tripleClick;
+ int m_tripleClickTimer;
+ QString m_cancelText;
+
+ void emitCursorPositionChanged();
+
+ bool finishChange(int validateFromState = -1, bool update = false, bool edited = true);
+
+#ifndef QT_NO_VALIDATOR
+ QPointer<QValidator> m_validator;
+#endif
+ QPointer<QCompleter> m_completer;
+#ifndef QT_NO_COMPLETER
+ bool advanceToEnabledItem(int dir);
+#endif
+
+ struct MaskInputData {
+ enum Casemode { NoCaseMode, Upper, Lower };
+ QChar maskChar; // either the separator char or the inputmask
+ bool separator;
+ Casemode caseMode;
+ };
+ QString m_inputMask;
+ QChar m_blank;
+ MaskInputData *m_maskData;
+
+ // undo/redo handling
+ enum CommandType { Separator, Insert, Remove, Delete, RemoveSelection, DeleteSelection, SetSelection };
+ struct Command {
+ inline Command() {}
+ inline Command(CommandType t, int p, QChar c, int ss, int se) : type(t),uc(c),pos(p),selStart(ss),selEnd(se) {}
+ uint type : 4;
+ QChar uc;
+ int pos, selStart, selEnd;
+ };
+ int m_modifiedState;
+ int m_undoState;
+ QVector<Command> m_history;
+ void addCommand(const Command& cmd);
+
+ inline void separate() { m_separator = true; }
+
+ // selection
+ int m_selstart;
+ int m_selend;
+
+ // masking
+ void parseInputMask(const QString &maskFields);
+ bool isValidInput(QChar key, QChar mask) const;
+ bool hasAcceptableInput(const QString &text) const;
+ QString maskString(uint pos, const QString &str, bool clear = false) const;
+ QString clearString(uint pos, uint len) const;
+ QString stripString(const QString &str) const;
+ int findInMask(int pos, bool forward, bool findSeparator, QChar searchChar = QChar()) const;
+
+ // complex text layout
+ QTextLayout m_textLayout;
+
+ bool m_passwordEchoEditing;
+ QChar m_passwordCharacter;
+
+Q_SIGNALS:
+ void cursorPositionChanged(int, int);
+ void selectionChanged();
+
+ void displayTextChanged(const QString &);
+ void textChanged(const QString &);
+ void textEdited(const QString &);
+
+ void resetInputContext();
+ void updateMicroFocus();
+
+ void accepted();
+ void editingFinished();
+ void updateNeeded(const QRect &);
+
+#ifdef QT_KEYPAD_NAVIGATION
+ void editFocusChange(bool);
+#endif
+protected:
+ virtual void timerEvent(QTimerEvent *event);
+
+private Q_SLOTS:
+ void _q_clipboardChanged();
+ void _q_deleteSelected();
+
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QT_NO_LINEEDIT
+
+#endif // QLINECONTROL_P_H
diff --git a/src/gui/kernel/qshortcut.cpp b/src/widgets/to_be_moved/qshortcut.cpp
index 978ef0c240..978ef0c240 100644
--- a/src/gui/kernel/qshortcut.cpp
+++ b/src/widgets/to_be_moved/qshortcut.cpp
diff --git a/src/widgets/to_be_moved/qshortcut.h b/src/widgets/to_be_moved/qshortcut.h
new file mode 100644
index 0000000000..c337e177cd
--- /dev/null
+++ b/src/widgets/to_be_moved/qshortcut.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSHORTCUT_H
+#define QSHORTCUT_H
+
+#include <QtWidgets/qwidget.h>
+#include <QtGui/qkeysequence.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_SHORTCUT
+
+class QShortcutPrivate;
+class Q_GUI_EXPORT QShortcut : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QShortcut)
+ Q_PROPERTY(QKeySequence key READ key WRITE setKey)
+ Q_PROPERTY(QString whatsThis READ whatsThis WRITE setWhatsThis)
+ Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled)
+ Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat)
+ Q_PROPERTY(Qt::ShortcutContext context READ context WRITE setContext)
+public:
+ explicit QShortcut(QWidget *parent);
+ QShortcut(const QKeySequence& key, QWidget *parent,
+ const char *member = 0, const char *ambiguousMember = 0,
+ Qt::ShortcutContext context = Qt::WindowShortcut);
+ ~QShortcut();
+
+ void setKey(const QKeySequence& key);
+ QKeySequence key() const;
+
+ void setEnabled(bool enable);
+ bool isEnabled() const;
+
+ void setContext(Qt::ShortcutContext context);
+ Qt::ShortcutContext context();
+
+ void setWhatsThis(const QString &text);
+ QString whatsThis() const;
+
+ void setAutoRepeat(bool on);
+ bool autoRepeat() const;
+
+ int id() const;
+
+ inline QWidget *parentWidget() const
+ { return static_cast<QWidget *>(QObject::parent()); }
+
+Q_SIGNALS:
+ void activated();
+ void activatedAmbiguously();
+
+protected:
+ bool event(QEvent *e);
+};
+
+#endif // QT_NO_SHORTCUT
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QSHORTCUT_H
diff --git a/src/widgets/to_be_moved/qshortcutmap.cpp b/src/widgets/to_be_moved/qshortcutmap.cpp
new file mode 100644
index 0000000000..d6baa1331e
--- /dev/null
+++ b/src/widgets/to_be_moved/qshortcutmap.cpp
@@ -0,0 +1,897 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qshortcutmap_p.h"
+#include "private/qobject_p.h"
+#include "qkeysequence.h"
+#include "qgraphicsscene.h"
+#include "qgraphicsview.h"
+#include "qdebug.h"
+#include "qevent.h"
+#include "qwidget.h"
+#include "qapplication.h"
+#include "qvector.h"
+#include "qmenu.h"
+#include "qmenubar.h"
+#include "qshortcut.h"
+#include "private/qapplication_p.h"
+#include <private/qaction_p.h>
+#include <private/qkeymapper_p.h>
+#include <private/qwidget_p.h>
+
+#ifndef QT_NO_SHORTCUT
+
+QT_BEGIN_NAMESPACE
+
+// To enable verbose output uncomment below
+//#define DEBUG_QSHORTCUTMAP
+
+/* \internal
+ Entry data for QShortcutMap
+ Contains:
+ Keysequence for entry
+ Pointer to parent owning the sequence
+*/
+struct QShortcutEntry
+{
+ QShortcutEntry()
+ : keyseq(0), context(Qt::WindowShortcut), enabled(false), autorepeat(1), id(0), owner(0)
+ {}
+
+ QShortcutEntry(const QKeySequence &k)
+ : keyseq(k), context(Qt::WindowShortcut), enabled(false), autorepeat(1), id(0), owner(0)
+ {}
+
+ QShortcutEntry(QObject *o, const QKeySequence &k, Qt::ShortcutContext c, int i)
+ : keyseq(k), context(c), enabled(true), autorepeat(1), id(i), owner(o)
+ {}
+
+ QShortcutEntry(QObject *o, const QKeySequence &k, Qt::ShortcutContext c, int i, bool a)
+ : keyseq(k), context(c), enabled(true), autorepeat(a), id(i), owner(o)
+ {}
+
+ bool operator<(const QShortcutEntry &f) const
+ { return keyseq < f.keyseq; }
+
+ QKeySequence keyseq;
+ Qt::ShortcutContext context;
+ bool enabled : 1;
+ bool autorepeat : 1;
+ signed int id;
+ QObject *owner;
+};
+
+#if 0 //ndef QT_NO_DEBUG_STREAM
+/*! \internal
+ QDebug operator<< for easy debug output of the shortcut entries.
+*/
+static QDebug &operator<<(QDebug &dbg, const QShortcutEntry *se) {
+ if (!se)
+ return dbg << "QShortcutEntry(0x0)";
+ dbg.nospace()
+ << "QShortcutEntry(" << se->keyseq
+ << "), id(" << se->id << "), enabled(" << se->enabled << "), autorepeat(" << se->autorepeat
+ << "), owner(" << se->owner << ')';
+ return dbg.space();
+}
+#endif // QT_NO_DEBUGSTREAM
+
+/* \internal
+ Private data for QShortcutMap
+*/
+class QShortcutMapPrivate
+{
+ Q_DECLARE_PUBLIC(QShortcutMap)
+
+public:
+ QShortcutMapPrivate(QShortcutMap* parent)
+ : q_ptr(parent), currentId(0), ambigCount(0), currentState(QKeySequence::NoMatch)
+ {
+ identicals.reserve(10);
+ currentSequences.reserve(10);
+ }
+ QShortcutMap *q_ptr; // Private's parent
+
+ QList<QShortcutEntry> sequences; // All sequences!
+
+ int currentId; // Global shortcut ID number
+ int ambigCount; // Index of last enabled ambiguous dispatch
+ QKeySequence::SequenceMatch currentState;
+ QVector<QKeySequence> currentSequences; // Sequence for the current state
+ QVector<QKeySequence> newEntries;
+ QKeySequence prevSequence; // Sequence for the previous identical match
+ QVector<const QShortcutEntry*> identicals; // Last identical matches
+};
+
+
+/*! \internal
+ QShortcutMap constructor.
+*/
+QShortcutMap::QShortcutMap()
+ : d_ptr(new QShortcutMapPrivate(this))
+{
+ resetState();
+}
+
+/*! \internal
+ QShortcutMap destructor.
+*/
+QShortcutMap::~QShortcutMap()
+{
+}
+
+/*! \internal
+ Adds a shortcut to the global map.
+ Returns the id of the newly added shortcut.
+*/
+int QShortcutMap::addShortcut(QObject *owner, const QKeySequence &key, Qt::ShortcutContext context)
+{
+ Q_ASSERT_X(owner, "QShortcutMap::addShortcut", "All shortcuts need an owner");
+ Q_ASSERT_X(!key.isEmpty(), "QShortcutMap::addShortcut", "Cannot add keyless shortcuts to map");
+ Q_D(QShortcutMap);
+
+ QShortcutEntry newEntry(owner, key, context, --(d->currentId), true);
+ QList<QShortcutEntry>::iterator it = qUpperBound(d->sequences.begin(), d->sequences.end(), newEntry);
+ d->sequences.insert(it, newEntry); // Insert sorted
+#if defined(DEBUG_QSHORTCUTMAP)
+ qDebug().nospace()
+ << "QShortcutMap::addShortcut(" << owner << ", "
+ << key << ", " << context << ") = " << d->currentId;
+#endif
+ return d->currentId;
+}
+
+/*! \internal
+ Removes a shortcut from the global map.
+ If \a owner is 0, all entries in the map with the key sequence specified
+ is removed. If \a key is null, all sequences for \a owner is removed from
+ the map. If \a id is 0, any identical \a key sequences owned by \a owner
+ are removed.
+ Returns the number of sequences removed from the map.
+*/
+
+int QShortcutMap::removeShortcut(int id, QObject *owner, const QKeySequence &key)
+{
+ Q_D(QShortcutMap);
+ int itemsRemoved = 0;
+ bool allOwners = (owner == 0);
+ bool allKeys = key.isEmpty();
+ bool allIds = id == 0;
+
+ // Special case, remove everything
+ if (allOwners && allKeys && id == 0) {
+ itemsRemoved = d->sequences.size();
+ d->sequences.clear();
+ return itemsRemoved;
+ }
+
+ int i = d->sequences.size()-1;
+ while (i>=0)
+ {
+ const QShortcutEntry &entry = d->sequences.at(i);
+ int entryId = entry.id;
+ if ((allOwners || entry.owner == owner)
+ && (allIds || entry.id == id)
+ && (allKeys || entry.keyseq == key)) {
+ d->sequences.removeAt(i);
+ ++itemsRemoved;
+ }
+ if (id == entryId)
+ return itemsRemoved;
+ --i;
+ }
+#if defined(DEBUG_QSHORTCUTMAP)
+ qDebug().nospace()
+ << "QShortcutMap::removeShortcut(" << id << ", " << owner << ", "
+ << key << ") = " << itemsRemoved;
+#endif
+ return itemsRemoved;
+}
+
+/*! \internal
+ Changes the enable state of a shortcut to \a enable.
+ If \a owner is 0, all entries in the map with the key sequence specified
+ is removed. If \a key is null, all sequences for \a owner is removed from
+ the map. If \a id is 0, any identical \a key sequences owned by \a owner
+ are changed.
+ Returns the number of sequences which are matched in the map.
+*/
+int QShortcutMap::setShortcutEnabled(bool enable, int id, QObject *owner, const QKeySequence &key)
+{
+ Q_D(QShortcutMap);
+ int itemsChanged = 0;
+ bool allOwners = (owner == 0);
+ bool allKeys = key.isEmpty();
+ bool allIds = id == 0;
+
+ int i = d->sequences.size()-1;
+ while (i>=0)
+ {
+ QShortcutEntry entry = d->sequences.at(i);
+ if ((allOwners || entry.owner == owner)
+ && (allIds || entry.id == id)
+ && (allKeys || entry.keyseq == key)) {
+ d->sequences[i].enabled = enable;
+ ++itemsChanged;
+ }
+ if (id == entry.id)
+ return itemsChanged;
+ --i;
+ }
+#if defined(DEBUG_QSHORTCUTMAP)
+ qDebug().nospace()
+ << "QShortcutMap::setShortcutEnabled(" << enable << ", " << id << ", "
+ << owner << ", " << key << ") = " << itemsChanged;
+#endif
+ return itemsChanged;
+}
+
+/*! \internal
+ Changes the auto repeat state of a shortcut to \a enable.
+ If \a owner is 0, all entries in the map with the key sequence specified
+ is removed. If \a key is null, all sequences for \a owner is removed from
+ the map. If \a id is 0, any identical \a key sequences owned by \a owner
+ are changed.
+ Returns the number of sequences which are matched in the map.
+*/
+int QShortcutMap::setShortcutAutoRepeat(bool on, int id, QObject *owner, const QKeySequence &key)
+{
+ Q_D(QShortcutMap);
+ int itemsChanged = 0;
+ bool allOwners = (owner == 0);
+ bool allKeys = key.isEmpty();
+ bool allIds = id == 0;
+
+ int i = d->sequences.size()-1;
+ while (i>=0)
+ {
+ QShortcutEntry entry = d->sequences.at(i);
+ if ((allOwners || entry.owner == owner)
+ && (allIds || entry.id == id)
+ && (allKeys || entry.keyseq == key)) {
+ d->sequences[i].autorepeat = on;
+ ++itemsChanged;
+ }
+ if (id == entry.id)
+ return itemsChanged;
+ --i;
+ }
+#if defined(DEBUG_QSHORTCUTMAP)
+ qDebug().nospace()
+ << "QShortcutMap::setShortcutAutoRepeat(" << on << ", " << id << ", "
+ << owner << ", " << key << ") = " << itemsChanged;
+#endif
+ return itemsChanged;
+}
+
+/*! \internal
+ Resets the state of the statemachine to NoMatch
+*/
+void QShortcutMap::resetState()
+{
+ Q_D(QShortcutMap);
+ d->currentState = QKeySequence::NoMatch;
+ clearSequence(d->currentSequences);
+}
+
+/*! \internal
+ Returns the current state of the statemachine
+*/
+QKeySequence::SequenceMatch QShortcutMap::state()
+{
+ Q_D(QShortcutMap);
+ return d->currentState;
+}
+
+/*! \internal
+ Uses ShortcutOverride event to see if any widgets want to override
+ the event. If not, uses nextState(QKeyEvent) to check for a grabbed
+ Shortcut, and dispatchEvent() is found an identical.
+ \sa nextState dispatchEvent
+*/
+bool QShortcutMap::tryShortcutEvent(QObject *o, QKeyEvent *e)
+{
+ Q_D(QShortcutMap);
+
+ bool wasAccepted = e->isAccepted();
+ bool wasSpontaneous = e->spont;
+ if (d->currentState == QKeySequence::NoMatch) {
+ ushort orgType = e->t;
+ e->t = QEvent::ShortcutOverride;
+ e->ignore();
+ QCoreApplication::sendEvent(o, e);
+ e->t = orgType;
+ e->spont = wasSpontaneous;
+ if (e->isAccepted()) {
+ if (!wasAccepted)
+ e->ignore();
+ return false;
+ }
+ }
+
+ QKeySequence::SequenceMatch result = nextState(e);
+ bool stateWasAccepted = e->isAccepted();
+ if (wasAccepted)
+ e->accept();
+ else
+ e->ignore();
+
+ int identicalMatches = d->identicals.count();
+
+ switch(result) {
+ case QKeySequence::NoMatch:
+ return stateWasAccepted;
+ case QKeySequence::ExactMatch:
+ resetState();
+ dispatchEvent(e);
+ default:
+ break;
+ }
+ // If nextState is QKeySequence::ExactMatch && identicals.count == 0
+ // we've only found disabled shortcuts
+ return identicalMatches > 0 || result == QKeySequence::PartialMatch;
+}
+
+/*! \internal
+ Returns the next state of the statemachine
+ If return value is SequenceMatch::ExactMatch, then a call to matches()
+ will return a QObjects* list of all matching objects for the last matching
+ sequence.
+*/
+QKeySequence::SequenceMatch QShortcutMap::nextState(QKeyEvent *e)
+{
+ Q_D(QShortcutMap);
+ // Modifiers can NOT be shortcuts...
+ if (e->key() >= Qt::Key_Shift &&
+ e->key() <= Qt::Key_Alt)
+ return d->currentState;
+
+ QKeySequence::SequenceMatch result = QKeySequence::NoMatch;
+
+ // We start fresh each time..
+ d->identicals.resize(0);
+
+ result = find(e);
+ if (result == QKeySequence::NoMatch && e->modifiers() & Qt::ShiftModifier) {
+ // If Shift + Key_Backtab, also try Shift + Qt::Key_Tab
+ if (e->key() == Qt::Key_Backtab) {
+ QKeyEvent pe = QKeyEvent(e->type(), Qt::Key_Tab, e->modifiers(), e->text());
+ result = find(&pe);
+ }
+ }
+
+ // Should we eat this key press?
+ if (d->currentState == QKeySequence::PartialMatch
+ || (d->currentState == QKeySequence::ExactMatch && d->identicals.count()))
+ e->accept();
+ // Does the new state require us to clean up?
+ if (result == QKeySequence::NoMatch)
+ clearSequence(d->currentSequences);
+ d->currentState = result;
+
+#if defined(DEBUG_QSHORTCUTMAP)
+ qDebug().nospace() << "QShortcutMap::nextState(" << e << ") = " << result;
+#endif
+ return result;
+}
+
+
+/*! \internal
+ Determines if an enabled shortcut has a matcing key sequence.
+*/
+bool QShortcutMap::hasShortcutForKeySequence(const QKeySequence &seq) const
+{
+ Q_D(const QShortcutMap);
+ QShortcutEntry entry(seq); // needed for searching
+ QList<QShortcutEntry>::ConstIterator itEnd = d->sequences.constEnd();
+ QList<QShortcutEntry>::ConstIterator it = qLowerBound(d->sequences.constBegin(), itEnd, entry);
+
+ for (;it != itEnd; ++it) {
+ if (matches(entry.keyseq, (*it).keyseq) == QKeySequence::ExactMatch && correctContext(*it) && (*it).enabled) {
+ return true;
+ }
+ }
+
+ //end of the loop: we didn't find anything
+ return false;
+}
+
+/*! \internal
+ Returns the next state of the statemachine, based
+ on the new key event \a e.
+ Matches are appended to the vector of identicals,
+ which can be access through matches().
+ \sa matches
+*/
+QKeySequence::SequenceMatch QShortcutMap::find(QKeyEvent *e)
+{
+ Q_D(QShortcutMap);
+ if (!d->sequences.count())
+ return QKeySequence::NoMatch;
+
+ createNewSequences(e, d->newEntries);
+#if defined(DEBUG_QSHORTCUTMAP)
+ qDebug() << "Possible shortcut key sequences:" << d->newEntries;
+#endif
+
+ // Should never happen
+ if (d->newEntries == d->currentSequences) {
+ Q_ASSERT_X(e->key() != Qt::Key_unknown || e->text().length(),
+ "QShortcutMap::find", "New sequence to find identical to previous");
+ return QKeySequence::NoMatch;
+ }
+
+ // Looking for new identicals, scrap old
+ d->identicals.resize(0);
+
+ bool partialFound = false;
+ bool identicalDisabledFound = false;
+ QVector<QKeySequence> okEntries;
+ int result = QKeySequence::NoMatch;
+ for (int i = d->newEntries.count()-1; i >= 0 ; --i) {
+ QShortcutEntry entry(d->newEntries.at(i)); // needed for searching
+ QList<QShortcutEntry>::ConstIterator itEnd = d->sequences.constEnd();
+ QList<QShortcutEntry>::ConstIterator it =
+ qLowerBound(d->sequences.constBegin(), itEnd, entry);
+
+ int oneKSResult = QKeySequence::NoMatch;
+ int tempRes = QKeySequence::NoMatch;
+ do {
+ if (it == itEnd)
+ break;
+ tempRes = matches(entry.keyseq, (*it).keyseq);
+ oneKSResult = qMax(oneKSResult, tempRes);
+ if (tempRes != QKeySequence::NoMatch && correctContext(*it)) {
+ if (tempRes == QKeySequence::ExactMatch) {
+ if ((*it).enabled)
+ d->identicals.append(&*it);
+ else
+ identicalDisabledFound = true;
+ } else if (tempRes == QKeySequence::PartialMatch) {
+ // We don't need partials, if we have identicals
+ if (d->identicals.size())
+ break;
+ // We only care about enabled partials, so we don't consume
+ // key events when all partials are disabled!
+ partialFound |= (*it).enabled;
+ }
+ }
+ ++it;
+ // If we got a valid match on this run, there might still be more keys to check against,
+ // so we'll loop once more. If we get NoMatch, there's guaranteed no more possible
+ // matches in the shortcutmap.
+ } while (tempRes != QKeySequence::NoMatch);
+
+ // If the type of match improves (ergo, NoMatch->Partial, or Partial->Exact), clear the
+ // previous list. If this match is equal or better than the last match, append to the list
+ if (oneKSResult > result) {
+ okEntries.clear();
+#if defined(DEBUG_QSHORTCUTMAP)
+ qDebug() << "Found better match (" << d->newEntries << "), clearing key sequence list";
+#endif
+ }
+ if (oneKSResult && oneKSResult >= result) {
+ okEntries << d->newEntries.at(i);
+#if defined(DEBUG_QSHORTCUTMAP)
+ qDebug() << "Added ok key sequence" << d->newEntries;
+#endif
+ }
+ }
+
+ if (d->identicals.size()) {
+ result = QKeySequence::ExactMatch;
+ } else if (partialFound) {
+ result = QKeySequence::PartialMatch;
+ } else if (identicalDisabledFound) {
+ result = QKeySequence::ExactMatch;
+ } else {
+ clearSequence(d->currentSequences);
+ result = QKeySequence::NoMatch;
+ }
+ if (result != QKeySequence::NoMatch)
+ d->currentSequences = okEntries;
+#if defined(DEBUG_QSHORTCUTMAP)
+ qDebug() << "Returning shortcut match == " << result;
+#endif
+ return QKeySequence::SequenceMatch(result);
+}
+
+/*! \internal
+ Clears \a seq to an empty QKeySequence.
+ Same as doing (the slower)
+ \snippet doc/src/snippets/code/src_gui_kernel_qshortcutmap.cpp 0
+*/
+void QShortcutMap::clearSequence(QVector<QKeySequence> &ksl)
+{
+ ksl.clear();
+ d_func()->newEntries.clear();
+}
+
+/*! \internal
+ Alters \a seq to the new sequence state, based on the
+ current sequence state, and the new key event \a e.
+*/
+void QShortcutMap::createNewSequences(QKeyEvent *e, QVector<QKeySequence> &ksl)
+{
+ Q_D(QShortcutMap);
+ QList<int> possibleKeys = QKeyMapper::possibleKeys(e);
+ int pkTotal = possibleKeys.count();
+ if (!pkTotal)
+ return;
+
+ int ssActual = d->currentSequences.count();
+ int ssTotal = qMax(1, ssActual);
+ // Resize to possible permutations of the current sequence(s).
+ ksl.resize(pkTotal * ssTotal);
+
+ int index = ssActual ? d->currentSequences.at(0).count() : 0;
+ for (int pkNum = 0; pkNum < pkTotal; ++pkNum) {
+ for (int ssNum = 0; ssNum < ssTotal; ++ssNum) {
+ int i = (pkNum * ssTotal) + ssNum;
+ QKeySequence &curKsl = ksl[i];
+ if (ssActual) {
+ const QKeySequence &curSeq = d->currentSequences.at(ssNum);
+ curKsl.setKey(curSeq[0], 0);
+ curKsl.setKey(curSeq[1], 1);
+ curKsl.setKey(curSeq[2], 2);
+ curKsl.setKey(curSeq[3], 3);
+ } else {
+ curKsl.setKey(0, 0);
+ curKsl.setKey(0, 1);
+ curKsl.setKey(0, 2);
+ curKsl.setKey(0, 3);
+ }
+ // Filtering keycode here with 0xdfffffff to ignore the Keypad modifier
+ curKsl.setKey(possibleKeys.at(pkNum) & 0xdfffffff, index);
+ }
+ }
+}
+
+/*! \internal
+ Basically the same function as QKeySequence::matches(const QKeySequence &seq) const
+ only that is specially handles Key_hyphen as Key_Minus, as people mix these up all the time and
+ they conceptually the same.
+*/
+QKeySequence::SequenceMatch QShortcutMap::matches(const QKeySequence &seq1,
+ const QKeySequence &seq2) const
+{
+ uint userN = seq1.count(),
+ seqN = seq2.count();
+
+ if (userN > seqN)
+ return QKeySequence::NoMatch;
+
+ // If equal in length, we have a potential ExactMatch sequence,
+ // else we already know it can only be partial.
+ QKeySequence::SequenceMatch match = (userN == seqN
+ ? QKeySequence::ExactMatch
+ : QKeySequence::PartialMatch);
+
+ for (uint i = 0; i < userN; ++i) {
+ int userKey = seq1[i],
+ sequenceKey = seq2[i];
+ if ((userKey & Qt::Key_unknown) == Qt::Key_hyphen)
+ userKey = (userKey & Qt::KeyboardModifierMask) | Qt::Key_Minus;
+ if ((sequenceKey & Qt::Key_unknown) == Qt::Key_hyphen)
+ sequenceKey = (sequenceKey & Qt::KeyboardModifierMask) | Qt::Key_Minus;
+ if (userKey != sequenceKey)
+ return QKeySequence::NoMatch;
+ }
+ return match;
+}
+
+/*! \internal
+ Returns true if the widget \a w is a logical sub window of the current
+ top-level widget.
+*/
+bool QShortcutMap::correctContext(const QShortcutEntry &item) const {
+ Q_ASSERT_X(item.owner, "QShortcutMap", "Shortcut has no owner. Illegal map state!");
+
+ QWidget *active_window = QApplication::activeWindow();
+
+ // popups do not become the active window,
+ // so we fake it here to get the correct context
+ // for the shortcut system.
+ if (QApplication::activePopupWidget())
+ active_window = QApplication::activePopupWidget();
+
+ if (!active_window)
+ return false;
+#ifndef QT_NO_ACTION
+ if (QAction *a = qobject_cast<QAction *>(item.owner))
+ return correctContext(item.context, a, active_window);
+#endif
+#ifndef QT_NO_GRAPHICSVIEW
+ if (QGraphicsWidget *gw = qobject_cast<QGraphicsWidget *>(item.owner))
+ return correctGraphicsWidgetContext(item.context, gw, active_window);
+#endif
+ QWidget *w = qobject_cast<QWidget *>(item.owner);
+ if (!w) {
+ QShortcut *s = qobject_cast<QShortcut *>(item.owner);
+ w = s->parentWidget();
+ }
+ return correctWidgetContext(item.context, w, active_window);
+}
+
+bool QShortcutMap::correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidget *active_window) const
+{
+ bool visible = w->isVisible();
+#ifdef Q_WS_MAC
+ if (!qApp->testAttribute(Qt::AA_DontUseNativeMenuBar) && qobject_cast<QMenuBar *>(w))
+ visible = true;
+#endif
+
+ if (!visible || !w->isEnabled())
+ return false;
+
+ if (context == Qt::ApplicationShortcut)
+ return QApplicationPrivate::tryModalHelper(w, 0); // true, unless w is shadowed by a modal dialog
+
+ if (context == Qt::WidgetShortcut)
+ return w == QApplication::focusWidget();
+
+ if (context == Qt::WidgetWithChildrenShortcut) {
+ const QWidget *tw = QApplication::focusWidget();
+ while (tw && tw != w && (tw->windowType() == Qt::Widget || tw->windowType() == Qt::Popup))
+ tw = tw->parentWidget();
+ return tw == w;
+ }
+
+ // Below is Qt::WindowShortcut context
+ QWidget *tlw = w->window();
+#ifndef QT_NO_GRAPHICSVIEW
+ if (QWExtra *topData = tlw->d_func()->extra) {
+ if (topData->proxyWidget) {
+ bool res = correctGraphicsWidgetContext(context, (QGraphicsWidget *)topData->proxyWidget, active_window);
+ return res;
+ }
+ }
+#endif
+
+ /* if a floating tool window is active, keep shortcuts on the
+ * parent working */
+ if (active_window != tlw && active_window && active_window->windowType() == Qt::Tool && active_window->parentWidget()) {
+ active_window = active_window->parentWidget()->window();
+ }
+
+ if (active_window != tlw)
+ return false;
+
+ /* if we live in a MDI subwindow, ignore the event if we are
+ not the active document window */
+ const QWidget* sw = w;
+ while (sw && !(sw->windowType() == Qt::SubWindow) && !sw->isWindow())
+ sw = sw->parentWidget();
+ if (sw && (sw->windowType() == Qt::SubWindow)) {
+ QWidget *focus_widget = QApplication::focusWidget();
+ while (focus_widget && focus_widget != sw)
+ focus_widget = focus_widget->parentWidget();
+ return sw == focus_widget;
+ }
+
+#if defined(DEBUG_QSHORTCUTMAP)
+ qDebug().nospace() << "..true [Pass-through]";
+#endif
+ return true;
+}
+
+#ifndef QT_NO_GRAPHICSVIEW
+bool QShortcutMap::correctGraphicsWidgetContext(Qt::ShortcutContext context, QGraphicsWidget *w, QWidget *active_window) const
+{
+ bool visible = w->isVisible();
+#ifdef Q_WS_MAC
+ if (!qApp->testAttribute(Qt::AA_DontUseNativeMenuBar) && qobject_cast<QMenuBar *>(w))
+ visible = true;
+#endif
+
+ if (!visible || !w->isEnabled() || !w->scene())
+ return false;
+
+ if (context == Qt::ApplicationShortcut) {
+ // Applicationwide shortcuts are always reachable unless their owner
+ // is shadowed by modality. In QGV there's no modality concept, but we
+ // must still check if all views are shadowed.
+ QList<QGraphicsView *> views = w->scene()->views();
+ for (int i = 0; i < views.size(); ++i) {
+ if (QApplicationPrivate::tryModalHelper(views.at(i), 0))
+ return true;
+ }
+ return false;
+ }
+
+ if (context == Qt::WidgetShortcut)
+ return static_cast<QGraphicsItem *>(w) == w->scene()->focusItem();
+
+ if (context == Qt::WidgetWithChildrenShortcut) {
+ const QGraphicsItem *ti = w->scene()->focusItem();
+ if (ti && ti->isWidget()) {
+ const QGraphicsWidget *tw = static_cast<const QGraphicsWidget *>(ti);
+ while (tw && tw != w && (tw->windowType() == Qt::Widget || tw->windowType() == Qt::Popup))
+ tw = tw->parentWidget();
+ return tw == w;
+ }
+ return false;
+ }
+
+ // Below is Qt::WindowShortcut context
+
+ // Find the active view (if any).
+ QList<QGraphicsView *> views = w->scene()->views();
+ QGraphicsView *activeView = 0;
+ for (int i = 0; i < views.size(); ++i) {
+ QGraphicsView *view = views.at(i);
+ if (view->window() == active_window) {
+ activeView = view;
+ break;
+ }
+ }
+ if (!activeView)
+ return false;
+
+ // The shortcut is reachable if owned by a windowless widget, or if the
+ // widget's window is the same as the focus item's window.
+ QGraphicsWidget *a = w->scene()->activeWindow();
+ return !w->window() || a == w->window();
+}
+#endif
+
+#ifndef QT_NO_ACTION
+bool QShortcutMap::correctContext(Qt::ShortcutContext context, QAction *a, QWidget *active_window) const
+{
+ const QList<QWidget *> &widgets = a->d_func()->widgets;
+#if defined(DEBUG_QSHORTCUTMAP)
+ if (widgets.isEmpty())
+ qDebug() << a << "not connected to any widgets; won't trigger";
+#endif
+ for (int i = 0; i < widgets.size(); ++i) {
+ QWidget *w = widgets.at(i);
+#ifndef QT_NO_MENU
+ if (QMenu *menu = qobject_cast<QMenu *>(w)) {
+ QAction *a = menu->menuAction();
+ if (correctContext(context, a, active_window))
+ return true;
+ } else
+#endif
+ if (correctWidgetContext(context, w, active_window))
+ return true;
+ }
+
+#ifndef QT_NO_GRAPHICSVIEW
+ const QList<QGraphicsWidget *> &graphicsWidgets = a->d_func()->graphicsWidgets;
+#if defined(DEBUG_QSHORTCUTMAP)
+ if (graphicsWidgets.isEmpty())
+ qDebug() << a << "not connected to any widgets; won't trigger";
+#endif
+ for (int i = 0; i < graphicsWidgets.size(); ++i) {
+ QGraphicsWidget *w = graphicsWidgets.at(i);
+ if (correctGraphicsWidgetContext(context, w, active_window))
+ return true;
+ }
+#endif
+ return false;
+}
+#endif // QT_NO_ACTION
+
+/*! \internal
+ Converts keyboard button states into modifier states
+*/
+int QShortcutMap::translateModifiers(Qt::KeyboardModifiers modifiers)
+{
+ int result = 0;
+ if (modifiers & Qt::ShiftModifier)
+ result |= Qt::SHIFT;
+ if (modifiers & Qt::ControlModifier)
+ result |= Qt::CTRL;
+ if (modifiers & Qt::MetaModifier)
+ result |= Qt::META;
+ if (modifiers & Qt::AltModifier)
+ result |= Qt::ALT;
+ return result;
+}
+
+/*! \internal
+ Returns the vector of QShortcutEntry's matching the last Identical state.
+*/
+QVector<const QShortcutEntry*> QShortcutMap::matches() const
+{
+ Q_D(const QShortcutMap);
+ return d->identicals;
+}
+
+/*! \internal
+ Dispatches QShortcutEvents to widgets who grabbed the matched key sequence.
+*/
+void QShortcutMap::dispatchEvent(QKeyEvent *e)
+{
+ Q_D(QShortcutMap);
+ if (!d->identicals.size())
+ return;
+
+ const QKeySequence &curKey = d->identicals.at(0)->keyseq;
+ if (d->prevSequence != curKey) {
+ d->ambigCount = 0;
+ d->prevSequence = curKey;
+ }
+ // Find next
+ const QShortcutEntry *current = 0, *next = 0;
+ int i = 0, enabledShortcuts = 0;
+ while(i < d->identicals.size()) {
+ current = d->identicals.at(i);
+ if (current->enabled || !next){
+ ++enabledShortcuts;
+ if (enabledShortcuts > d->ambigCount + 1)
+ break;
+ next = current;
+ }
+ ++i;
+ }
+ d->ambigCount = (d->identicals.size() == i ? 0 : d->ambigCount + 1);
+ // Don't trigger shortcut if we're autorepeating and the shortcut is
+ // grabbed with not accepting autorepeats.
+ if (!next || (e->isAutoRepeat() && !next->autorepeat))
+ return;
+ // Dispatch next enabled
+#if defined(DEBUG_QSHORTCUTMAP)
+ qDebug().nospace()
+ << "QShortcutMap::dispatchEvent(): Sending QShortcutEvent(\""
+ << (QString)next->keyseq << "\", " << next->id << ", "
+ << (bool)(enabledShortcuts>1) << ") to object(" << next->owner << ')';
+#endif
+ QShortcutEvent se(next->keyseq, next->id, enabledShortcuts>1);
+ QCoreApplication::sendEvent(const_cast<QObject *>(next->owner), &se);
+}
+
+/* \internal
+ QShortcutMap dump function, only available when DEBUG_QSHORTCUTMAP is
+ defined.
+*/
+#if defined(Dump_QShortcutMap)
+void QShortcutMap::dumpMap() const
+{
+ Q_D(const QShortcutMap);
+ for (int i = 0; i < d->sequences.size(); ++i)
+ qDebug().nospace() << &(d->sequences.at(i));
+}
+#endif
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_SHORTCUT
diff --git a/src/gui/kernel/qshortcutmap_p.h b/src/widgets/to_be_moved/qshortcutmap_p.h
index bc530b00b4..bc530b00b4 100644
--- a/src/gui/kernel/qshortcutmap_p.h
+++ b/src/widgets/to_be_moved/qshortcutmap_p.h
diff --git a/src/widgets/to_be_moved/qtextcontrol.cpp b/src/widgets/to_be_moved/qtextcontrol.cpp
new file mode 100644
index 0000000000..85bb6625eb
--- /dev/null
+++ b/src/widgets/to_be_moved/qtextcontrol.cpp
@@ -0,0 +1,3148 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qtextcontrol_p.h"
+#include "qtextcontrol_p_p.h"
+
+#ifndef QT_NO_TEXTCONTROL
+
+#include <qfont.h>
+#include <qpainter.h>
+#include <qevent.h>
+#include <qdebug.h>
+#include <qmime.h>
+#include <qdrag.h>
+#include <qclipboard.h>
+#include <qmenu.h>
+#include <qstyle.h>
+#include <qtimer.h>
+#include "private/qtextdocumentlayout_p.h"
+#include "private/qabstracttextdocumentlayout_p.h"
+#include "private/qtextedit_p.h"
+#include "qtextdocument.h"
+#include "private/qtextdocument_p.h"
+#include "qtextlist.h"
+#include "private/qtextcontrol_p.h"
+#include "qgraphicssceneevent.h"
+#include "qprinter.h"
+#include "qtextdocumentwriter.h"
+#include "private/qtextcursor_p.h"
+
+#include <qtextformat.h>
+#include <qdatetime.h>
+#include <qbuffer.h>
+#include <qapplication.h>
+#include <limits.h>
+#include <qtexttable.h>
+#include <qvariant.h>
+#include <qurl.h>
+#include <qdesktopservices.h>
+#include <qinputcontext.h>
+#include <qtooltip.h>
+#include <qstyleoption.h>
+#include <QtWidgets/qlineedit.h>
+
+#ifndef QT_NO_SHORTCUT
+#include "private/qapplication_p.h"
+#include "private/qshortcutmap_p.h"
+#include <qkeysequence.h>
+#define ACCEL_KEY(k) (!qApp->d_func()->shortcutMap.hasShortcutForKeySequence(k) ? QLatin1Char('\t') + QString(QKeySequence(k)) : QString())
+#else
+#define ACCEL_KEY(k) QString()
+#endif
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_CONTEXTMENU
+#if defined(Q_WS_WIN) || defined(Q_WS_X11)
+extern bool qt_use_rtl_extensions;
+#endif
+#endif
+
+// could go into QTextCursor...
+static QTextLine currentTextLine(const QTextCursor &cursor)
+{
+ const QTextBlock block = cursor.block();
+ if (!block.isValid())
+ return QTextLine();
+
+ const QTextLayout *layout = block.layout();
+ if (!layout)
+ return QTextLine();
+
+ const int relativePos = cursor.position() - block.position();
+ return layout->lineForTextPosition(relativePos);
+}
+
+QTextControlPrivate::QTextControlPrivate()
+ : doc(0), cursorOn(false), cursorIsFocusIndicator(false),
+ interactionFlags(Qt::TextEditorInteraction),
+ dragEnabled(true),
+#ifndef QT_NO_DRAGANDDROP
+ mousePressed(false), mightStartDrag(false),
+#endif
+ lastSelectionState(false), ignoreAutomaticScrollbarAdjustement(false),
+ overwriteMode(false),
+ acceptRichText(true),
+ preeditCursor(0), hideCursor(false),
+ hasFocus(false),
+#ifdef QT_KEYPAD_NAVIGATION
+ hasEditFocus(false),
+#endif
+ isEnabled(true),
+ hadSelectionOnMousePress(false),
+ ignoreUnusedNavigationEvents(false),
+ openExternalLinks(false),
+ wordSelectionEnabled(false)
+{}
+
+bool QTextControlPrivate::cursorMoveKeyEvent(QKeyEvent *e)
+{
+#ifdef QT_NO_SHORTCUT
+ Q_UNUSED(e);
+#endif
+
+ Q_Q(QTextControl);
+ if (cursor.isNull())
+ return false;
+
+ const QTextCursor oldSelection = cursor;
+ const int oldCursorPos = cursor.position();
+
+ QTextCursor::MoveMode mode = QTextCursor::MoveAnchor;
+ QTextCursor::MoveOperation op = QTextCursor::NoMove;
+
+ if (false) {
+ }
+#ifndef QT_NO_SHORTCUT
+ if (e == QKeySequence::MoveToNextChar) {
+ op = QTextCursor::Right;
+ }
+ else if (e == QKeySequence::MoveToPreviousChar) {
+ op = QTextCursor::Left;
+ }
+ else if (e == QKeySequence::SelectNextChar) {
+ op = QTextCursor::Right;
+ mode = QTextCursor::KeepAnchor;
+ }
+ else if (e == QKeySequence::SelectPreviousChar) {
+ op = QTextCursor::Left;
+ mode = QTextCursor::KeepAnchor;
+ }
+ else if (e == QKeySequence::SelectNextWord) {
+ op = QTextCursor::WordRight;
+ mode = QTextCursor::KeepAnchor;
+ }
+ else if (e == QKeySequence::SelectPreviousWord) {
+ op = QTextCursor::WordLeft;
+ mode = QTextCursor::KeepAnchor;
+ }
+ else if (e == QKeySequence::SelectStartOfLine) {
+ op = QTextCursor::StartOfLine;
+ mode = QTextCursor::KeepAnchor;
+ }
+ else if (e == QKeySequence::SelectEndOfLine) {
+ op = QTextCursor::EndOfLine;
+ mode = QTextCursor::KeepAnchor;
+ }
+ else if (e == QKeySequence::SelectStartOfBlock) {
+ op = QTextCursor::StartOfBlock;
+ mode = QTextCursor::KeepAnchor;
+ }
+ else if (e == QKeySequence::SelectEndOfBlock) {
+ op = QTextCursor::EndOfBlock;
+ mode = QTextCursor::KeepAnchor;
+ }
+ else if (e == QKeySequence::SelectStartOfDocument) {
+ op = QTextCursor::Start;
+ mode = QTextCursor::KeepAnchor;
+ }
+ else if (e == QKeySequence::SelectEndOfDocument) {
+ op = QTextCursor::End;
+ mode = QTextCursor::KeepAnchor;
+ }
+ else if (e == QKeySequence::SelectPreviousLine) {
+ op = QTextCursor::Up;
+ mode = QTextCursor::KeepAnchor;
+ }
+ else if (e == QKeySequence::SelectNextLine) {
+ op = QTextCursor::Down;
+ mode = QTextCursor::KeepAnchor;
+ {
+ QTextBlock block = cursor.block();
+ QTextLine line = currentTextLine(cursor);
+ if (!block.next().isValid()
+ && line.isValid()
+ && line.lineNumber() == block.layout()->lineCount() - 1)
+ op = QTextCursor::End;
+ }
+ }
+ else if (e == QKeySequence::MoveToNextWord) {
+ op = QTextCursor::WordRight;
+ }
+ else if (e == QKeySequence::MoveToPreviousWord) {
+ op = QTextCursor::WordLeft;
+ }
+ else if (e == QKeySequence::MoveToEndOfBlock) {
+ op = QTextCursor::EndOfBlock;
+ }
+ else if (e == QKeySequence::MoveToStartOfBlock) {
+ op = QTextCursor::StartOfBlock;
+ }
+ else if (e == QKeySequence::MoveToNextLine) {
+ op = QTextCursor::Down;
+ }
+ else if (e == QKeySequence::MoveToPreviousLine) {
+ op = QTextCursor::Up;
+ }
+ else if (e == QKeySequence::MoveToPreviousLine) {
+ op = QTextCursor::Up;
+ }
+ else if (e == QKeySequence::MoveToStartOfLine) {
+ op = QTextCursor::StartOfLine;
+ }
+ else if (e == QKeySequence::MoveToEndOfLine) {
+ op = QTextCursor::EndOfLine;
+ }
+ else if (e == QKeySequence::MoveToStartOfDocument) {
+ op = QTextCursor::Start;
+ }
+ else if (e == QKeySequence::MoveToEndOfDocument) {
+ op = QTextCursor::End;
+ }
+#endif // QT_NO_SHORTCUT
+ else {
+ return false;
+ }
+
+// Except for pageup and pagedown, Mac OS X has very different behavior, we don't do it all, but
+// here's the breakdown:
+// Shift still works as an anchor, but only one of the other keys can be down Ctrl (Command),
+// Alt (Option), or Meta (Control).
+// Command/Control + Left/Right -- Move to left or right of the line
+// + Up/Down -- Move to top bottom of the file. (Control doesn't move the cursor)
+// Option + Left/Right -- Move one word Left/right.
+// + Up/Down -- Begin/End of Paragraph.
+// Home/End Top/Bottom of file. (usually don't move the cursor, but will select)
+
+ bool visualNavigation = cursor.visualNavigation();
+ cursor.setVisualNavigation(true);
+ const bool moved = cursor.movePosition(op, mode);
+ cursor.setVisualNavigation(visualNavigation);
+ q->ensureCursorVisible();
+
+ bool ignoreNavigationEvents = ignoreUnusedNavigationEvents;
+ bool isNavigationEvent = e->key() == Qt::Key_Up || e->key() == Qt::Key_Down;
+
+#ifdef QT_KEYPAD_NAVIGATION
+ ignoreNavigationEvents = ignoreNavigationEvents || QApplication::keypadNavigationEnabled();
+ isNavigationEvent = isNavigationEvent ||
+ (QApplication::navigationMode() == Qt::NavigationModeKeypadDirectional
+ && (e->key() == Qt::Key_Left || e->key() == Qt::Key_Right));
+#else
+ isNavigationEvent = isNavigationEvent || e->key() == Qt::Key_Left || e->key() == Qt::Key_Right;
+#endif
+
+ if (moved) {
+ if (cursor.position() != oldCursorPos)
+ emit q->cursorPositionChanged();
+ emit q->microFocusChanged();
+ } else if (ignoreNavigationEvents && isNavigationEvent && oldSelection.anchor() == cursor.anchor()) {
+ return false;
+ }
+
+ selectionChanged(/*forceEmitSelectionChanged =*/(mode == QTextCursor::KeepAnchor));
+
+ repaintOldAndNewSelection(oldSelection);
+
+ return true;
+}
+
+void QTextControlPrivate::updateCurrentCharFormat()
+{
+ Q_Q(QTextControl);
+
+ QTextCharFormat fmt = cursor.charFormat();
+ if (fmt == lastCharFormat)
+ return;
+ lastCharFormat = fmt;
+
+ emit q->currentCharFormatChanged(fmt);
+ emit q->microFocusChanged();
+}
+
+void QTextControlPrivate::indent()
+{
+ QTextBlockFormat blockFmt = cursor.blockFormat();
+
+ QTextList *list = cursor.currentList();
+ if (!list) {
+ QTextBlockFormat modifier;
+ modifier.setIndent(blockFmt.indent() + 1);
+ cursor.mergeBlockFormat(modifier);
+ } else {
+ QTextListFormat format = list->format();
+ format.setIndent(format.indent() + 1);
+
+ if (list->itemNumber(cursor.block()) == 1)
+ list->setFormat(format);
+ else
+ cursor.createList(format);
+ }
+}
+
+void QTextControlPrivate::outdent()
+{
+ QTextBlockFormat blockFmt = cursor.blockFormat();
+
+ QTextList *list = cursor.currentList();
+
+ if (!list) {
+ QTextBlockFormat modifier;
+ modifier.setIndent(blockFmt.indent() - 1);
+ cursor.mergeBlockFormat(modifier);
+ } else {
+ QTextListFormat listFmt = list->format();
+ listFmt.setIndent(listFmt.indent() - 1);
+ list->setFormat(listFmt);
+ }
+}
+
+void QTextControlPrivate::gotoNextTableCell()
+{
+ QTextTable *table = cursor.currentTable();
+ QTextTableCell cell = table->cellAt(cursor);
+
+ int newColumn = cell.column() + cell.columnSpan();
+ int newRow = cell.row();
+
+ if (newColumn >= table->columns()) {
+ newColumn = 0;
+ ++newRow;
+ if (newRow >= table->rows())
+ table->insertRows(table->rows(), 1);
+ }
+
+ cell = table->cellAt(newRow, newColumn);
+ cursor = cell.firstCursorPosition();
+}
+
+void QTextControlPrivate::gotoPreviousTableCell()
+{
+ QTextTable *table = cursor.currentTable();
+ QTextTableCell cell = table->cellAt(cursor);
+
+ int newColumn = cell.column() - 1;
+ int newRow = cell.row();
+
+ if (newColumn < 0) {
+ newColumn = table->columns() - 1;
+ --newRow;
+ if (newRow < 0)
+ return;
+ }
+
+ cell = table->cellAt(newRow, newColumn);
+ cursor = cell.firstCursorPosition();
+}
+
+void QTextControlPrivate::createAutoBulletList()
+{
+ cursor.beginEditBlock();
+
+ QTextBlockFormat blockFmt = cursor.blockFormat();
+
+ QTextListFormat listFmt;
+ listFmt.setStyle(QTextListFormat::ListDisc);
+ listFmt.setIndent(blockFmt.indent() + 1);
+
+ blockFmt.setIndent(0);
+ cursor.setBlockFormat(blockFmt);
+
+ cursor.createList(listFmt);
+
+ cursor.endEditBlock();
+}
+
+void QTextControlPrivate::init(Qt::TextFormat format, const QString &text, QTextDocument *document)
+{
+ Q_Q(QTextControl);
+ setContent(format, text, document);
+
+ doc->setUndoRedoEnabled(interactionFlags & Qt::TextEditable);
+ q->setCursorWidth(-1);
+}
+
+void QTextControlPrivate::setContent(Qt::TextFormat format, const QString &text, QTextDocument *document)
+{
+ Q_Q(QTextControl);
+
+ // for use when called from setPlainText. we may want to re-use the currently
+ // set char format then.
+ const QTextCharFormat charFormatForInsertion = cursor.charFormat();
+
+ bool clearDocument = true;
+ if (!doc) {
+ if (document) {
+ doc = document;
+ clearDocument = false;
+ } else {
+ palette = QApplication::palette("QTextControl");
+ doc = new QTextDocument(q);
+ }
+ _q_documentLayoutChanged();
+ cursor = QTextCursor(doc);
+
+// #### doc->documentLayout()->setPaintDevice(viewport);
+
+ QObject::connect(doc, SIGNAL(contentsChanged()), q, SLOT(_q_updateCurrentCharFormatAndSelection()));
+ QObject::connect(doc, SIGNAL(cursorPositionChanged(QTextCursor)), q, SLOT(_q_emitCursorPosChanged(QTextCursor)));
+ QObject::connect(doc, SIGNAL(documentLayoutChanged()), q, SLOT(_q_documentLayoutChanged()));
+
+ // convenience signal forwards
+ QObject::connect(doc, SIGNAL(undoAvailable(bool)), q, SIGNAL(undoAvailable(bool)));
+ QObject::connect(doc, SIGNAL(redoAvailable(bool)), q, SIGNAL(redoAvailable(bool)));
+ QObject::connect(doc, SIGNAL(modificationChanged(bool)), q, SIGNAL(modificationChanged(bool)));
+ QObject::connect(doc, SIGNAL(blockCountChanged(int)), q, SIGNAL(blockCountChanged(int)));
+ }
+
+ bool previousUndoRedoState = doc->isUndoRedoEnabled();
+ if (!document)
+ doc->setUndoRedoEnabled(false);
+
+ //Saving the index save some time.
+ static int contentsChangedIndex = QTextDocument::staticMetaObject.indexOfSignal("contentsChanged()");
+ static int textChangedIndex = QTextControl::staticMetaObject.indexOfSignal("textChanged()");
+ // avoid multiple textChanged() signals being emitted
+ QMetaObject::disconnect(doc, contentsChangedIndex, q, textChangedIndex);
+
+ if (!text.isEmpty()) {
+ // clear 'our' cursor for insertion to prevent
+ // the emission of the cursorPositionChanged() signal.
+ // instead we emit it only once at the end instead of
+ // at the end of the document after loading and when
+ // positioning the cursor again to the start of the
+ // document.
+ cursor = QTextCursor();
+ if (format == Qt::PlainText) {
+ QTextCursor formatCursor(doc);
+ // put the setPlainText and the setCharFormat into one edit block,
+ // so that the syntax highlight triggers only /once/ for the entire
+ // document, not twice.
+ formatCursor.beginEditBlock();
+ doc->setPlainText(text);
+ doc->setUndoRedoEnabled(false);
+ formatCursor.select(QTextCursor::Document);
+ formatCursor.setCharFormat(charFormatForInsertion);
+ formatCursor.endEditBlock();
+ } else {
+#ifndef QT_NO_TEXTHTMLPARSER
+ doc->setHtml(text);
+#else
+ doc->setPlainText(text);
+#endif
+ doc->setUndoRedoEnabled(false);
+ }
+ cursor = QTextCursor(doc);
+ } else if (clearDocument) {
+ doc->clear();
+ }
+ cursor.setCharFormat(charFormatForInsertion);
+
+ QMetaObject::connect(doc, contentsChangedIndex, q, textChangedIndex);
+ emit q->textChanged();
+ if (!document)
+ doc->setUndoRedoEnabled(previousUndoRedoState);
+ _q_updateCurrentCharFormatAndSelection();
+ if (!document)
+ doc->setModified(false);
+
+ q->ensureCursorVisible();
+ emit q->cursorPositionChanged();
+}
+
+void QTextControlPrivate::startDrag()
+{
+#ifndef QT_NO_DRAGANDDROP
+ Q_Q(QTextControl);
+ mousePressed = false;
+ if (!contextWidget)
+ return;
+ QMimeData *data = q->createMimeDataFromSelection();
+
+ QDrag *drag = new QDrag(contextWidget);
+ drag->setMimeData(data);
+
+ Qt::DropActions actions = Qt::CopyAction;
+ Qt::DropAction action;
+ if (interactionFlags & Qt::TextEditable) {
+ actions |= Qt::MoveAction;
+ action = drag->exec(actions, Qt::MoveAction);
+ } else {
+ action = drag->exec(actions, Qt::CopyAction);
+ }
+
+ if (action == Qt::MoveAction && drag->target() != contextWidget)
+ cursor.removeSelectedText();
+#endif
+}
+
+void QTextControlPrivate::setCursorPosition(const QPointF &pos)
+{
+ Q_Q(QTextControl);
+ const int cursorPos = q->hitTest(pos, Qt::FuzzyHit);
+ if (cursorPos == -1)
+ return;
+ cursor.setPosition(cursorPos);
+}
+
+void QTextControlPrivate::setCursorPosition(int pos, QTextCursor::MoveMode mode)
+{
+ cursor.setPosition(pos, mode);
+
+ if (mode != QTextCursor::KeepAnchor) {
+ selectedWordOnDoubleClick = QTextCursor();
+ selectedBlockOnTrippleClick = QTextCursor();
+ }
+}
+
+void QTextControlPrivate::repaintCursor()
+{
+ Q_Q(QTextControl);
+ emit q->updateRequest(cursorRectPlusUnicodeDirectionMarkers(cursor));
+}
+
+void QTextControlPrivate::repaintOldAndNewSelection(const QTextCursor &oldSelection)
+{
+ Q_Q(QTextControl);
+ if (cursor.hasSelection()
+ && oldSelection.hasSelection()
+ && cursor.currentFrame() == oldSelection.currentFrame()
+ && !cursor.hasComplexSelection()
+ && !oldSelection.hasComplexSelection()
+ && cursor.anchor() == oldSelection.anchor()
+ ) {
+ QTextCursor differenceSelection(doc);
+ differenceSelection.setPosition(oldSelection.position());
+ differenceSelection.setPosition(cursor.position(), QTextCursor::KeepAnchor);
+ emit q->updateRequest(q->selectionRect(differenceSelection));
+ } else {
+ if (!oldSelection.isNull())
+ emit q->updateRequest(q->selectionRect(oldSelection) | cursorRectPlusUnicodeDirectionMarkers(oldSelection));
+ emit q->updateRequest(q->selectionRect() | cursorRectPlusUnicodeDirectionMarkers(cursor));
+ }
+}
+
+void QTextControlPrivate::selectionChanged(bool forceEmitSelectionChanged /*=false*/)
+{
+ Q_Q(QTextControl);
+ if (forceEmitSelectionChanged)
+ emit q->selectionChanged();
+
+ bool current = cursor.hasSelection();
+ if (current == lastSelectionState)
+ return;
+
+ lastSelectionState = current;
+ emit q->copyAvailable(current);
+ if (!forceEmitSelectionChanged)
+ emit q->selectionChanged();
+ emit q->microFocusChanged();
+}
+
+void QTextControlPrivate::_q_updateCurrentCharFormatAndSelection()
+{
+ updateCurrentCharFormat();
+ selectionChanged();
+}
+
+#ifndef QT_NO_CLIPBOARD
+void QTextControlPrivate::setClipboardSelection()
+{
+ QClipboard *clipboard = QApplication::clipboard();
+ if (!cursor.hasSelection() || !clipboard->supportsSelection())
+ return;
+ Q_Q(QTextControl);
+ QMimeData *data = q->createMimeDataFromSelection();
+ clipboard->setMimeData(data, QClipboard::Selection);
+}
+#endif
+
+void QTextControlPrivate::_q_emitCursorPosChanged(const QTextCursor &someCursor)
+{
+ Q_Q(QTextControl);
+ if (someCursor.isCopyOf(cursor)) {
+ emit q->cursorPositionChanged();
+ emit q->microFocusChanged();
+ }
+}
+
+void QTextControlPrivate::_q_documentLayoutChanged()
+{
+ Q_Q(QTextControl);
+ QAbstractTextDocumentLayout *layout = doc->documentLayout();
+ QObject::connect(layout, SIGNAL(update(QRectF)), q, SIGNAL(updateRequest(QRectF)));
+ QObject::connect(layout, SIGNAL(updateBlock(QTextBlock)), q, SLOT(_q_updateBlock(QTextBlock)));
+ QObject::connect(layout, SIGNAL(documentSizeChanged(QSizeF)), q, SIGNAL(documentSizeChanged(QSizeF)));
+
+}
+
+void QTextControlPrivate::setBlinkingCursorEnabled(bool enable)
+{
+ Q_Q(QTextControl);
+
+ if (enable && QApplication::cursorFlashTime() > 0)
+ cursorBlinkTimer.start(QApplication::cursorFlashTime() / 2, q);
+ else
+ cursorBlinkTimer.stop();
+
+ cursorOn = enable;
+
+ repaintCursor();
+}
+
+void QTextControlPrivate::extendWordwiseSelection(int suggestedNewPosition, qreal mouseXPosition)
+{
+ Q_Q(QTextControl);
+
+ // if inside the initial selected word keep that
+ if (suggestedNewPosition >= selectedWordOnDoubleClick.selectionStart()
+ && suggestedNewPosition <= selectedWordOnDoubleClick.selectionEnd()) {
+ q->setTextCursor(selectedWordOnDoubleClick);
+ return;
+ }
+
+ QTextCursor curs = selectedWordOnDoubleClick;
+ curs.setPosition(suggestedNewPosition, QTextCursor::KeepAnchor);
+
+ if (!curs.movePosition(QTextCursor::StartOfWord))
+ return;
+ const int wordStartPos = curs.position();
+
+ const int blockPos = curs.block().position();
+ const QPointF blockCoordinates = q->blockBoundingRect(curs.block()).topLeft();
+
+ QTextLine line = currentTextLine(curs);
+ if (!line.isValid())
+ return;
+
+ const qreal wordStartX = line.cursorToX(curs.position() - blockPos) + blockCoordinates.x();
+
+ if (!curs.movePosition(QTextCursor::EndOfWord))
+ return;
+ const int wordEndPos = curs.position();
+
+ const QTextLine otherLine = currentTextLine(curs);
+ if (otherLine.textStart() != line.textStart()
+ || wordEndPos == wordStartPos)
+ return;
+
+ const qreal wordEndX = line.cursorToX(curs.position() - blockPos) + blockCoordinates.x();
+
+ if (mouseXPosition < wordStartX || mouseXPosition > wordEndX)
+ return;
+
+ // keep the already selected word even when moving to the left
+ // (#39164)
+ if (suggestedNewPosition < selectedWordOnDoubleClick.position())
+ cursor.setPosition(selectedWordOnDoubleClick.selectionEnd());
+ else
+ cursor.setPosition(selectedWordOnDoubleClick.selectionStart());
+
+ const qreal differenceToStart = mouseXPosition - wordStartX;
+ const qreal differenceToEnd = wordEndX - mouseXPosition;
+
+ if (differenceToStart < differenceToEnd)
+ setCursorPosition(wordStartPos, QTextCursor::KeepAnchor);
+ else
+ setCursorPosition(wordEndPos, QTextCursor::KeepAnchor);
+
+ if (interactionFlags & Qt::TextSelectableByMouse) {
+#ifndef QT_NO_CLIPBOARD
+ setClipboardSelection();
+#endif
+ selectionChanged(true);
+ }
+}
+
+void QTextControlPrivate::extendBlockwiseSelection(int suggestedNewPosition)
+{
+ Q_Q(QTextControl);
+
+ // if inside the initial selected line keep that
+ if (suggestedNewPosition >= selectedBlockOnTrippleClick.selectionStart()
+ && suggestedNewPosition <= selectedBlockOnTrippleClick.selectionEnd()) {
+ q->setTextCursor(selectedBlockOnTrippleClick);
+ return;
+ }
+
+ if (suggestedNewPosition < selectedBlockOnTrippleClick.position()) {
+ cursor.setPosition(selectedBlockOnTrippleClick.selectionEnd());
+ cursor.setPosition(suggestedNewPosition, QTextCursor::KeepAnchor);
+ cursor.movePosition(QTextCursor::StartOfBlock, QTextCursor::KeepAnchor);
+ } else {
+ cursor.setPosition(selectedBlockOnTrippleClick.selectionStart());
+ cursor.setPosition(suggestedNewPosition, QTextCursor::KeepAnchor);
+ cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
+ cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
+ }
+
+ if (interactionFlags & Qt::TextSelectableByMouse) {
+#ifndef QT_NO_CLIPBOARD
+ setClipboardSelection();
+#endif
+ selectionChanged(true);
+ }
+}
+
+void QTextControlPrivate::_q_deleteSelected()
+{
+ if (!(interactionFlags & Qt::TextEditable) || !cursor.hasSelection())
+ return;
+ cursor.removeSelectedText();
+}
+
+void QTextControl::undo()
+{
+ Q_D(QTextControl);
+ d->repaintSelection();
+ const int oldCursorPos = d->cursor.position();
+ d->doc->undo(&d->cursor);
+ if (d->cursor.position() != oldCursorPos)
+ emit cursorPositionChanged();
+ emit microFocusChanged();
+ ensureCursorVisible();
+}
+
+void QTextControl::redo()
+{
+ Q_D(QTextControl);
+ d->repaintSelection();
+ const int oldCursorPos = d->cursor.position();
+ d->doc->redo(&d->cursor);
+ if (d->cursor.position() != oldCursorPos)
+ emit cursorPositionChanged();
+ emit microFocusChanged();
+ ensureCursorVisible();
+}
+
+QTextControl::QTextControl(QObject *parent)
+ : QObject(*new QTextControlPrivate, parent)
+{
+ Q_D(QTextControl);
+ d->init();
+}
+
+QTextControl::QTextControl(const QString &text, QObject *parent)
+ : QObject(*new QTextControlPrivate, parent)
+{
+ Q_D(QTextControl);
+ d->init(Qt::RichText, text);
+}
+
+QTextControl::QTextControl(QTextDocument *doc, QObject *parent)
+ : QObject(*new QTextControlPrivate, parent)
+{
+ Q_D(QTextControl);
+ d->init(Qt::RichText, QString(), doc);
+}
+
+QTextControl::~QTextControl()
+{
+}
+
+void QTextControl::setDocument(QTextDocument *document)
+{
+ Q_D(QTextControl);
+ if (d->doc == document)
+ return;
+
+ d->doc->disconnect(this);
+ d->doc->documentLayout()->disconnect(this);
+ d->doc->documentLayout()->setPaintDevice(0);
+
+ if (d->doc->parent() == this)
+ delete d->doc;
+
+ d->doc = 0;
+ d->setContent(Qt::RichText, QString(), document);
+}
+
+QTextDocument *QTextControl::document() const
+{
+ Q_D(const QTextControl);
+ return d->doc;
+}
+
+void QTextControl::setTextCursor(const QTextCursor &cursor)
+{
+ Q_D(QTextControl);
+ d->cursorIsFocusIndicator = false;
+ const bool posChanged = cursor.position() != d->cursor.position();
+ const QTextCursor oldSelection = d->cursor;
+ d->cursor = cursor;
+ d->cursorOn = d->hasFocus && (d->interactionFlags & Qt::TextEditable);
+ d->_q_updateCurrentCharFormatAndSelection();
+ ensureCursorVisible();
+ d->repaintOldAndNewSelection(oldSelection);
+ if (posChanged)
+ emit cursorPositionChanged();
+}
+
+QTextCursor QTextControl::textCursor() const
+{
+ Q_D(const QTextControl);
+ return d->cursor;
+}
+
+#ifndef QT_NO_CLIPBOARD
+
+void QTextControl::cut()
+{
+ Q_D(QTextControl);
+ if (!(d->interactionFlags & Qt::TextEditable) || !d->cursor.hasSelection())
+ return;
+ copy();
+ d->cursor.removeSelectedText();
+}
+
+void QTextControl::copy()
+{
+ Q_D(QTextControl);
+ if (!d->cursor.hasSelection())
+ return;
+ QMimeData *data = createMimeDataFromSelection();
+ QApplication::clipboard()->setMimeData(data);
+}
+
+void QTextControl::paste(QClipboard::Mode mode)
+{
+ const QMimeData *md = QApplication::clipboard()->mimeData(mode);
+ if (md)
+ insertFromMimeData(md);
+}
+#endif
+
+void QTextControl::clear()
+{
+ Q_D(QTextControl);
+ // clears and sets empty content
+ d->extraSelections.clear();
+ d->setContent();
+}
+
+
+void QTextControl::selectAll()
+{
+ Q_D(QTextControl);
+ const int selectionLength = qAbs(d->cursor.position() - d->cursor.anchor());
+ d->cursor.select(QTextCursor::Document);
+ d->selectionChanged(selectionLength != qAbs(d->cursor.position() - d->cursor.anchor()));
+ d->cursorIsFocusIndicator = false;
+ emit updateRequest();
+}
+
+void QTextControl::processEvent(QEvent *e, const QPointF &coordinateOffset, QWidget *contextWidget)
+{
+ QMatrix m;
+ m.translate(coordinateOffset.x(), coordinateOffset.y());
+ processEvent(e, m, contextWidget);
+}
+
+void QTextControl::processEvent(QEvent *e, const QMatrix &matrix, QWidget *contextWidget)
+{
+ Q_D(QTextControl);
+ if (d->interactionFlags == Qt::NoTextInteraction) {
+ e->ignore();
+ return;
+ }
+
+ d->contextWidget = contextWidget;
+
+ if (!d->contextWidget) {
+ switch (e->type()) {
+#ifndef QT_NO_GRAPHICSVIEW
+ case QEvent::GraphicsSceneMouseMove:
+ case QEvent::GraphicsSceneMousePress:
+ case QEvent::GraphicsSceneMouseRelease:
+ case QEvent::GraphicsSceneMouseDoubleClick:
+ case QEvent::GraphicsSceneContextMenu:
+ case QEvent::GraphicsSceneHoverEnter:
+ case QEvent::GraphicsSceneHoverMove:
+ case QEvent::GraphicsSceneHoverLeave:
+ case QEvent::GraphicsSceneHelp:
+ case QEvent::GraphicsSceneDragEnter:
+ case QEvent::GraphicsSceneDragMove:
+ case QEvent::GraphicsSceneDragLeave:
+ case QEvent::GraphicsSceneDrop: {
+ QGraphicsSceneEvent *ev = static_cast<QGraphicsSceneEvent *>(e);
+ d->contextWidget = ev->widget();
+ break;
+ }
+#endif // QT_NO_GRAPHICSVIEW
+ default: break;
+ };
+ }
+
+ switch (e->type()) {
+ case QEvent::KeyPress:
+ d->keyPressEvent(static_cast<QKeyEvent *>(e));
+ break;
+ case QEvent::MouseButtonPress: {
+ QMouseEvent *ev = static_cast<QMouseEvent *>(e);
+ d->mousePressEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(),
+ ev->buttons(), ev->globalPos());
+ break; }
+ case QEvent::MouseMove: {
+ QMouseEvent *ev = static_cast<QMouseEvent *>(e);
+ d->mouseMoveEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(),
+ ev->buttons(), ev->globalPos());
+ break; }
+ case QEvent::MouseButtonRelease: {
+ QMouseEvent *ev = static_cast<QMouseEvent *>(e);
+ d->mouseReleaseEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(),
+ ev->buttons(), ev->globalPos());
+ break; }
+ case QEvent::MouseButtonDblClick: {
+ QMouseEvent *ev = static_cast<QMouseEvent *>(e);
+ d->mouseDoubleClickEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(),
+ ev->buttons(), ev->globalPos());
+ break; }
+ case QEvent::InputMethod:
+ d->inputMethodEvent(static_cast<QInputMethodEvent *>(e));
+ break;
+#ifndef QT_NO_CONTEXTMENU
+ case QEvent::ContextMenu: {
+ QContextMenuEvent *ev = static_cast<QContextMenuEvent *>(e);
+ d->contextMenuEvent(ev->globalPos(), matrix.map(ev->pos()), contextWidget);
+ break; }
+#endif // QT_NO_CONTEXTMENU
+ case QEvent::FocusIn:
+ case QEvent::FocusOut:
+ d->focusEvent(static_cast<QFocusEvent *>(e));
+ break;
+
+ case QEvent::EnabledChange:
+ d->isEnabled = e->isAccepted();
+ break;
+
+#ifndef QT_NO_TOOLTIP
+ case QEvent::ToolTip: {
+ QHelpEvent *ev = static_cast<QHelpEvent *>(e);
+ d->showToolTip(ev->globalPos(), matrix.map(ev->pos()), contextWidget);
+ break;
+ }
+#endif // QT_NO_TOOLTIP
+
+#ifndef QT_NO_DRAGANDDROP
+ case QEvent::DragEnter: {
+ QDragEnterEvent *ev = static_cast<QDragEnterEvent *>(e);
+ if (d->dragEnterEvent(e, ev->mimeData()))
+ ev->acceptProposedAction();
+ break;
+ }
+ case QEvent::DragLeave:
+ d->dragLeaveEvent();
+ break;
+ case QEvent::DragMove: {
+ QDragMoveEvent *ev = static_cast<QDragMoveEvent *>(e);
+ if (d->dragMoveEvent(e, ev->mimeData(), matrix.map(ev->pos())))
+ ev->acceptProposedAction();
+ break;
+ }
+ case QEvent::Drop: {
+ QDropEvent *ev = static_cast<QDropEvent *>(e);
+ if (d->dropEvent(ev->mimeData(), matrix.map(ev->pos()), ev->dropAction(), ev->source()))
+ ev->acceptProposedAction();
+ break;
+ }
+#endif
+
+#ifndef QT_NO_GRAPHICSVIEW
+ case QEvent::GraphicsSceneMousePress: {
+ QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e);
+ d->mousePressEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(),
+ ev->screenPos());
+ break; }
+ case QEvent::GraphicsSceneMouseMove: {
+ QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e);
+ d->mouseMoveEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(),
+ ev->screenPos());
+ break; }
+ case QEvent::GraphicsSceneMouseRelease: {
+ QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e);
+ d->mouseReleaseEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(),
+ ev->screenPos());
+ break; }
+ case QEvent::GraphicsSceneMouseDoubleClick: {
+ QGraphicsSceneMouseEvent *ev = static_cast<QGraphicsSceneMouseEvent *>(e);
+ d->mouseDoubleClickEvent(ev, ev->button(), matrix.map(ev->pos()), ev->modifiers(), ev->buttons(),
+ ev->screenPos());
+ break; }
+ case QEvent::GraphicsSceneContextMenu: {
+ QGraphicsSceneContextMenuEvent *ev = static_cast<QGraphicsSceneContextMenuEvent *>(e);
+ d->contextMenuEvent(ev->screenPos(), matrix.map(ev->pos()), contextWidget);
+ break; }
+
+ case QEvent::GraphicsSceneHoverMove: {
+ QGraphicsSceneHoverEvent *ev = static_cast<QGraphicsSceneHoverEvent *>(e);
+ d->mouseMoveEvent(ev, Qt::NoButton, matrix.map(ev->pos()), ev->modifiers(),Qt::NoButton,
+ ev->screenPos());
+ break; }
+
+ case QEvent::GraphicsSceneDragEnter: {
+ QGraphicsSceneDragDropEvent *ev = static_cast<QGraphicsSceneDragDropEvent *>(e);
+ if (d->dragEnterEvent(e, ev->mimeData()))
+ ev->acceptProposedAction();
+ break; }
+ case QEvent::GraphicsSceneDragLeave:
+ d->dragLeaveEvent();
+ break;
+ case QEvent::GraphicsSceneDragMove: {
+ QGraphicsSceneDragDropEvent *ev = static_cast<QGraphicsSceneDragDropEvent *>(e);
+ if (d->dragMoveEvent(e, ev->mimeData(), matrix.map(ev->pos())))
+ ev->acceptProposedAction();
+ break; }
+ case QEvent::GraphicsSceneDrop: {
+ QGraphicsSceneDragDropEvent *ev = static_cast<QGraphicsSceneDragDropEvent *>(e);
+ if (d->dropEvent(ev->mimeData(), matrix.map(ev->pos()), ev->dropAction(), ev->source()))
+ ev->accept();
+ break; }
+#endif // QT_NO_GRAPHICSVIEW
+#ifdef QT_KEYPAD_NAVIGATION
+ case QEvent::EnterEditFocus:
+ case QEvent::LeaveEditFocus:
+ if (QApplication::keypadNavigationEnabled())
+ d->editFocusEvent(e);
+ break;
+#endif
+ case QEvent::ShortcutOverride:
+ if (d->interactionFlags & Qt::TextEditable) {
+ QKeyEvent* ke = static_cast<QKeyEvent *>(e);
+ if (ke->modifiers() == Qt::NoModifier
+ || ke->modifiers() == Qt::ShiftModifier
+ || ke->modifiers() == Qt::KeypadModifier) {
+ if (ke->key() < Qt::Key_Escape) {
+ ke->accept();
+ } else {
+ switch (ke->key()) {
+ case Qt::Key_Return:
+ case Qt::Key_Enter:
+ case Qt::Key_Delete:
+ case Qt::Key_Home:
+ case Qt::Key_End:
+ case Qt::Key_Backspace:
+ case Qt::Key_Left:
+ case Qt::Key_Right:
+ case Qt::Key_Up:
+ case Qt::Key_Down:
+ case Qt::Key_Tab:
+ ke->accept();
+ default:
+ break;
+ }
+ }
+#ifndef QT_NO_SHORTCUT
+ } else if (ke == QKeySequence::Copy
+ || ke == QKeySequence::Paste
+ || ke == QKeySequence::Cut
+ || ke == QKeySequence::Redo
+ || ke == QKeySequence::Undo
+ || ke == QKeySequence::MoveToNextWord
+ || ke == QKeySequence::MoveToPreviousWord
+ || ke == QKeySequence::MoveToStartOfDocument
+ || ke == QKeySequence::MoveToEndOfDocument
+ || ke == QKeySequence::SelectNextWord
+ || ke == QKeySequence::SelectPreviousWord
+ || ke == QKeySequence::SelectStartOfLine
+ || ke == QKeySequence::SelectEndOfLine
+ || ke == QKeySequence::SelectStartOfBlock
+ || ke == QKeySequence::SelectEndOfBlock
+ || ke == QKeySequence::SelectStartOfDocument
+ || ke == QKeySequence::SelectEndOfDocument
+ || ke == QKeySequence::SelectAll
+ ) {
+ ke->accept();
+#endif
+ }
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+bool QTextControl::event(QEvent *e)
+{
+ return QObject::event(e);
+}
+
+void QTextControl::timerEvent(QTimerEvent *e)
+{
+ Q_D(QTextControl);
+ if (e->timerId() == d->cursorBlinkTimer.timerId()) {
+ d->cursorOn = !d->cursorOn;
+
+ if (d->cursor.hasSelection())
+ d->cursorOn &= (QApplication::style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected)
+ != 0);
+
+ d->repaintCursor();
+ } else if (e->timerId() == d->trippleClickTimer.timerId()) {
+ d->trippleClickTimer.stop();
+ }
+}
+
+void QTextControl::setPlainText(const QString &text)
+{
+ Q_D(QTextControl);
+ d->setContent(Qt::PlainText, text);
+}
+
+void QTextControl::setHtml(const QString &text)
+{
+ Q_D(QTextControl);
+ d->setContent(Qt::RichText, text);
+}
+
+void QTextControlPrivate::keyPressEvent(QKeyEvent *e)
+{
+ Q_Q(QTextControl);
+#ifndef QT_NO_SHORTCUT
+ if (e == QKeySequence::SelectAll) {
+ e->accept();
+ q->selectAll();
+ return;
+ }
+#ifndef QT_NO_CLIPBOARD
+ else if (e == QKeySequence::Copy) {
+ e->accept();
+ q->copy();
+ return;
+ }
+#endif
+#endif // QT_NO_SHORTCUT
+
+ if (interactionFlags & Qt::TextSelectableByKeyboard
+ && cursorMoveKeyEvent(e))
+ goto accept;
+
+ if (interactionFlags & Qt::LinksAccessibleByKeyboard) {
+ if ((e->key() == Qt::Key_Return
+ || e->key() == Qt::Key_Enter
+#ifdef QT_KEYPAD_NAVIGATION
+ || e->key() == Qt::Key_Select
+#endif
+ )
+ && cursor.hasSelection()) {
+
+ e->accept();
+ activateLinkUnderCursor();
+ return;
+ }
+ }
+
+ if (!(interactionFlags & Qt::TextEditable)) {
+ e->ignore();
+ return;
+ }
+
+ if (e->key() == Qt::Key_Direction_L || e->key() == Qt::Key_Direction_R) {
+ QTextBlockFormat fmt;
+ fmt.setLayoutDirection((e->key() == Qt::Key_Direction_L) ? Qt::LeftToRight : Qt::RightToLeft);
+ cursor.mergeBlockFormat(fmt);
+ goto accept;
+ }
+
+ // schedule a repaint of the region of the cursor, as when we move it we
+ // want to make sure the old cursor disappears (not noticeable when moving
+ // only a few pixels but noticeable when jumping between cells in tables for
+ // example)
+ repaintSelection();
+
+ if (e->key() == Qt::Key_Backspace && !(e->modifiers() & ~Qt::ShiftModifier)) {
+ QTextBlockFormat blockFmt = cursor.blockFormat();
+ QTextList *list = cursor.currentList();
+ if (list && cursor.atBlockStart() && !cursor.hasSelection()) {
+ list->remove(cursor.block());
+ } else if (cursor.atBlockStart() && blockFmt.indent() > 0) {
+ blockFmt.setIndent(blockFmt.indent() - 1);
+ cursor.setBlockFormat(blockFmt);
+ } else {
+ QTextCursor localCursor = cursor;
+ localCursor.deletePreviousChar();
+ }
+ goto accept;
+ }
+#ifndef QT_NO_SHORTCUT
+ else if (e == QKeySequence::InsertParagraphSeparator) {
+ cursor.insertBlock();
+ e->accept();
+ goto accept;
+ } else if (e == QKeySequence::InsertLineSeparator) {
+ cursor.insertText(QString(QChar::LineSeparator));
+ e->accept();
+ goto accept;
+ }
+#endif
+ if (false) {
+ }
+#ifndef QT_NO_SHORTCUT
+ else if (e == QKeySequence::Undo) {
+ q->undo();
+ }
+ else if (e == QKeySequence::Redo) {
+ q->redo();
+ }
+#ifndef QT_NO_CLIPBOARD
+ else if (e == QKeySequence::Cut) {
+ q->cut();
+ }
+ else if (e == QKeySequence::Paste) {
+ QClipboard::Mode mode = QClipboard::Clipboard;
+#ifdef Q_WS_X11
+ if (e->modifiers() == (Qt::CTRL | Qt::SHIFT) && e->key() == Qt::Key_Insert)
+ mode = QClipboard::Selection;
+#endif
+ q->paste(mode);
+ }
+#endif
+ else if (e == QKeySequence::Delete) {
+ QTextCursor localCursor = cursor;
+ localCursor.deleteChar();
+ }
+ else if (e == QKeySequence::DeleteEndOfWord) {
+ if (!cursor.hasSelection())
+ cursor.movePosition(QTextCursor::NextWord, QTextCursor::KeepAnchor);
+ cursor.removeSelectedText();
+ }
+ else if (e == QKeySequence::DeleteStartOfWord) {
+ if (!cursor.hasSelection())
+ cursor.movePosition(QTextCursor::PreviousWord, QTextCursor::KeepAnchor);
+ cursor.removeSelectedText();
+ }
+ else if (e == QKeySequence::DeleteEndOfLine) {
+ QTextBlock block = cursor.block();
+ if (cursor.position() == block.position() + block.length() - 2)
+ cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
+ else
+ cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
+ cursor.removeSelectedText();
+ }
+#endif // QT_NO_SHORTCUT
+ else {
+ goto process;
+ }
+ goto accept;
+
+process:
+ {
+ QString text = e->text();
+ if (!text.isEmpty() && (text.at(0).isPrint() || text.at(0) == QLatin1Char('\t'))) {
+ if (overwriteMode
+ // no need to call deleteChar() if we have a selection, insertText
+ // does it already
+ && !cursor.hasSelection()
+ && !cursor.atBlockEnd())
+ cursor.deleteChar();
+
+ cursor.insertText(text);
+ selectionChanged();
+ } else {
+ e->ignore();
+ return;
+ }
+ }
+
+ accept:
+
+ e->accept();
+ cursorOn = true;
+
+ q->ensureCursorVisible();
+
+ updateCurrentCharFormat();
+}
+
+QVariant QTextControl::loadResource(int type, const QUrl &name)
+{
+#ifdef QT_NO_TEXTEDIT
+ Q_UNUSED(type);
+ Q_UNUSED(name);
+#else
+ if (QTextEdit *textEdit = qobject_cast<QTextEdit *>(parent())) {
+ QUrl resolvedName = textEdit->d_func()->resolveUrl(name);
+ return textEdit->loadResource(type, resolvedName);
+ }
+#endif
+ return QVariant();
+}
+
+void QTextControlPrivate::_q_updateBlock(const QTextBlock &block)
+{
+ Q_Q(QTextControl);
+ QRectF br = q->blockBoundingRect(block);
+ br.setRight(qreal(INT_MAX)); // the block might have shrunk
+ emit q->updateRequest(br);
+}
+
+QRectF QTextControlPrivate::rectForPosition(int position) const
+{
+ Q_Q(const QTextControl);
+ const QTextBlock block = doc->findBlock(position);
+ if (!block.isValid())
+ return QRectF();
+ const QAbstractTextDocumentLayout *docLayout = doc->documentLayout();
+ const QTextLayout *layout = block.layout();
+ const QPointF layoutPos = q->blockBoundingRect(block).topLeft();
+ int relativePos = position - block.position();
+ if (preeditCursor != 0) {
+ int preeditPos = layout->preeditAreaPosition();
+ if (relativePos == preeditPos)
+ relativePos += preeditCursor;
+ else if (relativePos > preeditPos)
+ relativePos += layout->preeditAreaText().length();
+ }
+ QTextLine line = layout->lineForTextPosition(relativePos);
+
+ int cursorWidth;
+ {
+ bool ok = false;
+#ifndef QT_NO_PROPERTIES
+ cursorWidth = docLayout->property("cursorWidth").toInt(&ok);
+#endif
+ if (!ok)
+ cursorWidth = 1;
+ }
+
+ QRectF r;
+
+ if (line.isValid()) {
+ qreal x = line.cursorToX(relativePos);
+ qreal w = 0;
+ if (overwriteMode) {
+ if (relativePos < line.textLength() - line.textStart())
+ w = line.cursorToX(relativePos + 1) - x;
+ else
+ w = QFontMetrics(block.layout()->font()).width(QLatin1Char(' ')); // in sync with QTextLine::draw()
+ }
+ r = QRectF(layoutPos.x() + x, layoutPos.y() + line.y(),
+ cursorWidth + w, line.height());
+ } else {
+ r = QRectF(layoutPos.x(), layoutPos.y(), cursorWidth, 10); // #### correct height
+ }
+
+ return r;
+}
+
+static inline bool firstFramePosLessThanCursorPos(QTextFrame *frame, int position)
+{
+ return frame->firstPosition() < position;
+}
+
+static inline bool cursorPosLessThanLastFramePos(int position, QTextFrame *frame)
+{
+ return position < frame->lastPosition();
+}
+
+static QRectF boundingRectOfFloatsInSelection(const QTextCursor &cursor)
+{
+ QRectF r;
+ QTextFrame *frame = cursor.currentFrame();
+ const QList<QTextFrame *> children = frame->childFrames();
+
+ const QList<QTextFrame *>::ConstIterator firstFrame = qLowerBound(children.constBegin(), children.constEnd(),
+ cursor.selectionStart(), firstFramePosLessThanCursorPos);
+ const QList<QTextFrame *>::ConstIterator lastFrame = qUpperBound(children.constBegin(), children.constEnd(),
+ cursor.selectionEnd(), cursorPosLessThanLastFramePos);
+ for (QList<QTextFrame *>::ConstIterator it = firstFrame; it != lastFrame; ++it) {
+ if ((*it)->frameFormat().position() != QTextFrameFormat::InFlow)
+ r |= frame->document()->documentLayout()->frameBoundingRect(*it);
+ }
+ return r;
+}
+
+QRectF QTextControl::selectionRect(const QTextCursor &cursor) const
+{
+ Q_D(const QTextControl);
+
+ QRectF r = d->rectForPosition(cursor.selectionStart());
+
+ if (cursor.hasComplexSelection() && cursor.currentTable()) {
+ QTextTable *table = cursor.currentTable();
+
+ r = d->doc->documentLayout()->frameBoundingRect(table);
+ /*
+ int firstRow, numRows, firstColumn, numColumns;
+ cursor.selectedTableCells(&firstRow, &numRows, &firstColumn, &numColumns);
+
+ const QTextTableCell firstCell = table->cellAt(firstRow, firstColumn);
+ const QTextTableCell lastCell = table->cellAt(firstRow + numRows - 1, firstColumn + numColumns - 1);
+
+ const QAbstractTextDocumentLayout * const layout = doc->documentLayout();
+
+ QRectF tableSelRect = layout->blockBoundingRect(firstCell.firstCursorPosition().block());
+
+ for (int col = firstColumn; col < firstColumn + numColumns; ++col) {
+ const QTextTableCell cell = table->cellAt(firstRow, col);
+ const qreal y = layout->blockBoundingRect(cell.firstCursorPosition().block()).top();
+
+ tableSelRect.setTop(qMin(tableSelRect.top(), y));
+ }
+
+ for (int row = firstRow; row < firstRow + numRows; ++row) {
+ const QTextTableCell cell = table->cellAt(row, firstColumn);
+ const qreal x = layout->blockBoundingRect(cell.firstCursorPosition().block()).left();
+
+ tableSelRect.setLeft(qMin(tableSelRect.left(), x));
+ }
+
+ for (int col = firstColumn; col < firstColumn + numColumns; ++col) {
+ const QTextTableCell cell = table->cellAt(firstRow + numRows - 1, col);
+ const qreal y = layout->blockBoundingRect(cell.lastCursorPosition().block()).bottom();
+
+ tableSelRect.setBottom(qMax(tableSelRect.bottom(), y));
+ }
+
+ for (int row = firstRow; row < firstRow + numRows; ++row) {
+ const QTextTableCell cell = table->cellAt(row, firstColumn + numColumns - 1);
+ const qreal x = layout->blockBoundingRect(cell.lastCursorPosition().block()).right();
+
+ tableSelRect.setRight(qMax(tableSelRect.right(), x));
+ }
+
+ r = tableSelRect.toRect();
+ */
+ } else if (cursor.hasSelection()) {
+ const int position = cursor.selectionStart();
+ const int anchor = cursor.selectionEnd();
+ const QTextBlock posBlock = d->doc->findBlock(position);
+ const QTextBlock anchorBlock = d->doc->findBlock(anchor);
+ if (posBlock == anchorBlock && posBlock.isValid() && posBlock.layout()->lineCount()) {
+ const QTextLine posLine = posBlock.layout()->lineForTextPosition(position - posBlock.position());
+ const QTextLine anchorLine = anchorBlock.layout()->lineForTextPosition(anchor - anchorBlock.position());
+
+ const int firstLine = qMin(posLine.lineNumber(), anchorLine.lineNumber());
+ const int lastLine = qMax(posLine.lineNumber(), anchorLine.lineNumber());
+ const QTextLayout *layout = posBlock.layout();
+ r = QRectF();
+ for (int i = firstLine; i <= lastLine; ++i) {
+ r |= layout->lineAt(i).rect();
+ r |= layout->lineAt(i).naturalTextRect(); // might be bigger in the case of wrap not enabled
+ }
+ r.translate(blockBoundingRect(posBlock).topLeft());
+ } else {
+ QRectF anchorRect = d->rectForPosition(cursor.selectionEnd());
+ r |= anchorRect;
+ r |= boundingRectOfFloatsInSelection(cursor);
+ QRectF frameRect(d->doc->documentLayout()->frameBoundingRect(cursor.currentFrame()));
+ r.setLeft(frameRect.left());
+ r.setRight(frameRect.right());
+ }
+ if (r.isValid())
+ r.adjust(-1, -1, 1, 1);
+ }
+
+ return r;
+}
+
+QRectF QTextControl::selectionRect() const
+{
+ Q_D(const QTextControl);
+ return selectionRect(d->cursor);
+}
+
+void QTextControlPrivate::mousePressEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos, Qt::KeyboardModifiers modifiers,
+ Qt::MouseButtons buttons, const QPoint &globalPos)
+{
+ Q_Q(QTextControl);
+
+ if (sendMouseEventToInputContext(
+ e, QEvent::MouseButtonPress, button, pos, modifiers, buttons, globalPos)) {
+ return;
+ }
+
+ if (interactionFlags & Qt::LinksAccessibleByMouse) {
+ anchorOnMousePress = q->anchorAt(pos);
+
+ if (cursorIsFocusIndicator) {
+ cursorIsFocusIndicator = false;
+ repaintSelection();
+ cursor.clearSelection();
+ }
+ }
+ if (!(button & Qt::LeftButton) ||
+ !((interactionFlags & Qt::TextSelectableByMouse) || (interactionFlags & Qt::TextEditable))) {
+ e->ignore();
+ return;
+ }
+
+ cursorIsFocusIndicator = false;
+ const QTextCursor oldSelection = cursor;
+ const int oldCursorPos = cursor.position();
+
+ mousePressed = (interactionFlags & Qt::TextSelectableByMouse);
+#ifndef QT_NO_DRAGANDDROP
+ mightStartDrag = false;
+#endif
+
+ if (trippleClickTimer.isActive()
+ && ((pos - trippleClickPoint).toPoint().manhattanLength() < QApplication::startDragDistance())) {
+
+ cursor.movePosition(QTextCursor::StartOfBlock);
+ cursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
+ cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);
+ selectedBlockOnTrippleClick = cursor;
+
+ anchorOnMousePress = QString();
+
+ trippleClickTimer.stop();
+ } else {
+ int cursorPos = q->hitTest(pos, Qt::FuzzyHit);
+ if (cursorPos == -1) {
+ e->ignore();
+ return;
+ }
+
+ if (modifiers == Qt::ShiftModifier && (interactionFlags & Qt::TextSelectableByMouse)) {
+ if (wordSelectionEnabled && !selectedWordOnDoubleClick.hasSelection()) {
+ selectedWordOnDoubleClick = cursor;
+ selectedWordOnDoubleClick.select(QTextCursor::WordUnderCursor);
+ }
+
+ if (selectedBlockOnTrippleClick.hasSelection())
+ extendBlockwiseSelection(cursorPos);
+ else if (selectedWordOnDoubleClick.hasSelection())
+ extendWordwiseSelection(cursorPos, pos.x());
+ else if (!wordSelectionEnabled)
+ setCursorPosition(cursorPos, QTextCursor::KeepAnchor);
+ } else {
+
+ if (dragEnabled
+ && cursor.hasSelection()
+ && !cursorIsFocusIndicator
+ && cursorPos >= cursor.selectionStart()
+ && cursorPos <= cursor.selectionEnd()
+ && q->hitTest(pos, Qt::ExactHit) != -1) {
+#ifndef QT_NO_DRAGANDDROP
+ mightStartDrag = true;
+ dragStartPos = pos.toPoint();
+#endif
+ return;
+ }
+
+ setCursorPosition(cursorPos);
+ }
+ }
+
+ if (interactionFlags & Qt::TextEditable) {
+ q->ensureCursorVisible();
+ if (cursor.position() != oldCursorPos)
+ emit q->cursorPositionChanged();
+ _q_updateCurrentCharFormatAndSelection();
+ } else {
+ if (cursor.position() != oldCursorPos)
+ emit q->cursorPositionChanged();
+ selectionChanged();
+ }
+ repaintOldAndNewSelection(oldSelection);
+ hadSelectionOnMousePress = cursor.hasSelection();
+}
+
+void QTextControlPrivate::mouseMoveEvent(QEvent *e, Qt::MouseButton button, const QPointF &mousePos, Qt::KeyboardModifiers modifiers,
+ Qt::MouseButtons buttons, const QPoint &globalPos)
+{
+ Q_Q(QTextControl);
+
+ if (sendMouseEventToInputContext(
+ e, QEvent::MouseMove, button, mousePos, modifiers, buttons, globalPos)) {
+ return;
+ }
+
+ if (interactionFlags & Qt::LinksAccessibleByMouse) {
+ QString anchor = q->anchorAt(mousePos);
+ if (anchor != highlightedAnchor) {
+ highlightedAnchor = anchor;
+ emit q->linkHovered(anchor);
+ }
+ }
+
+ if (!(buttons & Qt::LeftButton))
+ return;
+
+ const bool editable = interactionFlags & Qt::TextEditable;
+
+ if (!(mousePressed
+ || editable
+ || mightStartDrag
+ || selectedWordOnDoubleClick.hasSelection()
+ || selectedBlockOnTrippleClick.hasSelection()))
+ return;
+
+ const QTextCursor oldSelection = cursor;
+ const int oldCursorPos = cursor.position();
+
+ if (mightStartDrag) {
+ if ((mousePos.toPoint() - dragStartPos).manhattanLength() > QApplication::startDragDistance())
+ startDrag();
+ return;
+ }
+
+ if (!mousePressed)
+ return;
+
+ const qreal mouseX = qreal(mousePos.x());
+
+ int newCursorPos = q->hitTest(mousePos, Qt::FuzzyHit);
+ if (newCursorPos == -1)
+ return;
+
+ if (wordSelectionEnabled && !selectedWordOnDoubleClick.hasSelection()) {
+ selectedWordOnDoubleClick = cursor;
+ selectedWordOnDoubleClick.select(QTextCursor::WordUnderCursor);
+ }
+
+ if (selectedBlockOnTrippleClick.hasSelection())
+ extendBlockwiseSelection(newCursorPos);
+ else if (selectedWordOnDoubleClick.hasSelection())
+ extendWordwiseSelection(newCursorPos, mouseX);
+ else
+ setCursorPosition(newCursorPos, QTextCursor::KeepAnchor);
+
+ if (interactionFlags & Qt::TextEditable) {
+ // don't call ensureVisible for the visible cursor to avoid jumping
+ // scrollbars. the autoscrolling ensures smooth scrolling if necessary.
+ //q->ensureCursorVisible();
+ if (cursor.position() != oldCursorPos)
+ emit q->cursorPositionChanged();
+ _q_updateCurrentCharFormatAndSelection();
+#ifndef QT_NO_IM
+ if (contextWidget) {
+ if (QInputContext *ic = inputContext()) {
+ ic->update();
+ }
+ }
+#endif //QT_NO_IM
+ } else {
+ //emit q->visibilityRequest(QRectF(mousePos, QSizeF(1, 1)));
+ if (cursor.position() != oldCursorPos)
+ emit q->cursorPositionChanged();
+ }
+ selectionChanged(true);
+ repaintOldAndNewSelection(oldSelection);
+}
+
+void QTextControlPrivate::mouseReleaseEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos, Qt::KeyboardModifiers modifiers,
+ Qt::MouseButtons buttons, const QPoint &globalPos)
+{
+ Q_Q(QTextControl);
+
+ if (sendMouseEventToInputContext(
+ e, QEvent::MouseButtonRelease, button, pos, modifiers, buttons, globalPos)) {
+ return;
+ }
+
+ const QTextCursor oldSelection = cursor;
+ const int oldCursorPos = cursor.position();
+
+#ifndef QT_NO_DRAGANDDROP
+ if (mightStartDrag && (button & Qt::LeftButton)) {
+ mousePressed = false;
+ setCursorPosition(pos);
+ cursor.clearSelection();
+ selectionChanged();
+ }
+#endif
+ if (mousePressed) {
+ mousePressed = false;
+#ifndef QT_NO_CLIPBOARD
+ setClipboardSelection();
+ selectionChanged(true);
+ } else if (button == Qt::MidButton
+ && (interactionFlags & Qt::TextEditable)
+ && QApplication::clipboard()->supportsSelection()) {
+ setCursorPosition(pos);
+ const QMimeData *md = QApplication::clipboard()->mimeData(QClipboard::Selection);
+ if (md)
+ q->insertFromMimeData(md);
+#endif
+ }
+
+ repaintOldAndNewSelection(oldSelection);
+
+ if (cursor.position() != oldCursorPos)
+ emit q->cursorPositionChanged();
+
+ if (interactionFlags & Qt::LinksAccessibleByMouse) {
+ if (!(button & Qt::LeftButton))
+ return;
+
+ const QString anchor = q->anchorAt(pos);
+
+ if (anchor.isEmpty())
+ return;
+
+ if (!cursor.hasSelection()
+ || (anchor == anchorOnMousePress && hadSelectionOnMousePress)) {
+
+ const int anchorPos = q->hitTest(pos, Qt::ExactHit);
+ if (anchorPos != -1) {
+ cursor.setPosition(anchorPos);
+
+ QString anchor = anchorOnMousePress;
+ anchorOnMousePress = QString();
+ activateLinkUnderCursor(anchor);
+ }
+ }
+ }
+}
+
+void QTextControlPrivate::mouseDoubleClickEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos, Qt::KeyboardModifiers modifiers,
+ Qt::MouseButtons buttons, const QPoint &globalPos)
+{
+ Q_Q(QTextControl);
+
+ if (sendMouseEventToInputContext(
+ e, QEvent::MouseButtonDblClick, button, pos, modifiers, buttons, globalPos)) {
+ return;
+ }
+
+ if (button != Qt::LeftButton
+ || !(interactionFlags & Qt::TextSelectableByMouse)) {
+ e->ignore();
+ return;
+ }
+
+#ifndef QT_NO_DRAGANDDROP
+ mightStartDrag = false;
+#endif
+ const QTextCursor oldSelection = cursor;
+ setCursorPosition(pos);
+ QTextLine line = currentTextLine(cursor);
+ bool doEmit = false;
+ if (line.isValid() && line.textLength()) {
+ cursor.select(QTextCursor::WordUnderCursor);
+ doEmit = true;
+ }
+ repaintOldAndNewSelection(oldSelection);
+
+ cursorIsFocusIndicator = false;
+ selectedWordOnDoubleClick = cursor;
+
+ trippleClickPoint = pos;
+ trippleClickTimer.start(QApplication::doubleClickInterval(), q);
+ if (doEmit) {
+ selectionChanged();
+#ifndef QT_NO_CLIPBOARD
+ setClipboardSelection();
+#endif
+ emit q->cursorPositionChanged();
+ }
+}
+
+bool QTextControlPrivate::sendMouseEventToInputContext(
+ QEvent *e, QEvent::Type eventType, Qt::MouseButton button, const QPointF &pos,
+ Qt::KeyboardModifiers modifiers, Qt::MouseButtons buttons, const QPoint &globalPos)
+{
+#if !defined(QT_NO_IM)
+ Q_Q(QTextControl);
+
+ QTextLayout *layout = cursor.block().layout();
+ if (contextWidget && layout && !layout->preeditAreaText().isEmpty()) {
+ QInputContext *ctx = inputContext();
+ int cursorPos = q->hitTest(pos, Qt::FuzzyHit) - cursor.position();
+
+ if (cursorPos < 0 || cursorPos > layout->preeditAreaText().length()) {
+ cursorPos = -1;
+ // don't send move events outside the preedit area
+ if (eventType == QEvent::MouseMove)
+ return true;
+ }
+ if (ctx) {
+ QMouseEvent ev(eventType, contextWidget->mapFromGlobal(globalPos), globalPos,
+ button, buttons, modifiers);
+ ctx->mouseHandler(cursorPos, &ev);
+ e->setAccepted(ev.isAccepted());
+ }
+ if (!layout->preeditAreaText().isEmpty())
+ return true;
+ }
+#else
+ Q_UNUSED(e);
+ Q_UNUSED(eventType);
+ Q_UNUSED(button);
+ Q_UNUSED(pos);
+ Q_UNUSED(modifiers);
+ Q_UNUSED(buttons);
+ Q_UNUSED(globalPos);
+#endif
+ return false;
+}
+
+void QTextControlPrivate::contextMenuEvent(const QPoint &screenPos, const QPointF &docPos, QWidget *contextWidget)
+{
+#ifdef QT_NO_CONTEXTMENU
+ Q_UNUSED(screenPos);
+ Q_UNUSED(docPos);
+ Q_UNUSED(contextWidget);
+#else
+ Q_Q(QTextControl);
+ if (!hasFocus)
+ return;
+ QMenu *menu = q->createStandardContextMenu(docPos, contextWidget);
+ if (!menu)
+ return;
+ menu->setAttribute(Qt::WA_DeleteOnClose);
+ menu->popup(screenPos);
+#endif
+}
+
+bool QTextControlPrivate::dragEnterEvent(QEvent *e, const QMimeData *mimeData)
+{
+ Q_Q(QTextControl);
+ if (!(interactionFlags & Qt::TextEditable) || !q->canInsertFromMimeData(mimeData)) {
+ e->ignore();
+ return false;
+ }
+
+ dndFeedbackCursor = QTextCursor();
+
+ return true; // accept proposed action
+}
+
+void QTextControlPrivate::dragLeaveEvent()
+{
+ Q_Q(QTextControl);
+
+ const QRectF crect = q->cursorRect(dndFeedbackCursor);
+ dndFeedbackCursor = QTextCursor();
+
+ if (crect.isValid())
+ emit q->updateRequest(crect);
+}
+
+bool QTextControlPrivate::dragMoveEvent(QEvent *e, const QMimeData *mimeData, const QPointF &pos)
+{
+ Q_Q(QTextControl);
+ if (!(interactionFlags & Qt::TextEditable) || !q->canInsertFromMimeData(mimeData)) {
+ e->ignore();
+ return false;
+ }
+
+ const int cursorPos = q->hitTest(pos, Qt::FuzzyHit);
+ if (cursorPos != -1) {
+ QRectF crect = q->cursorRect(dndFeedbackCursor);
+ if (crect.isValid())
+ emit q->updateRequest(crect);
+
+ dndFeedbackCursor = cursor;
+ dndFeedbackCursor.setPosition(cursorPos);
+
+ crect = q->cursorRect(dndFeedbackCursor);
+ emit q->updateRequest(crect);
+ }
+
+ return true; // accept proposed action
+}
+
+bool QTextControlPrivate::dropEvent(const QMimeData *mimeData, const QPointF &pos, Qt::DropAction dropAction, QWidget *source)
+{
+ Q_Q(QTextControl);
+ dndFeedbackCursor = QTextCursor();
+
+ if (!(interactionFlags & Qt::TextEditable) || !q->canInsertFromMimeData(mimeData))
+ return false;
+
+ repaintSelection();
+
+ QTextCursor insertionCursor = q->cursorForPosition(pos);
+ insertionCursor.beginEditBlock();
+
+ if (dropAction == Qt::MoveAction && source == contextWidget)
+ cursor.removeSelectedText();
+
+ cursor = insertionCursor;
+ q->insertFromMimeData(mimeData);
+ insertionCursor.endEditBlock();
+ q->ensureCursorVisible();
+ return true; // accept proposed action
+}
+
+void QTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
+{
+ Q_Q(QTextControl);
+ if (!(interactionFlags & Qt::TextEditable) || cursor.isNull()) {
+ e->ignore();
+ return;
+ }
+ bool isGettingInput = !e->commitString().isEmpty()
+ || e->preeditString() != cursor.block().layout()->preeditAreaText()
+ || e->replacementLength() > 0;
+
+ cursor.beginEditBlock();
+ if (isGettingInput) {
+ cursor.removeSelectedText();
+ }
+
+ // insert commit string
+ if (!e->commitString().isEmpty() || e->replacementLength()) {
+ QTextCursor c = cursor;
+ c.setPosition(c.position() + e->replacementStart());
+ c.setPosition(c.position() + e->replacementLength(), QTextCursor::KeepAnchor);
+ c.insertText(e->commitString());
+ }
+
+ for (int i = 0; i < e->attributes().size(); ++i) {
+ const QInputMethodEvent::Attribute &a = e->attributes().at(i);
+ if (a.type == QInputMethodEvent::Selection) {
+ QTextCursor oldCursor = cursor;
+ int blockStart = a.start + cursor.block().position();
+ cursor.setPosition(blockStart, QTextCursor::MoveAnchor);
+ cursor.setPosition(blockStart + a.length, QTextCursor::KeepAnchor);
+ q->ensureCursorVisible();
+ repaintOldAndNewSelection(oldCursor);
+ }
+ }
+
+ QTextBlock block = cursor.block();
+ QTextLayout *layout = block.layout();
+ if (isGettingInput)
+ layout->setPreeditArea(cursor.position() - block.position(), e->preeditString());
+ QList<QTextLayout::FormatRange> overrides;
+ const int oldPreeditCursor = preeditCursor;
+ preeditCursor = e->preeditString().length();
+ hideCursor = false;
+ for (int i = 0; i < e->attributes().size(); ++i) {
+ const QInputMethodEvent::Attribute &a = e->attributes().at(i);
+ if (a.type == QInputMethodEvent::Cursor) {
+ preeditCursor = a.start;
+ hideCursor = !a.length;
+ } else if (a.type == QInputMethodEvent::TextFormat) {
+ QTextCharFormat f = qvariant_cast<QTextFormat>(a.value).toCharFormat();
+ if (f.isValid()) {
+ QTextLayout::FormatRange o;
+ o.start = a.start + cursor.position() - block.position();
+ o.length = a.length;
+ o.format = f;
+ overrides.append(o);
+ }
+ }
+ }
+ layout->setAdditionalFormats(overrides);
+ cursor.endEditBlock();
+ if (cursor.d)
+ cursor.d->setX();
+ if (oldPreeditCursor != preeditCursor)
+ emit q->microFocusChanged();
+}
+
+QVariant QTextControl::inputMethodQuery(Qt::InputMethodQuery property) const
+{
+ Q_D(const QTextControl);
+ QTextBlock block = d->cursor.block();
+ switch(property) {
+ case Qt::ImMicroFocus:
+ return cursorRect();
+ case Qt::ImFont:
+ return QVariant(d->cursor.charFormat().font());
+ case Qt::ImCursorPosition:
+ return QVariant(d->cursor.position() - block.position());
+ case Qt::ImSurroundingText:
+ return QVariant(block.text());
+ case Qt::ImCurrentSelection:
+ return QVariant(d->cursor.selectedText());
+ case Qt::ImMaximumTextLength:
+ return QVariant(); // No limit.
+ case Qt::ImAnchorPosition:
+ return QVariant(qBound(0, d->cursor.anchor() - block.position(), block.length()));
+ default:
+ return QVariant();
+ }
+}
+
+void QTextControl::setFocus(bool focus, Qt::FocusReason reason)
+{
+ QFocusEvent ev(focus ? QEvent::FocusIn : QEvent::FocusOut,
+ reason);
+ processEvent(&ev);
+}
+
+void QTextControlPrivate::focusEvent(QFocusEvent *e)
+{
+ Q_Q(QTextControl);
+ emit q->updateRequest(q->selectionRect());
+ if (e->gotFocus()) {
+#ifdef QT_KEYPAD_NAVIGATION
+ if (!QApplication::keypadNavigationEnabled() || (hasEditFocus && (e->reason() == Qt::PopupFocusReason
+#ifdef Q_OS_SYMBIAN
+ || e->reason() == Qt::ActiveWindowFocusReason
+#endif
+ ))) {
+#endif
+ cursorOn = (interactionFlags & Qt::TextSelectableByKeyboard);
+ if (interactionFlags & Qt::TextEditable) {
+ setBlinkingCursorEnabled(true);
+ }
+#ifdef QT_KEYPAD_NAVIGATION
+ }
+#endif
+ } else {
+ setBlinkingCursorEnabled(false);
+
+ if (cursorIsFocusIndicator
+ && e->reason() != Qt::ActiveWindowFocusReason
+ && e->reason() != Qt::PopupFocusReason
+ && cursor.hasSelection()) {
+ cursor.clearSelection();
+ }
+ }
+ hasFocus = e->gotFocus();
+}
+
+QString QTextControlPrivate::anchorForCursor(const QTextCursor &anchorCursor) const
+{
+ if (anchorCursor.hasSelection()) {
+ QTextCursor cursor = anchorCursor;
+ if (cursor.selectionStart() != cursor.position())
+ cursor.setPosition(cursor.selectionStart());
+ cursor.movePosition(QTextCursor::NextCharacter);
+ QTextCharFormat fmt = cursor.charFormat();
+ if (fmt.isAnchor() && fmt.hasProperty(QTextFormat::AnchorHref))
+ return fmt.stringProperty(QTextFormat::AnchorHref);
+ }
+ return QString();
+}
+
+#ifdef QT_KEYPAD_NAVIGATION
+void QTextControlPrivate::editFocusEvent(QEvent *e)
+{
+ Q_Q(QTextControl);
+
+ if (QApplication::keypadNavigationEnabled()) {
+ if (e->type() == QEvent::EnterEditFocus && interactionFlags & Qt::TextEditable) {
+ const QTextCursor oldSelection = cursor;
+ const int oldCursorPos = cursor.position();
+ const bool moved = cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
+ q->ensureCursorVisible();
+ if (moved) {
+ if (cursor.position() != oldCursorPos)
+ emit q->cursorPositionChanged();
+ emit q->microFocusChanged();
+ }
+ selectionChanged();
+ repaintOldAndNewSelection(oldSelection);
+
+ setBlinkingCursorEnabled(true);
+ } else
+ setBlinkingCursorEnabled(false);
+ }
+
+ hasEditFocus = e->type() == QEvent::EnterEditFocus ? true : false;
+}
+#endif
+
+#ifndef QT_NO_CONTEXTMENU
+QMenu *QTextControl::createStandardContextMenu(const QPointF &pos, QWidget *parent)
+{
+ Q_D(QTextControl);
+
+ const bool showTextSelectionActions = d->interactionFlags & (Qt::TextEditable | Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse);
+
+ d->linkToCopy = QString();
+ if (!pos.isNull())
+ d->linkToCopy = anchorAt(pos);
+
+ if (d->linkToCopy.isEmpty() && !showTextSelectionActions)
+ return 0;
+
+ QMenu *menu = new QMenu(parent);
+ QAction *a;
+
+ if (d->interactionFlags & Qt::TextEditable) {
+ a = menu->addAction(tr("&Undo") + ACCEL_KEY(QKeySequence::Undo), this, SLOT(undo()));
+ a->setEnabled(d->doc->isUndoAvailable());
+ a = menu->addAction(tr("&Redo") + ACCEL_KEY(QKeySequence::Redo), this, SLOT(redo()));
+ a->setEnabled(d->doc->isRedoAvailable());
+ menu->addSeparator();
+
+ a = menu->addAction(tr("Cu&t") + ACCEL_KEY(QKeySequence::Cut), this, SLOT(cut()));
+ a->setEnabled(d->cursor.hasSelection());
+ }
+
+ if (showTextSelectionActions) {
+ a = menu->addAction(tr("&Copy") + ACCEL_KEY(QKeySequence::Copy), this, SLOT(copy()));
+ a->setEnabled(d->cursor.hasSelection());
+ }
+
+ if ((d->interactionFlags & Qt::LinksAccessibleByKeyboard)
+ || (d->interactionFlags & Qt::LinksAccessibleByMouse)) {
+
+ a = menu->addAction(tr("Copy &Link Location"), this, SLOT(_q_copyLink()));
+ a->setEnabled(!d->linkToCopy.isEmpty());
+ }
+
+ if (d->interactionFlags & Qt::TextEditable) {
+#if !defined(QT_NO_CLIPBOARD)
+ a = menu->addAction(tr("&Paste") + ACCEL_KEY(QKeySequence::Paste), this, SLOT(paste()));
+ a->setEnabled(canPaste());
+#endif
+ a = menu->addAction(tr("Delete"), this, SLOT(_q_deleteSelected()));
+ a->setEnabled(d->cursor.hasSelection());
+ }
+
+
+ if (showTextSelectionActions) {
+ menu->addSeparator();
+ a = menu->addAction(tr("Select All") + ACCEL_KEY(QKeySequence::SelectAll), this, SLOT(selectAll()));
+ a->setEnabled(!d->doc->isEmpty());
+ }
+
+#if !defined(QT_NO_IM)
+ if (d->contextWidget) {
+ QInputContext *qic = d->inputContext();
+ if (qic) {
+ QList<QAction *> imActions = qic->actions();
+ for (int i = 0; i < imActions.size(); ++i)
+ menu->addAction(imActions.at(i));
+ }
+ }
+#endif
+
+#if defined(Q_WS_WIN) || defined(Q_WS_X11)
+ if ((d->interactionFlags & Qt::TextEditable) && qt_use_rtl_extensions) {
+#else
+ if (d->interactionFlags & Qt::TextEditable) {
+#endif
+ menu->addSeparator();
+ QUnicodeControlCharacterMenu *ctrlCharacterMenu = new QUnicodeControlCharacterMenu(this, menu);
+ menu->addMenu(ctrlCharacterMenu);
+ }
+
+ return menu;
+}
+#endif // QT_NO_CONTEXTMENU
+
+QTextCursor QTextControl::cursorForPosition(const QPointF &pos) const
+{
+ Q_D(const QTextControl);
+ int cursorPos = hitTest(pos, Qt::FuzzyHit);
+ if (cursorPos == -1)
+ cursorPos = 0;
+ QTextCursor c(d->doc);
+ c.setPosition(cursorPos);
+ return c;
+}
+
+QRectF QTextControl::cursorRect(const QTextCursor &cursor) const
+{
+ Q_D(const QTextControl);
+ if (cursor.isNull())
+ return QRectF();
+
+ return d->rectForPosition(cursor.position());
+}
+
+QRectF QTextControl::cursorRect() const
+{
+ Q_D(const QTextControl);
+ return cursorRect(d->cursor);
+}
+
+QRectF QTextControlPrivate::cursorRectPlusUnicodeDirectionMarkers(const QTextCursor &cursor) const
+{
+ if (cursor.isNull())
+ return QRectF();
+
+ return rectForPosition(cursor.position()).adjusted(-4, 0, 4, 0);
+}
+
+QString QTextControl::anchorAt(const QPointF &pos) const
+{
+ Q_D(const QTextControl);
+ return d->doc->documentLayout()->anchorAt(pos);
+}
+
+QString QTextControl::anchorAtCursor() const
+{
+ Q_D(const QTextControl);
+
+ return d->anchorForCursor(d->cursor);
+}
+
+bool QTextControl::overwriteMode() const
+{
+ Q_D(const QTextControl);
+ return d->overwriteMode;
+}
+
+void QTextControl::setOverwriteMode(bool overwrite)
+{
+ Q_D(QTextControl);
+ d->overwriteMode = overwrite;
+}
+
+int QTextControl::cursorWidth() const
+{
+#ifndef QT_NO_PROPERTIES
+ Q_D(const QTextControl);
+ return d->doc->documentLayout()->property("cursorWidth").toInt();
+#else
+ return 1;
+#endif
+}
+
+void QTextControl::setCursorWidth(int width)
+{
+ Q_D(QTextControl);
+#ifdef QT_NO_PROPERTIES
+ Q_UNUSED(width);
+#else
+ if (width == -1)
+ width = QApplication::style()->pixelMetric(QStyle::PM_TextCursorWidth);
+ d->doc->documentLayout()->setProperty("cursorWidth", width);
+#endif
+ d->repaintCursor();
+}
+
+bool QTextControl::acceptRichText() const
+{
+ Q_D(const QTextControl);
+ return d->acceptRichText;
+}
+
+void QTextControl::setAcceptRichText(bool accept)
+{
+ Q_D(QTextControl);
+ d->acceptRichText = accept;
+}
+
+#ifndef QT_NO_TEXTEDIT
+
+void QTextControl::setExtraSelections(const QList<QTextEdit::ExtraSelection> &selections)
+{
+ Q_D(QTextControl);
+
+ QHash<int, int> hash;
+ for (int i = 0; i < d->extraSelections.count(); ++i) {
+ const QAbstractTextDocumentLayout::Selection &esel = d->extraSelections.at(i);
+ hash.insertMulti(esel.cursor.anchor(), i);
+ }
+
+ for (int i = 0; i < selections.count(); ++i) {
+ const QTextEdit::ExtraSelection &sel = selections.at(i);
+ QHash<int, int>::iterator it = hash.find(sel.cursor.anchor());
+ if (it != hash.end()) {
+ const QAbstractTextDocumentLayout::Selection &esel = d->extraSelections.at(it.value());
+ if (esel.cursor.position() == sel.cursor.position()
+ && esel.format == sel.format) {
+ hash.erase(it);
+ continue;
+ }
+ }
+ QRectF r = selectionRect(sel.cursor);
+ if (sel.format.boolProperty(QTextFormat::FullWidthSelection)) {
+ r.setLeft(0);
+ r.setWidth(qreal(INT_MAX));
+ }
+ emit updateRequest(r);
+ }
+
+ for (QHash<int, int>::iterator it = hash.begin(); it != hash.end(); ++it) {
+ const QAbstractTextDocumentLayout::Selection &esel = d->extraSelections.at(it.value());
+ QRectF r = selectionRect(esel.cursor);
+ if (esel.format.boolProperty(QTextFormat::FullWidthSelection)) {
+ r.setLeft(0);
+ r.setWidth(qreal(INT_MAX));
+ }
+ emit updateRequest(r);
+ }
+
+ d->extraSelections.resize(selections.count());
+ for (int i = 0; i < selections.count(); ++i) {
+ d->extraSelections[i].cursor = selections.at(i).cursor;
+ d->extraSelections[i].format = selections.at(i).format;
+ }
+}
+
+QList<QTextEdit::ExtraSelection> QTextControl::extraSelections() const
+{
+ Q_D(const QTextControl);
+ QList<QTextEdit::ExtraSelection> selections;
+ for (int i = 0; i < d->extraSelections.count(); ++i) {
+ QTextEdit::ExtraSelection sel;
+ sel.cursor = d->extraSelections.at(i).cursor;
+ sel.format = d->extraSelections.at(i).format;
+ selections.append(sel);
+ }
+ return selections;
+}
+
+#endif // QT_NO_TEXTEDIT
+
+void QTextControl::setTextWidth(qreal width)
+{
+ Q_D(QTextControl);
+ d->doc->setTextWidth(width);
+}
+
+qreal QTextControl::textWidth() const
+{
+ Q_D(const QTextControl);
+ return d->doc->textWidth();
+}
+
+QSizeF QTextControl::size() const
+{
+ Q_D(const QTextControl);
+ return d->doc->size();
+}
+
+void QTextControl::setOpenExternalLinks(bool open)
+{
+ Q_D(QTextControl);
+ d->openExternalLinks = open;
+}
+
+bool QTextControl::openExternalLinks() const
+{
+ Q_D(const QTextControl);
+ return d->openExternalLinks;
+}
+
+bool QTextControl::ignoreUnusedNavigationEvents() const
+{
+ Q_D(const QTextControl);
+ return d->ignoreUnusedNavigationEvents;
+}
+
+void QTextControl::setIgnoreUnusedNavigationEvents(bool ignore)
+{
+ Q_D(QTextControl);
+ d->ignoreUnusedNavigationEvents = ignore;
+}
+
+void QTextControl::moveCursor(QTextCursor::MoveOperation op, QTextCursor::MoveMode mode)
+{
+ Q_D(QTextControl);
+ const QTextCursor oldSelection = d->cursor;
+ const bool moved = d->cursor.movePosition(op, mode);
+ d->_q_updateCurrentCharFormatAndSelection();
+ ensureCursorVisible();
+ d->repaintOldAndNewSelection(oldSelection);
+ if (moved)
+ emit cursorPositionChanged();
+}
+
+bool QTextControl::canPaste() const
+{
+#ifndef QT_NO_CLIPBOARD
+ Q_D(const QTextControl);
+ if (d->interactionFlags & Qt::TextEditable) {
+ const QMimeData *md = QApplication::clipboard()->mimeData();
+ return md && canInsertFromMimeData(md);
+ }
+#endif
+ return false;
+}
+
+void QTextControl::setCursorIsFocusIndicator(bool b)
+{
+ Q_D(QTextControl);
+ d->cursorIsFocusIndicator = b;
+ d->repaintCursor();
+}
+
+bool QTextControl::cursorIsFocusIndicator() const
+{
+ Q_D(const QTextControl);
+ return d->cursorIsFocusIndicator;
+}
+
+
+void QTextControl::setDragEnabled(bool enabled)
+{
+ Q_D(QTextControl);
+ d->dragEnabled = enabled;
+}
+
+bool QTextControl::isDragEnabled() const
+{
+ Q_D(const QTextControl);
+ return d->dragEnabled;
+}
+
+void QTextControl::setWordSelectionEnabled(bool enabled)
+{
+ Q_D(QTextControl);
+ d->wordSelectionEnabled = enabled;
+}
+
+bool QTextControl::isWordSelectionEnabled() const
+{
+ Q_D(const QTextControl);
+ return d->wordSelectionEnabled;
+}
+
+#ifndef QT_NO_PRINTER
+void QTextControl::print(QPrinter *printer) const
+{
+#ifndef QT_NO_PRINTER
+ Q_D(const QTextControl);
+ if (!printer || !printer->isValid())
+ return;
+ QTextDocument *tempDoc = 0;
+ const QTextDocument *doc = d->doc;
+ if (printer->printRange() == QPrinter::Selection) {
+ if (!d->cursor.hasSelection())
+ return;
+ tempDoc = new QTextDocument(const_cast<QTextDocument *>(doc));
+ tempDoc->setMetaInformation(QTextDocument::DocumentTitle, doc->metaInformation(QTextDocument::DocumentTitle));
+ tempDoc->setPageSize(doc->pageSize());
+ tempDoc->setDefaultFont(doc->defaultFont());
+ tempDoc->setUseDesignMetrics(doc->useDesignMetrics());
+ QTextCursor(tempDoc).insertFragment(d->cursor.selection());
+ doc = tempDoc;
+
+ // copy the custom object handlers
+ doc->documentLayout()->d_func()->handlers = d->doc->documentLayout()->d_func()->handlers;
+ }
+ doc->print(printer);
+ delete tempDoc;
+#endif
+}
+#endif // QT_NO_PRINTER
+
+QMimeData *QTextControl::createMimeDataFromSelection() const
+{
+ Q_D(const QTextControl);
+ const QTextDocumentFragment fragment(d->cursor);
+ return new QTextEditMimeData(fragment);
+}
+
+bool QTextControl::canInsertFromMimeData(const QMimeData *source) const
+{
+ Q_D(const QTextControl);
+ if (d->acceptRichText)
+ return (source->hasText() && !source->text().isEmpty())
+ || source->hasHtml()
+ || source->hasFormat(QLatin1String("application/x-qrichtext"))
+ || source->hasFormat(QLatin1String("application/x-qt-richtext"));
+ else
+ return source->hasText() && !source->text().isEmpty();
+}
+
+void QTextControl::insertFromMimeData(const QMimeData *source)
+{
+ Q_D(QTextControl);
+ if (!(d->interactionFlags & Qt::TextEditable) || !source)
+ return;
+
+ bool hasData = false;
+ QTextDocumentFragment fragment;
+#ifndef QT_NO_TEXTHTMLPARSER
+ if (source->hasFormat(QLatin1String("application/x-qrichtext")) && d->acceptRichText) {
+ // x-qrichtext is always UTF-8 (taken from Qt3 since we don't use it anymore).
+ QString richtext = QString::fromUtf8(source->data(QLatin1String("application/x-qrichtext")));
+ richtext.prepend(QLatin1String("<meta name=\"qrichtext\" content=\"1\" />"));
+ fragment = QTextDocumentFragment::fromHtml(richtext, d->doc);
+ hasData = true;
+ } else if (source->hasHtml() && d->acceptRichText) {
+ fragment = QTextDocumentFragment::fromHtml(source->html(), d->doc);
+ hasData = true;
+ } else {
+ QString text = source->text();
+ if (!text.isNull()) {
+ fragment = QTextDocumentFragment::fromPlainText(text);
+ hasData = true;
+ }
+ }
+#else
+ fragment = QTextDocumentFragment::fromPlainText(source->text());
+#endif // QT_NO_TEXTHTMLPARSER
+
+ if (hasData)
+ d->cursor.insertFragment(fragment);
+ ensureCursorVisible();
+}
+
+bool QTextControl::findNextPrevAnchor(const QTextCursor &startCursor, bool next, QTextCursor &newAnchor)
+{
+ Q_D(QTextControl);
+
+ int anchorStart = -1;
+ QString anchorHref;
+ int anchorEnd = -1;
+
+ if (next) {
+ const int startPos = startCursor.selectionEnd();
+
+ QTextBlock block = d->doc->findBlock(startPos);
+ QTextBlock::Iterator it = block.begin();
+
+ while (!it.atEnd() && it.fragment().position() < startPos)
+ ++it;
+
+ while (block.isValid()) {
+ anchorStart = -1;
+
+ // find next anchor
+ for (; !it.atEnd(); ++it) {
+ const QTextFragment fragment = it.fragment();
+ const QTextCharFormat fmt = fragment.charFormat();
+
+ if (fmt.isAnchor() && fmt.hasProperty(QTextFormat::AnchorHref)) {
+ anchorStart = fragment.position();
+ anchorHref = fmt.anchorHref();
+ break;
+ }
+ }
+
+ if (anchorStart != -1) {
+ anchorEnd = -1;
+
+ // find next non-anchor fragment
+ for (; !it.atEnd(); ++it) {
+ const QTextFragment fragment = it.fragment();
+ const QTextCharFormat fmt = fragment.charFormat();
+
+ if (!fmt.isAnchor() || fmt.anchorHref() != anchorHref) {
+ anchorEnd = fragment.position();
+ break;
+ }
+ }
+
+ if (anchorEnd == -1)
+ anchorEnd = block.position() + block.length() - 1;
+
+ // make found selection
+ break;
+ }
+
+ block = block.next();
+ it = block.begin();
+ }
+ } else {
+ int startPos = startCursor.selectionStart();
+ if (startPos > 0)
+ --startPos;
+
+ QTextBlock block = d->doc->findBlock(startPos);
+ QTextBlock::Iterator blockStart = block.begin();
+ QTextBlock::Iterator it = block.end();
+
+ if (startPos == block.position()) {
+ it = block.begin();
+ } else {
+ do {
+ if (it == blockStart) {
+ it = QTextBlock::Iterator();
+ block = QTextBlock();
+ } else {
+ --it;
+ }
+ } while (!it.atEnd() && it.fragment().position() + it.fragment().length() - 1 > startPos);
+ }
+
+ while (block.isValid()) {
+ anchorStart = -1;
+
+ if (!it.atEnd()) {
+ do {
+ const QTextFragment fragment = it.fragment();
+ const QTextCharFormat fmt = fragment.charFormat();
+
+ if (fmt.isAnchor() && fmt.hasProperty(QTextFormat::AnchorHref)) {
+ anchorStart = fragment.position() + fragment.length();
+ anchorHref = fmt.anchorHref();
+ break;
+ }
+
+ if (it == blockStart)
+ it = QTextBlock::Iterator();
+ else
+ --it;
+ } while (!it.atEnd());
+ }
+
+ if (anchorStart != -1 && !it.atEnd()) {
+ anchorEnd = -1;
+
+ do {
+ const QTextFragment fragment = it.fragment();
+ const QTextCharFormat fmt = fragment.charFormat();
+
+ if (!fmt.isAnchor() || fmt.anchorHref() != anchorHref) {
+ anchorEnd = fragment.position() + fragment.length();
+ break;
+ }
+
+ if (it == blockStart)
+ it = QTextBlock::Iterator();
+ else
+ --it;
+ } while (!it.atEnd());
+
+ if (anchorEnd == -1)
+ anchorEnd = qMax(0, block.position());
+
+ break;
+ }
+
+ block = block.previous();
+ it = block.end();
+ if (it != block.begin())
+ --it;
+ blockStart = block.begin();
+ }
+
+ }
+
+ if (anchorStart != -1 && anchorEnd != -1) {
+ newAnchor = d->cursor;
+ newAnchor.setPosition(anchorStart);
+ newAnchor.setPosition(anchorEnd, QTextCursor::KeepAnchor);
+ return true;
+ }
+
+ return false;
+}
+
+void QTextControlPrivate::activateLinkUnderCursor(QString href)
+{
+ QTextCursor oldCursor = cursor;
+
+ if (href.isEmpty()) {
+ QTextCursor tmp = cursor;
+ if (tmp.selectionStart() != tmp.position())
+ tmp.setPosition(tmp.selectionStart());
+ tmp.movePosition(QTextCursor::NextCharacter);
+ href = tmp.charFormat().anchorHref();
+ }
+ if (href.isEmpty())
+ return;
+
+ if (!cursor.hasSelection()) {
+ QTextBlock block = cursor.block();
+ const int cursorPos = cursor.position();
+
+ QTextBlock::Iterator it = block.begin();
+ QTextBlock::Iterator linkFragment;
+
+ for (; !it.atEnd(); ++it) {
+ QTextFragment fragment = it.fragment();
+ const int fragmentPos = fragment.position();
+ if (fragmentPos <= cursorPos &&
+ fragmentPos + fragment.length() > cursorPos) {
+ linkFragment = it;
+ break;
+ }
+ }
+
+ if (!linkFragment.atEnd()) {
+ it = linkFragment;
+ cursor.setPosition(it.fragment().position());
+ if (it != block.begin()) {
+ do {
+ --it;
+ QTextFragment fragment = it.fragment();
+ if (fragment.charFormat().anchorHref() != href)
+ break;
+ cursor.setPosition(fragment.position());
+ } while (it != block.begin());
+ }
+
+ for (it = linkFragment; !it.atEnd(); ++it) {
+ QTextFragment fragment = it.fragment();
+ if (fragment.charFormat().anchorHref() != href)
+ break;
+ cursor.setPosition(fragment.position() + fragment.length(), QTextCursor::KeepAnchor);
+ }
+ }
+ }
+
+ if (hasFocus) {
+ cursorIsFocusIndicator = true;
+ } else {
+ cursorIsFocusIndicator = false;
+ cursor.clearSelection();
+ }
+ repaintOldAndNewSelection(oldCursor);
+
+#ifndef QT_NO_DESKTOPSERVICES
+ if (openExternalLinks)
+ QDesktopServices::openUrl(href);
+ else
+#endif
+ emit q_func()->linkActivated(href);
+}
+
+#ifndef QT_NO_TOOLTIP
+void QTextControlPrivate::showToolTip(const QPoint &globalPos, const QPointF &pos, QWidget *contextWidget)
+{
+ const QString toolTip = q_func()->cursorForPosition(pos).charFormat().toolTip();
+ if (toolTip.isEmpty())
+ return;
+ QToolTip::showText(globalPos, toolTip, contextWidget);
+}
+#endif // QT_NO_TOOLTIP
+
+bool QTextControl::setFocusToNextOrPreviousAnchor(bool next)
+{
+ Q_D(QTextControl);
+
+ if (!(d->interactionFlags & Qt::LinksAccessibleByKeyboard))
+ return false;
+
+ QRectF crect = selectionRect();
+ emit updateRequest(crect);
+
+ // If we don't have a current anchor, we start from the start/end
+ if (!d->cursor.hasSelection()) {
+ d->cursor = QTextCursor(d->doc);
+ if (next)
+ d->cursor.movePosition(QTextCursor::Start);
+ else
+ d->cursor.movePosition(QTextCursor::End);
+ }
+
+ QTextCursor newAnchor;
+ if (findNextPrevAnchor(d->cursor, next, newAnchor)) {
+ d->cursor = newAnchor;
+ d->cursorIsFocusIndicator = true;
+ } else {
+ d->cursor.clearSelection();
+ }
+
+ if (d->cursor.hasSelection()) {
+ crect = selectionRect();
+ emit updateRequest(crect);
+ emit visibilityRequest(crect);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+bool QTextControl::setFocusToAnchor(const QTextCursor &newCursor)
+{
+ Q_D(QTextControl);
+
+ if (!(d->interactionFlags & Qt::LinksAccessibleByKeyboard))
+ return false;
+
+ // Verify that this is an anchor.
+ const QString anchorHref = d->anchorForCursor(newCursor);
+ if (anchorHref.isEmpty())
+ return false;
+
+ // and process it
+ QRectF crect = selectionRect();
+ emit updateRequest(crect);
+
+ d->cursor.setPosition(newCursor.selectionStart());
+ d->cursor.setPosition(newCursor.selectionEnd(), QTextCursor::KeepAnchor);
+ d->cursorIsFocusIndicator = true;
+
+ crect = selectionRect();
+ emit updateRequest(crect);
+ emit visibilityRequest(crect);
+ return true;
+}
+
+void QTextControl::setTextInteractionFlags(Qt::TextInteractionFlags flags)
+{
+ Q_D(QTextControl);
+ if (flags == d->interactionFlags)
+ return;
+ d->interactionFlags = flags;
+
+ if (d->hasFocus)
+ d->setBlinkingCursorEnabled(flags & Qt::TextEditable);
+}
+
+Qt::TextInteractionFlags QTextControl::textInteractionFlags() const
+{
+ Q_D(const QTextControl);
+ return d->interactionFlags;
+}
+
+void QTextControl::mergeCurrentCharFormat(const QTextCharFormat &modifier)
+{
+ Q_D(QTextControl);
+ d->cursor.mergeCharFormat(modifier);
+ d->updateCurrentCharFormat();
+}
+
+void QTextControl::setCurrentCharFormat(const QTextCharFormat &format)
+{
+ Q_D(QTextControl);
+ d->cursor.setCharFormat(format);
+ d->updateCurrentCharFormat();
+}
+
+QTextCharFormat QTextControl::currentCharFormat() const
+{
+ Q_D(const QTextControl);
+ return d->cursor.charFormat();
+}
+
+void QTextControl::insertPlainText(const QString &text)
+{
+ Q_D(QTextControl);
+ d->cursor.insertText(text);
+}
+
+#ifndef QT_NO_TEXTHTMLPARSER
+void QTextControl::insertHtml(const QString &text)
+{
+ Q_D(QTextControl);
+ d->cursor.insertHtml(text);
+}
+#endif // QT_NO_TEXTHTMLPARSER
+
+QPointF QTextControl::anchorPosition(const QString &name) const
+{
+ Q_D(const QTextControl);
+ if (name.isEmpty())
+ return QPointF();
+
+ QRectF r;
+ for (QTextBlock block = d->doc->begin(); block.isValid(); block = block.next()) {
+ QTextCharFormat format = block.charFormat();
+ if (format.isAnchor() && format.anchorNames().contains(name)) {
+ r = d->rectForPosition(block.position());
+ break;
+ }
+
+ for (QTextBlock::Iterator it = block.begin(); !it.atEnd(); ++it) {
+ QTextFragment fragment = it.fragment();
+ format = fragment.charFormat();
+ if (format.isAnchor() && format.anchorNames().contains(name)) {
+ r = d->rectForPosition(fragment.position());
+ block = QTextBlock();
+ break;
+ }
+ }
+ }
+ if (!r.isValid())
+ return QPointF();
+ return QPointF(0, r.top());
+}
+
+void QTextControl::adjustSize()
+{
+ Q_D(QTextControl);
+ d->doc->adjustSize();
+}
+
+bool QTextControl::find(const QString &exp, QTextDocument::FindFlags options)
+{
+ Q_D(QTextControl);
+ QTextCursor search = d->doc->find(exp, d->cursor, options);
+ if (search.isNull())
+ return false;
+
+ setTextCursor(search);
+ return true;
+}
+
+
+
+void QTextControlPrivate::append(const QString &text, Qt::TextFormat format)
+{
+ QTextCursor tmp(doc);
+ tmp.beginEditBlock();
+ tmp.movePosition(QTextCursor::End);
+
+ if (!doc->isEmpty())
+ tmp.insertBlock(cursor.blockFormat(), cursor.charFormat());
+ else
+ tmp.setCharFormat(cursor.charFormat());
+
+ // preserve the char format
+ QTextCharFormat oldCharFormat = cursor.charFormat();
+
+#ifndef QT_NO_TEXTHTMLPARSER
+ if (format == Qt::RichText || (format == Qt::AutoText && Qt::mightBeRichText(text))) {
+ tmp.insertHtml(text);
+ } else {
+ tmp.insertText(text);
+ }
+#else
+ tmp.insertText(text);
+#endif // QT_NO_TEXTHTMLPARSER
+ if (!cursor.hasSelection())
+ cursor.setCharFormat(oldCharFormat);
+
+ tmp.endEditBlock();
+}
+
+void QTextControl::append(const QString &text)
+{
+ Q_D(QTextControl);
+ d->append(text, Qt::AutoText);
+}
+
+void QTextControl::appendHtml(const QString &html)
+{
+ Q_D(QTextControl);
+ d->append(html, Qt::RichText);
+}
+
+void QTextControl::appendPlainText(const QString &text)
+{
+ Q_D(QTextControl);
+ d->append(text, Qt::PlainText);
+}
+
+
+void QTextControl::ensureCursorVisible()
+{
+ Q_D(QTextControl);
+ QRectF crect = d->rectForPosition(d->cursor.position()).adjusted(-5, 0, 5, 0);
+ emit visibilityRequest(crect);
+ emit microFocusChanged();
+}
+
+QPalette QTextControl::palette() const
+{
+ Q_D(const QTextControl);
+ return d->palette;
+}
+
+void QTextControl::setPalette(const QPalette &pal)
+{
+ Q_D(QTextControl);
+ d->palette = pal;
+}
+
+QAbstractTextDocumentLayout::PaintContext QTextControl::getPaintContext(QWidget *widget) const
+{
+ Q_D(const QTextControl);
+
+ QAbstractTextDocumentLayout::PaintContext ctx;
+
+ ctx.selections = d->extraSelections;
+ ctx.palette = d->palette;
+ if (d->cursorOn && d->isEnabled) {
+ if (d->hideCursor)
+ ctx.cursorPosition = -1;
+ else if (d->preeditCursor != 0)
+ ctx.cursorPosition = - (d->preeditCursor + 2);
+ else
+ ctx.cursorPosition = d->cursor.position();
+ }
+
+ if (!d->dndFeedbackCursor.isNull())
+ ctx.cursorPosition = d->dndFeedbackCursor.position();
+#ifdef QT_KEYPAD_NAVIGATION
+ if (!QApplication::keypadNavigationEnabled() || d->hasEditFocus)
+#endif
+ if (d->cursor.hasSelection()) {
+ QAbstractTextDocumentLayout::Selection selection;
+ selection.cursor = d->cursor;
+ if (d->cursorIsFocusIndicator) {
+ QStyleOption opt;
+ opt.palette = ctx.palette;
+ QStyleHintReturnVariant ret;
+ QStyle *style = QApplication::style();
+ if (widget)
+ style = widget->style();
+ style->styleHint(QStyle::SH_TextControl_FocusIndicatorTextCharFormat, &opt, widget, &ret);
+ selection.format = qvariant_cast<QTextFormat>(ret.variant).toCharFormat();
+ } else {
+ QPalette::ColorGroup cg = d->hasFocus ? QPalette::Active : QPalette::Inactive;
+ selection.format.setBackground(ctx.palette.brush(cg, QPalette::Highlight));
+ selection.format.setForeground(ctx.palette.brush(cg, QPalette::HighlightedText));
+ QStyleOption opt;
+ QStyle *style = QApplication::style();
+ if (widget) {
+ opt.initFrom(widget);
+ style = widget->style();
+ }
+ if (style->styleHint(QStyle::SH_RichText_FullWidthSelection, &opt, widget))
+ selection.format.setProperty(QTextFormat::FullWidthSelection, true);
+ }
+ ctx.selections.append(selection);
+ }
+
+ return ctx;
+}
+
+void QTextControl::drawContents(QPainter *p, const QRectF &rect, QWidget *widget)
+{
+ Q_D(QTextControl);
+ p->save();
+ QAbstractTextDocumentLayout::PaintContext ctx = getPaintContext(widget);
+ if (rect.isValid())
+ p->setClipRect(rect, Qt::IntersectClip);
+ ctx.clip = rect;
+
+ d->doc->documentLayout()->draw(p, ctx);
+ p->restore();
+}
+
+void QTextControlPrivate::_q_copyLink()
+{
+#ifndef QT_NO_CLIPBOARD
+ QMimeData *md = new QMimeData;
+ md->setText(linkToCopy);
+ QApplication::clipboard()->setMimeData(md);
+#endif
+}
+
+QInputContext *QTextControlPrivate::inputContext()
+{
+ QInputContext *ctx = contextWidget->inputContext();
+ if (!ctx && contextWidget->parentWidget())
+ ctx = contextWidget->parentWidget()->inputContext();
+ return ctx;
+}
+
+int QTextControl::hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const
+{
+ Q_D(const QTextControl);
+ return d->doc->documentLayout()->hitTest(point, accuracy);
+}
+
+QRectF QTextControl::blockBoundingRect(const QTextBlock &block) const
+{
+ Q_D(const QTextControl);
+ return d->doc->documentLayout()->blockBoundingRect(block);
+}
+
+#ifndef QT_NO_CONTEXTMENU
+#define NUM_CONTROL_CHARACTERS 10
+const struct QUnicodeControlCharacter {
+ const char *text;
+ ushort character;
+} qt_controlCharacters[NUM_CONTROL_CHARACTERS] = {
+ { QT_TRANSLATE_NOOP("QUnicodeControlCharacterMenu", "LRM Left-to-right mark"), 0x200e },
+ { QT_TRANSLATE_NOOP("QUnicodeControlCharacterMenu", "RLM Right-to-left mark"), 0x200f },
+ { QT_TRANSLATE_NOOP("QUnicodeControlCharacterMenu", "ZWJ Zero width joiner"), 0x200d },
+ { QT_TRANSLATE_NOOP("QUnicodeControlCharacterMenu", "ZWNJ Zero width non-joiner"), 0x200c },
+ { QT_TRANSLATE_NOOP("QUnicodeControlCharacterMenu", "ZWSP Zero width space"), 0x200b },
+ { QT_TRANSLATE_NOOP("QUnicodeControlCharacterMenu", "LRE Start of left-to-right embedding"), 0x202a },
+ { QT_TRANSLATE_NOOP("QUnicodeControlCharacterMenu", "RLE Start of right-to-left embedding"), 0x202b },
+ { QT_TRANSLATE_NOOP("QUnicodeControlCharacterMenu", "LRO Start of left-to-right override"), 0x202d },
+ { QT_TRANSLATE_NOOP("QUnicodeControlCharacterMenu", "RLO Start of right-to-left override"), 0x202e },
+ { QT_TRANSLATE_NOOP("QUnicodeControlCharacterMenu", "PDF Pop directional formatting"), 0x202c },
+};
+
+QUnicodeControlCharacterMenu::QUnicodeControlCharacterMenu(QObject *_editWidget, QWidget *parent)
+ : QMenu(parent), editWidget(_editWidget)
+{
+ setTitle(tr("Insert Unicode control character"));
+ for (int i = 0; i < NUM_CONTROL_CHARACTERS; ++i) {
+ addAction(tr(qt_controlCharacters[i].text), this, SLOT(menuActionTriggered()));
+ }
+}
+
+void QUnicodeControlCharacterMenu::menuActionTriggered()
+{
+ QAction *a = qobject_cast<QAction *>(sender());
+ int idx = actions().indexOf(a);
+ if (idx < 0 || idx >= NUM_CONTROL_CHARACTERS)
+ return;
+ QChar c(qt_controlCharacters[idx].character);
+ QString str(c);
+
+#ifndef QT_NO_TEXTEDIT
+ if (QTextEdit *edit = qobject_cast<QTextEdit *>(editWidget)) {
+ edit->insertPlainText(str);
+ return;
+ }
+#endif
+ if (QTextControl *control = qobject_cast<QTextControl *>(editWidget)) {
+ control->insertPlainText(str);
+ }
+#ifndef QT_NO_LINEEDIT
+ if (QLineEdit *edit = qobject_cast<QLineEdit *>(editWidget)) {
+ edit->insert(str);
+ return;
+ }
+#endif
+}
+#endif // QT_NO_CONTEXTMENU
+
+QStringList QTextEditMimeData::formats() const
+{
+ if (!fragment.isEmpty())
+ return QStringList() << QString::fromLatin1("text/plain") << QString::fromLatin1("text/html")
+#ifndef QT_NO_TEXTODFWRITER
+ << QString::fromLatin1("application/vnd.oasis.opendocument.text")
+#endif
+ ;
+ else
+ return QMimeData::formats();
+}
+
+QVariant QTextEditMimeData::retrieveData(const QString &mimeType, QVariant::Type type) const
+{
+ if (!fragment.isEmpty())
+ setup();
+ return QMimeData::retrieveData(mimeType, type);
+}
+
+void QTextEditMimeData::setup() const
+{
+ QTextEditMimeData *that = const_cast<QTextEditMimeData *>(this);
+#ifndef QT_NO_TEXTHTMLPARSER
+ that->setData(QLatin1String("text/html"), fragment.toHtml("utf-8").toUtf8());
+#endif
+#ifndef QT_NO_TEXTODFWRITER
+ {
+ QBuffer buffer;
+ QTextDocumentWriter writer(&buffer, "ODF");
+ writer.write(fragment);
+ buffer.close();
+ that->setData(QLatin1String("application/vnd.oasis.opendocument.text"), buffer.data());
+ }
+#endif
+ that->setText(fragment.toPlainText());
+ fragment = QTextDocumentFragment();
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qtextcontrol_p.cpp"
+
+#endif // QT_NO_TEXTCONTROL
diff --git a/src/widgets/to_be_moved/qtextcontrol_p.h b/src/widgets/to_be_moved/qtextcontrol_p.h
new file mode 100644
index 0000000000..d39cd57cf9
--- /dev/null
+++ b/src/widgets/to_be_moved/qtextcontrol_p.h
@@ -0,0 +1,307 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTEXTCONTROL_P_H
+#define QTEXTCONTROL_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtGui/qtextdocument.h>
+#include <QtGui/qtextoption.h>
+#include <QtGui/qtextcursor.h>
+#include <QtGui/qtextformat.h>
+#include <QtWidgets/qtextedit.h>
+#include <QtWidgets/qmenu.h>
+#include <QtCore/qrect.h>
+#include <QtGui/qabstracttextdocumentlayout.h>
+#include <QtGui/qtextdocumentfragment.h>
+#include <QtGui/qclipboard.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QStyleSheet;
+class QTextDocument;
+class QMenu;
+class QTextControlPrivate;
+class QMimeData;
+class QAbstractScrollArea;
+class QEvent;
+class QTimerEvent;
+
+class Q_GUI_EXPORT QTextControl : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QTextControl)
+#ifndef QT_NO_TEXTHTMLPARSER
+ Q_PROPERTY(QString html READ toHtml WRITE setHtml NOTIFY textChanged USER true)
+#endif
+ Q_PROPERTY(bool overwriteMode READ overwriteMode WRITE setOverwriteMode)
+ Q_PROPERTY(bool acceptRichText READ acceptRichText WRITE setAcceptRichText)
+ Q_PROPERTY(int cursorWidth READ cursorWidth WRITE setCursorWidth)
+ Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
+ Q_PROPERTY(bool openExternalLinks READ openExternalLinks WRITE setOpenExternalLinks)
+ Q_PROPERTY(bool ignoreUnusedNavigationEvents READ ignoreUnusedNavigationEvents WRITE setIgnoreUnusedNavigationEvents)
+public:
+ explicit QTextControl(QObject *parent = 0);
+ explicit QTextControl(const QString &text, QObject *parent = 0);
+ explicit QTextControl(QTextDocument *doc, QObject *parent = 0);
+ virtual ~QTextControl();
+
+ void setDocument(QTextDocument *document);
+ QTextDocument *document() const;
+
+ void setTextCursor(const QTextCursor &cursor);
+ QTextCursor textCursor() const;
+
+ void setTextInteractionFlags(Qt::TextInteractionFlags flags);
+ Qt::TextInteractionFlags textInteractionFlags() const;
+
+ void mergeCurrentCharFormat(const QTextCharFormat &modifier);
+
+ void setCurrentCharFormat(const QTextCharFormat &format);
+ QTextCharFormat currentCharFormat() const;
+
+ bool find(const QString &exp, QTextDocument::FindFlags options = 0);
+
+ inline QString toPlainText() const
+ { return document()->toPlainText(); }
+#ifndef QT_NO_TEXTHTMLPARSER
+ inline QString toHtml() const
+ { return document()->toHtml(); }
+#endif
+
+ virtual void ensureCursorVisible();
+
+ virtual QVariant loadResource(int type, const QUrl &name);
+#ifndef QT_NO_CONTEXTMENU
+ QMenu *createStandardContextMenu(const QPointF &pos, QWidget *parent);
+#endif
+
+ QTextCursor cursorForPosition(const QPointF &pos) const;
+ QRectF cursorRect(const QTextCursor &cursor) const;
+ QRectF cursorRect() const;
+ QRectF selectionRect(const QTextCursor &cursor) const;
+ QRectF selectionRect() const;
+
+ QString anchorAt(const QPointF &pos) const;
+ QPointF anchorPosition(const QString &name) const;
+
+ QString anchorAtCursor() const;
+
+ bool overwriteMode() const;
+ void setOverwriteMode(bool overwrite);
+
+ int cursorWidth() const;
+ void setCursorWidth(int width);
+
+ bool acceptRichText() const;
+ void setAcceptRichText(bool accept);
+
+#ifndef QT_NO_TEXTEDIT
+ void setExtraSelections(const QList<QTextEdit::ExtraSelection> &selections);
+ QList<QTextEdit::ExtraSelection> extraSelections() const;
+#endif
+
+ void setTextWidth(qreal width);
+ qreal textWidth() const;
+ QSizeF size() const;
+
+ void setOpenExternalLinks(bool open);
+ bool openExternalLinks() const;
+
+ void setIgnoreUnusedNavigationEvents(bool ignore);
+ bool ignoreUnusedNavigationEvents() const;
+
+ void moveCursor(QTextCursor::MoveOperation op, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor);
+
+ bool canPaste() const;
+
+ void setCursorIsFocusIndicator(bool b);
+ bool cursorIsFocusIndicator() const;
+
+ void setDragEnabled(bool enabled);
+ bool isDragEnabled() const;
+
+ bool isWordSelectionEnabled() const;
+ void setWordSelectionEnabled(bool enabled);
+
+#ifndef QT_NO_PRINTER
+ void print(QPrinter *printer) const;
+#endif
+
+ virtual int hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const;
+ virtual QRectF blockBoundingRect(const QTextBlock &block) const;
+ QAbstractTextDocumentLayout::PaintContext getPaintContext(QWidget *widget) const;
+
+public Q_SLOTS:
+ void setPlainText(const QString &text);
+ void setHtml(const QString &text);
+
+#ifndef QT_NO_CLIPBOARD
+ void cut();
+ void copy();
+ void paste(QClipboard::Mode mode = QClipboard::Clipboard);
+#endif
+
+ void undo();
+ void redo();
+
+ void clear();
+ void selectAll();
+
+ void insertPlainText(const QString &text);
+#ifndef QT_NO_TEXTHTMLPARSER
+ void insertHtml(const QString &text);
+#endif
+
+ void append(const QString &text);
+ void appendHtml(const QString &html);
+ void appendPlainText(const QString &text);
+
+ void adjustSize();
+
+Q_SIGNALS:
+ void textChanged();
+ void undoAvailable(bool b);
+ void redoAvailable(bool b);
+ void currentCharFormatChanged(const QTextCharFormat &format);
+ void copyAvailable(bool b);
+ void selectionChanged();
+ void cursorPositionChanged();
+
+ // control signals
+ void updateRequest(const QRectF &rect = QRectF());
+ void documentSizeChanged(const QSizeF &);
+ void blockCountChanged(int newBlockCount);
+ void visibilityRequest(const QRectF &rect);
+ void microFocusChanged();
+ void linkActivated(const QString &link);
+ void linkHovered(const QString &);
+ void modificationChanged(bool m);
+
+public:
+ // control properties
+ QPalette palette() const;
+ void setPalette(const QPalette &pal);
+
+ virtual void processEvent(QEvent *e, const QMatrix &matrix, QWidget *contextWidget = 0);
+ void processEvent(QEvent *e, const QPointF &coordinateOffset = QPointF(), QWidget *contextWidget = 0);
+
+ // control methods
+ void drawContents(QPainter *painter, const QRectF &rect = QRectF(), QWidget *widget = 0);
+
+ void setFocus(bool focus, Qt::FocusReason = Qt::OtherFocusReason);
+
+ virtual QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
+
+ virtual QMimeData *createMimeDataFromSelection() const;
+ virtual bool canInsertFromMimeData(const QMimeData *source) const;
+ virtual void insertFromMimeData(const QMimeData *source);
+
+ bool setFocusToAnchor(const QTextCursor &newCursor);
+ bool setFocusToNextOrPreviousAnchor(bool next);
+ bool findNextPrevAnchor(const QTextCursor& from, bool next, QTextCursor& newAnchor);
+
+protected:
+ virtual void timerEvent(QTimerEvent *e);
+
+ virtual bool event(QEvent *e);
+
+private:
+ Q_DISABLE_COPY(QTextControl)
+ Q_PRIVATE_SLOT(d_func(), void _q_updateCurrentCharFormatAndSelection())
+ Q_PRIVATE_SLOT(d_func(), void _q_emitCursorPosChanged(const QTextCursor &))
+ Q_PRIVATE_SLOT(d_func(), void _q_deleteSelected())
+ Q_PRIVATE_SLOT(d_func(), void _q_copyLink())
+ Q_PRIVATE_SLOT(d_func(), void _q_updateBlock(const QTextBlock &))
+ Q_PRIVATE_SLOT(d_func(), void _q_documentLayoutChanged())
+};
+
+
+#ifndef QT_NO_CONTEXTMENU
+class QUnicodeControlCharacterMenu : public QMenu
+{
+ Q_OBJECT
+public:
+ QUnicodeControlCharacterMenu(QObject *editWidget, QWidget *parent);
+
+private Q_SLOTS:
+ void menuActionTriggered();
+
+private:
+ QObject *editWidget;
+};
+#endif // QT_NO_CONTEXTMENU
+
+
+// also used by QLabel
+class QTextEditMimeData : public QMimeData
+{
+public:
+ inline QTextEditMimeData(const QTextDocumentFragment &aFragment) : fragment(aFragment) {}
+
+ virtual QStringList formats() const;
+protected:
+ virtual QVariant retrieveData(const QString &mimeType, QVariant::Type type) const;
+private:
+ void setup() const;
+
+ mutable QTextDocumentFragment fragment;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QTEXTCONTROL_H
diff --git a/src/widgets/to_be_moved/qtextcontrol_p_p.h b/src/widgets/to_be_moved/qtextcontrol_p_p.h
new file mode 100644
index 0000000000..348501c57d
--- /dev/null
+++ b/src/widgets/to_be_moved/qtextcontrol_p_p.h
@@ -0,0 +1,238 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTEXTCONTROL_P_P_H
+#define QTEXTCONTROL_P_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "QtGui/qtextdocumentfragment.h"
+#include "QtWidgets/qscrollbar.h"
+#include "QtGui/qtextcursor.h"
+#include "QtGui/qtextformat.h"
+#include "QtWidgets/qmenu.h"
+#include "QtGui/qabstracttextdocumentlayout.h"
+#include "QtCore/qbasictimer.h"
+#include "QtCore/qpointer.h"
+#include "private/qobject_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QMimeData;
+class QAbstractScrollArea;
+class QInputContext;
+
+class QTextControlPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QTextControl)
+public:
+ QTextControlPrivate();
+
+ bool cursorMoveKeyEvent(QKeyEvent *e);
+
+ void updateCurrentCharFormat();
+
+ void indent();
+ void outdent();
+
+ void gotoNextTableCell();
+ void gotoPreviousTableCell();
+
+ void createAutoBulletList();
+
+ void init(Qt::TextFormat format = Qt::RichText, const QString &text = QString(),
+ QTextDocument *document = 0);
+ void setContent(Qt::TextFormat format = Qt::RichText, const QString &text = QString(),
+ QTextDocument *document = 0);
+ void startDrag();
+
+ void paste(const QMimeData *source);
+
+ void setCursorPosition(const QPointF &pos);
+ void setCursorPosition(int pos, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor);
+
+ void repaintCursor();
+ inline void repaintSelection()
+ { repaintOldAndNewSelection(QTextCursor()); }
+ void repaintOldAndNewSelection(const QTextCursor &oldSelection);
+
+ void selectionChanged(bool forceEmitSelectionChanged = false);
+
+ void _q_updateCurrentCharFormatAndSelection();
+
+#ifndef QT_NO_CLIPBOARD
+ void setClipboardSelection();
+#endif
+
+ void _q_emitCursorPosChanged(const QTextCursor &someCursor);
+
+ void setBlinkingCursorEnabled(bool enable);
+
+ void extendWordwiseSelection(int suggestedNewPosition, qreal mouseXPosition);
+ void extendBlockwiseSelection(int suggestedNewPosition);
+
+ void _q_deleteSelected();
+
+ void _q_setCursorAfterUndoRedo(int undoPosition, int charsAdded, int charsRemoved);
+
+ QRectF cursorRectPlusUnicodeDirectionMarkers(const QTextCursor &cursor) const;
+ QRectF rectForPosition(int position) const;
+ QRectF selectionRect(const QTextCursor &cursor) const;
+ inline QRectF selectionRect() const
+ { return selectionRect(this->cursor); }
+
+ QString anchorForCursor(const QTextCursor &anchor) const;
+
+ void keyPressEvent(QKeyEvent *e);
+ void mousePressEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos,
+ Qt::KeyboardModifiers modifiers,
+ Qt::MouseButtons buttons,
+ const QPoint &globalPos);
+ void mouseMoveEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos,
+ Qt::KeyboardModifiers modifiers,
+ Qt::MouseButtons buttons,
+ const QPoint &globalPos);
+ void mouseReleaseEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos,
+ Qt::KeyboardModifiers modifiers,
+ Qt::MouseButtons buttons,
+ const QPoint &globalPos);
+ void mouseDoubleClickEvent(QEvent *e, Qt::MouseButton button, const QPointF &pos,
+ Qt::KeyboardModifiers modifiers,
+ Qt::MouseButtons buttons,
+ const QPoint &globalPos);
+ bool sendMouseEventToInputContext(QEvent *e, QEvent::Type eventType, Qt::MouseButton button,
+ const QPointF &pos,
+ Qt::KeyboardModifiers modifiers,
+ Qt::MouseButtons buttons,
+ const QPoint &globalPos);
+ void contextMenuEvent(const QPoint &screenPos, const QPointF &docPos, QWidget *contextWidget);
+ void focusEvent(QFocusEvent *e);
+#ifdef QT_KEYPAD_NAVIGATION
+ void editFocusEvent(QEvent *e);
+#endif
+ bool dragEnterEvent(QEvent *e, const QMimeData *mimeData);
+ void dragLeaveEvent();
+ bool dragMoveEvent(QEvent *e, const QMimeData *mimeData, const QPointF &pos);
+ bool dropEvent(const QMimeData *mimeData, const QPointF &pos, Qt::DropAction dropAction, QWidget *source);
+
+ void inputMethodEvent(QInputMethodEvent *);
+
+ void activateLinkUnderCursor(QString href = QString());
+
+#ifndef QT_NO_TOOLTIP
+ void showToolTip(const QPoint &globalPos, const QPointF &pos, QWidget *contextWidget);
+#endif
+
+ void append(const QString &text, Qt::TextFormat format = Qt::AutoText);
+
+ QInputContext *inputContext();
+
+ QTextDocument *doc;
+ bool cursorOn;
+ QTextCursor cursor;
+ bool cursorIsFocusIndicator;
+ QTextCharFormat lastCharFormat;
+
+ QTextCursor dndFeedbackCursor;
+
+ Qt::TextInteractionFlags interactionFlags;
+
+ QBasicTimer cursorBlinkTimer;
+ QBasicTimer trippleClickTimer;
+ QPointF trippleClickPoint;
+
+ bool dragEnabled;
+
+ bool mousePressed;
+
+ bool mightStartDrag;
+ QPoint dragStartPos;
+ QPointer<QWidget> contextWidget;
+
+ bool lastSelectionState;
+
+ bool ignoreAutomaticScrollbarAdjustement;
+
+ QTextCursor selectedWordOnDoubleClick;
+ QTextCursor selectedBlockOnTrippleClick;
+
+ bool overwriteMode;
+ bool acceptRichText;
+
+ int preeditCursor;
+ bool hideCursor; // used to hide the cursor in the preedit area
+
+ QVector<QAbstractTextDocumentLayout::Selection> extraSelections;
+
+ QPalette palette;
+ bool hasFocus;
+#ifdef QT_KEYPAD_NAVIGATION
+ bool hasEditFocus;
+#endif
+ bool isEnabled;
+
+ QString highlightedAnchor; // Anchor below cursor
+ QString anchorOnMousePress;
+ bool hadSelectionOnMousePress;
+
+ bool ignoreUnusedNavigationEvents;
+ bool openExternalLinks;
+
+ bool wordSelectionEnabled;
+
+ QString linkToCopy;
+ void _q_copyLink();
+ void _q_updateBlock(const QTextBlock &);
+ void _q_documentLayoutChanged();
+};
+
+QT_END_NAMESPACE
+
+#endif // QTEXTCONTROL_P_H
diff --git a/src/widgets/to_be_moved/to_be_moved.pri b/src/widgets/to_be_moved/to_be_moved.pri
new file mode 100644
index 0000000000..d09c568c69
--- /dev/null
+++ b/src/widgets/to_be_moved/to_be_moved.pri
@@ -0,0 +1,17 @@
+HEADERS += \
+ to_be_moved/qlinecontrol_p.h \
+ to_be_moved/qtextcontrol_p.h \
+ to_be_moved/qtextcontrol_p_p.h \
+ to_be_moved/qshortcut.h \
+ to_be_moved/qshortcutmap_p.h \
+ to_be_moved/qdrag.h \
+ to_be_moved/qdnd_p.h \
+
+SOURCES += \
+ to_be_moved/qlinecontrol.cpp \
+ to_be_moved/qtextcontrol.cpp \
+ to_be_moved/qshortcut.cpp \
+ to_be_moved/qshortcutmap.cpp \
+ to_be_moved/qdrag.cpp \
+ to_be_moved/qdnd.cpp \
+ to_be_moved/qdnd_qpa.cpp \
diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp
new file mode 100644
index 0000000000..c37ddf899a
--- /dev/null
+++ b/src/widgets/util/qcompleter.cpp
@@ -0,0 +1,1833 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \class QCompleter
+ \brief The QCompleter class provides completions based on an item model.
+ \since 4.2
+
+ You can use QCompleter to provide auto completions in any Qt
+ widget, such as QLineEdit and QComboBox.
+ When the user starts typing a word, QCompleter suggests possible ways of
+ completing the word, based on a word list. The word list is
+ provided as a QAbstractItemModel. (For simple applications, where
+ the word list is static, you can pass a QStringList to
+ QCompleter's constructor.)
+
+ \tableofcontents
+
+ \section1 Basic Usage
+
+ A QCompleter is used typically with a QLineEdit or QComboBox.
+ For example, here's how to provide auto completions from a simple
+ word list in a QLineEdit:
+
+ \snippet doc/src/snippets/code/src_gui_util_qcompleter.cpp 0
+
+ A QFileSystemModel can be used to provide auto completion of file names.
+ For example:
+
+ \snippet doc/src/snippets/code/src_gui_util_qcompleter.cpp 1
+
+ To set the model on which QCompleter should operate, call
+ setModel(). By default, QCompleter will attempt to match the \l
+ {completionPrefix}{completion prefix} (i.e., the word that the
+ user has started typing) against the Qt::EditRole data stored in
+ column 0 in the model case sensitively. This can be changed
+ using setCompletionRole(), setCompletionColumn(), and
+ setCaseSensitivity().
+
+ If the model is sorted on the column and role that are used for completion,
+ you can call setModelSorting() with either
+ QCompleter::CaseSensitivelySortedModel or
+ QCompleter::CaseInsensitivelySortedModel as the argument. On large models,
+ this can lead to significant performance improvements, because QCompleter
+ can then use binary search instead of linear search.
+
+ The model can be a \l{QAbstractListModel}{list model},
+ a \l{QAbstractTableModel}{table model}, or a
+ \l{QAbstractItemModel}{tree model}. Completion on tree models
+ is slightly more involved and is covered in the \l{Handling
+ Tree Models} section below.
+
+ The completionMode() determines the mode used to provide completions to
+ the user.
+
+ \section1 Iterating Through Completions
+
+ To retrieve a single candidate string, call setCompletionPrefix()
+ with the text that needs to be completed and call
+ currentCompletion(). You can iterate through the list of
+ completions as below:
+
+ \snippet doc/src/snippets/code/src_gui_util_qcompleter.cpp 2
+
+ completionCount() returns the total number of completions for the
+ current prefix. completionCount() should be avoided when possible,
+ since it requires a scan of the entire model.
+
+ \section1 The Completion Model
+
+ completionModel() return a list model that contains all possible
+ completions for the current completion prefix, in the order in which
+ they appear in the model. This model can be used to display the current
+ completions in a custom view. Calling setCompletionPrefix() automatically
+ refreshes the completion model.
+
+ \section1 Handling Tree Models
+
+ QCompleter can look for completions in tree models, assuming
+ that any item (or sub-item or sub-sub-item) can be unambiguously
+ represented as a string by specifying the path to the item. The
+ completion is then performed one level at a time.
+
+ Let's take the example of a user typing in a file system path.
+ The model is a (hierarchical) QFileSystemModel. The completion
+ occurs for every element in the path. For example, if the current
+ text is \c C:\Wind, QCompleter might suggest \c Windows to
+ complete the current path element. Similarly, if the current text
+ is \c C:\Windows\Sy, QCompleter might suggest \c System.
+
+ For this kind of completion to work, QCompleter needs to be able to
+ split the path into a list of strings that are matched at each level.
+ For \c C:\Windows\Sy, it needs to be split as "C:", "Windows" and "Sy".
+ The default implementation of splitPath(), splits the completionPrefix
+ using QDir::separator() if the model is a QFileSystemModel.
+
+ To provide completions, QCompleter needs to know the path from an index.
+ This is provided by pathFromIndex(). The default implementation of
+ pathFromIndex(), returns the data for the \l{Qt::EditRole}{edit role}
+ for list models and the absolute file path if the mode is a QFileSystemModel.
+
+ \sa QAbstractItemModel, QLineEdit, QComboBox, {Completer Example}
+*/
+
+#include "qcompleter_p.h"
+
+#ifndef QT_NO_COMPLETER
+
+#include "QtWidgets/qscrollbar.h"
+#include "QtWidgets/qstringlistmodel.h"
+#include "QtWidgets/qdirmodel.h"
+#include "QtWidgets/qfilesystemmodel.h"
+#include "QtWidgets/qheaderview.h"
+#include "QtWidgets/qlistview.h"
+#include "QtWidgets/qapplication.h"
+#include "QtGui/qevent.h"
+#include "QtWidgets/qheaderview.h"
+#include "QtWidgets/qdesktopwidget.h"
+#include "QtWidgets/qlineedit.h"
+
+QT_BEGIN_NAMESPACE
+
+QCompletionModel::QCompletionModel(QCompleterPrivate *c, QObject *parent)
+ : QAbstractProxyModel(*new QCompletionModelPrivate, parent),
+ c(c), showAll(false)
+{
+ createEngine();
+}
+
+int QCompletionModel::columnCount(const QModelIndex &) const
+{
+ Q_D(const QCompletionModel);
+ return d->model->columnCount();
+}
+
+void QCompletionModel::setSourceModel(QAbstractItemModel *source)
+{
+ bool hadModel = (sourceModel() != 0);
+
+ if (hadModel)
+ QObject::disconnect(sourceModel(), 0, this, 0);
+
+ QAbstractProxyModel::setSourceModel(source);
+
+ if (source) {
+ // TODO: Optimize updates in the source model
+ connect(source, SIGNAL(modelReset()), this, SLOT(invalidate()));
+ connect(source, SIGNAL(destroyed()), this, SLOT(modelDestroyed()));
+ connect(source, SIGNAL(layoutChanged()), this, SLOT(invalidate()));
+ connect(source, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(rowsInserted()));
+ connect(source, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(invalidate()));
+ connect(source, SIGNAL(columnsInserted(QModelIndex,int,int)), this, SLOT(invalidate()));
+ connect(source, SIGNAL(columnsRemoved(QModelIndex,int,int)), this, SLOT(invalidate()));
+ connect(source, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(invalidate()));
+ }
+
+ invalidate();
+}
+
+void QCompletionModel::createEngine()
+{
+ bool sortedEngine = false;
+ switch (c->sorting) {
+ case QCompleter::UnsortedModel:
+ sortedEngine = false;
+ break;
+ case QCompleter::CaseSensitivelySortedModel:
+ sortedEngine = c->cs == Qt::CaseSensitive;
+ break;
+ case QCompleter::CaseInsensitivelySortedModel:
+ sortedEngine = c->cs == Qt::CaseInsensitive;
+ break;
+ }
+
+ if (sortedEngine)
+ engine.reset(new QSortedModelEngine(c));
+ else
+ engine.reset(new QUnsortedModelEngine(c));
+}
+
+QModelIndex QCompletionModel::mapToSource(const QModelIndex& index) const
+{
+ Q_D(const QCompletionModel);
+ if (!index.isValid())
+ return engine->curParent;
+
+ int row;
+ QModelIndex parent = engine->curParent;
+ if (!showAll) {
+ if (!engine->matchCount())
+ return QModelIndex();
+ Q_ASSERT(index.row() < engine->matchCount());
+ QIndexMapper& rootIndices = engine->historyMatch.indices;
+ if (index.row() < rootIndices.count()) {
+ row = rootIndices[index.row()];
+ parent = QModelIndex();
+ } else {
+ row = engine->curMatch.indices[index.row() - rootIndices.count()];
+ }
+ } else {
+ row = index.row();
+ }
+
+ return d->model->index(row, index.column(), parent);
+}
+
+QModelIndex QCompletionModel::mapFromSource(const QModelIndex& idx) const
+{
+ if (!idx.isValid())
+ return QModelIndex();
+
+ int row = -1;
+ if (!showAll) {
+ if (!engine->matchCount())
+ return QModelIndex();
+
+ QIndexMapper& rootIndices = engine->historyMatch.indices;
+ if (idx.parent().isValid()) {
+ if (idx.parent() != engine->curParent)
+ return QModelIndex();
+ } else {
+ row = rootIndices.indexOf(idx.row());
+ if (row == -1 && engine->curParent.isValid())
+ return QModelIndex(); // source parent and our parent don't match
+ }
+
+ if (row == -1) {
+ QIndexMapper& indices = engine->curMatch.indices;
+ engine->filterOnDemand(idx.row() - indices.last());
+ row = indices.indexOf(idx.row()) + rootIndices.count();
+ }
+
+ if (row == -1)
+ return QModelIndex();
+ } else {
+ if (idx.parent() != engine->curParent)
+ return QModelIndex();
+ row = idx.row();
+ }
+
+ return createIndex(row, idx.column());
+}
+
+bool QCompletionModel::setCurrentRow(int row)
+{
+ if (row < 0 || !engine->matchCount())
+ return false;
+
+ if (row >= engine->matchCount())
+ engine->filterOnDemand(row + 1 - engine->matchCount());
+
+ if (row >= engine->matchCount()) // invalid row
+ return false;
+
+ engine->curRow = row;
+ return true;
+}
+
+QModelIndex QCompletionModel::currentIndex(bool sourceIndex) const
+{
+ if (!engine->matchCount())
+ return QModelIndex();
+
+ int row = engine->curRow;
+ if (showAll)
+ row = engine->curMatch.indices[engine->curRow];
+
+ QModelIndex idx = createIndex(row, c->column);
+ if (!sourceIndex)
+ return idx;
+ return mapToSource(idx);
+}
+
+QModelIndex QCompletionModel::index(int row, int column, const QModelIndex& parent) const
+{
+ Q_D(const QCompletionModel);
+ if (row < 0 || column < 0 || column >= columnCount(parent) || parent.isValid())
+ return QModelIndex();
+
+ if (!showAll) {
+ if (!engine->matchCount())
+ return QModelIndex();
+ if (row >= engine->historyMatch.indices.count()) {
+ int want = row + 1 - engine->matchCount();
+ if (want > 0)
+ engine->filterOnDemand(want);
+ if (row >= engine->matchCount())
+ return QModelIndex();
+ }
+ } else {
+ if (row >= d->model->rowCount(engine->curParent))
+ return QModelIndex();
+ }
+
+ return createIndex(row, column);
+}
+
+int QCompletionModel::completionCount() const
+{
+ if (!engine->matchCount())
+ return 0;
+
+ engine->filterOnDemand(INT_MAX);
+ return engine->matchCount();
+}
+
+int QCompletionModel::rowCount(const QModelIndex &parent) const
+{
+ Q_D(const QCompletionModel);
+ if (parent.isValid())
+ return 0;
+
+ if (showAll) {
+ // Show all items below current parent, even if we have no valid matches
+ if (engine->curParts.count() != 1 && !engine->matchCount()
+ && !engine->curParent.isValid())
+ return 0;
+ return d->model->rowCount(engine->curParent);
+ }
+
+ return completionCount();
+}
+
+void QCompletionModel::setFiltered(bool filtered)
+{
+ if (showAll == !filtered)
+ return;
+ showAll = !filtered;
+ resetModel();
+}
+
+bool QCompletionModel::hasChildren(const QModelIndex &parent) const
+{
+ Q_D(const QCompletionModel);
+ if (parent.isValid())
+ return false;
+
+ if (showAll)
+ return d->model->hasChildren(mapToSource(parent));
+
+ if (!engine->matchCount())
+ return false;
+
+ return true;
+}
+
+QVariant QCompletionModel::data(const QModelIndex& index, int role) const
+{
+ Q_D(const QCompletionModel);
+ return d->model->data(mapToSource(index), role);
+}
+
+void QCompletionModel::modelDestroyed()
+{
+ QAbstractProxyModel::setSourceModel(0); // switch to static empty model
+ invalidate();
+}
+
+void QCompletionModel::rowsInserted()
+{
+ invalidate();
+ emit rowsAdded();
+}
+
+void QCompletionModel::invalidate()
+{
+ engine->cache.clear();
+ filter(engine->curParts);
+}
+
+void QCompletionModel::filter(const QStringList& parts)
+{
+ Q_D(QCompletionModel);
+ engine->filter(parts);
+ resetModel();
+
+ if (d->model->canFetchMore(engine->curParent))
+ d->model->fetchMore(engine->curParent);
+}
+
+void QCompletionModel::resetModel()
+{
+ if (rowCount() == 0) {
+ reset();
+ return;
+ }
+
+ emit layoutAboutToBeChanged();
+ QModelIndexList piList = persistentIndexList();
+ QModelIndexList empty;
+ for (int i = 0; i < piList.size(); i++)
+ empty.append(QModelIndex());
+ changePersistentIndexList(piList, empty);
+ emit layoutChanged();
+}
+
+//////////////////////////////////////////////////////////////////////////////
+void QCompletionEngine::filter(const QStringList& parts)
+{
+ const QAbstractItemModel *model = c->proxy->sourceModel();
+ curParts = parts;
+ if (curParts.isEmpty())
+ curParts.append(QString());
+
+ curRow = -1;
+ curParent = QModelIndex();
+ curMatch = QMatchData();
+ historyMatch = filterHistory();
+
+ if (!model)
+ return;
+
+ QModelIndex parent;
+ for (int i = 0; i < curParts.count() - 1; i++) {
+ QString part = curParts[i];
+ int emi = filter(part, parent, -1).exactMatchIndex;
+ if (emi == -1)
+ return;
+ parent = model->index(emi, c->column, parent);
+ }
+
+ // Note that we set the curParent to a valid parent, even if we have no matches
+ // When filtering is disabled, we show all the items under this parent
+ curParent = parent;
+ if (curParts.last().isEmpty())
+ curMatch = QMatchData(QIndexMapper(0, model->rowCount(curParent) - 1), -1, false);
+ else
+ curMatch = filter(curParts.last(), curParent, 1); // build at least one
+ curRow = curMatch.isValid() ? 0 : -1;
+}
+
+QMatchData QCompletionEngine::filterHistory()
+{
+ QAbstractItemModel *source = c->proxy->sourceModel();
+ if (curParts.count() <= 1 || c->proxy->showAll || !source)
+ return QMatchData();
+ bool isDirModel = false;
+ bool isFsModel = false;
+#ifndef QT_NO_DIRMODEL
+ isDirModel = (qobject_cast<QDirModel *>(source) != 0);
+#endif
+#ifndef QT_NO_FILESYSTEMMODEL
+ isFsModel = (qobject_cast<QFileSystemModel *>(source) != 0);
+#endif
+ QVector<int> v;
+ QIndexMapper im(v);
+ QMatchData m(im, -1, true);
+
+ for (int i = 0; i < source->rowCount(); i++) {
+ QString str = source->index(i, c->column).data().toString();
+ if (str.startsWith(c->prefix, c->cs)
+#if (!defined(Q_OS_WIN) || defined(Q_OS_WINCE)) && !defined(Q_OS_SYMBIAN)
+ && ((!isFsModel && !isDirModel) || QDir::toNativeSeparators(str) != QDir::separator())
+#endif
+ )
+ m.indices.append(i);
+ }
+ return m;
+}
+
+// Returns a match hint from the cache by chopping the search string
+bool QCompletionEngine::matchHint(QString part, const QModelIndex& parent, QMatchData *hint)
+{
+ if (c->cs == Qt::CaseInsensitive)
+ part = part.toLower();
+
+ const CacheItem& map = cache[parent];
+
+ QString key = part;
+ while (!key.isEmpty()) {
+ key.chop(1);
+ if (map.contains(key)) {
+ *hint = map[key];
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool QCompletionEngine::lookupCache(QString part, const QModelIndex& parent, QMatchData *m)
+{
+ if (c->cs == Qt::CaseInsensitive)
+ part = part.toLower();
+ const CacheItem& map = cache[parent];
+ if (!map.contains(part))
+ return false;
+ *m = map[part];
+ return true;
+}
+
+// When the cache size exceeds 1MB, it clears out about 1/2 of the cache.
+void QCompletionEngine::saveInCache(QString part, const QModelIndex& parent, const QMatchData& m)
+{
+ QMatchData old = cache[parent].take(part);
+ cost = cost + m.indices.cost() - old.indices.cost();
+ if (cost * sizeof(int) > 1024 * 1024) {
+ QMap<QModelIndex, CacheItem>::iterator it1 = cache.begin();
+ while (it1 != cache.end()) {
+ CacheItem& ci = it1.value();
+ int sz = ci.count()/2;
+ QMap<QString, QMatchData>::iterator it2 = ci.begin();
+ int i = 0;
+ while (it2 != ci.end() && i < sz) {
+ cost -= it2.value().indices.cost();
+ it2 = ci.erase(it2);
+ i++;
+ }
+ if (ci.count() == 0) {
+ it1 = cache.erase(it1);
+ } else {
+ ++it1;
+ }
+ }
+ }
+
+ if (c->cs == Qt::CaseInsensitive)
+ part = part.toLower();
+ cache[parent][part] = m;
+}
+
+///////////////////////////////////////////////////////////////////////////////////
+QIndexMapper QSortedModelEngine::indexHint(QString part, const QModelIndex& parent, Qt::SortOrder order)
+{
+ const QAbstractItemModel *model = c->proxy->sourceModel();
+
+ if (c->cs == Qt::CaseInsensitive)
+ part = part.toLower();
+
+ const CacheItem& map = cache[parent];
+
+ // Try to find a lower and upper bound for the search from previous results
+ int to = model->rowCount(parent) - 1;
+ int from = 0;
+ const CacheItem::const_iterator it = map.lowerBound(part);
+
+ // look backward for first valid hint
+ for(CacheItem::const_iterator it1 = it; it1-- != map.constBegin();) {
+ const QMatchData& value = it1.value();
+ if (value.isValid()) {
+ if (order == Qt::AscendingOrder) {
+ from = value.indices.last() + 1;
+ } else {
+ to = value.indices.first() - 1;
+ }
+ break;
+ }
+ }
+
+ // look forward for first valid hint
+ for(CacheItem::const_iterator it2 = it; it2 != map.constEnd(); ++it2) {
+ const QMatchData& value = it2.value();
+ if (value.isValid() && !it2.key().startsWith(part)) {
+ if (order == Qt::AscendingOrder) {
+ to = value.indices.first() - 1;
+ } else {
+ from = value.indices.first() + 1;
+ }
+ break;
+ }
+ }
+
+ return QIndexMapper(from, to);
+}
+
+Qt::SortOrder QSortedModelEngine::sortOrder(const QModelIndex &parent) const
+{
+ const QAbstractItemModel *model = c->proxy->sourceModel();
+
+ int rowCount = model->rowCount(parent);
+ if (rowCount < 2)
+ return Qt::AscendingOrder;
+ QString first = model->data(model->index(0, c->column, parent), c->role).toString();
+ QString last = model->data(model->index(rowCount - 1, c->column, parent), c->role).toString();
+ return QString::compare(first, last, c->cs) <= 0 ? Qt::AscendingOrder : Qt::DescendingOrder;
+}
+
+QMatchData QSortedModelEngine::filter(const QString& part, const QModelIndex& parent, int)
+{
+ const QAbstractItemModel *model = c->proxy->sourceModel();
+
+ QMatchData hint;
+ if (lookupCache(part, parent, &hint))
+ return hint;
+
+ QIndexMapper indices;
+ Qt::SortOrder order = sortOrder(parent);
+
+ if (matchHint(part, parent, &hint)) {
+ if (!hint.isValid())
+ return QMatchData();
+ indices = hint.indices;
+ } else {
+ indices = indexHint(part, parent, order);
+ }
+
+ // binary search the model within 'indices' for 'part' under 'parent'
+ int high = indices.to() + 1;
+ int low = indices.from() - 1;
+ int probe;
+ QModelIndex probeIndex;
+ QString probeData;
+
+ while (high - low > 1)
+ {
+ probe = (high + low) / 2;
+ probeIndex = model->index(probe, c->column, parent);
+ probeData = model->data(probeIndex, c->role).toString();
+ const int cmp = QString::compare(probeData, part, c->cs);
+ if ((order == Qt::AscendingOrder && cmp >= 0)
+ || (order == Qt::DescendingOrder && cmp < 0)) {
+ high = probe;
+ } else {
+ low = probe;
+ }
+ }
+
+ if ((order == Qt::AscendingOrder && low == indices.to())
+ || (order == Qt::DescendingOrder && high == indices.from())) { // not found
+ saveInCache(part, parent, QMatchData());
+ return QMatchData();
+ }
+
+ probeIndex = model->index(order == Qt::AscendingOrder ? low+1 : high-1, c->column, parent);
+ probeData = model->data(probeIndex, c->role).toString();
+ if (!probeData.startsWith(part, c->cs)) {
+ saveInCache(part, parent, QMatchData());
+ return QMatchData();
+ }
+
+ const bool exactMatch = QString::compare(probeData, part, c->cs) == 0;
+ int emi = exactMatch ? (order == Qt::AscendingOrder ? low+1 : high-1) : -1;
+
+ int from = 0;
+ int to = 0;
+ if (order == Qt::AscendingOrder) {
+ from = low + 1;
+ high = indices.to() + 1;
+ low = from;
+ } else {
+ to = high - 1;
+ low = indices.from() - 1;
+ high = to;
+ }
+
+ while (high - low > 1)
+ {
+ probe = (high + low) / 2;
+ probeIndex = model->index(probe, c->column, parent);
+ probeData = model->data(probeIndex, c->role).toString();
+ const bool startsWith = probeData.startsWith(part, c->cs);
+ if ((order == Qt::AscendingOrder && startsWith)
+ || (order == Qt::DescendingOrder && !startsWith)) {
+ low = probe;
+ } else {
+ high = probe;
+ }
+ }
+
+ QMatchData m(order == Qt::AscendingOrder ? QIndexMapper(from, high - 1) : QIndexMapper(low+1, to), emi, false);
+ saveInCache(part, parent, m);
+ return m;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////
+int QUnsortedModelEngine::buildIndices(const QString& str, const QModelIndex& parent, int n,
+ const QIndexMapper& indices, QMatchData* m)
+{
+ Q_ASSERT(m->partial);
+ Q_ASSERT(n != -1 || m->exactMatchIndex == -1);
+ const QAbstractItemModel *model = c->proxy->sourceModel();
+ int i, count = 0;
+
+ for (i = 0; i < indices.count() && count != n; ++i) {
+ QModelIndex idx = model->index(indices[i], c->column, parent);
+ QString data = model->data(idx, c->role).toString();
+ if (!data.startsWith(str, c->cs) || !(model->flags(idx) & Qt::ItemIsSelectable))
+ continue;
+ m->indices.append(indices[i]);
+ ++count;
+ if (m->exactMatchIndex == -1 && QString::compare(data, str, c->cs) == 0) {
+ m->exactMatchIndex = indices[i];
+ if (n == -1)
+ return indices[i];
+ }
+ }
+ return indices[i-1];
+}
+
+void QUnsortedModelEngine::filterOnDemand(int n)
+{
+ Q_ASSERT(matchCount());
+ if (!curMatch.partial)
+ return;
+ Q_ASSERT(n >= -1);
+ const QAbstractItemModel *model = c->proxy->sourceModel();
+ int lastRow = model->rowCount(curParent) - 1;
+ QIndexMapper im(curMatch.indices.last() + 1, lastRow);
+ int lastIndex = buildIndices(curParts.last(), curParent, n, im, &curMatch);
+ curMatch.partial = (lastRow != lastIndex);
+ saveInCache(curParts.last(), curParent, curMatch);
+}
+
+QMatchData QUnsortedModelEngine::filter(const QString& part, const QModelIndex& parent, int n)
+{
+ QMatchData hint;
+
+ QVector<int> v;
+ QIndexMapper im(v);
+ QMatchData m(im, -1, true);
+
+ const QAbstractItemModel *model = c->proxy->sourceModel();
+ bool foundInCache = lookupCache(part, parent, &m);
+
+ if (!foundInCache) {
+ if (matchHint(part, parent, &hint) && !hint.isValid())
+ return QMatchData();
+ }
+
+ if (!foundInCache && !hint.isValid()) {
+ const int lastRow = model->rowCount(parent) - 1;
+ QIndexMapper all(0, lastRow);
+ int lastIndex = buildIndices(part, parent, n, all, &m);
+ m.partial = (lastIndex != lastRow);
+ } else {
+ if (!foundInCache) { // build from hint as much as we can
+ buildIndices(part, parent, INT_MAX, hint.indices, &m);
+ m.partial = hint.partial;
+ }
+ if (m.partial && ((n == -1 && m.exactMatchIndex == -1) || (m.indices.count() < n))) {
+ // need more and have more
+ const int lastRow = model->rowCount(parent) - 1;
+ QIndexMapper rest(hint.indices.last() + 1, lastRow);
+ int want = n == -1 ? -1 : n - m.indices.count();
+ int lastIndex = buildIndices(part, parent, want, rest, &m);
+ m.partial = (lastRow != lastIndex);
+ }
+ }
+
+ saveInCache(part, parent, m);
+ return m;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+QCompleterPrivate::QCompleterPrivate()
+: widget(0), proxy(0), popup(0), cs(Qt::CaseSensitive), role(Qt::EditRole), column(0),
+ maxVisibleItems(7), sorting(QCompleter::UnsortedModel), wrap(true), eatFocusOut(true),
+ hiddenBecauseNoMatch(false)
+{
+}
+
+void QCompleterPrivate::init(QAbstractItemModel *m)
+{
+ Q_Q(QCompleter);
+ proxy = new QCompletionModel(this, q);
+ QObject::connect(proxy, SIGNAL(rowsAdded()), q, SLOT(_q_autoResizePopup()));
+ q->setModel(m);
+#ifdef QT_NO_LISTVIEW
+ q->setCompletionMode(QCompleter::InlineCompletion);
+#else
+ q->setCompletionMode(QCompleter::PopupCompletion);
+#endif // QT_NO_LISTVIEW
+}
+
+void QCompleterPrivate::setCurrentIndex(QModelIndex index, bool select)
+{
+ Q_Q(QCompleter);
+ if (!q->popup())
+ return;
+ if (!select) {
+ popup->selectionModel()->setCurrentIndex(index, QItemSelectionModel::NoUpdate);
+ } else {
+ if (!index.isValid())
+ popup->selectionModel()->clear();
+ else
+ popup->selectionModel()->setCurrentIndex(index, QItemSelectionModel::Select
+ | QItemSelectionModel::Rows);
+ }
+ index = popup->selectionModel()->currentIndex();
+ if (!index.isValid())
+ popup->scrollToTop();
+ else
+ popup->scrollTo(index, QAbstractItemView::PositionAtTop);
+}
+
+void QCompleterPrivate::_q_completionSelected(const QItemSelection& selection)
+{
+ QModelIndex index;
+ if (!selection.indexes().isEmpty())
+ index = selection.indexes().first();
+
+ _q_complete(index, true);
+}
+
+void QCompleterPrivate::_q_complete(QModelIndex index, bool highlighted)
+{
+ Q_Q(QCompleter);
+ QString completion;
+
+ if (!index.isValid() || (!proxy->showAll && (index.row() >= proxy->engine->matchCount()))) {
+ completion = prefix;
+ } else {
+ if (!(index.flags() & Qt::ItemIsEnabled))
+ return;
+ QModelIndex si = proxy->mapToSource(index);
+ si = si.sibling(si.row(), column); // for clicked()
+ completion = q->pathFromIndex(si);
+#ifndef QT_NO_DIRMODEL
+ // add a trailing separator in inline
+ if (mode == QCompleter::InlineCompletion) {
+ if (qobject_cast<QDirModel *>(proxy->sourceModel()) && QFileInfo(completion).isDir())
+ completion += QDir::separator();
+ }
+#endif
+#ifndef QT_NO_FILESYSTEMMODEL
+ // add a trailing separator in inline
+ if (mode == QCompleter::InlineCompletion) {
+ if (qobject_cast<QFileSystemModel *>(proxy->sourceModel()) && QFileInfo(completion).isDir())
+ completion += QDir::separator();
+ }
+#endif
+ }
+
+ if (highlighted) {
+ emit q->highlighted(index);
+ emit q->highlighted(completion);
+ } else {
+ emit q->activated(index);
+ emit q->activated(completion);
+ }
+}
+
+void QCompleterPrivate::_q_autoResizePopup()
+{
+ if (!popup || !popup->isVisible())
+ return;
+ showPopup(popupRect);
+}
+
+void QCompleterPrivate::showPopup(const QRect& rect)
+{
+ const QRect screen = QApplication::desktop()->availableGeometry(widget);
+ Qt::LayoutDirection dir = widget->layoutDirection();
+ QPoint pos;
+ int rh, w;
+ int h = (popup->sizeHintForRow(0) * qMin(maxVisibleItems, popup->model()->rowCount()) + 3) + 3;
+ QScrollBar *hsb = popup->horizontalScrollBar();
+ if (hsb && hsb->isVisible())
+ h += popup->horizontalScrollBar()->sizeHint().height();
+
+ if (rect.isValid()) {
+ rh = rect.height();
+ w = rect.width();
+ pos = widget->mapToGlobal(dir == Qt::RightToLeft ? rect.bottomRight() : rect.bottomLeft());
+ } else {
+ rh = widget->height();
+ pos = widget->mapToGlobal(QPoint(0, widget->height() - 2));
+ w = widget->width();
+ }
+
+ if (w > screen.width())
+ w = screen.width();
+ if ((pos.x() + w) > (screen.x() + screen.width()))
+ pos.setX(screen.x() + screen.width() - w);
+ if (pos.x() < screen.x())
+ pos.setX(screen.x());
+
+ int top = pos.y() - rh - screen.top() + 2;
+ int bottom = screen.bottom() - pos.y();
+ h = qMax(h, popup->minimumHeight());
+ if (h > bottom) {
+ h = qMin(qMax(top, bottom), h);
+
+ if (top > bottom)
+ pos.setY(pos.y() - h - rh + 2);
+ }
+
+ popup->setGeometry(pos.x(), pos.y(), w, h);
+
+ if (!popup->isVisible())
+ popup->show();
+}
+
+void QCompleterPrivate::_q_fileSystemModelDirectoryLoaded(const QString &path)
+{
+ Q_Q(QCompleter);
+ // Slot called when QFileSystemModel has finished loading.
+ // If we hide the popup because there was no match because the model was not loaded yet,
+ // we re-start the completion when we get the results
+ if (hiddenBecauseNoMatch
+ && prefix.startsWith(path) && prefix != (path + QLatin1Char('/'))
+ && widget) {
+ q->complete();
+ }
+}
+
+/*!
+ Constructs a completer object with the given \a parent.
+*/
+QCompleter::QCompleter(QObject *parent)
+: QObject(*new QCompleterPrivate(), parent)
+{
+ Q_D(QCompleter);
+ d->init();
+}
+
+/*!
+ Constructs a completer object with the given \a parent that provides completions
+ from the specified \a model.
+*/
+QCompleter::QCompleter(QAbstractItemModel *model, QObject *parent)
+ : QObject(*new QCompleterPrivate(), parent)
+{
+ Q_D(QCompleter);
+ d->init(model);
+}
+
+#ifndef QT_NO_STRINGLISTMODEL
+/*!
+ Constructs a QCompleter object with the given \a parent that uses the specified
+ \a list as a source of possible completions.
+*/
+QCompleter::QCompleter(const QStringList& list, QObject *parent)
+: QObject(*new QCompleterPrivate(), parent)
+{
+ Q_D(QCompleter);
+ d->init(new QStringListModel(list, this));
+}
+#endif // QT_NO_STRINGLISTMODEL
+
+/*!
+ Destroys the completer object.
+*/
+QCompleter::~QCompleter()
+{
+}
+
+/*!
+ Sets the widget for which completion are provided for to \a widget. This
+ function is automatically called when a QCompleter is set on a QLineEdit
+ using QLineEdit::setCompleter() or on a QComboBox using
+ QComboBox::setCompleter(). The widget needs to be set explicitly when
+ providing completions for custom widgets.
+
+ \sa widget(), setModel(), setPopup()
+ */
+void QCompleter::setWidget(QWidget *widget)
+{
+ Q_D(QCompleter);
+ if (d->widget)
+ d->widget->removeEventFilter(this);
+ d->widget = widget;
+ if (d->widget)
+ d->widget->installEventFilter(this);
+ if (d->popup) {
+ d->popup->hide();
+ d->popup->setFocusProxy(d->widget);
+ }
+}
+
+/*!
+ Returns the widget for which the completer object is providing completions.
+
+ \sa setWidget()
+ */
+QWidget *QCompleter::widget() const
+{
+ Q_D(const QCompleter);
+ return d->widget;
+}
+
+/*!
+ Sets the model which provides completions to \a model. The \a model can
+ be list model or a tree model. If a model has been already previously set
+ and it has the QCompleter as its parent, it is deleted.
+
+ For convenience, if \a model is a QFileSystemModel, QCompleter switches its
+ caseSensitivity to Qt::CaseInsensitive on Windows and Qt::CaseSensitive
+ on other platforms.
+
+ \sa completionModel(), modelSorting, {Handling Tree Models}
+*/
+void QCompleter::setModel(QAbstractItemModel *model)
+{
+ Q_D(QCompleter);
+ QAbstractItemModel *oldModel = d->proxy->sourceModel();
+ d->proxy->setSourceModel(model);
+ if (d->popup)
+ setPopup(d->popup); // set the model and make new connections
+ if (oldModel && oldModel->QObject::parent() == this)
+ delete oldModel;
+#ifndef QT_NO_DIRMODEL
+ if (qobject_cast<QDirModel *>(model)) {
+#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN)
+ setCaseSensitivity(Qt::CaseInsensitive);
+#else
+ setCaseSensitivity(Qt::CaseSensitive);
+#endif
+ }
+#endif // QT_NO_DIRMODEL
+#ifndef QT_NO_FILESYSTEMMODEL
+ QFileSystemModel *fsModel = qobject_cast<QFileSystemModel *>(model);
+ if (fsModel) {
+#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) || defined(Q_OS_SYMBIAN)
+ setCaseSensitivity(Qt::CaseInsensitive);
+#else
+ setCaseSensitivity(Qt::CaseSensitive);
+#endif
+ setCompletionRole(QFileSystemModel::FileNameRole);
+ connect(fsModel, SIGNAL(directoryLoaded(QString)), this, SLOT(_q_fileSystemModelDirectoryLoaded(QString)));
+ }
+#endif // QT_NO_FILESYSTEMMODEL
+}
+
+/*!
+ Returns the model that provides completion strings.
+
+ \sa completionModel()
+*/
+QAbstractItemModel *QCompleter::model() const
+{
+ Q_D(const QCompleter);
+ return d->proxy->sourceModel();
+}
+
+/*!
+ \enum QCompleter::CompletionMode
+
+ This enum specifies how completions are provided to the user.
+
+ \value PopupCompletion Current completions are displayed in a popup window.
+ \value InlineCompletion Completions appear inline (as selected text).
+ \value UnfilteredPopupCompletion All possible completions are displayed in a popup window with the most likely suggestion indicated as current.
+
+ \sa setCompletionMode()
+*/
+
+/*!
+ \property QCompleter::completionMode
+ \brief how the completions are provided to the user
+
+ The default value is QCompleter::PopupCompletion.
+*/
+void QCompleter::setCompletionMode(QCompleter::CompletionMode mode)
+{
+ Q_D(QCompleter);
+ d->mode = mode;
+ d->proxy->setFiltered(mode != QCompleter::UnfilteredPopupCompletion);
+
+ if (mode == QCompleter::InlineCompletion) {
+ if (d->widget)
+ d->widget->removeEventFilter(this);
+ if (d->popup) {
+ d->popup->deleteLater();
+ d->popup = 0;
+ }
+ } else {
+ if (d->widget)
+ d->widget->installEventFilter(this);
+ }
+}
+
+QCompleter::CompletionMode QCompleter::completionMode() const
+{
+ Q_D(const QCompleter);
+ return d->mode;
+}
+
+/*!
+ Sets the popup used to display completions to \a popup. QCompleter takes
+ ownership of the view.
+
+ A QListView is automatically created when the completionMode() is set to
+ QCompleter::PopupCompletion or QCompleter::UnfilteredPopupCompletion. The
+ default popup displays the completionColumn().
+
+ Ensure that this function is called before the view settings are modified.
+ This is required since view's properties may require that a model has been
+ set on the view (for example, hiding columns in the view requires a model
+ to be set on the view).
+
+ \sa popup()
+*/
+void QCompleter::setPopup(QAbstractItemView *popup)
+{
+ Q_D(QCompleter);
+ Q_ASSERT(popup != 0);
+ if (d->popup) {
+ QObject::disconnect(d->popup->selectionModel(), 0, this, 0);
+ QObject::disconnect(d->popup, 0, this, 0);
+ }
+ if (d->popup != popup)
+ delete d->popup;
+ if (popup->model() != d->proxy)
+ popup->setModel(d->proxy);
+#if defined(Q_OS_MAC) && !defined(QT_MAC_USE_COCOA)
+ popup->show();
+#else
+ popup->hide();
+#endif
+
+ Qt::FocusPolicy origPolicy = Qt::NoFocus;
+ if (d->widget)
+ origPolicy = d->widget->focusPolicy();
+ popup->setParent(0, Qt::Popup);
+ popup->setFocusPolicy(Qt::NoFocus);
+ if (d->widget)
+ d->widget->setFocusPolicy(origPolicy);
+
+ popup->setFocusProxy(d->widget);
+ popup->installEventFilter(this);
+ popup->setItemDelegate(new QCompleterItemDelegate(popup));
+#ifndef QT_NO_LISTVIEW
+ if (QListView *listView = qobject_cast<QListView *>(popup)) {
+ listView->setModelColumn(d->column);
+ }
+#endif
+
+ QObject::connect(popup, SIGNAL(clicked(QModelIndex)),
+ this, SLOT(_q_complete(QModelIndex)));
+ QObject::connect(this, SIGNAL(activated(QModelIndex)),
+ popup, SLOT(hide()));
+
+ QObject::connect(popup->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
+ this, SLOT(_q_completionSelected(QItemSelection)));
+ d->popup = popup;
+}
+
+/*!
+ Returns the popup used to display completions.
+
+ \sa setPopup()
+*/
+QAbstractItemView *QCompleter::popup() const
+{
+ Q_D(const QCompleter);
+#ifndef QT_NO_LISTVIEW
+ if (!d->popup && completionMode() != QCompleter::InlineCompletion) {
+ QListView *listView = new QListView;
+ listView->setEditTriggers(QAbstractItemView::NoEditTriggers);
+ listView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ listView->setSelectionBehavior(QAbstractItemView::SelectRows);
+ listView->setSelectionMode(QAbstractItemView::SingleSelection);
+ listView->setModelColumn(d->column);
+ QCompleter *that = const_cast<QCompleter*>(this);
+ that->setPopup(listView);
+ }
+#endif // QT_NO_LISTVIEW
+ return d->popup;
+}
+
+/*!
+ \reimp
+*/
+bool QCompleter::event(QEvent *ev)
+{
+ return QObject::event(ev);
+}
+
+/*!
+ \reimp
+*/
+bool QCompleter::eventFilter(QObject *o, QEvent *e)
+{
+ Q_D(QCompleter);
+
+ if (d->eatFocusOut && o == d->widget && e->type() == QEvent::FocusOut) {
+ d->hiddenBecauseNoMatch = false;
+ if (d->popup && d->popup->isVisible())
+ return true;
+ }
+
+ if (o != d->popup)
+ return QObject::eventFilter(o, e);
+
+ switch (e->type()) {
+ case QEvent::KeyPress: {
+ QKeyEvent *ke = static_cast<QKeyEvent *>(e);
+
+ QModelIndex curIndex = d->popup->currentIndex();
+ QModelIndexList selList = d->popup->selectionModel()->selectedIndexes();
+
+ const int key = ke->key();
+ // In UnFilteredPopup mode, select the current item
+ if ((key == Qt::Key_Up || key == Qt::Key_Down) && selList.isEmpty() && curIndex.isValid()
+ && d->mode == QCompleter::UnfilteredPopupCompletion) {
+ d->setCurrentIndex(curIndex);
+ return true;
+ }
+
+ // Handle popup navigation keys. These are hardcoded because up/down might make the
+ // widget do something else (lineedit cursor moves to home/end on mac, for instance)
+ switch (key) {
+ case Qt::Key_End:
+ case Qt::Key_Home:
+ if (ke->modifiers() & Qt::ControlModifier)
+ return false;
+ break;
+
+ case Qt::Key_Up:
+ if (!curIndex.isValid()) {
+ int rowCount = d->proxy->rowCount();
+ QModelIndex lastIndex = d->proxy->index(rowCount - 1, d->column);
+ d->setCurrentIndex(lastIndex);
+ return true;
+ } else if (curIndex.row() == 0) {
+ if (d->wrap)
+ d->setCurrentIndex(QModelIndex());
+ return true;
+ }
+ return false;
+
+ case Qt::Key_Down:
+ if (!curIndex.isValid()) {
+ QModelIndex firstIndex = d->proxy->index(0, d->column);
+ d->setCurrentIndex(firstIndex);
+ return true;
+ } else if (curIndex.row() == d->proxy->rowCount() - 1) {
+ if (d->wrap)
+ d->setCurrentIndex(QModelIndex());
+ return true;
+ }
+ return false;
+
+ case Qt::Key_PageUp:
+ case Qt::Key_PageDown:
+ return false;
+ }
+
+ // Send the event to the widget. If the widget accepted the event, do nothing
+ // If the widget did not accept the event, provide a default implementation
+ d->eatFocusOut = false;
+ (static_cast<QObject *>(d->widget))->event(ke);
+ d->eatFocusOut = true;
+ if (!d->widget || e->isAccepted() || !d->popup->isVisible()) {
+ // widget lost focus, hide the popup
+ if (d->widget && (!d->widget->hasFocus()
+#ifdef QT_KEYPAD_NAVIGATION
+ || (QApplication::keypadNavigationEnabled() && !d->widget->hasEditFocus())
+#endif
+ ))
+ d->popup->hide();
+ if (e->isAccepted())
+ return true;
+ }
+
+ // default implementation for keys not handled by the widget when popup is open
+ switch (key) {
+#ifdef QT_KEYPAD_NAVIGATION
+ case Qt::Key_Select:
+ if (!QApplication::keypadNavigationEnabled())
+ break;
+#endif
+ case Qt::Key_Return:
+ case Qt::Key_Enter:
+ case Qt::Key_Tab:
+ d->popup->hide();
+ if (curIndex.isValid())
+ d->_q_complete(curIndex);
+ break;
+
+ case Qt::Key_F4:
+ if (ke->modifiers() & Qt::AltModifier)
+ d->popup->hide();
+ break;
+
+ case Qt::Key_Backtab:
+ case Qt::Key_Escape:
+ d->popup->hide();
+ break;
+
+ default:
+ break;
+ }
+
+ return true;
+ }
+
+#ifdef QT_KEYPAD_NAVIGATION
+ case QEvent::KeyRelease: {
+ QKeyEvent *ke = static_cast<QKeyEvent *>(e);
+ if (QApplication::keypadNavigationEnabled() && ke->key() == Qt::Key_Back) {
+ // Send the event to the 'widget'. This is what we did for KeyPress, so we need
+ // to do the same for KeyRelease, in case the widget's KeyPress event set
+ // up something (such as a timer) that is relying on also receiving the
+ // key release. I see this as a bug in Qt, and should really set it up for all
+ // the affected keys. However, it is difficult to tell how this will affect
+ // existing code, and I can't test for every combination!
+ d->eatFocusOut = false;
+ static_cast<QObject *>(d->widget)->event(ke);
+ d->eatFocusOut = true;
+ }
+ break;
+ }
+#endif
+
+ case QEvent::MouseButtonPress: {
+#ifdef QT_KEYPAD_NAVIGATION
+ if (QApplication::keypadNavigationEnabled()) {
+ // if we've clicked in the widget (or its descendant), let it handle the click
+ QWidget *source = qobject_cast<QWidget *>(o);
+ if (source) {
+ QPoint pos = source->mapToGlobal((static_cast<QMouseEvent *>(e))->pos());
+ QWidget *target = QApplication::widgetAt(pos);
+ if (target && (d->widget->isAncestorOf(target) ||
+ target == d->widget)) {
+ d->eatFocusOut = false;
+ static_cast<QObject *>(target)->event(e);
+ d->eatFocusOut = true;
+ return true;
+ }
+ }
+ }
+#endif
+ if (!d->popup->underMouse()) {
+ d->popup->hide();
+ return true;
+ }
+ }
+ return false;
+
+ case QEvent::InputMethod:
+ case QEvent::ShortcutOverride:
+ QApplication::sendEvent(d->widget, e);
+ break;
+
+ default:
+ return false;
+ }
+ return false;
+}
+
+/*!
+ For QCompleter::PopupCompletion and QCompletion::UnfilteredPopupCompletion
+ modes, calling this function displays the popup displaying the current
+ completions. By default, if \a rect is not specified, the popup is displayed
+ on the bottom of the widget(). If \a rect is specified the popup is
+ displayed on the left edge of the rectangle.
+
+ For QCompleter::InlineCompletion mode, the highlighted() signal is fired
+ with the current completion.
+*/
+void QCompleter::complete(const QRect& rect)
+{
+ Q_D(QCompleter);
+ QModelIndex idx = d->proxy->currentIndex(false);
+ d->hiddenBecauseNoMatch = false;
+ if (d->mode == QCompleter::InlineCompletion) {
+ if (idx.isValid())
+ d->_q_complete(idx, true);
+ return;
+ }
+
+ Q_ASSERT(d->widget != 0);
+ if ((d->mode == QCompleter::PopupCompletion && !idx.isValid())
+ || (d->mode == QCompleter::UnfilteredPopupCompletion && d->proxy->rowCount() == 0)) {
+ if (d->popup)
+ d->popup->hide(); // no suggestion, hide
+ d->hiddenBecauseNoMatch = true;
+ return;
+ }
+
+ popup();
+ if (d->mode == QCompleter::UnfilteredPopupCompletion)
+ d->setCurrentIndex(idx, false);
+
+ d->showPopup(rect);
+ d->popupRect = rect;
+}
+
+/*!
+ Sets the current row to the \a row specified. Returns true if successful;
+ otherwise returns false.
+
+ This function may be used along with currentCompletion() to iterate
+ through all the possible completions.
+
+ \sa currentCompletion(), completionCount()
+*/
+bool QCompleter::setCurrentRow(int row)
+{
+ Q_D(QCompleter);
+ return d->proxy->setCurrentRow(row);
+}
+
+/*!
+ Returns the current row.
+
+ \sa setCurrentRow()
+*/
+int QCompleter::currentRow() const
+{
+ Q_D(const QCompleter);
+ return d->proxy->currentRow();
+}
+
+/*!
+ Returns the number of completions for the current prefix. For an unsorted
+ model with a large number of items this can be expensive. Use setCurrentRow()
+ and currentCompletion() to iterate through all the completions.
+*/
+int QCompleter::completionCount() const
+{
+ Q_D(const QCompleter);
+ return d->proxy->completionCount();
+}
+
+/*!
+ \enum QCompleter::ModelSorting
+
+ This enum specifies how the items in the model are sorted.
+
+ \value UnsortedModel The model is unsorted.
+ \value CaseSensitivelySortedModel The model is sorted case sensitively.
+ \value CaseInsensitivelySortedModel The model is sorted case insensitively.
+
+ \sa setModelSorting()
+*/
+
+/*!
+ \property QCompleter::modelSorting
+ \brief the way the model is sorted
+
+ By default, no assumptions are made about the order of the items
+ in the model that provides the completions.
+
+ If the model's data for the completionColumn() and completionRole() is sorted in
+ ascending order, you can set this property to \l CaseSensitivelySortedModel
+ or \l CaseInsensitivelySortedModel. On large models, this can lead to
+ significant performance improvements because the completer object can
+ then use a binary search algorithm instead of linear search algorithm.
+
+ The sort order (i.e ascending or descending order) of the model is determined
+ dynamically by inspecting the contents of the model.
+
+ \bold{Note:} The performance improvements described above cannot take place
+ when the completer's \l caseSensitivity is different to the case sensitivity
+ used by the model's when sorting.
+
+ \sa setCaseSensitivity(), QCompleter::ModelSorting
+*/
+void QCompleter::setModelSorting(QCompleter::ModelSorting sorting)
+{
+ Q_D(QCompleter);
+ if (d->sorting == sorting)
+ return;
+ d->sorting = sorting;
+ d->proxy->createEngine();
+ d->proxy->invalidate();
+}
+
+QCompleter::ModelSorting QCompleter::modelSorting() const
+{
+ Q_D(const QCompleter);
+ return d->sorting;
+}
+
+/*!
+ \property QCompleter::completionColumn
+ \brief the column in the model in which completions are searched for.
+
+ If the popup() is a QListView, it is automatically setup to display
+ this column.
+
+ By default, the match column is 0.
+
+ \sa completionRole, caseSensitivity
+*/
+void QCompleter::setCompletionColumn(int column)
+{
+ Q_D(QCompleter);
+ if (d->column == column)
+ return;
+#ifndef QT_NO_LISTVIEW
+ if (QListView *listView = qobject_cast<QListView *>(d->popup))
+ listView->setModelColumn(column);
+#endif
+ d->column = column;
+ d->proxy->invalidate();
+}
+
+int QCompleter::completionColumn() const
+{
+ Q_D(const QCompleter);
+ return d->column;
+}
+
+/*!
+ \property QCompleter::completionRole
+ \brief the item role to be used to query the contents of items for matching.
+
+ The default role is Qt::EditRole.
+
+ \sa completionColumn, caseSensitivity
+*/
+void QCompleter::setCompletionRole(int role)
+{
+ Q_D(QCompleter);
+ if (d->role == role)
+ return;
+ d->role = role;
+ d->proxy->invalidate();
+}
+
+int QCompleter::completionRole() const
+{
+ Q_D(const QCompleter);
+ return d->role;
+}
+
+/*!
+ \property QCompleter::wrapAround
+ \brief the completions wrap around when navigating through items
+ \since 4.3
+
+ The default is true.
+*/
+void QCompleter::setWrapAround(bool wrap)
+{
+ Q_D(QCompleter);
+ if (d->wrap == wrap)
+ return;
+ d->wrap = wrap;
+}
+
+bool QCompleter::wrapAround() const
+{
+ Q_D(const QCompleter);
+ return d->wrap;
+}
+
+/*!
+ \property QCompleter::maxVisibleItems
+ \brief the maximum allowed size on screen of the completer, measured in items
+ \since 4.6
+
+ By default, this property has a value of 7.
+*/
+int QCompleter::maxVisibleItems() const
+{
+ Q_D(const QCompleter);
+ return d->maxVisibleItems;
+}
+
+void QCompleter::setMaxVisibleItems(int maxItems)
+{
+ Q_D(QCompleter);
+ if (maxItems < 0) {
+ qWarning("QCompleter::setMaxVisibleItems: "
+ "Invalid max visible items (%d) must be >= 0", maxItems);
+ return;
+ }
+ d->maxVisibleItems = maxItems;
+}
+
+/*!
+ \property QCompleter::caseSensitivity
+ \brief the case sensitivity of the matching
+
+ The default is Qt::CaseSensitive.
+
+ \sa completionColumn, completionRole, modelSorting
+*/
+void QCompleter::setCaseSensitivity(Qt::CaseSensitivity cs)
+{
+ Q_D(QCompleter);
+ if (d->cs == cs)
+ return;
+ d->cs = cs;
+ d->proxy->createEngine();
+ d->proxy->invalidate();
+}
+
+Qt::CaseSensitivity QCompleter::caseSensitivity() const
+{
+ Q_D(const QCompleter);
+ return d->cs;
+}
+
+/*!
+ \property QCompleter::completionPrefix
+ \brief the completion prefix used to provide completions.
+
+ The completionModel() is updated to reflect the list of possible
+ matches for \a prefix.
+*/
+void QCompleter::setCompletionPrefix(const QString &prefix)
+{
+ Q_D(QCompleter);
+ d->prefix = prefix;
+ d->proxy->filter(splitPath(prefix));
+}
+
+QString QCompleter::completionPrefix() const
+{
+ Q_D(const QCompleter);
+ return d->prefix;
+}
+
+/*!
+ Returns the model index of the current completion in the completionModel().
+
+ \sa setCurrentRow(), currentCompletion(), model()
+*/
+QModelIndex QCompleter::currentIndex() const
+{
+ Q_D(const QCompleter);
+ return d->proxy->currentIndex(false);
+}
+
+/*!
+ Returns the current completion string. This includes the \l completionPrefix.
+ When used alongside setCurrentRow(), it can be used to iterate through
+ all the matches.
+
+ \sa setCurrentRow(), currentIndex()
+*/
+QString QCompleter::currentCompletion() const
+{
+ Q_D(const QCompleter);
+ return pathFromIndex(d->proxy->currentIndex(true));
+}
+
+/*!
+ Returns the completion model. The completion model is a read-only list model
+ that contains all the possible matches for the current completion prefix.
+ The completion model is auto-updated to reflect the current completions.
+
+ \note The return value of this function is defined to be an QAbstractItemModel
+ purely for generality. This actual kind of model returned is an instance of an
+ QAbstractProxyModel subclass.
+
+ \sa completionPrefix, model()
+*/
+QAbstractItemModel *QCompleter::completionModel() const
+{
+ Q_D(const QCompleter);
+ return d->proxy;
+}
+
+/*!
+ Returns the path for the given \a index. The completer object uses this to
+ obtain the completion text from the underlying model.
+
+ The default implementation returns the \l{Qt::EditRole}{edit role} of the
+ item for list models. It returns the absolute file path if the model is a
+ QFileSystemModel.
+
+ \sa splitPath()
+*/
+
+QString QCompleter::pathFromIndex(const QModelIndex& index) const
+{
+ Q_D(const QCompleter);
+ if (!index.isValid())
+ return QString();
+
+ QAbstractItemModel *sourceModel = d->proxy->sourceModel();
+ if (!sourceModel)
+ return QString();
+ bool isDirModel = false;
+ bool isFsModel = false;
+#ifndef QT_NO_DIRMODEL
+ isDirModel = qobject_cast<QDirModel *>(d->proxy->sourceModel()) != 0;
+#endif
+#ifndef QT_NO_FILESYSTEMMODEL
+ isFsModel = qobject_cast<QFileSystemModel *>(d->proxy->sourceModel()) != 0;
+#endif
+ if (!isDirModel && !isFsModel)
+ return sourceModel->data(index, d->role).toString();
+
+ QModelIndex idx = index;
+ QStringList list;
+ do {
+ QString t;
+ if (isDirModel)
+ t = sourceModel->data(idx, Qt::EditRole).toString();
+#ifndef QT_NO_FILESYSTEMMODEL
+ else
+ t = sourceModel->data(idx, QFileSystemModel::FileNameRole).toString();
+#endif
+ list.prepend(t);
+ QModelIndex parent = idx.parent();
+ idx = parent.sibling(parent.row(), index.column());
+ } while (idx.isValid());
+
+#if (!defined(Q_OS_WIN) || defined(Q_OS_WINCE)) && !defined(Q_OS_SYMBIAN)
+ if (list.count() == 1) // only the separator or some other text
+ return list[0];
+ list[0].clear() ; // the join below will provide the separator
+#endif
+
+ return list.join(QDir::separator());
+}
+
+/*!
+ Splits the given \a path into strings that are used to match at each level
+ in the model().
+
+ The default implementation of splitPath() splits a file system path based on
+ QDir::separator() when the sourceModel() is a QFileSystemModel.
+
+ When used with list models, the first item in the returned list is used for
+ matching.
+
+ \sa pathFromIndex(), {Handling Tree Models}
+*/
+QStringList QCompleter::splitPath(const QString& path) const
+{
+ bool isDirModel = false;
+ bool isFsModel = false;
+#ifndef QT_NO_DIRMODEL
+ Q_D(const QCompleter);
+ isDirModel = qobject_cast<QDirModel *>(d->proxy->sourceModel()) != 0;
+#endif
+#ifndef QT_NO_FILESYSTEMMODEL
+#ifdef QT_NO_DIRMODEL
+ Q_D(const QCompleter);
+#endif
+ isFsModel = qobject_cast<QFileSystemModel *>(d->proxy->sourceModel()) != 0;
+#endif
+
+ if ((!isDirModel && !isFsModel) || path.isEmpty())
+ return QStringList(completionPrefix());
+
+ QString pathCopy = QDir::toNativeSeparators(path);
+ QString sep = QDir::separator();
+#if defined(Q_OS_SYMBIAN)
+ if (pathCopy == QLatin1String("\\"))
+ return QStringList(pathCopy);
+#elif defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+ if (pathCopy == QLatin1String("\\") || pathCopy == QLatin1String("\\\\"))
+ return QStringList(pathCopy);
+ QString doubleSlash(QLatin1String("\\\\"));
+ if (pathCopy.startsWith(doubleSlash))
+ pathCopy = pathCopy.mid(2);
+ else
+ doubleSlash.clear();
+#endif
+
+ QRegExp re(QLatin1Char('[') + QRegExp::escape(sep) + QLatin1Char(']'));
+ QStringList parts = pathCopy.split(re);
+
+#if defined(Q_OS_SYMBIAN)
+ // Do nothing
+#elif defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+ if (!doubleSlash.isEmpty())
+ parts[0].prepend(doubleSlash);
+#else
+ if (pathCopy[0] == sep[0]) // readd the "/" at the beginning as the split removed it
+ parts[0] = QDir::fromNativeSeparators(QString(sep[0]));
+#endif
+
+ return parts;
+}
+
+/*!
+ \fn void QCompleter::activated(const QModelIndex& index)
+
+ This signal is sent when an item in the popup() is activated by the user.
+ (by clicking or pressing return). The item's \a index in the completionModel()
+ is given.
+
+*/
+
+/*!
+ \fn void QCompleter::activated(const QString &text)
+
+ This signal is sent when an item in the popup() is activated by the user (by
+ clicking or pressing return). The item's \a text is given.
+
+*/
+
+/*!
+ \fn void QCompleter::highlighted(const QModelIndex& index)
+
+ This signal is sent when an item in the popup() is highlighted by
+ the user. It is also sent if complete() is called with the completionMode()
+ set to QCompleter::InlineCompletion. The item's \a index in the completionModel()
+ is given.
+*/
+
+/*!
+ \fn void QCompleter::highlighted(const QString &text)
+
+ This signal is sent when an item in the popup() is highlighted by
+ the user. It is also sent if complete() is called with the completionMode()
+ set to QCompleter::InlineCompletion. The item's \a text is given.
+*/
+
+QT_END_NAMESPACE
+
+#include "moc_qcompleter.cpp"
+
+#endif // QT_NO_COMPLETER
diff --git a/src/gui/util/qcompleter.h b/src/widgets/util/qcompleter.h
index ace2f0afb6..ace2f0afb6 100644
--- a/src/gui/util/qcompleter.h
+++ b/src/widgets/util/qcompleter.h
diff --git a/src/widgets/util/qcompleter_p.h b/src/widgets/util/qcompleter_p.h
new file mode 100644
index 0000000000..0342c35c51
--- /dev/null
+++ b/src/widgets/util/qcompleter_p.h
@@ -0,0 +1,264 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCOMPLETER_P_H
+#define QCOMPLETER_P_H
+
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "private/qobject_p.h"
+
+#ifndef QT_NO_COMPLETER
+
+#include "QtWidgets/qtreeview.h"
+#include "QtWidgets/qabstractproxymodel.h"
+#include "qcompleter.h"
+#include "QtWidgets/qitemdelegate.h"
+#include "QtGui/qpainter.h"
+#include "private/qabstractproxymodel_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QCompletionModel;
+
+class QCompleterPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QCompleter)
+
+public:
+ QCompleterPrivate();
+ ~QCompleterPrivate() { delete popup; }
+ void init(QAbstractItemModel *model = 0);
+
+ QPointer<QWidget> widget;
+ QCompletionModel *proxy;
+ QAbstractItemView *popup;
+ QCompleter::CompletionMode mode;
+
+ QString prefix;
+ Qt::CaseSensitivity cs;
+ int role;
+ int column;
+ int maxVisibleItems;
+ QCompleter::ModelSorting sorting;
+ bool wrap;
+
+ bool eatFocusOut;
+ QRect popupRect;
+ bool hiddenBecauseNoMatch;
+
+ void showPopup(const QRect&);
+ void _q_complete(QModelIndex, bool = false);
+ void _q_completionSelected(const QItemSelection&);
+ void _q_autoResizePopup();
+ void _q_fileSystemModelDirectoryLoaded(const QString &path);
+ void setCurrentIndex(QModelIndex, bool = true);
+};
+
+class QIndexMapper
+{
+public:
+ QIndexMapper() : v(false), f(0), t(-1) { }
+ QIndexMapper(int f, int t) : v(false), f(f), t(t) { }
+ QIndexMapper(QVector<int> vec) : v(true), vector(vec), f(-1), t(-1) { }
+
+ inline int count() const { return v ? vector.count() : t - f + 1; }
+ inline int operator[] (int index) const { return v ? vector[index] : f + index; }
+ inline int indexOf(int x) const { return v ? vector.indexOf(x) : ((t < f) ? -1 : x - f); }
+ inline bool isValid() const { return !isEmpty(); }
+ inline bool isEmpty() const { return v ? vector.isEmpty() : (t < f); }
+ inline void append(int x) { Q_ASSERT(v); vector.append(x); }
+ inline int first() const { return v ? vector.first() : f; }
+ inline int last() const { return v ? vector.last() : t; }
+ inline int from() const { Q_ASSERT(!v); return f; }
+ inline int to() const { Q_ASSERT(!v); return t; }
+ inline int cost() const { return vector.count()+2; }
+
+private:
+ bool v;
+ QVector<int> vector;
+ int f, t;
+};
+
+struct QMatchData {
+ QMatchData() : exactMatchIndex(-1) { }
+ QMatchData(const QIndexMapper& indices, int em, bool p) :
+ indices(indices), exactMatchIndex(em), partial(p) { }
+ QIndexMapper indices;
+ inline bool isValid() const { return indices.isValid(); }
+ int exactMatchIndex;
+ bool partial;
+};
+
+class QCompletionEngine
+{
+public:
+ typedef QMap<QString, QMatchData> CacheItem;
+ typedef QMap<QModelIndex, CacheItem> Cache;
+
+ QCompletionEngine(QCompleterPrivate *c) : c(c), curRow(-1), cost(0) { }
+ virtual ~QCompletionEngine() { }
+
+ void filter(const QStringList &parts);
+
+ QMatchData filterHistory();
+ bool matchHint(QString, const QModelIndex&, QMatchData*);
+
+ void saveInCache(QString, const QModelIndex&, const QMatchData&);
+ bool lookupCache(QString part, const QModelIndex& parent, QMatchData *m);
+
+ virtual void filterOnDemand(int) { }
+ virtual QMatchData filter(const QString&, const QModelIndex&, int) = 0;
+
+ int matchCount() const { return curMatch.indices.count() + historyMatch.indices.count(); }
+
+ QMatchData curMatch, historyMatch;
+ QCompleterPrivate *c;
+ QStringList curParts;
+ QModelIndex curParent;
+ int curRow;
+
+ Cache cache;
+ int cost;
+};
+
+class QSortedModelEngine : public QCompletionEngine
+{
+public:
+ QSortedModelEngine(QCompleterPrivate *c) : QCompletionEngine(c) { }
+ QMatchData filter(const QString&, const QModelIndex&, int);
+ QIndexMapper indexHint(QString, const QModelIndex&, Qt::SortOrder);
+ Qt::SortOrder sortOrder(const QModelIndex&) const;
+};
+
+class QUnsortedModelEngine : public QCompletionEngine
+{
+public:
+ QUnsortedModelEngine(QCompleterPrivate *c) : QCompletionEngine(c) { }
+
+ void filterOnDemand(int);
+ QMatchData filter(const QString&, const QModelIndex&, int);
+private:
+ int buildIndices(const QString& str, const QModelIndex& parent, int n,
+ const QIndexMapper& iv, QMatchData* m);
+};
+
+class QCompleterItemDelegate : public QItemDelegate
+{
+public:
+ QCompleterItemDelegate(QAbstractItemView *view)
+ : QItemDelegate(view), view(view) { }
+ void paint(QPainter *p, const QStyleOptionViewItem& opt, const QModelIndex& idx) const {
+ QStyleOptionViewItem optCopy = opt;
+ optCopy.showDecorationSelected = true;
+ if (view->currentIndex() == idx)
+ optCopy.state |= QStyle::State_HasFocus;
+ QItemDelegate::paint(p, optCopy, idx);
+ }
+
+private:
+ QAbstractItemView *view;
+};
+
+class QCompletionModelPrivate;
+
+class QCompletionModel : public QAbstractProxyModel
+{
+ Q_OBJECT
+
+public:
+ QCompletionModel(QCompleterPrivate *c, QObject *parent);
+
+ void createEngine();
+ void setFiltered(bool);
+ void filter(const QStringList& parts);
+ int completionCount() const;
+ int currentRow() const { return engine->curRow; }
+ bool setCurrentRow(int row);
+ QModelIndex currentIndex(bool) const;
+ void resetModel();
+
+ QModelIndex index(int row, int column, const QModelIndex & = QModelIndex()) const;
+ int rowCount(const QModelIndex &index = QModelIndex()) const;
+ int columnCount(const QModelIndex &index = QModelIndex()) const;
+ bool hasChildren(const QModelIndex &parent = QModelIndex()) const;
+ QModelIndex parent(const QModelIndex & = QModelIndex()) const { return QModelIndex(); }
+ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
+
+ void setSourceModel(QAbstractItemModel *sourceModel);
+ QModelIndex mapToSource(const QModelIndex& proxyIndex) const;
+ QModelIndex mapFromSource(const QModelIndex& sourceIndex) const;
+
+ QCompleterPrivate *c;
+ QScopedPointer<QCompletionEngine> engine;
+ bool showAll;
+
+ Q_DECLARE_PRIVATE(QCompletionModel)
+
+signals:
+ void rowsAdded();
+
+public Q_SLOTS:
+ void invalidate();
+ void rowsInserted();
+ void modelDestroyed();
+};
+
+class QCompletionModelPrivate : public QAbstractProxyModelPrivate
+{
+ Q_DECLARE_PUBLIC(QCompletionModel)
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_COMPLETER
+
+#endif // QCOMPLETER_P_H
diff --git a/src/gui/util/qflickgesture.cpp b/src/widgets/util/qflickgesture.cpp
index f87c84ccef..f87c84ccef 100644
--- a/src/gui/util/qflickgesture.cpp
+++ b/src/widgets/util/qflickgesture.cpp
diff --git a/src/gui/util/qflickgesture_p.h b/src/widgets/util/qflickgesture_p.h
index 451b579edd..451b579edd 100644
--- a/src/gui/util/qflickgesture_p.h
+++ b/src/widgets/util/qflickgesture_p.h
diff --git a/src/gui/util/qscroller.cpp b/src/widgets/util/qscroller.cpp
index 870d56fcb7..870d56fcb7 100644
--- a/src/gui/util/qscroller.cpp
+++ b/src/widgets/util/qscroller.cpp
diff --git a/src/widgets/util/qscroller.h b/src/widgets/util/qscroller.h
new file mode 100644
index 0000000000..dd4ff9d73e
--- /dev/null
+++ b/src/widgets/util/qscroller.h
@@ -0,0 +1,155 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSCROLLER_H
+#define QSCROLLER_H
+
+#include <QtCore/QObject>
+#include <QtCore/QPointF>
+#include <QtWidgets/QScrollerProperties>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QWidget;
+class QScrollerPrivate;
+class QScrollerProperties;
+#ifndef QT_NO_GESTURES
+class QFlickGestureRecognizer;
+class QMouseFlickGestureRecognizer;
+#endif
+
+class Q_GUI_EXPORT QScroller : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(State state READ state NOTIFY stateChanged)
+ Q_PROPERTY(QScrollerProperties scrollerProperties READ scrollerProperties WRITE setScrollerProperties NOTIFY scrollerPropertiesChanged)
+ Q_ENUMS(State)
+
+public:
+ enum State
+ {
+ Inactive,
+ Pressed,
+ Dragging,
+ Scrolling
+ };
+
+ enum ScrollerGestureType
+ {
+ TouchGesture,
+ LeftMouseButtonGesture,
+ RightMouseButtonGesture,
+ MiddleMouseButtonGesture
+ };
+
+ enum Input
+ {
+ InputPress = 1,
+ InputMove,
+ InputRelease
+ };
+
+ static bool hasScroller(QObject *target);
+
+ static QScroller *scroller(QObject *target);
+ static const QScroller *scroller(const QObject *target);
+
+#ifndef QT_NO_GESTURES
+ static Qt::GestureType grabGesture(QObject *target, ScrollerGestureType gestureType = TouchGesture);
+ static Qt::GestureType grabbedGesture(QObject *target);
+ static void ungrabGesture(QObject *target);
+#endif
+
+ static QList<QScroller *> activeScrollers();
+
+ QObject *target() const;
+
+ State state() const;
+
+ bool handleInput(Input input, const QPointF &position, qint64 timestamp = 0);
+
+ void stop();
+ QPointF velocity() const;
+ QPointF finalPosition() const;
+ QPointF pixelPerMeter() const;
+
+ QScrollerProperties scrollerProperties() const;
+
+ void setSnapPositionsX( const QList<qreal> &positions );
+ void setSnapPositionsX( qreal first, qreal interval );
+ void setSnapPositionsY( const QList<qreal> &positions );
+ void setSnapPositionsY( qreal first, qreal interval );
+
+public Q_SLOTS:
+ void setScrollerProperties(const QScrollerProperties &prop);
+ void scrollTo(const QPointF &pos);
+ void scrollTo(const QPointF &pos, int scrollTime);
+ void ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin);
+ void ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin, int scrollTime);
+ void resendPrepareEvent();
+
+Q_SIGNALS:
+ void stateChanged(QScroller::State newstate);
+ void scrollerPropertiesChanged(const QScrollerProperties &);
+
+private:
+ QScrollerPrivate *d_ptr;
+
+ QScroller(QObject *target);
+ virtual ~QScroller();
+
+ Q_DISABLE_COPY(QScroller)
+ Q_DECLARE_PRIVATE(QScroller)
+
+#ifndef QT_NO_GESTURES
+ friend class QFlickGestureRecognizer;
+#endif
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QSCROLLER_H
diff --git a/src/gui/util/qscroller_mac.mm b/src/widgets/util/qscroller_mac.mm
index 4bf69c17c0..4bf69c17c0 100644
--- a/src/gui/util/qscroller_mac.mm
+++ b/src/widgets/util/qscroller_mac.mm
diff --git a/src/gui/util/qscroller_p.h b/src/widgets/util/qscroller_p.h
index c1196152df..c1196152df 100644
--- a/src/gui/util/qscroller_p.h
+++ b/src/widgets/util/qscroller_p.h
diff --git a/src/gui/util/qscrollerproperties.cpp b/src/widgets/util/qscrollerproperties.cpp
index 85e2e82af1..85e2e82af1 100644
--- a/src/gui/util/qscrollerproperties.cpp
+++ b/src/widgets/util/qscrollerproperties.cpp
diff --git a/src/gui/util/qscrollerproperties.h b/src/widgets/util/qscrollerproperties.h
index 75d8932f81..75d8932f81 100644
--- a/src/gui/util/qscrollerproperties.h
+++ b/src/widgets/util/qscrollerproperties.h
diff --git a/src/gui/util/qscrollerproperties_p.h b/src/widgets/util/qscrollerproperties_p.h
index 76d8b0a79b..76d8b0a79b 100644
--- a/src/gui/util/qscrollerproperties_p.h
+++ b/src/widgets/util/qscrollerproperties_p.h
diff --git a/src/gui/util/qsystemtrayicon.cpp b/src/widgets/util/qsystemtrayicon.cpp
index 33cc61ee97..33cc61ee97 100644
--- a/src/gui/util/qsystemtrayicon.cpp
+++ b/src/widgets/util/qsystemtrayicon.cpp
diff --git a/src/widgets/util/qsystemtrayicon.h b/src/widgets/util/qsystemtrayicon.h
new file mode 100644
index 0000000000..2bb0494eff
--- /dev/null
+++ b/src/widgets/util/qsystemtrayicon.h
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSYSTEMTRAYICON_H
+#define QSYSTEMTRAYICON_H
+
+#include <QtCore/qobject.h>
+
+#ifndef QT_NO_SYSTEMTRAYICON
+
+#include <QtWidgets/qicon.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QSystemTrayIconPrivate;
+
+class QMenu;
+class QEvent;
+class QWheelEvent;
+class QMouseEvent;
+class QPoint;
+
+class Q_GUI_EXPORT QSystemTrayIcon : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QString toolTip READ toolTip WRITE setToolTip)
+ Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
+ Q_PROPERTY(bool visible READ isVisible WRITE setVisible DESIGNABLE false)
+
+public:
+ QSystemTrayIcon(QObject *parent = 0);
+ QSystemTrayIcon(const QIcon &icon, QObject *parent = 0);
+ ~QSystemTrayIcon();
+
+ enum ActivationReason {
+ Unknown,
+ Context,
+ DoubleClick,
+ Trigger,
+ MiddleClick
+ };
+
+#ifndef QT_NO_MENU
+ void setContextMenu(QMenu *menu);
+ QMenu *contextMenu() const;
+#endif
+
+ QIcon icon() const;
+ void setIcon(const QIcon &icon);
+
+ QString toolTip() const;
+ void setToolTip(const QString &tip);
+
+ static bool isSystemTrayAvailable();
+ static bool supportsMessages();
+
+ enum MessageIcon { NoIcon, Information, Warning, Critical };
+ void showMessage(const QString &title, const QString &msg,
+ MessageIcon icon = Information, int msecs = 10000);
+
+ QRect geometry() const;
+ bool isVisible() const;
+
+public Q_SLOTS:
+ void setVisible(bool visible);
+ inline void show() { setVisible(true); }
+ inline void hide() { setVisible(false); }
+
+Q_SIGNALS:
+ void activated(QSystemTrayIcon::ActivationReason reason);
+ void messageClicked();
+
+protected:
+ bool event(QEvent *event);
+
+private:
+ Q_DISABLE_COPY(QSystemTrayIcon)
+ Q_DECLARE_PRIVATE(QSystemTrayIcon)
+
+ friend class QSystemTrayIconSys;
+ friend class QBalloonTip;
+ friend void qtsystray_sendActivated(QSystemTrayIcon *, int);
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QT_NO_SYSTEMTRAYICON
+#endif // QSYSTEMTRAYICON_H
diff --git a/src/gui/util/qsystemtrayicon_mac.mm b/src/widgets/util/qsystemtrayicon_mac.mm
index 0ec0b07040..0ec0b07040 100644
--- a/src/gui/util/qsystemtrayicon_mac.mm
+++ b/src/widgets/util/qsystemtrayicon_mac.mm
diff --git a/src/widgets/util/qsystemtrayicon_p.h b/src/widgets/util/qsystemtrayicon_p.h
new file mode 100644
index 0000000000..7d587da1af
--- /dev/null
+++ b/src/widgets/util/qsystemtrayicon_p.h
@@ -0,0 +1,186 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSYSTEMTRAYICON_P_H
+#define QSYSTEMTRAYICON_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of a number of Qt sources files. This header file may change from
+// version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qsystemtrayicon.h"
+#include "private/qobject_p.h"
+
+#ifndef QT_NO_SYSTEMTRAYICON
+
+#include "QtWidgets/qmenu.h"
+#include "QtGui/qpixmap.h"
+#include "QtCore/qstring.h"
+#include "QtCore/qpointer.h"
+
+QT_BEGIN_NAMESPACE
+
+class QSystemTrayIconSys;
+class QToolButton;
+class QLabel;
+
+class QSystemTrayIconPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QSystemTrayIcon)
+
+public:
+ QSystemTrayIconPrivate() : sys(0), visible(false) { }
+
+ void install_sys();
+ void remove_sys();
+ void updateIcon_sys();
+ void updateToolTip_sys();
+ void updateMenu_sys();
+ QRect geometry_sys() const;
+ void showMessage_sys(const QString &msg, const QString &title, QSystemTrayIcon::MessageIcon icon, int secs);
+
+ static bool isSystemTrayAvailable_sys();
+ static bool supportsMessages_sys();
+
+ QPointer<QMenu> menu;
+ QIcon icon;
+ QString toolTip;
+ QSystemTrayIconSys *sys;
+ bool visible;
+};
+
+class QBalloonTip : public QWidget
+{
+ Q_OBJECT
+public:
+ static void showBalloon(QSystemTrayIcon::MessageIcon icon, const QString& title,
+ const QString& msg, QSystemTrayIcon *trayIcon,
+ const QPoint& pos, int timeout, bool showArrow = true);
+ static void hideBalloon();
+ static bool isBalloonVisible();
+
+private:
+ QBalloonTip(QSystemTrayIcon::MessageIcon icon, const QString& title,
+ const QString& msg, QSystemTrayIcon *trayIcon);
+ ~QBalloonTip();
+ void balloon(const QPoint&, int, bool);
+
+protected:
+ void paintEvent(QPaintEvent *);
+ void resizeEvent(QResizeEvent *);
+ void mousePressEvent(QMouseEvent *e);
+ void timerEvent(QTimerEvent *e);
+
+private:
+ QSystemTrayIcon *trayIcon;
+ QPixmap pixmap;
+ int timerId;
+};
+
+#if defined(Q_WS_X11)
+QT_BEGIN_INCLUDE_NAMESPACE
+#include <QtCore/qcoreapplication.h>
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+QT_END_INCLUDE_NAMESPACE
+
+class QSystemTrayIconSys : public QWidget
+{
+ friend class QSystemTrayIconPrivate;
+
+public:
+ QSystemTrayIconSys(QSystemTrayIcon *q);
+ ~QSystemTrayIconSys();
+ enum {
+ SYSTEM_TRAY_REQUEST_DOCK = 0,
+ SYSTEM_TRAY_BEGIN_MESSAGE = 1,
+ SYSTEM_TRAY_CANCEL_MESSAGE =2
+ };
+
+ void addToTray();
+ void updateIcon();
+ XVisualInfo* getSysTrayVisualInfo();
+
+ // QObject::event is public but QWidget's ::event() re-implementation
+ // is protected ;(
+ inline bool deliverToolTipEvent(QEvent *e)
+ { return QWidget::event(e); }
+
+ static Window sysTrayWindow;
+ static QList<QSystemTrayIconSys *> trayIcons;
+ static QCoreApplication::EventFilter oldEventFilter;
+ static bool sysTrayTracker(void *message, long *result);
+ static Window locateSystemTray();
+ static Atom sysTraySelection;
+ static XVisualInfo sysTrayVisual;
+
+protected:
+ void paintEvent(QPaintEvent *pe);
+ void resizeEvent(QResizeEvent *re);
+ bool x11Event(XEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+ void mouseDoubleClickEvent(QMouseEvent *event);
+#ifndef QT_NO_WHEELEVENT
+ void wheelEvent(QWheelEvent *event);
+#endif
+ bool event(QEvent *e);
+
+private:
+ QPixmap background;
+ QSystemTrayIcon *q;
+ Colormap colormap;
+};
+#endif // Q_WS_X11
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_SYSTEMTRAYICON
+
+#endif // QSYSTEMTRAYICON_P_H
+
diff --git a/src/gui/util/qsystemtrayicon_qws.cpp b/src/widgets/util/qsystemtrayicon_qpa.cpp
index 48f8fe8922..48f8fe8922 100644
--- a/src/gui/util/qsystemtrayicon_qws.cpp
+++ b/src/widgets/util/qsystemtrayicon_qpa.cpp
diff --git a/src/gui/util/qsystemtrayicon_win.cpp b/src/widgets/util/qsystemtrayicon_win.cpp
index 5a0e179e6d..5a0e179e6d 100644
--- a/src/gui/util/qsystemtrayicon_win.cpp
+++ b/src/widgets/util/qsystemtrayicon_win.cpp
diff --git a/src/gui/util/qsystemtrayicon_wince.cpp b/src/widgets/util/qsystemtrayicon_wince.cpp
index 85a34bbe25..85a34bbe25 100644
--- a/src/gui/util/qsystemtrayicon_wince.cpp
+++ b/src/widgets/util/qsystemtrayicon_wince.cpp
diff --git a/src/gui/util/qsystemtrayicon_x11.cpp b/src/widgets/util/qsystemtrayicon_x11.cpp
index 694746c834..694746c834 100644
--- a/src/gui/util/qsystemtrayicon_x11.cpp
+++ b/src/widgets/util/qsystemtrayicon_x11.cpp
diff --git a/src/gui/util/qundogroup.cpp b/src/widgets/util/qundogroup.cpp
index a24ce8dce8..a24ce8dce8 100644
--- a/src/gui/util/qundogroup.cpp
+++ b/src/widgets/util/qundogroup.cpp
diff --git a/src/gui/util/qundogroup.h b/src/widgets/util/qundogroup.h
index 4ed79a9c81..4ed79a9c81 100644
--- a/src/gui/util/qundogroup.h
+++ b/src/widgets/util/qundogroup.h
diff --git a/src/gui/util/qundostack.cpp b/src/widgets/util/qundostack.cpp
index 1dfab5d1ad..1dfab5d1ad 100644
--- a/src/gui/util/qundostack.cpp
+++ b/src/widgets/util/qundostack.cpp
diff --git a/src/gui/util/qundostack.h b/src/widgets/util/qundostack.h
index 700996f005..700996f005 100644
--- a/src/gui/util/qundostack.h
+++ b/src/widgets/util/qundostack.h
diff --git a/src/widgets/util/qundostack_p.h b/src/widgets/util/qundostack_p.h
new file mode 100644
index 0000000000..29f382587a
--- /dev/null
+++ b/src/widgets/util/qundostack_p.h
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QUNDOSTACK_P_H
+#define QUNDOSTACK_P_H
+
+#include <private/qobject_p.h>
+#include <QtCore/qlist.h>
+#include <QtCore/qstring.h>
+#include <QtWidgets/qaction.h>
+
+#include "qundostack.h"
+
+QT_BEGIN_NAMESPACE
+class QUndoCommand;
+class QUndoGroup;
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header
+// file may change from version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+class QUndoCommandPrivate
+{
+public:
+ QUndoCommandPrivate() : id(-1) {}
+ QList<QUndoCommand*> child_list;
+ QString text;
+ QString actionText;
+ int id;
+};
+
+#ifndef QT_NO_UNDOSTACK
+
+class QUndoStackPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QUndoStack)
+public:
+ QUndoStackPrivate() : index(0), clean_index(0), group(0), undo_limit(0) {}
+
+ QList<QUndoCommand*> command_list;
+ QList<QUndoCommand*> macro_stack;
+ int index;
+ int clean_index;
+ QUndoGroup *group;
+ int undo_limit;
+
+ void setIndex(int idx, bool clean);
+ bool checkUndoLimit();
+};
+
+#ifndef QT_NO_ACTION
+class QUndoAction : public QAction
+{
+ Q_OBJECT
+public:
+ QUndoAction(const QString &prefix, QObject *parent = 0);
+ void setTextFormat(const QString &textFormat, const QString &defaultText);
+public Q_SLOTS:
+ void setPrefixedText(const QString &text);
+private:
+ QString m_prefix;
+ QString m_defaultText;
+};
+#endif // QT_NO_ACTION
+
+
+QT_END_NAMESPACE
+#endif // QT_NO_UNDOSTACK
+#endif // QUNDOSTACK_P_H
diff --git a/src/widgets/util/qundoview.cpp b/src/widgets/util/qundoview.cpp
new file mode 100644
index 0000000000..35c18a04ac
--- /dev/null
+++ b/src/widgets/util/qundoview.cpp
@@ -0,0 +1,476 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qundostack.h"
+#include "qundoview.h"
+
+#ifndef QT_NO_UNDOVIEW
+
+#include "qundogroup.h"
+#include <QtCore/qabstractitemmodel.h>
+#include <QtCore/qpointer.h>
+#include <QtWidgets/qicon.h>
+#include <private/qlistview_p.h>
+
+QT_BEGIN_NAMESPACE
+
+class QUndoModel : public QAbstractItemModel
+{
+ Q_OBJECT
+public:
+ QUndoModel(QObject *parent = 0);
+
+ QUndoStack *stack() const;
+
+ virtual QModelIndex index(int row, int column,
+ const QModelIndex &parent = QModelIndex()) const;
+ virtual QModelIndex parent(const QModelIndex &child) const;
+ virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
+ virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+
+ QModelIndex selectedIndex() const;
+ QItemSelectionModel *selectionModel() const;
+
+ QString emptyLabel() const;
+ void setEmptyLabel(const QString &label);
+
+ void setCleanIcon(const QIcon &icon);
+ QIcon cleanIcon() const;
+
+public slots:
+ void setStack(QUndoStack *stack);
+
+private slots:
+ void stackChanged();
+ void stackDestroyed(QObject *obj);
+ void setStackCurrentIndex(const QModelIndex &index);
+
+private:
+ QUndoStack *m_stack;
+ QItemSelectionModel *m_sel_model;
+ QString m_emty_label;
+ QIcon m_clean_icon;
+};
+
+QUndoModel::QUndoModel(QObject *parent)
+ : QAbstractItemModel(parent)
+{
+ m_stack = 0;
+ m_sel_model = new QItemSelectionModel(this, this);
+ connect(m_sel_model, SIGNAL(currentChanged(QModelIndex,QModelIndex)),
+ this, SLOT(setStackCurrentIndex(QModelIndex)));
+ m_emty_label = tr("<empty>");
+}
+
+QItemSelectionModel *QUndoModel::selectionModel() const
+{
+ return m_sel_model;
+}
+
+QUndoStack *QUndoModel::stack() const
+{
+ return m_stack;
+}
+
+void QUndoModel::setStack(QUndoStack *stack)
+{
+ if (m_stack == stack)
+ return;
+
+ if (m_stack != 0) {
+ disconnect(m_stack, SIGNAL(cleanChanged(bool)), this, SLOT(stackChanged()));
+ disconnect(m_stack, SIGNAL(indexChanged(int)), this, SLOT(stackChanged()));
+ disconnect(m_stack, SIGNAL(destroyed(QObject*)), this, SLOT(stackDestroyed(QObject*)));
+ }
+ m_stack = stack;
+ if (m_stack != 0) {
+ connect(m_stack, SIGNAL(cleanChanged(bool)), this, SLOT(stackChanged()));
+ connect(m_stack, SIGNAL(indexChanged(int)), this, SLOT(stackChanged()));
+ connect(m_stack, SIGNAL(destroyed(QObject*)), this, SLOT(stackDestroyed(QObject*)));
+ }
+
+ stackChanged();
+}
+
+void QUndoModel::stackDestroyed(QObject *obj)
+{
+ if (obj != m_stack)
+ return;
+ m_stack = 0;
+
+ stackChanged();
+}
+
+void QUndoModel::stackChanged()
+{
+ reset();
+ m_sel_model->setCurrentIndex(selectedIndex(), QItemSelectionModel::ClearAndSelect);
+}
+
+void QUndoModel::setStackCurrentIndex(const QModelIndex &index)
+{
+ if (m_stack == 0)
+ return;
+
+ if (index == selectedIndex())
+ return;
+
+ if (index.column() != 0)
+ return;
+
+ m_stack->setIndex(index.row());
+}
+
+QModelIndex QUndoModel::selectedIndex() const
+{
+ return m_stack == 0 ? QModelIndex() : createIndex(m_stack->index(), 0);
+}
+
+QModelIndex QUndoModel::index(int row, int column, const QModelIndex &parent) const
+{
+ if (m_stack == 0)
+ return QModelIndex();
+
+ if (parent.isValid())
+ return QModelIndex();
+
+ if (column != 0)
+ return QModelIndex();
+
+ if (row < 0 || row > m_stack->count())
+ return QModelIndex();
+
+ return createIndex(row, column);
+}
+
+QModelIndex QUndoModel::parent(const QModelIndex&) const
+{
+ return QModelIndex();
+}
+
+int QUndoModel::rowCount(const QModelIndex &parent) const
+{
+ if (m_stack == 0)
+ return 0;
+
+ if (parent.isValid())
+ return 0;
+
+ return m_stack->count() + 1;
+}
+
+int QUndoModel::columnCount(const QModelIndex&) const
+{
+ return 1;
+}
+
+QVariant QUndoModel::data(const QModelIndex &index, int role) const
+{
+ if (m_stack == 0)
+ return QVariant();
+
+ if (index.column() != 0)
+ return QVariant();
+
+ if (index.row() < 0 || index.row() > m_stack->count())
+ return QVariant();
+
+ if (role == Qt::DisplayRole) {
+ if (index.row() == 0)
+ return m_emty_label;
+ return m_stack->text(index.row() - 1);
+ } else if (role == Qt::DecorationRole) {
+ if (index.row() == m_stack->cleanIndex() && !m_clean_icon.isNull())
+ return m_clean_icon;
+ return QVariant();
+ }
+
+ return QVariant();
+}
+
+QString QUndoModel::emptyLabel() const
+{
+ return m_emty_label;
+}
+
+void QUndoModel::setEmptyLabel(const QString &label)
+{
+ m_emty_label = label;
+ stackChanged();
+}
+
+void QUndoModel::setCleanIcon(const QIcon &icon)
+{
+ m_clean_icon = icon;
+ stackChanged();
+}
+
+QIcon QUndoModel::cleanIcon() const
+{
+ return m_clean_icon;
+}
+
+/*!
+ \class QUndoView
+ \brief The QUndoView class displays the contents of a QUndoStack.
+ \since 4.2
+
+ \ingroup advanced
+
+ QUndoView is a QListView which displays the list of commands pushed on an undo stack.
+ The most recently executed command is always selected. Selecting a different command
+ results in a call to QUndoStack::setIndex(), rolling the state of the document
+ backwards or forward to the new command.
+
+ The stack can be set explicitly with setStack(). Alternatively, a QUndoGroup object can
+ be set with setGroup(). The view will then update itself automatically whenever the
+ active stack of the group changes.
+
+ \image qundoview.png
+*/
+
+class QUndoViewPrivate : public QListViewPrivate
+{
+ Q_DECLARE_PUBLIC(QUndoView)
+public:
+ QUndoViewPrivate() :
+#ifndef QT_NO_UNDOGROUP
+ group(0),
+#endif
+ model(0) {}
+
+#ifndef QT_NO_UNDOGROUP
+ QPointer<QUndoGroup> group;
+#endif
+ QUndoModel *model;
+
+ void init();
+};
+
+void QUndoViewPrivate::init()
+{
+ Q_Q(QUndoView);
+
+ model = new QUndoModel(q);
+ q->setModel(model);
+ q->setSelectionModel(model->selectionModel());
+}
+
+/*!
+ Constructs a new view with parent \a parent.
+*/
+
+QUndoView::QUndoView(QWidget *parent)
+ : QListView(*new QUndoViewPrivate(), parent)
+{
+ Q_D(QUndoView);
+ d->init();
+}
+
+/*!
+ Constructs a new view with parent \a parent and sets the observed stack to \a stack.
+*/
+
+QUndoView::QUndoView(QUndoStack *stack, QWidget *parent)
+ : QListView(*new QUndoViewPrivate(), parent)
+{
+ Q_D(QUndoView);
+ d->init();
+ setStack(stack);
+}
+
+#ifndef QT_NO_UNDOGROUP
+
+/*!
+ Constructs a new view with parent \a parent and sets the observed group to \a group.
+
+ The view will update itself autmiatically whenever the active stack of the group changes.
+*/
+
+QUndoView::QUndoView(QUndoGroup *group, QWidget *parent)
+ : QListView(*new QUndoViewPrivate(), parent)
+{
+ Q_D(QUndoView);
+ d->init();
+ setGroup(group);
+}
+
+#endif // QT_NO_UNDOGROUP
+
+/*!
+ Destroys this view.
+*/
+
+QUndoView::~QUndoView()
+{
+}
+
+/*!
+ Returns the stack currently displayed by this view. If the view is looking at a
+ QUndoGroup, this the group's active stack.
+
+ \sa setStack() setGroup()
+*/
+
+QUndoStack *QUndoView::stack() const
+{
+ Q_D(const QUndoView);
+ return d->model->stack();
+}
+
+/*!
+ Sets the stack displayed by this view to \a stack. If \a stack is 0, the view
+ will be empty.
+
+ If the view was previously looking at a QUndoGroup, the group is set to 0.
+
+ \sa stack() setGroup()
+*/
+
+void QUndoView::setStack(QUndoStack *stack)
+{
+ Q_D(QUndoView);
+#ifndef QT_NO_UNDOGROUP
+ setGroup(0);
+#endif
+ d->model->setStack(stack);
+}
+
+#ifndef QT_NO_UNDOGROUP
+
+/*!
+ Sets the group displayed by this view to \a group. If \a group is 0, the view will
+ be empty.
+
+ The view will update itself autmiatically whenever the active stack of the group changes.
+
+ \sa group() setStack()
+*/
+
+void QUndoView::setGroup(QUndoGroup *group)
+{
+ Q_D(QUndoView);
+
+ if (d->group == group)
+ return;
+
+ if (d->group != 0) {
+ disconnect(d->group, SIGNAL(activeStackChanged(QUndoStack*)),
+ d->model, SLOT(setStack(QUndoStack*)));
+ }
+
+ d->group = group;
+
+ if (d->group != 0) {
+ connect(d->group, SIGNAL(activeStackChanged(QUndoStack*)),
+ d->model, SLOT(setStack(QUndoStack*)));
+ d->model->setStack(d->group->activeStack());
+ } else {
+ d->model->setStack(0);
+ }
+}
+
+/*!
+ Returns the group displayed by this view.
+
+ If the view is not looking at group, this function returns 0.
+
+ \sa setGroup() setStack()
+*/
+
+QUndoGroup *QUndoView::group() const
+{
+ Q_D(const QUndoView);
+ return d->group;
+}
+
+#endif // QT_NO_UNDOGROUP
+
+/*!
+ \property QUndoView::emptyLabel
+ \brief the label used for the empty state.
+
+ The empty label is the topmost element in the list of commands, which represents
+ the state of the document before any commands were pushed on the stack. The default
+ is the string "<empty>".
+*/
+
+void QUndoView::setEmptyLabel(const QString &label)
+{
+ Q_D(QUndoView);
+ d->model->setEmptyLabel(label);
+}
+
+QString QUndoView::emptyLabel() const
+{
+ Q_D(const QUndoView);
+ return d->model->emptyLabel();
+}
+
+/*!
+ \property QUndoView::cleanIcon
+ \brief the icon used to represent the clean state.
+
+ A stack may have a clean state set with QUndoStack::setClean(). This is usually
+ the state of the document at the point it was saved. QUndoView can display an
+ icon in the list of commands to show the clean state. If this property is
+ a null icon, no icon is shown. The default value is the null icon.
+*/
+
+void QUndoView::setCleanIcon(const QIcon &icon)
+{
+ Q_D(const QUndoView);
+ d->model->setCleanIcon(icon);
+
+}
+
+QIcon QUndoView::cleanIcon() const
+{
+ Q_D(const QUndoView);
+ return d->model->cleanIcon();
+}
+
+QT_END_NAMESPACE
+
+#include "qundoview.moc"
+
+#endif // QT_NO_UNDOVIEW
diff --git a/src/widgets/util/qundoview.h b/src/widgets/util/qundoview.h
new file mode 100644
index 0000000000..ca9197b8ba
--- /dev/null
+++ b/src/widgets/util/qundoview.h
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QUNDOVIEW_H
+#define QUNDOVIEW_H
+
+#include <QtWidgets/qlistview.h>
+#include <QtCore/qstring.h>
+
+#ifndef QT_NO_UNDOVIEW
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QUndoViewPrivate;
+class QUndoStack;
+class QUndoGroup;
+class QIcon;
+
+QT_MODULE(Gui)
+
+class Q_GUI_EXPORT QUndoView : public QListView
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QUndoView)
+ Q_PROPERTY(QString emptyLabel READ emptyLabel WRITE setEmptyLabel)
+ Q_PROPERTY(QIcon cleanIcon READ cleanIcon WRITE setCleanIcon)
+
+public:
+ explicit QUndoView(QWidget *parent = 0);
+ explicit QUndoView(QUndoStack *stack, QWidget *parent = 0);
+#ifndef QT_NO_UNDOGROUP
+ explicit QUndoView(QUndoGroup *group, QWidget *parent = 0);
+#endif
+ ~QUndoView();
+
+ QUndoStack *stack() const;
+#ifndef QT_NO_UNDOGROUP
+ QUndoGroup *group() const;
+#endif
+
+ void setEmptyLabel(const QString &label);
+ QString emptyLabel() const;
+
+ void setCleanIcon(const QIcon &icon);
+ QIcon cleanIcon() const;
+
+public Q_SLOTS:
+ void setStack(QUndoStack *stack);
+#ifndef QT_NO_UNDOGROUP
+ void setGroup(QUndoGroup *group);
+#endif
+
+private:
+ Q_DISABLE_COPY(QUndoView)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QT_NO_UNDOVIEW
+#endif // QUNDOVIEW_H
diff --git a/src/widgets/util/util.pri b/src/widgets/util/util.pri
new file mode 100644
index 0000000000..854964b784
--- /dev/null
+++ b/src/widgets/util/util.pri
@@ -0,0 +1,69 @@
+# Qt util module
+
+HEADERS += \
+ util/qsystemtrayicon.h \
+ util/qcompleter.h \
+ util/qcompleter_p.h \
+ util/qsystemtrayicon_p.h \
+ util/qscroller.h \
+ util/qscroller_p.h \
+ util/qscrollerproperties.h \
+ util/qscrollerproperties_p.h \
+ util/qflickgesture_p.h \
+ util/qundogroup.h \
+ util/qundostack.h \
+ util/qundostack_p.h \
+ util/qundoview.h
+
+SOURCES += \
+ util/qsystemtrayicon.cpp \
+ util/qcompleter.cpp \
+ util/qscroller.cpp \
+ util/qscrollerproperties.cpp \
+ util/qflickgesture.cpp \
+ util/qundogroup.cpp \
+ util/qundostack.cpp \
+ util/qundoview.cpp
+
+
+wince* {
+ SOURCES += \
+ util/qsystemtrayicon_wince.cpp
+} else:win32 {
+ SOURCES += \
+ util/qsystemtrayicon_win.cpp
+}
+
+unix:x11 {
+ SOURCES += \
+ util/qsystemtrayicon_x11.cpp
+}
+
+qpa {
+ SOURCES += \
+ util/qsystemtrayicon_qpa.cpp
+}
+
+!qpa:!x11:mac {
+ OBJECTIVE_SOURCES += util/qsystemtrayicon_mac.mm
+}
+
+symbian {
+ LIBS += -letext -lplatformenv
+ contains(S60_VERSION, 3.1)|contains(S60_VERSION, 3.2)|contains(S60_VERSION, 5.0) {
+ LIBS += -lsendas2 -lapmime
+ contains(QT_CONFIG, s60) {
+ contains(CONFIG, is_using_gnupoc) {
+ LIBS += -lcommonui
+ } else {
+ LIBS += -lCommonUI
+ }
+ }
+ } else {
+ DEFINES += USE_SCHEMEHANDLER
+ }
+}
+
+macx {
+ OBJECTIVE_SOURCES += util/qscroller_mac.mm
+}
diff --git a/src/widgets/widgets.pro b/src/widgets/widgets.pro
new file mode 100644
index 0000000000..d46e20fc32
--- /dev/null
+++ b/src/widgets/widgets.pro
@@ -0,0 +1,224 @@
+TARGET = QtWidgets
+QPRO_PWD = $$PWD
+QT = core-private gui-private
+
+CONFIG += module
+MODULE_PRI = ../modules/qt_widgets.pri
+
+DEFINES += QT_BUILD_GUI_LIB QT_NO_USING_NAMESPACE
+win32-msvc*|win32-icc:QMAKE_LFLAGS += /BASE:0x65000000
+irix-cc*:QMAKE_CXXFLAGS += -no_prelink -ptused
+
+!win32:!qpa:!mac:!symbian:CONFIG += x11
+
+unix|win32-g++*:QMAKE_PKGCONFIG_REQUIRES = QtCore
+
+include(../qbase.pri)
+
+contains(QT_CONFIG, x11sm):CONFIG += x11sm
+
+#platforms
+x11:include(kernel/x11.pri)
+mac:include(kernel/mac.pri)
+win32:include(kernel/win.pri)
+symbian {
+ include(kernel/symbian.pri)
+ include(s60framework/s60framework.pri)
+}
+
+# to be moved into QtGui
+include(to_be_moved/to_be_moved.pri)
+
+#modules
+include(animation/animation.pri)
+include(kernel/kernel.pri)
+include(styles/styles.pri)
+include(widgets/widgets.pri)
+include(dialogs/dialogs.pri)
+include(accessible/accessible.pri)
+include(itemviews/itemviews.pri)
+include(inputmethod/inputmethod.pri)
+include(graphicsview/graphicsview.pri)
+include(util/util.pri)
+include(statemachine/statemachine.pri)
+include(effects/effects.pri)
+
+
+QMAKE_LIBS += $$QMAKE_LIBS_GUI
+
+contains(DEFINES,QT_EVAL):include($$QT_SOURCE_TREE/src/corelib/eval.pri)
+
+QMAKE_DYNAMIC_LIST_FILE = $$PWD/QtGui.dynlist
+
+DEFINES += Q_INTERNAL_QAPP_SRC
+symbian {
+ TARGET.UID3=0x2001B2DD
+
+ # ro-section in gui can exceed default allocated space, so move rw-section a little further
+ QMAKE_LFLAGS.ARMCC += --rw-base 0x800000
+ QMAKE_LFLAGS.GCCE += -Tdata 0x800000
+}
+
+neon:*-g++* {
+ DEFINES += QT_HAVE_NEON
+ HEADERS += $$NEON_HEADERS
+
+ DRAWHELPER_NEON_ASM_FILES = $$NEON_ASM
+
+ neon_compiler.commands = $$QMAKE_CXX -c
+ neon_compiler.commands += $(CXXFLAGS) -mfpu=neon $(INCPATH) ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
+ neon_compiler.dependency_type = TYPE_C
+ neon_compiler.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)}
+ neon_compiler.input = DRAWHELPER_NEON_ASM_FILES NEON_SOURCES
+ neon_compiler.variable_out = OBJECTS
+ neon_compiler.name = compiling[neon] ${QMAKE_FILE_IN}
+ silent:neon_compiler.commands = @echo compiling[neon] ${QMAKE_FILE_IN} && $$neon_compiler.commands
+ QMAKE_EXTRA_COMPILERS += neon_compiler
+}
+
+INCLUDEPATH += ../3rdparty/harfbuzz/src
+
+win32:!contains(QT_CONFIG, directwrite) {
+ DEFINES += QT_NO_DIRECTWRITE
+}
+
+contains(QMAKE_MAC_XARCH, no) {
+ DEFINES += QT_NO_MAC_XARCH
+} else {
+ win32-g++*|!win32:!win32-icc*:!macx-icc* {
+ mmx {
+ mmx_compiler.commands = $$QMAKE_CXX -c -Winline
+
+ mac {
+ mmx_compiler.commands += -Xarch_i386 -mmmx
+ mmx_compiler.commands += -Xarch_x86_64 -mmmx
+ } else {
+ mmx_compiler.commands += -mmmx
+ }
+
+ mmx_compiler.commands += $(CXXFLAGS) $(INCPATH) ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
+ mmx_compiler.dependency_type = TYPE_C
+ mmx_compiler.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)}
+ mmx_compiler.input = MMX_SOURCES
+ mmx_compiler.variable_out = OBJECTS
+ mmx_compiler.name = compiling[mmx] ${QMAKE_FILE_IN}
+ silent:mmx_compiler.commands = @echo compiling[mmx] ${QMAKE_FILE_IN} && $$mmx_compiler.commands
+ QMAKE_EXTRA_COMPILERS += mmx_compiler
+ }
+ 3dnow {
+ mmx3dnow_compiler.commands = $$QMAKE_CXX -c -Winline
+
+ mac {
+ mmx3dnow_compiler.commands += -Xarch_i386 -m3dnow -Xarch_i386 -mmmx
+ mmx3dnow_compiler.commands += -Xarch_x86_64 -m3dnow -Xarch_x86_64 -mmmx
+ } else {
+ mmx3dnow_compiler.commands += -m3dnow -mmmx
+ }
+
+ mmx3dnow_compiler.commands += $(CXXFLAGS) $(INCPATH) ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
+ mmx3dnow_compiler.dependency_type = TYPE_C
+ mmx3dnow_compiler.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)}
+ mmx3dnow_compiler.input = MMX3DNOW_SOURCES
+ mmx3dnow_compiler.variable_out = OBJECTS
+ mmx3dnow_compiler.name = compiling[mmx3dnow] ${QMAKE_FILE_IN}
+ silent:mmx3dnow_compiler.commands = @echo compiling[mmx3dnow] ${QMAKE_FILE_IN} && $$mmx3dnow_compiler.commands
+ QMAKE_EXTRA_COMPILERS += mmx3dnow_compiler
+ sse {
+ sse3dnow_compiler.commands = $$QMAKE_CXX -c -Winline
+
+ mac {
+ sse3dnow_compiler.commands += -Xarch_i386 -m3dnow -Xarch_i386 -msse
+ sse3dnow_compiler.commands += -Xarch_x86_64 -m3dnow -Xarch_x86_64 -msse
+ } else {
+ sse3dnow_compiler.commands += -m3dnow -msse
+ }
+
+ sse3dnow_compiler.commands += $(CXXFLAGS) $(INCPATH) ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
+ sse3dnow_compiler.dependency_type = TYPE_C
+ sse3dnow_compiler.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)}
+ sse3dnow_compiler.input = SSE3DNOW_SOURCES
+ sse3dnow_compiler.variable_out = OBJECTS
+ sse3dnow_compiler.name = compiling[sse3dnow] ${QMAKE_FILE_IN}
+ silent:sse3dnow_compiler.commands = @echo compiling[sse3dnow] ${QMAKE_FILE_IN} && $$sse3dnow_compiler.commands
+ QMAKE_EXTRA_COMPILERS += sse3dnow_compiler
+ }
+ }
+ sse {
+ sse_compiler.commands = $$QMAKE_CXX -c -Winline
+
+ mac {
+ sse_compiler.commands += -Xarch_i386 -msse
+ sse_compiler.commands += -Xarch_x86_64 -msse
+ } else {
+ sse_compiler.commands += -msse
+ }
+
+ sse_compiler.commands += $(CXXFLAGS) $(INCPATH) ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
+ sse_compiler.dependency_type = TYPE_C
+ sse_compiler.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)}
+ sse_compiler.input = SSE_SOURCES
+ sse_compiler.variable_out = OBJECTS
+ sse_compiler.name = compiling[sse] ${QMAKE_FILE_IN}
+ silent:sse_compiler.commands = @echo compiling[sse] ${QMAKE_FILE_IN} && $$sse_compiler.commands
+ QMAKE_EXTRA_COMPILERS += sse_compiler
+ }
+ sse2 {
+ sse2_compiler.commands = $$QMAKE_CXX -c -Winline
+
+ mac {
+ sse2_compiler.commands += -Xarch_i386 -msse2
+ sse2_compiler.commands += -Xarch_x86_64 -msse2
+ } else {
+ sse2_compiler.commands += -msse2
+ }
+
+ sse2_compiler.commands += $(CXXFLAGS) $(INCPATH) ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
+ sse2_compiler.dependency_type = TYPE_C
+ sse2_compiler.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)}
+ sse2_compiler.input = SSE2_SOURCES
+ sse2_compiler.variable_out = OBJECTS
+ sse2_compiler.name = compiling[sse2] ${QMAKE_FILE_IN}
+ silent:sse2_compiler.commands = @echo compiling[sse2] ${QMAKE_FILE_IN} && $$sse2_compiler.commands
+ QMAKE_EXTRA_COMPILERS += sse2_compiler
+ }
+ ssse3 {
+ ssse3_compiler.commands = $$QMAKE_CXX -c -Winline
+
+ mac {
+ ssse3_compiler.commands += -Xarch_i386 -mssse3
+ ssse3_compiler.commands += -Xarch_x86_64 -mssse3
+ } else {
+ ssse3_compiler.commands += -mssse3
+ }
+
+ ssse3_compiler.commands += $(CXXFLAGS) $(INCPATH) ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
+ ssse3_compiler.dependency_type = TYPE_C
+ ssse3_compiler.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)}
+ ssse3_compiler.input = SSSE3_SOURCES
+ ssse3_compiler.variable_out = OBJECTS
+ ssse3_compiler.name = compiling[ssse3] ${QMAKE_FILE_IN}
+ silent:ssse3_compiler.commands = @echo compiling[ssse3] ${QMAKE_FILE_IN} && $$ssse3_compiler.commands
+ QMAKE_EXTRA_COMPILERS += ssse3_compiler
+ }
+ iwmmxt {
+ iwmmxt_compiler.commands = $$QMAKE_CXX -c -Winline
+ iwmmxt_compiler.commands += -mcpu=iwmmxt
+ iwmmxt_compiler.commands += $(CXXFLAGS) $(INCPATH) ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT}
+ iwmmxt_compiler.dependency_type = TYPE_C
+ iwmmxt_compiler.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)}
+ iwmmxt_compiler.input = IWMMXT_SOURCES
+ iwmmxt_compiler.variable_out = OBJECTS
+ iwmmxt_compiler.name = compiling[iwmmxt] ${QMAKE_FILE_IN}
+ silent:iwmmxt_compiler.commands = @echo compiling[iwmmxt] ${QMAKE_FILE_IN} && $$iwmmxt_compiler.commands
+ QMAKE_EXTRA_COMPILERS += iwmmxt_compiler
+ }
+ } else {
+ mmx: SOURCES += $$MMX_SOURCES
+ 3dnow: SOURCES += $$MMX3DNOW_SOURCES
+ 3dnow:sse: SOURCES += $$SSE3DNOW_SOURCES
+ sse: SOURCES += $$SSE_SOURCES
+ sse2: SOURCES += $$SSE2_SOURCES
+ ssse3: SOURCES += $$SSSE3_SOURCES
+ iwmmxt: SOURCES += $$IWMMXT_SOURCES
+ }
+}
diff --git a/src/gui/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp
index d45c56b72d..d45c56b72d 100644
--- a/src/gui/widgets/qabstractbutton.cpp
+++ b/src/widgets/widgets/qabstractbutton.cpp
diff --git a/src/widgets/widgets/qabstractbutton.h b/src/widgets/widgets/qabstractbutton.h
new file mode 100644
index 0000000000..40ce1fd6c9
--- /dev/null
+++ b/src/widgets/widgets/qabstractbutton.h
@@ -0,0 +1,180 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QABSTRACTBUTTON_H
+#define QABSTRACTBUTTON_H
+
+#include <QtWidgets/qicon.h>
+#include <QtGui/qkeysequence.h>
+#include <QtWidgets/qwidget.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QButtonGroup;
+class QAbstractButtonPrivate;
+
+class Q_GUI_EXPORT QAbstractButton : public QWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString text READ text WRITE setText)
+ Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
+ Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
+#ifndef QT_NO_SHORTCUT
+ Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut)
+#endif
+ Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable)
+ Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled USER true)
+ Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat)
+ Q_PROPERTY(bool autoExclusive READ autoExclusive WRITE setAutoExclusive)
+ Q_PROPERTY(int autoRepeatDelay READ autoRepeatDelay WRITE setAutoRepeatDelay)
+ Q_PROPERTY(int autoRepeatInterval READ autoRepeatInterval WRITE setAutoRepeatInterval)
+ Q_PROPERTY(bool down READ isDown WRITE setDown DESIGNABLE false)
+
+public:
+ explicit QAbstractButton(QWidget* parent=0);
+ ~QAbstractButton();
+
+ void setText(const QString &text);
+ QString text() const;
+
+ void setIcon(const QIcon &icon);
+ QIcon icon() const;
+
+ QSize iconSize() const;
+
+#ifndef QT_NO_SHORTCUT
+ void setShortcut(const QKeySequence &key);
+ QKeySequence shortcut() const;
+#endif
+
+ void setCheckable(bool);
+ bool isCheckable() const;
+
+ bool isChecked() const;
+
+ void setDown(bool);
+ bool isDown() const;
+
+ void setAutoRepeat(bool);
+ bool autoRepeat() const;
+
+ void setAutoRepeatDelay(int);
+ int autoRepeatDelay() const;
+
+ void setAutoRepeatInterval(int);
+ int autoRepeatInterval() const;
+
+ void setAutoExclusive(bool);
+ bool autoExclusive() const;
+
+#ifndef QT_NO_BUTTONGROUP
+ QButtonGroup *group() const;
+#endif
+
+public Q_SLOTS:
+ void setIconSize(const QSize &size);
+ void animateClick(int msec = 100);
+ void click();
+ void toggle();
+ void setChecked(bool);
+
+Q_SIGNALS:
+ void pressed();
+ void released();
+ void clicked(bool checked = false);
+ void toggled(bool checked);
+
+protected:
+ virtual void paintEvent(QPaintEvent *e) = 0;
+ virtual bool hitButton(const QPoint &pos) const;
+ virtual void checkStateSet();
+ virtual void nextCheckState();
+
+ bool event(QEvent *e);
+ void keyPressEvent(QKeyEvent *e);
+ void keyReleaseEvent(QKeyEvent *e);
+ void mousePressEvent(QMouseEvent *e);
+ void mouseReleaseEvent(QMouseEvent *e);
+ void mouseMoveEvent(QMouseEvent *e);
+ void focusInEvent(QFocusEvent *e);
+ void focusOutEvent(QFocusEvent *e);
+ void changeEvent(QEvent *e);
+ void timerEvent(QTimerEvent *e);
+
+#ifdef QT3_SUPPORT
+public:
+ QT3_SUPPORT_CONSTRUCTOR QAbstractButton(QWidget *parent, const char *name, Qt::WindowFlags f=0);
+ inline QT3_SUPPORT bool isOn() const { return isChecked(); }
+ inline QT3_SUPPORT const QPixmap *pixmap() const { return 0; } // help styles compile
+ inline QT3_SUPPORT void setPixmap( const QPixmap &p ) {
+ setIcon(QIcon(p));
+ setIconSize(p.size());
+ }
+ QT3_SUPPORT QIcon *iconSet() const;
+ inline QT3_SUPPORT void setIconSet(const QIcon &icon) { setIcon(icon); }
+ inline QT3_SUPPORT bool isToggleButton() const { return isCheckable(); }
+ inline QT3_SUPPORT void setToggleButton(bool b) { setCheckable(b); }
+ inline QT3_SUPPORT void setAccel(const QKeySequence &key) { setShortcut(key); }
+ inline QT3_SUPPORT QKeySequence accel() const { return shortcut(); }
+
+public Q_SLOTS:
+ inline QT_MOC_COMPAT void setOn(bool b) { setChecked(b); }
+#endif
+
+protected:
+ QAbstractButton(QAbstractButtonPrivate &dd, QWidget* parent = 0);
+
+private:
+ Q_DECLARE_PRIVATE(QAbstractButton)
+ Q_DISABLE_COPY(QAbstractButton)
+ friend class QButtonGroup;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QABSTRACTBUTTON_H
diff --git a/src/gui/widgets/qabstractbutton_p.h b/src/widgets/widgets/qabstractbutton_p.h
index e3f71e409a..e3f71e409a 100644
--- a/src/gui/widgets/qabstractbutton_p.h
+++ b/src/widgets/widgets/qabstractbutton_p.h
diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp
index dabfec0225..dabfec0225 100644
--- a/src/gui/widgets/qabstractscrollarea.cpp
+++ b/src/widgets/widgets/qabstractscrollarea.cpp
diff --git a/src/widgets/widgets/qabstractscrollarea.h b/src/widgets/widgets/qabstractscrollarea.h
new file mode 100644
index 0000000000..ed2503e2ee
--- /dev/null
+++ b/src/widgets/widgets/qabstractscrollarea.h
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QABSTRACTSCROLLAREA_H
+#define QABSTRACTSCROLLAREA_H
+
+#include <QtWidgets/qframe.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_SCROLLAREA
+
+class QMargins;
+class QScrollBar;
+class QAbstractScrollAreaPrivate;
+
+class Q_GUI_EXPORT QAbstractScrollArea : public QFrame
+{
+ Q_OBJECT
+ Q_PROPERTY(Qt::ScrollBarPolicy verticalScrollBarPolicy READ verticalScrollBarPolicy WRITE setVerticalScrollBarPolicy)
+ Q_PROPERTY(Qt::ScrollBarPolicy horizontalScrollBarPolicy READ horizontalScrollBarPolicy WRITE setHorizontalScrollBarPolicy)
+
+public:
+ explicit QAbstractScrollArea(QWidget* parent=0);
+ ~QAbstractScrollArea();
+
+ Qt::ScrollBarPolicy verticalScrollBarPolicy() const;
+ void setVerticalScrollBarPolicy(Qt::ScrollBarPolicy);
+ QScrollBar *verticalScrollBar() const;
+ void setVerticalScrollBar(QScrollBar *scrollbar);
+
+ Qt::ScrollBarPolicy horizontalScrollBarPolicy() const;
+ void setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy);
+ QScrollBar *horizontalScrollBar() const;
+ void setHorizontalScrollBar(QScrollBar *scrollbar);
+
+ QWidget *cornerWidget() const;
+ void setCornerWidget(QWidget *widget);
+
+ void addScrollBarWidget(QWidget *widget, Qt::Alignment alignment);
+ QWidgetList scrollBarWidgets(Qt::Alignment alignment);
+
+ QWidget *viewport() const;
+ void setViewport(QWidget *widget);
+ QSize maximumViewportSize() const;
+
+ QSize minimumSizeHint() const;
+
+ QSize sizeHint() const;
+
+protected Q_SLOTS:
+ void setupViewport(QWidget *viewport);
+
+protected:
+ QAbstractScrollArea(QAbstractScrollAreaPrivate &dd, QWidget *parent = 0);
+ void setViewportMargins(int left, int top, int right, int bottom);
+ void setViewportMargins(const QMargins &margins);
+
+ bool event(QEvent *);
+ virtual bool viewportEvent(QEvent *);
+
+ void resizeEvent(QResizeEvent *);
+ void paintEvent(QPaintEvent *);
+ void mousePressEvent(QMouseEvent *);
+ void mouseReleaseEvent(QMouseEvent *);
+ void mouseDoubleClickEvent(QMouseEvent *);
+ void mouseMoveEvent(QMouseEvent *);
+#ifndef QT_NO_WHEELEVENT
+ void wheelEvent(QWheelEvent *);
+#endif
+#ifndef QT_NO_CONTEXTMENU
+ void contextMenuEvent(QContextMenuEvent *);
+#endif
+#ifndef QT_NO_DRAGANDDROP
+ void dragEnterEvent(QDragEnterEvent *);
+ void dragMoveEvent(QDragMoveEvent *);
+ void dragLeaveEvent(QDragLeaveEvent *);
+ void dropEvent(QDropEvent *);
+#endif
+
+ void keyPressEvent(QKeyEvent *);
+
+ virtual void scrollContentsBy(int dx, int dy);
+
+private:
+ Q_DECLARE_PRIVATE(QAbstractScrollArea)
+ Q_DISABLE_COPY(QAbstractScrollArea)
+ Q_PRIVATE_SLOT(d_func(), void _q_hslide(int))
+ Q_PRIVATE_SLOT(d_func(), void _q_vslide(int))
+ Q_PRIVATE_SLOT(d_func(), void _q_showOrHideScrollBars())
+
+ friend class QStyleSheetStyle;
+ friend class QWidgetPrivate;
+};
+
+#endif // QT_NO_SCROLLAREA
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QABSTRACTSCROLLAREA_H
diff --git a/src/gui/widgets/qabstractscrollarea_p.h b/src/widgets/widgets/qabstractscrollarea_p.h
index 76e1c34868..76e1c34868 100644
--- a/src/gui/widgets/qabstractscrollarea_p.h
+++ b/src/widgets/widgets/qabstractscrollarea_p.h
diff --git a/src/gui/widgets/qabstractslider.cpp b/src/widgets/widgets/qabstractslider.cpp
index 2570496262..2570496262 100644
--- a/src/gui/widgets/qabstractslider.cpp
+++ b/src/widgets/widgets/qabstractslider.cpp
diff --git a/src/widgets/widgets/qabstractslider.h b/src/widgets/widgets/qabstractslider.h
new file mode 100644
index 0000000000..0aef801d3d
--- /dev/null
+++ b/src/widgets/widgets/qabstractslider.h
@@ -0,0 +1,184 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QABSTRACTSLIDER_H
+#define QABSTRACTSLIDER_H
+
+#include <QtWidgets/qwidget.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QAbstractSliderPrivate;
+
+class Q_GUI_EXPORT QAbstractSlider : public QWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(int minimum READ minimum WRITE setMinimum)
+ Q_PROPERTY(int maximum READ maximum WRITE setMaximum)
+ Q_PROPERTY(int singleStep READ singleStep WRITE setSingleStep)
+ Q_PROPERTY(int pageStep READ pageStep WRITE setPageStep)
+ Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged USER true)
+ Q_PROPERTY(int sliderPosition READ sliderPosition WRITE setSliderPosition NOTIFY sliderMoved)
+ Q_PROPERTY(bool tracking READ hasTracking WRITE setTracking)
+ Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
+ Q_PROPERTY(bool invertedAppearance READ invertedAppearance WRITE setInvertedAppearance)
+ Q_PROPERTY(bool invertedControls READ invertedControls WRITE setInvertedControls)
+ Q_PROPERTY(bool sliderDown READ isSliderDown WRITE setSliderDown DESIGNABLE false)
+
+public:
+ explicit QAbstractSlider(QWidget *parent=0);
+ ~QAbstractSlider();
+
+ Qt::Orientation orientation() const;
+
+ void setMinimum(int);
+ int minimum() const;
+
+ void setMaximum(int);
+ int maximum() const;
+
+ void setRange(int min, int max);
+
+ void setSingleStep(int);
+ int singleStep() const;
+
+ void setPageStep(int);
+ int pageStep() const;
+
+ void setTracking(bool enable);
+ bool hasTracking() const;
+
+ void setSliderDown(bool);
+ bool isSliderDown() const;
+
+ void setSliderPosition(int);
+ int sliderPosition() const;
+
+ void setInvertedAppearance(bool);
+ bool invertedAppearance() const;
+
+ void setInvertedControls(bool);
+ bool invertedControls() const;
+
+ enum SliderAction {
+ SliderNoAction,
+ SliderSingleStepAdd,
+ SliderSingleStepSub,
+ SliderPageStepAdd,
+ SliderPageStepSub,
+ SliderToMinimum,
+ SliderToMaximum,
+ SliderMove
+ };
+
+ int value() const;
+
+ void triggerAction(SliderAction action);
+
+public Q_SLOTS:
+ void setValue(int);
+ void setOrientation(Qt::Orientation);
+
+Q_SIGNALS:
+ void valueChanged(int value);
+
+ void sliderPressed();
+ void sliderMoved(int position);
+ void sliderReleased();
+
+ void rangeChanged(int min, int max);
+
+ void actionTriggered(int action);
+
+protected:
+ bool event(QEvent *e);
+
+ void setRepeatAction(SliderAction action, int thresholdTime = 500, int repeatTime = 50);
+ SliderAction repeatAction() const;
+
+ enum SliderChange {
+ SliderRangeChange,
+ SliderOrientationChange,
+ SliderStepsChange,
+ SliderValueChange
+ };
+ virtual void sliderChange(SliderChange change);
+
+ void keyPressEvent(QKeyEvent *ev);
+ void timerEvent(QTimerEvent *);
+#ifndef QT_NO_WHEELEVENT
+ void wheelEvent(QWheelEvent *e);
+#endif
+ void changeEvent(QEvent *e);
+
+#ifdef QT3_SUPPORT
+public:
+ inline QT3_SUPPORT int minValue() const { return minimum(); }
+ inline QT3_SUPPORT int maxValue() const { return maximum(); }
+ inline QT3_SUPPORT int lineStep() const { return singleStep(); }
+ inline QT3_SUPPORT void setMinValue(int v) { setMinimum(v); }
+ inline QT3_SUPPORT void setMaxValue(int v) { setMaximum(v); }
+ inline QT3_SUPPORT void setLineStep(int v) { setSingleStep(v); }
+ inline QT3_SUPPORT void setSteps(int single, int page) { setSingleStep(single); setPageStep(page); }
+ inline QT3_SUPPORT void addPage() { triggerAction(SliderPageStepAdd); }
+ inline QT3_SUPPORT void subtractPage() { triggerAction(SliderPageStepSub); }
+ inline QT3_SUPPORT void addLine() { triggerAction(SliderSingleStepAdd); }
+ inline QT3_SUPPORT void subtractLine() { triggerAction(SliderSingleStepSub); }
+#endif
+
+protected:
+ QAbstractSlider(QAbstractSliderPrivate &dd, QWidget *parent=0);
+
+private:
+ Q_DISABLE_COPY(QAbstractSlider)
+ Q_DECLARE_PRIVATE(QAbstractSlider)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QABSTRACTSLIDER_H
diff --git a/src/gui/widgets/qabstractslider_p.h b/src/widgets/widgets/qabstractslider_p.h
index 8887b47b47..8887b47b47 100644
--- a/src/gui/widgets/qabstractslider_p.h
+++ b/src/widgets/widgets/qabstractslider_p.h
diff --git a/src/gui/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp
index 34991ab236..34991ab236 100644
--- a/src/gui/widgets/qabstractspinbox.cpp
+++ b/src/widgets/widgets/qabstractspinbox.cpp
diff --git a/src/widgets/widgets/qabstractspinbox.h b/src/widgets/widgets/qabstractspinbox.h
new file mode 100644
index 0000000000..507921e272
--- /dev/null
+++ b/src/widgets/widgets/qabstractspinbox.h
@@ -0,0 +1,181 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QABSTRACTSPINBOX_H
+#define QABSTRACTSPINBOX_H
+
+#include <QtWidgets/qwidget.h>
+#include <QtGui/qvalidator.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_SPINBOX
+
+class QLineEdit;
+
+class QAbstractSpinBoxPrivate;
+class QStyleOptionSpinBox;
+
+class Q_GUI_EXPORT QAbstractSpinBox : public QWidget
+{
+ Q_OBJECT
+
+ Q_ENUMS(ButtonSymbols)
+ Q_ENUMS(CorrectionMode)
+ Q_PROPERTY(bool wrapping READ wrapping WRITE setWrapping)
+ Q_PROPERTY(bool frame READ hasFrame WRITE setFrame)
+ Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
+ Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
+ Q_PROPERTY(ButtonSymbols buttonSymbols READ buttonSymbols WRITE setButtonSymbols)
+ Q_PROPERTY(QString specialValueText READ specialValueText WRITE setSpecialValueText)
+ Q_PROPERTY(QString text READ text)
+ Q_PROPERTY(bool accelerated READ isAccelerated WRITE setAccelerated)
+ Q_PROPERTY(CorrectionMode correctionMode READ correctionMode WRITE setCorrectionMode)
+ Q_PROPERTY(bool acceptableInput READ hasAcceptableInput)
+ Q_PROPERTY(bool keyboardTracking READ keyboardTracking WRITE setKeyboardTracking)
+public:
+ explicit QAbstractSpinBox(QWidget *parent = 0);
+ ~QAbstractSpinBox();
+
+ enum StepEnabledFlag { StepNone = 0x00, StepUpEnabled = 0x01,
+ StepDownEnabled = 0x02 };
+ Q_DECLARE_FLAGS(StepEnabled, StepEnabledFlag)
+
+ enum ButtonSymbols { UpDownArrows, PlusMinus, NoButtons };
+
+ ButtonSymbols buttonSymbols() const;
+ void setButtonSymbols(ButtonSymbols bs);
+
+ enum CorrectionMode { CorrectToPreviousValue, CorrectToNearestValue };
+
+ void setCorrectionMode(CorrectionMode cm);
+ CorrectionMode correctionMode() const;
+
+ bool hasAcceptableInput() const;
+ QString text() const;
+
+ QString specialValueText() const;
+ void setSpecialValueText(const QString &txt);
+
+ bool wrapping() const;
+ void setWrapping(bool w);
+
+ void setReadOnly(bool r);
+ bool isReadOnly() const;
+
+ void setKeyboardTracking(bool kt);
+ bool keyboardTracking() const;
+
+ void setAlignment(Qt::Alignment flag);
+ Qt::Alignment alignment() const;
+
+ void setFrame(bool);
+ bool hasFrame() const;
+
+ void setAccelerated(bool on);
+ bool isAccelerated() const;
+
+ QSize sizeHint() const;
+ QSize minimumSizeHint() const;
+ void interpretText();
+ bool event(QEvent *event);
+
+ QVariant inputMethodQuery(Qt::InputMethodQuery) const;
+
+ virtual QValidator::State validate(QString &input, int &pos) const;
+ virtual void fixup(QString &input) const;
+
+ virtual void stepBy(int steps);
+public Q_SLOTS:
+ void stepUp();
+ void stepDown();
+ void selectAll();
+ virtual void clear();
+protected:
+ void resizeEvent(QResizeEvent *event);
+ void keyPressEvent(QKeyEvent *event);
+ void keyReleaseEvent(QKeyEvent *event);
+#ifndef QT_NO_WHEELEVENT
+ void wheelEvent(QWheelEvent *event);
+#endif
+ void focusInEvent(QFocusEvent *event);
+ void focusOutEvent(QFocusEvent *event);
+ void contextMenuEvent(QContextMenuEvent *event);
+ void changeEvent(QEvent *event);
+ void closeEvent(QCloseEvent *event);
+ void hideEvent(QHideEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+ void timerEvent(QTimerEvent *event);
+ void paintEvent(QPaintEvent *event);
+ void showEvent(QShowEvent *event);
+ void initStyleOption(QStyleOptionSpinBox *option) const;
+
+ QLineEdit *lineEdit() const;
+ void setLineEdit(QLineEdit *edit);
+
+ virtual StepEnabled stepEnabled() const;
+Q_SIGNALS:
+ void editingFinished();
+protected:
+ QAbstractSpinBox(QAbstractSpinBoxPrivate &dd, QWidget *parent = 0);
+
+private:
+ Q_PRIVATE_SLOT(d_func(), void _q_editorTextChanged(const QString &))
+ Q_PRIVATE_SLOT(d_func(), void _q_editorCursorPositionChanged(int, int))
+
+ Q_DECLARE_PRIVATE(QAbstractSpinBox)
+ Q_DISABLE_COPY(QAbstractSpinBox)
+};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QAbstractSpinBox::StepEnabled)
+
+#endif // QT_NO_SPINBOX
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QABSTRACTSPINBOX_H
diff --git a/src/widgets/widgets/qabstractspinbox_p.h b/src/widgets/widgets/qabstractspinbox_p.h
new file mode 100644
index 0000000000..b7524387ca
--- /dev/null
+++ b/src/widgets/widgets/qabstractspinbox_p.h
@@ -0,0 +1,170 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QABSTRACTSPINBOX_P_H
+#define QABSTRACTSPINBOX_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "QtWidgets/qabstractspinbox.h"
+
+#ifndef QT_NO_SPINBOX
+
+#include "QtWidgets/qlineedit.h"
+#include "QtWidgets/qstyleoption.h"
+#include "QtGui/qvalidator.h"
+#include "QtCore/qdatetime.h"
+#include "QtCore/qvariant.h"
+#include "private/qwidget_p.h"
+#include "private/qdatetime_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QVariant operator+(const QVariant &arg1, const QVariant &arg2);
+QVariant operator-(const QVariant &arg1, const QVariant &arg2);
+QVariant operator*(const QVariant &arg1, double multiplier);
+double operator/(const QVariant &arg1, const QVariant &arg2);
+
+enum EmitPolicy {
+ EmitIfChanged,
+ AlwaysEmit,
+ NeverEmit
+};
+
+enum Button {
+ None = 0x000,
+ Keyboard = 0x001,
+ Mouse = 0x002,
+ Wheel = 0x004,
+ ButtonMask = 0x008,
+ Up = 0x010,
+ Down = 0x020,
+ DirectionMask = 0x040
+};
+class QSpinBoxValidator;
+class QAbstractSpinBoxPrivate : public QWidgetPrivate
+{
+ Q_DECLARE_PUBLIC(QAbstractSpinBox)
+public:
+ QAbstractSpinBoxPrivate();
+ ~QAbstractSpinBoxPrivate();
+
+ void init();
+ void reset();
+ void updateState(bool up, bool fromKeyboard = false);
+ QString stripped(const QString &text, int *pos = 0) const;
+ bool specialValue() const;
+ virtual QVariant getZeroVariant() const;
+ virtual void setRange(const QVariant &min, const QVariant &max);
+ void setValue(const QVariant &val, EmitPolicy ep, bool updateEdit = true);
+ virtual QVariant bound(const QVariant &val, const QVariant &old = QVariant(), int steps = 0) const;
+ virtual void updateEdit();
+
+ virtual void emitSignals(EmitPolicy ep, const QVariant &old);
+ virtual void interpret(EmitPolicy ep);
+ virtual QString textFromValue(const QVariant &n) const;
+ virtual QVariant valueFromText(const QString &input) const;
+
+ void _q_editorTextChanged(const QString &);
+ virtual void _q_editorCursorPositionChanged(int oldpos, int newpos);
+
+ virtual QStyle::SubControl newHoverControl(const QPoint &pos);
+ bool updateHoverControl(const QPoint &pos);
+
+ virtual void clearCache() const;
+ virtual void updateEditFieldGeometry();
+
+ static int variantCompare(const QVariant &arg1, const QVariant &arg2);
+ static QVariant variantBound(const QVariant &min, const QVariant &value, const QVariant &max);
+
+ QLineEdit *edit;
+ QString prefix, suffix, specialValueText;
+ QVariant value, minimum, maximum, singleStep;
+ QVariant::Type type;
+ int spinClickTimerId, spinClickTimerInterval, spinClickThresholdTimerId, spinClickThresholdTimerInterval;
+ int effectiveSpinRepeatRate;
+ uint buttonState;
+ mutable QString cachedText;
+ mutable QVariant cachedValue;
+ mutable QValidator::State cachedState;
+ mutable QSize cachedSizeHint, cachedMinimumSizeHint;
+ uint pendingEmit : 1;
+ uint readOnly : 1;
+ uint wrapping : 1;
+ uint ignoreCursorPositionChanged : 1;
+ uint frame : 1;
+ uint accelerate : 1;
+ uint keyboardTracking : 1;
+ uint cleared : 1;
+ uint ignoreUpdateEdit : 1;
+ QAbstractSpinBox::CorrectionMode correctionMode;
+ int acceleration;
+ QStyle::SubControl hoverControl;
+ QRect hoverRect;
+ QAbstractSpinBox::ButtonSymbols buttonSymbols;
+ QSpinBoxValidator *validator;
+};
+
+class QSpinBoxValidator : public QValidator
+{
+public:
+ QSpinBoxValidator(QAbstractSpinBox *qptr, QAbstractSpinBoxPrivate *dptr);
+ QValidator::State validate(QString &input, int &) const;
+ void fixup(QString &) const;
+private:
+ QAbstractSpinBox *qptr;
+ QAbstractSpinBoxPrivate *dptr;
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_SPINBOX
+
+#endif // QABSTRACTSPINBOX_P_H
diff --git a/src/gui/widgets/qbuttongroup.cpp b/src/widgets/widgets/qbuttongroup.cpp
index c4a37153a6..c4a37153a6 100644
--- a/src/gui/widgets/qbuttongroup.cpp
+++ b/src/widgets/widgets/qbuttongroup.cpp
diff --git a/src/gui/widgets/qbuttongroup.h b/src/widgets/widgets/qbuttongroup.h
index 5c5522f229..5c5522f229 100644
--- a/src/gui/widgets/qbuttongroup.h
+++ b/src/widgets/widgets/qbuttongroup.h
diff --git a/src/gui/widgets/qcalendartextnavigator_p.h b/src/widgets/widgets/qcalendartextnavigator_p.h
index 0aaad4689f..0aaad4689f 100644
--- a/src/gui/widgets/qcalendartextnavigator_p.h
+++ b/src/widgets/widgets/qcalendartextnavigator_p.h
diff --git a/src/gui/widgets/qcalendarwidget.cpp b/src/widgets/widgets/qcalendarwidget.cpp
index d6a6f14e3f..d6a6f14e3f 100644
--- a/src/gui/widgets/qcalendarwidget.cpp
+++ b/src/widgets/widgets/qcalendarwidget.cpp
diff --git a/src/widgets/widgets/qcalendarwidget.h b/src/widgets/widgets/qcalendarwidget.h
new file mode 100644
index 0000000000..0d768a333c
--- /dev/null
+++ b/src/widgets/widgets/qcalendarwidget.h
@@ -0,0 +1,204 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCALENDARWIDGET_H
+#define QCALENDARWIDGET_H
+
+#include <QtWidgets/qwidget.h>
+#include <QtCore/qdatetime.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_CALENDARWIDGET
+
+class QDate;
+class QTextCharFormat;
+class QCalendarWidgetPrivate;
+
+class Q_GUI_EXPORT QCalendarWidget : public QWidget
+{
+ Q_OBJECT
+ Q_ENUMS(Qt::DayOfWeek)
+ Q_ENUMS(HorizontalHeaderFormat)
+ Q_ENUMS(VerticalHeaderFormat)
+ Q_ENUMS(SelectionMode)
+ Q_PROPERTY(QDate selectedDate READ selectedDate WRITE setSelectedDate)
+ Q_PROPERTY(QDate minimumDate READ minimumDate WRITE setMinimumDate)
+ Q_PROPERTY(QDate maximumDate READ maximumDate WRITE setMaximumDate)
+ Q_PROPERTY(Qt::DayOfWeek firstDayOfWeek READ firstDayOfWeek WRITE setFirstDayOfWeek)
+ Q_PROPERTY(bool gridVisible READ isGridVisible WRITE setGridVisible)
+ Q_PROPERTY(SelectionMode selectionMode READ selectionMode WRITE setSelectionMode)
+ Q_PROPERTY(HorizontalHeaderFormat horizontalHeaderFormat READ horizontalHeaderFormat WRITE setHorizontalHeaderFormat)
+ Q_PROPERTY(VerticalHeaderFormat verticalHeaderFormat READ verticalHeaderFormat WRITE setVerticalHeaderFormat)
+ Q_PROPERTY(bool headerVisible READ isHeaderVisible WRITE setHeaderVisible STORED false DESIGNABLE false) // obsolete
+ Q_PROPERTY(bool navigationBarVisible READ isNavigationBarVisible WRITE setNavigationBarVisible)
+ Q_PROPERTY(bool dateEditEnabled READ isDateEditEnabled WRITE setDateEditEnabled)
+ Q_PROPERTY(int dateEditAcceptDelay READ dateEditAcceptDelay WRITE setDateEditAcceptDelay)
+
+public:
+ enum HorizontalHeaderFormat {
+ NoHorizontalHeader,
+ SingleLetterDayNames,
+ ShortDayNames,
+ LongDayNames
+ };
+
+ enum VerticalHeaderFormat {
+ NoVerticalHeader,
+ ISOWeekNumbers
+ };
+
+ enum SelectionMode {
+ NoSelection,
+ SingleSelection
+ };
+
+ explicit QCalendarWidget(QWidget *parent = 0);
+ ~QCalendarWidget();
+
+ virtual QSize sizeHint() const;
+ virtual QSize minimumSizeHint() const;
+
+ QDate selectedDate() const;
+
+ int yearShown() const;
+ int monthShown() const;
+
+ QDate minimumDate() const;
+ void setMinimumDate(const QDate &date);
+
+ QDate maximumDate() const;
+ void setMaximumDate(const QDate &date);
+
+ Qt::DayOfWeek firstDayOfWeek() const;
+ void setFirstDayOfWeek(Qt::DayOfWeek dayOfWeek);
+
+ // ### Qt 5: eliminate these two
+ bool isHeaderVisible() const;
+ void setHeaderVisible(bool show);
+
+ inline bool isNavigationBarVisible() const { return isHeaderVisible(); }
+
+ bool isGridVisible() const;
+
+ SelectionMode selectionMode() const;
+ void setSelectionMode(SelectionMode mode);
+
+ HorizontalHeaderFormat horizontalHeaderFormat() const;
+ void setHorizontalHeaderFormat(HorizontalHeaderFormat format);
+
+ VerticalHeaderFormat verticalHeaderFormat() const;
+ void setVerticalHeaderFormat(VerticalHeaderFormat format);
+
+ QTextCharFormat headerTextFormat() const;
+ void setHeaderTextFormat(const QTextCharFormat &format);
+
+ QTextCharFormat weekdayTextFormat(Qt::DayOfWeek dayOfWeek) const;
+ void setWeekdayTextFormat(Qt::DayOfWeek dayOfWeek, const QTextCharFormat &format);
+
+ QMap<QDate, QTextCharFormat> dateTextFormat() const;
+ QTextCharFormat dateTextFormat(const QDate &date) const;
+ void setDateTextFormat(const QDate &date, const QTextCharFormat &format);
+
+ bool isDateEditEnabled() const;
+ void setDateEditEnabled(bool enable);
+
+ int dateEditAcceptDelay() const;
+ void setDateEditAcceptDelay(int delay);
+
+protected:
+ bool event(QEvent *event);
+ bool eventFilter(QObject *watched, QEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+ void resizeEvent(QResizeEvent * event);
+ void keyPressEvent(QKeyEvent * event);
+
+ virtual void paintCell(QPainter *painter, const QRect &rect, const QDate &date) const;
+ void updateCell(const QDate &date);
+ void updateCells();
+
+public Q_SLOTS:
+ void setSelectedDate(const QDate &date);
+ void setDateRange(const QDate &min, const QDate &max);
+ void setCurrentPage(int year, int month);
+ void setGridVisible(bool show);
+ void setNavigationBarVisible(bool visible);
+ void showNextMonth();
+ void showPreviousMonth();
+ void showNextYear();
+ void showPreviousYear();
+ void showSelectedDate();
+ void showToday();
+
+Q_SIGNALS:
+ void selectionChanged();
+ void clicked(const QDate &date);
+ void activated(const QDate &date);
+ void currentPageChanged(int year, int month);
+
+private:
+ Q_DECLARE_PRIVATE(QCalendarWidget)
+ Q_DISABLE_COPY(QCalendarWidget)
+
+ Q_PRIVATE_SLOT(d_func(), void _q_slotShowDate(const QDate &date))
+ Q_PRIVATE_SLOT(d_func(), void _q_slotChangeDate(const QDate &date))
+ Q_PRIVATE_SLOT(d_func(), void _q_slotChangeDate(const QDate &date, bool changeMonth))
+ Q_PRIVATE_SLOT(d_func(), void _q_editingFinished())
+ Q_PRIVATE_SLOT(d_func(), void _q_prevMonthClicked())
+ Q_PRIVATE_SLOT(d_func(), void _q_nextMonthClicked())
+ Q_PRIVATE_SLOT(d_func(), void _q_yearEditingFinished())
+ Q_PRIVATE_SLOT(d_func(), void _q_yearClicked())
+ Q_PRIVATE_SLOT(d_func(), void _q_monthChanged(QAction *act))
+
+};
+
+#endif // QT_NO_CALENDARWIDGET
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QCALENDARWIDGET_H
+
diff --git a/src/gui/widgets/qcheckbox.cpp b/src/widgets/widgets/qcheckbox.cpp
index df2512c1c8..df2512c1c8 100644
--- a/src/gui/widgets/qcheckbox.cpp
+++ b/src/widgets/widgets/qcheckbox.cpp
diff --git a/src/widgets/widgets/qcheckbox.h b/src/widgets/widgets/qcheckbox.h
new file mode 100644
index 0000000000..f3d5cc185d
--- /dev/null
+++ b/src/widgets/widgets/qcheckbox.h
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCHECKBOX_H
+#define QCHECKBOX_H
+
+#include <QtWidgets/qabstractbutton.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QCheckBoxPrivate;
+class QStyleOptionButton;
+
+class Q_GUI_EXPORT QCheckBox : public QAbstractButton
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool tristate READ isTristate WRITE setTristate)
+
+public:
+ explicit QCheckBox(QWidget *parent=0);
+ explicit QCheckBox(const QString &text, QWidget *parent=0);
+
+
+ QSize sizeHint() const;
+ QSize minimumSizeHint() const;
+
+ void setTristate(bool y = true);
+ bool isTristate() const;
+
+ Qt::CheckState checkState() const;
+ void setCheckState(Qt::CheckState state);
+
+Q_SIGNALS:
+ void stateChanged(int);
+
+protected:
+ bool event(QEvent *e);
+ bool hitButton(const QPoint &pos) const;
+ void checkStateSet();
+ void nextCheckState();
+ void paintEvent(QPaintEvent *);
+ void mouseMoveEvent(QMouseEvent *);
+ void initStyleOption(QStyleOptionButton *option) const;
+
+#ifdef QT3_SUPPORT
+public:
+ enum ToggleState {
+ Off = Qt::Unchecked,
+ NoChange = Qt::PartiallyChecked,
+ On = Qt::Checked
+ };
+ inline QT3_SUPPORT ToggleState state() const
+ { return static_cast<QCheckBox::ToggleState>(static_cast<int>(checkState())); }
+ inline QT3_SUPPORT void setState(ToggleState state)
+ { setCheckState(static_cast<Qt::CheckState>(static_cast<int>(state))); }
+ inline QT3_SUPPORT void setNoChange()
+ { setCheckState(Qt::PartiallyChecked); }
+ QT3_SUPPORT_CONSTRUCTOR QCheckBox(QWidget *parent, const char* name);
+ QT3_SUPPORT_CONSTRUCTOR QCheckBox(const QString &text, QWidget *parent, const char* name);
+#endif
+
+private:
+ Q_DECLARE_PRIVATE(QCheckBox)
+ Q_DISABLE_COPY(QCheckBox)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QCHECKBOX_H
diff --git a/src/gui/widgets/qcocoamenu_mac.mm b/src/widgets/widgets/qcocoamenu_mac.mm
index dff37b49ad..dff37b49ad 100644
--- a/src/gui/widgets/qcocoamenu_mac.mm
+++ b/src/widgets/widgets/qcocoamenu_mac.mm
diff --git a/src/gui/widgets/qcocoamenu_mac_p.h b/src/widgets/widgets/qcocoamenu_mac_p.h
index 42a43f7a51..42a43f7a51 100644
--- a/src/gui/widgets/qcocoamenu_mac_p.h
+++ b/src/widgets/widgets/qcocoamenu_mac_p.h
diff --git a/src/gui/widgets/qcocoatoolbardelegate_mac.mm b/src/widgets/widgets/qcocoatoolbardelegate_mac.mm
index a5ce0d3459..a5ce0d3459 100644
--- a/src/gui/widgets/qcocoatoolbardelegate_mac.mm
+++ b/src/widgets/widgets/qcocoatoolbardelegate_mac.mm
diff --git a/src/gui/widgets/qcocoatoolbardelegate_mac_p.h b/src/widgets/widgets/qcocoatoolbardelegate_mac_p.h
index 1542dcf2fa..1542dcf2fa 100644
--- a/src/gui/widgets/qcocoatoolbardelegate_mac_p.h
+++ b/src/widgets/widgets/qcocoatoolbardelegate_mac_p.h
diff --git a/src/gui/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index dd1ad9cd28..dd1ad9cd28 100644
--- a/src/gui/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h
new file mode 100644
index 0000000000..bfba3c7e6b
--- /dev/null
+++ b/src/widgets/widgets/qcombobox.h
@@ -0,0 +1,339 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCOMBOBOX_H
+#define QCOMBOBOX_H
+
+#include <QtWidgets/qwidget.h>
+#include <QtWidgets/qabstractitemdelegate.h>
+#include <QtCore/qabstractitemmodel.h>
+#include <QtCore/qvariant.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+#ifndef QT_NO_COMBOBOX
+
+class QAbstractItemView;
+class QLineEdit;
+class QComboBoxPrivate;
+class QCompleter;
+
+class Q_GUI_EXPORT QComboBox : public QWidget
+{
+ Q_OBJECT
+
+ Q_ENUMS(InsertPolicy)
+ Q_ENUMS(SizeAdjustPolicy)
+ Q_PROPERTY(bool editable READ isEditable WRITE setEditable)
+ Q_PROPERTY(int count READ count)
+ Q_PROPERTY(QString currentText READ currentText)
+ Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged USER true)
+ Q_PROPERTY(int maxVisibleItems READ maxVisibleItems WRITE setMaxVisibleItems)
+ Q_PROPERTY(int maxCount READ maxCount WRITE setMaxCount)
+ Q_PROPERTY(InsertPolicy insertPolicy READ insertPolicy WRITE setInsertPolicy)
+ Q_PROPERTY(SizeAdjustPolicy sizeAdjustPolicy READ sizeAdjustPolicy WRITE setSizeAdjustPolicy)
+ Q_PROPERTY(int minimumContentsLength READ minimumContentsLength WRITE setMinimumContentsLength)
+ Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
+
+#ifndef QT_NO_COMPLETER
+ Q_PROPERTY(bool autoCompletion READ autoCompletion WRITE setAutoCompletion DESIGNABLE false)
+ Q_PROPERTY(Qt::CaseSensitivity autoCompletionCaseSensitivity READ autoCompletionCaseSensitivity WRITE setAutoCompletionCaseSensitivity DESIGNABLE false)
+#endif // QT_NO_COMPLETER
+
+ Q_PROPERTY(bool duplicatesEnabled READ duplicatesEnabled WRITE setDuplicatesEnabled)
+ Q_PROPERTY(bool frame READ hasFrame WRITE setFrame)
+ Q_PROPERTY(int modelColumn READ modelColumn WRITE setModelColumn)
+
+public:
+ explicit QComboBox(QWidget *parent = 0);
+ ~QComboBox();
+
+ int maxVisibleItems() const;
+ void setMaxVisibleItems(int maxItems);
+
+ int count() const;
+ void setMaxCount(int max);
+ int maxCount() const;
+
+#ifndef QT_NO_COMPLETER
+ bool autoCompletion() const;
+ void setAutoCompletion(bool enable);
+
+ Qt::CaseSensitivity autoCompletionCaseSensitivity() const;
+ void setAutoCompletionCaseSensitivity(Qt::CaseSensitivity sensitivity);
+#endif
+
+ bool duplicatesEnabled() const;
+ void setDuplicatesEnabled(bool enable);
+
+ void setFrame(bool);
+ bool hasFrame() const;
+
+ inline int findText(const QString &text,
+ Qt::MatchFlags flags = static_cast<Qt::MatchFlags>(Qt::MatchExactly|Qt::MatchCaseSensitive)) const
+ { return findData(text, Qt::DisplayRole, flags); }
+ int findData(const QVariant &data, int role = Qt::UserRole,
+ Qt::MatchFlags flags = static_cast<Qt::MatchFlags>(Qt::MatchExactly|Qt::MatchCaseSensitive)) const;
+
+ enum InsertPolicy {
+ NoInsert,
+ InsertAtTop,
+ InsertAtCurrent,
+ InsertAtBottom,
+ InsertAfterCurrent,
+ InsertBeforeCurrent,
+ InsertAlphabetically
+#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
+ ,
+ NoInsertion = NoInsert,
+ AtTop = InsertAtTop,
+ AtCurrent = InsertAtCurrent,
+ AtBottom = InsertAtBottom,
+ AfterCurrent = InsertAfterCurrent,
+ BeforeCurrent = InsertBeforeCurrent
+#endif
+ };
+#ifdef QT3_SUPPORT
+ typedef InsertPolicy Policy;
+#endif
+
+ InsertPolicy insertPolicy() const;
+ void setInsertPolicy(InsertPolicy policy);
+
+ enum SizeAdjustPolicy {
+ AdjustToContents,
+ AdjustToContentsOnFirstShow,
+ AdjustToMinimumContentsLength, // ### Qt 5: remove
+ AdjustToMinimumContentsLengthWithIcon
+ };
+
+ SizeAdjustPolicy sizeAdjustPolicy() const;
+ void setSizeAdjustPolicy(SizeAdjustPolicy policy);
+ int minimumContentsLength() const;
+ void setMinimumContentsLength(int characters);
+ QSize iconSize() const;
+ void setIconSize(const QSize &size);
+
+ bool isEditable() const;
+ void setEditable(bool editable);
+ void setLineEdit(QLineEdit *edit);
+ QLineEdit *lineEdit() const;
+#ifndef QT_NO_VALIDATOR
+ void setValidator(const QValidator *v);
+ const QValidator *validator() const;
+#endif
+
+#ifndef QT_NO_COMPLETER
+ void setCompleter(QCompleter *c);
+ QCompleter *completer() const;
+#endif
+
+ QAbstractItemDelegate *itemDelegate() const;
+ void setItemDelegate(QAbstractItemDelegate *delegate);
+
+ QAbstractItemModel *model() const;
+ void setModel(QAbstractItemModel *model);
+
+ QModelIndex rootModelIndex() const;
+ void setRootModelIndex(const QModelIndex &index);
+
+ int modelColumn() const;
+ void setModelColumn(int visibleColumn);
+
+ int currentIndex() const;
+
+ QString currentText() const;
+
+ QString itemText(int index) const;
+ QIcon itemIcon(int index) const;
+ QVariant itemData(int index, int role = Qt::UserRole) const;
+
+ inline void addItem(const QString &text, const QVariant &userData = QVariant());
+ inline void addItem(const QIcon &icon, const QString &text,
+ const QVariant &userData = QVariant());
+ inline void addItems(const QStringList &texts)
+ { insertItems(count(), texts); }
+
+ inline void insertItem(int index, const QString &text, const QVariant &userData = QVariant());
+ void insertItem(int index, const QIcon &icon, const QString &text,
+ const QVariant &userData = QVariant());
+ void insertItems(int index, const QStringList &texts);
+ void insertSeparator(int index);
+
+ void removeItem(int index);
+
+ void setItemText(int index, const QString &text);
+ void setItemIcon(int index, const QIcon &icon);
+ void setItemData(int index, const QVariant &value, int role = Qt::UserRole);
+
+ QAbstractItemView *view() const;
+ void setView(QAbstractItemView *itemView);
+
+ QSize sizeHint() const;
+ QSize minimumSizeHint() const;
+
+ virtual void showPopup();
+ virtual void hidePopup();
+
+ bool event(QEvent *event);
+
+public Q_SLOTS:
+ void clear();
+ void clearEditText();
+ void setEditText(const QString &text);
+ void setCurrentIndex(int index);
+
+Q_SIGNALS:
+ void editTextChanged(const QString &);
+ void activated(int index);
+ void activated(const QString &);
+ void highlighted(int index);
+ void highlighted(const QString &);
+ void currentIndexChanged(int index);
+ void currentIndexChanged(const QString &);
+
+protected:
+ void focusInEvent(QFocusEvent *e);
+ void focusOutEvent(QFocusEvent *e);
+ void changeEvent(QEvent *e);
+ void resizeEvent(QResizeEvent *e);
+ void paintEvent(QPaintEvent *e);
+ void showEvent(QShowEvent *e);
+ void hideEvent(QHideEvent *e);
+ void mousePressEvent(QMouseEvent *e);
+ void mouseReleaseEvent(QMouseEvent *e);
+ void keyPressEvent(QKeyEvent *e);
+ void keyReleaseEvent(QKeyEvent *e);
+#ifndef QT_NO_WHEELEVENT
+ void wheelEvent(QWheelEvent *e);
+#endif
+ void contextMenuEvent(QContextMenuEvent *e);
+ void inputMethodEvent(QInputMethodEvent *);
+ QVariant inputMethodQuery(Qt::InputMethodQuery) const;
+ void initStyleOption(QStyleOptionComboBox *option) const;
+
+#ifdef QT3_SUPPORT
+public:
+ QT3_SUPPORT_CONSTRUCTOR QComboBox(QWidget *parent, const char *name);
+ QT3_SUPPORT_CONSTRUCTOR QComboBox(bool rw, QWidget *parent, const char *name = 0);
+ inline QT3_SUPPORT int currentItem() const { return currentIndex(); }
+ inline QT3_SUPPORT void setCurrentItem(int index) { setCurrentIndex(index); }
+ inline QT3_SUPPORT InsertPolicy insertionPolicy() const { return insertPolicy(); }
+ inline QT3_SUPPORT void setInsertionPolicy(InsertPolicy policy) { setInsertPolicy(policy); }
+ inline QT3_SUPPORT bool editable() const { return isEditable(); }
+ inline QT3_SUPPORT void popup() { showPopup(); }
+ inline QT3_SUPPORT void setCurrentText(const QString& text) {
+ int i = findText(text);
+ if (i != -1)
+ setCurrentIndex(i);
+ else if (isEditable())
+ setEditText(text);
+ else
+ setItemText(currentIndex(), text);
+ }
+ inline QT3_SUPPORT QString text(int index) const { return itemText(index); }
+
+ inline QT3_SUPPORT QPixmap pixmap(int index) const
+ { return itemIcon(index).pixmap(iconSize(), isEnabled() ? QIcon::Normal : QIcon::Disabled); }
+ inline QT3_SUPPORT void insertStringList(const QStringList &list, int index = -1)
+ { insertItems((index < 0 ? count() : index), list); }
+ inline QT3_SUPPORT void insertItem(const QString &text, int index = -1)
+ { insertItem((index < 0 ? count() : index), text); }
+ inline QT3_SUPPORT void insertItem(const QPixmap &pix, int index = -1)
+ { insertItem((index < 0 ? count() : index), QIcon(pix), QString()); }
+ inline QT3_SUPPORT void insertItem(const QPixmap &pix, const QString &text, int index = -1)
+ { insertItem((index < 0 ? count() : index), QIcon(pix), text); }
+ inline QT3_SUPPORT void changeItem(const QString &text, int index)
+ { setItemText(index, text); }
+ inline QT3_SUPPORT void changeItem(const QPixmap &pix, int index)
+ { setItemIcon(index, QIcon(pix)); }
+ inline QT3_SUPPORT void changeItem(const QPixmap &pix, const QString &text, int index)
+ { setItemIcon(index, QIcon(pix)); setItemText(index, text); }
+ inline QT3_SUPPORT void clearValidator() { setValidator(0); }
+ inline QT3_SUPPORT void clearEdit() { clearEditText(); }
+
+Q_SIGNALS:
+ QT_MOC_COMPAT void textChanged(const QString &);
+#endif
+
+protected:
+ QComboBox(QComboBoxPrivate &, QWidget *);
+
+private:
+ Q_DECLARE_PRIVATE(QComboBox)
+ Q_DISABLE_COPY(QComboBox)
+ Q_PRIVATE_SLOT(d_func(), void _q_itemSelected(const QModelIndex &item))
+ Q_PRIVATE_SLOT(d_func(), void _q_emitHighlighted(const QModelIndex &))
+ Q_PRIVATE_SLOT(d_func(), void _q_emitCurrentIndexChanged(const QModelIndex &index))
+ Q_PRIVATE_SLOT(d_func(), void _q_editingFinished())
+ Q_PRIVATE_SLOT(d_func(), void _q_returnPressed())
+ Q_PRIVATE_SLOT(d_func(), void _q_resetButton())
+ Q_PRIVATE_SLOT(d_func(), void _q_dataChanged(const QModelIndex &, const QModelIndex &))
+ Q_PRIVATE_SLOT(d_func(), void _q_updateIndexBeforeChange())
+ Q_PRIVATE_SLOT(d_func(), void _q_rowsInserted(const QModelIndex & parent, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_rowsRemoved(const QModelIndex & parent, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_modelDestroyed())
+ Q_PRIVATE_SLOT(d_func(), void _q_modelReset())
+#ifdef QT_KEYPAD_NAVIGATION
+ Q_PRIVATE_SLOT(d_func(), void _q_completerActivated())
+#endif
+};
+
+inline void QComboBox::addItem(const QString &atext, const QVariant &auserData)
+{ insertItem(count(), atext, auserData); }
+inline void QComboBox::addItem(const QIcon &aicon, const QString &atext,
+ const QVariant &auserData)
+{ insertItem(count(), aicon, atext, auserData); }
+
+inline void QComboBox::insertItem(int aindex, const QString &atext,
+ const QVariant &auserData)
+{ insertItem(aindex, QIcon(), atext, auserData); }
+
+#endif // QT_NO_COMBOBOX
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QCOMBOBOX_H
diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h
new file mode 100644
index 0000000000..e58c1e5a3d
--- /dev/null
+++ b/src/widgets/widgets/qcombobox_p.h
@@ -0,0 +1,421 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCOMBOBOX_P_H
+#define QCOMBOBOX_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "QtWidgets/qcombobox.h"
+
+#ifndef QT_NO_COMBOBOX
+#include "QtWidgets/qabstractslider.h"
+#include "QtWidgets/qapplication.h"
+#include "QtWidgets/qitemdelegate.h"
+#include "QtWidgets/qstandarditemmodel.h"
+#include "QtWidgets/qlineedit.h"
+#include "QtWidgets/qlistview.h"
+#include "QtGui/qpainter.h"
+#include "QtWidgets/qstyle.h"
+#include "QtWidgets/qstyleoption.h"
+#include "QtCore/qhash.h"
+#include "QtCore/qpair.h"
+#include "QtCore/qtimer.h"
+#include "private/qwidget_p.h"
+#include "QtCore/qpointer.h"
+#include "QtWidgets/qcompleter.h"
+#include "QtGui/qevent.h"
+#include "QtCore/qdebug.h"
+
+#include <limits.h>
+
+QT_BEGIN_NAMESPACE
+
+class QAction;
+
+class QComboBoxListView : public QListView
+{
+ Q_OBJECT
+public:
+ QComboBoxListView(QComboBox *cmb = 0) : combo(cmb) {}
+
+protected:
+ void resizeEvent(QResizeEvent *event)
+ {
+ resizeContents(viewport()->width(), contentsSize().height());
+ QListView::resizeEvent(event);
+ }
+
+ QStyleOptionViewItem viewOptions() const
+ {
+ QStyleOptionViewItem option = QListView::viewOptions();
+ option.showDecorationSelected = true;
+ if (combo)
+ option.font = combo->font();
+ return option;
+ }
+
+ void paintEvent(QPaintEvent *e)
+ {
+ if (combo) {
+ QStyleOptionComboBox opt;
+ opt.initFrom(combo);
+ opt.editable = combo->isEditable();
+ if (combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo)) {
+ //we paint the empty menu area to avoid having blank space that can happen when scrolling
+ QStyleOptionMenuItem menuOpt;
+ menuOpt.initFrom(this);
+ menuOpt.palette = palette();
+ menuOpt.state = QStyle::State_None;
+ menuOpt.checkType = QStyleOptionMenuItem::NotCheckable;
+ menuOpt.menuRect = e->rect();
+ menuOpt.maxIconWidth = 0;
+ menuOpt.tabWidth = 0;
+ QPainter p(viewport());
+ combo->style()->drawControl(QStyle::CE_MenuEmptyArea, &menuOpt, &p, this);
+ }
+ }
+ QListView::paintEvent(e);
+ }
+
+private:
+ QComboBox *combo;
+};
+
+
+class QStandardItemModel;
+
+class Q_AUTOTEST_EXPORT QComboBoxPrivateScroller : public QWidget
+{
+ Q_OBJECT
+
+public:
+ QComboBoxPrivateScroller(QAbstractSlider::SliderAction action, QWidget *parent)
+ : QWidget(parent), sliderAction(action)
+ {
+ setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
+ setAttribute(Qt::WA_NoMousePropagation);
+ }
+ QSize sizeHint() const {
+ return QSize(20, style()->pixelMetric(QStyle::PM_MenuScrollerHeight));
+ }
+
+protected:
+ inline void stopTimer() {
+ timer.stop();
+ }
+
+ inline void startTimer() {
+ timer.start(100, this);
+ fast = false;
+ }
+
+ void enterEvent(QEvent *) {
+ startTimer();
+ }
+
+ void leaveEvent(QEvent *) {
+ stopTimer();
+ }
+ void timerEvent(QTimerEvent *e) {
+ if (e->timerId() == timer.timerId()) {
+ emit doScroll(sliderAction);
+ if (fast) {
+ emit doScroll(sliderAction);
+ emit doScroll(sliderAction);
+ }
+ }
+ }
+ void hideEvent(QHideEvent *) {
+ stopTimer();
+ }
+
+ void mouseMoveEvent(QMouseEvent *e)
+ {
+ // Enable fast scrolling if the cursor is directly above or below the popup.
+ const int mouseX = e->pos().x();
+ const int mouseY = e->pos().y();
+ const bool horizontallyInside = pos().x() < mouseX && mouseX < rect().right() + 1;
+ const bool verticallyOutside = (sliderAction == QAbstractSlider::SliderSingleStepAdd) ?
+ rect().bottom() + 1 < mouseY : mouseY < pos().y();
+
+ fast = horizontallyInside && verticallyOutside;
+ }
+
+ void paintEvent(QPaintEvent *) {
+ QPainter p(this);
+ QStyleOptionMenuItem menuOpt;
+ menuOpt.init(this);
+ menuOpt.checkType = QStyleOptionMenuItem::NotCheckable;
+ menuOpt.menuRect = rect();
+ menuOpt.maxIconWidth = 0;
+ menuOpt.tabWidth = 0;
+ menuOpt.menuItemType = QStyleOptionMenuItem::Scroller;
+ if (sliderAction == QAbstractSlider::SliderSingleStepAdd)
+ menuOpt.state |= QStyle::State_DownArrow;
+#ifndef Q_WS_S60
+ p.eraseRect(rect());
+#endif
+ style()->drawControl(QStyle::CE_MenuScroller, &menuOpt, &p);
+ }
+
+Q_SIGNALS:
+ void doScroll(int action);
+
+private:
+ QAbstractSlider::SliderAction sliderAction;
+ QBasicTimer timer;
+ bool fast;
+};
+
+class Q_AUTOTEST_EXPORT QComboBoxPrivateContainer : public QFrame
+{
+ Q_OBJECT
+
+public:
+ QComboBoxPrivateContainer(QAbstractItemView *itemView, QComboBox *parent);
+ QAbstractItemView *itemView() const;
+ void setItemView(QAbstractItemView *itemView);
+ int spacing() const;
+ void updateTopBottomMargin();
+
+ QTimer blockMouseReleaseTimer;
+ QBasicTimer adjustSizeTimer;
+ QPoint initialClickPosition;
+
+public Q_SLOTS:
+ void scrollItemView(int action);
+ void updateScrollers();
+ void viewDestroyed();
+
+protected:
+ void changeEvent(QEvent *e);
+ bool eventFilter(QObject *o, QEvent *e);
+ void mousePressEvent(QMouseEvent *e);
+ void mouseReleaseEvent(QMouseEvent *e);
+ void showEvent(QShowEvent *e);
+ void hideEvent(QHideEvent *e);
+ void timerEvent(QTimerEvent *timerEvent);
+ void leaveEvent(QEvent *e);
+ void resizeEvent(QResizeEvent *e);
+ QStyleOptionComboBox comboStyleOption() const;
+
+Q_SIGNALS:
+ void itemSelected(const QModelIndex &);
+ void resetButton();
+
+private:
+ QComboBox *combo;
+ QAbstractItemView *view;
+ QComboBoxPrivateScroller *top;
+ QComboBoxPrivateScroller *bottom;
+#ifdef QT_SOFTKEYS_ENABLED
+ QAction *selectAction;
+ QAction *cancelAction;
+#endif
+};
+
+class QComboMenuDelegate : public QAbstractItemDelegate
+{ Q_OBJECT
+public:
+ QComboMenuDelegate(QObject *parent, QComboBox *cmb) : QAbstractItemDelegate(parent), mCombo(cmb) {}
+
+protected:
+ void paint(QPainter *painter,
+ const QStyleOptionViewItem &option,
+ const QModelIndex &index) const {
+ QStyleOptionMenuItem opt = getStyleOption(option, index);
+#ifndef Q_WS_S60
+ painter->fillRect(option.rect, opt.palette.background());
+#endif
+ mCombo->style()->drawControl(QStyle::CE_MenuItem, &opt, painter, mCombo);
+ }
+ QSize sizeHint(const QStyleOptionViewItem &option,
+ const QModelIndex &index) const {
+ QStyleOptionMenuItem opt = getStyleOption(option, index);
+ return mCombo->style()->sizeFromContents(
+ QStyle::CT_MenuItem, &opt, option.rect.size(), mCombo);
+ }
+
+private:
+ QStyleOptionMenuItem getStyleOption(const QStyleOptionViewItem &option,
+ const QModelIndex &index) const;
+ QComboBox *mCombo;
+};
+
+// Note that this class is intentionally not using QStyledItemDelegate
+// Vista does not use the new theme for combo boxes and there might
+// be other side effects from using the new class
+class QComboBoxDelegate : public QItemDelegate
+{ Q_OBJECT
+public:
+ QComboBoxDelegate(QObject *parent, QComboBox *cmb) : QItemDelegate(parent), mCombo(cmb) {}
+
+ static bool isSeparator(const QModelIndex &index) {
+ return index.data(Qt::AccessibleDescriptionRole).toString() == QLatin1String("separator");
+ }
+ static void setSeparator(QAbstractItemModel *model, const QModelIndex &index) {
+ model->setData(index, QString::fromLatin1("separator"), Qt::AccessibleDescriptionRole);
+ if (QStandardItemModel *m = qobject_cast<QStandardItemModel*>(model))
+ if (QStandardItem *item = m->itemFromIndex(index))
+ item->setFlags(item->flags() & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled));
+ }
+
+protected:
+ void paint(QPainter *painter,
+ const QStyleOptionViewItem &option,
+ const QModelIndex &index) const {
+ if (isSeparator(index)) {
+ QRect rect = option.rect;
+ if (const QStyleOptionViewItemV3 *v3 = qstyleoption_cast<const QStyleOptionViewItemV3*>(&option))
+ if (const QAbstractItemView *view = qobject_cast<const QAbstractItemView*>(v3->widget))
+ rect.setWidth(view->viewport()->width());
+ QStyleOption opt;
+ opt.rect = rect;
+ mCombo->style()->drawPrimitive(QStyle::PE_IndicatorToolBarSeparator, &opt, painter, mCombo);
+ } else {
+ QItemDelegate::paint(painter, option, index);
+ }
+ }
+
+ QSize sizeHint(const QStyleOptionViewItem &option,
+ const QModelIndex &index) const {
+ if (isSeparator(index)) {
+ int pm = mCombo->style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, mCombo);
+ return QSize(pm, pm);
+ }
+ return QItemDelegate::sizeHint(option, index);
+ }
+private:
+ QComboBox *mCombo;
+};
+
+class Q_AUTOTEST_EXPORT QComboBoxPrivate : public QWidgetPrivate
+{
+ Q_DECLARE_PUBLIC(QComboBox)
+public:
+ QComboBoxPrivate();
+ ~QComboBoxPrivate() {}
+ void init();
+ QComboBoxPrivateContainer* viewContainer();
+ void updateLineEditGeometry();
+ Qt::MatchFlags matchFlags() const;
+ void _q_editingFinished();
+ void _q_returnPressed();
+ void _q_complete();
+ void _q_itemSelected(const QModelIndex &item);
+ bool contains(const QString &text, int role);
+ void emitActivated(const QModelIndex&);
+ void _q_emitHighlighted(const QModelIndex&);
+ void _q_emitCurrentIndexChanged(const QModelIndex &index);
+ void _q_modelDestroyed();
+ void _q_modelReset();
+#ifdef QT_KEYPAD_NAVIGATION
+ void _q_completerActivated();
+#endif
+ void _q_resetButton();
+ void _q_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+ void _q_updateIndexBeforeChange();
+ void _q_rowsInserted(const QModelIndex & parent, int start, int end);
+ void _q_rowsRemoved(const QModelIndex & parent, int start, int end);
+ void updateArrow(QStyle::StateFlag state);
+ bool updateHoverControl(const QPoint &pos);
+ QRect popupGeometry(int screen = -1) const;
+ QStyle::SubControl newHoverControl(const QPoint &pos);
+ int computeWidthHint() const;
+ QSize recomputeSizeHint(QSize &sh) const;
+ void adjustComboBoxSize();
+ QString itemText(const QModelIndex &index) const;
+ QIcon itemIcon(const QModelIndex &index) const;
+ int itemRole() const;
+ void updateLayoutDirection();
+ void setCurrentIndex(const QModelIndex &index);
+ void updateDelegate(bool force = false);
+ void keyboardSearchString(const QString &text);
+ void modelChanged();
+ void updateViewContainerPaletteAndOpacity();
+
+ QAbstractItemModel *model;
+ QLineEdit *lineEdit;
+ QComboBoxPrivateContainer *container;
+ QComboBox::InsertPolicy insertPolicy;
+ QComboBox::SizeAdjustPolicy sizeAdjustPolicy;
+ int minimumContentsLength;
+ QSize iconSize;
+ uint shownOnce : 1;
+ uint autoCompletion : 1;
+ uint duplicatesEnabled : 1;
+ uint frame : 1;
+ uint padding : 26;
+ int maxVisibleItems;
+ int maxCount;
+ int modelColumn;
+ bool inserting;
+ mutable QSize minimumSizeHint;
+ mutable QSize sizeHint;
+ QStyle::StateFlag arrowState;
+ QStyle::SubControl hoverControl;
+ QRect hoverRect;
+ QPersistentModelIndex currentIndex;
+ QPersistentModelIndex root;
+ Qt::CaseSensitivity autoCompletionCaseSensitivity;
+ int indexBeforeChange;
+#ifndef QT_NO_COMPLETER
+ QPointer<QCompleter> completer;
+#endif
+ static QPalette viewContainerPalette(QComboBox *cmb)
+ { return cmb->d_func()->viewContainer()->palette(); }
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_COMBOBOX
+
+#endif // QCOMBOBOX_P_H
diff --git a/src/gui/widgets/qcommandlinkbutton.cpp b/src/widgets/widgets/qcommandlinkbutton.cpp
index f1734a009e..f1734a009e 100644
--- a/src/gui/widgets/qcommandlinkbutton.cpp
+++ b/src/widgets/widgets/qcommandlinkbutton.cpp
diff --git a/src/widgets/widgets/qcommandlinkbutton.h b/src/widgets/widgets/qcommandlinkbutton.h
new file mode 100644
index 0000000000..326697fc86
--- /dev/null
+++ b/src/widgets/widgets/qcommandlinkbutton.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCOMMANDLINKBUTTON_H
+#define QCOMMANDLINKBUTTON_H
+
+#include <QtWidgets/qpushbutton.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QCommandLinkButtonPrivate;
+
+class Q_GUI_EXPORT QCommandLinkButton: public QPushButton
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString description READ description WRITE setDescription)
+ Q_PROPERTY(bool flat READ isFlat WRITE setFlat DESIGNABLE false)
+
+public:
+ explicit QCommandLinkButton(QWidget *parent=0);
+ explicit QCommandLinkButton(const QString &text, QWidget *parent=0);
+ QCommandLinkButton(const QString &text, const QString &description, QWidget *parent=0);
+ QString description() const;
+ void setDescription(const QString &description);
+
+protected:
+ QSize sizeHint() const;
+ int heightForWidth(int) const;
+ QSize minimumSizeHint() const;
+ bool event(QEvent *e);
+ void paintEvent(QPaintEvent *);
+
+private:
+ Q_DISABLE_COPY(QCommandLinkButton)
+ Q_DECLARE_PRIVATE(QCommandLinkButton)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QCOMMANDLINKBUTTON
diff --git a/src/gui/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp
index a4739a7f69..a4739a7f69 100644
--- a/src/gui/widgets/qdatetimeedit.cpp
+++ b/src/widgets/widgets/qdatetimeedit.cpp
diff --git a/src/widgets/widgets/qdatetimeedit.h b/src/widgets/widgets/qdatetimeedit.h
new file mode 100644
index 0000000000..429fa0c590
--- /dev/null
+++ b/src/widgets/widgets/qdatetimeedit.h
@@ -0,0 +1,230 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDATETIMEEDIT_H
+#define QDATETIMEEDIT_H
+
+#include <QtCore/qdatetime.h>
+#include <QtCore/qvariant.h>
+#include <QtWidgets/qabstractspinbox.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_DATETIMEEDIT
+
+class QDateTimeEditPrivate;
+class QStyleOptionSpinBox;
+class QCalendarWidget;
+
+class Q_GUI_EXPORT QDateTimeEdit : public QAbstractSpinBox
+{
+ Q_OBJECT
+
+ Q_ENUMS(Section)
+ Q_FLAGS(Sections)
+ Q_PROPERTY(QDateTime dateTime READ dateTime WRITE setDateTime NOTIFY dateTimeChanged USER true)
+ Q_PROPERTY(QDate date READ date WRITE setDate NOTIFY dateChanged)
+ Q_PROPERTY(QTime time READ time WRITE setTime NOTIFY timeChanged)
+ Q_PROPERTY(QDateTime maximumDateTime READ maximumDateTime WRITE setMaximumDateTime RESET clearMaximumDateTime)
+ Q_PROPERTY(QDateTime minimumDateTime READ minimumDateTime WRITE setMinimumDateTime RESET clearMinimumDateTime)
+ Q_PROPERTY(QDate maximumDate READ maximumDate WRITE setMaximumDate RESET clearMaximumDate)
+ Q_PROPERTY(QDate minimumDate READ minimumDate WRITE setMinimumDate RESET clearMinimumDate)
+ Q_PROPERTY(QTime maximumTime READ maximumTime WRITE setMaximumTime RESET clearMaximumTime)
+ Q_PROPERTY(QTime minimumTime READ minimumTime WRITE setMinimumTime RESET clearMinimumTime)
+ Q_PROPERTY(Section currentSection READ currentSection WRITE setCurrentSection)
+ Q_PROPERTY(Sections displayedSections READ displayedSections)
+ Q_PROPERTY(QString displayFormat READ displayFormat WRITE setDisplayFormat)
+ Q_PROPERTY(bool calendarPopup READ calendarPopup WRITE setCalendarPopup)
+ Q_PROPERTY(int currentSectionIndex READ currentSectionIndex WRITE setCurrentSectionIndex)
+ Q_PROPERTY(int sectionCount READ sectionCount)
+ Q_PROPERTY(Qt::TimeSpec timeSpec READ timeSpec WRITE setTimeSpec)
+public:
+ enum Section {
+ NoSection = 0x0000,
+ AmPmSection = 0x0001,
+ MSecSection = 0x0002,
+ SecondSection = 0x0004,
+ MinuteSection = 0x0008,
+ HourSection = 0x0010,
+ DaySection = 0x0100,
+ MonthSection = 0x0200,
+ YearSection = 0x0400,
+ TimeSections_Mask = AmPmSection|MSecSection|SecondSection|MinuteSection|HourSection,
+ DateSections_Mask = DaySection|MonthSection|YearSection
+ };
+
+ Q_DECLARE_FLAGS(Sections, Section)
+
+ explicit QDateTimeEdit(QWidget *parent = 0);
+ explicit QDateTimeEdit(const QDateTime &dt, QWidget *parent = 0);
+ explicit QDateTimeEdit(const QDate &d, QWidget *parent = 0);
+ explicit QDateTimeEdit(const QTime &t, QWidget *parent = 0);
+
+ QDateTime dateTime() const;
+ QDate date() const;
+ QTime time() const;
+
+ QDateTime minimumDateTime() const;
+ void clearMinimumDateTime();
+ void setMinimumDateTime(const QDateTime &dt);
+
+ QDateTime maximumDateTime() const;
+ void clearMaximumDateTime();
+ void setMaximumDateTime(const QDateTime &dt);
+
+ void setDateTimeRange(const QDateTime &min, const QDateTime &max);
+
+ QDate minimumDate() const;
+ void setMinimumDate(const QDate &min);
+ void clearMinimumDate();
+
+ QDate maximumDate() const;
+ void setMaximumDate(const QDate &max);
+ void clearMaximumDate();
+
+ void setDateRange(const QDate &min, const QDate &max);
+
+ QTime minimumTime() const;
+ void setMinimumTime(const QTime &min);
+ void clearMinimumTime();
+
+ QTime maximumTime() const;
+ void setMaximumTime(const QTime &max);
+ void clearMaximumTime();
+
+ void setTimeRange(const QTime &min, const QTime &max);
+
+ Sections displayedSections() const;
+ Section currentSection() const;
+ Section sectionAt(int index) const;
+ void setCurrentSection(Section section);
+
+ int currentSectionIndex() const;
+ void setCurrentSectionIndex(int index);
+
+ QCalendarWidget *calendarWidget() const;
+ void setCalendarWidget(QCalendarWidget *calendarWidget);
+
+ int sectionCount() const;
+
+ void setSelectedSection(Section section);
+
+ QString sectionText(Section section) const;
+
+ QString displayFormat() const;
+ void setDisplayFormat(const QString &format);
+
+ bool calendarPopup() const;
+ void setCalendarPopup(bool enable);
+
+ Qt::TimeSpec timeSpec() const;
+ void setTimeSpec(Qt::TimeSpec spec);
+
+ QSize sizeHint() const;
+
+ virtual void clear();
+ virtual void stepBy(int steps);
+
+ bool event(QEvent *event);
+Q_SIGNALS:
+ void dateTimeChanged(const QDateTime &date);
+ void timeChanged(const QTime &date);
+ void dateChanged(const QDate &date);
+
+public Q_SLOTS:
+ void setDateTime(const QDateTime &dateTime);
+ void setDate(const QDate &date);
+ void setTime(const QTime &time);
+
+protected:
+ virtual void keyPressEvent(QKeyEvent *event);
+#ifndef QT_NO_WHEELEVENT
+ virtual void wheelEvent(QWheelEvent *event);
+#endif
+ virtual void focusInEvent(QFocusEvent *event);
+ virtual bool focusNextPrevChild(bool next);
+ virtual QValidator::State validate(QString &input, int &pos) const;
+ virtual void fixup(QString &input) const;
+
+ virtual QDateTime dateTimeFromText(const QString &text) const;
+ virtual QString textFromDateTime(const QDateTime &dt) const;
+ virtual StepEnabled stepEnabled() const;
+ virtual void mousePressEvent(QMouseEvent *event);
+ virtual void paintEvent(QPaintEvent *event);
+ void initStyleOption(QStyleOptionSpinBox *option) const;
+
+ QDateTimeEdit(const QVariant &val, QVariant::Type parserType, QWidget *parent = 0);
+private:
+ Q_DECLARE_PRIVATE(QDateTimeEdit)
+ Q_DISABLE_COPY(QDateTimeEdit)
+
+ Q_PRIVATE_SLOT(d_func(), void _q_resetButton())
+};
+
+class Q_GUI_EXPORT QTimeEdit : public QDateTimeEdit
+{
+ Q_OBJECT
+public:
+ QTimeEdit(QWidget *parent = 0);
+ QTimeEdit(const QTime &time, QWidget *parent = 0);
+};
+
+class Q_GUI_EXPORT QDateEdit : public QDateTimeEdit
+{
+ Q_OBJECT
+public:
+ QDateEdit(QWidget *parent = 0);
+ QDateEdit(const QDate &date, QWidget *parent = 0);
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QDateTimeEdit::Sections)
+
+#endif // QT_NO_DATETIMEEDIT
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDATETIMEEDIT_H
diff --git a/src/widgets/widgets/qdatetimeedit_p.h b/src/widgets/widgets/qdatetimeedit_p.h
new file mode 100644
index 0000000000..d6ff94c055
--- /dev/null
+++ b/src/widgets/widgets/qdatetimeedit_p.h
@@ -0,0 +1,185 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDATETIMEEDIT_P_H
+#define QDATETIMEEDIT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "QtWidgets/qcombobox.h"
+#include "QtWidgets/qcalendarwidget.h"
+#include "QtWidgets/qspinbox.h"
+#include "QtWidgets/qtoolbutton.h"
+#include "QtWidgets/qmenu.h"
+#include "QtWidgets/qlabel.h"
+#include "QtWidgets/qdatetimeedit.h"
+#include "private/qabstractspinbox_p.h"
+#include "private/qdatetime_p.h"
+
+#include "qdebug.h"
+
+#ifndef QT_NO_DATETIMEEDIT
+
+QT_BEGIN_NAMESPACE
+
+class QCalendarPopup;
+class QDateTimeEditPrivate : public QAbstractSpinBoxPrivate, public QDateTimeParser
+{
+ Q_DECLARE_PUBLIC(QDateTimeEdit)
+public:
+ QDateTimeEditPrivate();
+
+ void init(const QVariant &var);
+ void readLocaleSettings();
+
+ void emitSignals(EmitPolicy ep, const QVariant &old);
+ QString textFromValue(const QVariant &f) const;
+ QVariant valueFromText(const QString &f) const;
+ virtual void _q_editorCursorPositionChanged(int oldpos, int newpos);
+ virtual void interpret(EmitPolicy ep);
+ virtual void clearCache() const;
+
+ QDateTime validateAndInterpret(QString &input, int &, QValidator::State &state,
+ bool fixup = false) const;
+ void clearSection(int index);
+ virtual QString displayText() const { return edit->text(); } // this is from QDateTimeParser
+
+ int absoluteIndex(QDateTimeEdit::Section s, int index) const;
+ int absoluteIndex(const SectionNode &s) const;
+ void updateEdit();
+ QDateTime stepBy(int index, int steps, bool test = false) const;
+ int sectionAt(int pos) const;
+ int closestSection(int index, bool forward) const;
+ int nextPrevSection(int index, bool forward) const;
+ void setSelected(int index, bool forward = false);
+
+ void updateCache(const QVariant &val, const QString &str) const;
+
+ void updateTimeSpec();
+ virtual QDateTime getMinimum() const { return minimum.toDateTime(); }
+ virtual QDateTime getMaximum() const { return maximum.toDateTime(); }
+ virtual QLocale locale() const { return q_func()->locale(); }
+ QString valueToText(const QVariant &var) const { return textFromValue(var); }
+ QString getAmPmText(AmPm ap, Case cs) const;
+ int cursorPosition() const { return edit ? edit->cursorPosition() : -1; }
+
+ virtual QStyle::SubControl newHoverControl(const QPoint &pos);
+ virtual void updateEditFieldGeometry();
+ virtual QVariant getZeroVariant() const;
+ virtual void setRange(const QVariant &min, const QVariant &max);
+
+ void _q_resetButton();
+ void updateArrow(QStyle::StateFlag state);
+ bool calendarPopupEnabled() const;
+ void syncCalendarWidget();
+
+ bool isSeparatorKey(const QKeyEvent *k) const;
+
+ static QDateTimeEdit::Sections convertSections(QDateTimeParser::Sections s);
+ static QDateTimeEdit::Section convertToPublic(QDateTimeParser::Section s);
+
+ void initCalendarPopup(QCalendarWidget *cw = 0);
+ void positionCalendarPopup();
+
+ QDateTimeEdit::Sections sections;
+ mutable bool cacheGuard;
+
+ QString defaultDateFormat, defaultTimeFormat, defaultDateTimeFormat, unreversedFormat;
+ mutable QVariant conflictGuard;
+ bool hasHadFocus, formatExplicitlySet, calendarPopup;
+ QStyle::StateFlag arrowState;
+ QCalendarPopup *monthCalendar;
+
+#ifdef QT_KEYPAD_NAVIGATION
+ bool focusOnButton;
+#endif
+};
+
+
+class QCalendarPopup : public QWidget
+{
+ Q_OBJECT
+public:
+ QCalendarPopup(QWidget *parent = 0, QCalendarWidget *cw = 0);
+ QDate selectedDate() { return verifyCalendarInstance()->selectedDate(); }
+ void setDate(const QDate &date);
+ void setDateRange(const QDate &min, const QDate &max);
+ void setFirstDayOfWeek(Qt::DayOfWeek dow) { verifyCalendarInstance()->setFirstDayOfWeek(dow); }
+ QCalendarWidget *calendarWidget() const { return const_cast<QCalendarPopup*>(this)->verifyCalendarInstance(); }
+ void setCalendarWidget(QCalendarWidget *cw);
+Q_SIGNALS:
+ void activated(const QDate &date);
+ void newDateSelected(const QDate &newDate);
+ void hidingCalendar(const QDate &oldDate);
+ void resetButton();
+
+private Q_SLOTS:
+ void dateSelected(const QDate &date);
+ void dateSelectionChanged();
+
+protected:
+ void hideEvent(QHideEvent *);
+ void mousePressEvent(QMouseEvent *e);
+ void mouseReleaseEvent(QMouseEvent *);
+ bool event(QEvent *e);
+
+private:
+ QCalendarWidget *verifyCalendarInstance();
+
+ QWeakPointer<QCalendarWidget> calendar;
+ QDate oldDate;
+ bool dateChanged;
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_DATETIMEEDIT
+
+#endif // QDATETIMEEDIT_P_H
diff --git a/src/gui/widgets/qdial.cpp b/src/widgets/widgets/qdial.cpp
index 19e8d231ca..19e8d231ca 100644
--- a/src/gui/widgets/qdial.cpp
+++ b/src/widgets/widgets/qdial.cpp
diff --git a/src/widgets/widgets/qdial.h b/src/widgets/widgets/qdial.h
new file mode 100644
index 0000000000..ee3930c23d
--- /dev/null
+++ b/src/widgets/widgets/qdial.h
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef QDIAL_H
+#define QDIAL_H
+
+#include <QtWidgets/qabstractslider.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_DIAL
+
+class QDialPrivate;
+class QStyleOptionSlider;
+
+class Q_GUI_EXPORT QDial: public QAbstractSlider
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool wrapping READ wrapping WRITE setWrapping)
+ Q_PROPERTY(int notchSize READ notchSize)
+ Q_PROPERTY(qreal notchTarget READ notchTarget WRITE setNotchTarget)
+ Q_PROPERTY(bool notchesVisible READ notchesVisible WRITE setNotchesVisible)
+public:
+ explicit QDial(QWidget *parent = 0);
+
+ ~QDial();
+
+ bool wrapping() const;
+
+ int notchSize() const;
+
+ void setNotchTarget(double target);
+ qreal notchTarget() const;
+ bool notchesVisible() const;
+
+ QSize sizeHint() const;
+ QSize minimumSizeHint() const;
+
+public Q_SLOTS:
+ void setNotchesVisible(bool visible);
+ void setWrapping(bool on);
+
+protected:
+ bool event(QEvent *e);
+ void resizeEvent(QResizeEvent *re);
+ void paintEvent(QPaintEvent *pe);
+
+ void mousePressEvent(QMouseEvent *me);
+ void mouseReleaseEvent(QMouseEvent *me);
+ void mouseMoveEvent(QMouseEvent *me);
+
+ void sliderChange(SliderChange change);
+ void initStyleOption(QStyleOptionSlider *option) const;
+
+#ifdef QT3_SUPPORT
+public:
+ QT3_SUPPORT_CONSTRUCTOR QDial(int minValue, int maxValue, int pageStep, int value,
+ QWidget* parent = 0, const char* name = 0);
+ QT3_SUPPORT_CONSTRUCTOR QDial(QWidget *parent, const char *name);
+
+Q_SIGNALS:
+ QT_MOC_COMPAT void dialPressed();
+ QT_MOC_COMPAT void dialMoved(int value);
+ QT_MOC_COMPAT void dialReleased();
+#endif
+
+private:
+ Q_DECLARE_PRIVATE(QDial)
+ Q_DISABLE_COPY(QDial)
+};
+
+#endif // QT_NO_DIAL
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDIAL_H
diff --git a/src/widgets/widgets/qdialogbuttonbox.cpp b/src/widgets/widgets/qdialogbuttonbox.cpp
new file mode 100644
index 0000000000..5147cb12a7
--- /dev/null
+++ b/src/widgets/widgets/qdialogbuttonbox.cpp
@@ -0,0 +1,1285 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/qhash.h>
+#include <QtWidgets/qpushbutton.h>
+#include <QtWidgets/qstyle.h>
+#include <QtWidgets/qlayout.h>
+#include <QtWidgets/qdialog.h>
+#include <QtWidgets/qapplication.h>
+#include <private/qwidget_p.h>
+#include <QtWidgets/qaction.h>
+
+#include "qdialogbuttonbox.h"
+
+#ifdef QT_SOFTKEYS_ENABLED
+#include <QtWidgets/qaction.h>
+#endif
+
+
+QT_BEGIN_NAMESPACE
+
+/*!
+ \class QDialogButtonBox
+ \since 4.2
+ \brief The QDialogButtonBox class is a widget that presents buttons in a
+ layout that is appropriate to the current widget style.
+
+ \ingroup dialog-classes
+
+
+ Dialogs and message boxes typically present buttons in a layout that
+ conforms to the interface guidelines for that platform. Invariably,
+ different platforms have different layouts for their dialogs.
+ QDialogButtonBox allows a developer to add buttons to it and will
+ automatically use the appropriate layout for the user's desktop
+ environment.
+
+ Most buttons for a dialog follow certain roles. Such roles include:
+
+ \list
+ \o Accepting or rejecting the dialog.
+ \o Asking for help.
+ \o Performing actions on the dialog itself (such as resetting fields or
+ applying changes).
+ \endlist
+
+ There can also be alternate ways of dismissing the dialog which may cause
+ destructive results.
+
+ Most dialogs have buttons that can almost be considered standard (e.g.
+ \gui OK and \gui Cancel buttons). It is sometimes convenient to create these
+ buttons in a standard way.
+
+ There are a couple ways of using QDialogButtonBox. One ways is to create
+ the buttons (or button texts) yourself and add them to the button box,
+ specifying their role.
+
+ \snippet examples/dialogs/extension/finddialog.cpp 1
+
+ Alternatively, QDialogButtonBox provides several standard buttons (e.g. OK, Cancel, Save)
+ that you can use. They exist as flags so you can OR them together in the constructor.
+
+ \snippet examples/dialogs/tabdialog/tabdialog.cpp 2
+
+ You can mix and match normal buttons and standard buttons.
+
+ Currently the buttons are laid out in the following way if the button box is horizontal:
+ \table
+ \row \o \inlineimage buttonbox-gnomelayout-horizontal.png GnomeLayout Horizontal
+ \o Button box laid out in horizontal GnomeLayout
+ \row \o \inlineimage buttonbox-kdelayout-horizontal.png KdeLayout Horizontal
+ \o Button box laid out in horizontal KdeLayout
+ \row \o \inlineimage buttonbox-maclayout-horizontal.png MacLayout Horizontal
+ \o Button box laid out in horizontal MacLayout
+ \row \o \inlineimage buttonbox-winlayout-horizontal.png WinLayout Horizontal
+ \o Button box laid out in horizontal WinLayout
+ \endtable
+
+ The buttons are laid out the following way if the button box is vertical:
+
+ \table
+ \row \o GnomeLayout
+ \o KdeLayout
+ \o MacLayout
+ \o WinLayout
+ \row \o \inlineimage buttonbox-gnomelayout-vertical.png GnomeLayout Vertical
+ \o \inlineimage buttonbox-kdelayout-vertical.png KdeLayout Vertical
+ \o \inlineimage buttonbox-maclayout-vertical.png MacLayout Vertical
+ \o \inlineimage buttonbox-winlayout-vertical.png WinLayout Vertical
+ \endtable
+
+ Additionally, button boxes that contain only buttons with ActionRole or
+ HelpRole can be considered modeless and have an alternate look on Mac OS X:
+
+ \table
+ \row \o modeless horizontal MacLayout
+ \o \inlineimage buttonbox-mac-modeless-horizontal.png Screenshot of modeless horizontal MacLayout
+ \endtable
+
+ When a button is clicked in the button box, the clicked() signal is emitted
+ for the actual button is that is pressed. For convenience, if the button
+ has an AcceptRole, RejectRole, or HelpRole, the accepted(), rejected(), or
+ helpRequested() signals are emitted respectively.
+
+ If you want a specific button to be default you need to call
+ QPushButton::setDefault() on it yourself. However, if there is no default
+ button set and to preserve which button is the default button across
+ platforms when using the QPushButton::autoDefault property, the first push
+ button with the accept role is made the default button when the
+ QDialogButtonBox is shown,
+
+ \sa QMessageBox, QPushButton, QDialog
+*/
+
+enum {
+ AcceptRole = QDialogButtonBox::AcceptRole,
+ RejectRole = QDialogButtonBox::RejectRole,
+ DestructiveRole = QDialogButtonBox::DestructiveRole,
+ ActionRole = QDialogButtonBox::ActionRole,
+ HelpRole = QDialogButtonBox::HelpRole,
+ YesRole = QDialogButtonBox::YesRole,
+ NoRole = QDialogButtonBox::NoRole,
+ ApplyRole = QDialogButtonBox::ApplyRole,
+ ResetRole = QDialogButtonBox::ResetRole,
+
+ AlternateRole = 0x10000000,
+ Stretch = 0x20000000,
+ EOL = 0x40000000,
+ Reverse = 0x80000000
+};
+
+static QDialogButtonBox::ButtonRole roleFor(QDialogButtonBox::StandardButton button)
+{
+ switch (button) {
+ case QDialogButtonBox::Ok:
+ case QDialogButtonBox::Save:
+ case QDialogButtonBox::Open:
+ case QDialogButtonBox::SaveAll:
+ case QDialogButtonBox::Retry:
+ case QDialogButtonBox::Ignore:
+ return QDialogButtonBox::AcceptRole;
+
+ case QDialogButtonBox::Cancel:
+ case QDialogButtonBox::Close:
+ case QDialogButtonBox::Abort:
+ return QDialogButtonBox::RejectRole;
+
+ case QDialogButtonBox::Discard:
+ return QDialogButtonBox::DestructiveRole;
+
+ case QDialogButtonBox::Help:
+ return QDialogButtonBox::HelpRole;
+
+ case QDialogButtonBox::Apply:
+ return QDialogButtonBox::ApplyRole;
+
+ case QDialogButtonBox::Yes:
+ case QDialogButtonBox::YesToAll:
+ return QDialogButtonBox::YesRole;
+
+ case QDialogButtonBox::No:
+ case QDialogButtonBox::NoToAll:
+ return QDialogButtonBox::NoRole;
+
+ case QDialogButtonBox::RestoreDefaults:
+ case QDialogButtonBox::Reset:
+ return QDialogButtonBox::ResetRole;
+
+ case QDialogButtonBox::NoButton: // NoButton means zero buttons, not "No" button
+ ;
+ }
+
+ return QDialogButtonBox::InvalidRole;
+}
+
+static const int layouts[2][5][14] =
+{
+ // Qt::Horizontal
+ {
+ // WinLayout
+ { ResetRole, Stretch, YesRole, AcceptRole, AlternateRole, DestructiveRole, NoRole, ActionRole, RejectRole, ApplyRole,
+ HelpRole, EOL, EOL, EOL },
+
+ // MacLayout
+ { HelpRole, ResetRole, ApplyRole, ActionRole, Stretch, DestructiveRole | Reverse,
+ AlternateRole | Reverse, RejectRole | Reverse, AcceptRole | Reverse, NoRole | Reverse, YesRole | Reverse, EOL, EOL },
+
+ // KdeLayout
+ { HelpRole, ResetRole, Stretch, YesRole, NoRole, ActionRole, AcceptRole, AlternateRole,
+ ApplyRole, DestructiveRole, RejectRole, EOL },
+
+ // GnomeLayout
+ { HelpRole, ResetRole, Stretch, ActionRole, ApplyRole | Reverse, DestructiveRole | Reverse,
+ AlternateRole | Reverse, RejectRole | Reverse, AcceptRole | Reverse, NoRole | Reverse, YesRole | Reverse, EOL },
+
+ // Mac modeless
+ { ResetRole, ApplyRole, ActionRole, Stretch, HelpRole, EOL, EOL, EOL, EOL, EOL, EOL, EOL, EOL, EOL }
+ },
+
+ // Qt::Vertical
+ {
+ // WinLayout
+ { ActionRole, YesRole, AcceptRole, AlternateRole, DestructiveRole, NoRole, RejectRole, ApplyRole, ResetRole,
+ HelpRole, Stretch, EOL, EOL, EOL },
+
+ // MacLayout
+ { YesRole, NoRole, AcceptRole, RejectRole, AlternateRole, DestructiveRole, Stretch, ActionRole, ApplyRole,
+ ResetRole, HelpRole, EOL, EOL },
+
+ // KdeLayout
+ { AcceptRole, AlternateRole, ApplyRole, ActionRole, YesRole, NoRole, Stretch, ResetRole,
+ DestructiveRole, RejectRole, HelpRole, EOL },
+
+ // GnomeLayout
+ { YesRole, NoRole, AcceptRole, RejectRole, AlternateRole, DestructiveRole, ApplyRole, ActionRole, Stretch,
+ ResetRole, HelpRole, EOL, EOL, EOL },
+
+ // Mac modeless
+ { ActionRole, ApplyRole, ResetRole, Stretch, HelpRole, EOL, EOL, EOL, EOL, EOL, EOL, EOL, EOL, EOL }
+ }
+};
+
+#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION)
+class QDialogButtonEnabledProxy : public QObject
+{
+public:
+ QDialogButtonEnabledProxy(QObject *parent, QWidget *src, QAction *trg) : QObject(parent), source(src), target(trg)
+ {
+ source->installEventFilter(this);
+ target->setEnabled(source->isEnabled());
+ }
+ ~QDialogButtonEnabledProxy()
+ {
+ source->removeEventFilter(this);
+ }
+ bool eventFilter(QObject *object, QEvent *event)
+ {
+ if (object == source && event->type() == QEvent::EnabledChange) {
+ target->setEnabled(source->isEnabled());
+ }
+ return false;
+ };
+private:
+ QWidget *source;
+ QAction *target;
+};
+#endif
+
+class QDialogButtonBoxPrivate : public QWidgetPrivate
+{
+ Q_DECLARE_PUBLIC(QDialogButtonBox)
+
+public:
+ QDialogButtonBoxPrivate(Qt::Orientation orient);
+
+ QList<QAbstractButton *> buttonLists[QDialogButtonBox::NRoles];
+ QHash<QPushButton *, QDialogButtonBox::StandardButton> standardButtonHash;
+#ifdef QT_SOFTKEYS_ENABLED
+ QHash<QAbstractButton *, QAction *> softKeyActions;
+#endif
+
+ Qt::Orientation orientation;
+ QDialogButtonBox::ButtonLayout layoutPolicy;
+ QBoxLayout *buttonLayout;
+ bool internalRemove;
+ bool center;
+
+ void createStandardButtons(QDialogButtonBox::StandardButtons buttons);
+
+ void layoutButtons();
+ void initLayout();
+ void resetLayout();
+ QPushButton *createButton(QDialogButtonBox::StandardButton button, bool doLayout = true);
+ void addButton(QAbstractButton *button, QDialogButtonBox::ButtonRole role, bool doLayout = true);
+ void _q_handleButtonDestroyed();
+ void _q_handleButtonClicked();
+ void addButtonsToLayout(const QList<QAbstractButton *> &buttonList, bool reverse);
+ void retranslateStrings();
+ const char *standardButtonText(QDialogButtonBox::StandardButton sbutton) const;
+#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION)
+ QAction *createSoftKey(QAbstractButton *button, QDialogButtonBox::ButtonRole role);
+#endif
+};
+
+QDialogButtonBoxPrivate::QDialogButtonBoxPrivate(Qt::Orientation orient)
+ : orientation(orient), buttonLayout(0), internalRemove(false), center(false)
+{
+}
+
+void QDialogButtonBoxPrivate::initLayout()
+{
+ Q_Q(QDialogButtonBox);
+ layoutPolicy = QDialogButtonBox::ButtonLayout(q->style()->styleHint(QStyle::SH_DialogButtonLayout, 0, q));
+ bool createNewLayout = buttonLayout == 0
+ || (orientation == Qt::Horizontal && qobject_cast<QVBoxLayout *>(buttonLayout) != 0)
+ || (orientation == Qt::Vertical && qobject_cast<QHBoxLayout *>(buttonLayout) != 0);
+ if (createNewLayout) {
+ delete buttonLayout;
+ if (orientation == Qt::Horizontal)
+ buttonLayout = new QHBoxLayout(q);
+ else
+ buttonLayout = new QVBoxLayout(q);
+ }
+
+ int left, top, right, bottom;
+ setLayoutItemMargins(QStyle::SE_PushButtonLayoutItem);
+ getLayoutItemMargins(&left, &top, &right, &bottom);
+ buttonLayout->setContentsMargins(-left, -top, -right, -bottom);
+
+ if (!q->testAttribute(Qt::WA_WState_OwnSizePolicy)) {
+ QSizePolicy sp(QSizePolicy::Expanding, QSizePolicy::Fixed, QSizePolicy::ButtonBox);
+ if (orientation == Qt::Vertical)
+ sp.transpose();
+ q->setSizePolicy(sp);
+ q->setAttribute(Qt::WA_WState_OwnSizePolicy, false);
+ }
+
+ // ### move to a real init() function
+ q->setFocusPolicy(Qt::TabFocus);
+}
+
+void QDialogButtonBoxPrivate::resetLayout()
+{
+ //delete buttonLayout;
+ initLayout();
+ layoutButtons();
+}
+
+void QDialogButtonBoxPrivate::addButtonsToLayout(const QList<QAbstractButton *> &buttonList,
+ bool reverse)
+{
+ int start = reverse ? buttonList.count() - 1 : 0;
+ int end = reverse ? -1 : buttonList.count();
+ int step = reverse ? -1 : 1;
+
+ for (int i = start; i != end; i += step) {
+ QAbstractButton *button = buttonList.at(i);
+ buttonLayout->addWidget(button);
+ button->show();
+ }
+}
+
+void QDialogButtonBoxPrivate::layoutButtons()
+{
+ Q_Q(QDialogButtonBox);
+ const int MacGap = 36 - 8; // 8 is the default gap between a widget and a spacer item
+
+ for (int i = buttonLayout->count() - 1; i >= 0; --i) {
+ QLayoutItem *item = buttonLayout->takeAt(i);
+ if (QWidget *widget = item->widget())
+ widget->hide();
+ delete item;
+ }
+
+ int tmpPolicy = layoutPolicy;
+
+ static const int M = 5;
+ static const int ModalRoles[M] = { AcceptRole, RejectRole, DestructiveRole, YesRole, NoRole };
+ if (tmpPolicy == QDialogButtonBox::MacLayout) {
+ bool hasModalButton = false;
+ for (int i = 0; i < M; ++i) {
+ if (!buttonLists[ModalRoles[i]].isEmpty()) {
+ hasModalButton = true;
+ break;
+ }
+ }
+ if (!hasModalButton)
+ tmpPolicy = 4; // Mac modeless
+ }
+
+ const int *currentLayout = layouts[orientation == Qt::Vertical][tmpPolicy];
+
+ if (center)
+ buttonLayout->addStretch();
+
+ QList<QAbstractButton *> acceptRoleList = buttonLists[AcceptRole];
+
+ while (*currentLayout != EOL) {
+ int role = (*currentLayout & ~Reverse);
+ bool reverse = (*currentLayout & Reverse);
+
+ switch (role) {
+ case Stretch:
+ if (!center)
+ buttonLayout->addStretch();
+ break;
+ case AcceptRole: {
+ if (acceptRoleList.isEmpty())
+ break;
+ // Only the first one
+ QAbstractButton *button = acceptRoleList.first();
+ buttonLayout->addWidget(button);
+ button->show();
+ }
+ break;
+ case AlternateRole:
+ {
+ if (acceptRoleList.size() < 2)
+ break;
+ QList<QAbstractButton *> list = acceptRoleList;
+ list.removeFirst();
+ addButtonsToLayout(list, reverse);
+ }
+ break;
+ case DestructiveRole:
+ {
+ const QList<QAbstractButton *> &list = buttonLists[role];
+
+ /*
+ Mac: Insert a gap on the left of the destructive
+ buttons to ensure that they don't get too close to
+ the help and action buttons (but only if there are
+ some buttons to the left of the destructive buttons
+ (and the stretch, whence buttonLayout->count() > 1
+ and not 0)).
+ */
+ if (tmpPolicy == QDialogButtonBox::MacLayout
+ && !list.isEmpty() && buttonLayout->count() > 1)
+ buttonLayout->addSpacing(MacGap);
+
+ addButtonsToLayout(list, reverse);
+
+ /*
+ Insert a gap between the destructive buttons and the
+ accept and reject buttons.
+ */
+ if (tmpPolicy == QDialogButtonBox::MacLayout && !list.isEmpty())
+ buttonLayout->addSpacing(MacGap);
+ }
+ break;
+ case RejectRole:
+ case ActionRole:
+ case HelpRole:
+ case YesRole:
+ case NoRole:
+ case ApplyRole:
+ case ResetRole:
+ addButtonsToLayout(buttonLists[role], reverse);
+ }
+ ++currentLayout;
+ }
+
+ QWidget *lastWidget = 0;
+ q->setFocusProxy(0);
+ for (int i = 0; i < buttonLayout->count(); ++i) {
+ QLayoutItem *item = buttonLayout->itemAt(i);
+ if (QWidget *widget = item->widget()) {
+ if (lastWidget)
+ QWidget::setTabOrder(lastWidget, widget);
+ else
+ q->setFocusProxy(widget);
+ lastWidget = widget;
+ }
+ }
+
+ if (center)
+ buttonLayout->addStretch();
+}
+
+QPushButton *QDialogButtonBoxPrivate::createButton(QDialogButtonBox::StandardButton sbutton,
+ bool doLayout)
+{
+ Q_Q(QDialogButtonBox);
+ const char *buttonText = 0;
+ int icon = 0;
+
+ switch (sbutton) {
+ case QDialogButtonBox::Ok:
+ icon = QStyle::SP_DialogOkButton;
+ break;
+ case QDialogButtonBox::Save:
+ icon = QStyle::SP_DialogSaveButton;
+ break;
+ case QDialogButtonBox::Open:
+ icon = QStyle::SP_DialogOpenButton;
+ break;
+ case QDialogButtonBox::Cancel:
+ icon = QStyle::SP_DialogCancelButton;
+ break;
+ case QDialogButtonBox::Close:
+ icon = QStyle::SP_DialogCloseButton;
+ break;
+ case QDialogButtonBox::Apply:
+ icon = QStyle::SP_DialogApplyButton;
+ break;
+ case QDialogButtonBox::Reset:
+ icon = QStyle::SP_DialogResetButton;
+ break;
+ case QDialogButtonBox::Help:
+ icon = QStyle::SP_DialogHelpButton;
+ break;
+ case QDialogButtonBox::Discard:
+ icon = QStyle::SP_DialogDiscardButton;
+ break;
+ case QDialogButtonBox::Yes:
+ icon = QStyle::SP_DialogYesButton;
+ break;
+ case QDialogButtonBox::No:
+ icon = QStyle::SP_DialogNoButton;
+ break;
+ case QDialogButtonBox::YesToAll:
+ case QDialogButtonBox::NoToAll:
+ case QDialogButtonBox::SaveAll:
+ case QDialogButtonBox::Abort:
+ case QDialogButtonBox::Retry:
+ case QDialogButtonBox::Ignore:
+ case QDialogButtonBox::RestoreDefaults:
+ break;
+ case QDialogButtonBox::NoButton:
+ return 0;
+ ;
+ }
+ buttonText = standardButtonText(sbutton);
+
+ QPushButton *button = new QPushButton(QDialogButtonBox::tr(buttonText), q);
+ QStyle *style = q->style();
+ if (style->styleHint(QStyle::SH_DialogButtonBox_ButtonsHaveIcons, 0, q) && icon != 0)
+ button->setIcon(style->standardIcon(QStyle::StandardPixmap(icon), 0, q));
+ if (style != QApplication::style()) // Propagate style
+ button->setStyle(style);
+ standardButtonHash.insert(button, sbutton);
+ if (roleFor(sbutton) != QDialogButtonBox::InvalidRole) {
+ addButton(button, roleFor(sbutton), doLayout);
+ } else {
+ qWarning("QDialogButtonBox::createButton: Invalid ButtonRole, button not added");
+ }
+
+#ifdef Q_WS_MAC
+ // Since mnemonics is off by default on Mac, we add a Cmd-D
+ // shortcut here to e.g. make the "Don't Save" button work nativly:
+ if (sbutton == QDialogButtonBox::Discard)
+ button->setShortcut(QKeySequence(QLatin1String("Ctrl+D")));
+#endif
+
+ return button;
+}
+
+void QDialogButtonBoxPrivate::addButton(QAbstractButton *button, QDialogButtonBox::ButtonRole role,
+ bool doLayout)
+{
+ Q_Q(QDialogButtonBox);
+ QObject::connect(button, SIGNAL(clicked()), q, SLOT(_q_handleButtonClicked()));
+ QObject::connect(button, SIGNAL(destroyed()), q, SLOT(_q_handleButtonDestroyed()));
+ buttonLists[role].append(button);
+#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION)
+ QAction *action = createSoftKey(button, role);
+ softKeyActions.insert(button, action);
+ new QDialogButtonEnabledProxy(action, button, action);
+#endif
+ if (doLayout)
+ layoutButtons();
+}
+
+#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION)
+QAction* QDialogButtonBoxPrivate::createSoftKey(QAbstractButton *button, QDialogButtonBox::ButtonRole role)
+{
+ Q_Q(QDialogButtonBox);
+ QAction::SoftKeyRole softkeyRole;
+
+ QAction *action = new QAction(button->text(), button);
+
+ switch (role) {
+ case ApplyRole:
+ case AcceptRole:
+ case YesRole:
+ case ActionRole:
+ case HelpRole:
+ softkeyRole = QAction::PositiveSoftKey;
+ break;
+ case RejectRole:
+ case DestructiveRole:
+ case NoRole:
+ case ResetRole:
+ softkeyRole = QAction::NegativeSoftKey;
+ break;
+ default:
+ break;
+ }
+ QObject::connect(action, SIGNAL(triggered()), button, SIGNAL(clicked()));
+ action->setSoftKeyRole(softkeyRole);
+
+
+ QWidget *dialog = 0;
+ QWidget *p = q;
+ while (p && !p->isWindow()) {
+ p = p->parentWidget();
+ if ((dialog = qobject_cast<QDialog *>(p)))
+ break;
+ }
+
+ if (dialog) {
+ dialog->addAction(action);
+ } else {
+ q->addAction(action);
+ }
+
+ return action;
+}
+#endif
+
+void QDialogButtonBoxPrivate::createStandardButtons(QDialogButtonBox::StandardButtons buttons)
+{
+ uint i = QDialogButtonBox::FirstButton;
+ while (i <= QDialogButtonBox::LastButton) {
+ if (i & buttons) {
+ createButton(QDialogButtonBox::StandardButton(i), false);
+ }
+ i = i << 1;
+ }
+ layoutButtons();
+}
+
+const char *QDialogButtonBoxPrivate::standardButtonText(QDialogButtonBox::StandardButton sbutton) const
+{
+ const char *buttonText = 0;
+ bool gnomeLayout = (layoutPolicy == QDialogButtonBox::GnomeLayout);
+ switch (sbutton) {
+ case QDialogButtonBox::Ok:
+ buttonText = gnomeLayout ? QT_TRANSLATE_NOOP("QDialogButtonBox", "&OK") : QT_TRANSLATE_NOOP("QDialogButtonBox", "OK");
+ break;
+ case QDialogButtonBox::Save:
+ buttonText = gnomeLayout ? QT_TRANSLATE_NOOP("QDialogButtonBox", "&Save") : QT_TRANSLATE_NOOP("QDialogButtonBox", "Save");
+ break;
+ case QDialogButtonBox::Open:
+ buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Open");
+ break;
+ case QDialogButtonBox::Cancel:
+ buttonText = gnomeLayout ? QT_TRANSLATE_NOOP("QDialogButtonBox", "&Cancel") : QT_TRANSLATE_NOOP("QDialogButtonBox", "Cancel");
+ break;
+ case QDialogButtonBox::Close:
+ buttonText = gnomeLayout ? QT_TRANSLATE_NOOP("QDialogButtonBox", "&Close") : QT_TRANSLATE_NOOP("QDialogButtonBox", "Close");
+ break;
+ case QDialogButtonBox::Apply:
+ buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Apply");
+ break;
+ case QDialogButtonBox::Reset:
+ buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Reset");
+ break;
+ case QDialogButtonBox::Help:
+ buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Help");
+ break;
+ case QDialogButtonBox::Discard:
+ if (layoutPolicy == QDialogButtonBox::MacLayout)
+ buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Don't Save");
+ else if (layoutPolicy == QDialogButtonBox::GnomeLayout)
+ buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Close without Saving");
+ else
+ buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Discard");
+ break;
+ case QDialogButtonBox::Yes:
+ buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "&Yes");
+ break;
+ case QDialogButtonBox::YesToAll:
+ buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Yes to &All");
+ break;
+ case QDialogButtonBox::No:
+ buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "&No");
+ break;
+ case QDialogButtonBox::NoToAll:
+ buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "N&o to All");
+ break;
+ case QDialogButtonBox::SaveAll:
+ buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Save All");
+ break;
+ case QDialogButtonBox::Abort:
+ buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Abort");
+ break;
+ case QDialogButtonBox::Retry:
+ buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Retry");
+ break;
+ case QDialogButtonBox::Ignore:
+ buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Ignore");
+ break;
+ case QDialogButtonBox::RestoreDefaults:
+ buttonText = QT_TRANSLATE_NOOP("QDialogButtonBox", "Restore Defaults");
+ break;
+ case QDialogButtonBox::NoButton:
+ ;
+ } // switch
+ return buttonText;
+}
+
+void QDialogButtonBoxPrivate::retranslateStrings()
+{
+ const char *buttonText = 0;
+ QHash<QPushButton *, QDialogButtonBox::StandardButton>::iterator it = standardButtonHash.begin();
+ while (it != standardButtonHash.end()) {
+ buttonText = standardButtonText(it.value());
+ if (buttonText) {
+ QPushButton *button = it.key();
+ button->setText(QDialogButtonBox::tr(buttonText));
+#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION)
+ QAction *action = softKeyActions.value(button, 0);
+ if (action)
+ action->setText(button->text());
+#endif
+ }
+ ++it;
+ }
+}
+
+/*!
+ Constructs an empty, horizontal button box with the given \a parent.
+
+ \sa orientation, addButton()
+*/
+QDialogButtonBox::QDialogButtonBox(QWidget *parent)
+ : QWidget(*new QDialogButtonBoxPrivate(Qt::Horizontal), parent, 0)
+{
+ d_func()->initLayout();
+}
+
+/*!
+ Constructs an empty button box with the given \a orientation and \a parent.
+
+ \sa orientation, addButton()
+*/
+QDialogButtonBox::QDialogButtonBox(Qt::Orientation orientation, QWidget *parent)
+ : QWidget(*new QDialogButtonBoxPrivate(orientation), parent, 0)
+{
+ d_func()->initLayout();
+}
+
+/*!
+ Constructs a button box with the given \a orientation and \a parent, containing
+ the standard buttons specified by \a buttons.
+
+ \sa orientation, addButton()
+*/
+QDialogButtonBox::QDialogButtonBox(StandardButtons buttons, Qt::Orientation orientation,
+ QWidget *parent)
+ : QWidget(*new QDialogButtonBoxPrivate(orientation), parent, 0)
+{
+ d_func()->initLayout();
+ d_func()->createStandardButtons(buttons);
+}
+
+/*!
+ Destroys the button box.
+*/
+QDialogButtonBox::~QDialogButtonBox()
+{
+}
+
+/*!
+ \enum QDialogButtonBox::ButtonRole
+ \enum QMessageBox::ButtonRole
+
+ This enum describes the roles that can be used to describe buttons in
+ the button box. Combinations of these roles are as flags used to
+ describe different aspects of their behavior.
+
+ \value InvalidRole The button is invalid.
+ \value AcceptRole Clicking the button causes the dialog to be accepted
+ (e.g. OK).
+ \value RejectRole Clicking the button causes the dialog to be rejected
+ (e.g. Cancel).
+ \value DestructiveRole Clicking the button causes a destructive change
+ (e.g. for Discarding Changes) and closes the dialog.
+ \value ActionRole Clicking the button causes changes to the elements within
+ the dialog.
+ \value HelpRole The button can be clicked to request help.
+ \value YesRole The button is a "Yes"-like button.
+ \value NoRole The button is a "No"-like button.
+ \value ApplyRole The button applies current changes.
+ \value ResetRole The button resets the dialog's fields to default values.
+
+ \omitvalue NRoles
+
+ \sa StandardButton
+*/
+
+/*!
+ \enum QDialogButtonBox::StandardButton
+
+ These enums describe flags for standard buttons. Each button has a
+ defined \l ButtonRole.
+
+ \value Ok An "OK" button defined with the \l AcceptRole.
+ \value Open A "Open" button defined with the \l AcceptRole.
+ \value Save A "Save" button defined with the \l AcceptRole.
+ \value Cancel A "Cancel" button defined with the \l RejectRole.
+ \value Close A "Close" button defined with the \l RejectRole.
+ \value Discard A "Discard" or "Don't Save" button, depending on the platform,
+ defined with the \l DestructiveRole.
+ \value Apply An "Apply" button defined with the \l ApplyRole.
+ \value Reset A "Reset" button defined with the \l ResetRole.
+ \value RestoreDefaults A "Restore Defaults" button defined with the \l ResetRole.
+ \value Help A "Help" button defined with the \l HelpRole.
+ \value SaveAll A "Save All" button defined with the \l AcceptRole.
+ \value Yes A "Yes" button defined with the \l YesRole.
+ \value YesToAll A "Yes to All" button defined with the \l YesRole.
+ \value No A "No" button defined with the \l NoRole.
+ \value NoToAll A "No to All" button defined with the \l NoRole.
+ \value Abort An "Abort" button defined with the \l RejectRole.
+ \value Retry A "Retry" button defined with the \l AcceptRole.
+ \value Ignore An "Ignore" button defined with the \l AcceptRole.
+
+ \value NoButton An invalid button.
+
+ \omitvalue FirstButton
+ \omitvalue LastButton
+
+ \sa ButtonRole, standardButtons
+*/
+
+/*!
+ \enum QDialogButtonBox::ButtonLayout
+
+ This enum describes the layout policy to be used when arranging the buttons
+ contained in the button box.
+
+ \value WinLayout Use a policy appropriate for applications on Windows.
+ \value MacLayout Use a policy appropriate for applications on Mac OS X.
+ \value KdeLayout Use a policy appropriate for applications on KDE.
+ \value GnomeLayout Use a policy appropriate for applications on GNOME.
+
+ The button layout is specified by the \l{style()}{current style}. However,
+ on the X11 platform, it may be influenced by the desktop environment.
+*/
+
+/*!
+ \fn void QDialogButtonBox::clicked(QAbstractButton *button)
+
+ This signal is emitted when a button inside the button box is clicked. The
+ specific button that was pressed is specified by \a button.
+
+ \sa accepted(), rejected(), helpRequested()
+*/
+
+/*!
+ \fn void QDialogButtonBox::accepted()
+
+ This signal is emitted when a button inside the button box is clicked, as long
+ as it was defined with the \l AcceptRole or \l YesRole.
+
+ \sa rejected(), clicked() helpRequested()
+*/
+
+/*!
+ \fn void QDialogButtonBox::rejected()
+
+ This signal is emitted when a button inside the button box is clicked, as long
+ as it was defined with the \l RejectRole or \l NoRole.
+
+ \sa accepted() helpRequested() clicked()
+*/
+
+/*!
+ \fn void QDialogButtonBox::helpRequested()
+
+ This signal is emitted when a button inside the button box is clicked, as long
+ as it was defined with the \l HelpRole.
+
+ \sa accepted() rejected() clicked()
+*/
+
+/*!
+ \property QDialogButtonBox::orientation
+ \brief the orientation of the button box
+
+ By default, the orientation is horizontal (i.e. the buttons are laid out
+ side by side). The possible orientations are Qt::Horizontal and
+ Qt::Vertical.
+*/
+Qt::Orientation QDialogButtonBox::orientation() const
+{
+ return d_func()->orientation;
+}
+
+void QDialogButtonBox::setOrientation(Qt::Orientation orientation)
+{
+ Q_D(QDialogButtonBox);
+ if (orientation == d->orientation)
+ return;
+
+ d->orientation = orientation;
+ d->resetLayout();
+}
+
+/*!
+ Clears the button box, deleting all buttons within it.
+
+ \sa removeButton(), addButton()
+*/
+void QDialogButtonBox::clear()
+{
+ Q_D(QDialogButtonBox);
+#ifdef QT_SOFTKEYS_ENABLED
+ // Delete softkey actions as they have the buttons as parents
+ qDeleteAll(d->softKeyActions.values());
+ d->softKeyActions.clear();
+#endif
+ // Remove the created standard buttons, they should be in the other lists, which will
+ // do the deletion
+ d->standardButtonHash.clear();
+ for (int i = 0; i < NRoles; ++i) {
+ QList<QAbstractButton *> &list = d->buttonLists[i];
+ while (list.count()) {
+ QAbstractButton *button = list.takeAt(0);
+ QObject::disconnect(button, SIGNAL(destroyed()), this, SLOT(_q_handleButtonDestroyed()));
+ delete button;
+ }
+ }
+}
+
+/*!
+ Returns a list of all the buttons that have been added to the button box.
+
+ \sa buttonRole(), addButton(), removeButton()
+*/
+QList<QAbstractButton *> QDialogButtonBox::buttons() const
+{
+ Q_D(const QDialogButtonBox);
+ QList<QAbstractButton *> finalList;
+ for (int i = 0; i < NRoles; ++i) {
+ const QList<QAbstractButton *> &list = d->buttonLists[i];
+ for (int j = 0; j < list.count(); ++j)
+ finalList.append(list.at(j));
+ }
+ return finalList;
+}
+
+/*!
+ Returns the button role for the specified \a button. This function returns
+ \l InvalidRole if \a button is 0 or has not been added to the button box.
+
+ \sa buttons(), addButton()
+*/
+QDialogButtonBox::ButtonRole QDialogButtonBox::buttonRole(QAbstractButton *button) const
+{
+ Q_D(const QDialogButtonBox);
+ for (int i = 0; i < NRoles; ++i) {
+ const QList<QAbstractButton *> &list = d->buttonLists[i];
+ for (int j = 0; j < list.count(); ++j) {
+ if (list.at(j) == button)
+ return ButtonRole(i);
+ }
+ }
+ return InvalidRole;
+}
+
+/*!
+ Removes \a button from the button box without deleting it and sets its parent to zero.
+
+ \sa clear(), buttons(), addButton()
+*/
+void QDialogButtonBox::removeButton(QAbstractButton *button)
+{
+ Q_D(QDialogButtonBox);
+
+ if (!button)
+ return;
+
+ // Remove it from the standard button hash first and then from the roles
+ if (QPushButton *pushButton = qobject_cast<QPushButton *>(button))
+ d->standardButtonHash.remove(pushButton);
+ for (int i = 0; i < NRoles; ++i) {
+ QList<QAbstractButton *> &list = d->buttonLists[i];
+ for (int j = 0; j < list.count(); ++j) {
+ if (list.at(j) == button) {
+ list.takeAt(j);
+ if (!d->internalRemove) {
+ disconnect(button, SIGNAL(clicked()), this, SLOT(_q_handleButtonClicked()));
+ disconnect(button, SIGNAL(destroyed()), this, SLOT(_q_handleButtonDestroyed()));
+ }
+ break;
+ }
+ }
+ }
+#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION)
+ QAction *action = d->softKeyActions.value(button, 0);
+ if (action) {
+ d->softKeyActions.remove(button);
+ delete action;
+ }
+#endif
+ if (!d->internalRemove)
+ button->setParent(0);
+}
+
+/*!
+ Adds the given \a button to the button box with the specified \a role.
+ If the role is invalid, the button is not added.
+
+ If the button has already been added, it is removed and added again with the
+ new role.
+
+ \note The button box takes ownership of the button.
+
+ \sa removeButton(), clear()
+*/
+void QDialogButtonBox::addButton(QAbstractButton *button, ButtonRole role)
+{
+ Q_D(QDialogButtonBox);
+ if (role <= InvalidRole || role >= NRoles) {
+ qWarning("QDialogButtonBox::addButton: Invalid ButtonRole, button not added");
+ return;
+ }
+ removeButton(button);
+ button->setParent(this);
+ d->addButton(button, role);
+}
+
+/*!
+ Creates a push button with the given \a text, adds it to the button box for the
+ specified \a role, and returns the corresponding push button. If \a role is
+ invalid, no button is created, and zero is returned.
+
+ \sa removeButton(), clear()
+*/
+QPushButton *QDialogButtonBox::addButton(const QString &text, ButtonRole role)
+{
+ Q_D(QDialogButtonBox);
+ if (role <= InvalidRole || role >= NRoles) {
+ qWarning("QDialogButtonBox::addButton: Invalid ButtonRole, button not added");
+ return 0;
+ }
+ QPushButton *button = new QPushButton(text, this);
+ d->addButton(button, role);
+ return button;
+}
+
+/*!
+ Adds a standard \a button to the button box if it is valid to do so, and returns
+ a push button. If \a button is invalid, it is not added to the button box, and
+ zero is returned.
+
+ \sa removeButton(), clear()
+*/
+QPushButton *QDialogButtonBox::addButton(StandardButton button)
+{
+ Q_D(QDialogButtonBox);
+ return d->createButton(button);
+}
+
+/*!
+ \property QDialogButtonBox::standardButtons
+ \brief collection of standard buttons in the button box
+
+ This property controls which standard buttons are used by the button box.
+
+ \sa addButton()
+*/
+void QDialogButtonBox::setStandardButtons(StandardButtons buttons)
+{
+ Q_D(QDialogButtonBox);
+#ifdef QT_SOFTKEYS_ENABLED
+ // Delete softkey actions since they have the buttons as parents
+ qDeleteAll(d->softKeyActions.values());
+ d->softKeyActions.clear();
+#endif
+ // Clear out all the old standard buttons, then recreate them.
+ qDeleteAll(d->standardButtonHash.keys());
+ d->standardButtonHash.clear();
+
+ d->createStandardButtons(buttons);
+}
+
+QDialogButtonBox::StandardButtons QDialogButtonBox::standardButtons() const
+{
+ Q_D(const QDialogButtonBox);
+ StandardButtons standardButtons = NoButton;
+ QHash<QPushButton *, StandardButton>::const_iterator it = d->standardButtonHash.constBegin();
+ while (it != d->standardButtonHash.constEnd()) {
+ standardButtons |= it.value();
+ ++it;
+ }
+ return standardButtons;
+}
+
+/*!
+ Returns the QPushButton corresponding to the standard button \a which,
+ or 0 if the standard button doesn't exist in this button box.
+
+ \sa standardButton(), standardButtons(), buttons()
+*/
+QPushButton *QDialogButtonBox::button(StandardButton which) const
+{
+ Q_D(const QDialogButtonBox);
+ return d->standardButtonHash.key(which);
+}
+
+/*!
+ Returns the standard button enum value corresponding to the given \a button,
+ or NoButton if the given \a button isn't a standard button.
+
+ \sa button(), buttons(), standardButtons()
+*/
+QDialogButtonBox::StandardButton QDialogButtonBox::standardButton(QAbstractButton *button) const
+{
+ Q_D(const QDialogButtonBox);
+ return d->standardButtonHash.value(static_cast<QPushButton *>(button));
+}
+
+void QDialogButtonBoxPrivate::_q_handleButtonClicked()
+{
+ Q_Q(QDialogButtonBox);
+ if (QAbstractButton *button = qobject_cast<QAbstractButton *>(q->sender())) {
+ emit q->clicked(button);
+
+ switch (q->buttonRole(button)) {
+ case AcceptRole:
+ case YesRole:
+ emit q->accepted();
+ break;
+ case RejectRole:
+ case NoRole:
+ emit q->rejected();
+ break;
+ case HelpRole:
+ emit q->helpRequested();
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+void QDialogButtonBoxPrivate::_q_handleButtonDestroyed()
+{
+ Q_Q(QDialogButtonBox);
+ if (QObject *object = q->sender()) {
+ QBoolBlocker skippy(internalRemove);
+ q->removeButton(static_cast<QAbstractButton *>(object));
+ }
+}
+
+/*!
+ \property QDialogButtonBox::centerButtons
+ \brief whether the buttons in the button box are centered
+
+ By default, this property is false. This behavior is appopriate
+ for most types of dialogs. A notable exception is message boxes
+ on most platforms (e.g. Windows), where the button box is
+ centered horizontally.
+
+ \sa QMessageBox
+*/
+void QDialogButtonBox::setCenterButtons(bool center)
+{
+ Q_D(QDialogButtonBox);
+ if (d->center != center) {
+ d->center = center;
+ d->resetLayout();
+ }
+}
+
+bool QDialogButtonBox::centerButtons() const
+{
+ Q_D(const QDialogButtonBox);
+ return d->center;
+}
+
+/*!
+ \reimp
+*/
+void QDialogButtonBox::changeEvent(QEvent *event)
+{
+ typedef QHash<QPushButton *, QDialogButtonBox::StandardButton> StandardButtonHash;
+
+ Q_D(QDialogButtonBox);
+ switch (event->type()) {
+ case QEvent::StyleChange: // Propagate style
+ if (!d->standardButtonHash.empty()) {
+ QStyle *newStyle = style();
+ const StandardButtonHash::iterator end = d->standardButtonHash.end();
+ for (StandardButtonHash::iterator it = d->standardButtonHash.begin(); it != end; ++it)
+ it.key()->setStyle(newStyle);
+ }
+ // fallthrough intended
+#ifdef Q_WS_MAC
+ case QEvent::MacSizeChange:
+#endif
+ d->resetLayout();
+ QWidget::changeEvent(event);
+ break;
+ default:
+ QWidget::changeEvent(event);
+ break;
+ }
+}
+
+/*!
+ \reimp
+*/
+bool QDialogButtonBox::event(QEvent *event)
+{
+ Q_D(QDialogButtonBox);
+ if (event->type() == QEvent::Show) {
+ QList<QAbstractButton *> acceptRoleList = d->buttonLists[AcceptRole];
+ QPushButton *firstAcceptButton = acceptRoleList.isEmpty() ? 0 : qobject_cast<QPushButton *>(acceptRoleList.at(0));
+ bool hasDefault = false;
+ QWidget *dialog = 0;
+ QWidget *p = this;
+ while (p && !p->isWindow()) {
+ p = p->parentWidget();
+ if ((dialog = qobject_cast<QDialog *>(p)))
+ break;
+ }
+
+ foreach (QPushButton *pb, (dialog ? dialog : this)->findChildren<QPushButton *>()) {
+ if (pb->isDefault() && pb != firstAcceptButton) {
+ hasDefault = true;
+ break;
+ }
+ }
+ if (!hasDefault && firstAcceptButton)
+ firstAcceptButton->setDefault(true);
+#ifdef QT_SOFTKEYS_ENABLED
+ if (dialog)
+ setFixedSize(0,0);
+#endif
+ }else if (event->type() == QEvent::LanguageChange) {
+ d->retranslateStrings();
+ }
+#if defined(QT_SOFTKEYS_ENABLED) && !defined(QT_NO_ACTION)
+ else if (event->type() == QEvent::ParentChange) {
+ QWidget *dialog = 0;
+ QWidget *p = this;
+ while (p && !p->isWindow()) {
+ p = p->parentWidget();
+ if ((dialog = qobject_cast<QDialog *>(p)))
+ break;
+ }
+
+ // If the parent changes, then move the softkeys
+ for (QHash<QAbstractButton *, QAction *>::const_iterator it = d->softKeyActions.constBegin();
+ it != d->softKeyActions.constEnd(); ++it) {
+ QAction *current = it.value();
+ QList<QWidget *> widgets = current->associatedWidgets();
+ foreach (QWidget *w, widgets)
+ w->removeAction(current);
+ if (dialog)
+ dialog->addAction(current);
+ else
+ addAction(current);
+ }
+ }
+#endif
+
+ return QWidget::event(event);
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qdialogbuttonbox.cpp"
diff --git a/src/widgets/widgets/qdialogbuttonbox.h b/src/widgets/widgets/qdialogbuttonbox.h
new file mode 100644
index 0000000000..3bf242ba2f
--- /dev/null
+++ b/src/widgets/widgets/qdialogbuttonbox.h
@@ -0,0 +1,168 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDIALOGBUTTONBOX_H
+#define QDIALOGBUTTONBOX_H
+
+#include <QtWidgets/qwidget.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QAbstractButton;
+class QPushButton;
+class QDialogButtonBoxPrivate;
+
+class Q_GUI_EXPORT QDialogButtonBox : public QWidget
+{
+ Q_OBJECT
+ Q_FLAGS(StandardButtons)
+ Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
+ Q_PROPERTY(StandardButtons standardButtons READ standardButtons WRITE setStandardButtons)
+ Q_PROPERTY(bool centerButtons READ centerButtons WRITE setCenterButtons)
+
+public:
+ enum ButtonRole {
+ // keep this in sync with QMessageBox::ButtonRole
+ InvalidRole = -1,
+ AcceptRole,
+ RejectRole,
+ DestructiveRole,
+ ActionRole,
+ HelpRole,
+ YesRole,
+ NoRole,
+ ResetRole,
+ ApplyRole,
+
+ NRoles
+ };
+
+ enum StandardButton {
+ // keep this in sync with QMessageBox::StandardButton
+ NoButton = 0x00000000,
+ Ok = 0x00000400,
+ Save = 0x00000800,
+ SaveAll = 0x00001000,
+ Open = 0x00002000,
+ Yes = 0x00004000,
+ YesToAll = 0x00008000,
+ No = 0x00010000,
+ NoToAll = 0x00020000,
+ Abort = 0x00040000,
+ Retry = 0x00080000,
+ Ignore = 0x00100000,
+ Close = 0x00200000,
+ Cancel = 0x00400000,
+ Discard = 0x00800000,
+ Help = 0x01000000,
+ Apply = 0x02000000,
+ Reset = 0x04000000,
+ RestoreDefaults = 0x08000000,
+
+#ifndef Q_MOC_RUN
+ FirstButton = Ok,
+ LastButton = RestoreDefaults
+#endif
+ };
+
+ Q_DECLARE_FLAGS(StandardButtons, StandardButton)
+
+ enum ButtonLayout {
+ WinLayout,
+ MacLayout,
+ KdeLayout,
+ GnomeLayout
+ };
+
+ QDialogButtonBox(QWidget *parent = 0);
+ QDialogButtonBox(Qt::Orientation orientation, QWidget *parent = 0);
+ QDialogButtonBox(StandardButtons buttons, Qt::Orientation orientation = Qt::Horizontal,
+ QWidget *parent = 0);
+ ~QDialogButtonBox();
+
+ void setOrientation(Qt::Orientation orientation);
+ Qt::Orientation orientation() const;
+
+ void addButton(QAbstractButton *button, ButtonRole role);
+ QPushButton *addButton(const QString &text, ButtonRole role);
+ QPushButton *addButton(StandardButton button);
+ void removeButton(QAbstractButton *button);
+ void clear();
+
+ QList<QAbstractButton *> buttons() const;
+ ButtonRole buttonRole(QAbstractButton *button) const;
+
+ void setStandardButtons(StandardButtons buttons);
+ StandardButtons standardButtons() const;
+ StandardButton standardButton(QAbstractButton *button) const;
+ QPushButton *button(StandardButton which) const;
+
+ void setCenterButtons(bool center);
+ bool centerButtons() const;
+
+Q_SIGNALS:
+ void clicked(QAbstractButton *button);
+ void accepted();
+ void helpRequested();
+ void rejected();
+
+protected:
+ void changeEvent(QEvent *event);
+ bool event(QEvent *event);
+
+private:
+ Q_DISABLE_COPY(QDialogButtonBox)
+ Q_DECLARE_PRIVATE(QDialogButtonBox)
+ Q_PRIVATE_SLOT(d_func(), void _q_handleButtonClicked())
+ Q_PRIVATE_SLOT(d_func(), void _q_handleButtonDestroyed())
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QDialogButtonBox::StandardButtons)
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDIALOGBUTTONBOX_H
diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp
new file mode 100644
index 0000000000..6d599fcd57
--- /dev/null
+++ b/src/widgets/widgets/qdockarealayout.cpp
@@ -0,0 +1,3329 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "QtWidgets/qapplication.h"
+#include "QtWidgets/qwidget.h"
+#include "QtWidgets/qtabbar.h"
+#include "QtWidgets/qstyle.h"
+#include "QtWidgets/qdesktopwidget.h"
+#include "QtCore/qvariant.h"
+#include "qdockarealayout_p.h"
+#include "qdockwidget.h"
+#include "qmainwindow.h"
+#include "qwidgetanimator_p.h"
+#include "qmainwindowlayout_p.h"
+#include "qdockwidget_p.h"
+#include <private/qlayoutengine_p.h>
+
+#include <qpainter.h>
+#include <qstyleoption.h>
+
+#ifndef QT_NO_DOCKWIDGET
+
+QT_BEGIN_NAMESPACE
+
+// qmainwindow.cpp
+extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window);
+
+enum { StateFlagVisible = 1, StateFlagFloating = 2 };
+
+/******************************************************************************
+** QPlaceHolderItem
+*/
+
+QPlaceHolderItem::QPlaceHolderItem(QWidget *w)
+{
+ objectName = w->objectName();
+ hidden = w->isHidden();
+ window = w->isWindow();
+ if (window)
+ topLevelRect = w->geometry();
+}
+
+/******************************************************************************
+** QDockAreaLayoutItem
+*/
+
+QDockAreaLayoutItem::QDockAreaLayoutItem(QLayoutItem *_widgetItem)
+ : widgetItem(_widgetItem), subinfo(0), placeHolderItem(0), pos(0), size(-1), flags(NoFlags)
+{
+}
+
+QDockAreaLayoutItem::QDockAreaLayoutItem(QDockAreaLayoutInfo *_subinfo)
+ : widgetItem(0), subinfo(_subinfo), placeHolderItem(0), pos(0), size(-1), flags(NoFlags)
+{
+}
+
+QDockAreaLayoutItem::QDockAreaLayoutItem(QPlaceHolderItem *_placeHolderItem)
+ : widgetItem(0), subinfo(0), placeHolderItem(_placeHolderItem), pos(0), size(-1), flags(NoFlags)
+{
+}
+
+QDockAreaLayoutItem::QDockAreaLayoutItem(const QDockAreaLayoutItem &other)
+ : widgetItem(other.widgetItem), subinfo(0), placeHolderItem(0), pos(other.pos),
+ size(other.size), flags(other.flags)
+{
+ if (other.subinfo != 0)
+ subinfo = new QDockAreaLayoutInfo(*other.subinfo);
+ else if (other.placeHolderItem != 0)
+ placeHolderItem = new QPlaceHolderItem(*other.placeHolderItem);
+}
+
+QDockAreaLayoutItem::~QDockAreaLayoutItem()
+{
+ delete subinfo;
+ delete placeHolderItem;
+}
+
+bool QDockAreaLayoutItem::skip() const
+{
+ if (placeHolderItem != 0)
+ return true;
+
+ if (flags & GapItem)
+ return false;
+
+ if (widgetItem != 0)
+ return widgetItem->isEmpty();
+
+ if (subinfo != 0) {
+ for (int i = 0; i < subinfo->item_list.count(); ++i) {
+ if (!subinfo->item_list.at(i).skip())
+ return false;
+ }
+ }
+
+ return true;
+}
+
+QSize QDockAreaLayoutItem::minimumSize() const
+{
+ if (widgetItem != 0) {
+ int left, top, right, bottom;
+ widgetItem->widget()->getContentsMargins(&left, &top, &right, &bottom);
+ return widgetItem->minimumSize() + QSize(left+right, top+bottom);
+ }
+ if (subinfo != 0)
+ return subinfo->minimumSize();
+ return QSize(0, 0);
+}
+
+QSize QDockAreaLayoutItem::maximumSize() const
+{
+ if (widgetItem != 0) {
+ int left, top, right, bottom;
+ widgetItem->widget()->getContentsMargins(&left, &top, &right, &bottom);
+ return widgetItem->maximumSize()+ QSize(left+right, top+bottom);
+ }
+ if (subinfo != 0)
+ return subinfo->maximumSize();
+ return QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
+}
+
+bool QDockAreaLayoutItem::hasFixedSize(Qt::Orientation o) const
+{
+ return perp(o, minimumSize()) == perp(o, maximumSize());
+}
+
+bool QDockAreaLayoutItem::expansive(Qt::Orientation o) const
+{
+ if ((flags & GapItem) || placeHolderItem != 0)
+ return false;
+ if (widgetItem != 0)
+ return ((widgetItem->expandingDirections() & o) == o);
+ if (subinfo != 0)
+ return subinfo->expansive(o);
+ return false;
+}
+
+QSize QDockAreaLayoutItem::sizeHint() const
+{
+ if (placeHolderItem != 0)
+ return QSize(0, 0);
+ if (widgetItem != 0) {
+ int left, top, right, bottom;
+ widgetItem->widget()->getContentsMargins(&left, &top, &right, &bottom);
+ return widgetItem->sizeHint() + QSize(left+right, top+bottom);
+ }
+ if (subinfo != 0)
+ return subinfo->sizeHint();
+ return QSize(-1, -1);
+}
+
+QDockAreaLayoutItem
+ &QDockAreaLayoutItem::operator = (const QDockAreaLayoutItem &other)
+{
+ widgetItem = other.widgetItem;
+ if (other.subinfo == 0)
+ subinfo = 0;
+ else
+ subinfo = new QDockAreaLayoutInfo(*other.subinfo);
+
+ delete placeHolderItem;
+ if (other.placeHolderItem == 0)
+ placeHolderItem = 0;
+ else
+ placeHolderItem = new QPlaceHolderItem(*other.placeHolderItem);
+
+ pos = other.pos;
+ size = other.size;
+ flags = other.flags;
+
+ return *this;
+}
+
+/******************************************************************************
+** QDockAreaLayoutInfo
+*/
+
+#ifndef QT_NO_TABBAR
+static quintptr tabId(const QDockAreaLayoutItem &item)
+{
+ if (item.widgetItem == 0)
+ return 0;
+ return reinterpret_cast<quintptr>(item.widgetItem->widget());
+}
+#endif
+
+static const int zero = 0;
+
+QDockAreaLayoutInfo::QDockAreaLayoutInfo()
+ : sep(&zero), dockPos(QInternal::LeftDock), o(Qt::Horizontal), mainWindow(0)
+#ifndef QT_NO_TABBAR
+ , tabbed(false), tabBar(0), tabBarShape(QTabBar::RoundedSouth)
+#endif
+{
+}
+
+QDockAreaLayoutInfo::QDockAreaLayoutInfo(const int *_sep, QInternal::DockPosition _dockPos,
+ Qt::Orientation _o, int tbshape,
+ QMainWindow *window)
+ : sep(_sep), dockPos(_dockPos), o(_o), mainWindow(window)
+#ifndef QT_NO_TABBAR
+ , tabbed(false), tabBar(0), tabBarShape(static_cast<QTabBar::Shape>(tbshape))
+#endif
+{
+#ifdef QT_NO_TABBAR
+ Q_UNUSED(tbshape);
+#endif
+}
+
+QSize QDockAreaLayoutInfo::size() const
+{
+ return isEmpty() ? QSize(0, 0) : rect.size();
+}
+
+void QDockAreaLayoutInfo::clear()
+{
+ item_list.clear();
+ rect = QRect();
+#ifndef QT_NO_TABBAR
+ tabbed = false;
+ tabBar = 0;
+#endif
+}
+
+bool QDockAreaLayoutInfo::isEmpty() const
+{
+ return next(-1) == -1;
+}
+
+QSize QDockAreaLayoutInfo::minimumSize() const
+{
+ if (isEmpty())
+ return QSize(0, 0);
+
+ int a = 0, b = 0;
+ bool first = true;
+ for (int i = 0; i < item_list.size(); ++i) {
+ const QDockAreaLayoutItem &item = item_list.at(i);
+ if (item.skip())
+ continue;
+
+ QSize min_size = item.minimumSize();
+#ifndef QT_NO_TABBAR
+ if (tabbed) {
+ a = qMax(a, pick(o, min_size));
+ } else
+#endif
+ {
+ if (!first)
+ a += *sep;
+ a += pick(o, min_size);
+ }
+ b = qMax(b, perp(o, min_size));
+
+ first = false;
+ }
+
+ QSize result;
+ rpick(o, result) = a;
+ rperp(o, result) = b;
+
+#ifndef QT_NO_TABBAR
+ QSize tbm = tabBarMinimumSize();
+ if (!tbm.isNull()) {
+ switch (tabBarShape) {
+ case QTabBar::RoundedNorth:
+ case QTabBar::RoundedSouth:
+ case QTabBar::TriangularNorth:
+ case QTabBar::TriangularSouth:
+ result.rheight() += tbm.height();
+ result.rwidth() = qMax(tbm.width(), result.width());
+ break;
+ case QTabBar::RoundedEast:
+ case QTabBar::RoundedWest:
+ case QTabBar::TriangularEast:
+ case QTabBar::TriangularWest:
+ result.rheight() = qMax(tbm.height(), result.height());
+ result.rwidth() += tbm.width();
+ break;
+ default:
+ break;
+ }
+ }
+#endif // QT_NO_TABBAR
+
+ return result;
+}
+
+QSize QDockAreaLayoutInfo::maximumSize() const
+{
+ if (isEmpty())
+ return QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX);
+
+ int a = 0, b = QWIDGETSIZE_MAX;
+#ifndef QT_NO_TABBAR
+ if (tabbed)
+ a = QWIDGETSIZE_MAX;
+#endif
+
+ int min_perp = 0;
+
+ bool first = true;
+ for (int i = 0; i < item_list.size(); ++i) {
+ const QDockAreaLayoutItem &item = item_list.at(i);
+ if (item.skip())
+ continue;
+
+ QSize max_size = item.maximumSize();
+ min_perp = qMax(min_perp, perp(o, item.minimumSize()));
+
+#ifndef QT_NO_TABBAR
+ if (tabbed) {
+ a = qMin(a, pick(o, max_size));
+ } else
+#endif
+ {
+ if (!first)
+ a += *sep;
+ a += pick(o, max_size);
+ }
+ b = qMin(b, perp(o, max_size));
+
+ a = qMin(a, int(QWIDGETSIZE_MAX));
+ b = qMin(b, int(QWIDGETSIZE_MAX));
+
+ first = false;
+ }
+
+ b = qMax(b, min_perp);
+
+ QSize result;
+ rpick(o, result) = a;
+ rperp(o, result) = b;
+
+#ifndef QT_NO_TABBAR
+ QSize tbh = tabBarSizeHint();
+ if (!tbh.isNull()) {
+ switch (tabBarShape) {
+ case QTabBar::RoundedNorth:
+ case QTabBar::RoundedSouth:
+ result.rheight() += tbh.height();
+ break;
+ case QTabBar::RoundedEast:
+ case QTabBar::RoundedWest:
+ result.rwidth() += tbh.width();
+ break;
+ default:
+ break;
+ }
+ }
+#endif // QT_NO_TABBAR
+
+ return result;
+}
+
+QSize QDockAreaLayoutInfo::sizeHint() const
+{
+ if (isEmpty())
+ return QSize(0, 0);
+
+ int a = 0, b = 0;
+ int min_perp = 0;
+ int max_perp = QWIDGETSIZE_MAX;
+ const QDockAreaLayoutItem *previous = 0;
+ for (int i = 0; i < item_list.size(); ++i) {
+ const QDockAreaLayoutItem &item = item_list.at(i);
+ if (item.skip())
+ continue;
+
+ bool gap = item.flags & QDockAreaLayoutItem::GapItem;
+
+ QSize size_hint = item.sizeHint();
+ min_perp = qMax(min_perp, perp(o, item.minimumSize()));
+ max_perp = qMin(max_perp, perp(o, item.maximumSize()));
+
+#ifndef QT_NO_TABBAR
+ if (tabbed) {
+ a = qMax(a, gap ? item.size : pick(o, size_hint));
+ } else
+#endif
+ {
+ if (previous && !gap && !(previous->flags & QDockAreaLayoutItem::GapItem)
+ && !previous->hasFixedSize(o)) {
+ a += *sep;
+ }
+ a += gap ? item.size : pick(o, size_hint);
+ }
+ b = qMax(b, perp(o, size_hint));
+
+ previous = &item;
+ }
+
+ max_perp = qMax(max_perp, min_perp);
+ b = qMax(b, min_perp);
+ b = qMin(b, max_perp);
+
+ QSize result;
+ rpick(o, result) = a;
+ rperp(o, result) = b;
+
+#ifndef QT_NO_TABBAR
+ if (tabbed) {
+ QSize tbh = tabBarSizeHint();
+ switch (tabBarShape) {
+ case QTabBar::RoundedNorth:
+ case QTabBar::RoundedSouth:
+ case QTabBar::TriangularNorth:
+ case QTabBar::TriangularSouth:
+ result.rheight() += tbh.height();
+ result.rwidth() = qMax(tbh.width(), result.width());
+ break;
+ case QTabBar::RoundedEast:
+ case QTabBar::RoundedWest:
+ case QTabBar::TriangularEast:
+ case QTabBar::TriangularWest:
+ result.rheight() = qMax(tbh.height(), result.height());
+ result.rwidth() += tbh.width();
+ break;
+ default:
+ break;
+ }
+ }
+#endif // QT_NO_TABBAR
+
+ return result;
+}
+
+bool QDockAreaLayoutInfo::expansive(Qt::Orientation o) const
+{
+ for (int i = 0; i < item_list.size(); ++i) {
+ if (item_list.at(i).expansive(o))
+ return true;
+ }
+ return false;
+}
+
+/* QDockAreaLayoutInfo::maximumSize() doesn't return the real max size. For example,
+ if the layout is empty, it returns QWIDGETSIZE_MAX. This is so that empty dock areas
+ don't constrain the size of the QMainWindow, but sometimes we really need to know the
+ maximum size. Also, these functions take into account widgets that want to keep their
+ size (f.ex. when they are hidden and then shown, they should not change size).
+*/
+
+static int realMinSize(const QDockAreaLayoutInfo &info)
+{
+ int result = 0;
+ bool first = true;
+ for (int i = 0; i < info.item_list.size(); ++i) {
+ const QDockAreaLayoutItem &item = info.item_list.at(i);
+ if (item.skip())
+ continue;
+
+ int min = 0;
+ if ((item.flags & QDockAreaLayoutItem::KeepSize) && item.size != -1)
+ min = item.size;
+ else
+ min = pick(info.o, item.minimumSize());
+
+ if (!first)
+ result += *info.sep;
+ result += min;
+
+ first = false;
+ }
+
+ return result;
+}
+
+static int realMaxSize(const QDockAreaLayoutInfo &info)
+{
+ int result = 0;
+ bool first = true;
+ for (int i = 0; i < info.item_list.size(); ++i) {
+ const QDockAreaLayoutItem &item = info.item_list.at(i);
+ if (item.skip())
+ continue;
+
+ int max = 0;
+ if ((item.flags & QDockAreaLayoutItem::KeepSize) && item.size != -1)
+ max = item.size;
+ else
+ max = pick(info.o, item.maximumSize());
+
+ if (!first)
+ result += *info.sep;
+ result += max;
+
+ if (result >= QWIDGETSIZE_MAX)
+ return QWIDGETSIZE_MAX;
+
+ first = false;
+ }
+
+ return result;
+}
+
+void QDockAreaLayoutInfo::fitItems()
+{
+#ifndef QT_NO_TABBAR
+ if (tabbed) {
+ return;
+ }
+#endif
+
+ QVector<QLayoutStruct> layout_struct_list(item_list.size()*2);
+ int j = 0;
+
+ int size = pick(o, rect.size());
+ int min_size = realMinSize(*this);
+ int max_size = realMaxSize(*this);
+ int last_index = -1;
+
+ const QDockAreaLayoutItem *previous = 0;
+ for (int i = 0; i < item_list.size(); ++i) {
+ QDockAreaLayoutItem &item = item_list[i];
+ if (item.skip())
+ continue;
+
+ bool gap = item.flags & QDockAreaLayoutItem::GapItem;
+ if (previous && !gap) {
+ if (!(previous->flags & QDockAreaLayoutItem::GapItem)) {
+ QLayoutStruct &ls = layout_struct_list[j++];
+ ls.init();
+ ls.minimumSize = ls.maximumSize = ls.sizeHint = previous->hasFixedSize(o) ? 0 : *sep;
+ ls.empty = false;
+ }
+ }
+
+ if (item.flags & QDockAreaLayoutItem::KeepSize) {
+ // Check if the item can keep its size, without violating size constraints
+ // of other items.
+
+ if (size < min_size) {
+ // There is too little space to keep this widget's size
+ item.flags &= ~QDockAreaLayoutItem::KeepSize;
+ min_size -= item.size;
+ min_size += pick(o, item.minimumSize());
+ min_size = qMax(0, min_size);
+ } else if (size > max_size) {
+ // There is too much space to keep this widget's size
+ item.flags &= ~QDockAreaLayoutItem::KeepSize;
+ max_size -= item.size;
+ max_size += pick(o, item.maximumSize());
+ max_size = qMin<int>(QWIDGETSIZE_MAX, max_size);
+ }
+ }
+
+ last_index = j;
+ QLayoutStruct &ls = layout_struct_list[j++];
+ ls.init();
+ ls.empty = false;
+ if (item.flags & QDockAreaLayoutItem::KeepSize) {
+ ls.minimumSize = ls.maximumSize = ls.sizeHint = item.size;
+ ls.expansive = false;
+ ls.stretch = 0;
+ } else {
+ ls.maximumSize = pick(o, item.maximumSize());
+ ls.expansive = item.expansive(o);
+ ls.minimumSize = pick(o, item.minimumSize());
+ ls.sizeHint = item.size == -1 ? pick(o, item.sizeHint()) : item.size;
+ ls.stretch = ls.expansive ? ls.sizeHint : 0;
+ }
+
+ item.flags &= ~QDockAreaLayoutItem::KeepSize;
+ previous = &item;
+ }
+ layout_struct_list.resize(j);
+
+ // If there is more space than the widgets can take (due to maximum size constraints),
+ // we detect it here and stretch the last widget to take up the rest of the space.
+ if (size > max_size && last_index != -1) {
+ layout_struct_list[last_index].maximumSize = QWIDGETSIZE_MAX;
+ layout_struct_list[last_index].expansive = true;
+ }
+
+ qGeomCalc(layout_struct_list, 0, j, pick(o, rect.topLeft()), size, 0);
+
+ j = 0;
+ bool prev_gap = false;
+ bool first = true;
+ for (int i = 0; i < item_list.size(); ++i) {
+ QDockAreaLayoutItem &item = item_list[i];
+ if (item.skip())
+ continue;
+
+ bool gap = item.flags & QDockAreaLayoutItem::GapItem;
+ if (!first && !gap && !prev_gap)
+ ++j;
+
+ const QLayoutStruct &ls = layout_struct_list.at(j++);
+ item.size = ls.size;
+ item.pos = ls.pos;
+
+ if (item.subinfo != 0) {
+ item.subinfo->rect = itemRect(i);
+ item.subinfo->fitItems();
+ }
+
+ prev_gap = gap;
+ first = false;
+ }
+}
+
+static QInternal::DockPosition dockPosHelper(const QRect &rect, const QPoint &_pos,
+ Qt::Orientation o,
+ bool nestingEnabled,
+ QDockAreaLayoutInfo::TabMode tabMode)
+{
+ if (tabMode == QDockAreaLayoutInfo::ForceTabs)
+ return QInternal::DockCount;
+
+ QPoint pos = _pos - rect.topLeft();
+
+ int x = pos.x();
+ int y = pos.y();
+ int w = rect.width();
+ int h = rect.height();
+
+ if (tabMode != QDockAreaLayoutInfo::NoTabs) {
+ // is it in the center?
+ if (nestingEnabled) {
+ /* 2/3
+ +--------------+
+ | |
+ | CCCCCCCC |
+ 2/3 | CCCCCCCC |
+ | CCCCCCCC |
+ | |
+ +--------------+ */
+
+ QRect center(w/6, h/6, 2*w/3, 2*h/3);
+ if (center.contains(pos))
+ return QInternal::DockCount;
+ } else if (o == Qt::Horizontal) {
+ /* 2/3
+ +--------------+
+ | CCCCCCCC |
+ | CCCCCCCC |
+ | CCCCCCCC |
+ | CCCCCCCC |
+ | CCCCCCCC |
+ +--------------+ */
+
+ if (x > w/6 && x < w*5/6)
+ return QInternal::DockCount;
+ } else {
+ /*
+ +--------------+
+ | |
+ 2/3 |CCCCCCCCCCCCCC|
+ |CCCCCCCCCCCCCC|
+ | |
+ +--------------+ */
+ if (y > h/6 && y < 5*h/6)
+ return QInternal::DockCount;
+ }
+ }
+
+ // not in the center. which edge?
+ if (nestingEnabled) {
+ if (o == Qt::Horizontal) {
+ /* 1/3 1/3 1/3
+ +------------+ (we've already ruled out the center)
+ |LLLLTTTTRRRR|
+ |LLLLTTTTRRRR|
+ |LLLLBBBBRRRR|
+ |LLLLBBBBRRRR|
+ +------------+ */
+
+ if (x < w/3)
+ return QInternal::LeftDock;
+ if (x > 2*w/3)
+ return QInternal::RightDock;
+ if (y < h/2)
+ return QInternal::TopDock;
+ return QInternal::BottomDock;
+ } else {
+ /* +------------+ (we've already ruled out the center)
+ 1/3 |TTTTTTTTTTTT|
+ |LLLLLLRRRRRR|
+ 1/3 |LLLLLLRRRRRR|
+ 1/3 |BBBBBBBBBBBB|
+ +------------+ */
+
+ if (y < h/3)
+ return QInternal::TopDock;
+ if (y > 2*h/3)
+ return QInternal::BottomDock;
+ if (x < w/2)
+ return QInternal::LeftDock;
+ return QInternal::RightDock;
+ }
+ } else {
+ if (o == Qt::Horizontal) {
+ return x < w/2
+ ? QInternal::LeftDock
+ : QInternal::RightDock;
+ } else {
+ return y < h/2
+ ? QInternal::TopDock
+ : QInternal::BottomDock;
+ }
+ }
+}
+
+QList<int> QDockAreaLayoutInfo::gapIndex(const QPoint& _pos,
+ bool nestingEnabled, TabMode tabMode) const
+{
+ QList<int> result;
+ QRect item_rect;
+ int item_index = 0;
+
+#ifndef QT_NO_TABBAR
+ if (tabbed) {
+ item_rect = tabContentRect();
+ } else
+#endif
+ {
+ int pos = pick(o, _pos);
+
+ int last = -1;
+ for (int i = 0; i < item_list.size(); ++i) {
+ const QDockAreaLayoutItem &item = item_list.at(i);
+ if (item.skip())
+ continue;
+
+ last = i;
+
+ if (item.pos + item.size < pos)
+ continue;
+
+ if (item.subinfo != 0
+#ifndef QT_NO_TABBAR
+ && !item.subinfo->tabbed
+#endif
+ ) {
+ result = item.subinfo->gapIndex(_pos, nestingEnabled,
+ tabMode);
+ result.prepend(i);
+ return result;
+ }
+
+ item_rect = itemRect(i);
+ item_index = i;
+ break;
+ }
+
+ if (item_rect.isNull()) {
+ result.append(last + 1);
+ return result;
+ }
+ }
+
+ Q_ASSERT(!item_rect.isNull());
+
+ QInternal::DockPosition dock_pos
+ = dockPosHelper(item_rect, _pos, o, nestingEnabled, tabMode);
+
+ switch (dock_pos) {
+ case QInternal::LeftDock:
+ if (o == Qt::Horizontal)
+ result << item_index;
+ else
+ result << item_index << 0; // this subinfo doesn't exist yet, but insertGap()
+ // handles this by inserting it
+ break;
+ case QInternal::RightDock:
+ if (o == Qt::Horizontal)
+ result << item_index + 1;
+ else
+ result << item_index << 1;
+ break;
+ case QInternal::TopDock:
+ if (o == Qt::Horizontal)
+ result << item_index << 0;
+ else
+ result << item_index;
+ break;
+ case QInternal::BottomDock:
+ if (o == Qt::Horizontal)
+ result << item_index << 1;
+ else
+ result << item_index + 1;
+ break;
+ case QInternal::DockCount:
+ result << (-item_index - 1) << 0; // negative item_index means "on top of"
+ // -item_index - 1, insertGap()
+ // will insert a tabbed subinfo
+ break;
+ default:
+ break;
+ }
+
+ return result;
+}
+
+static inline int shrink(QLayoutStruct &ls, int delta)
+{
+ if (ls.empty)
+ return 0;
+ int old_size = ls.size;
+ ls.size = qMax(ls.size - delta, ls.minimumSize);
+ return old_size - ls.size;
+}
+
+static inline int grow(QLayoutStruct &ls, int delta)
+{
+ if (ls.empty)
+ return 0;
+ int old_size = ls.size;
+ ls.size = qMin(ls.size + delta, ls.maximumSize);
+ return ls.size - old_size;
+}
+
+static int separatorMoveHelper(QVector<QLayoutStruct> &list, int index, int delta, int sep)
+{
+ // adjust sizes
+ int pos = -1;
+ for (int i = 0; i < list.size(); ++i) {
+ const QLayoutStruct &ls = list.at(i);
+ if (!ls.empty) {
+ pos = ls.pos;
+ break;
+ }
+ }
+ if (pos == -1)
+ return 0;
+
+ if (delta > 0) {
+ int growlimit = 0;
+ for (int i = 0; i<=index; ++i) {
+ const QLayoutStruct &ls = list.at(i);
+ if (ls.empty)
+ continue;
+ if (ls.maximumSize == QLAYOUTSIZE_MAX) {
+ growlimit = QLAYOUTSIZE_MAX;
+ break;
+ }
+ growlimit += ls.maximumSize - ls.size;
+ }
+ if (delta > growlimit)
+ delta = growlimit;
+
+ int d = 0;
+ for (int i = index + 1; d < delta && i < list.count(); ++i)
+ d += shrink(list[i], delta - d);
+ delta = d;
+ d = 0;
+ for (int i = index; d < delta && i >= 0; --i)
+ d += grow(list[i], delta - d);
+ } else if (delta < 0) {
+ int growlimit = 0;
+ for (int i = index + 1; i < list.count(); ++i) {
+ const QLayoutStruct &ls = list.at(i);
+ if (ls.empty)
+ continue;
+ if (ls.maximumSize == QLAYOUTSIZE_MAX) {
+ growlimit = QLAYOUTSIZE_MAX;
+ break;
+ }
+ growlimit += ls.maximumSize - ls.size;
+ }
+ if (-delta > growlimit)
+ delta = -growlimit;
+
+ int d = 0;
+ for (int i = index; d < -delta && i >= 0; --i)
+ d += shrink(list[i], -delta - d);
+ delta = -d;
+ d = 0;
+ for (int i = index + 1; d < -delta && i < list.count(); ++i)
+ d += grow(list[i], -delta - d);
+ }
+
+ // adjust positions
+ bool first = true;
+ for (int i = 0; i < list.size(); ++i) {
+ QLayoutStruct &ls = list[i];
+ if (ls.empty) {
+ ls.pos = pos + (first ? 0 : sep);
+ continue;
+ }
+ if (!first)
+ pos += sep;
+ ls.pos = pos;
+ pos += ls.size;
+ first = false;
+ }
+
+ return delta;
+}
+
+int QDockAreaLayoutInfo::separatorMove(int index, int delta)
+{
+#ifndef QT_NO_TABBAR
+ Q_ASSERT(!tabbed);
+#endif
+
+ QVector<QLayoutStruct> list(item_list.size());
+ for (int i = 0; i < list.size(); ++i) {
+ const QDockAreaLayoutItem &item = item_list.at(i);
+ QLayoutStruct &ls = list[i];
+ Q_ASSERT(!(item.flags & QDockAreaLayoutItem::GapItem));
+ if (item.skip()) {
+ ls.empty = true;
+ } else {
+ const int separatorSpace = item.hasFixedSize(o) ? 0 : *sep;
+ ls.empty = false;
+ ls.pos = item.pos;
+ ls.size = item.size + separatorSpace;
+ ls.minimumSize = pick(o, item.minimumSize()) + separatorSpace;
+ ls.maximumSize = pick(o, item.maximumSize()) + separatorSpace;
+
+ }
+ }
+
+ //the separator space has been added to the size, so we pass 0 as a parameter
+ delta = separatorMoveHelper(list, index, delta, 0 /*separator*/);
+
+ for (int i = 0; i < list.size(); ++i) {
+ QDockAreaLayoutItem &item = item_list[i];
+ if (item.skip())
+ continue;
+ QLayoutStruct &ls = list[i];
+ const int separatorSpace = item.hasFixedSize(o) ? 0 : *sep;
+ item.size = ls.size - separatorSpace;
+ item.pos = ls.pos;
+ if (item.subinfo != 0) {
+ item.subinfo->rect = itemRect(i);
+ item.subinfo->fitItems();
+ }
+ }
+
+ return delta;
+}
+
+void QDockAreaLayoutInfo::unnest(int index)
+{
+ QDockAreaLayoutItem &item = item_list[index];
+ if (item.subinfo == 0)
+ return;
+ if (item.subinfo->item_list.count() > 1)
+ return;
+
+ if (item.subinfo->item_list.count() == 0) {
+ item_list.removeAt(index);
+ } else if (item.subinfo->item_list.count() == 1) {
+ QDockAreaLayoutItem &child = item.subinfo->item_list.first();
+ if (child.widgetItem != 0) {
+ item.widgetItem = child.widgetItem;
+ delete item.subinfo;
+ item.subinfo = 0;
+ } else if (child.subinfo != 0) {
+ QDockAreaLayoutInfo *tmp = item.subinfo;
+ item.subinfo = child.subinfo;
+ child.subinfo = 0;
+ tmp->item_list.clear();
+ delete tmp;
+ }
+ }
+}
+
+void QDockAreaLayoutInfo::remove(const QList<int> &path)
+{
+ Q_ASSERT(!path.isEmpty());
+
+ if (path.count() > 1) {
+ const int index = path.first();
+ QDockAreaLayoutItem &item = item_list[index];
+ Q_ASSERT(item.subinfo != 0);
+ item.subinfo->remove(path.mid(1));
+ unnest(index);
+ } else {
+ int index = path.first();
+ item_list.removeAt(index);
+ }
+}
+
+QLayoutItem *QDockAreaLayoutInfo::plug(const QList<int> &path)
+{
+ Q_ASSERT(!path.isEmpty());
+
+ int index = path.first();
+ if (index < 0)
+ index = -index - 1;
+
+ if (path.count() > 1) {
+ const QDockAreaLayoutItem &item = item_list.at(index);
+ Q_ASSERT(item.subinfo != 0);
+ return item.subinfo->plug(path.mid(1));
+ }
+
+ QDockAreaLayoutItem &item = item_list[index];
+
+ Q_ASSERT(item.widgetItem != 0);
+ Q_ASSERT(item.flags & QDockAreaLayoutItem::GapItem);
+ item.flags &= ~QDockAreaLayoutItem::GapItem;
+
+ QRect result;
+
+#ifndef QT_NO_TABBAR
+ if (tabbed) {
+ } else
+#endif
+ {
+ int prev = this->prev(index);
+ int next = this->next(index);
+
+ if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) {
+ item.pos += *sep;
+ item.size -= *sep;
+ }
+ if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
+ item.size -= *sep;
+
+ QPoint pos;
+ rpick(o, pos) = item.pos;
+ rperp(o, pos) = perp(o, rect.topLeft());
+ QSize s;
+ rpick(o, s) = item.size;
+ rperp(o, s) = perp(o, rect.size());
+ result = QRect(pos, s);
+ }
+
+ return item.widgetItem;
+}
+
+QLayoutItem *QDockAreaLayoutInfo::unplug(const QList<int> &path)
+{
+ Q_ASSERT(!path.isEmpty());
+
+ const int index = path.first();
+ if (path.count() > 1) {
+ const QDockAreaLayoutItem &item = item_list.at(index);
+ Q_ASSERT(item.subinfo != 0);
+ return item.subinfo->unplug(path.mid(1));
+ }
+
+ QDockAreaLayoutItem &item = item_list[index];
+ int prev = this->prev(index);
+ int next = this->next(index);
+
+ Q_ASSERT(!(item.flags & QDockAreaLayoutItem::GapItem));
+ item.flags |= QDockAreaLayoutItem::GapItem;
+
+#ifndef QT_NO_TABBAR
+ if (tabbed) {
+ } else
+#endif
+ {
+ if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) {
+ item.pos -= *sep;
+ item.size += *sep;
+ }
+ if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
+ item.size += *sep;
+ }
+
+ return item.widgetItem;
+}
+
+#ifndef QT_NO_TABBAR
+
+quintptr QDockAreaLayoutInfo::currentTabId() const
+{
+ if (!tabbed || tabBar == 0)
+ return 0;
+
+ int index = tabBar->currentIndex();
+ if (index == -1)
+ return 0;
+
+ return qvariant_cast<quintptr>(tabBar->tabData(index));
+}
+
+void QDockAreaLayoutInfo::setCurrentTab(QWidget *widget)
+{
+ setCurrentTabId(reinterpret_cast<quintptr>(widget));
+}
+
+void QDockAreaLayoutInfo::setCurrentTabId(quintptr id)
+{
+ if (!tabbed || tabBar == 0)
+ return;
+
+ for (int i = 0; i < tabBar->count(); ++i) {
+ if (qvariant_cast<quintptr>(tabBar->tabData(i)) == id) {
+ tabBar->setCurrentIndex(i);
+ return;
+ }
+ }
+}
+
+#endif // QT_NO_TABBAR
+
+static QRect dockedGeometry(QWidget *widget)
+{
+ int titleHeight = 0;
+
+ QDockWidgetLayout *layout
+ = qobject_cast<QDockWidgetLayout*>(widget->layout());
+ if(layout != 0 && layout->nativeWindowDeco())
+ titleHeight = layout->titleHeight();
+
+ QRect result = widget->geometry();
+ result.adjust(0, -titleHeight, 0, 0);
+ return result;
+}
+
+bool QDockAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *dockWidgetItem)
+{
+ Q_ASSERT(!path.isEmpty());
+
+ bool insert_tabbed = false;
+ int index = path.first();
+ if (index < 0) {
+ insert_tabbed = true;
+ index = -index - 1;
+ }
+
+// dump(qDebug() << "insertGap() before:" << index << tabIndex, *this, QString());
+
+ if (path.count() > 1) {
+ QDockAreaLayoutItem &item = item_list[index];
+
+ if (item.subinfo == 0
+#ifndef QT_NO_TABBAR
+ || (item.subinfo->tabbed && !insert_tabbed)
+#endif
+ ) {
+
+ // this is not yet a nested layout - make it
+
+ QDockAreaLayoutInfo *subinfo = item.subinfo;
+ QLayoutItem *widgetItem = item.widgetItem;
+ QPlaceHolderItem *placeHolderItem = item.placeHolderItem;
+ QRect r = subinfo == 0 ? widgetItem ? dockedGeometry(widgetItem->widget()) : placeHolderItem->topLevelRect : subinfo->rect;
+
+ Qt::Orientation opposite = o == Qt::Horizontal ? Qt::Vertical : Qt::Horizontal;
+#ifdef QT_NO_TABBAR
+ const int tabBarShape = 0;
+#endif
+ QDockAreaLayoutInfo *new_info
+ = new QDockAreaLayoutInfo(sep, dockPos, opposite, tabBarShape, mainWindow);
+
+ //item become a new top-level
+ item.subinfo = new_info;
+ item.widgetItem = 0;
+ item.placeHolderItem = 0;
+
+ QDockAreaLayoutItem new_item
+ = widgetItem == 0
+ ? QDockAreaLayoutItem(subinfo)
+ : widgetItem ? QDockAreaLayoutItem(widgetItem) : QDockAreaLayoutItem(placeHolderItem);
+ new_item.size = pick(opposite, r.size());
+ new_item.pos = pick(opposite, r.topLeft());
+ new_info->item_list.append(new_item);
+#ifndef QT_NO_TABBAR
+ if (insert_tabbed) {
+ new_info->tabbed = true;
+ }
+#endif
+ }
+
+ return item.subinfo->insertGap(path.mid(1), dockWidgetItem);
+ }
+
+ // create the gap item
+ QDockAreaLayoutItem gap_item;
+ gap_item.flags |= QDockAreaLayoutItem::GapItem;
+ gap_item.widgetItem = dockWidgetItem; // so minimumSize(), maximumSize() and
+ // sizeHint() will work
+#ifndef QT_NO_TABBAR
+ if (!tabbed)
+#endif
+ {
+ int prev = this->prev(index);
+ int next = this->next(index - 1);
+ // find out how much space we have in the layout
+ int space = 0;
+ if (isEmpty()) {
+ // I am an empty dock area, therefore I am a top-level dock area.
+ switch (dockPos) {
+ case QInternal::LeftDock:
+ case QInternal::RightDock:
+ if (o == Qt::Vertical) {
+ // the "size" is the height of the dock area (remember we are empty)
+ space = pick(Qt::Vertical, rect.size());
+ } else {
+ space = pick(Qt::Horizontal, dockWidgetItem->widget()->size());
+ }
+ break;
+ case QInternal::TopDock:
+ case QInternal::BottomDock:
+ default:
+ if (o == Qt::Horizontal) {
+ // the "size" is width of the dock area
+ space = pick(Qt::Horizontal, rect.size());
+ } else {
+ space = pick(Qt::Vertical, dockWidgetItem->widget()->size());
+ }
+ break;
+ }
+ } else {
+ for (int i = 0; i < item_list.count(); ++i) {
+ const QDockAreaLayoutItem &item = item_list.at(i);
+ if (item.skip())
+ continue;
+ Q_ASSERT(!(item.flags & QDockAreaLayoutItem::GapItem));
+ space += item.size - pick(o, item.minimumSize());
+ }
+ }
+
+ // find the actual size of the gap
+ int gap_size = 0;
+ int sep_size = 0;
+ if (isEmpty()) {
+ gap_size = space;
+ sep_size = 0;
+ } else {
+ QRect r = dockedGeometry(dockWidgetItem->widget());
+ gap_size = pick(o, r.size());
+ if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem))
+ sep_size += *sep;
+ if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
+ sep_size += *sep;
+ }
+ if (gap_size + sep_size > space)
+ gap_size = pick(o, gap_item.minimumSize());
+ gap_item.size = gap_size + sep_size;
+ }
+
+ // finally, insert the gap
+ item_list.insert(index, gap_item);
+
+// dump(qDebug() << "insertGap() after:" << index << tabIndex, *this, QString());
+
+ return true;
+}
+
+QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(QWidget *widget)
+{
+ for (int i = 0; i < item_list.count(); ++i) {
+ const QDockAreaLayoutItem &item = item_list.at(i);
+ if (item.skip())
+ continue;
+
+#ifndef QT_NO_TABBAR
+ if (tabbed && widget == tabBar)
+ return this;
+#endif
+
+ if (item.widgetItem != 0 && item.widgetItem->widget() == widget)
+ return this;
+
+ if (item.subinfo != 0) {
+ if (QDockAreaLayoutInfo *result = item.subinfo->info(widget))
+ return result;
+ }
+ }
+
+ return 0;
+}
+
+QDockAreaLayoutInfo *QDockAreaLayoutInfo::info(const QList<int> &path)
+{
+ int index = path.first();
+ if (index < 0)
+ index = -index - 1;
+ if (index >= item_list.count())
+ return this;
+ if (path.count() == 1 || item_list[index].subinfo == 0)
+ return this;
+ return item_list[index].subinfo->info(path.mid(1));
+}
+
+QRect QDockAreaLayoutInfo::itemRect(int index) const
+{
+ const QDockAreaLayoutItem &item = item_list.at(index);
+
+ if (item.skip())
+ return QRect();
+
+ QRect result;
+
+#ifndef QT_NO_TABBAR
+ if (tabbed) {
+ if (tabId(item) == currentTabId())
+ result = tabContentRect();
+ } else
+#endif
+ {
+ QPoint pos;
+ rpick(o, pos) = item.pos;
+ rperp(o, pos) = perp(o, rect.topLeft());
+ QSize s;
+ rpick(o, s) = item.size;
+ rperp(o, s) = perp(o, rect.size());
+ result = QRect(pos, s);
+ }
+
+ return result;
+}
+
+QRect QDockAreaLayoutInfo::itemRect(const QList<int> &path) const
+{
+ Q_ASSERT(!path.isEmpty());
+
+ const int index = path.first();
+ if (path.count() > 1) {
+ const QDockAreaLayoutItem &item = item_list.at(index);
+ Q_ASSERT(item.subinfo != 0);
+ return item.subinfo->itemRect(path.mid(1));
+ }
+
+ return itemRect(index);
+}
+
+QRect QDockAreaLayoutInfo::separatorRect(int index) const
+{
+#ifndef QT_NO_TABBAR
+ if (tabbed)
+ return QRect();
+#endif
+
+ const QDockAreaLayoutItem &item = item_list.at(index);
+ if (item.skip())
+ return QRect();
+
+ QPoint pos = rect.topLeft();
+ rpick(o, pos) = item.pos + item.size;
+ QSize s = rect.size();
+ rpick(o, s) = *sep;
+
+ return QRect(pos, s);
+}
+
+QRect QDockAreaLayoutInfo::separatorRect(const QList<int> &path) const
+{
+ Q_ASSERT(!path.isEmpty());
+
+ const int index = path.first();
+ if (path.count() > 1) {
+ const QDockAreaLayoutItem &item = item_list.at(index);
+ Q_ASSERT(item.subinfo != 0);
+ return item.subinfo->separatorRect(path.mid(1));
+ }
+ return separatorRect(index);
+}
+
+QList<int> QDockAreaLayoutInfo::findSeparator(const QPoint &_pos) const
+{
+#ifndef QT_NO_TABBAR
+ if (tabbed)
+ return QList<int>();
+#endif
+
+ int pos = pick(o, _pos);
+
+ for (int i = 0; i < item_list.size(); ++i) {
+ const QDockAreaLayoutItem &item = item_list.at(i);
+ if (item.skip() || (item.flags & QDockAreaLayoutItem::GapItem))
+ continue;
+
+ if (item.pos + item.size > pos) {
+ if (item.subinfo != 0) {
+ QList<int> result = item.subinfo->findSeparator(_pos);
+ if (!result.isEmpty()) {
+ result.prepend(i);
+ return result;
+ } else {
+ return QList<int>();
+ }
+ }
+ }
+
+ int next = this->next(i);
+ if (next == -1 || (item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
+ continue;
+
+ QRect sepRect = separatorRect(i);
+ if (!sepRect.isNull() && *sep == 1)
+ sepRect.adjust(-2, -2, 2, 2);
+ //we also make sure we don't find a separator that's not there
+ if (sepRect.contains(_pos) && !item.hasFixedSize(o)) {
+ return QList<int>() << i;
+ }
+
+ }
+
+ return QList<int>();
+}
+
+QList<int> QDockAreaLayoutInfo::indexOfPlaceHolder(const QString &objectName) const
+{
+ for (int i = 0; i < item_list.size(); ++i) {
+ const QDockAreaLayoutItem &item = item_list.at(i);
+
+ if (item.subinfo != 0) {
+ QList<int> result = item.subinfo->indexOfPlaceHolder(objectName);
+ if (!result.isEmpty()) {
+ result.prepend(i);
+ return result;
+ }
+ continue;
+ }
+
+ if (item.placeHolderItem != 0 && item.placeHolderItem->objectName == objectName) {
+ QList<int> result;
+ result << i;
+ return result;
+ }
+ }
+
+ return QList<int>();
+}
+
+QList<int> QDockAreaLayoutInfo::indexOf(QWidget *widget) const
+{
+ for (int i = 0; i < item_list.size(); ++i) {
+ const QDockAreaLayoutItem &item = item_list.at(i);
+
+ if (item.placeHolderItem != 0)
+ continue;
+
+ if (item.subinfo != 0) {
+ QList<int> result = item.subinfo->indexOf(widget);
+ if (!result.isEmpty()) {
+ result.prepend(i);
+ return result;
+ }
+ continue;
+ }
+
+ if (!(item.flags & QDockAreaLayoutItem::GapItem) && item.widgetItem->widget() == widget) {
+ QList<int> result;
+ result << i;
+ return result;
+ }
+ }
+
+ return QList<int>();
+}
+
+QMainWindowLayout *QDockAreaLayoutInfo::mainWindowLayout() const
+{
+ QMainWindowLayout *result = qt_mainwindow_layout(mainWindow);
+ Q_ASSERT(result != 0);
+ return result;
+}
+
+bool QDockAreaLayoutInfo::hasFixedSize() const
+{
+ return perp(o, minimumSize()) == perp(o, maximumSize());
+}
+
+
+void QDockAreaLayoutInfo::apply(bool animate)
+{
+ QWidgetAnimator &widgetAnimator = mainWindowLayout()->widgetAnimator;
+
+#ifndef QT_NO_TABBAR
+ if (tabbed) {
+ QRect tab_rect;
+ QSize tbh = tabBarSizeHint();
+
+ if (!tbh.isNull()) {
+ switch (tabBarShape) {
+ case QTabBar::RoundedNorth:
+ case QTabBar::TriangularNorth:
+ tab_rect = QRect(rect.left(), rect.top(), rect.width(), tbh.height());
+ break;
+ case QTabBar::RoundedSouth:
+ case QTabBar::TriangularSouth:
+ tab_rect = QRect(rect.left(), rect.bottom() - tbh.height() + 1,
+ rect.width(), tbh.height());
+ break;
+ case QTabBar::RoundedEast:
+ case QTabBar::TriangularEast:
+ tab_rect = QRect(rect.right() - tbh.width() + 1, rect.top(),
+ tbh.width(), rect.height());
+ break;
+ case QTabBar::RoundedWest:
+ case QTabBar::TriangularWest:
+ tab_rect = QRect(rect.left(), rect.top(),
+ tbh.width(), rect.height());
+ break;
+ default:
+ break;
+ }
+ }
+
+ widgetAnimator.animate(tabBar, tab_rect, animate);
+ }
+#endif // QT_NO_TABBAR
+
+ for (int i = 0; i < item_list.size(); ++i) {
+ QDockAreaLayoutItem &item = item_list[i];
+
+ if (item.flags & QDockAreaLayoutItem::GapItem)
+ continue;
+
+ if (item.subinfo != 0) {
+ item.subinfo->apply(animate);
+ continue;
+ }
+
+ if (item.skip())
+ continue;
+
+ Q_ASSERT(item.widgetItem);
+ QRect r = itemRect(i);
+ QWidget *w = item.widgetItem->widget();
+
+ QRect geo = w->geometry();
+ widgetAnimator.animate(w, r, animate);
+ if (!w->isHidden() && w->window()->isVisible()) {
+ QDockWidget *dw = qobject_cast<QDockWidget*>(w);
+ if (!r.isValid() && geo.right() >= 0 && geo.bottom() >= 0) {
+ dw->lower();
+ emit dw->visibilityChanged(false);
+ } else if (r.isValid()
+ && (geo.right() < 0 || geo.bottom() < 0)) {
+ emit dw->visibilityChanged(true);
+ }
+ }
+ }
+#ifndef QT_NO_TABBAR
+ if (*sep == 1)
+ updateSeparatorWidgets();
+#endif //QT_NO_TABBAR
+}
+
+static void paintSep(QPainter *p, QWidget *w, const QRect &r, Qt::Orientation o, bool mouse_over)
+{
+ QStyleOption opt(0);
+ opt.state = QStyle::State_None;
+ if (w->isEnabled())
+ opt.state |= QStyle::State_Enabled;
+ if (o != Qt::Horizontal)
+ opt.state |= QStyle::State_Horizontal;
+ if (mouse_over)
+ opt.state |= QStyle::State_MouseOver;
+ opt.rect = r;
+ opt.palette = w->palette();
+
+ w->style()->drawPrimitive(QStyle::PE_IndicatorDockWidgetResizeHandle, &opt, p, w);
+}
+
+QRegion QDockAreaLayoutInfo::separatorRegion() const
+{
+ QRegion result;
+
+ if (isEmpty())
+ return result;
+#ifndef QT_NO_TABBAR
+ if (tabbed)
+ return result;
+#endif
+
+ for (int i = 0; i < item_list.count(); ++i) {
+ const QDockAreaLayoutItem &item = item_list.at(i);
+
+ if (item.skip())
+ continue;
+
+ int next = this->next(i);
+
+ if (item.subinfo)
+ result |= item.subinfo->separatorRegion();
+
+ if (next == -1)
+ break;
+ result |= separatorRect(i);
+ }
+
+ return result;
+}
+
+void QDockAreaLayoutInfo::paintSeparators(QPainter *p, QWidget *widget,
+ const QRegion &clip,
+ const QPoint &mouse) const
+{
+ if (isEmpty())
+ return;
+#ifndef QT_NO_TABBAR
+ if (tabbed)
+ return;
+#endif
+
+ for (int i = 0; i < item_list.count(); ++i) {
+ const QDockAreaLayoutItem &item = item_list.at(i);
+
+ if (item.skip())
+ continue;
+
+ int next = this->next(i);
+ if ((item.flags & QDockAreaLayoutItem::GapItem)
+ || (next != -1 && (item_list.at(next).flags & QDockAreaLayoutItem::GapItem)))
+ continue;
+
+ if (item.subinfo) {
+ if (clip.contains(item.subinfo->rect))
+ item.subinfo->paintSeparators(p, widget, clip, mouse);
+ }
+
+ if (next == -1)
+ break;
+ QRect r = separatorRect(i);
+ if (clip.contains(r) && !item.hasFixedSize(o))
+ paintSep(p, widget, r, o, r.contains(mouse));
+ }
+}
+
+int QDockAreaLayoutInfo::next(int index) const
+{
+ for (int i = index + 1; i < item_list.size(); ++i) {
+ if (!item_list.at(i).skip())
+ return i;
+ }
+ return -1;
+}
+
+int QDockAreaLayoutInfo::prev(int index) const
+{
+ for (int i = index - 1; i >= 0; --i) {
+ if (!item_list.at(i).skip())
+ return i;
+ }
+ return -1;
+}
+
+void QDockAreaLayoutInfo::tab(int index, QLayoutItem *dockWidgetItem)
+{
+#ifdef QT_NO_TABBAR
+ Q_UNUSED(index);
+ Q_UNUSED(dockWidgetItem);
+#else
+ if (tabbed) {
+ item_list.append(QDockAreaLayoutItem(dockWidgetItem));
+ updateTabBar();
+ setCurrentTab(dockWidgetItem->widget());
+ } else {
+ QDockAreaLayoutInfo *new_info
+ = new QDockAreaLayoutInfo(sep, dockPos, o, tabBarShape, mainWindow);
+ item_list[index].subinfo = new_info;
+ new_info->item_list.append(item_list.at(index).widgetItem);
+ item_list[index].widgetItem = 0;
+ new_info->item_list.append(dockWidgetItem);
+ new_info->tabbed = true;
+ new_info->updateTabBar();
+ new_info->setCurrentTab(dockWidgetItem->widget());
+ }
+#endif // QT_NO_TABBAR
+}
+
+void QDockAreaLayoutInfo::split(int index, Qt::Orientation orientation,
+ QLayoutItem *dockWidgetItem)
+{
+ if (orientation == o) {
+ item_list.insert(index + 1, QDockAreaLayoutItem(dockWidgetItem));
+ } else {
+#ifdef QT_NO_TABBAR
+ const int tabBarShape = 0;
+#endif
+ QDockAreaLayoutInfo *new_info
+ = new QDockAreaLayoutInfo(sep, dockPos, orientation, tabBarShape, mainWindow);
+ item_list[index].subinfo = new_info;
+ new_info->item_list.append(item_list.at(index).widgetItem);
+ item_list[index].widgetItem = 0;
+ new_info->item_list.append(dockWidgetItem);
+ }
+}
+
+QDockAreaLayoutItem &QDockAreaLayoutInfo::item(const QList<int> &path)
+{
+ Q_ASSERT(!path.isEmpty());
+ const int index = path.first();
+ if (path.count() > 1) {
+ const QDockAreaLayoutItem &item = item_list[index];
+ Q_ASSERT(item.subinfo != 0);
+ return item.subinfo->item(path.mid(1));
+ }
+ return item_list[index];
+}
+
+QLayoutItem *QDockAreaLayoutInfo::itemAt(int *x, int index) const
+{
+ for (int i = 0; i < item_list.count(); ++i) {
+ const QDockAreaLayoutItem &item = item_list.at(i);
+ if (item.placeHolderItem != 0)
+ continue;
+ if (item.subinfo) {
+ if (QLayoutItem *ret = item.subinfo->itemAt(x, index))
+ return ret;
+ } else if (item.widgetItem) {
+ if ((*x)++ == index)
+ return item.widgetItem;
+ }
+ }
+ return 0;
+}
+
+QLayoutItem *QDockAreaLayoutInfo::takeAt(int *x, int index)
+{
+ for (int i = 0; i < item_list.count(); ++i) {
+ QDockAreaLayoutItem &item = item_list[i];
+ if (item.placeHolderItem != 0)
+ continue;
+ else if (item.subinfo) {
+ if (QLayoutItem *ret = item.subinfo->takeAt(x, index)) {
+ unnest(i);
+ return ret;
+ }
+ } else if (item.widgetItem) {
+ if ((*x)++ == index) {
+ item.placeHolderItem = new QPlaceHolderItem(item.widgetItem->widget());
+ QLayoutItem *ret = item.widgetItem;
+ item.widgetItem = 0;
+ if (item.size != -1)
+ item.flags |= QDockAreaLayoutItem::KeepSize;
+ return ret;
+ }
+ }
+ }
+ return 0;
+}
+
+void QDockAreaLayoutInfo::deleteAllLayoutItems()
+{
+ for (int i = 0; i < item_list.count(); ++i) {
+ QDockAreaLayoutItem &item= item_list[i];
+ if (item.subinfo) {
+ item.subinfo->deleteAllLayoutItems();
+ } else {
+ delete item.widgetItem;
+ item.widgetItem = 0;
+ }
+ }
+}
+
+void QDockAreaLayoutInfo::saveState(QDataStream &stream) const
+{
+#ifndef QT_NO_TABBAR
+ if (tabbed) {
+ stream << (uchar) TabMarker;
+
+ // write the index in item_list of the widget that's currently on top.
+ quintptr id = currentTabId();
+ int index = -1;
+ for (int i = 0; i < item_list.count(); ++i) {
+ if (tabId(item_list.at(i)) == id) {
+ index = i;
+ break;
+ }
+ }
+ stream << index;
+ } else
+#endif // QT_NO_TABBAR
+ {
+ stream << (uchar) SequenceMarker;
+ }
+
+ stream << (uchar) o << item_list.count();
+
+ for (int i = 0; i < item_list.count(); ++i) {
+ const QDockAreaLayoutItem &item = item_list.at(i);
+ if (item.widgetItem != 0) {
+ stream << (uchar) WidgetMarker;
+ QWidget *w = item.widgetItem->widget();
+ QString name = w->objectName();
+ if (name.isEmpty()) {
+ qWarning("QMainWindow::saveState(): 'objectName' not set for QDockWidget %p '%s;",
+ w, qPrintable(w->windowTitle()));
+ }
+ stream << name;
+
+ uchar flags = 0;
+ if (!w->isHidden())
+ flags |= StateFlagVisible;
+ if (w->isWindow())
+ flags |= StateFlagFloating;
+ stream << flags;
+
+ if (w->isWindow()) {
+ stream << w->x() << w->y() << w->width() << w->height();
+ } else {
+ stream << item.pos << item.size << pick(o, item.minimumSize())
+ << pick(o, item.maximumSize());
+ }
+ } else if (item.placeHolderItem != 0) {
+ stream << (uchar) WidgetMarker;
+ stream << item.placeHolderItem->objectName;
+ uchar flags = 0;
+ if (!item.placeHolderItem->hidden)
+ flags |= StateFlagVisible;
+ if (item.placeHolderItem->window)
+ flags |= StateFlagFloating;
+ stream << flags;
+ if (item.placeHolderItem->window) {
+ QRect r = item.placeHolderItem->topLevelRect;
+ stream << r.x() << r.y() << r.width() << r.height();
+ } else {
+ stream << item.pos << item.size << (int)0 << (int)0;
+ }
+ } else if (item.subinfo != 0) {
+ stream << (uchar) SequenceMarker << item.pos << item.size << pick(o, item.minimumSize()) << pick(o, item.maximumSize());
+ item.subinfo->saveState(stream);
+ }
+ }
+}
+
+static Qt::DockWidgetArea toDockWidgetArea(QInternal::DockPosition pos)
+{
+ switch (pos) {
+ case QInternal::LeftDock: return Qt::LeftDockWidgetArea;
+ case QInternal::RightDock: return Qt::RightDockWidgetArea;
+ case QInternal::TopDock: return Qt::TopDockWidgetArea;
+ case QInternal::BottomDock: return Qt::BottomDockWidgetArea;
+ default: break;
+ }
+ return Qt::NoDockWidgetArea;
+}
+
+static QRect constrainedRect(QRect rect, const QRect &desktop)
+{
+ if (desktop.isValid()) {
+ rect.setWidth(qMin(rect.width(), desktop.width()));
+ rect.setHeight(qMin(rect.height(), desktop.height()));
+ rect.moveLeft(qMax(rect.left(), desktop.left()));
+ rect.moveTop(qMax(rect.top(), desktop.top()));
+ rect.moveRight(qMin(rect.right(), desktop.right()));
+ rect.moveBottom(qMin(rect.bottom(), desktop.bottom()));
+ }
+
+ return rect;
+}
+
+bool QDockAreaLayoutInfo::restoreState(QDataStream &stream, QList<QDockWidget*> &widgets, bool testing)
+{
+ uchar marker;
+ stream >> marker;
+ if (marker != TabMarker && marker != SequenceMarker)
+ return false;
+
+#ifndef QT_NO_TABBAR
+ tabbed = marker == TabMarker;
+
+ int index = -1;
+ if (tabbed)
+ stream >> index;
+#endif
+
+ uchar orientation;
+ stream >> orientation;
+ o = static_cast<Qt::Orientation>(orientation);
+
+ int cnt;
+ stream >> cnt;
+
+ for (int i = 0; i < cnt; ++i) {
+ uchar nextMarker;
+ stream >> nextMarker;
+ if (nextMarker == WidgetMarker) {
+ QString name;
+ uchar flags;
+ stream >> name >> flags;
+ if (name.isEmpty()) {
+ int dummy;
+ stream >> dummy >> dummy >> dummy >> dummy;
+ continue;
+ }
+
+ QDockWidget *widget = 0;
+ for (int j = 0; j < widgets.count(); ++j) {
+ if (widgets.at(j)->objectName() == name) {
+ widget = widgets.takeAt(j);
+ break;
+ }
+ }
+
+ if (widget == 0) {
+ QPlaceHolderItem *placeHolder = new QPlaceHolderItem;
+ QDockAreaLayoutItem item(placeHolder);
+
+ placeHolder->objectName = name;
+ placeHolder->window = flags & StateFlagFloating;
+ placeHolder->hidden = !(flags & StateFlagVisible);
+ if (placeHolder->window) {
+ int x, y, w, h;
+ stream >> x >> y >> w >> h;
+ placeHolder->topLevelRect = QRect(x, y, w, h);
+ } else {
+ int dummy;
+ stream >> item.pos >> item.size >> dummy >> dummy;
+ }
+ if (item.size != -1)
+ item.flags |= QDockAreaLayoutItem::KeepSize;
+ if (!testing)
+ item_list.append(item);
+ } else {
+ QDockAreaLayoutItem item(new QDockWidgetItem(widget));
+ if (flags & StateFlagFloating) {
+ bool drawer = false;
+#ifdef Q_WS_MAC // drawer support
+ extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp
+ extern bool qt_mac_set_drawer_preferred_edge(QWidget *, Qt::DockWidgetArea); //qwidget_mac.cpp
+ drawer = qt_mac_is_macdrawer(widget);
+#endif
+
+ if (!testing) {
+ widget->hide();
+ if (!drawer)
+ widget->setFloating(true);
+ }
+
+ int x, y, w, h;
+ stream >> x >> y >> w >> h;
+
+#ifdef Q_WS_MAC // drawer support
+ if (drawer) {
+ mainWindow->window()->createWinId();
+ widget->window()->createWinId();
+ qt_mac_set_drawer_preferred_edge(widget, toDockWidgetArea(dockPos));
+ } else
+#endif
+ if (!testing) {
+ QRect r(x, y, w, h);
+ QDesktopWidget *desktop = QApplication::desktop();
+ if (desktop->isVirtualDesktop())
+ r = constrainedRect(r, desktop->screenGeometry(desktop->screenNumber(r.topLeft())));
+ else
+ r = constrainedRect(r, desktop->screenGeometry(widget));
+ widget->move(r.topLeft());
+ widget->resize(r.size());
+ }
+
+ if (!testing) {
+ widget->setVisible(flags & StateFlagVisible);
+ item_list.append(item);
+ }
+ } else {
+ int dummy;
+ stream >> item.pos >> item.size >> dummy >> dummy;
+ if (!testing) {
+ item_list.append(item);
+ widget->setFloating(false);
+ widget->setVisible(flags & StateFlagVisible);
+ emit widget->dockLocationChanged(toDockWidgetArea(dockPos));
+ }
+ }
+ if (testing) {
+ //was it is not really added to the layout, we need to delete the object here
+ delete item.widgetItem;
+ }
+ }
+ } else if (nextMarker == SequenceMarker) {
+ int dummy;
+#ifdef QT_NO_TABBAR
+ const int tabBarShape = 0;
+#endif
+ QDockAreaLayoutItem item(new QDockAreaLayoutInfo(sep, dockPos, o,
+ tabBarShape, mainWindow));
+ stream >> item.pos >> item.size >> dummy >> dummy;
+ //we need to make sure the element is in the list so the dock widget can eventually be docked correctly
+ if (!testing)
+ item_list.append(item);
+
+ //here we need to make sure we change the item in the item_list
+ QDockAreaLayoutItem &lastItem = testing ? item : item_list.last();
+
+ if (!lastItem.subinfo->restoreState(stream, widgets, testing))
+ return false;
+
+ } else {
+ return false;
+ }
+ }
+
+#ifndef QT_NO_TABBAR
+ if (!testing && tabbed && index >= 0 && index < item_list.count()) {
+ updateTabBar();
+ setCurrentTabId(tabId(item_list.at(index)));
+ }
+ if (!testing && *sep == 1)
+ updateSeparatorWidgets();
+#endif
+
+ return true;
+}
+
+#ifndef QT_NO_TABBAR
+void QDockAreaLayoutInfo::updateSeparatorWidgets() const
+{
+ if (tabbed) {
+ separatorWidgets.clear();
+ return;
+ }
+
+ int j = 0;
+ for (int i = 0; i < item_list.count(); ++i) {
+ const QDockAreaLayoutItem &item = item_list.at(i);
+
+ if (item.skip())
+ continue;
+
+ int next = this->next(i);
+ if ((item.flags & QDockAreaLayoutItem::GapItem)
+ || (next != -1 && (item_list.at(next).flags & QDockAreaLayoutItem::GapItem)))
+ continue;
+
+ if (item.subinfo) {
+ item.subinfo->updateSeparatorWidgets();
+ }
+
+ if (next == -1)
+ break;
+
+ QWidget *sepWidget;
+ if (j < separatorWidgets.size() && separatorWidgets.at(j)) {
+ sepWidget = separatorWidgets.at(j);
+ } else {
+ sepWidget = mainWindowLayout()->getSeparatorWidget();
+ separatorWidgets.append(sepWidget);
+ }
+ j++;
+
+#ifndef QT_MAC_USE_COCOA
+ sepWidget->raise();
+#endif
+ QRect sepRect = separatorRect(i).adjusted(-2, -2, 2, 2);
+ sepWidget->setGeometry(sepRect);
+ sepWidget->setMask( QRegion(separatorRect(i).translated( - sepRect.topLeft())));
+ sepWidget->show();
+ }
+
+ for (int k = j; k < separatorWidgets.size(); ++k) {
+ separatorWidgets[k]->hide();
+ }
+ separatorWidgets.resize(j);
+ Q_ASSERT(separatorWidgets.size() == j);
+}
+#endif //QT_NO_TABBAR
+
+#ifndef QT_NO_TABBAR
+//returns whether the tabbar is visible or not
+bool QDockAreaLayoutInfo::updateTabBar() const
+{
+ if (!tabbed)
+ return false;
+
+ QDockAreaLayoutInfo *that = const_cast<QDockAreaLayoutInfo*>(this);
+
+ if (that->tabBar == 0) {
+ that->tabBar = mainWindowLayout()->getTabBar();
+ that->tabBar->setShape(static_cast<QTabBar::Shape>(tabBarShape));
+ that->tabBar->setDrawBase(true);
+ }
+
+ bool blocked = tabBar->blockSignals(true);
+ bool gap = false;
+
+ int tab_idx = 0;
+ for (int i = 0; i < item_list.count(); ++i) {
+ const QDockAreaLayoutItem &item = item_list.at(i);
+ if (item.skip())
+ continue;
+ if (item.flags & QDockAreaLayoutItem::GapItem) {
+ gap = true;
+ continue;
+ }
+ if (item.widgetItem == 0)
+ continue;
+
+ QDockWidget *dw = qobject_cast<QDockWidget*>(item.widgetItem->widget());
+ QString title = dw->d_func()->fixedWindowTitle;
+ quintptr id = tabId(item);
+ if (tab_idx == tabBar->count()) {
+ tabBar->insertTab(tab_idx, title);
+#ifndef QT_NO_TOOLTIP
+ tabBar->setTabToolTip(tab_idx, title);
+#endif
+ tabBar->setTabData(tab_idx, id);
+ } else if (qvariant_cast<quintptr>(tabBar->tabData(tab_idx)) != id) {
+ if (tab_idx + 1 < tabBar->count()
+ && qvariant_cast<quintptr>(tabBar->tabData(tab_idx + 1)) == id)
+ tabBar->removeTab(tab_idx);
+ else {
+ tabBar->insertTab(tab_idx, title);
+#ifndef QT_NO_TOOLTIP
+ tabBar->setTabToolTip(tab_idx, title);
+#endif
+ tabBar->setTabData(tab_idx, id);
+ }
+ }
+
+ if (title != tabBar->tabText(tab_idx)) {
+ tabBar->setTabText(tab_idx, title);
+#ifndef QT_NO_TOOLTIP
+ tabBar->setTabToolTip(tab_idx, title);
+#endif
+ }
+
+ ++tab_idx;
+ }
+
+ while (tab_idx < tabBar->count()) {
+ tabBar->removeTab(tab_idx);
+ }
+
+ tabBar->blockSignals(blocked);
+
+ //returns if the tabbar is visible or not
+ return ( (gap ? 1 : 0) + tabBar->count()) > 1;
+}
+
+void QDockAreaLayoutInfo::setTabBarShape(int shape)
+{
+ if (shape == tabBarShape)
+ return;
+ tabBarShape = shape;
+ if (tabBar != 0)
+ tabBar->setShape(static_cast<QTabBar::Shape>(shape));
+
+ for (int i = 0; i < item_list.count(); ++i) {
+ QDockAreaLayoutItem &item = item_list[i];
+ if (item.subinfo != 0)
+ item.subinfo->setTabBarShape(shape);
+ }
+}
+
+QSize QDockAreaLayoutInfo::tabBarMinimumSize() const
+{
+ if (!updateTabBar())
+ return QSize(0, 0);
+
+ return tabBar->minimumSizeHint();
+}
+
+QSize QDockAreaLayoutInfo::tabBarSizeHint() const
+{
+ if (!updateTabBar())
+ return QSize(0, 0);
+
+ return tabBar->sizeHint();
+}
+
+QSet<QTabBar*> QDockAreaLayoutInfo::usedTabBars() const
+{
+ QSet<QTabBar*> result;
+
+ if (tabbed) {
+ updateTabBar();
+ result.insert(tabBar);
+ }
+
+ for (int i = 0; i < item_list.count(); ++i) {
+ const QDockAreaLayoutItem &item = item_list.at(i);
+ if (item.subinfo != 0)
+ result += item.subinfo->usedTabBars();
+ }
+
+ return result;
+}
+
+// returns a set of all used separator widgets for this dockarelayout info
+// and all subinfos
+QSet<QWidget*> QDockAreaLayoutInfo::usedSeparatorWidgets() const
+{
+ QSet<QWidget*> result;
+
+ for (int i = 0; i < separatorWidgets.count(); ++i)
+ result << separatorWidgets.at(i);
+
+ for (int i = 0; i < item_list.count(); ++i) {
+ const QDockAreaLayoutItem &item = item_list.at(i);
+ if (item.subinfo != 0)
+ result += item.subinfo->usedSeparatorWidgets();
+ }
+
+ return result;
+}
+
+QRect QDockAreaLayoutInfo::tabContentRect() const
+{
+ if (!tabbed)
+ return QRect();
+
+ QRect result = rect;
+ QSize tbh = tabBarSizeHint();
+
+ if (!tbh.isNull()) {
+ switch (tabBarShape) {
+ case QTabBar::RoundedNorth:
+ case QTabBar::TriangularNorth:
+ result.adjust(0, tbh.height(), 0, 0);
+ break;
+ case QTabBar::RoundedSouth:
+ case QTabBar::TriangularSouth:
+ result.adjust(0, 0, 0, -tbh.height());
+ break;
+ case QTabBar::RoundedEast:
+ case QTabBar::TriangularEast:
+ result.adjust(0, 0, -tbh.width(), 0);
+ break;
+ case QTabBar::RoundedWest:
+ case QTabBar::TriangularWest:
+ result.adjust(tbh.width(), 0, 0, 0);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return result;
+}
+#endif // QT_NO_TABBAR
+
+/******************************************************************************
+** QDockAreaLayout
+*/
+
+QDockAreaLayout::QDockAreaLayout(QMainWindow *win) : fallbackToSizeHints(true)
+{
+ mainWindow = win;
+ sep = win->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, win);
+#ifndef QT_NO_TABBAR
+ const int tabShape = QTabBar::RoundedSouth;
+#else
+ const int tabShape = 0;
+#endif
+ docks[QInternal::LeftDock]
+ = QDockAreaLayoutInfo(&sep, QInternal::LeftDock, Qt::Vertical, tabShape, win);
+ docks[QInternal::RightDock]
+ = QDockAreaLayoutInfo(&sep, QInternal::RightDock, Qt::Vertical, tabShape, win);
+ docks[QInternal::TopDock]
+ = QDockAreaLayoutInfo(&sep, QInternal::TopDock, Qt::Horizontal, tabShape, win);
+ docks[QInternal::BottomDock]
+ = QDockAreaLayoutInfo(&sep, QInternal::BottomDock, Qt::Horizontal, tabShape, win);
+ centralWidgetItem = 0;
+
+
+ corners[Qt::TopLeftCorner] = Qt::TopDockWidgetArea;
+ corners[Qt::TopRightCorner] = Qt::TopDockWidgetArea;
+ corners[Qt::BottomLeftCorner] = Qt::BottomDockWidgetArea;
+ corners[Qt::BottomRightCorner] = Qt::BottomDockWidgetArea;
+}
+
+bool QDockAreaLayout::isValid() const
+{
+ return rect.isValid();
+}
+
+void QDockAreaLayout::saveState(QDataStream &stream) const
+{
+ stream << (uchar) DockWidgetStateMarker;
+ int cnt = 0;
+ for (int i = 0; i < QInternal::DockCount; ++i) {
+ if (!docks[i].item_list.isEmpty())
+ ++cnt;
+ }
+ stream << cnt;
+ for (int i = 0; i < QInternal::DockCount; ++i) {
+ if (docks[i].item_list.isEmpty())
+ continue;
+ stream << i << docks[i].rect.size();
+ docks[i].saveState(stream);
+ }
+
+ stream << centralWidgetRect.size();
+
+ for (int i = 0; i < 4; ++i)
+ stream << static_cast<int>(corners[i]);
+}
+
+bool QDockAreaLayout::restoreState(QDataStream &stream, const QList<QDockWidget*> &_dockwidgets, bool testing)
+{
+ QList<QDockWidget*> dockwidgets = _dockwidgets;
+
+ int cnt;
+ stream >> cnt;
+ for (int i = 0; i < cnt; ++i) {
+ int pos;
+ stream >> pos;
+ QSize size;
+ stream >> size;
+ if (!testing) {
+ docks[pos].rect = QRect(QPoint(0, 0), size);
+ }
+ if (!docks[pos].restoreState(stream, dockwidgets, testing)) {
+ stream.setStatus(QDataStream::ReadCorruptData);
+ return false;
+ }
+ }
+
+ QSize size;
+ stream >> size;
+ centralWidgetRect = QRect(QPoint(0, 0), size);
+
+ bool ok = stream.status() == QDataStream::Ok;
+
+ if (ok) {
+ int cornerData[4];
+ for (int i = 0; i < 4; ++i)
+ stream >> cornerData[i];
+ if (stream.status() == QDataStream::Ok) {
+ for (int i = 0; i < 4; ++i)
+ corners[i] = static_cast<Qt::DockWidgetArea>(cornerData[i]);
+ }
+
+ if (!testing)
+ fallbackToSizeHints = false;
+ }
+
+ return ok;
+}
+
+QList<int> QDockAreaLayout::indexOfPlaceHolder(const QString &objectName) const
+{
+ for (int i = 0; i < QInternal::DockCount; ++i) {
+ QList<int> result = docks[i].indexOfPlaceHolder(objectName);
+ if (!result.isEmpty()) {
+ result.prepend(i);
+ return result;
+ }
+ }
+ return QList<int>();
+}
+
+QList<int> QDockAreaLayout::indexOf(QWidget *dockWidget) const
+{
+ for (int i = 0; i < QInternal::DockCount; ++i) {
+ QList<int> result = docks[i].indexOf(dockWidget);
+ if (!result.isEmpty()) {
+ result.prepend(i);
+ return result;
+ }
+ }
+ return QList<int>();
+}
+
+QList<int> QDockAreaLayout::gapIndex(const QPoint &pos) const
+{
+ QMainWindow::DockOptions opts = mainWindow->dockOptions();
+ bool nestingEnabled = opts & QMainWindow::AllowNestedDocks;
+ QDockAreaLayoutInfo::TabMode tabMode = QDockAreaLayoutInfo::NoTabs;
+#ifndef QT_NO_TABBAR
+ if (opts & QMainWindow::AllowTabbedDocks
+ || opts & QMainWindow::VerticalTabs)
+ tabMode = QDockAreaLayoutInfo::AllowTabs;
+ if (opts & QMainWindow::ForceTabbedDocks)
+ tabMode = QDockAreaLayoutInfo::ForceTabs;
+
+ if (tabMode == QDockAreaLayoutInfo::ForceTabs)
+ nestingEnabled = false;
+#endif
+
+
+ for (int i = 0; i < QInternal::DockCount; ++i) {
+ const QDockAreaLayoutInfo &info = docks[i];
+
+ if (!info.isEmpty() && info.rect.contains(pos)) {
+ QList<int> result
+ = docks[i].gapIndex(pos, nestingEnabled, tabMode);
+ if (!result.isEmpty())
+ result.prepend(i);
+ return result;
+ }
+ }
+
+ for (int i = 0; i < QInternal::DockCount; ++i) {
+ const QDockAreaLayoutInfo &info = docks[i];
+
+ if (info.isEmpty()) {
+ QRect r;
+ switch (i) {
+ case QInternal::LeftDock:
+ r = QRect(rect.left(), rect.top(), EmptyDropAreaSize, rect.height());
+ break;
+ case QInternal::RightDock:
+ r = QRect(rect.right() - EmptyDropAreaSize, rect.top(),
+ EmptyDropAreaSize, rect.height());
+ break;
+ case QInternal::TopDock:
+ r = QRect(rect.left(), rect.top(), rect.width(), EmptyDropAreaSize);
+ break;
+ case QInternal::BottomDock:
+ r = QRect(rect.left(), rect.bottom() - EmptyDropAreaSize,
+ rect.width(), EmptyDropAreaSize);
+ break;
+ }
+ if (r.contains(pos)) {
+ if (opts & QMainWindow::ForceTabbedDocks && !info.item_list.isEmpty()) {
+ //in case of ForceTabbedDocks, we pass -1 in order to force the gap to be tabbed
+ //it mustn't be completely empty otherwise it won't work
+ return QList<int>() << i << -1 << 0;
+ } else {
+ return QList<int>() << i << 0;
+ }
+ }
+ }
+ }
+
+ return QList<int>();
+}
+
+QList<int> QDockAreaLayout::findSeparator(const QPoint &pos) const
+{
+ QList<int> result;
+ for (int i = 0; i < QInternal::DockCount; ++i) {
+ const QDockAreaLayoutInfo &info = docks[i];
+ if (info.isEmpty())
+ continue;
+ QRect rect = separatorRect(i);
+ if (!rect.isNull() && sep == 1)
+ rect.adjust(-2, -2, 2, 2);
+ if (rect.contains(pos) && !info.hasFixedSize()) {
+ result << i;
+ break;
+ } else if (info.rect.contains(pos)) {
+ result = docks[i].findSeparator(pos);
+ if (!result.isEmpty()) {
+ result.prepend(i);
+ break;
+ }
+ }
+ }
+
+ return result;
+}
+
+QDockAreaLayoutInfo *QDockAreaLayout::info(QWidget *widget)
+{
+ for (int i = 0; i < QInternal::DockCount; ++i) {
+ if (QDockAreaLayoutInfo *result = docks[i].info(widget))
+ return result;
+ }
+
+ return 0;
+}
+
+QDockAreaLayoutInfo *QDockAreaLayout::info(const QList<int> &path)
+{
+ Q_ASSERT(!path.isEmpty());
+ const int index = path.first();
+ Q_ASSERT(index >= 0 && index < QInternal::DockCount);
+
+ if (path.count() == 1)
+ return &docks[index];
+
+ return docks[index].info(path.mid(1));
+}
+
+const QDockAreaLayoutInfo *QDockAreaLayout::info(const QList<int> &path) const
+{
+ return const_cast<QDockAreaLayout*>(this)->info(path);
+}
+
+QDockAreaLayoutItem &QDockAreaLayout::item(const QList<int> &path)
+{
+ Q_ASSERT(!path.isEmpty());
+ const int index = path.first();
+ Q_ASSERT(index >= 0 && index < QInternal::DockCount);
+ return docks[index].item(path.mid(1));
+}
+
+QRect QDockAreaLayout::itemRect(const QList<int> &path) const
+{
+ Q_ASSERT(!path.isEmpty());
+ const int index = path.first();
+ Q_ASSERT(index >= 0 && index < QInternal::DockCount);
+ return docks[index].itemRect(path.mid(1));
+}
+
+QRect QDockAreaLayout::separatorRect(int index) const
+{
+ const QDockAreaLayoutInfo &dock = docks[index];
+ if (dock.isEmpty())
+ return QRect();
+ QRect r = dock.rect;
+ switch (index) {
+ case QInternal::LeftDock:
+ return QRect(r.right() + 1, r.top(), sep, r.height());
+ case QInternal::RightDock:
+ return QRect(r.left() - sep, r.top(), sep, r.height());
+ case QInternal::TopDock:
+ return QRect(r.left(), r.bottom() + 1, r.width(), sep);
+ case QInternal::BottomDock:
+ return QRect(r.left(), r.top() - sep, r.width(), sep);
+ default:
+ break;
+ }
+ return QRect();
+}
+
+QRect QDockAreaLayout::separatorRect(const QList<int> &path) const
+{
+ Q_ASSERT(!path.isEmpty());
+
+ const int index = path.first();
+ Q_ASSERT(index >= 0 && index < QInternal::DockCount);
+
+ if (path.count() == 1)
+ return separatorRect(index);
+ else
+ return docks[index].separatorRect(path.mid(1));
+}
+
+bool QDockAreaLayout::insertGap(const QList<int> &path, QLayoutItem *dockWidgetItem)
+{
+ Q_ASSERT(!path.isEmpty());
+ const int index = path.first();
+ Q_ASSERT(index >= 0 && index < QInternal::DockCount);
+ return docks[index].insertGap(path.mid(1), dockWidgetItem);
+}
+
+QLayoutItem *QDockAreaLayout::plug(const QList<int> &path)
+{
+ Q_ASSERT(!path.isEmpty());
+ const int index = path.first();
+ Q_ASSERT(index >= 0 && index < QInternal::DockCount);
+ return docks[index].plug(path.mid(1));
+}
+
+QLayoutItem *QDockAreaLayout::unplug(const QList<int> &path)
+{
+ Q_ASSERT(!path.isEmpty());
+ const int index = path.first();
+ Q_ASSERT(index >= 0 && index < QInternal::DockCount);
+ return docks[index].unplug(path.mid(1));
+}
+
+void QDockAreaLayout::remove(const QList<int> &path)
+{
+ Q_ASSERT(!path.isEmpty());
+ const int index = path.first();
+ Q_ASSERT(index >= 0 && index < QInternal::DockCount);
+ docks[index].remove(path.mid(1));
+}
+
+static inline int qMin(int i1, int i2, int i3) { return qMin(i1, qMin(i2, i3)); }
+static inline int qMax(int i1, int i2, int i3) { return qMax(i1, qMax(i2, i3)); }
+
+void QDockAreaLayout::getGrid(QVector<QLayoutStruct> *_ver_struct_list,
+ QVector<QLayoutStruct> *_hor_struct_list)
+{
+ QSize center_hint(0, 0);
+ QSize center_min(0, 0);
+ const bool have_central = centralWidgetItem != 0 && !centralWidgetItem->isEmpty();
+ if (have_central) {
+ center_hint = centralWidgetRect.size();
+ if (!center_hint.isValid())
+ center_hint = centralWidgetItem->sizeHint();
+ center_min = centralWidgetItem->minimumSize();
+ }
+
+ QRect center_rect = rect;
+ if (!docks[QInternal::LeftDock].isEmpty())
+ center_rect.setLeft(rect.left() + docks[QInternal::LeftDock].rect.width() + sep);
+ if (!docks[QInternal::TopDock].isEmpty())
+ center_rect.setTop(rect.top() + docks[QInternal::TopDock].rect.height() + sep);
+ if (!docks[QInternal::RightDock].isEmpty())
+ center_rect.setRight(rect.right() - docks[QInternal::RightDock].rect.width() - sep);
+ if (!docks[QInternal::BottomDock].isEmpty())
+ center_rect.setBottom(rect.bottom() - docks[QInternal::BottomDock].rect.height() - sep);
+
+ QSize left_hint = docks[QInternal::LeftDock].size();
+ if (left_hint.isNull() || fallbackToSizeHints)
+ left_hint = docks[QInternal::LeftDock].sizeHint();
+ QSize left_min = docks[QInternal::LeftDock].minimumSize();
+ QSize left_max = docks[QInternal::LeftDock].maximumSize();
+ left_hint = left_hint.boundedTo(left_max).expandedTo(left_min);
+
+ QSize right_hint = docks[QInternal::RightDock].size();
+ if (right_hint.isNull() || fallbackToSizeHints)
+ right_hint = docks[QInternal::RightDock].sizeHint();
+ QSize right_min = docks[QInternal::RightDock].minimumSize();
+ QSize right_max = docks[QInternal::RightDock].maximumSize();
+ right_hint = right_hint.boundedTo(right_max).expandedTo(right_min);
+
+ QSize top_hint = docks[QInternal::TopDock].size();
+ if (top_hint.isNull() || fallbackToSizeHints)
+ top_hint = docks[QInternal::TopDock].sizeHint();
+ QSize top_min = docks[QInternal::TopDock].minimumSize();
+ QSize top_max = docks[QInternal::TopDock].maximumSize();
+ top_hint = top_hint.boundedTo(top_max).expandedTo(top_min);
+
+ QSize bottom_hint = docks[QInternal::BottomDock].size();
+ if (bottom_hint.isNull() || fallbackToSizeHints)
+ bottom_hint = docks[QInternal::BottomDock].sizeHint();
+ QSize bottom_min = docks[QInternal::BottomDock].minimumSize();
+ QSize bottom_max = docks[QInternal::BottomDock].maximumSize();
+ bottom_hint = bottom_hint.boundedTo(bottom_max).expandedTo(bottom_min);
+
+ fallbackToSizeHints = false;
+
+ if (_ver_struct_list != 0) {
+ QVector<QLayoutStruct> &ver_struct_list = *_ver_struct_list;
+ ver_struct_list.resize(3);
+
+ // top --------------------------------------------------
+ ver_struct_list[0].init();
+ ver_struct_list[0].stretch = 0;
+ ver_struct_list[0].sizeHint = top_hint.height();
+ ver_struct_list[0].minimumSize = top_min.height();
+ ver_struct_list[0].maximumSize = top_max.height();
+ ver_struct_list[0].expansive = false;
+ ver_struct_list[0].empty = docks[QInternal::TopDock].isEmpty();
+ ver_struct_list[0].pos = docks[QInternal::TopDock].rect.top();
+ ver_struct_list[0].size = docks[QInternal::TopDock].rect.height();
+
+ // center --------------------------------------------------
+ ver_struct_list[1].init();
+ ver_struct_list[1].stretch = center_hint.height();
+
+ bool tl_significant = corners[Qt::TopLeftCorner] == Qt::TopDockWidgetArea
+ || docks[QInternal::TopDock].isEmpty();
+ bool bl_significant = corners[Qt::BottomLeftCorner] == Qt::BottomDockWidgetArea
+ || docks[QInternal::BottomDock].isEmpty();
+ bool tr_significant = corners[Qt::TopRightCorner] == Qt::TopDockWidgetArea
+ || docks[QInternal::TopDock].isEmpty();
+ bool br_significant = corners[Qt::BottomRightCorner] == Qt::BottomDockWidgetArea
+ || docks[QInternal::BottomDock].isEmpty();
+
+ int left = (tl_significant && bl_significant) ? left_hint.height() : 0;
+ int right = (tr_significant && br_significant) ? right_hint.height() : 0;
+ ver_struct_list[1].sizeHint = qMax(left, center_hint.height(), right);
+
+ left = (tl_significant && bl_significant) ? left_min.height() : 0;
+ right = (tr_significant && br_significant) ? right_min.height() : 0;
+ ver_struct_list[1].minimumSize = qMax(left, center_min.height(), right);
+ ver_struct_list[1].maximumSize = have_central ? QWIDGETSIZE_MAX : 0;
+ ver_struct_list[1].expansive = have_central;
+ ver_struct_list[1].empty = docks[QInternal::LeftDock].isEmpty()
+ && !have_central
+ && docks[QInternal::RightDock].isEmpty();
+ ver_struct_list[1].pos = center_rect.top();
+ ver_struct_list[1].size = center_rect.height();
+
+ // bottom --------------------------------------------------
+ ver_struct_list[2].init();
+ ver_struct_list[2].stretch = 0;
+ ver_struct_list[2].sizeHint = bottom_hint.height();
+ ver_struct_list[2].minimumSize = bottom_min.height();
+ ver_struct_list[2].maximumSize = bottom_max.height();
+ ver_struct_list[2].expansive = false;
+ ver_struct_list[2].empty = docks[QInternal::BottomDock].isEmpty();
+ ver_struct_list[2].pos = docks[QInternal::BottomDock].rect.top();
+ ver_struct_list[2].size = docks[QInternal::BottomDock].rect.height();
+
+ for (int i = 0; i < 3; ++i) {
+ ver_struct_list[i].sizeHint
+ = qMax(ver_struct_list[i].sizeHint, ver_struct_list[i].minimumSize);
+ }
+ }
+
+ if (_hor_struct_list != 0) {
+ QVector<QLayoutStruct> &hor_struct_list = *_hor_struct_list;
+ hor_struct_list.resize(3);
+
+ // left --------------------------------------------------
+ hor_struct_list[0].init();
+ hor_struct_list[0].stretch = 0;
+ hor_struct_list[0].sizeHint = left_hint.width();
+ hor_struct_list[0].minimumSize = left_min.width();
+ hor_struct_list[0].maximumSize = left_max.width();
+ hor_struct_list[0].expansive = false;
+ hor_struct_list[0].empty = docks[QInternal::LeftDock].isEmpty();
+ hor_struct_list[0].pos = docks[QInternal::LeftDock].rect.left();
+ hor_struct_list[0].size = docks[QInternal::LeftDock].rect.width();
+
+ // center --------------------------------------------------
+ hor_struct_list[1].init();
+ hor_struct_list[1].stretch = center_hint.width();
+
+ bool tl_significant = corners[Qt::TopLeftCorner] == Qt::LeftDockWidgetArea
+ || docks[QInternal::LeftDock].isEmpty();
+ bool tr_significant = corners[Qt::TopRightCorner] == Qt::RightDockWidgetArea
+ || docks[QInternal::RightDock].isEmpty();
+ bool bl_significant = corners[Qt::BottomLeftCorner] == Qt::LeftDockWidgetArea
+ || docks[QInternal::LeftDock].isEmpty();
+ bool br_significant = corners[Qt::BottomRightCorner] == Qt::RightDockWidgetArea
+ || docks[QInternal::RightDock].isEmpty();
+
+ int top = (tl_significant && tr_significant) ? top_hint.width() : 0;
+ int bottom = (bl_significant && br_significant) ? bottom_hint.width() : 0;
+ hor_struct_list[1].sizeHint = qMax(top, center_hint.width(), bottom);
+
+ top = (tl_significant && tr_significant) ? top_min.width() : 0;
+ bottom = (bl_significant && br_significant) ? bottom_min.width() : 0;
+ hor_struct_list[1].minimumSize = qMax(top, center_min.width(), bottom);
+
+ hor_struct_list[1].maximumSize = have_central ? QWIDGETSIZE_MAX : 0;
+ hor_struct_list[1].expansive = have_central;
+ hor_struct_list[1].empty = !have_central;
+ hor_struct_list[1].pos = center_rect.left();
+ hor_struct_list[1].size = center_rect.width();
+
+ // right --------------------------------------------------
+ hor_struct_list[2].init();
+ hor_struct_list[2].stretch = 0;
+ hor_struct_list[2].sizeHint = right_hint.width();
+ hor_struct_list[2].minimumSize = right_min.width();
+ hor_struct_list[2].maximumSize = right_max.width();
+ hor_struct_list[2].expansive = false;
+ hor_struct_list[2].empty = docks[QInternal::RightDock].isEmpty();
+ hor_struct_list[2].pos = docks[QInternal::RightDock].rect.left();
+ hor_struct_list[2].size = docks[QInternal::RightDock].rect.width();
+
+ for (int i = 0; i < 3; ++i) {
+ hor_struct_list[i].sizeHint
+ = qMax(hor_struct_list[i].sizeHint, hor_struct_list[i].minimumSize);
+ }
+ }
+}
+
+void QDockAreaLayout::setGrid(QVector<QLayoutStruct> *ver_struct_list,
+ QVector<QLayoutStruct> *hor_struct_list)
+{
+
+ // top ---------------------------------------------------
+
+ if (!docks[QInternal::TopDock].isEmpty()) {
+ QRect r = docks[QInternal::TopDock].rect;
+ if (hor_struct_list != 0) {
+ r.setLeft(corners[Qt::TopLeftCorner] == Qt::TopDockWidgetArea
+ || docks[QInternal::LeftDock].isEmpty()
+ ? rect.left() : hor_struct_list->at(1).pos);
+ r.setRight(corners[Qt::TopRightCorner] == Qt::TopDockWidgetArea
+ || docks[QInternal::RightDock].isEmpty()
+ ? rect.right() : hor_struct_list->at(2).pos - sep - 1);
+ }
+ if (ver_struct_list != 0) {
+ r.setTop(rect.top());
+ r.setBottom(ver_struct_list->at(1).pos - sep - 1);
+ }
+ docks[QInternal::TopDock].rect = r;
+ docks[QInternal::TopDock].fitItems();
+ }
+
+ // bottom ---------------------------------------------------
+
+ if (!docks[QInternal::BottomDock].isEmpty()) {
+ QRect r = docks[QInternal::BottomDock].rect;
+ if (hor_struct_list != 0) {
+ r.setLeft(corners[Qt::BottomLeftCorner] == Qt::BottomDockWidgetArea
+ || docks[QInternal::LeftDock].isEmpty()
+ ? rect.left() : hor_struct_list->at(1).pos);
+ r.setRight(corners[Qt::BottomRightCorner] == Qt::BottomDockWidgetArea
+ || docks[QInternal::RightDock].isEmpty()
+ ? rect.right() : hor_struct_list->at(2).pos - sep - 1);
+ }
+ if (ver_struct_list != 0) {
+ r.setTop(ver_struct_list->at(2).pos);
+ r.setBottom(rect.bottom());
+ }
+ docks[QInternal::BottomDock].rect = r;
+ docks[QInternal::BottomDock].fitItems();
+ }
+
+ // left ---------------------------------------------------
+
+ if (!docks[QInternal::LeftDock].isEmpty()) {
+ QRect r = docks[QInternal::LeftDock].rect;
+ if (hor_struct_list != 0) {
+ r.setLeft(rect.left());
+ r.setRight(hor_struct_list->at(1).pos - sep - 1);
+ }
+ if (ver_struct_list != 0) {
+ r.setTop(corners[Qt::TopLeftCorner] == Qt::LeftDockWidgetArea
+ || docks[QInternal::TopDock].isEmpty()
+ ? rect.top() : ver_struct_list->at(1).pos);
+ r.setBottom(corners[Qt::BottomLeftCorner] == Qt::LeftDockWidgetArea
+ || docks[QInternal::BottomDock].isEmpty()
+ ? rect.bottom() : ver_struct_list->at(2).pos - sep - 1);
+ }
+ docks[QInternal::LeftDock].rect = r;
+ docks[QInternal::LeftDock].fitItems();
+ }
+
+ // right ---------------------------------------------------
+
+ if (!docks[QInternal::RightDock].isEmpty()) {
+ QRect r = docks[QInternal::RightDock].rect;
+ if (hor_struct_list != 0) {
+ r.setLeft(hor_struct_list->at(2).pos);
+ r.setRight(rect.right());
+ }
+ if (ver_struct_list != 0) {
+ r.setTop(corners[Qt::TopRightCorner] == Qt::RightDockWidgetArea
+ || docks[QInternal::TopDock].isEmpty()
+ ? rect.top() : ver_struct_list->at(1).pos);
+ r.setBottom(corners[Qt::BottomRightCorner] == Qt::RightDockWidgetArea
+ || docks[QInternal::BottomDock].isEmpty()
+ ? rect.bottom() : ver_struct_list->at(2).pos - sep - 1);
+ }
+ docks[QInternal::RightDock].rect = r;
+ docks[QInternal::RightDock].fitItems();
+ }
+
+ // center ---------------------------------------------------
+
+ if (hor_struct_list != 0) {
+ centralWidgetRect.setLeft(hor_struct_list->at(1).pos);
+ centralWidgetRect.setWidth(hor_struct_list->at(1).size);
+ }
+ if (ver_struct_list != 0) {
+ centralWidgetRect.setTop(ver_struct_list->at(1).pos);
+ centralWidgetRect.setHeight(ver_struct_list->at(1).size);
+ }
+}
+
+void QDockAreaLayout::fitLayout()
+{
+ QVector<QLayoutStruct> ver_struct_list(3);
+ QVector<QLayoutStruct> hor_struct_list(3);
+ getGrid(&ver_struct_list, &hor_struct_list);
+
+ qGeomCalc(ver_struct_list, 0, 3, rect.top(), rect.height(), sep);
+ qGeomCalc(hor_struct_list, 0, 3, rect.left(), rect.width(), sep);
+
+ setGrid(&ver_struct_list, &hor_struct_list);
+}
+
+void QDockAreaLayout::clear()
+{
+ for (int i = 0; i < QInternal::DockCount; ++i)
+ docks[i].clear();
+
+ rect = QRect();
+ centralWidgetRect = QRect();
+}
+
+QSize QDockAreaLayout::sizeHint() const
+{
+ int left_sep = 0;
+ int right_sep = 0;
+ int top_sep = 0;
+ int bottom_sep = 0;
+
+ if (centralWidgetItem != 0) {
+ left_sep = docks[QInternal::LeftDock].isEmpty() ? 0 : sep;
+ right_sep = docks[QInternal::RightDock].isEmpty() ? 0 : sep;
+ top_sep = docks[QInternal::TopDock].isEmpty() ? 0 : sep;
+ bottom_sep = docks[QInternal::BottomDock].isEmpty() ? 0 : sep;
+ }
+
+ QSize left = docks[QInternal::LeftDock].sizeHint() + QSize(left_sep, 0);
+ QSize right = docks[QInternal::RightDock].sizeHint() + QSize(right_sep, 0);
+ QSize top = docks[QInternal::TopDock].sizeHint() + QSize(0, top_sep);
+ QSize bottom = docks[QInternal::BottomDock].sizeHint() + QSize(0, bottom_sep);
+ QSize center = centralWidgetItem == 0 ? QSize(0, 0) : centralWidgetItem->sizeHint();
+
+ int row1 = top.width();
+ int row2 = left.width() + center.width() + right.width();
+ int row3 = bottom.width();
+ int col1 = left.height();
+ int col2 = top.height() + center.height() + bottom.height();
+ int col3 = right.height();
+
+ if (corners[Qt::TopLeftCorner] == Qt::LeftDockWidgetArea)
+ row1 += left.width();
+ else
+ col1 += top.height();
+
+ if (corners[Qt::TopRightCorner] == Qt::RightDockWidgetArea)
+ row1 += right.width();
+ else
+ col3 += top.height();
+
+ if (corners[Qt::BottomLeftCorner] == Qt::LeftDockWidgetArea)
+ row3 += left.width();
+ else
+ col1 += bottom.height();
+
+ if (corners[Qt::BottomRightCorner] == Qt::RightDockWidgetArea)
+ row3 += right.width();
+ else
+ col3 += bottom.height();
+
+ return QSize(qMax(row1, row2, row3), qMax(col1, col2, col3));
+}
+
+QSize QDockAreaLayout::minimumSize() const
+{
+ int left_sep = 0;
+ int right_sep = 0;
+ int top_sep = 0;
+ int bottom_sep = 0;
+
+ if (centralWidgetItem != 0) {
+ left_sep = docks[QInternal::LeftDock].isEmpty() ? 0 : sep;
+ right_sep = docks[QInternal::RightDock].isEmpty() ? 0 : sep;
+ top_sep = docks[QInternal::TopDock].isEmpty() ? 0 : sep;
+ bottom_sep = docks[QInternal::BottomDock].isEmpty() ? 0 : sep;
+ }
+
+ QSize left = docks[QInternal::LeftDock].minimumSize() + QSize(left_sep, 0);
+ QSize right = docks[QInternal::RightDock].minimumSize() + QSize(right_sep, 0);
+ QSize top = docks[QInternal::TopDock].minimumSize() + QSize(0, top_sep);
+ QSize bottom = docks[QInternal::BottomDock].minimumSize() + QSize(0, bottom_sep);
+ QSize center = centralWidgetItem == 0 ? QSize(0, 0) : centralWidgetItem->minimumSize();
+
+ int row1 = top.width();
+ int row2 = left.width() + center.width() + right.width();
+ int row3 = bottom.width();
+ int col1 = left.height();
+ int col2 = top.height() + center.height() + bottom.height();
+ int col3 = right.height();
+
+ if (corners[Qt::TopLeftCorner] == Qt::LeftDockWidgetArea)
+ row1 += left.width();
+ else
+ col1 += top.height();
+
+ if (corners[Qt::TopRightCorner] == Qt::RightDockWidgetArea)
+ row1 += right.width();
+ else
+ col3 += top.height();
+
+ if (corners[Qt::BottomLeftCorner] == Qt::LeftDockWidgetArea)
+ row3 += left.width();
+ else
+ col1 += bottom.height();
+
+ if (corners[Qt::BottomRightCorner] == Qt::RightDockWidgetArea)
+ row3 += right.width();
+ else
+ col3 += bottom.height();
+
+ return QSize(qMax(row1, row2, row3), qMax(col1, col2, col3));
+}
+
+bool QDockAreaLayout::restoreDockWidget(QDockWidget *dockWidget)
+{
+ QList<int> index = indexOfPlaceHolder(dockWidget->objectName());
+ if (index.isEmpty())
+ return false;
+
+ QDockAreaLayoutItem &item = this->item(index);
+ QPlaceHolderItem *placeHolder = item.placeHolderItem;
+ Q_ASSERT(placeHolder != 0);
+
+ item.widgetItem = new QDockWidgetItem(dockWidget);
+
+ if (placeHolder->window) {
+ QDesktopWidget desktop;
+ QRect r = constrainedRect(placeHolder->topLevelRect, desktop.screenGeometry(dockWidget));
+ dockWidget->d_func()->setWindowState(true, true, r);
+ }
+ dockWidget->setVisible(!placeHolder->hidden);
+#ifdef Q_WS_X11
+ if (placeHolder->window) // gets rid of the X11BypassWindowManager window flag
+ dockWidget->d_func()->setWindowState(true);
+#endif
+
+ item.placeHolderItem = 0;
+ delete placeHolder;
+
+ return true;
+}
+
+void QDockAreaLayout::addDockWidget(QInternal::DockPosition pos, QDockWidget *dockWidget,
+ Qt::Orientation orientation)
+{
+ QLayoutItem *dockWidgetItem = new QDockWidgetItem(dockWidget);
+ QDockAreaLayoutInfo &info = docks[pos];
+ if (orientation == info.o || info.item_list.count() <= 1) {
+ // empty dock areas, or dock areas containing exactly one widget can have their orientation
+ // switched.
+ info.o = orientation;
+
+ QDockAreaLayoutItem new_item(dockWidgetItem);
+ info.item_list.append(new_item);
+#ifndef QT_NO_TABBAR
+ if (info.tabbed && !new_item.skip()) {
+ info.updateTabBar();
+ info.setCurrentTabId(tabId(new_item));
+ }
+#endif
+ } else {
+#ifndef QT_NO_TABBAR
+ int tbshape = info.tabBarShape;
+#else
+ int tbshape = 0;
+#endif
+ QDockAreaLayoutInfo new_info(&sep, pos, orientation, tbshape, mainWindow);
+ new_info.item_list.append(new QDockAreaLayoutInfo(info));
+ new_info.item_list.append(dockWidgetItem);
+ info = new_info;
+ }
+
+ QList<int> index = indexOfPlaceHolder(dockWidget->objectName());
+ if (!index.isEmpty())
+ remove(index);
+}
+
+void QDockAreaLayout::tabifyDockWidget(QDockWidget *first, QDockWidget *second)
+{
+ QList<int> path = indexOf(first);
+ if (path.isEmpty())
+ return;
+
+ QDockAreaLayoutInfo *info = this->info(path);
+ Q_ASSERT(info != 0);
+ info->tab(path.last(), new QDockWidgetItem(second));
+
+ QList<int> index = indexOfPlaceHolder(second->objectName());
+ if (!index.isEmpty())
+ remove(index);
+}
+
+void QDockAreaLayout::splitDockWidget(QDockWidget *after,
+ QDockWidget *dockWidget,
+ Qt::Orientation orientation)
+{
+ QList<int> path = indexOf(after);
+ if (path.isEmpty())
+ return;
+
+ QDockAreaLayoutInfo *info = this->info(path);
+ Q_ASSERT(info != 0);
+ info->split(path.last(), orientation, new QDockWidgetItem(dockWidget));
+
+ QList<int> index = indexOfPlaceHolder(dockWidget->objectName());
+ if (!index.isEmpty())
+ remove(index);
+}
+
+void QDockAreaLayout::apply(bool animate)
+{
+ QWidgetAnimator &widgetAnimator = qt_mainwindow_layout(mainWindow)->widgetAnimator;
+
+ for (int i = 0; i < QInternal::DockCount; ++i)
+ docks[i].apply(animate);
+ if (centralWidgetItem != 0 && !centralWidgetItem->isEmpty()) {
+ widgetAnimator.animate(centralWidgetItem->widget(), centralWidgetRect,
+ animate);
+ }
+#ifndef QT_NO_TABBAR
+ if (sep == 1)
+ updateSeparatorWidgets();
+#endif //QT_NO_TABBAR
+}
+
+void QDockAreaLayout::paintSeparators(QPainter *p, QWidget *widget,
+ const QRegion &clip,
+ const QPoint &mouse) const
+{
+ for (int i = 0; i < QInternal::DockCount; ++i) {
+ const QDockAreaLayoutInfo &dock = docks[i];
+ if (dock.isEmpty())
+ continue;
+ QRect r = separatorRect(i);
+ if (clip.contains(r) && !dock.hasFixedSize()) {
+ Qt::Orientation opposite = dock.o == Qt::Horizontal
+ ? Qt::Vertical : Qt::Horizontal;
+ paintSep(p, widget, r, opposite, r.contains(mouse));
+ }
+ if (clip.contains(dock.rect))
+ dock.paintSeparators(p, widget, clip, mouse);
+ }
+}
+
+QRegion QDockAreaLayout::separatorRegion() const
+{
+ QRegion result;
+
+ for (int i = 0; i < QInternal::DockCount; ++i) {
+ const QDockAreaLayoutInfo &dock = docks[i];
+ if (dock.isEmpty())
+ continue;
+ result |= separatorRect(i);
+ result |= dock.separatorRegion();
+ }
+
+ return result;
+}
+
+int QDockAreaLayout::separatorMove(const QList<int> &separator, const QPoint &origin,
+ const QPoint &dest)
+{
+ int delta = 0;
+ int index = separator.last();
+
+ if (separator.count() > 1) {
+ QDockAreaLayoutInfo *info = this->info(separator);
+ delta = pick(info->o, dest - origin);
+ if (delta != 0)
+ delta = info->separatorMove(index, delta);
+ info->apply(false);
+ return delta;
+ }
+
+ QVector<QLayoutStruct> list;
+
+ if (index == QInternal::LeftDock || index == QInternal::RightDock)
+ getGrid(0, &list);
+ else
+ getGrid(&list, 0);
+
+ int sep_index = index == QInternal::LeftDock || index == QInternal::TopDock
+ ? 0 : 1;
+ Qt::Orientation o = index == QInternal::LeftDock || index == QInternal::RightDock
+ ? Qt::Horizontal
+ : Qt::Vertical;
+
+ delta = pick(o, dest - origin);
+ delta = separatorMoveHelper(list, sep_index, delta, sep);
+
+ if (index == QInternal::LeftDock || index == QInternal::RightDock)
+ setGrid(0, &list);
+ else
+ setGrid(&list, 0);
+
+ apply(false);
+
+ return delta;
+}
+
+#ifndef QT_NO_TABBAR
+// Sets the correct positions for the separator widgets
+// Allocates new sepearator widgets with getSeparatorWidget
+void QDockAreaLayout::updateSeparatorWidgets() const
+{
+ int j = 0;
+
+ for (int i = 0; i < QInternal::DockCount; ++i) {
+ const QDockAreaLayoutInfo &dock = docks[i];
+ if (dock.isEmpty())
+ continue;
+
+ QWidget *sepWidget;
+ if (j < separatorWidgets.size()) {
+ sepWidget = separatorWidgets.at(j);
+ } else {
+ sepWidget = qt_mainwindow_layout(mainWindow)->getSeparatorWidget();
+ separatorWidgets.append(sepWidget);
+ }
+ j++;
+
+#ifndef QT_MAC_USE_COCOA
+ sepWidget->raise();
+#endif
+ QRect sepRect = separatorRect(i).adjusted(-2, -2, 2, 2);
+ sepWidget->setGeometry(sepRect);
+ sepWidget->setMask( QRegion(separatorRect(i).translated( - sepRect.topLeft())));
+ sepWidget->show();
+ }
+ for (int i = j; i < separatorWidgets.size(); ++i)
+ separatorWidgets.at(i)->hide();
+
+ separatorWidgets.resize(j);
+}
+#endif //QT_NO_TABBAR
+
+QLayoutItem *QDockAreaLayout::itemAt(int *x, int index) const
+{
+ Q_ASSERT(x != 0);
+
+ for (int i = 0; i < QInternal::DockCount; ++i) {
+ const QDockAreaLayoutInfo &dock = docks[i];
+ if (QLayoutItem *ret = dock.itemAt(x, index))
+ return ret;
+ }
+
+ if (centralWidgetItem && (*x)++ == index)
+ return centralWidgetItem;
+
+ return 0;
+}
+
+QLayoutItem *QDockAreaLayout::takeAt(int *x, int index)
+{
+ Q_ASSERT(x != 0);
+
+ for (int i = 0; i < QInternal::DockCount; ++i) {
+ QDockAreaLayoutInfo &dock = docks[i];
+ if (QLayoutItem *ret = dock.takeAt(x, index))
+ return ret;
+ }
+
+ if (centralWidgetItem && (*x)++ == index) {
+ QLayoutItem *ret = centralWidgetItem;
+ centralWidgetItem = 0;
+ return ret;
+ }
+
+ return 0;
+}
+
+void QDockAreaLayout::deleteAllLayoutItems()
+{
+ for (int i = 0; i < QInternal::DockCount; ++i)
+ docks[i].deleteAllLayoutItems();
+}
+
+#ifndef QT_NO_TABBAR
+QSet<QTabBar*> QDockAreaLayout::usedTabBars() const
+{
+ QSet<QTabBar*> result;
+ for (int i = 0; i < QInternal::DockCount; ++i) {
+ const QDockAreaLayoutInfo &dock = docks[i];
+ result += dock.usedTabBars();
+ }
+ return result;
+}
+
+// Returns the set of all used separator widgets
+QSet<QWidget*> QDockAreaLayout::usedSeparatorWidgets() const
+{
+ QSet<QWidget*> result;
+
+ for (int i = 0; i < separatorWidgets.count(); ++i)
+ result << separatorWidgets.at(i);
+ for (int i = 0; i < QInternal::DockCount; ++i) {
+ const QDockAreaLayoutInfo &dock = docks[i];
+ result += dock.usedSeparatorWidgets();
+ }
+ return result;
+}
+#endif
+
+QRect QDockAreaLayout::gapRect(const QList<int> &path) const
+{
+ const QDockAreaLayoutInfo *info = this->info(path);
+ if (info == 0)
+ return QRect();
+ const QList<QDockAreaLayoutItem> &item_list = info->item_list;
+ Qt::Orientation o = info->o;
+ int index = path.last();
+ if (index < 0 || index >= item_list.count())
+ return QRect();
+ const QDockAreaLayoutItem &item = item_list.at(index);
+ if (!(item.flags & QDockAreaLayoutItem::GapItem))
+ return QRect();
+
+ QRect result;
+
+#ifndef QT_NO_TABBAR
+ if (info->tabbed) {
+ result = info->tabContentRect();
+ } else
+#endif
+ {
+ int pos = item.pos;
+ int size = item.size;
+
+ int prev = info->prev(index);
+ int next = info->next(index);
+
+ if (prev != -1 && !(item_list.at(prev).flags & QDockAreaLayoutItem::GapItem)) {
+ pos += sep;
+ size -= sep;
+ }
+ if (next != -1 && !(item_list.at(next).flags & QDockAreaLayoutItem::GapItem))
+ size -= sep;
+
+ QPoint p;
+ rpick(o, p) = pos;
+ rperp(o, p) = perp(o, info->rect.topLeft());
+ QSize s;
+ rpick(o, s) = size;
+ rperp(o, s) = perp(o, info->rect.size());
+
+ result = QRect(p, s);
+ }
+
+ return result;
+}
+
+void QDockAreaLayout::keepSize(QDockWidget *w)
+{
+ QList<int> path = indexOf(w);
+ if (path.isEmpty())
+ return;
+ QDockAreaLayoutItem &item = this->item(path);
+ if (item.size != -1)
+ item.flags |= QDockAreaLayoutItem::KeepSize;
+}
+
+void QDockAreaLayout::styleChangedEvent()
+{
+ sep = mainWindow->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, mainWindow);
+ fitLayout();
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_DOCKWIDGET
diff --git a/src/widgets/widgets/qdockarealayout_p.h b/src/widgets/widgets/qdockarealayout_p.h
new file mode 100644
index 0000000000..a83a930c04
--- /dev/null
+++ b/src/widgets/widgets/qdockarealayout_p.h
@@ -0,0 +1,308 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDOCKAREALAYOUT_P_H
+#define QDOCKAREALAYOUT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "QtCore/qrect.h"
+#include "QtCore/qpair.h"
+#include "QtCore/qlist.h"
+#include "QtCore/qvector.h"
+#include "QtWidgets/qlayout.h"
+
+#ifndef QT_NO_DOCKWIDGET
+
+QT_BEGIN_NAMESPACE
+
+class QLayoutItem;
+class QWidget;
+class QLayoutItem;
+class QDockAreaLayoutInfo;
+class QPlaceHolderItem;
+class QDockWidget;
+class QMainWindow;
+class QWidgetAnimator;
+class QMainWindowLayout;
+struct QLayoutStruct;
+class QTabBar;
+
+// The classes in this file represent the tree structure that represents all the docks
+// Also see the wiki internal documentation
+// At the root of the tree is: QDockAreaLayout, which handles all 4 sides, so there is only one.
+// For each side it has one QDockAreaLayoutInfo child. (See QDockAreaLayout::docks.)
+// The QDockAreaLayoutInfo have QDockAreaLayoutItems as children (See QDockAreaLayoutInfo::item_list),
+// which then has one QDockAreaLayoutInfo as a child. (QDockAreaLayoutItem::subInfo) or
+// a widgetItem if this is a node of the tree (QDockAreaLayoutItem::widgetItem)
+//
+// A path indetifies uniquely one object in this tree, the first number being the side and all the following
+// indexes into the QDockAreaLayoutInfo::item_list.
+
+struct QDockAreaLayoutItem
+{
+ enum ItemFlags { NoFlags = 0, GapItem = 1, KeepSize = 2 };
+
+ QDockAreaLayoutItem(QLayoutItem *_widgetItem = 0);
+ QDockAreaLayoutItem(QDockAreaLayoutInfo *_subinfo);
+ QDockAreaLayoutItem(QPlaceHolderItem *_placeHolderItem);
+ QDockAreaLayoutItem(const QDockAreaLayoutItem &other);
+ ~QDockAreaLayoutItem();
+
+ QDockAreaLayoutItem &operator = (const QDockAreaLayoutItem &other);
+
+ bool skip() const;
+ QSize minimumSize() const;
+ QSize maximumSize() const;
+ QSize sizeHint() const;
+ bool expansive(Qt::Orientation o) const;
+ bool hasFixedSize(Qt::Orientation o) const;
+
+ QLayoutItem *widgetItem;
+ QDockAreaLayoutInfo *subinfo;
+ QPlaceHolderItem *placeHolderItem;
+ int pos;
+ int size;
+ uint flags;
+};
+
+class Q_AUTOTEST_EXPORT QPlaceHolderItem
+{
+public:
+ QPlaceHolderItem() : hidden(false), window(false) {}
+ QPlaceHolderItem(QWidget *w);
+
+ QString objectName;
+ bool hidden, window;
+ QRect topLevelRect;
+};
+
+class Q_AUTOTEST_EXPORT QDockAreaLayoutInfo
+{
+public:
+ QDockAreaLayoutInfo();
+ QDockAreaLayoutInfo(const int *_sep, QInternal::DockPosition _dockPos, Qt::Orientation _o,
+ int tbhape, QMainWindow *window);
+
+ QSize minimumSize() const;
+ QSize maximumSize() const;
+ QSize sizeHint() const;
+ QSize size() const;
+
+ bool insertGap(const QList<int> &path, QLayoutItem *dockWidgetItem);
+ QLayoutItem *plug(const QList<int> &path);
+ QLayoutItem *unplug(const QList<int> &path);
+ enum TabMode { NoTabs, AllowTabs, ForceTabs };
+ QList<int> gapIndex(const QPoint &pos, bool nestingEnabled,
+ TabMode tabMode) const;
+ void remove(const QList<int> &path);
+ void unnest(int index);
+ void split(int index, Qt::Orientation orientation, QLayoutItem *dockWidgetItem);
+ void tab(int index, QLayoutItem *dockWidgetItem);
+ QDockAreaLayoutItem &item(const QList<int> &path);
+ QDockAreaLayoutInfo *info(const QList<int> &path);
+ QDockAreaLayoutInfo *info(QWidget *widget);
+
+ enum { // sentinel values used to validate state data
+ SequenceMarker = 0xfc,
+ TabMarker = 0xfa,
+ WidgetMarker = 0xfb
+ };
+ void saveState(QDataStream &stream) const;
+ bool restoreState(QDataStream &stream, QList<QDockWidget*> &widgets, bool testing);
+
+ void fitItems();
+ bool expansive(Qt::Orientation o) const;
+ int changeSize(int index, int size, bool below);
+ QRect itemRect(int index) const;
+ QRect itemRect(const QList<int> &path) const;
+ QRect separatorRect(int index) const;
+ QRect separatorRect(const QList<int> &path) const;
+
+ void clear();
+ bool isEmpty() const;
+ bool hasFixedSize() const;
+ QList<int> findSeparator(const QPoint &pos) const;
+ int next(int idx) const;
+ int prev(int idx) const;
+
+ QList<int> indexOf(QWidget *widget) const;
+ QList<int> indexOfPlaceHolder(const QString &objectName) const;
+
+ void apply(bool animate);
+
+ void paintSeparators(QPainter *p, QWidget *widget, const QRegion &clip,
+ const QPoint &mouse) const;
+ QRegion separatorRegion() const;
+ int separatorMove(int index, int delta);
+
+ QLayoutItem *itemAt(int *x, int index) const;
+ QLayoutItem *takeAt(int *x, int index);
+ void deleteAllLayoutItems();
+
+ QMainWindowLayout *mainWindowLayout() const;
+
+ const int *sep;
+ mutable QVector<QWidget*> separatorWidgets;
+ QInternal::DockPosition dockPos;
+ Qt::Orientation o;
+ QRect rect;
+ QMainWindow *mainWindow;
+ QList<QDockAreaLayoutItem> item_list;
+#ifndef QT_NO_TABBAR
+ void updateSeparatorWidgets() const;
+ QSet<QWidget*> usedSeparatorWidgets() const;
+#endif //QT_NO_TABBAR
+
+#ifndef QT_NO_TABBAR
+ quintptr currentTabId() const;
+ void setCurrentTab(QWidget *widget);
+ void setCurrentTabId(quintptr id);
+ QRect tabContentRect() const;
+ bool tabbed;
+ QTabBar *tabBar;
+ int tabBarShape;
+
+ bool updateTabBar() const;
+ void setTabBarShape(int shape);
+ QSize tabBarMinimumSize() const;
+ QSize tabBarSizeHint() const;
+
+ QSet<QTabBar*> usedTabBars() const;
+#endif // QT_NO_TABBAR
+};
+
+class Q_AUTOTEST_EXPORT QDockAreaLayout
+{
+public:
+ enum { EmptyDropAreaSize = 80 }; // when a dock area is empty, how "wide" is it?
+
+ Qt::DockWidgetArea corners[4]; // use a Qt::Corner for indexing
+ QRect rect;
+ QLayoutItem *centralWidgetItem;
+ QMainWindow *mainWindow;
+ QRect centralWidgetRect;
+ QDockAreaLayout(QMainWindow *win);
+ QDockAreaLayoutInfo docks[4];
+ int sep; // separator extent
+ bool fallbackToSizeHints; //determines if we should use the sizehint for the dock areas (true until the layout is restored or the central widget is set)
+ mutable QVector<QWidget*> separatorWidgets;
+
+ bool isValid() const;
+
+ enum { DockWidgetStateMarker = 0xfd };
+ void saveState(QDataStream &stream) const;
+ bool restoreState(QDataStream &stream, const QList<QDockWidget*> &widgets, bool testing = false);
+
+ QList<int> indexOfPlaceHolder(const QString &objectName) const;
+ QList<int> indexOf(QWidget *dockWidget) const;
+ QList<int> gapIndex(const QPoint &pos) const;
+ QList<int> findSeparator(const QPoint &pos) const;
+
+ QDockAreaLayoutItem &item(const QList<int> &path);
+ QDockAreaLayoutInfo *info(const QList<int> &path);
+ const QDockAreaLayoutInfo *info(const QList<int> &path) const;
+ QDockAreaLayoutInfo *info(QWidget *widget);
+ QRect itemRect(const QList<int> &path) const;
+ QRect separatorRect(int index) const;
+ QRect separatorRect(const QList<int> &path) const;
+
+ bool insertGap(const QList<int> &path, QLayoutItem *dockWidgetItem);
+ QLayoutItem *plug(const QList<int> &path);
+ QLayoutItem *unplug(const QList<int> &path);
+ void remove(const QList<int> &path);
+
+ void fitLayout();
+
+ void clear();
+
+ QSize sizeHint() const;
+ QSize minimumSize() const;
+
+ void addDockWidget(QInternal::DockPosition pos, QDockWidget *dockWidget, Qt::Orientation orientation);
+ bool restoreDockWidget(QDockWidget *dockWidget);
+ void splitDockWidget(QDockWidget *after, QDockWidget *dockWidget,
+ Qt::Orientation orientation);
+ void tabifyDockWidget(QDockWidget *first, QDockWidget *second);
+
+ void apply(bool animate);
+
+ void paintSeparators(QPainter *p, QWidget *widget, const QRegion &clip,
+ const QPoint &mouse) const;
+ QRegion separatorRegion() const;
+ int separatorMove(const QList<int> &separator, const QPoint &origin, const QPoint &dest);
+#ifndef QT_NO_TABBAR
+ void updateSeparatorWidgets() const;
+#endif //QT_NO_TABBAR
+
+ QLayoutItem *itemAt(int *x, int index) const;
+ QLayoutItem *takeAt(int *x, int index);
+ void deleteAllLayoutItems();
+
+ void getGrid(QVector<QLayoutStruct> *ver_struct_list,
+ QVector<QLayoutStruct> *hor_struct_list);
+ void setGrid(QVector<QLayoutStruct> *ver_struct_list,
+ QVector<QLayoutStruct> *hor_struct_list);
+
+ QRect gapRect(const QList<int> &path) const;
+
+ void keepSize(QDockWidget *w);
+#ifndef QT_NO_TABBAR
+ QSet<QTabBar*> usedTabBars() const;
+ QSet<QWidget*> usedSeparatorWidgets() const;
+#endif //QT_NO_TABBAR
+ void styleChangedEvent();
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_QDOCKWIDGET
+
+#endif // QDOCKAREALAYOUT_P_H
diff --git a/src/gui/widgets/qdockwidget.cpp b/src/widgets/widgets/qdockwidget.cpp
index 16b60c8295..16b60c8295 100644
--- a/src/gui/widgets/qdockwidget.cpp
+++ b/src/widgets/widgets/qdockwidget.cpp
diff --git a/src/widgets/widgets/qdockwidget.h b/src/widgets/widgets/qdockwidget.h
new file mode 100644
index 0000000000..e6ff1756f3
--- /dev/null
+++ b/src/widgets/widgets/qdockwidget.h
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDYNAMICDOCKWIDGET_H
+#define QDYNAMICDOCKWIDGET_H
+
+#include <QtWidgets/qwidget.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_DOCKWIDGET
+
+class QDockAreaLayout;
+class QDockWidgetPrivate;
+class QMainWindow;
+class QStyleOptionDockWidget;
+
+class Q_GUI_EXPORT QDockWidget : public QWidget
+{
+ Q_OBJECT
+
+ Q_FLAGS(DockWidgetFeatures)
+ Q_PROPERTY(bool floating READ isFloating WRITE setFloating)
+ Q_PROPERTY(DockWidgetFeatures features READ features WRITE setFeatures NOTIFY featuresChanged)
+ Q_PROPERTY(Qt::DockWidgetAreas allowedAreas READ allowedAreas
+ WRITE setAllowedAreas NOTIFY allowedAreasChanged)
+ Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle DESIGNABLE true)
+
+public:
+ explicit QDockWidget(const QString &title, QWidget *parent = 0, Qt::WindowFlags flags = 0);
+ explicit QDockWidget(QWidget *parent = 0, Qt::WindowFlags flags = 0);
+ ~QDockWidget();
+
+ QWidget *widget() const;
+ void setWidget(QWidget *widget);
+
+ enum DockWidgetFeature {
+ DockWidgetClosable = 0x01,
+ DockWidgetMovable = 0x02,
+ DockWidgetFloatable = 0x04,
+ DockWidgetVerticalTitleBar = 0x08,
+
+ DockWidgetFeatureMask = 0x0f,
+ AllDockWidgetFeatures = DockWidgetClosable|DockWidgetMovable|DockWidgetFloatable, // ### remove in 5.0
+ NoDockWidgetFeatures = 0x00,
+
+ Reserved = 0xff
+ };
+ Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature)
+
+ void setFeatures(DockWidgetFeatures features);
+ DockWidgetFeatures features() const;
+
+ void setFloating(bool floating);
+ inline bool isFloating() const { return isWindow(); }
+
+ void setAllowedAreas(Qt::DockWidgetAreas areas);
+ Qt::DockWidgetAreas allowedAreas() const;
+
+ void setTitleBarWidget(QWidget *widget);
+ QWidget *titleBarWidget() const;
+
+ inline bool isAreaAllowed(Qt::DockWidgetArea area) const
+ { return (allowedAreas() & area) == area; }
+
+#ifndef QT_NO_ACTION
+ QAction *toggleViewAction() const;
+#endif
+
+Q_SIGNALS:
+ void featuresChanged(QDockWidget::DockWidgetFeatures features);
+ void topLevelChanged(bool topLevel);
+ void allowedAreasChanged(Qt::DockWidgetAreas allowedAreas);
+ void visibilityChanged(bool visible);
+ void dockLocationChanged(Qt::DockWidgetArea area);
+
+protected:
+ void changeEvent(QEvent *event);
+ void closeEvent(QCloseEvent *event);
+ void paintEvent(QPaintEvent *event);
+ bool event(QEvent *event);
+ void initStyleOption(QStyleOptionDockWidget *option) const;
+
+private:
+ Q_DECLARE_PRIVATE(QDockWidget)
+ Q_DISABLE_COPY(QDockWidget)
+ Q_PRIVATE_SLOT(d_func(), void _q_toggleView(bool))
+ Q_PRIVATE_SLOT(d_func(), void _q_toggleTopLevel())
+ friend class QDockAreaLayout;
+ friend class QDockWidgetItem;
+ friend class QMainWindowLayout;
+ friend class QDockWidgetLayout;
+ friend class QDockAreaLayoutInfo;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QDockWidget::DockWidgetFeatures)
+
+#endif // QT_NO_DOCKWIDGET
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDYNAMICDOCKWIDGET_H
diff --git a/src/widgets/widgets/qdockwidget_p.h b/src/widgets/widgets/qdockwidget_p.h
new file mode 100644
index 0000000000..cf674d5d73
--- /dev/null
+++ b/src/widgets/widgets/qdockwidget_p.h
@@ -0,0 +1,207 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDYNAMICDOCKWIDGET_P_H
+#define QDYNAMICDOCKWIDGET_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "QtWidgets/qstyleoption.h"
+#include "private/qwidget_p.h"
+#include "QtWidgets/qboxlayout.h"
+#include "QtWidgets/qdockwidget.h"
+
+#ifndef QT_NO_DOCKWIDGET
+
+QT_BEGIN_NAMESPACE
+
+class QGridLayout;
+class QWidgetResizeHandler;
+class QRubberBand;
+class QDockWidgetTitleButton;
+class QSpacerItem;
+class QDockWidgetItem;
+
+class QDockWidgetPrivate : public QWidgetPrivate
+{
+ Q_DECLARE_PUBLIC(QDockWidget)
+
+ struct DragState {
+ QPoint pressPos;
+ bool dragging;
+ QLayoutItem *widgetItem;
+ bool ownWidgetItem;
+ bool nca;
+ bool ctrlDrag;
+ };
+
+public:
+ inline QDockWidgetPrivate()
+ : QWidgetPrivate(), state(0),
+ features(QDockWidget::DockWidgetClosable
+ | QDockWidget::DockWidgetMovable
+ | QDockWidget::DockWidgetFloatable),
+ allowedAreas(Qt::AllDockWidgetAreas)
+ { }
+
+ void init();
+ void _q_toggleView(bool); // private slot
+ void _q_toggleTopLevel(); // private slot
+
+ void updateButtons();
+ DragState *state;
+
+ QDockWidget::DockWidgetFeatures features;
+ Qt::DockWidgetAreas allowedAreas;
+
+ QWidgetResizeHandler *resizer;
+
+#ifndef QT_NO_ACTION
+ QAction *toggleViewAction;
+#endif
+
+// QMainWindow *findMainWindow(QWidget *widget) const;
+ QRect undockedGeometry;
+ QString fixedWindowTitle;
+
+ bool mousePressEvent(QMouseEvent *event);
+ bool mouseDoubleClickEvent(QMouseEvent *event);
+ bool mouseMoveEvent(QMouseEvent *event);
+ bool mouseReleaseEvent(QMouseEvent *event);
+ void setWindowState(bool floating, bool unplug = false, const QRect &rect = QRect());
+ void nonClientAreaMouseEvent(QMouseEvent *event);
+ void initDrag(const QPoint &pos, bool nca);
+ void startDrag();
+ void endDrag(bool abort = false);
+ void moveEvent(QMoveEvent *event);
+
+ void unplug(const QRect &rect);
+ void plug(const QRect &rect);
+
+ bool isAnimating() const;
+};
+
+class Q_GUI_EXPORT QDockWidgetLayout : public QLayout
+{
+ Q_OBJECT
+public:
+ QDockWidgetLayout(QWidget *parent = 0);
+ ~QDockWidgetLayout();
+ void addItem(QLayoutItem *item);
+ QLayoutItem *itemAt(int index) const;
+ QLayoutItem *takeAt(int index);
+ int count() const;
+
+ QSize maximumSize() const;
+ QSize minimumSize() const;
+ QSize sizeHint() const;
+
+ QSize sizeFromContent(const QSize &content, bool floating) const;
+
+ void setGeometry(const QRect &r);
+
+ enum Role { Content, CloseButton, FloatButton, TitleBar, RoleCount };
+ QWidget *widgetForRole(Role r) const;
+ void setWidgetForRole(Role r, QWidget *w);
+ QLayoutItem *itemForRole(Role r) const;
+
+ QRect titleArea() const { return _titleArea; }
+
+ int minimumTitleWidth() const;
+ int titleHeight() const;
+ void updateMaxSize();
+ bool nativeWindowDeco() const;
+ bool nativeWindowDeco(bool floating) const;
+
+ void setVerticalTitleBar(bool b);
+
+ bool verticalTitleBar;
+
+private:
+ QVector<QLayoutItem*> item_list;
+ QRect _titleArea;
+};
+
+/* The size hints of a QDockWidget will depend on whether it is docked or not.
+ This layout item always returns the size hints as if the dock widget was docked. */
+
+class QDockWidgetItem : public QWidgetItem
+{
+public:
+ QDockWidgetItem(QDockWidget *dockWidget);
+ QSize minimumSize() const;
+ QSize maximumSize() const;
+ QSize sizeHint() const;
+
+private:
+ inline QLayoutItem *dockWidgetChildItem() const;
+ inline QDockWidgetLayout *dockWidgetLayout() const;
+};
+
+inline QLayoutItem *QDockWidgetItem::dockWidgetChildItem() const
+{
+ if (QDockWidgetLayout *layout = dockWidgetLayout())
+ return layout->itemForRole(QDockWidgetLayout::Content);
+ return 0;
+}
+
+inline QDockWidgetLayout *QDockWidgetItem::dockWidgetLayout() const
+{
+ QWidget *w = const_cast<QDockWidgetItem*>(this)->widget();
+ if (w != 0)
+ return qobject_cast<QDockWidgetLayout*>(w->layout());
+ return 0;
+}
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_DOCKWIDGET
+
+#endif // QDYNAMICDOCKWIDGET_P_H
diff --git a/src/gui/widgets/qeffects.cpp b/src/widgets/widgets/qeffects.cpp
index 6b64d48654..6b64d48654 100644
--- a/src/gui/widgets/qeffects.cpp
+++ b/src/widgets/widgets/qeffects.cpp
diff --git a/src/gui/widgets/qeffects_p.h b/src/widgets/widgets/qeffects_p.h
index feaf9be9e6..feaf9be9e6 100644
--- a/src/gui/widgets/qeffects_p.h
+++ b/src/widgets/widgets/qeffects_p.h
diff --git a/src/gui/widgets/qfocusframe.cpp b/src/widgets/widgets/qfocusframe.cpp
index 6508c31b50..6508c31b50 100644
--- a/src/gui/widgets/qfocusframe.cpp
+++ b/src/widgets/widgets/qfocusframe.cpp
diff --git a/src/widgets/widgets/qfocusframe.h b/src/widgets/widgets/qfocusframe.h
new file mode 100644
index 0000000000..82d61b6067
--- /dev/null
+++ b/src/widgets/widgets/qfocusframe.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QFOCUSFRAME_H
+#define QFOCUSFRAME_H
+
+#include <QtWidgets/qwidget.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QFocusFramePrivate;
+class QStyleOption;
+
+class Q_GUI_EXPORT QFocusFrame : public QWidget
+{
+ Q_OBJECT
+public:
+ QFocusFrame(QWidget *parent=0);
+ ~QFocusFrame();
+
+ void setWidget(QWidget *widget);
+ QWidget *widget() const;
+
+protected:
+ bool event(QEvent *e);
+
+ bool eventFilter(QObject *, QEvent *);
+ void paintEvent(QPaintEvent *);
+ void initStyleOption(QStyleOption *option) const;
+
+private:
+ Q_DECLARE_PRIVATE(QFocusFrame)
+ Q_DISABLE_COPY(QFocusFrame)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QFOCUSFRAME_H
diff --git a/src/gui/widgets/qfontcombobox.cpp b/src/widgets/widgets/qfontcombobox.cpp
index d27f9dc339..d27f9dc339 100644
--- a/src/gui/widgets/qfontcombobox.cpp
+++ b/src/widgets/widgets/qfontcombobox.cpp
diff --git a/src/widgets/widgets/qfontcombobox.h b/src/widgets/widgets/qfontcombobox.h
new file mode 100644
index 0000000000..6a7f755476
--- /dev/null
+++ b/src/widgets/widgets/qfontcombobox.h
@@ -0,0 +1,112 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QFONTCOMBOBOX_H
+#define QFONTCOMBOBOX_H
+
+#include <QtWidgets/qcombobox.h>
+#include <QtGui/qfontdatabase.h>
+
+#ifndef QT_NO_FONTCOMBOBOX
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QFontComboBoxPrivate;
+
+class Q_GUI_EXPORT QFontComboBox : public QComboBox
+{
+ Q_OBJECT
+ Q_FLAGS(FontFilters)
+ Q_PROPERTY(QFontDatabase::WritingSystem writingSystem READ writingSystem WRITE setWritingSystem)
+ Q_PROPERTY(FontFilters fontFilters READ fontFilters WRITE setFontFilters)
+ Q_PROPERTY(QFont currentFont READ currentFont WRITE setCurrentFont NOTIFY currentFontChanged)
+ Q_ENUMS(FontSelection)
+
+public:
+ explicit QFontComboBox(QWidget *parent = 0);
+ ~QFontComboBox();
+
+ void setWritingSystem(QFontDatabase::WritingSystem);
+ QFontDatabase::WritingSystem writingSystem() const;
+
+ enum FontFilter {
+ AllFonts = 0,
+ ScalableFonts = 0x1,
+ NonScalableFonts = 0x2,
+ MonospacedFonts = 0x4,
+ ProportionalFonts = 0x8
+ };
+ Q_DECLARE_FLAGS(FontFilters, FontFilter)
+
+ void setFontFilters(FontFilters filters);
+ FontFilters fontFilters() const;
+
+ QFont currentFont() const;
+ QSize sizeHint() const;
+
+public Q_SLOTS:
+ void setCurrentFont(const QFont &f);
+
+Q_SIGNALS:
+ void currentFontChanged(const QFont &f);
+
+protected:
+ bool event(QEvent *e);
+
+private:
+ Q_DISABLE_COPY(QFontComboBox)
+ Q_DECLARE_PRIVATE(QFontComboBox)
+ Q_PRIVATE_SLOT(d_func(), void _q_currentChanged(const QString &))
+ Q_PRIVATE_SLOT(d_func(), void _q_updateModel())
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QFontComboBox::FontFilters)
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QT_NO_FONTCOMBOBOX
+#endif
diff --git a/src/gui/widgets/qframe.cpp b/src/widgets/widgets/qframe.cpp
index 1a61b3831f..1a61b3831f 100644
--- a/src/gui/widgets/qframe.cpp
+++ b/src/widgets/widgets/qframe.cpp
diff --git a/src/widgets/widgets/qframe.h b/src/widgets/widgets/qframe.h
new file mode 100644
index 0000000000..d93db6b7cb
--- /dev/null
+++ b/src/widgets/widgets/qframe.h
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QFRAME_H
+#define QFRAME_H
+
+#include <QtWidgets/qwidget.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QFramePrivate;
+
+class Q_GUI_EXPORT QFrame : public QWidget
+{
+ Q_OBJECT
+
+ Q_ENUMS(Shape Shadow)
+ Q_PROPERTY(Shape frameShape READ frameShape WRITE setFrameShape)
+ Q_PROPERTY(Shadow frameShadow READ frameShadow WRITE setFrameShadow)
+ Q_PROPERTY(int lineWidth READ lineWidth WRITE setLineWidth)
+ Q_PROPERTY(int midLineWidth READ midLineWidth WRITE setMidLineWidth)
+ Q_PROPERTY(int frameWidth READ frameWidth)
+ Q_PROPERTY(QRect frameRect READ frameRect WRITE setFrameRect DESIGNABLE false)
+
+public:
+ explicit QFrame(QWidget* parent = 0, Qt::WindowFlags f = 0);
+ ~QFrame();
+
+ int frameStyle() const;
+ void setFrameStyle(int);
+
+ int frameWidth() const;
+
+ QSize sizeHint() const;
+
+ enum Shape {
+ NoFrame = 0, // no frame
+ Box = 0x0001, // rectangular box
+ Panel = 0x0002, // rectangular panel
+ WinPanel = 0x0003, // rectangular panel (Windows)
+ HLine = 0x0004, // horizontal line
+ VLine = 0x0005, // vertical line
+ StyledPanel = 0x0006 // rectangular panel depending on the GUI style
+
+#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
+ ,PopupPanel = StyledPanel, // rectangular panel depending on the GUI style
+ MenuBarPanel = StyledPanel,
+ ToolBarPanel = StyledPanel,
+ LineEditPanel = StyledPanel,
+ TabWidgetPanel = StyledPanel,
+ GroupBoxPanel = StyledPanel
+#endif
+ };
+ enum Shadow {
+ Plain = 0x0010, // plain line
+ Raised = 0x0020, // raised shadow effect
+ Sunken = 0x0030 // sunken shadow effect
+ };
+
+ enum StyleMask {
+ Shadow_Mask = 0x00f0, // mask for the shadow
+ Shape_Mask = 0x000f // mask for the shape
+#if defined(QT3_SUPPORT)
+ ,MShadow = Shadow_Mask,
+ MShape = Shape_Mask
+#endif
+ };
+
+ Shape frameShape() const;
+ void setFrameShape(Shape);
+ Shadow frameShadow() const;
+ void setFrameShadow(Shadow);
+
+ int lineWidth() const;
+ void setLineWidth(int);
+
+ int midLineWidth() const;
+ void setMidLineWidth(int);
+
+ QRect frameRect() const;
+ void setFrameRect(const QRect &);
+
+protected:
+ bool event(QEvent *e);
+ void paintEvent(QPaintEvent *);
+ void changeEvent(QEvent *);
+ void drawFrame(QPainter *);
+
+#ifdef QT3_SUPPORT
+public:
+ QT3_SUPPORT_CONSTRUCTOR QFrame(QWidget* parent, const char* name, Qt::WindowFlags f = 0);
+#endif
+
+protected:
+ QFrame(QFramePrivate &dd, QWidget* parent = 0, Qt::WindowFlags f = 0);
+
+private:
+ Q_DISABLE_COPY(QFrame)
+ Q_DECLARE_PRIVATE(QFrame)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QFRAME_H
diff --git a/src/gui/widgets/qframe_p.h b/src/widgets/widgets/qframe_p.h
index 173dfdc6fa..173dfdc6fa 100644
--- a/src/gui/widgets/qframe_p.h
+++ b/src/widgets/widgets/qframe_p.h
diff --git a/src/gui/widgets/qgroupbox.cpp b/src/widgets/widgets/qgroupbox.cpp
index 560ccd08c3..560ccd08c3 100644
--- a/src/gui/widgets/qgroupbox.cpp
+++ b/src/widgets/widgets/qgroupbox.cpp
diff --git a/src/widgets/widgets/qgroupbox.h b/src/widgets/widgets/qgroupbox.h
new file mode 100644
index 0000000000..b84a34ff2b
--- /dev/null
+++ b/src/widgets/widgets/qgroupbox.h
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QGROUPBOX_H
+#define QGROUPBOX_H
+
+#include <QtWidgets/qframe.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_GROUPBOX
+
+class QGroupBoxPrivate;
+class QStyleOptionGroupBox;
+class Q_GUI_EXPORT QGroupBox : public QWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString title READ title WRITE setTitle)
+ Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
+ Q_PROPERTY(bool flat READ isFlat WRITE setFlat)
+ Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable)
+ Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled USER true)
+public:
+ explicit QGroupBox(QWidget* parent=0);
+ explicit QGroupBox(const QString &title, QWidget* parent=0);
+ ~QGroupBox();
+
+ QString title() const;
+ void setTitle(const QString &title);
+
+ Qt::Alignment alignment() const;
+ void setAlignment(int alignment);
+
+ QSize minimumSizeHint() const;
+
+ bool isFlat() const;
+ void setFlat(bool flat);
+ bool isCheckable() const;
+ void setCheckable(bool checkable);
+ bool isChecked() const;
+
+public Q_SLOTS:
+ void setChecked(bool checked);
+
+Q_SIGNALS:
+ void clicked(bool checked = false);
+ void toggled(bool);
+
+protected:
+ bool event(QEvent *event);
+ void childEvent(QChildEvent *event);
+ void resizeEvent(QResizeEvent *event);
+ void paintEvent(QPaintEvent *event);
+ void focusInEvent(QFocusEvent *event);
+ void changeEvent(QEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *event);
+ void initStyleOption(QStyleOptionGroupBox *option) const;
+
+#ifdef QT3_SUPPORT
+public:
+ QT3_SUPPORT_CONSTRUCTOR QGroupBox(QWidget* parent, const char* name);
+ QT3_SUPPORT_CONSTRUCTOR QGroupBox(const QString &title, QWidget* parent, const char* name);
+#endif
+
+private:
+ Q_DISABLE_COPY(QGroupBox)
+ Q_DECLARE_PRIVATE(QGroupBox)
+ Q_PRIVATE_SLOT(d_func(), void _q_setChildrenEnabled(bool b))
+};
+
+#endif // QT_NO_GROUPBOX
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QGROUPBOX_H
diff --git a/src/gui/widgets/qlabel.cpp b/src/widgets/widgets/qlabel.cpp
index 4714d2f2c9..4714d2f2c9 100644
--- a/src/gui/widgets/qlabel.cpp
+++ b/src/widgets/widgets/qlabel.cpp
diff --git a/src/widgets/widgets/qlabel.h b/src/widgets/widgets/qlabel.h
new file mode 100644
index 0000000000..a355b087b4
--- /dev/null
+++ b/src/widgets/widgets/qlabel.h
@@ -0,0 +1,182 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLABEL_H
+#define QLABEL_H
+
+#include <QtWidgets/qframe.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QLabelPrivate;
+
+class Q_GUI_EXPORT QLabel : public QFrame
+{
+ Q_OBJECT
+ Q_PROPERTY(QString text READ text WRITE setText)
+ Q_PROPERTY(Qt::TextFormat textFormat READ textFormat WRITE setTextFormat)
+ Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)
+ Q_PROPERTY(bool scaledContents READ hasScaledContents WRITE setScaledContents)
+ Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
+ Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
+ Q_PROPERTY(int margin READ margin WRITE setMargin)
+ Q_PROPERTY(int indent READ indent WRITE setIndent)
+ Q_PROPERTY(bool openExternalLinks READ openExternalLinks WRITE setOpenExternalLinks)
+ Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
+ Q_PROPERTY(bool hasSelectedText READ hasSelectedText)
+ Q_PROPERTY(QString selectedText READ selectedText)
+
+public:
+ explicit QLabel(QWidget *parent=0, Qt::WindowFlags f=0);
+ explicit QLabel(const QString &text, QWidget *parent=0, Qt::WindowFlags f=0);
+ ~QLabel();
+
+ QString text() const;
+ const QPixmap *pixmap() const;
+#ifndef QT_NO_PICTURE
+ const QPicture *picture() const;
+#endif
+#ifndef QT_NO_MOVIE
+ QMovie *movie() const;
+#endif
+
+ Qt::TextFormat textFormat() const;
+ void setTextFormat(Qt::TextFormat);
+
+ Qt::Alignment alignment() const;
+ void setAlignment(Qt::Alignment);
+
+ void setWordWrap(bool on);
+ bool wordWrap() const;
+
+ int indent() const;
+ void setIndent(int);
+
+ int margin() const;
+ void setMargin(int);
+
+ bool hasScaledContents() const;
+ void setScaledContents(bool);
+ QSize sizeHint() const;
+ QSize minimumSizeHint() const;
+#ifndef QT_NO_SHORTCUT
+ void setBuddy(QWidget *);
+ QWidget *buddy() const;
+#endif
+ int heightForWidth(int) const;
+
+ bool openExternalLinks() const;
+ void setOpenExternalLinks(bool open);
+
+ void setTextInteractionFlags(Qt::TextInteractionFlags flags);
+ Qt::TextInteractionFlags textInteractionFlags() const;
+
+ void setSelection(int, int);
+ bool hasSelectedText() const;
+ QString selectedText() const;
+ int selectionStart() const;
+
+public Q_SLOTS:
+ void setText(const QString &);
+ void setPixmap(const QPixmap &);
+#ifndef QT_NO_PICTURE
+ void setPicture(const QPicture &);
+#endif
+#ifndef QT_NO_MOVIE
+ void setMovie(QMovie *movie);
+#endif
+ void setNum(int);
+ void setNum(double);
+ void clear();
+
+Q_SIGNALS:
+ void linkActivated(const QString& link);
+ void linkHovered(const QString& link);
+
+protected:
+ bool event(QEvent *e);
+ void keyPressEvent(QKeyEvent *ev);
+ void paintEvent(QPaintEvent *);
+ void changeEvent(QEvent *);
+ void mousePressEvent(QMouseEvent *ev);
+ void mouseMoveEvent(QMouseEvent *ev);
+ void mouseReleaseEvent(QMouseEvent *ev);
+ void contextMenuEvent(QContextMenuEvent *ev);
+ void focusInEvent(QFocusEvent *ev);
+ void focusOutEvent(QFocusEvent *ev);
+ bool focusNextPrevChild(bool next);
+
+#ifdef QT3_SUPPORT
+public:
+ QT3_SUPPORT_CONSTRUCTOR QLabel(QWidget *parent, const char* name, Qt::WindowFlags f=0);
+ QT3_SUPPORT_CONSTRUCTOR QLabel(const QString &text, QWidget *parent, const char* name,
+ Qt::WindowFlags f=0);
+ QT3_SUPPORT_CONSTRUCTOR QLabel(QWidget *buddy, const QString &,
+ QWidget *parent=0, const char* name=0, Qt::WindowFlags f=0);
+ QT3_SUPPORT void setAlignment(int alignment);
+
+ // don't mark the next function with QT3_SUPPORT
+ inline void setAlignment(Qt::AlignmentFlag flag) { setAlignment((Qt::Alignment)flag); }
+#endif
+
+private:
+ Q_DISABLE_COPY(QLabel)
+ Q_DECLARE_PRIVATE(QLabel)
+#ifndef QT_NO_MOVIE
+ Q_PRIVATE_SLOT(d_func(), void _q_movieUpdated(const QRect&))
+ Q_PRIVATE_SLOT(d_func(), void _q_movieResized(const QSize&))
+#endif
+ Q_PRIVATE_SLOT(d_func(), void _q_linkHovered(const QString &))
+
+ friend class QTipLabel;
+ friend class QMessageBoxPrivate;
+ friend class QBalloonTip;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QLABEL_H
diff --git a/src/gui/widgets/qlabel_p.h b/src/widgets/widgets/qlabel_p.h
index ea79c8d205..ea79c8d205 100644
--- a/src/gui/widgets/qlabel_p.h
+++ b/src/widgets/widgets/qlabel_p.h
diff --git a/src/gui/widgets/qlcdnumber.cpp b/src/widgets/widgets/qlcdnumber.cpp
index 2513718d8b..2513718d8b 100644
--- a/src/gui/widgets/qlcdnumber.cpp
+++ b/src/widgets/widgets/qlcdnumber.cpp
diff --git a/src/widgets/widgets/qlcdnumber.h b/src/widgets/widgets/qlcdnumber.h
new file mode 100644
index 0000000000..a2eacecc33
--- /dev/null
+++ b/src/widgets/widgets/qlcdnumber.h
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLCDNUMBER_H
+#define QLCDNUMBER_H
+
+#include <QtWidgets/qframe.h>
+#include <QtCore/qbitarray.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_LCDNUMBER
+
+class QLCDNumberPrivate;
+class Q_GUI_EXPORT QLCDNumber : public QFrame // LCD number widget
+{
+ Q_OBJECT
+ Q_ENUMS(Mode SegmentStyle)
+ Q_PROPERTY(bool smallDecimalPoint READ smallDecimalPoint WRITE setSmallDecimalPoint)
+ Q_PROPERTY(int numDigits READ numDigits WRITE setNumDigits)
+ Q_PROPERTY(int digitCount READ digitCount WRITE setDigitCount)
+ Q_PROPERTY(Mode mode READ mode WRITE setMode)
+ Q_PROPERTY(SegmentStyle segmentStyle READ segmentStyle WRITE setSegmentStyle)
+ Q_PROPERTY(double value READ value WRITE display)
+ Q_PROPERTY(int intValue READ intValue WRITE display)
+
+public:
+ explicit QLCDNumber(QWidget* parent = 0);
+ explicit QLCDNumber(uint numDigits, QWidget* parent = 0);
+ ~QLCDNumber();
+
+ enum Mode {
+ Hex, Dec, Oct, Bin
+#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
+ , HEX = Hex, DEC = Dec, OCT = Oct, BIN = Bin
+#endif
+ };
+ enum SegmentStyle {
+ Outline, Filled, Flat
+ };
+
+ bool smallDecimalPoint() const;
+#ifdef QT_DEPRECATED
+ QT_DEPRECATED int numDigits() const;
+ QT_DEPRECATED void setNumDigits(int nDigits);
+#endif
+ int digitCount() const;
+ void setDigitCount(int nDigits);
+
+ bool checkOverflow(double num) const;
+ bool checkOverflow(int num) const;
+
+ Mode mode() const;
+ void setMode(Mode);
+
+ SegmentStyle segmentStyle() const;
+ void setSegmentStyle(SegmentStyle);
+
+ double value() const;
+ int intValue() const;
+
+ QSize sizeHint() const;
+
+public Q_SLOTS:
+ void display(const QString &str);
+ void display(int num);
+ void display(double num);
+ void setHexMode();
+ void setDecMode();
+ void setOctMode();
+ void setBinMode();
+ void setSmallDecimalPoint(bool);
+
+Q_SIGNALS:
+ void overflow();
+
+protected:
+ bool event(QEvent *e);
+ void paintEvent(QPaintEvent *);
+
+public:
+#ifdef QT3_SUPPORT
+ QT3_SUPPORT_CONSTRUCTOR QLCDNumber(QWidget* parent, const char* name);
+ QT3_SUPPORT_CONSTRUCTOR QLCDNumber(uint numDigits, QWidget* parent, const char* name);
+
+ QT3_SUPPORT void setMargin(int margin) { setContentsMargins(margin, margin, margin, margin); }
+ QT3_SUPPORT int margin() const
+ { int margin; int dummy; getContentsMargins(&margin, &dummy, &dummy, &dummy); return margin; }
+#endif
+
+private:
+ Q_DISABLE_COPY(QLCDNumber)
+ Q_DECLARE_PRIVATE(QLCDNumber)
+};
+
+#endif // QT_NO_LCDNUMBER
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QLCDNUMBER_H
diff --git a/src/gui/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp
index 43c3f52d2b..43c3f52d2b 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/widgets/widgets/qlineedit.cpp
diff --git a/src/widgets/widgets/qlineedit.h b/src/widgets/widgets/qlineedit.h
new file mode 100644
index 0000000000..7f7a7287fb
--- /dev/null
+++ b/src/widgets/widgets/qlineedit.h
@@ -0,0 +1,299 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLINEEDIT_H
+#define QLINEEDIT_H
+
+#include <QtWidgets/qframe.h>
+#include <QtGui/qtextcursor.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qmargins.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_LINEEDIT
+
+class QValidator;
+class QMenu;
+class QLineEditPrivate;
+class QCompleter;
+class QStyleOptionFrame;
+class QAbstractSpinBox;
+class QDateTimeEdit;
+
+class Q_GUI_EXPORT QLineEdit : public QWidget
+{
+ Q_OBJECT
+
+ Q_ENUMS(EchoMode)
+ Q_PROPERTY(QString inputMask READ inputMask WRITE setInputMask)
+ Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged USER true)
+ Q_PROPERTY(int maxLength READ maxLength WRITE setMaxLength)
+ Q_PROPERTY(bool frame READ hasFrame WRITE setFrame)
+ Q_PROPERTY(EchoMode echoMode READ echoMode WRITE setEchoMode)
+ Q_PROPERTY(QString displayText READ displayText)
+ Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition)
+ Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
+ Q_PROPERTY(bool modified READ isModified WRITE setModified DESIGNABLE false)
+ Q_PROPERTY(bool hasSelectedText READ hasSelectedText)
+ Q_PROPERTY(QString selectedText READ selectedText)
+ Q_PROPERTY(bool dragEnabled READ dragEnabled WRITE setDragEnabled)
+ Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
+ Q_PROPERTY(bool undoAvailable READ isUndoAvailable)
+ Q_PROPERTY(bool redoAvailable READ isRedoAvailable)
+ Q_PROPERTY(bool acceptableInput READ hasAcceptableInput)
+ Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText)
+
+public:
+ explicit QLineEdit(QWidget* parent=0);
+ explicit QLineEdit(const QString &, QWidget* parent=0);
+#ifdef QT3_SUPPORT
+ QT3_SUPPORT_CONSTRUCTOR QLineEdit(QWidget* parent, const char* name);
+ QT3_SUPPORT_CONSTRUCTOR QLineEdit(const QString &, QWidget* parent, const char* name);
+ QT3_SUPPORT_CONSTRUCTOR QLineEdit(const QString &, const QString &, QWidget* parent=0, const char* name=0);
+#endif
+ ~QLineEdit();
+
+ QString text() const;
+
+ QString displayText() const;
+
+ QString placeholderText() const;
+ void setPlaceholderText(const QString &);
+
+ int maxLength() const;
+ void setMaxLength(int);
+
+ void setFrame(bool);
+ bool hasFrame() const;
+
+ enum EchoMode { Normal, NoEcho, Password, PasswordEchoOnEdit };
+ EchoMode echoMode() const;
+ void setEchoMode(EchoMode);
+
+ bool isReadOnly() const;
+ void setReadOnly(bool);
+
+#ifndef QT_NO_VALIDATOR
+ void setValidator(const QValidator *);
+ const QValidator * validator() const;
+#endif
+
+#ifndef QT_NO_COMPLETER
+ void setCompleter(QCompleter *completer);
+ QCompleter *completer() const;
+#endif
+
+ QSize sizeHint() const;
+ QSize minimumSizeHint() const;
+
+ int cursorPosition() const;
+ void setCursorPosition(int);
+ int cursorPositionAt(const QPoint &pos);
+
+ void setAlignment(Qt::Alignment flag);
+ Qt::Alignment alignment() const;
+
+ void cursorForward(bool mark, int steps = 1);
+ void cursorBackward(bool mark, int steps = 1);
+ void cursorWordForward(bool mark);
+ void cursorWordBackward(bool mark);
+ void backspace();
+ void del();
+ void home(bool mark);
+ void end(bool mark);
+
+ bool isModified() const;
+ void setModified(bool);
+
+ void setSelection(int, int);
+ bool hasSelectedText() const;
+ QString selectedText() const;
+ int selectionStart() const;
+
+ bool isUndoAvailable() const;
+ bool isRedoAvailable() const;
+
+ void setDragEnabled(bool b);
+ bool dragEnabled() const;
+
+ void setCursorMoveStyle(QTextCursor::MoveStyle style);
+ QTextCursor::MoveStyle cursorMoveStyle() const;
+
+ QString inputMask() const;
+ void setInputMask(const QString &inputMask);
+ bool hasAcceptableInput() const;
+
+ void setTextMargins(int left, int top, int right, int bottom);
+ void setTextMargins(const QMargins &margins);
+ void getTextMargins(int *left, int *top, int *right, int *bottom) const;
+ QMargins textMargins() const;
+
+public Q_SLOTS:
+ void setText(const QString &);
+ void clear();
+ void selectAll();
+ void undo();
+ void redo();
+#ifndef QT_NO_CLIPBOARD
+ void cut();
+ void copy() const;
+ void paste();
+#endif
+
+public:
+ void deselect();
+ void insert(const QString &);
+#ifndef QT_NO_CONTEXTMENU
+ QMenu *createStandardContextMenu();
+#endif
+
+Q_SIGNALS:
+ void textChanged(const QString &);
+ void textEdited(const QString &);
+ void cursorPositionChanged(int, int);
+ void returnPressed();
+ void editingFinished();
+ void selectionChanged();
+
+protected:
+ void mousePressEvent(QMouseEvent *);
+ void mouseMoveEvent(QMouseEvent *);
+ void mouseReleaseEvent(QMouseEvent *);
+ void mouseDoubleClickEvent(QMouseEvent *);
+ void keyPressEvent(QKeyEvent *);
+ void focusInEvent(QFocusEvent *);
+ void focusOutEvent(QFocusEvent *);
+ void paintEvent(QPaintEvent *);
+#ifndef QT_NO_DRAGANDDROP
+ void dragEnterEvent(QDragEnterEvent *);
+ void dragMoveEvent(QDragMoveEvent *e);
+ void dragLeaveEvent(QDragLeaveEvent *e);
+ void dropEvent(QDropEvent *);
+#endif
+ void changeEvent(QEvent *);
+#ifndef QT_NO_CONTEXTMENU
+ void contextMenuEvent(QContextMenuEvent *);
+#endif
+#ifdef QT3_SUPPORT
+ inline QT3_SUPPORT void repaintArea(int, int) { update(); }
+#endif
+
+ void inputMethodEvent(QInputMethodEvent *);
+ void initStyleOption(QStyleOptionFrame *option) const;
+public:
+ QVariant inputMethodQuery(Qt::InputMethodQuery) const;
+ bool event(QEvent *);
+protected:
+ QRect cursorRect() const;
+
+public:
+#ifdef QT3_SUPPORT
+ inline QT3_SUPPORT void clearModified() { setModified(false); }
+ inline QT3_SUPPORT void cursorLeft(bool mark, int steps = 1) { cursorForward(mark, -steps); }
+ inline QT3_SUPPORT void cursorRight(bool mark, int steps = 1) { cursorForward(mark, steps); }
+ QT3_SUPPORT bool validateAndSet(const QString &, int, int, int);
+ inline QT3_SUPPORT bool frame() const { return hasFrame(); }
+#ifndef QT_NO_VALIDATOR
+ inline QT3_SUPPORT void clearValidator() { setValidator(0); }
+#endif
+ inline QT3_SUPPORT bool hasMarkedText() const { return hasSelectedText(); }
+ inline QT3_SUPPORT QString markedText() const { return selectedText(); }
+ QT3_SUPPORT bool edited() const;
+ QT3_SUPPORT void setEdited(bool);
+ QT3_SUPPORT int characterAt(int, QChar*) const;
+ QT3_SUPPORT bool getSelection(int *, int *);
+
+ QT3_SUPPORT void setFrameRect(QRect) {}
+ QT3_SUPPORT QRect frameRect() const { return QRect(); }
+ enum DummyFrame { Box, Sunken, Plain, Raised, MShadow, NoFrame, Panel, StyledPanel,
+ HLine, VLine, GroupBoxPanel, WinPanel, ToolBarPanel, MenuBarPanel,
+ PopupPanel, LineEditPanel, TabWidgetPanel, MShape };
+ QT3_SUPPORT void setFrameShadow(DummyFrame) {}
+ QT3_SUPPORT DummyFrame frameShadow() const { return Plain; }
+ QT3_SUPPORT void setFrameShape(DummyFrame) {}
+ QT3_SUPPORT DummyFrame frameShape() const { return NoFrame; }
+ QT3_SUPPORT void setFrameStyle(int) {}
+ QT3_SUPPORT int frameStyle() const { return 0; }
+ QT3_SUPPORT int frameWidth() const { return 0; }
+ QT3_SUPPORT void setLineWidth(int) {}
+ QT3_SUPPORT int lineWidth() const { return 0; }
+ QT3_SUPPORT void setMargin(int margin) { setContentsMargins(margin, margin, margin, margin); }
+ QT3_SUPPORT int margin() const
+ { int margin; int dummy; getContentsMargins(&margin, &dummy, &dummy, &dummy); return margin; }
+ QT3_SUPPORT void setMidLineWidth(int) {}
+ QT3_SUPPORT int midLineWidth() const { return 0; }
+
+Q_SIGNALS:
+ QT_MOC_COMPAT void lostFocus();
+#endif
+
+private:
+ friend class QAbstractSpinBox;
+#ifdef QT_KEYPAD_NAVIGATION
+ friend class QDateTimeEdit;
+#endif
+ Q_DISABLE_COPY(QLineEdit)
+ Q_DECLARE_PRIVATE(QLineEdit)
+ Q_PRIVATE_SLOT(d_func(), void _q_handleWindowActivate())
+ Q_PRIVATE_SLOT(d_func(), void _q_textEdited(const QString &))
+ Q_PRIVATE_SLOT(d_func(), void _q_cursorPositionChanged(int, int))
+#ifndef QT_NO_COMPLETER
+ Q_PRIVATE_SLOT(d_func(), void _q_completionHighlighted(QString))
+#endif
+#ifdef QT_KEYPAD_NAVIGATION
+ Q_PRIVATE_SLOT(d_func(), void _q_editFocusChange(bool))
+#endif
+ Q_PRIVATE_SLOT(d_func(), void _q_selectionChanged())
+ Q_PRIVATE_SLOT(d_func(), void _q_updateNeeded(const QRect &))
+};
+
+#endif // QT_NO_LINEEDIT
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QLINEEDIT_H
diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp
new file mode 100644
index 0000000000..816689019d
--- /dev/null
+++ b/src/widgets/widgets/qlineedit_p.cpp
@@ -0,0 +1,292 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qlineedit.h"
+#include "qlineedit_p.h"
+
+#ifndef QT_NO_LINEEDIT
+
+#include "qabstractitemview.h"
+#include "qdrag.h"
+#include "qclipboard.h"
+#ifndef QT_NO_ACCESSIBILITY
+#include "qaccessible.h"
+#endif
+#ifndef QT_NO_IM
+#include "qinputcontext.h"
+#include "qlist.h"
+#endif
+
+QT_BEGIN_NAMESPACE
+
+const int QLineEditPrivate::verticalMargin(1);
+const int QLineEditPrivate::horizontalMargin(2);
+
+QRect QLineEditPrivate::adjustedControlRect(const QRect &rect) const
+{
+ QRect cr = adjustedContentsRect();
+ int cix = cr.x() - hscroll + horizontalMargin;
+ return rect.translated(QPoint(cix, vscroll));
+}
+
+int QLineEditPrivate::xToPos(int x, QTextLine::CursorPosition betweenOrOn) const
+{
+ QRect cr = adjustedContentsRect();
+ x-= cr.x() - hscroll + horizontalMargin;
+ return control->xToPos(x, betweenOrOn);
+}
+
+QRect QLineEditPrivate::cursorRect() const
+{
+ return adjustedControlRect(control->cursorRect());
+}
+
+#ifndef QT_NO_COMPLETER
+
+void QLineEditPrivate::_q_completionHighlighted(QString newText)
+{
+ Q_Q(QLineEdit);
+ if (control->completer()->completionMode() != QCompleter::InlineCompletion) {
+ q->setText(newText);
+ } else {
+ int c = control->cursor();
+ QString text = control->text();
+ q->setText(text.left(c) + newText.mid(c));
+ control->moveCursor(control->end(), false);
+ control->moveCursor(c, true);
+ }
+}
+
+#endif // QT_NO_COMPLETER
+
+void QLineEditPrivate::_q_handleWindowActivate()
+{
+ Q_Q(QLineEdit);
+ if (!q->hasFocus() && control->hasSelectedText())
+ control->deselect();
+}
+
+void QLineEditPrivate::_q_textEdited(const QString &text)
+{
+ Q_Q(QLineEdit);
+ emit q->textEdited(text);
+#ifndef QT_NO_COMPLETER
+ if (control->completer()
+ && control->completer()->completionMode() != QCompleter::InlineCompletion)
+ control->complete(-1); // update the popup on cut/paste/del
+#endif
+}
+
+void QLineEditPrivate::_q_cursorPositionChanged(int from, int to)
+{
+ Q_Q(QLineEdit);
+ q->update();
+ emit q->cursorPositionChanged(from, to);
+}
+
+#ifdef QT_KEYPAD_NAVIGATION
+void QLineEditPrivate::_q_editFocusChange(bool e)
+{
+ Q_Q(QLineEdit);
+ q->setEditFocus(e);
+}
+#endif
+
+void QLineEditPrivate::_q_selectionChanged()
+{
+ Q_Q(QLineEdit);
+ if (!control->text().isEmpty() && control->preeditAreaText().isEmpty()) {
+ QStyleOptionFrameV2 opt;
+ q->initStyleOption(&opt);
+ bool showCursor = control->hasSelectedText() ?
+ q->style()->styleHint(QStyle::SH_BlinkCursorWhenTextSelected, &opt, q):
+ q->hasFocus();
+ setCursorVisible(showCursor);
+ }
+
+ emit q->selectionChanged();
+}
+
+void QLineEditPrivate::_q_updateNeeded(const QRect &rect)
+{
+ q_func()->update(adjustedControlRect(rect));
+}
+
+void QLineEditPrivate::init(const QString& txt)
+{
+ Q_Q(QLineEdit);
+ control = new QLineControl(txt);
+ control->setFont(q->font());
+ QObject::connect(control, SIGNAL(textChanged(QString)),
+ q, SIGNAL(textChanged(QString)));
+ QObject::connect(control, SIGNAL(textEdited(QString)),
+ q, SLOT(_q_textEdited(QString)));
+ QObject::connect(control, SIGNAL(cursorPositionChanged(int,int)),
+ q, SLOT(_q_cursorPositionChanged(int,int)));
+ QObject::connect(control, SIGNAL(selectionChanged()),
+ q, SLOT(_q_selectionChanged()));
+ QObject::connect(control, SIGNAL(accepted()),
+ q, SIGNAL(returnPressed()));
+ QObject::connect(control, SIGNAL(editingFinished()),
+ q, SIGNAL(editingFinished()));
+#ifdef QT_KEYPAD_NAVIGATION
+ QObject::connect(control, SIGNAL(editFocusChange(bool)),
+ q, SLOT(_q_editFocusChange(bool)));
+#endif
+ QObject::connect(control, SIGNAL(cursorPositionChanged(int,int)),
+ q, SLOT(updateMicroFocus()));
+
+ QObject::connect(control, SIGNAL(textChanged(const QString &)),
+ q, SLOT(updateMicroFocus()));
+
+ // for now, going completely overboard with updates.
+ QObject::connect(control, SIGNAL(selectionChanged()),
+ q, SLOT(update()));
+
+ QObject::connect(control, SIGNAL(displayTextChanged(QString)),
+ q, SLOT(update()));
+
+ QObject::connect(control, SIGNAL(updateNeeded(QRect)),
+ q, SLOT(_q_updateNeeded(QRect)));
+
+ QStyleOptionFrameV2 opt;
+ q->initStyleOption(&opt);
+ control->setPasswordCharacter(q->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, q));
+#ifndef QT_NO_CURSOR
+ q->setCursor(Qt::IBeamCursor);
+#endif
+ q->setFocusPolicy(Qt::StrongFocus);
+ q->setAttribute(Qt::WA_InputMethodEnabled);
+ // Specifies that this widget can use more, but is able to survive on
+ // less, horizontal space; and is fixed vertically.
+ q->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed, QSizePolicy::LineEdit));
+ q->setBackgroundRole(QPalette::Base);
+ q->setAttribute(Qt::WA_KeyCompression);
+ q->setMouseTracking(true);
+ q->setAcceptDrops(true);
+
+ q->setAttribute(Qt::WA_MacShowFocusRect);
+}
+
+QRect QLineEditPrivate::adjustedContentsRect() const
+{
+ Q_Q(const QLineEdit);
+ QStyleOptionFrameV2 opt;
+ q->initStyleOption(&opt);
+ QRect r = q->style()->subElementRect(QStyle::SE_LineEditContents, &opt, q);
+ r.setX(r.x() + leftTextMargin);
+ r.setY(r.y() + topTextMargin);
+ r.setRight(r.right() - rightTextMargin);
+ r.setBottom(r.bottom() - bottomTextMargin);
+ return r;
+}
+
+void QLineEditPrivate::setCursorVisible(bool visible)
+{
+ Q_Q(QLineEdit);
+ if ((bool)cursorVisible == visible)
+ return;
+ cursorVisible = visible;
+ if (control->inputMask().isEmpty())
+ q->update(cursorRect());
+ else
+ q->update();
+}
+
+void QLineEditPrivate::updatePasswordEchoEditing(bool editing)
+{
+ Q_Q(QLineEdit);
+ control->updatePasswordEchoEditing(editing);
+ q->setAttribute(Qt::WA_InputMethodEnabled, shouldEnableInputMethod());
+}
+
+/*!
+ This function is not intended as polymorphic usage. Just a shared code
+ fragment that calls QInputContext::mouseHandler for this
+ class.
+*/
+bool QLineEditPrivate::sendMouseEventToInputContext( QMouseEvent *e )
+{
+#if !defined QT_NO_IM
+ Q_Q(QLineEdit);
+ if ( control->composeMode() ) {
+ int tmp_cursor = xToPos(e->pos().x());
+ int mousePos = tmp_cursor - control->cursor();
+ if ( mousePos < 0 || mousePos > control->preeditAreaText().length() ) {
+ mousePos = -1;
+ // don't send move events outside the preedit area
+ if ( e->type() == QEvent::MouseMove )
+ return true;
+ }
+
+ QInputContext *qic = q->inputContext();
+ if ( qic )
+ // may be causing reset() in some input methods
+ qic->mouseHandler(mousePos, e);
+ if (!control->preeditAreaText().isEmpty())
+ return true;
+ }
+#else
+ Q_UNUSED(e);
+#endif
+
+ return false;
+}
+
+#ifndef QT_NO_DRAGANDDROP
+void QLineEditPrivate::drag()
+{
+ Q_Q(QLineEdit);
+ dndTimer.stop();
+ QMimeData *data = new QMimeData;
+ data->setText(control->selectedText());
+ QDrag *drag = new QDrag(q);
+ drag->setMimeData(data);
+ Qt::DropAction action = drag->start();
+ if (action == Qt::MoveAction && !control->isReadOnly() && drag->target() != q)
+ control->removeSelection();
+}
+
+#endif // QT_NO_DRAGANDDROP
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/widgets/widgets/qlineedit_p.h b/src/widgets/widgets/qlineedit_p.h
new file mode 100644
index 0000000000..b3ec575c86
--- /dev/null
+++ b/src/widgets/widgets/qlineedit_p.h
@@ -0,0 +1,156 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QLINEEDIT_P_H
+#define QLINEEDIT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "QtCore/qglobal.h"
+
+#ifndef QT_NO_LINEEDIT
+#include "private/qwidget_p.h"
+#include "QtWidgets/qlineedit.h"
+#include "QtGui/qtextlayout.h"
+#include "QtWidgets/qstyleoption.h"
+#include "QtCore/qbasictimer.h"
+#include "QtWidgets/qcompleter.h"
+#include "QtCore/qpointer.h"
+#include "QtWidgets/qlineedit.h"
+
+#include "private/qlinecontrol_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QLineEditPrivate : public QWidgetPrivate
+{
+ Q_DECLARE_PUBLIC(QLineEdit)
+public:
+
+ QLineEditPrivate()
+ : control(0), frame(1), contextMenuEnabled(1), cursorVisible(0),
+ dragEnabled(0), clickCausedFocus(0), hscroll(0), vscroll(0),
+ alignment(Qt::AlignLeading | Qt::AlignVCenter),
+ leftTextMargin(0), topTextMargin(0), rightTextMargin(0), bottomTextMargin(0)
+ {
+ }
+
+ ~QLineEditPrivate()
+ {
+ delete control;
+ }
+
+ QLineControl *control;
+
+#ifndef QT_NO_CONTEXTMENU
+ QPointer<QAction> selectAllAction;
+#endif
+ void init(const QString&);
+
+ QRect adjustedControlRect(const QRect &) const;
+
+ int xToPos(int x, QTextLine::CursorPosition = QTextLine::CursorBetweenCharacters) const;
+ QRect cursorRect() const;
+ void setCursorVisible(bool visible);
+
+ void updatePasswordEchoEditing(bool);
+
+ inline bool shouldEnableInputMethod() const
+ {
+ return !control->isReadOnly();
+ }
+
+ QPoint tripleClick;
+ QBasicTimer tripleClickTimer;
+ uint frame : 1;
+ uint contextMenuEnabled : 1;
+ uint cursorVisible : 1;
+ uint dragEnabled : 1;
+ uint clickCausedFocus : 1;
+ int hscroll;
+ int vscroll;
+ uint alignment;
+ static const int verticalMargin;
+ static const int horizontalMargin;
+
+ bool sendMouseEventToInputContext(QMouseEvent *e);
+
+ QRect adjustedContentsRect() const;
+
+ void _q_handleWindowActivate();
+ void _q_textEdited(const QString &);
+ void _q_cursorPositionChanged(int, int);
+#ifdef QT_KEYPAD_NAVIGATION
+ void _q_editFocusChange(bool);
+#endif
+ void _q_selectionChanged();
+ void _q_updateNeeded(const QRect &);
+#ifndef QT_NO_COMPLETER
+ void _q_completionHighlighted(QString);
+#endif
+#ifndef QT_NO_DRAGANDDROP
+ QPoint dndPos;
+ QBasicTimer dndTimer;
+ void drag();
+#endif
+
+ int leftTextMargin;
+ int topTextMargin;
+ int rightTextMargin;
+ int bottomTextMargin;
+
+ QString placeholderText;
+};
+
+#endif // QT_NO_LINEEDIT
+
+QT_END_NAMESPACE
+
+#endif // QLINEEDIT_P_H
diff --git a/src/widgets/widgets/qmaccocoaviewcontainer_mac.h b/src/widgets/widgets/qmaccocoaviewcontainer_mac.h
new file mode 100644
index 0000000000..eb5997c95f
--- /dev/null
+++ b/src/widgets/widgets/qmaccocoaviewcontainer_mac.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QCOCOAVIEWCONTAINER_H
+#define QCOCOAVIEWCONTAINER_H
+
+#include <QtWidgets/QWidget>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QMacCocoaViewContainerPrivate;
+
+class Q_GUI_EXPORT QMacCocoaViewContainer : public QWidget
+{
+ Q_OBJECT
+public:
+ QMacCocoaViewContainer(void *cocoaViewToWrap, QWidget *parent = 0);
+ virtual ~QMacCocoaViewContainer();
+
+ void setCocoaView(void *cocoaViewToWrap);
+ void *cocoaView() const;
+
+private:
+ Q_DECLARE_PRIVATE(QMacCocoaViewContainer)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QCOCOAVIEWCONTAINER_H
diff --git a/src/gui/widgets/qmaccocoaviewcontainer_mac.mm b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
index cefc93f734..cefc93f734 100644
--- a/src/gui/widgets/qmaccocoaviewcontainer_mac.mm
+++ b/src/widgets/widgets/qmaccocoaviewcontainer_mac.mm
diff --git a/src/widgets/widgets/qmacnativewidget_mac.h b/src/widgets/widgets/qmacnativewidget_mac.h
new file mode 100644
index 0000000000..c824f626d2
--- /dev/null
+++ b/src/widgets/widgets/qmacnativewidget_mac.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMACNATIVEWIDGET_H
+#define QMACNATIVEWIDGET_H
+
+#include <QtWidgets/QWidget>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QMacNativeWidgetPrivate;
+class Q_GUI_EXPORT QMacNativeWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ QMacNativeWidget(void *parentRef = 0);
+ ~QMacNativeWidget();
+
+ QSize sizeHint() const;
+
+protected:
+ bool event(QEvent *ev);
+
+private:
+ Q_DECLARE_PRIVATE(QMacNativeWidget)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QMACNATIVEWIDGET_H
diff --git a/src/gui/widgets/qmacnativewidget_mac.mm b/src/widgets/widgets/qmacnativewidget_mac.mm
index d71fedd2a8..d71fedd2a8 100644
--- a/src/gui/widgets/qmacnativewidget_mac.mm
+++ b/src/widgets/widgets/qmacnativewidget_mac.mm
diff --git a/src/gui/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index 43d67962e8..43d67962e8 100644
--- a/src/gui/widgets/qmainwindow.cpp
+++ b/src/widgets/widgets/qmainwindow.cpp
diff --git a/src/widgets/widgets/qmainwindow.h b/src/widgets/widgets/qmainwindow.h
new file mode 100644
index 0000000000..73d7436805
--- /dev/null
+++ b/src/widgets/widgets/qmainwindow.h
@@ -0,0 +1,219 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDYNAMICMAINWINDOW_H
+#define QDYNAMICMAINWINDOW_H
+
+#include <QtWidgets/qwidget.h>
+#include <QtWidgets/qtabwidget.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_MAINWINDOW
+
+class QDockWidget;
+class QMainWindowPrivate;
+class QMenuBar;
+class QStatusBar;
+class QToolBar;
+class QMenu;
+
+class Q_GUI_EXPORT QMainWindow : public QWidget
+{
+ Q_OBJECT
+
+ Q_ENUMS(DockOption)
+ Q_FLAGS(DockOptions)
+ Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
+ Q_PROPERTY(Qt::ToolButtonStyle toolButtonStyle READ toolButtonStyle WRITE setToolButtonStyle)
+#ifndef QT_NO_DOCKWIDGET
+ Q_PROPERTY(bool animated READ isAnimated WRITE setAnimated)
+#ifndef QT_NO_TABBAR
+ Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode)
+#endif // QT_NO_TABBAR
+#ifndef QT_NO_TABWIDGET
+ Q_PROPERTY(QTabWidget::TabShape tabShape READ tabShape WRITE setTabShape)
+#endif // QT_NO_TABWIDGET
+ Q_PROPERTY(bool dockNestingEnabled READ isDockNestingEnabled WRITE setDockNestingEnabled)
+#endif // QT_NO_DOCKWIDGET
+ Q_PROPERTY(DockOptions dockOptions READ dockOptions WRITE setDockOptions)
+#ifndef QT_NO_TOOLBAR
+ Q_PROPERTY(bool unifiedTitleAndToolBarOnMac READ unifiedTitleAndToolBarOnMac WRITE setUnifiedTitleAndToolBarOnMac)
+#endif
+
+public:
+ enum DockOption {
+ AnimatedDocks = 0x01,
+ AllowNestedDocks = 0x02,
+ AllowTabbedDocks = 0x04,
+ ForceTabbedDocks = 0x08, // implies AllowTabbedDocks, !AllowNestedDocks
+ VerticalTabs = 0x10 // implies AllowTabbedDocks
+ };
+ Q_DECLARE_FLAGS(DockOptions, DockOption)
+
+ explicit QMainWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0);
+ ~QMainWindow();
+
+ QSize iconSize() const;
+ void setIconSize(const QSize &iconSize);
+
+ Qt::ToolButtonStyle toolButtonStyle() const;
+ void setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle);
+
+#ifndef QT_NO_DOCKWIDGET
+ bool isAnimated() const;
+ bool isDockNestingEnabled() const;
+#endif
+
+#ifndef QT_NO_TABBAR
+ bool documentMode() const;
+ void setDocumentMode(bool enabled);
+#endif
+
+#ifndef QT_NO_TABWIDGET
+ QTabWidget::TabShape tabShape() const;
+ void setTabShape(QTabWidget::TabShape tabShape);
+ QTabWidget::TabPosition tabPosition(Qt::DockWidgetArea area) const;
+ void setTabPosition(Qt::DockWidgetAreas areas, QTabWidget::TabPosition tabPosition);
+#endif // QT_NO_TABWIDGET
+
+ void setDockOptions(DockOptions options);
+ DockOptions dockOptions() const;
+
+ bool isSeparator(const QPoint &pos) const;
+
+#ifndef QT_NO_MENUBAR
+ QMenuBar *menuBar() const;
+ void setMenuBar(QMenuBar *menubar);
+
+ QWidget *menuWidget() const;
+ void setMenuWidget(QWidget *menubar);
+#endif
+
+#ifndef QT_NO_STATUSBAR
+ QStatusBar *statusBar() const;
+ void setStatusBar(QStatusBar *statusbar);
+#endif
+
+ QWidget *centralWidget() const;
+ void setCentralWidget(QWidget *widget);
+
+#ifndef QT_NO_DOCKWIDGET
+ void setCorner(Qt::Corner corner, Qt::DockWidgetArea area);
+ Qt::DockWidgetArea corner(Qt::Corner corner) const;
+#endif
+
+#ifndef QT_NO_TOOLBAR
+ void addToolBarBreak(Qt::ToolBarArea area = Qt::TopToolBarArea);
+ void insertToolBarBreak(QToolBar *before);
+
+ void addToolBar(Qt::ToolBarArea area, QToolBar *toolbar);
+ void addToolBar(QToolBar *toolbar);
+ QToolBar *addToolBar(const QString &title);
+ void insertToolBar(QToolBar *before, QToolBar *toolbar);
+ void removeToolBar(QToolBar *toolbar);
+ void removeToolBarBreak(QToolBar *before);
+
+ void setUnifiedTitleAndToolBarOnMac(bool set);
+ bool unifiedTitleAndToolBarOnMac() const;
+
+ Qt::ToolBarArea toolBarArea(QToolBar *toolbar) const;
+ bool toolBarBreak(QToolBar *toolbar) const;
+#endif
+#ifndef QT_NO_DOCKWIDGET
+ void addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget);
+ void addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget,
+ Qt::Orientation orientation);
+ void splitDockWidget(QDockWidget *after, QDockWidget *dockwidget,
+ Qt::Orientation orientation);
+ void tabifyDockWidget(QDockWidget *first, QDockWidget *second);
+ QList<QDockWidget*> tabifiedDockWidgets(QDockWidget *dockwidget) const;
+ void removeDockWidget(QDockWidget *dockwidget);
+ bool restoreDockWidget(QDockWidget *dockwidget);
+
+ Qt::DockWidgetArea dockWidgetArea(QDockWidget *dockwidget) const;
+#endif // QT_NO_DOCKWIDGET
+
+ QByteArray saveState(int version = 0) const;
+ bool restoreState(const QByteArray &state, int version = 0);
+
+#ifndef QT_NO_MENU
+ virtual QMenu *createPopupMenu();
+#endif
+
+#ifdef QT3_SUPPORT
+ QT3_SUPPORT_CONSTRUCTOR QMainWindow(QWidget *parent, const char *name, Qt::WindowFlags flags = 0);
+#endif
+
+#ifndef QT_NO_DOCKWIDGET
+public Q_SLOTS:
+ void setAnimated(bool enabled);
+ void setDockNestingEnabled(bool enabled);
+#endif
+
+Q_SIGNALS:
+ void iconSizeChanged(const QSize &iconSize);
+ void toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle);
+
+protected:
+#ifndef QT_NO_CONTEXTMENU
+ void contextMenuEvent(QContextMenuEvent *event);
+#endif
+ bool event(QEvent *event);
+
+private:
+ Q_DECLARE_PRIVATE(QMainWindow)
+ Q_DISABLE_COPY(QMainWindow)
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QMainWindow::DockOptions)
+
+#endif // QT_NO_MAINWINDOW
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDYNAMICMAINWINDOW_H
diff --git a/src/gui/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp
index d4afe075be..d4afe075be 100644
--- a/src/gui/widgets/qmainwindowlayout.cpp
+++ b/src/widgets/widgets/qmainwindowlayout.cpp
diff --git a/src/gui/widgets/qmainwindowlayout_mac.mm b/src/widgets/widgets/qmainwindowlayout_mac.mm
index 761a4337e1..761a4337e1 100644
--- a/src/gui/widgets/qmainwindowlayout_mac.mm
+++ b/src/widgets/widgets/qmainwindowlayout_mac.mm
diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h
new file mode 100644
index 0000000000..7d287c3038
--- /dev/null
+++ b/src/widgets/widgets/qmainwindowlayout_p.h
@@ -0,0 +1,357 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDYNAMICMAINWINDOWLAYOUT_P_H
+#define QDYNAMICMAINWINDOWLAYOUT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qmainwindow.h"
+
+#ifndef QT_NO_MAINWINDOW
+
+#include "QtWidgets/qlayout.h"
+#include "QtWidgets/qtabbar.h"
+#include "QtCore/qvector.h"
+#include "QtCore/qset.h"
+#include "QtCore/qbasictimer.h"
+#include "private/qlayoutengine_p.h"
+#include "private/qwidgetanimator_p.h"
+
+#include "qdockarealayout_p.h"
+#include "qtoolbararealayout_p.h"
+
+//#define Q_DEBUG_MAINWINDOW_LAYOUT
+
+#if defined(Q_DEBUG_MAINWINDOW_LAYOUT) && !defined(QT_NO_DOCKWIDGET)
+QT_BEGIN_NAMESPACE
+class QTextStream;
+Q_GUI_EXPORT void qt_dumpLayout(QTextStream &qout, QMainWindow *window);
+QT_END_NAMESPACE
+#endif // Q_DEBUG_MAINWINDOW_LAYOUT && !QT_NO_DOCKWIDGET
+
+#ifdef Q_WS_MAC
+// Forward defs to make avoid including Carbon.h (faster compile you know ;).
+struct OpaqueHIObjectRef;
+typedef struct OpaqueHIObjectRef* HIObjectRef;
+typedef HIObjectRef HIToolbarItemRef;
+typedef const void * CFTypeRef;
+typedef const struct __CFString * CFStringRef;
+
+# ifdef QT_MAC_USE_COCOA
+#include <private/qunifiedtoolbarsurface_mac_p.h>
+# endif // QT_MAC_USE_COCOA
+
+#endif // Q_WS_MAC
+
+QT_BEGIN_NAMESPACE
+
+class QToolBar;
+class QRubberBand;
+
+/* This data structure represents the state of all the tool-bars and dock-widgets. It's value based
+ so it can be easilly copied into a temporary variable. All operations are performed without moving
+ any widgets. Only when we are sure we have the desired state, we call apply(), which moves the
+ widgets.
+*/
+
+class QMainWindowLayoutState
+{
+public:
+ QRect rect;
+ QMainWindow *mainWindow;
+
+ QMainWindowLayoutState(QMainWindow *win);
+
+#ifndef QT_NO_TOOLBAR
+ QToolBarAreaLayout toolBarAreaLayout;
+#endif
+
+#ifndef QT_NO_DOCKWIDGET
+ QDockAreaLayout dockAreaLayout;
+#else
+ QLayoutItem *centralWidgetItem;
+ QRect centralWidgetRect;
+#endif
+
+ void apply(bool animated);
+ void deleteAllLayoutItems();
+ void deleteCentralWidgetItem();
+
+ QSize sizeHint() const;
+ QSize minimumSize() const;
+ void fitLayout();
+
+ QLayoutItem *itemAt(int index, int *x) const;
+ QLayoutItem *takeAt(int index, int *x);
+ QList<int> indexOf(QWidget *widget) const;
+ QLayoutItem *item(const QList<int> &path);
+ QRect itemRect(const QList<int> &path) const;
+ QRect gapRect(const QList<int> &path) const; // ### get rid of this, use itemRect() instead
+
+ bool contains(QWidget *widget) const;
+
+ void setCentralWidget(QWidget *widget);
+ QWidget *centralWidget() const;
+
+ QList<int> gapIndex(QWidget *widget, const QPoint &pos) const;
+ bool insertGap(const QList<int> &path, QLayoutItem *item);
+ void remove(const QList<int> &path);
+ void remove(QLayoutItem *item);
+ void clear();
+ bool isValid() const;
+
+ QLayoutItem *plug(const QList<int> &path);
+ QLayoutItem *unplug(const QList<int> &path, QMainWindowLayoutState *savedState = 0);
+
+ void saveState(QDataStream &stream) const;
+ bool checkFormat(QDataStream &stream, bool pre43);
+ bool restoreState(QDataStream &stream, const QMainWindowLayoutState &oldState);
+};
+
+class Q_AUTOTEST_EXPORT QMainWindowLayout : public QLayout
+{
+ Q_OBJECT
+
+public:
+ QMainWindowLayoutState layoutState, savedState;
+
+ QMainWindowLayout(QMainWindow *mainwindow, QLayout *parentLayout);
+ ~QMainWindowLayout();
+
+ QMainWindow::DockOptions dockOptions;
+ void setDockOptions(QMainWindow::DockOptions opts);
+ bool usesHIToolBar(QToolBar *toolbar) const;
+
+ void timerEvent(QTimerEvent *e);
+
+ // status bar
+
+ QLayoutItem *statusbar;
+
+#ifndef QT_NO_STATUSBAR
+ QStatusBar *statusBar() const;
+ void setStatusBar(QStatusBar *sb);
+#endif
+
+ // central widget
+
+ QWidget *centralWidget() const;
+ void setCentralWidget(QWidget *cw);
+
+ // toolbars
+
+#ifndef QT_NO_TOOLBAR
+ void addToolBarBreak(Qt::ToolBarArea area);
+ void insertToolBarBreak(QToolBar *before);
+ void removeToolBarBreak(QToolBar *before);
+
+ void addToolBar(Qt::ToolBarArea area, QToolBar *toolbar, bool needAddChildWidget = true);
+ void insertToolBar(QToolBar *before, QToolBar *toolbar);
+ Qt::ToolBarArea toolBarArea(QToolBar *toolbar) const;
+ bool toolBarBreak(QToolBar *toolBar) const;
+ void getStyleOptionInfo(QStyleOptionToolBar *option, QToolBar *toolBar) const;
+ void removeToolBar(QToolBar *toolbar);
+ void toggleToolBarsVisible();
+ void moveToolBar(QToolBar *toolbar, int pos);
+#endif
+
+ // dock widgets
+
+#ifndef QT_NO_DOCKWIDGET
+ void setCorner(Qt::Corner corner, Qt::DockWidgetArea area);
+ Qt::DockWidgetArea corner(Qt::Corner corner) const;
+ void addDockWidget(Qt::DockWidgetArea area,
+ QDockWidget *dockwidget,
+ Qt::Orientation orientation);
+ void splitDockWidget(QDockWidget *after,
+ QDockWidget *dockwidget,
+ Qt::Orientation orientation);
+ void tabifyDockWidget(QDockWidget *first, QDockWidget *second);
+ Qt::DockWidgetArea dockWidgetArea(QDockWidget *dockwidget) const;
+ void raise(QDockWidget *widget);
+ void setVerticalTabsEnabled(bool enabled);
+ bool restoreDockWidget(QDockWidget *dockwidget);
+
+#ifndef QT_NO_TABBAR
+ bool _documentMode;
+ bool documentMode() const;
+ void setDocumentMode(bool enabled);
+
+ QTabBar *getTabBar();
+ QSet<QTabBar*> usedTabBars;
+ QList<QTabBar*> unusedTabBars;
+ bool verticalTabsEnabled;
+
+ QWidget *getSeparatorWidget();
+ QSet<QWidget*> usedSeparatorWidgets;
+ QList<QWidget*> unusedSeparatorWidgets;
+ int sep; // separator extent
+
+#ifndef QT_NO_TABWIDGET
+ QTabWidget::TabPosition tabPositions[4];
+ QTabWidget::TabShape _tabShape;
+
+ QTabWidget::TabShape tabShape() const;
+ void setTabShape(QTabWidget::TabShape tabShape);
+ QTabWidget::TabPosition tabPosition(Qt::DockWidgetArea area) const;
+ void setTabPosition(Qt::DockWidgetAreas areas, QTabWidget::TabPosition tabPosition);
+#endif // QT_NO_TABWIDGET
+#endif // QT_NO_TABBAR
+
+ // separators
+
+ QList<int> movingSeparator;
+ QPoint movingSeparatorOrigin, movingSeparatorPos;
+ QBasicTimer separatorMoveTimer;
+
+ bool startSeparatorMove(const QPoint &pos);
+ bool separatorMove(const QPoint &pos);
+ bool endSeparatorMove(const QPoint &pos);
+ void keepSize(QDockWidget *w);
+#endif // QT_NO_DOCKWIDGET
+
+ // save/restore
+
+ enum { // sentinel values used to validate state data
+ VersionMarker = 0xff
+ };
+ void saveState(QDataStream &stream) const;
+ bool restoreState(QDataStream &stream);
+
+ // QLayout interface
+
+ void addItem(QLayoutItem *item);
+ void setGeometry(const QRect &r);
+ QLayoutItem *itemAt(int index) const;
+ QLayoutItem *takeAt(int index);
+ int count() const;
+
+ QSize sizeHint() const;
+ QSize minimumSize() const;
+ mutable QSize szHint;
+ mutable QSize minSize;
+ void invalidate();
+
+ // animations
+
+ QWidgetAnimator widgetAnimator;
+ QList<int> currentGapPos;
+ QRect currentGapRect;
+ QWidget *pluggingWidget;
+#ifndef QT_NO_RUBBERBAND
+ QRubberBand *gapIndicator;
+#endif
+
+ QList<int> hover(QLayoutItem *widgetItem, const QPoint &mousePos);
+ bool plug(QLayoutItem *widgetItem);
+ QLayoutItem *unplug(QWidget *widget);
+ void revert(QLayoutItem *widgetItem);
+ void updateGapIndicator();
+ void paintDropIndicator(QPainter *p, QWidget *widget, const QRegion &clip);
+ void applyState(QMainWindowLayoutState &newState, bool animate = true);
+ void restore(bool keepSavedState = false);
+ void updateHIToolBarStatus();
+ void animationFinished(QWidget *widget);
+
+private Q_SLOTS:
+#ifndef QT_NO_DOCKWIDGET
+#ifndef QT_NO_TABBAR
+ void tabChanged();
+#endif
+#endif
+private:
+#ifndef QT_NO_TABBAR
+ void updateTabBarShapes();
+#endif
+#ifdef Q_WS_MAC
+# ifndef QT_MAC_USE_COCOA
+ static OSStatus qtmacToolbarDelegate(EventHandlerCallRef, EventRef , void *);
+ static OSStatus qtoolbarInHIToolbarHandler(EventHandlerCallRef inCallRef, EventRef event,
+ void *data);
+ static void qtMacHIToolbarRegisterQToolBarInHIToolborItemClass();
+ static HIToolbarItemRef CreateToolbarItemForIdentifier(CFStringRef identifier, CFTypeRef data);
+ static HIToolbarItemRef createQToolBarInHIToolbarItem(QToolBar *toolbar,
+ QMainWindowLayout *layout);
+# endif
+public:
+ struct ToolBarSaveState {
+ ToolBarSaveState() : movable(false) { }
+ ToolBarSaveState(bool newMovable, const QSize &newMax)
+ : movable(newMovable), maximumSize(newMax) { }
+ bool movable;
+ QSize maximumSize;
+ };
+ QList<QToolBar *> qtoolbarsInUnifiedToolbarList;
+ QList<void *> toolbarItemsCopy;
+ QHash<void *, QToolBar *> unifiedToolbarHash;
+ QHash<QToolBar *, ToolBarSaveState> toolbarSaveState;
+ QHash<QString, QToolBar *> cocoaItemIDToToolbarHash;
+ void insertIntoMacToolbar(QToolBar *before, QToolBar *after);
+ void removeFromMacToolbar(QToolBar *toolbar);
+ void cleanUpMacToolbarItems();
+ void fixSizeInUnifiedToolbar(QToolBar *tb) const;
+ bool useHIToolBar;
+ bool activateUnifiedToolbarAfterFullScreen;
+ void syncUnifiedToolbarVisibility();
+ bool blockVisiblityCheck;
+
+#ifdef QT_MAC_USE_COCOA
+ QUnifiedToolbarSurface *unifiedSurface;
+ void updateUnifiedToolbarOffset();
+#endif // QT_MAC_USE_COCOA
+
+#endif // Q_WS_MAC
+};
+QT_END_NAMESPACE
+
+#endif // QT_NO_MAINWINDOW
+
+#endif // QDYNAMICMAINWINDOWLAYOUT_P_H
diff --git a/src/gui/widgets/qmdiarea.cpp b/src/widgets/widgets/qmdiarea.cpp
index 2a486bba18..2a486bba18 100644
--- a/src/gui/widgets/qmdiarea.cpp
+++ b/src/widgets/widgets/qmdiarea.cpp
diff --git a/src/widgets/widgets/qmdiarea.h b/src/widgets/widgets/qmdiarea.h
new file mode 100644
index 0000000000..de64e11027
--- /dev/null
+++ b/src/widgets/widgets/qmdiarea.h
@@ -0,0 +1,179 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMDIAREA_H
+#define QMDIAREA_H
+
+#include <QtWidgets/qabstractscrollarea.h>
+#include <QtWidgets/qtabwidget.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_MDIAREA
+
+class QMdiSubWindow;
+
+class QMdiAreaPrivate;
+class Q_GUI_EXPORT QMdiArea : public QAbstractScrollArea
+{
+ Q_OBJECT
+ Q_ENUMS(ViewMode)
+ Q_PROPERTY(QBrush background READ background WRITE setBackground)
+ Q_PROPERTY(WindowOrder activationOrder READ activationOrder WRITE setActivationOrder)
+ Q_PROPERTY(ViewMode viewMode READ viewMode WRITE setViewMode)
+#ifndef QT_NO_TABBAR
+ Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode)
+ Q_PROPERTY(bool tabsClosable READ tabsClosable WRITE setTabsClosable)
+ Q_PROPERTY(bool tabsMovable READ tabsMovable WRITE setTabsMovable)
+#endif
+#ifndef QT_NO_TABWIDGET
+ Q_PROPERTY(QTabWidget::TabShape tabShape READ tabShape WRITE setTabShape)
+ Q_PROPERTY(QTabWidget::TabPosition tabPosition READ tabPosition WRITE setTabPosition)
+#endif
+ Q_ENUMS(WindowOrder)
+public:
+ enum AreaOption {
+ DontMaximizeSubWindowOnActivation = 0x1
+ };
+ Q_DECLARE_FLAGS(AreaOptions, AreaOption)
+
+ enum WindowOrder {
+ CreationOrder,
+ StackingOrder,
+ ActivationHistoryOrder
+ };
+
+ enum ViewMode {
+ SubWindowView,
+ TabbedView
+ };
+
+ QMdiArea(QWidget *parent = 0);
+ ~QMdiArea();
+
+ QSize sizeHint() const;
+ QSize minimumSizeHint() const;
+
+ QMdiSubWindow *currentSubWindow() const;
+ QMdiSubWindow *activeSubWindow() const;
+ QList<QMdiSubWindow *> subWindowList(WindowOrder order = CreationOrder) const;
+
+ QMdiSubWindow *addSubWindow(QWidget *widget, Qt::WindowFlags flags = 0);
+ void removeSubWindow(QWidget *widget);
+
+ QBrush background() const;
+ void setBackground(const QBrush &background);
+
+ WindowOrder activationOrder() const;
+ void setActivationOrder(WindowOrder order);
+
+ void setOption(AreaOption option, bool on = true);
+ bool testOption(AreaOption opton) const;
+
+ void setViewMode(ViewMode mode);
+ ViewMode viewMode() const;
+
+#ifndef QT_NO_TABBAR
+ bool documentMode() const;
+ void setDocumentMode(bool enabled);
+
+ void setTabsClosable(bool closable);
+ bool tabsClosable() const;
+
+ void setTabsMovable(bool movable);
+ bool tabsMovable() const;
+#endif
+#ifndef QT_NO_TABWIDGET
+ void setTabShape(QTabWidget::TabShape shape);
+ QTabWidget::TabShape tabShape() const;
+
+ void setTabPosition(QTabWidget::TabPosition position);
+ QTabWidget::TabPosition tabPosition() const;
+#endif
+
+Q_SIGNALS:
+ void subWindowActivated(QMdiSubWindow *);
+
+public Q_SLOTS:
+ void setActiveSubWindow(QMdiSubWindow *window);
+ void tileSubWindows();
+ void cascadeSubWindows();
+ void closeActiveSubWindow();
+ void closeAllSubWindows();
+ void activateNextSubWindow();
+ void activatePreviousSubWindow();
+
+protected Q_SLOTS:
+ void setupViewport(QWidget *viewport);
+
+protected:
+ bool event(QEvent *event);
+ bool eventFilter(QObject *object, QEvent *event);
+ void paintEvent(QPaintEvent *paintEvent);
+ void childEvent(QChildEvent *childEvent);
+ void resizeEvent(QResizeEvent *resizeEvent);
+ void timerEvent(QTimerEvent *timerEvent);
+ void showEvent(QShowEvent *showEvent);
+ bool viewportEvent(QEvent *event);
+ void scrollContentsBy(int dx, int dy);
+
+private:
+ Q_DISABLE_COPY(QMdiArea)
+ Q_DECLARE_PRIVATE(QMdiArea)
+ Q_PRIVATE_SLOT(d_func(), void _q_deactivateAllWindows())
+ Q_PRIVATE_SLOT(d_func(), void _q_processWindowStateChanged(Qt::WindowStates, Qt::WindowStates))
+ Q_PRIVATE_SLOT(d_func(), void _q_currentTabChanged(int))
+ Q_PRIVATE_SLOT(d_func(), void _q_closeTab(int))
+ Q_PRIVATE_SLOT(d_func(), void _q_moveTab(int, int))
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QMdiArea::AreaOptions)
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QT_NO_MDIAREA
+#endif // QMDIAREA_H
diff --git a/src/widgets/widgets/qmdiarea_p.h b/src/widgets/widgets/qmdiarea_p.h
new file mode 100644
index 0000000000..64624cc109
--- /dev/null
+++ b/src/widgets/widgets/qmdiarea_p.h
@@ -0,0 +1,285 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMDIAREA_P_H
+#define QMDIAREA_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qmdiarea.h"
+#include "qmdisubwindow.h"
+
+#ifndef QT_NO_MDIAREA
+
+#include <QList>
+#include <QRect>
+#include <QPoint>
+#include <QtWidgets/qapplication.h>
+#include <private/qmdisubwindow_p.h>
+#include <private/qabstractscrollarea_p.h>
+
+QT_BEGIN_NAMESPACE
+
+namespace QMdi {
+class Rearranger
+{
+public:
+ enum Type {
+ RegularTiler,
+ SimpleCascader,
+ IconTiler
+ };
+
+ // Rearranges widgets relative to domain.
+ virtual void rearrange(QList<QWidget *> &widgets, const QRect &domain) const = 0;
+ virtual Type type() const = 0;
+ virtual ~Rearranger() {}
+};
+
+class RegularTiler : public Rearranger
+{
+ // Rearranges widgets according to a regular tiling pattern
+ // covering the entire domain.
+ // Both positions and sizes may change.
+ void rearrange(QList<QWidget *> &widgets, const QRect &domain) const;
+ inline Type type() const { return Rearranger::RegularTiler; }
+};
+
+class SimpleCascader : public Rearranger
+{
+ // Rearranges widgets according to a simple, regular cascading pattern.
+ // Widgets are resized to minimumSize.
+ // Both positions and sizes may change.
+ void rearrange(QList<QWidget *> &widgets, const QRect &domain) const;
+ inline Type type() const { return Rearranger::SimpleCascader; }
+};
+
+class IconTiler : public Rearranger
+{
+ // Rearranges icons (assumed to be the same size) according to a regular
+ // tiling pattern filling up the domain from the bottom.
+ // Only positions may change.
+ void rearrange(QList<QWidget *> &widgets, const QRect &domain) const;
+ inline Type type() const { return Rearranger::IconTiler; }
+};
+
+class Placer
+{
+public:
+ // Places the rectangle defined by 'size' relative to 'rects' and 'domain'.
+ // Returns the position of the resulting rectangle.
+ virtual QPoint place(
+ const QSize &size, const QList<QRect> &rects, const QRect &domain) const = 0;
+ virtual ~Placer() {}
+};
+
+class MinOverlapPlacer : public Placer
+{
+ QPoint place(const QSize &size, const QList<QRect> &rects, const QRect &domain) const;
+ static int accumulatedOverlap(const QRect &source, const QList<QRect> &rects);
+ static QRect findMinOverlapRect(const QList<QRect> &source, const QList<QRect> &rects);
+ static void getCandidatePlacements(
+ const QSize &size, const QList<QRect> &rects, const QRect &domain,
+ QList<QRect> &candidates);
+ static QPoint findBestPlacement(
+ const QRect &domain, const QList<QRect> &rects, QList<QRect> &source);
+ static void findNonInsiders(
+ const QRect &domain, QList<QRect> &source, QList<QRect> &result);
+ static void findMaxOverlappers(
+ const QRect &domain, const QList<QRect> &source, QList<QRect> &result);
+};
+} // namespace QMdi
+
+class QMdiAreaTabBar;
+class QMdiAreaPrivate : public QAbstractScrollAreaPrivate
+{
+ Q_DECLARE_PUBLIC(QMdiArea)
+public:
+ QMdiAreaPrivate();
+
+ // Variables.
+ QMdi::Rearranger *cascader;
+ QMdi::Rearranger *regularTiler;
+ QMdi::Rearranger *iconTiler;
+ QMdi::Placer *placer;
+#ifndef QT_NO_RUBBERBAND
+ QRubberBand *rubberBand;
+#endif
+ QMdiAreaTabBar *tabBar;
+ QList<QMdi::Rearranger *> pendingRearrangements;
+ QList< QPointer<QMdiSubWindow> > pendingPlacements;
+ QList< QPointer<QMdiSubWindow> > childWindows;
+ QList<int> indicesToActivatedChildren;
+ QPointer<QMdiSubWindow> active;
+ QPointer<QMdiSubWindow> aboutToBecomeActive;
+ QBrush background;
+ QMdiArea::WindowOrder activationOrder;
+ QMdiArea::AreaOptions options;
+ QMdiArea::ViewMode viewMode;
+#ifndef QT_NO_TABBAR
+ bool documentMode;
+ bool tabsClosable;
+ bool tabsMovable;
+#endif
+#ifndef QT_NO_TABWIDGET
+ QTabWidget::TabShape tabShape;
+ QTabWidget::TabPosition tabPosition;
+#endif
+ bool ignoreGeometryChange;
+ bool ignoreWindowStateChange;
+ bool isActivated;
+ bool isSubWindowsTiled;
+ bool showActiveWindowMaximized;
+ bool tileCalledFromResizeEvent;
+ bool updatesDisabledByUs;
+ bool inViewModeChange;
+ int indexToNextWindow;
+ int indexToPreviousWindow;
+ int indexToHighlighted;
+ int indexToLastActiveTab;
+ int resizeTimerId;
+ int tabToPreviousTimerId;
+
+ // Slots.
+ void _q_deactivateAllWindows(QMdiSubWindow *aboutToActivate = 0);
+ void _q_processWindowStateChanged(Qt::WindowStates oldState, Qt::WindowStates newState);
+ void _q_currentTabChanged(int index);
+ void _q_closeTab(int index);
+ void _q_moveTab(int from, int to);
+
+ // Functions.
+ void appendChild(QMdiSubWindow *child);
+ void place(QMdi::Placer *placer, QMdiSubWindow *child);
+ void rearrange(QMdi::Rearranger *rearranger);
+ void arrangeMinimizedSubWindows();
+ void activateWindow(QMdiSubWindow *child);
+ void activateCurrentWindow();
+ void activateHighlightedWindow();
+ void emitWindowActivated(QMdiSubWindow *child);
+ void resetActiveWindow(QMdiSubWindow *child = 0);
+ void updateActiveWindow(int removedIndex, bool activeRemoved);
+ void updateScrollBars();
+ void internalRaise(QMdiSubWindow *child) const;
+ bool scrollBarsEnabled() const;
+ bool lastWindowAboutToBeDestroyed() const;
+ void setChildActivationEnabled(bool enable = true, bool onlyNextActivationEvent = false) const;
+ QRect resizeToMinimumTileSize(const QSize &minSubWindowSize, int subWindowCount);
+ void scrollBarPolicyChanged(Qt::Orientation, Qt::ScrollBarPolicy); // reimp
+ QMdiSubWindow *nextVisibleSubWindow(int increaseFactor, QMdiArea::WindowOrder,
+ int removed = -1, int fromIndex = -1) const;
+ void highlightNextSubWindow(int increaseFactor);
+ QList<QMdiSubWindow *> subWindowList(QMdiArea::WindowOrder, bool reversed = false) const;
+ void disconnectSubWindow(QObject *subWindow);
+ void setViewMode(QMdiArea::ViewMode mode);
+#ifndef QT_NO_TABBAR
+ void updateTabBarGeometry();
+ void refreshTabBar();
+#endif
+
+ inline void startResizeTimer()
+ {
+ Q_Q(QMdiArea);
+ if (resizeTimerId > 0)
+ q->killTimer(resizeTimerId);
+ resizeTimerId = q->startTimer(200);
+ }
+
+ inline void startTabToPreviousTimer()
+ {
+ Q_Q(QMdiArea);
+ if (tabToPreviousTimerId > 0)
+ q->killTimer(tabToPreviousTimerId);
+ tabToPreviousTimerId = q->startTimer(QApplication::keyboardInputInterval());
+ }
+
+ inline bool windowStaysOnTop(QMdiSubWindow *subWindow) const
+ {
+ if (!subWindow)
+ return false;
+ return subWindow->windowFlags() & Qt::WindowStaysOnTopHint;
+ }
+
+ inline bool isExplicitlyDeactivated(QMdiSubWindow *subWindow) const
+ {
+ if (!subWindow)
+ return true;
+ return subWindow->d_func()->isExplicitlyDeactivated;
+ }
+
+ inline void setActive(QMdiSubWindow *subWindow, bool active = true, bool changeFocus = true) const
+ {
+ if (subWindow)
+ subWindow->d_func()->setActive(active, changeFocus);
+ }
+
+#ifndef QT_NO_RUBBERBAND
+ inline void showRubberBandFor(QMdiSubWindow *subWindow)
+ {
+ if (!subWindow || !rubberBand)
+ return;
+ rubberBand->setGeometry(subWindow->geometry());
+ rubberBand->raise();
+ rubberBand->show();
+ }
+
+ inline void hideRubberBand()
+ {
+ if (rubberBand && rubberBand->isVisible())
+ rubberBand->hide();
+ indexToHighlighted = -1;
+ }
+#endif // QT_NO_RUBBERBAND
+};
+
+#endif // QT_NO_MDIAREA
+
+QT_END_NAMESPACE
+
+#endif // QMDIAREA_P_H
diff --git a/src/gui/widgets/qmdisubwindow.cpp b/src/widgets/widgets/qmdisubwindow.cpp
index 6f2b67608c..6f2b67608c 100644
--- a/src/gui/widgets/qmdisubwindow.cpp
+++ b/src/widgets/widgets/qmdisubwindow.cpp
diff --git a/src/widgets/widgets/qmdisubwindow.h b/src/widgets/widgets/qmdisubwindow.h
new file mode 100644
index 0000000000..05021f1e5c
--- /dev/null
+++ b/src/widgets/widgets/qmdisubwindow.h
@@ -0,0 +1,159 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMDISUBWINDOW_H
+#define QMDISUBWINDOW_H
+
+#include <QtWidgets/qwidget.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_MDIAREA
+
+class QMenu;
+class QMdiArea;
+
+namespace QMdi { class ControlContainer; }
+class QMdiSubWindowPrivate;
+class Q_GUI_EXPORT QMdiSubWindow : public QWidget
+{
+ Q_OBJECT
+ Q_PROPERTY(int keyboardSingleStep READ keyboardSingleStep WRITE setKeyboardSingleStep)
+ Q_PROPERTY(int keyboardPageStep READ keyboardPageStep WRITE setKeyboardPageStep)
+public:
+ enum SubWindowOption {
+ AllowOutsideAreaHorizontally = 0x1, // internal
+ AllowOutsideAreaVertically = 0x2, // internal
+ RubberBandResize = 0x4,
+ RubberBandMove = 0x8
+ };
+ Q_DECLARE_FLAGS(SubWindowOptions, SubWindowOption)
+
+ QMdiSubWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0);
+ ~QMdiSubWindow();
+
+ QSize sizeHint() const;
+ QSize minimumSizeHint() const;
+
+ void setWidget(QWidget *widget);
+ QWidget *widget() const;
+
+ QWidget *maximizedButtonsWidget() const; // internal
+ QWidget *maximizedSystemMenuIconWidget() const; // internal
+
+ bool isShaded() const;
+
+ void setOption(SubWindowOption option, bool on = true);
+ bool testOption(SubWindowOption) const;
+
+ void setKeyboardSingleStep(int step);
+ int keyboardSingleStep() const;
+
+ void setKeyboardPageStep(int step);
+ int keyboardPageStep() const;
+
+#ifndef QT_NO_MENU
+ void setSystemMenu(QMenu *systemMenu);
+ QMenu *systemMenu() const;
+#endif
+
+ QMdiArea *mdiArea() const;
+
+Q_SIGNALS:
+ void windowStateChanged(Qt::WindowStates oldState, Qt::WindowStates newState);
+ void aboutToActivate();
+
+public Q_SLOTS:
+#ifndef QT_NO_MENU
+ void showSystemMenu();
+#endif
+ void showShaded();
+
+protected:
+ bool eventFilter(QObject *object, QEvent *event);
+ bool event(QEvent *event);
+ void showEvent(QShowEvent *showEvent);
+ void hideEvent(QHideEvent *hideEvent);
+ void changeEvent(QEvent *changeEvent);
+ void closeEvent(QCloseEvent *closeEvent);
+ void leaveEvent(QEvent *leaveEvent);
+ void resizeEvent(QResizeEvent *resizeEvent);
+ void timerEvent(QTimerEvent *timerEvent);
+ void moveEvent(QMoveEvent *moveEvent);
+ void paintEvent(QPaintEvent *paintEvent);
+ void mousePressEvent(QMouseEvent *mouseEvent);
+ void mouseDoubleClickEvent(QMouseEvent *mouseEvent);
+ void mouseReleaseEvent(QMouseEvent *mouseEvent);
+ void mouseMoveEvent(QMouseEvent *mouseEvent);
+ void keyPressEvent(QKeyEvent *keyEvent);
+#ifndef QT_NO_CONTEXTMENU
+ void contextMenuEvent(QContextMenuEvent *contextMenuEvent);
+#endif
+ void focusInEvent(QFocusEvent *focusInEvent);
+ void focusOutEvent(QFocusEvent *focusOutEvent);
+ void childEvent(QChildEvent *childEvent);
+
+private:
+ Q_DISABLE_COPY(QMdiSubWindow)
+ Q_DECLARE_PRIVATE(QMdiSubWindow)
+ Q_PRIVATE_SLOT(d_func(), void _q_updateStaysOnTopHint())
+ Q_PRIVATE_SLOT(d_func(), void _q_enterInteractiveMode())
+ Q_PRIVATE_SLOT(d_func(), void _q_processFocusChanged(QWidget *, QWidget *))
+ friend class QMdiAreaPrivate;
+#ifndef QT_NO_TABBAR
+ friend class QMdiAreaTabBar;
+#endif
+ friend class QMdi::ControlContainer;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QMdiSubWindow::SubWindowOptions)
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QT_NO_MDIAREA
+
+#endif // QMDISUBWINDOW_H
diff --git a/src/gui/widgets/qmdisubwindow_p.h b/src/widgets/widgets/qmdisubwindow_p.h
index e5b9d8091f..e5b9d8091f 100644
--- a/src/gui/widgets/qmdisubwindow_p.h
+++ b/src/widgets/widgets/qmdisubwindow_p.h
diff --git a/src/gui/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp
index b0ea00f811..b0ea00f811 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/widgets/widgets/qmenu.cpp
diff --git a/src/widgets/widgets/qmenu.h b/src/widgets/widgets/qmenu.h
new file mode 100644
index 0000000000..aa3a48cc17
--- /dev/null
+++ b/src/widgets/widgets/qmenu.h
@@ -0,0 +1,434 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMENU_H
+#define QMENU_H
+
+#include <QtWidgets/qwidget.h>
+#include <QtCore/qstring.h>
+#include <QtWidgets/qicon.h>
+#include <QtWidgets/qaction.h>
+
+#ifdef QT3_SUPPORT
+#include <QtGui/qpixmap.h>
+#endif
+
+#ifdef Q_WS_WINCE
+#include <windef.h> // for HMENU
+#endif
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_MENU
+
+class QMenuPrivate;
+class QStyleOptionMenuItem;
+#ifdef QT3_SUPPORT
+class QMenuItem;
+#endif
+
+class Q_GUI_EXPORT QMenu : public QWidget
+{
+private:
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QMenu)
+
+ Q_PROPERTY(bool tearOffEnabled READ isTearOffEnabled WRITE setTearOffEnabled)
+ Q_PROPERTY(QString title READ title WRITE setTitle)
+ Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
+ Q_PROPERTY(bool separatorsCollapsible READ separatorsCollapsible WRITE setSeparatorsCollapsible)
+
+public:
+ explicit QMenu(QWidget *parent = 0);
+ explicit QMenu(const QString &title, QWidget *parent = 0);
+ ~QMenu();
+
+#ifdef Q_NO_USING_KEYWORD
+ inline void addAction(QAction *action) { QWidget::addAction(action); }
+#else
+ using QWidget::addAction;
+#endif
+ QAction *addAction(const QString &text);
+ QAction *addAction(const QIcon &icon, const QString &text);
+ QAction *addAction(const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut = 0);
+ QAction *addAction(const QIcon &icon, const QString &text, const QObject *receiver, const char* member, const QKeySequence &shortcut = 0);
+
+ QAction *addMenu(QMenu *menu);
+ QMenu *addMenu(const QString &title);
+ QMenu *addMenu(const QIcon &icon, const QString &title);
+
+ QAction *addSeparator();
+
+ QAction *insertMenu(QAction *before, QMenu *menu);
+ QAction *insertSeparator(QAction *before);
+
+ bool isEmpty() const;
+ void clear();
+
+ void setTearOffEnabled(bool);
+ bool isTearOffEnabled() const;
+
+ bool isTearOffMenuVisible() const;
+ void hideTearOffMenu();
+
+ void setDefaultAction(QAction *);
+ QAction *defaultAction() const;
+
+ void setActiveAction(QAction *act);
+ QAction *activeAction() const;
+
+ void popup(const QPoint &pos, QAction *at=0);
+ QAction *exec();
+ QAction *exec(const QPoint &pos, QAction *at=0);
+
+ // ### Qt 5: merge
+ static QAction *exec(QList<QAction*> actions, const QPoint &pos, QAction *at=0);
+ static QAction *exec(QList<QAction*> actions, const QPoint &pos, QAction *at, QWidget *parent);
+
+ QSize sizeHint() const;
+
+ QRect actionGeometry(QAction *) const;
+ QAction *actionAt(const QPoint &) const;
+
+ QAction *menuAction() const;
+
+ QString title() const;
+ void setTitle(const QString &title);
+
+ QIcon icon() const;
+ void setIcon(const QIcon &icon);
+
+ void setNoReplayFor(QWidget *widget);
+#ifdef Q_WS_MAC
+ OSMenuRef macMenu(OSMenuRef merge=0);
+#endif
+
+#ifdef Q_WS_WINCE
+ HMENU wceMenu();
+#endif
+
+ bool separatorsCollapsible() const;
+ void setSeparatorsCollapsible(bool collapse);
+
+Q_SIGNALS:
+ void aboutToShow();
+ void aboutToHide();
+ void triggered(QAction *action);
+ void hovered(QAction *action);
+
+protected:
+ int columnCount() const;
+
+ void changeEvent(QEvent *);
+ void keyPressEvent(QKeyEvent *);
+ void mouseReleaseEvent(QMouseEvent *);
+ void mousePressEvent(QMouseEvent *);
+ void mouseMoveEvent(QMouseEvent *);
+#ifndef QT_NO_WHEELEVENT
+ void wheelEvent(QWheelEvent *);
+#endif
+ void enterEvent(QEvent *);
+ void leaveEvent(QEvent *);
+ void hideEvent(QHideEvent *);
+ void paintEvent(QPaintEvent *);
+ void actionEvent(QActionEvent *);
+ void timerEvent(QTimerEvent *);
+ bool event(QEvent *);
+ bool focusNextPrevChild(bool next);
+ void initStyleOption(QStyleOptionMenuItem *option, const QAction *action) const;
+
+#ifdef Q_WS_WINCE
+ QAction* wceCommands(uint command);
+#endif
+
+private Q_SLOTS:
+ void internalSetSloppyAction();
+ void internalDelayedPopup();
+
+private:
+ Q_PRIVATE_SLOT(d_func(), void _q_actionTriggered())
+ Q_PRIVATE_SLOT(d_func(), void _q_actionHovered())
+ Q_PRIVATE_SLOT(d_func(), void _q_overrideMenuActionDestroyed())
+
+#ifdef QT3_SUPPORT
+public:
+ //menudata
+ inline QT3_SUPPORT uint count() const { return actions().count(); }
+ inline QT3_SUPPORT int insertItem(const QString &text, const QObject *receiver, const char* member,
+ const QKeySequence& shortcut = 0, int id = -1, int index = -1) {
+ return insertAny(0, &text, receiver, member, &shortcut, 0, id, index);
+ }
+ inline QT3_SUPPORT int insertItem(const QIcon& icon, const QString &text,
+ const QObject *receiver, const char* member,
+ const QKeySequence& shortcut = 0, int id = -1, int index = -1) {
+ return insertAny(&icon, &text, receiver, member, &shortcut, 0, id, index);
+ }
+ inline QT3_SUPPORT int insertItem(const QPixmap &pixmap, const QObject *receiver, const char* member,
+ const QKeySequence& shortcut = 0, int id = -1, int index = -1) {
+ QIcon icon(pixmap);
+ return insertAny(&icon, 0, receiver, member, &shortcut, 0, id, index);
+ }
+ inline QT3_SUPPORT int insertItem(const QString &text, int id=-1, int index=-1) {
+ return insertAny(0, &text, 0, 0, 0, 0, id, index);
+ }
+ inline QT3_SUPPORT int insertItem(const QIcon& icon, const QString &text, int id=-1, int index=-1) {
+ return insertAny(&icon, &text, 0, 0, 0, 0, id, index);
+ }
+ inline QT3_SUPPORT int insertItem(const QString &text, QMenu *popup, int id=-1, int index=-1) {
+ return insertAny(0, &text, 0, 0, 0, popup, id, index);
+ }
+ inline QT3_SUPPORT int insertItem(const QIcon& icon, const QString &text, QMenu *popup, int id=-1, int index=-1) {
+ return insertAny(&icon, &text, 0, 0, 0, popup, id, index);
+ }
+ inline QT3_SUPPORT int insertItem(const QPixmap &pixmap, int id=-1, int index=-1) {
+ QIcon icon(pixmap);
+ return insertAny(&icon, 0, 0, 0, 0, 0, id, index);
+ }
+ inline QT3_SUPPORT int insertItem(const QPixmap &pixmap, QMenu *popup, int id=-1, int index=-1) {
+ QIcon icon(pixmap);
+ return insertAny(&icon, 0, 0, 0, 0, popup, id, index);
+ }
+ QT3_SUPPORT int insertItem(QMenuItem *item, int id=-1, int index=-1);
+ QT3_SUPPORT int insertSeparator(int index=-1);
+ inline QT3_SUPPORT void removeItem(int id) {
+ if(QAction *act = findActionForId(id))
+ removeAction(act); }
+ inline QT3_SUPPORT void removeItemAt(int index) {
+ if(QAction *act = actions().value(index))
+ removeAction(act); }
+#ifndef QT_NO_SHORTCUT
+ inline QT3_SUPPORT QKeySequence accel(int id) const {
+ if(QAction *act = findActionForId(id))
+ return act->shortcut();
+ return QKeySequence(); }
+ inline QT3_SUPPORT void setAccel(const QKeySequence& key, int id) {
+ if(QAction *act = findActionForId(id))
+ act->setShortcut(key);
+ }
+#endif
+ inline QT3_SUPPORT QIcon iconSet(int id) const {
+ if(QAction *act = findActionForId(id))
+ return act->icon();
+ return QIcon(); }
+ inline QT3_SUPPORT QString text(int id) const {
+ if(QAction *act = findActionForId(id))
+ return act->text();
+ return QString(); }
+ inline QT3_SUPPORT QPixmap pixmap(int id) const {
+ if(QAction *act = findActionForId(id))
+ return act->icon().pixmap(QSize(22, 22));
+ return QPixmap(); }
+ inline QT3_SUPPORT void setWhatsThis(int id, const QString &w) {
+ if(QAction *act = findActionForId(id))
+ act->setWhatsThis(w); }
+ inline QT3_SUPPORT QString whatsThis(int id) const {
+ if(QAction *act = findActionForId(id))
+ return act->whatsThis();
+ return QString(); }
+
+ inline QT3_SUPPORT void changeItem(int id, const QString &text) {
+ if(QAction *act = findActionForId(id))
+ act->setText(text); }
+ inline QT3_SUPPORT void changeItem(int id, const QPixmap &pixmap) {
+ if(QAction *act = findActionForId(id))
+ act->setIcon(QIcon(pixmap)); }
+ inline QT3_SUPPORT void changeItem(int id, const QIcon &icon, const QString &text) {
+ if(QAction *act = findActionForId(id)) {
+ act->setIcon(icon);
+ act->setText(text);
+ }
+ }
+ inline QT3_SUPPORT void setActiveItem(int id) {
+ setActiveAction(findActionForId(id));
+ }
+ inline QT3_SUPPORT bool isItemActive(int id) const {
+ return findActionForId(id) == activeAction();
+ }
+ inline QT3_SUPPORT bool isItemEnabled(int id) const {
+ if(QAction *act = findActionForId(id))
+ return act->isEnabled();
+ return false; }
+ inline QT3_SUPPORT void setItemEnabled(int id, bool enable) {
+ if(QAction *act = findActionForId(id))
+ act->setEnabled(enable);
+ }
+ inline QT3_SUPPORT bool isItemChecked(int id) const {
+ if(QAction *act = findActionForId(id))
+ return act->isChecked();
+ return false;
+ }
+ inline QT3_SUPPORT void setItemChecked(int id, bool check) {
+ if(QAction *act = findActionForId(id)) {
+ act->setCheckable(true);
+ act->setChecked(check);
+ }
+ }
+ inline QT3_SUPPORT bool isItemVisible(int id) const {
+ if(QAction *act = findActionForId(id))
+ return act->isVisible();
+ return false;
+ }
+ inline QT3_SUPPORT void setItemVisible(int id, bool visible) {
+ if(QAction *act = findActionForId(id))
+ act->setVisible(visible);
+ }
+ inline QT3_SUPPORT QRect itemGeometry(int index) {
+ if(QAction *act = actions().value(index))
+ return actionGeometry(act);
+ return QRect();
+ }
+ inline QT3_SUPPORT QFont itemFont(int id) const {
+ if(QAction *act = findActionForId(id))
+ return act->font();
+ return QFont();
+ }
+ inline QT3_SUPPORT void setItemFont(int id, const QFont &font) {
+ if(QAction *act = findActionForId(id))
+ act->setFont(font);
+ }
+ inline QT3_SUPPORT int indexOf(int id) const {
+ return actions().indexOf(findActionForId(id));
+ }
+ inline QT3_SUPPORT int idAt(int index) const {
+ return findIdForAction(actions().value(index));
+ }
+ QT3_SUPPORT void setId (int index, int id);
+ inline QT3_SUPPORT void activateItemAt(int index) {
+ if(QAction *ret = actions().value(index))
+ ret->activate(QAction::Trigger);
+ }
+ inline QT3_SUPPORT bool connectItem(int id, const QObject *receiver, const char* member) {
+ if(QAction *act = findActionForId(id)) {
+ QObject::connect(act, SIGNAL(activated(int)), receiver, member);
+ return true;
+ }
+ return false;
+ }
+ inline QT3_SUPPORT bool disconnectItem(int id,const QObject *receiver, const char* member) {
+ if(QAction *act = findActionForId(id)) {
+ QObject::disconnect(act, SIGNAL(triggered()), receiver, member);
+ return true;
+ }
+ return false;
+ }
+ inline QT3_SUPPORT QMenuItem *findItem(int id) const {
+ return reinterpret_cast<QMenuItem*>(findActionForId(id));
+ }
+
+ inline QT3_SUPPORT void setCheckable(bool){}
+ inline QT3_SUPPORT bool isCheckable() const {return true;}
+
+ QT3_SUPPORT QMenuItem *findPopup( QMenu *popup, int *index );
+
+ QT3_SUPPORT bool setItemParameter(int id, int param);
+ QT3_SUPPORT int itemParameter(int id) const;
+
+ //frame
+ QT3_SUPPORT int frameWidth() const;
+
+ //popupmenu
+ inline QT3_SUPPORT void popup(const QPoint & pos, int indexAtPoint) { popup(pos, actions().value(indexAtPoint)); }
+ inline QT3_SUPPORT int insertTearOffHandle(int = 0, int = 0) {
+ setTearOffEnabled(true);
+ return -1;
+ }
+
+protected:
+ inline QT3_SUPPORT int itemAtPos(const QPoint &p, bool ignoreSeparator = true) {
+ QAction *ret = actionAt(p);
+ if(ignoreSeparator && ret && ret->isSeparator())
+ return -1;
+ return findIdForAction(ret);
+ }
+ inline QT3_SUPPORT int columns() const { return columnCount(); }
+ inline QT3_SUPPORT int itemHeight(int index) {
+ return actionGeometry(actions().value(index)).height();
+ }
+ inline QT3_SUPPORT int itemHeight(QMenuItem *mi) {
+ return actionGeometry(reinterpret_cast<QAction *>(mi)).height();
+ }
+
+Q_SIGNALS:
+ QT_MOC_COMPAT void activated(int itemId);
+ QT_MOC_COMPAT void highlighted(int itemId);
+
+private:
+ int insertAny(const QIcon *icon, const QString *text, const QObject *receiver, const char *member,
+ const QKeySequence *shorcut, const QMenu *popup, int id, int index);
+ QAction *findActionForId(int id) const;
+ int findIdForAction(QAction*) const;
+#endif
+
+protected:
+ QMenu(QMenuPrivate &dd, QWidget* parent = 0);
+
+private:
+ Q_DISABLE_COPY(QMenu)
+
+ friend class QMenuBar;
+ friend class QMenuBarPrivate;
+ friend class QTornOffMenu;
+ friend class Q3PopupMenu;
+ friend class QComboBox;
+ friend class QAction;
+ friend class QToolButtonPrivate;
+
+#ifdef Q_WS_MAC
+ friend void qt_mac_trayicon_activate_action(QMenu *, QAction *action);
+ friend bool qt_mac_watchingAboutToShow(QMenu *);
+ friend OSStatus qt_mac_menu_event(EventHandlerCallRef, EventRef, void *);
+ friend bool qt_mac_activate_action(OSMenuRef, uint, QAction::ActionEvent, bool);
+ friend void qt_mac_emit_menuSignals(QMenu *, bool);
+ friend void qt_mac_menu_emit_hovered(QMenu *menu, QAction *action);
+#endif
+};
+
+#endif // QT_NO_MENU
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QMENU_H
diff --git a/src/gui/widgets/qmenu_mac.mm b/src/widgets/widgets/qmenu_mac.mm
index 2977558a75..2977558a75 100644
--- a/src/gui/widgets/qmenu_mac.mm
+++ b/src/widgets/widgets/qmenu_mac.mm
diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h
new file mode 100644
index 0000000000..9c777d443d
--- /dev/null
+++ b/src/widgets/widgets/qmenu_p.h
@@ -0,0 +1,395 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMENU_P_H
+#define QMENU_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "QtWidgets/qmenubar.h"
+#include "QtWidgets/qstyleoption.h"
+#include "QtCore/qdatetime.h"
+#include "QtCore/qmap.h"
+#include "QtCore/qhash.h"
+#include "QtCore/qbasictimer.h"
+#include "private/qwidget_p.h"
+
+#ifdef Q_WS_S60
+class CEikMenuPane;
+#define QT_SYMBIAN_FIRST_MENU_ITEM 32000
+#define QT_SYMBIAN_LAST_MENU_ITEM 41999 // 10000 items ought to be enough for anybody...
+#endif
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_MENU
+
+#ifdef Q_WS_S60
+void qt_symbian_next_menu_from_action(QWidget* actionContainer);
+void qt_symbian_show_toplevel(CEikMenuPane* menuPane);
+void qt_symbian_show_submenu(CEikMenuPane* menuPane, int id);
+#endif // Q_WS_S60
+
+class QTornOffMenu;
+class QEventLoop;
+
+#ifdef Q_WS_MAC
+# ifdef __OBJC__
+QT_END_NAMESPACE
+@class NSMenuItem;
+QT_BEGIN_NAMESPACE
+# else
+typedef void NSMenuItem;
+# endif //__OBJC__
+struct QMacMenuAction {
+ QMacMenuAction()
+#ifndef QT_MAC_USE_COCOA
+ : command(0)
+#else
+ : menuItem(0)
+#endif
+ , ignore_accel(0), merged(0), menu(0)
+ {
+ }
+ ~QMacMenuAction();
+#ifndef QT_MAC_USE_COCOA
+ uint command;
+#else
+ NSMenuItem *menuItem;
+#endif
+ uchar ignore_accel : 1;
+ uchar merged : 1;
+ QPointer<QAction> action;
+ OSMenuRef menu;
+};
+
+struct QMenuMergeItem
+{
+#ifndef QT_MAC_USE_COCOA
+ inline QMenuMergeItem(MenuCommand c, QMacMenuAction *a) : command(c), action(a) { }
+ MenuCommand command;
+#else
+ inline QMenuMergeItem(NSMenuItem *c, QMacMenuAction *a) : menuItem(c), action(a) { }
+ NSMenuItem *menuItem;
+#endif
+ QMacMenuAction *action;
+};
+typedef QList<QMenuMergeItem> QMenuMergeList;
+#endif
+
+#ifdef Q_WS_WINCE
+struct QWceMenuAction {
+ uint command;
+ QPointer<QAction> action;
+ HMENU menuHandle;
+ QWceMenuAction() : menuHandle(0), command(0) {}
+};
+#endif
+#ifdef Q_WS_S60
+struct QSymbianMenuAction {
+ uint command;
+ int parent;
+ CEikMenuPane* menuPane;
+ QPointer<QAction> action;
+ QSymbianMenuAction() : command(0) {}
+};
+#endif
+
+class QMenuPrivate : public QWidgetPrivate
+{
+ Q_DECLARE_PUBLIC(QMenu)
+public:
+ QMenuPrivate() : itemsDirty(0), maxIconWidth(0), tabWidth(0), ncols(0),
+ collapsibleSeparators(true), activationRecursionGuard(false), hasHadMouse(0), aboutToHide(0), motions(0),
+ currentAction(0),
+#ifdef QT_KEYPAD_NAVIGATION
+ selectAction(0),
+ cancelAction(0),
+#endif
+ scroll(0), eventLoop(0), tearoff(0), tornoff(0), tearoffHighlighted(0),
+ hasCheckableItems(0), sloppyAction(0), doChildEffects(false)
+#ifdef Q_WS_MAC
+ ,mac_menu(0)
+#endif
+#if defined(Q_WS_WINCE) && !defined(QT_NO_MENUBAR)
+ ,wce_menu(0)
+#endif
+#ifdef Q_WS_S60
+ ,symbian_menu(0)
+#endif
+#ifdef QT3_SUPPORT
+ ,emitHighlighted(false)
+#endif
+ { }
+ ~QMenuPrivate()
+ {
+ delete scroll;
+#ifdef Q_WS_MAC
+ delete mac_menu;
+#endif
+#if defined(Q_WS_WINCE) && !defined(QT_NO_MENUBAR)
+ delete wce_menu;
+#endif
+#ifdef Q_WS_S60
+ delete symbian_menu;
+#endif
+
+ }
+ void init();
+
+ static QMenuPrivate *get(QMenu *m) { return m->d_func(); }
+ int scrollerHeight() const;
+
+ //item calculations
+ mutable uint itemsDirty : 1;
+ mutable uint maxIconWidth, tabWidth;
+ QRect actionRect(QAction *) const;
+
+ mutable QVector<QRect> actionRects;
+ mutable QHash<QAction *, QWidget *> widgetItems;
+ void updateActionRects() const;
+ void updateActionRects(const QRect &screen) const;
+ QRect popupGeometry(const QWidget *widget) const;
+ QRect popupGeometry(int screen = -1) const;
+ mutable uint ncols : 4; //4 bits is probably plenty
+ uint collapsibleSeparators : 1;
+ QSize adjustMenuSizeForScreen(const QRect & screen);
+ int getLastVisibleAction() const;
+
+ bool activationRecursionGuard;
+
+ //selection
+ static QMenu *mouseDown;
+ QPoint mousePopupPos;
+ uint hasHadMouse : 1;
+ uint aboutToHide : 1;
+ int motions;
+ QAction *currentAction;
+#ifdef QT_KEYPAD_NAVIGATION
+ QAction *selectAction;
+ QAction *cancelAction;
+#endif
+ QBasicTimer menuDelayTimer;
+ enum SelectionReason {
+ SelectedFromKeyboard,
+ SelectedFromElsewhere
+ };
+ QWidget *topCausedWidget() const;
+ QAction *actionAt(QPoint p) const;
+ void setFirstActionActive();
+ void setCurrentAction(QAction *, int popup = -1, SelectionReason reason = SelectedFromElsewhere, bool activateFirst = false);
+ void popupAction(QAction *, int, bool);
+ void setSyncAction();
+
+ //scrolling support
+ struct QMenuScroller {
+ enum ScrollLocation { ScrollStay, ScrollBottom, ScrollTop, ScrollCenter };
+ enum ScrollDirection { ScrollNone=0, ScrollUp=0x01, ScrollDown=0x02 };
+ uint scrollFlags : 2, scrollDirection : 2;
+ int scrollOffset;
+ QBasicTimer scrollTimer;
+
+ QMenuScroller() : scrollFlags(ScrollNone), scrollDirection(ScrollNone), scrollOffset(0) { }
+ ~QMenuScroller() { }
+ } *scroll;
+ void scrollMenu(QMenuScroller::ScrollLocation location, bool active=false);
+ void scrollMenu(QMenuScroller::ScrollDirection direction, bool page=false, bool active=false);
+ void scrollMenu(QAction *action, QMenuScroller::ScrollLocation location, bool active=false);
+
+ //synchronous operation (ie exec())
+ QEventLoop *eventLoop;
+ QPointer<QAction> syncAction;
+
+ //search buffer
+ QString searchBuffer;
+ QBasicTimer searchBufferTimer;
+
+ //passing of mouse events up the parent hierarchy
+ QPointer<QMenu> activeMenu;
+ bool mouseEventTaken(QMouseEvent *);
+
+ //used to walk up the popup list
+ struct QMenuCaused {
+ QPointer<QWidget> widget;
+ QPointer<QAction> action;
+ };
+ virtual QList<QPointer<QWidget> > calcCausedStack() const;
+ QMenuCaused causedPopup;
+ void hideUpToMenuBar();
+ void hideMenu(QMenu *menu, bool justRegister = false);
+
+ //index mappings
+ inline QAction *actionAt(int i) const { return q_func()->actions().at(i); }
+ inline int indexOf(QAction *act) const { return q_func()->actions().indexOf(act); }
+
+ //tear off support
+ uint tearoff : 1, tornoff : 1, tearoffHighlighted : 1;
+ QPointer<QTornOffMenu> tornPopup;
+
+ mutable bool hasCheckableItems;
+
+ //sloppy selection
+ static int sloppyDelayTimer;
+ mutable QAction *sloppyAction;
+ QRegion sloppyRegion;
+
+ //default action
+ QPointer<QAction> defaultAction;
+
+ QAction *menuAction;
+ QAction *defaultMenuAction;
+
+ void setOverrideMenuAction(QAction *);
+ void _q_overrideMenuActionDestroyed();
+
+ //firing of events
+ void activateAction(QAction *, QAction::ActionEvent, bool self=true);
+ void activateCausedStack(const QList<QPointer<QWidget> > &, QAction *, QAction::ActionEvent, bool);
+
+ void _q_actionTriggered();
+ void _q_actionHovered();
+
+ bool hasMouseMoved(const QPoint &globalPos);
+
+ void updateLayoutDirection();
+
+ //menu fading/scrolling effects
+ bool doChildEffects;
+
+#ifdef Q_WS_MAC
+ //mac menu binding
+ struct QMacMenuPrivate {
+ QList<QMacMenuAction*> actionItems;
+ OSMenuRef menu;
+ QMacMenuPrivate();
+ ~QMacMenuPrivate();
+
+ bool merged(const QAction *action) const;
+ void addAction(QAction *, QMacMenuAction* =0, QMenuPrivate *qmenu = 0);
+ void addAction(QMacMenuAction *, QMacMenuAction* =0, QMenuPrivate *qmenu = 0);
+ void syncAction(QMacMenuAction *);
+ inline void syncAction(QAction *a) { syncAction(findAction(a)); }
+ void removeAction(QMacMenuAction *);
+ inline void removeAction(QAction *a) { removeAction(findAction(a)); }
+ inline QMacMenuAction *findAction(QAction *a) {
+ for(int i = 0; i < actionItems.size(); i++) {
+ QMacMenuAction *act = actionItems[i];
+ if(a == act->action)
+ return act;
+ }
+ return 0;
+ }
+ } *mac_menu;
+ OSMenuRef macMenu(OSMenuRef merge);
+ void setMacMenuEnabled(bool enable = true);
+ void syncSeparatorsCollapsible(bool collapsible);
+ static QHash<OSMenuRef, OSMenuRef> mergeMenuHash;
+ static QHash<OSMenuRef, QMenuMergeList*> mergeMenuItemsHash;
+#endif
+
+ QPointer<QAction> actionAboutToTrigger;
+#ifdef QT3_SUPPORT
+ bool emitHighlighted;
+#endif
+
+#if defined(Q_WS_WINCE) && !defined(QT_NO_MENUBAR)
+ struct QWceMenuPrivate {
+ QList<QWceMenuAction*> actionItems;
+ HMENU menuHandle;
+ QWceMenuPrivate();
+ ~QWceMenuPrivate();
+ void addAction(QAction *, QWceMenuAction* =0);
+ void addAction(QWceMenuAction *, QWceMenuAction* =0);
+ void syncAction(QWceMenuAction *);
+ inline void syncAction(QAction *a) { syncAction(findAction(a)); }
+ void removeAction(QWceMenuAction *);
+ void rebuild();
+ inline void removeAction(QAction *a) { removeAction(findAction(a)); }
+ inline QWceMenuAction *findAction(QAction *a) {
+ for(int i = 0; i < actionItems.size(); i++) {
+ QWceMenuAction *act = actionItems[i];
+ if(a == act->action)
+ return act;
+ }
+ return 0;
+ }
+ } *wce_menu;
+ HMENU wceMenu();
+ QAction* wceCommands(uint command);
+#endif
+#if defined(Q_WS_S60)
+ struct QSymbianMenuPrivate {
+ QList<QSymbianMenuAction*> actionItems;
+ QSymbianMenuPrivate();
+ ~QSymbianMenuPrivate();
+ void addAction(QAction *, QSymbianMenuAction* =0);
+ void addAction(QSymbianMenuAction *, QSymbianMenuAction* =0);
+ void syncAction(QSymbianMenuAction *);
+ inline void syncAction(QAction *a) { syncAction(findAction(a)); }
+ void removeAction(QSymbianMenuAction *);
+ void rebuild(bool reCreate = false);
+ inline void removeAction(QAction *a) { removeAction(findAction(a)); }
+ inline QSymbianMenuAction *findAction(QAction *a) {
+ for(int i = 0; i < actionItems.size(); i++) {
+ QSymbianMenuAction *act = actionItems[i];
+ if(a == act->action)
+ return act;
+ }
+ return 0;
+ }
+ } *symbian_menu;
+#endif
+ QPointer<QWidget> noReplayFor;
+};
+
+#endif // QT_NO_MENU
+
+QT_END_NAMESPACE
+
+#endif // QMENU_P_H
diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/widgets/widgets/qmenu_symbian.cpp
index d614bb8a77..d614bb8a77 100644
--- a/src/gui/widgets/qmenu_symbian.cpp
+++ b/src/widgets/widgets/qmenu_symbian.cpp
diff --git a/src/gui/widgets/qmenu_wince.cpp b/src/widgets/widgets/qmenu_wince.cpp
index 86a78ad50a..86a78ad50a 100644
--- a/src/gui/widgets/qmenu_wince.cpp
+++ b/src/widgets/widgets/qmenu_wince.cpp
diff --git a/src/gui/widgets/qmenu_wince.rc b/src/widgets/widgets/qmenu_wince.rc
index 2540d9f43a..2540d9f43a 100644
--- a/src/gui/widgets/qmenu_wince.rc
+++ b/src/widgets/widgets/qmenu_wince.rc
diff --git a/src/gui/widgets/qmenu_wince_resource_p.h b/src/widgets/widgets/qmenu_wince_resource_p.h
index 80de31b015..80de31b015 100644
--- a/src/gui/widgets/qmenu_wince_resource_p.h
+++ b/src/widgets/widgets/qmenu_wince_resource_p.h
diff --git a/src/gui/widgets/qmenubar.cpp b/src/widgets/widgets/qmenubar.cpp
index 5bfac9a646..5bfac9a646 100644
--- a/src/gui/widgets/qmenubar.cpp
+++ b/src/widgets/widgets/qmenubar.cpp
diff --git a/src/widgets/widgets/qmenubar.h b/src/widgets/widgets/qmenubar.h
new file mode 100644
index 0000000000..f0e05b217d
--- /dev/null
+++ b/src/widgets/widgets/qmenubar.h
@@ -0,0 +1,367 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMENUBAR_H
+#define QMENUBAR_H
+
+#include <QtWidgets/qmenu.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_MENUBAR
+
+class QMenuBarPrivate;
+class QStyleOptionMenuItem;
+class QWindowsStyle;
+#ifdef QT3_SUPPORT
+class QMenuItem;
+#endif
+
+class Q_GUI_EXPORT QMenuBar : public QWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool defaultUp READ isDefaultUp WRITE setDefaultUp)
+ Q_PROPERTY(bool nativeMenuBar READ isNativeMenuBar WRITE setNativeMenuBar)
+
+public:
+ explicit QMenuBar(QWidget *parent = 0);
+ ~QMenuBar();
+
+#ifdef Q_NO_USING_KEYWORD
+ void addAction(QAction *action) { QWidget::addAction(action); }
+#else
+ using QWidget::addAction;
+#endif
+ QAction *addAction(const QString &text);
+ QAction *addAction(const QString &text, const QObject *receiver, const char* member);
+
+ QAction *addMenu(QMenu *menu);
+ QMenu *addMenu(const QString &title);
+ QMenu *addMenu(const QIcon &icon, const QString &title);
+
+
+ QAction *addSeparator();
+ QAction *insertSeparator(QAction *before);
+
+ QAction *insertMenu(QAction *before, QMenu *menu);
+
+ void clear();
+
+ QAction *activeAction() const;
+ void setActiveAction(QAction *action);
+
+ void setDefaultUp(bool);
+ bool isDefaultUp() const;
+
+ QSize sizeHint() const;
+ QSize minimumSizeHint() const;
+ int heightForWidth(int) const;
+
+ QRect actionGeometry(QAction *) const;
+ QAction *actionAt(const QPoint &) const;
+
+ void setCornerWidget(QWidget *w, Qt::Corner corner = Qt::TopRightCorner);
+ QWidget *cornerWidget(Qt::Corner corner = Qt::TopRightCorner) const;
+
+#ifdef Q_WS_MAC
+ OSMenuRef macMenu();
+ static bool macUpdateMenuBar();
+#endif
+
+#ifdef Q_WS_WINCE
+ void setDefaultAction(QAction *);
+ QAction *defaultAction() const;
+
+ static void wceCommands(uint command);
+ static void wceRefresh();
+#endif
+
+ bool isNativeMenuBar() const;
+ void setNativeMenuBar(bool nativeMenuBar);
+
+public Q_SLOTS:
+ virtual void setVisible(bool visible);
+
+Q_SIGNALS:
+ void triggered(QAction *action);
+ void hovered(QAction *action);
+
+protected:
+ void changeEvent(QEvent *);
+ void keyPressEvent(QKeyEvent *);
+ void mouseReleaseEvent(QMouseEvent *);
+ void mousePressEvent(QMouseEvent *);
+ void mouseMoveEvent(QMouseEvent *);
+ void leaveEvent(QEvent *);
+ void paintEvent(QPaintEvent *);
+ void resizeEvent(QResizeEvent *);
+ void actionEvent(QActionEvent *);
+ void focusOutEvent(QFocusEvent *);
+ void focusInEvent(QFocusEvent *);
+ void timerEvent(QTimerEvent *);
+ bool eventFilter(QObject *, QEvent *);
+ bool event(QEvent *);
+ void initStyleOption(QStyleOptionMenuItem *option, const QAction *action) const;
+
+#ifdef QT3_SUPPORT
+public:
+ QT3_SUPPORT_CONSTRUCTOR QMenuBar(QWidget *parent, const char *name);
+ inline QT3_SUPPORT uint count() const { return actions().count(); }
+ inline QT3_SUPPORT int insertItem(const QString &text, const QObject *receiver, const char* member,
+ const QKeySequence& shortcut = 0, int id = -1, int index = -1) {
+ return insertAny(0, &text, receiver, member, &shortcut, 0, id, index);
+ }
+ inline QT3_SUPPORT int insertItem(const QIcon& icon, const QString &text,
+ const QObject *receiver, const char* member,
+ const QKeySequence& shortcut = 0, int id = -1, int index = -1) {
+ return insertAny(&icon, &text, receiver, member, &shortcut, 0, id, index);
+ }
+ inline QT3_SUPPORT int insertItem(const QPixmap &pixmap, const QObject *receiver, const char* member,
+ const QKeySequence& shortcut = 0, int id = -1, int index = -1) {
+ QIcon icon(pixmap);
+ return insertAny(&icon, 0, receiver, member, &shortcut, 0, id, index);
+ }
+ inline QT3_SUPPORT int insertItem(const QString &text, int id=-1, int index=-1) {
+ return insertAny(0, &text, 0, 0, 0, 0, id, index);
+ }
+ inline QT3_SUPPORT int insertItem(const QIcon& icon, const QString &text, int id=-1, int index=-1) {
+ return insertAny(&icon, &text, 0, 0, 0, 0, id, index);
+ }
+ inline QT3_SUPPORT int insertItem(const QString &text, QMenu *popup, int id=-1, int index=-1) {
+ return insertAny(0, &text, 0, 0, 0, popup, id, index);
+ }
+ inline QT3_SUPPORT int insertItem(const QIcon& icon, const QString &text, QMenu *popup, int id=-1, int index=-1) {
+ return insertAny(&icon, &text, 0, 0, 0, popup, id, index);
+ }
+ inline QT3_SUPPORT int insertItem(const QPixmap &pixmap, int id=-1, int index=-1) {
+ QIcon icon(pixmap);
+ return insertAny(&icon, 0, 0, 0, 0, 0, id, index);
+ }
+ inline QT3_SUPPORT int insertItem(const QPixmap &pixmap, QMenu *popup, int id=-1, int index=-1) {
+ QIcon icon(pixmap);
+ return insertAny(&icon, 0, 0, 0, 0, popup, id, index);
+ }
+ QT3_SUPPORT int insertSeparator(int index=-1);
+ inline QT3_SUPPORT void removeItem(int id) {
+ if(QAction *act = findActionForId(id))
+ removeAction(act); }
+ inline QT3_SUPPORT void removeItemAt(int index) {
+ if(QAction *act = actions().value(index))
+ removeAction(act); }
+#ifndef QT_NO_SHORTCUT
+ inline QT3_SUPPORT QKeySequence accel(int id) const {
+ if(QAction *act = findActionForId(id))
+ return act->shortcut();
+ return QKeySequence(); }
+ inline QT3_SUPPORT void setAccel(const QKeySequence& key, int id) {
+ if(QAction *act = findActionForId(id))
+ act->setShortcut(key);
+ }
+#endif
+ inline QT3_SUPPORT QIcon iconSet(int id) const {
+ if(QAction *act = findActionForId(id))
+ return act->icon();
+ return QIcon(); }
+ inline QT3_SUPPORT QString text(int id) const {
+ if(QAction *act = findActionForId(id))
+ return act->text();
+ return QString(); }
+ inline QT3_SUPPORT QPixmap pixmap(int id) const {
+ if(QAction *act = findActionForId(id))
+ return act->icon().pixmap(QSize(22,22));
+ return QPixmap(); }
+ inline QT3_SUPPORT void setWhatsThis(int id, const QString &w) {
+ if(QAction *act = findActionForId(id))
+ act->setWhatsThis(w); }
+ inline QT3_SUPPORT QString whatsThis(int id) const {
+ if(QAction *act = findActionForId(id))
+ return act->whatsThis();
+ return QString(); }
+
+ inline QT3_SUPPORT void changeItem(int id, const QString &text) {
+ if(QAction *act = findActionForId(id))
+ act->setText(text); }
+ inline QT3_SUPPORT void changeItem(int id, const QPixmap &pixmap) {
+ if(QAction *act = findActionForId(id))
+ act->setIcon(QIcon(pixmap)); }
+ inline QT3_SUPPORT void changeItem(int id, const QIcon &icon, const QString &text) {
+ if(QAction *act = findActionForId(id)) {
+ act->setIcon(icon);
+ act->setText(text);
+ }
+ }
+ inline QT3_SUPPORT bool isItemActive(int id) const { return findActionForId(id) == activeAction(); }
+ inline QT3_SUPPORT bool isItemEnabled(int id) const {
+ if(QAction *act = findActionForId(id))
+ return act->isEnabled();
+ return false; }
+ inline QT3_SUPPORT void setItemEnabled(int id, bool enable) {
+ if(QAction *act = findActionForId(id))
+ act->setEnabled(enable); }
+ inline QT3_SUPPORT bool isItemChecked(int id) const {
+ if(QAction *act = findActionForId(id))
+ return act->isChecked();
+ return false; }
+ inline QT3_SUPPORT void setItemChecked(int id, bool check) {
+ if(QAction *act = findActionForId(id))
+ act->setChecked(check); }
+ inline QT3_SUPPORT bool isItemVisible(int id) const {
+ if(QAction *act = findActionForId(id))
+ return act->isVisible();
+ return false; }
+ inline QT3_SUPPORT void setItemVisible(int id, bool visible) {
+ if(QAction *act = findActionForId(id))
+ act->setVisible(visible); }
+ inline QT3_SUPPORT int indexOf(int id) const { return actions().indexOf(findActionForId(id)); }
+ inline QT3_SUPPORT int idAt(int index) const {
+ return index >= 0 && index < actions().size()
+ ? findIdForAction(actions().at(index))
+ : -1;
+ }
+ inline QT3_SUPPORT void activateItemAt(int index) {
+ if(QAction *ret = actions().value(index))
+ setActiveAction(ret);
+ }
+ inline QT3_SUPPORT bool connectItem(int id, const QObject *receiver, const char* member) {
+ if(QAction *act = findActionForId(id)) {
+ QObject::connect(act, SIGNAL(triggered()), receiver, member);
+ return true;
+ }
+ return false;
+ }
+ inline QT3_SUPPORT bool disconnectItem(int id,const QObject *receiver, const char* member) {
+ if(QAction *act = findActionForId(id)) {
+ QObject::disconnect(act, SIGNAL(triggered()), receiver, member);
+ return true;
+ }
+ return false;
+ }
+ inline QT3_SUPPORT QMenuItem *findItem(int id) const {
+ return (QMenuItem*)findActionForId(id);
+ }
+ QT3_SUPPORT bool setItemParameter(int id, int param);
+ QT3_SUPPORT int itemParameter(int id) const;
+
+ //frame
+ QT3_SUPPORT int frameWidth() const;
+
+ QT3_SUPPORT void setFrameRect(QRect) {}
+ QT3_SUPPORT QRect frameRect() const { return QRect(); }
+ enum DummyFrame { Box, Sunken, Plain, Raised, MShadow, NoFrame, Panel, StyledPanel,
+ HLine, VLine, GroupBoxPanel, WinPanel, ToolBarPanel, MenuBarPanel,
+ PopupPanel, LineEditPanel, TabWidgetPanel, MShape };
+ QT3_SUPPORT void setFrameShadow(DummyFrame) {}
+ QT3_SUPPORT DummyFrame frameShadow() const { return Plain; }
+ QT3_SUPPORT void setFrameShape(DummyFrame) {}
+ QT3_SUPPORT DummyFrame frameShape() const { return NoFrame; }
+ QT3_SUPPORT void setFrameStyle(int) {}
+ QT3_SUPPORT int frameStyle() const { return 0; }
+ QT3_SUPPORT void setLineWidth(int) {}
+ QT3_SUPPORT int lineWidth() const { return 0; }
+ QT3_SUPPORT void setMargin(int margin) { setContentsMargins(margin, margin, margin, margin); }
+ QT3_SUPPORT int margin() const
+ { int margin; int dummy; getContentsMargins(&margin, &dummy, &dummy, &dummy); return margin; }
+ QT3_SUPPORT void setMidLineWidth(int) {}
+ QT3_SUPPORT int midLineWidth() const { return 0; }
+
+ //menubar
+ enum Separator { Never=0, InWindowsStyle=1 };
+ inline QT3_SUPPORT Separator separator() const { return InWindowsStyle; }
+ inline QT3_SUPPORT void setSeparator(Separator) { }
+
+ QT3_SUPPORT void setAutoGeometry(bool);
+ QT3_SUPPORT bool autoGeometry() const;
+
+Q_SIGNALS:
+ QT_MOC_COMPAT void activated(int itemId);
+ QT_MOC_COMPAT void highlighted(int itemId);
+
+protected:
+ inline QT3_SUPPORT QRect itemRect(int index) {
+ if(QAction *act = actions().value(index))
+ return actionGeometry(act);
+ return QRect();
+ }
+ inline QT3_SUPPORT int itemAtPos(const QPoint &p) {
+ return findIdForAction(actionAt(p));
+ }
+private:
+ QAction *findActionForId(int id) const;
+ int insertAny(const QIcon *icon, const QString *text, const QObject *receiver, const char *member,
+ const QKeySequence *shorcut, const QMenu *popup, int id, int index);
+ int findIdForAction(QAction*) const;
+#endif
+
+private:
+ Q_DECLARE_PRIVATE(QMenuBar)
+ Q_DISABLE_COPY(QMenuBar)
+ Q_PRIVATE_SLOT(d_func(), void _q_actionTriggered())
+ Q_PRIVATE_SLOT(d_func(), void _q_actionHovered())
+ Q_PRIVATE_SLOT(d_func(), void _q_internalShortcutActivated(int))
+ Q_PRIVATE_SLOT(d_func(), void _q_updateLayout())
+
+#ifdef Q_WS_WINCE
+ Q_PRIVATE_SLOT(d_func(), void _q_updateDefaultAction())
+#endif
+
+ friend class QMenu;
+ friend class QMenuPrivate;
+ friend class QWindowsStyle;
+
+#ifdef Q_WS_MAC
+ friend class QApplicationPrivate;
+ friend class QWidgetPrivate;
+ friend bool qt_mac_activate_action(MenuRef, uint, QAction::ActionEvent, bool);
+#endif
+};
+
+#endif // QT_NO_MENUBAR
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QMENUBAR_H
diff --git a/src/widgets/widgets/qmenubar_p.h b/src/widgets/widgets/qmenubar_p.h
new file mode 100644
index 0000000000..939cd430de
--- /dev/null
+++ b/src/widgets/widgets/qmenubar_p.h
@@ -0,0 +1,283 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMENUBAR_P_H
+#define QMENUBAR_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.
+//
+
+#ifndef QMAC_Q3MENUBAR_CPP_FILE
+#include "QtWidgets/qstyleoption.h"
+#include <private/qmenu_p.h> // Mac needs what in this file!
+
+#ifdef Q_WS_WINCE
+#include "qguifunctions_wince.h"
+#endif
+
+#ifndef QT_NO_MENUBAR
+#ifdef Q_WS_S60
+class CCoeControl;
+class CEikMenuBar;
+#endif
+#endif
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_MENUBAR
+class QMenuBarExtension;
+class QMenuBarPrivate : public QWidgetPrivate
+{
+ Q_DECLARE_PUBLIC(QMenuBar)
+public:
+ QMenuBarPrivate() : itemsDirty(0), currentAction(0), mouseDown(0),
+ closePopupMode(0), defaultPopDown(1), popupState(0), keyboardState(0), altPressed(0),
+ nativeMenuBar(-1), doChildEffects(false)
+#ifdef QT3_SUPPORT
+ , doAutoResize(false)
+#endif
+#ifdef Q_WS_MAC
+ , mac_menubar(0)
+#endif
+
+#ifdef Q_WS_WINCE
+ , wce_menubar(0), wceClassicMenu(false)
+#endif
+#ifdef Q_WS_S60
+ , symbian_menubar(0)
+#endif
+
+ { }
+ ~QMenuBarPrivate()
+ {
+#ifdef Q_WS_MAC
+ delete mac_menubar;
+#endif
+#ifdef Q_WS_WINCE
+ delete wce_menubar;
+#endif
+#ifdef Q_WS_S60
+ delete symbian_menubar;
+#endif
+ }
+
+ void init();
+ QAction *getNextAction(const int start, const int increment) const;
+
+ //item calculations
+ uint itemsDirty : 1;
+
+ QVector<int> shortcutIndexMap;
+ mutable QVector<QRect> actionRects;
+ void calcActionRects(int max_width, int start) const;
+ QRect actionRect(QAction *) const;
+ void updateGeometries();
+
+ //selection
+ QPointer<QAction>currentAction;
+ uint mouseDown : 1, closePopupMode : 1, defaultPopDown;
+ QAction *actionAt(QPoint p) const;
+ void setCurrentAction(QAction *, bool =false, bool =false);
+ void popupAction(QAction *, bool);
+
+ //active popup state
+ uint popupState : 1;
+ QPointer<QMenu> activeMenu;
+
+ //keyboard mode for keyboard navigation
+ void focusFirstAction();
+ void setKeyboardMode(bool);
+ uint keyboardState : 1, altPressed : 1;
+ QPointer<QWidget> keyboardFocusWidget;
+
+
+ int nativeMenuBar : 3; // Only has values -1, 0, and 1
+ //firing of events
+ void activateAction(QAction *, QAction::ActionEvent);
+
+ void _q_actionTriggered();
+ void _q_actionHovered();
+ void _q_internalShortcutActivated(int);
+ void _q_updateLayout();
+
+#ifdef Q_WS_WINCE
+ void _q_updateDefaultAction();
+#endif
+
+ //extra widgets in the menubar
+ QPointer<QWidget> leftWidget, rightWidget;
+ QMenuBarExtension *extension;
+ bool isVisible(QAction *action);
+
+ //menu fading/scrolling effects
+ bool doChildEffects;
+
+ QRect menuRect(bool) const;
+
+ // reparenting
+ void handleReparent();
+ QWidget *oldParent;
+ QWidget *oldWindow;
+
+ QList<QAction*> hiddenActions;
+ //default action
+ QPointer<QAction> defaultAction;
+
+ QBasicTimer autoReleaseTimer;
+#ifdef QT3_SUPPORT
+ bool doAutoResize;
+#endif
+#ifdef Q_WS_MAC
+ //mac menubar binding
+ struct QMacMenuBarPrivate {
+ QList<QMacMenuAction*> actionItems;
+ OSMenuRef menu, apple_menu;
+ QMacMenuBarPrivate();
+ ~QMacMenuBarPrivate();
+
+ void addAction(QAction *, QMacMenuAction* =0);
+ void addAction(QMacMenuAction *, QMacMenuAction* =0);
+ void syncAction(QMacMenuAction *);
+ inline void syncAction(QAction *a) { syncAction(findAction(a)); }
+ void removeAction(QMacMenuAction *);
+ inline void removeAction(QAction *a) { removeAction(findAction(a)); }
+ inline QMacMenuAction *findAction(QAction *a) {
+ for(int i = 0; i < actionItems.size(); i++) {
+ QMacMenuAction *act = actionItems[i];
+ if(a == act->action)
+ return act;
+ }
+ return 0;
+ }
+ } *mac_menubar;
+ static bool macUpdateMenuBarImmediatly();
+ bool macWidgetHasNativeMenubar(QWidget *widget);
+ void macCreateMenuBar(QWidget *);
+ void macDestroyMenuBar();
+ OSMenuRef macMenu();
+#endif
+#ifdef Q_WS_WINCE
+ void wceCreateMenuBar(QWidget *);
+ void wceDestroyMenuBar();
+ struct QWceMenuBarPrivate {
+ QList<QWceMenuAction*> actionItems;
+ QList<QWceMenuAction*> actionItemsLeftButton;
+ QList<QList<QWceMenuAction*>> actionItemsClassic;
+ HMENU menuHandle;
+ HMENU leftButtonMenuHandle;
+ HWND menubarHandle;
+ HWND parentWindowHandle;
+ bool leftButtonIsMenu;
+ QPointer<QAction> leftButtonAction;
+ QMenuBarPrivate *d;
+ int leftButtonCommand;
+
+ QWceMenuBarPrivate(QMenuBarPrivate *menubar);
+ ~QWceMenuBarPrivate();
+ void addAction(QAction *, QWceMenuAction* =0);
+ void addAction(QWceMenuAction *, QWceMenuAction* =0);
+ void syncAction(QWceMenuAction *);
+ inline void syncAction(QAction *a) { syncAction(findAction(a)); }
+ void removeAction(QWceMenuAction *);
+ void rebuild();
+ inline void removeAction(QAction *a) { removeAction(findAction(a)); }
+ inline QWceMenuAction *findAction(QAction *a) {
+ for(int i = 0; i < actionItems.size(); i++) {
+ QWceMenuAction *act = actionItems[i];
+ if(a == act->action)
+ return act;
+ }
+ return 0;
+ }
+ } *wce_menubar;
+ bool wceClassicMenu;
+ void wceCommands(uint command);
+ void wceRefresh();
+ bool wceEmitSignals(QList<QWceMenuAction*> actions, uint command);
+#endif
+#ifdef Q_WS_S60
+ void symbianCreateMenuBar(QWidget *);
+ void symbianDestroyMenuBar();
+ void reparentMenuBar(QWidget *oldParent, QWidget *newParent);
+ struct QSymbianMenuBarPrivate {
+ QList<QSymbianMenuAction*> actionItems;
+ QMenuBarPrivate *d;
+ QSymbianMenuBarPrivate(QMenuBarPrivate *menubar);
+ ~QSymbianMenuBarPrivate();
+ void addAction(QAction *, QSymbianMenuAction* =0);
+ void addAction(QSymbianMenuAction *, QSymbianMenuAction* =0);
+ void syncAction(QSymbianMenuAction *);
+ inline void syncAction(QAction *a) { syncAction(findAction(a)); }
+ void removeAction(QSymbianMenuAction *);
+ void rebuild();
+ inline void removeAction(QAction *a) { removeAction(findAction(a)); }
+ inline QSymbianMenuAction *findAction(QAction *a) {
+ for(int i = 0; i < actionItems.size(); i++) {
+ QSymbianMenuAction *act = actionItems[i];
+ if(a == act->action)
+ return act;
+ }
+ return 0;
+ }
+ void insertNativeMenuItems(const QList<QAction*> &actions);
+
+ } *symbian_menubar;
+ static int symbianCommands(int command);
+#endif
+#ifdef QT_SOFTKEYS_ENABLED
+ QAction *menuBarAction;
+#endif
+};
+#endif
+
+#endif // QT_NO_MENUBAR
+
+QT_END_NAMESPACE
+
+#endif // QMENUBAR_P_H
diff --git a/src/gui/widgets/qmenudata.cpp b/src/widgets/widgets/qmenudata.cpp
index f302aa8d50..f302aa8d50 100644
--- a/src/gui/widgets/qmenudata.cpp
+++ b/src/widgets/widgets/qmenudata.cpp
diff --git a/src/widgets/widgets/qmenudata.h b/src/widgets/widgets/qmenudata.h
new file mode 100644
index 0000000000..c42a795183
--- /dev/null
+++ b/src/widgets/widgets/qmenudata.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMENUDATA_H
+#define QMENUDATA_H
+
+#include <QtCore/qglobal.h>
+
+#ifdef QT3_SUPPORT
+#include <QtWidgets/qaction.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class Q_GUI_EXPORT QMenuItem : public QAction
+{
+ Q_OBJECT
+
+public:
+ QMenuItem();
+
+ QT3_SUPPORT int id() const;
+ QT3_SUPPORT int signalValue() const;
+private:
+ friend class QMenu;
+ friend class QMenuBar;
+ void setId(int);
+ void setSignalValue(int);
+
+ Q_DISABLE_COPY(QMenuItem)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif
+
+#endif // QMENUDATA_H
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp
index 51c4ccbeb7..51c4ccbeb7 100644
--- a/src/gui/widgets/qplaintextedit.cpp
+++ b/src/widgets/widgets/qplaintextedit.cpp
diff --git a/src/widgets/widgets/qplaintextedit.h b/src/widgets/widgets/qplaintextedit.h
new file mode 100644
index 0000000000..9269543ee8
--- /dev/null
+++ b/src/widgets/widgets/qplaintextedit.h
@@ -0,0 +1,329 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLAINTEXTEDIT_H
+#define QPLAINTEXTEDIT_H
+
+#include <QtWidgets/qtextedit.h>
+
+#include <QtWidgets/qabstractscrollarea.h>
+#include <QtGui/qtextdocument.h>
+#include <QtGui/qtextoption.h>
+#include <QtGui/qtextcursor.h>
+#include <QtGui/qtextformat.h>
+#include <QtGui/qabstracttextdocumentlayout.h>
+
+#ifndef QT_NO_TEXTEDIT
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QStyleSheet;
+class QTextDocument;
+class QMenu;
+class QPlainTextEditPrivate;
+class QMimeData;
+
+
+class Q_GUI_EXPORT QPlainTextEdit : public QAbstractScrollArea
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QPlainTextEdit)
+ Q_ENUMS(LineWrapMode)
+ Q_PROPERTY(bool tabChangesFocus READ tabChangesFocus WRITE setTabChangesFocus)
+ Q_PROPERTY(QString documentTitle READ documentTitle WRITE setDocumentTitle)
+ Q_PROPERTY(bool undoRedoEnabled READ isUndoRedoEnabled WRITE setUndoRedoEnabled)
+ Q_PROPERTY(LineWrapMode lineWrapMode READ lineWrapMode WRITE setLineWrapMode)
+ QDOC_PROPERTY(QTextOption::WrapMode wordWrapMode READ wordWrapMode WRITE setWordWrapMode)
+ Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
+ Q_PROPERTY(QString plainText READ toPlainText WRITE setPlainText NOTIFY textChanged USER true)
+ Q_PROPERTY(bool overwriteMode READ overwriteMode WRITE setOverwriteMode)
+ Q_PROPERTY(int tabStopWidth READ tabStopWidth WRITE setTabStopWidth)
+ Q_PROPERTY(int cursorWidth READ cursorWidth WRITE setCursorWidth)
+ Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
+ Q_PROPERTY(int blockCount READ blockCount)
+ Q_PROPERTY(int maximumBlockCount READ maximumBlockCount WRITE setMaximumBlockCount)
+ Q_PROPERTY(bool backgroundVisible READ backgroundVisible WRITE setBackgroundVisible)
+ Q_PROPERTY(bool centerOnScroll READ centerOnScroll WRITE setCenterOnScroll)
+public:
+ enum LineWrapMode {
+ NoWrap,
+ WidgetWidth
+ };
+
+ explicit QPlainTextEdit(QWidget *parent = 0);
+ explicit QPlainTextEdit(const QString &text, QWidget *parent = 0);
+ virtual ~QPlainTextEdit();
+
+ void setDocument(QTextDocument *document);
+ QTextDocument *document() const;
+
+ void setTextCursor(const QTextCursor &cursor);
+ QTextCursor textCursor() const;
+
+ bool isReadOnly() const;
+ void setReadOnly(bool ro);
+
+ void setTextInteractionFlags(Qt::TextInteractionFlags flags);
+ Qt::TextInteractionFlags textInteractionFlags() const;
+
+ void mergeCurrentCharFormat(const QTextCharFormat &modifier);
+ void setCurrentCharFormat(const QTextCharFormat &format);
+ QTextCharFormat currentCharFormat() const;
+
+ bool tabChangesFocus() const;
+ void setTabChangesFocus(bool b);
+
+ inline void setDocumentTitle(const QString &title)
+ { document()->setMetaInformation(QTextDocument::DocumentTitle, title); }
+ inline QString documentTitle() const
+ { return document()->metaInformation(QTextDocument::DocumentTitle); }
+
+ inline bool isUndoRedoEnabled() const
+ { return document()->isUndoRedoEnabled(); }
+ inline void setUndoRedoEnabled(bool enable)
+ { document()->setUndoRedoEnabled(enable); }
+
+ inline void setMaximumBlockCount(int maximum)
+ { document()->setMaximumBlockCount(maximum); }
+ inline int maximumBlockCount() const
+ { return document()->maximumBlockCount(); }
+
+
+ LineWrapMode lineWrapMode() const;
+ void setLineWrapMode(LineWrapMode mode);
+
+ QTextOption::WrapMode wordWrapMode() const;
+ void setWordWrapMode(QTextOption::WrapMode policy);
+
+ void setBackgroundVisible(bool visible);
+ bool backgroundVisible() const;
+
+ void setCenterOnScroll(bool enabled);
+ bool centerOnScroll() const;
+
+ bool find(const QString &exp, QTextDocument::FindFlags options = 0);
+
+ inline QString toPlainText() const
+ { return document()->toPlainText(); }
+
+ void ensureCursorVisible();
+
+ virtual QVariant loadResource(int type, const QUrl &name);
+#ifndef QT_NO_CONTEXTMENU
+ QMenu *createStandardContextMenu();
+#endif
+
+ QTextCursor cursorForPosition(const QPoint &pos) const;
+ QRect cursorRect(const QTextCursor &cursor) const;
+ QRect cursorRect() const;
+
+ QString anchorAt(const QPoint &pos) const;
+
+ bool overwriteMode() const;
+ void setOverwriteMode(bool overwrite);
+
+ int tabStopWidth() const;
+ void setTabStopWidth(int width);
+
+ int cursorWidth() const;
+ void setCursorWidth(int width);
+
+ void setExtraSelections(const QList<QTextEdit::ExtraSelection> &selections);
+ QList<QTextEdit::ExtraSelection> extraSelections() const;
+
+ void moveCursor(QTextCursor::MoveOperation operation, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor);
+
+ bool canPaste() const;
+
+#ifndef QT_NO_PRINTER
+ void print(QPrinter *printer) const;
+#endif
+
+ int blockCount() const;
+
+public Q_SLOTS:
+
+ void setPlainText(const QString &text);
+
+#ifndef QT_NO_CLIPBOARD
+ void cut();
+ void copy();
+ void paste();
+#endif
+
+ void undo();
+ void redo();
+
+ void clear();
+ void selectAll();
+
+ void insertPlainText(const QString &text);
+
+ void appendPlainText(const QString &text);
+ void appendHtml(const QString &html);
+
+ void centerCursor();
+
+Q_SIGNALS:
+ void textChanged();
+ void undoAvailable(bool b);
+ void redoAvailable(bool b);
+ void copyAvailable(bool b);
+ void selectionChanged();
+ void cursorPositionChanged();
+
+ void updateRequest(const QRect &rect, int dy);
+ void blockCountChanged(int newBlockCount);
+ void modificationChanged(bool);
+
+protected:
+ virtual bool event(QEvent *e);
+ virtual void timerEvent(QTimerEvent *e);
+ virtual void keyPressEvent(QKeyEvent *e);
+ virtual void keyReleaseEvent(QKeyEvent *e);
+ virtual void resizeEvent(QResizeEvent *e);
+ virtual void paintEvent(QPaintEvent *e);
+ virtual void mousePressEvent(QMouseEvent *e);
+ virtual void mouseMoveEvent(QMouseEvent *e);
+ virtual void mouseReleaseEvent(QMouseEvent *e);
+ virtual void mouseDoubleClickEvent(QMouseEvent *e);
+ virtual bool focusNextPrevChild(bool next);
+#ifndef QT_NO_CONTEXTMENU
+ virtual void contextMenuEvent(QContextMenuEvent *e);
+#endif
+#ifndef QT_NO_DRAGANDDROP
+ virtual void dragEnterEvent(QDragEnterEvent *e);
+ virtual void dragLeaveEvent(QDragLeaveEvent *e);
+ virtual void dragMoveEvent(QDragMoveEvent *e);
+ virtual void dropEvent(QDropEvent *e);
+#endif
+ virtual void focusInEvent(QFocusEvent *e);
+ virtual void focusOutEvent(QFocusEvent *e);
+ virtual void showEvent(QShowEvent *);
+ virtual void changeEvent(QEvent *e);
+#ifndef QT_NO_WHEELEVENT
+ virtual void wheelEvent(QWheelEvent *e);
+#endif
+
+ virtual QMimeData *createMimeDataFromSelection() const;
+ virtual bool canInsertFromMimeData(const QMimeData *source) const;
+ virtual void insertFromMimeData(const QMimeData *source);
+
+ virtual void inputMethodEvent(QInputMethodEvent *);
+ QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
+
+ QPlainTextEdit(QPlainTextEditPrivate &dd, QWidget *parent);
+
+ virtual void scrollContentsBy(int dx, int dy);
+
+ QTextBlock firstVisibleBlock() const;
+ QPointF contentOffset() const;
+ QRectF blockBoundingRect(const QTextBlock &block) const;
+ QRectF blockBoundingGeometry(const QTextBlock &block) const;
+ QAbstractTextDocumentLayout::PaintContext getPaintContext() const;
+
+
+private:
+ Q_DISABLE_COPY(QPlainTextEdit)
+ Q_PRIVATE_SLOT(d_func(), void _q_repaintContents(const QRectF &r))
+ Q_PRIVATE_SLOT(d_func(), void _q_adjustScrollbars())
+ Q_PRIVATE_SLOT(d_func(), void _q_verticalScrollbarActionTriggered(int))
+ Q_PRIVATE_SLOT(d_func(), void _q_cursorPositionChanged())
+
+ friend class QPlainTextEditControl;
+};
+
+
+class QPlainTextDocumentLayoutPrivate;
+class Q_GUI_EXPORT QPlainTextDocumentLayout : public QAbstractTextDocumentLayout
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QPlainTextDocumentLayout)
+ Q_PROPERTY(int cursorWidth READ cursorWidth WRITE setCursorWidth)
+
+public:
+ QPlainTextDocumentLayout(QTextDocument *document);
+ ~QPlainTextDocumentLayout();
+
+ void draw(QPainter *, const PaintContext &);
+ int hitTest(const QPointF &, Qt::HitTestAccuracy ) const;
+
+ int pageCount() const;
+ QSizeF documentSize() const;
+
+ QRectF frameBoundingRect(QTextFrame *) const;
+ QRectF blockBoundingRect(const QTextBlock &block) const;
+
+ void ensureBlockLayout(const QTextBlock &block) const;
+
+ void setCursorWidth(int width);
+ int cursorWidth() const;
+
+ void requestUpdate();
+
+protected:
+ void documentChanged(int from, int /*charsRemoved*/, int charsAdded);
+
+
+private:
+ void setTextWidth(qreal newWidth);
+ qreal textWidth() const;
+ void layoutBlock(const QTextBlock &block);
+ qreal blockWidth(const QTextBlock &block);
+
+ QPlainTextDocumentLayoutPrivate *priv() const;
+
+ friend class QPlainTextEdit;
+ friend class QPlainTextEditPrivate;
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+
+#endif // QT_NO_TEXTEDIT
+
+#endif // QPLAINTEXTEDIT_H
diff --git a/src/widgets/widgets/qplaintextedit_p.h b/src/widgets/widgets/qplaintextedit_p.h
new file mode 100644
index 0000000000..ca059bc5b5
--- /dev/null
+++ b/src/widgets/widgets/qplaintextedit_p.h
@@ -0,0 +1,187 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPLAINTEXTEDIT_P_H
+#define QPLAINTEXTEDIT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "private/qabstractscrollarea_p.h"
+#include "QtGui/qtextdocumentfragment.h"
+#include "QtWidgets/qscrollbar.h"
+#include "QtGui/qtextcursor.h"
+#include "QtGui/qtextformat.h"
+#include "QtWidgets/qmenu.h"
+#include "QtGui/qabstracttextdocumentlayout.h"
+#include "QtCore/qbasictimer.h"
+#include "private/qtextcontrol_p.h"
+#include "qplaintextedit.h"
+
+#ifndef QT_NO_TEXTEDIT
+
+QT_BEGIN_NAMESPACE
+
+class QMimeData;
+
+class QPlainTextEdit;
+class ExtraArea;
+
+class QPlainTextEditControl : public QTextControl
+{
+ Q_OBJECT
+public:
+ QPlainTextEditControl(QPlainTextEdit *parent);
+
+
+ QMimeData *createMimeDataFromSelection() const;
+ bool canInsertFromMimeData(const QMimeData *source) const;
+ void insertFromMimeData(const QMimeData *source);
+ int hitTest(const QPointF &point, Qt::HitTestAccuracy = Qt::FuzzyHit) const;
+ QRectF blockBoundingRect(const QTextBlock &block) const;
+ inline QRectF cursorRect(const QTextCursor &cursor) const {
+ QRectF r = QTextControl::cursorRect(cursor);
+ r.setLeft(qMax(r.left(), (qreal) 0.));
+ return r;
+ }
+ inline QRectF cursorRect() { return cursorRect(textCursor()); }
+ void ensureCursorVisible() {
+ textEdit->ensureCursorVisible();
+ emit microFocusChanged();
+ }
+
+
+ QPlainTextEdit *textEdit;
+ int topBlock;
+ QTextBlock firstVisibleBlock() const;
+
+ QVariant loadResource(int type, const QUrl &name) {
+ return textEdit->loadResource(type, name);
+ }
+
+};
+
+
+class QPlainTextEditPrivate : public QAbstractScrollAreaPrivate
+{
+ Q_DECLARE_PUBLIC(QPlainTextEdit)
+public:
+ QPlainTextEditPrivate();
+
+ void init(const QString &txt = QString());
+ void _q_repaintContents(const QRectF &contentsRect);
+
+ inline QPoint mapToContents(const QPoint &point) const
+ { return QPoint(point.x() + horizontalOffset(), point.y() + verticalOffset()); }
+
+ void _q_adjustScrollbars();
+ void _q_verticalScrollbarActionTriggered(int action);
+ void ensureViewportLayouted();
+ void relayoutDocument();
+
+ void pageUpDown(QTextCursor::MoveOperation op, QTextCursor::MoveMode moveMode, bool moveCursor = true);
+
+ inline int horizontalOffset() const
+ { return (q_func()->isRightToLeft() ? (hbar->maximum() - hbar->value()) : hbar->value()); }
+ int verticalOffset(int topBlock, int topLine) const;
+ int verticalOffset() const;
+
+ inline void sendControlEvent(QEvent *e)
+ { control->processEvent(e, QPointF(horizontalOffset(), verticalOffset()), viewport); }
+
+ void updateDefaultTextOption();
+
+ QPlainTextEditControl *control;
+
+ bool tabChangesFocus;
+
+ QBasicTimer autoScrollTimer;
+ QPoint autoScrollDragPos;
+
+ QPlainTextEdit::LineWrapMode lineWrap;
+ QTextOption::WrapMode wordWrap;
+
+ uint showCursorOnInitialShow : 1;
+ uint backgroundVisible : 1;
+ uint centerOnScroll : 1;
+ uint inDrag : 1;
+ uint clickCausedFocus : 1;
+
+ int topLine;
+
+ void setTopLine(int visualTopLine, int dx = 0);
+ void setTopBlock(int newTopBlock, int newTopLine, int dx = 0);
+
+ void ensureVisible(int position, bool center, bool forceCenter = false);
+ void ensureCursorVisible(bool center = false);
+ void updateViewport();
+
+ QPointer<QPlainTextDocumentLayout> documentLayoutPtr;
+
+ void append(const QString &text, Qt::TextFormat format = Qt::AutoText);
+
+ qreal pageUpDownLastCursorY;
+ bool pageUpDownLastCursorYIsValid;
+
+
+#ifdef QT_KEYPAD_NAVIGATION
+ QBasicTimer deleteAllTimer;
+#endif
+
+ void _q_cursorPositionChanged();
+ void _q_modificationChanged(bool);
+
+ int originalOffsetY;
+};
+
+QT_END_NAMESPACE
+
+#endif // QT_NO_TEXTEDIT
+
+#endif // QPLAINTEXTEDIT_P_H
diff --git a/src/widgets/widgets/qprintpreviewwidget.cpp b/src/widgets/widgets/qprintpreviewwidget.cpp
new file mode 100644
index 0000000000..0b30af3d17
--- /dev/null
+++ b/src/widgets/widgets/qprintpreviewwidget.cpp
@@ -0,0 +1,844 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qprintpreviewwidget.h"
+#include "private/qwidget_p.h"
+#include <private/qprinter_p.h>
+
+#include <QtCore/qmath.h>
+#include <QtWidgets/qboxlayout.h>
+#include <QtWidgets/qgraphicsitem.h>
+#include <QtWidgets/qgraphicsview.h>
+#include <QtWidgets/qscrollbar.h>
+#include <QtWidgets/qstyleoption.h>
+
+#ifndef QT_NO_PRINTPREVIEWWIDGET
+
+QT_BEGIN_NAMESPACE
+
+namespace {
+class PageItem : public QGraphicsItem
+{
+public:
+ PageItem(int _pageNum, const QPicture* _pagePicture, QSize _paperSize, QRect _pageRect)
+ : pageNum(_pageNum), pagePicture(_pagePicture),
+ paperSize(_paperSize), pageRect(_pageRect)
+ {
+ qreal border = qMax(paperSize.height(), paperSize.width()) / 25;
+ brect = QRectF(QPointF(-border, -border),
+ QSizeF(paperSize)+QSizeF(2*border, 2*border));
+ setCacheMode(DeviceCoordinateCache);
+ }
+
+ inline QRectF boundingRect() const
+ { return brect; }
+
+ inline int pageNumber() const
+ { return pageNum; }
+
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *item, QWidget *widget);
+
+private:
+ int pageNum;
+ const QPicture* pagePicture;
+ QSize paperSize;
+ QRect pageRect;
+ QRectF brect;
+};
+
+void PageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
+{
+ Q_UNUSED(widget);
+
+#if 0
+ // Draw item bounding rect, for debugging
+ painter->save();
+ painter->setPen(QPen(Qt::red, 0));
+ painter->setBrush(Qt::NoBrush);
+ painter->drawRect(QRectF(-border()+1.0, -border()+1.0, boundingRect().width()-2, boundingRect().height()-2));
+ painter->restore();
+#endif
+
+ QRectF paperRect(0,0, paperSize.width(), paperSize.height());
+
+ // Draw shadow
+ painter->setClipRect(option->exposedRect);
+ qreal shWidth = paperRect.width()/100;
+ QRectF rshadow(paperRect.topRight() + QPointF(0, shWidth),
+ paperRect.bottomRight() + QPointF(shWidth, 0));
+ QLinearGradient rgrad(rshadow.topLeft(), rshadow.topRight());
+ rgrad.setColorAt(0.0, QColor(0,0,0,255));
+ rgrad.setColorAt(1.0, QColor(0,0,0,0));
+ painter->fillRect(rshadow, QBrush(rgrad));
+ QRectF bshadow(paperRect.bottomLeft() + QPointF(shWidth, 0),
+ paperRect.bottomRight() + QPointF(0, shWidth));
+ QLinearGradient bgrad(bshadow.topLeft(), bshadow.bottomLeft());
+ bgrad.setColorAt(0.0, QColor(0,0,0,255));
+ bgrad.setColorAt(1.0, QColor(0,0,0,0));
+ painter->fillRect(bshadow, QBrush(bgrad));
+ QRectF cshadow(paperRect.bottomRight(),
+ paperRect.bottomRight() + QPointF(shWidth, shWidth));
+ QRadialGradient cgrad(cshadow.topLeft(), shWidth, cshadow.topLeft());
+ cgrad.setColorAt(0.0, QColor(0,0,0,255));
+ cgrad.setColorAt(1.0, QColor(0,0,0,0));
+ painter->fillRect(cshadow, QBrush(cgrad));
+
+ painter->setClipRect(paperRect & option->exposedRect);
+ painter->fillRect(paperRect, Qt::white);
+ if (!pagePicture)
+ return;
+ painter->drawPicture(pageRect.topLeft(), *pagePicture);
+
+ // Effect: make anything drawn in the margins look washed out.
+ QPainterPath path;
+ path.addRect(paperRect);
+ path.addRect(pageRect);
+ painter->setPen(QPen(Qt::NoPen));
+ painter->setBrush(QColor(255, 255, 255, 180));
+ painter->drawPath(path);
+
+#if 0
+ // Draw frame around paper.
+ painter->setPen(QPen(Qt::black, 0));
+ painter->setBrush(Qt::NoBrush);
+ painter->drawRect(paperRect);
+#endif
+
+ // todo: drawtext "Page N" below paper
+}
+
+class GraphicsView : public QGraphicsView
+{
+ Q_OBJECT
+public:
+ GraphicsView(QWidget* parent = 0)
+ : QGraphicsView(parent)
+ {
+#ifdef Q_WS_MAC
+ setFrameStyle(QFrame::NoFrame);
+#endif
+ }
+signals:
+ void resized();
+
+protected:
+ void resizeEvent(QResizeEvent* e)
+ {
+ QGraphicsView::resizeEvent(e);
+ emit resized();
+ }
+
+ void showEvent(QShowEvent* e)
+ {
+ QGraphicsView::showEvent(e);
+ emit resized();
+ }
+};
+
+} // anonymous namespace
+
+class QPrintPreviewWidgetPrivate : public QWidgetPrivate
+{
+ Q_DECLARE_PUBLIC(QPrintPreviewWidget)
+public:
+ QPrintPreviewWidgetPrivate()
+ : scene(0), curPage(1),
+ viewMode(QPrintPreviewWidget::SinglePageView),
+ zoomMode(QPrintPreviewWidget::FitInView),
+ zoomFactor(1), initialized(false), fitting(true)
+ {}
+
+ // private slots
+ void _q_fit(bool doFitting = false);
+ void _q_updateCurrentPage();
+
+ void init();
+ void populateScene();
+ void layoutPages();
+ void generatePreview();
+ void setCurrentPage(int pageNumber);
+ void zoom(qreal zoom);
+ void setZoomFactor(qreal zoomFactor);
+ int calcCurrentPage();
+
+ GraphicsView *graphicsView;
+ QGraphicsScene *scene;
+
+ int curPage;
+ QList<const QPicture *> pictures;
+ QList<QGraphicsItem *> pages;
+
+ QPrintPreviewWidget::ViewMode viewMode;
+ QPrintPreviewWidget::ZoomMode zoomMode;
+ qreal zoomFactor;
+ bool ownPrinter;
+ QPrinter* printer;
+ bool initialized;
+ bool fitting;
+};
+
+void QPrintPreviewWidgetPrivate::_q_fit(bool doFitting)
+{
+ Q_Q(QPrintPreviewWidget);
+
+ if (curPage < 1 || curPage > pages.count())
+ return;
+
+ if (!doFitting && !fitting)
+ return;
+
+ if (doFitting && fitting) {
+ QRect viewRect = graphicsView->viewport()->rect();
+ if (zoomMode == QPrintPreviewWidget::FitInView) {
+ QList<QGraphicsItem*> containedItems = graphicsView->items(viewRect, Qt::ContainsItemBoundingRect);
+ foreach(QGraphicsItem* item, containedItems) {
+ PageItem* pg = static_cast<PageItem*>(item);
+ if (pg->pageNumber() == curPage)
+ return;
+ }
+ }
+
+ int newPage = calcCurrentPage();
+ if (newPage != curPage)
+ curPage = newPage;
+ }
+
+ QRectF target = pages.at(curPage-1)->sceneBoundingRect();
+ if (viewMode == QPrintPreviewWidget::FacingPagesView) {
+ // fit two pages
+ if (curPage % 2)
+ target.setLeft(target.left() - target.width());
+ else
+ target.setRight(target.right() + target.width());
+ } else if (viewMode == QPrintPreviewWidget::AllPagesView) {
+ target = scene->itemsBoundingRect();
+ }
+
+ if (zoomMode == QPrintPreviewWidget::FitToWidth) {
+ QTransform t;
+ qreal scale = graphicsView->viewport()->width() / target.width();
+ t.scale(scale, scale);
+ graphicsView->setTransform(t);
+ if (doFitting && fitting) {
+ QRectF viewSceneRect = graphicsView->viewportTransform().mapRect(graphicsView->viewport()->rect());
+ viewSceneRect.moveTop(target.top());
+ graphicsView->ensureVisible(viewSceneRect); // Nah...
+ }
+ } else {
+ graphicsView->fitInView(target, Qt::KeepAspectRatio);
+ if (zoomMode == QPrintPreviewWidget::FitInView) {
+ int step = qRound(graphicsView->matrix().mapRect(target).height());
+ graphicsView->verticalScrollBar()->setSingleStep(step);
+ graphicsView->verticalScrollBar()->setPageStep(step);
+ }
+ }
+
+ zoomFactor = graphicsView->transform().m11() * (float(printer->logicalDpiY()) / q->logicalDpiY());
+ emit q->previewChanged();
+}
+
+void QPrintPreviewWidgetPrivate::_q_updateCurrentPage()
+{
+ Q_Q(QPrintPreviewWidget);
+
+ if (viewMode == QPrintPreviewWidget::AllPagesView)
+ return;
+
+ int newPage = calcCurrentPage();
+ if (newPage != curPage) {
+ curPage = newPage;
+ emit q->previewChanged();
+ }
+}
+
+int QPrintPreviewWidgetPrivate::calcCurrentPage()
+{
+ int maxArea = 0;
+ int newPage = curPage;
+ QRect viewRect = graphicsView->viewport()->rect();
+ QList<QGraphicsItem*> items = graphicsView->items(viewRect);
+ for (int i=0; i<items.size(); ++i) {
+ PageItem* pg = static_cast<PageItem*>(items.at(i));
+ QRect overlap = graphicsView->mapFromScene(pg->sceneBoundingRect()).boundingRect() & viewRect;
+ int area = overlap.width() * overlap.height();
+ if (area > maxArea) {
+ maxArea = area;
+ newPage = pg->pageNumber();
+ } else if (area == maxArea && pg->pageNumber() < newPage) {
+ newPage = pg->pageNumber();
+ }
+ }
+ return newPage;
+}
+
+void QPrintPreviewWidgetPrivate::init()
+{
+ Q_Q(QPrintPreviewWidget);
+
+ graphicsView = new GraphicsView;
+ graphicsView->setInteractive(false);
+ graphicsView->setDragMode(QGraphicsView::ScrollHandDrag);
+ graphicsView->setViewportUpdateMode(QGraphicsView::SmartViewportUpdate);
+ QObject::connect(graphicsView->verticalScrollBar(), SIGNAL(valueChanged(int)),
+ q, SLOT(_q_updateCurrentPage()));
+ QObject::connect(graphicsView, SIGNAL(resized()), q, SLOT(_q_fit()));
+
+ scene = new QGraphicsScene(graphicsView);
+ scene->setBackgroundBrush(Qt::gray);
+ graphicsView->setScene(scene);
+
+ QVBoxLayout *layout = new QVBoxLayout;
+ q->setLayout(layout);
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->addWidget(graphicsView);
+}
+
+void QPrintPreviewWidgetPrivate::populateScene()
+{
+ // remove old pages
+ for (int i = 0; i < pages.size(); i++)
+ scene->removeItem(pages.at(i));
+ qDeleteAll(pages);
+ pages.clear();
+
+ int numPages = pictures.count();
+ QSize paperSize = printer->paperRect().size();
+ QRect pageRect = printer->pageRect();
+
+ for (int i = 0; i < numPages; i++) {
+ PageItem* item = new PageItem(i+1, pictures.at(i), paperSize, pageRect);
+ scene->addItem(item);
+ pages.append(item);
+ }
+}
+
+void QPrintPreviewWidgetPrivate::layoutPages()
+{
+ int numPages = pages.count();
+ if (numPages < 1)
+ return;
+
+ int numPagePlaces = numPages;
+ int cols = 1; // singleMode and default
+ if (viewMode == QPrintPreviewWidget::AllPagesView) {
+ if (printer->orientation() == QPrinter::Portrait)
+ cols = qCeil(qSqrt((float) numPages));
+ else
+ cols = qFloor(qSqrt((float) numPages));
+ cols += cols % 2; // Nicer with an even number of cols
+ }
+ else if (viewMode == QPrintPreviewWidget::FacingPagesView) {
+ cols = 2;
+ numPagePlaces += 1;
+ }
+ int rows = qCeil(qreal(numPagePlaces) / cols);
+
+ qreal itemWidth = pages.at(0)->boundingRect().width();
+ qreal itemHeight = pages.at(0)->boundingRect().height();
+ int pageNum = 1;
+ for (int i = 0; i < rows && pageNum <= numPages; i++) {
+ for (int j = 0; j < cols && pageNum <= numPages; j++) {
+ if (!i && !j && viewMode == QPrintPreviewWidget::FacingPagesView) {
+ // Front page doesn't have a facing page
+ continue;
+ } else {
+ pages.at(pageNum-1)->setPos(QPointF(j*itemWidth, i*itemHeight));
+ pageNum++;
+ }
+ }
+ }
+ scene->setSceneRect(scene->itemsBoundingRect());
+}
+
+void QPrintPreviewWidgetPrivate::generatePreview()
+{
+ //### If QPrinter::setPreviewMode() becomes public, handle the
+ //### case that we have been constructed with a printer that
+ //### _already_ has been preview-painted to, so we should
+ //### initially just show the pages it already contains, and not
+ //### emit paintRequested() until the user changes some parameter
+
+ Q_Q(QPrintPreviewWidget);
+ printer->d_func()->setPreviewMode(true);
+ emit q->paintRequested(printer);
+ printer->d_func()->setPreviewMode(false);
+ pictures = printer->d_func()->previewPages();
+ populateScene(); // i.e. setPreviewPrintedPictures() e.l.
+ layoutPages();
+ curPage = qBound(1, curPage, pages.count());
+ if (fitting)
+ _q_fit();
+ emit q->previewChanged();
+}
+
+void QPrintPreviewWidgetPrivate::setCurrentPage(int pageNumber)
+{
+ if (pageNumber < 1 || pageNumber > pages.count())
+ return;
+
+ int lastPage = curPage;
+ curPage = pageNumber;
+
+ if (lastPage != curPage && lastPage > 0 && lastPage <= pages.count()) {
+ if (zoomMode != QPrintPreviewWidget::FitInView) {
+ QScrollBar *hsc = graphicsView->horizontalScrollBar();
+ QScrollBar *vsc = graphicsView->verticalScrollBar();
+ QPointF pt = graphicsView->transform().map(pages.at(curPage-1)->pos());
+ vsc->setValue(int(pt.y()) - 10);
+ hsc->setValue(int(pt.x()) - 10);
+ } else {
+ graphicsView->centerOn(pages.at(curPage-1));
+ }
+ }
+}
+
+void QPrintPreviewWidgetPrivate::zoom(qreal zoom)
+{
+ zoomFactor *= zoom;
+ graphicsView->scale(zoom, zoom);
+}
+
+void QPrintPreviewWidgetPrivate::setZoomFactor(qreal _zoomFactor)
+{
+ Q_Q(QPrintPreviewWidget);
+ zoomFactor = _zoomFactor;
+ graphicsView->resetTransform();
+ int dpi_y = q->logicalDpiY();
+ int printer_dpi_y = printer->logicalDpiY();
+ graphicsView->scale(zoomFactor*(dpi_y/float(printer_dpi_y)),
+ zoomFactor*(dpi_y/float(printer_dpi_y)));
+}
+
+///////////////////////////////////////
+
+/*!
+ \class QPrintPreviewWidget
+ \since 4.4
+
+ \brief The QPrintPreviewWidget class provides a widget for
+ previewing page layouts for printer output.
+
+ \ingroup printing
+
+ QPrintPreviewDialog uses a QPrintPreviewWidget internally, and the
+ purpose of QPrintPreviewWidget is to make it possible to embed the
+ preview into other widgets. It also makes it possible to build a different
+ user interface around it than the default one provided with QPrintPreviewDialog.
+
+ Using QPrintPreviewWidget is straightforward:
+
+ \list 1
+ \o Create the QPrintPreviewWidget
+
+ Construct the QPrintPreviewWidget either by passing in an
+ existing QPrinter object, or have QPrintPreviewWidget create a
+ default constructed QPrinter object for you.
+
+ \o Connect the paintRequested() signal to a slot.
+
+ When the widget needs to generate a set of preview pages, a
+ paintRequested() signal will be emitted from the widget. Connect a
+ slot to this signal, and draw onto the QPrinter passed in as a
+ signal parameter. Call QPrinter::newPage(), to start a new
+ page in the preview.
+
+ \endlist
+
+ \sa QPrinter, QPrintDialog, QPageSetupDialog, QPrintPreviewDialog
+*/
+
+
+/*!
+ \enum QPrintPreviewWidget::ViewMode
+
+ This enum is used to describe the view mode of the preview widget.
+
+ \value SinglePageView A mode where single pages in the preview
+ is viewed.
+
+ \value FacingPagesView A mode where the facing pages in the preview
+ is viewed.
+
+ \value AllPagesView A view mode where all the pages in the preview
+ is viewed.
+*/
+
+/*!
+ \enum QPrintPreviewWidget::ZoomMode
+
+ This enum is used to describe zoom mode of the preview widget.
+
+ \value CustomZoom The zoom is set to a custom zoom value.
+
+ \value FitToWidth This mode fits the current page to the width of the view.
+
+ \value FitInView This mode fits the current page inside the view.
+
+*/
+
+/*!
+ Constructs a QPrintPreviewWidget based on \a printer and with \a
+ parent as the parent widget. The widget flags \a flags are passed on
+ to the QWidget constructor.
+
+ \sa QWidget::setWindowFlags()
+*/
+QPrintPreviewWidget::QPrintPreviewWidget(QPrinter *printer, QWidget *parent, Qt::WindowFlags flags)
+ : QWidget(*new QPrintPreviewWidgetPrivate, parent, flags)
+{
+ Q_D(QPrintPreviewWidget);
+ d->printer = printer;
+ d->ownPrinter = false;
+ d->init();
+}
+
+/*!
+ \overload
+
+ This will cause QPrintPreviewWidget to create an internal, default
+ constructed QPrinter object, which will be used to generate the
+ preview.
+*/
+QPrintPreviewWidget::QPrintPreviewWidget(QWidget *parent, Qt::WindowFlags flags)
+ : QWidget(*new QPrintPreviewWidgetPrivate, parent, flags)
+{
+ Q_D(QPrintPreviewWidget);
+ d->printer = new QPrinter;
+ d->ownPrinter = true;
+ d->init();
+}
+
+
+/*!
+ Destroys the QPrintPreviewWidget.
+*/
+QPrintPreviewWidget::~QPrintPreviewWidget()
+{
+ Q_D(QPrintPreviewWidget);
+ if (d->ownPrinter)
+ delete d->printer;
+}
+
+/*!
+ Returns the current view mode. The default view mode is SinglePageView.
+*/
+QPrintPreviewWidget::ViewMode QPrintPreviewWidget::viewMode() const
+{
+ Q_D(const QPrintPreviewWidget);
+ return d->viewMode;
+}
+
+/*!
+ Sets the view mode to \a mode. The default view mode is
+ SinglePageView.
+*/
+void QPrintPreviewWidget::setViewMode(ViewMode mode)
+{
+ Q_D(QPrintPreviewWidget);
+ d->viewMode = mode;
+ d->layoutPages();
+ if (d->viewMode == AllPagesView) {
+ d->graphicsView->fitInView(d->scene->itemsBoundingRect(), Qt::KeepAspectRatio);
+ d->fitting = false;
+ d->zoomMode = QPrintPreviewWidget::CustomZoom;
+ d->zoomFactor = d->graphicsView->transform().m11() * (float(d->printer->logicalDpiY()) / logicalDpiY());
+ emit previewChanged();
+ } else {
+ d->fitting = true;
+ d->_q_fit();
+ }
+}
+
+/*!
+ Returns the current orientation of the preview. This value is
+ obtained from the QPrinter object associated with the preview.
+*/
+QPrinter::Orientation QPrintPreviewWidget::orientation() const
+{
+ Q_D(const QPrintPreviewWidget);
+ return d->printer->orientation();
+}
+
+/*!
+ Sets the current orientation to \a orientation. This value will be
+ set on the QPrinter object associated with the preview.
+*/
+void QPrintPreviewWidget::setOrientation(QPrinter::Orientation orientation)
+{
+ Q_D(QPrintPreviewWidget);
+ d->printer->setOrientation(orientation);
+ d->generatePreview();
+}
+
+/*!
+ Prints the preview to the printer associated with the preview.
+*/
+void QPrintPreviewWidget::print()
+{
+ Q_D(QPrintPreviewWidget);
+ // ### make use of the generated pages
+ emit paintRequested(d->printer);
+}
+
+/*!
+ Zooms the current view in by \a factor. The default value for \a
+ factor is 1.1, which means the view will be scaled up by 10%.
+*/
+void QPrintPreviewWidget::zoomIn(qreal factor)
+{
+ Q_D(QPrintPreviewWidget);
+ d->fitting = false;
+ d->zoomMode = QPrintPreviewWidget::CustomZoom;
+ d->zoom(factor);
+}
+
+/*!
+ Zooms the current view out by \a factor. The default value for \a
+ factor is 1.1, which means the view will be scaled down by 10%.
+*/
+void QPrintPreviewWidget::zoomOut(qreal factor)
+{
+ Q_D(QPrintPreviewWidget);
+ d->fitting = false;
+ d->zoomMode = QPrintPreviewWidget::CustomZoom;
+ d->zoom(1/factor);
+}
+
+/*!
+ Returns the zoom factor of the view.
+*/
+qreal QPrintPreviewWidget::zoomFactor() const
+{
+ Q_D(const QPrintPreviewWidget);
+ return d->zoomFactor;
+}
+
+/*!
+ Sets the zoom factor of the view to \a factor. For example, a
+ value of 1.0 indicates an unscaled view, which is approximately
+ the size the view will have on paper. A value of 0.5 will halve
+ the size of the view, while a value of 2.0 will double the size of
+ the view.
+*/
+void QPrintPreviewWidget::setZoomFactor(qreal factor)
+{
+ Q_D(QPrintPreviewWidget);
+ d->fitting = false;
+ d->zoomMode = QPrintPreviewWidget::CustomZoom;
+ d->setZoomFactor(factor);
+}
+
+/*!
+ \obsolete
+ Returns the number of pages in the preview.
+ \sa pageCount()
+*/
+int QPrintPreviewWidget::numPages() const
+{
+ Q_D(const QPrintPreviewWidget);
+ return d->pages.size();
+}
+
+/*!
+ \since 4.6
+ Returns the number of pages in the preview.
+*/
+int QPrintPreviewWidget::pageCount() const
+{
+ Q_D(const QPrintPreviewWidget);
+ return d->pages.size();
+}
+
+/*!
+ Returns the currently viewed page in the preview.
+*/
+int QPrintPreviewWidget::currentPage() const
+{
+ Q_D(const QPrintPreviewWidget);
+ return d->curPage;
+}
+
+/*!
+ Sets the current page in the preview. This will cause the view to
+ skip to the beginning of \a page.
+*/
+void QPrintPreviewWidget::setCurrentPage(int page)
+{
+ Q_D(QPrintPreviewWidget);
+ d->setCurrentPage(page);
+}
+
+/*!
+ This is a convenience function and is the same as calling \c
+ {setZoomMode(QPrintPreviewWidget::FitToWidth)}.
+*/
+void QPrintPreviewWidget::fitToWidth()
+{
+ setZoomMode(FitToWidth);
+}
+
+/*!
+ This is a convenience function and is the same as calling \c
+ {setZoomMode(QPrintPreviewWidget::FitInView)}.
+*/
+void QPrintPreviewWidget::fitInView()
+{
+ setZoomMode(FitInView);
+}
+
+/*!
+ Sets the zoom mode to \a zoomMode. The default zoom mode is FitInView.
+
+ \sa zoomMode(), viewMode(), setViewMode()
+*/
+void QPrintPreviewWidget::setZoomMode(QPrintPreviewWidget::ZoomMode zoomMode)
+{
+ Q_D(QPrintPreviewWidget);
+ d->zoomMode = zoomMode;
+ if (d->zoomMode == FitInView || d->zoomMode == FitToWidth) {
+ d->fitting = true;
+ d->_q_fit(true);
+ } else {
+ d->fitting = false;
+ }
+}
+
+/*!
+ Returns the current zoom mode.
+
+ \sa setZoomMode(), viewMode(), setViewMode()
+*/
+QPrintPreviewWidget::ZoomMode QPrintPreviewWidget::zoomMode() const
+{
+ Q_D(const QPrintPreviewWidget);
+ return d->zoomMode;
+}
+
+/*!
+ This is a convenience function and is the same as calling \c
+ {setOrientation(QPrinter::Landscape)}.
+*/
+void QPrintPreviewWidget::setLandscapeOrientation()
+{
+ setOrientation(QPrinter::Landscape);
+}
+
+/*!
+ This is a convenience function and is the same as calling \c
+ {setOrientation(QPrinter::Portrait)}.
+*/
+void QPrintPreviewWidget::setPortraitOrientation()
+{
+ setOrientation(QPrinter::Portrait);
+}
+
+/*!
+ This is a convenience function and is the same as calling \c
+ {setViewMode(QPrintPreviewWidget::SinglePageView)}.
+*/
+void QPrintPreviewWidget::setSinglePageViewMode()
+{
+ setViewMode(SinglePageView);
+}
+
+/*!
+ This is a convenience function and is the same as calling \c
+ {setViewMode(QPrintPreviewWidget::FacingPagesView)}.
+*/
+void QPrintPreviewWidget::setFacingPagesViewMode()
+{
+ setViewMode(FacingPagesView);
+}
+
+/*!
+ This is a convenience function and is the same as calling \c
+ {setViewMode(QPrintPreviewWidget::AllPagesView)}.
+*/
+void QPrintPreviewWidget::setAllPagesViewMode()
+{
+ setViewMode(AllPagesView);
+}
+
+
+/*!
+ This function updates the preview, which causes the
+ paintRequested() signal to be emitted.
+*/
+void QPrintPreviewWidget::updatePreview()
+{
+ Q_D(QPrintPreviewWidget);
+ d->initialized = true;
+ d->generatePreview();
+ d->graphicsView->updateGeometry();
+}
+
+/*! \reimp
+*/
+void QPrintPreviewWidget::setVisible(bool visible)
+{
+ Q_D(QPrintPreviewWidget);
+ if (visible && !d->initialized)
+ updatePreview();
+ QWidget::setVisible(visible);
+}
+
+/*!
+ \fn void QPrintPreviewWidget::paintRequested(QPrinter *printer)
+
+ This signal is emitted when the preview widget needs to generate a
+ set of preview pages. \a printer is the printer associated with
+ this preview widget.
+*/
+
+/*!
+ \fn void QPrintPreviewWidget::previewChanged()
+
+ This signal is emitted whenever the preview widget has changed
+ some internal state, such as the orientation.
+*/
+
+
+QT_END_NAMESPACE
+
+#include "moc_qprintpreviewwidget.cpp"
+#include "qprintpreviewwidget.moc"
+
+#endif // QT_NO_PRINTPREVIEWWIDGET
diff --git a/src/widgets/widgets/qprintpreviewwidget.h b/src/widgets/widgets/qprintpreviewwidget.h
new file mode 100644
index 0000000000..ac2e15b461
--- /dev/null
+++ b/src/widgets/widgets/qprintpreviewwidget.h
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPRINTPREVIEWWIDGET_H
+#define QPRINTPREVIEWWIDGET_H
+
+#include <QtWidgets/qwidget.h>
+#include <QtGui/qprinter.h>
+
+#ifndef QT_NO_PRINTPREVIEWWIDGET
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QPrintPreviewWidgetPrivate;
+
+class Q_GUI_EXPORT QPrintPreviewWidget : public QWidget
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QPrintPreviewWidget)
+public:
+
+ enum ViewMode {
+ SinglePageView,
+ FacingPagesView,
+ AllPagesView
+ };
+
+ enum ZoomMode {
+ CustomZoom,
+ FitToWidth,
+ FitInView
+ };
+
+ explicit QPrintPreviewWidget(QPrinter *printer, QWidget *parent = 0, Qt::WindowFlags flags = 0);
+ explicit QPrintPreviewWidget(QWidget *parent = 0, Qt::WindowFlags flags = 0);
+ ~QPrintPreviewWidget();
+
+ qreal zoomFactor() const;
+ QPrinter::Orientation orientation() const;
+ ViewMode viewMode() const;
+ ZoomMode zoomMode() const;
+ int currentPage() const;
+#ifdef QT_DEPRECATED
+ QT_DEPRECATED int numPages() const;
+#endif
+ int pageCount() const;
+ void setVisible(bool visible);
+
+public Q_SLOTS:
+ void print();
+
+ void zoomIn(qreal zoom = 1.1);
+ void zoomOut(qreal zoom = 1.1);
+ void setZoomFactor(qreal zoomFactor);
+ void setOrientation(QPrinter::Orientation orientation);
+ void setViewMode(ViewMode viewMode);
+ void setZoomMode(ZoomMode zoomMode);
+ void setCurrentPage(int pageNumber);
+
+ void fitToWidth();
+ void fitInView();
+ void setLandscapeOrientation();
+ void setPortraitOrientation();
+ void setSinglePageViewMode();
+ void setFacingPagesViewMode();
+ void setAllPagesViewMode();
+
+ void updatePreview();
+
+Q_SIGNALS:
+ void paintRequested(QPrinter *printer);
+ void previewChanged();
+
+private:
+ void *dummy; // ### remove in Qt 5.0
+ Q_PRIVATE_SLOT(d_func(), void _q_fit())
+ Q_PRIVATE_SLOT(d_func(), void _q_updateCurrentPage())
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QT_NO_PRINTPREVIEWWIDGET
+#endif // QPRINTPREVIEWWIDGET_H
diff --git a/src/gui/widgets/qprogressbar.cpp b/src/widgets/widgets/qprogressbar.cpp
index b7350406d4..b7350406d4 100644
--- a/src/gui/widgets/qprogressbar.cpp
+++ b/src/widgets/widgets/qprogressbar.cpp
diff --git a/src/widgets/widgets/qprogressbar.h b/src/widgets/widgets/qprogressbar.h
new file mode 100644
index 0000000000..4690400feb
--- /dev/null
+++ b/src/widgets/widgets/qprogressbar.h
@@ -0,0 +1,132 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPROGRESSBAR_H
+#define QPROGRESSBAR_H
+
+#include <QtWidgets/qframe.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_PROGRESSBAR
+
+class QProgressBarPrivate;
+class QStyleOptionProgressBar;
+
+class Q_GUI_EXPORT QProgressBar : public QWidget
+{
+ Q_OBJECT
+ Q_ENUMS(Direction)
+ Q_PROPERTY(int minimum READ minimum WRITE setMinimum)
+ Q_PROPERTY(int maximum READ maximum WRITE setMaximum)
+ Q_PROPERTY(QString text READ text)
+ Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
+ Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
+ Q_PROPERTY(bool textVisible READ isTextVisible WRITE setTextVisible)
+ Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
+ Q_PROPERTY(bool invertedAppearance READ invertedAppearance WRITE setInvertedAppearance)
+ Q_PROPERTY(Direction textDirection READ textDirection WRITE setTextDirection)
+ Q_PROPERTY(QString format READ format WRITE setFormat)
+
+public:
+ enum Direction { TopToBottom, BottomToTop };
+
+ explicit QProgressBar(QWidget *parent = 0);
+
+ int minimum() const;
+ int maximum() const;
+
+ int value() const;
+
+ virtual QString text() const;
+ void setTextVisible(bool visible);
+ bool isTextVisible() const;
+
+ Qt::Alignment alignment() const;
+ void setAlignment(Qt::Alignment alignment);
+
+ QSize sizeHint() const;
+ QSize minimumSizeHint() const;
+
+ Qt::Orientation orientation() const;
+
+ void setInvertedAppearance(bool invert);
+ bool invertedAppearance(); //### Qt5 make const
+ bool invertedAppearance() const { return const_cast<QProgressBar *>(this)->invertedAppearance(); }
+ void setTextDirection(QProgressBar::Direction textDirection);
+ QProgressBar::Direction textDirection(); //### Qt5 make const
+ QProgressBar::Direction textDirection() const { return const_cast<QProgressBar *>(this)->textDirection(); }
+
+ void setFormat(const QString &format);
+ QString format() const;
+
+public Q_SLOTS:
+ void reset();
+ void setRange(int minimum, int maximum);
+ void setMinimum(int minimum);
+ void setMaximum(int maximum);
+ void setValue(int value);
+ void setOrientation(Qt::Orientation);
+
+Q_SIGNALS:
+ void valueChanged(int value);
+
+protected:
+ bool event(QEvent *e);
+ void paintEvent(QPaintEvent *);
+ void initStyleOption(QStyleOptionProgressBar *option) const;
+
+private:
+ Q_DECLARE_PRIVATE(QProgressBar)
+ Q_DISABLE_COPY(QProgressBar)
+};
+
+#endif // QT_NO_PROGRESSBAR
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPROGRESSBAR_H
diff --git a/src/gui/widgets/qpushbutton.cpp b/src/widgets/widgets/qpushbutton.cpp
index e52209bf1f..e52209bf1f 100644
--- a/src/gui/widgets/qpushbutton.cpp
+++ b/src/widgets/widgets/qpushbutton.cpp
diff --git a/src/widgets/widgets/qpushbutton.h b/src/widgets/widgets/qpushbutton.h
new file mode 100644
index 0000000000..412eb513d8
--- /dev/null
+++ b/src/widgets/widgets/qpushbutton.h
@@ -0,0 +1,127 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QPUSHBUTTON_H
+#define QPUSHBUTTON_H
+
+#include <QtWidgets/qabstractbutton.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QPushButtonPrivate;
+class QMenu;
+class QStyleOptionButton;
+
+class Q_GUI_EXPORT QPushButton : public QAbstractButton
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool autoDefault READ autoDefault WRITE setAutoDefault)
+ Q_PROPERTY(bool default READ isDefault WRITE setDefault)
+ Q_PROPERTY(bool flat READ isFlat WRITE setFlat)
+
+public:
+ explicit QPushButton(QWidget *parent=0);
+ explicit QPushButton(const QString &text, QWidget *parent=0);
+ QPushButton(const QIcon& icon, const QString &text, QWidget *parent=0);
+ ~QPushButton();
+
+ QSize sizeHint() const;
+ QSize minimumSizeHint() const;
+
+ bool autoDefault() const;
+ void setAutoDefault(bool);
+ bool isDefault() const;
+ void setDefault(bool);
+
+#ifndef QT_NO_MENU
+ void setMenu(QMenu* menu);
+ QMenu* menu() const;
+#endif
+
+ void setFlat(bool);
+ bool isFlat() const;
+
+public Q_SLOTS:
+#ifndef QT_NO_MENU
+ void showMenu();
+#endif
+
+protected:
+ bool event(QEvent *e);
+#ifdef Q_WS_MAC
+ bool hitButton(const QPoint &pos) const;
+#endif // Q_WS_MAC
+ void paintEvent(QPaintEvent *);
+ void keyPressEvent(QKeyEvent *);
+ void focusInEvent(QFocusEvent *);
+ void focusOutEvent(QFocusEvent *);
+ void initStyleOption(QStyleOptionButton *option) const;
+ QPushButton(QPushButtonPrivate &dd, QWidget* parent = 0);
+
+public:
+#ifdef QT3_SUPPORT
+ QT3_SUPPORT_CONSTRUCTOR QPushButton(QWidget *parent, const char* name);
+ QT3_SUPPORT_CONSTRUCTOR QPushButton(const QString &text, QWidget *parent, const char* name);
+ QT3_SUPPORT_CONSTRUCTOR QPushButton(const QIcon& icon, const QString &text, QWidget *parent, const char* name);
+ inline QT3_SUPPORT void openPopup() { showMenu(); }
+ inline QT3_SUPPORT bool isMenuButton() const { return menu() != 0; }
+ inline QT3_SUPPORT void setPopup(QMenu* popup) {setMenu(popup); }
+ inline QT3_SUPPORT QMenu* popup() const { return menu(); }
+#endif
+
+private:
+ Q_DISABLE_COPY(QPushButton)
+ Q_DECLARE_PRIVATE(QPushButton)
+#ifndef QT_NO_MENU
+ Q_PRIVATE_SLOT(d_func(), void _q_popupPressed())
+#endif
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QPUSHBUTTON_H
diff --git a/src/gui/widgets/qpushbutton_p.h b/src/widgets/widgets/qpushbutton_p.h
index f6804af277..f6804af277 100644
--- a/src/gui/widgets/qpushbutton_p.h
+++ b/src/widgets/widgets/qpushbutton_p.h
diff --git a/src/gui/widgets/qradiobutton.cpp b/src/widgets/widgets/qradiobutton.cpp
index bb13017dbc..bb13017dbc 100644
--- a/src/gui/widgets/qradiobutton.cpp
+++ b/src/widgets/widgets/qradiobutton.cpp
diff --git a/src/widgets/widgets/qradiobutton.h b/src/widgets/widgets/qradiobutton.h
new file mode 100644
index 0000000000..4489b93291
--- /dev/null
+++ b/src/widgets/widgets/qradiobutton.h
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QRADIOBUTTON_H
+#define QRADIOBUTTON_H
+
+#include <QtWidgets/qabstractbutton.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QRadioButtonPrivate;
+class QStyleOptionButton;
+
+class Q_GUI_EXPORT QRadioButton : public QAbstractButton
+{
+ Q_OBJECT
+
+public:
+ explicit QRadioButton(QWidget *parent=0);
+ explicit QRadioButton(const QString &text, QWidget *parent=0);
+
+ QSize sizeHint() const;
+ QSize minimumSizeHint() const;
+
+protected:
+ bool event(QEvent *e);
+ bool hitButton(const QPoint &) const;
+ void paintEvent(QPaintEvent *);
+ void mouseMoveEvent(QMouseEvent *);
+ void initStyleOption(QStyleOptionButton *button) const;
+
+#ifdef QT3_SUPPORT
+public:
+ QT3_SUPPORT_CONSTRUCTOR QRadioButton(QWidget *parent, const char* name);
+ QT3_SUPPORT_CONSTRUCTOR QRadioButton(const QString &text, QWidget *parent, const char* name);
+#endif
+
+private:
+ Q_DECLARE_PRIVATE(QRadioButton)
+ Q_DISABLE_COPY(QRadioButton)
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QRADIOBUTTON_H
diff --git a/src/gui/widgets/qrubberband.cpp b/src/widgets/widgets/qrubberband.cpp
index 55448c3116..55448c3116 100644
--- a/src/gui/widgets/qrubberband.cpp
+++ b/src/widgets/widgets/qrubberband.cpp
diff --git a/src/widgets/widgets/qrubberband.h b/src/widgets/widgets/qrubberband.h
new file mode 100644
index 0000000000..26257d351f
--- /dev/null
+++ b/src/widgets/widgets/qrubberband.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QRUBBERBAND_H
+#define QRUBBERBAND_H
+
+#include <QtWidgets/qwidget.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_RUBBERBAND
+
+class QRubberBandPrivate;
+class QStyleOptionRubberBand;
+
+class Q_GUI_EXPORT QRubberBand : public QWidget
+{
+ Q_OBJECT
+
+public:
+ enum Shape { Line, Rectangle };
+ explicit QRubberBand(Shape, QWidget * =0);
+ ~QRubberBand();
+
+ Shape shape() const;
+
+ void setGeometry(const QRect &r);
+
+ inline void setGeometry(int x, int y, int w, int h);
+ inline void move(int x, int y);
+ inline void move(const QPoint &p)
+ { move(p.x(), p.y()); }
+ inline void resize(int w, int h)
+ { setGeometry(geometry().x(), geometry().y(), w, h); }
+ inline void resize(const QSize &s)
+ { resize(s.width(), s.height()); }
+
+protected:
+ bool event(QEvent *e);
+ void paintEvent(QPaintEvent *);
+ void changeEvent(QEvent *);
+ void showEvent(QShowEvent *);
+ void resizeEvent(QResizeEvent *);
+ void moveEvent(QMoveEvent *);
+ void initStyleOption(QStyleOptionRubberBand *option) const;
+
+private:
+ Q_DECLARE_PRIVATE(QRubberBand)
+};
+
+inline void QRubberBand::setGeometry(int ax, int ay, int aw, int ah)
+{ setGeometry(QRect(ax, ay, aw, ah)); }
+inline void QRubberBand::move(int ax, int ay)
+{ setGeometry(ax, ay, width(), height()); }
+
+#endif // QT_NO_RUBBERBAND
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QRUBBERBAND_H
diff --git a/src/gui/widgets/qscrollarea.cpp b/src/widgets/widgets/qscrollarea.cpp
index d33c3ac008..d33c3ac008 100644
--- a/src/gui/widgets/qscrollarea.cpp
+++ b/src/widgets/widgets/qscrollarea.cpp
diff --git a/src/widgets/widgets/qscrollarea.h b/src/widgets/widgets/qscrollarea.h
new file mode 100644
index 0000000000..637f2ffb39
--- /dev/null
+++ b/src/widgets/widgets/qscrollarea.h
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSCROLLAREA_H
+#define QSCROLLAREA_H
+
+#include <QtWidgets/qabstractscrollarea.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_SCROLLAREA
+
+class QScrollAreaPrivate;
+
+class Q_GUI_EXPORT QScrollArea : public QAbstractScrollArea
+{
+ Q_OBJECT
+ Q_PROPERTY(bool widgetResizable READ widgetResizable WRITE setWidgetResizable)
+ Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment)
+
+public:
+ explicit QScrollArea(QWidget* parent=0);
+ ~QScrollArea();
+
+ QWidget *widget() const;
+ void setWidget(QWidget *widget);
+ QWidget *takeWidget();
+
+ bool widgetResizable() const;
+ void setWidgetResizable(bool resizable);
+
+ QSize sizeHint() const;
+ bool focusNextPrevChild(bool next);
+
+ Qt::Alignment alignment() const;
+ void setAlignment(Qt::Alignment);
+
+ void ensureVisible(int x, int y, int xmargin = 50, int ymargin = 50);
+ void ensureWidgetVisible(QWidget *childWidget, int xmargin = 50, int ymargin = 50);
+
+protected:
+ QScrollArea(QScrollAreaPrivate &dd, QWidget *parent = 0);
+ bool event(QEvent *);
+ bool eventFilter(QObject *, QEvent *);
+ void resizeEvent(QResizeEvent *);
+ void scrollContentsBy(int dx, int dy);
+
+private:
+ Q_DECLARE_PRIVATE(QScrollArea)
+ Q_DISABLE_COPY(QScrollArea)
+};
+
+#endif // QT_NO_SCROLLAREA
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QSCROLLAREA_H
diff --git a/src/widgets/widgets/qscrollarea_p.h b/src/widgets/widgets/qscrollarea_p.h
new file mode 100644
index 0000000000..4a30ce217b
--- /dev/null
+++ b/src/widgets/widgets/qscrollarea_p.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSCROLLAREA_P_H
+#define QSCROLLAREA_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.
+//
+
+#ifndef QT_NO_SCROLLAREA
+
+#include "private/qabstractscrollarea_p.h"
+#include <QtWidgets/qscrollbar.h>
+
+QT_BEGIN_NAMESPACE
+
+class QScrollAreaPrivate: public QAbstractScrollAreaPrivate
+{
+ Q_DECLARE_PUBLIC(QScrollArea)
+
+public:
+ QScrollAreaPrivate(): resizable(false), alignment(0){}
+ void updateScrollBars();
+ void updateWidgetPosition();
+ QPointer<QWidget> widget;
+ mutable QSize widgetSize;
+ bool resizable;
+ Qt::Alignment alignment;
+};
+
+#endif
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/gui/widgets/qscrollbar.cpp b/src/widgets/widgets/qscrollbar.cpp
index 87738a0083..87738a0083 100644
--- a/src/gui/widgets/qscrollbar.cpp
+++ b/src/widgets/widgets/qscrollbar.cpp
diff --git a/src/widgets/widgets/qscrollbar.h b/src/widgets/widgets/qscrollbar.h
new file mode 100644
index 0000000000..47f858fe3f
--- /dev/null
+++ b/src/widgets/widgets/qscrollbar.h
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSCROLLBAR_H
+#define QSCROLLBAR_H
+
+#include <QtWidgets/qwidget.h>
+#include <QtWidgets/qabstractslider.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_SCROLLBAR
+
+class QScrollBarPrivate;
+class QStyleOptionSlider;
+
+class Q_GUI_EXPORT QScrollBar : public QAbstractSlider
+{
+ Q_OBJECT
+public:
+ explicit QScrollBar(QWidget *parent=0);
+ explicit QScrollBar(Qt::Orientation, QWidget *parent=0);
+ ~QScrollBar();
+
+ QSize sizeHint() const;
+ bool event(QEvent *event);
+
+protected:
+ void paintEvent(QPaintEvent *);
+ void mousePressEvent(QMouseEvent *);
+ void mouseReleaseEvent(QMouseEvent *);
+ void mouseMoveEvent(QMouseEvent *);
+ void hideEvent(QHideEvent*);
+ void sliderChange(SliderChange change);
+#ifndef QT_NO_CONTEXTMENU
+ void contextMenuEvent(QContextMenuEvent *);
+#endif
+ void initStyleOption(QStyleOptionSlider *option) const;
+
+#ifdef QT3_SUPPORT
+public:
+ QT3_SUPPORT_CONSTRUCTOR QScrollBar(QWidget *parent, const char* name);
+ QT3_SUPPORT_CONSTRUCTOR QScrollBar(Qt::Orientation, QWidget *parent, const char* name);
+ QT3_SUPPORT_CONSTRUCTOR QScrollBar(int minValue, int maxValue, int lineStep, int pageStep,
+ int value, Qt::Orientation, QWidget *parent=0, const char* name = 0);
+ inline QT3_SUPPORT bool draggingSlider() { return isSliderDown(); }
+#endif
+
+private:
+ friend Q_GUI_EXPORT QStyleOptionSlider qt_qscrollbarStyleOption(QScrollBar *scrollBar);
+
+ Q_DISABLE_COPY(QScrollBar)
+ Q_DECLARE_PRIVATE(QScrollBar)
+};
+
+#endif // QT_NO_SCROLLBAR
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QSCROLLBAR_H
diff --git a/src/widgets/widgets/qsizegrip.cpp b/src/widgets/widgets/qsizegrip.cpp
new file mode 100644
index 0000000000..d5c231020c
--- /dev/null
+++ b/src/widgets/widgets/qsizegrip.cpp
@@ -0,0 +1,570 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qsizegrip.h"
+
+#ifndef QT_NO_SIZEGRIP
+
+#include "qapplication.h"
+#include "qevent.h"
+#include "qpainter.h"
+#include "qstyle.h"
+#include "qstyleoption.h"
+#include "qlayout.h"
+#include "qdebug.h"
+#include <QDesktopWidget>
+
+#if defined(Q_WS_X11)
+#include <private/qt_x11_p.h>
+#elif defined (Q_WS_WIN)
+#include "qt_windows.h"
+#endif
+#ifdef Q_WS_MAC
+#include <private/qt_mac_p.h>
+#endif
+
+#include <private/qwidget_p.h>
+#include <QtWidgets/qabstractscrollarea.h>
+
+#define SZ_SIZEBOTTOMRIGHT 0xf008
+#define SZ_SIZEBOTTOMLEFT 0xf007
+#define SZ_SIZETOPLEFT 0xf004
+#define SZ_SIZETOPRIGHT 0xf005
+
+QT_BEGIN_NAMESPACE
+
+static QWidget *qt_sizegrip_topLevelWidget(QWidget* w)
+{
+ while (w && !w->isWindow() && w->windowType() != Qt::SubWindow)
+ w = w->parentWidget();
+ return w;
+}
+
+class QSizeGripPrivate : public QWidgetPrivate
+{
+ Q_DECLARE_PUBLIC(QSizeGrip)
+public:
+ void init();
+ QPoint p;
+ QRect r;
+ int d;
+ int dxMax;
+ int dyMax;
+ Qt::Corner m_corner;
+ bool gotMousePress;
+ QWidget *tlw;
+#ifdef Q_WS_MAC
+ void updateMacSizer(bool hide) const;
+#endif
+ Qt::Corner corner() const;
+ inline bool atBottom() const
+ {
+ return m_corner == Qt::BottomRightCorner || m_corner == Qt::BottomLeftCorner;
+ }
+
+ inline bool atLeft() const
+ {
+ return m_corner == Qt::BottomLeftCorner || m_corner == Qt::TopLeftCorner;
+ }
+
+ void updateTopLevelWidget()
+ {
+ Q_Q(QSizeGrip);
+ QWidget *w = qt_sizegrip_topLevelWidget(q);
+ if (tlw == w)
+ return;
+ if (tlw)
+ tlw->removeEventFilter(q);
+ tlw = w;
+ if (tlw)
+ tlw->installEventFilter(q);
+ }
+
+ // This slot is invoked by QLayout when the size grip is added to
+ // a layout or reparented after the tlw is shown. This re-implementation is basically
+ // the same as QWidgetPrivate::_q_showIfNotHidden except that it checks
+ // for Qt::WindowFullScreen and Qt::WindowMaximized as well.
+ void _q_showIfNotHidden()
+ {
+ Q_Q(QSizeGrip);
+ bool showSizeGrip = !(q->isHidden() && q->testAttribute(Qt::WA_WState_ExplicitShowHide));
+ updateTopLevelWidget();
+ if (tlw && showSizeGrip) {
+ Qt::WindowStates sizeGripNotVisibleState = Qt::WindowFullScreen;
+#ifndef Q_WS_MAC
+ sizeGripNotVisibleState |= Qt::WindowMaximized;
+#endif
+ // Don't show the size grip if the tlw is maximized or in full screen mode.
+ showSizeGrip = !(tlw->windowState() & sizeGripNotVisibleState);
+ }
+ if (showSizeGrip)
+ q->setVisible(true);
+ }
+};
+
+#ifdef Q_WS_MAC
+void QSizeGripPrivate::updateMacSizer(bool hide) const
+{
+ Q_Q(const QSizeGrip);
+ if (QApplication::closingDown() || !parent)
+ return;
+ QWidget *topLevelWindow = qt_sizegrip_topLevelWidget(const_cast<QSizeGrip *>(q));
+ if(topLevelWindow && topLevelWindow->isWindow())
+ QWidgetPrivate::qt_mac_update_sizer(topLevelWindow, hide ? -1 : 1);
+}
+#endif
+
+Qt::Corner QSizeGripPrivate::corner() const
+{
+ Q_Q(const QSizeGrip);
+ QWidget *tlw = qt_sizegrip_topLevelWidget(const_cast<QSizeGrip *>(q));
+ const QPoint sizeGripPos = q->mapTo(tlw, QPoint(0, 0));
+ bool isAtBottom = sizeGripPos.y() >= tlw->height() / 2;
+ bool isAtLeft = sizeGripPos.x() <= tlw->width() / 2;
+ if (isAtLeft)
+ return isAtBottom ? Qt::BottomLeftCorner : Qt::TopLeftCorner;
+ else
+ return isAtBottom ? Qt::BottomRightCorner : Qt::TopRightCorner;
+}
+
+/*!
+ \class QSizeGrip
+
+ \brief The QSizeGrip class provides a resize handle for resizing top-level windows.
+
+ \ingroup mainwindow-classes
+ \ingroup basicwidgets
+
+ This widget works like the standard Windows resize handle. In the
+ X11 version this resize handle generally works differently from
+ the one provided by the system if the X11 window manager does not
+ support necessary modern post-ICCCM specifications.
+
+ Put this widget anywhere in a widget tree and the user can use it
+ to resize the top-level window or any widget with the Qt::SubWindow
+ flag set. Generally, this should be in the lower right-hand corner.
+ Note that QStatusBar already uses this widget, so if you have a
+ status bar (e.g., you are using QMainWindow), then you don't need
+ to use this widget explicitly.
+
+ On some platforms the size grip automatically hides itself when the
+ window is shown full screen or maximised.
+
+ \table 50%
+ \row \o \inlineimage plastique-sizegrip.png Screenshot of a Plastique style size grip
+ \o A size grip widget at the bottom-right corner of a main window, shown in the
+ \l{Plastique Style Widget Gallery}{Plastique widget style}.
+ \endtable
+
+ The QSizeGrip class inherits QWidget and reimplements the \l
+ {QWidget::mousePressEvent()}{mousePressEvent()} and \l
+ {QWidget::mouseMoveEvent()}{mouseMoveEvent()} functions to feature
+ the resize functionality, and the \l
+ {QWidget::paintEvent()}{paintEvent()} function to render the
+ size grip widget.
+
+ \sa QStatusBar QWidget::windowState()
+*/
+
+
+/*!
+ Constructs a resize corner as a child widget of the given \a
+ parent.
+*/
+QSizeGrip::QSizeGrip(QWidget * parent)
+ : QWidget(*new QSizeGripPrivate, parent, 0)
+{
+ Q_D(QSizeGrip);
+ d->init();
+}
+
+#ifdef QT3_SUPPORT
+/*!
+ \obsolete
+
+ Constructs a resize corner with the given \a name, as a child
+ widget of the given \a parent.
+*/
+QSizeGrip::QSizeGrip(QWidget * parent, const char* name)
+ : QWidget(*new QSizeGripPrivate, parent, 0)
+{
+ Q_D(QSizeGrip);
+ setObjectName(QString::fromAscii(name));
+ d->init();
+}
+#endif
+
+void QSizeGripPrivate::init()
+{
+ Q_Q(QSizeGrip);
+ dxMax = 0;
+ dyMax = 0;
+ tlw = 0;
+ m_corner = q->isLeftToRight() ? Qt::BottomRightCorner : Qt::BottomLeftCorner;
+ gotMousePress = false;
+
+#if !defined(QT_NO_CURSOR) && !defined(Q_WS_MAC)
+ q->setCursor(m_corner == Qt::TopLeftCorner || m_corner == Qt::BottomRightCorner
+ ? Qt::SizeFDiagCursor : Qt::SizeBDiagCursor);
+#endif
+ q->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
+ updateTopLevelWidget();
+}
+
+
+/*!
+ Destroys this size grip.
+*/
+QSizeGrip::~QSizeGrip()
+{
+}
+
+/*!
+ \reimp
+*/
+QSize QSizeGrip::sizeHint() const
+{
+ QStyleOption opt(0);
+ opt.init(this);
+ return (style()->sizeFromContents(QStyle::CT_SizeGrip, &opt, QSize(13, 13), this).
+ expandedTo(QApplication::globalStrut()));
+}
+
+/*!
+ Paints the resize grip.
+
+ Resize grips are usually rendered as small diagonal textured lines
+ in the lower-right corner. The paint event is passed in the \a
+ event parameter.
+*/
+void QSizeGrip::paintEvent(QPaintEvent *event)
+{
+ Q_UNUSED(event);
+ Q_D(QSizeGrip);
+ QPainter painter(this);
+ QStyleOptionSizeGrip opt;
+ opt.init(this);
+ opt.corner = d->m_corner;
+ style()->drawControl(QStyle::CE_SizeGrip, &opt, &painter, this);
+}
+
+/*!
+ \fn void QSizeGrip::mousePressEvent(QMouseEvent * event)
+
+ Receives the mouse press events for the widget, and primes the
+ resize operation. The mouse press event is passed in the \a event
+ parameter.
+*/
+void QSizeGrip::mousePressEvent(QMouseEvent * e)
+{
+ if (e->button() != Qt::LeftButton) {
+ QWidget::mousePressEvent(e);
+ return;
+ }
+
+ Q_D(QSizeGrip);
+ QWidget *tlw = qt_sizegrip_topLevelWidget(this);
+ d->p = e->globalPos();
+ d->gotMousePress = true;
+ d->r = tlw->geometry();
+
+#ifdef Q_WS_X11
+ // Use a native X11 sizegrip for "real" top-level windows if supported.
+ if (tlw->isWindow() && X11->isSupportedByWM(ATOM(_NET_WM_MOVERESIZE))
+ && !(tlw->windowFlags() & Qt::X11BypassWindowManagerHint)
+ && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) {
+ XEvent xev;
+ xev.xclient.type = ClientMessage;
+ xev.xclient.message_type = ATOM(_NET_WM_MOVERESIZE);
+ xev.xclient.display = X11->display;
+ xev.xclient.window = tlw->winId();
+ xev.xclient.format = 32;
+ xev.xclient.data.l[0] = e->globalPos().x();
+ xev.xclient.data.l[1] = e->globalPos().y();
+ if (d->atBottom())
+ xev.xclient.data.l[2] = d->atLeft() ? 6 : 4; // bottomleft/bottomright
+ else
+ xev.xclient.data.l[2] = d->atLeft() ? 0 : 2; // topleft/topright
+ xev.xclient.data.l[3] = Button1;
+ xev.xclient.data.l[4] = 0;
+ XUngrabPointer(X11->display, X11->time);
+ XSendEvent(X11->display, QX11Info::appRootWindow(x11Info().screen()), False,
+ SubstructureRedirectMask | SubstructureNotifyMask, &xev);
+ return;
+ }
+#endif // Q_WS_X11
+#ifdef Q_WS_WIN
+ if (tlw->isWindow() && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) {
+ uint orientation = 0;
+ if (d->atBottom())
+ orientation = d->atLeft() ? SZ_SIZEBOTTOMLEFT : SZ_SIZEBOTTOMRIGHT;
+ else
+ orientation = d->atLeft() ? SZ_SIZETOPLEFT : SZ_SIZETOPRIGHT;
+
+ ReleaseCapture();
+ PostMessage(tlw->winId(), WM_SYSCOMMAND, orientation, 0);
+ return;
+ }
+#endif // Q_WS_WIN
+
+ // Find available desktop/workspace geometry.
+ QRect availableGeometry;
+ bool hasVerticalSizeConstraint = true;
+ bool hasHorizontalSizeConstraint = true;
+ if (tlw->isWindow())
+ availableGeometry = QApplication::desktop()->availableGeometry(tlw);
+ else {
+ const QWidget *tlwParent = tlw->parentWidget();
+ // Check if tlw is inside QAbstractScrollArea/QScrollArea.
+ // If that's the case tlw->parentWidget() will return the viewport
+ // and tlw->parentWidget()->parentWidget() will return the scroll area.
+#ifndef QT_NO_SCROLLAREA
+ QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(tlwParent->parentWidget());
+ if (scrollArea) {
+ hasHorizontalSizeConstraint = scrollArea->horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOff;
+ hasVerticalSizeConstraint = scrollArea->verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOff;
+ }
+#endif // QT_NO_SCROLLAREA
+ availableGeometry = tlwParent->contentsRect();
+ }
+
+ // Find frame geometries, title bar height, and decoration sizes.
+ const QRect frameGeometry = tlw->frameGeometry();
+ const int titleBarHeight = qMax(tlw->geometry().y() - frameGeometry.y(), 0);
+ const int bottomDecoration = qMax(frameGeometry.height() - tlw->height() - titleBarHeight, 0);
+ const int leftRightDecoration = qMax((frameGeometry.width() - tlw->width()) / 2, 0);
+
+ // Determine dyMax depending on whether the sizegrip is at the bottom
+ // of the widget or not.
+ if (d->atBottom()) {
+ if (hasVerticalSizeConstraint)
+ d->dyMax = availableGeometry.bottom() - d->r.bottom() - bottomDecoration;
+ else
+ d->dyMax = INT_MAX;
+ } else {
+ if (hasVerticalSizeConstraint)
+ d->dyMax = availableGeometry.y() - d->r.y() + titleBarHeight;
+ else
+ d->dyMax = -INT_MAX;
+ }
+
+ // In RTL mode, the size grip is to the left; find dxMax from the desktop/workspace
+ // geometry, the size grip geometry and the width of the decoration.
+ if (d->atLeft()) {
+ if (hasHorizontalSizeConstraint)
+ d->dxMax = availableGeometry.x() - d->r.x() + leftRightDecoration;
+ else
+ d->dxMax = -INT_MAX;
+ } else {
+ if (hasHorizontalSizeConstraint)
+ d->dxMax = availableGeometry.right() - d->r.right() - leftRightDecoration;
+ else
+ d->dxMax = INT_MAX;
+ }
+}
+
+
+/*!
+ \fn void QSizeGrip::mouseMoveEvent(QMouseEvent * event)
+ Resizes the top-level widget containing this widget. The mouse
+ move event is passed in the \a event parameter.
+*/
+void QSizeGrip::mouseMoveEvent(QMouseEvent * e)
+{
+ if (e->buttons() != Qt::LeftButton) {
+ QWidget::mouseMoveEvent(e);
+ return;
+ }
+
+ Q_D(QSizeGrip);
+ QWidget* tlw = qt_sizegrip_topLevelWidget(this);
+ if (!d->gotMousePress || tlw->testAttribute(Qt::WA_WState_ConfigPending))
+ return;
+
+#ifdef Q_WS_X11
+ if (tlw->isWindow() && X11->isSupportedByWM(ATOM(_NET_WM_MOVERESIZE))
+ && tlw->isTopLevel() && !(tlw->windowFlags() & Qt::X11BypassWindowManagerHint)
+ && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth())
+ return;
+#endif
+#ifdef Q_WS_WIN
+ if (tlw->isWindow() && GetSystemMenu(tlw->winId(), FALSE) != 0 && internalWinId()
+ && !tlw->testAttribute(Qt::WA_DontShowOnScreen) && !qt_widget_private(tlw)->hasHeightForWidth()) {
+ MSG msg;
+ while(PeekMessage(&msg, winId(), WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE));
+ return;
+ }
+#endif
+
+ QPoint np(e->globalPos());
+
+ // Don't extend beyond the available geometry; bound to dyMax and dxMax.
+ QSize ns;
+ if (d->atBottom())
+ ns.rheight() = d->r.height() + qMin(np.y() - d->p.y(), d->dyMax);
+ else
+ ns.rheight() = d->r.height() - qMax(np.y() - d->p.y(), d->dyMax);
+
+ if (d->atLeft())
+ ns.rwidth() = d->r.width() - qMax(np.x() - d->p.x(), d->dxMax);
+ else
+ ns.rwidth() = d->r.width() + qMin(np.x() - d->p.x(), d->dxMax);
+
+ ns = QLayout::closestAcceptableSize(tlw, ns);
+
+ QPoint p;
+ QRect nr(p, ns);
+ if (d->atBottom()) {
+ if (d->atLeft())
+ nr.moveTopRight(d->r.topRight());
+ else
+ nr.moveTopLeft(d->r.topLeft());
+ } else {
+ if (d->atLeft())
+ nr.moveBottomRight(d->r.bottomRight());
+ else
+ nr.moveBottomLeft(d->r.bottomLeft());
+ }
+
+ tlw->setGeometry(nr);
+}
+
+/*!
+ \reimp
+*/
+void QSizeGrip::mouseReleaseEvent(QMouseEvent *mouseEvent)
+{
+ if (mouseEvent->button() == Qt::LeftButton) {
+ Q_D(QSizeGrip);
+ d->gotMousePress = false;
+ d->p = QPoint();
+ } else {
+ QWidget::mouseReleaseEvent(mouseEvent);
+ }
+}
+
+/*!
+ \reimp
+*/
+void QSizeGrip::moveEvent(QMoveEvent * /*moveEvent*/)
+{
+ Q_D(QSizeGrip);
+ // We're inside a resize operation; no update necessary.
+ if (!d->p.isNull())
+ return;
+
+ d->m_corner = d->corner();
+#if !defined(QT_NO_CURSOR) && !defined(Q_WS_MAC)
+ setCursor(d->m_corner == Qt::TopLeftCorner || d->m_corner == Qt::BottomRightCorner
+ ? Qt::SizeFDiagCursor : Qt::SizeBDiagCursor);
+#endif
+}
+
+/*!
+ \reimp
+*/
+void QSizeGrip::showEvent(QShowEvent *showEvent)
+{
+#ifdef Q_WS_MAC
+ d_func()->updateMacSizer(false);
+#endif
+ QWidget::showEvent(showEvent);
+}
+
+/*!
+ \reimp
+*/
+void QSizeGrip::hideEvent(QHideEvent *hideEvent)
+{
+#ifdef Q_WS_MAC
+ d_func()->updateMacSizer(true);
+#endif
+ QWidget::hideEvent(hideEvent);
+}
+
+/*!
+ \reimp
+*/
+void QSizeGrip::setVisible(bool visible)
+{
+ QWidget::setVisible(visible);
+}
+
+/*! \reimp */
+bool QSizeGrip::eventFilter(QObject *o, QEvent *e)
+{
+ Q_D(QSizeGrip);
+ if ((isHidden() && testAttribute(Qt::WA_WState_ExplicitShowHide))
+ || e->type() != QEvent::WindowStateChange
+ || o != d->tlw) {
+ return QWidget::eventFilter(o, e);
+ }
+ Qt::WindowStates sizeGripNotVisibleState = Qt::WindowFullScreen;
+#ifndef Q_WS_MAC
+ sizeGripNotVisibleState |= Qt::WindowMaximized;
+#endif
+ // Don't show the size grip if the tlw is maximized or in full screen mode.
+ setVisible(!(d->tlw->windowState() & sizeGripNotVisibleState));
+ setAttribute(Qt::WA_WState_ExplicitShowHide, false);
+ return QWidget::eventFilter(o, e);
+}
+
+/*!
+ \reimp
+*/
+bool QSizeGrip::event(QEvent *event)
+{
+ return QWidget::event(event);
+}
+
+#ifdef Q_WS_WIN
+/*! \reimp */
+bool QSizeGrip::winEvent( MSG *m, long *result )
+{
+ return QWidget::winEvent(m, result);
+}
+#endif
+
+QT_END_NAMESPACE
+
+#include "moc_qsizegrip.cpp"
+
+#endif //QT_NO_SIZEGRIP
diff --git a/src/widgets/widgets/qsizegrip.h b/src/widgets/widgets/qsizegrip.h
new file mode 100644
index 0000000000..acb98e3a3c
--- /dev/null
+++ b/src/widgets/widgets/qsizegrip.h
@@ -0,0 +1,95 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSIZEGRIP_H
+#define QSIZEGRIP_H
+
+#include <QtWidgets/qwidget.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_SIZEGRIP
+class QSizeGripPrivate;
+class Q_GUI_EXPORT QSizeGrip : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit QSizeGrip(QWidget *parent);
+ ~QSizeGrip();
+
+ QSize sizeHint() const;
+ void setVisible(bool);
+
+protected:
+ void paintEvent(QPaintEvent *);
+ void mousePressEvent(QMouseEvent *);
+ void mouseMoveEvent(QMouseEvent *);
+ void mouseReleaseEvent(QMouseEvent *mouseEvent);
+ void moveEvent(QMoveEvent *moveEvent);
+ void showEvent(QShowEvent *showEvent);
+ void hideEvent(QHideEvent *hideEvent);
+ bool eventFilter(QObject *, QEvent *);
+ bool event(QEvent *);
+#ifdef Q_WS_WIN
+ bool winEvent(MSG *m, long *result);
+#endif
+
+public:
+#ifdef QT3_SUPPORT
+ QT3_SUPPORT_CONSTRUCTOR QSizeGrip(QWidget *parent, const char *name);
+#endif
+
+private:
+ Q_DECLARE_PRIVATE(QSizeGrip)
+ Q_DISABLE_COPY(QSizeGrip)
+ Q_PRIVATE_SLOT(d_func(), void _q_showIfNotHidden())
+};
+#endif // QT_NO_SIZEGRIP
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QSIZEGRIP_H
diff --git a/src/gui/widgets/qslider.cpp b/src/widgets/widgets/qslider.cpp
index 1eefb9c5f1..1eefb9c5f1 100644
--- a/src/gui/widgets/qslider.cpp
+++ b/src/widgets/widgets/qslider.cpp
diff --git a/src/widgets/widgets/qslider.h b/src/widgets/widgets/qslider.h
new file mode 100644
index 0000000000..a6c457267e
--- /dev/null
+++ b/src/widgets/widgets/qslider.h
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSLIDER_H
+#define QSLIDER_H
+
+#include <QtWidgets/qabstractslider.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_SLIDER
+
+class QSliderPrivate;
+class QStyleOptionSlider;
+class Q_GUI_EXPORT QSlider : public QAbstractSlider
+{
+ Q_OBJECT
+
+ Q_ENUMS(TickPosition)
+ Q_PROPERTY(TickPosition tickPosition READ tickPosition WRITE setTickPosition)
+ Q_PROPERTY(int tickInterval READ tickInterval WRITE setTickInterval)
+
+public:
+ enum TickPosition {
+ NoTicks = 0,
+ TicksAbove = 1,
+ TicksLeft = TicksAbove,
+ TicksBelow = 2,
+ TicksRight = TicksBelow,
+ TicksBothSides = 3
+
+#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
+ ,NoMarks = NoTicks,
+ Above = TicksAbove,
+ Left = TicksAbove,
+ Below = TicksBelow,
+ Right = TicksRight,
+ Both = TicksBothSides
+#endif
+ };
+
+ explicit QSlider(QWidget *parent = 0);
+ explicit QSlider(Qt::Orientation orientation, QWidget *parent = 0);
+
+ ~QSlider();
+
+ QSize sizeHint() const;
+ QSize minimumSizeHint() const;
+
+ void setTickPosition(TickPosition position);
+ TickPosition tickPosition() const;
+
+ void setTickInterval(int ti);
+ int tickInterval() const;
+
+ bool event(QEvent *event);
+
+protected:
+ void paintEvent(QPaintEvent *ev);
+ void mousePressEvent(QMouseEvent *ev);
+ void mouseReleaseEvent(QMouseEvent *ev);
+ void mouseMoveEvent(QMouseEvent *ev);
+ void initStyleOption(QStyleOptionSlider *option) const;
+
+#ifdef QT3_SUPPORT
+public:
+ QT3_SUPPORT_CONSTRUCTOR QSlider(QWidget *parent, const char *name);
+ QT3_SUPPORT_CONSTRUCTOR QSlider(Qt::Orientation, QWidget *parent, const char *name);
+ QT3_SUPPORT_CONSTRUCTOR QSlider(int minValue, int maxValue, int pageStep, int value,
+ Qt::Orientation orientation,
+ QWidget *parent = 0, const char *name = 0);
+ inline QT3_SUPPORT void setTickmarks(TickPosition position) { setTickPosition(position); }
+ inline QT3_SUPPORT TickPosition tickmarks() const { return tickPosition(); }
+public Q_SLOTS:
+ inline QT_MOC_COMPAT void addStep() { triggerAction(SliderSingleStepAdd); }
+ inline QT_MOC_COMPAT void subtractStep() { triggerAction(SliderSingleStepSub); }
+#endif
+
+private:
+ friend Q_GUI_EXPORT QStyleOptionSlider qt_qsliderStyleOption(QSlider *slider);
+
+ Q_DISABLE_COPY(QSlider)
+ Q_DECLARE_PRIVATE(QSlider)
+};
+
+#endif // QT_NO_SLIDER
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QSLIDER_H
diff --git a/src/gui/widgets/qspinbox.cpp b/src/widgets/widgets/qspinbox.cpp
index 22fd2a9cc4..22fd2a9cc4 100644
--- a/src/gui/widgets/qspinbox.cpp
+++ b/src/widgets/widgets/qspinbox.cpp
diff --git a/src/widgets/widgets/qspinbox.h b/src/widgets/widgets/qspinbox.h
new file mode 100644
index 0000000000..cb7f0b8b69
--- /dev/null
+++ b/src/widgets/widgets/qspinbox.h
@@ -0,0 +1,188 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSPINBOX_H
+#define QSPINBOX_H
+
+#include <QtWidgets/qabstractspinbox.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_SPINBOX
+
+class QSpinBoxPrivate;
+class Q_GUI_EXPORT QSpinBox : public QAbstractSpinBox
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString suffix READ suffix WRITE setSuffix)
+ Q_PROPERTY(QString prefix READ prefix WRITE setPrefix)
+ Q_PROPERTY(QString cleanText READ cleanText)
+ Q_PROPERTY(int minimum READ minimum WRITE setMinimum)
+ Q_PROPERTY(int maximum READ maximum WRITE setMaximum)
+ Q_PROPERTY(int singleStep READ singleStep WRITE setSingleStep)
+ Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged USER true)
+
+public:
+ explicit QSpinBox(QWidget *parent = 0);
+#ifdef QT3_SUPPORT
+ QT3_SUPPORT_CONSTRUCTOR QSpinBox(QWidget *parent, const char *name);
+ QT3_SUPPORT_CONSTRUCTOR QSpinBox(int min, int max, int step, QWidget *parent,
+ const char *name = 0);
+#endif
+
+ int value() const;
+
+ QString prefix() const;
+ void setPrefix(const QString &prefix);
+
+ QString suffix() const;
+ void setSuffix(const QString &suffix);
+
+ QString cleanText() const;
+
+ int singleStep() const;
+ void setSingleStep(int val);
+
+ int minimum() const;
+ void setMinimum(int min);
+
+ int maximum() const;
+ void setMaximum(int max);
+
+ void setRange(int min, int max);
+
+#ifdef QT3_SUPPORT
+ inline QT3_SUPPORT void setLineStep(int step) { setSingleStep(step); }
+ inline QT3_SUPPORT void setMaxValue(int val) { setMaximum(val); }
+ inline QT3_SUPPORT void setMinValue(int val) { setMinimum(val); }
+ inline QT3_SUPPORT int maxValue() const { return maximum(); }
+ inline QT3_SUPPORT int minValue() const { return minimum(); }
+#endif
+
+protected:
+ bool event(QEvent *event);
+ virtual QValidator::State validate(QString &input, int &pos) const;
+ virtual int valueFromText(const QString &text) const;
+ virtual QString textFromValue(int val) const;
+ virtual void fixup(QString &str) const;
+
+
+public Q_SLOTS:
+ void setValue(int val);
+
+Q_SIGNALS:
+ void valueChanged(int);
+ void valueChanged(const QString &);
+
+private:
+ Q_DISABLE_COPY(QSpinBox)
+ Q_DECLARE_PRIVATE(QSpinBox)
+};
+
+class QDoubleSpinBoxPrivate;
+class Q_GUI_EXPORT QDoubleSpinBox : public QAbstractSpinBox
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QString prefix READ prefix WRITE setPrefix)
+ Q_PROPERTY(QString suffix READ suffix WRITE setSuffix)
+ Q_PROPERTY(QString cleanText READ cleanText)
+ Q_PROPERTY(int decimals READ decimals WRITE setDecimals)
+ Q_PROPERTY(double minimum READ minimum WRITE setMinimum)
+ Q_PROPERTY(double maximum READ maximum WRITE setMaximum)
+ Q_PROPERTY(double singleStep READ singleStep WRITE setSingleStep)
+ Q_PROPERTY(double value READ value WRITE setValue NOTIFY valueChanged USER true)
+public:
+ explicit QDoubleSpinBox(QWidget *parent = 0);
+
+ double value() const;
+
+ QString prefix() const;
+ void setPrefix(const QString &prefix);
+
+ QString suffix() const;
+ void setSuffix(const QString &suffix);
+
+ QString cleanText() const;
+
+ double singleStep() const;
+ void setSingleStep(double val);
+
+ double minimum() const;
+ void setMinimum(double min);
+
+ double maximum() const;
+ void setMaximum(double max);
+
+ void setRange(double min, double max);
+
+ int decimals() const;
+ void setDecimals(int prec);
+
+ virtual QValidator::State validate(QString &input, int &pos) const;
+ virtual double valueFromText(const QString &text) const;
+ virtual QString textFromValue(double val) const;
+ virtual void fixup(QString &str) const;
+
+public Q_SLOTS:
+ void setValue(double val);
+
+Q_SIGNALS:
+ void valueChanged(double);
+ void valueChanged(const QString &);
+
+private:
+ Q_DISABLE_COPY(QDoubleSpinBox)
+ Q_DECLARE_PRIVATE(QDoubleSpinBox)
+};
+
+#endif // QT_NO_SPINBOX
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QSPINBOX_H
diff --git a/src/gui/widgets/qsplashscreen.cpp b/src/widgets/widgets/qsplashscreen.cpp
index 9c486bfca4..9c486bfca4 100644
--- a/src/gui/widgets/qsplashscreen.cpp
+++ b/src/widgets/widgets/qsplashscreen.cpp
diff --git a/src/widgets/widgets/qsplashscreen.h b/src/widgets/widgets/qsplashscreen.h
new file mode 100644
index 0000000000..b2ea2b7f51
--- /dev/null
+++ b/src/widgets/widgets/qsplashscreen.h
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSPLASHSCREEN_H
+#define QSPLASHSCREEN_H
+
+#include <QtGui/qpixmap.h>
+#include <QtWidgets/qwidget.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_SPLASHSCREEN
+class QSplashScreenPrivate;
+
+class Q_GUI_EXPORT QSplashScreen : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit QSplashScreen(const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = 0);
+ QSplashScreen(QWidget *parent, const QPixmap &pixmap = QPixmap(), Qt::WindowFlags f = 0);
+ virtual ~QSplashScreen();
+
+ void setPixmap(const QPixmap &pixmap);
+ const QPixmap pixmap() const;
+ void finish(QWidget *w);
+ void repaint();
+
+public Q_SLOTS:
+ void showMessage(const QString &message, int alignment = Qt::AlignLeft,
+ const QColor &color = Qt::black);
+ void clearMessage();
+#ifdef QT3_SUPPORT
+ inline QT_MOC_COMPAT void message(const QString &str, int alignment = Qt::AlignLeft,
+ const QColor &color = Qt::black) { showMessage(str, alignment, color); }
+ inline QT_MOC_COMPAT void clear() { clearMessage(); }
+#endif
+
+Q_SIGNALS:
+ void messageChanged(const QString &message);
+
+protected:
+ bool event(QEvent *e);
+ virtual void drawContents(QPainter *painter);
+ void mousePressEvent(QMouseEvent *);
+
+private:
+ Q_DISABLE_COPY(QSplashScreen)
+ Q_DECLARE_PRIVATE(QSplashScreen)
+};
+
+#endif // QT_NO_SPLASHSCREEN
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QSPLASHSCREEN_H
diff --git a/src/gui/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp
index ca8fc3757a..ca8fc3757a 100644
--- a/src/gui/widgets/qsplitter.cpp
+++ b/src/widgets/widgets/qsplitter.cpp
diff --git a/src/widgets/widgets/qsplitter.h b/src/widgets/widgets/qsplitter.h
new file mode 100644
index 0000000000..9650fa71c1
--- /dev/null
+++ b/src/widgets/widgets/qsplitter.h
@@ -0,0 +1,192 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSPLITTER_H
+#define QSPLITTER_H
+
+#include <QtWidgets/qframe.h>
+#include <QtWidgets/qsizepolicy.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_SPLITTER
+
+class QSplitterPrivate;
+class QTextStream;
+template <typename T> class QList;
+
+class QSplitterHandle;
+
+class Q_GUI_EXPORT QSplitter : public QFrame
+{
+ Q_OBJECT
+
+ Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
+ Q_PROPERTY(bool opaqueResize READ opaqueResize WRITE setOpaqueResize)
+ Q_PROPERTY(int handleWidth READ handleWidth WRITE setHandleWidth)
+ Q_PROPERTY(bool childrenCollapsible READ childrenCollapsible WRITE setChildrenCollapsible)
+
+public:
+ explicit QSplitter(QWidget* parent = 0);
+ explicit QSplitter(Qt::Orientation, QWidget* parent = 0);
+ ~QSplitter();
+
+ void addWidget(QWidget *widget);
+ void insertWidget(int index, QWidget *widget);
+
+ void setOrientation(Qt::Orientation);
+ Qt::Orientation orientation() const;
+
+ void setChildrenCollapsible(bool);
+ bool childrenCollapsible() const;
+
+ void setCollapsible(int index, bool);
+ bool isCollapsible(int index) const;
+ void setOpaqueResize(bool opaque = true);
+ bool opaqueResize() const;
+ void refresh();
+
+ QSize sizeHint() const;
+ QSize minimumSizeHint() const;
+
+ QList<int> sizes() const;
+ void setSizes(const QList<int> &list);
+
+ QByteArray saveState() const;
+ bool restoreState(const QByteArray &state);
+
+ int handleWidth() const;
+ void setHandleWidth(int);
+
+ int indexOf(QWidget *w) const;
+ QWidget *widget(int index) const;
+ int count() const;
+
+ void getRange(int index, int *, int *) const;
+ QSplitterHandle *handle(int index) const;
+
+ void setStretchFactor(int index, int stretch);
+
+Q_SIGNALS:
+ void splitterMoved(int pos, int index);
+
+protected:
+ virtual QSplitterHandle *createHandle();
+
+ void childEvent(QChildEvent *);
+
+ bool event(QEvent *);
+ void resizeEvent(QResizeEvent *);
+
+ void changeEvent(QEvent *);
+ void moveSplitter(int pos, int index);
+ void setRubberBand(int position);
+ int closestLegalPosition(int, int);
+
+#ifdef QT3_SUPPORT
+public:
+ QT3_SUPPORT_CONSTRUCTOR QSplitter(QWidget* parent, const char* name);
+ QT3_SUPPORT_CONSTRUCTOR QSplitter(Qt::Orientation, QWidget* parent, const char* name);
+ enum ResizeMode { Stretch, KeepSize, FollowSizeHint, Auto };
+ QT3_SUPPORT void setResizeMode(QWidget *w, ResizeMode mode);
+ inline QT3_SUPPORT void moveToFirst(QWidget *w) { insertWidget(0,w); }
+ inline QT3_SUPPORT void moveToLast(QWidget *w) { addWidget(w); }
+ inline QT3_SUPPORT void setCollapsible(QWidget *w, bool collapse)
+ { setCollapsible(indexOf(w), collapse); }
+ QT3_SUPPORT void setMargin(int margin) { setContentsMargins(margin, margin, margin, margin); }
+ QT3_SUPPORT int margin() const
+ { int margin; int dummy; getContentsMargins(&margin, &dummy, &dummy, &dummy); return margin; }
+#endif
+
+private:
+ Q_DISABLE_COPY(QSplitter)
+ Q_DECLARE_PRIVATE(QSplitter)
+private:
+ friend class QSplitterHandle;
+};
+
+//#ifdef QT3_SUPPORT
+#ifndef QT_NO_TEXTSTREAM
+Q_GUI_EXPORT QTextStream& operator<<(QTextStream&, const QSplitter&);
+Q_GUI_EXPORT QTextStream& operator>>(QTextStream&, QSplitter&);
+#endif
+//#endif
+
+class QSplitterHandlePrivate;
+class Q_GUI_EXPORT QSplitterHandle : public QWidget
+{
+ Q_OBJECT
+public:
+ QSplitterHandle(Qt::Orientation o, QSplitter *parent);
+ void setOrientation(Qt::Orientation o);
+ Qt::Orientation orientation() const;
+ bool opaqueResize() const;
+ QSplitter *splitter() const;
+
+ QSize sizeHint() const;
+
+protected:
+ void paintEvent(QPaintEvent *);
+ void mouseMoveEvent(QMouseEvent *);
+ void mousePressEvent(QMouseEvent *);
+ void mouseReleaseEvent(QMouseEvent *);
+ void resizeEvent(QResizeEvent *);
+ bool event(QEvent *);
+
+ void moveSplitter(int p);
+ int closestLegalPosition(int p);
+
+private:
+ Q_DISABLE_COPY(QSplitterHandle)
+ Q_DECLARE_PRIVATE(QSplitterHandle)
+};
+
+#endif // QT_NO_SPLITTER
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QSPLITTER_H
diff --git a/src/gui/widgets/qsplitter_p.h b/src/widgets/widgets/qsplitter_p.h
index 1e72066194..1e72066194 100644
--- a/src/gui/widgets/qsplitter_p.h
+++ b/src/widgets/widgets/qsplitter_p.h
diff --git a/src/gui/widgets/qstackedwidget.cpp b/src/widgets/widgets/qstackedwidget.cpp
index a1c225bad4..a1c225bad4 100644
--- a/src/gui/widgets/qstackedwidget.cpp
+++ b/src/widgets/widgets/qstackedwidget.cpp
diff --git a/src/widgets/widgets/qstackedwidget.h b/src/widgets/widgets/qstackedwidget.h
new file mode 100644
index 0000000000..ce81c6f65a
--- /dev/null
+++ b/src/widgets/widgets/qstackedwidget.h
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSTACKEDWIDGET_H
+#define QSTACKEDWIDGET_H
+
+#include <QtWidgets/qframe.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_STACKEDWIDGET
+
+class QStackedWidgetPrivate;
+
+class Q_GUI_EXPORT QStackedWidget : public QFrame
+{
+ Q_OBJECT
+
+ Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
+ Q_PROPERTY(int count READ count)
+public:
+ explicit QStackedWidget(QWidget *parent=0);
+ ~QStackedWidget();
+
+ int addWidget(QWidget *w);
+ int insertWidget(int index, QWidget *w);
+ void removeWidget(QWidget *w);
+
+ QWidget *currentWidget() const;
+ int currentIndex() const;
+
+ int indexOf(QWidget *) const;
+ QWidget *widget(int) const;
+ int count() const;
+
+public Q_SLOTS:
+ void setCurrentIndex(int index);
+ void setCurrentWidget(QWidget *w);
+
+Q_SIGNALS:
+ void currentChanged(int);
+ void widgetRemoved(int index);
+
+protected:
+ bool event(QEvent *e);
+
+private:
+ Q_DISABLE_COPY(QStackedWidget)
+ Q_DECLARE_PRIVATE(QStackedWidget)
+};
+
+#endif // QT_NO_STACKEDWIDGET
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QSTACKEDWIDGET_H
diff --git a/src/gui/widgets/qstatusbar.cpp b/src/widgets/widgets/qstatusbar.cpp
index ea8ff505e2..ea8ff505e2 100644
--- a/src/gui/widgets/qstatusbar.cpp
+++ b/src/widgets/widgets/qstatusbar.cpp
diff --git a/src/widgets/widgets/qstatusbar.h b/src/widgets/widgets/qstatusbar.h
new file mode 100644
index 0000000000..9cb030e584
--- /dev/null
+++ b/src/widgets/widgets/qstatusbar.h
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSTATUSBAR_H
+#define QSTATUSBAR_H
+
+#include <QtWidgets/qwidget.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_STATUSBAR
+
+class QStatusBarPrivate;
+
+class Q_GUI_EXPORT QStatusBar: public QWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool sizeGripEnabled READ isSizeGripEnabled WRITE setSizeGripEnabled)
+
+public:
+ explicit QStatusBar(QWidget* parent=0);
+ virtual ~QStatusBar();
+
+ void addWidget(QWidget *widget, int stretch = 0);
+ int insertWidget(int index, QWidget *widget, int stretch = 0);
+ void addPermanentWidget(QWidget *widget, int stretch = 0);
+ int insertPermanentWidget(int index, QWidget *widget, int stretch = 0);
+ void removeWidget(QWidget *widget);
+
+ void setSizeGripEnabled(bool);
+ bool isSizeGripEnabled() const;
+
+ QString currentMessage() const;
+
+public Q_SLOTS:
+ void showMessage(const QString &text, int timeout = 0);
+ void clearMessage();
+
+#ifdef QT3_SUPPORT
+public:
+ QT3_SUPPORT_CONSTRUCTOR QStatusBar(QWidget* parent, const char* name);
+ QT3_SUPPORT void addWidget(QWidget *w, int stretch, bool permanent)
+ { if (permanent) addPermanentWidget(w, stretch); else addWidget(w, stretch); }
+public Q_SLOTS:
+ inline QT_MOC_COMPAT void message(const QString &text, int timeout = 0) { showMessage(text, timeout); }
+ inline QT_MOC_COMPAT void clear() { clearMessage(); }
+#endif
+
+Q_SIGNALS:
+ void messageChanged(const QString &text);
+
+protected:
+ void showEvent(QShowEvent *);
+ void paintEvent(QPaintEvent *);
+ void resizeEvent(QResizeEvent *);
+
+ // ### Qt 5: consider making reformat() and hideOrShow() private
+ void reformat();
+ void hideOrShow();
+ bool event(QEvent *);
+
+private:
+ Q_DISABLE_COPY(QStatusBar)
+ Q_DECLARE_PRIVATE(QStatusBar)
+};
+
+#endif // QT_NO_STATUSBAR
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QSTATUSBAR_H
diff --git a/src/gui/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp
index c5d0892122..c5d0892122 100644
--- a/src/gui/widgets/qtabbar.cpp
+++ b/src/widgets/widgets/qtabbar.cpp
diff --git a/src/widgets/widgets/qtabbar.h b/src/widgets/widgets/qtabbar.h
new file mode 100644
index 0000000000..31b766ca5f
--- /dev/null
+++ b/src/widgets/widgets/qtabbar.h
@@ -0,0 +1,226 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTABBAR_H
+#define QTABBAR_H
+
+#include <QtWidgets/qwidget.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_TABBAR
+
+class QIcon;
+class QTabBarPrivate;
+class QStyleOptionTab;
+
+class Q_GUI_EXPORT QTabBar: public QWidget
+{
+ Q_OBJECT
+
+ Q_ENUMS(Shape)
+ Q_PROPERTY(Shape shape READ shape WRITE setShape)
+ Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
+ Q_PROPERTY(int count READ count)
+ Q_PROPERTY(bool drawBase READ drawBase WRITE setDrawBase)
+ Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
+ Q_PROPERTY(Qt::TextElideMode elideMode READ elideMode WRITE setElideMode)
+ Q_PROPERTY(bool usesScrollButtons READ usesScrollButtons WRITE setUsesScrollButtons)
+ Q_PROPERTY(bool tabsClosable READ tabsClosable WRITE setTabsClosable)
+ Q_PROPERTY(SelectionBehavior selectionBehaviorOnRemove READ selectionBehaviorOnRemove WRITE setSelectionBehaviorOnRemove)
+ Q_PROPERTY(bool expanding READ expanding WRITE setExpanding)
+ Q_PROPERTY(bool movable READ isMovable WRITE setMovable)
+ Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode)
+
+public:
+ explicit QTabBar(QWidget* parent=0);
+ ~QTabBar();
+
+ enum Shape { RoundedNorth, RoundedSouth, RoundedWest, RoundedEast,
+ TriangularNorth, TriangularSouth, TriangularWest, TriangularEast
+#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
+ , RoundedAbove = RoundedNorth, RoundedBelow = RoundedSouth,
+ TriangularAbove = TriangularNorth, TriangularBelow = TriangularSouth
+#endif
+ };
+
+ enum ButtonPosition {
+ LeftSide,
+ RightSide
+ };
+
+ enum SelectionBehavior {
+ SelectLeftTab,
+ SelectRightTab,
+ SelectPreviousTab
+ };
+
+ Shape shape() const;
+ void setShape(Shape shape);
+
+ int addTab(const QString &text);
+ int addTab(const QIcon &icon, const QString &text);
+
+ int insertTab(int index, const QString &text);
+ int insertTab(int index, const QIcon&icon, const QString &text);
+
+ void removeTab(int index);
+ void moveTab(int from, int to);
+
+ bool isTabEnabled(int index) const;
+ void setTabEnabled(int index, bool);
+
+ QString tabText(int index) const;
+ void setTabText(int index, const QString &text);
+
+ QColor tabTextColor(int index) const;
+ void setTabTextColor(int index, const QColor &color);
+
+ QIcon tabIcon(int index) const;
+ void setTabIcon(int index, const QIcon &icon);
+
+ Qt::TextElideMode elideMode() const;
+ void setElideMode(Qt::TextElideMode);
+
+#ifndef QT_NO_TOOLTIP
+ void setTabToolTip(int index, const QString &tip);
+ QString tabToolTip(int index) const;
+#endif
+
+#ifndef QT_NO_WHATSTHIS
+ void setTabWhatsThis(int index, const QString &text);
+ QString tabWhatsThis(int index) const;
+#endif
+
+ void setTabData(int index, const QVariant &data);
+ QVariant tabData(int index) const;
+
+ QRect tabRect(int index) const;
+ int tabAt(const QPoint &pos) const;
+
+ int currentIndex() const;
+ int count() const;
+
+ QSize sizeHint() const;
+ QSize minimumSizeHint() const;
+
+ void setDrawBase(bool drawTheBase);
+ bool drawBase() const;
+
+ QSize iconSize() const;
+ void setIconSize(const QSize &size);
+
+ bool usesScrollButtons() const;
+ void setUsesScrollButtons(bool useButtons);
+
+ bool tabsClosable() const;
+ void setTabsClosable(bool closable);
+
+ void setTabButton(int index, ButtonPosition position, QWidget *widget);
+ QWidget *tabButton(int index, ButtonPosition position) const;
+
+ SelectionBehavior selectionBehaviorOnRemove() const;
+ void setSelectionBehaviorOnRemove(SelectionBehavior behavior);
+
+ bool expanding() const;
+ void setExpanding(bool enabled);
+
+ bool isMovable() const;
+ void setMovable(bool movable);
+
+ bool documentMode() const;
+ void setDocumentMode(bool set);
+
+public Q_SLOTS:
+ void setCurrentIndex(int index);
+
+Q_SIGNALS:
+ void currentChanged(int index);
+ void tabCloseRequested(int index);
+ void tabMoved(int from, int to);
+
+protected:
+ virtual QSize tabSizeHint(int index) const;
+ virtual void tabInserted(int index);
+ virtual void tabRemoved(int index);
+ virtual void tabLayoutChange();
+
+ bool event(QEvent *);
+ void resizeEvent(QResizeEvent *);
+ void showEvent(QShowEvent *);
+ void hideEvent(QHideEvent *);
+ void paintEvent(QPaintEvent *);
+ void mousePressEvent (QMouseEvent *);
+ void mouseMoveEvent (QMouseEvent *);
+ void mouseReleaseEvent (QMouseEvent *);
+#ifndef QT_NO_WHEELEVENT
+ void wheelEvent(QWheelEvent *event);
+#endif
+ void keyPressEvent(QKeyEvent *);
+ void changeEvent(QEvent *);
+ void initStyleOption(QStyleOptionTab *option, int tabIndex) const;
+
+#ifdef QT3_SUPPORT
+public Q_SLOTS:
+ QT_MOC_COMPAT void setCurrentTab(int index) { setCurrentIndex(index); }
+Q_SIGNALS:
+ QT_MOC_COMPAT void selected(int);
+#endif
+
+ friend class QAccessibleTabBar;
+private:
+ Q_DISABLE_COPY(QTabBar)
+ Q_DECLARE_PRIVATE(QTabBar)
+ Q_PRIVATE_SLOT(d_func(), void _q_scrollTabs())
+ Q_PRIVATE_SLOT(d_func(), void _q_closeTab())
+};
+
+#endif // QT_NO_TABBAR
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QTABBAR_H
diff --git a/src/gui/widgets/qtabbar_p.h b/src/widgets/widgets/qtabbar_p.h
index 1c94d73184..1c94d73184 100644
--- a/src/gui/widgets/qtabbar_p.h
+++ b/src/widgets/widgets/qtabbar_p.h
diff --git a/src/gui/widgets/qtabwidget.cpp b/src/widgets/widgets/qtabwidget.cpp
index c296b77370..c296b77370 100644
--- a/src/gui/widgets/qtabwidget.cpp
+++ b/src/widgets/widgets/qtabwidget.cpp
diff --git a/src/widgets/widgets/qtabwidget.h b/src/widgets/widgets/qtabwidget.h
new file mode 100644
index 0000000000..cc8d0265f6
--- /dev/null
+++ b/src/widgets/widgets/qtabwidget.h
@@ -0,0 +1,253 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTABWIDGET_H
+#define QTABWIDGET_H
+
+#include <QtWidgets/qwidget.h>
+#include <QtWidgets/qicon.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_TABWIDGET
+
+class QTabBar;
+class QTabWidgetPrivate;
+class QStyleOptionTabWidgetFrame;
+
+class Q_GUI_EXPORT QTabWidget : public QWidget
+{
+ Q_OBJECT
+ Q_ENUMS(TabPosition TabShape)
+ Q_PROPERTY(TabPosition tabPosition READ tabPosition WRITE setTabPosition)
+ Q_PROPERTY(TabShape tabShape READ tabShape WRITE setTabShape)
+ Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
+ Q_PROPERTY(int count READ count)
+ Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize)
+ Q_PROPERTY(Qt::TextElideMode elideMode READ elideMode WRITE setElideMode)
+ Q_PROPERTY(bool usesScrollButtons READ usesScrollButtons WRITE setUsesScrollButtons)
+ Q_PROPERTY(bool documentMode READ documentMode WRITE setDocumentMode)
+ Q_PROPERTY(bool tabsClosable READ tabsClosable WRITE setTabsClosable)
+ Q_PROPERTY(bool movable READ isMovable WRITE setMovable)
+
+public:
+ explicit QTabWidget(QWidget *parent = 0);
+ ~QTabWidget();
+
+ int addTab(QWidget *widget, const QString &);
+ int addTab(QWidget *widget, const QIcon& icon, const QString &label);
+
+ int insertTab(int index, QWidget *widget, const QString &);
+ int insertTab(int index, QWidget *widget, const QIcon& icon, const QString &label);
+
+ void removeTab(int index);
+
+ bool isTabEnabled(int index) const;
+ void setTabEnabled(int index, bool);
+
+ QString tabText(int index) const;
+ void setTabText(int index, const QString &);
+
+ QIcon tabIcon(int index) const;
+ void setTabIcon(int index, const QIcon & icon);
+
+#ifndef QT_NO_TOOLTIP
+ void setTabToolTip(int index, const QString & tip);
+ QString tabToolTip(int index) const;
+#endif
+
+#ifndef QT_NO_WHATSTHIS
+ void setTabWhatsThis(int index, const QString &text);
+ QString tabWhatsThis(int index) const;
+#endif
+
+ int currentIndex() const;
+ QWidget *currentWidget() const;
+ QWidget *widget(int index) const;
+ int indexOf(QWidget *widget) const;
+ int count() const;
+
+ enum TabPosition { North, South, West, East
+#if defined(QT3_SUPPORT) && !defined(Q_MOC_RUN)
+ , Top = North, Bottom = South
+#endif
+ };
+ TabPosition tabPosition() const;
+ void setTabPosition(TabPosition);
+
+ bool tabsClosable() const;
+ void setTabsClosable(bool closeable);
+
+ bool isMovable() const;
+ void setMovable(bool movable);
+
+ enum TabShape { Rounded, Triangular };
+ TabShape tabShape() const;
+ void setTabShape(TabShape s);
+
+ QSize sizeHint() const;
+ QSize minimumSizeHint() const;
+ int heightForWidth(int width) const;
+
+ void setCornerWidget(QWidget * w, Qt::Corner corner = Qt::TopRightCorner);
+ QWidget * cornerWidget(Qt::Corner corner = Qt::TopRightCorner) const;
+
+ Qt::TextElideMode elideMode() const;
+ void setElideMode(Qt::TextElideMode);
+
+ QSize iconSize() const;
+ void setIconSize(const QSize &size);
+
+ bool usesScrollButtons() const;
+ void setUsesScrollButtons(bool useButtons);
+
+ bool documentMode() const;
+ void setDocumentMode(bool set);
+
+ void clear();
+
+public Q_SLOTS:
+ void setCurrentIndex(int index);
+ void setCurrentWidget(QWidget *widget);
+
+Q_SIGNALS:
+ void currentChanged(int index);
+ void tabCloseRequested(int index);
+
+protected:
+ virtual void tabInserted(int index);
+ virtual void tabRemoved(int index);
+
+ void showEvent(QShowEvent *);
+ void resizeEvent(QResizeEvent *);
+ void keyPressEvent(QKeyEvent *);
+ void paintEvent(QPaintEvent *);
+ void setTabBar(QTabBar *);
+ QTabBar* tabBar() const;
+ void changeEvent(QEvent *);
+ bool event(QEvent *);
+ void initStyleOption(QStyleOptionTabWidgetFrame *option) const;
+
+#ifdef QT3_SUPPORT
+public:
+ QT3_SUPPORT_CONSTRUCTOR QTabWidget(QWidget *parent, const char *name, Qt::WindowFlags f = 0);
+
+ inline QT3_SUPPORT void insertTab(QWidget * w, const QString &s, int index = -1) { insertTab(index, w, s); }
+ inline QT3_SUPPORT void insertTab(QWidget *child, const QIcon& icon,
+ const QString &label, int index = -1) { insertTab(index, child, icon, label); }
+
+ inline QT3_SUPPORT void changeTab(QWidget *w, const QString &s) {setTabText(indexOf(w), s); }
+ inline QT3_SUPPORT void changeTab(QWidget *w, const QIcon& icon,
+ const QString &label) { int idx = indexOf(w); setTabText(idx, label); setTabIcon(idx, icon); }
+
+ inline QT3_SUPPORT bool isTabEnabled( QWidget *w) const {return isTabEnabled(indexOf(w)); }
+ inline QT3_SUPPORT void setTabEnabled(QWidget *w, bool b) { setTabEnabled(indexOf(w), b); }
+
+ inline QT3_SUPPORT QString tabLabel(QWidget *w) const {return tabText(indexOf(w)); }
+ inline QT3_SUPPORT void setTabLabel(QWidget *w, const QString &l) { setTabText(indexOf(w), l); }
+
+ inline QT3_SUPPORT QIcon tabIconSet(QWidget * w) const {return tabIcon(indexOf(w)); }
+ inline QT3_SUPPORT void setTabIconSet(QWidget * w, const QIcon & icon) { setTabIcon(indexOf(w), icon); }
+
+ inline QT3_SUPPORT void removeTabToolTip(QWidget * w) {
+#ifndef QT_NO_TOOLTIP
+ setTabToolTip(indexOf(w), QString());
+#else
+ Q_UNUSED(w);
+#endif
+ }
+ inline QT3_SUPPORT void setTabToolTip(QWidget * w, const QString & tip) {
+#ifndef QT_NO_TOOLTIP
+ setTabToolTip(indexOf(w), tip);
+#else
+ Q_UNUSED(w);
+ Q_UNUSED(tip);
+#endif
+ }
+
+ inline QT3_SUPPORT QString tabToolTip(QWidget * w) const {
+#ifndef QT_NO_TOOLTIP
+ return tabToolTip(indexOf(w));
+#else
+ Q_UNUSED(w);
+ return QString();
+#endif
+ }
+
+ inline QT3_SUPPORT QWidget * currentPage() const { return currentWidget(); }
+ inline QT3_SUPPORT QWidget *page(int index) const { return widget(index); }
+ inline QT3_SUPPORT QString label(int index) const { return tabText(index); }
+ inline QT3_SUPPORT int currentPageIndex() const { return currentIndex(); }
+
+ inline QT3_SUPPORT int margin() const { return 0; }
+ inline QT3_SUPPORT void setMargin(int) {}
+
+public Q_SLOTS:
+ inline QT_MOC_COMPAT void setCurrentPage(int index) { setCurrentIndex(index); }
+ inline QT_MOC_COMPAT void showPage(QWidget *w) { setCurrentIndex(indexOf(w)); }
+ inline QT_MOC_COMPAT void removePage(QWidget *w) { removeTab(indexOf(w)); }
+
+Q_SIGNALS:
+ QT_MOC_COMPAT void currentChanged(QWidget *);
+ QT_MOC_COMPAT void selected(const QString&);
+#endif // QT3_SUPPORT
+
+private:
+ Q_DECLARE_PRIVATE(QTabWidget)
+ Q_DISABLE_COPY(QTabWidget)
+ Q_PRIVATE_SLOT(d_func(), void _q_showTab(int))
+ Q_PRIVATE_SLOT(d_func(), void _q_removeTab(int))
+ Q_PRIVATE_SLOT(d_func(), void _q_tabMoved(int, int))
+ void setUpLayout(bool = false);
+ friend class Q3TabDialog;
+};
+
+#endif // QT_NO_TABWIDGET
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QTABWIDGET_H
diff --git a/src/gui/widgets/qtextbrowser.cpp b/src/widgets/widgets/qtextbrowser.cpp
index 2c1fb285c4..2c1fb285c4 100644
--- a/src/gui/widgets/qtextbrowser.cpp
+++ b/src/widgets/widgets/qtextbrowser.cpp
diff --git a/src/widgets/widgets/qtextbrowser.h b/src/widgets/widgets/qtextbrowser.h
new file mode 100644
index 0000000000..eb83820ea5
--- /dev/null
+++ b/src/widgets/widgets/qtextbrowser.h
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTEXTBROWSER_H
+#define QTEXTBROWSER_H
+
+#include <QtWidgets/qtextedit.h>
+#include <QtCore/qurl.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_TEXTBROWSER
+
+class QTextBrowserPrivate;
+
+class Q_GUI_EXPORT QTextBrowser : public QTextEdit
+{
+ Q_OBJECT
+
+ Q_PROPERTY(QUrl source READ source WRITE setSource)
+ Q_OVERRIDE(bool modified SCRIPTABLE false)
+ Q_OVERRIDE(bool readOnly DESIGNABLE false SCRIPTABLE false)
+ Q_OVERRIDE(bool undoRedoEnabled DESIGNABLE false SCRIPTABLE false)
+ Q_PROPERTY(QStringList searchPaths READ searchPaths WRITE setSearchPaths)
+ Q_PROPERTY(bool openExternalLinks READ openExternalLinks WRITE setOpenExternalLinks)
+ Q_PROPERTY(bool openLinks READ openLinks WRITE setOpenLinks)
+
+public:
+ explicit QTextBrowser(QWidget* parent = 0);
+ virtual ~QTextBrowser();
+
+ QUrl source() const;
+
+ QStringList searchPaths() const;
+ void setSearchPaths(const QStringList &paths);
+
+ virtual QVariant loadResource(int type, const QUrl &name);
+
+ bool isBackwardAvailable() const;
+ bool isForwardAvailable() const;
+ void clearHistory();
+ QString historyTitle(int) const;
+ QUrl historyUrl(int) const;
+ int backwardHistoryCount() const;
+ int forwardHistoryCount() const;
+
+ bool openExternalLinks() const;
+ void setOpenExternalLinks(bool open);
+
+ bool openLinks() const;
+ void setOpenLinks(bool open);
+
+public Q_SLOTS:
+ virtual void setSource(const QUrl &name);
+ virtual void backward();
+ virtual void forward();
+ virtual void home();
+ virtual void reload();
+
+Q_SIGNALS:
+ void backwardAvailable(bool);
+ void forwardAvailable(bool);
+ void historyChanged();
+ void sourceChanged(const QUrl &);
+ void highlighted(const QUrl &);
+ void highlighted(const QString &);
+ void anchorClicked(const QUrl &);
+
+protected:
+ bool event(QEvent *e);
+ virtual void keyPressEvent(QKeyEvent *ev);
+ virtual void mouseMoveEvent(QMouseEvent *ev);
+ virtual void mousePressEvent(QMouseEvent *ev);
+ virtual void mouseReleaseEvent(QMouseEvent *ev);
+ virtual void focusOutEvent(QFocusEvent *ev);
+ virtual bool focusNextPrevChild(bool next);
+ virtual void paintEvent(QPaintEvent *e);
+
+#if defined(QT3_SUPPORT)
+public:
+ QT3_SUPPORT_CONSTRUCTOR QTextBrowser(QWidget *parent, const char *name);
+#endif
+
+private:
+ Q_DISABLE_COPY(QTextBrowser)
+ Q_DECLARE_PRIVATE(QTextBrowser)
+ Q_PRIVATE_SLOT(d_func(), void _q_documentModified())
+ Q_PRIVATE_SLOT(d_func(), void _q_activateAnchor(const QString &))
+ Q_PRIVATE_SLOT(d_func(), void _q_highlightLink(const QString &))
+};
+
+#endif // QT_NO_TEXTBROWSER
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QTEXTBROWSER_H
diff --git a/src/gui/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp
index 8df436f932..8df436f932 100644
--- a/src/gui/widgets/qtextedit.cpp
+++ b/src/widgets/widgets/qtextedit.cpp
diff --git a/src/widgets/widgets/qtextedit.h b/src/widgets/widgets/qtextedit.h
new file mode 100644
index 0000000000..59fd7542fa
--- /dev/null
+++ b/src/widgets/widgets/qtextedit.h
@@ -0,0 +1,431 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTEXTEDIT_H
+#define QTEXTEDIT_H
+
+#include <QtWidgets/qabstractscrollarea.h>
+#include <QtGui/qtextdocument.h>
+#include <QtGui/qtextoption.h>
+#include <QtGui/qtextcursor.h>
+#include <QtGui/qtextformat.h>
+
+#ifndef QT_NO_TEXTEDIT
+
+#ifdef QT3_SUPPORT
+#include <QtGui/qtextobject.h>
+#include <QtGui/qtextlayout.h>
+#endif
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+class QStyleSheet;
+class QTextDocument;
+class QMenu;
+class QTextEditPrivate;
+class QMimeData;
+
+class Q_GUI_EXPORT QTextEdit : public QAbstractScrollArea
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QTextEdit)
+ Q_FLAGS(AutoFormatting)
+ Q_ENUMS(LineWrapMode)
+ Q_PROPERTY(AutoFormatting autoFormatting READ autoFormatting WRITE setAutoFormatting)
+ Q_PROPERTY(bool tabChangesFocus READ tabChangesFocus WRITE setTabChangesFocus)
+ Q_PROPERTY(QString documentTitle READ documentTitle WRITE setDocumentTitle)
+ Q_PROPERTY(bool undoRedoEnabled READ isUndoRedoEnabled WRITE setUndoRedoEnabled)
+ Q_PROPERTY(LineWrapMode lineWrapMode READ lineWrapMode WRITE setLineWrapMode)
+ QDOC_PROPERTY(QTextOption::WrapMode wordWrapMode READ wordWrapMode WRITE setWordWrapMode)
+ Q_PROPERTY(int lineWrapColumnOrWidth READ lineWrapColumnOrWidth WRITE setLineWrapColumnOrWidth)
+ Q_PROPERTY(bool readOnly READ isReadOnly WRITE setReadOnly)
+#ifndef QT_NO_TEXTHTMLPARSER
+ Q_PROPERTY(QString html READ toHtml WRITE setHtml NOTIFY textChanged USER true)
+#endif
+ Q_PROPERTY(QString plainText READ toPlainText WRITE setPlainText DESIGNABLE false)
+ Q_PROPERTY(bool overwriteMode READ overwriteMode WRITE setOverwriteMode)
+ Q_PROPERTY(int tabStopWidth READ tabStopWidth WRITE setTabStopWidth)
+ Q_PROPERTY(bool acceptRichText READ acceptRichText WRITE setAcceptRichText)
+ Q_PROPERTY(int cursorWidth READ cursorWidth WRITE setCursorWidth)
+ Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
+ Q_PROPERTY(QObject *document READ document)
+public:
+ enum LineWrapMode {
+ NoWrap,
+ WidgetWidth,
+ FixedPixelWidth,
+ FixedColumnWidth
+ };
+
+ enum AutoFormattingFlag {
+ AutoNone = 0,
+ AutoBulletList = 0x00000001,
+ AutoAll = 0xffffffff
+ };
+
+ Q_DECLARE_FLAGS(AutoFormatting, AutoFormattingFlag)
+
+#if defined(QT3_SUPPORT)
+ enum CursorAction {
+ MoveBackward,
+ MoveForward,
+ MoveWordBackward,
+ MoveWordForward,
+ MoveUp,
+ MoveDown,
+ MoveLineStart,
+ MoveLineEnd,
+ MoveHome,
+ MoveEnd,
+ MovePageUp,
+ MovePageDown
+#if !defined(Q_MOC_RUN)
+ ,
+ MovePgUp = MovePageUp,
+ MovePgDown = MovePageDown
+#endif
+ };
+#endif
+
+ explicit QTextEdit(QWidget *parent = 0);
+ explicit QTextEdit(const QString &text, QWidget *parent = 0);
+ virtual ~QTextEdit();
+
+ void setDocument(QTextDocument *document);
+ QTextDocument *document() const;
+
+ void setTextCursor(const QTextCursor &cursor);
+ QTextCursor textCursor() const;
+
+ bool isReadOnly() const;
+ void setReadOnly(bool ro);
+
+ void setTextInteractionFlags(Qt::TextInteractionFlags flags);
+ Qt::TextInteractionFlags textInteractionFlags() const;
+
+ qreal fontPointSize() const;
+ QString fontFamily() const;
+ int fontWeight() const;
+ bool fontUnderline() const;
+ bool fontItalic() const;
+ QColor textColor() const;
+ QColor textBackgroundColor() const;
+ QFont currentFont() const;
+ Qt::Alignment alignment() const;
+
+ void mergeCurrentCharFormat(const QTextCharFormat &modifier);
+
+ void setCurrentCharFormat(const QTextCharFormat &format);
+ QTextCharFormat currentCharFormat() const;
+
+ AutoFormatting autoFormatting() const;
+ void setAutoFormatting(AutoFormatting features);
+
+ bool tabChangesFocus() const;
+ void setTabChangesFocus(bool b);
+
+ inline void setDocumentTitle(const QString &title)
+ { document()->setMetaInformation(QTextDocument::DocumentTitle, title); }
+ inline QString documentTitle() const
+ { return document()->metaInformation(QTextDocument::DocumentTitle); }
+
+ inline bool isUndoRedoEnabled() const
+ { return document()->isUndoRedoEnabled(); }
+ inline void setUndoRedoEnabled(bool enable)
+ { document()->setUndoRedoEnabled(enable); }
+
+ LineWrapMode lineWrapMode() const;
+ void setLineWrapMode(LineWrapMode mode);
+
+ int lineWrapColumnOrWidth() const;
+ void setLineWrapColumnOrWidth(int w);
+
+ QTextOption::WrapMode wordWrapMode() const;
+ void setWordWrapMode(QTextOption::WrapMode policy);
+
+ bool find(const QString &exp, QTextDocument::FindFlags options = 0);
+
+ inline QString toPlainText() const
+ { return document()->toPlainText(); }
+#ifndef QT_NO_TEXTHTMLPARSER
+ inline QString toHtml() const
+ { return document()->toHtml(); }
+#endif
+
+ void ensureCursorVisible();
+
+ virtual QVariant loadResource(int type, const QUrl &name);
+#ifndef QT_NO_CONTEXTMENU
+ QMenu *createStandardContextMenu();
+ QMenu *createStandardContextMenu(const QPoint &position);
+#endif
+
+ QTextCursor cursorForPosition(const QPoint &pos) const;
+ QRect cursorRect(const QTextCursor &cursor) const;
+ QRect cursorRect() const;
+
+ QString anchorAt(const QPoint& pos) const;
+
+ bool overwriteMode() const;
+ void setOverwriteMode(bool overwrite);
+
+ int tabStopWidth() const;
+ void setTabStopWidth(int width);
+
+ int cursorWidth() const;
+ void setCursorWidth(int width);
+
+ bool acceptRichText() const;
+ void setAcceptRichText(bool accept);
+
+ struct ExtraSelection
+ {
+ QTextCursor cursor;
+ QTextCharFormat format;
+ };
+ void setExtraSelections(const QList<ExtraSelection> &selections);
+ QList<ExtraSelection> extraSelections() const;
+
+ void moveCursor(QTextCursor::MoveOperation operation, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor);
+
+ bool canPaste() const;
+
+#ifndef QT_NO_PRINTER
+ void print(QPrinter *printer) const;
+#endif
+
+public Q_SLOTS:
+ void setFontPointSize(qreal s);
+ void setFontFamily(const QString &fontFamily);
+ void setFontWeight(int w);
+ void setFontUnderline(bool b);
+ void setFontItalic(bool b);
+ void setTextColor(const QColor &c);
+ void setTextBackgroundColor(const QColor &c);
+ void setCurrentFont(const QFont &f);
+ void setAlignment(Qt::Alignment a);
+
+ void setPlainText(const QString &text);
+#ifndef QT_NO_TEXTHTMLPARSER
+ void setHtml(const QString &text);
+#endif
+ void setText(const QString &text);
+
+#ifndef QT_NO_CLIPBOARD
+ void cut();
+ void copy();
+ void paste();
+#endif
+
+ void undo();
+ void redo();
+
+ void clear();
+ void selectAll();
+
+ void insertPlainText(const QString &text);
+#ifndef QT_NO_TEXTHTMLPARSER
+ void insertHtml(const QString &text);
+#endif // QT_NO_TEXTHTMLPARSER
+
+ void append(const QString &text);
+
+ void scrollToAnchor(const QString &name);
+
+ void zoomIn(int range = 1);
+ void zoomOut(int range = 1);
+
+Q_SIGNALS:
+ void textChanged();
+ void undoAvailable(bool b);
+ void redoAvailable(bool b);
+ void currentCharFormatChanged(const QTextCharFormat &format);
+ void copyAvailable(bool b);
+ void selectionChanged();
+ void cursorPositionChanged();
+
+protected:
+ virtual bool event(QEvent *e);
+ virtual void timerEvent(QTimerEvent *e);
+ virtual void keyPressEvent(QKeyEvent *e);
+ virtual void keyReleaseEvent(QKeyEvent *e);
+ virtual void resizeEvent(QResizeEvent *e);
+ virtual void paintEvent(QPaintEvent *e);
+ virtual void mousePressEvent(QMouseEvent *e);
+ virtual void mouseMoveEvent(QMouseEvent *e);
+ virtual void mouseReleaseEvent(QMouseEvent *e);
+ virtual void mouseDoubleClickEvent(QMouseEvent *e);
+ virtual bool focusNextPrevChild(bool next);
+#ifndef QT_NO_CONTEXTMENU
+ virtual void contextMenuEvent(QContextMenuEvent *e);
+#endif
+#ifndef QT_NO_DRAGANDDROP
+ virtual void dragEnterEvent(QDragEnterEvent *e);
+ virtual void dragLeaveEvent(QDragLeaveEvent *e);
+ virtual void dragMoveEvent(QDragMoveEvent *e);
+ virtual void dropEvent(QDropEvent *e);
+#endif
+ virtual void focusInEvent(QFocusEvent *e);
+ virtual void focusOutEvent(QFocusEvent *e);
+ virtual void showEvent(QShowEvent *);
+ virtual void changeEvent(QEvent *e);
+#ifndef QT_NO_WHEELEVENT
+ virtual void wheelEvent(QWheelEvent *e);
+#endif
+
+ virtual QMimeData *createMimeDataFromSelection() const;
+ virtual bool canInsertFromMimeData(const QMimeData *source) const;
+ virtual void insertFromMimeData(const QMimeData *source);
+
+ virtual void inputMethodEvent(QInputMethodEvent *);
+ QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
+
+ QTextEdit(QTextEditPrivate &dd, QWidget *parent);
+
+ virtual void scrollContentsBy(int dx, int dy);
+
+#ifdef QT3_SUPPORT
+Q_SIGNALS:
+ QT_MOC_COMPAT void currentFontChanged(const QFont &f);
+ QT_MOC_COMPAT void currentColorChanged(const QColor &c);
+
+public:
+ QT3_SUPPORT_CONSTRUCTOR QTextEdit(QWidget *parent, const char *name);
+ inline QT3_SUPPORT bool find(const QString &exp, bool cs, bool wo)
+ {
+ QTextDocument::FindFlags flags = 0;
+ if (cs)
+ flags |= QTextDocument::FindCaseSensitively;
+ if (wo)
+ flags |= QTextDocument::FindWholeWords;
+ return find(exp, flags);
+ }
+
+ inline QT3_SUPPORT void sync() {}
+
+ QT3_SUPPORT void moveCursor(CursorAction action, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor);
+ QT3_SUPPORT void moveCursor(CursorAction action, bool select);
+
+ enum KeyboardAction {
+ ActionBackspace,
+ ActionDelete,
+ ActionReturn,
+ ActionKill,
+ ActionWordBackspace,
+ ActionWordDelete
+ };
+
+ QT3_SUPPORT void doKeyboardAction(KeyboardAction action);
+
+ QT3_SUPPORT QString text() const;
+ QT3_SUPPORT void setTextFormat(Qt::TextFormat);
+ QT3_SUPPORT Qt::TextFormat textFormat() const;
+
+ inline QT3_SUPPORT void setBold(bool b) { setFontWeight(b ? QFont::Bold : QFont::Normal); }
+ inline QT3_SUPPORT void setUnderline(bool b) { setFontUnderline(b); }
+ inline QT3_SUPPORT void setItalic(bool i) { setFontItalic(i); }
+ inline QT3_SUPPORT void setFamily(const QString &family) { setFontFamily(family); }
+ inline QT3_SUPPORT void setPointSize(int size) { setFontPointSize(size); }
+
+ inline QT3_SUPPORT bool italic() const { return fontItalic(); }
+ inline QT3_SUPPORT bool bold() const { return fontWeight() >= QFont::Bold; }
+ inline QT3_SUPPORT bool underline() const { return fontUnderline(); }
+ inline QT3_SUPPORT QString family() const { return fontFamily(); }
+ inline QT3_SUPPORT int pointSize() const { return (int)(fontPointSize()+0.5); }
+
+ inline QT3_SUPPORT bool hasSelectedText() const
+ { return textCursor().hasSelection(); }
+ inline QT3_SUPPORT QString selectedText() const
+ { return textCursor().selectedText(); }
+
+ inline QT3_SUPPORT bool isUndoAvailable() const
+ { return document()->isUndoAvailable(); }
+ inline QT3_SUPPORT bool isRedoAvailable() const
+ { return document()->isRedoAvailable(); }
+
+ inline QT3_SUPPORT void insert(const QString &text)
+ { insertPlainText(text); }
+
+ inline QT3_SUPPORT bool isModified() const
+ { return document()->isModified(); }
+
+ inline QT3_SUPPORT QColor color() const
+ { return textColor(); }
+
+public Q_SLOTS:
+ inline QT_MOC_COMPAT void setModified(bool m = true)
+ { document()->setModified(m); }
+public:
+ inline QT3_SUPPORT void undo() const
+ { document()->undo(); }
+ inline QT3_SUPPORT void redo() const
+ { document()->redo(); }
+
+public Q_SLOTS:
+ inline QT_MOC_COMPAT void setColor(const QColor &c)
+ { setTextColor(c); }
+
+#endif
+
+private:
+ Q_DISABLE_COPY(QTextEdit)
+ Q_PRIVATE_SLOT(d_func(), void _q_repaintContents(const QRectF &r))
+ Q_PRIVATE_SLOT(d_func(), void _q_currentCharFormatChanged(const QTextCharFormat &))
+ Q_PRIVATE_SLOT(d_func(), void _q_adjustScrollbars())
+ Q_PRIVATE_SLOT(d_func(), void _q_ensureVisible(const QRectF &))
+ friend class QTextEditControl;
+ friend class QTextDocument;
+ friend class QTextControl;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS(QTextEdit::AutoFormatting)
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QT_NO_TEXTEDIT
+
+#endif // QTEXTEDIT_H
diff --git a/src/widgets/widgets/qtextedit_p.h b/src/widgets/widgets/qtextedit_p.h
new file mode 100644
index 0000000000..fc6b2a96fb
--- /dev/null
+++ b/src/widgets/widgets/qtextedit_p.h
@@ -0,0 +1,141 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTEXTEDIT_P_H
+#define QTEXTEDIT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "private/qabstractscrollarea_p.h"
+#include "QtGui/qtextdocumentfragment.h"
+#include "QtWidgets/qscrollbar.h"
+#include "QtGui/qtextcursor.h"
+#include "QtGui/qtextformat.h"
+#include "QtWidgets/qmenu.h"
+#include "QtGui/qabstracttextdocumentlayout.h"
+#include "QtCore/qbasictimer.h"
+#include "QtCore/qurl.h"
+#include "private/qtextcontrol_p.h"
+#include "qtextedit.h"
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_TEXTEDIT
+
+class QMimeData;
+class QTextEditPrivate : public QAbstractScrollAreaPrivate
+{
+ Q_DECLARE_PUBLIC(QTextEdit)
+public:
+ QTextEditPrivate();
+
+ void init(const QString &html = QString());
+ void paint(QPainter *p, QPaintEvent *e);
+ void _q_repaintContents(const QRectF &contentsRect);
+
+ inline QPoint mapToContents(const QPoint &point) const
+ { return QPoint(point.x() + horizontalOffset(), point.y() + verticalOffset()); }
+
+ void _q_adjustScrollbars();
+ void _q_ensureVisible(const QRectF &rect);
+ void relayoutDocument();
+
+ void createAutoBulletList();
+ void pageUpDown(QTextCursor::MoveOperation op, QTextCursor::MoveMode moveMode);
+
+ inline int horizontalOffset() const
+ { return q_func()->isRightToLeft() ? (hbar->maximum() - hbar->value()) : hbar->value(); }
+ inline int verticalOffset() const
+ { return vbar->value(); }
+
+ inline void sendControlEvent(QEvent *e)
+ { control->processEvent(e, QPointF(horizontalOffset(), verticalOffset()), viewport); }
+
+ void _q_currentCharFormatChanged(const QTextCharFormat &format);
+
+ void updateDefaultTextOption();
+
+ // re-implemented by QTextBrowser, called by QTextDocument::loadResource
+ virtual QUrl resolveUrl(const QUrl &url) const
+ { return url; }
+
+ QTextControl *control;
+
+ QTextEdit::AutoFormatting autoFormatting;
+ bool tabChangesFocus;
+
+ QBasicTimer autoScrollTimer;
+ QPoint autoScrollDragPos;
+
+ QTextEdit::LineWrapMode lineWrap;
+ int lineWrapColumnOrWidth;
+ QTextOption::WrapMode wordWrap;
+
+ uint ignoreAutomaticScrollbarAdjustment : 1;
+ uint preferRichText : 1;
+ uint showCursorOnInitialShow : 1;
+ uint inDrag : 1;
+ uint clickCausedFocus : 1;
+
+ // Qt3 COMPAT only, for setText
+ Qt::TextFormat textFormat;
+
+ QString anchorToScrollToWhenVisible;
+
+#ifdef QT_KEYPAD_NAVIGATION
+ QBasicTimer deleteAllTimer;
+#endif
+};
+#endif // QT_NO_TEXTEDIT
+
+
+QT_END_NAMESPACE
+
+#endif // QTEXTEDIT_P_H
diff --git a/src/gui/widgets/qtoolbar.cpp b/src/widgets/widgets/qtoolbar.cpp
index e19ef69442..e19ef69442 100644
--- a/src/gui/widgets/qtoolbar.cpp
+++ b/src/widgets/widgets/qtoolbar.cpp
diff --git a/src/widgets/widgets/qtoolbar.h b/src/widgets/widgets/qtoolbar.h
new file mode 100644
index 0000000000..290b4d6f59
--- /dev/null
+++ b/src/widgets/widgets/qtoolbar.h
@@ -0,0 +1,188 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDYNAMICTOOLBAR_H
+#define QDYNAMICTOOLBAR_H
+
+#include <QtWidgets/qwidget.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_TOOLBAR
+
+class QToolBarPrivate;
+
+class QAction;
+class QIcon;
+class QMainWindow;
+class QStyleOptionToolBar;
+
+class Q_GUI_EXPORT QToolBar : public QWidget
+{
+ Q_OBJECT
+
+ Q_PROPERTY(bool movable READ isMovable WRITE setMovable
+ DESIGNABLE (qobject_cast<QMainWindow *>(parentWidget()) != 0)
+ NOTIFY movableChanged)
+ Q_PROPERTY(Qt::ToolBarAreas allowedAreas READ allowedAreas WRITE setAllowedAreas
+ DESIGNABLE (qobject_cast<QMainWindow *>(parentWidget()) != 0)
+ NOTIFY allowedAreasChanged)
+ Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation
+ DESIGNABLE (qobject_cast<QMainWindow *>(parentWidget()) == 0)
+ NOTIFY orientationChanged)
+ Q_PROPERTY(QSize iconSize READ iconSize WRITE setIconSize NOTIFY iconSizeChanged)
+ Q_PROPERTY(Qt::ToolButtonStyle toolButtonStyle READ toolButtonStyle WRITE setToolButtonStyle
+ NOTIFY toolButtonStyleChanged)
+ Q_PROPERTY(bool floating READ isFloating)
+ Q_PROPERTY(bool floatable READ isFloatable WRITE setFloatable)
+
+public:
+ explicit QToolBar(const QString &title, QWidget *parent = 0);
+ explicit QToolBar(QWidget *parent = 0);
+ ~QToolBar();
+
+ void setMovable(bool movable);
+ bool isMovable() const;
+
+ void setAllowedAreas(Qt::ToolBarAreas areas);
+ Qt::ToolBarAreas allowedAreas() const;
+
+ inline bool isAreaAllowed(Qt::ToolBarArea area) const
+ { return (allowedAreas() & area) == area; }
+
+ void setOrientation(Qt::Orientation orientation);
+ Qt::Orientation orientation() const;
+
+ void clear();
+
+#ifdef Q_NO_USING_KEYWORD
+ inline void addAction(QAction *action)
+ { QWidget::addAction(action); }
+#else
+ using QWidget::addAction;
+#endif
+
+ QAction *addAction(const QString &text);
+ QAction *addAction(const QIcon &icon, const QString &text);
+ QAction *addAction(const QString &text, const QObject *receiver, const char* member);
+ QAction *addAction(const QIcon &icon, const QString &text,
+ const QObject *receiver, const char* member);
+
+ QAction *addSeparator();
+ QAction *insertSeparator(QAction *before);
+
+ QAction *addWidget(QWidget *widget);
+ QAction *insertWidget(QAction *before, QWidget *widget);
+
+ QRect actionGeometry(QAction *action) const;
+ QAction *actionAt(const QPoint &p) const;
+ inline QAction *actionAt(int x, int y) const;
+
+ QAction *toggleViewAction() const;
+
+ QSize iconSize() const;
+ Qt::ToolButtonStyle toolButtonStyle() const;
+
+ QWidget *widgetForAction(QAction *action) const;
+
+ bool isFloatable() const;
+ void setFloatable(bool floatable);
+ bool isFloating() const;
+
+public Q_SLOTS:
+ void setIconSize(const QSize &iconSize);
+ void setToolButtonStyle(Qt::ToolButtonStyle toolButtonStyle);
+
+Q_SIGNALS:
+ void actionTriggered(QAction *action);
+ void movableChanged(bool movable);
+ void allowedAreasChanged(Qt::ToolBarAreas allowedAreas);
+ void orientationChanged(Qt::Orientation orientation);
+ void iconSizeChanged(const QSize &iconSize);
+ void toolButtonStyleChanged(Qt::ToolButtonStyle toolButtonStyle);
+ void topLevelChanged(bool topLevel);
+ void visibilityChanged(bool visible);
+
+protected:
+ void actionEvent(QActionEvent *event);
+ void changeEvent(QEvent *event);
+ void childEvent(QChildEvent *event);
+ void paintEvent(QPaintEvent *event);
+ void resizeEvent(QResizeEvent *event);
+ bool event(QEvent *event);
+ void initStyleOption(QStyleOptionToolBar *option) const;
+
+#ifdef QT3_SUPPORT
+public:
+ QT3_SUPPORT_CONSTRUCTOR QToolBar(QWidget *parent, const char *name);
+ inline QT3_SUPPORT void setLabel(const QString &label)
+ { setWindowTitle(label); }
+ inline QT3_SUPPORT QString label() const
+ { return windowTitle(); }
+#endif
+
+private:
+ Q_DECLARE_PRIVATE(QToolBar)
+ Q_DISABLE_COPY(QToolBar)
+ Q_PRIVATE_SLOT(d_func(), void _q_toggleView(bool))
+ Q_PRIVATE_SLOT(d_func(), void _q_updateIconSize(const QSize &))
+ Q_PRIVATE_SLOT(d_func(), void _q_updateToolButtonStyle(Qt::ToolButtonStyle))
+
+ friend class QMainWindow;
+ friend class QMainWindowLayout;
+ friend class QToolBarLayout;
+ friend class QToolBarAreaLayout;
+};
+
+inline QAction *QToolBar::actionAt(int ax, int ay) const
+{ return actionAt(QPoint(ax, ay)); }
+
+#endif // QT_NO_TOOLBAR
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDYNAMICTOOLBAR_H
diff --git a/src/widgets/widgets/qtoolbar_p.h b/src/widgets/widgets/qtoolbar_p.h
new file mode 100644
index 0000000000..8159f3381e
--- /dev/null
+++ b/src/widgets/widgets/qtoolbar_p.h
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDYNAMICTOOLBAR_P_H
+#define QDYNAMICTOOLBAR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qtoolbar.h"
+#include "QtWidgets/qaction.h"
+#include "private/qwidget_p.h"
+#include <QtCore/qbasictimer.h>
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_TOOLBAR
+
+class QToolBarLayout;
+class QTimer;
+
+class QToolBarPrivate : public QWidgetPrivate
+{
+ Q_DECLARE_PUBLIC(QToolBar)
+
+public:
+ inline QToolBarPrivate()
+ : explicitIconSize(false), explicitToolButtonStyle(false), movable(true), floatable(true),
+ allowedAreas(Qt::AllToolBarAreas), orientation(Qt::Horizontal),
+ toolButtonStyle(Qt::ToolButtonIconOnly),
+ layout(0), state(0)
+#ifdef Q_WS_MAC
+ , macWindowDragging(false)
+#endif
+ { }
+
+ void init();
+ void actionTriggered();
+ void _q_toggleView(bool b);
+ void _q_updateIconSize(const QSize &sz);
+ void _q_updateToolButtonStyle(Qt::ToolButtonStyle style);
+
+ bool explicitIconSize;
+ bool explicitToolButtonStyle;
+ bool movable;
+ bool floatable;
+ Qt::ToolBarAreas allowedAreas;
+ Qt::Orientation orientation;
+ Qt::ToolButtonStyle toolButtonStyle;
+ QSize iconSize;
+
+ QAction *toggleViewAction;
+
+ QToolBarLayout *layout;
+
+ struct DragState {
+ QPoint pressPos;
+ bool dragging;
+ bool moving;
+ QLayoutItem *widgetItem;
+ };
+ DragState *state;
+
+#ifdef Q_WS_MAC
+ bool macWindowDragging;
+ QPoint macWindowDragPressPosition;
+#endif
+
+ bool mousePressEvent(QMouseEvent *e);
+ bool mouseReleaseEvent(QMouseEvent *e);
+ bool mouseMoveEvent(QMouseEvent *e);
+
+ void updateWindowFlags(bool floating, bool unplug = false);
+ void setWindowState(bool floating, bool unplug = false, const QRect &rect = QRect());
+ void initDrag(const QPoint &pos);
+ void startDrag(bool moving = false);
+ void endDrag();
+
+ void unplug(const QRect &r);
+ void plug(const QRect &r);
+
+ QBasicTimer waitForPopupTimer;
+};
+
+#endif // QT_NO_TOOLBAR
+
+QT_END_NAMESPACE
+
+#endif // QDYNAMICTOOLBAR_P_H
diff --git a/src/gui/widgets/qtoolbararealayout.cpp b/src/widgets/widgets/qtoolbararealayout.cpp
index 05986e4ac5..05986e4ac5 100644
--- a/src/gui/widgets/qtoolbararealayout.cpp
+++ b/src/widgets/widgets/qtoolbararealayout.cpp
diff --git a/src/gui/widgets/qtoolbararealayout_p.h b/src/widgets/widgets/qtoolbararealayout_p.h
index cace88b2ed..cace88b2ed 100644
--- a/src/gui/widgets/qtoolbararealayout_p.h
+++ b/src/widgets/widgets/qtoolbararealayout_p.h
diff --git a/src/gui/widgets/qtoolbarextension.cpp b/src/widgets/widgets/qtoolbarextension.cpp
index 720c153d0f..720c153d0f 100644
--- a/src/gui/widgets/qtoolbarextension.cpp
+++ b/src/widgets/widgets/qtoolbarextension.cpp
diff --git a/src/widgets/widgets/qtoolbarextension_p.h b/src/widgets/widgets/qtoolbarextension_p.h
new file mode 100644
index 0000000000..eb529343d7
--- /dev/null
+++ b/src/widgets/widgets/qtoolbarextension_p.h
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDYNAMICTOOLBAREXTENSION_P_H
+#define QDYNAMICTOOLBAREXTENSION_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "QtWidgets/qtoolbutton.h"
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_TOOLBUTTON
+
+class Q_AUTOTEST_EXPORT QToolBarExtension : public QToolButton
+{
+ Q_OBJECT
+ Qt::Orientation orientation;
+
+public:
+ explicit QToolBarExtension(QWidget *parent);
+ void paintEvent(QPaintEvent *);
+ QSize sizeHint() const;
+
+public Q_SLOTS:
+ void setOrientation(Qt::Orientation o);
+};
+
+#endif // QT_NO_TOOLBUTTON
+
+QT_END_NAMESPACE
+
+#endif // QDYNAMICTOOLBAREXTENSION_P_H
diff --git a/src/gui/widgets/qtoolbarlayout.cpp b/src/widgets/widgets/qtoolbarlayout.cpp
index 531acb453f..531acb453f 100644
--- a/src/gui/widgets/qtoolbarlayout.cpp
+++ b/src/widgets/widgets/qtoolbarlayout.cpp
diff --git a/src/widgets/widgets/qtoolbarlayout_p.h b/src/widgets/widgets/qtoolbarlayout_p.h
new file mode 100644
index 0000000000..47ea08d14f
--- /dev/null
+++ b/src/widgets/widgets/qtoolbarlayout_p.h
@@ -0,0 +1,134 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTOOLBARLAYOUT_P_H
+#define QTOOLBARLAYOUT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtWidgets/qlayout.h>
+#include <private/qlayoutengine_p.h>
+#include <QVector>
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_TOOLBAR
+
+class QAction;
+class QToolBarExtension;
+class QMenu;
+
+class QToolBarItem : public QWidgetItem
+{
+public:
+ QToolBarItem(QWidget *widget);
+ bool isEmpty() const;
+
+ QAction *action;
+ bool customWidget;
+};
+
+class QToolBarLayout : public QLayout
+{
+ Q_OBJECT
+
+public:
+ QToolBarLayout(QWidget *parent = 0);
+ ~QToolBarLayout();
+
+ void addItem(QLayoutItem *item);
+ QLayoutItem *itemAt(int index) const;
+ QLayoutItem *takeAt(int index);
+ int count() const;
+
+ bool isEmpty() const;
+ void invalidate();
+ Qt::Orientations expandingDirections() const;
+
+ void setGeometry(const QRect &r);
+ QSize minimumSize() const;
+ QSize sizeHint() const;
+
+ void insertAction(int index, QAction *action);
+ int indexOf(QAction *action) const;
+ int indexOf(QWidget *widget) const { return QLayout::indexOf(widget); }
+
+ bool layoutActions(const QSize &size);
+ QSize expandedSize(const QSize &size) const;
+ bool expanded, animating;
+
+ void setUsePopupMenu(bool set); // Yeah, there's no getter, but it's internal.
+ void checkUsePopupMenu();
+
+ bool movable() const;
+ void updateMarginAndSpacing();
+ bool hasExpandFlag() const;
+
+public Q_SLOTS:
+ void setExpanded(bool b);
+
+private:
+ QList<QToolBarItem*> items;
+ QSize hint, minSize;
+ bool dirty, expanding, empty, expandFlag;
+ QVector<QLayoutStruct> geomArray;
+ QRect handRect;
+ QToolBarExtension *extension;
+
+ void updateGeomArray() const;
+ QToolBarItem *createItem(QAction *action);
+ QMenu *popupMenu;
+};
+
+#endif // QT_NO_TOOLBAR
+
+QT_END_NAMESPACE
+
+#endif // QTOOLBARLAYOUT_P_H
diff --git a/src/gui/widgets/qtoolbarseparator.cpp b/src/widgets/widgets/qtoolbarseparator.cpp
index 9ce523a48d..9ce523a48d 100644
--- a/src/gui/widgets/qtoolbarseparator.cpp
+++ b/src/widgets/widgets/qtoolbarseparator.cpp
diff --git a/src/widgets/widgets/qtoolbarseparator_p.h b/src/widgets/widgets/qtoolbarseparator_p.h
new file mode 100644
index 0000000000..b90f3d201f
--- /dev/null
+++ b/src/widgets/widgets/qtoolbarseparator_p.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDYNAMICTOOLBARSEPARATOR_P_H
+#define QDYNAMICTOOLBARSEPARATOR_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "QtWidgets/qwidget.h"
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_NO_TOOLBAR
+
+class QStyleOption;
+class QToolBar;
+
+class QToolBarSeparator : public QWidget
+{
+ Q_OBJECT
+ Qt::Orientation orient;
+
+public:
+ explicit QToolBarSeparator(QToolBar *parent);
+
+ Qt::Orientation orientation() const;
+
+ QSize sizeHint() const;
+
+ void paintEvent(QPaintEvent *);
+ void initStyleOption(QStyleOption *option) const;
+
+public Q_SLOTS:
+ void setOrientation(Qt::Orientation orientation);
+};
+
+#endif // QT_NO_TOOLBAR
+
+QT_END_NAMESPACE
+
+#endif // QDYNAMICTOOLBARSEPARATOR_P_H
diff --git a/src/gui/widgets/qtoolbox.cpp b/src/widgets/widgets/qtoolbox.cpp
index 1d0a26740b..1d0a26740b 100644
--- a/src/gui/widgets/qtoolbox.cpp
+++ b/src/widgets/widgets/qtoolbox.cpp
diff --git a/src/widgets/widgets/qtoolbox.h b/src/widgets/widgets/qtoolbox.h
new file mode 100644
index 0000000000..f4b8980719
--- /dev/null
+++ b/src/widgets/widgets/qtoolbox.h
@@ -0,0 +1,148 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTOOLBOX_H
+#define QTOOLBOX_H
+
+#include <QtWidgets/qframe.h>
+#include <QtWidgets/qicon.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_TOOLBOX
+
+class QToolBoxPrivate;
+
+class Q_GUI_EXPORT QToolBox : public QFrame
+{
+ Q_OBJECT
+ Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentChanged)
+ Q_PROPERTY(int count READ count)
+
+public:
+ explicit QToolBox(QWidget *parent = 0, Qt::WindowFlags f = 0);
+ ~QToolBox();
+
+ int addItem(QWidget *widget, const QString &text);
+ int addItem(QWidget *widget, const QIcon &icon, const QString &text);
+ int insertItem(int index, QWidget *widget, const QString &text);
+ int insertItem(int index, QWidget *widget, const QIcon &icon, const QString &text);
+
+ void removeItem(int index);
+
+ void setItemEnabled(int index, bool enabled);
+ bool isItemEnabled(int index) const;
+
+ void setItemText(int index, const QString &text);
+ QString itemText(int index) const;
+
+ void setItemIcon(int index, const QIcon &icon);
+ QIcon itemIcon(int index) const;
+
+#ifndef QT_NO_TOOLTIP
+ void setItemToolTip(int index, const QString &toolTip);
+ QString itemToolTip(int index) const;
+#endif
+
+ int currentIndex() const;
+ QWidget *currentWidget() const;
+ QWidget *widget(int index) const;
+ int indexOf(QWidget *widget) const;
+ int count() const;
+
+public Q_SLOTS:
+ void setCurrentIndex(int index);
+ void setCurrentWidget(QWidget *widget);
+
+Q_SIGNALS:
+ void currentChanged(int index);
+
+protected:
+ bool event(QEvent *e);
+ virtual void itemInserted(int index);
+ virtual void itemRemoved(int index);
+ void showEvent(QShowEvent *e);
+ void changeEvent(QEvent *);
+
+#ifdef QT3_SUPPORT
+public:
+ QT3_SUPPORT_CONSTRUCTOR QToolBox(QWidget *parent, const char *name, Qt::WindowFlags f = 0);
+ inline QT3_SUPPORT void setItemLabel(int index, const QString &text) { setItemText(index, text); }
+ inline QT3_SUPPORT QString itemLabel(int index) const { return itemText(index); }
+ inline QT3_SUPPORT QWidget *currentItem() const { return widget(currentIndex()); }
+ inline QT3_SUPPORT void setCurrentItem(QWidget *item) { setCurrentIndex(indexOf(item)); }
+ inline QT3_SUPPORT void setItemIconSet(int index, const QIcon &icon) { setItemIcon(index, icon); }
+ inline QT3_SUPPORT QIcon itemIconSet(int index) const { return itemIcon(index); }
+ inline QT3_SUPPORT int removeItem(QWidget *item)
+ { int i = indexOf(item); removeItem(i); return i; }
+ inline QT3_SUPPORT QWidget *item(int index) const { return widget(index); }
+ QT3_SUPPORT void setMargin(int margin) { setContentsMargins(margin, margin, margin, margin); }
+ QT3_SUPPORT int margin() const
+ { int margin; int dummy; getContentsMargins(&margin, &dummy, &dummy, &dummy); return margin; }
+#endif
+
+private:
+ Q_DECLARE_PRIVATE(QToolBox)
+ Q_DISABLE_COPY(QToolBox)
+ Q_PRIVATE_SLOT(d_func(), void _q_buttonClicked())
+ Q_PRIVATE_SLOT(d_func(), void _q_widgetDestroyed(QObject*))
+};
+
+
+inline int QToolBox::addItem(QWidget *item, const QString &text)
+{ return insertItem(-1, item, QIcon(), text); }
+inline int QToolBox::addItem(QWidget *item, const QIcon &iconSet,
+ const QString &text)
+{ return insertItem(-1, item, iconSet, text); }
+inline int QToolBox::insertItem(int index, QWidget *item, const QString &text)
+{ return insertItem(index, item, QIcon(), text); }
+
+#endif // QT_NO_TOOLBOX
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QTOOLBOX_H
diff --git a/src/gui/widgets/qtoolbutton.cpp b/src/widgets/widgets/qtoolbutton.cpp
index 2c9f15cfd9..2c9f15cfd9 100644
--- a/src/gui/widgets/qtoolbutton.cpp
+++ b/src/widgets/widgets/qtoolbutton.cpp
diff --git a/src/widgets/widgets/qtoolbutton.h b/src/widgets/widgets/qtoolbutton.h
new file mode 100644
index 0000000000..b89c0d0daa
--- /dev/null
+++ b/src/widgets/widgets/qtoolbutton.h
@@ -0,0 +1,199 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTOOLBUTTON_H
+#define QTOOLBUTTON_H
+
+#include <QtWidgets/qabstractbutton.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_TOOLBUTTON
+
+class QToolButtonPrivate;
+class QMenu;
+class QStyleOptionToolButton;
+
+class Q_GUI_EXPORT QToolButton : public QAbstractButton
+{
+ Q_OBJECT
+ Q_ENUMS(Qt::ToolButtonStyle Qt::ArrowType ToolButtonPopupMode)
+#ifndef QT_NO_MENU
+ Q_PROPERTY(ToolButtonPopupMode popupMode READ popupMode WRITE setPopupMode)
+#endif
+ Q_PROPERTY(Qt::ToolButtonStyle toolButtonStyle READ toolButtonStyle WRITE setToolButtonStyle)
+ Q_PROPERTY(bool autoRaise READ autoRaise WRITE setAutoRaise)
+ Q_PROPERTY(Qt::ArrowType arrowType READ arrowType WRITE setArrowType)
+
+public:
+ enum ToolButtonPopupMode {
+ DelayedPopup,
+ MenuButtonPopup,
+ InstantPopup
+ };
+
+ explicit QToolButton(QWidget * parent=0);
+ ~QToolButton();
+
+ QSize sizeHint() const;
+ QSize minimumSizeHint() const;
+
+ Qt::ToolButtonStyle toolButtonStyle() const;
+
+ Qt::ArrowType arrowType() const;
+ void setArrowType(Qt::ArrowType type);
+
+#ifndef QT_NO_MENU
+ void setMenu(QMenu* menu);
+ QMenu* menu() const;
+
+ void setPopupMode(ToolButtonPopupMode mode);
+ ToolButtonPopupMode popupMode() const;
+#endif
+
+ QAction *defaultAction() const;
+
+ void setAutoRaise(bool enable);
+ bool autoRaise() const;
+
+public Q_SLOTS:
+#ifndef QT_NO_MENU
+ void showMenu();
+#endif
+ void setToolButtonStyle(Qt::ToolButtonStyle style);
+ void setDefaultAction(QAction *);
+
+Q_SIGNALS:
+ void triggered(QAction *);
+
+protected:
+ QToolButton(QToolButtonPrivate &, QWidget* parent);
+ bool event(QEvent *e);
+ void mousePressEvent(QMouseEvent *);
+ void mouseReleaseEvent(QMouseEvent *);
+ void paintEvent(QPaintEvent *);
+ void actionEvent(QActionEvent *);
+
+ void enterEvent(QEvent *);
+ void leaveEvent(QEvent *);
+ void timerEvent(QTimerEvent *);
+ void changeEvent(QEvent *);
+
+ bool hitButton(const QPoint &pos) const;
+ void nextCheckState();
+ void initStyleOption(QStyleOptionToolButton *option) const;
+
+private:
+ Q_DISABLE_COPY(QToolButton)
+ Q_DECLARE_PRIVATE(QToolButton)
+#ifndef QT_NO_MENU
+ Q_PRIVATE_SLOT(d_func(), void _q_buttonPressed())
+ Q_PRIVATE_SLOT(d_func(), void _q_updateButtonDown())
+ Q_PRIVATE_SLOT(d_func(), void _q_menuTriggered(QAction*))
+#endif
+ Q_PRIVATE_SLOT(d_func(), void _q_actionTriggered())
+
+#ifdef QT3_SUPPORT
+public:
+ enum TextPosition {
+ BesideIcon,
+ BelowIcon
+ , Right = BesideIcon,
+ Under = BelowIcon
+ };
+
+ QT3_SUPPORT_CONSTRUCTOR QToolButton(QWidget * parent, const char* name);
+ QT3_SUPPORT_CONSTRUCTOR QToolButton(Qt::ArrowType type, QWidget *parent, const char* name);
+ QT3_SUPPORT_CONSTRUCTOR QToolButton( const QIcon& s, const QString &textLabel,
+ const QString& grouptext,
+ QObject * receiver, const char* slot,
+ QWidget * parent, const char* name=0 );
+ inline QT3_SUPPORT void setPixmap(const QPixmap &pixmap) { setIcon(static_cast<QIcon>(pixmap)); }
+ QT3_SUPPORT void setOnIconSet(const QIcon&);
+ QT3_SUPPORT void setOffIconSet(const QIcon&);
+ inline QT3_SUPPORT void setIconSet(const QIcon &icon){setIcon(icon);}
+ QT3_SUPPORT void setIconSet(const QIcon &, bool on);
+ inline QT3_SUPPORT void setTextLabel(const QString &text, bool tooltip = true) {
+ setText(text);
+#ifndef QT_NO_TOOLTIP
+ if (tooltip)
+ setToolTip(text);
+#else
+ Q_UNUSED(tooltip);
+#endif
+ }
+ inline QT3_SUPPORT QString textLabel() const { return text(); }
+ QT3_SUPPORT QIcon onIconSet() const;
+ QT3_SUPPORT QIcon offIconSet() const;
+ QT3_SUPPORT QIcon iconSet(bool on) const;
+ inline QT3_SUPPORT QIcon iconSet() const { return icon(); }
+ inline QT3_SUPPORT void openPopup() { showMenu(); }
+ inline QT3_SUPPORT void setPopup(QMenu* popup) {setMenu(popup); }
+ inline QT3_SUPPORT QMenu* popup() const { return menu(); }
+ inline QT3_SUPPORT bool usesBigPixmap() const { return iconSize().height() > 22; }
+ inline QT3_SUPPORT bool usesTextLabel() const { return toolButtonStyle() != Qt::ToolButtonIconOnly; }
+ inline QT3_SUPPORT TextPosition textPosition() const
+ { return toolButtonStyle() == Qt::ToolButtonTextUnderIcon ? BelowIcon : BesideIcon; }
+ QT3_SUPPORT void setPopupDelay(int delay);
+ QT3_SUPPORT int popupDelay() const;
+
+public Q_SLOTS:
+ QT_MOC_COMPAT void setUsesBigPixmap(bool enable)
+ { setIconSize(enable?QSize(32,32):QSize(22,22)); }
+ QT_MOC_COMPAT void setUsesTextLabel(bool enable)
+ { setToolButtonStyle(enable?Qt::ToolButtonTextUnderIcon : Qt::ToolButtonIconOnly); }
+ QT_MOC_COMPAT void setTextPosition(QToolButton::TextPosition pos)
+ { setToolButtonStyle(pos == BesideIcon ? Qt::ToolButtonTextBesideIcon : Qt::ToolButtonTextUnderIcon); }
+
+#endif
+};
+
+#endif // QT_NO_TOOLBUTTON
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QTOOLBUTTON_H
diff --git a/src/widgets/widgets/qwidgetanimator.cpp b/src/widgets/widgets/qwidgetanimator.cpp
new file mode 100644
index 0000000000..4df14098ae
--- /dev/null
+++ b/src/widgets/widgets/qwidgetanimator.cpp
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore/qpropertyanimation.h>
+#include <QtWidgets/qwidget.h>
+#include <private/qmainwindowlayout_p.h>
+
+#include "qwidgetanimator_p.h"
+
+QT_BEGIN_NAMESPACE
+
+QWidgetAnimator::QWidgetAnimator(QMainWindowLayout *layout) : m_mainWindowLayout(layout)
+{
+}
+
+void QWidgetAnimator::abort(QWidget *w)
+{
+#ifndef QT_NO_ANIMATION
+ AnimationMap::iterator it = m_animation_map.find(w);
+ if (it == m_animation_map.end())
+ return;
+ QPropertyAnimation *anim = *it;
+ m_animation_map.erase(it);
+ anim->stop();
+#ifndef QT_NO_MAINWINDOW
+ m_mainWindowLayout->animationFinished(w);
+#endif
+#else
+ Q_UNUSED(w); //there is no animation to abort
+#endif //QT_NO_ANIMATION
+}
+
+#ifndef QT_NO_ANIMATION
+void QWidgetAnimator::animationFinished()
+{
+ QPropertyAnimation *anim = qobject_cast<QPropertyAnimation*>(sender());
+ abort(static_cast<QWidget*>(anim->targetObject()));
+}
+#endif //QT_NO_ANIMATION
+
+void QWidgetAnimator::animate(QWidget *widget, const QRect &_final_geometry, bool animate)
+{
+ QRect r = widget->geometry();
+ if (r.right() < 0 || r.bottom() < 0)
+ r = QRect();
+
+ animate = animate && !r.isNull() && !_final_geometry.isNull();
+
+ // might make the wigdet go away by sending it to negative space
+ const QRect final_geometry = _final_geometry.isValid() || widget->isWindow() ? _final_geometry :
+ QRect(QPoint(-500 - widget->width(), -500 - widget->height()), widget->size());
+
+#ifndef QT_NO_ANIMATION
+ AnimationMap::const_iterator it = m_animation_map.constFind(widget);
+ if (it != m_animation_map.constEnd() && (*it)->endValue().toRect() == final_geometry)
+ return;
+
+ QPropertyAnimation *anim = new QPropertyAnimation(widget, "geometry", widget);
+ anim->setDuration(animate ? 200 : 0);
+ anim->setEasingCurve(QEasingCurve::InOutQuad);
+ anim->setEndValue(final_geometry);
+ m_animation_map[widget] = anim;
+ connect(anim, SIGNAL(finished()), SLOT(animationFinished()));
+ anim->start(QPropertyAnimation::DeleteWhenStopped);
+#else
+ //we do it in one shot
+ widget->setGeometry(final_geometry);
+#ifndef QT_NO_MAINWINDOW
+ m_mainWindowLayout->animationFinished(widget);
+#endif //QT_NO_MAINWINDOW
+#endif //QT_NO_ANIMATION
+}
+
+bool QWidgetAnimator::animating() const
+{
+ return !m_animation_map.isEmpty();
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/widgets/qwidgetanimator_p.h b/src/widgets/widgets/qwidgetanimator_p.h
index 37201c3207..37201c3207 100644
--- a/src/gui/widgets/qwidgetanimator_p.h
+++ b/src/widgets/widgets/qwidgetanimator_p.h
diff --git a/src/gui/widgets/qwidgetresizehandler.cpp b/src/widgets/widgets/qwidgetresizehandler.cpp
index 2d459ec1f0..2d459ec1f0 100644
--- a/src/gui/widgets/qwidgetresizehandler.cpp
+++ b/src/widgets/widgets/qwidgetresizehandler.cpp
diff --git a/src/gui/widgets/qwidgetresizehandler_p.h b/src/widgets/widgets/qwidgetresizehandler_p.h
index 25ac361a4d..25ac361a4d 100644
--- a/src/gui/widgets/qwidgetresizehandler_p.h
+++ b/src/widgets/widgets/qwidgetresizehandler_p.h
diff --git a/src/gui/widgets/qworkspace.cpp b/src/widgets/widgets/qworkspace.cpp
index 13ef13b2fe..13ef13b2fe 100644
--- a/src/gui/widgets/qworkspace.cpp
+++ b/src/widgets/widgets/qworkspace.cpp
diff --git a/src/widgets/widgets/qworkspace.h b/src/widgets/widgets/qworkspace.h
new file mode 100644
index 0000000000..af8b2eae2d
--- /dev/null
+++ b/src/widgets/widgets/qworkspace.h
@@ -0,0 +1,137 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtGui module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QWORKSPACE_H
+#define QWORKSPACE_H
+
+#include <QtWidgets/qwidget.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Gui)
+
+#ifndef QT_NO_WORKSPACE
+
+class QAction;
+class QWorkspaceChild;
+class QShowEvent;
+class QWorkspacePrivate;
+
+class Q_GUI_EXPORT QWorkspace : public QWidget
+{
+ Q_OBJECT
+ Q_PROPERTY(bool scrollBarsEnabled READ scrollBarsEnabled WRITE setScrollBarsEnabled)
+ Q_PROPERTY(QBrush background READ background WRITE setBackground)
+
+public:
+ explicit QWorkspace(QWidget* parent=0);
+ ~QWorkspace();
+
+ enum WindowOrder { CreationOrder, StackingOrder };
+
+ QWidget* activeWindow() const;
+ QWidgetList windowList(WindowOrder order = CreationOrder) const;
+
+ QWidget * addWindow(QWidget *w, Qt::WindowFlags flags = 0);
+
+ QSize sizeHint() const;
+
+ bool scrollBarsEnabled() const;
+ void setScrollBarsEnabled(bool enable);
+
+#ifdef QT3_SUPPORT
+ QT3_SUPPORT_CONSTRUCTOR QWorkspace(QWidget* parent, const char* name);
+ QT3_SUPPORT void setPaletteBackgroundColor(const QColor &);
+ QT3_SUPPORT void setPaletteBackgroundPixmap(const QPixmap &);
+#endif
+
+ void setBackground(const QBrush &background);
+ QBrush background() const;
+
+Q_SIGNALS:
+ void windowActivated(QWidget* w);
+
+public Q_SLOTS:
+ void setActiveWindow(QWidget *w);
+ void cascade();
+ void tile();
+ void arrangeIcons();
+ void closeActiveWindow();
+ void closeAllWindows();
+ void activateNextWindow();
+ void activatePreviousWindow();
+
+protected:
+ bool event(QEvent *e);
+ void paintEvent(QPaintEvent *e);
+ void changeEvent(QEvent *);
+ void childEvent(QChildEvent *);
+ void resizeEvent(QResizeEvent *);
+ bool eventFilter(QObject *, QEvent *);
+ void showEvent(QShowEvent *e);
+ void hideEvent(QHideEvent *e);
+#ifndef QT_NO_WHEELEVENT
+ void wheelEvent(QWheelEvent *e);
+#endif
+
+private:
+ Q_DECLARE_PRIVATE(QWorkspace)
+ Q_DISABLE_COPY(QWorkspace)
+ Q_PRIVATE_SLOT(d_func(), void _q_normalizeActiveWindow())
+ Q_PRIVATE_SLOT(d_func(), void _q_minimizeActiveWindow())
+ Q_PRIVATE_SLOT(d_func(), void _q_showOperationMenu())
+ Q_PRIVATE_SLOT(d_func(), void _q_popupOperationMenu(const QPoint&))
+ Q_PRIVATE_SLOT(d_func(), void _q_operationMenuActivated(QAction *))
+ Q_PRIVATE_SLOT(d_func(), void _q_updateActions())
+ Q_PRIVATE_SLOT(d_func(), void _q_scrollBarChanged())
+
+ friend class QWorkspaceChild;
+};
+
+#endif // QT_NO_WORKSPACE
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QWORKSPACE_H
diff --git a/src/widgets/widgets/widgets.pri b/src/widgets/widgets/widgets.pri
new file mode 100644
index 0000000000..a991ff1fac
--- /dev/null
+++ b/src/widgets/widgets/widgets.pri
@@ -0,0 +1,165 @@
+# Qt widgets module
+
+HEADERS += \
+ widgets/qbuttongroup.h \
+ widgets/qabstractbutton.h \
+ widgets/qabstractbutton_p.h \
+ widgets/qabstractslider.h \
+ widgets/qabstractslider_p.h \
+ widgets/qabstractspinbox.h \
+ widgets/qabstractspinbox_p.h \
+ widgets/qcalendartextnavigator_p.h \
+ widgets/qcalendarwidget.h \
+ widgets/qcheckbox.h \
+ widgets/qcombobox.h \
+ widgets/qcombobox_p.h \
+ widgets/qcommandlinkbutton.h \
+ widgets/qdatetimeedit.h \
+ widgets/qdatetimeedit_p.h \
+ widgets/qdial.h \
+ widgets/qdialogbuttonbox.h \
+ widgets/qdockwidget.h \
+ widgets/qdockwidget_p.h \
+ widgets/qdockarealayout_p.h \
+ widgets/qfontcombobox.h \
+ widgets/qframe.h \
+ widgets/qframe_p.h \
+ widgets/qgroupbox.h \
+ widgets/qlabel.h \
+ widgets/qlabel_p.h \
+ widgets/qlcdnumber.h \
+ widgets/qlineedit.h \
+ widgets/qlineedit_p.h \
+ widgets/qmainwindow.h \
+ widgets/qmainwindowlayout_p.h \
+ widgets/qmdiarea.h \
+ widgets/qmdiarea_p.h \
+ widgets/qmdisubwindow.h \
+ widgets/qmdisubwindow_p.h \
+ widgets/qmenu.h \
+ widgets/qmenu_p.h \
+ widgets/qmenubar.h \
+ widgets/qmenubar_p.h \
+ widgets/qmenudata.h \
+ widgets/qprogressbar.h \
+ widgets/qpushbutton.h \
+ widgets/qpushbutton_p.h \
+ widgets/qradiobutton.h \
+ widgets/qrubberband.h \
+ widgets/qscrollbar.h \
+ widgets/qscrollarea_p.h \
+ widgets/qsizegrip.h \
+ widgets/qslider.h \
+ widgets/qspinbox.h \
+ widgets/qsplashscreen.h \
+ widgets/qsplitter.h \
+ widgets/qsplitter_p.h \
+ widgets/qstackedwidget.h \
+ widgets/qstatusbar.h \
+ widgets/qtabbar.h \
+ widgets/qtabbar_p.h \
+ widgets/qtabwidget.h \
+ widgets/qtextedit.h \
+ widgets/qtextedit_p.h \
+ widgets/qtextbrowser.h \
+ widgets/qtoolbar.h \
+ widgets/qtoolbar_p.h \
+ widgets/qtoolbarlayout_p.h \
+ widgets/qtoolbarextension_p.h \
+ widgets/qtoolbarseparator_p.h \
+ widgets/qtoolbox.h \
+ widgets/qtoolbutton.h \
+ widgets/qabstractscrollarea.h \
+ widgets/qabstractscrollarea_p.h \
+ widgets/qwidgetresizehandler_p.h \
+ widgets/qfocusframe.h \
+ widgets/qscrollarea.h \
+ widgets/qworkspace.h \
+ widgets/qwidgetanimator_p.h \
+ widgets/qtoolbararealayout_p.h \
+ widgets/qplaintextedit.h \
+ widgets/qplaintextedit_p.h \
+ widgets/qprintpreviewwidget.h
+SOURCES += \
+ widgets/qabstractbutton.cpp \
+ widgets/qabstractslider.cpp \
+ widgets/qabstractspinbox.cpp \
+ widgets/qcalendarwidget.cpp \
+ widgets/qcheckbox.cpp \
+ widgets/qcombobox.cpp \
+ widgets/qcommandlinkbutton.cpp \
+ widgets/qdatetimeedit.cpp \
+ widgets/qdial.cpp \
+ widgets/qdialogbuttonbox.cpp \
+ widgets/qdockwidget.cpp \
+ widgets/qdockarealayout.cpp \
+ widgets/qeffects.cpp \
+ widgets/qfontcombobox.cpp \
+ widgets/qframe.cpp \
+ widgets/qgroupbox.cpp \
+ widgets/qlabel.cpp \
+ widgets/qlcdnumber.cpp \
+ widgets/qlineedit_p.cpp \
+ widgets/qlineedit.cpp \
+ widgets/qmainwindow.cpp \
+ widgets/qmainwindowlayout.cpp \
+ widgets/qmdiarea.cpp \
+ widgets/qmdisubwindow.cpp \
+ widgets/qmenu.cpp \
+ widgets/qmenubar.cpp \
+ widgets/qmenudata.cpp \
+ widgets/qprogressbar.cpp \
+ widgets/qpushbutton.cpp \
+ widgets/qradiobutton.cpp \
+ widgets/qrubberband.cpp \
+ widgets/qscrollbar.cpp \
+ widgets/qsizegrip.cpp \
+ widgets/qslider.cpp \
+ widgets/qspinbox.cpp \
+ widgets/qsplashscreen.cpp \
+ widgets/qsplitter.cpp \
+ widgets/qstackedwidget.cpp \
+ widgets/qstatusbar.cpp \
+ widgets/qtabbar.cpp \
+ widgets/qtabwidget.cpp \
+ widgets/qtextedit.cpp \
+ widgets/qtextbrowser.cpp \
+ widgets/qtoolbar.cpp \
+ widgets/qtoolbarlayout.cpp \
+ widgets/qtoolbarextension.cpp \
+ widgets/qtoolbarseparator.cpp \
+ widgets/qtoolbox.cpp \
+ widgets/qtoolbutton.cpp \
+ widgets/qabstractscrollarea.cpp \
+ widgets/qwidgetresizehandler.cpp \
+ widgets/qfocusframe.cpp \
+ widgets/qscrollarea.cpp \
+ widgets/qworkspace.cpp \
+ widgets/qwidgetanimator.cpp \
+ widgets/qtoolbararealayout.cpp \
+ widgets/qplaintextedit.cpp \
+ widgets/qprintpreviewwidget.cpp
+
+!qpa:mac {
+ HEADERS += widgets/qmacnativewidget_mac.h \
+ widgets/qmaccocoaviewcontainer_mac.h
+ OBJECTIVE_HEADERS += widgets/qcocoatoolbardelegate_mac_p.h \
+ widgets/qcocoamenu_mac_p.h
+ OBJECTIVE_SOURCES += widgets/qmenu_mac.mm \
+ widgets/qmaccocoaviewcontainer_mac.mm \
+ widgets/qcocoatoolbardelegate_mac.mm \
+ widgets/qmainwindowlayout_mac.mm \
+ widgets/qmacnativewidget_mac.mm \
+ widgets/qcocoamenu_mac.mm
+}
+
+wince*: {
+ SOURCES += widgets/qmenu_wince.cpp
+ HEADERS += widgets/qmenu_wince_resource_p.h
+ RC_FILE = widgets/qmenu_wince.rc
+ !static: QMAKE_WRITE_DEFAULT_RC = 1
+}
+
+symbian: {
+ SOURCES += widgets/qmenu_symbian.cpp
+}
diff --git a/sync.profile b/sync.profile
index 8d838041f2..d0627b5c02 100644
--- a/sync.profile
+++ b/sync.profile
@@ -1,7 +1,7 @@
%modules = ( # path to module name map
"QtGui" => "$basedir/src/gui",
+ "QtWidgets" => "$basedir/src/widgets",
"QtOpenGL" => "$basedir/src/opengl",
- "QtOpenVG" => "$basedir/src/openvg",
"QtCore" => "$basedir/src/corelib",
"QtXml" => "$basedir/src/xml",
"QtSql" => "$basedir/src/sql",
@@ -32,9 +32,9 @@
%mastercontent = (
"core" => "#include <QtCore/QtCore>\n",
"gui" => "#include <QtGui/QtGui>\n",
+ "widgets" => "#include <QtWidgets/QtWidgets>\n",
"network" => "#include <QtNetwork/QtNetwork>\n",
"opengl" => "#include <QtOpenGL/QtOpenGL>\n",
- "openvg" => "#include <QtOpenVG/QtOpenVG>\n",
"xml" => "#include <QtXml/QtXml>\n",
"uitools" => "#include <QtUiTools/QtUiTools>\n",
"designer" => "#include <QtDesigner/QtDesigner>\n",
@@ -43,9 +43,9 @@
"QtCore" => "$basedir/src/modules/qt_core.pri",
"QtDBus" => "$basedir/src/modules/qt_dbus.pri",
"QtGui" => "$basedir/src/modules/qt_gui.pri",
+ "QtWidgets" => "$basedir/src/modules/qt_widgets.pri",
"QtNetwork" => "$basedir/src/modules/qt_network.pri",
"QtOpenGL" => "$basedir/src/modules/qt_opengl.pri",
- "QtOpenVG" => "$basedir/src/modules/qt_openvg.pri",
"QtSql" => "$basedir/src/modules/qt_sql.pri",
"QtTest" => "$basedir/src/modules/qt_testlib.pri",
"QtXml" => "$basedir/src/modules/qt_xml.pri",
@@ -65,15 +65,12 @@
# - "LATEST_RELEASE", to always test against the latest public release.
# - "THIS_REPOSITORY", to indicate that the module is in this repository.
%dependencies = (
- "QtOpenVG" => {
- "QtCore" => "THIS_REPOSITORY",
- "QtGui" => "THIS_REPOSITORY",
- },
"QtCore" => {
},
"QtOpenGL" => {
"QtCore" => "THIS_REPOSITORY",
"QtGui" => "THIS_REPOSITORY",
+ "QtWidgets" => "THIS_REPOSITORY",
},
"QtXml" => {
"QtCore" => "THIS_REPOSITORY",
@@ -94,8 +91,13 @@
"QtGui" => {
"QtCore" => "THIS_REPOSITORY",
},
+ "QtWidgets" => {
+ "QtCore" => "THIS_REPOSITORY",
+ "QtGui" => "THIS_REPOSITORY",
+ },
"QtUiTools" => {
"QtCore" => "THIS_REPOSITORY",
"QtGui" => "THIS_REPOSITORY",
+ "QtWidgets" => "THIS_REPOSITORY",
},
);
diff --git a/tests/auto/qmetatype/tst_qmetatype.cpp b/tests/auto/qmetatype/tst_qmetatype.cpp
index 67bbac217a..9872682f89 100644
--- a/tests/auto/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/qmetatype/tst_qmetatype.cpp
@@ -224,7 +224,6 @@ void tst_QMetaType::typeName_data()
QTest::newRow("double") << QMetaType::Double << "double";
QTest::newRow("qlonglong") << QMetaType::LongLong << "qlonglong";
QTest::newRow("QRegExp") << QMetaType::QRegExp << "QRegExp";
- QTest::newRow("QColorGroup") << QMetaType::Type(63) << "QColorGroup";
QTest::newRow("void*") << QMetaType::VoidStar << "void*";
QTest::newRow("ulong") << QMetaType::ULong << "ulong";
QTest::newRow("QWidget*") << QMetaType::QWidgetStar << "QWidget*";
diff --git a/tests/auto/qvariant/tst_qvariant.cpp b/tests/auto/qvariant/tst_qvariant.cpp
index 6ebe84ea4e..d3438ca3d1 100644
--- a/tests/auto/qvariant/tst_qvariant.cpp
+++ b/tests/auto/qvariant/tst_qvariant.cpp
@@ -2028,10 +2028,6 @@ void tst_QVariant::typeName_data()
QTest::newRow("9") << int(QVariant::Size) << QByteArray("QSize");
QTest::newRow("10") << int(QVariant::Color) << QByteArray("QColor");
QTest::newRow("11") << int(QVariant::Palette) << QByteArray("QPalette");
-#ifdef QT3_SUPPORT
- QTest::newRow("12") << int(QVariant::ColorGroup) << QByteArray("QColorGroup");
- QTest::newRow("13") << int(QVariant::IconSet) << QByteArray("QIcon");
-#endif
QTest::newRow("14") << int(QVariant::Point) << QByteArray("QPoint");
QTest::newRow("15") << int(QVariant::Image) << QByteArray("QImage");
QTest::newRow("16") << int(QVariant::Int) << QByteArray("int");
diff --git a/tools/uilib/abstractformbuilder.cpp b/tools/uilib/abstractformbuilder.cpp
index 4d142bd09f..a221b6c748 100644
--- a/tools/uilib/abstractformbuilder.cpp
+++ b/tools/uilib/abstractformbuilder.cpp
@@ -55,48 +55,14 @@
#include <QtCore/qdebug.h>
#include <QtCore/QCoreApplication>
-#include <QtGui/QAction>
-#include <QtGui/QActionGroup>
-#include <QtGui/QButtonGroup>
-#include <QtGui/QComboBox>
-#include <QtGui/QFontComboBox>
-#include <QtGui/QGridLayout>
-#ifndef QT_NO_FORMLAYOUT
-# include <QtGui/QFormLayout>
-#endif
-#include <QtGui/QIcon>
-#include <QtGui/QListWidget>
-#include <QtGui/QMainWindow>
-#include <QtGui/QPixmap>
-#include <QtGui/QStatusBar>
-#include <QtGui/QTreeWidget>
-#include <QtGui/QTableWidget>
-#include <QtGui/QWidget>
-#include <QtGui/QSplitter>
-#include <QtGui/QScrollArea>
-#include <QtGui/QAbstractButton>
-#include <QtGui/QAbstractItemView>
-#include <QtGui/QHeaderView>
+#include <QtGui/QtGui>
+#include <QtWidgets/QtWidgets>
#ifndef QFORMINTERNAL_NAMESPACE
# include <private/qlayout_p.h> // Compiling within Designer
#endif
#include <QtXml/QXmlStreamReader>
-#include <QtGui/QDialog>
-
-// containers
-#include <QtGui/QToolBox>
-#include <QtGui/QStackedWidget>
-#include <QtGui/QTabWidget>
-#include <QtGui/QToolBar>
-#include <QtGui/QMenuBar>
-#include <QtGui/QDockWidget>
-#include <QtGui/QMdiArea>
-#include <QtGui/QWorkspace>
-#include <QtGui/QWizard>
-#include <QtGui/QWizardPage>
-
#include <QtCore/qdebug.h>
#include <limits.h>
diff --git a/tools/uilib/abstractformbuilder.h b/tools/uilib/abstractformbuilder.h
index 4c22570932..9d53e2d4b7 100644
--- a/tools/uilib/abstractformbuilder.h
+++ b/tools/uilib/abstractformbuilder.h
@@ -49,7 +49,7 @@
#include <QtCore/QDir>
#include <QtCore/QScopedPointer>
-#include <QtGui/QSizePolicy>
+#include <QtWidgets/QSizePolicy>
#include <QtGui/QPalette>
QT_BEGIN_HEADER
diff --git a/tools/uilib/customwidget.h b/tools/uilib/customwidget.h
index 0a04c93c6d..915cb9d706 100644
--- a/tools/uilib/customwidget.h
+++ b/tools/uilib/customwidget.h
@@ -45,7 +45,7 @@
#include "extension.h"
#include <QtCore/QObject>
#include <QtCore/QString>
-#include <QtGui/QIcon>
+#include <QtWidgets/QIcon>
QT_BEGIN_HEADER
diff --git a/tools/uilib/formbuilder.cpp b/tools/uilib/formbuilder.cpp
index 6e8ebcb975..67d3a8db95 100644
--- a/tools/uilib/formbuilder.cpp
+++ b/tools/uilib/formbuilder.cpp
@@ -45,6 +45,7 @@
#include "ui4_p.h"
#include <QtGui/QtGui>
+#include <QtWidgets/QtWidgets>
#include <QtCore/QCoreApplication>
QT_BEGIN_NAMESPACE
diff --git a/tools/uilib/formbuilderextra.cpp b/tools/uilib/formbuilderextra.cpp
index 12e43f1e38..bca0c595e5 100644
--- a/tools/uilib/formbuilderextra.cpp
+++ b/tools/uilib/formbuilderextra.cpp
@@ -45,9 +45,9 @@
#include "textbuilder_p.h"
#include "ui4_p.h"
-#include <QtGui/QLabel>
-#include <QtGui/QBoxLayout>
-#include <QtGui/QGridLayout>
+#include <QtWidgets/QLabel>
+#include <QtWidgets/QBoxLayout>
+#include <QtWidgets/QGridLayout>
#include <QtCore/QVariant>
#include <QtCore/qdebug.h>
diff --git a/tools/uilib/formscriptrunner.cpp b/tools/uilib/formscriptrunner.cpp
index e349f6b318..fdc4201aec 100644
--- a/tools/uilib/formscriptrunner.cpp
+++ b/tools/uilib/formscriptrunner.cpp
@@ -44,7 +44,7 @@
#include "ui4_p.h"
#include <QtScript/QScriptEngine>
-#include <QtGui/QWidget>
+#include <QtWidgets/QWidget>
#include <QtCore/QDebug>
#include <QtCore/QCoreApplication>
diff --git a/tools/uilib/properties.cpp b/tools/uilib/properties.cpp
index 67f4d11d22..9bf530b84c 100644
--- a/tools/uilib/properties.cpp
+++ b/tools/uilib/properties.cpp
@@ -49,11 +49,11 @@
#include <QtCore/QUrl>
#include <QtCore/qdebug.h>
-#include <QtGui/QIcon>
+#include <QtWidgets/QIcon>
#include <QtGui/QPixmap>
#include <QtGui/QFont>
-#include <QtGui/QFrame>
-#include <QtGui/QAbstractScrollArea>
+#include <QtWidgets/QFrame>
+#include <QtWidgets/QAbstractScrollArea>
QT_BEGIN_NAMESPACE
diff --git a/tools/uilib/properties_p.h b/tools/uilib/properties_p.h
index e57f9ed2ed..89e19ae43b 100644
--- a/tools/uilib/properties_p.h
+++ b/tools/uilib/properties_p.h
@@ -60,7 +60,7 @@
#include <QtCore/QLocale>
#include <QtCore/QCoreApplication>
-#include <QtGui/QWidget>
+#include <QtWidgets/QWidget>
#include "formbuilderextra_p.h"
diff --git a/tools/uilib/resourcebuilder.cpp b/tools/uilib/resourcebuilder.cpp
index 0ea5d4cf75..3d59ef2c23 100644
--- a/tools/uilib/resourcebuilder.cpp
+++ b/tools/uilib/resourcebuilder.cpp
@@ -46,7 +46,7 @@
#include <QtCore/QDir>
#include <QtCore/QDebug>
#include <QtGui/QPixmap>
-#include <QtGui/QIcon>
+#include <QtWidgets/QIcon>
QT_BEGIN_NAMESPACE